@datagrok/hit-triage 1.10.6 → 1.10.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +10 -0
- package/CHANGELOG.md +5 -0
- package/LICENSE.md +16 -0
- package/README_OLD.md +3 -3
- package/dist/package-test.js +34 -1
- package/dist/package-test.js.map +1 -1
- package/dist/package.js +430 -1
- package/dist/package.js.map +1 -1
- package/package.json +16 -42
- package/src/app/accordeons/new-hit-design-campaign-accordeon.ts +8 -2
- package/src/app/ai/view-functions.ts +549 -0
- package/src/app/base-view.ts +14 -2
- package/src/app/hit-app-base.ts +1 -0
- package/src/app/hit-design-app.ts +8 -1
- package/src/app/hit-design-views/info-view.ts +4 -3
- package/src/app/hit-design-views/submit-view.ts +13 -4
- package/src/app/hit-triage-app.ts +8 -1
- package/src/app/hit-triage-views/info-view.ts +4 -3
- package/src/app/hit-triage-views/submit-view.ts +6 -4
- package/src/package-api.ts +25 -14
- package/src/package.ts +5 -1
- package/src/packageSettingsEditor.ts +5 -11
- package/tsconfig.json +4 -69
- package/webpack.config.js +3 -46
- package/.eslintignore +0 -1
- package/.eslintrc.json +0 -45
package/dist/package.js
CHANGED
|
@@ -1,2 +1,431 @@
|
|
|
1
|
-
var hittriage;(()=>{var e={233(e){!function(){"use strict";var t=document,n=window,i=t.documentElement,o=t.createElement.bind(t),a=o("div"),r=o("table"),s=o("tbody"),l=o("tr"),c=Array.isArray,d=Array.prototype,u=d.concat,p=d.filter,m=d.indexOf,h=d.map,v=d.push,f=d.slice,g=d.some,y=d.splice,A=/^#(?:[\w-]|\\.|[^\x00-\xa0])*$/,w=/^\.(?:[\w-]|\\.|[^\x00-\xa0])*$/,C=/<.+>/,b=/^\w+$/;function E(e,t){var n,i=!!(n=t)&&11===n.nodeType;return e&&(i||I(t)||F(t))?!i&&w.test(e)?t.getElementsByClassName(e.slice(1).replace(/\\/g,"")):!i&&b.test(e)?t.getElementsByTagName(e):t.querySelectorAll(e):[]}var T=function(){function e(e,i){if(e){if(N(e))return e;var o=e;if(O(e)){var a=i||t;if(!(o=A.test(e)&&I(a)?a.getElementById(e.slice(1).replace(/\\/g,"")):C.test(e)?Z(e):N(a)?a.find(e):O(a)?S(a).find(e):E(e,a)))return}else if(P(e))return this.ready(e);(o.nodeType||o===n)&&(o=[o]),this.length=o.length;for(var r=0,s=this.length;r<s;r++)this[r]=o[r]}}return e.prototype.init=function(t,n){return new e(t,n)},e}(),x=T.prototype,S=x.init;function N(e){return e instanceof T}function B(e){return!!e&&e===e.window}function I(e){return!!e&&9===e.nodeType}function F(e){return!!e&&1===e.nodeType}function P(e){return"function"==typeof e}function O(e){return"string"==typeof e}function _(e){return void 0===e}function k(e){return null===e}function L(e){return!isNaN(parseFloat(e))&&isFinite(e)}function V(e){if("object"!=typeof e||null===e)return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function M(e,t,n){if(n){for(var i=e.length;i--;)if(!1===t.call(e[i],i,e[i]))return e}else if(V(e))for(var o=Object.keys(e),a=(i=0,o.length);i<a;i++){var r=o[i];if(!1===t.call(e[r],r,e[r]))return e}else for(i=0,a=e.length;i<a;i++)if(!1===t.call(e[i],i,e[i]))return e;return e}function $(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n="boolean"==typeof e[0]&&e.shift(),i=e.shift(),o=e.length;if(!i)return{};if(!o)return $(n,S,i);for(var a=0;a<o;a++){var r=e[a];for(var s in r)n&&(c(r[s])||V(r[s]))?(i[s]&&i[s].constructor===r[s].constructor||(i[s]=new r[s].constructor),$(n,i[s],r[s])):i[s]=r[s]}return i}S.fn=S.prototype=x,x.length=0,x.splice=y,"function"==typeof Symbol&&(x[Symbol.iterator]=d[Symbol.iterator]),S.isWindow=B,S.isFunction=P,S.isArray=c,S.isNumeric=L,S.isPlainObject=V,S.each=M,x.each=function(e){return M(this,e)},x.empty=function(){return this.each(function(e,t){for(;t.firstChild;)t.removeChild(t.firstChild)})},S.extend=$,x.extend=function(e){return $(x,e)};var D=/\S+/g;function R(e){return O(e)&&e.match(D)||[]}function U(e,t,i){if(F(e)){var o=n.getComputedStyle(e,null);return i?o.getPropertyValue(t)||void 0:o[t]||e.style[t]}}function j(e,t){return parseInt(U(e,t),10)||0}function H(e,t){return j(e,"border".concat(t?"Left":"Top","Width"))+j(e,"padding".concat(t?"Left":"Top"))+j(e,"padding".concat(t?"Right":"Bottom"))+j(e,"border".concat(t?"Right":"Bottom","Width"))}x.toggleClass=function(e,t){var n=R(e),i=!_(t);return this.each(function(e,o){F(o)&&M(n,function(e,n){i?t?o.classList.add(n):o.classList.remove(n):o.classList.toggle(n)})})},x.addClass=function(e){return this.toggleClass(e,!0)},x.removeAttr=function(e){var t=R(e);return this.each(function(e,n){F(n)&&M(t,function(e,t){n.removeAttribute(t)})})},x.attr=function(e,t){if(e){if(O(e)){if(arguments.length<2){if(!this[0]||!F(this[0]))return;var n=this[0].getAttribute(e);return k(n)?void 0:n}return _(t)?this:k(t)?this.removeAttr(e):this.each(function(n,i){F(i)&&i.setAttribute(e,t)})}for(var i in e)this.attr(i,e[i]);return this}},x.removeClass=function(e){return arguments.length?this.toggleClass(e,!1):this.attr("class","")},x.hasClass=function(e){return!!e&&g.call(this,function(t){return F(t)&&t.classList.contains(e)})},x.get=function(e){return _(e)?f.call(this):this[(e=Number(e))<0?e+this.length:e]},x.eq=function(e){return S(this.get(e))},x.first=function(){return this.eq(0)},x.last=function(){return this.eq(-1)},x.text=function(e){return _(e)?this.get().map(function(e){return F(e)||(t=e)&&3===t.nodeType?e.textContent:"";var t}).join(""):this.each(function(t,n){F(n)&&(n.textContent=e)})};var q={};function Y(e){return"none"===U(e,"display")}function G(e,t){var n=e&&(e.matches||e.webkitMatchesSelector||e.msMatchesSelector);return!!n&&!!t&&n.call(e,t)}function W(e){return O(e)?function(t,n){return G(n,e)}:P(e)?e:N(e)?function(t,n){return e.is(n)}:e?function(t,n){return n===e}:function(){return!1}}function z(e,t){return t?e.filter(t):e}x.filter=function(e){var t=W(e);return S(p.call(this,function(e,n){return t.call(e,n,e)}))},x.detach=function(e){return z(this,e).each(function(e,t){t.parentNode&&t.parentNode.removeChild(t)}),this};var J=/^\s*<(\w+)[^>]*>/,Q=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,K={"*":a,tr:s,td:l,th:l,thead:r,tbody:r,tfoot:r};function Z(e){if(!O(e))return[];if(Q.test(e))return[o(RegExp.$1)];var t=J.test(e)&&RegExp.$1,n=K[t]||K["*"];return n.innerHTML=e,S(n.childNodes).detach().get()}function X(e,t,n,i){for(var o=[],a=P(t),r=i&&W(i),s=0,l=e.length;s<l;s++)if(a){var c=t(e[s]);c.length&&v.apply(o,c)}else for(var d=e[s][t];!(null==d||i&&r(-1,d));)o.push(d),d=n?d[t]:null;return o}function ee(e){return e.multiple&&e.options?X(p.call(e.options,function(e){return e.selected&&!e.disabled&&!e.parentNode.disabled}),"value"):e.value||""}function te(e){return e.length>1?p.call(e,function(e,t,n){return m.call(n,e)===t}):e}S.parseHTML=Z,x.has=function(e){var t=O(e)?function(t,n){return E(e,n).length}:function(t,n){return n.contains(e)};return this.filter(t)},x.not=function(e){var t=W(e);return this.filter(function(n,i){return(!O(e)||F(i))&&!t.call(i,n,i)})},x.val=function(e){return arguments.length?this.each(function(t,n){var i=n.multiple&&n.options;if(i||Oe.test(n.type)){var o=c(e)?h.call(e,String):k(e)?[]:[String(e)];i?M(n.options,function(e,t){t.selected=o.indexOf(t.value)>=0},!0):n.checked=o.indexOf(n.value)>=0}else n.value=_(e)||k(e)?"":e}):this[0]&&ee(this[0])},x.is=function(e){var t=W(e);return g.call(this,function(e,n){return t.call(e,n,e)})},S.guid=1,S.unique=te,x.add=function(e,t){return S(te(this.get().concat(S(e,t).get())))},x.children=function(e){return z(S(te(X(this,function(e){return e.children}))),e)},x.parent=function(e){return z(S(te(X(this,"parentNode"))),e)},x.index=function(e){var t=e?S(e)[0]:this[0],n=e?this:S(t).parent().children();return m.call(n,t)},x.closest=function(e){var t=this.filter(e);if(t.length)return t;var n=this.parent();return n.length?n.closest(e):t},x.siblings=function(e){return z(S(te(X(this,function(e){return S(e).parent().children().not(e)}))),e)},x.find=function(e){return S(te(X(this,function(t){return E(e,t)})))};var ne=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,ie=/^$|^module$|\/(java|ecma)script/i,oe=["type","src","nonce","noModule"];function ae(e,t,n,a,r,s,l,c){return M(e,function(e,s){M(S(s),function(e,s){M(S(t),function(t,l){var c=n?l:s,d=n?e:t;!function(e,t,n,a,r){a?e.insertBefore(t,n?e.firstChild:null):"HTML"===e.nodeName?e.parentNode.replaceChild(t,e):e.parentNode.insertBefore(t,n?e:e.nextSibling),r&&function(e,t){var n=S(e);n.filter("script").add(n.find("script")).each(function(e,n){if(ie.test(n.type)&&i.contains(n)){var a=o("script");a.text=n.textContent.replace(ne,""),M(oe,function(e,t){n[t]&&(a[t]=n[t])}),t.head.insertBefore(a,null),t.head.removeChild(a)}})}(t,e.ownerDocument)}(n?s:l,d?c.cloneNode(!0):c,a,r,!d)},c)},l)},s),t}x.after=function(){return ae(arguments,this,!1,!1,!1,!0,!0)},x.append=function(){return ae(arguments,this,!1,!1,!0)},x.html=function(e){if(!arguments.length)return this[0]&&this[0].innerHTML;if(_(e))return this;var t=/<script[\s>]/.test(e);return this.each(function(n,i){F(i)&&(t?S(i).empty().append(e):i.innerHTML=e)})},x.appendTo=function(e){return ae(arguments,this,!0,!1,!0)},x.wrapInner=function(e){return this.each(function(t,n){var i=S(n),o=i.contents();o.length?o.wrapAll(e):i.append(e)})},x.before=function(){return ae(arguments,this,!1,!0)},x.wrapAll=function(e){for(var t=S(e),n=t[0];n.children.length;)n=n.firstElementChild;return this.first().before(t),this.appendTo(n)},x.wrap=function(e){return this.each(function(t,n){var i=S(e)[0];S(n).wrapAll(t?i.cloneNode(!0):i)})},x.insertAfter=function(e){return ae(arguments,this,!0,!1,!1,!1,!1,!0)},x.insertBefore=function(e){return ae(arguments,this,!0,!0)},x.prepend=function(){return ae(arguments,this,!1,!0,!0,!0,!0)},x.prependTo=function(e){return ae(arguments,this,!0,!0,!0,!1,!1,!0)},x.contents=function(){return S(te(X(this,function(e){return"IFRAME"===e.tagName?[e.contentDocument]:"TEMPLATE"===e.tagName?e.content.childNodes:e.childNodes})))},x.next=function(e,t,n){return z(S(te(X(this,"nextElementSibling",t,n))),e)},x.nextAll=function(e){return this.next(e,!0)},x.nextUntil=function(e,t){return this.next(t,!0,e)},x.parents=function(e,t){return z(S(te(X(this,"parentElement",!0,t))),e)},x.parentsUntil=function(e,t){return this.parents(t,e)},x.prev=function(e,t,n){return z(S(te(X(this,"previousElementSibling",t,n))),e)},x.prevAll=function(e){return this.prev(e,!0)},x.prevUntil=function(e,t){return this.prev(t,!0,e)},x.map=function(e){return S(u.apply([],h.call(this,function(t,n){return e.call(t,n,t)})))},x.clone=function(){return this.map(function(e,t){return t.cloneNode(!0)})},x.offsetParent=function(){return this.map(function(e,t){for(var n=t.offsetParent;n&&"static"===U(n,"position");)n=n.offsetParent;return n||i})},x.slice=function(e,t){return S(f.call(this,e,t))};var re=/-([a-z])/g;function se(e){return e.replace(re,function(e,t){return t.toUpperCase()})}x.ready=function(e){var n=function(){return setTimeout(e,0,S)};return"loading"!==t.readyState?n():t.addEventListener("DOMContentLoaded",n),this},x.unwrap=function(){return this.parent().each(function(e,t){if("BODY"!==t.tagName){var n=S(t);n.replaceWith(n.children())}}),this},x.offset=function(){var e=this[0];if(e){var t=e.getBoundingClientRect();return{top:t.top+n.pageYOffset,left:t.left+n.pageXOffset}}},x.position=function(){var e=this[0];if(e){var t="fixed"===U(e,"position"),n=t?e.getBoundingClientRect():this.offset();if(!t){for(var i=e.ownerDocument,o=e.offsetParent||i.documentElement;(o===i.body||o===i.documentElement)&&"static"===U(o,"position");)o=o.parentNode;if(o!==e&&F(o)){var a=S(o).offset();n.top-=a.top+j(o,"borderTopWidth"),n.left-=a.left+j(o,"borderLeftWidth")}}return{top:n.top-j(e,"marginTop"),left:n.left-j(e,"marginLeft")}}};var le={class:"className",contenteditable:"contentEditable",for:"htmlFor",readonly:"readOnly",maxlength:"maxLength",tabindex:"tabIndex",colspan:"colSpan",rowspan:"rowSpan",usemap:"useMap"};x.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(n,i){i[e]=t});for(var n in e)this.prop(n,e[n]);return this}},x.removeProp=function(e){return this.each(function(t,n){delete n[le[e]||e]})};var ce=/^--/;function de(e){return ce.test(e)}var ue={},pe=a.style,me=["webkit","moz","ms"],he={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,n){return void 0===n&&(n=de(e)),n||he[e]||!L(t)?t:"".concat(t,"px")}function fe(e,t){try{return e(t)}catch(e){return t}}x.css=function(e,t){if(O(e)){var n=de(e);return e=function(e,t){if(void 0===t&&(t=de(e)),t)return e;if(!ue[e]){var n=se(e),i="".concat(n[0].toUpperCase()).concat(n.slice(1));M("".concat(n," ").concat(me.join("".concat(i," "))).concat(i).split(" "),function(t,n){if(n in pe)return ue[e]=n,!1})}return ue[e]}(e,n),arguments.length<2?this[0]&&U(this[0],e,n):e?(t=ve(e,t,n),this.each(function(i,o){F(o)&&(n?o.style.setProperty(e,t):o.style[e]=t)})):this}for(var i in e)this.css(i,e[i]);return this};var ge=/^\s+|\s+$/;function ye(e,t){var n=e.dataset[t]||e.dataset[se(t)];return ge.test(n)?n:fe(JSON.parse,n)}function Ae(e,t){var n=e.documentElement;return Math.max(e.body["scroll".concat(t)],n["scroll".concat(t)],e.body["offset".concat(t)],n["offset".concat(t)],n["client".concat(t)])}x.data=function(e,t){if(!e){if(!this[0])return;var n={};for(var i in this[0].dataset)n[i]=ye(this[0],i);return n}if(O(e))return arguments.length<2?this[0]&&ye(this[0],e):_(t)?this:this.each(function(n,i){!function(e,t,n){n=fe(JSON.stringify,n),e.dataset[se(t)]=n}(i,e,t)});for(var i in e)this.data(i,e[i]);return this},M([!0,!1],function(e,t){M(["Width","Height"],function(e,n){var i="".concat(t?"outer":"inner").concat(n);x[i]=function(i){if(this[0])return B(this[0])?t?this[0]["inner".concat(n)]:this[0].document.documentElement["client".concat(n)]:I(this[0])?Ae(this[0],n):this[0]["".concat(t?"offset":"client").concat(n)]+(i&&t?j(this[0],"margin".concat(e?"Top":"Left"))+j(this[0],"margin".concat(e?"Bottom":"Right")):0)}})}),M(["Width","Height"],function(e,t){var n=t.toLowerCase();x[n]=function(i){if(!this[0])return _(i)?void 0:this;if(!arguments.length)return B(this[0])?this[0].document.documentElement["client".concat(t)]:I(this[0])?Ae(this[0],t):this[0].getBoundingClientRect()[n]-H(this[0],!e);var o=parseInt(i,10);return this.each(function(t,i){if(F(i)){var a=U(i,"boxSizing");i.style[n]=ve(n,o+("border-box"===a?H(i,!e):0))}})}});var we="___cd";x.toggle=function(e){return this.each(function(n,i){if(F(i)){var a=Y(i);(_(e)?a:e)?(i.style.display=i[we]||"",Y(i)&&(i.style.display=function(e){if(q[e])return q[e];var n=o(e);t.body.insertBefore(n,null);var i=U(n,"display");return t.body.removeChild(n),q[e]="none"!==i?i:"block"}(i.tagName))):a||(i[we]=U(i,"display"),i.style.display="none")}})},x.hide=function(){return this.toggle(!1)},x.show=function(){return this.toggle(!0)};var Ce="___ce",be={focus:"focusin",blur:"focusout"},Ee={mouseenter:"mouseover",mouseleave:"mouseout"},Te=/^(mouse|pointer|contextmenu|drag|drop|click|dblclick)/i;function xe(e){return Ee[e]||be[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 Be(e,t){return!t||!g.call(t,function(t){return e.indexOf(t)<0})}function Ie(e,t,n,i,o){var a=Ne(e);if(t)a[t]&&(a[t]=a[t].filter(function(a){var r=a[0],s=a[1],l=a[2];if(o&&l.guid!==o.guid||!Be(r,n)||i&&i!==s)return!0;e.removeEventListener(t,l)}));else for(t in a)Ie(e,t,n,i,o)}x.trigger=function(e,n){if(O(e)){var i=Se(e),o=i[0],a=i[1],r=xe(o);if(!r)return this;var s=Te.test(r)?"MouseEvents":"HTMLEvents";(e=t.createEvent(s)).initEvent(r,!0,!0),e.namespace=a.join("."),e.___ot=o}e.___td=n;var l=e.___ot in be;return this.each(function(t,n){l&&P(n[e.___ot])&&(n["___i".concat(e.type)]=!0,n[e.___ot](),n["___i".concat(e.type)]=!1),n.dispatchEvent(e)})},x.off=function(e,t,n){var i=this;if(_(e))this.each(function(e,t){(F(t)||I(t)||B(t))&&Ie(t)});else if(O(e))P(t)&&(n=t,t=""),M(R(e),function(e,o){var a=Se(o),r=a[0],s=a[1],l=xe(r);i.each(function(e,i){(F(i)||I(i)||B(i))&&Ie(i,l,s,t,n)})});else for(var o in e)this.off(o,e[o]);return this},x.remove=function(e){return z(this,e).detach().off(),this},x.replaceWith=function(e){return this.before(e).remove()},x.replaceAll=function(e){return S(e).replaceWith(this),this},x.on=function(e,t,n,i,o){var a=this;if(!O(e)){for(var r in e)this.on(r,t,n,e[r],o);return this}return O(t)||(_(t)||k(t)?t="":_(n)?(n=t,t=""):(i=n,n=t,t="")),P(i)||(i=n,n=void 0),i?(M(R(e),function(e,r){var s=Se(r),l=s[0],c=s[1],d=xe(l),u=l in Ee,p=l in be;d&&a.each(function(e,a){if(F(a)||I(a)||B(a)){var r=function(e){if(e.target["___i".concat(e.type)])return e.stopImmediatePropagation();if((!e.namespace||Be(c,e.namespace.split(".")))&&(t||!(p&&(e.target!==a||e.___ot===d)||u&&e.relatedTarget&&a.contains(e.relatedTarget)))){var s=a;if(t){for(var l=e.target;!G(l,t);){if(l===a)return;if(!(l=l.parentNode))return}s=l}Object.defineProperty(e,"currentTarget",{configurable:!0,get:function(){return s}}),Object.defineProperty(e,"delegateTarget",{configurable:!0,get:function(){return a}}),Object.defineProperty(e,"data",{configurable:!0,get:function(){return n}});var m=i.call(s,e,e.___td);o&&Ie(a,d,c,t,r),!1===m&&(e.preventDefault(),e.stopPropagation())}};r.guid=i.guid=i.guid||S.guid++,function(e,t,n,i,o){var a=Ne(e);a[t]=a[t]||[],a[t].push([n,i,o]),e.addEventListener(t,o)}(a,d,c,t,r)}})}),this):this},x.one=function(e,t,n,i){return this.on(e,t,n,i,!0)};var Fe=/\r?\n/g,Pe=/file|reset|submit|button|image/i,Oe=/radio|checkbox/i;x.serialize=function(){var e="";return this.each(function(t,n){M(n.elements||[n],function(t,n){if(!(n.disabled||!n.name||"FIELDSET"===n.tagName||Pe.test(n.type)||Oe.test(n.type)&&!n.checked)){var i=ee(n);_(i)||M(c(i)?i:[i],function(t,i){e+=function(e,t){return"&".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(t.replace(Fe,"\r\n")))}(n.name,i)})}})}),e.slice(1)},e.exports=S}()},558(e,t,n){"use strict";n.d(t,{A:()=>s});var i=n(354),o=n.n(i),a=n(314),r=n.n(a)()(o());r.push([e.id,".grok-hit-triage-view .d4-grid {\n width: initial !important;\n height: initial !important;\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.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}\n\n.hit-triage-info-view-container .fa-trash-alt:hover {\n color: #ff0000 !important;\n}","",{version:3,sources:["webpack://./css/hit-triage.css"],names:[],mappings:"AAAA;IACI,yBAAyB;IACzB,0BAA0B;AAC9B;;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;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;;AAEA;IACI,yBAAyB;AAC7B",sourcesContent:[".grok-hit-triage-view .d4-grid {\n width: initial !important;\n height: initial !important;\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.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}\n\n.hit-triage-info-view-container .fa-trash-alt:hover {\n color: #ff0000 !important;\n}"],sourceRoot:""}]);const s=r},801(e,t,n){"use strict";n.d(t,{A:()=>s});var i=n(354),o=n.n(i),a=n(314),r=n.n(a)()(o());r.push([e.id,".statistics-mpo-header {\n margin-top: 10px;\n padding-bottom: 5px;\n border-bottom: 1px solid var(--grey-2);\n gap: 10px;\n}\n\n.statistics-mpo-header > * {\n font-weight: bold;\n}\n\n.statistics-mpo-header > *:first-child {\n width: 130px;\n}\n\n.statistics-mpo-header > *:nth-child(2) {\n width: 120px;\n min-width: 60px;\n}\n\n.statistics-mpo-header > *:nth-child(3) {\n flex-grow: 1;\n}\n\n.statistics-mpo-property-cell {\n width: 130px;\n max-width: 130px;\n align-self: flex-end;\n margin-bottom: 20px !important;\n}\n\n.ui-form .statistics-mpo-property-cell > div:first-child {\n padding-left: 4px;\n}\n\n.statistics-mpo-property-cell > div:first-child {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.statistics-mpo-weight-input {\n width: 100px;\n}\n\n.statistics-mpo-weight-cell {\n align-self: flex-end;\n margin-bottom: 20px !important;\n align-items: center;\n gap: 4px;\n}\n\n.statistics-mpo-control-buttons {\n gap: 10px;\n margin-left: 10px;\n color: var(--blue-1);\n visibility: hidden;\n white-space: nowrap;\n flex-shrink: 0;\n}\n\n.statistics-mpo-row:hover .statistics-mpo-control-buttons,\n.statistics-mpo-cat-row:hover .statistics-mpo-control-buttons {\n visibility: visible;\n}\n\n.statistics-mpo-range-input {\n width: 70px;\n}\n\n.statistics-mpo-row {\n display: flex;\n align-items: center;\n justify-content: flex-start;\n padding: 8px 0;\n min-height: 70px;\n gap: 10px;\n\n flex-wrap: wrap;\n}\n\n.statistics-mpo-row > * {\n flex: 0 0 auto;\n}\n\n\n.statistics-mpo-row .ui-input-choice .ui-input-editor,\n.statistics-mpo-row .ui-input-column .ui-input-editor {\n width: 100px !important;\n max-width: none !important;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.ui-form .statistics-mpo-row .ui-input-root {\n margin-bottom: 0 !important;\n padding: 0 !important;\n}\n\n.statistics-mpo-editor-fill {\n width: 100%;\n height: 100%;\n}\n\n.statistics-mpo-cat-editor {\n width: 280px;\n margin-left: 30px;\n}\n\n.statistics-mpo-cat-row {\n display: flex;\n align-items: center;\n gap: 4px;\n margin-bottom: 2px;\n}\n\n.statistics-mpo-cat-name {\n width: 120px;\n}\n\n.statistics-mpo-cat-col-header {\n font-size: 11px;\n color: var(--grey-3);\n text-transform: uppercase;\n letter-spacing: 0.3px;\n}\n\n.statistics-mpo-desirability-dialog .statistics-mpo-cat-editor {\n width: auto;\n margin-left: 0;\n}\n\n.statistics-mpo-desirability-dialog .statistics-mpo-cat-name {\n flex: 1;\n width: auto;\n}\n\n.statistics-mpo-cat-desirability {\n width: 70px;\n}\n\n.statistics-compute-dialog-pane-header {\n display: flex;\n align-items: center;\n justify-content: end;\n}\n\n.statistics-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.statistics-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.statistics-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.statistics-compute-dialog-pane-header.selected {\n border-left: 4px solid var(--blue-1);\n background-color: #f2f2f5;\n}\n\n.statistics-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.statistics-compute-dialog-pane-header>span {\n padding: 0 4px;\n}\n\n.statistics-compute-dialog-host {\n max-height: 550px;\n max-width: 800px;\n min-width: 550px;\n overflow: clip;\n}\n\n.statistics-compute-dialog-descriptors-group {\n margin-left: 16px;\n overflow: hidden;\n}\n\n.statistics-compute-dialog-rerun-input {\n margin: 4px 0 8px 15px;\n padding-bottom: 6px;\n border-bottom: 1px solid var(--grey-2);\n}\n\n.oy-scroll {\n overflow-y: scroll;\n}\n\n.statistics-mpo-weight-toggle {\n cursor: pointer;\n color: var(--grey-4);\n font-size: 12px;\n}\n\n.statistics-mpo-weight-toggle:hover {\n color: var(--grey-5);\n}\n\n.statistics-mpo-weight-toggle-active {\n color: var(--grey-4);\n}\n\n.statistics-mpo-weight-toggle-active:hover {\n color: var(--grey-5);\n}\n\n.statistics-mpo-hidden {\n display: none !important;\n}\n\n.statistics-mpo-empty-state {\n text-align: center;\n padding: 48px 24px;\n color: var(--grey-4);\n border: 1px dashed var(--grey-2);\n border-radius: 8px;\n margin: 16px 12px;\n}\n\n.statistics-mpo-empty-state i {\n font-size: 48px;\n margin-bottom: 16px;\n display: block;\n color: var(--blue-1);\n opacity: 0.3;\n cursor: default;\n pointer-events: none;\n}\n\n.statistics-mpo-empty-state h3 {\n color: var(--grey-5);\n}\n\n.statistics-mpo-empty-state p {\n color: var(--grey-3);\n max-width: 360px;\n margin-inline: auto;\n}\n\n.statistics-mpo-dialog-header-row {\n gap: 12px;\n align-items: flex-end;\n margin-bottom: 8px;\n}\n\n.statistics-mpo-dialog-header-row .ui-input-root {\n flex: 0 1 auto;\n}\n\n.statistics-mpo-section-header {\n font-size: 11px;\n text-transform: uppercase;\n color: var(--blue-1);\n letter-spacing: 0.5px;\n border-bottom: 1px solid var(--grey-2);\n padding-bottom: 4px;\n margin: 12px 0 8px;\n}\n\n.statistics-mpo-param-grid.ui-form {\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 0 8px;\n}\n\n.statistics-mpo-desirability-dialog .statistics-mpo-plot {\n margin: 0 auto;\n}\n\n.statistics-mpo-plot-wrap {\n justify-content: center;\n align-items: flex-start;\n gap: 6px;\n}\n\n.statistics-mpo-plot-wrap .statistics-mpo-plot {\n margin: 0;\n}\n\n.statistics-mpo-curve-btn {\n padding: 1px 6px;\n font-size: 11px;\n text-align: center;\n cursor: pointer;\n border: 1px solid var(--grey-2, #dbdcdf);\n border-radius: 3px;\n background: var(--grey-1, #f2f2f5);\n}\n\n.statistics-mpo-curve-btn.statistics-mpo-toggle-on {\n color: #fff;\n background: var(--blue-1, #1f77b4);\n border-color: var(--blue-1, #1f77b4);\n}\n\n.statistics-mpo-curve-btn + .statistics-mpo-curve-btn {\n margin-top: 4px;\n}\n\n@media (max-width: 500px) {\n .statistics-mpo-row {\n flex-direction: column;\n align-items: flex-start;\n }\n\n .statistics-mpo-row > * {\n width: 100% !important;\n margin-bottom: 5px;\n }\n\n .statistics-mpo-weight-cell {\n margin-top: 0 !important;\n }\n}\n","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/statistics/css/styles.css"],names:[],mappings:"AAAA;EACE,gBAAgB;EAChB,mBAAmB;EACnB,sCAAsC;EACtC,SAAS;AACX;;AAEA;EACE,iBAAiB;AACnB;;AAEA;EACE,YAAY;AACd;;AAEA;EACE,YAAY;EACZ,eAAe;AACjB;;AAEA;EACE,YAAY;AACd;;AAEA;EACE,YAAY;EACZ,gBAAgB;EAChB,oBAAoB;EACpB,8BAA8B;AAChC;;AAEA;EACE,iBAAiB;AACnB;;AAEA;EACE,gBAAgB;EAChB,uBAAuB;EACvB,mBAAmB;AACrB;;AAEA;EACE,YAAY;AACd;;AAEA;EACE,oBAAoB;EACpB,8BAA8B;EAC9B,mBAAmB;EACnB,QAAQ;AACV;;AAEA;EACE,SAAS;EACT,iBAAiB;EACjB,oBAAoB;EACpB,kBAAkB;EAClB,mBAAmB;EACnB,cAAc;AAChB;;AAEA;;EAEE,mBAAmB;AACrB;;AAEA;EACE,WAAW;AACb;;AAEA;EACE,aAAa;EACb,mBAAmB;EACnB,2BAA2B;EAC3B,cAAc;EACd,gBAAgB;EAChB,SAAS;;EAET,eAAe;AACjB;;AAEA;EACE,cAAc;AAChB;;;AAGA;;EAEE,uBAAuB;EACvB,0BAA0B;EAC1B,gBAAgB;EAChB,uBAAuB;AACzB;;AAEA;EACE,2BAA2B;EAC3B,qBAAqB;AACvB;;AAEA;EACE,WAAW;EACX,YAAY;AACd;;AAEA;EACE,YAAY;EACZ,iBAAiB;AACnB;;AAEA;EACE,aAAa;EACb,mBAAmB;EACnB,QAAQ;EACR,kBAAkB;AACpB;;AAEA;EACE,YAAY;AACd;;AAEA;EACE,eAAe;EACf,oBAAoB;EACpB,yBAAyB;EACzB,qBAAqB;AACvB;;AAEA;EACE,WAAW;EACX,cAAc;AAChB;;AAEA;EACE,OAAO;EACP,WAAW;AACb;;AAEA;EACE,WAAW;AACb;;AAEA;EACE,aAAa;EACb,mBAAmB;EACnB,oBAAoB;AACtB;;AAEA;EACE,YAAY;EACZ,kCAAkC;EAClC,kBAAkB;EAClB,gBAAgB;EAChB,gBAAgB;EAChB,yBAAyB;EACzB,2BAA2B;AAC7B;;AAEA;EACE,oCAAoC;EACpC,yBAAyB;AAC3B;;AAEA;EACE,cAAc;AAChB;;AAEA;EACE,iBAAiB;EACjB,gBAAgB;EAChB,gBAAgB;EAChB,cAAc;AAChB;;AAEA;EACE,iBAAiB;EACjB,gBAAgB;AAClB;;AAEA;EACE,sBAAsB;EACtB,mBAAmB;EACnB,sCAAsC;AACxC;;AAEA;EACE,kBAAkB;AACpB;;AAEA;EACE,eAAe;EACf,oBAAoB;EACpB,eAAe;AACjB;;AAEA;EACE,oBAAoB;AACtB;;AAEA;EACE,oBAAoB;AACtB;;AAEA;EACE,oBAAoB;AACtB;;AAEA;EACE,wBAAwB;AAC1B;;AAEA;EACE,kBAAkB;EAClB,kBAAkB;EAClB,oBAAoB;EACpB,gCAAgC;EAChC,kBAAkB;EAClB,iBAAiB;AACnB;;AAEA;EACE,eAAe;EACf,mBAAmB;EACnB,cAAc;EACd,oBAAoB;EACpB,YAAY;EACZ,eAAe;EACf,oBAAoB;AACtB;;AAEA;EACE,oBAAoB;AACtB;;AAEA;EACE,oBAAoB;EACpB,gBAAgB;EAChB,mBAAmB;AACrB;;AAEA;EACE,SAAS;EACT,qBAAqB;EACrB,kBAAkB;AACpB;;AAEA;EACE,cAAc;AAChB;;AAEA;EACE,eAAe;EACf,yBAAyB;EACzB,oBAAoB;EACpB,qBAAqB;EACrB,sCAAsC;EACtC,mBAAmB;EACnB,kBAAkB;AACpB;;AAEA;EACE,aAAa;EACb,8BAA8B;EAC9B,UAAU;AACZ;;AAEA;EACE,cAAc;AAChB;;AAEA;EACE,uBAAuB;EACvB,uBAAuB;EACvB,QAAQ;AACV;;AAEA;EACE,SAAS;AACX;;AAEA;EACE,gBAAgB;EAChB,eAAe;EACf,kBAAkB;EAClB,eAAe;EACf,wCAAwC;EACxC,kBAAkB;EAClB,kCAAkC;AACpC;;AAEA;EACE,WAAW;EACX,kCAAkC;EAClC,oCAAoC;AACtC;;AAEA;EACE,eAAe;AACjB;;AAEA;EACE;IACE,sBAAsB;IACtB,uBAAuB;EACzB;;EAEA;IACE,sBAAsB;IACtB,kBAAkB;EACpB;;EAEA;IACE,wBAAwB;EAC1B;AACF",sourcesContent:[".statistics-mpo-header {\n margin-top: 10px;\n padding-bottom: 5px;\n border-bottom: 1px solid var(--grey-2);\n gap: 10px;\n}\n\n.statistics-mpo-header > * {\n font-weight: bold;\n}\n\n.statistics-mpo-header > *:first-child {\n width: 130px;\n}\n\n.statistics-mpo-header > *:nth-child(2) {\n width: 120px;\n min-width: 60px;\n}\n\n.statistics-mpo-header > *:nth-child(3) {\n flex-grow: 1;\n}\n\n.statistics-mpo-property-cell {\n width: 130px;\n max-width: 130px;\n align-self: flex-end;\n margin-bottom: 20px !important;\n}\n\n.ui-form .statistics-mpo-property-cell > div:first-child {\n padding-left: 4px;\n}\n\n.statistics-mpo-property-cell > div:first-child {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.statistics-mpo-weight-input {\n width: 100px;\n}\n\n.statistics-mpo-weight-cell {\n align-self: flex-end;\n margin-bottom: 20px !important;\n align-items: center;\n gap: 4px;\n}\n\n.statistics-mpo-control-buttons {\n gap: 10px;\n margin-left: 10px;\n color: var(--blue-1);\n visibility: hidden;\n white-space: nowrap;\n flex-shrink: 0;\n}\n\n.statistics-mpo-row:hover .statistics-mpo-control-buttons,\n.statistics-mpo-cat-row:hover .statistics-mpo-control-buttons {\n visibility: visible;\n}\n\n.statistics-mpo-range-input {\n width: 70px;\n}\n\n.statistics-mpo-row {\n display: flex;\n align-items: center;\n justify-content: flex-start;\n padding: 8px 0;\n min-height: 70px;\n gap: 10px;\n\n flex-wrap: wrap;\n}\n\n.statistics-mpo-row > * {\n flex: 0 0 auto;\n}\n\n\n.statistics-mpo-row .ui-input-choice .ui-input-editor,\n.statistics-mpo-row .ui-input-column .ui-input-editor {\n width: 100px !important;\n max-width: none !important;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.ui-form .statistics-mpo-row .ui-input-root {\n margin-bottom: 0 !important;\n padding: 0 !important;\n}\n\n.statistics-mpo-editor-fill {\n width: 100%;\n height: 100%;\n}\n\n.statistics-mpo-cat-editor {\n width: 280px;\n margin-left: 30px;\n}\n\n.statistics-mpo-cat-row {\n display: flex;\n align-items: center;\n gap: 4px;\n margin-bottom: 2px;\n}\n\n.statistics-mpo-cat-name {\n width: 120px;\n}\n\n.statistics-mpo-cat-col-header {\n font-size: 11px;\n color: var(--grey-3);\n text-transform: uppercase;\n letter-spacing: 0.3px;\n}\n\n.statistics-mpo-desirability-dialog .statistics-mpo-cat-editor {\n width: auto;\n margin-left: 0;\n}\n\n.statistics-mpo-desirability-dialog .statistics-mpo-cat-name {\n flex: 1;\n width: auto;\n}\n\n.statistics-mpo-cat-desirability {\n width: 70px;\n}\n\n.statistics-compute-dialog-pane-header {\n display: flex;\n align-items: center;\n justify-content: end;\n}\n\n.statistics-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.statistics-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.statistics-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.statistics-compute-dialog-pane-header.selected {\n border-left: 4px solid var(--blue-1);\n background-color: #f2f2f5;\n}\n\n.statistics-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.statistics-compute-dialog-pane-header>span {\n padding: 0 4px;\n}\n\n.statistics-compute-dialog-host {\n max-height: 550px;\n max-width: 800px;\n min-width: 550px;\n overflow: clip;\n}\n\n.statistics-compute-dialog-descriptors-group {\n margin-left: 16px;\n overflow: hidden;\n}\n\n.statistics-compute-dialog-rerun-input {\n margin: 4px 0 8px 15px;\n padding-bottom: 6px;\n border-bottom: 1px solid var(--grey-2);\n}\n\n.oy-scroll {\n overflow-y: scroll;\n}\n\n.statistics-mpo-weight-toggle {\n cursor: pointer;\n color: var(--grey-4);\n font-size: 12px;\n}\n\n.statistics-mpo-weight-toggle:hover {\n color: var(--grey-5);\n}\n\n.statistics-mpo-weight-toggle-active {\n color: var(--grey-4);\n}\n\n.statistics-mpo-weight-toggle-active:hover {\n color: var(--grey-5);\n}\n\n.statistics-mpo-hidden {\n display: none !important;\n}\n\n.statistics-mpo-empty-state {\n text-align: center;\n padding: 48px 24px;\n color: var(--grey-4);\n border: 1px dashed var(--grey-2);\n border-radius: 8px;\n margin: 16px 12px;\n}\n\n.statistics-mpo-empty-state i {\n font-size: 48px;\n margin-bottom: 16px;\n display: block;\n color: var(--blue-1);\n opacity: 0.3;\n cursor: default;\n pointer-events: none;\n}\n\n.statistics-mpo-empty-state h3 {\n color: var(--grey-5);\n}\n\n.statistics-mpo-empty-state p {\n color: var(--grey-3);\n max-width: 360px;\n margin-inline: auto;\n}\n\n.statistics-mpo-dialog-header-row {\n gap: 12px;\n align-items: flex-end;\n margin-bottom: 8px;\n}\n\n.statistics-mpo-dialog-header-row .ui-input-root {\n flex: 0 1 auto;\n}\n\n.statistics-mpo-section-header {\n font-size: 11px;\n text-transform: uppercase;\n color: var(--blue-1);\n letter-spacing: 0.5px;\n border-bottom: 1px solid var(--grey-2);\n padding-bottom: 4px;\n margin: 12px 0 8px;\n}\n\n.statistics-mpo-param-grid.ui-form {\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 0 8px;\n}\n\n.statistics-mpo-desirability-dialog .statistics-mpo-plot {\n margin: 0 auto;\n}\n\n.statistics-mpo-plot-wrap {\n justify-content: center;\n align-items: flex-start;\n gap: 6px;\n}\n\n.statistics-mpo-plot-wrap .statistics-mpo-plot {\n margin: 0;\n}\n\n.statistics-mpo-curve-btn {\n padding: 1px 6px;\n font-size: 11px;\n text-align: center;\n cursor: pointer;\n border: 1px solid var(--grey-2, #dbdcdf);\n border-radius: 3px;\n background: var(--grey-1, #f2f2f5);\n}\n\n.statistics-mpo-curve-btn.statistics-mpo-toggle-on {\n color: #fff;\n background: var(--blue-1, #1f77b4);\n border-color: var(--blue-1, #1f77b4);\n}\n\n.statistics-mpo-curve-btn + .statistics-mpo-curve-btn {\n margin-top: 4px;\n}\n\n@media (max-width: 500px) {\n .statistics-mpo-row {\n flex-direction: column;\n align-items: flex-start;\n }\n\n .statistics-mpo-row > * {\n width: 100% !important;\n margin-bottom: 5px;\n }\n\n .statistics-mpo-weight-cell {\n margin-top: 0 !important;\n }\n}\n"],sourceRoot:""}]);const s=r},677(e,t,n){"use strict";n.d(t,{A:()=>s});var i=n(354),o=n.n(i),a=n(314),r=n.n(a)()(o());r.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}\n\n.u2-app-header-bottom-line {\n border-bottom: solid 1px lightgrey;\n}\n\n.u2-app-header-with-name {\n gap: 60px;\n}\n\n.u2-app-header-with-name .ui-app-header-icon{\n width: 90px;\n height: 90px;\n}\n\n.u2-app-header-app-name-and-slogan-div {\n gap: 10px;\n margin-top: 10px;\n}\n\n.u2-app-header-app-name-div {\n font-size: 20px;\n font-weight: bold;\n}\n\n.u2-app-header-description {\n margin-top: 10px;\n margin-bottom: 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;;AAEA;IACI,kCAAkC;AACtC;;AAEA;IACI,SAAS;AACb;;AAEA;IACI,WAAW;IACX,YAAY;AAChB;;AAEA;IACI,SAAS;IACT,gBAAgB;AACpB;;AAEA;IACI,eAAe;IACf,iBAAiB;AACrB;;AAEA;IACI,gBAAgB;IAChB,mBAAmB;AACvB",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}\n\n.u2-app-header-bottom-line {\n border-bottom: solid 1px lightgrey;\n}\n\n.u2-app-header-with-name {\n gap: 60px;\n}\n\n.u2-app-header-with-name .ui-app-header-icon{\n width: 90px;\n height: 90px;\n}\n\n.u2-app-header-app-name-and-slogan-div {\n gap: 10px;\n margin-top: 10px;\n}\n\n.u2-app-header-app-name-div {\n font-size: 20px;\n font-weight: bold;\n}\n\n.u2-app-header-description {\n margin-top: 10px;\n margin-bottom: 10px;\n}"],sourceRoot:""}]);const s=r},542(e,t,n){"use strict";n.d(t,{A:()=>s});var i=n(354),o=n.n(i),a=n(314),r=n.n(a)()(o());r.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 s=r},314(e){"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map(function(t){var n="",i=void 0!==t[5];return t[4]&&(n+="@supports (".concat(t[4],") {")),t[2]&&(n+="@media ".concat(t[2]," {")),i&&(n+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),n+=e(t),i&&(n+="}"),t[2]&&(n+="}"),t[4]&&(n+="}"),n}).join("")},t.i=function(e,n,i,o,a){"string"==typeof e&&(e=[[null,e,void 0]]);var r={};if(i)for(var s=0;s<this.length;s++){var l=this[s][0];null!=l&&(r[l]=!0)}for(var c=0;c<e.length;c++){var d=[].concat(e[c]);i&&r[d[0]]||(void 0!==a&&(void 0===d[5]||(d[1]="@layer".concat(d[5].length>0?" ".concat(d[5]):""," {").concat(d[1],"}")),d[5]=a),n&&(d[2]?(d[1]="@media ".concat(d[2]," {").concat(d[1],"}"),d[2]=n):d[2]=n),o&&(d[4]?(d[1]="@supports (".concat(d[4],") {").concat(d[1],"}"),d[4]=o):d[4]="".concat(o)),t.push(d))}},t}},354(e){"use strict";e.exports=function(e){var t=e[1],n=e[3];if(!n)return t;if("function"==typeof btoa){var i=btoa(unescape(encodeURIComponent(JSON.stringify(n)))),o="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(i),a="/*# ".concat(o," */");return[t].concat([a]).join("\n")}return[t].join("\n")}},72(e){"use strict";var t=[];function n(e){for(var n=-1,i=0;i<t.length;i++)if(t[i].identifier===e){n=i;break}return n}function i(e,i){for(var a={},r=[],s=0;s<e.length;s++){var l=e[s],c=i.base?l[0]+i.base:l[0],d=a[c]||0,u="".concat(c," ").concat(d);a[c]=d+1;var p=n(u),m={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==p)t[p].references++,t[p].updater(m);else{var h=o(m,i);i.byIndex=s,t.splice(s,0,{identifier:u,updater:h,references:1})}r.push(u)}return r}function o(e,t){var n=t.domAPI(t);return n.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;n.update(e=t)}else n.remove()}}e.exports=function(e,o){var a=i(e=e||[],o=o||{});return function(e){e=e||[];for(var r=0;r<a.length;r++){var s=n(a[r]);t[s].references--}for(var l=i(e,o),c=0;c<a.length;c++){var d=n(a[c]);0===t[d].references&&(t[d].updater(),t.splice(d,1))}a=l}}},659(e){"use strict";var t={};e.exports=function(e,n){var i=function(e){if(void 0===t[e]){var n=document.querySelector(e);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(e){n=null}t[e]=n}return t[e]}(e);if(!i)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");i.appendChild(n)}},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,n){"use strict";e.exports=function(e){var t=n.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(n){!function(e,t,n){var i="";n.supports&&(i+="@supports (".concat(n.supports,") {")),n.media&&(i+="@media ".concat(n.media," {"));var o=void 0!==n.layer;o&&(i+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),i+=n.css,o&&(i+="}"),n.media&&(i+="}"),n.supports&&(i+="}");var a=n.sourceMap;a&&"undefined"!=typeof btoa&&(i+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(a))))," */")),t.styleTagTransform(i,e,t.options)}(t,e,n)},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 n(i){var o=t[i];if(void 0!==o)return o.exports;var a=t[i]={id:i,exports:{}};return e[i](a,a.exports,n),a.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.nc=void 0;var i={};(()=>{"use strict";n.r(i),n.d(i,{HTPackage:()=>Bn,PackageFunctions:()=>Pn,_package:()=>In,demoFileIngest:()=>vn,demoFileIngest1:()=>fn,demoFileIngest2:()=>gn,demoFileSubmit:()=>An,demoPeptideSequences:()=>yn,gasteigerCellRenderer:()=>bn,hitDesignApp:()=>un,hitDesignAppTreeBrowser:()=>ln,hitDesignVidPanel:()=>Cn,hitTriageApp:()=>dn,hitTriageAppTreeBrowser:()=>sn,htPackageSettingEditor:()=>En,initHT:()=>rn,pepTriageApp:()=>hn,pepTriageAppTreeBrowser:()=>mn,peptiHitApp:()=>pn,peptiHitAppTreeBrowser:()=>cn,registerMoleculesToViD:()=>wn});const e=grok,t=ui,o=DG,a="script",r="function-package",s="data-query",l="HTScript",c="HTQuery",d="molecules",u="campaignId",p="campaignId",m="enriched_table.csv",h="campaign.json",v="HitTriageDataSource",f="HitTriageSubmitFunction",g="Selected hits",y="Stage",A="Molecule",w="Helm",C="V-iD",b="HIT_DESIGN_VID",E="Source",T="New Template",x="Start",S="Create",N="Download",B="Cancel",I="Continue Campaign",F="New Campaign",P="No Information",O="HDCampaignsGrouping",_="HDCampaignTableColumns",k="HDCampaignsTableSorting";var L;!function(e){e.None="None",e.Template="Template",e.Status="Status",e.Author="Author",e.LastModifiedUser="Last Modified User"}(L||(L={}));const V={Name:e=>{var t;return null!==(t=e.friendlyName)&&void 0!==t?t:e.name},Code:e=>e.name,Created:e=>e.createDate,Author:e=>{var t;return null!==(t=e.authorUserFriendlyName)&&void 0!==t?t:""},"Last Modified by":e=>{var t;return null!==(t=e.lastModifiedUserName)&&void 0!==t?t:""},Molecules:e=>{var t;return(null!==(t=e.rowCount)&&void 0!==t?t:0).toString()},Status:e=>e.status},M="HTCampaignsGrouping",$="HTCampaignTableColumns",D="HTCampaignsTableSorting",R={Name:e=>{var t;return null!==(t=e.friendlyName)&&void 0!==t?t:e.name},Code:e=>e.name,Created:e=>e.createDate,Author:e=>{var t;return null!==(t=e.authorUserFriendlyName)&&void 0!==t?t:""},"Last Modified by":e=>{var t;return null!==(t=e.lastModifiedUserName)&&void 0!==t?t:""},Total:e=>{var t;return(null!==(t=e.rowCount)&&void 0!==t?t:0).toString()},Selected:e=>{var t;return(null!==(t=e.filteredRowCount)&&void 0!==t?t:0).toString()},Status:e=>e.status},U="pepTriageDataSource";var j=n(72),H=n.n(j),q=n(825),Y=n.n(q),G=n(659),W=n.n(G),z=n(56),J=n.n(z),Q=n(540),K=n.n(Q),Z=n(113),X=n.n(Z),ee=n(558),te={};function ne(e){var t,n,i;const o=null!==(t=localStorage.getItem(e))&&void 0!==t?t:"{}";try{const e=JSON.parse(o);return{order:null!==(n=null==e?void 0:e.order)&&void 0!==n?n:[],hidden:null!==(i=null==e?void 0:e.hidden)&&void 0!==i?i:[]}}catch(e){console.error("error parsing function ordering",e)}return{order:[],hidden:[]}}function ie(e){var t;try{return null===(t=e.package)||void 0===t?void 0:t.name}catch(e){return}}async function oe(e,t,n){if(0===n.rowCount)return;const i=e.col(t);if(!i)throw new Error("There is no molecule column in dataframe");let a=n.col(d);if(a||(await n.meta.detectSemanticTypes(),a=n.columns.bySemType(o.SEMTYPE.MOLECULE)),!a)throw new Error("There is no original molecule column in query result dataframe");const r=n.columns.names().filter(e=>(null==e?void 0:e.toLowerCase())!==d),s=r.filter(t=>{const i=e.col(t);return null!=i&&i.type===n.col(t).type});for(const t of r)!s.includes(t)&&e.col(t)&&e.columns.remove(t);if(s.length){const t=new Map;for(let e=0;e<a.length;e++){if(a.isNone(e))continue;const n=a.get(e);t.has(n)||t.set(n,e)}for(const o of s){const a=n.col(o),r=e.col(o);for(let e=0;e<i.length;e++){const n=i.isNone(e)?void 0:t.get(i.get(e));r.set(e,void 0===n||a.isNone(n)?null:a.get(n),!1)}}}const l=r.filter(e=>!s.includes(e));l.length&&e.join(n,[t],[a.name],void 0,l,void 0,!0)}te.styleTagTransform=X(),te.setAttributes=J(),te.insert=W().bind(null,"head"),te.domAPI=Y(),te.insertStyleElement=K(),H()(ee.A,te),ee.A&&ee.A.locals&&ee.A.locals;var ae=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{l(i.next(e))}catch(e){a(e)}}function s(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}l((i=i.apply(e,t||[])).next())})};const re=e=>`${e.getFullYear()}/${e.getMonth()+1}/${e.getDate()}`;function se(e,t){const n=document.title,i=window.location.href.split("?")[0]+"?"+e+"="+t;if(history.replaceState){const e={Title:n,Url:i};history.replaceState(e,e.Title,e.Url)}}function le(n,i,o,a){var r;const s=t.breadcrumbs([i,o]),l=s.onPathClick.subscribe(e=>{1===e.length&&(l.unsubscribe(),ce(n),a())}),c=null===(r=e.shell.v.ribbonMenu.root.parentElement)||void 0===r?void 0:r.getElementsByClassName("d4-ribbon-name")[0];return c&&(c.textContent="",c.appendChild(s.root)),{breadcrumbs:s,sub:l}}function ce(e){const t=e.getRibbonPanels();(null==t?void 0:t.length)&&(t.pop(),e.setRibbonPanels(t))}function de(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 ue(t,n){return ae(this,void 0,void 0,function*(){var i,a,r,s,l;try{const c=o.User.current().id,d=null===(i=o.User.current().group)||void 0===i?void 0:i.id;if(t===c)return!0;for(const t of n){const n=yield e.dapi.groups.find(t);if(n)if(n.personal){const t=yield e.dapi.groups.getUser(n);if((null==t?void 0:t.id)===c)return!0}else if(d){if((null!==(r=null===(a=n.members)||void 0===a?void 0:a.length)&&void 0!==r?r:0)>0&&n.members.some(e=>(null==e?void 0:e.id)===d))return!0;if((null!==(l=null===(s=n.adminMembers)||void 0===s?void 0:s.length)&&void 0!==l?l:0)>0&&n.adminMembers.some(e=>(null==e?void 0:e.id)===d))return!0}}}catch(e){In.logger.error(e)}return!1})}function pe(e,t){return ae(this,void 0,void 0,function*(){return ue(e,t.edit)})}function me(e,t){return ae(this,void 0,void 0,function*(){return ue(e,Array.from(new Set([...t.view,...t.edit])))})}function he(e){return localStorage.getItem(e)}function ve(e,t){localStorage.setItem(e,t)}function fe(e){ve(O,e)}function ge(e,t,n){if(!t)return;const i=null!=n?n:V,o=t.columnName in i?i[t.columnName]:e=>{var n,i,o;return null!==(o=null===(n=e.campaignFields)||void 0===n?void 0:n[null!==(i=t.columnName.replace("campaignFields.",""))&&void 0!==i?i:""])&&void 0!==o?o:""},a=new Map;e.forEach(e=>{a.set(e,o(e))});const r=Array.from(a.values()).every(e=>{var t;return Se(e)||!isNaN(Number(null!==(t=null==e?void 0:e.toString())&&void 0!==t?t:""))}),s=!r&&Array.from(a.values()).every(e=>{var t;return Se(e)||!isNaN(Date.parse(null!==(t=null==e?void 0:e.toString())&&void 0!==t?t:""))});r?e.forEach(e=>{a.set(e,Se(a.get(e))?t.ascending?1/0:-1/0:Number(a.get(e)))}):s&&e.forEach(e=>{var n,i;a.set(e,Se(a.get(e))?t.ascending?1/0:-1/0:Date.parse(null!==(i=null===(n=a.get(e))||void 0===n?void 0:n.toString())&&void 0!==i?i:""))}),e.sort((e,n)=>{const i=a.get(e),o=a.get(n);if(r||s)return t.ascending?i-o:o-i;const l=Se(i)?"":i.toString(),c=Se(o)?"":o.toString();return t.ascending?l.localeCompare(c):c.localeCompare(l)}),a.clear()}function ye(){const e=he(_),t=["Code","Created","Author","Last Modified by","Molecules","Status"];if(!e)return t;try{const n=JSON.parse(e);return Array.isArray(n)&&n.every(e=>"string"==typeof e)?n:t}catch(e){return console.error("error parsing campaign table columns",e),t}}function Ae(e){ve(_,JSON.stringify(e))}function we(e){ve(M,e)}function Ce(){const e=he($),t=["Created","Author","Total","Selected","Status"];if(!e)return t;try{const n=JSON.parse(e);return Array.isArray(n)&&n.every(e=>"string"==typeof e)?n:t}catch(e){return console.error("error parsing HT campaign table columns",e),t}}function be(e){ve($,JSON.stringify(e))}const Ee=(e,t)=>{var n,i,o,a,r,s;switch(e){case L.Template:return null!==(i=null===(n=t.template)||void 0===n?void 0:n.key)&&void 0!==i?i:t.templateName;case L.Status:return t.status;case L.Author:return null!==(o=t.authorUserFriendlyName)&&void 0!==o?o:P;case L.LastModifiedUser:return null!==(a=t.lastModifiedUserName)&&void 0!==a?a:P;default:if(e.startsWith("campaignFields.")){const n=e.replace("campaignFields.","");return null!==(s=null===(r=t.campaignFields)||void 0===r?void 0:r[n])&&void 0!==s?s:P}return""}};function Te(e,t){if(t===L.None)return{"":e};const n={};for(const i of e){const e=Ee(t,i);n[e]||(n[e]=[]),n[e].push(i)}return n}function xe(e,n,i=9){e.classList.add("hit-design-groupped-campaigns-table");const o=Object.keys(n);if(o.length<2)return e;const a=e.getElementsByTagName("tbody")[0],r=Array.from(e.getElementsByTagName("tr")).filter(e=>!e.classList.contains("header"));let s=0;const l=(e,t,n)=>{var i;for(let o=t;o<n;o++)(null===(i=r[o])||void 0===i?void 0:i.style)&&(r[o].style.display=e?"table-row":"none")};for(const e of o){const o=r[s];if(!o)break;const c=n[e].length,d=s,u=s+c,p=t.accordion(`Hit-Design-campaigns-group-${e}`).addPane(e,()=>t.div(),void 0,void 0,!1);p.root.style.marginLeft="-24px",p.root.onclick=()=>{l(p.expanded,d,u)},l(p.expanded,d,u);const m=a.insertRow(0),h=m.insertCell(0);h.appendChild(p.root),h.colSpan=i,a.insertBefore(m,o),s+=c}}function Se(e){return""===e||null==e||"number"==typeof e&&isNaN(e)}function Ne(e){return ae(this,void 0,void 0,function*(){return JSON.parse(yield In.files.readAsText(e))})}const Be={String:o.TYPE.STRING,Number:o.TYPE.FLOAT,Boolean:o.TYPE.BOOL,Date:o.TYPE.DATE_TIME,Molecule:o.SEMTYPE.MOLECULE};var Ie=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{l(i.next(e))}catch(e){a(e)}}function s(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}l((i=i.apply(e,t||[])).next())})};function Fe(n,i){return Ie(this,arguments,void 0,function*(n,i,a=v,r){var s,l,c;const d=t.divText("",{style:{color:"red"}});let u=null;const p=()=>Ie(this,void 0,void 0,function*(){try{if(u=m.value,!u)return;if(yield u.meta.detectSemanticTypes(),!u.columns.bySemType(o.SEMTYPE.MOLECULE))return void(d.innerText="No molecules column found");d.innerText=""}catch(e){d.innerText="Error parsing file"}}),m=t.input.table("Dataframe",{onValueChanged:p});yield p();const h=t.div([m,d]);0===Object.keys(i).length&&Array.from(new Set(o.Func.find({meta:{role:a}}).concat(o.Func.find({tags:[a]})))).forEach(e=>{var t;i[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e});let f=null;const g=()=>Ie(this,void 0,void 0,function*(){const e=i[A.value];f=e.prepare();const t=yield f.getEditor();t.classList.remove("ui-form"),y.innerHTML="",y.appendChild(t)}),y=t.div([]),A=t.input.choice(E,{value:null!==(s=n.queryFunctionName)&&void 0!==s?s:Object.keys(i)[0],items:Object.keys(i),onValueChanged:g});yield g(),n.queryFunctionName&&(null===(l=A.root.getElementsByTagName("select").item(0))||void 0===l||l.setAttribute("disabled","true"));const w=t.div([A,y]);w.style.display="none";const C=t.div([h,w]),b=t.input.string("Campaign Name",{value:"",nullable:!0});b.setTooltip("Optional friendly name for the campaign");const T=n.campaignFields.map(e=>e.type===o.SEMTYPE.MOLECULE?Object.assign(Object.assign({},e),{type:"String",semtype:o.SEMTYPE.MOLECULE}):e).map(e=>o.Property.fromOptions(Object.assign({name:e.name,type:Be[e.type],nullable:!e.required},e.semtype?{semType:e.semtype}:{}))),S={},N=T.length?t.input.form(S,T):t.div();N.classList.remove("ui-form"),"File"===n.dataSourceType?(h.style.display="inherit",w.style.display="none"):(h.style.display="none",w.style.display="inherit");const I=t.div([b.root,...null!==(c=null==r?void 0:r.extraFormElements)&&void 0!==c?c:[],C,...T.length?[N]:[]]),F=t.buttonsInput([]);I.appendChild(F);const P=new Promise(o=>{const a=()=>Ie(this,void 0,void 0,function*(){var t,a,s,l;if("File"===n.dataSourceType){if(!u)return void e.shell.error("No file selected");const n=u;n.name=u.name;const i=(null===(t=b.value)||void 0===t?void 0:t.trim())||void 0,s=null===(a=null==r?void 0:r.getExtraData)||void 0===a?void 0:a.call(r);o({df:n,type:"File",campaignProps:S,friendlyName:i,extraData:s})}else{const t=i[A.value];if(!t)return void e.shell.error("No function selected");const n={};Object.entries(f.inputs).forEach(([e,t])=>{n[e]=t});const a=yield t.apply(n),c=(null===(s=b.value)||void 0===s?void 0:s.trim())||void 0,d=null===(l=null==r?void 0:r.getExtraData)||void 0===l?void 0:l.call(r);o({df:a,type:"Query",campaignProps:S,friendlyName:c,extraData:d})}}),s=t.bigButton(x,()=>a());F.appendChild(s)});return{promise:P,root:I,cancelPromise:new Promise(e=>{t.button(B,()=>e())})}})}var Pe=n(233),Oe=n.n(Pe),_e=n(801),ke={};async function Le(e,n,i,d,u,p,m,h,v){var f,g,y,A,w,C,b,E,T,x,S,N,B,I,F,P,O,_,k,L,V,M,$;const D=null!=m?m:"HTFunctionOrderingLS",R=[];e.functions.filter(({inputs:e})=>e.length>=2&&"dataframe"===e[0].propertyType&&"column"===e[1].propertyType).forEach(e=>{var t,n,i,o;R.push({func:e,args:null!==(o=null===(i=null===(n=null===(t=null==d?void 0:d.compute)||void 0===t?void 0:t.functions)||void 0===n?void 0:n.find(t=>t.name===e.name&&t.package===e.package.name))||void 0===i?void 0:i.args)&&void 0!==o?o:{}})}),e.scripts.filter(({inputs:e})=>e.length>=2&&"dataframe"===e[0].propertyType&&"column"===e[1].propertyType).forEach(e=>{var t,n,i,o;R.push({func:e,args:null!==(o=null===(i=null===(n=null===(t=null==d?void 0:d.compute)||void 0===t?void 0:t.scripts)||void 0===n?void 0:n.find(t=>t.id===e.id))||void 0===i?void 0:i.args)&&void 0!==o?o:{}})}),e.queries.filter(e=>e.inputs.length>0&&"list"===e.inputs[0].propertyType).forEach(e=>{var t,n,i,o;R.push({func:e,args:null!==(o=null===(i=null===(n=null===(t=null==d?void 0:d.compute)||void 0===t?void 0:t.queries)||void 0===n?void 0:n.find(t=>t.id===e.id))||void 0===i?void 0:i.args)&&void 0!==o?o:{}})});const U=t.div([],{classes:"statistics-compute-dialog-host"}),j=[],H=t.tree(),q=t.wait(async()=>{var e,n,i;try{if(!p)return t.divText("No descriptors provider configured");const o=await p();function a(e,t){const n=t.group(e,null,!1);return n.enableCheckBox(!1),n}H.root.classList.add("statistics-compute-dialog-descriptors-group");const r=Object.keys(o),s=null!==(i=null===(n=null===(e=null==d?void 0:d.compute)||void 0===e?void 0:e.descriptors)||void 0===n?void 0:n.args)&&void 0!==i?i:[];for(const l of r){const c=a(l,H);for(const u of o[l].descriptors){const m=c.item(u.name,u);j.push(m),m.enableCheckBox(s.includes(u.name))}}return H.root}catch(h){console.error(h)}return t.divText("Failed to load descriptors")});q.classList.add("oy-scroll");const Y="Descriptors",G={[Y]:Y},W={[Y]:q},z={},J={[Y]:!1};J[Y]=!!(null===(g=null===(f=null==d?void 0:d.compute)||void 0===f?void 0:f.descriptors)||void 0===g?void 0:g.enabled)&&(null===(w=null===(A=null===(y=null==d?void 0:d.compute)||void 0===y?void 0:y.descriptors)||void 0===A?void 0:A.args)||void 0===w?void 0:w.length)>0;const Q={};function K(e,n){if(!v||e===Y)return n;const i=t.input.bool(v.label,{value:!!Q[e],onValueChanged:t=>{Q[e]=!!t}});return i.setTooltip(v.tooltip),i.root.classList.add("statistics-compute-dialog-rerun-input"),t.divV([i.root,n])}for(const e of R)try{const n=e.func,i=n.prepare(e.args),o=n.type===r?`${n.package.name}:${n.name}`:n.type===a?`${l}:${null!==(C=n.name)&&void 0!==C?C:""}:${n.id}`:`${c}:${null!==(b=n.name)&&void 0!==b?b:""}:${n.id}`;z[o]=i;const u=t.div();t.setUpdateIndicator(u,!0),i.buildEditor(u,{condensed:!1}).then(t=>{var i,o;(null===(i=null==t?void 0:t[0])||void 0===i?void 0:i.root)&&(t[0].root.style.display="none"),(null===(o=null==t?void 0:t[1])||void 0===o?void 0:o.root)&&n.type!==s&&(t[1].root.style.display="none"),t.forEach(t=>{var n,i;(null===(n=t.property)||void 0===n?void 0:n.name)&&Object.keys(e.args).includes(null===(i=t.property)||void 0===i?void 0:i.name)&&(t.value=e.args[t.property.name]),t.fireChanged()})}).catch(e=>{console.error(e),t.setUpdateIndicator(u,!1),u.appendChild(t.divText("Failed to build function editor"))}).finally(()=>t.setUpdateIndicator(u,!1)),u.classList.add("oy-scroll"),u.style.marginLeft="15px",u.style.removeProperty("max-width"),W[null!==(E=n.friendlyName)&&void 0!==E?E:n.name]=K(o,u),G[null!==(T=n.friendlyName)&&void 0!==T?T:n.name]=o,J[o]=null!==(P=(null===(S=null===(x=null==d?void 0:d.compute)||void 0===x?void 0:x.functions)||void 0===S?void 0:S.some(t=>e.func.type===r&&t.name===e.func.name&&t.package===ie(e.func)))||(null===(B=null===(N=null==d?void 0:d.compute)||void 0===N?void 0:N.scripts)||void 0===B?void 0:B.some(e=>e.id===n.id))||(null===(F=null===(I=null==d?void 0:d.compute)||void 0===I?void 0:I.queries)||void 0===F?void 0:F.some(e=>e.id===n.id)))&&void 0!==P&&P,Q[o]=null!==($=(null===(_=null===(O=null==d?void 0:d.compute)||void 0===O?void 0:O.functions)||void 0===_?void 0:_.some(e=>`${e.package}:${e.name}`===o&&e.rerunOnOpen))||(null===(L=null===(k=null==d?void 0:d.compute)||void 0===k?void 0:k.scripts)||void 0===L?void 0:L.some(e=>`${l}:${e.name}:${e.id}`===o&&e.rerunOnOpen))||(null===(M=null===(V=null==d?void 0:d.compute)||void 0===V?void 0:V.queries)||void 0===M?void 0:M.some(e=>`${c}:${e.name}:${e.id}`===o&&e.rerunOnOpen)))&&void 0!==$&&$}catch(e){console.error(e);continue}const Z=t.tabControl(W,!0);Z.onTabChanged.subscribe(()=>{try{Z.currentPane.content.style.removeProperty("max-width")}catch(e){}}),Z.header.style.overflow="scroll",Z.root.style.width="100%",Z.root.style.minWidth="350px",U.appendChild(Z.root);let X=[];function ee(e){var n,i;Z.clear();let o=null!==(n=e.order)&&void 0!==n?n:Object.keys(W);0===o.length&&(o=Object.keys(W)),o.forEach(e=>{W[e]&&Z.addPane(e,()=>W[e])}),Object.keys(W).forEach(t=>{var n;o.includes(t)||!W[t]||(null!==(n=e.hidden)&&void 0!==n?n:[]).includes(t)||Z.addPane(t,()=>W[t])}),(null!==(i=e.hidden)&&void 0!==i?i:[]).forEach(e=>{J[G[e]]=!1}),X=[],Z.panes.forEach(e=>{const n=G[e.name],i=!!J[n],o=t=>{var i,o;if(h&&t)for(let e=0;e<X.length;e++)G[Z.panes[e].name]!==n&&(X[e].value=null),J[G[Z.panes[e].name]]=!1;J[n]=t,t?null===(o=Oe()(e.content).find("input"))||void 0===o||o.removeAttr("disabled"):null===(i=Oe()(e.content).find("input"))||void 0===i||i.attr("disabled","true")},a=h?t.input.radio("",{items:[""],value:i?"":void 0,onValueChanged:e=>o(""===e)}):t.input.bool("",{value:i,onValueChanged:e=>o(!!e)});a.setTooltip("Toggle calculation of this function"),X.push(a),e.header.appendChild(a.root),e.header.classList.add("statistics-compute-dialog-pane-header")}),Z.panes.length>0&&(Z.currentPane=Z.panes[0])}function te(){const e={descriptors:[],externals:{},scripts:{},queries:{}};v&&(e.rerunOnOpen={},Object.keys(Q).forEach(t=>{J[t]&&Q[t]&&(e.rerunOnOpen[t]=!0)})),e.descriptors=J[Y]?j.filter(e=>e.checked).map(e=>e.value.name):[];const t=Object.entries(z).filter(([e,t])=>J[e]);t.filter(([e,t])=>!e.startsWith(l)&&!e.startsWith(c)).forEach(([t,n])=>{e.externals[t]={};const i=n.inputs;Object.entries(i).slice(2).forEach(([n,i])=>{e.externals[t][n]=i})}),t.filter(([e,t])=>e.startsWith(l)).forEach(([t,n])=>{e.scripts[t]={};const i=n.inputs;Object.entries(i).slice(2).forEach(([n,i])=>{e.scripts[t][n]=i})}),t.filter(([e,t])=>e.startsWith(c)).forEach(([t,n])=>{e.queries[t]={};const i=n.inputs;Object.entries(i).slice(1).forEach(([n,i])=>{e.queries[t][n]=i})}),console.log(e),n(e)}return ee(ne(D)),Z.root.appendChild(function(e,n,i){var a;const r=ne(i),s=o.DataFrame.fromColumns(e.map(e=>o.Column.fromStrings(e,[e])));s.columns.setOrder(null!==(a=r.order)&&void 0!==a?a:[]);const l=t.input.columns("reorder",{table:s,value:s.columns.toList().filter(e=>!r.hidden.includes(e.name))});l.onChanged.subscribe(()=>{try{const t=l.value.map(e=>e.name),o=e.filter(e=>!t.includes(e)),a={order:l.value.map(e=>e.name),hidden:o};s.columns.setOrder(a.order),function(e,t){localStorage.setItem(t,JSON.stringify(e))}(a,i),n(a)}catch(e){console.error(e)}});const c=Array.from(l.root.children);setTimeout(()=>{c.forEach(e=>{e.style.maxWidth="0px",e.style.overflow="hidden",e.style.padding="0px",e.style.paddingRight="0px",e.style.visibility="hidden",e instanceof HTMLLabelElement&&(e.style.display="none")})},200),l.root.style.justifyContent="end",l.root.style.width="40px",l.root.style.height="0px",l.root.style.overflow="visible",l.root.style.padding="0px";const d=t.icons.edit(()=>{c.forEach(e=>{e.click()})},"Order or hide functions");return l.addOptions(d),Array.from(l.root.children).forEach(e=>{e.style.borderBottom="unset"}),d.style.fontSize="16px",l.root}(Object.keys(W),e=>{ee(e)},D)),u&&t.dialog("Compute").add(U).onOK(()=>te()).onCancel(i).show({resizable:!0}),{root:U,okProxy:te}}ke.styleTagTransform=X(),ke.setAttributes=J(),ke.insert=W().bind(null,"head"),ke.domAPI=Y(),ke.insertStyleElement=K(),H()(_e.A,ke),_e.A&&_e.A.locals&&_e.A.locals;function Ve(t,n,i,o,a,r){return s=this,l=void 0,d=function*(){return Le(t.computeFunctions,n,i,o,a,()=>e.chem.descriptorsTree(),"HTFunctionOrderingLS",void 0,r?{label:"Re-run when campaign opens",tooltip:"Recompute this function for the whole molecule column every time this campaign is opened. Useful for database lookups that may resolve after the molecule was first drawn."}:void 0)},new((c=void 0)||(c=Promise))(function(e,t){function n(e){try{o(d.next(e))}catch(e){t(e)}}function i(e){try{o(d.throw(e))}catch(e){t(e)}}function o(t){var o;t.done?e(t.value):(o=t.value,o instanceof c?o:new c(function(e){e(o)})).then(n,i)}o((d=d.apply(s,l||[])).next())});var s,l,c,d}const Me=rxjs;class $e{constructor(e,n=[],i={}){this.onItemChanged=new Me.Subject,this.onAddingItemChanged=new Me.Subject,this.onItemAdded=new Me.Subject,this.onItemRemoved=new Me.Subject,this.options={removeButtonTooltip:"Remove item",addButtonTooltip:"Add item",allowAdd:!0,allowRemove:!0},this.addingItemInputs={},this.properties=e,this.options=Object.assign(Object.assign({},this.options),i),this._root=t.divV([],{style:{display:"grid",gridTemplateColumns:`repeat(${this.properties.length}, 1fr)`,alignItems:"center",gap:"12px"},classes:"ui-items-grid"}),this._items=n,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 n=this._items.splice(e,1);this.render(),t&&this.onItemRemoved.next(n[0])}removeAllItems(){this._items=[],this.render()}render(){var e,n,i,o,a;if(t.empty(this._root),!this.options.horizontalInputNames)for(const i of this.properties){let o=null!==(e=i.caption)&&void 0!==e?e:i.name;(null===(n=this.options.customLabels)||void 0===n?void 0:n[i.name])&&(o=this.options.customLabels[i.name]);const a=t.divText(o);a.style.fontWeight="bold",this._root.appendChild(a)}for(const e of this._items){const t=this.getItemDiv(e);for(const e of t)this._root.appendChild(e)}if(this.options.allowAdd){const e=this.getItemDiv(null!==(a=null===(o=(i=this.options).newItemFunction)||void 0===o?void 0:o.call(i))&&void 0!==a?a:void 0,!0);for(const t of e)this._root.appendChild(t)}}get addingItem(){const e={};return Object.keys(this.addingItemInputs).forEach(t=>{e[t]=this.addingItemInputs[t].value}),e}getItemDiv(e={},n){var i,a;const r=[],s={};let l=null;for(const c of this.properties){void 0===e[c.name]&&(e[c.name]=null);const d=(null===(i=this.options.customInputs)||void 0===i?void 0:i[c.name])?this.options.customInputs[c.name](e):t.input.forProperty(c,e),u=null===(a=this.options.validators)||void 0===a?void 0:a[c.name];u&&d.addValidator(u),r.push(this.options.horizontalInputNames?d.root:this.hideLabel(d.root)),c.propertyType!==o.TYPE.BOOL&&"color"!==c.name.toLowerCase()&&d.input&&(d.input.style.width="100%"),s[c.name]=d,d.onChanged.subscribe(()=>{e[c.name]=d.value,n?this.onAddingItemChanged.next({item:e,fieldName:c.name}):this.onItemChanged.next({item:e,fieldName:c.name})}),d.root.style.alignItems="center",l=d}let c=null;if(n)this.addingItemInputs=s,c=t.icons.add(()=>{const e=this.options.newItemFunction?this.options.newItemFunction():{};Object.keys(s).forEach(t=>{e[t]=s[t].value}),this._items.push(e),this.onItemAdded.next(e),this.render()},this.options.addButtonTooltip);else{if(!this.options.allowRemove)return r;c=t.icons.delete(()=>{this._items.splice(this._items.indexOf(e),1),this.onItemRemoved.next(e),this.render()},this.options.removeButtonTooltip)}return l&&l.addOptions?l.addOptions(c):null==l||l.root.appendChild(c),c.style.color="#2083d5",r}hideLabel(e){return e.getElementsByTagName("label")[0]&&e.removeChild(e.getElementsByTagName("label")[0]),e}hasErrors(){return this._root.querySelectorAll(".d4-invalid").length>0}}function De(){const n=o.Property.fromOptions({name:"layout",caption:"Layout",type:"file"}),i=o.InputBase.forProperty(n);let a=null,r=null,s=null,l=null;return i.onChanged.subscribe(t=>{return n=this,c=void 0,u=function*(){const t=i.value;if(t){try{const n=!!t.fullPath&&(yield e.dapi.files.exists(t.fullPath));s=n?t.fullPath:null}catch(e){s=null}try{const e=yield t.readAsString(),n=o.ViewLayout.fromJson(e);n?(a=n,r=n.viewState,l=null):(a=null,r=null,s=null,l="Invalid layout file")}catch(e){a=null,r=null,s=null,l="Invalid layout file"}i.input.classList[l?"add":"remove"]("d4-invalid")}else a=null,r=null,s=null},new((d=void 0)||(d=Promise))(function(e,t){function i(e){try{a(u.next(e))}catch(e){t(e)}}function o(e){try{a(u.throw(e))}catch(e){t(e)}}function a(t){var n;t.done?e(t.value):(n=t.value,n instanceof d?n:new d(function(e){e(n)})).then(i,o)}a((u=u.apply(n,c||[])).next())});var n,c,d,u}),t.tooltip.bind(i.root,()=>l||"Select a layout file"),{dataFileInput:i,getLayout:()=>a,getLayoutViewState:()=>r,getLocalFilePath:()=>s}}var Re=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{l(i.next(e))}catch(e){a(e)}}function s(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}l((i=i.apply(e,t||[])).next())})};function Ue(n,i,a){return Re(this,void 0,void 0,function*(){var r,s,d;const u=(yield In.files.list("Hit Triage/templates")).map(e=>e.name.slice(0,-5)),p=[];for(const e of u){const t=yield Ne(`Hit Triage/templates/${e}.json`);p.push(t.key)}const m=Array.from(new Set(o.Func.find({meta:{role:f}}).concat(o.Func.find({tags:[f]})))),h={};m.forEach(e=>{var t;h[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e});const g=(null==a?void 0:a.submit)?Object.keys(h).find(e=>{var t,n;return(null===(t=h[e])||void 0===t?void 0:t.name)===(null===(n=a.submit)||void 0===n?void 0:n.fName)}):null,y=t.input.choice("Submit function",{value:null!=g?g:null,items:[null,...Object.keys(h)]});g||(y.value=null),y.nullable=!0,y.fireChanged(),y.setTooltip("Select function to be called upon submitting");const A=De(),w=t.divText("Template name is empty or already exists",{classes:"hit-triage-error-div"}),C=t.divText("Template key is empty or already exists",{classes:"hit-triage-error-div"}),b=t.input.string("Name",{value:a?`${a.name} (copy)`:"",onValueChanged:e=>{""===e||u.includes(e)?(b.root.style.borderBottom="1px solid red",w.style.opacity="100%"):(b.root.style.borderBottom="none",w.style.opacity="0%")}}),T=t.input.string("Key",{value:a?`${a.key}-copy`:"",onValueChanged:e=>{""===e||p.includes(e)?(T.root.style.borderBottom="1px solid red",C.style.opacity="100%"):(T.root.style.borderBottom="none",C.style.opacity="0%")}});T.setTooltip("Template key used for campaign prefix"),b.setTooltip("Template name"),b.root.style.borderBottom="none",T.root.style.borderBottom="none",w.style.opacity="0%",C.style.opacity="0%";let x=null;const N=a||{compute:{descriptors:{enabled:!0,args:[]},functions:[]}},I=yield Ve(n,e=>{x=e},()=>null,N,!1);I.root.classList.add("hit-triage-new-template-functions-input"),0===Object.entries(i).length&&Array.from(new Set(o.Func.find({meta:{role:v}}).concat(o.Func.find({tags:[v]})))).forEach(e=>{var t;i[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e});const F=Object.keys(i),P=t.input.choice(E,{value:F[0],items:F}),O=t.input.choice("Ingest using",{value:null!==(r=null==a?void 0:a.dataSourceType)&&void 0!==r?r:"Query",items:["Query","File"],onValueChanged:e=>{P.root.style.display="Query"===e?"block":"none"}});(null==a?void 0:a.dataSourceType)&&(P.root.style.display="Query"===a.dataSourceType?"block":"none");const _=je(null==a?void 0:a.campaignFields),k=t.div([t.h2("Details"),t.div([b,w]),t.div([T,C]),O.root,P.root,A.dataFileInput,_.fieldsDiv,t.h2("Compute"),I.root,t.h2("Submit"),y.root],"ui-form"),L=t.buttonsInput([]),V=null!==(d=null===(s=L.getElementsByClassName("ui-input-editor"))||void 0===s?void 0:s[0])&&void 0!==d?d:L;k.appendChild(L);const M=new Promise(e=>{const n=t.button(B,()=>e());V.appendChild(n)}),$=new Promise(n=>{const i=t.bigButton(S,()=>function(){return Re(this,void 0,void 0,function*(){var t,i,o,a,r,s,d,u;if(I.okProxy(),"100%"===w.style.opacity)return void e.shell.error("Template name is empty or already exists");const p=y.value?h[y.value]:void 0,m=Object.assign(Object.assign({name:b.value,key:T.value,campaignFields:_.getFields(),dataSourceType:null!==(t=O.value)&&void 0!==t?t:"Query",layoutViewState:null!==(i=A.getLayoutViewState())&&void 0!==i?i:void 0,compute:{descriptors:{enabled:!!(null===(o=null==x?void 0:x.descriptors)||void 0===o?void 0:o.length),args:null!==(a=null==x?void 0:x.descriptors)&&void 0!==a?a:[]},functions:Object.entries(null!==(r=null==x?void 0:x.externals)&&void 0!==r?r:{}).map(([e,t])=>{const n=e.split(":");return{name:n[1],package:n[0],args:t}}),scripts:Object.entries(null!==(s=null==x?void 0:x.scripts)&&void 0!==s?s:{}).filter(([e,t])=>e.startsWith(l)&&3===e.split(":").length).map(([e,t])=>{var n,i;const o=e.split(":");return{name:null!==(n=o[1])&&void 0!==n?n:"",id:null!==(i=o[2])&&void 0!==i?i:"",args:t}}),queries:Object.entries(null!==(d=null==x?void 0:x.queries)&&void 0!==d?d:{}).filter(([e,t])=>e.startsWith(c)&&3===e.split(":").length).map(([e,t])=>{var n,i;const o=e.split(":");return{name:null!==(n=o[1])&&void 0!==n?n:"",id:null!==(i=o[2])&&void 0!==i?i:"",args:t}})}},p?{submit:{fName:p.name,package:ie(p)}}:{}),{queryFunctionName:"Query"===O.value&&null!==(u=P.value)&&void 0!==u?u:void 0});var v;v=m,In.files.writeAsText(`Hit Triage/templates/${v.name}.json`,JSON.stringify(v)),e.shell.info("Template created successfully"),n(m)})}());V.appendChild(i)});return{root:k,template:$,cancelPromise:M}})}function je(e){const n=[o.Property.fromOptions({name:"Name",type:o.TYPE.STRING}),o.Property.fromOptions({name:"Type",type:o.TYPE.STRING,choices:Object.keys(Be)}),o.Property.fromOptions({name:"Required",type:o.TYPE.BOOL})],i=new $e(n,e?e.map(e=>({Name:e.name,Type:e.type,Required:e.required})):void 0,{horizontalInputNames:!1});i.root.style.maxWidth="750px";let a={};i.onItemAdded.subscribe(e=>{a={}}),i.onAddingItemChanged.subscribe(e=>{e&&(a=e.item)});const r=t.h2("Additional fields");t.tooltip.bind(r,"Additional fields to be filled by user for each campaign");const s=t.div([r,i.root]);return{getFields:function(){var e;const t=i.items.filter(e=>e.Name).map(e=>{var t;return{name:e.Name,type:e.Type,required:null!==(t=e.Required)&&void 0!==t&&t}});return a.Name&&""!==a.Name&&a.Type&&(null!==(e=a.Required)&&void 0!==e||(a.Required=!1),t.push({name:a.Name,type:a.Type,required:a.Required})),t},fieldsDiv:t.div([s])}}var He=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{l(i.next(e))}catch(e){a(e)}}function s(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}l((i=i.apply(e,t||[])).next())})};class qe extends o.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 In.files.delete(`${e}/campaigns/${t}`)})}}var Ye=n(677),Ge={};Ge.styleTagTransform=X(),Ge.setAttributes=J(),Ge.insert=W().bind(null,"head"),Ge.domAPI=Y(),Ge.insertStyleElement=K(),H()(Ye.A,Ge),Ye.A&&Ye.A.locals&&Ye.A.locals;var We;!function(n){let i,o;!function(e){e.vert=function(e){return t.divV(e.map(e=>t.render(e)),{classes:"u2-panel"})},e.horz=function(e){return t.divH(e.map(e=>t.render(e)),{classes:"u2-panel"})}}(i=n.panels||(n.panels={})),n.appHeader=function(e){const n=t.iconImage("",e.iconPath);Oe()(n).addClass("ui-app-header-icon").css("margin-right","20px"),e.iconSize&&(n.style.width=`${e.iconSize}px`,n.style.height=`${e.iconSize}px`);const o=i.horz([]);if(e.appTitle){o.classList.add("u2-app-header-with-name");const i=t.divV([t.divText(e.appTitle,"u2-app-header-app-name-div")],"u2-app-header-app-name-and-slogan-div");e.appSubTitle&&i.append(t.divText(e.appSubTitle));const a=t.div(n);o.append(t.divH([a,i]))}else o.append(n);const a=i.vert([t.markdown(e.description),e.learnMoreUrl?t.link("Learn more",e.learnMoreUrl,void 0,{style:{marginLeft:"15px"}}):null]);return a.classList.add("u2-app-header-description"),o.append(a),e.bottomLine&&o.classList.add("u2-app-header-bottom-line"),o},function(n){n.runAsync=function(n,i){return o=this,a=void 0,s=function*(){t.setUpdateIndicator(n,!0);try{return yield i()}catch(t){e.log.error(t)}finally{t.setUpdateIndicator(n,!1)}},new((r=void 0)||(r=Promise))(function(e,t){function n(e){try{l(s.next(e))}catch(e){t(e)}}function i(e){try{l(s.throw(e))}catch(e){t(e)}}function l(t){var o;t.done?e(t.value):(o=t.value,o instanceof r?o:new r(function(e){e(o)})).then(n,i)}l((s=s.apply(o,a||[])).next())});var o,a,r,s}}(o=n.tools||(n.tools={}))}(We||(We={}));var ze=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{l(i.next(e))}catch(e){a(e)}}function s(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}l((i=i.apply(e,t||[])).next())})};const Je={view:[o.Group.defaultGroupsIds["All users"]],edit:[o.Group.defaultGroupsIds["All users"]]};class Qe{constructor(e){this.permissions=null!=e?e:Je,this.editGroupsInput=t.input.userGroups("Can Edit"),this.editGroupsInput.root.style.marginBottom="16px",this.viewGroupsInput=t.input.userGroups("Can View")}getDialogContent(){return ze(this,void 0,void 0,function*(){const n=[],i=[];for(const t of this.permissions.view){const i=yield e.dapi.groups.find(t);i&&n.push(i)}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=n,t.divV([this.viewGroupsInput.root,this.editGroupsInput.root])})}show(e){return ze(this,void 0,void 0,function*(){var n;const i=yield this.getDialogContent(),o=t.dialog("Edit Permissions").add(i).onOK(()=>{const t=new Set(this.editGroupsInput.value.map(e=>e.id)),n=new Set(this.viewGroupsInput.value.map(e=>e.id));this.permissions.edit=Array.from(t),t.forEach(e=>n.add(e)),this.permissions.view=Array.from(n),0===this.permissions.view.length&&(this.permissions.view=Je.view),e(this.permissions)});(null===(n=i.parentElement)||void 0===n?void 0:n.style)&&(i.parentElement.style.overflow="visible"),o.show()})}}var Ke=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{l(i.next(e))}catch(e){a(e)}}function s(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}l((i=i.apply(e,t||[])).next())})};class Ze extends qe{constructor(n){super(n),this.readmePath=In.webRoot+"README_HT.md",this.dataSourceFunctionsMap={},this.currentGroupping="None",this._appHeader=null,this._contentRoot=t.div([],{classes:"hit-triage-info-view-container"}),this.campaignsTableRoot=null,this.name="Hit Triage",this._appHeader=this.getAppHeader(),this.root.appendChild(t.div([this._appHeader],{style:{marginLeft:"10px"}})),this.root.appendChild(this._contentRoot),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)}refreshCampaignsTable(){return Ke(this,void 0,void 0,function*(){if(null!=this.campaignsTableRoot){t.setUpdateIndicator(this.campaignsTableRoot,!0);try{const e=yield this.getCampaignsTable();t.setUpdateIndicator(this.campaignsTableRoot,!1),t.empty(this.campaignsTableRoot),this.campaignsTableRoot.appendChild(e)}catch(t){e.shell.error("Failed to update campaigns table"),console.error(t)}finally{t.setUpdateIndicator(this.campaignsTableRoot,!1)}}})}getAppHeader(){return We.appHeader({iconPath:In.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 "})}getTemplatesFolder(){return`${this.app.appName}/templates`}getDataSourceTag(){return v}getDataSourceFunctionsMap(){return this.dataSourceFunctionsMap}init(e){return Ke(this,void 0,void 0,function*(){t.setUpdateIndicator(this.root,!0);try{const n=t.h1(I),i=t.h1(F,{style:{marginLeft:"10px"}}),a=t.div(),r=t.div([],{classes:"ui-form"}),s=yield this.getCampaignsTable();this.campaignsTableRoot=t.div([s],{style:{position:"relative"}});const l=t.iconFA("layer-group",()=>Ke(this,void 0,void 0,function*(){const e=o.Menu.popup();Object.values(L).forEach(t=>{e.item(t,()=>Ke(this,void 0,void 0,function*(){we(t),yield this.refreshCampaignsTable()}))});const t=e.group("Campaign Fields"),n=yield In.loadCampaigns(this.app.appName,this.deletedCampaigns),i=new Set;Object.values(n).forEach(e=>{e.campaignFields&&Object.keys(e.campaignFields).forEach(e=>i.add(e))}),Array.from(i).forEach(e=>{t.item(e,()=>Ke(this,void 0,void 0,function*(){we(`campaignFields.${e}`),yield this.refreshCampaignsTable()}))}),e.show({element:u,x:120,y:u.offsetTop+30})}),"Group by");l.style.marginBottom="9px",l.style.marginLeft="8px",l.style.fontSize="15px",l.style.color="var(--blue-1)",t.tooltip.bind(l,()=>`Group Campaigns. Current: ${this.currentGroupping}`);const c=t.iconFA("eye",()=>Ke(this,void 0,void 0,function*(){const e=o.Menu.popup(),t=yield In.loadCampaigns(this.app.appName,this.deletedCampaigns),n=Object.assign({},R);delete n.Name,Object.values(t).forEach(e=>{e.campaignFields&&Object.keys(e.campaignFields).forEach(e=>{n[`campaignFields.${e}`]=t=>{var n,i;return null!==(i=null===(n=t.campaignFields)||void 0===n?void 0:n[e])&&void 0!==i?i:""}})});const i=Ce().reduce((e,t)=>(e[t]=!0,e),{});Object.keys(n).filter(e=>!e.startsWith("campaignFields.")).forEach(t=>{var n;e.item(t,()=>{i[t]=!i[t],be(Object.keys(i).filter(e=>i[e])),this.refreshCampaignsTable()},null,{check:null!==(n=i[t])&&void 0!==n&&n})});const a=e.group("Campaign Fields");Object.keys(n).filter(e=>e.startsWith("campaignFields.")).forEach(e=>{var t;a.item(e.replace("campaignFields.",""),()=>{i[e]=!i[e],be(Object.keys(i).filter(e=>i[e])),this.refreshCampaignsTable()},null,{check:null!==(t=i[e])&&void 0!==t&&t})}),e.show({element:u,x:100,y:u.offsetTop+30})}),"View");t.tooltip.bind(c,"Edit visible columns in campaigns table"),c.style.marginBottom="9px",c.style.marginLeft="8px",c.style.fontSize="15px",c.style.color="var(--blue-1)";const d=t.iconFA("sync",()=>Ke(this,void 0,void 0,function*(){yield this.refreshCampaignsTable()}),"Refresh");d.style.marginBottom="9px",d.style.marginLeft="8px",d.style.color="var(--blue-1)",t.tooltip.bind(d,()=>"Refresh campaigns table");const u=t.divH([n,c,l,d],{style:{alignItems:"center"}});yield this.startNewCampaign(a,r,e),Oe()(this._contentRoot).empty(),this._contentRoot.appendChild(t.divV([u],{style:{marginLeft:"10px"}})),this._contentRoot.appendChild(this.campaignsTableRoot),this._contentRoot.appendChild(i),this._contentRoot.appendChild(r),this._contentRoot.appendChild(a)}catch(e){throw t.setUpdateIndicator(this.root,!1),e}finally{t.setUpdateIndicator(this.root,!1)}})}startNewCampaign(n,i,o){return Ke(this,void 0,void 0,function*(){var a;const r=(yield In.files.list(this.getTemplatesFolder())).filter(e=>e.name.endsWith(".json")).map(e=>e.name.slice(0,-5));o&&!r.includes(o.name)&&r.push(o.name);let s=null,l=!0;const c=()=>Ke(this,void 0,void 0,function*(){if(!l)return;const e=d.value,t=o&&o.name===e?o:yield Ne(this.getTemplatesFolder()+"/"+e+".json");s=t;const i=yield this.getNewCampaignAccordeon(t,n);Oe()(n).empty(),n.className="ui-form",n.appendChild(i)}),d=t.input.choice("Template",{value:null!==(a=null==o?void 0:o.name)&&void 0!==a?a:r[0],items:r,onValueChanged:()=>Ke(this,void 0,void 0,function*(){yield c()})});d.root.style.width="100%";const u=t.icons.add(()=>Ke(this,void 0,void 0,function*(){t.setUpdateIndicator(this.root,!0),yield this.createNewTemplate(),t.setUpdateIndicator(this.root,!1)}),T),p=t.icons.copy(()=>{s&&this.createNewTemplate(s)},"Clone template"),m=t.icons.delete(()=>{!d.value||d.items.length<2||t.dialog("Delete template").add(t.divText(`Are you sure you want to delete template ${d.value}?`)).onOK(()=>Ke(this,void 0,void 0,function*(){try{const t=d.value;yield In.files.delete(`${this.getTemplatesFolder()}/${t}.json`),l=!1,d.items=d.items.filter(e=>e!==t),d.value=d.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 "+d.value),console.error(t)}})).show()},"Delete template");m.style.color="var(--blue-1)",u.style.color="#2083d5",d.addOptions(u),d.addOptions(p),d.addOptions(m),yield c(),Oe()(i).empty(),i.appendChild(d.root)})}checkCampaign(e){return Ke(this,void 0,void 0,function*(){const t=location.search,n=new URLSearchParams(t);if(!n.has(u)&&!e)return;const i=null!=e?e:n.get(u);if(!(yield In.files.exists(`${this.app.appName}/campaigns/${i}/${h}`)))return;const o=JSON.parse(yield In.files.readAsText(`${this.app.appName}/campaigns/${i}/${h}`));if(o){if(o.authorUserId&&o.permissions&&!(yield me(o.authorUserId,o.permissions)))return void this.app.setBaseUrl();this.app.campaign=o}const a=yield Ne(`${this.getTemplatesFolder()}/${o.templateName}.json`);return this.app.setTemplate(a,o.filters,i,o.ingest),e&&se(u,e),o})}getCampaignsTable(){return Ke(this,void 0,void 0,function*(){const n=yield In.loadCampaigns(this.app.appName,this.deletedCampaigns),i=null!==(a=he(M))&&void 0!==a?a:L.None;var a;const r=function(){const e=he(D);return e?JSON.parse(e):null}(),s=Object.values(n);r&&ge(s,r,R);const l=Te(s,i),c=Ce();this.currentGroupping=i;const d=n=>{var i,a;const r=t.icons.delete(()=>Ke(this,void 0,void 0,function*(){var e;t.dialog("Delete campaign").add(t.divText(`Are you sure you want to delete campaign ${null!==(e=n.friendlyName)&&void 0!==e?e:n.name}?`)).onOK(()=>Ke(this,void 0,void 0,function*(){yield this.deleteCampaign(this.app.appName,n.name),this.deletedCampaigns.push(n.name),yield this.init()})).show()}),"Delete campaign"),s=t.iconFA("share",()=>Ke(this,void 0,void 0,function*(){yield new Qe(n.permissions).show(t=>Ke(this,void 0,void 0,function*(){var i,o,a;try{n.permissions=t,null!==(i=n.authorUserId)&&void 0!==i||(n.authorUserId=e.shell.user.id),yield In.saveCampaignJson(this.app.appName,n),e.shell.info("Permissions updated for campaign "+(null!==(o=n.friendlyName)&&void 0!==o?o:n.name))}catch(t){e.shell.error("Failed to update permissions for campaign "+(null!==(a=n.friendlyName)&&void 0!==a?a:n.name)),console.error(t)}}))}),"Manage campaign permissions");return r.style.display="none",s.style.display="none",pe(null!==(i=n.authorUserId)&&void 0!==i?i:o.User.current().id,null!==(a=n.permissions)&&void 0!==a?a:Je).then(e=>{e&&(r.style.display="inline-block",s.style.display="inline-block")}),r.style.color="var(--blue-1)",s.style.color="var(--blue-1)",[s,r]},u=Object.values(l).flat(),p=t.table(u,e=>{var n;return[t.link(null!==(n=e.friendlyName)&&void 0!==n?n:e.name,()=>this.setCampaign(e.name),"Continue Campaign",""),...c.map(t=>{var n,i,o,a;return t.startsWith("campaignFields.")?null!==(i=null===(n=e.campaignFields)||void 0===n?void 0:n[t.replace("campaignFields.","")])&&void 0!==i?i:"":null!==(a=null===(o=R[t])||void 0===o?void 0:o.call(R,e))&&void 0!==a?a:""}),...d(e)]},["Name",...c.map(e=>e.replace("campaignFields.","")),"",""]);return p.style.color="var(--grey-5)",p.style.marginLeft="24px",p.querySelectorAll("tr.header > td").forEach((e,n)=>{if(!e.textContent)return;const i=0===n?"Name":c[n-1];if(r&&i===r.columnName){const n=r.ascending?"↑":"↓";e.appendChild(t.span([n],{style:{fontSize:"12px",marginLeft:"2px"}}))}e.addEventListener("dblclick",()=>{let e={columnName:i,ascending:!0};var t;r&&i===r.columnName&&(e=r.ascending?{columnName:i,ascending:!1}:null),(t=e)?ve(D,JSON.stringify(t)):localStorage.removeItem(D),this.refreshCampaignsTable()})}),xe(p,l),p})}setCampaign(e){return Ke(this,void 0,void 0,function*(){const t=yield this.checkCampaign(e);this.app.campaign=t})}getNewCampaignAccordeon(e,n){return Ke(this,void 0,void 0,function*(){t.setUpdateIndicator(n,!0);const{root:i,promise:o,cancelPromise:a}=yield Fe(e,this.getDataSourceFunctionsMap(),this.getDataSourceTag());return t.setUpdateIndicator(n,!1),o.then(t=>Ke(this,void 0,void 0,function*(){this.app.dataFrame=t.df,this.app._fileInputType=t.type,yield this.app.setTemplate(e,void 0,void 0,void 0,t.friendlyName),this.app.campaignProps=t.campaignProps,yield this.app.saveCampaign(void 0,!1),e.layoutViewState&&this.app.campaign&&(this.app.campaign.layout=e.layoutViewState)})),a.then(()=>{this.init()}),i})}createNewTemplate(t){return Ke(this,void 0,void 0,function*(){const n=yield Ue(this.app,this.getDataSourceFunctionsMap(),t),i=new o.ViewBase,a=e.shell.v;i.name="New Template",i.root.appendChild(n.root),i.parentCall=this.app.parentCall,e.shell.addView(i),i.path=new URL(this.app.baseUrl).pathname+"/new-template",i.parentView=a;const{sub:r}=le(e.shell.v,this.app.appName,T,()=>{e.shell.v=a,i.close()});n.template.then(t=>Ke(this,void 0,void 0,function*(){yield this.init(t),i.close(),ce(i),e.shell.v=a,r.unsubscribe()})),n.cancelPromise.then(()=>{r.unsubscribe(),i.close(),e.shell.v=a})})}}class Xe extends qe{constructor(e){super(e),this.name="Submit"}render(){return t.empty(this.root),t.divV([t.h1("Summary"),t.div([t.tableFromMap(this.app.getSummary())])])}onActivated(){this.render()}submit(){return t=this,n=void 0,a=function*(){const t=this.app.submitParams;if(!t)return;const n=o.Func.find({name:t.fName,package:t.package})[0];if(!n)return void e.shell.error(`Function ${t.fName} not found.`);const i=o.DataFrame.fromCsv(this.app.dataFrame.toCsv({filteredRowsOnly:!0}));yield n.apply({df:i,molecules:this.app.molColName}),this.app.campaign&&(this.app.campaign.status="Submitted"),this.app.saveCampaign("Submitted"),e.shell.info("Submitted successfully.")},new((i=void 0)||(i=Promise))(function(e,o){function r(e){try{l(a.next(e))}catch(e){o(e)}}function s(e){try{l(a.throw(e))}catch(e){o(e)}}function l(t){var n;t.done?e(t.value):(n=t.value,n instanceof i?n:new i(function(e){e(n)})).then(r,s)}l((a=a.apply(t,n||[])).next())});var t,n,i,a}}var et,tt,nt=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{l(i.next(e))}catch(e){a(e)}}function s(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}l((i=i.apply(e,t||[])).next())})};!function(t){t.acquireCampaignLock=function(t,n,i){return nt(this,void 0,void 0,function*(){return yield e.data.query("HitTriage:AcquireCampaignLock",{appName:t,campaignId:n,lockedBy:i})})},t.releaseCampaignLock=function(t,n){return nt(this,void 0,void 0,function*(){return yield e.data.query("HitTriage:ReleaseCampaignLock",{appName:t,campaignId:n})})},t.getLastModified=function(t,n){return nt(this,void 0,void 0,function*(){return yield e.data.query("HitTriage:GetLastModified",{appName:t,campaignId:n})})},t.addMolecule=function(t,n,i,o){return nt(this,void 0,void 0,function*(){return yield e.data.query("HitTriage:AddMolecule",{canonicalSmiles:t,appName:n,campaignId:i,createdBy:o})})},t.addMolecules=function(t,n,i,o){return nt(this,void 0,void 0,function*(){return yield e.data.query("HitTriage:AddMolecules",{smiles:t,appName:n,campaignId:i,createdBy:o})})},t.getMoleculeByVid=function(t){return nt(this,void 0,void 0,function*(){return yield e.data.query("HitTriage:GetMoleculeByVid",{vid:t})})},t.getCampaignsByVid=function(t,n){return nt(this,void 0,void 0,function*(){return yield e.data.query("HitTriage:GetCampaignsByVid",{vid:t,appName:n})})}}(et||(et={})),function(t){t.initHT=function(){return nt(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:InitHT",{})})},t.hitTriageAppTreeBrowser=function(t){return nt(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:HitTriageAppTreeBrowser",{treeNode:t})})},t.hitDesignAppTreeBrowser=function(t){return nt(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:HitDesignAppTreeBrowser",{treeNode:t})})},t.peptiHitAppTreeBrowser=function(t){return nt(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:PeptiHitAppTreeBrowser",{treeNode:t})})},t.hitTriageApp=function(){return nt(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:HitTriageApp",{})})},t.hitDesignApp=function(){return nt(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:HitDesignApp",{})})},t.peptiHitApp=function(){return nt(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:PeptiHitApp",{})})},t.pepTriageAppTreeBrowser=function(t){return nt(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:PepTriageAppTreeBrowser",{treeNode:t})})},t.pepTriageApp=function(){return nt(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:PepTriageApp",{})})},t.demoFileIngest=function(){return nt(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:DemoFileIngest",{})})},t.demoFileIngest1=function(){return nt(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:DemoFileIngest1",{})})},t.demoFileIngest2=function(t){return nt(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:DemoFileIngest2",{numberOfMolecules:t})})},t.demoPeptideSequences=function(t){return nt(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:DemoPeptideSequences",{peptideCount:t})})},t.demoFileSubmit=function(t,n){return nt(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:DemoFileSubmit",{df:t,molecules:n})})},t.registerMoleculesToViD=function(){return nt(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:RegisterMoleculesToViD",{})})},t.hitDesignVidPanel=function(t){return nt(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:HitDesignVidPanel",{vid:t})})},t.gasteigerCellRenderer=function(){return nt(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:GasteigerCellRenderer",{})})},t.htPackageSettingEditor=function(t){return nt(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:HtPackageSettingEditor",{propList:t})})}}(tt||(tt={}));var it=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{l(i.next(e))}catch(e){a(e)}}function s(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}l((i=i.apply(e,t||[])).next())})};class ot{get appName(){return this._appName}constructor(e,t){this.parentCall=e,this.isJoining=!1,this.hasEditPermission=!1,this.baseUrl=new URL(window.location.href).origin+`/apps/HitTriage/${t.replace(" ","")}`,this._appName=t,this.computeFunctions=function(e){const t=Array.from(new Set(o.Func.find({meta:{role:e}}).concat(o.Func.find({tags:[e]}))));return{functions:t.filter(e=>e.type===r),scripts:t.filter(e=>e.type===a),queries:t.filter(e=>e.type===s)}}("HitTriageFunction")}setCanEdit(e){return it(this,void 0,void 0,function*(){e.authorUserId&&e.permissions?this.hasEditPermission=yield pe(e.authorUserId,e.permissions):this.hasEditPermission=!0})}getFilterType(e){const t=this.dataFrame.col(e);return(null==t?void 0:t.semType)===o.SEMTYPE.MOLECULE?o.FILTER_TYPE.SUBSTRUCTURE:(null==t?void 0:t.type)===o.COLUMN_TYPE.BOOL?o.FILTER_TYPE.BOOL_COLUMNS:(null==t?void 0:t.type)===o.COLUMN_TYPE.STRING?o.FILTER_TYPE.CATEGORICAL:o.FILTER_TYPE.HISTOGRAM}download(e,t,n=!1){const i=document.createElement("a"),a=o.DataFrame.fromColumns(e.columns.toList().filter(e=>!e.name.startsWith("~"))).toCsv({filteredRowsOnly:n});i.setAttribute("href","data:text/plain;charset=utf-8,"+encodeURIComponent(a)),i.setAttribute("download",t+".csv"),i.click()}getNewCampaignName(e,t){return it(this,void 0,void 0,function*(){const n=(yield In.files.list(e)).map(e=>e.name).filter(e=>e.startsWith(`${t}-`)&&!!parseInt(e.substring(t.length+1)));if(0===n.length)return t+"-1";const i=n.map(e=>e.substring(t.length+1)).filter(Boolean).map(e=>parseInt(e,10)).sort((e,t)=>e-t);return t+"-"+(i[i.length-1]+1).toString()})}setBaseUrl(){const e=document.title;if(history.replaceState){const t={Title:e,Url:this.baseUrl};history.replaceState(t,t.Title,t.Url)}}unionDataframes(e,t,n,i){var a,r,s,l;const c=n;e.col(n).name=i,n=i;const d=null===(r=null===(a=e.col(n))||void 0===a?void 0:a.toList())||void 0===r?void 0:r.map(e=>In.convertToSmiles(e)),u=null===(l=null===(s=t.col(i))||void 0===s?void 0:s.toList())||void 0===l?void 0:l.map(e=>In.convertToSmiles(e));if(!d||!u)throw new Error("Molecule column not found");const p=new Map;u.forEach((e,t)=>{e&&"MALFORMED_INPUT_VALUE"!==e&&p.set(e,t)});const m=(e,t,n,i)=>{try{if(e.type===t.type)e.set(n,t.get(i),!1);else if(e.type===o.COLUMN_TYPE.STRING)e.set(n,t.getString(i),!1);else if(e.type===o.COLUMN_TYPE.INT){const o=t.get(i);"number"==typeof o?e.set(n,Math.round(o),!1):"string"==typeof o&&o.length>0&&!isNaN(Number(o))&&e.set(n,Math.round(Number(o)),!1)}else if(e.type===o.COLUMN_TYPE.FLOAT){const o=t.get(i);"number"==typeof o?e.set(n,o,!1):"string"==typeof o&&o.length>0&&!isNaN(Number(o))&&e.set(n,Number(o),!1)}else e.set(n,t.get(i),!1)}catch(o){In.logger.error(`Error setting column value for column ${e.name} at row ${n} from column ${t.name} at row ${i}: ${o}`)}};this.isJoining=!0;try{const n=[];for(const i of e.columns)if(!t.columns.contains(i.name)){const e=t.columns.addNew(i.name,i.type);i.semType&&(e.semType=i.semType),n.push(i.name)}for(let i=0;i<d.length;i++)if(d[i]&&"MALFORMED_INPUT_VALUE"!==d[i])if(p.has(d[i])){if(n.length>0){const o=p.get(d[i]);for(const a of n)m(t.col(a),e.col(a),o,i)}}else{t.rows.addNew(null,!0);for(const n of e.columns)m(t.col(n.name),n,t.rowCount-1,i)}}finally{setTimeout(()=>{this.isJoining=!1},500),e.col(n).name=c}return t}aquireAndWaitCampaignLock(e){return it(this,arguments,void 0,function*(e,t=3e4){var n;const i=Date.now();let a=0,r=null;const s=o.User.current(),l=s&&(s.friendlyName||s.name)||"unknown";for(;Date.now()-i<t&&a<5;)try{const t=yield et.acquireCampaignLock(this.appName,e,l);if(t&&t.rowCount>0)return{aquired:!0,expires_at:null===(n=null==t?void 0:t.col("expires_at"))||void 0===n?void 0:n.getString(0)};r=null,yield o.delay(200)}catch(e){r=e,a++}if(r)throw r;return{aquired:!1,expires_at:null}})}releaseCampaignLock(e){return it(this,void 0,void 0,function*(){var t,n;return(null===(n=null===(t=yield et.releaseCampaignLock(this.appName,e))||void 0===t?void 0:t.col("updated_at"))||void 0===n?void 0:n.getString(0))||null})}}ot.molFileExtReaders=["sdf","mol","smi","mol2"].map(e=>{const t=o.Func.find({meta:{role:o.FUNC_TYPES.FILE_IMPORTER}}).concat(o.Func.find({tags:["file-handler"]})).find(t=>{var n;return(null===(n=null==t?void 0:t.options)||void 0===n?void 0:n.ext)&&"string"==typeof t.options.ext&&t.options.ext.split(",").includes(e)});return{ext:e,handlerFunc:t}}).filter(e=>e.handlerFunc);var at=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{l(i.next(e))}catch(e){a(e)}}function s(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}l((i=i.apply(e,t||[])).next())})},rt=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{l(i.next(e))}catch(e){a(e)}}function s(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}l((i=i.apply(e,t||[])).next())})};function st(){return{convertToSmiles:e=>In.convertToSmiles(e),logger:In.logger,molColName:A}}function lt(t,n,i){return rt(this,arguments,void 0,function*(t,n,i,r=[],l=[]){return async function(t,n,i,r=[],l=[],c){var d,u,p;const m=o.TaskBarProgressIndicator.create("Calculating ..."),h=null!==(d=null==c?void 0:c.convertToSmiles)&&void 0!==d?d:e=>e,v=null!==(u=null==c?void 0:c.logger)&&void 0!==u?u:console,f=null!==(p=null==c?void 0:c.molColName)&&void 0!==p?p:"Molecule",g=t.map(e=>h(e)),y=o.Column.fromStrings(f,g),A=o.DataFrame.fromColumns([y]);A.name="HD cell values",await A.meta.detectSemanticTypes();const w=[];w.push(new Promise(async t=>{try{n.length&&await e.chem.descriptors(A,y.name,n)}catch(e){v.error("Descriptors calculation error"),v.error(e)}t()}));for(const e of i)w.push(new Promise(async t=>{try{const n=e.args,i=o.Func.find({package:e.package,name:e.name});if(!i.length||!i[0])return console.warn(`Function ${e.name} from package ${e.package} is not found`),void t();const a=i[0],r=a.inputs[0].name,s=a.inputs[1].name;await a.apply({...n,[r]:A,[s]:y.name})}catch(e){v.error(e)}t()}));for(const e of r){const t=e.args;w.push(new Promise(async n=>{try{const n=o.Func.find({name:e.name}).filter(t=>t.type===a&&t.id===e.id)[0];if(n){const e=n.inputs[0].name,i=n.inputs[1].name,o=await n.apply({...t,[e]:A,[i]:y.name});if(o&&o.rowCount===A.rowCount&&"python"===n.language)for(const e of o.columns)e.name=A.columns.getUnusedName(e.name),A.columns.add(e)}}catch(e){v.error(e)}n()}))}for(const e of l){const t=e.args;w.push(new Promise(async n=>{try{const i=o.Func.find({name:e.name}).filter(t=>t.type===s&&t.id===e.id)[0];if(i){const e=i.inputs[0].name,o=[g],a=await i.apply({...t,[e]:o});if(!a||0===a.rowCount)return void n();await oe(A,f,a)}}catch(e){v.error(e)}n()}))}await Promise.all(w),m.close();const C=A.col(f);for(let e=0;e<C.length;e++)C.set(e,t[e],!1);return A}(t,n,i,r,l,st())})}function ct(t,n,i){return rt(this,void 0,void 0,function*(){return async function(t,n,i,r){var l,c,d,u;const p=o.TaskBarProgressIndicator.create("Calculating ..."),m=null!==(l=null==r?void 0:r.convertToSmiles)&&void 0!==l?l:e=>e,h=null!==(c=null==r?void 0:r.logger)&&void 0!==c?c:console,v=n.col(i);if(!v)throw new Error("There is no molecule column in dataframe");const f=`~${i}.canonicalSmiles`,g=n.columns.getOrCreate(f,o.TYPE.STRING);g.semType=o.SEMTYPE.MOLECULE;const y=v.toList();for(let e=0;e<y.length;e++){if(v.isNone(e))continue;const t=y[e];if(!t)continue;const n=m(t);g.set(e,n,!1)}const A=[];A.push(new Promise(async i=>{try{t.descriptors&&t.descriptors.length>0&&await e.chem.descriptors(n,f,t.descriptors)}catch(e){h.error("Descriptors calculation error"),h.error(e)}i()}));for(const e of Object.keys(t.externals))A.push(new Promise(async i=>{try{const i=t.externals[e],a=o.Func.find({package:e.split(":")[0],name:e.split(":")[1]})[0],r=a.inputs[0].name,s=a.inputs[1].name;i&&await a.apply({...i,[r]:n,[s]:f})}catch(e){h.error(e)}i()}));for(const e of Object.keys(null!==(d=t.scripts)&&void 0!==d?d:{})){const i=t.scripts[e];A.push(new Promise(async t=>{if(i){const r=e.split(":"),s=r[2];if(!s)return void t();try{const e=r[1],l=o.Func.find({name:e}).filter(e=>e.type===a&&e.id===s)[0];if(!l)return void t();const c=l.inputs[0].name,d=l.inputs[1].name,u=await l.apply({...i,[c]:n,[d]:f});if(u&&u.rowCount===n.rowCount&&"python"===l.language)for(const e of u.columns)e.name=n.columns.getUnusedName(e.name),n.columns.add(e)}catch(e){h.error(e)}}t()}))}for(const e of Object.keys(null!==(u=t.queries)&&void 0!==u?u:{})){const i=t.queries[e];A.push(new Promise(async t=>{if(i){const a=e.split(":"),r=a[2];if(!r)return void t();try{const e=a[1],l=o.Func.find({name:e}).filter(e=>e.type===s&&e.id===r)[0];if(!l)return void t();const c=l.inputs[0].name,d=await l.apply({...i,[c]:g.toList()});d&&await oe(n,f,d)}catch(e){console.error(e)}}t()}))}await Promise.all(A),p.close()}(t,n,i,st())})}var dt=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{l(i.next(e))}catch(e){a(e)}}function s(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}l((i=i.apply(e,t||[])).next())})};class ut extends ot{get infoView(){return this._infoView}constructor(t,n="Hit Triage",i=e=>new Ze(e)){super(t,n),this._filterViewName="Hit Triage | Pick",this._filterDescriptions=[],this.campaignProps={},this._pickViewPromise=null,this._infoView=i(this),this.multiView=new o.MultiView({viewFactories:{[this._infoView.name]:()=>this._infoView}}),this.multiView.tabs.onTabChanged.subscribe(e=>{this.multiView.currentView instanceof qe&&this.multiView.currentView.onActivated()}),this.multiView.parentCall=t,e.events.onCurrentViewChanged.subscribe(()=>{var t,n,i,o;try{(null===(t=e.shell.v)||void 0===t?void 0:t.name)===this.currentPickViewId&&(e.shell.windows.showHelp=!1,this.setBaseUrl(),se(u,null!==(o=null!==(n=this._campaignId)&&void 0!==n?n:null===(i=this._campaign)||void 0===i?void 0:i.name)&&void 0!==o?o:""))}catch(e){console.error(e)}})}get submitParams(){var e,t,n,i;return null!==(n=null===(t=null===(e=this.campaign)||void 0===e?void 0:e.template)||void 0===t?void 0:t.submit)&&void 0!==n?n:null===(i=this.template)||void 0===i?void 0:i.submit}prepareDataFrame(e){return dt(this,void 0,void 0,function*(){})}setTemplate(t,n,i,a,r){return dt(this,void 0,void 0,function*(){var s,d,p,m,h,v,f,g,y,A,w,C,b,E,T,x,S,N,B,I;if(this._friendlyName=null!=r?r:null===(s=this._campaign)||void 0===s?void 0:s.friendlyName,(null===(d=this._pickView)||void 0===d?void 0:d.dataFrame)&&e.shell.closeTable(null===(p=this._pickView)||void 0===p?void 0:p.dataFrame),this._pickView=void 0,i?a&&(this._fileInputType=a.type,"File"===a.type?this.dataFrame=yield e.dapi.files.readCsv(a.query):this.dataFrame=yield e.functions.call(a.query)):(i=yield this.getNewCampaignName(`${this.appName}/campaigns`,t.key),se(u,i)),!this.dataFrame)return void console.error("Dataframe is empty.");if((null===(m=this._campaign)||void 0===m?void 0:m.columnSemTypes)&&Object.entries(this._campaign.columnSemTypes).forEach(([e,t])=>{const n=this.dataFrame.columns.byName(e);n&&n.semType!==t&&(n.semType=t)}),(null===(h=this._campaign)||void 0===h?void 0:h.columnTypes)&&Object.entries(this._campaign.columnTypes).forEach(([e,t])=>{const n=this.dataFrame.columns.byName(e);if(n&&n.type!==t)try{n.convertTo(t)}catch(e){console.error(e)}}),yield this.dataFrame.meta.detectSemanticTypes(),yield this.prepareDataFrame(t),this._molColName=null!==(f=null===(v=this.dataFrame.columns.bySemType(o.SEMTYPE.MOLECULE))||void 0===v?void 0:v.name)&&void 0!==f?f:void 0,this._dfName=null!==(g=this.dataFrame.name)&&void 0!==g?g:null==a?void 0:a.query,this.dataFrame.name=null!==(A=null!==(y=this._dfName)&&void 0!==y?y:this.dataFrame.name)&&void 0!==A?A:"Molecules",this._campaignId=i,this.template=(null===(w=this.campaign)||void 0===w?void 0:w.template)?Object.assign(Object.assign({},this.campaign.template),{dataSourceType:t.dataSourceType,queryFunctionName:t.queryFunctionName}):t,this._campaignFilters=n,!n){const e={},n={},i={};t.compute.functions.forEach(t=>{const n=`${t.package}:${t.name}`;e[n]=t.args}),null===(C=t.compute.scripts)||void 0===C||C.forEach(e=>{const t=`${l}:${e.name}:${e.id}`;n[t]=e.args}),null===(b=t.compute.queries)||void 0===b||b.forEach(e=>{const t=`${c}:${e.name}:${e.id}`;i[t]=e.args}),yield ct({descriptors:t.compute.descriptors.enabled?t.compute.descriptors.args:[],externals:e,scripts:n,queries:i},this.dataFrame,this._molColName)}this.campaign?yield this.setCanEdit(this.campaign):this.hasEditPermission=!0,this._filterViewName=`${this.appName} | ${null!==(T=null!==(E=this._friendlyName)&&void 0!==E?E:this._campaignId)&&void 0!==T?T:"Pick"}`;const F=e.shell.v,P=e.shell.addView(this.pickView);this.currentPickViewId=P.name,this._submitView=new Xe(this),this.setBaseUrl(),se(u,null!==(N=null!==(x=this._campaignId)&&void 0!==x?x:null===(S=this._campaign)||void 0===S?void 0:S.name)&&void 0!==N?N:"");const O=P,_=null!==(I=null!==(B=this._friendlyName)&&void 0!==B?B:this._campaignId)&&void 0!==I?I:"Pick";setTimeout(()=>{this._pickViewPromise&&this._pickViewPromise.then(()=>{const{sub:t}=le(O,this.appName,_,()=>{e.shell.v=F,O.close(),t.unsubscribe()})})},300),e.shell.windows.showHelp=!1})}get filterSettings(){return this._campaignFilters}get campaignId(){return this._campaignId}get pickView(){return this._pickView=this.getFilterView()}get molColName(){var e,t,n;return null!==(e=this._molColName)&&void 0!==e?e:this._molColName=null===(n=null===(t=this.dataFrame)||void 0===t?void 0:t.columns.bySemType(o.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(g)||this.dataFrame.columns.addNewBool(g).init(!1);const n=o.TableView.create(this.dataFrame,!1);let i=n.getRibbonPanels();const a=t.iconFA("wrench",()=>dt(this,void 0,void 0,function*(){Ve(this,e=>dt(this,void 0,void 0,function*(){var t,n,i,o,a,r,s;const d=this.template.compute.descriptors.args,u=this.template.compute.functions,p=null!==(t=this.template.compute.scripts)&&void 0!==t?t:[],m=null!==(n=this.template.compute.queries)&&void 0!==n?n:[],h=e.descriptors,v={descriptors:{enabled:!!(null===(i=null==e?void 0:e.descriptors)||void 0===i?void 0:i.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 n=e.split(":");return{name:n[1],package:n[0],args:t}}),scripts:Object.entries(null!==(r=null==e?void 0:e.scripts)&&void 0!==r?r:{}).filter(([e,t])=>e.startsWith(l)&&3===e.split(":").length).map(([e,t])=>{var n,i;const o=e.split(":");return{name:null!==(n=o[1])&&void 0!==n?n:"",id:null!==(i=o[2])&&void 0!==i?i:"",args:t}}),queries:Object.entries(null!==(s=null==e?void 0:e.queries)&&void 0!==s?s:{}).filter(([e,t])=>e.startsWith(c)&&3===e.split(":").length).map(([e,t])=>{var n,i;const o=e.split(":");return{name:null!==(n=o[1])&&void 0!==n?n:"",id:null!==(i=o[2])&&void 0!==i?i:"",args:t}})};this.template.compute=v;const f=h.filter(e=>!d.includes(e)),g=v.functions.filter(e=>{if(!u.some(t=>t.name===e.name&&t.package===e.package))return!0;const t=u.find(t=>t.name===e.name&&t.package===e.package);return!Object.entries(e.args).every(([e,n])=>t.args[e]===n)}),y=v.scripts.filter(e=>{if(!p.some(t=>t.id===e.id))return!0;const t=p.find(t=>t.id===e.id);return!Object.entries(e.args).every(([e,n])=>t.args[e]===n)}),A=v.queries.filter(e=>{if(!m.some(t=>t.id===e.id))return!0;const t=m.find(t=>t.id===e.id);return!Object.entries(e.args).every(([e,n])=>t.args[e]===n)}),w={};g.forEach(e=>{const t=`${e.package}:${e.name}`;w[t]=e.args});const C={};y.forEach(e=>{const t=`${l}:${e.name}:${e.id}`;C[t]=e.args});const b={};A.forEach(e=>{const t=`${c}:${e.name}:${e.id}`;b[t]=e.args}),yield ct({descriptors:f,externals:w,scripts:C,queries:b},this.dataFrame,this._molColName),this.saveCampaign("In Progress",!1)}),()=>null,this.template,!0)}),"Calculate additional properties"),r=t.bigButton("Submit",()=>{var e;const n=null===(e=this._submitView)||void 0===e?void 0:e.render();if(n){const e=t.dialog("Submit");e.add(n),e.addButton("Save",()=>{this.saveCampaign(),e.close()}),e.addButton("Submit",()=>{var t;null===(t=this._submitView)||void 0===t||t.submit(),e.close()}),e.show()}}),s=t.iconFA("share",()=>dt(this,void 0,void 0,function*(){var e;yield new Qe(null===(e=this.campaign)||void 0===e?void 0:e.permissions).show(e=>{this.campaign.permissions=e,this.saveCampaign(void 0,!0)})}),"Edit permissions");r.classList.add("hit-design-submit-button");const d=de(i);return i.push([a,...this.hasEditPermission?[s]:[],...d?[]:[r]]),i.some(e=>{var t;const n=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!==n&&(e.splice(n,1),!0)}),i=i.filter(e=>{var t;return(null!==(t=null==e?void 0:e.length)&&void 0!==t?t:0)>0}),n.setRibbonPanels(i),n.name=this._filterViewName,setTimeout(()=>dt(this,void 0,void 0,function*(){var t,i,a;n._onAdded(),yield new Promise(e=>setTimeout(e,1e3));const r=n.filters(this._campaignFilters?{filters:this._campaignFilters}:void 0),s=null!==(i=null===(t=this._campaign)||void 0===t?void 0:t.layout)&&void 0!==i?i:null===(a=this.template)||void 0===a?void 0:a.layoutViewState;if(s)try{const e=o.ViewLayout.fromViewState(s);n.loadLayout(e)}catch(e){console.error(e)}n.dataFrame.onFilterChanged.subscribe(e=>{this._filterDescriptions=Array.from(n.dataFrame.rows.filters),this._campaignFilters=r.getOptions().look.filters}),setTimeout(()=>{this._filterDescriptions=Array.from(n.dataFrame.rows.filters),this._campaignFilters=r.getOptions().look.filters},300),e&&e()}),300),n.parentCall=this.parentCall,n}getSummary(){var e,n,i,o,a,r,s;const l=null!==(n=null===(e=this.campaign)||void 0===e?void 0:e.campaignFields)&&void 0!==n?n:this.campaignProps;return Object.assign(Object.assign({Template:null!==(o=null===(i=this.template)||void 0===i?void 0:i.name)&&void 0!==o?o:"Molecules","File path":t.divH([t.link(null!==(a=this._dfName)&&void 0!==a?a:"-",()=>this.download(this.dataFrame,"molecules"),N)],{style:{alignItems:"center"}})},l),{"Number of molecules":this.dataFrame.rowCount.toString(),"Enrichment methods":[this.template.compute.descriptors.enabled?"descriptors":"",...this.template.compute.functions.map(e=>e.name)].filter(e=>e&&""!==e.trim()).join(", "),Filters:this._filterDescriptions.join(", "),"Result Molecules":t.divH([t.link(null!==(s=null===(r=this.dataFrame)||void 0===r?void 0:r.filter.trueCount.toString())&&void 0!==s?s:"0",()=>{this.download(this.dataFrame,"hits",!0)},N)],{style:{alignItems:"center"}})})}saveCampaign(n){return dt(this,arguments,void 0,function*(n,i=!0){var a,r,s,l,c,d,u,p,h,v,f,g,y,A,w;const C=this.campaignId,b=this.filterSettings,E=this.template.name,T=this.dataFrame,x=`System:AppData/HitTriage/${this.appName}/campaigns/${C}/`,S=null!=C?C:yield function(e){return at(this,void 0,void 0,function*(){return new Promise(n=>at(this,void 0,void 0,function*(){const i=t.input.string("Campaign name",{value:""});t.dialog("Save Campaign").add(t.div(i.root)).onOK(function(){i.value&&""!==i.value?n(i.value):n(e)}).show()}))})}(C),N={};T.columns.toList().forEach(e=>N[e.name]=e.semType);const B={};T.columns.toList().forEach(e=>B[e.name]=e.type);const I=null!==(r=null===(a=this.campaign)||void 0===a?void 0:a.authorUserId)&&void 0!==r?r:e.shell.user.id,F=null!==(l=null===(s=this.campaign)||void 0===s?void 0:s.permissions)&&void 0!==l?l:Je,P=I?null!==(d=null===(c=this.campaign)||void 0===c?void 0:c.authorUserFriendlyName)&&void 0!==d?d:null===(u=yield e.dapi.users.find(I))||void 0===u?void 0:u.friendlyName:void 0,O={name:S,friendlyName:null!==(p=this._friendlyName)&&void 0!==p?p:null===(h=this.campaign)||void 0===h?void 0:h.friendlyName,templateName:E,filters:null!=b?b:{},ingest:{type:"File",query:`${x}${m}`,molColName:this.molColName},status:null!==(f=null!=n?n:null===(v=this.campaign)||void 0===v?void 0:v.status)&&void 0!==f?f:"In Progress",createDate:null!==(y=null===(g=this.campaign)||void 0===g?void 0:g.createDate)&&void 0!==y?y:re(new Date),campaignFields:null!==(w=null===(A=this.campaign)||void 0===A?void 0:A.campaignFields)&&void 0!==w?w:this.campaignProps,columnSemTypes:N,rowCount:T.rowCount,filteredRowCount:T.filter.trueCount,template:this.template,columnTypes:B,authorUserId:I,authorUserFriendlyName:P,lastModifiedUserName:e.shell.user.friendlyName,permissions:F};if(this.campaign=O,!this.hasEditPermission)return e.shell.error("You do not have permission to modify this campaign"),O;const _=o.DataFrame.fromColumns(T.columns.toList().filter(e=>!e.name.startsWith("~"))).toCsv();yield In.files.writeAsText(`${this.appName}/campaigns/${C}/${m}`,_);const k=this._pickView.saveLayout();return k?O.layout=k.viewState:e.shell.warning("Layout cound not be saved"),yield In.saveCampaignJson(this.appName,O),i&&e.shell.info("Campaign saved successfully."),O})}}function pt(n,i=!1){var a,r;const s=o.DataFrame.create(1);if(i){const e=s.columns.addNew(w,o.TYPE.STRING);e.semType=o.SEMTYPE.MACROMOLECULE,e.meta.units="helm",e.setTag("units","helm"),e.setTag("cell.renderer","helm"),e.setTag(".alphabetIsMultichar","true")}const l=s.columns.addNew(A,o.TYPE.STRING);l.semType=o.SEMTYPE.MOLECULE,l.meta.units=o.UNITS.Molecule.SMILES,l.set(0,null),(null===(a=null==n?void 0:n.stages)||void 0===a?void 0:a.length)>0&&s.columns.addNew(y,o.TYPE.STRING).set(0,n.stages[0]),s.columns.addNew(C,o.TYPE.STRING);const c=n.campaignFields.map(e=>e.type===o.SEMTYPE.MOLECULE?Object.assign(Object.assign({},e),{type:"String",semtype:o.SEMTYPE.MOLECULE}):e).map(e=>o.Property.fromOptions(Object.assign({name:e.name,type:Be[e.type],nullable:!e.required},e.semtype?{semType:e.semtype}:{}))),d={},u=t.input.string("Campaing Name",{tooltipText:"New campaign name. If empty, campaign code will be used."}),p=t.input.form(d,c);p.prepend(u.root),p.classList.remove("ui-form");const m=t.div([...(null===(r=n.campaignFields)||void 0===r||r.length,[]),p]),h=t.buttonsInput([]);return m.appendChild(h),{promise:new Promise(i=>{const o=t.bigButton(x,()=>{for(const t of n.campaignFields)if(t.required&&(!d[t.name]||""===d[t.name]))return void e.shell.error(`Field '${t.name}' is required`);i({df:s,campaignProps:d,name:u.value})});h.appendChild(o)}),root:m,cancelPromise:new Promise(e=>{t.button(B,()=>e())})}}var mt=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{l(i.next(e))}catch(e){a(e)}}function s(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}l((i=i.apply(e,t||[])).next())})};function ht(n,i){return mt(this,void 0,void 0,function*(){var a,r,s,d,u,p,m,h,v,g,y;const A=yield In.files.list(`${n.appName}/templates`);let w=!1,C=!1;const b=A.map(e=>e.name.slice(0,-5)),E=[];for(const e of A)try{const t=JSON.parse(yield In.files.readAsText(e));E.push(t.key)}catch(e){console.error(e)}const T=Array.from(new Set(o.Func.find({meta:{role:f}}).concat(o.Func.find({tags:[f]})))),x={};T.forEach(e=>{var t;x[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e});const N=t.input.choice("Submit function",{value:null,items:[null,...Object.keys(x)]});N.nullable=!0,N.value=null!==(r=null===(a=null==i?void 0:i.submit)||void 0===a?void 0:a.fName)&&void 0!==r?r:null,N.setTooltip("Select function to be called upon submitting");const I=t.divText("Template name is empty or already exists",{classes:"hit-triage-error-div"}),F=t.divText("Template key is empty or already exists",{classes:"hit-triage-error-div"}),P=De();function O(){var e,t,n,i;if(""===_.value||b.includes(null!==(t=null===(e=_.value)||void 0===e?void 0:e.trim())&&void 0!==t?t:"")){const e=null!==(n=_.input.offsetLeft)&&void 0!==n?n:0,t=null!==(i=_.input.offsetWidth)&&void 0!==i?i:0;I.style.marginLeft=`${e}px`,I.style.width=`${t}px`,I.style.opacity="100%",I.style.borderTop="1px solid red",w=!0}else I.style.borderTop="none",I.style.opacity="0%",w=!1}const _=t.input.string("Name",{value:null!==(s=null==i?void 0:i.name)&&void 0!==s?s:"",onValueChanged:O});function k(){var e,t,n,i;if(""===L.value||E.includes(null!==(t=null===(e=L.value)||void 0===e?void 0:e.trim())&&void 0!==t?t:"")){const e=null!==(n=L.input.offsetLeft)&&void 0!==n?n:0,t=null!==(i=L.input.offsetWidth)&&void 0!==i?i:0;F.style.marginLeft=`${e}px`,F.style.width=`${t}px`,F.style.borderTop="1px solid red",F.style.opacity="100%",C=!0}else F.style.opacity="0%",F.style.borderTop="none",C=!1}const L=t.input.string("Key",{value:null!==(d=null==i?void 0:i.key)&&void 0!==d?d:"",onValueChanged:k});L.setTooltip("Template key used for campaign prefix"),_.setTooltip("Template name"),_.root.style.borderBottom="none",L.root.style.borderBottom="none",I.style.opacity="0%",F.style.opacity="0%";let V=null;const M={compute:{descriptors:{enabled:!0,args:null!==(m=null===(p=null===(u=null==i?void 0:i.compute)||void 0===u?void 0:u.descriptors)||void 0===p?void 0:p.args)&&void 0!==m?m:[]},functions:null!==(v=null===(h=null==i?void 0:i.compute)||void 0===h?void 0:h.functions)&&void 0!==v?v:[]}},$=yield Ve(n,e=>{V=e},()=>null,M,!1,!0);$.root.classList.add("hit-triage-new-template-functions-input");const D=je(null==i?void 0:i.campaignFields),R=vt(null==i?void 0:i.stages),U=t.divV([t.divV([_,I]),t.divV([L,F]),P.dataFileInput,D.fieldsDiv]),j=t.h2("Stages");t.tooltip.bind(j,'Define Stages for designed molecules. For example, "Design", "Synthesis", "Test", etc.');const H=t.h2("Compute");t.tooltip.bind(H,'Define functions to be calculated for each molecule. For example, "Descriptors", "Descriptors:Descriptors", etc.');const q=t.div([t.h2("Details"),U,j,R.fieldsDiv,H,$.root,t.h2("Submit"),N.root],"ui-form"),Y=t.buttonsInput([]);q.appendChild(Y);const G=null!==(y=null===(g=Y.getElementsByClassName("ui-input-editor"))||void 0===g?void 0:g[0])&&void 0!==y?y:Y,W=new Promise(e=>{const n=t.button(B,()=>e());G.appendChild(n)}),z=new Promise(i=>{const o=t.bigButton(S,()=>function(){return mt(this,void 0,void 0,function*(){var t,o,a,r,s,d,u;if(O(),k(),$.okProxy(),w||!_.value||""===_.value)return void e.shell.error("Template name is empty or already exists");if(C||!L.value||""===L.value)return void e.shell.error("Template key is empty or already exists");const p=N.value?x[N.value]:void 0,m=Object.assign({name:_.value,key:L.value,campaignFields:D.getFields(),stages:R.getFields(),layoutViewState:null!==(t=P.getLayoutViewState())&&void 0!==t?t:void 0,localLayoutPath:null!==(o=P.getLocalFilePath())&&void 0!==o?o:void 0,compute:{descriptors:{enabled:!!(null===(a=null==V?void 0:V.descriptors)||void 0===a?void 0:a.length),args:null!==(r=null==V?void 0:V.descriptors)&&void 0!==r?r:[]},functions:Object.entries(null!==(s=null==V?void 0:V.externals)&&void 0!==s?s:{}).map(([e,t])=>{var n;const i=e.split(":");return{name:i[1],package:i[0],args:t,rerunOnOpen:!!(null===(n=null==V?void 0:V.rerunOnOpen)||void 0===n?void 0:n[e])}}),scripts:Object.entries(null!==(d=null==V?void 0:V.scripts)&&void 0!==d?d:{}).filter(([e,t])=>e.startsWith(l)&&3===e.split(":").length).map(([e,t])=>{var n,i,o;const a=e.split(":");return{name:null!==(n=a[1])&&void 0!==n?n:"",id:null!==(i=a[2])&&void 0!==i?i:"",args:t,rerunOnOpen:!!(null===(o=null==V?void 0:V.rerunOnOpen)||void 0===o?void 0:o[e])}}),queries:Object.entries(null!==(u=null==V?void 0:V.queries)&&void 0!==u?u:{}).filter(([e,t])=>e.startsWith(c)&&3===e.split(":").length).map(([e,t])=>{var n,i,o;const a=e.split(":");return{name:null!==(n=a[1])&&void 0!==n?n:"",id:null!==(i=a[2])&&void 0!==i?i:"",args:t,rerunOnOpen:!!(null===(o=null==V?void 0:V.rerunOnOpen)||void 0===o?void 0:o[e])}})}},p?{submit:{fName:p.name,package:ie(p)}}:{});yield function(e,t){return mt(this,void 0,void 0,function*(){yield In.files.writeAsText(`${t}/templates/${e.name}.json`,JSON.stringify(e))})}(m,n.appName),e.shell.info("Template created successfully"),i(m)})}());G.appendChild(o)});return{root:q,template:z,cancelPromise:W}})}function vt(e){const t=[o.Property.fromOptions({name:"Name",type:o.TYPE.STRING})],n=new $e(t,e?e.map(e=>({Name:e})):void 0,{horizontalInputNames:!0});let i={};return n.onItemAdded.subscribe(e=>{i={}}),n.onAddingItemChanged.subscribe(e=>{e&&(i=e.item)}),{getFields:function(){const e=n.items.filter(e=>e.Name).map(e=>e.Name);return i.Name&&""!==i.Name&&e.push(i.Name),e},fieldsDiv:n.root,itemsGrid:n}}var ft=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{l(i.next(e))}catch(e){a(e)}}function s(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}l((i=i.apply(e,t||[])).next())})};class gt extends qe{constructor(n){super(n),this.currentGroupping="None",this._appHeader=null,this._contentRoot=t.div([],{classes:"hit-triage-info-view-container"}),this.campaignsTableRoot=null,this.name="Hit Design",this._appHeader=this.getAppHeader(),this.root.appendChild(t.div([this._appHeader],{style:{marginLeft:"10px"}})),this.root.appendChild(this._contentRoot),e.shell.windows.showHelp=!0,e.shell.windows.help.showHelp(In.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(In.webRoot+"README_HD.md")}getAppHeader(){return We.appHeader({iconPath:In.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"})}refreshCampaignsTable(){return ft(this,void 0,void 0,function*(){if(null!=this.campaignsTableRoot){t.setUpdateIndicator(this.campaignsTableRoot,!0);try{const e=yield this.getCampaignsTable();t.setUpdateIndicator(this.campaignsTableRoot,!1),t.empty(this.campaignsTableRoot),this.campaignsTableRoot.appendChild(e)}catch(t){e.shell.error("Failed to update campaigns table"),console.error(t)}finally{t.setUpdateIndicator(this.campaignsTableRoot,!1)}}})}init(e){return ft(this,void 0,void 0,function*(){t.setUpdateIndicator(this.root,!0);try{const n=t.h1(I),i=t.h1(F,{style:{marginLeft:"10px"}}),a=t.div(),r=t.divH([]),s=t.div([r,a],"ui-form"),l=yield this.getCampaignsTable();this.campaignsTableRoot=t.div([l],{style:{position:"relative"}});const c=t.iconFA("layer-group",()=>ft(this,void 0,void 0,function*(){const e=o.Menu.popup();Object.values(L).forEach(t=>{e.item(t,()=>ft(this,void 0,void 0,function*(){fe(t),yield this.refreshCampaignsTable()}))});const t=e.group("Campaign Fields"),n=yield In.loadCampaigns(this.app.appName,this.deletedCampaigns),i=new Set;Object.values(n).forEach(e=>{e.campaignFields&&Object.keys(e.campaignFields).forEach(e=>i.add(e))}),Array.from(i).forEach(e=>{t.item(e,()=>ft(this,void 0,void 0,function*(){fe(`campaignFields.${e}`),yield this.refreshCampaignsTable()}))}),e.show({element:p,x:120,y:p.offsetTop+30})}),"Group by");c.style.marginBottom="9px",c.style.marginLeft="8px",c.style.fontSize="15px",c.style.color="var(--blue-1)",t.tooltip.bind(c,()=>`Group Campaigns. Current: ${this.currentGroupping}`);const d=t.iconFA("eye",()=>ft(this,void 0,void 0,function*(){const e=o.Menu.popup(),t=yield In.loadCampaigns(this.app.appName,this.deletedCampaigns),n=Object.assign({},V);delete n.Name,Object.values(t).forEach(e=>{e.campaignFields&&Object.keys(e.campaignFields).forEach(e=>{n[`campaignFields.${e}`]=t=>{var n,i;return null!==(i=null===(n=t.campaignFields)||void 0===n?void 0:n[e])&&void 0!==i?i:""}})});const i=ye().reduce((e,t)=>(e[t]=!0,e),{});Object.keys(n).filter(e=>!e.startsWith("campaignFields.")).forEach(t=>{var n;e.item(t,()=>{i[t]=!i[t],Ae(Object.keys(i).filter(e=>i[e])),this.refreshCampaignsTable()},null,{check:null!==(n=i[t])&&void 0!==n&&n})});const a=e.group("Campaign Fields");Object.keys(n).filter(e=>e.startsWith("campaignFields.")).forEach(e=>{var t;a.item(e.replace("campaignFields.",""),()=>{i[e]=!i[e],Ae(Object.keys(i).filter(e=>i[e])),this.refreshCampaignsTable()},null,{check:null!==(t=i[e])&&void 0!==t&&t})}),e.show({element:p,x:100,y:p.offsetTop+30})}),"View");t.tooltip.bind(d,"Edit visible columns in campaigns table"),d.style.marginBottom="9px",d.style.marginLeft="8px",d.style.fontSize="15px",d.style.color="var(--blue-1)";const u=t.iconFA("sync",()=>ft(this,void 0,void 0,function*(){yield this.refreshCampaignsTable()}),"Refresh");u.style.marginBottom="9px",u.style.marginLeft="8px",u.style.color="var(--blue-1)",t.tooltip.bind(u,()=>"Refresh campaigns table");const p=t.divH([n,d,c,u],{style:{alignItems:"center"}});Oe()(this._contentRoot).empty(),this._contentRoot.appendChild(t.divV([p],{style:{marginLeft:"10px"}})),this._contentRoot.appendChild(this.campaignsTableRoot),this._contentRoot.appendChild(i),this._contentRoot.appendChild(s),yield this.startNewCampaign(a,r,e)}finally{t.setUpdateIndicator(this.root,!1)}})}startNewCampaign(n,i,o){return ft(this,void 0,void 0,function*(){var a;const r=(yield In.files.list(`${this.app.appName}/templates`)).filter(e=>e.name.endsWith(".json")).map(e=>e.name.slice(0,-5));o&&!r.includes(o.name)&&r.push(o.name);let s=null,l=!0;const c=()=>ft(this,void 0,void 0,function*(){if(!l)return;const e=d.value,t=o&&o.name===e?o:yield Ne(`${this.app.appName}/templates/${e}.json`);s=t;const i=yield this.getNewCampaignAccordeon(t);Oe()(n).empty(),n.appendChild(i)}),d=t.input.choice("Template",{value:null!==(a=null==o?void 0:o.name)&&void 0!==a?a:r[0],items:r,onValueChanged:()=>ft(this,void 0,void 0,function*(){yield c()})});d.root.style.width="100%";const u=t.icons.add(()=>{this.createNewTemplate()},T),p=t.icons.copy(()=>{s&&this.createNewTemplate(s)},"Clone template"),m=t.icons.delete(()=>{!d.value||d.items.length<2||t.dialog("Delete template").add(t.divText(`Are you sure you want to delete template ${d.value}?`)).onOK(()=>ft(this,void 0,void 0,function*(){try{const t=d.value;yield In.files.delete(`${this.app.appName}/templates/${t}.json`),l=!1,d.items=d.items.filter(e=>e!==t),d.value=d.items[0],l=!0,yield c(),e.shell.info("Template "+t+" was deleted successfully")}catch(t){l=!0,e.shell.error("Failed to delete template "+d.value),console.error(t)}})).show()},"Delete template");m.style.color="var(--blue-1)",u.style.color="#2083d5",d.addOptions(u),d.addOptions(p),d.addOptions(m),yield c(),Oe()(i).empty(),i.appendChild(d.root)})}checkCampaign(e){return ft(this,void 0,void 0,function*(){var t;const n=location.search,i=new URLSearchParams(n);if(!i.has(p)&&!e)return;const o=null!=e?e:i.get(p);if(!(yield In.files.exists(`${this.app.appName}/campaigns/${o}/${h}`)))return;const a=JSON.parse(yield In.files.readAsText(`${this.app.appName}/campaigns/${o}/${h}`));if(a){if(a.authorUserId&&a.permissions&&!(yield me(a.authorUserId,a.permissions)))return void this.app.setBaseUrl();this.app.campaign=a}const r=null!==(t=a.template)&&void 0!==t?t:yield Ne(`${this.app.appName}/templates/${a.templateName}.json`);return yield this.app.setTemplate(r,o),e&&se(p,e),a.template=r,a})}getCampaignsTable(){return ft(this,void 0,void 0,function*(){const n=yield In.loadCampaigns(this.app.appName,this.deletedCampaigns),i=null!==(a=he(O))&&void 0!==a?a:L.None;var a;const r=function(){const e=he(k);return e?JSON.parse(e):null}(),s=Object.values(n);r&&ge(s,r);const l=Te(s,i),c=ye();this.currentGroupping=i,this.app.existingStatuses=Array.from(new Set(s.map(e=>e.status).filter(e=>!!e)));const d=n=>{var i,a;const r=t.icons.delete(()=>ft(this,void 0,void 0,function*(){t.dialog("Delete campaign").add(t.divText(`Are you sure you want to delete campaign ${n.name}?`)).onOK(()=>ft(this,void 0,void 0,function*(){yield this.deleteCampaign(this.app.appName,n.name),this.deletedCampaigns.push(n.name),yield this.init()})).show()}),"Delete campaign"),s=t.iconFA("share",()=>ft(this,void 0,void 0,function*(){yield new Qe(n.permissions).show(t=>ft(this,void 0,void 0,function*(){var i;try{n.permissions=t,null!==(i=n.authorUserId)&&void 0!==i||(n.authorUserId=e.shell.user.id),yield In.saveCampaignJson(this.app.appName,n),e.shell.info("Permissions updated for campaign "+n.name)}catch(t){e.shell.error("Failed to update permissions for campaign "+n.name),console.error(t)}}))}),"Manage campaign permissions");return r.style.display="none",s.style.display="none",pe(null!==(i=n.authorUserId)&&void 0!==i?i:o.User.current().id,null!==(a=n.permissions)&&void 0!==a?a:Je).then(e=>{e&&(r.style.display="inline-block",s.style.display="inline-block")}),r.style.color="var(--blue-1)",s.style.color="var(--blue-1)",[s,r]},u=t.table(Object.values(l).flat(),e=>{var n;return[t.link(null!==(n=e.friendlyName)&&void 0!==n?n:e.name,()=>this.setCampaign(e.name),"Continue Campaign",""),...c.map(t=>{var n,i,o;return t.startsWith("campaignFields.")?null!==(i=null===(n=e.campaignFields)||void 0===n?void 0:n[t.replace("campaignFields.","")])&&void 0!==i?i:"":null!==(o=V[t](e))&&void 0!==o?o:""}),...d(e)]},["Name",...c.map(e=>e.replace("campaignFields.","")),"",""]);return u.style.color="var(--grey-5)",u.style.marginLeft="24px",u.querySelectorAll("tr.header > td").forEach((e,n)=>{if(!e.textContent)return;const i=0===n?"Name":c[n-1];if(r&&i===r.columnName){const n=r.ascending?"↑":"↓";e.appendChild(t.span([n],{style:{fontSize:"12px",marginLeft:"2px"}}))}e.addEventListener("dblclick",()=>{let e={columnName:i,ascending:!0};var t;r&&i===r.columnName&&(e=r.ascending?{columnName:i,ascending:!1}:null),(t=e)?ve(k,JSON.stringify(t)):localStorage.removeItem(k),this.refreshCampaignsTable()})}),xe(u,l),u})}setCampaign(e){return ft(this,void 0,void 0,function*(){const t=yield this.checkCampaign(e);this.app.campaign=t})}getNewCampaignAccordeon(e){return ft(this,void 0,void 0,function*(){const{root:t,promise:n,cancelPromise:i}=pt(e);return n.then(t=>ft(this,void 0,void 0,function*(){var n,i;this.app.clearCampaign(),this.app.dataFrame=t.df,yield this.app.setTemplate(e),this.app.campaignProps=t.campaignProps;const o=(null===(n=t.name)||void 0===n?void 0:n.trim())?null===(i=t.name)||void 0===i?void 0:i.trim():void 0;yield this.app.saveCampaign(!1,!0,{friendlyName:o}),e.layoutViewState&&this.app.campaign&&(this.app.campaign.layout=e.layoutViewState)})),i.then(()=>{this.init()}),t})}createNewTemplate(n){return ft(this,void 0,void 0,function*(){t.setUpdateIndicator(this.root,!0);try{const t=yield ht(this.app,n),i=new o.ViewBase,a=e.shell.v;i.name="New Template",i.root.appendChild(t.root),i.parentCall=this.app.parentCall,e.shell.addView(i),i.path=new URL(this.app.baseUrl).pathname+"/new-template";const{sub:r}=le(i,this.app.appName,T,()=>ft(this,void 0,void 0,function*(){e.shell.v=a,i.close()}));t.template.then(t=>ft(this,void 0,void 0,function*(){yield this.init(t),i.close(),ce(i),e.shell.v=a,r.unsubscribe()})),t.cancelPromise.then(()=>ft(this,void 0,void 0,function*(){r.unsubscribe(),i.close(),e.shell.v=a}))}finally{t.setUpdateIndicator(this.root,!1)}})}}class yt extends qe{constructor(e){var n;super(e),this.name="Submit",this.statusInput=t.input.string("Status",{value:null===(n=this.app.campaign)||void 0===n?void 0:n.status,nullable:!1}),this.statusSuggestionsMenu=o.Menu.popup(),this.statusInput.root.style.marginLeft="12px",this.content=t.div(),this.statusInput.onChanged.subscribe(()=>{var e,t,n,i;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!==(i=null===(n=this.statusInput.input)||void 0===n?void 0:n.offsetLeft)&&void 0!==i?i: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,n;return null!==(n=null!==(e=this.statusInput.value)&&void 0!==e?e:null===(t=this.app.campaign)||void 0===t?void 0:t.status)&&void 0!==n?n:"No Status"}render(){var e,n,i;this.statusInput.value=null!==(n=null===(e=this.app.campaign)||void 0===e?void 0:e.status)&&void 0!==n?n:"",t.empty(this.content),this.content=t.divV([t.h1("Summary"),t.div([t.tableFromMap(this.app.getSummary())]),this.statusInput.root]);const a=t.dialog("Submit");a.add(this.content),a.addButton("Save",()=>{this.app.campaign.status=this.getStatus(),this.app.saveCampaign(),a.close()}),a.show();const r=Array.from(new Set(o.Func.find({meta:{role:f}}).concat(o.Func.find({tags:[f]})))),s=r.reduce((e,t)=>{var n;return e[null!==(n=t.friendlyName)&&void 0!==n?n:t.name]=t,e},{});if(r.length>0){const e=this.app.submitParams,n=e?r.find(t=>t.name===e.fName&&ie(t)==e.package):void 0,o=null!==(i=null==n?void 0:n.friendlyName)&&void 0!==i?i:null==n?void 0:n.name,l=t.input.choice("Submit function",{value:o,items:[...Object.keys(s)],nullable:!0});l.onChanged.subscribe(()=>{var e,t;const n=s[null!==(e=l.value)&&void 0!==e?e:""];this.app.campaign.template.submit=n?{fName:n.name,package:ie(n)}:void 0,null===(t=a.getButton("Submit"))||void 0===t||t.remove(),n&&a.addButton("Submit",()=>{this.submit(),a.close()},void 0,"Submit the campaign file to the specified function")}),l.fireChanged(),this.content.appendChild(l.root)}}onActivated(){}submit(){return t=this,n=void 0,a=function*(){const t=this.app.submitParams;if(!t)return void e.shell.error("No submit function selected. Please select a function to submit the campaign.");const n=o.Func.find({name:t.fName,package:t.package})[0];if(!n)return void e.shell.error(`Function ${t.fName} not found.`);const i=o.DataFrame.fromCsv(this.app.dataFrame.toCsv({filteredRowsOnly:!0}));yield n.apply({df:i,molecules:this.app.molColName}),this.app.campaign.status=this.getStatus(),this.app.saveCampaign(),e.shell.info("Submitted successfully.")},new((i=void 0)||(i=Promise))(function(e,o){function r(e){try{l(a.next(e))}catch(e){o(e)}}function s(e){try{l(a.throw(e))}catch(e){o(e)}}function l(t){var n;t.done?e(t.value):(n=t.value,n instanceof i?n:new i(function(e){e(n)})).then(r,s)}l((a=a.apply(t,n||[])).next())});var t,n,i,a}}var At=n(542),wt={};wt.styleTagTransform=X(),wt.setAttributes=J(),wt.insert=W().bind(null,"head"),wt.domAPI=Y(),wt.insertStyleElement=K(),H()(At.A,wt),At.A&&At.A.locals&&At.A.locals;function Ct(n,i){var a,r,s,l,c,d,u,p,m,h;const v=null===(a=n.campaign)||void 0===a?void 0:a.tilesViewerFormSketch;let f=null;if(v&&v.length>0)try{f=JSON.parse(v)}catch(e){console.error("Failed to parse sketch state string",e)}f&&f.elementStates&&(null!==(r=f.elementStates.length)&&void 0!==r?r:0)>0&&(f.elementStates=f.elementStates.filter(e=>{var t;return(null===(t=null==e?void 0:e.viewerSettings)||void 0===t?void 0:t.column)&&n.dataFrame.col(e.viewerSettings.column)}),f.elementStates.forEach(e=>{var t;(null===(t=null==e?void 0:e.viewerSettings)||void 0===t?void 0:t.table)&&(e.viewerSettings.table=n.dataFrame.name)}));const g=Object.assign({lanesColumnName:y,lanes:n.stages},(null!==(l=null===(s=null==f?void 0:f.elementStates)||void 0===s?void 0:s.length)&&void 0!==l?l:0)>0?{sketchState:f}:{}),A=i();if(!A)return void e.shell.error("Failed to create tiles viewer. table view is not available.");let w=null;const C=t.dialog("Progress Tracker");try{w=A.addViewer(o.VIEWER.TILE_VIEWER,g);const e=w.getOptions();e.look.sketchState=(null!==(d=null===(c=null==f?void 0:f.elementStates)||void 0===c?void 0:c.length)&&void 0!==d?d:0)>0?f:null,w.setOptions(e),w.copyViewersLook(w)}catch(t){e.shell.error("Failed to create tiles viewer with preset layout.\n Falling back to default layout."),console.error("Failed to create tiles viewer",t),w&&(w.close(),w.detach()),w=A.addViewer(o.VIEWER.TILE_VIEWER,{lanesColumnName:y,lanes:n.stages})}if(!w)return void e.shell.error("Failed to create tiles viewer. check the console for more details.");let b=null;const E=()=>{try{w.detach(),w.close()}catch(e){}};C.add(w.root),C.addButton("Modify Stages",()=>{null==b||b.close();const o=vt(n.stages);b=t.dialog("Modify Stages").add(o.fieldsDiv).onOK(()=>{return a=this,r=void 0,l=function*(){E(),t.setUpdateIndicator(C.root,!0);try{yield n.setStages(o.getFields()),t.setUpdateIndicator(C.root,!1),C.close(),yield new Promise(e=>setTimeout(()=>{e(),Ct(n,i)},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==C?void 0:C.root)&&document.contains(C.root)&&C.close()}},new((s=void 0)||(s=Promise))(function(e,t){function n(e){try{o(l.next(e))}catch(e){t(e)}}function i(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 s?o:new s(function(e){e(o)})).then(n,i)}o((l=l.apply(a,r||[])).next())});var a,r,s,l}).show(),b.root.classList.add("hit-design-stage-editing-dialog")},0);const T=e.events.onCurrentViewChanged.subscribe(()=>{e.shell.v===A?C.root.style.display="flex":C.root.style.setProperty("display","none","important")}),x=null===(p=null===(u=n.dataFrame)||void 0===u?void 0:u.col(y))||void 0===p?void 0:p.version,S=C.onClose.subscribe(()=>{var t,i;S.unsubscribe(),T.unsubscribe(),null==b||b.close();try{const e=w.props.sketchState;if(e&&"object"==typeof e){const t=JSON.stringify(e);n.campaign&&(n.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)}E(),null!=x&&(null===(i=null===(t=n.dataFrame)||void 0===t?void 0:t.col(y))||void 0===i?void 0:i.version)!==x&&n.saveCampaign()});C.showModal(!0),null===(m=C.getButton("CANCEL"))||void 0===m||m.remove(),C.onOK(()=>{}),null===(h=document.querySelector(".d4-modal-background"))||void 0===h||h.remove()}const bt=rxjs.operators;var Et=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{l(i.next(e))}catch(e){a(e)}}function s(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}l((i=i.apply(e,t||[])).next())})};const Tt="defaultCampaignFolder",xt="System.AppData/HitTriage";function St(t){return Et(this,void 0,void 0,function*(){if(!t)return[yield e.dapi.groups.find(o.Group.defaultGroupsIds["All users"])].filter(Boolean);try{const n=JSON.parse(t);return(yield Promise.all(n.map(t=>e.dapi.groups.find(t)))).filter(Boolean)}catch(t){return console.error(t),[yield e.dapi.groups.find(o.Group.defaultGroupsIds["All users"])].filter(Boolean)}})}var Nt=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{l(i.next(e))}catch(e){a(e)}}function s(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}l((i=i.apply(e,t||[])).next())})};function Bt(e){var t;const n=null===(t=In.meta)||void 0===t?void 0:t.sok;if(!n)throw new Error("Secret key for SMILES obfuscation is not set");let i="";for(let t=0;t<e.length;t++){const o=e.charCodeAt(t),a=n.charCodeAt(t%n.length);i+=String.fromCharCode(o^a)}return btoa(i)}function It(){var e,t,n;const i=o.User.current();return null!==(n=null!==(t=null!==(e=null==i?void 0:i.login)&&void 0!==e?e:null==i?void 0:i.friendlyName)&&void 0!==t?t:i.name)&&void 0!==n?n:"unknown user"}function Ft(t,n,i){return Nt(this,void 0,void 0,function*(){const o=In.convertToSmiles(t);if(!o||""===o||"MALFORMED_INPUT_VALUE"===o)return"";const a=Bt(o),r=yield et.addMolecule(a,i,n,It());return 0!==r.rowCount&&r.col("vid")?r.col("vid").getString(0):(e.shell.error("Molecule registration returned no data"),"")})}function Pt(t,n,i){return Nt(this,void 0,void 0,function*(){const o=new Map,a=new Map;if(t.forEach((e,t)=>{const n=In.convertToSmiles(e);n&&""!==n&&"MALFORMED_INPUT_VALUE"!==n&&(a.has(n)||a.set(n,[]),a.get(n).push(t))}),0===a.size)return o;const r=Array.from(a.keys());for(let s=0;s<r.length;s+=50){const l=r.slice(s,s+50);if(0!==l.length)try{const e=l.map(e=>Bt(e)),r=yield et.addMolecules(e,i,n,It());if(!r||r.rowCount!==l.length||!r.col("vid"))throw console.error("Molecule registration returned incomplete data for batch",`${s}-${s+l.length}`,`Batch size: ${l.length}, Result rows: ${null==r?void 0:r.rowCount}. Vid column found: ${!!(null==r?void 0:r.col("vid"))}`),new Error("Resulting molecule registration has no or incomplete data");const c=r.col("vid").toList();for(let e=0;e<r.rowCount;e++){const n=a.get(l[e]),i=c[e];for(const e of n)o.set(t[e],i)}}catch(t){e.shell.error("Error registering molecules batch. see console for details."),In.logger.error(t)}}return o})}var Ot=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{l(i.next(e))}catch(e){a(e)}}function s(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}l((i=i.apply(e,t||[])).next())})};const _t=["molecule","smiles","mol","structure","canonical_smiles","canonicalsmiles"],kt=["v-id","vid","v_id"],Lt=["csv",...ot.molFileExtReaders.map(e=>e.ext)];function Vt(e){var t,n,i;const o=null===(t=e.extension)||void 0===t?void 0:t.toLowerCase();if(o)return o;const a=null!==(i=null===(n=e.name)||void 0===n?void 0:n.toLowerCase())&&void 0!==i?i:"",r=a.lastIndexOf(".");return r>=0?a.slice(r+1):""}function Mt(e){return Ot(this,void 0,void 0,function*(){const t=Vt(e);if("csv"===t){const t=yield e.readAsString();return o.DataFrame.fromCsv(t)}const n=ot.molFileExtReaders.find(e=>e.ext===t);if(!n)return null;const i=yield e.readAsBytes();if(!i)return null;const a=n.handlerFunc.inputs[0].name,r=yield n.handlerFunc.apply({[a]:i});return Array.isArray(r)?r[0]:r})}function $t(e){var t,n;const i=(null!==(t=e.fullPath)&&void 0!==t?t:"").toLowerCase(),o=(null!==(n=e.name)&&void 0!==n?n:"").toLowerCase();return!i||i===o}function Dt(e,t,n,i){try{if(e.type===t.type)return void e.set(n,t.get(i),!1);if(e.type===o.COLUMN_TYPE.STRING)return void e.set(n,t.getString(i),!1);const a=t.get(i);if(e.type===o.COLUMN_TYPE.INT)return void("number"==typeof a?e.set(n,Math.round(a),!1):"string"==typeof a&&a.length>0&&!isNaN(Number(a))&&e.set(n,Math.round(Number(a)),!1));if(e.type===o.COLUMN_TYPE.FLOAT)return void("number"==typeof a?e.set(n,a,!1):"string"==typeof a&&a.length>0&&!isNaN(Number(a))&&e.set(n,Number(a),!1));e.set(n,a,!1)}catch(o){In.logger.error(`Merge: failed to set ${e.name}[${n}] from ${t.name}[${i}]: ${o}`)}}function Rt(e,t){if(e.isNone(t))return!0;if(e.type===o.COLUMN_TYPE.STRING){const n=e.get(t);return""===n||null==n}return!1}function Ut(t,n,i){return Ot(this,void 0,void 0,function*(){var o,a,r,s,l,c,d,u,p;if(!t.dataFrame)throw new Error("Campaign has no data");const m=t.dataFrame,h=t.molColName,v=i.addNewRows&&!!i.molColName,f=i.runComputeOnNewRows&&v,{map:g}=function(e,t,n){const i=new Array(e.rowCount).fill(null),o=new Map;if("smiles"===n){const n=e.col(t);if(!n)throw new Error(`Campaign has no molecule column "${t}"`);for(let t=0;t<e.rowCount;t++){const e=n.get(t);if(!e)continue;const a=In.convertToSmiles(e);a&&"MALFORMED_INPUT_VALUE"!==a&&(i[t]=a,o.has(a)||o.set(a,t))}}else{const t=e.col(C);if(!t)throw new Error(`Campaign has no "${C}" column`);for(let n=0;n<e.rowCount;n++){const e=t.get(n);e&&(i[n]=e,o.has(e)||o.set(e,n))}}return{keys:i,map:o}}(m,h,i.mode),w=function(e,t){const n=new Array(e.rowCount).fill(null);if("smiles"===t.mode){const i=e.col(t.molColName);if(!i)throw new Error(`Incoming table has no column "${t.molColName}"`);for(let t=0;t<e.rowCount;t++){const e=i.get(t);if(!e)continue;const o=In.convertToSmiles(e);o&&"MALFORMED_INPUT_VALUE"!==o&&(n[t]=o)}}else{const i=e.col(t.vidColName);if(!i)throw new Error(`Incoming table has no column "${t.vidColName}"`);for(let t=0;t<e.rowCount;t++){const e=i.get(t);e&&(n[t]=String(e))}}return n}(n,i),b=[],E=[];for(let e=0;e<n.rowCount;e++){const t=w[e];if(!t)continue;const n=g.get(t);void 0!==n?b.push({campRow:n,incRow:e}):v&&E.push(e)}let T=null;if(f&&i.molColName&&E.length>0){const u=null!==(r=null===(a=null===(o=t.campaign)||void 0===o?void 0:o.template)||void 0===a?void 0:a.compute)&&void 0!==r?r:null===(s=t.template)||void 0===s?void 0:s.compute,p=n.col(i.molColName);if(u&&p){const t=E.map(e=>p.get(e)),n=u.descriptors.enabled&&null!==(l=u.descriptors.args)&&void 0!==l?l:[];try{T=yield lt(t,n,u.functions,null!==(c=u.scripts)&&void 0!==c?c:[],null!==(d=u.queries)&&void 0!==d?d:[])}catch(t){In.logger.error(t),e.shell.warning("Merge: compute pipeline failed; merging without computed columns.")}}}const x=function(e,t,n,i){const o=[];for(const t of e.columns.toList()){if("smiles"===i.mode&&t.name===C)continue;let e=t.name;i.molColName&&t.name===i.molColName&&(e=n),"vid"===i.mode&&i.vidColName&&t.name===i.vidColName&&(e=C),o.push({col:t,target:e,isComputed:!1})}if(t)for(const e of t.columns.toList())e.name!==A&&e.name!==n&&(o.some(t=>t.target===e.name)||o.push({col:e,target:e.name,isComputed:!0}));return o}(n,T,h,i),S=new Set;for(const e of x)if(!m.columns.contains(e.target)){const t=m.columns.addNew(e.target,e.col.type);e.col.semType&&(t.semType=e.col.semType),S.add(e.target)}t.isJoining=!0;try{for(const{campRow:e,incRow:t}of b)for(const n of x){if(n.isComputed)continue;if("smiles"===i.mode&&n.target===h)continue;if("vid"===i.mode&&n.target===C)continue;const o=m.col(n.target);if(!o)continue;const a=Rt(o,e);(S.has(n.target)||a||"overwrite"===i.clashStrategy)&&Dt(o,n.col,e,t)}const e=m.rowCount;if(E.length>0){const o=(null!==(p=null===(u=t.stages)||void 0===u?void 0:u.length)&&void 0!==p?p:0)>0&&m.columns.contains(y);for(let e=0;e<E.length;e++){const n=E[e];m.rows.addNew(null,!0);const i=m.rowCount-1;for(const t of x){const o=t.isComputed?e:n;Dt(m.col(t.target),t.col,i,o)}if(o){const e=m.col(y);Rt(e,i)&&e.set(i,t.stages[0],!1)}}if(i.molColName){const o=n.col(i.molColName),a=m.col(C);if(o&&a&&t.campaignId){const n=E.map(e=>o.get(e)).filter(e=>!!e&&""!==e);if(n.length>0)try{const i=yield Pt(n,t.campaignId,t.appName);for(let t=0;t<E.length;t++){const n=o.get(E[t]),r=n?i.get(n):void 0;r&&a.set(e+t,r,!1)}}catch(e){In.logger.error(e)}}}}}finally{setTimeout(()=>{t.isJoining=!1},500)}m.fireValuesChanged()})}var jt=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{l(i.next(e))}catch(e){a(e)}}function s(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}l((i=i.apply(e,t||[])).next())})};const Ht={smiles:"By canonical SMILES",vid:"By V-iD"},qt={skip:"Skip (keep campaign value)",overwrite:"Overwrite (use incoming value)"},Yt="(none)";function Gt(e,t,n){e.items=t,null!=n&&t.includes(n)?e.value=n:t.length>0?e.value=t[0]:e.value=null}var Wt=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{l(i.next(e))}catch(e){a(e)}}function s(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}l((i=i.apply(e,t||[])).next())})};class zt extends ot{get infoView(){return this._infoView}get version(){var e,t;return null!==(t=null===(e=this._campaign)||void 0===e?void 0:e.version)&&void 0!==t?t:0}constructor(e,t="Hit Design",n=e=>new gt(e)){super(e,t),this._designViewName="Design",this._filePath=`System.AppData/HitTriage/${this.appName}/campaigns`,this._molColName=A,this.campaignProps={},this.existingStatuses=[],this._refreshIconTooltip="Refresh Campaign",this._updateCheckIntervalId=null,this._needsRefresh=!1,this._lastExpiresTimeString=null,this._refreshCampaignIcon=null,this._gridSubs=null,this._isSaving=!1,this._infoView=n(this),this.multiView=new o.MultiView({viewFactories:{[this._infoView.name]:()=>this._infoView}}),this.multiView.subs.push(this.multiView.tabs.onTabChanged.subscribe(e=>{this.multiView.currentView instanceof qe&&this.multiView.currentView.onActivated()})),this.multiView.parentCall=e,this.mainView=this.multiView,this._initViewSubs()}handleJoiningDataframe(n){return Wt(this,void 0,void 0,function*(){var i;const a=n.columns.bySemTypeAll(o.SEMTYPE.MOLECULE);if(!a||0===a.length)return void e.shell.error("No molecule column found");let r=null;if(a.length>1){const n=a.map(e=>e.name),o=null!==(i=a.find(e=>{var t,n;return"smiles"===(null===(t=null==e?void 0:e.name)||void 0===t?void 0:t.toLowerCase())||"molecule"===(null===(n=null==e?void 0:e.name)||void 0===n?void 0:n.toLowerCase())}))&&void 0!==i?i:a[0],s=t.input.choice("Primary Molecule Column",{items:n,value:o.name,nullable:!1}),l=new Promise(e=>{t.dialog("Select Primary Molecule Column").add(t.divText("Multiple molecule columns found. Please select the primary molecule column to be used for calculations.")).add(s).onOK(()=>e(s.value)).onCancel(()=>e(null)).show()});if(r=yield l,!r)return void e.shell.info("Operation cancelled by user")}else r=a[0].name;n.col(r)?(yield Ut(this,n,{mode:"smiles",molColName:r,addNewRows:!0,runComputeOnNewRows:!0,clashStrategy:"overwrite"}),yield this.saveCampaign(!1)):e.shell.error("No molecule column found")})}get submitParams(){var e,t,n,i;return null!==(n=null===(t=null===(e=this.campaign)||void 0===e?void 0:e.template)||void 0===t?void 0:t.submit)&&void 0!==n?n:null===(i=this.template)||void 0===i?void 0:i.submit}_initViewSubs(){this.multiView.subs.push(e.events.onCurrentViewChanged.subscribe(()=>Wt(this,void 0,void 0,function*(){var t,n,i,o;try{if(e.shell.v===this._designView){e.shell.windows.showHelp=!1,this.setBaseUrl(),se(u,null!==(i=null!==(t=this._campaignId)&&void 0!==t?t:null===(n=this._campaign)||void 0===n?void 0:n.name)&&void 0!==i?i:"");const{sub:a}=le(e.shell.v,this.appName,null===(o=e.shell.v)||void 0===o?void 0:o.name,()=>{var t;e.shell.v=this.mainView,null===(t=this._designView)||void 0===t||t.close(),this._infoView.init(),a.unsubscribe()})}else e.shell.v===this.mainView&&this.setBaseUrl()}catch(e){console.error(e)}}))),this.multiView.subs.push(e.events.onFileImportRequest.subscribe(t=>{var n,i;if(!e.shell.tv||!this._designView||e.shell.tv!==this._designView)return;if(!(null===(n=null==t?void 0:t.args)||void 0===n?void 0:n.file))return;const o=t.args.file;((null===(i=o.name)||void 0===i?void 0:i.endsWith(".csv"))||ot.molFileExtReaders.some(e=>{var t;return null===(t=o.name)||void 0===t?void 0:t.endsWith(e.ext)}))&&(t.preventDefault(),this.handleUploadingDataframe(o))}))}handleUploadingDataframe(n){return Wt(this,void 0,void 0,function*(){var i;try{let a=null;if(n.name.endsWith(".csv"))a=o.DataFrame.fromCsv(yield n.text());else{const t=yield new Promise(e=>Wt(this,void 0,void 0,function*(){const t=new FileReader;let i=null,o=null;t.onload=()=>{o=t.result?new Uint8Array(t.result):null,i&&clearTimeout(i),e(o)},t.readAsArrayBuffer(n),i=setTimeout(()=>{t.abort(),e(null)},1e4)}));if(!t)return void e.shell.error("Failed to read file");const i=ot.molFileExtReaders.find(e=>n.name.endsWith(e.ext)).handlerFunc,o=i.inputs[0].name;a=(yield i.apply({[o]:t}))[0]}if(!a)throw new Error("Failed to read file");if(a.name=n.name.slice(0,n.name.lastIndexOf(".")),yield a.meta.detectSemanticTypes(),yield e.data.detectSemanticTypes(a),!a.columns.bySemType(o.SEMTYPE.MOLECULE))return void e.shell.addTableView(a);const r=t.dialog("Uploading table with molecules").add(t.divText("Add new table to workspace or join with existing Hit Design campaign")).addButton("Add to workspace",()=>{r.close(),e.shell.addTableView(a)}).addButton("Add to existing campaign",()=>{r.close(),this.handleJoiningDataframe(a)});null===(i=r.getButton("CANCEL"))||void 0===i||i.remove(),r.show()}catch(t){e.shell.error("Hit Design Failed to read file"),console.error(t)}})}get stages(){var e,t,n,i,o;return null!==(o=null!==(n=null===(t=null===(e=this.campaign)||void 0===e?void 0:e.template)||void 0===t?void 0:t.stages)&&void 0!==n?n:null===(i=this.template)||void 0===i?void 0:i.stages)&&void 0!==o?o:[]}setStages(t){return Wt(this,void 0,void 0,function*(){var n;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 i=null===(n=this.dataFrame)||void 0===n?void 0:n.col(y);if(!i)return void e.shell.error("No stage column found");const o=[],a=new Set(t),r=[...a],s=this.dataFrame.rowCount,l=i.categories,c=i.getRawData();for(let e=0;e<s;e++){const n=l[c[e]];a.has(n)||(i.set(e,t[0],!1),o.push(n))}o.length>0&&e.shell.warning(`Some stages were removed: (${o.join(", ")}). Corresponding rows were set to stage "${t[0]}"`),this.campaign.template.stages=r,this.template.stages=r,yield this.saveCampaign(!0)})}refreshCampaign(){return Wt(this,void 0,void 0,function*(){this._campaignId&&this.template?this._isSaving?e.shell.info("Campaign is being saved. Please wait a moment and try again."):(clearInterval(this._updateCheckIntervalId),this._refreshIconTooltip="Refresh Campaign",yield this.setTemplate(this.template,this._campaignId)):e.shell.warning("No campaign to refresh")})}setTemplate(n,i){return Wt(this,void 0,void 0,function*(){var a,r,s,l,c,d,h,v,f,g,y,w,C;if(i){const t=`System.AppData/HitTriage/${this.appName}/campaigns`;this._filePath=null!==(s=null===(r=this.campaign)||void 0===r?void 0:r.savePath)&&void 0!==s?s:`${t}/${i}/${m}`,this.dataFrame=yield e.dapi.files.readCsv(this._filePath),(null===(l=this._campaign)||void 0===l?void 0:l.columnSemTypes)&&Object.entries(this._campaign.columnSemTypes).forEach(([e,t])=>{const n=this.dataFrame.columns.byName(e);n&&t&&(n.semType=t)}),(null===(c=this._campaign)||void 0===c?void 0:c.columnTypes)&&Object.entries(this._campaign.columnTypes).forEach(([e,t])=>{const n=this.dataFrame.columns.byName(e);if(n&&n.type!==t)try{this.dataFrame.changeColumnType(e,t)}catch(e){console.error(e)}})}else{(null===(a=this._designView)||void 0===a?void 0:a.dataFrame)&&e.shell.closeTable(this._designView.dataFrame),this._designView=void 0,i=yield this.getNewCampaignName(`${this.appName}/campaigns`,n.key),se(p,i);let t=yield function(){return Et(this,void 0,void 0,function*(){var t,n;const i=null!==(t=In.settings)&&void 0!==t?t:yield In.getSettings();if(!i)return xt;const o=null!==(n=i instanceof Map?i.get(Tt):i[Tt])&&void 0!==n?n:xt;return(yield e.dapi.files.exists(o))?o:xt})}();t.endsWith("/")||(t+="/"),this._filePath=`${t}${this.appName}/campaigns/${i}/${m}`}if(!this.dataFrame)return e.shell.error("DataFrame is empty"),clearInterval(this._updateCheckIntervalId),void(this._updateCheckIntervalId=null);yield this.dataFrame.meta.detectSemanticTypes(),this._molColName=null!==(h=null===(d=this.dataFrame.columns.bySemType(o.SEMTYPE.MOLECULE))||void 0===d?void 0:d.name)&&void 0!==h?h:A,this._campaignId=i,this.template=n,null!==(v=this._submitView)&&void 0!==v||(this._submitView=new yt(this)),e.shell.windows.showHelp=!1,this.campaign?yield this.setCanEdit(this.campaign):this.hasEditPermission=!0,i&&(null===(g=null===(f=this.campaign)||void 0===f?void 0:f.mergeConfig)||void 0===g?void 0:g.autoMergeOnOpen)&&this.campaign.mergeConfig.filePath&&(yield function(t){return Ot(this,void 0,void 0,function*(){var n;const i=null===(n=t.campaign)||void 0===n?void 0:n.mergeConfig;if((null==i?void 0:i.autoMergeOnOpen)&&i.filePath&&t.dataFrame)try{if(!(yield e.dapi.files.exists(i.filePath)))return void e.shell.warning(`Auto-merge: source file not found or not accessible: ${i.filePath}`);const n=o.FileInfo.fromString(i.filePath,""),a=yield Mt(n);if(!a)return void e.shell.warning("Auto-merge: could not read the saved source file; merge skipped.");yield a.meta.detectSemanticTypes(),yield e.data.detectSemanticTypes(a);const r=Object.assign(Object.assign({},i),{runComputeOnNewRows:!1});yield Ut(t,a,r)}catch(t){In.logger.error(t),e.shell.warning("Auto-merge failed; opening the campaign without merging.")}})}(this)),i&&this.campaign&&(yield this.reComputeOnCampaignOpen());const b=this.designView;this.currentDesignViewId=b.name,this.setBaseUrl(),se(u,null!==(C=null!==(y=this._campaignId)&&void 0!==y?y:null===(w=this._campaign)||void 0===w?void 0:w.name)&&void 0!==C?C:""),this.campaign&&(this.campaign.template=n),et.getLastModified(this.appName,this._campaignId).then(n=>{var i;const o=null===(i=null==n?void 0:n.col("updated_at"))||void 0===i?void 0:i.getString(0);this._lastExpiresTimeString=null!=o?o:null,this._needsRefresh=!1,clearInterval(this._updateCheckIntervalId);let a=!1;this._updateCheckIntervalId=setInterval(()=>Wt(this,void 0,void 0,function*(){var n;if(!a&&!this._needsRefresh){if(a=!0,this._designView&&!Array.from(e.shell.tableViews).some(e=>e===this._designView))return clearInterval(this._updateCheckIntervalId),console.log("Clearing campaign update check interval"),this._updateCheckIntervalId=null,void(a=!1);if(this._campaignId&&this.template&&!this._isSaving&&!this.isJoining&&this._designView&&e.shell.v===this._designView){try{const e=yield et.getLastModified(this.appName,this._campaignId),i=null===(n=null==e?void 0:e.col("updated_at"))||void 0===n?void 0:n.getString(0);if(!i)return void(a=!1);this._lastExpiresTimeString!==i&&this._refreshCampaignIcon&&(this._lastExpiresTimeString=i,t.hints.addHintIndicator(this._refreshCampaignIcon,!0,1e4),this._refreshIconTooltip="New changes available. Click to refresh campaign.",this._lastExpiresTimeString=i,this._needsRefresh=!0)}catch(e){console.error(e)}a=!1}else a=!1}}),3e3)}).catch(e=>console.error(e))})}get campaignId(){return this._campaignId}get designView(){return this._designView=this.getDesignView()}get designViewName(){return this._designViewName}set designViewName(e){this._designViewName=e,this._designView&&(this._designView.name=e)}get molColName(){var e,t,n,i;return null!==(e=this._molColName)&&void 0!==e?e:this._molColName=null!==(i=null===(n=null===(t=this.dataFrame)||void 0===t?void 0:t.columns.bySemType(o.SEMTYPE.MOLECULE))||void 0===n?void 0:n.name)&&void 0!==i?i:A}get campaign(){return this._campaign}set campaign(e){this._campaign=e}clearCampaign(){this._campaign=void 0}cacheDuplicateVIDs(){var e;const t=null===(e=this.dataFrame)||void 0===e?void 0:e.col(C);if(!t)return void(this._duplicateVidCache=void 0);const n=t.version,i=new Uint32Array(t.categories.length).fill(0),o=t.getRawData().subarray(0,t.length);o.forEach(e=>i[e]++),this._duplicateVidCache={colVersion:n,valueCounts:i,indexes:o}}get duplicateVidCache(){var e;const t=null===(e=this.dataFrame)||void 0===e?void 0:e.col(C);if(t)return this._duplicateVidCache&&t.version===this._duplicateVidCache.colVersion||this.cacheDuplicateVIDs(),this._duplicateVidCache}performSingleCellCalculations(e,t){return Wt(this,void 0,void 0,function*(){const n=this.template.compute;if(!t||""===t)return;const i=yield lt([t],n.descriptors.args,n.functions,n.scripts,n.queries);for(const t of i.columns.toList())t.name!==A&&(this.dataFrame.columns.contains(t.name)||(this.dataFrame.columns.addNew(t.name,t.type).semType=t.semType),this.dataFrame.col(t.name).set(e,t.get(0),!1));this.dataFrame.fireValuesChanged(),this.saveCampaign(!1)})}reComputeOnCampaignOpen(){return Wt(this,void 0,void 0,function*(){var t,n,i,o;const a=null===(t=this.template)||void 0===t?void 0:t.compute;if(!a||!this.dataFrame||!this.molColName)return;const r=(null!==(n=a.functions)&&void 0!==n?n:[]).filter(e=>e.rerunOnOpen),s=(null!==(i=a.scripts)&&void 0!==i?i:[]).filter(e=>e.rerunOnOpen),l=(null!==(o=a.queries)&&void 0!==o?o:[]).filter(e=>e.rerunOnOpen);if(!r.length&&!s.length&&!l.length)return;const c=this.dataFrame.col(this.molColName);if(c)try{const e=c.toList(),t=yield lt(e,[],r,s,l);for(const e of t.columns.toList()){if(e.name===this.molColName||e.name===A)continue;let t=this.dataFrame.col(e.name);t&&t.type===e.type||(t&&this.dataFrame.columns.remove(e.name),t=this.dataFrame.columns.addNew(e.name,e.type)),t.semType=e.semType;const n=Math.min(e.length,t.length);for(let i=0;i<n;i++)t.set(i,e.isNone(i)?null:e.get(i),!1)}this.dataFrame.fireValuesChanged()}catch(t){In.logger.error(t),e.shell.warning("Re-run on open failed for some functions; opening the campaign anyway.")}})}initDesignViewRibbons(n,i,a=!1){var r,s,d;const u=e.events.onViewRemoved.subscribe(e=>{e.id===(null==n?void 0:n.id)&&(i.forEach(e=>e.unsubscribe()),u.unsubscribe())});let p=null==n?void 0:n.getRibbonPanels();if(p&&!de(p)){setTimeout(()=>{const{sub:t}=le(n,this.appName,n.name,()=>{e.shell.v=this.mainView,null==n||n.close(),this._infoView.init(),t.unsubscribe()})},1e3);const i=()=>Wt(this,void 0,void 0,function*(){var e;Ve(this,e=>Wt(this,void 0,void 0,function*(){var i,o,a,r,s,d,u,p,m,h;const v=this.template.compute.descriptors.args,f=this.template.compute.functions,g=null!==(i=this.template.compute.scripts)&&void 0!==i?i:[],y=null!==(o=this.template.compute.queries)&&void 0!==o?o:[],A=e.descriptors,w={descriptors:{enabled:!!(null===(a=null==e?void 0:e.descriptors)||void 0===a?void 0:a.length),args:null!==(r=null==e?void 0:e.descriptors)&&void 0!==r?r:[]},functions:Object.entries(null!==(s=null==e?void 0:e.externals)&&void 0!==s?s:{}).map(([t,n])=>{var i;const o=t.split(":");return{name:o[1],package:o[0],args:n,rerunOnOpen:!!(null===(i=null==e?void 0:e.rerunOnOpen)||void 0===i?void 0:i[t])}}),scripts:Object.entries(null!==(d=null==e?void 0:e.scripts)&&void 0!==d?d:{}).filter(([e,t])=>e.startsWith(l)&&3===e.split(":").length).map(([t,n])=>{var i,o,a;const r=t.split(":");return{name:null!==(i=r[1])&&void 0!==i?i:"",id:null!==(o=r[2])&&void 0!==o?o:"",args:n,rerunOnOpen:!!(null===(a=null==e?void 0:e.rerunOnOpen)||void 0===a?void 0:a[t])}}),queries:Object.entries(null!==(u=null==e?void 0:e.queries)&&void 0!==u?u:{}).filter(([e,t])=>e.startsWith(c)&&3===e.split(":").length).map(([t,n])=>{var i,o,a;const r=t.split(":");return{name:null!==(i=r[1])&&void 0!==i?i:"",id:null!==(o=r[2])&&void 0!==o?o:"",args:n,rerunOnOpen:!!(null===(a=null==e?void 0:e.rerunOnOpen)||void 0===a?void 0:a[t])}})};this.template.compute=w,this.campaign.template=this.template;const C=A.filter(e=>!v.includes(e)),b={};Object.entries(null!==(p=null==e?void 0:e.externals)&&void 0!==p?p:{}).filter(([e,t])=>{const n=f.find(t=>`${t.package}:${t.name}`===e);return!n||!Object.entries(t).every(([e,t])=>n.args[e]===t)}).forEach(([e,t])=>{b[e]=t});const E={};Object.entries(null!==(m=null==e?void 0:e.scripts)&&void 0!==m?m:{}).filter(([e,t])=>{const n=g.find(t=>`${l}:${t.name}:${t.id}`===e);return!n||!Object.entries(t).every(([e,t])=>n.args[e]===t)}).forEach(([e,t])=>{E[e]=t});const T={};Object.entries(null!==(h=null==e?void 0:e.queries)&&void 0!==h?h:{}).filter(([e,t])=>{const n=y.find(t=>`${c}:${t.name}:${t.id}`===e);return!n||!Object.entries(t).every(([e,t])=>n.args[e]===t)}).forEach(([e,t])=>{T[e]=t}),t.setUpdateIndicator(n.grid.root,!0);try{yield ct({descriptors:C,externals:b,scripts:E,queries:T},this.dataFrame,this.molColName),this.dataFrame.fireValuesChanged()}finally{t.setUpdateIndicator(n.grid.root,!1),this.saveCampaign(!1)}}),()=>null,null===(e=this.campaign)||void 0===e?void 0:e.template,!0,!0)}),u=t.iconFA("wrench",i,"Calculate additional properties"),m=t.iconFA("code-merge",()=>{!function(n){jt(this,void 0,void 0,function*(){var i,a,r,s,l,c;if(!n.dataFrame)return void e.shell.error("Cannot merge: campaign has no data.");const d=null===(i=n.campaign)||void 0===i?void 0:i.mergeConfig;let u=null,p=!1,m=!1;const h=t.input.file("Source file",{nullable:!0,tooltipText:`Pick a file from your computer or from a Datagrok file share.\nAllowed extensions: ${Lt.join(", ")}.\nFiles picked from a share are remembered with the campaign and reloaded automatically next time.`,onValueChanged:t=>function(t){return jt(this,void 0,void 0,function*(){if(m)return;if(!t)return u=null,I(null),void N();const n=Vt(t);if(!Lt.includes(n))return setTimeout(()=>{m=!0;try{h.value=null}finally{m=!1}N()},0),void e.shell.warning(`Unsupported file type ".${n||"?"}". Allowed: ${Lt.join(", ")}.`);yield B(t,null)})}(t)});h.input.setAttribute("placeholder",`Drop file or pick from share — ${Lt.join(", ")}`);const v=t.input.choice("Merge by",{items:Object.values(Ht),value:Ht[null!==(a=null==d?void 0:d.mode)&&void 0!==a?a:"vid"],nullable:!1,tooltipText:'Join key. "Canonical SMILES" matches by canonicalized molecule structure; "V-iD" matches by the campaign\'s V-iD identifier.',onValueChanged:()=>N()}),f=t.input.choice("Molecule column (incoming)",{items:[],value:null,nullable:!0,tooltipText:"Column in the incoming table holding the molecules. Required for SMILES merge. In V-iD merge it is optional — if set, unmatched rows can be added to the campaign and registered with new V-iDs.",onValueChanged:()=>N()}),g=t.input.choice("V-iD column (incoming)",{items:[],value:null,nullable:!0,tooltipText:"Column in the incoming table holding V-iD strings. Used as the join key when merging by V-iD.",onValueChanged:()=>N()}),y=t.input.bool("Add unmatched rows",{value:null===(r=null==d?void 0:d.addNewRows)||void 0===r||r,tooltipText:"When on, rows from the incoming table whose key is not present in the campaign are added as new rows. When off, only existing rows are updated. Disabled when no incoming molecule column is selected (nothing to register the new row with).",onValueChanged:()=>N()}),A=t.input.bool("Run compute on new rows",{value:null===(s=null==d?void 0:d.runComputeOnNewRows)||void 0===s||s,tooltipText:"Run the campaign's compute pipeline (descriptors, functions, scripts, queries) on the incoming molecules so new rows arrive with all calculated columns filled in. Disabled when no rows will be added.",onValueChanged:()=>N()}),w=t.input.choice("On clashing data",{items:Object.values(qt),value:qt[null!==(l=null==d?void 0:d.clashStrategy)&&void 0!==l?l:"overwrite"],nullable:!1,tooltipText:'How to resolve cells that have a value on both sides for a matched row. "Skip" keeps the existing campaign value; "Overwrite" replaces it with the incoming value. Empty campaign cells are always filled from the incoming table regardless of this setting.',onValueChanged:()=>N()}),C=t.input.bool("Auto-merge on campaign open",{value:null!==(c=null==d?void 0:d.autoMergeOnOpen)&&void 0!==c&&c,tooltipText:"When on, this file is re-read and merged into the campaign every time the campaign is opened, using the configuration below. Compute is never re-run for this implicit pass and the campaign is not auto-saved. Only available for files picked from a Datagrok file share — local uploads cannot be re-read on open.",onValueChanged:()=>N()}),E=t.divText("");E.style.color="var(--failure)",E.style.fontSize="12px",E.style.marginTop="8px",E.style.minHeight="16px";const T=t.divV([h.root,v.root,f.root,g.root,y.root,A.root,w.root,C.root,E]);T.style.minWidth="420px";const x=e=>e===Ht.vid?"vid":"smiles",S=e=>{const t=e.value;return t&&t!==Yt?t:void 0};function N(){const e=x(v.value),t=!!u&&!p;v.enabled=t,f.enabled=t,g.enabled=t&&"vid"===e,w.enabled=t;const n=S(f),i=S(g),o=t&&!!n;y.enabled=o;const a=o&&!0===y.value;A.enabled=a;const r=h.value,s=!!r&&!$t(r);C.enabled=s;let l="";p?l="Reading file…":t?"smiles"!==e||n?"vid"!==e||i||(l="Pick the V-iD column from the incoming table."):l="Pick the molecule column from the incoming table.":l="Pick a source file to merge from.",E.textContent=l,function(e){const t=F.getButton("OK");t&&(e?(t.removeAttribute("disabled"),t.classList.remove("disabled")):(t.setAttribute("disabled","true"),t.classList.add("disabled")))}(""===l)}function B(n,i){return jt(this,void 0,void 0,function*(){var o;p=!0,u=null,N(),t.setUpdateIndicator(T,!0,"Reading file...");try{const t=yield Mt(n);if(!t)throw new Error("Empty result");t.name=(null!==(o=n.name)&&void 0!==o?o:"").replace(/\.[^.]+$/,""),yield t.meta.detectSemanticTypes(),yield e.data.detectSemanticTypes(t),u=t}catch(t){In.logger.error(t),e.shell.error(`Failed to read "${n.name}". Check that the file is accessible and well-formed.`),u=null}finally{t.setUpdateIndicator(T,!1),p=!1}I(i),i&&function(e){var t;v.value=Ht[e.mode],y.value=e.addNewRows,A.value=e.runComputeOnNewRows,w.value=qt[e.clashStrategy],C.value=null!==(t=e.autoMergeOnOpen)&&void 0!==t&&t}(i),N()})}function I(e){var t,n,i,a,r,s;if(!u)return Gt(f,[]),void Gt(g,[]);const l=u.columns.toList().map(e=>e.name),c=null!==(i=null!==(t=null==e?void 0:e.molColName)&&void 0!==t?t:null===(n=function(e){var t;const n=e.columns.toList(),i=n.filter(e=>e.semType===o.SEMTYPE.MOLECULE);if(i.length>0){const e=i.find(e=>_t.includes(e.name.toLowerCase()));return null!=e?e:i[0]}return n.find(e=>_t.includes(e.name.toLowerCase()))||(null!==(t=n.find(e=>e.type===o.COLUMN_TYPE.STRING))&&void 0!==t?t:null)}(u))||void 0===n?void 0:n.name)&&void 0!==i?i:null,d=[Yt,...l];Gt(f,d,null!=c?c:Yt);const p=null!==(s=null!==(a=null==e?void 0:e.vidColName)&&void 0!==a?a:null===(r=function(e){const t=e.columns.toList();return t.find(e=>kt.includes(e.name.toLowerCase()))||t.find(e=>e.semType===b)||null}(u))||void 0===r?void 0:r.name)&&void 0!==s?s:null,m=[Yt,...l];Gt(g,m,null!=p?p:Yt)}const F=t.dialog("Merge with table");if(F.add(T),F.onOK(()=>jt(this,void 0,void 0,function*(){yield function(){return jt(this,void 0,void 0,function*(){if(!u)return;const t=x(v.value),i=S(f),a=S(g),r=h.value,s=r&&!$t(r)?r.fullPath:void 0,l={mode:t,filePath:s,molColName:i,vidColName:"vid"===t?a:void 0,addNewRows:!!y.value&&!!i,runComputeOnNewRows:!!A.value&&!!y.value&&!!i,clashStrategy:(d=w.value,d===qt.overwrite?"overwrite":"skip"),autoMergeOnOpen:!!C.value&&!!s},c=o.TaskBarProgressIndicator.create("Merging table into campaign...");var d;try{yield Ut(n,u,l),n.campaign&&(n.campaign.mergeConfig=l,yield n.saveCampaign(!1)),e.shell.info("Table merged into campaign.")}catch(t){In.logger.error(t),e.shell.error("Merge failed. See console for details.")}finally{c.close()}})}()})),F.show(),N(),null==d?void 0:d.filePath)try{if(yield e.dapi.files.exists(d.filePath)){const e=o.FileInfo.fromString(d.filePath,"");m=!0;try{h.value=e}finally{m=!1}yield B(e,d)}else e.shell.warning(`Saved merge file not found or not accessible: ${d.filePath}`)}catch(t){In.logger.error(t),e.shell.warning("Could not restore previously saved merge file.")}})}(this)},"Merge another table into the campaign"),h=t.icons.add(()=>{var e;null===(e=this.dataFrame)||void 0===e||e.rows.addNew(null,!0)},"Add new row"),v=t.iconSvg("view-layout",()=>{this.applyTemplateLayout(n)},"Apply template layout "+((null===(r=this.template)||void 0===r?void 0:r.localLayoutPath)?"(Loaded from mounted file storage)":"(Static)"));this._refreshCampaignIcon=t.icons.sync(()=>Wt(this,void 0,void 0,function*(){this.refreshCampaign()}),"Refresh"),t.tooltip.bind(this._refreshCampaignIcon,()=>this._refreshIconTooltip);const f=t.iconFA("share",()=>Wt(this,void 0,void 0,function*(){var e;yield new Qe(null===(e=this.campaign)||void 0===e?void 0:e.permissions).show(e=>{this.campaign.permissions=e,this.saveCampaign(!0)})}),"Edit campaign permissions"),g=t.bigButton("Progress tracker",()=>{Ct(this,()=>{var e;return null!==(e=this._designView)&&void 0!==e?e:null})}),y=t.bigButton("Submit...",()=>{var e;null===(e=this._submitView)||void 0===e||e.render()}),A=o.Func.find({meta:{role:"HitDesignerFunction"}}).filter(e=>1===e.outputs.length&&e.outputs[0].propertyType===o.TYPE.DATA_FRAME);y.classList.add("hit-design-submit-button");const w=[y];if(this.stages.length>0&&w.unshift(g),this.campaign&&this.template&&!this.campaign.template&&(this.campaign.template=this.template),((null===(s=this.template)||void 0===s?void 0:s.layoutViewState)||(null===(d=this.template)||void 0===d?void 0:d.localLayoutPath))&&w.unshift(v),this.hasEditPermission&&w.unshift(f),A.length>0&&a){const n=A[0],i=t.iconFA("pen-nib",()=>Wt(this,void 0,void 0,function*(){var i;const a={};if(n.inputs.length>0&&this.dataFrame&&this.dataFrame.currentRowIdx>=0&&n.inputs[0].semType===o.SEMTYPE.MOLECULE){const e=In.convertToSmiles(null===(i=this.dataFrame.col(this.molColName))||void 0===i?void 0:i.get(this.dataFrame.currentRowIdx));e&&(a[n.inputs[0].name]=e)}const r=n.prepare(a),s=yield r.getEditor();t.dialog(n.friendlyName).add(s).onOK(()=>Wt(this,void 0,void 0,function*(){const t=o.TaskBarProgressIndicator.create(`Running ${n.friendlyName}`);try{yield r.call();const i=r.getOutputParamValue();if(!i||!i.rowCount)return e.shell.warning(`${n.friendlyName} returned an empty result`),void t.close();yield i.meta.detectSemanticTypes(),yield e.data.detectSemanticTypes(i),yield this.handleJoiningDataframe(i)}catch(t){e.shell.error(`Failed to run ${n.friendlyName}`),In.logger.error(t)}finally{t.close()}})).show()}),n.description?n.description:n.friendlyName);w.unshift(i)}w.unshift(u),w.unshift(m),w.unshift(h),w.unshift(this._refreshCampaignIcon),p.push(w),p.some(e=>{var t;const n=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!==n&&(e.splice(n,1),!0)}),p=p.filter(e=>{var t;return(null!==(t=null==e?void 0:e.length)&&void 0!==t?t:0)>0}),n.setRibbonPanels(p)}return n}applyTemplateLayout(t){return Wt(this,void 0,void 0,function*(){var n,i;if(t){if(null===(n=this.template)||void 0===n?void 0:n.localLayoutPath)try{const n=yield e.dapi.files.readAsText(this.template.localLayoutPath),i=o.ViewLayout.fromJson(n);return void t.loadLayout(i)}catch(t){e.shell.error("Failed to apply layout from mounted file storage. Falling back to static layout"),In.logger.error(t)}if(null===(i=this.template)||void 0===i?void 0:i.layoutViewState)try{const e=o.ViewLayout.fromViewState(this.template.layoutViewState);t.loadLayout(e)}catch(t){e.shell.error("Failed to apply template layout. Check console for more details."),In.logger.error(t)}else e.shell.error("No layout found")}else e.shell.error("No view found")})}getDesignView(){var t,n,i,a,r,s,l;this._designView&&this._designView.close();const c=[],d=null===(t=this.dataFrame.col(this.molColName))||void 0===t?void 0:t.toList().every(e=>!e&&""===e),u=e.shell.addTableView(this.dataFrame);this._designViewName=null!==(r=null!==(i=null===(n=this.campaign)||void 0===n?void 0:n.friendlyName)&&void 0!==i?i:null===(a=this.campaign)||void 0===a?void 0:a.name)&&void 0!==r?r:this._designViewName,u.name=this._designViewName,u._onAdded();const p=null===(s=this._campaign)||void 0===s?void 0:s.layout;if(p)try{const e=o.ViewLayout.fromViewState(p);u.loadLayout(e)}catch(t){e.shell.error("Failed to apply layout. Falling back to default layout."),console.error(t)}this.checkGrid(u),d&&e.functions.call("Chem:editMoleculeCell",{cell:u.grid.cell(this._molColName,0)}),this.initGridSubs(u,c);const m=null===(l=u.grid)||void 0===l?void 0:l.col(C);m&&(m.editable=!1);const h=this.dataFrame.col(C);return h&&(h.semType=b,h.valueComparer=(e,t)=>e===t?0:null===e?-1:null===t?1:parseInt(e.substring(1))-parseInt(t.substring(1))),c.push(this.dataFrame.onRowsAdded.pipe((0,bt.filter)(()=>!this.isJoining)).subscribe(()=>{var t;try{if(this.stages.length>0)for(let e=0;e<this.dataFrame.rowCount;e++){const n=this.dataFrame.col(y).get(e);n&&""!==n&&!(null===(t=this.dataFrame.col(y))||void 0===t?void 0:t.isNone(e))||this.dataFrame.set(y,e,this.stages[0])}let n=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||(n=t))}n&&e.functions.call("Chem:editMoleculeCell",{cell:n})}catch(e){console.error(e)}})),c.push(e.events.onContextMenu.subscribe(t=>{var n,i,a,r,s,l,c,d,p,m,h,v;try{const e=null===(n=null==t?void 0:t.args)||void 0===n?void 0:n.context;if(!e)return;if((null==e?void 0:e.type)!==o.VIEWER.GRID)return;if(!e.tableView||e.tableView.id!==u.id)return;if((null===(r=null===(a=null===(i=null==t?void 0:t.args)||void 0===i?void 0:i.item)||void 0===a?void 0:a.tableColumn)||void 0===r?void 0:r.name)!==this.molColName||!(null===(l=null===(s=null==t?void 0:t.args)||void 0===s?void 0:s.item)||void 0===l?void 0:l.isTableCell))return;const f=null===(c=null==t?void 0:t.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,n,i,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===(i=null===(n=null===(e=null==t?void 0:t.args)||void 0===e?void 0:e.item)||void 0===n?void 0:n.cell)||void 0===i?void 0:i.value)&&void 0!==o?o:"")}catch(e){console.error(e)}});const g=null===(p=null===(d=null==t?void 0:t.args)||void 0===d?void 0:d.item)||void 0===p?void 0:p.tableRowIndex,y=null===(v=null===(h=null===(m=null==t?void 0:t.args)||void 0===m?void 0:m.item)||void 0===h?void 0:h.cell)||void 0===v?void 0:v.value;y&&(null!=g?g:-1)>-1&&f.item("Re-Run Calculations",()=>Wt(this,void 0,void 0,function*(){try{yield this.performSingleCellCalculations(g,y)}catch(e){console.error(e)}}))}catch(t){e.log.error(t)}})),c.push(e.events.onViewLayoutApplied.subscribe(e=>{e&&e.view===u&&this.initGridSubs(u,c)})),this.initDesignViewRibbons(u,c,!0),u.parentCall=this.parentCall,u}checkGrid(t){t.grid||(e.shell.error("Applied layout created view without grid. Resetting layout."),t.resetLayout())}initGridSubs(t,n){this._gridSubs&&this._gridSubs.grid===t.grid||(this._gridSubs&&this._gridSubs.subs.forEach(e=>e.unsubscribe()),this.checkGrid(t),t.grid?(this._gridSubs={grid:t.grid,subs:[]},(null==t?void 0:t.grid)&&this._gridSubs.subs.push(t.grid.onCellValueEdited.subscribe(t=>Wt(this,void 0,void 0,function*(){var n,i;try{if((null===(n=t.tableColumn)||void 0===n?void 0:n.name)===y)return void(yield this.saveCampaign(!1));if((null===(i=t.tableColumn)||void 0===i?void 0:i.name)!==this.molColName)return;const e=t.cell.value,o=t.tableRowIndex;if(e)try{const t=yield Ft(e,this._campaignId,this.appName);this.dataFrame.col(C).set(o,t,!0)}catch(e){console.error("Failed to register molecule")}yield this.performSingleCellCalculations(o,e)}catch(t){e.shell.error("Failed to process molecule edit, check console for details"),console.error(t)}}))),(null==t?void 0:t.grid)&&this._gridSubs.subs.push(t.grid.onCellRender.subscribe(e=>{var t;try{const n=e.cell,i=this.duplicateVidCache;if(!n||!n.isTableCell||!n.tableColumn||!i||n.tableColumn.name!==C||(null!==(t=n.tableRowIndex)&&void 0!==t?t:-1)<0)return;i.valueCounts[i.indexes[n.tableRowIndex]]>1&&(e.cell.style.backColor=o.Color.setAlpha(o.Color.getCategoricalColor(i.indexes[n.tableRowIndex]),150))}catch(e){}})),this._gridSubs.subs.forEach(e=>n.push(e))):e.shell.error("No grid found, cannot initialize grid subscriptions"))}getSummary(){var n,i,a,r,s,l,c,d,u,p,h,v,f;const g=()=>{var e,t;const n=this._filePath.indexOf(null!==(e=this.campaignId)&&void 0!==e?e:null===(t=this._campaign)||void 0===t?void 0:t.name);return-1===n?this._filePath:this._filePath.substring(0,n-1)},y=Object.assign({},null!==(i=null===(n=this.campaign)||void 0===n?void 0:n.campaignFields)&&void 0!==i?i:this.campaignProps);this.template&&this.template.campaignFields&&Object.entries(y).forEach(([t,n])=>{const i=this.template.campaignFields.find(e=>e.name===t);i&&"Date"===i.type&&n?"Invalid Date"!==new Date(n).toString()?y[t]=new Date(n).toLocaleDateString():n.date?y[t]=new Date(n.date).toLocaleDateString():y[t]=n:i&&i.type===o.SEMTYPE.MOLECULE&&n&&(y[t]=e.chem.drawMolecule(n))});const A=null!==(l=null!==(r=null===(a=this.campaign)||void 0===a?void 0:a.friendlyName)&&void 0!==r?r:null===(s=this.campaign)||void 0===s?void 0:s.name)&&void 0!==l?l:this.campaignId,w=function(n,i){var o;const a=t.icons.edit(()=>{var o,s,l,c,d;let u=null!==(s=null!==(o=null==i?void 0:i.tooltip)&&void 0!==o?o:n.textContent)&&void 0!==s?s:"";const p=null!==(l=null==i?void 0:i.beforeEditTextContent)&&void 0!==l?l:e=>e,m=null!==(c=null==i?void 0:i.afterEditTextContent)&&void 0!==c?c:e=>e,h=t.input.string("smth",{value:p(null!==(d=n.textContent)&&void 0!==d?d:""),onValueChanged:()=>ae(this,void 0,void 0,function*(){var e;const t=yield f();setTimeout(()=>{var e,o;if(t)return h.input.classList.add("d4-invalid"),void(u=t);h.input.classList.remove("d4-invalid"),u=null!==(o=null!==(e=null==i?void 0:i.tooltip)&&void 0!==e?e:n.textContent)&&void 0!==o?o:""},100),null===(e=null==i?void 0:i.onChange)||void 0===e||e.call(i,h.value)})});t.tooltip.bind(h.input,()=>u);const v=h.root.getElementsByTagName("label").item(0);v&&v.remove(),h.root.style.width="100%";const f=()=>ae(this,void 0,void 0,function*(){var e;const t=(null===(e=h.value)||void 0===e?void 0:e.trim())||(null==i?void 0:i.nullable)?null:"Field cannot be empty";return null!=t?t:(null==i?void 0:i.validator)?yield i.validator(h.value):null}),g=t.button("Save",()=>ae(this,void 0,void 0,function*(){var o,s;const l=yield f();l?e.shell.error(l):(yield null===(o=null==i?void 0:i.onOk)||void 0===o?void 0:o.call(i,h.value),n.textContent=null!==(s=m(h.value))&&void 0!==s?s:"",t.empty(r),r.appendChild(n),r.appendChild(a))})),y=t.button("Cancel",()=>{var e;t.empty(r),r.appendChild(n),r.appendChild(a),null===(e=null==i?void 0:i.onCancel)||void 0===e||e.call(i)});t.empty(r),h.addOptions(y),h.addOptions(g),r.appendChild(h.root),h.input.focus()},null!==(o=null==i?void 0:i.tooltip)&&void 0!==o?o:"Edit"),r=t.divH([n,a],{style:{display:"flex",alignItems:"center"}});return a.style.marginLeft="5px",r}(t.divText(A),{tooltip:"Edit Campaign Name",nullable:!1,onOk:e=>Wt(this,void 0,void 0,function*(){this.campaign.friendlyName=e,yield this.saveCampaign(!0)}),validator:e=>Wt(this,void 0,void 0,function*(){return(null==e?void 0:e.trim())?null:"Campaign name can not be empty"})});return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({Name:w,Code:null!==(c=this.campaignId)&&void 0!==c?c:null===(d=this._campaign)||void 0===d?void 0:d.name,Template:null!==(p=null===(u=this.template)||void 0===u?void 0:u.name)&&void 0!==p?p:"Molecules","File Path":(()=>{const n=t.icons.edit(()=>{const i=g(),r=t.input.string("Path",{value:i}),s=r.root.getElementsByTagName("label").item(0);s&&s.remove(),r.root.style.width="100%";const l=t.button("Save",()=>Wt(this,void 0,void 0,function*(){if(!(yield function(t){return ae(this,void 0,void 0,function*(){return t&&""!==t.trim()?!!(yield e.dapi.files.exists(t))||(e.shell.error("Given folder does not exist"),!1):(e.shell.error("Path can not be empty"),!1)})}(r.value)))return;const i=r.value;i.endsWith("/")?this._filePath=`${i}${this.campaignId}/${m}`:this._filePath=`${i}/${this.campaignId}/${m}`,this._campaign&&(this._campaign.savePath=this._filePath),yield this.saveCampaign(!0),t.empty(a);const s=g();o=t.link(s,()=>{var e,t,n;return this.download(this.dataFrame,null!==(n=null!==(e=this.campaignId)&&void 0!==e?e:null===(t=this._campaign)||void 0===t?void 0:t.name)&&void 0!==n?n:"Molecules")},N),a.appendChild(o),a.appendChild(n)})),c=t.button("Cancel",()=>{t.empty(a),a.appendChild(o),a.appendChild(n)});t.empty(a),r.addOptions(c),r.addOptions(l),a.appendChild(r.root),r.input.focus()},"Edit file path");n.style.marginLeft="5px";const i=g();let o=t.link(i,()=>{var e,t,n;return this.download(this.dataFrame,null!==(n=null!==(e=this.campaignId)&&void 0!==e?e:null===(t=this._campaign)||void 0===t?void 0:t.name)&&void 0!==n?n:"Molecules")},N);const a=t.divH([o,n],{style:{alignItems:"center"}});return a})()},(null===(h=this.campaign)||void 0===h?void 0:h.authorUserFriendlyName)?{Author:this.campaign.authorUserFriendlyName}:{}),(null===(v=this.campaign)||void 0===v?void 0:v.lastModifiedUserName)?{"Last Modified By":this.campaign.lastModifiedUserName}:{}),(null===(f=this.campaign)||void 0===f?void 0:f.createDate)?{"Create Date":this.campaign.createDate}:{}),y),{"Number of Molecules":this.dataFrame.rowCount.toString(),"Enrichment Methods":[this.template.compute.descriptors.enabled?"descriptors":"",...this.template.compute.functions.map(e=>e.name)].filter(e=>e&&""!==e.trim()).join(", ")})}saveCampaign(){return Wt(this,arguments,void 0,function*(n=!0,i=!1,a){var r,s,l,c,d,u,p,m,v,f,g,y,A,w,C,b,E,T,x,S,N,B,I,F,P,O;this._isSaving=!0;const _=this.campaignId,k=setTimeout(()=>{var e;(null===(e=this._designView)||void 0===e?void 0:e.grid)&&t.setUpdateIndicator(this._designView.grid.root,!0,"Someone else is saving the campaign. Please wait...")},500);try{const e=yield this.aquireAndWaitCampaignLock(_);if(!(null==e?void 0:e.aquired))throw new Error("Could not acquire lock for campaign during 30 seconds")}catch(n){return clearTimeout(k),(null===(r=this._designView)||void 0===r?void 0:r.grid)&&t.setUpdateIndicator(this._designView.grid.root,!1),e.shell.error("Failed to acquire campaign lock. Someone else might be editing the campaign. Please try again later."),this._isSaving=!1,this.campaign}clearTimeout(k),(null===(s=this._designView)||void 0===s?void 0:s.grid)&&t.setUpdateIndicator(this._designView.grid.root,!0,"Saving Campaign...");const L=this.template.name,V=this.dataFrame,M=_,$={};V.columns.toList().forEach(e=>$[e.name]=e.semType);const D={};V.columns.toList().forEach(e=>D[e.name]=e.type);const R=null!==(c=null===(l=this.campaign)||void 0===l?void 0:l.tilesViewerFormSketch)&&void 0!==c?c:void 0,U=null!==(u=null===(d=this.campaign)||void 0===d?void 0:d.authorUserId)&&void 0!==u?u:e.shell.user.id,j=null!==(m=null===(p=this.campaign)||void 0===p?void 0:p.permissions)&&void 0!==m?m:yield(()=>Wt(this,void 0,void 0,function*(){try{const e=yield function(){return Et(this,void 0,void 0,function*(){var e,t,n,i,o;try{const a=null!==(e=In.settings)&&void 0!==e?e:yield In.getSettings(),r={view:[],edit:[]};return a?(a instanceof Map?(r.view=yield St(null!==(t=a.get("view"))&&void 0!==t?t:""),r.edit=yield St(null!==(n=a.get("edit"))&&void 0!==n?n:"")):(r.view=yield St(null!==(i=a.view)&&void 0!==i?i:""),r.edit=yield St(null!==(o=a.edit)&&void 0!==o?o:"")),r):r}catch(e){return console.error(e),{view:[],edit:[]}}})}(),t={view:e.view.map(e=>e.id),edit:e.edit.map(e=>e.id)};return 0===t.edit.length&&(t.edit=[Je.edit[0]]),0===t.view.length&&(t.view=[Je.view[0]]),t}catch(t){e.shell.error("Failed to get default permissions"),console.error(t)}return Je}))(),H=U?null!==(f=null===(v=this.campaign)||void 0===v?void 0:v.authorUserFriendlyName)&&void 0!==f?f:null===(g=yield e.dapi.users.find(U))||void 0===g?void 0:g.friendlyName:void 0,q={name:M,friendlyName:null!==(w=null!==(A=null===(y=this.campaign)||void 0===y?void 0:y.friendlyName)&&void 0!==A?A:null==a?void 0:a.friendlyName)&&void 0!==w?w:M,templateName:L,status:null!==(b=null===(C=this.campaign)||void 0===C?void 0:C.status)&&void 0!==b?b:"In Progress",createDate:null!==(T=null===(E=this.campaign)||void 0===E?void 0:E.createDate)&&void 0!==T?T:re(new Date),campaignFields:null!==(S=null===(x=this.campaign)||void 0===x?void 0:x.campaignFields)&&void 0!==S?S:this.campaignProps,columnSemTypes:$,rowCount:V.rowCount,filteredRowCount:V.filter.trueCount,savePath:this._filePath,columnTypes:D,tilesViewerFormSketch:R,version:this.version+1,authorUserId:U,authorUserFriendlyName:H,lastModifiedUserName:e.shell.user.friendlyName,permissions:j,mergeConfig:null===(N=this.campaign)||void 0===N?void 0:N.mergeConfig};if(!this.hasEditPermission)return e.shell.error("You do not have permission to modify this campaign"),(null===(B=this._designView)||void 0===B?void 0:B.grid)&&t.setUpdateIndicator(this._designView.grid.root,!1),yield this.releaseCampaignLock(_),this._isSaving=!1,q;const Y=`${this.appName}/campaigns/${_}/${h}`;let G=V;if(yield In.files.exists(Y)){const t=JSON.parse(yield In.files.readAsText(Y));if((null!==(I=t.version)&&void 0!==I?I:0)>this.version&&(q.version=Math.max(this.version,null!==(F=t.version)&&void 0!==F?F:0)+1,yield e.dapi.files.exists(this._filePath)))try{const t=yield e.dapi.files.readCsv(this._filePath);G=this.unionDataframes(t,V,this.molColName,this.molColName)}catch(e){console.error(e)}}const W=o.DataFrame.fromColumns(G.columns.toList().filter(e=>!e.name.startsWith("~"))).toCsv();yield e.dapi.files.writeAsText(this._filePath,W);const z=this._designView.saveLayout();z?q.layout=z.viewState:e.shell.warning("Layout cound not be saved"),q.template=this.template,yield In.saveCampaignJson(this.appName,q),n&&e.shell.info("Campaign saved successfully."),!n&&i&&e.shell.info("Campaign created successfully."),this.campaign=q,this.designViewName=null!==(P=q.friendlyName)&&void 0!==P?P:q.name;const J=yield this.releaseCampaignLock(_);return this._lastExpiresTimeString=J,(null===(O=this._designView)||void 0===O?void 0:O.grid)&&t.setUpdateIndicator(this._designView.grid.root,!1),this._isSaving=!1,this._refreshIconTooltip="Refresh Campaign",q})}}class Jt extends o.GridCellRenderer{get name(){return"customGasteigerPNG"}get cellType(){return"customGasteigerPNG"}get defaultHeight(){return 200}get defaultWidth(){return 200}render(e,t,n,i,o,a,r){if(a.gridRow<0||!a.cell.value)return;const s=a.cell.value,l=new Image(i-2,o-2);l.src="data:image/png;base64,"+s,l.onload=function(){e.drawImage(l,t+2,n+2,i-2,o-2)}}}var Qt=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{l(i.next(e))}catch(e){a(e)}}function s(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}l((i=i.apply(e,t||[])).next())})};class Kt extends gt{constructor(t){super(t),this.name="PeptiHit",e.shell.windows.showHelp=!0,e.shell.windows.help.showHelp(In.webRoot+"README_HD.md")}getNewCampaignAccordeon(e){return Qt(this,void 0,void 0,function*(){const{root:t,promise:n,cancelPromise:i}=pt(e,!0);return n.then(t=>Qt(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)})),i.then(()=>{this.init()}),t})}getAppHeader(){return We.appHeader({iconPath:In.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 Zt=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{l(i.next(e))}catch(e){a(e)}}function s(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}l((i=i.apply(e,t||[])).next())})};class Xt extends zt{constructor(e){super(e,"PeptiHit",e=>new Kt(e)),this._helmColName=w}setTemplate(e,t){const n=Object.create(null,{setTemplate:{get:()=>super.setTemplate}});return Zt(this,void 0,void 0,function*(){var i,a;yield n.setTemplate.call(this,e,t),this._helmColName=null!==(a=null===(i=this.dataFrame.columns.bySemType(o.SEMTYPE.MACROMOLECULE))||void 0===i?void 0:i.name)&&void 0!==a?a:w})}get helmColName(){var e,t;return null!==(e=this._helmColName)&&void 0!==e?e:null===(t=this.dataFrame.columns.bySemType(o.SEMTYPE.MACROMOLECULE))||void 0===t?void 0:t.name}performSingleCellCalculations(t,n){const i=Object.create(null,{performSingleCellCalculations:{get:()=>super.performSingleCellCalculations}});return Zt(this,void 0,void 0,function*(){var a;try{if(!n)throw new Error("No cell value provided");const r=o.Column.fromStrings(this.helmColName,[n]),s=o.DataFrame.fromColumns([r]);r.semType=o.SEMTYPE.MACROMOLECULE,r.setTag("units","helm"),r.setTag(".alphabetIsMultichar","true"),yield e.functions.call("Bio:toAtomicLevel",{table:s,seqCol:r,nonlinear:!0});const l=s.columns.names().find(e=>e.toLowerCase()!==this.helmColName.toLowerCase()),c=l?null===(a=s.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,t,c),yield i.performSingleCellCalculations.call(this,t,c)}catch(e){console.error(e)}})}getDesignView(){var t,n,i,a,r,s,l;const c=[],d=null===(t=this.dataFrame.col(this.helmColName))||void 0===t?void 0:t.toList().every(e=>!e&&""===e),u=this.dataFrame.col(this.helmColName);if(!u)throw new Error("No helm column found");u.semType=o.SEMTYPE.MACROMOLECULE,u.setTag("units","helm"),u.setTag(".alphabetIsMultichar","true"),u.setTag("cell.renderer","helm");const p=e.shell.addTableView(this.dataFrame);this._designViewName=null!==(i=null===(n=this.campaign)||void 0===n?void 0:n.name)&&void 0!==i?i:this._designViewName,p.name=this._designViewName,p._onAdded();const m=null!==(r=null===(a=this._campaign)||void 0===a?void 0:a.layout)&&void 0!==r?r:null===(s=this.template)||void 0===s?void 0:s.layoutViewState;if(m)try{const e=o.ViewLayout.fromViewState(m);p.loadLayout(e)}catch(t){e.shell.error("Failed to apply layout. Falling back to default layout."),console.error(t)}const h=null===(l=p.grid)||void 0===l?void 0:l.col(C);h&&(h.editable=!1);const v=this.dataFrame.col(C);return v&&(v.semType=b,v.valueComparer=(e,t)=>e===t?0:null===e?-1:null===t?1:parseInt(e.substring(1))-parseInt(t.substring(1))),d&&e.functions.call("Helm:editMoleculeCell",{cell:p.grid.cell(this.helmColName,0)}),c.push(this.dataFrame.onRowsAdded.pipe((0,bt.filter)(()=>!this.isJoining)).subscribe(()=>{var t;try{if(this.stages.length>0)for(let e=0;e<this.dataFrame.rowCount;e++){const n=this.dataFrame.col(y).get(e);n&&""!==n&&!(null===(t=this.dataFrame.col(y))||void 0===t?void 0:t.isNone(e))||this.dataFrame.set(y,e,this.stages[0])}let n=null;for(let e=0;e<this.dataFrame.rowCount;e++){const t=p.grid.cell(this.helmColName,e);t&&(""!==t.cell.value&&null!==t.cell.value||(n=t))}n&&e.functions.call("Helm:editMoleculeCell",{cell:n})}catch(e){console.error(e)}})),c.push(e.events.onContextMenu.subscribe(t=>{var n,i,a,r,s,l,c,d,u,m,h,v;try{const e=null===(n=null==t?void 0:t.args)||void 0===n?void 0:n.context;if(!e)return;if((null==e?void 0:e.type)!==o.VIEWER.GRID)return;if(!e.tableView||e.tableView.id!==p.id)return;if((null===(r=null===(a=null===(i=null==t?void 0:t.args)||void 0===i?void 0:i.item)||void 0===a?void 0:a.tableColumn)||void 0===r?void 0:r.name)!==this.helmColName||!(null===(l=null===(s=null==t?void 0:t.args)||void 0===s?void 0:s.item)||void 0===l?void 0:l.isTableCell))return;const f=null===(c=null==t?void 0:t.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,n,i,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===(i=null===(n=null===(e=null==t?void 0:t.args)||void 0===e?void 0:e.item)||void 0===n?void 0:n.cell)||void 0===i?void 0:i.value)&&void 0!==o?o:"")}catch(e){console.error(e)}});const g=null===(u=null===(d=null==t?void 0:t.args)||void 0===d?void 0:d.item)||void 0===u?void 0:u.tableRowIndex,y=null===(v=null===(h=null===(m=null==t?void 0:t.args)||void 0===m?void 0:m.item)||void 0===h?void 0:h.cell)||void 0===v?void 0:v.value;y&&(null!=g?g:-1)>-1&&f.item("Re-Run Calculations",()=>Zt(this,void 0,void 0,function*(){try{yield this.performSingleCellCalculations(g,y)}catch(e){console.error(e)}}))}catch(t){e.log.error(t)}})),(null==p?void 0:p.grid)||(e.shell.error("Applied layout created view without grid. Resetting layout."),p.resetLayout()),(null==p?void 0:p.grid)&&c.push(p.grid.onCellValueEdited.subscribe(t=>Zt(this,void 0,void 0,function*(){var n,i;try{if((null===(n=t.tableColumn)||void 0===n?void 0:n.name)===y)return void(yield this.saveCampaign(!1));if((null===(i=t.tableColumn)||void 0===i?void 0:i.name)!==this.helmColName)return;const e=t.cell.value,o=t.tableRowIndex;yield this.performSingleCellCalculations(o,e);try{const e=this.dataFrame.col(this.molColName).get(o),t=yield Ft(null!=e?e:"",this.campaignId,this.appName);t&&this.dataFrame.col(C).set(o,t,!0)}catch(e){console.error("Error updating V-iD column:",e)}}catch(t){e.shell.error("Error performing cell calculations: "+t),console.error(t)}}))),(null==p?void 0:p.grid)&&c.push(p.grid.onCellRender.subscribe(e=>{var t;try{const n=this.duplicateVidCache,i=e.cell;if(!i||!i.isTableCell||!i.tableColumn||!n||i.tableColumn.name!==C||(null!==(t=i.tableRowIndex)&&void 0!==t?t:-1)<0)return;n.valueCounts[n.indexes[i.tableRowIndex]]>1&&(e.cell.style.backColor=o.Color.setAlpha(o.Color.getCategoricalColor(n.indexes[i.tableRowIndex]),150))}catch(e){}})),this.initDesignViewRibbons(p,c),p.parentCall=this.parentCall,p}}var en=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{l(i.next(e))}catch(e){a(e)}}function s(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}l((i=i.apply(e,t||[])).next())})};var tn=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{l(i.next(e))}catch(e){a(e)}}function s(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}l((i=i.apply(e,t||[])).next())})};class nn extends Ze{constructor(t){super(t),this.pepTriageDataSourceFunctionsMap={},this.name="PepTriage",e.shell.windows.showHelp=!0,e.shell.windows.help.showHelp(In.webRoot+"README_HT.md")}onActivated(){e.shell.windows.showHelp=!0,e.shell.windows.help.showHelp(In.webRoot+"README_HT.md")}getAppHeader(){return We.appHeader({iconPath:In.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- Load sequence datasets and auto-convert to molecules\n- Calculate different molecular properties\n- Filter sequences using different criteria\n- Save campaigns and continue any time from where you left off\n- Submit final selection to the function of your choice"})}getTemplatesFolder(){return`${this.app.appName}/templates`}getDataSourceTag(){return U}getDataSourceFunctionsMap(){return this.pepTriageDataSourceFunctionsMap}getNewCampaignAccordeon(e,n){return tn(this,void 0,void 0,function*(){var i,o;const a=e,r=t.input.string("Sequence Column",{value:null!==(i=a.sequenceColumnName)&&void 0!==i?i:"",nullable:!1});r.setTooltip("Name of the sequence column in the dataset");const s=t.input.string("Molecule Column",{value:null!==(o=a.moleculeColumnName)&&void 0!==o?o:"",nullable:!0});s.setTooltip("Name of the molecule column (leave empty to auto-convert from sequences)"),t.setUpdateIndicator(n,!0);const{root:l,promise:c,cancelPromise:d}=yield Fe(e,this.getDataSourceFunctionsMap(),this.getDataSourceTag(),{extraFormElements:[r.root,s.root],getExtraData:()=>{var e,t;return{sequenceColumnName:(null===(e=r.value)||void 0===e?void 0:e.trim())||a.sequenceColumnName,moleculeColumnName:(null===(t=s.value)||void 0===t?void 0:t.trim())||void 0}}});return t.setUpdateIndicator(n,!1),c.then(e=>tn(this,void 0,void 0,function*(){var t,n,i,o;const r=Object.assign(Object.assign({},a),{sequenceColumnName:null!==(n=null===(t=e.extraData)||void 0===t?void 0:t.sequenceColumnName)&&void 0!==n?n:a.sequenceColumnName,moleculeColumnName:null!==(o=null===(i=e.extraData)||void 0===i?void 0:i.moleculeColumnName)&&void 0!==o?o:a.moleculeColumnName});this.app.dataFrame=e.df,this.app._fileInputType=e.type,yield this.app.setTemplate(r,void 0,void 0,void 0,e.friendlyName),this.app.campaignProps=e.campaignProps,yield this.app.saveCampaign(void 0,!1),r.layoutViewState&&this.app.campaign&&(this.app.campaign.layout=r.layoutViewState)})),d.then(()=>{this.init()}),l})}createNewTemplate(n){return tn(this,void 0,void 0,function*(){const i=yield function(n,i,a){return en(this,void 0,void 0,function*(){var r,s,d,u,p;const m=`${n.appName}/templates`,h=(yield In.files.list(m)).filter(e=>e.name.endsWith(".json")).map(e=>e.name.slice(0,-5)),v=[];for(const e of h){const t=yield Ne(`${m}/${e}.json`);v.push(t.key)}const g=Array.from(new Set(o.Func.find({meta:{role:f}}).concat(o.Func.find({tags:[f]})))),y={};g.forEach(e=>{var t;y[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e});const A=(null==a?void 0:a.submit)?Object.keys(y).find(e=>{var t,n;return(null===(t=y[e])||void 0===t?void 0:t.name)===(null===(n=a.submit)||void 0===n?void 0:n.fName)}):null,w=t.input.choice("Submit function",{value:null!=A?A:null,items:[null,...Object.keys(y)]});A||(w.value=null),w.nullable=!0,w.fireChanged(),w.setTooltip("Select function to be called upon submitting");const C=De(),b=t.divText("Template name is empty or already exists",{classes:"hit-triage-error-div"}),T=t.divText("Template key is empty or already exists",{classes:"hit-triage-error-div"}),x=t.input.string("Name",{value:a?`${a.name} (copy)`:"",onValueChanged:e=>{""===e||h.includes(e)?(x.root.style.borderBottom="1px solid red",b.style.opacity="100%"):(x.root.style.borderBottom="none",b.style.opacity="0%")}}),N=t.input.string("Key",{value:a?`${a.key}-copy`:"",onValueChanged:e=>{""===e||v.includes(e)?(N.root.style.borderBottom="1px solid red",T.style.opacity="100%"):(N.root.style.borderBottom="none",T.style.opacity="0%")}});N.setTooltip("Template key used for campaign prefix"),x.setTooltip("Template name"),x.root.style.borderBottom="none",N.root.style.borderBottom="none",b.style.opacity="0%",T.style.opacity="0%";const I=t.input.string("Sequence Column",{value:null!==(r=null==a?void 0:a.sequenceColumnName)&&void 0!==r?r:"",nullable:!1});I.setTooltip("Name of the sequence column in the dataset (mandatory)");const F=t.divText("Sequence column name is required",{classes:"hit-triage-error-div"});F.style.opacity="0%",I.onChanged.subscribe(()=>{var e;(null===(e=I.value)||void 0===e?void 0:e.trim())?(I.root.style.borderBottom="none",F.style.opacity="0%"):(I.root.style.borderBottom="1px solid red",F.style.opacity="100%")});const P=t.input.string("Molecule Column",{value:null!==(s=null==a?void 0:a.moleculeColumnName)&&void 0!==s?s:"",nullable:!0});P.setTooltip("Name of the molecule column (optional). If empty, sequences will be auto-converted to molecules.");let O=null;const _=a||{compute:{descriptors:{enabled:!0,args:[]},functions:[]}},k=yield Ve(n,e=>{O=e},()=>null,_,!1);k.root.classList.add("hit-triage-new-template-functions-input"),0===Object.entries(i).length&&Array.from(new Set(o.Func.find({meta:{role:U}}).concat(o.Func.find({tags:[U]})))).forEach(e=>{var t;i[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e});const L=Object.keys(i),V=t.input.choice(E,{value:L[0],items:L}),M=t.input.choice("Ingest using",{value:null!==(d=null==a?void 0:a.dataSourceType)&&void 0!==d?d:"Query",items:["Query","File"],onValueChanged:e=>{V.root.style.display="Query"===e?"block":"none"}});(null==a?void 0:a.dataSourceType)&&(V.root.style.display="Query"===a.dataSourceType?"block":"none");const $=je(null==a?void 0:a.campaignFields),D=t.div([t.h2("Details"),t.div([x,b]),t.div([N,T]),t.h2("Sequence Configuration"),t.div([I,F]),P.root,t.h2("Data Ingestion"),M.root,V.root,C.dataFileInput,$.fieldsDiv,t.h2("Compute"),k.root,t.h2("Submit"),w.root],"ui-form"),R=t.buttonsInput([]),j=null!==(p=null===(u=R.getElementsByClassName("ui-input-editor"))||void 0===u?void 0:u[0])&&void 0!==p?p:R;D.appendChild(R);const H=new Promise(e=>{const n=t.button(B,()=>e());j.appendChild(n)}),q=new Promise(n=>{const i=t.bigButton(S,()=>function(){return en(this,void 0,void 0,function*(){var t,i,o,a,r,s,d,u,p,h;if(k.okProxy(),"100%"===b.style.opacity)return void e.shell.error("Template name is empty or already exists");if("100%"===T.style.opacity)return void e.shell.error("Template key is empty or already exists");if(!(null===(t=I.value)||void 0===t?void 0:t.trim()))return void e.shell.error("Sequence column name is required");const v=w.value?y[w.value]:void 0,f=Object.assign(Object.assign({name:x.value,key:N.value,sequenceColumnName:I.value.trim(),moleculeColumnName:(null===(i=P.value)||void 0===i?void 0:i.trim())||void 0,campaignFields:$.getFields(),dataSourceType:null!==(o=M.value)&&void 0!==o?o:"Query",layoutViewState:null!==(a=C.getLayoutViewState())&&void 0!==a?a:void 0,compute:{descriptors:{enabled:!!(null===(r=null==O?void 0:O.descriptors)||void 0===r?void 0:r.length),args:null!==(s=null==O?void 0:O.descriptors)&&void 0!==s?s:[]},functions:Object.entries(null!==(d=null==O?void 0:O.externals)&&void 0!==d?d:{}).map(([e,t])=>{const n=e.split(":");return{name:n[1],package:n[0],args:t}}),scripts:Object.entries(null!==(u=null==O?void 0:O.scripts)&&void 0!==u?u:{}).filter(([e,t])=>e.startsWith(l)&&3===e.split(":").length).map(([e,t])=>{var n,i;const o=e.split(":");return{name:null!==(n=o[1])&&void 0!==n?n:"",id:null!==(i=o[2])&&void 0!==i?i:"",args:t}}),queries:Object.entries(null!==(p=null==O?void 0:O.queries)&&void 0!==p?p:{}).filter(([e,t])=>e.startsWith(c)&&3===e.split(":").length).map(([e,t])=>{var n,i;const o=e.split(":");return{name:null!==(n=o[1])&&void 0!==n?n:"",id:null!==(i=o[2])&&void 0!==i?i:"",args:t}})}},v?{submit:{fName:v.name,package:ie(v)}}:{}),{queryFunctionName:"Query"===M.value&&null!==(h=V.value)&&void 0!==h?h:void 0});In.files.writeAsText(`${m}/${f.name}.json`,JSON.stringify(f)),e.shell.info("Template created successfully"),n(f)})}());j.appendChild(i)});return{root:D,template:q,cancelPromise:H}})}(this.app,this.getDataSourceFunctionsMap(),n),a=new o.ViewBase,r=e.shell.v;a.name="New Template",a.root.appendChild(i.root),a.parentCall=this.app.parentCall,e.shell.addView(a),a.path=new URL(this.app.baseUrl).pathname+"/new-template",a.parentView=r;const{sub:s}=le(e.shell.v,this.app.appName,T,()=>{e.shell.v=r,a.close()});i.template.then(t=>tn(this,void 0,void 0,function*(){yield this.init(t),a.close(),ce(a),e.shell.v=r,s.unsubscribe()})),i.cancelPromise.then(()=>{s.unsubscribe(),a.close(),e.shell.v=r})})}}class on extends ut{constructor(e){super(e,"PepTriage",e=>new nn(e))}get seqColName(){return this._seqColName}prepareDataFrame(t){return n=this,i=void 0,r=function*(){var n;const i=t;if(!this.dataFrame)return;yield this.dataFrame.meta.detectSemanticTypes();const a=i.sequenceColumnName;let r=a?this.dataFrame.col(a):null;if(r||(r=this.dataFrame.columns.bySemType(o.SEMTYPE.MACROMOLECULE)),!r)throw new Error(`Sequence column '${null!=a?a:"Macromolecule"}' not found in the dataset. Make sure the data contains a column with sequences.`);this._seqColName=r.name;const s=o.TaskBarProgressIndicator.create("Initializing sequences...");try{const t=yield async function(){const e=o.Func.find({package:"Bio",name:"getSeqHelper"});if(0===e.length)throw new Error("Package 'Bio' must be installed for SeqHelper.");return(await e[0].prepare().call()).getOutputParamValue()}(),a=t.getSeqHandler(r);yield a.refinerPromise,t.getSeqHandler(r);const l=i.moleculeColumnName;let c=l?this.dataFrame.col(l):null;if(c||(c=this.dataFrame.columns.bySemType(o.SEMTYPE.MOLECULE)),!c&&(s.update(50,"Converting sequences to molecules..."),yield e.functions.call("Bio:toAtomicLevel",{table:this.dataFrame,seqCol:r,nonlinear:!0}),yield this.dataFrame.meta.detectSemanticTypes(),c=null!==(n=this.dataFrame.columns.bySemTypeAll(o.SEMTYPE.MOLECULE).find(e=>e.name.toLowerCase().includes(r.name.toLowerCase())))&&void 0!==n?n:null,!c))return void e.shell.warning("Failed to convert sequences to molecules. Calculations may not work.");this.reorderColumns(r.name,c.name)}catch(t){In.logger.error(t),e.shell.error("Error preparing sequence data: "+(t instanceof Error?t.message:t))}finally{s.close()}},new((a=void 0)||(a=Promise))(function(e,t){function o(e){try{l(r.next(e))}catch(e){t(e)}}function s(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 a?n:new a(function(e){e(n)})).then(o,s)}l((r=r.apply(n,i||[])).next())});var n,i,a,r}reorderColumns(e,t){if(!this.dataFrame)return;const n=this.dataFrame.col(e),i=this.dataFrame.col(t);n&&(this.dataFrame.columns.remove(e),this.dataFrame.columns.insert(n,0)),i&&(this.dataFrame.columns.remove(t),this.dataFrame.columns.insert(i,1))}}var an=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{l(i.next(e))}catch(e){a(e)}}function s(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}l((i=i.apply(e,t||[])).next())})};function rn(){return an(this,void 0,void 0,function*(){yield Pn.initHT()})}function sn(e){return an(this,void 0,void 0,function*(){yield Pn.hitTriageAppTreeBrowser(e)})}function ln(e){return an(this,void 0,void 0,function*(){yield Pn.hitDesignAppTreeBrowser(e)})}function cn(e){return an(this,void 0,void 0,function*(){yield Pn.peptiHitAppTreeBrowser(e)})}function dn(){return an(this,void 0,void 0,function*(){return yield Pn.hitTriageApp()})}function un(){return an(this,void 0,void 0,function*(){return yield Pn.hitDesignApp()})}function pn(){return an(this,void 0,void 0,function*(){return yield Pn.peptiHitApp()})}function mn(e){return an(this,void 0,void 0,function*(){yield Pn.pepTriageAppTreeBrowser(e)})}function hn(){return an(this,void 0,void 0,function*(){return yield Pn.pepTriageApp()})}function vn(){return an(this,void 0,void 0,function*(){return yield Pn.demoFileIngest()})}function fn(){return an(this,void 0,void 0,function*(){return yield Pn.demoFileIngest1()})}function gn(e){return an(this,void 0,void 0,function*(){return yield Pn.demoFileIngest2(e)})}function yn(e){return an(this,void 0,void 0,function*(){return yield Pn.demoPeptideSequences(e)})}function An(e,t){return an(this,void 0,void 0,function*(){yield Pn.demoFileSubmit(e,t)})}function wn(){return an(this,void 0,void 0,function*(){yield Pn.registerMoleculesToViD()})}function Cn(e){return Pn.hitDesignVidPanel(e)}function bn(){return Pn.gasteigerCellRenderer()}function En(e){return an(this,void 0,void 0,function*(){return yield Pn.htPackageSettingEditor(e)})}var Tn=function(e,t,n,i){var o,a=arguments.length,r=a<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(r=(a<3?o(r):a>3?o(t,n,r):o(t,n))||r);return a>3&&r&&Object.defineProperty(t,n,r),r},xn=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Sn=function(e,t){return function(n,i){t(n,i,e)}},Nn=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{l(i.next(e))}catch(e){a(e)}}function s(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}l((i=i.apply(e,t||[])).next())})};class Bn extends o.Package{constructor(){super(...arguments),this.molToSmilesLruCache=new o.LruCache(2e3),this.campaignsCache={}}convertToSmiles(t){return t?this.molToSmilesLruCache.getOrCreate(t,t=>e.chem.convert(t,e.chem.Notation.Unknown,e.chem.Notation.Smiles)):""}loadCampaigns(t,n){return Nn(this,void 0,void 0,function*(){return this.campaignsCache[t]||(this.campaignsCache[t]=yield function(t,n){return ae(this,void 0,void 0,function*(){const i=(yield In.files.list(`${t}/campaigns`)).filter(e=>-1===n.indexOf(e.name)),o={},a=i.map(n=>ae(this,void 0,void 0,function*(){try{const i=JSON.parse(yield In.files.readAsText(`${t}/campaigns/${n.name}/${h}`));if(i.authorUserId&&i.permissions&&!(yield me(i.authorUserId,i.permissions)))return null;if(i.authorUserId&&!i.authorUserFriendlyName){const t=yield e.dapi.users.find(i.authorUserId);t&&(i.authorUserFriendlyName=t.friendlyName)}o[i.name]=i}catch(e){console.error(e)}return null}));return yield Promise.all(a),o})}(t,null!=n?n:[])),this.campaignsCache[t]})}saveCampaignJson(e,t){return Nn(this,void 0,void 0,function*(){const n=`${e}/campaigns/${t.name}/${h}`;yield this.files.writeAsText(n,JSON.stringify(t)),this.campaignsCache[e][t.name]=t})}}const In=new Bn;function Fn(n,i){return Nn(this,void 0,void 0,function*(){var a,r,s;const l=t.div([],{style:{width:"50px",height:"24px",position:"relative"}});l.innerHTML='<div class="grok-loader"><div></div><div></div><div></div><div></div></div>';const c=n.item(l),d=yield In.loadCampaigns(i,[]);let u=null,p=!0;for(const[t,i]of Object.entries(d)){const t=null!==(a=i.templateName)&&void 0!==a?a:null===(r=i.template)||void 0===r?void 0:r.name,l=t?n.getOrCreateGroup(t,null,p):n;p=!1;const c=l.item(null!==(s=i.friendlyName)&&void 0!==s?s:i.name);c.root.addEventListener("dblclick",e=>{e.stopImmediatePropagation(),e.stopPropagation(),e.preventDefault()}),o.debounce(c.onSelected,200).subscribe(t=>Nn(this,void 0,void 0,function*(){var t;try{const n="ingest"in i?i.ingest.query:i.savePath;if(!n||!(yield e.dapi.files.exists(n)))return void e.shell.error("File not found: "+n);const a=yield e.dapi.files.readCsv(n);if(!a)return;a.name=null!==(t=i.friendlyName)&&void 0!==t?t:i.name;const r=i.columnSemTypes;if(r)for(const[m,h]of Object.entries(r)){const v=a.columns.byName(m);v&&(v.semType=h,h===o.SEMTYPE.MACROMOLECULE&&m===w&&(v.setTag("units","helm"),v.setTag(".alphabetIsMultichar","true"),v.setTag("cell.renderer","helm")))}const s=document.activeElement;let l=!1;function c(){setTimeout(()=>{!l&&s&&document.activeElement!==s&&s&&"focus"in s&&s.focus()})}window.addEventListener("focusout",c);try{u&&u.close()}catch(f){}try{u=e.shell.addTableView(a);const g=i.layout;g&&u.loadLayout(o.ViewLayout.fromViewState(g))}catch(y){console.error(y)}function d(){window.removeEventListener("focusout",c)}function p(){d(),l=!0}window.addEventListener("click",p,{once:!0}),setTimeout(()=>{d(),window.removeEventListener("click",p)},5e3)}catch(A){console.error(A)}}))}c.remove()})}class Pn{static initHT(){return Nn(this,void 0,void 0,function*(){yield e.functions.call("Chem:init",{})})}static hitTriageAppTreeBrowser(e){return Nn(this,void 0,void 0,function*(){yield Fn(e,"Hit Triage")})}static hitDesignAppTreeBrowser(e){return Nn(this,void 0,void 0,function*(){yield Fn(e,"Hit Design")})}static peptiHitAppTreeBrowser(e){return Nn(this,void 0,void 0,function*(){yield Fn(e,"PeptiHit")})}static hitTriageApp(){return Nn(this,void 0,void 0,function*(){const t=e.functions.getCurrentCall();return new ut(t).multiView})}static hitDesignApp(){return Nn(this,void 0,void 0,function*(){const t=e.functions.getCurrentCall();return new zt(t).multiView})}static peptiHitApp(){return Nn(this,void 0,void 0,function*(){const t=e.functions.getCurrentCall();return yield e.functions.call("Bio:initBio",{}),new Xt(t).multiView})}static pepTriageAppTreeBrowser(e){return Nn(this,void 0,void 0,function*(){yield Fn(e,"PepTriage")})}static pepTriageApp(){return Nn(this,void 0,void 0,function*(){const t=e.functions.getCurrentCall();return yield e.functions.call("Bio:initBio",{}),new on(t).multiView})}static demoFileIngest(){return Nn(this,void 0,void 0,function*(){const t=e.data.demo.molecules(100);return t.name="100 Molecules",t})}static demoFileIngest1(){return Nn(this,void 0,void 0,function*(){const t=e.data.demo.molecules(5e3);return t.name="5000 Molecules",t})}static demoFileIngest2(t){return Nn(this,void 0,void 0,function*(){const n=e.data.demo.molecules(t);return n.name="Variable Molecules number",n})}static demoPeptideSequences(e){return Nn(this,void 0,void 0,function*(){const t=["PEPTIDE1{A.G.L.V.K}$$$$V2.0","PEPTIDE1{G.A.V.L.I.P}$$$$V2.0","PEPTIDE1{F.W.Y.H.K.R}$$$$V2.0","PEPTIDE1{D.E.N.Q.S.T}$$$$V2.0","PEPTIDE1{A.R.N.D.C.E}$$$$V2.0","PEPTIDE1{G.H.I.L.K.M}$$$$V2.0","PEPTIDE1{F.P.S.T.W.Y}$$$$V2.0","PEPTIDE1{V.A.G.L.I}$$$$V2.0","PEPTIDE1{K.R.H.D.E}$$$$V2.0","PEPTIDE1{N.Q.S.T.C.M}$$$$V2.0","PEPTIDE1{A.V.L.I.P.F}$$$$V2.0","PEPTIDE1{W.Y.G.A.R}$$$$V2.0","PEPTIDE1{K.H.D.E.N.Q}$$$$V2.0","PEPTIDE1{S.T.C.M.F.W}$$$$V2.0","PEPTIDE1{Y.A.G.V.L.I}$$$$V2.0","PEPTIDE1{P.K.R.H.D}$$$$V2.0","PEPTIDE1{E.N.Q.S.T.C}$$$$V2.0","PEPTIDE1{M.F.W.Y.A.G}$$$$V2.0","PEPTIDE1{V.L.I.P.K.R}$$$$V2.0","PEPTIDE1{H.D.E.N.Q.S}$$$$V2.0"],n=[];for(let i=0;i<e;i++)n.push(t[i%t.length]);const i=o.Column.fromStrings("Helm",n);i.semType=o.SEMTYPE.MACROMOLECULE,i.setTag("units","helm"),i.setTag(".alphabetIsMultichar","true");const a=o.DataFrame.fromColumns([i]);return a.name="Demo Peptide Sequences",a})}static demoFileSubmit(t,n){return Nn(this,void 0,void 0,function*(){e.shell.info(t.rowCount),e.shell.info(n)})}static registerMoleculesToViD(){return Nn(this,void 0,void 0,function*(){!function(){Nt(this,void 0,void 0,function*(){var n;const i="Hit Design",a=yield In.loadCampaigns(i),r=Object.keys(a),s=t.input.choice("Select Campaign",{value:null,nullable:!0,items:r,tooltipText:"Select campaign to register its molecules. Leave empty to register all campaigns"}),l=yield new Promise(e=>Nt(this,void 0,void 0,function*(){t.dialog("Register Existing Campaign Molecules").add(t.divText("This operation will go through all molecules in the selected campaign(s) and register them into V-iD storage.\n This operation is irreversible.")).add(t.divText("You can select a specific campaign or leave it empty to process all campaigns.")).add(t.divText("After this opteration, all VIDs throughout all campaigns will become unique, and old V-iDs will no longer be valid.")).add(t.divText("WARNING: Depending on the number of molecules, this operation can take a long time.")).add(s).onOK(()=>{if(s.value){const t=a[s.value];e([t])}else{const t=r.map(e=>a[e]);e(t)}}).onCancel(()=>e(null)).show()})),c=o.TaskBarProgressIndicator.create("Registering molecules...");if(!l||0===l.length)return void c.close();const d=l.length;for(const t of l){c.update(0/d*100,`Processing campaign: ${t.name}`);try{const o=`System.AppData/HitTriage/${i}/campaigns`,a=null!==(n=null==t?void 0:t.savePath)&&void 0!==n?n:`${o}/${t.name}/${m}`,r=yield e.dapi.files.readCsv(a);if(!r){e.shell.warning(`Failed to load campaign table for campaign ${t.name} at path ${a}`),console.warn(`Failed to load campaign table for campaign ${t.name} at path ${a}`);continue}const s=r.col(A);if(!s){e.shell.warning(`Molecule column not found in campaign ${t.name} table`),console.warn(`Molecule column not found in campaign ${t.name} table`);continue}const l=r.col(C);if(!l){e.shell.warning(`V-iD column not found in campaign ${t.name} table`),console.warn(`V-iD column not found in campaign ${t.name} table`);continue}const c=s.toList(),d=yield Pt(c,t.name,i);for(let e=0;e<r.rowCount;e++){const t=c[e];if(!t||""===t){l.set(e,"",!1);continue}const n=d.get(t);n&&l.set(e,n,!1)}l.fireValuesChanged(),yield e.dapi.files.writeAsText(a,r.toCsv()),e.shell.info(`Finished processing campaign ${t.name}`),console.log(`Finished processing campaign ${t.name}`)}catch(n){e.shell.error(`Error processing campaign ${t.name}. See console for details.`),console.error(`Error processing campaign ${t.name} molecules registration:`,n)}}c.close()})}()})}static hitDesignVidPanel(n){return o.Widget.fromRoot(t.card(t.wait(()=>Nn(this,void 0,void 0,function*(){if(!(null==n?void 0:n.value))return t.divText("No V-iD provided");const i=yield et.getCampaignsByVid(n.value,null);if(!i||0===i.rowCount)return t.divText(`No campaigns found for V-iD: ${n.value}`);const o=yield et.getMoleculeByVid(n.value);if(!o||0===o.rowCount)return t.divText(`No molecule found for V-iD: ${n.value}`);const a=function(e){var t;const n=null===(t=In.meta)||void 0===t?void 0:t.sok;if(!n)throw new Error("Secret key for SMILES deobfuscation is not set");const i=atob(e);let o="";for(let e=0;e<i.length;e++){const t=i.charCodeAt(e),a=n.charCodeAt(e%n.length);o+=String.fromCharCode(t^a)}return o}(o.col("mh_string").get(0)),r=e.chem.drawMolecule(a,300,300),s=new Map;for(let e=0;e<i.rowCount;e++){const t=i.col("app_name").get(e),n=i.col("campaign_id").get(e),o=i.col("created_by").get(e);s.has(t)||s.set(t,[]),s.get(t).push({campaignId:n,createdBy:o})}const l=t.divV([r],{style:{gap:"10px",justifyContent:"center"}});for(const[e,n]of s.entries()){const i=t.table(n.map(e=>[e.campaignId,e.createdBy]),e=>[e[0],e[1]],["Campaigns","Created By"]),o=t.divV([t.h3(`${e} Campaigns`),i],{style:{gap:"4px"}});l.appendChild(o)}return l}))))}static gasteigerCellRenderer(){return new Jt}static htPackageSettingEditor(n){return Nn(this,void 0,void 0,function*(){return function(n){return Et(this,void 0,void 0,function*(){var i;const a=n.filter(e=>"DefaultUserGroupsSharing"===e.category),r=[];for(const n of a){const i=`${n.name[0].toUpperCase()}${n.name.slice(1)}`,a=n.get(null),s=yield St(a),l=t.input.userGroups(i);yield o.delay(200),l.value=s,l.onInput.subscribe(()=>{var t;try{const e=(null===(t=l.value)||void 0===t?void 0:t.length)?JSON.stringify(l.value.map(e=>e.id)):"";n.set(null,e)}catch(t){e.shell.error("Error Setting group. Check console for more details"),console.error(t)}}),l.setTooltip(`Selected groups will be granted ${i.toLowerCase()} permissions by default on newly created campaigns`),r.push(l)}const s=o.Widget.fromRoot(t.form(r,{style:{overflow:"visible"}}));s.root.prepend(t.h1("Default Campaign Sharing",{style:{marginBottom:"6px",marginTop:"6px"}}));const l=n.find(e=>e.name===Tt);if(l){const n='Default storage for newly created campaigns. For each app, folders will be created under their name. For example, for Hit Design, the campaign files will be saved under <b>"Your folder/Hit Design/campaigns/enriched_table.csv"</b>';let a=n;const r=null!==(i=l.get(null))&&void 0!==i?i:xt,c=t.h1("Default Campaign Storage",{style:{marginBottom:"6px",marginTop:"6px"}}),d=t.input.string("Folder Path",{value:r});t.tooltip.bind(d.input,()=>a),o.debounce(d.onChanged,200).subscribe(t=>Et(this,void 0,void 0,function*(){const t=d.value;try{if(!t)return l.set(null,xt),a=n+'<br><br> <b style="color: red">Cannot be empty.</b>',void d.input.classList.add("d4-invalid");if(!(yield e.dapi.files.exists(t)))return l.set(null,xt),a=n+'<br><br> <b style="color: red">Folder does not exist.</b>',void d.input.classList.add("d4-invalid");l.set(null,t),a=n,d.input.classList.remove("d4-invalid")}catch(t){e.shell.error("Error Setting default storage. Check console for more details"),console.error(t)}})),s.root.appendChild(c),s.root.appendChild(d.root)}return setTimeout(()=>{var e;return(null===(e=s.root.parentElement)||void 0===e?void 0:e.style)&&(s.root.parentElement.style.overflow="visible")},200),s})}(n)})}}Tn([e.decorators.init(),xn("design:type",Function),xn("design:paramtypes",[]),xn("design:returntype",Promise)],Pn,"initHT",null),Tn([e.decorators.treeBrowser({meta:{app:"Hit Triage"}}),xn("design:type",Function),xn("design:paramtypes",[o.TreeViewGroup]),xn("design:returntype",Promise)],Pn,"hitTriageAppTreeBrowser",null),Tn([e.decorators.treeBrowser({meta:{app:"Hit Design"}}),xn("design:type",Function),xn("design:paramtypes",[o.TreeViewGroup]),xn("design:returntype",Promise)],Pn,"hitDesignAppTreeBrowser",null),Tn([e.decorators.treeBrowser({meta:{app:"PeptiHit"}}),xn("design:type",Function),xn("design:paramtypes",[o.TreeViewGroup]),xn("design:returntype",Promise)],Pn,"peptiHitAppTreeBrowser",null),Tn([e.decorators.app({browsePath:"Chem",name:"Hit Triage",tags:["app"]}),xn("design:type",Function),xn("design:paramtypes",[]),xn("design:returntype",Promise)],Pn,"hitTriageApp",null),Tn([e.decorators.app({icon:"images/icons/hit-design-icon.png",browsePath:"Chem",name:"Hit Design",tags:["app"]}),xn("design:type",Function),xn("design:paramtypes",[]),xn("design:returntype",Promise)],Pn,"hitDesignApp",null),Tn([e.decorators.app({icon:"images/icons/pepti-hit-icon.png",browsePath:"Peptides",name:"PeptiHit",tags:["app"]}),xn("design:type",Function),xn("design:paramtypes",[]),xn("design:returntype",Promise)],Pn,"peptiHitApp",null),Tn([e.decorators.treeBrowser({meta:{app:"PepTriage"}}),xn("design:type",Function),xn("design:paramtypes",[o.TreeViewGroup]),xn("design:returntype",Promise)],Pn,"pepTriageAppTreeBrowser",null),Tn([e.decorators.app({icon:"images/icons/hit-triage-icon.png",browsePath:"Peptides",name:"PepTriage",tags:["app"]}),xn("design:type",Function),xn("design:paramtypes",[]),xn("design:returntype",Promise)],Pn,"pepTriageApp",null),Tn([e.decorators.func({name:"Demo Molecules 100",meta:{role:"hitTriageDataSource"}}),xn("design:type",Function),xn("design:paramtypes",[]),xn("design:returntype",Promise)],Pn,"demoFileIngest",null),Tn([e.decorators.func({name:"Demo Molecules 5000",meta:{role:"hitTriageDataSource"}}),xn("design:type",Function),xn("design:paramtypes",[]),xn("design:returntype",Promise)],Pn,"demoFileIngest1",null),Tn([e.decorators.func({name:"Demo Molecules variable",meta:{role:"hitTriageDataSource"}}),Sn(0,e.decorators.param({type:"int",options:{description:"Molecules counts"}})),xn("design:type",Function),xn("design:paramtypes",[Number]),xn("design:returntype",Promise)],Pn,"demoFileIngest2",null),Tn([e.decorators.func({name:"Demo Peptide Sequences",meta:{role:"pepTriageDataSource"}}),xn("design:type",Function),xn("design:paramtypes",[Number]),xn("design:returntype",Promise)],Pn,"demoPeptideSequences",null),Tn([e.decorators.func({name:"Demo File Submit",meta:{role:"hitTriageSubmitFunction"}}),Sn(0,e.decorators.param({options:{description:"Dataframe"}})),Sn(1,e.decorators.param({options:{description:"Molecules column name"}})),xn("design:type",Function),xn("design:paramtypes",[o.DataFrame,String]),xn("design:returntype",Promise)],Pn,"demoFileSubmit",null),Tn([e.decorators.func({}),xn("design:type",Function),xn("design:paramtypes",[]),xn("design:returntype",Promise)],Pn,"registerMoleculesToViD",null),Tn([e.decorators.panel({name:"Hit Design V-iD"}),Sn(0,e.decorators.param({type:"semantic_value",options:{semType:"HIT_DESIGN_VID"}})),xn("design:type",Function),xn("design:paramtypes",[o.SemanticValue]),xn("design:returntype",o.Widget)],Pn,"hitDesignVidPanel",null),Tn([e.decorators.func({meta:{cellType:"customGasteigerPNG",columnTags:"quality=customGasteigerPNG",role:"cellRenderer"},name:"gasteigerRenderer",outputs:[{type:"grid_cell_renderer",name:"result"}]}),xn("design:type",Function),xn("design:paramtypes",[]),xn("design:returntype",Jt)],Pn,"gasteigerCellRenderer",null),Tn([e.decorators.func({name:"Hit Triage package settings editor",meta:{role:"packageSettingsEditor"},tags:["packageSettingsEditor"]}),Sn(0,e.decorators.param({name:"propList",type:"object"})),xn("design:type",Function),xn("design:paramtypes",[Array]),xn("design:returntype",Promise)],Pn,"htPackageSettingEditor",null)})(),hittriage=i})();
|
|
1
|
+
var hittriage;(()=>{"use strict";var e={804(e,t,i){i.d(t,{A:()=>o});var n=i(126),a=i.n(n),r=i(454),l=i.n(r)()(a());l.push([e.id,`.statistics-mpo-header {
|
|
2
|
+
margin-top: 10px;
|
|
3
|
+
padding-bottom: 5px;
|
|
4
|
+
border-bottom: 1px solid var(--grey-2);
|
|
5
|
+
gap: 10px;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.statistics-mpo-header > * {
|
|
9
|
+
font-weight: bold;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.statistics-mpo-header > *:first-child {
|
|
13
|
+
width: 130px;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.statistics-mpo-header > *:nth-child(2) {
|
|
17
|
+
width: 120px;
|
|
18
|
+
min-width: 60px;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.statistics-mpo-header > *:nth-child(3) {
|
|
22
|
+
flex-grow: 1;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.statistics-mpo-property-cell {
|
|
26
|
+
width: 130px;
|
|
27
|
+
max-width: 130px;
|
|
28
|
+
align-self: flex-end;
|
|
29
|
+
margin-bottom: 20px !important;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.ui-form .statistics-mpo-property-cell > div:first-child {
|
|
33
|
+
padding-left: 4px;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.statistics-mpo-property-cell > div:first-child {
|
|
37
|
+
overflow: hidden;
|
|
38
|
+
text-overflow: ellipsis;
|
|
39
|
+
white-space: nowrap;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.statistics-mpo-weight-input {
|
|
43
|
+
width: 100px;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.statistics-mpo-weight-cell {
|
|
47
|
+
align-self: flex-end;
|
|
48
|
+
margin-bottom: 20px !important;
|
|
49
|
+
align-items: center;
|
|
50
|
+
gap: 4px;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.statistics-mpo-control-buttons {
|
|
54
|
+
gap: 10px;
|
|
55
|
+
margin-left: 10px;
|
|
56
|
+
color: var(--blue-1);
|
|
57
|
+
visibility: hidden;
|
|
58
|
+
white-space: nowrap;
|
|
59
|
+
flex-shrink: 0;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.statistics-mpo-row:hover .statistics-mpo-control-buttons,
|
|
63
|
+
.statistics-mpo-cat-row:hover .statistics-mpo-control-buttons {
|
|
64
|
+
visibility: visible;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.statistics-mpo-range-input {
|
|
68
|
+
width: 70px;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.statistics-mpo-row {
|
|
72
|
+
display: flex;
|
|
73
|
+
align-items: center;
|
|
74
|
+
justify-content: flex-start;
|
|
75
|
+
padding: 8px 0;
|
|
76
|
+
min-height: 70px;
|
|
77
|
+
gap: 10px;
|
|
78
|
+
|
|
79
|
+
flex-wrap: wrap;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.statistics-mpo-row > * {
|
|
83
|
+
flex: 0 0 auto;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
.statistics-mpo-row .ui-input-choice .ui-input-editor,
|
|
88
|
+
.statistics-mpo-row .ui-input-column .ui-input-editor {
|
|
89
|
+
width: 100px !important;
|
|
90
|
+
max-width: none !important;
|
|
91
|
+
overflow: hidden;
|
|
92
|
+
text-overflow: ellipsis;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.ui-form .statistics-mpo-row .ui-input-root {
|
|
96
|
+
margin-bottom: 0 !important;
|
|
97
|
+
padding: 0 !important;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.statistics-mpo-editor-fill {
|
|
101
|
+
width: 100%;
|
|
102
|
+
height: 100%;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.statistics-mpo-cat-editor {
|
|
106
|
+
width: 280px;
|
|
107
|
+
margin-left: 30px;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.statistics-mpo-cat-row {
|
|
111
|
+
display: flex;
|
|
112
|
+
align-items: center;
|
|
113
|
+
gap: 4px;
|
|
114
|
+
margin-bottom: 2px;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.statistics-mpo-cat-name {
|
|
118
|
+
width: 120px;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.statistics-mpo-cat-col-header {
|
|
122
|
+
font-size: 11px;
|
|
123
|
+
color: var(--grey-3);
|
|
124
|
+
text-transform: uppercase;
|
|
125
|
+
letter-spacing: 0.3px;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.statistics-mpo-desirability-dialog .statistics-mpo-cat-editor {
|
|
129
|
+
width: auto;
|
|
130
|
+
margin-left: 0;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.statistics-mpo-desirability-dialog .statistics-mpo-cat-name {
|
|
134
|
+
flex: 1;
|
|
135
|
+
width: auto;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.statistics-mpo-cat-desirability {
|
|
139
|
+
width: 70px;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.statistics-compute-dialog-pane-header {
|
|
143
|
+
display: flex;
|
|
144
|
+
align-items: center;
|
|
145
|
+
justify-content: end;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.statistics-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.statistics-compute-dialog-pane-header {
|
|
149
|
+
border: none;
|
|
150
|
+
border-left: 4px solid transparent;
|
|
151
|
+
border-radius: 1px;
|
|
152
|
+
padding: 4px 8px;
|
|
153
|
+
min-height: 28px;
|
|
154
|
+
justify-content: flex-end;
|
|
155
|
+
flex-direction: row-reverse;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.statistics-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.statistics-compute-dialog-pane-header.selected {
|
|
159
|
+
border-left: 4px solid var(--blue-1);
|
|
160
|
+
background-color: #f2f2f5;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.statistics-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.statistics-compute-dialog-pane-header>span {
|
|
164
|
+
padding: 0 4px;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.statistics-compute-dialog-host {
|
|
168
|
+
max-height: 550px;
|
|
169
|
+
max-width: 800px;
|
|
170
|
+
min-width: 550px;
|
|
171
|
+
overflow: clip;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.statistics-compute-dialog-descriptors-group {
|
|
175
|
+
margin-left: 16px;
|
|
176
|
+
overflow: hidden;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.statistics-compute-dialog-rerun-input {
|
|
180
|
+
margin: 4px 0 8px 15px;
|
|
181
|
+
padding-bottom: 6px;
|
|
182
|
+
border-bottom: 1px solid var(--grey-2);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.oy-scroll {
|
|
186
|
+
overflow-y: scroll;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.statistics-mpo-weight-toggle {
|
|
190
|
+
cursor: pointer;
|
|
191
|
+
color: var(--grey-4);
|
|
192
|
+
font-size: 12px;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.statistics-mpo-weight-toggle:hover {
|
|
196
|
+
color: var(--grey-5);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.statistics-mpo-weight-toggle-active {
|
|
200
|
+
color: var(--grey-4);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.statistics-mpo-weight-toggle-active:hover {
|
|
204
|
+
color: var(--grey-5);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.statistics-mpo-hidden {
|
|
208
|
+
display: none !important;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.statistics-mpo-empty-state {
|
|
212
|
+
text-align: center;
|
|
213
|
+
padding: 48px 24px;
|
|
214
|
+
color: var(--grey-4);
|
|
215
|
+
border: 1px dashed var(--grey-2);
|
|
216
|
+
border-radius: 8px;
|
|
217
|
+
margin: 16px 12px;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.statistics-mpo-empty-state i {
|
|
221
|
+
font-size: 48px;
|
|
222
|
+
margin-bottom: 16px;
|
|
223
|
+
display: block;
|
|
224
|
+
color: var(--blue-1);
|
|
225
|
+
opacity: 0.3;
|
|
226
|
+
cursor: default;
|
|
227
|
+
pointer-events: none;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.statistics-mpo-empty-state h3 {
|
|
231
|
+
color: var(--grey-5);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.statistics-mpo-empty-state p {
|
|
235
|
+
color: var(--grey-3);
|
|
236
|
+
max-width: 360px;
|
|
237
|
+
margin-inline: auto;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
.statistics-mpo-dialog-header-row {
|
|
241
|
+
gap: 12px;
|
|
242
|
+
align-items: flex-end;
|
|
243
|
+
margin-bottom: 8px;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.statistics-mpo-dialog-header-row .ui-input-root {
|
|
247
|
+
flex: 0 1 auto;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.statistics-mpo-section-header {
|
|
251
|
+
font-size: 11px;
|
|
252
|
+
text-transform: uppercase;
|
|
253
|
+
color: var(--blue-1);
|
|
254
|
+
letter-spacing: 0.5px;
|
|
255
|
+
border-bottom: 1px solid var(--grey-2);
|
|
256
|
+
padding-bottom: 4px;
|
|
257
|
+
margin: 12px 0 8px;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
.statistics-mpo-param-grid.ui-form {
|
|
261
|
+
display: grid;
|
|
262
|
+
grid-template-columns: 1fr 1fr;
|
|
263
|
+
gap: 0 8px;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
.statistics-mpo-desirability-dialog .statistics-mpo-plot {
|
|
267
|
+
margin: 0 auto;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
.statistics-mpo-plot-wrap {
|
|
271
|
+
justify-content: center;
|
|
272
|
+
align-items: flex-start;
|
|
273
|
+
gap: 6px;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.statistics-mpo-plot-wrap .statistics-mpo-plot {
|
|
277
|
+
margin: 0;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
.statistics-mpo-curve-btn {
|
|
281
|
+
padding: 1px 6px;
|
|
282
|
+
font-size: 11px;
|
|
283
|
+
text-align: center;
|
|
284
|
+
cursor: pointer;
|
|
285
|
+
border: 1px solid var(--grey-2, #dbdcdf);
|
|
286
|
+
border-radius: 3px;
|
|
287
|
+
background: var(--grey-1, #f2f2f5);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
.statistics-mpo-curve-btn.statistics-mpo-toggle-on {
|
|
291
|
+
color: #fff;
|
|
292
|
+
background: var(--blue-1, #1f77b4);
|
|
293
|
+
border-color: var(--blue-1, #1f77b4);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
.statistics-mpo-curve-btn + .statistics-mpo-curve-btn {
|
|
297
|
+
margin-top: 4px;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
@media (max-width: 500px) {
|
|
301
|
+
.statistics-mpo-row {
|
|
302
|
+
flex-direction: column;
|
|
303
|
+
align-items: flex-start;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
.statistics-mpo-row > * {
|
|
307
|
+
width: 100% !important;
|
|
308
|
+
margin-bottom: 5px;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
.statistics-mpo-weight-cell {
|
|
312
|
+
margin-top: 0 !important;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
`,"",{version:3,sources:["webpack://./../../libraries/statistics/dist/css/styles.css"],names:[],mappings:"AAAA;EACE,gBAAgB;EAChB,mBAAmB;EACnB,sCAAsC;EACtC,SAAS;AACX;;AAEA;EACE,iBAAiB;AACnB;;AAEA;EACE,YAAY;AACd;;AAEA;EACE,YAAY;EACZ,eAAe;AACjB;;AAEA;EACE,YAAY;AACd;;AAEA;EACE,YAAY;EACZ,gBAAgB;EAChB,oBAAoB;EACpB,8BAA8B;AAChC;;AAEA;EACE,iBAAiB;AACnB;;AAEA;EACE,gBAAgB;EAChB,uBAAuB;EACvB,mBAAmB;AACrB;;AAEA;EACE,YAAY;AACd;;AAEA;EACE,oBAAoB;EACpB,8BAA8B;EAC9B,mBAAmB;EACnB,QAAQ;AACV;;AAEA;EACE,SAAS;EACT,iBAAiB;EACjB,oBAAoB;EACpB,kBAAkB;EAClB,mBAAmB;EACnB,cAAc;AAChB;;AAEA;;EAEE,mBAAmB;AACrB;;AAEA;EACE,WAAW;AACb;;AAEA;EACE,aAAa;EACb,mBAAmB;EACnB,2BAA2B;EAC3B,cAAc;EACd,gBAAgB;EAChB,SAAS;;EAET,eAAe;AACjB;;AAEA;EACE,cAAc;AAChB;;;AAGA;;EAEE,uBAAuB;EACvB,0BAA0B;EAC1B,gBAAgB;EAChB,uBAAuB;AACzB;;AAEA;EACE,2BAA2B;EAC3B,qBAAqB;AACvB;;AAEA;EACE,WAAW;EACX,YAAY;AACd;;AAEA;EACE,YAAY;EACZ,iBAAiB;AACnB;;AAEA;EACE,aAAa;EACb,mBAAmB;EACnB,QAAQ;EACR,kBAAkB;AACpB;;AAEA;EACE,YAAY;AACd;;AAEA;EACE,eAAe;EACf,oBAAoB;EACpB,yBAAyB;EACzB,qBAAqB;AACvB;;AAEA;EACE,WAAW;EACX,cAAc;AAChB;;AAEA;EACE,OAAO;EACP,WAAW;AACb;;AAEA;EACE,WAAW;AACb;;AAEA;EACE,aAAa;EACb,mBAAmB;EACnB,oBAAoB;AACtB;;AAEA;EACE,YAAY;EACZ,kCAAkC;EAClC,kBAAkB;EAClB,gBAAgB;EAChB,gBAAgB;EAChB,yBAAyB;EACzB,2BAA2B;AAC7B;;AAEA;EACE,oCAAoC;EACpC,yBAAyB;AAC3B;;AAEA;EACE,cAAc;AAChB;;AAEA;EACE,iBAAiB;EACjB,gBAAgB;EAChB,gBAAgB;EAChB,cAAc;AAChB;;AAEA;EACE,iBAAiB;EACjB,gBAAgB;AAClB;;AAEA;EACE,sBAAsB;EACtB,mBAAmB;EACnB,sCAAsC;AACxC;;AAEA;EACE,kBAAkB;AACpB;;AAEA;EACE,eAAe;EACf,oBAAoB;EACpB,eAAe;AACjB;;AAEA;EACE,oBAAoB;AACtB;;AAEA;EACE,oBAAoB;AACtB;;AAEA;EACE,oBAAoB;AACtB;;AAEA;EACE,wBAAwB;AAC1B;;AAEA;EACE,kBAAkB;EAClB,kBAAkB;EAClB,oBAAoB;EACpB,gCAAgC;EAChC,kBAAkB;EAClB,iBAAiB;AACnB;;AAEA;EACE,eAAe;EACf,mBAAmB;EACnB,cAAc;EACd,oBAAoB;EACpB,YAAY;EACZ,eAAe;EACf,oBAAoB;AACtB;;AAEA;EACE,oBAAoB;AACtB;;AAEA;EACE,oBAAoB;EACpB,gBAAgB;EAChB,mBAAmB;AACrB;;AAEA;EACE,SAAS;EACT,qBAAqB;EACrB,kBAAkB;AACpB;;AAEA;EACE,cAAc;AAChB;;AAEA;EACE,eAAe;EACf,yBAAyB;EACzB,oBAAoB;EACpB,qBAAqB;EACrB,sCAAsC;EACtC,mBAAmB;EACnB,kBAAkB;AACpB;;AAEA;EACE,aAAa;EACb,8BAA8B;EAC9B,UAAU;AACZ;;AAEA;EACE,cAAc;AAChB;;AAEA;EACE,uBAAuB;EACvB,uBAAuB;EACvB,QAAQ;AACV;;AAEA;EACE,SAAS;AACX;;AAEA;EACE,gBAAgB;EAChB,eAAe;EACf,kBAAkB;EAClB,eAAe;EACf,wCAAwC;EACxC,kBAAkB;EAClB,kCAAkC;AACpC;;AAEA;EACE,WAAW;EACX,kCAAkC;EAClC,oCAAoC;AACtC;;AAEA;EACE,eAAe;AACjB;;AAEA;EACE;IACE,sBAAsB;IACtB,uBAAuB;EACzB;;EAEA;IACE,sBAAsB;IACtB,kBAAkB;EACpB;;EAEA;IACE,wBAAwB;EAC1B;AACF",sourcesContent:[".statistics-mpo-header {\n margin-top: 10px;\n padding-bottom: 5px;\n border-bottom: 1px solid var(--grey-2);\n gap: 10px;\n}\n\n.statistics-mpo-header > * {\n font-weight: bold;\n}\n\n.statistics-mpo-header > *:first-child {\n width: 130px;\n}\n\n.statistics-mpo-header > *:nth-child(2) {\n width: 120px;\n min-width: 60px;\n}\n\n.statistics-mpo-header > *:nth-child(3) {\n flex-grow: 1;\n}\n\n.statistics-mpo-property-cell {\n width: 130px;\n max-width: 130px;\n align-self: flex-end;\n margin-bottom: 20px !important;\n}\n\n.ui-form .statistics-mpo-property-cell > div:first-child {\n padding-left: 4px;\n}\n\n.statistics-mpo-property-cell > div:first-child {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.statistics-mpo-weight-input {\n width: 100px;\n}\n\n.statistics-mpo-weight-cell {\n align-self: flex-end;\n margin-bottom: 20px !important;\n align-items: center;\n gap: 4px;\n}\n\n.statistics-mpo-control-buttons {\n gap: 10px;\n margin-left: 10px;\n color: var(--blue-1);\n visibility: hidden;\n white-space: nowrap;\n flex-shrink: 0;\n}\n\n.statistics-mpo-row:hover .statistics-mpo-control-buttons,\n.statistics-mpo-cat-row:hover .statistics-mpo-control-buttons {\n visibility: visible;\n}\n\n.statistics-mpo-range-input {\n width: 70px;\n}\n\n.statistics-mpo-row {\n display: flex;\n align-items: center;\n justify-content: flex-start;\n padding: 8px 0;\n min-height: 70px;\n gap: 10px;\n\n flex-wrap: wrap;\n}\n\n.statistics-mpo-row > * {\n flex: 0 0 auto;\n}\n\n\n.statistics-mpo-row .ui-input-choice .ui-input-editor,\n.statistics-mpo-row .ui-input-column .ui-input-editor {\n width: 100px !important;\n max-width: none !important;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.ui-form .statistics-mpo-row .ui-input-root {\n margin-bottom: 0 !important;\n padding: 0 !important;\n}\n\n.statistics-mpo-editor-fill {\n width: 100%;\n height: 100%;\n}\n\n.statistics-mpo-cat-editor {\n width: 280px;\n margin-left: 30px;\n}\n\n.statistics-mpo-cat-row {\n display: flex;\n align-items: center;\n gap: 4px;\n margin-bottom: 2px;\n}\n\n.statistics-mpo-cat-name {\n width: 120px;\n}\n\n.statistics-mpo-cat-col-header {\n font-size: 11px;\n color: var(--grey-3);\n text-transform: uppercase;\n letter-spacing: 0.3px;\n}\n\n.statistics-mpo-desirability-dialog .statistics-mpo-cat-editor {\n width: auto;\n margin-left: 0;\n}\n\n.statistics-mpo-desirability-dialog .statistics-mpo-cat-name {\n flex: 1;\n width: auto;\n}\n\n.statistics-mpo-cat-desirability {\n width: 70px;\n}\n\n.statistics-compute-dialog-pane-header {\n display: flex;\n align-items: center;\n justify-content: end;\n}\n\n.statistics-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.statistics-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.statistics-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.statistics-compute-dialog-pane-header.selected {\n border-left: 4px solid var(--blue-1);\n background-color: #f2f2f5;\n}\n\n.statistics-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.statistics-compute-dialog-pane-header>span {\n padding: 0 4px;\n}\n\n.statistics-compute-dialog-host {\n max-height: 550px;\n max-width: 800px;\n min-width: 550px;\n overflow: clip;\n}\n\n.statistics-compute-dialog-descriptors-group {\n margin-left: 16px;\n overflow: hidden;\n}\n\n.statistics-compute-dialog-rerun-input {\n margin: 4px 0 8px 15px;\n padding-bottom: 6px;\n border-bottom: 1px solid var(--grey-2);\n}\n\n.oy-scroll {\n overflow-y: scroll;\n}\n\n.statistics-mpo-weight-toggle {\n cursor: pointer;\n color: var(--grey-4);\n font-size: 12px;\n}\n\n.statistics-mpo-weight-toggle:hover {\n color: var(--grey-5);\n}\n\n.statistics-mpo-weight-toggle-active {\n color: var(--grey-4);\n}\n\n.statistics-mpo-weight-toggle-active:hover {\n color: var(--grey-5);\n}\n\n.statistics-mpo-hidden {\n display: none !important;\n}\n\n.statistics-mpo-empty-state {\n text-align: center;\n padding: 48px 24px;\n color: var(--grey-4);\n border: 1px dashed var(--grey-2);\n border-radius: 8px;\n margin: 16px 12px;\n}\n\n.statistics-mpo-empty-state i {\n font-size: 48px;\n margin-bottom: 16px;\n display: block;\n color: var(--blue-1);\n opacity: 0.3;\n cursor: default;\n pointer-events: none;\n}\n\n.statistics-mpo-empty-state h3 {\n color: var(--grey-5);\n}\n\n.statistics-mpo-empty-state p {\n color: var(--grey-3);\n max-width: 360px;\n margin-inline: auto;\n}\n\n.statistics-mpo-dialog-header-row {\n gap: 12px;\n align-items: flex-end;\n margin-bottom: 8px;\n}\n\n.statistics-mpo-dialog-header-row .ui-input-root {\n flex: 0 1 auto;\n}\n\n.statistics-mpo-section-header {\n font-size: 11px;\n text-transform: uppercase;\n color: var(--blue-1);\n letter-spacing: 0.5px;\n border-bottom: 1px solid var(--grey-2);\n padding-bottom: 4px;\n margin: 12px 0 8px;\n}\n\n.statistics-mpo-param-grid.ui-form {\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 0 8px;\n}\n\n.statistics-mpo-desirability-dialog .statistics-mpo-plot {\n margin: 0 auto;\n}\n\n.statistics-mpo-plot-wrap {\n justify-content: center;\n align-items: flex-start;\n gap: 6px;\n}\n\n.statistics-mpo-plot-wrap .statistics-mpo-plot {\n margin: 0;\n}\n\n.statistics-mpo-curve-btn {\n padding: 1px 6px;\n font-size: 11px;\n text-align: center;\n cursor: pointer;\n border: 1px solid var(--grey-2, #dbdcdf);\n border-radius: 3px;\n background: var(--grey-1, #f2f2f5);\n}\n\n.statistics-mpo-curve-btn.statistics-mpo-toggle-on {\n color: #fff;\n background: var(--blue-1, #1f77b4);\n border-color: var(--blue-1, #1f77b4);\n}\n\n.statistics-mpo-curve-btn + .statistics-mpo-curve-btn {\n margin-top: 4px;\n}\n\n@media (max-width: 500px) {\n .statistics-mpo-row {\n flex-direction: column;\n align-items: flex-start;\n }\n\n .statistics-mpo-row > * {\n width: 100% !important;\n margin-bottom: 5px;\n }\n\n .statistics-mpo-weight-cell {\n margin-top: 0 !important;\n }\n}\n"],sourceRoot:""}]);let o=l},312(e,t,i){i.d(t,{A:()=>o});var n=i(126),a=i.n(n),r=i(454),l=i.n(r)()(a());l.push([e.id,`.ui-app-header {
|
|
316
|
+
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
.ui-app-header-icon {
|
|
320
|
+
width: 150px;
|
|
321
|
+
height: 150px;
|
|
322
|
+
margin-right: 20px;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
.u2-panel {
|
|
326
|
+
gap: 10px;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
.u2-app-header-bottom-line {
|
|
330
|
+
border-bottom: solid 1px lightgrey;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
.u2-app-header-with-name {
|
|
334
|
+
gap: 60px;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
.u2-app-header-with-name .ui-app-header-icon{
|
|
338
|
+
width: 90px;
|
|
339
|
+
height: 90px;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
.u2-app-header-app-name-and-slogan-div {
|
|
343
|
+
gap: 10px;
|
|
344
|
+
margin-top: 10px;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
.u2-app-header-app-name-div {
|
|
348
|
+
font-size: 20px;
|
|
349
|
+
font-weight: bold;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
.u2-app-header-description {
|
|
353
|
+
margin-top: 10px;
|
|
354
|
+
margin-bottom: 10px;
|
|
355
|
+
}`,"",{version:3,sources:["webpack://./../../libraries/utils/dist/src/u2.css"],names:[],mappings:"AAAA;;AAEA;;AAEA;IACI,YAAY;IACZ,aAAa;IACb,kBAAkB;AACtB;;AAEA;IACI,SAAS;AACb;;AAEA;IACI,kCAAkC;AACtC;;AAEA;IACI,SAAS;AACb;;AAEA;IACI,WAAW;IACX,YAAY;AAChB;;AAEA;IACI,SAAS;IACT,gBAAgB;AACpB;;AAEA;IACI,eAAe;IACf,iBAAiB;AACrB;;AAEA;IACI,gBAAgB;IAChB,mBAAmB;AACvB",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}\n\n.u2-app-header-bottom-line {\n border-bottom: solid 1px lightgrey;\n}\n\n.u2-app-header-with-name {\n gap: 60px;\n}\n\n.u2-app-header-with-name .ui-app-header-icon{\n width: 90px;\n height: 90px;\n}\n\n.u2-app-header-app-name-and-slogan-div {\n gap: 10px;\n margin-top: 10px;\n}\n\n.u2-app-header-app-name-div {\n font-size: 20px;\n font-weight: bold;\n}\n\n.u2-app-header-description {\n margin-top: 10px;\n margin-bottom: 10px;\n}"],sourceRoot:""}]);let o=l},946(e,t,i){i.d(t,{A:()=>o});var n=i(126),a=i.n(n),r=i(454),l=i.n(r)()(a());l.push([e.id,`.grok-hit-triage-view .d4-grid {
|
|
356
|
+
width: initial !important;
|
|
357
|
+
height: initial !important;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
table.hit-triage-table {
|
|
361
|
+
margin: 10px;
|
|
362
|
+
width: calc(100% - 20px);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
.hit-triage-table-container {
|
|
366
|
+
max-width: 600px;
|
|
367
|
+
max-height: 500px;
|
|
368
|
+
overflow-y: scroll;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
.hit-triage-error-div {
|
|
372
|
+
color: red;
|
|
373
|
+
text-align: start;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
.mx-5 {
|
|
377
|
+
margin-left: 5px;
|
|
378
|
+
margin-right: 5px;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
.hit-triage-new-template-functions-input > .ui-box {
|
|
382
|
+
height: 300px;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
.hit-triage-new-template-functions-input {
|
|
386
|
+
max-height: 200px;
|
|
387
|
+
max-width: unset !important;
|
|
388
|
+
overflow-y: scroll;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
.hit-triage-new-template-functions-input > .d4-tab-host {
|
|
393
|
+
width: 100% !important;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
.d4-ribbon-name .ui-breadcrumbs {
|
|
397
|
+
overflow: hidden;
|
|
398
|
+
white-space: nowrap;
|
|
399
|
+
text-overflow: ellipsis;
|
|
400
|
+
flex-wrap: nowrap;
|
|
401
|
+
padding: 0;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
.d4-ribbon-name .ui-breadcrumbs i {
|
|
405
|
+
padding: 0 6px;
|
|
406
|
+
font-size: 10px;
|
|
407
|
+
font-weight: bold;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
.d4-ribbon-name .ui-breadcrumbs-element:first-child {
|
|
411
|
+
white-space: nowrap;
|
|
412
|
+
overflow: hidden;
|
|
413
|
+
text-overflow: ellipsis;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
.hit-triage-info-view-container .fa-trash-alt:hover {
|
|
417
|
+
color: #ff0000 !important;
|
|
418
|
+
}`,"",{version:3,sources:["webpack://./css/hit-triage.css"],names:[],mappings:"AAAA;IACI,yBAAyB;IACzB,0BAA0B;AAC9B;;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;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;;AAEA;IACI,yBAAyB;AAC7B",sourcesContent:[".grok-hit-triage-view .d4-grid {\n width: initial !important;\n height: initial !important;\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.d4-ribbon-name .ui-breadcrumbs {\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n flex-wrap: nowrap;\n padding: 0;\n}\n\n.d4-ribbon-name .ui-breadcrumbs i {\n padding: 0 6px;\n font-size: 10px;\n font-weight: bold;\n}\n\n.d4-ribbon-name .ui-breadcrumbs-element:first-child {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.hit-triage-info-view-container .fa-trash-alt:hover {\n color: #ff0000 !important;\n}"],sourceRoot:""}]);let o=l},10(e,t,i){i.d(t,{A:()=>o});var n=i(126),a=i.n(n),r=i(454),l=i.n(r)()(a());l.push([e.id,`img[alt='hitDesignReadmeImg'] {
|
|
419
|
+
max-width: 100%;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
.hit-design-stage-editing-dialog {
|
|
423
|
+
z-index: 10000 !important;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
.hit-design-groupped-campaigns-table .d4-accordion-pane-content.expanded {
|
|
427
|
+
margin: 0 !important;
|
|
428
|
+
}`,"",{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:""}]);let o=l},454(e){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,a,r){"string"==typeof e&&(e=[[null,e,void 0]]);var l={};if(n)for(var o=0;o<this.length;o++){var s=this[o][0];null!=s&&(l[s]=!0)}for(var u=0;u<e.length;u++){var c=[].concat(e[u]);n&&l[c[0]]||(void 0!==r&&(void 0===c[5]||(c[1]="@layer".concat(c[5].length>0?" ".concat(c[5]):""," {").concat(c[1],"}")),c[5]=r),i&&(c[2]&&(c[1]="@media ".concat(c[2]," {").concat(c[1],"}")),c[2]=i),a&&(c[4]?(c[1]="@supports (".concat(c[4],") {").concat(c[1],"}"),c[4]=a):c[4]="".concat(a)),t.push(c))}},t}},126(e){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))));return[t].concat(["/*# ".concat("sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(n)," */")]).join("\n")}return[t].join("\n")}},2(e){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={},r=[],l=0;l<e.length;l++){var o=e[l],s=n.base?o[0]+n.base:o[0],u=a[s]||0,c="".concat(s," ").concat(u);a[s]=u+1;var p=i(c),d={css:o[1],media:o[2],sourceMap:o[3],supports:o[4],layer:o[5]};if(-1!==p)t[p].references++,t[p].updater(d);else{var m=function(e,t){var i=t.domAPI(t);return i.update(e),function(t){t?(t.css!==e.css||t.media!==e.media||t.sourceMap!==e.sourceMap||t.supports!==e.supports||t.layer!==e.layer)&&i.update(e=t):i.remove()}}(d,n);n.byIndex=l,t.splice(l,0,{identifier:c,updater:m,references:1})}r.push(c)}return r}e.exports=function(e,a){var r=n(e=e||[],a=a||{});return function(e){e=e||[];for(var l=0;l<r.length;l++){var o=i(r[l]);t[o].references--}for(var s=n(e,a),u=0;u<r.length;u++){var c=i(r[u]);0===t[c].references&&(t[c].updater(),t.splice(c,1))}r=s}}},129(e){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 Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");n.appendChild(i)}},838(e){e.exports=function(e){var t=document.createElement("style");return e.setAttributes(t,e.attributes),e.insert(t,e.options),t}},986(e,t,i){e.exports=function(e){var t=i.nc;t&&e.setAttribute("nonce",t)}},611(e){e.exports=function(e){if("u"<typeof document)return{update:function(){},remove:function(){}};var t=e.insertStyleElement(e);return{update:function(i){var n,a,r;n="",i.supports&&(n+="@supports (".concat(i.supports,") {")),i.media&&(n+="@media ".concat(i.media," {")),(a=void 0!==i.layer)&&(n+="@layer".concat(i.layer.length>0?" ".concat(i.layer):""," {")),n+=i.css,a&&(n+="}"),i.media&&(n+="}"),i.supports&&(n+="}"),(r=i.sourceMap)&&"u">typeof btoa&&(n+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(r))))," */")),e.styleTagTransform(n,t,e.options)},remove:function(){var e;null===(e=t).parentNode||e.parentNode.removeChild(e)}}}},515(e){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 a=t[n];if(void 0!==a)return a.exports;var r=t[n]={id:n,exports:{}};return e[n](r,r.exports,i),r.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=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.nc=void 0;var n={};(()=>{let e;i.r(n),i.d(n,{demoFileIngest2:()=>nt,pepTriageApp:()=>i9,peptiHitApp:()=>i8,demoFileSubmit:()=>nn,hitDesignAppTreeBrowser:()=>i2,hitDesignApp:()=>i3,pepTriageAppTreeBrowser:()=>i6,htPackageSettingEditor:()=>no,peptiHitAppTreeBrowser:()=>i4,registerMoleculesToViD:()=>na,initHT:()=>i0,demoFileIngest1:()=>ne,demoFileIngest:()=>i7,gasteigerCellRenderer:()=>nl,hitTriageApp:()=>i5,hitDesignVidPanel:()=>nr,HTPackage:()=>nm,_package:()=>nh,demoPeptideSequences:()=>ni,PackageFunctions:()=>nf,hitTriageAppTreeBrowser:()=>i1});let t=grok,a=ui,r=DG,l="campaignId",o="campaignId",s="enriched_table.csv",u="campaign.json",c="HitTriageDataSource",p="HitTriageSubmitFunction",d="Selected hits",m="Stage",h="Molecule",g="Helm",f="V-iD",y="HIT_DESIGN_VID",v="Source",b="New Template",w="Start",A="Create",C="Download",E="Cancel",T="Continue Campaign",x="New Campaign",S="No Information",O="HDCampaignsGrouping",P="HDCampaignTableColumns",N="HDCampaignsTableSorting";var F,B,I,k,V,D,j,_,L=((V={}).None="None",V.Template="Template",V.Status="Status",V.Author="Author",V.LastModifiedUser="Last Modified User",V);let M={Name:e=>{var t;return null!=(t=e.friendlyName)?t:e.name},Code:e=>e.name,Created:e=>e.createDate,Author:e=>{var t;return null!=(t=e.authorUserFriendlyName)?t:""},"Last Modified by":e=>{var t;return null!=(t=e.lastModifiedUserName)?t:""},Molecules:e=>{var t;return(null!=(t=e.rowCount)?t:0).toString()},Status:e=>e.status},H="HTCampaignsGrouping",R="HTCampaignTableColumns",U="HTCampaignsTableSorting",q={Name:e=>{var t;return null!=(t=e.friendlyName)?t:e.name},Code:e=>e.name,Created:e=>e.createDate,Author:e=>{var t;return null!=(t=e.authorUserFriendlyName)?t:""},"Last Modified by":e=>{var t;return null!=(t=e.lastModifiedUserName)?t:""},Total:e=>{var t;return(null!=(t=e.rowCount)?t:0).toString()},Selected:e=>{var t;return(null!=(t=e.filteredRowCount)?t:0).toString()},Status:e=>e.status},Y="pepTriageDataSource";var G=i(2),W=i.n(G),J=i(611),z=i.n(J),Q=i(129),K=i.n(Q),Z=i(986),X=i.n(Z),ee=i(838),et=i.n(ee),ei=i(515),en=i.n(ei),ea=i(946),er={};er.styleTagTransform=en(),er.setAttributes=X(),er.insert=K().bind(null,"head"),er.domAPI=z(),er.insertStyleElement=et(),W()(ea.A,er),ea.A&&ea.A.locals&&ea.A.locals;let el="script",eo="function-package",es="data-query",eu="HTScript",ec="HTQuery",ep="molecules";function ed(e,t,i,n,a,r,l){try{var o=e[r](l),s=o.value}catch(e){i(e);return}o.done?t(s):Promise.resolve(s).then(n,a)}function em(e){var t,i,n;let a=null!=(t=localStorage.getItem(e))?t:"{}";try{let e=JSON.parse(a);return{order:null!=(i=null==e?void 0:e.order)?i:[],hidden:null!=(n=null==e?void 0:e.hidden)?n:[]}}catch(e){console.error("error parsing function ordering",e)}return{order:[],hidden:[]}}function eh(e){try{var t;return null==(t=e.package)?void 0:t.name}catch(e){return}}function eg(e,t,i){var n;return(n=function*(){if(0===i.rowCount)return;let n=e.col(t);if(!n)throw Error("There is no molecule column in dataframe");let a=i.col(ep);if(a||(yield i.meta.detectSemanticTypes(),a=i.columns.bySemType(r.SEMTYPE.MOLECULE)),!a)throw Error("There is no original molecule column in query result dataframe");let l=i.columns.names().filter(e=>(null==e?void 0:e.toLowerCase())!==ep),o=l.filter(t=>{let n=e.col(t);return null!=n&&n.type===i.col(t).type});var s=!0,u=!1,c=void 0;try{for(var p,d=l[Symbol.iterator]();!(s=(p=d.next()).done);s=!0){let t=p.value;!o.includes(t)&&e.col(t)&&e.columns.remove(t)}}catch(e){u=!0,c=e}finally{try{s||null==d.return||d.return()}finally{if(u)throw c}}if(o.length){let t=new Map;for(let e=0;e<a.length;e++){if(a.isNone(e))continue;let i=a.get(e);t.has(i)||t.set(i,e)}var m=!0,h=!1,g=void 0;try{for(var f,y=o[Symbol.iterator]();!(m=(f=y.next()).done);m=!0){let a=f.value,r=i.col(a),l=e.col(a);for(let e=0;e<n.length;e++){let i=n.isNone(e)?void 0:t.get(n.get(e));l.set(e,void 0===i||r.isNone(i)?null:r.get(i),!1)}}}catch(e){h=!0,g=e}finally{try{m||null==y.return||y.return()}finally{if(h)throw g}}}let v=l.filter(e=>!o.includes(e));v.length&&e.join(i,[t],[a.name],void 0,v,void 0,!0)},function(){var e=this,t=arguments;return new Promise(function(i,a){var r=n.apply(e,t);function l(e){ed(r,i,a,l,o,"next",e)}function o(e){ed(r,i,a,l,o,"throw",e)}l(void 0)})})()}function ef(e,t,i,n,a,r,l){try{var o=e[r](l),s=o.value}catch(e){i(e);return}o.done?t(s):Promise.resolve(s).then(n,a)}function ey(e){return function(){var t=this,i=arguments;return new Promise(function(n,a){var r=e.apply(t,i);function l(e){ef(r,n,a,l,o,"next",e)}function o(e){ef(r,n,a,l,o,"throw",e)}l(void 0)})}}let ev=e=>`${e.getFullYear()}/${e.getMonth()+1}/${e.getDate()}`;function eb(e,t){let i=document.title,n=window.location.href.split("?")[0]+"?"+e+"="+t;if(history.replaceState){let e={Title:i,Url:n};history.replaceState(e,e.Title,e.Url)}}function ew(e,i,n,r){var l;let o=a.breadcrumbs([i,n]),s=o.onPathClick.subscribe(t=>{1===t.length&&(s.unsubscribe(),eA(e),r())}),u=null==(l=t.shell.v.ribbonMenu.root.parentElement)?void 0:l.getElementsByClassName("d4-ribbon-name")[0];return u&&(u.textContent="",u.appendChild(o.root)),{breadcrumbs:o,sub:s}}function eA(e){let t=e.getRibbonPanels();(null==t?void 0:t.length)&&(t.pop(),e.setRibbonPanels(t))}function eC(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 eE(e,i){return ey(function*(){try{var n,a,l,o,s;let u=r.User.current().id,c=null==(n=r.User.current().group)?void 0:n.id;if(e===u)return!0;for(let e of i){let i=yield t.dapi.groups.find(e);if(i){if(i.personal){let e=yield t.dapi.groups.getUser(i);if((null==e?void 0:e.id)===u)return!0}else if(c&&((null!=(a=null==(o=i.members)?void 0:o.length)?a:0)>0&&i.members.some(e=>(null==e?void 0:e.id)===c)||(null!=(l=null==(s=i.adminMembers)?void 0:s.length)?l:0)>0&&i.adminMembers.some(e=>(null==e?void 0:e.id)===c)))return!0}}}catch(e){nh.logger.error(e)}return!1})()}function eT(e,t){return ey(function*(){return eE(e,t.edit)})()}function ex(e,t){return ey(function*(){return eE(e,Array.from(new Set([...t.view,...t.edit])))})()}function eS(e){return localStorage.getItem(e)}function eO(e,t){localStorage.setItem(e,t)}function eP(e,t,i){if(!t)return;let n=null!=i?i:M,a=t.columnName in n?n[t.columnName]:e=>{var i,n,a;return null!=(i=null==(a=e.campaignFields)?void 0:a[null!=(n=t.columnName.replace("campaignFields.",""))?n:""])?i:""},r=new Map;e.forEach(e=>{r.set(e,a(e))});let l=Array.from(r.values()).every(e=>{var t;return ej(e)||!isNaN(Number(null!=(t=null==e?void 0:e.toString())?t:""))}),o=!l&&Array.from(r.values()).every(e=>{var t;return ej(e)||!isNaN(Date.parse(null!=(t=null==e?void 0:e.toString())?t:""))});l?e.forEach(e=>{r.set(e,ej(r.get(e))?t.ascending?1/0:-1/0:Number(r.get(e)))}):o&&e.forEach(e=>{var i,n;r.set(e,ej(r.get(e))?t.ascending?1/0:-1/0:Date.parse(null!=(i=null==(n=r.get(e))?void 0:n.toString())?i:""))}),e.sort((e,i)=>{let n=r.get(e),a=r.get(i);if(l||o)return t.ascending?n-a:a-n;let s=ej(n)?"":n.toString(),u=ej(a)?"":a.toString();return t.ascending?s.localeCompare(u):u.localeCompare(s)}),r.clear()}function eN(){let e=eS(P),t=["Code","Created","Author","Last Modified by","Molecules","Status"];if(!e)return t;try{let i=JSON.parse(e);if(Array.isArray(i)&&i.every(e=>"string"==typeof e))return i;return t}catch(e){return console.error("error parsing campaign table columns",e),t}}function eF(e){eO(P,JSON.stringify(e))}function eB(){let e=eS(R),t=["Created","Author","Total","Selected","Status"];if(!e)return t;try{let i=JSON.parse(e);if(Array.isArray(i)&&i.every(e=>"string"==typeof e))return i;return t}catch(e){return console.error("error parsing HT campaign table columns",e),t}}function eI(e){eO(R,JSON.stringify(e))}let ek=(e,t)=>{var i,n,a,r,l,o;switch(e){case L.Template:return null!=(i=null==(n=t.template)?void 0:n.key)?i:t.templateName;case L.Status:return t.status;case L.Author:return null!=(a=t.authorUserFriendlyName)?a:S;case L.LastModifiedUser:return null!=(r=t.lastModifiedUserName)?r:S;default:if(e.startsWith("campaignFields.")){let i=e.replace("campaignFields.","");return null!=(l=null==(o=t.campaignFields)?void 0:o[i])?l:S}return""}};function eV(e,t){if(t===L.None)return{"":e};let i={};for(let n of e){let e=ek(t,n);i[e]||(i[e]=[]),i[e].push(n)}return i}function eD(e,t,i=9){e.classList.add("hit-design-groupped-campaigns-table");let n=Object.keys(t);if(n.length<2)return e;let r=e.getElementsByTagName("tbody")[0],l=Array.from(e.getElementsByTagName("tr")).filter(e=>!e.classList.contains("header")),o=0,s=(e,t,i)=>{var n;for(let a=t;a<i;a++)(null==(n=l[a])?void 0:n.style)&&(l[a].style.display=e?"table-row":"none")};for(let e of n){let n=l[o];if(!n)break;let u=t[e].length,c=o,p=o+u,d=a.accordion(`Hit-Design-campaigns-group-${e}`).addPane(e,()=>a.div(),void 0,void 0,!1);d.root.style.marginLeft="-24px",d.root.onclick=()=>{s(d.expanded,c,p)},s(d.expanded,c,p);let m=r.insertRow(0),h=m.insertCell(0);h.appendChild(d.root),h.colSpan=i,r.insertBefore(m,n),o+=u}}function ej(e){return""===e||null==e||"number"==typeof e&&isNaN(e)}function e_(e){return ey(function*(){return JSON.parse((yield nh.files.readAsText(e)))})()}let eL={String:r.TYPE.STRING,Number:r.TYPE.FLOAT,Boolean:r.TYPE.BOOL,Date:r.TYPE.DATE_TIME,Molecule:r.SEMTYPE.MOLECULE};function e$(e,t,i,n,a,r,l){try{var o=e[r](l),s=o.value}catch(e){i(e);return}o.done?t(s):Promise.resolve(s).then(n,a)}function eM(e){return function(){var t=this,i=arguments;return new Promise(function(n,a){var r=e.apply(t,i);function l(e){e$(r,n,a,l,o,"next",e)}function o(e){e$(r,n,a,l,o,"throw",e)}l(void 0)})}}function eH(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{},n=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(i).filter(function(e){return Object.getOwnPropertyDescriptor(i,e).enumerable}))),n.forEach(function(t){var n;n=i[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}function eR(e,i,n){return eM(function*(e,i,n=c,l){var o,s,u;let p=a.divText("",{style:{color:"red"}}),d=null,m=()=>eM(function*(){try{if(!(d=h.value))return;if(yield d.meta.detectSemanticTypes(),!d.columns.bySemType(r.SEMTYPE.MOLECULE)){p.innerText="No molecules column found";return}p.innerText=""}catch(e){p.innerText="Error parsing file"}})(),h=a.input.table("Dataframe",{onValueChanged:m});yield m();let g=a.div([h,p]);0===Object.keys(i).length&&Array.from(new Set(r.Func.find({meta:{role:n}}).concat(r.Func.find({tags:[n]})))).forEach(e=>{var t;i[null!=(t=e.friendlyName)?t:e.name]=e});let f=null,y=()=>eM(function*(){f=i[A.value].prepare();let e=yield f.getEditor();e.classList.remove("ui-form"),b.innerHTML="",b.appendChild(e)})(),b=a.div([]),A=a.input.choice(v,{value:null!=(o=e.queryFunctionName)?o:Object.keys(i)[0],items:Object.keys(i),onValueChanged:y});yield y(),e.queryFunctionName&&(null==(u=A.root.getElementsByTagName("select").item(0))||u.setAttribute("disabled","true"));let C=a.div([A,b]);C.style.display="none";let T=a.div([g,C]),x=a.input.string("Campaign Name",{value:"",nullable:!0});x.setTooltip("Optional friendly name for the campaign");let S=e.campaignFields.map(e=>{var t,i;return e.type===r.SEMTYPE.MOLECULE?(t=eH({},e),i=i={type:"String",semtype:r.SEMTYPE.MOLECULE},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t.push.apply(t,i)}return t})(Object(i)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}),t):e}).map(e=>r.Property.fromOptions(eH({name:e.name,type:eL[e.type],nullable:!e.required},e.semtype?{semType:e.semtype}:{}))),O={},P=S.length?a.input.form(O,S):a.div();P.classList.remove("ui-form"),"File"===e.dataSourceType?(g.style.display="inherit",C.style.display="none"):(g.style.display="none",C.style.display="inherit");let N=a.div([x.root,...null!=(s=null==l?void 0:l.extraFormElements)?s:[],T,...S.length?[P]:[]]),F=a.buttonsInput([]);return N.appendChild(F),{promise:new Promise(n=>{let r=a.bigButton(w,()=>eM(function*(){var a,r,o,s;if("File"===e.dataSourceType){if(!d)return void t.shell.error("No file selected");let e=d;e.name=d.name,n({df:e,type:"File",campaignProps:O,friendlyName:(null==(a=x.value)?void 0:a.trim())||void 0,extraData:null==l||null==(r=l.getExtraData)?void 0:r.call(l)})}else{let e=i[A.value];if(!e)return void t.shell.error("No function selected");let a={};Object.entries(f.inputs).forEach(([e,t])=>{a[e]=t}),n({df:yield e.apply(a),type:"Query",campaignProps:O,friendlyName:(null==(o=x.value)?void 0:o.trim())||void 0,extraData:null==l||null==(s=l.getExtraData)?void 0:s.call(l)})}})());F.appendChild(r)}),root:N,cancelPromise:new Promise(e=>{a.button(E,()=>e())})}}).apply(this,arguments)}let eU=$;var eq=i.n(eU),eY=i(804),eG={};function eW(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=Array(t);i<t;i++)n[i]=e[i];return n}function eJ(e,t,i,n,a,r,l){try{var o=e[r](l),s=o.value}catch(e){i(e);return}o.done?t(s):Promise.resolve(s).then(n,a)}function ez(e){return function(){var t=this,i=arguments;return new Promise(function(n,a){var r=e.apply(t,i);function l(e){eJ(r,n,a,l,o,"next",e)}function o(e){eJ(r,n,a,l,o,"throw",e)}l(void 0)})}}function eQ(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var i,n,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var r=[],l=!0,o=!1;try{for(a=a.call(e);!(l=(i=a.next()).done)&&(r.push(i.value),!t||r.length!==t);l=!0);}catch(e){o=!0,n=e}finally{try{l||null==a.return||a.return()}finally{if(o)throw n}}return r}}(e,t)||function(e,t){if(e){if("string"==typeof e)return eW(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);if("Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i)return Array.from(i);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return eW(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function eK(e,t,i,n,a,r,l){try{var o=e[r](l),s=o.value}catch(e){i(e);return}o.done?t(s):Promise.resolve(s).then(n,a)}function eZ(e,i,n,l,o,s){var u;return(u=function*(){var u,c,p,d,m;return u=e.computeFunctions,c=()=>t.chem.descriptorsTree(),p="HTFunctionOrderingLS",d=void 0,m=s?{label:"Re-run when campaign opens",tooltip:"Recompute this function for the whole molecule column every time this campaign is opened. Useful for database lookups that may resolve after the molecule was first drawn."}:void 0,ez(function*(){let e,t,s,h,g,f=p,y=[];u.functions.filter(e=>{let t=e.inputs;return t.length>=2&&"dataframe"===t[0].propertyType&&"column"===t[1].propertyType}).forEach(e=>{var t,i,n,a;y.push({func:e,args:null!=(t=null==l||null==(a=l.compute)||null==(n=a.functions)||null==(i=n.find(t=>t.name===e.name&&t.package===e.package.name))?void 0:i.args)?t:{}})}),u.scripts.filter(e=>{let t=e.inputs;return t.length>=2&&"dataframe"===t[0].propertyType&&"column"===t[1].propertyType}).forEach(e=>{var t,i,n,a;y.push({func:e,args:null!=(t=null==l||null==(a=l.compute)||null==(n=a.scripts)||null==(i=n.find(t=>t.id===e.id))?void 0:i.args)?t:{}})}),u.queries.filter(e=>e.inputs.length>0&&"list"===e.inputs[0].propertyType).forEach(e=>{var t,i,n,a;y.push({func:e,args:null!=(t=null==l||null==(a=l.compute)||null==(n=a.queries)||null==(i=n.find(t=>t.id===e.id))?void 0:i.args)?t:{}})});let v=a.div([],{classes:"statistics-compute-dialog-host"}),b=[],w=a.tree(),A=a.wait(()=>ez(function*(){try{if(!c)return a.divText("No descriptors provider configured");let f=yield c();w.root.classList.add("statistics-compute-dialog-descriptors-group");let y=Object.keys(f),v=null!=(n=null==l||null==(o=l.compute)||null==(r=o.descriptors)?void 0:r.args)?n:[];var e=!0,t=!1,i=void 0;try{for(var n,r,o,s,u=y[Symbol.iterator]();!(e=(s=u.next()).done);e=!0){let e=s.value,t=function(e,t){let i=t.group(e,null,!1);return i.enableCheckBox(!1),i}(e,w);var p=!0,d=!1,m=void 0;try{for(var h,g=f[e].descriptors[Symbol.iterator]();!(p=(h=g.next()).done);p=!0){let e=h.value,i=t.item(e.name,e);b.push(i),i.enableCheckBox(v.includes(e.name))}}catch(e){d=!0,m=e}finally{try{p||null==g.return||g.return()}finally{if(d)throw m}}}}catch(e){t=!0,i=e}finally{try{e||null==u.return||u.return()}finally{if(t)throw i}}return w.root}catch(e){console.error(e)}return a.divText("Failed to load descriptors")})());A.classList.add("oy-scroll");let C="Descriptors",E={[C]:C},T={[C]:A},x={},S={[C]:!1};S[C]=!!(null==l||null==(D=l.compute)||null==(V=D.descriptors)?void 0:V.enabled)&&(null==l||null==(L=l.compute)||null==(_=L.descriptors)||null==(j=_.args)?void 0:j.length)>0;let O={};var P,N,F,B=!0,I=!1,k=void 0;try{for(var V,D,j,_,L,M,H,R,U,q,Y,G,W,J,z,Q,K,Z,X,ee,et,ei,en,ea,er=y[Symbol.iterator]();!(B=(ea=er.next()).done);B=!0){let e=ea.value;try{let t=e.func,i=t.prepare(e.args),n=t.type===eo?`${t.package.name}:${t.name}`:t.type===el?`${eu}:${null!=(M=t.name)?M:""}:${t.id}`:`${ec}:${null!=(H=t.name)?H:""}:${t.id}`;x[n]=i;let r=a.div();a.setUpdateIndicator(r,!0),i.buildEditor(r,{condensed:!1}).then(i=>{var n,a;(null==i||null==(n=i[0])?void 0:n.root)&&(i[0].root.style.display="none"),(null==i||null==(a=i[1])?void 0:a.root)&&t.type!==es&&(i[1].root.style.display="none"),i.forEach(t=>{var i,n;(null==(i=t.property)?void 0:i.name)&&Object.keys(e.args).includes(null==(n=t.property)?void 0:n.name)&&(t.value=e.args[t.property.name]),t.fireChanged()})}).catch(e=>{console.error(e),a.setUpdateIndicator(r,!1),r.appendChild(a.divText("Failed to build function editor"))}).finally(()=>a.setUpdateIndicator(r,!1)),r.classList.add("oy-scroll"),r.style.marginLeft="15px",r.style.removeProperty("max-width"),E[null!=(R=t.friendlyName)?R:t.name]=n,S[n]=null!=(U=(null==l||null==(W=l.compute)||null==(G=W.functions)?void 0:G.some(t=>e.func.type===eo&&t.name===e.func.name&&t.package===eh(e.func)))||(null==l||null==(z=l.compute)||null==(J=z.scripts)?void 0:J.some(e=>e.id===t.id))||(null==l||null==(K=l.compute)||null==(Q=K.queries)?void 0:Q.some(e=>e.id===t.id)))&&U,O[n]=null!=(q=(null==l||null==(X=l.compute)||null==(Z=X.functions)?void 0:Z.some(e=>`${e.package}:${e.name}`===n&&e.rerunOnOpen))||(null==l||null==(et=l.compute)||null==(ee=et.scripts)?void 0:ee.some(e=>`${eu}:${e.name}:${e.id}`===n&&e.rerunOnOpen))||(null==l||null==(en=l.compute)||null==(ei=en.queries)?void 0:ei.some(e=>`${ec}:${e.name}:${e.id}`===n&&e.rerunOnOpen)))&&q,T[null!=(Y=t.friendlyName)?Y:t.name]=function(e,t){if(!m||e===C)return t;let i=a.input.bool(m.label,{value:!!O[e],onValueChanged:t=>{O[e]=!!t}});return i.setTooltip(m.tooltip),i.root.classList.add("statistics-compute-dialog-rerun-input"),a.divV([i.root,t])}(n,r)}catch(e){console.error(e);continue}}}catch(e){I=!0,k=e}finally{try{B||null==er.return||er.return()}finally{if(I)throw k}}let ep=a.tabControl(T,{vertical:!0});ep.onTabChanged.subscribe(()=>{try{ep.currentPane.content.style.removeProperty("max-width")}catch(e){}}),ep.header.style.overflow="scroll",ep.root.style.width="100%",ep.root.style.minWidth="350px",v.appendChild(ep.root);let ed=[];function eg(e){var t,i;ep.clear();let n=null!=(t=e.order)?t:Object.keys(T);0===n.length&&(n=Object.keys(T)),n.forEach(e=>{T[e]&&ep.addPane(e,()=>T[e])}),Object.keys(T).forEach(t=>{var i;n.includes(t)||!T[t]||(null!=(i=e.hidden)?i:[]).includes(t)||ep.addPane(t,()=>T[t])}),(null!=(i=e.hidden)?i:[]).forEach(e=>{S[E[e]]=!1}),ed=[],ep.panes.forEach(e=>{let t=E[e.name],i=!!S[t],n=i=>{var n,a;if(d&&i)for(let e=0;e<ed.length;e++)E[ep.panes[e].name]!==t&&(ed[e].value=null),S[E[ep.panes[e].name]]=!1;S[t]=i,i?null==(a=eq()(e.content).find("input"))||a.removeAttr("disabled"):null==(n=eq()(e.content).find("input"))||n.attr("disabled","true")},r=d?a.input.radio("",{items:[""],value:i?"":void 0,onValueChanged:e=>n(""===e)}):a.input.bool("",{value:i,onValueChanged:e=>n(!!e)});r.setTooltip("Toggle calculation of this function"),ed.push(r),e.header.appendChild(r.root),e.header.classList.add("statistics-compute-dialog-pane-header")}),ep.panes.length>0&&(ep.currentPane=ep.panes[0])}function ef(){let e={descriptors:[],externals:{},scripts:{},queries:{}};m&&(e.rerunOnOpen={},Object.keys(O).forEach(t=>{S[t]&&O[t]&&(e.rerunOnOpen[t]=!0)})),e.descriptors=S[C]?b.filter(e=>e.checked).map(e=>e.value.name):[];let t=Object.entries(x).filter(e=>{let t=eQ(e,2),i=t[0];return t[1],S[i]});t.filter(e=>{let t=eQ(e,2),i=t[0];return t[1],!i.startsWith(eu)&&!i.startsWith(ec)}).forEach(t=>{let i=eQ(t,2),n=i[0],a=i[1];e.externals[n]={},Object.entries(a.inputs).slice(2).forEach(t=>{let i=eQ(t,2),a=i[0],r=i[1];e.externals[n][a]=r})}),t.filter(e=>{let t=eQ(e,2),i=t[0];return t[1],i.startsWith(eu)}).forEach(t=>{let i=eQ(t,2),n=i[0],a=i[1];e.scripts[n]={},Object.entries(a.inputs).slice(2).forEach(t=>{let i=eQ(t,2),a=i[0],r=i[1];e.scripts[n][a]=r})}),t.filter(e=>{let t=eQ(e,2),i=t[0];return t[1],i.startsWith(ec)}).forEach(t=>{let i=eQ(t,2),n=i[0],a=i[1];e.queries[n]={},Object.entries(a.inputs).slice(1).forEach(t=>{let i=eQ(t,2),a=i[0],r=i[1];e.queries[n][a]=r})}),console.log(e),i(e)}return eg(em(f)),ep.root.appendChild((P=Object.keys(T),N=e=>{eg(e)},e=em(f),(t=r.DataFrame.fromColumns(P.map(e=>r.Column.fromStrings(e,[e])))).columns.setOrder(null!=(F=e.order)?F:[]),(s=a.input.columns("reorder",{table:t,value:t.columns.toList().filter(t=>!e.hidden.includes(t.name))})).onChanged.subscribe(()=>{try{let e=s.value.map(e=>e.name),i=P.filter(t=>!e.includes(t)),n={order:s.value.map(e=>e.name),hidden:i};t.columns.setOrder(n.order),localStorage.setItem(f,JSON.stringify(n)),N(n)}catch(e){console.error(e)}}),h=Array.from(s.root.children),setTimeout(()=>{h.forEach(e=>{e.style.maxWidth="0px",e.style.overflow="hidden",e.style.padding="0px",e.style.paddingRight="0px",e.style.visibility="hidden",e instanceof HTMLLabelElement&&(e.style.display="none")})},200),s.root.style.justifyContent="end",s.root.style.width="40px",s.root.style.height="0px",s.root.style.overflow="visible",s.root.style.padding="0px",g=a.icons.edit(()=>{h.forEach(e=>{e.click()})},"Order or hide functions"),s.addOptions(g),Array.from(s.root.children).forEach(e=>{e.style.borderBottom="unset"}),g.style.fontSize="16px",s.root)),o&&a.dialog("Compute").add(v).onOK(()=>ef()).onCancel(n).show({resizable:!0}),{root:v,okProxy:ef}})()},function(){var e=this,t=arguments;return new Promise(function(i,n){var a=u.apply(e,t);function r(e){eK(a,i,n,r,l,"next",e)}function l(e){eK(a,i,n,r,l,"throw",e)}r(void 0)})})()}eG.styleTagTransform=en(),eG.setAttributes=X(),eG.insert=K().bind(null,"head"),eG.domAPI=z(),eG.insertStyleElement=et(),W()(eY.A,eG),eY.A&&eY.A.locals&&eY.A.locals;let eX=rxjs;class e0{get root(){return this._root}get items(){return this._items}set items(e){this._items=e,this.render()}addItem(e,t){this._items.push(e),this.render(),(void 0===t||t)&&this.onItemAdded.next(e)}removeItem(e,t){-1!==this._items.indexOf(e)&&(this._items.splice(this._items.indexOf(e),1),this.render(),(void 0===t||t)&&this.onItemRemoved.next(e))}removeAtIndex(e,t){if(e<0||e>=this._items.length)return;let i=this._items.splice(e,1);this.render(),(void 0===t||t)&&this.onItemRemoved.next(i[0])}removeAllItems(){this._items=[],this.render()}render(){if(a.empty(this._root),!this.options.horizontalInputNames){var e=!0,t=!1,i=void 0;try{for(var n,r,l,o=this.properties[Symbol.iterator]();!(e=(l=o.next()).done);e=!0){let e=l.value,t=null!=(n=e.caption)?n:e.name;(null==(r=this.options.customLabels)?void 0:r[e.name])&&(t=this.options.customLabels[e.name]);let i=a.divText(t);i.style.fontWeight="bold",this._root.appendChild(i)}}catch(e){t=!0,i=e}finally{try{e||null==o.return||o.return()}finally{if(t)throw i}}}var s=!0,u=!1,c=void 0;try{for(var p,d=this._items[Symbol.iterator]();!(s=(p=d.next()).done);s=!0){let e=p.value,t=this.getItemDiv(e);var m=!0,h=!1,g=void 0;try{for(var f,y=t[Symbol.iterator]();!(m=(f=y.next()).done);m=!0){let e=f.value;this._root.appendChild(e)}}catch(e){h=!0,g=e}finally{try{m||null==y.return||y.return()}finally{if(h)throw g}}}}catch(e){u=!0,c=e}finally{try{s||null==d.return||d.return()}finally{if(u)throw c}}if(this.options.allowAdd){let e=this.getItemDiv(null!=(A=null==(C=(E=this.options).newItemFunction)?void 0:C.call(E))?A:void 0,!0);var v=!0,b=!1,w=void 0;try{for(var A,C,E,T,x=e[Symbol.iterator]();!(v=(T=x.next()).done);v=!0){let e=T.value;this._root.appendChild(e)}}catch(e){b=!0,w=e}finally{try{v||null==x.return||x.return()}finally{if(b)throw w}}}}get addingItem(){let e={};return Object.keys(this.addingItemInputs).forEach(t=>{e[t]=this.addingItemInputs[t].value}),e}getItemDiv(e,t){let i=void 0===e?{}:e,n=[],l={},o=null;var s=!0,u=!1,c=void 0;try{for(var p,d,m,h=this.properties[Symbol.iterator]();!(s=(m=h.next()).done);s=!0){let e=m.value;void 0===i[e.name]&&(i[e.name]=null);let s=(null==(p=this.options.customInputs)?void 0:p[e.name])?this.options.customInputs[e.name](i):a.input.forProperty(e,i),u=null==(d=this.options.validators)?void 0:d[e.name];u&&s.addValidator(u),n.push(this.options.horizontalInputNames?s.root:this.hideLabel(s.root)),e.propertyType!==r.TYPE.BOOL&&"color"!==e.name.toLowerCase()&&s.input&&(s.input.style.width="100%"),l[e.name]=s,s.onChanged.subscribe(()=>{i[e.name]=s.value,t?this.onAddingItemChanged.next({item:i,fieldName:e.name}):this.onItemChanged.next({item:i,fieldName:e.name})}),s.root.style.alignItems="center",o=s}}catch(e){u=!0,c=e}finally{try{s||null==h.return||h.return()}finally{if(u)throw c}}let g=null;if(t)this.addingItemInputs=l,g=a.icons.add(()=>{let e=this.options.newItemFunction?this.options.newItemFunction():{};Object.keys(l).forEach(t=>{e[t]=l[t].value}),this._items.push(e),this.onItemAdded.next(e),this.render()},this.options.addButtonTooltip);else{if(!this.options.allowRemove)return n;g=a.icons.delete(()=>{this._items.splice(this._items.indexOf(i),1),this.onItemRemoved.next(i),this.render()},this.options.removeButtonTooltip)}return o&&o.addOptions?o.addOptions(g):null==o||o.root.appendChild(g),g.style.color="#2083d5",n}hideLabel(e){return e.getElementsByTagName("label")[0]&&e.removeChild(e.getElementsByTagName("label")[0]),e}hasErrors(){return this._root.querySelectorAll(".d4-invalid").length>0}constructor(e,t,i){this.onItemChanged=new eX.Subject,this.onAddingItemChanged=new eX.Subject,this.onItemAdded=new eX.Subject,this.onItemRemoved=new eX.Subject,this.options={removeButtonTooltip:"Remove item",addButtonTooltip:"Add item",allowAdd:!0,allowRemove:!0},this.addingItemInputs={},this.properties=e,this.options=function(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{},n=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(i).filter(function(e){return Object.getOwnPropertyDescriptor(i,e).enumerable}))),n.forEach(function(t){var n;n=i[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({},this.options,void 0===i?{}:i),this._root=a.divV([],{style:{display:"grid",gridTemplateColumns:`repeat(${this.properties.length}, 1fr)`,alignItems:"center",gap:"12px"},classes:"ui-items-grid"}),this._items=void 0===t?[]:t,this.render()}}function e1(e,t,i,n,a,r,l){try{var o=e[r](l),s=o.value}catch(e){i(e);return}o.done?t(s):Promise.resolve(s).then(n,a)}function e2(){let e=r.Property.fromOptions({name:"layout",caption:"Layout",type:"file"}),i=r.InputBase.forProperty(e),n=null,l=null,o=null,s=null;return i.onChanged.subscribe(e=>{var a;return(a=function*(){let e=i.value;if(e){try{o=e.fullPath&&(yield t.dapi.files.exists(e.fullPath))?e.fullPath:null}catch(e){o=null}try{let t=yield e.readAsString(),i=r.ViewLayout.fromJson(t);i?(n=i,l=i.viewState,s=null):(n=null,l=null,o=null,s="Invalid layout file")}catch(e){n=null,l=null,o=null,s="Invalid layout file"}i.input.classList[s?"add":"remove"]("d4-invalid")}else n=null,l=null,o=null},function(){var e=this,t=arguments;return new Promise(function(i,n){var r=a.apply(e,t);function l(e){e1(r,i,n,l,o,"next",e)}function o(e){e1(r,i,n,l,o,"throw",e)}l(void 0)})})()}),a.tooltip.bind(i.root,()=>s||"Select a layout file"),{dataFileInput:i,getLayout:()=>n,getLayoutViewState:()=>l,getLocalFilePath:()=>o}}function e4(e,t,i,n,a,r,l){try{var o=e[r](l),s=o.value}catch(e){i(e);return}o.done?t(s):Promise.resolve(s).then(n,a)}function e5(e){return function(){var t=this,i=arguments;return new Promise(function(n,a){var r=e.apply(t,i);function l(e){e4(r,n,a,l,o,"next",e)}function o(e){e4(r,n,a,l,o,"throw",e)}l(void 0)})}}function e3(e){let t=new e0([r.Property.fromOptions({name:"Name",type:r.TYPE.STRING}),r.Property.fromOptions({name:"Type",type:r.TYPE.STRING,choices:Object.keys(eL)}),r.Property.fromOptions({name:"Required",type:r.TYPE.BOOL})],e?e.map(e=>({Name:e.name,Type:e.type,Required:e.required})):void 0,{horizontalInputNames:!1});t.root.style.maxWidth="750px";let i={};t.onItemAdded.subscribe(e=>{i={}}),t.onAddingItemChanged.subscribe(e=>{e&&(i=e.item)});let n=a.h2("Additional fields");a.tooltip.bind(n,"Additional fields to be filled by user for each campaign");let l=a.div([n,t.root]);return{getFields:function(){let e=t.items.filter(e=>e.Name).map(e=>{var t;return{name:e.Name,type:e.Type,required:null!=(t=e.Required)&&t}});if(i.Name&&""!==i.Name&&i.Type){var n;null!=(n=i).Required||(n.Required=!1),e.push({name:i.Name,type:i.Type,required:i.Required})}return e},fieldsDiv:a.div([l])}}function e8(e,t,i,n,a,r,l){try{var o=e[r](l),s=o.value}catch(e){i(e);return}o.done?t(s):Promise.resolve(s).then(n,a)}function e6(e){return function(){var t=this,i=arguments;return new Promise(function(n,a){var r=e.apply(t,i);function l(e){e8(r,n,a,l,o,"next",e)}function o(e){e8(r,n,a,l,o,"throw",e)}l(void 0)})}}class e9 extends r.ViewBase{get template(){return this.app.template}onActivated(){}onReset(){}process(){return e6(function*(){})()}deleteCampaign(e,t){return e6(function*(){var i;yield nh.files.delete(`${e}/campaigns/${t}`),null==(i=nh.campaignsCache[e])||delete i[t]})()}deleteCampaignAndRefresh(e,t){return e6(function*(){var i;yield this.deleteCampaign(e,t),this.deletedCampaigns.push(t),yield null==(i=this.init)?void 0:i.call(this)}).call(this)}constructor(e){super(),this.deletedCampaigns=[],this.app=e}}var e7=i(312),te={};function tt(e,t,i,n,a,r,l){try{var o=e[r](l),s=o.value}catch(e){i(e);return}o.done?t(s):Promise.resolve(s).then(n,a)}function ti(e,t,i,n,a,r,l){try{var o=e[r](l),s=o.value}catch(e){i(e);return}o.done?t(s):Promise.resolve(s).then(n,a)}function tn(e){return function(){var t=this,i=arguments;return new Promise(function(n,a){var r=e.apply(t,i);function l(e){ti(r,n,a,l,o,"next",e)}function o(e){ti(r,n,a,l,o,"throw",e)}l(void 0)})}}te.styleTagTransform=en(),te.setAttributes=X(),te.insert=K().bind(null,"head"),te.domAPI=z(),te.insertStyleElement=et(),W()(e7.A,te),e7.A&&e7.A.locals&&e7.A.locals,(B=e=(F=D||(D={})).panels||(F.panels={})).vert=function(e,t){return r._options(a.divV(e.map(e=>a.render(e)),{classes:"u2-panel"}),t)},B.horz=function(e,t){return r._options(a.divH(e.map(e=>a.render(e)),{classes:"u2-panel"}),t)},F.appHeader=function(t){let i=a.iconImage("",t.iconPath);eq()(i).addClass("ui-app-header-icon").css("margin-right","20px"),t.iconSize&&(i.style.width=`${t.iconSize}px`,i.style.height=`${t.iconSize}px`);let n=e.horz([],{classes:"ui-app-header"});if(t.appTitle){n.classList.add("u2-app-header-with-name");let e=a.divV([a.divText(t.appTitle,"u2-app-header-app-name-div")],"u2-app-header-app-name-and-slogan-div");t.appSubTitle&&e.append(a.divText(t.appSubTitle));let r=a.div(i);n.append(a.divH([r,e]))}else n.append(i);let r=e.vert([a.markdown(t.description),t.learnMoreUrl?a.link("Learn more",t.learnMoreUrl,void 0,{style:{marginLeft:"15px"}}):null]);return r.classList.add("u2-app-header-description"),n.append(r),t.bottomLine&&n.classList.add("u2-app-header-bottom-line"),n},(F.tools||(F.tools={})).runAsync=function(e,i){var n;return(n=function*(){a.setUpdateIndicator(e,!0);try{return yield i()}catch(e){t.log.error(e)}finally{a.setUpdateIndicator(e,!1)}},function(){var e=this,t=arguments;return new Promise(function(i,a){var r=n.apply(e,t);function l(e){tt(r,i,a,l,o,"next",e)}function o(e){tt(r,i,a,l,o,"throw",e)}l(void 0)})})()};let ta={view:[r.Group.defaultGroupsIds["All users"]],edit:[r.Group.defaultGroupsIds["All users"]]};class tr{getDialogContent(){return tn(function*(){let e=[],i=[];for(let i of this.permissions.view){let n=yield t.dapi.groups.find(i);n&&e.push(n)}for(let e of this.permissions.edit){let n=yield t.dapi.groups.find(e);n&&i.push(n)}return this.editGroupsInput.value=i,this.viewGroupsInput.value=e,a.divV([this.viewGroupsInput.root,this.editGroupsInput.root])}).call(this)}show(e){return tn(function*(){var t;let i=yield this.getDialogContent(),n=a.dialog("Edit Permissions").add(i).onOK(()=>{let 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=ta.view),e(this.permissions)});(null==(t=i.parentElement)?void 0:t.style)&&(i.parentElement.style.overflow="visible"),n.show()}).call(this)}constructor(e){this.permissions=null!=e?e:ta,this.editGroupsInput=a.input.userGroups("Can Edit"),this.editGroupsInput.root.style.marginBottom="16px",this.viewGroupsInput=a.input.userGroups("Can View")}}function tl(e,t,i,n,a,r,l){try{var o=e[r](l),s=o.value}catch(e){i(e);return}o.done?t(s):Promise.resolve(s).then(n,a)}function to(e){return function(){var t=this,i=arguments;return new Promise(function(n,a){var r=e.apply(t,i);function l(e){tl(r,n,a,l,o,"next",e)}function o(e){tl(r,n,a,l,o,"throw",e)}l(void 0)})}}function ts(e,t,i,n,a,r,l){try{var o=e[r](l),s=o.value}catch(e){i(e);return}o.done?t(s):Promise.resolve(s).then(n,a)}function tu(e){return function(){var t=this,i=arguments;return new Promise(function(n,a){var r=e.apply(t,i);function l(e){ts(r,n,a,l,o,"next",e)}function o(e){ts(r,n,a,l,o,"throw",e)}l(void 0)})}}(I=j||(j={})).acquireCampaignLock=function(e,i,n){return to(function*(){return yield t.data.query("HitTriage:AcquireCampaignLock",{appName:e,campaignId:i,lockedBy:n})})()},I.releaseCampaignLock=function(e,i){return to(function*(){return yield t.data.query("HitTriage:ReleaseCampaignLock",{appName:e,campaignId:i})})()},I.getLastModified=function(e,i){return to(function*(){return yield t.data.query("HitTriage:GetLastModified",{appName:e,campaignId:i})})()},I.addMolecule=function(e,i,n,a){return to(function*(){return yield t.data.query("HitTriage:AddMolecule",{canonicalSmiles:e,appName:i,campaignId:n,createdBy:a})})()},I.addMolecules=function(e,i,n,a){return to(function*(){return yield t.data.query("HitTriage:AddMolecules",{smiles:e,appName:i,campaignId:n,createdBy:a})})()},I.getMoleculeByVid=function(e){return to(function*(){return yield t.data.query("HitTriage:GetMoleculeByVid",{vid:e})})()},I.getCampaignsByVid=function(e,i){return to(function*(){return yield t.data.query("HitTriage:GetCampaignsByVid",{vid:e,appName:i})})()},(k=_||(_={})).initHT=function(){return to(function*(){return yield t.functions.call("HitTriage:InitHT",{})})()},k.hitTriageAppTreeBrowser=function(e){return to(function*(){return yield t.functions.call("HitTriage:HitTriageAppTreeBrowser",{treeNode:e})})()},k.hitDesignAppTreeBrowser=function(e){return to(function*(){return yield t.functions.call("HitTriage:HitDesignAppTreeBrowser",{treeNode:e})})()},k.peptiHitAppTreeBrowser=function(e){return to(function*(){return yield t.functions.call("HitTriage:PeptiHitAppTreeBrowser",{treeNode:e})})()},k.hitTriageApp=function(){return to(function*(){return yield t.functions.call("HitTriage:HitTriageApp",{})})()},k.hitDesignApp=function(){return to(function*(){return yield t.functions.call("HitTriage:HitDesignApp",{})})()},k.peptiHitApp=function(){return to(function*(){return yield t.functions.call("HitTriage:PeptiHitApp",{})})()},k.pepTriageAppTreeBrowser=function(e){return to(function*(){return yield t.functions.call("HitTriage:PepTriageAppTreeBrowser",{treeNode:e})})()},k.pepTriageApp=function(){return to(function*(){return yield t.functions.call("HitTriage:PepTriageApp",{})})()},k.demoFileIngest=function(){return to(function*(){return yield t.functions.call("HitTriage:DemoFileIngest",{})})()},k.demoFileIngest1=function(){return to(function*(){return yield t.functions.call("HitTriage:DemoFileIngest1",{})})()},k.demoFileIngest2=function(e){return to(function*(){return yield t.functions.call("HitTriage:DemoFileIngest2",{numberOfMolecules:e})})()},k.demoPeptideSequences=function(e){return to(function*(){return yield t.functions.call("HitTriage:DemoPeptideSequences",{peptideCount:e})})()},k.demoFileSubmit=function(e,i){return to(function*(){return yield t.functions.call("HitTriage:DemoFileSubmit",{df:e,molecules:i})})()},k.registerMoleculesToViD=function(){return to(function*(){return yield t.functions.call("HitTriage:RegisterMoleculesToViD",{})})()},k.hitDesignVidPanel=function(e){return to(function*(){return yield t.functions.call("HitTriage:HitDesignVidPanel",{vid:e})})()},k.gasteigerCellRenderer=function(){return to(function*(){return yield t.functions.call("HitTriage:GasteigerCellRenderer",{})})()},k.htPackageSettingEditor=function(e){return to(function*(){return yield t.functions.call("HitTriage:HtPackageSettingEditor",{propList:e})})()};class tc{get canEdit(){return this.hasEditPermission}get appName(){return this._appName}setCanEdit(e){return tu(function*(){if(!e.authorUserId||!e.permissions){this.hasEditPermission=!0;return}this.hasEditPermission=yield eT(e.authorUserId,e.permissions)}).call(this)}getFilterType(e){let t=this.dataFrame.col(e);return(null==t?void 0:t.semType)===r.SEMTYPE.MOLECULE?r.FILTER_TYPE.SUBSTRUCTURE:(null==t?void 0:t.type)===r.COLUMN_TYPE.BOOL?r.FILTER_TYPE.BOOL_COLUMNS:(null==t?void 0:t.type)===r.COLUMN_TYPE.STRING?r.FILTER_TYPE.CATEGORICAL:r.FILTER_TYPE.HISTOGRAM}download(e,t,i=!1){let n=document.createElement("a"),a=r.DataFrame.fromColumns(e.columns.toList().filter(e=>!e.name.startsWith("~"))).toCsv({filteredRowsOnly:i});n.setAttribute("href","data:text/plain;charset=utf-8,"+encodeURIComponent(a)),n.setAttribute("download",t+".csv"),n.click()}getNewCampaignName(e,t){return tu(function*(){let i=(yield nh.files.list(e)).map(e=>e.name).filter(e=>e.startsWith(`${t}-`)&&!!parseInt(e.substring(t.length+1)));if(0===i.length)return t+"-1";let n=i.map(e=>e.substring(t.length+1)).filter(Boolean).map(e=>parseInt(e,10)).sort((e,t)=>e-t);return t+"-"+(n[n.length-1]+1).toString()})()}setBaseUrl(){let e=document.title;if(history.replaceState){let t={Title:e,Url:this.baseUrl};history.replaceState(t,t.Title,t.Url)}}unionDataframes(e,t,i,n){var a,l,o,s;let u=i;e.col(i).name=n,i=n;let c=null==(l=e.col(i))||null==(a=l.toList())?void 0:a.map(e=>nh.convertToSmiles(e)),p=null==(s=t.col(n))||null==(o=s.toList())?void 0:o.map(e=>nh.convertToSmiles(e));if(!c||!p)throw Error("Molecule column not found");let d=new Map;p.forEach((e,t)=>{e&&"MALFORMED_INPUT_VALUE"!==e&&d.set(e,t)});let m=(e,t,i,n)=>{try{if(e.type===t.type)e.set(i,t.get(n),!1);else if(e.type===r.COLUMN_TYPE.STRING)e.set(i,t.getString(n),!1);else if(e.type===r.COLUMN_TYPE.INT){let a=t.get(n);"number"==typeof a?e.set(i,Math.round(a),!1):"string"==typeof a&&a.length>0&&!isNaN(Number(a))&&e.set(i,Math.round(Number(a)),!1)}else if(e.type===r.COLUMN_TYPE.FLOAT){let a=t.get(n);"number"==typeof a?e.set(i,a,!1):"string"==typeof a&&a.length>0&&!isNaN(Number(a))&&e.set(i,Number(a),!1)}else e.set(i,t.get(n),!1)}catch(a){nh.logger.error(`Error setting column value for column ${e.name} at row ${i} from column ${t.name} at row ${n}: ${a}`)}};this.isJoining=!0;try{let i=[];for(let n of e.columns)if(!t.columns.contains(n.name)){let e=t.columns.addNew(n.name,n.type);n.semType&&(e.semType=n.semType),i.push(n.name)}for(let n=0;n<c.length;n++)if(c[n]&&"MALFORMED_INPUT_VALUE"!==c[n])if(d.has(c[n])){if(i.length>0){let a=d.get(c[n]);for(let r of i)m(t.col(r),e.col(r),a,n)}}else for(let i of(t.rows.addNew(null,!0),e.columns))m(t.col(i.name),i,t.rowCount-1,n)}finally{setTimeout(()=>{this.isJoining=!1},500),e.col(i).name=u}return t}aquireAndWaitCampaignLock(e,t=3e4){return tu(function*(){let i=Date.now(),n=0,a=null,l=r.User.current(),o=l&&(l.friendlyName||l.name)||"unknown";for(;Date.now()-i<t&&n<5;)try{let t=yield j.acquireCampaignLock(this.appName,e,o);if(t&&t.rowCount>0){var s;return{aquired:!0,expires_at:null==t||null==(s=t.col("expires_at"))?void 0:s.getString(0)}}a=null,yield r.delay(200)}catch(e){a=e,n++}if(a)throw a;return{aquired:!1,expires_at:null}}).call(this)}releaseCampaignLock(e){return tu(function*(){var t,i;return(null==(i=yield j.releaseCampaignLock(this.appName,e))||null==(t=i.col("updated_at"))?void 0:t.getString(0))||null}).call(this)}constructor(e,t){this.parentCall=e,this.isJoining=!1,this.hasEditPermission=!1,this.baseUrl=new URL(window.location.href).origin+`/apps/HitTriage/${t.replace(" ","")}`,this._appName=t,this.computeFunctions=function(e){let t=Array.from(new Set(r.Func.find({meta:{role:e}}).concat(r.Func.find({tags:[e]})))),i=t.filter(e=>e.type===eo);return{functions:i,scripts:t.filter(e=>e.type===el),queries:t.filter(e=>e.type===es)}}("HitTriageFunction")}}function tp(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{},n=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(i).filter(function(e){return Object.getOwnPropertyDescriptor(i,e).enumerable}))),n.forEach(function(t){var n;n=i[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}function td(e,t=!1){var i;let n=r.DataFrame.create(1);if(t){let e=n.columns.addNew(g,r.TYPE.STRING);e.semType=r.SEMTYPE.MACROMOLECULE,e.meta.units="helm",e.setTag("units","helm"),e.setTag("cell.renderer","helm"),e.setTag(".alphabetIsMultichar","true")}let a=n.columns.addNew(h,r.TYPE.STRING);return a.semType=r.SEMTYPE.MOLECULE,a.meta.units=r.UNITS.Molecule.SMILES,a.set(0,null),(null==e||null==(i=e.stages)?void 0:i.length)>0&&n.columns.addNew(m,r.TYPE.STRING).set(0,e.stages[0]),n.columns.addNew(f,r.TYPE.STRING),n}function tm(e,i=!1){var n;let l=td(e,i),o=e.campaignFields.map(e=>{var t,i;return e.type===r.SEMTYPE.MOLECULE?(t=tp({},e),i=i={type:"String",semtype:r.SEMTYPE.MOLECULE},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t.push.apply(t,i)}return t})(Object(i)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}),t):e}).map(e=>r.Property.fromOptions(tp({name:e.name,type:eL[e.type],nullable:!e.required},e.semtype?{semType:e.semtype}:{}))),s={},u=a.input.string("Campaign Name",{tooltipText:"New campaign name. If empty, campaign code will be used."}),c=a.input.form(s,o);c.prepend(u.root),c.classList.remove("ui-form");let p=a.div([...(null==(n=e.campaignFields)||n.length,[]),c]),d=a.buttonsInput([]);return p.appendChild(d),{promise:new Promise(i=>{let n=a.bigButton(w,()=>{for(let i of e.campaignFields)if(i.required&&(!s[i.name]||""===s[i.name]))return void t.shell.error(`Field '${i.name}' is required`);i({df:l,campaignProps:s,name:u.value})});d.appendChild(n)}),root:p,cancelPromise:new Promise(e=>{a.button(E,()=>e())})}}function th(e,t,i,n,a,r,l){try{var o=e[r](l),s=o.value}catch(e){i(e);return}o.done?t(s):Promise.resolve(s).then(n,a)}function tg(e){return function(){var t=this,i=arguments;return new Promise(function(n,a){var r=e.apply(t,i);function l(e){th(r,n,a,l,o,"next",e)}function o(e){th(r,n,a,l,o,"throw",e)}l(void 0)})}}function tf(e){let t=new e0([r.Property.fromOptions({name:"Name",type:r.TYPE.STRING})],e?e.map(e=>({Name:e})):void 0,{horizontalInputNames:!0}),i={};return t.onItemAdded.subscribe(e=>{i={}}),t.onAddingItemChanged.subscribe(e=>{e&&(i=e.item)}),{getFields:function(){let e=t.items.filter(e=>e.Name).map(e=>e.Name);return i.Name&&""!==i.Name&&e.push(i.Name),e},fieldsDiv:t.root,itemsGrid:t}}function ty(e,t,i,n,a,r,l){try{var o=e[r](l),s=o.value}catch(e){i(e);return}o.done?t(s):Promise.resolve(s).then(n,a)}function tv(e){return function(){var t=this,i=arguments;return new Promise(function(n,a){var r=e.apply(t,i);function l(e){ty(r,n,a,l,o,"next",e)}function o(e){ty(r,n,a,l,o,"throw",e)}l(void 0)})}}tc.molFileExtReaders=["sdf","mol","smi","mol2"].map(e=>{let t=r.Func.find({meta:{role:r.FUNC_TYPES.FILE_IMPORTER}}).concat(r.Func.find({tags:["file-handler"]})).find(t=>{var i;return(null==t||null==(i=t.options)?void 0:i.ext)&&"string"==typeof t.options.ext&&t.options.ext.split(",").includes(e)});return{ext:e,handlerFunc:t}}).filter(e=>e.handlerFunc);class tb extends e9{onActivated(){t.shell.windows.showHelp=!0,t.shell.windows.help.showHelp(nh.webRoot+"README_HD.md")}getAppHeader(){return D.appHeader({iconPath:nh.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"})}refreshCampaignsTable(){return tv(function*(){if(null!=this.campaignsTableRoot){a.setUpdateIndicator(this.campaignsTableRoot,!0);try{let e=yield this.getCampaignsTable();a.setUpdateIndicator(this.campaignsTableRoot,!1),a.empty(this.campaignsTableRoot),this.campaignsTableRoot.appendChild(e)}catch(e){t.shell.error("Failed to update campaigns table"),console.error(e)}finally{a.setUpdateIndicator(this.campaignsTableRoot,!1)}}}).call(this)}init(e){return tv(function*(){a.setUpdateIndicator(this.root,!0);try{let t=a.h1(T),i=a.h1(x,{style:{marginLeft:"10px"}}),n=a.div(),l=a.divH([]),o=a.div([l,n],"ui-form"),s=yield this.getCampaignsTable();this.campaignsTableRoot=a.div([s],{style:{position:"relative"}});let u=a.iconFA("layer-group",()=>tv(function*(){let e=r.Menu.popup();Object.values(L).forEach(t=>{e.item(t,()=>tv(function*(){eO(O,t),yield this.refreshCampaignsTable()}).call(this))});let t=e.group("Campaign Fields"),i=yield nh.loadCampaigns(this.app.appName,this.deletedCampaigns),n=new Set;Object.values(i).forEach(e=>{e.campaignFields&&Object.keys(e.campaignFields).forEach(e=>n.add(e))}),Array.from(n).forEach(e=>{t.item(e,()=>tv(function*(){var t;t=`campaignFields.${e}`,eO(O,t),yield this.refreshCampaignsTable()}).call(this))}),e.show({element:d,x:120,y:d.offsetTop+30})}).call(this),"Group by");u.style.marginBottom="9px",u.style.marginLeft="8px",u.style.fontSize="15px",u.style.color="var(--blue-1)",a.tooltip.bind(u,()=>`Group Campaigns. Current: ${this.currentGroupping}`);let c=a.iconFA("eye",()=>tv(function*(){let e=r.Menu.popup(),t=yield nh.loadCampaigns(this.app.appName,this.deletedCampaigns),i=function(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{},n=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(i).filter(function(e){return Object.getOwnPropertyDescriptor(i,e).enumerable}))),n.forEach(function(t){var n;n=i[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({},M);delete i.Name,Object.values(t).forEach(e=>{e.campaignFields&&Object.keys(e.campaignFields).forEach(e=>{i[`campaignFields.${e}`]=t=>{var i,n;return null!=(i=null==(n=t.campaignFields)?void 0:n[e])?i:""}})});let n=eN().reduce((e,t)=>(e[t]=!0,e),{});Object.keys(i).filter(e=>!e.startsWith("campaignFields.")).forEach(t=>{var i;e.item(t,()=>{n[t]=!n[t],eF(Object.keys(n).filter(e=>n[e])),this.refreshCampaignsTable()},null,{check:null!=(i=n[t])&&i})});let a=e.group("Campaign Fields");Object.keys(i).filter(e=>e.startsWith("campaignFields.")).forEach(e=>{var t;a.item(e.replace("campaignFields.",""),()=>{n[e]=!n[e],eF(Object.keys(n).filter(e=>n[e])),this.refreshCampaignsTable()},null,{check:null!=(t=n[e])&&t})}),e.show({element:d,x:100,y:d.offsetTop+30})}).call(this),"View");a.tooltip.bind(c,"Edit visible columns in campaigns table"),c.style.marginBottom="9px",c.style.marginLeft="8px",c.style.fontSize="15px",c.style.color="var(--blue-1)";let p=a.iconFA("sync",()=>tv(function*(){yield this.refreshCampaignsTable()}).call(this),"Refresh");p.style.marginBottom="9px",p.style.marginLeft="8px",p.style.color="var(--blue-1)",a.tooltip.bind(p,()=>"Refresh campaigns table");let d=a.divH([t,c,u,p],{style:{alignItems:"center"}});eq()(this._contentRoot).empty(),this._contentRoot.appendChild(a.divV([d],{style:{marginLeft:"10px"}})),this._contentRoot.appendChild(this.campaignsTableRoot),this._contentRoot.appendChild(i),this._contentRoot.appendChild(o),yield this.startNewCampaign(n,l,e)}finally{a.setUpdateIndicator(this.root,!1)}}).call(this)}startNewCampaign(e,i,n){return tv(function*(){var r;let l=(yield nh.files.list(`${this.app.appName}/templates`)).filter(e=>e.name.endsWith(".json")).map(e=>e.name.slice(0,-5));n&&!l.includes(n.name)&&l.push(n.name);let o=null,s=!0,u=()=>tv(function*(){if(!s)return;let t=c.value,i=n&&n.name===t?n:yield e_(`${this.app.appName}/templates/${t}.json`);o=i;let a=yield this.getNewCampaignAccordeon(i);eq()(e).empty(),e.appendChild(a)}).call(this),c=a.input.choice("Template",{value:null!=(r=null==n?void 0:n.name)?r:l[0],items:l,onValueChanged:()=>tv(function*(){yield u()})()});c.root.style.width="100%";let p=a.icons.add(()=>{this.createNewTemplate()},b),d=a.icons.copy(()=>{o&&this.createNewTemplate(o)},"Clone template"),m=a.icons.delete(()=>{c.value&&!(c.items.length<2)&&a.dialog("Delete template").add(a.divText(`Are you sure you want to delete template ${c.value}?`)).onOK(()=>tv(function*(){try{let e=c.value;yield nh.files.delete(`${this.app.appName}/templates/${e}.json`),s=!1,c.items=c.items.filter(t=>t!==e),c.value=c.items[0],s=!0,yield u(),t.shell.info("Template "+e+" was deleted successfully")}catch(e){s=!0,t.shell.error("Failed to delete template "+c.value),console.error(e)}}).call(this)).show()},"Delete template");m.style.color="var(--blue-1)",p.style.color="#2083d5",c.addOptions(p),c.addOptions(d),c.addOptions(m),yield u(),eq()(i).empty(),i.appendChild(c.root)}).call(this)}checkCampaign(e){return tv(function*(){var t;let i=new URLSearchParams(location.search);if(!i.has(o)&&!e)return;let n=null!=e?e:i.get(o);if(!(yield nh.files.exists(`${this.app.appName}/campaigns/${n}/${u}`)))return;let a=JSON.parse((yield nh.files.readAsText(`${this.app.appName}/campaigns/${n}/${u}`)));if(a){if(a.authorUserId&&a.permissions&&!(yield ex(a.authorUserId,a.permissions)))return void this.app.setBaseUrl();this.app.campaign=a}let r=null!=(t=a.template)?t:yield e_(`${this.app.appName}/templates/${a.templateName}.json`);return yield this.app.setTemplate(r,n),e&&eb(o,e),a.template=r,a}).call(this)}getCampaignsTable(){return tv(function*(){var e;let i,n=yield nh.loadCampaigns(this.app.appName,this.deletedCampaigns),l=null!=(e=eS(O))?e:L.None,o=(i=eS(N))?JSON.parse(i):null,s=Object.values(n);o&&eP(s,o);let u=eV(s,l),c=eN();this.currentGroupping=l,this.app.existingStatuses=Array.from(new Set(s.map(e=>e.status).filter(e=>!!e)));let p=e=>{var i,n;let l=a.icons.delete(()=>tv(function*(){a.dialog("Delete campaign").add(a.divText(`Are you sure you want to delete campaign ${e.name}?`)).onOK(()=>tv(function*(){yield this.deleteCampaignAndRefresh(this.app.appName,e.name)}).call(this)).show()}).call(this),"Delete campaign"),o=a.iconFA("share",()=>tv(function*(){yield new tr(e.permissions).show(i=>tv(function*(){try{e.permissions=i,null!=e.authorUserId||(e.authorUserId=t.shell.user.id),yield nh.saveCampaignJson(this.app.appName,e),t.shell.info("Permissions updated for campaign "+e.name)}catch(i){t.shell.error("Failed to update permissions for campaign "+e.name),console.error(i)}}).call(this))}).call(this),"Manage campaign permissions");return l.style.display="none",o.style.display="none",eT(null!=(i=e.authorUserId)?i:r.User.current().id,null!=(n=e.permissions)?n:ta).then(e=>{e&&(l.style.display="inline-block",o.style.display="inline-block")}),l.style.color="var(--blue-1)",o.style.color="var(--blue-1)",[o,l]},d=a.table(Object.values(u).flat(),e=>{var t;return[a.link(null!=(t=e.friendlyName)?t:e.name,()=>this.setCampaign(e.name),"Continue Campaign",""),...c.map(t=>{var i,n,a;return t.startsWith("campaignFields.")?null!=(i=null==(a=e.campaignFields)?void 0:a[t.replace("campaignFields.","")])?i:"":null!=(n=M[t](e))?n:""}),...p(e)]},["Name",...c.map(e=>e.replace("campaignFields.","")),"",""]);return d.style.color="var(--grey-5)",d.style.marginLeft="24px",d.querySelectorAll("tr.header > td").forEach((e,t)=>{if(!e.textContent)return;let i=0===t?"Name":c[t-1];if(o&&i===o.columnName){let t=o.ascending?"↑":"↓";e.appendChild(a.span([t],{style:{fontSize:"12px",marginLeft:"2px"}}))}e.addEventListener("dblclick",()=>{var e;let t={columnName:i,ascending:!0};o&&i===o.columnName&&(t=o.ascending?{columnName:i,ascending:!1}:null),(e=t)?eO(N,JSON.stringify(e)):localStorage.removeItem(N),this.refreshCampaignsTable()})}),eD(d,u),d}).call(this)}setCampaign(e){return tv(function*(){let t=yield this.checkCampaign(e);this.app.campaign=t}).call(this)}getNewCampaignAccordeon(e){return tv(function*(){let{root:t,promise:i,cancelPromise:n}=tm(e);return i.then(t=>tv(function*(){var i,n;this.app.clearCampaign(),this.app.dataFrame=t.df,yield this.app.setTemplate(e),this.app.campaignProps=t.campaignProps;let a=(null==(i=t.name)?void 0:i.trim())?null==(n=t.name)?void 0:n.trim():void 0;yield this.app.saveCampaign(!1,!0,{friendlyName:a}),e.layoutViewState&&this.app.campaign&&(this.app.campaign.layout=e.layoutViewState)}).call(this)),n.then(()=>{this.init()}),t}).call(this)}createNewTemplate(e){return tv(function*(){a.setUpdateIndicator(this.root,!0);try{var i;let n=yield(i=this.app,tg(function*(){var n,l,o,s,u,c,d,m,h,g,f;let y=yield nh.files.list(`${i.appName}/templates`),v=!1,b=!1,w=y.map(e=>e.name.slice(0,-5)),C=[];for(let e of y)try{let t=JSON.parse((yield nh.files.readAsText(e)));C.push(t.key)}catch(e){console.error(e)}let T=Array.from(new Set(r.Func.find({meta:{role:p}}).concat(r.Func.find({tags:[p]})))),x={};T.forEach(e=>{var t;x[null!=(t=e.friendlyName)?t:e.name]=e});let S=a.input.choice("Submit function",{value:null,items:[null,...Object.keys(x)]});S.nullable=!0,S.value=null!=(n=null==e||null==(d=e.submit)?void 0:d.fName)?n:null,S.setTooltip("Select function to be called upon submitting");let O=a.divText("Template name is empty or already exists",{classes:"hit-triage-error-div"}),P=a.divText("Template key is empty or already exists",{classes:"hit-triage-error-div"}),N=e2();function F(){var e,t,i,n;if(""===B.value||w.includes(null!=(e=null==(t=B.value)?void 0:t.trim())?e:"")){let e=null!=(i=B.input.offsetLeft)?i:0,t=null!=(n=B.input.offsetWidth)?n:0;O.style.marginLeft=`${e}px`,O.style.width=`${t}px`,O.style.opacity="100%",O.style.borderTop="1px solid red",v=!0}else O.style.borderTop="none",O.style.opacity="0%",v=!1}let B=a.input.string("Name",{value:null!=(l=null==e?void 0:e.name)?l:"",onValueChanged:F});function I(){var e,t,i,n;if(""===k.value||C.includes(null!=(e=null==(t=k.value)?void 0:t.trim())?e:"")){let e=null!=(i=k.input.offsetLeft)?i:0,t=null!=(n=k.input.offsetWidth)?n:0;P.style.marginLeft=`${e}px`,P.style.width=`${t}px`,P.style.borderTop="1px solid red",P.style.opacity="100%",b=!0}else P.style.opacity="0%",P.style.borderTop="none",b=!1}let k=a.input.string("Key",{value:null!=(o=null==e?void 0:e.key)?o:"",onValueChanged:I});k.setTooltip("Template key used for campaign prefix"),B.setTooltip("Template name"),B.root.style.borderBottom="none",k.root.style.borderBottom="none",O.style.opacity="0%",P.style.opacity="0%";let V=null,D={compute:{descriptors:{enabled:!0,args:null!=(s=null==e||null==(h=e.compute)||null==(m=h.descriptors)?void 0:m.args)?s:[]},functions:null!=(u=null==e||null==(g=e.compute)?void 0:g.functions)?u:[]}},j=yield eZ(i,e=>{V=e},()=>null,D,!1,!0);j.root.classList.add("hit-triage-new-template-functions-input");let _=e3(null==e?void 0:e.campaignFields),L=tf(null==e?void 0:e.stages),M=a.divV([a.divV([B,O]),a.divV([k,P]),N.dataFileInput,_.fieldsDiv]),H=a.h2("Stages");a.tooltip.bind(H,'Define Stages for designed molecules. For example, "Design", "Synthesis", "Test", etc.');let R=a.h2("Compute");a.tooltip.bind(R,'Define functions to be calculated for each molecule. For example, "Descriptors", "Descriptors:Descriptors", etc.');let U=a.div([a.h2("Details"),M,H,L.fieldsDiv,R,j.root,a.h2("Submit"),S.root],"ui-form"),q=a.buttonsInput([]);U.appendChild(q);let Y=null!=(c=null==(f=q.getElementsByClassName("ui-input-editor"))?void 0:f[0])?c:q,G=new Promise(e=>{let t=a.button(E,()=>e());Y.appendChild(t)});return{root:U,template:new Promise(e=>{let n=a.bigButton(A,()=>tg(function*(){var n,a,r,l,o,s,u,c,p;if(F(),I(),j.okProxy(),v||!B.value||""===B.value)return void t.shell.error("Template name is empty or already exists");if(b||!k.value||""===k.value)return void t.shell.error("Template key is empty or already exists");let d=S.value?x[S.value]:void 0,m=function(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{},n=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(i).filter(function(e){return Object.getOwnPropertyDescriptor(i,e).enumerable}))),n.forEach(function(t){var n;n=i[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({name:B.value,key:k.value,campaignFields:_.getFields(),stages:L.getFields(),layoutViewState:null!=(n=N.getLayoutViewState())?n:void 0,localLayoutPath:null!=(a=N.getLocalFilePath())?a:void 0,compute:{descriptors:{enabled:!!(null==V||null==(u=V.descriptors)?void 0:u.length),args:null!=(r=null==V?void 0:V.descriptors)?r:[]},functions:Object.entries(null!=(l=null==V?void 0:V.externals)?l:{}).map(([e,t])=>{var i;let n=e.split(":");return{name:n[1],package:n[0],args:t,rerunOnOpen:!!(null==V||null==(i=V.rerunOnOpen)?void 0:i[e])}}),scripts:Object.entries(null!=(o=null==V?void 0:V.scripts)?o:{}).filter(([e,t])=>e.startsWith(eu)&&3===e.split(":").length).map(([e,t])=>{var i,n,a;let r=e.split(":");return{name:null!=(i=r[1])?i:"",id:null!=(n=r[2])?n:"",args:t,rerunOnOpen:!!(null==V||null==(a=V.rerunOnOpen)?void 0:a[e])}}),queries:Object.entries(null!=(s=null==V?void 0:V.queries)?s:{}).filter(([e,t])=>e.startsWith(ec)&&3===e.split(":").length).map(([e,t])=>{var i,n,a;let r=e.split(":");return{name:null!=(i=r[1])?i:"",id:null!=(n=r[2])?n:"",args:t,rerunOnOpen:!!(null==V||null==(a=V.rerunOnOpen)?void 0:a[e])}})}},d?{submit:{fName:d.name,package:eh(d)}}:{});yield(c=m,p=i.appName,tg(function*(){yield nh.files.writeAsText(`${p}/templates/${c.name}.json`,JSON.stringify(c))})()),t.shell.info("Template created successfully"),e(m)})());Y.appendChild(n)}),cancelPromise:G}})()),l=new r.ViewBase,o=t.shell.v;l.name="New Template",l.root.appendChild(n.root),l.parentCall=this.app.parentCall,t.shell.addView(l),l.path=new URL(this.app.baseUrl).pathname+"/new-template";let{sub:s}=ew(l,this.app.appName,b,()=>tv(function*(){t.shell.v=o,l.close()})());n.template.then(e=>tv(function*(){yield this.init(e),l.close(),eA(l),t.shell.v=o,s.unsubscribe()}).call(this)),n.cancelPromise.then(()=>tv(function*(){s.unsubscribe(),l.close(),t.shell.v=o})())}finally{a.setUpdateIndicator(this.root,!1)}}).call(this)}constructor(e){super(e),this.currentGroupping="None",this._appHeader=null,this._contentRoot=a.div([],{classes:"hit-triage-info-view-container"}),this.campaignsTableRoot=null,this.name="Hit Design",this.aiDescription=iC(e.appName),this._appHeader=this.getAppHeader(),this.root.appendChild(a.div([this._appHeader],{style:{marginLeft:"10px"}})),this.root.appendChild(this._contentRoot),t.shell.windows.showHelp=!0,t.shell.windows.help.showHelp(nh.webRoot+"README_HD.md"),this.checkCampaign().then(e=>{this.app.campaign=e,this.init()})}}function tw(e,t,i,n,a,r,l){try{var o=e[r](l),s=o.value}catch(e){i(e);return}o.done?t(s):Promise.resolve(s).then(n,a)}function tA(e){return function(){var t=this,i=arguments;return new Promise(function(n,a){var r=e.apply(t,i);function l(e){tw(r,n,a,l,o,"next",e)}function o(e){tw(r,n,a,l,o,"throw",e)}l(void 0)})}}function tC(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{},n=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(i).filter(function(e){return Object.getOwnPropertyDescriptor(i,e).enumerable}))),n.forEach(function(t){var n;n=i[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}function tE(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t.push.apply(t,i)}return t})(Object(t)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(t,i))}),e}function tT(e,t,i,n,a,r,l){try{var o=e[r](l),s=o.value}catch(e){i(e);return}o.done?t(s):Promise.resolve(s).then(n,a)}function tx(e){return function(){var t=this,i=arguments;return new Promise(function(n,a){var r=e.apply(t,i);function l(e){tT(r,n,a,l,o,"next",e)}function o(e){tT(r,n,a,l,o,"throw",e)}l(void 0)})}}function tS(){return{convertToSmiles:e=>nh.convertToSmiles(e),logger:nh.logger,molColName:h}}function tO(e,i,n){return tx(function*(e,i,n,a=[],l=[]){return function(e,i,n,a){return tA(function*(e,i,n,a,l,o){let s=r.TaskBarProgressIndicator.create("Calculating ..."),u=null!=(b=null==o?void 0:o.convertToSmiles)?b:e=>e,c=null!=(w=null==o?void 0:o.logger)?w:console,p=null!=(A=null==o?void 0:o.molColName)?A:"Molecule",d=e.map(e=>u(e)),m=r.Column.fromStrings(p,d),h=r.DataFrame.fromColumns([m]);h.name="HD cell values",yield h.meta.detectSemanticTypes();let g=[];g.push(new Promise(e=>tA(function*(){try{i.length&&(yield t.chem.descriptors(h,m.name,i))}catch(e){c.error("Descriptors calculation error"),c.error(e)}e()})()));var f=!0,y=!1,v=void 0;try{for(var b,w,A,C,E=n[Symbol.iterator]();!(f=(C=E.next()).done);f=!0){let e=C.value;g.push(new Promise(t=>tA(function*(){try{let i=e.args,n=r.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`),t();return}let a=n[0],l=a.inputs[0].name,o=a.inputs[1].name;yield a.apply(tE(tC({},i),{[l]:h,[o]:m.name}))}catch(e){c.error(e)}t()})()))}}catch(e){y=!0,v=e}finally{try{f||null==E.return||E.return()}finally{if(y)throw v}}var T=!0,x=!1,S=void 0;try{for(var O,P=(void 0===a?[]:a)[Symbol.iterator]();!(T=(O=P.next()).done);T=!0){let e=O.value,t=e.args;g.push(new Promise(i=>tA(function*(){try{let i=r.Func.find({name:e.name}).filter(t=>t.type===el&&t.id===e.id)[0];if(i){let e=i.inputs[0].name,r=i.inputs[1].name,u=yield i.apply(tE(tC({},t),{[e]:h,[r]:m.name}));if(u&&u.rowCount===h.rowCount&&"python"===i.language){var n=!0,a=!1,l=void 0;try{for(var o,s=u.columns[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){let e=o.value;e.name=h.columns.getUnusedName(e.name),h.columns.add(e)}}catch(e){a=!0,l=e}finally{try{n||null==s.return||s.return()}finally{if(a)throw l}}}}}catch(e){c.error(e)}i()})()))}}catch(e){x=!0,S=e}finally{try{T||null==P.return||P.return()}finally{if(x)throw S}}var N=!0,F=!1,B=void 0;try{for(var I,k=(void 0===l?[]:l)[Symbol.iterator]();!(N=(I=k.next()).done);N=!0){let e=I.value,t=e.args;g.push(new Promise(i=>tA(function*(){try{let n=r.Func.find({name:e.name}).filter(t=>t.type===es&&t.id===e.id)[0];if(n){let e=n.inputs[0].name,a=[d],r=yield n.apply(tE(tC({},t),{[e]:a}));if(!r||0===r.rowCount)return void i();yield eg(h,p,r)}}catch(e){c.error(e)}i()})()))}}catch(e){F=!0,B=e}finally{try{N||null==k.return||k.return()}finally{if(F)throw B}}yield Promise.all(g),s.close();let V=h.col(p);for(let t=0;t<V.length;t++)V.set(t,e[t],!1);return h}).apply(this,arguments)}(e,i,n,a,l,tS())}).apply(this,arguments)}function tP(e,i,n){return tx(function*(){var a;return a=tS(),tA(function*(){let l=r.TaskBarProgressIndicator.create("Calculating ..."),o=null!=(y=null==a?void 0:a.convertToSmiles)?y:e=>e,s=null!=(v=null==a?void 0:a.logger)?v:console,u=i.col(n);if(!u)throw Error("There is no molecule column in dataframe");let c=`~${n}.canonicalSmiles`,p=i.columns.getOrCreate(c,r.TYPE.STRING);p.semType=r.SEMTYPE.MOLECULE;let d=u.toList();for(let e=0;e<d.length;e++){if(u.isNone(e))continue;let t=d[e];if(!t)continue;let i=o(t);p.set(e,i,!1)}let m=[];m.push(new Promise(n=>tA(function*(){try{e.descriptors&&e.descriptors.length>0&&(yield t.chem.descriptors(i,c,e.descriptors))}catch(e){s.error("Descriptors calculation error"),s.error(e)}n()})()));var h=!0,g=!1,f=void 0;try{for(var y,v,b,w,A,C=Object.keys(e.externals)[Symbol.iterator]();!(h=(A=C.next()).done);h=!0){let t=A.value;m.push(new Promise(n=>tA(function*(){try{let n=e.externals[t],a=r.Func.find({package:t.split(":")[0],name:t.split(":")[1]})[0],l=a.inputs[0].name,o=a.inputs[1].name;n&&(yield a.apply(tE(tC({},n),{[l]:i,[o]:c})))}catch(e){s.error(e)}n()})()))}}catch(e){g=!0,f=e}finally{try{h||null==C.return||C.return()}finally{if(g)throw f}}var E=!0,T=!1,x=void 0;try{for(var S,O=Object.keys(null!=(b=e.scripts)?b:{})[Symbol.iterator]();!(E=(S=O.next()).done);E=!0){let t=S.value,n=e.scripts[t];m.push(new Promise(e=>tA(function*(){if(n){let d=t.split(":"),m=d[2];if(!m)return void e();try{let t=d[1],s=r.Func.find({name:t}).filter(e=>e.type===el&&e.id===m)[0];if(!s)return void e();let h=s.inputs[0].name,g=s.inputs[1].name,f=yield s.apply(tE(tC({},n),{[h]:i,[g]:c}));if(f&&f.rowCount===i.rowCount&&"python"===s.language){var a=!0,l=!1,o=void 0;try{for(var u,p=f.columns[Symbol.iterator]();!(a=(u=p.next()).done);a=!0){let e=u.value;e.name=i.columns.getUnusedName(e.name),i.columns.add(e)}}catch(e){l=!0,o=e}finally{try{a||null==p.return||p.return()}finally{if(l)throw o}}}}catch(e){s.error(e)}}e()})()))}}catch(e){T=!0,x=e}finally{try{E||null==O.return||O.return()}finally{if(T)throw x}}var P=!0,N=!1,F=void 0;try{for(var B,I=Object.keys(null!=(w=e.queries)?w:{})[Symbol.iterator]();!(P=(B=I.next()).done);P=!0){let t=B.value,n=e.queries[t];m.push(new Promise(e=>tA(function*(){if(n){let a=t.split(":"),l=a[2];if(!l)return void e();try{let t=a[1],o=r.Func.find({name:t}).filter(e=>e.type===es&&e.id===l)[0];if(!o)return void e();let s=o.inputs[0].name,u=yield o.apply(tE(tC({},n),{[s]:p.toList()}));u&&(yield eg(i,c,u))}catch(e){console.error(e)}}e()})()))}}catch(e){N=!0,F=e}finally{try{P||null==I.return||I.return()}finally{if(N)throw F}}yield Promise.all(m),l.close()})()})()}function tN(e,t,i,n,a,r,l){try{var o=e[r](l),s=o.value}catch(e){i(e);return}o.done?t(s):Promise.resolve(s).then(n,a)}function tF(e){return function(){var t=this,i=arguments;return new Promise(function(n,a){var r=e.apply(t,i);function l(e){tN(r,n,a,l,o,"next",e)}function o(e){tN(r,n,a,l,o,"throw",e)}l(void 0)})}}class tB extends e9{getStatus(){var e,t,i;return null!=(e=null!=(t=this.statusInput.value)?t:null==(i=this.app.campaign)?void 0:i.status)?e:"No Status"}submitWithStatus(e){return tF(function*(){var t,i;return this.statusInput.value=(null==e?void 0:e.trim())?e.trim():null!=(t=null==(i=this.app.campaign)?void 0:i.status)?t:"Submitted",yield this.submit()}).call(this)}render(){var e,t,i;this.statusInput.value=null!=(e=null==(t=this.app.campaign)?void 0:t.status)?e:"",a.empty(this.content),this.content=a.divV([a.h1("Summary"),a.div([a.tableFromMap(this.app.getSummary())]),this.statusInput.root]);let n=a.dialog("Submit");n.add(this.content),n.addButton("Save",()=>{this.app.campaign.status=this.getStatus(),this.app.saveCampaign(),n.close()}),n.show();let l=Array.from(new Set(r.Func.find({meta:{role:p}}).concat(r.Func.find({tags:[p]})))),o=l.reduce((e,t)=>{var i;return e[null!=(i=t.friendlyName)?i:t.name]=t,e},{});if(l.length>0){let e=this.app.submitParams,t=e?l.find(t=>t.name===e.fName&&eh(t)==e.package):void 0,r=null!=(i=null==t?void 0:t.friendlyName)?i:null==t?void 0:t.name,s=a.input.choice("Submit function",{value:r,items:[...Object.keys(o)],nullable:!0});s.onChanged.subscribe(()=>{var e,t;let i=o[null!=(e=s.value)?e:""];this.app.campaign.template.submit=i?{fName:i.name,package:eh(i)}:void 0,null==(t=n.getButton("Submit"))||t.remove(),i&&n.addButton("Submit",()=>{this.submit(),n.close()},void 0,"Submit the campaign file to the specified function")}),s.fireChanged(),this.content.appendChild(s.root)}}onActivated(){}submit(){return tF(function*(){let e=this.app.submitParams;if(!e)return t.shell.error("No submit function selected. Please select a function to submit the campaign."),!1;let i=r.Func.find({name:e.fName,package:e.package})[0];if(!i)return t.shell.error(`Function ${e.fName} not found.`),!1;let n=r.DataFrame.fromCsv(this.app.dataFrame.toCsv({filteredRowsOnly:!0}));return yield i.apply({df:n,molecules:this.app.molColName}),this.app.campaign.status=this.getStatus(),yield this.app.saveCampaign(),t.shell.info("Submitted successfully."),!0}).call(this)}constructor(e){var t;super(e),this.name="Submit",this.statusInput=a.input.string("Status",{value:null==(t=this.app.campaign)?void 0:t.status,nullable:!1}),this.statusSuggestionsMenu=r.Menu.popup(),this.statusInput.root.style.marginLeft="12px",this.content=a.div(),this.statusInput.onChanged.subscribe(()=>{var e,t,i,n;this.statusSuggestionsMenu.clear();let a=(null!=(e=this.statusInput.value)?e:"").toLowerCase(),r=this.app.existingStatuses.filter(e=>{var t;return(null==e||null==(t=e.toLowerCase())?void 0:t.includes(a))&&(null==e?void 0:e.toLowerCase())!==a}).filter((e,t)=>t<5);if(r.length){if(r.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.parentElement){let e=this.statusInput.root.offsetLeft+(null!=(i=null==(n=this.statusInput.input)?void 0:n.offsetLeft)?i: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()})}}var tI=i(10),tk={};function tV(e,t,i,n,a,r,l){try{var o=e[r](l),s=o.value}catch(e){i(e);return}o.done?t(s):Promise.resolve(s).then(n,a)}tk.styleTagTransform=en(),tk.setAttributes=X(),tk.insert=K().bind(null,"head"),tk.domAPI=z(),tk.insertStyleElement=et(),W()(tI.A,tk),tI.A&&tI.A.locals&&tI.A.locals;let tD=rxjs.operators;function tj(e,t,i,n,a,r,l){try{var o=e[r](l),s=o.value}catch(e){i(e);return}o.done?t(s):Promise.resolve(s).then(n,a)}function t_(e){return function(){var t=this,i=arguments;return new Promise(function(n,a){var r=e.apply(t,i);function l(e){tj(r,n,a,l,o,"next",e)}function o(e){tj(r,n,a,l,o,"throw",e)}l(void 0)})}}let tL="defaultCampaignFolder",t$="System.AppData/HitTriage";function tM(e){return t_(function*(){if(!e)return[(yield t.dapi.groups.find(r.Group.defaultGroupsIds["All users"]))].filter(Boolean);try{let i=JSON.parse(e);return(yield Promise.all(i.map(e=>t.dapi.groups.find(e)))).filter(Boolean)}catch(e){return console.error(e),[(yield t.dapi.groups.find(r.Group.defaultGroupsIds["All users"]))].filter(Boolean)}})()}function tH(e,t,i,n,a,r,l){try{var o=e[r](l),s=o.value}catch(e){i(e);return}o.done?t(s):Promise.resolve(s).then(n,a)}function tR(e){return function(){var t=this,i=arguments;return new Promise(function(n,a){var r=e.apply(t,i);function l(e){tH(r,n,a,l,o,"next",e)}function o(e){tH(r,n,a,l,o,"throw",e)}l(void 0)})}}function tU(e){var t;let i=null==(t=nh.meta)?void 0:t.sok;if(!i)throw Error("Secret key for SMILES obfuscation is not set");let n="";for(let t=0;t<e.length;t++)n+=String.fromCharCode(e.charCodeAt(t)^i.charCodeAt(t%i.length));return btoa(n)}function tq(){var e,t,i;let n=r.User.current();return null!=(e=null!=(t=null!=(i=null==n?void 0:n.login)?i:null==n?void 0:n.friendlyName)?t:n.name)?e:"unknown user"}function tY(e,i,n){return tR(function*(){let a=nh.convertToSmiles(e);if(!a||""===a||"MALFORMED_INPUT_VALUE"===a)return"";let r=tU(a),l=yield j.addMolecule(r,n,i,tq());return 0!==l.rowCount&&l.col("vid")?l.col("vid").getString(0):(t.shell.error("Molecule registration returned no data"),"")})()}function tG(e,i,n){return tR(function*(){let a=new Map,r=new Map;if(e.forEach((e,t)=>{let i=nh.convertToSmiles(e);i&&""!==i&&"MALFORMED_INPUT_VALUE"!==i&&(r.has(i)||r.set(i,[]),r.get(i).push(t))}),0===r.size)return a;let l=Array.from(r.keys());for(let o=0;o<l.length;o+=50){let s=l.slice(o,o+50);if(0!==s.length)try{let t=s.map(e=>tU(e)),l=yield j.addMolecules(t,n,i,tq());if(!l||l.rowCount!==s.length||!l.col("vid"))throw console.error("Molecule registration returned incomplete data for batch",`${o}-${o+s.length}`,`Batch size: ${s.length}, Result rows: ${null==l?void 0:l.rowCount}. Vid column found: ${!!(null==l?void 0:l.col("vid"))}`),Error("Resulting molecule registration has no or incomplete data");let u=l.col("vid").toList();for(let t=0;t<l.rowCount;t++){let i=r.get(s[t]),n=u[t];for(let t of i)a.set(e[t],n)}}catch(e){t.shell.error("Error registering molecules batch. see console for details."),nh.logger.error(e)}}return a})()}function tW(e,t,i,n,a,r,l){try{var o=e[r](l),s=o.value}catch(e){i(e);return}o.done?t(s):Promise.resolve(s).then(n,a)}function tJ(e){return function(){var t=this,i=arguments;return new Promise(function(n,a){var r=e.apply(t,i);function l(e){tW(r,n,a,l,o,"next",e)}function o(e){tW(r,n,a,l,o,"throw",e)}l(void 0)})}}let tz=["molecule","smiles","mol","structure","canonical_smiles","canonicalsmiles"],tQ=["v-id","vid","v_id"],tK=["csv",...tc.molFileExtReaders.map(e=>e.ext)];function tZ(e){var t,i,n;let a=null==(i=e.extension)?void 0:i.toLowerCase();if(a)return a;let r=null!=(t=null==(n=e.name)?void 0:n.toLowerCase())?t:"",l=r.lastIndexOf(".");return l>=0?r.slice(l+1):""}function tX(e){return tJ(function*(){let t=tZ(e);if("csv"===t){let t=yield e.readAsString();return r.DataFrame.fromCsv(t)}let i=tc.molFileExtReaders.find(e=>e.ext===t);if(!i)return null;let n=yield e.readAsBytes();if(!n)return null;let a=i.handlerFunc.inputs[0].name,l=yield i.handlerFunc.apply({[a]:n});return Array.isArray(l)?l[0]:l})()}function t0(e){var t,i;let n=(null!=(t=e.fullPath)?t:"").toLowerCase(),a=(null!=(i=e.name)?i:"").toLowerCase();return!n||n===a}function t1(e,t,i,n){try{if(e.type===t.type)return void e.set(i,t.get(n),!1);if(e.type===r.COLUMN_TYPE.STRING)return void e.set(i,t.getString(n),!1);let a=t.get(n);if(e.type===r.COLUMN_TYPE.INT)return void("number"==typeof a?e.set(i,Math.round(a),!1):"string"==typeof a&&a.length>0&&!isNaN(Number(a))&&e.set(i,Math.round(Number(a)),!1));if(e.type===r.COLUMN_TYPE.FLOAT)return void("number"==typeof a?e.set(i,a,!1):"string"==typeof a&&a.length>0&&!isNaN(Number(a))&&e.set(i,Number(a),!1));e.set(i,a,!1)}catch(a){nh.logger.error(`Merge: failed to set ${e.name}[${i}] from ${t.name}[${n}]: ${a}`)}}function t2(e,t){if(e.isNone(t))return!0;if(e.type===r.COLUMN_TYPE.STRING){let i=e.get(t);return""===i||null==i}return!1}function t4(e,i,n){return tJ(function*(){var a,r,l,o,s,u,c,p,d;if(!e.dataFrame)throw Error("Campaign has no data");let g=e.dataFrame,y=e.molColName,v=n.addNewRows&&!!n.molColName,b=n.runComputeOnNewRows&&v,{map:w}=function(e,t,i){let n=Array(e.rowCount).fill(null),a=new Map;if("smiles"===i){let i=e.col(t);if(!i)throw Error(`Campaign has no molecule column "${t}"`);for(let t=0;t<e.rowCount;t++){let e=i.get(t);if(!e)continue;let r=nh.convertToSmiles(e);r&&"MALFORMED_INPUT_VALUE"!==r&&(n[t]=r,a.has(r)||a.set(r,t))}}else{let t=e.col(f);if(!t)throw Error(`Campaign has no "${f}" column`);for(let i=0;i<e.rowCount;i++){let e=t.get(i);e&&(n[i]=e,a.has(e)||a.set(e,i))}}return{keys:n,map:a}}(g,y,n.mode),A=function(e,t){let i=Array(e.rowCount).fill(null);if("smiles"===t.mode){let n=e.col(t.molColName);if(!n)throw Error(`Incoming table has no column "${t.molColName}"`);for(let t=0;t<e.rowCount;t++){let e=n.get(t);if(!e)continue;let a=nh.convertToSmiles(e);a&&"MALFORMED_INPUT_VALUE"!==a&&(i[t]=a)}}else{let n=e.col(t.vidColName);if(!n)throw Error(`Incoming table has no column "${t.vidColName}"`);for(let t=0;t<e.rowCount;t++){let e=n.get(t);e&&(i[t]=String(e))}}return i}(i,n),C=[],E=[];for(let e=0;e<i.rowCount;e++){let t=A[e];if(!t)continue;let i=w.get(t);void 0!==i?C.push({campRow:i,incRow:e}):v&&E.push(e)}let T=null;if(b&&n.molColName&&E.length>0){let p=null!=(a=null==(l=e.campaign)||null==(r=l.template)?void 0:r.compute)?a:null==(o=e.template)?void 0:o.compute,d=i.col(n.molColName);if(p&&d){let e=E.map(e=>d.get(e)),i=p.descriptors.enabled&&null!=(s=p.descriptors.args)?s:[];try{T=yield tO(e,i,p.functions,null!=(u=p.scripts)?u:[],null!=(c=p.queries)?c:[])}catch(e){nh.logger.error(e),t.shell.warning("Merge: compute pipeline failed; merging without computed columns.")}}}let x=function(e,t,i,n){let a=[];for(let t of e.columns.toList()){if("smiles"===n.mode&&t.name===f)continue;let e=t.name;n.molColName&&t.name===n.molColName&&(e=i),"vid"===n.mode&&n.vidColName&&t.name===n.vidColName&&(e=f),a.push({col:t,target:e,isComputed:!1})}if(t)for(let e of t.columns.toList())e.name!==h&&e.name!==i&&(a.some(t=>t.target===e.name)||a.push({col:e,target:e.name,isComputed:!0}));return a}(i,T,y,n),S=new Set;for(let e of x)if(!g.columns.contains(e.target)){let t=g.columns.addNew(e.target,e.col.type);e.col.semType&&(t.semType=e.col.semType),S.add(e.target)}e.isJoining=!0;try{for(let{campRow:e,incRow:t}of C)for(let i of x){if(i.isComputed||"smiles"===n.mode&&i.target===y||"vid"===n.mode&&i.target===f)continue;let a=g.col(i.target);if(!a)continue;let r=t2(a,e);(S.has(i.target)||r||"overwrite"===n.clashStrategy)&&t1(a,i.col,e,t)}let t=g.rowCount;if(E.length>0){let a=(null!=(p=null==(d=e.stages)?void 0:d.length)?p:0)>0&&g.columns.contains(m);for(let t=0;t<E.length;t++){let i=E[t];g.rows.addNew(null,!0);let n=g.rowCount-1;for(let e of x){let a=e.isComputed?t:i;t1(g.col(e.target),e.col,n,a)}if(a){let t=g.col(m);t2(t,n)&&t.set(n,e.stages[0],!1)}}if(n.molColName){let a=i.col(n.molColName),r=g.col(f);if(a&&r&&e.campaignId){let i=E.map(e=>a.get(e)).filter(e=>!!e&&""!==e);if(i.length>0)try{let n=yield tG(i,e.campaignId,e.appName);for(let e=0;e<E.length;e++){let i=a.get(E[e]),l=i?n.get(i):void 0;l&&r.set(t+e,l,!1)}}catch(e){nh.logger.error(e)}}}}}finally{setTimeout(()=>{e.isJoining=!1},500)}g.fireValuesChanged()})()}function t5(e,t,i,n,a,r,l){try{var o=e[r](l),s=o.value}catch(e){i(e);return}o.done?t(s):Promise.resolve(s).then(n,a)}function t3(e){return function(){var t=this,i=arguments;return new Promise(function(n,a){var r=e.apply(t,i);function l(e){t5(r,n,a,l,o,"next",e)}function o(e){t5(r,n,a,l,o,"throw",e)}l(void 0)})}}let t8={smiles:"By canonical SMILES",vid:"By V-iD"},t6={skip:"Skip (keep campaign value)",overwrite:"Overwrite (use incoming value)"},t9="(none)";function t7(e,t,i){e.items=t,null!=i&&t.includes(i)?e.value=i:t.length>0?e.value=t[0]:e.value=null}function ie(e,t,i,n,a,r,l){try{var o=e[r](l),s=o.value}catch(e){i(e);return}o.done?t(s):Promise.resolve(s).then(n,a)}function it(e){return function(){var t=this,i=arguments;return new Promise(function(n,a){var r=e.apply(t,i);function l(e){ie(r,n,a,l,o,"next",e)}function o(e){ie(r,n,a,l,o,"throw",e)}l(void 0)})}}function ii(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{},n=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(i).filter(function(e){return Object.getOwnPropertyDescriptor(i,e).enumerable}))),n.forEach(function(t){var n;n=i[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}class ia extends tc{get infoView(){return this._infoView}get submitView(){return this._submitView}get version(){var e,t;return null!=(e=null==(t=this._campaign)?void 0:t.version)?e:0}handleJoiningDataframe(e){return it(function*(){let i=e.columns.bySemTypeAll(r.SEMTYPE.MOLECULE);if(!i||0===i.length)return void t.shell.error("No molecule column found");let n=null;if(i.length>1){var l;let e=i.map(e=>e.name),r=null!=(l=i.find(e=>{var t,i;return(null==e||null==(t=e.name)?void 0:t.toLowerCase())==="smiles"||(null==e||null==(i=e.name)?void 0:i.toLowerCase())==="molecule"}))?l:i[0],o=a.input.choice("Primary Molecule Column",{items:e,value:r.name,nullable:!1}),s=new Promise(e=>{a.dialog("Select Primary Molecule Column").add(a.divText("Multiple molecule columns found. Please select the primary molecule column to be used for calculations.")).add(o).onOK(()=>e(o.value)).onCancel(()=>e(null)).show()});if(!(n=yield s))return void t.shell.info("Operation cancelled by user")}else n=i[0].name;e.col(n)?(yield t4(this,e,{mode:"smiles",molColName:n,addNewRows:!0,runComputeOnNewRows:!0,clashStrategy:"overwrite"}),yield this.saveCampaign(!1)):t.shell.error("No molecule column found")}).call(this)}get submitParams(){var e,t,i,n;return null!=(e=null==(i=this.campaign)||null==(t=i.template)?void 0:t.submit)?e:null==(n=this.template)?void 0:n.submit}_initViewSubs(){this.multiView.subs.push(t.events.onCurrentViewChanged.subscribe(()=>it(function*(){try{if(t.shell.v===this._designView){var e,i,n,a;t.shell.windows.showHelp=!1,this.setBaseUrl(),eb(l,null!=(e=null!=(i=this._campaignId)?i:null==(n=this._campaign)?void 0:n.name)?e:"");let{sub:r}=ew(t.shell.v,this.appName,null==(a=t.shell.v)?void 0:a.name,()=>{var e;t.shell.v=this.mainView,null==(e=this._designView)||e.close(),this._infoView.init(),r.unsubscribe()})}else t.shell.v===this.mainView&&this.setBaseUrl()}catch(e){console.error(e)}}).call(this))),this.multiView.subs.push(t.events.onFileImportRequest.subscribe(e=>{var i,n;if(!t.shell.tv||!this._designView||t.shell.tv!==this._designView||!(null==e||null==(i=e.args)?void 0:i.file))return;let a=e.args.file;((null==(n=a.name)?void 0:n.endsWith(".csv"))||tc.molFileExtReaders.some(e=>{var t;return null==(t=a.name)?void 0:t.endsWith(e.ext)}))&&(e.preventDefault(),this.handleUploadingDataframe(a))}))}handleUploadingDataframe(e){return it(function*(){try{var i;let n=null;if(e.name.endsWith(".csv"))n=r.DataFrame.fromCsv((yield e.text()));else{let i=yield new Promise(t=>it(function*(){let i=new FileReader,n=null,a=null;i.onload=()=>{a=i.result?new Uint8Array(i.result):null,n&&clearTimeout(n),t(a)},i.readAsArrayBuffer(e),n=setTimeout(()=>{i.abort(),t(null)},1e4)})());if(!i)return void t.shell.error("Failed to read file");let a=tc.molFileExtReaders.find(t=>e.name.endsWith(t.ext)).handlerFunc,r=a.inputs[0].name;n=(yield a.apply({[r]:i}))[0]}if(!n)throw Error("Failed to read file");if(n.name=e.name.slice(0,e.name.lastIndexOf(".")),yield n.meta.detectSemanticTypes(),yield t.data.detectSemanticTypes(n),!n.columns.bySemType(r.SEMTYPE.MOLECULE))return void t.shell.addTableView(n);let l=a.dialog("Uploading table with molecules").add(a.divText("Add new table to workspace or join with existing Hit Design campaign")).addButton("Add to workspace",()=>{l.close(),t.shell.addTableView(n)}).addButton("Add to existing campaign",()=>{l.close(),this.handleJoiningDataframe(n)});null==(i=l.getButton("CANCEL"))||i.remove(),l.show()}catch(e){t.shell.error("Hit Design Failed to read file"),console.error(e)}}).call(this)}get stages(){var e,t,i,n,a;return null!=(e=null!=(t=null==(n=this.campaign)||null==(i=n.template)?void 0:i.stages)?t:null==(a=this.template)?void 0:a.stages)?e:[]}setStages(e){return it(function*(){var i;if(!this.campaign||!this.campaign.template||!this.template)return void t.shell.error("Campaign or template is not set");if(!(null==e?void 0:e.length))return void t.shell.error("Removing all stages is not allowed");let n=null==(i=this.dataFrame)?void 0:i.col(m);if(!n)return void t.shell.error("No stage column found");let a=[],r=new Set(e),l=[...r],o=this.dataFrame.rowCount,s=n.categories,u=n.getRawData();for(let t=0;t<o;t++){let i=s[u[t]];r.has(i)||(n.set(t,e[0],!1),a.push(i))}a.length>0&&t.shell.warning(`Some stages were removed: (${a.join(", ")}). Corresponding rows were set to stage "${e[0]}"`),this.campaign.template.stages=l,this.template.stages=l,yield this.saveCampaign(!0)}).call(this)}refreshCampaign(){return it(function*(){this._campaignId&&this.template?this._isSaving?t.shell.info("Campaign is being saved. Please wait a moment and try again."):(clearInterval(this._updateCheckIntervalId),this._refreshIconTooltip="Refresh Campaign",yield this.setTemplate(this.template,this._campaignId)):t.shell.warning("No campaign to refresh")}).call(this)}setTemplate(e,i){return it(function*(){var n,u,c,p,d,m,g,f,y,v,b,w,A;if(i){let e=`System.AppData/HitTriage/${this.appName}/campaigns`;this._filePath=null!=(y=null==(v=this.campaign)?void 0:v.savePath)?y:`${e}/${i}/${s}`,this.dataFrame=yield t.dapi.files.readCsv(this._filePath),(null==(b=this._campaign)?void 0:b.columnSemTypes)&&Object.entries(this._campaign.columnSemTypes).forEach(([e,t])=>{let i=this.dataFrame.columns.byName(e);i&&t&&(i.semType=t)}),(null==(w=this._campaign)?void 0:w.columnTypes)&&Object.entries(this._campaign.columnTypes).forEach(([e,t])=>{let i=this.dataFrame.columns.byName(e);if(i&&i.type!==t)try{this.dataFrame.changeColumnType(e,t)}catch(e){console.error(e)}})}else{(null==(f=this._designView)?void 0:f.dataFrame)&&t.shell.closeTable(this._designView.dataFrame),this._designView=void 0,eb(o,i=yield this.getNewCampaignName(`${this.appName}/campaigns`,e.key));let n=yield t_(function*(){var e;let i=nh.settings;if(!i)return t$;let n=null!=(e=i[tL])?e:t$;return(yield t.dapi.files.exists(n))?n:t$})();n.endsWith("/")||(n+="/"),this._filePath=`${n}${this.appName}/campaigns/${i}/${s}`}if(!this.dataFrame){t.shell.error("DataFrame is empty"),clearInterval(this._updateCheckIntervalId),this._updateCheckIntervalId=null;return}yield this.dataFrame.meta.detectSemanticTypes(),this._molColName=null!=(n=null==(p=this.dataFrame.columns.bySemType(r.SEMTYPE.MOLECULE))?void 0:p.name)?n:h,this._campaignId=i,this.template=e,null!=this._submitView||(this._submitView=new tB(this)),t.shell.windows.showHelp=!1,this.campaign?yield this.setCanEdit(this.campaign):this.hasEditPermission=!0,i&&(null==(m=this.campaign)||null==(d=m.mergeConfig)?void 0:d.autoMergeOnOpen)&&this.campaign.mergeConfig.filePath&&(yield(A=this,tJ(function*(){var e,i,n;let a=null==(e=A.campaign)?void 0:e.mergeConfig;if((null==a?void 0:a.autoMergeOnOpen)&&a.filePath&&A.dataFrame)try{if(!(yield t.dapi.files.exists(a.filePath)))return void t.shell.warning(`Auto-merge: source file not found or not accessible: ${a.filePath}`);let e=r.FileInfo.fromString(a.filePath,""),l=yield tX(e);if(!l)return void t.shell.warning("Auto-merge: could not read the saved source file; merge skipped.");yield l.meta.detectSemanticTypes(),yield t.data.detectSemanticTypes(l);let o=(i=function(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{},n=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(i).filter(function(e){return Object.getOwnPropertyDescriptor(i,e).enumerable}))),n.forEach(function(t){var n;n=i[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({},a),n={runComputeOnNewRows:!1},n=null!=n?n:{},Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(n)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t.push.apply(t,i)}return t})(Object(n)).forEach(function(e){Object.defineProperty(i,e,Object.getOwnPropertyDescriptor(n,e))}),i);yield t4(A,l,o)}catch(e){nh.logger.error(e),t.shell.warning("Auto-merge failed; opening the campaign without merging.")}})())),i&&this.campaign&&(yield this.reComputeOnCampaignOpen());let C=this.designView;this.currentDesignViewId=C.name,this.setBaseUrl(),eb(l,null!=(u=null!=(c=this._campaignId)?c:null==(g=this._campaign)?void 0:g.name)?u:""),this.campaign&&(this.campaign.template=e),j.getLastModified(this.appName,this._campaignId).then(e=>{var i;let n=null==e||null==(i=e.col("updated_at"))?void 0:i.getString(0);this._lastExpiresTimeString=null!=n?n:null,this._needsRefresh=!1,clearInterval(this._updateCheckIntervalId);let r=!1;this._updateCheckIntervalId=setInterval(()=>it(function*(){if(!r&&!this._needsRefresh){if(r=!0,this._designView&&!Array.from(t.shell.tableViews).some(e=>e===this._designView)){clearInterval(this._updateCheckIntervalId),console.log("Clearing campaign update check interval"),this._updateCheckIntervalId=null,r=!1;return}if(!this._campaignId||!this.template||this._isSaving||this.isJoining||!this._designView||t.shell.v!==this._designView){r=!1;return}try{var e;let t=yield j.getLastModified(this.appName,this._campaignId),i=null==t||null==(e=t.col("updated_at"))?void 0:e.getString(0);if(!i){r=!1;return}this._lastExpiresTimeString!==i&&this._refreshCampaignIcon&&(this._lastExpiresTimeString=i,a.hints.addHintIndicator(this._refreshCampaignIcon,!0,1e4),this._refreshIconTooltip="New changes available. Click to refresh campaign.",this._lastExpiresTimeString=i,this._needsRefresh=!0)}catch(e){console.error(e)}r=!1}}).call(this),3e3)}).catch(e=>console.error(e))}).call(this)}get campaignId(){return this._campaignId}get designView(){let e=this.getDesignView();return iT(e,this,"design"),this._designView=e}get designViewName(){return this._designViewName}set designViewName(e){this._designViewName=e,this._designView&&(this._designView.name=e)}get molColName(){var e,t,i,n;return null!=(e=this._molColName)?e:this._molColName=null!=(t=null==(n=this.dataFrame)||null==(i=n.columns.bySemType(r.SEMTYPE.MOLECULE))?void 0:i.name)?t:h}get campaign(){return this._campaign}set campaign(e){this._campaign=e}clearCampaign(){this._campaign=void 0}cacheDuplicateVIDs(){var e;let t=null==(e=this.dataFrame)?void 0:e.col(f);if(!t){this._duplicateVidCache=void 0;return}let i=t.version,n=new Uint32Array(t.categories.length).fill(0),a=t.getRawData().subarray(0,t.length);a.forEach(e=>n[e]++),this._duplicateVidCache={colVersion:i,valueCounts:n,indexes:a}}get duplicateVidCache(){var e;let t=null==(e=this.dataFrame)?void 0:e.col(f);if(t)return this._duplicateVidCache&&t.version===this._duplicateVidCache.colVersion||this.cacheDuplicateVIDs(),this._duplicateVidCache}performSingleCellCalculations(e,t){return it(function*(){let i=this.template.compute;if(t&&""!==t){for(let n of(yield tO([t],i.descriptors.args,i.functions,i.scripts,i.queries)).columns.toList())n.name!==h&&(this.dataFrame.columns.contains(n.name)||(this.dataFrame.columns.addNew(n.name,n.type).semType=n.semType),this.dataFrame.col(n.name).set(e,n.get(0),!1));this.dataFrame.fireValuesChanged(),this.saveCampaign(!1)}}).call(this)}reComputeOnCampaignOpen(){return it(function*(){var e,i,n,a;let r=null==(a=this.template)?void 0:a.compute;if(!r||!this.dataFrame||!this.molColName)return;let l=(null!=(e=r.functions)?e:[]).filter(e=>e.rerunOnOpen),o=(null!=(i=r.scripts)?i:[]).filter(e=>e.rerunOnOpen),s=(null!=(n=r.queries)?n:[]).filter(e=>e.rerunOnOpen);if(!l.length&&!o.length&&!s.length)return;let u=this.dataFrame.col(this.molColName);if(u)try{let e=u.toList();for(let t of(yield tO(e,[],l,o,s)).columns.toList()){if(t.name===this.molColName||t.name===h)continue;let e=this.dataFrame.col(t.name);e&&e.type===t.type||(e&&this.dataFrame.columns.remove(t.name),e=this.dataFrame.columns.addNew(t.name,t.type)),e.semType=t.semType;let i=Math.min(t.length,e.length);for(let n=0;n<i;n++)e.set(n,t.isNone(n)?null:t.get(n),!1)}this.dataFrame.fireValuesChanged()}catch(e){nh.logger.error(e),t.shell.warning("Re-run on open failed for some functions; opening the campaign anyway.")}}).call(this)}initDesignViewRibbons(e,i,n=!1){let l=t.events.onViewRemoved.subscribe(t=>{t.id===(null==e?void 0:e.id)&&(i.forEach(e=>e.unsubscribe()),l.unsubscribe())}),o=null==e?void 0:e.getRibbonPanels();if(o&&!eC(o)){var s,u,c;setTimeout(()=>{let{sub:i}=ew(e,this.appName,e.name,()=>{t.shell.v=this.mainView,null==e||e.close(),this._infoView.init(),i.unsubscribe()})},1e3);let i=()=>it(function*(){var t;eZ(this,t=>it(function*(){var i,n,r,l,o,s,u,c,p,d;let m=this.template.compute.descriptors.args,h=this.template.compute.functions,g=null!=(i=this.template.compute.scripts)?i:[],f=null!=(n=this.template.compute.queries)?n:[],y=t.descriptors,v={descriptors:{enabled:!!(null==t||null==(d=t.descriptors)?void 0:d.length),args:null!=(r=null==t?void 0:t.descriptors)?r:[]},functions:Object.entries(null!=(l=null==t?void 0:t.externals)?l:{}).map(([e,i])=>{var n;let a=e.split(":");return{name:a[1],package:a[0],args:i,rerunOnOpen:!!(null==t||null==(n=t.rerunOnOpen)?void 0:n[e])}}),scripts:Object.entries(null!=(o=null==t?void 0:t.scripts)?o:{}).filter(([e,t])=>e.startsWith(eu)&&3===e.split(":").length).map(([e,i])=>{var n,a,r;let l=e.split(":");return{name:null!=(n=l[1])?n:"",id:null!=(a=l[2])?a:"",args:i,rerunOnOpen:!!(null==t||null==(r=t.rerunOnOpen)?void 0:r[e])}}),queries:Object.entries(null!=(s=null==t?void 0:t.queries)?s:{}).filter(([e,t])=>e.startsWith(ec)&&3===e.split(":").length).map(([e,i])=>{var n,a,r;let l=e.split(":");return{name:null!=(n=l[1])?n:"",id:null!=(a=l[2])?a:"",args:i,rerunOnOpen:!!(null==t||null==(r=t.rerunOnOpen)?void 0:r[e])}})};this.template.compute=v,this.campaign.template=this.template;let b=y.filter(e=>!m.includes(e)),w={};Object.entries(null!=(u=null==t?void 0:t.externals)?u:{}).filter(([e,t])=>{let i=h.find(t=>`${t.package}:${t.name}`===e);return!i||!Object.entries(t).every(([e,t])=>i.args[e]===t)}).forEach(([e,t])=>{w[e]=t});let A={};Object.entries(null!=(c=null==t?void 0:t.scripts)?c:{}).filter(([e,t])=>{let i=g.find(t=>`${eu}:${t.name}:${t.id}`===e);return!i||!Object.entries(t).every(([e,t])=>i.args[e]===t)}).forEach(([e,t])=>{A[e]=t});let C={};Object.entries(null!=(p=null==t?void 0:t.queries)?p:{}).filter(([e,t])=>{let i=f.find(t=>`${ec}:${t.name}:${t.id}`===e);return!i||!Object.entries(t).every(([e,t])=>i.args[e]===t)}).forEach(([e,t])=>{C[e]=t}),a.setUpdateIndicator(e.grid.root,!0);try{yield tP({descriptors:b,externals:w,scripts:A,queries:C},this.dataFrame,this.molColName),this.dataFrame.fireValuesChanged()}finally{a.setUpdateIndicator(e.grid.root,!1),this.saveCampaign(!1)}}).call(this),()=>null,null==(t=this.campaign)?void 0:t.template,!0,!0)}).call(this),l=a.iconFA("wrench",i,"Calculate additional properties"),p=a.iconFA("code-merge",()=>{var e;e=this,t3(function*(){var i,n,l,o,s,u;if(!e.dataFrame)return void t.shell.error("Cannot merge: campaign has no data.");let c=null==(u=e.campaign)?void 0:u.mergeConfig,p=null,d=!1,m=!1,h=a.input.file("Source file",{nullable:!0,tooltipText:`Pick a file from your computer or from a Datagrok file share.
|
|
429
|
+
Allowed extensions: ${tK.join(", ")}.
|
|
430
|
+
Files picked from a share are remembered with the campaign and reloaded automatically next time.`,onValueChanged:e=>{var i;return i=e,t3(function*(){if(m)return;if(!i){p=null,N(null),O();return}let e=tZ(i);if(!tK.includes(e)){setTimeout(()=>{m=!0;try{h.value=null}finally{m=!1}O()},0),t.shell.warning(`Unsupported file type ".${e||"?"}". Allowed: ${tK.join(", ")}.`);return}yield P(i,null)})()}});h.input.setAttribute("placeholder",`Drop file or pick from share — ${tK.join(", ")}`);let g=a.input.choice("Merge by",{items:Object.values(t8),value:t8[null!=(i=null==c?void 0:c.mode)?i:"vid"],nullable:!1,tooltipText:'Join key. "Canonical SMILES" matches by canonicalized molecule structure; "V-iD" matches by the campaign\'s V-iD identifier.',onValueChanged:()=>O()}),f=a.input.choice("Molecule column (incoming)",{items:[],value:null,nullable:!0,tooltipText:"Column in the incoming table holding the molecules. Required for SMILES merge. In V-iD merge it is optional — if set, unmatched rows can be added to the campaign and registered with new V-iDs.",onValueChanged:()=>O()}),v=a.input.choice("V-iD column (incoming)",{items:[],value:null,nullable:!0,tooltipText:"Column in the incoming table holding V-iD strings. Used as the join key when merging by V-iD.",onValueChanged:()=>O()}),b=a.input.bool("Add unmatched rows",{value:null==(n=null==c?void 0:c.addNewRows)||n,tooltipText:"When on, rows from the incoming table whose key is not present in the campaign are added as new rows. When off, only existing rows are updated. Disabled when no incoming molecule column is selected (nothing to register the new row with).",onValueChanged:()=>O()}),w=a.input.bool("Run compute on new rows",{value:null==(l=null==c?void 0:c.runComputeOnNewRows)||l,tooltipText:"Run the campaign's compute pipeline (descriptors, functions, scripts, queries) on the incoming molecules so new rows arrive with all calculated columns filled in. Disabled when no rows will be added.",onValueChanged:()=>O()}),A=a.input.choice("On clashing data",{items:Object.values(t6),value:t6[null!=(o=null==c?void 0:c.clashStrategy)?o:"overwrite"],nullable:!1,tooltipText:'How to resolve cells that have a value on both sides for a matched row. "Skip" keeps the existing campaign value; "Overwrite" replaces it with the incoming value. Empty campaign cells are always filled from the incoming table regardless of this setting.',onValueChanged:()=>O()}),C=a.input.bool("Auto-merge on campaign open",{value:null!=(s=null==c?void 0:c.autoMergeOnOpen)&&s,tooltipText:"When on, this file is re-read and merged into the campaign every time the campaign is opened, using the configuration below. Compute is never re-run for this implicit pass and the campaign is not auto-saved. Only available for files picked from a Datagrok file share — local uploads cannot be re-read on open.",onValueChanged:()=>O()}),E=a.divText("");E.style.color="var(--failure)",E.style.fontSize="12px",E.style.marginTop="8px",E.style.minHeight="16px";let T=a.divV([h.root,g.root,f.root,v.root,b.root,w.root,A.root,C.root,E]);T.style.minWidth="420px";let x=e=>e===t8.vid?"vid":"smiles",S=e=>{let t=e.value;return t&&t!==t9?t:void 0};function O(){var e;let t,i=x(g.value),n=!!p&&!d;g.enabled=n,f.enabled=n,v.enabled=n&&"vid"===i,A.enabled=n;let a=S(f),r=S(v),l=n&&!!a;b.enabled=l,w.enabled=l&&!0===b.value;let o=h.value;C.enabled=!!o&&!t0(o);let s="";d?s="Reading file…":n?"smiles"!==i||a?"vid"!==i||r||(s="Pick the V-iD column from the incoming table."):s="Pick the molecule column from the incoming table.":s="Pick a source file to merge from.",E.textContent=s,e=""===s,(t=F.getButton("OK"))&&(e?(t.removeAttribute("disabled"),t.classList.remove("disabled")):(t.setAttribute("disabled","true"),t.classList.add("disabled")))}function P(e,i){return t3(function*(){var n,r,l;d=!0,p=null,O(),a.setUpdateIndicator(T,!0,"Reading file...");try{let i=yield tX(e);if(!i)throw Error("Empty result");i.name=(null!=(n=e.name)?n:"").replace(/\.[^.]+$/,""),yield i.meta.detectSemanticTypes(),yield t.data.detectSemanticTypes(i),p=i}catch(i){nh.logger.error(i),t.shell.error(`Failed to read "${e.name}". Check that the file is accessible and well-formed.`),p=null}finally{a.setUpdateIndicator(T,!1),d=!1}N(i),i&&(g.value=t8[(r=i).mode],b.value=r.addNewRows,w.value=r.runComputeOnNewRows,A.value=t6[r.clashStrategy],C.value=null!=(l=r.autoMergeOnOpen)&&l),O()})()}function N(e){var t,i,n,a,l,o;if(!p){t7(f,[]),t7(v,[]);return}let s=p.columns.toList().map(e=>e.name),u=null!=(t=null!=(i=null==e?void 0:e.molColName)?i:null==(l=function(e){var t;let i=e.columns.toList(),n=i.filter(e=>e.semType===r.SEMTYPE.MOLECULE);if(n.length>0){let e=n.find(e=>tz.includes(e.name.toLowerCase()));return null!=e?e:n[0]}let a=i.find(e=>tz.includes(e.name.toLowerCase()));return a||(null!=(t=i.find(e=>e.type===r.COLUMN_TYPE.STRING))?t:null)}(p))?void 0:l.name)?t:null;t7(f,[t9,...s],null!=u?u:t9);let c=null!=(n=null!=(a=null==e?void 0:e.vidColName)?a:null==(o=function(e){let t=e.columns.toList(),i=t.find(e=>tQ.includes(e.name.toLowerCase()));if(i)return i;let n=t.find(e=>e.semType===y);return n||null}(p))?void 0:o.name)?n:null;t7(v,[t9,...s],null!=c?c:t9)}let F=a.dialog("Merge with table");if(F.add(T),F.onOK(()=>t3(function*(){yield t3(function*(){if(!p)return;let i=x(g.value),n=S(f),a=S(v),l=h.value,o=l&&!t0(l)?l.fullPath:void 0,s={mode:i,filePath:o,molColName:n,vidColName:"vid"===i?a:void 0,addNewRows:!!b.value&&!!n,runComputeOnNewRows:!!w.value&&!!b.value&&!!n,clashStrategy:A.value===t6.overwrite?"overwrite":"skip",autoMergeOnOpen:!!C.value&&!!o},u=r.TaskBarProgressIndicator.create("Merging table into campaign...");try{yield t4(e,p,s),e.campaign&&(e.campaign.mergeConfig=s,yield e.saveCampaign(!1)),t.shell.info("Table merged into campaign.")}catch(e){nh.logger.error(e),t.shell.error("Merge failed. See console for details.")}finally{u.close()}})()})()),F.show(),O(),null==c?void 0:c.filePath)try{if(yield t.dapi.files.exists(c.filePath)){let e=r.FileInfo.fromString(c.filePath,"");m=!0;try{h.value=e}finally{m=!1}yield P(e,c)}else t.shell.warning(`Saved merge file not found or not accessible: ${c.filePath}`)}catch(e){nh.logger.error(e),t.shell.warning("Could not restore previously saved merge file.")}})()},"Merge another table into the campaign"),d=a.icons.add(()=>{var e;null==(e=this.dataFrame)||e.rows.addNew(null,!0)},"Add new row"),h=a.iconSvg("view-layout",()=>{this.applyTemplateLayout(e)},`Apply template layout ${(null==(s=this.template)?void 0:s.localLayoutPath)?"(Loaded from mounted file storage)":"(Static)"}`);this._refreshCampaignIcon=a.icons.sync(()=>it(function*(){this.refreshCampaign()}).call(this),"Refresh"),a.tooltip.bind(this._refreshCampaignIcon,()=>this._refreshIconTooltip);let g=a.iconFA("share",()=>it(function*(){var e;yield new tr(null==(e=this.campaign)?void 0:e.permissions).show(e=>{this.campaign.permissions=e,this.saveCampaign(!0)})}).call(this),"Edit campaign permissions"),f=a.bigButton("Progress tracker",()=>{!function e(i,n){var l,o,s,u,c,p,d,h,g,f;let y=null==(o=i.campaign)?void 0:o.tilesViewerFormSketch,v=null;if(y&&y.length>0)try{v=JSON.parse(y)}catch(e){console.error("Failed to parse sketch state string",e)}v&&v.elementStates&&(null!=(h=v.elementStates.length)?h:0)>0&&(v.elementStates=v.elementStates.filter(e=>{var t;return(null==e||null==(t=e.viewerSettings)?void 0:t.column)&&i.dataFrame.col(e.viewerSettings.column)}),v.elementStates.forEach(e=>{var t;(null==e||null==(t=e.viewerSettings)?void 0:t.table)&&(e.viewerSettings.table=i.dataFrame.name)}));let b=function(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{},n=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(i).filter(function(e){return Object.getOwnPropertyDescriptor(i,e).enumerable}))),n.forEach(function(t){var n;n=i[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({lanesColumnName:m,lanes:i.stages},(null!=(l=null==v||null==(s=v.elementStates)?void 0:s.length)?l:0)>0?{sketchState:v}:{}),w=n();if(!w)return void t.shell.error("Failed to create tiles viewer. table view is not available.");let A=null,C=a.dialog("Progress Tracker");try{let e=(A=w.addViewer(r.VIEWER.TILE_VIEWER,b)).getOptions();e.look.sketchState=(null!=(g=null==v||null==(f=v.elementStates)?void 0:f.length)?g:0)>0?v:null,A.setOptions(e),A.copyViewersLook(A)}catch(e){t.shell.error("Failed to create tiles viewer with preset layout.\n Falling back to default layout."),console.error("Failed to create tiles viewer",e),A&&(A.close(),A.detach()),A=w.addViewer(r.VIEWER.TILE_VIEWER,{lanesColumnName:m,lanes:i.stages})}if(!A)return void t.shell.error("Failed to create tiles viewer. check the console for more details.");let E=null,T=()=>{try{A.detach(),A.close()}catch(e){}};C.add(A.root),C.addButton("Modify Stages",()=>{null==E||E.close();let r=tf(i.stages);(E=a.dialog("Modify Stages").add(r.fieldsDiv).onOK(()=>{var l;return(l=function*(){T(),a.setUpdateIndicator(C.root,!0);try{yield i.setStages(r.getFields()),a.setUpdateIndicator(C.root,!1),C.close(),yield new Promise(t=>setTimeout(()=>{t(),e(i,n)},100))}catch(e){t.shell.error("Failed to update stages. check the console for more details."),console.error("Failed to update stages",e)}finally{(null==C?void 0:C.root)&&document.contains(C.root)&&C.close()}},function(){var e=this,t=arguments;return new Promise(function(i,n){var a=l.apply(e,t);function r(e){tV(a,i,n,r,o,"next",e)}function o(e){tV(a,i,n,r,o,"throw",e)}r(void 0)})})()}).show()).root.classList.add("hit-design-stage-editing-dialog")},0);let x=t.events.onCurrentViewChanged.subscribe(()=>{t.shell.v===w?C.root.style.display="flex":C.root.style.setProperty("display","none","important")}),S=null==(c=i.dataFrame)||null==(u=c.col(m))?void 0:u.version,O=C.onClose.subscribe(()=>{var e,n;O.unsubscribe(),x.unsubscribe(),null==E||E.close();try{let e=A.props.sketchState;if(e&&"object"==typeof e){let t=JSON.stringify(e);i.campaign&&(i.campaign.tilesViewerFormSketch=t)}}catch(e){t.shell.error("Failed to save sketch state. check the console for more details."),console.error("Failed to save sketch state",e)}T(),void 0!=S&&(null==(n=i.dataFrame)||null==(e=n.col(m))?void 0:e.version)!==S&&i.saveCampaign()});C.showModal(!0),null==(p=C.getButton("CANCEL"))||p.remove(),C.onOK(()=>{}),null==(d=document.querySelector(".d4-modal-background"))||d.remove()}(this,()=>{var e;return null!=(e=this._designView)?e:null})}),v=a.bigButton("Submit...",()=>{var e;null==(e=this._submitView)||e.render()}),b=r.Func.find({meta:{role:"HitDesignerFunction"}}).filter(e=>1===e.outputs.length&&e.outputs[0].propertyType===r.TYPE.DATA_FRAME);v.classList.add("hit-design-submit-button");let w=[v];if(this.stages.length>0&&w.unshift(f),this.campaign&&this.template&&!this.campaign.template&&(this.campaign.template=this.template),((null==(u=this.template)?void 0:u.layoutViewState)||(null==(c=this.template)?void 0:c.localLayoutPath))&&w.unshift(h),this.hasEditPermission&&w.unshift(g),b.length>0&&n){let e=b[0],i=a.iconFA("pen-nib",()=>it(function*(){let i={};if(e.inputs.length>0&&this.dataFrame&&this.dataFrame.currentRowIdx>=0&&e.inputs[0].semType===r.SEMTYPE.MOLECULE){var n;let t=nh.convertToSmiles(null==(n=this.dataFrame.col(this.molColName))?void 0:n.get(this.dataFrame.currentRowIdx));t&&(i[e.inputs[0].name]=t)}let l=e.prepare(i),o=yield l.getEditor();a.dialog(e.friendlyName).add(o).onOK(()=>it(function*(){let i=r.TaskBarProgressIndicator.create(`Running ${e.friendlyName}`);try{yield l.call();let n=l.getOutputParamValue();if(!n||!n.rowCount){t.shell.warning(`${e.friendlyName} returned an empty result`),i.close();return}yield n.meta.detectSemanticTypes(),yield t.data.detectSemanticTypes(n),yield this.handleJoiningDataframe(n)}catch(i){t.shell.error(`Failed to run ${e.friendlyName}`),nh.logger.error(i)}finally{i.close()}}).call(this)).show()}).call(this),e.description?e.description:e.friendlyName);w.unshift(i)}w.unshift(l),w.unshift(p),w.unshift(d),w.unshift(this._refreshCampaignIcon),o.push(w),o.some(e=>{var t;let i=null!=(t=null==e?void 0:e.findIndex(e=>{var t;return(null==e||null==(t=e.textContent)?void 0:t.toLowerCase())==="save"}))?t:-1;return -1!==i&&(e.splice(i,1),!0)}),o=o.filter(e=>{var t;return(null!=(t=null==e?void 0:e.length)?t:0)>0}),e.setRibbonPanels(o)}return e}applyTemplateLayout(e){return it(function*(){var i,n;if(!e)return void t.shell.error("No view found");if(null==(i=this.template)?void 0:i.localLayoutPath)try{let i=yield t.dapi.files.readAsText(this.template.localLayoutPath),n=r.ViewLayout.fromJson(i);e.loadLayout(n);return}catch(e){t.shell.error("Failed to apply layout from mounted file storage. Falling back to static layout"),nh.logger.error(e)}if(!(null==(n=this.template)?void 0:n.layoutViewState))return void t.shell.error("No layout found");try{let t=r.ViewLayout.fromViewState(this.template.layoutViewState);e.loadLayout(t)}catch(e){t.shell.error("Failed to apply template layout. Check console for more details."),nh.logger.error(e)}}).call(this)}getDesignView(){var e,i,n,a,l,o,s;this._designView&&this._designView.close();let u=[],c=null==(n=this.dataFrame.col(this.molColName))?void 0:n.toList().every(e=>!e&&""===e),p=t.shell.addTableView(this.dataFrame);this._designViewName=null!=(e=null!=(i=null==(a=this.campaign)?void 0:a.friendlyName)?i:null==(l=this.campaign)?void 0:l.name)?e:this._designViewName,p.name=this._designViewName,p._onAdded();let d=null==(o=this._campaign)?void 0:o.layout;if(d)try{let e=r.ViewLayout.fromViewState(d);p.loadLayout(e)}catch(e){t.shell.error("Failed to apply layout. Falling back to default layout."),console.error(e)}this.checkGrid(p),c&&t.functions.call("Chem:editMoleculeCell",{cell:p.grid.cell(this._molColName,0)}),this.initGridSubs(p,u);let h=null==(s=p.grid)?void 0:s.col(f);h&&(h.editable=!1);let g=this.dataFrame.col(f);return g&&(g.semType=y,g.valueComparer=(e,t)=>e===t?0:null===e?-1:null===t?1:parseInt(e.substring(1))-parseInt(t.substring(1))),u.push(this.dataFrame.onRowsAdded.pipe((0,tD.filter)(()=>!this.isJoining)).subscribe(()=>{try{if(this.stages.length>0)for(let t=0;t<this.dataFrame.rowCount;t++){var e;let i=this.dataFrame.col(m).get(t);(!i||""===i||(null==(e=this.dataFrame.col(m))?void 0:e.isNone(t)))&&this.dataFrame.set(m,t,this.stages[0])}let i=null;for(let e=0;e<this.dataFrame.rowCount;e++){let t=p.grid.cell(this.molColName,e);t&&(""===t.cell.value||null===t.cell.value)&&(i=t)}i&&t.functions.call("Chem:editMoleculeCell",{cell:i})}catch(e){console.error(e)}})),u.push(t.events.onContextMenu.subscribe(e=>{try{var i,n,a,l,o,s,u,c,d,m,h,g;let t=null==e||null==(i=e.args)?void 0:i.context;if(!t||(null==t?void 0:t.type)!==r.VIEWER.GRID||!t.tableView||t.tableView.id!==p.id||(null==e||null==(l=e.args)||null==(a=l.item)||null==(n=a.tableColumn)?void 0:n.name)!==this.molColName||!(null==e||null==(s=e.args)||null==(o=s.item)?void 0:o.isTableCell))return;let f=null==e||null==(u=e.args)?void 0:u.menu;if(!f)return;f.item("Add new row",()=>{this.dataFrame.rows.addNew(null,!0)}),f.item("Duplicate molecule",()=>{try{var t,i,n,a;let r=this.dataFrame.rows.addNew(null,!0),l=r.get(this.molColName);null!=l&&r.idx>-1&&(this.dataFrame.cell(r.idx,this.molColName).value=null!=(t=null==e||null==(a=e.args)||null==(n=a.item)||null==(i=n.cell)?void 0:i.value)?t:"")}catch(e){console.error(e)}});let y=null==e||null==(d=e.args)||null==(c=d.item)?void 0:c.tableRowIndex,v=null==e||null==(g=e.args)||null==(h=g.item)||null==(m=h.cell)?void 0:m.value;v&&(null!=y?y:-1)>-1&&f.item("Re-Run Calculations",()=>it(function*(){try{yield this.performSingleCellCalculations(y,v)}catch(e){console.error(e)}}).call(this))}catch(e){t.log.error(e)}})),u.push(t.events.onViewLayoutApplied.subscribe(e=>{e&&e.view===p&&this.initGridSubs(p,u)})),this.initDesignViewRibbons(p,u,!0),p.parentCall=this.parentCall,p}checkGrid(e){e.grid||(t.shell.error("Applied layout created view without grid. Resetting layout."),e.resetLayout())}initGridSubs(e,i){if(!this._gridSubs||this._gridSubs.grid!==e.grid){if(this._gridSubs&&this._gridSubs.subs.forEach(e=>e.unsubscribe()),this.checkGrid(e),!e.grid)return void t.shell.error("No grid found, cannot initialize grid subscriptions");this._gridSubs={grid:e.grid,subs:[]},(null==e?void 0:e.grid)&&this._gridSubs.subs.push(e.grid.onCellValueEdited.subscribe(e=>it(function*(){try{var i,n;if((null==(i=e.tableColumn)?void 0:i.name)===m)return void(yield this.saveCampaign(!1));if((null==(n=e.tableColumn)?void 0:n.name)!==this.molColName)return;let t=e.cell.value,a=e.tableRowIndex;if(t)try{let e=yield tY(t,this._campaignId,this.appName);this.dataFrame.col(f).set(a,e,!0)}catch(e){console.error("Failed to register molecule")}yield this.performSingleCellCalculations(a,t)}catch(e){t.shell.error("Failed to process molecule edit, check console for details"),console.error(e)}}).call(this))),(null==e?void 0:e.grid)&&this._gridSubs.subs.push(e.grid.onCellRender.subscribe(e=>{try{var t;let i=e.cell,n=this.duplicateVidCache;if(!i||!i.isTableCell||!i.tableColumn||!n||i.tableColumn.name!==f||(null!=(t=i.tableRowIndex)?t:-1)<0)return;n.valueCounts[n.indexes[i.tableRowIndex]]>1&&(e.cell.style.backColor=r.Color.setAlpha(r.Color.getCategoricalColor(n.indexes[i.tableRowIndex]),150))}catch(e){}})),this._gridSubs.subs.forEach(e=>i.push(e))}}getSummary(){var e,i,n,l,o,u,c,p,d,m,h,g,f,y,v,b,w,A;let E,T,x=()=>{var e,t;let i=this._filePath.indexOf(null!=(e=this.campaignId)?e:null==(t=this._campaign)?void 0:t.name);return -1===i?this._filePath:this._filePath.substring(0,i-1)},S=ii({},null!=(e=null==(u=this.campaign)?void 0:u.campaignFields)?e:this.campaignProps);this.template&&this.template.campaignFields&&Object.entries(S).forEach(([e,i])=>{let n=this.template.campaignFields.find(t=>t.name===e);n&&"Date"===n.type&&i?"Invalid Date"!==new Date(i).toString()?S[e]=new Date(i).toLocaleDateString():i.date?S[e]=new Date(i.date).toLocaleDateString():S[e]=i:n&&n.type===r.SEMTYPE.MOLECULE&&i&&(S[e]=t.chem.drawMolecule(i))});let O=()=>{let e=a.icons.edit(()=>{let i=x(),l=a.input.string("Path",{value:i}),o=l.root.getElementsByTagName("label").item(0);o&&o.remove(),l.root.style.width="100%";let u=a.button("Save",()=>it(function*(){var i;if(!(yield(i=l.value,ey(function*(){return i&&""!==i.trim()?!!(yield t.dapi.files.exists(i))||(t.shell.error("Given folder does not exist"),!1):(t.shell.error("Path can not be empty"),!1)})())))return;let o=l.value;o.endsWith("/")?this._filePath=`${o}${this.campaignId}/${s}`:this._filePath=`${o}/${this.campaignId}/${s}`,this._campaign&&(this._campaign.savePath=this._filePath),yield this.saveCampaign(!0),a.empty(r);let u=x();n=a.link(u,()=>{var e,t,i;return this.download(this.dataFrame,null!=(e=null!=(t=this.campaignId)?t:null==(i=this._campaign)?void 0:i.name)?e:"Molecules")},C),r.appendChild(n),r.appendChild(e)}).call(this)),c=a.button("Cancel",()=>{a.empty(r),r.appendChild(n),r.appendChild(e)});a.empty(r),l.addOptions(c),l.addOptions(u),r.appendChild(l.root),l.input.focus()},"Edit file path");e.style.marginLeft="5px";let i=x(),n=a.link(i,()=>{var e,t,i;return this.download(this.dataFrame,null!=(e=null!=(t=this.campaignId)?t:null==(i=this._campaign)?void 0:i.name)?e:"Molecules")},C),r=a.divH([n,e],{style:{alignItems:"center"}});return r},P=null!=(i=null!=(n=null==(c=this.campaign)?void 0:c.friendlyName)?n:null==(p=this.campaign)?void 0:p.name)?i:this.campaignId;return w=ii({Name:(y=a.divText(P),v={tooltip:"Edit Campaign Name",nullable:!1,onOk:e=>it(function*(){this.campaign.friendlyName=e,yield this.saveCampaign(!0)}).call(this),validator:e=>it(function*(){return(null==e?void 0:e.trim())?null:"Campaign name can not be empty"})()},E=a.icons.edit(()=>{var e,i,n,r,l;let o=null!=(e=null!=(i=null==v?void 0:v.tooltip)?i:y.textContent)?e:"",s=null!=(n=null==v?void 0:v.beforeEditTextContent)?n:e=>e,u=null!=(r=null==v?void 0:v.afterEditTextContent)?r:e=>e,c=a.input.string("smth",{value:s(null!=(l=y.textContent)?l:""),onValueChanged:()=>ey(function*(){var e;let t=yield d();setTimeout(()=>{var e,i;if(t){c.input.classList.add("d4-invalid"),o=t;return}c.input.classList.remove("d4-invalid"),o=null!=(e=null!=(i=null==v?void 0:v.tooltip)?i:y.textContent)?e:""},100),null==v||null==(e=v.onChange)||e.call(v,c.value)})()});a.tooltip.bind(c.input,()=>o);let p=c.root.getElementsByTagName("label").item(0);p&&p.remove(),c.root.style.width="100%";let d=()=>ey(function*(){var e;let t=(null==(e=c.value)?void 0:e.trim())||(null==v?void 0:v.nullable)?null:"Field cannot be empty";return null!=t?t:(null==v?void 0:v.validator)?yield v.validator(c.value):null})(),m=a.button("Save",()=>ey(function*(){var e,i;let n=yield d();n?t.shell.error(n):(yield null==v||null==(i=v.onOk)?void 0:i.call(v,c.value),y.textContent=null!=(e=u(c.value))?e:"",a.empty(T),T.appendChild(y),T.appendChild(E))})()),h=a.button("Cancel",()=>{var e;a.empty(T),T.appendChild(y),T.appendChild(E),null==v||null==(e=v.onCancel)||e.call(v)});a.empty(T),c.addOptions(h),c.addOptions(m),T.appendChild(c.root),c.input.focus()},null!=(b=null==v?void 0:v.tooltip)?b:"Edit"),T=a.divH([y,E],{style:{display:"flex",alignItems:"center"}}),E.style.marginLeft="5px",T),Code:null!=(l=this.campaignId)?l:null==(d=this._campaign)?void 0:d.name,Template:null!=(o=null==(m=this.template)?void 0:m.name)?o:"Molecules","File Path":O()},(null==(h=this.campaign)?void 0:h.authorUserFriendlyName)?{Author:this.campaign.authorUserFriendlyName}:{},(null==(g=this.campaign)?void 0:g.lastModifiedUserName)?{"Last Modified By":this.campaign.lastModifiedUserName}:{},(null==(f=this.campaign)?void 0:f.createDate)?{"Create Date":this.campaign.createDate}:{},S),A=A={"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(", ")},Object.getOwnPropertyDescriptors?Object.defineProperties(w,Object.getOwnPropertyDescriptors(A)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t.push.apply(t,i)}return t})(Object(A)).forEach(function(e){Object.defineProperty(w,e,Object.getOwnPropertyDescriptor(A,e))}),w}saveCampaign(e=!0,i=!1,n){return it(function*(){var l,o,s,c,p,d,m,h,g,f,y,v,b,w,A,C,E,T,x,S,O,P,N,F,B,I;this._isSaving=!0;let k=this.campaignId,V=setTimeout(()=>{var e;(null==(e=this._designView)?void 0:e.grid)&&a.setUpdateIndicator(this._designView.grid.root,!0,"Someone else is saving the campaign. Please wait...")},500);try{let e=yield this.aquireAndWaitCampaignLock(k);if(!(null==e?void 0:e.aquired))throw Error("Could not acquire lock for campaign during 30 seconds")}catch(e){return clearTimeout(V),(null==(N=this._designView)?void 0:N.grid)&&a.setUpdateIndicator(this._designView.grid.root,!1),t.shell.error("Failed to acquire campaign lock. Someone else might be editing the campaign. Please try again later."),this._isSaving=!1,this.campaign}clearTimeout(V),(null==(y=this._designView)?void 0:y.grid)&&a.setUpdateIndicator(this._designView.grid.root,!0,"Saving Campaign...");let D=this.template.name,j=this.dataFrame,_={};j.columns.toList().forEach(e=>_[e.name]=e.semType);let L={};j.columns.toList().forEach(e=>L[e.name]=e.type);let M=null!=(l=null==(v=this.campaign)?void 0:v.tilesViewerFormSketch)?l:void 0,H=null!=(o=null==(b=this.campaign)?void 0:b.authorUserId)?o:t.shell.user.id,R=null!=(s=null==(w=this.campaign)?void 0:w.permissions)?s:yield it(function*(){try{let e=yield t_(function*(){try{var e,t;let i=nh.settings,n={view:[],edit:[]};if(!i)return n;return n.view=yield tM(null!=(e=i.view)?e:""),n.edit=yield tM(null!=(t=i.edit)?t:""),n}catch(e){return console.error(e),{view:[],edit:[]}}})(),t={view:e.view.map(e=>e.id),edit:e.edit.map(e=>e.id)};return 0===t.edit.length&&(t.edit=[ta.edit["0"]]),0===t.view.length&&(t.view=[ta.view["0"]]),t}catch(e){t.shell.error("Failed to get default permissions"),console.error(e)}return ta})(),U=H?null!=(c=null==(A=this.campaign)?void 0:A.authorUserFriendlyName)?c:null==(C=yield t.dapi.users.find(H))?void 0:C.friendlyName:void 0,q={name:k,friendlyName:null!=(p=null!=(d=null==(E=this.campaign)?void 0:E.friendlyName)?d:null==n?void 0:n.friendlyName)?p:k,templateName:D,status:null!=(m=null==(T=this.campaign)?void 0:T.status)?m:"In Progress",createDate:null!=(h=null==(x=this.campaign)?void 0:x.createDate)?h:ev(new Date),campaignFields:null!=(g=null==(S=this.campaign)?void 0:S.campaignFields)?g:this.campaignProps,columnSemTypes:_,rowCount:j.rowCount,filteredRowCount:j.filter.trueCount,savePath:this._filePath,columnTypes:L,tilesViewerFormSketch:M,version:this.version+1,authorUserId:H,authorUserFriendlyName:U,lastModifiedUserName:t.shell.user.friendlyName,permissions:R,mergeConfig:null==(O=this.campaign)?void 0:O.mergeConfig};if(!this.hasEditPermission)return t.shell.error("You do not have permission to modify this campaign"),(null==(F=this._designView)?void 0:F.grid)&&a.setUpdateIndicator(this._designView.grid.root,!1),yield this.releaseCampaignLock(k),this._isSaving=!1,q;let Y=`${this.appName}/campaigns/${k}/${u}`,G=j;if(yield nh.files.exists(Y)){let e=JSON.parse((yield nh.files.readAsText(Y)));if((null!=(B=e.version)?B:0)>this.version&&(q.version=Math.max(this.version,null!=(I=e.version)?I:0)+1,yield t.dapi.files.exists(this._filePath)))try{let e=yield t.dapi.files.readCsv(this._filePath);G=this.unionDataframes(e,j,this.molColName,this.molColName)}catch(e){console.error(e)}}let W=r.DataFrame.fromColumns(G.columns.toList().filter(e=>!e.name.startsWith("~"))).toCsv();yield t.dapi.files.writeAsText(this._filePath,W);let J=this._designView.saveLayout();J?q.layout=J.viewState:t.shell.warning("Layout cound not be saved"),q.template=this.template,yield nh.saveCampaignJson(this.appName,q),e&&t.shell.info("Campaign saved successfully."),!e&&i&&t.shell.info("Campaign created successfully."),this.campaign=q,this.designViewName=null!=(f=q.friendlyName)?f:q.name;let z=yield this.releaseCampaignLock(k);return this._lastExpiresTimeString=z,(null==(P=this._designView)?void 0:P.grid)&&a.setUpdateIndicator(this._designView.grid.root,!1),this._isSaving=!1,this._refreshIconTooltip="Refresh Campaign",q}).call(this)}constructor(e,t="Hit Design",i=e=>new tb(e)){super(e,t),this._designViewName="Design",this._filePath=`System.AppData/HitTriage/${this.appName}/campaigns`,this._molColName=h,this.campaignProps={},this.existingStatuses=[],this._refreshIconTooltip="Refresh Campaign",this._updateCheckIntervalId=null,this._needsRefresh=!1,this._lastExpiresTimeString=null,this._refreshCampaignIcon=null,this._gridSubs=null,this._isSaving=!1,this._infoView=i(this),this.multiView=new r.MultiView({viewFactories:{[this._infoView.name]:()=>this._infoView}}),this.multiView.subs.push(this.multiView.tabs.onTabChanged.subscribe(e=>{this.multiView.currentView instanceof e9&&this.multiView.currentView.onActivated()})),this.multiView.parentCall=e,iE(this.multiView,this),this.mainView=this.multiView,this._initViewSubs()}}function ir(e,t,i,n,a,r,l){try{var o=e[r](l),s=o.value}catch(e){i(e);return}o.done?t(s):Promise.resolve(s).then(n,a)}function il(e){return function(){var t=this,i=arguments;return new Promise(function(n,a){var r=e.apply(t,i);function l(e){ir(r,n,a,l,o,"next",e)}function o(e){ir(r,n,a,l,o,"throw",e)}l(void 0)})}}function io(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{},n=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(i).filter(function(e){return Object.getOwnPropertyDescriptor(i,e).enumerable}))),n.forEach(function(t){var n;n=i[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}function is(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t.push.apply(t,i)}return t})(Object(t)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(t,i))}),e}let iu=new Map;function ic(e,i,n,a){let r=iu.get(e);return r||(r=t.functions.register({signature:i,run:a,isAsync:!0,namespace:"HitTriageAI",tags:"hit-ai-function",options:{description:n}}),iu.set(e,r)),r}let ip=new WeakMap;function id(e){var t,i;let n=null!=(t=null==e?void 0:e.jsView)?t:e;for(let t of[n,e,null==n?void 0:n.currentView]){if(null==t)continue;let e=ip.get(t);if(e instanceof tc)return e;if(t.app instanceof tc)return t.app;if((null==(i=t.currentView)?void 0:i.app)instanceof tc)return t.currentView.app}throw Error("The current view does not belong to a Hit Triage / Hit Design app")}function im(e){let t=id(e);if(!(t instanceof ia))throw Error("This action applies only to Hit Design / PeptiHit campaigns");return t}function ih(e){var t,i;let n=null!=(t=null==e?void 0:e.jsView)?t:e;if(n instanceof r.TableView)return n;let a=id(e),l=null!=(i=a._designView)?i:a._pickView;if(l instanceof r.TableView)return l;throw Error("No campaign table view is open")}function ig(e){var t;return io(is(io({code:e.name},e.friendlyName&&e.friendlyName!==e.name?{name:e.friendlyName}:{}),{template:e.templateName,status:null!=(t=e.status)?t:null}),e.authorUserFriendlyName?{author:e.authorUserFriendlyName}:{},e.createDate?{created:e.createDate}:{},null!=e.rowCount?{rows:e.rowCount}:{})}function iy(e){var t,i,n,a;let r=null==e?void 0:e.compute;return r?{descriptors:(null==(a=r.descriptors)?void 0:a.enabled)?r.descriptors.args:[],functions:(null!=(t=r.functions)?t:[]).map(e=>`${e.package}:${e.name}`),scripts:(null!=(i=r.scripts)?i:[]).map(e=>e.name),queries:(null!=(n=r.queries)?n:[]).map(e=>e.name)}:null}function iv(e){return il(function*(){return!e.authorUserId||!e.permissions||(yield eT(e.authorUserId,e.permissions))})()}function ib(e,t){return il(function*(){var i,n;let a=yield nh.loadCampaigns(e.appName,[]);return null!=(i=null!=(n=a[t])?n:Object.values(a).find(e=>{var i;return(null!=(i=e.friendlyName)?i:"").toLowerCase()===t.toLowerCase()}))?i:null})()}function iw(e){return il(function*(){return(yield nh.files.list(`${e}/templates`)).filter(e=>e.name.endsWith(".json")).map(e=>e.name.slice(0,-5))})()}function iA(){return[ic("getHitCampaignState","dynamic getHitCampaignState(view view)","State of the open campaign - name, template, status, molecule column, stages, columns, row counts, edit permission, submit function. Call this first. The molecule data itself lives in the attached table",e=>il(function*(){var t,i,n,a,r;let l=id(e),o=l.dataFrame,s=l instanceof ia?l.stages:[];return is(io(is(io({app:l.appName,campaign:l.campaign?ig(l.campaign):null},l.campaignId?{code:l.campaignId}:{}),{moleculeColumn:null!=(t=l.molColName)?t:null}),l.helmColName?{sequenceColumn:l.helmColName}:{},s.length?{stages:s}:{}),{rows:null!=(i=null==o?void 0:o.rowCount)?i:0,filteredRows:null!=(n=null==o?void 0:o.filter.trueCount)?n:0,columns:o?o.columns.toList().filter(e=>!e.name.startsWith("~")).map(e=>io({name:e.name,type:e.type},e.semType?{semType:e.semType}:{})):[],canEdit:l.canEdit,submitFunction:l.submitParams?`${l.submitParams.package}:${l.submitParams.fName}`:null,compute:iy(null!=(a=null==(r=l.campaign)?void 0:r.template)?a:l.template)})})()),ic("saveHitCampaign","dynamic saveHitCampaign(view view)","Save the open campaign - its table, layout and metadata",e=>il(function*(){var t,i;let n=id(e);return n.canEdit?(yield n.saveCampaign(),{success:!0,campaign:null!=(t=n.campaignId)?t:null==(i=n.campaign)?void 0:i.name}):{success:!1,error:"You do not have permission to modify this campaign"}})()),ic("setHitCampaignStatus","dynamic setHitCampaignStatus(view view, string status)","Set the status of the open campaign (free text, e.g. In Progress, Approved) and save it",(e,t)=>il(function*(){let i=id(e);return(null==t?void 0:t.trim())?i.campaign?i.canEdit?(i.campaign.status=t.trim(),yield i.saveCampaign(),{success:!0,status:i.campaign.status}):{success:!1,error:"You do not have permission to modify this campaign"}:{success:!1,error:"No campaign is open"}:{success:!1,error:"status is required"}})()),ic("submitHitCampaign","dynamic submitHitCampaign(view view, string status)","Submit the campaign molecules to the configured submit function and save. status is optional and applies to Hit Design campaigns (Hit Triage submits always set the status to Submitted). ALWAYS confirm with the user first",(e,t)=>il(function*(){let i=id(e);if(!i.canEdit)return{success:!1,error:"You do not have permission to modify this campaign"};if(!i.submitParams)return{success:!1,error:"No submit function is configured for this campaign template"};let n=i.submitView;return n?(n.submitWithStatus?yield n.submitWithStatus(null!=t?t:void 0):yield n.submit())?{success:!0,submittedTo:`${i.submitParams.package}:${i.submitParams.fName}`}:{success:!1,error:"The configured submit function could not be run"}:{success:!1,error:"The campaign is not fully open yet"}})()),ic("searchHitTableFunctions","dynamic searchHitTableFunctions(view view, string query, int limit)","Search the standard table view functions (hundreds of data commands - add columns, aggregate, select rows, viewers). ALWAYS pass a query. Invoke matches with callHitTableFunction",(e,t,i)=>il(function*(){let n=ih(e),a=r.View.prototype.getFunctions.call(n),l=(null!=t?t:"").toLowerCase().split(/\s+/).filter(e=>e.length>0),o=a.map(e=>({f:e,s:(e=>{if(!l.length)return 1;let t=[e.name,e.friendlyName,e.description].filter(Boolean).join(" ").toLowerCase();return l.filter(e=>t.includes(e)).length})(e)})).filter(e=>e.s>0).sort((e,t)=>t.s-e.s).map(e=>e.f),s=i&&i>0?i:10;return io({total:o.length,functions:o.slice(0,s).map(e=>({name:e.name,description:e.description||e.friendlyName||e.name,inputs:e.inputs.filter(e=>"view"!==e.name&&"view"!==e.propertyType).map(e=>({name:e.name,type:e.propertyType}))}))},o.length>s?{note:`Showing ${s} of ${o.length} — refine the query`}:{})})()),ic("callHitTableFunction","dynamic callHitTableFunction(view view, string name, map parameters)","Invoke a standard table view function by name (from searchHitTableFunctions) with parameters keyed by input name",(e,t,i)=>il(function*(){var n;let a=ih(e),l=r.View.prototype.getFunctions.call(a),o=null!=(n=l.find(e=>e.name===t))?n:l.find(e=>e.name.toLowerCase()===(null!=t?t:"").toLowerCase());if(!o)return{success:!1,error:`No table function '${t}' — call searchHitTableFunctions to find it`};let s=io({},null!=i?i:{});for(let e of o.inputs)e.name in s||"view"!==e.name&&"view"!==e.propertyType||(s[e.name]=a);let u=yield o.apply(s);return io({success:!0},null!=u?{result:function(e){if(null==e||"string"==typeof e||"number"==typeof e||"boolean"==typeof e)return e;if(e instanceof r.DataFrame)return{type:"dataframe",name:e.name,rowCount:e.rowCount,columns:e.columns.names()};if(e instanceof r.Column)return{type:"column",name:e.name,length:e.length};if(e instanceof r.ViewBase)return{type:"view",name:e.name};try{return JSON.parse(JSON.stringify(e))}catch(t){return String(e)}}(u)}:{})})())]}function iC(e){return`${e} — the landing page of a molecule campaign app where teams ${"Hit Design"===e||"PeptiHit"===e?"design molecules in a spreadsheet, calculate properties, and track progress through stages":"ingest a molecule dataset, calculate properties, and filter it down to the hits"}. Act on it through the view functions (search list_view_functions with "hit"): getHitAppInfo (call first), listHitCampaigns / getHitCampaignDetails / openHitCampaign to browse and continue campaigns, listHitTemplates / getHitTemplateDetails for the templates, createHitCampaign / deleteHitCampaign to manage them (confirm deletions with the user first).`}function iE(e,t){ip.set(e,t),e.aiDescription=iC(t.appName),e.getFunctions=()=>[ic("getHitAppInfo","dynamic getHitAppInfo(view view)","Overview of this Hit app - its name, saved campaign and template counts, the campaign currently open. Call this first",e=>il(function*(){var t,i,n;let a=id(e),r=yield nh.loadCampaigns(a.appName,[]);return{app:a.appName,campaigns:Object.keys(r).length,templates:yield iw(a.appName),currentCampaign:null!=(t=null!=(i=a.campaignId)?i:null==(n=a.campaign)?void 0:n.name)?t:null,canCreateCampaignsHere:a instanceof ia}})()),ic("listHitCampaigns","dynamic listHitCampaigns(view view)","List the saved campaigns of this Hit app with code, name, template, status, author and row count. Campaigns are addressed by code",e=>il(function*(){let t=id(e),i=Object.values((yield nh.loadCampaigns(t.appName,[])));return{total:i.length,campaigns:i.map(ig)}})()),ic("getHitCampaignDetails","dynamic getHitCampaignDetails(view view, string campaignCode)","Full detail of one saved campaign - fields, row counts, compute methods, stages, whether the current user can edit it",(e,t)=>il(function*(){var i,n;let a=id(e),r=yield ib(a,t);return r?is(io({},ig(r),r.campaignFields&&Object.keys(r.campaignFields).length?{campaignFields:r.campaignFields}:{},null!=r.filteredRowCount?{filteredRows:r.filteredRowCount}:{},r.lastModifiedUserName?{lastModifiedBy:r.lastModifiedUserName}:{},(null==(n=r.template)||null==(i=n.stages)?void 0:i.length)?{stages:r.template.stages}:{}),{compute:iy(r.template),canEdit:yield iv(r)}):{success:!1,error:`No campaign '${t}' — call listHitCampaigns for codes`}})()),ic("openHitCampaign","dynamic openHitCampaign(view view, string campaignCode)","Open a saved campaign so the user can work on it - loads its table and shows the campaign view",(e,t)=>il(function*(){let i=id(e),n=yield ib(i,t);return n?(yield i.infoView.setCampaign(n.name),i.campaignId!==n.name)?{success:!1,error:"Failed to open the campaign — you may not have permission to view it"}:{success:!0,campaign:n.name,note:"The campaign view is now open"}:{success:!1,error:`No campaign '${t}' — call listHitCampaigns for codes`}})()),ic("listHitTemplates","dynamic listHitTemplates(view view)","List the campaign template names of this Hit app",e=>il(function*(){return{templates:yield iw(id(e).appName)}})()),ic("getHitTemplateDetails","dynamic getHitTemplateDetails(view view, string templateName)","Full detail of one campaign template - its campaign fields, stages, compute methods, data source and submit function",(e,t)=>il(function*(){var i,n;let a=id(e),r=`${a.appName}/templates/${t}.json`;if(!(yield nh.files.exists(r)))return{success:!1,error:`No template '${t}' — call listHitTemplates for names`};let l=yield e_(r);return io(is(io({name:l.name,key:l.key,campaignFields:(null!=(i=l.campaignFields)?i:[]).map(e=>({name:e.name,type:e.type,required:!!e.required}))},(null==(n=l.stages)?void 0:n.length)?{stages:l.stages}:{},l.dataSourceType?{dataSourceType:l.dataSourceType}:{},l.queryFunctionName?{dataSourceFunction:l.queryFunctionName}:{}),{compute:iy(l)}),l.submit?{submitFunction:`${l.submit.package}:${l.submit.fName}`}:{})})()),ic("createHitCampaign","dynamic createHitCampaign(view view, string templateName, string campaignName, map campaignFields)","Create a new campaign from a template and open it. Hit Design and PeptiHit only. campaignName and campaignFields are optional, but fields the template marks required must be provided",(e,t,i,n)=>il(function*(){var a;let r=im(e),l=`${r.appName}/templates/${t}.json`;if(!(yield nh.files.exists(l)))return{success:!1,error:`No template '${t}' — call listHitTemplates for names`};let o=yield e_(l),s=(null!=(a=o.campaignFields)?a:[]).filter(e=>e.required&&((null==n?void 0:n[e.name])==null||""===n[e.name])).map(e=>e.name);if(s.length)return{success:!1,error:`Missing required campaign fields: ${s.join(", ")} — pass them in campaignFields`};r.clearCampaign(),r.dataFrame=td(o,"PeptiHit"===r.appName),yield r.setTemplate(o),r.campaignProps=io({},null!=n?n:{});let u=(null==i?void 0:i.trim())?i.trim():void 0;return yield r.saveCampaign(!1,!0,{friendlyName:u}),o.layoutViewState&&r.campaign&&(r.campaign.layout=o.layoutViewState),{success:!0,campaign:r.campaignId,note:"The campaign is created and its design view is open"}})()),ic("deleteHitCampaign","dynamic deleteHitCampaign(view view, string campaignCode)","Permanently delete a saved campaign. ALWAYS confirm with the user first",(e,t)=>il(function*(){let i=id(e),n=yield ib(i,t);return n?(yield iv(n))?(yield i.infoView.deleteCampaignAndRefresh(i.appName,n.name),{success:!0,deleted:n.name}):{success:!1,error:"You do not have permission to delete this campaign"}:{success:!1,error:`No campaign '${t}' — call listHitCampaigns for codes`}})())]}function iT(e,t,i){var n;ip.set(e,t),n=t.appName,e.aiDescription=`An open ${n} campaign — a molecule spreadsheet for ${"design"===i?"sketching and editing molecules in the grid. Hit-specific functions: getHitCampaignState (call first), setHitMolecule / setHitStage / setHitStages / recalculateHitRow to edit, saveHitCampaign / setHitCampaignStatus / submitHitCampaign to persist":"filtering the enriched molecule table down to the hits. Hit-specific functions: getHitCampaignState (call first), saveHitCampaign / setHitCampaignStatus / submitHitCampaign"}. The underlying table view also has hundreds of standard data commands — find them with searchHitTableFunctions (always pass a query) and run them with callHitTableFunction. The data itself lives in the attached table.`,e.getFunctions=()=>"design"===i?[...iA(),ic("setHitMolecule","dynamic setHitMolecule(view view, string molecule, int row)","Set the molecule of a row (SMILES or molblock, HELM for PeptiHit). Omit row to add a new row. Registers the V-iD and runs the configured property calculations",(e,t,i)=>il(function*(){var n,a,r,l;let o=im(e);if(!o.canEdit)return{success:!1,error:"You do not have permission to modify this campaign"};if(!(null==t?void 0:t.trim()))return{success:!1,error:"molecule is required"};let s=o.dataFrame;if(!s)return{success:!1,error:"No campaign table is open"};let u=o.helmColName,c=u?s.col(u):s.col(o.molColName);if(!c)return{success:!1,error:"The molecule column was not found"};let p=null!=i?i:null;if(null==p)s.rows.addNew(null,!0),p=s.rowCount-1;else if(p<0||p>=s.rowCount)return{success:!1,error:`row must be between 0 and ${s.rowCount-1}`};if(c.set(p,t,!0),u){yield o.performSingleCellCalculations(p,t);let e=null==(a=s.col(o.molColName))?void 0:a.get(p);if(e)try{let t=yield tY(e,o.campaignId,o.appName);t&&(null==(r=s.col(f))||r.set(p,t,!0))}catch(e){console.error("Failed to register molecule",e)}}else{try{let e=yield tY(t,o.campaignId,o.appName);e&&(null==(l=s.col(f))||l.set(p,e,!0))}catch(e){console.error("Failed to register molecule",e)}yield o.performSingleCellCalculations(p,t)}return io({success:!0,row:p},(null==(n=s.col(f))?void 0:n.get(p))?{vId:s.col(f).get(p)}:{})})()),ic("setHitStage","dynamic setHitStage(view view, int row, string stage)","Move a row to another stage of the campaign progress tracker and save",(e,t,i)=>il(function*(){let n=im(e);if(!n.canEdit)return{success:!1,error:"You do not have permission to modify this campaign"};let a=n.dataFrame,r=null==a?void 0:a.col(m);return a&&r?null==t||t<0||t>=a.rowCount?{success:!1,error:`row must be between 0 and ${a.rowCount-1}`}:n.stages.includes(i)?(r.set(t,i,!0),yield n.saveCampaign(!1),{success:!0,row:t,stage:i}):{success:!1,error:`Unknown stage '${i}' — the stages are: ${n.stages.join(", ")}`}:{success:!1,error:"This campaign has no stage column"}})()),ic("setHitStages","dynamic setHitStages(view view, list stages)","Replace the stage list of the campaign progress tracker. Rows in a removed stage move to the first stage. Saves the campaign",(e,t)=>il(function*(){var i,n;let a=im(e);return a.canEdit?!Array.isArray(t)||!t.length||t.some(e=>"string"!=typeof e||!e.trim())?{success:!1,error:"Pass stages as a non-empty list of names"}:(null==(i=a.campaign)?void 0:i.template)&&a.template?(null==(n=a.dataFrame)?void 0:n.col(m))?(yield a.setStages(t.map(e=>e.trim())),{success:!0,stages:a.stages}):{success:!1,error:"This campaign has no stage column"}:{success:!1,error:"No campaign is open"}:{success:!1,error:"You do not have permission to modify this campaign"}})()),ic("recalculateHitRow","dynamic recalculateHitRow(view view, int row)","Re-run the configured property calculations for one row of the campaign",(e,t)=>il(function*(){var i;let n=im(e),a=n.dataFrame;if(!a)return{success:!1,error:"No campaign table is open"};if(null==t||t<0||t>=a.rowCount)return{success:!1,error:`row must be between 0 and ${a.rowCount-1}`};let r=n.helmColName,l=null==(i=r?a.col(r):a.col(n.molColName))?void 0:i.get(t);return l?(yield n.performSingleCellCalculations(t,l),{success:!0,row:t}):{success:!1,error:"The row has no molecule to calculate from"}})())]:iA()}function ix(e,t,i,n,a,r,l){try{var o=e[r](l),s=o.value}catch(e){i(e);return}o.done?t(s):Promise.resolve(s).then(n,a)}function iS(e){return function(){var t=this,i=arguments;return new Promise(function(n,a){var r=e.apply(t,i);function l(e){ix(r,n,a,l,o,"next",e)}function o(e){ix(r,n,a,l,o,"throw",e)}l(void 0)})}}class iO extends e9{onActivated(){t.shell.windows.showHelp=!0,t.shell.windows.help.showHelp(this.readmePath)}refreshCampaignsTable(){return iS(function*(){if(null!=this.campaignsTableRoot){a.setUpdateIndicator(this.campaignsTableRoot,!0);try{let e=yield this.getCampaignsTable();a.setUpdateIndicator(this.campaignsTableRoot,!1),a.empty(this.campaignsTableRoot),this.campaignsTableRoot.appendChild(e)}catch(e){t.shell.error("Failed to update campaigns table"),console.error(e)}finally{a.setUpdateIndicator(this.campaignsTableRoot,!1)}}}).call(this)}getAppHeader(){return D.appHeader({iconPath:nh.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 "})}getTemplatesFolder(){return`${this.app.appName}/templates`}getDataSourceTag(){return c}getDataSourceFunctionsMap(){return this.dataSourceFunctionsMap}init(e){return iS(function*(){a.setUpdateIndicator(this.root,!0);try{let t=a.h1(T),i=a.h1(x,{style:{marginLeft:"10px"}}),n=a.div(),l=a.div([],{classes:"ui-form"}),o=yield this.getCampaignsTable();this.campaignsTableRoot=a.div([o],{style:{position:"relative"}});let s=a.iconFA("layer-group",()=>iS(function*(){let e=r.Menu.popup();Object.values(L).forEach(t=>{e.item(t,()=>iS(function*(){eO(H,t),yield this.refreshCampaignsTable()}).call(this))});let t=e.group("Campaign Fields"),i=yield nh.loadCampaigns(this.app.appName,this.deletedCampaigns),n=new Set;Object.values(i).forEach(e=>{e.campaignFields&&Object.keys(e.campaignFields).forEach(e=>n.add(e))}),Array.from(n).forEach(e=>{t.item(e,()=>iS(function*(){var t;t=`campaignFields.${e}`,eO(H,t),yield this.refreshCampaignsTable()}).call(this))}),e.show({element:p,x:120,y:p.offsetTop+30})}).call(this),"Group by");s.style.marginBottom="9px",s.style.marginLeft="8px",s.style.fontSize="15px",s.style.color="var(--blue-1)",a.tooltip.bind(s,()=>`Group Campaigns. Current: ${this.currentGroupping}`);let u=a.iconFA("eye",()=>iS(function*(){let e=r.Menu.popup(),t=yield nh.loadCampaigns(this.app.appName,this.deletedCampaigns),i=function(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{},n=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(i).filter(function(e){return Object.getOwnPropertyDescriptor(i,e).enumerable}))),n.forEach(function(t){var n;n=i[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({},q);delete i.Name,Object.values(t).forEach(e=>{e.campaignFields&&Object.keys(e.campaignFields).forEach(e=>{i[`campaignFields.${e}`]=t=>{var i,n;return null!=(i=null==(n=t.campaignFields)?void 0:n[e])?i:""}})});let n=eB().reduce((e,t)=>(e[t]=!0,e),{});Object.keys(i).filter(e=>!e.startsWith("campaignFields.")).forEach(t=>{var i;e.item(t,()=>{n[t]=!n[t],eI(Object.keys(n).filter(e=>n[e])),this.refreshCampaignsTable()},null,{check:null!=(i=n[t])&&i})});let a=e.group("Campaign Fields");Object.keys(i).filter(e=>e.startsWith("campaignFields.")).forEach(e=>{var t;a.item(e.replace("campaignFields.",""),()=>{n[e]=!n[e],eI(Object.keys(n).filter(e=>n[e])),this.refreshCampaignsTable()},null,{check:null!=(t=n[e])&&t})}),e.show({element:p,x:100,y:p.offsetTop+30})}).call(this),"View");a.tooltip.bind(u,"Edit visible columns in campaigns table"),u.style.marginBottom="9px",u.style.marginLeft="8px",u.style.fontSize="15px",u.style.color="var(--blue-1)";let c=a.iconFA("sync",()=>iS(function*(){yield this.refreshCampaignsTable()}).call(this),"Refresh");c.style.marginBottom="9px",c.style.marginLeft="8px",c.style.color="var(--blue-1)",a.tooltip.bind(c,()=>"Refresh campaigns table");let p=a.divH([t,u,s,c],{style:{alignItems:"center"}});yield this.startNewCampaign(n,l,e),eq()(this._contentRoot).empty(),this._contentRoot.appendChild(a.divV([p],{style:{marginLeft:"10px"}})),this._contentRoot.appendChild(this.campaignsTableRoot),this._contentRoot.appendChild(i),this._contentRoot.appendChild(l),this._contentRoot.appendChild(n)}catch(e){throw a.setUpdateIndicator(this.root,!1),e}finally{a.setUpdateIndicator(this.root,!1)}}).call(this)}startNewCampaign(e,i,n){return iS(function*(){var r;let l=(yield nh.files.list(this.getTemplatesFolder())).filter(e=>e.name.endsWith(".json")).map(e=>e.name.slice(0,-5));n&&!l.includes(n.name)&&l.push(n.name);let o=null,s=!0,u=()=>iS(function*(){if(!s)return;let t=c.value,i=n&&n.name===t?n:yield e_(this.getTemplatesFolder()+"/"+t+".json");o=i;let a=yield this.getNewCampaignAccordeon(i,e);eq()(e).empty(),e.className="ui-form",e.appendChild(a)}).call(this),c=a.input.choice("Template",{value:null!=(r=null==n?void 0:n.name)?r:l[0],items:l,onValueChanged:()=>iS(function*(){yield u()})()});c.root.style.width="100%";let p=a.icons.add(()=>iS(function*(){a.setUpdateIndicator(this.root,!0),yield this.createNewTemplate(),a.setUpdateIndicator(this.root,!1)}).call(this),b),d=a.icons.copy(()=>{o&&this.createNewTemplate(o)},"Clone template"),m=a.icons.delete(()=>{c.value&&!(c.items.length<2)&&a.dialog("Delete template").add(a.divText(`Are you sure you want to delete template ${c.value}?`)).onOK(()=>iS(function*(){try{let e=c.value;yield nh.files.delete(`${this.getTemplatesFolder()}/${e}.json`),s=!1,c.items=c.items.filter(t=>t!==e),c.value=c.items[0],s=!0,yield u(),t.shell.info("Template "+e+" was deleted successfully")}catch(e){s=!0,t.shell.error("Failed to delete template "+c.value),console.error(e)}}).call(this)).show()},"Delete template");m.style.color="var(--blue-1)",p.style.color="#2083d5",c.addOptions(p),c.addOptions(d),c.addOptions(m),yield u(),eq()(i).empty(),i.appendChild(c.root)}).call(this)}checkCampaign(e){return iS(function*(){let t=new URLSearchParams(location.search);if(!t.has(l)&&!e)return;let i=null!=e?e:t.get(l);if(!(yield nh.files.exists(`${this.app.appName}/campaigns/${i}/${u}`)))return;let n=JSON.parse((yield nh.files.readAsText(`${this.app.appName}/campaigns/${i}/${u}`)));if(n){if(n.authorUserId&&n.permissions&&!(yield ex(n.authorUserId,n.permissions)))return void this.app.setBaseUrl();this.app.campaign=n}let a=yield e_(`${this.getTemplatesFolder()}/${n.templateName}.json`);return this.app.setTemplate(a,n.filters,i,n.ingest),e&&eb(l,e),n}).call(this)}getCampaignsTable(){return iS(function*(){var e;let i,n=yield nh.loadCampaigns(this.app.appName,this.deletedCampaigns),l=null!=(e=eS(H))?e:L.None,o=(i=eS(U))?JSON.parse(i):null,s=Object.values(n);o&&eP(s,o,q);let u=eV(s,l),c=eB();this.currentGroupping=l;let p=e=>{var i,n;let l=a.icons.delete(()=>iS(function*(){var t;a.dialog("Delete campaign").add(a.divText(`Are you sure you want to delete campaign ${null!=(t=e.friendlyName)?t:e.name}?`)).onOK(()=>iS(function*(){yield this.deleteCampaignAndRefresh(this.app.appName,e.name)}).call(this)).show()}).call(this),"Delete campaign"),o=a.iconFA("share",()=>iS(function*(){yield new tr(e.permissions).show(i=>iS(function*(){var n,a;try{e.permissions=i,null!=e.authorUserId||(e.authorUserId=t.shell.user.id),yield nh.saveCampaignJson(this.app.appName,e),t.shell.info("Permissions updated for campaign "+(null!=(n=e.friendlyName)?n:e.name))}catch(i){t.shell.error("Failed to update permissions for campaign "+(null!=(a=e.friendlyName)?a:e.name)),console.error(i)}}).call(this))}).call(this),"Manage campaign permissions");return l.style.display="none",o.style.display="none",eT(null!=(i=e.authorUserId)?i:r.User.current().id,null!=(n=e.permissions)?n:ta).then(e=>{e&&(l.style.display="inline-block",o.style.display="inline-block")}),l.style.color="var(--blue-1)",o.style.color="var(--blue-1)",[o,l]},d=Object.values(u).flat(),m=a.table(d,e=>{var t;return[a.link(null!=(t=e.friendlyName)?t:e.name,()=>this.setCampaign(e.name),"Continue Campaign",""),...c.map(t=>{var i,n,a,r;return t.startsWith("campaignFields.")?null!=(i=null==(a=e.campaignFields)?void 0:a[t.replace("campaignFields.","")])?i:"":null!=(n=null==(r=q[t])?void 0:r.call(q,e))?n:""}),...p(e)]},["Name",...c.map(e=>e.replace("campaignFields.","")),"",""]);return m.style.color="var(--grey-5)",m.style.marginLeft="24px",m.querySelectorAll("tr.header > td").forEach((e,t)=>{if(!e.textContent)return;let i=0===t?"Name":c[t-1];if(o&&i===o.columnName){let t=o.ascending?"↑":"↓";e.appendChild(a.span([t],{style:{fontSize:"12px",marginLeft:"2px"}}))}e.addEventListener("dblclick",()=>{var e;let t={columnName:i,ascending:!0};o&&i===o.columnName&&(t=o.ascending?{columnName:i,ascending:!1}:null),(e=t)?eO(U,JSON.stringify(e)):localStorage.removeItem(U),this.refreshCampaignsTable()})}),eD(m,u),m}).call(this)}setCampaign(e){return iS(function*(){let t=yield this.checkCampaign(e);this.app.campaign=t}).call(this)}getNewCampaignAccordeon(e,t){return iS(function*(){a.setUpdateIndicator(t,!0);let{root:i,promise:n,cancelPromise:r}=yield eR(e,this.getDataSourceFunctionsMap(),this.getDataSourceTag());return a.setUpdateIndicator(t,!1),n.then(t=>iS(function*(){this.app.dataFrame=t.df,this.app._fileInputType=t.type,yield this.app.setTemplate(e,void 0,void 0,void 0,t.friendlyName),this.app.campaignProps=t.campaignProps,yield this.app.saveCampaign(void 0,!1),e.layoutViewState&&this.app.campaign&&(this.app.campaign.layout=e.layoutViewState)}).call(this)),r.then(()=>{this.init()}),i}).call(this)}createNewTemplate(e){return iS(function*(){var i,n;let l=yield(i=this.app,n=this.getDataSourceFunctionsMap(),e5(function*(){var l,o,s;let u=(yield nh.files.list("Hit Triage/templates")).map(e=>e.name.slice(0,-5)),d=[];for(let e of u){let t=yield e_(`Hit Triage/templates/${e}.json`);d.push(t.key)}let m=Array.from(new Set(r.Func.find({meta:{role:p}}).concat(r.Func.find({tags:[p]})))),h={};m.forEach(e=>{var t;h[null!=(t=e.friendlyName)?t:e.name]=e});let g=(null==e?void 0:e.submit)?Object.keys(h).find(t=>{var i,n;return(null==(i=h[t])?void 0:i.name)===(null==(n=e.submit)?void 0:n.fName)}):null,f=a.input.choice("Submit function",{value:null!=g?g:null,items:[null,...Object.keys(h)]});g||(f.value=null),f.nullable=!0,f.fireChanged(),f.setTooltip("Select function to be called upon submitting");let y=e2(),b=a.divText("Template name is empty or already exists",{classes:"hit-triage-error-div"}),w=a.divText("Template key is empty or already exists",{classes:"hit-triage-error-div"}),C=a.input.string("Name",{value:e?`${e.name} (copy)`:"",onValueChanged:e=>{""===e||u.includes(e)?(C.root.style.borderBottom="1px solid red",b.style.opacity="100%"):(C.root.style.borderBottom="none",b.style.opacity="0%")}}),T=a.input.string("Key",{value:e?`${e.key}-copy`:"",onValueChanged:e=>{""===e||d.includes(e)?(T.root.style.borderBottom="1px solid red",w.style.opacity="100%"):(T.root.style.borderBottom="none",w.style.opacity="0%")}});T.setTooltip("Template key used for campaign prefix"),C.setTooltip("Template name"),C.root.style.borderBottom="none",T.root.style.borderBottom="none",b.style.opacity="0%",w.style.opacity="0%";let x=null,S=e||{compute:{descriptors:{enabled:!0,args:[]},functions:[]}},O=yield eZ(i,e=>{x=e},()=>null,S,!1);O.root.classList.add("hit-triage-new-template-functions-input"),0===Object.entries(n).length&&Array.from(new Set(r.Func.find({meta:{role:c}}).concat(r.Func.find({tags:[c]})))).forEach(e=>{var t;n[null!=(t=e.friendlyName)?t:e.name]=e});let P=Object.keys(n),N=a.input.choice(v,{value:P[0],items:P}),F=a.input.choice("Ingest using",{value:null!=(l=null==e?void 0:e.dataSourceType)?l:"Query",items:["Query","File"],onValueChanged:e=>{N.root.style.display="Query"===e?"block":"none"}});(null==e?void 0:e.dataSourceType)&&(N.root.style.display="Query"===e.dataSourceType?"block":"none");let B=e3(null==e?void 0:e.campaignFields),I=a.div([a.h2("Details"),a.div([C,b]),a.div([T,w]),F.root,N.root,y.dataFileInput,B.fieldsDiv,a.h2("Compute"),O.root,a.h2("Submit"),f.root],"ui-form"),k=a.buttonsInput([]),V=null!=(o=null==(s=k.getElementsByClassName("ui-input-editor"))?void 0:s[0])?o:k;I.appendChild(k);let D=new Promise(e=>{let t=a.button(E,()=>e());V.appendChild(t)});return{root:I,template:new Promise(e=>{let i=a.bigButton(A,()=>e5(function*(){var i,n,a,r,l,o,s,u,c,p,d;if(O.okProxy(),"100%"===b.style.opacity)return void t.shell.error("Template name is empty or already exists");let m=f.value?h[f.value]:void 0,g=(c=function(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{},n=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(i).filter(function(e){return Object.getOwnPropertyDescriptor(i,e).enumerable}))),n.forEach(function(t){var n;n=i[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({name:C.value,key:T.value,campaignFields:B.getFields(),dataSourceType:null!=(i=F.value)?i:"Query",layoutViewState:null!=(n=y.getLayoutViewState())?n:void 0,compute:{descriptors:{enabled:!!(null==x||null==(u=x.descriptors)?void 0:u.length),args:null!=(a=null==x?void 0:x.descriptors)?a:[]},functions:Object.entries(null!=(r=null==x?void 0:x.externals)?r:{}).map(([e,t])=>{let i=e.split(":");return{name:i[1],package:i[0],args:t}}),scripts:Object.entries(null!=(l=null==x?void 0:x.scripts)?l:{}).filter(([e,t])=>e.startsWith(eu)&&3===e.split(":").length).map(([e,t])=>{var i,n;let a=e.split(":");return{name:null!=(i=a[1])?i:"",id:null!=(n=a[2])?n:"",args:t}}),queries:Object.entries(null!=(o=null==x?void 0:x.queries)?o:{}).filter(([e,t])=>e.startsWith(ec)&&3===e.split(":").length).map(([e,t])=>{var i,n;let a=e.split(":");return{name:null!=(i=a[1])?i:"",id:null!=(n=a[2])?n:"",args:t}})}},m?{submit:{fName:m.name,package:eh(m)}}:{}),p=p={queryFunctionName:"Query"===F.value&&null!=(s=N.value)?s:void 0},Object.getOwnPropertyDescriptors?Object.defineProperties(c,Object.getOwnPropertyDescriptors(p)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t.push.apply(t,i)}return t})(Object(p)).forEach(function(e){Object.defineProperty(c,e,Object.getOwnPropertyDescriptor(p,e))}),c);d=g,nh.files.writeAsText(`Hit Triage/templates/${d.name}.json`,JSON.stringify(d)),t.shell.info("Template created successfully"),e(g)})());V.appendChild(i)}),cancelPromise:D}})()),o=new r.ViewBase,s=t.shell.v;o.name="New Template",o.root.appendChild(l.root),o.parentCall=this.app.parentCall,t.shell.addView(o),o.path=new URL(this.app.baseUrl).pathname+"/new-template",o.parentView=s;let{sub:u}=ew(t.shell.v,this.app.appName,b,()=>{t.shell.v=s,o.close()});l.template.then(e=>iS(function*(){yield this.init(e),o.close(),eA(o),t.shell.v=s,u.unsubscribe()}).call(this)),l.cancelPromise.then(()=>{u.unsubscribe(),o.close(),t.shell.v=s})}).call(this)}constructor(e){super(e),this.readmePath=nh.webRoot+"README_HT.md",this.dataSourceFunctionsMap={},this.currentGroupping="None",this._appHeader=null,this._contentRoot=a.div([],{classes:"hit-triage-info-view-container"}),this.campaignsTableRoot=null,this.name="Hit Triage",this.aiDescription=iC(e.appName),this._appHeader=this.getAppHeader(),this.root.appendChild(a.div([this._appHeader],{style:{marginLeft:"10px"}})),this.root.appendChild(this._contentRoot),t.shell.windows.showHelp=!0,t.shell.windows.help.showHelp(this.readmePath),this.checkCampaign().then(e=>{this.app.campaign=e,this.init()})}}function iP(e,t,i,n,a,r,l){try{var o=e[r](l),s=o.value}catch(e){i(e);return}o.done?t(s):Promise.resolve(s).then(n,a)}class iN extends e9{render(){return a.empty(this.root),a.divV([a.h1("Summary"),a.div([a.tableFromMap(this.app.getSummary())])])}onActivated(){this.render()}submit(){var e;return(e=function*(){let e=this.app.submitParams;if(!e)return!1;let i=r.Func.find({name:e.fName,package:e.package})[0];if(!i)return t.shell.error(`Function ${e.fName} not found.`),!1;let n=r.DataFrame.fromCsv(this.app.dataFrame.toCsv({filteredRowsOnly:!0}));return yield i.apply({df:n,molecules:this.app.molColName}),this.app.campaign&&(this.app.campaign.status="Submitted"),yield this.app.saveCampaign("Submitted"),t.shell.info("Submitted successfully."),!0},function(){var t=this,i=arguments;return new Promise(function(n,a){var r=e.apply(t,i);function l(e){iP(r,n,a,l,o,"next",e)}function o(e){iP(r,n,a,l,o,"throw",e)}l(void 0)})}).call(this)}constructor(e){super(e),this.name="Submit"}}function iF(e,t,i,n,a,r,l){try{var o=e[r](l),s=o.value}catch(e){i(e);return}o.done?t(s):Promise.resolve(s).then(n,a)}function iB(e){return function(){var t=this,i=arguments;return new Promise(function(n,a){var r=e.apply(t,i);function l(e){iF(r,n,a,l,o,"next",e)}function o(e){iF(r,n,a,l,o,"throw",e)}l(void 0)})}}function iI(e,t,i,n,a,r,l){try{var o=e[r](l),s=o.value}catch(e){i(e);return}o.done?t(s):Promise.resolve(s).then(n,a)}function ik(e){return function(){var t=this,i=arguments;return new Promise(function(n,a){var r=e.apply(t,i);function l(e){iI(r,n,a,l,o,"next",e)}function o(e){iI(r,n,a,l,o,"throw",e)}l(void 0)})}}function iV(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{},n=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(i).filter(function(e){return Object.getOwnPropertyDescriptor(i,e).enumerable}))),n.forEach(function(t){var n;n=i[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}function iD(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t.push.apply(t,i)}return t})(Object(t)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(t,i))}),e}class ij extends tc{get infoView(){return this._infoView}get submitView(){return this._submitView}get submitParams(){var e,t,i,n;return null!=(e=null==(i=this.campaign)||null==(t=i.template)?void 0:t.submit)?e:null==(n=this.template)?void 0:n.submit}prepareDataFrame(e){return ik(function*(){})()}setTemplate(e,i,n,a,o){return ik(function*(){var s,u,c,p,d,m,h,g,f,y,v,b,w,A,C,E,T,x,S,O;if(this._friendlyName=null!=o?o:null==(v=this._campaign)?void 0:v.friendlyName,(null==(b=this._pickView)?void 0:b.dataFrame)&&t.shell.closeTable(null==(w=this._pickView)?void 0:w.dataFrame),this._pickView=void 0,n?a&&(this._fileInputType=a.type,"File"===a.type?this.dataFrame=yield t.dapi.files.readCsv(a.query):this.dataFrame=yield t.functions.call(a.query)):eb(l,n=yield this.getNewCampaignName(`${this.appName}/campaigns`,e.key)),!this.dataFrame)return void console.error("Dataframe is empty.");if((null==(A=this._campaign)?void 0:A.columnSemTypes)&&Object.entries(this._campaign.columnSemTypes).forEach(([e,t])=>{let i=this.dataFrame.columns.byName(e);i&&i.semType!==t&&(i.semType=t)}),(null==(C=this._campaign)?void 0:C.columnTypes)&&Object.entries(this._campaign.columnTypes).forEach(([e,t])=>{let 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(),yield this.prepareDataFrame(e),this._molColName=null!=(s=null==(E=this.dataFrame.columns.bySemType(r.SEMTYPE.MOLECULE))?void 0:E.name)?s:void 0,this._dfName=null!=(u=this.dataFrame.name)?u:null==a?void 0:a.query,this.dataFrame.name=null!=(c=null!=(p=this._dfName)?p:this.dataFrame.name)?c:"Molecules",this._campaignId=n,this.template=(null==(T=this.campaign)?void 0:T.template)?iD(iV({},this.campaign.template),{dataSourceType:e.dataSourceType,queryFunctionName:e.queryFunctionName}):e,this._campaignFilters=i,!i){let t={},i={},n={};e.compute.functions.forEach(e=>{t[`${e.package}:${e.name}`]=e.args}),null==(S=e.compute.scripts)||S.forEach(e=>{i[`${eu}:${e.name}:${e.id}`]=e.args}),null==(O=e.compute.queries)||O.forEach(e=>{n[`${ec}:${e.name}:${e.id}`]=e.args}),yield tP({descriptors:e.compute.descriptors.enabled?e.compute.descriptors.args:[],externals:t,scripts:i,queries:n},this.dataFrame,this._molColName)}this.campaign?yield this.setCanEdit(this.campaign):this.hasEditPermission=!0,this._filterViewName=`${this.appName} | ${null!=(d=null!=(m=this._friendlyName)?m:this._campaignId)?d:"Pick"}`;let P=t.shell.v,N=t.shell.addView(this.pickView);this.currentPickViewId=N.name,this._submitView=new iN(this),this.setBaseUrl(),eb(l,null!=(h=null!=(g=this._campaignId)?g:null==(x=this._campaign)?void 0:x.name)?h:"");let F=null!=(f=null!=(y=this._friendlyName)?y:this._campaignId)?f:"Pick";setTimeout(()=>{this._pickViewPromise&&this._pickViewPromise.then(()=>{let{sub:e}=ew(N,this.appName,F,()=>{t.shell.v=P,N.close(),e.unsubscribe()})})},300),t.shell.windows.showHelp=!1}).call(this)}get filterSettings(){return this._campaignFilters}get campaignId(){return this._campaignId}get pickView(){let e=this.getFilterView();return iT(e,this,"pick"),this._pickView=e}get molColName(){var e,t,i;return null!=(e=this._molColName)?e:this._molColName=null==(i=this.dataFrame)||null==(t=i.columns.bySemType(r.SEMTYPE.MOLECULE))?void 0:t.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});let t=()=>ik(function*(){eZ(this,e=>ik(function*(){var t,i,n,a,r,l,o;let s=this.template.compute.descriptors.args,u=this.template.compute.functions,c=null!=(t=this.template.compute.scripts)?t:[],p=null!=(i=this.template.compute.queries)?i:[],d=e.descriptors,m={descriptors:{enabled:!!(null==e||null==(o=e.descriptors)?void 0:o.length),args:null!=(n=null==e?void 0:e.descriptors)?n:[]},functions:Object.entries(null!=(a=null==e?void 0:e.externals)?a:{}).map(([e,t])=>{let i=e.split(":");return{name:i[1],package:i[0],args:t}}),scripts:Object.entries(null!=(r=null==e?void 0:e.scripts)?r:{}).filter(([e,t])=>e.startsWith(eu)&&3===e.split(":").length).map(([e,t])=>{var i,n;let a=e.split(":");return{name:null!=(i=a[1])?i:"",id:null!=(n=a[2])?n:"",args:t}}),queries:Object.entries(null!=(l=null==e?void 0:e.queries)?l:{}).filter(([e,t])=>e.startsWith(ec)&&3===e.split(":").length).map(([e,t])=>{var i,n;let a=e.split(":");return{name:null!=(i=a[1])?i:"",id:null!=(n=a[2])?n:"",args:t}})};this.template.compute=m;let h=d.filter(e=>!s.includes(e)),g=m.functions.filter(e=>{if(!u.some(t=>t.name===e.name&&t.package===e.package))return!0;let t=u.find(t=>t.name===e.name&&t.package===e.package);return!Object.entries(e.args).every(([e,i])=>t.args[e]===i)}),f=m.scripts.filter(e=>{if(!c.some(t=>t.id===e.id))return!0;let t=c.find(t=>t.id===e.id);return!Object.entries(e.args).every(([e,i])=>t.args[e]===i)}),y=m.queries.filter(e=>{if(!p.some(t=>t.id===e.id))return!0;let t=p.find(t=>t.id===e.id);return!Object.entries(e.args).every(([e,i])=>t.args[e]===i)}),v={};g.forEach(e=>{v[`${e.package}:${e.name}`]=e.args});let b={};f.forEach(e=>{b[`${eu}:${e.name}:${e.id}`]=e.args});let w={};y.forEach(e=>{w[`${ec}:${e.name}:${e.id}`]=e.args}),yield tP({descriptors:h,externals:v,scripts:b,queries:w},this.dataFrame,this._molColName),this.saveCampaign("In Progress",!1)}).call(this),()=>null,this.template,!0)}).call(this);this.dataFrame.col(d)||this.dataFrame.columns.addNewBool(d).init(!1);let i=r.TableView.create(this.dataFrame,!1),n=i.getRibbonPanels(),l=a.iconFA("wrench",t,"Calculate additional properties"),o=a.bigButton("Submit",()=>{var e;let t=null==(e=this._submitView)?void 0:e.render();if(t){let e=a.dialog("Submit");e.add(t),e.addButton("Save",()=>{this.saveCampaign(),e.close()}),e.addButton("Submit",()=>{var t;null==(t=this._submitView)||t.submit(),e.close()}),e.show()}}),s=a.iconFA("share",()=>ik(function*(){var e;yield new tr(null==(e=this.campaign)?void 0:e.permissions).show(e=>{this.campaign.permissions=e,this.saveCampaign(void 0,!0)})}).call(this),"Edit permissions");o.classList.add("hit-design-submit-button");let u=eC(n);return n.push([l,...this.hasEditPermission?[s]:[],...u?[]:[o]]),n.some(e=>{var t;let i=null!=(t=null==e?void 0:e.findIndex(e=>{var t;return(null==e||null==(t=e.textContent)?void 0:t.toLowerCase())==="save"}))?t:-1;return -1!==i&&(e.splice(i,1),!0)}),n=n.filter(e=>{var t;return(null!=(t=null==e?void 0:e.length)?t:0)>0}),i.setRibbonPanels(n),i.name=this._filterViewName,setTimeout(()=>ik(function*(){var t,n,a;i._onAdded(),yield new Promise(e=>setTimeout(e,1e3));let l=i.filters(this._campaignFilters?{filters:this._campaignFilters}:void 0),o=null!=(t=null==(n=this._campaign)?void 0:n.layout)?t:null==(a=this.template)?void 0:a.layoutViewState;if(o)try{let e=r.ViewLayout.fromViewState(o);i.loadLayout(e)}catch(e){console.error(e)}i.dataFrame.onFilterChanged.subscribe(e=>{this._filterDescriptions=Array.from(i.dataFrame.rows.filters),this._campaignFilters=l.getOptions().look.filters}),setTimeout(()=>{this._filterDescriptions=Array.from(i.dataFrame.rows.filters),this._campaignFilters=l.getOptions().look.filters},300),e&&e()}).call(this),300),i.parentCall=this.parentCall,i}getSummary(){var e,t,i,n,r,l,o;let s=null!=(e=null==(r=this.campaign)?void 0:r.campaignFields)?e:this.campaignProps;return iD(iV({Template:null!=(t=null==(l=this.template)?void 0:l.name)?t:"Molecules","File path":a.divH([a.link(null!=(i=this._dfName)?i:"-",()=>this.download(this.dataFrame,"molecules"),C)],{style:{alignItems:"center"}})},s),{"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":a.divH([a.link(null!=(n=null==(o=this.dataFrame)?void 0:o.filter.trueCount.toString())?n:"0",()=>{this.download(this.dataFrame,"hits",!0)},C)],{style:{alignItems:"center"}})})}saveCampaign(e,i=!0){return ik(function*(){var n,l,o,u,c,p,d,m,h,g,f,y,v,b,w;let A=this.campaignId,C=this.filterSettings,E=this.template.name,T=this.dataFrame,x=`System:AppData/HitTriage/${this.appName}/campaigns/${A}/`,S=null!=A?A:yield iB(function*(){return new Promise(e=>iB(function*(){let t=a.input.string("Campaign name",{value:""});a.dialog("Save Campaign").add(a.div(t.root)).onOK(function(){t.value&&""!==t.value?e(t.value):e(A)}).show()})())})(),O={};T.columns.toList().forEach(e=>O[e.name]=e.semType);let P={};T.columns.toList().forEach(e=>P[e.name]=e.type);let N=null!=(n=null==(m=this.campaign)?void 0:m.authorUserId)?n:t.shell.user.id,F=null!=(l=null==(h=this.campaign)?void 0:h.permissions)?l:ta,B=N?null!=(o=null==(g=this.campaign)?void 0:g.authorUserFriendlyName)?o:null==(f=yield t.dapi.users.find(N))?void 0:f.friendlyName:void 0,I={name:S,friendlyName:null!=(u=this._friendlyName)?u:null==(y=this.campaign)?void 0:y.friendlyName,templateName:E,filters:null!=C?C:{},ingest:{type:"File",query:`${x}${s}`,molColName:this.molColName},status:null!=(c=null!=e?e:null==(v=this.campaign)?void 0:v.status)?c:"In Progress",createDate:null!=(p=null==(b=this.campaign)?void 0:b.createDate)?p:ev(new Date),campaignFields:null!=(d=null==(w=this.campaign)?void 0:w.campaignFields)?d:this.campaignProps,columnSemTypes:O,rowCount:T.rowCount,filteredRowCount:T.filter.trueCount,template:this.template,columnTypes:P,authorUserId:N,authorUserFriendlyName:B,lastModifiedUserName:t.shell.user.friendlyName,permissions:F};if(this.campaign=I,!this.hasEditPermission)return t.shell.error("You do not have permission to modify this campaign"),I;let k=r.DataFrame.fromColumns(T.columns.toList().filter(e=>!e.name.startsWith("~"))).toCsv();yield nh.files.writeAsText(`${this.appName}/campaigns/${A}/${s}`,k);let V=this._pickView.saveLayout();return V?I.layout=V.viewState:t.shell.warning("Layout cound not be saved"),yield nh.saveCampaignJson(this.appName,I),i&&t.shell.info("Campaign saved successfully."),I}).call(this)}constructor(e,i="Hit Triage",n=e=>new iO(e)){super(e,i),this._filterViewName="Hit Triage | Pick",this._filterDescriptions=[],this.campaignProps={},this._pickViewPromise=null,this._infoView=n(this),this.multiView=new r.MultiView({viewFactories:{[this._infoView.name]:()=>this._infoView}}),this.multiView.tabs.onTabChanged.subscribe(e=>{this.multiView.currentView instanceof e9&&this.multiView.currentView.onActivated()}),this.multiView.parentCall=e,iE(this.multiView,this),t.events.onCurrentViewChanged.subscribe(()=>{try{var e,i,n,a;(null==(e=t.shell.v)?void 0:e.name)===this.currentPickViewId&&(t.shell.windows.showHelp=!1,this.setBaseUrl(),eb(l,null!=(i=null!=(n=this._campaignId)?n:null==(a=this._campaign)?void 0:a.name)?i:""))}catch(e){console.error(e)}})}}class i_ extends r.GridCellRenderer{get name(){return"customGasteigerPNG"}get cellType(){return"customGasteigerPNG"}get defaultHeight(){return 200}get defaultWidth(){return 200}render(e,t,i,n,a,r,l){if(r.gridRow<0||!r.cell.value)return;let o=r.cell.value,s=new Image(n-2,a-2);s.src="data:image/png;base64,"+o,s.onload=function(){e.drawImage(s,t+2,i+2,n-2,a-2)}}}function iL(e,t,i,n,a,r,l){try{var o=e[r](l),s=o.value}catch(e){i(e);return}o.done?t(s):Promise.resolve(s).then(n,a)}function i$(e){return function(){var t=this,i=arguments;return new Promise(function(n,a){var r=e.apply(t,i);function l(e){iL(r,n,a,l,o,"next",e)}function o(e){iL(r,n,a,l,o,"throw",e)}l(void 0)})}}class iM extends tb{getNewCampaignAccordeon(e){return i$(function*(){let{root:t,promise:i,cancelPromise:n}=tm(e,!0);return i.then(t=>i$(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)}).call(this)),n.then(()=>{this.init()}),t}).call(this)}getAppHeader(){return D.appHeader({iconPath:nh.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"})}constructor(e){super(e),this.name="PeptiHit",t.shell.windows.showHelp=!0,t.shell.windows.help.showHelp(nh.webRoot+"README_HD.md")}}function iH(e,t,i,n,a,r,l){try{var o=e[r](l),s=o.value}catch(e){i(e);return}o.done?t(s):Promise.resolve(s).then(n,a)}function iR(e){return function(){var t=this,i=arguments;return new Promise(function(n,a){var r=e.apply(t,i);function l(e){iH(r,n,a,l,o,"next",e)}function o(e){iH(r,n,a,l,o,"throw",e)}l(void 0)})}}class iU extends ia{setTemplate(e,t){var i=this,n=()=>super.setTemplate;return iR(function*(){var a,l;yield n().call(i,e,t),this._helmColName=null!=(a=null==(l=this.dataFrame.columns.bySemType(r.SEMTYPE.MACROMOLECULE))?void 0:l.name)?a:g}).call(this)}get helmColName(){var e,t;return null!=(e=this._helmColName)?e:null==(t=this.dataFrame.columns.bySemType(r.SEMTYPE.MACROMOLECULE))?void 0:t.name}performSingleCellCalculations(e,i){var n=this,a=()=>super.performSingleCellCalculations;return iR(function*(){try{var l;if(!i)throw Error("No cell value provided");let o=r.Column.fromStrings(this.helmColName,[i]),s=r.DataFrame.fromColumns([o]);o.semType=r.SEMTYPE.MACROMOLECULE,o.setTag("units","helm"),o.setTag(".alphabetIsMultichar","true"),yield t.functions.call("Bio:toAtomicLevel",{table:s,seqCol:o,nonlinear:!0});let u=s.columns.names().find(e=>e.toLowerCase()!==this.helmColName.toLowerCase()),c=u?null==(l=s.col(u))?void 0:l.get(0):null;if(!c)throw Error("Failed to convert sequence to atomic level");this.dataFrame.set(this.molColName,e,c),yield a().call(n,e,c)}catch(e){console.error(e)}}).call(this)}getDesignView(){var e,i,n,a,l,o,s;let u=[],c=null==(n=this.dataFrame.col(this.helmColName))?void 0:n.toList().every(e=>!e&&""===e),p=this.dataFrame.col(this.helmColName);if(!p)throw Error("No helm column found");p.semType=r.SEMTYPE.MACROMOLECULE,p.setTag("units","helm"),p.setTag(".alphabetIsMultichar","true"),p.setTag("cell.renderer","helm");let d=t.shell.addTableView(this.dataFrame);this._designViewName=null!=(e=null==(a=this.campaign)?void 0:a.name)?e:this._designViewName,d.name=this._designViewName,d._onAdded();let h=null!=(i=null==(l=this._campaign)?void 0:l.layout)?i:null==(o=this.template)?void 0:o.layoutViewState;if(h)try{let e=r.ViewLayout.fromViewState(h);d.loadLayout(e)}catch(e){t.shell.error("Failed to apply layout. Falling back to default layout."),console.error(e)}let g=null==(s=d.grid)?void 0:s.col(f);g&&(g.editable=!1);let v=this.dataFrame.col(f);return v&&(v.semType=y,v.valueComparer=(e,t)=>e===t?0:null===e?-1:null===t?1:parseInt(e.substring(1))-parseInt(t.substring(1))),c&&t.functions.call("Helm:editMoleculeCell",{cell:d.grid.cell(this.helmColName,0)}),u.push(this.dataFrame.onRowsAdded.pipe((0,tD.filter)(()=>!this.isJoining)).subscribe(()=>{try{if(this.stages.length>0)for(let t=0;t<this.dataFrame.rowCount;t++){var e;let i=this.dataFrame.col(m).get(t);(!i||""===i||(null==(e=this.dataFrame.col(m))?void 0:e.isNone(t)))&&this.dataFrame.set(m,t,this.stages[0])}let i=null;for(let e=0;e<this.dataFrame.rowCount;e++){let t=d.grid.cell(this.helmColName,e);t&&(""===t.cell.value||null===t.cell.value)&&(i=t)}i&&t.functions.call("Helm:editMoleculeCell",{cell:i})}catch(e){console.error(e)}})),u.push(t.events.onContextMenu.subscribe(e=>{try{var i,n,a,l,o,s,u,c,p,m,h,g;let t=null==e||null==(i=e.args)?void 0:i.context;if(!t||(null==t?void 0:t.type)!==r.VIEWER.GRID||!t.tableView||t.tableView.id!==d.id||(null==e||null==(l=e.args)||null==(a=l.item)||null==(n=a.tableColumn)?void 0:n.name)!==this.helmColName||!(null==e||null==(s=e.args)||null==(o=s.item)?void 0:o.isTableCell))return;let f=null==e||null==(u=e.args)?void 0:u.menu;if(!f)return;f.item("Add new row",()=>{this.dataFrame.rows.addNew(null,!0)}),f.item("Duplicate Sequence",()=>{try{var t,i,n,a;let r=this.dataFrame.rows.addNew(null,!0),l=r.get(this.helmColName);null!=l&&r.idx>-1&&(this.dataFrame.cell(r.idx,this.helmColName).value=null!=(t=null==e||null==(a=e.args)||null==(n=a.item)||null==(i=n.cell)?void 0:i.value)?t:"")}catch(e){console.error(e)}});let y=null==e||null==(p=e.args)||null==(c=p.item)?void 0:c.tableRowIndex,v=null==e||null==(g=e.args)||null==(h=g.item)||null==(m=h.cell)?void 0:m.value;v&&(null!=y?y:-1)>-1&&f.item("Re-Run Calculations",()=>iR(function*(){try{yield this.performSingleCellCalculations(y,v)}catch(e){console.error(e)}}).call(this))}catch(e){t.log.error(e)}})),(null==d?void 0:d.grid)||(t.shell.error("Applied layout created view without grid. Resetting layout."),d.resetLayout()),(null==d?void 0:d.grid)&&u.push(d.grid.onCellValueEdited.subscribe(e=>iR(function*(){try{var i,n;if((null==(i=e.tableColumn)?void 0:i.name)===m)return void(yield this.saveCampaign(!1));if((null==(n=e.tableColumn)?void 0:n.name)!==this.helmColName)return;let t=e.cell.value,a=e.tableRowIndex;yield this.performSingleCellCalculations(a,t);try{let e=this.dataFrame.col(this.molColName).get(a),t=yield tY(null!=e?e:"",this.campaignId,this.appName);t&&this.dataFrame.col(f).set(a,t,!0)}catch(e){console.error("Error updating V-iD column:",e)}}catch(e){t.shell.error("Error performing cell calculations: "+e),console.error(e)}}).call(this))),(null==d?void 0:d.grid)&&u.push(d.grid.onCellRender.subscribe(e=>{try{var t;let i=this.duplicateVidCache,n=e.cell;if(!n||!n.isTableCell||!n.tableColumn||!i||n.tableColumn.name!==f||(null!=(t=n.tableRowIndex)?t:-1)<0)return;i.valueCounts[i.indexes[n.tableRowIndex]]>1&&(e.cell.style.backColor=r.Color.setAlpha(r.Color.getCategoricalColor(i.indexes[n.tableRowIndex]),150))}catch(e){}})),this.initDesignViewRibbons(d,u),d.parentCall=this.parentCall,d}constructor(e){super(e,"PeptiHit",e=>new iM(e)),this._helmColName=g}}function iq(e,t,i,n,a,r,l){try{var o=e[r](l),s=o.value}catch(e){i(e);return}o.done?t(s):Promise.resolve(s).then(n,a)}function iY(e){return function(){var t=this,i=arguments;return new Promise(function(n,a){var r=e.apply(t,i);function l(e){iq(r,n,a,l,o,"next",e)}function o(e){iq(r,n,a,l,o,"throw",e)}l(void 0)})}}function iG(e,t,i,n,a,r,l){try{var o=e[r](l),s=o.value}catch(e){i(e);return}o.done?t(s):Promise.resolve(s).then(n,a)}function iW(e){return function(){var t=this,i=arguments;return new Promise(function(n,a){var r=e.apply(t,i);function l(e){iG(r,n,a,l,o,"next",e)}function o(e){iG(r,n,a,l,o,"throw",e)}l(void 0)})}}class iJ extends iO{onActivated(){t.shell.windows.showHelp=!0,t.shell.windows.help.showHelp(nh.webRoot+"README_HT.md")}getAppHeader(){return D.appHeader({iconPath:nh.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- Load sequence datasets and auto-convert to molecules\n- Calculate different molecular properties\n- Filter sequences using different criteria\n- Save campaigns and continue any time from where you left off\n- Submit final selection to the function of your choice"})}getTemplatesFolder(){return`${this.app.appName}/templates`}getDataSourceTag(){return Y}getDataSourceFunctionsMap(){return this.pepTriageDataSourceFunctionsMap}getNewCampaignAccordeon(e,t){return iW(function*(){var i,n;let r=a.input.string("Sequence Column",{value:null!=(i=e.sequenceColumnName)?i:"",nullable:!1});r.setTooltip("Name of the sequence column in the dataset");let l=a.input.string("Molecule Column",{value:null!=(n=e.moleculeColumnName)?n:"",nullable:!0});l.setTooltip("Name of the molecule column (leave empty to auto-convert from sequences)"),a.setUpdateIndicator(t,!0);let{root:o,promise:s,cancelPromise:u}=yield eR(e,this.getDataSourceFunctionsMap(),this.getDataSourceTag(),{extraFormElements:[r.root,l.root],getExtraData:()=>{var t,i;return{sequenceColumnName:(null==(t=r.value)?void 0:t.trim())||e.sequenceColumnName,moleculeColumnName:(null==(i=l.value)?void 0:i.trim())||void 0}}});return a.setUpdateIndicator(t,!1),s.then(t=>iW(function*(){var i,n,a,r,l,o;let s=(l=function(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{},n=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(i).filter(function(e){return Object.getOwnPropertyDescriptor(i,e).enumerable}))),n.forEach(function(t){var n;n=i[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({},e),o=o={sequenceColumnName:null!=(i=null==(a=t.extraData)?void 0:a.sequenceColumnName)?i:e.sequenceColumnName,moleculeColumnName:null!=(n=null==(r=t.extraData)?void 0:r.moleculeColumnName)?n:e.moleculeColumnName},Object.getOwnPropertyDescriptors?Object.defineProperties(l,Object.getOwnPropertyDescriptors(o)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t.push.apply(t,i)}return t})(Object(o)).forEach(function(e){Object.defineProperty(l,e,Object.getOwnPropertyDescriptor(o,e))}),l);this.app.dataFrame=t.df,this.app._fileInputType=t.type,yield this.app.setTemplate(s,void 0,void 0,void 0,t.friendlyName),this.app.campaignProps=t.campaignProps,yield this.app.saveCampaign(void 0,!1),s.layoutViewState&&this.app.campaign&&(this.app.campaign.layout=s.layoutViewState)}).call(this)),u.then(()=>{this.init()}),o}).call(this)}createNewTemplate(e){return iW(function*(){var i,n;let l=yield(i=this.app,n=this.getDataSourceFunctionsMap(),iY(function*(){var l,o,s,u,c;let d=`${i.appName}/templates`,m=(yield nh.files.list(d)).filter(e=>e.name.endsWith(".json")).map(e=>e.name.slice(0,-5)),h=[];for(let e of m){let t=yield e_(`${d}/${e}.json`);h.push(t.key)}let g=Array.from(new Set(r.Func.find({meta:{role:p}}).concat(r.Func.find({tags:[p]})))),f={};g.forEach(e=>{var t;f[null!=(t=e.friendlyName)?t:e.name]=e});let y=(null==e?void 0:e.submit)?Object.keys(f).find(t=>{var i,n;return(null==(i=f[t])?void 0:i.name)===(null==(n=e.submit)?void 0:n.fName)}):null,b=a.input.choice("Submit function",{value:null!=y?y:null,items:[null,...Object.keys(f)]});y||(b.value=null),b.nullable=!0,b.fireChanged(),b.setTooltip("Select function to be called upon submitting");let w=e2(),C=a.divText("Template name is empty or already exists",{classes:"hit-triage-error-div"}),T=a.divText("Template key is empty or already exists",{classes:"hit-triage-error-div"}),x=a.input.string("Name",{value:e?`${e.name} (copy)`:"",onValueChanged:e=>{""===e||m.includes(e)?(x.root.style.borderBottom="1px solid red",C.style.opacity="100%"):(x.root.style.borderBottom="none",C.style.opacity="0%")}}),S=a.input.string("Key",{value:e?`${e.key}-copy`:"",onValueChanged:e=>{""===e||h.includes(e)?(S.root.style.borderBottom="1px solid red",T.style.opacity="100%"):(S.root.style.borderBottom="none",T.style.opacity="0%")}});S.setTooltip("Template key used for campaign prefix"),x.setTooltip("Template name"),x.root.style.borderBottom="none",S.root.style.borderBottom="none",C.style.opacity="0%",T.style.opacity="0%";let O=a.input.string("Sequence Column",{value:null!=(l=null==e?void 0:e.sequenceColumnName)?l:"",nullable:!1});O.setTooltip("Name of the sequence column in the dataset (mandatory)");let P=a.divText("Sequence column name is required",{classes:"hit-triage-error-div"});P.style.opacity="0%",O.onChanged.subscribe(()=>{var e;(null==(e=O.value)?void 0:e.trim())?(O.root.style.borderBottom="none",P.style.opacity="0%"):(O.root.style.borderBottom="1px solid red",P.style.opacity="100%")});let N=a.input.string("Molecule Column",{value:null!=(o=null==e?void 0:e.moleculeColumnName)?o:"",nullable:!0});N.setTooltip("Name of the molecule column (optional). If empty, sequences will be auto-converted to molecules.");let F=null,B=e||{compute:{descriptors:{enabled:!0,args:[]},functions:[]}},I=yield eZ(i,e=>{F=e},()=>null,B,!1);I.root.classList.add("hit-triage-new-template-functions-input"),0===Object.entries(n).length&&Array.from(new Set(r.Func.find({meta:{role:Y}}).concat(r.Func.find({tags:[Y]})))).forEach(e=>{var t;n[null!=(t=e.friendlyName)?t:e.name]=e});let k=Object.keys(n),V=a.input.choice(v,{value:k[0],items:k}),D=a.input.choice("Ingest using",{value:null!=(s=null==e?void 0:e.dataSourceType)?s:"Query",items:["Query","File"],onValueChanged:e=>{V.root.style.display="Query"===e?"block":"none"}});(null==e?void 0:e.dataSourceType)&&(V.root.style.display="Query"===e.dataSourceType?"block":"none");let j=e3(null==e?void 0:e.campaignFields),_=a.div([a.h2("Details"),a.div([x,C]),a.div([S,T]),a.h2("Sequence Configuration"),a.div([O,P]),N.root,a.h2("Data Ingestion"),D.root,V.root,w.dataFileInput,j.fieldsDiv,a.h2("Compute"),I.root,a.h2("Submit"),b.root],"ui-form"),L=a.buttonsInput([]),M=null!=(u=null==(c=L.getElementsByClassName("ui-input-editor"))?void 0:c[0])?u:L;_.appendChild(L);let H=new Promise(e=>{let t=a.button(E,()=>e());M.appendChild(t)});return{root:_,template:new Promise(e=>{let i=a.bigButton(A,()=>iY(function*(){var i,n,a,r,l,o,s,u,c,p,m,h;if(I.okProxy(),"100%"===C.style.opacity)return void t.shell.error("Template name is empty or already exists");if("100%"===T.style.opacity)return void t.shell.error("Template key is empty or already exists");if(!(null==(u=O.value)?void 0:u.trim()))return void t.shell.error("Sequence column name is required");let g=b.value?f[b.value]:void 0,y=(m=function(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{},n=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(i).filter(function(e){return Object.getOwnPropertyDescriptor(i,e).enumerable}))),n.forEach(function(t){var n;n=i[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({name:x.value,key:S.value,sequenceColumnName:O.value.trim(),moleculeColumnName:(null==(c=N.value)?void 0:c.trim())||void 0,campaignFields:j.getFields(),dataSourceType:null!=(i=D.value)?i:"Query",layoutViewState:null!=(n=w.getLayoutViewState())?n:void 0,compute:{descriptors:{enabled:!!(null==F||null==(p=F.descriptors)?void 0:p.length),args:null!=(a=null==F?void 0:F.descriptors)?a:[]},functions:Object.entries(null!=(r=null==F?void 0:F.externals)?r:{}).map(([e,t])=>{let i=e.split(":");return{name:i[1],package:i[0],args:t}}),scripts:Object.entries(null!=(l=null==F?void 0:F.scripts)?l:{}).filter(([e,t])=>e.startsWith(eu)&&3===e.split(":").length).map(([e,t])=>{var i,n;let a=e.split(":");return{name:null!=(i=a[1])?i:"",id:null!=(n=a[2])?n:"",args:t}}),queries:Object.entries(null!=(o=null==F?void 0:F.queries)?o:{}).filter(([e,t])=>e.startsWith(ec)&&3===e.split(":").length).map(([e,t])=>{var i,n;let a=e.split(":");return{name:null!=(i=a[1])?i:"",id:null!=(n=a[2])?n:"",args:t}})}},g?{submit:{fName:g.name,package:eh(g)}}:{}),h=h={queryFunctionName:"Query"===D.value&&null!=(s=V.value)?s:void 0},Object.getOwnPropertyDescriptors?Object.defineProperties(m,Object.getOwnPropertyDescriptors(h)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t.push.apply(t,i)}return t})(Object(h)).forEach(function(e){Object.defineProperty(m,e,Object.getOwnPropertyDescriptor(h,e))}),m);nh.files.writeAsText(`${d}/${y.name}.json`,JSON.stringify(y)),t.shell.info("Template created successfully"),e(y)})());M.appendChild(i)}),cancelPromise:H}})()),o=new r.ViewBase,s=t.shell.v;o.name="New Template",o.root.appendChild(l.root),o.parentCall=this.app.parentCall,t.shell.addView(o),o.path=new URL(this.app.baseUrl).pathname+"/new-template",o.parentView=s;let{sub:u}=ew(t.shell.v,this.app.appName,b,()=>{t.shell.v=s,o.close()});l.template.then(e=>iW(function*(){yield this.init(e),o.close(),eA(o),t.shell.v=s,u.unsubscribe()}).call(this)),l.cancelPromise.then(()=>{u.unsubscribe(),o.close(),t.shell.v=s})}).call(this)}constructor(e){super(e),this.pepTriageDataSourceFunctionsMap={},this.name="PepTriage",t.shell.windows.showHelp=!0,t.shell.windows.help.showHelp(nh.webRoot+"README_HT.md")}}function iz(e,t,i,n,a,r,l){try{var o=e[r](l),s=o.value}catch(e){i(e);return}o.done?t(s):Promise.resolve(s).then(n,a)}function iQ(e,t,i,n,a,r,l){try{var o=e[r](l),s=o.value}catch(e){i(e);return}o.done?t(s):Promise.resolve(s).then(n,a)}class iK extends ij{get seqColName(){return this._seqColName}prepareDataFrame(e){var i;return(i=function*(){if(!this.dataFrame)return;yield this.dataFrame.meta.detectSemanticTypes();let i=e.sequenceColumnName,n=i?this.dataFrame.col(i):null;if(n||(n=this.dataFrame.columns.bySemType(r.SEMTYPE.MACROMOLECULE)),!n)throw Error(`Sequence column '${null!=i?i:"Macromolecule"}' not found in the dataset. Make sure the data contains a column with sequences.`);this._seqColName=n.name;let a=r.TaskBarProgressIndicator.create("Initializing sequences...");try{var l,o;let i=yield(l=function*(){let e=r.Func.find({package:"Bio",name:"getSeqHelper"});if(0===e.length)throw Error("Package 'Bio' must be installed for SeqHelper.");return(yield e[0].prepare().call()).getOutputParamValue()},function(){var e=this,t=arguments;return new Promise(function(i,n){var a=l.apply(e,t);function r(e){iz(a,i,n,r,o,"next",e)}function o(e){iz(a,i,n,r,o,"throw",e)}r(void 0)})})(),s=i.getSeqHandler(n);yield s.refinerPromise,i.getSeqHandler(n);let u=e.moleculeColumnName,c=u?this.dataFrame.col(u):null;if((c||(c=this.dataFrame.columns.bySemType(r.SEMTYPE.MOLECULE)),!c)&&(a.update(50,"Converting sequences to molecules..."),yield t.functions.call("Bio:toAtomicLevel",{table:this.dataFrame,seqCol:n,nonlinear:!0}),yield this.dataFrame.meta.detectSemanticTypes(),!(c=null!=(o=this.dataFrame.columns.bySemTypeAll(r.SEMTYPE.MOLECULE).find(e=>e.name.toLowerCase().includes(n.name.toLowerCase())))?o:null)))return void t.shell.warning("Failed to convert sequences to molecules. Calculations may not work.");this.reorderColumns(n.name,c.name)}catch(e){nh.logger.error(e),t.shell.error("Error preparing sequence data: "+(e instanceof Error?e.message:e))}finally{a.close()}},function(){var e=this,t=arguments;return new Promise(function(n,a){var r=i.apply(e,t);function l(e){iQ(r,n,a,l,o,"next",e)}function o(e){iQ(r,n,a,l,o,"throw",e)}l(void 0)})}).call(this)}reorderColumns(e,t){if(!this.dataFrame)return;let i=this.dataFrame.col(e),n=this.dataFrame.col(t);i&&(this.dataFrame.columns.remove(e),this.dataFrame.columns.insert(i,0)),n&&(this.dataFrame.columns.remove(t),this.dataFrame.columns.insert(n,1))}constructor(e){super(e,"PepTriage",e=>new iJ(e))}}function iZ(e,t,i,n,a,r,l){try{var o=e[r](l),s=o.value}catch(e){i(e);return}o.done?t(s):Promise.resolve(s).then(n,a)}function iX(e){return function(){var t=this,i=arguments;return new Promise(function(n,a){var r=e.apply(t,i);function l(e){iZ(r,n,a,l,o,"next",e)}function o(e){iZ(r,n,a,l,o,"throw",e)}l(void 0)})}}function i0(){return iX(function*(){yield nf.initHT()})()}function i1(e){return iX(function*(){yield nf.hitTriageAppTreeBrowser(e)})()}function i2(e){return iX(function*(){yield nf.hitDesignAppTreeBrowser(e)})()}function i4(e){return iX(function*(){yield nf.peptiHitAppTreeBrowser(e)})()}function i5(){return iX(function*(){return yield nf.hitTriageApp()})()}function i3(){return iX(function*(){return yield nf.hitDesignApp()})()}function i8(){return iX(function*(){return yield nf.peptiHitApp()})()}function i6(e){return iX(function*(){yield nf.pepTriageAppTreeBrowser(e)})()}function i9(){return iX(function*(){return yield nf.pepTriageApp()})()}function i7(){return iX(function*(){return yield nf.demoFileIngest()})()}function ne(){return iX(function*(){return yield nf.demoFileIngest1()})()}function nt(e){return iX(function*(){return yield nf.demoFileIngest2(e)})()}function ni(e){return iX(function*(){return yield nf.demoPeptideSequences(e)})()}function nn(e,t){return iX(function*(){yield nf.demoFileSubmit(e,t)})()}function na(){return iX(function*(){yield nf.registerMoleculesToViD()})()}function nr(e){return nf.hitDesignVidPanel(e)}function nl(){return nf.gasteigerCellRenderer()}function no(e){return iX(function*(){return yield nf.htPackageSettingEditor(e)})()}function ns(e,t,i,n,a,r,l){try{var o=e[r](l),s=o.value}catch(e){i(e);return}o.done?t(s):Promise.resolve(s).then(n,a)}function nu(e){return function(){var t=this,i=arguments;return new Promise(function(n,a){var r=e.apply(t,i);function l(e){ns(r,n,a,l,o,"next",e)}function o(e){ns(r,n,a,l,o,"throw",e)}l(void 0)})}}function nc(e,t,i,n){var a,r=arguments.length,l=r<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(e,t,i,n);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(l=(r<3?a(l):r>3?a(t,i,l):a(t,i))||l);return r>3&&l&&Object.defineProperty(t,i,l),l}function np(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function nd(e,t){return function(i,n){t(i,n,e)}}class nm extends r.Package{convertToSmiles(e){return e?this.molToSmilesLruCache.getOrCreate(e,e=>t.chem.convert(e,t.chem.Notation.Unknown,t.chem.Notation.Smiles)):""}loadCampaigns(e,i){return nu(function*(){var n;return this.campaignsCache[e]||(this.campaignsCache[e]=yield(n=null!=i?i:[],ey(function*(){let i=(yield nh.files.list(`${e}/campaigns`)).filter(e=>-1===n.indexOf(e.name)),a={},r=i.map(i=>ey(function*(){try{let n=JSON.parse((yield nh.files.readAsText(`${e}/campaigns/${i.name}/${u}`)));if(n.authorUserId&&n.permissions&&!(yield ex(n.authorUserId,n.permissions)))return null;if(n.authorUserId&&!n.authorUserFriendlyName){let e=yield t.dapi.users.find(n.authorUserId);e&&(n.authorUserFriendlyName=e.friendlyName)}a[n.name]=n}catch(e){console.error(e)}return null})());return yield Promise.all(r),a})())),this.campaignsCache[e]}).call(this)}saveCampaignJson(e,t){return nu(function*(){let i=`${e}/campaigns/${t.name}/${u}`;yield this.files.writeAsText(i,JSON.stringify(t)),this.campaignsCache[e][t.name]=t}).call(this)}constructor(...e){super(...e),this.molToSmilesLruCache=new r.LruCache(2e3),this.campaignsCache={}}}let nh=new nm;function ng(e,i){return nu(function*(){let n=a.div([],{style:{width:"50px",height:"24px",position:"relative"}});n.innerHTML='<div class="grok-loader"><div></div><div></div><div></div><div></div></div>';let l=e.item(n),o=yield nh.loadCampaigns(i,[]),s=null,u=!0;for(let[i,n]of Object.entries(o)){var c,p,d;let i=null!=(c=n.templateName)?c:null==(d=n.template)?void 0:d.name,a=i?e.getOrCreateGroup(i,null,u):e;u=!1;let l=a.item(null!=(p=n.friendlyName)?p:n.name);l.root.addEventListener("dblclick",e=>{e.stopImmediatePropagation(),e.stopPropagation(),e.preventDefault()}),r.debounce(l.onSelected,200).subscribe(e=>nu(function*(){try{var e;let o="ingest"in n?n.ingest.query:n.savePath;if(!o||!(yield t.dapi.files.exists(o)))return void t.shell.error("File not found: "+o);let u=yield t.dapi.files.readCsv(o);if(!u)return;u.name=null!=(e=n.friendlyName)?e:n.name;let c=n.columnSemTypes;if(c)for(let[e,t]of Object.entries(c)){let i=u.columns.byName(e);i&&(i.semType=t,t===r.SEMTYPE.MACROMOLECULE&&e===g&&(i.setTag("units","helm"),i.setTag(".alphabetIsMultichar","true"),i.setTag("cell.renderer","helm")))}let p=document.activeElement,d=!1;function i(){setTimeout(()=>{!d&&p&&document.activeElement!==p&&p&&"focus"in p&&p.focus()})}window.addEventListener("focusout",i);try{s&&s.close()}catch(e){}try{s=t.shell.addTableView(u);let e=n.layout;e&&s.loadLayout(r.ViewLayout.fromViewState(e))}catch(e){console.error(e)}function a(){window.removeEventListener("focusout",i)}function l(){a(),d=!0}window.addEventListener("click",l,{once:!0}),setTimeout(()=>{a(),window.removeEventListener("click",l)},5e3)}catch(e){console.error(e)}})())}l.remove()})()}class nf{static initHT(){return nu(function*(){try{yield t.functions.call("Chem:init",{})}catch(e){console.error("error initializing chem package",e)}})()}static hitTriageAppTreeBrowser(e){return nu(function*(){yield ng(e,"Hit Triage")})()}static hitDesignAppTreeBrowser(e){return nu(function*(){yield ng(e,"Hit Design")})()}static peptiHitAppTreeBrowser(e){return nu(function*(){yield ng(e,"PeptiHit")})()}static hitTriageApp(){return nu(function*(){return new ij(t.functions.getCurrentCall()).multiView})()}static hitDesignApp(){return nu(function*(){return new ia(t.functions.getCurrentCall()).multiView})()}static peptiHitApp(){return nu(function*(){let e=t.functions.getCurrentCall();return yield t.functions.call("Bio:initBio",{}),new iU(e).multiView})()}static pepTriageAppTreeBrowser(e){return nu(function*(){yield ng(e,"PepTriage")})()}static pepTriageApp(){return nu(function*(){let e=t.functions.getCurrentCall();return yield t.functions.call("Bio:initBio",{}),new iK(e).multiView})()}static demoFileIngest(){return nu(function*(){let e=t.data.demo.molecules(100);return e.name="100 Molecules",e})()}static demoFileIngest1(){return nu(function*(){let e=t.data.demo.molecules(5e3);return e.name="5000 Molecules",e})()}static demoFileIngest2(e){return nu(function*(){let i=t.data.demo.molecules(e);return i.name="Variable Molecules number",i})()}static demoPeptideSequences(e){return nu(function*(){let t=["PEPTIDE1{A.G.L.V.K}$$$$V2.0","PEPTIDE1{G.A.V.L.I.P}$$$$V2.0","PEPTIDE1{F.W.Y.H.K.R}$$$$V2.0","PEPTIDE1{D.E.N.Q.S.T}$$$$V2.0","PEPTIDE1{A.R.N.D.C.E}$$$$V2.0","PEPTIDE1{G.H.I.L.K.M}$$$$V2.0","PEPTIDE1{F.P.S.T.W.Y}$$$$V2.0","PEPTIDE1{V.A.G.L.I}$$$$V2.0","PEPTIDE1{K.R.H.D.E}$$$$V2.0","PEPTIDE1{N.Q.S.T.C.M}$$$$V2.0","PEPTIDE1{A.V.L.I.P.F}$$$$V2.0","PEPTIDE1{W.Y.G.A.R}$$$$V2.0","PEPTIDE1{K.H.D.E.N.Q}$$$$V2.0","PEPTIDE1{S.T.C.M.F.W}$$$$V2.0","PEPTIDE1{Y.A.G.V.L.I}$$$$V2.0","PEPTIDE1{P.K.R.H.D}$$$$V2.0","PEPTIDE1{E.N.Q.S.T.C}$$$$V2.0","PEPTIDE1{M.F.W.Y.A.G}$$$$V2.0","PEPTIDE1{V.L.I.P.K.R}$$$$V2.0","PEPTIDE1{H.D.E.N.Q.S}$$$$V2.0"],i=[];for(let n=0;n<e;n++)i.push(t[n%t.length]);let n=r.Column.fromStrings("Helm",i);n.semType=r.SEMTYPE.MACROMOLECULE,n.setTag("units","helm"),n.setTag(".alphabetIsMultichar","true");let a=r.DataFrame.fromColumns([n]);return a.name="Demo Peptide Sequences",a})()}static demoFileSubmit(e,i){return nu(function*(){t.shell.info(e.rowCount),t.shell.info(i)})()}static registerMoleculesToViD(){return nu(function*(){tR(function*(){let e="Hit Design",i=yield nh.loadCampaigns(e),n=Object.keys(i),l=a.input.choice("Select Campaign",{value:null,nullable:!0,items:n,tooltipText:"Select campaign to register its molecules. Leave empty to register all campaigns"}),o=yield new Promise(e=>tR(function*(){a.dialog("Register Existing Campaign Molecules").add(a.divText("This operation will go through all molecules in the selected campaign(s) and register them into V-iD storage.\n This operation is irreversible.")).add(a.divText("You can select a specific campaign or leave it empty to process all campaigns.")).add(a.divText("After this opteration, all VIDs throughout all campaigns will become unique, and old V-iDs will no longer be valid.")).add(a.divText("WARNING: Depending on the number of molecules, this operation can take a long time.")).add(l).onOK(()=>{l.value?e([i[l.value]]):e(n.map(e=>i[e]))}).onCancel(()=>e(null)).show()})()),u=r.TaskBarProgressIndicator.create("Registering molecules...");if(!o||0===o.length)return void u.close();let c=o.length;for(let i of o){u.update(0/c*100,`Processing campaign: ${i.name}`);try{var p;let n=`System.AppData/HitTriage/${e}/campaigns`,a=null!=(p=null==i?void 0:i.savePath)?p:`${n}/${i.name}/${s}`,r=yield t.dapi.files.readCsv(a);if(!r){t.shell.warning(`Failed to load campaign table for campaign ${i.name} at path ${a}`),console.warn(`Failed to load campaign table for campaign ${i.name} at path ${a}`);continue}let l=r.col(h);if(!l){t.shell.warning(`Molecule column not found in campaign ${i.name} table`),console.warn(`Molecule column not found in campaign ${i.name} table`);continue}let o=r.col(f);if(!o){t.shell.warning(`V-iD column not found in campaign ${i.name} table`),console.warn(`V-iD column not found in campaign ${i.name} table`);continue}let u=l.toList(),c=yield tG(u,i.name,e);for(let e=0;e<r.rowCount;e++){let t=u[e];if(!t||""===t){o.set(e,"",!1);continue}let i=c.get(t);i&&o.set(e,i,!1)}o.fireValuesChanged(),yield t.dapi.files.writeAsText(a,r.toCsv()),t.shell.info(`Finished processing campaign ${i.name}`),console.log(`Finished processing campaign ${i.name}`)}catch(e){t.shell.error(`Error processing campaign ${i.name}. See console for details.`),console.error(`Error processing campaign ${i.name} molecules registration:`,e)}}u.close()})()})()}static hitDesignVidPanel(e){return r.Widget.fromRoot(a.card(a.wait(()=>nu(function*(){if(!(null==e?void 0:e.value))return a.divText("No V-iD provided");let i=yield j.getCampaignsByVid(e.value,null);if(!i||0===i.rowCount)return a.divText(`No campaigns found for V-iD: ${e.value}`);let n=yield j.getMoleculeByVid(e.value);if(!n||0===n.rowCount)return a.divText(`No molecule found for V-iD: ${e.value}`);let r=function(e){var t;let i=null==(t=nh.meta)?void 0:t.sok;if(!i)throw Error("Secret key for SMILES deobfuscation is not set");let n=atob(e),a="";for(let e=0;e<n.length;e++)a+=String.fromCharCode(n.charCodeAt(e)^i.charCodeAt(e%i.length));return a}(n.col("mh_string").get(0)),l=t.chem.drawMolecule(r,300,300),o=new Map;for(let e=0;e<i.rowCount;e++){let t=i.col("app_name").get(e),n=i.col("campaign_id").get(e),a=i.col("created_by").get(e);o.has(t)||o.set(t,[]),o.get(t).push({campaignId:n,createdBy:a})}let s=a.divV([l],{style:{gap:"10px",justifyContent:"center"}});for(let[e,t]of o.entries()){let i=a.table(t.map(e=>[e.campaignId,e.createdBy]),e=>[e[0],e[1]],["Campaigns","Created By"]),n=a.divV([a.h3(`${e} Campaigns`),i],{style:{gap:"4px"}});s.appendChild(n)}return s})())))}static gasteigerCellRenderer(){return new i_}static htPackageSettingEditor(e){return nu(function*(){return t_(function*(){let i=e.filter(e=>"DefaultUserGroupsSharing"===e.category),n=[];for(let e of i){let i=`${e.name[0].toUpperCase()}${e.name.slice(1)}`,l=e.get(null),o=yield tM(l),s=a.input.userGroups(i);yield r.delay(200),s.value=o,s.onInput.subscribe(()=>{try{var i;let t=(null==(i=s.value)?void 0:i.length)?JSON.stringify(s.value.map(e=>e.id)):"";e.set(null,t)}catch(e){t.shell.error("Error Setting group. Check console for more details"),console.error(e)}}),s.setTooltip(`Selected groups will be granted ${i.toLowerCase()} permissions by default on newly created campaigns`),n.push(s)}let l=r.Widget.fromRoot(a.form(n,{style:{overflow:"visible"}}));l.root.prepend(a.h1("Default Campaign Sharing",{style:{marginBottom:"6px",marginTop:"6px"}}));let o=e.find(e=>e.name===tL);if(o){var s;let e='Default storage for newly created campaigns. For each app, folders will be created under their name. For example, for Hit Design, the campaign files will be saved under <b>"Your folder/Hit Design/campaigns/enriched_table.csv"</b>',i=e,n=null!=(s=o.get(null))?s:t$,u=a.h1("Default Campaign Storage",{style:{marginBottom:"6px",marginTop:"6px"}}),c=a.input.string("Folder Path",{value:n});a.tooltip.bind(c.input,()=>i),r.debounce(c.onChanged,200).subscribe(n=>t_(function*(){let n=c.value;try{if(!n){o.set(null,t$),i=e+'<br><br> <b style="color: red">Cannot be empty.</b>',c.input.classList.add("d4-invalid");return}if(!(yield t.dapi.files.exists(n))){o.set(null,t$),i=e+'<br><br> <b style="color: red">Folder does not exist.</b>',c.input.classList.add("d4-invalid");return}o.set(null,n),i=e,c.input.classList.remove("d4-invalid")}catch(e){t.shell.error("Error Setting default storage. Check console for more details"),console.error(e)}})()),l.root.appendChild(u),l.root.appendChild(c.root)}return setTimeout(()=>{var e;return(null==(e=l.root.parentElement)?void 0:e.style)&&(l.root.parentElement.style.overflow="visible")},200),l})()})()}}nc([t.decorators.init(),np("design:type",Function),np("design:paramtypes",[]),np("design:returntype",Promise)],nf,"initHT",null),nc([t.decorators.treeBrowser({meta:{app:"Hit Triage"}}),np("design:type",Function),np("design:paramtypes",[void 0===r||void 0===r.TreeViewGroup?Object:r.TreeViewGroup]),np("design:returntype",Promise)],nf,"hitTriageAppTreeBrowser",null),nc([t.decorators.treeBrowser({meta:{app:"Hit Design"}}),np("design:type",Function),np("design:paramtypes",[void 0===r||void 0===r.TreeViewGroup?Object:r.TreeViewGroup]),np("design:returntype",Promise)],nf,"hitDesignAppTreeBrowser",null),nc([t.decorators.treeBrowser({meta:{app:"PeptiHit"}}),np("design:type",Function),np("design:paramtypes",[void 0===r||void 0===r.TreeViewGroup?Object:r.TreeViewGroup]),np("design:returntype",Promise)],nf,"peptiHitAppTreeBrowser",null),nc([t.decorators.app({browsePath:"Chem",name:"Hit Triage",tags:["app"]}),np("design:type",Function),np("design:paramtypes",[]),np("design:returntype",Promise)],nf,"hitTriageApp",null),nc([t.decorators.app({icon:"images/icons/hit-design-icon.png",browsePath:"Chem",name:"Hit Design",tags:["app"]}),np("design:type",Function),np("design:paramtypes",[]),np("design:returntype",Promise)],nf,"hitDesignApp",null),nc([t.decorators.app({icon:"images/icons/pepti-hit-icon.png",browsePath:"Peptides",name:"PeptiHit",tags:["app"]}),np("design:type",Function),np("design:paramtypes",[]),np("design:returntype",Promise)],nf,"peptiHitApp",null),nc([t.decorators.treeBrowser({meta:{app:"PepTriage"}}),np("design:type",Function),np("design:paramtypes",[void 0===r||void 0===r.TreeViewGroup?Object:r.TreeViewGroup]),np("design:returntype",Promise)],nf,"pepTriageAppTreeBrowser",null),nc([t.decorators.app({icon:"images/icons/hit-triage-icon.png",browsePath:"Peptides",name:"PepTriage",tags:["app"]}),np("design:type",Function),np("design:paramtypes",[]),np("design:returntype",Promise)],nf,"pepTriageApp",null),nc([t.decorators.func({name:"Demo Molecules 100",meta:{role:"hitTriageDataSource"}}),np("design:type",Function),np("design:paramtypes",[]),np("design:returntype",Promise)],nf,"demoFileIngest",null),nc([t.decorators.func({name:"Demo Molecules 5000",meta:{role:"hitTriageDataSource"}}),np("design:type",Function),np("design:paramtypes",[]),np("design:returntype",Promise)],nf,"demoFileIngest1",null),nc([t.decorators.func({name:"Demo Molecules variable",meta:{role:"hitTriageDataSource"}}),nd(0,t.decorators.param({type:"int",options:{description:"Molecules counts"}})),np("design:type",Function),np("design:paramtypes",[Number]),np("design:returntype",Promise)],nf,"demoFileIngest2",null),nc([t.decorators.func({name:"Demo Peptide Sequences",meta:{role:"pepTriageDataSource"}}),np("design:type",Function),np("design:paramtypes",[Number]),np("design:returntype",Promise)],nf,"demoPeptideSequences",null),nc([t.decorators.func({name:"Demo File Submit",meta:{role:"hitTriageSubmitFunction"}}),nd(0,t.decorators.param({options:{description:"Dataframe"}})),nd(1,t.decorators.param({options:{description:"Molecules column name"}})),np("design:type",Function),np("design:paramtypes",[void 0===r||void 0===r.DataFrame?Object:r.DataFrame,String]),np("design:returntype",Promise)],nf,"demoFileSubmit",null),nc([t.decorators.func({}),np("design:type",Function),np("design:paramtypes",[]),np("design:returntype",Promise)],nf,"registerMoleculesToViD",null),nc([t.decorators.panel({name:"Hit Design V-iD"}),nd(0,t.decorators.param({type:"semantic_value",options:{semType:"HIT_DESIGN_VID"}})),np("design:type",Function),np("design:paramtypes",[void 0===r||void 0===r.SemanticValue?Object:r.SemanticValue]),np("design:returntype",void 0===r||void 0===r.Widget?Object:r.Widget)],nf,"hitDesignVidPanel",null),nc([t.decorators.func({meta:{cellType:"customGasteigerPNG",columnTags:"quality=customGasteigerPNG",role:"cellRenderer"},name:"gasteigerRenderer",outputs:[{type:"grid_cell_renderer",name:"result"}]}),np("design:type",Function),np("design:paramtypes",[]),np("design:returntype",i_)],nf,"gasteigerCellRenderer",null),nc([t.decorators.func({name:"Hit Triage package settings editor",meta:{role:"packageSettingsEditor"},tags:["packageSettingsEditor"]}),nd(0,t.decorators.param({name:"propList",type:"object"})),np("design:type",Function),np("design:paramtypes",[Array]),np("design:returntype",Promise)],nf,"htPackageSettingEditor",null)})(),hittriage=n})();
|
|
2
431
|
//# sourceMappingURL=package.js.map
|