@datagrok/hit-triage 1.3.3 → 1.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/README_HD.md +8 -0
- package/dist/package.js +1 -1
- package/dist/package.js.map +1 -1
- package/package.json +1 -1
- package/src/app/consts.ts +13 -5
- package/src/app/hit-design-app.ts +17 -11
- package/src/app/hit-design-views/info-view.ts +44 -6
- package/src/app/hit-design-views/submit-view.ts +41 -5
- package/src/app/hit-design-views/utils.css +4 -0
- package/src/app/pepti-hit-app.ts +1 -1
- package/src/app/pepti-hits-views/info-view.ts +1 -1
- package/src/app/types.ts +1 -1
- package/src/app/utils.ts +82 -2
package/dist/package.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var hittriage;(()=>{var e={233:e=>{!function(){"use strict";var t=document,i=window,n=t.documentElement,o=t.createElement.bind(t),a=o("div"),s=o("table"),r=o("tbody"),l=o("tr"),c=Array.isArray,u=Array.prototype,d=u.concat,p=u.filter,h=u.indexOf,m=u.map,v=u.push,f=u.slice,g=u.some,y=u.splice,w=/^#(?:[\w-]|\\.|[^\x00-\xa0])*$/,b=/^\.(?:[\w-]|\\.|[^\x00-\xa0])*$/,C=/<.+>/,A=/^\w+$/;function T(e,t){var i,n=!!(i=t)&&11===i.nodeType;return e&&(n||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(N(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):N(a)?a.find(e):O(a)?S(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}(),E=x.prototype,S=E.init;function N(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 B(e){return null===e}function k(e){return!isNaN(parseFloat(e))&&isFinite(e)}function L(e){if("object"!=typeof e||null===e)return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function j(e,t,i){if(i){for(var n=e.length;n--;)if(!1===t.call(e[n],n,e[n]))return e}else if(L(e))for(var o=Object.keys(e),a=(n=0,o.length);n<a;n++){var s=o[n];if(!1===t.call(e[s],s,e[s]))return e}else for(n=0,a=e.length;n<a;n++)if(!1===t.call(e[n],n,e[n]))return e;return e}function M(){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 M(i,S,n);for(var a=0;a<o;a++){var s=e[a];for(var r in s)i&&(c(s[r])||L(s[r]))?(n[r]&&n[r].constructor===s[r].constructor||(n[r]=new s[r].constructor),M(i,n[r],s[r])):n[r]=s[r]}return n}S.fn=S.prototype=E,E.length=0,E.splice=y,"function"==typeof Symbol&&(E[Symbol.iterator]=u[Symbol.iterator]),S.isWindow=I,S.isFunction=P,S.isArray=c,S.isNumeric=k,S.isPlainObject=L,S.each=j,E.each=function(e){return j(this,e)},E.empty=function(){return this.each((function(e,t){for(;t.firstChild;)t.removeChild(t.firstChild)}))},S.extend=M,E.extend=function(e){return M(E,e)};var R=/\S+/g;function D(e){return O(e)&&e.match(R)||[]}function U(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(U(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"))}E.toggleClass=function(e,t){var i=D(e),n=!V(t);return this.each((function(e,o){_(o)&&j(i,(function(e,i){n?t?o.classList.add(i):o.classList.remove(i):o.classList.toggle(i)}))}))},E.addClass=function(e){return this.toggleClass(e,!0)},E.removeAttr=function(e){var t=D(e);return this.each((function(e,i){_(i)&&j(t,(function(e,t){i.removeAttribute(t)}))}))},E.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 B(i)?void 0:i}return V(t)?this:B(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}},E.removeClass=function(e){return arguments.length?this.toggleClass(e,!1):this.attr("class","")},E.hasClass=function(e){return!!e&&g.call(this,(function(t){return _(t)&&t.classList.contains(e)}))},E.get=function(e){return V(e)?f.call(this):this[(e=Number(e))<0?e+this.length:e]},E.eq=function(e){return S(this.get(e))},E.first=function(){return this.eq(0)},E.last=function(){return this.eq(-1)},E.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"===U(e,"display")}function W(e,t){var i=e&&(e.matches||e.webkitMatchesSelector||e.msMatchesSelector);return!!i&&!!t&&i.call(e,t)}function G(e){return O(e)?function(t,i){return W(i,e)}:P(e)?e:N(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}E.filter=function(e){var t=G(e);return S(p.call(this,(function(e,i){return t.call(e,i,e)})))},E.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,S(i.childNodes).detach().get()}function X(e,t,i,n){for(var o=[],a=P(t),s=n&&G(n),r=0,l=e.length;r<l;r++)if(a){var c=t(e[r]);c.length&&v.apply(o,c)}else for(var u=e[r][t];!(null==u||n&&s(-1,u));)o.push(u),u=i?u[t]:null;return o}function ee(e){return e.multiple&&e.options?X(p.call(e.options,(function(e){return e.selected&&!e.disabled&&!e.parentNode.disabled})),"value"):e.value||""}function te(e){return e.length>1?p.call(e,(function(e,t,i){return h.call(i,e)===t})):e}S.parseHTML=Z,E.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)},E.not=function(e){var t=G(e);return this.filter((function(i,n){return(!O(e)||_(n))&&!t.call(n,i,n)}))},E.val=function(e){return arguments.length?this.each((function(t,i){var n=i.multiple&&i.options;if(n||Oe.test(i.type)){var o=c(e)?m.call(e,String):B(e)?[]:[String(e)];n?j(i.options,(function(e,t){t.selected=o.indexOf(t.value)>=0}),!0):i.checked=o.indexOf(i.value)>=0}else i.value=V(e)||B(e)?"":e})):this[0]&&ee(this[0])},E.is=function(e){var t=G(e);return g.call(this,(function(e,i){return t.call(e,i,e)}))},S.guid=1,S.unique=te,E.add=function(e,t){return S(te(this.get().concat(S(e,t).get())))},E.children=function(e){return J(S(te(X(this,(function(e){return e.children})))),e)},E.parent=function(e){return J(S(te(X(this,"parentNode"))),e)},E.index=function(e){var t=e?S(e)[0]:this[0],i=e?this:S(t).parent().children();return h.call(i,t)},E.closest=function(e){var t=this.filter(e);if(t.length)return t;var i=this.parent();return i.length?i.closest(e):t},E.siblings=function(e){return J(S(te(X(this,(function(e){return S(e).parent().children().not(e)})))),e)},E.find=function(e){return S(te(X(this,(function(t){return T(e,t)}))))};var ie=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,ne=/^$|^module$|\/(java|ecma)script/i,oe=["type","src","nonce","noModule"];function ae(e,t,i,a,s,r,l,c){return j(e,(function(e,r){j(S(r),(function(e,r){j(S(t),(function(t,l){var c=i?l:r,u=i?e:t;!function(e,t,i,a,s){a?e.insertBefore(t,i?e.firstChild:null):"HTML"===e.nodeName?e.parentNode.replaceChild(t,e):e.parentNode.insertBefore(t,i?e:e.nextSibling),s&&function(e,t){var i=S(e);i.filter("script").add(i.find("script")).each((function(e,i){if(ne.test(i.type)&&n.contains(i)){var a=o("script");a.text=i.textContent.replace(ie,""),j(oe,(function(e,t){i[t]&&(a[t]=i[t])})),t.head.insertBefore(a,null),t.head.removeChild(a)}}))}(t,e.ownerDocument)}(i?r:l,u?c.cloneNode(!0):c,a,s,!u)}),c)}),l)}),r),t}E.after=function(){return ae(arguments,this,!1,!1,!1,!0,!0)},E.append=function(){return ae(arguments,this,!1,!1,!0)},E.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?S(n).empty().append(e):n.innerHTML=e)}))},E.appendTo=function(e){return ae(arguments,this,!0,!1,!0)},E.wrapInner=function(e){return this.each((function(t,i){var n=S(i),o=n.contents();o.length?o.wrapAll(e):n.append(e)}))},E.before=function(){return ae(arguments,this,!1,!0)},E.wrapAll=function(e){for(var t=S(e),i=t[0];i.children.length;)i=i.firstElementChild;return this.first().before(t),this.appendTo(i)},E.wrap=function(e){return this.each((function(t,i){var n=S(e)[0];S(i).wrapAll(t?n.cloneNode(!0):n)}))},E.insertAfter=function(e){return ae(arguments,this,!0,!1,!1,!1,!1,!0)},E.insertBefore=function(e){return ae(arguments,this,!0,!0)},E.prepend=function(){return ae(arguments,this,!1,!0,!0,!0,!0)},E.prependTo=function(e){return ae(arguments,this,!0,!0,!0,!1,!1,!0)},E.contents=function(){return S(te(X(this,(function(e){return"IFRAME"===e.tagName?[e.contentDocument]:"TEMPLATE"===e.tagName?e.content.childNodes:e.childNodes}))))},E.next=function(e,t,i){return J(S(te(X(this,"nextElementSibling",t,i))),e)},E.nextAll=function(e){return this.next(e,!0)},E.nextUntil=function(e,t){return this.next(t,!0,e)},E.parents=function(e,t){return J(S(te(X(this,"parentElement",!0,t))),e)},E.parentsUntil=function(e,t){return this.parents(t,e)},E.prev=function(e,t,i){return J(S(te(X(this,"previousElementSibling",t,i))),e)},E.prevAll=function(e){return this.prev(e,!0)},E.prevUntil=function(e,t){return this.prev(t,!0,e)},E.map=function(e){return S(d.apply([],m.call(this,(function(t,i){return e.call(t,i,t)}))))},E.clone=function(){return this.map((function(e,t){return t.cloneNode(!0)}))},E.offsetParent=function(){return this.map((function(e,t){for(var i=t.offsetParent;i&&"static"===U(i,"position");)i=i.offsetParent;return i||n}))},E.slice=function(e,t){return S(f.call(this,e,t))};var se=/-([a-z])/g;function re(e){return e.replace(se,(function(e,t){return t.toUpperCase()}))}E.ready=function(e){var i=function(){return setTimeout(e,0,S)};return"loading"!==t.readyState?i():t.addEventListener("DOMContentLoaded",i),this},E.unwrap=function(){return this.parent().each((function(e,t){if("BODY"!==t.tagName){var i=S(t);i.replaceWith(i.children())}})),this},E.offset=function(){var e=this[0];if(e){var t=e.getBoundingClientRect();return{top:t.top+i.pageYOffset,left:t.left+i.pageXOffset}}},E.position=function(){var e=this[0];if(e){var t="fixed"===U(e,"position"),i=t?e.getBoundingClientRect():this.offset();if(!t){for(var n=e.ownerDocument,o=e.offsetParent||n.documentElement;(o===n.body||o===n.documentElement)&&"static"===U(o,"position");)o=o.parentNode;if(o!==e&&_(o)){var a=S(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"};E.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}},E.removeProp=function(e){return this.each((function(t,i){delete i[le[e]||e]}))};var ce=/^--/;function ue(e){return ce.test(e)}var de={},pe=a.style,he=["webkit","moz","ms"],me={animationIterationCount:!0,columnCount:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,gridArea:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnStart:!0,gridRow:!0,gridRowEnd:!0,gridRowStart:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0};function ve(e,t,i){return void 0===i&&(i=ue(e)),i||me[e]||!k(t)?t:"".concat(t,"px")}function fe(e,t){try{return e(t)}catch(e){return t}}E.css=function(e,t){if(O(e)){var i=ue(e);return e=function(e,t){if(void 0===t&&(t=ue(e)),t)return e;if(!de[e]){var i=re(e),n="".concat(i[0].toUpperCase()).concat(i.slice(1));j("".concat(i," ").concat(he.join("".concat(n," "))).concat(n).split(" "),(function(t,i){if(i in pe)return de[e]=i,!1}))}return de[e]}(e,i),arguments.length<2?this[0]&&U(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)])}E.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},j([!0,!1],(function(e,t){j(["Width","Height"],(function(e,i){var n="".concat(t?"outer":"inner").concat(i);E[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)}}))})),j(["Width","Height"],(function(e,t){var i=t.toLowerCase();E[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=U(n,"boxSizing");n.style[i]=ve(i,o+("border-box"===a?H(n,!e):0))}}))}}));var be="___cd";E.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=U(i,"display");return t.body.removeChild(i),q[e]="none"!==n?n:"block"}(n.tagName))):a||(n[be]=U(n,"display"),n.style.display="none")}}))},E.hide=function(){return this.toggle(!1)},E.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 Ee(e){return Te[e]||Ae[e]||e}function Se(e){var t=e.split(".");return[t[0],t.slice(1).sort()]}function Ne(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=Ne(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)}E.trigger=function(e,i){if(O(e)){var n=Se(e),o=n[0],a=n[1],s=Ee(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)}))},E.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=""),j(D(e),(function(e,o){var a=Se(o),s=a[0],r=a[1],l=Ee(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},E.remove=function(e){return J(this,e).detach().off(),this},E.replaceWith=function(e){return this.before(e).remove()},E.replaceAll=function(e){return S(e).replaceWith(this),this},E.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)||B(t)?t="":V(i)?(i=t,t=""):(n=i,i=t,t="")),P(n)||(n=i,i=void 0),n?(j(D(e),(function(e,s){var r=Se(s),l=r[0],c=r[1],u=Ee(l),d=l in Te,p=l in Ae;u&&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(c,e.namespace.split(".")))&&(t||!(p&&(e.target!==a||e.___ot===u)||d&&e.relatedTarget&&a.contains(e.relatedTarget)))){var r=a;if(t){for(var l=e.target;!W(l,t);){if(l===a)return;if(!(l=l.parentNode))return}r=l}Object.defineProperty(e,"currentTarget",{configurable:!0,get:function(){return r}}),Object.defineProperty(e,"delegateTarget",{configurable:!0,get:function(){return a}}),Object.defineProperty(e,"data",{configurable:!0,get:function(){return i}});var h=n.call(r,e,e.___td);o&&Fe(a,u,c,t,s),!1===h&&(e.preventDefault(),e.stopPropagation())}};s.guid=n.guid=n.guid||S.guid++,function(e,t,i,n,o){var a=Ne(e);a[t]=a[t]||[],a[t].push([i,n,o]),e.addEventListener(t,o)}(a,u,c,t,s)}}))})),this):this},E.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;E.serialize=function(){var e="";return this.each((function(t,i){j(i.elements||[i],(function(t,i){if(!(i.disabled||!i.name||"FIELDSET"===i.tagName||Pe.test(i.type)||Oe.test(i.type)&&!i.checked)){var n=ee(i);V(n)||j(c(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=S}()},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}","",{version:3,sources:["webpack://./src/app/hit-design-views/utils.css"],names:[],mappings:"AAAA;IACI,eAAe;AACnB;;AAEA;IACI,yBAAyB;AAC7B",sourcesContent:["img[alt='hitDesignReadmeImg'] {\n max-width: 100%;\n}\n\n.hit-design-stage-editing-dialog {\n z-index: 10000 !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 c=0;c<e.length;c++){var u=[].concat(e[c]);n&&s[u[0]]||(void 0!==a&&(void 0===u[5]||(u[1]="@layer".concat(u[5].length>0?" ".concat(u[5]):""," {").concat(u[1],"}")),u[5]=a),i&&(u[2]?(u[1]="@media ".concat(u[2]," {").concat(u[1],"}"),u[2]=i):u[2]=i),o&&(u[4]?(u[1]="@supports (".concat(u[4],") {").concat(u[1],"}"),u[4]=o):u[4]="".concat(o)),t.push(u))}},t}},354:e=>{"use strict";e.exports=function(e){var t=e[1],i=e[3];if(!i)return t;if("function"==typeof btoa){var n=btoa(unescape(encodeURIComponent(JSON.stringify(i)))),o="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(n),a="/*# ".concat(o," */");return[t].concat([a]).join("\n")}return[t].join("\n")}},72:e=>{"use strict";var t=[];function i(e){for(var i=-1,n=0;n<t.length;n++)if(t[n].identifier===e){i=n;break}return i}function n(e,n){for(var a={},s=[],r=0;r<e.length;r++){var l=e[r],c=n.base?l[0]+n.base:l[0],u=a[c]||0,d="".concat(c," ").concat(u);a[c]=u+1;var p=i(d),h={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==p)t[p].references++,t[p].updater(h);else{var m=o(h,n);n.byIndex=r,t.splice(r,0,{identifier:d,updater:m,references:1})}s.push(d)}return s}function o(e,t){var i=t.domAPI(t);return i.update(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap&&t.supports===e.supports&&t.layer===e.layer)return;i.update(e=t)}else i.remove()}}e.exports=function(e,o){var a=n(e=e||[],o=o||{});return function(e){e=e||[];for(var s=0;s<a.length;s++){var r=i(a[s]);t[r].references--}for(var l=n(e,o),c=0;c<a.length;c++){var u=i(a[c]);0===t[u].references&&(t[u].updater(),t.splice(u,1))}a=l}}},659:e=>{"use strict";var t={};e.exports=function(e,i){var n=function(e){if(void 0===t[e]){var i=document.querySelector(e);if(window.HTMLIFrameElement&&i instanceof window.HTMLIFrameElement)try{i=i.contentDocument.head}catch(e){i=null}t[e]=i}return t[e]}(e);if(!n)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");n.appendChild(i)}},540:e=>{"use strict";e.exports=function(e){var t=document.createElement("style");return e.setAttributes(t,e.attributes),e.insert(t,e.options),t}},56:(e,t,i)=>{"use strict";e.exports=function(e){var t=i.nc;t&&e.setAttribute("nonce",t)}},825:e=>{"use strict";e.exports=function(e){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var t=e.insertStyleElement(e);return{update:function(i){!function(e,t,i){var n="";i.supports&&(n+="@supports (".concat(i.supports,") {")),i.media&&(n+="@media ".concat(i.media," {"));var o=void 0!==i.layer;o&&(n+="@layer".concat(i.layer.length>0?" ".concat(i.layer):""," {")),n+=i.css,o&&(n+="}"),i.media&&(n+="}"),i.supports&&(n+="}");var a=i.sourceMap;a&&"undefined"!=typeof btoa&&(n+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(a))))," */")),t.styleTagTransform(n,e,t.options)}(t,e,i)},remove:function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(t)}}}},113:e=>{"use strict";e.exports=function(e,t){if(t.styleSheet)t.styleSheet.cssText=e;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(e))}}}},t={};function i(n){var o=t[n];if(void 0!==o)return o.exports;var a=t[n]={id:n,exports:{}};return e[n](a,a.exports,i),a.exports}i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.nc=void 0;var n={};(()=>{"use strict";i.r(n),i.d(n,{_package:()=>Qe,demoFileIngest:()=>at,demoFileIngest1:()=>st,demoFileIngest2:()=>rt,demoFileSubmit:()=>lt,gasteigerCellRenderer:()=>ct,hitDesignApp:()=>nt,hitDesignAppTreeBrowser:()=>et,hitTriageApp:()=>it,hitTriageAppTreeBrowser:()=>Xe,peptiHitApp:()=>ot,peptiHitAppTreeBrowser:()=>tt});const e=grok,t=DG,o=ui,a="campaignId",s="campaignId",r="enriched_table.csv",l="campaign.json",c="HitTriageDataSource",u="HitTriageSubmitFunction",d="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",E="Cancel",S="Continue a campaign",N="New campaign",I={script:"script",function:"function-package",query:"data-query"};var F=i(72),_=i.n(F),P=i(825),O=i.n(P),V=i(659),B=i.n(V),k=i(56),L=i.n(k),j=i(540),M=i.n(j),R=i(113),D=i.n(R),U=i(558),$={};$.styleTagTransform=D(),$.setAttributes=L(),$.insert=B().bind(null,"head"),$.domAPI=O(),$.insertStyleElement=M(),_()(U.A,$),U.A&&U.A.locals&&U.A.locals;var H=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};const q=e=>`${e.getFullYear()}/${e.getMonth()+1}/${e.getDate()}`;function Y(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 W(t,i,n,a){var s;const r=o.breadcrumbs([i,n]),l=r.onPathClick.subscribe((e=>{1===e.length&&(l.unsubscribe(),G(t),a())})),c=null===(s=e.shell.v.ribbonMenu.root.parentElement)||void 0===s?void 0:s.getElementsByClassName("d4-ribbon-name")[0];return c&&(c.textContent="",c.appendChild(r.root)),{breadcrumbs:r,sub:l}}function G(e){const t=e.getRibbonPanels();(null==t?void 0:t.length)&&(t.pop(),e.setRibbonPanels(t))}function J(e){return e.reduce(((e,t)=>e||t.reduce(((e,t)=>e||t.classList.contains("hit-design-submit-button")||Array.from(t.children).some((e=>e.classList.contains("hit-design-submit-button")))),!1)),!1)}function z(e,i,n){return H(this,void 0,void 0,(function*(){if(0===n.rowCount)return;if(!e.col(i))throw new Error("There is no molecule column in dataframe");let o=n.col(w);if(o||(yield n.meta.detectSemanticTypes(),o=n.columns.bySemType(t.SEMTYPE.MOLECULE)),!o)throw new Error("There is no original molecule column in query result dataframe");const a=n.columns.names().filter((e=>e!==w));e.join(n,[i],[o.name],void 0,a,void 0,!0)}))}function K(e,t){return H(this,void 0,void 0,(function*(){const i=(yield Qe.files.list(`${e}/campaigns`)).filter((e=>-1===t.indexOf(e.name))),n={};for(const t of i)try{const i=JSON.parse(yield Qe.files.readAsText(`${e}/campaigns/${t.name}/${l}`));if(i.authorUserId&&i.permissions&&!(yield X(i.authorUserId,i.permissions)))continue;n[i.name]=i}catch(e){continue}return n}))}function Q(i,n){return H(this,void 0,void 0,(function*(){var o;const a=t.User.current().id,s=null===(o=t.User.current().group)||void 0===o?void 0:o.id;if(i===a)return!0;const r=e.dapi.groups;for(const e of n){const t=yield r.find(e);if(t)if(t.personal){const e=yield r.getUser(t);if((null==e?void 0:e.id)===a)return!0}else if(s&&t.members.length>0&&t.members.some((e=>e.id===s)))return!0}return!1}))}function Z(e,t){return H(this,void 0,void 0,(function*(){return Q(e,t.edit)}))}function X(e,t){return H(this,void 0,void 0,(function*(){return Q(e,Array.from(new Set([...t.view,...t.edit])))}))}const ee={String:t.TYPE.STRING,Number:t.TYPE.FLOAT,Boolean:t.TYPE.BOOL,Date:t.TYPE.DATE_TIME,Molecule:t.SEMTYPE.MOLECULE};var te=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))},ie=i(233),ne=i.n(ie),oe=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};function ae(t,i,n,a,s){return oe(this,void 0,void 0,(function*(){var r,l,c,u,d,p,h,m,v,f,w,b,C,A,T,x,E,S,N,F,_;const P=yield t.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 B=o.div([],{classes:"hit-triage-compute-dialog-host"}),k=[],L=o.tree();try{const q=yield e.chem.descriptorsTree();function Y(e,t){const i=t.group(e,null,!1);return i.enableCheckBox(!1),i}L.root.classList.add("hit-triage-compute-dialog-descriptors-group");const W=Object.keys(q),G=null!==(d=null===(u=null===(c=null==a?void 0:a.compute)||void 0===c?void 0:c.descriptors)||void 0===u?void 0:u.args)&&void 0!==d?d:[];for(const J of W){const z=Y(J,L);for(const K of q[J].descriptors){const Q=z.item(K.name,K);k.push(Q),Q.enableCheckBox(G.includes(K.name))}}}catch(Z){console.error(Z),V=!1}const j="Descriptors",M={[j]:j},R=V?{[j]:L.root}:{},D={},U={[j]:!1};U[j]=!!(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===I.function?`${ee.package.name}:${ee.name}`:ee.type===I.script?`${g}:${null!==(w=ee.name)&&void 0!==w?w:""}:${ee.id}`:`${y}:${null!==(b=ee.name)&&void 0!==b?b:""}:${ee.id}`;D[ie]=te;const oe=o.div(),ae=yield te.buildEditor(oe,{condensed:!1});oe.classList.add("oy-scroll"),oe.style.marginLeft="15px",oe.style.removeProperty("max-width"),R[null!==(C=ee.friendlyName)&&void 0!==C?C:ee.name]=oe,M[null!==(A=ee.friendlyName)&&void 0!==A?A:ee.name]=ie,U[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===I.function&&e.name===X.func.name&&e.package===(null===(t=X.func.package)||void 0===t?void 0:t.name)})))||(null===(S=null===(E=null==a?void 0:a.compute)||void 0===E?void 0:E.scripts)||void 0===S?void 0:S.some((e=>e.id===ee.id)))||(null===(F=null===(N=null==a?void 0:a.compute)||void 0===N?void 0:N.queries)||void 0===F?void 0:F.some((e=>e.id===ee.id))))&&void 0!==_&&_,oe.children[0].style.display="none",ee.type!==I.query&&(oe.children[1].style.display="none"),ae.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(se){console.error(se);continue}const $=o.tabControl(R,!0);function H(){const e={descriptors:[],externals:{},scripts:{},queries:{}};e.descriptors=U[j]?k.filter((e=>e.checked)).map((e=>e.value.name)):[];const t=Object.entries(D).filter((([e,t])=>U[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),i(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",B.appendChild($.root),$.panes.forEach((e=>{const t=o.input.bool("",{value:U[M[e.name]],onValueChanged:t=>{U[M[e.name]]=!!t,t?ne()(e.content).find("input").removeAttr("disabled"):ne()(e.content).find("input").attr("disabled","true")}});t.setTooltip("Toggle calculation of this function"),e.header.appendChild(t.root),e.header.classList.add("hit-triage-compute-dialog-pane-header")})),s&&o.dialog("Compute").add(B).onOK((()=>H())).onCancel(n).show(),{root:B,okProxy:H}}))}const se=rxjs;class re{constructor(e,t=[],i={}){this.onItemChanged=new se.Subject,this.onAddingItemChanged=new se.Subject,this.onItemAdded=new se.Subject,this.onItemRemoved=new se.Subject,this.options={removeButtonTooltip:"Remove item",addButtonTooltip:"Add item",allowAdd:!0,allowRemove:!0},this.properties=e,this.options=Object.assign(Object.assign({},this.options),i),this._root=o.divV([],{style:{display:"grid",gridTemplateColumns:`repeat(${this.properties.length}, 1fr)`,alignItems:"center",gap:"12px"},classes:"ui-items-grid"}),this._items=t,this.render()}get root(){return this._root}get items(){return this._items}set items(e){this._items=e,this.render()}addItem(e,t=!0){this._items.push(e),this.render(),t&&this.onItemAdded.next(e)}removeItem(e,t=!0){-1!==this._items.indexOf(e)&&(this._items.splice(this._items.indexOf(e),1),this.render(),t&&this.onItemRemoved.next(e))}removeAtIndex(e,t=!0){if(e<0||e>=this._items.length)return;const i=this._items.splice(e,1);this.render(),t&&this.onItemRemoved.next(i[0])}removeAllItems(){this._items=[],this.render()}render(){var e,t,i,n,a;if(o.empty(this._root),!this.options.horizontalInputNames)for(const i of this.properties){let n=null!==(e=i.caption)&&void 0!==e?e:i.name;(null===(t=this.options.customLabels)||void 0===t?void 0:t[i.name])&&(n=this.options.customLabels[i.name]);const a=o.divText(n);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===(n=(i=this.options).newItemFunction)||void 0===n?void 0:n.call(i))&&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 c of this.properties){void 0===e[c.name]&&(e[c.name]=null);const u=(null===(n=this.options.customInputs)||void 0===n?void 0:n[c.name])?this.options.customInputs[c.name](e):o.input.forProperty(c,e),d=null===(a=this.options.validators)||void 0===a?void 0:a[c.name];d&&u.addValidator(d),s.push(this.options.horizontalInputNames?u.root:this.hideLabel(u.root)),c.propertyType!==t.TYPE.BOOL&&"color"!==c.name.toLowerCase()&&u.input&&(u.input.style.width="100%"),r[c.name]=u,u.onChanged.subscribe((()=>{e[c.name]=u.value,i?this.onAddingItemChanged.next({item:e,fieldName:c.name}):this.onItemChanged.next({item:e,fieldName:c.name})})),u.root.style.alignItems="center",l=u}let c=null;if(i)c=o.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;c=o.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(c):null==l||l.root.appendChild(c),c.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 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 ce(){const e=t.Property.fromOptions({name:"layout",caption:"Layout",type:"file"}),i=t.InputBase.forProperty(e);let n=null,o=null,a=null;return i.addValidator((e=>a)),i.onChanged.subscribe((e=>le(this,void 0,void 0,(function*(){const s=e;if(s)try{const e=yield s.readAsString(),i=t.ViewLayout.fromJson(e);i?(n=i,o=i.viewState,a=null):(n=null,o=null,a="Invalid layout file")}catch(e){n=null,o=null,a="Invalid layout file"}i.setTooltip("Select a layout file")})))),{dataFileInput:i,getLayout:()=>n,getLayoutViewState:()=>o}}var 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 de(i,n){return ue(this,void 0,void 0,(function*(){var a,s;const r=(yield Qe.files.list("Hit Triage/templates")).map((e=>e.name.slice(0,-5))),l=[];for(const e of r){const t=JSON.parse(yield Qe.files.readAsText(`Hit Triage/templates/${e}.json`));l.push(t.key)}const d=t.Func.find({tags:[u]}),p={};d.forEach((e=>{var t;p[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e}));const h=o.input.choice("Submit function",{value:null,items:[null,...Object.keys(p)]});h.value=null,h.nullable=!0,h.fireChanged(),h.setTooltip("Select function to be called upon submitting");const m=ce(),v=o.divText("Template name is empty or already exists",{classes:"hit-triage-error-div"}),f=o.divText("Template key is empty or already exists",{classes:"hit-triage-error-div"}),w=o.input.string("Name",{value:"",onValueChanged: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=o.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 ae(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&&t.Func.find({tags:[c]}).forEach((e=>{var t;n[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e}));const S=Object.keys(n),N=o.input.choice(b,{value:S[0],items:S}),I=o.input.choice("Ingest using",{value:"Query",items:["Query","File"],onValueChanged:e=>{N.root.style.display="Query"===e?"block":"none"}}),F=pe(),_=o.div([o.h2("Details"),o.div([w,v]),o.div([C,f]),I.root,N.root,m.dataFileInput,F.fieldsDiv,o.h2("Compute"),x.root,o.h2("Submit"),h.root],"ui-form"),P=o.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 t=o.button(E,(()=>e()));O.appendChild(t)})),B=new Promise((t=>{const i=o.bigButton(T,(()=>function(){return ue(this,void 0,void 0,(function*(){var i,n,o,a,s,r,l,c;if(x.okProxy(),"100%"===v.style.opacity)return void e.shell.error("Template name is empty or already exists");const u=h.value?p[h.value]:void 0,d=Object.assign(Object.assign({name:w.value,key:C.value,campaignFields:F.getFields(),dataSourceType:null!==(i=I.value)&&void 0!==i?i:"Query",layoutViewState:null!==(n=m.getLayoutViewState())&&void 0!==n?n:void 0,compute:{descriptors:{enabled:!!(null===(o=null==A?void 0:A.descriptors)||void 0===o?void 0:o.length),args:null!==(a=null==A?void 0:A.descriptors)&&void 0!==a?a:[]},functions:Object.entries(null!==(s=null==A?void 0:A.externals)&&void 0!==s?s:{}).map((([e,t])=>{const i=e.split(":");return{name:i[1],package:i[0],args:t}})),scripts:Object.entries(null!==(r=null==A?void 0:A.scripts)&&void 0!==r?r:{}).filter((([e,t])=>e.startsWith(g)&&3===e.split(":").length)).map((([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}})),queries:Object.entries(null!==(l=null==A?void 0:A.queries)&&void 0!==l?l:{}).filter((([e,t])=>e.startsWith(y)&&3===e.split(":").length)).map((([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}}))}},u?{submit:{fName:u.name,package:u.package.name}}:{}),{queryFunctionName:"Query"===I.value&&null!==(c=N.value)&&void 0!==c?c:void 0});var f;f=d,Qe.files.writeAsText(`Hit Triage/templates/${f.name}.json`,JSON.stringify(f)),e.shell.info("Template created successfully"),t(d)}))}()));O.appendChild(i)}));return{root:_,template:B,cancelPromise:V}}))}function pe(e){const i=[t.Property.fromOptions({name:"Name",type:t.TYPE.STRING}),t.Property.fromOptions({name:"Type",type:t.TYPE.STRING,choices:Object.keys(ee)}),t.Property.fromOptions({name:"Required",type:t.TYPE.BOOL})],n=new re(i,e?e.map((e=>({Name:e.name,Type:e.type,Required:e.required}))):void 0,{horizontalInputNames:!1});n.root.style.maxWidth="750px";let a={};n.onItemAdded.subscribe((e=>{a={}})),n.onAddingItemChanged.subscribe((e=>{e&&(a=e.item)}));const s=o.h2("Additional fields");o.tooltip.bind(s,"Additional fields to be filled by user for each campaign");const r=o.div([s,n.root]);return{getFields:function(){var e;const t=n.items.filter((e=>e.Name)).map((e=>{var t;return{name:e.Name,type:e.Type,required:null!==(t=e.Required)&&void 0!==t&&t}}));return a.Name&&""!==a.Name&&a.Type&&(null!==(e=a.Required)&&void 0!==e||(a.Required=!1),t.push({name:a.Name,type:a.Type,required:a.Required})),t},fieldsDiv:o.div([r])}}var he=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 me extends t.ViewBase{constructor(e){super(),this.deletedCampaigns=[],this.app=e}get template(){return this.app.template}onActivated(){}onReset(){}process(){return he(this,void 0,void 0,(function*(){}))}deleteCampaign(e,t){return he(this,void 0,void 0,(function*(){yield Qe.files.delete(`${e}/campaigns/${t}`)}))}}var ve=i(677),fe={};fe.styleTagTransform=D(),fe.setAttributes=L(),fe.insert=B().bind(null,"head"),fe.domAPI=O(),fe.insertStyleElement=M(),_()(ve.A,fe),ve.A&&ve.A.locals&&ve.A.locals;var ge;!function(t){let i,n;!function(e){e.vert=function(e){return o.divV(e.map((e=>o.render(e))),{classes:"u2-panel"})},e.horz=function(e){return o.divH(e.map((e=>o.render(e))),{classes:"u2-panel"})}}(i=t.panels||(t.panels={})),t.appHeader=function(e){const t=o.iconImage("",e.iconPath);return ne()(t).addClass("ui-app-header-icon").css("margin-right","20px"),i.horz([t,i.vert([o.markdown(e.description),e.learnMoreUrl?o.link("Learn more",e.learnMoreUrl):null])])},function(t){t.runAsync=function(t,i){return n=this,a=void 0,r=function*(){o.setUpdateIndicator(t,!0);try{return yield i()}catch(t){e.log.error(t)}finally{o.setUpdateIndicator(t,!1)}},new((s=void 0)||(s=Promise))((function(e,t){function i(e){try{l(r.next(e))}catch(e){t(e)}}function o(e){try{l(r.throw(e))}catch(e){t(e)}}function l(t){var n;t.done?e(t.value):(n=t.value,n instanceof s?n:new s((function(e){e(n)}))).then(i,o)}l((r=r.apply(n,a||[])).next())}));var n,a,s,r}}(n=t.tools||(t.tools={}))}(ge||(ge={}));var ye=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};const we={view:[t.Group.defaultGroupsIds["All users"]],edit:[t.Group.defaultGroupsIds["All users"]]};class be{constructor(e){this.permissions=null!=e?e:we,this.editGroupsInput=o.input.userGroups("Can Edit"),this.editGroupsInput.root.style.marginBottom="16px",this.viewGroupsInput=o.input.userGroups("Can View")}getDialogContent(){return ye(this,void 0,void 0,(function*(){const t=[],i=[];for(const i of this.permissions.view){const n=yield e.dapi.groups.find(i);n&&t.push(n)}for(const t of this.permissions.edit){const n=yield e.dapi.groups.find(t);n&&i.push(n)}return this.editGroupsInput.value=i,this.viewGroupsInput.value=t,o.divV([this.editGroupsInput.root,this.viewGroupsInput.root])}))}show(e){return ye(this,void 0,void 0,(function*(){var t;const i=yield this.getDialogContent(),n=o.dialog("Edit Permissions").add(i).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=we.view),e(this.permissions)}));(null===(t=i.parentElement)||void 0===t?void 0:t.style)&&(i.parentElement.style.overflow="visible"),n.show()}))}}var Ce=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};class Ae extends me{constructor(t){super(t),this.readmePath=Qe.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 Ce(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0);try{const t=o.h1(S),i=o.h1(N,{style:{marginLeft:"10px"}}),n=ge.appHeader({iconPath:Qe.webRoot+"/images/icons/hit-triage-icon.png",learnMoreUrl:"https://github.com/datagrok-ai/public/blob/master/packages/HitTriage/README_HT.md",description:"- Configure your own workflow using the template editor.\n- Calculate different molecular properties.\n- Filter molecules using different criteria.\n- Submit processed dataframe to the function of your choice.\n- Save campaigns and continue any time from where you left off.\n "}),a=o.div(),s=o.div([],{classes:"ui-form"}),r=yield this.getCampaignsTable();yield this.startNewCampaign(a,s,e),ne()(this.root).empty(),this.root.appendChild(o.div([o.divV([n,t],{style:{marginLeft:"10px"}}),r,i,s,a])),this.app.resetBaseUrl()}catch(e){throw o.setUpdateIndicator(this.root,!1),e}finally{o.setUpdateIndicator(this.root,!1)}}))}startNewCampaign(e,t,i){return Ce(this,void 0,void 0,(function*(){var n;const a=(yield Qe.files.list("Hit Triage/templates")).map((e=>e.name.slice(0,-5)));i&&!a.includes(i.name)&&a.push(i.name);const s=()=>Ce(this,void 0,void 0,(function*(){const t=r.value,n=i&&i.name===t?i:JSON.parse(yield Qe.files.readAsText("Hit Triage/templates/"+t+".json")),o=yield this.getNewCampaignAccordeon(n,e);ne()(e).empty(),e.className="ui-form",e.appendChild(o)})),r=o.input.choice("Template",{value:null!==(n=null==i?void 0:i.name)&&void 0!==n?n:a[0],items:a,onValueChanged:()=>Ce(this,void 0,void 0,(function*(){yield s()}))}),l=o.icons.add((()=>Ce(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0),yield this.createNewTemplate(),o.setUpdateIndicator(this.root,!1)}))),C);r.addOptions(l),yield s(),ne()(t).empty(),t.appendChild(r.root)}))}checkCampaign(e){return Ce(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 Qe.files.exists(`Hit Triage/campaigns/${n}/${l}`)))return;const o=JSON.parse(yield Qe.files.readAsText(`Hit Triage/campaigns/${n}/${l}`));if(o){if(o.authorUserId&&o.permissions&&!(yield X(o.authorUserId,o.permissions)))return void this.app.setBaseUrl();this.app.campaign=o}const s=JSON.parse(yield Qe.files.readAsText(`Hit Triage/templates/${o.templateName}.json`));return this.app.setTemplate(s,o.filters,n,o.ingest),e&&Y(a,e),o}))}getCampaignsTable(){return Ce(this,void 0,void 0,(function*(){const e=yield K("Hit Triage",this.deletedCampaigns),i=e=>{var i,n;const a=o.icons.delete((()=>Ce(this,void 0,void 0,(function*(){o.dialog("Delete campaign").add(o.divText(`Are you sure you want to delete campaign ${e.name}?`)).onOK((()=>Ce(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",Z(null!==(i=e.authorUserId)&&void 0!==i?i:t.User.current().id,null!==(n=e.permissions)&&void 0!==n?n:we).then((e=>{e&&(a.style.display="inline-block")})),a},n=Object.values(e),a=o.table(n,(e=>[o.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 Ce(this,void 0,void 0,(function*(){const t=yield this.checkCampaign(e);this.app.campaign=t}))}getNewCampaignAccordeon(i,n){return Ce(this,void 0,void 0,(function*(){o.setUpdateIndicator(n,!0);const{root:a,promise:s,cancelPromise:r}=yield function(i,n){return te(this,void 0,void 0,(function*(){var a,s;const r=o.divText("",{style:{color:"red"}});let l=null;const u=()=>te(this,void 0,void 0,(function*(){try{if(l=d.value,!l)return;if(yield l.meta.detectSemanticTypes(),!l.columns.bySemType(t.SEMTYPE.MOLECULE))return void(r.innerText="No molecules column found");r.innerText=""}catch(e){r.innerText="Error parsing file"}})),d=o.input.table("Dataframe",{onValueChanged:u});yield u();const p=o.div([d,r]);0===Object.keys(n).length&&t.Func.find({tags:[c]}).forEach((e=>{var t;n[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e}));let h=null;const m=()=>te(this,void 0,void 0,(function*(){const e=n[f.value];h=e.prepare();const t=yield h.getEditor();t.classList.remove("ui-form"),v.innerHTML="",v.appendChild(t)})),v=o.div([]),f=o.input.choice(b,{value:null!==(a=i.queryFunctionName)&&void 0!==a?a:Object.keys(n)[0],items:Object.keys(n),onValueChanged:m});yield m(),i.queryFunctionName&&(null===(s=f.root.getElementsByTagName("select").item(0))||void 0===s||s.setAttribute("disabled","true"));const g=o.div([f,v]);g.style.display="none";const y=o.div([p,g]),w=i.campaignFields.map((e=>e.type===t.SEMTYPE.MOLECULE?Object.assign(Object.assign({},e),{type:"String",semtype:t.SEMTYPE.MOLECULE}):e)).map((e=>t.Property.fromOptions(Object.assign({name:e.name,type:ee[e.type],nullable:!e.required},e.semtype?{semType:e.semtype}:{})))),C={},T=w.length?o.input.form(C,w):o.div();T.classList.remove("ui-form"),"File"===i.dataSourceType?(p.style.display="inherit",g.style.display="none"):(p.style.display="none",g.style.display="inherit");const x=o.div([y,...w.length?[T]:[]]),S=o.buttonsInput([]);return x.appendChild(S),{promise:new Promise((t=>{const a=()=>te(this,void 0,void 0,(function*(){if("File"===i.dataSourceType){if(!l)return void e.shell.error("No file selected");const i=l;i.name=l.name,t({df:i,type:"File",campaignProps:C})}else{const i=n[f.value];if(!i)return void e.shell.error("No function selected");const o={};Object.entries(h.inputs).forEach((([e,t])=>{o[e]=t}));const a=yield i.apply(o);t({df:a,type:"Query",campaignProps:C})}})),s=o.bigButton(A,(()=>a()));S.appendChild(s)})),root:x,cancelPromise:new Promise((e=>{o.button(E,(()=>e()))}))}}))}(i,this.dataSourceFunctionsMap);return o.setUpdateIndicator(n,!1),s.then((e=>Ce(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 Ce(this,void 0,void 0,(function*(){const i=yield de(this.app,this.dataSourceFunctionsMap),n=new t.ViewBase,o=e.shell.v;n.name="New Template",n.root.appendChild(i.root),n.parentCall=this.app.parentCall,e.shell.addView(n),n.path=new URL(this.app.baseUrl).pathname+"/new-template",n.parentView=o;const{sub:a}=W(e.shell.v,"Hit Triage",C,(()=>{e.shell.v=o,n.close()}));i.template.then((t=>Ce(this,void 0,void 0,(function*(){yield this.init(t),n.close(),G(n),e.shell.v=o,a.unsubscribe()})))),i.cancelPromise.then((()=>{a.unsubscribe(),n.close(),e.shell.v=o}))}))}}class Te extends me{constructor(e){super(e),this.name="Submit"}render(){return o.empty(this.root),o.divV([o.h1("Summary"),o.div([o.tableFromMap(this.app.getSummary())])])}onActivated(){this.render()}submit(){return i=this,n=void 0,a=function*(){var i;const n=null===(i=this.app.template)||void 0===i?void 0:i.submit;if(!n)return;const o=t.Func.find({name:n.fName,package:n.package})[0];if(!o)return void e.shell.error(`Function ${n.fName} not found.`);const a=t.DataFrame.fromCsv(this.app.dataFrame.toCsv({filteredRowsOnly:!0}));yield o.apply({df:a,molecules:this.app.molColName}),this.app.campaign&&(this.app.campaign.status="Submitted"),this.app.saveCampaign("Submitted"),e.shell.info("Submitted successfully.")},new((o=void 0)||(o=Promise))((function(e,t){function s(e){try{l(a.next(e))}catch(e){t(e)}}function r(e){try{l(a.throw(e))}catch(e){t(e)}}function l(t){var i;t.done?e(t.value):(i=t.value,i instanceof o?i:new o((function(e){e(i)}))).then(s,r)}l((a=a.apply(i,n||[])).next())}));var i,n,o,a}}var xe=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};class Ee{get appName(){return this._appName}constructor(e,i){this.parentCall=e,this.isJoining=!1,this.hasEditPermission=!1,this._appName=i,this.resetBaseUrl(),this.computeFunctions=new Promise((e=>xe(this,void 0,void 0,(function*(){const i=t.Func.find({tags:["HitTriageFunction"]}),n=i.filter((e=>e.type===I.function)),o=i.filter((e=>e.type===I.script)),a=i.filter((e=>e.type===I.query));e({functions:n,scripts:o,queries:a})}))))}setCanEdit(e){return xe(this,void 0,void 0,(function*(){e.authorUserId&&e.permissions?this.hasEditPermission=yield Z(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 i=this.dataFrame.col(e);return(null==i?void 0:i.semType)===t.SEMTYPE.MOLECULE?t.FILTER_TYPE.SUBSTRUCTURE:(null==i?void 0:i.type)===t.COLUMN_TYPE.BOOL?t.FILTER_TYPE.BOOL_COLUMNS:(null==i?void 0:i.type)===t.COLUMN_TYPE.STRING?t.FILTER_TYPE.CATEGORICAL:t.FILTER_TYPE.HISTOGRAM}download(e,i,n=!1){const o=document.createElement("a"),a=t.DataFrame.fromColumns(e.columns.toList().filter((e=>!e.name.startsWith("~")))).toCsv({filteredRowsOnly:n});o.setAttribute("href","data:text/plain;charset=utf-8,"+encodeURIComponent(a)),o.setAttribute("download",i+".csv"),o.click()}getNewCampaignName(e,t){return xe(this,void 0,void 0,(function*(){const i=(yield Qe.files.list(e)).map((e=>e.name)).filter((e=>e.startsWith(t)));if(0===i.length)return t+"-1";const n=i.map((e=>e.split("-")[1])).filter(Boolean).map((e=>parseInt(e,10))).sort();return t+"-"+(n[n.length-1]+1).toString()}))}setBaseUrl(){const e=document.title;if(history.replaceState){const t={Title:e,Url:this.baseUrl};history.replaceState(t,t.Title,t.Url)}}unionDataframes(e,i,n){var o,a,s,r,l;const c=null===(a=null===(o=e.col(n))||void 0===o?void 0:o.toList())||void 0===a?void 0:a.filter((e=>!!e)).map((e=>t.chem.convert(e,t.chem.Notation.Unknown,t.chem.Notation.Smiles))),u=null===(r=null===(s=i.col(n))||void 0===s?void 0:s.toList())||void 0===r?void 0:r.filter((e=>!!e)).map((e=>t.chem.convert(e,t.chem.Notation.Unknown,t.chem.Notation.Smiles)));if(!c||!u)throw new Error("Molecule column not found");this.isJoining=!0;try{for(const t of e.columns)i.columns.contains(t.name)||i.columns.addNew(t.name,t.type);for(let t=0;t<c.length;t++)if(!u.includes(c[t])){i.rows.addNew(null,!0);for(const n of e.columns){const e=n.get(t);null===(l=i.col(n.name))||void 0===l||l.set(i.rowCount-1,e,!1)}}}finally{setTimeout((()=>{this.isJoining=!1}),500)}return i}}var 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())}))},Ne=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 Ie(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 Fe(i,n,o){return Ne(this,void 0,void 0,(function*(){var a,s;const r=t.TaskBarProgressIndicator.create("Calculating ..."),l=n.col(o);if(!l)throw new Error("There is no molecule column in dataframe");for(let t=0;t<l.length;t++){if(l.isNone(t))continue;const i=l.get(t);if(!i)continue;const n=e.chem.convert(i,e.chem.Notation.Unknown,e.chem.Notation.Smiles);l.set(t,n,!1)}try{i.descriptors&&i.descriptors.length>0&&(yield e.chem.descriptors(n,o,i.descriptors))}catch(e){console.error("Descriptors calculation error",e)}for(const e of Object.keys(i.externals))try{const a=i.externals[e],s=t.Func.find({package:e.split(":")[0],name:e.split(":")[1]})[0],r=s.inputs[0].name,l=s.inputs[1].name;a&&(yield s.apply(Object.assign(Object.assign({},a),{[r]:n,[l]:o})))}catch(e){console.error(e)}for(const e of Object.keys(null!==(a=i.scripts)&&void 0!==a?a:{})){const a=i.scripts[e];if(a){const i=e.split(":"),s=i[2];if(!s)continue;try{const e=i[1],r=t.Func.find({name:e}).filter((e=>e.type===I.script&&e.id===s))[0];if(!r)continue;const l=r.inputs[0].name,c=r.inputs[1].name,u=yield r.apply(Object.assign(Object.assign({},a),{[l]:n,[c]:o}));if(u&&u.rowCount===n.rowCount&&"python"===r.language)for(const e of u.columns)e.name=n.columns.getUnusedName(e.name),n.columns.add(e)}catch(e){console.error(e)}}}for(const e of Object.keys(null!==(s=i.queries)&&void 0!==s?s:{})){const a=i.queries[e];if(a){const i=e.split(":"),s=i[2];if(!s)continue;try{const e=i[1],r=t.Func.find({name:e}).filter((e=>e.type===I.query&&e.id===s))[0];if(!r)continue;const l=r.inputs[0].name,c=n.col(o).toList(),u=yield r.apply(Object.assign(Object.assign({},a),{[l]:c}));u&&(yield z(n,o,u))}catch(e){console.error(e)}}}r.close()}))}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())}))};class Pe extends Ee{get infoView(){return this._infoView}constructor(i){super(i,"Hit Triage"),this._filterViewName="Hit triage | Pick",this._filterDescriptions=[],this.campaignProps={},this._pickViewPromise=null,this._infoView=new Ae(this),this.multiView=new t.MultiView({viewFactories:{[this._infoView.name]:()=>this._infoView}}),this.multiView.tabs.onTabChanged.subscribe((e=>{this.multiView.currentView instanceof me&&this.multiView.currentView.onActivated()})),this.multiView.parentCall=i,e.events.onCurrentViewChanged.subscribe((()=>{var t,i,n,o;try{(null===(t=e.shell.v)||void 0===t?void 0:t.name)===this.currentPickViewId&&(e.shell.windows.showHelp=!1,this.setBaseUrl(),Y(a,null!==(o=null!==(i=this._campaignId)&&void 0!==i?i:null===(n=this._campaign)||void 0===n?void 0:n.name)&&void 0!==o?o:""))}catch(e){console.error(e)}}))}setTemplate(i,n,o,s){return _e(this,void 0,void 0,(function*(){var r,l,c,u,d,p,h,m,v,f,w,b,C,A,T;if((null===(r=this._pickView)||void 0===r?void 0:r.dataFrame)&&e.shell.closeTable(null===(l=this._pickView)||void 0===l?void 0:l.dataFrame),this._pickView=void 0,o?s&&(this._fileInputType=s.type,"File"===s.type?this.dataFrame=yield e.dapi.files.readCsv(s.query):this.dataFrame=yield e.functions.call(s.query)):(o=yield this.getNewCampaignName("Hit Triage/campaigns",i.key),Y(a,o)),!this.dataFrame)return void console.error("Dataframe is empty.");if((null===(c=this._campaign)||void 0===c?void 0:c.columnSemTypes)&&Object.entries(this._campaign.columnSemTypes).forEach((([e,t])=>{const i=this.dataFrame.columns.byName(e);i&&i.semType!==t&&(i.semType=t)})),(null===(u=this._campaign)||void 0===u?void 0:u.columnTypes)&&Object.entries(this._campaign.columnTypes).forEach((([e,t])=>{const i=this.dataFrame.columns.byName(e);if(i&&i.type!==t)try{i.convertTo(t)}catch(e){console.error(e)}})),yield this.dataFrame.meta.detectSemanticTypes(),this._molColName=null!==(p=null===(d=this.dataFrame.columns.bySemType(t.SEMTYPE.MOLECULE))||void 0===d?void 0:d.name)&&void 0!==p?p:void 0,this._dfName=null!==(h=this.dataFrame.name)&&void 0!==h?h:null==s?void 0:s.query,this.dataFrame.name=null!==(v=null!==(m=this._dfName)&&void 0!==m?m:this.dataFrame.name)&&void 0!==v?v:"Molecules",this._campaignId=o,this.template=(null===(f=this.campaign)||void 0===f?void 0:f.template)?Object.assign(Object.assign({},this.campaign.template),{dataSourceType:i.dataSourceType,queryFunctionName:i.queryFunctionName}):i,this._campaignFilters=n,!n){const e={},t={},n={};i.compute.functions.forEach((t=>{const i=`${t.package}:${t.name}`;e[i]=t.args})),null===(w=i.compute.scripts)||void 0===w||w.forEach((e=>{const i=`${g}:${e.name}:${e.id}`;t[i]=e.args})),null===(b=i.compute.queries)||void 0===b||b.forEach((e=>{const t=`${y}:${e.name}:${e.id}`;n[t]=e.args})),yield Fe({descriptors:i.compute.descriptors.enabled?i.compute.descriptors.args:[],externals:e,scripts:t,queries:n},this.dataFrame,this._molColName)}this.campaign?yield this.setCanEdit(this.campaign):this.hasEditPermission=!0;const x=e.shell.v,E=e.shell.addView(this.pickView);this.currentPickViewId=E.name,this._submitView=new Te(this),this.setBaseUrl(),Y(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 S=E;setTimeout((()=>{this._pickViewPromise&&this._pickViewPromise.then((()=>{const{sub:t}=W(S,"Hit Triage","Pick",(()=>{e.shell.v=x,S.close(),t.unsubscribe()}))}))}),300),e.shell.windows.showHelp=!1}))}get filterSettings(){return this._campaignFilters}get campaignId(){return this._campaignId}get pickView(){return this._pickView=this.getFilterView()}get molColName(){var e,i,n;return null!==(e=this._molColName)&&void 0!==e?e:this._molColName=null===(n=null===(i=this.dataFrame)||void 0===i?void 0:i.columns.bySemType(t.SEMTYPE.MOLECULE))||void 0===n?void 0:n.name}get fileInputType(){return this._fileInputType}get campaign(){return this._campaign}set campaign(e){this._campaign=e}getFilterView(){let e=null;this._pickViewPromise=new Promise((t=>{e=t})),this.dataFrame.col(d)||this.dataFrame.columns.addNewBool(d).init(!1);const i=t.TableView.create(this.dataFrame,!1),n=i.getRibbonPanels(),a=o.iconFA("wrench",(()=>_e(this,void 0,void 0,(function*(){ae(this,(e=>_e(this,void 0,void 0,(function*(){var t,i,n,o,a,s,r;const l=this.template.compute.descriptors.args,c=this.template.compute.functions,u=null!==(t=this.template.compute.scripts)&&void 0!==t?t:[],d=null!==(i=this.template.compute.queries)&&void 0!==i?i:[],p=e.descriptors,h={descriptors:{enabled:!!(null===(n=null==e?void 0:e.descriptors)||void 0===n?void 0:n.length),args:null!==(o=null==e?void 0:e.descriptors)&&void 0!==o?o:[]},functions:Object.entries(null!==(a=null==e?void 0:e.externals)&&void 0!==a?a:{}).map((([e,t])=>{const i=e.split(":");return{name:i[1],package:i[0],args:t}})),scripts:Object.entries(null!==(s=null==e?void 0:e.scripts)&&void 0!==s?s:{}).filter((([e,t])=>e.startsWith(g)&&3===e.split(":").length)).map((([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}})),queries:Object.entries(null!==(r=null==e?void 0:e.queries)&&void 0!==r?r:{}).filter((([e,t])=>e.startsWith(y)&&3===e.split(":").length)).map((([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}}))};this.template.compute=h;const m=p.filter((e=>!l.includes(e))),v=h.functions.filter((e=>{if(!c.some((t=>t.name===e.name&&t.package===e.package)))return!0;const t=c.find((t=>t.name===e.name&&t.package===e.package));return!Object.entries(e.args).every((([e,i])=>t.args[e]===i))})),f=h.scripts.filter((e=>{if(!u.some((t=>t.id===e.id)))return!0;const t=u.find((t=>t.id===e.id));return!Object.entries(e.args).every((([e,i])=>t.args[e]===i))})),w=h.queries.filter((e=>{if(!d.some((t=>t.id===e.id)))return!0;const t=d.find((t=>t.id===e.id));return!Object.entries(e.args).every((([e,i])=>t.args[e]===i))})),b={};v.forEach((e=>{const t=`${e.package}:${e.name}`;b[t]=e.args}));const C={};f.forEach((e=>{const t=`${g}:${e.name}:${e.id}`;C[t]=e.args}));const A={};w.forEach((e=>{const t=`${y}:${e.name}:${e.id}`;A[t]=e.args})),yield Fe({descriptors:m,externals:b,scripts:C,queries:A},this.dataFrame,this._molColName),this.saveCampaign("In Progress",!1)}))),(()=>null),this.template,!0)}))),"Calculate additional properties"),s=o.bigButton("Submit",(()=>{var e;const t=null===(e=this._submitView)||void 0===e?void 0:e.render();if(t){const e=o.dialog("Submit");e.add(t),e.addButton("Save",(()=>{this.saveCampaign(),e.close()})),e.addButton("Submit",(()=>{var t;null===(t=this._submitView)||void 0===t||t.submit(),e.close()})),e.show()}})),r=o.iconFA("share",(()=>_e(this,void 0,void 0,(function*(){var e;yield new be(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=J(n);return n.push([a,...this.hasEditPermission?[r]:[],...l?[]:[s]]),i.setRibbonPanels(n),i.name=this._filterViewName,setTimeout((()=>_e(this,void 0,void 0,(function*(){var n,o,a;i._onAdded(),yield new Promise((e=>setTimeout(e,1e3)));const s=i.filters(this._campaignFilters?{filters:this._campaignFilters}:void 0),r=null!==(o=null===(n=this._campaign)||void 0===n?void 0:n.layout)&&void 0!==o?o:null===(a=this.template)||void 0===a?void 0:a.layoutViewState;if(r)try{const e=t.ViewLayout.fromViewState(r);i.loadLayout(e)}catch(e){console.error(e)}i.dataFrame.onFilterChanged.subscribe((e=>{this._filterDescriptions=Array.from(i.dataFrame.rows.filters),this._campaignFilters=s.getOptions().look.filters})),setTimeout((()=>{this._filterDescriptions=Array.from(i.dataFrame.rows.filters),this._campaignFilters=s.getOptions().look.filters}),300),e&&e()}))),300),i.parentCall=this.parentCall,i}getSummary(){var e,t,i,n,a,s,r;const l=null!==(t=null===(e=this.campaign)||void 0===e?void 0:e.campaignFields)&&void 0!==t?t:this.campaignProps;return Object.assign(Object.assign({Template:null!==(n=null===(i=this.template)||void 0===i?void 0:i.name)&&void 0!==n?n:"Molecules","File path":o.divH([o.link(null!==(a=this._dfName)&&void 0!==a?a:"-",(()=>this.download(this.dataFrame,"molecules")),x)],{style:{alignItems:"center"}})},l),{"Number of molecules":this.dataFrame.rowCount.toString(),"Enrichment methods":[this.template.compute.descriptors.enabled?"descriptors":"",...this.template.compute.functions.map((e=>e.name))].filter((e=>e&&""!==e.trim())).join(", "),Filters:this._filterDescriptions.join(", "),"Result Molecules":o.divH([o.link(null!==(r=null===(s=this.dataFrame)||void 0===s?void 0:s.filter.trueCount.toString())&&void 0!==r?r:"0",(()=>{this.download(this.dataFrame,"hits",!0)}),x)],{style:{alignItems:"center"}})})}saveCampaign(i){return _e(this,arguments,void 0,(function*(i,n=!0){var a,s,c,u,d,p,h,m,v,f;const g=this.campaignId,y=this.filterSettings,w=this.template.name,b=this.dataFrame,C=`System:AppData/HitTriage/Hit Triage/campaigns/${g}/`,A=null!=g?g:yield function(e){return Se(this,void 0,void 0,(function*(){return new Promise((t=>Se(this,void 0,void 0,(function*(){const i=o.input.string("Campaign name",{value:""});o.dialog("Save Campaign").add(o.div(i.root)).onOK((function(){i.value&&""!==i.value?t(i.value):t(e)})).show()}))))}))}(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 E=null!==(s=null===(a=this.campaign)||void 0===a?void 0:a.authorUserId)&&void 0!==s?s:e.shell.user.id,S=null!==(u=null===(c=this.campaign)||void 0===c?void 0:c.permissions)&&void 0!==u?u:we,N={name:A,templateName:w,filters:null!=y?y:{},ingest:{type:"File",query:`${C}${r}`,molColName:this.molColName},status:null!==(p=null!=i?i:null===(d=this.campaign)||void 0===d?void 0:d.status)&&void 0!==p?p:"In Progress",createDate:null!==(m=null===(h=this.campaign)||void 0===h?void 0:h.createDate)&&void 0!==m?m:q(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:E,permissions:S};if(this.campaign=N,!this.hasEditPermission)return e.shell.error("You do not have permission to modify this campaign"),N;const I=t.DataFrame.fromColumns(b.columns.toList().filter((e=>!e.name.startsWith("~")))).toCsv();yield Qe.files.writeAsText(`Hit Triage/campaigns/${g}/${r}`,I);const F=this._pickView.saveLayout();return F?N.layout=F.viewState:e.shell.warning("Layout cound not be saved"),yield Qe.files.writeAsText(`Hit Triage/campaigns/${g}/${l}`,JSON.stringify(N)),n&&e.shell.info("Campaign saved successfully."),N}))}}function Oe(i,n=!1){var a,s;const r=t.DataFrame.create(1);if(n){const e=r.columns.addNew(m,t.TYPE.STRING);e.semType=t.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,t.TYPE.STRING);l.semType=t.SEMTYPE.MOLECULE,l.meta.units=t.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,t.TYPE.STRING).set(0,i.stages[0]);const c=r.columns.addNew(v,t.TYPE.STRING);c.set(0,Ie(c));const u=i.campaignFields.map((e=>e.type===t.SEMTYPE.MOLECULE?Object.assign(Object.assign({},e),{type:"String",semtype:t.SEMTYPE.MOLECULE}):e)).map((e=>t.Property.fromOptions(Object.assign({name:e.name,type:ee[e.type],nullable:!e.required},e.semtype?{semType:e.semtype}:{})))),d={},f=o.input.form(d,u);f.classList.remove("ui-form");const g=o.div([...(null===(s=i.campaignFields)||void 0===s||s.length,[]),f]),y=o.buttonsInput([]);return g.appendChild(y),{promise:new Promise((t=>{const n=o.bigButton(A,(()=>{for(const t of i.campaignFields)if(t.required&&(!d[t.name]||""===d[t.name]))return void e.shell.error(`Field '${t.name}' is required`);t({df:r,campaignProps:d})}));y.appendChild(n)})),root:g,cancelPromise:new Promise((e=>{o.button(E,(()=>e()))}))}}var Ve=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};function Be(i,n){return Ve(this,void 0,void 0,(function*(){var a,s,r,l,c,d,p,h,m,v,f;const w=yield Qe.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 Qe.files.readAsText(e));x.push(t.key)}catch(e){console.error(e)}const S=t.Func.find({tags:[u]}),N={};S.forEach((e=>{var t;N[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e}));const I=o.input.choice("Submit function",{value:null,items:[null,...Object.keys(N)]});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=o.divText("Template name is empty or already exists",{classes:"hit-triage-error-div"}),_=o.divText("Template key is empty or already exists",{classes:"hit-triage-error-div"}),P=ce();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=o.input.string("Name",{value:null!==(r=null==n?void 0:n.name)&&void 0!==r?r:"",onValueChanged:O});function B(){var e,t,i,n;if(""===k.value||x.includes(null!==(t=null===(e=k.value)||void 0===e?void 0:e.trim())&&void 0!==t?t:"")){const e=null!==(i=k.input.offsetLeft)&&void 0!==i?i:0,t=null!==(n=k.input.offsetWidth)&&void 0!==n?n:0;_.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 k=o.input.string("Key",{value:null!==(l=null==n?void 0:n.key)&&void 0!==l?l:"",onValueChanged:B});k.setTooltip("Template key used for campaign prefix"),V.setTooltip("Template name"),V.root.style.borderBottom="none",k.root.style.borderBottom="none",F.style.opacity="0%",_.style.opacity="0%";let L=null;const j={compute:{descriptors:{enabled:!0,args:null!==(p=null===(d=null===(c=null==n?void 0:n.compute)||void 0===c?void 0:c.descriptors)||void 0===d?void 0:d.args)&&void 0!==p?p:[]},functions:null!==(m=null===(h=null==n?void 0:n.compute)||void 0===h?void 0:h.functions)&&void 0!==m?m:[]}},M=yield ae(i,(e=>{L=e}),(()=>null),j,!1);M.root.classList.add("hit-triage-new-template-functions-input");const R=pe(null==n?void 0:n.campaignFields),D=ke(null==n?void 0:n.stages),U=o.divV([o.divV([V,F]),o.divV([k,_]),P.dataFileInput,R.fieldsDiv]),$=o.h2("Stages");o.tooltip.bind($,'Define Stages for designed molecules. For example, "Design", "Synthesis", "Test", etc.');const H=o.h2("Compute");o.tooltip.bind(H,'Define functions to be calculated for each molecule. For example, "Descriptors", "Descriptors:Descriptors", etc.');const q=o.div([o.h2("Details"),U,$,D.fieldsDiv,H,M.root,o.h2("Submit"),I.root],"ui-form"),Y=o.buttonsInput([]);q.appendChild(Y);const W=null!==(f=null===(v=Y.getElementsByClassName("ui-input-editor"))||void 0===v?void 0:v[0])&&void 0!==f?f:Y,G=new Promise((e=>{const t=o.button(E,(()=>e()));W.appendChild(t)})),J=new Promise((t=>{const n=o.bigButton(T,(()=>function(){return Ve(this,void 0,void 0,(function*(){var n,o,a,s,r,l;if(O(),B(),M.okProxy(),b||!V.value||""===V.value)return void e.shell.error("Template name is empty or already exists");if(C||!k.value||""===k.value)return void e.shell.error("Template key is empty or already exists");const c=I.value?N[I.value]:void 0,u=Object.assign({name:V.value,key:k.value,campaignFields:R.getFields(),stages:D.getFields(),layoutViewState:null!==(n=P.getLayoutViewState())&&void 0!==n?n:void 0,compute:{descriptors:{enabled:!!(null===(o=null==L?void 0:L.descriptors)||void 0===o?void 0:o.length),args:null!==(a=null==L?void 0:L.descriptors)&&void 0!==a?a:[]},functions:Object.entries(null!==(s=null==L?void 0:L.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==L?void 0:L.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==L?void 0:L.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}}))}},c?{submit:{fName:c.name,package:c.package.name}}:{});var d,p;d=u,p=i.appName,Qe.files.writeAsText(`${p}/templates/${d.name}.json`,JSON.stringify(d)),e.shell.info("Template created successfully"),t(u)}))}()));W.appendChild(n)}));return{root:q,template:J,cancelPromise:G}}))}function ke(e){const i=[t.Property.fromOptions({name:"Name",type:t.TYPE.STRING})],n=new re(i,e?e.map((e=>({Name:e}))):void 0,{horizontalInputNames:!0});let o={};return n.onItemAdded.subscribe((e=>{o={}})),n.onAddingItemChanged.subscribe((e=>{e&&(o=e.item)})),{getFields:function(){const e=n.items.filter((e=>e.Name)).map((e=>e.Name));return o.Name&&""!==o.Name&&e.push(o.Name),e},fieldsDiv:n.root,itemsGrid:n}}var 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())}))};class je extends me{constructor(t){super(t),this.name="Hit Design",e.shell.windows.showHelp=!0,e.shell.windows.help.showHelp(Qe.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(Qe.webRoot+"README_HD.md")}getAppHeader(){return ge.appHeader({iconPath:Qe.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(e){return Le(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0);try{const t=o.h1(S),i=o.h1(N,{style:{marginLeft:"10px"}}),n=this.getAppHeader(),a=o.div(),s=o.divH([]),r=o.div([s,a],"ui-form"),l=yield this.getCampaignsTable();ne()(this.root).empty(),this.root.appendChild(o.div([o.divV([n,t],{style:{marginLeft:"10px"}}),l,i,r])),yield this.startNewCampaign(a,s,e),this.app.resetBaseUrl()}finally{o.setUpdateIndicator(this.root,!1)}}))}startNewCampaign(t,i,n){return Le(this,void 0,void 0,(function*(){var a;const s=(yield Qe.files.list(`${this.app.appName}/templates`)).filter((e=>e.name.endsWith(".json"))).map((e=>e.name.slice(0,-5)));n&&!s.includes(n.name)&&s.push(n.name);let r=null,l=!0;const c=()=>Le(this,void 0,void 0,(function*(){if(!l)return;const e=u.value,i=n&&n.name===e?n:JSON.parse(yield Qe.files.readAsText(`${this.app.appName}/templates/${e}.json`));r=i;const o=yield this.getNewCampaignAccordeon(i);ne()(t).empty(),t.appendChild(o)})),u=o.input.choice("Template",{value:null!==(a=null==n?void 0:n.name)&&void 0!==a?a:s[0],items:s,onValueChanged:()=>Le(this,void 0,void 0,(function*(){yield c()}))});u.root.style.width="100%";const d=o.icons.add((()=>{this.createNewTemplate()}),C),p=o.icons.copy((()=>{r&&this.createNewTemplate(r)}),"Clone template"),h=o.icons.delete((()=>{!u.value||u.items.length<2||o.dialog("Delete template").add(o.divText(`Are you sure you want to delete template ${u.value}?`)).onOK((()=>Le(this,void 0,void 0,(function*(){try{const t=u.value;yield Qe.files.delete(`${this.app.appName}/templates/${t}.json`),l=!1,u.items=u.items.filter((e=>e!==t)),u.value=u.items[0],l=!0,yield c(),e.shell.info("Template "+t+" was deleted successfully")}catch(t){l=!0,e.shell.error("Failed to delete template "+u.value),console.error(t)}})))).show()}),"Delete template");d.style.color="#2083d5",u.addOptions(h),u.addOptions(p),u.addOptions(d),yield c(),ne()(i).empty(),i.appendChild(u.root)}))}checkCampaign(e){return Le(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 Qe.files.exists(`${this.app.appName}/campaigns/${o}/${l}`)))return;const a=JSON.parse(yield Qe.files.readAsText(`${this.app.appName}/campaigns/${o}/${l}`));if(a){if(a.authorUserId&&a.permissions&&!(yield X(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 Qe.files.readAsText(`${this.app.appName}/templates/${a.templateName}.json`));return yield this.app.setTemplate(r,o),e&&Y(s,e),a.template=r,a}))}getCampaignsTable(){return Le(this,void 0,void 0,(function*(){const i=yield K(this.app.appName,this.deletedCampaigns),n=i=>{var n,a;const s=o.icons.delete((()=>Le(this,void 0,void 0,(function*(){o.dialog("Delete campaign").add(o.divText(`Are you sure you want to delete campaign ${i.name}?`)).onOK((()=>Le(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=o.iconFA("share",(()=>Le(this,void 0,void 0,(function*(){yield new be(i.permissions).show((t=>Le(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 Qe.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",Z(null!==(n=i.authorUserId)&&void 0!==n?n:t.User.current().id,null!==(a=i.permissions)&&void 0!==a?a:we).then((e=>{e&&(s.style.display="inline-block",r.style.display="inline-block")})),[r,s]},a=o.table(Object.values(i),(e=>[o.link(e.name,(()=>this.setCampaign(e.name)),"",""),e.createDate,e.rowCount,e.status,...n(e)]),["Name","Created","Molecules","Status",""]);return a.style.color="var(--grey-5)",a.style.marginLeft="24px",a}))}setCampaign(e){return Le(this,void 0,void 0,(function*(){const t=yield this.checkCampaign(e);this.app.campaign=t}))}getNewCampaignAccordeon(e){return Le(this,void 0,void 0,(function*(){const{root:t,promise:i,cancelPromise:n}=Oe(e);return i.then((t=>Le(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(void 0,!1),e.layoutViewState&&this.app.campaign&&(this.app.campaign.layout=e.layoutViewState)})))),n.then((()=>{this.init()})),t}))}createNewTemplate(i){return Le(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0);try{const n=yield Be(this.app,i),o=new t.ViewBase,a=e.shell.v;o.name="New Template",o.root.appendChild(n.root),o.parentCall=this.app.parentCall,e.shell.addView(o),o.path=new URL(this.app.baseUrl).pathname+"/new-template";const{sub:s}=W(o,this.app.appName,C,(()=>Le(this,void 0,void 0,(function*(){e.shell.v=a,o.close()}))));n.template.then((t=>Le(this,void 0,void 0,(function*(){yield this.init(t),o.close(),G(o),e.shell.v=a,s.unsubscribe()})))),n.cancelPromise.then((()=>Le(this,void 0,void 0,(function*(){s.unsubscribe(),o.close(),e.shell.v=a}))))}finally{o.setUpdateIndicator(this.root,!1)}}))}}class Me extends me{constructor(e){super(e),this.name="Submit"}render(){return o.empty(this.root),o.divV([o.h1("Summary"),o.div([o.tableFromMap(this.app.getSummary())])])}onActivated(){this.render()}submit(){return i=this,n=void 0,a=function*(){var i;const n=null===(i=this.app.template)||void 0===i?void 0:i.submit;if(!n)return;const o=t.Func.find({name:n.fName,package:n.package})[0];if(!o)return void e.shell.error(`Function ${n.fName} not found.`);const a=t.DataFrame.fromCsv(this.app.dataFrame.toCsv({filteredRowsOnly:!0}));yield o.apply({df:a,molecules:this.app.molColName}),this.app.campaign&&(this.app.campaign.status="Submitted"),this.app.saveCampaign("Submitted"),e.shell.info("Submitted successfully.")},new((o=void 0)||(o=Promise))((function(e,t){function s(e){try{l(a.next(e))}catch(e){t(e)}}function r(e){try{l(a.throw(e))}catch(e){t(e)}}function l(t){var i;t.done?e(t.value):(i=t.value,i instanceof o?i:new o((function(e){e(i)}))).then(s,r)}l((a=a.apply(i,n||[])).next())}));var i,n,o,a}}var Re=i(542),De={};De.styleTagTransform=D(),De.setAttributes=L(),De.insert=B().bind(null,"head"),De.domAPI=O(),De.insertStyleElement=M(),_()(Re.A,De),Re.A&&Re.A.locals&&Re.A.locals;function Ue(i,n){var a,s,r,l,c,u,d,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=o.dialog("Progress Tracker");try{y=g.addViewer(t.VIEWER.TILE_VIEWER,f);const e=y.getOptions();e.look.sketchState=(null!==(u=null===(c=null==v?void 0:v.elementStates)||void 0===c?void 0:c.length)&&void 0!==u?u:0)>0?v:null,y.setOptions(e),y.copyViewersLook(y)}catch(n){e.shell.error("Failed to create tiles viewer with preset layout.\n Falling back to default layout."),console.error("Failed to create tiles viewer",n),y&&(y.close(),y.detach()),y=g.addViewer(t.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 t=ke(i.stages);b=o.dialog("Modify Stages").add(t.fieldsDiv).onOK((()=>{return a=this,s=void 0,l=function*(){C(),o.setUpdateIndicator(w.root,!0);try{yield i.setStages(t.getFields()),o.setUpdateIndicator(w.root,!1),w.close(),yield new Promise((e=>setTimeout((()=>{e(),Ue(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===(d=w.getButton("CANCEL"))||void 0===d||d.remove(),w.onOK((()=>{})),null===(h=document.querySelector(".d4-modal-background"))||void 0===h||h.remove()}const $e=rxjs.operators;var He=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 qe extends Ee{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,i="Hit Design",n=e=>new je(e)){super(e,i),this._designViewName="Design",this._filePath=`System.AppData/HitTriage/${this.appName}/campaigns`,this._molColName=h,this.campaignProps={},this._infoView=n(this),this.multiView=new t.MultiView({viewFactories:{[this._infoView.name]:()=>this._infoView}}),this.multiView.tabs.onTabChanged.subscribe((e=>{this.multiView.currentView instanceof me&&this.multiView.currentView.onActivated()})),this.multiView.parentCall=e,this.mainView=this.multiView,this._initViewChangeSub()}_initViewChangeSub(){this.multiView.subs.push(e.events.onCurrentViewChanged.subscribe((()=>He(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(),Y(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}=W(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)}})))))}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 He(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,c=n.getRawData();for(let e=0;e<r;e++){const i=l[c[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(void 0,!0)}))}setTemplate(i,n){return He(this,void 0,void 0,(function*(){var o,l,c,u,d,p,m,v,f,g,y;if(n){const t=`System.AppData/HitTriage/${this.appName}/campaigns`;this._filePath=null!==(c=null===(l=this.campaign)||void 0===l?void 0:l.savePath)&&void 0!==c?c:`${t}/${n}/${r}`,this.dataFrame=yield e.dapi.files.readCsv(this._filePath),(null===(u=this._campaign)||void 0===u?void 0:u.columnSemTypes)&&Object.entries(this._campaign.columnSemTypes).forEach((([e,t])=>{const i=this.dataFrame.columns.byName(e);i&&t&&(i.semType=t)})),(null===(d=this._campaign)||void 0===d?void 0:d.columnTypes)&&Object.entries(this._campaign.columnTypes).forEach((([e,t])=>{const i=this.dataFrame.columns.byName(e);if(i&&i.type!==t)try{this.dataFrame.changeColumnType(e,t)}catch(e){console.error(e)}}))}else(null===(o=this._designView)||void 0===o?void 0:o.dataFrame)&&e.shell.closeTable(this._designView.dataFrame),this._designView=void 0,n=yield this.getNewCampaignName(`${this.appName}/campaigns`,i.key),Y(s,n),this._filePath=`System.AppData/HitTriage/${this.appName}/campaigns/${n}/${r}`;if(!this.dataFrame)return void console.error("DataFrame is empty");yield this.dataFrame.meta.detectSemanticTypes(),this._molColName=null!==(m=null===(p=this.dataFrame.columns.bySemType(t.SEMTYPE.MOLECULE))||void 0===p?void 0:p.name)&&void 0!==m?m:h,this._campaignId=n,this.template=i,null!==(v=this._submitView)&&void 0!==v||(this._submitView=new Me(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(),Y(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=i)}))}get campaignId(){return this._campaignId}get designView(){return this._designView=this.getDesignView()}get designViewName(){return this._designViewName}get molColName(){var e,i,n,o;return null!==(e=this._molColName)&&void 0!==e?e:this._molColName=null!==(o=null===(n=null===(i=this.dataFrame)||void 0===i?void 0:i.columns.bySemType(t.SEMTYPE.MOLECULE))||void 0===n?void 0:n.name)&&void 0!==o?o:h}get campaign(){return this._campaign}set campaign(e){this._campaign=e}cacheDuplicateVIDs(){var e;const t=null===(e=this.dataFrame)||void 0===e?void 0:e.col(v);if(!t)return void(this._duplicateVidCache=void 0);const i=t.version,n=new Uint32Array(t.categories.length).fill(0),o=t.getRawData().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(i,n){return He(this,void 0,void 0,(function*(){const o=this.template.compute;if(!n||""===n)return;const a=yield function(i,n,o){return Ne(this,arguments,void 0,(function*(i,n,o,a=[],s=[]){const r=t.TaskBarProgressIndicator.create("Calculating ..."),l=e.chem.convert(i,e.chem.Notation.Unknown,e.chem.Notation.Smiles),c=t.Column.fromStrings(h,[l]),u=t.DataFrame.fromColumns([c]);u.name="HD Single cell values",yield u.meta.detectSemanticTypes();try{n.length&&(yield e.chem.descriptors(u,c.name,n))}catch(e){console.error("Descriptors calculation error",e)}for(const e of o)try{const i=e.args,n=t.Func.find({package:e.package,name:e.name});if(!n.length||!n[0]){console.warn(`Function ${e.name} from package ${e.package} is not found`);continue}const o=n[0],a=o.inputs[0].name,s=o.inputs[1].name;yield o.apply(Object.assign(Object.assign({},i),{[a]:u,[s]:c.name}))}catch(e){console.error(e);continue}for(const e of a){const i=e.args;try{const n=t.Func.find({name:e.name}).filter((t=>t.type===I.script&&t.id===e.id))[0];if(n){const e=n.inputs[0].name,t=n.inputs[1].name,o=yield n.apply(Object.assign(Object.assign({},i),{[e]:u,[t]:c.name}));if(o&&o.rowCount===u.rowCount&&"python"===n.language)for(const e of o.columns)e.name=u.columns.getUnusedName(e.name),u.columns.add(e)}}catch(e){console.error(e)}}for(const e of s){const i=e.args;try{const n=t.Func.find({name:e.name}).filter((t=>t.type===I.query&&t.id===e.id))[0];if(n){const e=n.inputs[0].name,t=[l],o=yield n.apply(Object.assign(Object.assign({},i),{[e]:t}));if(!o||0===o.rowCount)continue;yield z(u,h,o)}}catch(e){console.error(e)}}return r.close(),u}))}(n,o.descriptors.args,o.functions,o.scripts,o.queries);for(const e of a.columns.toList())e.name!==h&&(this.dataFrame.columns.contains(e.name)||(this.dataFrame.columns.addNew(e.name,e.type).semType=e.semType),this.dataFrame.col(e.name).set(i,e.get(0),!1));this.dataFrame.fireValuesChanged(),this.saveCampaign(void 0,!1)}))}initDesignViewRibbons(t,i){const n=e.events.onViewRemoved.subscribe((e=>{e.id===(null==t?void 0:t.id)&&(i.forEach((e=>e.unsubscribe())),n.unsubscribe())}));let a=null==t?void 0:t.getRibbonPanels();if(a&&!J(a)){const e=()=>He(this,void 0,void 0,(function*(){var e;ae(this,(e=>He(this,void 0,void 0,(function*(){var i,n,a,s,r,l,c,u,d,p;const h=this.template.compute.descriptors.args,m=this.template.compute.functions,v=null!==(i=this.template.compute.scripts)&&void 0!==i?i:[],f=null!==(n=this.template.compute.queries)&&void 0!==n?n:[],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!==(c=null==e?void 0:e.queries)&&void 0!==c?c:{}).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!==(u=null==e?void 0:e.externals)&&void 0!==u?u:{}).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!==(d=null==e?void 0:e.scripts)&&void 0!==d?d:{}).filter((([e,t])=>{const i=v.find((t=>`${g}:${t.name}:${t.id}`===e));return!i||!Object.entries(t).every((([e,t])=>i.args[e]===t))})).forEach((([e,t])=>{T[e]=t}));const x={};Object.entries(null!==(p=null==e?void 0:e.queries)&&void 0!==p?p:{}).filter((([e,t])=>{const i=f.find((t=>`${y}:${t.name}:${t.id}`===e));return!i||!Object.entries(t).every((([e,t])=>i.args[e]===t))})).forEach((([e,t])=>{x[e]=t})),o.setUpdateIndicator(t.grid.root,!0);try{yield Fe({descriptors:C,externals:A,scripts:T,queries:x},this.dataFrame,this.molColName),this.dataFrame.fireValuesChanged()}finally{o.setUpdateIndicator(t.grid.root,!1),this.saveCampaign(void 0,!1)}}))),(()=>null),null===(e=this.campaign)||void 0===e?void 0:e.template,!0)})),i=o.iconFA("wrench",e,"Calculate additional properties"),n=o.icons.add((()=>{var e;null===(e=this.dataFrame)||void 0===e||e.rows.addNew(null,!0)}),"Add new row"),s=o.iconFA("share",(()=>He(this,void 0,void 0,(function*(){var e;yield new be(null===(e=this.campaign)||void 0===e?void 0:e.permissions).show((e=>{this.campaign.permissions=e,this.saveCampaign(void 0,!0)}))}))),"Edit campaign permissions"),r=o.bigButton("Progress tracker",(()=>{Ue(this,(()=>{var e;return null!==(e=this._designView)&&void 0!==e?e:null}))})),l=o.bigButton("Submit",(()=>{var e;const t=null===(e=this._submitView)||void 0===e?void 0:e.render();if(t){const e=o.dialog("Submit");e.add(t),e.addButton("Save",(()=>{this.saveCampaign(),e.close()})),e.addButton("Submit",(()=>{var t;null===(t=this._submitView)||void 0===t||t.submit(),e.close()})),e.show()}}));l.classList.add("hit-design-submit-button");const c=[l];this.stages.length>0&&c.unshift(r),this.campaign&&this.template&&!this.campaign.template&&(this.campaign.template=this.template),this.hasEditPermission&&c.unshift(s),c.unshift(i),c.unshift(n),a.push(c),a.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)})),a=a.filter((e=>{var t;return(null!==(t=null==e?void 0:e.length)&&void 0!==t?t:0)>0})),t.setRibbonPanels(a)}return t}getDesignView(){var i,n,o,a,s,r;const l=[],c=null===(i=this.dataFrame.col(this.molColName))||void 0===i?void 0:i.toList().every((e=>!e&&""===e)),u=e.shell.addTableView(this.dataFrame);this._designViewName=null!==(o=null===(n=this.campaign)||void 0===n?void 0:n.name)&&void 0!==o?o:this._designViewName,u.name=this._designViewName,u._onAdded();const d=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(d)try{const e=t.ViewLayout.fromViewState(d);u.loadLayout(e)}catch(t){e.shell.error("Failed to apply layout. Falling back to default layout."),console.error(t)}return c&&e.functions.call("Chem:editMoleculeCell",{cell:u.grid.cell(this._molColName,0)}),l.push(this.dataFrame.onRowsAdded.pipe((0,$e.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=u.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((i=>{var n,o,a,s,r,l,c,d,p,h,m,v;try{const e=null===(n=null==i?void 0:i.args)||void 0===n?void 0:n.context;if(!e)return;if((null==e?void 0:e.type)!==t.VIEWER.GRID)return;if(!e.tableView||e.tableView.id!==u.id)return;if((null===(s=null===(a=null===(o=null==i?void 0:i.args)||void 0===o?void 0:o.item)||void 0===a?void 0:a.tableColumn)||void 0===s?void 0:s.name)!==this.molColName||!(null===(l=null===(r=null==i?void 0:i.args)||void 0===r?void 0:r.item)||void 0===l?void 0:l.isTableCell))return;const f=null===(c=null==i?void 0:i.args)||void 0===c?void 0:c.menu;if(!f)return;f.item("Add new row",(()=>{this.dataFrame.rows.addNew(null,!0)})),f.item("Duplicate molecule",(()=>{var e,t,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===(t=null===(e=null==i?void 0:i.args)||void 0===e?void 0:e.item)||void 0===t?void 0:t.cell)||void 0===n?void 0:n.value)&&void 0!==o?o:"")}catch(e){console.error(e)}}));const g=null===(p=null===(d=null==i?void 0:i.args)||void 0===d?void 0:d.item)||void 0===p?void 0:p.tableRowIndex,y=null===(v=null===(m=null===(h=null==i?void 0:i.args)||void 0===h?void 0:h.item)||void 0===m?void 0:m.cell)||void 0===v?void 0:v.value;y&&(null!=g?g:-1)>-1&&f.item("Re-Run Calculations",(()=>He(this,void 0,void 0,(function*(){try{yield this.performSingleCellCalculations(g,y)}catch(e){console.error(e)}}))))}catch(t){e.log.error(t)}}))),(null==u?void 0:u.grid)||(e.shell.error("Applied layout created view without grid. Resetting layout."),u.resetLayout()),(null==u?void 0:u.grid)&&l.push(u.grid.onCellValueEdited.subscribe((t=>He(this,void 0,void 0,(function*(){var i,n,o,a,s;try{if((null===(i=t.tableColumn)||void 0===i?void 0:i.name)===p)return void(yield this.saveCampaign(void 0,!1));if((null===(n=t.tableColumn)||void 0===n?void 0:n.name)!==this.molColName)return;const r=t.cell.value,l=t.tableRowIndex;let c=null===(o=this.dataFrame.col(v))||void 0===o?void 0:o.get(l),u=!1;if(r)try{const i=t.tableColumn.toList().map((t=>{try{return e.chem.convert(t,e.chem.Notation.Unknown,e.chem.Notation.Smiles)}catch(e){return""}})),n=e.chem.convert(r,e.chem.Notation.Unknown,e.chem.Notation.Smiles);if((null==i?void 0:i.length)===this.dataFrame.rowCount)for(let e=0;e<i.length;e++)if(i[e]===n&&e!==l&&(null===(a=this.dataFrame.col(v))||void 0===a?void 0:a.get(e))){c=null===(s=this.dataFrame.col(v))||void 0===s?void 0:s.get(e),u=!0;break}}catch(e){console.error(e)}this.duplicateVidCache&&!u&&this.duplicateVidCache.valueCounts[this.duplicateVidCache.indexes[l]]>1&&(c=null),c&&""!==c||(c=Ie(this.dataFrame.col(v))),this.dataFrame.col(v).set(l,c,!1),this.performSingleCellCalculations(l,r)}catch(e){console.error(e)}}))))),(null==u?void 0:u.grid)&&l.push(u.grid.onCellRender.subscribe((e=>{var i;try{const n=e.cell;if(!n||!n.isTableCell||!n.tableColumn||!this.duplicateVidCache||n.tableColumn.name!==v||(null!==(i=n.tableRowIndex)&&void 0!==i?i:-1)<0)return;this.duplicateVidCache.valueCounts[this.duplicateVidCache.indexes[n.tableRowIndex]]>1&&(e.cell.style.backColor=t.Color.setAlpha(t.Color.getCategoricalColor(this.duplicateVidCache.indexes[n.tableRowIndex]),150))}catch(e){}}))),this.initDesignViewRibbons(u,l),u.parentCall=this.parentCall,u}getSummary(){var i,n,a,s;const l=()=>{var e,t;const i=this._filePath.indexOf(null!==(e=this.campaignId)&&void 0!==e?e:null===(t=this._campaign)||void 0===t?void 0:t.name);return-1===i?this._filePath:this._filePath.substring(0,i-1)},c=Object.assign({},null!==(n=null===(i=this.campaign)||void 0===i?void 0:i.campaignFields)&&void 0!==n?n:this.campaignProps);return this.template&&this.template.campaignFields&&Object.entries(c).forEach((([i,n])=>{const o=this.template.campaignFields.find((e=>e.name===i));o&&"Date"===o.type&&n?"Invalid Date"!==new Date(n).toString()?c[i]=new Date(n).toLocaleDateString():n.date?c[i]=new Date(n.date).toLocaleDateString():c[i]=n:o&&o.type===t.SEMTYPE.MOLECULE&&n&&(c[i]=e.chem.drawMolecule(n))})),Object.assign(Object.assign({Template:null!==(s=null===(a=this.template)||void 0===a?void 0:a.name)&&void 0!==s?s:"Molecules","File path":(()=>{const t=o.icons.edit((()=>{const i=l(),s=o.input.string("Path",{value:i}),c=s.root.getElementsByTagName("label").item(0);c&&c.remove(),s.root.style.width="100%";const u=o.button("Save",(()=>He(this,void 0,void 0,(function*(){const i=yield function(){return He(this,void 0,void 0,(function*(){const t=s.value;return t&&""!==t.trim()?!!(yield e.dapi.files.exists(t))||(e.shell.error("Given folder does not exist"),!1):(e.shell.error("Path can not be empty"),!1)}))}();if(!i)return;const c=s.value;c.endsWith("/")?this._filePath=`${c}${this.campaignId}/${r}`:this._filePath=`${c}/${this.campaignId}/${r}`,this._campaign&&(this._campaign.savePath=this._filePath),yield this.saveCampaign(void 0,!0),o.empty(a);const u=l();n=o.link(u,(()=>{var e,t,i;return this.download(this.dataFrame,null!==(i=null!==(e=this.campaignId)&&void 0!==e?e:null===(t=this._campaign)||void 0===t?void 0:t.name)&&void 0!==i?i:"Molecules")}),x),a.appendChild(n),a.appendChild(t)})))),d=o.button("Cancel",(()=>{o.empty(a),a.appendChild(n),a.appendChild(t)}));o.empty(a),s.addOptions(d),s.addOptions(u),a.appendChild(s.root)}),"Edit file path");t.style.marginLeft="5px";const i=l();let n=o.link(i,(()=>{var e,t,i;return this.download(this.dataFrame,null!==(i=null!==(e=this.campaignId)&&void 0!==e?e:null===(t=this._campaign)||void 0===t?void 0:t.name)&&void 0!==i?i:"Molecules")}),x);const a=o.divH([n,t],{style:{alignItems:"center"}});return a})()},c),{"Number of molecules":this.dataFrame.rowCount.toString(),"Enrichment methods":[this.template.compute.descriptors.enabled?"descriptors":"",...this.template.compute.functions.map((e=>e.name))].filter((e=>e&&""!==e.trim())).join(", ")})}saveCampaign(i){return He(this,arguments,void 0,(function*(i,n=!0){var o,a,s,r,c,u,d,p,h,m,v,f,g,y;const w=this.campaignId,b=this.template.name,C=this.dataFrame,A=w,T={};C.columns.toList().forEach((e=>T[e.name]=e.semType));const x={};C.columns.toList().forEach((e=>x[e.name]=e.type));const E=null!==(a=null===(o=this.campaign)||void 0===o?void 0:o.tilesViewerFormSketch)&&void 0!==a?a:void 0,S=null!==(r=null===(s=this.campaign)||void 0===s?void 0:s.authorUserId)&&void 0!==r?r:e.shell.user.id,N=null!==(u=null===(c=this.campaign)||void 0===c?void 0:c.permissions)&&void 0!==u?u:we,I={name:A,templateName:b,status:null!==(p=null!=i?i:null===(d=this.campaign)||void 0===d?void 0:d.status)&&void 0!==p?p:"In Progress",createDate:null!==(m=null===(h=this.campaign)||void 0===h?void 0:h.createDate)&&void 0!==m?m:q(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:C.rowCount,filteredRowCount:C.filter.trueCount,savePath:this._filePath,columnTypes:x,tilesViewerFormSketch:E,version:this.version+1,authorUserId:S,permissions:N};if(!this.hasEditPermission)return e.shell.error("You do not have permission to modify this campaign"),I;const F=`${this.appName}/campaigns/${w}/${l}`;let _=C;if(yield Qe.files.exists(F)){const t=JSON.parse(yield Qe.files.readAsText(F));if((null!==(g=t.version)&&void 0!==g?g:0)>this.version&&(I.version=Math.max(this.version,null!==(y=t.version)&&void 0!==y?y:0)+1,yield e.dapi.files.exists(this._filePath)))try{const t=yield e.dapi.files.readCsv(this._filePath);_=this.unionDataframes(t,C,this.molColName)}catch(e){console.error(e)}}const P=t.DataFrame.fromColumns(_.columns.toList().filter((e=>!e.name.startsWith("~")))).toCsv();yield e.dapi.files.writeAsText(this._filePath,P);const O=this._designView.saveLayout();return O?I.layout=O.viewState:e.shell.warning("Layout cound not be saved"),I.template=this.template,yield Qe.files.writeAsText(F,JSON.stringify(I)),n&&e.shell.info("Campaign saved successfully."),this.campaign=I,I}))}}class Ye extends t.GridCellRenderer{get name(){return"customGasteigerPNG"}get cellType(){return"customGasteigerPNG"}get defaultHeight(){return 200}get defaultWidth(){return 200}render(e,t,i,n,o,a,s){if(a.gridRow<0||!a.cell.value)return;const r=a.cell.value,l=new Image(n-2,o-2);l.src="data:image/png;base64,"+r,l.onload=function(){e.drawImage(l,t+2,i+2,n-2,o-2)}}}var We=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};class Ge extends je{constructor(t){super(t),this.name="PeptiHit",e.shell.windows.showHelp=!0,e.shell.windows.help.showHelp(Qe.webRoot+"README_HD.md")}getNewCampaignAccordeon(e){return We(this,void 0,void 0,(function*(){const{root:t,promise:i,cancelPromise:n}=Oe(e,!0);return i.then((t=>We(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(void 0,!1),e.layoutViewState&&this.app.campaign&&(this.app.campaign.layout=e.layoutViewState)})))),n.then((()=>{this.init()})),t}))}getAppHeader(){return ge.appHeader({iconPath:Qe.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 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())}))};class ze extends qe{constructor(e){super(e,"PeptiHit",(e=>new Ge(e))),this._helmColName=m}setTemplate(e,i){const n=Object.create(null,{setTemplate:{get:()=>super.setTemplate}});return Je(this,void 0,void 0,(function*(){var o,a;yield n.setTemplate.call(this,e,i),this._helmColName=null!==(a=null===(o=this.dataFrame.columns.bySemType(t.SEMTYPE.MACROMOLECULE))||void 0===o?void 0:o.name)&&void 0!==a?a:m}))}get helmColName(){var e,i;return null!==(e=this._helmColName)&&void 0!==e?e:null===(i=this.dataFrame.columns.bySemType(t.SEMTYPE.MACROMOLECULE))||void 0===i?void 0:i.name}performSingleCellCalculations(i,n){const o=Object.create(null,{performSingleCellCalculations:{get:()=>super.performSingleCellCalculations}});return Je(this,void 0,void 0,(function*(){var a;try{if(!n)throw new Error("No cell value provided");const s=t.Column.fromStrings(this.helmColName,[n]),r=t.DataFrame.fromColumns([s]);s.semType=t.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())),c=l?null===(a=r.col(l))||void 0===a?void 0:a.get(0):null;if(!c)throw new Error("Failed to convert sequence to atomic level");this.dataFrame.set(this.molColName,i,c),yield o.performSingleCellCalculations.call(this,i,c)}catch(e){console.error(e)}}))}getDesignView(){var i,n,o,a,s,r;const l=[],c=null===(i=this.dataFrame.col(this.helmColName))||void 0===i?void 0:i.toList().every((e=>!e&&""===e)),u=this.dataFrame.col(this.helmColName);if(!u)throw new Error("No helm column found");u.semType=t.SEMTYPE.MACROMOLECULE,u.setTag("units","helm"),u.setTag(".alphabetIsMultichar","true"),u.setTag("cell.renderer","helm");const d=e.shell.addTableView(this.dataFrame);this._designViewName=null!==(o=null===(n=this.campaign)||void 0===n?void 0:n.name)&&void 0!==o?o:this._designViewName,d.name=this._designViewName,d._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=t.ViewLayout.fromViewState(h);d.loadLayout(e)}catch(t){e.shell.error("Failed to apply layout. Falling back to default layout."),console.error(t)}return c&&e.functions.call("Helm:editMoleculeCell",{cell:d.grid.cell(this.helmColName,0)}),l.push(this.dataFrame.onRowsAdded.pipe((0,$e.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.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((i=>{var n,o,a,s,r,l,c,u,p,h,m,v;try{const e=null===(n=null==i?void 0:i.args)||void 0===n?void 0:n.context;if(!e)return;if((null==e?void 0:e.type)!==t.VIEWER.GRID)return;if(!e.tableView||e.tableView.id!==d.id)return;if((null===(s=null===(a=null===(o=null==i?void 0:i.args)||void 0===o?void 0:o.item)||void 0===a?void 0:a.tableColumn)||void 0===s?void 0:s.name)!==this.helmColName||!(null===(l=null===(r=null==i?void 0:i.args)||void 0===r?void 0:r.item)||void 0===l?void 0:l.isTableCell))return;const f=null===(c=null==i?void 0:i.args)||void 0===c?void 0:c.menu;if(!f)return;f.item("Add new row",(()=>{this.dataFrame.rows.addNew(null,!0)})),f.item("Duplicate Sequence",(()=>{var e,t,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===(t=null===(e=null==i?void 0:i.args)||void 0===e?void 0:e.item)||void 0===t?void 0:t.cell)||void 0===n?void 0:n.value)&&void 0!==o?o:"")}catch(e){console.error(e)}}));const g=null===(p=null===(u=null==i?void 0:i.args)||void 0===u?void 0:u.item)||void 0===p?void 0:p.tableRowIndex,y=null===(v=null===(m=null===(h=null==i?void 0:i.args)||void 0===h?void 0:h.item)||void 0===m?void 0:m.cell)||void 0===v?void 0:v.value;y&&(null!=g?g:-1)>-1&&f.item("Re-Run Calculations",(()=>Je(this,void 0,void 0,(function*(){try{yield this.performSingleCellCalculations(g,y)}catch(e){console.error(e)}}))))}catch(t){e.log.error(t)}}))),(null==d?void 0:d.grid)||(e.shell.error("Applied layout created view without grid. Resetting layout."),d.resetLayout()),(null==d?void 0:d.grid)&&l.push(d.grid.onCellValueEdited.subscribe((e=>Je(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(void 0,!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),c=!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),c=!0;break}}catch(e){console.error(e)}this.duplicateVidCache&&!c&&this.duplicateVidCache.valueCounts[this.duplicateVidCache.indexes[r]]>1&&(l=null),l&&""!==l||(l=Ie(this.dataFrame.col(v))),this.dataFrame.col(v).set(r,l,!1),this.performSingleCellCalculations(r,s)}catch(e){console.error(e)}}))))),(null==d?void 0:d.grid)&&l.push(d.grid.onCellRender.subscribe((e=>{var i;try{const n=e.cell;if(!n||!n.isTableCell||!n.tableColumn||!this.duplicateVidCache||n.tableColumn.name!==v||(null!==(i=n.tableRowIndex)&&void 0!==i?i:-1)<0)return;this.duplicateVidCache.valueCounts[this.duplicateVidCache.indexes[n.tableRowIndex]]>1&&(e.cell.style.backColor=t.Color.setAlpha(t.Color.getCategoricalColor(this.duplicateVidCache.indexes[n.tableRowIndex]),150))}catch(e){}}))),this.initDesignViewRibbons(d,l),d.parentCall=this.parentCall,d}}var Ke=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 Qe=new t.Package;function Ze(i,n,o){return Ke(this,void 0,void 0,(function*(){const a=yield K(o,[]);for(const[o,s]of Object.entries(a)){const o="ingest"in s?s.ingest.query:s.savePath;o&&!1!==(yield e.dapi.files.exists(o))&&i.item(s.name).onSelected.subscribe((i=>Ke(this,void 0,void 0,(function*(){try{const i=yield e.dapi.files.readCsv(o);if(!i)return;const a=s.columnSemTypes;if(a)for(const[e,n]of Object.entries(a)){const o=i.columns.byName(e);o&&(o.semType=n,n===t.SEMTYPE.MACROMOLECULE&&e===m&&(o.setTag("units","helm"),o.setTag(".alphabetIsMultichar","true"),o.setTag("cell.renderer","helm")))}const r=t.TableView.create(i,!1);n.preview=r;const l=s.layout;l&&r.loadLayout(t.ViewLayout.fromViewState(l))}catch(e){console.error(e)}}))))}}))}function Xe(e,t){return Ke(this,void 0,void 0,(function*(){yield Ze(e,t,"Hit Triage")}))}function et(e,t){return Ke(this,void 0,void 0,(function*(){yield Ze(e,t,"Hit Design")}))}function tt(e,t){return Ke(this,void 0,void 0,(function*(){yield Ze(e,t,"PeptiHit")}))}function it(){return Ke(this,void 0,void 0,(function*(){const t=e.functions.getCurrentCall();return new Pe(t).multiView}))}function nt(){return Ke(this,void 0,void 0,(function*(){const t=e.functions.getCurrentCall();return new qe(t).multiView}))}function ot(){return Ke(this,void 0,void 0,(function*(){const t=e.functions.getCurrentCall();return yield e.functions.call("Bio:initBio",{}),new ze(t).multiView}))}function at(){return Ke(this,void 0,void 0,(function*(){const t=e.data.demo.molecules(100);return t.name="100 Molecules",t}))}function st(){return Ke(this,void 0,void 0,(function*(){const t=e.data.demo.molecules(5e3);return t.name="5000 Molecules",t}))}function rt(t){return Ke(this,void 0,void 0,(function*(){const i=e.data.demo.molecules(t);return i.name="Variable Molecules number",i}))}function lt(t,i){return Ke(this,void 0,void 0,(function*(){e.shell.info(t.rowCount),e.shell.info(i)}))}function ct(){return new Ye}})(),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"),c=Array.isArray,u=Array.prototype,d=u.concat,p=u.filter,h=u.indexOf,m=u.map,v=u.push,f=u.slice,g=u.some,y=u.splice,w=/^#(?:[\w-]|\\.|[^\x00-\xa0])*$/,b=/^\.(?:[\w-]|\\.|[^\x00-\xa0])*$/,C=/<.+>/,A=/^\w+$/;function T(e,t){var i,n=!!(i=t)&&11===i.nodeType;return e&&(n||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(I(e))return e;var o=e;if(P(e)){var a=n||t;if(!(o=w.test(e)&&F(a)?a.getElementById(e.slice(1).replace(/\\/g,"")):C.test(e)?Z(e):I(a)?a.find(e):P(a)?E(a).find(e):T(e,a)))return}else if(O(e))return this.ready(e);(o.nodeType||o===i)&&(o=[o]),this.length=o.length;for(var s=0,r=this.length;s<r;s++)this[s]=o[s]}}return e.prototype.init=function(t,i){return new e(t,i)},e}(),S=x.prototype,E=S.init;function I(e){return e instanceof x}function N(e){return!!e&&e===e.window}function F(e){return!!e&&9===e.nodeType}function _(e){return!!e&&1===e.nodeType}function O(e){return"function"==typeof e}function P(e){return"string"==typeof e}function V(e){return void 0===e}function B(e){return null===e}function k(e){return!isNaN(parseFloat(e))&&isFinite(e)}function L(e){if("object"!=typeof e||null===e)return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function 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(L(e))for(var o=Object.keys(e),a=(n=0,o.length);n<a;n++){var s=o[n];if(!1===t.call(e[s],s,e[s]))return e}else for(n=0,a=e.length;n<a;n++)if(!1===t.call(e[n],n,e[n]))return e;return e}function j(){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 j(i,E,n);for(var a=0;a<o;a++){var s=e[a];for(var r in s)i&&(c(s[r])||L(s[r]))?(n[r]&&n[r].constructor===s[r].constructor||(n[r]=new s[r].constructor),j(i,n[r],s[r])):n[r]=s[r]}return n}E.fn=E.prototype=S,S.length=0,S.splice=y,"function"==typeof Symbol&&(S[Symbol.iterator]=u[Symbol.iterator]),E.isWindow=N,E.isFunction=O,E.isArray=c,E.isNumeric=k,E.isPlainObject=L,E.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)}))},E.extend=j,S.extend=function(e){return j(S,e)};var R=/\S+/g;function U(e){return P(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=U(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=U(e);return this.each((function(e,i){_(i)&&M(t,(function(e,t){i.removeAttribute(t)}))}))},S.attr=function(e,t){if(e){if(P(e)){if(arguments.length<2){if(!this[0]||!_(this[0]))return;var i=this[0].getAttribute(e);return B(i)?void 0:i}return V(t)?this:B(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 E(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 W(e,t){var i=e&&(e.matches||e.webkitMatchesSelector||e.msMatchesSelector);return!!i&&!!t&&i.call(e,t)}function G(e){return P(e)?function(t,i){return W(i,e)}:O(e)?e:I(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=G(e);return E(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(!P(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,E(i.childNodes).detach().get()}function X(e,t,i,n){for(var o=[],a=O(t),s=n&&G(n),r=0,l=e.length;r<l;r++)if(a){var c=t(e[r]);c.length&&v.apply(o,c)}else for(var u=e[r][t];!(null==u||n&&s(-1,u));)o.push(u),u=i?u[t]:null;return o}function ee(e){return e.multiple&&e.options?X(p.call(e.options,(function(e){return e.selected&&!e.disabled&&!e.parentNode.disabled})),"value"):e.value||""}function te(e){return e.length>1?p.call(e,(function(e,t,i){return h.call(i,e)===t})):e}E.parseHTML=Z,S.has=function(e){var t=P(e)?function(t,i){return T(e,i).length}:function(t,i){return i.contains(e)};return this.filter(t)},S.not=function(e){var t=G(e);return this.filter((function(i,n){return(!P(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||Pe.test(i.type)){var o=c(e)?m.call(e,String):B(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)||B(e)?"":e})):this[0]&&ee(this[0])},S.is=function(e){var t=G(e);return g.call(this,(function(e,i){return t.call(e,i,e)}))},E.guid=1,E.unique=te,S.add=function(e,t){return E(te(this.get().concat(E(e,t).get())))},S.children=function(e){return J(E(te(X(this,(function(e){return e.children})))),e)},S.parent=function(e){return J(E(te(X(this,"parentNode"))),e)},S.index=function(e){var t=e?E(e)[0]:this[0],i=e?this:E(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(E(te(X(this,(function(e){return E(e).parent().children().not(e)})))),e)},S.find=function(e){return E(te(X(this,(function(t){return T(e,t)}))))};var ie=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,ne=/^$|^module$|\/(java|ecma)script/i,oe=["type","src","nonce","noModule"];function ae(e,t,i,a,s,r,l,c){return M(e,(function(e,r){M(E(r),(function(e,r){M(E(t),(function(t,l){var c=i?l:r,u=i?e:t;!function(e,t,i,a,s){a?e.insertBefore(t,i?e.firstChild:null):"HTML"===e.nodeName?e.parentNode.replaceChild(t,e):e.parentNode.insertBefore(t,i?e:e.nextSibling),s&&function(e,t){var i=E(e);i.filter("script").add(i.find("script")).each((function(e,i){if(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,u?c.cloneNode(!0):c,a,s,!u)}),c)}),l)}),r),t}S.after=function(){return ae(arguments,this,!1,!1,!1,!0,!0)},S.append=function(){return ae(arguments,this,!1,!1,!0)},S.html=function(e){if(!arguments.length)return this[0]&&this[0].innerHTML;if(V(e))return this;var t=/<script[\s>]/.test(e);return this.each((function(i,n){_(n)&&(t?E(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=E(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=E(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=E(e)[0];E(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 E(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(E(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(E(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(E(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 E(d.apply([],m.call(this,(function(t,i){return e.call(t,i,t)}))))},S.clone=function(){return this.map((function(e,t){return t.cloneNode(!0)}))},S.offsetParent=function(){return this.map((function(e,t){for(var i=t.offsetParent;i&&"static"===D(i,"position");)i=i.offsetParent;return i||n}))},S.slice=function(e,t){return E(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,E)};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=E(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=E(o).offset();i.top-=a.top+$(o,"borderTopWidth"),i.left-=a.left+$(o,"borderLeftWidth")}}return{top:i.top-$(e,"marginTop"),left:i.left-$(e,"marginLeft")}}};var 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(P(e))return e=le[e]||e,arguments.length<2?this[0]&&this[0][e]:this.each((function(i,n){n[e]=t}));for(var i in e)this.prop(i,e[i]);return this}},S.removeProp=function(e){return this.each((function(t,i){delete i[le[e]||e]}))};var ce=/^--/;function ue(e){return ce.test(e)}var de={},pe=a.style,he=["webkit","moz","ms"],me={animationIterationCount:!0,columnCount:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,gridArea:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnStart:!0,gridRow:!0,gridRowEnd:!0,gridRowStart:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0};function ve(e,t,i){return void 0===i&&(i=ue(e)),i||me[e]||!k(t)?t:"".concat(t,"px")}function fe(e,t){try{return e(t)}catch(e){return t}}S.css=function(e,t){if(P(e)){var i=ue(e);return e=function(e,t){if(void 0===t&&(t=ue(e)),t)return e;if(!de[e]){var i=re(e),n="".concat(i[0].toUpperCase()).concat(i.slice(1));M("".concat(i," ").concat(he.join("".concat(n," "))).concat(n).split(" "),(function(t,i){if(i in pe)return de[e]=i,!1}))}return de[e]}(e,i),arguments.length<2?this[0]&&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(P(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 N(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 N(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 Ee(e){var t=e.split(".");return[t[0],t.slice(1).sort()]}function Ie(e){return e[Ce]=e[Ce]||{}}function Ne(e,t){return!t||!g.call(t,(function(t){return e.indexOf(t)<0}))}function Fe(e,t,i,n,o){var a=Ie(e);if(t)a[t]&&(a[t]=a[t].filter((function(a){var s=a[0],r=a[1],l=a[2];if(o&&l.guid!==o.guid||!Ne(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(P(e)){var n=Ee(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&&O(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)||N(t))&&Fe(t)}));else if(P(e))O(t)&&(i=t,t=""),M(U(e),(function(e,o){var a=Ee(o),s=a[0],r=a[1],l=Se(s);n.each((function(e,n){(_(n)||F(n)||N(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 E(e).replaceWith(this),this},S.on=function(e,t,i,n,o){var a=this;if(!P(e)){for(var s in e)this.on(s,t,i,e[s],o);return this}return P(t)||(V(t)||B(t)?t="":V(i)?(i=t,t=""):(n=i,i=t,t="")),O(n)||(n=i,i=void 0),n?(M(U(e),(function(e,s){var r=Ee(s),l=r[0],c=r[1],u=Se(l),d=l in Te,p=l in Ae;u&&a.each((function(e,a){if(_(a)||F(a)||N(a)){var s=function(e){if(e.target["___i".concat(e.type)])return e.stopImmediatePropagation();if((!e.namespace||Ne(c,e.namespace.split(".")))&&(t||!(p&&(e.target!==a||e.___ot===u)||d&&e.relatedTarget&&a.contains(e.relatedTarget)))){var r=a;if(t){for(var l=e.target;!W(l,t);){if(l===a)return;if(!(l=l.parentNode))return}r=l}Object.defineProperty(e,"currentTarget",{configurable:!0,get:function(){return r}}),Object.defineProperty(e,"delegateTarget",{configurable:!0,get:function(){return a}}),Object.defineProperty(e,"data",{configurable:!0,get:function(){return i}});var h=n.call(r,e,e.___td);o&&Fe(a,u,c,t,s),!1===h&&(e.preventDefault(),e.stopPropagation())}};s.guid=n.guid=n.guid||E.guid++,function(e,t,i,n,o){var a=Ie(e);a[t]=a[t]||[],a[t].push([i,n,o]),e.addEventListener(t,o)}(a,u,c,t,s)}}))})),this):this},S.one=function(e,t,i,n){return this.on(e,t,i,n,!0)};var _e=/\r?\n/g,Oe=/file|reset|submit|button|image/i,Pe=/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||Oe.test(i.type)||Pe.test(i.type)&&!i.checked)){var n=ee(i);V(n)||M(c(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=E}()},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 c=0;c<e.length;c++){var u=[].concat(e[c]);n&&s[u[0]]||(void 0!==a&&(void 0===u[5]||(u[1]="@layer".concat(u[5].length>0?" ".concat(u[5]):""," {").concat(u[1],"}")),u[5]=a),i&&(u[2]?(u[1]="@media ".concat(u[2]," {").concat(u[1],"}"),u[2]=i):u[2]=i),o&&(u[4]?(u[1]="@supports (".concat(u[4],") {").concat(u[1],"}"),u[4]=o):u[4]="".concat(o)),t.push(u))}},t}},354:e=>{"use strict";e.exports=function(e){var t=e[1],i=e[3];if(!i)return t;if("function"==typeof btoa){var n=btoa(unescape(encodeURIComponent(JSON.stringify(i)))),o="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(n),a="/*# ".concat(o," */");return[t].concat([a]).join("\n")}return[t].join("\n")}},72:e=>{"use strict";var t=[];function i(e){for(var i=-1,n=0;n<t.length;n++)if(t[n].identifier===e){i=n;break}return i}function n(e,n){for(var a={},s=[],r=0;r<e.length;r++){var l=e[r],c=n.base?l[0]+n.base:l[0],u=a[c]||0,d="".concat(c," ").concat(u);a[c]=u+1;var p=i(d),h={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==p)t[p].references++,t[p].updater(h);else{var m=o(h,n);n.byIndex=r,t.splice(r,0,{identifier:d,updater:m,references:1})}s.push(d)}return s}function o(e,t){var i=t.domAPI(t);return i.update(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap&&t.supports===e.supports&&t.layer===e.layer)return;i.update(e=t)}else i.remove()}}e.exports=function(e,o){var a=n(e=e||[],o=o||{});return function(e){e=e||[];for(var s=0;s<a.length;s++){var r=i(a[s]);t[r].references--}for(var l=n(e,o),c=0;c<a.length;c++){var u=i(a[c]);0===t[u].references&&(t[u].updater(),t.splice(u,1))}a=l}}},659:e=>{"use strict";var t={};e.exports=function(e,i){var n=function(e){if(void 0===t[e]){var i=document.querySelector(e);if(window.HTMLIFrameElement&&i instanceof window.HTMLIFrameElement)try{i=i.contentDocument.head}catch(e){i=null}t[e]=i}return t[e]}(e);if(!n)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");n.appendChild(i)}},540:e=>{"use strict";e.exports=function(e){var t=document.createElement("style");return e.setAttributes(t,e.attributes),e.insert(t,e.options),t}},56:(e,t,i)=>{"use strict";e.exports=function(e){var t=i.nc;t&&e.setAttribute("nonce",t)}},825:e=>{"use strict";e.exports=function(e){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var t=e.insertStyleElement(e);return{update:function(i){!function(e,t,i){var n="";i.supports&&(n+="@supports (".concat(i.supports,") {")),i.media&&(n+="@media ".concat(i.media," {"));var o=void 0!==i.layer;o&&(n+="@layer".concat(i.layer.length>0?" ".concat(i.layer):""," {")),n+=i.css,o&&(n+="}"),i.media&&(n+="}"),i.supports&&(n+="}");var a=i.sourceMap;a&&"undefined"!=typeof btoa&&(n+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(a))))," */")),t.styleTagTransform(n,e,t.options)}(t,e,i)},remove:function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(t)}}}},113:e=>{"use strict";e.exports=function(e,t){if(t.styleSheet)t.styleSheet.cssText=e;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(e))}}}},t={};function i(n){var o=t[n];if(void 0!==o)return o.exports;var a=t[n]={id:n,exports:{}};return e[n](a,a.exports,i),a.exports}i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.nc=void 0;var n={};(()=>{"use strict";i.r(n),i.d(n,{_package:()=>et,demoFileIngest:()=>lt,demoFileIngest1:()=>ct,demoFileIngest2:()=>ut,demoFileSubmit:()=>dt,gasteigerCellRenderer:()=>pt,hitDesignApp:()=>st,hitDesignAppTreeBrowser:()=>nt,hitTriageApp:()=>at,hitTriageAppTreeBrowser:()=>it,peptiHitApp:()=>rt,peptiHitAppTreeBrowser:()=>ot});const e=grok,t=DG,o=ui,a="campaignId",s="campaignId",r="enriched_table.csv",l="campaign.json",c="HitTriageDataSource",u="HitTriageSubmitFunction",d="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",E="Continue Campaign",I="New Campaign",N={script:"script",function:"function-package",query:"data-query"},F="HDCampaignsGrouping";var _;!function(e){e.None="None",e.Template="Template",e.Status="Status"}(_||(_={}));var O=i(72),P=i.n(O),V=i(825),B=i.n(V),k=i(659),L=i.n(k),M=i(56),j=i.n(M),R=i(540),U=i.n(R),D=i(113),$=i.n(D),H=i(558),q={};q.styleTagTransform=$(),q.setAttributes=j(),q.insert=L().bind(null,"head"),q.domAPI=B(),q.insertStyleElement=U(),P()(H.A,q),H.A&&H.A.locals&&H.A.locals;var Y=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 G(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 J(t,i,n,a){var s;const r=o.breadcrumbs([i,n]),l=r.onPathClick.subscribe((e=>{1===e.length&&(l.unsubscribe(),z(t),a())})),c=null===(s=e.shell.v.ribbonMenu.root.parentElement)||void 0===s?void 0:s.getElementsByClassName("d4-ribbon-name")[0];return c&&(c.textContent="",c.appendChild(r.root)),{breadcrumbs:r,sub:l}}function z(e){const t=e.getRibbonPanels();(null==t?void 0:t.length)&&(t.pop(),e.setRibbonPanels(t))}function K(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 Q(e,i,n){return Y(this,void 0,void 0,(function*(){if(0===n.rowCount)return;if(!e.col(i))throw new Error("There is no molecule column in dataframe");let o=n.col(w);if(o||(yield n.meta.detectSemanticTypes(),o=n.columns.bySemType(t.SEMTYPE.MOLECULE)),!o)throw new Error("There is no original molecule column in query result dataframe");const a=n.columns.names().filter((e=>e!==w));e.join(n,[i],[o.name],void 0,a,void 0,!0)}))}function Z(e,t){return Y(this,void 0,void 0,(function*(){const i=(yield et.files.list(`${e}/campaigns`)).filter((e=>-1===t.indexOf(e.name))),n={};for(const t of i)try{const i=JSON.parse(yield et.files.readAsText(`${e}/campaigns/${t.name}/${l}`));if(i.authorUserId&&i.permissions&&!(yield te(i.authorUserId,i.permissions)))continue;n[i.name]=i}catch(e){continue}return n}))}function X(i,n){return Y(this,void 0,void 0,(function*(){var o;const a=t.User.current().id,s=null===(o=t.User.current().group)||void 0===o?void 0:o.id;if(i===a)return!0;const r=e.dapi.groups;for(const e of n){const t=yield r.find(e);if(t)if(t.personal){const e=yield r.getUser(t);if((null==e?void 0:e.id)===a)return!0}else if(s&&t.members.length>0&&t.members.some((e=>e.id===s)))return!0}return!1}))}function ee(e,t){return Y(this,void 0,void 0,(function*(){return X(e,t.edit)}))}function te(e,t){return Y(this,void 0,void 0,(function*(){return X(e,Array.from(new Set([...t.view,...t.edit])))}))}const ie=(e,t)=>{var i,n;switch(e){case _.Template:return null!==(n=null===(i=t.template)||void 0===i?void 0:i.key)&&void 0!==n?n:t.templateName;case _.Status:return t.status;default:return""}},ne={String:t.TYPE.STRING,Number:t.TYPE.FLOAT,Boolean:t.TYPE.BOOL,Date:t.TYPE.DATE_TIME,Molecule:t.SEMTYPE.MOLECULE};var oe=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))},ae=i(233),se=i.n(ae),re=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};function le(t,i,n,a,s){return re(this,void 0,void 0,(function*(){var r,l,c,u,d,p,h,m,v,f,w,b,C,A,T,x,S,E,I,F,_;const O=yield t.computeFunctions,P=[];O.functions.filter((({inputs:e})=>e.length>=2&&"dataframe"===e[0].propertyType&&"column"===e[1].propertyType)).forEach((e=>{var t,i,n,o;P.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:{}})})),O.scripts.filter((({inputs:e})=>e.length>=2&&"dataframe"===e[0].propertyType&&"column"===e[1].propertyType)).forEach((e=>{var t,i,n,o;P.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:{}})})),O.queries.filter((e=>e.inputs.length>0&&"list"===e.inputs[0].propertyType)).forEach((e=>{var t,i,n,o;P.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 B=o.div([],{classes:"hit-triage-compute-dialog-host"}),k=[],L=o.tree();try{const q=yield e.chem.descriptorsTree();function Y(e,t){const i=t.group(e,null,!1);return i.enableCheckBox(!1),i}L.root.classList.add("hit-triage-compute-dialog-descriptors-group");const W=Object.keys(q),G=null!==(d=null===(u=null===(c=null==a?void 0:a.compute)||void 0===c?void 0:c.descriptors)||void 0===u?void 0:u.args)&&void 0!==d?d:[];for(const J of W){const z=Y(J,L);for(const K of q[J].descriptors){const Q=z.item(K.name,K);k.push(Q),Q.enableCheckBox(G.includes(K.name))}}}catch(Z){console.error(Z),V=!1}const M="Descriptors",j={[M]:M},R=V?{[M]:L.root}:{},U={},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 P)try{const ee=X.func,te=ee.prepare(X.args),ie=ee.type===N.function?`${ee.package.name}:${ee.name}`:ee.type===N.script?`${g}:${null!==(w=ee.name)&&void 0!==w?w:""}:${ee.id}`:`${y}:${null!==(b=ee.name)&&void 0!==b?b:""}:${ee.id}`;U[ie]=te;const ne=o.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,j[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===N.function&&e.name===X.func.name&&e.package===(null===(t=X.func.package)||void 0===t?void 0:t.name)})))||(null===(E=null===(S=null==a?void 0:a.compute)||void 0===S?void 0:S.scripts)||void 0===E?void 0:E.some((e=>e.id===ee.id)))||(null===(F=null===(I=null==a?void 0:a.compute)||void 0===I?void 0:I.queries)||void 0===F?void 0:F.some((e=>e.id===ee.id))))&&void 0!==_&&_,ne.children[0].style.display="none",ee.type!==N.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 $=o.tabControl(R,!0);function H(){const e={descriptors:[],externals:{},scripts:{},queries:{}};e.descriptors=D[M]?k.filter((e=>e.checked)).map((e=>e.value.name)):[];const t=Object.entries(U).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),i(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",B.appendChild($.root),$.panes.forEach((e=>{const t=o.input.bool("",{value:D[j[e.name]],onValueChanged:t=>{D[j[e.name]]=!!t,t?se()(e.content).find("input").removeAttr("disabled"):se()(e.content).find("input").attr("disabled","true")}});t.setTooltip("Toggle calculation of this function"),e.header.appendChild(t.root),e.header.classList.add("hit-triage-compute-dialog-pane-header")})),s&&o.dialog("Compute").add(B).onOK((()=>H())).onCancel(n).show(),{root:B,okProxy:H}}))}const ce=rxjs;class ue{constructor(e,t=[],i={}){this.onItemChanged=new ce.Subject,this.onAddingItemChanged=new ce.Subject,this.onItemAdded=new ce.Subject,this.onItemRemoved=new ce.Subject,this.options={removeButtonTooltip:"Remove item",addButtonTooltip:"Add item",allowAdd:!0,allowRemove:!0},this.properties=e,this.options=Object.assign(Object.assign({},this.options),i),this._root=o.divV([],{style:{display:"grid",gridTemplateColumns:`repeat(${this.properties.length}, 1fr)`,alignItems:"center",gap:"12px"},classes:"ui-items-grid"}),this._items=t,this.render()}get root(){return this._root}get items(){return this._items}set items(e){this._items=e,this.render()}addItem(e,t=!0){this._items.push(e),this.render(),t&&this.onItemAdded.next(e)}removeItem(e,t=!0){-1!==this._items.indexOf(e)&&(this._items.splice(this._items.indexOf(e),1),this.render(),t&&this.onItemRemoved.next(e))}removeAtIndex(e,t=!0){if(e<0||e>=this._items.length)return;const i=this._items.splice(e,1);this.render(),t&&this.onItemRemoved.next(i[0])}removeAllItems(){this._items=[],this.render()}render(){var e,t,i,n,a;if(o.empty(this._root),!this.options.horizontalInputNames)for(const i of this.properties){let n=null!==(e=i.caption)&&void 0!==e?e:i.name;(null===(t=this.options.customLabels)||void 0===t?void 0:t[i.name])&&(n=this.options.customLabels[i.name]);const a=o.divText(n);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===(n=(i=this.options).newItemFunction)||void 0===n?void 0:n.call(i))&&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 c of this.properties){void 0===e[c.name]&&(e[c.name]=null);const u=(null===(n=this.options.customInputs)||void 0===n?void 0:n[c.name])?this.options.customInputs[c.name](e):o.input.forProperty(c,e),d=null===(a=this.options.validators)||void 0===a?void 0:a[c.name];d&&u.addValidator(d),s.push(this.options.horizontalInputNames?u.root:this.hideLabel(u.root)),c.propertyType!==t.TYPE.BOOL&&"color"!==c.name.toLowerCase()&&u.input&&(u.input.style.width="100%"),r[c.name]=u,u.onChanged.subscribe((()=>{e[c.name]=u.value,i?this.onAddingItemChanged.next({item:e,fieldName:c.name}):this.onItemChanged.next({item:e,fieldName:c.name})})),u.root.style.alignItems="center",l=u}let c=null;if(i)c=o.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;c=o.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(c):null==l||l.root.appendChild(c),c.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 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())}))};function pe(){const e=t.Property.fromOptions({name:"layout",caption:"Layout",type:"file"}),i=t.InputBase.forProperty(e);let n=null,o=null,a=null;return i.addValidator((e=>a)),i.onChanged.subscribe((e=>de(this,void 0,void 0,(function*(){const s=e;if(s)try{const e=yield s.readAsString(),i=t.ViewLayout.fromJson(e);i?(n=i,o=i.viewState,a=null):(n=null,o=null,a="Invalid layout file")}catch(e){n=null,o=null,a="Invalid layout file"}i.setTooltip("Select a layout file")})))),{dataFileInput:i,getLayout:()=>n,getLayoutViewState:()=>o}}var he=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 me(i,n){return he(this,void 0,void 0,(function*(){var a,s;const r=(yield et.files.list("Hit Triage/templates")).map((e=>e.name.slice(0,-5))),l=[];for(const e of r){const t=JSON.parse(yield et.files.readAsText(`Hit Triage/templates/${e}.json`));l.push(t.key)}const d=t.Func.find({tags:[u]}),p={};d.forEach((e=>{var t;p[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e}));const h=o.input.choice("Submit function",{value:null,items:[null,...Object.keys(p)]});h.value=null,h.nullable=!0,h.fireChanged(),h.setTooltip("Select function to be called upon submitting");const m=pe(),v=o.divText("Template name is empty or already exists",{classes:"hit-triage-error-div"}),f=o.divText("Template key is empty or already exists",{classes:"hit-triage-error-div"}),w=o.input.string("Name",{value:"",onValueChanged: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=o.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 le(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&&t.Func.find({tags:[c]}).forEach((e=>{var t;n[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e}));const E=Object.keys(n),I=o.input.choice(b,{value:E[0],items:E}),N=o.input.choice("Ingest using",{value:"Query",items:["Query","File"],onValueChanged:e=>{I.root.style.display="Query"===e?"block":"none"}}),F=ve(),_=o.div([o.h2("Details"),o.div([w,v]),o.div([C,f]),N.root,I.root,m.dataFileInput,F.fieldsDiv,o.h2("Compute"),x.root,o.h2("Submit"),h.root],"ui-form"),O=o.buttonsInput([]),P=null!==(s=null===(a=O.getElementsByClassName("ui-input-editor"))||void 0===a?void 0:a[0])&&void 0!==s?s:O;_.appendChild(O);const V=new Promise((e=>{const t=o.button(S,(()=>e()));P.appendChild(t)})),B=new Promise((t=>{const i=o.bigButton(T,(()=>function(){return he(this,void 0,void 0,(function*(){var i,n,o,a,s,r,l,c;if(x.okProxy(),"100%"===v.style.opacity)return void e.shell.error("Template name is empty or already exists");const u=h.value?p[h.value]:void 0,d=Object.assign(Object.assign({name:w.value,key:C.value,campaignFields:F.getFields(),dataSourceType:null!==(i=N.value)&&void 0!==i?i:"Query",layoutViewState:null!==(n=m.getLayoutViewState())&&void 0!==n?n:void 0,compute:{descriptors:{enabled:!!(null===(o=null==A?void 0:A.descriptors)||void 0===o?void 0:o.length),args:null!==(a=null==A?void 0:A.descriptors)&&void 0!==a?a:[]},functions:Object.entries(null!==(s=null==A?void 0:A.externals)&&void 0!==s?s:{}).map((([e,t])=>{const i=e.split(":");return{name:i[1],package:i[0],args:t}})),scripts:Object.entries(null!==(r=null==A?void 0:A.scripts)&&void 0!==r?r:{}).filter((([e,t])=>e.startsWith(g)&&3===e.split(":").length)).map((([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}})),queries:Object.entries(null!==(l=null==A?void 0:A.queries)&&void 0!==l?l:{}).filter((([e,t])=>e.startsWith(y)&&3===e.split(":").length)).map((([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}}))}},u?{submit:{fName:u.name,package:u.package.name}}:{}),{queryFunctionName:"Query"===N.value&&null!==(c=I.value)&&void 0!==c?c:void 0});var f;f=d,et.files.writeAsText(`Hit Triage/templates/${f.name}.json`,JSON.stringify(f)),e.shell.info("Template created successfully"),t(d)}))}()));P.appendChild(i)}));return{root:_,template:B,cancelPromise:V}}))}function ve(e){const i=[t.Property.fromOptions({name:"Name",type:t.TYPE.STRING}),t.Property.fromOptions({name:"Type",type:t.TYPE.STRING,choices:Object.keys(ne)}),t.Property.fromOptions({name:"Required",type:t.TYPE.BOOL})],n=new ue(i,e?e.map((e=>({Name:e.name,Type:e.type,Required:e.required}))):void 0,{horizontalInputNames:!1});n.root.style.maxWidth="750px";let a={};n.onItemAdded.subscribe((e=>{a={}})),n.onAddingItemChanged.subscribe((e=>{e&&(a=e.item)}));const s=o.h2("Additional fields");o.tooltip.bind(s,"Additional fields to be filled by user for each campaign");const r=o.div([s,n.root]);return{getFields:function(){var e;const t=n.items.filter((e=>e.Name)).map((e=>{var t;return{name:e.Name,type:e.Type,required:null!==(t=e.Required)&&void 0!==t&&t}}));return a.Name&&""!==a.Name&&a.Type&&(null!==(e=a.Required)&&void 0!==e||(a.Required=!1),t.push({name:a.Name,type:a.Type,required:a.Required})),t},fieldsDiv:o.div([r])}}var fe=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};class ge extends t.ViewBase{constructor(e){super(),this.deletedCampaigns=[],this.app=e}get template(){return this.app.template}onActivated(){}onReset(){}process(){return fe(this,void 0,void 0,(function*(){}))}deleteCampaign(e,t){return fe(this,void 0,void 0,(function*(){yield et.files.delete(`${e}/campaigns/${t}`)}))}}var ye=i(677),we={};we.styleTagTransform=$(),we.setAttributes=j(),we.insert=L().bind(null,"head"),we.domAPI=B(),we.insertStyleElement=U(),P()(ye.A,we),ye.A&&ye.A.locals&&ye.A.locals;var be;!function(t){let i,n;!function(e){e.vert=function(e){return o.divV(e.map((e=>o.render(e))),{classes:"u2-panel"})},e.horz=function(e){return o.divH(e.map((e=>o.render(e))),{classes:"u2-panel"})}}(i=t.panels||(t.panels={})),t.appHeader=function(e){const t=o.iconImage("",e.iconPath);return se()(t).addClass("ui-app-header-icon").css("margin-right","20px"),i.horz([t,i.vert([o.markdown(e.description),e.learnMoreUrl?o.link("Learn more",e.learnMoreUrl):null])])},function(t){t.runAsync=function(t,i){return n=this,a=void 0,r=function*(){o.setUpdateIndicator(t,!0);try{return yield i()}catch(t){e.log.error(t)}finally{o.setUpdateIndicator(t,!1)}},new((s=void 0)||(s=Promise))((function(e,t){function i(e){try{l(r.next(e))}catch(e){t(e)}}function o(e){try{l(r.throw(e))}catch(e){t(e)}}function l(t){var n;t.done?e(t.value):(n=t.value,n instanceof s?n:new s((function(e){e(n)}))).then(i,o)}l((r=r.apply(n,a||[])).next())}));var n,a,s,r}}(n=t.tools||(t.tools={}))}(be||(be={}));var Ce=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};const Ae={view:[t.Group.defaultGroupsIds["All users"]],edit:[t.Group.defaultGroupsIds["All users"]]};class Te{constructor(e){this.permissions=null!=e?e:Ae,this.editGroupsInput=o.input.userGroups("Can Edit"),this.editGroupsInput.root.style.marginBottom="16px",this.viewGroupsInput=o.input.userGroups("Can View")}getDialogContent(){return Ce(this,void 0,void 0,(function*(){const t=[],i=[];for(const i of this.permissions.view){const n=yield e.dapi.groups.find(i);n&&t.push(n)}for(const t of this.permissions.edit){const n=yield e.dapi.groups.find(t);n&&i.push(n)}return this.editGroupsInput.value=i,this.viewGroupsInput.value=t,o.divV([this.editGroupsInput.root,this.viewGroupsInput.root])}))}show(e){return Ce(this,void 0,void 0,(function*(){var t;const i=yield this.getDialogContent(),n=o.dialog("Edit Permissions").add(i).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=Ae.view),e(this.permissions)}));(null===(t=i.parentElement)||void 0===t?void 0:t.style)&&(i.parentElement.style.overflow="visible"),n.show()}))}}var xe=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 Se extends ge{constructor(t){super(t),this.readmePath=et.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 xe(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0);try{const t=o.h1(E),i=o.h1(I,{style:{marginLeft:"10px"}}),n=be.appHeader({iconPath:et.webRoot+"/images/icons/hit-triage-icon.png",learnMoreUrl:"https://github.com/datagrok-ai/public/blob/master/packages/HitTriage/README_HT.md",description:"- Configure your own workflow using the template editor.\n- Calculate different molecular properties.\n- Filter molecules using different criteria.\n- Submit processed dataframe to the function of your choice.\n- Save campaigns and continue any time from where you left off.\n "}),a=o.div(),s=o.div([],{classes:"ui-form"}),r=yield this.getCampaignsTable();yield this.startNewCampaign(a,s,e),se()(this.root).empty(),this.root.appendChild(o.div([o.divV([n,t],{style:{marginLeft:"10px"}}),r,i,s,a])),this.app.resetBaseUrl()}catch(e){throw o.setUpdateIndicator(this.root,!1),e}finally{o.setUpdateIndicator(this.root,!1)}}))}startNewCampaign(e,t,i){return xe(this,void 0,void 0,(function*(){var n;const a=(yield et.files.list("Hit Triage/templates")).map((e=>e.name.slice(0,-5)));i&&!a.includes(i.name)&&a.push(i.name);const s=()=>xe(this,void 0,void 0,(function*(){const t=r.value,n=i&&i.name===t?i:JSON.parse(yield et.files.readAsText("Hit Triage/templates/"+t+".json")),o=yield this.getNewCampaignAccordeon(n,e);se()(e).empty(),e.className="ui-form",e.appendChild(o)})),r=o.input.choice("Template",{value:null!==(n=null==i?void 0:i.name)&&void 0!==n?n:a[0],items:a,onValueChanged:()=>xe(this,void 0,void 0,(function*(){yield s()}))}),l=o.icons.add((()=>xe(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0),yield this.createNewTemplate(),o.setUpdateIndicator(this.root,!1)}))),C);r.addOptions(l),yield s(),se()(t).empty(),t.appendChild(r.root)}))}checkCampaign(e){return xe(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 et.files.exists(`Hit Triage/campaigns/${n}/${l}`)))return;const o=JSON.parse(yield et.files.readAsText(`Hit Triage/campaigns/${n}/${l}`));if(o){if(o.authorUserId&&o.permissions&&!(yield te(o.authorUserId,o.permissions)))return void this.app.setBaseUrl();this.app.campaign=o}const s=JSON.parse(yield et.files.readAsText(`Hit Triage/templates/${o.templateName}.json`));return this.app.setTemplate(s,o.filters,n,o.ingest),e&&G(a,e),o}))}getCampaignsTable(){return xe(this,void 0,void 0,(function*(){const e=yield Z("Hit Triage",this.deletedCampaigns),i=e=>{var i,n;const a=o.icons.delete((()=>xe(this,void 0,void 0,(function*(){o.dialog("Delete campaign").add(o.divText(`Are you sure you want to delete campaign ${e.name}?`)).onOK((()=>xe(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",ee(null!==(i=e.authorUserId)&&void 0!==i?i:t.User.current().id,null!==(n=e.permissions)&&void 0!==n?n:Ae).then((e=>{e&&(a.style.display="inline-block")})),a},n=Object.values(e),a=o.table(n,(e=>[o.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 xe(this,void 0,void 0,(function*(){const t=yield this.checkCampaign(e);this.app.campaign=t}))}getNewCampaignAccordeon(i,n){return xe(this,void 0,void 0,(function*(){o.setUpdateIndicator(n,!0);const{root:a,promise:s,cancelPromise:r}=yield function(i,n){return oe(this,void 0,void 0,(function*(){var a,s;const r=o.divText("",{style:{color:"red"}});let l=null;const u=()=>oe(this,void 0,void 0,(function*(){try{if(l=d.value,!l)return;if(yield l.meta.detectSemanticTypes(),!l.columns.bySemType(t.SEMTYPE.MOLECULE))return void(r.innerText="No molecules column found");r.innerText=""}catch(e){r.innerText="Error parsing file"}})),d=o.input.table("Dataframe",{onValueChanged:u});yield u();const p=o.div([d,r]);0===Object.keys(n).length&&t.Func.find({tags:[c]}).forEach((e=>{var t;n[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e}));let h=null;const m=()=>oe(this,void 0,void 0,(function*(){const e=n[f.value];h=e.prepare();const t=yield h.getEditor();t.classList.remove("ui-form"),v.innerHTML="",v.appendChild(t)})),v=o.div([]),f=o.input.choice(b,{value:null!==(a=i.queryFunctionName)&&void 0!==a?a:Object.keys(n)[0],items:Object.keys(n),onValueChanged:m});yield m(),i.queryFunctionName&&(null===(s=f.root.getElementsByTagName("select").item(0))||void 0===s||s.setAttribute("disabled","true"));const g=o.div([f,v]);g.style.display="none";const y=o.div([p,g]),w=i.campaignFields.map((e=>e.type===t.SEMTYPE.MOLECULE?Object.assign(Object.assign({},e),{type:"String",semtype:t.SEMTYPE.MOLECULE}):e)).map((e=>t.Property.fromOptions(Object.assign({name:e.name,type:ne[e.type],nullable:!e.required},e.semtype?{semType:e.semtype}:{})))),C={},T=w.length?o.input.form(C,w):o.div();T.classList.remove("ui-form"),"File"===i.dataSourceType?(p.style.display="inherit",g.style.display="none"):(p.style.display="none",g.style.display="inherit");const x=o.div([y,...w.length?[T]:[]]),E=o.buttonsInput([]);return x.appendChild(E),{promise:new Promise((t=>{const a=()=>oe(this,void 0,void 0,(function*(){if("File"===i.dataSourceType){if(!l)return void e.shell.error("No file selected");const i=l;i.name=l.name,t({df:i,type:"File",campaignProps:C})}else{const i=n[f.value];if(!i)return void e.shell.error("No function selected");const o={};Object.entries(h.inputs).forEach((([e,t])=>{o[e]=t}));const a=yield i.apply(o);t({df:a,type:"Query",campaignProps:C})}})),s=o.bigButton(A,(()=>a()));E.appendChild(s)})),root:x,cancelPromise:new Promise((e=>{o.button(S,(()=>e()))}))}}))}(i,this.dataSourceFunctionsMap);return o.setUpdateIndicator(n,!1),s.then((e=>xe(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 xe(this,void 0,void 0,(function*(){const i=yield me(this.app,this.dataSourceFunctionsMap),n=new t.ViewBase,o=e.shell.v;n.name="New Template",n.root.appendChild(i.root),n.parentCall=this.app.parentCall,e.shell.addView(n),n.path=new URL(this.app.baseUrl).pathname+"/new-template",n.parentView=o;const{sub:a}=J(e.shell.v,"Hit Triage",C,(()=>{e.shell.v=o,n.close()}));i.template.then((t=>xe(this,void 0,void 0,(function*(){yield this.init(t),n.close(),z(n),e.shell.v=o,a.unsubscribe()})))),i.cancelPromise.then((()=>{a.unsubscribe(),n.close(),e.shell.v=o}))}))}}class Ee extends ge{constructor(e){super(e),this.name="Submit"}render(){return o.empty(this.root),o.divV([o.h1("Summary"),o.div([o.tableFromMap(this.app.getSummary())])])}onActivated(){this.render()}submit(){return i=this,n=void 0,a=function*(){var i;const n=null===(i=this.app.template)||void 0===i?void 0:i.submit;if(!n)return;const o=t.Func.find({name:n.fName,package:n.package})[0];if(!o)return void e.shell.error(`Function ${n.fName} not found.`);const a=t.DataFrame.fromCsv(this.app.dataFrame.toCsv({filteredRowsOnly:!0}));yield o.apply({df:a,molecules:this.app.molColName}),this.app.campaign&&(this.app.campaign.status="Submitted"),this.app.saveCampaign("Submitted"),e.shell.info("Submitted successfully.")},new((o=void 0)||(o=Promise))((function(e,t){function s(e){try{l(a.next(e))}catch(e){t(e)}}function r(e){try{l(a.throw(e))}catch(e){t(e)}}function l(t){var i;t.done?e(t.value):(i=t.value,i instanceof o?i:new o((function(e){e(i)}))).then(s,r)}l((a=a.apply(i,n||[])).next())}));var i,n,o,a}}var Ie=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};class Ne{get appName(){return this._appName}constructor(e,i){this.parentCall=e,this.isJoining=!1,this.hasEditPermission=!1,this._appName=i,this.resetBaseUrl(),this.computeFunctions=new Promise((e=>Ie(this,void 0,void 0,(function*(){const i=t.Func.find({tags:["HitTriageFunction"]}),n=i.filter((e=>e.type===N.function)),o=i.filter((e=>e.type===N.script)),a=i.filter((e=>e.type===N.query));e({functions:n,scripts:o,queries:a})}))))}setCanEdit(e){return Ie(this,void 0,void 0,(function*(){e.authorUserId&&e.permissions?this.hasEditPermission=yield ee(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 i=this.dataFrame.col(e);return(null==i?void 0:i.semType)===t.SEMTYPE.MOLECULE?t.FILTER_TYPE.SUBSTRUCTURE:(null==i?void 0:i.type)===t.COLUMN_TYPE.BOOL?t.FILTER_TYPE.BOOL_COLUMNS:(null==i?void 0:i.type)===t.COLUMN_TYPE.STRING?t.FILTER_TYPE.CATEGORICAL:t.FILTER_TYPE.HISTOGRAM}download(e,i,n=!1){const o=document.createElement("a"),a=t.DataFrame.fromColumns(e.columns.toList().filter((e=>!e.name.startsWith("~")))).toCsv({filteredRowsOnly:n});o.setAttribute("href","data:text/plain;charset=utf-8,"+encodeURIComponent(a)),o.setAttribute("download",i+".csv"),o.click()}getNewCampaignName(e,t){return Ie(this,void 0,void 0,(function*(){const i=(yield et.files.list(e)).map((e=>e.name)).filter((e=>e.startsWith(t)));if(0===i.length)return t+"-1";const n=i.map((e=>e.split("-")[1])).filter(Boolean).map((e=>parseInt(e,10))).sort();return t+"-"+(n[n.length-1]+1).toString()}))}setBaseUrl(){const e=document.title;if(history.replaceState){const t={Title:e,Url:this.baseUrl};history.replaceState(t,t.Title,t.Url)}}unionDataframes(e,i,n){var o,a,s,r,l;const c=null===(a=null===(o=e.col(n))||void 0===o?void 0:o.toList())||void 0===a?void 0:a.filter((e=>!!e)).map((e=>t.chem.convert(e,t.chem.Notation.Unknown,t.chem.Notation.Smiles))),u=null===(r=null===(s=i.col(n))||void 0===s?void 0:s.toList())||void 0===r?void 0:r.filter((e=>!!e)).map((e=>t.chem.convert(e,t.chem.Notation.Unknown,t.chem.Notation.Smiles)));if(!c||!u)throw new Error("Molecule column not found");this.isJoining=!0;try{for(const t of e.columns)i.columns.contains(t.name)||i.columns.addNew(t.name,t.type);for(let t=0;t<c.length;t++)if(!u.includes(c[t])){i.rows.addNew(null,!0);for(const n of e.columns){const e=n.get(t);null===(l=i.col(n.name))||void 0===l||l.set(i.rowCount-1,e,!1)}}}finally{setTimeout((()=>{this.isJoining=!1}),500)}return i}}var Fe=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())}))},_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())}))};function Oe(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 Pe(i,n,o){return _e(this,void 0,void 0,(function*(){var a,s;const r=t.TaskBarProgressIndicator.create("Calculating ..."),l=n.col(o);if(!l)throw new Error("There is no molecule column in dataframe");for(let t=0;t<l.length;t++){if(l.isNone(t))continue;const i=l.get(t);if(!i)continue;const n=e.chem.convert(i,e.chem.Notation.Unknown,e.chem.Notation.Smiles);l.set(t,n,!1)}try{i.descriptors&&i.descriptors.length>0&&(yield e.chem.descriptors(n,o,i.descriptors))}catch(e){console.error("Descriptors calculation error",e)}for(const e of Object.keys(i.externals))try{const a=i.externals[e],s=t.Func.find({package:e.split(":")[0],name:e.split(":")[1]})[0],r=s.inputs[0].name,l=s.inputs[1].name;a&&(yield s.apply(Object.assign(Object.assign({},a),{[r]:n,[l]:o})))}catch(e){console.error(e)}for(const e of Object.keys(null!==(a=i.scripts)&&void 0!==a?a:{})){const a=i.scripts[e];if(a){const i=e.split(":"),s=i[2];if(!s)continue;try{const e=i[1],r=t.Func.find({name:e}).filter((e=>e.type===N.script&&e.id===s))[0];if(!r)continue;const l=r.inputs[0].name,c=r.inputs[1].name,u=yield r.apply(Object.assign(Object.assign({},a),{[l]:n,[c]:o}));if(u&&u.rowCount===n.rowCount&&"python"===r.language)for(const e of u.columns)e.name=n.columns.getUnusedName(e.name),n.columns.add(e)}catch(e){console.error(e)}}}for(const e of Object.keys(null!==(s=i.queries)&&void 0!==s?s:{})){const a=i.queries[e];if(a){const i=e.split(":"),s=i[2];if(!s)continue;try{const e=i[1],r=t.Func.find({name:e}).filter((e=>e.type===N.query&&e.id===s))[0];if(!r)continue;const l=r.inputs[0].name,c=n.col(o).toList(),u=yield r.apply(Object.assign(Object.assign({},a),{[l]:c}));u&&(yield Q(n,o,u))}catch(e){console.error(e)}}}r.close()}))}var Ve=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};class Be extends Ne{get infoView(){return this._infoView}constructor(i){super(i,"Hit Triage"),this._filterViewName="Hit triage | Pick",this._filterDescriptions=[],this.campaignProps={},this._pickViewPromise=null,this._infoView=new Se(this),this.multiView=new t.MultiView({viewFactories:{[this._infoView.name]:()=>this._infoView}}),this.multiView.tabs.onTabChanged.subscribe((e=>{this.multiView.currentView instanceof ge&&this.multiView.currentView.onActivated()})),this.multiView.parentCall=i,e.events.onCurrentViewChanged.subscribe((()=>{var t,i,n,o;try{(null===(t=e.shell.v)||void 0===t?void 0:t.name)===this.currentPickViewId&&(e.shell.windows.showHelp=!1,this.setBaseUrl(),G(a,null!==(o=null!==(i=this._campaignId)&&void 0!==i?i:null===(n=this._campaign)||void 0===n?void 0:n.name)&&void 0!==o?o:""))}catch(e){console.error(e)}}))}setTemplate(i,n,o,s){return Ve(this,void 0,void 0,(function*(){var r,l,c,u,d,p,h,m,v,f,w,b,C,A,T;if((null===(r=this._pickView)||void 0===r?void 0:r.dataFrame)&&e.shell.closeTable(null===(l=this._pickView)||void 0===l?void 0:l.dataFrame),this._pickView=void 0,o?s&&(this._fileInputType=s.type,"File"===s.type?this.dataFrame=yield e.dapi.files.readCsv(s.query):this.dataFrame=yield e.functions.call(s.query)):(o=yield this.getNewCampaignName("Hit Triage/campaigns",i.key),G(a,o)),!this.dataFrame)return void console.error("Dataframe is empty.");if((null===(c=this._campaign)||void 0===c?void 0:c.columnSemTypes)&&Object.entries(this._campaign.columnSemTypes).forEach((([e,t])=>{const i=this.dataFrame.columns.byName(e);i&&i.semType!==t&&(i.semType=t)})),(null===(u=this._campaign)||void 0===u?void 0:u.columnTypes)&&Object.entries(this._campaign.columnTypes).forEach((([e,t])=>{const i=this.dataFrame.columns.byName(e);if(i&&i.type!==t)try{i.convertTo(t)}catch(e){console.error(e)}})),yield this.dataFrame.meta.detectSemanticTypes(),this._molColName=null!==(p=null===(d=this.dataFrame.columns.bySemType(t.SEMTYPE.MOLECULE))||void 0===d?void 0:d.name)&&void 0!==p?p:void 0,this._dfName=null!==(h=this.dataFrame.name)&&void 0!==h?h:null==s?void 0:s.query,this.dataFrame.name=null!==(v=null!==(m=this._dfName)&&void 0!==m?m:this.dataFrame.name)&&void 0!==v?v:"Molecules",this._campaignId=o,this.template=(null===(f=this.campaign)||void 0===f?void 0:f.template)?Object.assign(Object.assign({},this.campaign.template),{dataSourceType:i.dataSourceType,queryFunctionName:i.queryFunctionName}):i,this._campaignFilters=n,!n){const e={},t={},n={};i.compute.functions.forEach((t=>{const i=`${t.package}:${t.name}`;e[i]=t.args})),null===(w=i.compute.scripts)||void 0===w||w.forEach((e=>{const i=`${g}:${e.name}:${e.id}`;t[i]=e.args})),null===(b=i.compute.queries)||void 0===b||b.forEach((e=>{const t=`${y}:${e.name}:${e.id}`;n[t]=e.args})),yield Pe({descriptors:i.compute.descriptors.enabled?i.compute.descriptors.args:[],externals:e,scripts:t,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(),G(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 E=S;setTimeout((()=>{this._pickViewPromise&&this._pickViewPromise.then((()=>{const{sub:t}=J(E,"Hit Triage","Pick",(()=>{e.shell.v=x,E.close(),t.unsubscribe()}))}))}),300),e.shell.windows.showHelp=!1}))}get filterSettings(){return this._campaignFilters}get campaignId(){return this._campaignId}get pickView(){return this._pickView=this.getFilterView()}get molColName(){var e,i,n;return null!==(e=this._molColName)&&void 0!==e?e:this._molColName=null===(n=null===(i=this.dataFrame)||void 0===i?void 0:i.columns.bySemType(t.SEMTYPE.MOLECULE))||void 0===n?void 0:n.name}get fileInputType(){return this._fileInputType}get campaign(){return this._campaign}set campaign(e){this._campaign=e}getFilterView(){let e=null;this._pickViewPromise=new Promise((t=>{e=t})),this.dataFrame.col(d)||this.dataFrame.columns.addNewBool(d).init(!1);const i=t.TableView.create(this.dataFrame,!1),n=i.getRibbonPanels(),a=o.iconFA("wrench",(()=>Ve(this,void 0,void 0,(function*(){le(this,(e=>Ve(this,void 0,void 0,(function*(){var t,i,n,o,a,s,r;const l=this.template.compute.descriptors.args,c=this.template.compute.functions,u=null!==(t=this.template.compute.scripts)&&void 0!==t?t:[],d=null!==(i=this.template.compute.queries)&&void 0!==i?i:[],p=e.descriptors,h={descriptors:{enabled:!!(null===(n=null==e?void 0:e.descriptors)||void 0===n?void 0:n.length),args:null!==(o=null==e?void 0:e.descriptors)&&void 0!==o?o:[]},functions:Object.entries(null!==(a=null==e?void 0:e.externals)&&void 0!==a?a:{}).map((([e,t])=>{const i=e.split(":");return{name:i[1],package:i[0],args:t}})),scripts:Object.entries(null!==(s=null==e?void 0:e.scripts)&&void 0!==s?s:{}).filter((([e,t])=>e.startsWith(g)&&3===e.split(":").length)).map((([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}})),queries:Object.entries(null!==(r=null==e?void 0:e.queries)&&void 0!==r?r:{}).filter((([e,t])=>e.startsWith(y)&&3===e.split(":").length)).map((([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}}))};this.template.compute=h;const m=p.filter((e=>!l.includes(e))),v=h.functions.filter((e=>{if(!c.some((t=>t.name===e.name&&t.package===e.package)))return!0;const t=c.find((t=>t.name===e.name&&t.package===e.package));return!Object.entries(e.args).every((([e,i])=>t.args[e]===i))})),f=h.scripts.filter((e=>{if(!u.some((t=>t.id===e.id)))return!0;const t=u.find((t=>t.id===e.id));return!Object.entries(e.args).every((([e,i])=>t.args[e]===i))})),w=h.queries.filter((e=>{if(!d.some((t=>t.id===e.id)))return!0;const t=d.find((t=>t.id===e.id));return!Object.entries(e.args).every((([e,i])=>t.args[e]===i))})),b={};v.forEach((e=>{const t=`${e.package}:${e.name}`;b[t]=e.args}));const C={};f.forEach((e=>{const t=`${g}:${e.name}:${e.id}`;C[t]=e.args}));const A={};w.forEach((e=>{const t=`${y}:${e.name}:${e.id}`;A[t]=e.args})),yield Pe({descriptors:m,externals:b,scripts:C,queries:A},this.dataFrame,this._molColName),this.saveCampaign("In Progress",!1)}))),(()=>null),this.template,!0)}))),"Calculate additional properties"),s=o.bigButton("Submit",(()=>{var e;const t=null===(e=this._submitView)||void 0===e?void 0:e.render();if(t){const e=o.dialog("Submit");e.add(t),e.addButton("Save",(()=>{this.saveCampaign(),e.close()})),e.addButton("Submit",(()=>{var t;null===(t=this._submitView)||void 0===t||t.submit(),e.close()})),e.show()}})),r=o.iconFA("share",(()=>Ve(this,void 0,void 0,(function*(){var e;yield new Te(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=K(n);return n.push([a,...this.hasEditPermission?[r]:[],...l?[]:[s]]),i.setRibbonPanels(n),i.name=this._filterViewName,setTimeout((()=>Ve(this,void 0,void 0,(function*(){var n,o,a;i._onAdded(),yield new Promise((e=>setTimeout(e,1e3)));const s=i.filters(this._campaignFilters?{filters:this._campaignFilters}:void 0),r=null!==(o=null===(n=this._campaign)||void 0===n?void 0:n.layout)&&void 0!==o?o:null===(a=this.template)||void 0===a?void 0:a.layoutViewState;if(r)try{const e=t.ViewLayout.fromViewState(r);i.loadLayout(e)}catch(e){console.error(e)}i.dataFrame.onFilterChanged.subscribe((e=>{this._filterDescriptions=Array.from(i.dataFrame.rows.filters),this._campaignFilters=s.getOptions().look.filters})),setTimeout((()=>{this._filterDescriptions=Array.from(i.dataFrame.rows.filters),this._campaignFilters=s.getOptions().look.filters}),300),e&&e()}))),300),i.parentCall=this.parentCall,i}getSummary(){var e,t,i,n,a,s,r;const l=null!==(t=null===(e=this.campaign)||void 0===e?void 0:e.campaignFields)&&void 0!==t?t:this.campaignProps;return Object.assign(Object.assign({Template:null!==(n=null===(i=this.template)||void 0===i?void 0:i.name)&&void 0!==n?n:"Molecules","File path":o.divH([o.link(null!==(a=this._dfName)&&void 0!==a?a:"-",(()=>this.download(this.dataFrame,"molecules")),x)],{style:{alignItems:"center"}})},l),{"Number of molecules":this.dataFrame.rowCount.toString(),"Enrichment methods":[this.template.compute.descriptors.enabled?"descriptors":"",...this.template.compute.functions.map((e=>e.name))].filter((e=>e&&""!==e.trim())).join(", "),Filters:this._filterDescriptions.join(", "),"Result Molecules":o.divH([o.link(null!==(r=null===(s=this.dataFrame)||void 0===s?void 0:s.filter.trueCount.toString())&&void 0!==r?r:"0",(()=>{this.download(this.dataFrame,"hits",!0)}),x)],{style:{alignItems:"center"}})})}saveCampaign(i){return Ve(this,arguments,void 0,(function*(i,n=!0){var a,s,c,u,d,p,h,m,v,f;const g=this.campaignId,y=this.filterSettings,w=this.template.name,b=this.dataFrame,C=`System:AppData/HitTriage/Hit Triage/campaigns/${g}/`,A=null!=g?g:yield function(e){return Fe(this,void 0,void 0,(function*(){return new Promise((t=>Fe(this,void 0,void 0,(function*(){const i=o.input.string("Campaign name",{value:""});o.dialog("Save Campaign").add(o.div(i.root)).onOK((function(){i.value&&""!==i.value?t(i.value):t(e)})).show()}))))}))}(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,E=null!==(u=null===(c=this.campaign)||void 0===c?void 0:c.permissions)&&void 0!==u?u:Ae,I={name:A,templateName:w,filters:null!=y?y:{},ingest:{type:"File",query:`${C}${r}`,molColName:this.molColName},status:null!==(p=null!=i?i:null===(d=this.campaign)||void 0===d?void 0:d.status)&&void 0!==p?p:"In Progress",createDate:null!==(m=null===(h=this.campaign)||void 0===h?void 0:h.createDate)&&void 0!==m?m: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:E};if(this.campaign=I,!this.hasEditPermission)return e.shell.error("You do not have permission to modify this campaign"),I;const N=t.DataFrame.fromColumns(b.columns.toList().filter((e=>!e.name.startsWith("~")))).toCsv();yield et.files.writeAsText(`Hit Triage/campaigns/${g}/${r}`,N);const F=this._pickView.saveLayout();return F?I.layout=F.viewState:e.shell.warning("Layout cound not be saved"),yield et.files.writeAsText(`Hit Triage/campaigns/${g}/${l}`,JSON.stringify(I)),n&&e.shell.info("Campaign saved successfully."),I}))}}function ke(i,n=!1){var a,s;const r=t.DataFrame.create(1);if(n){const e=r.columns.addNew(m,t.TYPE.STRING);e.semType=t.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,t.TYPE.STRING);l.semType=t.SEMTYPE.MOLECULE,l.meta.units=t.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,t.TYPE.STRING).set(0,i.stages[0]);const c=r.columns.addNew(v,t.TYPE.STRING);c.set(0,Oe(c));const u=i.campaignFields.map((e=>e.type===t.SEMTYPE.MOLECULE?Object.assign(Object.assign({},e),{type:"String",semtype:t.SEMTYPE.MOLECULE}):e)).map((e=>t.Property.fromOptions(Object.assign({name:e.name,type:ne[e.type],nullable:!e.required},e.semtype?{semType:e.semtype}:{})))),d={},f=o.input.form(d,u);f.classList.remove("ui-form");const g=o.div([...(null===(s=i.campaignFields)||void 0===s||s.length,[]),f]),y=o.buttonsInput([]);return g.appendChild(y),{promise:new Promise((t=>{const n=o.bigButton(A,(()=>{for(const t of i.campaignFields)if(t.required&&(!d[t.name]||""===d[t.name]))return void e.shell.error(`Field '${t.name}' is required`);t({df:r,campaignProps:d})}));y.appendChild(n)})),root:g,cancelPromise:new Promise((e=>{o.button(S,(()=>e()))}))}}var 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 Me(i,n){return Le(this,void 0,void 0,(function*(){var a,s,r,l,c,d,p,h,m,v,f;const w=yield et.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 et.files.readAsText(e));x.push(t.key)}catch(e){console.error(e)}const E=t.Func.find({tags:[u]}),I={};E.forEach((e=>{var t;I[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e}));const N=o.input.choice("Submit function",{value:null,items:[null,...Object.keys(I)]});N.nullable=!0,N.value=null!==(s=null===(a=null==n?void 0:n.submit)||void 0===a?void 0:a.fName)&&void 0!==s?s:null,N.setTooltip("Select function to be called upon submitting");const F=o.divText("Template name is empty or already exists",{classes:"hit-triage-error-div"}),_=o.divText("Template key is empty or already exists",{classes:"hit-triage-error-div"}),O=pe();function P(){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=o.input.string("Name",{value:null!==(r=null==n?void 0:n.name)&&void 0!==r?r:"",onValueChanged:P});function B(){var e,t,i,n;if(""===k.value||x.includes(null!==(t=null===(e=k.value)||void 0===e?void 0:e.trim())&&void 0!==t?t:"")){const e=null!==(i=k.input.offsetLeft)&&void 0!==i?i:0,t=null!==(n=k.input.offsetWidth)&&void 0!==n?n:0;_.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 k=o.input.string("Key",{value:null!==(l=null==n?void 0:n.key)&&void 0!==l?l:"",onValueChanged:B});k.setTooltip("Template key used for campaign prefix"),V.setTooltip("Template name"),V.root.style.borderBottom="none",k.root.style.borderBottom="none",F.style.opacity="0%",_.style.opacity="0%";let L=null;const M={compute:{descriptors:{enabled:!0,args:null!==(p=null===(d=null===(c=null==n?void 0:n.compute)||void 0===c?void 0:c.descriptors)||void 0===d?void 0:d.args)&&void 0!==p?p:[]},functions:null!==(m=null===(h=null==n?void 0:n.compute)||void 0===h?void 0:h.functions)&&void 0!==m?m:[]}},j=yield le(i,(e=>{L=e}),(()=>null),M,!1);j.root.classList.add("hit-triage-new-template-functions-input");const R=ve(null==n?void 0:n.campaignFields),U=je(null==n?void 0:n.stages),D=o.divV([o.divV([V,F]),o.divV([k,_]),O.dataFileInput,R.fieldsDiv]),$=o.h2("Stages");o.tooltip.bind($,'Define Stages for designed molecules. For example, "Design", "Synthesis", "Test", etc.');const H=o.h2("Compute");o.tooltip.bind(H,'Define functions to be calculated for each molecule. For example, "Descriptors", "Descriptors:Descriptors", etc.');const q=o.div([o.h2("Details"),D,$,U.fieldsDiv,H,j.root,o.h2("Submit"),N.root],"ui-form"),Y=o.buttonsInput([]);q.appendChild(Y);const W=null!==(f=null===(v=Y.getElementsByClassName("ui-input-editor"))||void 0===v?void 0:v[0])&&void 0!==f?f:Y,G=new Promise((e=>{const t=o.button(S,(()=>e()));W.appendChild(t)})),J=new Promise((t=>{const n=o.bigButton(T,(()=>function(){return Le(this,void 0,void 0,(function*(){var n,o,a,s,r,l;if(P(),B(),j.okProxy(),b||!V.value||""===V.value)return void e.shell.error("Template name is empty or already exists");if(C||!k.value||""===k.value)return void e.shell.error("Template key is empty or already exists");const c=N.value?I[N.value]:void 0,u=Object.assign({name:V.value,key:k.value,campaignFields:R.getFields(),stages:U.getFields(),layoutViewState:null!==(n=O.getLayoutViewState())&&void 0!==n?n:void 0,compute:{descriptors:{enabled:!!(null===(o=null==L?void 0:L.descriptors)||void 0===o?void 0:o.length),args:null!==(a=null==L?void 0:L.descriptors)&&void 0!==a?a:[]},functions:Object.entries(null!==(s=null==L?void 0:L.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==L?void 0:L.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==L?void 0:L.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}}))}},c?{submit:{fName:c.name,package:c.package.name}}:{});var d,p;d=u,p=i.appName,et.files.writeAsText(`${p}/templates/${d.name}.json`,JSON.stringify(d)),e.shell.info("Template created successfully"),t(u)}))}()));W.appendChild(n)}));return{root:q,template:J,cancelPromise:G}}))}function je(e){const i=[t.Property.fromOptions({name:"Name",type:t.TYPE.STRING})],n=new ue(i,e?e.map((e=>({Name:e}))):void 0,{horizontalInputNames:!0});let o={};return n.onItemAdded.subscribe((e=>{o={}})),n.onAddingItemChanged.subscribe((e=>{e&&(o=e.item)})),{getFields:function(){const e=n.items.filter((e=>e.Name)).map((e=>e.Name));return o.Name&&""!==o.Name&&e.push(o.Name),e},fieldsDiv:n.root,itemsGrid:n}}var Re=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};class Ue extends ge{constructor(t){super(t),this.currentSorting="None",this.name="Hit Design",e.shell.windows.showHelp=!0,e.shell.windows.help.showHelp(et.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(et.webRoot+"README_HD.md")}getAppHeader(){return be.appHeader({iconPath:et.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 Re(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0);try{const n=o.h1(E),a=o.h1(I,{style:{marginLeft:"10px"}}),s=this.getAppHeader(),r=o.div(),l=o.divH([]),c=o.div([l,r],"ui-form"),u=yield this.getCampaignsTable(),d=o.div([u],{style:{position:"relative"}}),p=o.iconFA("sort",(()=>{const i=t.Menu.popup();Object.values(_).forEach((t=>{i.item(t,(()=>Re(this,void 0,void 0,(function*(){(function(e,t){localStorage.setItem(e,t)})(F,t),o.setUpdateIndicator(d,!0);try{const e=yield this.getCampaignsTable();o.setUpdateIndicator(d,!1),o.empty(d),d.appendChild(e)}catch(t){e.shell.error("Failed to update campaigns table"),console.error(t)}finally{o.setUpdateIndicator(d,!1)}})))),i.show({element:h,x:100,y:h.offsetTop+30})}))}));p.style.marginBottom="12px",p.style.marginLeft="5px",p.style.fontSize="15px",o.tooltip.bind(p,(()=>`Group Campaigns. Current: ${this.currentSorting}`));const h=o.divH([n,p],{style:{alignItems:"center"}});se()(this.root).empty(),this.root.appendChild(o.div([o.divV([s,h],{style:{marginLeft:"10px"}}),d,a,c])),yield this.startNewCampaign(r,l,i),this.app.resetBaseUrl()}finally{o.setUpdateIndicator(this.root,!1)}}))}startNewCampaign(t,i,n){return Re(this,void 0,void 0,(function*(){var a;const s=(yield et.files.list(`${this.app.appName}/templates`)).filter((e=>e.name.endsWith(".json"))).map((e=>e.name.slice(0,-5)));n&&!s.includes(n.name)&&s.push(n.name);let r=null,l=!0;const c=()=>Re(this,void 0,void 0,(function*(){if(!l)return;const e=u.value,i=n&&n.name===e?n:JSON.parse(yield et.files.readAsText(`${this.app.appName}/templates/${e}.json`));r=i;const o=yield this.getNewCampaignAccordeon(i);se()(t).empty(),t.appendChild(o)})),u=o.input.choice("Template",{value:null!==(a=null==n?void 0:n.name)&&void 0!==a?a:s[0],items:s,onValueChanged:()=>Re(this,void 0,void 0,(function*(){yield c()}))});u.root.style.width="100%";const d=o.icons.add((()=>{this.createNewTemplate()}),C),p=o.icons.copy((()=>{r&&this.createNewTemplate(r)}),"Clone template"),h=o.icons.delete((()=>{!u.value||u.items.length<2||o.dialog("Delete template").add(o.divText(`Are you sure you want to delete template ${u.value}?`)).onOK((()=>Re(this,void 0,void 0,(function*(){try{const t=u.value;yield et.files.delete(`${this.app.appName}/templates/${t}.json`),l=!1,u.items=u.items.filter((e=>e!==t)),u.value=u.items[0],l=!0,yield c(),e.shell.info("Template "+t+" was deleted successfully")}catch(t){l=!0,e.shell.error("Failed to delete template "+u.value),console.error(t)}})))).show()}),"Delete template");d.style.color="#2083d5",u.addOptions(h),u.addOptions(p),u.addOptions(d),yield c(),se()(i).empty(),i.appendChild(u.root)}))}checkCampaign(e){return Re(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 et.files.exists(`${this.app.appName}/campaigns/${o}/${l}`)))return;const a=JSON.parse(yield et.files.readAsText(`${this.app.appName}/campaigns/${o}/${l}`));if(a){if(a.authorUserId&&a.permissions&&!(yield te(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 et.files.readAsText(`${this.app.appName}/templates/${a.templateName}.json`));return yield this.app.setTemplate(r,o),e&&G(s,e),a.template=r,a}))}getCampaignsTable(){return Re(this,void 0,void 0,(function*(){const i=yield Z(this.app.appName,this.deletedCampaigns),n=null!==(r=F,s=localStorage.getItem(r))&&void 0!==s?s:_.None,a=function(e,t){if(t===_.None)return{"":e};const i={};for(const n of e){const e=ie(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 c=i=>{var n,a;const s=o.icons.delete((()=>Re(this,void 0,void 0,(function*(){o.dialog("Delete campaign").add(o.divText(`Are you sure you want to delete campaign ${i.name}?`)).onOK((()=>Re(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=o.iconFA("share",(()=>Re(this,void 0,void 0,(function*(){yield new Te(i.permissions).show((t=>Re(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 et.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",ee(null!==(n=i.authorUserId)&&void 0!==n?n:t.User.current().id,null!==(a=i.permissions)&&void 0!==a?a:Ae).then((e=>{e&&(s.style.display="inline-block",r.style.display="inline-block")})),[r,s]},u=o.table(Object.values(i),(e=>[o.link(e.name,(()=>this.setCampaign(e.name)),"",""),e.createDate,e.rowCount,e.status,...c(e)]),["Name","Created","Molecules","Status",""]);return u.style.color="var(--grey-5)",u.style.marginLeft="24px",function(e,t,i=6){e.classList.add("hit-design-groupped-campaigns-table");const n=Object.keys(t);if(n.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 n){const n=s[r];if(!n)break;const c=t[e].length,u=r,d=r+c,p=o.accordion(`Hit-Design-campaigns-group-${e}`).addPane(e,(()=>o.div()),void 0,void 0,!1);p.root.style.marginLeft="-24px",p.root.onclick=()=>{l(p.expanded,u,d)},l(p.expanded,u,d);const h=a.insertRow(0),m=h.insertCell(0);m.appendChild(p.root),m.colSpan=i,a.insertBefore(h,n),r+=c}}(u,a),u}))}setCampaign(e){return Re(this,void 0,void 0,(function*(){const t=yield this.checkCampaign(e);this.app.campaign=t}))}getNewCampaignAccordeon(e){return Re(this,void 0,void 0,(function*(){const{root:t,promise:i,cancelPromise:n}=ke(e);return i.then((t=>Re(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}))}createNewTemplate(i){return Re(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0);try{const n=yield Me(this.app,i),o=new t.ViewBase,a=e.shell.v;o.name="New Template",o.root.appendChild(n.root),o.parentCall=this.app.parentCall,e.shell.addView(o),o.path=new URL(this.app.baseUrl).pathname+"/new-template";const{sub:s}=J(o,this.app.appName,C,(()=>Re(this,void 0,void 0,(function*(){e.shell.v=a,o.close()}))));n.template.then((t=>Re(this,void 0,void 0,(function*(){yield this.init(t),o.close(),z(o),e.shell.v=a,s.unsubscribe()})))),n.cancelPromise.then((()=>Re(this,void 0,void 0,(function*(){s.unsubscribe(),o.close(),e.shell.v=a}))))}finally{o.setUpdateIndicator(this.root,!1)}}))}}class De extends ge{constructor(e){var i;super(e),this.name="Submit",this.statusInput=o.input.string("Status",{value:null===(i=this.app.campaign)||void 0===i?void 0:i.status,nullable:!1}),this.statusSuggestionsMenu=t.Menu.popup(),this.statusInput.root.style.marginLeft="12px",this.content=o.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,t;return this.statusInput.value=null!==(t=null===(e=this.app.campaign)||void 0===e?void 0:e.status)&&void 0!==t?t:"",o.empty(this.content),this.content=o.divV([o.h1("Summary"),o.div([o.tableFromMap(this.app.getSummary())]),this.statusInput.root]),this.content}onActivated(){this.render()}submit(){return i=this,n=void 0,a=function*(){var i;const n=null===(i=this.app.template)||void 0===i?void 0:i.submit;if(!n)return;const o=t.Func.find({name:n.fName,package:n.package})[0];if(!o)return void e.shell.error(`Function ${n.fName} not found.`);const a=t.DataFrame.fromCsv(this.app.dataFrame.toCsv({filteredRowsOnly:!0}));yield o.apply({df:a,molecules:this.app.molColName}),this.app.campaign.status=this.getStatus(),this.app.saveCampaign(),e.shell.info("Submitted successfully.")},new((o=void 0)||(o=Promise))((function(e,t){function s(e){try{l(a.next(e))}catch(e){t(e)}}function r(e){try{l(a.throw(e))}catch(e){t(e)}}function l(t){var i;t.done?e(t.value):(i=t.value,i instanceof o?i:new o((function(e){e(i)}))).then(s,r)}l((a=a.apply(i,n||[])).next())}));var i,n,o,a}}var $e=i(542),He={};He.styleTagTransform=$(),He.setAttributes=j(),He.insert=L().bind(null,"head"),He.domAPI=B(),He.insertStyleElement=U(),P()($e.A,He),$e.A&&$e.A.locals&&$e.A.locals;function qe(i,n){var a,s,r,l,c,u,d,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=o.dialog("Progress Tracker");try{y=g.addViewer(t.VIEWER.TILE_VIEWER,f);const e=y.getOptions();e.look.sketchState=(null!==(u=null===(c=null==v?void 0:v.elementStates)||void 0===c?void 0:c.length)&&void 0!==u?u:0)>0?v:null,y.setOptions(e),y.copyViewersLook(y)}catch(n){e.shell.error("Failed to create tiles viewer with preset layout.\n Falling back to default layout."),console.error("Failed to create tiles viewer",n),y&&(y.close(),y.detach()),y=g.addViewer(t.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 t=je(i.stages);b=o.dialog("Modify Stages").add(t.fieldsDiv).onOK((()=>{return a=this,s=void 0,l=function*(){C(),o.setUpdateIndicator(w.root,!0);try{yield i.setStages(t.getFields()),o.setUpdateIndicator(w.root,!1),w.close(),yield new Promise((e=>setTimeout((()=>{e(),qe(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===(d=w.getButton("CANCEL"))||void 0===d||d.remove(),w.onOK((()=>{})),null===(h=document.querySelector(".d4-modal-background"))||void 0===h||h.remove()}const Ye=rxjs.operators;var We=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};class Ge extends Ne{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,i="Hit Design",n=e=>new Ue(e)){super(e,i),this._designViewName="Design",this._filePath=`System.AppData/HitTriage/${this.appName}/campaigns`,this._molColName=h,this.campaignProps={},this.existingStatuses=[],this._infoView=n(this),this.multiView=new t.MultiView({viewFactories:{[this._infoView.name]:()=>this._infoView}}),this.multiView.tabs.onTabChanged.subscribe((e=>{this.multiView.currentView instanceof ge&&this.multiView.currentView.onActivated()})),this.multiView.parentCall=e,this.mainView=this.multiView,this._initViewChangeSub()}_initViewChangeSub(){this.multiView.subs.push(e.events.onCurrentViewChanged.subscribe((()=>We(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(),G(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}=J(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)}})))))}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 We(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,c=n.getRawData();for(let e=0;e<r;e++){const i=l[c[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(i,n){return We(this,void 0,void 0,(function*(){var o,l,c,u,d,p,m,v,f,g,y;if(n){const t=`System.AppData/HitTriage/${this.appName}/campaigns`;this._filePath=null!==(c=null===(l=this.campaign)||void 0===l?void 0:l.savePath)&&void 0!==c?c:`${t}/${n}/${r}`,this.dataFrame=yield e.dapi.files.readCsv(this._filePath),(null===(u=this._campaign)||void 0===u?void 0:u.columnSemTypes)&&Object.entries(this._campaign.columnSemTypes).forEach((([e,t])=>{const i=this.dataFrame.columns.byName(e);i&&t&&(i.semType=t)})),(null===(d=this._campaign)||void 0===d?void 0:d.columnTypes)&&Object.entries(this._campaign.columnTypes).forEach((([e,t])=>{const i=this.dataFrame.columns.byName(e);if(i&&i.type!==t)try{this.dataFrame.changeColumnType(e,t)}catch(e){console.error(e)}}))}else(null===(o=this._designView)||void 0===o?void 0:o.dataFrame)&&e.shell.closeTable(this._designView.dataFrame),this._designView=void 0,n=yield this.getNewCampaignName(`${this.appName}/campaigns`,i.key),G(s,n),this._filePath=`System.AppData/HitTriage/${this.appName}/campaigns/${n}/${r}`;if(!this.dataFrame)return void console.error("DataFrame is empty");yield this.dataFrame.meta.detectSemanticTypes(),this._molColName=null!==(m=null===(p=this.dataFrame.columns.bySemType(t.SEMTYPE.MOLECULE))||void 0===p?void 0:p.name)&&void 0!==m?m:h,this._campaignId=n,this.template=i,null!==(v=this._submitView)&&void 0!==v||(this._submitView=new De(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(),G(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=i)}))}get campaignId(){return this._campaignId}get designView(){return this._designView=this.getDesignView()}get designViewName(){return this._designViewName}get molColName(){var e,i,n,o;return null!==(e=this._molColName)&&void 0!==e?e:this._molColName=null!==(o=null===(n=null===(i=this.dataFrame)||void 0===i?void 0:i.columns.bySemType(t.SEMTYPE.MOLECULE))||void 0===n?void 0:n.name)&&void 0!==o?o:h}get campaign(){return this._campaign}set campaign(e){this._campaign=e}cacheDuplicateVIDs(){var e;const t=null===(e=this.dataFrame)||void 0===e?void 0:e.col(v);if(!t)return void(this._duplicateVidCache=void 0);const i=t.version,n=new Uint32Array(t.categories.length).fill(0),o=t.getRawData().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(i,n){return We(this,void 0,void 0,(function*(){const o=this.template.compute;if(!n||""===n)return;const a=yield function(i,n,o){return _e(this,arguments,void 0,(function*(i,n,o,a=[],s=[]){const r=t.TaskBarProgressIndicator.create("Calculating ..."),l=e.chem.convert(i,e.chem.Notation.Unknown,e.chem.Notation.Smiles),c=t.Column.fromStrings(h,[l]),u=t.DataFrame.fromColumns([c]);u.name="HD Single cell values",yield u.meta.detectSemanticTypes();try{n.length&&(yield e.chem.descriptors(u,c.name,n))}catch(e){console.error("Descriptors calculation error",e)}for(const e of o)try{const i=e.args,n=t.Func.find({package:e.package,name:e.name});if(!n.length||!n[0]){console.warn(`Function ${e.name} from package ${e.package} is not found`);continue}const o=n[0],a=o.inputs[0].name,s=o.inputs[1].name;yield o.apply(Object.assign(Object.assign({},i),{[a]:u,[s]:c.name}))}catch(e){console.error(e);continue}for(const e of a){const i=e.args;try{const n=t.Func.find({name:e.name}).filter((t=>t.type===N.script&&t.id===e.id))[0];if(n){const e=n.inputs[0].name,t=n.inputs[1].name,o=yield n.apply(Object.assign(Object.assign({},i),{[e]:u,[t]:c.name}));if(o&&o.rowCount===u.rowCount&&"python"===n.language)for(const e of o.columns)e.name=u.columns.getUnusedName(e.name),u.columns.add(e)}}catch(e){console.error(e)}}for(const e of s){const i=e.args;try{const n=t.Func.find({name:e.name}).filter((t=>t.type===N.query&&t.id===e.id))[0];if(n){const e=n.inputs[0].name,t=[l],o=yield n.apply(Object.assign(Object.assign({},i),{[e]:t}));if(!o||0===o.rowCount)continue;yield Q(u,h,o)}}catch(e){console.error(e)}}return r.close(),u}))}(n,o.descriptors.args,o.functions,o.scripts,o.queries);for(const e of a.columns.toList())e.name!==h&&(this.dataFrame.columns.contains(e.name)||(this.dataFrame.columns.addNew(e.name,e.type).semType=e.semType),this.dataFrame.col(e.name).set(i,e.get(0),!1));this.dataFrame.fireValuesChanged(),this.saveCampaign(!1)}))}initDesignViewRibbons(i,n){const a=e.events.onViewRemoved.subscribe((e=>{e.id===(null==i?void 0:i.id)&&(n.forEach((e=>e.unsubscribe())),a.unsubscribe())}));let s=null==i?void 0:i.getRibbonPanels();if(s&&!K(s)){const e=()=>We(this,void 0,void 0,(function*(){var e;le(this,(e=>We(this,void 0,void 0,(function*(){var t,n,a,s,r,l,c,u,d,p;const h=this.template.compute.descriptors.args,m=this.template.compute.functions,v=null!==(t=this.template.compute.scripts)&&void 0!==t?t:[],f=null!==(n=this.template.compute.queries)&&void 0!==n?n:[],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!==(c=null==e?void 0:e.queries)&&void 0!==c?c:{}).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!==(u=null==e?void 0:e.externals)&&void 0!==u?u:{}).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!==(d=null==e?void 0:e.scripts)&&void 0!==d?d:{}).filter((([e,t])=>{const i=v.find((t=>`${g}:${t.name}:${t.id}`===e));return!i||!Object.entries(t).every((([e,t])=>i.args[e]===t))})).forEach((([e,t])=>{T[e]=t}));const x={};Object.entries(null!==(p=null==e?void 0:e.queries)&&void 0!==p?p:{}).filter((([e,t])=>{const i=f.find((t=>`${y}:${t.name}:${t.id}`===e));return!i||!Object.entries(t).every((([e,t])=>i.args[e]===t))})).forEach((([e,t])=>{x[e]=t})),o.setUpdateIndicator(i.grid.root,!0);try{yield Pe({descriptors:C,externals:A,scripts:T,queries:x},this.dataFrame,this.molColName),this.dataFrame.fireValuesChanged()}finally{o.setUpdateIndicator(i.grid.root,!1),this.saveCampaign(!1)}}))),(()=>null),null===(e=this.campaign)||void 0===e?void 0:e.template,!0)})),n=o.iconFA("wrench",e,"Calculate additional properties"),a=o.icons.add((()=>{var e;null===(e=this.dataFrame)||void 0===e||e.rows.addNew(null,!0)}),"Add new row"),r=o.iconFA("share",(()=>We(this,void 0,void 0,(function*(){var e;yield new Te(null===(e=this.campaign)||void 0===e?void 0:e.permissions).show((e=>{this.campaign.permissions=e,this.saveCampaign(!0)}))}))),"Edit campaign permissions"),l=o.bigButton("Progress tracker",(()=>{qe(this,(()=>{var e;return null!==(e=this._designView)&&void 0!==e?e:null}))})),c=o.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=o.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=t.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()}}));c.classList.add("hit-design-submit-button");const u=[c];this.stages.length>0&&u.unshift(l),this.campaign&&this.template&&!this.campaign.template&&(this.campaign.template=this.template),this.hasEditPermission&&u.unshift(r),u.unshift(n),u.unshift(a),s.push(u),s.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)})),s=s.filter((e=>{var t;return(null!==(t=null==e?void 0:e.length)&&void 0!==t?t:0)>0})),i.setRibbonPanels(s)}return i}getDesignView(){var i,n,o,a,s,r;const l=[],c=null===(i=this.dataFrame.col(this.molColName))||void 0===i?void 0:i.toList().every((e=>!e&&""===e)),u=e.shell.addTableView(this.dataFrame);this._designViewName=null!==(o=null===(n=this.campaign)||void 0===n?void 0:n.name)&&void 0!==o?o:this._designViewName,u.name=this._designViewName,u._onAdded();const d=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(d)try{const e=t.ViewLayout.fromViewState(d);u.loadLayout(e)}catch(t){e.shell.error("Failed to apply layout. Falling back to default layout."),console.error(t)}return c&&e.functions.call("Chem:editMoleculeCell",{cell:u.grid.cell(this._molColName,0)}),l.push(this.dataFrame.onRowsAdded.pipe((0,Ye.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=u.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((i=>{var n,o,a,s,r,l,c,d,p,h,m,v;try{const e=null===(n=null==i?void 0:i.args)||void 0===n?void 0:n.context;if(!e)return;if((null==e?void 0:e.type)!==t.VIEWER.GRID)return;if(!e.tableView||e.tableView.id!==u.id)return;if((null===(s=null===(a=null===(o=null==i?void 0:i.args)||void 0===o?void 0:o.item)||void 0===a?void 0:a.tableColumn)||void 0===s?void 0:s.name)!==this.molColName||!(null===(l=null===(r=null==i?void 0:i.args)||void 0===r?void 0:r.item)||void 0===l?void 0:l.isTableCell))return;const f=null===(c=null==i?void 0:i.args)||void 0===c?void 0:c.menu;if(!f)return;f.item("Add new row",(()=>{this.dataFrame.rows.addNew(null,!0)})),f.item("Duplicate molecule",(()=>{var e,t,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===(t=null===(e=null==i?void 0:i.args)||void 0===e?void 0:e.item)||void 0===t?void 0:t.cell)||void 0===n?void 0:n.value)&&void 0!==o?o:"")}catch(e){console.error(e)}}));const g=null===(p=null===(d=null==i?void 0:i.args)||void 0===d?void 0:d.item)||void 0===p?void 0:p.tableRowIndex,y=null===(v=null===(m=null===(h=null==i?void 0:i.args)||void 0===h?void 0:h.item)||void 0===m?void 0:m.cell)||void 0===v?void 0:v.value;y&&(null!=g?g:-1)>-1&&f.item("Re-Run Calculations",(()=>We(this,void 0,void 0,(function*(){try{yield this.performSingleCellCalculations(g,y)}catch(e){console.error(e)}}))))}catch(t){e.log.error(t)}}))),(null==u?void 0:u.grid)||(e.shell.error("Applied layout created view without grid. Resetting layout."),u.resetLayout()),(null==u?void 0:u.grid)&&l.push(u.grid.onCellValueEdited.subscribe((t=>We(this,void 0,void 0,(function*(){var i,n,o,a,s;try{if((null===(i=t.tableColumn)||void 0===i?void 0:i.name)===p)return void(yield this.saveCampaign(!1));if((null===(n=t.tableColumn)||void 0===n?void 0:n.name)!==this.molColName)return;const r=t.cell.value,l=t.tableRowIndex;let c=null===(o=this.dataFrame.col(v))||void 0===o?void 0:o.get(l),u=!1;if(r)try{const i=t.tableColumn.toList().map((t=>{try{return e.chem.convert(t,e.chem.Notation.Unknown,e.chem.Notation.Smiles)}catch(e){return""}})),n=e.chem.convert(r,e.chem.Notation.Unknown,e.chem.Notation.Smiles);if((null==i?void 0:i.length)===this.dataFrame.rowCount)for(let e=0;e<i.length;e++)if(i[e]===n&&e!==l&&(null===(a=this.dataFrame.col(v))||void 0===a?void 0:a.get(e))){c=null===(s=this.dataFrame.col(v))||void 0===s?void 0:s.get(e),u=!0;break}}catch(e){console.error(e)}this.duplicateVidCache&&!u&&this.duplicateVidCache.valueCounts[this.duplicateVidCache.indexes[l]]>1&&(c=null),c&&""!==c||(c=Oe(this.dataFrame.col(v))),this.dataFrame.col(v).set(l,c,!1),this.performSingleCellCalculations(l,r)}catch(e){console.error(e)}}))))),(null==u?void 0:u.grid)&&l.push(u.grid.onCellRender.subscribe((e=>{var i;try{const n=e.cell;if(!n||!n.isTableCell||!n.tableColumn||!this.duplicateVidCache||n.tableColumn.name!==v||(null!==(i=n.tableRowIndex)&&void 0!==i?i:-1)<0)return;this.duplicateVidCache.valueCounts[this.duplicateVidCache.indexes[n.tableRowIndex]]>1&&(e.cell.style.backColor=t.Color.setAlpha(t.Color.getCategoricalColor(this.duplicateVidCache.indexes[n.tableRowIndex]),150))}catch(e){}}))),this.initDesignViewRibbons(u,l),u.parentCall=this.parentCall,u}getSummary(){var i,n,a,s;const l=()=>{var e,t;const i=this._filePath.indexOf(null!==(e=this.campaignId)&&void 0!==e?e:null===(t=this._campaign)||void 0===t?void 0:t.name);return-1===i?this._filePath:this._filePath.substring(0,i-1)},c=Object.assign({},null!==(n=null===(i=this.campaign)||void 0===i?void 0:i.campaignFields)&&void 0!==n?n:this.campaignProps);return this.template&&this.template.campaignFields&&Object.entries(c).forEach((([i,n])=>{const o=this.template.campaignFields.find((e=>e.name===i));o&&"Date"===o.type&&n?"Invalid Date"!==new Date(n).toString()?c[i]=new Date(n).toLocaleDateString():n.date?c[i]=new Date(n.date).toLocaleDateString():c[i]=n:o&&o.type===t.SEMTYPE.MOLECULE&&n&&(c[i]=e.chem.drawMolecule(n))})),Object.assign(Object.assign({Template:null!==(s=null===(a=this.template)||void 0===a?void 0:a.name)&&void 0!==s?s:"Molecules","File path":(()=>{const t=o.icons.edit((()=>{const i=l(),s=o.input.string("Path",{value:i}),c=s.root.getElementsByTagName("label").item(0);c&&c.remove(),s.root.style.width="100%";const u=o.button("Save",(()=>We(this,void 0,void 0,(function*(){const i=yield function(){return We(this,void 0,void 0,(function*(){const t=s.value;return t&&""!==t.trim()?!!(yield e.dapi.files.exists(t))||(e.shell.error("Given folder does not exist"),!1):(e.shell.error("Path can not be empty"),!1)}))}();if(!i)return;const c=s.value;c.endsWith("/")?this._filePath=`${c}${this.campaignId}/${r}`:this._filePath=`${c}/${this.campaignId}/${r}`,this._campaign&&(this._campaign.savePath=this._filePath),yield this.saveCampaign(!0),o.empty(a);const u=l();n=o.link(u,(()=>{var e,t,i;return this.download(this.dataFrame,null!==(i=null!==(e=this.campaignId)&&void 0!==e?e:null===(t=this._campaign)||void 0===t?void 0:t.name)&&void 0!==i?i:"Molecules")}),x),a.appendChild(n),a.appendChild(t)})))),d=o.button("Cancel",(()=>{o.empty(a),a.appendChild(n),a.appendChild(t)}));o.empty(a),s.addOptions(d),s.addOptions(u),a.appendChild(s.root)}),"Edit file path");t.style.marginLeft="5px";const i=l();let n=o.link(i,(()=>{var e,t,i;return this.download(this.dataFrame,null!==(i=null!==(e=this.campaignId)&&void 0!==e?e:null===(t=this._campaign)||void 0===t?void 0:t.name)&&void 0!==i?i:"Molecules")}),x);const a=o.divH([n,t],{style:{alignItems:"center"}});return a})()},c),{"Number of molecules":this.dataFrame.rowCount.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 We(this,arguments,void 0,(function*(i=!0){var n,o,a,s,r,c,u,d,p,h,m,v,f,g;const y=this.campaignId,w=this.template.name,b=this.dataFrame,C=y,A={};b.columns.toList().forEach((e=>A[e.name]=e.semType));const T={};b.columns.toList().forEach((e=>T[e.name]=e.type));const x=null!==(o=null===(n=this.campaign)||void 0===n?void 0:n.tilesViewerFormSketch)&&void 0!==o?o:void 0,S=null!==(s=null===(a=this.campaign)||void 0===a?void 0:a.authorUserId)&&void 0!==s?s:e.shell.user.id,E=null!==(c=null===(r=this.campaign)||void 0===r?void 0:r.permissions)&&void 0!==c?c:Ae,I={name:C,templateName:w,status:null!==(d=null===(u=this.campaign)||void 0===u?void 0:u.status)&&void 0!==d?d:"In Progress",createDate:null!==(h=null===(p=this.campaign)||void 0===p?void 0:p.createDate)&&void 0!==h?h:W(new Date),campaignFields:null!==(v=null===(m=this.campaign)||void 0===m?void 0:m.campaignFields)&&void 0!==v?v:this.campaignProps,columnSemTypes:A,rowCount:b.rowCount,filteredRowCount:b.filter.trueCount,savePath:this._filePath,columnTypes:T,tilesViewerFormSketch:x,version:this.version+1,authorUserId:S,permissions:E};if(!this.hasEditPermission)return e.shell.error("You do not have permission to modify this campaign"),I;const N=`${this.appName}/campaigns/${y}/${l}`;let F=b;if(yield et.files.exists(N)){const t=JSON.parse(yield et.files.readAsText(N));if((null!==(f=t.version)&&void 0!==f?f:0)>this.version&&(I.version=Math.max(this.version,null!==(g=t.version)&&void 0!==g?g:0)+1,yield e.dapi.files.exists(this._filePath)))try{const t=yield e.dapi.files.readCsv(this._filePath);F=this.unionDataframes(t,b,this.molColName)}catch(e){console.error(e)}}const _=t.DataFrame.fromColumns(F.columns.toList().filter((e=>!e.name.startsWith("~")))).toCsv();yield e.dapi.files.writeAsText(this._filePath,_);const O=this._designView.saveLayout();return O?I.layout=O.viewState:e.shell.warning("Layout cound not be saved"),I.template=this.template,yield et.files.writeAsText(N,JSON.stringify(I)),i&&e.shell.info("Campaign saved successfully."),this.campaign=I,I}))}}class Je extends t.GridCellRenderer{get name(){return"customGasteigerPNG"}get cellType(){return"customGasteigerPNG"}get defaultHeight(){return 200}get defaultWidth(){return 200}render(e,t,i,n,o,a,s){if(a.gridRow<0||!a.cell.value)return;const r=a.cell.value,l=new Image(n-2,o-2);l.src="data:image/png;base64,"+r,l.onload=function(){e.drawImage(l,t+2,i+2,n-2,o-2)}}}var ze=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 Ue{constructor(t){super(t),this.name="PeptiHit",e.shell.windows.showHelp=!0,e.shell.windows.help.showHelp(et.webRoot+"README_HD.md")}getNewCampaignAccordeon(e){return ze(this,void 0,void 0,(function*(){const{root:t,promise:i,cancelPromise:n}=ke(e,!0);return i.then((t=>ze(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 be.appHeader({iconPath:et.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 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 Ge{constructor(e){super(e,"PeptiHit",(e=>new Ke(e))),this._helmColName=m}setTemplate(e,i){const n=Object.create(null,{setTemplate:{get:()=>super.setTemplate}});return Qe(this,void 0,void 0,(function*(){var o,a;yield n.setTemplate.call(this,e,i),this._helmColName=null!==(a=null===(o=this.dataFrame.columns.bySemType(t.SEMTYPE.MACROMOLECULE))||void 0===o?void 0:o.name)&&void 0!==a?a:m}))}get helmColName(){var e,i;return null!==(e=this._helmColName)&&void 0!==e?e:null===(i=this.dataFrame.columns.bySemType(t.SEMTYPE.MACROMOLECULE))||void 0===i?void 0:i.name}performSingleCellCalculations(i,n){const o=Object.create(null,{performSingleCellCalculations:{get:()=>super.performSingleCellCalculations}});return Qe(this,void 0,void 0,(function*(){var a;try{if(!n)throw new Error("No cell value provided");const s=t.Column.fromStrings(this.helmColName,[n]),r=t.DataFrame.fromColumns([s]);s.semType=t.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())),c=l?null===(a=r.col(l))||void 0===a?void 0:a.get(0):null;if(!c)throw new Error("Failed to convert sequence to atomic level");this.dataFrame.set(this.molColName,i,c),yield o.performSingleCellCalculations.call(this,i,c)}catch(e){console.error(e)}}))}getDesignView(){var i,n,o,a,s,r;const l=[],c=null===(i=this.dataFrame.col(this.helmColName))||void 0===i?void 0:i.toList().every((e=>!e&&""===e)),u=this.dataFrame.col(this.helmColName);if(!u)throw new Error("No helm column found");u.semType=t.SEMTYPE.MACROMOLECULE,u.setTag("units","helm"),u.setTag(".alphabetIsMultichar","true"),u.setTag("cell.renderer","helm");const d=e.shell.addTableView(this.dataFrame);this._designViewName=null!==(o=null===(n=this.campaign)||void 0===n?void 0:n.name)&&void 0!==o?o:this._designViewName,d.name=this._designViewName,d._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=t.ViewLayout.fromViewState(h);d.loadLayout(e)}catch(t){e.shell.error("Failed to apply layout. Falling back to default layout."),console.error(t)}return c&&e.functions.call("Helm:editMoleculeCell",{cell:d.grid.cell(this.helmColName,0)}),l.push(this.dataFrame.onRowsAdded.pipe((0,Ye.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.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((i=>{var n,o,a,s,r,l,c,u,p,h,m,v;try{const e=null===(n=null==i?void 0:i.args)||void 0===n?void 0:n.context;if(!e)return;if((null==e?void 0:e.type)!==t.VIEWER.GRID)return;if(!e.tableView||e.tableView.id!==d.id)return;if((null===(s=null===(a=null===(o=null==i?void 0:i.args)||void 0===o?void 0:o.item)||void 0===a?void 0:a.tableColumn)||void 0===s?void 0:s.name)!==this.helmColName||!(null===(l=null===(r=null==i?void 0:i.args)||void 0===r?void 0:r.item)||void 0===l?void 0:l.isTableCell))return;const f=null===(c=null==i?void 0:i.args)||void 0===c?void 0:c.menu;if(!f)return;f.item("Add new row",(()=>{this.dataFrame.rows.addNew(null,!0)})),f.item("Duplicate Sequence",(()=>{var e,t,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===(t=null===(e=null==i?void 0:i.args)||void 0===e?void 0:e.item)||void 0===t?void 0:t.cell)||void 0===n?void 0:n.value)&&void 0!==o?o:"")}catch(e){console.error(e)}}));const g=null===(p=null===(u=null==i?void 0:i.args)||void 0===u?void 0:u.item)||void 0===p?void 0:p.tableRowIndex,y=null===(v=null===(m=null===(h=null==i?void 0:i.args)||void 0===h?void 0:h.item)||void 0===m?void 0:m.cell)||void 0===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)}}))),(null==d?void 0:d.grid)||(e.shell.error("Applied layout created view without grid. Resetting layout."),d.resetLayout()),(null==d?void 0:d.grid)&&l.push(d.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.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),c=!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),c=!0;break}}catch(e){console.error(e)}this.duplicateVidCache&&!c&&this.duplicateVidCache.valueCounts[this.duplicateVidCache.indexes[r]]>1&&(l=null),l&&""!==l||(l=Oe(this.dataFrame.col(v))),this.dataFrame.col(v).set(r,l,!1),this.performSingleCellCalculations(r,s)}catch(e){console.error(e)}}))))),(null==d?void 0:d.grid)&&l.push(d.grid.onCellRender.subscribe((e=>{var i;try{const n=e.cell;if(!n||!n.isTableCell||!n.tableColumn||!this.duplicateVidCache||n.tableColumn.name!==v||(null!==(i=n.tableRowIndex)&&void 0!==i?i:-1)<0)return;this.duplicateVidCache.valueCounts[this.duplicateVidCache.indexes[n.tableRowIndex]]>1&&(e.cell.style.backColor=t.Color.setAlpha(t.Color.getCategoricalColor(this.duplicateVidCache.indexes[n.tableRowIndex]),150))}catch(e){}}))),this.initDesignViewRibbons(d,l),d.parentCall=this.parentCall,d}}var Xe=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 et=new t.Package;function tt(i,n,o){return Xe(this,void 0,void 0,(function*(){const a=yield Z(o,[]);for(const[o,s]of Object.entries(a)){const o="ingest"in s?s.ingest.query:s.savePath;o&&!1!==(yield e.dapi.files.exists(o))&&i.item(s.name).onSelected.subscribe((i=>Xe(this,void 0,void 0,(function*(){try{const i=yield e.dapi.files.readCsv(o);if(!i)return;const a=s.columnSemTypes;if(a)for(const[e,n]of Object.entries(a)){const o=i.columns.byName(e);o&&(o.semType=n,n===t.SEMTYPE.MACROMOLECULE&&e===m&&(o.setTag("units","helm"),o.setTag(".alphabetIsMultichar","true"),o.setTag("cell.renderer","helm")))}const r=t.TableView.create(i,!1);n.preview=r;const l=s.layout;l&&r.loadLayout(t.ViewLayout.fromViewState(l))}catch(e){console.error(e)}}))))}}))}function it(e,t){return Xe(this,void 0,void 0,(function*(){yield tt(e,t,"Hit Triage")}))}function nt(e,t){return Xe(this,void 0,void 0,(function*(){yield tt(e,t,"Hit Design")}))}function ot(e,t){return Xe(this,void 0,void 0,(function*(){yield tt(e,t,"PeptiHit")}))}function at(){return Xe(this,void 0,void 0,(function*(){const t=e.functions.getCurrentCall();return new Be(t).multiView}))}function st(){return Xe(this,void 0,void 0,(function*(){const t=e.functions.getCurrentCall();return new Ge(t).multiView}))}function rt(){return Xe(this,void 0,void 0,(function*(){const t=e.functions.getCurrentCall();return yield e.functions.call("Bio:initBio",{}),new Ze(t).multiView}))}function lt(){return Xe(this,void 0,void 0,(function*(){const t=e.data.demo.molecules(100);return t.name="100 Molecules",t}))}function ct(){return Xe(this,void 0,void 0,(function*(){const t=e.data.demo.molecules(5e3);return t.name="5000 Molecules",t}))}function ut(t){return Xe(this,void 0,void 0,(function*(){const i=e.data.demo.molecules(t);return i.name="Variable Molecules number",i}))}function dt(t,i){return Xe(this,void 0,void 0,(function*(){e.shell.info(t.rowCount),e.shell.info(i)}))}function pt(){return new Je}})(),hittriage=n})();
|
|
2
2
|
//# sourceMappingURL=package.js.map
|