@datagrok/bio 2.22.5 → 2.22.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.
@@ -1,8 +1,8 @@
1
- var bio_test;(()=>{var e={8924:(e,t,n)=>{"use strict";n.d(t,{X:()=>o});var r=n(7362);class o extends r.e{static get Lesk(){return void 0===this.lesk&&(this.lesk=this.makePalette([[["G","A","S","T"],"orange"],[["C","V","I","L","P","F","Y","M","W"],"all_green"],[["N","Q","H"],"magenta"],[["D","E"],"red"],[["K","R"],"all_blue"]],!1,o)),this.lesk}static get GrokGroups(){return void 0===this.grokGroups&&(this.grokGroups=this.makePalette([[["C","U"],"yellow"],[["G","P"],"red"],[["A","V","I","L","M","F","Y","W"],"all_green"],[["R","H","K"],"light_blue"],[["D","E"],"dark_blue"],[["S","T","N","Q"],"orange"]],!1,o)),this.grokGroups}static get RasMol(){return void 0===this.rasMol&&(this.rasMol=new o({D:"#E60A0A",E:"#E60A0A",C:"#E6E600",M:"#E6E600",K:"#145AFF",R:"#145AFF",S:"#FA9600",T:"#FA9600",F:"#3232AA",Y:"#3232AA",N:"#00DCDC",Q:"#00DCDC",G:"#EBEBEB",L:"#0F820F",V:"#0F820F",I:"#0F820F",A:"#C8C8C8",W:"#B45AB4",H:"#8282D2",P:"#DC9682",others:"#BEA06E"})),this.rasMol}get(e){const t=e in o.aaSynonyms?o.aaSynonyms[e]:e;return super.get(t)}}o.aaSynonyms={MeNle:"L",MeA:"A",MeG:"G",MeF:"F"};class s{static getPalette(e="grok"){switch(e){case"grok":return o.GrokGroups;case"lesk":return o.Lesk;default:throw new Error(`ChemPalette: scheme \`${e}\` does not exist`)}}static getInnerOuter(e){let t=0,n="",r="";for(const o of e)"("==o?t++:")"==o?t--:t?n+=o:r+=o;return isNaN(parseInt(n))?[r,n]:[r,""]}static getColorAAPivot(e="",t="grok"){const n=this.getPalette(t);let[r,o]=this.getInnerOuter(e);if(r=r.length>6?`${r.slice(0,3)}...`:r,o=o.length>6?`${o.slice(0,3)}...`:o,1==e.length||"("==e[1]){const t=e[0]?.toUpperCase();return t in n?[n.get(t),t,o,1]:[this.undefinedColor,r,o,1]}if("d"==e[0]&&e[1]in n&&(2==e.length||"("==e[2])){const t=e[1]?.toUpperCase();return t in n?[n.get(t),t,o,2]:[this.undefinedColor,r,o,2]}if(e.substring(0,3)in this.AAFullNames&&(3==e.length||"("==e[3])){const t=this.AAFullNames[e.substring(0,3)];return t in n?[n.get(t),t,o,3]:[this.undefinedColor,r,o,3]}if(e[0]?.toLowerCase()==e[0]&&e.substring(1,3)in this.AAFullNames&&(4==e.length||"("==e[4])){const t=this.AAFullNames[e.substring(1,3)];return t in n?[n.get(t),t,o,4]:[this.undefinedColor,r,o,4]}return[this.undefinedColor,r,o,0]}}s.SemType="Aminoacids",s.SemTypeMultipleAlignment="AminoacidsMultipleAlignment",s.undefinedColor="rgb(100,100,100)",s.Names={G:"Glycine",L:"Leucine",Y:"Tyrosine",S:"Serine",E:"Glutamic acid",Q:"Glutamine",D:"Aspartic acid",N:"Asparagine",F:"Phenylalanine",A:"Alanine",K:"Lysine",R:"Arginine",H:"Histidine",C:"Cysteine",V:"Valine",P:"Proline",W:"Tryptophan",I:"Isoleucine",M:"Methionine",T:"Threonine"},s.AASmiles={G:"NCC(=O)O",L:"N[C@H](CC(C)C)C(=O)O",Y:"NC(CC1=CC=C(O)C=C1)C(=O)O",S:"NC(CO)C(=O)O",E:"N[C@@H](CCC(O)=O)C(=O)O",Q:"N[C@@H](CCC(N)=O)C(=O)O",D:"N[C@@H](CC(O)=O)C(=O)O",N:"N[C@@H](CC(N)=O)C(=O)O",F:"NC(CC1=CC=CC=C1)C(=O)O",A:"N[C@H](C)C(=O)O",K:"NC(CCCCN)C(=O)O",R:"N[C@H](CCCNC(=N)C)C(=O)O",H:"NC(CC1=CN=C[N]1)C(=O)O",C:"N[C@@H](CS)C(=O)O",V:"NC(C(C)C)C(=O)O",P:"N(CCC1)C1C(=O)O",W:"N[C@@H](Cc1c2ccccc2n([H])c1)C(=O)O",I:"N[C@H]([C@H](C)CC)C(=O)O",M:"NC(CCSC)C(=O)O",T:"NC(C(O)C)C(=O)O"},s.AASmilesTruncated={G:"*C*",L:"CC(C)C[C@H](*)*",Y:"C1=CC(=CC=C1CC(*)*)O",S:"OCC(*)C*",E:"*[C@@H](CCC(O)=O)*",Q:"*N[C@@H](CCC(N)=O)*",D:"*[C@@H](CC(O)=O)*",N:"*[C@@H](CC(N)=O)*",F:"C1=CC=C(C=C1)CC(*)*",A:"C[C@H](*)*",K:"C(CCN)CC(*)*",R:"*[C@H](CCCNC(=N)C)*",H:"C1=C(NC=N1)CC(*)*",C:"C([C@@H](*)*)S",V:"CC(C)C(*)*",P:"C1CCN(*)C1*",W:"*[C@@H](Cc1c2ccccc2n([H])c1)*",I:"CC[C@H](C)[C@H](*)*",M:"CSCCC(*)*",T:"CC(O)C(*)*"},s.AAFullNames={Ala:"A",Arg:"R",Asn:"N",Asp:"D",Cys:"C",Gln:"Q",Glu:"E",Gly:"G",His:"H",Ile:"I",Leu:"L",Lys:"K",Met:"M",Phe:"F",Pro:"P",Ser:"S",Thr:"T",Trp:"W",Tyr:"Y",Val:"V"}},6717:(e,t,n)=>{"use strict";n.d(t,{j:()=>o});var r=n(6082);async function o(){const e=r.Func.find({package:"Chem",name:"getRdKitModule"});if(0===e.length)throw new Error('Package "Chem" must be installed for getRdKitModule.');return(await e[0].prepare().call()).getOutputParamValue()}},3599:(e,t,n)=>{"use strict";n.d(t,{o:()=>r.o});var r=n(6869)},9124:(e,t,n)=>{"use strict";n.d(t,{b2:()=>s,fA:()=>i});var r=n(7389),o=n(6082);async function s(){const e="Helm",t=o.Func.find({package:e,name:"getHelmHelper"});if(0===t.length)throw new Error(`Package '${e}' must be installed for HelmHelper.`);return(await t[0].prepare().call()).getOutputParamValue()}function i(e,t){if(!e)throw new Error("Argument 'a' of type Atom or HelmType is mandatory.");let n,r;const o=e;return"ATOM"===o.T?(n=o.biotype(),r=o.elem):(n=e,r=t),[n,r]}o.JsInputBase,Error,r.input.helmAsync=async function(e,t){return(await s()).createHelmInput(e,t)}},8438:(e,t,n)=>{"use strict";function r(e){return e.startsWith("[")&&e.endsWith("]")?e.slice(1,-1):e}n.d(t,{D:()=>r})},8123:(e,t,n)=>{"use strict";n.d(t,{u:()=>r});const r={V2K_RGP_SHIFT:8,V2K_RGP_LINE:"M RGP",V2K_A_LINE:"A ",V3K_COUNTS_SHIFT:14,V3K_IDX_SHIFT:7,V3K_HEADER_FIRST_LINE:"\nDatagrok macromolecule handler\n\n",V3K_HEADER_SECOND_LINE:" 0 0 0 0 0 0 999 V3000\n",V3K_BEGIN_CTAB_BLOCK:"M V30 BEGIN CTAB\n",V3K_END_CTAB_BLOCK:"M V30 END CTAB\n",V3K_BEGIN_COUNTS_LINE:"M V30 COUNTS ",V3K_COUNTS_LINE_ENDING:" 0 0 0\n",V3K_BEGIN_ATOM_BLOCK:"M V30 BEGIN ATOM\n",V3K_END_ATOM_BLOCK:"M V30 END ATOM\n",V3K_BEGIN_BOND_BLOCK:"M V30 BEGIN BOND\n",V3K_END_BOND_BLOCK:"M V30 END BOND\n",V3K_BOND_CONFIG:" CFG=",V3K_BEGIN_DATA_LINE:"M V30 ",V3K_END:"M END",PRECISION_FACTOR:1e4,DEOXYRIBOSE:{polymerType:"RNA",symbol:"d"},RIBOSE:{polymerType:"RNA",symbol:"r"},PHOSPHATE:{polymerType:"RNA",symbol:"p"},OXYGEN:"O",HYDROGEN:"H"}},4356:(e,t,n)=>{"use strict";n.d(t,{Eu:()=>a,ub:()=>i});var r=n(4328);const o="Libraries";let s=Promise.resolve();async function i(){let e;return s=s.then((async()=>{const t=r.userSettings.getValue(o,"Settings",!0);e=t?JSON.parse(t):{exclude:[],explicit:[],duplicateMonomerPreferences:{}},e.exclude=e.exclude instanceof Array?e.exclude:[],e.explicit=e.explicit instanceof Array?e.explicit:[],e.duplicateMonomerPreferences=e.duplicateMonomerPreferences instanceof Object?e.duplicateMonomerPreferences:{},console.debug(`Bio: getUserLibSettings()\n${JSON.stringify(e,void 0,2)}`)})),await s,e}async function a(e){s=s.then((async()=>{console.debug(`Bio: setUserLibSettings()\n${JSON.stringify(e,void 0,2)}`),r.userSettings.add(o,"Settings",JSON.stringify(e),!0)})),await s}},5553:(e,t,n)=>{"use strict";n.d(t,{Qc:()=>E,WN:()=>C});var r=n(1991),o=n.n(r);const s="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,i=new Set,a="object"==typeof process&&process?process:{},c=(e,t,n,r)=>{"function"==typeof a.emitWarning?a.emitWarning(e,t,n,r):console.error(`[${n}] ${t}: ${e}`)};let l=globalThis.AbortController,u=globalThis.AbortSignal;if(void 0===l){u=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(e,t){this._onabort.push(t)}},l=class{constructor(){t()}signal=new u;abort(e){if(!this.signal.aborted){this.signal.reason=e,this.signal.aborted=!0;for(const t of this.signal._onabort)t(e);this.signal.onabort?.(e)}}};let e="1"!==a.env?.LRU_CACHE_IGNORE_AC_WARNING;const t=()=>{e&&(e=!1,c("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",t))}}Symbol("type");const d=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),h=e=>d(e)?e<=Math.pow(2,8)?Uint8Array:e<=Math.pow(2,16)?Uint16Array:e<=Math.pow(2,32)?Uint32Array:e<=Number.MAX_SAFE_INTEGER?p:null:null;class p extends Array{constructor(e){super(e),this.fill(0)}}class m{heap;length;static#e=!1;static create(e){const t=h(e);if(!t)return[];m.#e=!0;const n=new m(e,t);return m.#e=!1,n}constructor(e,t){if(!m.#e)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}}class f{#t;#n;#r;#o;#s;#i;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#a;#c;#l;#u;#d;#h;#p;#m;#f;#g;#y;#b;#w;#v;#A;#E;#C;static unsafeExposeInternals(e){return{starts:e.#w,ttls:e.#v,sizes:e.#b,keyMap:e.#l,keyList:e.#u,valList:e.#d,next:e.#h,prev:e.#p,get head(){return e.#m},get tail(){return e.#f},free:e.#g,isBackgroundFetch:t=>e.#T(t),backgroundFetch:(t,n,r,o)=>e.#S(t,n,r,o),moveToTail:t=>e.#_(t),indexes:t=>e.#P(t),rindexes:t=>e.#M(t),isStale:t=>e.#x(t)}}get max(){return this.#t}get maxSize(){return this.#n}get calculatedSize(){return this.#c}get size(){return this.#a}get fetchMethod(){return this.#s}get memoMethod(){return this.#i}get dispose(){return this.#r}get disposeAfter(){return this.#o}constructor(e){const{max:t=0,ttl:n,ttlResolution:r=1,ttlAutopurge:o,updateAgeOnGet:s,updateAgeOnHas:a,allowStale:l,dispose:u,disposeAfter:p,noDisposeOnSet:g,noUpdateTTL:y,maxSize:b=0,maxEntrySize:w=0,sizeCalculation:v,fetchMethod:A,memoMethod:E,noDeleteOnFetchRejection:C,noDeleteOnStaleGet:T,allowStaleOnFetchRejection:S,allowStaleOnFetchAbort:_,ignoreFetchAbort:P}=e;if(0!==t&&!d(t))throw new TypeError("max option must be a nonnegative integer");const M=t?h(t):Array;if(!M)throw new Error("invalid max value: "+t);if(this.#t=t,this.#n=b,this.maxEntrySize=w||this.#n,this.sizeCalculation=v,this.sizeCalculation){if(!this.#n&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if("function"!=typeof this.sizeCalculation)throw new TypeError("sizeCalculation set to non-function")}if(void 0!==E&&"function"!=typeof E)throw new TypeError("memoMethod must be a function if defined");if(this.#i=E,void 0!==A&&"function"!=typeof A)throw new TypeError("fetchMethod must be a function if specified");if(this.#s=A,this.#E=!!A,this.#l=new Map,this.#u=new Array(t).fill(void 0),this.#d=new Array(t).fill(void 0),this.#h=new M(t),this.#p=new M(t),this.#m=0,this.#f=0,this.#g=m.create(t),this.#a=0,this.#c=0,"function"==typeof u&&(this.#r=u),"function"==typeof p?(this.#o=p,this.#y=[]):(this.#o=void 0,this.#y=void 0),this.#A=!!this.#r,this.#C=!!this.#o,this.noDisposeOnSet=!!g,this.noUpdateTTL=!!y,this.noDeleteOnFetchRejection=!!C,this.allowStaleOnFetchRejection=!!S,this.allowStaleOnFetchAbort=!!_,this.ignoreFetchAbort=!!P,0!==this.maxEntrySize){if(0!==this.#n&&!d(this.#n))throw new TypeError("maxSize must be a positive integer if specified");if(!d(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#N()}if(this.allowStale=!!l,this.noDeleteOnStaleGet=!!T,this.updateAgeOnGet=!!s,this.updateAgeOnHas=!!a,this.ttlResolution=d(r)||0===r?r:1,this.ttlAutopurge=!!o,this.ttl=n||0,this.ttl){if(!d(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#$()}if(0===this.#t&&0===this.ttl&&0===this.#n)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#t&&!this.#n){const e="LRU_CACHE_UNBOUNDED";(e=>!i.has(e))(e)&&(i.add(e),c("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",e,f))}}getRemainingTTL(e){return this.#l.has(e)?1/0:0}#$(){const e=new p(this.#t),t=new p(this.#t);this.#v=e,this.#w=t,this.#L=(n,r,o=s.now())=>{if(t[n]=0!==r?o:0,e[n]=r,0!==r&&this.ttlAutopurge){const e=setTimeout((()=>{this.#x(n)&&this.#I(this.#u[n],"expire")}),r+1);e.unref&&e.unref()}},this.#R=n=>{t[n]=0!==e[n]?s.now():0},this.#O=(o,s)=>{if(e[s]){const i=e[s],a=t[s];if(!i||!a)return;o.ttl=i,o.start=a,o.now=n||r();const c=o.now-a;o.remainingTTL=i-c}};let n=0;const r=()=>{const e=s.now();if(this.ttlResolution>0){n=e;const t=setTimeout((()=>n=0),this.ttlResolution);t.unref&&t.unref()}return e};this.getRemainingTTL=o=>{const s=this.#l.get(o);if(void 0===s)return 0;const i=e[s],a=t[s];return i&&a?i-((n||r())-a):1/0},this.#x=o=>{const s=t[o],i=e[o];return!!i&&!!s&&(n||r())-s>i}}#R=()=>{};#O=()=>{};#L=()=>{};#x=()=>!1;#N(){const e=new p(this.#t);this.#c=0,this.#b=e,this.#k=t=>{this.#c-=e[t],e[t]=0},this.#G=(e,t,n,r)=>{if(this.#T(t))return 0;if(!d(n)){if(!r)throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");if("function"!=typeof r)throw new TypeError("sizeCalculation must be a function");if(n=r(t,e),!d(n))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return n},this.#D=(t,n,r)=>{if(e[t]=n,this.#n){const n=this.#n-e[t];for(;this.#c>n;)this.#H(!0)}this.#c+=e[t],r&&(r.entrySize=n,r.totalCalculatedSize=this.#c)}}#k=e=>{};#D=(e,t,n)=>{};#G=(e,t,n,r)=>{if(n||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#P({allowStale:e=this.allowStale}={}){if(this.#a)for(let t=this.#f;this.#F(t)&&(!e&&this.#x(t)||(yield t),t!==this.#m);)t=this.#p[t]}*#M({allowStale:e=this.allowStale}={}){if(this.#a)for(let t=this.#m;this.#F(t)&&(!e&&this.#x(t)||(yield t),t!==this.#f);)t=this.#h[t]}#F(e){return void 0!==e&&this.#l.get(this.#u[e])===e}*entries(){for(const e of this.#P())void 0===this.#d[e]||void 0===this.#u[e]||this.#T(this.#d[e])||(yield[this.#u[e],this.#d[e]])}*rentries(){for(const e of this.#M())void 0===this.#d[e]||void 0===this.#u[e]||this.#T(this.#d[e])||(yield[this.#u[e],this.#d[e]])}*keys(){for(const e of this.#P()){const t=this.#u[e];void 0===t||this.#T(this.#d[e])||(yield t)}}*rkeys(){for(const e of this.#M()){const t=this.#u[e];void 0===t||this.#T(this.#d[e])||(yield t)}}*values(){for(const e of this.#P())void 0===this.#d[e]||this.#T(this.#d[e])||(yield this.#d[e])}*rvalues(){for(const e of this.#M())void 0===this.#d[e]||this.#T(this.#d[e])||(yield this.#d[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,t={}){for(const n of this.#P()){const r=this.#d[n],o=this.#T(r)?r.__staleWhileFetching:r;if(void 0!==o&&e(o,this.#u[n],this))return this.get(this.#u[n],t)}}forEach(e,t=this){for(const n of this.#P()){const r=this.#d[n],o=this.#T(r)?r.__staleWhileFetching:r;void 0!==o&&e.call(t,o,this.#u[n],this)}}rforEach(e,t=this){for(const n of this.#M()){const r=this.#d[n],o=this.#T(r)?r.__staleWhileFetching:r;void 0!==o&&e.call(t,o,this.#u[n],this)}}purgeStale(){let e=!1;for(const t of this.#M({allowStale:!0}))this.#x(t)&&(this.#I(this.#u[t],"expire"),e=!0);return e}info(e){const t=this.#l.get(e);if(void 0===t)return;const n=this.#d[t],r=this.#T(n)?n.__staleWhileFetching:n;if(void 0===r)return;const o={value:r};if(this.#v&&this.#w){const e=this.#v[t],n=this.#w[t];if(e&&n){const t=e-(s.now()-n);o.ttl=t,o.start=Date.now()}}return this.#b&&(o.size=this.#b[t]),o}dump(){const e=[];for(const t of this.#P({allowStale:!0})){const n=this.#u[t],r=this.#d[t],o=this.#T(r)?r.__staleWhileFetching:r;if(void 0===o||void 0===n)continue;const i={value:o};if(this.#v&&this.#w){i.ttl=this.#v[t];const e=s.now()-this.#w[t];i.start=Math.floor(Date.now()-e)}this.#b&&(i.size=this.#b[t]),e.unshift([n,i])}return e}load(e){this.clear();for(const[t,n]of e){if(n.start){const e=Date.now()-n.start;n.start=s.now()-e}this.set(t,n.value,n)}}set(e,t,n={}){if(void 0===t)return this.delete(e),this;const{ttl:r=this.ttl,start:o,noDisposeOnSet:s=this.noDisposeOnSet,sizeCalculation:i=this.sizeCalculation,status:a}=n;let{noUpdateTTL:c=this.noUpdateTTL}=n;const l=this.#G(e,t,n.size||0,i);if(this.maxEntrySize&&l>this.maxEntrySize)return a&&(a.set="miss",a.maxEntrySizeExceeded=!0),this.#I(e,"set"),this;let u=0===this.#a?void 0:this.#l.get(e);if(void 0===u)u=0===this.#a?this.#f:0!==this.#g.length?this.#g.pop():this.#a===this.#t?this.#H(!1):this.#a,this.#u[u]=e,this.#d[u]=t,this.#l.set(e,u),this.#h[this.#f]=u,this.#p[u]=this.#f,this.#f=u,this.#a++,this.#D(u,l,a),a&&(a.set="add"),c=!1;else{this.#_(u);const n=this.#d[u];if(t!==n){if(this.#E&&this.#T(n)){n.__abortController.abort(new Error("replaced"));const{__staleWhileFetching:t}=n;void 0===t||s||(this.#A&&this.#r?.(t,e,"set"),this.#C&&this.#y?.push([t,e,"set"]))}else s||(this.#A&&this.#r?.(n,e,"set"),this.#C&&this.#y?.push([n,e,"set"]));if(this.#k(u),this.#D(u,l,a),this.#d[u]=t,a){a.set="replace";const e=n&&this.#T(n)?n.__staleWhileFetching:n;void 0!==e&&(a.oldValue=e)}}else a&&(a.set="update")}if(0===r||this.#v||this.#$(),this.#v&&(c||this.#L(u,r,o),a&&this.#O(a,u)),!s&&this.#C&&this.#y){const e=this.#y;let t;for(;t=e?.shift();)this.#o?.(...t)}return this}pop(){try{for(;this.#a;){const e=this.#d[this.#m];if(this.#H(!0),this.#T(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(void 0!==e)return e}}finally{if(this.#C&&this.#y){const e=this.#y;let t;for(;t=e?.shift();)this.#o?.(...t)}}}#H(e){const t=this.#m,n=this.#u[t],r=this.#d[t];return this.#E&&this.#T(r)?r.__abortController.abort(new Error("evicted")):(this.#A||this.#C)&&(this.#A&&this.#r?.(r,n,"evict"),this.#C&&this.#y?.push([r,n,"evict"])),this.#k(t),e&&(this.#u[t]=void 0,this.#d[t]=void 0,this.#g.push(t)),1===this.#a?(this.#m=this.#f=0,this.#g.length=0):this.#m=this.#h[t],this.#l.delete(n),this.#a--,t}has(e,t={}){const{updateAgeOnHas:n=this.updateAgeOnHas,status:r}=t,o=this.#l.get(e);if(void 0!==o){const e=this.#d[o];if(this.#T(e)&&void 0===e.__staleWhileFetching)return!1;if(!this.#x(o))return n&&this.#R(o),r&&(r.has="hit",this.#O(r,o)),!0;r&&(r.has="stale",this.#O(r,o))}else r&&(r.has="miss");return!1}peek(e,t={}){const{allowStale:n=this.allowStale}=t,r=this.#l.get(e);if(void 0===r||!n&&this.#x(r))return;const o=this.#d[r];return this.#T(o)?o.__staleWhileFetching:o}#S(e,t,n,r){const o=void 0===t?void 0:this.#d[t];if(this.#T(o))return o;const s=new l,{signal:i}=n;i?.addEventListener("abort",(()=>s.abort(i.reason)),{signal:s.signal});const a={signal:s.signal,options:n,context:r},c=(r,o=!1)=>{const{aborted:i}=s.signal,c=n.ignoreFetchAbort&&void 0!==r;if(n.status&&(i&&!o?(n.status.fetchAborted=!0,n.status.fetchError=s.signal.reason,c&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),i&&!c&&!o)return u(s.signal.reason);const l=d;return this.#d[t]===d&&(void 0===r?l.__staleWhileFetching?this.#d[t]=l.__staleWhileFetching:this.#I(e,"fetch"):(n.status&&(n.status.fetchUpdated=!0),this.set(e,r,a.options))),r},u=r=>{const{aborted:o}=s.signal,i=o&&n.allowStaleOnFetchAbort,a=i||n.allowStaleOnFetchRejection,c=a||n.noDeleteOnFetchRejection,l=d;if(this.#d[t]===d&&(c&&void 0!==l.__staleWhileFetching?i||(this.#d[t]=l.__staleWhileFetching):this.#I(e,"fetch")),a)return n.status&&void 0!==l.__staleWhileFetching&&(n.status.returnedStale=!0),l.__staleWhileFetching;if(l.__returned===l)throw r};n.status&&(n.status.fetchDispatched=!0);const d=new Promise(((t,r)=>{const i=this.#s?.(e,o,a);i&&i instanceof Promise&&i.then((e=>t(void 0===e?void 0:e)),r),s.signal.addEventListener("abort",(()=>{n.ignoreFetchAbort&&!n.allowStaleOnFetchAbort||(t(void 0),n.allowStaleOnFetchAbort&&(t=e=>c(e,!0)))}))})).then(c,(e=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=e),u(e)))),h=Object.assign(d,{__abortController:s,__staleWhileFetching:o,__returned:void 0});return void 0===t?(this.set(e,h,{...a.options,status:void 0}),t=this.#l.get(e)):this.#d[t]=h,h}#T(e){if(!this.#E)return!1;const t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof l}async fetch(e,t={}){const{allowStale:n=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:s=this.ttl,noDisposeOnSet:i=this.noDisposeOnSet,size:a=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:l=this.noUpdateTTL,noDeleteOnFetchRejection:u=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:d=this.allowStaleOnFetchRejection,ignoreFetchAbort:h=this.ignoreFetchAbort,allowStaleOnFetchAbort:p=this.allowStaleOnFetchAbort,context:m,forceRefresh:f=!1,status:g,signal:y}=t;if(!this.#E)return g&&(g.fetch="get"),this.get(e,{allowStale:n,updateAgeOnGet:r,noDeleteOnStaleGet:o,status:g});const b={allowStale:n,updateAgeOnGet:r,noDeleteOnStaleGet:o,ttl:s,noDisposeOnSet:i,size:a,sizeCalculation:c,noUpdateTTL:l,noDeleteOnFetchRejection:u,allowStaleOnFetchRejection:d,allowStaleOnFetchAbort:p,ignoreFetchAbort:h,status:g,signal:y};let w=this.#l.get(e);if(void 0===w){g&&(g.fetch="miss");const t=this.#S(e,w,b,m);return t.__returned=t}{const t=this.#d[w];if(this.#T(t)){const e=n&&void 0!==t.__staleWhileFetching;return g&&(g.fetch="inflight",e&&(g.returnedStale=!0)),e?t.__staleWhileFetching:t.__returned=t}const o=this.#x(w);if(!f&&!o)return g&&(g.fetch="hit"),this.#_(w),r&&this.#R(w),g&&this.#O(g,w),t;const s=this.#S(e,w,b,m),i=void 0!==s.__staleWhileFetching&&n;return g&&(g.fetch=o?"stale":"refresh",i&&o&&(g.returnedStale=!0)),i?s.__staleWhileFetching:s.__returned=s}}async forceFetch(e,t={}){const n=await this.fetch(e,t);if(void 0===n)throw new Error("fetch() returned undefined");return n}memo(e,t={}){const n=this.#i;if(!n)throw new Error("no memoMethod provided to constructor");const{context:r,forceRefresh:o,...s}=t,i=this.get(e,s);if(!o&&void 0!==i)return i;const a=n(e,i,{options:s,context:r});return this.set(e,a,s),a}get(e,t={}){const{allowStale:n=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:s}=t,i=this.#l.get(e);if(void 0!==i){const t=this.#d[i],a=this.#T(t);return s&&this.#O(s,i),this.#x(i)?(s&&(s.get="stale"),a?(s&&n&&void 0!==t.__staleWhileFetching&&(s.returnedStale=!0),n?t.__staleWhileFetching:void 0):(o||this.#I(e,"expire"),s&&n&&(s.returnedStale=!0),n?t:void 0)):(s&&(s.get="hit"),a?t.__staleWhileFetching:(this.#_(i),r&&this.#R(i),t))}s&&(s.get="miss")}#V(e,t){this.#p[t]=e,this.#h[e]=t}#_(e){e!==this.#f&&(e===this.#m?this.#m=this.#h[e]:this.#V(this.#p[e],this.#h[e]),this.#V(this.#f,e),this.#f=e)}delete(e){return this.#I(e,"delete")}#I(e,t){let n=!1;if(0!==this.#a){const r=this.#l.get(e);if(void 0!==r)if(n=!0,1===this.#a)this.#U(t);else{this.#k(r);const n=this.#d[r];if(this.#T(n)?n.__abortController.abort(new Error("deleted")):(this.#A||this.#C)&&(this.#A&&this.#r?.(n,e,t),this.#C&&this.#y?.push([n,e,t])),this.#l.delete(e),this.#u[r]=void 0,this.#d[r]=void 0,r===this.#f)this.#f=this.#p[r];else if(r===this.#m)this.#m=this.#h[r];else{const e=this.#p[r];this.#h[e]=this.#h[r];const t=this.#h[r];this.#p[t]=this.#p[r]}this.#a--,this.#g.push(r)}}if(this.#C&&this.#y?.length){const e=this.#y;let t;for(;t=e?.shift();)this.#o?.(...t)}return n}clear(){return this.#U("delete")}#U(e){for(const t of this.#M({allowStale:!0})){const n=this.#d[t];if(this.#T(n))n.__abortController.abort(new Error("deleted"));else{const r=this.#u[t];this.#A&&this.#r?.(n,r,e),this.#C&&this.#y?.push([n,r,e])}}if(this.#l.clear(),this.#d.fill(void 0),this.#u.fill(void 0),this.#v&&this.#w&&(this.#v.fill(0),this.#w.fill(0)),this.#b&&this.#b.fill(0),this.#m=0,this.#f=0,this.#g.length=0,this.#c=0,this.#a=0,this.#C&&this.#y){const e=this.#y;let t;for(;t=e?.shift();)this.#o?.(...t)}}}function g(e){window.$monomerHover=e}var y=n(2003),b=n(6077),w=n(3561),v=n(9235);const A="MonomerHoverLinks";async function E(e,t,n,r,s,i=!1){const a=r.getSeqHandler(e),c=a.alphabet==y.YI.RNA||a.alphabet==y.YI.DNA,l=a.isHelm()&&c,u=!a.isHelm()&&c,d=e=>null==e?null:l?i?e:Math.floor(e/3):u&&i?3*e+1:e,h=i?await r.getHelmToMolfileConverter(n):null,p=new f({max:100});function m(e,t){const a=e.get(t);if(null==a)return null;let c=p.get(a);return c||p.set(a,c=function(e,t){const a=r.getSeqHandler(e);if(i){const e=a.getHelm(t);return r.helmToAtomicLevelSingle(e,h,!1,!1).monomers}{const e=a.getSplitted(t),r=a.defaultBiotype,i=o().count(0).take(e.length).map((t=>({position:t,symbol:e.getCanonical(t),biotype:r}))).toArray(),c=a.alphabet,l=c==y.YI.RNA||c==y.YI.DNA?"RNA":"PEPTIDE",u=(0,b.eM)([i],l,c,n,s);return(0,w.gU)(i,u,c,l).monomers}}(e,t)),c}const E={targetCol:t,handler:(t,r,o)=>{const s=o.grid,i=t.tableRowIndex,a=t.gridRow,c=s.cell(o.name,a),l=null!==(u=window.$monomerHover)&&void 0!==u?u:null;var u;if(!l||l&&(l.dataFrameId!=e.dataFrame.id||l.gridRowIdx!=a||l.seqColName!=e.name||l.seqPosition!=r?.position)){if(l&&(g(null),l.gridCell.render()),!r)return g(null),!0;g({gridCell:c,dataFrameId:e.dataFrame.id,gridRowIdx:a,seqColName:e.name,seqPosition:d(r?.position)??-1,getSubstruct:()=>{if(!r||"*"===r.symbol)return;const t=m(e,i);if(!t)return;const o=t.get(d(r?.position));return o?(0,v.H)([o],n):{atoms:[],bonds:[],highlightAtomColors:[],highlightBondColors:[]}}}),c.render()}return!0},getSubstruct:r=>{if("true"!=t.getTag(".sequence-src-highlight-monomers"))return;if(null==r)return;if(!e.get(r))return;const o=m(e,r);return o?(0,v.H)(o.values(),n):void 0}};return function(e,t){let n=e[A];n||(n=e[A]=[]),n.push(t),e[A]=n}(e.temp,E),function(e,t){let n=e["substruct-providers"];n||(n=e["substruct-providers"]=[]),n.push(t),e["substruct-providers"]=n}(t.temp,E),E}function C(e,t){try{const n=e.tableColumn;if(!n)return;const r=function(e){return e.temp[A]??[]}(n);for(let n=r.length-1;n>=0;--n){const o=r[n],s=e.grid.col(o.targetCol.name);if(s&&!o.handler(e,t,s))break}}catch(e){console.error(e)}}},6718:(e,t,n)=>{"use strict";n.d(t,{A7:()=>c,pj:()=>i});var r=n(6082),o=n(4328),s=n(6295);async function i(){const e=r.Func.find({package:"Bio",name:"getMonomerLibHelper"});if(0===e.length)throw new Error('Package "Bio" must be installed for MonomerLibHelper.');return(await e[0].prepare().call()).getOutputParamValue()}async function a(e){const t=(await i()).getMonomerLib(),n=[],s={},a=e.map((e=>t.getMonomer("PEPTIDE",e)?.smiles??"")),c=r.Column.fromStrings("smiles",a);for(let t=0;t<a.length;++t){s[e[t]]=t;const r=a[t],i=""===r?new Array(a.length).fill(0):(await o.chem.getSimilarities(c,r)).getRawData();i[t]=1,n[t]=Array.from(i)}return{scoringMatrix:n,alphabetIndexes:s}}async function c(e,t="Morgan"){const n=(await i()).getMonomerLib(),o=new Array(e.length).fill(0).map((()=>new Array(e.length).fill(0))),c={},l=e.map((e=>n.getMonomer("PEPTIDE",e)?.molfile||n.getMonomer("PEPTIDE",e)?.smiles||"")),u=r.Func.find({package:"Chem",name:"getFingerprints"})[0];if(!u)return console.warn('Function "Chem:getFingerprints" is not found in chem package. falling back to Morgan fingerprints'),await a(e);const d=r.Column.fromStrings("smiles",l),h=(r.DataFrame.fromColumns([d]),(await u.apply({col:d,fingerprintType:t}))?.entries);if(!h)return console.warn(`${t} Fingerprints could not be calculated for monomers from chem package.\n falling back to Morgan fingerprints`),await a(e);for(let t=0;t<h.length;++t)if(o[t][t]=1,c[e[t]]=t,h[t])for(let e=t+1;e<h.length;++e)h[e]&&(o[t][e]=o[e][t]=(0,s.$1)(h[t],h[e]));return{scoringMatrix:o,alphabetIndexes:c}}n(3151),n(3077),n(439)},6197:(e,t,n)=>{"use strict";n.d(t,{Y:()=>o});var r=n(3599);function o(e){let t;switch(e){case r.o.BASE:case r.o.SUGAR:case r.o.LINKER:case r.o.NUCLEOTIDE:case"nucleotide":t="RNA";break;case r.o.AA:t="PEPTIDE";break;case r.o.CHEM:t="CHEM";break;case r.o.BLOB:t="BLOB";break;default:t="PEPTIDE",console.warn(`Unexpected HelmType '${e}'`)}return t}},9235:(e,t,n)=>{"use strict";n.d(t,{H:()=>l,R:()=>c});var r=n(6082),o=n(1991),s=n.n(o),i=n(330),a=n(3599);async function c(e,t,o,c,l,u,d){const h=e.length,p=e.dataFrame,m=Math.max(navigator.hardwareConcurrency-2,1),f=new Array(m).fill(null).map((()=>new Worker(new URL(n.p+n.u(455),n.b)))),g=h/m,y=new Array(m),b=u.getSeqHandler(e),w="RNA"==c?a.o.NUCLEOTIDE:a.o.AA,v=s().count(0).take(e.length).map((e=>{const t=b.getSplitted(e);return s().count(0).take(t.length).map((e=>({position:e,symbol:t.getCanonical(e),biotype:w}))).toArray()})).toArray();for(let e=0;e<m;e++){const n=f[e],r=Math.floor(e*g),s=e===m-1?h:Math.floor((e+1)*g);y[e]=new Promise((e=>{n.onmessage=t=>{e(t.data)}})),n.postMessage({seqList:v,monomersDict:t,alphabet:o,polymerType:c,start:r,end:s})}const A=[],E=[];await Promise.all(y).then((e=>{for(const t of e)A.push(...t.molfiles),E.push(...t.warnings)})),setTimeout((()=>{f.forEach((e=>{e.terminate()}))}),0);const C=(0,i.qj)(p,e.name),T=r.Column.fromType(r.COLUMN_TYPE.STRING,C,e.length).init((e=>A[e]?.molfile));return T.semType=r.SEMTYPE.MOLECULE,T.meta.units=r.UNITS.Molecule.MOLBLOCK,T.setTag(".sequence-src-col",e.name),{molCol:T,warnings:E}}function l(e,t){const n={},o={};for(const s of e){const e=t.getWebEditorMonomer(s.biotype,s.symbol).backgroundcolor,a=(0,i.vG)(e??r.Color.toRgb(r.Color.mouseOverRows))??[1,0,0,.7];for(const e of s.atoms)n[e]=a;for(const e of s.bonds)o[e]=a}return{atoms:Object.keys(n).map((e=>parseInt(e))),bonds:Object.keys(o).map((e=>parseInt(e))),highlightAtomColors:n,highlightBondColors:o}}},3561:(e,t,n)=>{"use strict";n.d(t,{Hb:()=>c,YN:()=>f,gU:()=>l});var r=n(8123),o=n(294),s=n(3151),i=n(439),a=n(6197);function c(e,t,n){const o=new Map;for(const a of e.getMonomerSymbolsByType(t)){const c=e.getMonomer(t,a);if("RNA"===t&&("Branch"===c.monomerType||n===i.YI.DNA&&c.symbol===r.u.DEOXYRIBOSE.symbol||n===i.YI.RNA&&c.symbol===r.u.RIBOSE.symbol||c.symbol===r.u.PHOSPHATE.symbol)||"PEPTIDE"===t&&"Branch"!==c.monomerType){const e={};s.f6.forEach((t=>{e[t]=c[t]})),o.set(c.symbol,e)}}return o}function l(e,t,n,s){if(0===e.length)return o.vF.createEmpty();const c=m,{atomCount:l,bondCount:d,needsCapping:p}=c(e,t,n,s),g=new Array(l),y=new Array(d);let b,w=null,v=null;"PEPTIDE"===s?b=u:(b=h,w=n===i.YI.DNA?(0,o.xb)(t,r.u.DEOXYRIBOSE):(0,o.xb)(t,r.u.RIBOSE),v=(0,o.xb)(t,r.u.PHOSPHATE));const A={i:0,nodeShift:0,bondShift:0,backbonePositionShift:new Array(2).fill(0),branchPositionShift:new Array(2).fill(0),backboneAttachNode:0,branchAttachNode:0,flipFactor:1},E={sugar:w,phosphate:v,seqLength:e.length,atomCount:l,bondCount:d},C=new o.Cg,T=[];let S,_=0;for(A.i=0;A.i<E.seqLength;++A.i){const n=e[A.i];if(n.symbol===i._S)continue;const r=(0,o.xb)(t,{symbol:n.symbol,polymerType:(0,a.Y)(n.biotype)});S=r.terminalR2Atom;const s=A.nodeShift,c=A.bondShift;b(r,g,y,A,E),r.stereoAtoms?.forEach((e=>T.push(e+_))),_+=r.atoms.x.length;const l=A.nodeShift-s,u=new Array(l);for(let e=0;e<l;++e)u[e]=s+e;const d=A.bondShift-c,h=new Array(d);for(let e=0;e<d;++e)h[e]=c+e;C.set(A.i,{biotype:n.biotype,symbol:n.symbol,atoms:u,bonds:h})}p&&function(e,t,n,o,s=r.u.OXYGEN){const i=n.nodeShift+1;e[o.atomCount]=r.u.V3K_BEGIN_DATA_LINE+i+" "+(s??r.u.OXYGEN)+" "+f(n.backbonePositionShift[0])+" "+n.flipFactor*f(n.backbonePositionShift[1])+" 0.000000 0\n";const a=n.backboneAttachNode,c=i;t[o.bondCount]=r.u.V3K_BEGIN_DATA_LINE+n.bondShift+" 1 "+a+" "+c+"\n"}(g,y,A,E,S??r.u.OXYGEN);const P=r.u.V3K_BEGIN_COUNTS_LINE+l+" "+d+r.u.V3K_COUNTS_LINE_ENDING;let M="";return M+=r.u.V3K_HEADER_FIRST_LINE,M+=r.u.V3K_HEADER_SECOND_LINE,M+=r.u.V3K_BEGIN_CTAB_BLOCK,M+=P,M+=r.u.V3K_BEGIN_ATOM_BLOCK,M+=g.join(""),M+=r.u.V3K_END_ATOM_BLOCK,M+=r.u.V3K_BEGIN_BOND_BLOCK,M+=y.join(""),M+=r.u.V3K_END_BOND_BLOCK,T.length>0&&(M+=function(e){const t=[];let n=`M V30 MDLV30/STEABS ATOMS=(${e.length}`;for(let r=0;r<e.length;r++){const o=`${n} ${e[r]}`;o.length>76?(t.push(`${n} -\n`),n=`M V30 ${e[r]}`):n=o,r===e.length-1&&t.push(`${n})\n`)}return`M V30 BEGIN COLLECTION\n${t.join("")}M V30 END COLLECTION\n`}(T)),M+=r.u.V3K_END_CTAB_BLOCK,M+=r.u.V3K_END,{molfile:M,monomers:C}}function u(e,t,n,r){r.flipFactor=(-1)**(r.i%2),d(e,t,n,r)}function d(e,t,n,o){!function(e,t,n){for(let o=0;o<e.atoms.atomTypes.length;++o){const s=n.nodeShift+o+1;t[n.nodeShift+o]=r.u.V3K_BEGIN_DATA_LINE+s+" "+e.atoms.atomTypes[o]+" "+f(n.backbonePositionShift[0]+e.atoms.x[o])+" "+f(n.backbonePositionShift[1]+n.flipFactor*e.atoms.y[o])+" "+e.atoms.kwargs[o]}}(e,t,o),p(e,n,o),function(e,t,n){if(0!==n.backboneAttachNode){const o=n.bondShift,s=n.backboneAttachNode,i=e.meta.terminalNodes[0]+n.nodeShift;t[n.bondShift-1]=r.u.V3K_BEGIN_DATA_LINE+o+" 1 "+s+" "+i+"\n"}}(e,n,o),null!==e.meta.branchShift&&e.meta.terminalNodes.length>2&&function(e,t){t.branchAttachNode=t.nodeShift+e.meta.terminalNodes[2];for(let n=0;n<2;++n)t.branchPositionShift[n]=t.backbonePositionShift[n]+e.meta.branchShift[n]}(e,o),function(e,t){t.backboneAttachNode=t.nodeShift+e.meta.terminalNodes[1],t.bondShift+=e.bonds.atomPairs.length+1,t.nodeShift+=e.atoms.atomTypes.length,t.backbonePositionShift[0]+=e.meta.backboneShift?.[0]??0,t.backbonePositionShift[1]+=t.flipFactor*(e.meta.backboneShift?.[1]??0)}(e,o)}function h(e,t,n,o,s){if(0===o.i)d(s.sugar,t,n,o);else for(const e of[s.phosphate,s.sugar])d(e,t,n,o);!function(e,t,n,o){(function(e,t,n){for(let o=0;o<e.atoms.atomTypes.length;++o){const s=n.nodeShift+o+1;t[n.nodeShift+o]=r.u.V3K_BEGIN_DATA_LINE+s+" "+e.atoms.atomTypes[o]+" "+f(n.branchPositionShift[0]+e.atoms.x[o])+" "+f(n.branchPositionShift[1]+n.flipFactor*e.atoms.y[o])+" "+e.atoms.kwargs[o]}})(e,t,o),p(e,n,o),function(e,t,n){const o=n.bondShift,s=n.branchAttachNode,i=e.meta.terminalNodes[0]+n.nodeShift;t[o-1]=r.u.V3K_BEGIN_DATA_LINE+o+" 1 "+s+" "+i+"\n"}(e,n,o);const s=o.bondShift,i=o.branchAttachNode,a=e.meta.terminalNodes[0]+o.nodeShift;n[s-1]=r.u.V3K_BEGIN_DATA_LINE+s+" 1 "+i+" "+a+"\n",o.bondShift+=e.bonds.atomPairs.length+1,o.nodeShift+=e.atoms.atomTypes.length}(e,t,n,o)}function p(e,t,n){for(let o=0;o<e.bonds.atomPairs.length;++o){const s=n.bondShift+o+1,i=e.bonds.atomPairs[o][0]+n.nodeShift,a=e.bonds.atomPairs[o][1]+n.nodeShift;let c="";if(e.bonds.bondConfiguration.has(o)){let t=e.bonds.bondConfiguration.get(o);n.flipFactor<0&&(t=1===t?3:1),c=" CFG="+t}const l=e.bonds.kwargs.has(o)?" "+e.bonds.kwargs.get(o):"";t[n.bondShift+o]=r.u.V3K_BEGIN_DATA_LINE+s+" "+e.bonds.bondTypes[o]+" "+i+" "+a+c+l+"\n"}}function m(e,t,n,s){let c=0,l=0,u=0,d=!0,h=null;for(const n of e)if(n.symbol!==i._S){if("*"==n.symbol)throw new Error("Gap canonical symbol is '', not '*");h=(0,o.xb)(t,{symbol:n.symbol,polymerType:(0,a.Y)(n.biotype)}),c+=h.atoms.x.length,l+=h.bonds.bondTypes.length,u++}if("PEPTIDE"===s)c+=1,l+=u,u>0&&((h?.meta?.rNodes?.length??0)<2||h?.terminalR2Atom?.toLowerCase()===r.u.HYDROGEN.toLowerCase())&&(d=!1,c-=1,l-=1);else{const s=n===i.YI.DNA?(0,o.xb)(t,r.u.DEOXYRIBOSE):(0,o.xb)(t,r.u.RIBOSE),a=(0,o.xb)(t,r.u.PHOSPHATE);c+=(e.length-1)*a.atoms.x.length,c+=e.length*s.atoms.x.length,c+=1,l+=(e.length-1)*a.bonds.bondTypes.length,l+=e.length*s.bonds.bondTypes.length,l-=1,l+=3*e.length}return{atomCount:c,bondCount:l,needsCapping:d}}function f(e){return Math.round(r.u.PRECISION_FACTOR*e)/r.u.PRECISION_FACTOR}},6077:(e,t,n)=>{"use strict";n.d(t,{C4:()=>m,eM:()=>f});var r=n(4328),o=n(6082),s=n(1991),i=n.n(s),a=n(439),c=n(3561),l=n(9235),u=n(294),d=n(9192),h=n(330),p=n(8123);async function m(e,t,n,s,c){if(t.semType!==o.SEMTYPE.MACROMOLECULE)return{molCol:null,warnings:[`Only the ${o.SEMTYPE.MACROMOLECULE} columns can be converted to atomic level, the chosen column has semType '${t.semType}'`]};let u=t;const p=s.getSeqHandler(t);let m,g;p.notation!==a.Hi.SEPARATOR&&(u=p.convert(a.Hi.SEPARATOR,"."),u.name=t.name);try{g=s.getSeqHandler(u).alphabet,m=(0,h.pz)(g)}catch(e){const[t,n]=(0,d.AP)(e);return{molCol:null,warnings:[t]}}const y=function(e,t){const n=e.length,o=new Array(n),s=t.getSeqHandler(e);let a=!1;const c=s.defaultBiotype;for(let e=0;e<n;++e){const t=s.getSplitted(e);a||(a=0===t.length),o[e]=i().count(0).take(t.length).filter((e=>!t.isGap(e))).map((e=>({position:e,biotype:c,symbol:t.getCanonical(e)}))).toArray()}return a&&r.shell.warning(`Some values in the "${e.name}" column are empty`),o}(u,s),b=f(y,m,g,n,c),w=u.length,v=await(0,l.R)(u,b,g,m,n,s,c);return v.warnings.length>.05*w&&r.shell.warning(`Molfile conversion resulted in ${v.warnings.length} errors`),v}function f(e,t,n,r,o){const s=(0,c.Hb)(r,t,n),i={},l={value:null};if("RNA"===t){const e=n===a.YI.RNA?[p.u.RIBOSE,p.u.PHOSPHATE]:[p.u.DEOXYRIBOSE,p.u.PHOSPHATE];for(const n of e)g(i,n.symbol,s,o,t,l)}for(let n=0;n<e.length;++n){const r=e[n];for(const e of r){const n=e.symbol;if(""!==n)try{if("RNA"===t&&3===n.split(/\(|\)/).filter((e=>!!e)).length){const e=n.split(/\(|\)/)[1];g(i,e,s,o,t,l),i[t]?.[e]&&(i[t][n]=i[t][e])}else g(i,n,s,o,t,l)}catch(e){const t=e instanceof Error?e.message:e.toString(),r=e instanceof Error?e.stack:void 0;throw console.error(`bio lib: getMonomersDictFromLib() sym='${n}', error:\n${t}\n${r}`),new Error(`Can't get monomer '${n}' from library: ${t}`)}}}return i}function g(e,t,n,r,o,s){const i={polymerType:o,symbol:t};if(!(0,u.bq)(e,i)){const a=function(e,t,n,r,o){if(t.has(e)){const i=t.get(e),a=function(e){const t=[];for(const n of e){let e=n.capGroupSmiles;e||(e=n.capGroupSMILES),e=e.replace(/(\[|\]|\*|:|\d)/g,"").replace("OH","O").replace("Oh","O"),t.push(e)}return t}(i.rgroups),l=(s=i.molfile).includes("V3000")?function(e){const t=new Map,n=/M V30 (\d+) R#.+RGROUPS=\((\d+) (\d+)\).*/gm;let r;for(;null!==(r=n.exec(e));)r.index===n.lastIndex&&n.lastIndex++,t.set(parseInt(r[1]),parseInt(r[3]));return t}(s):function(e){const t=new Map;let n=e.indexOf(p.u.V2K_A_LINE,0),r=n;for(;-1!==n;){r=e.indexOf("\n",n);const o=parseInt(e.substring(n,r).replace(/^A\s+/,""));n=e.indexOf("R",r),r=e.indexOf("\n",n);const s=parseInt(e.substring(n,r).replace(/^R/,""));t.set(o,s),n=e.indexOf(p.u.V2K_A_LINE,r)}for(n=e.indexOf(p.u.V2K_RGP_LINE,0),r=e.indexOf("\n",n);-1!==n;){n+=p.u.V2K_RGP_SHIFT,r=e.indexOf("\n",n);const o=e.substring(n,r).replaceAll(/\s+/g," ").split(" ").map((e=>parseInt(e))).slice(1);for(let e=0;e<o.length;e+=2){if(t.has(o[e])&&t.get(o[e])!==o[e+1])throw new Error(`r-group index ${o[e]} has already been added with a different value`);t.set(o[e],o[e+1])}n=e.indexOf(p.u.V2K_RGP_LINE,r)}return t}(s),u=i.molfile.includes("V3000")?i.molfile:function(e,t){const n=t.get_mol(function(e){return e.split("\n").map((e=>{const t=e.indexOf(" R# "),n=e.indexOf(" R ");if(-1===t&&-1===n)return e;const r=-1!==t?t:n,o=e.split("");for(let e=r+5;e<o.length;e++)" "!==o[e]&&(o[e]="0");return o.join("")})).join("\n")}(e)),r=n.get_v3Kmolblock();return n.delete(),r}(function(e){let t=e.indexOf(p.u.V2K_A_LINE,0);-1===t&&(t=e.indexOf(p.u.V2K_RGP_LINE));const n=e.indexOf(p.u.V3K_END,t);return e.substring(0,t)+e.substring(n)}(i.molfile),n),d=function(e){let t=(e=e.replaceAll("\r","")).indexOf(p.u.V3K_BEGIN_COUNTS_LINE)+p.u.V3K_COUNTS_SHIFT,n=e.indexOf(" ",t+1);const r=parseInt(e.substring(t,n));return t=n+1,n=e.indexOf(" ",t+1),{atomCount:r,bondCount:parseInt(e.substring(t,n))}}(u),h=function(e,t){const n=new Array(t),r=new Float32Array(t),o=new Float32Array(t),s=new Array(t);let i=e.indexOf(p.u.V3K_BEGIN_ATOM_BLOCK);i=e.indexOf("\n",i);let a=i;for(let c=0;c<t;c++){i=e.indexOf(p.u.V3K_BEGIN_DATA_LINE,i)+p.u.V3K_IDX_SHIFT,a=e.indexOf(" ",i),i=a+1,a=e.indexOf(" ",i),n[c]=e.substring(i,a);const t=new Array(2);for(let n=0;n<2;++n)i=a+1,a=e.indexOf(" ",i),t[n]=parseFloat(e.substring(i,a));r[c]=t[0],o[c]=t[1],i=a,a=e.indexOf("\n",i)+1,s[c]=e.slice(i,a),i=a}return{atomTypes:n,x:r,y:o,kwargs:s}}(u,d.atomCount),m=function(e,t){const n=new Uint32Array(t),r=new Array(t),o=new Map,s=new Map;let i=e.indexOf(p.u.V3K_BEGIN_BOND_BLOCK);i=e.indexOf("\n",i);let a=i;for(let c=0;c<t;++c){const t=new Array(3);i=e.indexOf(p.u.V3K_BEGIN_DATA_LINE,a)+p.u.V3K_IDX_SHIFT,a=e.indexOf(" ",i);for(let n=0;n<3;++n)i=a+1,a=Math.min(e.indexOf("\n",i),e.indexOf(" ",i)),t[n]=parseInt(e.slice(i,a));n[c]=t[0],r[c]=t.slice(1);const l=e.indexOf("\n",i);let u=e.slice(a,l),d=u.indexOf(p.u.V3K_BOND_CONFIG);if(-1!==d){d=u.indexOf("=",d)+1;let e=u.indexOf(" ",d);-1===e&&(e=u.length);const t=parseInt(u.slice(d,e));o.set(c,t);const n=p.u.V3K_BOND_CONFIG+t.toString();u=u.replace(n,"")}u||s.set(c,u)}return{bondTypes:n,atomPairs:r,bondConfiguration:o,kwargs:s}}(u,d.bondCount),f=function(e,t,n,r){const o={backboneShift:null,branchShift:null,terminalNodes:[],rNodes:[]};if(n&&r&&[1,2].some((e=>!Array.from(r.values()).find((t=>t==e))))){const o=[1,2].find((e=>!Array.from(r.values()).find((t=>t==e)))),s=[1,2].find((e=>Array.from(r.values()).find((t=>t==e)))),i=Array.from(r.keys()).find((e=>r.get(e)===s))-1,a=e.x[i],c=e.y[i],l=t.atomPairs.find((e=>e.includes(i+1))).find((e=>e!==i+1))-1;let u=e.x.reduce(((t,n,r)=>{if(r===i)return t;if(r===l)return t;const o=e.y[r];return Math.sqrt((n-a)**2+(o-c)**2)>Math.sqrt((e.x[t]-a)**2+(e.y[t]-c)**2)?r:t}),-1);if(-1===u&&(u=e.x.length,e.x=new Float32Array([...e.x,-a]),e.y=new Float32Array([...e.y,-c]),e.atomTypes=[...e.atomTypes,"H"],e.kwargs=[...e.kwargs,""],t.atomPairs.push([l+1,u+1]),t.bondTypes=new Uint32Array([...t.bondTypes,1]),t.kwargs.set(t.atomPairs.length-1,"")),r.set(u+1,o),1===o)n.unshift(e.atomTypes[u]);else{if(2!==o)throw new Error(`Unexpected missing R-group: ${o}`);n.splice(1,0,e.atomTypes[u])}}return function(e,t,n){for(const[r,o]of n)e.atomTypes[r-1]=t[o-1]}(e,n,r),function(e,t){t.rNodes=Array.from(e.keys());for(let n=0;n<t.rNodes.length;n++)for(const r of[1,2])if(e.get(t.rNodes[n])===r){const e=t.rNodes[r-1];t.rNodes[r-1]=t.rNodes[n],t.rNodes[n]=e}}(r,o),y(t,o),o}(h,m,a,l),g=function(e){let t=[],n=e.indexOf("M V30 MDLV30/STEABS ATOMS=(");for(;-1!==n;){n+=28;const r=e.indexOf(")",n);t=t.concat(e.substring(n,r).split(" ").slice(1).map((e=>parseInt(e)))),n=r,n=e.indexOf("M V30 MDLV30/STEABS ATOMS=(",n)}return t}(u),w={atoms:h,bonds:m,meta:f,stereoAtoms:g};return"PEPTIDE"===r?function(e){const t=e.meta.terminalNodes[0]-1,n=e.meta.rNodes[0]-1,r=e.atoms.x,o=e.atoms.y;_(e,-r[t],-o[t]);const s=E(r[n],o[n]);C(e.atoms,-s),r[e.meta.rNodes[1]-1]<0&&T(e);const i=function(e){const t=function(e){const t=new Map;for(const n of e.bonds.atomPairs)for(let e=0;e<2;e++){const r=n[e],o=n[(e+1)%2];t.has(r)?t.get(r)?.push(o):t.set(r,new Array(1).fill(o))}return t}(e);let n=0;const r=e.atoms.atomTypes.length;let o=0;if(e.meta.terminalNodes.length<2)return null;for(;0===n;){const s=t.get(e.meta.terminalNodes[1])[o];if(e.atoms.atomTypes[s-1]===p.u.OXYGEN&&s!==e.meta.rNodes[1]&&(n=s),o++,o>r)return null}return n}(e);null!=i&&(function(e,t){e.atoms.y[e.meta.rNodes[1]-1]<0&&e.atoms.y[t-1]<0&&(function(e){S(e,!0)}(e),C(e.atoms,-function(e,t){return E(e,t)+Math.PI/2}(e.atoms.x[e.meta.terminalNodes[1]-1],e.atoms.y[e.meta.terminalNodes[1]-1])))}(e,i),function(e,t){const n=e.atoms.x;n[e.meta.rNodes[1]-1]>n[t-1]&&function(e,t,n){const r=t-1,o=n-1,s=e.atoms.x,i=e.atoms.y,a=s[r],c=i[r];s[r]=s[o],i[r]=i[o],s[o]=a,i[o]=c}(e,t,e.meta.rNodes[1])}(e,i))}(w):e===p.u.RIBOSE.symbol||e===p.u.DEOXYRIBOSE.symbol?function(e,t){const n=e.atoms.x,r=e.atoms.y;let o=e.meta.terminalNodes[0]-1;const s=e.meta.rNodes[1]-1;_(e,-n[o],-r[o]);const i=E(n[e.meta.rNodes[2]-1],r[e.meta.rNodes[2]-1]);C(e.atoms,-i),n[e.meta.rNodes[0]-1]>n[e.meta.rNodes[1]-1]&&T(e);const a=E(n[s],r[s]);C(e.atoms,3*Math.PI/2-a),t.value=function(e){const t=e.atoms.x,n=e.atoms.y,r=e.meta.rNodes[2]-1,o=e.meta.terminalNodes[2]-1,s=t[r]-t[o],i=n[r]-n[o];return Math.atan2(s,i)}(e),o=e.meta.terminalNodes[0]-1,_(e,-n[o],-r[o])}(w,o):e===p.u.PHOSPHATE.symbol?function(e){const t=e.meta.rNodes[1]-1,n=e.meta.rNodes[0]-1,r=e.atoms.x,o=e.atoms.y;_(e,-r[t],-o[t]);const s=E(r[n],o[n]);C(e.atoms,Math.PI/2-s)}(w):function(e,t){const n=e.atoms.x,r=e.atoms.y,o=e.meta.terminalNodes[0]-1,s=e.meta.rNodes[0]-1;_(e,-n[o],-r[o]);const i=E(n[s],r[s]),a=t.value;if(!a)throw new Error("The value of sugarBranchToOYAngle is null");C(e.atoms,Math.PI-i+a);const l=function(e,t){return(0,c.YN)(Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2))}({x:n[e.meta.rNodes[0]-1],y:r[e.meta.rNodes[0]-1]},{x:n[e.meta.terminalNodes[0]-1],y:r[e.meta.terminalNodes[0]-1]});if(1!=l)for(let e=0;e<n.length;++e)n[e]=(0,c.YN)(n[e]/l),r[e]=(0,c.YN)(r[e]/l)}(w,o),function(e,t,n){if("PEPTIDE"===e){b(t,e);const n=v(t,t.meta.rNodes[1]);n?.removedAtom&&(t.terminalR2Atom=n.removedAtom)}else n===p.u.RIBOSE.symbol||n===p.u.DEOXYRIBOSE.symbol?(v(t,t.meta.rNodes[1]),t.meta.rNodes[1]=t.meta.terminalNodes[1],y(t.bonds,t.meta),b(t,e),v(t,t.meta.rNodes[1]),v(t,t.meta.rNodes[0]),v(t,t.meta.rNodes[2])):n===p.u.PHOSPHATE.symbol&&(t.meta.terminalNodes[0]=t.meta.rNodes[0],_(t,-t.atoms.x[t.meta.terminalNodes[0]-1],-t.atoms.y[t.meta.terminalNodes[0]-1]),b(t,e),v(t,t.meta.rNodes[1]))}(r,w,e),function(e){let t=0;for(;t<e.atoms.atomTypes.length;)e.atoms.atomTypes[t]===p.u.HYDROGEN&&(v(e,t+1),--t),++t}(w),function(e){let t=0;for(;t<e.atoms.atomTypes.length;)"oh"===e.atoms.atomTypes[t]?.toLowerCase()&&(e.atoms.atomTypes[t]="O"),"?"===e.atoms.atomTypes[t]&&(e.atoms.atomTypes[t]="H"),++t}(w),function(e){const t=" RGROUPS=(1 1)";for(let n=0;n<(e.atoms.kwargs?.length??0);n++){const r=e.atoms.kwargs[n];r&&r.includes(t)&&(e.atoms.kwargs[n]=r.replace(t,""))}}(w),w}var s;return null}(t,n,r,o,s);if(!a)throw new Error(`Monomer with symbol '${t}' is absent the monomer library`);(0,u.LQ)(e,i,a)}}function y(e,t){const n=t.rNodes;t.terminalNodes=new Array(n.length).fill(0);const r=t.terminalNodes,o=e.atomPairs;let s=0,i=0;for(;s<o.length&&i<r.length;){for(let e=0;e<r.length;++e)for(let t=0;t<2;++t)o[s][t]===n[e]&&(r[e]=o[s][(t+1)%2],n.length,++i);++s}}function b(e,t){e.meta.rNodes.length>1&&(e.meta.backboneShift=w(e,e.meta.rNodes[1]-1,e.meta.terminalNodes[0]-1)),"RNA"===t&&e.meta.rNodes.length>2&&(e.meta.branchShift=w(e,e.meta.rNodes[2]-1,e.meta.terminalNodes[0]-1))}function w(e,t,n){return[(0,c.YN)(e.atoms.x[t]-e.atoms.x[n]),(0,c.YN)(e.atoms.y[t]-e.atoms.y[n])]}function v(e,t){if(void 0!==t){const n=t-1,r=e.atoms,o=e.bonds,s=e.meta,i=r.atomTypes.splice(n,1)[0];r.x=A(Float32Array,r.x,n,1),r.y=A(Float32Array,r.y,n,1),r.kwargs.splice(n,1);for(let e=0;e<s.terminalNodes.length;++e)s.terminalNodes[e]>t?--s.terminalNodes[e]:s.terminalNodes[e]===t&&(s.terminalNodes[e]=-1);for(let e=0;e<s.rNodes.length;++e)s.rNodes[e]>t?--s.rNodes[e]:s.rNodes[e]===t&&(s.rNodes[e]=-1);let a=0;for(;a<o.atomPairs.length;){const e=o.atomPairs[a][0],n=o.atomPairs[a][1];e===t||n===t?(o.atomPairs.splice(a,1),o.bondTypes=A(Uint32Array,o.bondTypes,a,1),o.bondConfiguration.has(a)&&o.bondConfiguration.delete(a),o.kwargs.has(a)&&o.kwargs.delete(a),--a):(o.atomPairs[a][0]=e>t?e-1:e,o.atomPairs[a][1]=n>t?n-1:n),++a}let c=Array.from(o.bondConfiguration.keys());return c.forEach((e=>{if(o.bondConfiguration.has(e)&&e>n){const t=o.bondConfiguration.get(e);o.bondConfiguration.delete(e),o.bondConfiguration.set(e-1,t)}})),c=Array.from(o.kwargs.keys()),c.forEach((e=>{if(o.kwargs.has(e)&&e>n){const t=o.kwargs.get(e);o.kwargs.delete(e),o.kwargs.set(e-1,t)}})),i?{removedAtom:i}:void 0}}function A(e,t,n,r){const o=new e(t.length-r);let s=0,i=0;for(;s<t.length;)s===n&&(s+=r),o[i]=t[s],++i,++s;return o}function E(e,t){let n;if(0===e)n=t>0?0:Math.PI;else if(0===t)n=e>0?-Math.PI/2:Math.PI/2;else{const r=t/e,o=Math.atan(r);n=e<0?Math.PI/2+o:-Math.PI/2+o}return n}function C(e,t){if(0!==t){const n=e.x,r=e.y,o=Math.cos(t),s=Math.sin(t);for(let e=0;e<n.length;++e){const t=n[e];n[e]=(0,c.YN)(t*o-r[e]*s),r[e]=(0,c.YN)(t*s+r[e]*o)}}}function T(e){S(e,!1)}function S(e,t){if(t){const t=e.atoms.y;for(let e=0;e<t.length;e++)t[e]=-t[e]}else{const t=e.atoms.x;for(let e=0;e<t.length;e++)t[e]=-t[e]}const n=e.bonds.bondConfiguration;for(const[e,t]of n){const r=1===t?3:1;n.set(e,r)}}function _(e,t,n){const r=e.atoms.x,o=e.atoms.y;for(let e=0;e<r.length;++e)r[e]=(0,c.YN)(r[e]+t),void 0!==n&&(o[e]=(0,c.YN)(o[e]+n))}},294:(e,t,n)=>{"use strict";function r(e,t){return e[t.polymerType]?.[t.symbol]}function o(e,t){return!!e[t.polymerType]?.[t.symbol]}function s(e,t,n){let r=e[t.polymerType];r||(r=e[t.polymerType]={}),r[t.symbol]=n}n.d(t,{Cg:()=>i,LQ:()=>s,bq:()=>o,vF:()=>a,xb:()=>r});class i extends Map{constructor(e){super(e)}}class a{constructor(e,t){this.molfile=e,this.monomers=t}static createEmpty(){return new a("",new i(null))}}},330:(e,t,n)=>{"use strict";n.d(t,{pz:()=>s,qj:()=>o,vG:()=>i});var r=n(2003);function o(e,t){return function(e,t){return e?e.columns.getUnusedName(t):t}(e,`molfile(${t})`)}function s(e){let t;if(e===r.YI.PT||e===r.YI.UN)t="PEPTIDE";else{if(e!==r.YI.RNA&&e!==r.YI.DNA)throw new Error(`Unexpected alphabet '${e}'.`);t="RNA"}return t}function i(e){const t=7===e.length?/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e):/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?[parseInt(t[1],16)/256,parseInt(t[2],16)/256,parseInt(t[3],16)/256,t.length>4?parseInt(t[4],16)/256:.3]:null}},1093:(e,t,n)=>{"use strict";n.d(t,{A:()=>o,Q:()=>s});var r=n(7362);class o extends r.e{static get Chromatogram(){return void 0===this.chromatogram&&(this.chromatogram=new o({A:"green",C:"blue",G:"black",T:"red",U:"red",others:"gray"})),this.chromatogram}}class s{}s.SemType="Nucleotides",s.SemTypeMultipleAlignment="NucleotidesMultipleAlignment",s.Names={A:"Adenine",C:"Cytosine",G:"Guanine",T:"Thymine",U:"Uracil"}},7362:(e,t,n)=>{"use strict";n.d(t,{e:()=>r});class r{static makePalette(e,t=!1,n=r){const o={};return e.forEach((e=>{const n=e[0],r=e[1];n.forEach(((e,n)=>{o[e]=this.colourPalette[r][t?0:n]}))})),new n(o)}constructor(e){this._palette=e}get(e,t){return this._palette[e]}}r.undefinedColor="rgb(100,100,100)",r.colourPalette={orange:["rgb(255,187,120)","rgb(245,167,100)","rgb(235,137,70)","rgb(205, 111, 71)"],all_green:["rgb(44,160,44)","rgb(74,160,74)","rgb(23,103,57)","rgb(30,110,96)","rgb(60,131,95)","rgb(24,110,79)","rgb(152,223,138)","rgb(182, 223, 138)","rgb(152, 193, 138)"],all_blue:["rgb(31,119,180)","rgb(23,190,207)","rgb(122, 102, 189)","rgb(158,218,229)","rgb(141, 124, 217)","rgb(31, 120, 150)"],magenta:["rgb(162,106,192)","rgb(197,165,224)","rgb(208,113,218)"],red:["rgb(214,39,40)","rgb(255,152,150)"],st_blue:["rgb(23,190,207)","rgb(158,218,229)","rgb(31,119,180)"],dark_blue:["rgb(31,119,180)","rgb(31, 120, 150)"],light_blue:["rgb(23,190,207)","rgb(158,218,229)","rgb(108, 218, 229)","rgb(23,190,227)"],lilac_blue:["rgb(124,102,211)","rgb(149,134,217)","rgb(97, 81, 150)"],dark_green:["rgb(23,103,57)","rgb(30,110,96)","rgb(60,131,95)","rgb(24,110,79)"],green:["rgb(44,160,44)","rgb(74,160,74)"],light_green:["rgb(152,223,138)","rgb(182, 223, 138)","rgb(152, 193, 138)"],st_green:["rgb(44,160,44)","rgb(152,223,138)","rgb(39, 174, 96)","rgb(74,160,74)"],pink:["rgb(247,182,210)"],brown:["rgb(140,86,75)","rgb(102, 62, 54)"],gray:["rgb(127,127,127)","rgb(199,199,199)","rgb(196,156,148)","rgb(222, 222, 180)"],yellow:["rgb(188,189,34)"],white:["rgb(230,230,230)"]}},4574:(e,t,n)=>{"use strict";n.d(t,{O:()=>s,n:()=>o});var r=n(1858);class o{constructor(e,t=!0,n){return this.substructure=e,this.readOnly=t,this.logger=n,new Proxy(this,{set:(e,t,n)=>{if(this.logger?.debug(`BioFilterProps.set ${t.toString()}( '${n}' )`),this.readOnly)throw new Error("Properties are immutable.");return e[t]=n,!0}})}}class s{constructor(){this.onChanged=new r.Subject,this._props=null,this._propsChanging=!1}get props(){return this._props||(this._props=this.emptyProps),this._props}set props(e){this._propsChanging=!0;try{this._props=e,this.applyProps(),this.onChanged.next()}finally{this._propsChanging=!1}}saveProps(){const e={};for(const[t,n]of Object.entries(this.props))"_onChanged"!==t&&"logger"!==t&&(e[t]=this.props[t]);return e}async detach(){}get filterSummary(){return this.props.substructure}get isFiltering(){return""!==this.props.substructure}resetFilter(){this.props=this.emptyProps,this.onChanged.next()}}},4152:(e,t,n)=>{"use strict";n.d(t,{$u:()=>c,oT:()=>d});var r=n(6082),o=n(7362),s=n(6718);function i(e,t=!0){if(null==e)return"rgb(100,100,100)";const n=r.Color.fromHtml(e);if(t){const e=r.Color.g(n),t=r.Color.r(n),o=r.Color.b(n),s=Math.sqrt(Math.pow(0-t,2)+Math.pow(0-e,2)+Math.pow(0-o,2));if(s>210)return`rgb(${t/s*210},${e/s*210},${o/s*210})`}return r.Color.toRgb(n)}class a{static hashCode(e){let t=0;if(0===e.length)return t;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t}}class c{}class l extends c{get(e,t){return"#666666"}}class u extends c{static get palette(){return u._pallete||(u._pallete=u.buildPalette()),u._pallete}static buildPalette(){return(0,s.pj)().then((e=>{e.awaitLoaded(1/0).then((()=>{const t=e.getMonomerLib();t.onChanged.subscribe((()=>{u.customMonomerColors={},u.polymerTypes=t.getPolymerTypes();for(const e of this.polymerTypes){const n=t.getMonomerSymbolsByType(e);for(const r of n){const n=t.getMonomer(e,r);n?.meta?.colors?.default?.background&&(this.customMonomerColors[r]||(this.customMonomerColors[r]={}),this.customMonomerColors[r][e]=i(n.meta.colors.default.background))}}}))}))})),[].concat(...Object.values(o.e.colourPalette))}get(e,t){const n=u.palette.length,r=u.customMonomerColors[e],o=t??"PEPTIDE";if(r&&r[o])return r[o];const s=a.hashCode(e)%n;return i(u.palette[s])}}u._pallete=null,u.customMonomerColors={},u.polymerTypes=[];class d extends o.e{static get Gray(){return void 0===this.gray&&(this.gray=new l),this.gray}static get Color(){return void 0===this.color&&(this.color=new u),this.color}}},6642:(e,t,n)=>{"use strict";n.d(t,{BG:()=>i,sD:()=>c});var r=n(4328),o=n(1858),s=n(8070);function i(e){let t=null,n=null;try{n=e.dart?e.gridColumn:null,t=n?n.temp:null}catch{[n,t]=[null,null]}const r=e.cell.column;if(t=t??(r?r.temp:null),!t)throw new Error("Grid cell renderer back store (GridColumn or Column) not found.");return[n,r,t]}class a{onKeyDown(e,t){}onKeyPress(e,t){}onMouseEnter(e,t){}onMouseLeave(e,t){}onMouseDown(e,t){}onMouseUp(e,t){}onMouseMove(e,t){}onClick(e,t){}onDoubleClick(e,t){}}class c extends a{constructor(e,t,n){super(),this.gridCol=e,this.tableCol=t,this.logger=n,this.subs=[],this.dirty=!0,this.destroyed=!1,this.viewerId=++c.viewerCounter,this.errors=[],this._onRendered=new o.Subject,this.tableCol&&this.tableCol.dataFrame&&(this.subs.push(this.tableCol.dataFrame.onDataChanged.subscribe((()=>{this.dirty=!0}))),this.subs.push(this.tableCol.dataFrame.onColumnsRemoved.subscribe((e=>{try{this.destroyed||!this.tableCol||this.tableCol.dataFrame||this.destroy()}catch(e){this.logger.error(e)}})))),this.tableCol&&this.subs.push(r.events.onTableRemoved.subscribe((e=>{try{const t=e.args.dataFrame;this.tableCol?.dataFrame.id!==t.id||this.destroyed||this.destroy()}catch(e){this.logger.error(e)}}))),this.gridCol&&this.subs.push(r.events.onViewRemoving.subscribe((e=>{try{const t=e.args.view;this.gridCol?.dart&&this.gridCol.grid&&this.gridCol?.grid?.dart&&this.gridCol?.grid?.view?.id===t.id&&!this.destroyed&&this.destroy()}catch(e){this.logger.error(e)}})))}toLog(){return`${this.constructor.name}<${this.viewerId}>`}destroy(){for(const e of this.subs)e.unsubscribe();this.destroyed=!0}invalidateGrid(){this.gridCol&&this.gridCol.dart&&this.gridCol.grid?.invalidate()}reset(){this.dirty=!1}get onRendered(){return this._onRendered}invalidate(e){this.invalidateGrid()}async awaitRendered(e=1e4,t=`${e} timeout`){const n=`${this.toLog()}.awaitRendered()`;if(this.logger.debug(`${n}, start, testEvent before`),await(0,s.PE)(this._onRendered,(()=>{}),(()=>{this.invalidate()}),e,`${n}, ${t}`),this.errors.length>0){const e=this.errors[0];throw this.errors=[],e}this.logger.debug(`${n}, end`)}}c.viewerCounter=-1},673:(e,t,n)=>{"use strict";n.d(t,{s:()=>r});const r={true:"1",false:"0"}},6882:(e,t,n)=>{"use strict";n.d(t,{Bb:()=>b,Jy:()=>w,S$:()=>y,U0:()=>v});var r=n(7389),o=n(6082),s=n(1991),i=n.n(s),a=n(8312),c=n(2003),l=n(6642),u=n(6718),d=n(9192),h=n(3856),p=n(673),m=n(3599),f=n(5553),g=n(9713);const y="rgb(100,100,100)";function b(e,t,n){if((n??0)>0&&t<(e[0]??0)+n)return-1;t-=n??0;let r,o=100,s=0,i=e.length-1;for(;s<=i;){if(r=Math.floor((i+s)/2),e[r]<=t&&t<e[r+1])return r;if(t<e[r]?i=r-1:s=r+1,--o<=0)throw new Error(`Get position for pointer x = ${t} searching has not converged on ${JSON.stringify(e)}. `)}return null}class w extends l.sD{get separatorWidth(){return this.props?.fontCharWidth?this.props?.fontCharWidth:5}constructor(e,t,n,r,s){if(super(e,t,n),this.monomerLengthLimit=r,this.propsProvider=s,this.colWidth=0,this._monomerLengthList=null,this._processedMaxVisibleSeqLength=0,this._monomerLengthMap={},this._monomerStructureMap={},this._ellipsisBounds=void 0,this._totalLinesNeeded=0,this._lineHeight=20,this._cellBounds=new Map,this.sysMonomerLib=null,this.padding=5,this._leftThreeDotsPadding=0,this.props=this.propsProvider(),this._processedRows=o.BitSet.create(this.tableCol.length),this.gridCol&&this.subs.push(this.gridCol.grid.onAfterDrawContent.subscribe((()=>{this._onRendered.next()}))),this.tableCol&&this.gridCol){this.subs.push(this.tableCol.dataFrame.onCurrentRowChanged.subscribe((()=>{-1===this.tableCol.dataFrame.currentRowIdx&&(this.tableCol.temp["reference-sequence"]=null,this.tableCol.temp["current-word"]=null,this.invalidateGrid())})));const e=[c.gp.positionShift,"renderMultiline"];this.subs.push(o.debounce(this.tableCol.dataFrame.onMetadataChanged.pipe(g.filter((t=>t.args.source===this.tableCol&&e.includes(t.args.key)))),200).subscribe((e=>{this.reset()}))),this.subs.push(o.debounce(this.tableCol.dataFrame.onMetadataChanged.pipe(g.filter((e=>e.args.source===this.tableCol&&e.args.key===c.gp.positionShift))),200).subscribe((e=>{this.reset()})))}}calculateFontBasedSpacing(e){const t=e.measureText("M");let n=12;if(this.tableCol?.temp[".mm.cellRenderer.fontSize"]){const e=this.tableCol.temp[".mm.cellRenderer.fontSize"];"number"!=typeof e||isNaN(e)||(n=Math.max(e,1))}return{lineHeight:Math.max(1.4*n,t.fontBoundingBoxAscent+t.fontBoundingBoxDescent+4),monomerSpacing:Math.max(2,.2*this.props.fontCharWidth)}}shouldUseMultilineRendering(e){return"true"===e.getTag("renderMultiline")}calculateMultiLineLayoutDynamic(e,t,n,r,o,s){if(this.dirty)try{this.reset()}catch(e){const[t,n]=(0,d.AP)(e);this.logger.error(t,void 0,n)}const{lineHeight:i,monomerSpacing:a}=this.calculateFontBasedSpacing(e),c=t-2*this.padding;let l=0;const u=[];if(r.length>0)for(let t=o;t<r.length;t++){const n=r.getOriginal(t),o=this.props.monomerToShort(n,s);u.push({text:o,posIdx:t}),l=Math.max(l,e.measureText(o).width)}if(0===u.length)return{lineLayouts:[],lineHeight:i};const h=l;let p=Math.floor((c+a)/(h+a));p=Math.max(1,p);const m=n-2*this.padding,f=Math.max(0,Math.floor(m/i)),g=[];let y=0;for(let e=0;e<f&&y<u.length;e++){const t=[];for(let e=0;e<p&&y<u.length;e++){const n=u[y],r=this.padding+e*(h+a);t.push({posIdx:n.posIdx,x:r,width:h,om:n.text,isSeparator:!1}),y++}g.push({lineIdx:e,elements:t})}return{lineLayouts:g,lineHeight:i}}async init(){await Promise.all([(async()=>{this.seqHelper=await(0,a.Q)(),this.invalidateGrid()})(),(async()=>{const e=await(0,u.pj)();this.sysMonomerLib=e.getMonomerLib()})()]),this.subs.push(this.sysMonomerLib.onChanged.subscribe((()=>{this.reset()}))),this.reset()}static getFontSettings(e){let t=12;return e&&e.temp[".mm.cellRenderer.fontSize"]&&"number"==typeof e.temp[".mm.cellRenderer.fontSize"]&&!isNaN(e.temp[".mm.cellRenderer.fontSize"])&&(t=Math.max(e.temp[".mm.cellRenderer.fontSize"],1)),{font:`${t}px monospace`,fontWidth:.6*t}}toLog(){return`MonomerPlacer<${this.viewerId}>`}getMonomerLib(){return this.tableCol.temp[".mm.cellRenderer.overriddenLibrary"]??this.sysMonomerLib}reset(){this.propsProvider&&(this.props=this.propsProvider()),this._processedRows=o.BitSet.create(this.tableCol.length),this._monomerLengthList=null,this._monomerLengthMap={},this._monomerStructureMap={},this._cellBounds.clear(),super.reset(),this.invalidateGrid()}invalidateGrid(){this.gridCol&&this.gridCol.dart&&this.gridCol.grid?.invalidate()}getCellMonomerLengths(e,t){const n=this.seqHelper.getSeqHandler(this.tableCol);if(this.colWidth<t&&(this.colWidth=t,this.dirty=!0),this.dirty)try{this.reset()}catch(e){const[t,n]=(0,d.AP)(e);this.logger.error(t,void 0,n)}const r=n.isMsa()?this.getCellMonomerLengthsForSeqMsa():this.getCellMonomerLengthsForSeq(e);return[r,this.getSummedMonomerLengths(r)]}getSummedMonomerLengths(e){const t=new Array(e.length+1);t[0]=this.padding;for(let n=1;n<t.length;n++)t[n]=t[n-1]+e[n-1];let n=t[0];for(let e=1;e<t.length;e++)t[e]?n=t[e]:t[e]=n;return t}getCellMonomerLengthsForSeqValue(e,t){const n=this.seqHelper.getSeqHandler(this.tableCol),r=this.props.separatorWidth+1*this.props.fontCharWidth,o=this.positionShift,s=Math.ceil(t/r)+o,i=n.splitter(e),a=Math.min(s,i.length),c=new Array(a-o);let l=0;for(let e=o;e<a;++e){const r=i.getOriginal(e),s=this.props.monomerToShort(r,this.monomerLengthLimit),a=(n.isSeparator()?this.separatorWidth:this.props.separatorWidth)+s.length*this.props.fontCharWidth;if(c[e-o]=a,l+=a,l>t)break}return c}getCellMonomerLengthsForSeq(e){this.toLog(),null===this._monomerLengthList&&(this._monomerLengthList=new Array(this.tableCol.length).fill(null));const t=this.positionShift,n=this.seqHelper.getSeqHandler(this.tableCol),r=this.props.separatorWidth+1*this.props.fontCharWidth,o=Math.ceil(this.colWidth/r)+t,s=n.getSplitted(e),i=Math.min(o,s.length);let a=this._monomerLengthList[e];if(null===a||a.length!=i-t){a=this._monomerLengthList[e]=new Array(s.length);let r=0;for(let e=t;e<i;++e){const o=s.getOriginal(e),i=this.props.monomerToShort(o,this.monomerLengthLimit),c=(n.isSeparator()?this.separatorWidth:this.props.separatorWidth)+i.length*this.props.fontCharWidth;if(a[e-t]=c,r+=c,r>this.colWidth)break}}return a}getCellMonomerLengthsForSeqMsa(){var e;this.toLog(),null===this._monomerLengthList&&(this._monomerLengthList=new Array(1).fill(null)),(e=this._monomerLengthList)[0]??(e[0]=new Array(0));const t=this._monomerLengthList[0],{startIdx:n,endIdx:r}=(()=>{try{const e=this.gridCol&&this.gridCol.dart?this.gridCol.grid:null;return e&&e.dart?{startIdx:Math.max(Math.floor((e?.vertScroll.min??0)-10),0),endIdx:Math.min(Math.ceil((e?.vertScroll.max??0)+10),this.tableCol.length)}:{startIdx:0,endIdx:Math.min(this.tableCol.length,10)}}catch(e){return{startIdx:0,endIdx:Math.min(this.tableCol.length,10)}}})(),o=this.props.separatorWidth+1*this.props.fontCharWidth,s=this.positionShift,i=Math.ceil(this.colWidth/o)+s;for(let e=n;e<r;e++){if(this._processedRows.get(e)&&i<=this._processedMaxVisibleSeqLength)continue;const n=this.seqHelper.getSeqHandler(this.tableCol).getSplitted(e,i),r=Math.min(i,n.length);r-s>t.length&&t.push(...new Array(r-s-t.length).fill(o));let a=0;for(let e=s;e<r;++e){const r=n.getOriginal(e),o=this.props.monomerToShort(r,this.monomerLengthLimit),i=this.props.separatorWidth+o.length*this.props.fontCharWidth;if(t[e-s]=Math.max(t[e-s]??0,i),a+=i,a>=this.colWidth)break}this._processedMaxVisibleSeqLength=Math.max(this._processedMaxVisibleSeqLength,i),this._processedRows.set(e,!0)}return t}getPosition(e,t,n,r){const[o,s]=this.getCellMonomerLengths(e,n);return 0===this.seqHelper.getSeqHandler(this.tableCol).getSplitted(e).length?null:b(s,t,r)}setMonomerLengthLimit(e){this.monomerLengthLimit!=e&&(this.monomerLengthLimit=e,this.dirty=!0)}setSeparatorWidth(e){this.separatorWidth!=e&&(this.props.separatorWidth=e,this.dirty=!0)}get positionShift(){const e=Number.parseInt(this.tableCol?.tags[c.gp.positionShift]??"0")??0;return isNaN(e)?0:Math.max(e,0)}render(e,t,n,r,s,a,l){const u=a.grid?.canvas===e.canvas;if(!this.seqHelper)return;const m=this.tableCol,f=this.positionShift;e.save();try{const l=this.seqHelper.getSeqHandler(m);let d=this.monomerLengthLimit;if(h.gp.maxMonomerLength in m.tags){const e=parseInt(m.getTag(h.gp.maxMonomerLength));d=!isNaN(e)&&e?e:50}if(m.temp[".mm.cellRenderer.settingsChanged"]===p.s.true||this.monomerLengthLimit!=d){let e=0;const t=8;e=m.temp[".mm.cellRenderer.gapLength"]??e,this.setMonomerLengthLimit(d),this.setSeparatorWidth(l.isMsa()?t:e),m.temp[".mm.cellRenderer.settingsChanged"]=p.s.false,this.dirty=!0}const g=a.cell.rowIndex,b=a.cell.value;u&&(r=v(a.grid,e,t,r,window.devicePixelRatio)),e.beginPath(),e.rect(t,n,r,s),e.clip(),e.font=this.props?.font??"12px monospace",e.textBaseline="top";const w=m.meta.units,A=m.getTag(c.gp.aligned),E=m.getTag(c.gp.separator)??"",C=u?l.getSplitted(g):l.splitter(b);let T=h.yg.classic;A?.includes("MSA")&&w===c.Hi.SEPARATOR&&(T=h.yg.MSA);const S=m.temp["reference-sequence"],_=this.tableCol.temp["current-word"],P=(()=>{const e=(0,l.splitter)(null!=S&&""!==S?S:_??"");return i().count(0).take(e.length).slice(f).map((t=>e.getCanonical(t))).toArray()})(),M=Number.parseInt(m.getTag(c.gp.selectedPosition)??"-200");if(this.shouldUseMultilineRendering(m)){const i=[],c=this.calculateMultiLineLayoutDynamic(e,r,s,C,f,d);let u=n+this.padding;1===c.lineLayouts.length&&(u=n+(s-c.lineHeight)/2);for(const r of c.lineLayouts){const s=u+r.lineIdx*c.lineHeight;for(const u of r.elements){const d=t+u.x,p=u,g=p.posIdx,b=C.getCanonical(g);let w=y;const v=this.getMonomerLib();v&&(w=v.getMonomerTextColor(l.defaultBiotype,b));let A=0;if(a.tableRowIndex!==m.dataFrame.currentRowIdx&&P.length>0){const e=g-f;e>=0&&e<P.length&&b===P[e]&&(A=.7)}i.push({lineIdx:r.lineIdx,monomerIdx:g-f,bounds:new o.Rect(u.x,s-n,u.width,c.lineHeight),sequencePosition:g}),(0,h.oZ)(e,p.om,d,s,u.width,c.lineHeight,{color:w,isMultiLineContext:!0,transparencyRate:A,selectedPosition:isNaN(M)||M<1?void 0:M,wordIdx:g})}}null!==a.tableRowIndex&&this._cellBounds.set(a.tableRowIndex,i)}else{this._leftThreeDotsPadding=this.shouldRenderShiftedThreeDots(f)?e.measureText("...").width:0;let[,o]=this.getCellMonomerLengths(a.tableRowIndex,r);u||(o=this.getSummedMonomerLengths(this.getCellMonomerLengthsForSeqValue(b,r)));const i=this.props.separatorWidth+1*this.props.fontCharWidth,c=Math.min(C.length,Math.ceil(r/i)+f);for(let i=f;i<c;++i){const c=i<C.length?C.getOriginal(i):l.defaultGapOriginal,u=i<C.length?C.getCanonical(i):l.defaultGapOriginal;let p=y;this.getMonomerLib()&&(p=this.getMonomerLib().getMonomerTextColor(l.defaultBiotype,u));const m={color:p,pivot:0,left:!0,transparencyRate:0,separator:E,last:i===C.length-1,drawStyle:T,maxWord:o,wordIdx:i-f,gridCell:a,referenceSequence:P,maxLengthOfMonomer:d,monomerTextSizeMap:this._monomerLengthMap,logger:this.logger,selectedPosition:isNaN(M)||M<1?void 0:M-f};(0,h.oZ)(e,c,t+this.padding+this._leftThreeDotsPadding,n,r,s,m)}if(this.shouldRenderShiftedThreeDots(f)){const i={color:y,pivot:0,left:!0,transparencyRate:0,separator:E,last:!1,drawStyle:T,maxWord:o,wordIdx:0,gridCell:a,maxLengthOfMonomer:d,monomerTextSizeMap:this._monomerLengthMap,logger:this.logger};(0,h.oZ)(e,"...",t+this.padding,n,r,s,i)}}}catch(e){const[t,n]=(0,d.AP)(e);this.logger.error(t,void 0,n),this.errors.push(e)}finally{e.restore()}}shouldRenderShiftedThreeDots(e){return e>0&&(!this.gridCol||!this.gridCol.dart||!this.gridCol.grid||!this.gridCol.grid.dart||(this.gridCol.grid.props.colHeaderHeight??0)<=50)}onMouseMove(e,t){const n=`${this.toLog()}.onMouseMove()`;if(!this.seqHelper||null==e.tableRowIndex)return;const o=this.positionShift,s=e.bounds,i=t.offsetX-e.gridColumn.left+(e.gridColumn.left-s.x),a=t.offsetY-s.y;this.gridCol?.grid?.canvas&&(this.gridCol.grid.canvas.style.cursor="default");let l=null;const u=this._cellBounds.get(e.tableRowIndex);if(u){for(const e of u)if(e.bounds.contains(i,a)){l=e.monomerIdx;break}}else{const t=this.shouldRenderShiftedThreeDots(o)&&(this._leftThreeDotsPadding??0)>0?this._leftThreeDotsPadding:0;l=this.getPosition(e.tableRowIndex,i,s.width,t)}this.logger.debug(`${n}, argsX: ${i}, argsY: ${a}, left: ${l}`);const d=this.seqHelper.getSeqHandler(this.tableCol),h=d.getSplitted(e.tableRowIndex);if(null!==l&&l>=0&&l+o<h.length){const n=d.alphabet??c.YI.UN,s={position:l,biotype:n===c.YI.RNA||n===c.YI.DNA?m.o.NUCLEOTIDE:m.o.AA,symbol:h.getCanonical(l+o)},i=[];let a=this._monomerStructureMap[s.symbol];if(!a){const e=this.getMonomerLib();a=this._monomerStructureMap[s.symbol]=e?e.getTooltip(s.biotype,s.symbol):r.divText("Monomer library is not available")}i.push(a),r.tooltip.show(r.divV(i),t.x+16,t.y+16),(0,f.WN)(e,s)}else-1===l?r.tooltip.show(r.divText(`${Math.min(o,h.length)} hidden monomers`),t.x+16,t.y+16):r.tooltip.hide(),(0,f.WN)(e,null)}}function v(e,t,n,r,o){return e?Math.max(Math.min(e.canvas.width/o-n,r)):Math.max(t.canvas.width/o-n,0)}},3856:(e,t,n)=>{"use strict";n.d(t,{Mn:()=>u,gp:()=>l,oZ:()=>p,yg:()=>d});var r=n(6082),o=n(7278);const s="rgb(100,100,100)",i="#808080",a="rgb(0,0,0)",c=o.zS;var l,u,d;!function(e){e.maxMonomerLength=".mm.cellRenderer.maxMonomerLength"}(l||(l={})),function(e){e.applyToBackground=".m.cellRenderer.applyToBackground"}(u||(u={})),function(e){e.MSA="MSA",e.classic="classic"}(d||(d={}));const h=new class{constructor(){this.color=s,this.pivot=0,this.left=!1,this.transparencyRate=0,this.separator="",this.last=!1,this.drawStyle=d.classic,this.maxWord=[],this.wordIdx=0,this.gridCell=null,this.referenceSequence=null,this.maxLengthOfMonomer=null,this.monomerTextSizeMap={},this.logger=void 0,this.selectedPosition=void 0,this.isMultiLineContext=!1,this.lineNumber=0}};function p(e,t,n,o,l,u,p){var m,f,g;const y={...h,...p};if(y.isMultiLineContext){e.textBaseline="middle",e.textAlign="center";let r=t;null!=y.maxLengthOfMonomer&&(r=c(r,y.maxLengthOfMonomer));const i=Math.max(.1,1-(y.transparencyRate??0));e.globalAlpha=i;const d=e.measureText(r),h=d.fontBoundingBoxAscent+d.fontBoundingBoxDescent,p=o+(u-h)/2+d.fontBoundingBoxAscent;let m=y.color??s;return m&&m!==s||(m=a),e.fillStyle=m,y.selectedPosition===y.wordIdx+1&&(e.save(),e.fillStyle="rgba(60, 177, 115, 0.2)",e.fillRect(n,o,l,u),e.restore(),e.fillStyle=m),e.fillText(r,n+l/2,p),e.globalAlpha=1,e.textBaseline="top",e.textAlign="start",n+l}p.logger?.debug("Bio: printLeftOrCentered(), start"),e.textAlign="start";let b=t.substring(0),w=y.last?"":y.separator;y.drawStyle===d.MSA&&(w="");let v=!0,A=!0,E="difference";if(null!=y.gridCell&&null!=y.gridCell.cell.column&&(v=y.gridCell.cell.column.temp["color-code"]??!0,A=y.gridCell.cell.column.temp["compare-with-current"]??!0,E=y.gridCell.cell.column.temp["highlight-difference"]??"difference"),y.referenceSequence){const e=y.referenceSequence[y.wordIdx];A&&y.referenceSequence.length>0&&"difference"===E&&(y.transparencyRate=b==e?.7:y.transparencyRate),A&&y.referenceSequence.length>0&&"equal"===E&&(y.transparencyRate=b!=e?.7:y.transparencyRate)}null!=y.maxLengthOfMonomer&&(b=c(b,y.maxLengthOfMonomer));const C=b+w;(m=y.monomerTextSizeMap)[C]??(m[C]=e.measureText(C));let T=y.monomerTextSizeMap[C];(f=y.monomerTextSizeMap)[b]??(f[b]=e.measureText(b));let S=y.monomerTextSizeMap[b].width;const _=u/2-(T.fontBoundingBoxAscent+T.fontBoundingBoxDescent)/2+1;(g=y.monomerTextSizeMap)[w]??(g[w]=e.measureText(w));const P=y.monomerTextSizeMap[w].width;function M(t,s){let c=v?y.color:a;y.selectedPosition===y.wordIdx+1&&(e.fillStyle="rgba(60, 177, 115, 0.2)",e.fillRect(n+t-4,o-5,y.monomerTextSizeMap[b].width+8,u+10),c=r.Color.toHtml(r.Color.setAlpha(r.Color.fromHtml(c),255))),e.fillStyle=c,e.globalAlpha=1-y.transparencyRate,y.drawStyle===d.classic&&(e.fillText(b,n+t,o+_),e.fillStyle=i,e.fillText(w,n+s,o+_)),y.drawStyle===d.MSA&&e.fillText(b,n+t,o+_),e.globalAlpha=1}T=T.width,y.drawStyle===d.MSA&&(S=y.maxWord[y.wordIdx],T=y.maxWord[y.wordIdx]);const x=(y.maxWord[y.wordIdx]??0)-(y.maxWord[0]??0);if(y.left||T>l)return M(x,x+S),n+x+S+P;{const e=(l-T)/2;return M(e,e+S),n+x+e+S}}},6307:(e,t,n)=>{"use strict";n.d(t,{F:()=>i});var r=n(7389),o=n(6082),s=n(439);function i(e,t,n){let i=0,a=null;for(const t of Object.values(e))i+=t,a=null===a?t:Math.max(a,t);const c=a/i,l=Object.assign({},...Array.from(Object.entries(e)).sort(((e,t)=>t[1]-e[1])).map((([e,a])=>{const l=a/i;let u;try{const r=n.getMonomerColors(t,e);u=r?.backgroundcolor||"#CCCCCC"}catch(t){console.warn(`Failed to get colors for monomer ${e}:`,t),u="#CCCCCC"}const d=r.div("",{classes:"macromolecule-cell-comp-analysis-bar"});d.style.width=50*l/c+"px",d.style.backgroundColor=u,s._S===e&&(d.style.borderWidth="1px",d.style.borderStyle="solid",d.style.borderColor=o.Color.toHtml(o.Color.lightGray));const h=s._S===e?"-":e,p=r.div(`${(100*l).toFixed(2)}%`),m=r.div([d,p],{classes:"macromolecule-cell-comp-analysis-value"});return{[h]:m}}))),u=r.tableFromMap(l);return Array.from(u.rows).forEach((e=>{const t=e.getElementsByClassName("macromolecule-cell-comp-analysis-bar")[0].style.backgroundColor;e.cells[0].style.color=t})),u}},3151:(e,t,n)=>{"use strict";n.d(t,{f6:()=>r});const r=["symbol","molfile","rgroups","name"];new RegExp("[rd]\\((\\w)\\)p?","g")},9192:(e,t,n)=>{"use strict";function r(e){return"string"==typeof e||e instanceof String?e:"StateError"===e.constructor.name?e.message:"StateError"===e.constructor.name&&"$thrownJsError"in e?r(e.$thrownJsError):e instanceof Error?e.message:e.toString()}function o(e){return e instanceof Error?e.stack:"StateError"===e.constructor.name&&"$thrownJsError"in e?o(e.$thrownJsError):void 0}function s(e){return[r(e),o(e)]}n.d(t,{AP:()=>s})},3516:(e,t,n)=>{"use strict";n.d(t,{m:()=>s});var r=n(6082),o=n(439);class s{get descriptionsArray(){return this._descriptionsArray}get sequencesArray(){return this._sequencesArray}parseMacromolecule(e,t){return this._fileContent.slice(e,t).split(/\s/).join("")}parseColumns(){const e=/^>(.*)$/gm;let t,n=0;for(;t=e.exec(this._fileContent);){const r=this._fileContent.substring(t.index+1,e.lastIndex);this._descriptionsArray.push(r),0!==n&&this._sequencesArray.push(this.parseMacromolecule(n,t.index)),n=e.lastIndex+1}this._sequencesArray.push(this.parseMacromolecule(n,-1))}importFasta(){const e=r.Column.fromStrings("description",this.descriptionsArray),t=r.Column.fromStrings("sequence",this.sequencesArray);return t.semType=r.SEMTYPE.MACROMOLECULE,t.meta.units=o.Hi.FASTA,[r.DataFrame.fromColumns([e,t])]}constructor(e){this._descriptionsArray=[],this._sequencesArray=[],this._fileContent=e,this.parseColumns()}}},6873:(e,t,n)=>{"use strict";n.d(t,{dW:()=>i,fD:()=>s});var r=n(6082),o=(n(1991),n(2003));function s(){const e=[];return e.push(r.Column.fromList("string","MSA",new Array(10**6).fill("meI/hHis/Aca/N/T/dE/Thr_PO3H2/Aca/D-Tyr_Et/Tyr_ab-dehydroMe/dV/E/N/D-Orn/D-aThr//Phe_4Me"))),e.push(r.Column.fromList(r.COLUMN_TYPE.FLOAT,"Activity",new Array(10**6).fill(5.30751))),e}function i(e=10**5){const t="meI/hHis/Aca/N//dE/Thr_PO3H2/Aca/D-Tyr_Et/Tyr_ab-dehydroMe".repeat(Math.ceil(e/10)).slice(0,-1),n=r.Column.fromList(r.COLUMN_TYPE.STRING,"MSA",new Array(100).fill(t));n.semType=r.SEMTYPE.MACROMOLECULE,n.meta.units=o.Hi.SEPARATOR,n.setTag(o.gp.separator,"/"),n.setTag(o.gp.alphabet,o.YI.UN),n.setTag(o.gp.alphabetIsMultichar,"true");const s=[];return s.push(n),s.push(r.Column.fromList(r.COLUMN_TYPE.FLOAT,"Activity",new Array(100).fill(7.30751))),s}n(7278),n(439)},439:(e,t,n)=>{"use strict";n.d(t,{B5:()=>c,Hi:()=>r,Vl:()=>l,YI:()=>o,_S:()=>d,b9:()=>h,gp:()=>s,ot:()=>p,q7:()=>u,z1:()=>a});var r,o,s,i=n(2738);!function(e){e.FASTA="fasta",e.SEPARATOR="separator",e.HELM="helm",e.CUSTOM="custom"}(r||(r={})),function(e){e.DNA="DNA",e.RNA="RNA",e.PT="PT",e.UN="UN"}(o||(o={})),function(e){e.aligned="aligned",e.alphabet="alphabet",e.alphabetSize=".alphabetSize",e.alphabetIsMultichar=".alphabetIsMultichar",e.separator="separator",e.isHelmCompatible=".isHelmCompatible",e.positionNames=".positionNames",e.positionLabels=".positionLabels",e.regions=".regions",e.positionShift=".positionShift",e.selectedPosition=".selectedPosition"}(s||(s={}));const a=", ",c=/(?:\[([A-Za-z0-9_\-,()]+)\])|([A-Za-z\-])/g,l=new class{constructor(){this.fasta={peptide:new Set(["G","L","Y","S","E","Q","D","N","F","A","K","R","H","C","V","P","W","I","M","T"]),dna:new Set(["A","C","G","T"]),rna:new Set(["A","C","G","U"])}}},u=[new i.a(o.PT,l.fasta.peptide,.5),new i.a(o.DNA,l.fasta.dna,.55),new i.a(o.RNA,l.fasta.rna,.55)],d="",h={[r.FASTA]:"-",[r.SEPARATOR]:"",[r.HELM]:"*"},p=" , "},2003:(e,t,n)=>{"use strict";n.d(t,{Hi:()=>r.Hi,J9:()=>o.J9,Qf:()=>o.Qf,SM:()=>o.SM,YI:()=>r.YI,gp:()=>r.gp,mn:()=>o.mn,nq:()=>o.nq,qp:()=>o.qp,z1:()=>r.z1,zS:()=>o.zS});var r=n(439),o=n(7278)},2738:(e,t,n)=>{"use strict";n.d(t,{X:()=>o,a:()=>r});class r{constructor(e,t,n){this.name=e,this.alphabet=t,this.cutoff=n}}class o extends r{constructor(e,t,n){super(e.name,e.alphabet,e.cutoff),this.freq=t,this.similarity=n}}},7278:(e,t,n)=>{"use strict";n.d(t,{Iv:()=>b,J9:()=>g,Mu:()=>m,Qf:()=>A,SM:()=>C,mn:()=>T,nq:()=>E,qp:()=>y,vZ:()=>f,zS:()=>v});var r=n(6082),o=n(1991),s=n.n(o),i=n(3527),a=n(3629),c=n(2738),l=n(439),u=n(8924),d=n(1093),h=n(4152),p=n(8438);class m{get length(){return this.mList.length}isGap(e){return this.getOriginal(e)===this.gapOriginalMonomer}getCanonical(e){if(this.length<=e)throw new Error("Index out of bounds");const t=this.mList[e];return t!==this.gapOriginalMonomer?t:l._S}getOriginal(e){if(this.length<=e)throw new Error("Index out of bounds");return this.mList[e]}getCanonicalRegion(e,t){const n=Math.min(Math.max(0,e),this.length),r=Math.max(Math.min(this.length,t),0)-n,o=this.gapOriginalMonomer;return new Array(r).fill(null).map(((e,t)=>{const r=this.mList[t+n];return r===o?l._S:r}))}getOriginalRegion(e,t){const n=Math.min(Math.max(0,e),this.length),r=Math.max(Math.min(this.length,t),0);return new Array(r-n).fill(null).map(((e,t)=>this.mList[t+n]))}get gapOriginal(){return this.gapOriginalMonomer}constructor(e,t){this.mList=e,this.gapOriginalMonomer=t}}function f(e,t,n){const r=e.categories;return function(e,t){const n={};let r=!0,o=null;for(const s of e)if(null==o?o=s.length:s.length!==o&&(r=!1),s.length>=t)for(let e=0;e<s.length;++e){const t=s.getCanonical(e);t in n||(n[t]=0),n[t]+=1}return{freq:n,sameLength:r}}(s().enumerate(e.getRawData()).map((([e,t])=>n(r[e]))),t)}const g=e=>{const t=s()(e.toString().matchAll(l.B5)).map((e=>e[2]??e[1])).toArray();return new m(t,l.b9[l.Hi.FASTA])},y=e=>{const t=e.split("$")[0].split("|"),n=s()(t.map((e=>(e.match(/(?<=\{).+(?=})/)?.[0]?.split(".")??[]).map((e=>(0,p.D)(e)))))).flatten().toArray();return new m(n,l.b9[l.Hi.HELM])};function b(e,t,n=void 0){if(e.toLowerCase().startsWith(l.Hi.FASTA))return g;if(e.toLowerCase().startsWith(l.Hi.SEPARATOR))return function(e,t){return n=>{if(n){let r;const o=new RegExp(`(?<=^|\\${e})("-"|'-'|[^\\${e}]*)(?=\\${e}|$)`,"g");return void 0!==t?(o.lastIndex=0,r=s()(n.matchAll(o)).take(t).map((e=>e[0])).toArray()):r=n.replaceAll('"-"',"").replaceAll("'-'","").split(e,t),new m(r,l.b9[l.Hi.SEPARATOR])}return new m([],l.b9[l.Hi.SEPARATOR])}}(t,n);if(e.toLowerCase().startsWith(l.Hi.HELM))return y;throw new Error(`Unexpected units ${e} .`)}const w=/([^\W_]+)/g;function v(e,t){if(e.length<=t)return e;const n=e.match(w),r=e.length>t||(n?.length??0)>1,o=n?.[0]??" ";return r?o.substring(0,t-1)+"…":o}function A(e){switch(e){case l.YI.DNA:return l.Vl.fasta.dna;case l.YI.RNA:return l.Vl.fasta.rna;case l.YI.PT:return l.Vl.fasta.peptide;default:throw new Error(`Unsupported alphabet '${e}'.`)}}function E(e,t,n="-"){const r=new Set([...new Set(Object.keys(e)),...t]);r.delete(n);const o=[],s=[];for(const n of r)o.push(n in e?e[n]:0),s.push(t.has(n)?1:0);const c=new i.Mi(o),l=new i.Mi(s);return(0,a.KE)(c,l)/((0,a.wQ)(c)*(0,a.wQ)(l))}function C(e,t,n=5){let o;return o=e.semType==r.SEMTYPE.MACROMOLECULE?t.getSeqHandler(e).alphabet:function(e,t,n="-"){const r=t.map((t=>{const r=E(e,t.alphabet,n);return new c.X(t,e,r)}));let o;const s=Math.max(...r.map((e=>e.similarity>e.cutoff?e.similarity:-1)));return o=s>0?r.find((e=>e.similarity===s)).name:l.YI.UN,o}(f(e,n,g).freq,l.q7),function(e){switch(e){case l.YI.PT:return u.X.GrokGroups;case l.YI.DNA:case l.YI.RNA:return d.A.Chromatogram;default:return h.oT.Color}}(o)}function T(e){const t=e.columns.bySemTypeAll(r.SEMTYPE.MACROMOLECULE);let n=t.find((e=>{const t=e.meta.units;return!!t&&-1!==t.indexOf("MSA")}))??null;return!n&&t.length>0&&(n=t[0]),n}},8312:(e,t,n)=>{"use strict";n.d(t,{Q:()=>o});var r=n(6082);async function o(){const e=r.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()}},3077:(e,t,n)=>{"use strict";n(6082)},7602:(e,t,n)=>{"use strict";n.d(t,{g:()=>s});var r,o=n(9192);!function(e){e[e.error=0]="error",e[e.warning=1]="warning",e[e.info=2]="info",e[e.debug=3]="debug"}(r||(r={}));class s{constructor(e){this.logger=e,this.promise=Promise.resolve(),this.errors=[],this.syncCounter=0}sync(e,t){const n=++this.syncCounter;this.logger.debug(`${e}, SYNC syncId = ${n}, IN `),this.promise=this.promise.then((async()=>{this.logger.debug(`${e}, SYNC syncId = ${n}, START `),await t(),this.logger.debug(`${e}, SYNC syncId = ${n}, END `)})).catch((t=>{const[r,s]=(0,o.AP)(t);this.logger.error(`${e}, SYNC syncId = ${n}, ERROR:\n${r}`,void 0,s),this.errors.push(t)}))}resetErrors(){const e=this.errors;return this.errors=[],e}}},4326:(e,t,n)=>{"use strict";n.d(t,{Fo:()=>u,Lp:()=>s,P4:()=>i,fH:()=>o,gp:()=>r,lT:()=>c,mH:()=>a});var r,o,s,i,a,c,l=n(6082);!function(e){e.tooltipWebLogo=".tooltipWebLogo"}(r||(r={})),function(e){e.Entropy="Entropy",e.full="100%"}(o||(o={})),function(e){e.TOP="top",e.MIDDLE="middle",e.BOTTOM="bottom"}(s||(s={})),function(e){e.LEFT="left",e.CENTER="center",e.RIGHT="right"}(i||(i={})),function(e){e.AUTO="auto",e.ON="on",e.OFF="off"}(a||(a={})),function(e){e.Filtered="Filtered",e.Selected="Selected"}(c||(c={}));const u=new class{constructor(){this.sequenceColumnName=null,this.valueAggrType=l.AGG.TOTAL_COUNT,this.valueColumnName="Activity",this.startPositionName=null,this.endPositionName=null,this.skipEmptySequences=!0,this.skipEmptyPositions=!1,this.shrinkEmptyTail=!0,this.backgroundColor=4294967295,this.positionHeight=o.Entropy,this.positionWidth=20,this.verticalAlignment=s.MIDDLE,this.horizontalAlignment=i.CENTER,this.fixWidth=!1,this.fitArea=!0,this.minHeight=25,this.maxHeight=300,this.maxMonomerLetters=5,this.showPositionLabels=!0,this.positionMarginState=a.AUTO,this.positionMargin=0,this.filterSource=c.Filtered}}},6869:(e,t,n)=>{"use strict";var r;n.d(t,{o:()=>r}),function(e){e.BASE="HELM_BASE",e.SUGAR="HELM_SUGAR",e.LINKER="HELM_LINKER",e.AA="HELM_AA",e.CHEM="HELM_CHEM",e.BLOB="HELM_BLOB",e.NUCLEOTIDE="HELM_NUCLETIDE"}(r||(r={}))},5540:(e,t,n)=>{"use strict";e=n.hmd(e);var r,o=(r="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0,function(e={}){var t,n,o=void 0!==e?e:{};o.ready=new Promise((function(e,r){t=e,n=r}));var s,i=Object.assign({},o),a="object"==typeof window,c="function"==typeof importScripts,l=("object"==typeof process&&"object"==typeof process.versions&&process.versions.node,"");(a||c)&&(c?l=self.location.href:"undefined"!=typeof document&&document.currentScript&&(l=document.currentScript.src),r&&(l=r),l=0!==l.indexOf("blob:")?l.substr(0,l.replace(/[?#].*/,"").lastIndexOf("/")+1):"",c&&(s=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)})),o.print||console.log.bind(console);var u,d,h=o.printErr||console.warn.bind(console);Object.assign(o,i),i=null,o.arguments&&o.arguments,o.thisProgram&&o.thisProgram,o.quit&&o.quit,o.wasmBinary&&(u=o.wasmBinary),o.noExitRuntime,"object"!=typeof WebAssembly&&_("no native wasm support detected");var p,m,f,g=!1;function y(){var e=d.buffer;o.HEAP8=p=new Int8Array(e),o.HEAP16=new Int16Array(e),o.HEAP32=new Int32Array(e),o.HEAPU8=m=new Uint8Array(e),o.HEAPU16=new Uint16Array(e),o.HEAPU32=f=new Uint32Array(e),o.HEAPF32=new Float32Array(e),o.HEAPF64=new Float64Array(e)}var b,w,v=[],A=[],E=[],C=0,T=null,S=null;function _(e){o.onAbort&&o.onAbort(e),h(e="Aborted("+e+")"),g=!0,e+=". Build with -sASSERTIONS for more info.";var t=new WebAssembly.RuntimeError(e);throw n(t),t}function P(e){return e.startsWith("data:application/octet-stream;base64,")}function M(e){try{if(e==b&&u)return new Uint8Array(u);if(s)return s(e);throw"both async and sync fetching of the wasm failed"}catch(e){_(e)}}function x(e,t,n){return function(e){return u||!a&&!c||"function"!=typeof fetch?Promise.resolve().then((function(){return M(e)})):fetch(e,{credentials:"same-origin"}).then((function(t){if(!t.ok)throw"failed to load wasm binary file at '"+e+"'";return t.arrayBuffer()})).catch((function(){return M(e)}))}(e).then((function(e){return WebAssembly.instantiate(e,t)})).then((function(e){return e})).then(n,(function(e){h("failed to asynchronously prepare wasm: "+e),_(e)}))}function N(e){for(;e.length>0;)e.shift()(o)}function $(e){this.excPtr=e,this.ptr=e-24,this.set_type=function(e){f[this.ptr+4>>2]=e},this.get_type=function(){return f[this.ptr+4>>2]},this.set_destructor=function(e){f[this.ptr+8>>2]=e},this.get_destructor=function(){return f[this.ptr+8>>2]},this.set_caught=function(e){e=e?1:0,p[this.ptr+12|0]=e},this.get_caught=function(){return 0!=p[this.ptr+12|0]},this.set_rethrown=function(e){e=e?1:0,p[this.ptr+13|0]=e},this.get_rethrown=function(){return 0!=p[this.ptr+13|0]},this.init=function(e,t){this.set_adjusted_ptr(0),this.set_type(e),this.set_destructor(t)},this.set_adjusted_ptr=function(e){f[this.ptr+16>>2]=e},this.get_adjusted_ptr=function(){return f[this.ptr+16>>2]},this.get_exception_ptr=function(){if(V(this.get_type()))return f[this.excPtr>>2];var e=this.get_adjusted_ptr();return 0!==e?e:this.excPtr}}function L(e){var t=d.buffer;try{return d.grow(e-t.byteLength+65535>>>16),y(),1}catch(e){}}function I(e){return o["_"+e]}P(b="wasmDbscan.wasm")||(w=b,b=o.locateFile?o.locateFile(w,l):l+w);var R="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function O(e,t,n,r,o){var s={string:e=>{var t=0;return null!=e&&0!==e&&(t=function(e){var t=function(e){for(var t=0,n=0;n<e.length;++n){var r=e.charCodeAt(n);r<=127?t++:r<=2047?t+=2:r>=55296&&r<=57343?(t+=4,++n):t+=3}return t}(e)+1,n=F(t);return function(e,t,n){!function(e,t,n,r){if(!(r>0))return 0;for(var o=n+r-1,s=0;s<e.length;++s){var i=e.charCodeAt(s);if(i>=55296&&i<=57343&&(i=65536+((1023&i)<<10)|1023&e.charCodeAt(++s)),i<=127){if(n>=o)break;t[n++]=i}else if(i<=2047){if(n+1>=o)break;t[n++]=192|i>>6,t[n++]=128|63&i}else if(i<=65535){if(n+2>=o)break;t[n++]=224|i>>12,t[n++]=128|i>>6&63,t[n++]=128|63&i}else{if(n+3>=o)break;t[n++]=240|i>>18,t[n++]=128|i>>12&63,t[n++]=128|i>>6&63,t[n++]=128|63&i}}t[n]=0}(e,m,t,n)}(e,n,t),n}(e)),t},array:e=>{var t,n,r=F(e.length);return t=e,n=r,p.set(t,n),r}},i=I(e),a=[],c=0;if(r)for(var l=0;l<r.length;l++){var u=s[n[l]];u?(0===c&&(c=D()),a[l]=u(r[l])):a[l]=r[l]}var d=i.apply(null,a);return function(e){return 0!==c&&H(c),function(e){return"string"===t?(n=e)?function(e,t,n){for(var r=t+n,o=t;e[o]&&!(o>=r);)++o;if(o-t>16&&e.buffer&&R)return R.decode(e.subarray(t,o));for(var s="";t<o;){var i=e[t++];if(128&i){var a=63&e[t++];if(192!=(224&i)){var c=63&e[t++];if((i=224==(240&i)?(15&i)<<12|a<<6|c:(7&i)<<18|a<<12|c<<6|63&e[t++])<65536)s+=String.fromCharCode(i);else{var l=i-65536;s+=String.fromCharCode(55296|l>>10,56320|1023&l)}}else s+=String.fromCharCode((31&i)<<6|a)}else s+=String.fromCharCode(i)}return s}(m,n,r):"":"boolean"===t?Boolean(e):e;var n,r}(e)}(d)}var k,G={__cxa_throw:function(e,t,n){throw new $(e).init(t,n),e},abort:function(){_("")},emscripten_memcpy_big:function(e,t,n){m.copyWithin(e,t,t+n)},emscripten_resize_heap:function(e){var t,n=m.length,r=2147483648;if((e>>>=0)>r)return!1;for(var o=1;o<=4;o*=2){var s=n*(1+.2/o);if(s=Math.min(s,e+100663296),L(Math.min(r,(t=Math.max(e,s))+(65536-t%65536)%65536)))return!0}return!1}},D=(function(){var e,t,r,s,i={env:G,wasi_snapshot_preview1:G};function a(e,t){var n,r=e.exports;return o.asm=r,d=o.asm.memory,y(),o.asm.__indirect_function_table,n=o.asm.__wasm_call_ctors,A.unshift(n),function(){if(C--,o.monitorRunDependencies&&o.monitorRunDependencies(C),0==C&&(null!==T&&(clearInterval(T),T=null),S)){var e=S;S=null,e()}}(),r}if(C++,o.monitorRunDependencies&&o.monitorRunDependencies(C),o.instantiateWasm)try{return o.instantiateWasm(i,a)}catch(e){h("Module.instantiateWasm callback failed with error: "+e),n(e)}(e=u,t=b,r=i,s=function(e){a(e.instance)},e||"function"!=typeof WebAssembly.instantiateStreaming||P(t)||"function"!=typeof fetch?x(t,r,s):fetch(t,{credentials:"same-origin"}).then((function(e){return WebAssembly.instantiateStreaming(e,r).then(s,(function(e){return h("wasm streaming compile failed: "+e),h("falling back to ArrayBuffer instantiation"),x(t,r,s)}))}))).catch(n)}(),o._dbscan=function(){return(o._dbscan=o.asm.dbscan).apply(null,arguments)},o._malloc=function(){return(o._malloc=o.asm.malloc).apply(null,arguments)},o._free=function(){return(o._free=o.asm.free).apply(null,arguments)},function(){return(D=o.asm.stackSave).apply(null,arguments)}),H=function(){return(H=o.asm.stackRestore).apply(null,arguments)},F=function(){return(F=o.asm.stackAlloc).apply(null,arguments)},V=function(){return(V=o.asm.__cxa_is_pointer_type).apply(null,arguments)};function U(){function e(){k||(k=!0,o.calledRun=!0,g||(N(A),t(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),function(){if(o.postRun)for("function"==typeof o.postRun&&(o.postRun=[o.postRun]);o.postRun.length;)e=o.postRun.shift(),E.unshift(e);var e;N(E)}()))}C>0||(function(){if(o.preRun)for("function"==typeof o.preRun&&(o.preRun=[o.preRun]);o.preRun.length;)e=o.preRun.shift(),v.unshift(e);var e;N(v)}(),C>0||(o.setStatus?(o.setStatus("Running..."),setTimeout((function(){setTimeout((function(){o.setStatus("")}),1),e()}),1)):e()))}if(o.ccall=O,o.cwrap=function(e,t,n,r){var o=!n||n.every((e=>"number"===e||"boolean"===e));return"string"!==t&&o&&!r?I(e):function(){return O(e,t,n,arguments)}},S=function e(){k||U(),k||(S=e)},o.preInit)for("function"==typeof o.preInit&&(o.preInit=[o.preInit]);o.preInit.length>0;)o.preInit.pop()();return U(),e.ready});"object"==typeof exports?e.exports=o:"function"==typeof define&&n.amdO?define([],(function(){return o})):"object"==typeof exports&&(exports.exportCppDbscanLib=o)},6295:(e,t,n)=>{"use strict";n.d(t,{$1:()=>i,Hf:()=>u,Hr:()=>S,Ii:()=>g,Qj:()=>m,T6:()=>T,TK:()=>E,be:()=>f,gt:()=>w,ij:()=>v,jL:()=>l,lO:()=>p,lP:()=>b,rR:()=>y,tO:()=>a,v_:()=>c,w_:()=>d,yK:()=>A,zn:()=>h});var r=n(8774),o=n(8498),s=n(6863);function i(e,t){const n=e.trueCount()+t.trueCount();if(0==n)return 1;const r=e.andWithCountBits(t,!0);return r/(n-r)}function a(e,t){return 1-i(e,t)}function c(e,t){return C(i(new r.A(e,32*e.length),new r.A(t,32*t.length)))}function l(e,t){let n=0;for(let r=0;r<e.length;r++)n+=Math.pow(e[r]-t[r],2);return Math.sqrt(n)}function u(e,t){let n=0;for(let r=0;r<e.length;r++)n+=Math.abs(e[r]-t[r]);return n}function d(e,t){let n=0,r=0,o=0;for(let s=0;s<e.length;s++)n+=e[s]*t[s],r+=e[s]*e[s],o+=t[s]*t[s];return(1-n/(Math.sqrt(r)*Math.sqrt(o)))/2}function h(e,t){return 1-function(e,t){const n=e.trueCount()+t.trueCount();return 0==n?0:2*e.andWithCountBits(t,!0)/n}(e,t)}function p(e,t){return 1-function(e,t){const n=e.trueCount()*t.trueCount();return 0==n?0:e.andWithCountBits(t,!0)/Math.sqrt(n)}(e,t)}function m(e,t){return Math.sqrt(e.trueCount()+t.trueCount()-2*e.andWithCountBits(t,!0))}function f(e,t){return e.trueCount()+t.trueCount()-2*e.andWithCountBits(t,!0)}function g(e,t){return 1-function(e,t){const n=e.trueCount()+t.trueCount(),r=e.andWithCountBits(t,!0);return r/(2*n-3*r)}(e,t)}function y(e,t){return C(function(e,t){const n=e.trueCount()+t.trueCount(),r=e.trueCount()*t.trueCount();return 0==r?0:e.andWithCountBits(t,!0)*n/(2*r)}(e,t))}function b(e,t){return C(function(e,t){const n=e.trueCount()+t.trueCount(),r=e.trueCount()*t.trueCount();return 0==r?0:(e.andWithCountBits(t,!0)*n-r)/r}(e,t))}function w(e,t){return 1-function(e,t){const n=Math.min(e.trueCount(),t.trueCount());return 0==n?0:e.andWithCountBits(t,!0)/n}(e,t)}function v(e,t){return C(function(e,t){const n=Math.max(e.trueCount(),t.trueCount());return 0==n?0:e.andWithCountBits(t,!0)/n}(e,t))}function A(e,t){return C(function(e,t){return 0==e.length?0:e.andWithCountBits(t,!0)/e.length}(e,t))}function E(e,t){return C(function(e,t){const n=e.andWithCountBits(t,!0),r=e.countBits(!0)+t.countBits(!0),o=e.length,s=o-r+n;return n==o||s==o?1:n/r+s/(2*o-r)}(e,t))}function C(e){return e<=0?3402823e32:1/e-1}function T(e){if(e&&null!=e.range&&e.range>0){const t=e.range;return(e,n)=>Math.abs(e-n)/t}return(e,t)=>Math.abs(e-t)}function S(e){const t=function(e){const t=e?.mostCommon??new Set;return(e,n)=>{const r=e.length,o=n.length;let s=0,i=0,a=0;for(;i<r&&a<o;)e[i]===n[a]?(t?.has(e[i])||++s,++i,++a):e[i]<n[a]?++i:++a;return s}}(e);return(e,n)=>0===n.length||0===e.length?1e4:Math.min(e.length,n.length)/(t(e,n)+1e-4)}o.aT.Tanimoto,o.aT.Dice,o.aT.Asymmetric,o.aT.BraunBlanquet,o.aT.Cosine,o.aT.Kulczynski,o.aT.McConnaughey,o.aT.RogotGoldberg,o.aT.Russel,o.aT.Sokal,o.aT.Hamming,o.aT.Euclidean,o.aT.Tanimoto,o.aT.Dice,o.aT.Asymmetric,o.aT.BraunBlanquet,o.aT.Cosine,o.aT.Kulczynski,o.aT.McConnaughey,o.aT.RogotGoldberg,o.aT.Russel,o.aT.Sokal,o.aT.Hamming,o.aT.Euclidean,o.aT.Tanimoto,o.aT.Dice,o.aT.Cosine,o.aT.Tanimoto,o.aT.Asymmetric,o.aT.Cosine,o.aT.Sokal,s.Z.HAMMING,s.Z.LEVENSHTEIN,s.Z.MONOMER_CHEMICAL_DISTANCE,s.Z.NEEDLEMANN_WUNSCH},684:(e,t,n)=>{"use strict";n.d(t,{C0:()=>s,GP:()=>r,Gi:()=>a,_X:()=>i,n3:()=>o,vb:()=>c});const r="dim-red-preprocessing-function",o="supportedSemTypes",s="supportedTypes",i="supportedUnits",a="supportedDistanceFunctions",c="bypassLargeDataWarning"},6863:(e,t,n)=>{"use strict";function r(e={}){const t=function(){if(!e||!e.scoringMatrix||!e.alphabetIndexes)return(e,t)=>e===t?0:1;if(e.scoringMatrix.length!==Object.keys(e.alphabetIndexes).length)throw new Error("Scoring matrix and alphabet indexes should have the same length");const t=e.alphabetIndexes,n=e.scoringMatrix,r=Math.min(...Object.keys(t).map((e=>e.charCodeAt(0))))+1,o=new Float32Array((n.length+r)*(n.length+r));return Object.entries(t).forEach((([e,r])=>{const s=n[r];Object.entries(t).forEach((([t,r])=>{o[e.charCodeAt(0)*n.length+t.charCodeAt(0)]=s[r]}))})),(e,t)=>1-o[e.charCodeAt(0)*n.length+t.charCodeAt(0)]}(),n=e?.threshold??0;return(e,r)=>{let o=0;const s=e.length,i=r.length,a=Math.ceil(Math.max(s,i)*(1-n));s!==i&&(o=Math.abs(s-i));let c=0;for(let n=0;n<Math.min(s,i);n++)if(e[n]!==r[n]&&(c+=t(e[n],r[n]),c>a))return 1;return c+=o,c/=Math.max(s,i),c}}n.d(t,{Z:()=>i,V:()=>a});var o=n(2787);const s={gapOpen:1,gapExtend:.6,scoringMatrix:[[4,-1,-2,-2,0,-1,-1,0,-2,-1,-1,-1,-1,-2,-1,1,0,-3,-2,0,-2,-1,0,-4],[-1,5,0,-2,-3,1,0,-2,0,-3,-2,2,-1,-3,-2,-1,-1,-3,-2,-3,-1,0,-1,-4],[-2,0,6,1,-3,0,0,0,1,-3,-3,0,-2,-3,-2,1,0,-4,-2,-3,3,0,-1,-4],[-2,-2,1,6,-3,0,2,-1,-1,-3,-4,-1,-3,-3,-1,0,-1,-4,-3,-3,4,1,-1,-4],[0,-3,-3,-3,9,-3,-4,-3,-3,-1,-1,-3,-1,-2,-3,-1,-1,-2,-2,-1,-3,-3,-2,-4],[-1,1,0,0,-3,5,2,-2,0,-3,-2,1,0,-3,-1,0,-1,-2,-1,-2,0,3,-1,-4],[-1,0,0,2,-4,2,5,-2,0,-3,-3,1,-2,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-2,0,-1,-3,-2,-2,6,-2,-4,-4,-2,-3,-3,-2,0,-2,-2,-3,-3,-1,-2,-1,-4],[-2,0,1,-1,-3,0,0,-2,8,-3,-3,-1,-2,-1,-2,-1,-2,-2,2,-3,0,0,-1,-4],[-1,-3,-3,-3,-1,-3,-3,-4,-3,4,2,-3,1,0,-3,-2,-1,-3,-1,3,-3,-3,-1,-4],[-1,-2,-3,-4,-1,-2,-3,-4,-3,2,4,-2,2,0,-3,-2,-1,-2,-1,1,-4,-3,-1,-4],[-1,2,0,-1,-3,1,1,-2,-1,-3,-2,5,-1,-3,-1,0,-1,-3,-2,-2,0,1,-1,-4],[-1,-1,-2,-3,-1,0,-2,-3,-2,1,2,-1,5,0,-2,-1,-1,-1,-1,1,-3,-1,-1,-4],[-2,-3,-3,-3,-2,-3,-3,-3,-1,0,0,-3,0,6,-4,-2,-2,1,3,-1,-3,-3,-1,-4],[-1,-2,-2,-1,-3,-1,-1,-2,-2,-3,-3,-1,-2,-4,7,-1,-1,-4,-3,-2,-2,-1,-2,-4],[1,-1,1,0,-1,0,0,0,-1,-2,-2,0,-1,-2,-1,4,1,-3,-2,-2,0,0,0,-4],[0,-1,0,-1,-1,-1,-1,-2,-2,-1,-1,-1,-1,-2,-1,1,5,-2,-2,0,-1,-1,0,-4],[-3,-3,-4,-4,-2,-2,-3,-2,-2,-3,-2,-3,-1,1,-4,-3,-2,11,2,-3,-4,-3,-2,-4],[-2,-2,-2,-3,-2,-1,-2,-3,2,-1,-1,-2,-1,3,-3,-2,-2,2,7,-1,-3,-2,-1,-4],[0,-3,-3,-3,-1,-2,-2,-3,-3,3,1,-2,1,-1,-2,-2,0,-3,-1,4,-3,-2,-1,-4],[-2,-1,3,4,-3,0,1,-1,0,-3,-4,0,-3,-3,-2,0,-1,-4,-3,-3,4,1,-1,-4],[-1,0,0,1,-3,3,4,-2,0,-3,-3,1,-1,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-1,-1,-1,-2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-2,0,0,-2,-1,-1,-1,-1,-1,-4],[-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,1]],alphabetIndexes:{A:0,R:1,N:2,D:3,C:4,Q:5,E:6,G:7,H:8,I:9,L:10,K:11,M:12,F:13,P:14,S:15,T:16,W:17,Y:18,V:19,B:20,Z:21,X:22,"*":23}};var i;!function(e){e.HAMMING="Hamming",e.LEVENSHTEIN="Levenshtein",e.NEEDLEMANN_WUNSCH="Needlemann-Wunsch",e.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance"}(i||(i={}));const a={[i.HAMMING]:r,[i.LEVENSHTEIN]:function(){return(e,t)=>(0,o.I)(e,t)/Math.max(e.length,t.length)},[i.NEEDLEMANN_WUNSCH]:function(e){const t=new Uint16Array(65536),{gapOpen:n,gapExtend:r,scoringMatrix:o,alphabetIndexes:i}={...s,...e};Object.entries(i).forEach((([e,n])=>t[e.charCodeAt(0)]=n));const a=[new Float32Array(1e4),new Float32Array(1e4)];return(e,s)=>{const i=new Array(e.length+1).fill(!1),c=new Array(e.length+1).fill(!1);let l=0,u=1;for(let t=1;t<e.length+1;t++)a[0][t]=-r-(t-1)*r,a[1][t]=0;a[0][0]=0;for(let d=1;d<s.length+1;d++){a[u][0]=-r-(d-1)*r;for(let h=1;h<e.length+1;h++){const p=a[l][h-1]+o[t[e.charCodeAt(h-1)]][t[s.charCodeAt(d-1)]],m=a[l][h]-(i[h]||1===d||d===s.length?r:n),f=a[u][h-1]-(c[h-1]||1===h||h===e.length?r:n);a[u][h]=Math.max(p,f,m),a[u][h]===p?(i[h]=!1,c[h]=!1):a[u][h]===f?(i[h]=!1,c[h]=!0):(i[h]=!0,c[h]=!1)}l=u,u=(u+1)%2}const d=Math.min(e.length,s.length);return(d-a[l][e.length])/d}},[i.MONOMER_CHEMICAL_DISTANCE]:r}},9039:(e,t,n)=>{"use strict";var r;n.d(t,{c:()=>r}),function(e){e.UMAP="UMAP",e.T_SNE="t-SNE"}(r||(r={}))},8498:(e,t,n)=>{"use strict";var r,o,s,i,a,c,l;n.d(t,{EG:()=>a,Pn:()=>o,RR:()=>c,Wn:()=>l,aT:()=>s,m6:()=>i,xL:()=>r}),function(e){e.Levenshtein="Levenshtein",e.JaroWinkler="Jaro-Winkler",e.Manhattan="Manhattan String",e.Onehot="One-Hot"}(r||(r={})),function(e){e.Euclidean="Euclidean",e.Manhattan="Manhattan",e.Cosine="Vector Cosine"}(o||(o={})),function(e){e.Tanimoto="Tanimoto",e.Dice="Dice",e.Asymmetric="Asymmetric",e.BraunBlanquet="Braun-Blanquet",e.Cosine="Cosine",e.Kulczynski="Kulczynski",e.McConnaughey="Mc-Connaughey",e.RogotGoldberg="Rogot-Goldberg",e.Russel="Russel",e.Sokal="Sokal",e.Hamming="Hamming",e.Euclidean="Euclidean BitArray"}(s||(s={})),function(e){e.TanimotoIntArray="TanimotoIntArray"}(i||(i={})),function(e){e.Vector="Vector",e.String="String",e.BitArray="BitArray",e.MacroMolecule="MacroMolecule",e.Number="Number",e.IntArray="IntArray",e.NumberArray="NumberArray"}(a||(a={})),function(e){e.Difference="Difference"}(c||(c={})),function(e){e.CommonItems="Common Items"}(l||(l={}))},2780:(e,t,n)=>{"use strict";n.d(t,{aT:()=>r.aT});var r=n(8498);n(9336)},9336:(e,t,n)=>{"use strict";var r=n(2787),o=n(944),s=n(6295),i=n(6863),a=n(8498);const c={[a.Pn.Euclidean]:s.jL,[a.Pn.Manhattan]:s.Hf,[a.Pn.Cosine]:s.w_},l={[a.xL.Levenshtein]:r.I,[a.xL.JaroWinkler]:o.Vb,[a.xL.Manhattan]:function(e,t){if(e.length!==t.length)return 1;{let n=0;for(let r=1;r<e.length;r++)n+=e[r]==t[r]?0:1;return n/e.length}},[a.xL.Onehot]:function(e,t){return e===t?0:1}},u={[a.aT.Tanimoto]:s.tO,[a.aT.Dice]:s.zn,[a.aT.Asymmetric]:s.gt,[a.aT.BraunBlanquet]:s.ij,[a.aT.Cosine]:s.lO,[a.aT.Kulczynski]:s.rR,[a.aT.McConnaughey]:s.lP,[a.aT.RogotGoldberg]:s.TK,[a.aT.Russel]:s.yK,[a.aT.Sokal]:s.Ii,[a.aT.Hamming]:s.be,[a.aT.Euclidean]:s.Qj},d={[a.m6.TanimotoIntArray]:s.v_},h={[a.RR.Difference]:s.T6},p={[a.Wn.CommonItems]:s.Hr},m={[a.EG.Vector]:{[a.Pn.Euclidean]:c[a.Pn.Euclidean],[a.Pn.Manhattan]:c[a.Pn.Manhattan],[a.Pn.Cosine]:c[a.Pn.Cosine]},[a.EG.String]:{[a.xL.Levenshtein]:l[a.xL.Levenshtein],[a.xL.JaroWinkler]:l[a.xL.JaroWinkler],[a.xL.Manhattan]:l[a.xL.Manhattan],[a.xL.Onehot]:l[a.xL.Onehot]},[a.EG.BitArray]:{[a.aT.Tanimoto]:u[a.aT.Tanimoto],[a.aT.Dice]:u[a.aT.Dice],[a.aT.Asymmetric]:u[a.aT.Asymmetric],[a.aT.BraunBlanquet]:u[a.aT.BraunBlanquet],[a.aT.Cosine]:u[a.aT.Cosine],[a.aT.Kulczynski]:u[a.aT.Kulczynski],[a.aT.McConnaughey]:u[a.aT.McConnaughey],[a.aT.RogotGoldberg]:u[a.aT.RogotGoldberg],[a.aT.Russel]:u[a.aT.Russel],[a.aT.Sokal]:u[a.aT.Sokal]},[a.EG.MacroMolecule]:{[i.Z.HAMMING]:i.V[i.Z.HAMMING],[i.Z.LEVENSHTEIN]:i.V[i.Z.LEVENSHTEIN],[i.Z.NEEDLEMANN_WUNSCH]:i.V[i.Z.NEEDLEMANN_WUNSCH],[i.Z.MONOMER_CHEMICAL_DISTANCE]:i.V[i.Z.MONOMER_CHEMICAL_DISTANCE]},[a.EG.Number]:{[a.RR.Difference]:h[a.RR.Difference]},[a.EG.IntArray]:{[a.m6.TanimotoIntArray]:d[a.m6.TanimotoIntArray]},[a.EG.NumberArray]:{[a.Wn.CommonItems]:p[a.Wn.CommonItems]}};Object.keys(m).reduce(((e,t)=>{for(const n of Object.keys(m[t]))e[n]=t;return e}),{})},8774:(e,t,n)=>{"use strict";n.d(t,{A:()=>r});class r{constructor(e,t=!1){if(this._length=0,this._version=0,this._updateLevel=0,this._selectedCount=0,this._selectedCountVersion=-1,this._selectedIndexesVersion=-1,this._versionedName="",this._versionedNameVersion=-1,this.SHRINK_THRESHOLD=256,"number"==typeof e){const n=e,o=r._createBuffer(n);if(t)for(let e=0;e<o.length;e++)o[e]=-1;this._data=o,this._length=n}else{if(!(e instanceof Uint32Array))throw new Error("Invalid constructor");this._data=e,this._length=t}}getRawData(){return this._data}assureGoez(e,t){if(e<0)throw new Error(`${t} should be greater than zero`)}assureInRange(e,t,n,r){if(e<t||e>n)throw new Error(`Argument ${r} (${e}) out of range (${t}, ${n})`)}copy(e,t,n){for(let r=0;r<n;r++)t[r]=e[r]}copyFrom(e){if(this._length!=e._length)throw new Error(`Lengths differ (${this._length} != ${e._length})`);this.copy(e._data,this._data,this.lengthInInts),this._version++}get length(){return this._length}get buffer(){return this._data}set buffer(e){this._data=e,this._version++}get version(){return this._version}set version(e){this._version=e}incrementVersion(e=!0){this._version++}get lengthInInts(){return Math.floor((this._length+31)/32)}get versionedName(){return this._version==this._versionedNameVersion?this._versionedName:""}set versionedName(e){this._versionedName=e,this._versionedNameVersion=this._version}get self(){return this}setLength(e){if(e<0)throw new Error("should be >= 0");if(e==this._length)return;const t=Math.floor((e+31)/32);if(t>this._data.length||t+this.SHRINK_THRESHOLD<this._data.length){const e=new Uint32Array(t);this.copy(this._data,e,t>this._data.length?this._data.length:t),this._data=e}e>this._length&&(this._length%32>0&&(this._data[this.lengthInInts-1]&=(1<<(this._length%32&31))-1),this._data.fill(0,this.lengthInInts,t)),this._length=e,this._version++}static fromAnd(e,t){if(e._length!=t._length)throw new Error(`Lengths differ (${e._length} != ${t._length})`);const n=new r(e._length);n._length=e._length,n._data=r._createBuffer(n._length),n._version=0;const o=e.lengthInInts;for(let r=0;r<o;r++)n._data[r]=e._data[r]&t._data[r];return n}static _createBuffer(e){return new Uint32Array(Math.floor((e+31)/32))}static fromValues(e){const t=new r(e.length);t._version=0;for(let n=0;n<t._length;n++)e[n]&&(t._data[Math.floor(n/32)]|=1<<(n%32&31));return t}static fromSeq(e,t){const n=new r(e);for(let r=0;r<e;++r)n.setBit(r,t(r));return n._version=0,n}static fromString(e){return r.fromSeq(e.length,(t=>"1"==e.charAt(t)))}static fromUint32Array(e,t){const n=new r(e);return n._data=t,n}static fromBytes(e){const t=e.length,n=new r(8*t);n._data=new Uint32Array(Math.floor((t+3)/4)),n._length=8*t;let o=0,s=0;for(;t-s>=4;)n._data[o++]=255&e[s]|(255&e[s+1])<<8|(255&e[s+2])<<16|(255&e[s+3])<<24,s+=4;return t-s==3&&(n._data[o]=(255&e[s+2])<<16),t-s==2&&(n._data[o]|=(255&e[s+1])<<8),t-s==1&&(n._data[o]|=255&e[s]),n._version=0,n}toString(){return`${this._length} bits, ${this.countBits(!0)} set`}equals(e){if(this==e)return!0;if(null==e)return!1;if(this._length!=e._length)return!1;if(0==this._length)return!0;for(let t=0;t<this._data.length-1;t++)if(this._data[t]!=e._data[t])return!1;for(let t=8*(this._data.length-1);t<this._length;t++)if(this.getBit(t)!=e.getBit(t))return!1;return!0}clone(){const e=new r(0,!1);return e._data=Uint32Array.from(this._data),e._length=this._length,e._version=this._version,e}init(e,t){this.setAll(!1,!1);for(let t=0;t<this._length;t++)e(t)&&(this._data[Math.floor(t/32)]|=1<<(t%32&31));return this.incrementVersion(t),this}invert(e=!0){for(let e=0;e<this._data.length;e++)this._data[e]^=-1;this.incrementVersion(e)}setAll(e,t=!1){const n=e?-1:0,r=this.lengthInInts;for(let e=0;e<r;e++)this._data[e]=n;this.incrementVersion(t)}setIndexes(e,t=!0,n=!0,r=!0){n&&this.setAll(!t,!1);for(const n of e)this.setFast(n,t);this.incrementVersion(r)}everyIndex(e,t=!0){for(const n of e)if(this.getBit(n)!=t)return!1;return!0}anyIndex(e,t=!0){for(const n of e)if(this.getBit(n)==t)return!0;return!1}setWhere(e,t=!0,n=!0,r=!0,o=!0){if(n&&o&&this.setAll(!t,!1),o)for(let n=0;n<this._length;n++)e(n)&&this.setFast(n,t);else for(let n=0;n<this._length;n++)this.setFast(n,e(n)?t:!t);this.incrementVersion(r)}getRange(e,t){this.assureInRange(e,0,this._length-1,"from"),this.assureInRange(t,0,this._length,"to");const n=[];for(let r=e;r<t;++r)n.push(this.getBit(r));return r.fromValues(n)}getRangeAsList(e,t){this.assureInRange(e,0,this._length-1,"from"),this.assureInRange(t,0,this._length,"to");const n=[];for(let r=e;r<t;++r)n.push(this.getBit(r));return n}setRange(e,t,n,r=!0){this.assureInRange(e,0,this._length-1,"from"),this.assureInRange(t,0,this._length-1,"to");const o=Math.min(e,t),s=Math.max(e,t);if(n)for(let e=o;e<=s;e++)this.setTrue(e);else for(let e=o;e<=s;e++)this.setFalse(e);return this.incrementVersion(r),this}setRandom(e,t,n=!0){if(e<0||e>this._length)throw new Error("n must be >= 0 && <= Count");e>this._length/2&&this.setRandom(this._length-e,!t),this.setAll(!t);for(let n=0;n<e;){const e=Math.floor(Math.random()*this._length);this.getBit(e)!=t&&(this.setFast(e,t),n++)}this.incrementVersion(n)}and(e,t=!0){if(this._length!=e._length)throw new Error("Array lengths differ.");for(let t=0,n=this.lengthInInts;t<n;t++)this._data[t]&=e._data[t];return this.incrementVersion(t),this}andNot(e,t=!0){if(this._length!=e._length)throw new Error("Array lengths differ.");const n=this.lengthInInts;for(let t=0;t<n;t++)this._data[t]&=~e._data[t];return this.incrementVersion(t),this}notAnd(e,t=!0){if(this._length!=e._length)throw new Error("Array lengths differ.");for(let t=0,n=this.lengthInInts;t<n;t++)this._data[t]=~this._data[t]&e._data[t];return this.incrementVersion(t),this}not(e=!0){for(let e=0,t=this.lengthInInts;e<t;e++)this._data[e]=~this._data[e];return this.incrementVersion(e),this}or(e,t=!0){if(this._length!=e._length)throw new Error("Array lengths differ.");for(let t=0,n=this.lengthInInts;t<n;t++)this._data[t]|=e._data[t];return this.incrementVersion(t),this}xor(e,t=!0){if(this._length!=e._length)throw new Error("Array lengths differ.");for(let t=0,n=this.lengthInInts;t<n;t++)this._data[t]^=e._data[t];return this.incrementVersion(t),this}insertAt(e,t,n=!1){if(this.assureInRange(e,0,this._length,"pos"),0==t)return;const r=this._length;this.setLength(this._length+t);for(let n=r-1;n>=e;n--)this.setBit(n+t,this.getBit(n));for(let r=e;r<e+t;r++)this.setBit(r,n)}removeAt(e,t=1){if(t<0)throw new Error("n cannot be negative");if(this.assureInRange(e,0,this._length-t,"pos"),this.contains(!0))for(let n=e;n<this._length-t;n++)this.setBit(n,this.getBit(n+t));this.setLength(this._length-t)}removeByMask(e,t=!0){if(this._length!=e.length)throw new Error("length != mask.length");if(e==this)this.setLength(e.countBits(!t)),this.setAll(!t);else{let n=0;for(let r=-1;-1!=(r=e.findNext(r,!t));)this.setFast(n++,this.getBit(r));this._length=n,this._version++}return this}getBit(e){return!!(this._data[Math.floor(e/32)]&1<<(31&e))}setBit(e,t,n=!0){this.setFast(e,t),this._version++}setFast(e,t){t?this._data[Math.floor(e/32)]|=1<<(31&e):this._data[Math.floor(e/32)]&=~(1<<(31&e))}setTrue(e){this._data[Math.floor(e/32)]|=1<<(31&e)}setFalse(e){this._data[Math.floor(e/32)]&=~(1<<(31&e))}trueCount(){return this.countBits(!0)}falseCount(){return this.countBits(!1)}countBits(e){if(0==this._length)return 0;if(this._selectedCountVersion!=this._version){this._selectedCount=0;const e=this.lengthInInts;let t=0;for(;t<e-1;t++)for(let e=this._data[t];0!=e;e>>>=8)this._selectedCount+=r._onBitCount[255&e];let n=this._data[t];const o=31&this._length;for(0!=o&&(n&=~(4294967295<<o));0!=n;n>>>=8)this._selectedCount+=r._onBitCount[255&n];this._selectedCountVersion=this._version}return e?this._selectedCount:this._length-this._selectedCount}countWhere(e){let t=0;if(this.trueCount()==this._length)for(let n=0;n<this._length;n++)t+=e(n)?1:0;else for(let n=-1;-1!=(n=this.findNext(n,!0));)t+=e(n)?1:0;return t}andWithCountBits(e,t){if(0==this._length)return 0;let n=0;const o=this.lengthInInts;let s=0;for(;s<o-1;s++)for(let t=this._data[s]&e._data[s];0!=t;t>>>=8)n+=r._onBitCount[255&t];let i=this._data[s]&e._data[s];const a=31&this._length;for(0!=a&&(i&=~(4294967295<<a));0!=i;i>>>=8)n+=r._onBitCount[255&i];return t?n:this._length-n}clear(){this.setLength(0)}contains(e){return this.findNext(-1,e)>=0}get allTrue(){return this.countBits(!0)==this._length}get allFalse(){return this.countBits(!1)==this._length}get anyTrue(){return this.countBits(!0)>0}get anyFalse(){return this.countBits(!1)>0}findNext(e,t=!0){if(this.assureInRange(e,-1,this._length,"index"),e>=this._length-1)return-1;let n=31&(e=e<0?0:e+1);const o=this.lengthInInts;for(let s=Math.floor(e/32);s<o;s++){let o=t?this._data[s]:~this._data[s];if(0!=n)o&=4294967295<<n&4294967295,n=0;else if(!t&&-4294967296==o)continue;for(let t=0;0!=o;t+=8,o>>>=8){const n=r._firstOnBit[255&o];if(n>=0)return(e=n+32*s+t)>=this._length?-1:e}}return-1}findPrev(e,t=!0){if(0==e)return-1;this.assureInRange(e,-1,this._length,"index");let n=1+(e=e<0?this._length-1:e-1)&31;for(let o=Math.floor(e/32);o>=0;o--){let e=t?this._data[o]:~this._data[o];0!=n&&(e&=~(4294967295<<n),n=0);for(let t=24;0!=e;t-=8,e<<=8){const n=r._lastOnBit[e>>>24];if(n>=0)return n+32*o+t}}return-1}}r._onBitCount=Int8Array.from([0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8]),r._firstOnBit=Int8Array.from([-1,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,7,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0]),r._lastOnBit=Int8Array.from([-1,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7])},8070:(e,t,n)=>{"use strict";n.d(t,{Pl:()=>D,bk:()=>K,gM:()=>G,L1:()=>k,cb:()=>j,E3:()=>L,J6:()=>O,Wj:()=>I,Xk:()=>R,Xb:()=>F,N$:()=>V,t6:()=>$,PE:()=>x,rd:()=>N,Bl:()=>Z,CN:()=>w});var r=n(4328),o=n(6082);n(9982);const s=o.DataFrame.fromCsv('countries,fasta,smiles,molregno,LON,Zip Code,Street Address Line 1,ImageUrl,user_id,error_message,xray,flag,magnitude,CS-id,pdb_id,accel_a,time_offset,chart,fit,Questions,empty_number,empty_string\nBelgium,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C(=O)OCCCc1cccnc1)c2cccc(c2)C(=O)c3ccccc3,1480014,36.276729583740234,995042300,14016 ROUTE 31W,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,1,1,1QBS,1,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.497360340644872, 1.7058694986686864, 5.278052678195135, 0.16000320889028383],""points"":[{""x"":0.10000000149011612,""y"":2.374499797821045},{""x"":0.6000000238418579,""y"":2.6242473125457764},{""x"":1.100000023841858,""y"":2.367267608642578},{""x"":1.600000023841858,""y"":2.6723148822784424},{""x"":2.0999999046325684,""y"":2.6537344455718994},{""x"":2.5999999046325684,""y"":2.3651671409606934},{""x"":3.0999999046325684,""y"":2.5654284954071045},{""x"":3.5999999046325684,""y"":2.4160959720611572},{""x"":4.099999904632568,""y"":2.286726713180542},{""x"":4.599999904632568,""y"":2.5100042819976807},{""x"":5.099999904632568,""y"":1.6676985025405884},{""x"":5.599999904632568,""y"":0.680136501789093},{""x"":6.099999904632568,""y"":0.3391543924808502},{""x"":6.599999904632568,""y"":0.09038983285427094},{""x"":7.099999904632568,""y"":0.19802775979042053}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[7.525235855508179, 1.3186911876809984, 5.335672608564294, 0.7860743343958098],""points"":[{""x"":0.10000000149011612,""y"":7.988070487976074},{""x"":0.6000000238418579,""y"":7.018453121185303},{""x"":1.100000023841858,""y"":8.115279197692871},{""x"":1.600000023841858,""y"":7.486658096313477},{""x"":2.0999999046325684,""y"":7.396438121795654},{""x"":2.5999999046325684,""y"":7.477052211761475},{""x"":3.0999999046325684,""y"":6.913095474243164},{""x"":3.5999999046325684,""y"":8.01385498046875},{""x"":4.099999904632568,""y"":6.985900402069092},{""x"":4.599999904632568,""y"":6.970335960388184},{""x"":5.099999904632568,""y"":5.448817253112793},{""x"":5.599999904632568,""y"":2.5534818172454834},{""x"":6.099999904632568,""y"":1.893947958946228},{""x"":6.599999904632568,""y"":0.6340042352676392},{""x"":7.099999904632568,""y"":0.8403874039649963}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,100,abc\nBurundi,MDYKETLLMPKTDFPMRGGLPNKEPQIQEKW,COc1ccc2cc(ccc2c1)C(C)C(=O)Oc3ccc(C)cc3OC,1480015,36.276729583740234,995073444,80 STATE HIGHWAY 310,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,2,2,1ZP8,2,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.431460753103398, 2.1691498799246745, 5.266445597102774, 0.7825762827017926],""points"":[{""x"":0.10000000149011612,""y"":4.751083850860596},{""x"":0.6000000238418579,""y"":4.203000068664551},{""x"":1.100000023841858,""y"":4.415858745574951},{""x"":1.600000023841858,""y"":4.68414306640625},{""x"":2.0999999046325684,""y"":4.198400974273682},{""x"":2.5999999046325684,""y"":4.179222106933594},{""x"":3.0999999046325684,""y"":4.638473987579346},{""x"":3.5999999046325684,""y"":4.708553314208984},{""x"":4.099999904632568,""y"":4.291589260101318},{""x"":4.599999904632568,""y"":4.038082599639893},{""x"":5.099999904632568,""y"":3.4349939823150635},{""x"":5.599999904632568,""y"":1.2194708585739136},{""x"":6.099999904632568,""y"":1.1920831203460693},{""x"":6.599999904632568,""y"":0.5352635979652405},{""x"":7.099999904632568,""y"":0.3346920311450958}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.339458017970126, -1.0734184310171178, 4.746332950550934, 0.2482416857595658],""points"":[{""x"":0.10000000149011612,""y"":0.2139337658882141},{""x"":0.6000000238418579,""y"":0.4269562065601349},{""x"":1.100000023841858,""y"":0.2441573292016983},{""x"":1.600000023841858,""y"":0.146635964512825},{""x"":2.0999999046325684,""y"":0.08818462491035461},{""x"":2.5999999046325684,""y"":0.2560656666755676},{""x"":3.0999999046325684,""y"":0.42434045672416687},{""x"":3.5999999046325684,""y"":0.37111231684684753},{""x"":4.099999904632568,""y"":0.5581737160682678},{""x"":4.599999904632568,""y"":1.183590054512024},{""x"":5.099999904632568,""y"":1.5629843473434448},{""x"":5.599999904632568,""y"":2.3211288452148438},{""x"":6.099999904632568,""y"":2.229961633682251},{""x"":6.599999904632568,""y"":2.2560226917266846},{""x"":7.099999904632568,""y"":2.2142398357391357}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCameroon,MIEVFLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL,COc1ccc2cc(ccc2c1)C(C)C(=O)OCCCc3cccnc3,1480016,36.26095962524414,995153596,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,3,3,2BDJ,3,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.6760652578642325, 0.9046956320756703, 5.651408971856738, 0.07738846012184185],""points"":[{""x"":0.10000000149011612,""y"":4.32425594329834},{""x"":0.6000000238418579,""y"":4.668442249298096},{""x"":1.100000023841858,""y"":4.379785060882568},{""x"":1.600000023841858,""y"":5.0345139503479},{""x"":2.0999999046325684,""y"":4.878653526306152},{""x"":2.5999999046325684,""y"":4.3451313972473145},{""x"":3.0999999046325684,""y"":4.336992263793945},{""x"":3.5999999046325684,""y"":5.037430286407471},{""x"":4.099999904632568,""y"":5.0092692375183105},{""x"":4.599999904632568,""y"":4.151902675628662},{""x"":5.099999904632568,""y"":3.4066951274871826},{""x"":5.599999904632568,""y"":2.3732759952545166},{""x"":6.099999904632568,""y"":1.673728108406067},{""x"":6.599999904632568,""y"":0.48574790358543396},{""x"":7.099999904632568,""y"":0.2783052325248718}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.938395863010111, -1.4658480661392117, 5.462702751996584, 0.3473139023615039],""points"":[{""x"":0.10000000149011612,""y"":0.4941710829734802},{""x"":0.6000000238418579,""y"":0.15323974192142487},{""x"":1.100000023841858,""y"":0.46373432874679565},{""x"":1.600000023841858,""y"":0.3370431363582611},{""x"":2.0999999046325684,""y"":0.5179030299186707},{""x"":2.5999999046325684,""y"":0.27899765968322754},{""x"":3.0999999046325684,""y"":0.22075064480304718},{""x"":3.5999999046325684,""y"":0.5789918899536133},{""x"":4.099999904632568,""y"":0.21169911324977875},{""x"":4.599999904632568,""y"":0.27857646346092224},{""x"":5.099999904632568,""y"":1.0906332731246948},{""x"":5.599999904632568,""y"":1.8520300388336182},{""x"":6.099999904632568,""y"":2.7177059650421143},{""x"":6.599999904632568,""y"":2.8680918216705322},{""x"":7.099999904632568,""y"":3.2413077354431152}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCanada,MMELVLKTIIGPIVVGVVLRIVDKWLNKDK,CC(C(=O)NCCS)c1cccc(c1)C(=O)c2ccccc2,1480017,36.26095962524414,99515,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,4,4,1IAN,4,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[0.8597390975430008, 1.0957625732481946, 5.260537067987958, 0.07974187998177736],""points"":[{""x"":0.10000000149011612,""y"":0.8190152645111084},{""x"":0.6000000238418579,""y"":0.8421689867973328},{""x"":1.100000023841858,""y"":0.8740922212600708},{""x"":1.600000023841858,""y"":0.8924275040626526},{""x"":2.0999999046325684,""y"":0.8249067664146423},{""x"":2.5999999046325684,""y"":0.9327669143676758},{""x"":3.0999999046325684,""y"":0.8522974252700806},{""x"":3.5999999046325684,""y"":0.8174492716789246},{""x"":4.099999904632568,""y"":0.8394647240638733},{""x"":4.599999904632568,""y"":0.7139387726783752},{""x"":5.099999904632568,""y"":0.5561167597770691},{""x"":5.599999904632568,""y"":0.3276226818561554},{""x"":6.099999904632568,""y"":0.12479474395513535},{""x"":6.599999904632568,""y"":0.13006797432899475},{""x"":7.099999904632568,""y"":0.059702079743146896}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.760930219582546, 1.6591793293833013, 4.667155929720851, 0.7858109544121652],""points"":[{""x"":0.10000000149011612,""y"":6.156993389129639},{""x"":0.6000000238418579,""y"":5.236701965332031},{""x"":1.100000023841858,""y"":6.010560512542725},{""x"":1.600000023841858,""y"":5.495512962341309},{""x"":2.0999999046325684,""y"":6.087770462036133},{""x"":2.5999999046325684,""y"":5.79986572265625},{""x"":3.0999999046325684,""y"":5.597546577453613},{""x"":3.5999999046325684,""y"":5.520902156829834},{""x"":4.099999904632568,""y"":5.360654354095459},{""x"":4.599999904632568,""y"":3.5539746284484863},{""x"":5.099999904632568,""y"":1.577236294746399},{""x"":5.599999904632568,""y"":1.0001264810562134},{""x"":6.099999904632568,""y"":0.9305797815322876},{""x"":6.599999904632568,""y"":0.6033638715744019},{""x"":7.099999904632568,""y"":0.4203685522079468}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nColombia,MDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN,FC(F)(F)c1ccc(OC2CCNCC2)cc1,1480029,36.3309440612793,995152050,1 COURT HOUSE SQUARE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,5,5,4UJ1,5,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[6.4995088314153655, 2.4270351004539914, 5.178659535348579, 0.625653346241577],""points"":[{""x"":0.10000000149011612,""y"":6.496231555938721},{""x"":0.6000000238418579,""y"":6.42543363571167},{""x"":1.100000023841858,""y"":7.040063858032227},{""x"":1.600000023841858,""y"":6.1115403175354},{""x"":2.0999999046325684,""y"":6.680728435516357},{""x"":2.5999999046325684,""y"":6.406774520874023},{""x"":3.0999999046325684,""y"":6.611269474029541},{""x"":3.5999999046325684,""y"":5.889094352722168},{""x"":4.099999904632568,""y"":6.75344705581665},{""x"":4.599999904632568,""y"":6.361435890197754},{""x"":5.099999904632568,""y"":4.1666975021362305},{""x"":5.599999904632568,""y"":1.172118902206421},{""x"":6.099999904632568,""y"":0.801048994064331},{""x"":6.599999904632568,""y"":0.4640021026134491},{""x"":7.099999904632568,""y"":0.0010357667924836278}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[1.4734381347446401, 1.1649805188074196, 4.82958608866421, 0.09500545496710007],""points"":[{""x"":0.10000000149011612,""y"":1.5279096364974976},{""x"":0.6000000238418579,""y"":1.3559974431991577},{""x"":1.100000023841858,""y"":1.5246378183364868},{""x"":1.600000023841858,""y"":1.5567657947540283},{""x"":2.0999999046325684,""y"":1.4114240407943726},{""x"":2.5999999046325684,""y"":1.4045010805130005},{""x"":3.0999999046325684,""y"":1.4769829511642456},{""x"":3.5999999046325684,""y"":1.4875500202178955},{""x"":4.099999904632568,""y"":1.2991987466812134},{""x"":4.599999904632568,""y"":0.922961413860321},{""x"":5.099999904632568,""y"":0.6520044803619385},{""x"":5.599999904632568,""y"":0.15350978076457977},{""x"":6.099999904632568,""y"":0.1078903079032898},{""x"":6.599999904632568,""y"":0.17276449501514435},{""x"":7.099999904632568,""y"":0.14066608250141144}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCosta Rica,MKSTKEEIQTIKTLLKDSRTAKYHKRLQIVL,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCCc3ccccc3,1480018,36.3309440612793,995084218,4041 SOUTHWESTERN BLVD,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,6,6,2BPW,6,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.4833641843311227, -1.8945978742090062, 4.671127708092568, 0.24159861311815153],""points"":[{""x"":0.10000000149011612,""y"":0.0969524160027504},{""x"":0.6000000238418579,""y"":0.028483040630817413},{""x"":1.100000023841858,""y"":0.22087176144123077},{""x"":1.600000023841858,""y"":0.0068915546871721745},{""x"":2.0999999046325684,""y"":0.4305879771709442},{""x"":2.5999999046325684,""y"":0.44774115085601807},{""x"":3.0999999046325684,""y"":0.45346319675445557},{""x"":3.5999999046325684,""y"":0.2370593100786209},{""x"":4.099999904632568,""y"":0.4657953977584839},{""x"":4.599999904632568,""y"":1.155200719833374},{""x"":5.099999904632568,""y"":2.2294070720672607},{""x"":5.599999904632568,""y"":2.4311530590057373},{""x"":6.099999904632568,""y"":2.33846116065979},{""x"":6.599999904632568,""y"":2.608201026916504},{""x"":7.099999904632568,""y"":2.8136143684387207}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.224573521642033, 1.4454033924198528, 5.6014197746076535, 0.2823216054197577],""points"":[{""x"":0.10000000149011612,""y"":4.95027494430542},{""x"":0.6000000238418579,""y"":5.1754679679870605},{""x"":1.100000023841858,""y"":5.276752948760986},{""x"":1.600000023841858,""y"":5.589294910430908},{""x"":2.0999999046325684,""y"":5.616994857788086},{""x"":2.5999999046325684,""y"":5.120813846588135},{""x"":3.0999999046325684,""y"":5.340766906738281},{""x"":3.5999999046325684,""y"":4.876471042633057},{""x"":4.099999904632568,""y"":4.94999361038208},{""x"":4.599999904632568,""y"":5.162564754486084},{""x"":5.099999904632568,""y"":4.399557590484619},{""x"":5.599999904632568,""y"":2.7977969646453857},{""x"":6.099999904632568,""y"":1.0229872465133667},{""x"":6.599999904632568,""y"":0.48275601863861084},{""x"":7.099999904632568,""y"":0.10408931970596313}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCuba,MHAILRYFIRRLFYHIFYKIYSLISKKHQSLPSDVRQF,COc1ccc2c(c1)c(CC(=O)N3CCCC3C(=O)Oc4ccc(C)cc4OC)c(C)n2C(=O)c5ccc(Cl)cc5,1480019,36.33115768432617,995081928,1227 US HIGHWAY 11,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,7,7,1QBS,7,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.320838679713925, -1.2421619987316728, 4.831325425225256, 0.3236011098403072],""points"":[{""x"":0.10000000149011612,""y"":0.3727470338344574},{""x"":0.6000000238418579,""y"":0.12365014106035233},{""x"":1.100000023841858,""y"":0.48422467708587646},{""x"":1.600000023841858,""y"":0.2264465093612671},{""x"":2.0999999046325684,""y"":0.16821794211864471},{""x"":2.5999999046325684,""y"":0.3879014551639557},{""x"":3.0999999046325684,""y"":0.5470244884490967},{""x"":3.5999999046325684,""y"":0.3419053554534912},{""x"":4.099999904632568,""y"":0.7655120491981506},{""x"":4.599999904632568,""y"":1.2346516847610474},{""x"":5.099999904632568,""y"":2.453336715698242},{""x"":5.599999904632568,""y"":2.9565491676330566},{""x"":6.099999904632568,""y"":3.335299491882324},{""x"":6.599999904632568,""y"":3.240290880203247},{""x"":7.099999904632568,""y"":3.1107218265533447}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.6401853521511094, 1.26211588875013, 5.399028074402744, 0.5089580830068091],""points"":[{""x"":0.10000000149011612,""y"":3.8585598468780518},{""x"":0.6000000238418579,""y"":3.6077206134796143},{""x"":1.100000023841858,""y"":3.855252265930176},{""x"":1.600000023841858,""y"":3.619039297103882},{""x"":2.0999999046325684,""y"":3.839388370513916},{""x"":2.5999999046325684,""y"":3.335283041000366},{""x"":3.0999999046325684,""y"":3.571141481399536},{""x"":3.5999999046325684,""y"":3.4155046939849854},{""x"":4.099999904632568,""y"":3.7316646575927734},{""x"":4.599999904632568,""y"":3.0680155754089355},{""x"":5.099999904632568,""y"":2.891066551208496},{""x"":5.599999904632568,""y"":1.6022753715515137},{""x"":6.099999904632568,""y"":0.7652576565742493},{""x"":6.599999904632568,""y"":0.6875326037406921},{""x"":7.099999904632568,""y"":0.5828871726989746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nItaly,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO[N+](=O)[O-],1480020,36.33115768432617,99502,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,8,8,1ZP8,8,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.293592105923809, 1.3781586549141835, 5.1025898038676605, 0.03493851245291291],""points"":[{""x"":0.10000000149011612,""y"":2.1287283897399902},{""x"":0.6000000238418579,""y"":2.267972230911255},{""x"":1.100000023841858,""y"":2.398442506790161},{""x"":1.600000023841858,""y"":2.5130622386932373},{""x"":2.0999999046325684,""y"":2.3255116939544678},{""x"":2.5999999046325684,""y"":2.127340793609619},{""x"":3.0999999046325684,""y"":2.47259783744812},{""x"":3.5999999046325684,""y"":2.131181478500366},{""x"":4.099999904632568,""y"":2.090421438217163},{""x"":4.599999904632568,""y"":2.02299165725708},{""x"":5.099999904632568,""y"":1.1105059385299683},{""x"":5.599999904632568,""y"":0.4494485855102539},{""x"":6.099999904632568,""y"":0.1375635862350464},{""x"":6.599999904632568,""y"":0.036351121962070465},{""x"":7.099999904632568,""y"":0.1619771122932434}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.953125499439879, 1.2528620255306528, 5.187637440149802, 0.3110348753260886],""points"":[{""x"":0.10000000149011612,""y"":5.6585283279418945},{""x"":0.6000000238418579,""y"":5.911152362823486},{""x"":1.100000023841858,""y"":5.924920082092285},{""x"":1.600000023841858,""y"":5.8469438552856445},{""x"":2.0999999046325684,""y"":5.929472923278809},{""x"":2.5999999046325684,""y"":6.190037727355957},{""x"":3.0999999046325684,""y"":6.236179828643799},{""x"":3.5999999046325684,""y"":6.141019344329834},{""x"":4.099999904632568,""y"":5.295210838317871},{""x"":4.599999904632568,""y"":5.265801906585693},{""x"":5.099999904632568,""y"":3.3722851276397705},{""x"":5.599999904632568,""y"":1.8299226760864258},{""x"":6.099999904632568,""y"":0.32690900564193726},{""x"":6.599999904632568,""y"":0.6274543404579163},{""x"":7.099999904632568,""y"":0.8441857099533081}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nRwanda,MPNSEPASLLELFNSIATQGELVRSLKAGNASK,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO,1480021,36.33137130737305,995037247,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,9,9,2BDJ,9,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.8209972202654474, 1.3779216716448506, 5.299882228439686, 0.06040645519069608],""points"":[{""x"":0.10000000149011612,""y"":3.7821109294891357},{""x"":0.6000000238418579,""y"":3.542433023452759},{""x"":1.100000023841858,""y"":3.7008674144744873},{""x"":1.600000023841858,""y"":3.717301607131958},{""x"":2.0999999046325684,""y"":4.024452209472656},{""x"":2.5999999046325684,""y"":4.013899326324463},{""x"":3.0999999046325684,""y"":3.945094347000122},{""x"":3.5999999046325684,""y"":3.866621971130371},{""x"":4.099999904632568,""y"":3.7461626529693604},{""x"":4.599999904632568,""y"":3.3454740047454834},{""x"":5.099999904632568,""y"":2.61944317817688},{""x"":5.599999904632568,""y"":0.999405026435852},{""x"":6.099999904632568,""y"":0.46259793639183044},{""x"":6.599999904632568,""y"":0.054134611040353775},{""x"":7.099999904632568,""y"":0.05711187422275543}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.6318079657726035, 1.8495493770000595, 5.391793312471116, 0.17060707587348442],""points"":[{""x"":0.10000000149011612,""y"":5.458079814910889},{""x"":0.6000000238418579,""y"":5.554427146911621},{""x"":1.100000023841858,""y"":5.799983024597168},{""x"":1.600000023841858,""y"":5.364140033721924},{""x"":2.0999999046325684,""y"":5.864485740661621},{""x"":2.5999999046325684,""y"":5.4509806632995605},{""x"":3.0999999046325684,""y"":5.702574729919434},{""x"":3.5999999046325684,""y"":5.7314534187316895},{""x"":4.099999904632568,""y"":5.5123443603515625},{""x"":4.599999904632568,""y"":5.724395751953125},{""x"":5.099999904632568,""y"":4.354506969451904},{""x"":5.599999904632568,""y"":1.7307666540145874},{""x"":6.099999904632568,""y"":0.6305936574935913},{""x"":6.599999904632568,""y"":0.035183437168598175},{""x"":7.099999904632568,""y"":0.7575169205665588}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nSwitzerland,IRVVGRYLIEVWKAAGMDMDKVLFLWSSDEI,CN1CCC(CC1)Oc2ccc(cc2)C(F)(F)F,1480028,36.33137130737305,99504,92-11 179TH PLACE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,9,10,1IAN,10,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[1.1190255865097471, 2.3163895161544437, 5.4968866182279195, 0.2035204047289052],""points"":[{""x"":0.10000000149011612,""y"":1.1057683229446411},{""x"":0.6000000238418579,""y"":1.1019697189331055},{""x"":1.100000023841858,""y"":1.0818607807159424},{""x"":1.600000023841858,""y"":1.062997817993164},{""x"":2.0999999046325684,""y"":1.046447515487671},{""x"":2.5999999046325684,""y"":1.1217249631881714},{""x"":3.0999999046325684,""y"":1.2166996002197266},{""x"":3.5999999046325684,""y"":1.215477705001831},{""x"":4.099999904632568,""y"":1.0581893920898438},{""x"":4.599999904632568,""y"":1.1747995615005493},{""x"":5.099999904632568,""y"":1.0181127786636353},{""x"":5.599999904632568,""y"":0.5344523191452026},{""x"":6.099999904632568,""y"":0.2569526433944702},{""x"":6.599999904632568,""y"":0.1912207305431366},{""x"":7.099999904632568,""y"":0.15060538053512573}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.1038581025805785, 2.0032224204185245, 5.087602825989163, 0.13277988512492753],""points"":[{""x"":0.10000000149011612,""y"":3.0498509407043457},{""x"":0.6000000238418579,""y"":2.805217742919922},{""x"":1.100000023841858,""y"":3.3415253162384033},{""x"":1.600000023841858,""y"":3.0549843311309814},{""x"":2.0999999046325684,""y"":3.250074863433838},{""x"":2.5999999046325684,""y"":3.0432586669921875},{""x"":3.0999999046325684,""y"":3.265852451324463},{""x"":3.5999999046325684,""y"":2.9475724697113037},{""x"":4.099999904632568,""y"":3.1929898262023926},{""x"":4.599999904632568,""y"":2.7460060119628906},{""x"":5.099999904632568,""y"":1.6175861358642578},{""x"":5.599999904632568,""y"":0.3006608486175537},{""x"":6.099999904632568,""y"":0.3444803059101105},{""x"":6.599999904632568,""y"":0.015537971630692482},{""x"":7.099999904632568,""y"":0.5527358055114746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\n,,,,,,,,,,,,,,,,,,,,,');s.columns.add(o.Column.fromList(o.TYPE.BYTE_ARRAY,"BinaryImage",Array.from(new Uint8Array(11))));var i=function(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}c((r=r.apply(e,t||[])).next())}))};function a(e,t,n,o,s,a,c,l,u=!0){return i(this,void 0,void 0,(function*(){let d=null;if(yield N(o,(n=>i(this,void 0,void 0,(function*(){let n=null;for(const r of e.viewers)r.type===t&&(n=r);if(!n)throw Error("Viewer hasn't been added");if(yield Promise.resolve(),a&&(yield a(n)),s){const t=null!=l?l:{};t.tv=e,t.viewer=n,d=yield s(t,u)}yield x(r.events.onViewerClosed,(()=>{L(n.subs.some((e=>!e.closed)),!1)}),(()=>n.close()),3e3)}))),(()=>i(this,void 0,void 0,(function*(){c?e.loadLayout(c):yield function(e,t,n){return i(this,void 0,void 0,(function*(){let r;return n?(r=yield e.dataFrame.plot.fromType(t),e.dockManager.dock(r)):r=e.addViewer(t),r}))}(e,t,n)}))),6e4,"TEST_EVENT_ASYNC"),d)return d}))}function c(e,t=!0){return i(this,void 0,void 0,(function*(){const n=e.tv.dataFrame,r=n.clone();Array.from(n.row(0).cells).forEach((e=>e.value=null));const o=n.rowCount<20?Math.floor(n.rowCount/2):10;n.rows.select((e=>e.idx>=0&&e.idx<o)),t&&(yield j(50));for(let e=o;e<2*o;e++)n.filter.set(e,!1);t&&(yield j(50)),n.currentRowIdx=1,n.columns.names().slice(0,Math.ceil(n.columns.length/2)).forEach((e=>n.columns.remove(e))),t&&(yield j(100)),e.tv.dataFrame=r,yield j(50)}))}function l(e,t=!0){return i(this,void 0,void 0,(function*(){const t=e.tv.dataFrame;setTimeout((()=>t.filter.set(0,!t.filter.get(0))),0)}))}function u(e,t=!0){return i(this,void 0,void 0,(function*(){let t,n;try{t=e.viewer.getOptions(!0).look}catch(e){throw new Error("Viewer's .getOptions() error.",{cause:e})}try{n=e.viewer.getProperties()}catch(e){throw new Error("Viewer's .getProperties() error.",{cause:e})}const r={};return Object.keys(t).filter((e=>"boolean"==typeof t[e])).forEach((e=>r[e]=!t[e])),n.filter((e=>null!==e.choices)).forEach((e=>r[e.name]=e.choices.find((n=>n!==t[e.name])))),e.viewer.setOptions(r),yield j(300),{layout:e.tv.saveLayout(),savedProps:e.viewer.getOptions().look}}))}function d(e,t=!0){return i(this,void 0,void 0,(function*(){L(JSON.stringify(e.viewer.getOptions().look),JSON.stringify(e.savedProps))}))}var h=function(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}c((r=r.apply(e,t||[])).next())}))};const p=3e4,m=108e5,f=console.log.bind(console),g=console.info.bind(console),y=console.warn.bind(console),b=console.error.bind(console),w={},v="Auto Tests",A="Demo",E="Detectors",C="Core",T={};let S;var _;!function(e){e.notNull=function(e,t){if(null==e)throw new Error(`${null==t?"Value":t} not defined`)}}(_||(_={}));class P{constructor(e,t){this.catchUnhandled=!0,this.report=!1,void 0!==e&&(this.catchUnhandled=e),void 0!==t&&(this.report=t)}}class M{constructor(e,t,n,r){var s;this.category=e,this.name=t,null!=r||(r={}),null!==(s=r.timeout)&&void 0!==s||(r.timeout=p),this.options=r,this.test=()=>h(this,void 0,void 0,(function*(){return new Promise(((e,t)=>h(this,void 0,void 0,(function*(){var r;let s="";try{o.Test.isInDebug;let e=yield n();try{s=null!==(r=null==e?void 0:e.toString())&&void 0!==r?r:""}catch(e){s="Can't convert test's result to string",console.error(`Can't convert test's result to string in the ${this.category}:${this.name} test`)}}catch(e){t(e)}e(s)}))))}))}}function x(e,t,n,r=0,o="timeout"){return h(this,void 0,void 0,(function*(){return new Promise(((s,i)=>{const a=e.subscribe((e=>{try{t(e),s("OK")}catch(e){i(e)}finally{a.unsubscribe(),clearTimeout(c)}})),c=setTimeout((()=>{a.unsubscribe(),i(o)}),r);n()}))}))}function N(e,t,n,r=0,o="timeout"){return h(this,void 0,void 0,(function*(){return new Promise(((s,i)=>{const a=e.subscribe((e=>{t(e).then((()=>{s("OK")})).catch((e=>{i(e)})).finally((()=>{a.unsubscribe(),clearTimeout(c)}))})),c=setTimeout((()=>{a.unsubscribe(),i(o)}),r);n()}))}))}function $(e,t,n){null==w[S]&&(w[S]={}),null==w[S].tests&&(w[S].tests=[]),w[S].tests.push(new M(S,e,t,n))}function L(e,t=!0,n){if(n=n?`${n}, `:"",e!==t)throw new Error(`${n}Expected "${t}", got "${e}"`)}function I(e,t,n=.001,r){if(e===Number.POSITIVE_INFINITY&&t===Number.POSITIVE_INFINITY||e===Number.NEGATIVE_INFINITY&&t===Number.NEGATIVE_INFINITY||e===Number.NaN&&t===Number.NaN||isNaN(e)&&isNaN(t))return;const o=Math.abs(e-t)<n;if(L(o,!0,`${null!=r?r:""} (tolerance = ${n})`),!o)throw new Error(`Expected ${t}, got ${e} (tolerance = ${n})`)}function R(e,t){for(const[n,r]of Object.entries(t)){if(!e.hasOwnProperty(n))throw new Error(`Expected property "${n}" not found`);const t=e[n];if(t instanceof Array&&r instanceof Array)O(t,r);else if(t instanceof Object&&r instanceof Object)R(t,r);else if(Number.isFinite(t)&&Number.isFinite(r))I(t,r);else if(t!=r)throw new Error(`Expected (${r}) for key '${n}', got (${t})`)}}function O(e,t){const n=e.length,r=t.length;if(n!=r)throw new Error(`Arrays are of different length: actual array length is ${n} and expected array length is ${r}`);for(let r=0;r<n;r++)if(e[r]instanceof Array&&t[r]instanceof Array)O(e[r],t[r]);else if(e[r]instanceof Object&&t[r]instanceof Object)R(e[r],t[r]);else if(e[r]!=t[r])throw new Error(`Expected ${t[r]} at position ${r}, got ${e[r]}`)}function k(e,t,n){var r;S=e,t(),w[S]&&(w[S].clear=null===(r=null==n?void 0:n.clear)||void 0===r||r,w[S].timeout=null==n?void 0:n.timeout,w[S].benchmarks=null==n?void 0:n.benchmarks,w[S].stressTests=null==n?void 0:n.stressTests,w[S].owner=null==n?void 0:n.owner)}function G(e){null==w[S]&&(w[S]={}),w[S].before=e}function D(e){null==w[S]&&(w[S]={}),w[S].after=e}function H(e,t){return e.replace(new RegExp(t.name,"gi"),t.nqName)}function F(e,t){var n,i,a,c,l,u,d,f,g,y;return h(this,void 0,void 0,(function*(){const b=e.id;if(T[b])return;const S=t?t.tests:w;if("DevTools"===e.name||t&&"DevTools"===t._package.name)for(const e of window.dartTests){const t=e.name.split(/\s*\|\s*!/g);let r=null!==(n=t.pop())&&void 0!==n?n:e.name,o=t.length?C+": "+t.join(": "):C,s=r.split(" | ");r=s[s.length-1],s.unshift(o),s.pop(),o=s.join(": "),void 0===S[o]&&(S[o]={tests:[],clear:!0}),S[o].tests.push(new M(o,r,e.test,{isAggregated:!1,timeout:null!==(a=null===(i=e.options)||void 0===i?void 0:i.timeout)&&void 0!==a?a:p,skipReason:null===(c=e.options)||void 0===c?void 0:c.skipReason,owner:null===(l=e.options)||void 0===l?void 0:l.owner,benchmark:null!==(d=null===(u=e.options)||void 0===u?void 0:u.benchmark)&&void 0!==d&&d}))}const _=[],P=[],x=[],N=yield r.dapi.functions.filter(`package.id = "${b}"`).list(),$=new RegExp(/skip:\s*([^,\s]+)|wait:\s*(\d+)|cat:\s*([^,\s]+)|timeout:\s*(\d+)/g);for(const t of N){const n=t.options.test,i=t.options.demoPath;if(n&&Array.isArray(n)&&n.length)for(let e=0;e<n.length;e++){const s=n[e].matchAll($),i={};Array.from(s).forEach((e=>{e[0].startsWith("skip")?i.skip=e[1]:e[0].startsWith("wait")?i.wait=parseInt(e[2]):e[0].startsWith("cat")?i.cat=e[3]:e[0].startsWith("timeout")&&(i.timeout=parseInt(e[4]))}));const a=new M(null!==(f=i.cat)&&void 0!==f?f:v,1===n.length?t.name:`${t.name} ${e+1}`,(()=>h(this,void 0,void 0,(function*(){const o=yield r.functions.eval(H(n[e],t));if(i.wait&&(yield j(i.wait)),"boolean"==typeof o&&!o)throw`Failed: ${n[e]}, expected true, got ${o}`}))),{skipReason:i.skip,timeout:o.Test.isInBenchmark?null!==(g=i.benchmarkTimeout)&&void 0!==g?g:m:null!==(y=i.timeout)&&void 0!==y?y:p});if(i.cat){const e=i.cat;void 0===S[e]&&(S[e]={tests:[],clear:!0}),S[e].tests||(S[e].tests=[]),S[e].tests.push(a)}else _.push(a)}if(i){const e=t.options.demoWait?parseInt(t.options.demoWait):void 0,n=new M(A,t.friendlyName,(()=>h(this,void 0,void 0,(function*(){yield j(300),r.shell.clearLastError(),yield t.apply(),yield j(e||2e3);const n=yield r.shell.lastError;if(n)throw new Error(n)}))),{skipReason:t.options.demoSkip});P.push(n)}if(t.hasTag("semTypeDetector")){let n=s;t.options.testData&&(n=yield r.data.files.openTable(`System:AppData/${e.nqName}/${t.options.testData}`));const o=new M(E,t.friendlyName,(()=>h(this,void 0,void 0,(function*(){const r=[];console.log(`System:AppData/${e.nqName}/${t.options.testData}`);for(const e of n.clone().columns){const n=yield t.apply([e]);r.push(n||e.semType)}const o=r.filter((e=>e));L(o.length,1),t.options.testDataColumnName&&L(o[0],t.options.testDataColumnName)}))),{skipReason:t.options.skipTest});x.push(o)}}T[b]=!0,_.length>0&&(S[v]={tests:_,clear:!0}),P.length>0&&(S[A]={tests:P,clear:!0}),x.length>0&&(S[E]={tests:x,clear:!1})}))}function V(e){var t,n,s,i,a,c;return h(this,void 0,void 0,(function*(){console.log("--------------------");const l=null===(n=null===(t=r.functions.getCurrentCall())||void 0===t?void 0:t.func)||void 0===n?void 0:n.package,u=(null!==(i=(null!==(s=null==l?void 0:l.packageOwner)&&void 0!==s?s:"").match(new RegExp("[^<]*<([^>]*)>")))&&void 0!==i?i:["",""])[1];yield F(l);const d=[];console.log("Running tests"),console.log(e),null!=e||(e={}),null!==(a=(c=e).testContext)&&void 0!==a||(c.testContext=new P),r.shell.clearLastError();const v=function(){const e=[];return console.log=(...t)=>{e.push(...t),f(...t)},console.info=(...t)=>{e.push(...t),g(...t)},console.warn=(...t)=>{e.push(...t),y(...t)},console.error=(...t)=>{e.push(...t),b(...t)},e}();yield function(e,t){var n,s,i,a,c,p,m;return h(this,void 0,void 0,(function*(){try{for(const[r,u]of Object.entries(e)){if((null==t?void 0:t.category)&&!r.toLowerCase().startsWith(null==t?void 0:t.category.toLowerCase())||(null===(n=t.exclude)||void 0===n?void 0:n.some((e=>r.startsWith(e)))))continue;f(`Started ${r} category`);const e=null===(s=u.tests)||void 0===s?void 0:s.every((e=>{var t;return null===(t=e.options)||void 0===t?void 0:t.skipReason}));e||(u.beforeStatus=yield A(u.before,null!==(i=t.category)&&void 0!==i?i:""));let g,y=null!==(a=u.tests)&&void 0!==a?a:[];t.stressTest&&(y=y.filter((e=>{var t;return null===(t=e.options)||void 0===t?void 0:t.stressTest})),y=W(y)),(null!==(p=null===(c=t.tags)||void 0===c?void 0:c.length)&&void 0!==p?p:0)>0&&(y=y.filter((e=>{var n,r;return null===(r=null===(n=e.options)||void 0===n?void 0:n.tags)||void 0===r?void 0:r.some((e=>{var n;return(null!==(n=null==t?void 0:t.tags)&&void 0!==n?n:[]).includes(e)}))}))),u.beforeStatus?(g=Array.from(y.map((e=>({date:(new Date).toISOString(),category:r,name:e.name,success:!1,result:"before() failed",ms:0,skipped:!1,logs:"",owner:null==l?void 0:l.packageOwner,package:l.name,widgetsDifference:0,flaking:o.Test.isReproducing})))),g.forEach((e=>h(this,void 0,void 0,(function*(){return U("package",e)}))))):g=yield E(u,t);const b=g.filter((e=>"skipped"!=e.result));e||(u.afterStatus=yield A(u.after,null!==(m=t.category)&&void 0!==m?m:"")),u.afterStatus&&b.push({date:(new Date).toISOString(),category:r,name:"after",success:!1,result:u.afterStatus,ms:0,skipped:!1,logs:"",owner:null==l?void 0:l.packageOwner,package:l.name,widgetsDifference:0,flaking:o.Test.isReproducing}),u.beforeStatus&&b.push({date:(new Date).toISOString(),category:r,name:"before",success:!1,result:u.beforeStatus,ms:0,skipped:!1,logs:"",owner:null==l?void 0:l.packageOwner,package:l.name,widgetsDifference:0,flaking:o.Test.isReproducing}),d.push(...b)}}finally{console.log=f,console.info=g,console.warn=y,console.error=b}if(t.testContext.catchUnhandled&&!o.Test.isInBenchmark){yield j(1e3);const e=yield r.shell.lastError,t={logs:"",date:(new Date).toISOString(),category:"Unhandled exceptions",name:"Exception",result:null!=e?e:"",success:!e,ms:0,skipped:!1,owner:null!=u?u:"",package:l.name,widgetsDifference:0};d.push(Object.assign(Object.assign({},t),{flaking:o.Test.isReproducing&&!e})),t.package=l.name,yield U("package",t)}}))}(w,e);for(let e of d)e.result=e.result.toString().replace(/"/g,"'"),null!=e.logs&&(e.logs=e.logs.toString().replace(/"/g,"'"));return d;function A(e,t){return h(this,void 0,void 0,(function*(){let n;try{void 0!==e&&(yield q((()=>h(this,void 0,void 0,(function*(){yield e()}))),1e5,`before ${t}: timeout error`))}catch(e){n=yield B(e)}return n}))}function E(e,t){var n,s,i,a,c,d,f,g,y,b,w,A,E,T,S,_,P,M;return h(this,void 0,void 0,(function*(){let h=null!==(n=e.tests)&&void 0!==n?n:[];const x=[],N=C();if(e.clear)for(let n=0;n<h.length;n++){h[n].options&&void 0===(null===(s=h[n].options)||void 0===s?void 0:s.benchmark)&&(h[n].options||(h[n].options={}),h[n].options.benchmark=null!==(i=e.benchmarks)&&void 0!==i&&i);let A=h[n];if(t.test&&t.test.toLowerCase()!==A.name.toLowerCase())continue;(null==A?void 0:A.options)&&(A.options.owner=null!==(f=null!==(d=null!==(c=null===(a=h[n].options)||void 0===a?void 0:a.owner)&&void 0!==c?c:null==e?void 0:e.owner)&&void 0!==d?d:u)&&void 0!==f?f:"");let E=yield Y(A,null==t?void 0:t.test,v,o.Test.isInBenchmark?null!==(y=null===(g=h[n].options)||void 0===g?void 0:g.benchmarkTimeout)&&void 0!==y?y:m:null!==(w=null===(b=h[n].options)||void 0===b?void 0:b.timeout)&&void 0!==w?w:p,l.name,t.verbose);E&&x.push(Object.assign(Object.assign({},E),{widgetsDifference:C()-N})),r.shell.closeAll(),o.Balloon.closeAll()}else for(let n=0;n<h.length;n++){let r=h[n];if(t.test&&t.test.toLowerCase()!==r.name.toLowerCase())continue;(null==r?void 0:r.options)&&(r.options.owner=null!==(S=null!==(T=null!==(E=null===(A=h[n].options)||void 0===A?void 0:A.owner)&&void 0!==E?E:null==e?void 0:e.owner)&&void 0!==T?T:u)&&void 0!==S?S:"");let s=yield Y(r,null==t?void 0:t.test,v,o.Test.isInBenchmark?null!==(P=null===(_=h[n].options)||void 0===_?void 0:_.benchmarkTimeout)&&void 0!==P?P:m:null===(M=h[n].options)||void 0===M?void 0:M.timeout,l.name,t.verbose);s&&x.push(Object.assign(Object.assign({},s),{widgetsDifference:C()-N}))}return x}))}function C(){var e;let t=-1;try{t=o.Widget.getAll().length}catch(t){console.warn(null!==(e=t.message)&&void 0!==e?e:t)}return t}}))}function U(e,t){return h(this,void 0,void 0,(function*(){null!=r.shell.reportTest?yield r.shell.reportTest(e,t):yield fetch(`${r.dapi.root}/log/tests/${e}`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify(t)})}))}function B(e){return h(this,void 0,void 0,(function*(){return`${e.toString()}\n${e.stack?yield o.Logger.translateStackTrace(e.stack):""}`}))}function Y(e,t,n,s,i,a){var c,l,u,d,m,g,y,w,v,A,E,C,T,S;return h(this,void 0,void 0,(function*(){let h;n.length=0;const _=null!=t&&e.name.toLowerCase()!==t.toLowerCase();let P=(null===(c=e.options)||void 0===c?void 0:c.skipReason)||_,M=_?"skipped":null===(l=e.options)||void 0===l?void 0:l.skipReason;if(console.log($.name,P),o.Test.isInBenchmark&&!(null===(u=e.options)||void 0===u?void 0:u.benchmark))return void f(`SKIPPED: ${e.category} ${e.name} doesnt available in benchmark mode`);P||f(`Started ${e.category} ${e.name}`);const x=Date.now(),N=new Date(x).toISOString();try{if(P)h={name:e.name,owner:null!==(m=null===(d=e.options)||void 0===d?void 0:d.owner)&&void 0!==m?m:"",category:e.category,logs:"",date:N,success:!0,result:M,ms:0,skipped:!0,package:null!=i?i:"",flaking:o.Test.isReproducing};else{let t=null!=s?s:p;o.Test.isProfiling&&console.profile(`${e.category}: ${e.name}`),h={name:e.name,owner:null!==(y=null===(g=e.options)||void 0===g?void 0:g.owner)&&void 0!==y?y:"",category:e.category,logs:"",date:N,success:!0,result:null!==(w=yield q(e.test,t))&&void 0!==w?w:"OK",ms:0,skipped:!1,package:null!=i?i:"",flaking:o.Test.isReproducing},o.Test.isProfiling&&(console.profileEnd(`${e.category}: ${e.name}`),r.shell.info(`Profiling of ${e.category}: ${e.name} finished \n Please ensure that you have opened DevTools (F12) / Performance panel before test starts.`))}}catch(t){b(t),h={name:e.name,owner:null!==(A=null===(v=e.options)||void 0===v?void 0:v.owner)&&void 0!==A?A:"",category:e.category,logs:"",date:N,success:!1,result:yield B(t),ms:0,skipped:!1,package:null!=i?i:"",flaking:!1}}if((null===(E=e.options)||void 0===E?void 0:E.isAggregated)&&h.result.constructor===o.DataFrame){const e=h.result.col("success");if(e&&(h.success=e.stats.sum===e.length),!a){const e=h.result;e.columns.remove("stack"),e.rows.removeWhere((e=>e.get("success"))),h.result=e}h.result=h.result.toCsv()}if(h.logs=n.join("\n"),h.ms=Date.now()-x,P||f(`Finished ${e.category} ${e.name} for ${h.ms} ms`),h.category=e.category,h.name=e.name,h.owner=null!==(T=null===(C=e.options)||void 0===C?void 0:C.owner)&&void 0!==T?T:"",!_){let t={success:h.success,result:h.result,ms:h.ms,date:h.date,skipped:h.skipped,category:e.category,name:e.name,logs:h.logs,owner:h.owner,flaking:o.Test.isReproducing&&h.success,package:h.package};if(h.result.constructor==Object){const e=Object.keys(h.result).reduce(((e,t)=>Object.assign(Object.assign({},e),{["result."+t]:h.result[t]})),{});t=Object.assign(Object.assign({},t),e)}t.result instanceof o.DataFrame&&(t.result=JSON.stringify(null===(S=t.result)||void 0===S?void 0:S.toJson())||""),yield U("package",t)}return h}))}function W(e){const t=e.slice();return t.sort((()=>Math.random()-.5)),t}function j(e){return h(this,void 0,void 0,(function*(){yield new Promise((t=>setTimeout(t,e)))}))}function K(e,t="Timeout exceeded",n=500,r=50){return h(this,void 0,void 0,(function*(){return new Promise(((o,s)=>{setTimeout((()=>{clearInterval(i),s(new Error(t))}),n);const i=setInterval((()=>{e()&&(clearInterval(i),o(null))}),r)}))}))}function q(e,t,n="EXECUTION TIMEOUT"){return h(this,void 0,void 0,(function*(){let r=null;const o=new Promise(((e,o)=>{r=setTimeout((()=>{o(n)}),t)}));try{return yield Promise.race([e(),o])}finally{r&&clearTimeout(r)}}))}const z=o.DataFrame.fromColumns([o.Column.fromStrings("col",["val1","val2","val3"])]);function Z(e,t,n){var o;return h(this,void 0,void 0,(function*(){const s=null!==(o=null==n?void 0:n.packageName)&&void 0!==o?o:"";(null==n?void 0:n.detectSemanticTypes)&&(yield r.data.detectSemanticTypes(t));const i=r.shell.addTableView(t);try{yield a(i,e,s,r.events.onViewerAdded),(null==n?void 0:n.awaitViewer)&&(yield a(i,e,s,r.events.onViewerAdded,void 0,n.awaitViewer)),(null==n?void 0:n.readOnly)||(yield a(i,e,s,r.events.onViewerAdded,c),(null==n?void 0:n.awaitViewer)&&(yield a(i,e,s,r.events.onViewerAdded,c,n.awaitViewer)));let t=null;t=yield a(i,e,s,r.events.onViewerAdded,u),(null==n?void 0:n.awaitViewer)&&(t=yield a(i,e,s,r.events.onViewerAdded,u,n.awaitViewer)),yield a(i,e,s,r.events.onViewLayoutApplied,d,void 0,null==t?void 0:t.layout,{savedProps:null==t?void 0:t.savedProps}),(null==n?void 0:n.awaitViewer)&&(yield a(i,e,s,r.events.onViewLayoutApplied,d,n.awaitViewer,null==t?void 0:t.layout,{savedProps:null==t?void 0:t.savedProps})),!1!==(null==n?void 0:n.arbitraryDfTest)&&(i.dataFrame=z,yield j(50),yield a(i,e,s,r.events.onViewerAdded),(null==n?void 0:n.awaitViewer)&&(yield a(i,e,s,r.events.onViewerAdded,void 0,n.awaitViewer))),yield a(i,e,s,r.events.onViewerAdded,l),(null==n?void 0:n.awaitViewer)&&(yield a(i,e,s,r.events.onViewerAdded,l,n.awaitViewer))}finally{}}))}},3527:(e,t,n)=>{"use strict";n.d(t,{Mi:()=>r});class r extends Float32Array{}},3629:(e,t,n)=>{"use strict";n.d(t,{KE:()=>a,dC:()=>s,vA:()=>o,wQ:()=>i});var r=n(3527);function o(e=!1,t="Assertion error."){if(!e)throw new Error(t)}function s(e,t,n=1){const s=e.length;o(s==t.length,"Vector lengths do not match.");const i=new r.Mi(s);for(let r=0;r<e.length;++r)i[r]=e[r]+n*t[r];return i}function i(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n]*e[n];return Math.sqrt(t)}function a(e,t){if(e.length!=t.length)throw new Error("The dimensionality of the vectors must match");let n=0;for(let r=0;r<e.length;r++)n+=e[r]*t[r];return n}},1913:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(3282),o=n(9029),s=n(1520),i=n(2586),a=n(8708),c=n(2023),l="errorMessage",u=new r.Name("emUsed"),d={required:"missingProperty",dependencies:"property",dependentRequired:"property"},h=/\$\{[^}]+\}/,p=/\$\{([^}]+)\}/g,m=/^""\s*\+\s*|\s*\+\s*""$/g;const f=(e,t={})=>{if(!e.opts.allErrors)throw new Error("ajv-errors: Ajv option allErrors must be true");if(e.opts.jsPropertySyntax)throw new Error("ajv-errors: ajv option jsPropertySyntax is not supported");return e.addKeyword(function(e){return{keyword:l,schemaType:["string","object"],post:!0,code(t){const{gen:n,data:f,schema:g,schemaValue:y,it:b}=t;if(!1===b.createErrors)return;const w=g,v=o.strConcat(c.default.instancePath,b.errorPath);function A(e,t){return o.and(r._`${e}.keyword !== ${l}`,r._`!${e}.${u}`,r._`${e}.instancePath === ${v}`,r._`${e}.keyword in ${t}`,r._`${e}.schemaPath.indexOf(${b.errSchemaPath}) === 0`,r._`/^\\/[^\\/]*$/.test(${e}.schemaPath.slice(${b.errSchemaPath.length}))`)}function E(e,t){const r=[];for(const n in e){const e=t[n];h.test(e)&&r.push([n,T(e)])}return n.object(...r)}function C(e){return h.test(e)?new s._Code(s.safeStringify(e).replace(p,((e,t)=>`" + JSON.stringify(${i.getData(t,b)}) + "`)).replace(m,"")):r.stringify(e)}function T(e){return r._`function(){return ${C(e)}}`}n.if(r._`${c.default.errors} > 0`,(()=>{if("object"==typeof w){const[s,i]=function(e){let t,n;for(const r in e){if("properties"===r||"items"===r)continue;const o=e[r];if("object"==typeof o){t||(t={});const e=t[r]={};for(const t in o)e[t]=[]}else n||(n={}),n[r]=[]}return[t,n]}(w);i&&function(o){const s=n.const("emErrors",r.stringify(o)),i=n.const("templates",E(o,g));n.forOf("err",c.default.vErrors,(e=>n.if(A(e,s),(()=>n.code(r._`${s}[${e}.keyword].push(${e})`).assign(r._`${e}.${u}`,!0)))));const{singleError:l}=e;if(l){const e=n.let("message",r._`""`),o=n.let("paramsErrors",r._`[]`);d((t=>{n.if(e,(()=>n.code(r._`${e} += ${"string"==typeof l?l:";"}`))),n.code(r._`${e} += ${h(t)}`),n.assign(o,r._`${o}.concat(${s}[${t}])`)})),a.reportError(t,{message:e,params:r._`{errors: ${o}}`})}else d((e=>a.reportError(t,{message:h(e),params:r._`{errors: ${s}[${e}]}`})));function d(e){n.forIn("key",s,(t=>n.if(r._`${s}[${t}].length`,(()=>e(t)))))}function h(e){return r._`${e} in ${i} ? ${i}[${e}]() : ${y}[${e}]`}}(i),s&&function(e){const o=n.const("emErrors",r.stringify(e)),s=[];for(const t in e)s.push([t,E(e[t],g[t])]);const i=n.const("templates",n.object(...s)),l=n.scopeValue("obj",{ref:d,code:r.stringify(d)}),h=n.let("emPropParams"),p=n.let("emParamsErrors");n.forOf("err",c.default.vErrors,(e=>n.if(A(e,o),(()=>{n.assign(h,r._`${l}[${e}.keyword]`),n.assign(p,r._`${o}[${e}.keyword][${e}.params[${h}]]`),n.if(p,(()=>n.code(r._`${p}.push(${e})`).assign(r._`${e}.${u}`,!0)))})))),n.forIn("key",o,(e=>n.forIn("keyProp",r._`${o}[${e}]`,(s=>{n.assign(p,r._`${o}[${e}][${s}]`),n.if(r._`${p}.length`,(()=>{const o=n.const("tmpl",r._`${i}[${e}] && ${i}[${e}][${s}]`);a.reportError(t,{message:r._`${o} ? ${o}() : ${y}[${e}][${s}]`,params:r._`{errors: ${p}}`})}))}))))}(s),function(e){const{props:s,items:i}=e;if(!s&&!i)return;const d=r._`typeof ${f} == "object"`,h=r._`Array.isArray(${f})`,p=n.let("emErrors");let m,b;const w=n.let("templates");function A(e,t){n.assign(p,r.stringify(e)),n.assign(w,E(e,t))}s&&i?(m=n.let("emChildKwd"),n.if(d),n.if(h,(()=>{A(i,g.items),n.assign(m,r.str`items`)}),(()=>{A(s,g.properties),n.assign(m,r.str`properties`)})),b=r._`[${m}]`):i?(n.if(h),A(i,g.items),b=r._`.items`):s&&(n.if(o.and(d,o.not(h))),A(s,g.properties),b=r._`.properties`),n.forOf("err",c.default.vErrors,(e=>function(e,t,s){n.if(o.and(r._`${e}.keyword !== ${l}`,r._`!${e}.${u}`,r._`${e}.instancePath.indexOf(${v}) === 0`),(()=>{const o=n.scopeValue("pattern",{ref:/^\/([^/]*)(?:\/|$)/,code:r._`new RegExp("^\\\/([^/]*)(?:\\\/|$)")`}),i=n.const("emMatches",r._`${o}.exec(${e}.instancePath.slice(${v}.length))`),a=n.const("emChild",r._`${i} && ${i}[1].replace(/~1/g, "/").replace(/~0/g, "~")`);n.if(r._`${a} !== undefined && ${a} in ${t}`,(()=>s(a)))}))}(e,p,(t=>n.code(r._`${p}[${t}].push(${e})`).assign(r._`${e}.${u}`,!0))))),n.forIn("key",p,(e=>n.if(r._`${p}[${e}].length`,(()=>{a.reportError(t,{message:r._`${e} in ${w} ? ${w}[${e}]() : ${y}${b}[${e}]`,params:r._`{errors: ${p}[${e}]}`}),n.assign(r._`${c.default.vErrors}[${c.default.errors}-1].instancePath`,r._`${v} + "/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`)})))),n.endIf()}(function({properties:e,items:t}){const n={};if(e){n.props={};for(const t in e)n.props[t]=[]}if(t){n.items={};for(let e=0;e<t.length;e++)n.items[e]=[]}return n}(w))}const s="string"==typeof w?w:w._;s&&function(e){const s=n.const("emErrs",r._`[]`);n.forOf("err",c.default.vErrors,(e=>n.if(function(e){return o.and(r._`${e}.keyword !== ${l}`,r._`!${e}.${u}`,o.or(r._`${e}.instancePath === ${v}`,o.and(r._`${e}.instancePath.indexOf(${v}) === 0`,r._`${e}.instancePath[${v}.length] === "/"`)),r._`${e}.schemaPath.indexOf(${b.errSchemaPath}) === 0`,r._`${e}.schemaPath[${b.errSchemaPath}.length] === "/"`)}(e),(()=>n.code(r._`${s}.push(${e})`).assign(r._`${e}.${u}`,!0))))),n.if(r._`${s}.length`,(()=>a.reportError(t,{message:C(e),params:r._`{errors: ${s}}`})))}(s),e.keepErrors||function(){const e=n.const("emErrs",r._`[]`);n.forOf("err",c.default.vErrors,(t=>n.if(r._`!${t}.${u}`,(()=>n.code(r._`${e}.push(${t})`))))),n.assign(c.default.vErrors,e).assign(c.default.errors,r._`${e}.length`)}()}))},metaSchema:{anyOf:[{type:"string"},{type:"object",properties:{properties:{$ref:"#/$defs/stringMap"},items:{$ref:"#/$defs/stringList"},required:{$ref:"#/$defs/stringOrMap"},dependencies:{$ref:"#/$defs/stringOrMap"}},additionalProperties:{type:"string"}}],$defs:{stringMap:{type:"object",additionalProperties:{type:"string"}},stringOrMap:{anyOf:[{type:"string"},{$ref:"#/$defs/stringMap"}]},stringList:{type:"array",items:{type:"string"}}}}}}(t))};t.default=f,e.exports=f,e.exports.default=f},7433:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MissingRefError=t.ValidationError=t.CodeGen=t.Name=t.nil=t.stringify=t.str=t._=t.KeywordCxt=t.Ajv2020=void 0;const r=n(4042),o=n(6105),s=n(6653),i=n(9572),a="https://json-schema.org/draft/2020-12/schema";class c extends r.default{constructor(e={}){super({...e,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){super._addVocabularies(),o.default.forEach((e=>this.addVocabulary(e))),this.opts.discriminator&&this.addKeyword(s.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();const{$data:e,meta:t}=this.opts;t&&(i.default.call(this,e),this.refs["http://json-schema.org/schema"]=a)}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(a)?a:void 0)}}t.Ajv2020=c,e.exports=t=c,e.exports.Ajv2020=c,Object.defineProperty(t,"__esModule",{value:!0}),t.default=c;var l=n(2586);Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return l.KeywordCxt}});var u=n(9029);Object.defineProperty(t,"_",{enumerable:!0,get:function(){return u._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return u.str}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return u.stringify}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return u.nil}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return u.Name}}),Object.defineProperty(t,"CodeGen",{enumerable:!0,get:function(){return u.CodeGen}});var d=n(3558);Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return d.default}});var h=n(4551);Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return h.default}})},3282:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MissingRefError=t.ValidationError=t.CodeGen=t.Name=t.nil=t.stringify=t.str=t._=t.KeywordCxt=t.Ajv=void 0;const r=n(4042),o=n(6144),s=n(6653),i=n(2079),a=["/properties"],c="http://json-schema.org/draft-07/schema";class l extends r.default{_addVocabularies(){super._addVocabularies(),o.default.forEach((e=>this.addVocabulary(e))),this.opts.discriminator&&this.addKeyword(s.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const e=this.opts.$data?this.$dataMetaSchema(i,a):i;this.addMetaSchema(e,c,!1),this.refs["http://json-schema.org/schema"]=c}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(c)?c:void 0)}}t.Ajv=l,e.exports=t=l,e.exports.Ajv=l,Object.defineProperty(t,"__esModule",{value:!0}),t.default=l;var u=n(2586);Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return u.KeywordCxt}});var d=n(9029);Object.defineProperty(t,"_",{enumerable:!0,get:function(){return d._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return d.str}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return d.stringify}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return d.nil}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return d.Name}}),Object.defineProperty(t,"CodeGen",{enumerable:!0,get:function(){return d.CodeGen}});var h=n(3558);Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return h.default}});var p=n(4551);Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return p.default}})},1520:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.regexpCode=t.getEsmExportName=t.getProperty=t.safeStringify=t.stringify=t.strConcat=t.addCodeArg=t.str=t._=t.nil=t._Code=t.Name=t.IDENTIFIER=t._CodeOrName=void 0;class n{}t._CodeOrName=n,t.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class r extends n{constructor(e){if(super(),!t.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}t.Name=r;class o extends n{constructor(e){super(),this._items="string"==typeof e?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const e=this._items[0];return""===e||'""'===e}get str(){var e;return null!==(e=this._str)&&void 0!==e?e:this._str=this._items.reduce(((e,t)=>`${e}${t}`),"")}get names(){var e;return null!==(e=this._names)&&void 0!==e?e:this._names=this._items.reduce(((e,t)=>(t instanceof r&&(e[t.str]=(e[t.str]||0)+1),e)),{})}}function s(e,...t){const n=[e[0]];let r=0;for(;r<t.length;)c(n,t[r]),n.push(e[++r]);return new o(n)}t._Code=o,t.nil=new o(""),t._=s;const i=new o("+");function a(e,...t){const n=[u(e[0])];let r=0;for(;r<t.length;)n.push(i),c(n,t[r]),n.push(i,u(e[++r]));return function(e){let t=1;for(;t<e.length-1;){if(e[t]===i){const n=l(e[t-1],e[t+1]);if(void 0!==n){e.splice(t-1,3,n);continue}e[t++]="+"}t++}}(n),new o(n)}function c(e,t){var n;t instanceof o?e.push(...t._items):t instanceof r?e.push(t):e.push("number"==typeof(n=t)||"boolean"==typeof n||null===n?n:u(Array.isArray(n)?n.join(","):n))}function l(e,t){if('""'===t)return e;if('""'===e)return t;if("string"==typeof e){if(t instanceof r||'"'!==e[e.length-1])return;return"string"!=typeof t?`${e.slice(0,-1)}${t}"`:'"'===t[0]?e.slice(0,-1)+t.slice(1):void 0}return"string"!=typeof t||'"'!==t[0]||e instanceof r?void 0:`"${e}${t.slice(1)}`}function u(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}t.str=a,t.addCodeArg=c,t.strConcat=function(e,t){return t.emptyStr()?e:e.emptyStr()?t:a`${e}${t}`},t.stringify=function(e){return new o(u(e))},t.safeStringify=u,t.getProperty=function(e){return"string"==typeof e&&t.IDENTIFIER.test(e)?new o(`.${e}`):s`[${e}]`},t.getEsmExportName=function(e){if("string"==typeof e&&t.IDENTIFIER.test(e))return new o(`${e}`);throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)},t.regexpCode=function(e){return new o(e.toString())}},9029:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.or=t.and=t.not=t.CodeGen=t.operators=t.varKinds=t.ValueScopeName=t.ValueScope=t.Scope=t.Name=t.regexpCode=t.stringify=t.getProperty=t.nil=t.strConcat=t.str=t._=void 0;const r=n(1520),o=n(7845);var s=n(1520);Object.defineProperty(t,"_",{enumerable:!0,get:function(){return s._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return s.str}}),Object.defineProperty(t,"strConcat",{enumerable:!0,get:function(){return s.strConcat}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return s.nil}}),Object.defineProperty(t,"getProperty",{enumerable:!0,get:function(){return s.getProperty}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return s.stringify}}),Object.defineProperty(t,"regexpCode",{enumerable:!0,get:function(){return s.regexpCode}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return s.Name}});var i=n(7845);Object.defineProperty(t,"Scope",{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(t,"ValueScope",{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(t,"ValueScopeName",{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(t,"varKinds",{enumerable:!0,get:function(){return i.varKinds}}),t.operators={GT:new r._Code(">"),GTE:new r._Code(">="),LT:new r._Code("<"),LTE:new r._Code("<="),EQ:new r._Code("==="),NEQ:new r._Code("!=="),NOT:new r._Code("!"),OR:new r._Code("||"),AND:new r._Code("&&"),ADD:new r._Code("+")};class a{optimizeNodes(){return this}optimizeNames(e,t){return this}}class c extends a{constructor(e,t,n){super(),this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){const n=e?o.varKinds.var:this.varKind,r=void 0===this.rhs?"":` = ${this.rhs}`;return`${n} ${this.name}${r};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&(this.rhs=$(this.rhs,e,t)),this}get names(){return this.rhs instanceof r._CodeOrName?this.rhs.names:{}}}class l extends a{constructor(e,t,n){super(),this.lhs=e,this.rhs=t,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,t){if(!(this.lhs instanceof r.Name)||e[this.lhs.str]||this.sideEffects)return this.rhs=$(this.rhs,e,t),this}get names(){return N(this.lhs instanceof r.Name?{}:{...this.lhs.names},this.rhs)}}class u extends l{constructor(e,t,n,r){super(e,n,r),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}}class d extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}}class h extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}}class p extends a{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}}class m extends a{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=$(this.code,e,t),this}get names(){return this.code instanceof r._CodeOrName?this.code.names:{}}}class f extends a{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce(((t,n)=>t+n.render(e)),"")}optimizeNodes(){const{nodes:e}=this;let t=e.length;for(;t--;){const n=e[t].optimizeNodes();Array.isArray(n)?e.splice(t,1,...n):n?e[t]=n:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){const{nodes:n}=this;let r=n.length;for(;r--;){const o=n[r];o.optimizeNames(e,t)||(L(e,o.names),n.splice(r,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce(((e,t)=>x(e,t.names)),{})}}class g extends f{render(e){return"{"+e._n+super.render(e)+"}"+e._n}}class y extends f{}class b extends g{}b.kind="else";class w extends g{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+="else "+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();const e=this.condition;if(!0===e)return this.nodes;let t=this.else;if(t){const e=t.optimizeNodes();t=this.else=Array.isArray(e)?new b(e):e}return t?!1===e?t instanceof w?t:t.nodes:this.nodes.length?this:new w(I(e),t instanceof w?[t]:t.nodes):!1!==e&&this.nodes.length?this:void 0}optimizeNames(e,t){var n;if(this.else=null===(n=this.else)||void 0===n?void 0:n.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=$(this.condition,e,t),this}get names(){const e=super.names;return N(e,this.condition),this.else&&x(e,this.else.names),e}}w.kind="if";class v extends g{}v.kind="for";class A extends v{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=$(this.iteration,e,t),this}get names(){return x(super.names,this.iteration.names)}}class E extends v{constructor(e,t,n,r){super(),this.varKind=e,this.name=t,this.from=n,this.to=r}render(e){const t=e.es5?o.varKinds.var:this.varKind,{name:n,from:r,to:s}=this;return`for(${t} ${n}=${r}; ${n}<${s}; ${n}++)`+super.render(e)}get names(){const e=N(super.names,this.from);return N(e,this.to)}}class C extends v{constructor(e,t,n,r){super(),this.loop=e,this.varKind=t,this.name=n,this.iterable=r}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=$(this.iterable,e,t),this}get names(){return x(super.names,this.iterable.names)}}class T extends g{constructor(e,t,n){super(),this.name=e,this.args=t,this.async=n}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}}T.kind="func";class S extends f{render(e){return"return "+super.render(e)}}S.kind="return";class _ extends g{render(e){let t="try"+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),null===(e=this.catch)||void 0===e||e.optimizeNodes(),null===(t=this.finally)||void 0===t||t.optimizeNodes(),this}optimizeNames(e,t){var n,r;return super.optimizeNames(e,t),null===(n=this.catch)||void 0===n||n.optimizeNames(e,t),null===(r=this.finally)||void 0===r||r.optimizeNames(e,t),this}get names(){const e=super.names;return this.catch&&x(e,this.catch.names),this.finally&&x(e,this.finally.names),e}}class P extends g{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}}P.kind="catch";class M extends g{render(e){return"finally"+super.render(e)}}function x(e,t){for(const n in t)e[n]=(e[n]||0)+(t[n]||0);return e}function N(e,t){return t instanceof r._CodeOrName?x(e,t.names):e}function $(e,t,n){return e instanceof r.Name?s(e):(o=e)instanceof r._Code&&o._items.some((e=>e instanceof r.Name&&1===t[e.str]&&void 0!==n[e.str]))?new r._Code(e._items.reduce(((e,t)=>(t instanceof r.Name&&(t=s(t)),t instanceof r._Code?e.push(...t._items):e.push(t),e)),[])):e;var o;function s(e){const r=n[e.str];return void 0===r||1!==t[e.str]?e:(delete t[e.str],r)}}function L(e,t){for(const n in t)e[n]=(e[n]||0)-(t[n]||0)}function I(e){return"boolean"==typeof e||"number"==typeof e||null===e?!e:r._`!${G(e)}`}M.kind="finally",t.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?"\n":""},this._extScope=e,this._scope=new o.Scope({parent:e}),this._nodes=[new y]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){const n=this._extScope.value(e,t);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,n,r){const o=this._scope.toName(t);return void 0!==n&&r&&(this._constants[o.str]=n),this._leafNode(new c(e,o,n)),o}const(e,t,n){return this._def(o.varKinds.const,e,t,n)}let(e,t,n){return this._def(o.varKinds.let,e,t,n)}var(e,t,n){return this._def(o.varKinds.var,e,t,n)}assign(e,t,n){return this._leafNode(new l(e,t,n))}add(e,n){return this._leafNode(new u(e,t.operators.ADD,n))}code(e){return"function"==typeof e?e():e!==r.nil&&this._leafNode(new m(e)),this}object(...e){const t=["{"];for(const[n,o]of e)t.length>1&&t.push(","),t.push(n),(n!==o||this.opts.es5)&&(t.push(":"),(0,r.addCodeArg)(t,o));return t.push("}"),new r._Code(t)}if(e,t,n){if(this._blockNode(new w(e)),t&&n)this.code(t).else().code(n).endIf();else if(t)this.code(t).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new w(e))}else(){return this._elseNode(new b)}endIf(){return this._endBlockNode(w,b)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new A(e),t)}forRange(e,t,n,r,s=(this.opts.es5?o.varKinds.var:o.varKinds.let)){const i=this._scope.toName(e);return this._for(new E(s,i,t,n),(()=>r(i)))}forOf(e,t,n,s=o.varKinds.const){const i=this._scope.toName(e);if(this.opts.es5){const e=t instanceof r.Name?t:this.var("_arr",t);return this.forRange("_i",0,r._`${e}.length`,(t=>{this.var(i,r._`${e}[${t}]`),n(i)}))}return this._for(new C("of",s,i,t),(()=>n(i)))}forIn(e,t,n,s=(this.opts.es5?o.varKinds.var:o.varKinds.const)){if(this.opts.ownProperties)return this.forOf(e,r._`Object.keys(${t})`,n);const i=this._scope.toName(e);return this._for(new C("in",s,i,t),(()=>n(i)))}endFor(){return this._endBlockNode(v)}label(e){return this._leafNode(new d(e))}break(e){return this._leafNode(new h(e))}return(e){const t=new S;if(this._blockNode(t),this.code(e),1!==t.nodes.length)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(S)}try(e,t,n){if(!t&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');const r=new _;if(this._blockNode(r),this.code(e),t){const e=this.name("e");this._currNode=r.catch=new P(e),t(e)}return n&&(this._currNode=r.finally=new M,this.code(n)),this._endBlockNode(P,M)}throw(e){return this._leafNode(new p(e))}block(e,t){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(t),this}endBlock(e){const t=this._blockStarts.pop();if(void 0===t)throw new Error("CodeGen: not in self-balancing block");const n=this._nodes.length-t;if(n<0||void 0!==e&&n!==e)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=t,this}func(e,t=r.nil,n,o){return this._blockNode(new T(e,t,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(T)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,t){const n=this._currNode;if(n instanceof e||t&&n instanceof t)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){const t=this._currNode;if(!(t instanceof w))throw new Error('CodeGen: "else" without "if"');return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){const e=this._nodes;return e[e.length-1]}set _currNode(e){const t=this._nodes;t[t.length-1]=e}},t.not=I;const R=k(t.operators.AND);t.and=function(...e){return e.reduce(R)};const O=k(t.operators.OR);function k(e){return(t,n)=>t===r.nil?n:n===r.nil?t:r._`${G(t)} ${e} ${G(n)}`}function G(e){return e instanceof r.Name?e:r._`(${e})`}t.or=function(...e){return e.reduce(O)}},7845:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ValueScope=t.ValueScopeName=t.Scope=t.varKinds=t.UsedValueState=void 0;const r=n(1520);class o extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}}var s;!function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"}(s||(t.UsedValueState=s={})),t.varKinds={const:new r.Name("const"),let:new r.Name("let"),var:new r.Name("var")};class i{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof r.Name?e:this.name(e)}name(e){return new r.Name(this._newName(e))}_newName(e){return`${e}${(this._names[e]||this._nameGroup(e)).index++}`}_nameGroup(e){var t,n;if((null===(n=null===(t=this._parent)||void 0===t?void 0:t._prefixes)||void 0===n?void 0:n.has(e))||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}}t.Scope=i;class a extends r.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:t,itemIndex:n}){this.value=e,this.scopePath=r._`.${new r.Name(t)}[${n}]`}}t.ValueScopeName=a;const c=r._`\n`;t.ValueScope=class extends i{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?c:r.nil}}get(){return this._scope}name(e){return new a(e,this._newName(e))}value(e,t){var n;if(void 0===t.ref)throw new Error("CodeGen: ref must be passed in value");const r=this.toName(e),{prefix:o}=r,s=null!==(n=t.key)&&void 0!==n?n:t.ref;let i=this._values[o];if(i){const e=i.get(s);if(e)return e}else i=this._values[o]=new Map;i.set(s,r);const a=this._scope[o]||(this._scope[o]=[]),c=a.length;return a[c]=t.ref,r.setValue(t,{property:o,itemIndex:c}),r}getValue(e,t){const n=this._values[e];if(n)return n.get(t)}scopeRefs(e,t=this._values){return this._reduceValues(t,(t=>{if(void 0===t.scopePath)throw new Error(`CodeGen: name "${t}" has no value`);return r._`${e}${t.scopePath}`}))}scopeCode(e=this._values,t,n){return this._reduceValues(e,(e=>{if(void 0===e.value)throw new Error(`CodeGen: name "${e}" has no value`);return e.value.code}),t,n)}_reduceValues(e,n,i={},a){let c=r.nil;for(const l in e){const u=e[l];if(!u)continue;const d=i[l]=i[l]||new Map;u.forEach((e=>{if(d.has(e))return;d.set(e,s.Started);let i=n(e);if(i){const n=this.opts.es5?t.varKinds.var:t.varKinds.const;c=r._`${c}${n} ${e} = ${i};${this.opts._n}`}else{if(!(i=null==a?void 0:a(e)))throw new o(e);c=r._`${c}${i}${this.opts._n}`}d.set(e,s.Completed)}))}return c}}},8708:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extendErrors=t.resetErrorsCount=t.reportExtraError=t.reportError=t.keyword$DataError=t.keywordError=void 0;const r=n(9029),o=n(4227),s=n(2023);function i(e,t){const n=e.const("err",t);e.if(r._`${s.default.vErrors} === null`,(()=>e.assign(s.default.vErrors,r._`[${n}]`)),r._`${s.default.vErrors}.push(${n})`),e.code(r._`${s.default.errors}++`)}function a(e,t){const{gen:n,validateName:o,schemaEnv:s}=e;s.$async?n.throw(r._`new ${e.ValidationError}(${t})`):(n.assign(r._`${o}.errors`,t),n.return(!1))}t.keywordError={message:({keyword:e})=>r.str`must pass "${e}" keyword validation`},t.keyword$DataError={message:({keyword:e,schemaType:t})=>t?r.str`"${e}" keyword must be ${t} ($data)`:r.str`"${e}" keyword is invalid ($data)`},t.reportError=function(e,n=t.keywordError,o,s){const{it:c}=e,{gen:u,compositeRule:d,allErrors:h}=c,p=l(e,n,o);(null!=s?s:d||h)?i(u,p):a(c,r._`[${p}]`)},t.reportExtraError=function(e,n=t.keywordError,r){const{it:o}=e,{gen:c,compositeRule:u,allErrors:d}=o;i(c,l(e,n,r)),u||d||a(o,s.default.vErrors)},t.resetErrorsCount=function(e,t){e.assign(s.default.errors,t),e.if(r._`${s.default.vErrors} !== null`,(()=>e.if(t,(()=>e.assign(r._`${s.default.vErrors}.length`,t)),(()=>e.assign(s.default.vErrors,null)))))},t.extendErrors=function({gen:e,keyword:t,schemaValue:n,data:o,errsCount:i,it:a}){if(void 0===i)throw new Error("ajv implementation error");const c=e.name("err");e.forRange("i",i,s.default.errors,(i=>{e.const(c,r._`${s.default.vErrors}[${i}]`),e.if(r._`${c}.instancePath === undefined`,(()=>e.assign(r._`${c}.instancePath`,(0,r.strConcat)(s.default.instancePath,a.errorPath)))),e.assign(r._`${c}.schemaPath`,r.str`${a.errSchemaPath}/${t}`),a.opts.verbose&&(e.assign(r._`${c}.schema`,n),e.assign(r._`${c}.data`,o))}))};const c={keyword:new r.Name("keyword"),schemaPath:new r.Name("schemaPath"),params:new r.Name("params"),propertyName:new r.Name("propertyName"),message:new r.Name("message"),schema:new r.Name("schema"),parentSchema:new r.Name("parentSchema")};function l(e,t,n){const{createErrors:o}=e.it;return!1===o?r._`{}`:function(e,t,n={}){const{gen:o,it:i}=e,a=[u(i,n),d(e,n)];return function(e,{params:t,message:n},o){const{keyword:i,data:a,schemaValue:l,it:u}=e,{opts:d,propertyName:h,topSchemaRef:p,schemaPath:m}=u;o.push([c.keyword,i],[c.params,"function"==typeof t?t(e):t||r._`{}`]),d.messages&&o.push([c.message,"function"==typeof n?n(e):n]),d.verbose&&o.push([c.schema,l],[c.parentSchema,r._`${p}${m}`],[s.default.data,a]),h&&o.push([c.propertyName,h])}(e,t,a),o.object(...a)}(e,t,n)}function u({errorPath:e},{instancePath:t}){const n=t?r.str`${e}${(0,o.getErrorPath)(t,o.Type.Str)}`:e;return[s.default.instancePath,(0,r.strConcat)(s.default.instancePath,n)]}function d({keyword:e,it:{errSchemaPath:t}},{schemaPath:n,parentSchema:s}){let i=s?t:r.str`${t}/${e}`;return n&&(i=r.str`${i}${(0,o.getErrorPath)(n,o.Type.Str)}`),[c.schemaPath,i]}},3835:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.resolveSchema=t.getCompilingSchema=t.resolveRef=t.compileSchema=t.SchemaEnv=void 0;const r=n(9029),o=n(3558),s=n(2023),i=n(6939),a=n(4227),c=n(2586);class l{constructor(e){var t;let n;this.refs={},this.dynamicAnchors={},"object"==typeof e.schema&&(n=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=null!==(t=e.baseId)&&void 0!==t?t:(0,i.normalizeId)(null==n?void 0:n[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=null==n?void 0:n.$async,this.refs={}}}function u(e){const t=h.call(this,e);if(t)return t;const n=(0,i.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:a,lines:l}=this.opts.code,{ownProperties:u}=this.opts,d=new r.CodeGen(this.scope,{es5:a,lines:l,ownProperties:u});let p;e.$async&&(p=d.scopeValue("Error",{ref:o.default,code:r._`require("ajv/dist/runtime/validation_error").default`}));const m=d.scopeName("validate");e.validateName=m;const f={gen:d,allErrors:this.opts.allErrors,data:s.default.data,parentData:s.default.parentData,parentDataProperty:s.default.parentDataProperty,dataNames:[s.default.data],dataPathArr:[r.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:d.scopeValue("schema",!0===this.opts.code.source?{ref:e.schema,code:(0,r.stringify)(e.schema)}:{ref:e.schema}),validateName:m,ValidationError:p,schema:e.schema,schemaEnv:e,rootId:n,baseId:e.baseId||n,schemaPath:r.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:r._`""`,opts:this.opts,self:this};let g;try{this._compilations.add(e),(0,c.validateFunctionCode)(f),d.optimize(this.opts.code.optimize);const t=d.toString();g=`${d.scopeRefs(s.default.scope)}return ${t}`,this.opts.code.process&&(g=this.opts.code.process(g,e));const n=new Function(`${s.default.self}`,`${s.default.scope}`,g)(this,this.scope.get());if(this.scope.value(m,{ref:n}),n.errors=null,n.schema=e.schema,n.schemaEnv=e,e.$async&&(n.$async=!0),!0===this.opts.code.source&&(n.source={validateName:m,validateCode:t,scopeValues:d._values}),this.opts.unevaluated){const{props:e,items:t}=f;n.evaluated={props:e instanceof r.Name?void 0:e,items:t instanceof r.Name?void 0:t,dynamicProps:e instanceof r.Name,dynamicItems:t instanceof r.Name},n.source&&(n.source.evaluated=(0,r.stringify)(n.evaluated))}return e.validate=n,e}catch(t){throw delete e.validate,delete e.validateName,g&&this.logger.error("Error compiling schema, function code:",g),t}finally{this._compilations.delete(e)}}function d(e){return(0,i.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:u.call(this,e)}function h(e){for(const r of this._compilations)if(n=e,(t=r).schema===n.schema&&t.root===n.root&&t.baseId===n.baseId)return r;var t,n}function p(e,t){let n;for(;"string"==typeof(n=this.refs[t]);)t=n;return n||this.schemas[t]||m.call(this,e,t)}function m(e,t){const n=this.opts.uriResolver.parse(t),r=(0,i._getFullPath)(this.opts.uriResolver,n);let o=(0,i.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&r===o)return g.call(this,n,e);const s=(0,i.normalizeId)(r),a=this.refs[s]||this.schemas[s];if("string"==typeof a){const t=m.call(this,e,a);if("object"!=typeof(null==t?void 0:t.schema))return;return g.call(this,n,t)}if("object"==typeof(null==a?void 0:a.schema)){if(a.validate||u.call(this,a),s===(0,i.normalizeId)(t)){const{schema:t}=a,{schemaId:n}=this.opts,r=t[n];return r&&(o=(0,i.resolveUrl)(this.opts.uriResolver,o,r)),new l({schema:t,schemaId:n,root:e,baseId:o})}return g.call(this,n,a)}}t.SchemaEnv=l,t.compileSchema=u,t.resolveRef=function(e,t,n){var r;n=(0,i.resolveUrl)(this.opts.uriResolver,t,n);const o=e.refs[n];if(o)return o;let s=p.call(this,e,n);if(void 0===s){const o=null===(r=e.localRefs)||void 0===r?void 0:r[n],{schemaId:i}=this.opts;o&&(s=new l({schema:o,schemaId:i,root:e,baseId:t}))}return void 0!==s?e.refs[n]=d.call(this,s):void 0},t.getCompilingSchema=h,t.resolveSchema=m;const f=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function g(e,{baseId:t,schema:n,root:r}){var o;if("/"!==(null===(o=e.fragment)||void 0===o?void 0:o[0]))return;for(const r of e.fragment.slice(1).split("/")){if("boolean"==typeof n)return;const e=n[(0,a.unescapeFragment)(r)];if(void 0===e)return;const o="object"==typeof(n=e)&&n[this.opts.schemaId];!f.has(r)&&o&&(t=(0,i.resolveUrl)(this.opts.uriResolver,t,o))}let s;if("boolean"!=typeof n&&n.$ref&&!(0,a.schemaHasRulesButRef)(n,this.RULES)){const e=(0,i.resolveUrl)(this.opts.uriResolver,t,n.$ref);s=m.call(this,r,e)}const{schemaId:c}=this.opts;return s=s||new l({schema:n,schemaId:c,root:r,baseId:t}),s.schema!==s.root.schema?s:void 0}},2023:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(9029),o={data:new r.Name("data"),valCxt:new r.Name("valCxt"),instancePath:new r.Name("instancePath"),parentData:new r.Name("parentData"),parentDataProperty:new r.Name("parentDataProperty"),rootData:new r.Name("rootData"),dynamicAnchors:new r.Name("dynamicAnchors"),vErrors:new r.Name("vErrors"),errors:new r.Name("errors"),this:new r.Name("this"),self:new r.Name("self"),scope:new r.Name("scope"),json:new r.Name("json"),jsonPos:new r.Name("jsonPos"),jsonLen:new r.Name("jsonLen"),jsonPart:new r.Name("jsonPart")};t.default=o},4551:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(6939);class o extends Error{constructor(e,t,n,o){super(o||`can't resolve reference ${n} from id ${t}`),this.missingRef=(0,r.resolveUrl)(e,t,n),this.missingSchema=(0,r.normalizeId)((0,r.getFullPath)(e,this.missingRef))}}t.default=o},6939:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getSchemaRefs=t.resolveUrl=t.normalizeId=t._getFullPath=t.getFullPath=t.inlineRef=void 0;const r=n(4227),o=n(2017),s=n(7106),i=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);t.inlineRef=function(e,t=!0){return"boolean"==typeof e||(!0===t?!c(e):!!t&&l(e)<=t)};const a=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function c(e){for(const t in e){if(a.has(t))return!0;const n=e[t];if(Array.isArray(n)&&n.some(c))return!0;if("object"==typeof n&&c(n))return!0}return!1}function l(e){let t=0;for(const n in e){if("$ref"===n)return 1/0;if(t++,!i.has(n)&&("object"==typeof e[n]&&(0,r.eachItem)(e[n],(e=>t+=l(e))),t===1/0))return 1/0}return t}function u(e,t="",n){!1!==n&&(t=p(t));const r=e.parse(t);return d(e,r)}function d(e,t){return e.serialize(t).split("#")[0]+"#"}t.getFullPath=u,t._getFullPath=d;const h=/#\/?$/;function p(e){return e?e.replace(h,""):""}t.normalizeId=p,t.resolveUrl=function(e,t,n){return n=p(n),e.resolve(t,n)};const m=/^[a-z_][-a-z0-9._]*$/i;t.getSchemaRefs=function(e,t){if("boolean"==typeof e)return{};const{schemaId:n,uriResolver:r}=this.opts,i=p(e[n]||t),a={"":i},c=u(r,i,!1),l={},d=new Set;return s(e,{allKeys:!0},((e,t,r,o)=>{if(void 0===o)return;const s=c+t;let i=a[o];function u(t){const n=this.opts.uriResolver.resolve;if(t=p(i?n(i,t):t),d.has(t))throw f(t);d.add(t);let r=this.refs[t];return"string"==typeof r&&(r=this.refs[r]),"object"==typeof r?h(e,r.schema,t):t!==p(s)&&("#"===t[0]?(h(e,l[t],t),l[t]=e):this.refs[t]=s),t}function g(e){if("string"==typeof e){if(!m.test(e))throw new Error(`invalid anchor "${e}"`);u.call(this,`#${e}`)}}"string"==typeof e[n]&&(i=u.call(this,e[n])),g.call(this,e.$anchor),g.call(this,e.$dynamicAnchor),a[t]=i})),l;function h(e,t,n){if(void 0!==t&&!o(e,t))throw f(n)}function f(e){return new Error(`reference "${e}" resolves to more than one schema`)}}},396:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getRules=t.isJSONType=void 0;const n=new Set(["string","number","integer","boolean","null","object","array"]);t.isJSONType=function(e){return"string"==typeof e&&n.has(e)},t.getRules=function(){const e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}},4227:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.checkStrictMode=t.getErrorPath=t.Type=t.useFunc=t.setEvaluated=t.evaluatedPropsToName=t.mergeEvaluated=t.eachItem=t.unescapeJsonPointer=t.escapeJsonPointer=t.escapeFragment=t.unescapeFragment=t.schemaRefOrVal=t.schemaHasRulesButRef=t.schemaHasRules=t.checkUnknownRules=t.alwaysValidSchema=t.toHash=void 0;const r=n(9029),o=n(1520);function s(e,t=e.schema){const{opts:n,self:r}=e;if(!n.strictSchema)return;if("boolean"==typeof t)return;const o=r.RULES.keywords;for(const n in t)o[n]||m(e,`unknown keyword: "${n}"`)}function i(e,t){if("boolean"==typeof e)return!e;for(const n in e)if(t[n])return!0;return!1}function a(e){return"number"==typeof e?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}function c(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function l({mergeNames:e,mergeToName:t,mergeValues:n,resultToName:o}){return(s,i,a,c)=>{const l=void 0===a?i:a instanceof r.Name?(i instanceof r.Name?e(s,i,a):t(s,i,a),a):i instanceof r.Name?(t(s,a,i),i):n(i,a);return c!==r.Name||l instanceof r.Name?l:o(s,l)}}function u(e,t){if(!0===t)return e.var("props",!0);const n=e.var("props",r._`{}`);return void 0!==t&&d(e,n,t),n}function d(e,t,n){Object.keys(n).forEach((n=>e.assign(r._`${t}${(0,r.getProperty)(n)}`,!0)))}t.toHash=function(e){const t={};for(const n of e)t[n]=!0;return t},t.alwaysValidSchema=function(e,t){return"boolean"==typeof t?t:0===Object.keys(t).length||(s(e,t),!i(t,e.self.RULES.all))},t.checkUnknownRules=s,t.schemaHasRules=i,t.schemaHasRulesButRef=function(e,t){if("boolean"==typeof e)return!e;for(const n in e)if("$ref"!==n&&t.all[n])return!0;return!1},t.schemaRefOrVal=function({topSchemaRef:e,schemaPath:t},n,o,s){if(!s){if("number"==typeof n||"boolean"==typeof n)return n;if("string"==typeof n)return r._`${n}`}return r._`${e}${t}${(0,r.getProperty)(o)}`},t.unescapeFragment=function(e){return c(decodeURIComponent(e))},t.escapeFragment=function(e){return encodeURIComponent(a(e))},t.escapeJsonPointer=a,t.unescapeJsonPointer=c,t.eachItem=function(e,t){if(Array.isArray(e))for(const n of e)t(n);else t(e)},t.mergeEvaluated={props:l({mergeNames:(e,t,n)=>e.if(r._`${n} !== true && ${t} !== undefined`,(()=>{e.if(r._`${t} === true`,(()=>e.assign(n,!0)),(()=>e.assign(n,r._`${n} || {}`).code(r._`Object.assign(${n}, ${t})`)))})),mergeToName:(e,t,n)=>e.if(r._`${n} !== true`,(()=>{!0===t?e.assign(n,!0):(e.assign(n,r._`${n} || {}`),d(e,n,t))})),mergeValues:(e,t)=>!0===e||{...e,...t},resultToName:u}),items:l({mergeNames:(e,t,n)=>e.if(r._`${n} !== true && ${t} !== undefined`,(()=>e.assign(n,r._`${t} === true ? true : ${n} > ${t} ? ${n} : ${t}`))),mergeToName:(e,t,n)=>e.if(r._`${n} !== true`,(()=>e.assign(n,!0===t||r._`${n} > ${t} ? ${n} : ${t}`))),mergeValues:(e,t)=>!0===e||Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})},t.evaluatedPropsToName=u,t.setEvaluated=d;const h={};var p;function m(e,t,n=e.opts.strictSchema){if(n){if(t=`strict mode: ${t}`,!0===n)throw new Error(t);e.self.logger.warn(t)}}t.useFunc=function(e,t){return e.scopeValue("func",{ref:t,code:h[t.code]||(h[t.code]=new o._Code(t.code))})},function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"}(p||(t.Type=p={})),t.getErrorPath=function(e,t,n){if(e instanceof r.Name){const o=t===p.Num;return n?o?r._`"[" + ${e} + "]"`:r._`"['" + ${e} + "']"`:o?r._`"/" + ${e}`:r._`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return n?(0,r.getProperty)(e).toString():"/"+a(e)},t.checkStrictMode=m},7887:(e,t)=>{"use strict";function n(e,t){return t.rules.some((t=>r(e,t)))}function r(e,t){var n;return void 0!==e[t.keyword]||(null===(n=t.definition.implements)||void 0===n?void 0:n.some((t=>void 0!==e[t])))}Object.defineProperty(t,"__esModule",{value:!0}),t.shouldUseRule=t.shouldUseGroup=t.schemaHasRulesForType=void 0,t.schemaHasRulesForType=function({schema:e,self:t},r){const o=t.RULES.types[r];return o&&!0!==o&&n(e,o)},t.shouldUseGroup=n,t.shouldUseRule=r},8727:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.boolOrEmptySchema=t.topBoolOrEmptySchema=void 0;const r=n(8708),o=n(9029),s=n(2023),i={message:"boolean schema is false"};function a(e,t){const{gen:n,data:o}=e,s={gen:n,keyword:"false schema",data:o,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,r.reportError)(s,i,void 0,t)}t.topBoolOrEmptySchema=function(e){const{gen:t,schema:n,validateName:r}=e;!1===n?a(e,!1):"object"==typeof n&&!0===n.$async?t.return(s.default.data):(t.assign(o._`${r}.errors`,null),t.return(!0))},t.boolOrEmptySchema=function(e,t){const{gen:n,schema:r}=e;!1===r?(n.var(t,!1),a(e)):n.var(t,!0)}},208:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.reportTypeError=t.checkDataTypes=t.checkDataType=t.coerceAndCheckDataType=t.getJSONTypes=t.getSchemaTypes=t.DataType=void 0;const r=n(396),o=n(7887),s=n(8708),i=n(9029),a=n(4227);var c;function l(e){const t=Array.isArray(e)?e:e?[e]:[];if(t.every(r.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}!function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"}(c||(t.DataType=c={})),t.getSchemaTypes=function(e){const t=l(e.type);if(t.includes("null")){if(!1===e.nullable)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&void 0!==e.nullable)throw new Error('"nullable" cannot be used without "type"');!0===e.nullable&&t.push("null")}return t},t.getJSONTypes=l,t.coerceAndCheckDataType=function(e,t){const{gen:n,data:r,opts:s}=e,a=function(e,t){return t?e.filter((e=>u.has(e)||"array"===t&&"array"===e)):[]}(t,s.coerceTypes),l=t.length>0&&!(0===a.length&&1===t.length&&(0,o.schemaHasRulesForType)(e,t[0]));if(l){const o=h(t,r,s.strictNumbers,c.Wrong);n.if(o,(()=>{a.length?function(e,t,n){const{gen:r,data:o,opts:s}=e,a=r.let("dataType",i._`typeof ${o}`),c=r.let("coerced",i._`undefined`);"array"===s.coerceTypes&&r.if(i._`${a} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,(()=>r.assign(o,i._`${o}[0]`).assign(a,i._`typeof ${o}`).if(h(t,o,s.strictNumbers),(()=>r.assign(c,o))))),r.if(i._`${c} !== undefined`);for(const e of n)(u.has(e)||"array"===e&&"array"===s.coerceTypes)&&l(e);function l(e){switch(e){case"string":return void r.elseIf(i._`${a} == "number" || ${a} == "boolean"`).assign(c,i._`"" + ${o}`).elseIf(i._`${o} === null`).assign(c,i._`""`);case"number":return void r.elseIf(i._`${a} == "boolean" || ${o} === null
2
- || (${a} == "string" && ${o} && ${o} == +${o})`).assign(c,i._`+${o}`);case"integer":return void r.elseIf(i._`${a} === "boolean" || ${o} === null
3
- || (${a} === "string" && ${o} && ${o} == +${o} && !(${o} % 1))`).assign(c,i._`+${o}`);case"boolean":return void r.elseIf(i._`${o} === "false" || ${o} === 0 || ${o} === null`).assign(c,!1).elseIf(i._`${o} === "true" || ${o} === 1`).assign(c,!0);case"null":return r.elseIf(i._`${o} === "" || ${o} === 0 || ${o} === false`),void r.assign(c,null);case"array":r.elseIf(i._`${a} === "string" || ${a} === "number"
4
- || ${a} === "boolean" || ${o} === null`).assign(c,i._`[${o}]`)}}r.else(),m(e),r.endIf(),r.if(i._`${c} !== undefined`,(()=>{r.assign(o,c),function({gen:e,parentData:t,parentDataProperty:n},r){e.if(i._`${t} !== undefined`,(()=>e.assign(i._`${t}[${n}]`,r)))}(e,c)}))}(e,t,a):m(e)}))}return l};const u=new Set(["string","number","integer","boolean","null"]);function d(e,t,n,r=c.Correct){const o=r===c.Correct?i.operators.EQ:i.operators.NEQ;let s;switch(e){case"null":return i._`${t} ${o} null`;case"array":s=i._`Array.isArray(${t})`;break;case"object":s=i._`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":s=a(i._`!(${t} % 1) && !isNaN(${t})`);break;case"number":s=a();break;default:return i._`typeof ${t} ${o} ${e}`}return r===c.Correct?s:(0,i.not)(s);function a(e=i.nil){return(0,i.and)(i._`typeof ${t} == "number"`,e,n?i._`isFinite(${t})`:i.nil)}}function h(e,t,n,r){if(1===e.length)return d(e[0],t,n,r);let o;const s=(0,a.toHash)(e);if(s.array&&s.object){const e=i._`typeof ${t} != "object"`;o=s.null?e:i._`!${t} || ${e}`,delete s.null,delete s.array,delete s.object}else o=i.nil;s.number&&delete s.integer;for(const e in s)o=(0,i.and)(o,d(e,t,n,r));return o}t.checkDataType=d,t.checkDataTypes=h;const p={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>"string"==typeof e?i._`{type: ${e}}`:i._`{type: ${t}}`};function m(e){const t=function(e){const{gen:t,data:n,schema:r}=e,o=(0,a.schemaRefOrVal)(e,r,"type");return{gen:t,keyword:"type",data:n,schema:r.type,schemaCode:o,schemaValue:o,parentSchema:r,params:{},it:e}}(e);(0,s.reportError)(t,p)}t.reportTypeError=m},7870:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.assignDefaults=void 0;const r=n(9029),o=n(4227);function s(e,t,n){const{gen:s,compositeRule:i,data:a,opts:c}=e;if(void 0===n)return;const l=r._`${a}${(0,r.getProperty)(t)}`;if(i)return void(0,o.checkStrictMode)(e,`default is ignored for: ${l}`);let u=r._`${l} === undefined`;"empty"===c.useDefaults&&(u=r._`${u} || ${l} === null || ${l} === ""`),s.if(u,r._`${l} = ${(0,r.stringify)(n)}`)}t.assignDefaults=function(e,t){const{properties:n,items:r}=e.schema;if("object"===t&&n)for(const t in n)s(e,t,n[t].default);else"array"===t&&Array.isArray(r)&&r.forEach(((t,n)=>s(e,n,t.default)))}},2586:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getData=t.KeywordCxt=t.validateFunctionCode=void 0;const r=n(8727),o=n(208),s=n(7887),i=n(208),a=n(7870),c=n(3673),l=n(4495),u=n(9029),d=n(2023),h=n(6939),p=n(4227),m=n(8708);function f({gen:e,validateName:t,schema:n,schemaEnv:r,opts:o},s){o.code.es5?e.func(t,u._`${d.default.data}, ${d.default.valCxt}`,r.$async,(()=>{e.code(u._`"use strict"; ${g(n,o)}`),function(e,t){e.if(d.default.valCxt,(()=>{e.var(d.default.instancePath,u._`${d.default.valCxt}.${d.default.instancePath}`),e.var(d.default.parentData,u._`${d.default.valCxt}.${d.default.parentData}`),e.var(d.default.parentDataProperty,u._`${d.default.valCxt}.${d.default.parentDataProperty}`),e.var(d.default.rootData,u._`${d.default.valCxt}.${d.default.rootData}`),t.dynamicRef&&e.var(d.default.dynamicAnchors,u._`${d.default.valCxt}.${d.default.dynamicAnchors}`)}),(()=>{e.var(d.default.instancePath,u._`""`),e.var(d.default.parentData,u._`undefined`),e.var(d.default.parentDataProperty,u._`undefined`),e.var(d.default.rootData,d.default.data),t.dynamicRef&&e.var(d.default.dynamicAnchors,u._`{}`)}))}(e,o),e.code(s)})):e.func(t,u._`${d.default.data}, ${function(e){return u._`{${d.default.instancePath}="", ${d.default.parentData}, ${d.default.parentDataProperty}, ${d.default.rootData}=${d.default.data}${e.dynamicRef?u._`, ${d.default.dynamicAnchors}={}`:u.nil}}={}`}(o)}`,r.$async,(()=>e.code(g(n,o)).code(s)))}function g(e,t){const n="object"==typeof e&&e[t.schemaId];return n&&(t.code.source||t.code.process)?u._`/*# sourceURL=${n} */`:u.nil}function y({schema:e,self:t}){if("boolean"==typeof e)return!e;for(const n in e)if(t.RULES.all[n])return!0;return!1}function b(e){return"boolean"!=typeof e.schema}function w(e){(0,p.checkUnknownRules)(e),function(e){const{schema:t,errSchemaPath:n,opts:r,self:o}=e;t.$ref&&r.ignoreKeywordsWithRef&&(0,p.schemaHasRulesButRef)(t,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${n}"`)}(e)}function v(e,t){if(e.opts.jtd)return E(e,[],!1,t);const n=(0,o.getSchemaTypes)(e.schema);E(e,n,!(0,o.coerceAndCheckDataType)(e,n),t)}function A({gen:e,schemaEnv:t,schema:n,errSchemaPath:r,opts:o}){const s=n.$comment;if(!0===o.$comment)e.code(u._`${d.default.self}.logger.log(${s})`);else if("function"==typeof o.$comment){const n=u.str`${r}/$comment`,o=e.scopeValue("root",{ref:t.root});e.code(u._`${d.default.self}.opts.$comment(${s}, ${n}, ${o}.schema)`)}}function E(e,t,n,r){const{gen:o,schema:a,data:c,allErrors:l,opts:h,self:m}=e,{RULES:f}=m;function g(p){(0,s.shouldUseGroup)(a,p)&&(p.type?(o.if((0,i.checkDataType)(p.type,c,h.strictNumbers)),C(e,p),1===t.length&&t[0]===p.type&&n&&(o.else(),(0,i.reportTypeError)(e)),o.endIf()):C(e,p),l||o.if(u._`${d.default.errors} === ${r||0}`))}!a.$ref||!h.ignoreKeywordsWithRef&&(0,p.schemaHasRulesButRef)(a,f)?(h.jtd||function(e,t){!e.schemaEnv.meta&&e.opts.strictTypes&&(function(e,t){t.length&&(e.dataTypes.length?(t.forEach((t=>{T(e.dataTypes,t)||S(e,`type "${t}" not allowed by context "${e.dataTypes.join(",")}"`)})),function(e,t){const n=[];for(const r of e.dataTypes)T(t,r)?n.push(r):t.includes("integer")&&"number"===r&&n.push("integer");e.dataTypes=n}(e,t)):e.dataTypes=t)}(e,t),e.opts.allowUnionTypes||function(e,t){t.length>1&&(2!==t.length||!t.includes("null"))&&S(e,"use allowUnionTypes to allow union type keyword")}(e,t),function(e,t){const n=e.self.RULES.all;for(const r in n){const o=n[r];if("object"==typeof o&&(0,s.shouldUseRule)(e.schema,o)){const{type:n}=o.definition;n.length&&!n.some((e=>{return r=e,(n=t).includes(r)||"number"===r&&n.includes("integer");var n,r}))&&S(e,`missing type "${n.join(",")}" for keyword "${r}"`)}}}(e,e.dataTypes))}(e,t),o.block((()=>{for(const e of f.rules)g(e);g(f.post)}))):o.block((()=>P(e,"$ref",f.all.$ref.definition)))}function C(e,t){const{gen:n,schema:r,opts:{useDefaults:o}}=e;o&&(0,a.assignDefaults)(e,t.type),n.block((()=>{for(const n of t.rules)(0,s.shouldUseRule)(r,n)&&P(e,n.keyword,n.definition,t.type)}))}function T(e,t){return e.includes(t)||"integer"===t&&e.includes("number")}function S(e,t){t+=` at "${e.schemaEnv.baseId+e.errSchemaPath}" (strictTypes)`,(0,p.checkStrictMode)(e,t,e.opts.strictTypes)}t.validateFunctionCode=function(e){b(e)&&(w(e),y(e))?function(e){const{schema:t,opts:n,gen:r}=e;f(e,(()=>{n.$comment&&t.$comment&&A(e),function(e){const{schema:t,opts:n}=e;void 0!==t.default&&n.useDefaults&&n.strictSchema&&(0,p.checkStrictMode)(e,"default is ignored in the schema root")}(e),r.let(d.default.vErrors,null),r.let(d.default.errors,0),n.unevaluated&&function(e){const{gen:t,validateName:n}=e;e.evaluated=t.const("evaluated",u._`${n}.evaluated`),t.if(u._`${e.evaluated}.dynamicProps`,(()=>t.assign(u._`${e.evaluated}.props`,u._`undefined`))),t.if(u._`${e.evaluated}.dynamicItems`,(()=>t.assign(u._`${e.evaluated}.items`,u._`undefined`)))}(e),v(e),function(e){const{gen:t,schemaEnv:n,validateName:r,ValidationError:o,opts:s}=e;n.$async?t.if(u._`${d.default.errors} === 0`,(()=>t.return(d.default.data)),(()=>t.throw(u._`new ${o}(${d.default.vErrors})`))):(t.assign(u._`${r}.errors`,d.default.vErrors),s.unevaluated&&function({gen:e,evaluated:t,props:n,items:r}){n instanceof u.Name&&e.assign(u._`${t}.props`,n),r instanceof u.Name&&e.assign(u._`${t}.items`,r)}(e),t.return(u._`${d.default.errors} === 0`))}(e)}))}(e):f(e,(()=>(0,r.topBoolOrEmptySchema)(e)))};class _{constructor(e,t,n){if((0,c.validateKeywordUsage)(e,t,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=t.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,p.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=t.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=t,this.$data)this.schemaCode=e.gen.const("vSchema",N(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,c.validSchemaType)(this.schema,t.schemaType,t.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(t.schemaType)}`);("code"in t?t.trackErrors:!1!==t.errors)&&(this.errsCount=e.gen.const("_errs",d.default.errors))}result(e,t,n){this.failResult((0,u.not)(e),t,n)}failResult(e,t,n){this.gen.if(e),n?n():this.error(),t?(this.gen.else(),t(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,t){this.failResult((0,u.not)(e),void 0,t)}fail(e){if(void 0===e)return this.error(),void(this.allErrors||this.gen.if(!1));this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);const{schemaCode:t}=this;this.fail(u._`${t} !== undefined && (${(0,u.or)(this.invalid$data(),e)})`)}error(e,t,n){if(t)return this.setParams(t),this._error(e,n),void this.setParams({});this._error(e,n)}_error(e,t){(e?m.reportExtraError:m.reportError)(this,this.def.error,t)}$dataError(){(0,m.reportError)(this,this.def.$dataError||m.keyword$DataError)}reset(){if(void 0===this.errsCount)throw new Error('add "trackErrors" to keyword definition');(0,m.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,t){t?Object.assign(this.params,e):this.params=e}block$data(e,t,n=u.nil){this.gen.block((()=>{this.check$data(e,n),t()}))}check$data(e=u.nil,t=u.nil){if(!this.$data)return;const{gen:n,schemaCode:r,schemaType:o,def:s}=this;n.if((0,u.or)(u._`${r} === undefined`,t)),e!==u.nil&&n.assign(e,!0),(o.length||s.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==u.nil&&n.assign(e,!1)),n.else()}invalid$data(){const{gen:e,schemaCode:t,schemaType:n,def:r,it:o}=this;return(0,u.or)(function(){if(n.length){if(!(t instanceof u.Name))throw new Error("ajv implementation error");const e=Array.isArray(n)?n:[n];return u._`${(0,i.checkDataTypes)(e,t,o.opts.strictNumbers,i.DataType.Wrong)}`}return u.nil}(),function(){if(r.validateSchema){const n=e.scopeValue("validate$data",{ref:r.validateSchema});return u._`!${n}(${t})`}return u.nil}())}subschema(e,t){const n=(0,l.getSubschema)(this.it,e);(0,l.extendSubschemaData)(n,this.it,e),(0,l.extendSubschemaMode)(n,e);const o={...this.it,...n,items:void 0,props:void 0};return function(e,t){b(e)&&(w(e),y(e))?function(e,t){const{schema:n,gen:r,opts:o}=e;o.$comment&&n.$comment&&A(e),function(e){const t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,h.resolveUrl)(e.opts.uriResolver,e.baseId,t))}(e),function(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}(e);const s=r.const("_errs",d.default.errors);v(e,s),r.var(t,u._`${s} === ${d.default.errors}`)}(e,t):(0,r.boolOrEmptySchema)(e,t)}(o,t),o}mergeEvaluated(e,t){const{it:n,gen:r}=this;n.opts.unevaluated&&(!0!==n.props&&void 0!==e.props&&(n.props=p.mergeEvaluated.props(r,e.props,n.props,t)),!0!==n.items&&void 0!==e.items&&(n.items=p.mergeEvaluated.items(r,e.items,n.items,t)))}mergeValidEvaluated(e,t){const{it:n,gen:r}=this;if(n.opts.unevaluated&&(!0!==n.props||!0!==n.items))return r.if(t,(()=>this.mergeEvaluated(e,u.Name))),!0}}function P(e,t,n,r){const o=new _(e,n,t);"code"in n?n.code(o,r):o.$data&&n.validate?(0,c.funcKeywordCode)(o,n):"macro"in n?(0,c.macroKeywordCode)(o,n):(n.compile||n.validate)&&(0,c.funcKeywordCode)(o,n)}t.KeywordCxt=_;const M=/^\/(?:[^~]|~0|~1)*$/,x=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function N(e,{dataLevel:t,dataNames:n,dataPathArr:r}){let o,s;if(""===e)return d.default.rootData;if("/"===e[0]){if(!M.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);o=e,s=d.default.rootData}else{const i=x.exec(e);if(!i)throw new Error(`Invalid JSON-pointer: ${e}`);const a=+i[1];if(o=i[2],"#"===o){if(a>=t)throw new Error(c("property/index",a));return r[t-a]}if(a>t)throw new Error(c("data",a));if(s=n[t-a],!o)return s}let i=s;const a=o.split("/");for(const e of a)e&&(s=u._`${s}${(0,u.getProperty)((0,p.unescapeJsonPointer)(e))}`,i=u._`${i} && ${s}`);return i;function c(e,n){return`Cannot access ${e} ${n} levels up, current level is ${t}`}}t.getData=N},3673:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validateKeywordUsage=t.validSchemaType=t.funcKeywordCode=t.macroKeywordCode=void 0;const r=n(9029),o=n(2023),s=n(5765),i=n(8708);function a(e){const{gen:t,data:n,it:o}=e;t.if(o.parentData,(()=>t.assign(n,r._`${o.parentData}[${o.parentDataProperty}]`)))}function c(e,t,n){if(void 0===n)throw new Error(`keyword "${t}" failed to compile`);return e.scopeValue("keyword","function"==typeof n?{ref:n}:{ref:n,code:(0,r.stringify)(n)})}t.macroKeywordCode=function(e,t){const{gen:n,keyword:o,schema:s,parentSchema:i,it:a}=e,l=t.macro.call(a.self,s,i,a),u=c(n,o,l);!1!==a.opts.validateSchema&&a.self.validateSchema(l,!0);const d=n.name("valid");e.subschema({schema:l,schemaPath:r.nil,errSchemaPath:`${a.errSchemaPath}/${o}`,topSchemaRef:u,compositeRule:!0},d),e.pass(d,(()=>e.error(!0)))},t.funcKeywordCode=function(e,t){var n;const{gen:l,keyword:u,schema:d,parentSchema:h,$data:p,it:m}=e;!function({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}(m,t);const f=!p&&t.compile?t.compile.call(m.self,d,h,m):t.validate,g=c(l,u,f),y=l.let("valid");function b(n=(t.async?r._`await `:r.nil)){const i=m.opts.passContext?o.default.this:o.default.self,a=!("compile"in t&&!p||!1===t.schema);l.assign(y,r._`${n}${(0,s.callValidateCode)(e,g,i,a)}`,t.modifying)}function w(e){var n;l.if((0,r.not)(null!==(n=t.valid)&&void 0!==n?n:y),e)}e.block$data(y,(function(){if(!1===t.errors)b(),t.modifying&&a(e),w((()=>e.error()));else{const n=t.async?function(){const e=l.let("ruleErrs",null);return l.try((()=>b(r._`await `)),(t=>l.assign(y,!1).if(r._`${t} instanceof ${m.ValidationError}`,(()=>l.assign(e,r._`${t}.errors`)),(()=>l.throw(t))))),e}():function(){const e=r._`${g}.errors`;return l.assign(e,null),b(r.nil),e}();t.modifying&&a(e),w((()=>function(e,t){const{gen:n}=e;n.if(r._`Array.isArray(${t})`,(()=>{n.assign(o.default.vErrors,r._`${o.default.vErrors} === null ? ${t} : ${o.default.vErrors}.concat(${t})`).assign(o.default.errors,r._`${o.default.vErrors}.length`),(0,i.extendErrors)(e)}),(()=>e.error()))}(e,n)))}})),e.ok(null!==(n=t.valid)&&void 0!==n?n:y)},t.validSchemaType=function(e,t,n=!1){return!t.length||t.some((t=>"array"===t?Array.isArray(e):"object"===t?e&&"object"==typeof e&&!Array.isArray(e):typeof e==t||n&&void 0===e))},t.validateKeywordUsage=function({schema:e,opts:t,self:n,errSchemaPath:r},o,s){if(Array.isArray(o.keyword)?!o.keyword.includes(s):o.keyword!==s)throw new Error("ajv implementation error");const i=o.dependencies;if(null==i?void 0:i.some((t=>!Object.prototype.hasOwnProperty.call(e,t))))throw new Error(`parent schema must have dependencies of ${s}: ${i.join(",")}`);if(o.validateSchema&&!o.validateSchema(e[s])){const e=`keyword "${s}" value is invalid at path "${r}": `+n.errorsText(o.validateSchema.errors);if("log"!==t.validateSchema)throw new Error(e);n.logger.error(e)}}},4495:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extendSubschemaMode=t.extendSubschemaData=t.getSubschema=void 0;const r=n(9029),o=n(4227);t.getSubschema=function(e,{keyword:t,schemaProp:n,schema:s,schemaPath:i,errSchemaPath:a,topSchemaRef:c}){if(void 0!==t&&void 0!==s)throw new Error('both "keyword" and "schema" passed, only one allowed');if(void 0!==t){const s=e.schema[t];return void 0===n?{schema:s,schemaPath:r._`${e.schemaPath}${(0,r.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:s[n],schemaPath:r._`${e.schemaPath}${(0,r.getProperty)(t)}${(0,r.getProperty)(n)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,o.escapeFragment)(n)}`}}if(void 0!==s){if(void 0===i||void 0===a||void 0===c)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:s,schemaPath:i,topSchemaRef:c,errSchemaPath:a}}throw new Error('either "keyword" or "schema" must be passed')},t.extendSubschemaData=function(e,t,{dataProp:n,dataPropType:s,data:i,dataTypes:a,propertyName:c}){if(void 0!==i&&void 0!==n)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:l}=t;if(void 0!==n){const{errorPath:i,dataPathArr:a,opts:c}=t;u(l.let("data",r._`${t.data}${(0,r.getProperty)(n)}`,!0)),e.errorPath=r.str`${i}${(0,o.getErrorPath)(n,s,c.jsPropertySyntax)}`,e.parentDataProperty=r._`${n}`,e.dataPathArr=[...a,e.parentDataProperty]}function u(n){e.data=n,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,n]}void 0!==i&&(u(i instanceof r.Name?i:l.let("data",i,!0)),void 0!==c&&(e.propertyName=c)),a&&(e.dataTypes=a)},t.extendSubschemaMode=function(e,{jtdDiscriminator:t,jtdMetadata:n,compositeRule:r,createErrors:o,allErrors:s}){void 0!==r&&(e.compositeRule=r),void 0!==o&&(e.createErrors=o),void 0!==s&&(e.allErrors=s),e.jtdDiscriminator=t,e.jtdMetadata=n}},4042:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CodeGen=t.Name=t.nil=t.stringify=t.str=t._=t.KeywordCxt=void 0;var r=n(2586);Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return r.KeywordCxt}});var o=n(9029);Object.defineProperty(t,"_",{enumerable:!0,get:function(){return o._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return o.str}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return o.stringify}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return o.nil}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return o.Name}}),Object.defineProperty(t,"CodeGen",{enumerable:!0,get:function(){return o.CodeGen}});const s=n(3558),i=n(4551),a=n(396),c=n(3835),l=n(9029),u=n(6939),d=n(208),h=n(4227),p=n(3837),m=n(5944),f=(e,t)=>new RegExp(e,t);f.code="new RegExp";const g=["removeAdditional","useDefaults","coerceTypes"],y=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),b={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},w={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'};function v(e){var t,n,r,o,s,i,a,c,l,u,d,h,p,g,y,b,w,v,A,E,C,T,S,_,P;const M=e.strict,x=null===(t=e.code)||void 0===t?void 0:t.optimize,N=!0===x||void 0===x?1:x||0,$=null!==(r=null===(n=e.code)||void 0===n?void 0:n.regExp)&&void 0!==r?r:f,L=null!==(o=e.uriResolver)&&void 0!==o?o:m.default;return{strictSchema:null===(i=null!==(s=e.strictSchema)&&void 0!==s?s:M)||void 0===i||i,strictNumbers:null===(c=null!==(a=e.strictNumbers)&&void 0!==a?a:M)||void 0===c||c,strictTypes:null!==(u=null!==(l=e.strictTypes)&&void 0!==l?l:M)&&void 0!==u?u:"log",strictTuples:null!==(h=null!==(d=e.strictTuples)&&void 0!==d?d:M)&&void 0!==h?h:"log",strictRequired:null!==(g=null!==(p=e.strictRequired)&&void 0!==p?p:M)&&void 0!==g&&g,code:e.code?{...e.code,optimize:N,regExp:$}:{optimize:N,regExp:$},loopRequired:null!==(y=e.loopRequired)&&void 0!==y?y:200,loopEnum:null!==(b=e.loopEnum)&&void 0!==b?b:200,meta:null===(w=e.meta)||void 0===w||w,messages:null===(v=e.messages)||void 0===v||v,inlineRefs:null===(A=e.inlineRefs)||void 0===A||A,schemaId:null!==(E=e.schemaId)&&void 0!==E?E:"$id",addUsedSchema:null===(C=e.addUsedSchema)||void 0===C||C,validateSchema:null===(T=e.validateSchema)||void 0===T||T,validateFormats:null===(S=e.validateFormats)||void 0===S||S,unicodeRegExp:null===(_=e.unicodeRegExp)||void 0===_||_,int32range:null===(P=e.int32range)||void 0===P||P,uriResolver:L}}class A{constructor(e={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...v(e)};const{es5:t,lines:n}=this.opts.code;this.scope=new l.ValueScope({scope:{},prefixes:y,es5:t,lines:n}),this.logger=function(e){if(!1===e)return M;if(void 0===e)return console;if(e.log&&e.warn&&e.error)return e;throw new Error("logger must implement log, warn and error methods")}(e.logger);const r=e.validateFormats;e.validateFormats=!1,this.RULES=(0,a.getRules)(),E.call(this,b,e,"NOT SUPPORTED"),E.call(this,w,e,"DEPRECATED","warn"),this._metaOpts=P.call(this),e.formats&&S.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&_.call(this,e.keywords),"object"==typeof e.meta&&this.addMetaSchema(e.meta),T.call(this),e.validateFormats=r}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:e,meta:t,schemaId:n}=this.opts;let r=p;"id"===n&&(r={...p},r.id=r.$id,delete r.$id),t&&e&&this.addMetaSchema(r,r[n],!1)}defaultMeta(){const{meta:e,schemaId:t}=this.opts;return this.opts.defaultMeta="object"==typeof e?e[t]||e:void 0}validate(e,t){let n;if("string"==typeof e){if(n=this.getSchema(e),!n)throw new Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);const r=n(t);return"$async"in n||(this.errors=n.errors),r}compile(e,t){const n=this._addSchema(e,t);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,t){if("function"!=typeof this.opts.loadSchema)throw new Error("options.loadSchema should be a function");const{loadSchema:n}=this.opts;return r.call(this,e,t);async function r(e,t){await o.call(this,e.$schema);const n=this._addSchema(e,t);return n.validate||s.call(this,n)}async function o(e){e&&!this.getSchema(e)&&await r.call(this,{$ref:e},!0)}async function s(e){try{return this._compileSchemaEnv(e)}catch(t){if(!(t instanceof i.default))throw t;return a.call(this,t),await c.call(this,t.missingSchema),s.call(this,e)}}function a({missingSchema:e,missingRef:t}){if(this.refs[e])throw new Error(`AnySchema ${e} is loaded but ${t} cannot be resolved`)}async function c(e){const n=await l.call(this,e);this.refs[e]||await o.call(this,n.$schema),this.refs[e]||this.addSchema(n,e,t)}async function l(e){const t=this._loading[e];if(t)return t;try{return await(this._loading[e]=n(e))}finally{delete this._loading[e]}}}addSchema(e,t,n,r=this.opts.validateSchema){if(Array.isArray(e)){for(const t of e)this.addSchema(t,void 0,n,r);return this}let o;if("object"==typeof e){const{schemaId:t}=this.opts;if(o=e[t],void 0!==o&&"string"!=typeof o)throw new Error(`schema ${t} must be string`)}return t=(0,u.normalizeId)(t||o),this._checkUnique(t),this.schemas[t]=this._addSchema(e,n,t,r,!0),this}addMetaSchema(e,t,n=this.opts.validateSchema){return this.addSchema(e,t,!0,n),this}validateSchema(e,t){if("boolean"==typeof e)return!0;let n;if(n=e.$schema,void 0!==n&&"string"!=typeof n)throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,!0;const r=this.validate(n,e);if(!r&&t){const e="schema is invalid: "+this.errorsText();if("log"!==this.opts.validateSchema)throw new Error(e);this.logger.error(e)}return r}getSchema(e){let t;for(;"string"==typeof(t=C.call(this,e));)e=t;if(void 0===t){const{schemaId:n}=this.opts,r=new c.SchemaEnv({schema:{},schemaId:n});if(t=c.resolveSchema.call(this,r,e),!t)return;this.refs[e]=t}return t.validate||this._compileSchemaEnv(t)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{const t=C.call(this,e);return"object"==typeof t&&this._cache.delete(t.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{const t=e;this._cache.delete(t);let n=e[this.opts.schemaId];return n&&(n=(0,u.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(const t of e)this.addKeyword(t);return this}addKeyword(e,t){let n;if("string"==typeof e)n=e,"object"==typeof t&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),t.keyword=n);else{if("object"!=typeof e||void 0!==t)throw new Error("invalid addKeywords parameters");if(n=(t=e).keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}if(N.call(this,n,t),!t)return(0,h.eachItem)(n,(e=>$.call(this,e))),this;I.call(this,t);const r={...t,type:(0,d.getJSONTypes)(t.type),schemaType:(0,d.getJSONTypes)(t.schemaType)};return(0,h.eachItem)(n,0===r.type.length?e=>$.call(this,e,r):e=>r.type.forEach((t=>$.call(this,e,r,t)))),this}getKeyword(e){const t=this.RULES.all[e];return"object"==typeof t?t.definition:!!t}removeKeyword(e){const{RULES:t}=this;delete t.keywords[e],delete t.all[e];for(const n of t.rules){const t=n.rules.findIndex((t=>t.keyword===e));t>=0&&n.rules.splice(t,1)}return this}addFormat(e,t){return"string"==typeof t&&(t=new RegExp(t)),this.formats[e]=t,this}errorsText(e=this.errors,{separator:t=", ",dataVar:n="data"}={}){return e&&0!==e.length?e.map((e=>`${n}${e.instancePath} ${e.message}`)).reduce(((e,n)=>e+t+n)):"No errors"}$dataMetaSchema(e,t){const n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(const r of t){const t=r.split("/").slice(1);let o=e;for(const e of t)o=o[e];for(const e in n){const t=n[e];if("object"!=typeof t)continue;const{$data:r}=t.definition,s=o[e];r&&s&&(o[e]=O(s))}}return e}_removeAllSchemas(e,t){for(const n in e){const r=e[n];t&&!t.test(n)||("string"==typeof r?delete e[n]:r&&!r.meta&&(this._cache.delete(r.schema),delete e[n]))}}_addSchema(e,t,n,r=this.opts.validateSchema,o=this.opts.addUsedSchema){let s;const{schemaId:i}=this.opts;if("object"==typeof e)s=e[i];else{if(this.opts.jtd)throw new Error("schema must be object");if("boolean"!=typeof e)throw new Error("schema must be object or boolean")}let a=this._cache.get(e);if(void 0!==a)return a;n=(0,u.normalizeId)(s||n);const l=u.getSchemaRefs.call(this,e,n);return a=new c.SchemaEnv({schema:e,schemaId:i,meta:t,baseId:n,localRefs:l}),this._cache.set(a.schema,a),o&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=a),r&&this.validateSchema(e,!0),a}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):c.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){const t=this.opts;this.opts=this._metaOpts;try{c.compileSchema.call(this,e)}finally{this.opts=t}}}function E(e,t,n,r="error"){for(const o in e){const s=o;s in t&&this.logger[r](`${n}: option ${o}. ${e[s]}`)}}function C(e){return e=(0,u.normalizeId)(e),this.schemas[e]||this.refs[e]}function T(){const e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(const t in e)this.addSchema(e[t],t)}function S(){for(const e in this.opts.formats){const t=this.opts.formats[e];t&&this.addFormat(e,t)}}function _(e){if(Array.isArray(e))this.addVocabulary(e);else{this.logger.warn("keywords option as map is deprecated, pass array");for(const t in e){const n=e[t];n.keyword||(n.keyword=t),this.addKeyword(n)}}}function P(){const e={...this.opts};for(const t of g)delete e[t];return e}A.ValidationError=s.default,A.MissingRefError=i.default,t.default=A;const M={log(){},warn(){},error(){}},x=/^[a-z_$][a-z0-9_$:-]*$/i;function N(e,t){const{RULES:n}=this;if((0,h.eachItem)(e,(e=>{if(n.keywords[e])throw new Error(`Keyword ${e} is already defined`);if(!x.test(e))throw new Error(`Keyword ${e} has invalid name`)})),t&&t.$data&&!("code"in t)&&!("validate"in t))throw new Error('$data keyword must have "code" or "validate" function')}function $(e,t,n){var r;const o=null==t?void 0:t.post;if(n&&o)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:s}=this;let i=o?s.post:s.rules.find((({type:e})=>e===n));if(i||(i={type:n,rules:[]},s.rules.push(i)),s.keywords[e]=!0,!t)return;const a={keyword:e,definition:{...t,type:(0,d.getJSONTypes)(t.type),schemaType:(0,d.getJSONTypes)(t.schemaType)}};t.before?L.call(this,i,a,t.before):i.rules.push(a),s.all[e]=a,null===(r=t.implements)||void 0===r||r.forEach((e=>this.addKeyword(e)))}function L(e,t,n){const r=e.rules.findIndex((e=>e.keyword===n));r>=0?e.rules.splice(r,0,t):(e.rules.push(t),this.logger.warn(`rule ${n} is not defined`))}function I(e){let{metaSchema:t}=e;void 0!==t&&(e.$data&&this.opts.$data&&(t=O(t)),e.validateSchema=this.compile(t,!0))}const R={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function O(e){return{anyOf:[e,R]}}},9572:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(1678),o=n(7216),s=n(9547),i=n(8226),a=n(518),c=n(4588),l=n(5707),u=n(7082),d=["/properties"];t.default=function(e){return[r,o,s,i,a,t(this,c),l,t(this,u)].forEach((e=>this.addMetaSchema(e,void 0,!1))),this;function t(t,n){return e?t.$dataMetaSchema(n,d):n}}},6250:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(2017);r.code='require("ajv/dist/runtime/equal").default',t.default=r},3853:(e,t)=>{"use strict";function n(e){const t=e.length;let n,r=0,o=0;for(;o<t;)r++,n=e.charCodeAt(o++),n>=55296&&n<=56319&&o<t&&(n=e.charCodeAt(o),56320==(64512&n)&&o++);return r}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n,n.code='require("ajv/dist/runtime/ucs2length").default'},5944:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(8343);r.code='require("ajv/dist/runtime/uri").default',t.default=r},3558:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});class n extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}}t.default=n},5457:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validateAdditionalItems=void 0;const r=n(9029),o=n(4227),s={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:{message:({params:{len:e}})=>r.str`must NOT have more than ${e} items`,params:({params:{len:e}})=>r._`{limit: ${e}}`},code(e){const{parentSchema:t,it:n}=e,{items:r}=t;Array.isArray(r)?i(e,r):(0,o.checkStrictMode)(n,'"additionalItems" is ignored when "items" is not an array of schemas')}};function i(e,t){const{gen:n,schema:s,data:i,keyword:a,it:c}=e;c.items=!0;const l=n.const("len",r._`${i}.length`);if(!1===s)e.setParams({len:t.length}),e.pass(r._`${l} <= ${t.length}`);else if("object"==typeof s&&!(0,o.alwaysValidSchema)(c,s)){const s=n.var("valid",r._`${l} <= ${t.length}`);n.if((0,r.not)(s),(()=>function(s){n.forRange("i",t.length,l,(t=>{e.subschema({keyword:a,dataProp:t,dataPropType:o.Type.Num},s),c.allErrors||n.if((0,r.not)(s),(()=>n.break()))}))}(s))),e.ok(s)}}t.validateAdditionalItems=i,t.default=s},8660:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(5765),o=n(9029),s=n(2023),i=n(4227),a={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:{message:"must NOT have additional properties",params:({params:e})=>o._`{additionalProperty: ${e.additionalProperty}}`},code(e){const{gen:t,schema:n,parentSchema:a,data:c,errsCount:l,it:u}=e;if(!l)throw new Error("ajv implementation error");const{allErrors:d,opts:h}=u;if(u.props=!0,"all"!==h.removeAdditional&&(0,i.alwaysValidSchema)(u,n))return;const p=(0,r.allSchemaProperties)(a.properties),m=(0,r.allSchemaProperties)(a.patternProperties);function f(e){t.code(o._`delete ${c}[${e}]`)}function g(r){if("all"===h.removeAdditional||h.removeAdditional&&!1===n)f(r);else{if(!1===n)return e.setParams({additionalProperty:r}),e.error(),void(d||t.break());if("object"==typeof n&&!(0,i.alwaysValidSchema)(u,n)){const n=t.name("valid");"failing"===h.removeAdditional?(y(r,n,!1),t.if((0,o.not)(n),(()=>{e.reset(),f(r)}))):(y(r,n),d||t.if((0,o.not)(n),(()=>t.break())))}}}function y(t,n,r){const o={keyword:"additionalProperties",dataProp:t,dataPropType:i.Type.Str};!1===r&&Object.assign(o,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(o,n)}t.forIn("key",c,(n=>{p.length||m.length?t.if(function(n){let s;if(p.length>8){const e=(0,i.schemaRefOrVal)(u,a.properties,"properties");s=(0,r.isOwnProperty)(t,e,n)}else s=p.length?(0,o.or)(...p.map((e=>o._`${n} === ${e}`))):o.nil;return m.length&&(s=(0,o.or)(s,...m.map((t=>o._`${(0,r.usePattern)(e,t)}.test(${n})`)))),(0,o.not)(s)}(n),(()=>g(n))):g(n)})),e.ok(o._`${l} === ${s.default.errors}`)}};t.default=a},5844:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(4227),o={keyword:"allOf",schemaType:"array",code(e){const{gen:t,schema:n,it:o}=e;if(!Array.isArray(n))throw new Error("ajv implementation error");const s=t.name("valid");n.forEach(((t,n)=>{if((0,r.alwaysValidSchema)(o,t))return;const i=e.subschema({keyword:"allOf",schemaProp:n},s);e.ok(s),e.mergeEvaluated(i)}))}};t.default=o},6505:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:n(5765).validateUnion,error:{message:"must match a schema in anyOf"}};t.default=r},2661:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(9029),o=n(4227),s={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:{message:({params:{min:e,max:t}})=>void 0===t?r.str`must contain at least ${e} valid item(s)`:r.str`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>void 0===t?r._`{minContains: ${e}}`:r._`{minContains: ${e}, maxContains: ${t}}`},code(e){const{gen:t,schema:n,parentSchema:s,data:i,it:a}=e;let c,l;const{minContains:u,maxContains:d}=s;a.opts.next?(c=void 0===u?1:u,l=d):c=1;const h=t.const("len",r._`${i}.length`);if(e.setParams({min:c,max:l}),void 0===l&&0===c)return void(0,o.checkStrictMode)(a,'"minContains" == 0 without "maxContains": "contains" keyword ignored');if(void 0!==l&&c>l)return(0,o.checkStrictMode)(a,'"minContains" > "maxContains" is always invalid'),void e.fail();if((0,o.alwaysValidSchema)(a,n)){let t=r._`${h} >= ${c}`;return void 0!==l&&(t=r._`${t} && ${h} <= ${l}`),void e.pass(t)}a.items=!0;const p=t.name("valid");function m(){const e=t.name("_valid"),n=t.let("count",0);f(e,(()=>t.if(e,(()=>function(e){t.code(r._`${e}++`),void 0===l?t.if(r._`${e} >= ${c}`,(()=>t.assign(p,!0).break())):(t.if(r._`${e} > ${l}`,(()=>t.assign(p,!1).break())),1===c?t.assign(p,!0):t.if(r._`${e} >= ${c}`,(()=>t.assign(p,!0))))}(n)))))}function f(n,r){t.forRange("i",0,h,(t=>{e.subschema({keyword:"contains",dataProp:t,dataPropType:o.Type.Num,compositeRule:!0},n),r()}))}void 0===l&&1===c?f(p,(()=>t.if(p,(()=>t.break())))):0===c?(t.let(p,!0),void 0!==l&&t.if(r._`${i}.length > 0`,m)):(t.let(p,!1),m()),e.result(p,(()=>e.reset()))}};t.default=s},3025:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validateSchemaDeps=t.validatePropertyDeps=t.error=void 0;const r=n(9029),o=n(4227),s=n(5765);t.error={message:({params:{property:e,depsCount:t,deps:n}})=>{const o=1===t?"property":"properties";return r.str`must have ${o} ${n} when property ${e} is present`},params:({params:{property:e,depsCount:t,deps:n,missingProperty:o}})=>r._`{property: ${e},
1
+ var bio_test;(()=>{var e={8924:(e,t,n)=>{"use strict";n.d(t,{X:()=>o});var i=n(7362);class o extends i.e{static get Lesk(){return void 0===this.lesk&&(this.lesk=this.makePalette([[["G","A","S","T"],"orange"],[["C","V","I","L","P","F","Y","M","W"],"all_green"],[["N","Q","H"],"magenta"],[["D","E"],"red"],[["K","R"],"all_blue"]],!1,o)),this.lesk}static get GrokGroups(){return void 0===this.grokGroups&&(this.grokGroups=this.makePalette([[["C","U"],"yellow"],[["G","P"],"red"],[["A","V","I","L","M","F","Y","W"],"all_green"],[["R","H","K"],"light_blue"],[["D","E"],"dark_blue"],[["S","T","N","Q"],"orange"]],!1,o)),this.grokGroups}static get RasMol(){return void 0===this.rasMol&&(this.rasMol=new o({D:"#E60A0A",E:"#E60A0A",C:"#E6E600",M:"#E6E600",K:"#145AFF",R:"#145AFF",S:"#FA9600",T:"#FA9600",F:"#3232AA",Y:"#3232AA",N:"#00DCDC",Q:"#00DCDC",G:"#EBEBEB",L:"#0F820F",V:"#0F820F",I:"#0F820F",A:"#C8C8C8",W:"#B45AB4",H:"#8282D2",P:"#DC9682",others:"#BEA06E"})),this.rasMol}get(e){const t=e in o.aaSynonyms?o.aaSynonyms[e]:e;return super.get(t)}}o.aaSynonyms={MeNle:"L",MeA:"A",MeG:"G",MeF:"F"};class s{static getPalette(e="grok"){switch(e){case"grok":return o.GrokGroups;case"lesk":return o.Lesk;default:throw new Error(`ChemPalette: scheme \`${e}\` does not exist`)}}static getInnerOuter(e){let t=0,n="",i="";for(const o of e)"("==o?t++:")"==o?t--:t?n+=o:i+=o;return isNaN(parseInt(n))?[i,n]:[i,""]}static getColorAAPivot(e="",t="grok"){const n=this.getPalette(t);let[i,o]=this.getInnerOuter(e);if(i=i.length>6?`${i.slice(0,3)}...`:i,o=o.length>6?`${o.slice(0,3)}...`:o,1==e.length||"("==e[1]){const t=e[0]?.toUpperCase();return t in n?[n.get(t),t,o,1]:[this.undefinedColor,i,o,1]}if("d"==e[0]&&e[1]in n&&(2==e.length||"("==e[2])){const t=e[1]?.toUpperCase();return t in n?[n.get(t),t,o,2]:[this.undefinedColor,i,o,2]}if(e.substring(0,3)in this.AAFullNames&&(3==e.length||"("==e[3])){const t=this.AAFullNames[e.substring(0,3)];return t in n?[n.get(t),t,o,3]:[this.undefinedColor,i,o,3]}if(e[0]?.toLowerCase()==e[0]&&e.substring(1,3)in this.AAFullNames&&(4==e.length||"("==e[4])){const t=this.AAFullNames[e.substring(1,3)];return t in n?[n.get(t),t,o,4]:[this.undefinedColor,i,o,4]}return[this.undefinedColor,i,o,0]}}s.SemType="Aminoacids",s.SemTypeMultipleAlignment="AminoacidsMultipleAlignment",s.undefinedColor="rgb(100,100,100)",s.Names={G:"Glycine",L:"Leucine",Y:"Tyrosine",S:"Serine",E:"Glutamic acid",Q:"Glutamine",D:"Aspartic acid",N:"Asparagine",F:"Phenylalanine",A:"Alanine",K:"Lysine",R:"Arginine",H:"Histidine",C:"Cysteine",V:"Valine",P:"Proline",W:"Tryptophan",I:"Isoleucine",M:"Methionine",T:"Threonine"},s.AASmiles={G:"NCC(=O)O",L:"N[C@H](CC(C)C)C(=O)O",Y:"NC(CC1=CC=C(O)C=C1)C(=O)O",S:"NC(CO)C(=O)O",E:"N[C@@H](CCC(O)=O)C(=O)O",Q:"N[C@@H](CCC(N)=O)C(=O)O",D:"N[C@@H](CC(O)=O)C(=O)O",N:"N[C@@H](CC(N)=O)C(=O)O",F:"NC(CC1=CC=CC=C1)C(=O)O",A:"N[C@H](C)C(=O)O",K:"NC(CCCCN)C(=O)O",R:"N[C@H](CCCNC(=N)C)C(=O)O",H:"NC(CC1=CN=C[N]1)C(=O)O",C:"N[C@@H](CS)C(=O)O",V:"NC(C(C)C)C(=O)O",P:"N(CCC1)C1C(=O)O",W:"N[C@@H](Cc1c2ccccc2n([H])c1)C(=O)O",I:"N[C@H]([C@H](C)CC)C(=O)O",M:"NC(CCSC)C(=O)O",T:"NC(C(O)C)C(=O)O"},s.AASmilesTruncated={G:"*C*",L:"CC(C)C[C@H](*)*",Y:"C1=CC(=CC=C1CC(*)*)O",S:"OCC(*)C*",E:"*[C@@H](CCC(O)=O)*",Q:"*N[C@@H](CCC(N)=O)*",D:"*[C@@H](CC(O)=O)*",N:"*[C@@H](CC(N)=O)*",F:"C1=CC=C(C=C1)CC(*)*",A:"C[C@H](*)*",K:"C(CCN)CC(*)*",R:"*[C@H](CCCNC(=N)C)*",H:"C1=C(NC=N1)CC(*)*",C:"C([C@@H](*)*)S",V:"CC(C)C(*)*",P:"C1CCN(*)C1*",W:"*[C@@H](Cc1c2ccccc2n([H])c1)*",I:"CC[C@H](C)[C@H](*)*",M:"CSCCC(*)*",T:"CC(O)C(*)*"},s.AAFullNames={Ala:"A",Arg:"R",Asn:"N",Asp:"D",Cys:"C",Gln:"Q",Glu:"E",Gly:"G",His:"H",Ile:"I",Leu:"L",Lys:"K",Met:"M",Phe:"F",Pro:"P",Ser:"S",Thr:"T",Trp:"W",Tyr:"Y",Val:"V"}},6717:(e,t,n)=>{"use strict";n.d(t,{j:()=>o});var i=n(6082);async function o(){const e=i.Func.find({package:"Chem",name:"getRdKitModule"});if(0===e.length)throw new Error('Package "Chem" must be installed for getRdKitModule.');return(await e[0].prepare().call()).getOutputParamValue()}},3599:(e,t,n)=>{"use strict";n.d(t,{o:()=>i.o});var i=n(6869)},9124:(e,t,n)=>{"use strict";n.d(t,{b2:()=>s,fA:()=>r});var i=n(7389),o=n(6082);async function s(){const e="Helm",t=o.Func.find({package:e,name:"getHelmHelper"});if(0===t.length)throw new Error(`Package '${e}' must be installed for HelmHelper.`);return(await t[0].prepare().call()).getOutputParamValue()}function r(e,t){if(!e)throw new Error("Argument 'a' of type Atom or HelmType is mandatory.");let n,i;const o=e;return"ATOM"===o.T?(n=o.biotype(),i=o.elem):(n=e,i=t),[n,i]}o.JsInputBase,Error,i.input.helmAsync=async function(e,t){return(await s()).createHelmInput(e,t)}},8438:(e,t,n)=>{"use strict";function i(e){return e.startsWith("[")&&e.endsWith("]")?e.slice(1,-1):e}n.d(t,{D:()=>i})},8123:(e,t,n)=>{"use strict";n.d(t,{u:()=>i});const i={V2K_RGP_SHIFT:8,V2K_RGP_LINE:"M RGP",V2K_A_LINE:"A ",V3K_COUNTS_SHIFT:14,V3K_IDX_SHIFT:7,V3K_HEADER_FIRST_LINE:"\nDatagrok macromolecule handler\n\n",V3K_HEADER_SECOND_LINE:" 0 0 0 0 0 0 999 V3000\n",V3K_BEGIN_CTAB_BLOCK:"M V30 BEGIN CTAB\n",V3K_END_CTAB_BLOCK:"M V30 END CTAB\n",V3K_BEGIN_COUNTS_LINE:"M V30 COUNTS ",V3K_COUNTS_LINE_ENDING:" 0 0 0\n",V3K_BEGIN_ATOM_BLOCK:"M V30 BEGIN ATOM\n",V3K_END_ATOM_BLOCK:"M V30 END ATOM\n",V3K_BEGIN_BOND_BLOCK:"M V30 BEGIN BOND\n",V3K_END_BOND_BLOCK:"M V30 END BOND\n",V3K_BOND_CONFIG:" CFG=",V3K_BEGIN_DATA_LINE:"M V30 ",V3K_END:"M END",PRECISION_FACTOR:1e4,DEOXYRIBOSE:{polymerType:"RNA",symbol:"d"},RIBOSE:{polymerType:"RNA",symbol:"r"},PHOSPHATE:{polymerType:"RNA",symbol:"p"},OXYGEN:"O",HYDROGEN:"H"}},4356:(e,t,n)=>{"use strict";n.d(t,{Eu:()=>a,ub:()=>r});var i=n(4328);const o="Libraries";let s=Promise.resolve();async function r(){let e;return s=s.then((async()=>{const t=i.userSettings.getValue(o,"Settings",!0);e=t?JSON.parse(t):{exclude:[],explicit:[],duplicateMonomerPreferences:{}},e.exclude=e.exclude instanceof Array?e.exclude:[],e.explicit=e.explicit instanceof Array?e.explicit:[],e.duplicateMonomerPreferences=e.duplicateMonomerPreferences instanceof Object?e.duplicateMonomerPreferences:{},console.debug(`Bio: getUserLibSettings()\n${JSON.stringify(e,void 0,2)}`)})),await s,e}async function a(e){s=s.then((async()=>{console.debug(`Bio: setUserLibSettings()\n${JSON.stringify(e,void 0,2)}`),i.userSettings.add(o,"Settings",JSON.stringify(e),!0)})),await s}},5553:(e,t,n)=>{"use strict";n.d(t,{Qc:()=>C,WN:()=>T});var i=n(1991),o=n.n(i);const s="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,r=new Set,a="object"==typeof process&&process?process:{},l=(e,t,n,i)=>{"function"==typeof a.emitWarning?a.emitWarning(e,t,n,i):console.error(`[${n}] ${t}: ${e}`)};let c=globalThis.AbortController,u=globalThis.AbortSignal;if(void 0===c){u=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(e,t){this._onabort.push(t)}},c=class{constructor(){t()}signal=new u;abort(e){if(!this.signal.aborted){this.signal.reason=e,this.signal.aborted=!0;for(const t of this.signal._onabort)t(e);this.signal.onabort?.(e)}}};let e="1"!==a.env?.LRU_CACHE_IGNORE_AC_WARNING;const t=()=>{e&&(e=!1,l("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",t))}}Symbol("type");const h=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),d=e=>h(e)?e<=Math.pow(2,8)?Uint8Array:e<=Math.pow(2,16)?Uint16Array:e<=Math.pow(2,32)?Uint32Array:e<=Number.MAX_SAFE_INTEGER?p:null:null;class p extends Array{constructor(e){super(e),this.fill(0)}}class m{heap;length;static#e=!1;static create(e){const t=d(e);if(!t)return[];m.#e=!0;const n=new m(e,t);return m.#e=!1,n}constructor(e,t){if(!m.#e)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}}class g{#t;#n;#i;#o;#s;#r;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#a;#l;#c;#u;#h;#d;#p;#m;#g;#f;#y;#b;#w;#v;#A;#C;#T;static unsafeExposeInternals(e){return{starts:e.#w,ttls:e.#v,sizes:e.#b,keyMap:e.#c,keyList:e.#u,valList:e.#h,next:e.#d,prev:e.#p,get head(){return e.#m},get tail(){return e.#g},free:e.#f,isBackgroundFetch:t=>e.#S(t),backgroundFetch:(t,n,i,o)=>e.#E(t,n,i,o),moveToTail:t=>e.#M(t),indexes:t=>e.#x(t),rindexes:t=>e.#L(t),isStale:t=>e.#_(t)}}get max(){return this.#t}get maxSize(){return this.#n}get calculatedSize(){return this.#l}get size(){return this.#a}get fetchMethod(){return this.#s}get memoMethod(){return this.#r}get dispose(){return this.#i}get disposeAfter(){return this.#o}constructor(e){const{max:t=0,ttl:n,ttlResolution:i=1,ttlAutopurge:o,updateAgeOnGet:s,updateAgeOnHas:a,allowStale:c,dispose:u,disposeAfter:p,noDisposeOnSet:f,noUpdateTTL:y,maxSize:b=0,maxEntrySize:w=0,sizeCalculation:v,fetchMethod:A,memoMethod:C,noDeleteOnFetchRejection:T,noDeleteOnStaleGet:S,allowStaleOnFetchRejection:E,allowStaleOnFetchAbort:M,ignoreFetchAbort:x}=e;if(0!==t&&!h(t))throw new TypeError("max option must be a nonnegative integer");const L=t?d(t):Array;if(!L)throw new Error("invalid max value: "+t);if(this.#t=t,this.#n=b,this.maxEntrySize=w||this.#n,this.sizeCalculation=v,this.sizeCalculation){if(!this.#n&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if("function"!=typeof this.sizeCalculation)throw new TypeError("sizeCalculation set to non-function")}if(void 0!==C&&"function"!=typeof C)throw new TypeError("memoMethod must be a function if defined");if(this.#r=C,void 0!==A&&"function"!=typeof A)throw new TypeError("fetchMethod must be a function if specified");if(this.#s=A,this.#C=!!A,this.#c=new Map,this.#u=new Array(t).fill(void 0),this.#h=new Array(t).fill(void 0),this.#d=new L(t),this.#p=new L(t),this.#m=0,this.#g=0,this.#f=m.create(t),this.#a=0,this.#l=0,"function"==typeof u&&(this.#i=u),"function"==typeof p?(this.#o=p,this.#y=[]):(this.#o=void 0,this.#y=void 0),this.#A=!!this.#i,this.#T=!!this.#o,this.noDisposeOnSet=!!f,this.noUpdateTTL=!!y,this.noDeleteOnFetchRejection=!!T,this.allowStaleOnFetchRejection=!!E,this.allowStaleOnFetchAbort=!!M,this.ignoreFetchAbort=!!x,0!==this.maxEntrySize){if(0!==this.#n&&!h(this.#n))throw new TypeError("maxSize must be a positive integer if specified");if(!h(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#I()}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!S,this.updateAgeOnGet=!!s,this.updateAgeOnHas=!!a,this.ttlResolution=h(i)||0===i?i:1,this.ttlAutopurge=!!o,this.ttl=n||0,this.ttl){if(!h(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#P()}if(0===this.#t&&0===this.ttl&&0===this.#n)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#t&&!this.#n){const e="LRU_CACHE_UNBOUNDED";(e=>!r.has(e))(e)&&(r.add(e),l("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",e,g))}}getRemainingTTL(e){return this.#c.has(e)?1/0:0}#P(){const e=new p(this.#t),t=new p(this.#t);this.#v=e,this.#w=t,this.#N=(n,i,o=s.now())=>{if(t[n]=0!==i?o:0,e[n]=i,0!==i&&this.ttlAutopurge){const e=setTimeout((()=>{this.#_(n)&&this.#R(this.#u[n],"expire")}),i+1);e.unref&&e.unref()}},this.#$=n=>{t[n]=0!==e[n]?s.now():0},this.#O=(o,s)=>{if(e[s]){const r=e[s],a=t[s];if(!r||!a)return;o.ttl=r,o.start=a,o.now=n||i();const l=o.now-a;o.remainingTTL=r-l}};let n=0;const i=()=>{const e=s.now();if(this.ttlResolution>0){n=e;const t=setTimeout((()=>n=0),this.ttlResolution);t.unref&&t.unref()}return e};this.getRemainingTTL=o=>{const s=this.#c.get(o);if(void 0===s)return 0;const r=e[s],a=t[s];return r&&a?r-((n||i())-a):1/0},this.#_=o=>{const s=t[o],r=e[o];return!!r&&!!s&&(n||i())-s>r}}#$=()=>{};#O=()=>{};#N=()=>{};#_=()=>!1;#I(){const e=new p(this.#t);this.#l=0,this.#b=e,this.#H=t=>{this.#l-=e[t],e[t]=0},this.#k=(e,t,n,i)=>{if(this.#S(t))return 0;if(!h(n)){if(!i)throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");if("function"!=typeof i)throw new TypeError("sizeCalculation must be a function");if(n=i(t,e),!h(n))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return n},this.#F=(t,n,i)=>{if(e[t]=n,this.#n){const n=this.#n-e[t];for(;this.#l>n;)this.#D(!0)}this.#l+=e[t],i&&(i.entrySize=n,i.totalCalculatedSize=this.#l)}}#H=e=>{};#F=(e,t,n)=>{};#k=(e,t,n,i)=>{if(n||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#x({allowStale:e=this.allowStale}={}){if(this.#a)for(let t=this.#g;this.#G(t)&&(!e&&this.#_(t)||(yield t),t!==this.#m);)t=this.#p[t]}*#L({allowStale:e=this.allowStale}={}){if(this.#a)for(let t=this.#m;this.#G(t)&&(!e&&this.#_(t)||(yield t),t!==this.#g);)t=this.#d[t]}#G(e){return void 0!==e&&this.#c.get(this.#u[e])===e}*entries(){for(const e of this.#x())void 0===this.#h[e]||void 0===this.#u[e]||this.#S(this.#h[e])||(yield[this.#u[e],this.#h[e]])}*rentries(){for(const e of this.#L())void 0===this.#h[e]||void 0===this.#u[e]||this.#S(this.#h[e])||(yield[this.#u[e],this.#h[e]])}*keys(){for(const e of this.#x()){const t=this.#u[e];void 0===t||this.#S(this.#h[e])||(yield t)}}*rkeys(){for(const e of this.#L()){const t=this.#u[e];void 0===t||this.#S(this.#h[e])||(yield t)}}*values(){for(const e of this.#x())void 0===this.#h[e]||this.#S(this.#h[e])||(yield this.#h[e])}*rvalues(){for(const e of this.#L())void 0===this.#h[e]||this.#S(this.#h[e])||(yield this.#h[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,t={}){for(const n of this.#x()){const i=this.#h[n],o=this.#S(i)?i.__staleWhileFetching:i;if(void 0!==o&&e(o,this.#u[n],this))return this.get(this.#u[n],t)}}forEach(e,t=this){for(const n of this.#x()){const i=this.#h[n],o=this.#S(i)?i.__staleWhileFetching:i;void 0!==o&&e.call(t,o,this.#u[n],this)}}rforEach(e,t=this){for(const n of this.#L()){const i=this.#h[n],o=this.#S(i)?i.__staleWhileFetching:i;void 0!==o&&e.call(t,o,this.#u[n],this)}}purgeStale(){let e=!1;for(const t of this.#L({allowStale:!0}))this.#_(t)&&(this.#R(this.#u[t],"expire"),e=!0);return e}info(e){const t=this.#c.get(e);if(void 0===t)return;const n=this.#h[t],i=this.#S(n)?n.__staleWhileFetching:n;if(void 0===i)return;const o={value:i};if(this.#v&&this.#w){const e=this.#v[t],n=this.#w[t];if(e&&n){const t=e-(s.now()-n);o.ttl=t,o.start=Date.now()}}return this.#b&&(o.size=this.#b[t]),o}dump(){const e=[];for(const t of this.#x({allowStale:!0})){const n=this.#u[t],i=this.#h[t],o=this.#S(i)?i.__staleWhileFetching:i;if(void 0===o||void 0===n)continue;const r={value:o};if(this.#v&&this.#w){r.ttl=this.#v[t];const e=s.now()-this.#w[t];r.start=Math.floor(Date.now()-e)}this.#b&&(r.size=this.#b[t]),e.unshift([n,r])}return e}load(e){this.clear();for(const[t,n]of e){if(n.start){const e=Date.now()-n.start;n.start=s.now()-e}this.set(t,n.value,n)}}set(e,t,n={}){if(void 0===t)return this.delete(e),this;const{ttl:i=this.ttl,start:o,noDisposeOnSet:s=this.noDisposeOnSet,sizeCalculation:r=this.sizeCalculation,status:a}=n;let{noUpdateTTL:l=this.noUpdateTTL}=n;const c=this.#k(e,t,n.size||0,r);if(this.maxEntrySize&&c>this.maxEntrySize)return a&&(a.set="miss",a.maxEntrySizeExceeded=!0),this.#R(e,"set"),this;let u=0===this.#a?void 0:this.#c.get(e);if(void 0===u)u=0===this.#a?this.#g:0!==this.#f.length?this.#f.pop():this.#a===this.#t?this.#D(!1):this.#a,this.#u[u]=e,this.#h[u]=t,this.#c.set(e,u),this.#d[this.#g]=u,this.#p[u]=this.#g,this.#g=u,this.#a++,this.#F(u,c,a),a&&(a.set="add"),l=!1;else{this.#M(u);const n=this.#h[u];if(t!==n){if(this.#C&&this.#S(n)){n.__abortController.abort(new Error("replaced"));const{__staleWhileFetching:t}=n;void 0===t||s||(this.#A&&this.#i?.(t,e,"set"),this.#T&&this.#y?.push([t,e,"set"]))}else s||(this.#A&&this.#i?.(n,e,"set"),this.#T&&this.#y?.push([n,e,"set"]));if(this.#H(u),this.#F(u,c,a),this.#h[u]=t,a){a.set="replace";const e=n&&this.#S(n)?n.__staleWhileFetching:n;void 0!==e&&(a.oldValue=e)}}else a&&(a.set="update")}if(0===i||this.#v||this.#P(),this.#v&&(l||this.#N(u,i,o),a&&this.#O(a,u)),!s&&this.#T&&this.#y){const e=this.#y;let t;for(;t=e?.shift();)this.#o?.(...t)}return this}pop(){try{for(;this.#a;){const e=this.#h[this.#m];if(this.#D(!0),this.#S(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(void 0!==e)return e}}finally{if(this.#T&&this.#y){const e=this.#y;let t;for(;t=e?.shift();)this.#o?.(...t)}}}#D(e){const t=this.#m,n=this.#u[t],i=this.#h[t];return this.#C&&this.#S(i)?i.__abortController.abort(new Error("evicted")):(this.#A||this.#T)&&(this.#A&&this.#i?.(i,n,"evict"),this.#T&&this.#y?.push([i,n,"evict"])),this.#H(t),e&&(this.#u[t]=void 0,this.#h[t]=void 0,this.#f.push(t)),1===this.#a?(this.#m=this.#g=0,this.#f.length=0):this.#m=this.#d[t],this.#c.delete(n),this.#a--,t}has(e,t={}){const{updateAgeOnHas:n=this.updateAgeOnHas,status:i}=t,o=this.#c.get(e);if(void 0!==o){const e=this.#h[o];if(this.#S(e)&&void 0===e.__staleWhileFetching)return!1;if(!this.#_(o))return n&&this.#$(o),i&&(i.has="hit",this.#O(i,o)),!0;i&&(i.has="stale",this.#O(i,o))}else i&&(i.has="miss");return!1}peek(e,t={}){const{allowStale:n=this.allowStale}=t,i=this.#c.get(e);if(void 0===i||!n&&this.#_(i))return;const o=this.#h[i];return this.#S(o)?o.__staleWhileFetching:o}#E(e,t,n,i){const o=void 0===t?void 0:this.#h[t];if(this.#S(o))return o;const s=new c,{signal:r}=n;r?.addEventListener("abort",(()=>s.abort(r.reason)),{signal:s.signal});const a={signal:s.signal,options:n,context:i},l=(i,o=!1)=>{const{aborted:r}=s.signal,l=n.ignoreFetchAbort&&void 0!==i;if(n.status&&(r&&!o?(n.status.fetchAborted=!0,n.status.fetchError=s.signal.reason,l&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),r&&!l&&!o)return u(s.signal.reason);const c=h;return this.#h[t]===h&&(void 0===i?c.__staleWhileFetching?this.#h[t]=c.__staleWhileFetching:this.#R(e,"fetch"):(n.status&&(n.status.fetchUpdated=!0),this.set(e,i,a.options))),i},u=i=>{const{aborted:o}=s.signal,r=o&&n.allowStaleOnFetchAbort,a=r||n.allowStaleOnFetchRejection,l=a||n.noDeleteOnFetchRejection,c=h;if(this.#h[t]===h&&(l&&void 0!==c.__staleWhileFetching?r||(this.#h[t]=c.__staleWhileFetching):this.#R(e,"fetch")),a)return n.status&&void 0!==c.__staleWhileFetching&&(n.status.returnedStale=!0),c.__staleWhileFetching;if(c.__returned===c)throw i};n.status&&(n.status.fetchDispatched=!0);const h=new Promise(((t,i)=>{const r=this.#s?.(e,o,a);r&&r instanceof Promise&&r.then((e=>t(void 0===e?void 0:e)),i),s.signal.addEventListener("abort",(()=>{n.ignoreFetchAbort&&!n.allowStaleOnFetchAbort||(t(void 0),n.allowStaleOnFetchAbort&&(t=e=>l(e,!0)))}))})).then(l,(e=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=e),u(e)))),d=Object.assign(h,{__abortController:s,__staleWhileFetching:o,__returned:void 0});return void 0===t?(this.set(e,d,{...a.options,status:void 0}),t=this.#c.get(e)):this.#h[t]=d,d}#S(e){if(!this.#C)return!1;const t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof c}async fetch(e,t={}){const{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:s=this.ttl,noDisposeOnSet:r=this.noDisposeOnSet,size:a=0,sizeCalculation:l=this.sizeCalculation,noUpdateTTL:c=this.noUpdateTTL,noDeleteOnFetchRejection:u=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:h=this.allowStaleOnFetchRejection,ignoreFetchAbort:d=this.ignoreFetchAbort,allowStaleOnFetchAbort:p=this.allowStaleOnFetchAbort,context:m,forceRefresh:g=!1,status:f,signal:y}=t;if(!this.#C)return f&&(f.fetch="get"),this.get(e,{allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:o,status:f});const b={allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:o,ttl:s,noDisposeOnSet:r,size:a,sizeCalculation:l,noUpdateTTL:c,noDeleteOnFetchRejection:u,allowStaleOnFetchRejection:h,allowStaleOnFetchAbort:p,ignoreFetchAbort:d,status:f,signal:y};let w=this.#c.get(e);if(void 0===w){f&&(f.fetch="miss");const t=this.#E(e,w,b,m);return t.__returned=t}{const t=this.#h[w];if(this.#S(t)){const e=n&&void 0!==t.__staleWhileFetching;return f&&(f.fetch="inflight",e&&(f.returnedStale=!0)),e?t.__staleWhileFetching:t.__returned=t}const o=this.#_(w);if(!g&&!o)return f&&(f.fetch="hit"),this.#M(w),i&&this.#$(w),f&&this.#O(f,w),t;const s=this.#E(e,w,b,m),r=void 0!==s.__staleWhileFetching&&n;return f&&(f.fetch=o?"stale":"refresh",r&&o&&(f.returnedStale=!0)),r?s.__staleWhileFetching:s.__returned=s}}async forceFetch(e,t={}){const n=await this.fetch(e,t);if(void 0===n)throw new Error("fetch() returned undefined");return n}memo(e,t={}){const n=this.#r;if(!n)throw new Error("no memoMethod provided to constructor");const{context:i,forceRefresh:o,...s}=t,r=this.get(e,s);if(!o&&void 0!==r)return r;const a=n(e,r,{options:s,context:i});return this.set(e,a,s),a}get(e,t={}){const{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:s}=t,r=this.#c.get(e);if(void 0!==r){const t=this.#h[r],a=this.#S(t);return s&&this.#O(s,r),this.#_(r)?(s&&(s.get="stale"),a?(s&&n&&void 0!==t.__staleWhileFetching&&(s.returnedStale=!0),n?t.__staleWhileFetching:void 0):(o||this.#R(e,"expire"),s&&n&&(s.returnedStale=!0),n?t:void 0)):(s&&(s.get="hit"),a?t.__staleWhileFetching:(this.#M(r),i&&this.#$(r),t))}s&&(s.get="miss")}#B(e,t){this.#p[t]=e,this.#d[e]=t}#M(e){e!==this.#g&&(e===this.#m?this.#m=this.#d[e]:this.#B(this.#p[e],this.#d[e]),this.#B(this.#g,e),this.#g=e)}delete(e){return this.#R(e,"delete")}#R(e,t){let n=!1;if(0!==this.#a){const i=this.#c.get(e);if(void 0!==i)if(n=!0,1===this.#a)this.#V(t);else{this.#H(i);const n=this.#h[i];if(this.#S(n)?n.__abortController.abort(new Error("deleted")):(this.#A||this.#T)&&(this.#A&&this.#i?.(n,e,t),this.#T&&this.#y?.push([n,e,t])),this.#c.delete(e),this.#u[i]=void 0,this.#h[i]=void 0,i===this.#g)this.#g=this.#p[i];else if(i===this.#m)this.#m=this.#d[i];else{const e=this.#p[i];this.#d[e]=this.#d[i];const t=this.#d[i];this.#p[t]=this.#p[i]}this.#a--,this.#f.push(i)}}if(this.#T&&this.#y?.length){const e=this.#y;let t;for(;t=e?.shift();)this.#o?.(...t)}return n}clear(){return this.#V("delete")}#V(e){for(const t of this.#L({allowStale:!0})){const n=this.#h[t];if(this.#S(n))n.__abortController.abort(new Error("deleted"));else{const i=this.#u[t];this.#A&&this.#i?.(n,i,e),this.#T&&this.#y?.push([n,i,e])}}if(this.#c.clear(),this.#h.fill(void 0),this.#u.fill(void 0),this.#v&&this.#w&&(this.#v.fill(0),this.#w.fill(0)),this.#b&&this.#b.fill(0),this.#m=0,this.#g=0,this.#f.length=0,this.#l=0,this.#a=0,this.#T&&this.#y){const e=this.#y;let t;for(;t=e?.shift();)this.#o?.(...t)}}}function f(e){window.$monomerHover=e}var y=n(2003),b=n(6077),w=n(3561),v=n(9235);const A="MonomerHoverLinks";async function C(e,t,n,i,s,r=!1){const a=i.getSeqHandler(e),l=a.alphabet==y.YI.RNA||a.alphabet==y.YI.DNA,c=a.isHelm()&&l,u=!a.isHelm()&&l,h=e=>null==e?null:c?r?e:Math.floor(e/3):u&&r?3*e+1:e,d=r?await i.getHelmToMolfileConverter(n):null,p=new g({max:100});function m(e,t){const a=e.get(t);if(null==a)return null;let l=p.get(a);return l||p.set(a,l=function(e,t){const a=i.getSeqHandler(e);if(r){const e=a.getHelm(t);return i.helmToAtomicLevelSingle(e,d,!1,!1).monomers}{const e=a.getSplitted(t),i=a.defaultBiotype,r=o().count(0).take(e.length).map((t=>({position:t,symbol:e.getCanonical(t),biotype:i}))).toArray(),l=a.alphabet,c=l==y.YI.RNA||l==y.YI.DNA?"RNA":"PEPTIDE",u=(0,b.eM)([r],c,l,n,s);return(0,w.gU)(r,u,l,c).monomers}}(e,t)),l}const C={targetCol:t,handler:(t,i,o)=>{const s=o.grid,r=t.tableRowIndex,a=t.gridRow,l=s.cell(o.name,a),c=null!==(u=window.$monomerHover)&&void 0!==u?u:null;var u;if(!c||c&&(c.dataFrameId!=e.dataFrame.id||c.gridRowIdx!=a||c.seqColName!=e.name||c.seqPosition!=i?.position)){if(c&&(f(null),c.gridCell.render()),!i)return f(null),!0;f({gridCell:l,dataFrameId:e.dataFrame.id,gridRowIdx:a,seqColName:e.name,seqPosition:h(i?.position)??-1,getSubstruct:()=>{if(!i||"*"===i.symbol)return;const t=m(e,r);if(!t)return;const o=t.get(h(i?.position));return o?(0,v.H)([o],n):{atoms:[],bonds:[],highlightAtomColors:[],highlightBondColors:[]}}}),l.render()}return!0},getSubstruct:i=>{if("true"!=t.getTag(".sequence-src-highlight-monomers"))return;if(null==i)return;if(!e.get(i))return;const o=m(e,i);return o?(0,v.H)(o.values(),n):void 0}};return function(e,t){let n=e[A];n||(n=e[A]=[]),n.push(t),e[A]=n}(e.temp,C),function(e,t){let n=e["substruct-providers"];n||(n=e["substruct-providers"]=[]),n.push(t),e["substruct-providers"]=n}(t.temp,C),C}function T(e,t){try{const n=e.tableColumn;if(!n)return;const i=function(e){return e.temp[A]??[]}(n);for(let n=i.length-1;n>=0;--n){const o=i[n],s=e.grid.col(o.targetCol.name);if(s&&!o.handler(e,t,s))break}}catch(e){console.error(e)}}},6718:(e,t,n)=>{"use strict";n.d(t,{A7:()=>p,pj:()=>u,uL:()=>h,uX:()=>c});var i=n(6082),o=n(4328),s=n(6295),r=n(3151),a=n(3077),l=n(439);function c(e){const t=[];for(let n=0;n<e.rowCount;n++){const i={};Object.keys(r.Ec).forEach((t=>{if("symbol"===t){const o=e.get(r.Ec[t],n);i[t]="."===o?e.get(r.yw,n):o}else if("rgroups"===t){const o=e.get(r.Ec[t],n).split("\n"),s=[];o.forEach((e=>{const t={},n=e.substring(e.lastIndexOf("]")+1),i=e.match(/\[R(\d+)\]/)[1];t.capGroupSmiles="H"===n?`[*:${i}][H]`:`O[*:${i}]`,t.alternateId="H"===n?`R${i}-H`:`R${i}-OH`,t.capGroupName="H"===n?"H":"OH",t.label=`R${i}`,s.push(t)})),i[t]=s}else r.Ec[t]&&(i[t]=e.get(r.Ec[t],n))})),i.author??(i.author=""),i.id??(i.id=0),i.smiles??(i.smiles=""),i.monomerType??(i.monomerType="Backbone"),i.createDate??(i.createDate=null),t.push(i)}return t}async function u(){const e=i.Func.find({package:"Bio",name:"getMonomerLibHelper"});if(0===e.length)throw new Error('Package "Bio" must be installed for MonomerLibHelper.');return(await e[0].prepare().call()).getOutputParamValue()}async function h(e,t,n){e instanceof i.Column&&(e=(0,a.R)(e,n).columns.toList());const s=(await u()).getMonomerLib(),r=new Array(e.length),c=e[0].length,h=new Float32Array(c);for(let n=0;n<e.length;++n){const a=n<t.length?t.getCanonical(n):l._S,u=s.getMonomer("PEPTIDE",a)?.smiles??"",d=e[n],p=d.getRawData(),m=d.categories,g=m.indexOf("");if(r[n]={categories:m,data:p,emptyIndex:g},void 0===a)continue;const f=i.Column.fromStrings("smiles",m.map((e=>s.getMonomer("PEPTIDE",e)?.smiles??""))),y=(i.DataFrame.fromColumns([f]),await o.chem.getSimilarities(f,u)),b=y?y.getRawData():null;for(let e=0;e<c;++e){const t=p[e];a!==l._S&&t!==g?h[e]+=b[t]:a===l._S&&t===g&&(h[e]+=1)}}for(let n=0;n<h.length;++n){let o=h[n]/t.length;for(let s=0;s<e.length;++s){const e=r[s];if(s>=t.length&&e.data[n]!==e.emptyIndex||e.data[n]===e.emptyIndex&&s<t.length){o=i.FLOAT_NULL;break}}h[n]=o}return i.Column.fromFloat32Array("Similarity",h)}async function d(e){const t=(await u()).getMonomerLib(),n=[],s={},r=e.map((e=>t.getMonomer("PEPTIDE",e)?.smiles??"")),a=i.Column.fromStrings("smiles",r);for(let t=0;t<r.length;++t){s[e[t]]=t;const i=r[t],l=""===i?new Array(r.length).fill(0):(await o.chem.getSimilarities(a,i)).getRawData();l[t]=1,n[t]=Array.from(l)}return{scoringMatrix:n,alphabetIndexes:s}}async function p(e,t="Morgan"){const n=(await u()).getMonomerLib(),o=new Array(e.length).fill(0).map((()=>new Array(e.length).fill(0))),r={},a=e.map((e=>n.getMonomer("PEPTIDE",e)?.molfile||n.getMonomer("PEPTIDE",e)?.smiles||"")),l=i.Func.find({package:"Chem",name:"getFingerprints"})[0];if(!l)return console.warn('Function "Chem:getFingerprints" is not found in chem package. falling back to Morgan fingerprints'),await d(e);const c=i.Column.fromStrings("smiles",a),h=(i.DataFrame.fromColumns([c]),(await l.apply({col:c,fingerprintType:t}))?.entries);if(!h)return console.warn(`${t} Fingerprints could not be calculated for monomers from chem package.\n falling back to Morgan fingerprints`),await d(e);for(let t=0;t<h.length;++t)if(o[t][t]=1,r[e[t]]=t,h[t])for(let e=t+1;e<h.length;++e)h[e]&&(o[t][e]=o[e][t]=(0,s.$1)(h[t],h[e]));return{scoringMatrix:o,alphabetIndexes:r}}},6197:(e,t,n)=>{"use strict";n.d(t,{Y:()=>o});var i=n(3599);function o(e){let t;switch(e){case i.o.BASE:case i.o.SUGAR:case i.o.LINKER:case i.o.NUCLEOTIDE:case"nucleotide":t="RNA";break;case i.o.AA:t="PEPTIDE";break;case i.o.CHEM:t="CHEM";break;case i.o.BLOB:t="BLOB";break;default:t="PEPTIDE",console.warn(`Unexpected HelmType '${e}'`)}return t}},9235:(e,t,n)=>{"use strict";n.d(t,{H:()=>c,R:()=>l});var i=n(6082),o=n(1991),s=n.n(o),r=n(330),a=n(3599);async function l(e,t,o,l,c,u,h){const d=e.length,p=e.dataFrame,m=Math.max(navigator.hardwareConcurrency-2,1),g=new Array(m).fill(null).map((()=>new Worker(new URL(n.p+n.u(455),n.b)))),f=d/m,y=new Array(m),b=u.getSeqHandler(e),w="RNA"==l?a.o.NUCLEOTIDE:a.o.AA,v=s().count(0).take(e.length).map((e=>{const t=b.getSplitted(e);return s().count(0).take(t.length).map((e=>({position:e,symbol:t.getCanonical(e),biotype:w}))).toArray()})).toArray();for(let e=0;e<m;e++){const n=g[e],i=Math.floor(e*f),s=e===m-1?d:Math.floor((e+1)*f);y[e]=new Promise((e=>{n.onmessage=t=>{e(t.data)}})),n.postMessage({seqList:v,monomersDict:t,alphabet:o,polymerType:l,start:i,end:s})}const A=[],C=[];await Promise.all(y).then((e=>{for(const t of e)A.push(...t.molfiles),C.push(...t.warnings)})),setTimeout((()=>{g.forEach((e=>{e.terminate()}))}),0);const T=(0,r.qj)(p,e.name),S=i.Column.fromType(i.COLUMN_TYPE.STRING,T,e.length).init((e=>A[e]?.molfile));return S.semType=i.SEMTYPE.MOLECULE,S.meta.units=i.UNITS.Molecule.MOLBLOCK,S.setTag(".sequence-src-col",e.name),{molCol:S,warnings:C}}function c(e,t){const n={},o={};for(const s of e){const e=t.getWebEditorMonomer(s.biotype,s.symbol).backgroundcolor,a=(0,r.vG)(e??i.Color.toRgb(i.Color.mouseOverRows))??[1,0,0,.7];for(const e of s.atoms)n[e]=a;for(const e of s.bonds)o[e]=a}return{atoms:Object.keys(n).map((e=>parseInt(e))),bonds:Object.keys(o).map((e=>parseInt(e))),highlightAtomColors:n,highlightBondColors:o}}},3561:(e,t,n)=>{"use strict";n.d(t,{Hb:()=>l,YN:()=>g,gU:()=>c});var i=n(8123),o=n(294),s=n(3151),r=n(439),a=n(6197);function l(e,t,n){const o=new Map;for(const a of e.getMonomerSymbolsByType(t)){const l=e.getMonomer(t,a);if("RNA"===t&&("Branch"===l.monomerType||n===r.YI.DNA&&l.symbol===i.u.DEOXYRIBOSE.symbol||n===r.YI.RNA&&l.symbol===i.u.RIBOSE.symbol||l.symbol===i.u.PHOSPHATE.symbol)||"PEPTIDE"===t&&"Branch"!==l.monomerType){const e={};s.f6.forEach((t=>{e[t]=l[t]})),o.set(l.symbol,e)}}return o}function c(e,t,n,s){if(0===e.length)return o.vF.createEmpty();const l=m,{atomCount:c,bondCount:h,needsCapping:p}=l(e,t,n,s),f=new Array(c),y=new Array(h);let b,w=null,v=null;"PEPTIDE"===s?b=u:(b=d,w=n===r.YI.DNA?(0,o.xb)(t,i.u.DEOXYRIBOSE):(0,o.xb)(t,i.u.RIBOSE),v=(0,o.xb)(t,i.u.PHOSPHATE));const A={i:0,nodeShift:0,bondShift:0,backbonePositionShift:new Array(2).fill(0),branchPositionShift:new Array(2).fill(0),backboneAttachNode:0,branchAttachNode:0,flipFactor:1},C={sugar:w,phosphate:v,seqLength:e.length,atomCount:c,bondCount:h},T=new o.Cg,S=[];let E,M=0;for(A.i=0;A.i<C.seqLength;++A.i){const n=e[A.i];if(n.symbol===r._S)continue;const i=(0,o.xb)(t,{symbol:n.symbol,polymerType:(0,a.Y)(n.biotype)});E=i.terminalR2Atom;const s=A.nodeShift,l=A.bondShift;b(i,f,y,A,C),i.stereoAtoms?.forEach((e=>S.push(e+M))),M+=i.atoms.x.length;const c=A.nodeShift-s,u=new Array(c);for(let e=0;e<c;++e)u[e]=s+e;const h=A.bondShift-l,d=new Array(h);for(let e=0;e<h;++e)d[e]=l+e;T.set(A.i,{biotype:n.biotype,symbol:n.symbol,atoms:u,bonds:d})}p&&function(e,t,n,o,s=i.u.OXYGEN){const r=n.nodeShift+1;e[o.atomCount]=i.u.V3K_BEGIN_DATA_LINE+r+" "+(s??i.u.OXYGEN)+" "+g(n.backbonePositionShift[0])+" "+n.flipFactor*g(n.backbonePositionShift[1])+" 0.000000 0\n";const a=n.backboneAttachNode,l=r;t[o.bondCount]=i.u.V3K_BEGIN_DATA_LINE+n.bondShift+" 1 "+a+" "+l+"\n"}(f,y,A,C,E??i.u.OXYGEN);const x=i.u.V3K_BEGIN_COUNTS_LINE+c+" "+h+i.u.V3K_COUNTS_LINE_ENDING;let L="";return L+=i.u.V3K_HEADER_FIRST_LINE,L+=i.u.V3K_HEADER_SECOND_LINE,L+=i.u.V3K_BEGIN_CTAB_BLOCK,L+=x,L+=i.u.V3K_BEGIN_ATOM_BLOCK,L+=f.join(""),L+=i.u.V3K_END_ATOM_BLOCK,L+=i.u.V3K_BEGIN_BOND_BLOCK,L+=y.join(""),L+=i.u.V3K_END_BOND_BLOCK,S.length>0&&(L+=function(e){const t=[];let n=`M V30 MDLV30/STEABS ATOMS=(${e.length}`;for(let i=0;i<e.length;i++){const o=`${n} ${e[i]}`;o.length>76?(t.push(`${n} -\n`),n=`M V30 ${e[i]}`):n=o,i===e.length-1&&t.push(`${n})\n`)}return`M V30 BEGIN COLLECTION\n${t.join("")}M V30 END COLLECTION\n`}(S)),L+=i.u.V3K_END_CTAB_BLOCK,L+=i.u.V3K_END,{molfile:L,monomers:T}}function u(e,t,n,i){i.flipFactor=(-1)**(i.i%2),h(e,t,n,i)}function h(e,t,n,o){!function(e,t,n){for(let o=0;o<e.atoms.atomTypes.length;++o){const s=n.nodeShift+o+1;t[n.nodeShift+o]=i.u.V3K_BEGIN_DATA_LINE+s+" "+e.atoms.atomTypes[o]+" "+g(n.backbonePositionShift[0]+e.atoms.x[o])+" "+g(n.backbonePositionShift[1]+n.flipFactor*e.atoms.y[o])+" "+e.atoms.kwargs[o]}}(e,t,o),p(e,n,o),function(e,t,n){if(0!==n.backboneAttachNode){const o=n.bondShift,s=n.backboneAttachNode,r=e.meta.terminalNodes[0]+n.nodeShift;t[n.bondShift-1]=i.u.V3K_BEGIN_DATA_LINE+o+" 1 "+s+" "+r+"\n"}}(e,n,o),null!==e.meta.branchShift&&e.meta.terminalNodes.length>2&&function(e,t){t.branchAttachNode=t.nodeShift+e.meta.terminalNodes[2];for(let n=0;n<2;++n)t.branchPositionShift[n]=t.backbonePositionShift[n]+e.meta.branchShift[n]}(e,o),function(e,t){t.backboneAttachNode=t.nodeShift+e.meta.terminalNodes[1],t.bondShift+=e.bonds.atomPairs.length+1,t.nodeShift+=e.atoms.atomTypes.length,t.backbonePositionShift[0]+=e.meta.backboneShift?.[0]??0,t.backbonePositionShift[1]+=t.flipFactor*(e.meta.backboneShift?.[1]??0)}(e,o)}function d(e,t,n,o,s){if(0===o.i)h(s.sugar,t,n,o);else for(const e of[s.phosphate,s.sugar])h(e,t,n,o);!function(e,t,n,o){(function(e,t,n){for(let o=0;o<e.atoms.atomTypes.length;++o){const s=n.nodeShift+o+1;t[n.nodeShift+o]=i.u.V3K_BEGIN_DATA_LINE+s+" "+e.atoms.atomTypes[o]+" "+g(n.branchPositionShift[0]+e.atoms.x[o])+" "+g(n.branchPositionShift[1]+n.flipFactor*e.atoms.y[o])+" "+e.atoms.kwargs[o]}})(e,t,o),p(e,n,o),function(e,t,n){const o=n.bondShift,s=n.branchAttachNode,r=e.meta.terminalNodes[0]+n.nodeShift;t[o-1]=i.u.V3K_BEGIN_DATA_LINE+o+" 1 "+s+" "+r+"\n"}(e,n,o);const s=o.bondShift,r=o.branchAttachNode,a=e.meta.terminalNodes[0]+o.nodeShift;n[s-1]=i.u.V3K_BEGIN_DATA_LINE+s+" 1 "+r+" "+a+"\n",o.bondShift+=e.bonds.atomPairs.length+1,o.nodeShift+=e.atoms.atomTypes.length}(e,t,n,o)}function p(e,t,n){for(let o=0;o<e.bonds.atomPairs.length;++o){const s=n.bondShift+o+1,r=e.bonds.atomPairs[o][0]+n.nodeShift,a=e.bonds.atomPairs[o][1]+n.nodeShift;let l="";if(e.bonds.bondConfiguration.has(o)){let t=e.bonds.bondConfiguration.get(o);n.flipFactor<0&&(t=1===t?3:1),l=" CFG="+t}const c=e.bonds.kwargs.has(o)?" "+e.bonds.kwargs.get(o):"";t[n.bondShift+o]=i.u.V3K_BEGIN_DATA_LINE+s+" "+e.bonds.bondTypes[o]+" "+r+" "+a+l+c+"\n"}}function m(e,t,n,s){let l=0,c=0,u=0,h=!0,d=null;for(const n of e)if(n.symbol!==r._S){if("*"==n.symbol)throw new Error("Gap canonical symbol is '', not '*");d=(0,o.xb)(t,{symbol:n.symbol,polymerType:(0,a.Y)(n.biotype)}),l+=d.atoms.x.length,c+=d.bonds.bondTypes.length,u++}if("PEPTIDE"===s)l+=1,c+=u,u>0&&((d?.meta?.rNodes?.length??0)<2||d?.terminalR2Atom?.toLowerCase()===i.u.HYDROGEN.toLowerCase())&&(h=!1,l-=1,c-=1);else{const s=n===r.YI.DNA?(0,o.xb)(t,i.u.DEOXYRIBOSE):(0,o.xb)(t,i.u.RIBOSE),a=(0,o.xb)(t,i.u.PHOSPHATE);l+=(e.length-1)*a.atoms.x.length,l+=e.length*s.atoms.x.length,l+=1,c+=(e.length-1)*a.bonds.bondTypes.length,c+=e.length*s.bonds.bondTypes.length,c-=1,c+=3*e.length}return{atomCount:l,bondCount:c,needsCapping:h}}function g(e){return Math.round(i.u.PRECISION_FACTOR*e)/i.u.PRECISION_FACTOR}},6077:(e,t,n)=>{"use strict";n.d(t,{C4:()=>m,eM:()=>g});var i=n(4328),o=n(6082),s=n(1991),r=n.n(s),a=n(439),l=n(3561),c=n(9235),u=n(294),h=n(9192),d=n(330),p=n(8123);async function m(e,t,n,s,l){if(t.semType!==o.SEMTYPE.MACROMOLECULE)return{molCol:null,warnings:[`Only the ${o.SEMTYPE.MACROMOLECULE} columns can be converted to atomic level, the chosen column has semType '${t.semType}'`]};let u=t;const p=s.getSeqHandler(t);let m,f;p.notation!==a.Hi.SEPARATOR&&(u=p.convert(a.Hi.SEPARATOR,"."),u.name=t.name);try{f=s.getSeqHandler(u).alphabet,m=(0,d.pz)(f)}catch(e){const[t,n]=(0,h.AP)(e);return{molCol:null,warnings:[t]}}const y=function(e,t){const n=e.length,o=new Array(n),s=t.getSeqHandler(e);let a=!1;const l=s.defaultBiotype;for(let e=0;e<n;++e){const t=s.getSplitted(e);a||(a=0===t.length),o[e]=r().count(0).take(t.length).filter((e=>!t.isGap(e))).map((e=>({position:e,biotype:l,symbol:t.getCanonical(e)}))).toArray()}return a&&i.shell.warning(`Some values in the "${e.name}" column are empty`),o}(u,s),b=g(y,m,f,n,l),w=u.length,v=await(0,c.R)(u,b,f,m,n,s,l);v.warnings.length>.05*w&&i.shell.warning(`Molfile conversion resulted in ${v.warnings.length} errors`);const A=o.Func.find({name:"convertToV3KViaOCL"})[0];if(A&&v.molCol)try{const e=v.molCol.toList(),t=await A.apply({mols:e});v.molCol.init((n=>t[n]?t[n]:e[n]))}catch(e){console.error(e)}return v}function g(e,t,n,i,o){const s=(0,l.Hb)(i,t,n),r={},c={value:null};if("RNA"===t){const e=n===a.YI.RNA?[p.u.RIBOSE,p.u.PHOSPHATE]:[p.u.DEOXYRIBOSE,p.u.PHOSPHATE];for(const n of e)f(r,n.symbol,s,o,t,c)}for(let n=0;n<e.length;++n){const i=e[n];for(const e of i){const n=e.symbol;if(""!==n)try{if("RNA"===t&&3===n.split(/\(|\)/).filter((e=>!!e)).length){const e=n.split(/\(|\)/)[1];f(r,e,s,o,t,c),r[t]?.[e]&&(r[t][n]=r[t][e])}else f(r,n,s,o,t,c)}catch(e){const t=e instanceof Error?e.message:e.toString(),i=e instanceof Error?e.stack:void 0;throw console.error(`bio lib: getMonomersDictFromLib() sym='${n}', error:\n${t}\n${i}`),new Error(`Can't get monomer '${n}' from library: ${t}`)}}}return r}function f(e,t,n,i,o,s){const r={polymerType:o,symbol:t};if(!(0,u.bq)(e,r)){const a=function(e,t,n,i,o){if(t.has(e)){const r=t.get(e),a=function(e){const t=[];for(const n of e){let e=n.capGroupSmiles;e||(e=n.capGroupSMILES),e=e.replace(/(\[|\]|\*|:|\d)/g,"").replace("OH","O").replace("Oh","O"),t.push(e)}return t}(r.rgroups),c=(s=r.molfile).includes("V3000")?function(e){const t=new Map,n=/M V30 (\d+) R#.+RGROUPS=\((\d+) (\d+)\).*/gm;let i;for(;null!==(i=n.exec(e));)i.index===n.lastIndex&&n.lastIndex++,t.set(parseInt(i[1]),parseInt(i[3]));return t}(s):function(e){const t=new Map;let n=e.indexOf(p.u.V2K_A_LINE,0),i=n;for(;-1!==n;){i=e.indexOf("\n",n);const o=parseInt(e.substring(n,i).replace(/^A\s+/,""));n=e.indexOf("R",i),i=e.indexOf("\n",n);const s=parseInt(e.substring(n,i).replace(/^R/,""));t.set(o,s),n=e.indexOf(p.u.V2K_A_LINE,i)}for(n=e.indexOf(p.u.V2K_RGP_LINE,0),i=e.indexOf("\n",n);-1!==n;){n+=p.u.V2K_RGP_SHIFT,i=e.indexOf("\n",n);const o=e.substring(n,i).replaceAll(/\s+/g," ").split(" ").map((e=>parseInt(e))).slice(1);for(let e=0;e<o.length;e+=2){if(t.has(o[e])&&t.get(o[e])!==o[e+1])throw new Error(`r-group index ${o[e]} has already been added with a different value`);t.set(o[e],o[e+1])}n=e.indexOf(p.u.V2K_RGP_LINE,i)}return t}(s),u=r.molfile.includes("V3000")?r.molfile:function(e,t){const n=t.get_mol(function(e){return e.split("\n").map((e=>{const t=e.indexOf(" R# "),n=e.indexOf(" R ");if(-1===t&&-1===n)return e;const i=-1!==t?t:n,o=e.split("");for(let e=i+5;e<o.length;e++)" "!==o[e]&&(o[e]="0");return o.join("")})).join("\n")}(e)),i=n.get_v3Kmolblock();return n.delete(),i}(function(e){let t=e.indexOf(p.u.V2K_A_LINE,0);-1===t&&(t=e.indexOf(p.u.V2K_RGP_LINE));const n=e.indexOf(p.u.V3K_END,t);return e.substring(0,t)+e.substring(n)}(r.molfile),n),h=function(e){let t=(e=e.replaceAll("\r","")).indexOf(p.u.V3K_BEGIN_COUNTS_LINE)+p.u.V3K_COUNTS_SHIFT,n=e.indexOf(" ",t+1);const i=parseInt(e.substring(t,n));return t=n+1,n=e.indexOf(" ",t+1),{atomCount:i,bondCount:parseInt(e.substring(t,n))}}(u),d=function(e,t){const n=new Array(t),i=new Float32Array(t),o=new Float32Array(t),s=new Array(t);let r=e.indexOf(p.u.V3K_BEGIN_ATOM_BLOCK);r=e.indexOf("\n",r);let a=r;for(let l=0;l<t;l++){r=e.indexOf(p.u.V3K_BEGIN_DATA_LINE,r)+p.u.V3K_IDX_SHIFT,a=e.indexOf(" ",r),r=a+1,a=e.indexOf(" ",r),n[l]=e.substring(r,a);const t=new Array(2);for(let n=0;n<2;++n)r=a+1,a=e.indexOf(" ",r),t[n]=parseFloat(e.substring(r,a));i[l]=t[0],o[l]=t[1],r=a,a=e.indexOf("\n",r)+1,s[l]=e.slice(r,a),r=a}return{atomTypes:n,x:i,y:o,kwargs:s}}(u,h.atomCount),m=function(e,t){const n=new Uint32Array(t),i=new Array(t),o=new Map,s=new Map;let r=e.indexOf(p.u.V3K_BEGIN_BOND_BLOCK);r=e.indexOf("\n",r);let a=r;for(let l=0;l<t;++l){const t=new Array(3);r=e.indexOf(p.u.V3K_BEGIN_DATA_LINE,a)+p.u.V3K_IDX_SHIFT,a=e.indexOf(" ",r);for(let n=0;n<3;++n)r=a+1,a=Math.min(e.indexOf("\n",r),e.indexOf(" ",r)),t[n]=parseInt(e.slice(r,a));n[l]=t[0],i[l]=t.slice(1);const c=e.indexOf("\n",r);let u=e.slice(a,c),h=u.indexOf(p.u.V3K_BOND_CONFIG);if(-1!==h){h=u.indexOf("=",h)+1;let e=u.indexOf(" ",h);-1===e&&(e=u.length);const t=parseInt(u.slice(h,e));o.set(l,t);const n=p.u.V3K_BOND_CONFIG+t.toString();u=u.replace(n,"")}u||s.set(l,u)}return{bondTypes:n,atomPairs:i,bondConfiguration:o,kwargs:s}}(u,h.bondCount),g=function(e,t,n,i){const o={backboneShift:null,branchShift:null,terminalNodes:[],rNodes:[]};if(n&&i&&[1,2].some((e=>!Array.from(i.values()).find((t=>t==e))))){const o=[1,2].find((e=>!Array.from(i.values()).find((t=>t==e)))),s=[1,2].find((e=>Array.from(i.values()).find((t=>t==e)))),r=Array.from(i.keys()).find((e=>i.get(e)===s))-1,a=e.x[r],l=e.y[r],c=t.atomPairs.find((e=>e.includes(r+1))).find((e=>e!==r+1))-1;let u=e.x.reduce(((t,n,i)=>{if(i===r)return t;if(i===c)return t;const o=e.y[i];return Math.sqrt((n-a)**2+(o-l)**2)>Math.sqrt((e.x[t]-a)**2+(e.y[t]-l)**2)?i:t}),-1);if(-1===u&&(u=e.x.length,e.x=new Float32Array([...e.x,-a]),e.y=new Float32Array([...e.y,-l]),e.atomTypes=[...e.atomTypes,"H"],e.kwargs=[...e.kwargs,""],t.atomPairs.push([c+1,u+1]),t.bondTypes=new Uint32Array([...t.bondTypes,1]),t.kwargs.set(t.atomPairs.length-1,"")),i.set(u+1,o),1===o)n.unshift(e.atomTypes[u]);else{if(2!==o)throw new Error(`Unexpected missing R-group: ${o}`);n.splice(1,0,e.atomTypes[u])}}return function(e,t,n){for(const[i,o]of n)e.atomTypes[i-1]=t[o-1]}(e,n,i),function(e,t){t.rNodes=Array.from(e.keys());for(let n=0;n<t.rNodes.length;n++)for(const i of[1,2])if(e.get(t.rNodes[n])===i){const e=t.rNodes[i-1];t.rNodes[i-1]=t.rNodes[n],t.rNodes[n]=e}}(i,o),y(t,o),o}(d,m,a,c),f=function(e){let t=[],n=e.indexOf("M V30 MDLV30/STEABS ATOMS=(");for(;-1!==n;){n+=28;const i=e.indexOf(")",n);t=t.concat(e.substring(n,i).split(" ").slice(1).map((e=>parseInt(e)))),n=i,n=e.indexOf("M V30 MDLV30/STEABS ATOMS=(",n)}return t}(u),w={atoms:d,bonds:m,meta:g,stereoAtoms:f};return"PEPTIDE"===i?function(e){const t=e.meta.terminalNodes[0]-1,n=e.meta.rNodes[0]-1,i=e.atoms.x,o=e.atoms.y;M(e,-i[t],-o[t]);const s=C(i[n],o[n]);T(e.atoms,-s),i[e.meta.rNodes[1]-1]<0&&S(e);const r=function(e){const t=function(e){const t=new Map;for(const n of e.bonds.atomPairs)for(let e=0;e<2;e++){const i=n[e],o=n[(e+1)%2];t.has(i)?t.get(i)?.push(o):t.set(i,new Array(1).fill(o))}return t}(e);let n=0;const i=e.atoms.atomTypes.length;let o=0;if(e.meta.terminalNodes.length<2)return null;for(;0===n;){const s=t.get(e.meta.terminalNodes[1])[o];if(e.atoms.atomTypes[s-1]===p.u.OXYGEN&&s!==e.meta.rNodes[1]&&(n=s),o++,o>i)return null}return n}(e);null!=r&&(function(e,t){e.atoms.y[e.meta.rNodes[1]-1]<0&&e.atoms.y[t-1]<0&&(function(e){E(e,!0)}(e),T(e.atoms,-function(e,t){return C(e,t)+Math.PI/2}(e.atoms.x[e.meta.terminalNodes[1]-1],e.atoms.y[e.meta.terminalNodes[1]-1])))}(e,r),function(e,t){const n=e.atoms.x;n[e.meta.rNodes[1]-1]>n[t-1]&&function(e,t,n){const i=t-1,o=n-1,s=e.atoms.x,r=e.atoms.y,a=s[i],l=r[i];s[i]=s[o],r[i]=r[o],s[o]=a,r[o]=l}(e,t,e.meta.rNodes[1])}(e,r))}(w):e===p.u.RIBOSE.symbol||e===p.u.DEOXYRIBOSE.symbol?function(e,t){const n=e.atoms.x,i=e.atoms.y;let o=e.meta.terminalNodes[0]-1;const s=e.meta.rNodes[1]-1;M(e,-n[o],-i[o]);const r=C(n[e.meta.rNodes[2]-1],i[e.meta.rNodes[2]-1]);T(e.atoms,-r),n[e.meta.rNodes[0]-1]>n[e.meta.rNodes[1]-1]&&S(e);const a=C(n[s],i[s]);T(e.atoms,3*Math.PI/2-a),t.value=function(e){const t=e.atoms.x,n=e.atoms.y,i=e.meta.rNodes[2]-1,o=e.meta.terminalNodes[2]-1,s=t[i]-t[o],r=n[i]-n[o];return Math.atan2(s,r)}(e),o=e.meta.terminalNodes[0]-1,M(e,-n[o],-i[o])}(w,o):e===p.u.PHOSPHATE.symbol?function(e){const t=e.meta.rNodes[1]-1,n=e.meta.rNodes[0]-1,i=e.atoms.x,o=e.atoms.y;M(e,-i[t],-o[t]);const s=C(i[n],o[n]);T(e.atoms,Math.PI/2-s)}(w):function(e,t){const n=e.atoms.x,i=e.atoms.y,o=e.meta.terminalNodes[0]-1,s=e.meta.rNodes[0]-1;M(e,-n[o],-i[o]);const r=C(n[s],i[s]),a=t.value;if(!a)throw new Error("The value of sugarBranchToOYAngle is null");T(e.atoms,Math.PI-r+a);const c=function(e,t){return(0,l.YN)(Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2))}({x:n[e.meta.rNodes[0]-1],y:i[e.meta.rNodes[0]-1]},{x:n[e.meta.terminalNodes[0]-1],y:i[e.meta.terminalNodes[0]-1]});if(1!=c)for(let e=0;e<n.length;++e)n[e]=(0,l.YN)(n[e]/c),i[e]=(0,l.YN)(i[e]/c)}(w,o),function(e,t,n){if("PEPTIDE"===e){b(t,e);const n=v(t,t.meta.rNodes[1]);n?.removedAtom&&(t.terminalR2Atom=n.removedAtom)}else n===p.u.RIBOSE.symbol||n===p.u.DEOXYRIBOSE.symbol?(v(t,t.meta.rNodes[1]),t.meta.rNodes[1]=t.meta.terminalNodes[1],y(t.bonds,t.meta),b(t,e),v(t,t.meta.rNodes[1]),v(t,t.meta.rNodes[0]),v(t,t.meta.rNodes[2])):n===p.u.PHOSPHATE.symbol&&(t.meta.terminalNodes[0]=t.meta.rNodes[0],M(t,-t.atoms.x[t.meta.terminalNodes[0]-1],-t.atoms.y[t.meta.terminalNodes[0]-1]),b(t,e),v(t,t.meta.rNodes[1]))}(i,w,e),function(e){let t=0;for(;t<e.atoms.atomTypes.length;)e.atoms.atomTypes[t]===p.u.HYDROGEN&&(v(e,t+1),--t),++t}(w),function(e){let t=0;for(;t<e.atoms.atomTypes.length;)"oh"===e.atoms.atomTypes[t]?.toLowerCase()&&(e.atoms.atomTypes[t]="O"),"?"===e.atoms.atomTypes[t]&&(e.atoms.atomTypes[t]="H"),++t}(w),function(e){const t=" RGROUPS=(1 1)";for(let n=0;n<(e.atoms.kwargs?.length??0);n++){const i=e.atoms.kwargs[n];i&&i.includes(t)&&(e.atoms.kwargs[n]=i.replace(t,""))}}(w),w}var s;return null}(t,n,i,o,s);if(!a)throw new Error(`Monomer with symbol '${t}' is absent the monomer library`);(0,u.LQ)(e,r,a)}}function y(e,t){const n=t.rNodes;t.terminalNodes=new Array(n.length).fill(0);const i=t.terminalNodes,o=e.atomPairs;let s=0,r=0;for(;s<o.length&&r<i.length;){for(let e=0;e<i.length;++e)for(let t=0;t<2;++t)o[s][t]===n[e]&&(i[e]=o[s][(t+1)%2],n.length,++r);++s}}function b(e,t){e.meta.rNodes.length>1&&(e.meta.backboneShift=w(e,e.meta.rNodes[1]-1,e.meta.terminalNodes[0]-1)),"RNA"===t&&e.meta.rNodes.length>2&&(e.meta.branchShift=w(e,e.meta.rNodes[2]-1,e.meta.terminalNodes[0]-1))}function w(e,t,n){return[(0,l.YN)(e.atoms.x[t]-e.atoms.x[n]),(0,l.YN)(e.atoms.y[t]-e.atoms.y[n])]}function v(e,t){if(void 0!==t){const n=t-1,i=e.atoms,o=e.bonds,s=e.meta,r=i.atomTypes.splice(n,1)[0];i.x=A(Float32Array,i.x,n,1),i.y=A(Float32Array,i.y,n,1),i.kwargs.splice(n,1);for(let e=0;e<s.terminalNodes.length;++e)s.terminalNodes[e]>t?--s.terminalNodes[e]:s.terminalNodes[e]===t&&(s.terminalNodes[e]=-1);for(let e=0;e<s.rNodes.length;++e)s.rNodes[e]>t?--s.rNodes[e]:s.rNodes[e]===t&&(s.rNodes[e]=-1);let a=0;for(;a<o.atomPairs.length;){const e=o.atomPairs[a][0],n=o.atomPairs[a][1];e===t||n===t?(o.atomPairs.splice(a,1),o.bondTypes=A(Uint32Array,o.bondTypes,a,1),o.bondConfiguration.has(a)&&o.bondConfiguration.delete(a),o.kwargs.has(a)&&o.kwargs.delete(a),--a):(o.atomPairs[a][0]=e>t?e-1:e,o.atomPairs[a][1]=n>t?n-1:n),++a}let l=Array.from(o.bondConfiguration.keys());return l.forEach((e=>{if(o.bondConfiguration.has(e)&&e>n){const t=o.bondConfiguration.get(e);o.bondConfiguration.delete(e),o.bondConfiguration.set(e-1,t)}})),l=Array.from(o.kwargs.keys()),l.forEach((e=>{if(o.kwargs.has(e)&&e>n){const t=o.kwargs.get(e);o.kwargs.delete(e),o.kwargs.set(e-1,t)}})),r?{removedAtom:r}:void 0}}function A(e,t,n,i){const o=new e(t.length-i);let s=0,r=0;for(;s<t.length;)s===n&&(s+=i),o[r]=t[s],++r,++s;return o}function C(e,t){let n;if(0===e)n=t>0?0:Math.PI;else if(0===t)n=e>0?-Math.PI/2:Math.PI/2;else{const i=t/e,o=Math.atan(i);n=e<0?Math.PI/2+o:-Math.PI/2+o}return n}function T(e,t){if(0!==t){const n=e.x,i=e.y,o=Math.cos(t),s=Math.sin(t);for(let e=0;e<n.length;++e){const t=n[e];n[e]=(0,l.YN)(t*o-i[e]*s),i[e]=(0,l.YN)(t*s+i[e]*o)}}}function S(e){E(e,!1)}function E(e,t){if(t){const t=e.atoms.y;for(let e=0;e<t.length;e++)t[e]=-t[e]}else{const t=e.atoms.x;for(let e=0;e<t.length;e++)t[e]=-t[e]}const n=e.bonds.bondConfiguration;for(const[e,t]of n){const i=1===t?3:1;n.set(e,i)}}function M(e,t,n){const i=e.atoms.x,o=e.atoms.y;for(let e=0;e<i.length;++e)i[e]=(0,l.YN)(i[e]+t),void 0!==n&&(o[e]=(0,l.YN)(o[e]+n))}},294:(e,t,n)=>{"use strict";function i(e,t){return e[t.polymerType]?.[t.symbol]}function o(e,t){return!!e[t.polymerType]?.[t.symbol]}function s(e,t,n){let i=e[t.polymerType];i||(i=e[t.polymerType]={}),i[t.symbol]=n}n.d(t,{Cg:()=>r,LQ:()=>s,bq:()=>o,vF:()=>a,xb:()=>i});class r extends Map{constructor(e){super(e)}}class a{constructor(e,t){this.molfile=e,this.monomers=t}static createEmpty(){return new a("",new r(null))}}},330:(e,t,n)=>{"use strict";n.d(t,{kA:()=>o,pz:()=>r,qj:()=>s,vG:()=>a});var i=n(2003);function o(e,t){return e?e.columns.getUnusedName(t):t}function s(e,t){return o(e,`molfile(${t})`)}function r(e){let t;if(e===i.YI.PT||e===i.YI.UN)t="PEPTIDE";else{if(e!==i.YI.RNA&&e!==i.YI.DNA)throw new Error(`Unexpected alphabet '${e}'.`);t="RNA"}return t}function a(e){const t=7===e.length?/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e):/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?[parseInt(t[1],16)/256,parseInt(t[2],16)/256,parseInt(t[3],16)/256,t.length>4?parseInt(t[4],16)/256:.3]:null}},1093:(e,t,n)=>{"use strict";n.d(t,{A:()=>o,Q:()=>s});var i=n(7362);class o extends i.e{static get Chromatogram(){return void 0===this.chromatogram&&(this.chromatogram=new o({A:"green",C:"blue",G:"black",T:"red",U:"red",others:"gray"})),this.chromatogram}}class s{}s.SemType="Nucleotides",s.SemTypeMultipleAlignment="NucleotidesMultipleAlignment",s.Names={A:"Adenine",C:"Cytosine",G:"Guanine",T:"Thymine",U:"Uracil"}},7362:(e,t,n)=>{"use strict";n.d(t,{e:()=>i});class i{static makePalette(e,t=!1,n=i){const o={};return e.forEach((e=>{const n=e[0],i=e[1];n.forEach(((e,n)=>{o[e]=this.colourPalette[i][t?0:n]}))})),new n(o)}constructor(e){this._palette=e}get(e,t){return this._palette[e]}}i.undefinedColor="rgb(100,100,100)",i.colourPalette={orange:["rgb(255,187,120)","rgb(245,167,100)","rgb(235,137,70)","rgb(205, 111, 71)"],all_green:["rgb(44,160,44)","rgb(74,160,74)","rgb(23,103,57)","rgb(30,110,96)","rgb(60,131,95)","rgb(24,110,79)","rgb(152,223,138)","rgb(182, 223, 138)","rgb(152, 193, 138)"],all_blue:["rgb(31,119,180)","rgb(23,190,207)","rgb(122, 102, 189)","rgb(158,218,229)","rgb(141, 124, 217)","rgb(31, 120, 150)"],magenta:["rgb(162,106,192)","rgb(197,165,224)","rgb(208,113,218)"],red:["rgb(214,39,40)","rgb(255,152,150)"],st_blue:["rgb(23,190,207)","rgb(158,218,229)","rgb(31,119,180)"],dark_blue:["rgb(31,119,180)","rgb(31, 120, 150)"],light_blue:["rgb(23,190,207)","rgb(158,218,229)","rgb(108, 218, 229)","rgb(23,190,227)"],lilac_blue:["rgb(124,102,211)","rgb(149,134,217)","rgb(97, 81, 150)"],dark_green:["rgb(23,103,57)","rgb(30,110,96)","rgb(60,131,95)","rgb(24,110,79)"],green:["rgb(44,160,44)","rgb(74,160,74)"],light_green:["rgb(152,223,138)","rgb(182, 223, 138)","rgb(152, 193, 138)"],st_green:["rgb(44,160,44)","rgb(152,223,138)","rgb(39, 174, 96)","rgb(74,160,74)"],pink:["rgb(247,182,210)"],brown:["rgb(140,86,75)","rgb(102, 62, 54)"],gray:["rgb(127,127,127)","rgb(199,199,199)","rgb(196,156,148)","rgb(222, 222, 180)"],yellow:["rgb(188,189,34)"],white:["rgb(230,230,230)"]}},4574:(e,t,n)=>{"use strict";n.d(t,{O:()=>s,n:()=>o});var i=n(1858);class o{constructor(e,t=!0,n){return this.substructure=e,this.readOnly=t,this.logger=n,new Proxy(this,{set:(e,t,n)=>{if(this.logger?.debug(`BioFilterProps.set ${t.toString()}( '${n}' )`),this.readOnly)throw new Error("Properties are immutable.");return e[t]=n,!0}})}}class s{constructor(){this.onChanged=new i.Subject,this._props=null,this._propsChanging=!1}get props(){return this._props||(this._props=this.emptyProps),this._props}set props(e){this._propsChanging=!0;try{this._props=e,this.applyProps(),this.onChanged.next()}finally{this._propsChanging=!1}}saveProps(){const e={};for(const[t,n]of Object.entries(this.props))"_onChanged"!==t&&"logger"!==t&&(e[t]=this.props[t]);return e}async detach(){}get filterSummary(){return this.props.substructure}get isFiltering(){return""!==this.props.substructure}resetFilter(){this.props=this.emptyProps,this.onChanged.next()}}},4152:(e,t,n)=>{"use strict";n.d(t,{$u:()=>l,oT:()=>h});var i=n(6082),o=n(7362),s=n(6718);function r(e,t=!0){if(null==e)return"rgb(100,100,100)";const n=i.Color.fromHtml(e);if(t){const e=i.Color.g(n),t=i.Color.r(n),o=i.Color.b(n),s=Math.sqrt(Math.pow(0-t,2)+Math.pow(0-e,2)+Math.pow(0-o,2));if(s>210)return`rgb(${t/s*210},${e/s*210},${o/s*210})`}return i.Color.toRgb(n)}class a{static hashCode(e){let t=0;if(0===e.length)return t;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t}}class l{}class c extends l{get(e,t){return"#666666"}}class u extends l{static get palette(){return u._pallete||(u._pallete=u.buildPalette()),u._pallete}static buildPalette(){return(0,s.pj)().then((e=>{e.awaitLoaded(1/0).then((()=>{const t=e.getMonomerLib();t.onChanged.subscribe((()=>{u.customMonomerColors={},u.polymerTypes=t.getPolymerTypes();for(const e of this.polymerTypes){const n=t.getMonomerSymbolsByType(e);for(const i of n){const n=t.getMonomer(e,i);n?.meta?.colors?.default?.background&&(this.customMonomerColors[i]||(this.customMonomerColors[i]={}),this.customMonomerColors[i][e]=r(n.meta.colors.default.background))}}}))}))})),[].concat(...Object.values(o.e.colourPalette))}get(e,t){const n=u.palette.length,i=u.customMonomerColors[e],o=t??"PEPTIDE";if(i&&i[o])return i[o];const s=a.hashCode(e)%n;return r(u.palette[s])}}u._pallete=null,u.customMonomerColors={},u.polymerTypes=[];class h extends o.e{static get Gray(){return void 0===this.gray&&(this.gray=new c),this.gray}static get Color(){return void 0===this.color&&(this.color=new u),this.color}}},6642:(e,t,n)=>{"use strict";n.d(t,{BG:()=>r,sD:()=>l});var i=n(4328),o=n(1858),s=n(8070);function r(e){let t=null,n=null;try{n=e.dart?e.gridColumn:null,t=n?n.temp:null}catch{[n,t]=[null,null]}const i=e.cell.column;if(t=t??(i?i.temp:null),!t)throw new Error("Grid cell renderer back store (GridColumn or Column) not found.");return[n,i,t]}class a{onKeyDown(e,t){}onKeyPress(e,t){}onMouseEnter(e,t){}onMouseLeave(e,t){}onMouseDown(e,t){}onMouseUp(e,t){}onMouseMove(e,t){}onClick(e,t){}onDoubleClick(e,t){}}class l extends a{constructor(e,t,n){super(),this.gridCol=e,this.tableCol=t,this.logger=n,this.subs=[],this.dirty=!0,this.destroyed=!1,this.viewerId=++l.viewerCounter,this.errors=[],this._onRendered=new o.Subject,this.tableCol&&this.tableCol.dataFrame&&(this.subs.push(this.tableCol.dataFrame.onDataChanged.subscribe((()=>{this.dirty=!0}))),this.subs.push(this.tableCol.dataFrame.onColumnsRemoved.subscribe((e=>{try{this.destroyed||!this.tableCol||this.tableCol.dataFrame||this.destroy()}catch(e){this.logger.error(e)}})))),this.tableCol&&this.subs.push(i.events.onTableRemoved.subscribe((e=>{try{const t=e.args.dataFrame;this.tableCol?.dataFrame.id!==t.id||this.destroyed||this.destroy()}catch(e){this.logger.error(e)}}))),this.gridCol&&this.subs.push(i.events.onViewRemoving.subscribe((e=>{try{const t=e.args.view;this.gridCol?.dart&&this.gridCol.grid&&this.gridCol?.grid?.dart&&this.gridCol?.grid?.view?.id===t.id&&!this.destroyed&&this.destroy()}catch(e){this.logger.error(e)}})))}toLog(){return`${this.constructor.name}<${this.viewerId}>`}destroy(){for(const e of this.subs)e.unsubscribe();this.destroyed=!0}invalidateGrid(){this.gridCol&&this.gridCol.dart&&this.gridCol.grid?.invalidate()}reset(){this.dirty=!1}get onRendered(){return this._onRendered}invalidate(e){this.invalidateGrid()}async awaitRendered(e=1e4,t=`${e} timeout`){const n=`${this.toLog()}.awaitRendered()`;if(this.logger.debug(`${n}, start, testEvent before`),await(0,s.PE)(this._onRendered,(()=>{}),(()=>{this.invalidate()}),e,`${n}, ${t}`),this.errors.length>0){const e=this.errors[0];throw this.errors=[],e}this.logger.debug(`${n}, end`)}}l.viewerCounter=-1},673:(e,t,n)=>{"use strict";n.d(t,{s:()=>i});const i={true:"1",false:"0"}},6882:(e,t,n)=>{"use strict";n.d(t,{Bb:()=>b,Jy:()=>w,S$:()=>y,U0:()=>v});var i=n(7389),o=n(6082),s=n(1991),r=n.n(s),a=n(8312),l=n(2003),c=n(6642),u=n(6718),h=n(9192),d=n(3856),p=n(673),m=n(3599),g=n(5553),f=n(9713);const y="rgb(100,100,100)";function b(e,t,n){if((n??0)>0&&t<(e[0]??0)+n)return-1;t-=n??0;let i,o=100,s=0,r=e.length-1;for(;s<=r;){if(i=Math.floor((r+s)/2),e[i]<=t&&t<e[i+1])return i;if(t<e[i]?r=i-1:s=i+1,--o<=0)throw new Error(`Get position for pointer x = ${t} searching has not converged on ${JSON.stringify(e)}. `)}return null}class w extends c.sD{get separatorWidth(){return this.props?.fontCharWidth?this.props?.fontCharWidth:5}constructor(e,t,n,i,s){if(super(e,t,n),this.monomerLengthLimit=i,this.propsProvider=s,this.colWidth=0,this._monomerLengthList=null,this._processedMaxVisibleSeqLength=0,this._monomerLengthMap={},this._monomerStructureMap={},this._ellipsisBounds=void 0,this._totalLinesNeeded=0,this._lineHeight=20,this._cellBounds=new Map,this.sysMonomerLib=null,this.padding=5,this._leftThreeDotsPadding=0,this.props=this.propsProvider(),this._processedRows=o.BitSet.create(this.tableCol.length),this.gridCol&&this.subs.push(this.gridCol.grid.onAfterDrawContent.subscribe((()=>{this._onRendered.next()}))),this.tableCol&&this.gridCol){this.subs.push(this.tableCol.dataFrame.onCurrentRowChanged.subscribe((()=>{-1===this.tableCol.dataFrame.currentRowIdx&&(this.tableCol.temp["reference-sequence"]=null,this.tableCol.temp["current-word"]=null,this.invalidateGrid())})));const e=[l.gp.positionShift,"renderMultiline"];this.subs.push(o.debounce(this.tableCol.dataFrame.onMetadataChanged.pipe(f.filter((t=>t.args.source===this.tableCol&&e.includes(t.args.key)))),200).subscribe((e=>{this.reset()}))),this.subs.push(o.debounce(this.tableCol.dataFrame.onMetadataChanged.pipe(f.filter((e=>e.args.source===this.tableCol&&e.args.key===l.gp.positionShift))),200).subscribe((e=>{this.reset()})))}}calculateFontBasedSpacing(e){const t=e.measureText("M");let n=12;if(this.tableCol?.temp[".mm.cellRenderer.fontSize"]){const e=this.tableCol.temp[".mm.cellRenderer.fontSize"];"number"!=typeof e||isNaN(e)||(n=Math.max(e,1))}return{lineHeight:Math.max(1.4*n,t.fontBoundingBoxAscent+t.fontBoundingBoxDescent+4),monomerSpacing:Math.max(2,.2*this.props.fontCharWidth)}}shouldUseMultilineRendering(e){return"true"===e.getTag("renderMultiline")}calculateMultiLineLayoutDynamic(e,t,n,i,o,s){if(this.dirty)try{this.reset()}catch(e){const[t,n]=(0,h.AP)(e);this.logger.error(t,void 0,n)}const{lineHeight:r,monomerSpacing:a}=this.calculateFontBasedSpacing(e),l=t-2*this.padding;let c=0;const u=[];if(i.length>0)for(let t=o;t<i.length;t++){const n=i.getOriginal(t),o=this.props.monomerToShort(n,s);u.push({text:o,posIdx:t}),c=Math.max(c,e.measureText(o).width)}if(0===u.length)return{lineLayouts:[],lineHeight:r};const d=c;let p=Math.floor((l+a)/(d+a));p=Math.max(1,p);const m=n-2*this.padding,g=Math.max(0,Math.floor(m/r)),f=[];let y=0;for(let e=0;e<g&&y<u.length;e++){const t=[];for(let e=0;e<p&&y<u.length;e++){const n=u[y],i=this.padding+e*(d+a);t.push({posIdx:n.posIdx,x:i,width:d,om:n.text,isSeparator:!1}),y++}f.push({lineIdx:e,elements:t})}return{lineLayouts:f,lineHeight:r}}async init(){await Promise.all([(async()=>{this.seqHelper=await(0,a.Q)(),this.invalidateGrid()})(),(async()=>{const e=await(0,u.pj)();this.sysMonomerLib=e.getMonomerLib()})()]),this.subs.push(this.sysMonomerLib.onChanged.subscribe((()=>{this.reset()}))),this.reset()}static getFontSettings(e){let t=12;return e&&e.temp[".mm.cellRenderer.fontSize"]&&"number"==typeof e.temp[".mm.cellRenderer.fontSize"]&&!isNaN(e.temp[".mm.cellRenderer.fontSize"])&&(t=Math.max(e.temp[".mm.cellRenderer.fontSize"],1)),{font:`${t}px monospace`,fontWidth:.6*t}}toLog(){return`MonomerPlacer<${this.viewerId}>`}getMonomerLib(){return this.tableCol.temp[".mm.cellRenderer.overriddenLibrary"]??this.sysMonomerLib}reset(){this.propsProvider&&(this.props=this.propsProvider()),this._processedRows=o.BitSet.create(this.tableCol.length),this._monomerLengthList=null,this._monomerLengthMap={},this._monomerStructureMap={},this._cellBounds.clear(),super.reset(),this.invalidateGrid()}invalidateGrid(){this.gridCol&&this.gridCol.dart&&this.gridCol.grid?.invalidate()}getCellMonomerLengths(e,t){const n=this.seqHelper.getSeqHandler(this.tableCol);if(this.colWidth<t&&(this.colWidth=t,this.dirty=!0),this.dirty)try{this.reset()}catch(e){const[t,n]=(0,h.AP)(e);this.logger.error(t,void 0,n)}const i=n.isMsa()?this.getCellMonomerLengthsForSeqMsa():this.getCellMonomerLengthsForSeq(e);return[i,this.getSummedMonomerLengths(i)]}getSummedMonomerLengths(e){const t=new Array(e.length+1);t[0]=this.padding;for(let n=1;n<t.length;n++)t[n]=t[n-1]+e[n-1];let n=t[0];for(let e=1;e<t.length;e++)t[e]?n=t[e]:t[e]=n;return t}getCellMonomerLengthsForSeqValue(e,t){const n=this.seqHelper.getSeqHandler(this.tableCol),i=this.props.separatorWidth+1*this.props.fontCharWidth,o=this.positionShift,s=Math.ceil(t/i)+o,r=n.splitter(e),a=Math.min(s,r.length),l=new Array(a-o);let c=0;for(let e=o;e<a;++e){const i=r.getOriginal(e),s=this.props.monomerToShort(i,this.monomerLengthLimit),a=(n.isSeparator()?this.separatorWidth:this.props.separatorWidth)+s.length*this.props.fontCharWidth;if(l[e-o]=a,c+=a,c>t)break}return l}getCellMonomerLengthsForSeq(e){this.toLog(),null===this._monomerLengthList&&(this._monomerLengthList=new Array(this.tableCol.length).fill(null));const t=this.positionShift,n=this.seqHelper.getSeqHandler(this.tableCol),i=this.props.separatorWidth+1*this.props.fontCharWidth,o=Math.ceil(this.colWidth/i)+t,s=n.getSplitted(e),r=Math.min(o,s.length);let a=this._monomerLengthList[e];if(null===a||a.length!=r-t){a=this._monomerLengthList[e]=new Array(s.length);let i=0;for(let e=t;e<r;++e){const o=s.getOriginal(e),r=this.props.monomerToShort(o,this.monomerLengthLimit),l=(n.isSeparator()?this.separatorWidth:this.props.separatorWidth)+r.length*this.props.fontCharWidth;if(a[e-t]=l,i+=l,i>this.colWidth)break}}return a}getCellMonomerLengthsForSeqMsa(){var e;this.toLog(),null===this._monomerLengthList&&(this._monomerLengthList=new Array(1).fill(null)),(e=this._monomerLengthList)[0]??(e[0]=new Array(0));const t=this._monomerLengthList[0],{startIdx:n,endIdx:i}=(()=>{try{const e=this.gridCol&&this.gridCol.dart?this.gridCol.grid:null;return e&&e.dart?{startIdx:Math.max(Math.floor((e?.vertScroll.min??0)-10),0),endIdx:Math.min(Math.ceil((e?.vertScroll.max??0)+10),this.tableCol.length)}:{startIdx:0,endIdx:Math.min(this.tableCol.length,10)}}catch(e){return{startIdx:0,endIdx:Math.min(this.tableCol.length,10)}}})(),o=this.props.separatorWidth+1*this.props.fontCharWidth,s=this.positionShift,r=Math.ceil(this.colWidth/o)+s;for(let e=n;e<i;e++){if(this._processedRows.get(e)&&r<=this._processedMaxVisibleSeqLength)continue;const n=this.seqHelper.getSeqHandler(this.tableCol).getSplitted(e,r),i=Math.min(r,n.length);i-s>t.length&&t.push(...new Array(i-s-t.length).fill(o));let a=0;for(let e=s;e<i;++e){const i=n.getOriginal(e),o=this.props.monomerToShort(i,this.monomerLengthLimit),r=this.props.separatorWidth+o.length*this.props.fontCharWidth;if(t[e-s]=Math.max(t[e-s]??0,r),a+=r,a>=this.colWidth)break}this._processedMaxVisibleSeqLength=Math.max(this._processedMaxVisibleSeqLength,r),this._processedRows.set(e,!0)}return t}getPosition(e,t,n,i){const[o,s]=this.getCellMonomerLengths(e,n);return 0===this.seqHelper.getSeqHandler(this.tableCol).getSplitted(e).length?null:b(s,t,i)}setMonomerLengthLimit(e){this.monomerLengthLimit!=e&&(this.monomerLengthLimit=e,this.dirty=!0)}setSeparatorWidth(e){this.separatorWidth!=e&&(this.props.separatorWidth=e,this.dirty=!0)}get positionShift(){const e=Number.parseInt(this.tableCol?.tags[l.gp.positionShift]??"0")??0;return isNaN(e)?0:Math.max(e,0)}render(e,t,n,i,s,a,c){const u=a.grid?.canvas===e.canvas;if(!this.seqHelper)return;const m=this.tableCol,g=this.positionShift;e.save();try{const c=this.seqHelper.getSeqHandler(m);let h=this.monomerLengthLimit;if(d.gp.maxMonomerLength in m.tags){const e=parseInt(m.getTag(d.gp.maxMonomerLength));h=!isNaN(e)&&e?e:50}if(m.temp[".mm.cellRenderer.settingsChanged"]===p.s.true||this.monomerLengthLimit!=h){let e=0;const t=8;e=m.temp[".mm.cellRenderer.gapLength"]??e,this.setMonomerLengthLimit(h),this.setSeparatorWidth(c.isMsa()?t:e),m.temp[".mm.cellRenderer.settingsChanged"]=p.s.false,this.dirty=!0}const f=a.cell.rowIndex,b=a.cell.value;u&&(i=v(a.grid,e,t,i,window.devicePixelRatio)),e.beginPath(),e.rect(t,n,i,s),e.clip(),e.font=this.props?.font??"12px monospace",e.textBaseline="top";const w=m.meta.units,A=m.getTag(l.gp.aligned),C=m.getTag(l.gp.separator)??"",T=u?c.getSplitted(f):c.splitter(b);let S=d.yg.classic;A?.includes("MSA")&&w===l.Hi.SEPARATOR&&(S=d.yg.MSA);const E=m.temp["reference-sequence"],M=this.tableCol.temp["current-word"],x=(()=>{const e=(0,c.splitter)(null!=E&&""!==E?E:M??"");return r().count(0).take(e.length).slice(g).map((t=>e.getCanonical(t))).toArray()})(),L=Number.parseInt(m.getTag(l.gp.selectedPosition)??"-200");if(this.shouldUseMultilineRendering(m)){const r=[],l=this.calculateMultiLineLayoutDynamic(e,i,s,T,g,h);let u=n+this.padding;1===l.lineLayouts.length&&(u=n+(s-l.lineHeight)/2);for(const i of l.lineLayouts){const s=u+i.lineIdx*l.lineHeight;for(const u of i.elements){const h=t+u.x,p=u,f=p.posIdx,b=T.getCanonical(f);let w=y;const v=this.getMonomerLib();v&&(w=v.getMonomerTextColor(c.defaultBiotype,b));let A=0;if(a.tableRowIndex!==m.dataFrame.currentRowIdx&&x.length>0){const e=f-g;e>=0&&e<x.length&&b===x[e]&&(A=.7)}r.push({lineIdx:i.lineIdx,monomerIdx:f-g,bounds:new o.Rect(u.x,s-n,u.width,l.lineHeight),sequencePosition:f}),(0,d.oZ)(e,p.om,h,s,u.width,l.lineHeight,{color:w,isMultiLineContext:!0,transparencyRate:A,selectedPosition:isNaN(L)||L<1?void 0:L,wordIdx:f})}}null!==a.tableRowIndex&&this._cellBounds.set(a.tableRowIndex,r)}else{this._leftThreeDotsPadding=this.shouldRenderShiftedThreeDots(g)?e.measureText("...").width:0;let[,o]=this.getCellMonomerLengths(a.tableRowIndex,i);u||(o=this.getSummedMonomerLengths(this.getCellMonomerLengthsForSeqValue(b,i)));const r=this.props.separatorWidth+1*this.props.fontCharWidth,l=Math.min(T.length,Math.ceil(i/r)+g);for(let r=g;r<l;++r){const l=r<T.length?T.getOriginal(r):c.defaultGapOriginal,u=r<T.length?T.getCanonical(r):c.defaultGapOriginal;let p=y;this.getMonomerLib()&&(p=this.getMonomerLib().getMonomerTextColor(c.defaultBiotype,u));const m={color:p,pivot:0,left:!0,transparencyRate:0,separator:C,last:r===T.length-1,drawStyle:S,maxWord:o,wordIdx:r-g,gridCell:a,referenceSequence:x,maxLengthOfMonomer:h,monomerTextSizeMap:this._monomerLengthMap,logger:this.logger,selectedPosition:isNaN(L)||L<1?void 0:L-g};(0,d.oZ)(e,l,t+this.padding+this._leftThreeDotsPadding,n,i,s,m)}if(this.shouldRenderShiftedThreeDots(g)){const r={color:y,pivot:0,left:!0,transparencyRate:0,separator:C,last:!1,drawStyle:S,maxWord:o,wordIdx:0,gridCell:a,maxLengthOfMonomer:h,monomerTextSizeMap:this._monomerLengthMap,logger:this.logger};(0,d.oZ)(e,"...",t+this.padding,n,i,s,r)}}}catch(e){const[t,n]=(0,h.AP)(e);this.logger.error(t,void 0,n),this.errors.push(e)}finally{e.restore()}}shouldRenderShiftedThreeDots(e){return e>0&&(!this.gridCol||!this.gridCol.dart||!this.gridCol.grid||!this.gridCol.grid.dart||(this.gridCol.grid.props.colHeaderHeight??0)<=50)}onMouseMove(e,t){const n=`${this.toLog()}.onMouseMove()`;if(!this.seqHelper||null==e.tableRowIndex)return;const o=this.positionShift,s=e.bounds,r=t.offsetX-e.gridColumn.left+(e.gridColumn.left-s.x),a=t.offsetY-s.y;this.gridCol?.grid?.canvas&&(this.gridCol.grid.canvas.style.cursor="default");let c=null;const u=this._cellBounds.get(e.tableRowIndex);if(u){for(const e of u)if(e.bounds.contains(r,a)){c=e.monomerIdx;break}}else{const t=this.shouldRenderShiftedThreeDots(o)&&(this._leftThreeDotsPadding??0)>0?this._leftThreeDotsPadding:0;c=this.getPosition(e.tableRowIndex,r,s.width,t)}this.logger.debug(`${n}, argsX: ${r}, argsY: ${a}, left: ${c}`);const h=this.seqHelper.getSeqHandler(this.tableCol),d=h.getSplitted(e.tableRowIndex);if(null!==c&&c>=0&&c+o<d.length){const n=h.alphabet??l.YI.UN,s={position:c,biotype:n===l.YI.RNA||n===l.YI.DNA?m.o.NUCLEOTIDE:m.o.AA,symbol:d.getCanonical(c+o)},r=[];let a=this._monomerStructureMap[s.symbol];if(!a){const e=this.getMonomerLib();a=this._monomerStructureMap[s.symbol]=e?e.getTooltip(s.biotype,s.symbol):i.divText("Monomer library is not available")}r.push(a),i.tooltip.show(i.divV(r),t.x+16,t.y+16),(0,g.WN)(e,s)}else-1===c?i.tooltip.show(i.divText(`${Math.min(o,d.length)} hidden monomers`),t.x+16,t.y+16):i.tooltip.hide(),(0,g.WN)(e,null)}}function v(e,t,n,i,o){return e?Math.max(Math.min(e.canvas.width/o-n,i)):Math.max(t.canvas.width/o-n,0)}},3856:(e,t,n)=>{"use strict";n.d(t,{Mn:()=>u,gp:()=>c,oZ:()=>p,yg:()=>h});var i=n(6082),o=n(7278);const s="rgb(100,100,100)",r="#808080",a="rgb(0,0,0)",l=o.zS;var c,u,h;!function(e){e.maxMonomerLength=".mm.cellRenderer.maxMonomerLength"}(c||(c={})),function(e){e.applyToBackground=".m.cellRenderer.applyToBackground"}(u||(u={})),function(e){e.MSA="MSA",e.classic="classic"}(h||(h={}));const d=new class{constructor(){this.color=s,this.pivot=0,this.left=!1,this.transparencyRate=0,this.separator="",this.last=!1,this.drawStyle=h.classic,this.maxWord=[],this.wordIdx=0,this.gridCell=null,this.referenceSequence=null,this.maxLengthOfMonomer=null,this.monomerTextSizeMap={},this.logger=void 0,this.selectedPosition=void 0,this.isMultiLineContext=!1,this.lineNumber=0}};function p(e,t,n,o,c,u,p){var m,g,f;const y={...d,...p};if(y.isMultiLineContext){e.textBaseline="middle",e.textAlign="center";let i=t;null!=y.maxLengthOfMonomer&&(i=l(i,y.maxLengthOfMonomer));const r=Math.max(.1,1-(y.transparencyRate??0));e.globalAlpha=r;const h=e.measureText(i),d=h.fontBoundingBoxAscent+h.fontBoundingBoxDescent,p=o+(u-d)/2+h.fontBoundingBoxAscent;let m=y.color??s;return m&&m!==s||(m=a),e.fillStyle=m,y.selectedPosition===y.wordIdx+1&&(e.save(),e.fillStyle="rgba(60, 177, 115, 0.2)",e.fillRect(n,o,c,u),e.restore(),e.fillStyle=m),e.fillText(i,n+c/2,p),e.globalAlpha=1,e.textBaseline="top",e.textAlign="start",n+c}p.logger?.debug("Bio: printLeftOrCentered(), start"),e.textAlign="start";let b=t.substring(0),w=y.last?"":y.separator;y.drawStyle===h.MSA&&(w="");let v=!0,A=!0,C="difference";if(null!=y.gridCell&&null!=y.gridCell.cell.column&&(v=y.gridCell.cell.column.temp["color-code"]??!0,A=y.gridCell.cell.column.temp["compare-with-current"]??!0,C=y.gridCell.cell.column.temp["highlight-difference"]??"difference"),y.referenceSequence){const e=y.referenceSequence[y.wordIdx];A&&y.referenceSequence.length>0&&"difference"===C&&(y.transparencyRate=b==e?.7:y.transparencyRate),A&&y.referenceSequence.length>0&&"equal"===C&&(y.transparencyRate=b!=e?.7:y.transparencyRate)}null!=y.maxLengthOfMonomer&&(b=l(b,y.maxLengthOfMonomer));const T=b+w;(m=y.monomerTextSizeMap)[T]??(m[T]=e.measureText(T));let S=y.monomerTextSizeMap[T];(g=y.monomerTextSizeMap)[b]??(g[b]=e.measureText(b));let E=y.monomerTextSizeMap[b].width;const M=u/2-(S.fontBoundingBoxAscent+S.fontBoundingBoxDescent)/2+1;(f=y.monomerTextSizeMap)[w]??(f[w]=e.measureText(w));const x=y.monomerTextSizeMap[w].width;function L(t,s){let l=v?y.color:a;y.selectedPosition===y.wordIdx+1&&(e.fillStyle="rgba(60, 177, 115, 0.2)",e.fillRect(n+t-4,o-5,y.monomerTextSizeMap[b].width+8,u+10),l=i.Color.toHtml(i.Color.setAlpha(i.Color.fromHtml(l),255))),e.fillStyle=l,e.globalAlpha=1-y.transparencyRate,y.drawStyle===h.classic&&(e.fillText(b,n+t,o+M),e.fillStyle=r,e.fillText(w,n+s,o+M)),y.drawStyle===h.MSA&&e.fillText(b,n+t,o+M),e.globalAlpha=1}S=S.width,y.drawStyle===h.MSA&&(E=y.maxWord[y.wordIdx],S=y.maxWord[y.wordIdx]);const _=(y.maxWord[y.wordIdx]??0)-(y.maxWord[0]??0);if(y.left||S>c)return L(_,_+E),n+_+E+x;{const e=(c-S)/2;return L(e,e+E),n+_+e+E}}},6307:(e,t,n)=>{"use strict";n.d(t,{F:()=>r});var i=n(7389),o=n(6082),s=n(439);function r(e,t,n){let r=0,a=null;for(const t of Object.values(e))r+=t,a=null===a?t:Math.max(a,t);const l=a/r,c=Object.assign({},...Array.from(Object.entries(e)).sort(((e,t)=>t[1]-e[1])).map((([e,a])=>{const c=a/r;let u;try{const i=n.getMonomerColors(t,e);u=i?.backgroundcolor||"#CCCCCC"}catch(t){console.warn(`Failed to get colors for monomer ${e}:`,t),u="#CCCCCC"}const h=i.div("",{classes:"macromolecule-cell-comp-analysis-bar"});h.style.width=50*c/l+"px",h.style.backgroundColor=u,s._S===e&&(h.style.borderWidth="1px",h.style.borderStyle="solid",h.style.borderColor=o.Color.toHtml(o.Color.lightGray));const d=s._S===e?"-":e,p=i.div(`${(100*c).toFixed(2)}%`),m=i.div([h,p],{classes:"macromolecule-cell-comp-analysis-value"});return{[d]:m}}))),u=i.tableFromMap(c);return Array.from(u.rows).forEach((e=>{const t=e.getElementsByClassName("macromolecule-cell-comp-analysis-bar")[0].style.backgroundColor;e.cells[0].style.color=t})),u}},3151:(e,t,n)=>{"use strict";n.d(t,{EK:()=>l,Ec:()=>s,f6:()=>i,pe:()=>r,q7:()=>a,yw:()=>o});const i=["symbol","molfile","rgroups","name"],o="MonomerName",s={monomerType:null,smiles:null,name:"Name",author:null,molfile:"molecule",naturalAnalog:"MonomerNaturalAnalogCode",rgroups:"MonomerCaps",createDate:null,id:null,polymerType:"MonomerType",symbol:"MonomerName"},r={monomerType:"Backbone",smiles:"",name:"",author:"Datagrok",molfile:"",naturalAnalog:"",rgroups:[],createDate:null,id:0,polymerType:"PEPTIDE",symbol:""},a="p",l=new RegExp(`[rd]\\((\\w)\\)${a}?`,"g")},9192:(e,t,n)=>{"use strict";function i(e){return"string"==typeof e||e instanceof String?e:"StateError"===e.constructor.name?e.message:"StateError"===e.constructor.name&&"$thrownJsError"in e?i(e.$thrownJsError):e instanceof Error?e.message:e.toString()}function o(e){return e instanceof Error?e.stack:"StateError"===e.constructor.name&&"$thrownJsError"in e?o(e.$thrownJsError):void 0}function s(e){return[i(e),o(e)]}n.d(t,{AP:()=>s})},3516:(e,t,n)=>{"use strict";n.d(t,{m:()=>s});var i=n(6082),o=n(439);class s{get descriptionsArray(){return this._descriptionsArray}get sequencesArray(){return this._sequencesArray}parseMacromolecule(e,t){return this._fileContent.slice(e,t).split(/\s/).join("")}parseColumns(){const e=/^>(.*)$/gm;let t,n=0;for(;t=e.exec(this._fileContent);){const i=this._fileContent.substring(t.index+1,e.lastIndex);this._descriptionsArray.push(i),0!==n&&this._sequencesArray.push(this.parseMacromolecule(n,t.index)),n=e.lastIndex+1}this._sequencesArray.push(this.parseMacromolecule(n,-1))}importFasta(){const e=i.Column.fromStrings("description",this.descriptionsArray),t=i.Column.fromStrings("sequence",this.sequencesArray);return t.semType=i.SEMTYPE.MACROMOLECULE,t.meta.units=o.Hi.FASTA,[i.DataFrame.fromColumns([e,t])]}constructor(e){this._descriptionsArray=[],this._sequencesArray=[],this._fileContent=e,this.parseColumns()}}},6873:(e,t,n)=>{"use strict";n.d(t,{Hx:()=>h,dW:()=>u,fD:()=>c});var i=n(6082),o=n(1991),s=n.n(o),r=n(2003),a=n(7278),l=n(439);function c(){const e=[];return e.push(i.Column.fromList("string","MSA",new Array(10**6).fill("meI/hHis/Aca/N/T/dE/Thr_PO3H2/Aca/D-Tyr_Et/Tyr_ab-dehydroMe/dV/E/N/D-Orn/D-aThr//Phe_4Me"))),e.push(i.Column.fromList(i.COLUMN_TYPE.FLOAT,"Activity",new Array(10**6).fill(5.30751))),e}function u(e=10**5){const t="meI/hHis/Aca/N//dE/Thr_PO3H2/Aca/D-Tyr_Et/Tyr_ab-dehydroMe".repeat(Math.ceil(e/10)).slice(0,-1),n=i.Column.fromList(i.COLUMN_TYPE.STRING,"MSA",new Array(100).fill(t));n.semType=i.SEMTYPE.MACROMOLECULE,n.meta.units=r.Hi.SEPARATOR,n.setTag(r.gp.separator,"/"),n.setTag(r.gp.alphabet,r.YI.UN),n.setTag(r.gp.alphabetIsMultichar,"true");const o=[];return o.push(n),o.push(i.Column.fromList(i.COLUMN_TYPE.FLOAT,"Activity",new Array(100).fill(7.30751))),o}function h(e,t=r.Hi.SEPARATOR,n=r.YI.PT,o=(t===r.Hi.SEPARATOR?"-":void 0),c=void 0,u="seq",h=100,d=10**6){const p=n===r.YI.UN?c?.getMonomerSymbolsByType("PEPTIDE")??[]:Array.from((0,r.Qf)(n)),m=p.length,g=i.Column.fromType(i.COLUMN_TYPE.STRING,u,h);g.semType=i.SEMTYPE.MACROMOLECULE,g.meta.units=t,g.setTag(r.gp.alphabet,n),t==r.Hi.SEPARATOR&&g.setTag(r.gp.separator,o);const f=e.getSeqHandler(g);for(let e=0;e<h;e++){const n=s().count(0).take(d).map((e=>p[Math.floor(Math.random()*m)])).toArray(),i=f.joiner(new a.Mu(n,l.b9[t]));g.set(e,i)}return g}},439:(e,t,n)=>{"use strict";n.d(t,{B5:()=>l,Hi:()=>i,Vl:()=>c,YI:()=>o,_S:()=>h,b9:()=>d,gp:()=>s,ot:()=>p,q7:()=>u,z1:()=>a});var i,o,s,r=n(2738);!function(e){e.FASTA="fasta",e.SEPARATOR="separator",e.HELM="helm",e.CUSTOM="custom"}(i||(i={})),function(e){e.DNA="DNA",e.RNA="RNA",e.PT="PT",e.UN="UN"}(o||(o={})),function(e){e.aligned="aligned",e.alphabet="alphabet",e.alphabetSize=".alphabetSize",e.alphabetIsMultichar=".alphabetIsMultichar",e.separator="separator",e.isHelmCompatible=".isHelmCompatible",e.positionNames=".positionNames",e.positionLabels=".positionLabels",e.regions=".regions",e.positionShift=".positionShift",e.selectedPosition=".selectedPosition"}(s||(s={}));const a=", ",l=/(?:\[([A-Za-z0-9_\-,()]+)\])|([A-Za-z\-])/g,c=new class{constructor(){this.fasta={peptide:new Set(["G","L","Y","S","E","Q","D","N","F","A","K","R","H","C","V","P","W","I","M","T"]),dna:new Set(["A","C","G","T"]),rna:new Set(["A","C","G","U"])}}},u=[new r.a(o.PT,c.fasta.peptide,.5),new r.a(o.DNA,c.fasta.dna,.55),new r.a(o.RNA,c.fasta.rna,.55)],h="",d={[i.FASTA]:"-",[i.SEPARATOR]:"",[i.HELM]:"*"},p=" , "},2003:(e,t,n)=>{"use strict";n.d(t,{Hi:()=>i.Hi,J9:()=>o.J9,Qf:()=>o.Qf,SM:()=>o.SM,YI:()=>i.YI,dh:()=>o.dh,gp:()=>i.gp,mn:()=>o.mn,nq:()=>o.nq,q7:()=>i.q7,qp:()=>o.qp,z1:()=>i.z1,zS:()=>o.zS});var i=n(439),o=n(7278)},2738:(e,t,n)=>{"use strict";n.d(t,{X:()=>o,a:()=>i});class i{constructor(e,t,n){this.name=e,this.alphabet=t,this.cutoff=n}}class o extends i{constructor(e,t,n){super(e.name,e.alphabet,e.cutoff),this.freq=t,this.similarity=n}}},7278:(e,t,n)=>{"use strict";n.d(t,{Iv:()=>A,J9:()=>y,Mu:()=>m,Qf:()=>S,SM:()=>L,dh:()=>w,mn:()=>_,nq:()=>E,p0:()=>x,pc:()=>M,qp:()=>v,tm:()=>b,vZ:()=>f,zS:()=>T});var i=n(6082),o=n(1991),s=n.n(o),r=n(3527),a=n(3629),l=n(2738),c=n(439),u=n(8924),h=n(1093),d=n(4152),p=n(8438);class m{get length(){return this.mList.length}isGap(e){return this.getOriginal(e)===this.gapOriginalMonomer}getCanonical(e){if(this.length<=e)throw new Error("Index out of bounds");const t=this.mList[e];return t!==this.gapOriginalMonomer?t:c._S}getOriginal(e){if(this.length<=e)throw new Error("Index out of bounds");return this.mList[e]}getCanonicalRegion(e,t){const n=Math.min(Math.max(0,e),this.length),i=Math.max(Math.min(this.length,t),0)-n,o=this.gapOriginalMonomer;return new Array(i).fill(null).map(((e,t)=>{const i=this.mList[t+n];return i===o?c._S:i}))}getOriginalRegion(e,t){const n=Math.min(Math.max(0,e),this.length),i=Math.max(Math.min(this.length,t),0);return new Array(i-n).fill(null).map(((e,t)=>this.mList[t+n]))}get gapOriginal(){return this.gapOriginalMonomer}constructor(e,t){this.mList=e,this.gapOriginalMonomer=t}}class g{get length(){return this.seqS.length}isGap(e){return this.getOriginal(e)===c.b9[c.Hi.FASTA]}getCanonical(e){if(this.length<=e)throw new Error("Index out of bounds");return this.isGap(e)?c._S:this.seqS[e]}getOriginal(e){if(this.length<=e)throw new Error("Index out of bounds");return this.seqS[e]}getCanonicalRegion(e,t){const n=Math.max(0,e),i=Math.min(this.length,t)-n,o=c.b9[c.Hi.FASTA];return new Array(i).fill(null).map(((e,t)=>{const i=this.seqS[t+n];return i===o?c._S:i}))}getOriginalRegion(e,t){const n=Math.max(0,e),i=Math.min(this.length,t);return this.seqS.slice(n,i)}get gapOriginal(){return c.b9[c.Hi.FASTA]}constructor(e){this.seqS=e}}function f(e,t,n){const i=e.categories;return function(e,t){const n={};let i=!0,o=null;for(const s of e)if(null==o?o=s.length:s.length!==o&&(i=!1),s.length>=t)for(let e=0;e<s.length;++e){const t=s.getCanonical(e);t in n||(n[t]=0),n[t]+=1}return{freq:n,sameLength:i}}(s().enumerate(e.getRawData()).map((([e,t])=>n(i[e]))),t)}const y=e=>{const t=s()(e.toString().matchAll(c.B5)).map((e=>e[2]??e[1])).toArray();return new m(t,c.b9[c.Hi.FASTA])},b=e=>e?new g(e):new m([],c.b9[c.Hi.FASTA]);function w(e,t=void 0){return n=>{if(n){let i;const o=new RegExp(`(?<=^|\\${e})("-"|'-'|[^\\${e}]*)(?=\\${e}|$)`,"g");return void 0!==t?(o.lastIndex=0,i=s()(n.matchAll(o)).take(t).map((e=>e[0])).toArray()):i=n.replaceAll('"-"',"").replaceAll("'-'","").split(e,t),new m(i,c.b9[c.Hi.SEPARATOR])}return new m([],c.b9[c.Hi.SEPARATOR])}}const v=e=>{const t=e.split("$")[0].split("|"),n=s()(t.map((e=>(e.match(/(?<=\{).+(?=})/)?.[0]?.split(".")??[]).map((e=>(0,p.D)(e)))))).flatten().toArray();return new m(n,c.b9[c.Hi.HELM])};function A(e,t,n=void 0){if(e.toLowerCase().startsWith(c.Hi.FASTA))return y;if(e.toLowerCase().startsWith(c.Hi.SEPARATOR))return w(t,n);if(e.toLowerCase().startsWith(c.Hi.HELM))return v;throw new Error(`Unexpected units ${e} .`)}const C=/([^\W_]+)/g;function T(e,t){if(e.length<=t)return e;const n=e.match(C),i=e.length>t||(n?.length??0)>1,o=n?.[0]??" ";return i?o.substring(0,t-1)+"…":o}function S(e){switch(e){case c.YI.DNA:return c.Vl.fasta.dna;case c.YI.RNA:return c.Vl.fasta.rna;case c.YI.PT:return c.Vl.fasta.peptide;default:throw new Error(`Unsupported alphabet '${e}'.`)}}function E(e,t,n="-"){const i=new Set([...new Set(Object.keys(e)),...t]);i.delete(n);const o=[],s=[];for(const n of i)o.push(n in e?e[n]:0),s.push(t.has(n)?1:0);const l=new r.Mi(o),c=new r.Mi(s);return(0,a.KE)(l,c)/((0,a.wQ)(l)*(0,a.wQ)(c))}function M(e,t,n="-"){const i=t.map((t=>{const i=E(e,t.alphabet,n);return new l.X(t,e,i)}));let o;const s=Math.max(...i.map((e=>e.similarity>e.cutoff?e.similarity:-1)));return o=s>0?i.find((e=>e.similarity===s)).name:c.YI.UN,o}function x(e,t,n="-"){const i=Object.keys(e),o=/\(|\)/;return M(i.filter((e=>3===e.split(o).filter((e=>!!e)).length)).length>.8*i.length?Object.entries(e).reduce(((e,[t,n])=>{const i=t.split(o)[1];return i&&(e[i]=n),e}),{}):e,t,n)}function L(e,t,n=5){let o;return o=e.semType==i.SEMTYPE.MACROMOLECULE?t.getSeqHandler(e).alphabet:M(f(e,n,y).freq,c.q7),function(e){switch(e){case c.YI.PT:return u.X.GrokGroups;case c.YI.DNA:case c.YI.RNA:return h.A.Chromatogram;default:return d.oT.Color}}(o)}function _(e){const t=e.columns.bySemTypeAll(i.SEMTYPE.MACROMOLECULE);let n=t.find((e=>{const t=e.meta.units;return!!t&&-1!==t.indexOf("MSA")}))??null;return!n&&t.length>0&&(n=t[0]),n}},8312:(e,t,n)=>{"use strict";n.d(t,{Q:()=>o});var i=n(6082);async function o(){const e=i.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()}},3077:(e,t,n)=>{"use strict";n.d(t,{R:()=>o});var i=n(6082);function o(e,t){const n=e=>{const t=r.columns.addNewString((e+1).toString());return o.push(t),t},o=[],s=e.length,r=i.DataFrame.create(s),a=t.getSeqHandler(e);for(let e=0;e<s;++e){const t=a.getSplitted(e);for(let i=0;i<t.length;++i){const s=t.getCanonical(i);((o[i]??null)||n(i)).set(e,s,!1)}}return r}},7602:(e,t,n)=>{"use strict";n.d(t,{g:()=>s});var i,o=n(9192);!function(e){e[e.error=0]="error",e[e.warning=1]="warning",e[e.info=2]="info",e[e.debug=3]="debug"}(i||(i={}));class s{constructor(e){this.logger=e,this.promise=Promise.resolve(),this.errors=[],this.syncCounter=0}sync(e,t){const n=++this.syncCounter;this.logger.debug(`${e}, SYNC syncId = ${n}, IN `),this.promise=this.promise.then((async()=>{this.logger.debug(`${e}, SYNC syncId = ${n}, START `),await t(),this.logger.debug(`${e}, SYNC syncId = ${n}, END `)})).catch((t=>{const[i,s]=(0,o.AP)(t);this.logger.error(`${e}, SYNC syncId = ${n}, ERROR:\n${i}`,void 0,s),this.errors.push(t)}))}resetErrors(){const e=this.errors;return this.errors=[],e}}},4326:(e,t,n)=>{"use strict";n.d(t,{Fo:()=>u,Lp:()=>s,P4:()=>r,fH:()=>o,gp:()=>i,lT:()=>l,mH:()=>a});var i,o,s,r,a,l,c=n(6082);!function(e){e.tooltipWebLogo=".tooltipWebLogo"}(i||(i={})),function(e){e.Entropy="Entropy",e.full="100%"}(o||(o={})),function(e){e.TOP="top",e.MIDDLE="middle",e.BOTTOM="bottom"}(s||(s={})),function(e){e.LEFT="left",e.CENTER="center",e.RIGHT="right"}(r||(r={})),function(e){e.AUTO="auto",e.ON="on",e.OFF="off"}(a||(a={})),function(e){e.Filtered="Filtered",e.Selected="Selected"}(l||(l={}));const u=new class{constructor(){this.sequenceColumnName=null,this.valueAggrType=c.AGG.TOTAL_COUNT,this.valueColumnName="Activity",this.startPositionName=null,this.endPositionName=null,this.skipEmptySequences=!0,this.skipEmptyPositions=!1,this.shrinkEmptyTail=!0,this.backgroundColor=4294967295,this.positionHeight=o.Entropy,this.positionWidth=20,this.verticalAlignment=s.MIDDLE,this.horizontalAlignment=r.CENTER,this.fixWidth=!1,this.fitArea=!0,this.minHeight=25,this.maxHeight=300,this.maxMonomerLetters=5,this.showPositionLabels=!0,this.positionMarginState=a.AUTO,this.positionMargin=0,this.filterSource=l.Filtered}}},6869:(e,t,n)=>{"use strict";var i;n.d(t,{o:()=>i}),function(e){e.BASE="HELM_BASE",e.SUGAR="HELM_SUGAR",e.LINKER="HELM_LINKER",e.AA="HELM_AA",e.CHEM="HELM_CHEM",e.BLOB="HELM_BLOB",e.NUCLEOTIDE="HELM_NUCLETIDE"}(i||(i={}))},5540:(e,t,n)=>{"use strict";e=n.hmd(e);var i,o=(i="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0,function(e={}){var t,n,o=void 0!==e?e:{};o.ready=new Promise((function(e,i){t=e,n=i}));var s,r=Object.assign({},o),a="object"==typeof window,l="function"==typeof importScripts,c=("object"==typeof process&&"object"==typeof process.versions&&process.versions.node,"");(a||l)&&(l?c=self.location.href:"undefined"!=typeof document&&document.currentScript&&(c=document.currentScript.src),i&&(c=i),c=0!==c.indexOf("blob:")?c.substr(0,c.replace(/[?#].*/,"").lastIndexOf("/")+1):"",l&&(s=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)})),o.print||console.log.bind(console);var u,h,d=o.printErr||console.warn.bind(console);Object.assign(o,r),r=null,o.arguments&&o.arguments,o.thisProgram&&o.thisProgram,o.quit&&o.quit,o.wasmBinary&&(u=o.wasmBinary),o.noExitRuntime,"object"!=typeof WebAssembly&&M("no native wasm support detected");var p,m,g,f=!1;function y(){var e=h.buffer;o.HEAP8=p=new Int8Array(e),o.HEAP16=new Int16Array(e),o.HEAP32=new Int32Array(e),o.HEAPU8=m=new Uint8Array(e),o.HEAPU16=new Uint16Array(e),o.HEAPU32=g=new Uint32Array(e),o.HEAPF32=new Float32Array(e),o.HEAPF64=new Float64Array(e)}var b,w,v=[],A=[],C=[],T=0,S=null,E=null;function M(e){o.onAbort&&o.onAbort(e),d(e="Aborted("+e+")"),f=!0,e+=". Build with -sASSERTIONS for more info.";var t=new WebAssembly.RuntimeError(e);throw n(t),t}function x(e){return e.startsWith("data:application/octet-stream;base64,")}function L(e){try{if(e==b&&u)return new Uint8Array(u);if(s)return s(e);throw"both async and sync fetching of the wasm failed"}catch(e){M(e)}}function _(e,t,n){return function(e){return u||!a&&!l||"function"!=typeof fetch?Promise.resolve().then((function(){return L(e)})):fetch(e,{credentials:"same-origin"}).then((function(t){if(!t.ok)throw"failed to load wasm binary file at '"+e+"'";return t.arrayBuffer()})).catch((function(){return L(e)}))}(e).then((function(e){return WebAssembly.instantiate(e,t)})).then((function(e){return e})).then(n,(function(e){d("failed to asynchronously prepare wasm: "+e),M(e)}))}function I(e){for(;e.length>0;)e.shift()(o)}function P(e){this.excPtr=e,this.ptr=e-24,this.set_type=function(e){g[this.ptr+4>>2]=e},this.get_type=function(){return g[this.ptr+4>>2]},this.set_destructor=function(e){g[this.ptr+8>>2]=e},this.get_destructor=function(){return g[this.ptr+8>>2]},this.set_caught=function(e){e=e?1:0,p[this.ptr+12|0]=e},this.get_caught=function(){return 0!=p[this.ptr+12|0]},this.set_rethrown=function(e){e=e?1:0,p[this.ptr+13|0]=e},this.get_rethrown=function(){return 0!=p[this.ptr+13|0]},this.init=function(e,t){this.set_adjusted_ptr(0),this.set_type(e),this.set_destructor(t)},this.set_adjusted_ptr=function(e){g[this.ptr+16>>2]=e},this.get_adjusted_ptr=function(){return g[this.ptr+16>>2]},this.get_exception_ptr=function(){if(B(this.get_type()))return g[this.excPtr>>2];var e=this.get_adjusted_ptr();return 0!==e?e:this.excPtr}}function N(e){var t=h.buffer;try{return h.grow(e-t.byteLength+65535>>>16),y(),1}catch(e){}}function R(e){return o["_"+e]}x(b="wasmDbscan.wasm")||(w=b,b=o.locateFile?o.locateFile(w,c):c+w);var $="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function O(e,t,n,i,o){var s={string:e=>{var t=0;return null!=e&&0!==e&&(t=function(e){var t=function(e){for(var t=0,n=0;n<e.length;++n){var i=e.charCodeAt(n);i<=127?t++:i<=2047?t+=2:i>=55296&&i<=57343?(t+=4,++n):t+=3}return t}(e)+1,n=G(t);return function(e,t,n){!function(e,t,n,i){if(!(i>0))return 0;for(var o=n+i-1,s=0;s<e.length;++s){var r=e.charCodeAt(s);if(r>=55296&&r<=57343&&(r=65536+((1023&r)<<10)|1023&e.charCodeAt(++s)),r<=127){if(n>=o)break;t[n++]=r}else if(r<=2047){if(n+1>=o)break;t[n++]=192|r>>6,t[n++]=128|63&r}else if(r<=65535){if(n+2>=o)break;t[n++]=224|r>>12,t[n++]=128|r>>6&63,t[n++]=128|63&r}else{if(n+3>=o)break;t[n++]=240|r>>18,t[n++]=128|r>>12&63,t[n++]=128|r>>6&63,t[n++]=128|63&r}}t[n]=0}(e,m,t,n)}(e,n,t),n}(e)),t},array:e=>{var t,n,i=G(e.length);return t=e,n=i,p.set(t,n),i}},r=R(e),a=[],l=0;if(i)for(var c=0;c<i.length;c++){var u=s[n[c]];u?(0===l&&(l=F()),a[c]=u(i[c])):a[c]=i[c]}var h=r.apply(null,a);return function(e){return 0!==l&&D(l),function(e){return"string"===t?(n=e)?function(e,t,n){for(var i=t+n,o=t;e[o]&&!(o>=i);)++o;if(o-t>16&&e.buffer&&$)return $.decode(e.subarray(t,o));for(var s="";t<o;){var r=e[t++];if(128&r){var a=63&e[t++];if(192!=(224&r)){var l=63&e[t++];if((r=224==(240&r)?(15&r)<<12|a<<6|l:(7&r)<<18|a<<12|l<<6|63&e[t++])<65536)s+=String.fromCharCode(r);else{var c=r-65536;s+=String.fromCharCode(55296|c>>10,56320|1023&c)}}else s+=String.fromCharCode((31&r)<<6|a)}else s+=String.fromCharCode(r)}return s}(m,n,i):"":"boolean"===t?Boolean(e):e;var n,i}(e)}(h)}var H,k={__cxa_throw:function(e,t,n){throw new P(e).init(t,n),e},abort:function(){M("")},emscripten_memcpy_big:function(e,t,n){m.copyWithin(e,t,t+n)},emscripten_resize_heap:function(e){var t,n=m.length,i=2147483648;if((e>>>=0)>i)return!1;for(var o=1;o<=4;o*=2){var s=n*(1+.2/o);if(s=Math.min(s,e+100663296),N(Math.min(i,(t=Math.max(e,s))+(65536-t%65536)%65536)))return!0}return!1}},F=(function(){var e,t,i,s,r={env:k,wasi_snapshot_preview1:k};function a(e,t){var n,i=e.exports;return o.asm=i,h=o.asm.memory,y(),o.asm.__indirect_function_table,n=o.asm.__wasm_call_ctors,A.unshift(n),function(){if(T--,o.monitorRunDependencies&&o.monitorRunDependencies(T),0==T&&(null!==S&&(clearInterval(S),S=null),E)){var e=E;E=null,e()}}(),i}if(T++,o.monitorRunDependencies&&o.monitorRunDependencies(T),o.instantiateWasm)try{return o.instantiateWasm(r,a)}catch(e){d("Module.instantiateWasm callback failed with error: "+e),n(e)}(e=u,t=b,i=r,s=function(e){a(e.instance)},e||"function"!=typeof WebAssembly.instantiateStreaming||x(t)||"function"!=typeof fetch?_(t,i,s):fetch(t,{credentials:"same-origin"}).then((function(e){return WebAssembly.instantiateStreaming(e,i).then(s,(function(e){return d("wasm streaming compile failed: "+e),d("falling back to ArrayBuffer instantiation"),_(t,i,s)}))}))).catch(n)}(),o._dbscan=function(){return(o._dbscan=o.asm.dbscan).apply(null,arguments)},o._malloc=function(){return(o._malloc=o.asm.malloc).apply(null,arguments)},o._free=function(){return(o._free=o.asm.free).apply(null,arguments)},function(){return(F=o.asm.stackSave).apply(null,arguments)}),D=function(){return(D=o.asm.stackRestore).apply(null,arguments)},G=function(){return(G=o.asm.stackAlloc).apply(null,arguments)},B=function(){return(B=o.asm.__cxa_is_pointer_type).apply(null,arguments)};function V(){function e(){H||(H=!0,o.calledRun=!0,f||(I(A),t(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),function(){if(o.postRun)for("function"==typeof o.postRun&&(o.postRun=[o.postRun]);o.postRun.length;)e=o.postRun.shift(),C.unshift(e);var e;I(C)}()))}T>0||(function(){if(o.preRun)for("function"==typeof o.preRun&&(o.preRun=[o.preRun]);o.preRun.length;)e=o.preRun.shift(),v.unshift(e);var e;I(v)}(),T>0||(o.setStatus?(o.setStatus("Running..."),setTimeout((function(){setTimeout((function(){o.setStatus("")}),1),e()}),1)):e()))}if(o.ccall=O,o.cwrap=function(e,t,n,i){var o=!n||n.every((e=>"number"===e||"boolean"===e));return"string"!==t&&o&&!i?R(e):function(){return O(e,t,n,arguments)}},E=function e(){H||V(),H||(E=e)},o.preInit)for("function"==typeof o.preInit&&(o.preInit=[o.preInit]);o.preInit.length>0;)o.preInit.pop()();return V(),e.ready});"object"==typeof exports?e.exports=o:"function"==typeof define&&n.amdO?define([],(function(){return o})):"object"==typeof exports&&(exports.exportCppDbscanLib=o)},6295:(e,t,n)=>{"use strict";n.d(t,{$1:()=>r,Hf:()=>u,Hr:()=>E,Ii:()=>f,Qj:()=>m,T6:()=>S,TK:()=>C,be:()=>g,gt:()=>w,ij:()=>v,jL:()=>c,lO:()=>p,lP:()=>b,rR:()=>y,tO:()=>a,v_:()=>l,w_:()=>h,yK:()=>A,zn:()=>d});var i=n(8774),o=n(8498),s=n(6863);function r(e,t){const n=e.trueCount()+t.trueCount();if(0==n)return 1;const i=e.andWithCountBits(t,!0);return i/(n-i)}function a(e,t){return 1-r(e,t)}function l(e,t){return T(r(new i.A(e,32*e.length),new i.A(t,32*t.length)))}function c(e,t){let n=0;for(let i=0;i<e.length;i++)n+=Math.pow(e[i]-t[i],2);return Math.sqrt(n)}function u(e,t){let n=0;for(let i=0;i<e.length;i++)n+=Math.abs(e[i]-t[i]);return n}function h(e,t){let n=0,i=0,o=0;for(let s=0;s<e.length;s++)n+=e[s]*t[s],i+=e[s]*e[s],o+=t[s]*t[s];return(1-n/(Math.sqrt(i)*Math.sqrt(o)))/2}function d(e,t){return 1-function(e,t){const n=e.trueCount()+t.trueCount();return 0==n?0:2*e.andWithCountBits(t,!0)/n}(e,t)}function p(e,t){return 1-function(e,t){const n=e.trueCount()*t.trueCount();return 0==n?0:e.andWithCountBits(t,!0)/Math.sqrt(n)}(e,t)}function m(e,t){return Math.sqrt(e.trueCount()+t.trueCount()-2*e.andWithCountBits(t,!0))}function g(e,t){return e.trueCount()+t.trueCount()-2*e.andWithCountBits(t,!0)}function f(e,t){return 1-function(e,t){const n=e.trueCount()+t.trueCount(),i=e.andWithCountBits(t,!0);return i/(2*n-3*i)}(e,t)}function y(e,t){return T(function(e,t){const n=e.trueCount()+t.trueCount(),i=e.trueCount()*t.trueCount();return 0==i?0:e.andWithCountBits(t,!0)*n/(2*i)}(e,t))}function b(e,t){return T(function(e,t){const n=e.trueCount()+t.trueCount(),i=e.trueCount()*t.trueCount();return 0==i?0:(e.andWithCountBits(t,!0)*n-i)/i}(e,t))}function w(e,t){return 1-function(e,t){const n=Math.min(e.trueCount(),t.trueCount());return 0==n?0:e.andWithCountBits(t,!0)/n}(e,t)}function v(e,t){return T(function(e,t){const n=Math.max(e.trueCount(),t.trueCount());return 0==n?0:e.andWithCountBits(t,!0)/n}(e,t))}function A(e,t){return T(function(e,t){return 0==e.length?0:e.andWithCountBits(t,!0)/e.length}(e,t))}function C(e,t){return T(function(e,t){const n=e.andWithCountBits(t,!0),i=e.countBits(!0)+t.countBits(!0),o=e.length,s=o-i+n;return n==o||s==o?1:n/i+s/(2*o-i)}(e,t))}function T(e){return e<=0?3402823e32:1/e-1}function S(e){if(e&&null!=e.range&&e.range>0){const t=e.range;return(e,n)=>Math.abs(e-n)/t}return(e,t)=>Math.abs(e-t)}function E(e){const t=function(e){const t=e?.mostCommon??new Set;return(e,n)=>{const i=e.length,o=n.length;let s=0,r=0,a=0;for(;r<i&&a<o;)e[r]===n[a]?(t?.has(e[r])||++s,++r,++a):e[r]<n[a]?++r:++a;return s}}(e);return(e,n)=>0===n.length||0===e.length?1e4:Math.min(e.length,n.length)/(t(e,n)+1e-4)}o.aT.Tanimoto,o.aT.Dice,o.aT.Asymmetric,o.aT.BraunBlanquet,o.aT.Cosine,o.aT.Kulczynski,o.aT.McConnaughey,o.aT.RogotGoldberg,o.aT.Russel,o.aT.Sokal,o.aT.Hamming,o.aT.Euclidean,o.aT.Tanimoto,o.aT.Dice,o.aT.Asymmetric,o.aT.BraunBlanquet,o.aT.Cosine,o.aT.Kulczynski,o.aT.McConnaughey,o.aT.RogotGoldberg,o.aT.Russel,o.aT.Sokal,o.aT.Hamming,o.aT.Euclidean,o.aT.Tanimoto,o.aT.Dice,o.aT.Cosine,o.aT.Tanimoto,o.aT.Asymmetric,o.aT.Cosine,o.aT.Sokal,s.Z.HAMMING,s.Z.LEVENSHTEIN,s.Z.MONOMER_CHEMICAL_DISTANCE,s.Z.NEEDLEMANN_WUNSCH},684:(e,t,n)=>{"use strict";n.d(t,{C0:()=>s,GP:()=>i,Gi:()=>a,YP:()=>c,_X:()=>r,n3:()=>o,vb:()=>l});const i="dim-red-preprocessing-function",o="supportedSemTypes",s="supportedTypes",r="supportedUnits",a="supportedDistanceFunctions",l="bypassLargeDataWarning",c="show-scatterplot-progress"},6863:(e,t,n)=>{"use strict";function i(e={}){const t=function(){if(!e||!e.scoringMatrix||!e.alphabetIndexes)return(e,t)=>e===t?0:1;if(e.scoringMatrix.length!==Object.keys(e.alphabetIndexes).length)throw new Error("Scoring matrix and alphabet indexes should have the same length");const t=e.alphabetIndexes,n=e.scoringMatrix,i=Math.min(...Object.keys(t).map((e=>e.charCodeAt(0))))+1,o=new Float32Array((n.length+i)*(n.length+i));return Object.entries(t).forEach((([e,i])=>{const s=n[i];Object.entries(t).forEach((([t,i])=>{o[e.charCodeAt(0)*n.length+t.charCodeAt(0)]=s[i]}))})),(e,t)=>1-o[e.charCodeAt(0)*n.length+t.charCodeAt(0)]}(),n=e?.threshold??0;return(e,i)=>{let o=0;const s=e.length,r=i.length,a=Math.ceil(Math.max(s,r)*(1-n));s!==r&&(o=Math.abs(s-r));let l=0;for(let n=0;n<Math.min(s,r);n++)if(e[n]!==i[n]&&(l+=t(e[n],i[n]),l>a))return 1;return l+=o,l/=Math.max(s,r),l}}n.d(t,{Z:()=>r,V:()=>a});var o=n(2787);const s={gapOpen:1,gapExtend:.6,scoringMatrix:[[4,-1,-2,-2,0,-1,-1,0,-2,-1,-1,-1,-1,-2,-1,1,0,-3,-2,0,-2,-1,0,-4],[-1,5,0,-2,-3,1,0,-2,0,-3,-2,2,-1,-3,-2,-1,-1,-3,-2,-3,-1,0,-1,-4],[-2,0,6,1,-3,0,0,0,1,-3,-3,0,-2,-3,-2,1,0,-4,-2,-3,3,0,-1,-4],[-2,-2,1,6,-3,0,2,-1,-1,-3,-4,-1,-3,-3,-1,0,-1,-4,-3,-3,4,1,-1,-4],[0,-3,-3,-3,9,-3,-4,-3,-3,-1,-1,-3,-1,-2,-3,-1,-1,-2,-2,-1,-3,-3,-2,-4],[-1,1,0,0,-3,5,2,-2,0,-3,-2,1,0,-3,-1,0,-1,-2,-1,-2,0,3,-1,-4],[-1,0,0,2,-4,2,5,-2,0,-3,-3,1,-2,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-2,0,-1,-3,-2,-2,6,-2,-4,-4,-2,-3,-3,-2,0,-2,-2,-3,-3,-1,-2,-1,-4],[-2,0,1,-1,-3,0,0,-2,8,-3,-3,-1,-2,-1,-2,-1,-2,-2,2,-3,0,0,-1,-4],[-1,-3,-3,-3,-1,-3,-3,-4,-3,4,2,-3,1,0,-3,-2,-1,-3,-1,3,-3,-3,-1,-4],[-1,-2,-3,-4,-1,-2,-3,-4,-3,2,4,-2,2,0,-3,-2,-1,-2,-1,1,-4,-3,-1,-4],[-1,2,0,-1,-3,1,1,-2,-1,-3,-2,5,-1,-3,-1,0,-1,-3,-2,-2,0,1,-1,-4],[-1,-1,-2,-3,-1,0,-2,-3,-2,1,2,-1,5,0,-2,-1,-1,-1,-1,1,-3,-1,-1,-4],[-2,-3,-3,-3,-2,-3,-3,-3,-1,0,0,-3,0,6,-4,-2,-2,1,3,-1,-3,-3,-1,-4],[-1,-2,-2,-1,-3,-1,-1,-2,-2,-3,-3,-1,-2,-4,7,-1,-1,-4,-3,-2,-2,-1,-2,-4],[1,-1,1,0,-1,0,0,0,-1,-2,-2,0,-1,-2,-1,4,1,-3,-2,-2,0,0,0,-4],[0,-1,0,-1,-1,-1,-1,-2,-2,-1,-1,-1,-1,-2,-1,1,5,-2,-2,0,-1,-1,0,-4],[-3,-3,-4,-4,-2,-2,-3,-2,-2,-3,-2,-3,-1,1,-4,-3,-2,11,2,-3,-4,-3,-2,-4],[-2,-2,-2,-3,-2,-1,-2,-3,2,-1,-1,-2,-1,3,-3,-2,-2,2,7,-1,-3,-2,-1,-4],[0,-3,-3,-3,-1,-2,-2,-3,-3,3,1,-2,1,-1,-2,-2,0,-3,-1,4,-3,-2,-1,-4],[-2,-1,3,4,-3,0,1,-1,0,-3,-4,0,-3,-3,-2,0,-1,-4,-3,-3,4,1,-1,-4],[-1,0,0,1,-3,3,4,-2,0,-3,-3,1,-1,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-1,-1,-1,-2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-2,0,0,-2,-1,-1,-1,-1,-1,-4],[-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,1]],alphabetIndexes:{A:0,R:1,N:2,D:3,C:4,Q:5,E:6,G:7,H:8,I:9,L:10,K:11,M:12,F:13,P:14,S:15,T:16,W:17,Y:18,V:19,B:20,Z:21,X:22,"*":23}};var r;!function(e){e.HAMMING="Hamming",e.LEVENSHTEIN="Levenshtein",e.NEEDLEMANN_WUNSCH="Needlemann-Wunsch",e.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance"}(r||(r={}));const a={[r.HAMMING]:i,[r.LEVENSHTEIN]:function(){return(e,t)=>(0,o.I)(e,t)/Math.max(e.length,t.length)},[r.NEEDLEMANN_WUNSCH]:function(e){const t=new Uint16Array(65536),{gapOpen:n,gapExtend:i,scoringMatrix:o,alphabetIndexes:r}={...s,...e};Object.entries(r).forEach((([e,n])=>t[e.charCodeAt(0)]=n));const a=[new Float32Array(1e4),new Float32Array(1e4)];return(e,s)=>{const r=new Array(e.length+1).fill(!1),l=new Array(e.length+1).fill(!1);let c=0,u=1;for(let t=1;t<e.length+1;t++)a[0][t]=-i-(t-1)*i,a[1][t]=0;a[0][0]=0;for(let h=1;h<s.length+1;h++){a[u][0]=-i-(h-1)*i;for(let d=1;d<e.length+1;d++){const p=a[c][d-1]+o[t[e.charCodeAt(d-1)]][t[s.charCodeAt(h-1)]],m=a[c][d]-(r[d]||1===h||h===s.length?i:n),g=a[u][d-1]-(l[d-1]||1===d||d===e.length?i:n);a[u][d]=Math.max(p,g,m),a[u][d]===p?(r[d]=!1,l[d]=!1):a[u][d]===g?(r[d]=!1,l[d]=!0):(r[d]=!0,l[d]=!1)}c=u,u=(u+1)%2}const h=Math.min(e.length,s.length);return(h-a[c][e.length])/h}},[r.MONOMER_CHEMICAL_DISTANCE]:i}},9039:(e,t,n)=>{"use strict";var i;n.d(t,{c:()=>i}),function(e){e.UMAP="UMAP",e.T_SNE="t-SNE"}(i||(i={}))},8498:(e,t,n)=>{"use strict";var i,o,s,r,a,l,c;n.d(t,{EG:()=>a,Pn:()=>o,RR:()=>l,Wn:()=>c,aT:()=>s,m6:()=>r,xL:()=>i}),function(e){e.Levenshtein="Levenshtein",e.JaroWinkler="Jaro-Winkler",e.Manhattan="Manhattan String",e.Onehot="One-Hot"}(i||(i={})),function(e){e.Euclidean="Euclidean",e.Manhattan="Manhattan",e.Cosine="Vector Cosine"}(o||(o={})),function(e){e.Tanimoto="Tanimoto",e.Dice="Dice",e.Asymmetric="Asymmetric",e.BraunBlanquet="Braun-Blanquet",e.Cosine="Cosine",e.Kulczynski="Kulczynski",e.McConnaughey="Mc-Connaughey",e.RogotGoldberg="Rogot-Goldberg",e.Russel="Russel",e.Sokal="Sokal",e.Hamming="Hamming",e.Euclidean="Euclidean BitArray"}(s||(s={})),function(e){e.TanimotoIntArray="TanimotoIntArray"}(r||(r={})),function(e){e.Vector="Vector",e.String="String",e.BitArray="BitArray",e.MacroMolecule="MacroMolecule",e.Number="Number",e.IntArray="IntArray",e.NumberArray="NumberArray"}(a||(a={})),function(e){e.Difference="Difference"}(l||(l={})),function(e){e.CommonItems="Common Items"}(c||(c={}))},2780:(e,t,n)=>{"use strict";n.d(t,{aT:()=>i.aT});var i=n(8498);n(9336)},9336:(e,t,n)=>{"use strict";var i=n(2787),o=n(944),s=n(6295),r=n(6863),a=n(8498);const l={[a.Pn.Euclidean]:s.jL,[a.Pn.Manhattan]:s.Hf,[a.Pn.Cosine]:s.w_},c={[a.xL.Levenshtein]:i.I,[a.xL.JaroWinkler]:o.Vb,[a.xL.Manhattan]:function(e,t){if(e.length!==t.length)return 1;{let n=0;for(let i=1;i<e.length;i++)n+=e[i]==t[i]?0:1;return n/e.length}},[a.xL.Onehot]:function(e,t){return e===t?0:1}},u={[a.aT.Tanimoto]:s.tO,[a.aT.Dice]:s.zn,[a.aT.Asymmetric]:s.gt,[a.aT.BraunBlanquet]:s.ij,[a.aT.Cosine]:s.lO,[a.aT.Kulczynski]:s.rR,[a.aT.McConnaughey]:s.lP,[a.aT.RogotGoldberg]:s.TK,[a.aT.Russel]:s.yK,[a.aT.Sokal]:s.Ii,[a.aT.Hamming]:s.be,[a.aT.Euclidean]:s.Qj},h={[a.m6.TanimotoIntArray]:s.v_},d={[a.RR.Difference]:s.T6},p={[a.Wn.CommonItems]:s.Hr},m={[a.EG.Vector]:{[a.Pn.Euclidean]:l[a.Pn.Euclidean],[a.Pn.Manhattan]:l[a.Pn.Manhattan],[a.Pn.Cosine]:l[a.Pn.Cosine]},[a.EG.String]:{[a.xL.Levenshtein]:c[a.xL.Levenshtein],[a.xL.JaroWinkler]:c[a.xL.JaroWinkler],[a.xL.Manhattan]:c[a.xL.Manhattan],[a.xL.Onehot]:c[a.xL.Onehot]},[a.EG.BitArray]:{[a.aT.Tanimoto]:u[a.aT.Tanimoto],[a.aT.Dice]:u[a.aT.Dice],[a.aT.Asymmetric]:u[a.aT.Asymmetric],[a.aT.BraunBlanquet]:u[a.aT.BraunBlanquet],[a.aT.Cosine]:u[a.aT.Cosine],[a.aT.Kulczynski]:u[a.aT.Kulczynski],[a.aT.McConnaughey]:u[a.aT.McConnaughey],[a.aT.RogotGoldberg]:u[a.aT.RogotGoldberg],[a.aT.Russel]:u[a.aT.Russel],[a.aT.Sokal]:u[a.aT.Sokal]},[a.EG.MacroMolecule]:{[r.Z.HAMMING]:r.V[r.Z.HAMMING],[r.Z.LEVENSHTEIN]:r.V[r.Z.LEVENSHTEIN],[r.Z.NEEDLEMANN_WUNSCH]:r.V[r.Z.NEEDLEMANN_WUNSCH],[r.Z.MONOMER_CHEMICAL_DISTANCE]:r.V[r.Z.MONOMER_CHEMICAL_DISTANCE]},[a.EG.Number]:{[a.RR.Difference]:d[a.RR.Difference]},[a.EG.IntArray]:{[a.m6.TanimotoIntArray]:h[a.m6.TanimotoIntArray]},[a.EG.NumberArray]:{[a.Wn.CommonItems]:p[a.Wn.CommonItems]}};Object.keys(m).reduce(((e,t)=>{for(const n of Object.keys(m[t]))e[n]=t;return e}),{})},8774:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});class i{constructor(e,t=!1){if(this._length=0,this._version=0,this._updateLevel=0,this._selectedCount=0,this._selectedCountVersion=-1,this._selectedIndexesVersion=-1,this._versionedName="",this._versionedNameVersion=-1,this.SHRINK_THRESHOLD=256,"number"==typeof e){const n=e,o=i._createBuffer(n);if(t)for(let e=0;e<o.length;e++)o[e]=-1;this._data=o,this._length=n}else{if(!(e instanceof Uint32Array))throw new Error("Invalid constructor");this._data=e,this._length=t}}getRawData(){return this._data}assureGoez(e,t){if(e<0)throw new Error(`${t} should be greater than zero`)}assureInRange(e,t,n,i){if(e<t||e>n)throw new Error(`Argument ${i} (${e}) out of range (${t}, ${n})`)}copy(e,t,n){for(let i=0;i<n;i++)t[i]=e[i]}copyFrom(e){if(this._length!=e._length)throw new Error(`Lengths differ (${this._length} != ${e._length})`);this.copy(e._data,this._data,this.lengthInInts),this._version++}get length(){return this._length}get buffer(){return this._data}set buffer(e){this._data=e,this._version++}get version(){return this._version}set version(e){this._version=e}incrementVersion(e=!0){this._version++}get lengthInInts(){return Math.floor((this._length+31)/32)}get versionedName(){return this._version==this._versionedNameVersion?this._versionedName:""}set versionedName(e){this._versionedName=e,this._versionedNameVersion=this._version}get self(){return this}setLength(e){if(e<0)throw new Error("should be >= 0");if(e==this._length)return;const t=Math.floor((e+31)/32);if(t>this._data.length||t+this.SHRINK_THRESHOLD<this._data.length){const e=new Uint32Array(t);this.copy(this._data,e,t>this._data.length?this._data.length:t),this._data=e}e>this._length&&(this._length%32>0&&(this._data[this.lengthInInts-1]&=(1<<(this._length%32&31))-1),this._data.fill(0,this.lengthInInts,t)),this._length=e,this._version++}static fromAnd(e,t){if(e._length!=t._length)throw new Error(`Lengths differ (${e._length} != ${t._length})`);const n=new i(e._length);n._length=e._length,n._data=i._createBuffer(n._length),n._version=0;const o=e.lengthInInts;for(let i=0;i<o;i++)n._data[i]=e._data[i]&t._data[i];return n}static _createBuffer(e){return new Uint32Array(Math.floor((e+31)/32))}static fromValues(e){const t=new i(e.length);t._version=0;for(let n=0;n<t._length;n++)e[n]&&(t._data[Math.floor(n/32)]|=1<<(n%32&31));return t}static fromSeq(e,t){const n=new i(e);for(let i=0;i<e;++i)n.setBit(i,t(i));return n._version=0,n}static fromString(e){return i.fromSeq(e.length,(t=>"1"==e.charAt(t)))}static fromUint32Array(e,t){const n=new i(e);return n._data=t,n}static fromBytes(e){const t=e.length,n=new i(8*t);n._data=new Uint32Array(Math.floor((t+3)/4)),n._length=8*t;let o=0,s=0;for(;t-s>=4;)n._data[o++]=255&e[s]|(255&e[s+1])<<8|(255&e[s+2])<<16|(255&e[s+3])<<24,s+=4;return t-s==3&&(n._data[o]=(255&e[s+2])<<16),t-s==2&&(n._data[o]|=(255&e[s+1])<<8),t-s==1&&(n._data[o]|=255&e[s]),n._version=0,n}toString(){return`${this._length} bits, ${this.countBits(!0)} set`}equals(e){if(this==e)return!0;if(null==e)return!1;if(this._length!=e._length)return!1;if(0==this._length)return!0;for(let t=0;t<this._data.length-1;t++)if(this._data[t]!=e._data[t])return!1;for(let t=8*(this._data.length-1);t<this._length;t++)if(this.getBit(t)!=e.getBit(t))return!1;return!0}clone(){const e=new i(0,!1);return e._data=Uint32Array.from(this._data),e._length=this._length,e._version=this._version,e}init(e,t){this.setAll(!1,!1);for(let t=0;t<this._length;t++)e(t)&&(this._data[Math.floor(t/32)]|=1<<(t%32&31));return this.incrementVersion(t),this}invert(e=!0){for(let e=0;e<this._data.length;e++)this._data[e]^=-1;this.incrementVersion(e)}setAll(e,t=!1){const n=e?-1:0,i=this.lengthInInts;for(let e=0;e<i;e++)this._data[e]=n;this.incrementVersion(t)}setIndexes(e,t=!0,n=!0,i=!0){n&&this.setAll(!t,!1);for(const n of e)this.setFast(n,t);this.incrementVersion(i)}everyIndex(e,t=!0){for(const n of e)if(this.getBit(n)!=t)return!1;return!0}anyIndex(e,t=!0){for(const n of e)if(this.getBit(n)==t)return!0;return!1}setWhere(e,t=!0,n=!0,i=!0,o=!0){if(n&&o&&this.setAll(!t,!1),o)for(let n=0;n<this._length;n++)e(n)&&this.setFast(n,t);else for(let n=0;n<this._length;n++)this.setFast(n,e(n)?t:!t);this.incrementVersion(i)}getRange(e,t){this.assureInRange(e,0,this._length-1,"from"),this.assureInRange(t,0,this._length,"to");const n=[];for(let i=e;i<t;++i)n.push(this.getBit(i));return i.fromValues(n)}getRangeAsList(e,t){this.assureInRange(e,0,this._length-1,"from"),this.assureInRange(t,0,this._length,"to");const n=[];for(let i=e;i<t;++i)n.push(this.getBit(i));return n}setRange(e,t,n,i=!0){this.assureInRange(e,0,this._length-1,"from"),this.assureInRange(t,0,this._length-1,"to");const o=Math.min(e,t),s=Math.max(e,t);if(n)for(let e=o;e<=s;e++)this.setTrue(e);else for(let e=o;e<=s;e++)this.setFalse(e);return this.incrementVersion(i),this}setRandom(e,t,n=!0){if(e<0||e>this._length)throw new Error("n must be >= 0 && <= Count");e>this._length/2&&this.setRandom(this._length-e,!t),this.setAll(!t);for(let n=0;n<e;){const e=Math.floor(Math.random()*this._length);this.getBit(e)!=t&&(this.setFast(e,t),n++)}this.incrementVersion(n)}and(e,t=!0){if(this._length!=e._length)throw new Error("Array lengths differ.");for(let t=0,n=this.lengthInInts;t<n;t++)this._data[t]&=e._data[t];return this.incrementVersion(t),this}andNot(e,t=!0){if(this._length!=e._length)throw new Error("Array lengths differ.");const n=this.lengthInInts;for(let t=0;t<n;t++)this._data[t]&=~e._data[t];return this.incrementVersion(t),this}notAnd(e,t=!0){if(this._length!=e._length)throw new Error("Array lengths differ.");for(let t=0,n=this.lengthInInts;t<n;t++)this._data[t]=~this._data[t]&e._data[t];return this.incrementVersion(t),this}not(e=!0){for(let e=0,t=this.lengthInInts;e<t;e++)this._data[e]=~this._data[e];return this.incrementVersion(e),this}or(e,t=!0){if(this._length!=e._length)throw new Error("Array lengths differ.");for(let t=0,n=this.lengthInInts;t<n;t++)this._data[t]|=e._data[t];return this.incrementVersion(t),this}xor(e,t=!0){if(this._length!=e._length)throw new Error("Array lengths differ.");for(let t=0,n=this.lengthInInts;t<n;t++)this._data[t]^=e._data[t];return this.incrementVersion(t),this}insertAt(e,t,n=!1){if(this.assureInRange(e,0,this._length,"pos"),0==t)return;const i=this._length;this.setLength(this._length+t);for(let n=i-1;n>=e;n--)this.setBit(n+t,this.getBit(n));for(let i=e;i<e+t;i++)this.setBit(i,n)}removeAt(e,t=1){if(t<0)throw new Error("n cannot be negative");if(this.assureInRange(e,0,this._length-t,"pos"),this.contains(!0))for(let n=e;n<this._length-t;n++)this.setBit(n,this.getBit(n+t));this.setLength(this._length-t)}removeByMask(e,t=!0){if(this._length!=e.length)throw new Error("length != mask.length");if(e==this)this.setLength(e.countBits(!t)),this.setAll(!t);else{let n=0;for(let i=-1;-1!=(i=e.findNext(i,!t));)this.setFast(n++,this.getBit(i));this._length=n,this._version++}return this}getBit(e){return!!(this._data[Math.floor(e/32)]&1<<(31&e))}setBit(e,t,n=!0){this.setFast(e,t),this._version++}setFast(e,t){t?this._data[Math.floor(e/32)]|=1<<(31&e):this._data[Math.floor(e/32)]&=~(1<<(31&e))}setTrue(e){this._data[Math.floor(e/32)]|=1<<(31&e)}setFalse(e){this._data[Math.floor(e/32)]&=~(1<<(31&e))}trueCount(){return this.countBits(!0)}falseCount(){return this.countBits(!1)}countBits(e){if(0==this._length)return 0;if(this._selectedCountVersion!=this._version){this._selectedCount=0;const e=this.lengthInInts;let t=0;for(;t<e-1;t++)for(let e=this._data[t];0!=e;e>>>=8)this._selectedCount+=i._onBitCount[255&e];let n=this._data[t];const o=31&this._length;for(0!=o&&(n&=~(4294967295<<o));0!=n;n>>>=8)this._selectedCount+=i._onBitCount[255&n];this._selectedCountVersion=this._version}return e?this._selectedCount:this._length-this._selectedCount}countWhere(e){let t=0;if(this.trueCount()==this._length)for(let n=0;n<this._length;n++)t+=e(n)?1:0;else for(let n=-1;-1!=(n=this.findNext(n,!0));)t+=e(n)?1:0;return t}andWithCountBits(e,t){if(0==this._length)return 0;let n=0;const o=this.lengthInInts;let s=0;for(;s<o-1;s++)for(let t=this._data[s]&e._data[s];0!=t;t>>>=8)n+=i._onBitCount[255&t];let r=this._data[s]&e._data[s];const a=31&this._length;for(0!=a&&(r&=~(4294967295<<a));0!=r;r>>>=8)n+=i._onBitCount[255&r];return t?n:this._length-n}clear(){this.setLength(0)}contains(e){return this.findNext(-1,e)>=0}get allTrue(){return this.countBits(!0)==this._length}get allFalse(){return this.countBits(!1)==this._length}get anyTrue(){return this.countBits(!0)>0}get anyFalse(){return this.countBits(!1)>0}findNext(e,t=!0){if(this.assureInRange(e,-1,this._length,"index"),e>=this._length-1)return-1;let n=31&(e=e<0?0:e+1);const o=this.lengthInInts;for(let s=Math.floor(e/32);s<o;s++){let o=t?this._data[s]:~this._data[s];if(0!=n)o&=4294967295<<n&4294967295,n=0;else if(!t&&-4294967296==o)continue;for(let t=0;0!=o;t+=8,o>>>=8){const n=i._firstOnBit[255&o];if(n>=0)return(e=n+32*s+t)>=this._length?-1:e}}return-1}findPrev(e,t=!0){if(0==e)return-1;this.assureInRange(e,-1,this._length,"index");let n=1+(e=e<0?this._length-1:e-1)&31;for(let o=Math.floor(e/32);o>=0;o--){let e=t?this._data[o]:~this._data[o];0!=n&&(e&=~(4294967295<<n),n=0);for(let t=24;0!=e;t-=8,e<<=8){const n=i._lastOnBit[e>>>24];if(n>=0)return n+32*o+t}}return-1}}i._onBitCount=Int8Array.from([0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8]),i._firstOnBit=Int8Array.from([-1,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,7,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0]),i._lastOnBit=Int8Array.from([-1,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7])},8070:(e,t,n)=>{"use strict";n.d(t,{Pl:()=>F,bk:()=>j,gM:()=>k,L1:()=>H,cb:()=>Y,E3:()=>N,J6:()=>O,Wj:()=>R,Xk:()=>$,Xb:()=>G,N$:()=>B,t6:()=>P,PE:()=>_,rd:()=>I,Bl:()=>Z,CN:()=>w});var i=n(4328),o=n(6082);n(9982);const s=o.DataFrame.fromCsv('countries,fasta,smiles,molregno,LON,Zip Code,Street Address Line 1,ImageUrl,user_id,error_message,xray,flag,magnitude,CS-id,pdb_id,accel_a,time_offset,chart,fit,Questions,empty_number,empty_string\nBelgium,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C(=O)OCCCc1cccnc1)c2cccc(c2)C(=O)c3ccccc3,1480014,36.276729583740234,995042300,14016 ROUTE 31W,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,1,1,1QBS,1,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.497360340644872, 1.7058694986686864, 5.278052678195135, 0.16000320889028383],""points"":[{""x"":0.10000000149011612,""y"":2.374499797821045},{""x"":0.6000000238418579,""y"":2.6242473125457764},{""x"":1.100000023841858,""y"":2.367267608642578},{""x"":1.600000023841858,""y"":2.6723148822784424},{""x"":2.0999999046325684,""y"":2.6537344455718994},{""x"":2.5999999046325684,""y"":2.3651671409606934},{""x"":3.0999999046325684,""y"":2.5654284954071045},{""x"":3.5999999046325684,""y"":2.4160959720611572},{""x"":4.099999904632568,""y"":2.286726713180542},{""x"":4.599999904632568,""y"":2.5100042819976807},{""x"":5.099999904632568,""y"":1.6676985025405884},{""x"":5.599999904632568,""y"":0.680136501789093},{""x"":6.099999904632568,""y"":0.3391543924808502},{""x"":6.599999904632568,""y"":0.09038983285427094},{""x"":7.099999904632568,""y"":0.19802775979042053}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[7.525235855508179, 1.3186911876809984, 5.335672608564294, 0.7860743343958098],""points"":[{""x"":0.10000000149011612,""y"":7.988070487976074},{""x"":0.6000000238418579,""y"":7.018453121185303},{""x"":1.100000023841858,""y"":8.115279197692871},{""x"":1.600000023841858,""y"":7.486658096313477},{""x"":2.0999999046325684,""y"":7.396438121795654},{""x"":2.5999999046325684,""y"":7.477052211761475},{""x"":3.0999999046325684,""y"":6.913095474243164},{""x"":3.5999999046325684,""y"":8.01385498046875},{""x"":4.099999904632568,""y"":6.985900402069092},{""x"":4.599999904632568,""y"":6.970335960388184},{""x"":5.099999904632568,""y"":5.448817253112793},{""x"":5.599999904632568,""y"":2.5534818172454834},{""x"":6.099999904632568,""y"":1.893947958946228},{""x"":6.599999904632568,""y"":0.6340042352676392},{""x"":7.099999904632568,""y"":0.8403874039649963}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,100,abc\nBurundi,MDYKETLLMPKTDFPMRGGLPNKEPQIQEKW,COc1ccc2cc(ccc2c1)C(C)C(=O)Oc3ccc(C)cc3OC,1480015,36.276729583740234,995073444,80 STATE HIGHWAY 310,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,2,2,1ZP8,2,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.431460753103398, 2.1691498799246745, 5.266445597102774, 0.7825762827017926],""points"":[{""x"":0.10000000149011612,""y"":4.751083850860596},{""x"":0.6000000238418579,""y"":4.203000068664551},{""x"":1.100000023841858,""y"":4.415858745574951},{""x"":1.600000023841858,""y"":4.68414306640625},{""x"":2.0999999046325684,""y"":4.198400974273682},{""x"":2.5999999046325684,""y"":4.179222106933594},{""x"":3.0999999046325684,""y"":4.638473987579346},{""x"":3.5999999046325684,""y"":4.708553314208984},{""x"":4.099999904632568,""y"":4.291589260101318},{""x"":4.599999904632568,""y"":4.038082599639893},{""x"":5.099999904632568,""y"":3.4349939823150635},{""x"":5.599999904632568,""y"":1.2194708585739136},{""x"":6.099999904632568,""y"":1.1920831203460693},{""x"":6.599999904632568,""y"":0.5352635979652405},{""x"":7.099999904632568,""y"":0.3346920311450958}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.339458017970126, -1.0734184310171178, 4.746332950550934, 0.2482416857595658],""points"":[{""x"":0.10000000149011612,""y"":0.2139337658882141},{""x"":0.6000000238418579,""y"":0.4269562065601349},{""x"":1.100000023841858,""y"":0.2441573292016983},{""x"":1.600000023841858,""y"":0.146635964512825},{""x"":2.0999999046325684,""y"":0.08818462491035461},{""x"":2.5999999046325684,""y"":0.2560656666755676},{""x"":3.0999999046325684,""y"":0.42434045672416687},{""x"":3.5999999046325684,""y"":0.37111231684684753},{""x"":4.099999904632568,""y"":0.5581737160682678},{""x"":4.599999904632568,""y"":1.183590054512024},{""x"":5.099999904632568,""y"":1.5629843473434448},{""x"":5.599999904632568,""y"":2.3211288452148438},{""x"":6.099999904632568,""y"":2.229961633682251},{""x"":6.599999904632568,""y"":2.2560226917266846},{""x"":7.099999904632568,""y"":2.2142398357391357}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCameroon,MIEVFLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL,COc1ccc2cc(ccc2c1)C(C)C(=O)OCCCc3cccnc3,1480016,36.26095962524414,995153596,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,3,3,2BDJ,3,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.6760652578642325, 0.9046956320756703, 5.651408971856738, 0.07738846012184185],""points"":[{""x"":0.10000000149011612,""y"":4.32425594329834},{""x"":0.6000000238418579,""y"":4.668442249298096},{""x"":1.100000023841858,""y"":4.379785060882568},{""x"":1.600000023841858,""y"":5.0345139503479},{""x"":2.0999999046325684,""y"":4.878653526306152},{""x"":2.5999999046325684,""y"":4.3451313972473145},{""x"":3.0999999046325684,""y"":4.336992263793945},{""x"":3.5999999046325684,""y"":5.037430286407471},{""x"":4.099999904632568,""y"":5.0092692375183105},{""x"":4.599999904632568,""y"":4.151902675628662},{""x"":5.099999904632568,""y"":3.4066951274871826},{""x"":5.599999904632568,""y"":2.3732759952545166},{""x"":6.099999904632568,""y"":1.673728108406067},{""x"":6.599999904632568,""y"":0.48574790358543396},{""x"":7.099999904632568,""y"":0.2783052325248718}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.938395863010111, -1.4658480661392117, 5.462702751996584, 0.3473139023615039],""points"":[{""x"":0.10000000149011612,""y"":0.4941710829734802},{""x"":0.6000000238418579,""y"":0.15323974192142487},{""x"":1.100000023841858,""y"":0.46373432874679565},{""x"":1.600000023841858,""y"":0.3370431363582611},{""x"":2.0999999046325684,""y"":0.5179030299186707},{""x"":2.5999999046325684,""y"":0.27899765968322754},{""x"":3.0999999046325684,""y"":0.22075064480304718},{""x"":3.5999999046325684,""y"":0.5789918899536133},{""x"":4.099999904632568,""y"":0.21169911324977875},{""x"":4.599999904632568,""y"":0.27857646346092224},{""x"":5.099999904632568,""y"":1.0906332731246948},{""x"":5.599999904632568,""y"":1.8520300388336182},{""x"":6.099999904632568,""y"":2.7177059650421143},{""x"":6.599999904632568,""y"":2.8680918216705322},{""x"":7.099999904632568,""y"":3.2413077354431152}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCanada,MMELVLKTIIGPIVVGVVLRIVDKWLNKDK,CC(C(=O)NCCS)c1cccc(c1)C(=O)c2ccccc2,1480017,36.26095962524414,99515,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,4,4,1IAN,4,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[0.8597390975430008, 1.0957625732481946, 5.260537067987958, 0.07974187998177736],""points"":[{""x"":0.10000000149011612,""y"":0.8190152645111084},{""x"":0.6000000238418579,""y"":0.8421689867973328},{""x"":1.100000023841858,""y"":0.8740922212600708},{""x"":1.600000023841858,""y"":0.8924275040626526},{""x"":2.0999999046325684,""y"":0.8249067664146423},{""x"":2.5999999046325684,""y"":0.9327669143676758},{""x"":3.0999999046325684,""y"":0.8522974252700806},{""x"":3.5999999046325684,""y"":0.8174492716789246},{""x"":4.099999904632568,""y"":0.8394647240638733},{""x"":4.599999904632568,""y"":0.7139387726783752},{""x"":5.099999904632568,""y"":0.5561167597770691},{""x"":5.599999904632568,""y"":0.3276226818561554},{""x"":6.099999904632568,""y"":0.12479474395513535},{""x"":6.599999904632568,""y"":0.13006797432899475},{""x"":7.099999904632568,""y"":0.059702079743146896}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.760930219582546, 1.6591793293833013, 4.667155929720851, 0.7858109544121652],""points"":[{""x"":0.10000000149011612,""y"":6.156993389129639},{""x"":0.6000000238418579,""y"":5.236701965332031},{""x"":1.100000023841858,""y"":6.010560512542725},{""x"":1.600000023841858,""y"":5.495512962341309},{""x"":2.0999999046325684,""y"":6.087770462036133},{""x"":2.5999999046325684,""y"":5.79986572265625},{""x"":3.0999999046325684,""y"":5.597546577453613},{""x"":3.5999999046325684,""y"":5.520902156829834},{""x"":4.099999904632568,""y"":5.360654354095459},{""x"":4.599999904632568,""y"":3.5539746284484863},{""x"":5.099999904632568,""y"":1.577236294746399},{""x"":5.599999904632568,""y"":1.0001264810562134},{""x"":6.099999904632568,""y"":0.9305797815322876},{""x"":6.599999904632568,""y"":0.6033638715744019},{""x"":7.099999904632568,""y"":0.4203685522079468}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nColombia,MDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN,FC(F)(F)c1ccc(OC2CCNCC2)cc1,1480029,36.3309440612793,995152050,1 COURT HOUSE SQUARE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,5,5,4UJ1,5,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[6.4995088314153655, 2.4270351004539914, 5.178659535348579, 0.625653346241577],""points"":[{""x"":0.10000000149011612,""y"":6.496231555938721},{""x"":0.6000000238418579,""y"":6.42543363571167},{""x"":1.100000023841858,""y"":7.040063858032227},{""x"":1.600000023841858,""y"":6.1115403175354},{""x"":2.0999999046325684,""y"":6.680728435516357},{""x"":2.5999999046325684,""y"":6.406774520874023},{""x"":3.0999999046325684,""y"":6.611269474029541},{""x"":3.5999999046325684,""y"":5.889094352722168},{""x"":4.099999904632568,""y"":6.75344705581665},{""x"":4.599999904632568,""y"":6.361435890197754},{""x"":5.099999904632568,""y"":4.1666975021362305},{""x"":5.599999904632568,""y"":1.172118902206421},{""x"":6.099999904632568,""y"":0.801048994064331},{""x"":6.599999904632568,""y"":0.4640021026134491},{""x"":7.099999904632568,""y"":0.0010357667924836278}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[1.4734381347446401, 1.1649805188074196, 4.82958608866421, 0.09500545496710007],""points"":[{""x"":0.10000000149011612,""y"":1.5279096364974976},{""x"":0.6000000238418579,""y"":1.3559974431991577},{""x"":1.100000023841858,""y"":1.5246378183364868},{""x"":1.600000023841858,""y"":1.5567657947540283},{""x"":2.0999999046325684,""y"":1.4114240407943726},{""x"":2.5999999046325684,""y"":1.4045010805130005},{""x"":3.0999999046325684,""y"":1.4769829511642456},{""x"":3.5999999046325684,""y"":1.4875500202178955},{""x"":4.099999904632568,""y"":1.2991987466812134},{""x"":4.599999904632568,""y"":0.922961413860321},{""x"":5.099999904632568,""y"":0.6520044803619385},{""x"":5.599999904632568,""y"":0.15350978076457977},{""x"":6.099999904632568,""y"":0.1078903079032898},{""x"":6.599999904632568,""y"":0.17276449501514435},{""x"":7.099999904632568,""y"":0.14066608250141144}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCosta Rica,MKSTKEEIQTIKTLLKDSRTAKYHKRLQIVL,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCCc3ccccc3,1480018,36.3309440612793,995084218,4041 SOUTHWESTERN BLVD,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,6,6,2BPW,6,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.4833641843311227, -1.8945978742090062, 4.671127708092568, 0.24159861311815153],""points"":[{""x"":0.10000000149011612,""y"":0.0969524160027504},{""x"":0.6000000238418579,""y"":0.028483040630817413},{""x"":1.100000023841858,""y"":0.22087176144123077},{""x"":1.600000023841858,""y"":0.0068915546871721745},{""x"":2.0999999046325684,""y"":0.4305879771709442},{""x"":2.5999999046325684,""y"":0.44774115085601807},{""x"":3.0999999046325684,""y"":0.45346319675445557},{""x"":3.5999999046325684,""y"":0.2370593100786209},{""x"":4.099999904632568,""y"":0.4657953977584839},{""x"":4.599999904632568,""y"":1.155200719833374},{""x"":5.099999904632568,""y"":2.2294070720672607},{""x"":5.599999904632568,""y"":2.4311530590057373},{""x"":6.099999904632568,""y"":2.33846116065979},{""x"":6.599999904632568,""y"":2.608201026916504},{""x"":7.099999904632568,""y"":2.8136143684387207}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.224573521642033, 1.4454033924198528, 5.6014197746076535, 0.2823216054197577],""points"":[{""x"":0.10000000149011612,""y"":4.95027494430542},{""x"":0.6000000238418579,""y"":5.1754679679870605},{""x"":1.100000023841858,""y"":5.276752948760986},{""x"":1.600000023841858,""y"":5.589294910430908},{""x"":2.0999999046325684,""y"":5.616994857788086},{""x"":2.5999999046325684,""y"":5.120813846588135},{""x"":3.0999999046325684,""y"":5.340766906738281},{""x"":3.5999999046325684,""y"":4.876471042633057},{""x"":4.099999904632568,""y"":4.94999361038208},{""x"":4.599999904632568,""y"":5.162564754486084},{""x"":5.099999904632568,""y"":4.399557590484619},{""x"":5.599999904632568,""y"":2.7977969646453857},{""x"":6.099999904632568,""y"":1.0229872465133667},{""x"":6.599999904632568,""y"":0.48275601863861084},{""x"":7.099999904632568,""y"":0.10408931970596313}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCuba,MHAILRYFIRRLFYHIFYKIYSLISKKHQSLPSDVRQF,COc1ccc2c(c1)c(CC(=O)N3CCCC3C(=O)Oc4ccc(C)cc4OC)c(C)n2C(=O)c5ccc(Cl)cc5,1480019,36.33115768432617,995081928,1227 US HIGHWAY 11,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,7,7,1QBS,7,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.320838679713925, -1.2421619987316728, 4.831325425225256, 0.3236011098403072],""points"":[{""x"":0.10000000149011612,""y"":0.3727470338344574},{""x"":0.6000000238418579,""y"":0.12365014106035233},{""x"":1.100000023841858,""y"":0.48422467708587646},{""x"":1.600000023841858,""y"":0.2264465093612671},{""x"":2.0999999046325684,""y"":0.16821794211864471},{""x"":2.5999999046325684,""y"":0.3879014551639557},{""x"":3.0999999046325684,""y"":0.5470244884490967},{""x"":3.5999999046325684,""y"":0.3419053554534912},{""x"":4.099999904632568,""y"":0.7655120491981506},{""x"":4.599999904632568,""y"":1.2346516847610474},{""x"":5.099999904632568,""y"":2.453336715698242},{""x"":5.599999904632568,""y"":2.9565491676330566},{""x"":6.099999904632568,""y"":3.335299491882324},{""x"":6.599999904632568,""y"":3.240290880203247},{""x"":7.099999904632568,""y"":3.1107218265533447}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.6401853521511094, 1.26211588875013, 5.399028074402744, 0.5089580830068091],""points"":[{""x"":0.10000000149011612,""y"":3.8585598468780518},{""x"":0.6000000238418579,""y"":3.6077206134796143},{""x"":1.100000023841858,""y"":3.855252265930176},{""x"":1.600000023841858,""y"":3.619039297103882},{""x"":2.0999999046325684,""y"":3.839388370513916},{""x"":2.5999999046325684,""y"":3.335283041000366},{""x"":3.0999999046325684,""y"":3.571141481399536},{""x"":3.5999999046325684,""y"":3.4155046939849854},{""x"":4.099999904632568,""y"":3.7316646575927734},{""x"":4.599999904632568,""y"":3.0680155754089355},{""x"":5.099999904632568,""y"":2.891066551208496},{""x"":5.599999904632568,""y"":1.6022753715515137},{""x"":6.099999904632568,""y"":0.7652576565742493},{""x"":6.599999904632568,""y"":0.6875326037406921},{""x"":7.099999904632568,""y"":0.5828871726989746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nItaly,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO[N+](=O)[O-],1480020,36.33115768432617,99502,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,8,8,1ZP8,8,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.293592105923809, 1.3781586549141835, 5.1025898038676605, 0.03493851245291291],""points"":[{""x"":0.10000000149011612,""y"":2.1287283897399902},{""x"":0.6000000238418579,""y"":2.267972230911255},{""x"":1.100000023841858,""y"":2.398442506790161},{""x"":1.600000023841858,""y"":2.5130622386932373},{""x"":2.0999999046325684,""y"":2.3255116939544678},{""x"":2.5999999046325684,""y"":2.127340793609619},{""x"":3.0999999046325684,""y"":2.47259783744812},{""x"":3.5999999046325684,""y"":2.131181478500366},{""x"":4.099999904632568,""y"":2.090421438217163},{""x"":4.599999904632568,""y"":2.02299165725708},{""x"":5.099999904632568,""y"":1.1105059385299683},{""x"":5.599999904632568,""y"":0.4494485855102539},{""x"":6.099999904632568,""y"":0.1375635862350464},{""x"":6.599999904632568,""y"":0.036351121962070465},{""x"":7.099999904632568,""y"":0.1619771122932434}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.953125499439879, 1.2528620255306528, 5.187637440149802, 0.3110348753260886],""points"":[{""x"":0.10000000149011612,""y"":5.6585283279418945},{""x"":0.6000000238418579,""y"":5.911152362823486},{""x"":1.100000023841858,""y"":5.924920082092285},{""x"":1.600000023841858,""y"":5.8469438552856445},{""x"":2.0999999046325684,""y"":5.929472923278809},{""x"":2.5999999046325684,""y"":6.190037727355957},{""x"":3.0999999046325684,""y"":6.236179828643799},{""x"":3.5999999046325684,""y"":6.141019344329834},{""x"":4.099999904632568,""y"":5.295210838317871},{""x"":4.599999904632568,""y"":5.265801906585693},{""x"":5.099999904632568,""y"":3.3722851276397705},{""x"":5.599999904632568,""y"":1.8299226760864258},{""x"":6.099999904632568,""y"":0.32690900564193726},{""x"":6.599999904632568,""y"":0.6274543404579163},{""x"":7.099999904632568,""y"":0.8441857099533081}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nRwanda,MPNSEPASLLELFNSIATQGELVRSLKAGNASK,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO,1480021,36.33137130737305,995037247,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,9,9,2BDJ,9,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.8209972202654474, 1.3779216716448506, 5.299882228439686, 0.06040645519069608],""points"":[{""x"":0.10000000149011612,""y"":3.7821109294891357},{""x"":0.6000000238418579,""y"":3.542433023452759},{""x"":1.100000023841858,""y"":3.7008674144744873},{""x"":1.600000023841858,""y"":3.717301607131958},{""x"":2.0999999046325684,""y"":4.024452209472656},{""x"":2.5999999046325684,""y"":4.013899326324463},{""x"":3.0999999046325684,""y"":3.945094347000122},{""x"":3.5999999046325684,""y"":3.866621971130371},{""x"":4.099999904632568,""y"":3.7461626529693604},{""x"":4.599999904632568,""y"":3.3454740047454834},{""x"":5.099999904632568,""y"":2.61944317817688},{""x"":5.599999904632568,""y"":0.999405026435852},{""x"":6.099999904632568,""y"":0.46259793639183044},{""x"":6.599999904632568,""y"":0.054134611040353775},{""x"":7.099999904632568,""y"":0.05711187422275543}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.6318079657726035, 1.8495493770000595, 5.391793312471116, 0.17060707587348442],""points"":[{""x"":0.10000000149011612,""y"":5.458079814910889},{""x"":0.6000000238418579,""y"":5.554427146911621},{""x"":1.100000023841858,""y"":5.799983024597168},{""x"":1.600000023841858,""y"":5.364140033721924},{""x"":2.0999999046325684,""y"":5.864485740661621},{""x"":2.5999999046325684,""y"":5.4509806632995605},{""x"":3.0999999046325684,""y"":5.702574729919434},{""x"":3.5999999046325684,""y"":5.7314534187316895},{""x"":4.099999904632568,""y"":5.5123443603515625},{""x"":4.599999904632568,""y"":5.724395751953125},{""x"":5.099999904632568,""y"":4.354506969451904},{""x"":5.599999904632568,""y"":1.7307666540145874},{""x"":6.099999904632568,""y"":0.6305936574935913},{""x"":6.599999904632568,""y"":0.035183437168598175},{""x"":7.099999904632568,""y"":0.7575169205665588}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nSwitzerland,IRVVGRYLIEVWKAAGMDMDKVLFLWSSDEI,CN1CCC(CC1)Oc2ccc(cc2)C(F)(F)F,1480028,36.33137130737305,99504,92-11 179TH PLACE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,9,10,1IAN,10,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[1.1190255865097471, 2.3163895161544437, 5.4968866182279195, 0.2035204047289052],""points"":[{""x"":0.10000000149011612,""y"":1.1057683229446411},{""x"":0.6000000238418579,""y"":1.1019697189331055},{""x"":1.100000023841858,""y"":1.0818607807159424},{""x"":1.600000023841858,""y"":1.062997817993164},{""x"":2.0999999046325684,""y"":1.046447515487671},{""x"":2.5999999046325684,""y"":1.1217249631881714},{""x"":3.0999999046325684,""y"":1.2166996002197266},{""x"":3.5999999046325684,""y"":1.215477705001831},{""x"":4.099999904632568,""y"":1.0581893920898438},{""x"":4.599999904632568,""y"":1.1747995615005493},{""x"":5.099999904632568,""y"":1.0181127786636353},{""x"":5.599999904632568,""y"":0.5344523191452026},{""x"":6.099999904632568,""y"":0.2569526433944702},{""x"":6.599999904632568,""y"":0.1912207305431366},{""x"":7.099999904632568,""y"":0.15060538053512573}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.1038581025805785, 2.0032224204185245, 5.087602825989163, 0.13277988512492753],""points"":[{""x"":0.10000000149011612,""y"":3.0498509407043457},{""x"":0.6000000238418579,""y"":2.805217742919922},{""x"":1.100000023841858,""y"":3.3415253162384033},{""x"":1.600000023841858,""y"":3.0549843311309814},{""x"":2.0999999046325684,""y"":3.250074863433838},{""x"":2.5999999046325684,""y"":3.0432586669921875},{""x"":3.0999999046325684,""y"":3.265852451324463},{""x"":3.5999999046325684,""y"":2.9475724697113037},{""x"":4.099999904632568,""y"":3.1929898262023926},{""x"":4.599999904632568,""y"":2.7460060119628906},{""x"":5.099999904632568,""y"":1.6175861358642578},{""x"":5.599999904632568,""y"":0.3006608486175537},{""x"":6.099999904632568,""y"":0.3444803059101105},{""x"":6.599999904632568,""y"":0.015537971630692482},{""x"":7.099999904632568,""y"":0.5527358055114746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\n,,,,,,,,,,,,,,,,,,,,,');s.columns.add(o.Column.fromList(o.TYPE.BYTE_ARRAY,"BinaryImage",Array.from(new Uint8Array(11))));var r=function(e,t,n,i){return new(n||(n=Promise))((function(o,s){function r(e){try{l(i.next(e))}catch(e){s(e)}}function a(e){try{l(i.throw(e))}catch(e){s(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,a)}l((i=i.apply(e,t||[])).next())}))};function a(e,t,n,o,s,a,l,c,u=!0){return r(this,void 0,void 0,(function*(){let h=null;if(yield I(o,(n=>r(this,void 0,void 0,(function*(){let n=null;for(const i of e.viewers)i.type===t&&(n=i);if(!n)throw Error("Viewer hasn't been added");if(yield Promise.resolve(),a&&(yield a(n)),s){const t=null!=c?c:{};t.tv=e,t.viewer=n,h=yield s(t,u)}yield _(i.events.onViewerClosed,(()=>{N(n.subs.some((e=>!e.closed)),!1)}),(()=>n.close()),3e3)}))),(()=>r(this,void 0,void 0,(function*(){l?e.loadLayout(l):yield function(e,t,n){return r(this,void 0,void 0,(function*(){let i;return n?(i=yield e.dataFrame.plot.fromType(t),e.dockManager.dock(i)):i=e.addViewer(t),i}))}(e,t,n)}))),6e4,"TEST_EVENT_ASYNC"),h)return h}))}function l(e,t=!0){return r(this,void 0,void 0,(function*(){const n=e.tv.dataFrame,i=n.clone();Array.from(n.row(0).cells).forEach((e=>e.value=null));const o=n.rowCount<20?Math.floor(n.rowCount/2):10;n.rows.select((e=>e.idx>=0&&e.idx<o)),t&&(yield Y(50));for(let e=o;e<2*o;e++)n.filter.set(e,!1);t&&(yield Y(50)),n.currentRowIdx=1,n.columns.names().slice(0,Math.ceil(n.columns.length/2)).forEach((e=>n.columns.remove(e))),t&&(yield Y(100)),e.tv.dataFrame=i,yield Y(50)}))}function c(e,t=!0){return r(this,void 0,void 0,(function*(){const t=e.tv.dataFrame;setTimeout((()=>t.filter.set(0,!t.filter.get(0))),0)}))}function u(e,t=!0){return r(this,void 0,void 0,(function*(){let t,n;try{t=e.viewer.getOptions(!0).look}catch(e){throw new Error("Viewer's .getOptions() error.",{cause:e})}try{n=e.viewer.getProperties()}catch(e){throw new Error("Viewer's .getProperties() error.",{cause:e})}const i={};return Object.keys(t).filter((e=>"boolean"==typeof t[e])).forEach((e=>i[e]=!t[e])),n.filter((e=>null!==e.choices)).forEach((e=>i[e.name]=e.choices.find((n=>n!==t[e.name])))),e.viewer.setOptions(i),yield Y(300),{layout:e.tv.saveLayout(),savedProps:e.viewer.getOptions().look}}))}function h(e,t=!0){return r(this,void 0,void 0,(function*(){N(JSON.stringify(e.viewer.getOptions().look),JSON.stringify(e.savedProps))}))}var d=function(e,t,n,i){return new(n||(n=Promise))((function(o,s){function r(e){try{l(i.next(e))}catch(e){s(e)}}function a(e){try{l(i.throw(e))}catch(e){s(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,a)}l((i=i.apply(e,t||[])).next())}))};const p=3e4,m=108e5,g=console.log.bind(console),f=console.info.bind(console),y=console.warn.bind(console),b=console.error.bind(console),w={},v="Auto Tests",A="Demo",C="Detectors",T="Core",S={};let E;var M;!function(e){e.notNull=function(e,t){if(null==e)throw new Error(`${null==t?"Value":t} not defined`)}}(M||(M={}));class x{constructor(e,t){this.catchUnhandled=!0,this.report=!1,void 0!==e&&(this.catchUnhandled=e),void 0!==t&&(this.report=t)}}class L{constructor(e,t,n,i){var s;this.category=e,this.name=t,null!=i||(i={}),null!==(s=i.timeout)&&void 0!==s||(i.timeout=p),this.options=i,this.test=()=>d(this,void 0,void 0,(function*(){return new Promise(((e,t)=>d(this,void 0,void 0,(function*(){var i;let s="";try{o.Test.isInDebug;let e=yield n();try{s=null!==(i=null==e?void 0:e.toString())&&void 0!==i?i:""}catch(e){s="Can't convert test's result to string",console.error(`Can't convert test's result to string in the ${this.category}:${this.name} test`)}}catch(e){t(e)}e(s)}))))}))}}function _(e,t,n,i=0,o="timeout"){return d(this,void 0,void 0,(function*(){return new Promise(((s,r)=>{const a=e.subscribe((e=>{try{t(e),s("OK")}catch(e){r(e)}finally{a.unsubscribe(),clearTimeout(l)}})),l=setTimeout((()=>{a.unsubscribe(),r(o)}),i);n()}))}))}function I(e,t,n,i=0,o="timeout"){return d(this,void 0,void 0,(function*(){return new Promise(((s,r)=>{const a=e.subscribe((e=>{t(e).then((()=>{s("OK")})).catch((e=>{r(e)})).finally((()=>{a.unsubscribe(),clearTimeout(l)}))})),l=setTimeout((()=>{a.unsubscribe(),r(o)}),i);n()}))}))}function P(e,t,n){null==w[E]&&(w[E]={}),null==w[E].tests&&(w[E].tests=[]),w[E].tests.push(new L(E,e,t,n))}function N(e,t=!0,n){if(n=n?`${n}, `:"",e!==t)throw new Error(`${n}Expected "${t}", got "${e}"`)}function R(e,t,n=.001,i){if(e===Number.POSITIVE_INFINITY&&t===Number.POSITIVE_INFINITY||e===Number.NEGATIVE_INFINITY&&t===Number.NEGATIVE_INFINITY||e===Number.NaN&&t===Number.NaN||isNaN(e)&&isNaN(t))return;const o=Math.abs(e-t)<n;if(N(o,!0,`${null!=i?i:""} (tolerance = ${n})`),!o)throw new Error(`Expected ${t}, got ${e} (tolerance = ${n})`)}function $(e,t){for(const[n,i]of Object.entries(t)){if(!e.hasOwnProperty(n))throw new Error(`Expected property "${n}" not found`);const t=e[n];if(t instanceof Array&&i instanceof Array)O(t,i);else if(t instanceof Object&&i instanceof Object)$(t,i);else if(Number.isFinite(t)&&Number.isFinite(i))R(t,i);else if(t!=i)throw new Error(`Expected (${i}) for key '${n}', got (${t})`)}}function O(e,t){const n=e.length,i=t.length;if(n!=i)throw new Error(`Arrays are of different length: actual array length is ${n} and expected array length is ${i}`);for(let i=0;i<n;i++)if(e[i]instanceof Array&&t[i]instanceof Array)O(e[i],t[i]);else if(e[i]instanceof Object&&t[i]instanceof Object)$(e[i],t[i]);else if(e[i]!=t[i])throw new Error(`Expected ${t[i]} at position ${i}, got ${e[i]}`)}function H(e,t,n){var i;E=e,t(),w[E]&&(w[E].clear=null===(i=null==n?void 0:n.clear)||void 0===i||i,w[E].timeout=null==n?void 0:n.timeout,w[E].benchmarks=null==n?void 0:n.benchmarks,w[E].stressTests=null==n?void 0:n.stressTests,w[E].owner=null==n?void 0:n.owner)}function k(e){null==w[E]&&(w[E]={}),w[E].before=e}function F(e){null==w[E]&&(w[E]={}),w[E].after=e}function D(e,t){return e.replace(new RegExp(t.name,"gi"),t.nqName)}function G(e,t){var n,r,a,l,c,u,h,g,f,y;return d(this,void 0,void 0,(function*(){const b=e.id;if(S[b])return;const E=t?t.tests:w;if("DevTools"===e.name||t&&"DevTools"===t._package.name)for(const e of window.dartTests){const t=e.name.split(/\s*\|\s*!/g);let i=null!==(n=t.pop())&&void 0!==n?n:e.name,o=t.length?T+": "+t.join(": "):T,s=i.split(" | ");i=s[s.length-1],s.unshift(o),s.pop(),o=s.join(": "),void 0===E[o]&&(E[o]={tests:[],clear:!0}),E[o].tests.push(new L(o,i,e.test,{isAggregated:!1,timeout:null!==(a=null===(r=e.options)||void 0===r?void 0:r.timeout)&&void 0!==a?a:p,skipReason:null===(l=e.options)||void 0===l?void 0:l.skipReason,owner:null===(c=e.options)||void 0===c?void 0:c.owner,benchmark:null!==(h=null===(u=e.options)||void 0===u?void 0:u.benchmark)&&void 0!==h&&h}))}const M=[],x=[],_=[],I=yield i.dapi.functions.filter(`package.id = "${b}"`).list(),P=new RegExp(/skip:\s*([^,\s]+)|wait:\s*(\d+)|cat:\s*([^,\s]+)|timeout:\s*(\d+)/g);for(const t of I){const n=t.options.test,r=t.options.demoPath;if(n&&Array.isArray(n)&&n.length)for(let e=0;e<n.length;e++){const s=n[e].matchAll(P),r={};Array.from(s).forEach((e=>{e[0].startsWith("skip")?r.skip=e[1]:e[0].startsWith("wait")?r.wait=parseInt(e[2]):e[0].startsWith("cat")?r.cat=e[3]:e[0].startsWith("timeout")&&(r.timeout=parseInt(e[4]))}));const a=new L(null!==(g=r.cat)&&void 0!==g?g:v,1===n.length?t.name:`${t.name} ${e+1}`,(()=>d(this,void 0,void 0,(function*(){const o=yield i.functions.eval(D(n[e],t));if(r.wait&&(yield Y(r.wait)),"boolean"==typeof o&&!o)throw`Failed: ${n[e]}, expected true, got ${o}`}))),{skipReason:r.skip,timeout:o.Test.isInBenchmark?null!==(f=r.benchmarkTimeout)&&void 0!==f?f:m:null!==(y=r.timeout)&&void 0!==y?y:p});if(r.cat){const e=r.cat;void 0===E[e]&&(E[e]={tests:[],clear:!0}),E[e].tests||(E[e].tests=[]),E[e].tests.push(a)}else M.push(a)}if(r){const e=t.options.demoWait?parseInt(t.options.demoWait):void 0,n=new L(A,t.friendlyName,(()=>d(this,void 0,void 0,(function*(){yield Y(300),i.shell.clearLastError(),yield t.apply(),yield Y(e||2e3);const n=yield i.shell.lastError;if(n)throw new Error(n)}))),{skipReason:t.options.demoSkip});x.push(n)}if(t.hasTag("semTypeDetector")){let n=s;t.options.testData&&(n=yield i.data.files.openTable(`System:AppData/${e.nqName}/${t.options.testData}`));const o=new L(C,t.friendlyName,(()=>d(this,void 0,void 0,(function*(){const i=[];console.log(`System:AppData/${e.nqName}/${t.options.testData}`);for(const e of n.clone().columns){const n=yield t.apply([e]);i.push(n||e.semType)}const o=i.filter((e=>e));N(o.length,1),t.options.testDataColumnName&&N(o[0],t.options.testDataColumnName)}))),{skipReason:t.options.skipTest});_.push(o)}}S[b]=!0,M.length>0&&(E[v]={tests:M,clear:!0}),x.length>0&&(E[A]={tests:x,clear:!0}),_.length>0&&(E[C]={tests:_,clear:!1})}))}function B(e){var t,n,s,r,a,l;return d(this,void 0,void 0,(function*(){console.log("--------------------");const c=null===(n=null===(t=i.functions.getCurrentCall())||void 0===t?void 0:t.func)||void 0===n?void 0:n.package,u=(null!==(r=(null!==(s=null==c?void 0:c.packageOwner)&&void 0!==s?s:"").match(new RegExp("[^<]*<([^>]*)>")))&&void 0!==r?r:["",""])[1];yield G(c);const h=[];console.log("Running tests"),console.log(e),null!=e||(e={}),null!==(a=(l=e).testContext)&&void 0!==a||(l.testContext=new x),i.shell.clearLastError();const v=function(){const e=[];return console.log=(...t)=>{e.push(...t),g(...t)},console.info=(...t)=>{e.push(...t),f(...t)},console.warn=(...t)=>{e.push(...t),y(...t)},console.error=(...t)=>{e.push(...t),b(...t)},e}();yield function(e,t){var n,s,r,a,l,p,m;return d(this,void 0,void 0,(function*(){try{for(const[i,u]of Object.entries(e)){if((null==t?void 0:t.category)&&!i.toLowerCase().startsWith(null==t?void 0:t.category.toLowerCase())||(null===(n=t.exclude)||void 0===n?void 0:n.some((e=>i.startsWith(e)))))continue;g(`Started ${i} category`);const e=null===(s=u.tests)||void 0===s?void 0:s.every((e=>{var t;return null===(t=e.options)||void 0===t?void 0:t.skipReason}));e||(u.beforeStatus=yield A(u.before,null!==(r=t.category)&&void 0!==r?r:""));let f,y=null!==(a=u.tests)&&void 0!==a?a:[];t.stressTest&&(y=y.filter((e=>{var t;return null===(t=e.options)||void 0===t?void 0:t.stressTest})),y=q(y)),(null!==(p=null===(l=t.tags)||void 0===l?void 0:l.length)&&void 0!==p?p:0)>0&&(y=y.filter((e=>{var n,i;return null===(i=null===(n=e.options)||void 0===n?void 0:n.tags)||void 0===i?void 0:i.some((e=>{var n;return(null!==(n=null==t?void 0:t.tags)&&void 0!==n?n:[]).includes(e)}))}))),u.beforeStatus?(f=Array.from(y.map((e=>({date:(new Date).toISOString(),category:i,name:e.name,success:!1,result:"before() failed",ms:0,skipped:!1,logs:"",owner:null==c?void 0:c.packageOwner,package:c.name,widgetsDifference:0,flaking:o.Test.isReproducing})))),f.forEach((e=>d(this,void 0,void 0,(function*(){return V("package",e)}))))):f=yield C(u,t);const b=f.filter((e=>"skipped"!=e.result));e||(u.afterStatus=yield A(u.after,null!==(m=t.category)&&void 0!==m?m:"")),u.afterStatus&&b.push({date:(new Date).toISOString(),category:i,name:"after",success:!1,result:u.afterStatus,ms:0,skipped:!1,logs:"",owner:null==c?void 0:c.packageOwner,package:c.name,widgetsDifference:0,flaking:o.Test.isReproducing}),u.beforeStatus&&b.push({date:(new Date).toISOString(),category:i,name:"before",success:!1,result:u.beforeStatus,ms:0,skipped:!1,logs:"",owner:null==c?void 0:c.packageOwner,package:c.name,widgetsDifference:0,flaking:o.Test.isReproducing}),h.push(...b)}}finally{console.log=g,console.info=f,console.warn=y,console.error=b}if(t.testContext.catchUnhandled&&!o.Test.isInBenchmark){yield Y(1e3);const e=yield i.shell.lastError,t={logs:"",date:(new Date).toISOString(),category:"Unhandled exceptions",name:"Exception",result:null!=e?e:"",success:!e,ms:0,skipped:!1,owner:null!=u?u:"",package:c.name,widgetsDifference:0};h.push(Object.assign(Object.assign({},t),{flaking:o.Test.isReproducing&&!e})),t.package=c.name,yield V("package",t)}}))}(w,e);for(let e of h)e.result=e.result.toString().replace(/"/g,"'"),null!=e.logs&&(e.logs=e.logs.toString().replace(/"/g,"'"));return h;function A(e,t){return d(this,void 0,void 0,(function*(){let n;try{void 0!==e&&(yield K((()=>d(this,void 0,void 0,(function*(){yield e()}))),1e5,`before ${t}: timeout error`))}catch(e){n=yield U(e)}return n}))}function C(e,t){var n,s,r,a,l,h,g,f,y,b,w,A,C,S,E,M,x,L;return d(this,void 0,void 0,(function*(){let d=null!==(n=e.tests)&&void 0!==n?n:[];const _=[],I=T();if(e.clear)for(let n=0;n<d.length;n++){d[n].options&&void 0===(null===(s=d[n].options)||void 0===s?void 0:s.benchmark)&&(d[n].options||(d[n].options={}),d[n].options.benchmark=null!==(r=e.benchmarks)&&void 0!==r&&r);let A=d[n];if(t.test&&t.test.toLowerCase()!==A.name.toLowerCase())continue;(null==A?void 0:A.options)&&(A.options.owner=null!==(g=null!==(h=null!==(l=null===(a=d[n].options)||void 0===a?void 0:a.owner)&&void 0!==l?l:null==e?void 0:e.owner)&&void 0!==h?h:u)&&void 0!==g?g:"");let C=yield W(A,null==t?void 0:t.test,v,o.Test.isInBenchmark?null!==(y=null===(f=d[n].options)||void 0===f?void 0:f.benchmarkTimeout)&&void 0!==y?y:m:null!==(w=null===(b=d[n].options)||void 0===b?void 0:b.timeout)&&void 0!==w?w:p,c.name,t.verbose);C&&_.push(Object.assign(Object.assign({},C),{widgetsDifference:T()-I})),i.shell.closeAll(),o.Balloon.closeAll()}else for(let n=0;n<d.length;n++){let i=d[n];if(t.test&&t.test.toLowerCase()!==i.name.toLowerCase())continue;(null==i?void 0:i.options)&&(i.options.owner=null!==(E=null!==(S=null!==(C=null===(A=d[n].options)||void 0===A?void 0:A.owner)&&void 0!==C?C:null==e?void 0:e.owner)&&void 0!==S?S:u)&&void 0!==E?E:"");let s=yield W(i,null==t?void 0:t.test,v,o.Test.isInBenchmark?null!==(x=null===(M=d[n].options)||void 0===M?void 0:M.benchmarkTimeout)&&void 0!==x?x:m:null===(L=d[n].options)||void 0===L?void 0:L.timeout,c.name,t.verbose);s&&_.push(Object.assign(Object.assign({},s),{widgetsDifference:T()-I}))}return _}))}function T(){var e;let t=-1;try{t=o.Widget.getAll().length}catch(t){console.warn(null!==(e=t.message)&&void 0!==e?e:t)}return t}}))}function V(e,t){return d(this,void 0,void 0,(function*(){null!=i.shell.reportTest?yield i.shell.reportTest(e,t):yield fetch(`${i.dapi.root}/log/tests/${e}`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify(t)})}))}function U(e){return d(this,void 0,void 0,(function*(){return`${e.toString()}\n${e.stack?yield o.Logger.translateStackTrace(e.stack):""}`}))}function W(e,t,n,s,r,a){var l,c,u,h,m,f,y,w,v,A,C,T,S,E;return d(this,void 0,void 0,(function*(){let d;n.length=0;const M=null!=t&&e.name.toLowerCase()!==t.toLowerCase();let x=(null===(l=e.options)||void 0===l?void 0:l.skipReason)||M,L=M?"skipped":null===(c=e.options)||void 0===c?void 0:c.skipReason;if(console.log(P.name,x),o.Test.isInBenchmark&&!(null===(u=e.options)||void 0===u?void 0:u.benchmark))return void g(`SKIPPED: ${e.category} ${e.name} doesnt available in benchmark mode`);x||g(`Started ${e.category} ${e.name}`);const _=Date.now(),I=new Date(_).toISOString();try{if(x)d={name:e.name,owner:null!==(m=null===(h=e.options)||void 0===h?void 0:h.owner)&&void 0!==m?m:"",category:e.category,logs:"",date:I,success:!0,result:L,ms:0,skipped:!0,package:null!=r?r:"",flaking:o.Test.isReproducing};else{let t=null!=s?s:p;o.Test.isProfiling&&console.profile(`${e.category}: ${e.name}`),d={name:e.name,owner:null!==(y=null===(f=e.options)||void 0===f?void 0:f.owner)&&void 0!==y?y:"",category:e.category,logs:"",date:I,success:!0,result:null!==(w=yield K(e.test,t))&&void 0!==w?w:"OK",ms:0,skipped:!1,package:null!=r?r:"",flaking:o.Test.isReproducing},o.Test.isProfiling&&(console.profileEnd(`${e.category}: ${e.name}`),i.shell.info(`Profiling of ${e.category}: ${e.name} finished \n Please ensure that you have opened DevTools (F12) / Performance panel before test starts.`))}}catch(t){b(t),d={name:e.name,owner:null!==(A=null===(v=e.options)||void 0===v?void 0:v.owner)&&void 0!==A?A:"",category:e.category,logs:"",date:I,success:!1,result:yield U(t),ms:0,skipped:!1,package:null!=r?r:"",flaking:!1}}if((null===(C=e.options)||void 0===C?void 0:C.isAggregated)&&d.result.constructor===o.DataFrame){const e=d.result.col("success");if(e&&(d.success=e.stats.sum===e.length),!a){const e=d.result;e.columns.remove("stack"),e.rows.removeWhere((e=>e.get("success"))),d.result=e}d.result=d.result.toCsv()}if(d.logs=n.join("\n"),d.ms=Date.now()-_,x||g(`Finished ${e.category} ${e.name} for ${d.ms} ms`),d.category=e.category,d.name=e.name,d.owner=null!==(S=null===(T=e.options)||void 0===T?void 0:T.owner)&&void 0!==S?S:"",!M){let t={success:d.success,result:d.result,ms:d.ms,date:d.date,skipped:d.skipped,category:e.category,name:e.name,logs:d.logs,owner:d.owner,flaking:o.Test.isReproducing&&d.success,package:d.package};if(d.result.constructor==Object){const e=Object.keys(d.result).reduce(((e,t)=>Object.assign(Object.assign({},e),{["result."+t]:d.result[t]})),{});t=Object.assign(Object.assign({},t),e)}t.result instanceof o.DataFrame&&(t.result=JSON.stringify(null===(E=t.result)||void 0===E?void 0:E.toJson())||""),yield V("package",t)}return d}))}function q(e){const t=e.slice();return t.sort((()=>Math.random()-.5)),t}function Y(e){return d(this,void 0,void 0,(function*(){yield new Promise((t=>setTimeout(t,e)))}))}function j(e,t="Timeout exceeded",n=500,i=50){return d(this,void 0,void 0,(function*(){return new Promise(((o,s)=>{setTimeout((()=>{clearInterval(r),s(new Error(t))}),n);const r=setInterval((()=>{e()&&(clearInterval(r),o(null))}),i)}))}))}function K(e,t,n="EXECUTION TIMEOUT"){return d(this,void 0,void 0,(function*(){let i=null;const o=new Promise(((e,o)=>{i=setTimeout((()=>{o(n)}),t)}));try{return yield Promise.race([e(),o])}finally{i&&clearTimeout(i)}}))}const z=o.DataFrame.fromColumns([o.Column.fromStrings("col",["val1","val2","val3"])]);function Z(e,t,n){var o;return d(this,void 0,void 0,(function*(){const s=null!==(o=null==n?void 0:n.packageName)&&void 0!==o?o:"";(null==n?void 0:n.detectSemanticTypes)&&(yield i.data.detectSemanticTypes(t));const r=i.shell.addTableView(t);try{yield a(r,e,s,i.events.onViewerAdded),(null==n?void 0:n.awaitViewer)&&(yield a(r,e,s,i.events.onViewerAdded,void 0,n.awaitViewer)),(null==n?void 0:n.readOnly)||(yield a(r,e,s,i.events.onViewerAdded,l),(null==n?void 0:n.awaitViewer)&&(yield a(r,e,s,i.events.onViewerAdded,l,n.awaitViewer)));let t=null;t=yield a(r,e,s,i.events.onViewerAdded,u),(null==n?void 0:n.awaitViewer)&&(t=yield a(r,e,s,i.events.onViewerAdded,u,n.awaitViewer)),yield a(r,e,s,i.events.onViewLayoutApplied,h,void 0,null==t?void 0:t.layout,{savedProps:null==t?void 0:t.savedProps}),(null==n?void 0:n.awaitViewer)&&(yield a(r,e,s,i.events.onViewLayoutApplied,h,n.awaitViewer,null==t?void 0:t.layout,{savedProps:null==t?void 0:t.savedProps})),!1!==(null==n?void 0:n.arbitraryDfTest)&&(r.dataFrame=z,yield Y(50),yield a(r,e,s,i.events.onViewerAdded),(null==n?void 0:n.awaitViewer)&&(yield a(r,e,s,i.events.onViewerAdded,void 0,n.awaitViewer))),yield a(r,e,s,i.events.onViewerAdded,c),(null==n?void 0:n.awaitViewer)&&(yield a(r,e,s,i.events.onViewerAdded,c,n.awaitViewer))}finally{}}))}},3527:(e,t,n)=>{"use strict";n.d(t,{Mi:()=>i});class i extends Float32Array{}},3629:(e,t,n)=>{"use strict";n.d(t,{KE:()=>a,S8:()=>l,dC:()=>s,vA:()=>o,wQ:()=>r});var i=n(3527);function o(e=!1,t="Assertion error."){if(!e)throw new Error(t)}function s(e,t,n=1){const s=e.length;o(s==t.length,"Vector lengths do not match.");const r=new i.Mi(s);for(let i=0;i<e.length;++i)r[i]=e[i]+n*t[i];return r}function r(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n]*e[n];return Math.sqrt(t)}function a(e,t){if(e.length!=t.length)throw new Error("The dimensionality of the vectors must match");let n=0;for(let i=0;i<e.length;i++)n+=e[i]*t[i];return n}function l(e){const t=e.length;let n=0,i=0;for(let o=0;o<t;++o)n+=e[o],i+=Math.pow(e[o],2);const o=n/t,s=1/Math.sqrt(i/t-Math.pow(o,2));for(let n=0;n<t;++n)e[n]=(e[n]-o)*s;return e}},1913:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(3282),o=n(9029),s=n(1520),r=n(2586),a=n(8708),l=n(2023),c="errorMessage",u=new i.Name("emUsed"),h={required:"missingProperty",dependencies:"property",dependentRequired:"property"},d=/\$\{[^}]+\}/,p=/\$\{([^}]+)\}/g,m=/^""\s*\+\s*|\s*\+\s*""$/g;const g=(e,t={})=>{if(!e.opts.allErrors)throw new Error("ajv-errors: Ajv option allErrors must be true");if(e.opts.jsPropertySyntax)throw new Error("ajv-errors: ajv option jsPropertySyntax is not supported");return e.addKeyword(function(e){return{keyword:c,schemaType:["string","object"],post:!0,code(t){const{gen:n,data:g,schema:f,schemaValue:y,it:b}=t;if(!1===b.createErrors)return;const w=f,v=o.strConcat(l.default.instancePath,b.errorPath);function A(e,t){return o.and(i._`${e}.keyword !== ${c}`,i._`!${e}.${u}`,i._`${e}.instancePath === ${v}`,i._`${e}.keyword in ${t}`,i._`${e}.schemaPath.indexOf(${b.errSchemaPath}) === 0`,i._`/^\\/[^\\/]*$/.test(${e}.schemaPath.slice(${b.errSchemaPath.length}))`)}function C(e,t){const i=[];for(const n in e){const e=t[n];d.test(e)&&i.push([n,S(e)])}return n.object(...i)}function T(e){return d.test(e)?new s._Code(s.safeStringify(e).replace(p,((e,t)=>`" + JSON.stringify(${r.getData(t,b)}) + "`)).replace(m,"")):i.stringify(e)}function S(e){return i._`function(){return ${T(e)}}`}n.if(i._`${l.default.errors} > 0`,(()=>{if("object"==typeof w){const[s,r]=function(e){let t,n;for(const i in e){if("properties"===i||"items"===i)continue;const o=e[i];if("object"==typeof o){t||(t={});const e=t[i]={};for(const t in o)e[t]=[]}else n||(n={}),n[i]=[]}return[t,n]}(w);r&&function(o){const s=n.const("emErrors",i.stringify(o)),r=n.const("templates",C(o,f));n.forOf("err",l.default.vErrors,(e=>n.if(A(e,s),(()=>n.code(i._`${s}[${e}.keyword].push(${e})`).assign(i._`${e}.${u}`,!0)))));const{singleError:c}=e;if(c){const e=n.let("message",i._`""`),o=n.let("paramsErrors",i._`[]`);h((t=>{n.if(e,(()=>n.code(i._`${e} += ${"string"==typeof c?c:";"}`))),n.code(i._`${e} += ${d(t)}`),n.assign(o,i._`${o}.concat(${s}[${t}])`)})),a.reportError(t,{message:e,params:i._`{errors: ${o}}`})}else h((e=>a.reportError(t,{message:d(e),params:i._`{errors: ${s}[${e}]}`})));function h(e){n.forIn("key",s,(t=>n.if(i._`${s}[${t}].length`,(()=>e(t)))))}function d(e){return i._`${e} in ${r} ? ${r}[${e}]() : ${y}[${e}]`}}(r),s&&function(e){const o=n.const("emErrors",i.stringify(e)),s=[];for(const t in e)s.push([t,C(e[t],f[t])]);const r=n.const("templates",n.object(...s)),c=n.scopeValue("obj",{ref:h,code:i.stringify(h)}),d=n.let("emPropParams"),p=n.let("emParamsErrors");n.forOf("err",l.default.vErrors,(e=>n.if(A(e,o),(()=>{n.assign(d,i._`${c}[${e}.keyword]`),n.assign(p,i._`${o}[${e}.keyword][${e}.params[${d}]]`),n.if(p,(()=>n.code(i._`${p}.push(${e})`).assign(i._`${e}.${u}`,!0)))})))),n.forIn("key",o,(e=>n.forIn("keyProp",i._`${o}[${e}]`,(s=>{n.assign(p,i._`${o}[${e}][${s}]`),n.if(i._`${p}.length`,(()=>{const o=n.const("tmpl",i._`${r}[${e}] && ${r}[${e}][${s}]`);a.reportError(t,{message:i._`${o} ? ${o}() : ${y}[${e}][${s}]`,params:i._`{errors: ${p}}`})}))}))))}(s),function(e){const{props:s,items:r}=e;if(!s&&!r)return;const h=i._`typeof ${g} == "object"`,d=i._`Array.isArray(${g})`,p=n.let("emErrors");let m,b;const w=n.let("templates");function A(e,t){n.assign(p,i.stringify(e)),n.assign(w,C(e,t))}s&&r?(m=n.let("emChildKwd"),n.if(h),n.if(d,(()=>{A(r,f.items),n.assign(m,i.str`items`)}),(()=>{A(s,f.properties),n.assign(m,i.str`properties`)})),b=i._`[${m}]`):r?(n.if(d),A(r,f.items),b=i._`.items`):s&&(n.if(o.and(h,o.not(d))),A(s,f.properties),b=i._`.properties`),n.forOf("err",l.default.vErrors,(e=>function(e,t,s){n.if(o.and(i._`${e}.keyword !== ${c}`,i._`!${e}.${u}`,i._`${e}.instancePath.indexOf(${v}) === 0`),(()=>{const o=n.scopeValue("pattern",{ref:/^\/([^/]*)(?:\/|$)/,code:i._`new RegExp("^\\\/([^/]*)(?:\\\/|$)")`}),r=n.const("emMatches",i._`${o}.exec(${e}.instancePath.slice(${v}.length))`),a=n.const("emChild",i._`${r} && ${r}[1].replace(/~1/g, "/").replace(/~0/g, "~")`);n.if(i._`${a} !== undefined && ${a} in ${t}`,(()=>s(a)))}))}(e,p,(t=>n.code(i._`${p}[${t}].push(${e})`).assign(i._`${e}.${u}`,!0))))),n.forIn("key",p,(e=>n.if(i._`${p}[${e}].length`,(()=>{a.reportError(t,{message:i._`${e} in ${w} ? ${w}[${e}]() : ${y}${b}[${e}]`,params:i._`{errors: ${p}[${e}]}`}),n.assign(i._`${l.default.vErrors}[${l.default.errors}-1].instancePath`,i._`${v} + "/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`)})))),n.endIf()}(function({properties:e,items:t}){const n={};if(e){n.props={};for(const t in e)n.props[t]=[]}if(t){n.items={};for(let e=0;e<t.length;e++)n.items[e]=[]}return n}(w))}const s="string"==typeof w?w:w._;s&&function(e){const s=n.const("emErrs",i._`[]`);n.forOf("err",l.default.vErrors,(e=>n.if(function(e){return o.and(i._`${e}.keyword !== ${c}`,i._`!${e}.${u}`,o.or(i._`${e}.instancePath === ${v}`,o.and(i._`${e}.instancePath.indexOf(${v}) === 0`,i._`${e}.instancePath[${v}.length] === "/"`)),i._`${e}.schemaPath.indexOf(${b.errSchemaPath}) === 0`,i._`${e}.schemaPath[${b.errSchemaPath}.length] === "/"`)}(e),(()=>n.code(i._`${s}.push(${e})`).assign(i._`${e}.${u}`,!0))))),n.if(i._`${s}.length`,(()=>a.reportError(t,{message:T(e),params:i._`{errors: ${s}}`})))}(s),e.keepErrors||function(){const e=n.const("emErrs",i._`[]`);n.forOf("err",l.default.vErrors,(t=>n.if(i._`!${t}.${u}`,(()=>n.code(i._`${e}.push(${t})`))))),n.assign(l.default.vErrors,e).assign(l.default.errors,i._`${e}.length`)}()}))},metaSchema:{anyOf:[{type:"string"},{type:"object",properties:{properties:{$ref:"#/$defs/stringMap"},items:{$ref:"#/$defs/stringList"},required:{$ref:"#/$defs/stringOrMap"},dependencies:{$ref:"#/$defs/stringOrMap"}},additionalProperties:{type:"string"}}],$defs:{stringMap:{type:"object",additionalProperties:{type:"string"}},stringOrMap:{anyOf:[{type:"string"},{$ref:"#/$defs/stringMap"}]},stringList:{type:"array",items:{type:"string"}}}}}}(t))};t.default=g,e.exports=g,e.exports.default=g},7433:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MissingRefError=t.ValidationError=t.CodeGen=t.Name=t.nil=t.stringify=t.str=t._=t.KeywordCxt=t.Ajv2020=void 0;const i=n(4042),o=n(6105),s=n(6653),r=n(9572),a="https://json-schema.org/draft/2020-12/schema";class l extends i.default{constructor(e={}){super({...e,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){super._addVocabularies(),o.default.forEach((e=>this.addVocabulary(e))),this.opts.discriminator&&this.addKeyword(s.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();const{$data:e,meta:t}=this.opts;t&&(r.default.call(this,e),this.refs["http://json-schema.org/schema"]=a)}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(a)?a:void 0)}}t.Ajv2020=l,e.exports=t=l,e.exports.Ajv2020=l,Object.defineProperty(t,"__esModule",{value:!0}),t.default=l;var c=n(2586);Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return c.KeywordCxt}});var u=n(9029);Object.defineProperty(t,"_",{enumerable:!0,get:function(){return u._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return u.str}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return u.stringify}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return u.nil}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return u.Name}}),Object.defineProperty(t,"CodeGen",{enumerable:!0,get:function(){return u.CodeGen}});var h=n(3558);Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return h.default}});var d=n(4551);Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return d.default}})},3282:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MissingRefError=t.ValidationError=t.CodeGen=t.Name=t.nil=t.stringify=t.str=t._=t.KeywordCxt=t.Ajv=void 0;const i=n(4042),o=n(6144),s=n(6653),r=n(2079),a=["/properties"],l="http://json-schema.org/draft-07/schema";class c extends i.default{_addVocabularies(){super._addVocabularies(),o.default.forEach((e=>this.addVocabulary(e))),this.opts.discriminator&&this.addKeyword(s.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const e=this.opts.$data?this.$dataMetaSchema(r,a):r;this.addMetaSchema(e,l,!1),this.refs["http://json-schema.org/schema"]=l}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(l)?l:void 0)}}t.Ajv=c,e.exports=t=c,e.exports.Ajv=c,Object.defineProperty(t,"__esModule",{value:!0}),t.default=c;var u=n(2586);Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return u.KeywordCxt}});var h=n(9029);Object.defineProperty(t,"_",{enumerable:!0,get:function(){return h._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return h.str}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return h.stringify}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return h.nil}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return h.Name}}),Object.defineProperty(t,"CodeGen",{enumerable:!0,get:function(){return h.CodeGen}});var d=n(3558);Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return d.default}});var p=n(4551);Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return p.default}})},1520:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.regexpCode=t.getEsmExportName=t.getProperty=t.safeStringify=t.stringify=t.strConcat=t.addCodeArg=t.str=t._=t.nil=t._Code=t.Name=t.IDENTIFIER=t._CodeOrName=void 0;class n{}t._CodeOrName=n,t.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class i extends n{constructor(e){if(super(),!t.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}t.Name=i;class o extends n{constructor(e){super(),this._items="string"==typeof e?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const e=this._items[0];return""===e||'""'===e}get str(){var e;return null!==(e=this._str)&&void 0!==e?e:this._str=this._items.reduce(((e,t)=>`${e}${t}`),"")}get names(){var e;return null!==(e=this._names)&&void 0!==e?e:this._names=this._items.reduce(((e,t)=>(t instanceof i&&(e[t.str]=(e[t.str]||0)+1),e)),{})}}function s(e,...t){const n=[e[0]];let i=0;for(;i<t.length;)l(n,t[i]),n.push(e[++i]);return new o(n)}t._Code=o,t.nil=new o(""),t._=s;const r=new o("+");function a(e,...t){const n=[u(e[0])];let i=0;for(;i<t.length;)n.push(r),l(n,t[i]),n.push(r,u(e[++i]));return function(e){let t=1;for(;t<e.length-1;){if(e[t]===r){const n=c(e[t-1],e[t+1]);if(void 0!==n){e.splice(t-1,3,n);continue}e[t++]="+"}t++}}(n),new o(n)}function l(e,t){var n;t instanceof o?e.push(...t._items):t instanceof i?e.push(t):e.push("number"==typeof(n=t)||"boolean"==typeof n||null===n?n:u(Array.isArray(n)?n.join(","):n))}function c(e,t){if('""'===t)return e;if('""'===e)return t;if("string"==typeof e){if(t instanceof i||'"'!==e[e.length-1])return;return"string"!=typeof t?`${e.slice(0,-1)}${t}"`:'"'===t[0]?e.slice(0,-1)+t.slice(1):void 0}return"string"!=typeof t||'"'!==t[0]||e instanceof i?void 0:`"${e}${t.slice(1)}`}function u(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}t.str=a,t.addCodeArg=l,t.strConcat=function(e,t){return t.emptyStr()?e:e.emptyStr()?t:a`${e}${t}`},t.stringify=function(e){return new o(u(e))},t.safeStringify=u,t.getProperty=function(e){return"string"==typeof e&&t.IDENTIFIER.test(e)?new o(`.${e}`):s`[${e}]`},t.getEsmExportName=function(e){if("string"==typeof e&&t.IDENTIFIER.test(e))return new o(`${e}`);throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)},t.regexpCode=function(e){return new o(e.toString())}},9029:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.or=t.and=t.not=t.CodeGen=t.operators=t.varKinds=t.ValueScopeName=t.ValueScope=t.Scope=t.Name=t.regexpCode=t.stringify=t.getProperty=t.nil=t.strConcat=t.str=t._=void 0;const i=n(1520),o=n(7845);var s=n(1520);Object.defineProperty(t,"_",{enumerable:!0,get:function(){return s._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return s.str}}),Object.defineProperty(t,"strConcat",{enumerable:!0,get:function(){return s.strConcat}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return s.nil}}),Object.defineProperty(t,"getProperty",{enumerable:!0,get:function(){return s.getProperty}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return s.stringify}}),Object.defineProperty(t,"regexpCode",{enumerable:!0,get:function(){return s.regexpCode}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return s.Name}});var r=n(7845);Object.defineProperty(t,"Scope",{enumerable:!0,get:function(){return r.Scope}}),Object.defineProperty(t,"ValueScope",{enumerable:!0,get:function(){return r.ValueScope}}),Object.defineProperty(t,"ValueScopeName",{enumerable:!0,get:function(){return r.ValueScopeName}}),Object.defineProperty(t,"varKinds",{enumerable:!0,get:function(){return r.varKinds}}),t.operators={GT:new i._Code(">"),GTE:new i._Code(">="),LT:new i._Code("<"),LTE:new i._Code("<="),EQ:new i._Code("==="),NEQ:new i._Code("!=="),NOT:new i._Code("!"),OR:new i._Code("||"),AND:new i._Code("&&"),ADD:new i._Code("+")};class a{optimizeNodes(){return this}optimizeNames(e,t){return this}}class l extends a{constructor(e,t,n){super(),this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){const n=e?o.varKinds.var:this.varKind,i=void 0===this.rhs?"":` = ${this.rhs}`;return`${n} ${this.name}${i};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&(this.rhs=P(this.rhs,e,t)),this}get names(){return this.rhs instanceof i._CodeOrName?this.rhs.names:{}}}class c extends a{constructor(e,t,n){super(),this.lhs=e,this.rhs=t,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,t){if(!(this.lhs instanceof i.Name)||e[this.lhs.str]||this.sideEffects)return this.rhs=P(this.rhs,e,t),this}get names(){return I(this.lhs instanceof i.Name?{}:{...this.lhs.names},this.rhs)}}class u extends c{constructor(e,t,n,i){super(e,n,i),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}}class h extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}}class d extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}}class p extends a{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}}class m extends a{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=P(this.code,e,t),this}get names(){return this.code instanceof i._CodeOrName?this.code.names:{}}}class g extends a{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce(((t,n)=>t+n.render(e)),"")}optimizeNodes(){const{nodes:e}=this;let t=e.length;for(;t--;){const n=e[t].optimizeNodes();Array.isArray(n)?e.splice(t,1,...n):n?e[t]=n:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){const{nodes:n}=this;let i=n.length;for(;i--;){const o=n[i];o.optimizeNames(e,t)||(N(e,o.names),n.splice(i,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce(((e,t)=>_(e,t.names)),{})}}class f extends g{render(e){return"{"+e._n+super.render(e)+"}"+e._n}}class y extends g{}class b extends f{}b.kind="else";class w extends f{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+="else "+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();const e=this.condition;if(!0===e)return this.nodes;let t=this.else;if(t){const e=t.optimizeNodes();t=this.else=Array.isArray(e)?new b(e):e}return t?!1===e?t instanceof w?t:t.nodes:this.nodes.length?this:new w(R(e),t instanceof w?[t]:t.nodes):!1!==e&&this.nodes.length?this:void 0}optimizeNames(e,t){var n;if(this.else=null===(n=this.else)||void 0===n?void 0:n.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=P(this.condition,e,t),this}get names(){const e=super.names;return I(e,this.condition),this.else&&_(e,this.else.names),e}}w.kind="if";class v extends f{}v.kind="for";class A extends v{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=P(this.iteration,e,t),this}get names(){return _(super.names,this.iteration.names)}}class C extends v{constructor(e,t,n,i){super(),this.varKind=e,this.name=t,this.from=n,this.to=i}render(e){const t=e.es5?o.varKinds.var:this.varKind,{name:n,from:i,to:s}=this;return`for(${t} ${n}=${i}; ${n}<${s}; ${n}++)`+super.render(e)}get names(){const e=I(super.names,this.from);return I(e,this.to)}}class T extends v{constructor(e,t,n,i){super(),this.loop=e,this.varKind=t,this.name=n,this.iterable=i}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=P(this.iterable,e,t),this}get names(){return _(super.names,this.iterable.names)}}class S extends f{constructor(e,t,n){super(),this.name=e,this.args=t,this.async=n}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}}S.kind="func";class E extends g{render(e){return"return "+super.render(e)}}E.kind="return";class M extends f{render(e){let t="try"+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),null===(e=this.catch)||void 0===e||e.optimizeNodes(),null===(t=this.finally)||void 0===t||t.optimizeNodes(),this}optimizeNames(e,t){var n,i;return super.optimizeNames(e,t),null===(n=this.catch)||void 0===n||n.optimizeNames(e,t),null===(i=this.finally)||void 0===i||i.optimizeNames(e,t),this}get names(){const e=super.names;return this.catch&&_(e,this.catch.names),this.finally&&_(e,this.finally.names),e}}class x extends f{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}}x.kind="catch";class L extends f{render(e){return"finally"+super.render(e)}}function _(e,t){for(const n in t)e[n]=(e[n]||0)+(t[n]||0);return e}function I(e,t){return t instanceof i._CodeOrName?_(e,t.names):e}function P(e,t,n){return e instanceof i.Name?s(e):(o=e)instanceof i._Code&&o._items.some((e=>e instanceof i.Name&&1===t[e.str]&&void 0!==n[e.str]))?new i._Code(e._items.reduce(((e,t)=>(t instanceof i.Name&&(t=s(t)),t instanceof i._Code?e.push(...t._items):e.push(t),e)),[])):e;var o;function s(e){const i=n[e.str];return void 0===i||1!==t[e.str]?e:(delete t[e.str],i)}}function N(e,t){for(const n in t)e[n]=(e[n]||0)-(t[n]||0)}function R(e){return"boolean"==typeof e||"number"==typeof e||null===e?!e:i._`!${k(e)}`}L.kind="finally",t.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?"\n":""},this._extScope=e,this._scope=new o.Scope({parent:e}),this._nodes=[new y]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){const n=this._extScope.value(e,t);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,n,i){const o=this._scope.toName(t);return void 0!==n&&i&&(this._constants[o.str]=n),this._leafNode(new l(e,o,n)),o}const(e,t,n){return this._def(o.varKinds.const,e,t,n)}let(e,t,n){return this._def(o.varKinds.let,e,t,n)}var(e,t,n){return this._def(o.varKinds.var,e,t,n)}assign(e,t,n){return this._leafNode(new c(e,t,n))}add(e,n){return this._leafNode(new u(e,t.operators.ADD,n))}code(e){return"function"==typeof e?e():e!==i.nil&&this._leafNode(new m(e)),this}object(...e){const t=["{"];for(const[n,o]of e)t.length>1&&t.push(","),t.push(n),(n!==o||this.opts.es5)&&(t.push(":"),(0,i.addCodeArg)(t,o));return t.push("}"),new i._Code(t)}if(e,t,n){if(this._blockNode(new w(e)),t&&n)this.code(t).else().code(n).endIf();else if(t)this.code(t).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new w(e))}else(){return this._elseNode(new b)}endIf(){return this._endBlockNode(w,b)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new A(e),t)}forRange(e,t,n,i,s=(this.opts.es5?o.varKinds.var:o.varKinds.let)){const r=this._scope.toName(e);return this._for(new C(s,r,t,n),(()=>i(r)))}forOf(e,t,n,s=o.varKinds.const){const r=this._scope.toName(e);if(this.opts.es5){const e=t instanceof i.Name?t:this.var("_arr",t);return this.forRange("_i",0,i._`${e}.length`,(t=>{this.var(r,i._`${e}[${t}]`),n(r)}))}return this._for(new T("of",s,r,t),(()=>n(r)))}forIn(e,t,n,s=(this.opts.es5?o.varKinds.var:o.varKinds.const)){if(this.opts.ownProperties)return this.forOf(e,i._`Object.keys(${t})`,n);const r=this._scope.toName(e);return this._for(new T("in",s,r,t),(()=>n(r)))}endFor(){return this._endBlockNode(v)}label(e){return this._leafNode(new h(e))}break(e){return this._leafNode(new d(e))}return(e){const t=new E;if(this._blockNode(t),this.code(e),1!==t.nodes.length)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(E)}try(e,t,n){if(!t&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');const i=new M;if(this._blockNode(i),this.code(e),t){const e=this.name("e");this._currNode=i.catch=new x(e),t(e)}return n&&(this._currNode=i.finally=new L,this.code(n)),this._endBlockNode(x,L)}throw(e){return this._leafNode(new p(e))}block(e,t){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(t),this}endBlock(e){const t=this._blockStarts.pop();if(void 0===t)throw new Error("CodeGen: not in self-balancing block");const n=this._nodes.length-t;if(n<0||void 0!==e&&n!==e)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=t,this}func(e,t=i.nil,n,o){return this._blockNode(new S(e,t,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(S)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,t){const n=this._currNode;if(n instanceof e||t&&n instanceof t)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){const t=this._currNode;if(!(t instanceof w))throw new Error('CodeGen: "else" without "if"');return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){const e=this._nodes;return e[e.length-1]}set _currNode(e){const t=this._nodes;t[t.length-1]=e}},t.not=R;const $=H(t.operators.AND);t.and=function(...e){return e.reduce($)};const O=H(t.operators.OR);function H(e){return(t,n)=>t===i.nil?n:n===i.nil?t:i._`${k(t)} ${e} ${k(n)}`}function k(e){return e instanceof i.Name?e:i._`(${e})`}t.or=function(...e){return e.reduce(O)}},7845:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ValueScope=t.ValueScopeName=t.Scope=t.varKinds=t.UsedValueState=void 0;const i=n(1520);class o extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}}var s;!function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"}(s||(t.UsedValueState=s={})),t.varKinds={const:new i.Name("const"),let:new i.Name("let"),var:new i.Name("var")};class r{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof i.Name?e:this.name(e)}name(e){return new i.Name(this._newName(e))}_newName(e){return`${e}${(this._names[e]||this._nameGroup(e)).index++}`}_nameGroup(e){var t,n;if((null===(n=null===(t=this._parent)||void 0===t?void 0:t._prefixes)||void 0===n?void 0:n.has(e))||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}}t.Scope=r;class a extends i.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:t,itemIndex:n}){this.value=e,this.scopePath=i._`.${new i.Name(t)}[${n}]`}}t.ValueScopeName=a;const l=i._`\n`;t.ValueScope=class extends r{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?l:i.nil}}get(){return this._scope}name(e){return new a(e,this._newName(e))}value(e,t){var n;if(void 0===t.ref)throw new Error("CodeGen: ref must be passed in value");const i=this.toName(e),{prefix:o}=i,s=null!==(n=t.key)&&void 0!==n?n:t.ref;let r=this._values[o];if(r){const e=r.get(s);if(e)return e}else r=this._values[o]=new Map;r.set(s,i);const a=this._scope[o]||(this._scope[o]=[]),l=a.length;return a[l]=t.ref,i.setValue(t,{property:o,itemIndex:l}),i}getValue(e,t){const n=this._values[e];if(n)return n.get(t)}scopeRefs(e,t=this._values){return this._reduceValues(t,(t=>{if(void 0===t.scopePath)throw new Error(`CodeGen: name "${t}" has no value`);return i._`${e}${t.scopePath}`}))}scopeCode(e=this._values,t,n){return this._reduceValues(e,(e=>{if(void 0===e.value)throw new Error(`CodeGen: name "${e}" has no value`);return e.value.code}),t,n)}_reduceValues(e,n,r={},a){let l=i.nil;for(const c in e){const u=e[c];if(!u)continue;const h=r[c]=r[c]||new Map;u.forEach((e=>{if(h.has(e))return;h.set(e,s.Started);let r=n(e);if(r){const n=this.opts.es5?t.varKinds.var:t.varKinds.const;l=i._`${l}${n} ${e} = ${r};${this.opts._n}`}else{if(!(r=null==a?void 0:a(e)))throw new o(e);l=i._`${l}${r}${this.opts._n}`}h.set(e,s.Completed)}))}return l}}},8708:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extendErrors=t.resetErrorsCount=t.reportExtraError=t.reportError=t.keyword$DataError=t.keywordError=void 0;const i=n(9029),o=n(4227),s=n(2023);function r(e,t){const n=e.const("err",t);e.if(i._`${s.default.vErrors} === null`,(()=>e.assign(s.default.vErrors,i._`[${n}]`)),i._`${s.default.vErrors}.push(${n})`),e.code(i._`${s.default.errors}++`)}function a(e,t){const{gen:n,validateName:o,schemaEnv:s}=e;s.$async?n.throw(i._`new ${e.ValidationError}(${t})`):(n.assign(i._`${o}.errors`,t),n.return(!1))}t.keywordError={message:({keyword:e})=>i.str`must pass "${e}" keyword validation`},t.keyword$DataError={message:({keyword:e,schemaType:t})=>t?i.str`"${e}" keyword must be ${t} ($data)`:i.str`"${e}" keyword is invalid ($data)`},t.reportError=function(e,n=t.keywordError,o,s){const{it:l}=e,{gen:u,compositeRule:h,allErrors:d}=l,p=c(e,n,o);(null!=s?s:h||d)?r(u,p):a(l,i._`[${p}]`)},t.reportExtraError=function(e,n=t.keywordError,i){const{it:o}=e,{gen:l,compositeRule:u,allErrors:h}=o;r(l,c(e,n,i)),u||h||a(o,s.default.vErrors)},t.resetErrorsCount=function(e,t){e.assign(s.default.errors,t),e.if(i._`${s.default.vErrors} !== null`,(()=>e.if(t,(()=>e.assign(i._`${s.default.vErrors}.length`,t)),(()=>e.assign(s.default.vErrors,null)))))},t.extendErrors=function({gen:e,keyword:t,schemaValue:n,data:o,errsCount:r,it:a}){if(void 0===r)throw new Error("ajv implementation error");const l=e.name("err");e.forRange("i",r,s.default.errors,(r=>{e.const(l,i._`${s.default.vErrors}[${r}]`),e.if(i._`${l}.instancePath === undefined`,(()=>e.assign(i._`${l}.instancePath`,(0,i.strConcat)(s.default.instancePath,a.errorPath)))),e.assign(i._`${l}.schemaPath`,i.str`${a.errSchemaPath}/${t}`),a.opts.verbose&&(e.assign(i._`${l}.schema`,n),e.assign(i._`${l}.data`,o))}))};const l={keyword:new i.Name("keyword"),schemaPath:new i.Name("schemaPath"),params:new i.Name("params"),propertyName:new i.Name("propertyName"),message:new i.Name("message"),schema:new i.Name("schema"),parentSchema:new i.Name("parentSchema")};function c(e,t,n){const{createErrors:o}=e.it;return!1===o?i._`{}`:function(e,t,n={}){const{gen:o,it:r}=e,a=[u(r,n),h(e,n)];return function(e,{params:t,message:n},o){const{keyword:r,data:a,schemaValue:c,it:u}=e,{opts:h,propertyName:d,topSchemaRef:p,schemaPath:m}=u;o.push([l.keyword,r],[l.params,"function"==typeof t?t(e):t||i._`{}`]),h.messages&&o.push([l.message,"function"==typeof n?n(e):n]),h.verbose&&o.push([l.schema,c],[l.parentSchema,i._`${p}${m}`],[s.default.data,a]),d&&o.push([l.propertyName,d])}(e,t,a),o.object(...a)}(e,t,n)}function u({errorPath:e},{instancePath:t}){const n=t?i.str`${e}${(0,o.getErrorPath)(t,o.Type.Str)}`:e;return[s.default.instancePath,(0,i.strConcat)(s.default.instancePath,n)]}function h({keyword:e,it:{errSchemaPath:t}},{schemaPath:n,parentSchema:s}){let r=s?t:i.str`${t}/${e}`;return n&&(r=i.str`${r}${(0,o.getErrorPath)(n,o.Type.Str)}`),[l.schemaPath,r]}},3835:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.resolveSchema=t.getCompilingSchema=t.resolveRef=t.compileSchema=t.SchemaEnv=void 0;const i=n(9029),o=n(3558),s=n(2023),r=n(6939),a=n(4227),l=n(2586);class c{constructor(e){var t;let n;this.refs={},this.dynamicAnchors={},"object"==typeof e.schema&&(n=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=null!==(t=e.baseId)&&void 0!==t?t:(0,r.normalizeId)(null==n?void 0:n[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=null==n?void 0:n.$async,this.refs={}}}function u(e){const t=d.call(this,e);if(t)return t;const n=(0,r.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:a,lines:c}=this.opts.code,{ownProperties:u}=this.opts,h=new i.CodeGen(this.scope,{es5:a,lines:c,ownProperties:u});let p;e.$async&&(p=h.scopeValue("Error",{ref:o.default,code:i._`require("ajv/dist/runtime/validation_error").default`}));const m=h.scopeName("validate");e.validateName=m;const g={gen:h,allErrors:this.opts.allErrors,data:s.default.data,parentData:s.default.parentData,parentDataProperty:s.default.parentDataProperty,dataNames:[s.default.data],dataPathArr:[i.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:h.scopeValue("schema",!0===this.opts.code.source?{ref:e.schema,code:(0,i.stringify)(e.schema)}:{ref:e.schema}),validateName:m,ValidationError:p,schema:e.schema,schemaEnv:e,rootId:n,baseId:e.baseId||n,schemaPath:i.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:i._`""`,opts:this.opts,self:this};let f;try{this._compilations.add(e),(0,l.validateFunctionCode)(g),h.optimize(this.opts.code.optimize);const t=h.toString();f=`${h.scopeRefs(s.default.scope)}return ${t}`,this.opts.code.process&&(f=this.opts.code.process(f,e));const n=new Function(`${s.default.self}`,`${s.default.scope}`,f)(this,this.scope.get());if(this.scope.value(m,{ref:n}),n.errors=null,n.schema=e.schema,n.schemaEnv=e,e.$async&&(n.$async=!0),!0===this.opts.code.source&&(n.source={validateName:m,validateCode:t,scopeValues:h._values}),this.opts.unevaluated){const{props:e,items:t}=g;n.evaluated={props:e instanceof i.Name?void 0:e,items:t instanceof i.Name?void 0:t,dynamicProps:e instanceof i.Name,dynamicItems:t instanceof i.Name},n.source&&(n.source.evaluated=(0,i.stringify)(n.evaluated))}return e.validate=n,e}catch(t){throw delete e.validate,delete e.validateName,f&&this.logger.error("Error compiling schema, function code:",f),t}finally{this._compilations.delete(e)}}function h(e){return(0,r.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:u.call(this,e)}function d(e){for(const i of this._compilations)if(n=e,(t=i).schema===n.schema&&t.root===n.root&&t.baseId===n.baseId)return i;var t,n}function p(e,t){let n;for(;"string"==typeof(n=this.refs[t]);)t=n;return n||this.schemas[t]||m.call(this,e,t)}function m(e,t){const n=this.opts.uriResolver.parse(t),i=(0,r._getFullPath)(this.opts.uriResolver,n);let o=(0,r.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&i===o)return f.call(this,n,e);const s=(0,r.normalizeId)(i),a=this.refs[s]||this.schemas[s];if("string"==typeof a){const t=m.call(this,e,a);if("object"!=typeof(null==t?void 0:t.schema))return;return f.call(this,n,t)}if("object"==typeof(null==a?void 0:a.schema)){if(a.validate||u.call(this,a),s===(0,r.normalizeId)(t)){const{schema:t}=a,{schemaId:n}=this.opts,i=t[n];return i&&(o=(0,r.resolveUrl)(this.opts.uriResolver,o,i)),new c({schema:t,schemaId:n,root:e,baseId:o})}return f.call(this,n,a)}}t.SchemaEnv=c,t.compileSchema=u,t.resolveRef=function(e,t,n){var i;n=(0,r.resolveUrl)(this.opts.uriResolver,t,n);const o=e.refs[n];if(o)return o;let s=p.call(this,e,n);if(void 0===s){const o=null===(i=e.localRefs)||void 0===i?void 0:i[n],{schemaId:r}=this.opts;o&&(s=new c({schema:o,schemaId:r,root:e,baseId:t}))}return void 0!==s?e.refs[n]=h.call(this,s):void 0},t.getCompilingSchema=d,t.resolveSchema=m;const g=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function f(e,{baseId:t,schema:n,root:i}){var o;if("/"!==(null===(o=e.fragment)||void 0===o?void 0:o[0]))return;for(const i of e.fragment.slice(1).split("/")){if("boolean"==typeof n)return;const e=n[(0,a.unescapeFragment)(i)];if(void 0===e)return;const o="object"==typeof(n=e)&&n[this.opts.schemaId];!g.has(i)&&o&&(t=(0,r.resolveUrl)(this.opts.uriResolver,t,o))}let s;if("boolean"!=typeof n&&n.$ref&&!(0,a.schemaHasRulesButRef)(n,this.RULES)){const e=(0,r.resolveUrl)(this.opts.uriResolver,t,n.$ref);s=m.call(this,i,e)}const{schemaId:l}=this.opts;return s=s||new c({schema:n,schemaId:l,root:i,baseId:t}),s.schema!==s.root.schema?s:void 0}},2023:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o={data:new i.Name("data"),valCxt:new i.Name("valCxt"),instancePath:new i.Name("instancePath"),parentData:new i.Name("parentData"),parentDataProperty:new i.Name("parentDataProperty"),rootData:new i.Name("rootData"),dynamicAnchors:new i.Name("dynamicAnchors"),vErrors:new i.Name("vErrors"),errors:new i.Name("errors"),this:new i.Name("this"),self:new i.Name("self"),scope:new i.Name("scope"),json:new i.Name("json"),jsonPos:new i.Name("jsonPos"),jsonLen:new i.Name("jsonLen"),jsonPart:new i.Name("jsonPart")};t.default=o},4551:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(6939);class o extends Error{constructor(e,t,n,o){super(o||`can't resolve reference ${n} from id ${t}`),this.missingRef=(0,i.resolveUrl)(e,t,n),this.missingSchema=(0,i.normalizeId)((0,i.getFullPath)(e,this.missingRef))}}t.default=o},6939:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getSchemaRefs=t.resolveUrl=t.normalizeId=t._getFullPath=t.getFullPath=t.inlineRef=void 0;const i=n(4227),o=n(2017),s=n(7106),r=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);t.inlineRef=function(e,t=!0){return"boolean"==typeof e||(!0===t?!l(e):!!t&&c(e)<=t)};const a=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function l(e){for(const t in e){if(a.has(t))return!0;const n=e[t];if(Array.isArray(n)&&n.some(l))return!0;if("object"==typeof n&&l(n))return!0}return!1}function c(e){let t=0;for(const n in e){if("$ref"===n)return 1/0;if(t++,!r.has(n)&&("object"==typeof e[n]&&(0,i.eachItem)(e[n],(e=>t+=c(e))),t===1/0))return 1/0}return t}function u(e,t="",n){!1!==n&&(t=p(t));const i=e.parse(t);return h(e,i)}function h(e,t){return e.serialize(t).split("#")[0]+"#"}t.getFullPath=u,t._getFullPath=h;const d=/#\/?$/;function p(e){return e?e.replace(d,""):""}t.normalizeId=p,t.resolveUrl=function(e,t,n){return n=p(n),e.resolve(t,n)};const m=/^[a-z_][-a-z0-9._]*$/i;t.getSchemaRefs=function(e,t){if("boolean"==typeof e)return{};const{schemaId:n,uriResolver:i}=this.opts,r=p(e[n]||t),a={"":r},l=u(i,r,!1),c={},h=new Set;return s(e,{allKeys:!0},((e,t,i,o)=>{if(void 0===o)return;const s=l+t;let r=a[o];function u(t){const n=this.opts.uriResolver.resolve;if(t=p(r?n(r,t):t),h.has(t))throw g(t);h.add(t);let i=this.refs[t];return"string"==typeof i&&(i=this.refs[i]),"object"==typeof i?d(e,i.schema,t):t!==p(s)&&("#"===t[0]?(d(e,c[t],t),c[t]=e):this.refs[t]=s),t}function f(e){if("string"==typeof e){if(!m.test(e))throw new Error(`invalid anchor "${e}"`);u.call(this,`#${e}`)}}"string"==typeof e[n]&&(r=u.call(this,e[n])),f.call(this,e.$anchor),f.call(this,e.$dynamicAnchor),a[t]=r})),c;function d(e,t,n){if(void 0!==t&&!o(e,t))throw g(n)}function g(e){return new Error(`reference "${e}" resolves to more than one schema`)}}},396:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getRules=t.isJSONType=void 0;const n=new Set(["string","number","integer","boolean","null","object","array"]);t.isJSONType=function(e){return"string"==typeof e&&n.has(e)},t.getRules=function(){const e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}},4227:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.checkStrictMode=t.getErrorPath=t.Type=t.useFunc=t.setEvaluated=t.evaluatedPropsToName=t.mergeEvaluated=t.eachItem=t.unescapeJsonPointer=t.escapeJsonPointer=t.escapeFragment=t.unescapeFragment=t.schemaRefOrVal=t.schemaHasRulesButRef=t.schemaHasRules=t.checkUnknownRules=t.alwaysValidSchema=t.toHash=void 0;const i=n(9029),o=n(1520);function s(e,t=e.schema){const{opts:n,self:i}=e;if(!n.strictSchema)return;if("boolean"==typeof t)return;const o=i.RULES.keywords;for(const n in t)o[n]||m(e,`unknown keyword: "${n}"`)}function r(e,t){if("boolean"==typeof e)return!e;for(const n in e)if(t[n])return!0;return!1}function a(e){return"number"==typeof e?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}function l(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function c({mergeNames:e,mergeToName:t,mergeValues:n,resultToName:o}){return(s,r,a,l)=>{const c=void 0===a?r:a instanceof i.Name?(r instanceof i.Name?e(s,r,a):t(s,r,a),a):r instanceof i.Name?(t(s,a,r),r):n(r,a);return l!==i.Name||c instanceof i.Name?c:o(s,c)}}function u(e,t){if(!0===t)return e.var("props",!0);const n=e.var("props",i._`{}`);return void 0!==t&&h(e,n,t),n}function h(e,t,n){Object.keys(n).forEach((n=>e.assign(i._`${t}${(0,i.getProperty)(n)}`,!0)))}t.toHash=function(e){const t={};for(const n of e)t[n]=!0;return t},t.alwaysValidSchema=function(e,t){return"boolean"==typeof t?t:0===Object.keys(t).length||(s(e,t),!r(t,e.self.RULES.all))},t.checkUnknownRules=s,t.schemaHasRules=r,t.schemaHasRulesButRef=function(e,t){if("boolean"==typeof e)return!e;for(const n in e)if("$ref"!==n&&t.all[n])return!0;return!1},t.schemaRefOrVal=function({topSchemaRef:e,schemaPath:t},n,o,s){if(!s){if("number"==typeof n||"boolean"==typeof n)return n;if("string"==typeof n)return i._`${n}`}return i._`${e}${t}${(0,i.getProperty)(o)}`},t.unescapeFragment=function(e){return l(decodeURIComponent(e))},t.escapeFragment=function(e){return encodeURIComponent(a(e))},t.escapeJsonPointer=a,t.unescapeJsonPointer=l,t.eachItem=function(e,t){if(Array.isArray(e))for(const n of e)t(n);else t(e)},t.mergeEvaluated={props:c({mergeNames:(e,t,n)=>e.if(i._`${n} !== true && ${t} !== undefined`,(()=>{e.if(i._`${t} === true`,(()=>e.assign(n,!0)),(()=>e.assign(n,i._`${n} || {}`).code(i._`Object.assign(${n}, ${t})`)))})),mergeToName:(e,t,n)=>e.if(i._`${n} !== true`,(()=>{!0===t?e.assign(n,!0):(e.assign(n,i._`${n} || {}`),h(e,n,t))})),mergeValues:(e,t)=>!0===e||{...e,...t},resultToName:u}),items:c({mergeNames:(e,t,n)=>e.if(i._`${n} !== true && ${t} !== undefined`,(()=>e.assign(n,i._`${t} === true ? true : ${n} > ${t} ? ${n} : ${t}`))),mergeToName:(e,t,n)=>e.if(i._`${n} !== true`,(()=>e.assign(n,!0===t||i._`${n} > ${t} ? ${n} : ${t}`))),mergeValues:(e,t)=>!0===e||Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})},t.evaluatedPropsToName=u,t.setEvaluated=h;const d={};var p;function m(e,t,n=e.opts.strictSchema){if(n){if(t=`strict mode: ${t}`,!0===n)throw new Error(t);e.self.logger.warn(t)}}t.useFunc=function(e,t){return e.scopeValue("func",{ref:t,code:d[t.code]||(d[t.code]=new o._Code(t.code))})},function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"}(p||(t.Type=p={})),t.getErrorPath=function(e,t,n){if(e instanceof i.Name){const o=t===p.Num;return n?o?i._`"[" + ${e} + "]"`:i._`"['" + ${e} + "']"`:o?i._`"/" + ${e}`:i._`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return n?(0,i.getProperty)(e).toString():"/"+a(e)},t.checkStrictMode=m},7887:(e,t)=>{"use strict";function n(e,t){return t.rules.some((t=>i(e,t)))}function i(e,t){var n;return void 0!==e[t.keyword]||(null===(n=t.definition.implements)||void 0===n?void 0:n.some((t=>void 0!==e[t])))}Object.defineProperty(t,"__esModule",{value:!0}),t.shouldUseRule=t.shouldUseGroup=t.schemaHasRulesForType=void 0,t.schemaHasRulesForType=function({schema:e,self:t},i){const o=t.RULES.types[i];return o&&!0!==o&&n(e,o)},t.shouldUseGroup=n,t.shouldUseRule=i},8727:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.boolOrEmptySchema=t.topBoolOrEmptySchema=void 0;const i=n(8708),o=n(9029),s=n(2023),r={message:"boolean schema is false"};function a(e,t){const{gen:n,data:o}=e,s={gen:n,keyword:"false schema",data:o,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,i.reportError)(s,r,void 0,t)}t.topBoolOrEmptySchema=function(e){const{gen:t,schema:n,validateName:i}=e;!1===n?a(e,!1):"object"==typeof n&&!0===n.$async?t.return(s.default.data):(t.assign(o._`${i}.errors`,null),t.return(!0))},t.boolOrEmptySchema=function(e,t){const{gen:n,schema:i}=e;!1===i?(n.var(t,!1),a(e)):n.var(t,!0)}},208:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.reportTypeError=t.checkDataTypes=t.checkDataType=t.coerceAndCheckDataType=t.getJSONTypes=t.getSchemaTypes=t.DataType=void 0;const i=n(396),o=n(7887),s=n(8708),r=n(9029),a=n(4227);var l;function c(e){const t=Array.isArray(e)?e:e?[e]:[];if(t.every(i.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}!function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"}(l||(t.DataType=l={})),t.getSchemaTypes=function(e){const t=c(e.type);if(t.includes("null")){if(!1===e.nullable)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&void 0!==e.nullable)throw new Error('"nullable" cannot be used without "type"');!0===e.nullable&&t.push("null")}return t},t.getJSONTypes=c,t.coerceAndCheckDataType=function(e,t){const{gen:n,data:i,opts:s}=e,a=function(e,t){return t?e.filter((e=>u.has(e)||"array"===t&&"array"===e)):[]}(t,s.coerceTypes),c=t.length>0&&!(0===a.length&&1===t.length&&(0,o.schemaHasRulesForType)(e,t[0]));if(c){const o=d(t,i,s.strictNumbers,l.Wrong);n.if(o,(()=>{a.length?function(e,t,n){const{gen:i,data:o,opts:s}=e,a=i.let("dataType",r._`typeof ${o}`),l=i.let("coerced",r._`undefined`);"array"===s.coerceTypes&&i.if(r._`${a} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,(()=>i.assign(o,r._`${o}[0]`).assign(a,r._`typeof ${o}`).if(d(t,o,s.strictNumbers),(()=>i.assign(l,o))))),i.if(r._`${l} !== undefined`);for(const e of n)(u.has(e)||"array"===e&&"array"===s.coerceTypes)&&c(e);function c(e){switch(e){case"string":return void i.elseIf(r._`${a} == "number" || ${a} == "boolean"`).assign(l,r._`"" + ${o}`).elseIf(r._`${o} === null`).assign(l,r._`""`);case"number":return void i.elseIf(r._`${a} == "boolean" || ${o} === null
2
+ || (${a} == "string" && ${o} && ${o} == +${o})`).assign(l,r._`+${o}`);case"integer":return void i.elseIf(r._`${a} === "boolean" || ${o} === null
3
+ || (${a} === "string" && ${o} && ${o} == +${o} && !(${o} % 1))`).assign(l,r._`+${o}`);case"boolean":return void i.elseIf(r._`${o} === "false" || ${o} === 0 || ${o} === null`).assign(l,!1).elseIf(r._`${o} === "true" || ${o} === 1`).assign(l,!0);case"null":return i.elseIf(r._`${o} === "" || ${o} === 0 || ${o} === false`),void i.assign(l,null);case"array":i.elseIf(r._`${a} === "string" || ${a} === "number"
4
+ || ${a} === "boolean" || ${o} === null`).assign(l,r._`[${o}]`)}}i.else(),m(e),i.endIf(),i.if(r._`${l} !== undefined`,(()=>{i.assign(o,l),function({gen:e,parentData:t,parentDataProperty:n},i){e.if(r._`${t} !== undefined`,(()=>e.assign(r._`${t}[${n}]`,i)))}(e,l)}))}(e,t,a):m(e)}))}return c};const u=new Set(["string","number","integer","boolean","null"]);function h(e,t,n,i=l.Correct){const o=i===l.Correct?r.operators.EQ:r.operators.NEQ;let s;switch(e){case"null":return r._`${t} ${o} null`;case"array":s=r._`Array.isArray(${t})`;break;case"object":s=r._`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":s=a(r._`!(${t} % 1) && !isNaN(${t})`);break;case"number":s=a();break;default:return r._`typeof ${t} ${o} ${e}`}return i===l.Correct?s:(0,r.not)(s);function a(e=r.nil){return(0,r.and)(r._`typeof ${t} == "number"`,e,n?r._`isFinite(${t})`:r.nil)}}function d(e,t,n,i){if(1===e.length)return h(e[0],t,n,i);let o;const s=(0,a.toHash)(e);if(s.array&&s.object){const e=r._`typeof ${t} != "object"`;o=s.null?e:r._`!${t} || ${e}`,delete s.null,delete s.array,delete s.object}else o=r.nil;s.number&&delete s.integer;for(const e in s)o=(0,r.and)(o,h(e,t,n,i));return o}t.checkDataType=h,t.checkDataTypes=d;const p={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>"string"==typeof e?r._`{type: ${e}}`:r._`{type: ${t}}`};function m(e){const t=function(e){const{gen:t,data:n,schema:i}=e,o=(0,a.schemaRefOrVal)(e,i,"type");return{gen:t,keyword:"type",data:n,schema:i.type,schemaCode:o,schemaValue:o,parentSchema:i,params:{},it:e}}(e);(0,s.reportError)(t,p)}t.reportTypeError=m},7870:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.assignDefaults=void 0;const i=n(9029),o=n(4227);function s(e,t,n){const{gen:s,compositeRule:r,data:a,opts:l}=e;if(void 0===n)return;const c=i._`${a}${(0,i.getProperty)(t)}`;if(r)return void(0,o.checkStrictMode)(e,`default is ignored for: ${c}`);let u=i._`${c} === undefined`;"empty"===l.useDefaults&&(u=i._`${u} || ${c} === null || ${c} === ""`),s.if(u,i._`${c} = ${(0,i.stringify)(n)}`)}t.assignDefaults=function(e,t){const{properties:n,items:i}=e.schema;if("object"===t&&n)for(const t in n)s(e,t,n[t].default);else"array"===t&&Array.isArray(i)&&i.forEach(((t,n)=>s(e,n,t.default)))}},2586:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getData=t.KeywordCxt=t.validateFunctionCode=void 0;const i=n(8727),o=n(208),s=n(7887),r=n(208),a=n(7870),l=n(3673),c=n(4495),u=n(9029),h=n(2023),d=n(6939),p=n(4227),m=n(8708);function g({gen:e,validateName:t,schema:n,schemaEnv:i,opts:o},s){o.code.es5?e.func(t,u._`${h.default.data}, ${h.default.valCxt}`,i.$async,(()=>{e.code(u._`"use strict"; ${f(n,o)}`),function(e,t){e.if(h.default.valCxt,(()=>{e.var(h.default.instancePath,u._`${h.default.valCxt}.${h.default.instancePath}`),e.var(h.default.parentData,u._`${h.default.valCxt}.${h.default.parentData}`),e.var(h.default.parentDataProperty,u._`${h.default.valCxt}.${h.default.parentDataProperty}`),e.var(h.default.rootData,u._`${h.default.valCxt}.${h.default.rootData}`),t.dynamicRef&&e.var(h.default.dynamicAnchors,u._`${h.default.valCxt}.${h.default.dynamicAnchors}`)}),(()=>{e.var(h.default.instancePath,u._`""`),e.var(h.default.parentData,u._`undefined`),e.var(h.default.parentDataProperty,u._`undefined`),e.var(h.default.rootData,h.default.data),t.dynamicRef&&e.var(h.default.dynamicAnchors,u._`{}`)}))}(e,o),e.code(s)})):e.func(t,u._`${h.default.data}, ${function(e){return u._`{${h.default.instancePath}="", ${h.default.parentData}, ${h.default.parentDataProperty}, ${h.default.rootData}=${h.default.data}${e.dynamicRef?u._`, ${h.default.dynamicAnchors}={}`:u.nil}}={}`}(o)}`,i.$async,(()=>e.code(f(n,o)).code(s)))}function f(e,t){const n="object"==typeof e&&e[t.schemaId];return n&&(t.code.source||t.code.process)?u._`/*# sourceURL=${n} */`:u.nil}function y({schema:e,self:t}){if("boolean"==typeof e)return!e;for(const n in e)if(t.RULES.all[n])return!0;return!1}function b(e){return"boolean"!=typeof e.schema}function w(e){(0,p.checkUnknownRules)(e),function(e){const{schema:t,errSchemaPath:n,opts:i,self:o}=e;t.$ref&&i.ignoreKeywordsWithRef&&(0,p.schemaHasRulesButRef)(t,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${n}"`)}(e)}function v(e,t){if(e.opts.jtd)return C(e,[],!1,t);const n=(0,o.getSchemaTypes)(e.schema);C(e,n,!(0,o.coerceAndCheckDataType)(e,n),t)}function A({gen:e,schemaEnv:t,schema:n,errSchemaPath:i,opts:o}){const s=n.$comment;if(!0===o.$comment)e.code(u._`${h.default.self}.logger.log(${s})`);else if("function"==typeof o.$comment){const n=u.str`${i}/$comment`,o=e.scopeValue("root",{ref:t.root});e.code(u._`${h.default.self}.opts.$comment(${s}, ${n}, ${o}.schema)`)}}function C(e,t,n,i){const{gen:o,schema:a,data:l,allErrors:c,opts:d,self:m}=e,{RULES:g}=m;function f(p){(0,s.shouldUseGroup)(a,p)&&(p.type?(o.if((0,r.checkDataType)(p.type,l,d.strictNumbers)),T(e,p),1===t.length&&t[0]===p.type&&n&&(o.else(),(0,r.reportTypeError)(e)),o.endIf()):T(e,p),c||o.if(u._`${h.default.errors} === ${i||0}`))}!a.$ref||!d.ignoreKeywordsWithRef&&(0,p.schemaHasRulesButRef)(a,g)?(d.jtd||function(e,t){!e.schemaEnv.meta&&e.opts.strictTypes&&(function(e,t){t.length&&(e.dataTypes.length?(t.forEach((t=>{S(e.dataTypes,t)||E(e,`type "${t}" not allowed by context "${e.dataTypes.join(",")}"`)})),function(e,t){const n=[];for(const i of e.dataTypes)S(t,i)?n.push(i):t.includes("integer")&&"number"===i&&n.push("integer");e.dataTypes=n}(e,t)):e.dataTypes=t)}(e,t),e.opts.allowUnionTypes||function(e,t){t.length>1&&(2!==t.length||!t.includes("null"))&&E(e,"use allowUnionTypes to allow union type keyword")}(e,t),function(e,t){const n=e.self.RULES.all;for(const i in n){const o=n[i];if("object"==typeof o&&(0,s.shouldUseRule)(e.schema,o)){const{type:n}=o.definition;n.length&&!n.some((e=>{return i=e,(n=t).includes(i)||"number"===i&&n.includes("integer");var n,i}))&&E(e,`missing type "${n.join(",")}" for keyword "${i}"`)}}}(e,e.dataTypes))}(e,t),o.block((()=>{for(const e of g.rules)f(e);f(g.post)}))):o.block((()=>x(e,"$ref",g.all.$ref.definition)))}function T(e,t){const{gen:n,schema:i,opts:{useDefaults:o}}=e;o&&(0,a.assignDefaults)(e,t.type),n.block((()=>{for(const n of t.rules)(0,s.shouldUseRule)(i,n)&&x(e,n.keyword,n.definition,t.type)}))}function S(e,t){return e.includes(t)||"integer"===t&&e.includes("number")}function E(e,t){t+=` at "${e.schemaEnv.baseId+e.errSchemaPath}" (strictTypes)`,(0,p.checkStrictMode)(e,t,e.opts.strictTypes)}t.validateFunctionCode=function(e){b(e)&&(w(e),y(e))?function(e){const{schema:t,opts:n,gen:i}=e;g(e,(()=>{n.$comment&&t.$comment&&A(e),function(e){const{schema:t,opts:n}=e;void 0!==t.default&&n.useDefaults&&n.strictSchema&&(0,p.checkStrictMode)(e,"default is ignored in the schema root")}(e),i.let(h.default.vErrors,null),i.let(h.default.errors,0),n.unevaluated&&function(e){const{gen:t,validateName:n}=e;e.evaluated=t.const("evaluated",u._`${n}.evaluated`),t.if(u._`${e.evaluated}.dynamicProps`,(()=>t.assign(u._`${e.evaluated}.props`,u._`undefined`))),t.if(u._`${e.evaluated}.dynamicItems`,(()=>t.assign(u._`${e.evaluated}.items`,u._`undefined`)))}(e),v(e),function(e){const{gen:t,schemaEnv:n,validateName:i,ValidationError:o,opts:s}=e;n.$async?t.if(u._`${h.default.errors} === 0`,(()=>t.return(h.default.data)),(()=>t.throw(u._`new ${o}(${h.default.vErrors})`))):(t.assign(u._`${i}.errors`,h.default.vErrors),s.unevaluated&&function({gen:e,evaluated:t,props:n,items:i}){n instanceof u.Name&&e.assign(u._`${t}.props`,n),i instanceof u.Name&&e.assign(u._`${t}.items`,i)}(e),t.return(u._`${h.default.errors} === 0`))}(e)}))}(e):g(e,(()=>(0,i.topBoolOrEmptySchema)(e)))};class M{constructor(e,t,n){if((0,l.validateKeywordUsage)(e,t,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=t.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,p.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=t.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=t,this.$data)this.schemaCode=e.gen.const("vSchema",I(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,l.validSchemaType)(this.schema,t.schemaType,t.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(t.schemaType)}`);("code"in t?t.trackErrors:!1!==t.errors)&&(this.errsCount=e.gen.const("_errs",h.default.errors))}result(e,t,n){this.failResult((0,u.not)(e),t,n)}failResult(e,t,n){this.gen.if(e),n?n():this.error(),t?(this.gen.else(),t(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,t){this.failResult((0,u.not)(e),void 0,t)}fail(e){if(void 0===e)return this.error(),void(this.allErrors||this.gen.if(!1));this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);const{schemaCode:t}=this;this.fail(u._`${t} !== undefined && (${(0,u.or)(this.invalid$data(),e)})`)}error(e,t,n){if(t)return this.setParams(t),this._error(e,n),void this.setParams({});this._error(e,n)}_error(e,t){(e?m.reportExtraError:m.reportError)(this,this.def.error,t)}$dataError(){(0,m.reportError)(this,this.def.$dataError||m.keyword$DataError)}reset(){if(void 0===this.errsCount)throw new Error('add "trackErrors" to keyword definition');(0,m.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,t){t?Object.assign(this.params,e):this.params=e}block$data(e,t,n=u.nil){this.gen.block((()=>{this.check$data(e,n),t()}))}check$data(e=u.nil,t=u.nil){if(!this.$data)return;const{gen:n,schemaCode:i,schemaType:o,def:s}=this;n.if((0,u.or)(u._`${i} === undefined`,t)),e!==u.nil&&n.assign(e,!0),(o.length||s.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==u.nil&&n.assign(e,!1)),n.else()}invalid$data(){const{gen:e,schemaCode:t,schemaType:n,def:i,it:o}=this;return(0,u.or)(function(){if(n.length){if(!(t instanceof u.Name))throw new Error("ajv implementation error");const e=Array.isArray(n)?n:[n];return u._`${(0,r.checkDataTypes)(e,t,o.opts.strictNumbers,r.DataType.Wrong)}`}return u.nil}(),function(){if(i.validateSchema){const n=e.scopeValue("validate$data",{ref:i.validateSchema});return u._`!${n}(${t})`}return u.nil}())}subschema(e,t){const n=(0,c.getSubschema)(this.it,e);(0,c.extendSubschemaData)(n,this.it,e),(0,c.extendSubschemaMode)(n,e);const o={...this.it,...n,items:void 0,props:void 0};return function(e,t){b(e)&&(w(e),y(e))?function(e,t){const{schema:n,gen:i,opts:o}=e;o.$comment&&n.$comment&&A(e),function(e){const t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,d.resolveUrl)(e.opts.uriResolver,e.baseId,t))}(e),function(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}(e);const s=i.const("_errs",h.default.errors);v(e,s),i.var(t,u._`${s} === ${h.default.errors}`)}(e,t):(0,i.boolOrEmptySchema)(e,t)}(o,t),o}mergeEvaluated(e,t){const{it:n,gen:i}=this;n.opts.unevaluated&&(!0!==n.props&&void 0!==e.props&&(n.props=p.mergeEvaluated.props(i,e.props,n.props,t)),!0!==n.items&&void 0!==e.items&&(n.items=p.mergeEvaluated.items(i,e.items,n.items,t)))}mergeValidEvaluated(e,t){const{it:n,gen:i}=this;if(n.opts.unevaluated&&(!0!==n.props||!0!==n.items))return i.if(t,(()=>this.mergeEvaluated(e,u.Name))),!0}}function x(e,t,n,i){const o=new M(e,n,t);"code"in n?n.code(o,i):o.$data&&n.validate?(0,l.funcKeywordCode)(o,n):"macro"in n?(0,l.macroKeywordCode)(o,n):(n.compile||n.validate)&&(0,l.funcKeywordCode)(o,n)}t.KeywordCxt=M;const L=/^\/(?:[^~]|~0|~1)*$/,_=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function I(e,{dataLevel:t,dataNames:n,dataPathArr:i}){let o,s;if(""===e)return h.default.rootData;if("/"===e[0]){if(!L.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);o=e,s=h.default.rootData}else{const r=_.exec(e);if(!r)throw new Error(`Invalid JSON-pointer: ${e}`);const a=+r[1];if(o=r[2],"#"===o){if(a>=t)throw new Error(l("property/index",a));return i[t-a]}if(a>t)throw new Error(l("data",a));if(s=n[t-a],!o)return s}let r=s;const a=o.split("/");for(const e of a)e&&(s=u._`${s}${(0,u.getProperty)((0,p.unescapeJsonPointer)(e))}`,r=u._`${r} && ${s}`);return r;function l(e,n){return`Cannot access ${e} ${n} levels up, current level is ${t}`}}t.getData=I},3673:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validateKeywordUsage=t.validSchemaType=t.funcKeywordCode=t.macroKeywordCode=void 0;const i=n(9029),o=n(2023),s=n(5765),r=n(8708);function a(e){const{gen:t,data:n,it:o}=e;t.if(o.parentData,(()=>t.assign(n,i._`${o.parentData}[${o.parentDataProperty}]`)))}function l(e,t,n){if(void 0===n)throw new Error(`keyword "${t}" failed to compile`);return e.scopeValue("keyword","function"==typeof n?{ref:n}:{ref:n,code:(0,i.stringify)(n)})}t.macroKeywordCode=function(e,t){const{gen:n,keyword:o,schema:s,parentSchema:r,it:a}=e,c=t.macro.call(a.self,s,r,a),u=l(n,o,c);!1!==a.opts.validateSchema&&a.self.validateSchema(c,!0);const h=n.name("valid");e.subschema({schema:c,schemaPath:i.nil,errSchemaPath:`${a.errSchemaPath}/${o}`,topSchemaRef:u,compositeRule:!0},h),e.pass(h,(()=>e.error(!0)))},t.funcKeywordCode=function(e,t){var n;const{gen:c,keyword:u,schema:h,parentSchema:d,$data:p,it:m}=e;!function({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}(m,t);const g=!p&&t.compile?t.compile.call(m.self,h,d,m):t.validate,f=l(c,u,g),y=c.let("valid");function b(n=(t.async?i._`await `:i.nil)){const r=m.opts.passContext?o.default.this:o.default.self,a=!("compile"in t&&!p||!1===t.schema);c.assign(y,i._`${n}${(0,s.callValidateCode)(e,f,r,a)}`,t.modifying)}function w(e){var n;c.if((0,i.not)(null!==(n=t.valid)&&void 0!==n?n:y),e)}e.block$data(y,(function(){if(!1===t.errors)b(),t.modifying&&a(e),w((()=>e.error()));else{const n=t.async?function(){const e=c.let("ruleErrs",null);return c.try((()=>b(i._`await `)),(t=>c.assign(y,!1).if(i._`${t} instanceof ${m.ValidationError}`,(()=>c.assign(e,i._`${t}.errors`)),(()=>c.throw(t))))),e}():function(){const e=i._`${f}.errors`;return c.assign(e,null),b(i.nil),e}();t.modifying&&a(e),w((()=>function(e,t){const{gen:n}=e;n.if(i._`Array.isArray(${t})`,(()=>{n.assign(o.default.vErrors,i._`${o.default.vErrors} === null ? ${t} : ${o.default.vErrors}.concat(${t})`).assign(o.default.errors,i._`${o.default.vErrors}.length`),(0,r.extendErrors)(e)}),(()=>e.error()))}(e,n)))}})),e.ok(null!==(n=t.valid)&&void 0!==n?n:y)},t.validSchemaType=function(e,t,n=!1){return!t.length||t.some((t=>"array"===t?Array.isArray(e):"object"===t?e&&"object"==typeof e&&!Array.isArray(e):typeof e==t||n&&void 0===e))},t.validateKeywordUsage=function({schema:e,opts:t,self:n,errSchemaPath:i},o,s){if(Array.isArray(o.keyword)?!o.keyword.includes(s):o.keyword!==s)throw new Error("ajv implementation error");const r=o.dependencies;if(null==r?void 0:r.some((t=>!Object.prototype.hasOwnProperty.call(e,t))))throw new Error(`parent schema must have dependencies of ${s}: ${r.join(",")}`);if(o.validateSchema&&!o.validateSchema(e[s])){const e=`keyword "${s}" value is invalid at path "${i}": `+n.errorsText(o.validateSchema.errors);if("log"!==t.validateSchema)throw new Error(e);n.logger.error(e)}}},4495:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extendSubschemaMode=t.extendSubschemaData=t.getSubschema=void 0;const i=n(9029),o=n(4227);t.getSubschema=function(e,{keyword:t,schemaProp:n,schema:s,schemaPath:r,errSchemaPath:a,topSchemaRef:l}){if(void 0!==t&&void 0!==s)throw new Error('both "keyword" and "schema" passed, only one allowed');if(void 0!==t){const s=e.schema[t];return void 0===n?{schema:s,schemaPath:i._`${e.schemaPath}${(0,i.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:s[n],schemaPath:i._`${e.schemaPath}${(0,i.getProperty)(t)}${(0,i.getProperty)(n)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,o.escapeFragment)(n)}`}}if(void 0!==s){if(void 0===r||void 0===a||void 0===l)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:s,schemaPath:r,topSchemaRef:l,errSchemaPath:a}}throw new Error('either "keyword" or "schema" must be passed')},t.extendSubschemaData=function(e,t,{dataProp:n,dataPropType:s,data:r,dataTypes:a,propertyName:l}){if(void 0!==r&&void 0!==n)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:c}=t;if(void 0!==n){const{errorPath:r,dataPathArr:a,opts:l}=t;u(c.let("data",i._`${t.data}${(0,i.getProperty)(n)}`,!0)),e.errorPath=i.str`${r}${(0,o.getErrorPath)(n,s,l.jsPropertySyntax)}`,e.parentDataProperty=i._`${n}`,e.dataPathArr=[...a,e.parentDataProperty]}function u(n){e.data=n,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,n]}void 0!==r&&(u(r instanceof i.Name?r:c.let("data",r,!0)),void 0!==l&&(e.propertyName=l)),a&&(e.dataTypes=a)},t.extendSubschemaMode=function(e,{jtdDiscriminator:t,jtdMetadata:n,compositeRule:i,createErrors:o,allErrors:s}){void 0!==i&&(e.compositeRule=i),void 0!==o&&(e.createErrors=o),void 0!==s&&(e.allErrors=s),e.jtdDiscriminator=t,e.jtdMetadata=n}},4042:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CodeGen=t.Name=t.nil=t.stringify=t.str=t._=t.KeywordCxt=void 0;var i=n(2586);Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return i.KeywordCxt}});var o=n(9029);Object.defineProperty(t,"_",{enumerable:!0,get:function(){return o._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return o.str}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return o.stringify}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return o.nil}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return o.Name}}),Object.defineProperty(t,"CodeGen",{enumerable:!0,get:function(){return o.CodeGen}});const s=n(3558),r=n(4551),a=n(396),l=n(3835),c=n(9029),u=n(6939),h=n(208),d=n(4227),p=n(3837),m=n(5944),g=(e,t)=>new RegExp(e,t);g.code="new RegExp";const f=["removeAdditional","useDefaults","coerceTypes"],y=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),b={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},w={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'};function v(e){var t,n,i,o,s,r,a,l,c,u,h,d,p,f,y,b,w,v,A,C,T,S,E,M,x;const L=e.strict,_=null===(t=e.code)||void 0===t?void 0:t.optimize,I=!0===_||void 0===_?1:_||0,P=null!==(i=null===(n=e.code)||void 0===n?void 0:n.regExp)&&void 0!==i?i:g,N=null!==(o=e.uriResolver)&&void 0!==o?o:m.default;return{strictSchema:null===(r=null!==(s=e.strictSchema)&&void 0!==s?s:L)||void 0===r||r,strictNumbers:null===(l=null!==(a=e.strictNumbers)&&void 0!==a?a:L)||void 0===l||l,strictTypes:null!==(u=null!==(c=e.strictTypes)&&void 0!==c?c:L)&&void 0!==u?u:"log",strictTuples:null!==(d=null!==(h=e.strictTuples)&&void 0!==h?h:L)&&void 0!==d?d:"log",strictRequired:null!==(f=null!==(p=e.strictRequired)&&void 0!==p?p:L)&&void 0!==f&&f,code:e.code?{...e.code,optimize:I,regExp:P}:{optimize:I,regExp:P},loopRequired:null!==(y=e.loopRequired)&&void 0!==y?y:200,loopEnum:null!==(b=e.loopEnum)&&void 0!==b?b:200,meta:null===(w=e.meta)||void 0===w||w,messages:null===(v=e.messages)||void 0===v||v,inlineRefs:null===(A=e.inlineRefs)||void 0===A||A,schemaId:null!==(C=e.schemaId)&&void 0!==C?C:"$id",addUsedSchema:null===(T=e.addUsedSchema)||void 0===T||T,validateSchema:null===(S=e.validateSchema)||void 0===S||S,validateFormats:null===(E=e.validateFormats)||void 0===E||E,unicodeRegExp:null===(M=e.unicodeRegExp)||void 0===M||M,int32range:null===(x=e.int32range)||void 0===x||x,uriResolver:N}}class A{constructor(e={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...v(e)};const{es5:t,lines:n}=this.opts.code;this.scope=new c.ValueScope({scope:{},prefixes:y,es5:t,lines:n}),this.logger=function(e){if(!1===e)return L;if(void 0===e)return console;if(e.log&&e.warn&&e.error)return e;throw new Error("logger must implement log, warn and error methods")}(e.logger);const i=e.validateFormats;e.validateFormats=!1,this.RULES=(0,a.getRules)(),C.call(this,b,e,"NOT SUPPORTED"),C.call(this,w,e,"DEPRECATED","warn"),this._metaOpts=x.call(this),e.formats&&E.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&M.call(this,e.keywords),"object"==typeof e.meta&&this.addMetaSchema(e.meta),S.call(this),e.validateFormats=i}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:e,meta:t,schemaId:n}=this.opts;let i=p;"id"===n&&(i={...p},i.id=i.$id,delete i.$id),t&&e&&this.addMetaSchema(i,i[n],!1)}defaultMeta(){const{meta:e,schemaId:t}=this.opts;return this.opts.defaultMeta="object"==typeof e?e[t]||e:void 0}validate(e,t){let n;if("string"==typeof e){if(n=this.getSchema(e),!n)throw new Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);const i=n(t);return"$async"in n||(this.errors=n.errors),i}compile(e,t){const n=this._addSchema(e,t);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,t){if("function"!=typeof this.opts.loadSchema)throw new Error("options.loadSchema should be a function");const{loadSchema:n}=this.opts;return i.call(this,e,t);async function i(e,t){await o.call(this,e.$schema);const n=this._addSchema(e,t);return n.validate||s.call(this,n)}async function o(e){e&&!this.getSchema(e)&&await i.call(this,{$ref:e},!0)}async function s(e){try{return this._compileSchemaEnv(e)}catch(t){if(!(t instanceof r.default))throw t;return a.call(this,t),await l.call(this,t.missingSchema),s.call(this,e)}}function a({missingSchema:e,missingRef:t}){if(this.refs[e])throw new Error(`AnySchema ${e} is loaded but ${t} cannot be resolved`)}async function l(e){const n=await c.call(this,e);this.refs[e]||await o.call(this,n.$schema),this.refs[e]||this.addSchema(n,e,t)}async function c(e){const t=this._loading[e];if(t)return t;try{return await(this._loading[e]=n(e))}finally{delete this._loading[e]}}}addSchema(e,t,n,i=this.opts.validateSchema){if(Array.isArray(e)){for(const t of e)this.addSchema(t,void 0,n,i);return this}let o;if("object"==typeof e){const{schemaId:t}=this.opts;if(o=e[t],void 0!==o&&"string"!=typeof o)throw new Error(`schema ${t} must be string`)}return t=(0,u.normalizeId)(t||o),this._checkUnique(t),this.schemas[t]=this._addSchema(e,n,t,i,!0),this}addMetaSchema(e,t,n=this.opts.validateSchema){return this.addSchema(e,t,!0,n),this}validateSchema(e,t){if("boolean"==typeof e)return!0;let n;if(n=e.$schema,void 0!==n&&"string"!=typeof n)throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,!0;const i=this.validate(n,e);if(!i&&t){const e="schema is invalid: "+this.errorsText();if("log"!==this.opts.validateSchema)throw new Error(e);this.logger.error(e)}return i}getSchema(e){let t;for(;"string"==typeof(t=T.call(this,e));)e=t;if(void 0===t){const{schemaId:n}=this.opts,i=new l.SchemaEnv({schema:{},schemaId:n});if(t=l.resolveSchema.call(this,i,e),!t)return;this.refs[e]=t}return t.validate||this._compileSchemaEnv(t)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{const t=T.call(this,e);return"object"==typeof t&&this._cache.delete(t.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{const t=e;this._cache.delete(t);let n=e[this.opts.schemaId];return n&&(n=(0,u.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(const t of e)this.addKeyword(t);return this}addKeyword(e,t){let n;if("string"==typeof e)n=e,"object"==typeof t&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),t.keyword=n);else{if("object"!=typeof e||void 0!==t)throw new Error("invalid addKeywords parameters");if(n=(t=e).keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}if(I.call(this,n,t),!t)return(0,d.eachItem)(n,(e=>P.call(this,e))),this;R.call(this,t);const i={...t,type:(0,h.getJSONTypes)(t.type),schemaType:(0,h.getJSONTypes)(t.schemaType)};return(0,d.eachItem)(n,0===i.type.length?e=>P.call(this,e,i):e=>i.type.forEach((t=>P.call(this,e,i,t)))),this}getKeyword(e){const t=this.RULES.all[e];return"object"==typeof t?t.definition:!!t}removeKeyword(e){const{RULES:t}=this;delete t.keywords[e],delete t.all[e];for(const n of t.rules){const t=n.rules.findIndex((t=>t.keyword===e));t>=0&&n.rules.splice(t,1)}return this}addFormat(e,t){return"string"==typeof t&&(t=new RegExp(t)),this.formats[e]=t,this}errorsText(e=this.errors,{separator:t=", ",dataVar:n="data"}={}){return e&&0!==e.length?e.map((e=>`${n}${e.instancePath} ${e.message}`)).reduce(((e,n)=>e+t+n)):"No errors"}$dataMetaSchema(e,t){const n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(const i of t){const t=i.split("/").slice(1);let o=e;for(const e of t)o=o[e];for(const e in n){const t=n[e];if("object"!=typeof t)continue;const{$data:i}=t.definition,s=o[e];i&&s&&(o[e]=O(s))}}return e}_removeAllSchemas(e,t){for(const n in e){const i=e[n];t&&!t.test(n)||("string"==typeof i?delete e[n]:i&&!i.meta&&(this._cache.delete(i.schema),delete e[n]))}}_addSchema(e,t,n,i=this.opts.validateSchema,o=this.opts.addUsedSchema){let s;const{schemaId:r}=this.opts;if("object"==typeof e)s=e[r];else{if(this.opts.jtd)throw new Error("schema must be object");if("boolean"!=typeof e)throw new Error("schema must be object or boolean")}let a=this._cache.get(e);if(void 0!==a)return a;n=(0,u.normalizeId)(s||n);const c=u.getSchemaRefs.call(this,e,n);return a=new l.SchemaEnv({schema:e,schemaId:r,meta:t,baseId:n,localRefs:c}),this._cache.set(a.schema,a),o&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=a),i&&this.validateSchema(e,!0),a}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):l.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){const t=this.opts;this.opts=this._metaOpts;try{l.compileSchema.call(this,e)}finally{this.opts=t}}}function C(e,t,n,i="error"){for(const o in e){const s=o;s in t&&this.logger[i](`${n}: option ${o}. ${e[s]}`)}}function T(e){return e=(0,u.normalizeId)(e),this.schemas[e]||this.refs[e]}function S(){const e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(const t in e)this.addSchema(e[t],t)}function E(){for(const e in this.opts.formats){const t=this.opts.formats[e];t&&this.addFormat(e,t)}}function M(e){if(Array.isArray(e))this.addVocabulary(e);else{this.logger.warn("keywords option as map is deprecated, pass array");for(const t in e){const n=e[t];n.keyword||(n.keyword=t),this.addKeyword(n)}}}function x(){const e={...this.opts};for(const t of f)delete e[t];return e}A.ValidationError=s.default,A.MissingRefError=r.default,t.default=A;const L={log(){},warn(){},error(){}},_=/^[a-z_$][a-z0-9_$:-]*$/i;function I(e,t){const{RULES:n}=this;if((0,d.eachItem)(e,(e=>{if(n.keywords[e])throw new Error(`Keyword ${e} is already defined`);if(!_.test(e))throw new Error(`Keyword ${e} has invalid name`)})),t&&t.$data&&!("code"in t)&&!("validate"in t))throw new Error('$data keyword must have "code" or "validate" function')}function P(e,t,n){var i;const o=null==t?void 0:t.post;if(n&&o)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:s}=this;let r=o?s.post:s.rules.find((({type:e})=>e===n));if(r||(r={type:n,rules:[]},s.rules.push(r)),s.keywords[e]=!0,!t)return;const a={keyword:e,definition:{...t,type:(0,h.getJSONTypes)(t.type),schemaType:(0,h.getJSONTypes)(t.schemaType)}};t.before?N.call(this,r,a,t.before):r.rules.push(a),s.all[e]=a,null===(i=t.implements)||void 0===i||i.forEach((e=>this.addKeyword(e)))}function N(e,t,n){const i=e.rules.findIndex((e=>e.keyword===n));i>=0?e.rules.splice(i,0,t):(e.rules.push(t),this.logger.warn(`rule ${n} is not defined`))}function R(e){let{metaSchema:t}=e;void 0!==t&&(e.$data&&this.opts.$data&&(t=O(t)),e.validateSchema=this.compile(t,!0))}const $={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function O(e){return{anyOf:[e,$]}}},9572:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(1678),o=n(7216),s=n(9547),r=n(8226),a=n(518),l=n(4588),c=n(5707),u=n(7082),h=["/properties"];t.default=function(e){return[i,o,s,r,a,t(this,l),c,t(this,u)].forEach((e=>this.addMetaSchema(e,void 0,!1))),this;function t(t,n){return e?t.$dataMetaSchema(n,h):n}}},6250:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(2017);i.code='require("ajv/dist/runtime/equal").default',t.default=i},3853:(e,t)=>{"use strict";function n(e){const t=e.length;let n,i=0,o=0;for(;o<t;)i++,n=e.charCodeAt(o++),n>=55296&&n<=56319&&o<t&&(n=e.charCodeAt(o),56320==(64512&n)&&o++);return i}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n,n.code='require("ajv/dist/runtime/ucs2length").default'},5944:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(8343);i.code='require("ajv/dist/runtime/uri").default',t.default=i},3558:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});class n extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}}t.default=n},5457:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validateAdditionalItems=void 0;const i=n(9029),o=n(4227),s={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:{message:({params:{len:e}})=>i.str`must NOT have more than ${e} items`,params:({params:{len:e}})=>i._`{limit: ${e}}`},code(e){const{parentSchema:t,it:n}=e,{items:i}=t;Array.isArray(i)?r(e,i):(0,o.checkStrictMode)(n,'"additionalItems" is ignored when "items" is not an array of schemas')}};function r(e,t){const{gen:n,schema:s,data:r,keyword:a,it:l}=e;l.items=!0;const c=n.const("len",i._`${r}.length`);if(!1===s)e.setParams({len:t.length}),e.pass(i._`${c} <= ${t.length}`);else if("object"==typeof s&&!(0,o.alwaysValidSchema)(l,s)){const s=n.var("valid",i._`${c} <= ${t.length}`);n.if((0,i.not)(s),(()=>function(s){n.forRange("i",t.length,c,(t=>{e.subschema({keyword:a,dataProp:t,dataPropType:o.Type.Num},s),l.allErrors||n.if((0,i.not)(s),(()=>n.break()))}))}(s))),e.ok(s)}}t.validateAdditionalItems=r,t.default=s},8660:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(5765),o=n(9029),s=n(2023),r=n(4227),a={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:{message:"must NOT have additional properties",params:({params:e})=>o._`{additionalProperty: ${e.additionalProperty}}`},code(e){const{gen:t,schema:n,parentSchema:a,data:l,errsCount:c,it:u}=e;if(!c)throw new Error("ajv implementation error");const{allErrors:h,opts:d}=u;if(u.props=!0,"all"!==d.removeAdditional&&(0,r.alwaysValidSchema)(u,n))return;const p=(0,i.allSchemaProperties)(a.properties),m=(0,i.allSchemaProperties)(a.patternProperties);function g(e){t.code(o._`delete ${l}[${e}]`)}function f(i){if("all"===d.removeAdditional||d.removeAdditional&&!1===n)g(i);else{if(!1===n)return e.setParams({additionalProperty:i}),e.error(),void(h||t.break());if("object"==typeof n&&!(0,r.alwaysValidSchema)(u,n)){const n=t.name("valid");"failing"===d.removeAdditional?(y(i,n,!1),t.if((0,o.not)(n),(()=>{e.reset(),g(i)}))):(y(i,n),h||t.if((0,o.not)(n),(()=>t.break())))}}}function y(t,n,i){const o={keyword:"additionalProperties",dataProp:t,dataPropType:r.Type.Str};!1===i&&Object.assign(o,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(o,n)}t.forIn("key",l,(n=>{p.length||m.length?t.if(function(n){let s;if(p.length>8){const e=(0,r.schemaRefOrVal)(u,a.properties,"properties");s=(0,i.isOwnProperty)(t,e,n)}else s=p.length?(0,o.or)(...p.map((e=>o._`${n} === ${e}`))):o.nil;return m.length&&(s=(0,o.or)(s,...m.map((t=>o._`${(0,i.usePattern)(e,t)}.test(${n})`)))),(0,o.not)(s)}(n),(()=>f(n))):f(n)})),e.ok(o._`${c} === ${s.default.errors}`)}};t.default=a},5844:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(4227),o={keyword:"allOf",schemaType:"array",code(e){const{gen:t,schema:n,it:o}=e;if(!Array.isArray(n))throw new Error("ajv implementation error");const s=t.name("valid");n.forEach(((t,n)=>{if((0,i.alwaysValidSchema)(o,t))return;const r=e.subschema({keyword:"allOf",schemaProp:n},s);e.ok(s),e.mergeEvaluated(r)}))}};t.default=o},6505:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:n(5765).validateUnion,error:{message:"must match a schema in anyOf"}};t.default=i},2661:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o=n(4227),s={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:{message:({params:{min:e,max:t}})=>void 0===t?i.str`must contain at least ${e} valid item(s)`:i.str`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>void 0===t?i._`{minContains: ${e}}`:i._`{minContains: ${e}, maxContains: ${t}}`},code(e){const{gen:t,schema:n,parentSchema:s,data:r,it:a}=e;let l,c;const{minContains:u,maxContains:h}=s;a.opts.next?(l=void 0===u?1:u,c=h):l=1;const d=t.const("len",i._`${r}.length`);if(e.setParams({min:l,max:c}),void 0===c&&0===l)return void(0,o.checkStrictMode)(a,'"minContains" == 0 without "maxContains": "contains" keyword ignored');if(void 0!==c&&l>c)return(0,o.checkStrictMode)(a,'"minContains" > "maxContains" is always invalid'),void e.fail();if((0,o.alwaysValidSchema)(a,n)){let t=i._`${d} >= ${l}`;return void 0!==c&&(t=i._`${t} && ${d} <= ${c}`),void e.pass(t)}a.items=!0;const p=t.name("valid");function m(){const e=t.name("_valid"),n=t.let("count",0);g(e,(()=>t.if(e,(()=>function(e){t.code(i._`${e}++`),void 0===c?t.if(i._`${e} >= ${l}`,(()=>t.assign(p,!0).break())):(t.if(i._`${e} > ${c}`,(()=>t.assign(p,!1).break())),1===l?t.assign(p,!0):t.if(i._`${e} >= ${l}`,(()=>t.assign(p,!0))))}(n)))))}function g(n,i){t.forRange("i",0,d,(t=>{e.subschema({keyword:"contains",dataProp:t,dataPropType:o.Type.Num,compositeRule:!0},n),i()}))}void 0===c&&1===l?g(p,(()=>t.if(p,(()=>t.break())))):0===l?(t.let(p,!0),void 0!==c&&t.if(i._`${r}.length > 0`,m)):(t.let(p,!1),m()),e.result(p,(()=>e.reset()))}};t.default=s},3025:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validateSchemaDeps=t.validatePropertyDeps=t.error=void 0;const i=n(9029),o=n(4227),s=n(5765);t.error={message:({params:{property:e,depsCount:t,deps:n}})=>{const o=1===t?"property":"properties";return i.str`must have ${o} ${n} when property ${e} is present`},params:({params:{property:e,depsCount:t,deps:n,missingProperty:o}})=>i._`{property: ${e},
5
5
  missingProperty: ${o},
6
6
  depsCount: ${t},
7
- deps: ${n}}`};const i={keyword:"dependencies",type:"object",schemaType:"object",error:t.error,code(e){const[t,n]=function({schema:e}){const t={},n={};for(const r in e)"__proto__"!==r&&((Array.isArray(e[r])?t:n)[r]=e[r]);return[t,n]}(e);a(e,t),c(e,n)}};function a(e,t=e.schema){const{gen:n,data:o,it:i}=e;if(0===Object.keys(t).length)return;const a=n.let("missing");for(const c in t){const l=t[c];if(0===l.length)continue;const u=(0,s.propertyInData)(n,o,c,i.opts.ownProperties);e.setParams({property:c,depsCount:l.length,deps:l.join(", ")}),i.allErrors?n.if(u,(()=>{for(const t of l)(0,s.checkReportMissingProp)(e,t)})):(n.if(r._`${u} && (${(0,s.checkMissingProp)(e,l,a)})`),(0,s.reportMissingProp)(e,a),n.else())}}function c(e,t=e.schema){const{gen:n,data:r,keyword:i,it:a}=e,c=n.name("valid");for(const l in t)(0,o.alwaysValidSchema)(a,t[l])||(n.if((0,s.propertyInData)(n,r,l,a.opts.ownProperties),(()=>{const t=e.subschema({keyword:i,schemaProp:l},c);e.mergeValidEvaluated(t,c)}),(()=>n.var(c,!0))),e.ok(c))}t.validatePropertyDeps=a,t.validateSchemaDeps=c,t.default=i},4845:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(3025),o={keyword:"dependentSchemas",type:"object",schemaType:"object",code:e=>(0,r.validateSchemaDeps)(e)};t.default=o},1239:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(9029),o=n(4227),s={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:{message:({params:e})=>r.str`must match "${e.ifClause}" schema`,params:({params:e})=>r._`{failingKeyword: ${e.ifClause}}`},code(e){const{gen:t,parentSchema:n,it:s}=e;void 0===n.then&&void 0===n.else&&(0,o.checkStrictMode)(s,'"if" without "then" and "else" is ignored');const a=i(s,"then"),c=i(s,"else");if(!a&&!c)return;const l=t.let("valid",!0),u=t.name("_valid");if(function(){const t=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},u);e.mergeEvaluated(t)}(),e.reset(),a&&c){const n=t.let("ifClause");e.setParams({ifClause:n}),t.if(u,d("then",n),d("else",n))}else a?t.if(u,d("then")):t.if((0,r.not)(u),d("else"));function d(n,o){return()=>{const s=e.subschema({keyword:n},u);t.assign(l,u),e.mergeValidEvaluated(s,l),o?t.assign(o,r._`${n}`):e.setParams({ifClause:n})}}e.pass(l,(()=>e.error(!0)))}};function i(e,t){const n=e.schema[t];return void 0!==n&&!(0,o.alwaysValidSchema)(e,n)}t.default=s},6378:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(5457),o=n(5354),s=n(494),i=n(3966),a=n(2661),c=n(3025),l=n(2094),u=n(8660),d=n(117),h=n(5333),p=n(7923),m=n(6505),f=n(6163),g=n(5844),y=n(1239),b=n(4426);t.default=function(e=!1){const t=[p.default,m.default,f.default,g.default,y.default,b.default,l.default,u.default,c.default,d.default,h.default];return e?t.push(o.default,i.default):t.push(r.default,s.default),t.push(a.default),t}},494:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validateTuple=void 0;const r=n(9029),o=n(4227),s=n(5765),i={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){const{schema:t,it:n}=e;if(Array.isArray(t))return a(e,"additionalItems",t);n.items=!0,(0,o.alwaysValidSchema)(n,t)||e.ok((0,s.validateArray)(e))}};function a(e,t,n=e.schema){const{gen:s,parentSchema:i,data:a,keyword:c,it:l}=e;!function(e){const{opts:r,errSchemaPath:s}=l,i=n.length,a=i===e.minItems&&(i===e.maxItems||!1===e[t]);if(r.strictTuples&&!a){const e=`"${c}" is ${i}-tuple, but minItems or maxItems/${t} are not specified or different at path "${s}"`;(0,o.checkStrictMode)(l,e,r.strictTuples)}}(i),l.opts.unevaluated&&n.length&&!0!==l.items&&(l.items=o.mergeEvaluated.items(s,n.length,l.items));const u=s.name("valid"),d=s.const("len",r._`${a}.length`);n.forEach(((t,n)=>{(0,o.alwaysValidSchema)(l,t)||(s.if(r._`${d} > ${n}`,(()=>e.subschema({keyword:c,schemaProp:n,dataProp:n},u))),e.ok(u))}))}t.validateTuple=a,t.default=i},3966:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(9029),o=n(4227),s=n(5765),i=n(5457),a={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:{message:({params:{len:e}})=>r.str`must NOT have more than ${e} items`,params:({params:{len:e}})=>r._`{limit: ${e}}`},code(e){const{schema:t,parentSchema:n,it:r}=e,{prefixItems:a}=n;r.items=!0,(0,o.alwaysValidSchema)(r,t)||(a?(0,i.validateAdditionalItems)(e,a):e.ok((0,s.validateArray)(e)))}};t.default=a},7923:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(4227),o={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){const{gen:t,schema:n,it:o}=e;if((0,r.alwaysValidSchema)(o,n))return void e.fail();const s=t.name("valid");e.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},s),e.failResult(s,(()=>e.reset()),(()=>e.error()))},error:{message:"must NOT be valid"}};t.default=o},6163:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(9029),o=n(4227),s={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:{message:"must match exactly one schema in oneOf",params:({params:e})=>r._`{passingSchemas: ${e.passing}}`},code(e){const{gen:t,schema:n,parentSchema:s,it:i}=e;if(!Array.isArray(n))throw new Error("ajv implementation error");if(i.opts.discriminator&&s.discriminator)return;const a=n,c=t.let("valid",!1),l=t.let("passing",null),u=t.name("_valid");e.setParams({passing:l}),t.block((function(){a.forEach(((n,s)=>{let a;(0,o.alwaysValidSchema)(i,n)?t.var(u,!0):a=e.subschema({keyword:"oneOf",schemaProp:s,compositeRule:!0},u),s>0&&t.if(r._`${u} && ${c}`).assign(c,!1).assign(l,r._`[${l}, ${s}]`).else(),t.if(u,(()=>{t.assign(c,!0),t.assign(l,s),a&&e.mergeEvaluated(a,r.Name)}))}))})),e.result(c,(()=>e.reset()),(()=>e.error(!0)))}};t.default=s},5333:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(5765),o=n(9029),s=n(4227),i=n(4227),a={keyword:"patternProperties",type:"object",schemaType:"object",code(e){const{gen:t,schema:n,data:a,parentSchema:c,it:l}=e,{opts:u}=l,d=(0,r.allSchemaProperties)(n),h=d.filter((e=>(0,s.alwaysValidSchema)(l,n[e])));if(0===d.length||h.length===d.length&&(!l.opts.unevaluated||!0===l.props))return;const p=u.strictSchema&&!u.allowMatchingProperties&&c.properties,m=t.name("valid");!0===l.props||l.props instanceof o.Name||(l.props=(0,i.evaluatedPropsToName)(t,l.props));const{props:f}=l;function g(e){for(const t in p)new RegExp(e).test(t)&&(0,s.checkStrictMode)(l,`property ${t} matches pattern ${e} (use allowMatchingProperties)`)}function y(n){t.forIn("key",a,(s=>{t.if(o._`${(0,r.usePattern)(e,n)}.test(${s})`,(()=>{const r=h.includes(n);r||e.subschema({keyword:"patternProperties",schemaProp:n,dataProp:s,dataPropType:i.Type.Str},m),l.opts.unevaluated&&!0!==f?t.assign(o._`${f}[${s}]`,!0):r||l.allErrors||t.if((0,o.not)(m),(()=>t.break()))}))}))}!function(){for(const e of d)p&&g(e),l.allErrors?y(e):(t.var(m,!0),y(e),t.if(m))}()}};t.default=a},5354:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(494),o={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,r.validateTuple)(e,"items")};t.default=o},117:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(2586),o=n(5765),s=n(4227),i=n(8660),a={keyword:"properties",type:"object",schemaType:"object",code(e){const{gen:t,schema:n,parentSchema:a,data:c,it:l}=e;"all"===l.opts.removeAdditional&&void 0===a.additionalProperties&&i.default.code(new r.KeywordCxt(l,i.default,"additionalProperties"));const u=(0,o.allSchemaProperties)(n);for(const e of u)l.definedProperties.add(e);l.opts.unevaluated&&u.length&&!0!==l.props&&(l.props=s.mergeEvaluated.props(t,(0,s.toHash)(u),l.props));const d=u.filter((e=>!(0,s.alwaysValidSchema)(l,n[e])));if(0===d.length)return;const h=t.name("valid");for(const n of d)p(n)?m(n):(t.if((0,o.propertyInData)(t,c,n,l.opts.ownProperties)),m(n),l.allErrors||t.else().var(h,!0),t.endIf()),e.it.definedProperties.add(n),e.ok(h);function p(e){return l.opts.useDefaults&&!l.compositeRule&&void 0!==n[e].default}function m(t){e.subschema({keyword:"properties",schemaProp:t,dataProp:t},h)}}};t.default=a},2094:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(9029),o=n(4227),s={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:{message:"property name must be valid",params:({params:e})=>r._`{propertyName: ${e.propertyName}}`},code(e){const{gen:t,schema:n,data:s,it:i}=e;if((0,o.alwaysValidSchema)(i,n))return;const a=t.name("valid");t.forIn("key",s,(n=>{e.setParams({propertyName:n}),e.subschema({keyword:"propertyNames",data:n,dataTypes:["string"],propertyName:n,compositeRule:!0},a),t.if((0,r.not)(a),(()=>{e.error(!0),i.allErrors||t.break()}))})),e.ok(a)}};t.default=s},4426:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(4227),o={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:n}){void 0===t.if&&(0,r.checkStrictMode)(n,`"${e}" without "if" is ignored`)}};t.default=o},5765:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validateUnion=t.validateArray=t.usePattern=t.callValidateCode=t.schemaProperties=t.allSchemaProperties=t.noPropertyInData=t.propertyInData=t.isOwnProperty=t.hasPropFunc=t.reportMissingProp=t.checkMissingProp=t.checkReportMissingProp=void 0;const r=n(9029),o=n(4227),s=n(2023),i=n(4227);function a(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:r._`Object.prototype.hasOwnProperty`})}function c(e,t,n){return r._`${a(e)}.call(${t}, ${n})`}function l(e,t,n,o){const s=r._`${t}${(0,r.getProperty)(n)} === undefined`;return o?(0,r.or)(s,(0,r.not)(c(e,t,n))):s}function u(e){return e?Object.keys(e).filter((e=>"__proto__"!==e)):[]}t.checkReportMissingProp=function(e,t){const{gen:n,data:o,it:s}=e;n.if(l(n,o,t,s.opts.ownProperties),(()=>{e.setParams({missingProperty:r._`${t}`},!0),e.error()}))},t.checkMissingProp=function({gen:e,data:t,it:{opts:n}},o,s){return(0,r.or)(...o.map((o=>(0,r.and)(l(e,t,o,n.ownProperties),r._`${s} = ${o}`))))},t.reportMissingProp=function(e,t){e.setParams({missingProperty:t},!0),e.error()},t.hasPropFunc=a,t.isOwnProperty=c,t.propertyInData=function(e,t,n,o){const s=r._`${t}${(0,r.getProperty)(n)} !== undefined`;return o?r._`${s} && ${c(e,t,n)}`:s},t.noPropertyInData=l,t.allSchemaProperties=u,t.schemaProperties=function(e,t){return u(t).filter((n=>!(0,o.alwaysValidSchema)(e,t[n])))},t.callValidateCode=function({schemaCode:e,data:t,it:{gen:n,topSchemaRef:o,schemaPath:i,errorPath:a},it:c},l,u,d){const h=d?r._`${e}, ${t}, ${o}${i}`:t,p=[[s.default.instancePath,(0,r.strConcat)(s.default.instancePath,a)],[s.default.parentData,c.parentData],[s.default.parentDataProperty,c.parentDataProperty],[s.default.rootData,s.default.rootData]];c.opts.dynamicRef&&p.push([s.default.dynamicAnchors,s.default.dynamicAnchors]);const m=r._`${h}, ${n.object(...p)}`;return u!==r.nil?r._`${l}.call(${u}, ${m})`:r._`${l}(${m})`};const d=r._`new RegExp`;t.usePattern=function({gen:e,it:{opts:t}},n){const o=t.unicodeRegExp?"u":"",{regExp:s}=t.code,a=s(n,o);return e.scopeValue("pattern",{key:a.toString(),ref:a,code:r._`${"new RegExp"===s.code?d:(0,i.useFunc)(e,s)}(${n}, ${o})`})},t.validateArray=function(e){const{gen:t,data:n,keyword:s,it:i}=e,a=t.name("valid");if(i.allErrors){const e=t.let("valid",!0);return c((()=>t.assign(e,!1))),e}return t.var(a,!0),c((()=>t.break())),a;function c(i){const c=t.const("len",r._`${n}.length`);t.forRange("i",0,c,(n=>{e.subschema({keyword:s,dataProp:n,dataPropType:o.Type.Num},a),t.if((0,r.not)(a),i)}))}},t.validateUnion=function(e){const{gen:t,schema:n,keyword:s,it:i}=e;if(!Array.isArray(n))throw new Error("ajv implementation error");if(n.some((e=>(0,o.alwaysValidSchema)(i,e)))&&!i.opts.unevaluated)return;const a=t.let("valid",!1),c=t.name("_valid");t.block((()=>n.forEach(((n,o)=>{const i=e.subschema({keyword:s,schemaProp:o,compositeRule:!0},c);t.assign(a,r._`${a} || ${c}`),e.mergeValidEvaluated(i,c)||t.if((0,r.not)(a))})))),e.result(a,(()=>e.reset()),(()=>e.error(!0)))}},3463:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};t.default=n},2128:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(3463),o=n(3693),s=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",r.default,o.default];t.default=s},3693:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.callRef=t.getValidate=void 0;const r=n(4551),o=n(5765),s=n(9029),i=n(2023),a=n(3835),c=n(4227),l={keyword:"$ref",schemaType:"string",code(e){const{gen:t,schema:n,it:o}=e,{baseId:i,schemaEnv:c,validateName:l,opts:h,self:p}=o,{root:m}=c;if(("#"===n||"#/"===n)&&i===m.baseId)return function(){if(c===m)return d(e,l,c,c.$async);const n=t.scopeValue("root",{ref:m});return d(e,s._`${n}.validate`,m,m.$async)}();const f=a.resolveRef.call(p,m,i,n);if(void 0===f)throw new r.default(o.opts.uriResolver,i,n);return f instanceof a.SchemaEnv?function(t){const n=u(e,t);d(e,n,t,t.$async)}(f):function(r){const o=t.scopeValue("schema",!0===h.code.source?{ref:r,code:(0,s.stringify)(r)}:{ref:r}),i=t.name("valid"),a=e.subschema({schema:r,dataTypes:[],schemaPath:s.nil,topSchemaRef:o,errSchemaPath:n},i);e.mergeEvaluated(a),e.ok(i)}(f)}};function u(e,t){const{gen:n}=e;return t.validate?n.scopeValue("validate",{ref:t.validate}):s._`${n.scopeValue("wrapper",{ref:t})}.validate`}function d(e,t,n,r){const{gen:a,it:l}=e,{allErrors:u,schemaEnv:d,opts:h}=l,p=h.passContext?i.default.this:s.nil;function m(e){const t=s._`${e}.errors`;a.assign(i.default.vErrors,s._`${i.default.vErrors} === null ? ${t} : ${i.default.vErrors}.concat(${t})`),a.assign(i.default.errors,s._`${i.default.vErrors}.length`)}function f(e){var t;if(!l.opts.unevaluated)return;const r=null===(t=null==n?void 0:n.validate)||void 0===t?void 0:t.evaluated;if(!0!==l.props)if(r&&!r.dynamicProps)void 0!==r.props&&(l.props=c.mergeEvaluated.props(a,r.props,l.props));else{const t=a.var("props",s._`${e}.evaluated.props`);l.props=c.mergeEvaluated.props(a,t,l.props,s.Name)}if(!0!==l.items)if(r&&!r.dynamicItems)void 0!==r.items&&(l.items=c.mergeEvaluated.items(a,r.items,l.items));else{const t=a.var("items",s._`${e}.evaluated.items`);l.items=c.mergeEvaluated.items(a,t,l.items,s.Name)}}r?function(){if(!d.$async)throw new Error("async schema referenced by sync schema");const n=a.let("valid");a.try((()=>{a.code(s._`await ${(0,o.callValidateCode)(e,t,p)}`),f(t),u||a.assign(n,!0)}),(e=>{a.if(s._`!(${e} instanceof ${l.ValidationError})`,(()=>a.throw(e))),m(e),u||a.assign(n,!1)})),e.ok(n)}():e.result((0,o.callValidateCode)(e,t,p),(()=>f(t)),(()=>m(t)))}t.getValidate=u,t.callRef=d,t.default=l},6653:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(9029),o=n(7652),s=n(3835),i=n(4551),a=n(4227),c={keyword:"discriminator",type:"object",schemaType:"object",error:{message:({params:{discrError:e,tagName:t}})=>e===o.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:n}})=>r._`{error: ${e}, tag: ${n}, tagValue: ${t}}`},code(e){const{gen:t,data:n,schema:c,parentSchema:l,it:u}=e,{oneOf:d}=l;if(!u.opts.discriminator)throw new Error("discriminator: requires discriminator option");const h=c.propertyName;if("string"!=typeof h)throw new Error("discriminator: requires propertyName");if(c.mapping)throw new Error("discriminator: mapping is not supported");if(!d)throw new Error("discriminator: requires oneOf keyword");const p=t.let("valid",!1),m=t.const("tag",r._`${n}${(0,r.getProperty)(h)}`);function f(n){const o=t.name("valid"),s=e.subschema({keyword:"oneOf",schemaProp:n},o);return e.mergeEvaluated(s,r.Name),o}t.if(r._`typeof ${m} == "string"`,(()=>function(){const n=function(){var e;const t={},n=o(l);let r=!0;for(let t=0;t<d.length;t++){let l=d[t];if((null==l?void 0:l.$ref)&&!(0,a.schemaHasRulesButRef)(l,u.self.RULES)){const e=l.$ref;if(l=s.resolveRef.call(u.self,u.schemaEnv.root,u.baseId,e),l instanceof s.SchemaEnv&&(l=l.schema),void 0===l)throw new i.default(u.opts.uriResolver,u.baseId,e)}const p=null===(e=null==l?void 0:l.properties)||void 0===e?void 0:e[h];if("object"!=typeof p)throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${h}"`);r=r&&(n||o(l)),c(p,t)}if(!r)throw new Error(`discriminator: "${h}" must be required`);return t;function o({required:e}){return Array.isArray(e)&&e.includes(h)}function c(e,t){if(e.const)p(e.const,t);else{if(!e.enum)throw new Error(`discriminator: "properties/${h}" must have "const" or "enum"`);for(const n of e.enum)p(n,t)}}function p(e,n){if("string"!=typeof e||e in t)throw new Error(`discriminator: "${h}" values must be unique strings`);t[e]=n}}();t.if(!1);for(const e in n)t.elseIf(r._`${m} === ${e}`),t.assign(p,f(n[e]));t.else(),e.error(!1,{discrError:o.DiscrError.Mapping,tag:m,tagName:h}),t.endIf()}()),(()=>e.error(!1,{discrError:o.DiscrError.Tag,tag:m,tagName:h}))),e.ok(p)}};t.default=c},7652:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.DiscrError=void 0,function(e){e.Tag="tag",e.Mapping="mapping"}(n||(t.DiscrError=n={}))},6105:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(2128),o=n(7060),s=n(6378),i=n(5520),a=n(5413),c=n(3265),l=n(7532),u=n(9857),d=[i.default,r.default,o.default,(0,s.default)(!0),l.default,u.metadataVocabulary,u.contentVocabulary,a.default,c.default];t.default=d},6144:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(2128),o=n(7060),s=n(6378),i=n(7532),a=n(9857),c=[r.default,o.default,(0,s.default)(),i.default,a.metadataVocabulary,a.contentVocabulary];t.default=c},2476:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dynamicAnchor=void 0;const r=n(9029),o=n(2023),s=n(3835),i=n(3693),a={keyword:"$dynamicAnchor",schemaType:"string",code:e=>c(e,e.schema)};function c(e,t){const{gen:n,it:a}=e;a.schemaEnv.root.dynamicAnchors[t]=!0;const c=r._`${o.default.dynamicAnchors}${(0,r.getProperty)(t)}`,l="#"===a.errSchemaPath?a.validateName:function(e){const{schemaEnv:t,schema:n,self:r}=e.it,{root:o,baseId:a,localRefs:c,meta:l}=t.root,{schemaId:u}=r.opts,d=new s.SchemaEnv({schema:n,schemaId:u,root:o,baseId:a,localRefs:c,meta:l});return s.compileSchema.call(r,d),(0,i.getValidate)(e,d)}(e);n.if(r._`!${c}`,(()=>n.assign(c,l)))}t.dynamicAnchor=c,t.default=a},3252:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dynamicRef=void 0;const r=n(9029),o=n(2023),s=n(3693),i={keyword:"$dynamicRef",schemaType:"string",code:e=>a(e,e.schema)};function a(e,t){const{gen:n,keyword:i,it:a}=e;if("#"!==t[0])throw new Error(`"${i}" only supports hash fragment reference`);const c=t.slice(1);if(a.allErrors)l();else{const t=n.let("valid",!1);l(t),e.ok(t)}function l(e){if(a.schemaEnv.root.dynamicAnchors[c]){const t=n.let("_v",r._`${o.default.dynamicAnchors}${(0,r.getProperty)(c)}`);n.if(t,u(t,e),u(a.validateName,e))}else u(a.validateName,e)()}function u(t,r){return r?()=>n.block((()=>{(0,s.callRef)(e,t),n.let(r,!0)})):()=>(0,s.callRef)(e,t)}}t.dynamicRef=a,t.default=i},5520:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(2476),o=n(3252),s=n(2721),i=n(3799),a=[r.default,o.default,s.default,i.default];t.default=a},2721:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(2476),o=n(4227),s={keyword:"$recursiveAnchor",schemaType:"boolean",code(e){e.schema?(0,r.dynamicAnchor)(e,""):(0,o.checkStrictMode)(e.it,"$recursiveAnchor: false is ignored")}};t.default=s},3799:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(3252),o={keyword:"$recursiveRef",schemaType:"string",code:e=>(0,r.dynamicRef)(e,e.schema)};t.default=o},4737:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(9029),o={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:{message:({schemaCode:e})=>r.str`must match format "${e}"`,params:({schemaCode:e})=>r._`{format: ${e}}`},code(e,t){const{gen:n,data:o,$data:s,schema:i,schemaCode:a,it:c}=e,{opts:l,errSchemaPath:u,schemaEnv:d,self:h}=c;l.validateFormats&&(s?function(){const s=n.scopeValue("formats",{ref:h.formats,code:l.code.formats}),i=n.const("fDef",r._`${s}[${a}]`),c=n.let("fType"),u=n.let("format");n.if(r._`typeof ${i} == "object" && !(${i} instanceof RegExp)`,(()=>n.assign(c,r._`${i}.type || "string"`).assign(u,r._`${i}.validate`)),(()=>n.assign(c,r._`"string"`).assign(u,i))),e.fail$data((0,r.or)(!1===l.strictSchema?r.nil:r._`${a} && !${u}`,function(){const e=d.$async?r._`(${i}.async ? await ${u}(${o}) : ${u}(${o}))`:r._`${u}(${o})`,n=r._`(typeof ${u} == "function" ? ${e} : ${u}.test(${o}))`;return r._`${u} && ${u} !== true && ${c} === ${t} && !${n}`}()))}():function(){const s=h.formats[i];if(!s)return void function(){if(!1!==l.strictSchema)throw new Error(e());function e(){return`unknown format "${i}" ignored in schema at path "${u}"`}h.logger.warn(e())}();if(!0===s)return;const[a,c,p]=function(e){const t=e instanceof RegExp?(0,r.regexpCode)(e):l.code.formats?r._`${l.code.formats}${(0,r.getProperty)(i)}`:void 0,o=n.scopeValue("formats",{key:i,ref:e,code:t});return"object"!=typeof e||e instanceof RegExp?["string",e,o]:[e.type||"string",e.validate,r._`${o}.validate`]}(s);a===t&&e.pass(function(){if("object"==typeof s&&!(s instanceof RegExp)&&s.async){if(!d.$async)throw new Error("async format in sync schema");return r._`await ${p}(${o})`}return"function"==typeof c?r._`${p}(${o})`:r._`${p}.test(${o})`}())}())}};t.default=o},7532:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=[n(4737).default];t.default=r},9857:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.contentVocabulary=t.metadataVocabulary=void 0,t.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"],t.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]},5413:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(1846),o=n(4845),s=n(2626),i=[r.default,o.default,s.default];t.default=i},3265:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(392),o=n(3445),s=[r.default,o.default];t.default=s},3445:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(9029),o=n(4227),s={keyword:"unevaluatedItems",type:"array",schemaType:["boolean","object"],error:{message:({params:{len:e}})=>r.str`must NOT have more than ${e} items`,params:({params:{len:e}})=>r._`{limit: ${e}}`},code(e){const{gen:t,schema:n,data:s,it:i}=e,a=i.items||0;if(!0===a)return;const c=t.const("len",r._`${s}.length`);if(!1===n)e.setParams({len:a}),e.fail(r._`${c} > ${a}`);else if("object"==typeof n&&!(0,o.alwaysValidSchema)(i,n)){const n=t.var("valid",r._`${c} <= ${a}`);t.if((0,r.not)(n),(()=>function(n,s){t.forRange("i",s,c,(s=>{e.subschema({keyword:"unevaluatedItems",dataProp:s,dataPropType:o.Type.Num},n),i.allErrors||t.if((0,r.not)(n),(()=>t.break()))}))}(n,a))),e.ok(n)}i.items=!0}};t.default=s},392:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(9029),o=n(4227),s=n(2023),i={keyword:"unevaluatedProperties",type:"object",schemaType:["boolean","object"],trackErrors:!0,error:{message:"must NOT have unevaluated properties",params:({params:e})=>r._`{unevaluatedProperty: ${e.unevaluatedProperty}}`},code(e){const{gen:t,schema:n,data:i,errsCount:a,it:c}=e;if(!a)throw new Error("ajv implementation error");const{allErrors:l,props:u}=c;function d(s){if(!1===n)return e.setParams({unevaluatedProperty:s}),e.error(),void(l||t.break());if(!(0,o.alwaysValidSchema)(c,n)){const n=t.name("valid");e.subschema({keyword:"unevaluatedProperties",dataProp:s,dataPropType:o.Type.Str},n),l||t.if((0,r.not)(n),(()=>t.break()))}}u instanceof r.Name?t.if(r._`${u} !== true`,(()=>t.forIn("key",i,(e=>t.if(function(e,t){return r._`!${e} || !${e}[${t}]`}(u,e),(()=>d(e))))))):!0!==u&&t.forIn("key",i,(e=>void 0===u?d(e):t.if(function(e,t){const n=[];for(const o in e)!0===e[o]&&n.push(r._`${t} !== ${o}`);return(0,r.and)(...n)}(u,e),(()=>d(e))))),c.props=!0,e.ok(r._`${a} === ${s.default.errors}`)}};t.default=i},7935:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(9029),o=n(4227),s=n(6250),i={keyword:"const",$data:!0,error:{message:"must be equal to constant",params:({schemaCode:e})=>r._`{allowedValue: ${e}}`},code(e){const{gen:t,data:n,$data:i,schemaCode:a,schema:c}=e;i||c&&"object"==typeof c?e.fail$data(r._`!${(0,o.useFunc)(t,s.default)}(${n}, ${a})`):e.fail(r._`${c} !== ${n}`)}};t.default=i},1846:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(3025),o={keyword:"dependentRequired",type:"object",schemaType:"object",error:r.error,code:e=>(0,r.validatePropertyDeps)(e)};t.default=o},8643:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(9029),o=n(4227),s=n(6250),i={keyword:"enum",schemaType:"array",$data:!0,error:{message:"must be equal to one of the allowed values",params:({schemaCode:e})=>r._`{allowedValues: ${e}}`},code(e){const{gen:t,data:n,$data:i,schema:a,schemaCode:c,it:l}=e;if(!i&&0===a.length)throw new Error("enum must have non-empty array");const u=a.length>=l.opts.loopEnum;let d;const h=()=>null!=d?d:d=(0,o.useFunc)(t,s.default);let p;if(u||i)p=t.let("valid"),e.block$data(p,(function(){t.assign(p,!1),t.forOf("v",c,(e=>t.if(r._`${h()}(${n}, ${e})`,(()=>t.assign(p,!0).break()))))}));else{if(!Array.isArray(a))throw new Error("ajv implementation error");const e=t.const("vSchema",c);p=(0,r.or)(...a.map(((t,o)=>function(e,t){const o=a[t];return"object"==typeof o&&null!==o?r._`${h()}(${n}, ${e}[${t}])`:r._`${n} === ${o}`}(e,o))))}e.pass(p)}};t.default=i},7060:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(5882),o=n(3439),s=n(7307),i=n(422),a=n(4486),c=n(4003),l=n(1163),u=n(617),d=n(7935),h=n(8643),p=[r.default,o.default,s.default,i.default,a.default,c.default,l.default,u.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},d.default,h.default];t.default=p},2626:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(4227),o={keyword:["maxContains","minContains"],type:"array",schemaType:"number",code({keyword:e,parentSchema:t,it:n}){void 0===t.contains&&(0,r.checkStrictMode)(n,`"${e}" without "contains" is ignored`)}};t.default=o},1163:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(9029),o={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:{message({keyword:e,schemaCode:t}){const n="maxItems"===e?"more":"fewer";return r.str`must NOT have ${n} than ${t} items`},params:({schemaCode:e})=>r._`{limit: ${e}}`},code(e){const{keyword:t,data:n,schemaCode:o}=e,s="maxItems"===t?r.operators.GT:r.operators.LT;e.fail$data(r._`${n}.length ${s} ${o}`)}};t.default=o},7307:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(9029),o=n(4227),s=n(3853),i={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:{message({keyword:e,schemaCode:t}){const n="maxLength"===e?"more":"fewer";return r.str`must NOT have ${n} than ${t} characters`},params:({schemaCode:e})=>r._`{limit: ${e}}`},code(e){const{keyword:t,data:n,schemaCode:i,it:a}=e,c="maxLength"===t?r.operators.GT:r.operators.LT,l=!1===a.opts.unicode?r._`${n}.length`:r._`${(0,o.useFunc)(e.gen,s.default)}(${n})`;e.fail$data(r._`${l} ${c} ${i}`)}};t.default=i},5882:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(9029),o=r.operators,s={maximum:{okStr:"<=",ok:o.LTE,fail:o.GT},minimum:{okStr:">=",ok:o.GTE,fail:o.LT},exclusiveMaximum:{okStr:"<",ok:o.LT,fail:o.GTE},exclusiveMinimum:{okStr:">",ok:o.GT,fail:o.LTE}},i={message:({keyword:e,schemaCode:t})=>r.str`must be ${s[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>r._`{comparison: ${s[e].okStr}, limit: ${t}}`},a={keyword:Object.keys(s),type:"number",schemaType:"number",$data:!0,error:i,code(e){const{keyword:t,data:n,schemaCode:o}=e;e.fail$data(r._`${n} ${s[t].fail} ${o} || isNaN(${n})`)}};t.default=a},4486:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(9029),o={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:{message({keyword:e,schemaCode:t}){const n="maxProperties"===e?"more":"fewer";return r.str`must NOT have ${n} than ${t} properties`},params:({schemaCode:e})=>r._`{limit: ${e}}`},code(e){const{keyword:t,data:n,schemaCode:o}=e,s="maxProperties"===t?r.operators.GT:r.operators.LT;e.fail$data(r._`Object.keys(${n}).length ${s} ${o}`)}};t.default=o},3439:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(9029),o={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:{message:({schemaCode:e})=>r.str`must be multiple of ${e}`,params:({schemaCode:e})=>r._`{multipleOf: ${e}}`},code(e){const{gen:t,data:n,schemaCode:o,it:s}=e,i=s.opts.multipleOfPrecision,a=t.let("res"),c=i?r._`Math.abs(Math.round(${a}) - ${a}) > 1e-${i}`:r._`${a} !== parseInt(${a})`;e.fail$data(r._`(${o} === 0 || (${a} = ${n}/${o}, ${c}))`)}};t.default=o},422:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(5765),o=n(9029),s={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:{message:({schemaCode:e})=>o.str`must match pattern "${e}"`,params:({schemaCode:e})=>o._`{pattern: ${e}}`},code(e){const{data:t,$data:n,schema:s,schemaCode:i,it:a}=e,c=a.opts.unicodeRegExp?"u":"",l=n?o._`(new RegExp(${i}, ${c}))`:(0,r.usePattern)(e,s);e.fail$data(o._`!${l}.test(${t})`)}};t.default=s},4003:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(5765),o=n(9029),s=n(4227),i={keyword:"required",type:"object",schemaType:"array",$data:!0,error:{message:({params:{missingProperty:e}})=>o.str`must have required property '${e}'`,params:({params:{missingProperty:e}})=>o._`{missingProperty: ${e}}`},code(e){const{gen:t,schema:n,schemaCode:i,data:a,$data:c,it:l}=e,{opts:u}=l;if(!c&&0===n.length)return;const d=n.length>=u.loopRequired;if(l.allErrors?function(){if(d||c)e.block$data(o.nil,h);else for(const t of n)(0,r.checkReportMissingProp)(e,t)}():function(){const s=t.let("missing");if(d||c){const n=t.let("valid",!0);e.block$data(n,(()=>function(n,s){e.setParams({missingProperty:n}),t.forOf(n,i,(()=>{t.assign(s,(0,r.propertyInData)(t,a,n,u.ownProperties)),t.if((0,o.not)(s),(()=>{e.error(),t.break()}))}),o.nil)}(s,n))),e.ok(n)}else t.if((0,r.checkMissingProp)(e,n,s)),(0,r.reportMissingProp)(e,s),t.else()}(),u.strictRequired){const t=e.parentSchema.properties,{definedProperties:r}=e.it;for(const e of n)if(void 0===(null==t?void 0:t[e])&&!r.has(e)){const t=`required property "${e}" is not defined at "${l.schemaEnv.baseId+l.errSchemaPath}" (strictRequired)`;(0,s.checkStrictMode)(l,t,l.opts.strictRequired)}}function h(){t.forOf("prop",i,(n=>{e.setParams({missingProperty:n}),t.if((0,r.noPropertyInData)(t,a,n,u.ownProperties),(()=>e.error()))}))}}};t.default=i},617:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(208),o=n(9029),s=n(4227),i=n(6250),a={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:{message:({params:{i:e,j:t}})=>o.str`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>o._`{i: ${e}, j: ${t}}`},code(e){const{gen:t,data:n,$data:a,schema:c,parentSchema:l,schemaCode:u,it:d}=e;if(!a&&!c)return;const h=t.let("valid"),p=l.items?(0,r.getSchemaTypes)(l.items):[];function m(s,i){const a=t.name("item"),c=(0,r.checkDataTypes)(p,a,d.opts.strictNumbers,r.DataType.Wrong),l=t.const("indices",o._`{}`);t.for(o._`;${s}--;`,(()=>{t.let(a,o._`${n}[${s}]`),t.if(c,o._`continue`),p.length>1&&t.if(o._`typeof ${a} == "string"`,o._`${a} += "_"`),t.if(o._`typeof ${l}[${a}] == "number"`,(()=>{t.assign(i,o._`${l}[${a}]`),e.error(),t.assign(h,!1).break()})).code(o._`${l}[${a}] = ${s}`)}))}function f(r,a){const c=(0,s.useFunc)(t,i.default),l=t.name("outer");t.label(l).for(o._`;${r}--;`,(()=>t.for(o._`${a} = ${r}; ${a}--;`,(()=>t.if(o._`${c}(${n}[${r}], ${n}[${a}])`,(()=>{e.error(),t.assign(h,!1).break(l)}))))))}e.block$data(h,(function(){const r=t.let("i",o._`${n}.length`),s=t.let("j");e.setParams({i:r,j:s}),t.assign(h,!0),t.if(o._`${r} > 1`,(()=>(p.length>0&&!p.some((e=>"object"===e||"array"===e))?m:f)(r,s)))}),o._`${u} === false`),e.ok(h)}};t.default=a},5488:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var r=n(1354),o=n.n(r),s=n(6314),i=n.n(s)()(o());i.push([e.id,"\n.ui-form.ui-tooltip .ui-input-root > label.ui-input-label:not(:empty) {\n /* min-width: 30px; /* Breaks right margin /**/\n}\n\n.ui-form.ui-tooltip .ui-input-root > div.ui-input-text:not(:empty) {\n margin-top: 6px;\n}","",{version:3,sources:["webpack://./css/cell-renderer.css"],names:[],mappings:";AACA;IACI,8CAA8C;AAClD;;AAEA;IACI,eAAe;AACnB",sourcesContent:["\n.ui-form.ui-tooltip .ui-input-root > label.ui-input-label:not(:empty) {\n /* min-width: 30px; /* Breaks right margin /**/\n}\n\n.ui-form.ui-tooltip .ui-input-root > div.ui-input-text:not(:empty) {\n margin-top: 6px;\n}"],sourceRoot:""}]);const a=i},5999:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var r=n(1354),o=n.n(r),s=n(6314),i=n.n(s)()(o());i.push([e.id,".macromolecule-cell-comp-analysis-host{\n max-height: 250px;\n overflow-y: scroll;\n}\n\n.macromolecule-cell-comp-analysis-bar{\n height: inherit;\n display: block;\n margin-top: 1.5px;\n margin-bottom: 1.5px;\n margin-right: 3px;\n}\n\n.macromolecule-cell-comp-analysis-value{\n display: flex;\n}","",{version:3,sources:["webpack://./css/composition-analysis.css"],names:[],mappings:"AAAA;IACI,iBAAiB;IACjB,kBAAkB;AACtB;;AAEA;IACI,eAAe;IACf,cAAc;IACd,iBAAiB;IACjB,oBAAoB;IACpB,iBAAiB;AACrB;;AAEA;IACI,aAAa;AACjB",sourcesContent:[".macromolecule-cell-comp-analysis-host{\n max-height: 250px;\n overflow-y: scroll;\n}\n\n.macromolecule-cell-comp-analysis-bar{\n height: inherit;\n display: block;\n margin-top: 1.5px;\n margin-bottom: 1.5px;\n margin-right: 3px;\n}\n\n.macromolecule-cell-comp-analysis-value{\n display: flex;\n}"],sourceRoot:""}]);const a=i},857:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var r=n(1354),o=n.n(r),s=n(6314),i=n.n(s)()(o());i.push([e.id,".monomer-manager-root .grok-sketcher {\n min-width: unset !important;\n}\n\n.monomer-manager-root {\n width: 100% !important;\n height: 100% !important;\n}\n\n.monomer-manager-sketcher .ketcher-host {\n height: 100% !important;\n width: unset !important;\n} \n\n.monomer-manager-root > div:first-child {\n flex-basis: 40% !important;\n}\n.monomer-manager-root > div:nth-child(2) {\n flex-basis: 60% !important;\n}\n\n.monomer-manager-root > div:first-child > .ui-form {\n max-width: unset !important;\n}\n\n.monomer-card-info-row {\n width: 100%;\n overflow: hidden;\n text-overflow: ellipsis;\n margin-bottom: 10px;\n}\n\n.monomer-card-info-row > div:nth-child(2) {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.monomer-card-info-row > div:nth-child(1) {\n font-weight: bold;\n margin-right: 5px;\n text-wrap: nowrap;\n}\n\n.duplicate-monomer-symbol-row {\n visibility: visible !important;\n}\n\n.monomer-card-root {\n border: 2px solid var(--grey-2);\n border-radius: 5px;\n padding: 5px;\n margin: 5px;\n overflow: hidden;\n align-items: center;\n cursor: pointer;\n width: 200px;\n height: 300px;\n min-width: 200px;\n min-height: 300px;\n}\n\n.duplicate-monomers-virtual-view {\n width: 100% !important;\n overflow-x: clip;\n overflow-y: auto;\n}\n\n.monomer-manager-form-tab-control input.d4-invalid {\n background: #ff000030;\n}\n\n.monomer-lib-controls-form .ui-input-root {\n flex-wrap: nowrap !important;\n}","",{version:3,sources:["webpack://./css/monomer-manager.css"],names:[],mappings:"AAAA;IACI,2BAA2B;AAC/B;;AAEA;IACI,sBAAsB;IACtB,uBAAuB;AAC3B;;AAEA;IACI,uBAAuB;IACvB,uBAAuB;AAC3B;;AAEA;IACI,0BAA0B;AAC9B;AACA;IACI,0BAA0B;AAC9B;;AAEA;IACI,2BAA2B;AAC/B;;AAEA;IACI,WAAW;IACX,gBAAgB;IAChB,uBAAuB;IACvB,mBAAmB;AACvB;;AAEA;IACI,mBAAmB;IACnB,gBAAgB;IAChB,uBAAuB;AAC3B;;AAEA;IACI,iBAAiB;IACjB,iBAAiB;IACjB,iBAAiB;AACrB;;AAEA;IACI,8BAA8B;AAClC;;AAEA;IACI,+BAA+B;IAC/B,kBAAkB;IAClB,YAAY;IACZ,WAAW;IACX,gBAAgB;IAChB,mBAAmB;IACnB,eAAe;IACf,YAAY;IACZ,aAAa;IACb,gBAAgB;IAChB,iBAAiB;AACrB;;AAEA;IACI,sBAAsB;IACtB,gBAAgB;IAChB,gBAAgB;AACpB;;AAEA;IACI,qBAAqB;AACzB;;AAEA;IACI,4BAA4B;AAChC",sourcesContent:[".monomer-manager-root .grok-sketcher {\n min-width: unset !important;\n}\n\n.monomer-manager-root {\n width: 100% !important;\n height: 100% !important;\n}\n\n.monomer-manager-sketcher .ketcher-host {\n height: 100% !important;\n width: unset !important;\n} \n\n.monomer-manager-root > div:first-child {\n flex-basis: 40% !important;\n}\n.monomer-manager-root > div:nth-child(2) {\n flex-basis: 60% !important;\n}\n\n.monomer-manager-root > div:first-child > .ui-form {\n max-width: unset !important;\n}\n\n.monomer-card-info-row {\n width: 100%;\n overflow: hidden;\n text-overflow: ellipsis;\n margin-bottom: 10px;\n}\n\n.monomer-card-info-row > div:nth-child(2) {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.monomer-card-info-row > div:nth-child(1) {\n font-weight: bold;\n margin-right: 5px;\n text-wrap: nowrap;\n}\n\n.duplicate-monomer-symbol-row {\n visibility: visible !important;\n}\n\n.monomer-card-root {\n border: 2px solid var(--grey-2);\n border-radius: 5px;\n padding: 5px;\n margin: 5px;\n overflow: hidden;\n align-items: center;\n cursor: pointer;\n width: 200px;\n height: 300px;\n min-width: 200px;\n min-height: 300px;\n}\n\n.duplicate-monomers-virtual-view {\n width: 100% !important;\n overflow-x: clip;\n overflow-y: auto;\n}\n\n.monomer-manager-form-tab-control input.d4-invalid {\n background: #ff000030;\n}\n\n.monomer-lib-controls-form .ui-input-root {\n flex-wrap: nowrap !important;\n}"],sourceRoot:""}]);const a=i},6369:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var r=n(1354),o=n.n(r),s=n(6314),i=n.n(s)()(o());i.push([e.id,".kalign-version {\n margin-bottom: 0;\n text-align: end;\n font-size: 12px;\n opacity: 0.8;\n}\nbutton.msa-params-button.ui-btn {\n justify-content: end;\n}","",{version:3,sources:["webpack://./css/msa.css"],names:[],mappings:"AAAA;IACI,gBAAgB;IAChB,eAAe;IACf,eAAe;IACf,YAAY;AAChB;AACA;IACI,oBAAoB;AACxB",sourcesContent:[".kalign-version {\n margin-bottom: 0;\n text-align: end;\n font-size: 12px;\n opacity: 0.8;\n}\nbutton.msa-params-button.ui-btn {\n justify-content: end;\n}"],sourceRoot:""}]);const a=i},7939:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var r=n(1354),o=n.n(r),s=n(6314),i=n.n(s)()(o());i.push([e.id,".scatter_plot_link {\n right: 10px;\n}\n\n.cliffs_div {\n flex-grow: initial!important;\n justify-content: flex-end;\n flex-wrap: wrap;\n}\n\n.cliffs_grid {\n margin: 0!important;\n}\n\n.ml-dim-reduction-settings-input i.grok-icon.grok-font-icon-settings {\n font-size: 18px;\n position: absolute;\n height: 28px;\n}\n\n.ml-dim-reduction-settings-input i.grok-icon.grok-font-icon-settings:not(.ml-dim-reduction-column-editor-input-root i) {\n left: -20px;\n}\n.dlg-dimensionality-reduction.ui-form, .dlg-markov-clustering.ui-form, .dlg-markov-clustering.ui-form .ui-form, .dlg-dimensionality-reduction.ui-form .ui-form {\n max-width: unset;\n}\n\n.ml-dim-reduction-column-editor-input-root label {\n display: none !important;\n}\n\n.dim-reduction-dialog-form > .ui-input-root, .dim-reduction-dialog-form > div > .ui-input-root {\n margin-left: 10px;\n}\n\n.ml-dim-reduction-column-editor-input-root input, .ml-dim-reduction-column-editor-input-root select {\n margin-left: 20px !important;\n}\n\nh3.ml-dim-reduction-column-editor-input-root {\n margin: 0 !important;\n}\n\n.ml-dim-reduction-column-editor-root, .ml-dim-reduction-column-editor-header-root {\n display: flex;\n flex-direction: row;\n align-items: center;\n margin-bottom: 10px !important;\n width: 700px !important;\n}\n\n.ml-dim-reduction-column-editor-column-title {\n text-overflow: ellipsis;\n overflow: hidden;\n}\n\n.ml-dim-reduction-column-editor-header-root > h1:not(:first-child) {\n margin-left: 20px !important;\n}\n\n.ml-dim-reduction-column-editor-table-root .header > td:not(:first-child) {\n padding-left: 32px;\n}","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/ml/css/styles.css"],names:[],mappings:"AAAA;IACI,WAAW;AACf;;AAEA;IACI,4BAA4B;IAC5B,yBAAyB;IACzB,eAAe;AACnB;;AAEA;GACG,mBAAmB;AACtB;;AAEA;IACI,eAAe;IACf,kBAAkB;IAClB,YAAY;AAChB;;AAEA;IACI,WAAW;AACf;AACA;IACI,gBAAgB;AACpB;;AAEA;IACI,wBAAwB;AAC5B;;AAEA;IACI,iBAAiB;AACrB;;AAEA;IACI,4BAA4B;AAChC;;AAEA;IACI,oBAAoB;AACxB;;AAEA;IACI,aAAa;IACb,mBAAmB;IACnB,mBAAmB;IACnB,8BAA8B;IAC9B,uBAAuB;AAC3B;;AAEA;IACI,uBAAuB;IACvB,gBAAgB;AACpB;;AAEA;IACI,4BAA4B;AAChC;;AAEA;IACI,kBAAkB;AACtB",sourcesContent:[".scatter_plot_link {\n right: 10px;\n}\n\n.cliffs_div {\n flex-grow: initial!important;\n justify-content: flex-end;\n flex-wrap: wrap;\n}\n\n.cliffs_grid {\n margin: 0!important;\n}\n\n.ml-dim-reduction-settings-input i.grok-icon.grok-font-icon-settings {\n font-size: 18px;\n position: absolute;\n height: 28px;\n}\n\n.ml-dim-reduction-settings-input i.grok-icon.grok-font-icon-settings:not(.ml-dim-reduction-column-editor-input-root i) {\n left: -20px;\n}\n.dlg-dimensionality-reduction.ui-form, .dlg-markov-clustering.ui-form, .dlg-markov-clustering.ui-form .ui-form, .dlg-dimensionality-reduction.ui-form .ui-form {\n max-width: unset;\n}\n\n.ml-dim-reduction-column-editor-input-root label {\n display: none !important;\n}\n\n.dim-reduction-dialog-form > .ui-input-root, .dim-reduction-dialog-form > div > .ui-input-root {\n margin-left: 10px;\n}\n\n.ml-dim-reduction-column-editor-input-root input, .ml-dim-reduction-column-editor-input-root select {\n margin-left: 20px !important;\n}\n\nh3.ml-dim-reduction-column-editor-input-root {\n margin: 0 !important;\n}\n\n.ml-dim-reduction-column-editor-root, .ml-dim-reduction-column-editor-header-root {\n display: flex;\n flex-direction: row;\n align-items: center;\n margin-bottom: 10px !important;\n width: 700px !important;\n}\n\n.ml-dim-reduction-column-editor-column-title {\n text-overflow: ellipsis;\n overflow: hidden;\n}\n\n.ml-dim-reduction-column-editor-header-root > h1:not(:first-child) {\n margin-left: 20px !important;\n}\n\n.ml-dim-reduction-column-editor-table-root .header > td:not(:first-child) {\n padding-left: 32px;\n}"],sourceRoot:""}]);const a=i},3017:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var r=n(1354),o=n.n(r),s=n(6314),i=n.n(s)()(o());i.push([e.id,".monomer-lib-controls-form {\n margin-left: auto;\n margin-right: auto;\n display: flex;\n flex-direction: column;\n align-items: center;\n min-width: 220px;\n width: 100%;\n\n}\n","",{version:3,sources:["webpack://./src/utils/monomer-lib/library-file-manager/style.css"],names:[],mappings:"AAAA;EACE,iBAAiB;EACjB,kBAAkB;EAClB,aAAa;EACb,sBAAsB;EACtB,mBAAmB;EACnB,gBAAgB;EAChB,WAAW;;AAEb",sourcesContent:[".monomer-lib-controls-form {\n margin-left: auto;\n margin-right: auto;\n display: flex;\n flex-direction: column;\n align-items: center;\n min-width: 220px;\n width: 100%;\n\n}\n"],sourceRoot:""}]);const a=i},6314:e=>{"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var n="",r=void 0!==t[5];return t[4]&&(n+="@supports (".concat(t[4],") {")),t[2]&&(n+="@media ".concat(t[2]," {")),r&&(n+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),n+=e(t),r&&(n+="}"),t[2]&&(n+="}"),t[4]&&(n+="}"),n})).join("")},t.i=function(e,n,r,o,s){"string"==typeof e&&(e=[[null,e,void 0]]);var i={};if(r)for(var a=0;a<this.length;a++){var c=this[a][0];null!=c&&(i[c]=!0)}for(var l=0;l<e.length;l++){var u=[].concat(e[l]);r&&i[u[0]]||(void 0!==s&&(void 0===u[5]||(u[1]="@layer".concat(u[5].length>0?" ".concat(u[5]):""," {").concat(u[1],"}")),u[5]=s),n&&(u[2]?(u[1]="@media ".concat(u[2]," {").concat(u[1],"}"),u[2]=n):u[2]=n),o&&(u[4]?(u[1]="@supports (".concat(u[4],") {").concat(u[1],"}"),u[4]=o):u[4]="".concat(o)),t.push(u))}},t}},1354:e=>{"use strict";e.exports=function(e){var t=e[1],n=e[3];if(!n)return t;if("function"==typeof btoa){var r=btoa(unescape(encodeURIComponent(JSON.stringify(n)))),o="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(r),s="/*# ".concat(o," */");return[t].concat([s]).join("\n")}return[t].join("\n")}},2017:e=>{"use strict";e.exports=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){if(t.constructor!==n.constructor)return!1;var r,o,s;if(Array.isArray(t)){if((r=t.length)!=n.length)return!1;for(o=r;0!=o--;)if(!e(t[o],n[o]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if((r=(s=Object.keys(t)).length)!==Object.keys(n).length)return!1;for(o=r;0!=o--;)if(!Object.prototype.hasOwnProperty.call(n,s[o]))return!1;for(o=r;0!=o--;){var i=s[o];if(!e(t[i],n[i]))return!1}return!0}return t!=t&&n!=n}},9982:function(e,t,n){var r;!function(){var t={};!function(e){"use strict";e.__esModule=!0,e.digestLength=32,e.blockSize=64;var t=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function n(e,n,r,o,s){for(var i,a,c,l,u,d,h,p,m,f,g,y,b;s>=64;){for(i=n[0],a=n[1],c=n[2],l=n[3],u=n[4],d=n[5],h=n[6],p=n[7],f=0;f<16;f++)g=o+4*f,e[f]=(255&r[g])<<24|(255&r[g+1])<<16|(255&r[g+2])<<8|255&r[g+3];for(f=16;f<64;f++)y=((m=e[f-2])>>>17|m<<15)^(m>>>19|m<<13)^m>>>10,b=((m=e[f-15])>>>7|m<<25)^(m>>>18|m<<14)^m>>>3,e[f]=(y+e[f-7]|0)+(b+e[f-16]|0);for(f=0;f<64;f++)y=(((u>>>6|u<<26)^(u>>>11|u<<21)^(u>>>25|u<<7))+(u&d^~u&h)|0)+(p+(t[f]+e[f]|0)|0)|0,b=((i>>>2|i<<30)^(i>>>13|i<<19)^(i>>>22|i<<10))+(i&a^i&c^a&c)|0,p=h,h=d,d=u,u=l+y|0,l=c,c=a,a=i,i=y+b|0;n[0]+=i,n[1]+=a,n[2]+=c,n[3]+=l,n[4]+=u,n[5]+=d,n[6]+=h,n[7]+=p,o+=64,s-=64}return o}var r=function(){function t(){this.digestLength=e.digestLength,this.blockSize=e.blockSize,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this.reset()}return t.prototype.reset=function(){return this.state[0]=1779033703,this.state[1]=3144134277,this.state[2]=1013904242,this.state[3]=2773480762,this.state[4]=1359893119,this.state[5]=2600822924,this.state[6]=528734635,this.state[7]=1541459225,this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this},t.prototype.clean=function(){for(var e=0;e<this.buffer.length;e++)this.buffer[e]=0;for(e=0;e<this.temp.length;e++)this.temp[e]=0;this.reset()},t.prototype.update=function(e,t){if(void 0===t&&(t=e.length),this.finished)throw new Error("SHA256: can't update because hash was finished.");var r=0;if(this.bytesHashed+=t,this.bufferLength>0){for(;this.bufferLength<64&&t>0;)this.buffer[this.bufferLength++]=e[r++],t--;64===this.bufferLength&&(n(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(t>=64&&(r=n(this.temp,this.state,e,r,t),t%=64);t>0;)this.buffer[this.bufferLength++]=e[r++],t--;return this},t.prototype.finish=function(e){if(!this.finished){var t=this.bytesHashed,r=this.bufferLength,o=t/536870912|0,s=t<<3,i=t%64<56?64:128;this.buffer[r]=128;for(var a=r+1;a<i-8;a++)this.buffer[a]=0;this.buffer[i-8]=o>>>24&255,this.buffer[i-7]=o>>>16&255,this.buffer[i-6]=o>>>8&255,this.buffer[i-5]=o>>>0&255,this.buffer[i-4]=s>>>24&255,this.buffer[i-3]=s>>>16&255,this.buffer[i-2]=s>>>8&255,this.buffer[i-1]=s>>>0&255,n(this.temp,this.state,this.buffer,0,i),this.finished=!0}for(a=0;a<8;a++)e[4*a+0]=this.state[a]>>>24&255,e[4*a+1]=this.state[a]>>>16&255,e[4*a+2]=this.state[a]>>>8&255,e[4*a+3]=this.state[a]>>>0&255;return this},t.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},t.prototype._saveState=function(e){for(var t=0;t<this.state.length;t++)e[t]=this.state[t]},t.prototype._restoreState=function(e,t){for(var n=0;n<this.state.length;n++)this.state[n]=e[n];this.bytesHashed=t,this.finished=!1,this.bufferLength=0},t}();e.Hash=r;var o=function(){function e(e){this.inner=new r,this.outer=new r,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var t=new Uint8Array(this.blockSize);if(e.length>this.blockSize)(new r).update(e).finish(t).clean();else for(var n=0;n<e.length;n++)t[n]=e[n];for(n=0;n<t.length;n++)t[n]^=54;for(this.inner.update(t),n=0;n<t.length;n++)t[n]^=106;for(this.outer.update(t),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate),n=0;n<t.length;n++)t[n]=0}return e.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},e.prototype.clean=function(){for(var e=0;e<this.istate.length;e++)this.ostate[e]=this.istate[e]=0;this.inner.clean(),this.outer.clean()},e.prototype.update=function(e){return this.inner.update(e),this},e.prototype.finish=function(e){return this.outer.finished?this.outer.finish(e):(this.inner.finish(e),this.outer.update(e,this.digestLength).finish(e)),this},e.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},e}();function s(e){var t=(new r).update(e),n=t.digest();return t.clean(),n}function i(e,t){var n=new o(e).update(t),r=n.digest();return n.clean(),r}function a(e,t,n,r){var o=r[0];if(0===o)throw new Error("hkdf: cannot expand more");t.reset(),o>1&&t.update(e),n&&t.update(n),t.update(r),t.finish(e),r[0]++}e.HMAC=o,e.hash=s,e.default=s,e.hmac=i;var c=new Uint8Array(e.digestLength);e.hkdf=function(e,t,n,r){void 0===t&&(t=c),void 0===r&&(r=32);for(var s=new Uint8Array([1]),l=i(t,e),u=new o(l),d=new Uint8Array(u.digestLength),h=d.length,p=new Uint8Array(r),m=0;m<r;m++)h===d.length&&(a(d,u,n,s),h=0),p[m]=d[h++];return u.clean(),d.fill(0),s.fill(0),p},e.pbkdf2=function(e,t,n,r){for(var s=new o(e),i=s.digestLength,a=new Uint8Array(4),c=new Uint8Array(i),l=new Uint8Array(i),u=new Uint8Array(r),d=0;d*i<r;d++){var h=d+1;a[0]=h>>>24&255,a[1]=h>>>16&255,a[2]=h>>>8&255,a[3]=h>>>0&255,s.reset(),s.update(t),s.update(a),s.finish(l);for(var p=0;p<i;p++)c[p]=l[p];for(p=2;p<=n;p++){s.reset(),s.update(l).finish(l);for(var m=0;m<i;m++)c[m]^=l[m]}for(p=0;p<i&&d*i+p<r;p++)u[d*i+p]=c[p]}for(d=0;d<i;d++)c[d]=l[d]=0;for(d=0;d<4;d++)a[d]=0;return s.clean(),u}}(t);var o=t.default;for(var s in t)o[s]=t[s];"object"==typeof e.exports?e.exports=o:void 0===(r=function(){return o}.call(t,n,t,e))||(e.exports=r)}()},2787:(e,t,n)=>{"use strict";n.d(t,{I:()=>o});const r=new Uint32Array(65536),o=(e,t)=>{if(e.length<t.length){const n=t;t=e,e=n}return 0===t.length?e.length:e.length<=32?((e,t)=>{const n=e.length,o=t.length,s=1<<n-1;let i=-1,a=0,c=n,l=n;for(;l--;)r[e.charCodeAt(l)]|=1<<l;for(l=0;l<o;l++){let e=r[t.charCodeAt(l)];const n=e|a;e|=(e&i)+i^i,a|=~(e|i),i&=e,a&s&&c++,i&s&&c--,a=a<<1|1,i=i<<1|~(n|a),a&=n}for(l=n;l--;)r[e.charCodeAt(l)]=0;return c})(e,t):((e,t)=>{const n=t.length,o=e.length,s=[],i=[],a=Math.ceil(n/32),c=Math.ceil(o/32);for(let e=0;e<a;e++)i[e]=-1,s[e]=0;let l=0;for(;l<c-1;l++){let a=0,c=-1;const u=32*l,d=Math.min(32,o)+u;for(let t=u;t<d;t++)r[e.charCodeAt(t)]|=1<<t;for(let e=0;e<n;e++){const n=r[t.charCodeAt(e)],o=i[e/32|0]>>>e&1,l=s[e/32|0]>>>e&1,u=n|a,d=((n|l)&c)+c^c|n|l;let h=a|~(d|c),p=c&d;h>>>31^o&&(i[e/32|0]^=1<<e),p>>>31^l&&(s[e/32|0]^=1<<e),h=h<<1|o,p=p<<1|l,c=p|~(u|h),a=h&u}for(let t=u;t<d;t++)r[e.charCodeAt(t)]=0}let u=0,d=-1;const h=32*l,p=Math.min(32,o-h)+h;for(let t=h;t<p;t++)r[e.charCodeAt(t)]|=1<<t;let m=o;for(let e=0;e<n;e++){const n=r[t.charCodeAt(e)],a=i[e/32|0]>>>e&1,c=s[e/32|0]>>>e&1,l=n|u,h=((n|c)&d)+d^d|n|c;let p=u|~(h|d),f=d&h;m+=p>>>o-1&1,m-=f>>>o-1&1,p>>>31^a&&(i[e/32|0]^=1<<e),f>>>31^c&&(s[e/32|0]^=1<<e),p=p<<1|a,f=f<<1|c,d=f|~(l|p),u=p&l}for(let t=h;t<p;t++)r[e.charCodeAt(t)]=0;return m})(e,t)}},9937:e=>{e.exports={linLogMode:!1,outboundAttractionDistribution:!1,adjustSizes:!1,edgeWeightInfluence:1,scalingRatio:1,strongGravityMode:!1,gravity:1,slowDown:1,barnesHutOptimize:!1,barnesHutTheta:.5}},1782:(e,t)=>{t.assign=function(e){e=e||{};var t,n,r,o=Array.prototype.slice.call(arguments).slice(1);for(t=0,r=o.length;t<r;t++)if(o[t])for(n in o[t])e[n]=o[t][n];return e},t.validateSettings=function(e){return"linLogMode"in e&&"boolean"!=typeof e.linLogMode?{message:"the `linLogMode` setting should be a boolean."}:"outboundAttractionDistribution"in e&&"boolean"!=typeof e.outboundAttractionDistribution?{message:"the `outboundAttractionDistribution` setting should be a boolean."}:"adjustSizes"in e&&"boolean"!=typeof e.adjustSizes?{message:"the `adjustSizes` setting should be a boolean."}:"edgeWeightInfluence"in e&&"number"!=typeof e.edgeWeightInfluence?{message:"the `edgeWeightInfluence` setting should be a number."}:!("scalingRatio"in e)||"number"==typeof e.scalingRatio&&e.scalingRatio>=0?"strongGravityMode"in e&&"boolean"!=typeof e.strongGravityMode?{message:"the `strongGravityMode` setting should be a boolean."}:!("gravity"in e)||"number"==typeof e.gravity&&e.gravity>=0?"slowDown"in e&&!("number"==typeof e.slowDown||e.slowDown>=0)?{message:"the `slowDown` setting should be a number >= 0."}:"barnesHutOptimize"in e&&"boolean"!=typeof e.barnesHutOptimize?{message:"the `barnesHutOptimize` setting should be a boolean."}:!("barnesHutTheta"in e)||"number"==typeof e.barnesHutTheta&&e.barnesHutTheta>=0?null:{message:"the `barnesHutTheta` setting should be a number >= 0."}:{message:"the `gravity` setting should be a number >= 0."}:{message:"the `scalingRatio` setting should be a number >= 0."}},t.graphToByteArrays=function(e,t){var n,r=e.order,o=e.size,s={},i=new Float32Array(10*r),a=new Float32Array(3*o);return n=0,e.forEachNode((function(e,t){s[e]=n,i[n]=t.x,i[n+1]=t.y,i[n+2]=0,i[n+3]=0,i[n+4]=0,i[n+5]=0,i[n+6]=1,i[n+7]=1,i[n+8]=t.size||1,i[n+9]=t.fixed?1:0,n+=10})),n=0,e.forEachEdge((function(e,r,o,c,l,u,d){var h=s[o],p=s[c],m=t(e,r,o,c,l,u,d);i[h+6]+=m,i[p+6]+=m,a[n]=h,a[n+1]=p,a[n+2]=m,n+=3})),{nodes:i,edges:a}},t.assignLayoutChanges=function(e,t,n){var r=0;e.updateEachNodeAttributes((function(e,o){return o.x=t[r],o.y=t[r+1],r+=10,n?n(e,o):o}))},t.readGraphPositions=function(e,t){var n=0;e.forEachNode((function(e,r){t[n]=r.x,t[n+1]=r.y,n+=10}))},t.collectLayoutChanges=function(e,t,n){for(var r=e.nodes(),o={},s=0,i=0,a=t.length;s<a;s+=10){if(n){var c=Object.assign({},e.getNodeAttributes(r[i]));c.x=t[s],c.y=t[s+1],c=n(r[i],c),o[r[i]]={x:c.x,y:c.y}}else o[r[i]]={x:t[s],y:t[s+1]};i++}return o},t.createWorker=function(e){var t=window.URL||window.webkitURL,n=e.toString(),r=t.createObjectURL(new Blob(["("+n+").call(this);"],{type:"text/javascript"})),o=new Worker(r);return t.revokeObjectURL(r),o}},8903:(e,t,n)=>{var r=n(1736),o=n(8153).Fd,s=n(2561),i=n(1782),a=n(9937);function c(e,t,n){if(!r(t))throw new Error("graphology-layout-forceatlas2: the given graph is not a valid graphology instance.");"number"==typeof n&&(n={iterations:n});var c=n.iterations;if("number"!=typeof c)throw new Error("graphology-layout-forceatlas2: invalid number of iterations.");if(c<=0)throw new Error("graphology-layout-forceatlas2: you should provide a positive number of iterations.");var l=o("getEdgeWeight"in n?n.getEdgeWeight:"weight").fromEntry,u="function"==typeof n.outputReducer?n.outputReducer:null,d=i.assign({},a,n.settings),h=i.validateSettings(d);if(h)throw new Error("graphology-layout-forceatlas2: "+h.message);var p,m=i.graphToByteArrays(t,l);for(p=0;p<c;p++)s(d,m.nodes,m.edges);if(!e)return i.collectLayoutChanges(t,m.nodes);i.assignLayoutChanges(t,m.nodes,u)}var l=c.bind(null,!1);l.assign=c.bind(null,!0),l.inferSettings=function(e){var t="number"==typeof e?e:e.order;return{barnesHutOptimize:t>2e3,strongGravityMode:!0,gravity:.05,scalingRatio:10,slowDown:1+Math.log(t)}},e.exports=l},2561:e=>{var t=10;e.exports=function(e,n,r){var o,s,i,a,c,l,u,d,h,p,m,f,g,y,b,w,v,A,E,C,T,S,_,P=n.length,M=r.length,x=e.adjustSizes,N=e.barnesHutTheta*e.barnesHutTheta,$=[];for(i=0;i<P;i+=t)n[i+4]=n[i+2],n[i+5]=n[i+3],n[i+2]=0,n[i+3]=0;if(e.outboundAttractionDistribution){for(m=0,i=0;i<P;i+=t)m+=n[i+6];m/=P/t}if(e.barnesHutOptimize){var L,I,R,O=1/0,k=-1/0,G=1/0,D=-1/0;for(i=0;i<P;i+=t)O=Math.min(O,n[i+0]),k=Math.max(k,n[i+0]),G=Math.min(G,n[i+1]),D=Math.max(D,n[i+1]);var H=k-O,F=D-G;for(H>F?D=(G-=(H-F)/2)+H:k=(O-=(F-H)/2)+F,$[0]=-1,$[1]=(O+k)/2,$[2]=(G+D)/2,$[3]=Math.max(k-O,D-G),$[4]=-1,$[5]=-1,$[6]=0,$[7]=0,$[8]=0,o=1,i=0;i<P;i+=t)for(s=0,R=3;;){if(!($[s+5]>=0)){if($[s+0]<0){$[s+0]=i;break}if($[s+5]=9*o,d=$[s+3]/2,$[(h=$[s+5])+0]=-1,$[h+1]=$[s+1]-d,$[h+2]=$[s+2]-d,$[h+3]=d,$[h+4]=h+9,$[h+5]=-1,$[h+6]=0,$[h+7]=0,$[h+8]=0,$[(h+=9)+0]=-1,$[h+1]=$[s+1]-d,$[h+2]=$[s+2]+d,$[h+3]=d,$[h+4]=h+9,$[h+5]=-1,$[h+6]=0,$[h+7]=0,$[h+8]=0,$[(h+=9)+0]=-1,$[h+1]=$[s+1]+d,$[h+2]=$[s+2]-d,$[h+3]=d,$[h+4]=h+9,$[h+5]=-1,$[h+6]=0,$[h+7]=0,$[h+8]=0,$[(h+=9)+0]=-1,$[h+1]=$[s+1]+d,$[h+2]=$[s+2]+d,$[h+3]=d,$[h+4]=$[s+4],$[h+5]=-1,$[h+6]=0,$[h+7]=0,$[h+8]=0,o+=4,L=n[$[s+0]+0]<$[s+1]?n[$[s+0]+1]<$[s+2]?$[s+5]:$[s+5]+9:n[$[s+0]+1]<$[s+2]?$[s+5]+18:$[s+5]+27,$[s+6]=n[$[s+0]+6],$[s+7]=n[$[s+0]+0],$[s+8]=n[$[s+0]+1],$[L+0]=$[s+0],$[s+0]=-1,L===(I=n[i+0]<$[s+1]?n[i+1]<$[s+2]?$[s+5]:$[s+5]+9:n[i+1]<$[s+2]?$[s+5]+18:$[s+5]+27)){if(R--){s=L;continue}R=3;break}$[I+0]=i;break}L=n[i+0]<$[s+1]?n[i+1]<$[s+2]?$[s+5]:$[s+5]+9:n[i+1]<$[s+2]?$[s+5]+18:$[s+5]+27,$[s+7]=($[s+7]*$[s+6]+n[i+0]*n[i+6])/($[s+6]+n[i+6]),$[s+8]=($[s+8]*$[s+6]+n[i+1]*n[i+6])/($[s+6]+n[i+6]),$[s+6]+=n[i+6],s=L}}if(e.barnesHutOptimize){for(f=e.scalingRatio,i=0;i<P;i+=t)for(s=0;;)if($[s+5]>=0){if(w=Math.pow(n[i+0]-$[s+7],2)+Math.pow(n[i+1]-$[s+8],2),4*(p=$[s+3])*p/w<N){if(g=n[i+0]-$[s+7],y=n[i+1]-$[s+8],!0===x?w>0?(v=f*n[i+6]*$[s+6]/w,n[i+2]+=g*v,n[i+3]+=y*v):w<0&&(v=-f*n[i+6]*$[s+6]/Math.sqrt(w),n[i+2]+=g*v,n[i+3]+=y*v):w>0&&(v=f*n[i+6]*$[s+6]/w,n[i+2]+=g*v,n[i+3]+=y*v),(s=$[s+4])<0)break;continue}s=$[s+5]}else if((l=$[s+0])>=0&&l!==i&&(w=(g=n[i+0]-n[l+0])*g+(y=n[i+1]-n[l+1])*y,!0===x?w>0?(v=f*n[i+6]*n[l+6]/w,n[i+2]+=g*v,n[i+3]+=y*v):w<0&&(v=-f*n[i+6]*n[l+6]/Math.sqrt(w),n[i+2]+=g*v,n[i+3]+=y*v):w>0&&(v=f*n[i+6]*n[l+6]/w,n[i+2]+=g*v,n[i+3]+=y*v)),(s=$[s+4])<0)break}else for(f=e.scalingRatio,a=0;a<P;a+=t)for(c=0;c<a;c+=t)g=n[a+0]-n[c+0],y=n[a+1]-n[c+1],!0===x?(w=Math.sqrt(g*g+y*y)-n[a+8]-n[c+8])>0?(v=f*n[a+6]*n[c+6]/w/w,n[a+2]+=g*v,n[a+3]+=y*v,n[c+2]-=g*v,n[c+3]-=y*v):w<0&&(v=100*f*n[a+6]*n[c+6],n[a+2]+=g*v,n[a+3]+=y*v,n[c+2]-=g*v,n[c+3]-=y*v):(w=Math.sqrt(g*g+y*y))>0&&(v=f*n[a+6]*n[c+6]/w/w,n[a+2]+=g*v,n[a+3]+=y*v,n[c+2]-=g*v,n[c+3]-=y*v);for(h=e.gravity/e.scalingRatio,f=e.scalingRatio,i=0;i<P;i+=t)v=0,g=n[i+0],y=n[i+1],w=Math.sqrt(Math.pow(g,2)+Math.pow(y,2)),e.strongGravityMode?w>0&&(v=f*n[i+6]*h):w>0&&(v=f*n[i+6]*h/w),n[i+2]-=g*v,n[i+3]-=y*v;for(f=1*(e.outboundAttractionDistribution?m:1),u=0;u<M;u+=3)a=r[u+0],c=r[u+1],d=r[u+2],b=Math.pow(d,e.edgeWeightInfluence),g=n[a+0]-n[c+0],y=n[a+1]-n[c+1],!0===x?(w=Math.sqrt(g*g+y*y)-n[a+8]-n[c+8],e.linLogMode?e.outboundAttractionDistribution?w>0&&(v=-f*b*Math.log(1+w)/w/n[a+6]):w>0&&(v=-f*b*Math.log(1+w)/w):e.outboundAttractionDistribution?w>0&&(v=-f*b/n[a+6]):w>0&&(v=-f*b)):(w=Math.sqrt(Math.pow(g,2)+Math.pow(y,2)),e.linLogMode?e.outboundAttractionDistribution?w>0&&(v=-f*b*Math.log(1+w)/w/n[a+6]):w>0&&(v=-f*b*Math.log(1+w)/w):e.outboundAttractionDistribution?(w=1,v=-f*b/n[a+6]):(w=1,v=-f*b)),w>0&&(n[a+2]+=g*v,n[a+3]+=y*v,n[c+2]-=g*v,n[c+3]-=y*v);if(!0===x)for(i=0;i<P;i+=t)1!==n[i+9]&&((A=Math.sqrt(Math.pow(n[i+2],2)+Math.pow(n[i+3],2)))>10&&(n[i+2]=10*n[i+2]/A,n[i+3]=10*n[i+3]/A),E=n[i+6]*Math.sqrt((n[i+4]-n[i+2])*(n[i+4]-n[i+2])+(n[i+5]-n[i+3])*(n[i+5]-n[i+3])),C=Math.sqrt((n[i+4]+n[i+2])*(n[i+4]+n[i+2])+(n[i+5]+n[i+3])*(n[i+5]+n[i+3]))/2,T=.1*Math.log(1+C)/(1+Math.sqrt(E)),S=n[i+0]+n[i+2]*(T/e.slowDown),n[i+0]=S,_=n[i+1]+n[i+3]*(T/e.slowDown),n[i+1]=_);else for(i=0;i<P;i+=t)1!==n[i+9]&&(E=n[i+6]*Math.sqrt((n[i+4]-n[i+2])*(n[i+4]-n[i+2])+(n[i+5]-n[i+3])*(n[i+5]-n[i+3])),C=Math.sqrt((n[i+4]+n[i+2])*(n[i+4]+n[i+2])+(n[i+5]+n[i+3])*(n[i+5]+n[i+3]))/2,T=n[i+7]*Math.log(1+C)/(1+Math.sqrt(E)),n[i+7]=Math.min(1,Math.sqrt(T*(Math.pow(n[i+2],2)+Math.pow(n[i+3],2))/(1+Math.sqrt(E)))),S=n[i+0]+n[i+2]*(T/e.slowDown),n[i+0]=S,_=n[i+1]+n[i+3]*(T/e.slowDown),n[i+1]=_);return{}}},8153:(e,t)=>{function n(e){return"number"!=typeof e||isNaN(e)?1:e}t.Fd=function(e){return function(e,t){var n={},r=function(e){return void 0===e?t:e};"function"==typeof t&&(r=t);var o=function(t){return r(t[e])},s=function(){return r(void 0)};return"string"==typeof e?(n.fromAttributes=o,n.fromGraph=function(e,t){return o(e.getEdgeAttributes(t))},n.fromEntry=function(e,t){return o(t)},n.fromPartialEntry=n.fromEntry,n.fromMinimalEntry=n.fromEntry):"function"==typeof e?(n.fromAttributes=function(){throw new Error("graphology-utils/getters/createEdgeValueGetter: irrelevant usage.")},n.fromGraph=function(t,n){var o=t.extremities(n);return r(e(n,t.getEdgeAttributes(n),o[0],o[1],t.getNodeAttributes(o[0]),t.getNodeAttributes(o[1]),t.isUndirected(n)))},n.fromEntry=function(t,n,o,s,i,a,c){return r(e(t,n,o,s,i,a,c))},n.fromPartialEntry=function(t,n,o,s){return r(e(t,n,o,s))},n.fromMinimalEntry=function(t,n){return r(e(t,n))}):(n.fromAttributes=s,n.fromGraph=s,n.fromEntry=s,n.fromMinimalEntry=s),n}(e,n)}},1736:e=>{e.exports=function(e){return null!==e&&"object"==typeof e&&"function"==typeof e.addUndirectedEdgeWithKey&&"function"==typeof e.dropNode&&"boolean"==typeof e.multi}},934:function(e){e.exports=function(){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,r(e,t)}function n(e){return n=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},n(e)}function r(e,t){return r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},r(e,t)}function o(e,t,n){return o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}()?Reflect.construct.bind():function(e,t,n){var o=[null];o.push.apply(o,t);var s=new(Function.bind.apply(e,o));return n&&r(s,n.prototype),s},o.apply(null,arguments)}function s(e){var t="function"==typeof Map?new Map:void 0;return s=function(e){if(null===e||(s=e,-1===Function.toString.call(s).indexOf("[native code]")))return e;var s;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,i)}function i(){return o(e,arguments,n(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),r(i,e)},s(e)}function i(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var a=function(){for(var e=arguments[0],t=1,n=arguments.length;t<n;t++)if(arguments[t])for(var r in arguments[t])e[r]=arguments[t][r];return e};function c(e,t,n,r){var o=e._nodes.get(t),s=null;return o?s="mixed"===r?o.out&&o.out[n]||o.undirected&&o.undirected[n]:"directed"===r?o.out&&o.out[n]:o.undirected&&o.undirected[n]:s}function l(t){return"object"===e(t)&&null!==t}function u(e){var t;for(t in e)return!1;return!0}function d(e,t,n){Object.defineProperty(e,t,{enumerable:!1,configurable:!1,writable:!0,value:n})}function h(e,t,n){var r={enumerable:!0,configurable:!0};"function"==typeof n?r.get=n:(r.value=n,r.writable=!1),Object.defineProperty(e,t,r)}function p(e){return!(!l(e)||e.attributes&&!Array.isArray(e.attributes))}"function"==typeof Object.assign&&(a=Object.assign);var m,f={exports:{}},g="object"==typeof Reflect?Reflect:null,y=g&&"function"==typeof g.apply?g.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};m=g&&"function"==typeof g.ownKeys?g.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var b=Number.isNaN||function(e){return e!=e};function w(){w.init.call(this)}f.exports=w,f.exports.once=function(e,t){return new Promise((function(n,r){function o(n){e.removeListener(t,s),r(n)}function s(){"function"==typeof e.removeListener&&e.removeListener("error",o),n([].slice.call(arguments))}x(e,t,s,{once:!0}),"error"!==t&&function(e,t){"function"==typeof e.on&&x(e,"error",t,{once:!0})}(e,o)}))},w.EventEmitter=w,w.prototype._events=void 0,w.prototype._eventsCount=0,w.prototype._maxListeners=void 0;var v=10;function A(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function E(e){return void 0===e._maxListeners?w.defaultMaxListeners:e._maxListeners}function C(e,t,n,r){var o,s,i,a;if(A(n),void 0===(s=e._events)?(s=e._events=Object.create(null),e._eventsCount=0):(void 0!==s.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),s=e._events),i=s[t]),void 0===i)i=s[t]=n,++e._eventsCount;else if("function"==typeof i?i=s[t]=r?[n,i]:[i,n]:r?i.unshift(n):i.push(n),(o=E(e))>0&&i.length>o&&!i.warned){i.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+i.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=i.length,a=c,console&&console.warn&&console.warn(a)}return e}function T(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function S(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},o=T.bind(r);return o.listener=n,r.wrapFn=o,o}function _(e,t,n){var r=e._events;if(void 0===r)return[];var o=r[t];return void 0===o?[]:"function"==typeof o?n?[o.listener||o]:[o]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(o):M(o,o.length)}function P(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function M(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}function x(e,t,n,r){if("function"==typeof e.on)r.once?e.once(t,n):e.on(t,n);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function o(s){r.once&&e.removeEventListener(t,o),n(s)}))}}function N(e){if("function"!=typeof e)throw new Error("obliterator/iterator: expecting a function!");this.next=e}Object.defineProperty(w,"defaultMaxListeners",{enumerable:!0,get:function(){return v},set:function(e){if("number"!=typeof e||e<0||b(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");v=e}}),w.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},w.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||b(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},w.prototype.getMaxListeners=function(){return E(this)},w.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var r="error"===e,o=this._events;if(void 0!==o)r=r&&void 0===o.error;else if(!r)return!1;if(r){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var i=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw i.context=s,i}var a=o[e];if(void 0===a)return!1;if("function"==typeof a)y(a,this,t);else{var c=a.length,l=M(a,c);for(n=0;n<c;++n)y(l[n],this,t)}return!0},w.prototype.addListener=function(e,t){return C(this,e,t,!1)},w.prototype.on=w.prototype.addListener,w.prototype.prependListener=function(e,t){return C(this,e,t,!0)},w.prototype.once=function(e,t){return A(t),this.on(e,S(this,e,t)),this},w.prototype.prependOnceListener=function(e,t){return A(t),this.prependListener(e,S(this,e,t)),this},w.prototype.removeListener=function(e,t){var n,r,o,s,i;if(A(t),void 0===(r=this._events))return this;if(void 0===(n=r[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(o=-1,s=n.length-1;s>=0;s--)if(n[s]===t||n[s].listener===t){i=n[s].listener,o=s;break}if(o<0)return this;0===o?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,o),1===n.length&&(r[e]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",e,i||t)}return this},w.prototype.off=w.prototype.removeListener,w.prototype.removeAllListeners=function(e){var t,n,r;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var o,s=Object.keys(n);for(r=0;r<s.length;++r)"removeListener"!==(o=s[r])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this},w.prototype.listeners=function(e){return _(this,e,!0)},w.prototype.rawListeners=function(e){return _(this,e,!1)},w.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):P.call(e,t)},w.prototype.listenerCount=P,w.prototype.eventNames=function(){return this._eventsCount>0?m(this._events):[]},"undefined"!=typeof Symbol&&(N.prototype[Symbol.iterator]=function(){return this}),N.of=function(){var e=arguments,t=e.length,n=0;return new N((function(){return n>=t?{done:!0}:{done:!1,value:e[n++]}}))},N.empty=function(){return new N((function(){return{done:!0}}))},N.fromSequence=function(e){var t=0,n=e.length;return new N((function(){return t>=n?{done:!0}:{done:!1,value:e[t++]}}))},N.is=function(e){return e instanceof N||"object"==typeof e&&null!==e&&"function"==typeof e.next};var $=N,L={};L.ARRAY_BUFFER_SUPPORT="undefined"!=typeof ArrayBuffer,L.SYMBOL_SUPPORT="undefined"!=typeof Symbol;var I=$,R=L,O=R.ARRAY_BUFFER_SUPPORT,k=R.SYMBOL_SUPPORT,G=function(e){var t=function(e){return"string"==typeof e||Array.isArray(e)||O&&ArrayBuffer.isView(e)?I.fromSequence(e):"object"!=typeof e||null===e?null:k&&"function"==typeof e[Symbol.iterator]?e[Symbol.iterator]():"function"==typeof e.next?e:null}(e);if(!t)throw new Error("obliterator: target is not iterable nor a valid iterator.");return t},D=G,H=function(e,t){for(var n,r=arguments.length>1?t:1/0,o=r!==1/0?new Array(r):[],s=0,i=D(e);;){if(s===r)return o;if((n=i.next()).done)return s!==t&&(o.length=s),o;o[s++]=n.value}},F=function(e){function n(t){var n;return(n=e.call(this)||this).name="GraphError",n.message=t,n}return t(n,e),n}(s(Error)),V=function(e){function n(t){var r;return(r=e.call(this,t)||this).name="InvalidArgumentsGraphError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(i(r),n.prototype.constructor),r}return t(n,e),n}(F),U=function(e){function n(t){var r;return(r=e.call(this,t)||this).name="NotFoundGraphError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(i(r),n.prototype.constructor),r}return t(n,e),n}(F),B=function(e){function n(t){var r;return(r=e.call(this,t)||this).name="UsageGraphError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(i(r),n.prototype.constructor),r}return t(n,e),n}(F);function Y(e,t){this.key=e,this.attributes=t,this.clear()}function W(e,t){this.key=e,this.attributes=t,this.clear()}function j(e,t){this.key=e,this.attributes=t,this.clear()}function K(e,t,n,r,o){this.key=t,this.attributes=o,this.undirected=e,this.source=n,this.target=r}function q(e,t,n,r,o,s,i){var a,c,l,u;if(r=""+r,0===n){if(!(a=e._nodes.get(r)))throw new U("Graph.".concat(t,': could not find the "').concat(r,'" node in the graph.'));l=o,u=s}else if(3===n){if(o=""+o,!(c=e._edges.get(o)))throw new U("Graph.".concat(t,': could not find the "').concat(o,'" edge in the graph.'));var d=c.source.key,h=c.target.key;if(r===d)a=c.target;else{if(r!==h)throw new U("Graph.".concat(t,': the "').concat(r,'" node is not attached to the "').concat(o,'" edge (').concat(d,", ").concat(h,")."));a=c.source}l=s,u=i}else{if(!(c=e._edges.get(r)))throw new U("Graph.".concat(t,': could not find the "').concat(r,'" edge in the graph.'));a=1===n?c.source:c.target,l=o,u=s}return[a,l,u]}Y.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}},W.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}},j.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}},K.prototype.attach=function(){var e="out",t="in";this.undirected&&(e=t="undirected");var n=this.source.key,r=this.target.key;this.source[e][r]=this,this.undirected&&n===r||(this.target[t][n]=this)},K.prototype.attachMulti=function(){var e="out",t="in",n=this.source.key,r=this.target.key;this.undirected&&(e=t="undirected");var o=this.source[e],s=o[r];if(void 0===s)return o[r]=this,void(this.undirected&&n===r||(this.target[t][n]=this));s.previous=this,this.next=s,o[r]=this,this.target[t][n]=this},K.prototype.detach=function(){var e=this.source.key,t=this.target.key,n="out",r="in";this.undirected&&(n=r="undirected"),delete this.source[n][t],delete this.target[r][e]},K.prototype.detachMulti=function(){var e=this.source.key,t=this.target.key,n="out",r="in";this.undirected&&(n=r="undirected"),void 0===this.previous?void 0===this.next?(delete this.source[n][t],delete this.target[r][e]):(this.next.previous=void 0,this.source[n][t]=this.next,this.target[r][e]=this.next):(this.previous.next=this.next,void 0!==this.next&&(this.next.previous=this.previous))};var z=[{name:function(e){return"get".concat(e,"Attribute")},attacher:function(e,t,n){e.prototype[t]=function(e,r,o){var s=q(this,t,n,e,r,o),i=s[0],a=s[1];return i.attributes[a]}}},{name:function(e){return"get".concat(e,"Attributes")},attacher:function(e,t,n){e.prototype[t]=function(e,r){return q(this,t,n,e,r)[0].attributes}}},{name:function(e){return"has".concat(e,"Attribute")},attacher:function(e,t,n){e.prototype[t]=function(e,r,o){var s=q(this,t,n,e,r,o),i=s[0],a=s[1];return i.attributes.hasOwnProperty(a)}}},{name:function(e){return"set".concat(e,"Attribute")},attacher:function(e,t,n){e.prototype[t]=function(e,r,o,s){var i=q(this,t,n,e,r,o,s),a=i[0],c=i[1],l=i[2];return a.attributes[c]=l,this.emit("nodeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:c}),this}}},{name:function(e){return"update".concat(e,"Attribute")},attacher:function(e,t,n){e.prototype[t]=function(e,r,o,s){var i=q(this,t,n,e,r,o,s),a=i[0],c=i[1],l=i[2];if("function"!=typeof l)throw new V("Graph.".concat(t,": updater should be a function."));var u=a.attributes,d=l(u[c]);return u[c]=d,this.emit("nodeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:c}),this}}},{name:function(e){return"remove".concat(e,"Attribute")},attacher:function(e,t,n){e.prototype[t]=function(e,r,o){var s=q(this,t,n,e,r,o),i=s[0],a=s[1];return delete i.attributes[a],this.emit("nodeAttributesUpdated",{key:i.key,type:"remove",attributes:i.attributes,name:a}),this}}},{name:function(e){return"replace".concat(e,"Attributes")},attacher:function(e,t,n){e.prototype[t]=function(e,r,o){var s=q(this,t,n,e,r,o),i=s[0],a=s[1];if(!l(a))throw new V("Graph.".concat(t,": provided attributes are not a plain object."));return i.attributes=a,this.emit("nodeAttributesUpdated",{key:i.key,type:"replace",attributes:i.attributes}),this}}},{name:function(e){return"merge".concat(e,"Attributes")},attacher:function(e,t,n){e.prototype[t]=function(e,r,o){var s=q(this,t,n,e,r,o),i=s[0],c=s[1];if(!l(c))throw new V("Graph.".concat(t,": provided attributes are not a plain object."));return a(i.attributes,c),this.emit("nodeAttributesUpdated",{key:i.key,type:"merge",attributes:i.attributes,data:c}),this}}},{name:function(e){return"update".concat(e,"Attributes")},attacher:function(e,t,n){e.prototype[t]=function(e,r,o){var s=q(this,t,n,e,r,o),i=s[0],a=s[1];if("function"!=typeof a)throw new V("Graph.".concat(t,": provided updater is not a function."));return i.attributes=a(i.attributes),this.emit("nodeAttributesUpdated",{key:i.key,type:"update",attributes:i.attributes}),this}}}],Z=[{name:function(e){return"get".concat(e,"Attribute")},attacher:function(e,t,n){e.prototype[t]=function(e,r){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new B("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new B("Graph.".concat(t,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var s=""+e,i=""+r;if(r=arguments[2],!(o=c(this,s,i,n)))throw new U("Graph.".concat(t,': could not find an edge for the given path ("').concat(s,'" - "').concat(i,'").'))}else{if("mixed"!==n)throw new B("Graph.".concat(t,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(e=""+e,!(o=this._edges.get(e)))throw new U("Graph.".concat(t,': could not find the "').concat(e,'" edge in the graph.'))}return o.attributes[r]}}},{name:function(e){return"get".concat(e,"Attributes")},attacher:function(e,t,n){e.prototype[t]=function(e){var r;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new B("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>1){if(this.multi)throw new B("Graph.".concat(t,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var o=""+e,s=""+arguments[1];if(!(r=c(this,o,s,n)))throw new U("Graph.".concat(t,': could not find an edge for the given path ("').concat(o,'" - "').concat(s,'").'))}else{if("mixed"!==n)throw new B("Graph.".concat(t,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(e=""+e,!(r=this._edges.get(e)))throw new U("Graph.".concat(t,': could not find the "').concat(e,'" edge in the graph.'))}return r.attributes}}},{name:function(e){return"has".concat(e,"Attribute")},attacher:function(e,t,n){e.prototype[t]=function(e,r){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new B("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new B("Graph.".concat(t,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var s=""+e,i=""+r;if(r=arguments[2],!(o=c(this,s,i,n)))throw new U("Graph.".concat(t,': could not find an edge for the given path ("').concat(s,'" - "').concat(i,'").'))}else{if("mixed"!==n)throw new B("Graph.".concat(t,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(e=""+e,!(o=this._edges.get(e)))throw new U("Graph.".concat(t,': could not find the "').concat(e,'" edge in the graph.'))}return o.attributes.hasOwnProperty(r)}}},{name:function(e){return"set".concat(e,"Attribute")},attacher:function(e,t,n){e.prototype[t]=function(e,r,o){var s;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new B("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>3){if(this.multi)throw new B("Graph.".concat(t,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var i=""+e,a=""+r;if(r=arguments[2],o=arguments[3],!(s=c(this,i,a,n)))throw new U("Graph.".concat(t,': could not find an edge for the given path ("').concat(i,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new B("Graph.".concat(t,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(e=""+e,!(s=this._edges.get(e)))throw new U("Graph.".concat(t,': could not find the "').concat(e,'" edge in the graph.'))}return s.attributes[r]=o,this.emit("edgeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:r}),this}}},{name:function(e){return"update".concat(e,"Attribute")},attacher:function(e,t,n){e.prototype[t]=function(e,r,o){var s;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new B("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>3){if(this.multi)throw new B("Graph.".concat(t,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var i=""+e,a=""+r;if(r=arguments[2],o=arguments[3],!(s=c(this,i,a,n)))throw new U("Graph.".concat(t,': could not find an edge for the given path ("').concat(i,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new B("Graph.".concat(t,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(e=""+e,!(s=this._edges.get(e)))throw new U("Graph.".concat(t,': could not find the "').concat(e,'" edge in the graph.'))}if("function"!=typeof o)throw new V("Graph.".concat(t,": updater should be a function."));return s.attributes[r]=o(s.attributes[r]),this.emit("edgeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:r}),this}}},{name:function(e){return"remove".concat(e,"Attribute")},attacher:function(e,t,n){e.prototype[t]=function(e,r){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new B("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new B("Graph.".concat(t,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var s=""+e,i=""+r;if(r=arguments[2],!(o=c(this,s,i,n)))throw new U("Graph.".concat(t,': could not find an edge for the given path ("').concat(s,'" - "').concat(i,'").'))}else{if("mixed"!==n)throw new B("Graph.".concat(t,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(e=""+e,!(o=this._edges.get(e)))throw new U("Graph.".concat(t,': could not find the "').concat(e,'" edge in the graph.'))}return delete o.attributes[r],this.emit("edgeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:r}),this}}},{name:function(e){return"replace".concat(e,"Attributes")},attacher:function(e,t,n){e.prototype[t]=function(e,r){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new B("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new B("Graph.".concat(t,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var s=""+e,i=""+r;if(r=arguments[2],!(o=c(this,s,i,n)))throw new U("Graph.".concat(t,': could not find an edge for the given path ("').concat(s,'" - "').concat(i,'").'))}else{if("mixed"!==n)throw new B("Graph.".concat(t,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(e=""+e,!(o=this._edges.get(e)))throw new U("Graph.".concat(t,': could not find the "').concat(e,'" edge in the graph.'))}if(!l(r))throw new V("Graph.".concat(t,": provided attributes are not a plain object."));return o.attributes=r,this.emit("edgeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}},{name:function(e){return"merge".concat(e,"Attributes")},attacher:function(e,t,n){e.prototype[t]=function(e,r){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new B("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new B("Graph.".concat(t,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var s=""+e,i=""+r;if(r=arguments[2],!(o=c(this,s,i,n)))throw new U("Graph.".concat(t,': could not find an edge for the given path ("').concat(s,'" - "').concat(i,'").'))}else{if("mixed"!==n)throw new B("Graph.".concat(t,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(e=""+e,!(o=this._edges.get(e)))throw new U("Graph.".concat(t,': could not find the "').concat(e,'" edge in the graph.'))}if(!l(r))throw new V("Graph.".concat(t,": provided attributes are not a plain object."));return a(o.attributes,r),this.emit("edgeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:r}),this}}},{name:function(e){return"update".concat(e,"Attributes")},attacher:function(e,t,n){e.prototype[t]=function(e,r){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new B("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new B("Graph.".concat(t,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var s=""+e,i=""+r;if(r=arguments[2],!(o=c(this,s,i,n)))throw new U("Graph.".concat(t,': could not find an edge for the given path ("').concat(s,'" - "').concat(i,'").'))}else{if("mixed"!==n)throw new B("Graph.".concat(t,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(e=""+e,!(o=this._edges.get(e)))throw new U("Graph.".concat(t,': could not find the "').concat(e,'" edge in the graph.'))}if("function"!=typeof r)throw new V("Graph.".concat(t,": provided updater is not a function."));return o.attributes=r(o.attributes),this.emit("edgeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}}],X=$,Q=G,J=function(){var e=arguments,t=null,n=-1;return new X((function(){for(var r=null;;){if(null===t){if(++n>=e.length)return{done:!0};t=Q(e[n])}if(!0!==(r=t.next()).done)break;t=null}return r}))},ee=[{name:"edges",type:"mixed"},{name:"inEdges",type:"directed",direction:"in"},{name:"outEdges",type:"directed",direction:"out"},{name:"inboundEdges",type:"mixed",direction:"in"},{name:"outboundEdges",type:"mixed",direction:"out"},{name:"directedEdges",type:"directed"},{name:"undirectedEdges",type:"undirected"}];function te(e,t,n,r){var o=!1;for(var s in t)if(s!==r){var i=t[s];if(o=n(i.key,i.attributes,i.source.key,i.target.key,i.source.attributes,i.target.attributes,i.undirected),e&&o)return i.key}}function ne(e,t,n,r){var o,s,i,a=!1;for(var c in t)if(c!==r){o=t[c];do{if(s=o.source,i=o.target,a=n(o.key,o.attributes,s.key,i.key,s.attributes,i.attributes,o.undirected),e&&a)return o.key;o=o.next}while(void 0!==o)}}function re(e,t){var n,r=Object.keys(e),o=r.length,s=0;return new $((function(){do{if(n)n=n.next;else{if(s>=o)return{done:!0};var i=r[s++];if(i===t){n=void 0;continue}n=e[i]}}while(!n);return{done:!1,value:{edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected}}}))}function oe(e,t,n,r){var o=t[n];if(o){var s=o.source,i=o.target;return r(o.key,o.attributes,s.key,i.key,s.attributes,i.attributes,o.undirected)&&e?o.key:void 0}}function se(e,t,n,r){var o=t[n];if(o){var s=!1;do{if(s=r(o.key,o.attributes,o.source.key,o.target.key,o.source.attributes,o.target.attributes,o.undirected),e&&s)return o.key;o=o.next}while(void 0!==o)}}function ie(e,t){var n=e[t];return void 0!==n.next?new $((function(){if(!n)return{done:!0};var e={edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected};return n=n.next,{done:!1,value:e}})):$.of({edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected})}function ae(e,t,n,r){if(0!==t.size)for(var o,s,i="mixed"!==n&&n!==t.type,a="undirected"===n,c=!1,l=t._edges.values();!0!==(o=l.next()).done;)if(s=o.value,!i||s.undirected===a){var u=s,d=u.key,h=u.attributes,p=u.source,m=u.target;if(c=r(d,h,p.key,m.key,p.attributes,m.attributes,s.undirected),e&&c)return d}}function ce(e,t,n,r,o,s){var i,a=t?ne:te;if("undirected"!==n){if("out"!==r&&(i=a(e,o.in,s),e&&i))return i;if("in"!==r&&(i=a(e,o.out,s,r?void 0:o.key),e&&i))return i}if("directed"!==n&&(i=a(e,o.undirected,s),e&&i))return i}function le(e,t,n,r,o,s,i){var a,c=n?se:oe;if("undirected"!==t){if(void 0!==o.in&&"out"!==r&&(a=c(e,o.in,s,i),e&&a))return a;if(void 0!==o.out&&"in"!==r&&(r||o.key!==s)&&(a=c(e,o.out,s,i),e&&a))return a}if("directed"!==t&&void 0!==o.undirected&&(a=c(e,o.undirected,s,i),e&&a))return a}var ue=[{name:"neighbors",type:"mixed"},{name:"inNeighbors",type:"directed",direction:"in"},{name:"outNeighbors",type:"directed",direction:"out"},{name:"inboundNeighbors",type:"mixed",direction:"in"},{name:"outboundNeighbors",type:"mixed",direction:"out"},{name:"directedNeighbors",type:"directed"},{name:"undirectedNeighbors",type:"undirected"}];function de(){this.A=null,this.B=null}function he(e,t,n,r,o){for(var s in r){var i=r[s],a=i.source,c=i.target,l=a===n?c:a;if(!t||!t.has(l.key)){var u=o(l.key,l.attributes);if(e&&u)return l.key}}}function pe(e,t,n,r,o){if("mixed"!==t){if("undirected"===t)return he(e,null,r,r.undirected,o);if("string"==typeof n)return he(e,null,r,r[n],o)}var s,i=new de;if("undirected"!==t){if("out"!==n){if(s=he(e,null,r,r.in,o),e&&s)return s;i.wrap(r.in)}if("in"!==n){if(s=he(e,i,r,r.out,o),e&&s)return s;i.wrap(r.out)}}if("directed"!==t&&(s=he(e,i,r,r.undirected,o),e&&s))return s}function me(e,t,n){var r=Object.keys(n),o=r.length,s=0;return new $((function(){var i=null;do{if(s>=o)return e&&e.wrap(n),{done:!0};var a=n[r[s++]],c=a.source,l=a.target;i=c===t?l:c,e&&e.has(i.key)&&(i=null)}while(null===i);return{done:!1,value:{neighbor:i.key,attributes:i.attributes}}}))}function fe(e,t,n,r,o){for(var s,i,a,c,l,u,d,h=r._nodes.values(),p=r.type;!0!==(s=h.next()).done;){var m=!1;if(i=s.value,"undirected"!==p)for(a in c=i.out){l=c[a];do{if(u=l.target,m=!0,d=o(i.key,u.key,i.attributes,u.attributes,l.key,l.attributes,l.undirected),e&&d)return l;l=l.next}while(l)}if("directed"!==p)for(a in c=i.undirected)if(!(t&&i.key>a)){l=c[a];do{if((u=l.target).key!==a&&(u=l.source),m=!0,d=o(i.key,u.key,i.attributes,u.attributes,l.key,l.attributes,l.undirected),e&&d)return l;l=l.next}while(l)}if(n&&!m&&(d=o(i.key,null,i.attributes,null,null,null,null),e&&d))return null}}function ge(e){if(!l(e))throw new V('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in e))throw new V("Graph.import: serialized node is missing its key.");if("attributes"in e&&(!l(e.attributes)||null===e.attributes))throw new V("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function ye(e){if(!l(e))throw new V('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in e))throw new V("Graph.import: serialized edge is missing its source.");if(!("target"in e))throw new V("Graph.import: serialized edge is missing its target.");if("attributes"in e&&(!l(e.attributes)||null===e.attributes))throw new V("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in e&&"boolean"!=typeof e.undirected)throw new V("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}de.prototype.wrap=function(e){null===this.A?this.A=e:null===this.B&&(this.B=e)},de.prototype.has=function(e){return null!==this.A&&e in this.A||null!==this.B&&e in this.B};var be,we=(be=255&Math.floor(256*Math.random()),function(){return be++}),ve=new Set(["directed","undirected","mixed"]),Ae=new Set(["domain","_events","_eventsCount","_maxListeners"]),Ee={allowSelfLoops:!0,multi:!1,type:"mixed"};function Ce(e,t,n){var r=new e.NodeDataClass(t,n);return e._nodes.set(t,r),e.emit("nodeAdded",{key:t,attributes:n}),r}function Te(e,t,n,r,o,s,i,a){if(!r&&"undirected"===e.type)throw new B("Graph.".concat(t,": you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead."));if(r&&"directed"===e.type)throw new B("Graph.".concat(t,": you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead."));if(a&&!l(a))throw new V("Graph.".concat(t,': invalid attributes. Expecting an object but got "').concat(a,'"'));if(s=""+s,i=""+i,a=a||{},!e.allowSelfLoops&&s===i)throw new B("Graph.".concat(t,': source & target are the same ("').concat(s,"\"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false."));var c=e._nodes.get(s),u=e._nodes.get(i);if(!c)throw new U("Graph.".concat(t,': source node "').concat(s,'" not found.'));if(!u)throw new U("Graph.".concat(t,': target node "').concat(i,'" not found.'));var d={key:null,undirected:r,source:s,target:i,attributes:a};if(n)o=e._edgeKeyGenerator();else if(o=""+o,e._edges.has(o))throw new B("Graph.".concat(t,': the "').concat(o,'" edge already exists in the graph.'));if(!e.multi&&(r?void 0!==c.undirected[i]:void 0!==c.out[i]))throw new B("Graph.".concat(t,': an edge linking "').concat(s,'" to "').concat(i,"\" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option."));var h=new K(r,o,c,u,a);e._edges.set(o,h);var p=s===i;return r?(c.undirectedDegree++,u.undirectedDegree++,p&&(c.undirectedLoops++,e._undirectedSelfLoopCount++)):(c.outDegree++,u.inDegree++,p&&(c.directedLoops++,e._directedSelfLoopCount++)),e.multi?h.attachMulti():h.attach(),r?e._undirectedSize++:e._directedSize++,d.key=o,e.emit("edgeAdded",d),o}function Se(e,t,n,r,o,s,i,c,u){if(!r&&"undirected"===e.type)throw new B("Graph.".concat(t,": you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead."));if(r&&"directed"===e.type)throw new B("Graph.".concat(t,": you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead."));if(c)if(u){if("function"!=typeof c)throw new V("Graph.".concat(t,': invalid updater function. Expecting a function but got "').concat(c,'"'))}else if(!l(c))throw new V("Graph.".concat(t,': invalid attributes. Expecting an object but got "').concat(c,'"'));var d;if(s=""+s,i=""+i,u&&(d=c,c=void 0),!e.allowSelfLoops&&s===i)throw new B("Graph.".concat(t,': source & target are the same ("').concat(s,"\"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false."));var h,p,m=e._nodes.get(s),f=e._nodes.get(i);if(!n&&(h=e._edges.get(o))){if(!(h.source.key===s&&h.target.key===i||r&&h.source.key===i&&h.target.key===s))throw new B("Graph.".concat(t,': inconsistency detected when attempting to merge the "').concat(o,'" edge with "').concat(s,'" source & "').concat(i,'" target vs. ("').concat(h.source.key,'", "').concat(h.target.key,'").'));p=h}if(p||e.multi||!m||(p=r?m.undirected[i]:m.out[i]),p){var g=[p.key,!1,!1,!1];if(u?!d:!c)return g;if(u){var y=p.attributes;p.attributes=d(y),e.emit("edgeAttributesUpdated",{type:"replace",key:p.key,attributes:p.attributes})}else a(p.attributes,c),e.emit("edgeAttributesUpdated",{type:"merge",key:p.key,attributes:p.attributes,data:c});return g}c=c||{},u&&d&&(c=d(c));var b={key:null,undirected:r,source:s,target:i,attributes:c};if(n)o=e._edgeKeyGenerator();else if(o=""+o,e._edges.has(o))throw new B("Graph.".concat(t,': the "').concat(o,'" edge already exists in the graph.'));var w=!1,v=!1;m||(m=Ce(e,s,{}),w=!0,s===i&&(f=m,v=!0)),f||(f=Ce(e,i,{}),v=!0),h=new K(r,o,m,f,c),e._edges.set(o,h);var A=s===i;return r?(m.undirectedDegree++,f.undirectedDegree++,A&&(m.undirectedLoops++,e._undirectedSelfLoopCount++)):(m.outDegree++,f.inDegree++,A&&(m.directedLoops++,e._directedSelfLoopCount++)),e.multi?h.attachMulti():h.attach(),r?e._undirectedSize++:e._directedSize++,b.key=o,e.emit("edgeAdded",b),[o,!0,w,v]}function _e(e,t){e._edges.delete(t.key);var n=t.source,r=t.target,o=t.attributes,s=t.undirected,i=n===r;s?(n.undirectedDegree--,r.undirectedDegree--,i&&(n.undirectedLoops--,e._undirectedSelfLoopCount--)):(n.outDegree--,r.inDegree--,i&&(n.directedLoops--,e._directedSelfLoopCount--)),e.multi?t.detachMulti():t.detach(),s?e._undirectedSize--:e._directedSize--,e.emit("edgeDropped",{key:t.key,attributes:o,source:n.key,target:r.key,undirected:s})}var Pe=function(n){function r(e){var t;if(t=n.call(this)||this,"boolean"!=typeof(e=a({},Ee,e)).multi)throw new V("Graph.constructor: invalid 'multi' option. Expecting a boolean but got \"".concat(e.multi,'".'));if(!ve.has(e.type))throw new V('Graph.constructor: invalid \'type\' option. Should be one of "mixed", "directed" or "undirected" but got "'.concat(e.type,'".'));if("boolean"!=typeof e.allowSelfLoops)throw new V("Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got \"".concat(e.allowSelfLoops,'".'));var r="mixed"===e.type?Y:"directed"===e.type?W:j;d(i(t),"NodeDataClass",r);var o="geid_"+we()+"_",s=0;return d(i(t),"_attributes",{}),d(i(t),"_nodes",new Map),d(i(t),"_edges",new Map),d(i(t),"_directedSize",0),d(i(t),"_undirectedSize",0),d(i(t),"_directedSelfLoopCount",0),d(i(t),"_undirectedSelfLoopCount",0),d(i(t),"_edgeKeyGenerator",(function(){var e;do{e=o+s++}while(t._edges.has(e));return e})),d(i(t),"_options",e),Ae.forEach((function(e){return d(i(t),e,t[e])})),h(i(t),"order",(function(){return t._nodes.size})),h(i(t),"size",(function(){return t._edges.size})),h(i(t),"directedSize",(function(){return t._directedSize})),h(i(t),"undirectedSize",(function(){return t._undirectedSize})),h(i(t),"selfLoopCount",(function(){return t._directedSelfLoopCount+t._undirectedSelfLoopCount})),h(i(t),"directedSelfLoopCount",(function(){return t._directedSelfLoopCount})),h(i(t),"undirectedSelfLoopCount",(function(){return t._undirectedSelfLoopCount})),h(i(t),"multi",t._options.multi),h(i(t),"type",t._options.type),h(i(t),"allowSelfLoops",t._options.allowSelfLoops),h(i(t),"implementation",(function(){return"graphology"})),t}t(r,n);var o=r.prototype;return o._resetInstanceCounters=function(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0},o.hasNode=function(e){return this._nodes.has(""+e)},o.hasDirectedEdge=function(e,t){if("undirected"===this.type)return!1;if(1===arguments.length){var n=""+e,r=this._edges.get(n);return!!r&&!r.undirected}if(2===arguments.length){e=""+e,t=""+t;var o=this._nodes.get(e);return!!o&&o.out.hasOwnProperty(t)}throw new V("Graph.hasDirectedEdge: invalid arity (".concat(arguments.length,", instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target."))},o.hasUndirectedEdge=function(e,t){if("directed"===this.type)return!1;if(1===arguments.length){var n=""+e,r=this._edges.get(n);return!!r&&r.undirected}if(2===arguments.length){e=""+e,t=""+t;var o=this._nodes.get(e);return!!o&&o.undirected.hasOwnProperty(t)}throw new V("Graph.hasDirectedEdge: invalid arity (".concat(arguments.length,", instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target."))},o.hasEdge=function(e,t){if(1===arguments.length){var n=""+e;return this._edges.has(n)}if(2===arguments.length){e=""+e,t=""+t;var r=this._nodes.get(e);return!!r&&(void 0!==r.out&&r.out.hasOwnProperty(t)||void 0!==r.undirected&&r.undirected.hasOwnProperty(t))}throw new V("Graph.hasEdge: invalid arity (".concat(arguments.length,", instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target."))},o.directedEdge=function(e,t){if("undirected"!==this.type){if(e=""+e,t=""+t,this.multi)throw new B("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");var n=this._nodes.get(e);if(!n)throw new U('Graph.directedEdge: could not find the "'.concat(e,'" source node in the graph.'));if(!this._nodes.has(t))throw new U('Graph.directedEdge: could not find the "'.concat(t,'" target node in the graph.'));var r=n.out&&n.out[t]||void 0;return r?r.key:void 0}},o.undirectedEdge=function(e,t){if("directed"!==this.type){if(e=""+e,t=""+t,this.multi)throw new B("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");var n=this._nodes.get(e);if(!n)throw new U('Graph.undirectedEdge: could not find the "'.concat(e,'" source node in the graph.'));if(!this._nodes.has(t))throw new U('Graph.undirectedEdge: could not find the "'.concat(t,'" target node in the graph.'));var r=n.undirected&&n.undirected[t]||void 0;return r?r.key:void 0}},o.edge=function(e,t){if(this.multi)throw new B("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");e=""+e,t=""+t;var n=this._nodes.get(e);if(!n)throw new U('Graph.edge: could not find the "'.concat(e,'" source node in the graph.'));if(!this._nodes.has(t))throw new U('Graph.edge: could not find the "'.concat(t,'" target node in the graph.'));var r=n.out&&n.out[t]||n.undirected&&n.undirected[t]||void 0;if(r)return r.key},o.areDirectedNeighbors=function(e,t){e=""+e,t=""+t;var n=this._nodes.get(e);if(!n)throw new U('Graph.areDirectedNeighbors: could not find the "'.concat(e,'" node in the graph.'));return"undirected"!==this.type&&(t in n.in||t in n.out)},o.areOutNeighbors=function(e,t){e=""+e,t=""+t;var n=this._nodes.get(e);if(!n)throw new U('Graph.areOutNeighbors: could not find the "'.concat(e,'" node in the graph.'));return"undirected"!==this.type&&t in n.out},o.areInNeighbors=function(e,t){e=""+e,t=""+t;var n=this._nodes.get(e);if(!n)throw new U('Graph.areInNeighbors: could not find the "'.concat(e,'" node in the graph.'));return"undirected"!==this.type&&t in n.in},o.areUndirectedNeighbors=function(e,t){e=""+e,t=""+t;var n=this._nodes.get(e);if(!n)throw new U('Graph.areUndirectedNeighbors: could not find the "'.concat(e,'" node in the graph.'));return"directed"!==this.type&&t in n.undirected},o.areNeighbors=function(e,t){e=""+e,t=""+t;var n=this._nodes.get(e);if(!n)throw new U('Graph.areNeighbors: could not find the "'.concat(e,'" node in the graph.'));return"undirected"!==this.type&&(t in n.in||t in n.out)||"directed"!==this.type&&t in n.undirected},o.areInboundNeighbors=function(e,t){e=""+e,t=""+t;var n=this._nodes.get(e);if(!n)throw new U('Graph.areInboundNeighbors: could not find the "'.concat(e,'" node in the graph.'));return"undirected"!==this.type&&t in n.in||"directed"!==this.type&&t in n.undirected},o.areOutboundNeighbors=function(e,t){e=""+e,t=""+t;var n=this._nodes.get(e);if(!n)throw new U('Graph.areOutboundNeighbors: could not find the "'.concat(e,'" node in the graph.'));return"undirected"!==this.type&&t in n.out||"directed"!==this.type&&t in n.undirected},o.inDegree=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new U('Graph.inDegree: could not find the "'.concat(e,'" node in the graph.'));return"undirected"===this.type?0:t.inDegree},o.outDegree=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new U('Graph.outDegree: could not find the "'.concat(e,'" node in the graph.'));return"undirected"===this.type?0:t.outDegree},o.directedDegree=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new U('Graph.directedDegree: could not find the "'.concat(e,'" node in the graph.'));return"undirected"===this.type?0:t.inDegree+t.outDegree},o.undirectedDegree=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new U('Graph.undirectedDegree: could not find the "'.concat(e,'" node in the graph.'));return"directed"===this.type?0:t.undirectedDegree},o.inboundDegree=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new U('Graph.inboundDegree: could not find the "'.concat(e,'" node in the graph.'));var n=0;return"directed"!==this.type&&(n+=t.undirectedDegree),"undirected"!==this.type&&(n+=t.inDegree),n},o.outboundDegree=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new U('Graph.outboundDegree: could not find the "'.concat(e,'" node in the graph.'));var n=0;return"directed"!==this.type&&(n+=t.undirectedDegree),"undirected"!==this.type&&(n+=t.outDegree),n},o.degree=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new U('Graph.degree: could not find the "'.concat(e,'" node in the graph.'));var n=0;return"directed"!==this.type&&(n+=t.undirectedDegree),"undirected"!==this.type&&(n+=t.inDegree+t.outDegree),n},o.inDegreeWithoutSelfLoops=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new U('Graph.inDegreeWithoutSelfLoops: could not find the "'.concat(e,'" node in the graph.'));return"undirected"===this.type?0:t.inDegree-t.directedLoops},o.outDegreeWithoutSelfLoops=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new U('Graph.outDegreeWithoutSelfLoops: could not find the "'.concat(e,'" node in the graph.'));return"undirected"===this.type?0:t.outDegree-t.directedLoops},o.directedDegreeWithoutSelfLoops=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new U('Graph.directedDegreeWithoutSelfLoops: could not find the "'.concat(e,'" node in the graph.'));return"undirected"===this.type?0:t.inDegree+t.outDegree-2*t.directedLoops},o.undirectedDegreeWithoutSelfLoops=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new U('Graph.undirectedDegreeWithoutSelfLoops: could not find the "'.concat(e,'" node in the graph.'));return"directed"===this.type?0:t.undirectedDegree-2*t.undirectedLoops},o.inboundDegreeWithoutSelfLoops=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new U('Graph.inboundDegreeWithoutSelfLoops: could not find the "'.concat(e,'" node in the graph.'));var n=0,r=0;return"directed"!==this.type&&(n+=t.undirectedDegree,r+=2*t.undirectedLoops),"undirected"!==this.type&&(n+=t.inDegree,r+=t.directedLoops),n-r},o.outboundDegreeWithoutSelfLoops=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new U('Graph.outboundDegreeWithoutSelfLoops: could not find the "'.concat(e,'" node in the graph.'));var n=0,r=0;return"directed"!==this.type&&(n+=t.undirectedDegree,r+=2*t.undirectedLoops),"undirected"!==this.type&&(n+=t.outDegree,r+=t.directedLoops),n-r},o.degreeWithoutSelfLoops=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new U('Graph.degreeWithoutSelfLoops: could not find the "'.concat(e,'" node in the graph.'));var n=0,r=0;return"directed"!==this.type&&(n+=t.undirectedDegree,r+=2*t.undirectedLoops),"undirected"!==this.type&&(n+=t.inDegree+t.outDegree,r+=2*t.directedLoops),n-r},o.source=function(e){e=""+e;var t=this._edges.get(e);if(!t)throw new U('Graph.source: could not find the "'.concat(e,'" edge in the graph.'));return t.source.key},o.target=function(e){e=""+e;var t=this._edges.get(e);if(!t)throw new U('Graph.target: could not find the "'.concat(e,'" edge in the graph.'));return t.target.key},o.extremities=function(e){e=""+e;var t=this._edges.get(e);if(!t)throw new U('Graph.extremities: could not find the "'.concat(e,'" edge in the graph.'));return[t.source.key,t.target.key]},o.opposite=function(e,t){e=""+e,t=""+t;var n=this._edges.get(t);if(!n)throw new U('Graph.opposite: could not find the "'.concat(t,'" edge in the graph.'));var r=n.source.key,o=n.target.key;if(e===r)return o;if(e===o)return r;throw new U('Graph.opposite: the "'.concat(e,'" node is not attached to the "').concat(t,'" edge (').concat(r,", ").concat(o,")."))},o.hasExtremity=function(e,t){e=""+e,t=""+t;var n=this._edges.get(e);if(!n)throw new U('Graph.hasExtremity: could not find the "'.concat(e,'" edge in the graph.'));return n.source.key===t||n.target.key===t},o.isUndirected=function(e){e=""+e;var t=this._edges.get(e);if(!t)throw new U('Graph.isUndirected: could not find the "'.concat(e,'" edge in the graph.'));return t.undirected},o.isDirected=function(e){e=""+e;var t=this._edges.get(e);if(!t)throw new U('Graph.isDirected: could not find the "'.concat(e,'" edge in the graph.'));return!t.undirected},o.isSelfLoop=function(e){e=""+e;var t=this._edges.get(e);if(!t)throw new U('Graph.isSelfLoop: could not find the "'.concat(e,'" edge in the graph.'));return t.source===t.target},o.addNode=function(e,t){var n=function(e,t,n){if(n&&!l(n))throw new V('Graph.addNode: invalid attributes. Expecting an object but got "'.concat(n,'"'));if(t=""+t,n=n||{},e._nodes.has(t))throw new B('Graph.addNode: the "'.concat(t,'" node already exist in the graph.'));var r=new e.NodeDataClass(t,n);return e._nodes.set(t,r),e.emit("nodeAdded",{key:t,attributes:n}),r}(this,e,t);return n.key},o.mergeNode=function(e,t){if(t&&!l(t))throw new V('Graph.mergeNode: invalid attributes. Expecting an object but got "'.concat(t,'"'));e=""+e,t=t||{};var n=this._nodes.get(e);return n?(t&&(a(n.attributes,t),this.emit("nodeAttributesUpdated",{type:"merge",key:e,attributes:n.attributes,data:t})),[e,!1]):(n=new this.NodeDataClass(e,t),this._nodes.set(e,n),this.emit("nodeAdded",{key:e,attributes:t}),[e,!0])},o.updateNode=function(e,t){if(t&&"function"!=typeof t)throw new V('Graph.updateNode: invalid updater function. Expecting a function but got "'.concat(t,'"'));e=""+e;var n=this._nodes.get(e);if(n){if(t){var r=n.attributes;n.attributes=t(r),this.emit("nodeAttributesUpdated",{type:"replace",key:e,attributes:n.attributes})}return[e,!1]}var o=t?t({}):{};return n=new this.NodeDataClass(e,o),this._nodes.set(e,n),this.emit("nodeAdded",{key:e,attributes:o}),[e,!0]},o.dropNode=function(e){e=""+e;var t,n=this._nodes.get(e);if(!n)throw new U('Graph.dropNode: could not find the "'.concat(e,'" node in the graph.'));if("undirected"!==this.type){for(var r in n.out){t=n.out[r];do{_e(this,t),t=t.next}while(t)}for(var o in n.in){t=n.in[o];do{_e(this,t),t=t.next}while(t)}}if("directed"!==this.type)for(var s in n.undirected){t=n.undirected[s];do{_e(this,t),t=t.next}while(t)}this._nodes.delete(e),this.emit("nodeDropped",{key:e,attributes:n.attributes})},o.dropEdge=function(e){var t;if(arguments.length>1){var n=""+arguments[0],r=""+arguments[1];if(!(t=c(this,n,r,this.type)))throw new U('Graph.dropEdge: could not find the "'.concat(n,'" -> "').concat(r,'" edge in the graph.'))}else if(e=""+e,!(t=this._edges.get(e)))throw new U('Graph.dropEdge: could not find the "'.concat(e,'" edge in the graph.'));return _e(this,t),this},o.dropDirectedEdge=function(e,t){if(arguments.length<2)throw new B("Graph.dropDirectedEdge: it does not make sense to try and drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new B("Graph.dropDirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");var n=c(this,e=""+e,t=""+t,"directed");if(!n)throw new U('Graph.dropDirectedEdge: could not find a "'.concat(e,'" -> "').concat(t,'" edge in the graph.'));return _e(this,n),this},o.dropUndirectedEdge=function(e,t){if(arguments.length<2)throw new B("Graph.dropUndirectedEdge: it does not make sense to drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new B("Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");var n=c(this,e,t,"undirected");if(!n)throw new U('Graph.dropUndirectedEdge: could not find a "'.concat(e,'" -> "').concat(t,'" edge in the graph.'));return _e(this,n),this},o.clear=function(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")},o.clearEdges=function(){for(var e,t=this._nodes.values();!0!==(e=t.next()).done;)e.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")},o.getAttribute=function(e){return this._attributes[e]},o.getAttributes=function(){return this._attributes},o.hasAttribute=function(e){return this._attributes.hasOwnProperty(e)},o.setAttribute=function(e,t){return this._attributes[e]=t,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this},o.updateAttribute=function(e,t){if("function"!=typeof t)throw new V("Graph.updateAttribute: updater should be a function.");var n=this._attributes[e];return this._attributes[e]=t(n),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this},o.removeAttribute=function(e){return delete this._attributes[e],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:e}),this},o.replaceAttributes=function(e){if(!l(e))throw new V("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=e,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this},o.mergeAttributes=function(e){if(!l(e))throw new V("Graph.mergeAttributes: provided attributes are not a plain object.");return a(this._attributes,e),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:e}),this},o.updateAttributes=function(e){if("function"!=typeof e)throw new V("Graph.updateAttributes: provided updater is not a function.");return this._attributes=e(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this},o.updateEachNodeAttributes=function(e,t){if("function"!=typeof e)throw new V("Graph.updateEachNodeAttributes: expecting an updater function.");if(t&&!p(t))throw new V("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");for(var n,r,o=this._nodes.values();!0!==(n=o.next()).done;)(r=n.value).attributes=e(r.key,r.attributes);this.emit("eachNodeAttributesUpdated",{hints:t||null})},o.updateEachEdgeAttributes=function(e,t){if("function"!=typeof e)throw new V("Graph.updateEachEdgeAttributes: expecting an updater function.");if(t&&!p(t))throw new V("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");for(var n,r,o,s,i=this._edges.values();!0!==(n=i.next()).done;)o=(r=n.value).source,s=r.target,r.attributes=e(r.key,r.attributes,o.key,s.key,o.attributes,s.attributes,r.undirected);this.emit("eachEdgeAttributesUpdated",{hints:t||null})},o.forEachAdjacencyEntry=function(e){if("function"!=typeof e)throw new V("Graph.forEachAdjacencyEntry: expecting a callback.");fe(!1,!1,!1,this,e)},o.forEachAdjacencyEntryWithOrphans=function(e){if("function"!=typeof e)throw new V("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");fe(!1,!1,!0,this,e)},o.forEachAssymetricAdjacencyEntry=function(e){if("function"!=typeof e)throw new V("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");fe(!1,!0,!1,this,e)},o.forEachAssymetricAdjacencyEntryWithOrphans=function(e){if("function"!=typeof e)throw new V("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");fe(!1,!0,!0,this,e)},o.nodes=function(){return"function"==typeof Array.from?Array.from(this._nodes.keys()):H(this._nodes.keys(),this._nodes.size)},o.forEachNode=function(e){if("function"!=typeof e)throw new V("Graph.forEachNode: expecting a callback.");for(var t,n,r=this._nodes.values();!0!==(t=r.next()).done;)e((n=t.value).key,n.attributes)},o.findNode=function(e){if("function"!=typeof e)throw new V("Graph.findNode: expecting a callback.");for(var t,n,r=this._nodes.values();!0!==(t=r.next()).done;)if(e((n=t.value).key,n.attributes))return n.key},o.mapNodes=function(e){if("function"!=typeof e)throw new V("Graph.mapNode: expecting a callback.");for(var t,n,r=this._nodes.values(),o=new Array(this.order),s=0;!0!==(t=r.next()).done;)n=t.value,o[s++]=e(n.key,n.attributes);return o},o.someNode=function(e){if("function"!=typeof e)throw new V("Graph.someNode: expecting a callback.");for(var t,n,r=this._nodes.values();!0!==(t=r.next()).done;)if(e((n=t.value).key,n.attributes))return!0;return!1},o.everyNode=function(e){if("function"!=typeof e)throw new V("Graph.everyNode: expecting a callback.");for(var t,n,r=this._nodes.values();!0!==(t=r.next()).done;)if(!e((n=t.value).key,n.attributes))return!1;return!0},o.filterNodes=function(e){if("function"!=typeof e)throw new V("Graph.filterNodes: expecting a callback.");for(var t,n,r=this._nodes.values(),o=[];!0!==(t=r.next()).done;)e((n=t.value).key,n.attributes)&&o.push(n.key);return o},o.reduceNodes=function(e,t){if("function"!=typeof e)throw new V("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new V("Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.");for(var n,r,o=t,s=this._nodes.values();!0!==(n=s.next()).done;)o=e(o,(r=n.value).key,r.attributes);return o},o.nodeEntries=function(){var e=this._nodes.values();return new $((function(){var t=e.next();if(t.done)return t;var n=t.value;return{value:{node:n.key,attributes:n.attributes},done:!1}}))},o.export=function(){var e=this,t=new Array(this._nodes.size),n=0;this._nodes.forEach((function(e,r){t[n++]=function(e,t){var n={key:e};return u(t.attributes)||(n.attributes=a({},t.attributes)),n}(r,e)}));var r=new Array(this._edges.size);return n=0,this._edges.forEach((function(t,o){r[n++]=function(e,t,n){var r={key:t,source:n.source.key,target:n.target.key};return u(n.attributes)||(r.attributes=a({},n.attributes)),"mixed"===e&&n.undirected&&(r.undirected=!0),r}(e.type,o,t)})),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:t,edges:r}},o.import=function(e){var t,n,o,s,i,a=this,c=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(e instanceof r)return e.forEachNode((function(e,t){c?a.mergeNode(e,t):a.addNode(e,t)})),e.forEachEdge((function(e,t,n,r,o,s,i){c?i?a.mergeUndirectedEdgeWithKey(e,n,r,t):a.mergeDirectedEdgeWithKey(e,n,r,t):i?a.addUndirectedEdgeWithKey(e,n,r,t):a.addDirectedEdgeWithKey(e,n,r,t)})),this;if(!l(e))throw new V("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(e.attributes){if(!l(e.attributes))throw new V("Graph.import: invalid attributes. Expecting a plain object.");c?this.mergeAttributes(e.attributes):this.replaceAttributes(e.attributes)}if(e.nodes){if(o=e.nodes,!Array.isArray(o))throw new V("Graph.import: invalid nodes. Expecting an array.");for(t=0,n=o.length;t<n;t++){ge(s=o[t]);var u=s,d=u.key,h=u.attributes;c?this.mergeNode(d,h):this.addNode(d,h)}}if(e.edges){var p=!1;if("undirected"===this.type&&(p=!0),o=e.edges,!Array.isArray(o))throw new V("Graph.import: invalid edges. Expecting an array.");for(t=0,n=o.length;t<n;t++){ye(i=o[t]);var m=i,f=m.source,g=m.target,y=m.attributes,b=m.undirected,w=void 0===b?p:b;"key"in i?(c?w?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:w?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey).call(this,i.key,f,g,y):(c?w?this.mergeUndirectedEdge:this.mergeDirectedEdge:w?this.addUndirectedEdge:this.addDirectedEdge).call(this,f,g,y)}}return this},o.nullCopy=function(e){var t=new r(a({},this._options,e));return t.replaceAttributes(a({},this.getAttributes())),t},o.emptyCopy=function(e){var t=this.nullCopy(e);return this._nodes.forEach((function(e,n){var r=a({},e.attributes);e=new t.NodeDataClass(n,r),t._nodes.set(n,e)})),t},o.copy=function(e){if("string"==typeof(e=e||{}).type&&e.type!==this.type&&"mixed"!==e.type)throw new B('Graph.copy: cannot create an incompatible copy from "'.concat(this.type,'" type to "').concat(e.type,'" because this would mean losing information about the current graph.'));if("boolean"==typeof e.multi&&e.multi!==this.multi&&!0!==e.multi)throw new B("Graph.copy: cannot create an incompatible copy by downgrading a multi graph to a simple one because this would mean losing information about the current graph.");if("boolean"==typeof e.allowSelfLoops&&e.allowSelfLoops!==this.allowSelfLoops&&!0!==e.allowSelfLoops)throw new B("Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.");for(var t,n,r=this.emptyCopy(e),o=this._edges.values();!0!==(t=o.next()).done;)Te(r,"copy",!1,(n=t.value).undirected,n.key,n.source.key,n.target.key,a({},n.attributes));return r},o.toJSON=function(){return this.export()},o.toString=function(){return"[object Graph]"},o.inspect=function(){var t=this,n={};this._nodes.forEach((function(e,t){n[t]=e.attributes}));var r={},o={};this._edges.forEach((function(e,n){var s,i=e.undirected?"--":"->",a="",c=e.source.key,l=e.target.key;e.undirected&&c>l&&(s=c,c=l,l=s);var u="(".concat(c,")").concat(i,"(").concat(l,")");n.startsWith("geid_")?t.multi&&(void 0===o[u]?o[u]=0:o[u]++,a+="".concat(o[u],". ")):a+="[".concat(n,"]: "),r[a+=u]=e.attributes}));var s={};for(var i in this)this.hasOwnProperty(i)&&!Ae.has(i)&&"function"!=typeof this[i]&&"symbol"!==e(i)&&(s[i]=this[i]);return s.attributes=this._attributes,s.nodes=n,s.edges=r,d(s,"constructor",this.constructor),s},r}(f.exports.EventEmitter);"undefined"!=typeof Symbol&&(Pe.prototype[Symbol.for("nodejs.util.inspect.custom")]=Pe.prototype.inspect),[{name:function(e){return"".concat(e,"Edge")},generateKey:!0},{name:function(e){return"".concat(e,"DirectedEdge")},generateKey:!0,type:"directed"},{name:function(e){return"".concat(e,"UndirectedEdge")},generateKey:!0,type:"undirected"},{name:function(e){return"".concat(e,"EdgeWithKey")}},{name:function(e){return"".concat(e,"DirectedEdgeWithKey")},type:"directed"},{name:function(e){return"".concat(e,"UndirectedEdgeWithKey")},type:"undirected"}].forEach((function(e){["add","merge","update"].forEach((function(t){var n=e.name(t),r="add"===t?Te:Se;e.generateKey?Pe.prototype[n]=function(o,s,i){return r(this,n,!0,"undirected"===(e.type||this.type),null,o,s,i,"update"===t)}:Pe.prototype[n]=function(o,s,i,a){return r(this,n,!1,"undirected"===(e.type||this.type),o,s,i,a,"update"===t)}}))})),function(e){z.forEach((function(t){var n=t.name,r=t.attacher;r(e,n("Node"),0),r(e,n("Source"),1),r(e,n("Target"),2),r(e,n("Opposite"),3)}))}(Pe),function(e){Z.forEach((function(t){var n=t.name,r=t.attacher;r(e,n("Edge"),"mixed"),r(e,n("DirectedEdge"),"directed"),r(e,n("UndirectedEdge"),"undirected")}))}(Pe),function(e){ee.forEach((function(t){!function(e,t){var n=t.name,r=t.type,o=t.direction;e.prototype[n]=function(e,t){if("mixed"!==r&&"mixed"!==this.type&&r!==this.type)return[];if(!arguments.length)return function(e,t){if(0===e.size)return[];if("mixed"===t||t===e.type)return"function"==typeof Array.from?Array.from(e._edges.keys()):H(e._edges.keys(),e._edges.size);for(var n,r,o="undirected"===t?e.undirectedSize:e.directedSize,s=new Array(o),i="undirected"===t,a=e._edges.values(),c=0;!0!==(n=a.next()).done;)(r=n.value).undirected===i&&(s[c++]=r.key);return s}(this,r);if(1===arguments.length){e=""+e;var s=this._nodes.get(e);if(void 0===s)throw new U("Graph.".concat(n,': could not find the "').concat(e,'" node in the graph.'));return function(e,t,n,r){var o=[];return ce(!1,e,t,n,r,(function(e){o.push(e)})),o}(this.multi,"mixed"===r?this.type:r,o,s)}if(2===arguments.length){e=""+e,t=""+t;var i=this._nodes.get(e);if(!i)throw new U("Graph.".concat(n,': could not find the "').concat(e,'" source node in the graph.'));if(!this._nodes.has(t))throw new U("Graph.".concat(n,': could not find the "').concat(t,'" target node in the graph.'));return function(e,t,n,r,o){var s=[];return le(!1,e,t,n,r,o,(function(e){s.push(e)})),s}(r,this.multi,o,i,t)}throw new V("Graph.".concat(n,": too many arguments (expecting 0, 1 or 2 and got ").concat(arguments.length,")."))}}(e,t),function(e,t){var n=t.name,r=t.type,o=t.direction,s="forEach"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[s]=function(e,t,n){if("mixed"===r||"mixed"===this.type||r===this.type){if(1===arguments.length)return ae(!1,this,r,n=e);if(2===arguments.length){e=""+e,n=t;var i=this._nodes.get(e);if(void 0===i)throw new U("Graph.".concat(s,': could not find the "').concat(e,'" node in the graph.'));return ce(!1,this.multi,"mixed"===r?this.type:r,o,i,n)}if(3===arguments.length){e=""+e,t=""+t;var a=this._nodes.get(e);if(!a)throw new U("Graph.".concat(s,': could not find the "').concat(e,'" source node in the graph.'));if(!this._nodes.has(t))throw new U("Graph.".concat(s,': could not find the "').concat(t,'" target node in the graph.'));return le(!1,r,this.multi,o,a,t,n)}throw new V("Graph.".concat(s,": too many arguments (expecting 1, 2 or 3 and got ").concat(arguments.length,")."))}};var i="map"+n[0].toUpperCase()+n.slice(1);e.prototype[i]=function(){var e,t=Array.prototype.slice.call(arguments),n=t.pop();if(0===t.length){var o=0;"directed"!==r&&(o+=this.undirectedSize),"undirected"!==r&&(o+=this.directedSize),e=new Array(o);var i=0;t.push((function(t,r,o,s,a,c,l){e[i++]=n(t,r,o,s,a,c,l)}))}else e=[],t.push((function(t,r,o,s,i,a,c){e.push(n(t,r,o,s,i,a,c))}));return this[s].apply(this,t),e};var a="filter"+n[0].toUpperCase()+n.slice(1);e.prototype[a]=function(){var e=Array.prototype.slice.call(arguments),t=e.pop(),n=[];return e.push((function(e,r,o,s,i,a,c){t(e,r,o,s,i,a,c)&&n.push(e)})),this[s].apply(this,e),n};var c="reduce"+n[0].toUpperCase()+n.slice(1);e.prototype[c]=function(){var e,t,n=Array.prototype.slice.call(arguments);if(n.length<2||n.length>4)throw new V("Graph.".concat(c,": invalid number of arguments (expecting 2, 3 or 4 and got ").concat(n.length,")."));if("function"==typeof n[n.length-1]&&"function"!=typeof n[n.length-2])throw new V("Graph.".concat(c,": missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array."));2===n.length?(e=n[0],t=n[1],n=[]):3===n.length?(e=n[1],t=n[2],n=[n[0]]):4===n.length&&(e=n[2],t=n[3],n=[n[0],n[1]]);var r=t;return n.push((function(t,n,o,s,i,a,c){r=e(r,t,n,o,s,i,a,c)})),this[s].apply(this,n),r}}(e,t),function(e,t){var n=t.name,r=t.type,o=t.direction,s="find"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[s]=function(e,t,n){if("mixed"!==r&&"mixed"!==this.type&&r!==this.type)return!1;if(1===arguments.length)return ae(!0,this,r,n=e);if(2===arguments.length){e=""+e,n=t;var i=this._nodes.get(e);if(void 0===i)throw new U("Graph.".concat(s,': could not find the "').concat(e,'" node in the graph.'));return ce(!0,this.multi,"mixed"===r?this.type:r,o,i,n)}if(3===arguments.length){e=""+e,t=""+t;var a=this._nodes.get(e);if(!a)throw new U("Graph.".concat(s,': could not find the "').concat(e,'" source node in the graph.'));if(!this._nodes.has(t))throw new U("Graph.".concat(s,': could not find the "').concat(t,'" target node in the graph.'));return le(!0,r,this.multi,o,a,t,n)}throw new V("Graph.".concat(s,": too many arguments (expecting 1, 2 or 3 and got ").concat(arguments.length,")."))};var i="some"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[i]=function(){var e=Array.prototype.slice.call(arguments),t=e.pop();return e.push((function(e,n,r,o,s,i,a){return t(e,n,r,o,s,i,a)})),!!this[s].apply(this,e)};var a="every"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[a]=function(){var e=Array.prototype.slice.call(arguments),t=e.pop();return e.push((function(e,n,r,o,s,i,a){return!t(e,n,r,o,s,i,a)})),!this[s].apply(this,e)}}(e,t),function(e,t){var n=t.name,r=t.type,o=t.direction,s=n.slice(0,-1)+"Entries";e.prototype[s]=function(e,t){if("mixed"!==r&&"mixed"!==this.type&&r!==this.type)return $.empty();if(!arguments.length)return function(e,t){if(0===e.size)return $.empty();var n="mixed"!==t&&t!==e.type,r="undirected"===t,o=e._edges.values();return new $((function(){for(var e,t;;){if((e=o.next()).done)return e;if(t=e.value,!n||t.undirected===r)break}return{value:{edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected},done:!1}}))}(this,r);if(1===arguments.length){e=""+e;var n=this._nodes.get(e);if(!n)throw new U("Graph.".concat(s,': could not find the "').concat(e,'" node in the graph.'));return function(e,t,n){var r=$.empty();return"undirected"!==e&&("out"!==t&&void 0!==n.in&&(r=J(r,re(n.in))),"in"!==t&&void 0!==n.out&&(r=J(r,re(n.out,t?void 0:n.key)))),"directed"!==e&&void 0!==n.undirected&&(r=J(r,re(n.undirected))),r}(r,o,n)}if(2===arguments.length){e=""+e,t=""+t;var i=this._nodes.get(e);if(!i)throw new U("Graph.".concat(s,': could not find the "').concat(e,'" source node in the graph.'));if(!this._nodes.has(t))throw new U("Graph.".concat(s,': could not find the "').concat(t,'" target node in the graph.'));return function(e,t,n,r){var o=$.empty();return"undirected"!==e&&(void 0!==n.in&&"out"!==t&&r in n.in&&(o=J(o,ie(n.in,r))),void 0!==n.out&&"in"!==t&&r in n.out&&(t||n.key!==r)&&(o=J(o,ie(n.out,r)))),"directed"!==e&&void 0!==n.undirected&&r in n.undirected&&(o=J(o,ie(n.undirected,r))),o}(r,o,i,t)}throw new V("Graph.".concat(s,": too many arguments (expecting 0, 1 or 2 and got ").concat(arguments.length,")."))}}(e,t)}))}(Pe),function(e){ue.forEach((function(t){(function(e,t){var n=t.name,r=t.type,o=t.direction;e.prototype[n]=function(e){if("mixed"!==r&&"mixed"!==this.type&&r!==this.type)return[];e=""+e;var t=this._nodes.get(e);if(void 0===t)throw new U("Graph.".concat(n,': could not find the "').concat(e,'" node in the graph.'));return function(e,t,n){if("mixed"!==e){if("undirected"===e)return Object.keys(n.undirected);if("string"==typeof t)return Object.keys(n[t])}var r=[];return pe(!1,e,t,n,(function(e){r.push(e)})),r}("mixed"===r?this.type:r,o,t)}})(e,t),function(e,t){var n=t.name,r=t.type,o=t.direction,s="forEach"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[s]=function(e,t){if("mixed"===r||"mixed"===this.type||r===this.type){e=""+e;var n=this._nodes.get(e);if(void 0===n)throw new U("Graph.".concat(s,': could not find the "').concat(e,'" node in the graph.'));pe(!1,"mixed"===r?this.type:r,o,n,t)}};var i="map"+n[0].toUpperCase()+n.slice(1);e.prototype[i]=function(e,t){var n=[];return this[s](e,(function(e,r){n.push(t(e,r))})),n};var a="filter"+n[0].toUpperCase()+n.slice(1);e.prototype[a]=function(e,t){var n=[];return this[s](e,(function(e,r){t(e,r)&&n.push(e)})),n};var c="reduce"+n[0].toUpperCase()+n.slice(1);e.prototype[c]=function(e,t,n){if(arguments.length<3)throw new V("Graph.".concat(c,": missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array."));var r=n;return this[s](e,(function(e,n){r=t(r,e,n)})),r}}(e,t),function(e,t){var n=t.name,r=t.type,o=t.direction,s=n[0].toUpperCase()+n.slice(1,-1),i="find"+s;e.prototype[i]=function(e,t){if("mixed"===r||"mixed"===this.type||r===this.type){e=""+e;var n=this._nodes.get(e);if(void 0===n)throw new U("Graph.".concat(i,': could not find the "').concat(e,'" node in the graph.'));return pe(!0,"mixed"===r?this.type:r,o,n,t)}};var a="some"+s;e.prototype[a]=function(e,t){return!!this[i](e,t)};var c="every"+s;e.prototype[c]=function(e,t){return!this[i](e,(function(e,n){return!t(e,n)}))}}(e,t),function(e,t){var n=t.name,r=t.type,o=t.direction,s=n.slice(0,-1)+"Entries";e.prototype[s]=function(e){if("mixed"!==r&&"mixed"!==this.type&&r!==this.type)return $.empty();e=""+e;var t=this._nodes.get(e);if(void 0===t)throw new U("Graph.".concat(s,': could not find the "').concat(e,'" node in the graph.'));return function(e,t,n){if("mixed"!==e){if("undirected"===e)return me(null,n,n.undirected);if("string"==typeof t)return me(null,n,n[t])}var r=$.empty(),o=new de;return"undirected"!==e&&("out"!==t&&(r=J(r,me(o,n,n.in))),"in"!==t&&(r=J(r,me(o,n,n.out)))),"directed"!==e&&(r=J(r,me(o,n,n.undirected))),r}("mixed"===r?this.type:r,o,t)}}(e,t)}))}(Pe);var Me=function(e){function n(t){var n=a({type:"directed"},t);if("multi"in n&&!1!==n.multi)throw new V("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if("directed"!==n.type)throw new V('DirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return e.call(this,n)||this}return t(n,e),n}(Pe),xe=function(e){function n(t){var n=a({type:"undirected"},t);if("multi"in n&&!1!==n.multi)throw new V("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if("undirected"!==n.type)throw new V('UndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return e.call(this,n)||this}return t(n,e),n}(Pe),Ne=function(e){function n(t){var n=a({multi:!0},t);if("multi"in n&&!0!==n.multi)throw new V("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");return e.call(this,n)||this}return t(n,e),n}(Pe),$e=function(e){function n(t){var n=a({type:"directed",multi:!0},t);if("multi"in n&&!0!==n.multi)throw new V("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if("directed"!==n.type)throw new V('MultiDirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return e.call(this,n)||this}return t(n,e),n}(Pe),Le=function(e){function n(t){var n=a({type:"undirected",multi:!0},t);if("multi"in n&&!0!==n.multi)throw new V("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if("undirected"!==n.type)throw new V('MultiUndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return e.call(this,n)||this}return t(n,e),n}(Pe);function Ie(e){e.from=function(t,n){var r=a({},t.options,n),o=new e(r);return o.import(t),o}}return Ie(Pe),Ie(Me),Ie(xe),Ie(Ne),Ie($e),Ie(Le),Pe.Graph=Pe,Pe.DirectedGraph=Me,Pe.UndirectedGraph=xe,Pe.MultiGraph=Ne,Pe.MultiDirectedGraph=$e,Pe.MultiUndirectedGraph=Le,Pe.InvalidArgumentsGraphError=V,Pe.NotFoundGraphError=U,Pe.UsageGraphError=B,Pe}()},944:(e,t)=>{"use strict";t.Vb=void 0,t.Vb=function(e,t,n){var r=function(e,t,n){if(0===e.length||0===t.length)return 0;if(n&&!n.caseSensitive&&(e=e.toUpperCase(),t=t.toUpperCase()),e===t)return 1;for(var r=0,o=e.length,s=t.length,i=Math.floor(Math.max(o,s)/2)-1,a=new Array(o),c=new Array(s),l=0;l<o;l++)for(var u=Math.max(0,l-i);u<=Math.min(s,l+i+1);u++)if(!a[l]&&!c[u]&&e[l]===t[u]){++r,a[l]=c[u]=!0;break}if(0===r)return 0;var d=0,h=0;for(l=0;l<o;l++)if(a[l]){for(;!c[h];)h++;e.charAt(l)!==t.charAt(h++)&&d++}return(r/o+r/s+(r-(d/=2))/r)/3}(e,t,n),o=0;if(r>.7){for(var s=Math.min(e.length,t.length),i=0;e[i]===t[i]&&i<4&&i<s;)++o,i++;r+=.1*o*(1-r)}return r}},7106:e=>{"use strict";var t=e.exports=function(e,t,r){"function"==typeof t&&(r=t,t={}),n(t,"function"==typeof(r=t.cb||r)?r:r.pre||function(){},r.post||function(){},e,"",e)};function n(e,r,o,s,i,a,c,l,u,d){if(s&&"object"==typeof s&&!Array.isArray(s)){for(var h in r(s,i,a,c,l,u,d),s){var p=s[h];if(Array.isArray(p)){if(h in t.arrayKeywords)for(var m=0;m<p.length;m++)n(e,r,o,p[m],i+"/"+h+"/"+m,a,i,h,s,m)}else if(h in t.propsKeywords){if(p&&"object"==typeof p)for(var f in p)n(e,r,o,p[f],i+"/"+h+"/"+f.replace(/~/g,"~0").replace(/\//g,"~1"),a,i,h,s,f)}else(h in t.keywords||e.allKeys&&!(h in t.skipKeywords))&&n(e,r,o,p,i+"/"+h,a,i,h,s)}o(s,i,a,c,l,u,d)}}t.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0},t.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},t.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},t.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0}},5072:e=>{"use strict";var t=[];function n(e){for(var n=-1,r=0;r<t.length;r++)if(t[r].identifier===e){n=r;break}return n}function r(e,r){for(var s={},i=[],a=0;a<e.length;a++){var c=e[a],l=r.base?c[0]+r.base:c[0],u=s[l]||0,d="".concat(l," ").concat(u);s[l]=u+1;var h=n(d),p={css:c[1],media:c[2],sourceMap:c[3],supports:c[4],layer:c[5]};if(-1!==h)t[h].references++,t[h].updater(p);else{var m=o(p,r);r.byIndex=a,t.splice(a,0,{identifier:d,updater:m,references:1})}i.push(d)}return i}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 s=r(e=e||[],o=o||{});return function(e){e=e||[];for(var i=0;i<s.length;i++){var a=n(s[i]);t[a].references--}for(var c=r(e,o),l=0;l<s.length;l++){var u=n(s[l]);0===t[u].references&&(t[u].updater(),t.splice(u,1))}s=c}}},7659:e=>{"use strict";var t={};e.exports=function(e,n){var r=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(!r)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");r.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}},5056:(e,t,n)=>{"use strict";e.exports=function(e){var t=n.nc;t&&e.setAttribute("nonce",t)}},7825: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 r="";n.supports&&(r+="@supports (".concat(n.supports,") {")),n.media&&(r+="@media ".concat(n.media," {"));var o=void 0!==n.layer;o&&(r+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),r+=n.css,o&&(r+="}"),n.media&&(r+="}"),n.supports&&(r+="}");var s=n.sourceMap;s&&"undefined"!=typeof btoa&&(r+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(s))))," */")),t.styleTagTransform(r,e,t.options)}(t,e,n)},remove:function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(t)}}}},1113: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))}}},6723:(e,t,n)=>{"use strict";n.d(t,{_package:()=>je,getMonomerLibHelper:()=>Ke});var r,o,s=n(4328),i=n(7389),a=n(6082);n(684),n(9039),(o=r||(r={})).EUCLIDEAN="EUCLIDEAN",o.MANHATTAN="MANHATTAN";var c=n(1858),l=n(5072),u=n.n(l),d=n(7825),h=n.n(d),p=n(7659),m=n.n(p),f=n(5056),g=n.n(f),y=n(540),b=n.n(y),w=n(1113),v=n.n(w),A=n(7939),E={};E.styleTagTransform=v(),E.setAttributes=g(),E.insert=m().bind(null,"head"),E.domAPI=h(),E.insertStyleElement=b(),u()(A.A,E),A.A&&A.A.locals&&A.A.locals,n(2780),Promise.resolve(),n(934),n(8903);var C=n(1991),T=n.n(C);a.SEMTYPE.MOLECULE,a.SEMTYPE.MACROMOLECULE;var S=n(9713);n(6295);var _,P,M,x,N,$,L=n(8774);(M=_||(_={})).none="none",M.bold="bold",M.dashed="dashed",(x=P||(P={})).EUCLIDEAN="EUCLIDEAN",x.MANHATTAN="MANHATTAN",P.EUCLIDEAN,P.MANHATTAN,($=N||(N={})).HAMMING="Hamming",$.EUCLIDEAN="Euclidean",$.VECTOR_COSINE="Vector Cosine",$.MANHATTAN="Manhattan",$.TANIMOTO="Tanimoto",$.LEVENSTEIN="Levenshtein",$.NEEDLEMAN_WUNSCH="Needlemann-Wunsch",$.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance",$.SOKAL="Sokal",$.COSINE="Cosine",$.ASYMMETRIC="Asymmetric",$.Difference="Difference",$.OneHot="One-Hot",N.HAMMING,N.EUCLIDEAN,N.MANHATTAN,N.VECTOR_COSINE,N.TANIMOTO,N.LEVENSTEIN,N.NEEDLEMAN_WUNSCH,N.MONOMER_CHEMICAL_DISTANCE,N.SOKAL,N.COSINE,N.ASYMMETRIC,N.Difference,N.OneHot,N.HAMMING,N.EUCLIDEAN,N.MANHATTAN,N.TANIMOTO,N.SOKAL,N.COSINE,N.ASYMMETRIC,N.LEVENSTEIN,N.NEEDLEMAN_WUNSCH,N.MONOMER_CHEMICAL_DISTANCE,N.Difference,N.OneHot,N.VECTOR_COSINE,new Set([N.HAMMING,N.LEVENSTEIN,N.NEEDLEMAN_WUNSCH,N.MONOMER_CHEMICAL_DISTANCE,N.OneHot]),new Set([N.HAMMING,N.EUCLIDEAN,N.MANHATTAN,N.MONOMER_CHEMICAL_DISTANCE,N.LEVENSTEIN,N.NEEDLEMAN_WUNSCH,N.TANIMOTO,N.COSINE,N.VECTOR_COSINE,N.SOKAL,N.ASYMMETRIC,N.OneHot,N.Difference]),new Set([N.EUCLIDEAN,N.MANHATTAN,N.OneHot,N.Difference,N.VECTOR_COSINE]),new Set([N.EUCLIDEAN,N.MANHATTAN,N.Difference,N.VECTOR_COSINE]),new Set([N.EUCLIDEAN,N.MANHATTAN,N.Difference]),new Set([N.TANIMOTO,N.COSINE,N.SOKAL,N.ASYMMETRIC]),new c.Subject;var I,R,O,k,G,D=n(2003),H=(n(3516),n(6718),n(3077),n(439));(R=I||(I={})).IDENTITY="identity",R.SIMILARITY="similarity",n(5540),function(e){e.ADD="ADD",e.SUB="SUB",e.MULT="MULT"}(O||(O={})),function(e){e.SQUARE="SQUARE",e.INVERSE="INVERSE",e.TRANSPOSE="TRANSPOSE",e.NORM="NORM",e.COLUMN_NORM="COLUMN_NORM"}(k||(k={})),function(e){e.SCALARMULT="SCALARMULT",e.SCALARADD="SCALARADD",e.SCALARPOW="SCALARPOW"}(G||(G={})),Object.prototype.toString,n(6873);var F=n(4356),V=(n(6717),n(4870),n(3856),n(6882),n(7278),n(5553),n(6642)),U=n(3599);n(673),n(8312),V.sD,n(4139),new class{constructor(){this.seqHandler="seq-handler",this.notationProvider="seq-handler.notation-provider"}},a.SemanticValue,D.zS,a.GridCellRenderer,a.GridCellRenderer;var B,Y,W,j,K=n(8070),q=n(4326);!function(e){e.Unknown="unknown",e.FR="framework",e.CDR="cdr"}(B||(B={})),new class{constructor(){this.regionTypes=[B.CDR],this.chains=["Heavy","Light"],this.skipEmptyPositions=!1,this.fitWidth=!1,this.positionWidth=16,this.positionHeight=q.fH.Entropy,this.filterSource=q.Fo.filterSource}},n(7602),n(250),function(e){e.STYLE="Style",e.BEHAVIOR="Behavior",e.LAYOUT="Layout",e.DATA="Data"}(Y||(Y={})),function(e){e.skipEmptyPositions="skipEmptyPositions",e.regionTypes="regionTypes",e.chains="chains",e.fitWidth="fitWidth",e.positionWidth="positionWidth",e.positionHeight="positionHeight",e.filterSource="filterSource"}(W||(W={})),a.JsViewer,n(6863),n(4954),a.JsViewer,H.b9[H.Hi.FASTA],n(5433),n(3890),n(1687),function(e){e.TYPE="V2000",e[e.NUM_OF_HEADER_LINES=3]="NUM_OF_HEADER_LINES",e[e.NUM_OF_COUNTS_DIGITS=3]="NUM_OF_COUNTS_DIGITS",e[e.ATOM_TYPE_COL=4]="ATOM_TYPE_COL",e[e.FIRST_BONDED_ATOM_COL=1]="FIRST_BONDED_ATOM_COL",e[e.BOND_TYPE_COL=3]="BOND_TYPE_COL",e[e.RGP_SHIFT=8]="RGP_SHIFT",e[e.MAX_ATOM_COUNT=999]="MAX_ATOM_COUNT",e.RGP_LINE_START="M RGP",e.ATOM_ALIAS_LINE_START="A ",e.END="M END"}(j||(j={}));class z{constructor(e){this.init(e)}init(e){this.fileContent=e.replace(/\r/g,""),this._atomCount=void 0,this._atomTypes=void 0,this._bondCount=void 0,this._bondTypes=void 0,this.xyzAtomCoordinates=void 0,this._pairsOfBondedAtoms=void 0}get atomCount(){return void 0===this._atomCount&&this.setAtomAndBondCounts(),this._atomCount}get bondCount(){return void 0===this._bondCount&&this.setAtomAndBondCounts(),this._bondCount}get x(){var e;return null!==(e=this.xyzAtomCoordinates)&&void 0!==e||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.x}get y(){var e;return null!==(e=this.xyzAtomCoordinates)&&void 0!==e||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.y}get z(){var e;return null!==(e=this.xyzAtomCoordinates)&&void 0!==e||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.z}get atomTypes(){var e;return null!==(e=this._atomTypes)&&void 0!==e||(this._atomTypes=this.parseAtomTypes()),this._atomTypes}get pairsOfBondedAtoms(){var e;return null!==(e=this._pairsOfBondedAtoms)&&void 0!==e||(this._pairsOfBondedAtoms=this.parseBondedAtomPairs()),this._pairsOfBondedAtoms}get bondTypes(){var e;return null!==(e=this._bondTypes)&&void 0!==e||(this._bondTypes=this.parseBondTypes()),this._bondTypes}setAtomAndBondCounts(){const{atomCount:e,bondCount:t}=this.parseAtomAndBondCounts();this._atomCount=e,this._bondCount=t}getNextColumnIdx(e){for(;!this.isWhitespace(e);)++e;for(;this.isWhitespace(e);)++e;return e}shiftIdxToSpecifiedColumn(e,t){let n=e;const r=this.isWhitespace(n)?t:t-1;for(let e=0;e<r;e++)n=this.getNextColumnIdx(n);return n}parseAtomTypes(){const e=this.atomCount,t=new Array(e);let n=this.getAtomBlockIdx();for(let r=0;r<e;r++)n=this.shiftIdxToAtomType(n),t[r]=this.parseAtomType(n),n=this.getNextLineIdx(n);return t}parseAtomCoordinates(){const e=new Float32Array(this.atomCount),t=new Float32Array(this.atomCount),n=new Float32Array(this.atomCount);let r=this.getAtomBlockIdx();for(let o=0;o<this.atomCount;o++){r=this.shiftIdxToXColumn(r);for(const s of[e,t,n])s[o]=this.parseFloatValue(r),r=this.getNextColumnIdx(r);r=this.getNextLineIdx(r)}return{x:e,y:t,z:n}}parseBondedAtomPairs(){const e=new Array(this.bondCount);let t=this.getBondBlockIdx();for(let n=0;n<this.bondCount;n++){t=this.shiftIdxToBondedAtomsPair(t);const r=new Uint16Array(2);r[0]=this.parseIntValue(t),t=this.getNextColumnIdx(t),r[1]=this.parseIntValue(t),e[n]=r,t=this.getNextLineIdx(t)}return e}parseBondTypes(){const e=this.bondCount,t=new Uint16Array(e);let n=this.getBondBlockIdx();for(let r=0;r<e;r++)n=this.shiftIdxToBondType(n),t[r]=this.parseIntValue(n),n=this.getNextLineIdx(n);return t}isWhitespace(e){const t=this.fileContent[e];return" "===t||"\t"===t}getNextLineIdx(e){return"\n"!==this.fileContent[e]?this.fileContent.indexOf("\n",e)+1:e+1}parseFloatValue(e){return this.parseNumericValue(parseFloat,e)}parseIntValue(e){return this.parseNumericValue(parseInt,e)}parseNumericValue(e,t){let n=t+1;for(;!this.isWhitespace(n);)++n;return e(this.fileContent.substring(t,n))}}class Z extends z{constructor(e){super(e),this.init(e)}init(e){super.init(e)}parseAtomType(e){let t=e,n=t;return this.isQuote(t)?(n=this.getNextIdenticalChar(t),t++):n=this.fileContent.indexOf(" ",n),this.fileContent.substring(t,n)}isQuote(e){const t=this.fileContent[e].charCodeAt(0);return 39===t||34===t}getNextIdenticalChar(e){const t=this.fileContent[e];return t?this.fileContent.indexOf(t,e+1):-1}isQuery(){return this.isQueryOrFragment(((e,t)=>{return 39===e||34===e||76===e&&!((n=this.fileContent.charCodeAt(t+1))>64&&n<91||n>96&&n<123);var n}))}isFragment(){return this.isQueryOrFragment((e=>82===e||42===e))}isQueryOrFragment(e){const t=this.atomCount;let n=this.getAtomBlockIdx();for(let r=0;r<t;r++){if(n=this.shiftIdxToAtomType(n),e(this.fileContent.charCodeAt(n),n))return!0;n=this.getNextLineIdx(n)}return!1}}class X extends Z{constructor(e){super(e)}getAtomLines(){const e=this.getAtomBlockIdx(),t=this.getBondBlockIdx();return this.fileContent.substring(e,t).split("\n").slice(0,this.atomCount)}getBondLines(){const e=this.getBondBlockIdx();return this.fileContent.substring(e).split("\n").slice(0,this.bondCount)}getRGroupIdToAtomicIdxMap(){const e=new Map,t=this.fileContent.split("\n");t.filter((e=>e.startsWith(j.RGP_LINE_START))).forEach((t=>{const n=this.getAtomIdxToRgpIdxList(t);for(const[t,r]of n){if(e.has(t))throw new Error(`R group ${t} is already in the map`);e.set(t,r)}}));const n=t.map(((e,t)=>{if(e.startsWith(j.ATOM_ALIAS_LINE_START))return t})).filter((e=>void 0!==e)),r=n.map((e=>t[e])),o=n.map((e=>t[e+1]));r.forEach(((t,n)=>{const r=parseInt(t.split(/\s+/)[1])-1,s=parseInt(o[n].substring(1));if(e.has(s))throw new Error(`R group ${s} is already in the map`);e.set(s,r)}));const s=this.getRGroupAtomicIndices().filter((t=>!Array.from(e.values()).includes(t)));if(0!==s.length)throw new Error(`Unaccounted R group indices: ${s}`);return e}getAtomIdxToRgpIdxList(e){const t=e.split(/\s+/).filter((e=>e)).slice(3).map((e=>parseInt(e))),n=new Array(t.length/2);for(let e=0;e<t.length;e+=2)n[e/2]=[t[e+1],t[e]-1];return n}getRGroupAtomicIndices(){return this.atomTypes.map(((e,t)=>{if(e.includes("R#"))return t})).filter((e=>void 0!==e))}static isValidMolfile(e){return-1!==e.indexOf(j.TYPE)&&-1!==e.indexOf(j.END)}shiftIdxToAtomType(e){return this.shiftIdxToSpecifiedColumn(e,j.ATOM_TYPE_COL)}getCountsLineIdx(){let e=0;for(let t=0;t<j.NUM_OF_HEADER_LINES;++t)e=this.getNextLineIdx(e);return e}getAtomBlockIdx(){let e=this.getCountsLineIdx();return e=this.getNextLineIdx(e),e}shiftIdxToXColumn(e){return this.getNextColumnIdx(e)}shiftIdxToBondedAtomsPair(e){return this.shiftIdxToSpecifiedColumn(e,j.FIRST_BONDED_ATOM_COL)}shiftIdxToBondType(e){return this.shiftIdxToSpecifiedColumn(e,j.BOND_TYPE_COL)}getBondBlockIdx(){let e=this.getAtomBlockIdx();for(let t=0;t<this.atomCount;t++)e=this.getNextLineIdx(e);return e}parseAtomAndBondCounts(){let e=this.getCountsLineIdx(),t=e+j.NUM_OF_COUNTS_DIGITS;const n=parseInt(this.fileContent.substring(e,t));return e=t,t+=j.NUM_OF_COUNTS_DIGITS,{atomCount:n,bondCount:parseInt(this.fileContent.substring(e,t))}}}class Q extends Z{constructor(e){super(e),this.init(e)}getAtomLines(){const e=this.getAtomBlockIdx(),t=this.getBondBlockIdx();return this.fileContent.substring(e,t).split("\n").slice(0,this.atomCount)}getBondLines(){const e=this.getBondBlockIdx();return this.fileContent.substring(e).split("\n").slice(0,this.bondCount)}getRGroupIdToAtomicIdxMap(){const e=new Map;return this.getAtomLines().forEach(((t,n)=>{const r=t.match(/RGROUPS=\(([\d\s]+)\)/);if(r){const t=r[1].split(/\s+/).map((e=>parseInt(e)));if(t.length>2)throw new Error(`R group data ${t} has more than 2 elements`);const o=t[1];if(e.has(o))throw new Error(`R group ${o} is already in the map`);e.set(o,n)}})),e}shiftIdxToAtomType(e){return this.shiftIdxToSpecifiedColumn(e,4)}getCountsLineIdx(){return this.fileContent.indexOf("M V30 COUNTS ")}getAtomBlockIdx(){let e=this.fileContent.indexOf("M V30 BEGIN ATOM");return e=this.getNextLineIdx(e),e}shiftIdxToXColumn(e){let t=this.shiftIdxToAtomType(e);return this.isQuote(t)?(t=this.getNextIdenticalChar(t),t=this.getNextColumnIdx(t),t):this.shiftIdxToSpecifiedColumn(e,5)}shiftIdxToBondedAtomsPair(e){return this.shiftIdxToSpecifiedColumn(e,5)}shiftIdxToBondType(e){return this.shiftIdxToSpecifiedColumn(e,4)}getBondBlockIdx(){return this.getNextLineIdx(this.fileContent.indexOf("M V30 BEGIN BOND"))}static isValidMolfile(e){return-1!==e.indexOf("V3000")&&-1!==e.indexOf("M END")}parseAtomAndBondCounts(){let e=this.fileContent.indexOf("M V30 COUNTS ")+14,t=this.fileContent.indexOf(" ",e+1);const n=parseInt(this.fileContent.substring(e,t));return e=t+1,t=this.fileContent.indexOf(" ",e+1),{atomCount:n,bondCount:parseInt(this.fileContent.substring(e,t))}}}class J{constructor(){}static getInstance(e){if(J.isMolfileV2K(e))return new X(e);if(J.isMolfileV3K(e))return new Q(e);throw new Error("Malformed molfile")}static isMolfileV2K(e){return X.isValidMolfile(e)}static isMolfileV3K(e){return Q.isValidMolfile(e)}}var ee=n(6197),te=n(9124),ne=n(3527),re=n(3629);class oe{biotype;id;n;m;type;mt;smiles;get issmiles(){return!!this.smiles}at={R1:"H",R2:"H",R3:"H",R4:"H",R5:"H",R6:"H",R7:"H",R8:"H",R9:"H"};get rs(){return Object.keys(this.at).length}constructor(e,t,n="missing",r=void 0,o=void 0,s=void 0,i){if(this.biotype=e,this.id=t,this.n=n,this.m=r,this.type=o,this.mt=s,this.smiles=i,!this.id)throw new Error("Invalid arg undefined [id].")}static objCounter=-1;objId=++oe.objCounter;className="WebEditorMonomerDummy";toLog(){return`Helm: ${this.className}<${this.objId}>`}}class se extends oe{backgroundcolor="#FFFFFF";linecolor="#808080";textcolor="#808080";constructor(e){super(e,"*","gap")}}class ie extends oe{backgroundcolor="#808080";linecolor="#000000";textcolor="#000000";constructor(e,t){super(e,t,"ambiguous")}}class ae extends oe{backgroundcolor="#FF4444";linecolor="#800000";textcolor="#FFFFFF";constructor(e,t,n){super(e,t,"missing"),n&&(this.backgroundcolor="#C0C0C0",this.linecolor="#404040",this.textcolor="#404040")}}class ce extends oe{backgroundcolor="#FFFF44";linecolor="#800000";textcolor="#000000";constructor(e,t){super(e,t,"broken")}}class le{id;m;n;na;type;mt;at;smiles;get rs(){return Object.keys(this.at).length}get issmiles(){return!!this.smiles}linecolor;backgroundcolor;textcolor;constructor(e,t,n,r,o,s,i,a){this.id=e,this.m=t,this.n=n,this.na=r,this.type=o,this.mt=s,this.at=i,this.smiles=a}static fromMonomer(e,t,n){let r={};const o=t.symbol,s=t.smiles;if(t.rgroups.length>0)t.rgroups.forEach((e=>{r[e.label]=e.capGroupName}));else{if(!s){if(t.lib)return new ce(e,o);throw new Error("Unexpected missing monomer without .lib")}r=n.getRS(s)}const i=new le(t.symbol,t.molfile,t.name,t.naturalAnalog,t.polymerType,t.monomerType,r),a=n.getMonomerColors(e,t.symbol);return a&&(i.textcolor=a?.textcolor,i.linecolor=a?.linecolor,i.backgroundcolor=a?.backgroundcolor),i}}const ue={[U.o.BASE]:{A:"#20E040",G:"#040404",T:"#FF8080",C:"#2060FF",U:"#FF8080"},[U.o.NUCLEOTIDE]:{A:"#20E040",G:"#040404",T:"#FF8080",C:"#2060FF",U:"#FF8080"},[U.o.LINKER]:{P:"#9aa5e1",p:"#9aa5e1"},[U.o.SUGAR]:{R:"#7a85c1",r:"#7a85c1"},[U.o.AA]:{A:"rgb(44,160,44)",R:"rgb(23,190,207)",N:"rgb(235,137,70)",D:"rgb(31,119,180)",C:"rgb(188,189,34)",E:"rgb(31, 120, 150)",Q:"rgb(205, 111, 71)",G:"rgb(214,39,40)",H:"rgb(158,218,229)",I:"rgb(23,103,57)",L:"rgb(30,110,96)",K:"rgb(108, 218, 229)",M:"rgb(60,131,95)",F:"rgb(24,110,79)",P:"rgb(255,152,150)",S:"rgb(255,187,120)",T:"rgb(245,167,100)",W:"rgb(182, 223, 138)",Y:"rgb(152,223,138)",V:"rgb(74,160,74)"},[U.o.CHEM]:{R:"#eeeeee"},[U.o.BLOB]:{B:"#999999",G:"#e2e2e2"}},de=/[\w()]+/,he=RegExp(String.raw`\(${de}(,${de})+\)`),pe=e=>{const t=i.canvas(250,250);return s.chem.canvasMol(0,0,250,250,t,e),t},me=new ne.Mi([255,255,255]),fe=new ne.Mi([0,0,0]),ge=.7*(0,re.wQ)(me);class ye{_monomers;source;_isEmpty;get isEmpty(){return this._isEmpty}_onChanged=new c.Subject;get onChanged(){return this._onChanged}constructor(e,t){this._monomers=e,this.source=t,this._isEmpty=!this._monomers||0===Object.keys(this._monomers).length||Object.entries(this._monomers).every((([e,t])=>0===Object.keys(t).length));for(const[e,t]of Object.entries(this._monomers))for(const[e,n]of Object.entries(t))n.lib=this}getMonomerSymbolsByType(e){return Object.keys(this._monomers[e])}addMissingMonomer(e,t){let n=this._monomers[e];n||(n=this._monomers[e]={});let r=t;return t==H._S||t===H.b9[H.Hi.HELM]?r="Gap":("PEPTIDE"===e&&"X"===t||"RNA"===e&&"N"===t)&&(r="Any"),n[t]={symbol:t,name:r,molfile:"",author:"MISSING",id:-1,rgroups:T().count(1).take(9).map((e=>({capGroupSmiles:"",alternateId:"",capGroupName:"",label:`R${e.toString()}`}))).toArray(),smiles:"",polymerType:e,monomerType:void 0,createDate:null}}getMonomer(e,t){let n=t;"RNA"==e&&"R"==n&&(n="r"),"RNA"==e&&"P"==n&&(n="p");let r=null;if(e){const t=this._monomers[e];r=t?t[n]:null}else{je.logger.warning(`Bio: MonomerLib.getMonomer() symbol '${t}', polymerType not specified.`);for(const[e,t]of Object.entries(this._monomers))if(r=t[n],r)break}return r}getWebEditorMonomer(e,t){const[n,r]=(0,te.fA)(e,t),o=(0,ee.Y)(n);let s=this.getMonomer(o,r);if(s&&n==U.o.LINKER&&2!=s.rgroups.length)return null;if(s&&n==U.o.SUGAR&&3!=s.rgroups.length)return null;s||(s=this.addMissingMonomer(o,r));let i=s.wem??null;return i||(r===H._S||"*"==r?i=s.wem=new se(n):n===U.o.NUCLEOTIDE&&"N"===r||n===U.o.AA&&"X"===r||(U.o.CHEM,0)||he.test(r)?i=s.wem=new ie(n,r):s.lib||(i=s.wem=new ae(n,r,this.isEmpty)),i||(i=s.wem=le.fromMonomer(n,s,this))),i}getTooltip(e,t){const n=(0,ee.Y)(e),r=i.div([],{classes:"ui-form ui-tooltip"}),o=this.getWebEditorMonomer(e,t),s=this.getMonomer(n,t);if(s){const e=s.symbol,[t,n,a]=(s.name,o?[o.textcolor,o.backgroundcolor,o.linecolor]:["#202020","#A0A0A0","#202020"]);let c;if(r.append(i.divH([i.div([e],{style:{textWrap:"nowrap",marginLeft:"4px",marginRight:"4px",color:t,backgroundColor:n,borderColor:a,borderWidth:"1px",borderStyle:"solid",borderRadius:"2px",padding:"3px",minWidth:"24px",textAlign:"center"}}),i.div([s.name],{style:{padding:"4px"}})],{style:{display:"flex",flexDirection:"row",justifyContent:"left"}})),c=s.molfile?pe(s.molfile):s.smiles?i.divV([pe(s.smiles),i.divText("from smiles",{style:{fontSize:"smaller"}})]):i.divText("No structure",{style:{margin:"6px"}}),r.append(i.div(c,{style:{display:"flex",flexDirection:"row",justifyContent:"center",margin:"6px"}})),s.symbol!=H._S){let e=s.lib?.source;e?(e.endsWith(".json")&&(e=e.substring(0,e.length-5)),e=e.replace(/_/g," ").replace(/-/g," ").replace(/([a-z])([a-z])([A-Z])/g,"$1$2 $3"),r.append(i.divText(e))):r.append(i.divText("Missed in libraries"))}}else r.append(i.divV([i.divText(`Monomer '${t}' of type '${n}' not found.`),i.divText("Open the Context Panel, then expand Manage Libraries")]));return r}getMonomerTextColor(e,t){const n=this.getMonomerColors(e,t),r=e=>{const t=/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/.exec(e);if(t)return[parseInt(t[1]),parseInt(t[2]),parseInt(t[3])];const n=a.Color.fromHtml(e);return[a.Color.r(n),a.Color.g(n),a.Color.b(n)]},o=r(n.textcolor),s=new ne.Mi([...o.map((e=>e+1))]),i=(0,re.KE)(s,me)/((0,re.wQ)(s)*(0,re.wQ)(me)),c=r(n.backgroundcolor),l=new ne.Mi([...c.map((e=>e+.01))]);let u;u=(0,re.KE)(l,me)/((0,re.wQ)(l)*(0,re.wQ)(me))<i?c:o;let d=new ne.Mi(u);const h=(0,re.wQ)(d);return h>ge&&(d=(0,re.dC)(fe,d,ge/h)),`rgb(${d[0]}, ${d[1]}, ${d[2]})`}getMonomerColors(e,t){const n="default";let r=n;const o=(0,ee.Y)(e),s=this.getMonomer(o,t);let i;if(s){if(s.meta&&s.meta.colors){const e=s.meta.colors;n in e||(r="default"),i=e[r]}if(!i){const t=ue[e],n=t?.[s.symbol];n&&(i={textColor:a.Color.toHtml(a.Color.getContrastColor(a.Color.fromHtml(n))),lineColor:"#202020",backgroundColor:n})}const t=s.naturalAnalog;if(!i&&t)return this.getMonomerColors(e,t)}return i||(i={textColor:"#202020",lineColor:"#202020",backgroundColor:"#A0A0A0"}),{textcolor:i.text??i.textColor,linecolor:i.line??i.lineColor,backgroundcolor:i.background??i.backgroundColor}}getRS(e){const t=e.match(/(?<=\[)[^\][]*(?=])/gm),n={};let r,o="";if(t)for(let e=0;e<t.length;e++)if(null!=t[e]&&/\d/.test(t[e])){r=t[e][t[e].length-1],t[e]=t[e].replace(/[0-9]/g,"");for(let n=0;n<t[e].length;n++)":"!=t[e][n]&&(o+=t[e][n]);n["R"+r]=o,o=""}return n}}var be=n(5488),we={};we.styleTagTransform=v(),we.setAttributes=g(),we.insert=m().bind(null,"head"),we.domAPI=h(),we.insertStyleElement=b(),u()(be.A,we),be.A&&be.A.locals&&be.A.locals;class ve extends ye{error;_duplicateMonomers={};get duplicateMonomers(){return this._duplicateMonomers}_duplicatesHandled=!0;get duplicatesHandled(){return this._duplicatesHandled}duplicatesNotified=!1;constructor(e,t,n=void 0){super(e,t),this.error=n}toJSON(){const e=[];for(const t of Object.values(this._monomers))for(const n of Object.values(t))e.push({...n,lib:void 0,wem:void 0});return e}getMonomer(e,t){let n=t;"RNA"==e&&"R"==n&&(n="r"),"RNA"==e&&"P"==n&&(n="p");let r=null;if(e){const t=this._monomers[e];r=t?.[n]??null}else{je.logger.warning(`Bio: MonomerLib.getMonomer() symbol '${t}', polymerType not specified.`);for(const[e,t]of Object.entries(this._monomers))if(r=t[n],r)break}return r}_monomerSets=null;getMonomerSet(e){const t=(0,ee.Y)(e);if(this._monomerSets||(this._monomerSets={}),!(e in this._monomerSets))for(const[e,n]of Object.entries(this._monomers[t]));return this._monomerSets[e]}getPolymerTypes(){return Object.keys(this._monomers)}getMonomerMolsByPolymerType(e){const t={};return Object.keys(this._monomers[e]??{}).forEach((n=>{t[n]=this._monomers[e][n].molfile})),t}getMonomerSymbolsByRGroup(e,t,n){let r=this.getMonomerSymbolsByType(t).map((e=>this.getMonomer(t,e)));return r=r.filter((e=>null!==e)),0===r.length?[]:(r=r.filter((t=>{if(!t?.rgroups)return!1;let n=t?.rgroups.length>=e;var r;return r=J.getInstance(t.molfile).atomTypes,r.map(((e,t)=>"R#"===e?t:-1)).filter((e=>-1!==e)),n&&=!0,n})),r.map((e=>e?.symbol)))}_updateLibInt(e){const t=e.getPolymerTypes(),n=this.getPolymerTypes();t.forEach((t=>{n.includes(t)||(this._monomers[t]={}),e.getMonomerSymbolsByType(t).forEach((n=>{this._monomers[t][n]&&(this._duplicateMonomers[t]??={},this._duplicateMonomers[t][n]??=[this._monomers[t][n]],this._duplicateMonomers[t][n].push(e.getMonomer(t,n))),this._monomers[t][n]=e.getMonomer(t,n)}))})),this._isEmpty=this.isEmpty&&e.isEmpty}updateLibs(e,t=!1){t&&(this._monomers={},this._isEmpty=!0),this._duplicateMonomers={};for(const t of e)t.error||this._updateLibInt(t);Object.entries(this.duplicateMonomers).length>0?(0,F.ub)().then((e=>{this.assignDuplicatePreferences(e)})):this._duplicatesHandled=!0,this._onChanged.next()}assignDuplicatePreferences(e){let t=!0;for(const n in this.duplicateMonomers)for(const r in this.duplicateMonomers[n])if(e.duplicateMonomerPreferences?.[n]?.[r]){const o=e.duplicateMonomerPreferences[n][r],s=this.duplicateMonomers[n][r].find((e=>e.lib?.source===o));s?this._monomers[n][r]=s:t=!1}else t=!1;return this._duplicatesHandled=t,t}clear(){this._monomers={},this._onChanged.next()}getSummaryObj(){const e={},t=this.getPolymerTypes();for(const n of t)e[n]=this.getMonomerSymbolsByType(n).length;return e}getSummaryDf(){const e=this.getPolymerTypes(),t=new Array(e.length);for(const[n,r]of T().enumerate(e))t[r]=this.getMonomerSymbolsByType(n).length;return a.DataFrame.fromColumns([a.Column.fromStrings("polymerType",e),a.Column.fromList(a.COLUMN_TYPE.INT,"count",t)])}getSummary(){const e=this.getPolymerTypes();return 0==e.length?"empty":e.map((e=>`${e} ${this.getMonomerSymbolsByType(e).length}`)).join("\n")}static overrideCounter=0;override(e,t){return new Ae(e,`override: ${++ve.overrideCounter}, ${t}`,this)}}class Ae extends ye{data;base;constructor(e,t,n){super(e,t),this.data=e,this.base=n}get onChanged(){return this.base.onChanged}getMonomerSymbolsByType(e){const t=this.base.getMonomerSymbolsByType(e);for(const n of Object.keys(this.data[e]??{}))t.includes(n)||t.push(n);return t}addMissingMonomer(e,t){return this.base.addMissingMonomer(e,t)}getMonomer(e,t){const n=this.data[e]?.[t];return n??this.base.getMonomer(e,t)}}var Ee=n(9192);class Ce{monomerLib;symbol;polymerType;monomerType;monomerLinks;monomers;error=null;constructor(e,t,n,r,o){this.monomerLib=e,this.symbol=t,this.polymerType=n,this.monomerType=r,this.monomerLinks=o;try{this.monomers=this.monomerLinks.map((e=>{const n=this.monomerLib.getMonomer(this.polymerType,e.symbol);if(!n)throw new Error("Monomer not found: ");if(n.lib?.source!=e.source)throw new Error(`Monomer '${t}' found in different library.`);return n}))}catch(e){const[t,n]=(0,Ee.AP)(e);this.error=t,this.monomers=[]}}}class Te{description;placeholders;source;error;constructor(e,t,n=void 0,r=void 0){this.description=e,this.placeholders=t,this.source=n,this.error=r}updateSets(e,t=!1){t&&(this.placeholders=[]);for(const t of e)t.error||this._updateSetInt(t)}_updateSetInt(e){for(const t of e.placeholders)this.placeholders.push(t)}}var Se=n(7433),_e=n.n(Se),Pe=n(1913),Me=n.n(Pe);class xe{helmMonomerSchema;validateMonomerSchema;constructor(e){this.helmMonomerSchema=e;const t=new(_e())({allErrors:!0,strictTuples:!1,allowUnionTypes:!0});Me()(t),this.validateMonomerSchema=t.compile(this.helmMonomerSchema)}validateFile(e,t){const n=this.parseJson(e,t);return null!==n&&(Array.isArray(n)?this.validateJsonContent(n,t):(console.warn(`Bio: Monomer Library File Validator file '${t}': Invalid JSON format: The file must contain an array of monomers.`),!1))}parseJson(e,t){try{return JSON.parse(e)}catch(e){return console.error(`Bio: Monomer Library File Validator file '${t}': Invalid JSON format:`,e),null}}validateJsonContent(e,t){let n=!0;const r=new Set;for(const o of e){const e=o.symbol??o.id??o.name??"#N/A";if(n=this.validateMonomerSchema(o),!n){console.warn(`Bio: Monomer Library File Validator file ${t}, monomer '${e}' violating JSON schema:`,o,"\nError reason: ",JSON.stringify(this.validateMonomerSchema.errors??{}),`\nThere may be other errors in ${t} since the validation is stopped after the first error.`," Please, verify that the monomer library file satisfies the JSON schema");break}const s=`${o.polymerType??""}-${e}`;r.has(s)&&console.warn(`Bio: Monomer Library File Validator file ${t}, monomer '${e}' is duplicated.`,"Please, verify that the monomer library file does not contain duplicated monomer symbols."),r.add(s)}return n}}var Ne=n(8604);class $e{fileValidator;libHelper;eventManager;logger;filesPromise=Promise.resolve();initializedPromise=Promise.resolve();constructor(e,t,n,r){let o;this.fileValidator=e,this.libHelper=t,this.eventManager=n,this.logger=r;let s=!1;this.initializedPromise=Promise.race([a.delay(1e3),new Promise((e=>o=e))]),this.eventManager.updateValidLibraryFileListRequested$.subscribe((()=>{this.updateValidLibList().then((()=>{})),s||(s=!0,o())})),this.eventManager.updateValidSetFileListRequested$.subscribe((()=>{this.updateValidSetList().then((()=>{}))}))}static objCounter=-1;objId=++$e.objCounter;toLog(){return`MonomerLibFileManager<${this.objId}>`}static async create(e,t,n){const r=await s.dapi.files.readAsText(Ne.gt),o=JSON.parse(r),i=new xe(o);return new $e(i,e,t,n)}async addLibraryFile(e,t,n=!0){try{if(await s.dapi.files.exists(Ne.so+`${t}`))return void s.shell.error(`File ${t} already exists`);await this.validateAgainstHELM(e,t),await s.dapi.files.writeAsText(Ne.so+`${t}`,e),await this.updateValidLibList(),await s.dapi.files.exists(Ne.so+`${t}`)?s.shell.info(`Added ${t} HELM library`):s.shell.error(`Failed to add ${t} library`)}catch(e){console.error(e),s.shell.error(`Failed to add ${t} library`)}}async deleteLibraryFile(e){try{await s.dapi.files.delete(Ne.so+`${e}`),await this.updateValidLibList(),s.shell.info(`Deleted ${e} library`)}catch(t){console.error(t),await s.dapi.files.exists(Ne.so+`${e}`)?s.shell.error(`Failed to delete ${e} library`):s.shell.warning(`File ${e} already deleted, refresh the list`)}}async loadLibraryFromFile(e,t){let n=[];const r=new a.FileSource(e),o=await r.readAsText(t);n=JSON.parse(o);const s={},i=[];return n.forEach((e=>{const t=e.polymerType,n=e.symbol;i.includes(t)||(s[t]={},i.push(t)),s[t][n]=e})),new ve(s,t)}async loadSetFromFile(e,t,n){let r={};const o=new a.FileSource(t),s=await o.readAsText(n);r=JSON.parse(s);const i=r.description,c=Object.entries(r.placeholders).map((([t,n])=>{const r=t,o=n.polymerType,s=n.monomerType,i=n.set;return new Ce(e,r,o,s,i)}));return new Te(i,c)}getValidLibraryPaths(){return this.eventManager.getValidLibPathList()}getValidSetPaths(){return this.eventManager.getValidSetPathList()}async getValidLibraryPathsAsynchronously(){return await this.eventManager.getValidLibraryPathsAsynchronously()}async updateValidLibList(){const e=`${this.toLog()}.updateValidLibList()`;return this.logger.debug(`${e}, start`),this.filesPromise=this.filesPromise.then((async()=>{this.logger.debug(`${e}, IN`);const t=[],n=await this.getLibFileListAtLocation();if(!this.libListHasChanged(n))return void this.logger.debug(`${e}, end, not changed`);for(const e of n){if(!e.endsWith(".json")){t.push(e);continue}const n=await s.dapi.files.readAsText(Ne.so+`${e}`);this.isValidHELMLibrary(n,e)||t.push(e)}const r=n.filter((e=>!t.includes(e)));if(this.libListHasChanged(r)&&(this.eventManager.changeValidLibPathList(r),await this.libHelper.loadMonomerLib(!0)),r.some((e=>!e.endsWith(".json")))&&this.logger.warning(`Wrong validation: ${r}`),t.length>0){const e=`Invalid monomer library files in ${Ne.so}, consider fixing or removing them: ${t.join(", ")}`;this.logger.warning(e)}this.logger.debug(`${e}, OUT`)})),this.logger.debug(`${e}, end`),this.filesPromise}async updateValidSetList(){const e=`${this.toLog()}.updateValidSetList()`;return je.logger.debug(`${e}, start`),this.filesPromise=this.filesPromise.then((async()=>{je.logger.debug(`${e}, IN`);const t=[],n=await this.getSetFileListAtLocation();if(!this.setListHasChanged(n))return void je.logger.debug(`${e}, end, not changed`);for(const e of n)e.endsWith(".json")?await s.dapi.files.readAsText(Ne.Es+`${e}`):t.push(e);const r=n.filter((e=>!t.includes(e)));this.setListHasChanged(r)&&(this.eventManager.changeValidSetPathList(r),this.libHelper.loadMonomerSets(!0)),je.logger.debug(`${e}, OUT`)})),je.logger.debug(`${e}, end`),this.filesPromise}libListHasChanged(e){const t=this.eventManager.getValidLibPathList();return e.length!==t.length||e.some(((e,n)=>e!==t[n]))}setListHasChanged(e){const t=this.eventManager.getValidSetPathList();return e.length!==t.length||e.some(((e,n)=>e!==t[n]))}async validateAgainstHELM(e,t){if(!this.isValidHELMLibrary(e,t))throw new Error(`File ${t} does not satisfy HELM standard`)}isValidHELMLibrary(e,t){return this.fileValidator.validateFile(e,t)}async getLibFileListAtLocation(){const e=`${this.toLog()}.getLibFileListAtLocation()`;this.logger.debug(`${e}, start`);const t=await s.dapi.files.list(Ne.so).then((e=>e.filter((e=>e.isFile)).map((e=>e.fullPath)))),n=[];return n.push(...t),n.map((e=>e.substring(Ne.so.length)))}async getSetFileListAtLocation(){const e=`${this.toLog()}.getSetFileListAtLocation()`;this.logger.debug(`${e}, start`);const t=await s.dapi.files.list(Ne.Es).then((e=>e.map((e=>e.fullPath)))),n=[];return n.push(...t),n.map((e=>e.substring(Ne.Es.length)))}}class Le{constructor(){}static _instance;static getInstance(){return Le._instance||(Le._instance=new Le),Le._instance}_libFilesUpdateSubject$=new c.BehaviorSubject([]);_setFilesUpdateSubject$=new c.BehaviorSubject([]);_addLibraryFilesSubject$=new c.Subject;_librarySelectionSubject$=new c.Subject;getValidLibPathList(){return this._libFilesUpdateSubject$.getValue()}getValidSetPathList(){return this._setFilesUpdateSubject$.getValue()}async getValidLibraryPathsAsynchronously(){return new Promise((e=>{const t=this._libFilesUpdateSubject$.pipe((0,S.skip)(1)).subscribe((n=>{e(n),t.unsubscribe()}))}))}changeValidLibPathList(e){this._libFilesUpdateSubject$.next(e)}changeValidSetPathList(e){this._setFilesUpdateSubject$.next(e)}get updateUIControlsRequested$(){return this._libFilesUpdateSubject$.pipe()}get updateValidLibraryFileListRequested$(){return this._libFilesUpdateSubject$.pipe()}get updateValidSetFileListRequested$(){return this._setFilesUpdateSubject$.pipe()}get addLibraryFileRequested$(){return this._addLibraryFilesSubject$.pipe()}addLibraryFile(){this._addLibraryFilesSubject$.next()}get librarySelectionRequested$(){return this._librarySelectionSubject$}updateLibrarySelectionStatus(e,t){this._librarySelectionSubject$.next([e,t])}}class Ie{logger;_monomerLib=new ve({},"MAIN");_monomerSets=new Te("MAIN",[]);_initialLoadCompleted=!1;get initialLoadCompleted(){return this._initialLoadCompleted}_eventManager;get eventManager(){return this._eventManager}async awaitLoaded(e=1/0){return e=e===1/0?6e4:e,await Promise.race([(async()=>{const e=await this.getFileManager();return await e.filesPromise,!0})(),(async()=>(await(0,K.cb)(e),!1))()]).then((t=>{if(!t)throw new Error(`Loading monomer libraries timeout ${e} ms.`)}))}constructor(e){this.logger=e}static objCounter=-1;objId=(()=>{if(++Ie.objCounter>0)throw new Error("MonomerLibManager MUST be a singleton.");return Ie.objCounter})();toLog(){return`MonomerLibManager<${this.objId}>`}getMonomerLib(){return this._monomerLib}getBioLib(){return this.getMonomerLib()}getMonomerSets(){return this._monomerSets}get duplicateMonomers(){return this._monomerLib.duplicateMonomers}get duplicatesHandled(){return this._monomerLib.duplicatesHandled}assignDuplicatePreferances(e){this._monomerLib.assignDuplicatePreferences(e)}_fileManagerPromise;async getFileManager(){return void 0===this._fileManagerPromise&&(this._fileManagerPromise=(async()=>{const e=await $e.create(this,this._eventManager,this.logger);return await e.initializedPromise,e})()),this._fileManagerPromise}loadLibrariesPromise=Promise.resolve();async loadMonomerLib(e=!1){const t=`${this.toLog()}.loadMonomerLib()`;return this.logger.debug(`${t}, start`),this.loadLibrariesPromise=this.loadLibrariesPromise.then((async()=>{this.logger.debug(`${t}, IN`);const n=a.TaskBarProgressIndicator.create("Loading monomers ...");try{const[[t],r]=await Promise.all([await this.getFileManager().then((e=>[e.getValidLibraryPaths()])),(0,F.ub)()]),o=t.filter((e=>{const t=!r.exclude.includes(e),n=0===r.explicit.length||r.explicit.includes(e);return t&&n}));let s=0;const i=o.length,[a]=await Promise.all([Promise.all(o.map((e=>this.readLibrary(Ne.so,e).catch((t=>{const n=`Loading monomers from '${e}' error: ${t instanceof Error?t.message:t.toString()}`;return new ve({},e,n)})).finally((()=>{n.update(Math.round(100*++s/i),`Loading monomers ${s}/${i}`)})))))]);this._monomerLib.updateLibs(a,e),this._initialLoadCompleted=!0}catch(e){const t=`Loading monomer libraries error: ${e instanceof Error?e.message:e.toString()}`;s.shell.warning(t);const n=e instanceof Error?e.stack:void 0;this.logger.error(t,void 0,n)}finally{n.close(),this.logger.debug(`${t}, OUT`)}})),this.logger.debug(`${t}, end`),this.loadLibrariesPromise}async loadLibraries(e){return this.loadMonomerLib(e)}loadSetsPromise=Promise.resolve();async loadMonomerSets(e=!1){const t=`${this.toLog()}.loadMonomerSets()`;return this.logger.debug(`${t}, start`),this.loadSetsPromise=this.loadSetsPromise.then((async()=>{this.logger.debug(`${t}, IN`);const e=a.TaskBarProgressIndicator.create("Loading monomer sets ...");try{const[[t]]=await Promise.all([await this.getFileManager().then((e=>[e.getValidSetPaths()]))]),n=t.filter((e=>!0));let r=0;const o=n.length,[s]=await Promise.all([Promise.all(n.map((t=>this.readSet(Ne.Es,t).catch((e=>{const n=`Loading monomer sets from '${t}' error: ${e instanceof Error?e.message:e.toString()}`;return new Te("Broken monomer set",[],t,n)})).finally((()=>{e.update(Math.round(100*++r/o),`Loading monomers ${r}/${o}`)})))))]);this._monomerSets.updateSets(s)}catch(e){const t=`Loading monomer sets error: ${e instanceof Error?e.message:e.toString()}`;s.shell.warning(t);const n=e instanceof Error?e.stack:void 0;this.logger.error(t,void 0,n)}finally{e.close(),this.logger.debug(`${t}, OUT`)}})),this.logger.debug(`${t}, end`),this.loadSetsPromise}async readLibrary(e,t){const n=await this.getFileManager();return await n.loadLibraryFromFile(e,t)}async readSet(e,t){const n=await this.getFileManager();return await n.loadSetFromFile(this._monomerLib,e,t)}async selectSpecifiedLibraries(e){const t=await this.getInvalidFileNames(e);if(t.length>0)throw new Error(`Cannot select libraries ${t}: no such library in the list`);const n=await(0,F.ub)();n.exclude=(await this.getFileManager()).getValidLibraryPaths().filter((t=>!e.includes(t))),await(0,F.Eu)(n)}async getInvalidFileNames(e){const t=(await this.getFileManager()).getValidLibraryPaths();return e.filter((e=>!t.includes(e)))}async loadMonomerLibForTests(){await(0,F.Eu)(Ne.G3),await this.awaitLoaded(1e4),await this.loadMonomerLib(!0)}static async getInstance(){let e=window.$monomerLibHelperPromise;return null==e&&(e=window.$monomerLibHelperPromise=(async()=>{const e=new Ie(je.logger);return e._eventManager=Le.getInstance(),e})()),e}}n(1757);var Re=n(3017),Oe={};Oe.styleTagTransform=v(),Oe.setAttributes=g(),Oe.insert=m().bind(null,"head"),Oe.domAPI=h(),Oe.insertStyleElement=b(),u()(Re.A,Oe),Re.A&&Re.A.locals&&Re.A.locals,n(3151);new L.A(new Uint32Array([2,0,0,0,16,0,0,0,134217728,0,0,0,32,0,33554432,0,0,0,0,0,1024,0,0,0,262144,128,0,0,0,0,0,0,0,2,0,0,524288,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1048576,0,536870912,0,0,0,0]),2048),new L.A(new Uint32Array([2,0,65536,0,0,0,0,32,0,0,2,0,32,0,0,0,0,0,0,0,1024,0,0,0,262144,128,0,0,0,0,0,0,0,65536,0,0,524288,0,0,0,0,0,0,0,524288,524288,0,0,0,0,0,0,0,0,0,0,0,34603008,0,536870912,64,0,0,0]),2048),new L.A(new Uint32Array([2,0,65600,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,1024,0,0,0,262400,128,0,0,0,0,0,0,0,0,0,2097152,524288,0,0,0,1024,0,0,0,524288,0,0,0,0,0,0,0,0,0,512,0,0,34603008,0,536870912,0,0,0,0]),2048),new L.A(new Uint32Array([2,0,65536,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,1024,0,0,8,262144,128,0,0,16,134217728,0,0,0,0,0,0,524288,0,0,0,128,0,0,0,524288,0,0,0,268435456,0,0,0,0,0,512,2147483648,0,34603008,0,536870912,0,0,0,0]),2048),new L.A(new Uint32Array([2,0,98304,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,1024,0,0,0,262144,128,33554432,0,0,0,0,33554432,0,1024,1,0,524288,32768,32,0,0,0,0,16,524288,0,0,0,0,0,0,0,0,0,71303168,0,0,34603008,131072,536870912,0,0,0,0]),2048),new L.A(new Uint32Array([134217728,0,65536,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,1024,0,0,0,0,128,0,0,0,0,2097216,0,0,0,0,0,524288,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,512,0,0,0,0,536870912,0,0,0,0]),2048),new L.A(new Uint32Array([2,0,1073840128,0,0,0,0,0,0,0,0,67108864,32,0,0,0,0,0,0,0,1024,0,512,0,262144,192,0,268435456,0,0,8200,0,0,0,67108864,0,524296,0,32,0,0,0,0,16,524288,0,0,2147483648,0,0,8,0,0,0,0,0,0,34603008,131072,536870920,4194304,0,0,0]),2048),new L.A(new Uint32Array([2,0,65536,0,0,0,0,0,150994944,64,0,0,32,0,0,0,0,0,0,0,1024,0,8388608,0,327680,128,0,0,0,0,0,0,0,2,0,524288,524288,0,0,0,0,0,0,0,0,0,0,0,256,0,0,0,0,8388608,0,33554432,0,1048576,0,536870912,0,0,0,0]),2048),new L.A(new Uint32Array([2,0,65536,0,0,0,0,0,0,0,0,0,268435488,0,0,0,0,0,0,0,1024,0,0,8,262144,128,0,0,0,0,2097152,0,0,67108864,0,0,524288,0,0,0,8,0,0,0,524288,0,0,8192,0,0,0,0,0,0,0,2147483648,0,34668544,0,545259520,0,0,0,0]),2048),new L.A(new Uint32Array([2,0,65536,0,0,0,0,0,134217728,0,0,0,32,512,0,0,0,0,0,0,1024,256,0,8388608,262400,128,0,0,0,0,0,0,0,2,0,0,524288,0,0,0,0,0,0,0,524288,0,0,0,0,0,0,0,0,0,0,0,0,42991616,0,536870912,0,0,0,0]),2048),new L.A(new Uint32Array([2050,0,65536,1048576,0,0,0,0,0,0,0,0,1056,0,0,0,0,0,0,0,1024,0,0,8,262144,128,0,0,0,0,0,536870912,0,2,0,0,1074266112,0,0,0,0,0,0,0,524288,0,0,0,4194304,0,0,0,0,0,0,2147483648,0,34603008,0,536870912,4194304,0,0,0]),2048),new L.A(new Uint32Array([2,0,65536,0,4096,0,0,0,0,0,0,16777216,32,0,0,0,0,0,0,0,1024,0,0,0,262400,128,0,0,0,0,0,0,0,0,0,0,524288,0,0,0,1024,0,0,0,524288,0,0,0,0,0,0,0,0,0,0,0,0,34603008,0,536871936,67108864,0,0,0]),2048),new L.A(new Uint32Array([0,0,1024,0,0,0,0,0,0,131072,0,1024,32,0,0,0,0,512,0,0,1024,0,0,64,0,128,0,0,1073741824,0,0,138412032,16,0,67108864,0,0,0,0,0,0,8192,0,0,8388608,0,0,8,0,0,0,0,0,0,256,0,0,0,0,553648128,0,0,0,0]),2048),new L.A(new Uint32Array([2,0,65536,0,4096,0,0,0,0,0,0,0,32,0,0,0,0,2,0,0,1024,0,0,8,262144,128,0,0,16,0,0,0,0,0,0,0,524288,0,0,0,0,0,0,0,524288,0,0,0,268435456,0,0,0,0,0,16777216,2147483648,0,34603008,0,536871936,0,0,0,0]),2048),new L.A(new Uint32Array([2,0,65536,0,4096,0,32,0,0,0,0,0,268435488,0,0,0,0,0,0,32768,134218752,0,16,8,262144,128,0,1073741824,0,0,8388608,0,0,0,65536,0,524289,0,0,0,0,0,0,0,524288,2048,0,0,0,0,0,0,0,0,0,2147483648,0,34603008,1048576,545259520,0,0,0,0]),2048),new L.A(new Uint32Array([2,0,65536,0,0,0,1073741824,0,0,0,0,0,32,0,0,4,0,0,0,0,1024,0,0,0,262144,128,0,0,0,0,0,0,0,0,0,0,524288,0,0,1048576,0,0,0,0,524288,0,0,0,0,0,0,0,0,0,8388608,0,0,34603008,0,536870912,0,0,0,0]),2048),new L.A(new Uint32Array([2,0,0,0,0,0,0,8,134217728,0,0,67108864,32,0,0,0,0,0,0,0,1024,0,8388608,0,262144,128,0,0,0,0,0,0,0,2,0,524288,524288,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,536870912,0,0,0,0,1048576,67108864,536870912,0,0,0,0]),2048),new L.A(new Uint32Array([2,0,0,0,0,0,0,0,134217728,0,0,0,32,0,0,0,0,0,0,0,1024,0,8388608,0,262144,128,0,0,0,0,0,1073741824,128,2,0,524288,524288,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8192,0,1048576,0,536870912,0,0,0,0]),2048),new L.A(new Uint32Array([2,0,98304,8388608,0,0,0,0,0,0,256,4096,32,0,0,0,0,0,0,0,1024,0,0,0,262144,192,0,0,0,0,0,0,0,0,67108865,0,524288,32768,32,0,0,0,8224,16,524288,0,0,0,0,32,128,0,2097152,0,4194304,8388608,0,34603008,8519680,536870912,131072,262144,0,0]),2048),new L.A(new Uint32Array([2,0,98304,0,0,0,0,0,0,4194304,0,0,32,0,0,0,0,0,0,0,1024,0,0,512,262144,128,33554432,0,0,0,0,33554432,0,0,0,0,524288,0,32,0,0,2,0,16,524288,0,0,0,0,0,4,0,0,0,71303168,262144,0,34603008,131072,536870912,0,0,0,0]),2048);new L.A(new Uint32Array([0,0,0,0,0,0,0,0,0,1024,0,67108864,0,0,0,512,0,0,0,8388608,0,0,512,0,0,64,4,0,0,0,4,0,0,0,67108864,0,524289,0,0,0,0,0,0,16,0,659456,0,256,0,16,0,0,0,268435456,0,0,262144,0,131072,0,0,0,8388608,0]),2048),new L.A(new Uint32Array([0,1073741824,0,0,0,0,0,2147483648,4,67108864,0,67108864,0,256,0,0,0,0,0,0,1024,0,128,0,0,64,0,0,0,0,0,0,0,0,67108864,0,524289,0,65536,0,0,0,0,16,0,131072,0,4,0,0,0,0,0,0,4194304,0,0,2147483648,131072,0,4096,0,0,0]),2048),new L.A(new Uint32Array([0,0,0,0,1024,0,0,0,0,67109888,16384,67108864,0,0,0,0,0,0,0,33562624,1024,33554432,512,16384,0,64,4,0,0,33554432,0,0,0,0,67108864,0,524289,0,0,0,0,0,0,16,0,135168,0,268435456,0,0,0,0,0,268435456,131072,0,0,2147483648,131072,0,0,0,8388608,0]),2048),new L.A(new Uint32Array([8388608,0,0,0,0,0,0,0,0,67108864,0,0,0,4,0,0,0,0,0,0,1024,0,0,16384,0,64,0,0,0,0,0,0,0,2,67108864,0,0,0,0,0,0,0,0,40976,0,0,0,0,0,0,0,0,0,67108864,131072,524288,0,0,8519680,0,1,33554432,1048576,0]),2048),new L.A(new Uint32Array([0,0,131072,1073741824,0,0,0,0,0,67108864,0,0,0,0,0,0,0,0,0,0,1024,0,128,0,0,64,0,0,0,0,0,0,0,32768,67108864,0,0,0,0,0,0,0,0,16,0,0,0,4,0,0,2048,0,0,0,4341760,0,0,0,131072,0,0,33554432,1048576,0]),2048);var ke,Ge=n(857),De={};De.styleTagTransform=v(),De.setAttributes=g(),De.insert=m().bind(null,"head"),De.domAPI=h(),De.insertStyleElement=b(),u()(Ge.A,De),Ge.A&&Ge.A.locals&&Ge.A.locals,function(e){e.MONOMER="Monomer",e.SYMBOL="Symbol",e.NAME="Name",e.R_GROUPS="~R-Groups",e.MONOMER_TYPE="Monomer Type",e.POLYMER_TYPE="Polymer Type",e.NATURAL_ANALOG="Natural Analog",e.AUTHOR="Author",e.CREATE_DATE="Create Date",e.ID="ID",e.META="Meta",e.SOURCE="Source"}(ke||(ke={})),ke.MONOMER,a.COLUMN_TYPE.STRING,ke.SYMBOL,a.COLUMN_TYPE.STRING,ke.NAME,a.COLUMN_TYPE.STRING,ke.R_GROUPS,a.COLUMN_TYPE.STRING,ke.MONOMER_TYPE,a.COLUMN_TYPE.STRING,ke.POLYMER_TYPE,a.COLUMN_TYPE.STRING,ke.NATURAL_ANALOG,a.COLUMN_TYPE.STRING,ke.AUTHOR,a.COLUMN_TYPE.STRING,ke.CREATE_DATE,a.COLUMN_TYPE.DATE_TIME,ke.ID,a.COLUMN_TYPE.INT,ke.META,a.COLUMN_TYPE.STRING,ke.SOURCE,a.COLUMN_TYPE.STRING;var He,Fe=function(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}c((r=r.apply(e,t||[])).next())}))};class Ve{_setBreadcrumbsInViewName(){var e,t;const n=["Home","Demo",...(null!==(e=this._path)&&void 0!==e?e:"").split("/")],r=i.breadcrumbs(n);if(r.onPathClick.subscribe((e=>Fe(this,void 0,void 0,(function*(){const t=e[e.length-1];if(t===r.path[r.path.length-1])return;const n=s.shell.browsePanel.mainTree.getOrCreateGroup("Apps").getOrCreateGroup("Demo");n.currentItem="Demo"===t?n:n.items.find((e=>e.text===t))})))),s.shell.v){if(0!==r.path.length&&"Home"===r.path[0]){const e=i.iconFA("home",(()=>{s.shell.v.close(),s.shell.v=a.View.createByType(a.VIEW_TYPE.HOME)}));e.classList.add("demo-breadcrumbs-home-element"),r.root.firstElementChild.replaceWith(e)}const e=null===(t=s.shell.v.ribbonMenu.root.parentElement)||void 0===t?void 0:t.getElementsByClassName("d4-ribbon-name")[0];e&&(e.textContent="",e.appendChild(r.root))}}constructor(e,t,n=!1,r){var o,s;this.name="",this.description="",this._isAutomatic=!1,this._autoStartFirstStep=!1,this._currentStep=0,this._isStopped=!1,this._isCancelled=!1,this._isStepProcessed=!1,this._root=i.div([],{id:"demo-script",classes:"tutorials-root tutorials-track demo-app-script"}),this._steps=[],this._mainHeader=i.panel([],"tutorials-main-header"),this._header=i.h2(""),this._headerDiv=i.divH([],"tutorials-root-header"),this._stopStartBtn=i.button(i.iconFA("pause"),(()=>Fe(this,void 0,void 0,(function*(){return yield this._changeStopState()}))),"Play / pause"),this._restartBtn=i.button(i.iconFA("redo"),(()=>Fe(this,void 0,void 0,(function*(){return yield this._restartScript()}))),"Restart"),this._nextStepBtn=i.button(i.iconFA("play"),(()=>Fe(this,void 0,void 0,(function*(){this._isStepProcessed||(yield this._nextStep())}))),"Next step"),this._activity=i.panel([],"tutorials-root-description"),this._progressDiv=i.divV([],"tutorials-root-progress"),this._progress=i.element("progress"),this._progressSteps=i.divText(""),this._closeBtn=i.button(i.iconFA("chevron-left"),(()=>this._closeDock()),"Back to demo"),this.DEMO_PATH="apps/Tutorials/Demo",this.name=e,this.description=t,this._isAutomatic=n,this._autoStartFirstStep=null!==(o=null==r?void 0:r.autoStartFirstStep)&&void 0!==o&&o,this._path=null!==(s=null==r?void 0:r.path)&&void 0!==s?s:"",this._progress.max=0,this._progress.value=1,Ve.currentObject=this}get steps(){return this._steps}get stepNumber(){return this._steps.length}_addHeader(){this._createHeaderDiv(),this._createProgressDiv(),this._mainHeader.append(this._headerDiv,this._progressDiv)}_createHeaderDiv(){this._header.innerText=this.name,this._headerDiv.append(this._closeBtn),this._headerDiv.append(this._header),this._nextStepBtn.firstChild.className="grok-icon fas fa-play",this._headerDiv.append(this._isAutomatic?this._stopStartBtn:this._nextStepBtn)}_createProgressDiv(){this._progress.max=this.stepNumber,this._progressDiv.append(this._progress),this._progressSteps=i.divText(`Step: ${this._progress.value} of ${this.stepNumber}`),this._progressDiv.append(this._progressSteps)}_addDescription(){var e;this._activity.append(i.div(this.description,"tutorials-root-description"));for(let t=0;t<this.stepNumber;t++){let n=i.iconFA("clock");this._isAutomatic||0===t&&(n=i.iconFA("play",(()=>this._nextStep()),"Next step"),n.className="grok-icon fas fa-play");const r=i.div(this._steps[t].name,"grok-tutorial-entry-instruction"),o=i.div(null===(e=this._steps[t].options)||void 0===e?void 0:e.description,"grok-tutorial-step-description hidden"),s=i.divH([n,r],"grok-tutorial-entry");this._activity.append(s,o)}}_initRoot(){s.shell.windows.showContextPanel=!0,s.shell.windows.showHelp=!1,this._node=s.shell.dockManager.dock(this._root,a.DOCK_TYPE.FILL,s.shell.dockManager.findNode(s.shell.browsePanel.root),this.name),this._node.container.containerElement.classList.add("tutorials-demo-script-container"),this._addHeader(),this._root.append(this._mainHeader),this._addDescription(),this._root.append(this._activity)}_setViewParams(){var e;s.shell.v&&(s.shell.v.name=this.name,s.shell.v.path=`${this.DEMO_PATH}/${(null!==(e=this._path)&&void 0!==e?e:"").replaceAll(" ","-")}`,this._setBreadcrumbsInViewName())}_nextStep(){return Fe(this,void 0,void 0,(function*(){var e,t;this._isStepProcessed=!0,this._isAutomatic||(this._nextStepBtn.classList.add("disabled"),this._nextStepBtn.firstChild.classList.add("fa-disabled"));const n=this._activity.getElementsByClassName("grok-tutorial-entry")[this._currentStep],r=this._activity.getElementsByClassName("grok-icon")[this._currentStep],o=this._activity.getElementsByClassName("grok-tutorial-step-description")[this._currentStep];r.className="grok-icon far fa-spinner-third fa-spin",o.classList.remove("hidden"),o.classList.add("visible");const c=n,l=(null===(e=this._steps[this._currentStep].options)||void 0===e?void 0:e.delay)?null===(t=this._steps[this._currentStep].options)||void 0===t?void 0:t.delay:2e3;try{this._setViewParams(),yield this._steps[this._currentStep].func(),this._setViewParams()}catch(e){console.error(e)}this._scrollTo(this._root,c.offsetTop-this._mainHeader.offsetHeight),this._isAutomatic&&(yield this._countdown(n,r,l),yield(0,K.cb)(l));const u=i.iconFA("check");if(r.replaceWith(u),u.className="grok-icon far fa-check",this._progress.value++,this._progressSteps.innerText=`Step: ${this._progress.value} of ${this.stepNumber}`,this._currentStep++,this._isStepProcessed=!1,this._currentStep!==this.stepNumber){if(!this._isAutomatic){const e=this._activity.getElementsByClassName("grok-icon")[this._currentStep],t=i.iconFA("play",(()=>this._nextStep()),"Next step");t.className="grok-icon fas fa-play",e.replaceWith(t),this._nextStepBtn.classList.remove("disabled"),this._nextStepBtn.firstChild.classList.remove("fa-disabled")}s.shell.v instanceof a.TableView&&(yield s.data.detectSemanticTypes(s.shell.tv.dataFrame))}else this._isAutomatic?this._stopStartBtn.replaceWith(this._restartBtn):this._nextStepBtn.replaceWith(this._restartBtn)}))}_startScript(){return Fe(this,void 0,void 0,(function*(){for(let e=this._currentStep;e<this.stepNumber&&!this._isStopped&&!this._isCancelled;e++)yield this._nextStep()}))}_scrollTo(e,t){e.focus(),e.scrollTop=t}_countdown(e,t,n){return Fe(this,void 0,void 0,(function*(){const r=i.div([],"demo-script-countdown");t.classList.add("hidden");let o=n/1e3;const s=this._createSVGIndicator(o);r.append(s),e.prepend(r);const a=setInterval((()=>{o--,0===o&&(clearInterval(a),r.remove(),t.classList.remove("hidden"),t.classList.add("visible"))}),1e3)}))}_createSVGIndicator(e){const t=document.createElementNS("http://www.w3.org/2000/svg","svg"),n=document.createElementNS("http://www.w3.org/2000/svg","circle");return n.setAttributeNS(null,"cx","7"),n.setAttributeNS(null,"cy","7"),n.setAttributeNS(null,"r","6"),n.setAttributeNS(null,"style",`animation: countdown ${e}s linear infinite forwards`),t.append(n),t}_changeStopState(){return Fe(this,void 0,void 0,(function*(){const e=this._stopStartBtn.getElementsByClassName("grok-icon");e[0].className="grok-icon fas fa-play",this._isStopped=!this._isStopped,this._isStopped||(e[0].className="grok-icon fal fa-pause",this._isStepProcessed||(yield this._startScript()))}))}_restartScript(){return Fe(this,void 0,void 0,(function*(){s.shell.dockManager.close(this._node),this._clearRoot(),this._setInitParams(),yield this.start()}))}_clearRoot(){this._root=i.div([],{id:"demo-script",classes:"tutorials-root tutorials-track demo-app-script"}),this._mainHeader=i.panel([],"tutorials-main-header"),this._header=i.h2(""),this._headerDiv=i.divH([],"tutorials-root-header"),this._activity=i.panel([],"tutorials-root-description"),this._progressDiv=i.divV([],"tutorials-root-progress"),this._progress=i.element("progress"),this._progressSteps=i.divText(""),this._progress.max=0,this._progress.value=1}_setInitParams(){this._currentStep=0,this._isStopped=!1,this._isCancelled=!1,this._stopStartBtn.getElementsByClassName("grok-icon")[0].className="grok-icon fal fa-pause",this._nextStepBtn.classList.remove("disabled")}_closeDock(){s.shell.dockManager.close(this._node),this.cancelScript()}cancelScript(){this._isCancelled=!0,Ve.currentObject=null}step(e,t,n){return this._steps[this.steps.length]={name:e,func:t,options:n},this}start(){return Fe(this,void 0,void 0,(function*(){this._initRoot(),s.shell.v.name===this.name&&(s.shell.v.close(),this._node=s.shell.dockManager.dock(this._root,a.DOCK_TYPE.FILL,s.shell.dockManager.findNode(s.shell.browsePanel.root),this.name)),this._isAutomatic?yield this._startScript():this._autoStartFirstStep&&(yield this._nextStep())}))}}Ve.currentObject=null,function(e){e.X="Embed_X",e.Y="Embed_Y"}(He||(He={})),n(966),n(608),n(1619),n(6869),new class{tooltipHandlerTemp="tooltip-handler.Monomer"},a.GridCellRenderer;class Ue{constructor(e,t,n=""){this.target=e,this.debugEnabled=t,this.prefix=n}error(e,t,n){return this.target.error(this.prefix+e,t,n)}warning(e,t){return this.target.warning(this.prefix+e,t)}info(e,t){return this.target.info(this.prefix+e,t)}debug(e,t){if(this.debugEnabled)return this.target.debug(this.prefix+e,t)}}Map;class Be extends a.Package{_properties;_seqHelper;get seqHelper(){if(!this._seqHelper)throw new Error("Package Bio .seqHelper is not initialized.");return this._seqHelper}_monomerLib;get monomerLib(){if(!this._monomerLib)throw new Error("Package Bio .monomerLib is not initialized.");return this._monomerLib}_monomerSets;get monomerSets(){if(!this._monomerSets)throw new Error("Package Bio .monomerSets is not initialized.");return this._monomerSets}_rdKitModule;get rdKitModule(){if(!this._rdKitModule)throw new Error("Package Bio .rdKitModule is not initialized.");return this._rdKitModule}get properties(){return this._properties}set properties(e){this._properties=e}_initialized=!1;get initialized(){return this._initialized}constructor(e={debug:!1}){super(),super._logger=new Ue(super.logger,e.debug)}completeInit(e,t,n,r){this._seqHelper=e,this._monomerLib=t,this._monomerSets=n,this._rdKitModule=r,this._initialized=!0}handleErrorUI(e){const[t,n]=(0,Ee.AP)(e);s.shell.error(t),this.logger.error(t,void 0,n)}}var Ye=n(5999),We={};We.styleTagTransform=v(),We.setAttributes=g(),We.insert=m().bind(null,"head"),We.domAPI=h(),We.insertStyleElement=b(),u()(Ye.A,We),Ye.A&&Ye.A.locals&&Ye.A.locals,n(6307),a.Widget,a.DataFrame.fromCsv("seq,value\nATCCGTCGT,0.5\nTGTTCGTCA,0.4\nATGGTCGTA,0.7\nATCCGTGCA,0.1"),["1","1A","1C","2","4","4A","4B","5","6"].join(D.z1),n(8754),n(294),n(330),OCL,n(6956),new Map;new a.LruCache(100),new a.LruCache(100);const je=new Be;async function Ke(){return await Ie.getInstance()}},4954:(e,t,n)=>{"use strict";n.d(t,{if:()=>h,nI:()=>d});var r=n(4328),o=(n(7389),n(6082)),s=n(8070),i=n(2003),a=n(439);const c=31;async function l(e,t,n=!1,s){const i=t.getSeqHandler(e);let a;s??=new Map;const l=i.isHelm()?t.getSeqMonomers(e):Object.keys(i.stats.freq).filter((e=>""!==e));for(let e=0;e<l.length;e++)s.has(l[e])||s.set(l[e],`${s.size+1}`);if(i.isHelm())a=await r.functions.call("HELM:getMolFiles",{col:e}),a=function(e,t,n=!1){const r=new Array(e.length);for(let o=0;o<e.length;o++){let s=0,i=0,a="\n Datagrok macromolecule handler\n\n 0 0 0 0 0 0 999 V3000\nM V30 BEGIN CTAB\n";const l=e.get(o);s=l.indexOf("\n",s)+1,s=l.indexOf("\n",s)+1,s=l.indexOf("\n",s)+1;const u=parseInt(l.substring(s,s+3)),d=parseInt(l.substring(s+3,s+6));a+=`M V30 COUNTS ${u} ${d} 0 0 0\n`,a+="M V30 BEGIN ATOM\n";for(let e=0;e<u;e++){s=l.indexOf("\n",s)+1+c,i=l.indexOf(" ",s);const r=l.substring(s,i);a+=n?`M V30 ${e+1} R${t.get(r)} 0.000 0.000 0 0\n`:`M V30 ${e+1} At 0.000 0.000 0 0 MASS=${t.get(r)}\n`}a+="M V30 END ATOM\n",a+="M V30 BEGIN BOND\n";for(let e=0;e<d;e++){s=l.indexOf("\n",s)+1;const t=parseInt(l.substring(s,s+3).trim()),n=parseInt(l.substring(s+3,s+6).trim());a+=`M V30 ${e+1} ${parseInt(l.substring(s+6,s+9).trim())} ${t} ${n}\n`}a+="M V30 END BOND\n",a+="M V30 END CTAB\n",a+="M END",r[o]=a}return r}(a,s,n);else{a=new Array(e.length);for(let t=0;t<e.length;t++){const e=u(i.getSplitted(t),s,n);a[t]=e}}return o.Column.fromStrings("monomericMols",a)}function u(e,t,n=!1){let r="\n Datagrok macromolecule handler\n\n 0 0 0 0 0 0 999 V3000\nM V30 BEGIN CTAB\n";r+=`M V30 COUNTS ${e.length} ${e.length?e.length-1:0} 0 0 0\n`,r+="M V30 BEGIN ATOM\n";for(let o=0;o<e.length;o++){const s=e.getCanonical(o);s!==a._S&&(r+=n?`M V30 ${o+1} R${t.get(s)} 0.000 0.000 0 0\n`:`M V30 ${o+1} At 0.000 0.000 0 0 MASS=${t.get(s)}\n`)}r+="M V30 END ATOM\n",r+="M V30 BEGIN BOND\n";for(let t=0;t<e.length-1;t++)r+=`M V30 ${t+1} 1 ${t+1} ${t+2}\n`;return r+="M V30 END BOND\n",r+="M V30 END CTAB\n",r+="M END",r}function d(e,t,n){const r=n?function(e,t){const n=`${t}`.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),r=e.charAt(0)===t,o=e.charAt(e.length-1)===t,s=e.replace(new RegExp(`^${n}|${n}$`,"g"),"");return r?o?`${n}${s}${n}`:`${n}${s}${n}|${n}${s}$`:o?`^${s}${n}|${n}${s}${n}`:`^${s}${n}|${n}${s}${n}|${n}${s}$`}(e,n):e,s=o.BitSet.create(t.length);for(let n=0;n<t.length;n++){const o=t.get(n);(o.match(r)||o===e)&&s.set(n,!0,!1)}return s}async function h(e,t,n){t.version!==t.temp["last-invalidated-version"]&&await async function(e,t){const n=o.TaskBarProgressIndicator.create(`Invalidating molfiles for ${e.name}`);try{await(0,s.cb)(10);const n=new Map,r=await l(e,t,!0,n);e.temp["monomeric-mols"]=r,e.temp["monomers-dict"]=n,e.temp["last-invalidated-version"]=e.version}finally{n.close()}}(t,n);const a=o.Column.string("helm",1).init((t=>e));a.semType=o.SEMTYPE.MACROMOLECULE,a.meta.units=i.Hi.HELM;const c=await l(a,n,!0,t.temp["monomers-dict"]);return(await r.functions.call("Chem:searchSubstructure",{molStringsColumn:t.temp["monomeric-mols"],molString:c.get(0),molBlockFailover:""})).get(0)}n(4870)},966:(e,t,n)=>{"use strict";n.d(t,{l:()=>s});var r=n(4328),o=n(6082);function s(e,t,n,s=[],i=[]){let a=!0,c="";if(e.semType!==o.SEMTYPE.MACROMOLECULE)r.shell.warning(t+" analysis is allowed for Macromolecules semantic type"),a=!1;else{const r=n.getSeqHandler(e),o=r.notation;if(s.length>0&&!s.some((e=>o.toUpperCase()==e.toUpperCase())))c=`${t} + ' analysis is allowed for Macromolecules with notation ${0==s.length?"any notation":`notation${s.length>1?"s":""} ${s.map((e=>`"${e}"`)).join(", ")} `}.`,a=!1;else if(!r.isHelm()){const e=r.alphabet;i.length>0&&!i.some((t=>e.toUpperCase()==t.toUpperCase()))&&(c=`${t} + ' analysis is allowed for Macromolecules with alphabet ${0==i.length?"any alphabet":`alphabet${i.length>1?"s":""} ${i.map((e=>`"${e}"`)).join(", ")}.`}.`,a=!1)}}return[a,c]}n(6723)},4139:(e,t,n)=>{"use strict";n.d(t,{HX:()=>d,J:()=>l,b9:()=>u,gN:()=>a,uF:()=>s});var r,o,s,i=n(8152);!function(e){e.SPLIT_COL="~split",e.ACTIVITY="~activity",e.ACTIVITY_SCALED="activity_scaled",e.ALIGNED_SEQUENCE="~aligned_sequence",e.AMINO_ACID_RESIDUE="AAR",e.POSITION="Pos",e.P_VALUE="pValue",e.MEAN_DIFFERENCE="Mean difference"}(r||(r={})),function(e){e.AAR="AAR",e.POSITION="Pos",e.SELECTION="selection"}(o||(o={})),function(e){e.MONOMER="Monomer",e.MACROMOLECULE_DIFFERENCE="MacromoleculeDifference",e.ACTIVITY="activity",e.ACTIVITY_SCALED="activityScaled"}(s||(s={}));const a="MSA";var c,l;!function(e){e.CELL_CHANGING="isCellChanging"}(c||(c={})),function(e){e.SEPARATOR="."}(l||(l={}));const u="3.3.1",d={pepsea:{gapOpen:1.53,gapExtend:0,method:i.ZY[0]},kalign:{gapOpen:-1,gapExtend:-1,terminalGap:-1}}},5433:(e,t,n)=>{"use strict";n.d(t,{r:()=>o}),n(6082),n(7389);var r=n(4328);async function o(e,t,n,o){const s=t.getSeqHandler(e).convert(n,o);e.dataFrame.columns.add(s);const i=await r.functions.call("Bio:detectMacromolecule",{col:s});return i&&(s.semType=i),await r.data.detectSemanticTypes(e.dataFrame),s}n(1757),n(2003)},6956:(e,t,n)=>{"use strict";n.d(t,{mP:()=>s,pk:()=>o,xe:()=>r});const r="|",o="$",s="H"},8604:(e,t,n)=>{"use strict";n.d(t,{Es:()=>o,G3:()=>i,VV:()=>a,gt:()=>s,so:()=>r});const r="System:AppData/Bio/monomer-libraries/",o="System:AppData/Bio/monomer-sets/",s="System:AppData/Bio/tests/libraries/HELMmonomerSchema.json",i={explicit:["HELMCoreLibrary.json","polytool-lib.json"],exclude:[],duplicateMonomerPreferences:{}},a={PEPTIDE:326,RNA:383,CHEM:0}},1619:(e,t,n)=>{"use strict";n.d(t,{D:()=>P});var r=n(4328),o=n(6082),s=n(7389),i=n(8070),a=n(2003),c=n(608),l=n(8152),u=n(966),d=n(4139),h=n(5072),p=n.n(h),m=n(7825),f=n.n(m),g=n(7659),y=n.n(g),b=n(5056),w=n.n(b),v=n(540),A=n.n(v),E=n(1113),C=n.n(E),T=n(6369),S={};S.styleTagTransform=C(),S.setAttributes=w(),S.insert=y().bind(null,"head"),S.domAPI=f(),S.insertStyleElement=A(),p()(T.A,S),T.A&&T.A.locals&&T.A.locals;var _=n(6723);async function P(e,t){return new Promise((async(n,a)=>{e.clustersCol??=null,e.pepsea??={},e.pepsea.method??=d.HX.pepsea.method,e.pepsea.gapOpen??=d.HX.pepsea.gapOpen,e.pepsea.gapExtend??=d.HX.pepsea.gapExtend;const u=e.col?.dataFrame??r.shell.t;if(!u){const e="Multiple Sequence Alignment analysis requires a dataset with a macromolecule column.";return void a(new c.Ap(s.divText(e)))}const h=e.col??u.columns.bySemType(o.SEMTYPE.MACROMOLECULE);if(null==h){const e="Multiple Sequence Alignment analysis requires a dataset with a macromolecule column.";return void a(new c.Ap(s.divText(e)))}const p=s.input.choice("Method",{value:e.pepsea.method,items:l.ZY});p.setTooltip("Alignment method");const m=s.input.float("Terminal gap",{value:e?.kalign?.terminalGap});m.setTooltip("Penalty for opening a gap at the beginning or end of the sequence");const f=s.p(`Kalign version: ${d.b9}`,"kalign-version"),g=s.input.float("Gap open",{value:e.pepsea.gapOpen});g.setTooltip("Gap opening penalty at group-to-group alignment");const y=s.input.float("Gap extend",{value:e.pepsea.gapExtend});y.setTooltip("Gap extension penalty to skip the alignment");const b=s.input.bool("Selected Rows Only",{value:!1}),w=s.inputs([g,y,m]),v=s.button("Alignment parameters",(()=>{w.hidden=!w.hidden,[g,y,m].forEach((e=>{e.root.style.removeProperty("max-width"),e.captionLabel.style.removeProperty("max-width")}))}),"Adjust alignment parameters such as penalties for opening and extending gaps");v.classList.add("msa-params-button"),w.hidden=!0,v.prepend(s.icons.settings((()=>null)));const A=[p.root.style],E=[m.root.style,f.style];let C,T=h;const S=s.input.column("Sequence",{table:u,value:h,onValueChanged:async e=>{if(!e||e.semType!==o.SEMTYPE.MACROMOLECULE)return N.disabled=!0,await(0,i.cb)(0),void(S.value=T);T=e,N.disabled=!1,C=await x(S.value,u,t,A,E,p,_,g,y,m,b)},filter:e=>e.semType===o.SEMTYPE.MACROMOLECULE});S.setTooltip("Sequences column to use for alignment");const _=s.input.column("Clusters",{table:u,value:e.clustersCol});_.nullable=!0;const P=s.dialog("MSA").add(S).add(_).add(p).add(w).add(v).add(b).add(f).onOK((async()=>{await M(S,u,C,n,a)})),N=P.getButton("OK");if(S.fireChanged(),e.col)return C=await x(e.col,u,t,A,E,p,_,g,y,m,b),void await M(S,u,C,n,a);P.show()}))}async function M(e,t,n,s,i){let a=null;const c=o.TaskBarProgressIndicator.create("Analyze for MSA ...");try{if(e.fireChanged(),e.value.semType!==o.SEMTYPE.MACROMOLECULE)throw new Error("Chosen column has to be of Macromolecule semantic type");if(void 0===n)throw new Error("Invalid column format");if(a=await n(),null==a)return i("PepSeA container has not started");t.columns.add(a),await r.data.detectSemanticTypes(t),s(a)}catch(e){i(e)}finally{c.close()}}async function x(e,t,n,s,i,h,p,m,f,g,y){try{if(e.semType!==o.SEMTYPE.MACROMOLECULE)return;const r=t.columns.getUnusedName(`msa(${e.name})`);if((0,u.l)(e,e.name,n,[a.Hi.FASTA,a.Hi.SEPARATOR],[a.YI.DNA,a.YI.RNA,a.YI.PT])[0]){N(s,i,"kalign"),m.value=null,f.value=null,g.value=null;const o=n.getSeqHandler(e),l=o.isFasta()?e:o.convert(a.Hi.FASTA);return async()=>await(0,c.eE)(t,l,!1,r,p.value,void 0,void 0,void 0,y.value)}if((0,u.l)(e,e.name,n,[a.Hi.HELM],[])[0])return N(s,i,"pepsea"),m.value??=d.HX.pepsea.gapOpen,f.value??=d.HX.pepsea.gapExtend,async()=>(0,l.GD)(t,e,r,h.value,m.value,f.value,p.value,void 0,y.value);if((0,u.l)(e,e.name,n,[a.Hi.SEPARATOR],[a.YI.UN])[0]){const o=n.getSeqHandler(e).convert(a.Hi.HELM);return N(s,i,"pepsea"),m.value??=d.HX.pepsea.gapOpen,f.value??=d.HX.pepsea.gapExtend,async()=>(0,l.GD)(t,o,r,h.value,m.value,f.value,p.value,void 0,y.value)}return m.value=null,f.value=null,g.value=null,void N(s,i,"kalign")}catch(e){const t=e instanceof Error?e.message:e.toString();r.shell.error(t),_._package.logger.error(t)}}function N(e,t,n){if("kalign"===n){for(const t of e)t.display="none";for(const e of t)e.removeProperty("display")}else{for(const e of t)e.display="none";for(const t of e)t.removeProperty("display")}}},608:(e,t,n)=>{"use strict";n.d(t,{Ap:()=>G,aZ:()=>V,eE:()=>H});var r=n(7389),o=n(6082),s=n(1991),i=n.n(s),a=n(3516),c=n(2003);const l=Symbol("Comlink.proxy"),u=Symbol("Comlink.endpoint"),d=Symbol("Comlink.releaseProxy"),h=Symbol("Comlink.thrown"),p=e=>"object"==typeof e&&null!==e||"function"==typeof e,m=new Map([["proxy",{canHandle:e=>p(e)&&e[l],serialize(e){const{port1:t,port2:n}=new MessageChannel;return f(e,t),[n,[n]]},deserialize:e=>(e.start(),y(e))}],["throw",{canHandle:e=>p(e)&&h in e,serialize({value:e}){let t;return t=e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[t,[]]},deserialize(e){throw e.isError?Object.assign(new Error(e.value.message),e.value):e.value}}]]);function f(e,t=self){t.addEventListener("message",(function n(r){if(!r||!r.data)return;const{id:o,type:s,path:i}=Object.assign({path:[]},r.data),a=(r.data.argumentList||[]).map(T);let c;try{const t=i.slice(0,-1).reduce(((e,t)=>e[t]),e),n=i.reduce(((e,t)=>e[t]),e);switch(s){case"GET":c=n;break;case"SET":t[i.slice(-1)[0]]=T(r.data.value),c=!0;break;case"APPLY":c=n.apply(t,a);break;case"CONSTRUCT":c=function(e){return Object.assign(e,{[l]:!0})}(new n(...a));break;case"ENDPOINT":{const{port1:t,port2:n}=new MessageChannel;f(e,n),c=function(e,t){return E.set(e,t),e}(t,[t])}break;case"RELEASE":c=void 0;break;default:return}}catch(e){c={value:e,[h]:0}}Promise.resolve(c).catch((e=>({value:e,[h]:0}))).then((e=>{const[r,i]=C(e);t.postMessage(Object.assign(Object.assign({},r),{id:o}),i),"RELEASE"===s&&(t.removeEventListener("message",n),g(t))}))})),t.start&&t.start()}function g(e){(function(e){return"MessagePort"===e.constructor.name})(e)&&e.close()}function y(e,t){return w(e,[],t)}function b(e){if(e)throw new Error("Proxy has been released and is not useable")}function w(e,t=[],n=function(){}){let r=!1;const o=new Proxy(n,{get(n,s){if(b(r),s===d)return()=>S(e,{type:"RELEASE",path:t.map((e=>e.toString()))}).then((()=>{g(e),r=!0}));if("then"===s){if(0===t.length)return{then:()=>o};const n=S(e,{type:"GET",path:t.map((e=>e.toString()))}).then(T);return n.then.bind(n)}return w(e,[...t,s])},set(n,o,s){b(r);const[i,a]=C(s);return S(e,{type:"SET",path:[...t,o].map((e=>e.toString())),value:i},a).then(T)},apply(n,o,s){b(r);const i=t[t.length-1];if(i===u)return S(e,{type:"ENDPOINT"}).then(T);if("bind"===i)return w(e,t.slice(0,-1));const[a,c]=A(s);return S(e,{type:"APPLY",path:t.map((e=>e.toString())),argumentList:a},c).then(T)},construct(n,o){b(r);const[s,i]=A(o);return S(e,{type:"CONSTRUCT",path:t.map((e=>e.toString())),argumentList:s},i).then(T)}});return o}function v(e){return Array.prototype.concat.apply([],e)}function A(e){const t=e.map(C);return[t.map((e=>e[0])),v(t.map((e=>e[1])))]}const E=new WeakMap;function C(e){for(const[t,n]of m)if(n.canHandle(e)){const[r,o]=n.serialize(e);return[{type:"HANDLER",name:t,value:r},o]}return[{type:"RAW",value:e},E.get(e)||[]]}function T(e){switch(e.type){case"HANDLER":return m.get(e.name).deserialize(e.value);case"RAW":return e.value}}function S(e,t,n){return new Promise((r=>{const o=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");e.addEventListener("message",(function t(n){!n.data||!n.data.id||n.data.id!==o||(e.removeEventListener("message",t),r(n.data))})),e.start&&e.start(),e.postMessage(Object.assign({id:o},t),n)}))}const _="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0ICQ9U3ltYm9sKCJDb21saW5rLnByb3h5IiksQT1TeW1ib2woIkNvbWxpbmsuZW5kcG9pbnQiKSxSPVN5bWJvbCgiQ29tbGluay5yZWxlYXNlUHJveHkiKSx5PVN5bWJvbCgiQ29tbGluay50aHJvd24iKSxfPWU9PnR5cGVvZiBlPT0ib2JqZWN0IiYmZSE9PW51bGx8fHR5cGVvZiBlPT0iZnVuY3Rpb24iLEw9e2NhbkhhbmRsZTplPT5fKGUpJiZlWyRdLHNlcmlhbGl6ZShlKXtjb25zdHtwb3J0MTpyLHBvcnQyOml9PW5ldyBNZXNzYWdlQ2hhbm5lbDtyZXR1cm4gdyhlLHIpLFtpLFtpXV19LGRlc2VyaWFsaXplKGUpe3JldHVybiBlLnN0YXJ0KCksQyhlKX19LE89e2NhbkhhbmRsZTplPT5fKGUpJiZ5IGluIGUsc2VyaWFsaXplKHt2YWx1ZTplfSl7bGV0IHI7cmV0dXJuIGUgaW5zdGFuY2VvZiBFcnJvcj9yPXtpc0Vycm9yOiEwLHZhbHVlOnttZXNzYWdlOmUubWVzc2FnZSxuYW1lOmUubmFtZSxzdGFjazplLnN0YWNrfX06cj17aXNFcnJvcjohMSx2YWx1ZTplfSxbcixbXV19LGRlc2VyaWFsaXplKGUpe3Rocm93IGUuaXNFcnJvcj9PYmplY3QuYXNzaWduKG5ldyBFcnJvcihlLnZhbHVlLm1lc3NhZ2UpLGUudmFsdWUpOmUudmFsdWV9fSxFPW5ldyBNYXAoW1sicHJveHkiLExdLFsidGhyb3ciLE9dXSk7ZnVuY3Rpb24gdyhlLHI9c2VsZil7ci5hZGRFdmVudExpc3RlbmVyKCJtZXNzYWdlIixmdW5jdGlvbiBpKHMpe2lmKCFzfHwhcy5kYXRhKXJldHVybjtjb25zdHtpZDpvLHR5cGU6YSxwYXRoOm59PU9iamVjdC5hc3NpZ24oe3BhdGg6W119LHMuZGF0YSksYz0ocy5kYXRhLmFyZ3VtZW50TGlzdHx8W10pLm1hcChtKTtsZXQgbDt0cnl7Y29uc3QgdT1uLnNsaWNlKDAsLTEpLnJlZHVjZSgoZCxwKT0+ZFtwXSxlKSxmPW4ucmVkdWNlKChkLHApPT5kW3BdLGUpO3N3aXRjaChhKXtjYXNlIkdFVCI6bD1mO2JyZWFrO2Nhc2UiU0VUIjp1W24uc2xpY2UoLTEpWzBdXT1tKHMuZGF0YS52YWx1ZSksbD0hMDticmVhaztjYXNlIkFQUExZIjpsPWYuYXBwbHkodSxjKTticmVhaztjYXNlIkNPTlNUUlVDVCI6e2NvbnN0IGQ9bmV3IGYoLi4uYyk7bD16KGQpfWJyZWFrO2Nhc2UiRU5EUE9JTlQiOntjb25zdHtwb3J0MTpkLHBvcnQyOnB9PW5ldyBNZXNzYWdlQ2hhbm5lbDt3KGUscCksbD1OKGQsW2RdKX1icmVhaztjYXNlIlJFTEVBU0UiOmw9dm9pZCAwO2JyZWFrO2RlZmF1bHQ6cmV0dXJufX1jYXRjaCh1KXtsPXt2YWx1ZTp1LFt5XTowfX1Qcm9taXNlLnJlc29sdmUobCkuY2F0Y2godT0+KHt2YWx1ZTp1LFt5XTowfSkpLnRoZW4odT0+e2NvbnN0W2YsZF09Uyh1KTtyLnBvc3RNZXNzYWdlKE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSxmKSx7aWQ6b30pLGQpLGE9PT0iUkVMRUFTRSImJihyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGkpLE0ocikpfSl9KSxyLnN0YXJ0JiZyLnN0YXJ0KCl9ZnVuY3Rpb24gVChlKXtyZXR1cm4gZS5jb25zdHJ1Y3Rvci5uYW1lPT09Ik1lc3NhZ2VQb3J0In1mdW5jdGlvbiBNKGUpe1QoZSkmJmUuY2xvc2UoKX1mdW5jdGlvbiBDKGUscil7cmV0dXJuIGIoZSxbXSxyKX1mdW5jdGlvbiBoKGUpe2lmKGUpdGhyb3cgbmV3IEVycm9yKCJQcm94eSBoYXMgYmVlbiByZWxlYXNlZCBhbmQgaXMgbm90IHVzZWFibGUiKX1mdW5jdGlvbiBiKGUscj1bXSxpPWZ1bmN0aW9uKCl7fSl7bGV0IHM9ITE7Y29uc3Qgbz1uZXcgUHJveHkoaSx7Z2V0KGEsbil7aWYoaChzKSxuPT09UilyZXR1cm4oKT0+ZyhlLHt0eXBlOiJSRUxFQVNFIixwYXRoOnIubWFwKGM9PmMudG9TdHJpbmcoKSl9KS50aGVuKCgpPT57TShlKSxzPSEwfSk7aWYobj09PSJ0aGVuIil7aWYoci5sZW5ndGg9PT0wKXJldHVybnt0aGVuOigpPT5vfTtjb25zdCBjPWcoZSx7dHlwZToiR0VUIixwYXRoOnIubWFwKGw9PmwudG9TdHJpbmcoKSl9KS50aGVuKG0pO3JldHVybiBjLnRoZW4uYmluZChjKX1yZXR1cm4gYihlLFsuLi5yLG5dKX0sc2V0KGEsbixjKXtoKHMpO2NvbnN0W2wsdV09UyhjKTtyZXR1cm4gZyhlLHt0eXBlOiJTRVQiLHBhdGg6Wy4uLnIsbl0ubWFwKGY9PmYudG9TdHJpbmcoKSksdmFsdWU6bH0sdSkudGhlbihtKX0sYXBwbHkoYSxuLGMpe2gocyk7Y29uc3QgbD1yW3IubGVuZ3RoLTFdO2lmKGw9PT1BKXJldHVybiBnKGUse3R5cGU6IkVORFBPSU5UIn0pLnRoZW4obSk7aWYobD09PSJiaW5kIilyZXR1cm4gYihlLHIuc2xpY2UoMCwtMSkpO2NvbnN0W3UsZl09RihjKTtyZXR1cm4gZyhlLHt0eXBlOiJBUFBMWSIscGF0aDpyLm1hcChkPT5kLnRvU3RyaW5nKCkpLGFyZ3VtZW50TGlzdDp1fSxmKS50aGVuKG0pfSxjb25zdHJ1Y3QoYSxuKXtoKHMpO2NvbnN0W2MsbF09RihuKTtyZXR1cm4gZyhlLHt0eXBlOiJDT05TVFJVQ1QiLHBhdGg6ci5tYXAodT0+dS50b1N0cmluZygpKSxhcmd1bWVudExpc3Q6Y30sbCkudGhlbihtKX19KTtyZXR1cm4gb31mdW5jdGlvbiBEKGUpe3JldHVybiBBcnJheS5wcm90b3R5cGUuY29uY2F0LmFwcGx5KFtdLGUpfWZ1bmN0aW9uIEYoZSl7Y29uc3Qgcj1lLm1hcChTKTtyZXR1cm5bci5tYXAoaT0+aVswXSksRChyLm1hcChpPT5pWzFdKSldfWNvbnN0IFA9bmV3IFdlYWtNYXA7ZnVuY3Rpb24gTihlLHIpe3JldHVybiBQLnNldChlLHIpLGV9ZnVuY3Rpb24geihlKXtyZXR1cm4gT2JqZWN0LmFzc2lnbihlLHtbJF06ITB9KX1mdW5jdGlvbiBTKGUpe2Zvcihjb25zdFtyLGldb2YgRSlpZihpLmNhbkhhbmRsZShlKSl7Y29uc3RbcyxvXT1pLnNlcmlhbGl6ZShlKTtyZXR1cm5be3R5cGU6IkhBTkRMRVIiLG5hbWU6cix2YWx1ZTpzfSxvXX1yZXR1cm5be3R5cGU6IlJBVyIsdmFsdWU6ZX0sUC5nZXQoZSl8fFtdXX1mdW5jdGlvbiBtKGUpe3N3aXRjaChlLnR5cGUpe2Nhc2UiSEFORExFUiI6cmV0dXJuIEUuZ2V0KGUubmFtZSkuZGVzZXJpYWxpemUoZS52YWx1ZSk7Y2FzZSJSQVciOnJldHVybiBlLnZhbHVlfX1mdW5jdGlvbiBnKGUscixpKXtyZXR1cm4gbmV3IFByb21pc2Uocz0+e2NvbnN0IG89VSgpO2UuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsZnVuY3Rpb24gYShuKXshbi5kYXRhfHwhbi5kYXRhLmlkfHxuLmRhdGEuaWQhPT1vfHwoZS5yZW1vdmVFdmVudExpc3RlbmVyKCJtZXNzYWdlIixhKSxzKG4uZGF0YSkpfSksZS5zdGFydCYmZS5zdGFydCgpLGUucG9zdE1lc3NhZ2UoT2JqZWN0LmFzc2lnbih7aWQ6b30sciksaSl9KX1mdW5jdGlvbiBVKCl7cmV0dXJuIG5ldyBBcnJheSg0KS5maWxsKDApLm1hcCgoKT0+TWF0aC5mbG9vcihNYXRoLnJhbmRvbSgpKk51bWJlci5NQVhfU0FGRV9JTlRFR0VSKS50b1N0cmluZygxNikpLmpvaW4oIi0iKX1jb25zdCBXPWFzeW5jKCk9PldlYkFzc2VtYmx5LnZhbGlkYXRlKG5ldyBVaW50OEFycmF5KFswLDk3LDExNSwxMDksMSwwLDAsMCwxLDUsMSw5NiwwLDEsMTIzLDMsMiwxLDAsMTAsMTAsMSw4LDAsNjUsMCwyNTMsMTUsMjUzLDk4LDExXSkpLGs9ImVhZ2VyIix4PSJsYXp5IixqPXtzc3c6WyJzaW1kIl0sbWluaW1hcDI6WyJzaW1kIl19LHQ9e3Rvb2xzOltdLGNvbmZpZzp7fSxmaWxlczpbXSxiYXNlOnt9LGZzOnt9LGFzeW5jIGluaXQoKXtpZih0LnRvb2xzLmxlbmd0aD09PTApdGhyb3ciRXhwZWN0aW5nIGF0IGxlYXN0IDEgdG9vbC4iO2lmKG5ldyBTZXQodC50b29scy5tYXAocj0+YCR7ci50b29sfS8ke3IucHJvZ3JhbXx8ci50b29sfWApKS5zaXplIT09dC50b29scy5sZW5ndGgpdGhyb3ciRm91bmQgZHVwbGljYXRlIHRvb2xzOyBjYW4gb25seSBoYXZlIGVhY2ggdG9vbC9wcm9ncmFtIGNvbWJpbmF0aW9uIGF0IG1vc3Qgb25jZS4iO2lmKHQuYmFzZT10LnRvb2xzLmZpbmQocj0+ci5yZWluaXQhPT0hMCksIXQuYmFzZSl0aHJvdyJDb3VsZCBub3QgZmluZCBhIHRvb2wgd2l0aCBgcmVpbml0OiBmYWxzZWAgdG8gdXNlIGFzIHRoZSBiYXNlIG1vZHVsZS4gVG8gZml4IHRoaXMgaXNzdWUsIGluY2x1ZGUgdGhlIHRvb2wgYGJhc2UvMS4wLjBgIHdoZW4gaW5pdGlhbGl6aW5nIEFpb2xpLiI7cmV0dXJuIHQuYmFzZS5pc0Jhc2VNb2R1bGU9ITAsYXdhaXQgdGhpcy5fc2V0dXAodC5iYXNlKSxhd2FpdCB0aGlzLl9pbml0TW9kdWxlcygpLHQuX2xvZygiUmVhZHkiKSwhMH0sYXN5bmMgX2luaXRNb2R1bGVzKCl7YXdhaXQgUHJvbWlzZS5hbGwodC50b29scy5tYXAodGhpcy5fc2V0dXApKSxhd2FpdCB0aGlzLl9zZXR1cEZTKCl9LG1vdW50KGU9W10pe2NvbnN0IHI9YCR7dC5jb25maWcuZGlyU2hhcmVkfSR7dC5jb25maWcuZGlyRGF0YX1gLGk9YCR7dC5jb25maWcuZGlyU2hhcmVkfSR7dC5jb25maWcuZGlyTW91bnRlZH1gO2xldCBzPVtdLG89W10sYT1bXTshQXJyYXkuaXNBcnJheShlKSYmIShlIGluc3RhbmNlb2YgRmlsZUxpc3QpJiYoZT1bZV0pLHQuX2xvZyhgTW91bnRpbmcgJHtlLmxlbmd0aH0gZmlsZXNgKTtmb3IobGV0IG4gb2YgZSl7aWYobiBpbnN0YW5jZW9mIEZpbGV8fChuPT1udWxsP3ZvaWQgMDpuLmRhdGEpaW5zdGFuY2VvZiBCbG9iJiZuLm5hbWV8fHR5cGVvZihuPT1udWxsP3ZvaWQgMDpuLmRhdGEpPT0ic3RyaW5nIiYmbi5uYW1lKXR5cGVvZihuPT1udWxsP3ZvaWQgMDpuLmRhdGEpPT0ic3RyaW5nIiYmKG4uZGF0YT1uZXcgQmxvYihbbi5kYXRhXSx7dHlwZToidGV4dC9wbGFpbiJ9KSkscy5wdXNoKG4pO2Vsc2UgaWYobi5uYW1lJiZuLnVybClvLnB1c2gobik7ZWxzZSBpZih0eXBlb2Ygbj09InN0cmluZyImJm4uc3RhcnRzV2l0aCgiaHR0cCIpKW49e3VybDpuLG5hbWU6bi5zcGxpdCgiLy8iKS5wb3AoKS5yZXBsYWNlKC9cLy9nLCItIil9LG8ucHVzaChuKTtlbHNlIHRocm93J0Nhbm5vdCBtb3VudCBmaWxlKHMpIHNwZWNpZmllZC4gTXVzdCBiZSBhIEZpbGUsIEJsb2IsIGEgVVJMIHN0cmluZywgb3IgeyBuYW1lOiAiZmlsZS50eHQiLCBkYXRhOiAic3RyaW5nIiB9Lic7YS5wdXNoKG4ubmFtZSl9dHJ5e3QuZnMudW5tb3VudChpKX1jYXRjaHt9Zm9yKGxldCBuIG9mIG8pdC5mcy5jcmVhdGVMYXp5RmlsZShyLG4ubmFtZSxuLnVybCwhMCwhMCk7cmV0dXJuIHQuZmlsZXM9dC5maWxlcy5jb25jYXQocyksdC5iYXNlLm1vZHVsZS5GUy5tb3VudCh0LmJhc2UubW9kdWxlLldPUktFUkZTLHtmaWxlczp0LmZpbGVzLmZpbHRlcihuPT5uIGluc3RhbmNlb2YgRmlsZSksYmxvYnM6dC5maWxlcy5maWx0ZXIobj0+KG49PW51bGw/dm9pZCAwOm4uZGF0YSlpbnN0YW5jZW9mIEJsb2IpfSxpKSxzLm1hcChuPT57Y29uc3QgYz1gJHtpfS8ke24ubmFtZX1gLGw9YCR7cn0vJHtuLm5hbWV9YDt0cnl7dC5mcy51bmxpbmsobCl9Y2F0Y2h7fXQuX2xvZyhgQ3JlYXRpbmcgc3ltbGluazogJHtsfSAtLT4gJHtjfWApLHQuZnMuc3ltbGluayhjLGwpfSksYS5tYXAobj0+YCR7cn0vJHtufWApfSxhc3luYyBleGVjKGUscj1udWxsKXtpZih0Ll9sb2coYEV4ZWN1dGluZyAlYyR7ZX0lYyBhcmdzPSR7cn1gLCJjb2xvcjpkYXJrYmx1ZTsgZm9udC13ZWlnaHQ6Ym9sZCIsIiIpLCFlKXRocm93IkV4cGVjdGluZyBhIGNvbW1hbmQiO2xldCBpPWU7cj09bnVsbCYmKHI9ZS5zcGxpdCgiICIpLGk9ci5zaGlmdCgpKTtjb25zdCBzPXQudG9vbHMuZmluZChhPT57dmFyIGM7bGV0IG49aTtyZXR1cm4oKGM9YT09bnVsbD92b2lkIDA6YS5mZWF0dXJlcyk9PW51bGw/dm9pZCAwOmMuc2ltZCk9PT0hMCYmKG49YCR7bn0tc2ltZGApLGEucHJvZ3JhbT09bn0pO2lmKHM9PW51bGwpdGhyb3dgUHJvZ3JhbSAke2l9IG5vdCBmb3VuZC5gO3Muc3Rkb3V0PSIiLHMuc3RkZXJyPSIiLHMubG9hZGluZz09eCYmKHMubG9hZGluZz1rLGF3YWl0IHRoaXMuX2luaXRNb2R1bGVzKCkpO3RyeXtzLm1vZHVsZS5jYWxsTWFpbihyKX1jYXRjaChhKXtjb25zb2xlLmVycm9yKGEpfXRyeXtzLm1vZHVsZS5GUy5jbG9zZShzLm1vZHVsZS5GUy5zdHJlYW1zWzFdKSxzLm1vZHVsZS5GUy5jbG9zZShzLm1vZHVsZS5GUy5zdHJlYW1zWzJdKX1jYXRjaHt9cy5tb2R1bGUuRlMuc3RyZWFtc1sxXT1zLm1vZHVsZS5GUy5vcGVuKCIvZGV2L3N0ZG91dCIsInciKSxzLm1vZHVsZS5GUy5zdHJlYW1zWzJdPXMubW9kdWxlLkZTLm9wZW4oIi9kZXYvc3RkZXJyIiwidyIpO2xldCBvPXtzdGRvdXQ6cy5zdGRvdXQsc3RkZXJyOnMuc3RkZXJyfTtyZXR1cm4gdC5jb25maWcucHJpbnRJbnRlcmxlYXZlZCYmKG89cy5zdGRvdXQpLHMucmVpbml0PT09ITAmJmF3YWl0IHRoaXMucmVpbml0KHMudG9vbCksb30sY2F0KGUpe3JldHVybiB0Ll9maWxlb3AoImNhdCIsZSl9LGxzKGUpe3JldHVybiB0Ll9maWxlb3AoImxzIixlKX0sZG93bmxvYWQoZSl7cmV0dXJuIHQuX2ZpbGVvcCgiZG93bmxvYWQiLGUpfSxwd2QoKXtyZXR1cm4gdC5mcy5jd2QoKX0sY2QoZSl7Zm9yKGxldCByIG9mIHQudG9vbHMpIXIubW9kdWxlfHxyLm1vZHVsZS5GUy5jaGRpcihlKX0sbWtkaXIoZSl7cmV0dXJuIHQuZnMubWtkaXIoZSksITB9LHJlYWQoe3BhdGg6ZSxsZW5ndGg6cixmbGFnOmk9InIiLG9mZnNldDpzPTAscG9zaXRpb246bz0wfSl7Y29uc3QgYT10LmZzLm9wZW4oZSxpKSxuPW5ldyBVaW50OEFycmF5KHIpO3JldHVybiB0LmZzLnJlYWQoYSxuLHMscixvKSx0LmZzLmNsb3NlKGEpLG59LHdyaXRlKHtwYXRoOmUsYnVmZmVyOnIsZmxhZzppPSJ3KyIsb2Zmc2V0OnM9MCxwb3NpdGlvbjpvPTB9KXtjb25zdCBhPXQuZnMub3BlbihlLGkpO3QuZnMud3JpdGUoYSxyLHMsci5sZW5ndGgsbyksdC5mcy5jbG9zZShhKX0sYXN5bmMgcmVpbml0KGUpe2NvbnN0IHI9dC50b29scy5maW5kKHM9PnMudG9vbD09ZSksaT10LmJhc2UubW9kdWxlLkZTLmN3ZCgpO09iamVjdC5hc3NpZ24ocixyLmNvbmZpZyksci5yZWFkeT0hMSxhd2FpdCB0aGlzLmluaXQoKSxyLmlzQmFzZU1vZHVsZSYmdGhpcy5tb3VudCgpLHRoaXMuY2QoaSl9LF9zdGRpblR4dDoiIixfc3RkaW5QdHI6MCxnZXQgc3RkaW4oKXtyZXR1cm4gdC5fc3RkaW5UeHR9LHNldCBzdGRpbihlPSIiKXt0Ll9sb2coYFNldHRpbmcgc3RkaW4gdG8gJWMke2V9JWNgLCJjb2xvcjpkYXJrYmx1ZSIsIiIpLHQuX3N0ZGluVHh0PWUsdC5fc3RkaW5QdHI9MH0sYXN5bmMgX3NldHVwKGUpe2lmKGUucmVhZHkpcmV0dXJuO2lmKHQuX2xvZyhgU2V0dGluZyB1cCAke2UudG9vbH0gKGJhc2UgPSAke2UuaXNCYXNlTW9kdWxlPT09ITB9KS4uLmApLGUuY29uZmlnPU9iamVjdC5hc3NpZ24oe30sZSksZS51cmxQcmVmaXh8fChlLnVybFByZWZpeD1gJHt0LmNvbmZpZy51cmxDRE59LyR7ZS50b29sfS8ke2UudmVyc2lvbn1gKSxlLnByb2dyYW18fChlLnByb2dyYW09ZS50b29sKSxlLmZlYXR1cmVzfHwoZS5mZWF0dXJlcz17fSwoaltlLnByb2dyYW1dfHxbXSkuaW5jbHVkZXMoInNpbWQiKSYmKGF3YWl0IFcoKT8oZS5wcm9ncmFtKz0iLXNpbWQiLGUuZmVhdHVyZXMuc2ltZD0hMCk6dC5fbG9nKGBXZWJBc3NlbWJseSBTSU1EIGlzIG5vdCBzdXBwb3J0ZWQgaW4gdGhpcyBicm93c2VyOyB3aWxsIGxvYWQgbm9uLVNJTUQgdmVyc2lvbiBvZiAke2UucHJvZ3JhbX0uYCkpKSxlLmlzQmFzZU1vZHVsZSYmKGUubG9hZGluZz1rKSxlLmxvYWRpbmc9PT14KXt0Ll9sb2coYFdpbGwgbGF6eS1sb2FkICR7ZS50b29sfTsgc2tpcHBpbmcgaW5pdGlhbGl6YXRpb24uYCk7cmV0dXJufXNlbGYuaW1wb3J0U2NyaXB0cyhgJHtlLnVybFByZWZpeH0vJHtlLnByb2dyYW19LmpzYCksZS5tb2R1bGU9YXdhaXQgTW9kdWxlKHt0aGlzUHJvZ3JhbTplLnByb2dyYW0sbG9jYXRlRmlsZTooaSxzKT0+YCR7ZS51cmxQcmVmaXh9LyR7aX1gLHN0ZGluOigpPT50Ll9zdGRpblB0cjx0LnN0ZGluLmxlbmd0aD90LnN0ZGluLmNoYXJDb2RlQXQodC5fc3RkaW5QdHIrKyk6KHQuc3RkaW49IiIsbnVsbCkscHJpbnQ6aT0+e3QuY29uZmlnLnByaW50U3RyZWFtP3Bvc3RNZXNzYWdlKHt0eXBlOiJiaW93YXNtIix2YWx1ZTp7c3Rkb3V0Oml9fSk6ZS5zdGRvdXQrPWkrYApgfSxwcmludEVycjppPT57Y29uc3Qgcz10LmNvbmZpZy5wcmludEludGVybGVhdmVkPyJzdGRvdXQiOiJzdGRlcnIiO3QuY29uZmlnLnByaW50U3RyZWFtP3Bvc3RNZXNzYWdlKHt0eXBlOiJiaW93YXNtIix2YWx1ZTp7W3NdOml9fSk6ZVtzXSs9aStgCmB9fSk7Y29uc3Qgcj1lLm1vZHVsZS5GUztlLmlzQmFzZU1vZHVsZT8odC5fbG9nKGBTZXR0aW5nIHVwICR7ZS50b29sfSB3aXRoIGJhc2UgbW9kdWxlIGZpbGVzeXN0ZW0uLi5gKSxyLm1rZGlyKHQuY29uZmlnLmRpclNoYXJlZCw1MTEpLHIubWtkaXIoYCR7dC5jb25maWcuZGlyU2hhcmVkfS8ke3QuY29uZmlnLmRpckRhdGF9YCw1MTEpLHIubWtkaXIoYCR7dC5jb25maWcuZGlyU2hhcmVkfS8ke3QuY29uZmlnLmRpck1vdW50ZWR9YCw1MTEpLHIuY2hkaXIoYCR7dC5jb25maWcuZGlyU2hhcmVkfS8ke3QuY29uZmlnLmRpckRhdGF9YCksdC5mcz1yKToodC5fbG9nKGBTZXR0aW5nIHVwICR7ZS50b29sfSB3aXRoIGZpbGVzeXN0ZW0uLi5gKSxyLm1rZGlyKHQuY29uZmlnLmRpclNoYXJlZCksci5tb3VudChlLm1vZHVsZS5QUk9YWUZTLHtyb290OnQuY29uZmlnLmRpclNoYXJlZCxmczp0LmZzfSx0LmNvbmZpZy5kaXJTaGFyZWQpLHIuY2hkaXIodC5mcy5jd2QoKSkpLGUuc3Rkb3V0PSIiLGUuc3RkZXJyPSIiLGUucmVhZHk9ITB9LGFzeW5jIF9zZXR1cEZTKCl7Y29uc3QgZT10LmZzO2ZvcihsZXQgciBvZiB0LnRvb2xzKXtpZighci5yZWFkeSljb250aW51ZTtjb25zdCBpPXIubW9kdWxlLkZTLHM9YC8ke3IudG9vbH1gLG89YCR7dC5jb25maWcuZGlyU2hhcmVkfSR7c31gOyFpLmFuYWx5emVQYXRoKHMpLmV4aXN0c3x8ZS5hbmFseXplUGF0aChvKS5leGlzdHN8fCh0Ll9sb2coYE1vdW50aW5nICR7c30gb250byAke3QuYmFzZS50b29sfSBmaWxlc3lzdGVtIGF0ICR7b31gKSxlLm1rZGlyKG8pLGUubW91bnQodC5iYXNlLm1vZHVsZS5QUk9YWUZTLHtyb290OnMsZnM6aX0sbykpfX0sX2ZpbGVvcChlLHIpe3QuX2xvZyhgUnVubmluZyAke2V9ICR7cn1gKTtjb25zdCBpPXQuZnMuYW5hbHl6ZVBhdGgocik7aWYoIWkuZXhpc3RzKXJldHVybiB0Ll9sb2coYEZpbGUgJHtyfSBub3QgZm91bmQuYCksITE7c3dpdGNoKGUpe2Nhc2UiY2F0IjpyZXR1cm4gdC5mcy5yZWFkRmlsZShyLHtlbmNvZGluZzoidXRmOCJ9KTtjYXNlImxzIjpyZXR1cm4gdC5mcy5pc0ZpbGUoaS5vYmplY3QubW9kZSk/dC5mcy5zdGF0KHIpOnQuZnMucmVhZGRpcihyKTtjYXNlImRvd25sb2FkIjpjb25zdCBzPW5ldyBCbG9iKFt0aGlzLmNhdChyKV0pO3JldHVybiBVUkwuY3JlYXRlT2JqZWN0VVJMKHMpfXJldHVybiExfSxfbG9nKGUpe2lmKCF0LmNvbmZpZy5kZWJ1ZylyZXR1cm47bGV0IHI9Wy4uLmFyZ3VtZW50c107ci5zaGlmdCgpLGNvbnNvbGUubG9nKGAlY1tXZWJXb3JrZXJdJWMgJHtlfWAsImZvbnQtd2VpZ2h0OmJvbGQiLCIiLC4uLnIpfX07dyh0KX0pKCk7Cg==",P=typeof window<"u"&&window.Blob&&new Blob([atob(_)],{type:"text/javascript;charset=utf-8"});function M(){const e=P&&(window.URL||window.webkitURL).createObjectURL(P);try{return e?new Worker(e):new Worker("data:application/javascript;base64,"+_)}finally{e&&(window.URL||window.webkitURL).revokeObjectURL(e)}}const x={urlCDN:"https://biowasm.com/cdn/v3",urlCDNStg:"https://stg.biowasm.com/cdn/v3",dirShared:"/shared",dirMounted:"/mnt",dirData:"/data",printInterleaved:!0,printStream:!1,callback:null,debug:!1,env:"prd"};class N{constructor(e,t={}){if(null==e)throw"Expecting array of tools as input to Aioli constructor.";return Array.isArray(e)||(e=[e]),t=Object.assign({},x,t),e=e.map(this._parseTool),"stg"===t.env&&(t.urlCDN=t.urlCDNStg),this.tools=e,this.config=t,null!=this.config.callback&&(this.callback=this.config.callback),delete this.config.callback,this.init()}async init(){const e=new M;this.callback&&(e.onmessage=e=>{"biowasm"===e.data.type&&this.callback(e.data.value)});const t=y(e);return t.tools=this.tools,t.config=this.config,await t.init(),t}_parseTool(e){if("string"!=typeof e)return e;const t=e.split("/");if(2!=t.length&&3!=t.length)throw"Expecting '<tool>/<version>' or '<tool>/<program>/<version>'";return{tool:t[0],program:3==t.length?t[1]:t[0],version:t[t.length-1]}}}var $=n(3629);class L{static getAvailableScales(){return Object.entries(this.scales).map((([e,t])=>e))}static getScale(e){return(0,$.vA)(!(void 0===this.scales[e]),`Scale '${e}' was not found.`),this.scales[e]}}L.scales={WimleyWhite:{"-":0,A:.17,C:-.24,D:-.07,E:-.01,F:-1.13,G:.01,H:.17,I:-.31,K:.99,L:-.56,M:-.23,N:.42,P:.45,Q:.58,R:.81,S:.13,T:.14,V:.07,W:-1.85,Y:-.94},categorial:{"-":0,A:1,C:2,D:3,E:4,F:5,G:6,H:7,I:8,K:9,L:10,M:11,N:12,P:13,Q:14,R:15,S:16,T:17,V:18,W:19,Y:20}};class I{constructor(e="categorial"){this.aa2num=L.getScale(e),this.num2aa={},Object.entries(this.aa2num).forEach((([e,t])=>this.num2aa[t]=e))}static _truncateSequence(e){let t=0,n=e.length;const r=["NH2","COOH"];if(e.startsWith(r[0])){const n=r[0].length;(0,$.vA)("-"==e[n],`Wrong sequence format: ${r[0]} without following '-' in '${e}'.`),t=n}if(e.endsWith(r[1])){const t=r[1].length+1;(0,$.vA)("-"==e[n-t],`Wrong sequence format: ${r[1]} without '-' precending in '${e}'.`),n-=t}return e.substring(t,n)}static _dropDefises(e){return e.replace(/(-)([^-]+)/g,"$2")}static clean(e){return I._dropDefises(I._truncateSequence(e))}encode(e){const t=e.length,n=new Array(t).fill(0);for(let r=0;r<t;++r){const t=e[r];(0,$.vA)(t in this.aa2num,`Unknown char '${t}' found in sequence '${e}'`),n[r]=this.encodeLettter(t)}return n}encodeLettter(e){return this.aa2num[e]}decode(e){let t="";for(let n=0;n<e.length;++n){const r=e[n];(0,$.vA)(r in this.num2aa,`Unknown code '${r}' found in vector '${e}'`),t+=this.num2aa[r]}return t}}var R=n(4139);const O="input.fa",k="result.fasta";class G extends Error{element;constructor(e,t){super(e.innerText,t),this.element=e}}function D(e){return e.reduce(((e,t,n)=>e+`>sample${n+1}\n${t}\n`),"")}async function H(e,t,n=!1,r="",s=null,i,l,u,d){let h=t.toList();n&&(h=h.map((e=>I.clean(e).replace(/\-/g,""))));const p=t.length;s??=o.Column.string("Clusters",p).init("0"),s.type!=o.COLUMN_TYPE.STRING&&(s=s.convertTo(o.TYPE.STRING)),s.compact();const m=s.categories,f=s.getRawData(),g=new Array(m.length),y=new Array(m.length);if(d){const t=e.selection;if(0===t.length)throw new Error("No selected rows in the table.");for(let e=-1;-1!==(e=t.findNext(e,!0));){const t=f[e];(g[t]??=[]).push(h[e]),(y[t]??=[]).push(e)}}else for(let e=0;e<p;++e){const t=f[e];(g[t]??=[]).push(h[e]),(y[t]??=[]).push(e)}V(y,m);const b=await new N(["base/1.0.0",{tool:"kalign",version:R.b9,reinit:!0}]),w=o.Column.string(r,p);for(let e=0;e<m.length;++e){const t=g[e];if(!t||0===t.length)continue;const n=D(t);await b.fs.writeFile(O,n);const r=`${void 0!==i?` --gpo ${i}`:""}${void 0!==l?` --gpe ${l}`:""}${void 0!==u?` --tgpe ${u}`:""}`,o=await b.exec(`kalign ${O} -f fasta -o ${k}${r}`);console.warn(o);const s=await b.cat(k);if(!s){const e=F(o,1);throw new Error(e)}const c=new a.m(s).sequencesArray,d=y[e];for(let e=0;e<c.length;++e)w.set(d[e],c[e])}const v=t.meta.units,A=t.getTag(c.gp.alphabet);return w.meta.units=v,w.setTag(c.gp.aligned,"SEQ.MSA"),w.setTag(c.gp.alphabet,A),w.semType=o.SEMTYPE.MACROMOLECULE,w}function F(e,t){const n=[],r=/^.+ERROR : (.+)$/gm;let o;for(;null!=(o=r.exec(e))&&(void 0===t||n.length<t);)n.push(o[1]);return n.join("\n")}function V(e,t){const n=e.map(((e,t)=>[e,t])).filter((([e,t])=>1==e.length)).map((([e,t])=>t));if(n.length>0){const e=r.div([r.divText(`MSA analysis is not available on single sequence clusters #${n.length}:`),...i()(n).take(3).map((e=>{let o=t[e];return o.length>25&&(o=o.slice(0,25)+"..."),r.divText(`"${o}"${e<n.length-1?", ":"."}`)})).toArray(),...n.length>3?[r.divText("...")]:[]]);throw new G(e)}}},8152:(e,t,n)=>{"use strict";n.d(t,{GD:()=>h,ZY:()=>u});var r=n(4328),o=n(6082),s=n(2003),i=n(608),a=n(4139),c=n(6723);const l=new class{dcName="bio";async getDockerContainer(){return await r.dapi.docker.dockerContainers.filter(this.dcName).first()}},u=["mafft --auto","mafft","linsi","ginsi","einsi","fftns","fftnsi","nwns","nwnsi"],d=["AlignedSeq","AlignedSubpeptide","HELM","ID","PolymerID"];async function h(e,t,n,r="ginsi",c=1.53,u=0,h=null,m,f=!1){const g=await l.getDockerContainer(),y=t.length;h??=o.Column.int("Clusters",y).init(0),h.type!=o.COLUMN_TYPE.STRING&&(h=h.convertTo(o.TYPE.STRING));const b=h.categories,w=h.getRawData(),v=new Array(b.length),A=new Array(b.length);if(f){const n=e.selection;for(let e=-1;-1!==(e=n.findNext(e,!0));){const n=w[e];if(!b[n])continue;const r=n,o=t.get(e);o&&((v[r]??=[]).push({ID:e.toString(),HELM:o}),(A[n]??=[]).push(e))}}else for(let e=0;e<y;++e){const n=w[e];if(!b[n])continue;const r=n,o=t.get(e);o&&((v[r]??=[]).push({ID:e.toString(),HELM:o}),(A[n]??=[]).push(e))}(0,i.aZ)(A,b);const E=new Array(y).fill(null);for(const e of v){if(!e||0===e.length)continue;const t=(await p(g.id,e,r,c,u,m)).Alignment;for(const e of t)E[parseInt(e.ID)]=Object.entries(e).filter((e=>!d.includes(e[0]))).map((e=>"-"!==e[1]?e[1]:"")).join(a.J.SEPARATOR)}const C=o.Column.fromStrings(n,E);return C.meta.units=s.Hi.SEPARATOR,C.setTag(s.gp.separator,a.J.SEPARATOR),C.setTag(s.gp.aligned,"SEQ.MSA"),C.setTag(s.gp.alphabet,s.YI.UN),C.setTag(s.gp.alphabetIsMultichar,"true"),C.semType=o.SEMTYPE.MACROMOLECULE,C}async function p(e,t,n,o,s,i){const a={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(t)},l=`/align?method=${n}&gap_open=${o}&gap_extend=${s}`,u=window.performance.now(),d=await r.dapi.docker.dockerContainers.fetchProxy(e,l,a),h=window.performance.now();c._package.logger.debug(`Bio: requestAlignedObjects() dockerContainers.fetchProxy(), ET: ${h-u} ms`);const p="application/json"===d.headers.get("content-type");if(!d.ok&&p){const e=await d.json(),t=e["pepsea-error"];if(t)throw new Error(`PepSeA error: ${t}`);const n=e["datagrok-error"];if(n)throw new Error(`Datagrok error: ${n}`);throw new Error(d.statusText)}if(!d.ok&&!p){const e=await d.text();throw new Error(`Error: ${e}`)}if(!p){const e=await d.text();throw new Error(`Error: PepSeA expected JSON response, got '${e}'.`)}const m=await d.json();if("pepsea-stderr"in m){const e=m["pepsea-stderr"];i?.warning(e)}return m}},3890:(e,t,n)=>{"use strict";n.d(t,{aS:()=>a,wz:()=>i}),n(6082),n(7389),n(4328);var r=n(1991),o=n.n(r);n(6723);const s=60;function i(e,t,n=s,r="\n"){const o=[];for(let s=0;s<t.length;s++){const i=e.map((e=>e.get(s).toString())).join("|"),c=a(t.getSplitted(s),n);o.push(`>${i}${r}`);for(const e of c)o.push(`${e}${r}`)}return"".concat(...o)}function a(e,t=s){let n=0;const r=e.length,i=[];for(;n<r;){const r=o().count(n).take(Math.min(e.length-n,t)).map((t=>e.getOriginal(t))).toArray(),s=r.map((e=>e.length>1?`[${e}]`:e)).reduce(((e,t)=>e+t),"");i.push(s),n+=r.length}return i}},8754:(e,t,n)=>{"use strict";n.d(t,{V:()=>u});var r=n(4328),o=n(6077),s=n(2003),i=n(8312),a=n(5553),c=n(966),l=n(330);async function u(e,t,n,u,d,h,p){let m;if(n){const n=await(0,i.Q)(),r=n.getSeqHandler(t);let o,a;r.isHelm()?o=t:(a=t.name,t.name=`__${a}`,o=r.convert(s.Hi.HELM),o.name=a,e.columns.add(o,!1));try{m=await n.helmToAtomicLevel(o,!0,!0,d)}finally{o!==t&&(e.columns.remove(o.name),t.name=a)}}else{if(!(0,c.l)(t,"To Atomic Level",h)[0])return{molCol:null,warnings:["Column is not suitable"]};m=await(0,o.C4)(e,t,d,h,p)}if(m.molCol){const o=(0,l.qj)(e,t.name);m.molCol.name=o,e.columns.add(m.molCol,!0),await(0,a.Qc)(t,m.molCol,d,h,p,n),m.molCol.setTag(".sequence-src-highlight-monomers",String(u)),await r.data.detectSemanticTypes(e)}return m}},4870:(e,t,n)=>{"use strict";function r(e,t){e.innerHTML="",e.append(t)}function o(e,t,n,r,o){const s=()=>{const o=e.col(t);o&&(o.width=n),r&&(e.props.rowHeight=r)};if(o)return void s();const i=e.onAfterDrawOverlay.subscribe((()=>{i.unsubscribe(),setTimeout((()=>{s()}))}))}n.d(t,{Kd:()=>o,Ku:()=>r}),n(4328),n(6082)},250:(e,t,n)=>{"use strict";n.d(t,{VN:()=>m,n5:()=>l,Ue:()=>p,Tc:()=>h,eN:()=>f}),n(4328),n(7389);var r=n(6082),o=(n(1757),n(1991),n(1858),n(2003)),s=n(4326);n(8070),n(7602);var i=n(439),a=n(6882);n(6723);var c,l,u,d=n(6307);HTMLCanvasElement.prototype.getCursorPosition=function(e,t){const n=this.getBoundingClientRect();return new r.Point((e.clientX-n.left)*t,(e.clientY-n.top)*t)},r.Rect.prototype.contains=function(e,t){return this.left<=e&&e<=this.right&&this.top<=t&&t<=this.bottom};class h{rowCount;value;plotValue;valueList=null;valueIdx=0;bounds;constructor(e=0,t){this.value=this.rowCount=e,this.bounds=t}push(e){this.valueList||(this.valueList=new Array(this.rowCount),this.valueIdx=0),this.valueList[this.valueIdx]=e,++this.valueIdx}aggregate(e){this.value=e(this.valueList)??0,this.valueList=null}}class p{pos;name;_label;get label(){return this._label?this._label:this.name}_freqs;sumRowCount=0;sumPlotValue;sumPlotValueForHeight;constructor(e,t,n,r){this.pos=e,this.name=t,this._freqs=n??{},r?.sumRowCount&&(this.sumRowCount=r.sumRowCount),r?.sumValueForHeight&&(this.sumPlotValue=r.sumValueForHeight),r?.label&&(this._label=r.label)}getMonomers(){return Object.keys(this._freqs)}hasMonomer(e){return e in this._freqs}getFreq(e){let t=this._freqs[e];return t||(t=this._freqs[e]=new h),t}aggregate(e){const t=function(e){return t=>{const n=function(e){let t;const n="agg";return t=e instanceof Float32Array?r.Column.fromFloat32Array(n,e):e instanceof Int32Array?r.Column.fromInt32Array(n,e):r.Column.fromList(r.COLUMN_TYPE.FLOAT,n,e),t}(t);return n.aggregate(e)}}(e);for(const[e,n]of Object.entries(this._freqs))n.aggregate(t)}getMinValue(){return Math.min(...Object.values(this._freqs).map((e=>e.value)))}calcPlotValue(e){for(const t of Object.values(this._freqs))t.plotValue=t.value-e}calcHeights(e){this.sumPlotValue=0;for(const e of Object.values(this._freqs))this.sumPlotValue+=e.plotValue;if(this.sumPlotValueForHeight=0,e===s.fH.Entropy){const e=Object.keys(this._freqs).length,t=.01*this.sumPlotValue,n=t/e;for(const e of Object.values(this._freqs)){const r=(e.plotValue+n)/(this.sumPlotValue+t);this.sumPlotValueForHeight+=-r*Math.log2(r)}}else if(e===s.fH.full)for(const[e,t]of Object.entries(this._freqs)){const e=t.plotValue/this.sumPlotValue;this.sumPlotValueForHeight+=e}}calcScreen(e,t,n,o,a,c,l,u,d){const h=o===s.fH.Entropy?n*(a-this.sumPlotValueForHeight)/a:n;let p=d*u+(n-h-1);const m=Object.entries(this._freqs).sort(((e,t)=>e[0]!==i._S&&t[0]!==i._S?t[1].value-e[1].value:e[0]===i._S&&t[0]===i._S?0:e[0]===i._S?-1:1));for(const[n,o]of m){const n=h*o.plotValue/this.sumPlotValue;o.bounds=new r.Rect((e-t)*u*c,p,l*u,n),p+=n}}render(e,t,n,r,s,c,l){for(const[u,d]of Object.entries(this._freqs))if(u!==i._S){const i=(0,o.zS)(u,l),h=d.bounds,p=h.left;let m=a.S$;c&&(m=c.getMonomerTextColor(s,u)),e.resetTransform(),e.strokeStyle="lightgray",e.lineWidth=1,e.rect(p,h.top,h.width,h.height),e.fillStyle=m,e.textAlign="left",e.font=t;const f=e.measureText(i);e.setTransform(h.width/f.width,0,0,h.height/r,p,h.top),e.fillText(i,0,-n)}}getMonomerAt(e,t){const n=Object.entries(this._freqs).find((([n,r])=>r.bounds.contains(e,t)));return n?n[0]:void 0}buildCompositionTable(e,t){if("-"in this._freqs)throw new Error("Unexpected monomer symbol '-'.");return(0,d.F)(Object.assign({},...Object.entries(this._freqs).map((([e,t])=>({[e]:t.rowCount})))),e,t)}}!function(e){e.STYLE="Style",e.BEHAVIOR="Behavior",e.LAYOUT="Layout",e.DATA="Data"}(c||(c={})),function(e){e.sequenceColumnName="sequenceColumnName",e.valueAggrType="valueAggrType",e.valueColumnName="valueColumnName",e.startPositionName="startPositionName",e.endPositionName="endPositionName",e.skipEmptySequences="skipEmptySequences",e.skipEmptyPositions="skipEmptyPositions",e.shrinkEmptyTail="shrinkEmptyTail",e.backgroundColor="backgroundColor",e.positionHeight="positionHeight",e.positionWidth="positionWidth",e.verticalAlignment="verticalAlignment",e.horizontalAlignment="horizontalAlignment",e.fixWidth="fixWidth",e.fitArea="fitArea",e.minHeight="minHeight",e.maxHeight="maxHeight",e.maxMonomerLetters="maxMonomerLetters",e.showPositionLabels="showPositionLabels",e.positionMarginState="positionMarginState",e.positionMargin="positionMargin",e.filterSource="filterSource"}(l||(l={})),s.Fo,function(e){e[e.None=0]="None",e[e.Render=1]="Render",e[e.Layout=1]="Layout",e[e.Freqs=2]="Freqs"}(u||(u={}));const m=new class{render=20};function f(e,t,n,r,o){let s=0,i=-1;for(;-1!=(i=n.findNext(i,!0));){const e=t.getSplitted(i),n=o.pos,a=n<e.length?e.getCanonical(n):null;null!==a&&a===r&&s++}return s}r.JsViewer},1687:(e,t,n)=>{"use strict";n.d(t,{_i:()=>T,AR:()=>C});var r=n(7389),o=n(6082),s=n(4328),i=n(1991),a=n.n(i),c=n(1858),l=n(2003),u=n(8070),d=n(7602),h=n(4954),p=n(4574),m=n(1757),f=n.n(m),g=n(9124),y=n(9192),b=n(4870),w=n(6723);class v extends p.O{seqHelper;emptyProps=new p.n("",void 0,w._package.logger);helmEditor;_filterPanel=r.div("",{style:{cursor:"pointer"}});logger;static viewerCounter=-1;viewerId=++v.viewerCounter;viewerToLog(){return`HelmBioFilter<${this.viewerId}>`}get type(){return"HelmBioFilter"}constructor(e){super(),this.seqHelper=e,this.logger=w._package.logger}viewSubs=[];async detach(){await super.detach();for(const e of this.viewSubs)e.unsubscribe()}async attach(){this.viewerToLog();try{const e=await(0,g.b2)();let t,n;this.helmEditor=e.createHelmWebEditor(),this.logger.warning("TEST: HelmBioFilter.init().sync() waitForElementInDom waiting..."),await r.tools.waitForElementInDom(this._filterPanel),this.logger.warning("TEST: HelmBioFilter.init().sync() waitForElementInDom ready"),this.updateFilterPanel(),this.viewSubs.push((0,c.fromEvent)(this._filterPanel,"click").subscribe((()=>{t=r.div(),n=e.createWebEditorApp(t,this.props.substructure),r.dialog({showHeader:!1,showFooter:!0}).add(t).onOK((()=>{try{const e=n.canvas.getHelm(!0).replace(/<\/span>/g,"").replace(/<span style='background:#bbf;'>/g,"");this.props=new p.n(e,void 0,w._package.logger)}catch(e){this.logger.error(e)}finally{f()(t).empty(),t=null,n=null}})).onCancel((()=>{f()(t).empty(),t=null,n=null})).show({modal:!0,fullScreen:!0})}))),this.viewSubs.push(r.onSizeChanged(this._filterPanel).subscribe((e=>{try{if(n){const e=n.canvas.getHelm(!0).replace(/<\/span>/g,"").replace(/<span style='background:#bbf;'>/g,"");this.updateFilterPanel(e)}}catch(e){const[t,n]=(0,y.AP)(e);this.logger.error(t,void 0,n)}})))}catch(e){const[t,n]=(0,y.AP)(e),o=this._filterPanel;o.innerText="error",o.classList.add("d4-error"),r.tooltip.bind(o,t)}}applyProps(){this.helmEditor&&this.updateFilterPanel(this.props.substructure)}get filterPanel(){return this._filterPanel}updateFilterPanel(e){if(!this.helmEditor)throw new Error("helmEditor is not created, the filter is not in dom yet");const t=this._filterPanel.parentElement.clientWidth<100?100:this._filterPanel.parentElement.clientWidth,n=t/2;if(e)(0,b.Ku)(this._filterPanel,this.helmEditor.host),this.helmEditor.editor.setHelm(e),this.helmEditor.resizeEditor(t,n);else{const e=r.divText("Click to edit","helm-substructure-filter");(0,b.Ku)(this._filterPanel,e)}}async substructureSearch(e){const t=`${this.viewerToLog()}.substructureSearch( column = <${e.name}> )`;w._package.logger.debug(`${t}, start`);try{return await(0,u.cb)(10),await(0,h.if)(this.props.substructure,e,this.seqHelper)}finally{w._package.logger.debug(`${t}, end`)}}}const A="bio-substructure-filter";class E{props;filterId;dataFrameId;columnName;bitset;constructor(e,t,n,r,o){this.props=e,this.filterId=t,this.dataFrameId=n,this.columnName=r,this.bitset=o}}class C extends p.n{separator;constructor(e,t,n){super(e,!1,n),this.separator=t,this.readOnly=!0}}class T extends o.Filter{seqHelper;logger;bioFilter=null;bitset=null;loader;notation=void 0;filterSyncer;get calculating(){return"initial"==this.loader.style.display}set calculating(e){this.loader.style.display=e?"initial":"none"}get filterSummary(){return this.bioFilter.filterSummary}get isFiltering(){return super.isFiltering&&(this.bioFilter?.isFiltering??!1)}get isReadyToApplyFilter(){return!this.calculating&&null!=this.bitset}get debounceTime(){if(null==this.column)return 1e3;const e=this.column.length;return e<500?0:e>1e4?1e3:Math.floor((e-500)/9500*1e3)}constructor(e,t){super(),this.seqHelper=e,this.logger=t,this.root=r.divV([]),this.loader=r.loader(),this.calculating=!1,this.filterSyncer=new d.g(this.logger)}static filterCounter=-1;filterId=++T.filterCounter;filterToLog(){return`BioSubstructureFilter<${this.filterId}>`}viewSubs=[];attach(e){const t=super.attach.bind(this),n=`${this.filterToLog()}.attach()`;this.filterSyncer.sync(n,(async()=>{t(e),this.column||(this.columnName?this.column=this.dataFrame.getCol(this.columnName):this.column=e.columns.bySemType(o.SEMTYPE.MACROMOLECULE)),this.seqHelper.getSeqHandler(this.column),this.columnName??=this.column?.name,this.notation??=this.column?.meta.units,this.bioFilter=this.notation===l.Hi.FASTA?new S:this.notation===l.Hi.SEPARATOR?new _(this.column.getTag(l.gp.separator)):new v(this.seqHelper),this.root.appendChild(this.bioFilter.filterPanel),this.root.appendChild(this.loader),await this.bioFilter.attach(),this.viewSubs.push(o.debounce(this.bioFilter.onChanged,this.debounceTime).subscribe(this.bioFilterOnChangedDebounced.bind(this))),this.viewSubs.push(s.events.onResetFilterRequest.subscribe(this.grokEventsOnResetFilterRequest.bind(this))),this.viewSubs.push(s.events.onCustomEvent(A).subscribe(this.filterOnSync.bind(this)))}))}detach(){const e=super.detach.bind(this),t=`${this.filterToLog()}.detach()`;this.filterSyncer.sync(t,(async()=>{for(const e of this.viewSubs)e.unsubscribe();this.viewSubs=[],e(),this.bioFilter&&this.bioFilter.detach(),this.bioFilter=null}))}filterOnSync(e){e.filterId!==this.filterId&&e.dataFrameId===this.dataFrame.id&&e.columnName===this.columnName&&(this.bioFilter.props=e.props)}applyFilter(){const e=`${this.filterToLog()}.applyFilter()`;this.logger.debug(`${e}, IN`),this.bitset&&!this.isDetached&&this.dataFrame?.filter.and(this.bitset)}saveState(){const e=`${this.filterToLog()}.saveState()`,t=super.saveState();return this.logger.debug(`${e}, super.state = ${JSON.stringify(t)}`),t.props=this.bioFilter.saveProps(),t}applyState(e){const t=`${this.filterToLog()}.applyState()`;super.applyState(e),this.filterSyncer.sync(t,(async()=>{e.props&&this.bioFilter&&(this.bioFilter.props=o.toJs(e.props??{}))}))}fireFilterSync(){const e=`${this.filterToLog()}.fireFilterSync()`;this.logger.debug(`${e}, bioFilter = ${this.bioFilter?this.bioFilter.constructor.name:"null"}`+(this.bioFilter?`, props = ${JSON.stringify(this.bioFilter.saveProps())}`:"")),s.events.fireCustomEvent(A,new E(this.bioFilter.props,this.filterId,this.dataFrame.id,this.columnName,this.bitset))}bioFilterOnChangedDebounced(){if(!this.dataFrame)return;const e=`${this.filterToLog()}.bioFilterOnChangedDebounced()`;if(this.logger.debug(`${e}, start, isFiltering = ${this.isFiltering}, props = ${JSON.stringify(this.bioFilter.saveProps())}`),!this.isFiltering)return this.bitset=null,void this.dataFrame.rows.requestFilter();a()(this.dataFrame.rows.filters).has(`${this.columnName}: ${this.filterSummary}`)||this.filterSyncer.sync(e,(async()=>{this.calculating=!0;try{this.logger.debug(`${e}, before substructureSearch`),this.bitset=await(this.bioFilter?.substructureSearch(this.column)),this.logger.debug(`${e}, after substructureSearch`),this.calculating=!1,this.fireFilterSync(),this.dataFrame?.rows.requestFilter()}finally{this.calculating=!1,this.logger.debug(`${e}, end`)}}))}grokEventsOnResetFilterRequest(){const e=`${this.filterToLog()}.grokEventsOnResetFilterRequest()`;this.logger.debug(`${e}`),this.bioFilter?.resetFilter()}_onRendered=new c.Subject;get onRendered(){return this._onRendered}invalidate(e){const t=`${this.filterToLog()}.invalidate(${e?` <- ${e} `:""})`;this.filterSyncer.sync(t,(async()=>{this._onRendered.next()}))}async awaitRendered(e=1e4){const t=`awaitRendered( ${e} )`,n=`${this.filterToLog()}.${t}`;await(0,u.cb)(10),await(0,u.PE)(this.onRendered,(()=>{this.logger.debug(`${n}, _onRendered event caught`)}),(()=>{this.invalidate(t)}),e,`${n} timeout`);const r=this.filterSyncer.resetErrors();if(r.length>0)throw r[0]}}class S extends p.O{emptyProps=new p.n("",void 0,w._package.logger);substructureInput;get type(){return"FastaBioFilter"}constructor(){super(),this.substructureInput=r.input.string("",{value:"",onValueChanged:e=>{window.setTimeout((()=>{this.props=new p.n(e,void 0,w._package.logger),this._propsChanging||this.onChanged.next()}),0)},placeholder:"Substructure"})}applyProps(){this.substructureInput.value!==this.props.substructure&&(this.substructureInput.value=this.props.substructure)}get filterPanel(){return this.substructureInput.root}get isFiltering(){return""!==this.substructureInput.value}async substructureSearch(e){return(0,h.nI)(this.props.substructure,e)}async attach(){}async detach(){await super.detach()}}class _ extends p.O{emptyProps=new C("",void 0,w._package.logger);substructureInput;separatorInput;colSeparator="";get type(){return"SeparatorBioFilter"}constructor(e){super(),this.substructureInput=r.input.string("",{value:"",onValueChanged:e=>{this.props=new C(e,this.props.separator,w._package.logger),setTimeout((()=>{this._propsChanging||this.onChanged.next()}))},placeholder:"Substructure"}),this.separatorInput=r.input.string("",{value:this.colSeparator=e,onValueChanged:e=>{const t=e||"";this.props=new C(this.props.substructure,t,w._package.logger),setTimeout((()=>{this._propsChanging||this.onChanged.next()}))},placeholder:"Separator"})}applyProps(){this.substructureInput.value!==this.props.substructure&&(this.substructureInput.value=this.props.substructure);const e=this.props.separator??this.colSeparator;this.separatorInput.value!==e&&(this.separatorInput.value=e)}get filterSummary(){return this.props.separator?this.props.separator:this.colSeparator,`${this.props.substructure}, {sep}`}get isFiltering(){return""!==this.props.substructure}resetFilter(){this.props=new C("",void 0,w._package.logger)}get filterPanel(){return r.divV([this.substructureInput.root,this.separatorInput.root])}get substructure(){return this.separatorInput.value&&this.separatorInput.value!==this.colSeparator?this.substructureInput.value.replaceAll(this.separatorInput.value,this.colSeparator):this.substructureInput.value}set substructure(e){this.substructureInput.value=e}async substructureSearch(e){return(0,h.nI)(this.substructure,e,this.colSeparator)}async attach(){}async detach(){await super.detach()}}},1757:e=>{"use strict";e.exports=$},6082:e=>{"use strict";e.exports=DG},4328:e=>{"use strict";e.exports=grok},1858:e=>{"use strict";e.exports=rxjs},9713:e=>{"use strict";e.exports=rxjs.operators},7389:e=>{"use strict";e.exports=ui},1991:e=>{"use strict";e.exports=wu},8343:(e,t,n)=>{"use strict";const{normalizeIPv6:r,normalizeIPv4:o,removeDotSegments:s,recomposeAuthority:i,normalizeComponentEncoding:a}=n(4834),c=n(343);function l(e,t,n,r){const o={};return r||(e=p(u(e,n),n),t=p(u(t,n),n)),!(n=n||{}).tolerant&&t.scheme?(o.scheme=t.scheme,o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=s(t.path||""),o.query=t.query):(void 0!==t.userinfo||void 0!==t.host||void 0!==t.port?(o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=s(t.path||""),o.query=t.query):(t.path?("/"===t.path.charAt(0)?o.path=s(t.path):(void 0===e.userinfo&&void 0===e.host&&void 0===e.port||e.path?e.path?o.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+t.path:o.path=t.path:o.path="/"+t.path,o.path=s(o.path)),o.query=t.query):(o.path=e.path,void 0!==t.query?o.query=t.query:o.query=e.query),o.userinfo=e.userinfo,o.host=e.host,o.port=e.port),o.scheme=e.scheme),o.fragment=t.fragment,o}function u(e,t){const n={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:""},r=Object.assign({},t),o=[],a=c[(r.scheme||n.scheme||"").toLowerCase()];a&&a.serialize&&a.serialize(n,r),void 0!==n.path&&(r.skipEscape?n.path=unescape(n.path):(n.path=escape(n.path),void 0!==n.scheme&&(n.path=n.path.split("%3A").join(":")))),"suffix"!==r.reference&&n.scheme&&o.push(n.scheme,":");const l=i(n);if(void 0!==l&&("suffix"!==r.reference&&o.push("//"),o.push(l),n.path&&"/"!==n.path.charAt(0)&&o.push("/")),void 0!==n.path){let e=n.path;r.absolutePath||a&&a.absolutePath||(e=s(e)),void 0===l&&(e=e.replace(/^\/\//u,"/%2F")),o.push(e)}return void 0!==n.query&&o.push("?",n.query),void 0!==n.fragment&&o.push("#",n.fragment),o.join("")}const d=Array.from({length:127},((e,t)=>/[^!"$&'()*+,\-.;=_`a-z{}~]/u.test(String.fromCharCode(t)))),h=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function p(e,t){const n=Object.assign({},t),s={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},i=-1!==e.indexOf("%");let a=!1;"suffix"===n.reference&&(e=(n.scheme?n.scheme+":":"")+"//"+e);const l=e.match(h);if(l){if(s.scheme=l[1],s.userinfo=l[3],s.host=l[4],s.port=parseInt(l[5],10),s.path=l[6]||"",s.query=l[7],s.fragment=l[8],isNaN(s.port)&&(s.port=l[5]),s.host){const e=o(s.host);if(!1===e.isIPV4){const t=r(e.host);s.host=t.host.toLowerCase(),a=t.isIPV6}else s.host=e.host,a=!0}void 0!==s.scheme||void 0!==s.userinfo||void 0!==s.host||void 0!==s.port||void 0!==s.query||s.path?void 0===s.scheme?s.reference="relative":void 0===s.fragment?s.reference="absolute":s.reference="uri":s.reference="same-document",n.reference&&"suffix"!==n.reference&&n.reference!==s.reference&&(s.error=s.error||"URI is not a "+n.reference+" reference.");const e=c[(n.scheme||s.scheme||"").toLowerCase()];if(!(n.unicodeSupport||e&&e.unicodeSupport)&&s.host&&(n.domainHost||e&&e.domainHost)&&!1===a&&function(e){let t=0;for(let n=0,r=e.length;n<r;++n)if(t=e.charCodeAt(n),t>126||d[t])return!0;return!1}(s.host))try{s.host=URL.domainToASCII(s.host.toLowerCase())}catch(e){s.error=s.error||"Host's domain name can not be converted to ASCII: "+e}(!e||e&&!e.skipNormalize)&&(i&&void 0!==s.scheme&&(s.scheme=unescape(s.scheme)),i&&void 0!==s.host&&(s.host=unescape(s.host)),s.path&&(s.path=escape(unescape(s.path))),s.fragment&&(s.fragment=encodeURI(decodeURIComponent(s.fragment)))),e&&e.parse&&e.parse(s,n)}else s.error=s.error||"URI can not be parsed.";return s}const m={SCHEMES:c,normalize:function(e,t){return"string"==typeof e?e=u(p(e,t),t):"object"==typeof e&&(e=p(u(e,t),t)),e},resolve:function(e,t,n){const r=Object.assign({scheme:"null"},n);return u(l(p(e,r),p(t,r),r,!0),{...r,skipEscape:!0})},resolveComponents:l,equal:function(e,t,n){return"string"==typeof e?(e=unescape(e),e=u(a(p(e,n),!0),{...n,skipEscape:!0})):"object"==typeof e&&(e=u(a(e,!0),{...n,skipEscape:!0})),"string"==typeof t?(t=unescape(t),t=u(a(p(t,n),!0),{...n,skipEscape:!0})):"object"==typeof t&&(t=u(a(t,!0),{...n,skipEscape:!0})),e.toLowerCase()===t.toLowerCase()},serialize:u,parse:p};e.exports=m,e.exports.default=m,e.exports.fastUri=m},343:e=>{"use strict";const t=/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu,n=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;function r(e){return"boolean"==typeof e.secure?e.secure:"wss"===String(e.scheme).toLowerCase()}function o(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function s(e){const t="https"===String(e.scheme).toLowerCase();return e.port!==(t?443:80)&&""!==e.port||(e.port=void 0),e.path||(e.path="/"),e}const i={scheme:"http",domainHost:!0,parse:o,serialize:s},a={scheme:"ws",domainHost:!0,parse:function(e){return e.secure=r(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e},serialize:function(e){if(e.port!==(r(e)?443:80)&&""!==e.port||(e.port=void 0),"boolean"==typeof e.secure&&(e.scheme=e.secure?"wss":"ws",e.secure=void 0),e.resourceName){const[t,n]=e.resourceName.split("?");e.path=t&&"/"!==t?t:void 0,e.query=n,e.resourceName=void 0}return e.fragment=void 0,e}},c={http:i,https:{scheme:"https",domainHost:i.domainHost,parse:o,serialize:s},ws:a,wss:{scheme:"wss",domainHost:a.domainHost,parse:a.parse,serialize:a.serialize},urn:{scheme:"urn",parse:function(e,t){if(!e.path)return e.error="URN can not be parsed",e;const r=e.path.match(n);if(r){const n=t.scheme||e.scheme||"urn";e.nid=r[1].toLowerCase(),e.nss=r[2];const o=`${n}:${t.nid||e.nid}`,s=c[o];e.path=void 0,s&&(e=s.parse(e,t))}else e.error=e.error||"URN can not be parsed.";return e},serialize:function(e,t){const n=t.scheme||e.scheme||"urn",r=e.nid.toLowerCase(),o=`${n}:${t.nid||r}`,s=c[o];s&&(e=s.serialize(e,t));const i=e,a=e.nss;return i.path=`${r||t.nid}:${a}`,t.skipEscape=!0,i},skipNormalize:!0},"urn:uuid":{scheme:"urn:uuid",parse:function(e,n){const r=e;return r.uuid=r.nss,r.nss=void 0,n.tolerant||r.uuid&&t.test(r.uuid)||(r.error=r.error||"UUID is not valid."),r},serialize:function(e){const t=e;return t.nss=(e.uuid||"").toLowerCase(),t},skipNormalize:!0}};e.exports=c},4914:e=>{"use strict";e.exports={HEX:{0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15}}},4834:(e,t,n)=>{"use strict";const{HEX:r}=n(4914),o=/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u;function s(e){if(l(e,".")<3)return{host:e,isIPV4:!1};const t=e.match(o)||[],[n]=t;return n?{host:c(n,"."),isIPV4:!0}:{host:e,isIPV4:!1}}function i(e,t=!1){let n="",o=!0;for(const t of e){if(void 0===r[t])return;"0"!==t&&!0===o&&(o=!1),o||(n+=t)}return t&&0===n.length&&(n="0"),n}function a(e){if(l(e,":")<2)return{host:e,isIPV6:!1};const t=function(e){let t=0;const n={error:!1,address:"",zone:""},r=[],o=[];let s=!1,a=!1,c=!1;function l(){if(o.length){if(!1===s){const e=i(o);if(void 0===e)return n.error=!0,!1;r.push(e)}o.length=0}return!0}for(let i=0;i<e.length;i++){const u=e[i];if("["!==u&&"]"!==u)if(":"!==u)if("%"===u){if(!l())break;s=!0}else o.push(u);else{if(!0===a&&(c=!0),!l())break;if(t++,r.push(":"),t>7){n.error=!0;break}i-1>=0&&":"===e[i-1]&&(a=!0)}}return o.length&&(s?n.zone=o.join(""):c?r.push(o.join("")):r.push(i(o))),n.address=r.join(""),n}(e);if(t.error)return{host:e,isIPV6:!1};{let e=t.address,n=t.address;return t.zone&&(e+="%"+t.zone,n+="%25"+t.zone),{host:e,escapedHost:n,isIPV6:!0}}}function c(e,t){let n="",r=!0;const o=e.length;for(let s=0;s<o;s++){const i=e[s];"0"===i&&r?(s+1<=o&&e[s+1]===t||s+1===o)&&(n+=i,r=!1):(r=i===t,n+=i)}return n}function l(e,t){let n=0;for(let r=0;r<e.length;r++)e[r]===t&&n++;return n}const u=/^\.\.?\//u,d=/^\/\.(?:\/|$)/u,h=/^\/\.\.(?:\/|$)/u,p=/^\/?(?:.|\n)*?(?=\/|$)/u;e.exports={recomposeAuthority:function(e){const t=[];if(void 0!==e.userinfo&&(t.push(e.userinfo),t.push("@")),void 0!==e.host){let n=unescape(e.host);const r=s(n);if(r.isIPV4)n=r.host;else{const t=a(r.host);n=!0===t.isIPV6?`[${t.escapedHost}]`:e.host}t.push(n)}return"number"!=typeof e.port&&"string"!=typeof e.port||(t.push(":"),t.push(String(e.port))),t.length?t.join(""):void 0},normalizeComponentEncoding:function(e,t){const n=!0!==t?escape:unescape;return void 0!==e.scheme&&(e.scheme=n(e.scheme)),void 0!==e.userinfo&&(e.userinfo=n(e.userinfo)),void 0!==e.host&&(e.host=n(e.host)),void 0!==e.path&&(e.path=n(e.path)),void 0!==e.query&&(e.query=n(e.query)),void 0!==e.fragment&&(e.fragment=n(e.fragment)),e},removeDotSegments:function(e){const t=[];for(;e.length;)if(e.match(u))e=e.replace(u,"");else if(e.match(d))e=e.replace(d,"/");else if(e.match(h))e=e.replace(h,"/"),t.pop();else if("."===e||".."===e)e="";else{const n=e.match(p);if(!n)throw new Error("Unexpected dot segment condition");{const r=n[0];e=e.slice(r.length),t.push(r)}}return t.join("")},normalizeIPv4:s,normalizeIPv6:a,stringArrayToHexStripped:i}},3837:e=>{"use strict";e.exports=JSON.parse('{"$id":"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#","description":"Meta-schema for $data reference (JSON AnySchema extension proposal)","type":"object","required":["$data"],"properties":{"$data":{"type":"string","anyOf":[{"format":"relative-json-pointer"},{"format":"json-pointer"}]}},"additionalProperties":false}')},7216:e=>{"use strict";e.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/meta/applicator","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/applicator":true},"$dynamicAnchor":"meta","title":"Applicator vocabulary meta-schema","type":["object","boolean"],"properties":{"prefixItems":{"$ref":"#/$defs/schemaArray"},"items":{"$dynamicRef":"#meta"},"contains":{"$dynamicRef":"#meta"},"additionalProperties":{"$dynamicRef":"#meta"},"properties":{"type":"object","additionalProperties":{"$dynamicRef":"#meta"},"default":{}},"patternProperties":{"type":"object","additionalProperties":{"$dynamicRef":"#meta"},"propertyNames":{"format":"regex"},"default":{}},"dependentSchemas":{"type":"object","additionalProperties":{"$dynamicRef":"#meta"},"default":{}},"propertyNames":{"$dynamicRef":"#meta"},"if":{"$dynamicRef":"#meta"},"then":{"$dynamicRef":"#meta"},"else":{"$dynamicRef":"#meta"},"allOf":{"$ref":"#/$defs/schemaArray"},"anyOf":{"$ref":"#/$defs/schemaArray"},"oneOf":{"$ref":"#/$defs/schemaArray"},"not":{"$dynamicRef":"#meta"}},"$defs":{"schemaArray":{"type":"array","minItems":1,"items":{"$dynamicRef":"#meta"}}}}')},8226:e=>{"use strict";e.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/meta/content","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/content":true},"$dynamicAnchor":"meta","title":"Content vocabulary meta-schema","type":["object","boolean"],"properties":{"contentEncoding":{"type":"string"},"contentMediaType":{"type":"string"},"contentSchema":{"$dynamicRef":"#meta"}}}')},518:e=>{"use strict";e.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/meta/core","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/core":true},"$dynamicAnchor":"meta","title":"Core vocabulary meta-schema","type":["object","boolean"],"properties":{"$id":{"$ref":"#/$defs/uriReferenceString","$comment":"Non-empty fragments not allowed.","pattern":"^[^#]*#?$"},"$schema":{"$ref":"#/$defs/uriString"},"$ref":{"$ref":"#/$defs/uriReferenceString"},"$anchor":{"$ref":"#/$defs/anchorString"},"$dynamicRef":{"$ref":"#/$defs/uriReferenceString"},"$dynamicAnchor":{"$ref":"#/$defs/anchorString"},"$vocabulary":{"type":"object","propertyNames":{"$ref":"#/$defs/uriString"},"additionalProperties":{"type":"boolean"}},"$comment":{"type":"string"},"$defs":{"type":"object","additionalProperties":{"$dynamicRef":"#meta"}}},"$defs":{"anchorString":{"type":"string","pattern":"^[A-Za-z_][-A-Za-z0-9._]*$"},"uriString":{"type":"string","format":"uri"},"uriReferenceString":{"type":"string","format":"uri-reference"}}}')},4588:e=>{"use strict";e.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/meta/format-annotation","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/format-annotation":true},"$dynamicAnchor":"meta","title":"Format vocabulary meta-schema for annotation results","type":["object","boolean"],"properties":{"format":{"type":"string"}}}')},5707:e=>{"use strict";e.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/meta/meta-data","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/meta-data":true},"$dynamicAnchor":"meta","title":"Meta-data vocabulary meta-schema","type":["object","boolean"],"properties":{"title":{"type":"string"},"description":{"type":"string"},"default":true,"deprecated":{"type":"boolean","default":false},"readOnly":{"type":"boolean","default":false},"writeOnly":{"type":"boolean","default":false},"examples":{"type":"array","items":true}}}')},9547:e=>{"use strict";e.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/meta/unevaluated","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/unevaluated":true},"$dynamicAnchor":"meta","title":"Unevaluated applicator vocabulary meta-schema","type":["object","boolean"],"properties":{"unevaluatedItems":{"$dynamicRef":"#meta"},"unevaluatedProperties":{"$dynamicRef":"#meta"}}}')},7082:e=>{"use strict";e.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/meta/validation","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/validation":true},"$dynamicAnchor":"meta","title":"Validation vocabulary meta-schema","type":["object","boolean"],"properties":{"type":{"anyOf":[{"$ref":"#/$defs/simpleTypes"},{"type":"array","items":{"$ref":"#/$defs/simpleTypes"},"minItems":1,"uniqueItems":true}]},"const":true,"enum":{"type":"array","items":true},"multipleOf":{"type":"number","exclusiveMinimum":0},"maximum":{"type":"number"},"exclusiveMaximum":{"type":"number"},"minimum":{"type":"number"},"exclusiveMinimum":{"type":"number"},"maxLength":{"$ref":"#/$defs/nonNegativeInteger"},"minLength":{"$ref":"#/$defs/nonNegativeIntegerDefault0"},"pattern":{"type":"string","format":"regex"},"maxItems":{"$ref":"#/$defs/nonNegativeInteger"},"minItems":{"$ref":"#/$defs/nonNegativeIntegerDefault0"},"uniqueItems":{"type":"boolean","default":false},"maxContains":{"$ref":"#/$defs/nonNegativeInteger"},"minContains":{"$ref":"#/$defs/nonNegativeInteger","default":1},"maxProperties":{"$ref":"#/$defs/nonNegativeInteger"},"minProperties":{"$ref":"#/$defs/nonNegativeIntegerDefault0"},"required":{"$ref":"#/$defs/stringArray"},"dependentRequired":{"type":"object","additionalProperties":{"$ref":"#/$defs/stringArray"}}},"$defs":{"nonNegativeInteger":{"type":"integer","minimum":0},"nonNegativeIntegerDefault0":{"$ref":"#/$defs/nonNegativeInteger","default":0},"simpleTypes":{"enum":["array","boolean","integer","null","number","object","string"]},"stringArray":{"type":"array","items":{"type":"string"},"uniqueItems":true,"default":[]}}}')},1678:e=>{"use strict";e.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/schema","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/core":true,"https://json-schema.org/draft/2020-12/vocab/applicator":true,"https://json-schema.org/draft/2020-12/vocab/unevaluated":true,"https://json-schema.org/draft/2020-12/vocab/validation":true,"https://json-schema.org/draft/2020-12/vocab/meta-data":true,"https://json-schema.org/draft/2020-12/vocab/format-annotation":true,"https://json-schema.org/draft/2020-12/vocab/content":true},"$dynamicAnchor":"meta","title":"Core and Validation specifications meta-schema","allOf":[{"$ref":"meta/core"},{"$ref":"meta/applicator"},{"$ref":"meta/unevaluated"},{"$ref":"meta/validation"},{"$ref":"meta/meta-data"},{"$ref":"meta/format-annotation"},{"$ref":"meta/content"}],"type":["object","boolean"],"$comment":"This meta-schema also defines keywords that have appeared in previous drafts in order to prevent incompatible extensions as they remain in common use.","properties":{"definitions":{"$comment":"\\"definitions\\" has been replaced by \\"$defs\\".","type":"object","additionalProperties":{"$dynamicRef":"#meta"},"deprecated":true,"default":{}},"dependencies":{"$comment":"\\"dependencies\\" has been split and replaced by \\"dependentSchemas\\" and \\"dependentRequired\\" in order to serve their differing semantics.","type":"object","additionalProperties":{"anyOf":[{"$dynamicRef":"#meta"},{"$ref":"meta/validation#/$defs/stringArray"}]},"deprecated":true,"default":{}},"$recursiveAnchor":{"$comment":"\\"$recursiveAnchor\\" has been replaced by \\"$dynamicAnchor\\".","$ref":"meta/core#/$defs/anchorString","deprecated":true},"$recursiveRef":{"$comment":"\\"$recursiveRef\\" has been replaced by \\"$dynamicRef\\".","$ref":"meta/core#/$defs/uriReferenceString","deprecated":true}}}')},2079:e=>{"use strict";e.exports=JSON.parse('{"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://json-schema.org/draft-07/schema#","title":"Core schema meta-schema","definitions":{"schemaArray":{"type":"array","minItems":1,"items":{"$ref":"#"}},"nonNegativeInteger":{"type":"integer","minimum":0},"nonNegativeIntegerDefault0":{"allOf":[{"$ref":"#/definitions/nonNegativeInteger"},{"default":0}]},"simpleTypes":{"enum":["array","boolean","integer","null","number","object","string"]},"stringArray":{"type":"array","items":{"type":"string"},"uniqueItems":true,"default":[]}},"type":["object","boolean"],"properties":{"$id":{"type":"string","format":"uri-reference"},"$schema":{"type":"string","format":"uri"},"$ref":{"type":"string","format":"uri-reference"},"$comment":{"type":"string"},"title":{"type":"string"},"description":{"type":"string"},"default":true,"readOnly":{"type":"boolean","default":false},"examples":{"type":"array","items":true},"multipleOf":{"type":"number","exclusiveMinimum":0},"maximum":{"type":"number"},"exclusiveMaximum":{"type":"number"},"minimum":{"type":"number"},"exclusiveMinimum":{"type":"number"},"maxLength":{"$ref":"#/definitions/nonNegativeInteger"},"minLength":{"$ref":"#/definitions/nonNegativeIntegerDefault0"},"pattern":{"type":"string","format":"regex"},"additionalItems":{"$ref":"#"},"items":{"anyOf":[{"$ref":"#"},{"$ref":"#/definitions/schemaArray"}],"default":true},"maxItems":{"$ref":"#/definitions/nonNegativeInteger"},"minItems":{"$ref":"#/definitions/nonNegativeIntegerDefault0"},"uniqueItems":{"type":"boolean","default":false},"contains":{"$ref":"#"},"maxProperties":{"$ref":"#/definitions/nonNegativeInteger"},"minProperties":{"$ref":"#/definitions/nonNegativeIntegerDefault0"},"required":{"$ref":"#/definitions/stringArray"},"additionalProperties":{"$ref":"#"},"definitions":{"type":"object","additionalProperties":{"$ref":"#"},"default":{}},"properties":{"type":"object","additionalProperties":{"$ref":"#"},"default":{}},"patternProperties":{"type":"object","additionalProperties":{"$ref":"#"},"propertyNames":{"format":"regex"},"default":{}},"dependencies":{"type":"object","additionalProperties":{"anyOf":[{"$ref":"#"},{"$ref":"#/definitions/stringArray"}]}},"propertyNames":{"$ref":"#"},"const":true,"enum":{"type":"array","items":true,"minItems":1,"uniqueItems":true},"type":{"anyOf":[{"$ref":"#/definitions/simpleTypes"},{"type":"array","items":{"$ref":"#/definitions/simpleTypes"},"minItems":1,"uniqueItems":true}]},"format":{"type":"string"},"contentMediaType":{"type":"string"},"contentEncoding":{"type":"string"},"if":{"$ref":"#"},"then":{"$ref":"#"},"else":{"$ref":"#"},"allOf":{"$ref":"#/definitions/schemaArray"},"anyOf":{"$ref":"#/definitions/schemaArray"},"oneOf":{"$ref":"#/definitions/schemaArray"},"not":{"$ref":"#"}},"default":true}')}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var s=t[r]={id:r,loaded:!1,exports:{}};return e[r].call(s.exports,s,s.exports,n),s.loaded=!0,s.exports}n.m=e,n.amdO={},n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.u=e=>e+".js",n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.hmd=e=>((e=Object.create(e)).children||(e.children=[]),Object.defineProperty(e,"exports",{enumerable:!0,set:()=>{throw new Error("ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: "+e.id)}}),e),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})},(()=>{var e;n.g.importScripts&&(e=n.g.location+"");var t=n.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");if(r.length)for(var o=r.length-1;o>-1&&(!e||!/^http(s?):/.test(e));)e=r[o--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=e})(),n.b=document.baseURI||self.location.href,n.nc=void 0;var r={};(()=>{"use strict";n.r(r),n.d(r,{_package:()=>_e,initAutoTests:()=>Me,test:()=>Pe,tests:()=>t.CN});var e=n(6082),t=n(8070);(0,t.L1)("_first",(()=>{(0,t.t6)("_first",(async()=>{}))}));var o=n(8924),s=n(7362),i=n(1093);(0,t.L1)("Palettes",(()=>{(0,t.t6)("testPaletteN",(async()=>{await async function(){const e=i.A.Chromatogram;(0,t.E3)(e instanceof s.e,!0),(0,t.E3)(e instanceof i.A,!0)}()})),(0,t.t6)("testPaletteAA",(async()=>{await async function(){const e=o.X.Lesk,n=o.X.RasMol,r=o.X.GrokGroups;(0,t.E3)(e instanceof s.e,!0),(0,t.E3)(n instanceof s.e,!0),(0,t.E3)(r instanceof s.e,!0),(0,t.E3)(e instanceof o.X,!0),(0,t.E3)(n instanceof o.X,!0),(0,t.E3)(r instanceof o.X,!0)}()})),(0,t.t6)("testPalettePtMe",(async()=>{const e=o.X.GrokGroups.get("MeNle"),n=o.X.GrokGroups.get("MeA"),r=o.X.GrokGroups.get("MeG"),s=o.X.GrokGroups.get("MeF"),i=o.X.GrokGroups.get("L"),a=o.X.GrokGroups.get("A"),c=o.X.GrokGroups.get("G"),l=o.X.GrokGroups.get("F");(0,t.E3)(e,i),(0,t.E3)(n,a),(0,t.E3)(r,c),(0,t.E3)(s,l)}))}));var a=n(4328),c=n(2003),l=n(8312);class u{units;aligned;alphabet;alphabetSize;alphabetIsMultichar;separator;constructor(e,t,n,r,o,s){this.units=e,this.aligned=t,this.alphabet=n,this.alphabetSize=r,this.alphabetIsMultichar=o,this.separator=s}}async function d(t,n){const r=(await t()).getCol(n),o=await a.functions.call("Bio:detectMacromolecule",{col:r});if(o&&(r.semType=o),r.semType===e.SEMTYPE.MACROMOLECULE){const e=`Negative test detected semType='${r.semType}', units='${r.meta.units}'.`;throw new Error(e)}}async function h(n,r,o,s,i,l,u,d,h=null){const p=(await n()).col(r),m=await a.functions.call("Bio:detectMacromolecule",{col:p});m&&(p.semType=m),(0,t.E3)(p.semType,e.SEMTYPE.MACROMOLECULE),(0,t.E3)(p.meta.units,s),(0,t.E3)(p.getTag(c.gp.aligned),i),(0,t.E3)(p.getTag(c.gp.alphabet),l),h&&(0,t.E3)(p.getTag(c.gp.separator),h);const f=o.getSeqHandler(p);(0,t.E3)(f.getAlphabetSize(),u),(0,t.E3)(f.getAlphabetIsMultichar(),d),f.isHelm()||((0,t.E3)(f.aligned,i),(0,t.E3)(f.alphabet,l))}async function p(t){const n=e.Column.fromList(e.TYPE.STRING,"col1",t);if(await a.functions.call("Bio:detectMacromolecule",{col:n}),n.semType===e.SEMTYPE.MACROMOLECULE){const e=`Negative test detected semType='${n.semType}', units='${n.meta.units}'.`;throw new Error(e)}}async function m(n,r,o,s,i,l,u,d=null){const h=e.Column.fromList(e.TYPE.STRING,"seq",n),p=await a.functions.call("Bio:detectMacromolecule",{col:h});p&&(h.semType=p),(0,t.E3)(h.semType,e.SEMTYPE.MACROMOLECULE),(0,t.E3)(h.meta.units,o),(0,t.E3)(h.getTag(c.gp.aligned),s),(0,t.E3)(h.getTag(c.gp.alphabet),i),d&&(0,t.E3)(h.getTag(c.gp.separator),d);const m=r.getSeqHandler(h);(0,t.E3)(m.getAlphabetSize(),l),(0,t.E3)(m.getAlphabetIsMultichar(),u),m.isHelm()||((0,t.E3)(m.aligned,s),(0,t.E3)(m.alphabet,i))}async function f(e,t,n){const r=await e(),o=[];for(const s of r.columns.names())if(s in t){const r=t[s];try{await h(e,s,n,r.units,r.aligned,r.alphabet,r.alphabetSize,r.alphabetIsMultichar,r.separator)}catch(e){const t=e.toString();o.push(`Positive col '${s}' failed: ${t}`)}}else try{await d(e,s)}catch(e){const t=e.toString();o.push(`Negative col '${s}' failed: ${t}`)}if(o.length>0)throw new Error(o.join("\n"))}(0,t.L1)("detectors",(()=>{let n;(0,t.gM)((async()=>{n=await(0,l.Q)()}));const r={negEmpty:{csv:"id,col1\n1,\n2,\n3,\n4,\n5,",neg:["col1"]},negNum1:{csv:"col1\n1\n2\n3",neg:["col1"]},negNum2:{csv:"col1\n4\n5\n6\n7",neg:["col1"]},negNum3:{csv:"col1\n8\n9\n10\n11\n12",neg:["col1"]},negSmiles:{csv:"col1\nCCCCN1C(=O)CN=C(c2cc(F)ccc12)C3CCCCC3\nC1CCCCC1\nCCCCCC",neg:["col1"]},negSmilesWithSquareBrackets:{csv:"col1\nCl.c1ccc2nc3ccccc3cc2c1\nOc1cccc2cc3ccccc3cc12\n[SeH]c1ccc2ccccc2c1",neg:["col1"]},negFastaUnSingleChar:{csv:"col1\nAlanine\nCysteine\nAspartic acid\nGlutamic acid\nPhenylalanine",neg:["col1"]},fastaMsaSameLength:{csv:"seq\nFWPHEYFWPHEYYV\nYNRQWYVYNRQWYV\nMKPSEYVMKPSEYV",pos:{seq:new u(c.Hi.FASTA,"SEQ.MSA",c.YI.PT,20,!1,void 0)}},fastaExtSameLength:{csv:"seq\nFW[Ac]PHEYFWPH\nYN[Re]VYNRQWYV\n[Me]EYVMPS[Et]",pos:{seq:new u(c.Hi.FASTA,"SEQ",c.YI.UN,16,!0,void 0)}},fastaMsaExtSameLength:{csv:"seq\nFW[Ac]PHEY[Re]WPH\nYN[Re]VYNR[Ac]WYV\n[Me]EYVMPSFW[Me]H",pos:{seq:new u(c.Hi.FASTA,"SEQ.MSA",c.YI.UN,14,!0,void 0)}},fastaMsaExtManyMinus:{csv:"seq\n[D-Tic]-------[D-Tyr_Et][Tyr_ab-dehydroMe][dV][Cys_SEt]N[D-Orn][D-aThr]-[Phe_4Me]\n[Phe_2F]--------[Tyr_ab-dehydroMe][dV][Aca]N[D-Orn][D-aThr]-[Phe_4Me]\n[D-Tic]-[Hcy]QTWQ[Phe_4NH2][D-Tyr_Et][Tyr_ab-dehydroMe][dV][Cys_SEt]----[Phe_4Me]",pos:{seq:new u(c.Hi.FASTA,"SEQ.MSA",c.YI.UN,17,!0,void 0)}},sepSameLength:{csv:"seq\nAca-A-A-A-A-A-A-A-A-A-A-A-A-A-C-G-NH2\nAca-A-A-A-A-A-A-A-A-A-A-A-A-A-C-G-NH2\nAca-A-A-A-A-A-A-A-A-A-A-A-A-A-C-G-NH2",pos:{seq:new u(c.Hi.SEPARATOR,"SEQ.MSA",c.YI.UN,5,!0,"-")}},sepMsaSameLength:{csv:"seq\nAca-A-A-A-A-A-A-A-A-A-A-A-A-A-Aca-G-NH2\nAca-A-Aca-A-A-A-meI-A-A-A-A-A-Aca-G-NH2\nAca-A-A-A-A-A-A-A-A-A-A-A-A-A-Aca-G-NH2",pos:{seq:new u(c.Hi.SEPARATOR,"SEQ",c.YI.UN,5,!0,"-")}},helmSameLength:{csv:"seq\nPEPTIDE1{Ac(1).A.A.A.A.A.A.A.A.A.A.A.A.A.C(1).G.NH2}$$$$\nPEPTIDE1{Ab(1).Y.V.K.H.P.F.W.R.W.Y.A.A.A.C(1).G.NH2}$$$$\nPEPTIDE1{Ad(1).S.W.Y.C.K.H.P.M.W.A.A.A.A.C(1)-G-NH2}$$$$",pos:{seq:new u(c.Hi.HELM,null,null,19,void 0,void 0)}},fastaNonDigitAlphabet:{csv:'flagC\n"NMe-pyridazineH"\n"Pyrrolo[2,3-c]pyridazineH"',neg:["flagC"]}};for(const[o,s]of Object.entries(r))(0,t.t6)(`csvData2-${o}`,(async()=>{const t=(i=o,async()=>{const t=r[i].csv,n=e.DataFrame.fromCsv(t);return await a.data.detectSemanticTypes(n),n});var i;for(const e of s.neg??[])await d(t,e);for(const[e,r]of Object.entries(s.pos??{}))await h(t,e,n,r.units,r.aligned,r.alphabet,r.alphabetSize,r.alphabetIsMultichar,r.separator)}));const o=new class{csvFastaDna1="seq\nACGTCACGTC\nCAGTGTCAGTGT\nTTCAACTTCAAC";fastaRna1="seq\nACGUCACGUC\nCAGUGUCAGUGU\nUUCAACUUCAAC";fastaPt1="seq\nFWPHEY\nYNRQWYV\nMKPSEYV";fastaUn="seq\n[meI][hHis][Aca]NT[dE][Thr_PO3H2][Aca]DN\n[meI][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2][Aca]\n[Lys_Boc][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2][Aca]";sepDna="seq\nA*C*G*T*C*A*C*G*T*C\nC*A*G*T*G*T*C*A*G*T*G*T\nT*T*C*A*A*C*T*T*C*A*A*C";sepRna="seq\nA*C*G*U*C*A*C*G*U*C\nC*A*G*U*G*U*C*A*G*U*G*U\nU*U*C*A*A*C*U*U*C*A*A*C";sepPt="seq\nF-W-P-H-E-Y-F-W-P-H-E-Y\nY-N-R-Q-W-Y-V-Y-N-R-Q-W-Y-V\nM-K-P-S-E-Y-V-M-K-P-S-E-Y-V";sepUn1="seq\nabc-dfgg-abc1-cfr3-rty-wert-cfr3-rty-wert\nrut12-her2-rty-wert-abc-abc1-dfgg-abc-abc1-dfgg\nrut12-rty-her2-abc-cfr3-wert-rut12-cfr3-wert-rut12";sepUn2="seq\nabc/dfgg/abc1/cfr3/rty/wert/abc/dfgg/abc1/cfr3/rty/wert\nrut12/her2/rty/wert//abc/abc1/dfgg/rut12/her2/rty/wert//abc/abc1/dfgg\nrut12/rty/her2/abc/cfr3//wert/rut12/rut12/rty/her2/abc/cfr3//wert/rut12";sepMsaDna1="seq\nA-C--G-T--C-T-A-C--G-T--C-T\nC-A-C--T--G-T-C-A-C--T--G-T\nA-C-C-G-T-A-C-T-A-C-C-G-T-A-C-T";sepMsaUnWEmpty="seq\nm1-M-m3-mon4-mon5-N-T-MON8-N9-m1-M-m3-mon4-mon5-N-T-MON8-N9\nm1-mon2-m3-mon4-mon5-Num--MON8-N9-m1-mon2-m3-mon4-mon5-Num--MON8-N9\n\nmon1-M-mon3-mon4-mon5---MON8-N9-mon1-M-mon3-mon4-mon5---MON8-N9";sepComplex="seq\nAca-F-K(AEEA-AEEA-R-Ac)-L-mF-V-Y-mNle-D-W-N-mF-Aca-G-NH2\nAca-F-K(AEEA-ARRA-W-Ac)-L-mF-V-Y-mNle-D-W-N-mF-Aca-G-NH2\nAca-F-K(AEEA-AEEA-Ac)-L-mF-V-Y-mNle-D-W-N-mF-Aca-G-NH2";fastaMsaDna1="seq\nAC-GT-CTAC-GT-CT\nCAC-T-GTCAC-T-GT\nACCGTACTACCGTACT";fastaMsaPt1="seq\nFWR-WYV-KHPFWR-WYV-KHP\nYNR-WYV-KHPYNR-WYV-KHP\nMWRSWY-CKHPMWRSWY-CKHP"},s={fastaPtCsv:"System:AppData/Bio/samples/FASTA_PT.csv",msaComplex:"System:AppData/Bio/samples/MSA.csv",fastaCsv:"System:AppData/Bio/samples/FASTA.csv",helmCsv:"System:AppData/Bio/samples/HELM.csv",peptidesComplex:"System:AppData/Bio/tests/peptides_complex_msa.csv",peptidesSimple:"System:AppData/Bio/tests/peptides_simple_msa.csv",testDemogCsv:"System:AppData/Bio/tests/testDemog.csv",testHelmCsv:"System:AppData/Bio/tests/testHelm.csv",testIdCsv:"System:AppData/Bio/tests/testId.csv",testSmilesCsv:"System:AppData/Bio/tests/testSmiles.csv",testSmiles2Csv:"System:AppData/Bio/tests/testSmiles2.csv",testSmilesShort:"System:AppData/Bio/tests/testSmilesShort.csv",testActivityCliffsCsv:"System:AppData/Bio/tests/testActivityCliffs.csv",testCerealCsv:"System:AppData/Bio/tests/testCereal.csv",testUnichemSources:"System:AppData/Bio/tests/testUnichemSources.csv",testDmvOffices:"System:AppData/Bio/tests/testDmvOffices.csv",testAlertCollection:"System:AppData/Bio/tests/testAlertCollection.csv",testSpgi100:"System:AppData/Bio/tests/testSpgi100.csv",testSpgi:"System:AppData/Bio/tests/SPGI-derived.csv",testUrl:"System:AppData/Bio/tests/testUrl.csv",fasta_negative_words:"System:AppData/Bio/tests/fasta_negative_words.csv"},i={};function g(e,t=y){return async()=>(e in i||(i[e]=(async()=>await t(s[e]))().catch((t=>{throw delete i[e],t}))),i[e])}async function y(t){const n=await a.dapi.files.readAsText(t);return e.DataFrame.fromCsv(n)}const b=t=>async()=>{const n=o[t],r=e.DataFrame.fromCsv(n);return await a.data.detectSemanticTypes(r),r};(0,t.t6)("NegativeStartEnd",(async()=>{await p(["START","END"])})),(0,t.t6)("NegativeStartEndIntermediate",(async()=>{await p(["START","END","INTERMEDIATE"])})),(0,t.t6)("FastaDna1",(async()=>{await h(b("csvFastaDna1"),"seq",n,c.Hi.FASTA,"SEQ",c.YI.DNA,4,!1)})),(0,t.t6)("FastaRna1",(async()=>{await h(b("fastaRna1"),"seq",n,c.Hi.FASTA,"SEQ",c.YI.RNA,4,!1)})),(0,t.t6)("FastaPt1",(async()=>{await h(b("fastaPt1"),"seq",n,c.Hi.FASTA,"SEQ",c.YI.PT,20,!1)})),(0,t.t6)("FastaPtGaps",(()=>m(["FW-PH-EYY","FYNRQWYV-","FKP-Q-SEYV"],n,c.Hi.FASTA,"SEQ",c.YI.PT,20,!1))),(0,t.t6)("FastaPtGapsMsa",(()=>m(["FW-PH-EYY","FYNRQWYV-","FKP-Q-SEY"],n,c.Hi.FASTA,"SEQ.MSA",c.YI.PT,20,!1))),(0,t.t6)("FastaUn",(async()=>{await h(b("fastaUn"),"seq",n,c.Hi.FASTA,"SEQ.MSA",c.YI.UN,12,!0)})),(0,t.t6)("FastaMsaDna1",(async()=>{await h(b("fastaMsaDna1"),"seq",n,c.Hi.FASTA,"SEQ.MSA",c.YI.DNA,4,!1)})),(0,t.t6)("FastaMsaPt1",(async()=>{await h(b("fastaMsaPt1"),"seq",n,c.Hi.FASTA,"SEQ.MSA",c.YI.PT,20,!1)})),(0,t.t6)("SepDna",(async()=>{await h(b("sepDna"),"seq",n,c.Hi.SEPARATOR,"SEQ",c.YI.DNA,4,!1,"*")})),(0,t.t6)("SepRna",(async()=>{await h(b("sepRna"),"seq",n,c.Hi.SEPARATOR,"SEQ",c.YI.RNA,4,!1,"*")})),(0,t.t6)("SepPt",(async()=>{await h(b("sepPt"),"seq",n,c.Hi.SEPARATOR,"SEQ",c.YI.PT,20,!1,"-")})),(0,t.t6)("SepUn1",(async()=>{await h(b("sepUn1"),"seq",n,c.Hi.SEPARATOR,"SEQ",c.YI.UN,8,!0,"-")})),(0,t.t6)("SepUn2",(async()=>{await h(b("sepUn2"),"seq",n,c.Hi.SEPARATOR,"SEQ",c.YI.UN,9,!0,"/")})),(0,t.t6)("SepMsaN1",(async()=>{await h(b("sepMsaDna1"),"seq",n,c.Hi.SEPARATOR,"SEQ.MSA",c.YI.DNA,4,!1,"-")})),(0,t.t6)("SepMsaUnWEmpty",(async()=>{await h(b("sepMsaUnWEmpty"),"seq",n,c.Hi.SEPARATOR,"SEQ.MSA",c.YI.UN,14,!0)})),(0,t.t6)("SepComplex",(async()=>{await h(b("sepComplex"),"seq",n,c.Hi.SEPARATOR,"SEQ",c.YI.UN,17,!0)})),(0,t.t6)("samplesFastaCsv",(async()=>{await f(g("fastaCsv"),{Sequence:new u(c.Hi.FASTA,"SEQ",c.YI.PT,20,!1)},n)})),(0,t.t6)("samplesPeptidesComplex",(async()=>{await f(g("peptidesComplex"),{},n)})),(0,t.t6)("samplesMsaComplex",(async()=>{await f(g("msaComplex"),{MSA:new u(c.Hi.SEPARATOR,"SEQ.MSA",c.YI.UN,161,!0,"/")},n)})),(0,t.t6)("samplesIdCsv",(async()=>{await f(g("testIdCsv"),{},n)})),(0,t.t6)("samplesSarSmallCsv",(async()=>{await f(g("testSmilesCsv"),{},n)})),(0,t.t6)("samplesHelmCsv",(async()=>{await f(g("helmCsv"),{HELM:new u(c.Hi.HELM,null,null,160,!0)},n)})),(0,t.t6)("samplesTestHelmCsv",(async()=>{await f(g("testHelmCsv"),{"HELM string":new u(c.Hi.HELM,null,null,9,!0)},n)})),(0,t.t6)("samplesTestDemogCsv",(async()=>{await f(g("testDemogCsv"),{},n)})),(0,t.t6)("samplesTestSmiles2Csv",(async()=>{await f(g("testSmiles2Csv"),{},n)})),(0,t.t6)("samplesTestSmilesShort",(async()=>{await f(g("testSmilesShort"),{},n)})),(0,t.t6)("samplesTestActivityCliffsNegativeSmiles",(async()=>{await f(g("testActivityCliffsCsv"),{},n)})),(0,t.t6)("samplesFastaPtCsv",(async()=>{await f(g("fastaPtCsv"),{sequence:new u(c.Hi.FASTA,"SEQ",c.YI.PT,20,!1)},n)})),(0,t.t6)("samplesTestCerealCsv",(async()=>{await f(g("testCerealCsv"),{},n)})),(0,t.t6)("samplesTestUnichemSources",(async()=>{await f(g("testUnichemSources"),{},n)})),(0,t.t6)("samplesTestDmvOffices",(async()=>{await f(g("testDmvOffices"),{},n)})),(0,t.t6)("samplesTestAlertCollection",(async()=>{await f(g("testAlertCollection"),{},n)})),(0,t.t6)("samplesTestSpgi",(async()=>{await f(g("testSpgi"),{},n)})),(0,t.t6)("samplesTestSpgi100",(async()=>{await f(g("testSpgi100"),{},n)})),(0,t.t6)("samplesTestUrl",(async()=>{await f(g("testUrl"),{},n)})),(0,t.t6)("samplesFastaNegativeWords",(async()=>{await f(g("fasta_negative_words"),{},n)}))})),(0,t.L1)("detectors.weak-and-likely",(()=>{let n;(0,t.gM)((async()=>{n=await(0,l.Q)()}));const r={fastaDnaWeak1:"id,colName\n1,TTTTTTTTTT\n2,TTTTTTTTTT\n3,TTTTTTTTTT\n4,TTTTTTTTTT",fastaDnaWeak1LikelyName:"id,seq\n1,TTTTTTT\n2,TTTTTTT\n3,TTTTTTT\n4,TTTTTTT",fastaRnaWeak1:"id,colName\n1,UUUUUUUUUU\n2,UUUUUUUUUU\n3,UUUUUUUUUU\n4,UUUUUUUUUU",fastaRnaWeak1LikelyName:"id,seq\n1,UUUUUUU\n2,UUUUUUU\n3,UUUUUUU\n4,UUUUUUU",fastaPtWeak1:"id,colName\n1,SLSLSPGKSLSLSPGK\n2,SLSLSPGKSLSLSPGK\n3,SLSLSPGKSLSLSPGK\n4,SLSLSPGKSLSLSPGK",fastaPtWeak1LikelyName:"id,seq\n1,SLSLSPGKSLSLSPGK\n2,SLSLSPGKSLSLSPGK\n3,SLSLSPGKSLSLSPGK\n4,SLSLSPGKSLSLSPGK",fastaUn1:"id,colName\n1,word\n2,other\n3,some\n4,another",fastaUn1LikelyName:"id,seq\n1,word\n2,other\n3,some\n4,another",fastaUn2LikelyName:'protein\nBoombastic\nMegafantastic\n"just-a-random-thought,oy!"',fastaUnMsa1LikelyName:"id,seq\n1,word\n2,male\n3,bare\n4,core"},o=t=>async()=>{const n=r[t],o=e.DataFrame.fromCsv(n);return await a.data.detectSemanticTypes(o),o};(0,t.t6)("fastaDnaWeak1",(async()=>{await d(o("fastaDnaWeak1"),"colName")})),(0,t.t6)("fastaDnaWeak1LikelyName",(async()=>{await h(o("fastaDnaWeak1LikelyName"),"seq",n,c.Hi.FASTA,"SEQ.MSA",c.YI.DNA,4,!1)})),(0,t.t6)("fastaRnaWeak1",(async()=>{await d(o("fastaRnaWeak1"),"colName")})),(0,t.t6)("fastaRnaWeak1LikelyName",(async()=>{await h(o("fastaRnaWeak1LikelyName"),"seq",n,c.Hi.FASTA,"SEQ.MSA",c.YI.RNA,4,!1)})),(0,t.t6)("fastaPtWeak1",(async()=>{await d(o("fastaPtWeak1"),"colName")})),(0,t.t6)("fastaPtWeak1LikelyName",(async()=>{await h(o("fastaPtWeak1LikelyName"),"seq",n,c.Hi.FASTA,"SEQ.MSA",c.YI.PT,20,!1)})),(0,t.t6)("fastaUn1",(async()=>{await d(o("fastaUn1"),"colName")})),(0,t.t6)("fastaUn1LikelyName",(async()=>{await d(o("fastaUn1LikelyName"),"seq")})),(0,t.t6)("fastaUn2LikelyName",(async()=>{await d(o("fastaUn2LikelyName"),"protein")})),(0,t.t6)("fastaUnMsa1LikelyName",(async()=>{await d(o("fastaUnMsa1LikelyName"),"seq")}))})),(0,t.L1)("detectorsBenchmark",(()=>{let n,r;async function o(o,i,a,l,u,d){return await async function(o){const h=await(async()=>{const t=function(t,n,r,o,s){let i;switch(t){case c.Hi.FASTA:i=e=>{let t="";for(let n=0;n<e.length;n++){const r=e[n];t+=1==r.length?r:`[${r}]`}return t};break;case c.Hi.SEPARATOR:i=(e,t)=>e.join(t);break;default:throw new Error(`Not supported notation '${t}'.`)}const a=(e,t)=>{const n=new Array(t);for(let r=0;r<t;r++)n[r]=e[Math.floor(Math.random()*e.length)];return i(n,s)},l=Array(o);for(let e=0;e<o;e++)l[e]=a(n,r);return e.Column.fromStrings("seq",l)}(i,[...(0,c.Qf)(a)],l,u,d),n=r.prepare({col:t});return s(n),n})(),p=Date.now(),m=s(h),f=Date.now();(function(e,r){const o=n.getSeqHandler(e);(0,t.E3)(e.semType===r.semType,!0),(0,t.E3)(o.notation===r.notation,!0),(0,t.E3)(o.alphabet===r.alphabet,!0),(0,t.E3)(o.separator===r.separator,!0)})(m,{semType:e.SEMTYPE.MACROMOLECULE,notation:i,alphabet:a,separator:d});const g=f-p;if(g>o){const e=`ET ${g} ms is more than max allowed ${o} ms.`;throw console.error(e),new Error(e)}return console.log(`ET ${g} ms is OK.`),g}(o)}function s(e){e.callSync();const t=e.getOutputParamValue(),n=e.inputs.col;return t&&(n.semType=t),n}(0,t.gM)((async()=>{n=await(0,l.Q)();const t=e.Func.find({package:"Bio",name:"detectMacromolecule"});r=t[0];const o=e.Column.fromStrings("seq",["ACGT","ACGT","ACGT"]);await r.prepare({col:o}).call()})),(0,t.t6)("fastaDnaShorts50Few50",(async()=>{await o(20,c.Hi.FASTA,c.YI.DNA,50,50)})),(0,t.t6)("fastaDnaShorts50Many1E6",(async()=>{await o(20,c.Hi.FASTA,c.YI.DNA,50,1e6)})),(0,t.t6)("fastaDnaLong1e6Few50",(async()=>{await o(20,c.Hi.FASTA,c.YI.DNA,1e6,50)})),(0,t.t6)("separatorDnaShorts50Few50",(async()=>{await o(20,c.Hi.SEPARATOR,c.YI.DNA,50,50,"/")})),(0,t.t6)("separatorDnaShorts50Many1E6",(async()=>{await o(20,c.Hi.SEPARATOR,c.YI.DNA,50,1e6,"/")})),(0,t.t6)("separatorDnaLong1e6Few50",(async()=>{await o(20,c.Hi.SEPARATOR,c.YI.DNA,1e6,50,"/")}))}));var g=n(608),y=n(1619);async function b(n,r){const o=e.DataFrame.fromCsv(n);await a.data.detectSemanticTypes(o);const s=e.DataFrame.fromCsv(r),i=o.getCol("seq");(0,t.E3)(i.semType,e.SEMTYPE.MACROMOLECULE);const c=s.getCol("seq"),l=await(0,g.eE)(o,i,!0);(0,t.J6)(l.toList(),c.toList())}(0,t.L1)("MSA",(async()=>{let n;async function r(r,o,s,i,l,u){const d=e.DataFrame.fromCsv(r);await a.data.detectSemanticTypes(d);const h=e.DataFrame.fromCsv(o).getCol("seq"),p=d.getCol("seq");(0,t.E3)(p.semType,e.SEMTYPE.MACROMOLECULE),(0,t.E3)(p.meta.units,s),l&&(0,t.E3)(p.getTag(c.gp.alphabet),l);const m=await(0,y.D)({col:p,pepsea:{method:u}},n);(0,t.E3)(m.semType,e.SEMTYPE.MACROMOLECULE),(0,t.E3)(m.meta.units,i),(0,t.E3)(m.getTag(c.gp.aligned),"SEQ.MSA"),l&&(0,t.E3)(m.getTag(c.gp.alphabet),l),(0,t.J6)(m.toList(),h.toList())}(0,t.gM)((async()=>{n=await(0,l.Q)()})),(0,t.t6)("isCorrect",(async()=>{await b("seq\nFWRWYVKHP\nYNRWYVKHP\nMWRSWYCKHP","seq\nFWR-WYVKHP\nYNR-WYVKHP\nMWRSWYCKHP")})),(0,t.t6)("isCorrectLong",(async()=>{await b("seq\nFWRWYVKHPFWRWYVKHPFWRWYVKHPFWRWYVKHPFWRWYVKHPFWRWYVKHPFWRWYVKHPFWRWYVKHP\nYNRWYVKHPYNRWYVKHPYNRWYVKHPYNRWYVKHPYNRWYVKHPYNRWYVKHPYNRWYVKHPYNRWYVKHP\nMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHP","seq\nFWR-WYVKHPFWR-WYVKHPFWR-WYVKHPFWR-WYVKHPFWR-WYVKHPFWR-WYVKHPFWR-WYVKHPFWR-WYVKHP\nYNR-WYVKHPYNR-WYVKHPYNR-WYVKHPYNR-WYVKHPYNR-WYVKHPYNR-WYVKHPYNR-WYVKHPYNR-WYVKHP\nMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHP")})),(0,t.t6)("isCorrectHelm",(async()=>{await r("seq\n PEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2}$$$$\n PEPTIDE1{meI.Aca.N.T.dE.Thr_PO3H2}$$$$\n PEPTIDE1{hHis.Aca.N.T.dE.Thr_PO3H2}$$$$","seq\n meI.hHis.Aca.N.T.dE.Thr_PO3H2\n .meI.Aca.N.T.dE.Thr_PO3H2\n .hHis.Aca.N.T.dE.Thr_PO3H2",c.Hi.HELM,c.Hi.SEPARATOR,void 0,"mafft")}),{timeout:8e4,skipReason:"Fails in docker"}),(0,t.t6)("isCorrectHelmLong",(async()=>{await r("seq\n PEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et.dV.E.N.D-Orn.D-aThr.Phe_4Me.Thr_PO3H2}$$$$\n PEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Tyr_PO3H2.D-Chg.dV.Phe_ab-dehydro.N.D-Orn.D-aThr.Phe_4Me}$$$$\n PEPTIDE1{Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Tyr_PO3H2.D-Chg.dV.Thr_PO3H2.N.D-Orn.D-aThr.Phe_4Me}$$$$","seq\n meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et.dV.E.N.D-Orn.D-aThr.Phe_4Me.Thr_PO3H2\n meI.hHis.Aca.Cys_SEt.T.dK..Tyr_PO3H2.D-Chg.dV.Phe_ab-dehydro.N.D-Orn.D-aThr.Phe_4Me.\n Lys_Boc.hHis.Aca.Cys_SEt.T.dK..Tyr_PO3H2.D-Chg.dV.Thr_PO3H2.N.D-Orn.D-aThr.Phe_4Me.",c.Hi.HELM,c.Hi.SEPARATOR,void 0,"mafft")}),{timeout:8e4,skipReason:"Fails in docker"}),(0,t.t6)("isCorrectSeparator",(async()=>{await r("seq\n F-W-P-H-E-Y\n Y-N-R-Q-W-Y-V\n M-K-P-S-E-Y-V","seq\n FWPHEY-\n YNRQWYV\n MKPSEYV",c.Hi.SEPARATOR,c.Hi.FASTA,c.YI.PT)})),(0,t.t6)("isCorrectSeparatorLong",(async()=>{await r("seq\n M-I-E-V-F-L-F-G-I-V-L-G-L-I-P-I-T-L-A-G-L-F-V-T-A-Y-L-Q-Y-R-R-G-D-Q-L-D-L\n M-M-E-L-V-L-K-T-I-I-G-P-I-V-V-G-V-V-L-R-I-V-D-K-W-L-N-K-D-K\n M-D-R-T-D-E-V-S-N-H-T-H-D-K-P-T-L-T-W-F-E-E-I-F-E-E-Y-H-S-P-F-H-N","seq\n MIEV-FLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL\n MMEL-VLKTII-GPIVVGVVLRIVDKWLNKDK------\n MDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN-----",c.Hi.SEPARATOR,c.Hi.FASTA,c.YI.PT)}))}));var w=n(1991),v=n.n(w),A=n(7278),E=n(6718),C=n(6642);async function T(t){const n=await async function(e){return await _e.files.readAsText(e)}(t),r=e.DataFrame.fromCsv(n);return r.name=t.replace(".csv",""),r}async function S(e,n=5e3){await(0,t.cb)(0),await(0,t.PE)(e.onAfterDrawContent,(()=>{}),(()=>{e.invalidate()}),n);const r=e.columns.length;for(let t=0;t<r;++t){const n=e.columns.byIndex(t);if(n){const t=e.cell(n.name,0),[r,i,a]=(0,C.BG)(t),c=(void 0,(s=o=a.rendererBack)&&void 0!==s.onRendered&&void 0!==s.invalidate&&void 0!==s.awaitRendered?o:null);c&&await c.awaitRendered()}}var o,s}var _=n(4139),P=n(4356);async function M(e,n){const r=(0,c.J9)(e);console.debug(`Bio: tests: splitters: src=${JSON.stringify(e)}, res=${JSON.stringify(r)} .`),(0,t.J6)(v().count(0).take(r.length).map((e=>r.getOriginal(e))).toArray(),n)}async function x(e,n){const r=(0,A.qp)(e);console.debug(`Bio: tests: splitters: src=${JSON.stringify(e)}, res=${JSON.stringify(r)} .`),(0,t.J6)(v().count(0).take(r.length).map((e=>r.getOriginal(e))).toArray(),n)}(0,t.L1)("splitters",(async()=>{(0,t.gM)((async()=>{})),(0,t.Pl)((async()=>{}));const e=["M[MeI]YKETLL[MeF]PKTDFPMRGGL[MeA]",["M","MeI","Y","K","E","T","L","L","MeF","P","K","T","D","F","P","M","R","G","G","L","MeA"]],n=["[meI][Pip][dK][Thr_PO3H2][L-hArg(Et,Et)][D-Tyr_Et][Tyr_ab-dehydroMe][dV]EN[D-Orn][D-aThr][Phe_4Me]",["meI","Pip","dK","Thr_PO3H2","L-hArg(Et,Et)","D-Tyr_Et","Tyr_ab-dehydroMe","dV","E","N","D-Orn","D-aThr","Phe_4Me"]],r=["PEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et.Tyr_ab-dehydroMe.dV.E.N.D-Orn.D-aThr.Phe_4Me}$$$",["meI","hHis","Aca","N","T","dE","Thr_PO3H2","Aca","D-Tyr_Et","Tyr_ab-dehydroMe","dV","E","N","D-Orn","D-aThr","Phe_4Me"]],o=["PEPTIDE1{meI.hHis.Aca.N.T.dK.Thr_PO3H2.Aca.D-Tyr_Et.D-Dap.dV.E.N.pnG.Phe_4Me}$$$",["meI","hHis","Aca","N","T","dK","Thr_PO3H2","Aca","D-Tyr_Et","D-Dap","dV","E","N","pnG","Phe_4Me"]],s=["PEPTIDE1{[meI].[hHis].[Aca].N.T.[dK].[Thr_PO3H2].[Aca].[D-Tyr_Et].[D-Dap].[dV].E.N.[pnG].[Phe_4Me]}$$$",["meI","hHis","Aca","N","T","dK","Thr_PO3H2","Aca","D-Tyr_Et","D-Dap","dV","E","N","pnG","Phe_4Me"]],i=["RNA1{R(U)P.R(T)P.R(G)P.R(C)P.R(A)}$$$$",["R(U)P","R(T)P","R(G)P","R(C)P","R(A)"]],a=["RNA1{P.R(U)P.R(T)}$$$$",["P","R(U)P","R(T)"]],c=["RNA1{P.R(U).P.R(T)}$$$$",["P","R(U)","P","R(T)"]];(0,t.t6)("fastaMulti",(async()=>{await M(e[0],e[1])})),(0,t.t6)("fastaFromHelm",(async()=>{await M(n[0],n[1])})),(0,t.t6)("helm1",(async()=>{await x(r[0],r[1])})),(0,t.t6)("helm2",(async()=>{await x(o[0],o[1])})),(0,t.t6)("helm3-multichar",(async()=>{await x(s[0],s[1])})),(0,t.t6)("testHelm1",(async()=>{await x(i[0],i[1])})),(0,t.t6)("testHelm2",(async()=>{await x(a[0],a[1])})),(0,t.t6)("testHelm3",(async()=>{await x(c[0],c[1])}))})),(0,t.L1)("splitters",(()=>{let n,r,o;(0,t.gM)((async()=>{n=await(0,l.Q)(),r=await(0,E.pj)(),o=await(0,P.ub)(),await r.loadMonomerLibForTests()})),(0,t.Pl)((async()=>{await(0,P.Eu)(o),await r.loadMonomerLib(!0)})),(0,t.t6)("splitToMonomers",(async()=>{const e=await a.dapi.files.readCsv("System:AppData/Bio/samples/MSA.csv"),n=e.getCol("MSA"),r=await a.functions.call("Bio:detectMacromolecule",{col:n});r&&(n.semType=r),n.setTag(c.gp.aligned,_.gN);const o=await a.functions.call("Bio:splitToMonomersTopMenu",{table:e,sequence:n});(0,t.E3)(o.columns.names().includes("17"),!0),await a.data.detectSemanticTypes(o);const s=a.shell.addTableView(o);await S(s.grid),(0,t.E3)(s.grid.dataFrame.id,e.id)})),(0,t.t6)("getHelmMonomers",(async()=>{const t=e.DataFrame.fromCsv("HELM,Activity\nPEPTIDE1{hHis.N.T}$$$,5.30751\nPEPTIDE1{hHis.Aca.Cys_SEt}$$$,5.72388\n");await a.data.detectSemanticTypes(t);const n=["hHis","Aca","Cys_SEt","N","T"],r=t.getCol("HELM"),o=await a.functions.call("Bio:getHelmMonomers",{sequence:r}),s=n.filter((e=>!o.includes(e))),i=o.filter((e=>!n.includes(e)));if(s.length>0||i.length){const e=[];throw s.length>0&&e.push(`Missed monomers ${JSON.stringify(s)}.`),i.length>0&&e.push(`Unexpected monomers ${JSON.stringify(i)}.`),new Error(e.join(" "))}}))}));var N=n(8604);(0,t.L1)("monomerLibraries",(()=>{let e,n=null;(0,t.gM)((async()=>{e=await(0,E.pj)(),n=(0,P.ub)()})),(0,t.Pl)((async()=>{await(0,P.Eu)(n)})),(0,t.t6)("default",(async()=>{await(0,P.Eu)({exclude:[],explicit:[],duplicateMonomerPreferences:{}}),await e.loadMonomerLib(!0);const n=e.getMonomerLib();(0,t.E3)(n.getPolymerTypes().length>0,!0)})),(0,t.t6)("forTests",(async()=>{await e.loadMonomerLibForTests(),function(e,n){const r=n,o=e.getSummaryObj();for(const e in r)r[e]||delete r[e];for(const e in o)o[e]||delete o[e];if(0==Object.keys(r).length&&0!=Object.keys(o).length)throw new Error("Expected empty monomer lib, actual is not.");if(0!=Object.keys(r).length&&0==Object.keys(o).length)throw new Error("Expected non-empty monomer lib, actual is empty.");try{(0,t.Xk)(o,r),(0,t.Xk)(r,o)}catch(e){throw new Error(`Expected monomer lib ${JSON.stringify(r)} does not match actual ${JSON.stringify(o)}.`)}}(e.getMonomerLib(),N.VV)})),(0,t.t6)("empty",(async()=>{const n=await(0,P.ub)(),r=await e.getFileManager();let o=r.getValidLibraryPaths();0===o.length&&(o=await r.getValidLibraryPathsAsynchronously()),n.exclude=o,n.explicit=[],await(0,P.Eu)(n),await e.loadMonomerLib(!0);const s=e.getMonomerLib().getPolymerTypes();(0,t.E3)(0===s.length,!0)})),(0,t.t6)("override",(async()=>{const n={symbol:"over1",name:"Test override monomer 1",molfile:"",author:"Test Author",id:0,rgroups:[],smiles:"",polymerType:"PEPTIDE",monomerType:"Backbone",createDate:null},r=e.getMonomerLib(),o=r.getMonomer(n.polymerType,n.symbol);(0,t.E3)(null===o,!0,`Unexpectedly found monomer '${n.symbol}' `);const s=r.override({[n.polymerType]:{[n.symbol]:n}},"test").getMonomer(n.polymerType,n.symbol);s&&(s.lib=void 0),(0,t.Xk)(s,n)}))}));var $=n(7389),L=n(1757),I=n.n(L),R=n(1858),O=n(6873),k=n(5433);async function G(n,r){const o=n(),s=e.DataFrame.fromColumns(o);await a.data.detectSemanticTypes(s);const i=Date.now(),c=(s.columns.byName("MSA"),a.shell.addTableView(s));await S(c.grid),(0,t.E3)(c.grid.dataFrame.id,s.id);const l=Date.now()-i;console.log(`Performance test: ${r}: ${l}ms`)}(0,t.L1)("renderers",(()=>{let n;(0,t.gM)((async()=>{n=await(0,l.Q)()})),(0,t.t6)("long sequence performance ",(async()=>{await G(O.dW,"Long sequences")})),(0,t.t6)("many sequence performance",(async()=>{await G(O.fD,"Many sequences")})),(0,t.t6)("rendererMacromoleculeFasta",(async()=>{await async function(){const n=await a.dapi.files.readAsText("System:AppData/Bio/samples/FASTA.csv"),r=e.DataFrame.fromCsv(n),o=r.getCol("Sequence"),s=await a.functions.call("Bio:detectMacromolecule",{col:o});s&&(o.semType=s);const i=a.shell.addTableView(r);await a.data.detectSemanticTypes(r),await S(i.grid),(0,t.E3)(i.grid.dataFrame.id,r.id);const c=o.getTag(e.TAGS.CELL_RENDERER);(0,t.E3)(c,"sequence")}()})),(0,t.t6)("rendererMacromoleculeSeparator",(async()=>{await async function(){const n=await a.dapi.files.readAsText("System:AppData/Bio/samples/SEPARATOR_PT.csv"),r=e.DataFrame.fromCsv(n),o=r.getCol("sequence"),s=await a.functions.call("Bio:detectMacromolecule",{col:o});s&&(o.semType=s);const i=a.shell.addTableView(r);await a.data.detectSemanticTypes(r),await S(i.grid),(0,t.E3)(i.grid.dataFrame.id,r.id);const c=o.getTag(e.TAGS.CELL_RENDERER);(0,t.E3)(c,"sequence")}()})),(0,t.t6)("rendererMacromoleculeDifference",(async()=>{await async function(){const n=e.Column.fromStrings("SequencesDiff",["meI/hHis/Aca/N/T/dK/Thr_PO3H2/Aca#D-Tyr_Et/Tyr_ab-dehydroMe/meN/E/N/dV"]);n.meta.units=c.Hi.SEPARATOR,n.setTag(c.gp.separator,"/"),n.setTag(c.gp.aligned,"SEQ"),n.setTag(c.gp.alphabet,"UN"),n.setTag(c.gp.alphabetIsMultichar,"true"),n.semType=_.uF.MACROMOLECULE_DIFFERENCE;const r=e.DataFrame.fromColumns([n]),o=a.shell.addTableView(r);await a.data.detectSemanticTypes(r),await S(o.grid),(0,t.E3)(o.grid.dataFrame.id,r.id);const s=n.getTag(e.TAGS.CELL_RENDERER);(0,t.E3)(s,_.uF.MACROMOLECULE_DIFFERENCE)}()})),(0,t.t6)("afterMsa",(async()=>{await async function(){const r=await a.dapi.files.readAsText("System:AppData/Bio/samples/FASTA.fasta"),o=(await a.functions.call("Bio:importFasta",{fileContent:r}))[0],s=o.getCol("sequence"),i=await a.functions.call("Bio:detectMacromolecule",{col:s});i&&(s.semType=i);const l=a.shell.addTableView(o);await a.data.detectSemanticTypes(o),console.log("Bio: tests/renderers/afterMsa, table view"),await S(l.grid),(0,t.E3)(l.grid.dataFrame.id,o.id),console.log(`Bio: tests/renderers/afterMsa, src before test semType="${s.semType}", units="${s.meta.units}", cell.renderer="${s.getTag(e.TAGS.CELL_RENDERER)}"`),(0,t.E3)(s.semType,e.SEMTYPE.MACROMOLECULE),(0,t.E3)(s.meta.units,c.Hi.FASTA),(0,t.E3)(s.getTag(c.gp.aligned),"SEQ"),(0,t.E3)(s.getTag(c.gp.alphabet),c.YI.PT),(0,t.E3)(s.getTag(e.TAGS.CELL_RENDERER),"sequence");const u=await(0,y.D)({col:s},n);await S(l.grid),(0,t.E3)(l.grid.dataFrame.id,o.id),(0,t.E3)(u.semType,e.SEMTYPE.MACROMOLECULE),(0,t.E3)(u.meta.units,c.Hi.FASTA),(0,t.E3)(u.getTag(c.gp.aligned),"SEQ.MSA"),(0,t.E3)(u.getTag(c.gp.alphabet),c.YI.PT),(0,t.E3)(u.getTag(e.TAGS.CELL_RENDERER),"sequence"),n.getSeqHandler(u)}()})),(0,t.t6)("afterConvert",(async()=>{await async function(){const r=await a.dapi.files.readAsText("System:AppData/Bio/samples/FASTA_PT.csv"),o=e.DataFrame.fromCsv(r),s=o.getCol("sequence"),i=await a.functions.call("Bio:detectMacromolecule",{col:s});i&&(s.semType=i);const l=a.shell.addTableView(o);await a.data.detectSemanticTypes(o);const u=await(0,k.r)(s,n,c.Hi.SEPARATOR,"/");await S(l.grid),(0,t.E3)(l.grid.dataFrame.id,o.id);const d=u.getTag(e.TAGS.CELL_RENDERER);(0,t.E3)(d,"sequence"),n.getSeqHandler(u)}()})),(0,t.t6)("afterConvertToHelm",(async()=>{await async function(){const r=await a.dapi.files.readCsv("System:AppData/Bio/samples/FASTA_PT.csv"),o=a.shell.addTableView(r);await S(o.grid),await r.meta.detectSemanticTypes(),await a.data.detectSemanticTypes(r);const s=r.getCol("sequence"),i=n.getSeqHandler(s).convert(c.Hi.HELM);r.columns.add(i),await S(o.grid),(0,t.E3)(i.getTag(e.TAGS.CELL_RENDERER),"helm")}()})),(0,t.t6)("selectRendererBySemType",(async()=>{await async function(){const n=e.Column.fromStrings("SequencesDiff",["meI/hHis/Aca/N/T/dK/Thr_PO3H2/Aca#D-Tyr_Et/Tyr_ab-dehydroMe/meN/E/N/dV"]);n.meta.units=c.Hi.SEPARATOR,n.setTag(c.gp.separator,"/"),n.setTag(c.gp.aligned,"SEQ"),n.setTag(c.gp.alphabet,"UN"),n.setTag(c.gp.alphabetIsMultichar,"true"),n.semType=_.uF.MACROMOLECULE_DIFFERENCE;const r=e.DataFrame.fromColumns([n]);a.shell.addTableView(r),await(0,t.cb)(100);const o=n.getTag(e.TAGS.CELL_RENDERER);if("MacromoleculeDifference"!==o)throw new Error(`Units 'separator', separator '/' and semType 'MacromoleculeDifference' have been manually set on column but after df was added as table, view renderer has set to '${o}' instead of correct 'MacromoleculeDifference'.`)}()})),(0,t.t6)("scatterPlotTooltip",(async()=>{await async function(){const n=e.DataFrame.fromCsv(r);n.currentRowIdx=0;const o=a.shell.addTableView(n);await n.meta.detectSemanticTypes(),await a.data.detectSemanticTypes(n);const s=n.plot.scatter({x:"x",y:"y"});o.dockManager.dock(s,e.DOCK_TYPE.RIGHT,null),await Promise.all([(0,t.PE)(s.onAfterDrawScene,(()=>{}),(()=>{s.invalidateCanvas()}),1e3),S(o.grid,500)]);const i=s.root.getBoundingClientRect(),c=s.worldToScreen(1,0),l=new MouseEvent("mousemove",{cancelable:!0,bubbles:!0,view:window,button:0,clientX:i.left+c.x,clientY:i.top+c.y}),u=I()(s.root).find("canvas").get()[0];await(0,t.PE)(e.debounce((0,R.fromEvent)(u,"mousemove"),200),(()=>{_e.logger.debug(`Test: event, currentRowIdx=${n.currentRowIdx}`),(0,t.E3)(I()($.tooltip.root).find("div table.d4-row-tooltip-table tr td canvas").length,1),(0,t.E3)(s.hitTest(c.x,c.y),1)}),(()=>{u.dispatchEvent(l)}),500),await S(o.grid,500)}()}),{skipReason:"GROK-17450"});const r="seq,x,y\nACGGTGTCGT,0,0\nCGGTATCCCT,1,0\nCTCGGCATGC,2,0\n"}));var D=n(6882);(0,t.L1)("renderers: monomerPlacer",(()=>{let n,r;(0,t.gM)((async()=>{n=await(0,E.pj)(),r=await(0,P.ub)(),await n.loadMonomerLibForTests()})),(0,t.Pl)((async()=>{await(0,P.Eu)(r),await n.loadMonomerLib(!0)}));const o={splitter:{csv:"id,seq\nid1,m1-M-m3-mon4-mon5-N-T-MON8-N9\nid2,m1-mon2-m3-mon4-mon5-Num-MON8-N9\nid3,mon1-M-mon3-mon4-mon5-MON8-N9\n",testList:[{src:{row:0,x:-1},tgt:{pos:null}},{src:{row:1,x:0},tgt:{pos:null}},{src:{row:1,x:5},tgt:{pos:0}},{src:{row:1,x:6},tgt:{pos:0}},{src:{row:1,x:26},tgt:{pos:1}},{src:{row:1,x:160},tgt:{pos:6}},{src:{row:1,x:190},tgt:{pos:7}},{src:{row:2,x:140},tgt:{pos:5}},{src:{row:2,x:145},tgt:{pos:5}}]},splitterMsa:{csv:"id,seq\nid1,m1-M-m3-mon4-mon5-N-T-MON8-N9\nid2,m1-mon2-m3-mon4-mon5-Num--MON8-N9\nid3,\nid4,mon1-M-mon3-mon4-mon5---MON8-N9\n",testList:[{src:{row:0,x:-1},tgt:{pos:null}},{src:{row:1,x:0},tgt:{pos:null}},{src:{row:1,x:1},tgt:{pos:null}},{src:{row:1,x:4},tgt:{pos:null}},{src:{row:1,x:5},tgt:{pos:0}},{src:{row:1,x:37},tgt:{pos:0}},{src:{row:1,x:38},tgt:{pos:1}},{src:{row:1,x:170},tgt:{pos:5}},{src:{row:1,x:200},tgt:{pos:5}},{src:{row:2,x:20},tgt:{pos:null}},{src:{row:3,x:170},tgt:{pos:5}},{src:{row:3,x:200},tgt:{pos:5}},{src:{row:3,x:297},tgt:{pos:null}}]},fastaMsa:{csv:"id,seq\nid1,QQYNIYPLT\nid2,QQWSSFPYT\nid3,\nid3,QHIRE--LT\n",testList:[{src:{row:1,x:-1},tgt:{pos:null}},{src:{row:1,x:0},tgt:{pos:null}},{src:{row:1,x:1},tgt:{pos:null}},{src:{row:1,x:19},tgt:{pos:0}},{src:{row:1,x:170},tgt:{pos:8}},{src:{row:1,x:171},tgt:{pos:8}},{src:{row:2,x:5},tgt:{pos:null}},{src:{row:3,x:170},tgt:{pos:8}},{src:{row:3,x:181},tgt:{pos:null}}]}};for(const[n,r]of Object.entries(o))(0,t.t6)(`getPosition-${n}`,(async()=>{const t=e.DataFrame.fromCsv(r.csv);await a.data.detectSemanticTypes(t);const n=t.getCol("seq"),o=new D.Jy(null,n,_e.logger,3,(()=>({font:"12px monospace",fontCharWidth:7,separatorWidth:12,monomerToShort:c.zS})));await o.init();const s=r.testList;for(let e=0;e<n.length;++e)o.getCellMonomerLengths(e,1e4);const i=[];for(const[e,t]of v().enumerate(s)){const t={pos:o.getPosition(e.src.row,e.src.x,1e4)};e.tgt.pos!=t.pos&&i.push(`Test src ${JSON.stringify(e.src)} expected tgt ${JSON.stringify(e.tgt)}, but get ${JSON.stringify({res:t})}`)}if(i.length>0)throw new Error("Test failed error(s):\n"+i.join(", \n"))}));const s=[10,20,30,40,50,60],i={left:{x:3,tgt:null},c0left:{x:10,tgt:0},c0mid:{x:12,tgt:0},c0right:{x:19,tgt:0},c1left:{x:20,tgt:1},c2right:{x:39,tgt:2},c4left:{x:50,tgt:4},c4right:{x:59,tgt:4},max:{x:60,tgt:null},right:{x:65,tgt:null}};for(const[e,n]of Object.entries(i))(0,t.t6)("hitBounds-"+e,(async()=>{const e=(0,D.Bb)(s,n.x);(0,t.E3)(e,n.tgt)}));const l={mono1:{src:{csv:"seq\nm1/m2/m3/m4/m5/m6/m7/m8/m9\nn1/m2/n3/m4/n5/m6/n7/m8/n9\nm1/n2/m3/n4/m5/n6/m7/n8/m9\n"},tgt:{lengths:[5,31,57,83,109,135,161,187,213,239]}},monoWithGaps:{src:{csv:"seq\nm1/m2/m3/m4/m5/m6//m8/m9\nn1/m2/n3/m4/n5/m6//m8/n9\nm1/n2/m3/n4/m5/n6/m7/n8/m9\n"},tgt:{lengths:[5,31,57,83,109,135,161,187,213,239]}},monoWithGapColumn:{src:{csv:"seq\nm1/m2/m3/m4/m5/m6//m8/m9\nn1/m2/n3/m4/n5/m6//m8/n9\nm1/n2/m3/n4/m5///n8/m9\n"},tgt:{lengths:[5,31,57,83,109,135,161,180,206,232]}}};for(const[n,r]of Object.entries(l))(0,t.t6)(`getCellMonomerLengths-${n}`,(async()=>{const n=e.DataFrame.fromCsv(r.src.csv);await a.data.detectSemanticTypes(n);const o=n.getCol("seq"),s=new D.Jy(null,o,_e.logger,3,(()=>({fontCharWidth:7,font:"12px monospace",separatorWidth:12,monomerToShort:c.zS})));await s.init();const i=s.getCellMonomerLengths(0,1e3)[1];(0,t.J6)(i,r.tgt.lengths)}))})),(0,t.L1)("converters",(()=>{let n,r;(0,t.gM)((async()=>{n=await(0,l.Q)()})),function(e){e.fastaPt="fastaPt",e.separatorPt="separatorPt",e.helmPt="helmPt",e.fastaDna="fastaDna",e.separatorDna="separatorDna",e.helmDna="helmDna",e.fastaRna="fastaRna",e.separatorRna="separatorRna",e.helmRna="helmRna",e.fastaGaps="fastaGaps",e.separatorGaps="separatorGaps",e.helmGaps="helmGaps",e.fastaUn="fastaUn",e.separatorUn="separatorUn",e.helmUn="helmUn",e.helmLoneDeoxyribose="helmLoneDeoxyribose",e.helmLoneRibose="helmLoneRibose",e.helmLonePhosphorus="helmLonePhosphorus",e.fastaLoneDeoxyribose="fastaLoneDeoxyribose",e.fastaLoneRibose="fastaLoneRibose",e.fastaLonePhosphorus="fastaLonePhosphorus"}(r||(r={}));const o={[r.fastaPt]:"seq\nFWPHEYFWPHEY\nYNRQWYVYNRQWYV\nMKPSEYVMKPSEYV",[r.separatorPt]:"seq\nF-W-P-H-E-Y-F-W-P-H-E-Y\nY-N-R-Q-W-Y-V-Y-N-R-Q-W-Y-V\nM-K-P-S-E-Y-V-M-K-P-S-E-Y-V",[r.helmPt]:"seq\nPEPTIDE1{F.W.P.H.E.Y.F.W.P.H.E.Y}$$$$\nPEPTIDE1{Y.N.R.Q.W.Y.V.Y.N.R.Q.W.Y.V}$$$$\nPEPTIDE1{M.K.P.S.E.Y.V.M.K.P.S.E.Y.V}$$$$",[r.fastaDna]:"seq\nACGTCACGTC\nCAGTGTCAGTGT\nTTCAACTTCAAC",[r.separatorDna]:"seq\nA/C/G/T/C/A/C/G/T/C\nC/A/G/T/G/T/C/A/G/T/G/T\nT/T/C/A/A/C/T/T/C/A/A/C",[r.helmDna]:"seq\nRNA1{d(A)p.d(C)p.d(G)p.d(T)p.d(C)p.d(A)p.d(C)p.d(G)p.d(T)p.d(C)p}$$$$\nRNA1{d(C)p.d(A)p.d(G)p.d(T)p.d(G)p.d(T)p.d(C)p.d(A)p.d(G)p.d(T)p.d(G)p.d(T)p}$$$$\nRNA1{d(T)p.d(T)p.d(C)p.d(A)p.d(A)p.d(C)p.d(T)p.d(T)p.d(C)p.d(A)p.d(A)p.d(C)p}$$$$",[r.fastaRna]:"seq\nACGUCACGUC\nCAGUGUCAGUGU\nUUCAACUUCAAC",[r.separatorRna]:"seq\nA*C*G*U*C*A*C*G*U*C\nC*A*G*U*G*U*C*A*G*U*G*U\nU*U*C*A*A*C*U*U*C*A*A*C",[r.helmRna]:"seq\nRNA1{r(A)p.r(C)p.r(G)p.r(U)p.r(C)p.r(A)p.r(C)p.r(G)p.r(U)p.r(C)p}$$$$\nRNA1{r(C)p.r(A)p.r(G)p.r(U)p.r(G)p.r(U)p.r(C)p.r(A)p.r(G)p.r(U)p.r(G)p.r(U)p}$$$$\nRNA1{r(U)p.r(U)p.r(C)p.r(A)p.r(A)p.r(C)p.r(U)p.r(U)p.r(C)p.r(A)p.r(A)p.r(C)p}$$$$",[r.fastaGaps]:"seq\nFW-PH-EYYFW-PH-EYY\nFYNRQWYV-FYNRQWYV-\nFKP-Q-SEYVFKP-Q-SEYV",[r.separatorGaps]:"seq\nF/W//P/H//E/Y/Y/F/W//P/H//E/Y/Y\nF/Y/N/R/Q/W/Y/V//F/Y/N/R/Q/W/Y/V/\nF/K/P//Q//S/E/Y/V/F/K/P//Q//S/E/Y/V",[r.helmGaps]:"seq\nPEPTIDE1{F.W.*.P.H.*.E.Y.Y.F.W.*.P.H.*.E.Y.Y}$$$$\nPEPTIDE1{F.Y.N.R.Q.W.Y.V.*.F.Y.N.R.Q.W.Y.V.*}$$$$\nPEPTIDE1{F.K.P.*.Q.*.S.E.Y.V.F.K.P.*.Q.*.S.E.Y.V}$$$$",[r.fastaUn]:"seq\n[meI][hHis][Aca]NT[dE][Thr_PO3H2][Aca]D[meI][hHis][Aca]NT[dE][Thr_PO3H2][Aca]D\n[meI][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2][meI][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2]\n[Lys_Boc][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2][Lys_Boc][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca]",[r.separatorUn]:"seq\nmeI-hHis-Aca-N-T-dE-Thr_PO3H2-Aca-D-meI-hHis-Aca-N-T-dE-Thr_PO3H2-Aca-D\nmeI-hHis-Aca-Cys_SEt-T-dK-Thr_PO3H2-Aca-Tyr_PO3H2-meI-hHis-Aca-Cys_SEt-T-dK-Thr_PO3H2-Aca-Tyr_PO3H2\nLys_Boc-hHis-Aca-Cys_SEt-T-dK-Thr_PO3H2-Aca-Tyr_PO3H2-Lys_Boc-hHis-Aca-Cys_SEt-T-dK-Thr_PO3H2-Aca",[r.helmUn]:"seq\nPEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D.meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D}$$$$\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2.meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2}$$$$\nPEPTIDE1{Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2.Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca}$$$$",[r.helmLoneDeoxyribose]:"seq\nRNA1{d(A).d(C).d(G).d(T).d(C).d(A).d(C).d(G).d(T).d(C)}$$$$\nRNA1{d(C).d(A).d(G).d(T).d(G).d(T)p.d(C).d(A).d(G).d(T).d(G).d(T)p}$$$$\nRNA1{d(T).d(T).d(C).d(A).d(A).d(C)p.d(T).d(T).d(C).d(A).d(A).d(C)p}$$$$",[r.helmLoneRibose]:"seq\nRNA1{r(A).r(C).r(G).r(U).r(C).r(A).r(C).r(G).r(U).r(C)}$$$$\nRNA1{r(C).r(A).r(G).r(U).r(G).r(U)p.r(C).r(A).r(G).r(U).r(G).r(U)p}$$$$\nRNA1{r(U).r(U).r(C).r(A).r(A).r(C)p.r(U).r(U).r(C).r(A).r(A).r(C)p}$$$$",[r.helmLonePhosphorus]:"seq\nRNA1{p.p.r(A)p.r(C)p.r(G)p.r(U)p.r(C)p.r(A)p.r(C)p.r(G)p.r(U)p.r(C)p}$$$$\nRNA1{p.p.r(C)p.r(A)p.p.r(G)p.r(U)p.r(G)p.r(U)p.r(C)p.r(A)p.p.r(G)p.r(U)p.r(G)p.r(U)p}$$$$\nRNA1{p.r(U)p.r(U)p.r(C)p.r(A)p.r(A)p.r(C)p.r(U)p.r(U)p.r(C)p.r(A)p.r(A)p.r(C)p.p.p}$$$$"},s=new Set(Object.values(c.gp));async function i(t){const n=o[t],r=e.DataFrame.fromCsv(n);return await a.data.detectSemanticTypes(r),r}function u(e,r){if(e===c.Hi.SEPARATOR&&!r)throw new Error(`Argument 'separator' is mandatory for target notation '${e.toString()}'.`);return function(o){const s=n.getSeqHandler(o).convert(e,r);return(0,t.E3)(s.meta.units,e),s}}async function d(e,r,o){const a=(await i(e)).getCol("seq"),l=r(a),u=(await i(o)).getCol("seq");(0,t.J6)(l.toList(),u.toList());const d=n.getSeqHandler(a),h=n.getSeqHandler(l);for(const[e,n]of Object.entries(u.tags)){if(!s.has(e)||d.notation===c.Hi.HELM&&[c.gp.alphabet,c.gp.alphabetIsMultichar].includes(e)||h.notation===c.Hi.HELM&&[c.gp.alphabet,c.gp.alphabetIsMultichar].includes(e))continue;const r=l.getTag(e);(0,t.E3)(r,n,`Tag '${e}' expected value '${n}' is not equal to actual '${r}'.`)}}(0,t.t6)("testFastaPtToSeparator",(async()=>{await d(r.fastaPt,u(c.Hi.SEPARATOR,"-"),r.separatorPt)})),(0,t.t6)("testFastaDnaToSeparator",(async()=>{await d(r.fastaDna,u(c.Hi.SEPARATOR,"/"),r.separatorDna)})),(0,t.t6)("testFastaRnaToSeparator",(async()=>{await d(r.fastaRna,u(c.Hi.SEPARATOR,"*"),r.separatorRna)})),(0,t.t6)("testFastaGapsToSeparator",(async()=>{await d(r.fastaGaps,u(c.Hi.SEPARATOR,"/"),r.separatorGaps)})),(0,t.t6)("testFastaUnToSeparator",(async()=>{await d(r.fastaUn,u(c.Hi.SEPARATOR,"-"),r.separatorUn)})),(0,t.t6)("testFastaPtToHelm",(async()=>{await d(r.fastaPt,u(c.Hi.HELM),r.helmPt)})),(0,t.t6)("testFastaDnaToHelm",(async()=>{await d(r.fastaDna,u(c.Hi.HELM),r.helmDna)})),(0,t.t6)("testFastaRnaToHelm",(async()=>{await d(r.fastaRna,u(c.Hi.HELM),r.helmRna)})),(0,t.t6)("testFastaGapsToHelm",(async()=>{await d(r.fastaGaps,u(c.Hi.HELM),r.helmGaps)})),(0,t.t6)("testSeparatorPtToFasta",(async()=>{await d(r.separatorPt,u(c.Hi.FASTA),r.fastaPt)})),(0,t.t6)("testSeparatorDnaToFasta",(async()=>{await d(r.separatorDna,u(c.Hi.FASTA),r.fastaDna)})),(0,t.t6)("testSeparatorRnaToFasta",(async()=>{await d(r.separatorRna,u(c.Hi.FASTA),r.fastaRna)})),(0,t.t6)("testSeparatorGapsToFasta",(async()=>{await d(r.separatorGaps,u(c.Hi.FASTA),r.fastaGaps)})),(0,t.t6)("testSeparatorUnToFasta",(async()=>{await d(r.separatorUn,u(c.Hi.FASTA),r.fastaUn)})),(0,t.t6)("testSeparatorPtToHelm",(async()=>{await d(r.separatorPt,u(c.Hi.HELM),r.helmPt)})),(0,t.t6)("testSeparatorDnaToHelm",(async()=>{await d(r.separatorDna,u(c.Hi.HELM),r.helmDna)})),(0,t.t6)("testSeparatorRnaToHelm",(async()=>{await d(r.separatorRna,u(c.Hi.HELM),r.helmRna)})),(0,t.t6)("testSeparatorGapsToHelm",(async()=>{await d(r.separatorGaps,u(c.Hi.HELM),r.helmGaps)})),(0,t.t6)("testHelmDnaToFasta",(async()=>{await d(r.helmDna,u(c.Hi.FASTA),r.fastaDna)})),(0,t.t6)("testHelmRnaToFasta",(async()=>{await d(r.helmRna,u(c.Hi.FASTA),r.fastaRna)})),(0,t.t6)("testHelmPtToFasta",(async()=>{await d(r.helmPt,u(c.Hi.FASTA),r.fastaPt)})),(0,t.t6)("testHelmUnToFasta",(async()=>{await d(r.helmUn,u(c.Hi.FASTA),r.fastaUn)})),(0,t.t6)("testHelmDnaToSeparator",(async()=>{await d(r.helmDna,u(c.Hi.SEPARATOR,"/"),r.separatorDna)})),(0,t.t6)("testHelmRnaToSeparator",(async()=>{await d(r.helmRna,u(c.Hi.SEPARATOR,"*"),r.separatorRna)})),(0,t.t6)("testHelmPtToSeparator",(async()=>{await d(r.helmPt,u(c.Hi.SEPARATOR,"-"),r.separatorPt)})),(0,t.t6)("testHelmUnToSeparator",(async()=>{await d(r.helmUn,u(c.Hi.SEPARATOR,"-"),r.separatorUn)})),(0,t.t6)("testHelmLoneRibose",(async()=>{await d(r.helmLoneRibose,u(c.Hi.FASTA),r.fastaRna)})),(0,t.t6)("testHelmLoneDeoxyribose",(async()=>{await d(r.helmLoneDeoxyribose,u(c.Hi.SEPARATOR,"/"),r.separatorDna)})),(0,t.t6)("testHelmLonePhosphorus",(async()=>{await d(r.helmLonePhosphorus,u(c.Hi.FASTA),r.fastaRna)}))}));var H=n(3516);(0,t.L1)("fastaFileHandler",(()=>{const n=["description:1","description:2","description:3","description:4"],r=(e.Column.fromStrings("description",n),["MDYKETLLMPKTDFPMRGGLPNKEPQIQEKW","MIEVFLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL","MMELVLKTIIGPIVVGVVLRIVDKWLNKDK","MDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN"]);function o(e){const o=new H.m(e),s=o.descriptionsArray,i=o.sequencesArray;(0,t.J6)([s,i],[n,r])}(0,t.t6)("testNormalFormatting",(async()=>{o(">description:1\nMDYKETLLMPKTDFPMRGGLPNKEPQIQEKW\n\n>description:2\nMIEVFLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL\n\n>description:3\nMMELVLKTIIGPIVVGVVLRIVDKWLNKDK\n\n>description:4\nMDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN\n")})),(0,t.t6)("testExtraSpaces",(async()=>{o(">description:1\n MDYKETLLMPKTDFPMRGGLPNKEPQIQEKW\n\n>description:2\nMI EVF LFGIVLGLI PITLAGLFVTAY LQYRRGDQLDL\n\n>description:3\nM MELVLKTI IGPI VVGVVLR IVDKWLNKDK\n\n>description:4\nMDR TDEVSNHTHDKP TLTWFEEIFEEYHSPFHN\n ")})),(0,t.t6)("testExtraNewlines",(async()=>{o(">description:1\n\nMDYKETLLMPKTDFPMRGGLPNKEPQIQEKW\n\n>description:2\nMIEVF\nLFGIVLGLI\nPITLAGLFVTA\nYLQYRRGDQLDL\n\n>description:3\nM\nME\n\nLVLKTIIG\n\nPIVVGVVLRI\nVDKWLNKDK\n\n\n>description:4\n\nMDRT\n\nDEVSNHTHDKP\n\nTLTWFEEIFEE\n\n\n\nYHSPFHN\n")}))}));var F=n(3890);(0,t.L1)("fastaExport",(()=>{let n,r;(0,t.gM)((async()=>{n=await(0,l.Q)()})),function(e){e.single="single",e.multi="multi"}(r||(r={}));const o={[r.single]:{src:"MDYKETLLMPKTDFPMRGGLP",tgt:["MDYKETLLMP","KTDFPMRGGL","P"]},[r.multi]:{src:"M[MeI]YKETLL[MeF]PKTDFPMRGGL[MeA]",tgt:["M[MeI]YKETLL[MeF]P","KTDFPMRGGL","[MeA]"]}};let s;!function(e){e.test1="test1",e.test2="test2"}(s||(s={}));const i={[s.test1]:{srcCsv:"id,seq\n1,MDYKETLLMP\n2,KTDFPMRGGL\n3,P",idCols:["id"],seqCol:"seq",lineWidth:10,tgtFasta:">1\nMDYKETLLMP\n>2\nKTDFPMRGGL\n>3\nP\n"},[s.test2]:{srcCsv:"id,id2,seq\n1,seqA,M[MeI]YKETLL[MeF]P\n2,seqB,KTDFPMRGGL\n3,seqC,[MeA]\n",idCols:["id2","id"],seqCol:"seq",lineWidth:5,tgtFasta:">seqA|1\nM[MeI]YKE\nTLL[MeF]P\n>seqB|2\nKTDFP\nMRGGL\n>seqC|3\n[MeA]\n"}};function a(r,s=10){const i=o[r].src,a=e.Column.fromStrings("src",[i]);a.semType=e.SEMTYPE.MACROMOLECULE,a.meta.units=c.Hi.FASTA;const l=n.getSeqHandler(a).getSplitted(0),u=(0,F.aS)(l,s),d=o[r].tgt;(0,t.J6)(u,d)}async function u(r){const o=e.DataFrame.fromCsv(r.srcCsv),s=o.getCol(r.seqCol);s.semType=e.SEMTYPE.MACROMOLECULE,s.meta.units=c.Hi.FASTA;const i=r.idCols.map((e=>o.getCol(e))),a=n.getSeqHandler(s),l=(0,F.wz)(i,a,r.lineWidth);(0,t.E3)(l,r.tgtFasta)}(0,t.t6)("wrapSequenceSingle",(async()=>{a(r.single,10)})),(0,t.t6)("wrapSequenceMulti",(async()=>{a(r.multi,10)})),(0,t.t6)("saveAsFastaTest1",(async()=>{u(i[s.test1])})),(0,t.t6)("saveAsFastaTest2",(async()=>{u(i[s.test2])}))}));var V=n(4152),U=n(439);const B=U._S;(0,t.L1)("bio",(()=>{let n;(0,t.gM)((async()=>{n=await(0,l.Q)()}));const r="seq\nACGTCT\nCAGTGT\nTTCAAC";(0,t.t6)("testGetStatsHelm1",(async()=>{const n=e.DataFrame.fromCsv("seq\nPEPTIDE1{meI}$$$$").getCol("seq");n.semType=e.SEMTYPE.MACROMOLECULE,n.meta.units=c.Hi.HELM;const r=(0,A.vZ)(n,1,c.qp);(0,t.Xk)(r.freq,{meI:1}),(0,t.E3)(r.sameLength,!0)})),(0,t.t6)("testGetStatsN1",(async()=>{await function(n){const r=e.DataFrame.fromCsv(n).col("seq");r.semType=e.SEMTYPE.MACROMOLECULE,r.meta.units=c.Hi.FASTA;const o=(0,A.vZ)(r,5,c.J9);(0,t.Xk)(o.freq,{A:4,C:5,G:3,T:6}),(0,t.E3)(o.sameLength,!0)}(r)})),(0,t.t6)("testGetAlphabetSimilarity",(async()=>{await async function(){const e={A:2041,C:3015,G:3015,T:2048,[B]:1e3},n=new Set(Object.keys(i.Q.Names)),r=(0,c.nq)(e,n);(0,t.E3)(r>.6,!0)}()})),(0,t.t6)("testPickupPaletteN1",(async()=>{await async function(r){const o=e.DataFrame.fromCsv(r).col("seq");o.semType=e.SEMTYPE.MACROMOLECULE,o.meta.units=c.Hi.FASTA;const s=(0,c.SM)(o,n);(0,t.E3)(s instanceof i.A,!0)}(r)})),(0,t.t6)("testPickupPaletteN1e",(async()=>{await async function(){const r=e.DataFrame.fromCsv("seq\nACGTAT\nCAGTTG\nTTCG2C").col("seq");r.semType=e.SEMTYPE.MACROMOLECULE,r.meta.units=c.Hi.FASTA;const o=(0,c.SM)(r,n);(0,t.E3)(o instanceof i.A,!0)}()})),(0,t.t6)("testPickupPaletteAA1",(async()=>{await async function(){const r=e.DataFrame.fromCsv("seq\nFWPHEYV\nYNRQWYV\nMKPSEYV").col("seq");r.semType=e.SEMTYPE.MACROMOLECULE,r.meta.units=c.Hi.FASTA;const s=(0,c.SM)(r,n);(0,t.E3)(s instanceof o.X,!0)}()})),(0,t.t6)("testPickupPaletteX",(async()=>{await async function(){const r=e.DataFrame.fromCsv("seq\nXZJ{}2\n5Z4733\n3Z6></\n675687").col("seq");r.semType=e.SEMTYPE.MACROMOLECULE,r.meta.units=c.Hi.FASTA;const o=(0,c.SM)(r,n);(0,t.E3)(o instanceof V.$u,!0)}()}))})),(0,t.L1)("WebLogo.monomerToShort",(()=>{(0,t.t6)("longMonomerSingle",(async()=>{(0,t.E3)((0,c.zS)("S",5),"S")})),(0,t.t6)("longMonomerShort",(async()=>{(0,t.E3)((0,c.zS)("Short",5),"Short")})),(0,t.t6)("longMonomerLong56",(async()=>{(0,t.E3)((0,c.zS)("Long56",6),"Long56")})),(0,t.t6)("longMonomerComplexFirstPartShort",(async()=>{(0,t.E3)((0,c.zS)("Long-long",5),"Long…")})),(0,t.t6)("longMonomerComplexFirstPartLong56",(async()=>{(0,t.E3)((0,c.zS)("Long56-long",6),"Long5…")})),(0,t.t6)("monomerToShort",(async()=>{const e=[["AbC","AbC"],["AbCd","Ab…"],["ABc","ABc"],["ABcd","AB…"],["A_b","A_b"],["A_bc","A…"],["Ab_c","Ab…"],["A1_b","A1…"],["Abc_d","Ab…"],["Abcd_e","Ab…"],["A-b","A-b"],["A-bc","A…"],["Ab-c","Ab…"],["A1-b","A1…"],["Abc-d","Ab…"],["Abcd-e","Ab…"],["A","A"],["Ab","Ab"],["Abc","Abc"],["Ab…","Ab…"],["Abcd","Ab…"],["Abcde","Ab…"]],n=e.map((e=>e[0])),r=e.map((e=>e[1])),o=n.map((e=>(0,c.zS)(e,3)));(0,t.J6)(o,r)}))}));var Y=n(250);const W=U._S;function j(e,n){(0,t.E3)(e.name,n.name),(0,t.J6)(e.getMonomers(),n.getMonomers());for(const r of e.getMonomers())(0,t.E3)(e.getFreq(r).rowCount,n.getFreq(r).rowCount)}(0,t.L1)("WebLogo.positions",(()=>{let n;(0,t.gM)((async()=>{n=await(0,l.Q)()}));const r="seq\nATC-G-TTGC--\nATC-G-TTGC--\n-TC-G-TTGC--\n-TC-GCTTGC--\n-TC-GCTTGC--";(0,t.t6)("allPositions",(async()=>{const n=e.DataFrame.fromCsv(r),o=a.shell.addTableView(n),s=n.getCol("seq");s.semType=e.SEMTYPE.MACROMOLECULE,s.meta.units=c.Hi.FASTA,s.setTag(c.gp.alphabet,c.YI.DNA),s.setTag(c.gp.aligned,"SEQ.MSA");const i=await n.plot.fromType("WebLogo");await(0,t.PE)(i.onLayoutCalculated,(()=>{}),(()=>{o.dockManager.dock(i.root,e.DOCK_TYPE.DOWN)}),500,"Layout calculate timeout");const l=i.positions,u=[new Y.Ue(0,"1",{A:new Y.Tc(2),[W]:new Y.Tc(3)}),new Y.Ue(1,"2",{T:new Y.Tc(5)}),new Y.Ue(2,"3",{C:new Y.Tc(5)}),new Y.Ue(3,"4",{[W]:new Y.Tc(5)}),new Y.Ue(4,"5",{G:new Y.Tc(5)}),new Y.Ue(5,"6",{[W]:new Y.Tc(3),C:new Y.Tc(2)}),new Y.Ue(6,"7",{T:new Y.Tc(5)}),new Y.Ue(7,"8",{T:new Y.Tc(5)}),new Y.Ue(8,"9",{G:new Y.Tc(5)}),new Y.Ue(9,"10",{C:new Y.Tc(5)}),new Y.Ue(10,"11",{[W]:new Y.Tc(5)}),new Y.Ue(11,"12",{[W]:new Y.Tc(5)})];(0,t.E3)(l.length,u.length);for(let e=0;e<l.length;e++){(0,t.E3)(l[e].name,u[e].name);for(const n of l[e].getMonomers())(0,t.E3)(l[e].getFreq(n).rowCount,u[e].getFreq(n).rowCount)}await i.awaitRendered()})),(0,t.t6)("positions with shrinkEmptyTail option true (filtered)",(async()=>{const n=e.DataFrame.fromCsv("seq\n-TC-G-TTGC--\n-TC-GCTTGC--\n-T--C-GT-\n-T--C-GT-\n-T--C-GT-\n-T--CCGT-"),r=a.shell.addTableView(n),o=n.getCol("seq");o.semType=e.SEMTYPE.MACROMOLECULE,o.meta.units=c.Hi.FASTA,o.setTag(c.gp.alphabet,c.YI.DNA),o.setTag(c.gp.aligned,"SEQ"),n.filter.init((e=>e>2)),n.filter.fireChanged();const s=await n.plot.fromType("WebLogo",{shrinkEmptyTail:!0});await(0,t.PE)(s.onLayoutCalculated,(()=>{}),(()=>{r.dockManager.dock(s.root,e.DOCK_TYPE.DOWN)}),500);const i=s.positions,l=[new Y.Ue(0,"1",{[W]:new Y.Tc(3)}),new Y.Ue(1,"2",{T:new Y.Tc(3)}),new Y.Ue(2,"3",{[W]:new Y.Tc(3)}),new Y.Ue(3,"4",{[W]:new Y.Tc(3)}),new Y.Ue(4,"5",{C:new Y.Tc(3)}),new Y.Ue(5,"6",{[W]:new Y.Tc(2),C:new Y.Tc(1)}),new Y.Ue(6,"7",{G:new Y.Tc(3)}),new Y.Ue(7,"8",{T:new Y.Tc(3)}),new Y.Ue(8,"9",{[W]:new Y.Tc(3)})];(0,t.E3)(i.length,l.length);for(let e=0;e<i.length;e++){(0,t.E3)(i[e].name,l[e].name);for(const n of i[e].getMonomers())(0,t.E3)(i[e].getFreq(n).rowCount,l[e].getFreq(n).rowCount)}await s.awaitRendered()})),(0,t.t6)("positions with skipEmptyPositions option",(async()=>{const n=e.DataFrame.fromCsv(r),o=a.shell.addTableView(n),s=n.getCol("seq");s.semType=e.SEMTYPE.MACROMOLECULE,s.meta.units=c.Hi.FASTA,s.setTag(c.gp.alphabet,c.YI.DNA),s.setTag(c.gp.aligned,"SEQ.MSA");const i=await n.plot.fromType("WebLogo",{skipEmptyPositions:!0});await(0,t.PE)(i.onLayoutCalculated,(()=>{}),(()=>{o.dockManager.dock(i.root,e.DOCK_TYPE.DOWN)}),500);const l=i.positions,u=[new Y.Ue(0,"1",{A:new Y.Tc(2),[W]:new Y.Tc(3)}),new Y.Ue(1,"2",{T:new Y.Tc(5)}),new Y.Ue(2,"3",{C:new Y.Tc(5)}),new Y.Ue(4,"5",{G:new Y.Tc(5)}),new Y.Ue(5,"6",{[W]:new Y.Tc(3),C:new Y.Tc(2)}),new Y.Ue(6,"7",{T:new Y.Tc(5)}),new Y.Ue(7,"8",{T:new Y.Tc(5)}),new Y.Ue(8,"9",{G:new Y.Tc(5)}),new Y.Ue(9,"10",{C:new Y.Tc(5)})];(0,t.E3)(l.length,u.length);for(let e=0;e<l.length;e++)j(l[e],u[e]);await i.awaitRendered()})),(0,t.t6)("count sequences for monomer at position",(async()=>{const o=function(t,n,r){const o=e.DataFrame.fromCsv(t),s=o.getCol("seq");return s.semType=e.SEMTYPE.MACROMOLECULE,s.meta.units=n,s.setTag(c.gp.alphabet,r),s.setTag(c.gp.aligned,"SEQ.MSA"),o}(r,c.Hi.FASTA,c.YI.DNA),s=o.getCol("seq"),i=a.shell.addTableView(o),l=await o.plot.fromType("WebLogo",{startPositionName:"3",endPositionName:"7",skipEmptyPositions:!0});await(0,t.PE)(l.onLayoutCalculated,(()=>{}),(()=>{i.dockManager.dock(l.root,e.DOCK_TYPE.DOWN)}),500);const u=l.positions,d=[new Y.Ue(2,"3",{C:new Y.Tc(5)}),new Y.Ue(4,"5",{G:new Y.Tc(5)}),new Y.Ue(5,"6",{[W]:new Y.Tc(3),C:new Y.Tc(2)}),new Y.Ue(6,"7",{T:new Y.Tc(5)})];(0,t.E3)(u.length,d.length);for(let e=0;e<u.length;e++)j(u[e],d[e]);const h=u[1],p=n.getSeqHandler(s),m=(0,Y.eN)(o,p,o.filter,"G",h);(0,t.E3)(m,5),await l.awaitRendered()})),(0,t.t6)("empty",(async()=>{const n=e.DataFrame.fromColumns([(()=>{const t=e.Column.fromStrings("seq",[]);return t.semType=e.SEMTYPE.MACROMOLECULE,t.meta.units=c.Hi.FASTA,t.setTag(c.gp.alphabet,c.YI.DNA),t})()]),r=a.shell.addTableView(n),o=await n.plot.fromType("WebLogo");await(0,t.PE)(o.onLayoutCalculated,(()=>{}),(()=>{r.dockManager.dock(o.root,e.DOCK_TYPE.DOWN)}),500),o.positions,await o.awaitRendered()}))})),(0,t.L1)("WebLogo.project",(()=>{(0,t.t6)("fasta",(async()=>{const n="Tests.Bio.WebLogo-project.fasta",r=await _e.files.readCsv("tests/filter_FASTA.csv"),o=r.name,s=r.getCol("fasta");await a.data.detectSemanticTypes(r);const i=a.shell.addTableView(r),c=await r.plot.fromType("WebLogo",{sequenceColumnName:s.name});i.dockManager.dock(c),await c.awaitRendered(),await S(i.grid),await async function(t,n,r,o){const s=e.Project.create(),i=r.saveLayout();s.name=t,s.addChild(n),s.addChild(i),await a.dapi.layouts.save(r.saveLayout()),await a.dapi.tables.uploadDataFrame(o),await a.dapi.tables.save(n),await a.dapi.projects.save(s)}(n,r.getTableInfo(),i,r),a.shell.closeAll(),await(0,t.cb)(500),await a.dapi.projects.open(n);const l=a.shell.getTableView(o),u=v()(l.viewers).toArray();(0,t.E3)(u.length,2),(0,t.E3)(u.filter((e=>"Grid"===e.type)).length,1);const d=u.find((e=>"WebLogo"===e.type));(0,t.E3)(!!d,!0),await S(i.grid),await d.awaitRendered()}),{skipReason:"depends on 1.18"})})),(0,t.L1)("WebLogo.layout",(()=>{(0,t.t6)("fasta",(async()=>{const e=await _e.files.readCsv("tests/filter_FASTA.csv"),n=e.getCol("fasta");await a.data.detectSemanticTypes(e);const r=a.shell.addTableView(e),o=await e.plot.fromType("WebLogo",{sequenceColumnName:n.name});r.dockManager.dock(o),await(0,t.cb)(2*Y.VN.render),await o.awaitRendered(),await S(r.grid);const s=r.saveLayout();s.toJson(),r.loadLayout(s),await(0,t.cb)(2*Y.VN.render),await o.awaitRendered(),await S(r.grid);const i=v()(r.viewers).toArray();(0,t.E3)(i.length,2),(0,t.E3)(i.filter((e=>"Grid"===e.type)).length,1),(0,t.E3)(i.filter((e=>"WebLogo"===e.type)).length,1)}))}));var K=n(966);function q(e,t){let n=null;for(const r of e.viewers)r.type===t&&(n=r);return n}(0,t.L1)("checkInputColumn",(()=>{let n;(0,t.gM)((async()=>{n=await(0,l.Q)()}));const r="seq\nseq1,\nseq2,\nseq3,\nseq4";(0,t.t6)("testMsaPos",(async()=>{const o=e.DataFrame.fromCsv(r).getCol("seq");o.semType=e.SEMTYPE.MACROMOLECULE,o.meta.units=c.Hi.FASTA,o.setTag(c.gp.alphabet,c.YI.DNA),o.setTag(c.gp.aligned,"SEQ");const[s,i]=(0,K.l)(o,"Test",n,[c.Hi.FASTA],[c.YI.DNA,c.YI.RNA,c.YI.PT]);(0,t.E3)(s,!0)})),(0,t.t6)("testMsaNegHelm",(async()=>{const o=e.DataFrame.fromCsv(r).getCol("seq");o.semType=e.SEMTYPE.MACROMOLECULE,o.meta.units=c.Hi.HELM,o.setTag(c.gp.alphabetIsMultichar,"true");const[s,i]=(0,K.l)(o,"Test",n,[c.Hi.FASTA],[c.YI.DNA,c.YI.RNA,c.YI.PT]);(0,t.E3)(s,!1)})),(0,t.t6)("testMsaNegUN",(async()=>{const o=e.DataFrame.fromCsv(r).getCol("seq");o.semType=e.SEMTYPE.MACROMOLECULE,o.meta.units=c.Hi.FASTA,o.setTag(c.gp.alphabet,"UN"),o.setTag(c.gp.alphabetSize,"11"),o.setTag(c.gp.alphabetIsMultichar,"true"),o.setTag(c.gp.aligned,"SEQ");const[s,i]=(0,K.l)(o,"Test",n,[c.Hi.FASTA],[c.YI.DNA,c.YI.RNA,c.YI.PT]);(0,t.E3)(s,!1)})),(0,t.t6)("testGetActionFunctionMeta",(async()=>{e.Func.find({package:"Bio",name:"multipleSequenceAlignmentDialog"})[0].inputs.find((e=>"sequence"==e.name))}))})),(0,t.L1)("similarity/diversity",(async()=>{(0,t.t6)("similaritySearchViewer",(async()=>{await async function(){const n=await _e.files.readAsText("tests/sample_MSA_data.csv"),r=e.DataFrame.fromCsv(n);await a.data.detectSemanticTypes(r);const o=a.shell.addTableView(r),s=o.dataFrame.getCol("MSA");(0,t.E3)(s.semType,e.SEMTYPE.MACROMOLECULE);const i=await o.dataFrame.plot.fromType("Sequence Similarity Search");let c=!1;if(i.computeCompleted.subscribe((e=>{e&&(c=!0)})),o.dockManager.dock(i,e.DOCK_TYPE.RIGHT,null,"Similarity"),await i.renderPromise,await(0,t.bk)((()=>void 0!==q(o,"Sequence Similarity Search")),"Sequence Similarity Search viewer has not been created",100),!i.initialized)throw new Error("The viewer is not initialized.");if(!i.targetColumn)throw new Error("The viewer has not molecule column (onTableAttached).");if(!i.beforeRender())throw new Error("The viewer is not able to render.");if(!i.computeRequested)throw new Error("The viewer has not compute requested even.");if(!c)throw new Error("The viewer has not compute completed.");const l=i;await(0,t.bk)((()=>0!==l.root.getElementsByClassName("d4-grid").length),"Sequence Similarity Search viewer grid has not been created",100);(0,t.E3)(l.fingerprint,"Morgan"),(0,t.E3)(l.distanceMetric,"Hamming"),(0,t.E3)(l.scores.get(0),e.FLOAT_NULL),(0,t.E3)(l.idxs.get(0),0),(0,t.E3)(l.molCol.get(0),"D-Tyr_Et/Tyr_ab-dehydroMe/dV/E/N/D-Orn/D-aThr//Phe_4Me"),(0,t.E3)(l.scores.get(1).toFixed(2),"0.10"),(0,t.E3)(l.idxs.get(1),7),(0,t.E3)(l.molCol.get(1),"/D-Tyr_Et/meQ/dV/E/N/dV///Phe_4Me"),o.dataFrame.currentRowIdx=1,await(0,t.bk)((()=>1===l.targetMoleculeIdx),"Target molecule has not been changed",5e3),await(0,t.bk)((()=>"meI/hHis/Aca/Cys_SEt/T/dK/Thr_PO3H2/Aca/Tyr_PO3H2/D-Chg/dV/Phe_ab-dehydro/N/D-Orn/D-aThr//Phe_4Me"===l.molCol.get(0)),"Incorrect first similar molecule",5e3)}()})),(0,t.t6)("diversitySearchViewer",(async()=>{await async function(){const n=await _e.files.readAsText("tests/sample_MSA_data.csv"),r=e.DataFrame.fromCsv(n),o=a.shell.addTableView(r);await a.data.detectSemanticTypes(r);const s=o.dataFrame.getCol("MSA");(0,t.E3)(s.semType,e.SEMTYPE.MACROMOLECULE);const i=await o.dataFrame.plot.fromType("Sequence Diversity Search");let c=!1;if(i.computeCompleted.subscribe((e=>{e&&(c=!0)})),o.dockManager.dock(i,e.DOCK_TYPE.DOWN,null,"Diversity"),await i.renderPromise,await(0,t.bk)((()=>void 0!==q(o,"Sequence Diversity Search")),"Sequence Diversity Search viewer has not been created",100),!i.initialized)throw new Error("The viewer is not initialized.");if(!i.targetColumn)throw new Error("The viewer has not molecule column (onTableAttached).");if(!i.beforeRender())throw new Error("The viewer is not able to render.");if(!i.computeRequested)throw new Error("The viewer has not compute requested even.");if(!c)throw new Error("The viewer has not compute completed.");const l=i;await(0,t.bk)((()=>0!==l.root.getElementsByClassName("d4-grid").length),"Sequence Diversity Search viewer grid has not been created",100),(0,t.E3)(l.fingerprint,"Morgan"),(0,t.E3)(l.distanceMetric,"Hamming"),(0,t.E3)(l.initialized,!0),(0,t.E3)(l.renderMolIds.length>0,!0)}()}))}));var z=n(1687),Z=n(4574);(0,t.L1)("bio-substructure-filters",(async()=>{let n,r,o;async function s(e,t){if(!t.columns.names().includes(e))throw new Error(`The column '${e}' not found. Available in data frame are ${JSON.stringify(t.columns.names())}`);const r=new z._i(n,_e.logger);return r.attach(t),r.applyState({columnName:e}),r.column=t.col(e),r.columnName=e,r}(0,t.gM)((async()=>{n=await(0,l.Q)(),r=await(0,E.pj)(),o=await(0,P.ub)(),await r.loadMonomerLibForTests()})),(0,t.Pl)((async()=>{await(0,P.Eu)(o),await r.loadMonomerLib(!0)})),(0,t.t6)("fasta",(async()=>{const e=await T("tests/filter_FASTA.csv");await a.data.detectSemanticTypes(e);const r=new z._i(n,_e.logger);r.attach(e),await r.awaitRendered();try{(0,t.E3)(!!r.bioFilter,!0),(0,t.E3)(r.bioFilter.type,"FastaBioFilter");const n=r.bioFilter;await(0,t.PE)(e.onRowsFiltered,(()=>{}),(()=>{n.props=new Z.n("MD",void 0,_e.logger)}),5e3,"testEvent onRowsFiltered"),(0,t.E3)(r.dataFrame.filter.trueCount,3),(0,t.E3)(r.dataFrame?.filter.toBinaryString(),"10010000100000")}finally{r.detach()}await r.awaitRendered()})),(0,t.t6)("separator",(async()=>{const e=await T("tests/filter_MSA.csv"),r=new z._i(n,_e.logger);await a.data.detectSemanticTypes(e),r.attach(e),await r.awaitRendered();try{(0,t.E3)(!!r.bioFilter,!0),(0,t.E3)(r.bioFilter.type,"SeparatorBioFilter");const n=r.bioFilter;await(0,t.PE)(e.onRowsFiltered,(()=>{}),(()=>{n.props=new z.AR("meI",void 0,_e.logger)}),5e3,"testEvent onRowsFiltered"),(0,t.E3)(r.dataFrame.filter.trueCount,7),(0,t.E3)(r.dataFrame.filter.get(2),!1),await(0,t.PE)(e.onRowsFiltered,(()=>{}),(()=>{n.props=new z.AR("/meI",void 0,_e.logger)}),5e3,"testEvent onRowsFiltered"),(0,t.E3)(r.dataFrame.filter.trueCount,0),await(0,t.PE)(e.onRowsFiltered,(()=>{}),(()=>{n.props=new z.AR("meI-hHis","-",_e.logger)}),5e3,"testEvent onRowsFiltered"),(0,t.E3)(r.dataFrame.filter.trueCount,7),(0,t.E3)(r.dataFrame.filter.get(2),!1)}finally{r.detach()}await r.awaitRendered()})),(0,t.t6)("helm-dialog",(async()=>{if(e.Func.find({package:"Helm",name:"getHelmHelper"}).length){const e="Bio tests: substructureFilters/helm-dialog",r=await T("tests/filter_HELM.csv"),o=a.shell.addTableView(r);await a.data.detectSemanticTypes(r),await r.meta.detectSemanticTypes(),_e.logger.debug(`${e}, filter attaching.`);const s=new z._i(n,_e.logger);s.attach(r);const i=$.dialog("Test filters").add(s.root).show();await s.awaitRendered();try{const n=s.bioFilter;(0,t.E3)(null!==s.bioFilter,!0,"bioFilter is not created"),_e.logger.debug(`${e}, filter 1 change awaiting...`),await(0,t.PE)(r.onRowsFiltered,(()=>{}),(()=>{n.props=new Z.n("PEPTIDE1{A.C}$$$$V2.0",void 0,_e.logger)}),2e4),_e.logger.debug(`${e}, filter 1 changed.`),(0,t.E3)(s.dataFrame.filter.trueCount,1),(0,t.E3)(s.dataFrame.filter.toBinaryString(),"0001"),_e.logger.debug(`${e}, filter 2 change awaiting...`),await(0,t.PE)(r.onRowsFiltered,(()=>{}),(()=>{n.props=new Z.n("PEPTIDE1{C}$$$$V2.0",void 0,_e.logger)}),2e4),setTimeout((()=>o.grid.invalidate()),500),await S(o.grid),await(0,t.cb)(1e3),_e.logger.debug(`${e}, filter 2 changed.`),(0,t.E3)(s.dataFrame.filter.trueCount,2),(0,t.E3)(s.dataFrame.filter.toBinaryString(),"1001")}finally{i.close()}await s.awaitRendered(),await(0,t.cb)(3e3)}}),{}),(0,t.t6)("helm-view",(async()=>{if(e.Func.find({package:"Helm",name:"getHelmHelper"}).length){const e=await T("tests/filter_HELM.csv");e.getCol("HELM string"),await a.data.detectSemanticTypes(e);const t=a.shell.addTableView(e);t.getFiltersGroup(),await S(t.grid)}})),(0,t.t6)("sync-fasta",(async()=>{const e=await _e.files.readCsv("tests/filter_FASTA.csv");await a.data.detectSemanticTypes(e);const n=await s("fasta",e),r=await s("fasta",e);await Promise.all([n.awaitRendered(),r.awaitRendered()]);try{(0,t.E3)(!!n.bioFilter,!0),(0,t.E3)(!!r.bioFilter,!0),(0,t.E3)(n.bioFilter.type,"FastaBioFilter"),(0,t.E3)(r.bioFilter.type,"FastaBioFilter");const o=n.bioFilter,s=r.bioFilter;await(0,t.PE)(e.onRowsFiltered,(()=>{}),(()=>{o.props=new Z.n("MD",void 0,_e.logger)}),1e4,"await onRowsFiltered"),(0,t.E3)(e.filter.trueCount,3),await n.awaitRendered(),(0,t.E3)(s.props.substructure,"MD")}finally{n.detach(),r.detach()}await Promise.all([n.awaitRendered(),r.awaitRendered()])})),(0,t.t6)("sync-msa",(async()=>{const e=await _e.files.readCsv("tests/filter_MSA.csv");await a.data.detectSemanticTypes(e);const n="hHis-Aca",r=await s("MSA",e),o=await s("MSA",e);await Promise.all([r.awaitRendered(),o.awaitRendered()]);try{(0,t.E3)(!!r.bioFilter,!0),(0,t.E3)(!!o.bioFilter,!0),(0,t.E3)(r.bioFilter.type,"SeparatorBioFilter"),(0,t.E3)(o.bioFilter.type,"SeparatorBioFilter");const s=r.bioFilter,i=o.bioFilter;await(0,t.PE)(e.onRowsFiltered,(()=>{}),(()=>{s.props=new z.AR(n,"-",_e.logger)}),1e4,"await onRowsFiltered"),(0,t.E3)(e.filter.trueCount,8),(0,t.E3)(i.props.substructure,n),(0,t.E3)(i.props.separator,"-")}finally{r.detach(),o.detach()}await Promise.all([r.awaitRendered(),o.awaitRendered()])})),(0,t.t6)("sync-helm",(async()=>{if(e.Func.find({package:"Helm",name:"getHelmHelper"}).length){const e=await _e.files.readCsv("tests/filter_HELM.csv");await a.data.detectSemanticTypes(e);const n=a.shell.addTableView(e),r="PEPTIDE1{A.C}$$$$V2.0",o=1,i=await s("HELM string",e),c=await s("HELM string",e),l=$.dialog("Test filters").add(i.root).add(c.root).show();await Promise.all([i.awaitRendered(),c.awaitRendered()]);try{(0,t.E3)(!!i.bioFilter,!0),(0,t.E3)(!!c.bioFilter,!0),(0,t.E3)(i.bioFilter.type,"HelmBioFilter"),(0,t.E3)(c.bioFilter.type,"HelmBioFilter");const s=i.bioFilter,a=c.bioFilter;await(0,t.PE)(e.onRowsFiltered,(()=>{}),(()=>{s.props=new Z.n(r,void 0,_e.logger)}),6e4,"await onRowsFiltered"),await S(n.grid),_e.logger.debug("Bio tests: substructureFilters/sync-helm, before changed event"),await(0,t.cb)(2*i.debounceTime),_e.logger.debug("Bio tests: substructureFilters/sync-helm, after changed event"),(0,t.E3)(e.filter.trueCount,o),await i.awaitRendered(),(0,t.E3)(a.props.substructure,r)}finally{i.detach(),c.detach(),l.close()}await Promise.all([i.awaitRendered(),c.awaitRendered()]),await S(n.grid),await(0,t.cb)(3e3)}})),(0,t.t6)("two-columns-fasta",(async()=>{const n=e.DataFrame.fromCsv("id,seq1,seq2,trueSeq1,trueSeq2\n0,CGGCTACGGC,ATTGCATTCG,0,1,\n1,CGGCTGCCGC,ATAGCATTCG,1,1,\n2,CGGCTGCGCC,AATGCATACG,1,0,\n3,CGGCTGCATT,TTTGCATTCG,1,1,\n4,CGGCTGCATT,AAAGCATACG,1,0,\n");await a.data.detectSemanticTypes(n);const r=a.shell.addTableView(n),o="seq1",s="CGGCTG",i=n.getCol("trueSeq1").toList(),c="seq2",l="GCATT",u=n.getCol("trueSeq2").toList(),d=[{type:"Bio:bioSubstructureFilter",columnName:o},{type:"Bio:bioSubstructureFilter",columnName:c}],h=await n.plot.fromType(e.VIEWER.FILTERS,{filters:d});r.dockManager.dock(h,e.DOCK_TYPE.LEFT),await(0,t.cb)(100),await S(r.grid);const p=h.filters[0],m=h.filters[1];(0,t.E3)(p.column.name,o),(0,t.E3)(m.column.name,c);const f=p.bioFilter,g=m.bioFilter;await(0,t.PE)(n.onRowsFiltered,(()=>{}),(()=>{f.props=new Z.n(s,void 0,_e.logger)}),1e3),await(0,t.PE)(n.onRowsFiltered,(()=>{}),(()=>{g.props=new Z.n("",void 0,_e.logger)}),1e3,"testEvent onRowsFiltered on seq1"),(0,t.E3)(n.filter.trueCount,i.filter((e=>1===e)).length),(0,t.E3)(n.filter.toBinaryString(),i.map((e=>e.toString())).join("")),await(0,t.PE)(n.onRowsFiltered,(()=>{}),(()=>{f.props=new Z.n("",void 0,_e.logger)}),1e3),await(0,t.PE)(n.onRowsFiltered,(()=>{}),(()=>{g.props=new Z.n(l,void 0,_e.logger)}),1e3,"testEvent onRowsFiltered on seq2"),(0,t.E3)(n.filter.trueCount,u.filter((e=>1===e)).length),(0,t.E3)(n.filter.toBinaryString(),u.map((e=>e.toString())).join("")),await(0,t.PE)(n.onRowsFiltered,(()=>{}),(()=>{f.props=new Z.n("",void 0,_e.logger)}),1e3),await(0,t.PE)(n.onRowsFiltered,(()=>{}),(()=>{g.props=new Z.n("",void 0,_e.logger)}),1e3,"testEvent onRowsFiltered on neither"),(0,t.E3)(n.filter.trueCount,n.rowCount),await(0,t.PE)(n.onRowsFiltered,(()=>{}),(()=>{f.props=new Z.n(s,void 0,_e.logger)}),5e3),await(0,t.PE)(n.onRowsFiltered,(()=>{}),(()=>{g.props=new Z.n(l,void 0,_e.logger)}),5e3,"testEvent onRowsFiltered on both");const y=v().count(0).take(n.rowCount).map((e=>i[e]*u[e])).toArray();(0,t.E3)(n.filter.trueCount,y.filter((e=>1===e)).length),(0,t.E3)(n.filter.toBinaryString(),y.map((e=>e.toString())).join("")),await Promise.all([p.awaitRendered(),m.awaitRendered(),S(r.grid)])}),{skipReason:"Inconsistent behavior of test"}),(0,t.t6)("reset-fasta",(async()=>{const n=await T("tests/filter_FASTA.csv"),r=a.shell.addTableView(n);await a.data.detectSemanticTypes(n),await n.meta.detectSemanticTypes();const o="MD",s=await n.plot.fromType(e.VIEWER.FILTERS,{filters:[{type:"Bio:bioSubstructureFilter",columnName:"fasta"}]});r.dockManager.dock(s,e.DOCK_TYPE.LEFT),await(0,t.cb)(100),await S(r.grid);const i=s.filters[0].bioFilter;await(0,t.PE)(n.onRowsFiltered,(()=>{}),(()=>{i.props=new Z.n(o,void 0,_e.logger)}),1e3,"testEvent onRowsFiltered"),(0,t.E3)(n.filter.trueCount,3),(0,t.E3)(i.props.substructure,o),(0,t.E3)(i.substructureInput.value,o),I()(s.root).find('i[name="icon-arrow-rotate-left"]')[0].click(),await(0,t.cb)(100),await S(r.grid),(0,t.E3)(i.props.substructure,""),(0,t.E3)(i.substructureInput.value,"")})),(0,t.t6)("reopen",(async()=>{const n=await _e.files.readCsv("tests/filter_FASTA.csv"),r=a.shell.addTableView(n);await a.data.detectSemanticTypes(n),await n.meta.detectSemanticTypes();const o=[{type:"Bio:bioSubstructureFilter",columnName:"fasta"}],s=await n.plot.fromType(e.VIEWER.FILTERS,{filters:o});r.dockManager.dock(s,e.DOCK_TYPE.LEFT),await(0,t.cb)(100),await S(r.grid),s.close(),await S(r.grid);const i=await n.plot.fromType(e.VIEWER.FILTERS,{filters:o});r.dockManager.dock(i,e.DOCK_TYPE.LEFT),await(0,t.cb)(100),await S(r.grid)}),{})}));var X=n(8152);class Q{errorList=[];warningList=[];infoList=[];debugList=[];error(e,t,n){this.errorList.push({message:e,params:t,stackTrace:n})}warning(e,t){this.warningList.push({message:e,params:t})}info(e,t){this.infoList.push({message:e,params:t})}debug(e,t){this.debugList.push({message:e,params:t})}}var J=n(9192);(0,t.L1)("PepSeA",(()=>{(0,t.t6)("Basic alignment",(async()=>{const n=e.DataFrame.fromCsv('HELM,MSA\n"PEPTIDE1{F.L.R.G.W.[MeF].Y.S.N.N.C}$$$$","F.L.R.G.W.MeF.Y..S.N.N.C"\n"PEPTIDE1{F.L.R.G.Y.[MeF].Y.W.N.C}$$$$","F.L.R.G.Y.MeF.Y.W...N.C"\n"PEPTIDE1{F.G.Y.[MeF].Y.W.S.D.N.C}$$$$","F...G.Y.MeF.Y.W.S.D.N.C"\n"PEPTIDE1{F.L.R.G.Y.[MeF].Y.W.S.N.D.C}$$$$","F.L.R.G.Y.MeF.Y.W.S.N.D.C"\n"PEPTIDE1{F.V.R.G.Y.[MeF].Y.W.S.N.C}$$$$","F.V.R.G.Y.MeF.Y.W.S..N.C"\n'),r=await(0,X.GD)(n,n.getCol("HELM"),"msa(HELM)"),o=n.getCol("MSA");for(let e=0;e<r.length;++e)(0,t.E3)(r.get(e)==o.get(e),!0)}),{timeout:6e4,stressTest:!0,skipReason:"Fails in docker"}),(0,t.t6)("stderr",(async()=>{const n=new Q,r=e.DataFrame.fromCsv('HELM,MSA\n"PEPTIDE1{F.L.Mis.G.W.[MeF].Y.S.N.N.C}$$$$","F.L.Mis.G.W.MeF.Y..S.N.N.C"\n"PEPTIDE1{F.L.Mis.G.Y.[MeF].Y.W.N.C}$$$$","F.L.Mis.G.Y.MeF.Y...W.N.C"\n"PEPTIDE1{F.G.Y.[MeF].Y.W.S.D.N.C}$$$$","F...G.Y.MeF.Y.W.S.D.N.C"\n'),o=await(0,X.GD)(r,r.getCol("HELM"),"msa(HELM)",void 0,void 0,void 0,void 0,n),s=r.getCol("MSA");(0,t.J6)(o.toList(),s.toList()),(0,t.E3)(n.warningList[0].message,"Mis not found in Monomer Map\nMeF not found in Monomer Map\n")}),{timeout:6e4,stressTest:!0,skipReason:"Fails in docker"}),(0,t.t6)("error",(async()=>{const n=new Q;try{const t=e.DataFrame.fromCsv('HELM\n"PEPTIDE1{[NH2].*.A.Q.T.T.Y.K.N.Y.R.R.N.L.L.*.[COOH]}$$$$"\n"PEPTIDE1{[NH2].M.A.N.T.T.Y.K.N.Y.R.N.N.L.L.*.[COOH]}$$$$"\n"PEPTIDE1{[NH2].*.A.N.T.T.Y.K.C.Y.R.R.N.L.L.*.[COOH]}$$$$"\n"PEPTIDE1{[NH2].*.A.N.T.T.Y.K.F.Y.R.R.N.L.L.*.[COOH]}$$$$"\n');await(0,X.GD)(t,t.getCol("HELM"),"msa(HELM)",void 0,void 0,void 0,void 0,n)}catch(e){const[t,r]=(0,J.AP)(e);n.error(t,void 0,r)}(0,t.E3)(n.errorList[0].message,"PepSeA error: The pair (*,M) couldn't be found in the substitution matrix")}),{skipReason:"Fails in docker"})})),(0,t.L1)("viewers",(()=>{const n=e.Func.find({package:"Bio",tags:["viewer"]}).map((e=>e.friendlyName));for(const e of n)(0,t.t6)(e,(async()=>{const n=await T("samples/FASTA_DNA.csv");await(0,t.Bl)(e,n,{detectSemanticTypes:!0})}),{skipReason:{"Sequence Similarity Search":"GROK-13162","Sequence Diversity Search":"GROK-13162",WebLogo:"GROK-13162",VdRegions:"GROK-13162"}[e]})}));const ee="seq\nACGTCACGTC\nCAGTGTCAGTGT\nTTCAACTTCAAC",te="seq\nAC-GT-CTAC-GT-CT\nCAC-T-GTCAC-T-GT\nACCGTACTACCGTACT",ne="seq\nabc-dfgg-abc1-cfr3-rty-wert-abc-dfgg-abc1-cfr3-rty-wert\nrut12-her2-rty-wert-abc-abc1-dfgg-rut12-her2-rty-wert-abc-abc1-dfgg\nrut12-rty-her2-abc-cfr3-wert-rut12-rut12-rty-her2-abc-cfr3-wert-rut12";var re,oe;(0,t.L1)("SeqHandler",(()=>{let n;async function r(t){const r=e.DataFrame.fromCsv(t);await a.data.detectSemanticTypes(r);const o=n.getSeqHandler(r.getCol("seq"));return[r,o]}(0,t.gM)((async()=>{n=await(0,l.Q)()})),(0,t.t6)("Seq-Fasta",(async()=>{const[e,n]=await r(ee);(0,t.E3)(n.notation,c.Hi.FASTA),(0,t.E3)(n.isMsa(),!1)})),(0,t.t6)("Seq-Fasta-MSA",(async()=>{const[e,n]=await r(te);(0,t.E3)(n.notation,c.Hi.FASTA),(0,t.E3)(n.isMsa(),!0)})),(0,t.t6)("Seq-Fasta-units",(async()=>{const[e,n]=await r(ee);(0,t.E3)(n.notation,c.Hi.FASTA),(0,t.E3)(n.isMsa(),!1)})),(0,t.t6)("Seq-Fasta-MSA-units",(async()=>{const[e,n]=await r(te);(0,t.E3)(n.notation,c.Hi.FASTA),(0,t.E3)(n.isMsa(),!0)})),(0,t.t6)("Seq-Helm",(async()=>{const[e,n]=await r("seq\nPEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et.Tyr_ab-dehydroMe.dV.E.N.D-Orn.D-aThr.Phe_4Me}$$$$\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2.D-Chg.dV.Phe_ab-dehydro.N.D-Orn.D-aThr.Phe_4Me}$$$$\nPEPTIDE1{Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2.D-Chg.dV.Thr_PO3H2.N.D-Orn.D-aThr.Phe_4Me}$$$$\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2.D-Chg.dV.Thr_PO3H2.N.D-Orn.D-aThr.Phe_4Me}$$$$");(0,t.E3)(n.notation,c.Hi.HELM),(0,t.E3)(n.isHelm(),!0)})),(0,t.t6)("Seq-UN",(async()=>{const[e,n]=await r(ne);(0,t.E3)(n.notation,c.Hi.SEPARATOR),(0,t.E3)(n.separator,"-"),(0,t.E3)(n.alphabet,c.YI.UN)})),(0,t.t6)("Seq-UN-auto",(async()=>{const[e,n]=await r(ne);(0,t.E3)(n.notation,c.Hi.SEPARATOR),(0,t.E3)(n.separator,"-"),(0,t.E3)(n.alphabet,c.YI.UN)})),(0,t.t6)("column-version",(async()=>{const r=e.DataFrame.fromCsv(ee);await a.data.detectSemanticTypes(r);const o=r.getCol("seq"),s=n.getSeqHandler(o),i=o.version,c=n.getSeqHandler(o),l=o.version;(0,t.E3)(i,l,"Unexpected column version changed"),(0,t.E3)(s,c,"Unexpected SeqHandler object changed"),r.rows.addNew(["TACCCCTTCAAC"]);const u=n.getSeqHandler(o),d=o.version;(0,t.E3)(l<d,!0,"Stalled column version on add row"),(0,t.E3)(c!==u,!0,"Stalled SeqHandler object on add row"),o.set(1,"CAGTGTCCCCGT");const h=n.getSeqHandler(o),p=o.version;(0,t.E3)(d<p,!0,"Stalled column version on change data"),(0,t.E3)(u!==h,!0,"Stalled SeqHandler object on change data"),o.setTag("testTag","testValue");const m=n.getSeqHandler(o),f=o.version;(0,t.E3)(p<f,!0,"Stalled column version on set tag"),(0,t.E3)(h!==m,!0,"Stalled SeqHandler object on set tag")}))})),(oe=re||(re={})).fasta="fasta",oe.fastaMsa="fastaMsa",oe.separator="separator",oe.separatorMsa="separatorMsa",oe.helm="helm",(0,t.L1)("SeqHandler: splitted",(()=>{let n;(0,t.gM)((async()=>{n=await(0,l.Q)()})),U.b9[c.Hi.FASTA],U.b9[c.Hi.HELM];const r=U.b9[c.Hi.SEPARATOR],o={[re.fasta]:{src:{csv:"seq\nACGTCACGTC\nCAGTGTCAGTGT\nTTCAACTTCAAC"},tgt:{notation:c.Hi.FASTA,splitted:[["A","C","G","T","C","A","C","G","T","C"],["C","A","G","T","G","T","C","A","G","T","G","T"],["T","T","C","A","A","C","T","T","C","A","A","C"]]}},[re.fastaMsa]:{src:{csv:"seq\nAC-GT-CTAC-GT-CT\nCAC-T-GTCAC-T-GT\nACCGTACTACCGTACT"},tgt:{notation:c.Hi.FASTA,splitted:[["A","C","-","G","T","-","C","T","A","C","-","G","T","-","C","T"],["C","A","C","-","T","-","G","T","C","A","C","-","T","-","G","T"],["A","C","C","G","T","A","C","T","A","C","C","G","T","A","C","T"]]}},[re.separator]:{src:{csv:"seq\nabc-dfgg-abc1-cfr3-rty-wert-abc-dfgg-abc1-cfr3-rty-wert\nrut12-her2-rty-wert-abc-abc1-dfgg-rut12-her2-rty-wert-abc\nrut12-rty-her2-abc-cfr3-wert-rut12-rut12-rty-her2-abc-cfr3"},tgt:{notation:c.Hi.SEPARATOR,separator:"-",splitted:[["abc","dfgg","abc1","cfr3","rty","wert","abc","dfgg","abc1","cfr3","rty","wert"],["rut12","her2","rty","wert","abc","abc1","dfgg","rut12","her2","rty","wert","abc"],["rut12","rty","her2","abc","cfr3","wert","rut12","rut12","rty","her2","abc","cfr3"]]}},[re.separatorMsa]:{src:{csv:'seq\nrut0-dfgg-abc1-cfr3-rty-wert-abc-dfgg-abc1-cfr3-rty-wert\nrut1-her2-rty--abc1-dfgg-rut12-her2-rty--abc1-dfgg\nrut2-rty-her2---wert-rut12-rty-her2---wert\n"rut3-rty-her2-""-""-""-""-wert-rut12-rty-her2-""-""-""-""-wert"\n"""-""-rut4-her2-wert-rut12-rty-her2-wert"\n"rut5-rty-her2-wert-rut12-rty-her2-wert-""-"""'},tgt:{notation:c.Hi.SEPARATOR,separator:"-",splitted:[["rut0","dfgg","abc1","cfr3","rty","wert","abc","dfgg","abc1","cfr3","rty","wert"],["rut1","her2","rty",r,"abc1","dfgg","rut12","her2","rty",r,"abc1","dfgg"],["rut2","rty","her2",r,r,"wert","rut12","rty","her2",r,r,"wert"],["rut3","rty","her2",r,r,"wert","rut12","rty","her2",r,r,"wert"],[r,"rut4","her2","wert","rut12","rty","her2","wert"],["rut5","rty","her2","wert","rut12","rty","her2","wert",r]]}},[re.helm]:{src:{csv:"seq\nPEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et.Thr_PO3H2.Aca.D-Tyr_Et}$$$$\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.dK.Thr_PO3H2.Aca}$$$$\nPEPTIDE1{Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.dK.Thr_PO3H2.Aca}$$$$\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.T.dK.Thr_PO3H2}$$$$,\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.T.dK}|PEPTIDE2{Thr_PO3H2}$$$$"},tgt:{notation:c.Hi.HELM,splitted:[["meI","hHis","Aca","N","T","dE","Thr_PO3H2","Aca","D-Tyr_Et","Thr_PO3H2","Aca","D-Tyr_Et"],["meI","hHis","Aca","Cys_SEt","T","dK","Thr_PO3H2","Aca","dK","Thr_PO3H2","Aca"],["Lys_Boc","hHis","Aca","Cys_SEt","T","dK","Thr_PO3H2","Aca","dK","Thr_PO3H2","Aca"],["meI","hHis","Aca","Cys_SEt","T","dK","Thr_PO3H2","T","dK","Thr_PO3H2"],["meI","hHis","Aca","Cys_SEt","T","dK","Thr_PO3H2","T","dK","Thr_PO3H2"]]}}};for(const[r,s]of Object.entries(o))(0,t.t6)(`${r}`,(async()=>{const r=e.DataFrame.fromCsv(s.src.csv).getCol("seq"),o=await a.functions.call("Bio:detectMacromolecule",{col:r});o&&(r.semType=o),(0,t.E3)(r.semType,e.SEMTYPE.MACROMOLECULE);const i=n.getSeqHandler(r);(0,t.E3)(i.notation,s.tgt.notation),(0,t.E3)(i.separator===s.tgt.separator,!0);const c=v().count(0).take(i.length).map((e=>{const t=i.getSplitted(e);return v().count(0).take(t.length).map((e=>t.getOriginal(e))).toArray()})).toArray();(0,t.J6)(c,s.tgt.splitted)}))})),(0,t.L1)("SeqHandler: getRegion",(()=>{let n;(0,t.gM)((async()=>{n=await(0,l.Q)()}));const r={fastaDna:{srcCsv:"seq\nATTCGT\nACTGCTC\nATTCCGTA",startIdx:2,endIdx:4,tgtCsv:"seq\nTCG\nTGC\nTCC",units:c.Hi.FASTA,alphabet:c.YI.DNA,positionNames:{tag:"a, b, c, d, e, f, g, h",start:"c",end:"e"}},separatorPt:{srcCsv:"seq\nM-D-Y-K-E-T-L\nM-I-E-V-F-L-F-G-I\nM-M-",startIdx:5,endIdx:null,tgtCsv:"seq\nT-L--\nL-F-G-I\n---",units:c.Hi.SEPARATOR,alphabet:c.YI.PT,positionNames:{tag:"1, 1A, 1B, 2, 3, 4, 4A, 4A, 4C",start:"4",end:null}},helm:{srcCsv:"seq\nPEPTIDE1{[meI].[hHis].[Aca].N.T.[dE].[Thr_PO3H2].[Aca].[D-Tyr_Et].[Tyr_ab-dehydroMe].[dV].E.N.[D-Orn]}$$$$\nPEPTIDE1{[meI].[hHis].[Aca].[Cys_SEt].T.[dK].[Thr_PO3H2].[Aca].[Tyr_PO3H2].[D-Chg].[dV].[Phe_ab-dehydro]}$$$$\nPEPTIDE1{[Lys_Boc].[hHis].[Aca].[Cys_SEt].T}$$$$",startIdx:3,endIdx:6,tgtCsv:"seq\nPEPTIDE1{N.T.[dE].[Thr_PO3H2]}$$$$\nPEPTIDE1{[Cys_SEt].T.[dK].[Thr_PO3H2]}$$$$\nPEPTIDE1{[Cys_SEt].T.*.*}$$$$",units:c.Hi.HELM,alphabet:c.YI.UN,positionNames:{tag:null,start:"4",end:"7"}}};for(const[o,s]of Object.entries(r))(0,t.t6)(`${o}-idx`,(async()=>{const r=e.DataFrame.fromCsv(s.srcCsv).getCol("seq"),o=await a.functions.call("Bio:detectMacromolecule",{col:r});o&&(r.semType=o);const i=n.getSeqHandler(r).getRegion(s.startIdx,s.endIdx,"regSeq"),l=e.DataFrame.fromCsv(s.tgtCsv).getCol("seq");(0,t.E3)(r.meta.units,s.units),(0,t.E3)(i.meta.units,s.units),(0,t.E3)(r.getTag(c.gp.alphabet),s.alphabet),(0,t.E3)(i.getTag(c.gp.alphabet),s.alphabet),(0,t.J6)(i.toList(),l.toList())})),s.positionNames&&(0,t.t6)(`${o}-positionNames`,(async()=>{const n=e.DataFrame.fromCsv(s.srcCsv).getCol("seq");s.positionNames.tag&&n.setTag(c.gp.positionNames,s.positionNames.tag);const r=await a.functions.call("Bio:detectMacromolecule",{col:n});r&&(n.semType=r);const o=await a.functions.call("Bio:getRegion",{sequence:n,start:s.positionNames.start,end:s.positionNames.end}),i=e.DataFrame.fromCsv(s.tgtCsv).getCol("seq");(0,t.E3)(n.meta.units,s.units),(0,t.E3)(o.meta.units,s.units),(0,t.E3)(n.getTag(c.gp.alphabet),s.alphabet),(0,t.E3)(o.getTag(c.gp.alphabet),s.alphabet),(0,t.J6)(o.toList(),i.toList())}))})),(0,t.L1)("SeqHandler: getHelm",(()=>{let n,r,o;(0,t.gM)((async()=>{n=await(0,l.Q)(),r=await(0,E.pj)(),o=await(0,P.ub)(),await r.loadMonomerLibForTests()})),(0,t.Pl)((async()=>{await(0,P.Eu)(o),await r.loadMonomerLib(!0)}));const s={fasta:{src:{seq:"MDYKETMDYKET",notation:c.Hi.FASTA},tgt:{helm:"PEPTIDE1{M.D.Y.K.E.T.M.D.Y.K.E.T}$$$$"}},separator:{src:{seq:"M-D-Y-K-E-T-M-D-Y-K-E-T",notation:c.Hi.SEPARATOR,separator:"-"},tgt:{helm:"PEPTIDE1{M.D.Y.K.E.T.M.D.Y.K.E.T}$$$$"}},helm:{src:{seq:"PEPTIDE1{M.D.Y.K.E.T}$$$$",notation:c.Hi.HELM},tgt:{helm:"PEPTIDE1{M.D.Y.K.E.T}$$$$"}},"helm-cyclic":{src:{seq:"PEPTIDE1{M.D.Y.K.E.T}$PEPTIDE1,PEPTIDE1,6:R2-1:R1$$$V2.0",notation:c.Hi.HELM},tgt:{helm:"PEPTIDE1{M.D.Y.K.E.T}$PEPTIDE1,PEPTIDE1,6:R2-1:R1$$$V2.0"}}};for(const[e,n]of Object.entries(s))(0,t.t6)(e,(async()=>{await i(n.src.seq,n.src.notation,n.src.separator,n.tgt.helm)}));async function i(r,o,s,i){const c=e.Column.fromStrings("seq",[r]),l=e.DataFrame.fromColumns([c]);await a.data.detectSemanticTypes(l);const u=n.getSeqHandler(c),d=(await u.getValue(0)).helm;(0,t.E3)(d,i)}}));var se=n(6956);class ie{constructor(e){const t=e.split(se.xe).filter((e=>e));t.forEach((e=>this.validateConnectionItem(e))),this.connectionItems=t}connectionItems;validateConnectionItem(e){const t="(PEPTIDE|RNA)",n=new RegExp(`${t}[0-9]+,${t}[0-9]+,[0-9]+:R[0-9]+-[0-9]+:R[0-9]+`,"g");if(!e.match(n))throw new Error(`Cannot parse connection item from ${e}`)}getConnectionData(){const e=[];return this.connectionItems.forEach((t=>{const n=[],r=t.split(",");r[2].split("-").forEach(((e,t)=>{const o=r[t],s=e.split(":"),i={monomerIdx:parseInt(s[0])-1,rGroupId:parseInt(s[1].slice(1))};n.push({polymerId:o,bond:i})})),e.push(n)})),e}}var ae=n(8438);class ce{simplePolymer;isNucleotideSequence=!1;constructor(e){this.simplePolymer=e,this.polymerType=this.getPolymerType(),this.isNucleotideSequence="RNA"===this.polymerType,this.idx=this.getIdx();const{monomers:t,monomerTypes:n}=this.getMonomerSymbolsAndTypes();this.monomers=t,this.monomerTypes=n}polymerType;monomers;idx;monomerTypes;get id(){return this.polymerType+this.idx.toString()}getPolymerType(){const e=new RegExp("(PEPTIDE|RNA)[0-9]+{"),t=this.simplePolymer.match(e);if(!t)throw new Error(`Unsupported polymer type in ${this.simplePolymer}`);return t[1]}getIdx(){const e=new RegExp(`${this.polymerType}([0-9]+){`),t=this.simplePolymer.match(e);if(!t)throw new Error(`Cannot parse simple polymer id from ${this.simplePolymer}`);return parseInt(t[1])}getMonomerSymbolsAndTypes(){const e=new RegExp(`${this.polymerType}${this.idx}{|}`,"g"),t=this.simplePolymer.replace(e,"").split("."),n=[],r=[];return t.forEach((e=>{if(this.isNucleotideSequence){const t=e.split(/\(|\)/).filter((e=>!!e)).map((e=>(0,ae.D)(e)));n.push(...t),t.forEach(((e,t)=>r.push(t%3==1?"Branch":"Backbone")))}else n.push((0,ae.D)(e)),r.push("Backbone")})),{monomers:n,monomerTypes:r}}getBondData(){const e=[],t=this.monomerTypes.map(((e,t)=>{if("Backbone"===e)return t})).filter((e=>void 0!==e)),n=this.monomerTypes.map(((e,t)=>{if("Branch"===e)return t})).filter((e=>void 0!==e));for(let n=0;n<t.length-1;n++){const r=t[n],o=t[n+1];e.push([{monomerIdx:r,rGroupId:2},{monomerIdx:o,rGroupId:1}])}for(let t=0;t<n.length;t++){const r=n[t],o=r-1;e.push([{monomerIdx:o,rGroupId:3},{monomerIdx:r,rGroupId:1}])}return e}}class le{helmString;constructor(e){this.helmString=e;const t=this.helmString.split(se.pk),n=t[0].split(se.xe);this.simplePolymers=n.map((e=>new ce(e))),this.connectionList=new ie(t[1]),this.bondData=this.getBondData(),this.bondedRGroupsMap=this.getBondedRGroupsMap()}bondData;simplePolymers;connectionList;bondedRGroupsMap;getBondedRGroupsMap(){const e=this.simplePolymers.map((e=>e.monomers.length)).reduce(((e,t)=>e+t),0),t=Array.from({length:e},(()=>[]));return this.bondData.forEach((e=>{e.forEach((e=>{const n=e.monomerIdx,r=e.rGroupId;t[n].push(r)}))})),t}toString(){return this.helmString}getPolymerTypeByMonomerIdx(e){return this.getSimplePolymerByMonomerIdx(e).polymerType}getSimplePolymerByMonomerIdx(e){const t=this.getMonomerIdxShifts(),n=Object.values(t).sort(((e,t)=>e-t)).find((t=>e>=t));if(void 0===n)throw new Error(`Cannot find simple polymer for monomer ${e}`);const r=Object.keys(t).find((e=>t[e]===n));return this.simplePolymers.find((e=>e.id===r))}shiftBondMonomerIds(e,t){t.forEach((t=>{t.forEach((t=>{t.monomerIdx+=e}))}))}getMonomerIdxShifts(){const e={};let t=0;return this.simplePolymers.forEach((n=>{e[n.id]=t,t+=n.monomers.length})),e}getBondData(){const e=this.getMonomerIdxShifts(),t=[];return this.simplePolymers.forEach((n=>{const r=n.getBondData(),o=e[n.id];this.shiftBondMonomerIds(o,r),t.push(...r)})),this.connectionList.getConnectionData().forEach((n=>{const r=[];n.forEach((t=>{const n=e[t.polymerId],o=t.bond;o.monomerIdx+=n,r.push(o)})),t.push(r)})),t}}(0,t.L1)("helm",(()=>{const e={"single-linear":{src:{helm:"PEPTIDE1{R.F.Y.[GGaz].T.[meI]}$$$$"},tgt:{simplePolymers:[6],connections:[],bondedRGroups:[1,2,2,2,2,1]}},"single-cyclized-C-2-2":{src:{helm:"PEPTIDE1{R.F.C.Y.G.H.[GGaz].C.T.[meI]}$PEPTIDE1,PEPTIDE1,3:R3-8:R3$$$"},tgt:{simplePolymers:[10],connections:[[["PEPTIDE1",3,"R3"],["PEPTIDE1",8,"R3"]]],bondedRGroups:[1,2,3,2,2,2,2,3,2,1]}},"single-cyclized-C-1-1":{src:{helm:"PEPTIDE1{F.C.Y.G.H.[GGaz].C.[meI]}$PEPTIDE1,PEPTIDE1,2:R3-7:R3$$$"},tgt:{simplePolymers:[8],connections:[[["PEPTIDE1",2,"R3"],["PEPTIDE1",7,"R3"]]],bondedRGroups:[1,3,2,2,2,1,3,1]}},"single-cyclized-C-0-0":{src:{helm:"PEPTIDE1{C.Y.G.H.[GGaz].C}$PEPTIDE1,PEPTIDE1,1:R3-6:R3$$$"},tgt:{simplePolymers:[6],connections:[[["PEPTIDE1",1,"R3"],["PEPTIDE1",6,"R3"]]],bondedRGroups:[2,2,2,2,2,2]}},"two-separated-5-1":{src:{helm:"PEPTIDE1{R.F.Y.[GGaz].T}|PEPTIDE2{[meI]}$$$$"},tgt:{simplePolymers:[5,1],connections:[],bondedRGroups:[1,2,2,2,1,0]}},"two-separated-1-5":{src:{helm:"PEPTIDE1{[meI]}|PEPTIDE2{R.F.Y.[GGaz].T}$$$$"},tgt:{simplePolymers:[1,5],connections:[],bondedRGroups:[0,1,2,2,2,1]}},"two-separated-4-2":{src:{helm:"PEPTIDE1{R.F.Y.[GGaz]}|PEPTIDE2{T.[meI]}$$$$"},tgt:{simplePolymers:[4,2],connections:[],bondedRGroups:[1,2,2,1,1,1]}},"two-connected-1":{src:{helm:"PEPTIDE1{R.F.Y.[GGaz].T}|PEPTIDE2{[meI]}$PEPTIDE1,PEPTIDE2,5:R2-1:R1$$$"},tgt:{simplePolymers:[5,1],connections:[[["PEPTIDE1",5,"R2"],["PEPTIDE2",1,"R1"]]],bondedRGroups:[1,2,2,2,2,1]}},"two-connected-2":{src:{helm:"PEPTIDE1{R.F.Y.[GGaz]}|PEPTIDE2{T.[meI]}$PEPTIDE1,PEPTIDE2,4:R2-1:R1$$$"},tgt:{simplePolymers:[4,2],connections:[[["PEPTIDE1",4,"R2"],["PEPTIDE2",1,"R1"]]],bondedRGroups:[1,2,2,2,2,1]}},"two-cyclized-1-9":{src:{helm:"PEPTIDE1{[meI]}|PEPTIDE2{R.F.[GGaz].T.G.H.F.Y.P}$PEPTIDE2,PEPTIDE2,3:R3-9:R2|PEPTIDE2,PEPTIDE1,3:R4-1:R1$$$V2.0"},tgt:{simplePolymers:[1,9],connections:[[["PEPTIDE2",3,"R3"],["PEPTIDE2",9,"R2"]],[["PEPTIDE2",3,"R4"],["PEPTIDE1",1,"R1"]]],bondedRGroups:[1,1,2,4,2,2,2,2,2,1]}}};for(const[n,{src:r,tgt:o}]of Object.entries(e))(0,t.t6)(n,(async()=>{const e=new le(r.helm),n=e.simplePolymers.map((e=>e.monomers.length)),s=n.reduce(((e,t)=>e+t),0);(0,t.J6)(n,o.simplePolymers);const i=e.connectionList.getConnectionData().map((e=>[[e[0].polymerId,e[0].bond.monomerIdx+1,`R${e[0].bond.rGroupId}`],[e[1].polymerId,e[1].bond.monomerIdx+1,`R${e[1].bond.rGroupId}`]]));(0,t.J6)(i,o.connections);const a=v().count(0).take(e.bondedRGroupsMap.length).map((t=>e.bondedRGroupsMap[t].length)).toArray();(0,t.E3)(s,a.length)}))}));var ue=n(6077),de=n(6717);const he=new e.FileSource("System:AppData/Bio"),pe={"peptides-fasta":{inPath:"tests/to-atomic-level-peptides-fasta-input.csv",outPath:"tests/to-atomic-level-peptides-fasta-output.csv"},"dna-fasta":{inPath:"tests/to-atomic-level-dna-fasta-input.csv",outPath:"tests/to-atomic-level-dna-fasta-output.csv"},"msa-separator":{inPath:"tests/to-atomic-level-msa-separator-input.csv",outPath:"tests/to-atomic-level-msa-separator-output.csv"},"msa-fasta":{inPath:"tests/to-atomic-level-msa-fasta-input.csv",outPath:"tests/to-atomic-level-msa-fasta-output.csv"}},me="molfile(sequence)";function fe(e){return e.replaceAll("\r\n","\n").replace(/\n$/,"").split("\n").map((e=>e.trimEnd())).join("\n")}(0,t.L1)("toAtomicLevel",(async()=>{const n={},r={};let o,s,i,u,d,h;async function p(e,n){const r=e.getCol("sequence");await a.functions.call("Bio:toAtomicLevel",{table:e,seqCol:r,nonlinear:!1});const o=e.getCol(me),s=n.getCol(me),i=v()(o.values()).map((e=>fe(e))).toArray(),c=v()(s.values()).map((e=>fe(e))).toArray();(0,t.J6)(i,c)}(0,t.gM)((async()=>{d=await(0,de.j)(),i=await(0,l.Q)(),o=await(0,E.pj)(),s=await(0,P.ub)(),await o.loadMonomerLibForTests(),u=o.getMonomerLib();for(const[t,o]of Object.entries(pe))o.inPath,n[t]=e.DataFrame.fromCsv((await he.readAsText(o.inPath)).replace(/\n$/,"")),await a.data.detectSemanticTypes(n[t]),r[t]=e.DataFrame.fromCsv((await he.readAsText(o.outPath)).replace(/\n$/,""))})),(0,t.Pl)((async()=>{await(0,P.Eu)(s),await o.loadMonomerLib(!0)}));for(const[e,o]of Object.entries(pe))(0,t.t6)(`${e}`,(async()=>{await p(n[e],r[e])}));!function(e){e.fastaDna="fastaDna",e.fastaRna="fastaRna",e.fastaPt="fastaPt",e.fastaUn="fastaUn",e.separatorDna="separatorDna",e.separatorRna="separatorRna",e.separatorPt="separatorPt",e.separatorUn="separatorUn",e.helm="helm"}(h||(h={}));const m={[h.fastaDna]:"seq\nACGTCACGTC\nCAGTGTCAGTGT\nTTCAACTTCAAC",[h.fastaRna]:"seq\nACGUCACGUC\nCAGUGUCAGUGU\nUUCAACUUCAAC",[h.fastaPt]:"seq\nFWPHEYFWPHEY\nYNRQWYVYNRQWYV\nMKPSEYVMKPSEYV",[h.fastaUn]:"seq\n[meI][hHis][Aca]NT[dE][Thr_PO3H2][Aca]D[meI][hHis][Aca]NT[dE][Thr_PO3H2][Aca]D\n[meI][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2][meI][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2]\n[Lys_Boc][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2][Lys_Boc][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2]",[h.separatorDna]:"seq\nA/C/G/T/C/A/C/G/T/C\nC/A/G/T/G/T/C/A/G/T/G/T\nT/T/C/A/A/C/T/T/C/A/A/C",[h.separatorRna]:"seq\nA*C*G*U*C*A*C*G*U*C\nC*A*G*U*G*U*C*A*G*U*G*U\nU*U*C*A*A*C*U*U*C*A*A*C",[h.separatorPt]:"seq\nF-W-P-H-E-Y-F-W-P-H-E-Y\nY-N-R-Q-W-Y-V-Y-N-R-Q-W-Y-V\nM-K-P-S-E-Y-V-M-K-P-S-E-Y-V",[h.separatorUn]:"seq\nmeI-hHis-Aca-N-T-dE-Thr_PO3H2-Aca-D-meI-hHis-Aca-N-T-dE-Thr_PO3H2-Aca-D\nmeI-hHis-Aca-Cys_SEt-T-dK-Thr_PO3H2-Aca-Tyr_PO3H2-meI-hHis-Aca-Cys_SEt-T-dK-Thr_PO3H2-Aca-Tyr_PO3H2\nLys_Boc-hHis-Aca-Cys_SEt-T-dK-Thr_PO3H2-Aca-Tyr_PO3H2-Lys_Boc-hHis-Aca-Cys_SEt-T-dK-Thr_PO3H2-Aca-Tyr_PO3H2",[h.helm]:"seq\nPEPTIDE1{meI.D-gGlu.Aca.N.T.dE.Thr_PO3H2.Aca.D.Thr_PO3H2.Aca.D}$$$\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2.Thr_PO3H2.Aca.Tyr_PO3H2}$$$\nPEPTIDE1{Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2.Thr_PO3H2.Aca.Tyr_PO3H2}$$$"};async function f(t){const n=m[t],r=e.DataFrame.fromCsv(n.replace(/\n$/,""));return await a.data.detectSemanticTypes(r),r}async function g(e,t="seq",n){const r=e.getCol(t),o=await(0,ue.C4)(e,r,u,i,d);return o.warnings.length>0&&_e.logger.warning(`_toAtomicLevel() warnings ${o.warnings.join("\n")}`),o.molCol}(0,t.t6)("fastaDna",(async()=>{await g(await f(h.fastaDna),"seq")})),(0,t.t6)("fastaRna",(async()=>{await g(await f(h.fastaRna),"seq")})),(0,t.t6)("fastaPt",(async()=>{await g(await f(h.fastaPt),"seq")})),(0,t.t6)("fastaUn",(async()=>{await g(await f(h.fastaUn),"seq")})),(0,t.t6)("separatorDna",(async()=>{await g(await f(h.separatorDna),"seq")})),(0,t.t6)("separatorDna",(async()=>{await g(await f(h.separatorRna),"seq")})),(0,t.t6)("separatorPt",(async()=>{await g(await f(h.separatorPt),"seq")})),(0,t.t6)("separatorUn",(async()=>{await g(await f(h.separatorUn),"seq")})),(0,t.t6)("helm",(async()=>{await g(await f(h.helm),"seq")})),(0,t.t6)("ptFasta2",(async()=>{const n=await _e.files.readAsText("tests/to-atomic-level-pt-fasta-2.mol"),r=e.DataFrame.fromCsv("seq\nAR"),o=r.getCol("seq");o.semType=e.SEMTYPE.MACROMOLECULE,o.meta.units=c.Hi.FASTA,o.setTag(c.gp.alphabet,c.YI.PT),i.getSeqHandler(o);const s=await g(r,"seq");(0,t.E3)(fe(s.get(0)),fe(n))}))}));var ge=n(8754);(0,t.L1)("toAtomicLevel-ui",(()=>{let n,r,o,s,i;(0,t.gM)((async()=>{o=await(0,l.Q)(),i=await(0,de.j)(),n=await(0,E.pj)(),r=await(0,P.ub)(),await n.loadMonomerLibForTests(),s=n.getMonomerLib()})),(0,t.Pl)((async()=>{await(0,P.Eu)(r),await n.loadMonomerLib(!0)}));const u={fasta:{src:{seq:"MDYKETLLMPK",units:c.Hi.FASTA},tgt:{atomCount:94,bondCount:95}},"fasta-with-gap":{src:{seq:"MD-YKETLLMPK",units:c.Hi.FASTA},tgt:{atomCount:94,bondCount:95}},helm:{src:{seq:"PEPTIDE1{meI.hHis.Aca.N.T.dK.Thr_PO3H2}$$$$",units:c.Hi.HELM},tgt:{atomCount:68,bondCount:68}},"helm-with-gap":{src:{seq:"PEPTIDE1{meI.hHis.*.Aca.N.T.dK.Thr_PO3H2}$$$$",units:c.Hi.HELM},tgt:{atomCount:68,bondCount:68}}},d=async t=>{const n=t.src.seq,r=e.DataFrame.fromColumns([e.Column.fromList(e.COLUMN_TYPE.STRING,"seq",[n])]);return await a.data.detectSemanticTypes(r),r.getCol("seq")};for(const[e,n]of Object.entries(u))(0,t.t6)(`${e}-linear`,(async()=>{const e=await d(n);await h(e,!1,n.tgt)}));if(e.Func.find({package:"Helm",name:"getHelmHelper"}).length)for(const[e,n]of Object.entries(u))(0,t.t6)(`${e}-nonlinear`,(async()=>{const e=await d(n);await h(e,!0,n.tgt)}));async function h(n,r,a){const c=await(0,ge.V)(n.dataFrame,n,r,!1,s,o,i);(0,t.E3)(c.molCol.semType,e.SEMTYPE.MOLECULE);const l=c.molCol.get(0),u=i.get_mol(l);(0,t.E3)(null!=u,!0,"No molecule generated");try{const e=u.get_num_atoms(),n=u.get_num_bonds();(0,t.E3)(e,a.atomCount),(0,t.E3)(n,a.bondCount)}finally{u.delete()}}}));var ye=n(6863);async function be(t,n){const r=e.DataFrame.fromCsv(t),o=r.col("seq"),s=await a.functions.call("Bio:detectMacromolecule",{col:o});return s&&(o.semType=s),await a.data.detectSemanticTypes(r),n.getSeqHandler(o)}function we(e,n,r,o){const s=r(e,n);(0,t.E3)(Number(s.toFixed(3)),Number(o.toFixed(3)))}(0,t.L1)("Distance",(async()=>{let n;(0,t.gM)((async()=>{n=await(0,l.Q)()}));const r=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],o={F:0,W:1,R:2,Y:3},s="FWRWY",i="FWRWW",a="FWY",c="FWRWY",u="FWY",d="FWRRRRY";(0,t.t6)("protein-distance-function",(async()=>{const e=(await be("seq\nFWRWYVKHPFWRWYVKHP\nYNRWYVKHPYNRWYVKHP\nMWRSWYCKHPMWRSWYCKHP",n)).getDistanceFunctionName();(0,t.E3)(e,ye.Z.LEVENSHTEIN)})),(0,t.t6)("DNA-distance-function",(async()=>{const e=(await be("seq\nATAACGATAACG\nATCGAATCGA\nATCGAATCGA",n)).getDistanceFunctionName();(0,t.E3)(e,ye.Z.LEVENSHTEIN)})),(0,t.t6)("MSA-distance-function",(async()=>{const e=(await be("seq\nATAACATAAC\nATCGAATCGA\nATCGAATCGA",n)).getDistanceFunctionName();(0,t.E3)(e,ye.Z.HAMMING)})),(0,t.t6)("levenstein-sub",(async()=>{const e=ye.V[ye.Z.LEVENSHTEIN]();we(s,i,e,.2)})),(0,t.t6)("levenstein-del",(async()=>{const e=ye.V[ye.Z.LEVENSHTEIN]();we(a,c,e,.4)})),(0,t.t6)("hamming",(async()=>{const e=ye.V[ye.Z.HAMMING]();we(a,c,e,.6)})),(0,t.t6)("needleman-blosum62",(async()=>{const e=ye.V[ye.Z.NEEDLEMANN_WUNSCH]({gapOpen:8,gapExtend:2});we(s,i,e,-6)})),(0,t.t6)("needleman-blosum62-del",(async()=>{const e=ye.V[ye.Z.NEEDLEMANN_WUNSCH]({gapOpen:8,gapExtend:2});we(a,c,e,-3.667)})),(0,t.t6)("needleman-custom-sub",(async()=>{const e=ye.V[ye.Z.NEEDLEMANN_WUNSCH]({scoringMatrix:r,alphabetIndexes:o,gapOpen:1,gapExtend:1});we(s,i,e,.2)})),(0,t.t6)("needleman-custom-del",(async()=>{const e=ye.V[ye.Z.NEEDLEMANN_WUNSCH]({scoringMatrix:r,alphabetIndexes:o,gapOpen:1,gapExtend:1});we(a,c,e,.667)})),(0,t.t6)("needleman-custom-zero-extend",(async()=>{const e=ye.V[ye.Z.NEEDLEMANN_WUNSCH]({scoringMatrix:r,alphabetIndexes:o,gapOpen:1,gapExtend:0});we(u,d,e,.333)})),(0,t.t6)("needleman-custom-half-extend",(async()=>{const e=ye.V[ye.Z.NEEDLEMANN_WUNSCH]({scoringMatrix:r,alphabetIndexes:o,gapOpen:2,gapExtend:1});we(u,d,e,1.667)})),(0,t.t6)("needleman-custom-same-extend",(async()=>{const t=ye.V[ye.Z.NEEDLEMANN_WUNSCH]({scoringMatrix:r,alphabetIndexes:o,gapOpen:1,gapExtend:1});e.Test.isInBenchmark?we(Array(1e3).fill(u).join(""),Array(1e3).fill(d).join(""),t,1.333):we(u,d,t,1.333)}),{benchmark:!0})}));var ve=n(684);async function Ae(n,r,o,s,i,c,l,u){await a.data.detectSemanticTypes(n),await a.functions.call("Bio:activityCliffs",{table:n,molecules:n.getCol(o),activities:n.getCol(s),similarity:i,methodName:r,similarityMetric:l,preprocessingFunction:u,options:{[`${ve.vb}`]:!0},demo:!1});const d=Array.from(a.shell.tv.viewers)[1];(0,t.E3)(d?.type===e.VIEWER.SCATTER_PLOT,!0),await(0,t.bk)((()=>{const e=Array.from(d.root.getElementsByClassName("scatter_plot_link"));return!e.length||e[0].innerText.toLowerCase()===`${c} cliffs`}),"incorrect cliffs link",3e3)}var Ee=n(2780),Ce=n(9039),Te=n(9124);async function Se(n,r,o){const s=n.getCol(o);n.name="seqSpaceDf";const i=await a.functions.call("Bio:detectMacromolecule",{col:s});i&&(s.semType=i);const c=e.Func.find({package:"Bio",name:"macromoleculePreprocessingFunction"})[0];if(!c)throw new Error("Preprocessing function not found");await a.functions.call("Bio:sequenceSpaceTopMenu",{table:n,molecules:n.col(o),methodName:r,similarityMetric:ye.Z.LEVENSHTEIN,plotEmbeddings:!0,preprocessingFunction:c,options:{[ve.vb]:!0}});const l=a.shell.tableView(n.name),u=Array.from(l?.viewers??[])[1];(0,t.E3)(null!=u)}(0,t.L1)("activityCliffs",(async()=>{let n,r,o;const s=e.Func.find({name:"macromoleculePreprocessingFunction",package:"Bio"})[0],i=e.Func.find({name:"helmPreprocessingFunction",package:"Bio"})[0];(0,t.gM)((async()=>{e.Func.find({package:"Helm",name:"getHelmHelper"}).length&&(n=await(0,Te.b2)()),r=await(0,E.pj)(),o=await(0,P.ub)(),await r.loadMonomerLibForTests()})),(0,t.Pl)((async()=>{await(0,P.Eu)(o),await r.loadMonomerLib(!0)})),(0,t.t6)("activityCliffsOpens",(async()=>{const t=e.Test.isInBenchmark?{fileName:"tests/peptides_with_random_motif_1600.csv",tgt:{cliffCount:64}}:{fileName:"tests/100_3_clustests.csv",tgt:{cliffCount:3}},n=await T(t.fileName);a.shell.addTableView(n),await Ae(n,Ce.c.UMAP,"sequence","Activity",90,t.tgt.cliffCount,ye.Z.LEVENSHTEIN,s)}),{benchmark:!0,skipReason:"Fails"}),(0,t.t6)("activityCliffsWithEmptyRows",(async()=>{const e=await T("tests/100_3_clustests_empty_vals.csv");a.shell.addTableView(e),await Ae(e,Ce.c.UMAP,"sequence","Activity",90,3,ye.Z.LEVENSHTEIN,s)})),(0,t.t6)("Helm",(async()=>{if(e.Func.find({package:"Helm",name:"getHelmHelper"}).length){const e=await _e.files.readCsv("samples/HELM_50.csv");a.shell.addTableView(e),await Ae(e,Ce.c.UMAP,"HELM","Activity",65,20,Ee.aT.Tanimoto,i)}}))})),(0,t.L1)("sequenceSpace",(async()=>{let n,r,o,s;(0,t.t6)("sequenceSpaceOpens",(async()=>{const t=e.Test.isInBenchmark?{fileName:"tests/peptides_with_random_motif_1600.csv"}:{fileName:"tests/100_3_clustests.csv"};n=await T(t.fileName),r=a.shell.addTableView(n),await Se(n,Ce.c.UMAP,"sequence")}),{benchmark:!0}),(0,t.t6)("sequenceSpaceWithEmptyRows",(async()=>{o=await T("tests/100_3_clustests_empty_vals.csv"),s=a.shell.addTableView(o),await Se(o,Ce.c.UMAP,"sequence")}))})),(0,t.L1)("Scoring",(()=>{const n="sequence",r="expected_similarity",o="expected_identity",s=e.DataFrame.fromCsv(`${n},${r},${o}\nPEPTIDE1{Aca.Orn.gGlu.Pqa.D-His_1Bn.dH.hHis.4Abz.D-Tic.D-Dap.Y.Iva.meS.F.P.F.D-1Nal}$$$$,1.0,1.0\nPEPTIDE1{Iva.Gly_allyl.gGlu.Pqa.D-Dip.dH.hHis.4Abz.D-aHyp.D-Dap.Y.Iva.I.Tyr_26diMe.P.Asu.meC}$$$$,0.691,0.53\nPEPTIDE1{[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal]}$$$$V2.0,0.37,0.0`),i=s.getCol(n);i.meta.units=c.Hi.HELM,i.semType=e.SEMTYPE.MACROMOLECULE;const l=i.get(0);let u,d;(0,t.gM)((async()=>{u=await(0,E.pj)(),d=await(0,P.ub)(),await u.loadMonomerLibForTests()})),(0,t.Pl)((async()=>{await(0,P.Eu)(d),await u.loadMonomerLib(!0)})),(0,t.t6)("Identity",(async()=>{const e=await a.functions.call("Bio:sequenceIdentityScoring",{table:s,macromolecule:i,reference:l});for(let n=0;n<e.length;n++){const r=e.get(n),i=s.get(o,n);(0,t.Wj)(r,i,.01,`Wrong identity score for sequence at position ${n}`)}})),(0,t.t6)("Identity-shortReference",(async()=>{const e=await a.functions.call("Bio:sequenceIdentityScoring",{table:s,macromolecule:i,reference:"PEPTIDE1{Iva.Gly_allyl.gGlu.Pqa.D-Dip.dH.hHis.4Abz.D-aHyp.D-Dap.Y.Iva}$$$$"});(0,t.E3)(v().count(0).take(e.length).map((t=>e.get(t))).every((e=>null!=e&&!isNaN(e))),!0)})),(0,t.t6)("Identity-longReference",(async()=>{const e=await a.functions.call("Bio:sequenceIdentityScoring",{table:s,macromolecule:i,reference:"PEPTIDE1{Iva.Gly_allyl.gGlu.Pqa.D-Dip.dH.hHis.4Abz.D-aHyp.D-Dap.Y.Iva.I.Tyr_26diMe.P.Asu.meC.I.Tyr_26diMe.P.Asu.meC}$$$$"});(0,t.E3)(v().count(0).take(e.length).map((t=>e.get(t))).every((e=>null!=e&&!isNaN(e))),!0)})),(0,t.t6)("Similarity",(async()=>{const e=await a.functions.call("Bio:sequenceSimilarityScoring",{table:s,macromolecule:i,reference:l});for(let n=0;n<e.length;n++){const o=e.get(n),i=s.get(r,n);(0,t.Wj)(o,i,.01,`Wrong similarity score for sequence at position ${n}`)}}))}));const _e=new e.Package;async function Pe(n,r,o,s){const i=await(0,t.N$)({category:n,test:r,testContext:o,stressTest:s});return e.DataFrame.fromObjects(i)}async function Me(){await(0,t.Xb)(_e,_e.getModule("package-test.js"))}})(),bio_test=r})();
7
+ deps: ${n}}`};const r={keyword:"dependencies",type:"object",schemaType:"object",error:t.error,code(e){const[t,n]=function({schema:e}){const t={},n={};for(const i in e)"__proto__"!==i&&((Array.isArray(e[i])?t:n)[i]=e[i]);return[t,n]}(e);a(e,t),l(e,n)}};function a(e,t=e.schema){const{gen:n,data:o,it:r}=e;if(0===Object.keys(t).length)return;const a=n.let("missing");for(const l in t){const c=t[l];if(0===c.length)continue;const u=(0,s.propertyInData)(n,o,l,r.opts.ownProperties);e.setParams({property:l,depsCount:c.length,deps:c.join(", ")}),r.allErrors?n.if(u,(()=>{for(const t of c)(0,s.checkReportMissingProp)(e,t)})):(n.if(i._`${u} && (${(0,s.checkMissingProp)(e,c,a)})`),(0,s.reportMissingProp)(e,a),n.else())}}function l(e,t=e.schema){const{gen:n,data:i,keyword:r,it:a}=e,l=n.name("valid");for(const c in t)(0,o.alwaysValidSchema)(a,t[c])||(n.if((0,s.propertyInData)(n,i,c,a.opts.ownProperties),(()=>{const t=e.subschema({keyword:r,schemaProp:c},l);e.mergeValidEvaluated(t,l)}),(()=>n.var(l,!0))),e.ok(l))}t.validatePropertyDeps=a,t.validateSchemaDeps=l,t.default=r},4845:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(3025),o={keyword:"dependentSchemas",type:"object",schemaType:"object",code:e=>(0,i.validateSchemaDeps)(e)};t.default=o},1239:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o=n(4227),s={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:{message:({params:e})=>i.str`must match "${e.ifClause}" schema`,params:({params:e})=>i._`{failingKeyword: ${e.ifClause}}`},code(e){const{gen:t,parentSchema:n,it:s}=e;void 0===n.then&&void 0===n.else&&(0,o.checkStrictMode)(s,'"if" without "then" and "else" is ignored');const a=r(s,"then"),l=r(s,"else");if(!a&&!l)return;const c=t.let("valid",!0),u=t.name("_valid");if(function(){const t=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},u);e.mergeEvaluated(t)}(),e.reset(),a&&l){const n=t.let("ifClause");e.setParams({ifClause:n}),t.if(u,h("then",n),h("else",n))}else a?t.if(u,h("then")):t.if((0,i.not)(u),h("else"));function h(n,o){return()=>{const s=e.subschema({keyword:n},u);t.assign(c,u),e.mergeValidEvaluated(s,c),o?t.assign(o,i._`${n}`):e.setParams({ifClause:n})}}e.pass(c,(()=>e.error(!0)))}};function r(e,t){const n=e.schema[t];return void 0!==n&&!(0,o.alwaysValidSchema)(e,n)}t.default=s},6378:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(5457),o=n(5354),s=n(494),r=n(3966),a=n(2661),l=n(3025),c=n(2094),u=n(8660),h=n(117),d=n(5333),p=n(7923),m=n(6505),g=n(6163),f=n(5844),y=n(1239),b=n(4426);t.default=function(e=!1){const t=[p.default,m.default,g.default,f.default,y.default,b.default,c.default,u.default,l.default,h.default,d.default];return e?t.push(o.default,r.default):t.push(i.default,s.default),t.push(a.default),t}},494:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validateTuple=void 0;const i=n(9029),o=n(4227),s=n(5765),r={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){const{schema:t,it:n}=e;if(Array.isArray(t))return a(e,"additionalItems",t);n.items=!0,(0,o.alwaysValidSchema)(n,t)||e.ok((0,s.validateArray)(e))}};function a(e,t,n=e.schema){const{gen:s,parentSchema:r,data:a,keyword:l,it:c}=e;!function(e){const{opts:i,errSchemaPath:s}=c,r=n.length,a=r===e.minItems&&(r===e.maxItems||!1===e[t]);if(i.strictTuples&&!a){const e=`"${l}" is ${r}-tuple, but minItems or maxItems/${t} are not specified or different at path "${s}"`;(0,o.checkStrictMode)(c,e,i.strictTuples)}}(r),c.opts.unevaluated&&n.length&&!0!==c.items&&(c.items=o.mergeEvaluated.items(s,n.length,c.items));const u=s.name("valid"),h=s.const("len",i._`${a}.length`);n.forEach(((t,n)=>{(0,o.alwaysValidSchema)(c,t)||(s.if(i._`${h} > ${n}`,(()=>e.subschema({keyword:l,schemaProp:n,dataProp:n},u))),e.ok(u))}))}t.validateTuple=a,t.default=r},3966:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o=n(4227),s=n(5765),r=n(5457),a={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:{message:({params:{len:e}})=>i.str`must NOT have more than ${e} items`,params:({params:{len:e}})=>i._`{limit: ${e}}`},code(e){const{schema:t,parentSchema:n,it:i}=e,{prefixItems:a}=n;i.items=!0,(0,o.alwaysValidSchema)(i,t)||(a?(0,r.validateAdditionalItems)(e,a):e.ok((0,s.validateArray)(e)))}};t.default=a},7923:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(4227),o={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){const{gen:t,schema:n,it:o}=e;if((0,i.alwaysValidSchema)(o,n))return void e.fail();const s=t.name("valid");e.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},s),e.failResult(s,(()=>e.reset()),(()=>e.error()))},error:{message:"must NOT be valid"}};t.default=o},6163:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o=n(4227),s={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:{message:"must match exactly one schema in oneOf",params:({params:e})=>i._`{passingSchemas: ${e.passing}}`},code(e){const{gen:t,schema:n,parentSchema:s,it:r}=e;if(!Array.isArray(n))throw new Error("ajv implementation error");if(r.opts.discriminator&&s.discriminator)return;const a=n,l=t.let("valid",!1),c=t.let("passing",null),u=t.name("_valid");e.setParams({passing:c}),t.block((function(){a.forEach(((n,s)=>{let a;(0,o.alwaysValidSchema)(r,n)?t.var(u,!0):a=e.subschema({keyword:"oneOf",schemaProp:s,compositeRule:!0},u),s>0&&t.if(i._`${u} && ${l}`).assign(l,!1).assign(c,i._`[${c}, ${s}]`).else(),t.if(u,(()=>{t.assign(l,!0),t.assign(c,s),a&&e.mergeEvaluated(a,i.Name)}))}))})),e.result(l,(()=>e.reset()),(()=>e.error(!0)))}};t.default=s},5333:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(5765),o=n(9029),s=n(4227),r=n(4227),a={keyword:"patternProperties",type:"object",schemaType:"object",code(e){const{gen:t,schema:n,data:a,parentSchema:l,it:c}=e,{opts:u}=c,h=(0,i.allSchemaProperties)(n),d=h.filter((e=>(0,s.alwaysValidSchema)(c,n[e])));if(0===h.length||d.length===h.length&&(!c.opts.unevaluated||!0===c.props))return;const p=u.strictSchema&&!u.allowMatchingProperties&&l.properties,m=t.name("valid");!0===c.props||c.props instanceof o.Name||(c.props=(0,r.evaluatedPropsToName)(t,c.props));const{props:g}=c;function f(e){for(const t in p)new RegExp(e).test(t)&&(0,s.checkStrictMode)(c,`property ${t} matches pattern ${e} (use allowMatchingProperties)`)}function y(n){t.forIn("key",a,(s=>{t.if(o._`${(0,i.usePattern)(e,n)}.test(${s})`,(()=>{const i=d.includes(n);i||e.subschema({keyword:"patternProperties",schemaProp:n,dataProp:s,dataPropType:r.Type.Str},m),c.opts.unevaluated&&!0!==g?t.assign(o._`${g}[${s}]`,!0):i||c.allErrors||t.if((0,o.not)(m),(()=>t.break()))}))}))}!function(){for(const e of h)p&&f(e),c.allErrors?y(e):(t.var(m,!0),y(e),t.if(m))}()}};t.default=a},5354:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(494),o={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,i.validateTuple)(e,"items")};t.default=o},117:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(2586),o=n(5765),s=n(4227),r=n(8660),a={keyword:"properties",type:"object",schemaType:"object",code(e){const{gen:t,schema:n,parentSchema:a,data:l,it:c}=e;"all"===c.opts.removeAdditional&&void 0===a.additionalProperties&&r.default.code(new i.KeywordCxt(c,r.default,"additionalProperties"));const u=(0,o.allSchemaProperties)(n);for(const e of u)c.definedProperties.add(e);c.opts.unevaluated&&u.length&&!0!==c.props&&(c.props=s.mergeEvaluated.props(t,(0,s.toHash)(u),c.props));const h=u.filter((e=>!(0,s.alwaysValidSchema)(c,n[e])));if(0===h.length)return;const d=t.name("valid");for(const n of h)p(n)?m(n):(t.if((0,o.propertyInData)(t,l,n,c.opts.ownProperties)),m(n),c.allErrors||t.else().var(d,!0),t.endIf()),e.it.definedProperties.add(n),e.ok(d);function p(e){return c.opts.useDefaults&&!c.compositeRule&&void 0!==n[e].default}function m(t){e.subschema({keyword:"properties",schemaProp:t,dataProp:t},d)}}};t.default=a},2094:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o=n(4227),s={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:{message:"property name must be valid",params:({params:e})=>i._`{propertyName: ${e.propertyName}}`},code(e){const{gen:t,schema:n,data:s,it:r}=e;if((0,o.alwaysValidSchema)(r,n))return;const a=t.name("valid");t.forIn("key",s,(n=>{e.setParams({propertyName:n}),e.subschema({keyword:"propertyNames",data:n,dataTypes:["string"],propertyName:n,compositeRule:!0},a),t.if((0,i.not)(a),(()=>{e.error(!0),r.allErrors||t.break()}))})),e.ok(a)}};t.default=s},4426:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(4227),o={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:n}){void 0===t.if&&(0,i.checkStrictMode)(n,`"${e}" without "if" is ignored`)}};t.default=o},5765:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validateUnion=t.validateArray=t.usePattern=t.callValidateCode=t.schemaProperties=t.allSchemaProperties=t.noPropertyInData=t.propertyInData=t.isOwnProperty=t.hasPropFunc=t.reportMissingProp=t.checkMissingProp=t.checkReportMissingProp=void 0;const i=n(9029),o=n(4227),s=n(2023),r=n(4227);function a(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:i._`Object.prototype.hasOwnProperty`})}function l(e,t,n){return i._`${a(e)}.call(${t}, ${n})`}function c(e,t,n,o){const s=i._`${t}${(0,i.getProperty)(n)} === undefined`;return o?(0,i.or)(s,(0,i.not)(l(e,t,n))):s}function u(e){return e?Object.keys(e).filter((e=>"__proto__"!==e)):[]}t.checkReportMissingProp=function(e,t){const{gen:n,data:o,it:s}=e;n.if(c(n,o,t,s.opts.ownProperties),(()=>{e.setParams({missingProperty:i._`${t}`},!0),e.error()}))},t.checkMissingProp=function({gen:e,data:t,it:{opts:n}},o,s){return(0,i.or)(...o.map((o=>(0,i.and)(c(e,t,o,n.ownProperties),i._`${s} = ${o}`))))},t.reportMissingProp=function(e,t){e.setParams({missingProperty:t},!0),e.error()},t.hasPropFunc=a,t.isOwnProperty=l,t.propertyInData=function(e,t,n,o){const s=i._`${t}${(0,i.getProperty)(n)} !== undefined`;return o?i._`${s} && ${l(e,t,n)}`:s},t.noPropertyInData=c,t.allSchemaProperties=u,t.schemaProperties=function(e,t){return u(t).filter((n=>!(0,o.alwaysValidSchema)(e,t[n])))},t.callValidateCode=function({schemaCode:e,data:t,it:{gen:n,topSchemaRef:o,schemaPath:r,errorPath:a},it:l},c,u,h){const d=h?i._`${e}, ${t}, ${o}${r}`:t,p=[[s.default.instancePath,(0,i.strConcat)(s.default.instancePath,a)],[s.default.parentData,l.parentData],[s.default.parentDataProperty,l.parentDataProperty],[s.default.rootData,s.default.rootData]];l.opts.dynamicRef&&p.push([s.default.dynamicAnchors,s.default.dynamicAnchors]);const m=i._`${d}, ${n.object(...p)}`;return u!==i.nil?i._`${c}.call(${u}, ${m})`:i._`${c}(${m})`};const h=i._`new RegExp`;t.usePattern=function({gen:e,it:{opts:t}},n){const o=t.unicodeRegExp?"u":"",{regExp:s}=t.code,a=s(n,o);return e.scopeValue("pattern",{key:a.toString(),ref:a,code:i._`${"new RegExp"===s.code?h:(0,r.useFunc)(e,s)}(${n}, ${o})`})},t.validateArray=function(e){const{gen:t,data:n,keyword:s,it:r}=e,a=t.name("valid");if(r.allErrors){const e=t.let("valid",!0);return l((()=>t.assign(e,!1))),e}return t.var(a,!0),l((()=>t.break())),a;function l(r){const l=t.const("len",i._`${n}.length`);t.forRange("i",0,l,(n=>{e.subschema({keyword:s,dataProp:n,dataPropType:o.Type.Num},a),t.if((0,i.not)(a),r)}))}},t.validateUnion=function(e){const{gen:t,schema:n,keyword:s,it:r}=e;if(!Array.isArray(n))throw new Error("ajv implementation error");if(n.some((e=>(0,o.alwaysValidSchema)(r,e)))&&!r.opts.unevaluated)return;const a=t.let("valid",!1),l=t.name("_valid");t.block((()=>n.forEach(((n,o)=>{const r=e.subschema({keyword:s,schemaProp:o,compositeRule:!0},l);t.assign(a,i._`${a} || ${l}`),e.mergeValidEvaluated(r,l)||t.if((0,i.not)(a))})))),e.result(a,(()=>e.reset()),(()=>e.error(!0)))}},3463:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};t.default=n},2128:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(3463),o=n(3693),s=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",i.default,o.default];t.default=s},3693:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.callRef=t.getValidate=void 0;const i=n(4551),o=n(5765),s=n(9029),r=n(2023),a=n(3835),l=n(4227),c={keyword:"$ref",schemaType:"string",code(e){const{gen:t,schema:n,it:o}=e,{baseId:r,schemaEnv:l,validateName:c,opts:d,self:p}=o,{root:m}=l;if(("#"===n||"#/"===n)&&r===m.baseId)return function(){if(l===m)return h(e,c,l,l.$async);const n=t.scopeValue("root",{ref:m});return h(e,s._`${n}.validate`,m,m.$async)}();const g=a.resolveRef.call(p,m,r,n);if(void 0===g)throw new i.default(o.opts.uriResolver,r,n);return g instanceof a.SchemaEnv?function(t){const n=u(e,t);h(e,n,t,t.$async)}(g):function(i){const o=t.scopeValue("schema",!0===d.code.source?{ref:i,code:(0,s.stringify)(i)}:{ref:i}),r=t.name("valid"),a=e.subschema({schema:i,dataTypes:[],schemaPath:s.nil,topSchemaRef:o,errSchemaPath:n},r);e.mergeEvaluated(a),e.ok(r)}(g)}};function u(e,t){const{gen:n}=e;return t.validate?n.scopeValue("validate",{ref:t.validate}):s._`${n.scopeValue("wrapper",{ref:t})}.validate`}function h(e,t,n,i){const{gen:a,it:c}=e,{allErrors:u,schemaEnv:h,opts:d}=c,p=d.passContext?r.default.this:s.nil;function m(e){const t=s._`${e}.errors`;a.assign(r.default.vErrors,s._`${r.default.vErrors} === null ? ${t} : ${r.default.vErrors}.concat(${t})`),a.assign(r.default.errors,s._`${r.default.vErrors}.length`)}function g(e){var t;if(!c.opts.unevaluated)return;const i=null===(t=null==n?void 0:n.validate)||void 0===t?void 0:t.evaluated;if(!0!==c.props)if(i&&!i.dynamicProps)void 0!==i.props&&(c.props=l.mergeEvaluated.props(a,i.props,c.props));else{const t=a.var("props",s._`${e}.evaluated.props`);c.props=l.mergeEvaluated.props(a,t,c.props,s.Name)}if(!0!==c.items)if(i&&!i.dynamicItems)void 0!==i.items&&(c.items=l.mergeEvaluated.items(a,i.items,c.items));else{const t=a.var("items",s._`${e}.evaluated.items`);c.items=l.mergeEvaluated.items(a,t,c.items,s.Name)}}i?function(){if(!h.$async)throw new Error("async schema referenced by sync schema");const n=a.let("valid");a.try((()=>{a.code(s._`await ${(0,o.callValidateCode)(e,t,p)}`),g(t),u||a.assign(n,!0)}),(e=>{a.if(s._`!(${e} instanceof ${c.ValidationError})`,(()=>a.throw(e))),m(e),u||a.assign(n,!1)})),e.ok(n)}():e.result((0,o.callValidateCode)(e,t,p),(()=>g(t)),(()=>m(t)))}t.getValidate=u,t.callRef=h,t.default=c},6653:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o=n(7652),s=n(3835),r=n(4551),a=n(4227),l={keyword:"discriminator",type:"object",schemaType:"object",error:{message:({params:{discrError:e,tagName:t}})=>e===o.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:n}})=>i._`{error: ${e}, tag: ${n}, tagValue: ${t}}`},code(e){const{gen:t,data:n,schema:l,parentSchema:c,it:u}=e,{oneOf:h}=c;if(!u.opts.discriminator)throw new Error("discriminator: requires discriminator option");const d=l.propertyName;if("string"!=typeof d)throw new Error("discriminator: requires propertyName");if(l.mapping)throw new Error("discriminator: mapping is not supported");if(!h)throw new Error("discriminator: requires oneOf keyword");const p=t.let("valid",!1),m=t.const("tag",i._`${n}${(0,i.getProperty)(d)}`);function g(n){const o=t.name("valid"),s=e.subschema({keyword:"oneOf",schemaProp:n},o);return e.mergeEvaluated(s,i.Name),o}t.if(i._`typeof ${m} == "string"`,(()=>function(){const n=function(){var e;const t={},n=o(c);let i=!0;for(let t=0;t<h.length;t++){let c=h[t];if((null==c?void 0:c.$ref)&&!(0,a.schemaHasRulesButRef)(c,u.self.RULES)){const e=c.$ref;if(c=s.resolveRef.call(u.self,u.schemaEnv.root,u.baseId,e),c instanceof s.SchemaEnv&&(c=c.schema),void 0===c)throw new r.default(u.opts.uriResolver,u.baseId,e)}const p=null===(e=null==c?void 0:c.properties)||void 0===e?void 0:e[d];if("object"!=typeof p)throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${d}"`);i=i&&(n||o(c)),l(p,t)}if(!i)throw new Error(`discriminator: "${d}" must be required`);return t;function o({required:e}){return Array.isArray(e)&&e.includes(d)}function l(e,t){if(e.const)p(e.const,t);else{if(!e.enum)throw new Error(`discriminator: "properties/${d}" must have "const" or "enum"`);for(const n of e.enum)p(n,t)}}function p(e,n){if("string"!=typeof e||e in t)throw new Error(`discriminator: "${d}" values must be unique strings`);t[e]=n}}();t.if(!1);for(const e in n)t.elseIf(i._`${m} === ${e}`),t.assign(p,g(n[e]));t.else(),e.error(!1,{discrError:o.DiscrError.Mapping,tag:m,tagName:d}),t.endIf()}()),(()=>e.error(!1,{discrError:o.DiscrError.Tag,tag:m,tagName:d}))),e.ok(p)}};t.default=l},7652:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.DiscrError=void 0,function(e){e.Tag="tag",e.Mapping="mapping"}(n||(t.DiscrError=n={}))},6105:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(2128),o=n(7060),s=n(6378),r=n(5520),a=n(5413),l=n(3265),c=n(7532),u=n(9857),h=[r.default,i.default,o.default,(0,s.default)(!0),c.default,u.metadataVocabulary,u.contentVocabulary,a.default,l.default];t.default=h},6144:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(2128),o=n(7060),s=n(6378),r=n(7532),a=n(9857),l=[i.default,o.default,(0,s.default)(),r.default,a.metadataVocabulary,a.contentVocabulary];t.default=l},2476:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dynamicAnchor=void 0;const i=n(9029),o=n(2023),s=n(3835),r=n(3693),a={keyword:"$dynamicAnchor",schemaType:"string",code:e=>l(e,e.schema)};function l(e,t){const{gen:n,it:a}=e;a.schemaEnv.root.dynamicAnchors[t]=!0;const l=i._`${o.default.dynamicAnchors}${(0,i.getProperty)(t)}`,c="#"===a.errSchemaPath?a.validateName:function(e){const{schemaEnv:t,schema:n,self:i}=e.it,{root:o,baseId:a,localRefs:l,meta:c}=t.root,{schemaId:u}=i.opts,h=new s.SchemaEnv({schema:n,schemaId:u,root:o,baseId:a,localRefs:l,meta:c});return s.compileSchema.call(i,h),(0,r.getValidate)(e,h)}(e);n.if(i._`!${l}`,(()=>n.assign(l,c)))}t.dynamicAnchor=l,t.default=a},3252:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dynamicRef=void 0;const i=n(9029),o=n(2023),s=n(3693),r={keyword:"$dynamicRef",schemaType:"string",code:e=>a(e,e.schema)};function a(e,t){const{gen:n,keyword:r,it:a}=e;if("#"!==t[0])throw new Error(`"${r}" only supports hash fragment reference`);const l=t.slice(1);if(a.allErrors)c();else{const t=n.let("valid",!1);c(t),e.ok(t)}function c(e){if(a.schemaEnv.root.dynamicAnchors[l]){const t=n.let("_v",i._`${o.default.dynamicAnchors}${(0,i.getProperty)(l)}`);n.if(t,u(t,e),u(a.validateName,e))}else u(a.validateName,e)()}function u(t,i){return i?()=>n.block((()=>{(0,s.callRef)(e,t),n.let(i,!0)})):()=>(0,s.callRef)(e,t)}}t.dynamicRef=a,t.default=r},5520:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(2476),o=n(3252),s=n(2721),r=n(3799),a=[i.default,o.default,s.default,r.default];t.default=a},2721:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(2476),o=n(4227),s={keyword:"$recursiveAnchor",schemaType:"boolean",code(e){e.schema?(0,i.dynamicAnchor)(e,""):(0,o.checkStrictMode)(e.it,"$recursiveAnchor: false is ignored")}};t.default=s},3799:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(3252),o={keyword:"$recursiveRef",schemaType:"string",code:e=>(0,i.dynamicRef)(e,e.schema)};t.default=o},4737:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:{message:({schemaCode:e})=>i.str`must match format "${e}"`,params:({schemaCode:e})=>i._`{format: ${e}}`},code(e,t){const{gen:n,data:o,$data:s,schema:r,schemaCode:a,it:l}=e,{opts:c,errSchemaPath:u,schemaEnv:h,self:d}=l;c.validateFormats&&(s?function(){const s=n.scopeValue("formats",{ref:d.formats,code:c.code.formats}),r=n.const("fDef",i._`${s}[${a}]`),l=n.let("fType"),u=n.let("format");n.if(i._`typeof ${r} == "object" && !(${r} instanceof RegExp)`,(()=>n.assign(l,i._`${r}.type || "string"`).assign(u,i._`${r}.validate`)),(()=>n.assign(l,i._`"string"`).assign(u,r))),e.fail$data((0,i.or)(!1===c.strictSchema?i.nil:i._`${a} && !${u}`,function(){const e=h.$async?i._`(${r}.async ? await ${u}(${o}) : ${u}(${o}))`:i._`${u}(${o})`,n=i._`(typeof ${u} == "function" ? ${e} : ${u}.test(${o}))`;return i._`${u} && ${u} !== true && ${l} === ${t} && !${n}`}()))}():function(){const s=d.formats[r];if(!s)return void function(){if(!1!==c.strictSchema)throw new Error(e());function e(){return`unknown format "${r}" ignored in schema at path "${u}"`}d.logger.warn(e())}();if(!0===s)return;const[a,l,p]=function(e){const t=e instanceof RegExp?(0,i.regexpCode)(e):c.code.formats?i._`${c.code.formats}${(0,i.getProperty)(r)}`:void 0,o=n.scopeValue("formats",{key:r,ref:e,code:t});return"object"!=typeof e||e instanceof RegExp?["string",e,o]:[e.type||"string",e.validate,i._`${o}.validate`]}(s);a===t&&e.pass(function(){if("object"==typeof s&&!(s instanceof RegExp)&&s.async){if(!h.$async)throw new Error("async format in sync schema");return i._`await ${p}(${o})`}return"function"==typeof l?i._`${p}(${o})`:i._`${p}.test(${o})`}())}())}};t.default=o},7532:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=[n(4737).default];t.default=i},9857:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.contentVocabulary=t.metadataVocabulary=void 0,t.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"],t.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]},5413:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(1846),o=n(4845),s=n(2626),r=[i.default,o.default,s.default];t.default=r},3265:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(392),o=n(3445),s=[i.default,o.default];t.default=s},3445:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o=n(4227),s={keyword:"unevaluatedItems",type:"array",schemaType:["boolean","object"],error:{message:({params:{len:e}})=>i.str`must NOT have more than ${e} items`,params:({params:{len:e}})=>i._`{limit: ${e}}`},code(e){const{gen:t,schema:n,data:s,it:r}=e,a=r.items||0;if(!0===a)return;const l=t.const("len",i._`${s}.length`);if(!1===n)e.setParams({len:a}),e.fail(i._`${l} > ${a}`);else if("object"==typeof n&&!(0,o.alwaysValidSchema)(r,n)){const n=t.var("valid",i._`${l} <= ${a}`);t.if((0,i.not)(n),(()=>function(n,s){t.forRange("i",s,l,(s=>{e.subschema({keyword:"unevaluatedItems",dataProp:s,dataPropType:o.Type.Num},n),r.allErrors||t.if((0,i.not)(n),(()=>t.break()))}))}(n,a))),e.ok(n)}r.items=!0}};t.default=s},392:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o=n(4227),s=n(2023),r={keyword:"unevaluatedProperties",type:"object",schemaType:["boolean","object"],trackErrors:!0,error:{message:"must NOT have unevaluated properties",params:({params:e})=>i._`{unevaluatedProperty: ${e.unevaluatedProperty}}`},code(e){const{gen:t,schema:n,data:r,errsCount:a,it:l}=e;if(!a)throw new Error("ajv implementation error");const{allErrors:c,props:u}=l;function h(s){if(!1===n)return e.setParams({unevaluatedProperty:s}),e.error(),void(c||t.break());if(!(0,o.alwaysValidSchema)(l,n)){const n=t.name("valid");e.subschema({keyword:"unevaluatedProperties",dataProp:s,dataPropType:o.Type.Str},n),c||t.if((0,i.not)(n),(()=>t.break()))}}u instanceof i.Name?t.if(i._`${u} !== true`,(()=>t.forIn("key",r,(e=>t.if(function(e,t){return i._`!${e} || !${e}[${t}]`}(u,e),(()=>h(e))))))):!0!==u&&t.forIn("key",r,(e=>void 0===u?h(e):t.if(function(e,t){const n=[];for(const o in e)!0===e[o]&&n.push(i._`${t} !== ${o}`);return(0,i.and)(...n)}(u,e),(()=>h(e))))),l.props=!0,e.ok(i._`${a} === ${s.default.errors}`)}};t.default=r},7935:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o=n(4227),s=n(6250),r={keyword:"const",$data:!0,error:{message:"must be equal to constant",params:({schemaCode:e})=>i._`{allowedValue: ${e}}`},code(e){const{gen:t,data:n,$data:r,schemaCode:a,schema:l}=e;r||l&&"object"==typeof l?e.fail$data(i._`!${(0,o.useFunc)(t,s.default)}(${n}, ${a})`):e.fail(i._`${l} !== ${n}`)}};t.default=r},1846:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(3025),o={keyword:"dependentRequired",type:"object",schemaType:"object",error:i.error,code:e=>(0,i.validatePropertyDeps)(e)};t.default=o},8643:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o=n(4227),s=n(6250),r={keyword:"enum",schemaType:"array",$data:!0,error:{message:"must be equal to one of the allowed values",params:({schemaCode:e})=>i._`{allowedValues: ${e}}`},code(e){const{gen:t,data:n,$data:r,schema:a,schemaCode:l,it:c}=e;if(!r&&0===a.length)throw new Error("enum must have non-empty array");const u=a.length>=c.opts.loopEnum;let h;const d=()=>null!=h?h:h=(0,o.useFunc)(t,s.default);let p;if(u||r)p=t.let("valid"),e.block$data(p,(function(){t.assign(p,!1),t.forOf("v",l,(e=>t.if(i._`${d()}(${n}, ${e})`,(()=>t.assign(p,!0).break()))))}));else{if(!Array.isArray(a))throw new Error("ajv implementation error");const e=t.const("vSchema",l);p=(0,i.or)(...a.map(((t,o)=>function(e,t){const o=a[t];return"object"==typeof o&&null!==o?i._`${d()}(${n}, ${e}[${t}])`:i._`${n} === ${o}`}(e,o))))}e.pass(p)}};t.default=r},7060:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(5882),o=n(3439),s=n(7307),r=n(422),a=n(4486),l=n(4003),c=n(1163),u=n(617),h=n(7935),d=n(8643),p=[i.default,o.default,s.default,r.default,a.default,l.default,c.default,u.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},h.default,d.default];t.default=p},2626:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(4227),o={keyword:["maxContains","minContains"],type:"array",schemaType:"number",code({keyword:e,parentSchema:t,it:n}){void 0===t.contains&&(0,i.checkStrictMode)(n,`"${e}" without "contains" is ignored`)}};t.default=o},1163:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:{message({keyword:e,schemaCode:t}){const n="maxItems"===e?"more":"fewer";return i.str`must NOT have ${n} than ${t} items`},params:({schemaCode:e})=>i._`{limit: ${e}}`},code(e){const{keyword:t,data:n,schemaCode:o}=e,s="maxItems"===t?i.operators.GT:i.operators.LT;e.fail$data(i._`${n}.length ${s} ${o}`)}};t.default=o},7307:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o=n(4227),s=n(3853),r={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:{message({keyword:e,schemaCode:t}){const n="maxLength"===e?"more":"fewer";return i.str`must NOT have ${n} than ${t} characters`},params:({schemaCode:e})=>i._`{limit: ${e}}`},code(e){const{keyword:t,data:n,schemaCode:r,it:a}=e,l="maxLength"===t?i.operators.GT:i.operators.LT,c=!1===a.opts.unicode?i._`${n}.length`:i._`${(0,o.useFunc)(e.gen,s.default)}(${n})`;e.fail$data(i._`${c} ${l} ${r}`)}};t.default=r},5882:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o=i.operators,s={maximum:{okStr:"<=",ok:o.LTE,fail:o.GT},minimum:{okStr:">=",ok:o.GTE,fail:o.LT},exclusiveMaximum:{okStr:"<",ok:o.LT,fail:o.GTE},exclusiveMinimum:{okStr:">",ok:o.GT,fail:o.LTE}},r={message:({keyword:e,schemaCode:t})=>i.str`must be ${s[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>i._`{comparison: ${s[e].okStr}, limit: ${t}}`},a={keyword:Object.keys(s),type:"number",schemaType:"number",$data:!0,error:r,code(e){const{keyword:t,data:n,schemaCode:o}=e;e.fail$data(i._`${n} ${s[t].fail} ${o} || isNaN(${n})`)}};t.default=a},4486:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:{message({keyword:e,schemaCode:t}){const n="maxProperties"===e?"more":"fewer";return i.str`must NOT have ${n} than ${t} properties`},params:({schemaCode:e})=>i._`{limit: ${e}}`},code(e){const{keyword:t,data:n,schemaCode:o}=e,s="maxProperties"===t?i.operators.GT:i.operators.LT;e.fail$data(i._`Object.keys(${n}).length ${s} ${o}`)}};t.default=o},3439:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:{message:({schemaCode:e})=>i.str`must be multiple of ${e}`,params:({schemaCode:e})=>i._`{multipleOf: ${e}}`},code(e){const{gen:t,data:n,schemaCode:o,it:s}=e,r=s.opts.multipleOfPrecision,a=t.let("res"),l=r?i._`Math.abs(Math.round(${a}) - ${a}) > 1e-${r}`:i._`${a} !== parseInt(${a})`;e.fail$data(i._`(${o} === 0 || (${a} = ${n}/${o}, ${l}))`)}};t.default=o},422:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(5765),o=n(9029),s={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:{message:({schemaCode:e})=>o.str`must match pattern "${e}"`,params:({schemaCode:e})=>o._`{pattern: ${e}}`},code(e){const{data:t,$data:n,schema:s,schemaCode:r,it:a}=e,l=a.opts.unicodeRegExp?"u":"",c=n?o._`(new RegExp(${r}, ${l}))`:(0,i.usePattern)(e,s);e.fail$data(o._`!${c}.test(${t})`)}};t.default=s},4003:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(5765),o=n(9029),s=n(4227),r={keyword:"required",type:"object",schemaType:"array",$data:!0,error:{message:({params:{missingProperty:e}})=>o.str`must have required property '${e}'`,params:({params:{missingProperty:e}})=>o._`{missingProperty: ${e}}`},code(e){const{gen:t,schema:n,schemaCode:r,data:a,$data:l,it:c}=e,{opts:u}=c;if(!l&&0===n.length)return;const h=n.length>=u.loopRequired;if(c.allErrors?function(){if(h||l)e.block$data(o.nil,d);else for(const t of n)(0,i.checkReportMissingProp)(e,t)}():function(){const s=t.let("missing");if(h||l){const n=t.let("valid",!0);e.block$data(n,(()=>function(n,s){e.setParams({missingProperty:n}),t.forOf(n,r,(()=>{t.assign(s,(0,i.propertyInData)(t,a,n,u.ownProperties)),t.if((0,o.not)(s),(()=>{e.error(),t.break()}))}),o.nil)}(s,n))),e.ok(n)}else t.if((0,i.checkMissingProp)(e,n,s)),(0,i.reportMissingProp)(e,s),t.else()}(),u.strictRequired){const t=e.parentSchema.properties,{definedProperties:i}=e.it;for(const e of n)if(void 0===(null==t?void 0:t[e])&&!i.has(e)){const t=`required property "${e}" is not defined at "${c.schemaEnv.baseId+c.errSchemaPath}" (strictRequired)`;(0,s.checkStrictMode)(c,t,c.opts.strictRequired)}}function d(){t.forOf("prop",r,(n=>{e.setParams({missingProperty:n}),t.if((0,i.noPropertyInData)(t,a,n,u.ownProperties),(()=>e.error()))}))}}};t.default=r},617:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(208),o=n(9029),s=n(4227),r=n(6250),a={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:{message:({params:{i:e,j:t}})=>o.str`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>o._`{i: ${e}, j: ${t}}`},code(e){const{gen:t,data:n,$data:a,schema:l,parentSchema:c,schemaCode:u,it:h}=e;if(!a&&!l)return;const d=t.let("valid"),p=c.items?(0,i.getSchemaTypes)(c.items):[];function m(s,r){const a=t.name("item"),l=(0,i.checkDataTypes)(p,a,h.opts.strictNumbers,i.DataType.Wrong),c=t.const("indices",o._`{}`);t.for(o._`;${s}--;`,(()=>{t.let(a,o._`${n}[${s}]`),t.if(l,o._`continue`),p.length>1&&t.if(o._`typeof ${a} == "string"`,o._`${a} += "_"`),t.if(o._`typeof ${c}[${a}] == "number"`,(()=>{t.assign(r,o._`${c}[${a}]`),e.error(),t.assign(d,!1).break()})).code(o._`${c}[${a}] = ${s}`)}))}function g(i,a){const l=(0,s.useFunc)(t,r.default),c=t.name("outer");t.label(c).for(o._`;${i}--;`,(()=>t.for(o._`${a} = ${i}; ${a}--;`,(()=>t.if(o._`${l}(${n}[${i}], ${n}[${a}])`,(()=>{e.error(),t.assign(d,!1).break(c)}))))))}e.block$data(d,(function(){const i=t.let("i",o._`${n}.length`),s=t.let("j");e.setParams({i,j:s}),t.assign(d,!0),t.if(o._`${i} > 1`,(()=>(p.length>0&&!p.some((e=>"object"===e||"array"===e))?m:g)(i,s)))}),o._`${u} === false`),e.ok(d)}};t.default=a},5488:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var i=n(1354),o=n.n(i),s=n(6314),r=n.n(s)()(o());r.push([e.id,"\n.ui-form.ui-tooltip .ui-input-root > label.ui-input-label:not(:empty) {\n /* min-width: 30px; /* Breaks right margin /**/\n}\n\n.ui-form.ui-tooltip .ui-input-root > div.ui-input-text:not(:empty) {\n margin-top: 6px;\n}","",{version:3,sources:["webpack://./css/cell-renderer.css"],names:[],mappings:";AACA;IACI,8CAA8C;AAClD;;AAEA;IACI,eAAe;AACnB",sourcesContent:["\n.ui-form.ui-tooltip .ui-input-root > label.ui-input-label:not(:empty) {\n /* min-width: 30px; /* Breaks right margin /**/\n}\n\n.ui-form.ui-tooltip .ui-input-root > div.ui-input-text:not(:empty) {\n margin-top: 6px;\n}"],sourceRoot:""}]);const a=r},5999:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var i=n(1354),o=n.n(i),s=n(6314),r=n.n(s)()(o());r.push([e.id,".macromolecule-cell-comp-analysis-host{\n max-height: 250px;\n overflow-y: scroll;\n}\n\n.macromolecule-cell-comp-analysis-bar{\n height: inherit;\n display: block;\n margin-top: 1.5px;\n margin-bottom: 1.5px;\n margin-right: 3px;\n}\n\n.macromolecule-cell-comp-analysis-value{\n display: flex;\n}","",{version:3,sources:["webpack://./css/composition-analysis.css"],names:[],mappings:"AAAA;IACI,iBAAiB;IACjB,kBAAkB;AACtB;;AAEA;IACI,eAAe;IACf,cAAc;IACd,iBAAiB;IACjB,oBAAoB;IACpB,iBAAiB;AACrB;;AAEA;IACI,aAAa;AACjB",sourcesContent:[".macromolecule-cell-comp-analysis-host{\n max-height: 250px;\n overflow-y: scroll;\n}\n\n.macromolecule-cell-comp-analysis-bar{\n height: inherit;\n display: block;\n margin-top: 1.5px;\n margin-bottom: 1.5px;\n margin-right: 3px;\n}\n\n.macromolecule-cell-comp-analysis-value{\n display: flex;\n}"],sourceRoot:""}]);const a=r},857:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var i=n(1354),o=n.n(i),s=n(6314),r=n.n(s)()(o());r.push([e.id,".monomer-manager-root .grok-sketcher {\n min-width: unset !important;\n}\n\n.monomer-manager-root {\n width: 100% !important;\n height: 100% !important;\n}\n\n.monomer-manager-sketcher .ketcher-host {\n height: 100% !important;\n width: unset !important;\n} \n\n.monomer-manager-root > div:first-child {\n flex-basis: 40% !important;\n}\n.monomer-manager-root > div:nth-child(2) {\n flex-basis: 60% !important;\n}\n\n.monomer-manager-root > div:first-child > .ui-form {\n max-width: unset !important;\n}\n\n.monomer-card-info-row {\n width: 100%;\n overflow: hidden;\n text-overflow: ellipsis;\n margin-bottom: 10px;\n}\n\n.monomer-card-info-row > div:nth-child(2) {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.monomer-card-info-row > div:nth-child(1) {\n font-weight: bold;\n margin-right: 5px;\n text-wrap: nowrap;\n}\n\n.duplicate-monomer-symbol-row {\n visibility: visible !important;\n}\n\n.monomer-card-root {\n border: 2px solid var(--grey-2);\n border-radius: 5px;\n padding: 5px;\n margin: 5px;\n overflow: hidden;\n align-items: center;\n cursor: pointer;\n width: 200px;\n height: 300px;\n min-width: 200px;\n min-height: 300px;\n}\n\n.duplicate-monomers-virtual-view {\n width: 100% !important;\n overflow-x: clip;\n overflow-y: auto;\n}\n\n.monomer-manager-form-tab-control input.d4-invalid {\n background: #ff000030;\n}\n\n.monomer-lib-controls-form .ui-input-root {\n flex-wrap: nowrap !important;\n}","",{version:3,sources:["webpack://./css/monomer-manager.css"],names:[],mappings:"AAAA;IACI,2BAA2B;AAC/B;;AAEA;IACI,sBAAsB;IACtB,uBAAuB;AAC3B;;AAEA;IACI,uBAAuB;IACvB,uBAAuB;AAC3B;;AAEA;IACI,0BAA0B;AAC9B;AACA;IACI,0BAA0B;AAC9B;;AAEA;IACI,2BAA2B;AAC/B;;AAEA;IACI,WAAW;IACX,gBAAgB;IAChB,uBAAuB;IACvB,mBAAmB;AACvB;;AAEA;IACI,mBAAmB;IACnB,gBAAgB;IAChB,uBAAuB;AAC3B;;AAEA;IACI,iBAAiB;IACjB,iBAAiB;IACjB,iBAAiB;AACrB;;AAEA;IACI,8BAA8B;AAClC;;AAEA;IACI,+BAA+B;IAC/B,kBAAkB;IAClB,YAAY;IACZ,WAAW;IACX,gBAAgB;IAChB,mBAAmB;IACnB,eAAe;IACf,YAAY;IACZ,aAAa;IACb,gBAAgB;IAChB,iBAAiB;AACrB;;AAEA;IACI,sBAAsB;IACtB,gBAAgB;IAChB,gBAAgB;AACpB;;AAEA;IACI,qBAAqB;AACzB;;AAEA;IACI,4BAA4B;AAChC",sourcesContent:[".monomer-manager-root .grok-sketcher {\n min-width: unset !important;\n}\n\n.monomer-manager-root {\n width: 100% !important;\n height: 100% !important;\n}\n\n.monomer-manager-sketcher .ketcher-host {\n height: 100% !important;\n width: unset !important;\n} \n\n.monomer-manager-root > div:first-child {\n flex-basis: 40% !important;\n}\n.monomer-manager-root > div:nth-child(2) {\n flex-basis: 60% !important;\n}\n\n.monomer-manager-root > div:first-child > .ui-form {\n max-width: unset !important;\n}\n\n.monomer-card-info-row {\n width: 100%;\n overflow: hidden;\n text-overflow: ellipsis;\n margin-bottom: 10px;\n}\n\n.monomer-card-info-row > div:nth-child(2) {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.monomer-card-info-row > div:nth-child(1) {\n font-weight: bold;\n margin-right: 5px;\n text-wrap: nowrap;\n}\n\n.duplicate-monomer-symbol-row {\n visibility: visible !important;\n}\n\n.monomer-card-root {\n border: 2px solid var(--grey-2);\n border-radius: 5px;\n padding: 5px;\n margin: 5px;\n overflow: hidden;\n align-items: center;\n cursor: pointer;\n width: 200px;\n height: 300px;\n min-width: 200px;\n min-height: 300px;\n}\n\n.duplicate-monomers-virtual-view {\n width: 100% !important;\n overflow-x: clip;\n overflow-y: auto;\n}\n\n.monomer-manager-form-tab-control input.d4-invalid {\n background: #ff000030;\n}\n\n.monomer-lib-controls-form .ui-input-root {\n flex-wrap: nowrap !important;\n}"],sourceRoot:""}]);const a=r},6369:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var i=n(1354),o=n.n(i),s=n(6314),r=n.n(s)()(o());r.push([e.id,".kalign-version {\n margin-bottom: 0;\n text-align: end;\n font-size: 12px;\n opacity: 0.8;\n}\nbutton.msa-params-button.ui-btn {\n justify-content: end;\n}","",{version:3,sources:["webpack://./css/msa.css"],names:[],mappings:"AAAA;IACI,gBAAgB;IAChB,eAAe;IACf,eAAe;IACf,YAAY;AAChB;AACA;IACI,oBAAoB;AACxB",sourcesContent:[".kalign-version {\n margin-bottom: 0;\n text-align: end;\n font-size: 12px;\n opacity: 0.8;\n}\nbutton.msa-params-button.ui-btn {\n justify-content: end;\n}"],sourceRoot:""}]);const a=r},7939:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var i=n(1354),o=n.n(i),s=n(6314),r=n.n(s)()(o());r.push([e.id,".scatter_plot_link {\n right: 10px;\n}\n\n.cliffs_div {\n flex-grow: initial!important;\n justify-content: flex-end;\n flex-wrap: wrap;\n}\n\n.cliffs_grid {\n margin: 0!important;\n}\n\n.ml-dim-reduction-settings-input i.grok-icon.grok-font-icon-settings {\n font-size: 18px;\n position: absolute;\n height: 28px;\n}\n\n.ml-dim-reduction-settings-input i.grok-icon.grok-font-icon-settings:not(.ml-dim-reduction-column-editor-input-root i) {\n left: -20px;\n}\n.dlg-dimensionality-reduction.ui-form, .dlg-markov-clustering.ui-form, .dlg-markov-clustering.ui-form .ui-form, .dlg-dimensionality-reduction.ui-form .ui-form {\n max-width: unset;\n}\n\n.ml-dim-reduction-column-editor-input-root label {\n display: none !important;\n}\n\n.dim-reduction-dialog-form > .ui-input-root, .dim-reduction-dialog-form > div > .ui-input-root {\n margin-left: 10px;\n}\n\n.ml-dim-reduction-column-editor-input-root input, .ml-dim-reduction-column-editor-input-root select {\n margin-left: 20px !important;\n}\n\nh3.ml-dim-reduction-column-editor-input-root {\n margin: 0 !important;\n}\n\n.ml-dim-reduction-column-editor-root, .ml-dim-reduction-column-editor-header-root {\n display: flex;\n flex-direction: row;\n align-items: center;\n margin-bottom: 10px !important;\n width: 700px !important;\n}\n\n.ml-dim-reduction-column-editor-column-title {\n text-overflow: ellipsis;\n overflow: hidden;\n}\n\n.ml-dim-reduction-column-editor-header-root > h1:not(:first-child) {\n margin-left: 20px !important;\n}\n\n.ml-dim-reduction-column-editor-table-root .header > td:not(:first-child) {\n padding-left: 32px;\n}","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/ml/css/styles.css"],names:[],mappings:"AAAA;IACI,WAAW;AACf;;AAEA;IACI,4BAA4B;IAC5B,yBAAyB;IACzB,eAAe;AACnB;;AAEA;GACG,mBAAmB;AACtB;;AAEA;IACI,eAAe;IACf,kBAAkB;IAClB,YAAY;AAChB;;AAEA;IACI,WAAW;AACf;AACA;IACI,gBAAgB;AACpB;;AAEA;IACI,wBAAwB;AAC5B;;AAEA;IACI,iBAAiB;AACrB;;AAEA;IACI,4BAA4B;AAChC;;AAEA;IACI,oBAAoB;AACxB;;AAEA;IACI,aAAa;IACb,mBAAmB;IACnB,mBAAmB;IACnB,8BAA8B;IAC9B,uBAAuB;AAC3B;;AAEA;IACI,uBAAuB;IACvB,gBAAgB;AACpB;;AAEA;IACI,4BAA4B;AAChC;;AAEA;IACI,kBAAkB;AACtB",sourcesContent:[".scatter_plot_link {\n right: 10px;\n}\n\n.cliffs_div {\n flex-grow: initial!important;\n justify-content: flex-end;\n flex-wrap: wrap;\n}\n\n.cliffs_grid {\n margin: 0!important;\n}\n\n.ml-dim-reduction-settings-input i.grok-icon.grok-font-icon-settings {\n font-size: 18px;\n position: absolute;\n height: 28px;\n}\n\n.ml-dim-reduction-settings-input i.grok-icon.grok-font-icon-settings:not(.ml-dim-reduction-column-editor-input-root i) {\n left: -20px;\n}\n.dlg-dimensionality-reduction.ui-form, .dlg-markov-clustering.ui-form, .dlg-markov-clustering.ui-form .ui-form, .dlg-dimensionality-reduction.ui-form .ui-form {\n max-width: unset;\n}\n\n.ml-dim-reduction-column-editor-input-root label {\n display: none !important;\n}\n\n.dim-reduction-dialog-form > .ui-input-root, .dim-reduction-dialog-form > div > .ui-input-root {\n margin-left: 10px;\n}\n\n.ml-dim-reduction-column-editor-input-root input, .ml-dim-reduction-column-editor-input-root select {\n margin-left: 20px !important;\n}\n\nh3.ml-dim-reduction-column-editor-input-root {\n margin: 0 !important;\n}\n\n.ml-dim-reduction-column-editor-root, .ml-dim-reduction-column-editor-header-root {\n display: flex;\n flex-direction: row;\n align-items: center;\n margin-bottom: 10px !important;\n width: 700px !important;\n}\n\n.ml-dim-reduction-column-editor-column-title {\n text-overflow: ellipsis;\n overflow: hidden;\n}\n\n.ml-dim-reduction-column-editor-header-root > h1:not(:first-child) {\n margin-left: 20px !important;\n}\n\n.ml-dim-reduction-column-editor-table-root .header > td:not(:first-child) {\n padding-left: 32px;\n}"],sourceRoot:""}]);const a=r},3017:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var i=n(1354),o=n.n(i),s=n(6314),r=n.n(s)()(o());r.push([e.id,".monomer-lib-controls-form {\n margin-left: auto;\n margin-right: auto;\n display: flex;\n flex-direction: column;\n align-items: center;\n min-width: 220px;\n width: 100%;\n\n}\n","",{version:3,sources:["webpack://./src/utils/monomer-lib/library-file-manager/style.css"],names:[],mappings:"AAAA;EACE,iBAAiB;EACjB,kBAAkB;EAClB,aAAa;EACb,sBAAsB;EACtB,mBAAmB;EACnB,gBAAgB;EAChB,WAAW;;AAEb",sourcesContent:[".monomer-lib-controls-form {\n margin-left: auto;\n margin-right: auto;\n display: flex;\n flex-direction: column;\n align-items: center;\n min-width: 220px;\n width: 100%;\n\n}\n"],sourceRoot:""}]);const a=r},6314: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,s){"string"==typeof e&&(e=[[null,e,void 0]]);var r={};if(i)for(var a=0;a<this.length;a++){var l=this[a][0];null!=l&&(r[l]=!0)}for(var c=0;c<e.length;c++){var u=[].concat(e[c]);i&&r[u[0]]||(void 0!==s&&(void 0===u[5]||(u[1]="@layer".concat(u[5].length>0?" ".concat(u[5]):""," {").concat(u[1],"}")),u[5]=s),n&&(u[2]?(u[1]="@media ".concat(u[2]," {").concat(u[1],"}"),u[2]=n):u[2]=n),o&&(u[4]?(u[1]="@supports (".concat(u[4],") {").concat(u[1],"}"),u[4]=o):u[4]="".concat(o)),t.push(u))}},t}},1354: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),s="/*# ".concat(o," */");return[t].concat([s]).join("\n")}return[t].join("\n")}},2017:e=>{"use strict";e.exports=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){if(t.constructor!==n.constructor)return!1;var i,o,s;if(Array.isArray(t)){if((i=t.length)!=n.length)return!1;for(o=i;0!=o--;)if(!e(t[o],n[o]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if((i=(s=Object.keys(t)).length)!==Object.keys(n).length)return!1;for(o=i;0!=o--;)if(!Object.prototype.hasOwnProperty.call(n,s[o]))return!1;for(o=i;0!=o--;){var r=s[o];if(!e(t[r],n[r]))return!1}return!0}return t!=t&&n!=n}},9982:function(e,t,n){var i;!function(){var t={};!function(e){"use strict";e.__esModule=!0,e.digestLength=32,e.blockSize=64;var t=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function n(e,n,i,o,s){for(var r,a,l,c,u,h,d,p,m,g,f,y,b;s>=64;){for(r=n[0],a=n[1],l=n[2],c=n[3],u=n[4],h=n[5],d=n[6],p=n[7],g=0;g<16;g++)f=o+4*g,e[g]=(255&i[f])<<24|(255&i[f+1])<<16|(255&i[f+2])<<8|255&i[f+3];for(g=16;g<64;g++)y=((m=e[g-2])>>>17|m<<15)^(m>>>19|m<<13)^m>>>10,b=((m=e[g-15])>>>7|m<<25)^(m>>>18|m<<14)^m>>>3,e[g]=(y+e[g-7]|0)+(b+e[g-16]|0);for(g=0;g<64;g++)y=(((u>>>6|u<<26)^(u>>>11|u<<21)^(u>>>25|u<<7))+(u&h^~u&d)|0)+(p+(t[g]+e[g]|0)|0)|0,b=((r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10))+(r&a^r&l^a&l)|0,p=d,d=h,h=u,u=c+y|0,c=l,l=a,a=r,r=y+b|0;n[0]+=r,n[1]+=a,n[2]+=l,n[3]+=c,n[4]+=u,n[5]+=h,n[6]+=d,n[7]+=p,o+=64,s-=64}return o}var i=function(){function t(){this.digestLength=e.digestLength,this.blockSize=e.blockSize,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this.reset()}return t.prototype.reset=function(){return this.state[0]=1779033703,this.state[1]=3144134277,this.state[2]=1013904242,this.state[3]=2773480762,this.state[4]=1359893119,this.state[5]=2600822924,this.state[6]=528734635,this.state[7]=1541459225,this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this},t.prototype.clean=function(){for(var e=0;e<this.buffer.length;e++)this.buffer[e]=0;for(e=0;e<this.temp.length;e++)this.temp[e]=0;this.reset()},t.prototype.update=function(e,t){if(void 0===t&&(t=e.length),this.finished)throw new Error("SHA256: can't update because hash was finished.");var i=0;if(this.bytesHashed+=t,this.bufferLength>0){for(;this.bufferLength<64&&t>0;)this.buffer[this.bufferLength++]=e[i++],t--;64===this.bufferLength&&(n(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(t>=64&&(i=n(this.temp,this.state,e,i,t),t%=64);t>0;)this.buffer[this.bufferLength++]=e[i++],t--;return this},t.prototype.finish=function(e){if(!this.finished){var t=this.bytesHashed,i=this.bufferLength,o=t/536870912|0,s=t<<3,r=t%64<56?64:128;this.buffer[i]=128;for(var a=i+1;a<r-8;a++)this.buffer[a]=0;this.buffer[r-8]=o>>>24&255,this.buffer[r-7]=o>>>16&255,this.buffer[r-6]=o>>>8&255,this.buffer[r-5]=o>>>0&255,this.buffer[r-4]=s>>>24&255,this.buffer[r-3]=s>>>16&255,this.buffer[r-2]=s>>>8&255,this.buffer[r-1]=s>>>0&255,n(this.temp,this.state,this.buffer,0,r),this.finished=!0}for(a=0;a<8;a++)e[4*a+0]=this.state[a]>>>24&255,e[4*a+1]=this.state[a]>>>16&255,e[4*a+2]=this.state[a]>>>8&255,e[4*a+3]=this.state[a]>>>0&255;return this},t.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},t.prototype._saveState=function(e){for(var t=0;t<this.state.length;t++)e[t]=this.state[t]},t.prototype._restoreState=function(e,t){for(var n=0;n<this.state.length;n++)this.state[n]=e[n];this.bytesHashed=t,this.finished=!1,this.bufferLength=0},t}();e.Hash=i;var o=function(){function e(e){this.inner=new i,this.outer=new i,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var t=new Uint8Array(this.blockSize);if(e.length>this.blockSize)(new i).update(e).finish(t).clean();else for(var n=0;n<e.length;n++)t[n]=e[n];for(n=0;n<t.length;n++)t[n]^=54;for(this.inner.update(t),n=0;n<t.length;n++)t[n]^=106;for(this.outer.update(t),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate),n=0;n<t.length;n++)t[n]=0}return e.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},e.prototype.clean=function(){for(var e=0;e<this.istate.length;e++)this.ostate[e]=this.istate[e]=0;this.inner.clean(),this.outer.clean()},e.prototype.update=function(e){return this.inner.update(e),this},e.prototype.finish=function(e){return this.outer.finished?this.outer.finish(e):(this.inner.finish(e),this.outer.update(e,this.digestLength).finish(e)),this},e.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},e}();function s(e){var t=(new i).update(e),n=t.digest();return t.clean(),n}function r(e,t){var n=new o(e).update(t),i=n.digest();return n.clean(),i}function a(e,t,n,i){var o=i[0];if(0===o)throw new Error("hkdf: cannot expand more");t.reset(),o>1&&t.update(e),n&&t.update(n),t.update(i),t.finish(e),i[0]++}e.HMAC=o,e.hash=s,e.default=s,e.hmac=r;var l=new Uint8Array(e.digestLength);e.hkdf=function(e,t,n,i){void 0===t&&(t=l),void 0===i&&(i=32);for(var s=new Uint8Array([1]),c=r(t,e),u=new o(c),h=new Uint8Array(u.digestLength),d=h.length,p=new Uint8Array(i),m=0;m<i;m++)d===h.length&&(a(h,u,n,s),d=0),p[m]=h[d++];return u.clean(),h.fill(0),s.fill(0),p},e.pbkdf2=function(e,t,n,i){for(var s=new o(e),r=s.digestLength,a=new Uint8Array(4),l=new Uint8Array(r),c=new Uint8Array(r),u=new Uint8Array(i),h=0;h*r<i;h++){var d=h+1;a[0]=d>>>24&255,a[1]=d>>>16&255,a[2]=d>>>8&255,a[3]=d>>>0&255,s.reset(),s.update(t),s.update(a),s.finish(c);for(var p=0;p<r;p++)l[p]=c[p];for(p=2;p<=n;p++){s.reset(),s.update(c).finish(c);for(var m=0;m<r;m++)l[m]^=c[m]}for(p=0;p<r&&h*r+p<i;p++)u[h*r+p]=l[p]}for(h=0;h<r;h++)l[h]=c[h]=0;for(h=0;h<4;h++)a[h]=0;return s.clean(),u}}(t);var o=t.default;for(var s in t)o[s]=t[s];"object"==typeof e.exports?e.exports=o:void 0===(i=function(){return o}.call(t,n,t,e))||(e.exports=i)}()},2787:(e,t,n)=>{"use strict";n.d(t,{I:()=>o});const i=new Uint32Array(65536),o=(e,t)=>{if(e.length<t.length){const n=t;t=e,e=n}return 0===t.length?e.length:e.length<=32?((e,t)=>{const n=e.length,o=t.length,s=1<<n-1;let r=-1,a=0,l=n,c=n;for(;c--;)i[e.charCodeAt(c)]|=1<<c;for(c=0;c<o;c++){let e=i[t.charCodeAt(c)];const n=e|a;e|=(e&r)+r^r,a|=~(e|r),r&=e,a&s&&l++,r&s&&l--,a=a<<1|1,r=r<<1|~(n|a),a&=n}for(c=n;c--;)i[e.charCodeAt(c)]=0;return l})(e,t):((e,t)=>{const n=t.length,o=e.length,s=[],r=[],a=Math.ceil(n/32),l=Math.ceil(o/32);for(let e=0;e<a;e++)r[e]=-1,s[e]=0;let c=0;for(;c<l-1;c++){let a=0,l=-1;const u=32*c,h=Math.min(32,o)+u;for(let t=u;t<h;t++)i[e.charCodeAt(t)]|=1<<t;for(let e=0;e<n;e++){const n=i[t.charCodeAt(e)],o=r[e/32|0]>>>e&1,c=s[e/32|0]>>>e&1,u=n|a,h=((n|c)&l)+l^l|n|c;let d=a|~(h|l),p=l&h;d>>>31^o&&(r[e/32|0]^=1<<e),p>>>31^c&&(s[e/32|0]^=1<<e),d=d<<1|o,p=p<<1|c,l=p|~(u|d),a=d&u}for(let t=u;t<h;t++)i[e.charCodeAt(t)]=0}let u=0,h=-1;const d=32*c,p=Math.min(32,o-d)+d;for(let t=d;t<p;t++)i[e.charCodeAt(t)]|=1<<t;let m=o;for(let e=0;e<n;e++){const n=i[t.charCodeAt(e)],a=r[e/32|0]>>>e&1,l=s[e/32|0]>>>e&1,c=n|u,d=((n|l)&h)+h^h|n|l;let p=u|~(d|h),g=h&d;m+=p>>>o-1&1,m-=g>>>o-1&1,p>>>31^a&&(r[e/32|0]^=1<<e),g>>>31^l&&(s[e/32|0]^=1<<e),p=p<<1|a,g=g<<1|l,h=g|~(c|p),u=p&c}for(let t=d;t<p;t++)i[e.charCodeAt(t)]=0;return m})(e,t)}},9937:e=>{e.exports={linLogMode:!1,outboundAttractionDistribution:!1,adjustSizes:!1,edgeWeightInfluence:1,scalingRatio:1,strongGravityMode:!1,gravity:1,slowDown:1,barnesHutOptimize:!1,barnesHutTheta:.5}},1782:(e,t)=>{t.assign=function(e){e=e||{};var t,n,i,o=Array.prototype.slice.call(arguments).slice(1);for(t=0,i=o.length;t<i;t++)if(o[t])for(n in o[t])e[n]=o[t][n];return e},t.validateSettings=function(e){return"linLogMode"in e&&"boolean"!=typeof e.linLogMode?{message:"the `linLogMode` setting should be a boolean."}:"outboundAttractionDistribution"in e&&"boolean"!=typeof e.outboundAttractionDistribution?{message:"the `outboundAttractionDistribution` setting should be a boolean."}:"adjustSizes"in e&&"boolean"!=typeof e.adjustSizes?{message:"the `adjustSizes` setting should be a boolean."}:"edgeWeightInfluence"in e&&"number"!=typeof e.edgeWeightInfluence?{message:"the `edgeWeightInfluence` setting should be a number."}:!("scalingRatio"in e)||"number"==typeof e.scalingRatio&&e.scalingRatio>=0?"strongGravityMode"in e&&"boolean"!=typeof e.strongGravityMode?{message:"the `strongGravityMode` setting should be a boolean."}:!("gravity"in e)||"number"==typeof e.gravity&&e.gravity>=0?"slowDown"in e&&!("number"==typeof e.slowDown||e.slowDown>=0)?{message:"the `slowDown` setting should be a number >= 0."}:"barnesHutOptimize"in e&&"boolean"!=typeof e.barnesHutOptimize?{message:"the `barnesHutOptimize` setting should be a boolean."}:!("barnesHutTheta"in e)||"number"==typeof e.barnesHutTheta&&e.barnesHutTheta>=0?null:{message:"the `barnesHutTheta` setting should be a number >= 0."}:{message:"the `gravity` setting should be a number >= 0."}:{message:"the `scalingRatio` setting should be a number >= 0."}},t.graphToByteArrays=function(e,t){var n,i=e.order,o=e.size,s={},r=new Float32Array(10*i),a=new Float32Array(3*o);return n=0,e.forEachNode((function(e,t){s[e]=n,r[n]=t.x,r[n+1]=t.y,r[n+2]=0,r[n+3]=0,r[n+4]=0,r[n+5]=0,r[n+6]=1,r[n+7]=1,r[n+8]=t.size||1,r[n+9]=t.fixed?1:0,n+=10})),n=0,e.forEachEdge((function(e,i,o,l,c,u,h){var d=s[o],p=s[l],m=t(e,i,o,l,c,u,h);r[d+6]+=m,r[p+6]+=m,a[n]=d,a[n+1]=p,a[n+2]=m,n+=3})),{nodes:r,edges:a}},t.assignLayoutChanges=function(e,t,n){var i=0;e.updateEachNodeAttributes((function(e,o){return o.x=t[i],o.y=t[i+1],i+=10,n?n(e,o):o}))},t.readGraphPositions=function(e,t){var n=0;e.forEachNode((function(e,i){t[n]=i.x,t[n+1]=i.y,n+=10}))},t.collectLayoutChanges=function(e,t,n){for(var i=e.nodes(),o={},s=0,r=0,a=t.length;s<a;s+=10){if(n){var l=Object.assign({},e.getNodeAttributes(i[r]));l.x=t[s],l.y=t[s+1],l=n(i[r],l),o[i[r]]={x:l.x,y:l.y}}else o[i[r]]={x:t[s],y:t[s+1]};r++}return o},t.createWorker=function(e){var t=window.URL||window.webkitURL,n=e.toString(),i=t.createObjectURL(new Blob(["("+n+").call(this);"],{type:"text/javascript"})),o=new Worker(i);return t.revokeObjectURL(i),o}},8903:(e,t,n)=>{var i=n(1736),o=n(8153).Fd,s=n(2561),r=n(1782),a=n(9937);function l(e,t,n){if(!i(t))throw new Error("graphology-layout-forceatlas2: the given graph is not a valid graphology instance.");"number"==typeof n&&(n={iterations:n});var l=n.iterations;if("number"!=typeof l)throw new Error("graphology-layout-forceatlas2: invalid number of iterations.");if(l<=0)throw new Error("graphology-layout-forceatlas2: you should provide a positive number of iterations.");var c=o("getEdgeWeight"in n?n.getEdgeWeight:"weight").fromEntry,u="function"==typeof n.outputReducer?n.outputReducer:null,h=r.assign({},a,n.settings),d=r.validateSettings(h);if(d)throw new Error("graphology-layout-forceatlas2: "+d.message);var p,m=r.graphToByteArrays(t,c);for(p=0;p<l;p++)s(h,m.nodes,m.edges);if(!e)return r.collectLayoutChanges(t,m.nodes);r.assignLayoutChanges(t,m.nodes,u)}var c=l.bind(null,!1);c.assign=l.bind(null,!0),c.inferSettings=function(e){var t="number"==typeof e?e:e.order;return{barnesHutOptimize:t>2e3,strongGravityMode:!0,gravity:.05,scalingRatio:10,slowDown:1+Math.log(t)}},e.exports=c},2561:e=>{var t=10;e.exports=function(e,n,i){var o,s,r,a,l,c,u,h,d,p,m,g,f,y,b,w,v,A,C,T,S,E,M,x=n.length,L=i.length,_=e.adjustSizes,I=e.barnesHutTheta*e.barnesHutTheta,P=[];for(r=0;r<x;r+=t)n[r+4]=n[r+2],n[r+5]=n[r+3],n[r+2]=0,n[r+3]=0;if(e.outboundAttractionDistribution){for(m=0,r=0;r<x;r+=t)m+=n[r+6];m/=x/t}if(e.barnesHutOptimize){var N,R,$,O=1/0,H=-1/0,k=1/0,F=-1/0;for(r=0;r<x;r+=t)O=Math.min(O,n[r+0]),H=Math.max(H,n[r+0]),k=Math.min(k,n[r+1]),F=Math.max(F,n[r+1]);var D=H-O,G=F-k;for(D>G?F=(k-=(D-G)/2)+D:H=(O-=(G-D)/2)+G,P[0]=-1,P[1]=(O+H)/2,P[2]=(k+F)/2,P[3]=Math.max(H-O,F-k),P[4]=-1,P[5]=-1,P[6]=0,P[7]=0,P[8]=0,o=1,r=0;r<x;r+=t)for(s=0,$=3;;){if(!(P[s+5]>=0)){if(P[s+0]<0){P[s+0]=r;break}if(P[s+5]=9*o,h=P[s+3]/2,P[(d=P[s+5])+0]=-1,P[d+1]=P[s+1]-h,P[d+2]=P[s+2]-h,P[d+3]=h,P[d+4]=d+9,P[d+5]=-1,P[d+6]=0,P[d+7]=0,P[d+8]=0,P[(d+=9)+0]=-1,P[d+1]=P[s+1]-h,P[d+2]=P[s+2]+h,P[d+3]=h,P[d+4]=d+9,P[d+5]=-1,P[d+6]=0,P[d+7]=0,P[d+8]=0,P[(d+=9)+0]=-1,P[d+1]=P[s+1]+h,P[d+2]=P[s+2]-h,P[d+3]=h,P[d+4]=d+9,P[d+5]=-1,P[d+6]=0,P[d+7]=0,P[d+8]=0,P[(d+=9)+0]=-1,P[d+1]=P[s+1]+h,P[d+2]=P[s+2]+h,P[d+3]=h,P[d+4]=P[s+4],P[d+5]=-1,P[d+6]=0,P[d+7]=0,P[d+8]=0,o+=4,N=n[P[s+0]+0]<P[s+1]?n[P[s+0]+1]<P[s+2]?P[s+5]:P[s+5]+9:n[P[s+0]+1]<P[s+2]?P[s+5]+18:P[s+5]+27,P[s+6]=n[P[s+0]+6],P[s+7]=n[P[s+0]+0],P[s+8]=n[P[s+0]+1],P[N+0]=P[s+0],P[s+0]=-1,N===(R=n[r+0]<P[s+1]?n[r+1]<P[s+2]?P[s+5]:P[s+5]+9:n[r+1]<P[s+2]?P[s+5]+18:P[s+5]+27)){if($--){s=N;continue}$=3;break}P[R+0]=r;break}N=n[r+0]<P[s+1]?n[r+1]<P[s+2]?P[s+5]:P[s+5]+9:n[r+1]<P[s+2]?P[s+5]+18:P[s+5]+27,P[s+7]=(P[s+7]*P[s+6]+n[r+0]*n[r+6])/(P[s+6]+n[r+6]),P[s+8]=(P[s+8]*P[s+6]+n[r+1]*n[r+6])/(P[s+6]+n[r+6]),P[s+6]+=n[r+6],s=N}}if(e.barnesHutOptimize){for(g=e.scalingRatio,r=0;r<x;r+=t)for(s=0;;)if(P[s+5]>=0){if(w=Math.pow(n[r+0]-P[s+7],2)+Math.pow(n[r+1]-P[s+8],2),4*(p=P[s+3])*p/w<I){if(f=n[r+0]-P[s+7],y=n[r+1]-P[s+8],!0===_?w>0?(v=g*n[r+6]*P[s+6]/w,n[r+2]+=f*v,n[r+3]+=y*v):w<0&&(v=-g*n[r+6]*P[s+6]/Math.sqrt(w),n[r+2]+=f*v,n[r+3]+=y*v):w>0&&(v=g*n[r+6]*P[s+6]/w,n[r+2]+=f*v,n[r+3]+=y*v),(s=P[s+4])<0)break;continue}s=P[s+5]}else if((c=P[s+0])>=0&&c!==r&&(w=(f=n[r+0]-n[c+0])*f+(y=n[r+1]-n[c+1])*y,!0===_?w>0?(v=g*n[r+6]*n[c+6]/w,n[r+2]+=f*v,n[r+3]+=y*v):w<0&&(v=-g*n[r+6]*n[c+6]/Math.sqrt(w),n[r+2]+=f*v,n[r+3]+=y*v):w>0&&(v=g*n[r+6]*n[c+6]/w,n[r+2]+=f*v,n[r+3]+=y*v)),(s=P[s+4])<0)break}else for(g=e.scalingRatio,a=0;a<x;a+=t)for(l=0;l<a;l+=t)f=n[a+0]-n[l+0],y=n[a+1]-n[l+1],!0===_?(w=Math.sqrt(f*f+y*y)-n[a+8]-n[l+8])>0?(v=g*n[a+6]*n[l+6]/w/w,n[a+2]+=f*v,n[a+3]+=y*v,n[l+2]-=f*v,n[l+3]-=y*v):w<0&&(v=100*g*n[a+6]*n[l+6],n[a+2]+=f*v,n[a+3]+=y*v,n[l+2]-=f*v,n[l+3]-=y*v):(w=Math.sqrt(f*f+y*y))>0&&(v=g*n[a+6]*n[l+6]/w/w,n[a+2]+=f*v,n[a+3]+=y*v,n[l+2]-=f*v,n[l+3]-=y*v);for(d=e.gravity/e.scalingRatio,g=e.scalingRatio,r=0;r<x;r+=t)v=0,f=n[r+0],y=n[r+1],w=Math.sqrt(Math.pow(f,2)+Math.pow(y,2)),e.strongGravityMode?w>0&&(v=g*n[r+6]*d):w>0&&(v=g*n[r+6]*d/w),n[r+2]-=f*v,n[r+3]-=y*v;for(g=1*(e.outboundAttractionDistribution?m:1),u=0;u<L;u+=3)a=i[u+0],l=i[u+1],h=i[u+2],b=Math.pow(h,e.edgeWeightInfluence),f=n[a+0]-n[l+0],y=n[a+1]-n[l+1],!0===_?(w=Math.sqrt(f*f+y*y)-n[a+8]-n[l+8],e.linLogMode?e.outboundAttractionDistribution?w>0&&(v=-g*b*Math.log(1+w)/w/n[a+6]):w>0&&(v=-g*b*Math.log(1+w)/w):e.outboundAttractionDistribution?w>0&&(v=-g*b/n[a+6]):w>0&&(v=-g*b)):(w=Math.sqrt(Math.pow(f,2)+Math.pow(y,2)),e.linLogMode?e.outboundAttractionDistribution?w>0&&(v=-g*b*Math.log(1+w)/w/n[a+6]):w>0&&(v=-g*b*Math.log(1+w)/w):e.outboundAttractionDistribution?(w=1,v=-g*b/n[a+6]):(w=1,v=-g*b)),w>0&&(n[a+2]+=f*v,n[a+3]+=y*v,n[l+2]-=f*v,n[l+3]-=y*v);if(!0===_)for(r=0;r<x;r+=t)1!==n[r+9]&&((A=Math.sqrt(Math.pow(n[r+2],2)+Math.pow(n[r+3],2)))>10&&(n[r+2]=10*n[r+2]/A,n[r+3]=10*n[r+3]/A),C=n[r+6]*Math.sqrt((n[r+4]-n[r+2])*(n[r+4]-n[r+2])+(n[r+5]-n[r+3])*(n[r+5]-n[r+3])),T=Math.sqrt((n[r+4]+n[r+2])*(n[r+4]+n[r+2])+(n[r+5]+n[r+3])*(n[r+5]+n[r+3]))/2,S=.1*Math.log(1+T)/(1+Math.sqrt(C)),E=n[r+0]+n[r+2]*(S/e.slowDown),n[r+0]=E,M=n[r+1]+n[r+3]*(S/e.slowDown),n[r+1]=M);else for(r=0;r<x;r+=t)1!==n[r+9]&&(C=n[r+6]*Math.sqrt((n[r+4]-n[r+2])*(n[r+4]-n[r+2])+(n[r+5]-n[r+3])*(n[r+5]-n[r+3])),T=Math.sqrt((n[r+4]+n[r+2])*(n[r+4]+n[r+2])+(n[r+5]+n[r+3])*(n[r+5]+n[r+3]))/2,S=n[r+7]*Math.log(1+T)/(1+Math.sqrt(C)),n[r+7]=Math.min(1,Math.sqrt(S*(Math.pow(n[r+2],2)+Math.pow(n[r+3],2))/(1+Math.sqrt(C)))),E=n[r+0]+n[r+2]*(S/e.slowDown),n[r+0]=E,M=n[r+1]+n[r+3]*(S/e.slowDown),n[r+1]=M);return{}}},8153:(e,t)=>{function n(e){return"number"!=typeof e||isNaN(e)?1:e}t.Fd=function(e){return function(e,t){var n={},i=function(e){return void 0===e?t:e};"function"==typeof t&&(i=t);var o=function(t){return i(t[e])},s=function(){return i(void 0)};return"string"==typeof e?(n.fromAttributes=o,n.fromGraph=function(e,t){return o(e.getEdgeAttributes(t))},n.fromEntry=function(e,t){return o(t)},n.fromPartialEntry=n.fromEntry,n.fromMinimalEntry=n.fromEntry):"function"==typeof e?(n.fromAttributes=function(){throw new Error("graphology-utils/getters/createEdgeValueGetter: irrelevant usage.")},n.fromGraph=function(t,n){var o=t.extremities(n);return i(e(n,t.getEdgeAttributes(n),o[0],o[1],t.getNodeAttributes(o[0]),t.getNodeAttributes(o[1]),t.isUndirected(n)))},n.fromEntry=function(t,n,o,s,r,a,l){return i(e(t,n,o,s,r,a,l))},n.fromPartialEntry=function(t,n,o,s){return i(e(t,n,o,s))},n.fromMinimalEntry=function(t,n){return i(e(t,n))}):(n.fromAttributes=s,n.fromGraph=s,n.fromEntry=s,n.fromMinimalEntry=s),n}(e,n)}},1736:e=>{e.exports=function(e){return null!==e&&"object"==typeof e&&"function"==typeof e.addUndirectedEdgeWithKey&&"function"==typeof e.dropNode&&"boolean"==typeof e.multi}},934:function(e){e.exports=function(){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,i(e,t)}function n(e){return n=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},n(e)}function i(e,t){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},i(e,t)}function o(e,t,n){return o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}()?Reflect.construct.bind():function(e,t,n){var o=[null];o.push.apply(o,t);var s=new(Function.bind.apply(e,o));return n&&i(s,n.prototype),s},o.apply(null,arguments)}function s(e){var t="function"==typeof Map?new Map:void 0;return s=function(e){if(null===e||(s=e,-1===Function.toString.call(s).indexOf("[native code]")))return e;var s;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return o(e,arguments,n(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),i(r,e)},s(e)}function r(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var a=function(){for(var e=arguments[0],t=1,n=arguments.length;t<n;t++)if(arguments[t])for(var i in arguments[t])e[i]=arguments[t][i];return e};function l(e,t,n,i){var o=e._nodes.get(t),s=null;return o?s="mixed"===i?o.out&&o.out[n]||o.undirected&&o.undirected[n]:"directed"===i?o.out&&o.out[n]:o.undirected&&o.undirected[n]:s}function c(t){return"object"===e(t)&&null!==t}function u(e){var t;for(t in e)return!1;return!0}function h(e,t,n){Object.defineProperty(e,t,{enumerable:!1,configurable:!1,writable:!0,value:n})}function d(e,t,n){var i={enumerable:!0,configurable:!0};"function"==typeof n?i.get=n:(i.value=n,i.writable=!1),Object.defineProperty(e,t,i)}function p(e){return!(!c(e)||e.attributes&&!Array.isArray(e.attributes))}"function"==typeof Object.assign&&(a=Object.assign);var m,g={exports:{}},f="object"==typeof Reflect?Reflect:null,y=f&&"function"==typeof f.apply?f.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};m=f&&"function"==typeof f.ownKeys?f.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var b=Number.isNaN||function(e){return e!=e};function w(){w.init.call(this)}g.exports=w,g.exports.once=function(e,t){return new Promise((function(n,i){function o(n){e.removeListener(t,s),i(n)}function s(){"function"==typeof e.removeListener&&e.removeListener("error",o),n([].slice.call(arguments))}_(e,t,s,{once:!0}),"error"!==t&&function(e,t){"function"==typeof e.on&&_(e,"error",t,{once:!0})}(e,o)}))},w.EventEmitter=w,w.prototype._events=void 0,w.prototype._eventsCount=0,w.prototype._maxListeners=void 0;var v=10;function A(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function C(e){return void 0===e._maxListeners?w.defaultMaxListeners:e._maxListeners}function T(e,t,n,i){var o,s,r,a;if(A(n),void 0===(s=e._events)?(s=e._events=Object.create(null),e._eventsCount=0):(void 0!==s.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),s=e._events),r=s[t]),void 0===r)r=s[t]=n,++e._eventsCount;else if("function"==typeof r?r=s[t]=i?[n,r]:[r,n]:i?r.unshift(n):r.push(n),(o=C(e))>0&&r.length>o&&!r.warned){r.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+r.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=r.length,a=l,console&&console.warn&&console.warn(a)}return e}function S(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function E(e,t,n){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},o=S.bind(i);return o.listener=n,i.wrapFn=o,o}function M(e,t,n){var i=e._events;if(void 0===i)return[];var o=i[t];return void 0===o?[]:"function"==typeof o?n?[o.listener||o]:[o]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(o):L(o,o.length)}function x(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function L(e,t){for(var n=new Array(t),i=0;i<t;++i)n[i]=e[i];return n}function _(e,t,n,i){if("function"==typeof e.on)i.once?e.once(t,n):e.on(t,n);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function o(s){i.once&&e.removeEventListener(t,o),n(s)}))}}function I(e){if("function"!=typeof e)throw new Error("obliterator/iterator: expecting a function!");this.next=e}Object.defineProperty(w,"defaultMaxListeners",{enumerable:!0,get:function(){return v},set:function(e){if("number"!=typeof e||e<0||b(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");v=e}}),w.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},w.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||b(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},w.prototype.getMaxListeners=function(){return C(this)},w.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var i="error"===e,o=this._events;if(void 0!==o)i=i&&void 0===o.error;else if(!i)return!1;if(i){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var r=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw r.context=s,r}var a=o[e];if(void 0===a)return!1;if("function"==typeof a)y(a,this,t);else{var l=a.length,c=L(a,l);for(n=0;n<l;++n)y(c[n],this,t)}return!0},w.prototype.addListener=function(e,t){return T(this,e,t,!1)},w.prototype.on=w.prototype.addListener,w.prototype.prependListener=function(e,t){return T(this,e,t,!0)},w.prototype.once=function(e,t){return A(t),this.on(e,E(this,e,t)),this},w.prototype.prependOnceListener=function(e,t){return A(t),this.prependListener(e,E(this,e,t)),this},w.prototype.removeListener=function(e,t){var n,i,o,s,r;if(A(t),void 0===(i=this._events))return this;if(void 0===(n=i[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(o=-1,s=n.length-1;s>=0;s--)if(n[s]===t||n[s].listener===t){r=n[s].listener,o=s;break}if(o<0)return this;0===o?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,o),1===n.length&&(i[e]=n[0]),void 0!==i.removeListener&&this.emit("removeListener",e,r||t)}return this},w.prototype.off=w.prototype.removeListener,w.prototype.removeAllListeners=function(e){var t,n,i;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var o,s=Object.keys(n);for(i=0;i<s.length;++i)"removeListener"!==(o=s[i])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this},w.prototype.listeners=function(e){return M(this,e,!0)},w.prototype.rawListeners=function(e){return M(this,e,!1)},w.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):x.call(e,t)},w.prototype.listenerCount=x,w.prototype.eventNames=function(){return this._eventsCount>0?m(this._events):[]},"undefined"!=typeof Symbol&&(I.prototype[Symbol.iterator]=function(){return this}),I.of=function(){var e=arguments,t=e.length,n=0;return new I((function(){return n>=t?{done:!0}:{done:!1,value:e[n++]}}))},I.empty=function(){return new I((function(){return{done:!0}}))},I.fromSequence=function(e){var t=0,n=e.length;return new I((function(){return t>=n?{done:!0}:{done:!1,value:e[t++]}}))},I.is=function(e){return e instanceof I||"object"==typeof e&&null!==e&&"function"==typeof e.next};var P=I,N={};N.ARRAY_BUFFER_SUPPORT="undefined"!=typeof ArrayBuffer,N.SYMBOL_SUPPORT="undefined"!=typeof Symbol;var R=P,$=N,O=$.ARRAY_BUFFER_SUPPORT,H=$.SYMBOL_SUPPORT,k=function(e){var t=function(e){return"string"==typeof e||Array.isArray(e)||O&&ArrayBuffer.isView(e)?R.fromSequence(e):"object"!=typeof e||null===e?null:H&&"function"==typeof e[Symbol.iterator]?e[Symbol.iterator]():"function"==typeof e.next?e:null}(e);if(!t)throw new Error("obliterator: target is not iterable nor a valid iterator.");return t},F=k,D=function(e,t){for(var n,i=arguments.length>1?t:1/0,o=i!==1/0?new Array(i):[],s=0,r=F(e);;){if(s===i)return o;if((n=r.next()).done)return s!==t&&(o.length=s),o;o[s++]=n.value}},G=function(e){function n(t){var n;return(n=e.call(this)||this).name="GraphError",n.message=t,n}return t(n,e),n}(s(Error)),B=function(e){function n(t){var i;return(i=e.call(this,t)||this).name="InvalidArgumentsGraphError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(r(i),n.prototype.constructor),i}return t(n,e),n}(G),V=function(e){function n(t){var i;return(i=e.call(this,t)||this).name="NotFoundGraphError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(r(i),n.prototype.constructor),i}return t(n,e),n}(G),U=function(e){function n(t){var i;return(i=e.call(this,t)||this).name="UsageGraphError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(r(i),n.prototype.constructor),i}return t(n,e),n}(G);function W(e,t){this.key=e,this.attributes=t,this.clear()}function q(e,t){this.key=e,this.attributes=t,this.clear()}function Y(e,t){this.key=e,this.attributes=t,this.clear()}function j(e,t,n,i,o){this.key=t,this.attributes=o,this.undirected=e,this.source=n,this.target=i}function K(e,t,n,i,o,s,r){var a,l,c,u;if(i=""+i,0===n){if(!(a=e._nodes.get(i)))throw new V("Graph.".concat(t,': could not find the "').concat(i,'" node in the graph.'));c=o,u=s}else if(3===n){if(o=""+o,!(l=e._edges.get(o)))throw new V("Graph.".concat(t,': could not find the "').concat(o,'" edge in the graph.'));var h=l.source.key,d=l.target.key;if(i===h)a=l.target;else{if(i!==d)throw new V("Graph.".concat(t,': the "').concat(i,'" node is not attached to the "').concat(o,'" edge (').concat(h,", ").concat(d,")."));a=l.source}c=s,u=r}else{if(!(l=e._edges.get(i)))throw new V("Graph.".concat(t,': could not find the "').concat(i,'" edge in the graph.'));a=1===n?l.source:l.target,c=o,u=s}return[a,c,u]}W.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}},q.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}},Y.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}},j.prototype.attach=function(){var e="out",t="in";this.undirected&&(e=t="undirected");var n=this.source.key,i=this.target.key;this.source[e][i]=this,this.undirected&&n===i||(this.target[t][n]=this)},j.prototype.attachMulti=function(){var e="out",t="in",n=this.source.key,i=this.target.key;this.undirected&&(e=t="undirected");var o=this.source[e],s=o[i];if(void 0===s)return o[i]=this,void(this.undirected&&n===i||(this.target[t][n]=this));s.previous=this,this.next=s,o[i]=this,this.target[t][n]=this},j.prototype.detach=function(){var e=this.source.key,t=this.target.key,n="out",i="in";this.undirected&&(n=i="undirected"),delete this.source[n][t],delete this.target[i][e]},j.prototype.detachMulti=function(){var e=this.source.key,t=this.target.key,n="out",i="in";this.undirected&&(n=i="undirected"),void 0===this.previous?void 0===this.next?(delete this.source[n][t],delete this.target[i][e]):(this.next.previous=void 0,this.source[n][t]=this.next,this.target[i][e]=this.next):(this.previous.next=this.next,void 0!==this.next&&(this.next.previous=this.previous))};var z=[{name:function(e){return"get".concat(e,"Attribute")},attacher:function(e,t,n){e.prototype[t]=function(e,i,o){var s=K(this,t,n,e,i,o),r=s[0],a=s[1];return r.attributes[a]}}},{name:function(e){return"get".concat(e,"Attributes")},attacher:function(e,t,n){e.prototype[t]=function(e,i){return K(this,t,n,e,i)[0].attributes}}},{name:function(e){return"has".concat(e,"Attribute")},attacher:function(e,t,n){e.prototype[t]=function(e,i,o){var s=K(this,t,n,e,i,o),r=s[0],a=s[1];return r.attributes.hasOwnProperty(a)}}},{name:function(e){return"set".concat(e,"Attribute")},attacher:function(e,t,n){e.prototype[t]=function(e,i,o,s){var r=K(this,t,n,e,i,o,s),a=r[0],l=r[1],c=r[2];return a.attributes[l]=c,this.emit("nodeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:l}),this}}},{name:function(e){return"update".concat(e,"Attribute")},attacher:function(e,t,n){e.prototype[t]=function(e,i,o,s){var r=K(this,t,n,e,i,o,s),a=r[0],l=r[1],c=r[2];if("function"!=typeof c)throw new B("Graph.".concat(t,": updater should be a function."));var u=a.attributes,h=c(u[l]);return u[l]=h,this.emit("nodeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:l}),this}}},{name:function(e){return"remove".concat(e,"Attribute")},attacher:function(e,t,n){e.prototype[t]=function(e,i,o){var s=K(this,t,n,e,i,o),r=s[0],a=s[1];return delete r.attributes[a],this.emit("nodeAttributesUpdated",{key:r.key,type:"remove",attributes:r.attributes,name:a}),this}}},{name:function(e){return"replace".concat(e,"Attributes")},attacher:function(e,t,n){e.prototype[t]=function(e,i,o){var s=K(this,t,n,e,i,o),r=s[0],a=s[1];if(!c(a))throw new B("Graph.".concat(t,": provided attributes are not a plain object."));return r.attributes=a,this.emit("nodeAttributesUpdated",{key:r.key,type:"replace",attributes:r.attributes}),this}}},{name:function(e){return"merge".concat(e,"Attributes")},attacher:function(e,t,n){e.prototype[t]=function(e,i,o){var s=K(this,t,n,e,i,o),r=s[0],l=s[1];if(!c(l))throw new B("Graph.".concat(t,": provided attributes are not a plain object."));return a(r.attributes,l),this.emit("nodeAttributesUpdated",{key:r.key,type:"merge",attributes:r.attributes,data:l}),this}}},{name:function(e){return"update".concat(e,"Attributes")},attacher:function(e,t,n){e.prototype[t]=function(e,i,o){var s=K(this,t,n,e,i,o),r=s[0],a=s[1];if("function"!=typeof a)throw new B("Graph.".concat(t,": provided updater is not a function."));return r.attributes=a(r.attributes),this.emit("nodeAttributesUpdated",{key:r.key,type:"update",attributes:r.attributes}),this}}}],Z=[{name:function(e){return"get".concat(e,"Attribute")},attacher:function(e,t,n){e.prototype[t]=function(e,i){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new U("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new U("Graph.".concat(t,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var s=""+e,r=""+i;if(i=arguments[2],!(o=l(this,s,r,n)))throw new V("Graph.".concat(t,': could not find an edge for the given path ("').concat(s,'" - "').concat(r,'").'))}else{if("mixed"!==n)throw new U("Graph.".concat(t,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(e=""+e,!(o=this._edges.get(e)))throw new V("Graph.".concat(t,': could not find the "').concat(e,'" edge in the graph.'))}return o.attributes[i]}}},{name:function(e){return"get".concat(e,"Attributes")},attacher:function(e,t,n){e.prototype[t]=function(e){var i;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new U("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>1){if(this.multi)throw new U("Graph.".concat(t,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var o=""+e,s=""+arguments[1];if(!(i=l(this,o,s,n)))throw new V("Graph.".concat(t,': could not find an edge for the given path ("').concat(o,'" - "').concat(s,'").'))}else{if("mixed"!==n)throw new U("Graph.".concat(t,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(e=""+e,!(i=this._edges.get(e)))throw new V("Graph.".concat(t,': could not find the "').concat(e,'" edge in the graph.'))}return i.attributes}}},{name:function(e){return"has".concat(e,"Attribute")},attacher:function(e,t,n){e.prototype[t]=function(e,i){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new U("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new U("Graph.".concat(t,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var s=""+e,r=""+i;if(i=arguments[2],!(o=l(this,s,r,n)))throw new V("Graph.".concat(t,': could not find an edge for the given path ("').concat(s,'" - "').concat(r,'").'))}else{if("mixed"!==n)throw new U("Graph.".concat(t,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(e=""+e,!(o=this._edges.get(e)))throw new V("Graph.".concat(t,': could not find the "').concat(e,'" edge in the graph.'))}return o.attributes.hasOwnProperty(i)}}},{name:function(e){return"set".concat(e,"Attribute")},attacher:function(e,t,n){e.prototype[t]=function(e,i,o){var s;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new U("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>3){if(this.multi)throw new U("Graph.".concat(t,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var r=""+e,a=""+i;if(i=arguments[2],o=arguments[3],!(s=l(this,r,a,n)))throw new V("Graph.".concat(t,': could not find an edge for the given path ("').concat(r,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new U("Graph.".concat(t,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(e=""+e,!(s=this._edges.get(e)))throw new V("Graph.".concat(t,': could not find the "').concat(e,'" edge in the graph.'))}return s.attributes[i]=o,this.emit("edgeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:i}),this}}},{name:function(e){return"update".concat(e,"Attribute")},attacher:function(e,t,n){e.prototype[t]=function(e,i,o){var s;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new U("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>3){if(this.multi)throw new U("Graph.".concat(t,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var r=""+e,a=""+i;if(i=arguments[2],o=arguments[3],!(s=l(this,r,a,n)))throw new V("Graph.".concat(t,': could not find an edge for the given path ("').concat(r,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new U("Graph.".concat(t,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(e=""+e,!(s=this._edges.get(e)))throw new V("Graph.".concat(t,': could not find the "').concat(e,'" edge in the graph.'))}if("function"!=typeof o)throw new B("Graph.".concat(t,": updater should be a function."));return s.attributes[i]=o(s.attributes[i]),this.emit("edgeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:i}),this}}},{name:function(e){return"remove".concat(e,"Attribute")},attacher:function(e,t,n){e.prototype[t]=function(e,i){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new U("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new U("Graph.".concat(t,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var s=""+e,r=""+i;if(i=arguments[2],!(o=l(this,s,r,n)))throw new V("Graph.".concat(t,': could not find an edge for the given path ("').concat(s,'" - "').concat(r,'").'))}else{if("mixed"!==n)throw new U("Graph.".concat(t,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(e=""+e,!(o=this._edges.get(e)))throw new V("Graph.".concat(t,': could not find the "').concat(e,'" edge in the graph.'))}return delete o.attributes[i],this.emit("edgeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:i}),this}}},{name:function(e){return"replace".concat(e,"Attributes")},attacher:function(e,t,n){e.prototype[t]=function(e,i){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new U("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new U("Graph.".concat(t,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var s=""+e,r=""+i;if(i=arguments[2],!(o=l(this,s,r,n)))throw new V("Graph.".concat(t,': could not find an edge for the given path ("').concat(s,'" - "').concat(r,'").'))}else{if("mixed"!==n)throw new U("Graph.".concat(t,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(e=""+e,!(o=this._edges.get(e)))throw new V("Graph.".concat(t,': could not find the "').concat(e,'" edge in the graph.'))}if(!c(i))throw new B("Graph.".concat(t,": provided attributes are not a plain object."));return o.attributes=i,this.emit("edgeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}},{name:function(e){return"merge".concat(e,"Attributes")},attacher:function(e,t,n){e.prototype[t]=function(e,i){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new U("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new U("Graph.".concat(t,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var s=""+e,r=""+i;if(i=arguments[2],!(o=l(this,s,r,n)))throw new V("Graph.".concat(t,': could not find an edge for the given path ("').concat(s,'" - "').concat(r,'").'))}else{if("mixed"!==n)throw new U("Graph.".concat(t,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(e=""+e,!(o=this._edges.get(e)))throw new V("Graph.".concat(t,': could not find the "').concat(e,'" edge in the graph.'))}if(!c(i))throw new B("Graph.".concat(t,": provided attributes are not a plain object."));return a(o.attributes,i),this.emit("edgeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:i}),this}}},{name:function(e){return"update".concat(e,"Attributes")},attacher:function(e,t,n){e.prototype[t]=function(e,i){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new U("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new U("Graph.".concat(t,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var s=""+e,r=""+i;if(i=arguments[2],!(o=l(this,s,r,n)))throw new V("Graph.".concat(t,': could not find an edge for the given path ("').concat(s,'" - "').concat(r,'").'))}else{if("mixed"!==n)throw new U("Graph.".concat(t,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(e=""+e,!(o=this._edges.get(e)))throw new V("Graph.".concat(t,': could not find the "').concat(e,'" edge in the graph.'))}if("function"!=typeof i)throw new B("Graph.".concat(t,": provided updater is not a function."));return o.attributes=i(o.attributes),this.emit("edgeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}}],X=P,J=k,Q=function(){var e=arguments,t=null,n=-1;return new X((function(){for(var i=null;;){if(null===t){if(++n>=e.length)return{done:!0};t=J(e[n])}if(!0!==(i=t.next()).done)break;t=null}return i}))},ee=[{name:"edges",type:"mixed"},{name:"inEdges",type:"directed",direction:"in"},{name:"outEdges",type:"directed",direction:"out"},{name:"inboundEdges",type:"mixed",direction:"in"},{name:"outboundEdges",type:"mixed",direction:"out"},{name:"directedEdges",type:"directed"},{name:"undirectedEdges",type:"undirected"}];function te(e,t,n,i){var o=!1;for(var s in t)if(s!==i){var r=t[s];if(o=n(r.key,r.attributes,r.source.key,r.target.key,r.source.attributes,r.target.attributes,r.undirected),e&&o)return r.key}}function ne(e,t,n,i){var o,s,r,a=!1;for(var l in t)if(l!==i){o=t[l];do{if(s=o.source,r=o.target,a=n(o.key,o.attributes,s.key,r.key,s.attributes,r.attributes,o.undirected),e&&a)return o.key;o=o.next}while(void 0!==o)}}function ie(e,t){var n,i=Object.keys(e),o=i.length,s=0;return new P((function(){do{if(n)n=n.next;else{if(s>=o)return{done:!0};var r=i[s++];if(r===t){n=void 0;continue}n=e[r]}}while(!n);return{done:!1,value:{edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected}}}))}function oe(e,t,n,i){var o=t[n];if(o){var s=o.source,r=o.target;return i(o.key,o.attributes,s.key,r.key,s.attributes,r.attributes,o.undirected)&&e?o.key:void 0}}function se(e,t,n,i){var o=t[n];if(o){var s=!1;do{if(s=i(o.key,o.attributes,o.source.key,o.target.key,o.source.attributes,o.target.attributes,o.undirected),e&&s)return o.key;o=o.next}while(void 0!==o)}}function re(e,t){var n=e[t];return void 0!==n.next?new P((function(){if(!n)return{done:!0};var e={edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected};return n=n.next,{done:!1,value:e}})):P.of({edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected})}function ae(e,t,n,i){if(0!==t.size)for(var o,s,r="mixed"!==n&&n!==t.type,a="undirected"===n,l=!1,c=t._edges.values();!0!==(o=c.next()).done;)if(s=o.value,!r||s.undirected===a){var u=s,h=u.key,d=u.attributes,p=u.source,m=u.target;if(l=i(h,d,p.key,m.key,p.attributes,m.attributes,s.undirected),e&&l)return h}}function le(e,t,n,i,o,s){var r,a=t?ne:te;if("undirected"!==n){if("out"!==i&&(r=a(e,o.in,s),e&&r))return r;if("in"!==i&&(r=a(e,o.out,s,i?void 0:o.key),e&&r))return r}if("directed"!==n&&(r=a(e,o.undirected,s),e&&r))return r}function ce(e,t,n,i,o,s,r){var a,l=n?se:oe;if("undirected"!==t){if(void 0!==o.in&&"out"!==i&&(a=l(e,o.in,s,r),e&&a))return a;if(void 0!==o.out&&"in"!==i&&(i||o.key!==s)&&(a=l(e,o.out,s,r),e&&a))return a}if("directed"!==t&&void 0!==o.undirected&&(a=l(e,o.undirected,s,r),e&&a))return a}var ue=[{name:"neighbors",type:"mixed"},{name:"inNeighbors",type:"directed",direction:"in"},{name:"outNeighbors",type:"directed",direction:"out"},{name:"inboundNeighbors",type:"mixed",direction:"in"},{name:"outboundNeighbors",type:"mixed",direction:"out"},{name:"directedNeighbors",type:"directed"},{name:"undirectedNeighbors",type:"undirected"}];function he(){this.A=null,this.B=null}function de(e,t,n,i,o){for(var s in i){var r=i[s],a=r.source,l=r.target,c=a===n?l:a;if(!t||!t.has(c.key)){var u=o(c.key,c.attributes);if(e&&u)return c.key}}}function pe(e,t,n,i,o){if("mixed"!==t){if("undirected"===t)return de(e,null,i,i.undirected,o);if("string"==typeof n)return de(e,null,i,i[n],o)}var s,r=new he;if("undirected"!==t){if("out"!==n){if(s=de(e,null,i,i.in,o),e&&s)return s;r.wrap(i.in)}if("in"!==n){if(s=de(e,r,i,i.out,o),e&&s)return s;r.wrap(i.out)}}if("directed"!==t&&(s=de(e,r,i,i.undirected,o),e&&s))return s}function me(e,t,n){var i=Object.keys(n),o=i.length,s=0;return new P((function(){var r=null;do{if(s>=o)return e&&e.wrap(n),{done:!0};var a=n[i[s++]],l=a.source,c=a.target;r=l===t?c:l,e&&e.has(r.key)&&(r=null)}while(null===r);return{done:!1,value:{neighbor:r.key,attributes:r.attributes}}}))}function ge(e,t,n,i,o){for(var s,r,a,l,c,u,h,d=i._nodes.values(),p=i.type;!0!==(s=d.next()).done;){var m=!1;if(r=s.value,"undirected"!==p)for(a in l=r.out){c=l[a];do{if(u=c.target,m=!0,h=o(r.key,u.key,r.attributes,u.attributes,c.key,c.attributes,c.undirected),e&&h)return c;c=c.next}while(c)}if("directed"!==p)for(a in l=r.undirected)if(!(t&&r.key>a)){c=l[a];do{if((u=c.target).key!==a&&(u=c.source),m=!0,h=o(r.key,u.key,r.attributes,u.attributes,c.key,c.attributes,c.undirected),e&&h)return c;c=c.next}while(c)}if(n&&!m&&(h=o(r.key,null,r.attributes,null,null,null,null),e&&h))return null}}function fe(e){if(!c(e))throw new B('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in e))throw new B("Graph.import: serialized node is missing its key.");if("attributes"in e&&(!c(e.attributes)||null===e.attributes))throw new B("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function ye(e){if(!c(e))throw new B('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in e))throw new B("Graph.import: serialized edge is missing its source.");if(!("target"in e))throw new B("Graph.import: serialized edge is missing its target.");if("attributes"in e&&(!c(e.attributes)||null===e.attributes))throw new B("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in e&&"boolean"!=typeof e.undirected)throw new B("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}he.prototype.wrap=function(e){null===this.A?this.A=e:null===this.B&&(this.B=e)},he.prototype.has=function(e){return null!==this.A&&e in this.A||null!==this.B&&e in this.B};var be,we=(be=255&Math.floor(256*Math.random()),function(){return be++}),ve=new Set(["directed","undirected","mixed"]),Ae=new Set(["domain","_events","_eventsCount","_maxListeners"]),Ce={allowSelfLoops:!0,multi:!1,type:"mixed"};function Te(e,t,n){var i=new e.NodeDataClass(t,n);return e._nodes.set(t,i),e.emit("nodeAdded",{key:t,attributes:n}),i}function Se(e,t,n,i,o,s,r,a){if(!i&&"undirected"===e.type)throw new U("Graph.".concat(t,": you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead."));if(i&&"directed"===e.type)throw new U("Graph.".concat(t,": you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead."));if(a&&!c(a))throw new B("Graph.".concat(t,': invalid attributes. Expecting an object but got "').concat(a,'"'));if(s=""+s,r=""+r,a=a||{},!e.allowSelfLoops&&s===r)throw new U("Graph.".concat(t,': source & target are the same ("').concat(s,"\"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false."));var l=e._nodes.get(s),u=e._nodes.get(r);if(!l)throw new V("Graph.".concat(t,': source node "').concat(s,'" not found.'));if(!u)throw new V("Graph.".concat(t,': target node "').concat(r,'" not found.'));var h={key:null,undirected:i,source:s,target:r,attributes:a};if(n)o=e._edgeKeyGenerator();else if(o=""+o,e._edges.has(o))throw new U("Graph.".concat(t,': the "').concat(o,'" edge already exists in the graph.'));if(!e.multi&&(i?void 0!==l.undirected[r]:void 0!==l.out[r]))throw new U("Graph.".concat(t,': an edge linking "').concat(s,'" to "').concat(r,"\" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option."));var d=new j(i,o,l,u,a);e._edges.set(o,d);var p=s===r;return i?(l.undirectedDegree++,u.undirectedDegree++,p&&(l.undirectedLoops++,e._undirectedSelfLoopCount++)):(l.outDegree++,u.inDegree++,p&&(l.directedLoops++,e._directedSelfLoopCount++)),e.multi?d.attachMulti():d.attach(),i?e._undirectedSize++:e._directedSize++,h.key=o,e.emit("edgeAdded",h),o}function Ee(e,t,n,i,o,s,r,l,u){if(!i&&"undirected"===e.type)throw new U("Graph.".concat(t,": you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead."));if(i&&"directed"===e.type)throw new U("Graph.".concat(t,": you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead."));if(l)if(u){if("function"!=typeof l)throw new B("Graph.".concat(t,': invalid updater function. Expecting a function but got "').concat(l,'"'))}else if(!c(l))throw new B("Graph.".concat(t,': invalid attributes. Expecting an object but got "').concat(l,'"'));var h;if(s=""+s,r=""+r,u&&(h=l,l=void 0),!e.allowSelfLoops&&s===r)throw new U("Graph.".concat(t,': source & target are the same ("').concat(s,"\"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false."));var d,p,m=e._nodes.get(s),g=e._nodes.get(r);if(!n&&(d=e._edges.get(o))){if(!(d.source.key===s&&d.target.key===r||i&&d.source.key===r&&d.target.key===s))throw new U("Graph.".concat(t,': inconsistency detected when attempting to merge the "').concat(o,'" edge with "').concat(s,'" source & "').concat(r,'" target vs. ("').concat(d.source.key,'", "').concat(d.target.key,'").'));p=d}if(p||e.multi||!m||(p=i?m.undirected[r]:m.out[r]),p){var f=[p.key,!1,!1,!1];if(u?!h:!l)return f;if(u){var y=p.attributes;p.attributes=h(y),e.emit("edgeAttributesUpdated",{type:"replace",key:p.key,attributes:p.attributes})}else a(p.attributes,l),e.emit("edgeAttributesUpdated",{type:"merge",key:p.key,attributes:p.attributes,data:l});return f}l=l||{},u&&h&&(l=h(l));var b={key:null,undirected:i,source:s,target:r,attributes:l};if(n)o=e._edgeKeyGenerator();else if(o=""+o,e._edges.has(o))throw new U("Graph.".concat(t,': the "').concat(o,'" edge already exists in the graph.'));var w=!1,v=!1;m||(m=Te(e,s,{}),w=!0,s===r&&(g=m,v=!0)),g||(g=Te(e,r,{}),v=!0),d=new j(i,o,m,g,l),e._edges.set(o,d);var A=s===r;return i?(m.undirectedDegree++,g.undirectedDegree++,A&&(m.undirectedLoops++,e._undirectedSelfLoopCount++)):(m.outDegree++,g.inDegree++,A&&(m.directedLoops++,e._directedSelfLoopCount++)),e.multi?d.attachMulti():d.attach(),i?e._undirectedSize++:e._directedSize++,b.key=o,e.emit("edgeAdded",b),[o,!0,w,v]}function Me(e,t){e._edges.delete(t.key);var n=t.source,i=t.target,o=t.attributes,s=t.undirected,r=n===i;s?(n.undirectedDegree--,i.undirectedDegree--,r&&(n.undirectedLoops--,e._undirectedSelfLoopCount--)):(n.outDegree--,i.inDegree--,r&&(n.directedLoops--,e._directedSelfLoopCount--)),e.multi?t.detachMulti():t.detach(),s?e._undirectedSize--:e._directedSize--,e.emit("edgeDropped",{key:t.key,attributes:o,source:n.key,target:i.key,undirected:s})}var xe=function(n){function i(e){var t;if(t=n.call(this)||this,"boolean"!=typeof(e=a({},Ce,e)).multi)throw new B("Graph.constructor: invalid 'multi' option. Expecting a boolean but got \"".concat(e.multi,'".'));if(!ve.has(e.type))throw new B('Graph.constructor: invalid \'type\' option. Should be one of "mixed", "directed" or "undirected" but got "'.concat(e.type,'".'));if("boolean"!=typeof e.allowSelfLoops)throw new B("Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got \"".concat(e.allowSelfLoops,'".'));var i="mixed"===e.type?W:"directed"===e.type?q:Y;h(r(t),"NodeDataClass",i);var o="geid_"+we()+"_",s=0;return h(r(t),"_attributes",{}),h(r(t),"_nodes",new Map),h(r(t),"_edges",new Map),h(r(t),"_directedSize",0),h(r(t),"_undirectedSize",0),h(r(t),"_directedSelfLoopCount",0),h(r(t),"_undirectedSelfLoopCount",0),h(r(t),"_edgeKeyGenerator",(function(){var e;do{e=o+s++}while(t._edges.has(e));return e})),h(r(t),"_options",e),Ae.forEach((function(e){return h(r(t),e,t[e])})),d(r(t),"order",(function(){return t._nodes.size})),d(r(t),"size",(function(){return t._edges.size})),d(r(t),"directedSize",(function(){return t._directedSize})),d(r(t),"undirectedSize",(function(){return t._undirectedSize})),d(r(t),"selfLoopCount",(function(){return t._directedSelfLoopCount+t._undirectedSelfLoopCount})),d(r(t),"directedSelfLoopCount",(function(){return t._directedSelfLoopCount})),d(r(t),"undirectedSelfLoopCount",(function(){return t._undirectedSelfLoopCount})),d(r(t),"multi",t._options.multi),d(r(t),"type",t._options.type),d(r(t),"allowSelfLoops",t._options.allowSelfLoops),d(r(t),"implementation",(function(){return"graphology"})),t}t(i,n);var o=i.prototype;return o._resetInstanceCounters=function(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0},o.hasNode=function(e){return this._nodes.has(""+e)},o.hasDirectedEdge=function(e,t){if("undirected"===this.type)return!1;if(1===arguments.length){var n=""+e,i=this._edges.get(n);return!!i&&!i.undirected}if(2===arguments.length){e=""+e,t=""+t;var o=this._nodes.get(e);return!!o&&o.out.hasOwnProperty(t)}throw new B("Graph.hasDirectedEdge: invalid arity (".concat(arguments.length,", instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target."))},o.hasUndirectedEdge=function(e,t){if("directed"===this.type)return!1;if(1===arguments.length){var n=""+e,i=this._edges.get(n);return!!i&&i.undirected}if(2===arguments.length){e=""+e,t=""+t;var o=this._nodes.get(e);return!!o&&o.undirected.hasOwnProperty(t)}throw new B("Graph.hasDirectedEdge: invalid arity (".concat(arguments.length,", instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target."))},o.hasEdge=function(e,t){if(1===arguments.length){var n=""+e;return this._edges.has(n)}if(2===arguments.length){e=""+e,t=""+t;var i=this._nodes.get(e);return!!i&&(void 0!==i.out&&i.out.hasOwnProperty(t)||void 0!==i.undirected&&i.undirected.hasOwnProperty(t))}throw new B("Graph.hasEdge: invalid arity (".concat(arguments.length,", instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target."))},o.directedEdge=function(e,t){if("undirected"!==this.type){if(e=""+e,t=""+t,this.multi)throw new U("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");var n=this._nodes.get(e);if(!n)throw new V('Graph.directedEdge: could not find the "'.concat(e,'" source node in the graph.'));if(!this._nodes.has(t))throw new V('Graph.directedEdge: could not find the "'.concat(t,'" target node in the graph.'));var i=n.out&&n.out[t]||void 0;return i?i.key:void 0}},o.undirectedEdge=function(e,t){if("directed"!==this.type){if(e=""+e,t=""+t,this.multi)throw new U("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");var n=this._nodes.get(e);if(!n)throw new V('Graph.undirectedEdge: could not find the "'.concat(e,'" source node in the graph.'));if(!this._nodes.has(t))throw new V('Graph.undirectedEdge: could not find the "'.concat(t,'" target node in the graph.'));var i=n.undirected&&n.undirected[t]||void 0;return i?i.key:void 0}},o.edge=function(e,t){if(this.multi)throw new U("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");e=""+e,t=""+t;var n=this._nodes.get(e);if(!n)throw new V('Graph.edge: could not find the "'.concat(e,'" source node in the graph.'));if(!this._nodes.has(t))throw new V('Graph.edge: could not find the "'.concat(t,'" target node in the graph.'));var i=n.out&&n.out[t]||n.undirected&&n.undirected[t]||void 0;if(i)return i.key},o.areDirectedNeighbors=function(e,t){e=""+e,t=""+t;var n=this._nodes.get(e);if(!n)throw new V('Graph.areDirectedNeighbors: could not find the "'.concat(e,'" node in the graph.'));return"undirected"!==this.type&&(t in n.in||t in n.out)},o.areOutNeighbors=function(e,t){e=""+e,t=""+t;var n=this._nodes.get(e);if(!n)throw new V('Graph.areOutNeighbors: could not find the "'.concat(e,'" node in the graph.'));return"undirected"!==this.type&&t in n.out},o.areInNeighbors=function(e,t){e=""+e,t=""+t;var n=this._nodes.get(e);if(!n)throw new V('Graph.areInNeighbors: could not find the "'.concat(e,'" node in the graph.'));return"undirected"!==this.type&&t in n.in},o.areUndirectedNeighbors=function(e,t){e=""+e,t=""+t;var n=this._nodes.get(e);if(!n)throw new V('Graph.areUndirectedNeighbors: could not find the "'.concat(e,'" node in the graph.'));return"directed"!==this.type&&t in n.undirected},o.areNeighbors=function(e,t){e=""+e,t=""+t;var n=this._nodes.get(e);if(!n)throw new V('Graph.areNeighbors: could not find the "'.concat(e,'" node in the graph.'));return"undirected"!==this.type&&(t in n.in||t in n.out)||"directed"!==this.type&&t in n.undirected},o.areInboundNeighbors=function(e,t){e=""+e,t=""+t;var n=this._nodes.get(e);if(!n)throw new V('Graph.areInboundNeighbors: could not find the "'.concat(e,'" node in the graph.'));return"undirected"!==this.type&&t in n.in||"directed"!==this.type&&t in n.undirected},o.areOutboundNeighbors=function(e,t){e=""+e,t=""+t;var n=this._nodes.get(e);if(!n)throw new V('Graph.areOutboundNeighbors: could not find the "'.concat(e,'" node in the graph.'));return"undirected"!==this.type&&t in n.out||"directed"!==this.type&&t in n.undirected},o.inDegree=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new V('Graph.inDegree: could not find the "'.concat(e,'" node in the graph.'));return"undirected"===this.type?0:t.inDegree},o.outDegree=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new V('Graph.outDegree: could not find the "'.concat(e,'" node in the graph.'));return"undirected"===this.type?0:t.outDegree},o.directedDegree=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new V('Graph.directedDegree: could not find the "'.concat(e,'" node in the graph.'));return"undirected"===this.type?0:t.inDegree+t.outDegree},o.undirectedDegree=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new V('Graph.undirectedDegree: could not find the "'.concat(e,'" node in the graph.'));return"directed"===this.type?0:t.undirectedDegree},o.inboundDegree=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new V('Graph.inboundDegree: could not find the "'.concat(e,'" node in the graph.'));var n=0;return"directed"!==this.type&&(n+=t.undirectedDegree),"undirected"!==this.type&&(n+=t.inDegree),n},o.outboundDegree=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new V('Graph.outboundDegree: could not find the "'.concat(e,'" node in the graph.'));var n=0;return"directed"!==this.type&&(n+=t.undirectedDegree),"undirected"!==this.type&&(n+=t.outDegree),n},o.degree=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new V('Graph.degree: could not find the "'.concat(e,'" node in the graph.'));var n=0;return"directed"!==this.type&&(n+=t.undirectedDegree),"undirected"!==this.type&&(n+=t.inDegree+t.outDegree),n},o.inDegreeWithoutSelfLoops=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new V('Graph.inDegreeWithoutSelfLoops: could not find the "'.concat(e,'" node in the graph.'));return"undirected"===this.type?0:t.inDegree-t.directedLoops},o.outDegreeWithoutSelfLoops=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new V('Graph.outDegreeWithoutSelfLoops: could not find the "'.concat(e,'" node in the graph.'));return"undirected"===this.type?0:t.outDegree-t.directedLoops},o.directedDegreeWithoutSelfLoops=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new V('Graph.directedDegreeWithoutSelfLoops: could not find the "'.concat(e,'" node in the graph.'));return"undirected"===this.type?0:t.inDegree+t.outDegree-2*t.directedLoops},o.undirectedDegreeWithoutSelfLoops=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new V('Graph.undirectedDegreeWithoutSelfLoops: could not find the "'.concat(e,'" node in the graph.'));return"directed"===this.type?0:t.undirectedDegree-2*t.undirectedLoops},o.inboundDegreeWithoutSelfLoops=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new V('Graph.inboundDegreeWithoutSelfLoops: could not find the "'.concat(e,'" node in the graph.'));var n=0,i=0;return"directed"!==this.type&&(n+=t.undirectedDegree,i+=2*t.undirectedLoops),"undirected"!==this.type&&(n+=t.inDegree,i+=t.directedLoops),n-i},o.outboundDegreeWithoutSelfLoops=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new V('Graph.outboundDegreeWithoutSelfLoops: could not find the "'.concat(e,'" node in the graph.'));var n=0,i=0;return"directed"!==this.type&&(n+=t.undirectedDegree,i+=2*t.undirectedLoops),"undirected"!==this.type&&(n+=t.outDegree,i+=t.directedLoops),n-i},o.degreeWithoutSelfLoops=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new V('Graph.degreeWithoutSelfLoops: could not find the "'.concat(e,'" node in the graph.'));var n=0,i=0;return"directed"!==this.type&&(n+=t.undirectedDegree,i+=2*t.undirectedLoops),"undirected"!==this.type&&(n+=t.inDegree+t.outDegree,i+=2*t.directedLoops),n-i},o.source=function(e){e=""+e;var t=this._edges.get(e);if(!t)throw new V('Graph.source: could not find the "'.concat(e,'" edge in the graph.'));return t.source.key},o.target=function(e){e=""+e;var t=this._edges.get(e);if(!t)throw new V('Graph.target: could not find the "'.concat(e,'" edge in the graph.'));return t.target.key},o.extremities=function(e){e=""+e;var t=this._edges.get(e);if(!t)throw new V('Graph.extremities: could not find the "'.concat(e,'" edge in the graph.'));return[t.source.key,t.target.key]},o.opposite=function(e,t){e=""+e,t=""+t;var n=this._edges.get(t);if(!n)throw new V('Graph.opposite: could not find the "'.concat(t,'" edge in the graph.'));var i=n.source.key,o=n.target.key;if(e===i)return o;if(e===o)return i;throw new V('Graph.opposite: the "'.concat(e,'" node is not attached to the "').concat(t,'" edge (').concat(i,", ").concat(o,")."))},o.hasExtremity=function(e,t){e=""+e,t=""+t;var n=this._edges.get(e);if(!n)throw new V('Graph.hasExtremity: could not find the "'.concat(e,'" edge in the graph.'));return n.source.key===t||n.target.key===t},o.isUndirected=function(e){e=""+e;var t=this._edges.get(e);if(!t)throw new V('Graph.isUndirected: could not find the "'.concat(e,'" edge in the graph.'));return t.undirected},o.isDirected=function(e){e=""+e;var t=this._edges.get(e);if(!t)throw new V('Graph.isDirected: could not find the "'.concat(e,'" edge in the graph.'));return!t.undirected},o.isSelfLoop=function(e){e=""+e;var t=this._edges.get(e);if(!t)throw new V('Graph.isSelfLoop: could not find the "'.concat(e,'" edge in the graph.'));return t.source===t.target},o.addNode=function(e,t){var n=function(e,t,n){if(n&&!c(n))throw new B('Graph.addNode: invalid attributes. Expecting an object but got "'.concat(n,'"'));if(t=""+t,n=n||{},e._nodes.has(t))throw new U('Graph.addNode: the "'.concat(t,'" node already exist in the graph.'));var i=new e.NodeDataClass(t,n);return e._nodes.set(t,i),e.emit("nodeAdded",{key:t,attributes:n}),i}(this,e,t);return n.key},o.mergeNode=function(e,t){if(t&&!c(t))throw new B('Graph.mergeNode: invalid attributes. Expecting an object but got "'.concat(t,'"'));e=""+e,t=t||{};var n=this._nodes.get(e);return n?(t&&(a(n.attributes,t),this.emit("nodeAttributesUpdated",{type:"merge",key:e,attributes:n.attributes,data:t})),[e,!1]):(n=new this.NodeDataClass(e,t),this._nodes.set(e,n),this.emit("nodeAdded",{key:e,attributes:t}),[e,!0])},o.updateNode=function(e,t){if(t&&"function"!=typeof t)throw new B('Graph.updateNode: invalid updater function. Expecting a function but got "'.concat(t,'"'));e=""+e;var n=this._nodes.get(e);if(n){if(t){var i=n.attributes;n.attributes=t(i),this.emit("nodeAttributesUpdated",{type:"replace",key:e,attributes:n.attributes})}return[e,!1]}var o=t?t({}):{};return n=new this.NodeDataClass(e,o),this._nodes.set(e,n),this.emit("nodeAdded",{key:e,attributes:o}),[e,!0]},o.dropNode=function(e){e=""+e;var t,n=this._nodes.get(e);if(!n)throw new V('Graph.dropNode: could not find the "'.concat(e,'" node in the graph.'));if("undirected"!==this.type){for(var i in n.out){t=n.out[i];do{Me(this,t),t=t.next}while(t)}for(var o in n.in){t=n.in[o];do{Me(this,t),t=t.next}while(t)}}if("directed"!==this.type)for(var s in n.undirected){t=n.undirected[s];do{Me(this,t),t=t.next}while(t)}this._nodes.delete(e),this.emit("nodeDropped",{key:e,attributes:n.attributes})},o.dropEdge=function(e){var t;if(arguments.length>1){var n=""+arguments[0],i=""+arguments[1];if(!(t=l(this,n,i,this.type)))throw new V('Graph.dropEdge: could not find the "'.concat(n,'" -> "').concat(i,'" edge in the graph.'))}else if(e=""+e,!(t=this._edges.get(e)))throw new V('Graph.dropEdge: could not find the "'.concat(e,'" edge in the graph.'));return Me(this,t),this},o.dropDirectedEdge=function(e,t){if(arguments.length<2)throw new U("Graph.dropDirectedEdge: it does not make sense to try and drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new U("Graph.dropDirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");var n=l(this,e=""+e,t=""+t,"directed");if(!n)throw new V('Graph.dropDirectedEdge: could not find a "'.concat(e,'" -> "').concat(t,'" edge in the graph.'));return Me(this,n),this},o.dropUndirectedEdge=function(e,t){if(arguments.length<2)throw new U("Graph.dropUndirectedEdge: it does not make sense to drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new U("Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");var n=l(this,e,t,"undirected");if(!n)throw new V('Graph.dropUndirectedEdge: could not find a "'.concat(e,'" -> "').concat(t,'" edge in the graph.'));return Me(this,n),this},o.clear=function(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")},o.clearEdges=function(){for(var e,t=this._nodes.values();!0!==(e=t.next()).done;)e.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")},o.getAttribute=function(e){return this._attributes[e]},o.getAttributes=function(){return this._attributes},o.hasAttribute=function(e){return this._attributes.hasOwnProperty(e)},o.setAttribute=function(e,t){return this._attributes[e]=t,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this},o.updateAttribute=function(e,t){if("function"!=typeof t)throw new B("Graph.updateAttribute: updater should be a function.");var n=this._attributes[e];return this._attributes[e]=t(n),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this},o.removeAttribute=function(e){return delete this._attributes[e],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:e}),this},o.replaceAttributes=function(e){if(!c(e))throw new B("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=e,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this},o.mergeAttributes=function(e){if(!c(e))throw new B("Graph.mergeAttributes: provided attributes are not a plain object.");return a(this._attributes,e),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:e}),this},o.updateAttributes=function(e){if("function"!=typeof e)throw new B("Graph.updateAttributes: provided updater is not a function.");return this._attributes=e(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this},o.updateEachNodeAttributes=function(e,t){if("function"!=typeof e)throw new B("Graph.updateEachNodeAttributes: expecting an updater function.");if(t&&!p(t))throw new B("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");for(var n,i,o=this._nodes.values();!0!==(n=o.next()).done;)(i=n.value).attributes=e(i.key,i.attributes);this.emit("eachNodeAttributesUpdated",{hints:t||null})},o.updateEachEdgeAttributes=function(e,t){if("function"!=typeof e)throw new B("Graph.updateEachEdgeAttributes: expecting an updater function.");if(t&&!p(t))throw new B("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");for(var n,i,o,s,r=this._edges.values();!0!==(n=r.next()).done;)o=(i=n.value).source,s=i.target,i.attributes=e(i.key,i.attributes,o.key,s.key,o.attributes,s.attributes,i.undirected);this.emit("eachEdgeAttributesUpdated",{hints:t||null})},o.forEachAdjacencyEntry=function(e){if("function"!=typeof e)throw new B("Graph.forEachAdjacencyEntry: expecting a callback.");ge(!1,!1,!1,this,e)},o.forEachAdjacencyEntryWithOrphans=function(e){if("function"!=typeof e)throw new B("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");ge(!1,!1,!0,this,e)},o.forEachAssymetricAdjacencyEntry=function(e){if("function"!=typeof e)throw new B("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");ge(!1,!0,!1,this,e)},o.forEachAssymetricAdjacencyEntryWithOrphans=function(e){if("function"!=typeof e)throw new B("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");ge(!1,!0,!0,this,e)},o.nodes=function(){return"function"==typeof Array.from?Array.from(this._nodes.keys()):D(this._nodes.keys(),this._nodes.size)},o.forEachNode=function(e){if("function"!=typeof e)throw new B("Graph.forEachNode: expecting a callback.");for(var t,n,i=this._nodes.values();!0!==(t=i.next()).done;)e((n=t.value).key,n.attributes)},o.findNode=function(e){if("function"!=typeof e)throw new B("Graph.findNode: expecting a callback.");for(var t,n,i=this._nodes.values();!0!==(t=i.next()).done;)if(e((n=t.value).key,n.attributes))return n.key},o.mapNodes=function(e){if("function"!=typeof e)throw new B("Graph.mapNode: expecting a callback.");for(var t,n,i=this._nodes.values(),o=new Array(this.order),s=0;!0!==(t=i.next()).done;)n=t.value,o[s++]=e(n.key,n.attributes);return o},o.someNode=function(e){if("function"!=typeof e)throw new B("Graph.someNode: expecting a callback.");for(var t,n,i=this._nodes.values();!0!==(t=i.next()).done;)if(e((n=t.value).key,n.attributes))return!0;return!1},o.everyNode=function(e){if("function"!=typeof e)throw new B("Graph.everyNode: expecting a callback.");for(var t,n,i=this._nodes.values();!0!==(t=i.next()).done;)if(!e((n=t.value).key,n.attributes))return!1;return!0},o.filterNodes=function(e){if("function"!=typeof e)throw new B("Graph.filterNodes: expecting a callback.");for(var t,n,i=this._nodes.values(),o=[];!0!==(t=i.next()).done;)e((n=t.value).key,n.attributes)&&o.push(n.key);return o},o.reduceNodes=function(e,t){if("function"!=typeof e)throw new B("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new B("Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.");for(var n,i,o=t,s=this._nodes.values();!0!==(n=s.next()).done;)o=e(o,(i=n.value).key,i.attributes);return o},o.nodeEntries=function(){var e=this._nodes.values();return new P((function(){var t=e.next();if(t.done)return t;var n=t.value;return{value:{node:n.key,attributes:n.attributes},done:!1}}))},o.export=function(){var e=this,t=new Array(this._nodes.size),n=0;this._nodes.forEach((function(e,i){t[n++]=function(e,t){var n={key:e};return u(t.attributes)||(n.attributes=a({},t.attributes)),n}(i,e)}));var i=new Array(this._edges.size);return n=0,this._edges.forEach((function(t,o){i[n++]=function(e,t,n){var i={key:t,source:n.source.key,target:n.target.key};return u(n.attributes)||(i.attributes=a({},n.attributes)),"mixed"===e&&n.undirected&&(i.undirected=!0),i}(e.type,o,t)})),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:t,edges:i}},o.import=function(e){var t,n,o,s,r,a=this,l=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(e instanceof i)return e.forEachNode((function(e,t){l?a.mergeNode(e,t):a.addNode(e,t)})),e.forEachEdge((function(e,t,n,i,o,s,r){l?r?a.mergeUndirectedEdgeWithKey(e,n,i,t):a.mergeDirectedEdgeWithKey(e,n,i,t):r?a.addUndirectedEdgeWithKey(e,n,i,t):a.addDirectedEdgeWithKey(e,n,i,t)})),this;if(!c(e))throw new B("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(e.attributes){if(!c(e.attributes))throw new B("Graph.import: invalid attributes. Expecting a plain object.");l?this.mergeAttributes(e.attributes):this.replaceAttributes(e.attributes)}if(e.nodes){if(o=e.nodes,!Array.isArray(o))throw new B("Graph.import: invalid nodes. Expecting an array.");for(t=0,n=o.length;t<n;t++){fe(s=o[t]);var u=s,h=u.key,d=u.attributes;l?this.mergeNode(h,d):this.addNode(h,d)}}if(e.edges){var p=!1;if("undirected"===this.type&&(p=!0),o=e.edges,!Array.isArray(o))throw new B("Graph.import: invalid edges. Expecting an array.");for(t=0,n=o.length;t<n;t++){ye(r=o[t]);var m=r,g=m.source,f=m.target,y=m.attributes,b=m.undirected,w=void 0===b?p:b;"key"in r?(l?w?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:w?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey).call(this,r.key,g,f,y):(l?w?this.mergeUndirectedEdge:this.mergeDirectedEdge:w?this.addUndirectedEdge:this.addDirectedEdge).call(this,g,f,y)}}return this},o.nullCopy=function(e){var t=new i(a({},this._options,e));return t.replaceAttributes(a({},this.getAttributes())),t},o.emptyCopy=function(e){var t=this.nullCopy(e);return this._nodes.forEach((function(e,n){var i=a({},e.attributes);e=new t.NodeDataClass(n,i),t._nodes.set(n,e)})),t},o.copy=function(e){if("string"==typeof(e=e||{}).type&&e.type!==this.type&&"mixed"!==e.type)throw new U('Graph.copy: cannot create an incompatible copy from "'.concat(this.type,'" type to "').concat(e.type,'" because this would mean losing information about the current graph.'));if("boolean"==typeof e.multi&&e.multi!==this.multi&&!0!==e.multi)throw new U("Graph.copy: cannot create an incompatible copy by downgrading a multi graph to a simple one because this would mean losing information about the current graph.");if("boolean"==typeof e.allowSelfLoops&&e.allowSelfLoops!==this.allowSelfLoops&&!0!==e.allowSelfLoops)throw new U("Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.");for(var t,n,i=this.emptyCopy(e),o=this._edges.values();!0!==(t=o.next()).done;)Se(i,"copy",!1,(n=t.value).undirected,n.key,n.source.key,n.target.key,a({},n.attributes));return i},o.toJSON=function(){return this.export()},o.toString=function(){return"[object Graph]"},o.inspect=function(){var t=this,n={};this._nodes.forEach((function(e,t){n[t]=e.attributes}));var i={},o={};this._edges.forEach((function(e,n){var s,r=e.undirected?"--":"->",a="",l=e.source.key,c=e.target.key;e.undirected&&l>c&&(s=l,l=c,c=s);var u="(".concat(l,")").concat(r,"(").concat(c,")");n.startsWith("geid_")?t.multi&&(void 0===o[u]?o[u]=0:o[u]++,a+="".concat(o[u],". ")):a+="[".concat(n,"]: "),i[a+=u]=e.attributes}));var s={};for(var r in this)this.hasOwnProperty(r)&&!Ae.has(r)&&"function"!=typeof this[r]&&"symbol"!==e(r)&&(s[r]=this[r]);return s.attributes=this._attributes,s.nodes=n,s.edges=i,h(s,"constructor",this.constructor),s},i}(g.exports.EventEmitter);"undefined"!=typeof Symbol&&(xe.prototype[Symbol.for("nodejs.util.inspect.custom")]=xe.prototype.inspect),[{name:function(e){return"".concat(e,"Edge")},generateKey:!0},{name:function(e){return"".concat(e,"DirectedEdge")},generateKey:!0,type:"directed"},{name:function(e){return"".concat(e,"UndirectedEdge")},generateKey:!0,type:"undirected"},{name:function(e){return"".concat(e,"EdgeWithKey")}},{name:function(e){return"".concat(e,"DirectedEdgeWithKey")},type:"directed"},{name:function(e){return"".concat(e,"UndirectedEdgeWithKey")},type:"undirected"}].forEach((function(e){["add","merge","update"].forEach((function(t){var n=e.name(t),i="add"===t?Se:Ee;e.generateKey?xe.prototype[n]=function(o,s,r){return i(this,n,!0,"undirected"===(e.type||this.type),null,o,s,r,"update"===t)}:xe.prototype[n]=function(o,s,r,a){return i(this,n,!1,"undirected"===(e.type||this.type),o,s,r,a,"update"===t)}}))})),function(e){z.forEach((function(t){var n=t.name,i=t.attacher;i(e,n("Node"),0),i(e,n("Source"),1),i(e,n("Target"),2),i(e,n("Opposite"),3)}))}(xe),function(e){Z.forEach((function(t){var n=t.name,i=t.attacher;i(e,n("Edge"),"mixed"),i(e,n("DirectedEdge"),"directed"),i(e,n("UndirectedEdge"),"undirected")}))}(xe),function(e){ee.forEach((function(t){!function(e,t){var n=t.name,i=t.type,o=t.direction;e.prototype[n]=function(e,t){if("mixed"!==i&&"mixed"!==this.type&&i!==this.type)return[];if(!arguments.length)return function(e,t){if(0===e.size)return[];if("mixed"===t||t===e.type)return"function"==typeof Array.from?Array.from(e._edges.keys()):D(e._edges.keys(),e._edges.size);for(var n,i,o="undirected"===t?e.undirectedSize:e.directedSize,s=new Array(o),r="undirected"===t,a=e._edges.values(),l=0;!0!==(n=a.next()).done;)(i=n.value).undirected===r&&(s[l++]=i.key);return s}(this,i);if(1===arguments.length){e=""+e;var s=this._nodes.get(e);if(void 0===s)throw new V("Graph.".concat(n,': could not find the "').concat(e,'" node in the graph.'));return function(e,t,n,i){var o=[];return le(!1,e,t,n,i,(function(e){o.push(e)})),o}(this.multi,"mixed"===i?this.type:i,o,s)}if(2===arguments.length){e=""+e,t=""+t;var r=this._nodes.get(e);if(!r)throw new V("Graph.".concat(n,': could not find the "').concat(e,'" source node in the graph.'));if(!this._nodes.has(t))throw new V("Graph.".concat(n,': could not find the "').concat(t,'" target node in the graph.'));return function(e,t,n,i,o){var s=[];return ce(!1,e,t,n,i,o,(function(e){s.push(e)})),s}(i,this.multi,o,r,t)}throw new B("Graph.".concat(n,": too many arguments (expecting 0, 1 or 2 and got ").concat(arguments.length,")."))}}(e,t),function(e,t){var n=t.name,i=t.type,o=t.direction,s="forEach"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[s]=function(e,t,n){if("mixed"===i||"mixed"===this.type||i===this.type){if(1===arguments.length)return ae(!1,this,i,n=e);if(2===arguments.length){e=""+e,n=t;var r=this._nodes.get(e);if(void 0===r)throw new V("Graph.".concat(s,': could not find the "').concat(e,'" node in the graph.'));return le(!1,this.multi,"mixed"===i?this.type:i,o,r,n)}if(3===arguments.length){e=""+e,t=""+t;var a=this._nodes.get(e);if(!a)throw new V("Graph.".concat(s,': could not find the "').concat(e,'" source node in the graph.'));if(!this._nodes.has(t))throw new V("Graph.".concat(s,': could not find the "').concat(t,'" target node in the graph.'));return ce(!1,i,this.multi,o,a,t,n)}throw new B("Graph.".concat(s,": too many arguments (expecting 1, 2 or 3 and got ").concat(arguments.length,")."))}};var r="map"+n[0].toUpperCase()+n.slice(1);e.prototype[r]=function(){var e,t=Array.prototype.slice.call(arguments),n=t.pop();if(0===t.length){var o=0;"directed"!==i&&(o+=this.undirectedSize),"undirected"!==i&&(o+=this.directedSize),e=new Array(o);var r=0;t.push((function(t,i,o,s,a,l,c){e[r++]=n(t,i,o,s,a,l,c)}))}else e=[],t.push((function(t,i,o,s,r,a,l){e.push(n(t,i,o,s,r,a,l))}));return this[s].apply(this,t),e};var a="filter"+n[0].toUpperCase()+n.slice(1);e.prototype[a]=function(){var e=Array.prototype.slice.call(arguments),t=e.pop(),n=[];return e.push((function(e,i,o,s,r,a,l){t(e,i,o,s,r,a,l)&&n.push(e)})),this[s].apply(this,e),n};var l="reduce"+n[0].toUpperCase()+n.slice(1);e.prototype[l]=function(){var e,t,n=Array.prototype.slice.call(arguments);if(n.length<2||n.length>4)throw new B("Graph.".concat(l,": invalid number of arguments (expecting 2, 3 or 4 and got ").concat(n.length,")."));if("function"==typeof n[n.length-1]&&"function"!=typeof n[n.length-2])throw new B("Graph.".concat(l,": missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array."));2===n.length?(e=n[0],t=n[1],n=[]):3===n.length?(e=n[1],t=n[2],n=[n[0]]):4===n.length&&(e=n[2],t=n[3],n=[n[0],n[1]]);var i=t;return n.push((function(t,n,o,s,r,a,l){i=e(i,t,n,o,s,r,a,l)})),this[s].apply(this,n),i}}(e,t),function(e,t){var n=t.name,i=t.type,o=t.direction,s="find"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[s]=function(e,t,n){if("mixed"!==i&&"mixed"!==this.type&&i!==this.type)return!1;if(1===arguments.length)return ae(!0,this,i,n=e);if(2===arguments.length){e=""+e,n=t;var r=this._nodes.get(e);if(void 0===r)throw new V("Graph.".concat(s,': could not find the "').concat(e,'" node in the graph.'));return le(!0,this.multi,"mixed"===i?this.type:i,o,r,n)}if(3===arguments.length){e=""+e,t=""+t;var a=this._nodes.get(e);if(!a)throw new V("Graph.".concat(s,': could not find the "').concat(e,'" source node in the graph.'));if(!this._nodes.has(t))throw new V("Graph.".concat(s,': could not find the "').concat(t,'" target node in the graph.'));return ce(!0,i,this.multi,o,a,t,n)}throw new B("Graph.".concat(s,": too many arguments (expecting 1, 2 or 3 and got ").concat(arguments.length,")."))};var r="some"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[r]=function(){var e=Array.prototype.slice.call(arguments),t=e.pop();return e.push((function(e,n,i,o,s,r,a){return t(e,n,i,o,s,r,a)})),!!this[s].apply(this,e)};var a="every"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[a]=function(){var e=Array.prototype.slice.call(arguments),t=e.pop();return e.push((function(e,n,i,o,s,r,a){return!t(e,n,i,o,s,r,a)})),!this[s].apply(this,e)}}(e,t),function(e,t){var n=t.name,i=t.type,o=t.direction,s=n.slice(0,-1)+"Entries";e.prototype[s]=function(e,t){if("mixed"!==i&&"mixed"!==this.type&&i!==this.type)return P.empty();if(!arguments.length)return function(e,t){if(0===e.size)return P.empty();var n="mixed"!==t&&t!==e.type,i="undirected"===t,o=e._edges.values();return new P((function(){for(var e,t;;){if((e=o.next()).done)return e;if(t=e.value,!n||t.undirected===i)break}return{value:{edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected},done:!1}}))}(this,i);if(1===arguments.length){e=""+e;var n=this._nodes.get(e);if(!n)throw new V("Graph.".concat(s,': could not find the "').concat(e,'" node in the graph.'));return function(e,t,n){var i=P.empty();return"undirected"!==e&&("out"!==t&&void 0!==n.in&&(i=Q(i,ie(n.in))),"in"!==t&&void 0!==n.out&&(i=Q(i,ie(n.out,t?void 0:n.key)))),"directed"!==e&&void 0!==n.undirected&&(i=Q(i,ie(n.undirected))),i}(i,o,n)}if(2===arguments.length){e=""+e,t=""+t;var r=this._nodes.get(e);if(!r)throw new V("Graph.".concat(s,': could not find the "').concat(e,'" source node in the graph.'));if(!this._nodes.has(t))throw new V("Graph.".concat(s,': could not find the "').concat(t,'" target node in the graph.'));return function(e,t,n,i){var o=P.empty();return"undirected"!==e&&(void 0!==n.in&&"out"!==t&&i in n.in&&(o=Q(o,re(n.in,i))),void 0!==n.out&&"in"!==t&&i in n.out&&(t||n.key!==i)&&(o=Q(o,re(n.out,i)))),"directed"!==e&&void 0!==n.undirected&&i in n.undirected&&(o=Q(o,re(n.undirected,i))),o}(i,o,r,t)}throw new B("Graph.".concat(s,": too many arguments (expecting 0, 1 or 2 and got ").concat(arguments.length,")."))}}(e,t)}))}(xe),function(e){ue.forEach((function(t){(function(e,t){var n=t.name,i=t.type,o=t.direction;e.prototype[n]=function(e){if("mixed"!==i&&"mixed"!==this.type&&i!==this.type)return[];e=""+e;var t=this._nodes.get(e);if(void 0===t)throw new V("Graph.".concat(n,': could not find the "').concat(e,'" node in the graph.'));return function(e,t,n){if("mixed"!==e){if("undirected"===e)return Object.keys(n.undirected);if("string"==typeof t)return Object.keys(n[t])}var i=[];return pe(!1,e,t,n,(function(e){i.push(e)})),i}("mixed"===i?this.type:i,o,t)}})(e,t),function(e,t){var n=t.name,i=t.type,o=t.direction,s="forEach"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[s]=function(e,t){if("mixed"===i||"mixed"===this.type||i===this.type){e=""+e;var n=this._nodes.get(e);if(void 0===n)throw new V("Graph.".concat(s,': could not find the "').concat(e,'" node in the graph.'));pe(!1,"mixed"===i?this.type:i,o,n,t)}};var r="map"+n[0].toUpperCase()+n.slice(1);e.prototype[r]=function(e,t){var n=[];return this[s](e,(function(e,i){n.push(t(e,i))})),n};var a="filter"+n[0].toUpperCase()+n.slice(1);e.prototype[a]=function(e,t){var n=[];return this[s](e,(function(e,i){t(e,i)&&n.push(e)})),n};var l="reduce"+n[0].toUpperCase()+n.slice(1);e.prototype[l]=function(e,t,n){if(arguments.length<3)throw new B("Graph.".concat(l,": missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array."));var i=n;return this[s](e,(function(e,n){i=t(i,e,n)})),i}}(e,t),function(e,t){var n=t.name,i=t.type,o=t.direction,s=n[0].toUpperCase()+n.slice(1,-1),r="find"+s;e.prototype[r]=function(e,t){if("mixed"===i||"mixed"===this.type||i===this.type){e=""+e;var n=this._nodes.get(e);if(void 0===n)throw new V("Graph.".concat(r,': could not find the "').concat(e,'" node in the graph.'));return pe(!0,"mixed"===i?this.type:i,o,n,t)}};var a="some"+s;e.prototype[a]=function(e,t){return!!this[r](e,t)};var l="every"+s;e.prototype[l]=function(e,t){return!this[r](e,(function(e,n){return!t(e,n)}))}}(e,t),function(e,t){var n=t.name,i=t.type,o=t.direction,s=n.slice(0,-1)+"Entries";e.prototype[s]=function(e){if("mixed"!==i&&"mixed"!==this.type&&i!==this.type)return P.empty();e=""+e;var t=this._nodes.get(e);if(void 0===t)throw new V("Graph.".concat(s,': could not find the "').concat(e,'" node in the graph.'));return function(e,t,n){if("mixed"!==e){if("undirected"===e)return me(null,n,n.undirected);if("string"==typeof t)return me(null,n,n[t])}var i=P.empty(),o=new he;return"undirected"!==e&&("out"!==t&&(i=Q(i,me(o,n,n.in))),"in"!==t&&(i=Q(i,me(o,n,n.out)))),"directed"!==e&&(i=Q(i,me(o,n,n.undirected))),i}("mixed"===i?this.type:i,o,t)}}(e,t)}))}(xe);var Le=function(e){function n(t){var n=a({type:"directed"},t);if("multi"in n&&!1!==n.multi)throw new B("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if("directed"!==n.type)throw new B('DirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return e.call(this,n)||this}return t(n,e),n}(xe),_e=function(e){function n(t){var n=a({type:"undirected"},t);if("multi"in n&&!1!==n.multi)throw new B("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if("undirected"!==n.type)throw new B('UndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return e.call(this,n)||this}return t(n,e),n}(xe),Ie=function(e){function n(t){var n=a({multi:!0},t);if("multi"in n&&!0!==n.multi)throw new B("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");return e.call(this,n)||this}return t(n,e),n}(xe),Pe=function(e){function n(t){var n=a({type:"directed",multi:!0},t);if("multi"in n&&!0!==n.multi)throw new B("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if("directed"!==n.type)throw new B('MultiDirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return e.call(this,n)||this}return t(n,e),n}(xe),Ne=function(e){function n(t){var n=a({type:"undirected",multi:!0},t);if("multi"in n&&!0!==n.multi)throw new B("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if("undirected"!==n.type)throw new B('MultiUndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return e.call(this,n)||this}return t(n,e),n}(xe);function Re(e){e.from=function(t,n){var i=a({},t.options,n),o=new e(i);return o.import(t),o}}return Re(xe),Re(Le),Re(_e),Re(Ie),Re(Pe),Re(Ne),xe.Graph=xe,xe.DirectedGraph=Le,xe.UndirectedGraph=_e,xe.MultiGraph=Ie,xe.MultiDirectedGraph=Pe,xe.MultiUndirectedGraph=Ne,xe.InvalidArgumentsGraphError=B,xe.NotFoundGraphError=V,xe.UsageGraphError=U,xe}()},944:(e,t)=>{"use strict";t.Vb=void 0,t.Vb=function(e,t,n){var i=function(e,t,n){if(0===e.length||0===t.length)return 0;if(n&&!n.caseSensitive&&(e=e.toUpperCase(),t=t.toUpperCase()),e===t)return 1;for(var i=0,o=e.length,s=t.length,r=Math.floor(Math.max(o,s)/2)-1,a=new Array(o),l=new Array(s),c=0;c<o;c++)for(var u=Math.max(0,c-r);u<=Math.min(s,c+r+1);u++)if(!a[c]&&!l[u]&&e[c]===t[u]){++i,a[c]=l[u]=!0;break}if(0===i)return 0;var h=0,d=0;for(c=0;c<o;c++)if(a[c]){for(;!l[d];)d++;e.charAt(c)!==t.charAt(d++)&&h++}return(i/o+i/s+(i-(h/=2))/i)/3}(e,t,n),o=0;if(i>.7){for(var s=Math.min(e.length,t.length),r=0;e[r]===t[r]&&r<4&&r<s;)++o,r++;i+=.1*o*(1-i)}return i}},7106:e=>{"use strict";var t=e.exports=function(e,t,i){"function"==typeof t&&(i=t,t={}),n(t,"function"==typeof(i=t.cb||i)?i:i.pre||function(){},i.post||function(){},e,"",e)};function n(e,i,o,s,r,a,l,c,u,h){if(s&&"object"==typeof s&&!Array.isArray(s)){for(var d in i(s,r,a,l,c,u,h),s){var p=s[d];if(Array.isArray(p)){if(d in t.arrayKeywords)for(var m=0;m<p.length;m++)n(e,i,o,p[m],r+"/"+d+"/"+m,a,r,d,s,m)}else if(d in t.propsKeywords){if(p&&"object"==typeof p)for(var g in p)n(e,i,o,p[g],r+"/"+d+"/"+g.replace(/~/g,"~0").replace(/\//g,"~1"),a,r,d,s,g)}else(d in t.keywords||e.allKeys&&!(d in t.skipKeywords))&&n(e,i,o,p,r+"/"+d,a,r,d,s)}o(s,r,a,l,c,u,h)}}t.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0},t.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},t.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},t.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0}},5072: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 s={},r=[],a=0;a<e.length;a++){var l=e[a],c=i.base?l[0]+i.base:l[0],u=s[c]||0,h="".concat(c," ").concat(u);s[c]=u+1;var d=n(h),p={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==d)t[d].references++,t[d].updater(p);else{var m=o(p,i);i.byIndex=a,t.splice(a,0,{identifier:h,updater:m,references:1})}r.push(h)}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 s=i(e=e||[],o=o||{});return function(e){e=e||[];for(var r=0;r<s.length;r++){var a=n(s[r]);t[a].references--}for(var l=i(e,o),c=0;c<s.length;c++){var u=n(s[c]);0===t[u].references&&(t[u].updater(),t.splice(u,1))}s=l}}},7659: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}},5056:(e,t,n)=>{"use strict";e.exports=function(e){var t=n.nc;t&&e.setAttribute("nonce",t)}},7825: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 s=n.sourceMap;s&&"undefined"!=typeof btoa&&(i+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(s))))," */")),t.styleTagTransform(i,e,t.options)}(t,e,n)},remove:function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(t)}}}},1113: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))}}},8926:(e,t,n)=>{"use strict";n.d(t,{PackageFunctions:()=>lo,_package:()=>ro});var i,o,s=n(4328),r=n(7389),a=n(6082),l=n(684),c=n(9039);(o=i||(i={})).EUCLIDEAN="EUCLIDEAN",o.MANHATTAN="MANHATTAN";var u=n(1858),h=n(5072),d=n.n(h),p=n(7825),m=n.n(p),g=n(7659),f=n.n(g),y=n(5056),b=n.n(y),w=n(540),v=n.n(w),A=n(1113),C=n.n(A),T=n(7939),S={};S.styleTagTransform=C(),S.setAttributes=b(),S.insert=f().bind(null,"head"),S.domAPI=m(),S.insertStyleElement=v(),d()(T.A,S),T.A&&T.A.locals&&T.A.locals;var E=function(e,t,n,i){return new(n||(n=Promise))((function(o,s){function r(e){try{l(i.next(e))}catch(e){s(e)}}function a(e){try{l(i.throw(e))}catch(e){s(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,a)}l((i=i.apply(e,t||[])).next())}))};let M=null,x=null;function L(e,t){return e&&""!=e?e:t}n(2780);class _{constructor(){this.learningRate={uiName:"Learninig rate",value:1,tooltip:"The initial learning rate for the embedding optimization"},this.nEpochs={uiName:"Epochs",value:0,tooltip:"The number of epochs to optimize embeddings via SGD. Computed automatically if set to 0"},this.nNeighbors={uiName:"Neighbors",value:15,tooltip:"The number of nearest neighbors to construct the fuzzy manifold"},this.spread={uiName:"Spread",value:1,tooltip:"The effective scale of embedded points, used with min distance to control \n the clumped/dispersed nature of the embedding"},this.minDist={uiName:"Min distance",value:.1,tooltip:"The effective minimum distance between embedded points, \n used with spread to control the clumped/dispersed nature of the embedding"},this.randomSeed={uiName:"Random seed",value:null,tooltip:"Random seed",type:"string"},this.useWebGPU={uiName:"Use WebGPU",value:!1,tooltip:"Use WebGPU for Distance and UMAP computations",type:"boolean",disableTooltip:"WebGPU is not available"},function(){return E(this,void 0,void 0,(function*(){if(!navigator.gpu)return console.error("WebGPU is not supported in this browser"),null;if(!M&&(M=yield navigator.gpu.requestAdapter(),null==M))return null;let e=null;return"info"in M&&(e=M.info),e?L(e.description,L(e.vendor,"No GPU description available")):"No GPU description available"}))}().then((e=>{e?(this.useWebGPU.tooltip+=` (${e})`,this.useWebGPU.value=!0):(this.useWebGPU.value=!1,this.useWebGPU.disable=!0)}))}}class I{constructor(){this.epsilon={uiName:"Epsilon",value:10,tooltip:"Epsilon is learning rate"},this.perplexity={uiName:"Perplexity",value:30,tooltip:"Roughly how many neighbors each point influences"}}}Promise.resolve(),n(934),n(8903);const P="MCL";var N=n(1991),R=n.n(N);a.SEMTYPE.MOLECULE,a.SEMTYPE.MACROMOLECULE;class ${constructor(){this.epsilon={uiName:"Epsilon",value:.01,tooltip:"Minimum distance between cluster points",min:0,max:2,step:.005},this.minPts={uiName:"Minimum points",value:4,tooltip:"Minimum number of points in cluster",min:1,max:1e3,step:1}}}class O{get algorithmOptions(){const e=this.methodsParams[this.methodInput.value],t={};return Object.keys(e).forEach((n=>{null!=e[n].value&&(t[n]=e[n].value)})),t}get dbScanOptions(){return{dbScanEpsilon:this.dbScanParams.epsilon.value??.01,dbScanMinPts:this.dbScanParams.minPts.value??4}}constructor(e={}){this.editorSettings={},this.plotEmbeddingsInput=r.input.bool("Plot embeddings",{value:!0}),this.clusterEmbeddingsInput=r.input.bool("Cluster embeddings",{value:!0}),this.preprocessingFunctionInputRoot=null,this.methods=[c.c.UMAP,c.c.T_SNE],this.columnFunctionsMap={},this.supportedFunctions={},this.availableMetrics=[],this.methodSettingsDiv=r.inputs([]),this.dbScanSettingsDiv=r.inputs([]),this.preprocessingFuncSettingsDiv=r.inputs([]),this.preprocessingFunctionSettings={},this.methodsParams={[c.c.UMAP]:new _,[c.c.T_SNE]:new I},this.dbScanParams=new $,this.editorSettings=e,this.editorSettings.enableMCL&&this.methods.push(P),a.Func.find({tags:[l.GP]}).forEach((e=>{const t=e.options.get(l.n3)??"",n=e.friendlyName??e.name,i=e.options.get(l.C0)??"",o=e.options.get(l._X)??"",s=e.options.get(l.Gi)??"";this.editorSettings.semtype&&!t.includes(this.editorSettings.semtype)||this.editorSettings.type&&!i.includes(this.editorSettings.type)||this.editorSettings.units&&!o.includes(this.editorSettings.units)||(this.supportedFunctions[n]={func:e,semTypes:t?t.split(","):[],types:i?i.split(","):[],units:o?o.split(","):[],distanceFunctions:s?s.split(","):[]})})),this.tableInput=r.input.table("Table",{value:s.shell.tv.dataFrame,items:s.shell.tables,onValueChanged:()=>{this.onTableInputChanged()}}),this.onTableInputChanged(),this.regenerateColInput(),this.onColumnInputChanged();let t=!1,n=!1;this.methodInput=r.input.choice("Method",{value:c.c.UMAP,items:this.methods,onValueChanged:e=>{t&&this.createAlgorithmSettingsDiv(this.methodSettingsDiv,this.methodsParams[e])}}),this.methodSettingsIcon=r.icons.settings((()=>{t=!t,t?this.createAlgorithmSettingsDiv(this.methodSettingsDiv,this.methodsParams[this.methodInput.value]):r.empty(this.methodSettingsDiv)}),"Modify methods parameters"),this.dbScanSettingsIcon=r.icons.settings((()=>{n=!n,n?this.createAlgorithmSettingsDiv(this.dbScanSettingsDiv,this.dbScanParams):r.empty(this.dbScanSettingsDiv)}),"Modify clustering parameters"),this.clusterEmbeddingsInput.classList.add("ml-dim-reduction-settings-input"),this.clusterEmbeddingsInput.root.prepend(this.dbScanSettingsIcon),this.methodInput.root.classList.add("ml-dim-reduction-settings-input"),this.methodInput.root.prepend(this.methodSettingsIcon),this.methodSettingsDiv=r.inputs([]);const i=this.columnFunctionsMap[this.colInput.value.name];this.preprocessingFunctionInput=r.input.choice("Encoding function",{value:i[0],items:i,onValueChanged:()=>{this.onPreprocessingFunctionChanged()}});let o=!1;this.preprocessingFunctionInputRoot||(this.preprocessingFunctionInputRoot=this.preprocessingFunctionInput.root,o=!0),o||(r.empty(this.preprocessingFunctionInputRoot),Array.from(this.preprocessingFunctionInput.root.children).forEach((e=>this.preprocessingFunctionInputRoot.append(e)))),this.preprocessingFunctionInputRoot.classList.add("ml-dim-reduction-settings-input");let u=!1;this.preprocessingFuncSettingsIcon=r.icons.settings((async()=>{u?r.empty(this.preprocessingFuncSettingsDiv):await this.createPreprocessingFuncParamsDiv(this.preprocessingFuncSettingsDiv,this.supportedFunctions[this.preprocessingFunctionInput.value].func),u=!u}),"Modify encoding function parameters"),this.preprocessingFunctionInputRoot.prepend(this.preprocessingFuncSettingsIcon),this.similarityMetricInput=r.input.choice("Similarity",{value:"",items:[]}),this.similarityMetricInput.nullable=!1,this.similarityMetricInputRoot||(this.similarityMetricInputRoot=this.similarityMetricInput.root),this.onPreprocessingFunctionChanged()}getColInput(){const e=this.tableInput.value?.columns.toList().find((e=>!!this.columnFunctionsMap[e.name]))??null,t=r.input.column("Column",{table:this.tableInput.value,value:e,nullable:!1,onValueChanged:()=>this.onColumnInputChanged(),filter:e=>!!this.columnFunctionsMap[e.name]});return this.colInputRoot||(this.colInputRoot=t.root),t}regenerateColInput(){let e=!1;this.colInputRoot&&(e=!0,r.empty(this.colInputRoot)),this.colInput=this.getColInput(),e&&Array.from(this.colInput.root.children).forEach((e=>this.colInputRoot.append(e))),this.onColumnInputChanged()}onTableInputChanged(){const e=this.tableInput.value;if(!e)return;const t=()=>{this.columnFunctionsMap={},e.columns.toList().forEach((e=>{Object.keys(this.supportedFunctions).forEach((t=>{const n=this.supportedFunctions[t].semTypes,i=this.supportedFunctions[t].types,o=this.supportedFunctions[t].units,s=!n.length||e.semType&&n.includes(e.semType),r=!i.length||i.includes(e.type),a=!o.length||e.meta.units&&o.includes(e.meta.units);s&&r&&a&&(this.columnFunctionsMap[e.name]||(this.columnFunctionsMap[e.name]=[]),this.columnFunctionsMap[e.name].push(t))}))})),this.regenerateColInput()};t(),R()(e.columns).some((e=>!!e.getTag(a.Tags.SemanticDetectionDuration)))||e.meta.detectSemanticTypes().then((()=>{t()}))}onColumnInputChanged(){const e=this.colInput.value;if(!e)return;const t=this.columnFunctionsMap[e.name];this.preprocessingFunctionInput=r.input.choice("Preprocessing function",{value:t[0],items:t,onValueChanged:()=>{this.onPreprocessingFunctionChanged()}});let n=!1;this.preprocessingFunctionInputRoot||(this.preprocessingFunctionInputRoot=this.preprocessingFunctionInput.root,n=!0),n||(r.empty(this.preprocessingFunctionInputRoot),Array.from(this.preprocessingFunctionInput.root.children).forEach((e=>this.preprocessingFunctionInputRoot.append(e)))),this.onPreprocessingFunctionChanged()}onPreprocessingFunctionChanged(){r.empty(this.preprocessingFuncSettingsDiv),this.preprocessingFunctionSettings={};const e=this.preprocessingFunctionInput.value,t=this.supportedFunctions[e].distanceFunctions;this.availableMetrics=[...t],this.similarityMetricInput=r.input.choice("Similarity",{value:this.availableMetrics[0],items:this.availableMetrics}),this.similarityMetricInput.nullable=!1,this.similarityMetricInputRoot||(this.similarityMetricInputRoot=this.similarityMetricInput.root),r.empty(this.similarityMetricInputRoot),Array.from(this.similarityMetricInput.root.children).forEach((e=>this.similarityMetricInputRoot.append(e))),this.preprocessingFuncSettingsIcon&&(this.supportedFunctions[e].func.inputs.length<3?this.preprocessingFuncSettingsIcon.style.display="none":this.preprocessingFuncSettingsIcon.style.display="flex")}createAlgorithmSettingsDiv(e,t){return r.empty(e),Object.keys(t).forEach((n=>{const i=t[n],o="string"===i.type?r.input.string(i.uiName,{value:i.value??"",onValueChanged:e=>{i.value=e}}):"boolean"===i.type?r.input.bool(i.uiName,{value:i.value??!1,onValueChanged:e=>{i.value=e}}):r.input.float(i.uiName,{value:i.value,onValueChanged:e=>{i.value=e}});e.append(o.root),i.disable?(o.enabled=!1,r.tooltip.bind(o.input??o.root,i.disableTooltip??"")):r.tooltip.bind(o.input??o.root,i.tooltip)})),e}async createPreprocessingFuncParamsDiv(e,t){if(r.empty(e),t.inputs.length<3)return r.div();const n=t.prepare(),i=await n.buildEditor(r.div());for(let o=2;o<t.inputs.length;o++){const s=t.inputs[o];(this.preprocessingFunctionSettings[s.name]||n.inputParams[t.inputs[o].name].value||s.defaultValue)&&(this.preprocessingFunctionSettings[s.name]=this.preprocessingFunctionSettings[s.name]??n.inputParams[s.name].value??s.defaultValue);const r=i.find((e=>e.property.name===s.name));r&&(null!==this.preprocessingFunctionSettings[s.name]&&void 0!==this.preprocessingFunctionSettings[s.name]&&(r.value=this.preprocessingFunctionSettings[s.name]),r.onChanged.subscribe((e=>{this.preprocessingFunctionSettings[s.name]=e})),e.append(r.root))}return e}getEditor(){return r.div([this.tableInput,this.colInputRoot,this.preprocessingFunctionInputRoot,this.preprocessingFuncSettingsDiv,this.methodInput,this.methodSettingsDiv,this.similarityMetricInputRoot,this.plotEmbeddingsInput,this.clusterEmbeddingsInput,this.dbScanSettingsDiv],{style:{minWidth:"420px"},classes:"ui-form dim-reduction-dialog-form"})}getParams(){return{table:this.tableInput.value,col:this.colInput.value,methodName:this.methodInput.value,preprocessingFunction:this.supportedFunctions[this.preprocessingFunctionInput.value].func,similarityMetric:this.similarityMetricInput.value,plotEmbeddings:this.plotEmbeddingsInput.value,clusterEmbeddings:this.clusterEmbeddingsInput.value,options:{...this.algorithmOptions,...this.dbScanOptions,preprocessingFuncArgs:this.preprocessingFunctionSettings??{}}}}getInput(){return{table:this.tableInput.value.name,col:this.colInput.value.name,methodName:this.methodInput.value,preprocessingFunction:this.preprocessingFunctionInput.value,similarityMetric:this.similarityMetricInput.value,plotEmbeddings:this.plotEmbeddingsInput.value,clusterEmbeddings:this.clusterEmbeddingsInput.value,options:{...this.algorithmOptions,...this.dbScanOptions,preprocessingFuncArgs:this.preprocessingFunctionSettings??{}}}}getStringInput(){return JSON.stringify(this.getInput())}async applyStringInput(e){try{const t=JSON.parse(e);await this.applyInput(t)}catch(e){s.shell.error("Error applying input from history"),console.error(e)}}async applyInput(e){try{const t=this.tableInput.value?.col(e.col);if(!t)throw new Error("Column not found");this.colInput.value=t,this.preprocessingFunctionInput.value=e.preprocessingFunction,this.similarityMetricInput.value=e.similarityMetric,this.plotEmbeddingsInput.value=e.plotEmbeddings,this.clusterEmbeddingsInput.value=e.clusterEmbeddings;const n=this.methodsParams[this.methodInput.value];Object.keys(n).forEach((t=>{null!=e.options[t]&&(this.methodsParams[e.methodName][t].value=e.options[t])})),this.methodInput.value=e.methodName,this.preprocessingFunctionSettings=e.options.preprocessingFuncArgs,await this.createPreprocessingFuncParamsDiv(this.preprocessingFuncSettingsDiv,this.supportedFunctions[this.preprocessingFunctionInput.value].func)}catch(e){s.shell.error("Error applying input from history"),console.error(e)}}}var H=n(9713),k=n(6295);const F=e=>null==e;function D(e,t,n,i){if(n>e[e.length-1])return;const o=e.findIndex((e=>n<e));e.pop(),e.splice(o,0,n),t.pop(),t.splice(o,0,i)}class G{constructor(e=!0,t=!0){const i=navigator.hardwareConcurrency;this._workerCount=e?Math.max(i-2,1):1,this._workers=new Array(this._workerCount).fill(null).map((()=>new Worker(new URL(n.p+n.u(793),n.b)))),this._terminateOnComplete=t}async calc(e,t,n=!0,o){return await this.calcMulti([e],[t],n,[o??{}],[1],i.MANHATTAN)}async calcMulti(e,t,n=!0,o=[{}],s=[1],r=i.MANHATTAN){if(e.length<1)throw new Error("values must contain at least one array");if(t.length!==e.length||o.length!==e.length||s.length!==e.length)throw new Error("values, fnNames, weights and opts must have the same length");return new Promise((async(i,a)=>{try{const a=e[0].length,l=new Array(this._workerCount),c=a*(a-1)/2;this._workerCount=Math.min(this._workerCount,c);const u=c/this._workerCount,h=new Float32Array(c);let d=0,p=1,m=0,g=Number.MIN_VALUE;for(let n=0;n<this._workerCount;n++){const i=Math.floor(n*u),f=n===this._workerCount-1?c:Math.floor((n+1)*u),y=d,b=p;n!==this._workerCount-1&&(d=a-2-Math.floor(Math.sqrt(-8*f+4*a*(a-1)-7)/2-.5),p=f-a*d+Math.floor((d+1)*(d+2)/2)),this._workers[n].postMessage({values:e,fnNames:t,startRow:y,startCol:b,chunckSize:f-i,opts:o,weights:s,aggregationMethod:r}),l[n]=new Promise(((e,t)=>{this._workers[n].onmessage=({data:{error:o,distanceMatrixData:s,min:r,max:a}})=>{this._terminateOnComplete&&setTimeout((()=>this._workers[n].terminate())),o?t(o):(h.set(s,i),r<m&&(m=r),a>g&&(g=a),e())}}))}await Promise.all(l),n&&h.forEach(((e,t)=>{h[t]=(e-m)/(g-m)})),i(h)}catch(e){a(e)}}))}terminate(){this._workers.forEach((e=>e.terminate()))}}class B{constructor(){this._workerCount=Math.max(navigator.hardwareConcurrency-2,1)}static pruneSparseMatrix(e,t=1e6){const n=200,i=new Uint32Array(n),o=e.distance.length,s=e.distance;for(let e=0;e<o;e++)i[Math.floor(s[e]*n)]++;let r=0,a=0;for(let e=0;e<n&&(r+=i[e],a=e,!(r>=t));e++);const l=new Uint32Array(r),c=new Uint32Array(r),u=new Float32Array(r),h=e.i,d=e.j;let p=0;const m=(a+1)/n;for(let e=0;e<o;e++)s[e]<m&&(l[p]=h[e],c[p]=d[e],u[p]=s[e],p++);return{i:l,j:c,distance:u}}async calcMultiColumn(e,t,o,s=[{}],r=[1],a=i.EUCLIDEAN){const l=e[0].length*(e[0].length-1)/2,c=Math.floor(l/this._workerCount),u=e[0].length>2e4?await this.getMinimalThreshold(e,t,s,r,a):0;o<u&&(console.log(`using threshold ${u}`),o=u),s.forEach(((e,t)=>s[t].threshold=o));const h=new Array(this._workerCount),d=new Array(this._workerCount).fill(null).map((()=>new Worker(new URL(n.p+n.u(111),n.b))));for(let n=0;n<this._workerCount;n++)h[n]=new Promise(((i,u)=>{const h=n*c,p=n===this._workerCount-1?l:(n+1)*c;p<=h&&i({i:new Int32Array(0),j:new Int32Array(0),distance:new Float32Array(0),idx:n}),d[n].postMessage({values:e,startIdx:h,endIdx:p,threshold:o,fnNames:t,opts:s,weights:r,aggregationMethod:a}),d[n].onmessage=({data:{error:e,i:t,j:o,distance:s}})=>{e?(d[n].terminate(),u(e)):(d[n].terminate(),i({i:t,j:o,distance:s,idx:n}))}}));const p=await Promise.all(h),m=p.reduce(((e,t)=>e+t.i.length),0),g=new Int32Array(m),f=new Int32Array(m),y=new Float32Array(m);let b=0;for(const e of p)g.set(e.i,b),f.set(e.j,b),y.set(e.distance,b),b+=e.i.length;return{i:g,j:f,distance:y}}async calc(e,t,n,i={}){return await this.calcMultiColumn([e],[t],n,[i],[1])}async getKNN(e,t,n=15,i={}){return await this.multiColumnKNN([e],[t],n,[i],[1])}async getThresholdKNN(e,t,n=.8,i={}){return await this.multiColumnThresholdKnn([e],[t],n,[i],[1])}async multiColumnThresholdKnn(e,t,o=.8,s,r,a=i.EUCLIDEAN){if(e.length!==t.length||e.length!==s.length||e.length!==r.length)throw new Error("values, distance functions, options and weights arrays should have the same length");if(e.some((t=>t.length!==e[0].length)))throw new Error("all values arrays should have the same length");const l=e[0].length*(e[0].length-1)/2,c=Math.floor(l/this._workerCount),u=new Array(this._workerCount),h=new Array(this._workerCount).fill(null).map((()=>new Worker(new URL(n.p+n.u(603),n.b))));for(let n=0;n<this._workerCount;n++)u[n]=new Promise(((i,u)=>{const d=n*c,p=n===this._workerCount-1?l:(n+1)*c;p<=d&&i({knnDistances:new Array(0),knnIndexes:new Array(0)}),h[n].postMessage({values:e,startIdx:d,endIdx:p,fnNames:t,opts:s,threshold:o,weights:r,aggregationMethod:a}),h[n].onmessage=({data:{error:e,knnDistances:t,knnIndexes:o}})=>{e?(h[n].terminate(),u(e)):(h[n].terminate(),i({knnDistances:t,knnIndexes:o}))}}));const d=await Promise.all(u),p=new Int32Array(e[0].length);for(const t of d)for(let n=0;n<e[0].length;++n)p[n]+=t.knnIndexes[n]?.length??0;const m={knnDistances:new Array(e[0].length).fill(null).map(((e,t)=>new Array(p[t]))),knnIndexes:new Array(e[0].length).fill(null).map(((e,t)=>new Array(p[t])))};for(const t of d)for(let n=0;n<e[0].length;++n)for(let e=0;e<(t.knnDistances[n]?.length??0);++e)m.knnDistances[n][p[n]-1]=t.knnDistances[n][e],m.knnIndexes[n][p[n]-1]=t.knnIndexes[n][e],p[n]-=1;return m}async multiColumnSingleValueKNN(e,t,o,s=15,r,a,l=i.EUCLIDEAN){if(e.length!==o.length||e.length!==r.length||e.length!==a.length)throw new Error("values, distance functions, options and weights arrays should have the same length");if(e.some((t=>t.length!==e[0].length)))throw new Error("all values arrays should have the same length");const c=new Array(this._workerCount).fill(null).map((()=>new Worker(new URL(n.p+n.u(810),n.b)))),u=new Array(this._workerCount),h=e[0].length,d=e.map((e=>e[t])),p=Math.ceil(h/this._workerCount);for(let t=0;t<this._workerCount;t++)u[t]=new Promise(((n,i)=>{const u=t*p,m=t===this._workerCount-1?h:(t+1)*p;m<=u&&n({knnDistances:new Array(0),knnIndexes:new Array(0)}),c[t].postMessage({values:e.map((e=>e.slice(u,m))),target:d,fnNames:o,opts:r,nNeighbours:s,weights:a,aggregationMethod:l,startIdx:u}),c[t].onmessage=({data:{error:e,knnDistances:o,knnIndexes:s}})=>{e?(c[t].terminate(),i(e)):(c[t].terminate(),n({knnDistances:o,knnIndexes:s}))}}));const m=await Promise.all(u),g={knnDistances:new Array(s).fill(99999),knnIndexes:new Array(s).fill(-1)};for(const e of m)for(let t=0;t<(e.knnDistances?.length??0);++t)D(g.knnDistances,g.knnIndexes,e.knnDistances[t],e.knnIndexes[t]);return g}async multiColumnKNN(e,t,o=15,s,r,a=i.EUCLIDEAN){if(e.length!==t.length||e.length!==s.length||e.length!==r.length)throw new Error("values, distance functions, options and weights arrays should have the same length");if(e.some((t=>t.length!==e[0].length)))throw new Error("all values arrays should have the same length");const l=e[0].length*(e[0].length-1)/2,c=Math.floor(l/this._workerCount),u=new Array(this._workerCount),h=new Array(this._workerCount).fill(null).map((()=>new Worker(new URL(n.p+n.u(950),n.b))));for(let n=0;n<this._workerCount;n++)u[n]=new Promise(((i,u)=>{const d=n*c,p=n===this._workerCount-1?l:(n+1)*c;p<=d&&i({knnDistances:new Array(0),knnIndexes:new Array(0)}),h[n].postMessage({values:e,startIdx:d,endIdx:p,fnNames:t,opts:s,nNeighbours:o,weights:r,aggregationMethod:a}),h[n].onmessage=({data:{error:e,knnDistances:t,knnIndexes:o}})=>{e?(h[n].terminate(),u(e)):(h[n].terminate(),i({knnDistances:t,knnIndexes:o}))}}));const d=await Promise.all(u),p={knnDistances:new Array(e[0].length).fill(null).map((()=>new Array(o).fill(99999))),knnIndexes:new Array(e[0].length).fill(null).map((()=>new Array(o).fill(-1)))};for(const t of d)for(let n=0;n<e[0].length;++n)for(let e=0;e<(t.knnDistances[n]?.length??0);++e)D(p.knnDistances[n],p.knnIndexes[n],t.knnDistances[n][e],t.knnIndexes[n][e]);return p}async getSampleDistances(e,t,o=[],s,r=i.EUCLIDEAN){const a=new Array(this._workerCount).fill(null).map((()=>new Worker(new URL(n.p+n.u(778),n.b))));try{const n=e[0].length*(e[0].length-1)/2,i=Math.floor(n/this._workerCount),l=1e6,c=Math.max(Math.min(n/1e3,l),Math.min(n,l)),u=Math.floor(c/this._workerCount),h=new Array(this._workerCount);for(let l=0;l<this._workerCount;l++)h[l]=new Promise(((c,h)=>{const d=l*i,p=l===this._workerCount-1?n:(l+1)*i;a[l].postMessage({values:e,startIdx:d,endIdx:p,sampleLength:u,fnNames:t,opts:o,weights:s,aggregationMethod:r}),a[l].onmessage=({data:{error:e,distance:t}})=>{a[l].terminate(),e?h(e):c({distance:t})}}));const d=await Promise.all(h),p=d.reduce(((e,t)=>e+t.distance.length),0),m=new Float32Array(p);let g=0;for(const e of d)m.set(e.distance,g),g+=e.distance.length;return m.sort(),m}catch(e){return a?.forEach((e=>e?.terminate())),console.error(e),new Float32Array(1).fill(.5)}}async getMinimalThreshold(e,t,n=[],o,s=i.EUCLIDEAN){try{const i=e.length*(e.length-1)/2,r=await this.getSampleDistances(e,t,n,o,s);return 1-r[Math.floor(7e7/i*r.length)]}catch(e){return console.error(e),.5}}static calcSync(e,t,n,i){const o=[],s=[],r=[];let a=0,l=0,c=0;const u=e.length*(e.length-1)/2;for(;a<u;){const t=F(e[l])||F(e[c])?1:n(e[l],e[c]);1-t>=i&&(o.push(l),s.push(c),r.push(t)),a++,c++,c===e.length&&(l++,c=l+1)}return{i:new Int32Array(o),j:new Int32Array(s),distance:new Float32Array(r)}}}var V,U,W=n(8774);(U=V||(V={})).none="none",U.bold="bold",U.dashed="dashed";class q{get currentLineId(){return this._currentLineIdx}set currentLineId(e){e!==this._currentLineIdx&&(this._currentLineIdx=e,this.sp.render(this.ctx))}set linesToRender(e){this.updateLines(e),this.sp.render(this.ctx)}set linesVisibility(e){this.visibility=e,this.sp.render(this.ctx)}constructor(e,t,n,i,o=V.none){var s;this._currentLineIdx=-1,this.lineClicked=new u.Subject,this.lineHover=new u.Subject,this.mouseOverLineId=-1,this.arrowWidth=15,this.sp=e,this.xAxisCol=this.sp.dataFrame.columns.byName(t),this.yAxisCol=this.sp.dataFrame.columns.byName(n),this.canvas=this.sp.getInfo().canvas,this.ctx=this.canvas.getContext("2d"),this.currentLineStyle=o,this.updateLines(i),this.visibility=null!==(s=i.visibility)&&void 0!==s?s:new W.A(this.lines.from.length),i.visibility||this.visibility.setAll(!0,!1),i.arrowSize&&(this.arrowWidth=i.arrowSize),this.canvas.onmousedown=e=>{var t;(null===(t=this.lines)||void 0===t?void 0:t.skipMouseOverDetection)&&(this.mouseOverLineId=this.checkCoordsOnLine(e.offsetX,e.offsetY)),-1!==this.mouseOverLineId&&this.lineClicked.next({x:e.clientX,y:e.clientY,id:this.mouseOverLineId,event:e})},this.canvas.onmousemove=e=>{var t;this.mouseOverLineId=(null===(t=this.lines)||void 0===t?void 0:t.skipMouseOverDetection)?-1:this.checkCoordsOnLine(e.offsetX,e.offsetY),-1!==this.mouseOverLineId&&this.lineHover.next({x:e.clientX,y:e.clientY,id:this.mouseOverLineId,event:e})},e.onEvent("d4-before-draw-scene").subscribe((e=>{this.renderLines()}))}updateLines(e){this.lines=e,this.multipleLinesCounts=new Uint8Array(this.lines.from.length),e.skipMultiLineCalculation?this.multipleLinesCounts.fill(0):this.createMultiLinesIndices()}renderLines(){var e,t,n,i,o,s,r,a,l,c,u,h,d,p,m,g,f;const y=this.lines.colors||this.lines.widths||this.lines.opacities||this.lines.drawArrowsArr;y||(this.ctx.lineWidth=null!==(e=this.lines.width)&&void 0!==e?e:1,this.ctx.strokeStyle=`rgba(${null!==(t=this.lines.color)&&void 0!==t?t:"0,128,0"},${null!==(n=this.lines.opacity)&&void 0!==n?n:1})`);const b=this.sp.dataFrame.filter,w=Math.pow(null!==(i=this.lines.shortLineThreshold)&&void 0!==i?i:5,2);for(let e=0;e<this.lines.from.length;e++)if(b.get(this.lines.from[e])&&b.get(this.lines.to[e])&&this.visibility.getBit(e)){let t=0;const n=this.sp.getMarkerSize(this.lines.from[e])/2,i=this.sp.getMarkerSize(this.lines.to[e])/2,b=this.sp.pointToScreen(this.lines.from[e]);let v=null==b?void 0:b.x,A=null==b?void 0:b.y;const C=this.sp.pointToScreen(this.lines.to[e]);let T=null==C?void 0:C.x,S=null==C?void 0:C.y;const E=Math.min(this.sp.viewBox.width,this.sp.viewBox.height);if(this.ctx.beginPath(),v&&A&&T&&S&&Math.hypot(T-v,S-A)/E>.01){if(y){const t=(null===(o=this.lines.colors)||void 0===o?void 0:o[e])?null===(s=this.lines.colors)||void 0===s?void 0:s[e]:null!==(r=this.lines.color)&&void 0!==r?r:"0,128,0",n=(null===(a=this.lines.opacities)||void 0===a?void 0:a[e])?null===(l=this.lines.opacities)||void 0===l?void 0:l[e]:null!==(c=this.lines.opacity)&&void 0!==c?c:1;this.ctx.strokeStyle=`rgba(${t},${n})`,this.ctx.lineWidth=(null===(u=this.lines.widths)||void 0===u?void 0:u[e])?null===(h=this.lines.widths)||void 0===h?void 0:h[e]:null!==(d=this.lines.width)&&void 0!==d?d:1}e===this._currentLineIdx&&this.toggleCurrentLineStyle(!0);const b=this.multipleLinesCounts[e];let C=null;if(b){t=this.getLineLength(v,A,T,S);const o=this.getPointOnDistance(v,A,T,S,i,t),s=this.getPointOnDistance(T,S,v,A,n,t);v=o.x,A=o.y,T=s.x,S=s.y,C=this.lines.from[e]>this.lines.to[e]?this.findControlPoint(b,v,A,T,S,e):this.findControlPoint(b,T,S,v,A,e),this.ctx.moveTo(v,A),this.ctx.quadraticCurveTo(C.x,C.y,T,S)}else(!this.lines.skipShortLines||Math.pow(T-v,2)+Math.pow(S-A,2)>w)&&(this.ctx.moveTo(v,A),this.ctx.lineTo(T,S));if((null!==(p=this.lines.drawArrows)&&void 0!==p?p:null===(m=this.lines.drawArrowsArr)||void 0===m?void 0:m.getBit(e))&&(t||(t=this.getLineLength(v,A,T,S)),t>this.arrowWidth)){const e=b?null:this.getPointOnDistance(v,A,T,S,i,t),n=b?C.x:v,o=b?C.y:A;this.canvasArrow(this.ctx,null!==(g=null==e?void 0:e.x)&&void 0!==g?g:v,null!==(f=null==e?void 0:e.y)&&void 0!==f?f:A,n,o)}this.ctx.stroke(),this.ctx.closePath(),e===this._currentLineIdx&&this.toggleCurrentLineStyle(!1)}}this.fillLeftBottomRect()}toggleCurrentLineStyle(e){switch(this.currentLineStyle){case V.bold:e?this.ctx.lineWidth+=2:this.ctx.lineWidth-=2;break;case V.dashed:e?this.ctx.setLineDash([5,5]):this.ctx.setLineDash([]);break;default:return}}fillLeftBottomRect(){const e=new Path2D;e.rect(this.sp.yAxisBox.minX,this.sp.yAxisBox.maxY,this.sp.yAxisBox.width,this.sp.xAxisBox.height),this.ctx.fillStyle="white",this.ctx.beginPath(),this.ctx.fill(e),this.ctx.closePath()}createMultiLinesIndices(){const e={};for(let t=0;t<this.lines.from.length;t++){let n=0,i=0;this.lines.from[t]<this.lines.to[t]?(n=this.lines.from[t],i=this.lines.to[t]):(n=this.lines.to[t],i=this.lines.from[t]),e[`${n}|${i}`]?(1===e[`${n}|${i}`].length&&(this.multipleLinesCounts[e[`${n}|${i}`][0]]=1,e[`${n}|${i}`].push(1)),this.multipleLinesCounts[t]=++e[`${n}|${i}`][1]):e[`${n}|${i}`]=[t]}}checkCoordsOnLine(e,t){let n=-1,i=null,o=null;const s=this.sp.dataFrame.filter;for(let r=0;r<this.lines.from.length;r++)if(s.get(this.lines.from[r])&&s.get(this.lines.to[r])&&this.visibility.getBit(r)){const s=this.sp.getMarkerSize(this.lines.from[r])/2,a=this.sp.getMarkerSize(this.lines.to[r])/2,l=this.sp.worldToScreen(this.xAxisCol.get(this.lines.from[r]),this.yAxisCol.get(this.lines.from[r])),c=this.sp.worldToScreen(this.xAxisCol.get(this.lines.to[r]),this.yAxisCol.get(this.lines.to[r]));if(this.multipleLinesCounts[r]){const n=this.getLineLength(l.x,l.y,c.x,c.y),i=this.getPointOnDistance(l.x,l.y,c.x,c.y,a,n),u=this.getPointOnDistance(c.x,c.y,null==l?void 0:l.x,null==l?void 0:l.y,s,n),h=this.lines.from[r]>this.lines.to[r]?this.findControlPoint(this.multipleLinesCounts[r],i.x,i.y,u.x,u.y,r):this.findControlPoint(this.multipleLinesCounts[r],u.x,u.y,i.x,i.y,r);o=this.calculateDistToCurveLine(r,e,t,i,u,h)}else o=this.calculateDistToStraightLine(e,t,l,c);(!i&&null!==o&&o<5||i&&null!==o&&o<i)&&(i=o,n=r)}return n}calculateDistToStraightLine(e,t,n,i){const o=Math.min(n.x,i.x),s=Math.max(n.x,i.x),r=Math.min(n.y,i.y),a=Math.max(n.y,i.y);return e>=o-2&&e<=s+2&&t>=r-2&&t<=a+2?this.distToStraightLineSegment(e,t,n,i):null}distToStraightLineSegment(e,t,n,i){const o=(e,t,n,i)=>Math.pow(e-n,2)+Math.pow(t-i,2),s=o(n.x,n.y,i.x,i.y);if(0==s)return o(e,t,n.x,n.y);let r=((e-n.x)*(i.x-n.x)+(t-n.y)*(i.y-n.y))/s;return r=Math.max(0,Math.min(1,r)),o(e,t,n.x+r*(i.x-n.x),n.y+r*(i.y-n.y))}calculateDistToCurveLine(e,t,n,i,o,s){const r=Math.min(i.x,o.x,s.x),a=Math.max(i.x,o.x,s.x),l=Math.min(i.y,o.y,s.y),c=Math.max(i.y,o.y,s.y);if(t>=r-2&&t<=a+2&&n>=l-2&&n<=c+2){const e=a-r,u=c-l;return this.calculateDistToCurveInRect(t,n,i,s,o,e,u)}return null}calculateDistToCurveInRect(e,t,n,i,o,s,r){const a=Math.floor((s+r)/3),l=1/a,c=new Uint32Array(a),u=new Uint32Array(a),h=new Uint32Array(a);let d=null;const p=new W.A(a);for(let s=0;s<c.length;s++){const r=s*l,a=Math.pow(1-r,2)*n.x+2*r*(1-r)*i.x+Math.pow(r,2)*o.x,p=Math.pow(1-r,2)*n.y+2*r*(1-r)*i.y+Math.pow(r,2)*o.y,m=Math.abs(e-a),g=Math.abs(t-p),f=m+g;(!d||d>f)&&(d=f),h[s]=Math.max(m,g),c[s]=a,u[s]=p}for(let e=0;e<c.length;e++)h[e]<d&&p.setBit(e,!0,!1);let m=null;for(let n=-1;-1!==(n=p.findNext(n));){const i=Math.hypot(c[n]-e,u[n]-t);(!m||m>i)&&(m=i)}return m}getLineLength(e,t,n,i){return Math.sqrt(Math.pow(n-e,2)+Math.pow(i-t,2))}getPointOnDistance(e,t,n,i,o,s){const r=n-o*((n-e)/s),l=i-o*((i-t)/s);return new a.Point(r,l)}findControlPoint(e,t,n,i,o,s){const r=t+(i-t)/2,l=n+(o-n)/2;let c=r-t,u=l-n;const h=Math.sqrt(c*c+u*u);c/=h,u/=h;const d=50*Math.ceil(e/2);return e%2==0?new a.Point(r+d/2*u,l-d/2*c):new a.Point(r-d/2*u,l+d/2*c)}canvasArrow(e,t,n,i,o){const s=Math.atan2(i-t,o-n)+Math.PI;e.moveTo(t-this.arrowWidth*Math.sin(s-Math.PI/10),n-this.arrowWidth*Math.cos(s-Math.PI/10)),e.lineTo(t,n),e.lineTo(t-this.arrowWidth*Math.sin(s+Math.PI/10),n-this.arrowWidth*Math.cos(s+Math.PI/10))}}const Y="dimensionality-reducer-terminate-event";var j,K,z=n(3629);async function Z(e,t,i,o,r,a,l){let c=await async function(e,t,i,o,r,a,l){if(!a.distanceFnArgs)throw new Error("options.distanceFnArgs must be defined");if(e.length!==t.length||e.length!==a.distanceFnArgs.length||e.length!==o.length)throw new Error("data, metrics and options and weights must have the same length");return new Promise((function(c,u){const h=new Worker(new URL(n.p+n.u(234),n.b));h.postMessage({columnsData:e,distanceMetrics:t,method:i,options:a,weights:o,aggregationMethod:r});const d=s.events.onCustomEvent(Y).subscribe((()=>{try{h?.terminate()}finally{d.unsubscribe()}}));h.onmessage=({data:{error:e,embedding:t,epochNum:n,epochsLength:i}})=>{F(n)||F(i)?(d.unsubscribe(),e?u(e):c(t),setTimeout((()=>h.terminate()),100)):l&&l(n,i,t)}}))}(e,i,t,o,r,a,l);return c=c.map((e=>(0,z.S8)(e))),c}(K=j||(j={})).EUCLIDEAN="EUCLIDEAN",K.MANHATTAN="MANHATTAN";const X={[j.EUCLIDEAN]:function(e){return`\n var sum = 0.0;\n for (var i = 0u; i < ${e}; i = i + 1u) {\n sum = sum + distances[i] * distances[i] * computeInfo.weights[i] * computeInfo.weights[i];\n }\n return sqrt(sum);\n `},[j.MANHATTAN]:function(e){return`\n var sum = 0.0;\n for (var i = 0u; i < ${e}; i = i + 1u) {\n sum = sum + abs(distances[i]) * computeInfo.weights[i];\n }\n return sum;\n `}};var J,Q;(Q=J||(J={})).HAMMING="Hamming",Q.EUCLIDEAN="Euclidean",Q.VECTOR_COSINE="Vector Cosine",Q.MANHATTAN="Manhattan",Q.TANIMOTO="Tanimoto",Q.LEVENSTEIN="Levenshtein",Q.NEEDLEMAN_WUNSCH="Needlemann-Wunsch",Q.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance",Q.SOKAL="Sokal",Q.COSINE="Cosine",Q.ASYMMETRIC="Asymmetric",Q.Difference="Difference",Q.OneHot="One-Hot";const ee={[J.HAMMING]:function(e,t){return`\n let aLength: u32 = computeInfo.entrySizes[${t}][aIndex];\n let bLength: u32 = computeInfo.entrySizes[${t}][bIndex];\n let maxLength: u32 = max(aLength, bLength);\n let minLength: u32 = min(aLength, bLength);\n let sizeDiff: u32 = maxLength - minLength;\n \n let maxIntDistance = ceil(maxDistance * f32(maxLength)) - f32(sizeDiff);\n\n var diff: f32 = 0.0;\n for (var i = 0u; i < ${e}; i = i + 1u) {\n diff = diff + f32(a[i] != b[i]);\n if (diff > maxIntDistance) {\n return 1.0;\n }\n }\n diff += f32(sizeDiff);\n return diff / ${e};\n `},[J.EUCLIDEAN]:function(e,t){return`\n var dist: f32 = 0.0;\n for (var i = 0u; i < ${e}; i = i + 1u) {\n dist = dist + f32(a[i] - b[i]) * f32(a[i] - b[i]);\n }\n return sqrt(dist);\n `},[J.MANHATTAN]:function(e,t){return`\n var dist: f32 = 0.0;\n for (var i = 0u; i < ${e}; i = i + 1u) {\n dist = dist + abs(f32(a[i] - b[i]));\n }\n return dist;\n `},[J.VECTOR_COSINE]:function(e,t){return`\n var dist: f32 = 0.0;\n var productSum: f32 = 0.0;\n var aSquareSum: f32 = 0.0;\n var bSquareSum: f32 = 0.0;\n for (var i = 0u; i < ${e}; i = i + 1u) {\n productSum = productSum + f32(a[i] * b[i]);\n aSquareSum = aSquareSum + f32(a[i] * a[i]);\n bSquareSum = bSquareSum + f32(b[i] * b[i]);\n }\n var sim = productSum / (sqrt(aSquareSum) * sqrt(bSquareSum));\n return (1.0 - sim) / 2.0;\n `},[J.TANIMOTO]:function(e,t){return`\n var onBitsa: u32 = 0u;\n var onBitsb: u32 = 0u;\n for (var i = 0u; i < ${e}u; i = i + 1u) {\n onBitsa = onBitsa + countOneBits(a[i]);\n onBitsb = onBitsb + countOneBits(b[i]);\n }\n\n if (onBitsa == 0u && onBitsb == 0u) {\n return 0.0;\n }\n\n let totalOnBits = onBitsa + onBitsb;\n var commonBits: u32 = 0u;\n for (var i = 0u; i < ${e}u; i = i + 1u) {\n commonBits = commonBits + countOneBits(a[i] & b[i]);\n }\n\n return 1.0 - f32(commonBits) / f32(totalOnBits - commonBits);\n `},[J.LEVENSTEIN]:function(e,t){return`\n let aLength: u32 = computeInfo.entrySizes[${t}][aIndex];\n let bLength: u32 = computeInfo.entrySizes[${t}][bIndex];\n let maxLength: u32 = max(aLength, bLength);\n let minLength: u32 = min(aLength, bLength);\n\n let maxIntDistance = ceil(maxDistance * f32(maxLength));\n\n // we will store two arrays as matrix and swap the working indices per pass.\n // this way we can reduce memory usage per computation to just O(aLength)\n // the grid will have aLength + 1 columns and bLength + 1 rows\n // this will be guaranteed by iteration, but the array sizes must be known at compile time, so we will use a fixed size of maxArraySize\n var dynamicPassMat: array<array<f32, ${e+1}u>, 2>; // initialize to 0\n \n var prevIndex: u32 = 0;\n var curIndex: u32 = 1; // we will swap these indices per pass\n\n // initialize the first row\n for (var i = 0u; i <= aLength; i = i + 1u) {\n dynamicPassMat[prevIndex][i] = f32(i);\n }\n\n // iterate over the rows\n for (var i = 1u; i <= bLength; i = i + 1u) {\n dynamicPassMat[curIndex][0] = f32(i);\n var minEntry: f32 = f32(maxLength);\n let prevRow = &dynamicPassMat[prevIndex];\n let curRow = &dynamicPassMat[curIndex];\n let bMon = u32(b[i - 1]);\n for (var j = 1u; j <= aLength; j = j + 1u) {\n var cost: f32 = f32(a[j - 1] != bMon);\n var res: f32 = min(\n min(\n (*prevRow)[j] + 1.0, // deletion\n (*curRow)[j - 1] + 1.0, // insertion\n ),\n (*prevRow)[j - 1] + cost // substitution\n );\n (*curRow)[j] = res;\n if (res < minEntry) {\n minEntry = res;\n }\n }\n // swap the indices\n let temp: u32 = prevIndex;\n prevIndex = curIndex;\n curIndex = temp;\n if (minEntry > maxIntDistance) {\n return 1.0;\n }\n }\n\n return dynamicPassMat[prevIndex][aLength] / f32(maxLength);\n `},[J.NEEDLEMAN_WUNSCH]:function(e,t){return`\n let aLength: u32 = computeInfo.entrySizes[${t}][aIndex];\n let bLength: u32 = computeInfo.entrySizes[${t}][bIndex];\n let maxLength: u32 = max(aLength, bLength);\n let minLength: u32 = min(aLength, bLength);\n \n let maxIntDistance = ceil(maxDistance * f32(maxLength));\n // we will store two arrays as matrix and swap the working indices per pass.\n // this way we can reduce memory usage per computation to just O(aLength)\n // the grid will have aLength + 1 columns and bLength + 1 rows\n // this will be guaranteed by iteration, but the array sizes must be known at compile time, so we will use a fixed size of maxArraySize\n var dynamicPassMat: array<array<f32, ${e+1}u>, 2>; // initialize to 0\n \n // we need to keep track of which operation led to the current cell\n // i.e. whether we came from the left, top or diagonal to assign gap open/gap extend penalty\n var verticalGaps: array<u32, ${e+1}u>;\n var horizontalGaps: array<u32, ${e+1}u>;\n\n let gapOpenPenalty: f32 = suppInfo.gapOpenPenalty${t};\n let gapExtensionPenalty: f32 = suppInfo.gapExtensionPenalty${t};\n var prevIndex: u32 = 0;\n var curIndex: u32 = 1; // we will swap these indices per pass\n // initialize the first row\n for (var i = 0u; i <= aLength; i = i + 1u) {\n dynamicPassMat[prevIndex][i] = gapExtensionPenalty + f32(i - 1) * gapExtensionPenalty; // accounting for the fact that left and right gaps are less costly\n dynamicPassMat[curIndex][i] = 0.0;\n }\n dynamicPassMat[0][0] = 0.0;\n\n let simMatrix = &suppInfo.similarityMatrix${t}; // using pointers make things faster\n // iterate over the rows\n for (var i = 1u; i <= bLength; i = i + 1u) {\n let prevRow = &dynamicPassMat[prevIndex];\n let curRow = &dynamicPassMat[curIndex];\n (*curRow)[0] = gapExtensionPenalty + f32(i - 1) * gapExtensionPenalty;\n var minEntry: f32 = f32(maxLength);\n let monB = u32(b[i - 1]);\n for (var j = 1u; j <= aLength; j = j + 1u) {\n let monA = u32(a[j - 1]);\n \n let cost: f32 = (*prevRow)[j - 1] + 1f - (*simMatrix)[monA][monB];\n var top = (*prevRow)[j]; // deletion\n if (verticalGaps[j] > 0 || i == 1 || i == bLength) {\n top = top + gapExtensionPenalty;\n } else {\n top = top + gapOpenPenalty;\n }\n var left = (*curRow)[j - 1]; // insertion\n if (horizontalGaps[j - 1] > 0 || j == 1 || j == aLength) {\n left = left + gapExtensionPenalty;\n } else {\n left = left + gapOpenPenalty;\n }\n var res: f32 = min(\n min(\n top, // deletion\n left, // insertion\n ),\n cost // substitution\n );\n (*curRow)[j] = res;\n if (res < minEntry) {\n minEntry = res;\n }\n // update the horizontal and vertical gaps\n if (res == cost) {\n verticalGaps[j] = 0;\n horizontalGaps[j] = 0;\n } else if (res == left) {\n verticalGaps[j] = 0;\n horizontalGaps[j] = 1;\n } else {\n verticalGaps[j] = 1;\n horizontalGaps[j] = 0;\n }\n }\n // swap the indices\n let temp: u32 = prevIndex;\n prevIndex = curIndex;\n curIndex = temp;\n if (minEntry > maxIntDistance) {\n return 1.0;\n }\n }\n return dynamicPassMat[prevIndex][aLength] / f32(minLength);\n\n `},[J.MONOMER_CHEMICAL_DISTANCE]:function(e,t){return`\n let aLength: u32 = computeInfo.entrySizes[${t}][aIndex];\n let bLength: u32 = computeInfo.entrySizes[${t}][bIndex];\n let maxLength: u32 = max(aLength, bLength);\n let minLength: u32 = min(aLength, bLength);\n let sizeDiff: u32 = maxLength - minLength;\n \n let maxIntDistance = ceil(maxDistance * f32(maxLength)) - f32(sizeDiff);\n\n let simMatrix = &(suppInfo.similarityMatrix${t}); // using pointers make things faster\n var diff: f32 = 0.0;\n for (var i = 0u; i < ${e}; i = i + 1u) {\n diff = diff + 1.0 - (*simMatrix)[u32(a[i])][u32(b[i])];\n if (diff > maxIntDistance) {\n return 1.0;\n }\n }\n diff += f32(sizeDiff);\n return diff / ${e};\n `},[J.SOKAL]:function(e,t){return`\n var onBitsa: u32 = 0u;\n var onBitsb: u32 = 0u;\n for (var i = 0u; i < ${e}u; i = i + 1u) {\n onBitsa = onBitsa + countOneBits(a[i]);\n onBitsb = onBitsb + countOneBits(b[i]);\n }\n let total = onBitsa + onBitsb;\n if (total == 0u) {\n return 1.0;\n }\n var commonBits: u32 = 0u;\n for (var i = 0u; i < ${e}u; i = i + 1u) {\n commonBits = commonBits + countOneBits(a[i] & b[i]);\n }\n return 1.0 - f32(commonBits) / f32(total * 2 - commonBits * 3);\n `},[J.COSINE]:function(e,t){return`\n var onBitsa: u32 = 0u;\n var onBitsb: u32 = 0u;\n for (var i = 0u; i < ${e}u; i = i + 1u) {\n onBitsa = onBitsa + countOneBits(a[i]);\n onBitsb = onBitsb + countOneBits(b[i]);\n }\n let total = onBitsa * onBitsb; // p.s. here total is taken by multiplying\n if (total == 0u) {\n return 1.0;\n }\n var commonBits: u32 = 0u;\n for (var i = 0u; i < ${e}u; i = i + 1u) {\n commonBits = commonBits + countOneBits(a[i] & b[i]);\n }\n return 1.0 - f32(commonBits) / sqrt(f32(total));\n `},[J.ASYMMETRIC]:function(e,t){return`\n var onBitsa: u32 = 0u;\n var onBitsb: u32 = 0u;\n for (var i = 0u; i < ${e}u; i = i + 1u) {\n onBitsa = onBitsa + countOneBits(a[i]);\n onBitsb = onBitsb + countOneBits(b[i]);\n }\n let min = min(onBitsa, onBitsb);\n if (min == 0u) {\n return 1.0;\n }\n var commonBits: u32 = 0u;\n for (var i = 0u; i < ${e}u; i = i + 1u) {\n commonBits = commonBits + countOneBits(a[i] & b[i]);\n }\n return 1.0 - f32(commonBits) / f32(min);\n `},[J.Difference]:function(e,t){return`\n let range = suppInfo.range${t};\n return f32(abs(f32(a[0]) - f32(b[0])) / range);\n `},[J.OneHot]:function(e,t){return`\n let aLength: u32 = computeInfo.entrySizes[${t}][aIndex];\n let bLength: u32 = computeInfo.entrySizes[${t}][bIndex];\n if (aLength != bLength) {\n return 1.0;\n }\n for (var i = 0u; i < aLength; i = i + 1u) {\n if(a[i] != b[i]) {\n return 1.0;\n }\n }\n return 0.0;\n `}},te={[J.HAMMING]:e=>Math.ceil(e/30),[J.EUCLIDEAN]:e=>Math.ceil(e/30),[J.MANHATTAN]:e=>Math.ceil(e/30),[J.TANIMOTO]:e=>Math.ceil(e/30),[J.SOKAL]:e=>Math.ceil(e/30),[J.COSINE]:e=>Math.ceil(e/30),[J.ASYMMETRIC]:e=>Math.ceil(e/30),[J.LEVENSTEIN]:e=>Math.ceil(e*e/60),[J.NEEDLEMAN_WUNSCH]:e=>Math.ceil(e*e/60),[J.MONOMER_CHEMICAL_DISTANCE]:e=>Math.ceil(e/25),[J.Difference]:e=>1,[J.OneHot]:e=>Math.ceil(e/40),[J.VECTOR_COSINE]:e=>Math.ceil(e/30)},ne={STRING:new Set([J.HAMMING,J.LEVENSTEIN,J.NEEDLEMAN_WUNSCH,J.MONOMER_CHEMICAL_DISTANCE,J.OneHot]),UINT32ARRAY:new Set([J.HAMMING,J.EUCLIDEAN,J.MANHATTAN,J.MONOMER_CHEMICAL_DISTANCE,J.LEVENSTEIN,J.NEEDLEMAN_WUNSCH,J.TANIMOTO,J.COSINE,J.VECTOR_COSINE,J.SOKAL,J.ASYMMETRIC,J.OneHot,J.Difference]),INT32ARRAY:new Set([J.EUCLIDEAN,J.MANHATTAN,J.OneHot,J.Difference,J.VECTOR_COSINE]),FLOAT32ARRAY:new Set([J.EUCLIDEAN,J.MANHATTAN,J.Difference,J.VECTOR_COSINE]),NUMBER:new Set([J.EUCLIDEAN,J.MANHATTAN,J.Difference]),BITARRAY:new Set([J.TANIMOTO,J.COSINE,J.SOKAL,J.ASYMMETRIC])};function ie(e,t=.8,n,i,o,s){return function(e,t,n,i){return new(n||(n=Promise))((function(o,s){function r(e){try{l(i.next(e))}catch(e){s(e)}}function a(e){try{l(i.throw(e))}catch(e){s(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,a)}l((i=i.apply(e,t||[])).next())}))}(this,void 0,void 0,(function*(){const r=yield function(){return E(this,void 0,void 0,(function*(){if(!navigator.gpu)return console.error("WebGPU is not supported in this browser"),null;if(!M&&(M=yield navigator.gpu.requestAdapter({powerPreference:"high-performance"}),null==M))return null;let e=!1;if(x&&(x.lost.then((()=>{e=!0})),yield new Promise((e=>setTimeout(e,10)))),!x||e){const e=1e9,t=M.limits,n=t.maxBufferSize,i=t.maxStorageBufferBindingSize;try{return x=yield M.requestDevice({requiredLimits:{maxBufferSize:Math.min(n,e),maxStorageBufferBindingSize:Math.min(i,e)}}),x}catch(e){return console.error("Failed to create device with required limits",e),x=yield M.requestDevice(),x}}return x}))}();if(!r)return null;const a=Object.values(J);if(n.some((e=>!a.includes(e))))throw new Error("Invalid distance metrics provided: "+n.join(", "));if(!Object.values(j).includes(i))throw new Error("Invalid aggregation function provided: "+i);const l=1-t;if(s.length!==e.length||s.length!==n.length||s.length!==o.length)throw new Error("Options, weigths and distance functions must be provided for each column");if(e.some((t=>t.length!==e[0].length)))throw new Error("All entry lists must be the same length");const c=e.length,u=e[0].length,h=e.map(((e,t)=>function(e,t=J.HAMMING,n,i={gapOpenPenalty:1,gapExtensionPenalty:.6}){var o,s;let r=null;const a=e.some((e=>"string"==typeof e))?(r="STRING",e.map((e=>new Uint32Array(e.split("").map((e=>e.charCodeAt(0))))))):e.some((e=>"number"==typeof e))?(r="NUMBER",e.map((e=>new Float32Array([e])))):"object"==typeof e[0]&&e.some((e=>"_data"in e&&"_length"in e))?(r="BITARRAY",e.map((e=>e._data))):e.some((e=>e instanceof Float32Array))?(r="FLOAT32ARRAY",e):e.some((e=>e instanceof Uint32Array))?(r="UINT32ARRAY",e):e.some((e=>e instanceof Int32Array))?(r="INT32ARRAY",e):void 0;if(!a||!r)throw new Error("Invalid entry type, could not determine entry type from input list");const l=a[0]instanceof Int32Array?"INT32ARRAY":a[0]instanceof Float32Array?"FLOAT32ARRAY":"UINT32ARRAY",c=new Uint32Array(a.map((e=>e.length)));if(!ne[r]||!ne[r].has(t))throw new Error(`Distance metric '${t}' not supported for entry type '${r}'`);const u=c.reduce(((e,t)=>Math.max(e,t)),0),h=te[t](u),d="INT32ARRAY"===l?Int32Array:"FLOAT32ARRAY"===l?Float32Array:Uint32Array,p=new d(a.length*u);a.forEach(((e,t)=>{p.set(e,t*u)}));let m="",g=0,f="FLOAT32ARRAY",y=null;if(t===J.NEEDLEMAN_WUNSCH||t===J.MONOMER_CHEMICAL_DISTANCE){let e=i.scoringMatrix&&i.alphabetIndexes?Object.keys(i.alphabetIndexes).reduce(((e,t)=>Math.max(e,t.charCodeAt(0))),0):-1;if(!i.alphabetIndexes||!i.scoringMatrix){for(let t=0;t<p.length;t++)p[t]>e&&(e=p[t]);i.scoringMatrix=new Array(e+1).fill(null).map((()=>new Array(e+1).fill(0))),i.alphabetIndexes={};for(let e=0;e<i.scoringMatrix.length;e++)i.scoringMatrix[e][e]=1,i.alphabetIndexes[String.fromCharCode(e)]=e}const t=(e+1)*(e+1),r=new Array(e+1).fill(null).map((()=>new Float32Array(e+1)));for(let t=0;t<e+1;t++)r[t][t]=1;const a=i.alphabetIndexes;for(const e of Object.keys(a))for(const t of Object.keys(a))e!==t&&(r[e.charCodeAt(0)][t.charCodeAt(0)]=i.scoringMatrix[a[e]][a[t]]);g=2+t,f="FLOAT32ARRAY",y=new Float32Array(g),y[0]=null!==(o=i.gapOpenPenalty)&&void 0!==o?o:1,y[1]=null!==(s=i.gapExtensionPenalty)&&void 0!==s?s:.6;let l=2;for(let e=0;e<r.length;e++)y.set(r[e],l),l+=r[e].length;m=`\n gapOpenPenalty${n}: f32,\n gapExtensionPenalty${n}: f32,\n similarityMatrix${n}: array<array<f32, ${e+1}>, ${e+1}>`}else if(t===J.Difference){if(!i.range||"number"!=typeof i.range||i.range<=0){const e=p.reduce(((e,t)=>Math.min(e,t)),p[0]),t=p.reduce(((e,t)=>Math.max(e,t)),p[0]);i.range=t-e}i.range<=0&&(i.range=1),g=1,f="FLOAT32ARRAY",y=new Float32Array([i.range]),m=`\n range${n}: f32`}const b=p instanceof Int32Array?"i32":p instanceof Float32Array?"f32":"u32",w=`data${n}: array<array<${b}, ${u}>, ${a.length}>`;return{flatSourceArray:p,sourceArraySize:p.length,maxEntryLen:u,arraySizes:c,complexity:h,suppInfoBuffer:y,suppInfoSize:g,suppInfoType:f,suppInfoStructWgsl:m,entryType:r,dataTypeWGSL:b,dataStructWgsl:w,EncodedArrayConstructor:d}}(e,n[t],t,s[t])));if(0===c)throw new Error("No columns provided. Please provide at least one column of data.");1===c&&(i=j.MANHATTAN);let d=h.map((e=>e.suppInfoStructWgsl)).filter((e=>!!e&&""!=e)).join(",\n"),p=!1;d&&""!=d.trim()||(p=!0,d="\ndummy: f32\n");const m=h.map((e=>e.dataStructWgsl)).filter((e=>!!e&&""!=e)).join(",\n"),g=new Uint32Array(c*u);h.forEach(((e,t)=>{g.set(e.arraySizes,t*u)}));const f=1e4,y=100,b=h.reduce(((e,t)=>e+t.complexity),0),w=Math.ceil(6e3/b),v=Math.ceil(Math.sqrt(Math.ceil(100))),A=10*v,C=u*(u-1)/2,T=Math.ceil(C/f),S=r.createShaderModule({label:"Sparse matrix compute shader",code:`\n // each thread will perform 100 iterations at one time, comparing 100 pairs of entries.\n // in total, each thread will perform at most ${T} comparisons.\n // first is the result struct, containing is, js, and distances. each array with length of 100,\n // and also integer for how many pairs were found to be below threshold.\n struct SparseResult {\n i: array<array<u32, 100>, 10000>,\n j: array<array<u32, 100>, 10000>,\n distances: array<array<f32, 100>, 10000>,\n found: array<u32, 10000>,\n done: array<u32, 10000>\n }\n // struct for the data\n struct ComputeInfo {\n // start at cols and rows, and end at cols and rows for each thread, these will be calculated on cpu and passed to gpu.\n startAtCols: array<u32, 10000>,\n startAtRows: array<u32, 10000>,\n endAtCols: array<u32, 10000>,\n endAtRows: array<u32, 10000>,\n\n // the ACTUALLY sizes of each entry\n entrySizes: array<array<u32, ${u}>, ${c}>,\n // the weights for each entry\n weights: array<f32, ${c}>,\n // the data for each entry\n ${m} // an example of the dataWgsl would be:\n //data0: array<array<u32,20>,100>,\n //data1: array<array<u32,20>,100>\n }\n\n // struct for the supplementary information\n struct SuppInfo {\n // struct containing all the supplementary info, like scoring matrix, alphabet indexes, range, etc.\n ${d}\n };\n\n @group(0) @binding(0) var<storage, read_write> computeInfo: ComputeInfo;\n @group(0) @binding(1) var<storage, read_write> suppInfo: SuppInfo;\n @group(0) @binding(2) var<storage, read_write> results: SparseResult;\n @compute @workgroup_size(10, 10) fn calcSparseMatrix(\n @builtin(global_invocation_id) id: vec3<u32>\n ) {\n ${p?"let otherDummy = suppInfo.dummy * 2;":""} // just to make sure that the suppInfo is not optimized out\n let threadCol = id.x;\n let threadRow = id.y;\n let linearIndex = threadRow * ${A} + threadCol;\n if (linearIndex >= 10000) {\n return; // if we are out of bounds, return\n } \n var startAtCol: u32 = computeInfo.startAtCols[linearIndex];\n var startAtRow: u32 = computeInfo.startAtRows[linearIndex];\n let endAtCol: u32 = min(computeInfo.endAtCols[linearIndex], ${u}u);\n let endAtRow: u32 = min(computeInfo.endAtRows[linearIndex], ${u}u);\n let is = &results.i[linearIndex];\n let js = &results.j[linearIndex];\n let distances = &results.distances[linearIndex];\n results.found[linearIndex] = 0; // initialize the found counter\n var found: u32 = 0;\n if (results.done[linearIndex] > 0) {\n return; // if we are done, return\n }\n for (var i = 0; i < ${w}; i++) {\n if (startAtCol >= endAtCol && startAtRow >= endAtRow) {\n results.done[linearIndex] = 1;\n break;\n }\n if (found >= 100) {\n break;\n }\n let dist = combinedDistance(startAtCol, startAtRow);\n if (dist <= ${l}) {\n (*is)[found] = startAtCol;\n (*js)[found] = startAtRow;\n (*distances)[found] = dist;\n found = found + 1;\n }\n startAtCol = startAtCol + 1;\n if (startAtCol >= ${u}u) {\n startAtRow += 1;\n startAtCol = startAtRow + 1;\n }\n }\n results.found[linearIndex] = found;\n // update the startAtCols and startAtRows\n computeInfo.startAtCols[linearIndex] = startAtCol;\n computeInfo.startAtRows[linearIndex] = startAtRow;\n\n }\n\n // this will generate the distance script for each distance metric and then combine them into one\n ${oe(n,h.map((e=>e.maxEntryLen)),l,i)}\n\n\n `}),L=r.createComputePipeline({label:"sparse matrix compute pipeline",layout:"auto",compute:{module:S,entryPoint:"calcSparseMatrix"}}),_=new Uint32Array(f),I=new Uint32Array(f),P=new Uint32Array(f),N=new Uint32Array(f),R=Math.floor(C/f);let $=0,O=1;console.time("GPUthreadStarts");for(let e=0;e<f;e++){const t=9999===e?C-1:(e+1)*R,n=u-2-Math.floor(Math.sqrt(-8*t+4*u*(u-1)-7)/2-.5),i=t-u*n+Math.floor((n+1)*(n+2)/2);_[e]=O,I[e]=$,P[e]=i,N[e]=n,$=n,O=i}console.timeEnd("GPUthreadStarts");const H=4e4+u*c+c+h.reduce(((e,t)=>e+t.sourceArraySize),0),k=h.reduce(((e,t)=>e+t.suppInfoSize),0),F=1e6,D=H*Uint32Array.BYTES_PER_ELEMENT;let G=D;const B=15&D;0!==B&&(G+=16-B);const V=r.createBuffer({label:"compute info buffer",size:G,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST,mappedAtCreation:!0}),U=V.getMappedRange();let W=0;new Uint32Array(U,W,f).set(_),W+=f*Uint32Array.BYTES_PER_ELEMENT,new Uint32Array(U,W,f).set(I),W+=f*Uint32Array.BYTES_PER_ELEMENT,new Uint32Array(U,W,f).set(P),W+=f*Uint32Array.BYTES_PER_ELEMENT,new Uint32Array(U,W,f).set(N),W+=f*Uint32Array.BYTES_PER_ELEMENT,new Uint32Array(U,W,g.length).set(g),W+=g.length*Uint32Array.BYTES_PER_ELEMENT,new Float32Array(U,W,c).set(o),W+=c*Float32Array.BYTES_PER_ELEMENT;for(const e of h){const t=e.EncodedArrayConstructor,n=e.sourceArraySize;new t(U,W,n).set(e.flatSourceArray),W+=n*t.BYTES_PER_ELEMENT}V.unmap();const q=k*Uint32Array.BYTES_PER_ELEMENT;let Y=q;const K=15&q;0!==K&&(Y+=16-K),Y=Math.max(Y,16);const z=r.createBuffer({label:"supp info buffer",size:Y,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST,mappedAtCreation:!0}),Z=z.getMappedRange();let X=0;for(const e of h)e.suppInfoBuffer&&e.suppInfoBuffer.byteLength>0&&e.suppInfoSize>0&&(new("UINT32ARRAY"===e.suppInfoType?Uint32Array:Float32Array)(Z,X,e.suppInfoBuffer.length).set(e.suppInfoBuffer),X+=e.suppInfoBuffer.byteLength);0===X&&new Uint32Array(Z,0,4).set([1,1,1,1]),z.unmap();const Q=302e4*Uint32Array.BYTES_PER_ELEMENT;let ee=Q;const ie=15&Q;0!==ie&&(ee+=16-ie);const se=r.createBuffer({label:"results buffer",size:ee,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_SRC}),re=r.createBindGroup({label:"bindGroup for sparse matrix buffer",layout:L.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:V}},{binding:1,resource:{buffer:z}},{binding:2,resource:{buffer:se}}]}),ae=r.createBuffer({label:"results out buffer",size:se.size,usage:GPUBufferUsage.MAP_READ|GPUBufferUsage.COPY_DST}),le=[],ce=[],ue=[];let he=!1;for(;!he;){const e=r.createCommandEncoder({label:"distance encoder"}),t=e.beginComputePass({label:"distance compute pass"});t.setPipeline(L),t.setBindGroup(0,re),t.dispatchWorkgroups(v,v),t.end(),e.copyBufferToBuffer(se,0,ae,0,ae.size);const n=e.finish();r.queue.submit([n]),yield r.queue.onSubmittedWorkDone(),yield ae.mapAsync(GPUMapMode.READ);const i=ae.getMappedRange();let o=0;const s=new Uint32Array(i,o,F);o+=F*Uint32Array.BYTES_PER_ELEMENT;const a=new Uint32Array(i,o,F);o+=F*Uint32Array.BYTES_PER_ELEMENT;const l=new Float32Array(i,o,F);o+=F*Float32Array.BYTES_PER_ELEMENT;const c=new Uint32Array(i,o,f);o+=f*Uint32Array.BYTES_PER_ELEMENT,he=new Uint32Array(i,o,f).every((e=>1===e));const u=c.reduce(((e,t)=>e+t),0),h=new Uint32Array(u),d=new Uint32Array(u),p=new Float32Array(u);let m=0;for(let e=0;e<c.length;e++){const t=c[e];0!==t&&(h.set(s.subarray(e*y,e*y+t),m),d.set(a.subarray(e*y,e*y+t),m),p.set(l.subarray(e*y,e*y+t),m),m+=t)}le.push(h),ce.push(d),ue.push(p),ae.unmap()}const de=le.reduce(((e,t)=>e+t.length),0),pe=new Uint32Array(de),me=new Uint32Array(de),ge=new Float32Array(de);let fe=0;for(let e=0;e<le.length;e++)pe.set(le[e],fe),me.set(ce[e],fe),ge.set(ue[e],fe),fe+=le[e].length;return V.destroy(),z.destroy(),se.destroy(),ae.destroy(),{i:pe,j:me,distance:ge}}))}function oe(e,t,n,i){return e.map(((e,i)=>`\n fn distanceScript${i}(aIndex: u32, bIndex: u32) -> f32 {\n let a = computeInfo.data${i}[aIndex];\n let b = computeInfo.data${i}[bIndex];\n let maxDistance: f32 = ${n};\n ${ee[e](t[i],i)}\n }\n `)).join("\n")+"\n"+`\n fn combinedDistance(aIndex: u32, bIndex: u32) -> f32 {\n var distances: array<f32, ${e.length}>;\n ${e.map(((e,t)=>`distances[${t}] = distanceScript${t}(aIndex, bIndex);`)).join("\n")}\n ${X[i](e.length)}\n }\n \n `}let se=0;const re="cliffsDf",ae=new u.Subject,le="SALI",ce="line index",ue=["From","To"],he="filterCliffs";async function de(e,t,i,o,l,c,u,h,d,p,m,g,f,y,b,w,v){se++;const A=c/100;let C,T=!1;const S=g.inputs,E=await g.apply({[S[0].name]:t,[S[1].name]:u,...d.preprocessingFuncArgs??{}});let M=[];if(h===P){const t=await function(e,t,i,o,s,r,a=10,l=!1,c=2){const u=new Worker(new URL(n.p+n.u(980),n.b));let h;return u.postMessage({data:e,threshold:t,weights:i,aggregationMethod:o,distanceFns:s,distanceFnArgs:r,maxIterations:a,useWebGPU:l,inflate:c}),{promise:new Promise(((e,t)=>{h=e,u.onmessage=t=>{setTimeout((()=>u.terminate()),100),e(t.data.res)},u.onerror=e=>{setTimeout((()=>u.terminate()),100),t(e)}})),terminate:()=>{try{h(null),u.terminate()}catch(e){console.error(e)}}}}([E.entries],c,[1],"MANHATTAN",[u],[E.options??{}],d?.maxIterations??5,d.useWebGPU??!1).promise;e.columns.addNewInt(e.columns.getUnusedName("MCL Cluster")).init((e=>t.clusters[e])),M=[t.embedX,t.embedY]}else M=await Z([E.entries],h,[u],[1],"MANHATTAN",{...d,distanceFnArgs:[E.options??{}]});if(M.length!==i.length)throw new Error("Number of axes names should be equal to number of embedding dimensions");for(let t=0;t<M.length;++t)e.columns.addNewFloat(i[t]).init((e=>M[t][e]));let x=null;if(d.useWebGPU)try{x=await ie([E.entries],A,[u],j.MANHATTAN,[1],[E.options??{}])}catch(e){console.error(e)}x||(d.useWebGPU&&console.error("WebGPU sparse matrix calculation failed, falling back to CPU implementation"),x=await(new B).calc(E.entries,u,A,E.options));const L=await async function(e,t){const n=e.distance.map(((n,i)=>{const o=Math.abs(t.get(e.i[i])-t.get(e.j[i]));return 0!=n?o/n:1/0})),i=e.distance.map((e=>1-e)),o=e.i,s=e.j,r=a.BitSet.create(t.length);return e.distance.forEach(((t,n)=>{r.set(e.i[n],!0),r.set(e.j[n],!0)})),{simVals:i,saliVals:n,n1:o,n2:s,cliffsBitSet:r}}(x,l),_=function(e,t,n,i,o,s,r){const l=new Array(e).fill(0);for(let e=0;e!=i.length;++e)n[e]!=1/0&&(r.get(i[e])>r.get(o[e])?l[i[e]]+=n[e]:l[o[e]]+=n[e]);return a.Column.fromList("double",t,l)}(t.length,`sali_${i[0].substring(i[0].lastIndexOf("_"))}`,L.saliVals,L.n1,L.n2,0,l);e.columns.add(_);const I=L.cliffsBitSet,N=function(e){const t=e.filter((e=>e!==1/0)),n=t.reduce(((e,t)=>Math.min(e,t)),Number.MAX_VALUE);return{max:t.reduce(((e,t)=>Math.max(e,t)),n),min:n}}(L.saliVals),$=.8/(N.max-N.min),O=s.shell.getTableView(e.name),k=O.addViewer(a.VIEWER.SCATTER_PLOT,{xColumnName:i[0],yColumnName:i[1],size:_.name,color:l.name,showXSelector:!1,showYSelector:!1,showSizeSelector:!1,showColorSelector:!1,markerMinSize:5,markerMaxSize:25,title:o}),F=function(e,t,n,i,o,s,r,l){const c={from:new Uint32Array(t.n1.length),to:new Uint32Array(t.n1.length),opacities:new Float32Array(t.n1.length),colors:new Array(t.n1.length),widths:new Float32Array(t.n1.length)};for(let n=0;n<t.n1.length;n++)c.from[n]=t.n1[n],c.to[n]=t.n2[n],c.opacities[n]=t.saliVals[n]===1/0?1:.2+(t.saliVals[n]-r.min)*l,c.colors[n]=e.selection.get(c.from[n])&&e.selection.get(c.to[n])?"255,255,0":"0,128,0",c.widths[n]=1;const u=a.DataFrame.create(c.from.length);return ue.forEach(((e,t)=>{u.columns.addNewString(e).init((e=>n.get(0===t?c.from[e]:c.to[e]))),function(e,t){Object.keys(t).forEach((n=>{e.tags[n]=t[n]}))}(u.col(e),s),u.col(e).semType=o})),u.columns.addNewFloat("Δ activity").init((e=>Math.abs(i.get(c.from[e])-i.get(c.to[e])))),u.columns.addNewInt(ce).init((e=>e)),u.columns.addNewFloat(le).init((e=>t.saliVals[e])),u.columns.addNewFloat("Similarity").init((e=>t.simVals[e])),u.name=`${re}${se}`,{lines:c,linesDf:u}}(e,L,t,l,p,m,N,$);F.lines.skipMultiLineCalculation=!0,F.linesDf.col(le).setTag("description","Structure−Activity Landscape Index (activity difference divided by 1 minus similarity)");const D=new q(k,i[0],i[1],F.lines,V.none),G=b?b(F.linesDf,ue).sort([le],[!1]):F.linesDf.plot.grid().sort([le],[!1]);G.col(ce)&&(G.col(ce).visible=!1),e.temp[".cliffsDfGrid"]=G;const U=r.button(`${F.linesDf.rowCount} cliffs`,(()=>{const e=R()(O.viewers).some((e=>e.dataFrame.name===`${re}${se}`));v&&!e&&O.addViewer(G),O.dockManager.dock(G,"down",null,"Activity cliffs",w??.2)}));U.classList.add("scatter_plot_link","cliffs_grid");const W=r.input.toggle("Show only cliffs",{value:!1,onValueChanged:t=>{t?(k.dataFrame.setTag(he,i[0]),e.filter.and(I),ae.next(i[0])):(k.dataFrame.setTag(he,""),e.filter.setAll(!0),ae.next(""))}});k.root.prepend(r.divH([U,W.root],"cliffs_div")),ae.subscribe((e=>{W.enabled=""===e||e===i[0]})),e.onRowsFiltering.subscribe((()=>{W.value&&e.filter.and(L.cliffsBitSet)}));const Y=s.events.onViewerClosed.subscribe((e=>{e.args.viewer===k&&(O.dockManager.close(G.root),Y.unsubscribe(),O.subs=O.subs.filter((e=>e!==Y)))}));return O.subs.push(Y),F.linesDf.onCurrentCellChanged.subscribe((()=>{for(let e=0;e<F.linesDf.rowCount;e++)F.lines.widths[e]=e===F.linesDf.currentRowIdx?3:1;D.linesToRender=F.lines;const n=F.linesDf.currentCol&&F.linesDf.currentCol.name===ue[1]?F.lines.to:F.lines.from,o=-1!==F.linesDf.currentRowIdx?F.linesDf.currentRowIdx:null;if(k.dataFrame.currentRowIdx=o?n[o]:-1,null!==o){const n=F.linesDf.currentRowIdx;D.currentLineId=n;const{zoomLeft:a,zoomRight:c,zoomTop:u,zoomBottom:h}=function(e,t,n,i,o,s){const r=Math.abs(n-o),a=Math.abs(i-s),l=e/r,c=t/a,u=Math.min(l,c),h=e/u*5,d=t/u*5,p=(n<o?n:o)+r/2-h/2,m=(i>s?i:s)-a/2+d/2;return{zoomLeft:p,zoomRight:p+h,zoomTop:m,zoomBottom:m-d}}(k.viewport.width,k.viewport.height,k.dataFrame.get(i[0],F.lines.from[n]),k.dataFrame.get(i[1],F.lines.from[n]),k.dataFrame.get(i[0],F.lines.to[n]),k.dataFrame.get(i[1],F.lines.to[n]));k.zoom(a,u,c,h),W.value?e.filter.and(I):!0===W.enabled&&e.filter.setAll(!0),setTimeout((()=>{!function(e,t,n,i,o,a,l,c,u){const h=t.getPane("Cliff Details");r.empty(h.root);const d=u({points:[n,i],lineId:o,df:e,seqCol:a,activityCol:l,sali:c});h.root.append(d),setTimeout((()=>{s.shell.o=t.root}),500)}(e,C,F.lines.from[o],F.lines.to[o],o,t,l,F.linesDf.get(le,o),y);const n=k.dataFrame.getSortedOrder(O.grid.sortByColumns,O.grid.sortTypes);O.grid.scrollToCell(t.name,n.indexOf(k.dataFrame.currentRowIdx))}),1e3)}})),F.linesDf.onSelectionChanged.subscribe((t=>{setTimeout((()=>(()=>{const t=a.BitSet.create(e.rowCount);for(let e=0;e<F.linesDf.rowCount;e++){const n=F.linesDf.selection.get(e);n&&(t.set(F.lines.from[e],!0),t.set(F.lines.to[e],!0)),F.lines.colors[e]=n?"255,255,0":"0,128,0"}e.selection.copyFrom(t),D.linesToRender=F.lines})()),100)})),e.onSelectionChanged.subscribe((t=>{!1===e.selection.anyTrue&&"number"==typeof t&&(T?T=!1:(e=>{e.selection.setAll(!1);for(let e=0;e<F.lines.colors.length;e++)F.lines.colors[e]="0,128,0";D.linesToRender=F.lines})(G.dataFrame))})),D.lineClicked.subscribe((t=>{if(T=!0,D.currentLineId=t.id,-1!==t.id){const n=F.linesDf.selection.clone();setTimeout((()=>{t.event.ctrlKey?(n.set(t.id,!n.get(t.id)),F.linesDf.selection.copyFrom(n)):(F.linesDf.currentRowIdx!==t.id&&(F.linesDf.currentRowIdx=t.id,e.currentRowIdx=F.lines.from[t.id]),F.linesDf.selection.copyFrom(n));const i=F.linesDf.getSortedOrder(G.sortByColumns,G.sortTypes);G.scrollToCell(ue[0],i.indexOf(t.id))}),500)}})),D.lineHover.pipe((0,H.debounceTime)(500)).subscribe((n=>{-1!==n.id&&-1===e.mouseOverRowIdx&&r.tooltip.show(f({lineId:n.id,points:[F.lines.from[n.id],F.lines.to[n.id]],df:e,seqCol:t,activityCol:l}),n.x,n.y)})),k.addProperty("similarityLimit","double",A),C=function(){const e=r.accordion(),t=r.element("i");return t.className="grok-icon svg-icon svg-view-layout",e.addTitle(r.span([t,r.label("Activity cliffs")])),e.addPane("Cliff Details",(()=>r.divText("Cliff has not been selected")),!0),s.shell.o=e.root,e}(),k}var pe,me=n(6863),ge=n(2003),fe=n(3516),ye=n(6718),be=n(3077),we=n(439);!function(e){e.IDENTITY="identity",e.SIMILARITY="similarity"}(pe||(pe={}));var ve=n(9192);class Ae{constructor(){this.maxIterations={uiName:"Max iterations",value:0,tooltip:"Maximum iterations for MCL process.Default is \n 0 which will construct the clusters with plain sparse matrix. Values greater than 0 will \n perform MCL with the given number of iterations and will result in trans-cluster activity cliff lines."},this.useWebGPU={uiName:"Use WebGPU",value:!1,tooltip:"Use WebGPU for MCL calculation. (Experimental)",type:"boolean"}}}class Ce extends O{constructor(e={}){super({...e,enableMCL:!0});const t=Array.from(this.tableInput.value.columns.numericalNoDateTime);this.activitiesInput=r.input.column("Activities",{table:this.tableInput.value,value:t.length?t[0]:null,filter:e=>t.includes(e)}),this.activitiesInputRoot=this.activitiesInput.root,this.similarityInput=r.input.int("Similarity cutoff",{value:80}),this.methodsParams[P]=new Ae}onTableInputChanged(){if(super.onTableInputChanged(),this.activitiesInputRoot){r.empty(this.activitiesInputRoot);const e=Array.from(this.tableInput.value.columns.numerical);this.activitiesInput=r.input.column("Activities",{table:this.tableInput.value,value:e.length?e[0]:null,filter:t=>e.includes(t)}),Array.from(this.activitiesInput.root.children).forEach((e=>this.activitiesInputRoot.append(e)))}}getEditor(){return r.div([this.tableInput,this.colInputRoot,this.preprocessingFunctionInputRoot,this.preprocessingFuncSettingsDiv,this.activitiesInputRoot,this.similarityMetricInputRoot,this.methodInput,this.methodSettingsDiv,this.similarityMetricInputRoot,this.similarityInput],{style:{minWidth:"320px"},classes:"ui-form dim-reduction-dialog-form"})}getParams(){return{...super.getParams(),activities:this.activitiesInput.value,similarityThreshold:this.similarityInput.value}}getInput(){return{...super.getInput(),activityCol:this.activitiesInput.value.name,simThreshold:this.similarityInput.value}}async applyInput(e){super.applyInput(e),this.activitiesInput.value=this.tableInput.value.col(e.activityCol),this.similarityInput.value=e.simThreshold}}var Te,Se,Ee;function Me(e){const t=["Embed_X","Embed_Y"],n=e.columns.names().filter((e=>e.includes(t[0]))).length+1;return t.map((e=>`${e}_${n}`))}function xe(e,t){return`${t} (${e.length>4?`${e.length} columns`:e.map((e=>e.name)).join(", ")})`}async function Le(e,t,i,o,c,u,h,d=!0,p=!1,m={preprocessingFuncArgs:[]},g={},f=null,y={},b){const w={showXAxis:!1,showYAxis:!1,showXSelector:!1,showYSelector:!1};if(t.length!==o.length||t.length!==u.length||t.length!==c.length||t.length!==m.preprocessingFuncArgs.length)throw new Error("columns, metrics and preprocessing functions, weights and function argumentsmust have the same length");const v=d?g.tableView??s.shell.tableView(e.name)??s.shell.addTableView(e):null,A=async()=>{const A=a.TaskBarProgressIndicator.create(`Initializing ${g.scatterPlotName??"dimensionality reduction"} ...`);let C;try{const T=Me(e);function S(n,o,s){let c=null,u=null;e.columns.names().includes(T[0])?(c=e.columns.byName(T[0]),u=e.columns.byName(T[1])):(c=e.columns.add(a.Column.float(T[0],e.rowCount)),u=e.columns.add(a.Column.float(T[1],e.rowCount)),d&&!C&&(C=v.scatterPlot({...w,x:T[0],y:T[1],title:g.scatterPlotName??xe(t,i)}))),g[l.YP]&&(C?.root&&r.setUpdateIndicator(C.root,!1),c.init((e=>s[0]?s[0][e]:void 0)),u.init((e=>s[1]?s[1][e]:void 0)));const h=n/o*100;A.update(h,`Running ${g.scatterPlotName??"dimensionality reduction"}... ${h.toFixed(0)}%`)}async function E(){e.columns.add(a.Column.float(T[0],e.rowCount)),e.columns.add(a.Column.float(T[1],e.rowCount));let n=null;d&&(C=v.scatterPlot({...w,x:T[0],y:T[1],title:g.scatterPlotName??xe(t,i)}),r.setUpdateIndicator(C.root,!0));const p=s.events.onViewerClosed.subscribe((e=>{const t=e.args.viewer;t?.getOptions()?.look?.title&&C?.getOptions()?.look?.title&&t?.getOptions()?.look?.title===C?.getOptions()?.look?.title&&(s.events.fireCustomEvent(Y,{}),p.unsubscribe(),n?.(),A.close())})),f=new Promise((async(s,r)=>{try{n=s;const r=[];let a=o,d=c,p=h;if(b&&t.every((e=>e.isNumerical))){const n=t.map((e=>e.toList())),i=new Array(e.rowCount).fill(0).map(((e,n)=>new Float32Array(t.length)));for(let o=0;o<t.length;++o)for(let t=0;t<e.rowCount;++t)i[t][o]=n[o][t];m.distanceFnArgs=[{}],r.push({entries:i,options:{}}),a=[b],d=[1],p="MANHATTAN"}else for(let e=0;e<u.length;++e){const n=u[e];if(m.distanceFnArgs||(m.distanceFnArgs=[]),n){const i=n.inputs[0].name,s=n.inputs[1].name,{entries:a,options:l}=await n.apply({[i]:t[e],[s]:o[e],...m.preprocessingFuncArgs[e]??{}});r.push({entries:a,options:l}),m.distanceFnArgs.push(l)}else{const n=t[e].toList(),i={};r.push({entries:n,options:i}),m.distanceFnArgs.push(i)}}s(await Z(r.map((e=>e.entries)),i,a,d,h,m,g[l.vb]?void 0:S))}catch(e){r(e)}})),y=await f;return A.close(),p.unsubscribe(),y}const M=await E();if(p&&M){const x=a.TaskBarProgressIndicator.create("Clustering embeddings ...");try{const L=await function(e,t,i,o){return function(e,t,n,i){return new(n||(n=Promise))((function(o,s){function r(e){try{l(i.next(e))}catch(e){s(e)}}function a(e){try{l(i.throw(e))}catch(e){s(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,a)}l((i=i.apply(e,t||[])).next())}))}(this,void 0,void 0,(function*(){return new Promise((function(s,r){const a=new Worker(new URL(n.p+n.u(682),n.b));a.postMessage({embedX:e,embedY:t,minPts:o,epsilon:i}),a.onmessage=({data:{error:e,clusters:t}})=>{a.terminate(),e?r(e):s(t)}}))}))}(M[0],M[1],m.dbScanEpsilon??.01,m.dbScanMinPts??4),_=e.columns.getUnusedName("Cluster (DBSCAN)");e.columns.addNewString(_).init((e=>L[e].toString())),C&&(C.props.colorColumnName=_)}catch(I){s.shell.error("Clustering embeddings failed"),console.error(I)}finally{x.close()}}if(M){const P=e.columns.byName(T[0]),N=e.columns.byName(T[1]);if(P.init((e=>M[0][e])),N.init((e=>M[1][e])),f)try{const R=f.inputs[0].name,$=f.inputs[1].name;await f.prepare({[R]:P,[$]:N,...y}).call(!0)}catch(O){s.shell.error("Post-processing failed"),console.error(O)}if(C)return r.setUpdateIndicator(C.root,!1),C.helpUrl="/help/compute/sequence-space",C}}catch(H){s.shell.error("Dimensionality reduction failed"),console.error(H),A.close(),C&&r.setUpdateIndicator(C.root,!1)}};return new Promise((async(t,n)=>{try{if(g.fastRowCount&&e.rowCount>g.fastRowCount&&!g[l.vb])r.dialog().add(r.divText("Analysis might take several minutes. Do you want to continue?")).onOK((async()=>{try{const e=await A();t(e)}catch(e){n(e)}})).onCancel((()=>t(void 0))).show();else{const e=await A();t(e)}}catch(e){n(e)}}))}n(5540),function(e){e.ADD="ADD",e.SUB="SUB",e.MULT="MULT"}(Te||(Te={})),function(e){e.SQUARE="SQUARE",e.INVERSE="INVERSE",e.TRANSPOSE="TRANSPOSE",e.NORM="NORM",e.COLUMN_NORM="COLUMN_NORM"}(Se||(Se={})),function(e){e.SCALARMULT="SCALARMULT",e.SCALARADD="SCALARADD",e.SCALARPOW="SCALARPOW"}(Ee||(Ee={})),Object.prototype.toString;var _e=n(6873),Ie=n(4356),Pe=n(6717),Ne=n(4870),Re=n(3856),$e=n(6882),Oe=n(7278),He=n(5553),ke=n(6642),Fe=n(3599),De=n(673),Ge=n(8312);class Be extends ke.sD{monomerLib=null;seqHelper=null;constructor(e,t){super(e,t,ro.logger),(0,ye.pj)().then((e=>{this.monomerLib=e.getMonomerLib(),this.dirty=!0,this.gridCol?.grid?.invalidate(),this.subs.push(this.monomerLib.onChanged.subscribe((()=>{this.dirty=!0,this.gridCol?.grid?.invalidate()})))})),(0,Ge.Q)().then((e=>{this.seqHelper=e,this.dirty=!0,this.gridCol?.grid?.invalidate()}))}}var Ve=n(4139);const Ue=new class{constructor(){this.seqHandler="seq-handler",this.notationProvider="seq-handler.notation-provider"}};class We extends a.SemanticValue{get value(){return this.seqHandler.column.get(this.rowIdx)}set value(e){this.seqHandler.column.set(this.rowIdx,e)}get helm(){return this.seqHandler.getHelm(this.rowIdx)}isDna(){return this.seqHandler.alphabet===we.YI.DNA}isRna(){return this.seqHandler.alphabet===we.YI.RNA}isNaturalPeptide(){return this.seqHandler.alphabet===we.YI.PT}isHelm(){return this.seqHandler.isHelm()}constructor(e,t){if(null==t.column.dataFrame)throw new Error("Attribute .dataFrame is required for SeqValueBase from cell");const n=t.column.dataFrame.cell(e,t.column.name);super(a.SemanticValue.fromTableCell(n).dart),this.rowIdx=e,this.seqHandler=t}getSplitted(){return this.seqHandler.getSplitted(this.rowIdx)}getSplittedWithSugarsAndPhosphates(){if(!this.isDna()&&!this.isRna())return this.getSplitted();const e=(0,Oe.qp)(this.helm),t=[],n=/\(|\)/;for(let i=0;i<e.length;i++){const o=e.getOriginal(i),s=o.split(n).filter((e=>!!e));3===s.length?(t.push(s[0]),t.push(s[1]),t.push(s[2])):t.push(o)}return new Oe.Mu(t,this.seqHandler.defaultGapOriginal)}}const qe=ge.zS;function Ye(e){const t=!R().enumerate(e).some((([t,n])=>t.length>1&&0!=n&&n!=e.length-1)),n=[],i=t?"":" ";for(const[t,o]of R().enumerate(e)){let s=t;o<e.length&&(s+=`${t?"":"-"}${i}`),n.push(s)}return[n,t]}class je extends a.GridCellRenderer{seqHelper;get name(){return"sequence"}get cellType(){return"sequence"}get defaultHeight(){return 30}get defaultWidth(){return 230}hasMouseOver=!1;constructor(){super(),this.seqHelper=ro.seqHelper}getRendererBack(e){const[t,n,i]=(0,ke.BG)(e);if(n.meta.units!==ge.Hi.CUSTOM)return i.rendererBack;let o=null;return this.seqHelper&&(o=this.seqHelper.getSeqHandler(n).getRendererBack(t,n)),o}onClick(e,t){if(e.cell.column.temp["current-word"]=e.cell.value,e.grid.invalidate(),e.cell.column.meta.units===ge.Hi.CUSTOM){const n=this.getRendererBack(e);n?.onClick(e,t)}}onMouseEnter(e,t){const n=this.getRendererBack(e);n?.onMouseEnter(e,t),this.hasMouseOver=!0}onMouseMove(e,t){const n=this.getRendererBack(e);n?.onMouseMove(e,t)}onMouseLeave(e,t){if((0,He.WN)(e,null),e?.grid){const t=e.grid.onEvent("d4-grid-show-tooltip").subscribe((e=>{t.unsubscribe(),this.hasMouseOver&&e.preventDefault()}))}this.hasMouseOver=!1}onDoubleClick(e,t){const n=this.getRendererBack(e);n?.onDoubleClick(e,t)}onKeyDown(e,t){const n=this.getRendererBack(e);n?.onKeyDown(e,t)}onKeyPress(e,t){const n=this.getRendererBack(e);n?.onKeyPress(e,t)}renderInt(e,t,n,i,o,s,r){const[a,l,c]=(0,ke.BG)(s);if(!l)return;const u=l.temp,h=this.seqHelper.getSeqHandler(l);let d=(ro.properties?ro.properties.maxMonomerLength:4)??50;if(Re.gp.maxMonomerLength in l.tags){const e=parseInt(l.getTag(Re.gp.maxMonomerLength));d=!isNaN(e)&&e?e:50}if(".mm.cellRenderer.maxMonomerLength"in u){const e=u[".mm.cellRenderer.maxMonomerLength"];d=!isNaN(e)&&e?e:50}let p=c.rendererBack;p||(p=c.rendererBack=new $e.Jy(a,l,ro.logger,d,(()=>{const{font:e,fontWidth:t}=$e.Jy.getFontSettings(l);return{font:e,fontCharWidth:t,separatorWidth:h.isMsa()?8:0,monomerToShort:qe}})),l.temp[".mm.cellRenderer.settingsChanged"],De.s.true,p.init().then((()=>{}))),p.render(e,t,n,i,o,s,r)}render(e,t,n,i,o,s,r){if(s.cell.column?.meta?.units!==ge.Hi.CUSTOM)this.renderInt(e,t,n,i,o,s,r);else{const a=this.getRendererBack(s);a?.render(e,t,n,i,o,s,r)}}}class Ke extends Be{constructor(e,t){super(e,t)}render(e,t,n,i,o,s,r){const a=window.devicePixelRatio,l=s.grid,c=s.cell.value??"",u=this.tableCol.tags[ge.gp.separator],h=this.tableCol.meta.units;i=(0,$e.U0)(l,e,t,i,a);const[d,p]=c.split("#"),m=this.tableCol.temp[Ue.notationProvider]?.separatorSplitter??(0,Oe.Iv)(h,u),g=m(d),f=m(p),y=R().count(0).take(g.length).map((e=>g.getCanonical(e))).toArray(),b=R().count(0).take(f.length).map((e=>f.getCanonical(e))).toArray(),w=this.tableCol.getTag(ge.gp.alphabet);Ze(e,t,n,i,o,y,b,w===ge.YI.RNA||w===ge.YI.DNA?Fe.o.NUCLEOTIDE:Fe.o.AA,this.monomerLib,void 0,void 0)}async awaitRendered(e=1e4,t=`${e} timeout`){return Promise.resolve()}static getOrCreate(e){const[t,n,i]=(0,ke.BG)(e);let o=i.rendererBack;return o||(o=i.rendererBack=new Ke(t,n)),o}}class ze extends a.GridCellRenderer{get name(){return"MacromoleculeDifferenceCR"}get cellType(){return Ve.uF.MACROMOLECULE_DIFFERENCE}get defaultHeight(){return 30}get defaultWidth(){return 230}render(e,t,n,i,o,s,r){Ke.getOrCreate(s).render(e,t,n,i,o,s,r)}}function Ze(e,t,n,i,o,s,r,a,l,c,u){if(s.length!==r.length){const e=function(e,t){let n=0,i=0;const o=e.length>t.length?e:t,s=e.length>t.length?t:e;for(let e=0;e<s.length;e++)o[e]===s[e]&&n++;const r=o.length-s.length;for(let e=o.length-1;e>r;e--)o[e]===s[e-r]&&i++;const a=new Array(Math.abs(e.length-t.length)).fill(we.b9[ge.Hi.FASTA]);function l(e){return n>i?e.concat(a):a.concat(e)}return e.length>t.length?t=l(R()(t).toArray()):e=l(R()(e).toArray()),{subParts1:e,subParts2:t}}(s,r);s=e.subParts1,r=e.subParts2}const h=e.measureText(Ye(s).join("")),d=e.measureText(Ye(r).join("")),p=Math.max(h.width,d.width);c&&(i=p+4*s.length,e.canvas.width=p+4*s.length);let m=Math.max(t,t+(i-(p+4*s.length))/2)+5;const g=Math.max(n,n+(o-28)/2);e.save();try{e.beginPath(),e.rect(t,n,c?p+4*s.length:i,o),e.clip(),e.font="12px monospace",e.textBaseline="top";const h=7;for(let t=0;t<s.length;t++){const n=s[t],c=r[t];let d=$e.S$;if(l&&(d=l.getMonomerTextColor(a,n)),n!=c){let s=$e.S$;l&&(s=l.getMonomerTextColor(a,c));const r=(0,Re.oZ)(e,n,m,g-h,i,o,{color:d,pivot:0,left:!0}),p=(0,Re.oZ)(e,c,m,g+h,i,o,{color:s,pivot:0,left:!0});m=Math.max(p,r),u&&(u[t]=Xe(n,c,d,s,g,h,o))}else m=(0,Re.oZ)(e,n,m,g,i,o,{color:d,pivot:0,left:!0,transparencyRate:.5});m+=4}}finally{e.restore()}}function Xe(e,t,n,i,o,s,r){const a=document.createElement("canvas"),l=a.getContext("2d");l.font="12px monospace";const c=l.measureText(Ye([e]).join("")).width,u=l.measureText(Ye([t]).join("")).width,h=Math.max(c,u);return a.height=r,a.width=h+4,l.font="12px monospace",l.textBaseline="top",(0,Re.oZ)(l,e,0,o-s,h,r,{color:n,pivot:0,left:!0}),(0,Re.oZ)(l,t,0,o+s,h,r,{color:i,pivot:0,left:!0}),a}var Je,Qe=n(8070),et=n(4326);!function(e){e.Unknown="unknown",e.FR="framework",e.CDR="cdr"}(Je||(Je={}));const tt=new class{constructor(){this.regionTypes=[Je.CDR],this.chains=["Heavy","Light"],this.skipEmptyPositions=!1,this.fitWidth=!1,this.positionWidth=16,this.positionHeight=et.fH.Entropy,this.filterSource=et.Fo.filterSource}};var nt=n(7602),it=n(250);const ot=Je;var st,rt;!function(e){e.STYLE="Style",e.BEHAVIOR="Behavior",e.LAYOUT="Layout",e.DATA="Data"}(st||(st={})),function(e){e.skipEmptyPositions="skipEmptyPositions",e.regionTypes="regionTypes",e.chains="chains",e.fitWidth="fitWidth",e.positionWidth="positionWidth",e.positionHeight="positionHeight",e.filterSource="filterSource"}(rt||(rt={}));const at=tt;class lt extends a.JsViewer{viewed=!1;regionsFg=null;regionsRoot=null;isOpened=!1;panelNode=null;regions=[];regionTypes;chains;skipEmptyPositions;fitWidth;positionWidth;positionHeight;filterSource;constructor(){super(),this.skipEmptyPositions=this.bool(rt.skipEmptyPositions,at.skipEmptyPositions,{category:st.DATA}),this.regionTypes=this.stringList(rt.regionTypes,at.regionTypes,{category:st.DATA,choices:Object.values(ot).filter((e=>e!=ot.Unknown))}),this.chains=this.stringList(rt.chains,at.chains,{category:st.DATA,choices:["Heavy","Light"]}),this.fitWidth=this.bool(rt.fitWidth,at.fitWidth,{category:st.LAYOUT}),this.positionWidth=this.float(rt.positionWidth,at.positionWidth,{category:st.LAYOUT,editor:"slider",min:0,max:64,description:"Internal WebLogo viewers property width of position."}),this.positionHeight=this.string(rt.positionHeight,at.positionHeight,{category:st.LAYOUT,choices:Object.keys(et.fH)}),this.filterSource=this.string(rt.filterSource,at.filterSource,{category:st.BEHAVIOR,choices:Object.values(et.lT)}),this.viewSyncer=new nt.g(ro.logger)}static viewerCounter=-1;viewerId=++lt.viewerCounter;viewerToLog(){return`VdRegionsViewer<${this.viewerId}>`}async init(){this.subs.push((0,u.fromEvent)(this.root,"mousemove").subscribe(this.rootOnMouseMove.bind(this)))}detach(){const e=`${this.viewerToLog()}.detach()`,t=super.detach.bind(this);this.viewSyncer.sync(`${e}`,(async()=>{this.setDataInProgress||(this.viewed&&(await this.destroyView("detach"),this.viewed=!1),t())}))}onTableAttached(){super.onTableAttached(),this.setData(this.regions)}onPropertyChanged(e){if(super.onPropertyChanged(e),e){switch(e.name){case rt.regionTypes:case rt.chains:this.setData(this.regions)}switch(e.name){case rt.skipEmptyPositions:for(let e=0;e<this.logos.length;++e)for(const t of this.chains)this.logos[e][t].setOptions({[it.n5.skipEmptyPositions]:this.skipEmptyPositions});this.calcSize();break;case rt.fitWidth:case rt.positionWidth:this.calcSize();break;case rt.positionHeight:for(let e=0;e<this.logos.length;++e)for(const t of this.chains)this.logos[e][t].setOptions({[it.n5.positionHeight]:this.positionHeight});this.calcSize();break;case rt.filterSource:this.filterSourceInput.value=this.filterSource;break;default:this.setData(this.regions)}}else console.warn("Bio: VdRegionsViewer.onPropertyChanged() property is null")}setData(e){const t=`${this.viewerToLog()}.setData()`;ro.logger.debug(`${t}, in, regions.length = ${e.length}`),this.viewSyncer.sync(`${t}`,(async()=>{if(!this.setDataInProgress){this.setDataInProgress=!0;try{this.viewed&&(await this.destroyView("setData"),this.viewed=!1),this.regions=e,this.viewed||(await this.buildView("setData"),this.viewed=!0)}finally{this.setDataInProgress=!1}}}))}viewSyncer;setDataInProgress=!1;host=null;filterSourceInput;mainLayout=null;logos=[];viewSubs=[];async destroyView(e){ro.logger.debug(`Bio: VdRegionsViewer.destroyView( mainLayout = ${this.mainLayout?"value":"none"} ), purpose = '${e}', this.regions.length = ${this.regions.length}`),this.filterSourceInput&&r.empty(this.filterSourceInput.root),null!=this.mainLayout&&(this.mainLayout.remove(),this.host.remove(),this.host=null,this.mainLayout=null);for(const e of this.viewSubs)e.unsubscribe()}async buildView(e){ro.logger.debug(`Bio: VdRegionsViewer.buildView() begin, purpose = '${e}', this.regions.length = ${this.regions.length}`);const t=this.regions.filter((e=>this.regionTypes.includes(e.type))),n=Array.from(new Set(t.map((e=>e.order)))).sort(),i=[];for(let e=0;e<n.length;e++)for(const o of this.chains){const s=t.find((t=>t.order==n[e]&&t.chain==o));i.push((async()=>{const t=await this.dataFrame.plot.fromType("WebLogo",{sequenceColumnName:s.sequenceColumnName,startPositionName:s.positionStartName,endPositionName:s.positionEndName,fixWidth:!0,skipEmptyPositions:this.skipEmptyPositions,positionWidth:this.positionWidth,positionHeight:this.positionHeight,filterSource:this.filterSource});return t.onSizeChanged.subscribe((()=>{this.calcSize()})),[e,o,t]})())}const o=await Promise.all(i);this.logos=new Array(n.length);for(let e=0;e<n.length;++e)this.logos[e]={};for(const[e,t,n]of o)this.logos[e][t]=n,this.viewSubs.push(n.onFreqsCalculated.subscribe((()=>{this.calcSize()})));this.mainLayout=r.table(this.chains,(e=>[...n.length>0?[r.div(e,{style:{transform:"rotate(-90deg)",font:"12px Roboto, Roboto Local, sans-serif",textAlign:"center",width:"16px",marginTop:"24px",marginLeft:"6px"}})]:[],...[...Array(n.length).keys()].map((t=>{const n=this.logos[t][e];return n.root.style.height="100%",r.div([n.root],{style:{marginTop:"4px",marginBottom:"4px"}})}))]),["",...[...Array(n.length).keys()].map((e=>t.find((t=>t.order==n[e]&&t.chain==this.chains[0])).name||"Name"))]),this.mainLayout.className="mlb-vd-regions-viewer-table2",this.filterSourceInput=r.input.choice("Data source",{value:this.filterSource,items:Object.values(et.lT),onValueChanged:this.filterSourceInputOnValueChanged.bind(this)}),this.filterSourceInput.root.style.position="absolute",this.filterSourceInput.root.style.right="9px",this.filterSourceInput.root.style.top="-4px",Math.ceil(255*Math.random()).toString(16),this.host=r.div([this.mainLayout,this.filterSourceInput.root],{}),this.root.appendChild(this.host),this.root.style.overflowX="auto",this.calcSize(),this.viewSubs.push(r.onSizeChanged(this.root).subscribe(this.rootOnSizeChanged.bind(this))),ro.logger.debug("Bio: VdRegionsViewer.buildView() end")}calcSizeRequested=!1;calcSize(){ro.logger.debug("Bio: VdRegionsViewer.calcSize(), start");const e=()=>{if(!this.host)return;const e=(this.root.clientHeight-54)/this.chains.length;let t=0;for(let n=0;n<this.logos.length;n++){for(const t of this.chains)this.logos[n][t].root.style.height=`${e}px`;t+=Math.max(...this.chains.map((e=>this.logos[n][e].Length)))}if(this.fitWidth){if(this.logos.length>0&&t>0){const e=22,n=13,i=9,o=(this.root.clientWidth-e-(this.logos.length-1)*i-n)/t;for(let e=0;e<this.logos.length;e++)for(const t of this.chains){const n=this.logos[e][t];n.setOptions({[it.n5.positionWidth]:o-n.positionMarginValue}),n.root.style.width=o*n.Length+"px"}}this.host.style.setProperty("overflow","hidden","important")}else{for(let e=0;e<this.logos.length;e++)for(const t of this.chains)this.logos[e][t].setOptions({[it.n5.positionWidth]:this.positionWidth});this.host.style.removeProperty("overflow")}0===this.positionWidth?this.host.style.setProperty("overflow-x","hidden","important"):this.host.style.removeProperty("overflow-x")};this.calcSizeRequested||(this.calcSizeRequested=!0,window.setTimeout((()=>{e(),this.calcSizeRequested=!1}),0))}rootOnSizeChanged(e){this.calcSize()}rootOnMouseMove(e){}filterSourceInputOnValueChanged(){const e=`${this.viewerToLog()}.filterSourceInputOnValueChanged()`,t=this.filterSourceInput.value;this.viewSyncer.sync(`${e}`,(async()=>{if(this.filterSource!==t){this.props.getProperty(rt.filterSource).set(this,t);for(let e=0;e<this.logos.length;e++)for(let t=0;t<this.chains.length;t++){const n=this.chains[t];this.logos[e][n].setOptions({[it.n5.filterSource]:this.filterSource})}}}))}_onRendered=new u.Subject;get onRendered(){return this._onRendered}invalidate(e){const t=`${this.viewerToLog()}.invalidate(${e?` <- ${e} `:""})`;this.viewSyncer.sync(`${t}`,(async()=>{this._onRendered.next()}))}async awaitRendered(e=5e3){await(0,Qe.PE)(this.onRendered,(()=>{}),(()=>{this.invalidate()}),e);const t=this.viewSyncer.resetErrors();if(t.length>0)throw t[0]}}class ct{value;parentI;parentJ;constructor(){this.value=0,this.parentI=0,this.parentJ=0}}class ut{seq1;seq2;score;constructor(e,t,n){this.seq1=e,this.seq2=t,this.score=n}}class ht{seq1="";seq2="";gap=1;len1=0;len2=0;step=1;alignGrid=[];scores=[];dpGrid=[];connections={};BLOSUM45=[[5,-2,-1,-2,-1,-1,-1,0,-2,-1,-1,-1,-1,-2,-1,1,0,-2,-2,0,-1,-1,0,-5],[-2,7,0,-1,-3,1,0,-2,0,-3,-2,3,-1,-2,-2,-1,-1,-2,-1,-2,-1,0,-1,-5],[-1,0,6,2,-2,0,0,0,1,-2,-3,0,-2,-2,-2,1,0,-4,-2,-3,4,0,-1,-5],[-2,-1,2,7,-3,0,2,-1,0,-4,-3,0,-3,-4,-1,0,-1,-4,-2,-3,5,1,-1,-5],[-1,-3,-2,-3,12,-3,-3,-3,-3,-3,-2,-3,-2,-2,-4,-1,-1,-5,-3,-1,-2,-3,-2,-5],[-1,1,0,0,-3,6,2,-2,1,-2,-2,1,0,-4,-1,0,-1,-2,-1,-3,0,4,-1,-5],[-1,0,0,2,-3,2,6,-2,0,-3,-2,1,-2,-3,0,0,-1,-3,-2,-3,1,4,-1,-5],[0,-2,0,-1,-3,-2,-2,7,-2,-4,-3,-2,-2,-3,-2,0,-2,-2,-3,-3,-1,-2,-1,-5],[-2,0,1,0,-3,1,0,-2,10,-3,-2,-1,0,-2,-2,-1,-2,-3,2,-3,0,0,-1,-5],[-1,-3,-2,-4,-3,-2,-3,-4,-3,5,2,-3,2,0,-2,-2,-1,-2,0,3,-3,-3,-1,-5],[-1,-2,-3,-3,-2,-2,-2,-3,-2,2,5,-3,2,1,-3,-3,-1,-2,0,1,-3,-2,-1,-5],[-1,3,0,0,-3,1,1,-2,-1,-3,-3,5,-1,-3,-1,-1,-1,-2,-1,-2,0,1,-1,-5],[-1,-1,-2,-3,-2,0,-2,-2,0,2,2,-1,6,0,-2,-2,-1,-2,0,1,-2,-1,-1,-5],[-2,-2,-2,-4,-2,-4,-3,-3,-2,0,1,-3,0,8,-3,-2,-1,1,3,0,-3,-3,-1,-5],[-1,-2,-2,-1,-4,-1,0,-2,-2,-2,-3,-1,-2,-3,9,-1,-1,-3,-3,-3,-2,-1,-1,-5],[1,-1,1,0,-1,0,0,0,-1,-2,-3,-1,-2,-2,-1,4,2,-4,-2,-1,0,0,0,-5],[0,-1,0,-1,-1,-1,-1,-2,-2,-1,-1,-1,-1,-1,-1,2,5,-3,-1,0,0,-1,0,-5],[-2,-2,-4,-4,-5,-2,-3,-2,-3,-2,-2,-2,-2,1,-3,-4,-3,15,3,-3,-4,-2,-2,-5],[-2,-1,-2,-2,-3,-1,-2,-3,2,0,0,-1,0,3,-3,-2,-1,3,8,-1,-2,-2,-1,-5],[0,-2,-3,-3,-1,-3,-3,-3,-3,3,1,-2,1,0,-3,-1,0,-3,-1,5,-3,-3,-1,-5],[-1,-1,4,5,-2,0,1,-1,0,-3,-3,0,-2,-3,-2,0,0,-4,-2,-3,4,2,-1,-5],[-1,0,0,1,-3,4,4,-2,0,-3,-2,1,-1,-3,-1,0,-1,-2,-2,-3,2,4,-1,-5],[0,-1,-1,-1,-2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,0,-2,-1,-1,-1,-1,-1,-5],[-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,1]];BLOSUM50=[[5,-2,-1,-2,-1,-1,-1,0,-2,-1,-2,-1,-1,-3,-1,1,0,-3,-2,0,-2,-1,-1,-5],[-2,7,-1,-2,-4,1,0,-3,0,-4,-3,3,-2,-3,-3,-1,-1,-3,-1,-3,-1,0,-1,-5],[-1,-1,7,2,-2,0,0,0,1,-3,-4,0,-2,-4,-2,1,0,-4,-2,-3,4,0,-1,-5],[-2,-2,2,8,-4,0,2,-1,-1,-4,-4,-1,-4,-5,-1,0,-1,-5,-3,-4,5,1,-1,-5],[-1,-4,-2,-4,13,-3,-3,-3,-3,-2,-2,-3,-2,-2,-4,-1,-1,-5,-3,-1,-3,-3,-2,-5],[-1,1,0,0,-3,7,2,-2,1,-3,-2,2,0,-4,-1,0,-1,-1,-1,-3,0,4,-1,-5],[-1,0,0,2,-3,2,6,-3,0,-4,-3,1,-2,-3,-1,-1,-1,-3,-2,-3,1,5,-1,-5],[0,-3,0,-1,-3,-2,-3,8,-2,-4,-4,-2,-3,-4,-2,0,-2,-3,-3,-4,-1,-2,-2,-5],[-2,0,1,-1,-3,1,0,-2,10,-4,-3,0,-1,-1,-2,-1,-2,-3,2,-4,0,0,-1,-5],[-1,-4,-3,-4,-2,-3,-4,-4,-4,5,2,-3,2,0,-3,-3,-1,-3,-1,4,-4,-3,-1,-5],[-2,-3,-4,-4,-2,-2,-3,-4,-3,2,5,-3,3,1,-4,-3,-1,-2,-1,1,-4,-3,-1,-5],[-1,3,0,-1,-3,2,1,-2,0,-3,-3,6,-2,-4,-1,0,-1,-3,-2,-3,0,1,-1,-5],[-1,-2,-2,-4,-2,0,-2,-3,-1,2,3,-2,7,0,-3,-2,-1,-1,0,1,-3,-1,-1,-5],[-3,-3,-4,-5,-2,-4,-3,-4,-1,0,1,-4,0,8,-4,-3,-2,1,4,-1,-4,-4,-2,-5],[-1,-3,-2,-1,-4,-1,-1,-2,-2,-3,-4,-1,-3,-4,10,-1,-1,-4,-3,-3,-2,-1,-2,-5],[1,-1,1,0,-1,0,-1,0,-1,-3,-3,0,-2,-3,-1,5,2,-4,-2,-2,0,0,-1,-5],[0,-1,0,-1,-1,-1,-1,-2,-2,-1,-1,-1,-1,-2,-1,2,5,-3,-2,0,0,-1,0,-5],[-3,-3,-4,-5,-5,-1,-3,-3,-3,-3,-2,-3,-1,1,-4,-4,-3,15,2,-3,-5,-2,-3,-5],[-2,-1,-2,-3,-3,-1,-2,-3,2,-1,-1,-2,0,4,-3,-2,-2,2,8,-1,-3,-2,-1,-5],[0,-3,-3,-4,-1,-3,-3,-4,-4,4,1,-3,1,-1,-3,-2,0,-3,-1,5,-4,-3,-1,-5],[-2,-1,4,5,-3,0,1,-1,0,-4,-4,0,-3,-4,-2,0,0,-5,-3,-4,5,2,-1,-5],[-1,0,0,1,-3,4,5,-2,0,-3,-3,1,-1,-4,-1,0,-1,-2,-2,-3,2,5,-1,-5],[-1,-1,-1,-1,-2,-1,-1,-2,-1,-1,-1,-1,-1,-2,-2,-1,0,-3,-1,-1,-1,-1,-1,-5],[-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,1]];BLOSUM62=[[4,-1,-2,-2,0,-1,-1,0,-2,-1,-1,-1,-1,-2,-1,1,0,-3,-2,0,-2,-1,0,-4],[-1,5,0,-2,-3,1,0,-2,0,-3,-2,2,-1,-3,-2,-1,-1,-3,-2,-3,-1,0,-1,-4],[-2,0,6,1,-3,0,0,0,1,-3,-3,0,-2,-3,-2,1,0,-4,-2,-3,3,0,-1,-4],[-2,-2,1,6,-3,0,2,-1,-1,-3,-4,-1,-3,-3,-1,0,-1,-4,-3,-3,4,1,-1,-4],[0,-3,-3,-3,9,-3,-4,-3,-3,-1,-1,-3,-1,-2,-3,-1,-1,-2,-2,-1,-3,-3,-2,-4],[-1,1,0,0,-3,5,2,-2,0,-3,-2,1,0,-3,-1,0,-1,-2,-1,-2,0,3,-1,-4],[-1,0,0,2,-4,2,5,-2,0,-3,-3,1,-2,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-2,0,-1,-3,-2,-2,6,-2,-4,-4,-2,-3,-3,-2,0,-2,-2,-3,-3,-1,-2,-1,-4],[-2,0,1,-1,-3,0,0,-2,8,-3,-3,-1,-2,-1,-2,-1,-2,-2,2,-3,0,0,-1,-4],[-1,-3,-3,-3,-1,-3,-3,-4,-3,4,2,-3,1,0,-3,-2,-1,-3,-1,3,-3,-3,-1,-4],[-1,-2,-3,-4,-1,-2,-3,-4,-3,2,4,-2,2,0,-3,-2,-1,-2,-1,1,-4,-3,-1,-4],[-1,2,0,-1,-3,1,1,-2,-1,-3,-2,5,-1,-3,-1,0,-1,-3,-2,-2,0,1,-1,-4],[-1,-1,-2,-3,-1,0,-2,-3,-2,1,2,-1,5,0,-2,-1,-1,-1,-1,1,-3,-1,-1,-4],[-2,-3,-3,-3,-2,-3,-3,-3,-1,0,0,-3,0,6,-4,-2,-2,1,3,-1,-3,-3,-1,-4],[-1,-2,-2,-1,-3,-1,-1,-2,-2,-3,-3,-1,-2,-4,7,-1,-1,-4,-3,-2,-2,-1,-2,-4],[1,-1,1,0,-1,0,0,0,-1,-2,-2,0,-1,-2,-1,4,1,-3,-2,-2,0,0,0,-4],[0,-1,0,-1,-1,-1,-1,-2,-2,-1,-1,-1,-1,-2,-1,1,5,-2,-2,0,-1,-1,0,-4],[-3,-3,-4,-4,-2,-2,-3,-2,-2,-3,-2,-3,-1,1,-4,-3,-2,11,2,-3,-4,-3,-2,-4],[-2,-2,-2,-3,-2,-1,-2,-3,2,-1,-1,-2,-1,3,-3,-2,-2,2,7,-1,-3,-2,-1,-4],[0,-3,-3,-3,-1,-2,-2,-3,-3,3,1,-2,1,-1,-2,-2,0,-3,-1,4,-3,-2,-1,-4],[-2,-1,3,4,-3,0,1,-1,0,-3,-4,0,-3,-3,-2,0,-1,-4,-3,-3,4,1,-1,-4],[-1,0,0,1,-3,3,4,-2,0,-3,-3,1,-1,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-1,-1,-1,-2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-2,0,0,-2,-1,-1,-1,-1,-1,-4],[-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,1]];BLOSUM80=[[7,-3,-3,-3,-1,-2,-2,0,-3,-3,-3,-1,-2,-4,-1,2,0,-5,-4,-1,-3,-2,-1,-8],[-3,9,-1,-3,-6,1,-1,-4,0,-5,-4,3,-3,-5,-3,-2,-2,-5,-4,-4,-2,0,-2,-8],[-3,-1,9,2,-5,0,-1,-1,1,-6,-6,0,-4,-6,-4,1,0,-7,-4,-5,5,-1,-2,-8],[-3,-3,2,10,-7,-1,2,-3,-2,-7,-7,-2,-6,-6,-3,-1,-2,-8,-6,-6,6,1,-3,-8],[-1,-6,-5,-7,13,-5,-7,-6,-7,-2,-3,-6,-3,-4,-6,-2,-2,-5,-5,-2,-6,-7,-4,-8],[-2,1,0,-1,-5,9,3,-4,1,-5,-4,2,-1,-5,-3,-1,-1,-4,-3,-4,-1,5,-2,-8],[-2,-1,-1,2,-7,3,8,-4,0,-6,-6,1,-4,-6,-2,-1,-2,-6,-5,-4,1,6,-2,-8],[0,-4,-1,-3,-6,-4,-4,9,-4,-7,-7,-3,-5,-6,-5,-1,-3,-6,-6,-6,-2,-4,-3,-8],[-3,0,1,-2,-7,1,0,-4,12,-6,-5,-1,-4,-2,-4,-2,-3,-4,3,-5,-1,0,-2,-8],[-3,-5,-6,-7,-2,-5,-6,-7,-6,7,2,-5,2,-1,-5,-4,-2,-5,-3,4,-6,-6,-2,-8],[-3,-4,-6,-7,-3,-4,-6,-7,-5,2,6,-4,3,0,-5,-4,-3,-4,-2,1,-7,-5,-2,-8],[-1,3,0,-2,-6,2,1,-3,-1,-5,-4,8,-3,-5,-2,-1,-1,-6,-4,-4,-1,1,-2,-8],[-2,-3,-4,-6,-3,-1,-4,-5,-4,2,3,-3,9,0,-4,-3,-1,-3,-3,1,-5,-3,-2,-8],[-4,-5,-6,-6,-4,-5,-6,-6,-2,-1,0,-5,0,10,-6,-4,-4,0,4,-2,-6,-6,-3,-8],[-1,-3,-4,-3,-6,-3,-2,-5,-4,-5,-5,-2,-4,-6,12,-2,-3,-7,-6,-4,-4,-2,-3,-8],[2,-2,1,-1,-2,-1,-1,-1,-2,-4,-4,-1,-3,-4,-2,7,2,-6,-3,-3,0,-1,-1,-8],[0,-2,0,-2,-2,-1,-2,-3,-3,-2,-3,-1,-1,-4,-3,2,8,-5,-3,0,-1,-2,-1,-8],[-5,-5,-7,-8,-5,-4,-6,-6,-4,-5,-4,-6,-3,0,-7,-6,-5,16,3,-5,-8,-5,-5,-8],[-4,-4,-4,-6,-5,-3,-5,-6,3,-3,-2,-4,-3,4,-6,-3,-3,3,11,-3,-5,-4,-3,-8],[-1,-4,-5,-6,-2,-4,-4,-6,-5,4,1,-4,1,-2,-4,-3,0,-5,-3,7,-6,-4,-2,-8],[-3,-2,5,6,-6,-1,1,-2,-1,-6,-7,-1,-5,-6,-4,0,-1,-8,-5,-6,6,0,-3,-8],[-2,0,-1,1,-7,5,6,-4,0,-6,-5,1,-3,-6,-2,-1,-2,-5,-4,-4,0,6,-1,-8],[-1,-2,-2,-3,-4,-2,-2,-3,-2,-2,-2,-2,-2,-3,-3,-1,-1,-5,-3,-2,-3,-1,-2,-8],[-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,1]];BLOSUM90=[[5,-2,-2,-3,-1,-1,-1,0,-2,-2,-2,-1,-2,-3,-1,1,0,-4,-3,-1,-2,-1,-1,-6],[-2,6,-1,-3,-5,1,-1,-3,0,-4,-3,2,-2,-4,-3,-1,-2,-4,-3,-3,-2,0,-2,-6],[-2,-1,7,1,-4,0,-1,-1,0,-4,-4,0,-3,-4,-3,0,0,-5,-3,-4,4,-1,-2,-6],[-3,-3,1,7,-5,-1,1,-2,-2,-5,-5,-1,-4,-5,-3,-1,-2,-6,-4,-5,4,0,-2,-6],[-1,-5,-4,-5,9,-4,-6,-4,-5,-2,-2,-4,-2,-3,-4,-2,-2,-4,-4,-2,-4,-5,-3,-6],[-1,1,0,-1,-4,7,2,-3,1,-4,-3,1,0,-4,-2,-1,-1,-3,-3,-3,-1,4,-1,-6],[-1,-1,-1,1,-6,2,6,-3,-1,-4,-4,0,-3,-5,-2,-1,-1,-5,-4,-3,0,4,-2,-6],[0,-3,-1,-2,-4,-3,-3,6,-3,-5,-5,-2,-4,-5,-3,-1,-3,-4,-5,-5,-2,-3,-2,-6],[-2,0,0,-2,-5,1,-1,-3,8,-4,-4,-1,-3,-2,-3,-2,-2,-3,1,-4,-1,0,-2,-6],[-2,-4,-4,-5,-2,-4,-4,-5,-4,5,1,-4,1,-1,-4,-3,-1,-4,-2,3,-5,-4,-2,-6],[-2,-3,-4,-5,-2,-3,-4,-5,-4,1,5,-3,2,0,-4,-3,-2,-3,-2,0,-5,-4,-2,-6],[-1,2,0,-1,-4,1,0,-2,-1,-4,-3,6,-2,-4,-2,-1,-1,-5,-3,-3,-1,1,-1,-6],[-2,-2,-3,-4,-2,0,-3,-4,-3,1,2,-2,7,-1,-3,-2,-1,-2,-2,0,-4,-2,-1,-6],[-3,-4,-4,-5,-3,-4,-5,-5,-2,-1,0,-4,-1,7,-4,-3,-3,0,3,-2,-4,-4,-2,-6],[-1,-3,-3,-3,-4,-2,-2,-3,-3,-4,-4,-2,-3,-4,8,-2,-2,-5,-4,-3,-3,-2,-2,-6],[1,-1,0,-1,-2,-1,-1,-1,-2,-3,-3,-1,-2,-3,-2,5,1,-4,-3,-2,0,-1,-1,-6],[0,-2,0,-2,-2,-1,-1,-3,-2,-1,-2,-1,-1,-3,-2,1,6,-4,-2,-1,-1,-1,-1,-6],[-4,-4,-5,-6,-4,-3,-5,-4,-3,-4,-3,-5,-2,0,-5,-4,-4,11,2,-3,-6,-4,-3,-6],[-3,-3,-3,-4,-4,-3,-4,-5,1,-2,-2,-3,-2,3,-4,-3,-2,2,8,-3,-4,-3,-2,-6],[-1,-3,-4,-5,-2,-3,-3,-5,-4,3,0,-3,0,-2,-3,-2,-1,-3,-3,5,-4,-3,-2,-6],[-2,-2,4,4,-4,-1,0,-2,-1,-5,-5,-1,-4,-4,-3,0,-1,-6,-4,-4,4,0,-2,-6],[-1,0,-1,0,-5,4,4,-3,0,-4,-4,1,-2,-4,-2,-1,-1,-4,-3,-3,0,4,-1,-6],[-1,-2,-2,-2,-3,-1,-2,-2,-2,-2,-2,-1,-1,-2,-2,-1,-1,-3,-2,-2,-2,-1,-2,-6],[-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,1]];NUCLEOTIDES=[[1,-1,-1,-1],[-1,1,-1,-1],[-1,-1,1,-1],[-1,-1,-1,1]];PAM30=[[6,-7,-4,-3,-6,-4,-2,-2,-7,-5,-6,-7,-5,-8,-2,0,-1,-13,-8,-2,-3,-3,-3,-17],[-7,8,-6,-10,-8,-2,-9,-9,-2,-5,-8,0,-4,-9,-4,-3,-6,-2,-10,-8,-7,-4,-6,-17],[-4,-6,8,2,-11,-3,-2,-3,0,-5,-7,-1,-9,-9,-6,0,-2,-8,-4,-8,6,-3,-3,-17],[-3,-10,2,8,-14,-2,2,-3,-4,-7,-12,-4,-11,-15,-8,-4,-5,-15,-11,-8,6,1,-5,-17],[-6,-8,-11,-14,10,-14,-14,-9,-7,-6,-15,-14,-13,-13,-8,-3,-8,-15,-4,-6,-12,-14,-9,-17],[-4,-2,-3,-2,-14,8,1,-7,1,-8,-5,-3,-4,-13,-3,-5,-5,-13,-12,-7,-3,6,-5,-17],[-2,-9,-2,2,-14,1,8,-4,-5,-5,-9,-4,-7,-14,-5,-4,-6,-17,-8,-6,1,6,-5,-17],[-2,-9,-3,-3,-9,-7,-4,6,-9,-11,-10,-7,-8,-9,-6,-2,-6,-15,-14,-5,-3,-5,-5,-17],[-7,-2,0,-4,-7,1,-5,-9,9,-9,-6,-6,-10,-6,-4,-6,-7,-7,-3,-6,-1,-1,-5,-17],[-5,-5,-5,-7,-6,-8,-5,-11,-9,8,-1,-6,-1,-2,-8,-7,-2,-14,-6,2,-6,-6,-5,-17],[-6,-8,-7,-12,-15,-5,-9,-10,-6,-1,7,-8,1,-3,-7,-8,-7,-6,-7,-2,-9,-7,-6,-17],[-7,0,-1,-4,-14,-3,-4,-7,-6,-6,-8,7,-2,-14,-6,-4,-3,-12,-9,-9,-2,-4,-5,-17],[-5,-4,-9,-11,-13,-4,-7,-8,-10,-1,1,-2,11,-4,-8,-5,-4,-13,-11,-1,-10,-5,-5,-17],[-8,-9,-9,-15,-13,-13,-14,-9,-6,-2,-3,-14,-4,9,-10,-6,-9,-4,2,-8,-10,-13,-8,-17],[-2,-4,-6,-8,-8,-3,-5,-6,-4,-8,-7,-6,-8,-10,8,-2,-4,-14,-13,-6,-7,-4,-5,-17],[0,-3,0,-4,-3,-5,-4,-2,-6,-7,-8,-4,-5,-6,-2,6,0,-5,-7,-6,-1,-5,-3,-17],[-1,-6,-2,-5,-8,-5,-6,-6,-7,-2,-7,-3,-4,-9,-4,0,7,-13,-6,-3,-3,-6,-4,-17],[-13,-2,-8,-15,-15,-13,-17,-15,-7,-14,-6,-12,-13,-4,-14,-5,-13,13,-5,-15,-10,-14,-11,-17],[-8,-10,-4,-11,-4,-12,-8,-14,-3,-6,-7,-9,-11,2,-13,-7,-6,-5,10,-7,-6,-9,-7,-17],[-2,-8,-8,-8,-6,-7,-6,-5,-6,2,-2,-9,-1,-8,-6,-6,-3,-15,-7,7,-8,-6,-5,-17],[-3,-7,6,6,-12,-3,1,-3,-1,-6,-9,-2,-10,-10,-7,-1,-3,-10,-6,-8,6,0,-5,-17],[-3,-4,-3,1,-14,6,6,-5,-1,-6,-7,-4,-5,-13,-4,-5,-6,-14,-9,-6,0,6,-5,-17],[-3,-6,-3,-5,-9,-5,-5,-5,-5,-5,-6,-5,-5,-8,-5,-3,-4,-11,-7,-5,-5,-5,-5,-17],[-17,-17,-17,-17,-17,-17,-17,-17,-17,-17,-17,-17,-17,-17,-17,-17,-17,-17,-17,-17,-17,-17,-17,1]];PAM70=[[5,-4,-2,-1,-4,-2,-1,0,-4,-2,-4,-4,-3,-6,0,1,1,-9,-5,-1,-1,-1,-2,-11],[-4,8,-3,-6,-5,0,-5,-6,0,-3,-6,2,-2,-7,-2,-1,-4,0,-7,-5,-4,-2,-3,-11],[-2,-3,6,3,-7,-1,0,-1,1,-3,-5,0,-5,-6,-3,1,0,-6,-3,-5,5,-1,-2,-11],[-1,-6,3,6,-9,0,3,-1,-1,-5,-8,-2,-7,-10,-4,-1,-2,-10,-7,-5,5,2,-3,-11],[-4,-5,-7,-9,9,-9,-9,-6,-5,-4,-10,-9,-9,-8,-5,-1,-5,-11,-2,-4,-8,-9,-6,-11],[-2,0,-1,0,-9,7,2,-4,2,-5,-3,-1,-2,-9,-1,-3,-3,-8,-8,-4,-1,5,-2,-11],[-1,-5,0,3,-9,2,6,-2,-2,-4,-6,-2,-4,-9,-3,-2,-3,-11,-6,-4,2,5,-3,-11],[0,-6,-1,-1,-6,-4,-2,6,-6,-6,-7,-5,-6,-7,-3,0,-3,-10,-9,-3,-1,-3,-3,-11],[-4,0,1,-1,-5,2,-2,-6,8,-6,-4,-3,-6,-4,-2,-3,-4,-5,-1,-4,0,1,-3,-11],[-2,-3,-3,-5,-4,-5,-4,-6,-6,7,1,-4,1,0,-5,-4,-1,-9,-4,3,-4,-4,-3,-11],[-4,-6,-5,-8,-10,-3,-6,-7,-4,1,6,-5,2,-1,-5,-6,-4,-4,-4,0,-6,-4,-4,-11],[-4,2,0,-2,-9,-1,-2,-5,-3,-4,-5,6,0,-9,-4,-2,-1,-7,-7,-6,-1,-2,-3,-11],[-3,-2,-5,-7,-9,-2,-4,-6,-6,1,2,0,10,-2,-5,-3,-2,-8,-7,0,-6,-3,-3,-11],[-6,-7,-6,-10,-8,-9,-9,-7,-4,0,-1,-9,-2,8,-7,-4,-6,-2,4,-5,-7,-9,-5,-11],[0,-2,-3,-4,-5,-1,-3,-3,-2,-5,-5,-4,-5,-7,7,0,-2,-9,-9,-3,-4,-2,-3,-11],[1,-1,1,-1,-1,-3,-2,0,-3,-4,-6,-2,-3,-4,0,5,2,-3,-5,-3,0,-2,-1,-11],[1,-4,0,-2,-5,-3,-3,-3,-4,-1,-4,-1,-2,-6,-2,2,6,-8,-4,-1,-1,-3,-2,-11],[-9,0,-6,-10,-11,-8,-11,-10,-5,-9,-4,-7,-8,-2,-9,-3,-8,13,-3,-10,-7,-10,-7,-11],[-5,-7,-3,-7,-2,-8,-6,-9,-1,-4,-4,-7,-7,4,-9,-5,-4,-3,9,-5,-4,-7,-5,-11],[-1,-5,-5,-5,-4,-4,-4,-3,-4,3,0,-6,0,-5,-3,-3,-1,-10,-5,6,-5,-4,-2,-11],[-1,-4,5,5,-8,-1,2,-1,0,-4,-6,-1,-6,-7,-4,0,-1,-7,-4,-5,5,1,-2,-11],[-1,-2,-1,2,-9,5,5,-3,1,-4,-4,-2,-3,-9,-2,-2,-3,-10,-7,-4,1,5,-3,-11],[-2,-3,-2,-3,-6,-2,-3,-3,-3,-3,-4,-3,-3,-5,-3,-1,-2,-7,-5,-2,-2,-3,-3,-11],[-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,1]];PAM250=[[2,-2,0,0,-2,0,0,1,-1,-1,-2,-1,-1,-3,1,1,1,-6,-3,0,0,0,0,-8],[-2,6,0,-1,-4,1,-1,-3,2,-2,-3,3,0,-4,0,0,-1,2,-4,-2,-1,0,-1,-8],[0,0,2,2,-4,1,1,0,2,-2,-3,1,-2,-3,0,1,0,-4,-2,-2,2,1,0,-8],[0,-1,2,4,-5,2,3,1,1,-2,-4,0,-3,-6,-1,0,0,-7,-4,-2,3,3,-1,-8],[-2,-4,-4,-5,12,-5,-5,-3,-3,-2,-6,-5,-5,-4,-3,0,-2,-8,0,-2,-4,-5,-3,-8],[0,1,1,2,-5,4,2,-1,3,-2,-2,1,-1,-5,0,-1,-1,-5,-4,-2,1,3,-1,-8],[0,-1,1,3,-5,2,4,0,1,-2,-3,0,-2,-5,-1,0,0,-7,-4,-2,3,3,-1,-8],[1,-3,0,1,-3,-1,0,5,-2,-3,-4,-2,-3,-5,0,1,0,-7,-5,-1,0,0,-1,-8],[-1,2,2,1,-3,3,1,-2,6,-2,-2,0,-2,-2,0,-1,-1,-3,0,-2,1,2,-1,-8],[-1,-2,-2,-2,-2,-2,-2,-3,-2,5,2,-2,2,1,-2,-1,0,-5,-1,4,-2,-2,-1,-8],[-2,-3,-3,-4,-6,-2,-3,-4,-2,2,6,-3,4,2,-3,-3,-2,-2,-1,2,-3,-3,-1,-8],[-1,3,1,0,-5,1,0,-2,0,-2,-3,5,0,-5,-1,0,0,-3,-4,-2,1,0,-1,-8],[-1,0,-2,-3,-5,-1,-2,-3,-2,2,4,0,6,0,-2,-2,-1,-4,-2,2,-2,-2,-1,-8],[-3,-4,-3,-6,-4,-5,-5,-5,-2,1,2,-5,0,9,-5,-3,-3,0,7,-1,-4,-5,-2,-8],[1,0,0,-1,-3,0,-1,0,0,-2,-3,-1,-2,-5,6,1,0,-6,-5,-1,-1,0,-1,-8],[1,0,1,0,0,-1,0,1,-1,-1,-3,0,-2,-3,1,2,1,-2,-3,-1,0,0,0,-8],[1,-1,0,0,-2,-1,0,0,-1,0,-2,0,-1,-3,0,1,3,-5,-3,0,0,-1,0,-8],[-6,2,-4,-7,-8,-5,-7,-7,-3,-5,-2,-3,-4,0,-6,-2,-5,17,0,-6,-5,-6,-4,-8],[-3,-4,-2,-4,0,-4,-4,-5,0,-1,-1,-4,-2,7,-5,-3,-3,0,10,-2,-3,-4,-2,-8],[0,-2,-2,-2,-2,-2,-2,-1,-2,4,2,-2,2,-1,-1,-1,0,-6,-2,4,-2,-2,-1,-8],[0,-1,2,3,-4,1,3,0,1,-2,-3,1,-2,-4,-1,0,0,-5,-3,-2,3,2,-1,-8],[0,0,1,3,-5,3,3,0,2,-2,-3,0,-2,-5,0,0,-1,-6,-4,-2,2,3,-1,-8],[0,-1,0,-1,-3,-1,-1,-1,-1,-1,-1,-1,-1,-2,-1,0,0,-4,-2,-1,-1,-1,-1,-8],[-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,1]];SCHNEIDER=[[11.6,-2.7,9.7,-1.7,-2.7,-6.4,-3.9,-5.6,5.1,-5,3.6,-4.2,-6.3,-13,-7.1,-11.5,.4,-6,-1.9,-5.3,-8.5,-11.2,-8.9,-10.8,2.1,0,1.4,.2,-10.2,-13.5,-13,-12.5,-2.6,-8.5,-5,-8.1,-6.3,-9.9,-7.5,-9,-7.1,-10.2,-8.2,-9.2,-8.2,-12.5,-11.1,-11.4,-50,-14.8,-50,-13.8,-7.3,-10.1,-8.4,-9.1,-50,-13,-13.5,-12.4,-10.7,-18.1,-11.8,-17.2],[-2.7,13,-3.3,10.9,-3.5,-.4,-3.3,-1.8,-5.4,4.6,-5.5,3,-10.2,-7.9,-9.9,-9.6,-5,.5,-5.5,-1,-10.3,-8.1,-9.4,-9.6,-8.1,-5,-7.3,-6.3,-13.4,-11.3,-14.4,-12.9,-6.3,.8,-6.4,-1.1,-7.4,-5,-6.2,-6.5,-5.6,-1.6,-4.7,-3,-10.8,-8.7,-11.9,-10,-50,-6.2,-50,-7.5,-6.3,-4.3,-6.2,-5.4,-50,-7,-16.3,-8.2,-13.2,-12.3,-13.1,-13.3],[9.7,-3.3,11.6,-2.8,-4.5,-6.7,-3.1,-6.9,3.3,-5.5,4.8,-5.1,-8.9,-13.2,-5.7,-12.6,-1.5,-6.1,-.6,-6.1,-10,-11.8,-8.6,-11.9,1.2,.5,2.2,.1,-11.8,-14,-11.9,-13.4,-4.9,-9.1,-3.4,-8.9,-8,-10,-7.2,-10,-9.1,-10.2,-7.1,-9.9,-10.1,-13,-10.6,-12.7,-50,-14.9,-50,-14.4,-8.9,-10.8,-8.9,-10.4,-50,-13.1,-11.8,-13,-12.4,-19.4,-11.5,-17.8],[-1.7,10.9,-2.8,12.9,-2.7,-2.2,-2.8,.2,-4.8,2.9,-5.2,5.2,-9.1,-9.5,-9,-7,-4,-1,-5,1,-9,-8.8,-8.9,-7.7,-7,-6.8,-7.1,-4.3,-12.4,-12.9,-13.9,-10,-4.9,-.7,-5.6,1.4,-6,-6.5,-6.2,-4.8,-5.1,-3.2,-5,-1.2,-9.8,-9.9,-11.3,-8.2,-50,-7.6,-50,-5.1,-5.5,-5.8,-5.9,-4.2,-50,-8.3,-15.5,-5.9,-11.6,-14.2,-12,-11.6],[-2.7,-3.5,-4.5,-2.7,11.7,9,10.6,9.6,-3.2,-.7,-5.1,-.4,.7,-4.6,-.4,-3.6,-4.8,-8.9,-6.5,-7.8,-1.4,-4.1,-2.9,-3.3,-8,-9.1,-8,-8.2,-6,-9.3,-7.7,-8.5,-6.4,-10.1,-7.5,-8.6,2.8,-.7,.9,.1,-5.9,-7.3,-6.5,-6.5,-.4,-3.9,-2.6,-3.1,-50,-14.6,-50,-12.6,2.9,.1,1.8,1,-50,-9.2,-13.6,-7.7,-4.8,-12.2,-6.2,-11],[-6.4,-.4,-6.7,-2.2,9,12.3,9.8,9.6,-7.1,2.4,-7.2,.3,-2.9,-1.2,-3,-3.3,-7.6,-6.7,-8.1,-7.9,-4.9,-1.9,-4.5,-3.8,-9.5,-7.8,-9.3,-8.9,-9.4,-7.1,-9,-9,-9.4,-7.5,-9.3,-9.2,-.7,2.6,.2,-.1,-8,-4.6,-7.7,-6.1,-3.6,-1,-4.1,-3.1,-50,-11.6,-50,-11.6,.2,2.3,.4,.5,-50,-6.5,-15.3,-7.8,-8.4,-9.5,-8.3,-11.1],[-3.9,-3.3,-3.1,-2.8,10.6,9.8,12.2,9.8,-4.9,.1,-3.6,-.2,-1.7,-4.1,.9,-3.5,-5.9,-8.9,-5.6,-8.5,-3.9,-3.9,-2.2,-4.5,-7.3,-7.5,-6.4,-8.5,-7.1,-8.2,-6.7,-7.8,-7.9,-9.1,-7.1,-9.4,.9,-.2,2.5,-.3,-6.9,-6.5,-5.5,-6.8,-1.7,-3.4,-1.7,-2.8,-50,-13,-50,-11.5,1.5,.7,2.7,.6,-50,-8.9,-12.1,-7.4,-6.1,-11.5,-5.4,-10.4],[-5.6,-1.8,-6.9,.2,9.6,9.6,9.8,11.6,-6.6,.9,-7.2,2.5,-2.3,-3.4,-2.3,-.6,-6.5,-8.2,-8,-6.3,-3.7,-3.5,-3.9,-1.6,-9.9,-8.9,-9.6,-7,-8.6,-8.9,-8.8,-6.8,-8.6,-8.2,-8.8,-6.8,.3,.1,.2,2.4,-7.4,-6.2,-6.9,-4.4,-2.9,-2.9,-3.5,-.9,-50,-12.2,-50,-10.1,1.2,.6,1.2,2.4,-50,-7.6,-16.1,-5.8,-7.2,-10.8,-7.4,-9],[5.1,-5.4,3.3,-4.8,-3.2,-7.1,-4.9,-6.6,13.3,-2.8,11.2,-1.9,-5.7,-12.5,-7.2,-11.6,-.7,-4.8,-3.1,-4.3,-10,-11.6,-8.8,-11.7,10.5,7.7,9.1,8.5,-9.8,-12.7,-11.7,-11.8,-6.3,-11.4,-8.8,-11,-7.5,-10.3,-8.3,-9.9,-1.9,-6.7,-4.1,-6.4,-7.9,-12.5,-11.4,-11.7,-50,-14,-50,-13.2,-8.5,-10.4,-9.1,-9.6,-50,-9.8,-7.7,-8.8,-10.3,-17.9,-11.8,-16],[-5,4.6,-5.5,2.9,-.7,2.4,.1,.9,-2.8,12.8,-2.6,11,-8.4,-6.3,-8.3,-7.7,-6.1,-2.9,-6.5,-4.2,-8.5,-5.9,-7.5,-7.7,-5.5,-2.4,-5.5,-4.1,-12.9,-10.3,-12.7,-11.3,-7.4,-3.1,-7.4,-4.9,-4.4,-1.8,-3.5,-3.5,-1.6,3,-.8,.9,-8.4,-6.3,-9.6,-7.3,-50,-9,-50,-9.7,-2.3,-.2,-1.2,-1.5,-50,-.7,-13.3,-2,-11.8,-11.9,-12.3,-12.7],[3.6,-5.5,4.8,-5.2,-5.1,-7.2,-3.6,-7.2,11.2,-2.6,13.4,-2.1,-7.7,-12.5,-5.3,-11.9,-2.2,-4.4,-1.9,-4.8,-10.2,-11.5,-8.1,-12,9.3,8.2,10,8,-10.8,-11.9,-10.7,-12.4,-8.2,-11.8,-6.9,-11.5,-8.4,-9.9,-7.1,-10.6,-4.7,-6.8,-1.2,-7,-9.8,-11.6,-9.6,-12.1,-50,-14.1,-50,-12.7,-10,-10.8,-8.8,-10.5,-50,-9.2,-4.2,-9.3,-11,-18.2,-11.1,-16.1],[-4.2,3,-5.1,5.2,-.4,.3,-.2,2.5,-1.9,11,-2.1,13.2,-7.6,-8.5,-8,-5.3,-5.6,-4.5,-6.8,-2.4,-7.8,-7.9,-7.9,-6.2,-5.7,-5.1,-5.4,-2.1,-12.4,-12.3,-13.1,-10.1,-6.6,-4.4,-6.9,-2.6,-3.6,-3.8,-3.7,-2,-1.4,.8,-.9,3,-8.2,-8.1,-9.2,-5.8,-50,-10.1,-50,-7.4,-1.7,-2,-1.5,-.5,-50,-2.1,-12.6,-.4,-11.6,-13.9,-11.4,-11.1],[-6.3,-10.2,-8.9,-9.1,.7,-2.9,-1.7,-2.3,-5.7,-8.4,-7.7,-7.6,13.2,9.6,3.5,9.7,-8.7,-12.4,-10.7,-10.7,-7.8,-10.2,-8.8,-9.6,-9.5,-11.9,-10.9,-10.5,2.3,-.4,-.2,-.3,-9.7,-15.5,-11.4,-13.7,-3,-6.4,-4.1,-5.4,-9.6,-11.9,-10.5,-11.8,6.2,3.3,3.7,3.6,-50,-13.6,-50,-11.9,-5.6,-8.8,-7.2,-8.9,-50,-12.4,-14.1,-11.6,2.8,-6.4,.5,-5.2],[-13,-7.9,-13.2,-9.5,-4.6,-1.2,-4.1,-3.4,-12.5,-6.3,-12.5,-8.5,9.6,12.7,.2,10.5,-12.4,-11.6,-13.2,-12,-12.4,-10.1,-11.6,-12,-15.1,-13.1,-14.3,-13.4,-1.4,1.4,-1.6,-.5,-14.9,-14.3,-15.2,-16.8,-7.7,-4.7,-6.3,-6.6,-14.6,-10.8,-12.8,-13,2.3,6,2.5,3.6,-50,-11.2,-50,-11.9,-10.5,-9.2,-10.5,-10.5,-50,-10.3,-16.2,-11.3,-1.7,-3.7,-2.5,-5.4],[-7.1,-9.9,-5.7,-9,-.4,-3,.9,-2.3,-7.2,-8.3,-5.3,-8,3.5,.2,14.3,1,-7.3,-11.2,-6.9,-9.7,-8.5,-10.2,-7.7,-9.8,-10,-10.4,-8.4,-10.2,1,-.6,1.7,-.5,-11.1,-14.8,-9.7,-14.5,-3.7,-5.8,-3.1,-5.6,-10.4,-11.5,-8.2,-11.1,.6,-1.6,1.6,-1.1,-50,-12.4,-50,-11.5,-5.5,-8,-4.9,-7.2,-50,-12.4,-10.3,-11.6,.7,-6.8,2.4,-6],[-11.5,-9.6,-12.6,-7,-3.6,-3.3,-3.5,-.6,-11.6,-7.7,-11.9,-5.3,9.7,10.5,1,12.6,-12,-12.2,-12.5,-9.7,-11.1,-11.2,-11.9,-9.4,-12.9,-14.3,-14,-11.9,-1,-.4,-1.6,1.2,-13.9,-15.4,-13.7,-12.6,-6.2,-6.7,-6.3,-4.4,-13,-12.2,-13,-10.4,2.9,3.8,2.5,5.8,-50,-12.5,-50,-10.2,-9.6,-9.7,-9.6,-8.3,-50,-11.6,-15.4,-9.4,-1.1,-5.4,-1.6,-3.3],[.4,-5,-1.5,-4,-4.8,-7.6,-5.9,-6.5,-.7,-6.1,-2.2,-5.6,-8.7,-12.4,-7.3,-12,12.8,2.3,10.2,3,0,-3.4,-.7,-3.2,2.5,-.8,.9,.2,-3,-7.2,-5.7,-6.1,-.2,-6.6,-1.8,-6,-5.3,-8.2,-5.7,-7.6,-6.7,-9.6,-7.5,-9.3,-7.1,-10.5,-9.6,-9.4,-50,-8.1,-50,-7.2,-4.3,-6.8,-5.7,-6.3,-50,-9.5,-9.6,-8.9,-6.2,-12.8,-6.8,-11.8],[-6,.5,-6.1,-1,-8.9,-6.7,-8.9,-8.2,-4.8,-2.9,-4.4,-4.5,-12.4,-11.6,-11.2,-12.2,2.3,14.6,1.9,12.9,-5.5,-2.6,-4.1,-4.7,-1.2,3,-1.1,1.6,-8,-4.7,-8.7,-6,-8.2,-4.7,-7.8,-6.7,-10,-8.3,-8.9,-9.9,-10.8,-7.1,-10,-9.2,-11.6,-10.1,-12.3,-11.9,-50,2.2,-50,.9,-7.9,-5.9,-7.4,-6.9,-50,-4.6,-11.6,-5.6,-9.7,-5.9,-9.9,-7.3],[-1.9,-5.5,-.6,-5,-6.5,-8.1,-5.6,-8,-3.1,-6.5,-1.9,-6.8,-10.7,-13.2,-6.9,-12.5,10.2,1.9,11.9,2.1,-2.3,-4.1,-.5,-4.6,-.1,-.9,2.4,-.8,-5.1,-6.9,-4.8,-6.7,-2.3,-7.1,-.8,-7.2,-7.2,-8,-5.6,-8.5,-9.4,-9.7,-7.2,-9.8,-9.2,-11.1,-9.5,-10.7,-50,-8.7,-50,-8.6,-6.1,-7.5,-5.5,-7.7,-50,-10.4,-7.7,-10,-7.3,-13.6,-6.4,-13.3],[-5.3,-1,-6.1,1,-7.8,-7.9,-8.5,-6.3,-4.3,-4.2,-4.8,-2.4,-10.7,-12,-9.7,-9.7,3,12.9,2.1,14.7,-4.9,-3.8,-4,-2.4,-1,.8,-1.3,3.4,-7.6,-5.7,-8.1,-3.5,-6.8,-5.8,-7.2,-4.2,-8.9,-10.2,-8.4,-8.2,-9.9,-8.4,-9.7,-6.4,-11.1,-11.1,-11.8,-10,-50,.4,-50,2.6,-7.2,-7,-7.4,-5.1,-50,-5.7,-9.8,-3.2,-8.4,-7.4,-8.9,-5.9],[-8.5,-10.3,-10,-9,-1.4,-4.9,-3.9,-3.7,-10,-8.5,-10.2,-7.8,-7.8,-12.4,-8.5,-11.1,0,-5.5,-2.3,-4.9,12.6,10,11.1,10.5,-6,-8.3,-6.9,-7.5,-2.2,-7.4,-5.3,-5.9,-8.9,-12.5,-9.4,-11.6,-.7,-3.9,-2.3,-3,-9.1,-9.8,-9.2,-9.5,-5.6,-9,-8,-8.5,-50,-15.3,-50,-14.1,2.3,-1.4,.3,-.5,-50,-13.6,-14.3,-11.5,-5.3,-13.7,-6.1,-12.7],[-11.2,-8.1,-11.8,-8.8,-4.1,-1.9,-3.9,-3.5,-11.6,-5.9,-11.5,-7.9,-10.2,-10.1,-10.2,-11.2,-3.4,-2.6,-4.1,-3.8,10,13.1,10.7,10.6,-8.1,-5.2,-8,-6.7,-6.1,-3.7,-7.5,-5.6,-11.1,-10.3,-10.6,-11.9,-3.2,-1,-2.2,-2.8,-10.5,-8.1,-9.4,-9.5,-8.3,-6.9,-9.4,-8.8,-50,-11.3,-50,-12.8,-.6,2.2,-.3,.1,-50,-10.1,-17.5,-11.1,-8.6,-9.9,-8.6,-11.9],[-8.9,-9.4,-8.6,-8.9,-2.9,-4.5,-2.2,-3.9,-8.8,-7.5,-8.1,-7.9,-8.8,-11.6,-7.7,-11.9,-.7,-4.1,-.5,-4,11.1,10.7,13.2,10.4,-5.7,-5.8,-3.5,-6.1,-3.6,-6.5,-3.3,-5.5,-9.4,-11,-8.7,-11.2,-1.8,-2.7,.7,-3,-9.1,-8.2,-7.3,-9.4,-7.2,-8.2,-7.2,-8.2,-50,-13.2,-50,-13.3,.5,-.9,1.8,-.6,-50,-11.4,-11.1,-10.5,-6.1,-12.9,-5,-11.9],[-10.8,-9.6,-11.9,-7.7,-3.3,-3.8,-4.5,-1.6,-11.7,-7.7,-12,-6.2,-9.6,-12,-9.8,-9.4,-3.2,-4.7,-4.6,-2.4,10.5,10.6,10.4,12.6,-8.2,-7.9,-9,-4.7,-6.1,-6,-7.5,-2.9,-10.9,-12.2,-11.2,-10.9,-2.4,-2.9,-2.7,-.9,-10.4,-9.7,-10.2,-8,-8.4,-9.1,-9.3,-6.5,-50,-13.3,-50,-11,-0,-.4,-.4,2.3,-50,-10.9,-17.2,-8.3,-8.3,-12.7,-7.8,-9.3],[2.1,-8.1,1.2,-7,-8,-9.5,-7.3,-9.9,10.5,-5.5,9.3,-5.7,-9.5,-15.1,-10,-12.9,2.5,-1.2,-.1,-1,-6,-8.1,-5.7,-8.2,13.8,11.3,11.8,12.1,-6,-9.1,-9,-9.5,-8.9,-13.4,-10,-13.1,-9.9,-11.7,-9.8,-12.8,-5.9,-9.4,-6.5,-8.1,-10.7,-14,-13.3,-13.9,-50,-11.9,-50,-9.7,-8.9,-10.8,-9,-11.1,-50,-6.5,-5.3,-6.3,-10.5,-16.2,-10.4,-15.2],[0,-5,.5,-6.8,-9.1,-7.8,-7.5,-8.9,7.7,-2.4,8.2,-5.1,-11.9,-13.1,-10.4,-14.3,-.8,3,-.9,.8,-8.3,-5.2,-5.8,-7.9,11.3,15,11.2,12.8,-9.7,-5.3,-9.2,-7.8,-11.7,-10.6,-10.1,-12.2,-11.7,-8.8,-8.9,-11.8,-9.3,-5,-8,-8.2,-13.6,-11.4,-12.8,-13,-50,-7.2,-50,-8.4,-11,-7.7,-8.7,-10.2,-50,-1.5,-7.1,-4.9,-11.2,-11.6,-11.6,-15],[1.4,-7.3,2.2,-7.1,-8,-9.3,-6.4,-9.6,9.1,-5.5,10,-5.4,-10.9,-14.3,-8.4,-14,.9,-1.1,2.4,-1.3,-6.9,-8,-3.5,-9,11.8,11.2,13.4,11.4,-7.3,-8.8,-6.5,-8.5,-10,-12.5,-7.8,-12.5,-9.6,-11,-7.1,-10.7,-7.9,-8,-4.3,-9.4,-11.4,-12.3,-10.9,-12.9,-50,-11.8,-50,-11.2,-9.4,-9.8,-7.3,-10.5,-50,-6.2,-2.2,-6.7,-9.8,-15.2,-8.5,-14.9],[.2,-6.3,.1,-4.3,-8.2,-8.9,-8.5,-7,8.5,-4.1,8,-2.1,-10.5,-13.4,-10.2,-11.9,.2,1.6,-.8,3.4,-7.5,-6.7,-6.1,-4.7,12.1,12.8,11.4,14.7,-8.7,-7.4,-9.4,-5.3,-9.9,-11.8,-10.5,-10.3,-9.9,-10.1,-9.3,-9.3,-8.1,-7.2,-8,-5.2,-12,-12.1,-12.6,-10.9,-50,-7.9,-50,-5.3,-9.3,-8.8,-8.9,-7,-50,-3.6,-7.1,-1.2,-10.2,-12.7,-9.9,-11],[-10.2,-13.4,-11.8,-12.4,-6,-9.4,-7.1,-8.6,-9.8,-12.9,-10.8,-12.4,2.3,-1.4,1,-1,-3,-8,-5.1,-7.6,-2.2,-6.1,-3.6,-6.1,-6,-9.7,-7.3,-8.7,11.2,7.9,8.9,8.1,-12.1,-17.4,-13.2,-16.8,-6.3,-9.5,-7.5,-8.8,-12.7,-15.2,-13.1,-14.2,0,-3.1,-1.8,-3.1,-50,-10.7,-50,-9.3,-4.6,-8.9,-5.9,-8.3,-50,-12.8,-9.6,-10.6,9.5,-3.2,8.2,-2.8],[-13.5,-11.3,-14,-12.9,-9.3,-7.1,-8.2,-8.9,-12.7,-10.3,-11.9,-12.3,-.4,1.4,-.6,-.4,-7.2,-4.7,-6.9,-5.7,-7.4,-3.7,-6.5,-6,-9.1,-5.3,-8.8,-7.4,7.9,11.9,7.8,9.3,-15.2,-15.1,-14.6,-17.2,-9.7,-7.3,-8.2,-9.2,-15,-12.8,-14.1,-14.9,-2.8,.2,-2.9,-2.3,-50,-7.4,-50,-8.7,-9.4,-7.3,-9.4,-9.4,-50,-8,-11.9,-9.7,6.5,.5,6.4,-1.8],[-13,-14.4,-11.9,-13.9,-7.7,-9,-6.7,-8.8,-11.7,-12.7,-10.7,-13.1,-.2,-1.6,1.7,-1.6,-5.7,-8.7,-4.8,-8.1,-5.3,-7.5,-3.3,-7.5,-9,-9.2,-6.5,-9.4,8.9,7.8,10.1,7.8,-14.3,-17.7,-13,-17.8,-8,-9.4,-6.2,-9.2,-15.1,-14.9,-12.2,-14.9,-1.8,-3.2,-.8,-3.2,-50,-10.8,-50,-9.9,-7.3,-9.6,-6.4,-9.4,-50,-12.3,-8.7,-11.3,7.6,-3.3,8.7,-2.9],[-12.5,-12.9,-13.4,-10,-8.5,-9,-7.8,-6.8,-11.8,-11.3,-12.4,-10.1,-.3,-.5,-.5,1.2,-6.1,-6,-6.7,-3.5,-5.9,-5.6,-5.5,-2.9,-9.5,-7.8,-8.5,-5.3,8.1,9.3,7.8,11.8,-14.4,-15.7,-14.5,-14.6,-8.4,-8.7,-7.9,-7.1,-14.3,-13.8,-13.8,-12.3,-2.4,-2.2,-2.9,-.2,-50,-8.9,-50,-7.1,-8.1,-9.1,-8.7,-6.6,-50,-9.7,-11.4,-8,6.8,-1.8,6.9,.4],[-2.6,-6.3,-4.9,-4.9,-6.4,-9.4,-7.9,-8.6,-6.3,-7.4,-8.2,-6.6,-9.7,-14.9,-11.1,-13.9,-.2,-8.2,-2.3,-6.8,-8.9,-11.1,-9.4,-10.9,-8.9,-11.7,-10,-9.9,-12.1,-15.2,-14.3,-14.4,11.1,2.9,9.2,3.5,-3,-7,-4.3,-6.2,-2.2,-6.6,-3.7,-5.7,-6,-10.4,-8.6,-9.5,-50,-15.5,-50,-13.9,-7.8,-10.5,-8.7,-9.6,-50,-16.5,-17.1,-14.8,-12.1,-18.9,-12.4,-17.4],[-8.5,.8,-9.1,-.7,-10.1,-7.5,-9.1,-8.2,-11.4,-3.1,-11.8,-4.4,-15.5,-14.3,-14.8,-15.4,-6.6,-4.7,-7.1,-5.8,-12.5,-10.3,-11,-12.2,-13.4,-10.6,-12.5,-11.8,-17.4,-15.1,-17.7,-15.7,2.9,12.5,3.1,10.3,-7.7,-5.2,-6.2,-7.3,-5.4,-1.7,-5.4,-3.7,-11.6,-9.1,-13,-10.8,-50,-10.3,-50,-11.2,-9.8,-8.3,-9.1,-9.7,-50,-12.7,-20.6,-13.1,-16,-16.6,-17,-18.4],[-5,-6.4,-3.4,-5.6,-7.5,-9.3,-7.1,-8.8,-8.8,-7.4,-6.9,-6.9,-11.4,-15.2,-9.7,-13.7,-1.8,-7.8,-.8,-7.2,-9.4,-10.6,-8.7,-11.2,-10,-10.1,-7.8,-10.5,-13.2,-14.6,-13,-14.5,9.2,3.1,10.8,3,-4.5,-6.7,-2.7,-6.7,-5,-6.8,-2.5,-6.7,-7.5,-10.4,-7.4,-10.2,-50,-15.5,-50,-14.2,-8.9,-10.2,-8.5,-10,-50,-15.6,-15.3,-15.5,-13,-18.8,-12.6,-18.3],[-8.1,-1.1,-8.9,1.4,-8.6,-9.2,-9.4,-6.8,-11,-4.9,-11.5,-2.6,-13.7,-16.8,-14.5,-12.6,-6,-6.7,-7.2,-4.2,-11.6,-11.9,-11.2,-10.9,-13.1,-12.2,-12.5,-10.3,-16.8,-17.2,-17.8,-14.6,3.5,10.3,3,12.4,-6.9,-7.5,-6.8,-4.9,-5.4,-4.2,-5.4,-1.3,-10.8,-11.5,-12.4,-8.2,-50,-12.5,-50,-8.9,-9.2,-10,-9.4,-7.9,-50,-14.3,-19.9,-11.4,-16.2,-19.2,-15.8,-15.9],[-6.3,-7.4,-8,-6,2.8,-.7,.9,.3,-7.5,-4.4,-8.4,-3.6,-3,-7.7,-3.7,-6.2,-5.3,-10,-7.2,-8.9,-.7,-3.2,-1.8,-2.4,-9.9,-11.7,-9.6,-9.9,-6.3,-9.7,-8,-8.4,-3,-7.7,-4.5,-6.9,11.3,8.2,9.4,9.1,-1,-3.3,-1.8,-2.4,1.5,-2.1,-.4,-1.1,-50,-14.5,-50,-12.9,2.8,-0,1.4,.7,-50,-8.7,-14.1,-7.5,-5.2,-12.5,-6.5,-10.7],[-9.9,-5,-10,-6.5,-.7,2.6,-.2,.1,-10.3,-1.8,-9.9,-3.8,-6.4,-4.7,-5.8,-6.7,-8.2,-8.3,-8,-10.2,-3.9,-1,-2.7,-2.9,-11.7,-8.8,-11,-10.1,-9.5,-7.3,-9.4,-8.7,-7,-5.2,-6.7,-7.5,8.2,11.6,8.8,9.1,-3.7,-.9,-3.1,-3,-2,1.2,-2.3,-1.3,-50,-12.1,-50,-12.6,.1,2.5,.7,.6,-50,-6,-14.8,-7.5,-8.6,-9.4,-8.5,-11.2],[-7.5,-6.2,-7.2,-6.2,.9,.2,2.5,.2,-8.3,-3.5,-7.1,-3.7,-4.1,-6.3,-3.1,-6.3,-5.7,-8.9,-5.6,-8.4,-2.3,-2.2,.7,-2.7,-9.8,-8.9,-7.1,-9.3,-7.5,-8.2,-6.2,-7.9,-4.3,-6.2,-2.7,-6.8,9.4,8.8,12.1,8.8,-2.1,-2,.1,-2.4,0,-1.1,1.3,-.8,-50,-11.9,-50,-12.6,1.2,.7,3.5,.8,-50,-7.1,-12.4,-7.1,-7.1,-10.6,-5,-10.6],[-9,-6.5,-10,-4.8,.1,-.1,-.3,2.4,-9.9,-3.5,-10.6,-2,-5.4,-6.6,-5.6,-4.4,-7.6,-9.9,-8.5,-8.2,-3,-2.8,-3,-.9,-12.8,-11.8,-10.7,-9.3,-8.8,-9.2,-9.2,-7.1,-6.2,-7.3,-6.7,-4.9,9.1,9.1,8.8,11.2,-3.1,-3,-3.3,-1,-1.1,-1.4,-2,1.2,-50,-12.8,-50,-10.9,.8,.5,.7,2.3,-50,-7.5,-16.5,-5.9,-7.8,-11.1,-7.8,-9],[-7.1,-5.6,-9.1,-5.1,-5.9,-8,-6.9,-7.4,-1.9,-1.6,-4.7,-1.4,-9.6,-14.6,-10.4,-13,-6.7,-10.8,-9.4,-9.9,-9.1,-10.5,-9.1,-10.4,-5.9,-9.3,-7.9,-8.1,-12.7,-15,-15.1,-14.3,-2.2,-5.4,-5,-5.4,-1,-3.7,-2.1,-3.1,12.8,9.6,11.1,10.1,-4.8,-9.4,-8.1,-8.6,-50,-18.3,-50,-15.4,-5.9,-7.5,-6.6,-7.1,-50,-9.5,-11.7,-8.4,-12.5,-17.3,-13.2,-15.4],[-10.2,-1.6,-10.2,-3.2,-7.3,-4.6,-6.5,-6.2,-6.7,3,-6.8,.8,-11.9,-10.8,-11.5,-12.2,-9.6,-7.1,-9.7,-8.4,-9.8,-8.1,-8.2,-9.7,-9.4,-5,-8,-7.2,-15.2,-12.8,-14.9,-13.8,-6.6,-1.7,-6.8,-4.2,-3.3,-.9,-2,-3,9.6,12.8,9.7,10.5,-8.5,-5.6,-9.3,-7.8,-50,-12.7,-50,-13.8,-6.8,-5.1,-5.3,-6.5,-50,-4.1,-12.8,-5.8,-14.4,-14.1,-13.6,-14.8],[-8.2,-4.7,-7.1,-5,-6.5,-7.7,-5.5,-6.9,-4.1,-.8,-1.2,-.9,-10.5,-12.8,-8.2,-13,-7.5,-10,-7.2,-9.7,-9.2,-9.4,-7.3,-10.2,-6.5,-8,-4.3,-8,-13.1,-14.1,-12.2,-13.8,-3.7,-5.4,-2.5,-5.4,-1.8,-3.1,.1,-3.3,11.1,9.7,12.9,9.8,-5.5,-8.1,-5.4,-7.8,-50,-16.4,-50,-14.8,-5.9,-7.1,-4.7,-7.2,-50,-8.4,-6.4,-8.1,-12.1,-16.2,-10.3,-15.8],[-9.2,-3,-9.9,-1.2,-6.5,-6.1,-6.8,-4.4,-6.4,.9,-7,3,-11.8,-13,-11.1,-10.4,-9.3,-9.2,-9.8,-6.4,-9.5,-9.5,-9.4,-8,-8.1,-8.2,-9.4,-5.2,-14.2,-14.9,-14.9,-12.3,-5.7,-3.7,-6.7,-1.3,-2.4,-3,-2.4,-1,10.1,10.5,9.8,13.1,-7.2,-8,-8.4,-5,-50,-14.7,-50,-11.4,-6.3,-6.7,-5.8,-5,-50,-6.1,-13.4,-3.6,-13,-16,-13.7,-13.3],[-8.2,-10.8,-10.1,-9.8,-.4,-3.6,-1.7,-2.9,-7.9,-8.4,-9.8,-8.2,6.2,2.3,.6,2.9,-7.1,-11.6,-9.2,-11.1,-5.6,-8.3,-7.2,-8.4,-10.7,-13.6,-11.4,-12,0,-2.8,-1.8,-2.4,-6,-11.6,-7.5,-10.8,1.5,-2,0,-1.1,-4.8,-8.5,-5.5,-7.2,11.9,8.6,10,9,-50,-14.2,-50,-12.8,-4.1,-7.4,-5.7,-6.5,-50,-11,-14.3,-9.9,1.4,-7.9,-.7,-6.8],[-12.5,-8.7,-13,-9.9,-3.9,-1,-3.4,-2.9,-12.5,-6.3,-11.6,-8.1,3.3,6,-1.6,3.8,-10.5,-10.1,-11.1,-11.1,-9,-6.9,-8.2,-9.1,-14,-11.4,-12.3,-12.1,-3.1,.2,-3.2,-2.2,-10.4,-9.1,-10.4,-11.5,-2.1,1.2,-1.1,-1.4,-9.4,-5.6,-8.1,-8,8.6,12.4,8.6,9.5,-50,-10.4,-50,-11.6,-7.2,-5.7,-7.5,-7.4,-50,-8.6,-15.7,-9.7,-3,-3.7,-3.2,-5.9],[-11.1,-11.9,-10.6,-11.3,-2.6,-4.1,-1.7,-3.5,-11.4,-9.6,-9.6,-9.2,3.7,2.5,1.6,2.5,-9.6,-12.3,-9.5,-11.8,-8,-9.4,-7.2,-9.3,-13.3,-12.8,-10.9,-12.6,-1.8,-2.9,-.8,-2.9,-8.6,-13,-7.4,-12.4,-.4,-2.3,1.3,-2,-8.1,-9.3,-5.4,-8.4,10,8.6,11.4,8.9,-50,-13.7,-50,-13.2,-6.1,-8.1,-5.5,-7.5,-50,-11.3,-12.7,-10.1,-1.6,-7.8,-.3,-7.2],[-11.4,-10,-12.7,-8.2,-3.1,-3.1,-2.8,-.9,-11.7,-7.3,-12.1,-5.8,3.6,3.6,-1.1,5.8,-9.4,-11.9,-10.7,-10,-8.5,-8.8,-8.2,-6.5,-13.9,-13,-12.9,-10.9,-3.1,-2.3,-3.2,-.2,-9.5,-10.8,-10.2,-8.2,-1.1,-1.3,-.8,1.2,-8.6,-7.8,-7.8,-5,9,9.5,8.9,12,-50,-13,-50,-10.3,-6.2,-7,-7.1,-5.4,-50,-9.3,-14,-8.2,-2.4,-6.3,-2.4,-3.9],[-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,33.3,-50,30.6,-50,-50,-50,-50,-50,29.2,-50,-50,-50,-50,-50,-50,-50],[-14.8,-6.2,-14.9,-7.6,-14.6,-11.6,-13,-12.2,-14,-9,-14.1,-10.1,-13.6,-11.2,-12.4,-12.5,-8.1,2.2,-8.7,.4,-15.3,-11.3,-13.2,-13.3,-11.9,-7.2,-11.8,-7.9,-10.7,-7.4,-10.8,-8.9,-15.5,-10.3,-15.5,-12.5,-14.5,-12.1,-11.9,-12.8,-18.3,-12.7,-16.4,-14.7,-14.2,-10.4,-13.7,-13,-50,15.1,-50,13.3,-9.9,-5.8,-8.9,-7.6,-50,-1.5,-7.8,-3,-8.1,3.6,-9.4,2],[-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,30.6,-50,35.2,-50,-50,-50,-50,-50,28.5,-50,-50,-50,-50,-50,-50,-50],[-13.8,-7.5,-14.4,-5.1,-12.6,-11.6,-11.5,-10.1,-13.2,-9.7,-12.7,-7.4,-11.9,-11.9,-11.5,-10.2,-7.2,.9,-8.6,2.6,-14.1,-12.8,-13.3,-11,-9.7,-8.4,-11.2,-5.3,-9.3,-8.7,-9.9,-7.1,-13.9,-11.2,-14.2,-8.9,-12.9,-12.6,-12.6,-10.9,-15.4,-13.8,-14.8,-11.4,-12.8,-11.6,-13.2,-10.3,-50,13.3,-50,15.2,-8.6,-7,-8.4,-4.8,-50,-3,-7.1,-.1,-7.3,2.3,-8.7,3.9],[-7.3,-6.3,-8.9,-5.5,2.9,.2,1.5,1.2,-8.5,-2.3,-10,-1.7,-5.6,-10.5,-5.5,-9.6,-4.3,-7.9,-6.1,-7.2,2.3,-.6,.5,-0,-8.9,-11,-9.4,-9.3,-4.6,-9.4,-7.3,-8.1,-7.8,-9.8,-8.9,-9.2,2.8,.1,1.2,.8,-5.9,-6.8,-5.9,-6.3,-4.1,-7.2,-6.1,-6.2,-50,-9.9,-50,-8.6,12.5,9.4,11,9.8,-50,-4.8,-8.7,-3.5,-0,-8.6,-2.1,-7],[-10.1,-4.3,-10.8,-5.8,.1,2.3,.7,.6,-10.4,-.2,-10.8,-2,-8.8,-9.2,-8,-9.7,-6.8,-5.9,-7.5,-7,-1.4,2.2,-.9,-.4,-10.8,-7.7,-9.8,-8.8,-8.9,-7.3,-9.6,-9.1,-10.5,-8.3,-10.2,-10,-0,2.5,.7,.5,-7.5,-5.1,-7.1,-6.7,-7.4,-5.7,-8.1,-7,-50,-5.8,-50,-7,9.4,12.7,10.1,10,-50,-1.5,-11.3,-3.3,-5.4,-4.2,-5.6,-6.8],[-8.4,-6.2,-8.9,-5.9,1.8,.4,2.7,1.2,-9.1,-1.2,-8.8,-1.5,-7.2,-10.5,-4.9,-9.6,-5.7,-7.4,-5.5,-7.4,.3,-.3,1.8,-.4,-9,-8.7,-7.3,-8.9,-5.9,-9.4,-6.4,-8.7,-8.7,-9.1,-8.5,-9.4,1.4,.7,3.5,.7,-6.6,-5.3,-4.7,-5.8,-5.7,-7.5,-5.5,-7.1,-50,-8.9,-50,-8.4,11,10.1,13.2,10.2,-50,-4.2,-6.1,-3.6,-3.5,-8.4,-1.2,-6.8],[-9.1,-5.4,-10.4,-4.2,1,.5,.6,2.4,-9.6,-1.5,-10.5,-.5,-8.9,-10.5,-7.2,-8.3,-6.3,-6.9,-7.7,-5.1,-.5,.1,-.6,2.3,-11.1,-10.2,-10.5,-7,-8.3,-9.4,-9.4,-6.6,-9.6,-9.7,-10,-7.9,.7,.6,.8,2.3,-7.1,-6.5,-7.2,-5,-6.5,-7.4,-7.5,-5.4,-50,-7.6,-50,-4.8,9.8,10,10.2,12.1,-50,-3.1,-11.4,-.7,-4.6,-6.6,-4.9,-3.9],[-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,29.2,-50,28.5,-50,-50,-50,-50,-50,33.3,-50,-50,-50,-50,-50,-50,-50],[-13,-7,-13.1,-8.3,-9.2,-6.5,-8.9,-7.6,-9.8,-.7,-9.2,-2.1,-12.4,-10.3,-12.4,-11.6,-9.5,-4.6,-10.4,-5.7,-13.6,-10.1,-11.4,-10.9,-6.5,-1.5,-6.2,-3.6,-12.8,-8,-12.3,-9.7,-16.5,-12.7,-15.6,-14.3,-8.7,-6,-7.1,-7.5,-9.5,-4.1,-8.4,-6.1,-11,-8.6,-11.3,-9.3,-50,-1.5,-50,-3,-4.8,-1.5,-4.2,-3.1,-50,16.4,-5.1,14.2,-10.1,-4.3,-10,-5.4],[-13.5,-16.3,-11.8,-15.5,-13.6,-15.3,-12.1,-16.1,-7.7,-13.3,-4.2,-12.6,-14.1,-16.2,-10.3,-15.4,-9.6,-11.6,-7.7,-9.8,-14.3,-17.5,-11.1,-17.2,-5.3,-7.1,-2.2,-7.1,-9.6,-11.9,-8.7,-11.4,-17.1,-20.6,-15.3,-19.9,-14.1,-14.8,-12.4,-16.5,-11.7,-12.8,-6.4,-13.4,-14.3,-15.7,-12.7,-14,-50,-7.8,-50,-7.1,-8.7,-11.3,-6.1,-11.4,-50,-5.1,18.6,-4.8,-8.6,-8.1,-4.5,-7.3],[-12.4,-8.2,-13,-5.9,-7.7,-7.8,-7.4,-5.8,-8.8,-2,-9.3,-.4,-11.6,-11.3,-11.6,-9.4,-8.9,-5.6,-10,-3.2,-11.5,-11.1,-10.5,-8.3,-6.3,-4.9,-6.7,-1.2,-10.6,-9.7,-11.3,-8,-14.8,-13.1,-15.5,-11.4,-7.5,-7.5,-7.1,-5.9,-8.4,-5.8,-8.1,-3.6,-9.9,-9.7,-10.1,-8.2,-50,-3,-50,-.1,-3.5,-3.3,-3.6,-.7,-50,14.2,-4.8,16.4,-8.9,-5.8,-8.9,-3.4],[-10.7,-13.2,-12.4,-11.6,-4.8,-8.4,-6.1,-7.2,-10.3,-11.8,-11,-11.6,2.8,-1.7,.7,-1.1,-6.2,-9.7,-7.3,-8.4,-5.3,-8.6,-6.1,-8.3,-10.5,-11.2,-9.8,-10.2,9.5,6.5,7.6,6.8,-12.1,-16,-13,-16.2,-5.2,-8.6,-7.1,-7.8,-12.5,-14.4,-12.1,-13,1.4,-3,-1.6,-2.4,-50,-8.1,-50,-7.3,-0,-5.4,-3.5,-4.6,-50,-10.1,-8.6,-8.9,13.2,-.9,9.7,-.3],[-18.1,-12.3,-19.4,-14.2,-12.2,-9.5,-11.5,-10.8,-17.9,-11.9,-18.2,-13.9,-6.4,-3.7,-6.8,-5.4,-12.8,-5.9,-13.6,-7.4,-13.7,-9.9,-12.9,-12.7,-16.2,-11.6,-15.2,-12.7,-3.2,.5,-3.3,-1.8,-18.9,-16.6,-18.8,-19.2,-12.5,-9.4,-10.6,-11.1,-17.3,-14.1,-16.2,-16,-7.9,-3.7,-7.8,-6.3,-50,3.6,-50,2.3,-8.6,-4.2,-8.4,-6.6,-50,-4.3,-8.1,-5.8,-.9,14.2,-1.8,11.6],[-11.8,-13.1,-11.5,-12,-6.2,-8.3,-5.4,-7.4,-11.8,-12.3,-11.1,-11.4,.5,-2.5,2.4,-1.6,-6.8,-9.9,-6.4,-8.9,-6.1,-8.6,-5,-7.8,-10.4,-11.6,-8.5,-9.9,8.2,6.4,8.7,6.9,-12.4,-17,-12.6,-15.8,-6.5,-8.5,-5,-7.8,-13.2,-13.6,-10.3,-13.7,-.7,-3.2,-.3,-2.4,-50,-9.4,-50,-8.7,-2.1,-5.6,-1.2,-4.9,-50,-10,-4.5,-8.9,9.7,-1.8,11.3,-.9],[-17.2,-13.3,-17.8,-11.6,-11,-11.1,-10.4,-9,-16,-12.7,-16.1,-11.1,-5.2,-5.4,-6,-3.3,-11.8,-7.3,-13.3,-5.9,-12.7,-11.9,-11.9,-9.3,-15.2,-15,-14.9,-11,-2.8,-1.8,-2.9,.4,-17.4,-18.4,-18.3,-15.9,-10.7,-11.2,-10.6,-9,-15.4,-14.8,-15.8,-13.3,-6.8,-5.9,-7.2,-3.9,-50,2,-50,3.9,-7,-6.8,-6.8,-3.9,-50,-5.4,-7.3,-3.4,-.3,11.6,-.9,14.1]];TRANS=[[5,0,0,4],[0,5,4,0],[0,4,5,0],[4,0,0,5]];CONBLO={A:0,R:1,N:2,D:3,C:4,Q:5,E:6,G:7,H:8,I:9,L:10,K:11,M:12,F:13,P:14,S:15,T:16,W:17,Y:18,V:19,B:20,Z:21,X:22,"*":23};CONNUCL={A:0,T:1,C:2,G:3};CONSCHN={AAA:0,AAC:1,AAG:2,AAT:3,ACA:4,ACC:5,ACG:6,ACT:7,AGA:8,AGC:9,AGG:10,AGT:11,ATA:12,ATC:13,ATG:14,ATT:15,CAA:16,CAC:17,CAG:18,CAT:19,CCA:20,CCC:21,CCG:22,CCT:23,CGA:24,CGC:25,CGG:26,CGT:27,CTA:28,CTC:29,CTG:30,CTT:31,GAA:32,GAC:33,GAG:34,GAT:35,GCA:36,GCC:37,GCG:38,GCT:39,GGA:40,GGC:41,GGG:42,GGT:43,GTA:44,GTC:45,GTG:46,GTT:47,TAA:48,TAC:49,TAG:50,TAT:51,TCA:52,TCC:53,TCG:54,TCT:55,TGA:56,TGC:57,TGG:58,TGT:59,TTA:60,TTC:61,TTG:62,TTT:63};fillNeedleman(){for(let e=0;e<=this.len1;e++)this.dpGrid[e][0].value=-e*this.gap,this.dpGrid[e][0].parentI=e-1,this.dpGrid[e][0].parentJ=0;for(let e=1;e<=this.len2;e++)this.dpGrid[0][e].value=-e*this.gap,this.dpGrid[0][e].parentI=0,this.dpGrid[0][e].parentJ=e-1}fillOne(e,t){this.dpGrid[e][t].value=Math.max(this.dpGrid[e-1][t-1].value+this.scores[e-1][t-1],Math.max(this.dpGrid[e-1][t].value-this.gap,this.dpGrid[e][t-1].value-this.gap)),this.dpGrid[e][t].value==this.dpGrid[e-1][t-1].value+this.scores[e-1][t-1]?(this.dpGrid[e][t].parentI=e-1,this.dpGrid[e][t].parentJ=t-1):this.dpGrid[e][t].value==this.dpGrid[e-1][t].value-this.gap?(this.dpGrid[e][t].parentI=e-1,this.dpGrid[e][t].parentJ=t):(this.dpGrid[e][t].parentI=e,this.dpGrid[e][t].parentJ=t-1)}gridFromName(e){switch(e){case"BLOSUM45":this.alignGrid=this.BLOSUM45,this.connections=this.CONBLO,this.step=1;break;case"BLOSUM50":this.alignGrid=this.BLOSUM50,this.connections=this.CONBLO,this.step=1;break;case"BLOSUM62":this.alignGrid=this.BLOSUM62,this.connections=this.CONBLO,this.step=1;break;case"BLOSUM80":this.alignGrid=this.BLOSUM80,this.connections=this.CONBLO,this.step=1;break;case"BLOSUM90":this.alignGrid=this.BLOSUM90,this.connections=this.CONBLO,this.step=1;break;case"PAM30":this.alignGrid=this.PAM30,this.connections=this.CONBLO,this.step=1;break;case"PAM70":this.alignGrid=this.PAM70,this.connections=this.CONBLO,this.step=1;break;case"PAM250":this.alignGrid=this.PAM250,this.connections=this.CONBLO,this.step=1;break;case"NUCLEOTIDES":this.alignGrid=this.NUCLEOTIDES,this.connections=this.CONNUCL,this.step=1;break;case"TRANS":this.alignGrid=this.TRANS,this.connections=this.CONNUCL,this.step=1;break;case"SCHNEIDER":this.alignGrid=this.SCHNEIDER,this.connections=this.CONSCHN,this.step=3}this.fillScores()}constructResult(e,t){let n="",i="",o="";const s=this.dpGrid[e][t].value;for(let e=0;e<this.step;e++)o+="|";for(;e>0||t>0;){this.dpGrid[e][t].parentI==e?(n=o+n,i=this.seq2.substr((t-1)*this.step,this.step)+i):this.dpGrid[e][t].parentJ==t?(i=o+i,n=this.seq1.substr((e-1)*this.step,this.step)+n):(n=e-1>=0?this.seq1.substr((e-1)*this.step,this.step)+n:o+n,i=t-1>=0?this.seq2.substr((t-1)*this.step,this.step)+i:o+i);const s=e;e=this.dpGrid[e][t].parentI,t=this.dpGrid[s][t].parentJ}return new ut(n,i,s)}fillScores(){this.scores=[];for(let e=0;e<this.len1;e++){this.scores.push([]);for(let t=0;t<this.len2;t++)this.scores[e].push(this.alignGrid[this.connections[this.seq1.substr(e*this.step,this.step)]][this.connections[this.seq2.substr(t*this.step,this.step)]])}}typeRec(){if(/[ATGC]*/.test(this.seq1)&&/[ATGC]*/.test(this.seq2))return"NUCLEOTIDES";if(/[ARNDCQEGHILKMFPSTWYVBZX*]*/.test(this.seq1)&&/[ARNDCQEGHILKMFPSTWYVBZX*]*/.test(this.seq2))return"BLOSUM62";throw Error("Can't recognize sequence type")}needlemanWunsch(){this.dpGrid=[];for(let e=0;e<this.len1+1;e++){const e=[];for(let t=0;t<this.len2+1;t++)e.push(new ct);this.dpGrid.push(e)}this.fillNeedleman();for(let e=1;e<=this.len1;e++)for(let t=1;t<=this.len2;t++)this.fillOne(e,t);return this.constructResult(this.len1,this.len2)}smithWaterman(){this.dpGrid=[];for(let e=0;e<this.len1+1;e++){const e=[];for(let t=0;t<this.len2+1;t++)e.push(new ct);this.dpGrid.push(e)}let e=0,t=0,n=0;for(let i=1;i<=this.len1;i++)for(let o=1;o<=this.len2;o++)this.fillOne(i,o),this.dpGrid[i][o].value<=0?(this.dpGrid[i][o].value=0,this.dpGrid[i][o].parentI=0,this.dpGrid[i][o].parentJ=0):0==this.dpGrid[this.dpGrid[i][o].parentI][this.dpGrid[i][o].parentJ].value&&(this.dpGrid[i][o].parentI=0,this.dpGrid[i][o].parentJ=0),this.dpGrid[i][o].value>e&&(e=this.dpGrid[i][o].value,t=i,n=o);return this.constructResult(t,n)}setSequences(e,t){this.seq1=e,this.seq2=t,this.len1=this.seq1.length/this.step,this.len2=this.seq2.length/this.step,this.fillScores()}setGap(e){this.gap=e}setMethod(e=""){"AUTO"==e&&(e=this.typeRec()),this.gridFromName(e)}constructor(e,t,n,i=""){this.setMethod(i),this.setSequences(e,t),this.setGap(n)}}async function dt(e,t,n="Morgan",i=1,o=.6){const s=e.length,r=ro.seqHelper.getSeqHandler(e),a=Array(s);let l=1;const c=new Map,u=e.categories,h=e.getRawData();for(let t=0;t<s;t++){if(null===u[h[t]]||e.isNone(t)){a[t]=null;continue}a[t]="";const n=r.getSplitted(t);for(let e=0;e<n.length;e++){const i=n.getCanonical(e);c.has(i)||(c.set(i,String.fromCharCode(l)),l++),a[t]+=c.get(i)}}let d={};if(t===me.Z.MONOMER_CHEMICAL_DISTANCE||t===me.Z.NEEDLEMANN_WUNSCH){const e=Array.from(c.keys()),s=await(0,ye.A7)(e,n),r={};Object.entries(s.alphabetIndexes).forEach((([e,t])=>{r[c.get(e)]=t}));const l=a.reduce(((e,t)=>Math.max(e,t?.length||0)),0);d={scoringMatrix:s.scoringMatrix,alphabetIndexes:r,maxLength:l},t===me.Z.NEEDLEMANN_WUNSCH&&(d.gapOpen=i,d.gapExtend=o)}return{seqList:a,options:d}}var pt=n(4954);function mt(e){const t=r.divH([],{style:{gap:"10px"}}),n=r.divV([r.divText(e.seqCol.name),r.divText(e.activityCol.name)]);return n.style.fontWeight="bold",n.style.display="flex",n.style.justifyContent="space-between",t.append(n),e.points.forEach((n=>{const i=r.divText(e.activityCol.get(n).toFixed(2));i.style.display="flex",i.style.justifyContent="left",i.style.paddingLeft="30px",t.append(r.divV([r.divText(e.seqCol.get(n)),i]))})),t}function gt(e){const t=r.div();t.append(r.divText(e.seqCol.name,{style:{fontWeight:"bold"}}));const n=new Array(2);e.points.forEach(((t,i)=>{n[i]=e.activityCol.get(t)}));const i={},o=ro.seqHelper.getSeqHandler(e.seqCol),s=o.defaultBiotype,a=yt(o.getSplitted(e.points[0]),o.getSplitted(e.points[1]),s,i);return t.append(r.div(a,{style:{width:"300px",overflow:"scroll"}})),t.append(bt(i)),t.append(ft("Activity delta",Math.abs(n[0]-n[1]))),t.append(ft("Cliff",e.sali)),t}function ft(e,t){return r.divH([r.divText(`${e}: `,{style:{fontWeight:"bold",paddingRight:"5px"}}),r.divText(t.toFixed(2))],{style:{paddingTop:"10px"}})}function yt(e,t,n,i){const o=document.createElement("canvas"),s=o.getContext("2d");o.height=30;const r=ro.monomerLib;return Ze(s,0,0,0,30,R().count(0).take(e.length).map((t=>e.getCanonical(t))).toArray(),R().count(0).take(t.length).map((e=>t.getCanonical(e))).toArray(),n,r,!0,i),o}function bt(e){const t=r.div();if(Object.keys(e).length>0){const n=r.divV([]);n.append(r.divH([r.divText("Pos",{style:{fontWeight:"bold",width:"30px",borderBottom:"1px solid"}}),r.divText("Difference",{style:{fontWeight:"bold",borderBottom:"1px solid"}})]));for(const t of Object.keys(e))e[t].style.borderBottom="1px solid lightgray",n.append(r.divH([r.divText((parseInt(t)+1).toString(),{style:{width:"30px",borderBottom:"1px solid lightgray"}}),e[t]]));t.append(n)}return t}function wt(e,t){const n=a.Column.string("seq_diff",e.rowCount).init((n=>`${e.get(t[0],n)}#${e.get(t[1],n)}`));n.semType="MacromoleculeDifference",n.meta.units=e.col(t[0]).meta.units,n.setTag(ge.gp.separator,e.col(t[0]).getTag(ge.gp.separator)),e.columns.add(n);const i=e.plot.grid();return i.col(t[0]).visible=!1,i.col(t[1]).visible=!1,i}class vt extends a.JsViewer{constructor(e,t){super(),this.name="",this.semType="",this.initialized=!1,this.gridSelect=!1,this.maxLimit=100,this.recomputeOnCurrentRowChange=!0,this.skipRecomputingProperies=[],this.debounceTimer=null,this.computeRequested=!1,this.renderPromise=Promise.resolve(),this.limit=this.int("limit",10,{min:1,max:this.maxLimit}),this.targetColumnName=this.string("targetColumnName",null,{...t?{semType:t}:{},nullable:!1}),this.name=e,this.semType=t}init(){this.initialized=!0}detach(){this.subs.forEach((e=>e.unsubscribe()))}async onTableAttached(){if(this.init(),this.dataFrame){this.subs.push(a.debounce(this.dataFrame.onRowsRemoved,50).subscribe((e=>this.render(!0))));const e="diversity"!==this.name;this.subs.push(a.debounce(this.dataFrame.onCurrentRowChanged,50).subscribe((t=>{this.gridSelect||this.render(e)}))),this.subs.push(a.debounce(this.dataFrame.selection.onChanged,50).subscribe((e=>this.render(!1)))),this.subs.push(a.debounce(r.onSizeChanged(this.root),50).subscribe((e=>this.render(!1)))),this.targetColumnName??(this.targetColumnName=this.dataFrame.columns.bySemType(this.semType).name),this.targetColumn=this.dataFrame.col(this.targetColumnName),this.getProperty("limit").fromOptions({min:1,max:this.maxLimit})}this.render()}onPropertyChanged(e){if(super.onPropertyChanged(e),this.initialized){if("targetColumnName"===e.name){const t=this.dataFrame.col(e.get(this));t.semType===this.semType&&(this.targetColumn=t)}this.debouncedRender()}}debouncedRender(e=!0){this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout((()=>{this.render(e),this.debounceTimer=null}),100)}render(e=!0){this.renderPromise=this.renderPromise.then((async()=>{this.computeRequested=this.computeRequested||e,await this.renderInt(e)}))}async renderInt(e){}beforeRender(){return!(!this.initialized||!this.targetColumnName||this.dataFrame&&this.targetColumnName&&this.dataFrame.col(this.targetColumnName).semType!==this.semType&&(s.shell.error(`${this.targetColumnName} is not ${this.semType} type`),1))}}class At extends vt{distanceMetric;fingerprint;gapOpen;gapExtend;metricsProperties=["distanceMetric","fingerprint","gapOpen","gapExtend"];fingerprintChoices=["Morgan","RDKit","Pattern","AtomPair","MACCS","TopologicalTorsion"];distanceFunctionChoices=[me.Z.NEEDLEMANN_WUNSCH,me.Z.HAMMING,me.Z.LEVENSHTEIN,me.Z.MONOMER_CHEMICAL_DISTANCE];tags=[a.TAGS.UNITS,ge.gp.aligned,ge.gp.separator,ge.gp.alphabet,"cell.renderer"];preComputeDistanceMatrix=!1;requiresSampling=!1;constructor(e,t){super(e,t),this.distanceMetric=this.string("distanceMetric",me.Z.HAMMING,{choices:this.distanceFunctionChoices}),this.fingerprint=this.string("fingerprint",this.fingerprintChoices[0],{choices:this.fingerprintChoices}),this.gapOpen=this.float("gapOpen",1),this.gapExtend=this.float("gapExtend",.6)}async onTableAttached(){if(super.onTableAttached(),this.dataFrame){const e=this.dataFrame.rowCount;this.preComputeDistanceMatrix=e<=1e4,this.requiresSampling=e>1e4}}needsGapPenalties(){return this.distanceMetric===me.Z.NEEDLEMANN_WUNSCH}needsFingerprint(){return this.distanceMetric===me.Z.MONOMER_CHEMICAL_DISTANCE||this.distanceMetric===me.Z.NEEDLEMANN_WUNSCH}}const Ct={gapPenalty:1,matchScore:1,gapSymbol:we.b9[we.Hi.FASTA],localAlignment:!1};class Tt extends At{seqHelper;cutoff;hotSearch;similarColumnLabel;sketchedMolecule="";curIdx=0;molCol=null;idxs=null;scores=null;gridSelect=!1;targetMoleculeIdx=0;computeCompleted=new u.Subject;distanceMatrixComputed=!1;mmDistanceMatrix;knn;kPrevNeighbors=0;demo;analysisGrid;subInited=!1;lastDistanceMetric="";lastFingerprint="";lastGapOpen=0;lastGapExtend=0;constructor(e,t){super("similarity",a.SEMTYPE.MACROMOLECULE),this.seqHelper=e,this.cutoff=this.float("cutoff",.01,{min:0,max:1}),this.hotSearch=this.bool("hotSearch",!0),this.similarColumnLabel=this.string("similarColumnLabel",null),this.demo=t}init(){this.hotSearch=!0,this.initialized=!0}async renderInt(e){if(this.beforeRender()&&this.targetColumn){this.curIdx=-1==this.dataFrame.currentRowIdx?0:this.dataFrame.currentRowIdx;const t=this.lastDistanceMetric!==this.distanceMetric||this.lastFingerprint!==this.fingerprint||this.lastGapOpen!==this.gapOpen||this.lastGapExtend!==this.gapExtend;if(e&&!this.gridSelect||t){this.targetMoleculeIdx=(this.dataFrame.currentRowIdx??-1)<0?0:this.dataFrame.currentRowIdx,await this.computeByMM();const e=null!=this.similarColumnLabel?this.similarColumnLabel:`similar (${this.targetColumn})`;this.molCol=a.Column.string(e,this.idxs.length).init((e=>this.targetColumn?.get(this.idxs?.get(e)))),this.molCol.semType=a.SEMTYPE.MACROMOLECULE,this.tags.forEach((e=>this.molCol.setTag(e,this.targetColumn.getTag(e))));const t=a.DataFrame.fromColumns([this.idxs,this.molCol,this.scores]);await t.meta.detectSemanticTypes(),await s.data.detectSemanticTypes(t),this.molCol.temp["reference-sequence"]=this.targetColumn.get(this.targetMoleculeIdx),this.molCol.temp[".mm.cellRenderer.maxMonomerLength"]=4;let n=null;t.onCurrentRowChanged.subscribe((e=>{n&&clearTimeout(n),(t.currentRowIdx??-1)<0||(this.dataFrame.currentRowIdx=t.col("indexes").get(t.currentRowIdx),n=setTimeout((()=>{this.createPropertyPanel(t)}),300),this.gridSelect=!0)})),this.analysisGrid?(this.analysisGrid.dataFrame=t,this.analysisGrid.invalidate()):(this.analysisGrid=t.plot.grid(),(0,Ne.Ku)(this.root,this.analysisGrid.root)),this.analysisGrid.col("indexes").visible=!1,(0,Ne.Kd)(this.analysisGrid,this.molCol.name,450,30,!0);const i=this.idxs?.getRawData().findIndex((e=>e==this.targetMoleculeIdx));this.analysisGrid.cell("score",i).cell.value=null;const o=s.shell.tv;this.subInited||(o.grid.root.addEventListener("click",(e=>{this.gridSelect=!1})),this.subInited=!0),this.computeCompleted.next(!0)}}}async computeByMM(){const e=this.targetColumn.length,t=Math.min(this.limit,e-1);if(!this.knn||this.kPrevNeighbors!==t||this.lastDistanceMetric!==this.distanceMetric||this.lastFingerprint!==this.fingerprint||this.lastGapOpen!==this.gapOpen||this.lastGapExtend!==this.gapExtend){const e=this.distanceMetric,n=await dt(this.targetColumn,e,this.fingerprint,this.gapOpen,this.gapExtend),i=n.seqList,o=n.options;this.lastDistanceMetric=this.distanceMetric,this.lastFingerprint=this.fingerprint,this.lastGapOpen=this.gapOpen,this.lastGapExtend=this.gapExtend,this.kPrevNeighbors=t,this.knn=await(new B).getKNN(i,e,t,o)}const n=new Array(t).fill(0).map(((e,t)=>({idx:this.knn.knnIndexes[this.targetMoleculeIdx][t],score:1-this.knn.knnDistances[this.targetMoleculeIdx][t]})));n.sort(((e,t)=>t.score-e.score)),n.unshift({idx:this.targetMoleculeIdx,score:a.FLOAT_NULL}),this.idxs=a.Column.int("indexes",t+1).init((e=>n[e].idx)),this.scores=a.Column.float("score",t+1).init((e=>n[e].score))}createPropertyPanel(e){const t=r.div(),n={},i=this.molCol?.name,o=e.col(i),a=this.seqHelper.getSeqHandler(this.targetColumn),l=this.seqHelper.getSeqHandler(o),c=a.getSplitted(this.targetMoleculeIdx),u=l.getSplitted(e.currentRowIdx),h=function(e,t,n={}){const i={...Ct,...n},o=e.length,s=t.length,r=Array(o+1).fill(0).map((()=>Array(s+1).fill(0)));let a=-9999,l=[1,1];for(let n=1;n<o+1;n++)for(let o=1;o<s+1;o++)r[n][o]=Math.max(0,r[n-1][o-1]+(e.getCanonical(n-1)===t.getCanonical(o-1)?i.matchScore:-i.matchScore),r[n-1][o]-i.gapPenalty,r[n][o-1]-i.gapPenalty),r[n][o]>=a&&(a=r[n][o],l=[n,o]);let c=i.localAlignment?l[0]:o,u=i.localAlignment?l[1]:s,h=new Array(0),d=new Array(0);for(;c>0&&u>0;){const n=Math.max(r[c-1][u-1],r[c-1][u],r[c][u-1]);r[c][u]==r[c-1][u-1]+i.matchScore&&n==r[c-1][u-1]?(h.push(e.getCanonical(c-1)),d.push(t.getCanonical(u-1)),c-=1,u-=1):r[c][u]==r[c-1][u]-i.gapPenalty?(d.push(i.gapSymbol),h.push(e.getCanonical(c-1)),c-=1):r[c][u]==r[c][u-1]-i.gapPenalty?(h.push(i.gapSymbol),d.push(t.getCanonical(u-1)),u-=1):(h.push(e.getCanonical(c-1)),d.push(t.getCanonical(u-1)),c-=1,u-=1)}h=[...R().count(0).take(c).map((t=>e.getCanonical(t))),...h.reverse(),...i.localAlignment?R().count(l[0]).take(o).map((t=>e.getCanonical(t))):[]],d=[...R().count(0).take(u).map((e=>t.getCanonical(e))),...d.reverse(),...i.localAlignment?R().count(l[1]).take(s).map((e=>t.getCanonical(e))):[]];const p=c,m=u;return p>m?d=[...new Array(p-m).fill(i.gapSymbol.valueOf()),...d]:h=[...new Array(m-p).fill(i.gapSymbol.valueOf()),...h],d.length>h.length?h.push(...new Array(d.length-h.length).fill(i.gapSymbol.valueOf())):d.push(...new Array(h.length-d.length).fill(i.gapSymbol.valueOf())),{seq1:h.join(""),seq2:d.join(""),seq1Splitted:new Oe.Mu(h,i.gapSymbol),seq2Splitted:new Oe.Mu(d,i.gapSymbol)}}(c,u),d=yt(h.seq1Splitted,h.seq2Splitted,l.defaultBiotype,n);t.append(r.div(d,{style:{width:"300px",overflow:"scroll"}})),c.length!==u.length&&t.append(r.divV([r.divText("Different sequence length:",{style:{fontWeight:"bold"}}),r.divText(`target: ${c.length} monomers`),r.divText(`selected: ${u.length} monomers`)],{style:{paddingBottom:"10px"}})),t.append(bt(n));const p=r.accordion(),m=r.element("i");m.className="grok-icon svg-icon svg-view-layout",p.addTitle(r.span([m,r.label("Similarity search")])),p.addPane("Differences",(()=>t),!0),s.shell.o=p.root}}class St extends At{seqHelper;diverseColumnLabel;renderMolIds=null;columnNames=[];computeCompleted=new u.Subject;sampledIndices=null;constructor(e){super("diversity",a.SEMTYPE.MACROMOLECULE),this.seqHelper=e,this.diverseColumnLabel=this.string("diverseColumnLabel",null)}async renderInt(e){if(this.beforeRender()&&this.dataFrame&&e&&this.targetColumn){await this.computeByMM();const e=null!=this.diverseColumnLabel?this.diverseColumnLabel:`diverse (${this.targetColumnName})`,t=a.Column.string(e,this.renderMolIds.length).init((e=>this.targetColumn?.get(this.renderMolIds[e])));t.semType=a.SEMTYPE.MACROMOLECULE,this.tags.forEach((e=>t.setTag(e,this.targetColumn.getTag(e))));const n=a.DataFrame.fromColumns([t]);t.temp[".mm.cellRenderer.maxMonomerLength"]=4,n.onCurrentRowChanged.subscribe((e=>{this.dataFrame.currentRowIdx=this.renderMolIds[n.currentRowIdx]}));const i=n.plot.grid();(0,Ne.Kd)(i,t.name,450,30),(0,Ne.Ku)(this.root,i.root),this.computeCompleted.next(!0)}}async computeByMM(){const e=this.targetColumn.length;let t;this.requiresSampling&&e>1e4?(t=this.createRandomSample(e,1e4),this.sampledIndices=t):(t=Array.from({length:e},((e,t)=>t)),this.sampledIndices=null);const n=this.distanceMetric,i=await dt(this.targetColumn,n,this.fingerprint,this.gapOpen,this.gapExtend),o=i.seqList,s=i.options,r=t.map((e=>o[e])),a=new G(!0,!1),l=await a.calc(r,n,!0,s);a.terminate();const c=t.length,u=(d=c,(e,t)=>d*e+t-Math.floor((e+2)*(e+1)/2)),h=function(e,t){function n(e,t){let n=null,i=null;for(const o of e){const e=t(o);(null==i||e>i)&&(n=o,i=e)}return n}const i=[(s=e-1,Math.floor(function(e){return Math.random()*e}(s)))],o=new Set;var s;for(let t=0;t<e;++t)i.includes(t)||o.add(t);for(;i.length<t;){const e=n(o.values(),(e=>Math.min.apply(Math,i.map((function(t,n){return l[u(e,t)]})))));null!=e&&(i.push(e),o.delete(e))}return i}(c,Math.min(c,this.limit));var d;this.renderMolIds=h.map((e=>t[e]))}createRandomSample(e,t){const n=[];for(let t=0;t<e;t++)this.targetColumn.isNone(t)||n.push(t);if(n.length<=t)return n;for(let e=n.length-1;e>0;e--){const t=Math.floor(Math.random()*(e+1)),i=n[e];n[e]=n[t],n[t]=i}return n.slice(0,t)}}var Et,Mt=n(5433),xt=n(3890),Lt=n(1687);!function(e){e.TYPE="V2000",e[e.NUM_OF_HEADER_LINES=3]="NUM_OF_HEADER_LINES",e[e.NUM_OF_COUNTS_DIGITS=3]="NUM_OF_COUNTS_DIGITS",e[e.ATOM_TYPE_COL=4]="ATOM_TYPE_COL",e[e.FIRST_BONDED_ATOM_COL=1]="FIRST_BONDED_ATOM_COL",e[e.BOND_TYPE_COL=3]="BOND_TYPE_COL",e[e.RGP_SHIFT=8]="RGP_SHIFT",e[e.MAX_ATOM_COUNT=999]="MAX_ATOM_COUNT",e.RGP_LINE_START="M RGP",e.ATOM_ALIAS_LINE_START="A ",e.END="M END"}(Et||(Et={}));class _t{constructor(e){this.init(e)}init(e){this.fileContent=e.replace(/\r/g,""),this._atomCount=void 0,this._atomTypes=void 0,this._bondCount=void 0,this._bondTypes=void 0,this.xyzAtomCoordinates=void 0,this._pairsOfBondedAtoms=void 0}get atomCount(){return void 0===this._atomCount&&this.setAtomAndBondCounts(),this._atomCount}get bondCount(){return void 0===this._bondCount&&this.setAtomAndBondCounts(),this._bondCount}get x(){var e;return null!==(e=this.xyzAtomCoordinates)&&void 0!==e||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.x}get y(){var e;return null!==(e=this.xyzAtomCoordinates)&&void 0!==e||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.y}get z(){var e;return null!==(e=this.xyzAtomCoordinates)&&void 0!==e||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.z}get atomTypes(){var e;return null!==(e=this._atomTypes)&&void 0!==e||(this._atomTypes=this.parseAtomTypes()),this._atomTypes}get pairsOfBondedAtoms(){var e;return null!==(e=this._pairsOfBondedAtoms)&&void 0!==e||(this._pairsOfBondedAtoms=this.parseBondedAtomPairs()),this._pairsOfBondedAtoms}get bondTypes(){var e;return null!==(e=this._bondTypes)&&void 0!==e||(this._bondTypes=this.parseBondTypes()),this._bondTypes}setAtomAndBondCounts(){const{atomCount:e,bondCount:t}=this.parseAtomAndBondCounts();this._atomCount=e,this._bondCount=t}getNextColumnIdx(e){for(;!this.isWhitespace(e);)++e;for(;this.isWhitespace(e);)++e;return e}shiftIdxToSpecifiedColumn(e,t){let n=e;const i=this.isWhitespace(n)?t:t-1;for(let e=0;e<i;e++)n=this.getNextColumnIdx(n);return n}parseAtomTypes(){const e=this.atomCount,t=new Array(e);let n=this.getAtomBlockIdx();for(let i=0;i<e;i++)n=this.shiftIdxToAtomType(n),t[i]=this.parseAtomType(n),n=this.getNextLineIdx(n);return t}parseAtomCoordinates(){const e=new Float32Array(this.atomCount),t=new Float32Array(this.atomCount),n=new Float32Array(this.atomCount);let i=this.getAtomBlockIdx();for(let o=0;o<this.atomCount;o++){i=this.shiftIdxToXColumn(i);for(const s of[e,t,n])s[o]=this.parseFloatValue(i),i=this.getNextColumnIdx(i);i=this.getNextLineIdx(i)}return{x:e,y:t,z:n}}parseBondedAtomPairs(){const e=new Array(this.bondCount);let t=this.getBondBlockIdx();for(let n=0;n<this.bondCount;n++){t=this.shiftIdxToBondedAtomsPair(t);const i=new Uint16Array(2);i[0]=this.parseIntValue(t),t=this.getNextColumnIdx(t),i[1]=this.parseIntValue(t),e[n]=i,t=this.getNextLineIdx(t)}return e}parseBondTypes(){const e=this.bondCount,t=new Uint16Array(e);let n=this.getBondBlockIdx();for(let i=0;i<e;i++)n=this.shiftIdxToBondType(n),t[i]=this.parseIntValue(n),n=this.getNextLineIdx(n);return t}isWhitespace(e){const t=this.fileContent[e];return" "===t||"\t"===t}getNextLineIdx(e){return"\n"!==this.fileContent[e]?this.fileContent.indexOf("\n",e)+1:e+1}parseFloatValue(e){return this.parseNumericValue(parseFloat,e)}parseIntValue(e){return this.parseNumericValue(parseInt,e)}parseNumericValue(e,t){let n=t+1;for(;!this.isWhitespace(n);)++n;return e(this.fileContent.substring(t,n))}}class It extends _t{constructor(e){super(e),this.init(e)}init(e){super.init(e)}parseAtomType(e){let t=e,n=t;return this.isQuote(t)?(n=this.getNextIdenticalChar(t),t++):n=this.fileContent.indexOf(" ",n),this.fileContent.substring(t,n)}isQuote(e){const t=this.fileContent[e].charCodeAt(0);return 39===t||34===t}getNextIdenticalChar(e){const t=this.fileContent[e];return t?this.fileContent.indexOf(t,e+1):-1}isQuery(){return this.isQueryOrFragment(((e,t)=>{return 39===e||34===e||76===e&&!((n=this.fileContent.charCodeAt(t+1))>64&&n<91||n>96&&n<123);var n}))}isFragment(){return this.isQueryOrFragment((e=>82===e||42===e))}isQueryOrFragment(e){const t=this.atomCount;let n=this.getAtomBlockIdx();for(let i=0;i<t;i++){if(n=this.shiftIdxToAtomType(n),e(this.fileContent.charCodeAt(n),n))return!0;n=this.getNextLineIdx(n)}return!1}}class Pt extends It{constructor(e){super(e)}getAtomLines(){const e=this.getAtomBlockIdx(),t=this.getBondBlockIdx();return this.fileContent.substring(e,t).split("\n").slice(0,this.atomCount)}getBondLines(){const e=this.getBondBlockIdx();return this.fileContent.substring(e).split("\n").slice(0,this.bondCount)}getRGroupIdToAtomicIdxMap(){const e=new Map,t=this.fileContent.split("\n");t.filter((e=>e.startsWith(Et.RGP_LINE_START))).forEach((t=>{const n=this.getAtomIdxToRgpIdxList(t);for(const[t,i]of n){if(e.has(t))throw new Error(`R group ${t} is already in the map`);e.set(t,i)}}));const n=t.map(((e,t)=>{if(e.startsWith(Et.ATOM_ALIAS_LINE_START))return t})).filter((e=>void 0!==e)),i=n.map((e=>t[e])),o=n.map((e=>t[e+1]));i.forEach(((t,n)=>{const i=parseInt(t.split(/\s+/)[1])-1,s=parseInt(o[n].substring(1));if(e.has(s))throw new Error(`R group ${s} is already in the map`);e.set(s,i)}));const s=this.getRGroupAtomicIndices().filter((t=>!Array.from(e.values()).includes(t)));if(0!==s.length)throw new Error(`Unaccounted R group indices: ${s}`);return e}getAtomIdxToRgpIdxList(e){const t=e.split(/\s+/).filter((e=>e)).slice(3).map((e=>parseInt(e))),n=new Array(t.length/2);for(let e=0;e<t.length;e+=2)n[e/2]=[t[e+1],t[e]-1];return n}getRGroupAtomicIndices(){return this.atomTypes.map(((e,t)=>{if(e.includes("R#"))return t})).filter((e=>void 0!==e))}static isValidMolfile(e){return-1!==e.indexOf(Et.TYPE)&&-1!==e.indexOf(Et.END)}shiftIdxToAtomType(e){return this.shiftIdxToSpecifiedColumn(e,Et.ATOM_TYPE_COL)}getCountsLineIdx(){let e=0;for(let t=0;t<Et.NUM_OF_HEADER_LINES;++t)e=this.getNextLineIdx(e);return e}getAtomBlockIdx(){let e=this.getCountsLineIdx();return e=this.getNextLineIdx(e),e}shiftIdxToXColumn(e){return this.getNextColumnIdx(e)}shiftIdxToBondedAtomsPair(e){return this.shiftIdxToSpecifiedColumn(e,Et.FIRST_BONDED_ATOM_COL)}shiftIdxToBondType(e){return this.shiftIdxToSpecifiedColumn(e,Et.BOND_TYPE_COL)}getBondBlockIdx(){let e=this.getAtomBlockIdx();for(let t=0;t<this.atomCount;t++)e=this.getNextLineIdx(e);return e}parseAtomAndBondCounts(){let e=this.getCountsLineIdx(),t=e+Et.NUM_OF_COUNTS_DIGITS;const n=parseInt(this.fileContent.substring(e,t));return e=t,t+=Et.NUM_OF_COUNTS_DIGITS,{atomCount:n,bondCount:parseInt(this.fileContent.substring(e,t))}}}class Nt extends It{constructor(e){super(e),this.init(e)}getAtomLines(){const e=this.getAtomBlockIdx(),t=this.getBondBlockIdx();return this.fileContent.substring(e,t).split("\n").slice(0,this.atomCount)}getBondLines(){const e=this.getBondBlockIdx();return this.fileContent.substring(e).split("\n").slice(0,this.bondCount)}getRGroupIdToAtomicIdxMap(){const e=new Map;return this.getAtomLines().forEach(((t,n)=>{const i=t.match(/RGROUPS=\(([\d\s]+)\)/);if(i){const t=i[1].split(/\s+/).map((e=>parseInt(e)));if(t.length>2)throw new Error(`R group data ${t} has more than 2 elements`);const o=t[1];if(e.has(o))throw new Error(`R group ${o} is already in the map`);e.set(o,n)}})),e}shiftIdxToAtomType(e){return this.shiftIdxToSpecifiedColumn(e,4)}getCountsLineIdx(){return this.fileContent.indexOf("M V30 COUNTS ")}getAtomBlockIdx(){let e=this.fileContent.indexOf("M V30 BEGIN ATOM");return e=this.getNextLineIdx(e),e}shiftIdxToXColumn(e){let t=this.shiftIdxToAtomType(e);return this.isQuote(t)?(t=this.getNextIdenticalChar(t),t=this.getNextColumnIdx(t),t):this.shiftIdxToSpecifiedColumn(e,5)}shiftIdxToBondedAtomsPair(e){return this.shiftIdxToSpecifiedColumn(e,5)}shiftIdxToBondType(e){return this.shiftIdxToSpecifiedColumn(e,4)}getBondBlockIdx(){return this.getNextLineIdx(this.fileContent.indexOf("M V30 BEGIN BOND"))}static isValidMolfile(e){return-1!==e.indexOf("V3000")&&-1!==e.indexOf("M END")}parseAtomAndBondCounts(){let e=this.fileContent.indexOf("M V30 COUNTS ")+14,t=this.fileContent.indexOf(" ",e+1);const n=parseInt(this.fileContent.substring(e,t));return e=t+1,t=this.fileContent.indexOf(" ",e+1),{atomCount:n,bondCount:parseInt(this.fileContent.substring(e,t))}}}class Rt{constructor(){}static getInstance(e){if(Rt.isMolfileV2K(e))return new Pt(e);if(Rt.isMolfileV3K(e))return new Nt(e);throw new Error("Malformed molfile")}static isMolfileV2K(e){return Pt.isValidMolfile(e)}static isMolfileV3K(e){return Nt.isValidMolfile(e)}}var $t=n(6197),Ot=n(9124),Ht=n(3527);class kt{biotype;id;n;m;type;mt;smiles;get issmiles(){return!!this.smiles}at={R1:"H",R2:"H",R3:"H",R4:"H",R5:"H",R6:"H",R7:"H",R8:"H",R9:"H"};get rs(){return Object.keys(this.at).length}constructor(e,t,n="missing",i=void 0,o=void 0,s=void 0,r){if(this.biotype=e,this.id=t,this.n=n,this.m=i,this.type=o,this.mt=s,this.smiles=r,!this.id)throw new Error("Invalid arg undefined [id].")}static objCounter=-1;objId=++kt.objCounter;className="WebEditorMonomerDummy";toLog(){return`Helm: ${this.className}<${this.objId}>`}}class Ft extends kt{backgroundcolor="#FFFFFF";linecolor="#808080";textcolor="#808080";constructor(e){super(e,"*","gap")}}class Dt extends kt{backgroundcolor="#808080";linecolor="#000000";textcolor="#000000";constructor(e,t){super(e,t,"ambiguous")}}class Gt extends kt{backgroundcolor="#FF4444";linecolor="#800000";textcolor="#FFFFFF";constructor(e,t,n){super(e,t,"missing"),n&&(this.backgroundcolor="#C0C0C0",this.linecolor="#404040",this.textcolor="#404040")}}class Bt extends kt{backgroundcolor="#FFFF44";linecolor="#800000";textcolor="#000000";constructor(e,t){super(e,t,"broken")}}class Vt{id;m;n;na;type;mt;at;smiles;get rs(){return Object.keys(this.at).length}get issmiles(){return!!this.smiles}linecolor;backgroundcolor;textcolor;constructor(e,t,n,i,o,s,r,a){this.id=e,this.m=t,this.n=n,this.na=i,this.type=o,this.mt=s,this.at=r,this.smiles=a}static fromMonomer(e,t,n){let i={};const o=t.symbol,s=t.smiles;if(t.rgroups.length>0)t.rgroups.forEach((e=>{i[e.label]=e.capGroupName}));else{if(!s){if(t.lib)return new Bt(e,o);throw new Error("Unexpected missing monomer without .lib")}i=n.getRS(s)}const r=new Vt(t.symbol,t.molfile,t.name,t.naturalAnalog,t.polymerType,t.monomerType,i),a=n.getMonomerColors(e,t.symbol);return a&&(r.textcolor=a?.textcolor,r.linecolor=a?.linecolor,r.backgroundcolor=a?.backgroundcolor),r}}const Ut={[Fe.o.BASE]:{A:"#20E040",G:"#040404",T:"#FF8080",C:"#2060FF",U:"#FF8080"},[Fe.o.NUCLEOTIDE]:{A:"#20E040",G:"#040404",T:"#FF8080",C:"#2060FF",U:"#FF8080"},[Fe.o.LINKER]:{P:"#9aa5e1",p:"#9aa5e1"},[Fe.o.SUGAR]:{R:"#7a85c1",r:"#7a85c1"},[Fe.o.AA]:{A:"rgb(44,160,44)",R:"rgb(23,190,207)",N:"rgb(235,137,70)",D:"rgb(31,119,180)",C:"rgb(188,189,34)",E:"rgb(31, 120, 150)",Q:"rgb(205, 111, 71)",G:"rgb(214,39,40)",H:"rgb(158,218,229)",I:"rgb(23,103,57)",L:"rgb(30,110,96)",K:"rgb(108, 218, 229)",M:"rgb(60,131,95)",F:"rgb(24,110,79)",P:"rgb(255,152,150)",S:"rgb(255,187,120)",T:"rgb(245,167,100)",W:"rgb(182, 223, 138)",Y:"rgb(152,223,138)",V:"rgb(74,160,74)"},[Fe.o.CHEM]:{R:"#eeeeee"},[Fe.o.BLOB]:{B:"#999999",G:"#e2e2e2"}},Wt=/[\w()]+/,qt=RegExp(String.raw`\(${Wt}(,${Wt})+\)`),Yt=e=>{const t=r.canvas(250,250);return s.chem.canvasMol(0,0,250,250,t,e),t},jt=new Ht.Mi([255,255,255]),Kt=new Ht.Mi([0,0,0]),zt=.7*(0,z.wQ)(jt);class Zt{_monomers;source;_isEmpty;get isEmpty(){return this._isEmpty}_onChanged=new u.Subject;get onChanged(){return this._onChanged}constructor(e,t){this._monomers=e,this.source=t,this._isEmpty=!this._monomers||0===Object.keys(this._monomers).length||Object.entries(this._monomers).every((([e,t])=>0===Object.keys(t).length));for(const[e,t]of Object.entries(this._monomers))for(const[e,n]of Object.entries(t))n.lib=this}getMonomerSymbolsByType(e){return Object.keys(this._monomers[e])}addMissingMonomer(e,t){let n=this._monomers[e];n||(n=this._monomers[e]={});let i=t;return t==we._S||t===we.b9[we.Hi.HELM]?i="Gap":("PEPTIDE"===e&&"X"===t||"RNA"===e&&"N"===t)&&(i="Any"),n[t]={symbol:t,name:i,molfile:"",author:"MISSING",id:-1,rgroups:R().count(1).take(9).map((e=>({capGroupSmiles:"",alternateId:"",capGroupName:"",label:`R${e.toString()}`}))).toArray(),smiles:"",polymerType:e,monomerType:void 0,createDate:null}}getMonomer(e,t){let n=t;"RNA"==e&&"R"==n&&(n="r"),"RNA"==e&&"P"==n&&(n="p");let i=null;if(e){const t=this._monomers[e];i=t?t[n]:null}else{ro.logger.warning(`Bio: MonomerLib.getMonomer() symbol '${t}', polymerType not specified.`);for(const[e,t]of Object.entries(this._monomers))if(i=t[n],i)break}return i}getWebEditorMonomer(e,t){const[n,i]=(0,Ot.fA)(e,t),o=(0,$t.Y)(n);let s=this.getMonomer(o,i);if(s&&n==Fe.o.LINKER&&2!=s.rgroups.length)return null;if(s&&n==Fe.o.SUGAR&&3!=s.rgroups.length)return null;s||(s=this.addMissingMonomer(o,i));let r=s.wem??null;return r||(i===we._S||"*"==i?r=s.wem=new Ft(n):n===Fe.o.NUCLEOTIDE&&"N"===i||n===Fe.o.AA&&"X"===i||(Fe.o.CHEM,0)||qt.test(i)?r=s.wem=new Dt(n,i):s.lib||(r=s.wem=new Gt(n,i,this.isEmpty)),r||(r=s.wem=Vt.fromMonomer(n,s,this))),r}getTooltip(e,t){const n=(0,$t.Y)(e),i=r.div([],{classes:"ui-form ui-tooltip"}),o=this.getWebEditorMonomer(e,t),s=this.getMonomer(n,t);if(s){const e=s.symbol,[t,n,a]=(s.name,o?[o.textcolor,o.backgroundcolor,o.linecolor]:["#202020","#A0A0A0","#202020"]);let l;if(i.append(r.divH([r.div([e],{style:{textWrap:"nowrap",marginLeft:"4px",marginRight:"4px",color:t,backgroundColor:n,borderColor:a,borderWidth:"1px",borderStyle:"solid",borderRadius:"2px",padding:"3px",minWidth:"24px",textAlign:"center"}}),r.div([s.name],{style:{padding:"4px"}})],{style:{display:"flex",flexDirection:"row",justifyContent:"left"}})),l=s.molfile?Yt(s.molfile):s.smiles?r.divV([Yt(s.smiles),r.divText("from smiles",{style:{fontSize:"smaller"}})]):r.divText("No structure",{style:{margin:"6px"}}),i.append(r.div(l,{style:{display:"flex",flexDirection:"row",justifyContent:"center",margin:"6px"}})),s.symbol!=we._S){let e=s.lib?.source;e?(e.endsWith(".json")&&(e=e.substring(0,e.length-5)),e=e.replace(/_/g," ").replace(/-/g," ").replace(/([a-z])([a-z])([A-Z])/g,"$1$2 $3"),i.append(r.divText(e))):i.append(r.divText("Missed in libraries"))}}else i.append(r.divV([r.divText(`Monomer '${t}' of type '${n}' not found.`),r.divText("Open the Context Panel, then expand Manage Libraries")]));return i}getMonomerTextColor(e,t){const n=this.getMonomerColors(e,t),i=e=>{const t=/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/.exec(e);if(t)return[parseInt(t[1]),parseInt(t[2]),parseInt(t[3])];const n=a.Color.fromHtml(e);return[a.Color.r(n),a.Color.g(n),a.Color.b(n)]},o=i(n.textcolor),s=new Ht.Mi([...o.map((e=>e+1))]),r=(0,z.KE)(s,jt)/((0,z.wQ)(s)*(0,z.wQ)(jt)),l=i(n.backgroundcolor),c=new Ht.Mi([...l.map((e=>e+.01))]);let u;u=(0,z.KE)(c,jt)/((0,z.wQ)(c)*(0,z.wQ)(jt))<r?l:o;let h=new Ht.Mi(u);const d=(0,z.wQ)(h);return d>zt&&(h=(0,z.dC)(Kt,h,zt/d)),`rgb(${h[0]}, ${h[1]}, ${h[2]})`}getMonomerColors(e,t){const n="default";let i=n;const o=(0,$t.Y)(e),s=this.getMonomer(o,t);let r;if(s){if(s.meta&&s.meta.colors){if("string"==typeof s.meta.colors)try{s.meta.colors=JSON.parse(s.meta.colors)}catch(e){ro.logger.error(`Bio: MonomerLib.getMonomerColors() failed to parse monomer.meta.colors: ${e}`)}const e=s.meta.colors;e&&"string"!=typeof e&&!(n in e)&&(i="default"),e&&"string"!=typeof e&&i in e&&(r=e[i])}if(!r){const t=Ut[e],n=t?.[s.symbol];n&&(r={textColor:a.Color.toHtml(a.Color.getContrastColor(a.Color.fromHtml(n))),lineColor:"#202020",backgroundColor:n})}const t=s.naturalAnalog;if(!r&&t)return this.getMonomerColors(e,t)}return r||(r={textColor:"#202020",lineColor:"#202020",backgroundColor:"#A0A0A0"}),{textcolor:r.text??r.textColor,linecolor:r.line??r.lineColor,backgroundcolor:r.background??r.backgroundColor}}getRS(e){const t=e.match(/(?<=\[)[^\][]*(?=])/gm),n={};let i,o="";if(t)for(let e=0;e<t.length;e++)if(null!=t[e]&&/\d/.test(t[e])){i=t[e][t[e].length-1],t[e]=t[e].replace(/[0-9]/g,"");for(let n=0;n<t[e].length;n++)":"!=t[e][n]&&(o+=t[e][n]);n["R"+i]=o,o=""}return n}}var Xt=n(5488),Jt={};Jt.styleTagTransform=C(),Jt.setAttributes=b(),Jt.insert=f().bind(null,"head"),Jt.domAPI=m(),Jt.insertStyleElement=v(),d()(Xt.A,Jt),Xt.A&&Xt.A.locals&&Xt.A.locals;class Qt extends Zt{error;_duplicateMonomers={};get duplicateMonomers(){return this._duplicateMonomers}_duplicatesHandled=!0;get duplicatesHandled(){return this._duplicatesHandled}duplicatesNotified=!1;constructor(e,t,n=void 0){super(e,t),this.error=n}toJSON(){const e=[];for(const t of Object.values(this._monomers))for(const n of Object.values(t))e.push({...n,lib:void 0,wem:void 0});return e}getMonomer(e,t){let n=t;"RNA"==e&&"R"==n&&(n="r"),"RNA"==e&&"P"==n&&(n="p");let i=null;if(e){const t=this._monomers[e];i=t?.[n]??null}else{ro.logger.warning(`Bio: MonomerLib.getMonomer() symbol '${t}', polymerType not specified.`);for(const[e,t]of Object.entries(this._monomers))if(i=t[n],i)break}return i}_monomerSets=null;getMonomerSet(e){const t=(0,$t.Y)(e);if(this._monomerSets||(this._monomerSets={}),!(e in this._monomerSets))for(const[e,n]of Object.entries(this._monomers[t]));return this._monomerSets[e]}getPolymerTypes(){return Object.keys(this._monomers)}getMonomerMolsByPolymerType(e){const t={};return Object.keys(this._monomers[e]??{}).forEach((n=>{t[n]=this._monomers[e][n].molfile})),t}getMonomerSymbolsByRGroup(e,t,n){let i=this.getMonomerSymbolsByType(t).map((e=>this.getMonomer(t,e)));return i=i.filter((e=>null!==e)),0===i.length?[]:(i=i.filter((t=>{if(!t?.rgroups)return!1;let n=t?.rgroups.length>=e;var i;return i=Rt.getInstance(t.molfile).atomTypes,i.map(((e,t)=>"R#"===e?t:-1)).filter((e=>-1!==e)),n&&=!0,n})),i.map((e=>e?.symbol)))}_updateLibInt(e){const t=e.getPolymerTypes(),n=this.getPolymerTypes();t.forEach((t=>{n.includes(t)||(this._monomers[t]={}),e.getMonomerSymbolsByType(t).forEach((n=>{this._monomers[t][n]&&(this._duplicateMonomers[t]??={},this._duplicateMonomers[t][n]??=[this._monomers[t][n]],this._duplicateMonomers[t][n].push(e.getMonomer(t,n))),this._monomers[t][n]=e.getMonomer(t,n)}))})),this._isEmpty=this.isEmpty&&e.isEmpty}updateLibs(e,t=!1){t&&(this._monomers={},this._isEmpty=!0),this._duplicateMonomers={};for(const t of e)t.error||this._updateLibInt(t);Object.entries(this.duplicateMonomers).length>0?(0,Ie.ub)().then((e=>{this.assignDuplicatePreferences(e)})):this._duplicatesHandled=!0,this._onChanged.next()}assignDuplicatePreferences(e){let t=!0;for(const n in this.duplicateMonomers)for(const i in this.duplicateMonomers[n])if(e.duplicateMonomerPreferences?.[n]?.[i]){const o=e.duplicateMonomerPreferences[n][i],s=this.duplicateMonomers[n][i].find((e=>e.lib?.source===o));s?this._monomers[n][i]=s:t=!1}else t=!1;return this._duplicatesHandled=t,t}clear(){this._monomers={},this._onChanged.next()}getSummaryObj(){const e={},t=this.getPolymerTypes();for(const n of t)e[n]=this.getMonomerSymbolsByType(n).length;return e}getSummaryDf(){const e=this.getPolymerTypes(),t=new Array(e.length);for(const[n,i]of R().enumerate(e))t[i]=this.getMonomerSymbolsByType(n).length;return a.DataFrame.fromColumns([a.Column.fromStrings("polymerType",e),a.Column.fromList(a.COLUMN_TYPE.INT,"count",t)])}getSummary(){const e=this.getPolymerTypes();return 0==e.length?"empty":e.map((e=>`${e} ${this.getMonomerSymbolsByType(e).length}`)).join("\n")}static overrideCounter=0;override(e,t){return new en(e,`override: ${++Qt.overrideCounter}, ${t}`,this)}}class en extends Zt{data;base;constructor(e,t,n){super(e,t),this.data=e,this.base=n}get onChanged(){return this.base.onChanged}getMonomerSymbolsByType(e){const t=this.base.getMonomerSymbolsByType(e);for(const n of Object.keys(this.data[e]??{}))t.includes(n)||t.push(n);return t}addMissingMonomer(e,t){return this.base.addMissingMonomer(e,t)}getMonomer(e,t){const n=this.data[e]?.[t];return n??this.base.getMonomer(e,t)}}class tn{monomerLib;symbol;polymerType;monomerType;monomerLinks;monomers;error=null;constructor(e,t,n,i,o){this.monomerLib=e,this.symbol=t,this.polymerType=n,this.monomerType=i,this.monomerLinks=o;try{this.monomers=this.monomerLinks.map((e=>{const n=this.monomerLib.getMonomer(this.polymerType,e.symbol);if(!n)throw new Error("Monomer not found: ");if(n.lib?.source!=e.source)throw new Error(`Monomer '${t}' found in different library.`);return n}))}catch(e){const[t,n]=(0,ve.AP)(e);this.error=t,this.monomers=[]}}}class nn{description;placeholders;source;error;constructor(e,t,n=void 0,i=void 0){this.description=e,this.placeholders=t,this.source=n,this.error=i}updateSets(e,t=!1){t&&(this.placeholders=[]);for(const t of e)t.error||this._updateSetInt(t)}_updateSetInt(e){for(const t of e.placeholders)this.placeholders.push(t)}}var on=n(7433),sn=n.n(on),rn=n(1913),an=n.n(rn);class ln{helmMonomerSchema;validateMonomerSchema;constructor(e){this.helmMonomerSchema=e;const t=new(sn())({allErrors:!0,strictTuples:!1,allowUnionTypes:!0});an()(t),this.validateMonomerSchema=t.compile(this.helmMonomerSchema)}validateFile(e,t){const n=this.parseJson(e,t);return null!==n&&(Array.isArray(n)?this.validateJsonContent(n,t):(console.warn(`Bio: Monomer Library File Validator file '${t}': Invalid JSON format: The file must contain an array of monomers.`),!1))}parseJson(e,t){try{return JSON.parse(e)}catch(e){return console.error(`Bio: Monomer Library File Validator file '${t}': Invalid JSON format:`,e),null}}validateJsonContent(e,t){let n=!0;const i=new Set;for(const o of e){const e=o.symbol??o.id??o.name??"#N/A";if(n=this.validateMonomerSchema(o),!n){console.warn(`Bio: Monomer Library File Validator file ${t}, monomer '${e}' violating JSON schema:`,o,"\nError reason: ",JSON.stringify(this.validateMonomerSchema.errors??{}),`\nThere may be other errors in ${t} since the validation is stopped after the first error.`," Please, verify that the monomer library file satisfies the JSON schema");break}const s=`${o.polymerType??""}-${e}`;i.has(s)&&console.warn(`Bio: Monomer Library File Validator file ${t}, monomer '${e}' is duplicated.`,"Please, verify that the monomer library file does not contain duplicated monomer symbols."),i.add(s)}return n}}var cn=n(8604);class un{fileValidator;libHelper;eventManager;logger;filesPromise=Promise.resolve();initializedPromise=Promise.resolve();constructor(e,t,n,i){let o;this.fileValidator=e,this.libHelper=t,this.eventManager=n,this.logger=i;let s=!1;this.initializedPromise=Promise.race([a.delay(1e3),new Promise((e=>o=e))]),this.eventManager.updateValidLibraryFileListRequested$.subscribe((()=>{this.updateValidLibList().then((()=>{})),s||(s=!0,o())})),this.eventManager.updateValidSetFileListRequested$.subscribe((()=>{this.updateValidSetList().then((()=>{}))}))}static objCounter=-1;objId=++un.objCounter;toLog(){return`MonomerLibFileManager<${this.objId}>`}static async create(e,t,n){const i=await s.dapi.files.readAsText(cn.gt),o=JSON.parse(i),r=new ln(o);return new un(r,e,t,n)}async addLibraryFile(e,t,n=!0){try{if(await s.dapi.files.exists(cn.so+`${t}`))return void s.shell.error(`File ${t} already exists`);await this.validateAgainstHELM(e,t),await s.dapi.files.writeAsText(cn.so+`${t}`,e),await this.updateValidLibList(),await s.dapi.files.exists(cn.so+`${t}`)?s.shell.info(`Added ${t} HELM library`):s.shell.error(`Failed to add ${t} library`)}catch(e){console.error(e),s.shell.error(`Failed to add ${t} library`)}}async deleteLibraryFile(e){try{await s.dapi.files.delete(cn.so+`${e}`),await this.updateValidLibList(),s.shell.info(`Deleted ${e} library`)}catch(t){console.error(t),await s.dapi.files.exists(cn.so+`${e}`)?s.shell.error(`Failed to delete ${e} library`):s.shell.warning(`File ${e} already deleted, refresh the list`)}}async loadLibraryFromFile(e,t){let n=[];const i=new a.FileSource(e),o=await i.readAsText(t);n=JSON.parse(o);const s={},r=[];return n.forEach((e=>{const t=e.polymerType,n=e.symbol;r.includes(t)||(s[t]={},r.push(t)),s[t][n]=e})),new Qt(s,t)}async loadSetFromFile(e,t,n){let i={};const o=new a.FileSource(t),s=await o.readAsText(n);i=JSON.parse(s);const r=i.description,l=Object.entries(i.placeholders).map((([t,n])=>{const i=t,o=n.polymerType,s=n.monomerType,r=n.set;return new tn(e,i,o,s,r)}));return new nn(r,l)}getValidLibraryPaths(){return this.eventManager.getValidLibPathList()}getValidSetPaths(){return this.eventManager.getValidSetPathList()}async getValidLibraryPathsAsynchronously(){return await this.eventManager.getValidLibraryPathsAsynchronously()}async updateValidLibList(){const e=`${this.toLog()}.updateValidLibList()`;return this.logger.debug(`${e}, start`),this.filesPromise=this.filesPromise.then((async()=>{this.logger.debug(`${e}, IN`);const t=[],n=await this.getLibFileListAtLocation();if(!this.libListHasChanged(n))return void this.logger.debug(`${e}, end, not changed`);for(const e of n){if(!e.endsWith(".json")){t.push(e);continue}const n=await s.dapi.files.readAsText(cn.so+`${e}`);this.isValidHELMLibrary(n,e)||t.push(e)}const i=n.filter((e=>!t.includes(e)));if(this.libListHasChanged(i)&&(this.eventManager.changeValidLibPathList(i),await this.libHelper.loadMonomerLib(!0)),i.some((e=>!e.endsWith(".json")))&&this.logger.warning(`Wrong validation: ${i}`),t.length>0){const e=`Invalid monomer library files in ${cn.so}, consider fixing or removing them: ${t.join(", ")}`;this.logger.warning(e)}this.logger.debug(`${e}, OUT`)})),this.logger.debug(`${e}, end`),this.filesPromise}async updateValidSetList(){const e=`${this.toLog()}.updateValidSetList()`;return ro.logger.debug(`${e}, start`),this.filesPromise=this.filesPromise.then((async()=>{ro.logger.debug(`${e}, IN`);const t=[],n=await this.getSetFileListAtLocation();if(!this.setListHasChanged(n))return void ro.logger.debug(`${e}, end, not changed`);for(const e of n)e.endsWith(".json")?await s.dapi.files.readAsText(cn.Es+`${e}`):t.push(e);const i=n.filter((e=>!t.includes(e)));this.setListHasChanged(i)&&(this.eventManager.changeValidSetPathList(i),this.libHelper.loadMonomerSets(!0)),ro.logger.debug(`${e}, OUT`)})),ro.logger.debug(`${e}, end`),this.filesPromise}libListHasChanged(e){const t=this.eventManager.getValidLibPathList();return e.length!==t.length||e.some(((e,n)=>e!==t[n]))}setListHasChanged(e){const t=this.eventManager.getValidSetPathList();return e.length!==t.length||e.some(((e,n)=>e!==t[n]))}async validateAgainstHELM(e,t){if(!this.isValidHELMLibrary(e,t))throw new Error(`File ${t} does not satisfy HELM standard`)}isValidHELMLibrary(e,t){return this.fileValidator.validateFile(e,t)}async getLibFileListAtLocation(){const e=`${this.toLog()}.getLibFileListAtLocation()`;this.logger.debug(`${e}, start`);const t=await s.dapi.files.list(cn.so).then((e=>e.filter((e=>e.isFile)).map((e=>e.fullPath)))),n=[];return n.push(...t),n.map((e=>e.substring(cn.so.length)))}async getSetFileListAtLocation(){const e=`${this.toLog()}.getSetFileListAtLocation()`;this.logger.debug(`${e}, start`);const t=await s.dapi.files.list(cn.Es).then((e=>e.map((e=>e.fullPath)))),n=[];return n.push(...t),n.map((e=>e.substring(cn.Es.length)))}}class hn{constructor(){}static _instance;static getInstance(){return hn._instance||(hn._instance=new hn),hn._instance}_libFilesUpdateSubject$=new u.BehaviorSubject([]);_setFilesUpdateSubject$=new u.BehaviorSubject([]);_addLibraryFilesSubject$=new u.Subject;_librarySelectionSubject$=new u.Subject;getValidLibPathList(){return this._libFilesUpdateSubject$.getValue()}getValidSetPathList(){return this._setFilesUpdateSubject$.getValue()}async getValidLibraryPathsAsynchronously(){return new Promise((e=>{const t=this._libFilesUpdateSubject$.pipe((0,H.skip)(1)).subscribe((n=>{e(n),t.unsubscribe()}))}))}changeValidLibPathList(e){this._libFilesUpdateSubject$.next(e)}changeValidSetPathList(e){this._setFilesUpdateSubject$.next(e)}get updateUIControlsRequested$(){return this._libFilesUpdateSubject$.pipe()}get updateValidLibraryFileListRequested$(){return this._libFilesUpdateSubject$.pipe()}get updateValidSetFileListRequested$(){return this._setFilesUpdateSubject$.pipe()}get addLibraryFileRequested$(){return this._addLibraryFilesSubject$.pipe()}addLibraryFile(){this._addLibraryFilesSubject$.next()}get librarySelectionRequested$(){return this._librarySelectionSubject$}updateLibrarySelectionStatus(e,t){this._librarySelectionSubject$.next([e,t])}}class dn{logger;_monomerLib=new Qt({},"MAIN");_monomerSets=new nn("MAIN",[]);_initialLoadCompleted=!1;get initialLoadCompleted(){return this._initialLoadCompleted}_eventManager;get eventManager(){return this._eventManager}async awaitLoaded(e=1/0){return e=e===1/0?6e4:e,await Promise.race([(async()=>{const e=await this.getFileManager();return await e.filesPromise,!0})(),(async()=>(await(0,Qe.cb)(e),!1))()]).then((t=>{if(!t)throw new Error(`Loading monomer libraries timeout ${e} ms.`)}))}constructor(e){this.logger=e}static objCounter=-1;objId=(()=>{if(++dn.objCounter>0)throw new Error("MonomerLibManager MUST be a singleton.");return dn.objCounter})();toLog(){return`MonomerLibManager<${this.objId}>`}getMonomerLib(){return this._monomerLib}getBioLib(){return this.getMonomerLib()}getMonomerSets(){return this._monomerSets}get duplicateMonomers(){return this._monomerLib.duplicateMonomers}get duplicatesHandled(){return this._monomerLib.duplicatesHandled}assignDuplicatePreferances(e){this._monomerLib.assignDuplicatePreferences(e)}_fileManagerPromise;async getFileManager(){return void 0===this._fileManagerPromise&&(this._fileManagerPromise=(async()=>{const e=await un.create(this,this._eventManager,this.logger);return await e.initializedPromise,e})()),this._fileManagerPromise}loadLibrariesPromise=Promise.resolve();async loadMonomerLib(e=!1){const t=`${this.toLog()}.loadMonomerLib()`;return this.logger.debug(`${t}, start`),this.loadLibrariesPromise=this.loadLibrariesPromise.then((async()=>{this.logger.debug(`${t}, IN`);const n=a.TaskBarProgressIndicator.create("Loading monomers ...");try{const[[t],i]=await Promise.all([await this.getFileManager().then((e=>[e.getValidLibraryPaths()])),(0,Ie.ub)()]),o=t.filter((e=>{const t=!i.exclude.includes(e),n=0===i.explicit.length||i.explicit.includes(e);return t&&n}));let s=0;const r=o.length,[a]=await Promise.all([Promise.all(o.map((e=>this.readLibrary(cn.so,e).catch((t=>{const n=`Loading monomers from '${e}' error: ${t instanceof Error?t.message:t.toString()}`;return new Qt({},e,n)})).finally((()=>{n.update(Math.round(100*++s/r),`Loading monomers ${s}/${r}`)})))))]);this._monomerLib.updateLibs(a,e),this._initialLoadCompleted=!0}catch(e){const t=`Loading monomer libraries error: ${e instanceof Error?e.message:e.toString()}`;s.shell.warning(t);const n=e instanceof Error?e.stack:void 0;this.logger.error(t,void 0,n)}finally{n.close(),this.logger.debug(`${t}, OUT`)}})),this.logger.debug(`${t}, end`),this.loadLibrariesPromise}async loadLibraries(e){return this.loadMonomerLib(e)}loadSetsPromise=Promise.resolve();async loadMonomerSets(e=!1){const t=`${this.toLog()}.loadMonomerSets()`;return this.logger.debug(`${t}, start`),this.loadSetsPromise=this.loadSetsPromise.then((async()=>{this.logger.debug(`${t}, IN`);const e=a.TaskBarProgressIndicator.create("Loading monomer sets ...");try{const[[t]]=await Promise.all([await this.getFileManager().then((e=>[e.getValidSetPaths()]))]),n=t.filter((e=>!0));let i=0;const o=n.length,[s]=await Promise.all([Promise.all(n.map((t=>this.readSet(cn.Es,t).catch((e=>{const n=`Loading monomer sets from '${t}' error: ${e instanceof Error?e.message:e.toString()}`;return new nn("Broken monomer set",[],t,n)})).finally((()=>{e.update(Math.round(100*++i/o),`Loading monomers ${i}/${o}`)})))))]);this._monomerSets.updateSets(s)}catch(e){const t=`Loading monomer sets error: ${e instanceof Error?e.message:e.toString()}`;s.shell.warning(t);const n=e instanceof Error?e.stack:void 0;this.logger.error(t,void 0,n)}finally{e.close(),this.logger.debug(`${t}, OUT`)}})),this.logger.debug(`${t}, end`),this.loadSetsPromise}async readLibrary(e,t){const n=await this.getFileManager();return await n.loadLibraryFromFile(e,t)}async readSet(e,t){const n=await this.getFileManager();return await n.loadSetFromFile(this._monomerLib,e,t)}async selectSpecifiedLibraries(e){const t=await this.getInvalidFileNames(e);if(t.length>0)throw new Error(`Cannot select libraries ${t}: no such library in the list`);const n=await(0,Ie.ub)();n.exclude=(await this.getFileManager()).getValidLibraryPaths().filter((t=>!e.includes(t))),await(0,Ie.Eu)(n)}async getInvalidFileNames(e){const t=(await this.getFileManager()).getValidLibraryPaths();return e.filter((e=>!t.includes(e)))}async loadMonomerLibForTests(){await(0,Ie.Eu)(cn.G3),await this.awaitLoaded(1e4),await this.loadMonomerLib(!0)}static async getInstance(){let e=window.$monomerLibHelperPromise;return null==e&&(e=window.$monomerLibHelperPromise=(async()=>{const e=new dn(ro.logger);return e._eventManager=hn.getInstance(),e})()),e}}var pn=n(1757),mn=n.n(pn),gn=n(3017),fn={};fn.styleTagTransform=C(),fn.setAttributes=b(),fn.insert=f().bind(null,"head"),fn.domAPI=m(),fn.insertStyleElement=v(),d()(gn.A,fn),gn.A&&gn.A.locals&&gn.A.locals;var yn=n(3151);class bn{constructor(e,t=[],n={}){this.onItemChanged=new u.Subject,this.onAddingItemChanged=new u.Subject,this.onItemAdded=new u.Subject,this.onItemRemoved=new u.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),n),this._root=r.divV([],{style:{display:"grid",gridTemplateColumns:`repeat(${this.properties.length}, 1fr)`,alignItems:"center",gap:"12px"},classes:"ui-items-grid"}),this._items=t,this.render()}get root(){return this._root}get items(){return this._items}set items(e){this._items=e,this.render()}addItem(e,t=!0){this._items.push(e),this.render(),t&&this.onItemAdded.next(e)}removeItem(e,t=!0){-1!==this._items.indexOf(e)&&(this._items.splice(this._items.indexOf(e),1),this.render(),t&&this.onItemRemoved.next(e))}removeAtIndex(e,t=!0){if(e<0||e>=this._items.length)return;const n=this._items.splice(e,1);this.render(),t&&this.onItemRemoved.next(n[0])}removeAllItems(){this._items=[],this.render()}render(){var e,t,n,i,o;if(r.empty(this._root),!this.options.horizontalInputNames)for(const n of this.properties){let i=null!==(e=n.caption)&&void 0!==e?e:n.name;(null===(t=this.options.customLabels)||void 0===t?void 0:t[n.name])&&(i=this.options.customLabels[n.name]);const o=r.divText(i);o.style.fontWeight="bold",this._root.appendChild(o)}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!==(o=null===(i=(n=this.options).newItemFunction)||void 0===i?void 0:i.call(n))&&void 0!==o?o: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={},t){var n,i;const o=[],s={};let l=null;for(const c of this.properties){void 0===e[c.name]&&(e[c.name]=null);const u=(null===(n=this.options.customInputs)||void 0===n?void 0:n[c.name])?this.options.customInputs[c.name](e):r.input.forProperty(c,e),h=null===(i=this.options.validators)||void 0===i?void 0:i[c.name];h&&u.addValidator(h),o.push(this.options.horizontalInputNames?u.root:this.hideLabel(u.root)),c.propertyType!==a.TYPE.BOOL&&"color"!==c.name.toLowerCase()&&u.input&&(u.input.style.width="100%"),s[c.name]=u,u.onChanged.subscribe((()=>{e[c.name]=u.value,t?this.onAddingItemChanged.next({item:e,fieldName:c.name}):this.onItemChanged.next({item:e,fieldName:c.name})})),u.root.style.alignItems="center",l=u}let c=null;if(t)this.addingItemInputs=s,c=r.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 o;c=r.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",o}hideLabel(e){return e.getElementsByTagName("label")[0]&&e.removeChild(e.getElementsByTagName("label")[0]),e}hasErrors(){return this._root.querySelectorAll(".d4-invalid").length>0}}const wn={A:new W.A(new Uint32Array([2,0,0,0,16,0,0,0,134217728,0,0,0,32,0,33554432,0,0,0,0,0,1024,0,0,0,262144,128,0,0,0,0,0,0,0,2,0,0,524288,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1048576,0,536870912,0,0,0,0]),2048),C:new W.A(new Uint32Array([2,0,65536,0,0,0,0,32,0,0,2,0,32,0,0,0,0,0,0,0,1024,0,0,0,262144,128,0,0,0,0,0,0,0,65536,0,0,524288,0,0,0,0,0,0,0,524288,524288,0,0,0,0,0,0,0,0,0,0,0,34603008,0,536870912,64,0,0,0]),2048),D:new W.A(new Uint32Array([2,0,65600,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,1024,0,0,0,262400,128,0,0,0,0,0,0,0,0,0,2097152,524288,0,0,0,1024,0,0,0,524288,0,0,0,0,0,0,0,0,0,512,0,0,34603008,0,536870912,0,0,0,0]),2048),E:new W.A(new Uint32Array([2,0,65536,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,1024,0,0,8,262144,128,0,0,16,134217728,0,0,0,0,0,0,524288,0,0,0,128,0,0,0,524288,0,0,0,268435456,0,0,0,0,0,512,2147483648,0,34603008,0,536870912,0,0,0,0]),2048),F:new W.A(new Uint32Array([2,0,98304,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,1024,0,0,0,262144,128,33554432,0,0,0,0,33554432,0,1024,1,0,524288,32768,32,0,0,0,0,16,524288,0,0,0,0,0,0,0,0,0,71303168,0,0,34603008,131072,536870912,0,0,0,0]),2048),G:new W.A(new Uint32Array([134217728,0,65536,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,1024,0,0,0,0,128,0,0,0,0,2097216,0,0,0,0,0,524288,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,512,0,0,0,0,536870912,0,0,0,0]),2048),H:new W.A(new Uint32Array([2,0,1073840128,0,0,0,0,0,0,0,0,67108864,32,0,0,0,0,0,0,0,1024,0,512,0,262144,192,0,268435456,0,0,8200,0,0,0,67108864,0,524296,0,32,0,0,0,0,16,524288,0,0,2147483648,0,0,8,0,0,0,0,0,0,34603008,131072,536870920,4194304,0,0,0]),2048),I:new W.A(new Uint32Array([2,0,65536,0,0,0,0,0,150994944,64,0,0,32,0,0,0,0,0,0,0,1024,0,8388608,0,327680,128,0,0,0,0,0,0,0,2,0,524288,524288,0,0,0,0,0,0,0,0,0,0,0,256,0,0,0,0,8388608,0,33554432,0,1048576,0,536870912,0,0,0,0]),2048),K:new W.A(new Uint32Array([2,0,65536,0,0,0,0,0,0,0,0,0,268435488,0,0,0,0,0,0,0,1024,0,0,8,262144,128,0,0,0,0,2097152,0,0,67108864,0,0,524288,0,0,0,8,0,0,0,524288,0,0,8192,0,0,0,0,0,0,0,2147483648,0,34668544,0,545259520,0,0,0,0]),2048),L:new W.A(new Uint32Array([2,0,65536,0,0,0,0,0,134217728,0,0,0,32,512,0,0,0,0,0,0,1024,256,0,8388608,262400,128,0,0,0,0,0,0,0,2,0,0,524288,0,0,0,0,0,0,0,524288,0,0,0,0,0,0,0,0,0,0,0,0,42991616,0,536870912,0,0,0,0]),2048),M:new W.A(new Uint32Array([2050,0,65536,1048576,0,0,0,0,0,0,0,0,1056,0,0,0,0,0,0,0,1024,0,0,8,262144,128,0,0,0,0,0,536870912,0,2,0,0,1074266112,0,0,0,0,0,0,0,524288,0,0,0,4194304,0,0,0,0,0,0,2147483648,0,34603008,0,536870912,4194304,0,0,0]),2048),N:new W.A(new Uint32Array([2,0,65536,0,4096,0,0,0,0,0,0,16777216,32,0,0,0,0,0,0,0,1024,0,0,0,262400,128,0,0,0,0,0,0,0,0,0,0,524288,0,0,0,1024,0,0,0,524288,0,0,0,0,0,0,0,0,0,0,0,0,34603008,0,536871936,67108864,0,0,0]),2048),P:new W.A(new Uint32Array([0,0,1024,0,0,0,0,0,0,131072,0,1024,32,0,0,0,0,512,0,0,1024,0,0,64,0,128,0,0,1073741824,0,0,138412032,16,0,67108864,0,0,0,0,0,0,8192,0,0,8388608,0,0,8,0,0,0,0,0,0,256,0,0,0,0,553648128,0,0,0,0]),2048),Q:new W.A(new Uint32Array([2,0,65536,0,4096,0,0,0,0,0,0,0,32,0,0,0,0,2,0,0,1024,0,0,8,262144,128,0,0,16,0,0,0,0,0,0,0,524288,0,0,0,0,0,0,0,524288,0,0,0,268435456,0,0,0,0,0,16777216,2147483648,0,34603008,0,536871936,0,0,0,0]),2048),R:new W.A(new Uint32Array([2,0,65536,0,4096,0,32,0,0,0,0,0,268435488,0,0,0,0,0,0,32768,134218752,0,16,8,262144,128,0,1073741824,0,0,8388608,0,0,0,65536,0,524289,0,0,0,0,0,0,0,524288,2048,0,0,0,0,0,0,0,0,0,2147483648,0,34603008,1048576,545259520,0,0,0,0]),2048),S:new W.A(new Uint32Array([2,0,65536,0,0,0,1073741824,0,0,0,0,0,32,0,0,4,0,0,0,0,1024,0,0,0,262144,128,0,0,0,0,0,0,0,0,0,0,524288,0,0,1048576,0,0,0,0,524288,0,0,0,0,0,0,0,0,0,8388608,0,0,34603008,0,536870912,0,0,0,0]),2048),T:new W.A(new Uint32Array([2,0,0,0,0,0,0,8,134217728,0,0,67108864,32,0,0,0,0,0,0,0,1024,0,8388608,0,262144,128,0,0,0,0,0,0,0,2,0,524288,524288,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,536870912,0,0,0,0,1048576,67108864,536870912,0,0,0,0]),2048),V:new W.A(new Uint32Array([2,0,0,0,0,0,0,0,134217728,0,0,0,32,0,0,0,0,0,0,0,1024,0,8388608,0,262144,128,0,0,0,0,0,1073741824,128,2,0,524288,524288,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8192,0,1048576,0,536870912,0,0,0,0]),2048),W:new W.A(new Uint32Array([2,0,98304,8388608,0,0,0,0,0,0,256,4096,32,0,0,0,0,0,0,0,1024,0,0,0,262144,192,0,0,0,0,0,0,0,0,67108865,0,524288,32768,32,0,0,0,8224,16,524288,0,0,0,0,32,128,0,2097152,0,4194304,8388608,0,34603008,8519680,536870912,131072,262144,0,0]),2048),Y:new W.A(new Uint32Array([2,0,98304,0,0,0,0,0,0,4194304,0,0,32,0,0,0,0,0,0,0,1024,0,0,512,262144,128,33554432,0,0,0,0,33554432,0,0,0,0,524288,0,32,0,0,2,0,16,524288,0,0,0,0,0,4,0,0,0,71303168,262144,0,34603008,131072,536870912,0,0,0,0]),2048)},vn={RNA:{A:new W.A(new Uint32Array([0,0,0,0,0,0,0,0,0,1024,0,67108864,0,0,0,512,0,0,0,8388608,0,0,512,0,0,64,4,0,0,0,4,0,0,0,67108864,0,524289,0,0,0,0,0,0,16,0,659456,0,256,0,16,0,0,0,268435456,0,0,262144,0,131072,0,0,0,8388608,0]),2048),C:new W.A(new Uint32Array([0,1073741824,0,0,0,0,0,2147483648,4,67108864,0,67108864,0,256,0,0,0,0,0,0,1024,0,128,0,0,64,0,0,0,0,0,0,0,0,67108864,0,524289,0,65536,0,0,0,0,16,0,131072,0,4,0,0,0,0,0,0,4194304,0,0,2147483648,131072,0,4096,0,0,0]),2048),G:new W.A(new Uint32Array([0,0,0,0,1024,0,0,0,0,67109888,16384,67108864,0,0,0,0,0,0,0,33562624,1024,33554432,512,16384,0,64,4,0,0,33554432,0,0,0,0,67108864,0,524289,0,0,0,0,0,0,16,0,135168,0,268435456,0,0,0,0,0,268435456,131072,0,0,2147483648,131072,0,0,0,8388608,0]),2048),T:new W.A(new Uint32Array([8388608,0,0,0,0,0,0,0,0,67108864,0,0,0,4,0,0,0,0,0,0,1024,0,0,16384,0,64,0,0,0,0,0,0,0,2,67108864,0,0,0,0,0,0,0,0,40976,0,0,0,0,0,0,0,0,0,67108864,131072,524288,0,0,8519680,0,1,33554432,1048576,0]),2048),U:new W.A(new Uint32Array([0,0,131072,1073741824,0,0,0,0,0,67108864,0,0,0,0,0,0,0,0,0,0,1024,0,128,0,0,64,0,0,0,0,0,0,0,32768,67108864,0,0,0,0,0,0,0,0,16,0,0,0,4,0,0,2048,0,0,0,4341760,0,0,0,131072,0,0,33554432,1048576,0]),2048)},PEPTIDE:wn};async function An(e,t,n=0){if(!Object.keys(vn).includes(t))return null;const i=await async function(e){const t=a.Func.find({package:"Chem",name:"getMorganFingerprint"})?.[0];if(!t)return null;try{const n=(await t.apply({molString:e}))?.getBuffer().buffer;if(n)return new W.A(new Uint32Array(n),2048)}catch(e){return null}}(e);if(!i)return null;if(!vn[t])return null;const o=vn[t];let s=0,r=null;for(const[e,t]of Object.entries(o)){const o=(0,k.$1)(i,t);o>s&&o>=n&&(s=o,r=e)}return r}var Cn,Tn=n(857),Sn={};Sn.styleTagTransform=C(),Sn.setAttributes=b(),Sn.insert=f().bind(null,"head"),Sn.domAPI=m(),Sn.insertStyleElement=v(),d()(Tn.A,Sn),Tn.A&&Tn.A.locals&&Tn.A.locals,function(e){e.MONOMER="Monomer",e.SYMBOL="Symbol",e.NAME="Name",e.R_GROUPS="~R-Groups",e.MONOMER_TYPE="Monomer Type",e.POLYMER_TYPE="Polymer Type",e.NATURAL_ANALOG="Natural Analog",e.AUTHOR="Author",e.CREATE_DATE="Create Date",e.ID="ID",e.META="Meta",e.SOURCE="Source"}(Cn||(Cn={}));const En={[Cn.MONOMER]:a.COLUMN_TYPE.STRING,[Cn.SYMBOL]:a.COLUMN_TYPE.STRING,[Cn.NAME]:a.COLUMN_TYPE.STRING,[Cn.R_GROUPS]:a.COLUMN_TYPE.STRING,[Cn.MONOMER_TYPE]:a.COLUMN_TYPE.STRING,[Cn.POLYMER_TYPE]:a.COLUMN_TYPE.STRING,[Cn.NATURAL_ANALOG]:a.COLUMN_TYPE.STRING,[Cn.AUTHOR]:a.COLUMN_TYPE.STRING,[Cn.CREATE_DATE]:a.COLUMN_TYPE.DATE_TIME,[Cn.ID]:a.COLUMN_TYPE.INT,[Cn.META]:a.COLUMN_TYPE.STRING,[Cn.SOURCE]:a.COLUMN_TYPE.STRING};class Mn{monomerLibManamger;adjustTable(){this.tv?.dataFrame&&(s.data.detectSemanticTypes(this.tv.dataFrame),this.tv.dataFrame.meta.detectSemanticTypes()),setTimeout((()=>{this.tv?.grid&&(this.tv.grid.props.allowEdit=!1,this.tv.grid.col(Cn.NAME).width=100,this.tv.grid.col(Cn.SYMBOL).width=70)}),200)}static VIEW_NAME="Manage Monomers";_newMonomer=yn.pe;_newMonomerForm;monomerLib;tv=null;libInput;static instance;activeMonomerLib=null;constructor(e){this.monomerLibManamger=e,this.monomerLib=e.getBioLib(),this._newMonomerForm=new Pn(e,(()=>this.activeMonomerLib),(async e=>{const t=await this.getMonomersDf(this.libInput.value);this.tv?.dataFrame&&(this.tv.dataFrame=t,this.adjustTable(),null!=e&&setTimeout((()=>{const n=t.col(Cn.SYMBOL).toList().indexOf(e);-1!==n&&(this.tv?.grid.scrollToCell(t.columns.byIndex(0),n),t.currentRow=t.rows.get(n))}),500))}),(()=>this.tv?.dataFrame))}static async getInstance(){if(!this.instance){const e=await dn.getInstance();await e.awaitLoaded(),await e.loadLibrariesPromise,this.instance=new Mn(e)}return this.instance}static async getNewInstance(){const e=await dn.getInstance();return await e.awaitLoaded(),await e.loadLibrariesPromise,new Mn(e)}async createNewMonomerLib(e,t){this.tv?.grid&&r.setUpdateIndicator(this.tv.grid.root,!0);try{const n=JSON.stringify(t.map((e=>({...e,lib:void 0,wem:void 0}))),null,2);e.endsWith(".json")||(e+=".json"),await(await this.monomerLibManamger.getFileManager()).addLibraryFile(n,e),await s.dapi.files.writeAsText(cn.so+e,n),await this.monomerLibManamger.loadLibraries(!1),s.shell.v=await this.getViewRoot(e)}catch(e){s.shell.error("Error creating library"),console.error(e)}finally{this.tv?.grid&&r.setUpdateIndicator(this.tv.grid.root,!1)}}async createNewLibDialog(e){const t=(await this.monomerLibManamger.getFileManager()).getValidLibraryPaths(),n=r.input.string("Library Name",{placeholder:"Enter library name",nullable:!1,onValueChanged:()=>{const e=i(n.value);o.getButton("Create")?.classList?.toggle("d4-disabled",!!e)}});function i(e){return e&&e.trim()?e.endsWith(".json")&&t.includes(e)||t.includes(e+".json")?"Library with this name already exists":null:"Library name cannot be empty"}n.addValidator(i);const o=r.dialog("Create New Library").add(n).addButton("Create",(async()=>{const t=i(n.value);if(t)s.shell.warning(t);else{try{await this.createNewMonomerLib(function(){let e=n.value;return e.endsWith(".json")||(e+=".json"),e}(),e??[])}catch(e){s.shell.error("Error creating library"),console.error(e)}o.close()}})).show();o.getButton("Create")?.classList?.toggle("d4-disabled",!0)}get newMonomer(){return this._newMonomer}getNewMonomerForm(){return this._newMonomerForm}async getMonomersTableView(e,t=!0){const n=await this.getMonomersDf(e);return this.tv=a.TableView.create(n,t),this.adjustTable(),this.tv.subs.push(s.events.onContextMenu.subscribe((({args:e})=>{if(!e||!e.menu||!e.context||e.context.type!==a.VIEWER.GRID||!e.context.tableView||e.context.tableView.id!==(this.tv.id??"")||!e.item||!e.item.isTableCell||(e.item.tableRowIndex??-1)<0)return;const t=e.item.tableRowIndex;e.menu.item("Edit Monomer",(async()=>{await this.editMonomer(this.tv.dataFrame.rows.get(t))})),e.menu.item("Fix all monomers",(()=>{this.fixAllMonomers()})),this.tv.dataFrame.selection.trueCount>0?(e.menu.item("Remove Selected Monomers",(async()=>{const e=await Promise.all(Array.from(this.tv.dataFrame.selection.getSelectedIndexes()).map((e=>Hn(this.tv.dataFrame.rows.get(e)))));this._newMonomerForm.removeMonomers(e,this.libInput.value)})),e.menu.item("Selection To New Library",(async()=>{const e=await Promise.all(Array.from(this.tv.dataFrame.selection.getSelectedIndexes()).map((e=>Hn(this.tv.dataFrame.rows.get(e)))));this.createNewLibDialog(e)}))):e.menu.item("Remove Monomer",(async()=>{const e=await Hn(this.tv.dataFrame.rows.get(t));this._newMonomerForm.removeMonomers([e],this.libInput.value)}))}))),this.tv.grid&&(this.tv.grid.props.allowEdit=!1),this.tv}static closeAllMonomerManagers(){Array.from(s.shell.tableViews??[]).filter((e=>e.name===Mn.VIEW_NAME)).forEach((e=>e.close()))}findActiveManagerView(){if(!this.tv)return null;const e=Array.from(s.shell.tableViews??[]).find((e=>e.id===this.tv.id));return e?s.shell.v=e:Mn.closeAllMonomerManagers(),e??null}_skipLibInputOnchange=!1;async getViewRoot(e,t=!0){const n=(await this.monomerLibManamger.getFileManager()).getValidLibraryPaths();if(this._newMonomerForm.molSketcher.resize(),t&&(this.tv=this.findActiveManagerView())&&(e??this.libInput.value)){try{this._skipLibInputOnchange=!0,this.libInput&&(this.libInput.items=n),e&&(this.libInput.value=e)}catch(e){s.shell.error("Error updating library list"),console.error(e)}finally{this._skipLibInputOnchange=!1}const t=await this.getMonomersDf(e);return this.tv.dataFrame=t,this.adjustTable(),this.tv}e??=n[0],this.tv=await this.getMonomersTableView(e,t);let i=this.tv.getRibbonPanels();i.forEach(((e,t)=>{i[t]=e.filter((e=>0!==e.getElementsByClassName("grok-icon-filter").length))})),i=i.filter((e=>e.length>0));const o=r.icons.add((()=>{this._newMonomerForm.setEmptyMonomer()}),"Add New Monomer"),l=r.iconFA("wand-magic",(()=>{this.fixAllMonomers()}),"Fix all monomers"),c=r.icons.edit((async()=>{(this.tv?.dataFrame?.currentRowIdx??-1)<0||await this.editMonomer(this.tv.dataFrame.rows.get(this.tv.dataFrame.currentRowIdx))}),"Edit Monomer"),u=r.icons.delete((async()=>{const e=this.tv?.dataFrame?.currentRowIdx??-1,t=Array.from(this.tv?.dataFrame?.selection?.getSelectedIndexes()??[]);if(e<0&&0===t.length)return;if(t.length>0){const e=await Promise.all(t.map((e=>Hn(this.tv.dataFrame.rows.get(e)))));return void await this._newMonomerForm.removeMonomers(e,this.libInput.value)}const n=await Hn(this.tv.dataFrame.rows.get(e));await this._newMonomerForm.removeMonomers([n],this.libInput.value)}));r.tooltip.bind(u,(()=>(this.tv?.dataFrame?.selection?.trueCount??0)>0?"Delete selected monomers":"Delete monomer"));const h=r.iconFA("arrow-to-bottom",(async()=>{const e=this.libInput.value;if(!e)return s.shell.error("No library selected");let t=null;try{t=await s.dapi.files.readAsText(cn.so+e)}catch(t){return s.shell.error(`Error reading library ${e}`),console.error(t)}if(!t)return s.shell.error(`Library ${e} is empty`);a.Utils.download(e,t,"text/plain")}),"Download Monomer Library");i.push([o,c,l,u,h]),this.tv.setRibbonPanels(i),this.tv.name=Mn.VIEW_NAME,this.libInput=r.input.choice("Monomer Library",{value:e,items:n,nullable:!1,onValueChanged:async()=>{try{if(this._skipLibInputOnchange)return;const e=await this.getMonomersDf(this.libInput.value);this.tv.dataFrame=e,this.adjustTable()}catch(e){console.error(e)}}}),this.libInput.addOptions(r.icons.add((()=>{this.createNewLibDialog()}),"Create new monomer library..."));const d=this._newMonomerForm.form;return d.prepend(this.libInput.root),r.tools.waitForElementInDom(this.tv.root).then((()=>{this.tv.dockManager.dock(d,a.DOCK_TYPE.LEFT,null,void 0,.4)})),this.tv}async editMonomer(e){return this._newMonomer=await Hn(e),this._newMonomerForm.setMonomer(this._newMonomer),this._newMonomer}async getMonomersDf(e){this.tv?.grid&&r.setUpdateIndicator(this.tv.grid.root,!0);try{return e??=(await this.monomerLibManamger.getFileManager()).getValidLibraryPaths()[0],this.activeMonomerLib=await this.monomerLibManamger.readLibrary(cn.so,e),this.activeMonomerLib?function(e){try{const t=e.getPolymerTypes().flatMap((t=>e.getMonomerSymbolsByType(t).map((n=>e.getMonomer(t,n))))),n=a.DataFrame.create(t.length),i=new Set;for(const e of t)e.rgroups.forEach((e=>{e.label&&i.add(e.label)}));const o=Array.from(i);o.sort();for(const[e,t]of Object.entries(En))if(n.columns.addNew(e,t),e===Cn.R_GROUPS)for(const e of o)n.columns.addNew(e,a.COLUMN_TYPE.STRING);n.col(Cn.SYMBOL).semType="Monomer",n.col(Cn.SYMBOL).setTag(Re.Mn.applyToBackground,"true");for(let e=0;e<t.length;e++){let i=Rn(t[e].rgroups,t[e].smiles,t[e].molfile);i=xn(i),t[e].rgroups=In(t[e].rgroups);const s=o.map((n=>{const i=t[e].rgroups.find((e=>e.label===n));return i?_n(i,"capGroupSmiles"):""}));let r=null;if(t[e].createDate)try{r=Date.parse(t[e].createDate)}catch(n){console.error(`Error parsing date ${t[e].createDate}`)}n.rows.setValues(e,[i,t[e].symbol,t[e].name,JSON.stringify(t[e].rgroups??[]),...s,t[e].monomerType,t[e].polymerType,t[e].naturalAnalog,t[e].author,r,t[e].id,JSON.stringify(t[e].meta??{}),t[e].lib?.source??""]);try{r&&n.col(Cn.CREATE_DATE)?.set(e,r,!1)}catch(n){console.error(`Error setting date ${t[e].createDate}`,n)}}return n.col(Cn.MONOMER).semType=a.SEMTYPE.MOLECULE,o.forEach((e=>{n.col(e).semType=a.SEMTYPE.MOLECULE})),n}catch(e){throw s.shell.error("Error creating monomers dataframe"),console.error(e),e}}(this.activeMonomerLib):(s.shell.error(`Library ${e} not found`),a.DataFrame.create())}catch(e){throw s.shell.error("Error creating monomers dataframe"),console.error(e),e}finally{this.tv?.grid&&r.setUpdateIndicator(this.tv.grid.root,!1)}}async fixAllMonomers(){r.dialog("Fix All Monomers").add(r.divText("This action will fix all monomers in the library, standardize their smiles, molblocks and r-groups, assign correct natural analogs and save the library.")).add(r.divText("Do you wish to continue?")).onOK((async()=>{const e=this.tv?.dataFrame;let t=this.libInput.value;if(e&&t){this.tv?.grid&&r.setUpdateIndicator(this.tv.grid.root,!0);try{const n=await Promise.all(new Array(e.rowCount).fill(0).map(((t,n)=>Hn(e.rows.get(n))))),i=JSON.stringify(n.map((e=>({...e,lib:void 0,wem:void 0}))),null,2);t.endsWith(".json")||(t+=".json"),await s.dapi.files.writeAsText(cn.so+t,i),await this.monomerLibManamger.loadLibraries(!0),s.shell.v=await this.getViewRoot(t)}catch(e){s.shell.error("Error saving library"),console.error(e)}finally{this.tv?.grid&&r.setUpdateIndicator(this.tv.grid.root,!1)}}else s.shell.error("No monomer library loaded")})).show()}resetCurrentRowFollowing(){this._newMonomerForm.molChanged=!1}}function xn(e){let t=e.replaceAll(/\[R[1-9]\]/g,(e=>`[*:${e[2]}]`));return t=t.replaceAll(/\[\d\*\]/g,(e=>`[*:${e[1]}]`)),t.replaceAll(/\[\d\*\:\d\]/g,(e=>`[*:${e[1]}]`))}const Ln=["alternateId","capGroupName","capGroupSMILES","label"];function _n(e,t){const n=Object.keys(e).find((e=>e.toLowerCase()===t.toLowerCase()));if(n)return e[n]}function In(e){return e.map((e=>{const t=function(e,t){const n={};return e.forEach((e=>{const i=Object.keys(t).find((t=>t.toLowerCase()===e.toLowerCase()));i&&(n[e]=t[i])})),n}(Ln,e),n=_n(t,"capGroupSMILES"),i=_n(t,"alternateId"),o=_n(t,"capGroupName"),s=_n(t,"label")??"R1";if(n&&i&&o||s.length<2)return t;if(i&&-1!==i.indexOf(`${s}-`)){const e=i.replace(`${s}-`,"");o||(t.capGroupName=e),n||(t.capGroupSMILES=`[*:${s.substring(1)}][${e}]`)}else o&&(n||(t.capGroupSMILES=`[*:${s.substring(1)}][${o}]`),i||(t.alternateId=`${s}-${o}`));return t})).sort(((e,t)=>e.label?.localeCompare(t.label??"")??0))}class Pn{monomerLibManager;getMonomerLib;refreshTable;getMonomersDataFrame;molSketcher;monomerTypeInput;polymerTypeInput;monomerSymbolInput;monomerNameInput;monomerIdInput;monomerNaturalAnalogInput;rgroupsGrid;metaGrid;colors;colorsEditor;saveButton;rgroupsGridRoot;_molChanged=!1;get molChanged(){return this._molChanged}set molChanged(e){this._molChanged=e}saveValidationResult=null;triggerMolChange=!0;inputsTabControl;constructor(e,t,n,i){this.monomerLibManager=e,this.getMonomerLib=t,this.refreshTable=n,this.getMonomersDataFrame=i,this.colors={line:"#000000",background:"#000000",text:"#000000"},this.colorsEditor=new kn(this.colors),this.molSketcher=new a.chem.Sketcher,this.molSketcher.root.classList.add("monomer-manager-sketcher"),this.polymerTypeInput=r.input.choice("Polymer Type",{value:"PEPTIDE",items:["PEPTIDE","RNA","CHEM","BLOB","G"],onValueChanged:()=>this.onMonomerInputChanged(),nullable:!1}),this.monomerTypeInput=r.input.choice("Monomer Type",{value:"Backbone",items:["Backbone","Branch","Terminal"],onValueChanged:()=>this.onMonomerInputChanged(),nullable:!1}),this.monomerSymbolInput=r.input.string("Monomer Symbol",{nullable:!1,onValueChanged:()=>this.onMonomerInputChanged()}),this.monomerNameInput=r.input.string("Monomer Name",{nullable:!1,onValueChanged:()=>this.onMonomerInputChanged()}),this.monomerNameInput.nullable=!1,this.monomerIdInput=r.input.int("Monomer ID",{nullable:!0,value:0,onValueChanged:()=>this.onMonomerInputChanged()}),this.monomerNaturalAnalogInput=r.input.string("Natural Analog",{nullable:!0,onValueChanged:()=>this.onMonomerInputChanged()}),this.saveButton=r.bigButton("Save",(async()=>{const e=this.validateInputs();e?s.shell.warning(e):await this.saveMonomer()})),this.molSketcher.subs.push(this.molSketcher.onChanged.subscribe((async()=>{if(this.triggerMolChange){try{this.rgroupsGridRoot.style.display="none";const e=this.inputsTabControl.panes.find((e=>"r-groups"===e.name?.toLowerCase()));e&&e.header.style.removeProperty("background-color");let t=this.molSketcher.getSmiles();if(!t)return this.rgroupsGrid.items=[],this.rgroupsGrid.render(),this.saveValidationResult="Monomer molecule is required",void this.invalidateSaveButton();t=Rn([],t);const n=this.findRgroupsInSmiles(t);if(0===n.length)return this.rgroupsGrid.items=[],this.rgroupsGrid.render(),this.saveValidationResult="At least one R-group is required",e&&e.header.style.setProperty("background-color","#ff000030"),void this.invalidateSaveButton();if(new Set(n.map((e=>e[0]))).size!==n.length)return this.saveValidationResult="Duplicate R-groups are not allowed",this.rgroupsGridRoot.style.display="flex",e&&e.header.style.setProperty("background-color","#ff000030"),void this.invalidateSaveButton();const i=n.map((e=>Number.parseInt(e[0].match(/[1-9]/g)[0]))).map((e=>this.rgroupsGrid.items.find((t=>t.label===`R${e}`))??{capGroupSMILES:`[*:${e}][H]`,alternateId:`R${e}-H`,capGroupName:"H",label:`R${e}`}));this.rgroupsGrid.items=i.sort(((e,t)=>e.label?.localeCompare(t.label??"")??0)),this.rgroupsGrid.render(),this.rgroupsGridRoot.style.display="flex";const o=await An(On(t,i),this.polymerTypeInput.value??"");o&&(this.monomerNaturalAnalogInput.value=o)}catch(e){console.error(e)}this.onMonomerInputChanged(),this._molChanged=!0}else this.triggerMolChange=!0})));const o=[a.Property.js("capGroupSMILES",a.TYPE.STRING,{caption:"R-group SMILES",nullable:!1}),a.Property.js("alternateId",a.TYPE.STRING,{caption:"Alternate ID",nullable:!1}),a.Property.js("capGroupName",a.TYPE.STRING,{caption:"R-group name",nullable:!1}),a.Property.js("label",a.TYPE.STRING,{fieldName:"R-group Label",nullable:!1,userEditable:!1})];this.rgroupsGrid=new bn(o,[],{allowAdd:!1,allowRemove:!1,validators:{capGroupSMILES:e=>e?s.chem.checkSmiles(e)?null:"Invalid SMILES":"Cap group smiles is required",alternateId:e=>e?null:"Alternate ID is required",capGroupName:e=>e?null:"Cap group name is required",label:e=>e?null:"R-group label is required"},customLabels:{capGroupSMILES:"R-group SMILES",alternateId:"Alternate ID",capGroupName:"Cap Group Name",label:"Label"}}),this.rgroupsGrid.onItemChanged.subscribe((()=>this.onMonomerInputChanged())),this.rgroupsGridRoot=r.divV([this.rgroupsGrid.root]),this.rgroupsGridRoot.style.display="none";const l=[a.Property.js("Property",a.TYPE.STRING,{caption:"Property",nullable:!0}),a.Property.js("Value",a.TYPE.STRING,{caption:"Value",nullable:!0})];this.metaGrid=new bn(l,[]),this.onMonomerInputChanged();const c=r.divV([this.polymerTypeInput,this.monomerTypeInput,this.monomerSymbolInput,this.monomerNameInput,this.monomerIdInput,this.monomerNaturalAnalogInput]);this.inputsTabControl=r.tabControl({Monomer:c,"R-groups":this.rgroupsGridRoot,Meta:r.divV([this.metaGrid.root]),Colors:this.colorsEditor.form},!1)}invalidateSaveButton(){this.saveValidationResult?this.saveButton.classList.add("d4-disabled"):this.saveButton.classList.remove("d4-disabled")}onMonomerInputChanged(){setTimeout((()=>{this.saveValidationResult=this.validateInputs(),this.invalidateSaveButton();const e=this.polymerTypeInput.value&&this.polymerTypeInput.value&&!!this.getMonomerLib()?.getMonomer(this.polymerTypeInput.value,this.monomerSymbolInput.value);this.saveButton.textContent=e?"Save Monomer":"Add Monomer"}),200)}setEmptyMonomer(){this.triggerMolChange=!1,this.molSketcher.setSmiles(""),this.monomerSymbolInput.value="",this.monomerNameInput.value="",this.monomerIdInput.value=null,this.monomerNaturalAnalogInput.value=null,this.rgroupsGrid.items=[],this.metaGrid.items=[],this.rgroupsGrid.render(),this.metaGrid.render(),this.rgroupsGridRoot.style.display="none",this.onMonomerInputChanged(),this.colorsEditor.colors={line:"#000000",background:"#000000",text:"#000000"}}setMonomer(e){this.triggerMolChange=!1,this.molSketcher.setSmiles(e.smiles),this.polymerTypeInput.value=e.polymerType,this.monomerTypeInput.value=e.monomerType,this.monomerSymbolInput.value=e.symbol,this.monomerNameInput.value=e.name,this.monomerIdInput.value=e.id,this.monomerNaturalAnalogInput.value=e.naturalAnalog??null,this.rgroupsGrid.items=In(e.rgroups),this.metaGrid.items=Object.entries(e.meta??{}).filter((([e,t])=>"colors"!==e?.toLowerCase())).map((([e,t])=>({Property:e,Value:t}))),this.rgroupsGrid.render(),this.metaGrid.render(),this.rgroupsGridRoot.style.display="flex",this.onMonomerInputChanged(),!e.naturalAnalog&&e.polymerType&&An(On(e.smiles,this.rgroupsGrid.items),e.polymerType).then((e=>{e&&(this.monomerNaturalAnalogInput.value=e)}));const t=e.meta?.colors??"";let n={};try{n=t?JSON.parse(t)?.default:{}}catch(e){console.error(e)}this.colorsEditor.colors={line:n.line??"#000000",background:n.background??"#000000",text:n.text??"#000000"}}validateInputs(){const e=this.inputsTabControl.panes.find((e=>"r-groups"===e.name?.toLowerCase()));if(e&&e.header.style.removeProperty("background-color"),!this.molSketcher.getSmiles())return"Monomer Molecule field is required";for(const e of[this.polymerTypeInput,this.monomerTypeInput,this.monomerSymbolInput,this.monomerNameInput])if(null==e.value||""===e.value)return`${e.caption} field is required`;let t=null;if(this.rgroupsGrid.items.length<1&&(t="At least one R-group is required"),!t)e:for(const e of this.rgroupsGrid.items)for(const[n,i]of Object.entries(e))if(!i){t=`R-group ${n} field is required for ${e.label}`;break e}return!t&&this.rgroupsGrid.hasErrors()&&(t="R-group fields contain errors"),t?(e&&e.header.style.setProperty("background-color","#ff000030"),t):null}findRgroupsInSmiles(e){return[...Array.from(e.matchAll(/\[[1-9]\*\]/g)),...Array.from(e.matchAll(/\[\*\:[1-9]\]/g))]}get form(){this.inputsTabControl.root.classList.add("monomer-manager-form-tab-control"),this.inputsTabControl.header.style.marginBottom="10px";const e=r.buttonsInput([this.saveButton]);return r.tooltip.bind(e,(()=>this.saveValidationResult??"Save monomer to library")),r.divV([this.molSketcher.root,this.inputsTabControl.root,e],{classes:"ui-form",style:{paddingLeft:"10px",overflow:"scroll",maxWidth:"unset"}})}get fieldInputs(){return{molecule:this.molSketcher,polymerType:this.polymerTypeInput,monomerType:this.monomerTypeInput,symbol:this.monomerSymbolInput,name:this.monomerNameInput,id:this.monomerIdInput,naturalAnalog:this.monomerNaturalAnalogInput}}get metaInputs(){return[]}get rgroupInputs(){return[]}getMonomerInfoTable(e){const t=Rn(e.rgroups,e.smiles,e.molfile),n=s.chem.drawMolecule(t,150,150),i=r.tableFromMap({name:e.name,author:e.author,createDate:e.createDate});return r.divH([n,i],{style:{alignItems:"center"}})}async removeMonomers(e,t,n=!0){let i=[];try{const e=await s.dapi.files.readAsText(cn.so+t);i=JSON.parse(e)}catch(e){return s.shell.error(`Error reading library ${t}`),console.error(e)}const o=e.map((e=>Nn(i,(t=>t.symbol===e.symbol&&t.polymerType===e.polymerType))));for(let n=0;n<o.length;n++)if(-1===o[n])return void s.shell.error(`Monomer ${e[n].symbol} not found in library ${t}`);const a=o.map((e=>i[e])),l=r.divV(a.map((e=>this.getMonomerInfoTable(e))),{style:{maxHeight:"500px",overflow:"scroll"}}),c=a.length>1,u=c?`Are you sure you want to remove monomers ${a.map((e=>e.symbol)).join(", ")} from ${t} library?`:`Are you sure you want to remove monomer with symbol ${a[0].symbol} from ${t} library?`,h=r.dialog("Remove Monomer"+(c?"s":"")).add(r.h1(u)).add(l).addButton("Remove",(async()=>{i=i.filter((e=>!a.includes(e))),await s.dapi.files.writeAsText(cn.so+t,JSON.stringify(i,null,2)),await(await dn.getInstance()).loadLibraries(!0),await this.refreshTable(),n&&s.shell.info(`Monomer${c?"s":""} ${a.map((e=>e.symbol)).join(", ")} ${c?"were":"was"} successfully removed from ${t} library`),h.close()})).show()}async addMonomerToLib(e,t){let n=[];try{const e=await s.dapi.files.readAsText(cn.so+t);n=JSON.parse(e)}catch(e){return s.shell.error(`Error reading library ${t}`),console.error(e)}const i=Nn(n,(t=>t.symbol===e.symbol&&t.polymerType===e.polymerType)),o=this.getMonomersDataFrame()?.col(Cn.MONOMER)?.toList()?.findIndex((t=>t===e.smiles)),a=async()=>{try{const i=n.findIndex((t=>t.symbol===e.symbol&&t.polymerType===e.polymerType));i>=0?n[i]={...e,lib:void 0,wem:void 0}:n.push({...e,lib:void 0,wem:void 0}),await s.dapi.files.writeAsText(cn.so+t,JSON.stringify(n,null,2)),await(await dn.getInstance()).loadLibraries(!0),await this.refreshTable(e.symbol),this._molChanged=!1,s.shell.info(`Monomer ${e.symbol} was successfully saved in library ${t}`)}catch(e){s.shell.error("Error saving monomer"),console.error(e)}this.onMonomerInputChanged()};let l=null,c="";if(i>=0)l=this.getMonomerInfoTable(n[i]),c=`Monomer with symbol '${e.symbol}' already exists in library ${t}.\nAre you sure you want to overwrite it?`;else if((o??-1)>=0){const e=await Hn(this.getMonomersDataFrame().rows.get(o));l=this.getMonomerInfoTable(e),c=`Monomer with the same structure already exists in library ${t} with different symbol (${e.symbol}).\nAre you sure you want to duplicate it?`}if(l){const e=r.dialog("Save Monomer").add(r.divText(c)).add(l).addButton("Save",(()=>{e.close(),a()})).show()}else await a()}async saveMonomer(){let e=this.molSketcher.getSmiles();if(!e||!s.chem.checkSmiles(e))return void s.shell.warning("Invalid SMILES");e=Rn([],e);let t=s.chem.convert(e,a.chem.Notation.Smiles,a.chem.Notation.MolBlock);t=$n(t);const n={};this.metaGrid.items.filter((e=>!!e.Property&&!!e.Value)).forEach((e=>{n[e.Property]=e.Value}));const i=this.metaGrid.addingItem;i&&i.Property&&i.Value&&(n[i.Property]=i.Value),"#000000"===this.colorsEditor.colors.line&&"#000000"===this.colorsEditor.colors.background&&"#000000"===this.colorsEditor.colors.text||(n.colors={default:this.colorsEditor.colors});const o={symbol:this.monomerSymbolInput.value,name:this.monomerNameInput.value,molfile:t,smiles:e,polymerType:this.polymerTypeInput.value,monomerType:this.monomerTypeInput.value,naturalAnalog:this.monomerNaturalAnalogInput.value?this.monomerNaturalAnalogInput.value:void 0,id:this.monomerIdInput.value??0,rgroups:this.rgroupsGrid.items,author:a.User.current().friendlyName,createDate:(new Date).toISOString(),meta:n},r=this.getMonomerLib()?.source;r?await this.addMonomerToLib(o,r):s.shell.warning("Monomer library source is not specified")}}function Nn(e,t){let n=-1;for(let i=e.length-1;i>=0;i--)if(t(e[i])){n=i;break}return n}function Rn(e,t,n){const i=!t||!s.chem.checkSmiles(t);if(i&&!n)throw new Error("Both SMILES and MOL block are empty or malformed");let o=i?s.chem.convert(n,a.chem.Notation.Unknown,a.chem.Notation.Smiles):t;return o=function(e,t){let n=e;return t.forEach((e=>{const t=e.label[1]??"1",i=new RegExp(`\\[\\${e.capGroupName}:${t}\\]`,"g");n=n.replace(i,`[*:${t}]`)})),n=n.replaceAll(/\[\d[A-Z]{1,2}\]/g,(e=>`[*:${e[1]}]`)),n}(o,e),o=xn(o),i?o:s.chem.convert(o,a.chem.Notation.Unknown,a.chem.Notation.Smiles)}function $n(e){const t=e.split("\n"),n=t.findIndex((e=>e.startsWith("M")&&e.includes("ISO")));if(-1!==n){const e=t[n].indexOf("ISO");t[n]=t[n].substring(0,e)+"RGP"+t[n].substring(e+3)}const i=t.findIndex((e=>e.includes("V2000")));if(-1===i)return console.error("Mol start line not found"),e;const o=Number.parseInt(t[i].trim().split(" ")[0].slice(0,3).trim()),s={};for(let e=i+1;e<i+1+o;e++){const n=t[e].indexOf("R ");if(-1===n)continue;"#"!==t[e][n+1]&&(t[e]=t[e].replace("R ","R#"));const o=t[e].trim().split(" ").map((e=>e.trim())).filter(Boolean);if(s[e-i]=1,o.length<14)continue;const r=Number.parseInt(o[13]);Number.isNaN(r)||(s[e-i]=r)}const r=Object.keys(s);if(-1===t.findIndex((e=>e.startsWith("M")&&e.includes("RGP")))){const e=`M RGP${r.length.toString().padStart(3," ")}${Object.entries(s).map((([e,t])=>`${e.toString().padStart(4," ")}${t.toString().padStart(4," ")}`)).join("")}`,n=t.findIndex((e=>e.startsWith("M")&&e.includes("END")));t.splice(n,0,e)}return r.filter((e=>!!Number.parseInt(e))).map((e=>Number.parseInt(e)+i)).forEach((e=>{const n=t[e].split(" "),i=n.findIndex((e=>"R#"===e));if(-1!==i){for(let e=i+1;e<n.length;e++)n[e]&&1==n[e].length&&(Number.parseInt(n[e])??0)>0&&(n[e]="0");t[e]=n.join(" ")}})),t.join("\n")}function On(e,t){let n=e;return t.forEach((e=>{const t=e.label[1]??"1",i=_n(e,"capGroupName");n=n.replace(`[*:${t}]`,`[${i}]`)})),n}async function Hn(e){let t;try{t=JSON.parse(e.get(Cn.META)??"{}");for(const e in t)"object"==typeof t[e]&&(t[e]=JSON.stringify(t[e])),("string"!=typeof t[e]||t[e]!==a.INT_NULL.toString()&&t[e]!==a.FLOAT_NULL.toString())&&("number"!=typeof t[e]||t[e]!==a.INT_NULL&&t[e]!==a.FLOAT_NULL)||(t[e]=null)}catch(e){console.error(e)}const n=e.get(Cn.MONOMER);if(!n)throw new Error("Monomer SMILES is empty");let i="";try{i=s.chem.convert(n,a.chem.Notation.Smiles,a.chem.Notation.MolBlock),i=$n(i)}catch(e){s.shell.error(`Error converting SMILES to molfile, \n ${n}`),console.error(e)}let o=e.get(Cn.NATURAL_ANALOG);const r=e.get(Cn.POLYMER_TYPE);let l=[];try{if(l=JSON.parse(e.get(Cn.R_GROUPS)??"[]"),!o&&r){const e=await An(On(n,l),r);e&&(o=e)}}catch(e){l??=[]}return{symbol:e.get(Cn.SYMBOL),name:e.get(Cn.NAME),molfile:i,smiles:n,polymerType:r,monomerType:e.get(Cn.MONOMER_TYPE),naturalAnalog:o,id:e.get(Cn.ID),rgroups:l,meta:t,author:e.get(Cn.AUTHOR),createDate:e.get(Cn.CREATE_DATE)}}class kn{_colors;_colorInputs;constructor(e){this._colors=e,this._colorInputs={line:r.input.color("Line",{value:e.line,onValueChanged:e=>this._colors.line=e}),background:r.input.color("Background",{value:e.background,onValueChanged:e=>this._colors.background=e}),text:r.input.color("Text",{value:e.text,onValueChanged:e=>this._colors.text=e})}}get colors(){return this._colors}set colors(e){const t={line:a.Color.toHtml(a.Color.fromHtml(e.line??"#000000")),background:a.Color.toHtml(a.Color.fromHtml(e.background??"#000000")),text:a.Color.toHtml(a.Color.fromHtml(e.text??"#000000"))};this._colors=t;for(const e in this._colorInputs)this._colorInputs[e].value=t[e]}get colorsMetaFormat(){return{colors:{default:this._colors}}}get form(){return r.form(Object.values(this._colorInputs))}}class Fn{monomer;root=r.divV([],{classes:"monomer-card-root"});_selected=!1;get selected(){return this._selected}set selected(e){this._selected=e,this.root.style.border=e?"2px solid var(--green-2)":"2px solid var(--grey-2)"}constructor(e){this.monomer=e}render(){r.empty(this.root);const e=this.monomer.smiles&&s.chem.checkSmiles(this.monomer.smiles)?s.chem.drawMolecule(this.monomer.smiles,200,200):s.chem.drawMolecule(this.monomer.molfile??"",200,200);this.root.appendChild(e);const t=r.divH([r.divText("Monomer Name: "),r.divText(this.monomer.name)],{classes:"monomer-card-info-row"});if(this.root.appendChild(t),r.tooltip.bind(t,this.monomer.name),this.monomer.lib?.source){const e=r.divH([r.divText("Source: "),r.divText(this.monomer.lib.source)],{classes:"monomer-card-info-row"});this.root.appendChild(e),r.tooltip.bind(e,this.monomer.lib.source)}const n=r.divH([r.divText("Polymer Type: "),r.divText(this.monomer.polymerType)],{classes:"monomer-card-info-row"});this.root.appendChild(n),r.tooltip.bind(n,this.monomer.polymerType),r.tooltip.bind(this.root,"Select Monomer")}}class Dn{monomerSymbol;monomers;root=r.divH([],{style:{alignItems:"center",width:"100%",overflow:"hidden",visibility:"visible"},classes:"duplicate-monomer-symbol-row"});monomerCards;constructor(e,t,n,i){this.monomerSymbol=e,this.monomers=t,this.monomerCards=t.map((e=>new Fn(e)));const o=r.divH([],{style:{overflowX:"auto",width:"100%"}}),s=r.h1(e,{style:{lineHeight:"2em",fontSize:"1.5em",marginRight:"20px",width:"100px",overflow:"hidden",textOverflow:"elipsis"}});r.tooltip.bind(s,e),this.root.appendChild(s),this.root.appendChild(o),this.monomerCards.forEach((e=>{e.root.onclick=()=>{this.monomerCards.forEach((e=>e.selected=!1)),e.selected=!0,i(e.monomer)},n&&e.monomer===n&&(e.selected=!0),o.appendChild(e.root)}))}render(){this.monomerCards.forEach((e=>e.render()))}}class Gn{monomerCardRows=[];saveSettingsPromise=Promise.resolve();searchInput;_root;monomers;settings;filteredMonomerRows=[];static _instance;vv;static async getInstance(){return Gn._instance||(Gn._instance=new Gn,await Gn._instance.refresh(),(await dn.getInstance()).getMonomerLib().onChanged.subscribe((async()=>await Gn._instance.refresh()))),Gn._instance.refresh(),Gn._instance}async refresh(){this.settings=await(0,Ie.ub)();const e=await dn.getInstance();await e.awaitLoaded(),await e.loadLibrariesPromise,this.monomers=e.duplicateMonomers,this.monomerCardRows=[];for(const t in this.monomers)for(const n in this.monomers[t]){const i=this.settings.duplicateMonomerPreferences?.[t]?.[n]??null,o=i?this.monomers[t][n].find((e=>e.lib?.source===i))??null:null;this.monomerCardRows.push(new Dn(n,this.monomers[t][n],o,(async i=>{this.saveSettingsPromise=this.saveSettingsPromise.then((async()=>{i.lib?.source&&(this.settings.duplicateMonomerPreferences=this.settings.duplicateMonomerPreferences??{},this.settings.duplicateMonomerPreferences[t]=this.settings.duplicateMonomerPreferences[t]??{},this.settings.duplicateMonomerPreferences[t][n]=i.lib.source,await(0,Ie.Eu)(this.settings),e.assignDuplicatePreferances(this.settings),s.shell.info(`Monomer '${i.name}' from source '${i.lib.source}' selected for symbol '${n}'.`))}))})))}const t=r.divText("Set Default");if(t.addEventListener("click",(async()=>{if(0===Object.keys(this.monomers??{}).length)return void s.shell.info("No Duplicate Monomers found");const t=new Set;for(const e in this.monomers)for(const n in this.monomers[e])for(const i of this.monomers[e][n])i.lib?.source&&t.add(i.lib.source);if(0===t.size)return void s.shell.info("No Duplicate Monomers found");const n=Array.from(t),i=r.input.choice("Default Library",{items:n,nullable:!0});r.dialog("Set Default Monomer Source for Duplicates").add(i).onOK((async()=>{if(i.value){for(const e in this.monomers)for(const t in this.monomers[e]){const n=this.monomers[e][t];n?.some((e=>e.lib?.source===i.value))&&(this.settings.duplicateMonomerPreferences=this.settings.duplicateMonomerPreferences??{},this.settings.duplicateMonomerPreferences[e]=this.settings.duplicateMonomerPreferences[e]??{},this.settings.duplicateMonomerPreferences[e][t]=i.value)}await(0,Ie.Eu)(this.settings),e.assignDuplicatePreferances(this.settings),s.shell.info(`Default Monomer Source for Duplicates set to '${i.value}'.`),setTimeout((()=>this.refresh()),100)}else s.shell.info("No library selected")})).show()})),this.filteredMonomerRows=this.monomerCardRows,this.vv)this.vv.setData(this.filteredMonomerRows.length,(e=>(this.filteredMonomerRows[e].render(),this.filteredMonomerRows[e].root)));else{this.vv=r.virtualView(this.monomerCardRows.length,(e=>(this.monomerCardRows[e].render(),this.monomerCardRows[e].root))),this.vv.root.classList.add("duplicate-monomers-virtual-view"),this.searchInput=r.input.string("Search",{placeholder:"Monomer Symbol",value:"",onValueChanged:()=>e(this.searchInput.value)}),this.searchInput.root.style.justifyContent="center",this.searchInput.addOptions(t),this.searchInput.input.style.width="200px",this._root=r.divV([r.h1("Manage Duplicate Monomer Symbols",{style:{textAlign:"center"}}),this.searchInput.root,r.divV([this.vv.root],{style:{overflowY:"auto",height:"100%"}})],{style:{height:"100%"}});const e=e=>{this.filteredMonomerRows=this.monomerCardRows.filter((t=>t.monomerSymbol.toLowerCase().includes(e.toLowerCase()))),this.vv.setData(this.filteredMonomerRows.length,(e=>(this.filteredMonomerRows[e].render(),this.filteredMonomerRows[e].root)))}}}constructor(){}get root(){return this._root}}async function Bn(){await qn.showDialog()}async function Vn(e=!0){return await Yn.showView(e)}class Un{_fileManager;_widget;get widget(){return this._widget}constructor(){}static instancePromise;static async getInstance(){return void 0===Un.instancePromise&&(Un.instancePromise=(async()=>{const e=new Un,t=await(0,ye.pj)();return e._fileManager=await t.getFileManager(),e._widget=await e.createWidget(),e})()),Un.instancePromise}static async reloadWidget(){const e=await Un.getInstance();e._widget=await e.createWidget()}async createWidget(){const e=await this.getWidgetContent();return(await(0,ye.pj)()).eventManager.addLibraryFileRequested$.subscribe((()=>this.promptToAddLibraryFiles())),new a.Widget(e)}async getWidgetContent(){const e=await Wn.createControlsForm();return mn()(e).addClass("monomer-lib-controls-form"),setTimeout((()=>{e&&mn()(e)&&mn()(e).removeClass("ui-form-condensed")}),200),r.divV([e])}async promptToAddLibraryFiles(){a.Utils.openFile({accept:".json",open:async e=>{const t=await e.text(),n=e.name,i=a.TaskBarProgressIndicator.create(`Adding ${n} as a monomer library`);try{await this._fileManager.addLibraryFile(t,n)}catch(e){s.shell.error(`File ${n} is not a valid monomer library, verify it is aligned to HELM JSON schema.`)}finally{i.close()}}})}}class Wn{fileManager;userLibSettings;constructor(e,t){this.fileManager=e,this.userLibSettings=t,this.fileManager.eventManager.updateUIControlsRequested$.subscribe((()=>{this.updateControlsForm()})),this.fileManager.eventManager.librarySelectionRequested$.subscribe((([e,t])=>{this.updateLibrarySelectionStatus(t,e)}))}toLog(){return"LibraryControlsManager<#>"}static async createControlsForm(){ro.logger.debug("LibraryControlsForm.createControlsForm(), start");const[e,t]=await Promise.all([(0,ye.pj)().then((e=>e.getFileManager())),await(0,Ie.ub)()]);return new Wn(e,t)._createControlsForm()}_createControlsForm(){const e=this.createLibraryControls(),t=r.wideForm(e,void 0);return mn()(t).addClass("monomer-lib-controls-form"),t}updateControlsForm(){const e=this._createControlsForm();mn()(".monomer-lib-controls-form").replaceWith(e)}createLibraryControls(){return this.fileManager.getValidLibraryPaths().map((e=>this.createLibInput(e)))}createLibInput(e){const t=`${this.toLog()}.createLibInput()`;ro.logger.debug(`${t}, libFileName = '${e}', start`);const n=!this.userLibSettings.exclude.includes(e),i=r.input.bool(e,{value:n,onValueChanged:()=>{this.fileManager.eventManager.updateLibrarySelectionStatus(e,i.value)}});r.tooltip.bind(i.root,`Include monomers from ${e}`);const o=r.iconFA("trash-alt",(()=>this.promptForLibraryDeletion(e))),a=r.icons.edit((async()=>{s.shell.v=await(await Mn.getInstance()).getViewRoot(e)}),"Edit monomer library");return r.tooltip.bind(o,`Delete ${e}`),i.addOptions(a),i.addOptions(o),ro.logger.debug(`${t}, libFileName = '${e}', end`),i}async updateLibrarySelectionStatus(e,t){this.updateLibrarySettings(e,t),await(0,Ie.Eu)(this.userLibSettings);const n=await(0,ye.pj)();await n.loadMonomerLib(!0),s.shell.info("Monomer library user settings saved")}updateLibrarySettings(e,t){e?this.userLibSettings.exclude=this.userLibSettings.exclude.filter((e=>e!==t)):this.userLibSettings.exclude.includes(t)||this.userLibSettings.exclude.push(t)}promptForLibraryDeletion(e){r.dialog("Warning").add(r.divText(`Delete file ${e}?`)).onOK((async()=>{try{const t=a.TaskBarProgressIndicator.create(`Deleting ${e} library`);await this.updateLibrarySelectionStatus(!1,e),await this.fileManager.deleteLibraryFile(e),t.close()}catch(t){console.error(t),s.shell.error(`Failed to delete ${e} library`)}})).showModal(!1)}}class qn{constructor(){}static _instance;dialog;closeDialogSubject$=new u.Subject;static async showDialog(){qn._instance||(qn._instance=new qn,qn._instance.closeDialogSubject$.subscribe((()=>{qn._instance.dialog=void 0}))),qn._instance.dialog||(qn._instance.dialog=await qn._instance.getDialog()),qn._instance.dialog.show()}async getDialog(){const e=hn.getInstance(),t=(await Un.getInstance()).widget,n=r.dialog({title:"Manage monomer libraries",helpUrl:"/help/datagrok/solutions/domains/bio/bio.md#manage-monomer-libraries"});mn()(n.root).css("width","350px"),n.clear(),n.addButton("Add",(()=>e.addLibraryFile()),void 0,"Upload new HELM monomer library"),n.add(t);const i=n.onClose.subscribe((()=>{this.closeDialogSubject$.next(),i.unsubscribe()}));return n}}class Yn{constructor(){}static _instance;static viewName="Manage Monomer Libraries";_view;_duplicateManager;libManager;async getView(e=!0){const t=hn.getInstance(),n=(await Un.getInstance()).widget,i=r.bigButton("Add",(()=>t.addLibraryFile()),"Upload new HELM monomer library"),o=r.bigButton("Merge",(()=>{this.mergeSelectedLibs()}),"Merge selected libraries into one"),l=r.splitH([r.divV([n.root,r.buttonsInput([i,o])],{classes:"ui-form"}),this._duplicateManager.root],{style:{width:"100%",height:"100%"}},!0);if(this._view)try{this._view.subs.forEach((e=>e.unsubscribe())),this._view.detach(),this._view.close()}catch(e){}return this._view=a.View.fromRoot(l),this._view.name=Yn.viewName,e&&s.shell.addView(this._view),r.tools.waitForElementInDom(l).then((()=>{setTimeout((()=>{const e=Array.from(l.children).filter((e=>e.classList.contains("ui-box")));if(2!==e.length)return;const[t,n]=e,i=t.getBoundingClientRect().width+n.getBoundingClientRect().width,o=.3*i;t.style.width=`${o}px`;const s=i-o;n.style.width=`${s}px`}),100),this._view.subs.push(s.events.onCurrentViewChanged.subscribe((()=>{try{const e=Yn._instance;e&&e._view&&s.shell.v&&"id"in s.shell.v&&s.shell.v.id===e._view.id&&e._duplicateManager?.refresh()}catch(e){console.error(e)}})))})),this._view}static async showView(e=!0){return Yn._instance||(Yn._instance=new Yn),Yn._instance._duplicateManager||(Yn._instance._duplicateManager=await Gn.getInstance()),Yn._instance.libManager||(Yn._instance.libManager=await dn.getInstance()),e&&Yn._instance._view&&Array.from(s.shell.views).find((e=>e.id&&e.id===Yn._instance._view.id))?(s.shell.v=Yn._instance._view,await Yn._instance._duplicateManager.refresh(),Yn._instance._view):(Yn.closeExistingViews(),Yn._instance.getView(e))}static closeExistingViews(){Array.from(s.shell.views).filter((e=>e.name===Yn.viewName)).forEach((e=>e.close()))}async mergeSelectedLibs(){const e="Library with this name already exists",t=await dn.getInstance();if(await t.awaitLoaded(),await t.loadLibrariesPromise,!t.duplicatesHandled)return void s.shell.warning("Selected libraries contain repeating symbols with different monomers.\n Please choose the correct monomer for each symbol using duplicate monomomer manager.");const n=t.getBioLib().toJSON(),i=r.dialog("Merge selected libraries"),o=r.input.string("Library Name",{placeholder:"Enter new library name",nullable:!1,onValueChanged:()=>{const t=u(o.value);i.getButton("Download")?.classList?.toggle("d4-disabled",!!t&&t!==e),i.getButton("Save")?.classList?.toggle("d4-disabled",!!t)}}),l=(await this.libManager.getFileManager()).getValidLibraryPaths();function c(){let e=o.value;return e.endsWith(".json")||(e+=".json"),e}function u(t){return t&&t.trim()?t.endsWith(".json")&&l.includes(t)||l.includes(t+".json")?e:null:"Library name cannot be empty"}o.addValidator(u),i.add(o).add(r.divText(`Total monomers: ${n.length}`)).addButton("Download",(()=>{a.Utils.download(c(),JSON.stringify(n))})).addButton("Save",(async()=>{i.close();const e=c(),t=JSON.stringify(n),o=await this.libManager.getFileManager();this._view&&r.setUpdateIndicator(this._view.root,!0);try{await o.addLibraryFile(t,e,!1);const n=await(0,Ie.ub)();n.exclude=l,await(0,Ie.Eu)(n),await this.libManager.loadLibraries(!0),await Un.reloadWidget()}catch(t){s.shell.error(`Failed to save library ${e}. see console for details.`),console.error(t)}finally{this._view&&r.setUpdateIndicator(this._view.root,!1)}})).show(),i.getButton("Download")?.classList?.add("d4-disabled"),i.getButton("Save")?.classList?.add("d4-disabled")}}var jn,Kn=function(e,t,n,i){return new(n||(n=Promise))((function(o,s){function r(e){try{l(i.next(e))}catch(e){s(e)}}function a(e){try{l(i.throw(e))}catch(e){s(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,a)}l((i=i.apply(e,t||[])).next())}))};class zn{_setBreadcrumbsInViewName(){var e,t;const n=["Home","Demo",...(null!==(e=this._path)&&void 0!==e?e:"").split("/")],i=r.breadcrumbs(n);if(i.onPathClick.subscribe((e=>Kn(this,void 0,void 0,(function*(){const t=e[e.length-1];if(t===i.path[i.path.length-1])return;const n=s.shell.browsePanel.mainTree.getOrCreateGroup("Apps").getOrCreateGroup("Demo");n.currentItem="Demo"===t?n:n.items.find((e=>e.text===t))})))),s.shell.v){if(0!==i.path.length&&"Home"===i.path[0]){const e=r.iconFA("home",(()=>{s.shell.v.close(),s.shell.v=a.View.createByType(a.VIEW_TYPE.HOME)}));e.classList.add("demo-breadcrumbs-home-element"),i.root.firstElementChild.replaceWith(e)}const e=null===(t=s.shell.v.ribbonMenu.root.parentElement)||void 0===t?void 0:t.getElementsByClassName("d4-ribbon-name")[0];e&&(e.textContent="",e.appendChild(i.root))}}constructor(e,t,n=!1,i){var o,s;this.name="",this.description="",this._isAutomatic=!1,this._autoStartFirstStep=!1,this._currentStep=0,this._isStopped=!1,this._isCancelled=!1,this._isStepProcessed=!1,this._root=r.div([],{id:"demo-script",classes:"tutorials-root tutorials-track demo-app-script"}),this._steps=[],this._mainHeader=r.panel([],"tutorials-main-header"),this._header=r.h2(""),this._headerDiv=r.divH([],"tutorials-root-header"),this._stopStartBtn=r.button(r.iconFA("pause"),(()=>Kn(this,void 0,void 0,(function*(){return yield this._changeStopState()}))),"Play / pause"),this._restartBtn=r.button(r.iconFA("redo"),(()=>Kn(this,void 0,void 0,(function*(){return yield this._restartScript()}))),"Restart"),this._nextStepBtn=r.button(r.iconFA("play"),(()=>Kn(this,void 0,void 0,(function*(){this._isStepProcessed||(yield this._nextStep())}))),"Next step"),this._activity=r.panel([],"tutorials-root-description"),this._progressDiv=r.divV([],"tutorials-root-progress"),this._progress=r.element("progress"),this._progressSteps=r.divText(""),this._closeBtn=r.button(r.iconFA("chevron-left"),(()=>this._closeDock()),"Back to demo"),this.DEMO_PATH="apps/Tutorials/Demo",this.name=e,this.description=t,this._isAutomatic=n,this._autoStartFirstStep=null!==(o=null==i?void 0:i.autoStartFirstStep)&&void 0!==o&&o,this._path=null!==(s=null==i?void 0:i.path)&&void 0!==s?s:"",this._progress.max=0,this._progress.value=1,zn.currentObject=this}get steps(){return this._steps}get stepNumber(){return this._steps.length}_addHeader(){this._createHeaderDiv(),this._createProgressDiv(),this._mainHeader.append(this._headerDiv,this._progressDiv)}_createHeaderDiv(){this._header.innerText=this.name,this._headerDiv.append(this._closeBtn),this._headerDiv.append(this._header),this._nextStepBtn.firstChild.className="grok-icon fas fa-play",this._headerDiv.append(this._isAutomatic?this._stopStartBtn:this._nextStepBtn)}_createProgressDiv(){this._progress.max=this.stepNumber,this._progressDiv.append(this._progress),this._progressSteps=r.divText(`Step: ${this._progress.value} of ${this.stepNumber}`),this._progressDiv.append(this._progressSteps)}_addDescription(){var e;this._activity.append(r.div(this.description,"tutorials-root-description"));for(let t=0;t<this.stepNumber;t++){let n=r.iconFA("clock");this._isAutomatic||0===t&&(n=r.iconFA("play",(()=>this._nextStep()),"Next step"),n.className="grok-icon fas fa-play");const i=r.div(this._steps[t].name,"grok-tutorial-entry-instruction"),o=r.div(null===(e=this._steps[t].options)||void 0===e?void 0:e.description,"grok-tutorial-step-description hidden"),s=r.divH([n,i],"grok-tutorial-entry");this._activity.append(s,o)}}_initRoot(){s.shell.windows.showContextPanel=!0,s.shell.windows.showHelp=!1,this._node=s.shell.dockManager.dock(this._root,a.DOCK_TYPE.FILL,s.shell.dockManager.findNode(s.shell.browsePanel.root),this.name),this._node.container.containerElement.classList.add("tutorials-demo-script-container"),this._addHeader(),this._root.append(this._mainHeader),this._addDescription(),this._root.append(this._activity)}_setViewParams(){var e;s.shell.v&&(s.shell.v.name=this.name,s.shell.v.path=`${this.DEMO_PATH}/${(null!==(e=this._path)&&void 0!==e?e:"").replaceAll(" ","-")}`,this._setBreadcrumbsInViewName())}_nextStep(){return Kn(this,void 0,void 0,(function*(){var e,t;this._isStepProcessed=!0,this._isAutomatic||(this._nextStepBtn.classList.add("disabled"),this._nextStepBtn.firstChild.classList.add("fa-disabled"));const n=this._activity.getElementsByClassName("grok-tutorial-entry")[this._currentStep],i=this._activity.getElementsByClassName("grok-icon")[this._currentStep],o=this._activity.getElementsByClassName("grok-tutorial-step-description")[this._currentStep];i.className="grok-icon far fa-spinner-third fa-spin",o.classList.remove("hidden"),o.classList.add("visible");const l=n,c=(null===(e=this._steps[this._currentStep].options)||void 0===e?void 0:e.delay)?null===(t=this._steps[this._currentStep].options)||void 0===t?void 0:t.delay:2e3;try{this._setViewParams(),yield this._steps[this._currentStep].func(),this._setViewParams()}catch(e){console.error(e)}this._scrollTo(this._root,l.offsetTop-this._mainHeader.offsetHeight),this._isAutomatic&&(yield this._countdown(n,i,c),yield(0,Qe.cb)(c));const u=r.iconFA("check");if(i.replaceWith(u),u.className="grok-icon far fa-check",this._progress.value++,this._progressSteps.innerText=`Step: ${this._progress.value} of ${this.stepNumber}`,this._currentStep++,this._isStepProcessed=!1,this._currentStep!==this.stepNumber){if(!this._isAutomatic){const e=this._activity.getElementsByClassName("grok-icon")[this._currentStep],t=r.iconFA("play",(()=>this._nextStep()),"Next step");t.className="grok-icon fas fa-play",e.replaceWith(t),this._nextStepBtn.classList.remove("disabled"),this._nextStepBtn.firstChild.classList.remove("fa-disabled")}s.shell.v instanceof a.TableView&&(yield s.data.detectSemanticTypes(s.shell.tv.dataFrame))}else this._isAutomatic?this._stopStartBtn.replaceWith(this._restartBtn):this._nextStepBtn.replaceWith(this._restartBtn)}))}_startScript(){return Kn(this,void 0,void 0,(function*(){for(let e=this._currentStep;e<this.stepNumber&&!this._isStopped&&!this._isCancelled;e++)yield this._nextStep()}))}_scrollTo(e,t){e.focus(),e.scrollTop=t}_countdown(e,t,n){return Kn(this,void 0,void 0,(function*(){const i=r.div([],"demo-script-countdown");t.classList.add("hidden");let o=n/1e3;const s=this._createSVGIndicator(o);i.append(s),e.prepend(i);const a=setInterval((()=>{o--,0===o&&(clearInterval(a),i.remove(),t.classList.remove("hidden"),t.classList.add("visible"))}),1e3)}))}_createSVGIndicator(e){const t=document.createElementNS("http://www.w3.org/2000/svg","svg"),n=document.createElementNS("http://www.w3.org/2000/svg","circle");return n.setAttributeNS(null,"cx","7"),n.setAttributeNS(null,"cy","7"),n.setAttributeNS(null,"r","6"),n.setAttributeNS(null,"style",`animation: countdown ${e}s linear infinite forwards`),t.append(n),t}_changeStopState(){return Kn(this,void 0,void 0,(function*(){const e=this._stopStartBtn.getElementsByClassName("grok-icon");e[0].className="grok-icon fas fa-play",this._isStopped=!this._isStopped,this._isStopped||(e[0].className="grok-icon fal fa-pause",this._isStepProcessed||(yield this._startScript()))}))}_restartScript(){return Kn(this,void 0,void 0,(function*(){s.shell.dockManager.close(this._node),this._clearRoot(),this._setInitParams(),yield this.start()}))}_clearRoot(){this._root=r.div([],{id:"demo-script",classes:"tutorials-root tutorials-track demo-app-script"}),this._mainHeader=r.panel([],"tutorials-main-header"),this._header=r.h2(""),this._headerDiv=r.divH([],"tutorials-root-header"),this._activity=r.panel([],"tutorials-root-description"),this._progressDiv=r.divV([],"tutorials-root-progress"),this._progress=r.element("progress"),this._progressSteps=r.divText(""),this._progress.max=0,this._progress.value=1}_setInitParams(){this._currentStep=0,this._isStopped=!1,this._isCancelled=!1,this._stopStartBtn.getElementsByClassName("grok-icon")[0].className="grok-icon fal fa-pause",this._nextStepBtn.classList.remove("disabled")}_closeDock(){s.shell.dockManager.close(this._node),this.cancelScript()}cancelScript(){this._isCancelled=!0,zn.currentObject=null}step(e,t,n){return this._steps[this.steps.length]={name:e,func:t,options:n},this}start(){return Kn(this,void 0,void 0,(function*(){this._initRoot(),s.shell.v.name===this.name&&(s.shell.v.close(),this._node=s.shell.dockManager.dock(this._root,a.DOCK_TYPE.FILL,s.shell.dockManager.findNode(s.shell.browsePanel.root),this.name)),this._isAutomatic?yield this._startScript():this._autoStartFirstStep&&(yield this._nextStep())}))}}zn.currentObject=null,function(e){e.X="Embed_X",e.Y="Embed_Y"}(jn||(jn={}));var Zn=n(966),Xn=n(608),Jn=n(1619);class Qn{urlParams;funcName;options;df;view;constructor(e,t,n={}){this.urlParams=e,this.funcName=t,this.options=n}async init(e){this.df=e,await this.buildView()}async buildView(){const e=R()(this.urlParams.entries()).map((([e,t])=>`${e}=${encodeURIComponent(t)}`)).toArray().join("&");this.view=s.shell.addTableView(this.df),this.view.path=this.view.basePath=`func/${ro.name}.${this.funcName}?${e}`;const t={...this.options,sequenceColumnName:"sequence"};for(const[e,n]of this.urlParams.entries())switch(e){case it.n5.fixWidth:case it.n5.fitArea:t[e]=["1","on","true"].includes(n.toLowerCase());break;default:t[e]=n}const n=await this.view.dataFrame.plot.fromType("WebLogo",t);this.view.dockManager.dock(n,a.DOCK_TYPE.DOWN,null,"WebLogo",.35)}}class ei{tableInput;seqColInput;funcParamsDiv;get funcParams(){return{table:this.tableInput.value,sequence:this.seqColInput.value}}get paramsUI(){return this.funcParamsDiv}constructor(){this.tableInput=r.input.table("Table",{value:s.shell.tv.dataFrame,onValueChanged:()=>{this.onTableInputChanged()}});const e=this.tableInput.value.columns.bySemType(a.SEMTYPE.MACROMOLECULE);this.seqColInput=r.input.column("Sequence",{table:this.tableInput.value,value:e,filter:e=>e.semType===a.SEMTYPE.MACROMOLECULE}),this.funcParamsDiv=r.inputs([this.tableInput,this.seqColInput],{style:{minWidth:"320px"}})}onTableInputChanged(){this.seqColInput=r.input.column("Sequence",{table:this.tableInput.value,value:this.tableInput.value.columns.bySemType(a.SEMTYPE.MACROMOLECULE)})}}var ti=n(6869);new class{tooltipHandlerTemp="tooltip-handler.Monomer"};const ni="-";class ii extends Be{constructor(e,t){super(e,t)}render(e,t,n,i,o,s,r){e.save(),e.beginPath(),e.rect(t,n,i,o),e.clip();try{if(!s.isTableCell)return;const r=s.cell?.column&&s.cell.column?.dart&&"true"===s.cell.column.getTag(Re.Mn.applyToBackground);e.font="12px monospace",e.textBaseline="middle",e.textAlign="left";let a=s.cell.value;a&&a!==we._S||(a=ni);const l=a.split(we.ot).map((e=>e&&e!==we._S?e.trim():ni)),c=l.map((e=>(0,ge.zS)(e,Math.max(2,Math.floor(.15*i/l.length))))),u=c.map((t=>e.measureText(t).width)),h=u.reduce(((e,t)=>e+t),0);let d=t+(i-h)/2;const p=this.tableCol.getTag(we.gp.alphabet),m=p===ge.YI.RNA||p===ge.YI.DNA?ti.o.NUCLEOTIDE:ti.o.AA;for(let s=0;s<c.length;s++){const a=l[s];let h=$e.S$,p="rgb(255, 255, 255)";if(this.monomerLib)if(r){const e=this.monomerLib.getMonomerColors(m,a);h=e?.textcolor??h,p=e?.backgroundcolor??p}else h=this.monomerLib.getMonomerTextColor(m,a);r&&1==l.length&&(e.fillStyle=p,e.fillRect(t,n,i,o)),e.fillStyle=h,e.fillText(c[s],d,n+o/2,i),d+=u[s]}}finally{e.restore()}}onMouseMove(e,t){if(e.grid.dart!=this.gridCol?.grid.dart||e.gridColumn.dart!=this.gridCol?.dart||!e.tableColumn||!e.isTableCell)return!1;const n=e.tableColumn.getTag(we.gp.alphabet),i=e.cell.value,o=e.grid.canvas.getBoundingClientRect(),s=e.bounds.right+o.left-4,a=e.bounds.bottom+o.top-4;if(!i||i==we._S||i==ni)return r.tooltip.show(r.divText("gap"),s,a),!0;if(!this.monomerLib)return r.tooltip.show(r.divText("Monomer library is not available."),s,a),!0;const l=n===ge.YI.RNA||n===ge.YI.DNA?ti.o.NUCLEOTIDE:ti.o.AA,c=i.split(we.ot).map((e=>e&&e!==we._S&&e!==ni?this.monomerLib.getTooltip(l,e):r.divText("gap"))),u=r.divH(c,{style:{alignItems:"top"}}),h=Array.from(u.querySelectorAll("canvas"));if(h.length>2){const e=Math.floor(550/h.length);h.forEach((t=>{t.style.setProperty("max-width",`${e}px`,"important"),t.style.setProperty("max-height",`${e}px`,"important")}))}return r.tooltip.show(u,s,a),!0}async awaitRendered(e=1e4,t=`${e} timeout`){return Promise.resolve()}static getOrCreate(e){const[t,n,i]=(0,ke.BG)(e);let o=i.rendererBack;return o||(o=i.rendererBack=new ii(t,n)),o}}class oi extends a.GridCellRenderer{get name(){return Ve.uF.MONOMER}get cellType(){return Ve.uF.MONOMER}get defaultHeight(){return 15}get defaultWidth(){return 40}render(e,t,n,i,o,s,r){ii.getOrCreate(s).render(e,t,n,i,o,s,r)}onMouseMove(e,t){ii.getOrCreate(e).onMouseMove(e,t)}}class si{constructor(e,t,n=""){this.target=e,this.debugEnabled=t,this.prefix=n}error(e,t,n){return this.target.error(this.prefix+e,t,n)}warning(e,t){return this.target.warning(this.prefix+e,t)}info(e,t){return this.target.info(this.prefix+e,t)}debug(e,t){if(this.debugEnabled)return this.target.debug(this.prefix+e,t)}}class ri extends Map{_onPropertyChanged=new u.Subject;get onPropertyChanged(){return this._onPropertyChanged}get fontSize(){const e=super.get("FontSize");return e&&!isNaN(e)?Number.parseInt(e):12}set fontSize(e){super.set("FontSize",e),this._onPropertyChanged.next("FontSize")}get maxMonomerLength(){const e=super.get("MaxMonomerLength");return"long"===e?null:parseInt(e)}set maxMonomerLength(e){const t=null===e?"long":e.toString();super.set("MaxMonomerLength",t),this._onPropertyChanged.next("MaxMonomerLength")}get tooltipWebLogo(){return super.get("TooltipWebLogo")}set tooltipWebLogo(e){super.set("TooltipWebLogo",e),this._onPropertyChanged.next("TooltipWebLogo")}get defaultSeparator(){return super.get("DefaultSeparator")}set defaultSeparator(e){if(1!==e.length)throw new Error("The separator must be of length one.");super.set("DefaultSeparator",e),this._onPropertyChanged.next("DefaultSeparator")}constructor(e){super(Object.entries(e))}}class ai extends a.Package{_properties;_seqHelper;get seqHelper(){if(!this._seqHelper)throw new Error("Package Bio .seqHelper is not initialized.");return this._seqHelper}_monomerLib;get monomerLib(){if(!this._monomerLib)throw new Error("Package Bio .monomerLib is not initialized.");return this._monomerLib}_monomerSets;get monomerSets(){if(!this._monomerSets)throw new Error("Package Bio .monomerSets is not initialized.");return this._monomerSets}_rdKitModule;get rdKitModule(){if(!this._rdKitModule)throw new Error("Package Bio .rdKitModule is not initialized.");return this._rdKitModule}get properties(){return this._properties}set properties(e){this._properties=e}_initialized=!1;get initialized(){return this._initialized}constructor(e={debug:!1}){super(),super._logger=new si(super.logger,e.debug)}completeInit(e,t,n,i){this._seqHelper=e,this._monomerLib=t,this._monomerSets=n,this._rdKitModule=i,this._initialized=!0}handleErrorUI(e){const[t,n]=(0,ve.AP)(e);s.shell.error(t),this.logger.error(t,void 0,n)}}var li=n(5999),ci={};ci.styleTagTransform=C(),ci.setAttributes=b(),ci.insert=f().bind(null,"head"),ci.domAPI=m(),ci.insertStyleElement=v(),d()(li.A,ci),li.A&&li.A.locals&&li.A.locals;var ui=n(6307);class hi extends a.Widget{seqCol;seqHelper;viewed=!1;wlViewer=null;constructor(e,t){super(r.divV([])),this.seqCol=e,this.seqHelper=t}async init(){const e=this.seqHelper.getSeqHandler(this.seqCol),t=ro.properties.tooltipWebLogo,n=this.seqCol.getTag(et.gp.tooltipWebLogo);!1===t||["false","off","disable","disabled"].includes(n)||(this.wlViewer=await this.seqCol.dataFrame.plot.fromType("WebLogo",{sequenceColumnName:this.seqCol.name,backgroundColor:0,positionHeight:"Entropy",positionWidth:e.getAlphabetIsMultichar()?24:16,fixWidth:!0,fitArea:!1,positionNames:"",endPositionName:"50"}),this.wlViewer.root.style.height="50px",this.root.appendChild(this.wlViewer.root),this.root.style.width="100%")}detach(){this.wlViewer&&(this.wlViewer.detach(),this.wlViewer=null),super.detach()}}function di(e,t,n,i){const o=ro.seqHelper.getSeqHandler(e);let s=null,r=null;for(let e=0;e<o.posList.length;++e)o.posList[e]==t&&(s=e),o.posList[e]==n&&(r=e);if(null===s&&null!==t)throw new Error(`Start position ${t} not found.`);if(null===r&&null!==n)throw new Error(`End position ${n} not found.`);if(o.posList.length<r)throw new Error(`End position ${r} exceeds positions length`);const a=i||`${e.name}: (${t??""}-${n??""})`;return o.getRegion(s,r,a)}const pi={df:a.DataFrame.fromCsv("seq,value\nATCCGTCGT,0.5\nTGTTCGTCA,0.4\nATGGTCGTA,0.7\nATCCGTGCA,0.1"),colName:"seq",positionNames:["1","1A","1C","2","4","4A","4B","5","6"].join(ge.z1),regions:[{name:"first region",start:"1",end:"2"},{name:"second region",start:"1C",end:"4"},{name:"overlapping second",start:"1C",end:"4A"},{name:"whole sequence",start:"1",end:"6"},{name:"bad start",start:"0",end:"6"},{name:"bad end",start:"1",end:"4C"},{name:"bad start & end",start:"0",end:"4C"}]};class mi{urlParams;funcName;view;data;constructor(e,t){this.urlParams=e,this.funcName=t}async init(e){this.data=e??pi;const t=this.data.df.getCol(this.data.colName);this.data.positionNames&&t.setTag(ge.gp.positionNames,this.data.positionNames),this.data.regions&&t.setTag(ge.gp.regions,JSON.stringify(this.data.regions)),await this.buildView()}async buildView(){await s.data.detectSemanticTypes(this.data.df),this.view=s.shell.addTableView(this.data.df),this.view.path=this.view.basePath=`func/${ro.name}.${this.funcName}`;const e=await this.view.dataFrame.plot.fromType("WebLogo",{sequenceColumnName:this.data.colName});this.view.dockManager.dock(e,a.DOCK_TYPE.DOWN,null,"WebLogo",.35)}}class gi{call;seqHelper;inputs=new class{table;sequence;region;start;end;name};constructor(e,t){this.call=e,this.seqHelper=t;const n=e=>this.call.inputParams[e].property.description;this.inputs.table=r.input.table("Table",{value:this.call.inputParams.table.value??s.shell.tv.dataFrame});const i=this.call.inputParams.sequence.value??this.inputs.table.value.columns.bySemType(a.SEMTYPE.MACROMOLECULE);this.inputs.sequence=r.input.column("Sequence",{table:s.shell.tv.dataFrame,value:i,onValueChanged:this.sequenceInputChanged.bind(this),filter:e=>e.semType===a.SEMTYPE.MACROMOLECULE}),this.inputs.start=r.input.choice("Start",{onValueChanged:this.startInputChanged.bind(this)}),this.inputs.end=r.input.choice("End",{onValueChanged:this.endInputChanged.bind(this)}),this.inputs.region=r.input.choice("Region",{value:null,items:[],onValueChanged:this.regionInputChanged.bind(this)}),this.inputs.name=r.input.string("Column name",{value:this.getDefaultName(),onValueChanged:this.nameInputChanged.bind(this),clearIcon:!0}),this.inputs.name.onInput.subscribe((()=>this.nameInputInput.bind(this)));for(const e in this.call.inputParams)r.tooltip.bind(this.inputs[e].captionLabel,n(e));this.sequenceInputChanged()}sequenceInputChanged(){const e=this.inputs.sequence.value;e&&this.seqHelper.getSeqHandler(e),this.updateRegionItems(),this.updateStartEndInputItems(),this.updateRegion(!0),this.updateNameInput()}fixRegion=!1;regionInputChanged(){this.fixRegion=!0;try{const e=this.inputs.region.stringValue,t=e?JSON.parse(e):null;if(null!==t)this.inputs.start.value=t?.start,this.inputs.end.value=t?.end;else{const e=this.seqHelper.getSeqHandler(this.inputs.sequence.value);this.inputs.start.value=e.posList[0],this.inputs.end.value=e.posList[e.posList.length-1]}}finally{this.fixRegion=!1}}startInputChanged(){this.updateRegion(!1),this.updateNameInput()}endInputChanged(){this.updateRegion(!1),this.updateNameInput()}nameInputChanged(){this.defaultNameUpdating||(this.defaultName=!1)}nameInputInput(){this.inputs.name.value||(this.defaultName=!0,this.inputs.name.input.focus())}updateStartEndInputItems(){const e=this.inputs.sequence.value,t=e?this.seqHelper.getSeqHandler(e):null,n=this.inputs.start.input,i=this.inputs.end.input;for(let e=n.options.length-1;e>=0;--e)n.options.remove(e);for(let e=i.options.length-1;e>=0;--e)i.options.remove(e);for(const e of t?.posList??[]){const t=document.createElement("option"),o=document.createElement("option");t.text=o.text=e,t.value=o.value=e,n.options.add(t),i.options.add(o)}n.value=t?.posList[0]??"",i.value=t?.posList[t?.posList.length-1]??""}updateRegionItems(){const e=this.inputs.sequence.value,t=e?e.getTag(ge.gp.regions):null,n=t?JSON.parse(t):null,i=this.inputs.region.input;for(let e=i.options.length-1;e>=0;--e)i.options.remove(e);const o=document.createElement("option");if(o.text="",o.value=JSON.stringify(null),i.options.add(o),null!=n){this.inputs.region.root.style.removeProperty("display");for(const e of n){const t=document.createElement("option");t.text=`${e.name}: ${e.start}-${e.end}`,t.value=JSON.stringify(e),i.options.add(t)}}else this.inputs.region.root.style.display="none"}updateRegion(e){const t=this.inputs.start.stringValue??"",n=this.inputs.end.stringValue??"";if(!this.fixRegion){const e=this.inputs.region.input;e.selectedIndex=-1;for(let i=e.options.length-1;i>=0;--i){const o=e.options[i],s=JSON.parse(o.value);s&&t===s.start&&n===s.end&&(e.selectedIndex=i)}}}defaultName=!0;defaultNameUpdating=!1;updateNameInput(){this.defaultNameUpdating=!0;try{this.defaultName&&(this.inputs.name.value=this.getDefaultName())}finally{this.defaultNameUpdating=!1}}getDefaultName(){const e=this.inputs.region.stringValue,t=e?JSON.parse(e):null,n=this.inputs.sequence.value,i=this.inputs.start.stringValue??"",o=this.inputs.end.stringValue??"";return null!=t?`${n.name}(${t.name}): ${t.start}-${t.end}`:`${n?.name}: (${i}-${o})`}getParams(){return{table:this.inputs.table.value,sequence:this.inputs.sequence.value,start:this.getStart(),end:this.getEnd(),name:this.getName()}}getStart(){return this.inputs.start.stringValue}getEnd(){return this.inputs.end.stringValue}getName(){const e=this.inputs.name.stringValue;return""==e?null:e}dialog(){const e=r.inputs(Object.values(this.inputs),{style:{minWidth:"320px"}});r.dialog({title:"Get Region"}).add(e).onOK((()=>{(async()=>{const e=this.getParams();await this.call.func.prepare(e).call(!0)})().catch((e=>{ro.handleErrorUI(e)}))})).show()}widget(){const e=r.inputs(Object.entries(this.inputs).filter((([e,t])=>!["table","sequence"].includes(e))).map((([e,t])=>t))),t=r.button("Get Region",(()=>{(async()=>{const e=this.getParams();await this.call.func.prepare(e).call(!0)})().catch((e=>{ro.handleErrorUI(e)}))}));return a.Widget.fromRoot(r.divV([e,r.div(t)]))}}var fi=n(8754);async function yi(e,t,n,i,o){const s=await async function(e,t,n,i,o){const s=(0,be.R)(t,o),r=o.getSeqHandler(t).getNewColumnFromList("ref",[n]),l=o.getSeqHandler(r).getSplitted(0),c=i===pe.IDENTITY?function(e,t){const n=t.columns.length,i=new Array(n),o=new Array(n),s=new Array(n);for(let r=0;r<n;++r){const n=t.columns.byIndex(r);i[r]=n.getRawData(),o[r]=n.categories.indexOf("");const a=r<e.length?e.getOriginal(r):we._S;s[r]=n.categories.indexOf(a)}const r=a.Column.float("Identity",t.rowCount),l=r.getRawData();for(let n=0;n<t.rowCount;++n){l[n]=0;for(let t=0;t<e.length;++t)(i[t]?i[t][n]:0)===s[t]&&++l[n];l[n]/=e.length}return r}(l,s):i===pe.SIMILARITY?await async function(e,t,n){const i=t.columns.toList();return await(0,ye.uL)(i,e,n)}(l,s,o):null;if(null===c)throw new Error(`In bio library: Unknown sequence scoring method: ${i}`);return c.name=e.columns.getUnusedName(c.name),e.columns.add(c),c}(e,t,n,i,o);for(let e=0;e<s.length;e++)t.isNone(e)&&s.set(e,null,!1);return s}var bi=n(294),wi=n(330);const vi=OCL;var Ai=n(2582);class Ci{monomerSymbol;constructor(e){this.monomerSymbol=e}atoms;bonds;rGroups;get atomCount(){return this.atoms.count}get bondCount(){return this.bonds.count}shiftR1GroupToOrigin(){const e=this.rGroups.getAtomicIdx(1);if(null===e)return;const{x:t,y:n}=this.atoms.atomCoordinates[e];this.atoms.shift({x:-t,y:-n})}alignR2AlongX(){const e=this.rGroups.getAtomicIdx(2);if(null===e)throw new Error(`Cannot find R2 group for monomer ${this.monomerSymbol}`);const t=this.atoms.atomCoordinates[e],n=t.y/t.x,i=Math.atan(n);if(isNaN(i))throw new Error(`Cannot calculate angle for R2 group for monomer ${this.monomerSymbol}`);this.rotateCoordinates(-i)}shiftMonomerToDefaultPosition(){this.shiftR1GroupToOrigin(),null!==this.rGroups.getAtomicIdx(2)&&this.alignR2AlongX()}deleteBondLineWithSpecifiedRGroup(e){this.rGroups.deleteBondLineWithSpecifiedRGroup(e)}shiftCoordinates(e){this.atoms.shift(e)}rotateCoordinates(e){this.atoms.rotate(e)}getBondLines(){return this.bonds.getBondLines()}getAtomLines(){return this.atoms.atomLines}removeRGroups(e){this.rGroups.removeRGroups(e)}replaceRGroupWithAttachmentAtom(e,t){this.rGroups.replaceRGroupWithAttachmentAtom(e,t)}getAttachmentAtomByRGroupId(e){return this.rGroups.getAttachmentAtomIdByRGroupId(e)}shiftBonds(e){this.bonds.shift(e)}capRGroups(e){this.rGroups.capRGroups(e)}}var Ti=n(6956);class Si{atoms;bonds;constructor(e,t,n){this.atoms=t,this.bonds=n,this.rGroupIdToAtomicIndexMap=e.getRGroupIdToAtomicIdxMap()}rGroupIdToAtomicIndexMap;rGroupBondPositionMap=new Map;getAtomicIdx(e){const t=this.rGroupIdToAtomicIndexMap.get(e);return void 0===t?null:t}removeRGroupsFromAtomBlock(e){e.forEach((e=>{if(void 0===this.rGroupIdToAtomicIndexMap.get(e))throw new Error(`Cannot find atomic index for R group ${e}`)}));const t=Array.from(this.rGroupIdToAtomicIndexMap.entries()).filter((([t,n])=>e.includes(t))).map((([e,t])=>t));this.atoms.deleteAtoms(t)}removeRGroups(e){this.removeRGroupsFromAtomBlock(e),e.forEach((e=>{const t=this.replaceRGroupInBondsByDummy(e);this.rGroupBondPositionMap.set(e,t)}))}replaceRGroupInBondsByDummy(e){const t=this.rGroupIdToAtomicIndexMap.get(e);if(this.rGroupBondPositionMap.has(e))throw new Error(`R group ${e} is already handled`);const n=this.bonds.getPositionsInBonds(t+1);if(0===n.length)throw new Error(`Cannot find position for R group ${e}`);if(n.length>1)throw new Error(`More than one position for R group ${e}`);const i=n[0];return this.bonds.replacePositionsInBondsByDummy([i]),this.bonds.removeAtomIdFromBonds(t+1),this.removeRGroupFromAtomicIdxMap(e,t),i}removeRGroupFromAtomicIdxMap(e,t){this.rGroupIdToAtomicIndexMap.delete(e);for(const[e,n]of this.rGroupIdToAtomicIndexMap)n>t&&this.rGroupIdToAtomicIndexMap.set(e,n-1)}deleteBondLineWithSpecifiedRGroup(e){const t=this.rGroupBondPositionMap.get(e);if(!t)throw new Error(`Cannot find position for R group ${e}`);const{bondLineIdx:n}=t;this.bonds.deleteBondLines([n]),this.rGroupBondPositionMap.delete(e),this.rGroupIdToAtomicIndexMap.delete(e),this.rGroupBondPositionMap.forEach((e=>{e.bondLineIdx>n&&(e.bondLineIdx-=1)}))}replaceRGroupWithAttachmentAtom(e,t){const n=this.rGroupBondPositionMap.get(e);if(!n)throw new Error(`Cannot find position for R group ${e}`);const{bondLineIdx:i,nodeIdx:o}=n;this.bonds.bondedAtoms[i][o]=t}getAttachmentAtomIdByRGroupId(e){const t=this.rGroupBondPositionMap.get(e);if(!t)throw new Error(`Cannot find position for R group ${e}`);const{bondLineIdx:n,nodeIdx:i}=t;return this.bonds.bondedAtoms[n][(i+1)%2]}capRGroups(e){this.rGroupIdToAtomicIndexMap.forEach(((t,n)=>{const i=e[n-1];i===Ti.mP?(this.removeRGroups([n]),this.deleteBondLineWithSpecifiedRGroup(n)):this.atoms.replaceRGroupSymbolByElement(t,i)}))}}class Ei{coordinates=[];rawAtomLines=[];get count(){return this.coordinates.length}get atomCoordinates(){return this.coordinates}replaceRGroupSymbolByElement(e,t){this.rawAtomLines[e]=this.rawAtomLines[e].replace("R#",t)}deleteAtoms(e){this.coordinates=this.coordinates.filter(((t,n)=>!e.includes(n))),this.rawAtomLines=this.rawAtomLines.filter(((t,n)=>!e.includes(n)))}shift(e){this.coordinates=this.coordinates.map((t=>{const n=t.x+e.x,i=t.y+e.y;if(isNaN(n)||isNaN(i))throw new Error(`Cannot shift coordinates by ${e.x}, ${e.y}`);return{x:n,y:i}}))}rotate(e){this.coordinates=this.coordinates.map((t=>{const n=t.x,i=t.y,o=n*Math.cos(e)-i*Math.sin(e),s=n*Math.sin(e)+i*Math.cos(e);if(isNaN(o)||isNaN(s))throw new Error(`Cannot rotate coordinates by ${e}`);return{x:o,y:s}}))}}class Mi extends Ei{constructor(e){super(),this.rawAtomLines=e.getAtomLines(),this.coordinates=this.rawAtomLines.map((e=>({x:parseFloat(e.substring(0,10)),y:parseFloat(e.substring(10,20))})))}get atomLines(){return this.rawAtomLines.map(((e,t)=>{const n=this.coordinates[t];return`${n.x.toFixed(4).padStart(10," ")}${n.y.toFixed(4).padStart(10," ")}${e.substring(20)}`}))}}class xi{bondedAtomPairs=[];rawBondLines=[];get count(){return this.bondedAtomPairs.length}get bondedAtoms(){return this.bondedAtomPairs}deleteBondLines(e){this.rawBondLines=this.rawBondLines.filter(((t,n)=>!e.includes(n))),this.bondedAtomPairs=this.bondedAtomPairs.filter(((t,n)=>!e.includes(n)))}getPositionsInBonds(e){const t=[];return this.bondedAtomPairs.forEach(((n,i)=>{n.forEach(((n,o)=>{n===e&&t.push({bondLineIdx:i,nodeIdx:o})}))})),t}replacePositionsInBondsByDummy(e,t){void 0===t&&(t=-1),e.forEach((e=>{const{bondLineIdx:n,nodeIdx:i}=e;this.bondedAtomPairs[n][i]=t}))}removeAtomIdFromBonds(e){this.bondedAtomPairs=this.bondedAtomPairs.map((t=>t.map((t=>t>e?t-1:t))))}shift(e){this.bondedAtomPairs=this.bondedAtomPairs.map((t=>t.map((t=>t+e))))}}class Li extends xi{constructor(e){super(),this.rawBondLines=e.getBondLines(),this.bondedAtomPairs=this.rawBondLines.map((e=>[parseInt(e.substring(0,3)),parseInt(e.substring(3,6))]))}getBondLines(){return this.bondedAtomPairs.map(((e,t)=>{if(e.some((e=>-1===e)))throw new Error(`Bonded pair ${e} contains -1`);return`${e[0].toString().padStart(3," ")}${e[1].toString().padStart(3," ")}${this.rawBondLines[t].substring(6)}`}))}}class _i extends Ci{constructor(e,t){super(t);const n=Rt.getInstance(e);this.atoms=new Mi(n),this.bonds=new Li(n),this.rGroups=new Si(n,this.atoms,this.bonds),this.shiftMonomerToDefaultPosition()}}class Ii extends Ei{molfileHandler;constructor(e){super(),this.molfileHandler=e,this.rawAtomLines=e.getAtomLines(),this.coordinates=this.getCoordinates()}getCoordinates(){const e=this.molfileHandler.x,t=this.molfileHandler.y;return Array.from(e).map(((e,n)=>({x:e,y:t[n]})))}get atomLines(){const e=/^(M V30 [^-]*)(-?\d+\.\d+)( )(-?\d+\.\d+)( -?\d+\.\d+.*)$/,t=/\sRGROUPS=\(\d+(\s+\d+)*\)/;return this.rawAtomLines.map(((n,i)=>{const o=this.coordinates[i],s=o.x.toFixed(4)+"00",r=o.y.toFixed(4)+"00";return n.replace(e,((e,t,n,i,o,a)=>t+s+i+r+a)).replace(t,"")}))}replaceRGroupSymbolByElement(e,t){super.replaceRGroupSymbolByElement(e,t);const n=this.rawAtomLines[e].substring(3).split(" ");n.length>7&&(this.rawAtomLines[e]=`M ${n.slice(0,7).join(" ")}`)}}class Pi extends xi{molfileHandler;constructor(e){super(),this.molfileHandler=e,this.rawBondLines=e.getBondLines(),this.bondedAtomPairs=this.getBondedAtomPairs()}getBondedAtomPairs(){return this.molfileHandler.pairsOfBondedAtoms.map((e=>[e[0],e[1]]))}getBondLines(){const e=/^(M\s+V30\s+\d+\s+\d+\s+)(\d+)(\s+)(\d+)(.*)$/;return this.bondedAtomPairs.map(((t,n)=>{if(t.some((e=>-1===e)))throw new Error(`Bonded pair ${t} contains -1`);return this.rawBondLines[n].replace(e,((e,n,i,o,s,r)=>`${n}${t[0]}${o}${t[1]}${r}`))}))}}class Ni extends Ci{constructor(e,t){super(t);const n=Rt.getInstance(e);this.atoms=new Ii(n),this.bonds=new Pi(n),this.rGroups=new Si(n,this.atoms,this.bonds),this.shiftMonomerToDefaultPosition()}}class Ri{static getInstance(e,t){if(Rt.isMolfileV2K(e))return new _i(e,t);if(Rt.isMolfileV3K(e))return new Ni(e,t);throw new Error("Unsupported molfile version")}}class $i{monomerSymbol;monomerIdx;helm;monomerLib;molfileWrapper;capGroupElements=[];static molfileV2KToV3KCache=new Map;constructor(e,t,n,i,o,s){this.monomerSymbol=e,this.monomerIdx=t,this.helm=n,this.monomerLib=s;const r=this.getLibraryMonomerObject();let a=r.molfile;Rt.isMolfileV2K(a)&&(a=this.convertMolfileToV3KFormat(a,e,o)),this.molfileWrapper=Ri.getInstance(a,e),this.capGroupElements=this.getCapGroupElements(r),this.removeRGroups(n.bondedRGroupsMap[t]),this.capRemainingRGroups(),this.shiftCoordinates(i)}get atomCount(){return this.molfileWrapper.atomCount}get bondCount(){return this.molfileWrapper.bondCount}convertMolfileToV3KFormat(e,t,n){if($i.molfileV2KToV3KCache.has(e))return $i.molfileV2KToV3KCache.get(e);let i=null;try{if(i=n.get_mol(e,JSON.stringify({mergeQueryHs:!0})),i){const t=i.get_v3Kmolblock();return $i.molfileV2KToV3KCache.set(e,t),t}throw new Error(`Cannot convert ${t} to molV3000`)}finally{i?.delete()}}getLibraryMonomerObject(){const e=this.helm.getPolymerTypeByMonomerIdx(this.monomerIdx),t=this.monomerLib.getMonomer(e,this.monomerSymbol);if(!t)throw new Error(`Monomer ${this.monomerSymbol} is not found in the library`);return t}getCapGroupElements(e){return e.rgroups.map((e=>(e.capGroupSmiles||e.capGroupSMILES).replace(/(\[|\]|\*|:|\d)/g,"")))}shiftCoordinates(e){this.molfileWrapper.shiftCoordinates(e)}getAtomLines(){return this.molfileWrapper.getAtomLines()}getBondLines(){return this.molfileWrapper.getBondLines()}removeRGroups(e){this.molfileWrapper.removeRGroups(e)}capRemainingRGroups(){this.molfileWrapper.capRGroups(this.capGroupElements)}replaceRGroupWithAttachmentAtom(e,t){this.molfileWrapper.replaceRGroupWithAttachmentAtom(e,t)}getAttachmentAtomByRGroupId(e){return this.molfileWrapper.getAttachmentAtomByRGroupId(e)}deleteBondLineWithSpecifiedRGroup(e){this.molfileWrapper.deleteBondLineWithSpecifiedRGroup(e)}shiftBonds(e){this.molfileWrapper.shiftBonds(e)}}class Oi{rdKitModule;monomerLib;constructor(e,t,n){this.rdKitModule=t,this.monomerLib=n,this.helm=new Ai.f(e)}monomerWrappers=[];helm;addMonomer(e,t,n){if(e===we.b9[ge.Hi.HELM])return;const i=this.monomerWrappers.length,o=new $i(e,i,this.helm,n,this.rdKitModule,this.monomerLib);this.monomerWrappers.push(o)}getAtomNumberShifts(){const e=[];let t=0;return this.monomerWrappers.forEach((n=>{e.push(t),t+=n.getAtomLines().length})),e}restoreBondsBetweenMonomers(){this.helm.bondData.forEach((e=>{const t=e.map((e=>e.monomerIdx)),n=e.map((e=>e.rGroupId)),i=t.map((e=>this.monomerWrappers[e])),o=i[1].getAttachmentAtomByRGroupId(n[1]);i[0].replaceRGroupWithAttachmentAtom(n[0],o),i[1].deleteBondLineWithSpecifiedRGroup(n[1])}))}compileToMolfile(){const e=[],t=[],n=this.getAtomNumberShifts();this.monomerWrappers.forEach(((e,t)=>{e.shiftBonds(n[t])})),this.restoreBondsBetweenMonomers();const i=new bi.Cg;for(const[n,o]of R().enumerate(this.monomerWrappers)){const s=e.length,r=t.length;e.push(...n.getAtomLines()),t.push(...n.getBondLines());const a="RNA"==this.helm.getPolymerTypeByMonomerIdx(o)?Fe.o.NUCLEOTIDE:Fe.o.AA;i.set(o,{biotype:a,symbol:n.monomerSymbol,atoms:R().count(s).take(n.atomCount).toArray(),bonds:R().count(r).take(n.bondCount).toArray()})}const o=e.length,s=t.length;return{molfile:[this.getV3KHeader(o,s),this.getV3KAtomBlock(e),this.getV3KBondBlock(t),"M V30 END CTAB\nM END"].join("\n"),monomers:i}}getV3KHeader(e,t){return`\n Datagrok\n\n 0 0 0 0 0 0 0 0 0 0999 V3000\nM V30 BEGIN CTAB\nM V30 COUNTS ${e} ${t} 0 0 1`}getV3KAtomBlock(e){const t=/^(M V30 )(\d+)( .*)$/;return["M V30 BEGIN ATOM",...e.map(((e,n)=>{const i=n+1;return e.replace(t,((e,t,n,o)=>t+i+o))})),"M V30 END ATOM"].join("\n")}getV3KBondBlock(e){const t=/^(M V30 )(\d+)( .*)$/;return["M V30 BEGIN BOND",...e.map(((e,n)=>{const i=n+1;return e.replace(t,((e,t,n,o)=>t+i+o))})),"M V30 END BOND"].join("\n")}}class Hi{constructor(e){this.molfileHandler=Rt.getInstance(e)}molfileHandler;get monomerSymbols(){return this.molfileHandler.atomTypes}getMonomerShifts(e){return{x:this.molfileHandler.x[e],y:this.molfileHandler.y[e]}}}class ki{helmHelper;rdKitModule;monomerLib;constructor(e,t,n){this.helmHelper=e,this.rdKitModule=t,this.monomerLib=n}convertToSmiles(e){const t=e.dataFrame,n=this.getSmilesList(e),i=`smiles(${e.name})`,o=t?t.columns.getUnusedName(i):i;return a.Column.fromStrings(o,n.map((e=>null===e?"":e)))}getSmilesList(e){return this.convertToMolfileV3KColumn(e).toList().map((e=>a.chem.convert(e,a.chem.Notation.MolBlock,a.chem.Notation.Smiles)))}molV3KtoMolV3KOCL(e){try{if(!e)return"";return vi.Molecule.fromMolfile(e).toMolfileV3().replace("STERAC1","STEABS")}catch(e){const[t,n]=(0,ve.AP)(e);return ro.logger.error(t,void 0,n),""}}getMolV3000ViaOCL(e,t){const n=e.map((e=>{if(null===e)return"";const t=e.get_v3Kmolblock();return e.delete(),t})),i=new Array(n.length),o=a.TaskBarProgressIndicator.create("Handling chirality...");for(let e=0;e<n.length;e++){i[e]=this.molV3KtoMolV3KOCL(n[e]);const t=e/n.length*100;o.update(t,`${t?.toFixed(2)}% of molecules completed`)}return o.close(),a.Column.fromStrings(t,i)}convertToRdKitBeautifiedMolfileColumn(e,t,n,i){const o=e.dataFrame,s=this.convertToMolfileV3KColumn(e).toList().map((e=>{if(""===e)return null;const t=n.get_mol(e);return t?(t.set_new_coords(),t.normalize_depiction(1),t.straighten_depiction(!0),t):null})),r=`molfile(${e.name})`,l=o?o.columns.getUnusedName(r):r;return t?this.getMolV3000ViaOCL(s,l):a.Column.fromStrings(l,s.map((e=>{if(null===e)return"";const t=e.get_v3Kmolblock();return e.delete(),t})))}convertToMolfileV3KColumn(e){const t=e.dataFrame,n=this.convertToMolfileV3K(e.toList()).map((e=>e.molfile)),i=(0,wi.kA)(t,`molfileV3K(${e.name})`);return a.Column.fromList("string",i,n)}convertToMolfileV3K(e){const t=new Array(e.length);for(let n=0;n<e.length;++n){const i=e[n];if(!i){t[n]=bi.vF.createEmpty();continue}let o;try{o=this.getPolymerMolfile(i)}catch(e){const[t,n]=(0,ve.AP)(e);ro.logger.error(t,void 0,n),o=bi.vF.createEmpty()}t[n]=o}return t}getPolymerGraphColumn(e){const t=e.toList(),n=this.helmHelper.getMolfiles(t);return a.Column.fromStrings("mols",n)}getPolymerMolfile(e){const t=this.helmHelper.removeGaps(e),n=t.resHelm,i=new Map;for(const[e,n]of t.monomerMap?.entries()??[])i.set(n,e);const o=this.helmHelper.getMolfiles([n])[0],s=new Hi(o),r=new Oi(n,this.rdKitModule,this.monomerLib);s.monomerSymbols.forEach(((e,t)=>{const n=s.getMonomerShifts(t);r.addMonomer(e,t,n)}));const a=r.compileToMolfile(),l=new bi.Cg;for(const[e,t]of a.monomers.entries()){const n=i.get(e);l.set(n,t)}return new bi.vF(a.molfile,l)}}class Fi{seqHelper;_column;_units;_notation;_defaultGapOriginal;notationProvider;_splitter=null;constructor(e,t){if(this.seqHelper=t,e.type!==a.TYPE.STRING)throw new Error(`Unexpected column type '${e.type}', must be '${a.TYPE.STRING}'.`);this._column=e;const n=this._column.meta.units;if(!n)throw new Error("Units are not specified in column");this._units=n,this._notation=this.getNotation(),this.isCustom()&&(this.notationProvider=this.column.temp[Ue.notationProvider]??null);const i=this.isFasta()?we.b9[ge.Hi.FASTA]:this.isSeparator()?we.b9[ge.Hi.SEPARATOR]:this.isHelm()?we.b9[ge.Hi.HELM]:this.isCustom()?this.notationProvider?.defaultGapOriginal??we.b9[ge.Hi.SEPARATOR]:void 0;if(null==i)throw new Error(`Unexpected defaultGapOriginal for notation '${this.notation}'`);if(this._defaultGapOriginal=i,!this.column.tags.has(ge.gp.aligned)||!this.column.tags.has(ge.gp.alphabet)||!this.column.tags.has(ge.gp.alphabetIsMultichar)&&!this.isHelm()&&this.alphabet===ge.YI.UN)if(this.isFasta())this.seqHelper.setUnitsToFastaColumn(this);else if(this.isSeparator()){const t=e.getTag(ge.gp.separator);this.seqHelper.setUnitsToSeparatorColumn(this,t)}else if(this.isHelm())this.seqHelper.setUnitsToHelmColumn(this);else{if(!this.isCustom())throw new Error(`Unexpected units '${this.column.meta.units}'.`);this.notationProvider.setUnits(this)}if(!this.column.tags.has(ge.gp.alphabetIsMultichar))if(this.isHelm())this.column.setTag(ge.gp.alphabetIsMultichar,"true");else if(["UN"].includes(this.alphabet))throw new Error(`For column '${this.column.name}' of alphabet '${this.alphabet}' tag '${ge.gp.alphabetIsMultichar}' is mandatory.`);this.columnVersion=this.column.version,!this.isSeparator()||this.isCustom()&&this.notationProvider||e.temp.seqHandlerRefined||(this.refineSeparatorNotation(),e.temp.seqHandlerRefined=!0)}async refineSeparatorNotation(){const e=((e,t,n)=>{const i={};let o=!0,s=null;for(const t of e){const e=t?n(t):[];if(null===s?s=e.length:e.length!==s&&(o=!1),e.length>=3)for(const t of e)t in i||(i[t]=0),i[t]+=1}return{freq:i,sameLength:o}})([...new Set((this.column.length<100?R().count(0).take(Math.min(100,this.column.length)).map((e=>this.column.get(e))):this.column.categories.slice(0,100)).map((e=>e?e.substring(0,500):"")).filter((e=>0!==e.length)))],0,(e=>e.split(this.separator)));let t=!1;const n=[{package:"SequenceTranslator",name:"refineNotationProviderForHarmonizedSequence"}];for(const i of n)try{const n=a.Func.find(i);if(0===n.length)continue;const o=n[0].prepare({col:this.column,stats:e,separator:this.separator}),s=(await o.call()).getOutputParamValue();t||=s}catch(e){console.error(e)}t&&(delete this.column.temp[Ue.seqHandler],this.column.fireValuesChanged())}static setTags(e){const t=e.column.meta.units;if([ge.Hi.FASTA,ge.Hi.SEPARATOR].includes(t)){if(!e.column.getTag(ge.gp.alphabet)&&0===Object.keys(e.stats.freq).length)throw new Error("Alphabet is empty and not annotated.");let t=e.column.getTag(ge.gp.aligned);null===t&&(t=e.stats.sameLength?"SEQ.MSA":"SEQ",e.column.setTag(ge.gp.aligned,t));let n=e.column.getTag(ge.gp.alphabet);if(null===n&&(n=(0,Oe.pc)(e.stats.freq,ge.q7),e.column.setTag(ge.gp.alphabet,n)),n===ge.YI.UN){const t=Object.keys(e.stats.freq).length,n=Object.keys(e.stats.freq).some((e=>e.length>1));e.column.setTag(ge.gp.alphabetSize,t.toString()),e.column.setTag(ge.gp.alphabetIsMultichar,n?"true":"false")}}else if(t===ge.Hi.HELM){let t=e.column.getTag(ge.gp.alphabet);null===t&&(t=(0,Oe.p0)(e.stats.freq,ge.q7,e.defaultGapOriginal),e.column.setTag(ge.gp.alphabet,t))}}get column(){return this._column}get length(){return this._column.length}get units(){return this._units}get notation(){return this._notation}get defaultGapOriginal(){return this._defaultGapOriginal}get separator(){const e=this.column.getTag(ge.gp.separator)??void 0;if(this.notation===ge.Hi.SEPARATOR&&void 0===e)throw new Error(`Separator is mandatory for column '${this.column.name}' of notation '${this.notation}'.`);return e}get aligned(){const e=this.column.getTag(ge.gp.aligned);if(!e&&(this.isFasta()||this.isSeparator()))throw new Error("Tag aligned not set");return e}get alphabet(){const e=this.column.getTag(ge.gp.alphabet);if(!e&&(this.isFasta()||this.isSeparator()))throw new Error("Tag alphabet not set");return e}get defaultBiotype(){return this.alphabet===ge.YI.RNA||this.alphabet===ge.YI.DNA?Fe.o.NUCLEOTIDE:Fe.o.AA}get helmCompatible(){return this.column.getTag(ge.gp.isHelmCompatible)}getAlphabetSize(){if(this.notation==ge.Hi.HELM||this.alphabet==ge.YI.UN){const e=this.column.getTag(ge.gp.alphabetSize);let t;if(e)t=parseInt(e);else{const e=this.stats;t=Object.keys(e.freq).length}return t}switch(this.alphabet){case ge.YI.PT:return 20;case ge.YI.DNA:case ge.YI.RNA:return 4;case"NT":return console.warn("Unexpected alphabet 'NT'."),4;default:throw new Error(`Unexpected alphabet '${this.alphabet}'.`)}}getAlphabetIsMultichar(){return this.notation===ge.Hi.HELM||this.alphabet===ge.YI.UN&&"true"===this.column.getTag(ge.gp.alphabetIsMultichar)}cached=!0;_splitted=null;columnVersion=null;getSplitted(e,t){if(this.cached&&void 0===t){this.column.version===this.columnVersion&&null!==this._splitted||(this.columnVersion=this.column.version,this._splitted=new Array(this.column.length));let t=this._splitted[e]?this._splitted[e].deref():void 0;if(!t){const n=this.column.get(e);t=this.splitter(n),this._splitted[e]=new WeakRef(t)}return t}{const n=this.column.get(e);return this.getSplitter(t)(n)}}getMonomerAtPosition(e,t,n){if(this.isCanonicalAlphabet&&this.isFasta()&&!this.getAlphabetIsMultichar()){const i=(this.column.get(e)??"")[t];return n?i===we.b9[ge.Hi.FASTA]?we._S:i??we._S:i??""}const i=this.getSplitted(e);return t<0||t>=i.length?this.defaultGapOriginal:n?i.getCanonical(t):i.getOriginal(t)}getMonomersAtPosition(e,t){const n=this.column.length,i=new Array(n).fill(we._S);if(this.isCanonicalAlphabet&&this.isFasta()&&!this.getAlphabetIsMultichar()){const o=this.column.categories,s=this.column.getRawData();for(let r=0;r<n;r++){const n=o[s[r]]??"";if(e<n.length){const o=n[e];i[r]=t?o===we.b9[ge.Hi.FASTA]?we._S:o??we._S:o??""}}}else for(let o=0;o<n;o++){const n=this.getSplitted(o);e>=0&&e<n.length&&(i[o]=t?n.getCanonical(e):n.getOriginal(e))}return i}getValue(e,t){return this.column.get(e),new We(e,this)}getHelm(e){let t;const n=this.column.get(e);return t=this.notation===ge.Hi.HELM?n:this.notation===ge.Hi.CUSTOM?this.notationProvider.getHelm(n,{}):this.getConverter(ge.Hi.HELM)(n),t}_stats=null;get isCanonicalAlphabet(){const e=this.alphabet;return e===ge.YI.DNA||e===ge.YI.RNA||e===ge.YI.PT}get stats(){if(null===this._stats){const e={};let t=!0,n=null;const i=this.column.length;for(let o=0;o<i;++o){const i=this.getSplitted(o);null==n?n=i.length:i.length!==n&&(t=!1);for(let t=0;t<i.length;++t){const n=i.getCanonical(t);n in e||(e[n]=0),e[n]+=1}}this._stats={freq:e,sameLength:t}}return this._stats}_maxLength=null;get maxLength(){return null===this._maxLength&&(this._maxLength=0===this.column.length?0:R().count(0).take(this.column.length).map((e=>this.getSplitted(e).length)).reduce(((e,t)=>e>t?e:t),0)),this._maxLength}_posList=null;get posList(){if(null===this._posList){const e=this.column.getTag(ge.gp.positionNames);this._posList=e?e.split(ge.z1).map((e=>e.trim())):R().count(1).take(this.maxLength).map((e=>e.toString())).toArray()}return this._posList}isFasta(){return this.notation===ge.Hi.FASTA}isSeparator(){return this.notation===ge.Hi.SEPARATOR||!!this.separator}isFastaOrSeparator(){return this.isFasta()||this.isSeparator()}isHelm(){return this.notation===ge.Hi.HELM}isCustom(){return this.notation===ge.Hi.CUSTOM}isRna(){return this.alphabet===ge.YI.RNA}isDna(){return this.alphabet===ge.YI.DNA}isPeptide(){return this.alphabet===ge.YI.PT}isMsa(){return!!this.aligned&&this.aligned.toUpperCase().includes("MSA")}isHelmCompatible(){return"true"===this.helmCompatible}isGap(e){return!e||e===this._defaultGapOriginal}getNotation(){if(this.units.toLowerCase().startsWith(ge.Hi.FASTA))return ge.Hi.FASTA;if(this.units.toLowerCase().startsWith(ge.Hi.SEPARATOR))return ge.Hi.SEPARATOR;if(this.units.toLowerCase().startsWith(ge.Hi.HELM))return ge.Hi.HELM;if(this.units.toLowerCase().startsWith(ge.Hi.CUSTOM))return ge.Hi.CUSTOM;throw new Error(`Column '${this.column.name}' has unexpected notation '${this.units}'.`)}getHelmWrappers(){return[this.isDna()||this.isRna()||this.isHelmCompatible()?"RNA1{":"PEPTIDE1{",this.isDna()?"d(":this.isRna()?"r(":"",this.isDna()||this.isRna()?")p":"","}$$$$"]}getNewColumn(e,t,n,i){const o=this.column,s=e.toLowerCase()+"("+o.name+")",r=n??o.dataFrame?.columns.getUnusedName(s)??s,l=a.Column.fromList("string",r,i??new Array(this.column.length).fill(""));if(l.semType=a.SEMTYPE.MACROMOLECULE,l.meta.units=e,e===ge.Hi.SEPARATOR){if(!t)throw new Error(`Notation '${ge.Hi.SEPARATOR}' requires separator value.`);l.setTag(ge.gp.separator,t)}l.setTag(a.TAGS.CELL_RENDERER,e===ge.Hi.HELM?"helm":"sequence");const c=o.getTag(ge.gp.aligned);c&&l.setTag(ge.gp.aligned,c);let u=o.getTag(ge.gp.alphabet);u||this.notation!==ge.Hi.HELM||e===ge.Hi.HELM||(u=ge.YI.UN),null!=u&&l.setTag(ge.gp.alphabet,u);let h=o.getTag(ge.gp.alphabetSize);null!=u&&h&&l.setTag(ge.gp.alphabetSize,h);const d=o.getTag(ge.gp.alphabetIsMultichar);return null!=u&&void 0!==d&&l.setTag(ge.gp.alphabetIsMultichar,d),e==ge.Hi.HELM&&(h=this.getAlphabetSize().toString(),l.setTag(ge.gp.alphabetSize,h)),l}getNewColumnFromList(e,t){return this.getNewColumn(this.notation,this.separator,e,t)}static unitsStringIsValid(e){return e=e.toLowerCase(),[ge.Hi.FASTA,ge.Hi.SEPARATOR,ge.Hi.HELM].some((t=>e.startsWith(t.toLowerCase())))}static getNewColumnFromParams(e,t,n){if(!Fi.unitsStringIsValid(n))throw new Error("Invalid format of 'units' parameter");const i=a.Column.fromList("string",t,new Array(e).fill(""));return i.semType=a.SEMTYPE.MACROMOLECULE,i.meta.units=n,i}get splitter(){return null===this._splitter&&(this._splitter=this.getSplitter()),this._splitter}getSplitter(e){let t=null;if(t=this.notationProvider?this.notationProvider.splitter:null,t)return t;if(this.units.toLowerCase().startsWith(ge.Hi.FASTA))return null===this.column.getTag(ge.gp.alphabet)||this.getAlphabetIsMultichar()?ge.J9:Oe.tm;if(this.units.toLowerCase().startsWith(ge.Hi.SEPARATOR))return(0,ge.dh)(this.separator,e);if(this.units.toLowerCase().startsWith(ge.Hi.HELM))return ge.qp;throw new Error(`Unexpected units ${this.units} .`)}split(e){return this.splitter(e)}getDistanceFunctionName(){if(!this.isFasta())throw new Error("Only FASTA notation is supported");if(this.isMsa())return me.Z.HAMMING;switch(this.alphabet){case ge.YI.DNA:case ge.YI.RNA:case ge.YI.PT:}return me.Z.LEVENSHTEIN}getDistanceFunction(){return me.V[this.getDistanceFunctionName()]()}async checkHelmCompatibility(){if(this.column.tags.has(ge.gp.isHelmCompatible))return"true"===this.column.getTag(ge.gp.isHelmCompatible);const e=(await(0,ye.pj)()).getMonomerLib().getMonomerSymbolsByType("PEPTIDE"),t=new Set(e),n=((0,ge.dh)(this.separator),new Set),i=this.column.length,o=this.column.getRawData();for(let e=0;e<i;++e){const i=o[e];if(!(i in n)){n.add(i);const o=this.getSplitted(e);for(let e=0;e<o.length;++e){const n=o.getCanonical(e);if(!t.has(n))return this.column.setTag(ge.gp.isHelmCompatible,"false"),!1}}}return this.column.setTag(ge.gp.isHelmCompatible,"true"),!0}toFasta(e){return e===ge.Hi.FASTA}toSeparator(e){return e===ge.Hi.SEPARATOR}toHelm(e){return e===ge.Hi.HELM}convertHelmToFastaSeparator(e,t,n,i){i||(i=this.toFasta(t)?we.b9[ge.Hi.FASTA]:we.b9[ge.Hi.SEPARATOR]),n||(n=this.toFasta(t)?"":this.separator);const o=e.startsWith("RNA"),s=(0,ge.qp)(e),r=[];for(let e=0;e<s.length;++e){let n=s.getOriginal(e);if(o&&(n=n.replace(yn.EK,"$1")),n===we.b9[ge.Hi.HELM])r.push(i);else if(this.toFasta(t)&&n.length>1){const e="["+n+"]";r.push(e)}else r.push(n)}return r.join(n)}convert(e,t){const n=this.getJoiner({notation:e,separator:t}),i=this.getNewColumn(e,t);return i.init((e=>{const t=this.getSplitted(e);return n(t)})),i}getRegion(e,t,n){const i=this.getNewColumn(this.notation,this.separator);i.name=n;const o=e??0,s=t??this.maxLength-1,r=this.getJoiner(),a=s-o+1,l=we.b9[this.notation];i.init((e=>{const t=this.getSplitted(e),n=new Array(a);for(let e=0;e<a;++e){const i=o+e;n[e]=i<t.length?t.getOriginal(i):l}return r(new Oe.Mu(n,l))}));const c=e=>{const t=e.split(",").map((e=>e.trim())),n=new Array(a);for(let e=0;e<a;++e){const i=o+e;n[e]=i<t.length?t[i]:"?"}return n.join(ge.z1)},u=this.column.getTag(ge.gp.positionNames);u&&i.setTag(ge.gp.positionNames,c(u));const h=this.column.getTag(ge.gp.positionLabels);return h&&i.setTag(ge.gp.positionLabels,c(h)),i}_joiner=void 0;get joiner(){return this._joiner||(this._joiner=this.getJoiner()),this._joiner}getJoiner(e){const t=e?e.notation:this.notation,n=e?e.separator:this.separator;let i;const o=this;switch(t){case ge.Hi.FASTA:i=function(e){return o.joinToFasta(e,o.isHelm())};break;case ge.Hi.SEPARATOR:if(!n)throw new Error(`Separator is mandatory for notation '${t}'.`);i=function(e){return Di(e,n,o.isHelm())};break;case ge.Hi.HELM:{const e=o.alphabet===ge.YI.DNA||o.alphabet===ge.YI.RNA,t=o.getHelmWrappers();i=function(n){return Gi(n,t,e)};break}default:throw new Error(`Unexpected notation '${t}'.`)}return i}getConverter(e,t=void 0){if(e===ge.Hi.SEPARATOR&&!t)throw new Error(`Target separator is not specified for target units '${ge.Hi.SEPARATOR}'.`);const n=this;if(e===ge.Hi.FASTA)return function(e){return n.convertToFasta(e)};if(e===ge.Hi.HELM)return function(e){return n.convertToHelm(e)};if(e===ge.Hi.SEPARATOR)return function(e){return n.convertToSeparator(e,t)};throw new Error}static forColumn(e,t){let n=e.temp[Ue.seqHandler];return n&&n.columnVersion===e.version||(n=e.temp[Ue.seqHandler]=new Fi(e,t)),n}joinToFasta(e,t){const n=new Array(e.length);for(let i=0;i<e.length;++i){const o=e.getOriginal(i);let s=e.getOriginal(i);t&&(s=s.replace(yn.EK,"$1")),o===we._S?s=we.b9[ge.Hi.FASTA]:o===yn.q7?s="":s.length>1&&(s="["+s+"]"),n[i]=s}return n.join("")}convertToFasta(e){const t=this.splitter,n=this.isHelm()?this.splitterAsHelmNucl(e):t(e);return this.joinToFasta(n,this.isHelm())}convertToSeparator(e,t){return Di(this.isHelm()?this.splitterAsHelmNucl(e):this.splitter(e),t,this.isHelm())}convertToHelm(e){if(this.notation==ge.Hi.HELM)return e;const t=this.getHelmWrappers(),n=e.startsWith("DNA")||e.startsWith("RNA");return Gi(this.splitter(e),t,n)}splitterAsHelmNucl(e){const t=this.splitter(e),n=new Array(t.length),i=e.startsWith("DNA"),o=e.startsWith("RNA");for(let e=0;e<t.length;++e){let s=t.getOriginal(e);(i||o)&&(s=s.replace(yn.EK,"$1"),s=s===yn.q7?null:s),n[e]=s||null}return new Oe.Mu(n.filter((e=>!!e)),we.b9[ge.Hi.HELM])}getRendererBack(e,t){const n=this.column.temp;let i=n.rendererBack;return i||(i=n.rendererBack=this.notationProvider.createCellRendererBack(e,t)),i}}function Di(e,t,n){const i=new Array(e.length);for(let t=0;t<e.length;++t){const o=e.getCanonical(t);let s=e.getOriginal(t);n&&(s=s.replace(yn.EK,"$1")),o===we._S?s=we.b9[ge.Hi.SEPARATOR]:o===yn.q7&&(s=""),i[t]=s}return i.join(t)}function Gi(e,t,n){const[i,o,s,r]=t,a=new Array(e.length);for(let t=0;t<e.length;++t){const i=e.getCanonical(t);let r=e.getOriginal(t);i===we._S?r=we.b9[ge.Hi.HELM]:(n&&(r=r.replace(yn.EK,"$1")),r=1===r.length?`${o}${r}${s}`:`${o}[${r}]${s}`),a[t]=r}return`${i}${a.join(".")}${r}`}class Bi{libHelper;rdKitModule;constructor(e,t){this.libHelper=e,this.rdKitModule=t}getSeqHandler(e){return Fi.forColumn(e,this)}getSeqMonomers(e){const t=this.getSeqHandler(e);return Object.keys(t.stats.freq)}async getHelmToMolfileConverter(e){const t=await(0,Ot.b2)();return new ki(t,this.rdKitModule,e)}helmToAtomicLevelSingle(e,t,n,i=!0){if(!e)return bi.vF.createEmpty();const o=t.convertToMolfileV3K([e])[0];if(!o||!o.molfile)return bi.vF.createEmpty();let s=null;try{let e=o.molfile;if(i){if(s=this.rdKitModule.get_mol(e),!s)return bi.vF.createEmpty();s.set_new_coords(),s.normalize_depiction(1),s.straighten_depiction(!0),e=s.get_v3Kmolblock()}return n&&(e=t.molV3KtoMolV3KOCL(e)),new bi.vF(e,o.monomers)}catch(e){const[t,n]=(0,ve.AP)(e);return ro.logger.error(t,void 0,n),bi.vF.createEmpty()}finally{s?.delete()}}async helmToAtomicLevel(e,t,n,i){const o=i??this.libHelper.getMonomerLib(),r=e.dataFrame,l=(0,wi.qj)(r,e.name),c=await this.getHelmToMolfileConverter(o),u=e.toList(),h=new Array(e.length),d=a.Func.find({package:"Chem",name:"beautifyMols"})[0],p=a.Func.find({package:"Chem",name:"convertToV3KViaOCL"})[0];for(let n=0;n<e.length;n++)h[n]=this.helmToAtomicLevelSingle(u[n],c,t&&!p,!d).molfile;if(d){const t=await d.apply({mols:h});if(t&&Array.isArray(t)&&t.length===e.length)for(let n=0;n<e.length;n++)t[n]&&(h[n]=t[n])}if(t&&p){const t=await p.apply({mols:h});if(t&&Array.isArray(t)&&t.length===e.length)for(let n=0;n<e.length;n++)t[n]&&(h[n]=t[n]);else s.shell.warning("OCL function returned an unexpected result")}const m=a.Column.fromStrings(l,h);return m.semType=a.SEMTYPE.MOLECULE,m.meta.units=a.UNITS.Molecule.MOLBLOCK,m.setTag(".sequence-src-col",e.name),{molCol:m,warnings:[]}}setUnitsToFastaColumn(e){if(e.column.semType!==a.SEMTYPE.MACROMOLECULE||e.column.meta.units!==ge.Hi.FASTA)throw new Error(`The column of notation '${ge.Hi.FASTA}' must be '${a.SEMTYPE.MACROMOLECULE}'.`);e.column.meta.units=ge.Hi.FASTA,Fi.setTags(e)}setUnitsToSeparatorColumn(e,t){if(e.column.semType!==a.SEMTYPE.MACROMOLECULE||e.column.meta.units!==ge.Hi.SEPARATOR)throw new Error(`The column of notation '${ge.Hi.SEPARATOR}' must be '${a.SEMTYPE.MACROMOLECULE}'.`);if(!t)throw new Error(`The column of notation '${ge.Hi.SEPARATOR}' must have the separator tag.`);e.column.meta.units=ge.Hi.SEPARATOR,e.column.setTag(ge.gp.separator,t),Fi.setTags(e)}setUnitsToHelmColumn(e){if(e.column.semType!==a.SEMTYPE.MACROMOLECULE)throw new Error(`The column of notation '${ge.Hi.HELM}' must be '${a.SEMTYPE.MACROMOLECULE}'`);e.column.meta.units=ge.Hi.HELM,Fi.setTags(e)}}async function Vi(e){let t="";try{if(!e||!e.value)return t="No sequence provided",{errorText:t,mol:""};if(!(e.cell&&e.cell.dart&&e.cell.dataFrame&&e.cell.column))return t="Atomic level conversion requeires a sequence column",{errorText:t,mol:""};if(![ge.Hi.FASTA,ge.Hi.SEPARATOR,ge.Hi.HELM].includes(e.cell.column.meta.units?.toLowerCase()??""))return t="Unsupported sequence notation. please use Bio | Polytool | Convert",{errorText:t,mol:""};const n=(await lo.getSeqHelper()).getSeqHandler(e.cell.column);if(!n)return t="No sequence handler found",{errorText:t,mol:""};if((n.getSplitted(e.cell.rowIndex,50)?.length??100)>40)return t="Maximum number of monomers is 40",{errorText:t,mol:""};const i=a.Column.fromStrings("singleVal",[e.value]),o=a.DataFrame.fromColumns([i]);if(Object.entries(e.cell.column.tags).forEach((([e,t])=>{i.setTag(e,t)})),await lo.toAtomicLevel(o,i,e.cell.column.meta.units===ge.Hi.HELM,!1),o.columns.length<2)return t="No structure generated",{errorText:t,mol:""};const s=o.columns.byIndex(1).get(0);return s?{errorText:"",mol:s}:(t="No structure generated",{errorText:t,mol:""})}catch(e){ro.logger.error(e)}return t="No Structure generated",{errorText:t,mol:""}}const Ui="#333333",Wi="rgba(60, 177, 115, 0.1)",qi="rgba(240, 240, 240, 0.5)",Yi="rgba(100, 100, 100, 0.3)";class ji{constructor(e=Zi.DEFAULT_TRACK_HEIGHT,t=Zi.MIN_TRACK_HEIGHT,n=""){this.ctx=null,this.visible=!0,this.title="",this.tooltipEnabled=!1,this.tooltipContent=null,this.height=e,this.defaultHeight=e,this.minHeight=t,this.title=n}init(e){this.ctx=e}getMonomerAt(e,t,n){return null}enableTooltip(e){this.tooltipEnabled=e}setTooltipContentGenerator(e){this.tooltipContent=e}getTooltipContent(e,t){if(!this.tooltipEnabled||!this.tooltipContent)return null;const n=this.getPositionData(e)??new Map;return this.tooltipContent(e,t,n)}getPositionData(e){return null}setVisible(e){this.visible=e}getHeight(){return this.visible?this.height:0}getDefaultHeight(){return this.defaultHeight}getMinHeight(){return this.minHeight}setHeight(e){this.height=Math.max(this.minHeight,e)}resetHeight(){this.height=this.defaultHeight}isVisible(){return this.visible}setTitle(e){this.title=e}getTitle(){return this.title}}class Ki extends ji{constructor(e=new Map,t=Zi.DEFAULT_TRACK_HEIGHT,n="",i="WebLogo"){super(t,Zi.DEFAULT_TRACK_HEIGHT,i),this.data=new Map,this.monomerLib=null,this.biotype="HELM_AA",this.hoveredPosition=-1,this.hoveredMonomer=null,this.data=e,this.visible=e.size>0}setHovered(e,t){this.hoveredPosition=e,this.hoveredMonomer=t}getPositionData(e){return this.data.get(e)||null}setupDefaultTooltip(){this.enableTooltip(!0),this.setTooltipContentGenerator(((e,t,n)=>this.createTooltipContent(e,t,n)))}createFrequencyTable(e){let t;switch(this.biotype){case"HELM_BASE":case"HELM_SUGAR":case"HELM_NUCLETIDE":t=Fe.o.NUCLEOTIDE;break;default:t=Fe.o.AA}const n=Array.from(e.values()).reduce(((e,t)=>e+t),0),i={};for(const[t,o]of e.entries())i[t]=Math.max(1,Math.round(o/n*100));const o=(0,ui.F)(i,t,this.monomerLib);return o.style.fontSize="11px",o.style.marginTop="4px",o}createTooltipContent(e,t,n){const i=[];if(i.push(r.divText(`Position: ${e+1}`,{style:{fontWeight:"bold",marginBottom:"6px",fontSize:"13px"}})),t&&(i.push(r.divText(`Monomer: ${t}`,{style:{marginBottom:"6px",fontSize:"13px"}})),n.has(t)&&i.push(r.divText(`${(100*n.get(t)).toFixed(2)}%`,{style:{marginBottom:"6px",fontSize:"13px"}}))),n&&n.size>0){const e=this.createFrequencyTable(n);i.push(e)}else i.push(r.divText("No data available",{style:{fontStyle:"italic",color:"#666"}}));const o=r.divV(i);return o.style.maxHeight="80vh",o}setMonomerLib(e){this.monomerLib=e}setBiotype(e){this.biotype=e}getMonomerAt(e,t,n){if(!this.ctx||!this.visible||0===this.data.size)return null;const i=this.data.get(n);if(!i||0===i.size)return null;const o=t,s=Array.from(i.entries()).sort(((e,t)=>t[1]-e[1])),r=s.reduce(((e,[t,n])=>e+n),0),a=this.height;let l=0;for(const[e,t]of s){const n=t*a/r;if(o>=l&&o<l+n)return e;l+=n}return null}updateData(e){this.data=e,this.visible=e.size>0}draw(e,t,n,i,o,s,r,a){if(!this.ctx||!this.visible||0===this.data.size)return;const l=Math.floor(n/s),c=i-4,u=t+2;for(let h=0;h<l;h++)this.drawWebLogoColumn(h,e,t,n,i,o,s,r,a,u,c)}drawWebLogoColumn(e,t,n,i,o,s,r,a,l,c,u){const h=s+e-1;if(h<0||h>=a)return;const d=this.data.get(h);if(!d||0===d.size)return;const p=t+e*r,m=r-2;s+e===l&&(this.ctx.fillStyle=Wi,this.ctx.fillRect(p,n,r,o)),this.ctx.fillStyle=qi,this.ctx.fillRect(p+1,c,m,u),this.drawLettersInColumn(h,p,m,c,u,d),this.drawColumnBorder(p,c,m,u)}drawLettersInColumn(e,t,n,i,o,s){const r=Array.from(s.entries()).sort(((e,t)=>t[1]-e[1])),a=r.reduce(((e,[t,n])=>e+n),0),l=Math.min(1,o/(a*o));let c=i;const u=i+o;for(const[i,s]of r){const r=s*o*l,a=Math.max(4,Math.floor(r));if(a<4)continue;const h=e===this.hoveredPosition&&i===this.hoveredMonomer,d=Math.min(a,u-c);if(d<4)break;this.drawLetter(i,t+1,c,n,d,h),c+=d}}drawColumnBorder(e,t,n,i){this.ctx.strokeStyle=Yi,this.ctx.lineWidth=1,this.ctx.strokeRect(e+1,t,n,i)}drawLetter(e,t,n,i,o,s=!1){if(!this.ctx)return;const r=this.getMonomerBackgroundColor(e),a=this.getMonomerTextColor(e);this.ctx.fillStyle=r,this.ctx.fillRect(t,n,i,o),s&&(this.ctx.shadowColor="rgba(255, 255, 255, 0.8)",this.ctx.shadowBlur=8,this.ctx.strokeStyle="white",this.ctx.lineWidth=2,this.ctx.strokeRect(t,n,i,o),this.ctx.shadowBlur=0),this.drawLetterSeparators(t,n,i,o),this.drawLetterText(e,t,n,i,o,a)}drawLetterSeparators(e,t,n,i){this.ctx.strokeStyle="rgba(255, 255, 255, 0.4)",this.ctx.lineWidth=1,t+i<t+this.ctx.canvas.height&&(this.ctx.beginPath(),this.ctx.moveTo(e,t+i),this.ctx.lineTo(e+n,t+i),this.ctx.stroke())}drawLetterText(e,t,n,i,o,s){const r=Math.min(.8*o,.8*i);r>=7&&(this.ctx.fillStyle=s,this.ctx.font=`bold ${r}px Roboto, Roboto Local`,this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillText(e,t+i/2,n+o/2))}getMonomerBackgroundColor(e){if(this.monomerLib)try{const t=this.monomerLib.getMonomerColors(this.biotype,e);if(t&&t.backgroundcolor)return t.backgroundcolor}catch(e){console.warn("Error getting background color from monomerLib:",e)}return"#CCCCCC"}getMonomerTextColor(e){const t=this.getMonomerBackgroundColor(e);try{const e=a.Color.fromHtml(t),n=a.Color.getContrastColor(e);return a.Color.toHtml(n)}catch(e){return console.warn("Error calculating contrast color:",e),"#000000"}}}class zi extends ji{constructor(e,t=Zi.DEFAULT_TRACK_HEIGHT,n="default",i="Conservation"){super(t,Zi.MIN_TRACK_HEIGHT,i),this.data=e,this.colorScheme=n,this.visible=e.length>0}updateData(e){this.data=e,this.visible=e.length>0}draw(e,t,n,i,o,s,r,a){if(!this.ctx||!this.visible||0===this.data.length)return;const l=Math.floor(n/s);for(let n=0;n<l;n++){const l=o+n;if(l>r)break;const c=e+n*s,u=s,h=c+u/2;l-1<this.data.length&&(this.drawConservationBar(l-1,c,u,h,t,i),l===a&&(this.ctx.fillStyle=Wi,this.ctx.fillRect(c,t,u,i)))}}drawConservationBar(e,t,n,i,o,s){if(!this.ctx)return;const r=this.data[e];this.ctx.fillStyle=qi,this.ctx.fillRect(t+2,o,n-4,s);let a="#3CB173";if("default"===this.colorScheme)r<.5?a="#E74C3C":r<.75&&(a="#F39C12");else if("rainbow"===this.colorScheme)a=r<.2?"#E74C3C":r<.4?"#FF7F00":r<.6?"#FFFF00":r<.8?"#00FF00":"#0000FF";else if("heatmap"===this.colorScheme){const e=Math.round(255*r);a=`rgb(255, ${e}, ${e})`}const l=r*s;this.ctx.fillStyle=a,this.ctx.fillRect(t+2,o+s-l,n-4,l),this.ctx.strokeStyle=Yi,this.ctx.lineWidth=1,this.ctx.strokeRect(t+2,o,n-4,s),n>20&&(this.ctx.fillStyle=Ui,this.ctx.font="9px monospace",this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillText(`${Math.round(100*r)}%`,i,o+s/2))}}const Zi={TITLE_HEIGHT:16,TRACK_GAP:4,DOTTED_CELL_HEIGHT:30,SLIDER_HEIGHT:8,TOP_PADDING:5,DEFAULT_TRACK_HEIGHT:45,MIN_TRACK_HEIGHT:35},Xi={BASE:Zi.DOTTED_CELL_HEIGHT+Zi.SLIDER_HEIGHT,WITH_TITLE:function(){return this.BASE+Zi.TITLE_HEIGHT+Zi.TRACK_GAP},WITH_WEBLOGO:function(){return this.WITH_TITLE()+Zi.DEFAULT_TRACK_HEIGHT+Zi.TRACK_GAP},WITH_BOTH:function(){return this.WITH_WEBLOGO()+Zi.DEFAULT_TRACK_HEIGHT+Zi.TRACK_GAP}};class Ji{constructor(e,t){this.gridColumn=t,this.canvas=null,this.ctx=null,this.tracks=new Map,this.currentHoverPosition=-1,this.currentHoverTrack=null,this.currentHoverMonomer=null,this.previousHoverPosition=-1,this.previousHoverTrack=null,this.previousHoverMonomer=null,this.dataFrame=null,this.seqHandler=null,this.seqColumn=null,this.onSelectionCallback=null,this.trackButtons=[],this.userSelectedTracks=null,this.config={x:e.x||0,y:e.y||0,width:e.width||0,height:e.height||0,windowStartPosition:e.windowStartPosition||1,positionWidth:e.positionWidth||15,totalPositions:e.totalPositions||5e3,headerHeight:e.headerHeight||Xi.BASE,sliderHeight:e.sliderHeight||Zi.SLIDER_HEIGHT,currentPosition:e.currentPosition||1,cellBackground:void 0===e.cellBackground||e.cellBackground,sliderColor:e.sliderColor||"rgba(220, 220, 220, 0.4)",onPositionChange:e.onPositionChange||((e,t)=>{}),onHeaderHeightChange:e.onHeaderHeightChange||(()=>{}),...e},this.eventElement=r.div(),this.eventElement.style.position="absolute",this.config.canvas.parentElement?.appendChild(this.eventElement),this.state={isDragging:!1,dragStartX:0},this.setupEventListeners(),this.init()}determineVisibleTracks(){const e=this.config.headerHeight,t=this.getTrack("weblogo"),n=this.getTrack("conservation");if(this.tracks.forEach((e=>{e.setVisible(!1),e.setHeight(Zi.DEFAULT_TRACK_HEIGHT)})),!(e<Xi.WITH_TITLE()||e<Xi.WITH_WEBLOGO()))if(e<Xi.WITH_BOTH()){if(t){t.setVisible(!0);const n=e-Xi.WITH_WEBLOGO();t.setHeight(Zi.DEFAULT_TRACK_HEIGHT+n)}}else{if(t&&t.setVisible(!0),n&&n.setVisible(!0),t&&e>Xi.WITH_BOTH()){const n=e-Xi.WITH_BOTH();t.setHeight(Zi.DEFAULT_TRACK_HEIGHT+n)}this.userSelectedTracks&&(this.tracks.forEach(((e,t)=>{this.userSelectedTracks[t]||e.setVisible(!1)})),e<Xi.WITH_WEBLOGO()&&t&&t.setVisible(!1),e<Xi.WITH_BOTH()&&n&&n.setVisible(!1))}}drawTrackButtons(){if(!this.ctx||this.config.width<280)return;this.trackButtons=[];const e=this.getTrack("conservation"),t=this.getTrack("weblogo"),n=e?.isVisible()??!1,i=t?.isVisible()??!1;let o=this.config.width-16;const s=this.config.headerHeight>=Xi.WITH_TITLE()?(Zi.TITLE_HEIGHT-14)/2:2;n&&i||(!n&&e&&(o-=70,this.drawTrackButton("conservation","Conservation",o,s,70,14),o-=4),!i&&t&&(o-=70,this.drawTrackButton("weblogo","WebLogo",o,s,70,14)))}drawTrackButton(e,t,n,i,o,s,r=!1){this.ctx&&(this.trackButtons.push({id:e,label:t,x:n,y:i,width:o,height:s}),this.ctx.fillStyle=r?"rgba(100, 150, 200, 0.8)":"rgba(240, 240, 240, 0.8)",this.ctx.fillRect(n,i,o,s),this.ctx.strokeStyle=r?"rgba(70, 120, 170, 0.8)":"rgba(180, 180, 180, 0.8)",this.ctx.lineWidth=1,this.ctx.strokeRect(n,i,o,s),this.ctx.fillStyle=r?"#ffffff":"#666666",this.ctx.font="9px Roboto, Roboto Local",this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillText(t,n+o/2,i+s/2))}handleTrackButtonClick(e,t){for(const n of this.trackButtons)if(e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height)return this.snapToTrackHeight(n.id),!0;return!1}isInsideColumnHeaderArea(e,t){return t<(this.config.headerHeight>=Xi.WITH_TITLE()?Zi.TITLE_HEIGHT:0)}snapToTrackHeight(e){let t;if("weblogo"===e)t=Xi.WITH_WEBLOGO();else{if("conservation"!==e)return;t=Xi.WITH_BOTH()}this.userSelectedTracks||(this.userSelectedTracks={},this.tracks.forEach(((e,t)=>{this.userSelectedTracks[t]=!1}))),"conservation"===e?(this.userSelectedTracks.weblogo=!0,this.userSelectedTracks.conservation=!0):"weblogo"===e&&(this.userSelectedTracks.weblogo=!0),this.config.onHeaderHeightChange&&this.config.onHeaderHeightChange(t),window.requestAnimationFrame((()=>this.redraw()))}resetToAutoMode(){this.userSelectedTracks=null;const e=this.tracks.size>0?Xi.WITH_BOTH():Xi.BASE;this.config.onHeaderHeightChange&&this.config.onHeaderHeightChange(e),window.requestAnimationFrame((()=>this.redraw()))}drawColumnTitle(e,t,n,i){this.ctx&&i&&this.config.headerHeight>=Xi.WITH_TITLE()&&(this.ctx.fillStyle="rgba(255, 255, 255, 0.95)",this.ctx.fillRect(e,t,n,Zi.TITLE_HEIGHT),this.ctx.fillStyle=Ui,this.ctx.font="bold 13px Roboto, Roboto Local",this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillText(i,e+n/2,t+Zi.TITLE_HEIGHT/2))}clearHoverStates(){(-1!==this.previousHoverPosition||null!==this.previousHoverTrack||null!==this.previousHoverMonomer)&&(this.previousHoverPosition=-1,this.previousHoverTrack=null,this.previousHoverMonomer=null,this.tracks.forEach((e=>{e instanceof Ki&&e.setHovered(-1,null)})),window.requestAnimationFrame((()=>this.redraw())))}redraw(){this.draw(this.config.x,this.config.y,this.config.width,this.config.height,this.config.currentPosition,this.config.windowStartPosition,{preventDefault:()=>{}},this.seqColumn?.name)}setSelectionData(e,t,n,i){this.dataFrame=e,this.seqColumn=t,this.seqHandler=n,this.onSelectionCallback=i||null}setupTooltipHandling(){this.eventElement.addEventListener("mousemove",this.handleTooltipMouseMove.bind(this)),this.eventElement.addEventListener("mouseleave",this.handleTooltipMouseLeave.bind(this))}handleTooltipMouseMove(e){if(!this.isValid)return;const{x:t,y:n}=this.getCoords(e),i=this.config.positionWidth,o=Math.floor(t/i),s=this.config.windowStartPosition+o-1;if(s<0||s>=this.config.totalPositions)return this.hideTooltip(),void this.clearHoverStates();const a=this.config.headerHeight>=Xi.WITH_TITLE()?Zi.TITLE_HEIGHT:0,l=this.config.headerHeight-Zi.SLIDER_HEIGHT-Zi.DOTTED_CELL_HEIGHT,c=l-Zi.TRACK_GAP;if(n>=l||n<a)return this.hideTooltip(),void this.clearHoverStates();let u=null,h=0;const d=[],p=this.getTrack("weblogo");p&&p.isVisible()&&d.push({id:"weblogo",track:p});const m=this.getTrack("conservation");m&&m.isVisible()&&d.push({id:"conservation",track:m});let g=c;for(const{id:e,track:t}of d){const i=g-t.getHeight();if(n>=i&&n<g){u=e,h=n-i;break}g=i-Zi.TRACK_GAP}let f=null;if(u){const e=this.tracks.get(u);e&&(f=e.getMonomerAt(t,h,s))}if((this.previousHoverPosition!==s||this.previousHoverTrack!==u||this.previousHoverMonomer!==f)&&(this.previousHoverPosition=s,this.previousHoverTrack=u,this.previousHoverMonomer=f,u)){const e=this.tracks.get(u);e instanceof Ki&&(e.setHovered(s,f),window.requestAnimationFrame((()=>this.redraw())))}if((s!==this.currentHoverPosition||u!==this.currentHoverTrack||f!==this.currentHoverMonomer)&&(this.currentHoverPosition=s,this.currentHoverTrack=u,this.currentHoverMonomer=f,u)){const t=this.tracks.get(u);if(t){const n=t.getTooltipContent(s,f);if(n)return void r.tooltip.show(n,e.clientX+16,e.clientY+16)}}u&&f||(this.hideTooltip(),this.clearHoverStates())}handleTooltipMouseLeave(){this.hideTooltip(),this.clearHoverStates(),window.requestAnimationFrame((()=>this.draw(this.config.x,this.config.y,this.config.width,this.config.height,this.config.currentPosition,this.config.windowStartPosition,{preventDefault:()=>{}},this.seqColumn?.name)))}hideTooltip(){this.currentHoverPosition=-1,this.currentHoverTrack=null,r.tooltip.hide()}draw(e,t,n,i,o,s,r,a){if(Object.assign(this.config,{x:e,y:t,width:n,height:i,currentPosition:o,windowStartPosition:s}),!this.isValid)return void(this.eventElement.style.display="none");this.ctx.save(),this.ctx.clearRect(e,t,n,i),this.ctx.translate(e,t),this.ctx.rect(0,0,n,i),this.ctx.clip(),this.determineVisibleTracks();const l=this.config.headerHeight>=Xi.WITH_TITLE();l&&Zi.TITLE_HEIGHT,a&&l&&this.drawColumnTitle(0,0,n,a);const c=i-Zi.SLIDER_HEIGHT,u=c-Zi.DOTTED_CELL_HEIGHT,h=u-Zi.TRACK_GAP,d=[],p=[],m=this.getTrack("weblogo");m&&m.isVisible()&&p.push({id:"weblogo",track:m});const g=this.getTrack("conservation");g&&g.isVisible()&&p.push({id:"conservation",track:g});let f=h;for(const{track:e}of p){const t=e.getHeight(),i=f-t;e.draw(0,i,n,t,this.config.windowStartPosition,this.config.positionWidth,this.config.totalPositions,this.config.currentPosition),d.unshift({y:i,height:t}),f=i-Zi.TRACK_GAP}if(this.drawDottedCells(0,u,n,Zi.DOTTED_CELL_HEIGHT,c),d.push({y:u,height:Zi.DOTTED_CELL_HEIGHT}),this.config.currentPosition>=1&&this.config.currentPosition<=this.config.totalPositions){const e=this.config.positionWidth,t=this.config.currentPosition-this.config.windowStartPosition;if(t>=0&&t<Math.floor(n/e)){const n=t*e+e/2;for(let e=0;e<d.length-1;e++){const t=d[e],i=d[e+1];this.ctx.strokeStyle="rgba(60, 177, 115, 0.4)",this.ctx.lineWidth=1,this.ctx.beginPath(),this.ctx.moveTo(n,t.y+t.height),this.ctx.lineTo(n,i.y),this.ctx.stroke()}}}this.drawTrackButtons(),this.ctx.restore(),r.preventDefault(),this.setupEventElement()}drawDottedCells(e,t,n,i,o){if(!this.ctx)return;const s=this.config.totalPositions,r=this.config.positionWidth,a=this.config.currentPosition,l=this.config.windowStartPosition,c=Math.floor(n/r),u=t+Zi.TOP_PADDING;this.drawSlider(e,o,n);for(let n=0;n<c;n++){const c=l+n;if(c>s)break;const h=e+n*r,d=r,p=h+d/2;this.config.cellBackground&&(this.ctx.fillStyle=n%2==0?"rgba(248, 248, 248, 0.3)":"rgba(242, 242, 242, 0.2)",this.ctx.fillRect(h,t,d,i),this.ctx.strokeStyle="rgba(220, 220, 220, 0.7)",this.ctx.beginPath(),this.ctx.moveTo(h,t),this.ctx.lineTo(h,o),this.ctx.stroke()),this.ctx.fillStyle="#999999",this.ctx.beginPath(),this.ctx.arc(p,u+5,1,0,2*Math.PI),this.ctx.fill(),(c===a||(1===c||c%10==0)&&Math.abs(c-a)>1)&&(this.ctx.fillStyle=Ui,this.ctx.font="12px monospace",this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillText(c.toString(),p,u+15)),c===a&&(this.ctx.fillStyle="rgba(60, 177, 115, 0.2)",this.ctx.fillRect(h,t,d,i))}}drawSlider(e,t,n){if(!this.ctx)return;this.ctx.fillStyle=this.config.sliderColor,this.ctx.fillRect(e,t,n,Zi.SLIDER_HEIGHT);const i=Math.floor(n/this.config.positionWidth),o=this.config.windowStartPosition,s=this.config.totalPositions-i,r=this.sliderWidth,a=s<=0?0:(o-1)/s*(n-r),l=s<=0?n:r;if(this.ctx.fillStyle="rgba(150, 150, 150, 0.5)",this.ctx.fillRect(e+a,t,l,Zi.SLIDER_HEIGHT),this.config.currentPosition>=1&&this.config.currentPosition<=this.config.totalPositions){const i=(this.config.currentPosition-1)/(this.config.totalPositions-1),o=Math.round(i*n);this.ctx.fillStyle="#3CB173",this.ctx.fillRect(e+o-1,t-2,3,Zi.SLIDER_HEIGHT+4)}}setupEventElement(){this.eventElement.style.display="block",this.eventElement.style.left=`${this.config.x}px`,this.eventElement.style.top=`${this.config.y}px`,this.eventElement.style.width=`${this.config.width}px`,this.eventElement.style.height=`${this.config.height}px`}getCoords(e){const t=this.canvas.getBoundingClientRect();return{x:e.clientX-t.left-this.config.x,y:e.clientY-t.top-this.config.y}}isInHeaderArea(e){const{x:t,y:n}=this.getCoords(e);return t>=0&&t<=this.config.width&&n>=0&&n<=this.config.headerHeight}get positionWidth(){return this.config.positionWidth}set positionWidth(e){this.config.positionWidth=e}isInSliderArea(e){const{y:t}=this.getCoords(e),n=this.config.headerHeight-Zi.SLIDER_HEIGHT;return t>n&&t<n+Zi.SLIDER_HEIGHT}get sliderWidth(){const e=this.config.width/this.config.totalPositions*(this.config.width/this.config.positionWidth);return Math.max(e,20)}isInSliderDraggableArea(e){const{x:t,y:n}=this.getCoords(e),i=this.config.headerHeight-Zi.SLIDER_HEIGHT,o=Math.floor(this.config.width/this.config.positionWidth),s=this.config.windowStartPosition,r=this.config.totalPositions-o,a=r<=0?0:(s-1)/r*(this.config.width-this.sliderWidth);return n>i&&n<i+Zi.SLIDER_HEIGHT&&t>=a&&t<a+this.sliderWidth}setupEventListeners(){this.eventElement.addEventListener("mousemove",(e=>{this.isValid&&(this.isInSliderDraggableArea(e)?this.eventElement.style.cursor="grab":this.isInSliderArea(e)||this.isInHeaderArea(e)?this.eventElement.style.cursor="pointer":this.eventElement.style.cursor="default")})),this.eventElement.addEventListener("mousedown",this.handleMouseDown.bind(this)),this.eventElement.addEventListener("mousemove",this.handleMouseMove.bind(this)),this.eventElement.addEventListener("mouseup",this.handleMouseUp.bind(this)),this.eventElement.addEventListener("mouseleave",this.handleMouseUp.bind(this)),this.eventElement.addEventListener("click",this.handleSelectionClick.bind(this)),this.eventElement.addEventListener("click",this.handleClick.bind(this)),this.eventElement.addEventListener("wheel",this.handleMouseWheel.bind(this)),window.addEventListener("keydown",this.handleKeyDown.bind(this))}handleSelectionClick(e){if(!(this.isValid&&this.dataFrame&&this.seqColumn&&this.seqHandler))return;const{x:t,y:n}=this.getCoords(e);if(this.handleTrackButtonClick(t,n))return;if(this.isInsideColumnHeaderArea(t,n))return;const i=this.config.positionWidth,o=Math.floor(t/i),s=this.config.windowStartPosition+o-1;if(s<0||s>=this.config.totalPositions)return;const r=this.config.headerHeight>=Xi.WITH_TITLE()?Zi.TITLE_HEIGHT:0,a=this.config.headerHeight-Zi.SLIDER_HEIGHT-Zi.DOTTED_CELL_HEIGHT,l=a-Zi.TRACK_GAP;if(n>=a||n<r)return;let c=null,u=0;const h=[],d=this.getTrack("weblogo");d&&d.isVisible()&&h.push({id:"weblogo",track:d});const p=this.getTrack("conservation");p&&p.isVisible()&&h.push({id:"conservation",track:p});let m=l;for(const{id:e,track:t}of h){const i=m-t.getHeight();if(n>=i&&n<m){c=e,u=n-i;break}m=i-Zi.TRACK_GAP}if(c){const n=this.tracks.get(c);if(n){const i=n.getMonomerAt(t,u,s);if(i){if(this.onSelectionCallback)return void this.onSelectionCallback(s,i);this.selectRowsWithMonomerAtPosition(s,i),e.stopPropagation(),e.stopImmediatePropagation()}}}}selectRowsWithMonomerAtPosition(e,t){if(this.dataFrame&&this.seqHandler)try{const n=this.dataFrame.selection,i=this.seqHandler.getMonomersAtPosition(e,!0);n.init((e=>i[e]===t))}catch(e){console.error("Error selecting rows:",e)}}init(){if(this.canvas=this.config.canvas,!this.canvas)return void console.error("Canvas not found");const e=this.canvas.getContext("2d");e?(this.ctx=e,this.tracks.forEach((t=>t.init(e)))):console.error("Failed to get 2D context from canvas")}addTrack(e,t){this.ctx&&t.init(this.ctx),this.tracks.set(e,t)}removeTrack(e){this.tracks.delete(e)}getTrack(e){return this.tracks.get(e)}updateTrack(e,t){const n=this.getTrack(e);n&&t(n)}get isValid(){const e=this.gridColumn,t=e?.grid,n=t?.horzScroll?.min||0,i=t?.horzScroll?.max||1e7;return!!this.canvas&&!!this.ctx&&this.config.height>=Xi.WITH_TITLE()&&t&&(Qi(e.left??0,n,i)||Qi(e.right??1/0,n,i))}handleMouseDown(e){if(!this.isValid)return;const{x:t}=this.getCoords(e);this.isInSliderDraggableArea(e)&&(this.state.isDragging=!0,this.state.dragStartX=t,this.handleSliderDrag(t),e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation())}handleMouseWheel(e){if(this.isValid&&this.isInHeaderArea(e)){e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation();const t=e.shiftKey?Math.sign(e.deltaY):Math.sign(e.deltaX||e.deltaY),n=e.shiftKey?3:1,i=this.config.windowStartPosition+t*n,o=Math.floor(this.config.width/this.config.positionWidth),s=this.config.totalPositions-o+1;this.config.windowStartPosition=Math.max(1,Math.min(s,i)),"function"==typeof this.config.onPositionChange&&this.config.onPositionChange(this.config.currentPosition,this.getWindowRange())}}handleMouseMove(e){if(!this.state.isDragging||!this.isValid)return;const t=this.canvas.getBoundingClientRect(),n=e.clientX-t.left-this.config.x;this.handleSliderDrag(n),e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation()}handleKeyDown(e){if(this.isValid&&!(this.config.currentPosition<1)&&document.activeElement?.contains(this.eventElement)&&"block"===this.eventElement.style.display){if("ArrowLeft"===e.key||"ArrowRight"===e.key){e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation();const t="ArrowLeft"===e.key?-1:1,n=Math.min(Math.max(this.config.currentPosition+t,1),this.config.totalPositions);if(n===this.config.currentPosition)return;this.config.currentPosition=n;const i=Math.floor(this.config.width/this.config.positionWidth),o=this.config.windowStartPosition;(n<o||n>o+i-1)&&(this.config.windowStartPosition=t<0?n:Math.max(1,n-i+1))}else{if("Escape"!==e.key)return;this.config.currentPosition=-2,e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation()}"function"==typeof this.config.onPositionChange&&this.config.onPositionChange(this.config.currentPosition,this.getWindowRange())}}handleMouseUp(){this.state.isDragging=!1}handleSliderDrag(e){if(!this.isValid)return;const t=this.sliderWidth,n=this.config.width-t,i=Math.max(0,Math.min(this.config.width,e)),o=Math.floor(this.config.width/this.config.positionWidth),s=Math.floor(this.config.width/this.config.positionWidth),r=this.config.totalPositions-s,a=Math.max(0,i-t/2)/n*r;this.config.windowStartPosition=Math.max(1,Math.min(a,this.config.totalPositions-o+1)),"function"==typeof this.config.onPositionChange&&this.config.onPositionChange(this.config.currentPosition,this.getWindowRange())}get headerHeight(){return this.config.headerHeight}set headerHeight(e){this.config.headerHeight=e}handleClick(e){if(!this.isValid)return;e.clientX,this.canvas.getBoundingClientRect().left,e.clientY,this.canvas.getBoundingClientRect().top;const{x:t,y:n}=this.getCoords(e);if(this.handleTrackButtonClick(t,n))return e.preventDefault(),void e.stopPropagation();if(!this.isInsideColumnHeaderArea(t,n)&&n<this.config.headerHeight-Zi.SLIDER_HEIGHT&&n>=0){const e=this.config.positionWidth,n=Math.round(t/e-.5),i=this.config.windowStartPosition+n;i>=1&&i<=this.config.totalPositions&&(this.config.currentPosition=i,"function"==typeof this.config.onPositionChange&&this.config.onPositionChange(this.config.currentPosition,this.getWindowRange()))}}getWindowRange(){return{start:this.config.windowStartPosition,end:Math.min(this.config.totalPositions,this.config.windowStartPosition+Math.floor(this.config.width/this.config.positionWidth))}}updateConfig(e){Object.assign(this.config,e),this.config.currentPosition=Math.min(this.config.currentPosition,this.config.totalPositions),"function"==typeof this.config.onPositionChange&&this.config.onPositionChange(this.config.currentPosition,this.getWindowRange())}getCurrentPosition(){return this.config.currentPosition}setCurrentPosition(e){this.config.currentPosition=Math.max(1,Math.min(this.config.totalPositions,e)),"function"==typeof this.config.onPositionChange&&this.config.onPositionChange(this.config.currentPosition,this.getWindowRange())}getHeightThresholds(){return{BASE:Xi.BASE,WITH_TITLE:Xi.WITH_TITLE(),WITH_WEBLOGO:Xi.WITH_WEBLOGO(),WITH_BOTH:Xi.WITH_BOTH()}}}function Qi(e,t,n){return e>=t&&e<=n}class eo{static conservationCache=new a.LruCache(100);static webLogoCache=new a.LruCache(100);static lastInvalidationTime=0;static CHUNK_SIZE=50;static clearAllCaches(){eo.conservationCache=new a.LruCache(100),eo.webLogoCache=new a.LruCache(100),eo.lastInvalidationTime=Date.now()}static getLastInvalidationTime(){return eo.lastInvalidationTime}static getChunkCacheKey(e,t,n){const i=e.dataFrame;return`${i.id}_${e.name}_f${i.filter.version}_${t}_${n}`}static getConservationChunk(e,t,n,i){return eo.conservationCache.getOrCreate(i,(()=>{const o=eo.getWebLogoChunk(e,t,n,i),s=new Array(n-t).fill(0);for(let i=t;i<n;i++){const n=o.get(i);if(!n||0===n.size)continue;let r=0,a=0;const l=e.defaultGapOriginal;for(const[e,t]of n.entries())e&&e!==l&&(r+=t,t>a&&(a=t));s[i-t]=r>0?a/r:0}return s}))}static getWebLogoChunk(e,t,n,i){return eo.webLogoCache.getOrCreate(i,(()=>{const i=e.column.dataFrame,o=new Map,s=i.filter.trueCount;if(s<=1)return o;for(let e=t;e<n;e++)o.set(e,new Map);const r=i.filter,a=1/s;for(let i=-1;-1!==(i=r.findNext(i,!0));){const s=e.getSplitted(i).getOriginalRegion(t,n);if(0!==s.length)for(let e=0;e<s.length;e++){const n=s[e],i=o.get(t+e);i.set(n,(i.get(n)||0)+a)}}return o}))}static getConservationForViewport(e,t,n,i){const o=new Array(i).fill(0),s=Math.floor(t/eo.CHUNK_SIZE)*eo.CHUNK_SIZE,r=Math.ceil(n/eo.CHUNK_SIZE)*eo.CHUNK_SIZE;for(let t=s;t<r;t+=eo.CHUNK_SIZE){const n=Math.min(t+eo.CHUNK_SIZE,i),s=eo.getChunkCacheKey(e.column,t,n),r=eo.getConservationChunk(e,t,n,s);for(let e=0;e<r.length&&t+e<i;e++)o[t+e]=r[e]}return o}static getWebLogoForViewport(e,t,n,i){const o=new Map,s=Math.floor(t/eo.CHUNK_SIZE)*eo.CHUNK_SIZE,r=Math.ceil(n/eo.CHUNK_SIZE)*eo.CHUNK_SIZE;for(let t=s;t<r;t+=eo.CHUNK_SIZE){const n=Math.min(t+eo.CHUNK_SIZE,i),s=eo.getChunkCacheKey(e.column,t,n),r=eo.getWebLogoChunk(e,t,n,s);for(const[e,t]of r.entries())e<i&&o.set(e,t)}return o}}class to extends Ki{seqHandler;maxLength;lastViewportStart=-1;lastViewportEnd=-1;lastInvalidationTime=0;forceNextUpdate=!1;constructor(e,t,n=45,i="WebLogo"){super(new Map,n,"",i),this.seqHandler=e,this.maxLength=t,this.visible=e.column.dataFrame.filter.trueCount>1}forceUpdate(){this.forceNextUpdate=!0}resetViewportTracking(){this.lastViewportStart=-1,this.lastViewportEnd=-1}updateForViewport(e,t){const n=eo.getLastInvalidationTime(),i=n>this.lastInvalidationTime;if(!(Math.abs(this.lastViewportStart-e)>=10||Math.abs(this.lastViewportEnd-t)>=10||i||this.forceNextUpdate))return;this.forceNextUpdate=!1,this.lastViewportStart=e,this.lastViewportEnd=t,this.lastInvalidationTime=n;const o=Math.max(0,e-20),s=Math.min(this.maxLength,t+20),r=eo.getWebLogoForViewport(this.seqHandler,o,s,this.maxLength);this.updateData(r)}draw(e,t,n,i,o,s,r,a){const l=Math.ceil(n/s)+2,c=Math.min(o+l,r);this.updateForViewport(o-1,c-1),super.draw(e,t,n,i,o,s,r,a)}}class no extends zi{seqHandler;maxLength;lastViewportStart=-1;lastViewportEnd=-1;lastInvalidationTime=0;forceNextUpdate=!1;constructor(e,t,n=45,i="default",o="Conservation"){super([],n,i,o),this.seqHandler=e,this.maxLength=t,this.visible=e.column.dataFrame.filter.trueCount>1}forceUpdate(){this.forceNextUpdate=!0}resetViewportTracking(){this.lastViewportStart=-1,this.lastViewportEnd=-1}updateForViewport(e,t){const n=eo.getLastInvalidationTime(),i=n>this.lastInvalidationTime;if(!(Math.abs(this.lastViewportStart-e)>=10||Math.abs(this.lastViewportEnd-t)>=10||i||this.forceNextUpdate))return;this.forceNextUpdate=!1,this.lastViewportStart=e,this.lastViewportEnd=t,this.lastInvalidationTime=n;const o=Math.max(0,e-20),s=Math.min(this.maxLength,t+20),r=eo.getConservationForViewport(this.seqHandler,o,s,this.maxLength);this.updateData(r)}draw(e,t,n,i,o,s,r,a){const l=Math.ceil(n/s)+2,c=Math.min(o+l,r);this.updateForViewport(o-1,c-1),super.draw(e,t,n,i,o,s,r,a)}}var io=function(e,t,n,i){var o,s=arguments.length,r=s<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 a=e.length-1;a>=0;a--)(o=e[a])&&(r=(s<3?o(r):s>3?o(t,n,r):o(t,n))||r);return s>3&&r&&Object.defineProperty(t,n,r),r},oo=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},so=function(e,t){return function(n,i){t(n,i,e)}};const ro=new ai;let ao=null;class lo{static async getMonomerLibHelper(){return await dn.getInstance()}static async initBio(){null===ao&&(ao=async function(){const e="Bio: _package.initBio()";ro.logger.debug(`${e}, start`);const t=window.performance.now(),n=await(0,Pe.j)(),i=await ro.getProperties(),o=new ri(i);ro.properties=o;const r=await dn.getInstance(),l=await(0,Ie.ub)();l.explicit&&(l.explicit=[],await(0,Ie.Eu)(l)),await r.awaitLoaded(1/0),r.initialLoadCompleted||await r.loadMonomerLib(),r.loadMonomerSets();const c=r.getMonomerLib(),h=r.getMonomerSets(),d=window.performance.now();ro.logger.debug(`${e}, loading ET: ${d-t} ms`);const p=new Bi(r,n);ro.completeInit(p,c,h,n),ro.logger.debug(`${e}, end`),function(){const e=e=>{setTimeout((()=>{if(e.isDetached)return;const t=e.dataFrame;if(!t)return;const n=t.columns.bySemTypeAll(a.SEMTYPE.MACROMOLECULE);for(const i of n){let n=null;try{n=ro.seqHelper.getSeqHandler(i)}catch(e){continue}if(!n)continue;if(n.isHelm()||n.alphabet===ge.YI.UN)continue;const o=e.col(i.name);if(!o)continue;let r=!!e.tableView&&Array.from(e.tableView.viewers).some((e=>"Sequence Position Statistics"===e.type));if(n.isMsa()){const l=(e,t)=>Number.isNaN(e)?t:e,c=()=>l(Math.max(Number.parseInt(i.getTag(ge.gp.positionShift)??"0"),0),0)+1,h=()=>l(Number.parseInt(i.getTag(ge.gp.selectedPosition)??"-2"),-2),d=()=>$e.Jy.getFontSettings(i).fontWidth;let p=0,m=0;const g=i.categories;for(let e=0;e<g.length;e++){const t=g[e];t&&t.length>m&&(m=t.length,p=e)}const f=g[p],y=n.splitter(f),b=y?y.length:30,w={WITH_TITLE:58,WITH_WEBLOGO:107,WITH_BOTH:156};let v;v=i.length>1e5||b<50?w.WITH_TITLE:i.length>5e4?w.WITH_WEBLOGO:w.WITH_BOTH;let A=null,C=null;const T=a.debounce(u.merge(t.onFilterChanged,t.onDataChanged.pipe((0,H.filter)((e=>e?.args?.column===i)))),100).subscribe((()=>{eo.clearAllCaches(),A&&(A.resetViewportTracking(),A.forceUpdate()),C&&(C.resetViewportTracking(),C.forceUpdate()),setTimeout((()=>{e.isDetached||e.invalidate()}),50)}));e.sub(T);const S=s=>{const l=[],u=new no(n,b,45,"default","Conservation");C=u,l.push({id:"conservation",track:u,priority:1});const p=new to(n,b,45,"WebLogo");A=p,s&&(p.setMonomerLib(s),p.setBiotype(n.defaultBiotype||"HELM_AA")),p.setupDefaultTooltip(),l.push({id:"weblogo",track:p,priority:2});const m=new Ji({canvas:e.overlay,headerHeight:v,totalPositions:b+1,onPositionChange:(t,n)=>{setTimeout((()=>{const o=c(),s=h();if(o!==n.start&&i.setTag(ge.gp.positionShift,(n.start-1).toString()),s!==t&&(i.setTag(ge.gp.selectedPosition,t.toString()),t>=0&&!r&&e.tableView&&R()(e.dataFrame?.columns.numerical).find((e=>!0)))){r=!0;const t=e.tableView.addViewer("Sequence Position Statistics",{sequenceColumnName:i.name});e.tableView.dockManager.dock(t,a.DOCK_TYPE.DOWN,null,"Sequence Position Statistics",.4)}}))},onHeaderHeightChange:t=>{e.isDetached||t<w.WITH_TITLE||setTimeout((()=>e.props.colHeaderHeight=t))}},o);m.setupTooltipHandling(),l.forEach((({id:e,track:t})=>{m.addTrack(e,t)})),m.setSelectionData(t,i,n),b>50&&(e.props.colHeaderHeight=v,setTimeout((()=>{e.isDetached||(o.width=400)}),300)),e.sub(e.onCellRender.subscribe((e=>{const t=e.cell;if(!t||!t.isColHeader||t?.gridColumn?.name!==o?.name)return;const n=e.bounds;if(!n)return;m.headerHeight=n.height;const s=d();m.positionWidth=s+8;const r=c();m.draw(n.x,n.y,n.width,n.height,h(),r,e,i.name)})))};(0,ye.pj)().then((e=>{const t=e.getMonomerLib();S(t)})).catch((e=>{s.shell.warning("Failed to initialize monomer library"),console.error("Failed to initialize monomer library:",e)}))}}}),1e3)},t=(s.events.onViewerAdded.subscribe((t=>{if(!(t.args&&t.args.viewer instanceof a.Grid))return;const n=t.args.viewer;e(n)})),s.shell.tableViews);for(const n of t){const t=n?.grid;t&&e(t)}}()}()),await ao}static sequenceTooltip(e){const t=new hi(e,ro.seqHelper);return t.init().then((()=>{})).catch((e=>{const t=e instanceof Error?e.message:e.toString();s.shell.error(t)})),t}static getBioLib(){return ro.monomerLib}static getSeqHandler(e){return ro.seqHelper.getSeqHandler(e)}static getRegionPanel(e){const t="getRegionTopMenu",n=a.Func.find({package:ro.name,name:t});if(1!==n.length)throw new Error(`Package '${ro.name}' func '${t}' not found`);const i=n[0].prepare({table:e.dataFrame,sequence:e});return new gi(i,ro.seqHelper).widget()}static async libraryPanel(e){return async function(){const e=r.label("Manage monomer libraries");return mn()(e).addClass("d4-link-action"),e.onclick=async()=>await Bn(),new a.Widget(e)}()}static GetRegionEditor(e){try{new gi(e,ro.seqHelper).dialog()}catch(e){const t=e instanceof Error?e.message:e.toString(),n=e instanceof Error?e.stack:void 0;s.shell.error(`Get region editor error: ${t}`),ro.logger.error(t,void 0,n)}}static SplitToMonomersEditor(e){const t=new ei;r.dialog({title:"Split to Monomers"}).add(t.paramsUI).onOK((async()=>e.func.prepare(t.funcParams).call(!0))).show()}static SequenceSpaceEditor(e){const t=new O({semtype:a.SEMTYPE.MACROMOLECULE}),n=r.dialog({title:"Sequence Space"}).add(t.getEditor()).onOK((async()=>{const n=t.getParams();return e.func.prepare({molecules:n.col,table:n.table,methodName:n.methodName,similarityMetric:n.similarityMetric,plotEmbeddings:n.plotEmbeddings,options:n.options,preprocessingFunction:n.preprocessingFunction,clusterEmbeddings:n.clusterEmbeddings}).call()}));n.history((()=>({editorSettings:t.getStringInput()})),(e=>t.applyStringInput(e.editorSettings))),n.show()}static SeqActivityCliffsEditor(e){const t=new Ce({semtype:a.SEMTYPE.MACROMOLECULE}),n=r.dialog({title:"Activity Cliffs"}).add(t.getEditor()).onOK((async()=>{const n=t.getParams();return e.func.prepare({table:n.table,molecules:n.col,activities:n.activities,similarity:n.similarityThreshold,methodName:n.methodName,similarityMetric:n.similarityMetric,preprocessingFunction:n.preprocessingFunction,options:n.options}).call()}));n.history((()=>({editorSettings:t.getStringInput()})),(e=>t.applyStringInput(e.editorSettings))),n.show()}static customSequenceCellRenderer(){return new je}static fastaSequenceCellRenderer(){return new je}static separatorSequenceCellRenderer(){return new je}static macroMolColumnPropertyPanel(e){return function(e){const t=Array.from(e.dataFrame.columns).filter((e=>e.semType===a.SEMTYPE.MOLECULE)).map((e=>e.name));new Set(t).delete(e.name);let n=ro.properties?ro.properties.maxMonomerLength:4;if(Re.gp.maxMonomerLength in e.tags){const t=parseInt(e.getTag(Re.gp.maxMonomerLength));n=isNaN(t)?n:t}if(".mm.cellRenderer.maxMonomerLength"in e.temp){const t=parseInt(e.temp[".mm.cellRenderer.maxMonomerLength"]);n=isNaN(t)?n:t}const i=r.input.int("Max Monomer Length",{value:n,nullable:!0,min:1,max:50,step:1,onValueChanged:t=>{if(0==t)setTimeout((()=>{i.value=null}),0);else{const n=t??"",i=null==n?"":n.toString();e.temp[".mm.cellRenderer.maxMonomerLength"]=i,e.temp[".mm.cellRenderer.settingsChanged"]=De.s.true,e.dataFrame.fireValuesChanged()}},tooltipText:"The max length of monomer symbol displayed without shortening, empty to no limit"});let o=ro.properties?ro.properties.fontSize:12;".mm.cellRenderer.fontSize"in e.temp&&e.temp[".mm.cellRenderer.fontSize"]&&!isNaN(e.temp[".mm.cellRenderer.fontSize"])&&(o=e.temp[".mm.cellRenderer.fontSize"]);const s=r.input.int("Font Size",{value:o,nullable:!0,min:1,max:50,step:1,onValueChanged:t=>{if(t&&t>0){const n=t??12;e.temp[".mm.cellRenderer.fontSize"]=n,e.temp[".mm.cellRenderer.settingsChanged"]=De.s.true,e.dataFrame.fireValuesChanged()}},tooltipText:"The font size of monomer symbol in sequence renderer"}),l=r.input.int("Monomer Margin",{value:e.temp[".mm.cellRenderer.gapLength"]??0,onValueChanged:t=>{e.temp[".mm.cellRenderer.gapLength"]=t,e.temp[".mm.cellRenderer.settingsChanged"]=De.s.true,e.dataFrame.fireValuesChanged()},tooltipText:"The size of margin between monomers (in pixels)"}),c=r.input.bool("Color Code",{value:null==e?.temp["color-code"]||e.temp["color-code"],onValueChanged:t=>{e.temp["color-code"]=t,e.dataFrame.fireValuesChanged()},tooltipText:"Color code"}),u=r.input.string("Reference Sequence",{value:null!=e?.temp["reference-sequence"]?e?.temp["reference-sequence"]:"",nullable:!0,onValueChanged:t=>{e.temp["reference-sequence"]=t,e.dataFrame.fireValuesChanged()},tooltipText:"Reference sequence is not empty, then the sequence will be render \nas a difference from the reference sequence"}),h=r.input.bool("Compare with current",{value:null==e?.temp["compare-with-current"]||e.temp["compare-with-current"],onValueChanged:t=>{e.temp["compare-with-current"]=t,e.dataFrame.fireValuesChanged()},tooltipText:'When on, all sequences get rendered in the "diff" mode'});let d=null;(()=>{const t=e.meta.units;return t!==ge.Hi.HELM&&t!==ge.Hi.CUSTOM})()&&(d=r.input.bool("Multiline Rendering",{value:"true"===e.getTag("renderMultiline"),onValueChanged:t=>{e.tags.renderMultiline=t?"true":"false",e.dataFrame.fireValuesChanged()},tooltipText:"Render sequences across multiple lines when they exceed cell width"}));const p=[s,i,l,u,c,h];d&&p.push(d);const m=r.inputs(p);return new a.Widget(m)}(e)}static compositionAnalysisWidget(e){return function(e,t,n){const i=r.div();i.classList.add("macromolecule-cell-comp-analysis-host");const o=e.cell.column.tags[ge.gp.alphabet],s=o===ge.YI.DNA||o===ge.YI.RNA?Fe.o.NUCLEOTIDE:Fe.o.AA,l={},c=n.getSeqHandler(e.cell.column),u=e.cell.rowIndex,h=c.getSplitted(u);R().count(0).take(h.length).filter((e=>!h.isGap(e))).forEach((e=>{let t=h.getCanonical(e);s===Fe.o.NUCLEOTIDE&&c.isHelm()&&"("===t[1]&&")"===t[t.length-2]&&(t=t.substring(2,t.length-2));const n=l[t]||0;l[t]=n+1}));const d=(0,ui.F)(l,s,t);return Array.from(d.rows).forEach((e=>{const t=e.getElementsByClassName("macromolecule-cell-comp-analysis-bar")[0].style.backgroundColor;e.cells[0].style.color=t})),i.appendChild(d),new a.Widget(i)}(e,ro.monomerLib,ro.seqHelper)}static macromoleculeDifferenceCellRenderer(){return new ze}static sequenceAlignment(e,t,n,i,o){const s=new ht(i,o,n,t);return"Local alignment"==e?s.smithWaterman():s.needlemanWunsch()}static webLogoViewer(){return new it.oP}static vdRegionsViewer(){return new lt}static getRegion(e,t,n,i){return di(e,t??null,n??null,i??null)}static async getRegionTopMenu(e,t,n,i,o){const r=di(t,n??null,i??null,o??null);t.dataFrame.columns.add(r),await s.data.detectSemanticTypes(t.dataFrame)}static async activityCliffs(e,t,n,i,o,u,h,d,p){if(e.name!==s.shell.tv.dataFrame.name)return void s.shell.error(`Table ${e.name} is not a current table view`);if(!(0,Zn.V)(t,"Activity Cliffs"))return;const m=Me(e),g={units:t.meta.units,aligned:t.getTag(ge.gp.aligned),separator:t.getTag(ge.gp.separator),alphabet:t.getTag(ge.gp.alphabet)},f=u,y=t,b=async()=>await de(e,y,m,"Activity cliffs",n,i,f,o,{...d??{}},a.SEMTYPE.MACROMOLECULE,g,h,mt,gt,wt,void 0,p),w=o===c.c.UMAP?2e5:2e4,v=o===c.c.UMAP?5e3:2e3;if(e.rowCount>w)return void s.shell.warning(`Too many rows, maximum for sequence activity cliffs is ${w}`);const A=a.TaskBarProgressIndicator.create("Running sequence activity cliffs ..."),C=await new Promise(((t,n)=>{e.rowCount>v&&!d?.[l.vb]?r.dialog().add(r.divText("Activity cliffs analysis might take several minutes.\n Do you want to continue?")).onOK((async()=>{b().then((e=>t(e))).catch((e=>n(e)))})).onCancel((()=>{t(void 0)})).show():b().then((e=>t(e))).catch((e=>n(e)))})).catch((e=>{const[t,n]=(0,ve.AP)(e);throw ro.logger.error(t,void 0,n),e})).finally((()=>{A.close()}));return C?.props?.xColumnName&&C?.props?.yColumnName&&e.col(C.props.xColumnName)&&e.col(C.props.yColumnName)&&(e.col(C.props.xColumnName).set(0,e.col(C.props.xColumnName).get(0)),e.col(C.props.yColumnName).set(0,e.col(C.props.yColumnName).get(0))),C}static async macromoleculePreprocessingFunction(e,t,n=1,i=.6,o="Morgan"){if(e.semType!==a.SEMTYPE.MACROMOLECULE)return{entries:e.toList(),options:{}};const{seqList:s,options:r}=await dt(e,t,o,n,i);return{entries:s,options:r}}static async helmPreprocessingFunction(e,t){e.version!==e.temp["last-invalidated-version"]&&await(0,pt.BQ)(e,ro.seqHelper,!1);const n=e.temp["monomeric-mols"],i=await s.functions.call("Chem:getMorganFingerprints",{molColumn:n}),o=new Array(i.length).fill(null);for(let e=0;e<i.length;e++){if(i.isNone(e)||!i.get(e))continue;const t=i.get(e);o[e]=W.A.fromUint32Array(t.length,new Uint32Array(t.getBuffer().buffer))}return{entries:o,options:{}}}static async sequenceSpaceTopMenu(e,t,n,i,o,r,c,u,h){if(e.name!==s.shell.tv.dataFrame.name)return void s.shell.error(`Table ${e.name} is not a current table view`);const d=s.shell.tv.dataFrame==e?s.shell.tv:void 0;return(0,Zn.V)(t,"Sequence Space")?(r||(r=a.Func.find({name:"macromoleculePreprocessingFunction",package:"Bio"})[0]),c??={},await Le(e,[t],n,[i],[1],[r],"MANHATTAN",o,u??!1,{...c,preprocessingFuncArgs:[c.preprocessingFuncArgs??{}]},{fastRowCount:1e4,scatterPlotName:"Sequence space",bypassLargeDataWarning:c?.[l.vb],tableView:d})):void 0}static async toAtomicLevel(e,t,n,i=!1){const o=a.TaskBarProgressIndicator.create("Converting to atomic level ...");try{await ao;const o=t.temp[".mm.cellRenderer.overriddenLibrary"]??ro.monomerLib,s=ro.seqHelper,r=ro.rdKitModule;await(0,fi.V)(e,t,n,i,o,s,r)}finally{o.close()}}static async toAtomicLevelAction(e){if(!e?.dataFrame)throw new Error("Sequence column is not found or its data frame is not empty");const t=a.Func.find({name:"toAtomicLevel",package:"Bio"})[0];if(!t)throw new Error("To Atomic level Function not found");t.prepare({table:e.dataFrame,seqCol:e}).edit()}static async toAtomicLevelPanel(e){return async function(e){const t=await Vi(e);if(t.errorText||!t.mol)return a.Widget.fromRoot(r.divText(t.errorText??"No structure generated"));try{const e=a.SemanticValue.fromValueType(t.mol,a.SEMTYPE.MOLECULE),n=r.panels.infoPanel(e);let i=null;n&&(i=a.Widget.fromRoot(n.root));const o=s.chem.drawMolecule(t.mol,300,300,!1);return o.style.cursor="pointer",r.tooltip.bind(o,"Click to expand"),o.onclick=()=>{const e=window.innerWidth-200,n=window.innerHeight-200,i=s.chem.drawMolecule(t.mol,e,n,!1);r.dialog({title:"Molecule"}).add(i).showModal(!0)},i&&i.root.prepend(o),i??a.Widget.fromRoot(o)}catch(e){ro.logger.error(e)}return a.Widget.fromRoot(r.divText("No structure generated"))}(e)}static async sequence3dStructureWidget(e){return async function(e){const t=a.TaskBarProgressIndicator.create("Creating 3D view");let n,i="";try{await(a.Func.find({name:"getPdbHelper"})[0]?.apply({}));try{const o=await Vi(e);if(o.errorText||!o.mol)return n=r.divText(o.errorText??"No structure generated"),t.close(),new a.Widget(n);const l=o.mol;i=await s.functions.call("Bio:Embed",{molecule:l});const c=vi.Molecule.fromMolfile(i);c?i=c.toMolfile():console.warn("Failed to convert molv3 to molv2")}catch(e){console.warn(e)}try{i=i.replaceAll("\\n","\n");const e=new Blob([i],{type:"text/plain"}),t=r.div([],{classes:"d4-ngl-viewer",id:"ngl-3d-host"});t.style.setProperty("height","100%","important");const o=new NGL.Stage(t,{backgroundColor:"white"});o.loadFile(e,{ext:"sdf"}).then((function(e){o.setSize(300,300),e.addRepresentation("ball+stick"),e.autoView()})),n=r.div([t],{style:{aspectRatio:"1"}})}catch(e){n=r.divText("Couldn't get 3D structure")}}catch(e){n=r.divText("Couldn't get 3D structure")}return t.close(),new a.Widget(n)}(e)}static multipleSequenceAlignmentDialog(){(0,Jn.D)({},ro.seqHelper).catch((e=>{const[t,n]=(0,ve.AP)(e);if(e instanceof Xn.Ap)return s.shell.warning(e.element),void ro.logger.warning(t);s.shell.error(t),ro.logger.error(t,void 0,n)}))}static async alignSequences(e=null,t=null,n){return(0,Jn.D)({col:e,clustersCol:t,...n},ro.seqHelper)}static async compositionAnalysis(){const e=s.shell.tv,t=e.dataFrame.columns.toList().filter((e=>e.semType==a.SEMTYPE.MACROMOLECULE&&(ro.seqHelper.getSeqHandler(e),!0))),n=async t=>{if(!(0,Zn.V)(t,"Composition"))return;const n=e.addViewer("WebLogo",{sequenceColumnName:t.name});s.shell.tv.dockManager.dock(n,a.DOCK_TYPE.DOWN,null,"Composition analysis",.25)};let i=null;if(0!=t.length){if(t.length>1){const e=t.map((e=>e.name)),i=t.find((e=>ro.seqHelper.getSeqHandler(e).isMsa())),o=r.input.choice("Column",{value:i?i.name:e[0],items:e});r.dialog({title:"Composition Analysis",helpUrl:"https://datagrok.ai/help/datagrok/solutions/domains/bio/#sequence-composition"}).add(r.div([o])).onOK((async()=>{const e=t.find((e=>e.name==o.value))??null;e&&await n(e)})).show()}else i=t[0];i&&await n(i)}else s.shell.error("Current table does not contain sequences")}static importFasta(e){return new fe.m(e).importFasta()}static importBam(e){return console.log(e),[]}static convertDialog(){const e=(0,Ne.me)()[0];(0,Mt.C)(e,ro.seqHelper)}static convertColumnAction(e){(0,Mt.C)(e,ro.seqHelper)}static monomerCellRenderer(){return new oi}static async testDetectMacromolecule(e){const t=a.TaskBarProgressIndicator.create("Test detectMacromolecule..."),n=(await s.dapi.files.list(e,!0,"")).filter((e=>e.fileName.endsWith(".csv")));let i=0;const o=[];for(const r of n)try{const t=await s.dapi.files.readAsText(e+r.fullPath),n=a.DataFrame.fromCsv(t);for(const e of n.columns)await s.functions.call("Bio:detectMacromolecule",{col:e})===a.SEMTYPE.MACROMOLECULE&&o.push({file:r.path,result:"detected",column:e.name,message:`units: ${e.meta.units}`})}catch(e){o.push({file:r.path,result:"error",column:null,message:e instanceof Error?e.message:e.toString()})}finally{i+=1,t.update(100*i/n.length,`Test ${r.fileName}`)}s.shell.info("Test Demo:Files for detectMacromolecule finished."),t.close();const r=a.DataFrame.fromObjects(o);return r.name=`datasets_detectMacromolecule_${e}`,r}static async splitToMonomersTopMenu(e,t){return await async function(e,t){if(await(0,Qe.cb)(10),!(0,Zn.V)(t,"Sequence space"))return e;const n=ro.seqHelper,i=(0,be.R)(t,n);i.name="splitToMonomers";const o=t.dataFrame;for(const e of i.columns)e.semType=Ve.uF.MONOMER,e.setTag(we.gp.alphabet,t.getTag(we.gp.alphabet));const r=/(\d+)(?: \((\d+)\))?/,l=e=>{r.lastIndex=0;const t=e.match(r);return t?`${t[1]} (${parseInt(t[2]??"0")+1})`:e};for(let e=0;e<i.columns.length;e++){const n=i.columns.byIndex(e);n.semType=Ve.uF.MONOMER,n.setTag(we.gp.alphabet,t.getTag(we.gp.alphabet));const s=100;let r=0;for(;o.columns.byName(n.name)&&r<s;)n.name=l(n.name),r++;o.columns.add(n)}await s.data.detectSemanticTypes(o);for(let e=0;e<i.columns.length;e++){const t=i.columns.byIndex(e);t.setTag(a.TAGS.CELL_RENDERER,"Monomer"),t.setTag(".use-as-filter","false")}return o}(e,t)}static getHelmMonomers(e){return ro.seqHelper.getSeqMonomers(e)}static similaritySearchViewer(){return new Tt(ro.seqHelper)}static similaritySearchTopMenu(){const e=s.shell.v,t=e.addViewer("Sequence Similarity Search");e.dockManager.dock(t,"down")}static diversitySearchViewer(){return new St(ro.seqHelper)}static diversitySearchTopMenu(){const e=s.shell.v,t=e.addViewer("Sequence Diversity Search");e.dockManager.dock(t,"down")}static searchSubsequenceEditor(e){const t=(0,Ne.me)();1===t.length?e.func.prepare({macromolecules:t[0]}).call(!0):new pt.a7(t,ro.seqHelper)}static SubsequenceSearchTopMenu(e){s.shell.tv.getFiltersGroup({createDefaultFilters:!1}).updateOrAdd({type:"Bio:bioSubstructureFilter",column:e.name,columnName:e.name}),s.shell.tv.grid.scrollToCell(e,0)}static async sequenceIdentityScoring(e,t,n){const i=ro.seqHelper;return yi(e,t,n,pe.IDENTITY,i)}static async sequenceSimilarityScoring(e,t,n){const i=ro.seqHelper;return yi(e,t,n,pe.SIMILARITY,i)}static async manageMonomerLibraries(){Bn()}static async manageLibrariesView(){await Vn()}static async manageMonomersView(){const e=await Mn.getInstance();await e.getViewRoot()}static async manageMonomerLibrariesView(){return await Vn(!1)}static async manageMonomerLibrariesViewTreeBrowser(e,t){(await(await dn.getInstance()).getFileManager()).getValidLibraryPaths().forEach((t=>{const n=t.endsWith(".json")?t.substring(0,t.length-5):t;e.item(n).onSelected.subscribe((async()=>{const e=await Mn.getInstance();await e.getViewRoot(t,!0),e.resetCurrentRowFollowing()}))}))}static saveAsFasta(){(0,xt.TE)()}static bioSubstructureFilter(){return new Lt._i(ro.seqHelper,ro.logger)}static bioSubstructureFilterTest(){return new Lt._i(ro.seqHelper,ro.logger)}static async webLogoLargeApp(){const e=a.TaskBarProgressIndicator.create("WebLogo");try{const e=new URLSearchParams(window.location.search),t=new Qn(e,"webLogoLargeApp"),n=await ro.files.readCsv("data/sample_PT_100000x5.csv");await s.data.detectSemanticTypes(n),await t.init(n)}finally{e.close()}}static async webLogoAggApp(){const e=a.TaskBarProgressIndicator.create("WebLogo ...");try{const e=new URLSearchParams(window.location.search),t=new Qn(e,"webLogoAggApp"),n=await ro.files.readCsv("samples/FASTA_PT_activity.csv");await s.data.detectSemanticTypes(n),await t.init(n)}finally{e.close()}}static async getRegionApp(){const e=a.TaskBarProgressIndicator.create("getRegion ...");try{const e=new URLSearchParams(window.location.search),t=new mi(e,"getRegionApp");await t.init()}finally{e.close()}}static async getRegionHelmApp(){const e=a.TaskBarProgressIndicator.create("getRegion ...");try{const e=new URLSearchParams(window.location.search),t=await ro.files.readCsv("samples/HELM_empty_vals.csv"),n=new mi(e,"getRegionHelmApp");await n.init({df:t,colName:"HELM"})}finally{e.close()}}static longSeqTableSeparator(){const e=a.DataFrame.fromColumns((0,_e.dW)());s.shell.addTableView(e)}static longSeqTableFasta(){const e=a.DataFrame.fromColumns([(0,_e.Hx)(ro.seqHelper,ge.Hi.FASTA)]);s.shell.addTableView(e)}static longSeqTableHelm(){const e=a.DataFrame.fromColumns([(0,_e.Hx)(ro.seqHelper,ge.Hi.HELM)]);s.shell.addTableView(e)}static addCopyMenu(e,t){!function(e,t,n){const i=Object.values(ge.Hi).filter((e=>e!==ge.Hi.CUSTOM));t.group("Copy").items(i,(t=>{const i=e.column,o=e.rowIndex,r=n.getSeqHandler(i),a=t===ge.Hi.SEPARATOR?ro.properties.defaultSeparator??"-":void 0,l=r.getJoiner({notation:t,separator:a})(r.getSplitted(o));navigator.clipboard?(navigator.clipboard.writeText(l),s.shell.info(`Value of notation '${t}' copied to clipboard`)):s.shell.warning("The clipboard functionality requires a secure origin — either HTTPS or localhost")}))}(e,t,ro.seqHelper)}static async demoBioSimilarityDiversity(){await async function(){const e=await ro.files.readCsv("samples/peptides-non-natural.csv");e.name="Similarity and Diversity Demo",e.col("activity").setTag("format","3 significant digits"),e.col("sequence").temp[".mm.cellRenderer.maxMonomerLength"]=4;const t=s.shell.addTableView(e);await e.meta.detectSemanticTypes(),await s.data.detectSemanticTypes(e);const n=t.addViewer("Sequence Similarity Search",{limit:20}),i=t.dockManager.dock(n,a.DOCK_TYPE.RIGHT,null,"Similarity search",.45);(0,Ne.Kd)(t.grid,"sequence",500,30);const o=t.addViewer("Sequence Diversity Search",{limit:20});t.dockManager.dock(o,a.DOCK_TYPE.DOWN,i,"Diversity search",.4),s.functions.call("Dendrogram:HierarchicalClustering",{df:s.shell.t,colNameList:["sequence"],distance:"euclidian",linkage:"complete"})}()}static async demoBioSequenceSpace(){await async function(){const e=await s.functions.eval("Bio:SeqSpaceDemo"),t=await s.dapi.projects.find(e.id);await t.open(),s.shell.windows.help.showHelp("/help/datagrok/solutions/domains/bio/bio.md#sequence-space")}()}static async demoBioActivityCliffs(){await async function(){const e=await ro.files.readCsv("tests/helm_cyclic_cliffs.csv");e.name="Activity Cliffs Demo",await s.data.detectSemanticTypes(e),await e.meta.detectSemanticTypes();const t=s.shell.addTableView(e);r.setUpdateIndicator(t.root,!0);try{const n=a.Func.find({name:"macromoleculePreprocessingFunction",package:"Bio"})[0],i=await lo.activityCliffs(e,e.getCol("Sequence"),e.getCol("Activity"),96,c.c.UMAP,me.Z.MONOMER_CHEMICAL_DISTANCE,n,{},!0);t.dockManager.dock(i,a.DOCK_TYPE.RIGHT,null,"Activity Cliffs",.65),await a.delay(100),mn()(i.root).find("button.scatter_plot_link,cliffs_grid").get()[0].click(),await a.delay(100),t.grid.props.rowHeight=180,t.grid.col("sequence")&&(t.grid.col("sequence").width=300),t.grid.col("structure")&&(t.grid.col("structure").width=300);const o=Array.from(t.viewers).find((e=>e!==t.grid&&e.type===a.VIEWER.GRID));o&&(o.props.rowHeight=40,o.col("seq_diff").width=600,t.dockManager.dock(o,a.DOCK_TYPE.DOWN,null,"Cliffs",.35),t.dockManager.dock(i,a.DOCK_TYPE.RIGHT,null,"Activity Cliffs",.55))}catch(e){!function(e){const t=e instanceof Error?e.message:e.toString(),n=e instanceof Error?e.stack:void 0;s.shell.error(t),ro.logger.error(e.message,void 0,n)}(e)}finally{r.setUpdateIndicator(t.root,!1)}s.shell.windows.help.showHelp("/help/datagrok/solutions/domains/bio/bio.md#activity-cliffs")}()}static async demoBioAtomicLevel(){await async function(){const e=await ro.files.readCsv("samples/HELM_BI_CYCLIC.csv");e.name="To Atomic Level",await e.meta.detectSemanticTypes(),await s.data.detectSemanticTypes(e);const t=s.shell.addTableView(e),n=e.col("HELM");await lo.toAtomicLevel(e,n,!0,!1),(0,Ne.Kd)(t.grid,"molfile(HELM)",500,300,!0),(0,Ne.Kd)(t.grid,"HELM",500,void 0,!0),s.shell.info("Hover over monomers in HELM column to highlight them in molecular structure.",{timeout:10}),s.shell.windows.help.showHelp("/help/datagrok/solutions/domains/bio/bio.md#get-atomic-level-structure")}()}static async sdfToJsonLib(e){const t=(0,ye.uX)(e),n=JSON.stringify(t);a.Utils.download(`${e.name}.json`,n)}static async seq2atomic(e,t){if(!e.trim())return"";try{const n=a.Column.fromList(a.COLUMN_TYPE.STRING,"helm",[e]),i=a.DataFrame.fromColumns([n]),o=await s.functions.call("Bio:detectMacromolecule",{col:n});o&&(n.semType=o);const r=(await lo.getMonomerLibHelper()).getMonomerLib(),l=ro.seqHelper,c=await(0,Pe.j)(),u=(await(0,fi.V)(i,n,t,!1,r,l,c))?.molCol?.get(0);return u??void 0}catch(e){const[t,n]=(0,ve.AP)(e);throw ro.logger.error(t,void 0,n),e}}static async seqIdentity(e,t){if(!e.trim())return null;try{const n=a.Column.fromList(a.COLUMN_TYPE.STRING,"seq",[e]),i=a.DataFrame.fromColumns([n]);if(!await s.functions.call("Bio:detectMacromolecule",{col:n}))throw new Error("Macromolecule required");return(await yi(i,n,t,pe.IDENTITY,ro.seqHelper)).get(0)}catch(e){const[t,n]=(0,ve.AP)(e);throw ro.logger.error(t,void 0,n),e}}static async detectMacromoleculeProbe(e,t="",n=100){const i=await e.readAsString();await async function(e,t,n){const i=a.TaskBarProgressIndicator.create("detectMacromolecule probe ...");try{let o=0;const r=await s.functions.call("Bio:detectMacromoleculeEnableStore");let l=0;for(let c=0;c<n;++c){const u=a.DataFrame.fromCsv(e),h=t?u.getCol(t):u.columns.byIndex(0);await s.functions.call("Bio:detectMacromolecule",{col:h})!==a.SEMTYPE.MACROMOLECULE&&(++l,console.warn(`Reject reason: ${r.last.rejectReason}`));const d=c/n;d-o>=.1&&(o=d,i.update(100*d,`detectMacromolecule probe ${l}/${c}/${n} ...`),await(0,Qe.cb)(0))}l>0?s.shell.warning(`detectMacromolecule failed ${l} / ${n}`):s.shell.info(`detectMacromolecule success ${n}`)}finally{i.close()}}(i,t,n)}static async getSeqHelper(){return await lo.initBio(),ro.seqHelper}static async getMolFromHelm(e,t,n=!0){return async function(e,t,n=!0,i){const o=ro.seqHelper,s=(await o.getHelmToMolfileConverter(i)).convertToRdKitBeautifiedMolfileColumn(t,n,ro.rdKitModule,i);return s.semType=a.SEMTYPE.MOLECULE,s}(0,t,n,ro.monomerLib)}}io([s.decorators.func({description:"Returns an instance of the monomer library helper",outputs:[{type:"object",name:"result"}]}),oo("design:type",Function),oo("design:paramtypes",[]),oo("design:returntype",Promise)],lo,"getMonomerLibHelper",null),io([s.decorators.init({}),oo("design:type",Function),oo("design:paramtypes",[]),oo("design:returntype",Promise)],lo,"initBio",null),io([s.decorators.func({tags:["tooltip"]}),so(0,s.decorators.param({options:{semType:"Macromolecule"}})),oo("design:type",Function),oo("design:paramtypes",[a.Column]),oo("design:returntype",a.Widget)],lo,"sequenceTooltip",null),io([s.decorators.func({outputs:[{type:"object",name:"monomerLib"}]}),oo("design:type",Function),oo("design:paramtypes",[]),oo("design:returntype",Object)],lo,"getBioLib",null),io([s.decorators.func({outputs:[{type:"object",name:"result"}]}),so(0,s.decorators.param({type:"column",options:{semType:"Macromolecule"}})),oo("design:type",Function),oo("design:paramtypes",[a.Column]),oo("design:returntype",Object)],lo,"getSeqHandler",null),io([s.decorators.panel({name:"Bioinformatics | Get Region",description:"Creates a new column with sequences of the region between start and end"}),so(0,s.decorators.param({type:"column",options:{semType:"Macromolecule"}})),oo("design:type",Function),oo("design:paramtypes",[a.Column]),oo("design:returntype",a.Widget)],lo,"getRegionPanel",null),io([s.decorators.panel({name:"Bioinformatics | Manage Monomer Libraries",tags:["exclude-actions-panel"]}),so(0,s.decorators.param({name:"seqColumn",options:{semType:"Macromolecule"}})),oo("design:type",Function),oo("design:paramtypes",[a.Column]),oo("design:returntype",Promise)],lo,"libraryPanel",null),io([s.decorators.editor({}),oo("design:type",Function),oo("design:paramtypes",[a.FuncCall]),oo("design:returntype",void 0)],lo,"GetRegionEditor",null),io([s.decorators.editor({}),oo("design:type",Function),oo("design:paramtypes",[a.FuncCall]),oo("design:returntype",void 0)],lo,"SplitToMonomersEditor",null),io([s.decorators.editor({}),oo("design:type",Function),oo("design:paramtypes",[a.FuncCall]),oo("design:returntype",void 0)],lo,"SequenceSpaceEditor",null),io([s.decorators.editor({}),oo("design:type",Function),oo("design:paramtypes",[a.FuncCall]),oo("design:returntype",void 0)],lo,"SeqActivityCliffsEditor",null),io([s.decorators.func({name:"customSequenceCellRenderer",tags:["cellRenderer"],meta:{cellType:"sequence",columnTags:"quality=Macromolecule, units=custom"},outputs:[{type:"grid_cell_renderer",name:"result"}]}),oo("design:type",Function),oo("design:paramtypes",[]),oo("design:returntype",a.GridCellRenderer)],lo,"customSequenceCellRenderer",null),io([s.decorators.func({name:"fastaSequenceCellRenderer",tags:["cellRenderer"],meta:{cellType:"sequence",columnTags:"quality=Macromolecule, units=fasta"},outputs:[{type:"grid_cell_renderer",name:"result"}]}),oo("design:type",Function),oo("design:paramtypes",[]),oo("design:returntype",je)],lo,"fastaSequenceCellRenderer",null),io([s.decorators.func({name:"separatorSequenceCellRenderer",tags:["cellRenderer"],meta:{cellType:"sequence",columnTags:"quality=Macromolecule, units=separator"},outputs:[{type:"grid_cell_renderer",name:"result"}]}),oo("design:type",Function),oo("design:paramtypes",[]),oo("design:returntype",je)],lo,"separatorSequenceCellRenderer",null),io([s.decorators.panel({name:"Bioinformatics | Sequence Renderer"}),so(0,s.decorators.param({options:{semType:"Macromolecule"}})),oo("design:type",Function),oo("design:paramtypes",[a.Column]),oo("design:returntype",a.Widget)],lo,"macroMolColumnPropertyPanel",null),io([s.decorators.panel({name:"Composition analysis",tags:["bio","widgets"]}),so(0,s.decorators.param({options:{semType:"Macromolecule"}})),oo("design:type",Function),oo("design:paramtypes",[a.SemanticValue]),oo("design:returntype",a.Widget)],lo,"compositionAnalysisWidget",null),io([s.decorators.func({name:"MacromoleculeDifferenceCellRenderer",tags:["cellRenderer"],meta:{cellType:"MacromoleculeDifference",columnTags:"quality=MacromoleculeDifference"},outputs:[{type:"grid_cell_renderer",name:"result"}]}),oo("design:type",Function),oo("design:paramtypes",[]),oo("design:returntype",ze)],lo,"macromoleculeDifferenceCellRenderer",null),io([s.decorators.func({outputs:[{type:"object",name:"result"}]}),so(0,s.decorators.param({options:{choices:["Local alignment","Global alignment"]}})),so(1,s.decorators.param({options:{choices:["AUTO","NUCLEOTIDES","BLOSUM45","BLOSUM50","BLOSUM62","BLOSUM80","BLOSUM90","PAM30","PAM70","PAM250","SCHNEIDER","TRANS"]}})),oo("design:type",Function),oo("design:paramtypes",[String,String,Number,String,String]),oo("design:returntype",void 0)],lo,"sequenceAlignment",null),io([s.decorators.panel({name:"WebLogo",description:"WebLogo",tags:["viewer"],meta:{icon:"files/icons/weblogo-viewer.svg"},outputs:[{type:"viewer",name:"result"}]}),oo("design:type",Function),oo("design:paramtypes",[]),oo("design:returntype",void 0)],lo,"webLogoViewer",null),io([s.decorators.panel({name:"VdRegions",description:"V-Domain regions viewer",tags:["viewer"],meta:{icon:"files/icons/vdregions-viewer.svg"},outputs:[{type:"viewer",name:"result"}]}),oo("design:type",Function),oo("design:paramtypes",[]),oo("design:returntype",void 0)],lo,"vdRegionsViewer",null),io([s.decorators.func({name:"getRegion",description:"Gets a new column with sequences of the region between start and end"}),so(0,s.decorators.param({type:"column"})),so(1,s.decorators.param({type:"string",options:{optional:!0}})),so(2,s.decorators.param({type:"string",options:{optional:!0}})),so(3,s.decorators.param({type:"string",options:{optional:!0,description:"Name of the column to be created"}})),oo("design:type",Function),oo("design:paramtypes",[a.Column,Object,Object,Object]),oo("design:returntype",a.Column)],lo,"getRegion",null),io([s.decorators.func({name:"Get Region Top Menu",description:"Get sequences for a region specified from a Macromolecule","top-menu":"Bio | Calculate | Get Region...",editor:"Bio:GetRegionEditor"}),so(0,s.decorators.param({options:{description:"Input data table"}})),so(1,s.decorators.param({options:{semType:"Macromolecule",description:"Sequence column"}})),so(2,s.decorators.param({type:"string",options:{optional:!0,description:"Region start position name"}})),so(3,s.decorators.param({type:"string",options:{optional:!0,description:"Region end position name"}})),so(4,s.decorators.param({type:"string",options:{optional:!0,description:"Region column name"}})),oo("design:type",Function),oo("design:paramtypes",[a.DataFrame,a.Column,Object,Object,Object]),oo("design:returntype",Promise)],lo,"getRegionTopMenu",null),io([s.decorators.func({name:"Sequence Activity Cliffs",description:"Detects pairs of molecules with similar structure and significant difference in any given property","top-menu":"Bio | Analyze | Activity Cliffs...",editor:"Bio:SeqActivityCliffsEditor",outputs:[]}),so(0,s.decorators.param({options:{description:"Input data table"}})),so(1,s.decorators.param({type:"string",options:{semType:"Macromolecule",description:"Input data table"}})),so(3,s.decorators.param({options:{initialValue:"80",description:"Similarity cutoff"}})),so(4,s.decorators.param({type:"string",options:{choices:["UMAP","t-SNE"]}})),so(5,s.decorators.param({type:"string",options:{choices:["Hamming","Levenshtein","Monomer chemical distance"]}})),so(6,s.decorators.param({type:"func"})),so(7,s.decorators.param({type:"object",options:{optional:!0}})),so(8,s.decorators.param({options:{optional:!0}})),oo("design:type",Function),oo("design:paramtypes",[a.DataFrame,a.Column,a.Column,Number,String,String,a.Func,Object,Boolean]),oo("design:returntype",Promise)],lo,"activityCliffs",null),io([s.decorators.func({name:"Encode Sequences",tags:["dim-red-preprocessing-function"],meta:{supportedSemTypes:"Macromolecule",supportedTypes:"string",supportedDistanceFunctions:"Hamming,Levenshtein,Monomer chemical distance,Needlemann-Wunsch"},outputs:[{type:"object",name:"result"}]}),so(0,s.decorators.param({options:{semType:"Macromolecule"}})),so(1,s.decorators.param({type:"string"})),so(2,s.decorators.param({options:{initialValue:"1",caption:"Gap open penalty",optional:!0}})),so(3,s.decorators.param({options:{initialValue:"0.6",caption:"Gap extension penalty",optional:!0}})),so(4,s.decorators.param({options:{caption:"Fingerprint type",initialValue:"Morgan",choices:["Morgan","RDKit","Pattern","AtomPair","MACCS","TopologicalTorsion"],optional:!0}})),oo("design:type",Function),oo("design:paramtypes",[a.Column,String,Number,Number,String]),oo("design:returntype",Promise)],lo,"macromoleculePreprocessingFunction",null),io([s.decorators.func({name:"Helm Fingerprints",meta:{supportedSemTypes:"Macromolecule",supportedTypes:"string",supportedUnits:"helm",supportedDistanceFunctions:"Tanimoto,Asymmetric,Cosine,Sokal"},outputs:[{type:"object",name:"result"}]}),so(0,s.decorators.param({type:"column",options:{semType:"Macromolecule"}})),so(1,s.decorators.param({type:"string"})),oo("design:type",Function),oo("design:paramtypes",[a.Column,String]),oo("design:returntype",Promise)],lo,"helmPreprocessingFunction",null),io([s.decorators.func({name:"Sequence Space",description:"Creates 2D sequence space with projected sequences by pairwise distance","top-menu":"Bio | Analyze | Sequence Space...",editor:"Bio:SequenceSpaceEditor",outputs:[]}),so(1,s.decorators.param({options:{semType:"Macromolecule"}})),so(2,s.decorators.param({type:"string",options:{choices:["UMAP","t-SNE"]}})),so(3,s.decorators.param({type:"string",options:{choices:["Hamming","Levenshtein","Monomer chemical distance"]}})),so(4,s.decorators.param({options:{initialValue:"true"}})),so(5,s.decorators.param({type:"func",options:{optional:!0}})),so(6,s.decorators.param({type:"object",options:{optional:!0}})),so(7,s.decorators.param({options:{optional:!0,initialValue:"true"}})),so(8,s.decorators.param({options:{optional:!0}})),oo("design:type",Function),oo("design:paramtypes",[a.DataFrame,a.Column,String,String,Boolean,a.Func,Object,Boolean,Boolean]),oo("design:returntype",Promise)],lo,"sequenceSpaceTopMenu",null),io([s.decorators.func({name:"To Atomic Level",description:"Converts sequences to molblocks","top-menu":"Bio | Transform | To Atomic Level..."}),so(0,s.decorators.param({options:{description:"Input data table"}})),so(1,s.decorators.param({options:{semType:"Macromolecule",caption:"Sequence"}})),so(2,s.decorators.param({options:{initialValue:"false",caption:"Non-linear",description:"Slower mode for cycling/branching HELM structures"}})),so(3,s.decorators.param({options:{initialValue:"false",caption:"Highlight monomers",description:"Highlight monomers' substructures of the molecule"}})),oo("design:type",Function),oo("design:paramtypes",[a.DataFrame,a.Column,Boolean,Boolean]),oo("design:returntype",Promise)],lo,"toAtomicLevel",null),io([s.decorators.func({name:"To Atomic Level...",meta:{action:"to atomic level"}}),so(0,s.decorators.param({options:{semType:"Macromolecule"}})),oo("design:type",Function),oo("design:paramtypes",[a.Column]),oo("design:returntype",Promise)],lo,"toAtomicLevelAction",null),io([s.decorators.panel({name:"Molecular Structure",tags:["bio","widgets"]}),so(0,s.decorators.param({name:"sequence",type:"semantic_value",options:{semType:"Macromolecule"}})),oo("design:type",Function),oo("design:paramtypes",[a.SemanticValue]),oo("design:returntype",Promise)],lo,"toAtomicLevelPanel",null),io([s.decorators.panel({name:"Molecular 3D Structure",tags:["bio","widgets"]}),so(0,s.decorators.param({type:"semantic_value",options:{semType:"Macromolecule"}})),oo("design:type",Function),oo("design:paramtypes",[a.SemanticValue]),oo("design:returntype",Promise)],lo,"sequence3dStructureWidget",null),io([s.decorators.panel({name:"MSA",description:"Performs multiple sequence alignment",tags:["bio"],"top-menu":"Bio | Analyze | MSA..."}),oo("design:type",Function),oo("design:paramtypes",[]),oo("design:returntype",void 0)],lo,"multipleSequenceAlignmentDialog",null),io([s.decorators.func({name:"Multiple Sequence Alignment",description:"Multiple sequence alignment",tags:["bio"]}),so(0,s.decorators.param({type:"column",options:{semType:"Macromolecule"}})),so(1,s.decorators.param({type:"column"})),so(2,s.decorators.param({type:"object",options:{optional:!0}})),oo("design:type",Function),oo("design:paramtypes",[Object,Object,Object]),oo("design:returntype",Promise)],lo,"alignSequences",null),io([s.decorators.func({name:"Composition Analysis",description:"Visualizes sequence composition on a WebLogo plot","top-menu":"Bio | Analyze | Composition",meta:{icon:"files/icons/composition-analysis.svg"},outputs:[{name:"result",type:"viewer"}]}),oo("design:type",Function),oo("design:paramtypes",[]),oo("design:returntype",Promise)],lo,"compositionAnalysis",null),io([s.decorators.fileHandler({name:"importFasta",description:"Opens FASTA file",ext:"fasta, fna, ffn, faa, frn, fa, fst"}),oo("design:type",Function),oo("design:paramtypes",[String]),oo("design:returntype",Array)],lo,"importFasta",null),io([s.decorators.fileHandler({name:"importBam",description:"Opens Bam file",ext:"bam, bai"}),oo("design:type",Function),oo("design:paramtypes",[String]),oo("design:returntype",Array)],lo,"importBam",null),io([s.decorators.func({name:"convertDialog","top-menu":"Bio | Transform | Convert Notation..."}),oo("design:type",Function),oo("design:paramtypes",[]),oo("design:returntype",void 0)],lo,"convertDialog",null),io([s.decorators.func({name:"Convert Notation...",meta:{action:"Convert Notation..."}}),so(0,s.decorators.param({options:{semType:"Macromolecule"}})),oo("design:type",Function),oo("design:paramtypes",[a.Column]),oo("design:returntype",void 0)],lo,"convertColumnAction",null),io([s.decorators.func({name:"monomerCellRenderer",tags:["cellRenderer"],meta:{cellType:"Monomer",columnTags:"quality=Monomer"},outputs:[{type:"grid_cell_renderer",name:"result"}]}),oo("design:type",Function),oo("design:paramtypes",[]),oo("design:returntype",oi)],lo,"monomerCellRenderer",null),io([s.decorators.func({name:"testDetectMacromolecule"}),so(0,s.decorators.param({options:{choices:["Demo:Files/","System:AppData/"]}})),oo("design:type",Function),oo("design:paramtypes",[String]),oo("design:returntype",Promise)],lo,"testDetectMacromolecule",null),io([s.decorators.func({name:"Split to Monomers","top-menu":"Bio | Transform | Split to Monomers...",editor:"Bio:SplitToMonomersEditor"}),so(1,s.decorators.param({options:{semType:"Macromolecule"}})),oo("design:type",Function),oo("design:paramtypes",[a.DataFrame,a.Column]),oo("design:returntype",Promise)],lo,"splitToMonomersTopMenu",null),io([s.decorators.func({name:"Bio: getHelmMonomers",outputs:[{name:"result",type:"object"}]}),so(0,s.decorators.param({type:"column",options:{semType:"Macromolecule"}})),oo("design:type",Function),oo("design:paramtypes",[a.Column]),oo("design:returntype",Array)],lo,"getHelmMonomers",null),io([s.decorators.func({name:"Sequence Similarity Search",tags:["viewer"],meta:{icon:"files/icons/sequence-similarity-viewer.svg"},outputs:[{name:"result",type:"viewer"}]}),oo("design:type",Function),oo("design:paramtypes",[]),oo("design:returntype",Tt)],lo,"similaritySearchViewer",null),io([s.decorators.func({name:"similaritySearch",description:"Finds similar sequences","top-menu":"Bio | Search | Similarity Search",outputs:[{name:"result",type:"viewer"}]}),oo("design:type",Function),oo("design:paramtypes",[]),oo("design:returntype",void 0)],lo,"similaritySearchTopMenu",null),io([s.decorators.func({name:"Sequence Diversity Search",tags:["viewer"],meta:{icon:"files/icons/sequence-diversity-viewer.svg"},outputs:[{name:"result",type:"viewer"}]}),oo("design:type",Function),oo("design:paramtypes",[]),oo("design:returntype",St)],lo,"diversitySearchViewer",null),io([s.decorators.func({name:"diversitySearch",description:"Finds the most diverse sequences","top-menu":"Bio | Search | Diversity Search",outputs:[{name:"result",type:"viewer"}]}),oo("design:type",Function),oo("design:paramtypes",[]),oo("design:returntype",void 0)],lo,"diversitySearchTopMenu",null),io([s.decorators.editor({name:"SearchSubsequenceEditor"}),oo("design:type",Function),oo("design:paramtypes",[a.FuncCall]),oo("design:returntype",void 0)],lo,"searchSubsequenceEditor",null),io([s.decorators.func({name:"Subsequence Search","top-menu":"Bio | Search | Subsequence Search ...",editor:"Bio:SearchSubsequenceEditor"}),oo("design:type",Function),oo("design:paramtypes",[a.Column]),oo("design:returntype",void 0)],lo,"SubsequenceSearchTopMenu",null),io([s.decorators.func({name:"Identity Scoring",description:"Adds a column with fraction of matching monomers","top-menu":"Bio | Calculate | Identity..."}),so(0,s.decorators.param({options:{description:"Table containing Macromolecule column"}})),so(1,s.decorators.param({options:{semType:"Macromolecule",description:"Sequences to score"}})),so(2,s.decorators.param({options:{description:"Sequence,matching column format"}})),oo("design:type",Function),oo("design:paramtypes",[a.DataFrame,a.Column,String]),oo("design:returntype",Promise)],lo,"sequenceIdentityScoring",null),io([s.decorators.func({name:"Similarity Scoring",description:"Adds a column with similarity scores, calculated as sum of monomer fingerprint similarities","top-menu":"Bio | Calculate | Similarity..."}),so(0,s.decorators.param({options:{description:"Table containing Macromolecule column"}})),so(1,s.decorators.param({options:{semType:"Macromolecule",description:"Sequences to score"}})),so(2,s.decorators.param({options:{description:"Sequence,matching column format"}})),oo("design:type",Function),oo("design:paramtypes",[a.DataFrame,a.Column,String]),oo("design:returntype",Promise)],lo,"sequenceSimilarityScoring",null),io([s.decorators.func({name:"Manage Monomer Libraries",description:"Manage HELM monomer libraries"}),oo("design:type",Function),oo("design:paramtypes",[]),oo("design:returntype",Promise)],lo,"manageMonomerLibraries",null),io([s.decorators.func({name:"Manage Monomer Libraries View","top-menu":"Bio | Manage | Monomer Libraries"}),oo("design:type",Function),oo("design:paramtypes",[]),oo("design:returntype",Promise)],lo,"manageLibrariesView",null),io([s.decorators.func({name:"manageMonomersView",description:"Edit and create monomers","top-menu":"Bio | Manage | Monomers"}),oo("design:type",Function),oo("design:paramtypes",[]),oo("design:returntype",Promise)],lo,"manageMonomersView",null),io([s.decorators.app({name:"Manage Monomer Libraries",browsePath:"Peptides",icon:"files/icons/monomers.png"}),oo("design:type",Function),oo("design:paramtypes",[]),oo("design:returntype",Promise)],lo,"manageMonomerLibrariesView",null),io([s.decorators.func({name:"Monomer Manager Tree Browser"}),oo("design:type",Function),oo("design:paramtypes",[a.TreeViewGroup,a.BrowsePanel]),oo("design:returntype",Promise)],lo,"manageMonomerLibrariesViewTreeBrowser",null),io([s.decorators.fileExporter({description:"As FASTA..."}),oo("design:type",Function),oo("design:paramtypes",[]),oo("design:returntype",void 0)],lo,"saveAsFasta",null),io([s.decorators.func({name:"Bio Substructure Filter",description:"Substructure filter for macromolecules",tags:["filter"],meta:{semType:"Macromolecule"},outputs:[{type:"filter",name:"result"}]}),oo("design:type",Function),oo("design:paramtypes",[]),oo("design:returntype",Lt._i)],lo,"bioSubstructureFilter",null),io([s.decorators.func({name:"Bio Substructure Filter Test",description:"Substructure filter for Helm package tests",outputs:[{name:"result",type:"object"}]}),oo("design:type",Function),oo("design:paramtypes",[]),oo("design:returntype",Lt._i)],lo,"bioSubstructureFilterTest",null),io([s.decorators.func(),oo("design:type",Function),oo("design:paramtypes",[]),oo("design:returntype",Promise)],lo,"webLogoLargeApp",null),io([s.decorators.func(),oo("design:type",Function),oo("design:paramtypes",[]),oo("design:returntype",Promise)],lo,"webLogoAggApp",null),io([s.decorators.func(),oo("design:type",Function),oo("design:paramtypes",[]),oo("design:returntype",Promise)],lo,"getRegionApp",null),io([s.decorators.func(),oo("design:type",Function),oo("design:paramtypes",[]),oo("design:returntype",Promise)],lo,"getRegionHelmApp",null),io([s.decorators.func(),oo("design:type",Function),oo("design:paramtypes",[]),oo("design:returntype",void 0)],lo,"longSeqTableSeparator",null),io([s.decorators.func(),oo("design:type",Function),oo("design:paramtypes",[]),oo("design:returntype",void 0)],lo,"longSeqTableFasta",null),io([s.decorators.func(),oo("design:type",Function),oo("design:paramtypes",[]),oo("design:returntype",void 0)],lo,"longSeqTableHelm",null),io([s.decorators.func(),so(0,s.decorators.param({type:"object"})),so(1,s.decorators.param({type:"object"})),oo("design:type",Function),oo("design:paramtypes",[a.Cell,a.Menu]),oo("design:returntype",void 0)],lo,"addCopyMenu",null),io([s.decorators.demo({description:"Sequence similarity tracking and evaluation dataset diversity",demoPath:"Bioinformatics | Similarity, Diversity",path:"/apps/Tutorials/Demo/Bioinformatics/Similarity,%20Diversity",demoSkip:"GROK-14320"}),oo("design:type",Function),oo("design:paramtypes",[]),oo("design:returntype",Promise)],lo,"demoBioSimilarityDiversity",null),io([s.decorators.demo({description:"Exploring sequence space of Macromolecules, comparison with hierarchical clustering results",demoPath:"Bioinformatics | Sequence Space",path:"/apps/Tutorials/Demo/Bioinformatics/Sequence%20Space",demoSkip:"GROK-14320"}),oo("design:type",Function),oo("design:paramtypes",[]),oo("design:returntype",Promise)],lo,"demoBioSequenceSpace",null),io([s.decorators.demo({description:"Activity Cliffs analysis on Macromolecules data",demoPath:"Bioinformatics | Activity Cliffs",path:"/apps/Tutorials/Demo/Bioinformatics/Activity%20Cliffs",demoSkip:"GROK-14320"}),oo("design:type",Function),oo("design:paramtypes",[]),oo("design:returntype",Promise)],lo,"demoBioActivityCliffs",null),io([s.decorators.demo({description:"Atomic level structure of Macromolecules",demoPath:"Bioinformatics | Atomic Level",path:"/apps/Tutorials/Demo/Bioinformatics/Atomic%20Level",demoSkip:"GROK-14320"}),oo("design:type",Function),oo("design:paramtypes",[]),oo("design:returntype",Promise)],lo,"demoBioAtomicLevel",null),io([s.decorators.func({name:"SDF to JSON Library"}),oo("design:type",Function),oo("design:paramtypes",[a.DataFrame]),oo("design:returntype",Promise)],lo,"sdfToJsonLib",null),io([s.decorators.func({friendlyName:"seq2atomic",description:"Converts a `Macromolecule` sequence to its atomic level `Molecule` representation",outputs:[{name:"molfile",type:"string",options:{semType:"Molecule"}}]}),so(0,s.decorators.param({options:{semType:"Macromolecule"}})),oo("design:type",Function),oo("design:paramtypes",[String,Boolean]),oo("design:returntype",Promise)],lo,"seq2atomic",null),io([s.decorators.func({name:"seqIdentity",friendlyName:"seqIdentity",description:"Gets identity to a reference sequence"}),so(0,s.decorators.param({options:{semType:"Macromolecule"}})),so(1,s.decorators.param({options:{semType:"Macromolecule"}})),oo("design:type",Function),oo("design:paramtypes",[String,String]),oo("design:returntype",Promise)],lo,"seqIdentity",null),io([s.decorators.func(),so(2,s.decorators.param({options:{initialValue:"100"}})),oo("design:type",Function),oo("design:paramtypes",[a.FileInfo,String,Number]),oo("design:returntype",Promise)],lo,"detectMacromoleculeProbe",null),io([s.decorators.func({outputs:[{type:"object",name:"result"}]}),oo("design:type",Function),oo("design:paramtypes",[]),oo("design:returntype",Promise)],lo,"getSeqHelper",null),io([s.decorators.func(),so(1,s.decorators.param({type:"column"})),so(2,s.decorators.param({options:{initialValue:"true"}})),oo("design:type",Function),oo("design:paramtypes",[a.DataFrame,a.Column,Boolean]),oo("design:returntype",Promise)],lo,"getMolFromHelm",null)},4954:(e,t,n)=>{"use strict";n.d(t,{a7:()=>m,if:()=>f,BQ:()=>y,nI:()=>g});var i=n(4328),o=n(7389),s=n(6082),r=n(8070),a=n(2003),l=n(439);const c=31;async function u(e,t,n=!1,o){const r=t.getSeqHandler(e);let a;o??=new Map;const l=r.isHelm()?t.getSeqMonomers(e):Object.keys(r.stats.freq).filter((e=>""!==e));for(let e=0;e<l.length;e++)o.has(l[e])||o.set(l[e],`${o.size+1}`);if(r.isHelm())a=await i.functions.call("HELM:getMolFiles",{col:e}),a=function(e,t,n=!1){const i=new Array(e.length);for(let o=0;o<e.length;o++){let s=0,r=0,a="\n Datagrok macromolecule handler\n\n 0 0 0 0 0 0 999 V3000\nM V30 BEGIN CTAB\n";const l=e.get(o);s=l.indexOf("\n",s)+1,s=l.indexOf("\n",s)+1,s=l.indexOf("\n",s)+1;const u=parseInt(l.substring(s,s+3)),h=parseInt(l.substring(s+3,s+6));a+=`M V30 COUNTS ${u} ${h} 0 0 0\n`,a+="M V30 BEGIN ATOM\n";for(let e=0;e<u;e++){s=l.indexOf("\n",s)+1+c,r=l.indexOf(" ",s);const i=l.substring(s,r);a+=n?`M V30 ${e+1} R${t.get(i)} 0.000 0.000 0 0\n`:`M V30 ${e+1} At 0.000 0.000 0 0 MASS=${t.get(i)}\n`}a+="M V30 END ATOM\n",a+="M V30 BEGIN BOND\n";for(let e=0;e<h;e++){s=l.indexOf("\n",s)+1;const t=parseInt(l.substring(s,s+3).trim()),n=parseInt(l.substring(s+3,s+6).trim());a+=`M V30 ${e+1} ${parseInt(l.substring(s+6,s+9).trim())} ${t} ${n}\n`}a+="M V30 END BOND\n",a+="M V30 END CTAB\n",a+="M END",i[o]=a}return i}(a,o,n);else{a=new Array(e.length);for(let t=0;t<e.length;t++){const e=h(r.getSplitted(t),o,n);a[t]=e}}return s.Column.fromStrings("monomericMols",a)}function h(e,t,n=!1){let i="\n Datagrok macromolecule handler\n\n 0 0 0 0 0 0 999 V3000\nM V30 BEGIN CTAB\n";i+=`M V30 COUNTS ${e.length} ${e.length?e.length-1:0} 0 0 0\n`,i+="M V30 BEGIN ATOM\n";for(let o=0;o<e.length;o++){const s=e.getCanonical(o);s!==l._S&&(i+=n?`M V30 ${o+1} R${t.get(s)} 0.000 0.000 0 0\n`:`M V30 ${o+1} At 0.000 0.000 0 0 MASS=${t.get(s)}\n`)}i+="M V30 END ATOM\n",i+="M V30 BEGIN BOND\n";for(let t=0;t<e.length-1;t++)i+=`M V30 ${t+1} 1 ${t+1} ${t+2}\n`;return i+="M V30 END BOND\n",i+="M V30 END CTAB\n",i+="M END",i}var d=n(4870);const p="substr_helm";class m{seqHelper;units;separator;inputsDiv;substructureInput;separatorInput;editHelmLink;columnsInput;grid;col;dialog;constructor(e,t){this.seqHelper=t,this.col=e[0],this.createUI()}editHelmLinkAction(){(0,d.Ku)(this.inputsDiv,this.grid.root),o.tools.waitForElementInDom(this.grid.root).then((()=>{setTimeout((()=>{this.grid.cell(p,0).element.children[0].dispatchEvent(new KeyboardEvent("keydown",{key:"Enter"}))}),100)}))}updateInputs(){const e=this.units===a.Hi.HELM?o.divV([this.columnsInput,this.editHelmLink]):this.units===a.Hi.SEPARATOR?o.inputs([this.columnsInput,this.substructureInput,this.separatorInput]):o.inputs([this.columnsInput,this.substructureInput]);(0,d.Ku)(this.inputsDiv,e)}updateNotationDiv(){this.units=this.col.meta.units,this.separator=this.col.getTag(a.gp.separator);const e=this.dialog.root.getElementsByClassName("notation-text")[0];e&&(e.textContent=`Notation: ${this.units}`)}createUI(){const e=i.shell.tv.dataFrame;this.columnsInput=o.input.column("Column",{table:e,value:this.col,onValueChanged:e=>{this.col=e,this.updateNotationDiv(),this.updateInputs()},filter:e=>e.semType===s.SEMTYPE.MACROMOLECULE}),this.substructureInput=o.input.string("Substructure",{value:""}),this.editHelmLink=o.link("Edit helm",(()=>this.editHelmLinkAction()),void 0,{style:{position:"relative",left:"95px"}});const t=s.DataFrame.create(1);t.columns.addNewString(p).init((e=>"")),t.col(p).semType=this.col.semType,t.col(p).meta.units=a.Hi.HELM,this.grid=t.plot.grid(),this.separatorInput=o.input.string("Separator",{value:this.separator}),this.inputsDiv=o.div(),this.units=this.col.meta.units,this.separator=this.col.getTag(a.gp.separator),this.updateInputs(),this.dialog=o.dialog("Substructure Search").add(o.divV([o.divText(`Notation: ${this.units}`,"notation-text"),this.inputsDiv])).onOK((async()=>{let e,n=this.units===a.Hi.HELM?t.get(p,0):this.substructureInput.value;this.units===a.Hi.SEPARATOR&&this.separatorInput.value!==this.separator&&this.separatorInput.value&&(n=n.replaceAll(this.separatorInput.value,this.separator)),e=this.units===a.Hi.HELM?await f(n,this.col,this.seqHelper):g(n,this.col),this.col.dataFrame.filter.and(e)})).show()}}function g(e,t,n){const i=n?function(e,t){const n=`${t}`.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),i=e.charAt(0)===t,o=e.charAt(e.length-1)===t,s=e.replace(new RegExp(`^${n}|${n}$`,"g"),"");return i?o?`${n}${s}${n}`:`${n}${s}${n}|${n}${s}$`:o?`^${s}${n}|${n}${s}${n}`:`^${s}${n}|${n}${s}${n}|${n}${s}$`}(e,n):e,o=s.BitSet.create(t.length);for(let n=0;n<t.length;n++){const s=t.get(n);(s.match(i)||s===e)&&o.set(n,!0,!1)}return o}async function f(e,t,n){t.version!==t.temp["last-invalidated-version"]&&await y(t,n,!0);const o=s.Column.string("helm",1).init((t=>e));o.semType=s.SEMTYPE.MACROMOLECULE,o.meta.units=a.Hi.HELM;const r=await u(o,n,!0,t.temp["monomers-dict"]);return(await i.functions.call("Chem:searchSubstructure",{molStringsColumn:t.temp["monomeric-mols"],molString:r.get(0),molBlockFailover:""})).get(0)}async function y(e,t,n){const i=s.TaskBarProgressIndicator.create(`Invalidating molfiles for ${e.name}`);try{await(0,r.cb)(10);const i=new Map,o=await u(e,t,n,i);e.temp["monomeric-mols"]=o,e.temp["monomers-dict"]=i,e.temp["last-invalidated-version"]=e.version}finally{i.close()}}},966:(e,t,n)=>{"use strict";n.d(t,{V:()=>r,l:()=>a});var i=n(4328),o=n(6082),s=n(8926);function r(e,t,n=[],o=[],r=!0){const l=s._package.seqHelper,[c,u]=a(e,t,l,n,o);return r&&!c&&i.shell.warning(u),c}function a(e,t,n,s=[],r=[]){let a=!0,l="";if(e.semType!==o.SEMTYPE.MACROMOLECULE)i.shell.warning(t+" analysis is allowed for Macromolecules semantic type"),a=!1;else{const i=n.getSeqHandler(e),o=i.notation;if(s.length>0&&!s.some((e=>o.toUpperCase()==e.toUpperCase())))l=`${t} + ' analysis is allowed for Macromolecules with notation ${0==s.length?"any notation":`notation${s.length>1?"s":""} ${s.map((e=>`"${e}"`)).join(", ")} `}.`,a=!1;else if(!i.isHelm()){const e=i.alphabet;r.length>0&&!r.some((t=>e.toUpperCase()==t.toUpperCase()))&&(l=`${t} + ' analysis is allowed for Macromolecules with alphabet ${0==r.length?"any alphabet":`alphabet${r.length>1?"s":""} ${r.map((e=>`"${e}"`)).join(", ")}.`}.`,a=!1)}}return[a,l]}},4139:(e,t,n)=>{"use strict";n.d(t,{HX:()=>h,J:()=>c,b9:()=>u,gN:()=>a,uF:()=>s});var i,o,s,r=n(8152);!function(e){e.SPLIT_COL="~split",e.ACTIVITY="~activity",e.ACTIVITY_SCALED="activity_scaled",e.ALIGNED_SEQUENCE="~aligned_sequence",e.AMINO_ACID_RESIDUE="AAR",e.POSITION="Pos",e.P_VALUE="pValue",e.MEAN_DIFFERENCE="Mean difference"}(i||(i={})),function(e){e.AAR="AAR",e.POSITION="Pos",e.SELECTION="selection"}(o||(o={})),function(e){e.MONOMER="Monomer",e.MACROMOLECULE_DIFFERENCE="MacromoleculeDifference",e.ACTIVITY="activity",e.ACTIVITY_SCALED="activityScaled"}(s||(s={}));const a="MSA";var l,c;!function(e){e.CELL_CHANGING="isCellChanging"}(l||(l={})),function(e){e.SEPARATOR="."}(c||(c={}));const u="3.3.1",h={pepsea:{gapOpen:1.53,gapExtend:0,method:r.ZY[0]},kalign:{gapOpen:-1,gapExtend:-1,terminalGap:-1}}},5433:(e,t,n)=>{"use strict";n.d(t,{C:()=>h,r:()=>d});var i=n(6082),o=n(7389),s=n(4328),r=n(1757),a=n.n(r),l=n(2003);let c=null,u=[];function h(e,t){let n=e??s.shell.t.columns.bySemType("Macromolecule");if(!n)throw new Error("No column with Macromolecule semantic type found");let r=t.getSeqHandler(n),h=r.notation;const p=o.divText("Current notation: "+h,{style:{"text-align":"center","font-weight":"bold","font-size":"14px",padding:"5px"}}),m=[l.Hi.FASTA,l.Hi.SEPARATOR,l.Hi.HELM],g=o.input.column("Column",{table:s.shell.t,value:n,filter:e=>e.semType===i.SEMTYPE.MACROMOLECULE,nullable:!1,onValueChanged:e=>(n=e,r=t.getSeqHandler(n),h=r.notation,h===l.Hi.HELM&&(b.value="/"),p.textContent="Current notation: "+h,y=m.filter((e=>e!==h)),v=o.input.choice("Convert to",{value:y[0],items:y,onValueChanged:w}),w(),c?.clear(),void c?.add(o.div([p,g.root,v.root,b.root])))}),f=["-",".","/"];let y=m.filter((e=>e!==h));const b=o.input.choice("Separator",{value:f[0],items:f}),w=()=>{v.value!==l.Hi.SEPARATOR?a()(b.root).hide():a()(b.root).show()};let v=o.input.choice("Convert to",{value:y[0],items:y,onValueChanged:w});w(),v.onChanged.subscribe((()=>{w()})),null==c&&(c=o.dialog("Convert Sequence Notation").add(o.div([p,g.root,v.root,b.root])).onOK((async()=>{const e=v.value,i=e===l.Hi.SEPARATOR?b.value:void 0;await d(n,t,e,i)})).show({x:350,y:100}),u.push(c.onClose.subscribe((e=>{u.forEach((e=>{e.unsubscribe()})),u=[],c=null}))))}async function d(e,t,n,i){const o=t.getSeqHandler(e).convert(n,i);e.dataFrame.columns.add(o);const r=await s.functions.call("Bio:detectMacromolecule",{col:o});return r&&(o.semType=r),await s.data.detectSemanticTypes(e.dataFrame),o}},6956:(e,t,n)=>{"use strict";n.d(t,{mP:()=>s,pk:()=>o,xe:()=>i});const i="|",o="$",s="H"},2582:(e,t,n)=>{"use strict";n.d(t,{f:()=>a});var i=n(6956);class o{constructor(e){const t=e.split(i.xe).filter((e=>e));t.forEach((e=>this.validateConnectionItem(e))),this.connectionItems=t}connectionItems;validateConnectionItem(e){const t="(PEPTIDE|RNA)",n=new RegExp(`${t}[0-9]+,${t}[0-9]+,[0-9]+:R[0-9]+-[0-9]+:R[0-9]+`,"g");if(!e.match(n))throw new Error(`Cannot parse connection item from ${e}`)}getConnectionData(){const e=[];return this.connectionItems.forEach((t=>{const n=[],i=t.split(",");i[2].split("-").forEach(((e,t)=>{const o=i[t],s=e.split(":"),r={monomerIdx:parseInt(s[0])-1,rGroupId:parseInt(s[1].slice(1))};n.push({polymerId:o,bond:r})})),e.push(n)})),e}}var s=n(8438);class r{simplePolymer;isNucleotideSequence=!1;constructor(e){this.simplePolymer=e,this.polymerType=this.getPolymerType(),this.isNucleotideSequence="RNA"===this.polymerType,this.idx=this.getIdx();const{monomers:t,monomerTypes:n}=this.getMonomerSymbolsAndTypes();this.monomers=t,this.monomerTypes=n}polymerType;monomers;idx;monomerTypes;get id(){return this.polymerType+this.idx.toString()}getPolymerType(){const e=new RegExp("(PEPTIDE|RNA)[0-9]+{"),t=this.simplePolymer.match(e);if(!t)throw new Error(`Unsupported polymer type in ${this.simplePolymer}`);return t[1]}getIdx(){const e=new RegExp(`${this.polymerType}([0-9]+){`),t=this.simplePolymer.match(e);if(!t)throw new Error(`Cannot parse simple polymer id from ${this.simplePolymer}`);return parseInt(t[1])}getMonomerSymbolsAndTypes(){const e=new RegExp(`${this.polymerType}${this.idx}{|}`,"g"),t=this.simplePolymer.replace(e,"").split("."),n=[],i=[];return t.forEach((e=>{if(this.isNucleotideSequence){const t=e.split(/\(|\)/).filter((e=>!!e)).map((e=>(0,s.D)(e)));n.push(...t),t.forEach(((e,t)=>i.push(t%3==1?"Branch":"Backbone")))}else n.push((0,s.D)(e)),i.push("Backbone")})),{monomers:n,monomerTypes:i}}getBondData(){const e=[],t=this.monomerTypes.map(((e,t)=>{if("Backbone"===e)return t})).filter((e=>void 0!==e)),n=this.monomerTypes.map(((e,t)=>{if("Branch"===e)return t})).filter((e=>void 0!==e));for(let n=0;n<t.length-1;n++){const i=t[n],o=t[n+1];e.push([{monomerIdx:i,rGroupId:2},{monomerIdx:o,rGroupId:1}])}for(let t=0;t<n.length;t++){const i=n[t],o=i-1;e.push([{monomerIdx:o,rGroupId:3},{monomerIdx:i,rGroupId:1}])}return e}}class a{helmString;constructor(e){this.helmString=e;const t=this.helmString.split(i.pk),n=t[0].split(i.xe);this.simplePolymers=n.map((e=>new r(e))),this.connectionList=new o(t[1]),this.bondData=this.getBondData(),this.bondedRGroupsMap=this.getBondedRGroupsMap()}bondData;simplePolymers;connectionList;bondedRGroupsMap;getBondedRGroupsMap(){const e=this.simplePolymers.map((e=>e.monomers.length)).reduce(((e,t)=>e+t),0),t=Array.from({length:e},(()=>[]));return this.bondData.forEach((e=>{e.forEach((e=>{const n=e.monomerIdx,i=e.rGroupId;t[n].push(i)}))})),t}toString(){return this.helmString}getPolymerTypeByMonomerIdx(e){return this.getSimplePolymerByMonomerIdx(e).polymerType}getSimplePolymerByMonomerIdx(e){const t=this.getMonomerIdxShifts(),n=Object.values(t).sort(((e,t)=>e-t)).find((t=>e>=t));if(void 0===n)throw new Error(`Cannot find simple polymer for monomer ${e}`);const i=Object.keys(t).find((e=>t[e]===n));return this.simplePolymers.find((e=>e.id===i))}shiftBondMonomerIds(e,t){t.forEach((t=>{t.forEach((t=>{t.monomerIdx+=e}))}))}getMonomerIdxShifts(){const e={};let t=0;return this.simplePolymers.forEach((n=>{e[n.id]=t,t+=n.monomers.length})),e}getBondData(){const e=this.getMonomerIdxShifts(),t=[];return this.simplePolymers.forEach((n=>{const i=n.getBondData(),o=e[n.id];this.shiftBondMonomerIds(o,i),t.push(...i)})),this.connectionList.getConnectionData().forEach((n=>{const i=[];n.forEach((t=>{const n=e[t.polymerId],o=t.bond;o.monomerIdx+=n,i.push(o)})),t.push(i)})),t}}},8604:(e,t,n)=>{"use strict";n.d(t,{Es:()=>o,G3:()=>r,VV:()=>a,gt:()=>s,so:()=>i});const i="System:AppData/Bio/monomer-libraries/",o="System:AppData/Bio/monomer-sets/",s="System:AppData/Bio/tests/libraries/HELMmonomerSchema.json",r={explicit:["HELMCoreLibrary.json","polytool-lib.json"],exclude:[],duplicateMonomerPreferences:{}},a={PEPTIDE:326,RNA:383,CHEM:0}},1619:(e,t,n)=>{"use strict";n.d(t,{D:()=>x});var i=n(4328),o=n(6082),s=n(7389),r=n(8070),a=n(2003),l=n(608),c=n(8152),u=n(966),h=n(4139),d=n(5072),p=n.n(d),m=n(7825),g=n.n(m),f=n(7659),y=n.n(f),b=n(5056),w=n.n(b),v=n(540),A=n.n(v),C=n(1113),T=n.n(C),S=n(6369),E={};E.styleTagTransform=T(),E.setAttributes=w(),E.insert=y().bind(null,"head"),E.domAPI=g(),E.insertStyleElement=A(),p()(S.A,E),S.A&&S.A.locals&&S.A.locals;var M=n(8926);async function x(e,t){return new Promise((async(n,a)=>{e.clustersCol??=null,e.pepsea??={},e.pepsea.method??=h.HX.pepsea.method,e.pepsea.gapOpen??=h.HX.pepsea.gapOpen,e.pepsea.gapExtend??=h.HX.pepsea.gapExtend;const u=e.col?.dataFrame??i.shell.t;if(!u){const e="Multiple Sequence Alignment analysis requires a dataset with a macromolecule column.";return void a(new l.Ap(s.divText(e)))}const d=e.col??u.columns.bySemType(o.SEMTYPE.MACROMOLECULE);if(null==d){const e="Multiple Sequence Alignment analysis requires a dataset with a macromolecule column.";return void a(new l.Ap(s.divText(e)))}const p=s.input.choice("Method",{value:e.pepsea.method,items:c.ZY});p.setTooltip("Alignment method");const m=s.input.float("Terminal gap",{value:e?.kalign?.terminalGap});m.setTooltip("Penalty for opening a gap at the beginning or end of the sequence");const g=s.p(`Kalign version: ${h.b9}`,"kalign-version"),f=s.input.float("Gap open",{value:e.pepsea.gapOpen});f.setTooltip("Gap opening penalty at group-to-group alignment");const y=s.input.float("Gap extend",{value:e.pepsea.gapExtend});y.setTooltip("Gap extension penalty to skip the alignment");const b=s.input.bool("Selected Rows Only",{value:!1}),w=s.inputs([f,y,m]),v=s.button("Alignment parameters",(()=>{w.hidden=!w.hidden,[f,y,m].forEach((e=>{e.root.style.removeProperty("max-width"),e.captionLabel.style.removeProperty("max-width")}))}),"Adjust alignment parameters such as penalties for opening and extending gaps");v.classList.add("msa-params-button"),w.hidden=!0,v.prepend(s.icons.settings((()=>null)));const A=[p.root.style],C=[m.root.style,g.style];let T,S=d;const E=s.input.column("Sequence",{table:u,value:d,onValueChanged:async e=>{if(!e||e.semType!==o.SEMTYPE.MACROMOLECULE)return I.disabled=!0,await(0,r.cb)(0),void(E.value=S);S=e,I.disabled=!1,T=await _(E.value,u,t,A,C,p,M,f,y,m,b)},filter:e=>e.semType===o.SEMTYPE.MACROMOLECULE});E.setTooltip("Sequences column to use for alignment");const M=s.input.column("Clusters",{table:u,value:e.clustersCol});M.nullable=!0;const x=s.dialog("MSA").add(E).add(M).add(p).add(w).add(v).add(b).add(g).onOK((async()=>{await L(E,u,T,n,a)})),I=x.getButton("OK");if(E.fireChanged(),e.col)return T=await _(e.col,u,t,A,C,p,M,f,y,m,b),void await L(E,u,T,n,a);x.show()}))}async function L(e,t,n,s,r){let a=null;const l=o.TaskBarProgressIndicator.create("Analyze for MSA ...");try{if(e.fireChanged(),e.value.semType!==o.SEMTYPE.MACROMOLECULE)throw new Error("Chosen column has to be of Macromolecule semantic type");if(void 0===n)throw new Error("Invalid column format");if(a=await n(),null==a)return r("PepSeA container has not started");t.columns.add(a),await i.data.detectSemanticTypes(t),s(a)}catch(e){r(e)}finally{l.close()}}async function _(e,t,n,s,r,d,p,m,g,f,y){try{if(e.semType!==o.SEMTYPE.MACROMOLECULE)return;const i=t.columns.getUnusedName(`msa(${e.name})`);if((0,u.l)(e,e.name,n,[a.Hi.FASTA,a.Hi.SEPARATOR],[a.YI.DNA,a.YI.RNA,a.YI.PT])[0]){I(s,r,"kalign"),m.value=null,g.value=null,f.value=null;const o=n.getSeqHandler(e),c=o.isFasta()?e:o.convert(a.Hi.FASTA);return async()=>await(0,l.eE)(t,c,!1,i,p.value,void 0,void 0,void 0,y.value)}if((0,u.l)(e,e.name,n,[a.Hi.HELM],[])[0])return I(s,r,"pepsea"),m.value??=h.HX.pepsea.gapOpen,g.value??=h.HX.pepsea.gapExtend,async()=>(0,c.GD)(t,e,i,d.value,m.value,g.value,p.value,void 0,y.value);if((0,u.l)(e,e.name,n,[a.Hi.SEPARATOR],[a.YI.UN])[0]){const o=n.getSeqHandler(e).convert(a.Hi.HELM);return I(s,r,"pepsea"),m.value??=h.HX.pepsea.gapOpen,g.value??=h.HX.pepsea.gapExtend,async()=>(0,c.GD)(t,o,i,d.value,m.value,g.value,p.value,void 0,y.value)}return m.value=null,g.value=null,f.value=null,void I(s,r,"kalign")}catch(e){const t=e instanceof Error?e.message:e.toString();i.shell.error(t),M._package.logger.error(t)}}function I(e,t,n){if("kalign"===n){for(const t of e)t.display="none";for(const e of t)e.removeProperty("display")}else{for(const e of t)e.display="none";for(const t of e)t.removeProperty("display")}}},608:(e,t,n)=>{"use strict";n.d(t,{Ap:()=>k,aZ:()=>B,eE:()=>D});var i=n(7389),o=n(6082),s=n(1991),r=n.n(s),a=n(3516),l=n(2003);const c=Symbol("Comlink.proxy"),u=Symbol("Comlink.endpoint"),h=Symbol("Comlink.releaseProxy"),d=Symbol("Comlink.thrown"),p=e=>"object"==typeof e&&null!==e||"function"==typeof e,m=new Map([["proxy",{canHandle:e=>p(e)&&e[c],serialize(e){const{port1:t,port2:n}=new MessageChannel;return g(e,t),[n,[n]]},deserialize:e=>(e.start(),y(e))}],["throw",{canHandle:e=>p(e)&&d in e,serialize({value:e}){let t;return t=e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[t,[]]},deserialize(e){throw e.isError?Object.assign(new Error(e.value.message),e.value):e.value}}]]);function g(e,t=self){t.addEventListener("message",(function n(i){if(!i||!i.data)return;const{id:o,type:s,path:r}=Object.assign({path:[]},i.data),a=(i.data.argumentList||[]).map(S);let l;try{const t=r.slice(0,-1).reduce(((e,t)=>e[t]),e),n=r.reduce(((e,t)=>e[t]),e);switch(s){case"GET":l=n;break;case"SET":t[r.slice(-1)[0]]=S(i.data.value),l=!0;break;case"APPLY":l=n.apply(t,a);break;case"CONSTRUCT":l=function(e){return Object.assign(e,{[c]:!0})}(new n(...a));break;case"ENDPOINT":{const{port1:t,port2:n}=new MessageChannel;g(e,n),l=function(e,t){return C.set(e,t),e}(t,[t])}break;case"RELEASE":l=void 0;break;default:return}}catch(e){l={value:e,[d]:0}}Promise.resolve(l).catch((e=>({value:e,[d]:0}))).then((e=>{const[i,r]=T(e);t.postMessage(Object.assign(Object.assign({},i),{id:o}),r),"RELEASE"===s&&(t.removeEventListener("message",n),f(t))}))})),t.start&&t.start()}function f(e){(function(e){return"MessagePort"===e.constructor.name})(e)&&e.close()}function y(e,t){return w(e,[],t)}function b(e){if(e)throw new Error("Proxy has been released and is not useable")}function w(e,t=[],n=function(){}){let i=!1;const o=new Proxy(n,{get(n,s){if(b(i),s===h)return()=>E(e,{type:"RELEASE",path:t.map((e=>e.toString()))}).then((()=>{f(e),i=!0}));if("then"===s){if(0===t.length)return{then:()=>o};const n=E(e,{type:"GET",path:t.map((e=>e.toString()))}).then(S);return n.then.bind(n)}return w(e,[...t,s])},set(n,o,s){b(i);const[r,a]=T(s);return E(e,{type:"SET",path:[...t,o].map((e=>e.toString())),value:r},a).then(S)},apply(n,o,s){b(i);const r=t[t.length-1];if(r===u)return E(e,{type:"ENDPOINT"}).then(S);if("bind"===r)return w(e,t.slice(0,-1));const[a,l]=A(s);return E(e,{type:"APPLY",path:t.map((e=>e.toString())),argumentList:a},l).then(S)},construct(n,o){b(i);const[s,r]=A(o);return E(e,{type:"CONSTRUCT",path:t.map((e=>e.toString())),argumentList:s},r).then(S)}});return o}function v(e){return Array.prototype.concat.apply([],e)}function A(e){const t=e.map(T);return[t.map((e=>e[0])),v(t.map((e=>e[1])))]}const C=new WeakMap;function T(e){for(const[t,n]of m)if(n.canHandle(e)){const[i,o]=n.serialize(e);return[{type:"HANDLER",name:t,value:i},o]}return[{type:"RAW",value:e},C.get(e)||[]]}function S(e){switch(e.type){case"HANDLER":return m.get(e.name).deserialize(e.value);case"RAW":return e.value}}function E(e,t,n){return new Promise((i=>{const o=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");e.addEventListener("message",(function t(n){!n.data||!n.data.id||n.data.id!==o||(e.removeEventListener("message",t),i(n.data))})),e.start&&e.start(),e.postMessage(Object.assign({id:o},t),n)}))}const M="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0ICQ9U3ltYm9sKCJDb21saW5rLnByb3h5IiksQT1TeW1ib2woIkNvbWxpbmsuZW5kcG9pbnQiKSxSPVN5bWJvbCgiQ29tbGluay5yZWxlYXNlUHJveHkiKSx5PVN5bWJvbCgiQ29tbGluay50aHJvd24iKSxfPWU9PnR5cGVvZiBlPT0ib2JqZWN0IiYmZSE9PW51bGx8fHR5cGVvZiBlPT0iZnVuY3Rpb24iLEw9e2NhbkhhbmRsZTplPT5fKGUpJiZlWyRdLHNlcmlhbGl6ZShlKXtjb25zdHtwb3J0MTpyLHBvcnQyOml9PW5ldyBNZXNzYWdlQ2hhbm5lbDtyZXR1cm4gdyhlLHIpLFtpLFtpXV19LGRlc2VyaWFsaXplKGUpe3JldHVybiBlLnN0YXJ0KCksQyhlKX19LE89e2NhbkhhbmRsZTplPT5fKGUpJiZ5IGluIGUsc2VyaWFsaXplKHt2YWx1ZTplfSl7bGV0IHI7cmV0dXJuIGUgaW5zdGFuY2VvZiBFcnJvcj9yPXtpc0Vycm9yOiEwLHZhbHVlOnttZXNzYWdlOmUubWVzc2FnZSxuYW1lOmUubmFtZSxzdGFjazplLnN0YWNrfX06cj17aXNFcnJvcjohMSx2YWx1ZTplfSxbcixbXV19LGRlc2VyaWFsaXplKGUpe3Rocm93IGUuaXNFcnJvcj9PYmplY3QuYXNzaWduKG5ldyBFcnJvcihlLnZhbHVlLm1lc3NhZ2UpLGUudmFsdWUpOmUudmFsdWV9fSxFPW5ldyBNYXAoW1sicHJveHkiLExdLFsidGhyb3ciLE9dXSk7ZnVuY3Rpb24gdyhlLHI9c2VsZil7ci5hZGRFdmVudExpc3RlbmVyKCJtZXNzYWdlIixmdW5jdGlvbiBpKHMpe2lmKCFzfHwhcy5kYXRhKXJldHVybjtjb25zdHtpZDpvLHR5cGU6YSxwYXRoOm59PU9iamVjdC5hc3NpZ24oe3BhdGg6W119LHMuZGF0YSksYz0ocy5kYXRhLmFyZ3VtZW50TGlzdHx8W10pLm1hcChtKTtsZXQgbDt0cnl7Y29uc3QgdT1uLnNsaWNlKDAsLTEpLnJlZHVjZSgoZCxwKT0+ZFtwXSxlKSxmPW4ucmVkdWNlKChkLHApPT5kW3BdLGUpO3N3aXRjaChhKXtjYXNlIkdFVCI6bD1mO2JyZWFrO2Nhc2UiU0VUIjp1W24uc2xpY2UoLTEpWzBdXT1tKHMuZGF0YS52YWx1ZSksbD0hMDticmVhaztjYXNlIkFQUExZIjpsPWYuYXBwbHkodSxjKTticmVhaztjYXNlIkNPTlNUUlVDVCI6e2NvbnN0IGQ9bmV3IGYoLi4uYyk7bD16KGQpfWJyZWFrO2Nhc2UiRU5EUE9JTlQiOntjb25zdHtwb3J0MTpkLHBvcnQyOnB9PW5ldyBNZXNzYWdlQ2hhbm5lbDt3KGUscCksbD1OKGQsW2RdKX1icmVhaztjYXNlIlJFTEVBU0UiOmw9dm9pZCAwO2JyZWFrO2RlZmF1bHQ6cmV0dXJufX1jYXRjaCh1KXtsPXt2YWx1ZTp1LFt5XTowfX1Qcm9taXNlLnJlc29sdmUobCkuY2F0Y2godT0+KHt2YWx1ZTp1LFt5XTowfSkpLnRoZW4odT0+e2NvbnN0W2YsZF09Uyh1KTtyLnBvc3RNZXNzYWdlKE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSxmKSx7aWQ6b30pLGQpLGE9PT0iUkVMRUFTRSImJihyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGkpLE0ocikpfSl9KSxyLnN0YXJ0JiZyLnN0YXJ0KCl9ZnVuY3Rpb24gVChlKXtyZXR1cm4gZS5jb25zdHJ1Y3Rvci5uYW1lPT09Ik1lc3NhZ2VQb3J0In1mdW5jdGlvbiBNKGUpe1QoZSkmJmUuY2xvc2UoKX1mdW5jdGlvbiBDKGUscil7cmV0dXJuIGIoZSxbXSxyKX1mdW5jdGlvbiBoKGUpe2lmKGUpdGhyb3cgbmV3IEVycm9yKCJQcm94eSBoYXMgYmVlbiByZWxlYXNlZCBhbmQgaXMgbm90IHVzZWFibGUiKX1mdW5jdGlvbiBiKGUscj1bXSxpPWZ1bmN0aW9uKCl7fSl7bGV0IHM9ITE7Y29uc3Qgbz1uZXcgUHJveHkoaSx7Z2V0KGEsbil7aWYoaChzKSxuPT09UilyZXR1cm4oKT0+ZyhlLHt0eXBlOiJSRUxFQVNFIixwYXRoOnIubWFwKGM9PmMudG9TdHJpbmcoKSl9KS50aGVuKCgpPT57TShlKSxzPSEwfSk7aWYobj09PSJ0aGVuIil7aWYoci5sZW5ndGg9PT0wKXJldHVybnt0aGVuOigpPT5vfTtjb25zdCBjPWcoZSx7dHlwZToiR0VUIixwYXRoOnIubWFwKGw9PmwudG9TdHJpbmcoKSl9KS50aGVuKG0pO3JldHVybiBjLnRoZW4uYmluZChjKX1yZXR1cm4gYihlLFsuLi5yLG5dKX0sc2V0KGEsbixjKXtoKHMpO2NvbnN0W2wsdV09UyhjKTtyZXR1cm4gZyhlLHt0eXBlOiJTRVQiLHBhdGg6Wy4uLnIsbl0ubWFwKGY9PmYudG9TdHJpbmcoKSksdmFsdWU6bH0sdSkudGhlbihtKX0sYXBwbHkoYSxuLGMpe2gocyk7Y29uc3QgbD1yW3IubGVuZ3RoLTFdO2lmKGw9PT1BKXJldHVybiBnKGUse3R5cGU6IkVORFBPSU5UIn0pLnRoZW4obSk7aWYobD09PSJiaW5kIilyZXR1cm4gYihlLHIuc2xpY2UoMCwtMSkpO2NvbnN0W3UsZl09RihjKTtyZXR1cm4gZyhlLHt0eXBlOiJBUFBMWSIscGF0aDpyLm1hcChkPT5kLnRvU3RyaW5nKCkpLGFyZ3VtZW50TGlzdDp1fSxmKS50aGVuKG0pfSxjb25zdHJ1Y3QoYSxuKXtoKHMpO2NvbnN0W2MsbF09RihuKTtyZXR1cm4gZyhlLHt0eXBlOiJDT05TVFJVQ1QiLHBhdGg6ci5tYXAodT0+dS50b1N0cmluZygpKSxhcmd1bWVudExpc3Q6Y30sbCkudGhlbihtKX19KTtyZXR1cm4gb31mdW5jdGlvbiBEKGUpe3JldHVybiBBcnJheS5wcm90b3R5cGUuY29uY2F0LmFwcGx5KFtdLGUpfWZ1bmN0aW9uIEYoZSl7Y29uc3Qgcj1lLm1hcChTKTtyZXR1cm5bci5tYXAoaT0+aVswXSksRChyLm1hcChpPT5pWzFdKSldfWNvbnN0IFA9bmV3IFdlYWtNYXA7ZnVuY3Rpb24gTihlLHIpe3JldHVybiBQLnNldChlLHIpLGV9ZnVuY3Rpb24geihlKXtyZXR1cm4gT2JqZWN0LmFzc2lnbihlLHtbJF06ITB9KX1mdW5jdGlvbiBTKGUpe2Zvcihjb25zdFtyLGldb2YgRSlpZihpLmNhbkhhbmRsZShlKSl7Y29uc3RbcyxvXT1pLnNlcmlhbGl6ZShlKTtyZXR1cm5be3R5cGU6IkhBTkRMRVIiLG5hbWU6cix2YWx1ZTpzfSxvXX1yZXR1cm5be3R5cGU6IlJBVyIsdmFsdWU6ZX0sUC5nZXQoZSl8fFtdXX1mdW5jdGlvbiBtKGUpe3N3aXRjaChlLnR5cGUpe2Nhc2UiSEFORExFUiI6cmV0dXJuIEUuZ2V0KGUubmFtZSkuZGVzZXJpYWxpemUoZS52YWx1ZSk7Y2FzZSJSQVciOnJldHVybiBlLnZhbHVlfX1mdW5jdGlvbiBnKGUscixpKXtyZXR1cm4gbmV3IFByb21pc2Uocz0+e2NvbnN0IG89VSgpO2UuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsZnVuY3Rpb24gYShuKXshbi5kYXRhfHwhbi5kYXRhLmlkfHxuLmRhdGEuaWQhPT1vfHwoZS5yZW1vdmVFdmVudExpc3RlbmVyKCJtZXNzYWdlIixhKSxzKG4uZGF0YSkpfSksZS5zdGFydCYmZS5zdGFydCgpLGUucG9zdE1lc3NhZ2UoT2JqZWN0LmFzc2lnbih7aWQ6b30sciksaSl9KX1mdW5jdGlvbiBVKCl7cmV0dXJuIG5ldyBBcnJheSg0KS5maWxsKDApLm1hcCgoKT0+TWF0aC5mbG9vcihNYXRoLnJhbmRvbSgpKk51bWJlci5NQVhfU0FGRV9JTlRFR0VSKS50b1N0cmluZygxNikpLmpvaW4oIi0iKX1jb25zdCBXPWFzeW5jKCk9PldlYkFzc2VtYmx5LnZhbGlkYXRlKG5ldyBVaW50OEFycmF5KFswLDk3LDExNSwxMDksMSwwLDAsMCwxLDUsMSw5NiwwLDEsMTIzLDMsMiwxLDAsMTAsMTAsMSw4LDAsNjUsMCwyNTMsMTUsMjUzLDk4LDExXSkpLGs9ImVhZ2VyIix4PSJsYXp5IixqPXtzc3c6WyJzaW1kIl0sbWluaW1hcDI6WyJzaW1kIl19LHQ9e3Rvb2xzOltdLGNvbmZpZzp7fSxmaWxlczpbXSxiYXNlOnt9LGZzOnt9LGFzeW5jIGluaXQoKXtpZih0LnRvb2xzLmxlbmd0aD09PTApdGhyb3ciRXhwZWN0aW5nIGF0IGxlYXN0IDEgdG9vbC4iO2lmKG5ldyBTZXQodC50b29scy5tYXAocj0+YCR7ci50b29sfS8ke3IucHJvZ3JhbXx8ci50b29sfWApKS5zaXplIT09dC50b29scy5sZW5ndGgpdGhyb3ciRm91bmQgZHVwbGljYXRlIHRvb2xzOyBjYW4gb25seSBoYXZlIGVhY2ggdG9vbC9wcm9ncmFtIGNvbWJpbmF0aW9uIGF0IG1vc3Qgb25jZS4iO2lmKHQuYmFzZT10LnRvb2xzLmZpbmQocj0+ci5yZWluaXQhPT0hMCksIXQuYmFzZSl0aHJvdyJDb3VsZCBub3QgZmluZCBhIHRvb2wgd2l0aCBgcmVpbml0OiBmYWxzZWAgdG8gdXNlIGFzIHRoZSBiYXNlIG1vZHVsZS4gVG8gZml4IHRoaXMgaXNzdWUsIGluY2x1ZGUgdGhlIHRvb2wgYGJhc2UvMS4wLjBgIHdoZW4gaW5pdGlhbGl6aW5nIEFpb2xpLiI7cmV0dXJuIHQuYmFzZS5pc0Jhc2VNb2R1bGU9ITAsYXdhaXQgdGhpcy5fc2V0dXAodC5iYXNlKSxhd2FpdCB0aGlzLl9pbml0TW9kdWxlcygpLHQuX2xvZygiUmVhZHkiKSwhMH0sYXN5bmMgX2luaXRNb2R1bGVzKCl7YXdhaXQgUHJvbWlzZS5hbGwodC50b29scy5tYXAodGhpcy5fc2V0dXApKSxhd2FpdCB0aGlzLl9zZXR1cEZTKCl9LG1vdW50KGU9W10pe2NvbnN0IHI9YCR7dC5jb25maWcuZGlyU2hhcmVkfSR7dC5jb25maWcuZGlyRGF0YX1gLGk9YCR7dC5jb25maWcuZGlyU2hhcmVkfSR7dC5jb25maWcuZGlyTW91bnRlZH1gO2xldCBzPVtdLG89W10sYT1bXTshQXJyYXkuaXNBcnJheShlKSYmIShlIGluc3RhbmNlb2YgRmlsZUxpc3QpJiYoZT1bZV0pLHQuX2xvZyhgTW91bnRpbmcgJHtlLmxlbmd0aH0gZmlsZXNgKTtmb3IobGV0IG4gb2YgZSl7aWYobiBpbnN0YW5jZW9mIEZpbGV8fChuPT1udWxsP3ZvaWQgMDpuLmRhdGEpaW5zdGFuY2VvZiBCbG9iJiZuLm5hbWV8fHR5cGVvZihuPT1udWxsP3ZvaWQgMDpuLmRhdGEpPT0ic3RyaW5nIiYmbi5uYW1lKXR5cGVvZihuPT1udWxsP3ZvaWQgMDpuLmRhdGEpPT0ic3RyaW5nIiYmKG4uZGF0YT1uZXcgQmxvYihbbi5kYXRhXSx7dHlwZToidGV4dC9wbGFpbiJ9KSkscy5wdXNoKG4pO2Vsc2UgaWYobi5uYW1lJiZuLnVybClvLnB1c2gobik7ZWxzZSBpZih0eXBlb2Ygbj09InN0cmluZyImJm4uc3RhcnRzV2l0aCgiaHR0cCIpKW49e3VybDpuLG5hbWU6bi5zcGxpdCgiLy8iKS5wb3AoKS5yZXBsYWNlKC9cLy9nLCItIil9LG8ucHVzaChuKTtlbHNlIHRocm93J0Nhbm5vdCBtb3VudCBmaWxlKHMpIHNwZWNpZmllZC4gTXVzdCBiZSBhIEZpbGUsIEJsb2IsIGEgVVJMIHN0cmluZywgb3IgeyBuYW1lOiAiZmlsZS50eHQiLCBkYXRhOiAic3RyaW5nIiB9Lic7YS5wdXNoKG4ubmFtZSl9dHJ5e3QuZnMudW5tb3VudChpKX1jYXRjaHt9Zm9yKGxldCBuIG9mIG8pdC5mcy5jcmVhdGVMYXp5RmlsZShyLG4ubmFtZSxuLnVybCwhMCwhMCk7cmV0dXJuIHQuZmlsZXM9dC5maWxlcy5jb25jYXQocyksdC5iYXNlLm1vZHVsZS5GUy5tb3VudCh0LmJhc2UubW9kdWxlLldPUktFUkZTLHtmaWxlczp0LmZpbGVzLmZpbHRlcihuPT5uIGluc3RhbmNlb2YgRmlsZSksYmxvYnM6dC5maWxlcy5maWx0ZXIobj0+KG49PW51bGw/dm9pZCAwOm4uZGF0YSlpbnN0YW5jZW9mIEJsb2IpfSxpKSxzLm1hcChuPT57Y29uc3QgYz1gJHtpfS8ke24ubmFtZX1gLGw9YCR7cn0vJHtuLm5hbWV9YDt0cnl7dC5mcy51bmxpbmsobCl9Y2F0Y2h7fXQuX2xvZyhgQ3JlYXRpbmcgc3ltbGluazogJHtsfSAtLT4gJHtjfWApLHQuZnMuc3ltbGluayhjLGwpfSksYS5tYXAobj0+YCR7cn0vJHtufWApfSxhc3luYyBleGVjKGUscj1udWxsKXtpZih0Ll9sb2coYEV4ZWN1dGluZyAlYyR7ZX0lYyBhcmdzPSR7cn1gLCJjb2xvcjpkYXJrYmx1ZTsgZm9udC13ZWlnaHQ6Ym9sZCIsIiIpLCFlKXRocm93IkV4cGVjdGluZyBhIGNvbW1hbmQiO2xldCBpPWU7cj09bnVsbCYmKHI9ZS5zcGxpdCgiICIpLGk9ci5zaGlmdCgpKTtjb25zdCBzPXQudG9vbHMuZmluZChhPT57dmFyIGM7bGV0IG49aTtyZXR1cm4oKGM9YT09bnVsbD92b2lkIDA6YS5mZWF0dXJlcyk9PW51bGw/dm9pZCAwOmMuc2ltZCk9PT0hMCYmKG49YCR7bn0tc2ltZGApLGEucHJvZ3JhbT09bn0pO2lmKHM9PW51bGwpdGhyb3dgUHJvZ3JhbSAke2l9IG5vdCBmb3VuZC5gO3Muc3Rkb3V0PSIiLHMuc3RkZXJyPSIiLHMubG9hZGluZz09eCYmKHMubG9hZGluZz1rLGF3YWl0IHRoaXMuX2luaXRNb2R1bGVzKCkpO3RyeXtzLm1vZHVsZS5jYWxsTWFpbihyKX1jYXRjaChhKXtjb25zb2xlLmVycm9yKGEpfXRyeXtzLm1vZHVsZS5GUy5jbG9zZShzLm1vZHVsZS5GUy5zdHJlYW1zWzFdKSxzLm1vZHVsZS5GUy5jbG9zZShzLm1vZHVsZS5GUy5zdHJlYW1zWzJdKX1jYXRjaHt9cy5tb2R1bGUuRlMuc3RyZWFtc1sxXT1zLm1vZHVsZS5GUy5vcGVuKCIvZGV2L3N0ZG91dCIsInciKSxzLm1vZHVsZS5GUy5zdHJlYW1zWzJdPXMubW9kdWxlLkZTLm9wZW4oIi9kZXYvc3RkZXJyIiwidyIpO2xldCBvPXtzdGRvdXQ6cy5zdGRvdXQsc3RkZXJyOnMuc3RkZXJyfTtyZXR1cm4gdC5jb25maWcucHJpbnRJbnRlcmxlYXZlZCYmKG89cy5zdGRvdXQpLHMucmVpbml0PT09ITAmJmF3YWl0IHRoaXMucmVpbml0KHMudG9vbCksb30sY2F0KGUpe3JldHVybiB0Ll9maWxlb3AoImNhdCIsZSl9LGxzKGUpe3JldHVybiB0Ll9maWxlb3AoImxzIixlKX0sZG93bmxvYWQoZSl7cmV0dXJuIHQuX2ZpbGVvcCgiZG93bmxvYWQiLGUpfSxwd2QoKXtyZXR1cm4gdC5mcy5jd2QoKX0sY2QoZSl7Zm9yKGxldCByIG9mIHQudG9vbHMpIXIubW9kdWxlfHxyLm1vZHVsZS5GUy5jaGRpcihlKX0sbWtkaXIoZSl7cmV0dXJuIHQuZnMubWtkaXIoZSksITB9LHJlYWQoe3BhdGg6ZSxsZW5ndGg6cixmbGFnOmk9InIiLG9mZnNldDpzPTAscG9zaXRpb246bz0wfSl7Y29uc3QgYT10LmZzLm9wZW4oZSxpKSxuPW5ldyBVaW50OEFycmF5KHIpO3JldHVybiB0LmZzLnJlYWQoYSxuLHMscixvKSx0LmZzLmNsb3NlKGEpLG59LHdyaXRlKHtwYXRoOmUsYnVmZmVyOnIsZmxhZzppPSJ3KyIsb2Zmc2V0OnM9MCxwb3NpdGlvbjpvPTB9KXtjb25zdCBhPXQuZnMub3BlbihlLGkpO3QuZnMud3JpdGUoYSxyLHMsci5sZW5ndGgsbyksdC5mcy5jbG9zZShhKX0sYXN5bmMgcmVpbml0KGUpe2NvbnN0IHI9dC50b29scy5maW5kKHM9PnMudG9vbD09ZSksaT10LmJhc2UubW9kdWxlLkZTLmN3ZCgpO09iamVjdC5hc3NpZ24ocixyLmNvbmZpZyksci5yZWFkeT0hMSxhd2FpdCB0aGlzLmluaXQoKSxyLmlzQmFzZU1vZHVsZSYmdGhpcy5tb3VudCgpLHRoaXMuY2QoaSl9LF9zdGRpblR4dDoiIixfc3RkaW5QdHI6MCxnZXQgc3RkaW4oKXtyZXR1cm4gdC5fc3RkaW5UeHR9LHNldCBzdGRpbihlPSIiKXt0Ll9sb2coYFNldHRpbmcgc3RkaW4gdG8gJWMke2V9JWNgLCJjb2xvcjpkYXJrYmx1ZSIsIiIpLHQuX3N0ZGluVHh0PWUsdC5fc3RkaW5QdHI9MH0sYXN5bmMgX3NldHVwKGUpe2lmKGUucmVhZHkpcmV0dXJuO2lmKHQuX2xvZyhgU2V0dGluZyB1cCAke2UudG9vbH0gKGJhc2UgPSAke2UuaXNCYXNlTW9kdWxlPT09ITB9KS4uLmApLGUuY29uZmlnPU9iamVjdC5hc3NpZ24oe30sZSksZS51cmxQcmVmaXh8fChlLnVybFByZWZpeD1gJHt0LmNvbmZpZy51cmxDRE59LyR7ZS50b29sfS8ke2UudmVyc2lvbn1gKSxlLnByb2dyYW18fChlLnByb2dyYW09ZS50b29sKSxlLmZlYXR1cmVzfHwoZS5mZWF0dXJlcz17fSwoaltlLnByb2dyYW1dfHxbXSkuaW5jbHVkZXMoInNpbWQiKSYmKGF3YWl0IFcoKT8oZS5wcm9ncmFtKz0iLXNpbWQiLGUuZmVhdHVyZXMuc2ltZD0hMCk6dC5fbG9nKGBXZWJBc3NlbWJseSBTSU1EIGlzIG5vdCBzdXBwb3J0ZWQgaW4gdGhpcyBicm93c2VyOyB3aWxsIGxvYWQgbm9uLVNJTUQgdmVyc2lvbiBvZiAke2UucHJvZ3JhbX0uYCkpKSxlLmlzQmFzZU1vZHVsZSYmKGUubG9hZGluZz1rKSxlLmxvYWRpbmc9PT14KXt0Ll9sb2coYFdpbGwgbGF6eS1sb2FkICR7ZS50b29sfTsgc2tpcHBpbmcgaW5pdGlhbGl6YXRpb24uYCk7cmV0dXJufXNlbGYuaW1wb3J0U2NyaXB0cyhgJHtlLnVybFByZWZpeH0vJHtlLnByb2dyYW19LmpzYCksZS5tb2R1bGU9YXdhaXQgTW9kdWxlKHt0aGlzUHJvZ3JhbTplLnByb2dyYW0sbG9jYXRlRmlsZTooaSxzKT0+YCR7ZS51cmxQcmVmaXh9LyR7aX1gLHN0ZGluOigpPT50Ll9zdGRpblB0cjx0LnN0ZGluLmxlbmd0aD90LnN0ZGluLmNoYXJDb2RlQXQodC5fc3RkaW5QdHIrKyk6KHQuc3RkaW49IiIsbnVsbCkscHJpbnQ6aT0+e3QuY29uZmlnLnByaW50U3RyZWFtP3Bvc3RNZXNzYWdlKHt0eXBlOiJiaW93YXNtIix2YWx1ZTp7c3Rkb3V0Oml9fSk6ZS5zdGRvdXQrPWkrYApgfSxwcmludEVycjppPT57Y29uc3Qgcz10LmNvbmZpZy5wcmludEludGVybGVhdmVkPyJzdGRvdXQiOiJzdGRlcnIiO3QuY29uZmlnLnByaW50U3RyZWFtP3Bvc3RNZXNzYWdlKHt0eXBlOiJiaW93YXNtIix2YWx1ZTp7W3NdOml9fSk6ZVtzXSs9aStgCmB9fSk7Y29uc3Qgcj1lLm1vZHVsZS5GUztlLmlzQmFzZU1vZHVsZT8odC5fbG9nKGBTZXR0aW5nIHVwICR7ZS50b29sfSB3aXRoIGJhc2UgbW9kdWxlIGZpbGVzeXN0ZW0uLi5gKSxyLm1rZGlyKHQuY29uZmlnLmRpclNoYXJlZCw1MTEpLHIubWtkaXIoYCR7dC5jb25maWcuZGlyU2hhcmVkfS8ke3QuY29uZmlnLmRpckRhdGF9YCw1MTEpLHIubWtkaXIoYCR7dC5jb25maWcuZGlyU2hhcmVkfS8ke3QuY29uZmlnLmRpck1vdW50ZWR9YCw1MTEpLHIuY2hkaXIoYCR7dC5jb25maWcuZGlyU2hhcmVkfS8ke3QuY29uZmlnLmRpckRhdGF9YCksdC5mcz1yKToodC5fbG9nKGBTZXR0aW5nIHVwICR7ZS50b29sfSB3aXRoIGZpbGVzeXN0ZW0uLi5gKSxyLm1rZGlyKHQuY29uZmlnLmRpclNoYXJlZCksci5tb3VudChlLm1vZHVsZS5QUk9YWUZTLHtyb290OnQuY29uZmlnLmRpclNoYXJlZCxmczp0LmZzfSx0LmNvbmZpZy5kaXJTaGFyZWQpLHIuY2hkaXIodC5mcy5jd2QoKSkpLGUuc3Rkb3V0PSIiLGUuc3RkZXJyPSIiLGUucmVhZHk9ITB9LGFzeW5jIF9zZXR1cEZTKCl7Y29uc3QgZT10LmZzO2ZvcihsZXQgciBvZiB0LnRvb2xzKXtpZighci5yZWFkeSljb250aW51ZTtjb25zdCBpPXIubW9kdWxlLkZTLHM9YC8ke3IudG9vbH1gLG89YCR7dC5jb25maWcuZGlyU2hhcmVkfSR7c31gOyFpLmFuYWx5emVQYXRoKHMpLmV4aXN0c3x8ZS5hbmFseXplUGF0aChvKS5leGlzdHN8fCh0Ll9sb2coYE1vdW50aW5nICR7c30gb250byAke3QuYmFzZS50b29sfSBmaWxlc3lzdGVtIGF0ICR7b31gKSxlLm1rZGlyKG8pLGUubW91bnQodC5iYXNlLm1vZHVsZS5QUk9YWUZTLHtyb290OnMsZnM6aX0sbykpfX0sX2ZpbGVvcChlLHIpe3QuX2xvZyhgUnVubmluZyAke2V9ICR7cn1gKTtjb25zdCBpPXQuZnMuYW5hbHl6ZVBhdGgocik7aWYoIWkuZXhpc3RzKXJldHVybiB0Ll9sb2coYEZpbGUgJHtyfSBub3QgZm91bmQuYCksITE7c3dpdGNoKGUpe2Nhc2UiY2F0IjpyZXR1cm4gdC5mcy5yZWFkRmlsZShyLHtlbmNvZGluZzoidXRmOCJ9KTtjYXNlImxzIjpyZXR1cm4gdC5mcy5pc0ZpbGUoaS5vYmplY3QubW9kZSk/dC5mcy5zdGF0KHIpOnQuZnMucmVhZGRpcihyKTtjYXNlImRvd25sb2FkIjpjb25zdCBzPW5ldyBCbG9iKFt0aGlzLmNhdChyKV0pO3JldHVybiBVUkwuY3JlYXRlT2JqZWN0VVJMKHMpfXJldHVybiExfSxfbG9nKGUpe2lmKCF0LmNvbmZpZy5kZWJ1ZylyZXR1cm47bGV0IHI9Wy4uLmFyZ3VtZW50c107ci5zaGlmdCgpLGNvbnNvbGUubG9nKGAlY1tXZWJXb3JrZXJdJWMgJHtlfWAsImZvbnQtd2VpZ2h0OmJvbGQiLCIiLC4uLnIpfX07dyh0KX0pKCk7Cg==",x=typeof window<"u"&&window.Blob&&new Blob([atob(M)],{type:"text/javascript;charset=utf-8"});function L(){const e=x&&(window.URL||window.webkitURL).createObjectURL(x);try{return e?new Worker(e):new Worker("data:application/javascript;base64,"+M)}finally{e&&(window.URL||window.webkitURL).revokeObjectURL(e)}}const _={urlCDN:"https://biowasm.com/cdn/v3",urlCDNStg:"https://stg.biowasm.com/cdn/v3",dirShared:"/shared",dirMounted:"/mnt",dirData:"/data",printInterleaved:!0,printStream:!1,callback:null,debug:!1,env:"prd"};class I{constructor(e,t={}){if(null==e)throw"Expecting array of tools as input to Aioli constructor.";return Array.isArray(e)||(e=[e]),t=Object.assign({},_,t),e=e.map(this._parseTool),"stg"===t.env&&(t.urlCDN=t.urlCDNStg),this.tools=e,this.config=t,null!=this.config.callback&&(this.callback=this.config.callback),delete this.config.callback,this.init()}async init(){const e=new L;this.callback&&(e.onmessage=e=>{"biowasm"===e.data.type&&this.callback(e.data.value)});const t=y(e);return t.tools=this.tools,t.config=this.config,await t.init(),t}_parseTool(e){if("string"!=typeof e)return e;const t=e.split("/");if(2!=t.length&&3!=t.length)throw"Expecting '<tool>/<version>' or '<tool>/<program>/<version>'";return{tool:t[0],program:3==t.length?t[1]:t[0],version:t[t.length-1]}}}var P=n(3629);class N{static getAvailableScales(){return Object.entries(this.scales).map((([e,t])=>e))}static getScale(e){return(0,P.vA)(!(void 0===this.scales[e]),`Scale '${e}' was not found.`),this.scales[e]}}N.scales={WimleyWhite:{"-":0,A:.17,C:-.24,D:-.07,E:-.01,F:-1.13,G:.01,H:.17,I:-.31,K:.99,L:-.56,M:-.23,N:.42,P:.45,Q:.58,R:.81,S:.13,T:.14,V:.07,W:-1.85,Y:-.94},categorial:{"-":0,A:1,C:2,D:3,E:4,F:5,G:6,H:7,I:8,K:9,L:10,M:11,N:12,P:13,Q:14,R:15,S:16,T:17,V:18,W:19,Y:20}};class R{constructor(e="categorial"){this.aa2num=N.getScale(e),this.num2aa={},Object.entries(this.aa2num).forEach((([e,t])=>this.num2aa[t]=e))}static _truncateSequence(e){let t=0,n=e.length;const i=["NH2","COOH"];if(e.startsWith(i[0])){const n=i[0].length;(0,P.vA)("-"==e[n],`Wrong sequence format: ${i[0]} without following '-' in '${e}'.`),t=n}if(e.endsWith(i[1])){const t=i[1].length+1;(0,P.vA)("-"==e[n-t],`Wrong sequence format: ${i[1]} without '-' precending in '${e}'.`),n-=t}return e.substring(t,n)}static _dropDefises(e){return e.replace(/(-)([^-]+)/g,"$2")}static clean(e){return R._dropDefises(R._truncateSequence(e))}encode(e){const t=e.length,n=new Array(t).fill(0);for(let i=0;i<t;++i){const t=e[i];(0,P.vA)(t in this.aa2num,`Unknown char '${t}' found in sequence '${e}'`),n[i]=this.encodeLettter(t)}return n}encodeLettter(e){return this.aa2num[e]}decode(e){let t="";for(let n=0;n<e.length;++n){const i=e[n];(0,P.vA)(i in this.num2aa,`Unknown code '${i}' found in vector '${e}'`),t+=this.num2aa[i]}return t}}var $=n(4139);const O="input.fa",H="result.fasta";class k extends Error{element;constructor(e,t){super(e.innerText,t),this.element=e}}function F(e){return e.reduce(((e,t,n)=>e+`>sample${n+1}\n${t}\n`),"")}async function D(e,t,n=!1,i="",s=null,r,c,u,h){let d=t.toList();n&&(d=d.map((e=>R.clean(e).replace(/\-/g,""))));const p=t.length;s??=o.Column.string("Clusters",p).init("0"),s.type!=o.COLUMN_TYPE.STRING&&(s=s.convertTo(o.TYPE.STRING)),s.compact();const m=s.categories,g=s.getRawData(),f=new Array(m.length),y=new Array(m.length);if(h){const t=e.selection;if(0===t.length)throw new Error("No selected rows in the table.");for(let e=-1;-1!==(e=t.findNext(e,!0));){const t=g[e];(f[t]??=[]).push(d[e]),(y[t]??=[]).push(e)}}else for(let e=0;e<p;++e){const t=g[e];(f[t]??=[]).push(d[e]),(y[t]??=[]).push(e)}B(y,m);const b=await new I(["base/1.0.0",{tool:"kalign",version:$.b9,reinit:!0}]),w=o.Column.string(i,p);for(let e=0;e<m.length;++e){const t=f[e];if(!t||0===t.length)continue;const n=F(t);await b.fs.writeFile(O,n);const i=`${void 0!==r?` --gpo ${r}`:""}${void 0!==c?` --gpe ${c}`:""}${void 0!==u?` --tgpe ${u}`:""}`,o=await b.exec(`kalign ${O} -f fasta -o ${H}${i}`);console.warn(o);const s=await b.cat(H);if(!s){const e=G(o,1);throw new Error(e)}const l=new a.m(s).sequencesArray,h=y[e];for(let e=0;e<l.length;++e)w.set(h[e],l[e])}const v=t.meta.units,A=t.getTag(l.gp.alphabet);return w.meta.units=v,w.setTag(l.gp.aligned,"SEQ.MSA"),w.setTag(l.gp.alphabet,A),w.semType=o.SEMTYPE.MACROMOLECULE,w}function G(e,t){const n=[],i=/^.+ERROR : (.+)$/gm;let o;for(;null!=(o=i.exec(e))&&(void 0===t||n.length<t);)n.push(o[1]);return n.join("\n")}function B(e,t){const n=e.map(((e,t)=>[e,t])).filter((([e,t])=>1==e.length)).map((([e,t])=>t));if(n.length>0){const e=i.div([i.divText(`MSA analysis is not available on single sequence clusters #${n.length}:`),...r()(n).take(3).map((e=>{let o=t[e];return o.length>25&&(o=o.slice(0,25)+"..."),i.divText(`"${o}"${e<n.length-1?", ":"."}`)})).toArray(),...n.length>3?[i.divText("...")]:[]]);throw new k(e)}}},8152:(e,t,n)=>{"use strict";n.d(t,{GD:()=>d,ZY:()=>u});var i=n(4328),o=n(6082),s=n(2003),r=n(608),a=n(4139),l=n(8926);const c=new class{dcName="bio";async getDockerContainer(){return await i.dapi.docker.dockerContainers.filter(this.dcName).first()}},u=["mafft --auto","mafft","linsi","ginsi","einsi","fftns","fftnsi","nwns","nwnsi"],h=["AlignedSeq","AlignedSubpeptide","HELM","ID","PolymerID"];async function d(e,t,n,i="ginsi",l=1.53,u=0,d=null,m,g=!1){const f=await c.getDockerContainer(),y=t.length;d??=o.Column.int("Clusters",y).init(0),d.type!=o.COLUMN_TYPE.STRING&&(d=d.convertTo(o.TYPE.STRING));const b=d.categories,w=d.getRawData(),v=new Array(b.length),A=new Array(b.length);if(g){const n=e.selection;for(let e=-1;-1!==(e=n.findNext(e,!0));){const n=w[e];if(!b[n])continue;const i=n,o=t.get(e);o&&((v[i]??=[]).push({ID:e.toString(),HELM:o}),(A[n]??=[]).push(e))}}else for(let e=0;e<y;++e){const n=w[e];if(!b[n])continue;const i=n,o=t.get(e);o&&((v[i]??=[]).push({ID:e.toString(),HELM:o}),(A[n]??=[]).push(e))}(0,r.aZ)(A,b);const C=new Array(y).fill(null);for(const e of v){if(!e||0===e.length)continue;const t=(await p(f.id,e,i,l,u,m)).Alignment;for(const e of t)C[parseInt(e.ID)]=Object.entries(e).filter((e=>!h.includes(e[0]))).map((e=>"-"!==e[1]?e[1]:"")).join(a.J.SEPARATOR)}const T=o.Column.fromStrings(n,C);return T.meta.units=s.Hi.SEPARATOR,T.setTag(s.gp.separator,a.J.SEPARATOR),T.setTag(s.gp.aligned,"SEQ.MSA"),T.setTag(s.gp.alphabet,s.YI.UN),T.setTag(s.gp.alphabetIsMultichar,"true"),T.semType=o.SEMTYPE.MACROMOLECULE,T}async function p(e,t,n,o,s,r){const a={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(t)},c=`/align?method=${n}&gap_open=${o}&gap_extend=${s}`,u=window.performance.now(),h=await i.dapi.docker.dockerContainers.fetchProxy(e,c,a),d=window.performance.now();l._package.logger.debug(`Bio: requestAlignedObjects() dockerContainers.fetchProxy(), ET: ${d-u} ms`);const p="application/json"===h.headers.get("content-type");if(!h.ok&&p){const e=await h.json(),t=e["pepsea-error"];if(t)throw new Error(`PepSeA error: ${t}`);const n=e["datagrok-error"];if(n)throw new Error(`Datagrok error: ${n}`);throw new Error(h.statusText)}if(!h.ok&&!p){const e=await h.text();throw new Error(`Error: ${e}`)}if(!p){const e=await h.text();throw new Error(`Error: PepSeA expected JSON response, got '${e}'.`)}const m=await h.json();if("pepsea-stderr"in m){const e=m["pepsea-stderr"];r?.warning(e)}return m}},3890:(e,t,n)=>{"use strict";n.d(t,{TE:()=>u,aS:()=>d,wz:()=>h});var i=n(6082),o=n(7389),s=n(4328),r=n(1991),a=n.n(r),l=n(8926);const c=60;function u(){const e=s.shell.tv.grid,t=a().count(0).take(e.columns.length).map((t=>e.columns.byIndex(t))).filter((e=>!!e.column&&e.column.semType!==i.SEMTYPE.MACROMOLECULE)).toArray(),n=t.find((e=>-1!==e.name.toLowerCase().indexOf("id"))),r=n?[n.name]:[],u=o.input.multiChoice("Seq id columns",{value:r,items:t.map((e=>e.name))}),d=a().count(0).take(e.columns.length).map((t=>e.columns.byIndex(t))).filter((e=>{const t=e.column;return!(!t||t.semType!==i.SEMTYPE.MACROMOLECULE)&&l._package.seqHelper.getSeqHandler(t).isFasta()})).toArray(),p=d.length>0?d[0].name:[],m=o.input.choice("Seq column",{value:p,items:d.map((e=>e.name))}),g=o.input.int("FASTA line width",{value:c});o.dialog({title:"Save as FASTA"}).add(o.inputs([u,m,g])).onOK((()=>{const t=u.value?u.value.map((t=>e.columns.byName(t).column)):[],n=m.value?e.columns.byName(m.value).column:null,i=g.value??c;n||s.shell.warning("Seq column is mandatory to save as FASTA.");const o=h(t,l._package.seqHelper.getSeqHandler(n),i),r=document.createElement("a");r.setAttribute("href",`data:text/plain;charset=utf-8,${encodeURIComponent(o)}`),r.setAttribute("download",`${e.dataFrame.name}.fasta`),r.click()})).show()}function h(e,t,n=c,i="\n"){const o=[];for(let s=0;s<t.length;s++){const r=e.map((e=>e.get(s).toString())).join("|"),a=d(t.getSplitted(s),n);o.push(`>${r}${i}`);for(const e of a)o.push(`${e}${i}`)}return"".concat(...o)}function d(e,t=c){let n=0;const i=e.length,o=[];for(;n<i;){const i=a().count(n).take(Math.min(e.length-n,t)).map((t=>e.getOriginal(t))).toArray(),s=i.map((e=>e.length>1?`[${e}]`:e)).reduce(((e,t)=>e+t),"");o.push(s),n+=i.length}return o}},8754:(e,t,n)=>{"use strict";n.d(t,{V:()=>u});var i=n(4328),o=n(6077),s=n(2003),r=n(8312),a=n(5553),l=n(966),c=n(330);async function u(e,t,n,u,h,d,p){let m;if(n){const n=await(0,r.Q)(),i=n.getSeqHandler(t);let o,a;i.isHelm()?o=t:(a=t.name,t.name=`__${a}`,o=i.convert(s.Hi.HELM),o.name=a,e.columns.add(o,!1));try{m=await n.helmToAtomicLevel(o,!0,!0,h)}finally{o!==t&&(e.columns.remove(o.name),t.name=a)}}else{if(!(0,l.l)(t,"To Atomic Level",d)[0])return{molCol:null,warnings:["Column is not suitable"]};m=await(0,o.C4)(e,t,h,d,p)}if(m.molCol){const o=(0,c.qj)(e,t.name);m.molCol.name=o,e.columns.add(m.molCol,!0),await(0,a.Qc)(t,m.molCol,h,d,p,n),m.molCol.setTag(".sequence-src-highlight-monomers",String(u)),await i.data.detectSemanticTypes(e)}return m}},4870:(e,t,n)=>{"use strict";n.d(t,{Kd:()=>a,Ku:()=>r,me:()=>s});var i=n(4328),o=n(6082);function s(){const e=i.shell.t.columns.bySemTypeAll(o.SEMTYPE.MACROMOLECULE);return null===e?(i.shell.error("Current table does not contain macromolecules"),[]):e}function r(e,t){e.innerHTML="",e.append(t)}function a(e,t,n,i,o){const s=()=>{const o=e.col(t);o&&(o.width=n),i&&(e.props.rowHeight=i)};if(o)return void s();const r=e.onAfterDrawOverlay.subscribe((()=>{r.unsubscribe(),setTimeout((()=>{s()}))}))}},250:(e,t,n)=>{"use strict";n.d(t,{VN:()=>x,n5:()=>A,Ue:()=>S,Tc:()=>T,oP:()=>L,eN:()=>_});var i=n(4328),o=n(7389),s=n(6082),r=n(1757),a=n.n(r),l=n(1991),c=n.n(l),u=n(1858),h=n(2003),d=n(4326);function p(e){var t;return"string"==typeof e||e instanceof String?e:("object"==typeof e||e instanceof Object)&&"$thrownJsError"in e?p(e.$thrownJsError):e instanceof Error?null!==(t=e.stack)&&void 0!==t?t:e.message:e.toString()}var m=n(8070),g=n(7602),f=n(439),y=n(6882);var b=n(8926);function w(e,t,n){return Math.abs(e-t)<=n}var v,A,C=n(6307);HTMLCanvasElement.prototype.getCursorPosition=function(e,t){const n=this.getBoundingClientRect();return new s.Point((e.clientX-n.left)*t,(e.clientY-n.top)*t)},s.Rect.prototype.contains=function(e,t){return this.left<=e&&e<=this.right&&this.top<=t&&t<=this.bottom};class T{rowCount;value;plotValue;valueList=null;valueIdx=0;bounds;constructor(e=0,t){this.value=this.rowCount=e,this.bounds=t}push(e){this.valueList||(this.valueList=new Array(this.rowCount),this.valueIdx=0),this.valueList[this.valueIdx]=e,++this.valueIdx}aggregate(e){this.value=e(this.valueList)??0,this.valueList=null}}class S{pos;name;_label;get label(){return this._label?this._label:this.name}_freqs;sumRowCount=0;sumPlotValue;sumPlotValueForHeight;constructor(e,t,n,i){this.pos=e,this.name=t,this._freqs=n??{},i?.sumRowCount&&(this.sumRowCount=i.sumRowCount),i?.sumValueForHeight&&(this.sumPlotValue=i.sumValueForHeight),i?.label&&(this._label=i.label)}getMonomers(){return Object.keys(this._freqs)}hasMonomer(e){return e in this._freqs}getFreq(e){let t=this._freqs[e];return t||(t=this._freqs[e]=new T),t}aggregate(e){const t=function(e){return t=>{const n=function(e){let t;const n="agg";return t=e instanceof Float32Array?s.Column.fromFloat32Array(n,e):e instanceof Int32Array?s.Column.fromInt32Array(n,e):s.Column.fromList(s.COLUMN_TYPE.FLOAT,n,e),t}(t);return n.aggregate(e)}}(e);for(const[e,n]of Object.entries(this._freqs))n.aggregate(t)}getMinValue(){return Math.min(...Object.values(this._freqs).map((e=>e.value)))}calcPlotValue(e){for(const t of Object.values(this._freqs))t.plotValue=t.value-e}calcHeights(e){this.sumPlotValue=0;for(const e of Object.values(this._freqs))this.sumPlotValue+=e.plotValue;if(this.sumPlotValueForHeight=0,e===d.fH.Entropy){const e=Object.keys(this._freqs).length,t=.01*this.sumPlotValue,n=t/e;for(const e of Object.values(this._freqs)){const i=(e.plotValue+n)/(this.sumPlotValue+t);this.sumPlotValueForHeight+=-i*Math.log2(i)}}else if(e===d.fH.full)for(const[e,t]of Object.entries(this._freqs)){const e=t.plotValue/this.sumPlotValue;this.sumPlotValueForHeight+=e}}calcScreen(e,t,n,i,o,r,a,l,c){const u=i===d.fH.Entropy?n*(o-this.sumPlotValueForHeight)/o:n;let h=c*l+(n-u-1);const p=Object.entries(this._freqs).sort(((e,t)=>e[0]!==f._S&&t[0]!==f._S?t[1].value-e[1].value:e[0]===f._S&&t[0]===f._S?0:e[0]===f._S?-1:1));for(const[n,i]of p){const n=u*i.plotValue/this.sumPlotValue;i.bounds=new s.Rect((e-t)*l*r,h,a*l,n),h+=n}}render(e,t,n,i,o,s,r){for(const[a,l]of Object.entries(this._freqs))if(a!==f._S){const c=(0,h.zS)(a,r),u=l.bounds,d=u.left;let p=y.S$;s&&(p=s.getMonomerTextColor(o,a)),e.resetTransform(),e.strokeStyle="lightgray",e.lineWidth=1,e.rect(d,u.top,u.width,u.height),e.fillStyle=p,e.textAlign="left",e.font=t;const m=e.measureText(c);e.setTransform(u.width/m.width,0,0,u.height/i,d,u.top),e.fillText(c,0,-n)}}getMonomerAt(e,t){const n=Object.entries(this._freqs).find((([n,i])=>i.bounds.contains(e,t)));return n?n[0]:void 0}buildCompositionTable(e,t){if("-"in this._freqs)throw new Error("Unexpected monomer symbol '-'.");return(0,C.F)(Object.assign({},...Object.entries(this._freqs).map((([e,t])=>({[e]:t.rowCount})))),e,t)}}!function(e){e.STYLE="Style",e.BEHAVIOR="Behavior",e.LAYOUT="Layout",e.DATA="Data"}(v||(v={})),function(e){e.sequenceColumnName="sequenceColumnName",e.valueAggrType="valueAggrType",e.valueColumnName="valueColumnName",e.startPositionName="startPositionName",e.endPositionName="endPositionName",e.skipEmptySequences="skipEmptySequences",e.skipEmptyPositions="skipEmptyPositions",e.shrinkEmptyTail="shrinkEmptyTail",e.backgroundColor="backgroundColor",e.positionHeight="positionHeight",e.positionWidth="positionWidth",e.verticalAlignment="verticalAlignment",e.horizontalAlignment="horizontalAlignment",e.fixWidth="fixWidth",e.fitArea="fitArea",e.minHeight="minHeight",e.maxHeight="maxHeight",e.maxMonomerLetters="maxMonomerLetters",e.showPositionLabels="showPositionLabels",e.positionMarginState="positionMarginState",e.positionMargin="positionMargin",e.filterSource="filterSource"}(A||(A={}));const E=d.Fo;var M;!function(e){e[e.None=0]="None",e[e.Render=1]="Render",e[e.Layout=1]="Layout",e[e.Freqs=2]="Freqs"}(M||(M={}));const x=new class{render=20};class L extends s.JsViewer{static residuesSet="nucleotides";viewed=!1;seqHelper;seqHandler;initialized=!1;monomerLib=null;host;msgHost;canvas;slider;textBaseline;seqCol=null;positions=[];visibleSlider=!1;allowResize=!0;turnOfResizeForOneSetValue=!1;sequenceColumnName;valueAggrType;valueColumnName;skipEmptySequences;skipEmptyPositions;positionWidth;_positionWidth;_positionWidthWithMargin;get positionWidthWithMargin(){return this._positionWidthWithMargin}minHeight;backgroundColor=4294967295;maxHeight;maxMonomerLetters;showPositionLabels;positionMarginState;positionMargin=0;_positionMargin;startPositionName;endPositionName;fixWidth;verticalAlignment;horizontalAlignment;fitArea;shrinkEmptyTail;positionHeight;filterSource;positionNames=[];positionLabels=void 0;startPosition=-1;endPosition=-1;error=null;get Length(){return this.skipEmptyPositions?this.positions.length:this.startPosition<=this.endPosition?this.endPosition-this.startPosition+1:0}get positionMarginValue(){return this.positionMarginState===d.mH.AUTO&&!0===this.seqHandler.getAlphabetIsMultichar()||this.positionMarginState===d.mH.ON?this.positionMargin:0}constructor(){super(),this.seqHelper=b._package.seqHelper,this.textBaseline="top",this.seqHandler=null,this.sequenceColumnName=this.string(A.sequenceColumnName,E.sequenceColumnName,{category:v.DATA,semType:s.SEMTYPE.MACROMOLECULE,description:"Column with sequences"});const e=[s.AGG.KEY,s.AGG.PIVOT,s.AGG.MISSING_VALUE_COUNT,s.AGG.SKEW,s.AGG.KURT,s.AGG.SELECTED_ROWS_COUNT],t=Object.values(s.AGG).filter((t=>!e.includes(t)));this.valueColumnName=this.string(A.valueColumnName,E.valueColumnName,{category:v.DATA,columnTypeFilter:"numerical",description:"Column with values used in aggregation for position heights"}),this.valueAggrType=this.string(A.valueAggrType,E.valueAggrType,{category:v.DATA,choices:t,description:"Aggregation method for value column"}),this.startPositionName=this.string(A.startPositionName,E.startPositionName,{category:v.DATA,description:"Position or column name for start position. If column with given name is found, its values will be used as start position. If number is supplied, it will be used as start position of WebLogo."}),this.endPositionName=this.string(A.endPositionName,E.endPositionName,{category:v.DATA,description:"Position or column name for end position. If column with given name is found, its values will be used as end position. If number is supplied, it will be used as end position of WebLogo."}),this.skipEmptySequences=this.bool(A.skipEmptySequences,E.skipEmptySequences,{category:v.DATA,description:"Skip sequences which are empty in all positions"}),this.skipEmptyPositions=this.bool(A.skipEmptyPositions,E.skipEmptyPositions,{category:v.DATA,description:"Skip positions which are empty in all sequences"}),this.shrinkEmptyTail=this.bool(A.shrinkEmptyTail,E.shrinkEmptyTail,{category:v.DATA,description:"Skip empty tail (if found for all sequences within a subset) in WebLogo"}),this.backgroundColor=this.int(A.backgroundColor,E.backgroundColor,{category:v.STYLE,description:"Background color of WebLogo canvas"}),this.positionHeight=this.string(A.positionHeight,E.positionHeight,{category:v.STYLE,choices:Object.values(d.fH),description:"Monomer-Position height mode. Entropy of 100%(full height)"}),this._positionWidth=this.positionWidth=this.float(A.positionWidth,E.positionWidth,{category:v.LAYOUT,editor:"slider",min:4,max:100,description:'Width of position in WebLogo. If "Fit Area" is enabled, width will be calculated to fit horizontal space'}),this.verticalAlignment=this.string(A.verticalAlignment,E.verticalAlignment,{category:v.LAYOUT,choices:Object.values(d.Lp)}),this.horizontalAlignment=this.string(A.horizontalAlignment,E.horizontalAlignment,{category:v.LAYOUT,choices:Object.values(d.P4)}),this.fixWidth=this.bool(A.fixWidth,E.fixWidth,{category:v.LAYOUT,userEditable:!1}),this.fitArea=this.bool(A.fitArea,E.fitArea,{category:v.LAYOUT,description:"Fit WebLogo to the horizontal space. Calculates position width as maximum between provided width value and value needed to fit whole horizontal space."}),this.minHeight=this.int(A.minHeight,E.minHeight,{category:v.LAYOUT,editor:"slider",min:10,max:250,description:"Minimum height of WebLogo"}),this.maxHeight=this.int(A.maxHeight,E.maxHeight,{category:v.LAYOUT,editor:"slider",min:25,max:Math.max(window.innerHeight??0,1e3),nullable:!0,description:"Maximum height of WebLogo"}),this.maxMonomerLetters=this.int(A.maxMonomerLetters,E.maxMonomerLetters,{category:v.LAYOUT,editor:"slider",min:1,max:40,description:"Maximum monomer letters to display before shortening"}),this.showPositionLabels=this.bool(A.showPositionLabels,E.showPositionLabels,{category:v.LAYOUT,description:"Show position labels on top of the weblogo"}),this.positionMarginState=this.string(A.positionMarginState,E.positionMarginState,{category:v.LAYOUT,choices:Object.values(d.mH),description:"Calculate optimal margins between positions or turn it on/off"});let n=0;"auto"===this.positionMarginState&&(n=4),this.positionMargin=this.int(A.positionMargin,n,{category:v.LAYOUT,min:0,max:25,description:"Margin between positions in WebLogo"}),this.filterSource=this.string(A.filterSource,E.filterSource,{category:v.BEHAVIOR,choices:Object.values(d.lT),description:"Data source for weblogo. Selected or filtered rows."}),this.slider=o.rangeSlider(0,100,0,20,!1,{style:"barbell"}),this.canvas=o.canvas(),this.canvas.classList.value="bio-wl-canvas",this.canvas.style.width="100%",b.PackageFunctions.getMonomerLibHelper().then((e=>{this.monomerLib=e.getMonomerLib(),this.render(M.Render,"monomerLib"),this.subs.push(this.monomerLib.onChanged.subscribe((()=>{this.render(M.Render,"monomerLib changed")})))})),this.viewSyncer=new g.g(b._package.logger)}static viewerCounter=-1;viewerId=++L.viewerCounter;toLog(){return`WebLogoViewer<${this.viewerId}>`}setData(){const e=`${this.toLog()}.setData()`;b._package.logger.debug(`${e}, in`),this.viewSyncer.sync(`${e}`,(async()=>{if(!this.setDataInProgress){this.setDataInProgress=!0;try{this.viewed&&(this.renderRequestSub.unsubscribe(),await this.destroyView(),this.viewed=!1),this.updateSeqCol(),this.updateEditors(),this.viewed||(await this.buildView(),this.viewed=!0)}finally{this.setDataInProgress=!1}}})),b._package.logger.debug(`${e}, out`)}viewSyncer;setDataInProgress=!1;viewSubs=[];async destroyView(){for(const e of this.viewSubs)e.unsubscribe();this.viewSubs=[];const e=this.dataFrame?"data":"null";b._package.logger.debug(`${this.toLog()}.destroyView( dataFrame = ${e} ) start`),this.host.remove(),this.msgHost=void 0,this.host=void 0,b._package.logger.debug(`${this.toLog()}.destroyView() end`)}async buildView(){const e=this.dataFrame?"data":"null";b._package.logger.debug(`${this.toLog()}.buildView( dataFrame = ${e} ) start`),window.devicePixelRatio,this.viewSubs.push(s.debounce(this.renderRequest,x.render).subscribe(this.renderRequestOnDebounce.bind(this))),this.helpUrl="/help/visualize/viewers/web-logo.md",this.msgHost=o.div("No message",{classes:"bio-wl-msg"}),this.msgHost.style.display="none",this.canvas=o.canvas(),this.canvas.style.width="100%",this.slider.root.style.position="absolute",this.slider.root.style.zIndex="999",this.slider.root.style.display="none",this.slider.root.style.height="0.7em",this.visibleSlider=!1,this.host=o.div([this.msgHost,this.canvas],{classes:"bio-wl-host",style:{display:"flex",flexDirection:"row",flexGrow:"0",flexWrap:"wrap"}}),this.root.append(this.host),this.root.append(this.slider.root),this.error&&(this.msgHost.innerText=this.error.message,o.tooltip.bind(this.msgHost,this.error.stack),this.msgHost.style.setProperty("display",null)),this.dataFrame&&(this.viewSubs.push(this.dataFrame.filter.onChanged.subscribe(this.dataFrameFilterOnChanged.bind(this))),this.viewSubs.push(this.dataFrame.selection.onChanged.subscribe(this.dataFrameSelectionOnChanged.bind(this)))),this.viewSubs.push(o.onSizeChanged(this.root).subscribe(this.rootOnSizeChanged.bind(this))),this.viewSubs.push(this.slider.onValuesChanged.subscribe(this.sliderOnValuesChanged.bind(this))),this.viewSubs.push((0,u.fromEvent)(this.canvas,"mousemove").subscribe(this.canvasOnMouseMove.bind(this))),this.viewSubs.push((0,u.fromEvent)(this.canvas,"mousedown").subscribe(this.canvasOnMouseDown.bind(this))),this.viewSubs.push((0,u.fromEvent)(this.canvas,"wheel").subscribe(this.canvasOnWheel.bind(this))),this.render(M.Freqs,"buildView"),b._package.logger.debug(`${this.toLog()}.buildView() end`)}lastSize={width:-1,height:-1};rootOnSizeChanged(e){const t={width:e.target.clientWidth,height:e.target.clientHeight};this.lastSize.width==t.width&&this.lastSize.height==t.height||(b._package.logger.debug(`${this.toLog()}.rootOnSizeChanged(), ${JSON.stringify(t)}, start `),this.render(M.Layout,"rootOnSizeChanged")),this.lastSize=t}updateEditors(){this.props.getProperty(A.valueColumnName).choices=c()(this.dataFrame.columns.numerical).map((e=>e.name)).toArray()}updateSeqCol(){if(this.dataFrame&&(this.seqCol=this.sequenceColumnName?this.dataFrame.col(this.sequenceColumnName):null,null==this.seqCol&&(this.seqCol=(0,h.mn)(this.dataFrame),this.sequenceColumnName=this.seqCol?this.seqCol.name:null),this.seqCol)){try{this.seqHandler=this.seqHelper.getSeqHandler(this.seqCol),this.render(M.Freqs,"updateSeqCol()"),this.error=null}catch(e){throw this.seqCol=null,this.error=e instanceof Error?e:new Error(e.toString()),e}this.seqCol||(this.seqHandler=null,this.positionNames=[],this.positionLabels=[],this.startPosition=-1,this.endPosition=-1)}}getFilter(){let e;switch(this.filterSource){case d.lT.Filtered:e=this.dataFrame.filter;break;case d.lT.Selected:e=0===this.dataFrame.selection.trueCount?this.dataFrame.filter:this.dataFrame.selection}return e}setSliderVisibility(e){e?(this.slider.root.style.display="inherit",this.visibleSlider=!0):(this.slider.root.style.display="none",this.visibleSlider=!1)}calcLayout(e){this.host&&this.canvas&&this.slider&&(this.host.classList.remove("bio-wl-fixWidth","bio-wl-fitArea"),this.canvas.classList.remove("bio-wl-fixWidth","bio-wl-fitArea"),this._positionWidth=this.positionWidth,this._positionMargin=this.positionMargin,this._positionWidthWithMargin=this._positionWidth+this.positionMarginValue,this.fixWidth?this.calcLayoutFixWidth(e):this.calcLayoutNoFitArea(e),this.slider.root.style.width=`${this.host.clientWidth}px`)}calcLayoutFixWidth(e){if(!this.host||!this.canvas||!this.slider)return;this.host.classList.add("bio-wl-fixWidth"),this.canvas.classList.add("bio-wl-fitArea");const t=this._positionWidthWithMargin*this.Length,n=Math.min(Math.max(this.minHeight,this.root.clientHeight),this.maxHeight??this.root.clientHeight);this.host.style.justifyContent=d.P4.LEFT,this.host.style.removeProperty("margin-left"),this.host.style.removeProperty("margin-top"),this.host.style.width=this.canvas.style.width=`${t}px`,this.host.style.height=this.canvas.style.height=`${n}px`,this.host.style.left=this.canvas.style.left="0",this.host.style.top=this.canvas.style.top="0",this.host.style.setProperty("overflow","hidden","important"),this.slider.root.style.display="none",this.slider.setValues(0,Math.max(0,this.Length-1),0,Math.max(0,this.Length-1)),this.canvas.width=t*e,this.canvas.height=n*e}calcLayoutNoFitArea(e){if(!this.host||!this.canvas||!this.slider)return;let t=this._positionWidthWithMargin*this.Length,n=Math.min(this.root.clientWidth,t);this.fitArea&&t<this.root.clientWidth&&(this._positionWidth=Math.floor(this._positionWidth*this.root.clientWidth/t),this._positionWidthWithMargin=this._positionWidth+this.positionMarginValue,t=this._positionWidthWithMargin*this.Length,n=Math.min(this.root.clientWidth,t));const i=Math.min(Math.max(this.minHeight,this.root.clientHeight),this.maxHeight??this.root.clientHeight);this.canvas.style.width=`${n}px`,this.canvas.style.height=`${i}px`,this.host.style.width=`${this.root.clientWidth}px`,this.host.style.height=`${this.root.clientHeight}px`,this.host.style.justifyContent=this.horizontalAlignment,this.host.style.alignContent=this.verticalAlignment===d.Lp.TOP?"start":this.verticalAlignment===d.Lp.MIDDLE?"center":this.verticalAlignment===d.Lp.BOTTOM?"end":"inherit",this.root.clientHeight<this.minHeight&&(this.host.style.alignContent="start",this.host.style.width=`${n+8}px`);const o=t>n;if(this.setSliderVisibility(o),o){this.slider.root.style.removeProperty("display"),this.host.style.justifyContent="left",this.host.style.height=this.root.clientHeight-this.slider.root.offsetHeight+"px",this.canvas.style.height=i-this.slider.root.offsetHeight+"px",this.slider.root.style.top=`${this.host.offsetHeight}px`;let e=Math.min(Math.max(0,this.slider.min),this.Length-.001),t=Math.min(Math.max(0,this.slider.max),this.Length-.001);const n=this.canvas.clientWidth/this._positionWidthWithMargin;t=Math.min(Math.max(e,0)+n,this.Length-.001),e=Math.max(0,Math.min(t,this.Length-.001)-n),this.safeUpdateSlider(0,Math.max(this.Length-.001),e,t)}else this.safeUpdateSlider(0,Math.max(0,this.Length-.001),0,Math.max(0,this.Length-.001));this.canvas.width=n*e,this.canvas.height=i*e}calcLayoutFitArea(e){if(!this.host||!this.canvas||!this.slider)return;const t=this._positionWidth*this.Length,n=Math.min(Math.max(this.minHeight,this.root.clientHeight),this.maxHeight??this.root.clientHeight),i=t>0?(this.root.clientWidth-this.positionMarginValue*this.Length)/t:0,o=this.root.clientHeight/n,s=Math.max(1,Math.min(i,o));this._positionWidth=this.positionWidth*s,this._positionWidthWithMargin=this._positionWidth+this.positionMarginValue;const r=(this._positionWidth+this.positionMarginValue)*this.Length,a=s*n,l=Math.min(this.root.clientWidth,r);this.canvas.style.width=`${l}px`,this.canvas.style.height=`${a}px`,this.host.style.width=`${l}px`,this.host.style.height=`${this.root.clientHeight}px`,this.host.style.justifyContent=this.horizontalAlignment,this.host.style.alignContent=this.verticalAlignment===d.Lp.TOP?"start":this.verticalAlignment===d.Lp.MIDDLE?"center":this.verticalAlignment===d.Lp.BOTTOM?"end":"inherit",this.root.clientHeight<this.minHeight&&(this.host.style.alignContent="start",this.host.style.width=`${l+6}px`),this.host.style.width=`${this.host}px`;const c=r>l;if(this.setSliderVisibility(c),c){this.slider.root.style.removeProperty("display"),this.host.style.justifyContent="left",this.host.style.height=this.root.clientHeight-this.slider.root.offsetHeight+"px",this.slider.root.style.top=`${this.host.offsetHeight}px`;let e=Math.min(Math.max(0,this.slider.min),this.Length-.001),t=Math.min(Math.max(0,this.slider.max),this.Length-.001);const n=this.root.clientWidth/this._positionWidthWithMargin;t=Math.min(Math.max(e,0)+n,this.Length-.001),e=Math.max(0,Math.min(t,this.Length-.001)-n),this.safeUpdateSlider(0,Math.max(0,this.Length-.001),e,t)}else this.safeUpdateSlider(0,Math.max(0,this.Length-.001),0,Math.max(0,this.Length-.001));this.canvas.width=l*e,this.canvas.height=a*e}safeUpdateSlider(e,t,n,i){w(e,this.slider.minRange,.1)&&w(t,this.slider.maxRange,.1)&&w(n,this.slider.min,.1)&&w(i,this.slider.max,.1)||this.slider.setValues(e,t,n,i)}onPropertyChanged(e){switch(super.onPropertyChanged(e),e.name){case A.sequenceColumnName:this.updateSeqCol();break;case A.sequenceColumnName:case A.startPositionName:case A.endPositionName:case A.filterSource:case A.shrinkEmptyTail:case A.skipEmptyPositions:case A.positionHeight:case A.valueColumnName:case A.valueAggrType:this.render(M.Freqs,`onPropertyChanged( ${e.name} )`);break;case A.minHeight:case A.maxHeight:case A.maxMonomerLetters:case A.positionWidth:case A.showPositionLabels:case A.fixWidth:case A.fitArea:case A.horizontalAlignment:case A.verticalAlignment:case A.positionMargin:case A.positionMarginState:this.render(M.Layout,`onPropertyChanged(${e.name})`);break;case A.backgroundColor:this.render(M.Render,`onPropertyChanged(${e.name})`)}}onTableAttached(){b._package.logger.debug(`${this.toLog()}.onTableAttached(), `),super.onTableAttached(),this.setData()}detach(){const e=`${this.toLog()}.detach()`;b._package.logger.debug(`${e}, in`);const t=super.detach.bind(this);this.viewSyncer.sync(`${e}`,(async()=>{this.setDataInProgress||(this.viewed&&(await this.destroyView(),this.viewed=!1),t())})),b._package.logger.debug(`${e}, out`)}_onSizeChanged=new u.Subject;get onSizeChanged(){return this._onSizeChanged}_onFreqsCalculated=new u.Subject;get onFreqsCalculated(){return this._onFreqsCalculated}_onLayoutCalculated=new u.Subject;get onLayoutCalculated(){return this._onLayoutCalculated}getMonomer(e,t){const n=e.x,i=Math.floor(e.x/(this._positionWidthWithMargin*t)+Math.floor(this.slider.min)),o=this.positions[i];if(!o)return[null,null,null];const s=o.getMonomerAt(n,e.y);return void 0===s?[o,null,null]:[o,s,o.getFreq(s)]}_nullSequence(e="X"){return this.skipEmptySequences?"":new Array(this.Length).fill(e).join("")}_removeEmptyPositions(){this.skipEmptyPositions&&(this.positions=c()(this.positions).filter((e=>!e.hasMonomer(f._S)||e.getFreq(f._S).rowCount!==e.sumRowCount)).toArray())}requestedRenderLevel=M.Freqs;renderRequest=new u.Subject;renderRequestSub;render(e,t){b._package.logger.debug(`${this.toLog()}.render( recalcLevelVal=${e}, reason='${t}' )`),this.requestedRenderLevel=Math.max(this.requestedRenderLevel,e),this.renderRequest.next(this.requestedRenderLevel)}async renderInt(e){if(b._package.logger.debug(`${this.toLog()}.render.renderInt( renderLevel=${e} ), start `),this.msgHost&&(this.msgHost.style.display="none"),!this.seqCol||!this.dataFrame||null==this.host||null==this.slider)return;const t=window.devicePixelRatio,n=this.showPositionLabels?12:0;if(e>=M.Freqs&&(()=>{if(b._package.logger.debug(`${this.toLog()}.render.calculateFreqsInt(), start `),!this.host||!this.seqCol||!this.dataFrame)return;const e=this.seqCol.getTag(h.gp.positionNames),t=this.seqCol.getTag(h.gp.positionLabels);let n;!e&&this.endPositionName&&/\d+/.test(this.endPositionName)?n=Number(this.endPositionName):e&&this.endPositionName&&(n=e.split(h.z1).indexOf(this.endPositionName),n=-1!==n?n:void 0);const i=this.getFilter(),o=0===i.trueCount?this.seqHandler.maxLength:c().count(0).take(this.seqHandler.length).map((e=>{const t=this.seqHandler.getSplitted(e,n);return i.get(e)&&t?t.length:0})).reduce(((e,t)=>Math.max(e,t)),0);this.positionNames=e?e.split(h.z1).map((e=>e.trim())):[...Array(o).keys()].map((e=>`${e+1}`)),this.positionLabels=t?t.split(h.z1).map((e=>e.trim())):void 0,this.startPosition=this.startPositionName&&this.positionNames&&this.positionNames.includes(this.startPositionName)?this.positionNames.indexOf(this.startPositionName):0,this.endPosition=this.endPositionName&&this.positionNames&&this.positionNames.includes(this.endPositionName)?this.positionNames.indexOf(this.endPositionName):o-1;const r=this.startPosition<=this.endPosition?this.endPosition-this.startPosition+1:0;this.seqHandler=this.seqHelper.getSeqHandler(this.seqCol);const a=this.startPosition<=this.endPosition?this.endPosition-this.startPosition+1:0;this.positions=new Array(a);for(let e=0;e<r;e++){const t=this.positionNames[this.startPosition+e],n=this.positionLabels?this.positionLabels[this.startPosition+e]:void 0;this.positions[e]=new S(this.startPosition+e,t,{},{label:n})}this.dataFrame.rowCount;const l=i.getSelectedIndexes();for(let e=0;e<r;++e){for(const t of l){const n=this.seqHandler.getSplitted(t),i=e+this.startPosition<n.length?n.getCanonical(this.startPosition+e):this.seqHandler.defaultGapOriginal,o=this.seqHandler.defaultGapOriginal===i?f._S:i,s=this.positions[e],r=s.getFreq(o);++s.sumRowCount,r.value=++r.rowCount}if(this.valueAggrType===s.AGG.TOTAL_COUNT)continue;let t=null;try{t=this.dataFrame.getCol(this.valueColumnName),t.matches("numerical")||(t=null)}catch{t=null}if(t){for(const n of l){const i=this.seqHandler.getSplitted(n),o=e+this.startPosition<i.length?i.getCanonical(this.startPosition+e):this.seqHandler.defaultGapOriginal,s=this.seqHandler.defaultGapOriginal===o?f._S:o,r=t.get(n);this.positions[e].getFreq(s).push(r)}this.positions[e].aggregate(this.valueAggrType)}}const u=this.valueAggrType===s.AGG.TOTAL_COUNT?0:Math.min(0,Math.min(...this.positions.map((e=>e.getMinValue()))));for(let e=0;e<r;++e)this.positions[e].calcPlotValue(u),this.positions[e].calcHeights(this.positionHeight);this._removeEmptyPositions(),this._onFreqsCalculated.next()})(),this.calcLayout(t),-1===this.startPosition)return;const o=Math.max(Math.floor(this.slider.min),0),r=Math.min(this.positions.length-1,Math.floor(this.slider.max));e>=M.Layout&&((e,t,n,o)=>{b._package.logger.debug(`${this.toLog()}.render.calculateLayoutInt(), start `);const r=this.canvas.height-o*n;let a;if(this.valueAggrType===s.AGG.TOTAL_COUNT){const e=this.seqHandler.getAlphabetSize();this.positionHeight==d.fH.Entropy&&null==e&&i.shell.error("WebLogo: alphabet is undefined."),a=Math.log2(e)}else a=Math.max(...c().count(e).takeWhile((e=>e<=t)).map((e=>this.positions[e].sumPlotValueForHeight)));for(let i=e;i<=t;++i)i in this.positions?this.positions[i].calcScreen(i,this.slider.min,r,this.positionHeight,a,this._positionWidthWithMargin,this._positionWidth,n,o):b._package.logger.warning(`${this.toLog()}.render.calculateLayoutInt() this.positions.length = ${this.positions.length}, jPos = ${i}`);b._package.logger.debug(`${this.toLog()}.render.calculateLayoutInt(), end `),this._onLayoutCalculated.next()})(o,r,window.devicePixelRatio,n);const a=this.canvas.getContext("2d");if(a){a.save();try{this.Length,a.resetTransform(),a.fillStyle=function(e){const t=s.Color.a(e);return`#${(16777215&e).toString(16).padStart(6,"0")}`+t.toString(16).padStart(2,"0")}(this.backgroundColor),a.fillRect(0,0,this.canvas.width,this.canvas.height),a.textBaseline=this.textBaseline;const e=10*t;a.resetTransform(),a.fillStyle="black",a.textAlign="center",a.font=`${e.toFixed(1)}px Roboto, Roboto Local, sans-serif`,n>0&&this.positions.length>0&&function(e,t,n,i,o,s,r,a){e.save();try{e.textAlign="center";let l=null,c=null;for(let t=Math.floor(r);t<=Math.floor(a);t++){const n=s[t],i=e.measureText(n.name),o=i.actualBoundingBoxDescent-i.actualBoundingBoxAscent;l=null===l?i.width:Math.max(l,i.width),c=null===c?o:Math.max(c,o)}const u=l<i*t-2?1:(i*t-2)/l;for(let l=Math.floor(r);l<=Math.floor(a);l++){const a=s[l],h=(l-r)*n*t+i*t/2,d=(o*t-c)/2;e.setTransform(u,0,0,1,h,d),e.measureText(a.label),e.fillText(a.label,0,0)}}finally{e.restore()}}(a,t,this._positionWidthWithMargin,this._positionWidth,n,this.positions,this.slider.min,this.slider.max);const i="16px Roboto, Roboto Local, sans-serif",l=.25,c=12.2,u=this.seqHandler.defaultBiotype;for(let e=o;e<=r;e++)this.positions[e].render(a,i,l,c,u,this.monomerLib,this.maxMonomerLetters)}finally{a.restore()}b._package.logger.debug(`${this.toLog()}.render.renderInt( recalcLevel=${e} ), end`)}}renderRequestOnDebounce(e){const t=`${this.toLog()}.renderRequestOnDebounce()`;"HTML"!==a()(this.root).offsetParent().get()[0]?.tagName?(this.requestedRenderLevel=M.None,this.viewSyncer.sync(t,(async()=>{await this.renderInt(e)}))):b._package.logger.warning(`${t}, $(this.root).offsetParent() is the 'HTML' tag.`)}_lastWidth;_lastHeight;sliderOnValuesChanged(e){try{const e={minRange:this.slider.minRange,min:this.slider.min,max:this.slider.max,maxRange:this.slider.maxRange};if(this.canvas&&this.canvas.offsetWidth>0&&(this._positionWidthWithMargin??0)>0){const t=e.max-e.min,n=this.canvas.offsetWidth/t-this.positionMarginValue;w(n,this.positionWidth,.1)?this.render(M.Layout,"sliderOnValuesChanged"):this.getProperty(A.positionWidth)?.set(this,n)}}catch(e){const t=p(e);b._package.logger.error(`${this.toLog()}.sliderOnValuesChanged() error:\n`+t)}}dataFrameFilterOnChanged(e){b._package.logger.debug(`${this.toLog()}.dataFrameFilterChanged()`);try{this.filterSource===d.lT.Filtered&&this.render(M.Freqs,"dataFrameFilterOnChanged")}catch(e){const t=p(e);b._package.logger.error(`${this.toLog()}.dataFrameFilterOnChanged() error:\n`+t)}}dataFrameSelectionOnChanged(e){b._package.logger.debug(`${this.toLog()}.dataFrameSelectionOnChanged()`);try{this.filterSource===d.lT.Selected&&this.render(M.Freqs,"dataFrameSelectionOnChanged")}catch(e){const t=p(e);b._package.logger.error(`${this.toLog()}.dataFrameSelectionOnChanged() error:\n`+t)}}canvasOnMouseMove(e){if(!this.monomerLib||!this.seqHandler)return;const t=window.devicePixelRatio;try{const n=e,i=this.canvas.getCursorPosition(n,t),[r,a]=this.getMonomer(i,t),l=this.showPositionLabels?12*t:0;if(null!==r&&null===a&&0<=i.y&&i.y<=l){const e=[o.divText(`Position ${r.label}`)];if(this.valueAggrType===s.AGG.TOTAL_COUNT){const t=this.seqHandler.defaultBiotype;e.push(r.buildCompositionTable(t,this.monomerLib))}const t=o.divV(e);t.style.maxHeight="80vh",o.tooltip.show(t,n.x+16,n.y+16)}else if(null!==r&&a&&this.dataFrame&&this.seqCol&&this.seqHandler){const e=r.getFreq(a),t=[o.div(`${a}`),o.div(`${e.rowCount} rows`)];this.valueAggrType!==s.AGG.TOTAL_COUNT&&t.push(o.div(`${this.valueAggrType}: ${e.value.toFixed(3)}`));const i=o.divV(t);o.tooltip.show(i,n.x+16,n.y+16)}else o.tooltip.hide()}catch(e){const t=p(e);b._package.logger.error(`${this.toLog()}.canvasOnMouseMove() error:\n`+t)}}canvasOnMouseDown(e){try{const t=e,n=window.devicePixelRatio,[i,o]=this.getMonomer(this.canvas.getCursorPosition(t,n),n);if(null!==i&&null!==o&&this.dataFrame&&this.seqCol&&this.seqHandler){const e=s.BitSet.create(this.dataFrame.selection.length,(e=>function(e,t,n,i,o,s){const r=t.getSplitted(i),a=s.pos<r.length?r.getCanonical(s.pos):null;return null!==a&&a===o}(this.dataFrame,this.seqHandler,this.getFilter(),e,o,i)));this.dataFrame.selection.init((t=>e.get(t)))}}catch(e){const t=p(e);b._package.logger.error(`${this.toLog()}.canvasOnMouseDown() error:\n`+t)}}canvasOnWheel(e){const t=window.devicePixelRatio;try{if(!this.visibleSlider)return;const n=this.canvas.width/(this._positionWidthWithMargin*t),i=e.deltaY/100*Math.max(Math.floor(n/5),1);this.slider.scrollBy(this.slider.min+i)}catch(e){const t=p(e);b._package.logger.error(`${this.toLog()}.canvasOnWheel() error:\n`+t)}}_onRendered=new u.Subject;get onRendered(){return this._onRendered}invalidate(e){const t=`invalidate(${e?` <- ${e} `:""})`,n=`${this.toLog()}.${t}`;this.render(M.None,t),this.viewSyncer.sync(`${n}`,(async()=>{this._onRendered.next()}))}async awaitRendered(e=5e3){await(0,m.PE)(this.onRendered,(()=>{}),(()=>{this.invalidate()}),e);const t=this.viewSyncer.resetErrors();if(t.length>0)throw t[0]}}function _(e,t,n,i,o){let s=0,r=-1;for(;-1!=(r=n.findNext(r,!0));){const e=t.getSplitted(r),n=o.pos,a=n<e.length?e.getCanonical(n):null;null!==a&&a===i&&s++}return s}},1687:(e,t,n)=>{"use strict";n.d(t,{_i:()=>S,AR:()=>T});var i=n(7389),o=n(6082),s=n(4328),r=n(1991),a=n.n(r),l=n(1858),c=n(2003),u=n(8070),h=n(7602),d=n(4954),p=n(4574),m=n(1757),g=n.n(m),f=n(9124),y=n(9192),b=n(4870),w=n(8926);class v extends p.O{seqHelper;emptyProps=new p.n("",void 0,w._package.logger);helmEditor;_filterPanel=i.div("",{style:{cursor:"pointer"}});logger;static viewerCounter=-1;viewerId=++v.viewerCounter;viewerToLog(){return`HelmBioFilter<${this.viewerId}>`}get type(){return"HelmBioFilter"}constructor(e){super(),this.seqHelper=e,this.logger=w._package.logger}viewSubs=[];async detach(){await super.detach();for(const e of this.viewSubs)e.unsubscribe()}async attach(){this.viewerToLog();try{const e=await(0,f.b2)();let t,n;this.helmEditor=e.createHelmWebEditor(),this.logger.warning("TEST: HelmBioFilter.init().sync() waitForElementInDom waiting..."),await i.tools.waitForElementInDom(this._filterPanel),this.logger.warning("TEST: HelmBioFilter.init().sync() waitForElementInDom ready"),this.updateFilterPanel(),this.viewSubs.push((0,l.fromEvent)(this._filterPanel,"click").subscribe((()=>{t=i.div(),n=e.createWebEditorApp(t,this.props.substructure),i.dialog({showHeader:!1,showFooter:!0}).add(t).onOK((()=>{try{const e=n.canvas.getHelm(!0).replace(/<\/span>/g,"").replace(/<span style='background:#bbf;'>/g,"");this.props=new p.n(e,void 0,w._package.logger)}catch(e){this.logger.error(e)}finally{g()(t).empty(),t=null,n=null}})).onCancel((()=>{g()(t).empty(),t=null,n=null})).show({modal:!0,fullScreen:!0})}))),this.viewSubs.push(i.onSizeChanged(this._filterPanel).subscribe((e=>{try{if(n){const e=n.canvas.getHelm(!0).replace(/<\/span>/g,"").replace(/<span style='background:#bbf;'>/g,"");this.updateFilterPanel(e)}}catch(e){const[t,n]=(0,y.AP)(e);this.logger.error(t,void 0,n)}})))}catch(e){const[t,n]=(0,y.AP)(e),o=this._filterPanel;o.innerText="error",o.classList.add("d4-error"),i.tooltip.bind(o,t)}}applyProps(){this.helmEditor&&this.updateFilterPanel(this.props.substructure)}get filterPanel(){return this._filterPanel}updateFilterPanel(e){if(!this.helmEditor)throw new Error("helmEditor is not created, the filter is not in dom yet");const t=this._filterPanel.parentElement.clientWidth<100?100:this._filterPanel.parentElement.clientWidth,n=t/2;if(e)(0,b.Ku)(this._filterPanel,this.helmEditor.host),this.helmEditor.editor.setHelm(e),this.helmEditor.resizeEditor(t,n);else{const e=i.divText("Click to edit","helm-substructure-filter");(0,b.Ku)(this._filterPanel,e)}}async substructureSearch(e){const t=`${this.viewerToLog()}.substructureSearch( column = <${e.name}> )`;w._package.logger.debug(`${t}, start`);try{return await(0,u.cb)(10),await(0,d.if)(this.props.substructure,e,this.seqHelper)}finally{w._package.logger.debug(`${t}, end`)}}}const A="bio-substructure-filter";class C{props;filterId;dataFrameId;columnName;bitset;constructor(e,t,n,i,o){this.props=e,this.filterId=t,this.dataFrameId=n,this.columnName=i,this.bitset=o}}class T extends p.n{separator;constructor(e,t,n){super(e,!1,n),this.separator=t,this.readOnly=!0}}class S extends o.Filter{seqHelper;logger;bioFilter=null;bitset=null;loader;notation=void 0;filterSyncer;get calculating(){return"initial"==this.loader.style.display}set calculating(e){this.loader.style.display=e?"initial":"none"}get filterSummary(){return this.bioFilter.filterSummary}get isFiltering(){return super.isFiltering&&(this.bioFilter?.isFiltering??!1)}get isReadyToApplyFilter(){return!this.calculating&&null!=this.bitset}get debounceTime(){if(null==this.column)return 1e3;const e=this.column.length;return e<500?0:e>1e4?1e3:Math.floor((e-500)/9500*1e3)}constructor(e,t){super(),this.seqHelper=e,this.logger=t,this.root=i.divV([]),this.loader=i.loader(),this.calculating=!1,this.filterSyncer=new h.g(this.logger)}static filterCounter=-1;filterId=++S.filterCounter;filterToLog(){return`BioSubstructureFilter<${this.filterId}>`}viewSubs=[];attach(e){const t=super.attach.bind(this),n=`${this.filterToLog()}.attach()`;this.filterSyncer.sync(n,(async()=>{t(e),this.column||(this.columnName?this.column=this.dataFrame.getCol(this.columnName):this.column=e.columns.bySemType(o.SEMTYPE.MACROMOLECULE)),this.seqHelper.getSeqHandler(this.column),this.columnName??=this.column?.name,this.notation??=this.column?.meta.units,this.bioFilter=this.notation===c.Hi.FASTA?new E:this.notation===c.Hi.SEPARATOR?new M(this.column.getTag(c.gp.separator)):new v(this.seqHelper),this.root.appendChild(this.bioFilter.filterPanel),this.root.appendChild(this.loader),await this.bioFilter.attach(),this.viewSubs.push(o.debounce(this.bioFilter.onChanged,this.debounceTime).subscribe(this.bioFilterOnChangedDebounced.bind(this))),this.viewSubs.push(s.events.onResetFilterRequest.subscribe(this.grokEventsOnResetFilterRequest.bind(this))),this.viewSubs.push(s.events.onCustomEvent(A).subscribe(this.filterOnSync.bind(this)))}))}detach(){const e=super.detach.bind(this),t=`${this.filterToLog()}.detach()`;this.filterSyncer.sync(t,(async()=>{for(const e of this.viewSubs)e.unsubscribe();this.viewSubs=[],e(),this.bioFilter&&this.bioFilter.detach(),this.bioFilter=null}))}filterOnSync(e){e.filterId!==this.filterId&&e.dataFrameId===this.dataFrame.id&&e.columnName===this.columnName&&(this.bioFilter.props=e.props)}applyFilter(){const e=`${this.filterToLog()}.applyFilter()`;this.logger.debug(`${e}, IN`),this.bitset&&!this.isDetached&&this.dataFrame?.filter.and(this.bitset)}saveState(){const e=`${this.filterToLog()}.saveState()`,t=super.saveState();return this.logger.debug(`${e}, super.state = ${JSON.stringify(t)}`),t.props=this.bioFilter.saveProps(),t}applyState(e){const t=`${this.filterToLog()}.applyState()`;super.applyState(e),this.filterSyncer.sync(t,(async()=>{e.props&&this.bioFilter&&(this.bioFilter.props=o.toJs(e.props??{}))}))}fireFilterSync(){const e=`${this.filterToLog()}.fireFilterSync()`;this.logger.debug(`${e}, bioFilter = ${this.bioFilter?this.bioFilter.constructor.name:"null"}`+(this.bioFilter?`, props = ${JSON.stringify(this.bioFilter.saveProps())}`:"")),s.events.fireCustomEvent(A,new C(this.bioFilter.props,this.filterId,this.dataFrame.id,this.columnName,this.bitset))}bioFilterOnChangedDebounced(){if(!this.dataFrame)return;const e=`${this.filterToLog()}.bioFilterOnChangedDebounced()`;if(this.logger.debug(`${e}, start, isFiltering = ${this.isFiltering}, props = ${JSON.stringify(this.bioFilter.saveProps())}`),!this.isFiltering)return this.bitset=null,void this.dataFrame.rows.requestFilter();a()(this.dataFrame.rows.filters).has(`${this.columnName}: ${this.filterSummary}`)||this.filterSyncer.sync(e,(async()=>{this.calculating=!0;try{this.logger.debug(`${e}, before substructureSearch`),this.bitset=await(this.bioFilter?.substructureSearch(this.column)),this.logger.debug(`${e}, after substructureSearch`),this.calculating=!1,this.fireFilterSync(),this.dataFrame?.rows.requestFilter()}finally{this.calculating=!1,this.logger.debug(`${e}, end`)}}))}grokEventsOnResetFilterRequest(){const e=`${this.filterToLog()}.grokEventsOnResetFilterRequest()`;this.logger.debug(`${e}`),this.bioFilter?.resetFilter()}_onRendered=new l.Subject;get onRendered(){return this._onRendered}invalidate(e){const t=`${this.filterToLog()}.invalidate(${e?` <- ${e} `:""})`;this.filterSyncer.sync(t,(async()=>{this._onRendered.next()}))}async awaitRendered(e=1e4){const t=`awaitRendered( ${e} )`,n=`${this.filterToLog()}.${t}`;await(0,u.cb)(10),await(0,u.PE)(this.onRendered,(()=>{this.logger.debug(`${n}, _onRendered event caught`)}),(()=>{this.invalidate(t)}),e,`${n} timeout`);const i=this.filterSyncer.resetErrors();if(i.length>0)throw i[0]}}class E extends p.O{emptyProps=new p.n("",void 0,w._package.logger);substructureInput;get type(){return"FastaBioFilter"}constructor(){super(),this.substructureInput=i.input.string("",{value:"",onValueChanged:e=>{window.setTimeout((()=>{this.props=new p.n(e,void 0,w._package.logger),this._propsChanging||this.onChanged.next()}),0)},placeholder:"Substructure"})}applyProps(){this.substructureInput.value!==this.props.substructure&&(this.substructureInput.value=this.props.substructure)}get filterPanel(){return this.substructureInput.root}get isFiltering(){return""!==this.substructureInput.value}async substructureSearch(e){return(0,d.nI)(this.props.substructure,e)}async attach(){}async detach(){await super.detach()}}class M extends p.O{emptyProps=new T("",void 0,w._package.logger);substructureInput;separatorInput;colSeparator="";get type(){return"SeparatorBioFilter"}constructor(e){super(),this.substructureInput=i.input.string("",{value:"",onValueChanged:e=>{this.props=new T(e,this.props.separator,w._package.logger),setTimeout((()=>{this._propsChanging||this.onChanged.next()}))},placeholder:"Substructure"}),this.separatorInput=i.input.string("",{value:this.colSeparator=e,onValueChanged:e=>{const t=e||"";this.props=new T(this.props.substructure,t,w._package.logger),setTimeout((()=>{this._propsChanging||this.onChanged.next()}))},placeholder:"Separator"})}applyProps(){this.substructureInput.value!==this.props.substructure&&(this.substructureInput.value=this.props.substructure);const e=this.props.separator??this.colSeparator;this.separatorInput.value!==e&&(this.separatorInput.value=e)}get filterSummary(){return this.props.separator?this.props.separator:this.colSeparator,`${this.props.substructure}, {sep}`}get isFiltering(){return""!==this.props.substructure}resetFilter(){this.props=new T("",void 0,w._package.logger)}get filterPanel(){return i.divV([this.substructureInput.root,this.separatorInput.root])}get substructure(){return this.separatorInput.value&&this.separatorInput.value!==this.colSeparator?this.substructureInput.value.replaceAll(this.separatorInput.value,this.colSeparator):this.substructureInput.value}set substructure(e){this.substructureInput.value=e}async substructureSearch(e){return(0,d.nI)(this.substructure,e,this.colSeparator)}async attach(){}async detach(){await super.detach()}}},1757:e=>{"use strict";e.exports=$},6082:e=>{"use strict";e.exports=DG},4328:e=>{"use strict";e.exports=grok},1858:e=>{"use strict";e.exports=rxjs},9713:e=>{"use strict";e.exports=rxjs.operators},7389:e=>{"use strict";e.exports=ui},1991:e=>{"use strict";e.exports=wu},8343:(e,t,n)=>{"use strict";const{normalizeIPv6:i,normalizeIPv4:o,removeDotSegments:s,recomposeAuthority:r,normalizeComponentEncoding:a}=n(4834),l=n(343);function c(e,t,n,i){const o={};return i||(e=p(u(e,n),n),t=p(u(t,n),n)),!(n=n||{}).tolerant&&t.scheme?(o.scheme=t.scheme,o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=s(t.path||""),o.query=t.query):(void 0!==t.userinfo||void 0!==t.host||void 0!==t.port?(o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=s(t.path||""),o.query=t.query):(t.path?("/"===t.path.charAt(0)?o.path=s(t.path):(void 0===e.userinfo&&void 0===e.host&&void 0===e.port||e.path?e.path?o.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+t.path:o.path=t.path:o.path="/"+t.path,o.path=s(o.path)),o.query=t.query):(o.path=e.path,void 0!==t.query?o.query=t.query:o.query=e.query),o.userinfo=e.userinfo,o.host=e.host,o.port=e.port),o.scheme=e.scheme),o.fragment=t.fragment,o}function u(e,t){const n={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:""},i=Object.assign({},t),o=[],a=l[(i.scheme||n.scheme||"").toLowerCase()];a&&a.serialize&&a.serialize(n,i),void 0!==n.path&&(i.skipEscape?n.path=unescape(n.path):(n.path=escape(n.path),void 0!==n.scheme&&(n.path=n.path.split("%3A").join(":")))),"suffix"!==i.reference&&n.scheme&&o.push(n.scheme,":");const c=r(n);if(void 0!==c&&("suffix"!==i.reference&&o.push("//"),o.push(c),n.path&&"/"!==n.path.charAt(0)&&o.push("/")),void 0!==n.path){let e=n.path;i.absolutePath||a&&a.absolutePath||(e=s(e)),void 0===c&&(e=e.replace(/^\/\//u,"/%2F")),o.push(e)}return void 0!==n.query&&o.push("?",n.query),void 0!==n.fragment&&o.push("#",n.fragment),o.join("")}const h=Array.from({length:127},((e,t)=>/[^!"$&'()*+,\-.;=_`a-z{}~]/u.test(String.fromCharCode(t)))),d=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function p(e,t){const n=Object.assign({},t),s={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},r=-1!==e.indexOf("%");let a=!1;"suffix"===n.reference&&(e=(n.scheme?n.scheme+":":"")+"//"+e);const c=e.match(d);if(c){if(s.scheme=c[1],s.userinfo=c[3],s.host=c[4],s.port=parseInt(c[5],10),s.path=c[6]||"",s.query=c[7],s.fragment=c[8],isNaN(s.port)&&(s.port=c[5]),s.host){const e=o(s.host);if(!1===e.isIPV4){const t=i(e.host);s.host=t.host.toLowerCase(),a=t.isIPV6}else s.host=e.host,a=!0}void 0!==s.scheme||void 0!==s.userinfo||void 0!==s.host||void 0!==s.port||void 0!==s.query||s.path?void 0===s.scheme?s.reference="relative":void 0===s.fragment?s.reference="absolute":s.reference="uri":s.reference="same-document",n.reference&&"suffix"!==n.reference&&n.reference!==s.reference&&(s.error=s.error||"URI is not a "+n.reference+" reference.");const e=l[(n.scheme||s.scheme||"").toLowerCase()];if(!(n.unicodeSupport||e&&e.unicodeSupport)&&s.host&&(n.domainHost||e&&e.domainHost)&&!1===a&&function(e){let t=0;for(let n=0,i=e.length;n<i;++n)if(t=e.charCodeAt(n),t>126||h[t])return!0;return!1}(s.host))try{s.host=URL.domainToASCII(s.host.toLowerCase())}catch(e){s.error=s.error||"Host's domain name can not be converted to ASCII: "+e}(!e||e&&!e.skipNormalize)&&(r&&void 0!==s.scheme&&(s.scheme=unescape(s.scheme)),r&&void 0!==s.host&&(s.host=unescape(s.host)),s.path&&(s.path=escape(unescape(s.path))),s.fragment&&(s.fragment=encodeURI(decodeURIComponent(s.fragment)))),e&&e.parse&&e.parse(s,n)}else s.error=s.error||"URI can not be parsed.";return s}const m={SCHEMES:l,normalize:function(e,t){return"string"==typeof e?e=u(p(e,t),t):"object"==typeof e&&(e=p(u(e,t),t)),e},resolve:function(e,t,n){const i=Object.assign({scheme:"null"},n);return u(c(p(e,i),p(t,i),i,!0),{...i,skipEscape:!0})},resolveComponents:c,equal:function(e,t,n){return"string"==typeof e?(e=unescape(e),e=u(a(p(e,n),!0),{...n,skipEscape:!0})):"object"==typeof e&&(e=u(a(e,!0),{...n,skipEscape:!0})),"string"==typeof t?(t=unescape(t),t=u(a(p(t,n),!0),{...n,skipEscape:!0})):"object"==typeof t&&(t=u(a(t,!0),{...n,skipEscape:!0})),e.toLowerCase()===t.toLowerCase()},serialize:u,parse:p};e.exports=m,e.exports.default=m,e.exports.fastUri=m},343:e=>{"use strict";const t=/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu,n=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;function i(e){return"boolean"==typeof e.secure?e.secure:"wss"===String(e.scheme).toLowerCase()}function o(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function s(e){const t="https"===String(e.scheme).toLowerCase();return e.port!==(t?443:80)&&""!==e.port||(e.port=void 0),e.path||(e.path="/"),e}const r={scheme:"http",domainHost:!0,parse:o,serialize:s},a={scheme:"ws",domainHost:!0,parse:function(e){return e.secure=i(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e},serialize:function(e){if(e.port!==(i(e)?443:80)&&""!==e.port||(e.port=void 0),"boolean"==typeof e.secure&&(e.scheme=e.secure?"wss":"ws",e.secure=void 0),e.resourceName){const[t,n]=e.resourceName.split("?");e.path=t&&"/"!==t?t:void 0,e.query=n,e.resourceName=void 0}return e.fragment=void 0,e}},l={http:r,https:{scheme:"https",domainHost:r.domainHost,parse:o,serialize:s},ws:a,wss:{scheme:"wss",domainHost:a.domainHost,parse:a.parse,serialize:a.serialize},urn:{scheme:"urn",parse:function(e,t){if(!e.path)return e.error="URN can not be parsed",e;const i=e.path.match(n);if(i){const n=t.scheme||e.scheme||"urn";e.nid=i[1].toLowerCase(),e.nss=i[2];const o=`${n}:${t.nid||e.nid}`,s=l[o];e.path=void 0,s&&(e=s.parse(e,t))}else e.error=e.error||"URN can not be parsed.";return e},serialize:function(e,t){const n=t.scheme||e.scheme||"urn",i=e.nid.toLowerCase(),o=`${n}:${t.nid||i}`,s=l[o];s&&(e=s.serialize(e,t));const r=e,a=e.nss;return r.path=`${i||t.nid}:${a}`,t.skipEscape=!0,r},skipNormalize:!0},"urn:uuid":{scheme:"urn:uuid",parse:function(e,n){const i=e;return i.uuid=i.nss,i.nss=void 0,n.tolerant||i.uuid&&t.test(i.uuid)||(i.error=i.error||"UUID is not valid."),i},serialize:function(e){const t=e;return t.nss=(e.uuid||"").toLowerCase(),t},skipNormalize:!0}};e.exports=l},4914:e=>{"use strict";e.exports={HEX:{0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15}}},4834:(e,t,n)=>{"use strict";const{HEX:i}=n(4914),o=/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u;function s(e){if(c(e,".")<3)return{host:e,isIPV4:!1};const t=e.match(o)||[],[n]=t;return n?{host:l(n,"."),isIPV4:!0}:{host:e,isIPV4:!1}}function r(e,t=!1){let n="",o=!0;for(const t of e){if(void 0===i[t])return;"0"!==t&&!0===o&&(o=!1),o||(n+=t)}return t&&0===n.length&&(n="0"),n}function a(e){if(c(e,":")<2)return{host:e,isIPV6:!1};const t=function(e){let t=0;const n={error:!1,address:"",zone:""},i=[],o=[];let s=!1,a=!1,l=!1;function c(){if(o.length){if(!1===s){const e=r(o);if(void 0===e)return n.error=!0,!1;i.push(e)}o.length=0}return!0}for(let r=0;r<e.length;r++){const u=e[r];if("["!==u&&"]"!==u)if(":"!==u)if("%"===u){if(!c())break;s=!0}else o.push(u);else{if(!0===a&&(l=!0),!c())break;if(t++,i.push(":"),t>7){n.error=!0;break}r-1>=0&&":"===e[r-1]&&(a=!0)}}return o.length&&(s?n.zone=o.join(""):l?i.push(o.join("")):i.push(r(o))),n.address=i.join(""),n}(e);if(t.error)return{host:e,isIPV6:!1};{let e=t.address,n=t.address;return t.zone&&(e+="%"+t.zone,n+="%25"+t.zone),{host:e,escapedHost:n,isIPV6:!0}}}function l(e,t){let n="",i=!0;const o=e.length;for(let s=0;s<o;s++){const r=e[s];"0"===r&&i?(s+1<=o&&e[s+1]===t||s+1===o)&&(n+=r,i=!1):(i=r===t,n+=r)}return n}function c(e,t){let n=0;for(let i=0;i<e.length;i++)e[i]===t&&n++;return n}const u=/^\.\.?\//u,h=/^\/\.(?:\/|$)/u,d=/^\/\.\.(?:\/|$)/u,p=/^\/?(?:.|\n)*?(?=\/|$)/u;e.exports={recomposeAuthority:function(e){const t=[];if(void 0!==e.userinfo&&(t.push(e.userinfo),t.push("@")),void 0!==e.host){let n=unescape(e.host);const i=s(n);if(i.isIPV4)n=i.host;else{const t=a(i.host);n=!0===t.isIPV6?`[${t.escapedHost}]`:e.host}t.push(n)}return"number"!=typeof e.port&&"string"!=typeof e.port||(t.push(":"),t.push(String(e.port))),t.length?t.join(""):void 0},normalizeComponentEncoding:function(e,t){const n=!0!==t?escape:unescape;return void 0!==e.scheme&&(e.scheme=n(e.scheme)),void 0!==e.userinfo&&(e.userinfo=n(e.userinfo)),void 0!==e.host&&(e.host=n(e.host)),void 0!==e.path&&(e.path=n(e.path)),void 0!==e.query&&(e.query=n(e.query)),void 0!==e.fragment&&(e.fragment=n(e.fragment)),e},removeDotSegments:function(e){const t=[];for(;e.length;)if(e.match(u))e=e.replace(u,"");else if(e.match(h))e=e.replace(h,"/");else if(e.match(d))e=e.replace(d,"/"),t.pop();else if("."===e||".."===e)e="";else{const n=e.match(p);if(!n)throw new Error("Unexpected dot segment condition");{const i=n[0];e=e.slice(i.length),t.push(i)}}return t.join("")},normalizeIPv4:s,normalizeIPv6:a,stringArrayToHexStripped:r}},3837:e=>{"use strict";e.exports=JSON.parse('{"$id":"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#","description":"Meta-schema for $data reference (JSON AnySchema extension proposal)","type":"object","required":["$data"],"properties":{"$data":{"type":"string","anyOf":[{"format":"relative-json-pointer"},{"format":"json-pointer"}]}},"additionalProperties":false}')},7216:e=>{"use strict";e.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/meta/applicator","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/applicator":true},"$dynamicAnchor":"meta","title":"Applicator vocabulary meta-schema","type":["object","boolean"],"properties":{"prefixItems":{"$ref":"#/$defs/schemaArray"},"items":{"$dynamicRef":"#meta"},"contains":{"$dynamicRef":"#meta"},"additionalProperties":{"$dynamicRef":"#meta"},"properties":{"type":"object","additionalProperties":{"$dynamicRef":"#meta"},"default":{}},"patternProperties":{"type":"object","additionalProperties":{"$dynamicRef":"#meta"},"propertyNames":{"format":"regex"},"default":{}},"dependentSchemas":{"type":"object","additionalProperties":{"$dynamicRef":"#meta"},"default":{}},"propertyNames":{"$dynamicRef":"#meta"},"if":{"$dynamicRef":"#meta"},"then":{"$dynamicRef":"#meta"},"else":{"$dynamicRef":"#meta"},"allOf":{"$ref":"#/$defs/schemaArray"},"anyOf":{"$ref":"#/$defs/schemaArray"},"oneOf":{"$ref":"#/$defs/schemaArray"},"not":{"$dynamicRef":"#meta"}},"$defs":{"schemaArray":{"type":"array","minItems":1,"items":{"$dynamicRef":"#meta"}}}}')},8226:e=>{"use strict";e.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/meta/content","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/content":true},"$dynamicAnchor":"meta","title":"Content vocabulary meta-schema","type":["object","boolean"],"properties":{"contentEncoding":{"type":"string"},"contentMediaType":{"type":"string"},"contentSchema":{"$dynamicRef":"#meta"}}}')},518:e=>{"use strict";e.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/meta/core","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/core":true},"$dynamicAnchor":"meta","title":"Core vocabulary meta-schema","type":["object","boolean"],"properties":{"$id":{"$ref":"#/$defs/uriReferenceString","$comment":"Non-empty fragments not allowed.","pattern":"^[^#]*#?$"},"$schema":{"$ref":"#/$defs/uriString"},"$ref":{"$ref":"#/$defs/uriReferenceString"},"$anchor":{"$ref":"#/$defs/anchorString"},"$dynamicRef":{"$ref":"#/$defs/uriReferenceString"},"$dynamicAnchor":{"$ref":"#/$defs/anchorString"},"$vocabulary":{"type":"object","propertyNames":{"$ref":"#/$defs/uriString"},"additionalProperties":{"type":"boolean"}},"$comment":{"type":"string"},"$defs":{"type":"object","additionalProperties":{"$dynamicRef":"#meta"}}},"$defs":{"anchorString":{"type":"string","pattern":"^[A-Za-z_][-A-Za-z0-9._]*$"},"uriString":{"type":"string","format":"uri"},"uriReferenceString":{"type":"string","format":"uri-reference"}}}')},4588:e=>{"use strict";e.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/meta/format-annotation","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/format-annotation":true},"$dynamicAnchor":"meta","title":"Format vocabulary meta-schema for annotation results","type":["object","boolean"],"properties":{"format":{"type":"string"}}}')},5707:e=>{"use strict";e.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/meta/meta-data","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/meta-data":true},"$dynamicAnchor":"meta","title":"Meta-data vocabulary meta-schema","type":["object","boolean"],"properties":{"title":{"type":"string"},"description":{"type":"string"},"default":true,"deprecated":{"type":"boolean","default":false},"readOnly":{"type":"boolean","default":false},"writeOnly":{"type":"boolean","default":false},"examples":{"type":"array","items":true}}}')},9547:e=>{"use strict";e.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/meta/unevaluated","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/unevaluated":true},"$dynamicAnchor":"meta","title":"Unevaluated applicator vocabulary meta-schema","type":["object","boolean"],"properties":{"unevaluatedItems":{"$dynamicRef":"#meta"},"unevaluatedProperties":{"$dynamicRef":"#meta"}}}')},7082:e=>{"use strict";e.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/meta/validation","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/validation":true},"$dynamicAnchor":"meta","title":"Validation vocabulary meta-schema","type":["object","boolean"],"properties":{"type":{"anyOf":[{"$ref":"#/$defs/simpleTypes"},{"type":"array","items":{"$ref":"#/$defs/simpleTypes"},"minItems":1,"uniqueItems":true}]},"const":true,"enum":{"type":"array","items":true},"multipleOf":{"type":"number","exclusiveMinimum":0},"maximum":{"type":"number"},"exclusiveMaximum":{"type":"number"},"minimum":{"type":"number"},"exclusiveMinimum":{"type":"number"},"maxLength":{"$ref":"#/$defs/nonNegativeInteger"},"minLength":{"$ref":"#/$defs/nonNegativeIntegerDefault0"},"pattern":{"type":"string","format":"regex"},"maxItems":{"$ref":"#/$defs/nonNegativeInteger"},"minItems":{"$ref":"#/$defs/nonNegativeIntegerDefault0"},"uniqueItems":{"type":"boolean","default":false},"maxContains":{"$ref":"#/$defs/nonNegativeInteger"},"minContains":{"$ref":"#/$defs/nonNegativeInteger","default":1},"maxProperties":{"$ref":"#/$defs/nonNegativeInteger"},"minProperties":{"$ref":"#/$defs/nonNegativeIntegerDefault0"},"required":{"$ref":"#/$defs/stringArray"},"dependentRequired":{"type":"object","additionalProperties":{"$ref":"#/$defs/stringArray"}}},"$defs":{"nonNegativeInteger":{"type":"integer","minimum":0},"nonNegativeIntegerDefault0":{"$ref":"#/$defs/nonNegativeInteger","default":0},"simpleTypes":{"enum":["array","boolean","integer","null","number","object","string"]},"stringArray":{"type":"array","items":{"type":"string"},"uniqueItems":true,"default":[]}}}')},1678:e=>{"use strict";e.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/schema","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/core":true,"https://json-schema.org/draft/2020-12/vocab/applicator":true,"https://json-schema.org/draft/2020-12/vocab/unevaluated":true,"https://json-schema.org/draft/2020-12/vocab/validation":true,"https://json-schema.org/draft/2020-12/vocab/meta-data":true,"https://json-schema.org/draft/2020-12/vocab/format-annotation":true,"https://json-schema.org/draft/2020-12/vocab/content":true},"$dynamicAnchor":"meta","title":"Core and Validation specifications meta-schema","allOf":[{"$ref":"meta/core"},{"$ref":"meta/applicator"},{"$ref":"meta/unevaluated"},{"$ref":"meta/validation"},{"$ref":"meta/meta-data"},{"$ref":"meta/format-annotation"},{"$ref":"meta/content"}],"type":["object","boolean"],"$comment":"This meta-schema also defines keywords that have appeared in previous drafts in order to prevent incompatible extensions as they remain in common use.","properties":{"definitions":{"$comment":"\\"definitions\\" has been replaced by \\"$defs\\".","type":"object","additionalProperties":{"$dynamicRef":"#meta"},"deprecated":true,"default":{}},"dependencies":{"$comment":"\\"dependencies\\" has been split and replaced by \\"dependentSchemas\\" and \\"dependentRequired\\" in order to serve their differing semantics.","type":"object","additionalProperties":{"anyOf":[{"$dynamicRef":"#meta"},{"$ref":"meta/validation#/$defs/stringArray"}]},"deprecated":true,"default":{}},"$recursiveAnchor":{"$comment":"\\"$recursiveAnchor\\" has been replaced by \\"$dynamicAnchor\\".","$ref":"meta/core#/$defs/anchorString","deprecated":true},"$recursiveRef":{"$comment":"\\"$recursiveRef\\" has been replaced by \\"$dynamicRef\\".","$ref":"meta/core#/$defs/uriReferenceString","deprecated":true}}}')},2079:e=>{"use strict";e.exports=JSON.parse('{"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://json-schema.org/draft-07/schema#","title":"Core schema meta-schema","definitions":{"schemaArray":{"type":"array","minItems":1,"items":{"$ref":"#"}},"nonNegativeInteger":{"type":"integer","minimum":0},"nonNegativeIntegerDefault0":{"allOf":[{"$ref":"#/definitions/nonNegativeInteger"},{"default":0}]},"simpleTypes":{"enum":["array","boolean","integer","null","number","object","string"]},"stringArray":{"type":"array","items":{"type":"string"},"uniqueItems":true,"default":[]}},"type":["object","boolean"],"properties":{"$id":{"type":"string","format":"uri-reference"},"$schema":{"type":"string","format":"uri"},"$ref":{"type":"string","format":"uri-reference"},"$comment":{"type":"string"},"title":{"type":"string"},"description":{"type":"string"},"default":true,"readOnly":{"type":"boolean","default":false},"examples":{"type":"array","items":true},"multipleOf":{"type":"number","exclusiveMinimum":0},"maximum":{"type":"number"},"exclusiveMaximum":{"type":"number"},"minimum":{"type":"number"},"exclusiveMinimum":{"type":"number"},"maxLength":{"$ref":"#/definitions/nonNegativeInteger"},"minLength":{"$ref":"#/definitions/nonNegativeIntegerDefault0"},"pattern":{"type":"string","format":"regex"},"additionalItems":{"$ref":"#"},"items":{"anyOf":[{"$ref":"#"},{"$ref":"#/definitions/schemaArray"}],"default":true},"maxItems":{"$ref":"#/definitions/nonNegativeInteger"},"minItems":{"$ref":"#/definitions/nonNegativeIntegerDefault0"},"uniqueItems":{"type":"boolean","default":false},"contains":{"$ref":"#"},"maxProperties":{"$ref":"#/definitions/nonNegativeInteger"},"minProperties":{"$ref":"#/definitions/nonNegativeIntegerDefault0"},"required":{"$ref":"#/definitions/stringArray"},"additionalProperties":{"$ref":"#"},"definitions":{"type":"object","additionalProperties":{"$ref":"#"},"default":{}},"properties":{"type":"object","additionalProperties":{"$ref":"#"},"default":{}},"patternProperties":{"type":"object","additionalProperties":{"$ref":"#"},"propertyNames":{"format":"regex"},"default":{}},"dependencies":{"type":"object","additionalProperties":{"anyOf":[{"$ref":"#"},{"$ref":"#/definitions/stringArray"}]}},"propertyNames":{"$ref":"#"},"const":true,"enum":{"type":"array","items":true,"minItems":1,"uniqueItems":true},"type":{"anyOf":[{"$ref":"#/definitions/simpleTypes"},{"type":"array","items":{"$ref":"#/definitions/simpleTypes"},"minItems":1,"uniqueItems":true}]},"format":{"type":"string"},"contentMediaType":{"type":"string"},"contentEncoding":{"type":"string"},"if":{"$ref":"#"},"then":{"$ref":"#"},"else":{"$ref":"#"},"allOf":{"$ref":"#/definitions/schemaArray"},"anyOf":{"$ref":"#/definitions/schemaArray"},"oneOf":{"$ref":"#/definitions/schemaArray"},"not":{"$ref":"#"}},"default":true}')}},t={};function n(i){var o=t[i];if(void 0!==o)return o.exports;var s=t[i]={id:i,loaded:!1,exports:{}};return e[i].call(s.exports,s,s.exports,n),s.loaded=!0,s.exports}n.m=e,n.amdO={},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.u=e=>e+".js",n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.hmd=e=>((e=Object.create(e)).children||(e.children=[]),Object.defineProperty(e,"exports",{enumerable:!0,set:()=>{throw new Error("ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: "+e.id)}}),e),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})},(()=>{var e;n.g.importScripts&&(e=n.g.location+"");var t=n.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var i=t.getElementsByTagName("script");if(i.length)for(var o=i.length-1;o>-1&&(!e||!/^http(s?):/.test(e));)e=i[o--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=e})(),n.b=document.baseURI||self.location.href,n.nc=void 0;var i={};(()=>{"use strict";n.r(i),n.d(i,{_package:()=>Ce,initAutoTests:()=>Se,test:()=>Te,tests:()=>t.CN});var e=n(6082),t=n(8070);(0,t.L1)("_first",(()=>{(0,t.t6)("_first",(async()=>{}))}));var o=n(8924),s=n(7362),r=n(1093);(0,t.L1)("Palettes",(()=>{(0,t.t6)("testPaletteN",(async()=>{await async function(){const e=r.A.Chromatogram;(0,t.E3)(e instanceof s.e,!0),(0,t.E3)(e instanceof r.A,!0)}()})),(0,t.t6)("testPaletteAA",(async()=>{await async function(){const e=o.X.Lesk,n=o.X.RasMol,i=o.X.GrokGroups;(0,t.E3)(e instanceof s.e,!0),(0,t.E3)(n instanceof s.e,!0),(0,t.E3)(i instanceof s.e,!0),(0,t.E3)(e instanceof o.X,!0),(0,t.E3)(n instanceof o.X,!0),(0,t.E3)(i instanceof o.X,!0)}()})),(0,t.t6)("testPalettePtMe",(async()=>{const e=o.X.GrokGroups.get("MeNle"),n=o.X.GrokGroups.get("MeA"),i=o.X.GrokGroups.get("MeG"),s=o.X.GrokGroups.get("MeF"),r=o.X.GrokGroups.get("L"),a=o.X.GrokGroups.get("A"),l=o.X.GrokGroups.get("G"),c=o.X.GrokGroups.get("F");(0,t.E3)(e,r),(0,t.E3)(n,a),(0,t.E3)(i,l),(0,t.E3)(s,c)}))}));var a=n(4328),l=n(2003),c=n(8312);class u{units;aligned;alphabet;alphabetSize;alphabetIsMultichar;separator;constructor(e,t,n,i,o,s){this.units=e,this.aligned=t,this.alphabet=n,this.alphabetSize=i,this.alphabetIsMultichar=o,this.separator=s}}async function h(t,n){const i=(await t()).getCol(n),o=await a.functions.call("Bio:detectMacromolecule",{col:i});if(o&&(i.semType=o),i.semType===e.SEMTYPE.MACROMOLECULE){const e=`Negative test detected semType='${i.semType}', units='${i.meta.units}'.`;throw new Error(e)}}async function d(n,i,o,s,r,c,u,h,d=null){const p=(await n()).col(i),m=await a.functions.call("Bio:detectMacromolecule",{col:p});m&&(p.semType=m),(0,t.E3)(p.semType,e.SEMTYPE.MACROMOLECULE),(0,t.E3)(p.meta.units,s),(0,t.E3)(p.getTag(l.gp.aligned),r),(0,t.E3)(p.getTag(l.gp.alphabet),c),d&&(0,t.E3)(p.getTag(l.gp.separator),d);const g=o.getSeqHandler(p);(0,t.E3)(g.getAlphabetSize(),u),(0,t.E3)(g.getAlphabetIsMultichar(),h),g.isHelm()||((0,t.E3)(g.aligned,r),(0,t.E3)(g.alphabet,c))}async function p(t){const n=e.Column.fromList(e.TYPE.STRING,"col1",t);if(await a.functions.call("Bio:detectMacromolecule",{col:n}),n.semType===e.SEMTYPE.MACROMOLECULE){const e=`Negative test detected semType='${n.semType}', units='${n.meta.units}'.`;throw new Error(e)}}async function m(n,i,o,s,r,c,u,h=null){const d=e.Column.fromList(e.TYPE.STRING,"seq",n),p=await a.functions.call("Bio:detectMacromolecule",{col:d});p&&(d.semType=p),(0,t.E3)(d.semType,e.SEMTYPE.MACROMOLECULE),(0,t.E3)(d.meta.units,o),(0,t.E3)(d.getTag(l.gp.aligned),s),(0,t.E3)(d.getTag(l.gp.alphabet),r),h&&(0,t.E3)(d.getTag(l.gp.separator),h);const m=i.getSeqHandler(d);(0,t.E3)(m.getAlphabetSize(),c),(0,t.E3)(m.getAlphabetIsMultichar(),u),m.isHelm()||((0,t.E3)(m.aligned,s),(0,t.E3)(m.alphabet,r))}async function g(e,t,n){const i=await e(),o=[];for(const s of i.columns.names())if(s in t){const i=t[s];try{await d(e,s,n,i.units,i.aligned,i.alphabet,i.alphabetSize,i.alphabetIsMultichar,i.separator)}catch(e){const t=e.toString();o.push(`Positive col '${s}' failed: ${t}`)}}else try{await h(e,s)}catch(e){const t=e.toString();o.push(`Negative col '${s}' failed: ${t}`)}if(o.length>0)throw new Error(o.join("\n"))}(0,t.L1)("detectors",(()=>{let n;(0,t.gM)((async()=>{n=await(0,c.Q)()}));const i={negEmpty:{csv:"id,col1\n1,\n2,\n3,\n4,\n5,",neg:["col1"]},negNum1:{csv:"col1\n1\n2\n3",neg:["col1"]},negNum2:{csv:"col1\n4\n5\n6\n7",neg:["col1"]},negNum3:{csv:"col1\n8\n9\n10\n11\n12",neg:["col1"]},negSmiles:{csv:"col1\nCCCCN1C(=O)CN=C(c2cc(F)ccc12)C3CCCCC3\nC1CCCCC1\nCCCCCC",neg:["col1"]},negSmilesWithSquareBrackets:{csv:"col1\nCl.c1ccc2nc3ccccc3cc2c1\nOc1cccc2cc3ccccc3cc12\n[SeH]c1ccc2ccccc2c1",neg:["col1"]},negFastaUnSingleChar:{csv:"col1\nAlanine\nCysteine\nAspartic acid\nGlutamic acid\nPhenylalanine",neg:["col1"]},fastaMsaSameLength:{csv:"seq\nFWPHEYFWPHEYYV\nYNRQWYVYNRQWYV\nMKPSEYVMKPSEYV",pos:{seq:new u(l.Hi.FASTA,"SEQ.MSA",l.YI.PT,20,!1,void 0)}},fastaExtSameLength:{csv:"seq\nFW[Ac]PHEYFWPH\nYN[Re]VYNRQWYV\n[Me]EYVMPS[Et]",pos:{seq:new u(l.Hi.FASTA,"SEQ",l.YI.UN,16,!0,void 0)}},fastaMsaExtSameLength:{csv:"seq\nFW[Ac]PHEY[Re]WPH\nYN[Re]VYNR[Ac]WYV\n[Me]EYVMPSFW[Me]H",pos:{seq:new u(l.Hi.FASTA,"SEQ.MSA",l.YI.UN,14,!0,void 0)}},fastaMsaExtManyMinus:{csv:"seq\n[D-Tic]-------[D-Tyr_Et][Tyr_ab-dehydroMe][dV][Cys_SEt]N[D-Orn][D-aThr]-[Phe_4Me]\n[Phe_2F]--------[Tyr_ab-dehydroMe][dV][Aca]N[D-Orn][D-aThr]-[Phe_4Me]\n[D-Tic]-[Hcy]QTWQ[Phe_4NH2][D-Tyr_Et][Tyr_ab-dehydroMe][dV][Cys_SEt]----[Phe_4Me]",pos:{seq:new u(l.Hi.FASTA,"SEQ.MSA",l.YI.UN,17,!0,void 0)}},sepSameLength:{csv:"seq\nAca-A-A-A-A-A-A-A-A-A-A-A-A-A-C-G-NH2\nAca-A-A-A-A-A-A-A-A-A-A-A-A-A-C-G-NH2\nAca-A-A-A-A-A-A-A-A-A-A-A-A-A-C-G-NH2",pos:{seq:new u(l.Hi.SEPARATOR,"SEQ.MSA",l.YI.UN,5,!0,"-")}},sepMsaSameLength:{csv:"seq\nAca-A-A-A-A-A-A-A-A-A-A-A-A-A-Aca-G-NH2\nAca-A-Aca-A-A-A-meI-A-A-A-A-A-Aca-G-NH2\nAca-A-A-A-A-A-A-A-A-A-A-A-A-A-Aca-G-NH2",pos:{seq:new u(l.Hi.SEPARATOR,"SEQ",l.YI.UN,5,!0,"-")}},helmSameLength:{csv:"seq\nPEPTIDE1{Ac(1).A.A.A.A.A.A.A.A.A.A.A.A.A.C(1).G.NH2}$$$$\nPEPTIDE1{Ab(1).Y.V.K.H.P.F.W.R.W.Y.A.A.A.C(1).G.NH2}$$$$\nPEPTIDE1{Ad(1).S.W.Y.C.K.H.P.M.W.A.A.A.A.C(1)-G-NH2}$$$$",pos:{seq:new u(l.Hi.HELM,null,null,19,void 0,void 0)}},fastaNonDigitAlphabet:{csv:'flagC\n"NMe-pyridazineH"\n"Pyrrolo[2,3-c]pyridazineH"',neg:["flagC"]}};for(const[o,s]of Object.entries(i))(0,t.t6)(`csvData2-${o}`,(async()=>{const t=(r=o,async()=>{const t=i[r].csv,n=e.DataFrame.fromCsv(t);return await a.data.detectSemanticTypes(n),n});var r;for(const e of s.neg??[])await h(t,e);for(const[e,i]of Object.entries(s.pos??{}))await d(t,e,n,i.units,i.aligned,i.alphabet,i.alphabetSize,i.alphabetIsMultichar,i.separator)}));const o=new class{csvFastaDna1="seq\nACGTCACGTC\nCAGTGTCAGTGT\nTTCAACTTCAAC";fastaRna1="seq\nACGUCACGUC\nCAGUGUCAGUGU\nUUCAACUUCAAC";fastaPt1="seq\nFWPHEY\nYNRQWYV\nMKPSEYV";fastaUn="seq\n[meI][hHis][Aca]NT[dE][Thr_PO3H2][Aca]DN\n[meI][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2][Aca]\n[Lys_Boc][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2][Aca]";sepDna="seq\nA*C*G*T*C*A*C*G*T*C\nC*A*G*T*G*T*C*A*G*T*G*T\nT*T*C*A*A*C*T*T*C*A*A*C";sepRna="seq\nA*C*G*U*C*A*C*G*U*C\nC*A*G*U*G*U*C*A*G*U*G*U\nU*U*C*A*A*C*U*U*C*A*A*C";sepPt="seq\nF-W-P-H-E-Y-F-W-P-H-E-Y\nY-N-R-Q-W-Y-V-Y-N-R-Q-W-Y-V\nM-K-P-S-E-Y-V-M-K-P-S-E-Y-V";sepUn1="seq\nabc-dfgg-abc1-cfr3-rty-wert-cfr3-rty-wert\nrut12-her2-rty-wert-abc-abc1-dfgg-abc-abc1-dfgg\nrut12-rty-her2-abc-cfr3-wert-rut12-cfr3-wert-rut12";sepUn2="seq\nabc/dfgg/abc1/cfr3/rty/wert/abc/dfgg/abc1/cfr3/rty/wert\nrut12/her2/rty/wert//abc/abc1/dfgg/rut12/her2/rty/wert//abc/abc1/dfgg\nrut12/rty/her2/abc/cfr3//wert/rut12/rut12/rty/her2/abc/cfr3//wert/rut12";sepMsaDna1="seq\nA-C--G-T--C-T-A-C--G-T--C-T\nC-A-C--T--G-T-C-A-C--T--G-T\nA-C-C-G-T-A-C-T-A-C-C-G-T-A-C-T";sepMsaUnWEmpty="seq\nm1-M-m3-mon4-mon5-N-T-MON8-N9-m1-M-m3-mon4-mon5-N-T-MON8-N9\nm1-mon2-m3-mon4-mon5-Num--MON8-N9-m1-mon2-m3-mon4-mon5-Num--MON8-N9\n\nmon1-M-mon3-mon4-mon5---MON8-N9-mon1-M-mon3-mon4-mon5---MON8-N9";sepComplex="seq\nAca-F-K(AEEA-AEEA-R-Ac)-L-mF-V-Y-mNle-D-W-N-mF-Aca-G-NH2\nAca-F-K(AEEA-ARRA-W-Ac)-L-mF-V-Y-mNle-D-W-N-mF-Aca-G-NH2\nAca-F-K(AEEA-AEEA-Ac)-L-mF-V-Y-mNle-D-W-N-mF-Aca-G-NH2";fastaMsaDna1="seq\nAC-GT-CTAC-GT-CT\nCAC-T-GTCAC-T-GT\nACCGTACTACCGTACT";fastaMsaPt1="seq\nFWR-WYV-KHPFWR-WYV-KHP\nYNR-WYV-KHPYNR-WYV-KHP\nMWRSWY-CKHPMWRSWY-CKHP"},s={fastaPtCsv:"System:AppData/Bio/samples/FASTA_PT.csv",msaComplex:"System:AppData/Bio/samples/MSA.csv",fastaCsv:"System:AppData/Bio/samples/FASTA.csv",helmCsv:"System:AppData/Bio/samples/HELM.csv",peptidesComplex:"System:AppData/Bio/tests/peptides_complex_msa.csv",peptidesSimple:"System:AppData/Bio/tests/peptides_simple_msa.csv",testDemogCsv:"System:AppData/Bio/tests/testDemog.csv",testHelmCsv:"System:AppData/Bio/tests/testHelm.csv",testIdCsv:"System:AppData/Bio/tests/testId.csv",testSmilesCsv:"System:AppData/Bio/tests/testSmiles.csv",testSmiles2Csv:"System:AppData/Bio/tests/testSmiles2.csv",testSmilesShort:"System:AppData/Bio/tests/testSmilesShort.csv",testActivityCliffsCsv:"System:AppData/Bio/tests/testActivityCliffs.csv",testCerealCsv:"System:AppData/Bio/tests/testCereal.csv",testUnichemSources:"System:AppData/Bio/tests/testUnichemSources.csv",testDmvOffices:"System:AppData/Bio/tests/testDmvOffices.csv",testAlertCollection:"System:AppData/Bio/tests/testAlertCollection.csv",testSpgi100:"System:AppData/Bio/tests/testSpgi100.csv",testSpgi:"System:AppData/Bio/tests/SPGI-derived.csv",testUrl:"System:AppData/Bio/tests/testUrl.csv",fasta_negative_words:"System:AppData/Bio/tests/fasta_negative_words.csv"},r={};function f(e,t=y){return async()=>(e in r||(r[e]=(async()=>await t(s[e]))().catch((t=>{throw delete r[e],t}))),r[e])}async function y(t){const n=await a.dapi.files.readAsText(t);return e.DataFrame.fromCsv(n)}const b=t=>async()=>{const n=o[t],i=e.DataFrame.fromCsv(n);return await a.data.detectSemanticTypes(i),i};(0,t.t6)("NegativeStartEnd",(async()=>{await p(["START","END"])})),(0,t.t6)("NegativeStartEndIntermediate",(async()=>{await p(["START","END","INTERMEDIATE"])})),(0,t.t6)("FastaDna1",(async()=>{await d(b("csvFastaDna1"),"seq",n,l.Hi.FASTA,"SEQ",l.YI.DNA,4,!1)})),(0,t.t6)("FastaRna1",(async()=>{await d(b("fastaRna1"),"seq",n,l.Hi.FASTA,"SEQ",l.YI.RNA,4,!1)})),(0,t.t6)("FastaPt1",(async()=>{await d(b("fastaPt1"),"seq",n,l.Hi.FASTA,"SEQ",l.YI.PT,20,!1)})),(0,t.t6)("FastaPtGaps",(()=>m(["FW-PH-EYY","FYNRQWYV-","FKP-Q-SEYV"],n,l.Hi.FASTA,"SEQ",l.YI.PT,20,!1))),(0,t.t6)("FastaPtGapsMsa",(()=>m(["FW-PH-EYY","FYNRQWYV-","FKP-Q-SEY"],n,l.Hi.FASTA,"SEQ.MSA",l.YI.PT,20,!1))),(0,t.t6)("FastaUn",(async()=>{await d(b("fastaUn"),"seq",n,l.Hi.FASTA,"SEQ.MSA",l.YI.UN,12,!0)})),(0,t.t6)("FastaMsaDna1",(async()=>{await d(b("fastaMsaDna1"),"seq",n,l.Hi.FASTA,"SEQ.MSA",l.YI.DNA,4,!1)})),(0,t.t6)("FastaMsaPt1",(async()=>{await d(b("fastaMsaPt1"),"seq",n,l.Hi.FASTA,"SEQ.MSA",l.YI.PT,20,!1)})),(0,t.t6)("SepDna",(async()=>{await d(b("sepDna"),"seq",n,l.Hi.SEPARATOR,"SEQ",l.YI.DNA,4,!1,"*")})),(0,t.t6)("SepRna",(async()=>{await d(b("sepRna"),"seq",n,l.Hi.SEPARATOR,"SEQ",l.YI.RNA,4,!1,"*")})),(0,t.t6)("SepPt",(async()=>{await d(b("sepPt"),"seq",n,l.Hi.SEPARATOR,"SEQ",l.YI.PT,20,!1,"-")})),(0,t.t6)("SepUn1",(async()=>{await d(b("sepUn1"),"seq",n,l.Hi.SEPARATOR,"SEQ",l.YI.UN,8,!0,"-")})),(0,t.t6)("SepUn2",(async()=>{await d(b("sepUn2"),"seq",n,l.Hi.SEPARATOR,"SEQ",l.YI.UN,9,!0,"/")})),(0,t.t6)("SepMsaN1",(async()=>{await d(b("sepMsaDna1"),"seq",n,l.Hi.SEPARATOR,"SEQ.MSA",l.YI.DNA,4,!1,"-")})),(0,t.t6)("SepMsaUnWEmpty",(async()=>{await d(b("sepMsaUnWEmpty"),"seq",n,l.Hi.SEPARATOR,"SEQ.MSA",l.YI.UN,14,!0)})),(0,t.t6)("SepComplex",(async()=>{await d(b("sepComplex"),"seq",n,l.Hi.SEPARATOR,"SEQ",l.YI.UN,17,!0)})),(0,t.t6)("samplesFastaCsv",(async()=>{await g(f("fastaCsv"),{Sequence:new u(l.Hi.FASTA,"SEQ",l.YI.PT,20,!1)},n)})),(0,t.t6)("samplesPeptidesComplex",(async()=>{await g(f("peptidesComplex"),{},n)})),(0,t.t6)("samplesMsaComplex",(async()=>{await g(f("msaComplex"),{MSA:new u(l.Hi.SEPARATOR,"SEQ.MSA",l.YI.UN,161,!0,"/")},n)})),(0,t.t6)("samplesIdCsv",(async()=>{await g(f("testIdCsv"),{},n)})),(0,t.t6)("samplesSarSmallCsv",(async()=>{await g(f("testSmilesCsv"),{},n)})),(0,t.t6)("samplesHelmCsv",(async()=>{await g(f("helmCsv"),{HELM:new u(l.Hi.HELM,null,null,160,!0)},n)})),(0,t.t6)("samplesTestHelmCsv",(async()=>{await g(f("testHelmCsv"),{"HELM string":new u(l.Hi.HELM,null,null,9,!0)},n)})),(0,t.t6)("samplesTestDemogCsv",(async()=>{await g(f("testDemogCsv"),{},n)})),(0,t.t6)("samplesTestSmiles2Csv",(async()=>{await g(f("testSmiles2Csv"),{},n)})),(0,t.t6)("samplesTestSmilesShort",(async()=>{await g(f("testSmilesShort"),{},n)})),(0,t.t6)("samplesTestActivityCliffsNegativeSmiles",(async()=>{await g(f("testActivityCliffsCsv"),{},n)})),(0,t.t6)("samplesFastaPtCsv",(async()=>{await g(f("fastaPtCsv"),{sequence:new u(l.Hi.FASTA,"SEQ",l.YI.PT,20,!1)},n)})),(0,t.t6)("samplesTestCerealCsv",(async()=>{await g(f("testCerealCsv"),{},n)})),(0,t.t6)("samplesTestUnichemSources",(async()=>{await g(f("testUnichemSources"),{},n)})),(0,t.t6)("samplesTestDmvOffices",(async()=>{await g(f("testDmvOffices"),{},n)})),(0,t.t6)("samplesTestAlertCollection",(async()=>{await g(f("testAlertCollection"),{},n)})),(0,t.t6)("samplesTestSpgi",(async()=>{await g(f("testSpgi"),{},n)})),(0,t.t6)("samplesTestSpgi100",(async()=>{await g(f("testSpgi100"),{},n)})),(0,t.t6)("samplesTestUrl",(async()=>{await g(f("testUrl"),{},n)})),(0,t.t6)("samplesFastaNegativeWords",(async()=>{await g(f("fasta_negative_words"),{},n)}))})),(0,t.L1)("detectors.weak-and-likely",(()=>{let n;(0,t.gM)((async()=>{n=await(0,c.Q)()}));const i={fastaDnaWeak1:"id,colName\n1,TTTTTTTTTT\n2,TTTTTTTTTT\n3,TTTTTTTTTT\n4,TTTTTTTTTT",fastaDnaWeak1LikelyName:"id,seq\n1,TTTTTTT\n2,TTTTTTT\n3,TTTTTTT\n4,TTTTTTT",fastaRnaWeak1:"id,colName\n1,UUUUUUUUUU\n2,UUUUUUUUUU\n3,UUUUUUUUUU\n4,UUUUUUUUUU",fastaRnaWeak1LikelyName:"id,seq\n1,UUUUUUU\n2,UUUUUUU\n3,UUUUUUU\n4,UUUUUUU",fastaPtWeak1:"id,colName\n1,SLSLSPGKSLSLSPGK\n2,SLSLSPGKSLSLSPGK\n3,SLSLSPGKSLSLSPGK\n4,SLSLSPGKSLSLSPGK",fastaPtWeak1LikelyName:"id,seq\n1,SLSLSPGKSLSLSPGK\n2,SLSLSPGKSLSLSPGK\n3,SLSLSPGKSLSLSPGK\n4,SLSLSPGKSLSLSPGK",fastaUn1:"id,colName\n1,word\n2,other\n3,some\n4,another",fastaUn1LikelyName:"id,seq\n1,word\n2,other\n3,some\n4,another",fastaUn2LikelyName:'protein\nBoombastic\nMegafantastic\n"just-a-random-thought,oy!"',fastaUnMsa1LikelyName:"id,seq\n1,word\n2,male\n3,bare\n4,core"},o=t=>async()=>{const n=i[t],o=e.DataFrame.fromCsv(n);return await a.data.detectSemanticTypes(o),o};(0,t.t6)("fastaDnaWeak1",(async()=>{await h(o("fastaDnaWeak1"),"colName")})),(0,t.t6)("fastaDnaWeak1LikelyName",(async()=>{await d(o("fastaDnaWeak1LikelyName"),"seq",n,l.Hi.FASTA,"SEQ.MSA",l.YI.DNA,4,!1)})),(0,t.t6)("fastaRnaWeak1",(async()=>{await h(o("fastaRnaWeak1"),"colName")})),(0,t.t6)("fastaRnaWeak1LikelyName",(async()=>{await d(o("fastaRnaWeak1LikelyName"),"seq",n,l.Hi.FASTA,"SEQ.MSA",l.YI.RNA,4,!1)})),(0,t.t6)("fastaPtWeak1",(async()=>{await h(o("fastaPtWeak1"),"colName")})),(0,t.t6)("fastaPtWeak1LikelyName",(async()=>{await d(o("fastaPtWeak1LikelyName"),"seq",n,l.Hi.FASTA,"SEQ.MSA",l.YI.PT,20,!1)})),(0,t.t6)("fastaUn1",(async()=>{await h(o("fastaUn1"),"colName")})),(0,t.t6)("fastaUn1LikelyName",(async()=>{await h(o("fastaUn1LikelyName"),"seq")})),(0,t.t6)("fastaUn2LikelyName",(async()=>{await h(o("fastaUn2LikelyName"),"protein")})),(0,t.t6)("fastaUnMsa1LikelyName",(async()=>{await h(o("fastaUnMsa1LikelyName"),"seq")}))})),(0,t.L1)("detectorsBenchmark",(()=>{let n,i;async function o(o,r,a,c,u,h){return await async function(o){const d=await(async()=>{const t=function(t,n,i,o,s){let r;switch(t){case l.Hi.FASTA:r=e=>{let t="";for(let n=0;n<e.length;n++){const i=e[n];t+=1==i.length?i:`[${i}]`}return t};break;case l.Hi.SEPARATOR:r=(e,t)=>e.join(t);break;default:throw new Error(`Not supported notation '${t}'.`)}const a=(e,t)=>{const n=new Array(t);for(let i=0;i<t;i++)n[i]=e[Math.floor(Math.random()*e.length)];return r(n,s)},c=Array(o);for(let e=0;e<o;e++)c[e]=a(n,i);return e.Column.fromStrings("seq",c)}(r,[...(0,l.Qf)(a)],c,u,h),n=i.prepare({col:t});return s(n),n})(),p=Date.now(),m=s(d),g=Date.now();(function(e,i){const o=n.getSeqHandler(e);(0,t.E3)(e.semType===i.semType,!0),(0,t.E3)(o.notation===i.notation,!0),(0,t.E3)(o.alphabet===i.alphabet,!0),(0,t.E3)(o.separator===i.separator,!0)})(m,{semType:e.SEMTYPE.MACROMOLECULE,notation:r,alphabet:a,separator:h});const f=g-p;if(f>o){const e=`ET ${f} ms is more than max allowed ${o} ms.`;throw console.error(e),new Error(e)}return console.log(`ET ${f} ms is OK.`),f}(o)}function s(e){e.callSync();const t=e.getOutputParamValue(),n=e.inputs.col;return t&&(n.semType=t),n}(0,t.gM)((async()=>{n=await(0,c.Q)();const t=e.Func.find({package:"Bio",name:"detectMacromolecule"});i=t[0];const o=e.Column.fromStrings("seq",["ACGT","ACGT","ACGT"]);await i.prepare({col:o}).call()})),(0,t.t6)("fastaDnaShorts50Few50",(async()=>{await o(20,l.Hi.FASTA,l.YI.DNA,50,50)})),(0,t.t6)("fastaDnaShorts50Many1E6",(async()=>{await o(20,l.Hi.FASTA,l.YI.DNA,50,1e6)})),(0,t.t6)("fastaDnaLong1e6Few50",(async()=>{await o(20,l.Hi.FASTA,l.YI.DNA,1e6,50)})),(0,t.t6)("separatorDnaShorts50Few50",(async()=>{await o(20,l.Hi.SEPARATOR,l.YI.DNA,50,50,"/")})),(0,t.t6)("separatorDnaShorts50Many1E6",(async()=>{await o(20,l.Hi.SEPARATOR,l.YI.DNA,50,1e6,"/")})),(0,t.t6)("separatorDnaLong1e6Few50",(async()=>{await o(20,l.Hi.SEPARATOR,l.YI.DNA,1e6,50,"/")}))}));var f=n(608),y=n(1619);async function b(n,i){const o=e.DataFrame.fromCsv(n);await a.data.detectSemanticTypes(o);const s=e.DataFrame.fromCsv(i),r=o.getCol("seq");(0,t.E3)(r.semType,e.SEMTYPE.MACROMOLECULE);const l=s.getCol("seq"),c=await(0,f.eE)(o,r,!0);(0,t.J6)(c.toList(),l.toList())}(0,t.L1)("MSA",(async()=>{let n;async function i(i,o,s,r,c,u){const h=e.DataFrame.fromCsv(i);await a.data.detectSemanticTypes(h);const d=e.DataFrame.fromCsv(o).getCol("seq"),p=h.getCol("seq");(0,t.E3)(p.semType,e.SEMTYPE.MACROMOLECULE),(0,t.E3)(p.meta.units,s),c&&(0,t.E3)(p.getTag(l.gp.alphabet),c);const m=await(0,y.D)({col:p,pepsea:{method:u}},n);(0,t.E3)(m.semType,e.SEMTYPE.MACROMOLECULE),(0,t.E3)(m.meta.units,r),(0,t.E3)(m.getTag(l.gp.aligned),"SEQ.MSA"),c&&(0,t.E3)(m.getTag(l.gp.alphabet),c),(0,t.J6)(m.toList(),d.toList())}(0,t.gM)((async()=>{n=await(0,c.Q)()})),(0,t.t6)("isCorrect",(async()=>{await b("seq\nFWRWYVKHP\nYNRWYVKHP\nMWRSWYCKHP","seq\nFWR-WYVKHP\nYNR-WYVKHP\nMWRSWYCKHP")})),(0,t.t6)("isCorrectLong",(async()=>{await b("seq\nFWRWYVKHPFWRWYVKHPFWRWYVKHPFWRWYVKHPFWRWYVKHPFWRWYVKHPFWRWYVKHPFWRWYVKHP\nYNRWYVKHPYNRWYVKHPYNRWYVKHPYNRWYVKHPYNRWYVKHPYNRWYVKHPYNRWYVKHPYNRWYVKHP\nMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHP","seq\nFWR-WYVKHPFWR-WYVKHPFWR-WYVKHPFWR-WYVKHPFWR-WYVKHPFWR-WYVKHPFWR-WYVKHPFWR-WYVKHP\nYNR-WYVKHPYNR-WYVKHPYNR-WYVKHPYNR-WYVKHPYNR-WYVKHPYNR-WYVKHPYNR-WYVKHPYNR-WYVKHP\nMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHP")})),(0,t.t6)("isCorrectHelm",(async()=>{await i("seq\n PEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2}$$$$\n PEPTIDE1{meI.Aca.N.T.dE.Thr_PO3H2}$$$$\n PEPTIDE1{hHis.Aca.N.T.dE.Thr_PO3H2}$$$$","seq\n meI.hHis.Aca.N.T.dE.Thr_PO3H2\n .meI.Aca.N.T.dE.Thr_PO3H2\n .hHis.Aca.N.T.dE.Thr_PO3H2",l.Hi.HELM,l.Hi.SEPARATOR,void 0,"mafft")}),{timeout:8e4,skipReason:"Fails in docker"}),(0,t.t6)("isCorrectHelmLong",(async()=>{await i("seq\n PEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et.dV.E.N.D-Orn.D-aThr.Phe_4Me.Thr_PO3H2}$$$$\n PEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Tyr_PO3H2.D-Chg.dV.Phe_ab-dehydro.N.D-Orn.D-aThr.Phe_4Me}$$$$\n PEPTIDE1{Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Tyr_PO3H2.D-Chg.dV.Thr_PO3H2.N.D-Orn.D-aThr.Phe_4Me}$$$$","seq\n meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et.dV.E.N.D-Orn.D-aThr.Phe_4Me.Thr_PO3H2\n meI.hHis.Aca.Cys_SEt.T.dK..Tyr_PO3H2.D-Chg.dV.Phe_ab-dehydro.N.D-Orn.D-aThr.Phe_4Me.\n Lys_Boc.hHis.Aca.Cys_SEt.T.dK..Tyr_PO3H2.D-Chg.dV.Thr_PO3H2.N.D-Orn.D-aThr.Phe_4Me.",l.Hi.HELM,l.Hi.SEPARATOR,void 0,"mafft")}),{timeout:8e4,skipReason:"Fails in docker"}),(0,t.t6)("isCorrectSeparator",(async()=>{await i("seq\n F-W-P-H-E-Y\n Y-N-R-Q-W-Y-V\n M-K-P-S-E-Y-V","seq\n FWPHEY-\n YNRQWYV\n MKPSEYV",l.Hi.SEPARATOR,l.Hi.FASTA,l.YI.PT)})),(0,t.t6)("isCorrectSeparatorLong",(async()=>{await i("seq\n M-I-E-V-F-L-F-G-I-V-L-G-L-I-P-I-T-L-A-G-L-F-V-T-A-Y-L-Q-Y-R-R-G-D-Q-L-D-L\n M-M-E-L-V-L-K-T-I-I-G-P-I-V-V-G-V-V-L-R-I-V-D-K-W-L-N-K-D-K\n M-D-R-T-D-E-V-S-N-H-T-H-D-K-P-T-L-T-W-F-E-E-I-F-E-E-Y-H-S-P-F-H-N","seq\n MIEV-FLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL\n MMEL-VLKTII-GPIVVGVVLRIVDKWLNKDK------\n MDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN-----",l.Hi.SEPARATOR,l.Hi.FASTA,l.YI.PT)}))}));var w=n(1991),v=n.n(w),A=n(7278),C=n(6718),T=n(6642);async function S(t){const n=await async function(e){return await Ce.files.readAsText(e)}(t),i=e.DataFrame.fromCsv(n);return i.name=t.replace(".csv",""),i}async function E(e,n=5e3){await(0,t.cb)(0),await(0,t.PE)(e.onAfterDrawContent,(()=>{}),(()=>{e.invalidate()}),n);const i=e.columns.length;for(let t=0;t<i;++t){const n=e.columns.byIndex(t);if(n){const t=e.cell(n.name,0),[i,r,a]=(0,T.BG)(t),l=(void 0,(s=o=a.rendererBack)&&void 0!==s.onRendered&&void 0!==s.invalidate&&void 0!==s.awaitRendered?o:null);l&&await l.awaitRendered()}}var o,s}var M=n(4139),x=n(4356);async function L(e,n){const i=(0,l.J9)(e);console.debug(`Bio: tests: splitters: src=${JSON.stringify(e)}, res=${JSON.stringify(i)} .`),(0,t.J6)(v().count(0).take(i.length).map((e=>i.getOriginal(e))).toArray(),n)}async function _(e,n){const i=(0,A.qp)(e);console.debug(`Bio: tests: splitters: src=${JSON.stringify(e)}, res=${JSON.stringify(i)} .`),(0,t.J6)(v().count(0).take(i.length).map((e=>i.getOriginal(e))).toArray(),n)}(0,t.L1)("splitters",(async()=>{(0,t.gM)((async()=>{})),(0,t.Pl)((async()=>{}));const e=["M[MeI]YKETLL[MeF]PKTDFPMRGGL[MeA]",["M","MeI","Y","K","E","T","L","L","MeF","P","K","T","D","F","P","M","R","G","G","L","MeA"]],n=["[meI][Pip][dK][Thr_PO3H2][L-hArg(Et,Et)][D-Tyr_Et][Tyr_ab-dehydroMe][dV]EN[D-Orn][D-aThr][Phe_4Me]",["meI","Pip","dK","Thr_PO3H2","L-hArg(Et,Et)","D-Tyr_Et","Tyr_ab-dehydroMe","dV","E","N","D-Orn","D-aThr","Phe_4Me"]],i=["PEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et.Tyr_ab-dehydroMe.dV.E.N.D-Orn.D-aThr.Phe_4Me}$$$",["meI","hHis","Aca","N","T","dE","Thr_PO3H2","Aca","D-Tyr_Et","Tyr_ab-dehydroMe","dV","E","N","D-Orn","D-aThr","Phe_4Me"]],o=["PEPTIDE1{meI.hHis.Aca.N.T.dK.Thr_PO3H2.Aca.D-Tyr_Et.D-Dap.dV.E.N.pnG.Phe_4Me}$$$",["meI","hHis","Aca","N","T","dK","Thr_PO3H2","Aca","D-Tyr_Et","D-Dap","dV","E","N","pnG","Phe_4Me"]],s=["PEPTIDE1{[meI].[hHis].[Aca].N.T.[dK].[Thr_PO3H2].[Aca].[D-Tyr_Et].[D-Dap].[dV].E.N.[pnG].[Phe_4Me]}$$$",["meI","hHis","Aca","N","T","dK","Thr_PO3H2","Aca","D-Tyr_Et","D-Dap","dV","E","N","pnG","Phe_4Me"]],r=["RNA1{R(U)P.R(T)P.R(G)P.R(C)P.R(A)}$$$$",["R(U)P","R(T)P","R(G)P","R(C)P","R(A)"]],a=["RNA1{P.R(U)P.R(T)}$$$$",["P","R(U)P","R(T)"]],l=["RNA1{P.R(U).P.R(T)}$$$$",["P","R(U)","P","R(T)"]];(0,t.t6)("fastaMulti",(async()=>{await L(e[0],e[1])})),(0,t.t6)("fastaFromHelm",(async()=>{await L(n[0],n[1])})),(0,t.t6)("helm1",(async()=>{await _(i[0],i[1])})),(0,t.t6)("helm2",(async()=>{await _(o[0],o[1])})),(0,t.t6)("helm3-multichar",(async()=>{await _(s[0],s[1])})),(0,t.t6)("testHelm1",(async()=>{await _(r[0],r[1])})),(0,t.t6)("testHelm2",(async()=>{await _(a[0],a[1])})),(0,t.t6)("testHelm3",(async()=>{await _(l[0],l[1])}))})),(0,t.L1)("splitters",(()=>{let n,i,o;(0,t.gM)((async()=>{n=await(0,c.Q)(),i=await(0,C.pj)(),o=await(0,x.ub)(),await i.loadMonomerLibForTests()})),(0,t.Pl)((async()=>{await(0,x.Eu)(o),await i.loadMonomerLib(!0)})),(0,t.t6)("splitToMonomers",(async()=>{const e=await a.dapi.files.readCsv("System:AppData/Bio/samples/MSA.csv"),n=e.getCol("MSA"),i=await a.functions.call("Bio:detectMacromolecule",{col:n});i&&(n.semType=i),n.setTag(l.gp.aligned,M.gN);const o=await a.functions.call("Bio:splitToMonomersTopMenu",{table:e,sequence:n});(0,t.E3)(o.columns.names().includes("17"),!0),await a.data.detectSemanticTypes(o);const s=a.shell.addTableView(o);await E(s.grid),(0,t.E3)(s.grid.dataFrame.id,e.id)})),(0,t.t6)("getHelmMonomers",(async()=>{const t=e.DataFrame.fromCsv("HELM,Activity\nPEPTIDE1{hHis.N.T}$$$,5.30751\nPEPTIDE1{hHis.Aca.Cys_SEt}$$$,5.72388\n");await a.data.detectSemanticTypes(t);const n=["hHis","Aca","Cys_SEt","N","T"],i=t.getCol("HELM"),o=await a.functions.call("Bio:getHelmMonomers",{sequence:i}),s=n.filter((e=>!o.includes(e))),r=o.filter((e=>!n.includes(e)));if(s.length>0||r.length){const e=[];throw s.length>0&&e.push(`Missed monomers ${JSON.stringify(s)}.`),r.length>0&&e.push(`Unexpected monomers ${JSON.stringify(r)}.`),new Error(e.join(" "))}}))}));var I=n(8604);(0,t.L1)("monomerLibraries",(()=>{let e,n=null;(0,t.gM)((async()=>{e=await(0,C.pj)(),n=(0,x.ub)()})),(0,t.Pl)((async()=>{await(0,x.Eu)(n)})),(0,t.t6)("default",(async()=>{await(0,x.Eu)({exclude:[],explicit:[],duplicateMonomerPreferences:{}}),await e.loadMonomerLib(!0);const n=e.getMonomerLib();(0,t.E3)(n.getPolymerTypes().length>0,!0)})),(0,t.t6)("forTests",(async()=>{await e.loadMonomerLibForTests(),function(e,n){const i=n,o=e.getSummaryObj();for(const e in i)i[e]||delete i[e];for(const e in o)o[e]||delete o[e];if(0==Object.keys(i).length&&0!=Object.keys(o).length)throw new Error("Expected empty monomer lib, actual is not.");if(0!=Object.keys(i).length&&0==Object.keys(o).length)throw new Error("Expected non-empty monomer lib, actual is empty.");try{(0,t.Xk)(o,i),(0,t.Xk)(i,o)}catch(e){throw new Error(`Expected monomer lib ${JSON.stringify(i)} does not match actual ${JSON.stringify(o)}.`)}}(e.getMonomerLib(),I.VV)})),(0,t.t6)("empty",(async()=>{const n=await(0,x.ub)(),i=await e.getFileManager();let o=i.getValidLibraryPaths();0===o.length&&(o=await i.getValidLibraryPathsAsynchronously()),n.exclude=o,n.explicit=[],await(0,x.Eu)(n),await e.loadMonomerLib(!0);const s=e.getMonomerLib().getPolymerTypes();(0,t.E3)(0===s.length,!0)})),(0,t.t6)("override",(async()=>{const n={symbol:"over1",name:"Test override monomer 1",molfile:"",author:"Test Author",id:0,rgroups:[],smiles:"",polymerType:"PEPTIDE",monomerType:"Backbone",createDate:null},i=e.getMonomerLib(),o=i.getMonomer(n.polymerType,n.symbol);(0,t.E3)(null===o,!0,`Unexpectedly found monomer '${n.symbol}' `);const s=i.override({[n.polymerType]:{[n.symbol]:n}},"test").getMonomer(n.polymerType,n.symbol);s&&(s.lib=void 0),(0,t.Xk)(s,n)}))}));var P=n(7389),N=n(1757),R=n.n(N),$=n(1858),O=n(6873),H=n(5433);async function k(n,i){const o=n(),s=e.DataFrame.fromColumns(o);await a.data.detectSemanticTypes(s);const r=Date.now(),l=(s.columns.byName("MSA"),a.shell.addTableView(s));await E(l.grid),(0,t.E3)(l.grid.dataFrame.id,s.id);const c=Date.now()-r;console.log(`Performance test: ${i}: ${c}ms`)}(0,t.L1)("renderers",(()=>{let n;(0,t.gM)((async()=>{n=await(0,c.Q)()})),(0,t.t6)("long sequence performance ",(async()=>{await k((()=>(0,O.dW)(1e4)),"Long sequences")})),(0,t.t6)("many sequence performance",(async()=>{await k(O.fD,"Many sequences")})),(0,t.t6)("rendererMacromoleculeFasta",(async()=>{await async function(){const n=await a.dapi.files.readAsText("System:AppData/Bio/samples/FASTA.csv"),i=e.DataFrame.fromCsv(n),o=i.getCol("Sequence"),s=await a.functions.call("Bio:detectMacromolecule",{col:o});s&&(o.semType=s);const r=a.shell.addTableView(i);await a.data.detectSemanticTypes(i),await E(r.grid),(0,t.E3)(r.grid.dataFrame.id,i.id);const l=o.getTag(e.TAGS.CELL_RENDERER);(0,t.E3)(l,"sequence")}()})),(0,t.t6)("rendererMacromoleculeSeparator",(async()=>{await async function(){const n=await a.dapi.files.readAsText("System:AppData/Bio/samples/SEPARATOR_PT.csv"),i=e.DataFrame.fromCsv(n),o=i.getCol("sequence"),s=await a.functions.call("Bio:detectMacromolecule",{col:o});s&&(o.semType=s);const r=a.shell.addTableView(i);await a.data.detectSemanticTypes(i),await E(r.grid),(0,t.E3)(r.grid.dataFrame.id,i.id);const l=o.getTag(e.TAGS.CELL_RENDERER);(0,t.E3)(l,"sequence")}()})),(0,t.t6)("rendererMacromoleculeDifference",(async()=>{await async function(){const n=e.Column.fromStrings("SequencesDiff",["meI/hHis/Aca/N/T/dK/Thr_PO3H2/Aca#D-Tyr_Et/Tyr_ab-dehydroMe/meN/E/N/dV"]);n.meta.units=l.Hi.SEPARATOR,n.setTag(l.gp.separator,"/"),n.setTag(l.gp.aligned,"SEQ"),n.setTag(l.gp.alphabet,"UN"),n.setTag(l.gp.alphabetIsMultichar,"true"),n.semType=M.uF.MACROMOLECULE_DIFFERENCE;const i=e.DataFrame.fromColumns([n]),o=a.shell.addTableView(i);await a.data.detectSemanticTypes(i),await E(o.grid),(0,t.E3)(o.grid.dataFrame.id,i.id);const s=n.getTag(e.TAGS.CELL_RENDERER);(0,t.E3)(s,M.uF.MACROMOLECULE_DIFFERENCE)}()})),(0,t.t6)("afterMsa",(async()=>{await async function(){const i=await a.dapi.files.readAsText("System:AppData/Bio/samples/FASTA.fasta"),o=(await a.functions.call("Bio:importFasta",{fileContent:i}))[0],s=o.getCol("sequence"),r=await a.functions.call("Bio:detectMacromolecule",{col:s});r&&(s.semType=r);const c=a.shell.addTableView(o);await a.data.detectSemanticTypes(o),console.log("Bio: tests/renderers/afterMsa, table view"),await E(c.grid),(0,t.E3)(c.grid.dataFrame.id,o.id),console.log(`Bio: tests/renderers/afterMsa, src before test semType="${s.semType}", units="${s.meta.units}", cell.renderer="${s.getTag(e.TAGS.CELL_RENDERER)}"`),(0,t.E3)(s.semType,e.SEMTYPE.MACROMOLECULE),(0,t.E3)(s.meta.units,l.Hi.FASTA),(0,t.E3)(s.getTag(l.gp.aligned),"SEQ"),(0,t.E3)(s.getTag(l.gp.alphabet),l.YI.PT),(0,t.E3)(s.getTag(e.TAGS.CELL_RENDERER),"sequence");const u=await(0,y.D)({col:s},n);await E(c.grid),(0,t.E3)(c.grid.dataFrame.id,o.id),(0,t.E3)(u.semType,e.SEMTYPE.MACROMOLECULE),(0,t.E3)(u.meta.units,l.Hi.FASTA),(0,t.E3)(u.getTag(l.gp.aligned),"SEQ.MSA"),(0,t.E3)(u.getTag(l.gp.alphabet),l.YI.PT),(0,t.E3)(u.getTag(e.TAGS.CELL_RENDERER),"sequence"),n.getSeqHandler(u)}()})),(0,t.t6)("afterConvert",(async()=>{await async function(){const i=await a.dapi.files.readAsText("System:AppData/Bio/samples/FASTA_PT.csv"),o=e.DataFrame.fromCsv(i),s=o.getCol("sequence"),r=await a.functions.call("Bio:detectMacromolecule",{col:s});r&&(s.semType=r);const c=a.shell.addTableView(o);await a.data.detectSemanticTypes(o);const u=await(0,H.r)(s,n,l.Hi.SEPARATOR,"/");await E(c.grid),(0,t.E3)(c.grid.dataFrame.id,o.id);const h=u.getTag(e.TAGS.CELL_RENDERER);(0,t.E3)(h,"sequence"),n.getSeqHandler(u)}()})),(0,t.t6)("afterConvertToHelm",(async()=>{await async function(){const i=await a.dapi.files.readCsv("System:AppData/Bio/samples/FASTA_PT.csv"),o=a.shell.addTableView(i);await E(o.grid),await i.meta.detectSemanticTypes(),await a.data.detectSemanticTypes(i);const s=i.getCol("sequence"),r=n.getSeqHandler(s).convert(l.Hi.HELM);i.columns.add(r),await E(o.grid),(0,t.E3)(r.getTag(e.TAGS.CELL_RENDERER),"helm")}()})),(0,t.t6)("selectRendererBySemType",(async()=>{await async function(){const n=e.Column.fromStrings("SequencesDiff",["meI/hHis/Aca/N/T/dK/Thr_PO3H2/Aca#D-Tyr_Et/Tyr_ab-dehydroMe/meN/E/N/dV"]);n.meta.units=l.Hi.SEPARATOR,n.setTag(l.gp.separator,"/"),n.setTag(l.gp.aligned,"SEQ"),n.setTag(l.gp.alphabet,"UN"),n.setTag(l.gp.alphabetIsMultichar,"true"),n.semType=M.uF.MACROMOLECULE_DIFFERENCE;const i=e.DataFrame.fromColumns([n]);a.shell.addTableView(i),await(0,t.cb)(100);const o=n.getTag(e.TAGS.CELL_RENDERER);if("MacromoleculeDifference"!==o)throw new Error(`Units 'separator', separator '/' and semType 'MacromoleculeDifference' have been manually set on column but after df was added as table, view renderer has set to '${o}' instead of correct 'MacromoleculeDifference'.`)}()})),(0,t.t6)("scatterPlotTooltip",(async()=>{await async function(){const n=e.DataFrame.fromCsv(i);n.currentRowIdx=0;const o=a.shell.addTableView(n);await n.meta.detectSemanticTypes(),await a.data.detectSemanticTypes(n);const s=n.plot.scatter({x:"x",y:"y"});o.dockManager.dock(s,e.DOCK_TYPE.RIGHT,null),await Promise.all([(0,t.PE)(s.onAfterDrawScene,(()=>{}),(()=>{s.invalidateCanvas()}),1e3),E(o.grid,500)]);const r=s.root.getBoundingClientRect(),l=s.worldToScreen(1,0),c=new MouseEvent("mousemove",{cancelable:!0,bubbles:!0,view:window,button:0,clientX:r.left+l.x,clientY:r.top+l.y}),u=R()(s.root).find("canvas").get()[0];await(0,t.PE)(e.debounce((0,$.fromEvent)(u,"mousemove"),200),(()=>{Ce.logger.debug(`Test: event, currentRowIdx=${n.currentRowIdx}`),(0,t.E3)(R()(P.tooltip.root).find("div table.d4-row-tooltip-table tr td canvas").length,1),(0,t.E3)(s.hitTest(l.x,l.y),1)}),(()=>{u.dispatchEvent(c)}),500),await E(o.grid,500)}()}),{skipReason:"GROK-17450"});const i="seq,x,y\nACGGTGTCGT,0,0\nCGGTATCCCT,1,0\nCTCGGCATGC,2,0\n"}));var F=n(6882);(0,t.L1)("renderers: monomerPlacer",(()=>{let n,i;(0,t.gM)((async()=>{n=await(0,C.pj)(),i=await(0,x.ub)(),await n.loadMonomerLibForTests()})),(0,t.Pl)((async()=>{await(0,x.Eu)(i),await n.loadMonomerLib(!0)}));const o={splitter:{csv:"id,seq\nid1,m1-M-m3-mon4-mon5-N-T-MON8-N9\nid2,m1-mon2-m3-mon4-mon5-Num-MON8-N9\nid3,mon1-M-mon3-mon4-mon5-MON8-N9\n",testList:[{src:{row:0,x:-1},tgt:{pos:null}},{src:{row:1,x:0},tgt:{pos:null}},{src:{row:1,x:5},tgt:{pos:0}},{src:{row:1,x:6},tgt:{pos:0}},{src:{row:1,x:26},tgt:{pos:1}},{src:{row:1,x:160},tgt:{pos:6}},{src:{row:1,x:190},tgt:{pos:7}},{src:{row:2,x:140},tgt:{pos:5}},{src:{row:2,x:145},tgt:{pos:5}}]},splitterMsa:{csv:"id,seq\nid1,m1-M-m3-mon4-mon5-N-T-MON8-N9\nid2,m1-mon2-m3-mon4-mon5-Num--MON8-N9\nid3,\nid4,mon1-M-mon3-mon4-mon5---MON8-N9\n",testList:[{src:{row:0,x:-1},tgt:{pos:null}},{src:{row:1,x:0},tgt:{pos:null}},{src:{row:1,x:1},tgt:{pos:null}},{src:{row:1,x:4},tgt:{pos:null}},{src:{row:1,x:5},tgt:{pos:0}},{src:{row:1,x:37},tgt:{pos:0}},{src:{row:1,x:38},tgt:{pos:1}},{src:{row:1,x:170},tgt:{pos:5}},{src:{row:1,x:200},tgt:{pos:5}},{src:{row:2,x:20},tgt:{pos:null}},{src:{row:3,x:170},tgt:{pos:5}},{src:{row:3,x:200},tgt:{pos:5}},{src:{row:3,x:297},tgt:{pos:null}}]},fastaMsa:{csv:"id,seq\nid1,QQYNIYPLT\nid2,QQWSSFPYT\nid3,\nid3,QHIRE--LT\n",testList:[{src:{row:1,x:-1},tgt:{pos:null}},{src:{row:1,x:0},tgt:{pos:null}},{src:{row:1,x:1},tgt:{pos:null}},{src:{row:1,x:19},tgt:{pos:0}},{src:{row:1,x:170},tgt:{pos:8}},{src:{row:1,x:171},tgt:{pos:8}},{src:{row:2,x:5},tgt:{pos:null}},{src:{row:3,x:170},tgt:{pos:8}},{src:{row:3,x:181},tgt:{pos:null}}]}};for(const[n,i]of Object.entries(o))(0,t.t6)(`getPosition-${n}`,(async()=>{const t=e.DataFrame.fromCsv(i.csv);await a.data.detectSemanticTypes(t);const n=t.getCol("seq"),o=new F.Jy(null,n,Ce.logger,3,(()=>({font:"12px monospace",fontCharWidth:7,separatorWidth:12,monomerToShort:l.zS})));await o.init();const s=i.testList;for(let e=0;e<n.length;++e)o.getCellMonomerLengths(e,1e4);const r=[];for(const[e,t]of v().enumerate(s)){const t={pos:o.getPosition(e.src.row,e.src.x,1e4)};e.tgt.pos!=t.pos&&r.push(`Test src ${JSON.stringify(e.src)} expected tgt ${JSON.stringify(e.tgt)}, but get ${JSON.stringify({res:t})}`)}if(r.length>0)throw new Error("Test failed error(s):\n"+r.join(", \n"))}));const s=[10,20,30,40,50,60],r={left:{x:3,tgt:null},c0left:{x:10,tgt:0},c0mid:{x:12,tgt:0},c0right:{x:19,tgt:0},c1left:{x:20,tgt:1},c2right:{x:39,tgt:2},c4left:{x:50,tgt:4},c4right:{x:59,tgt:4},max:{x:60,tgt:null},right:{x:65,tgt:null}};for(const[e,n]of Object.entries(r))(0,t.t6)("hitBounds-"+e,(async()=>{const e=(0,F.Bb)(s,n.x);(0,t.E3)(e,n.tgt)}));const c={mono1:{src:{csv:"seq\nm1/m2/m3/m4/m5/m6/m7/m8/m9\nn1/m2/n3/m4/n5/m6/n7/m8/n9\nm1/n2/m3/n4/m5/n6/m7/n8/m9\n"},tgt:{lengths:[5,31,57,83,109,135,161,187,213,239]}},monoWithGaps:{src:{csv:"seq\nm1/m2/m3/m4/m5/m6//m8/m9\nn1/m2/n3/m4/n5/m6//m8/n9\nm1/n2/m3/n4/m5/n6/m7/n8/m9\n"},tgt:{lengths:[5,31,57,83,109,135,161,187,213,239]}},monoWithGapColumn:{src:{csv:"seq\nm1/m2/m3/m4/m5/m6//m8/m9\nn1/m2/n3/m4/n5/m6//m8/n9\nm1/n2/m3/n4/m5///n8/m9\n"},tgt:{lengths:[5,31,57,83,109,135,161,180,206,232]}}};for(const[n,i]of Object.entries(c))(0,t.t6)(`getCellMonomerLengths-${n}`,(async()=>{const n=e.DataFrame.fromCsv(i.src.csv);await a.data.detectSemanticTypes(n);const o=n.getCol("seq"),s=new F.Jy(null,o,Ce.logger,3,(()=>({fontCharWidth:7,font:"12px monospace",separatorWidth:12,monomerToShort:l.zS})));await s.init();const r=s.getCellMonomerLengths(0,1e3)[1];(0,t.J6)(r,i.tgt.lengths)}))})),(0,t.L1)("converters",(()=>{let n,i;(0,t.gM)((async()=>{n=await(0,c.Q)()})),function(e){e.fastaPt="fastaPt",e.separatorPt="separatorPt",e.helmPt="helmPt",e.fastaDna="fastaDna",e.separatorDna="separatorDna",e.helmDna="helmDna",e.fastaRna="fastaRna",e.separatorRna="separatorRna",e.helmRna="helmRna",e.fastaGaps="fastaGaps",e.separatorGaps="separatorGaps",e.helmGaps="helmGaps",e.fastaUn="fastaUn",e.separatorUn="separatorUn",e.helmUn="helmUn",e.helmLoneDeoxyribose="helmLoneDeoxyribose",e.helmLoneRibose="helmLoneRibose",e.helmLonePhosphorus="helmLonePhosphorus",e.fastaLoneDeoxyribose="fastaLoneDeoxyribose",e.fastaLoneRibose="fastaLoneRibose",e.fastaLonePhosphorus="fastaLonePhosphorus"}(i||(i={}));const o={[i.fastaPt]:"seq\nFWPHEYFWPHEY\nYNRQWYVYNRQWYV\nMKPSEYVMKPSEYV",[i.separatorPt]:"seq\nF-W-P-H-E-Y-F-W-P-H-E-Y\nY-N-R-Q-W-Y-V-Y-N-R-Q-W-Y-V\nM-K-P-S-E-Y-V-M-K-P-S-E-Y-V",[i.helmPt]:"seq\nPEPTIDE1{F.W.P.H.E.Y.F.W.P.H.E.Y}$$$$\nPEPTIDE1{Y.N.R.Q.W.Y.V.Y.N.R.Q.W.Y.V}$$$$\nPEPTIDE1{M.K.P.S.E.Y.V.M.K.P.S.E.Y.V}$$$$",[i.fastaDna]:"seq\nACGTCACGTC\nCAGTGTCAGTGT\nTTCAACTTCAAC",[i.separatorDna]:"seq\nA/C/G/T/C/A/C/G/T/C\nC/A/G/T/G/T/C/A/G/T/G/T\nT/T/C/A/A/C/T/T/C/A/A/C",[i.helmDna]:"seq\nRNA1{d(A)p.d(C)p.d(G)p.d(T)p.d(C)p.d(A)p.d(C)p.d(G)p.d(T)p.d(C)p}$$$$\nRNA1{d(C)p.d(A)p.d(G)p.d(T)p.d(G)p.d(T)p.d(C)p.d(A)p.d(G)p.d(T)p.d(G)p.d(T)p}$$$$\nRNA1{d(T)p.d(T)p.d(C)p.d(A)p.d(A)p.d(C)p.d(T)p.d(T)p.d(C)p.d(A)p.d(A)p.d(C)p}$$$$",[i.fastaRna]:"seq\nACGUCACGUC\nCAGUGUCAGUGU\nUUCAACUUCAAC",[i.separatorRna]:"seq\nA*C*G*U*C*A*C*G*U*C\nC*A*G*U*G*U*C*A*G*U*G*U\nU*U*C*A*A*C*U*U*C*A*A*C",[i.helmRna]:"seq\nRNA1{r(A)p.r(C)p.r(G)p.r(U)p.r(C)p.r(A)p.r(C)p.r(G)p.r(U)p.r(C)p}$$$$\nRNA1{r(C)p.r(A)p.r(G)p.r(U)p.r(G)p.r(U)p.r(C)p.r(A)p.r(G)p.r(U)p.r(G)p.r(U)p}$$$$\nRNA1{r(U)p.r(U)p.r(C)p.r(A)p.r(A)p.r(C)p.r(U)p.r(U)p.r(C)p.r(A)p.r(A)p.r(C)p}$$$$",[i.fastaGaps]:"seq\nFW-PH-EYYFW-PH-EYY\nFYNRQWYV-FYNRQWYV-\nFKP-Q-SEYVFKP-Q-SEYV",[i.separatorGaps]:"seq\nF/W//P/H//E/Y/Y/F/W//P/H//E/Y/Y\nF/Y/N/R/Q/W/Y/V//F/Y/N/R/Q/W/Y/V/\nF/K/P//Q//S/E/Y/V/F/K/P//Q//S/E/Y/V",[i.helmGaps]:"seq\nPEPTIDE1{F.W.*.P.H.*.E.Y.Y.F.W.*.P.H.*.E.Y.Y}$$$$\nPEPTIDE1{F.Y.N.R.Q.W.Y.V.*.F.Y.N.R.Q.W.Y.V.*}$$$$\nPEPTIDE1{F.K.P.*.Q.*.S.E.Y.V.F.K.P.*.Q.*.S.E.Y.V}$$$$",[i.fastaUn]:"seq\n[meI][hHis][Aca]NT[dE][Thr_PO3H2][Aca]D[meI][hHis][Aca]NT[dE][Thr_PO3H2][Aca]D\n[meI][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2][meI][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2]\n[Lys_Boc][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2][Lys_Boc][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca]",[i.separatorUn]:"seq\nmeI-hHis-Aca-N-T-dE-Thr_PO3H2-Aca-D-meI-hHis-Aca-N-T-dE-Thr_PO3H2-Aca-D\nmeI-hHis-Aca-Cys_SEt-T-dK-Thr_PO3H2-Aca-Tyr_PO3H2-meI-hHis-Aca-Cys_SEt-T-dK-Thr_PO3H2-Aca-Tyr_PO3H2\nLys_Boc-hHis-Aca-Cys_SEt-T-dK-Thr_PO3H2-Aca-Tyr_PO3H2-Lys_Boc-hHis-Aca-Cys_SEt-T-dK-Thr_PO3H2-Aca",[i.helmUn]:"seq\nPEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D.meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D}$$$$\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2.meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2}$$$$\nPEPTIDE1{Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2.Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca}$$$$",[i.helmLoneDeoxyribose]:"seq\nRNA1{d(A).d(C).d(G).d(T).d(C).d(A).d(C).d(G).d(T).d(C)}$$$$\nRNA1{d(C).d(A).d(G).d(T).d(G).d(T)p.d(C).d(A).d(G).d(T).d(G).d(T)p}$$$$\nRNA1{d(T).d(T).d(C).d(A).d(A).d(C)p.d(T).d(T).d(C).d(A).d(A).d(C)p}$$$$",[i.helmLoneRibose]:"seq\nRNA1{r(A).r(C).r(G).r(U).r(C).r(A).r(C).r(G).r(U).r(C)}$$$$\nRNA1{r(C).r(A).r(G).r(U).r(G).r(U)p.r(C).r(A).r(G).r(U).r(G).r(U)p}$$$$\nRNA1{r(U).r(U).r(C).r(A).r(A).r(C)p.r(U).r(U).r(C).r(A).r(A).r(C)p}$$$$",[i.helmLonePhosphorus]:"seq\nRNA1{p.p.r(A)p.r(C)p.r(G)p.r(U)p.r(C)p.r(A)p.r(C)p.r(G)p.r(U)p.r(C)p}$$$$\nRNA1{p.p.r(C)p.r(A)p.p.r(G)p.r(U)p.r(G)p.r(U)p.r(C)p.r(A)p.p.r(G)p.r(U)p.r(G)p.r(U)p}$$$$\nRNA1{p.r(U)p.r(U)p.r(C)p.r(A)p.r(A)p.r(C)p.r(U)p.r(U)p.r(C)p.r(A)p.r(A)p.r(C)p.p.p}$$$$"},s=new Set(Object.values(l.gp));async function r(t){const n=o[t],i=e.DataFrame.fromCsv(n);return await a.data.detectSemanticTypes(i),i}function u(e,i){if(e===l.Hi.SEPARATOR&&!i)throw new Error(`Argument 'separator' is mandatory for target notation '${e.toString()}'.`);return function(o){const s=n.getSeqHandler(o).convert(e,i);return(0,t.E3)(s.meta.units,e),s}}async function h(e,i,o){const a=(await r(e)).getCol("seq"),c=i(a),u=(await r(o)).getCol("seq");(0,t.J6)(c.toList(),u.toList());const h=n.getSeqHandler(a),d=n.getSeqHandler(c);for(const[e,n]of Object.entries(u.tags)){if(!s.has(e)||h.notation===l.Hi.HELM&&[l.gp.alphabet,l.gp.alphabetIsMultichar].includes(e)||d.notation===l.Hi.HELM&&[l.gp.alphabet,l.gp.alphabetIsMultichar].includes(e))continue;const i=c.getTag(e);(0,t.E3)(i,n,`Tag '${e}' expected value '${n}' is not equal to actual '${i}'.`)}}(0,t.t6)("testFastaPtToSeparator",(async()=>{await h(i.fastaPt,u(l.Hi.SEPARATOR,"-"),i.separatorPt)})),(0,t.t6)("testFastaDnaToSeparator",(async()=>{await h(i.fastaDna,u(l.Hi.SEPARATOR,"/"),i.separatorDna)})),(0,t.t6)("testFastaRnaToSeparator",(async()=>{await h(i.fastaRna,u(l.Hi.SEPARATOR,"*"),i.separatorRna)})),(0,t.t6)("testFastaGapsToSeparator",(async()=>{await h(i.fastaGaps,u(l.Hi.SEPARATOR,"/"),i.separatorGaps)})),(0,t.t6)("testFastaUnToSeparator",(async()=>{await h(i.fastaUn,u(l.Hi.SEPARATOR,"-"),i.separatorUn)})),(0,t.t6)("testFastaPtToHelm",(async()=>{await h(i.fastaPt,u(l.Hi.HELM),i.helmPt)})),(0,t.t6)("testFastaDnaToHelm",(async()=>{await h(i.fastaDna,u(l.Hi.HELM),i.helmDna)})),(0,t.t6)("testFastaRnaToHelm",(async()=>{await h(i.fastaRna,u(l.Hi.HELM),i.helmRna)})),(0,t.t6)("testFastaGapsToHelm",(async()=>{await h(i.fastaGaps,u(l.Hi.HELM),i.helmGaps)})),(0,t.t6)("testSeparatorPtToFasta",(async()=>{await h(i.separatorPt,u(l.Hi.FASTA),i.fastaPt)})),(0,t.t6)("testSeparatorDnaToFasta",(async()=>{await h(i.separatorDna,u(l.Hi.FASTA),i.fastaDna)})),(0,t.t6)("testSeparatorRnaToFasta",(async()=>{await h(i.separatorRna,u(l.Hi.FASTA),i.fastaRna)})),(0,t.t6)("testSeparatorGapsToFasta",(async()=>{await h(i.separatorGaps,u(l.Hi.FASTA),i.fastaGaps)})),(0,t.t6)("testSeparatorUnToFasta",(async()=>{await h(i.separatorUn,u(l.Hi.FASTA),i.fastaUn)})),(0,t.t6)("testSeparatorPtToHelm",(async()=>{await h(i.separatorPt,u(l.Hi.HELM),i.helmPt)})),(0,t.t6)("testSeparatorDnaToHelm",(async()=>{await h(i.separatorDna,u(l.Hi.HELM),i.helmDna)})),(0,t.t6)("testSeparatorRnaToHelm",(async()=>{await h(i.separatorRna,u(l.Hi.HELM),i.helmRna)})),(0,t.t6)("testSeparatorGapsToHelm",(async()=>{await h(i.separatorGaps,u(l.Hi.HELM),i.helmGaps)})),(0,t.t6)("testHelmDnaToFasta",(async()=>{await h(i.helmDna,u(l.Hi.FASTA),i.fastaDna)})),(0,t.t6)("testHelmRnaToFasta",(async()=>{await h(i.helmRna,u(l.Hi.FASTA),i.fastaRna)})),(0,t.t6)("testHelmPtToFasta",(async()=>{await h(i.helmPt,u(l.Hi.FASTA),i.fastaPt)})),(0,t.t6)("testHelmUnToFasta",(async()=>{await h(i.helmUn,u(l.Hi.FASTA),i.fastaUn)})),(0,t.t6)("testHelmDnaToSeparator",(async()=>{await h(i.helmDna,u(l.Hi.SEPARATOR,"/"),i.separatorDna)})),(0,t.t6)("testHelmRnaToSeparator",(async()=>{await h(i.helmRna,u(l.Hi.SEPARATOR,"*"),i.separatorRna)})),(0,t.t6)("testHelmPtToSeparator",(async()=>{await h(i.helmPt,u(l.Hi.SEPARATOR,"-"),i.separatorPt)})),(0,t.t6)("testHelmUnToSeparator",(async()=>{await h(i.helmUn,u(l.Hi.SEPARATOR,"-"),i.separatorUn)})),(0,t.t6)("testHelmLoneRibose",(async()=>{await h(i.helmLoneRibose,u(l.Hi.FASTA),i.fastaRna)})),(0,t.t6)("testHelmLoneDeoxyribose",(async()=>{await h(i.helmLoneDeoxyribose,u(l.Hi.SEPARATOR,"/"),i.separatorDna)})),(0,t.t6)("testHelmLonePhosphorus",(async()=>{await h(i.helmLonePhosphorus,u(l.Hi.FASTA),i.fastaRna)}))}));var D=n(3516);(0,t.L1)("fastaFileHandler",(()=>{const n=["description:1","description:2","description:3","description:4"],i=(e.Column.fromStrings("description",n),["MDYKETLLMPKTDFPMRGGLPNKEPQIQEKW","MIEVFLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL","MMELVLKTIIGPIVVGVVLRIVDKWLNKDK","MDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN"]);function o(e){const o=new D.m(e),s=o.descriptionsArray,r=o.sequencesArray;(0,t.J6)([s,r],[n,i])}(0,t.t6)("testNormalFormatting",(async()=>{o(">description:1\nMDYKETLLMPKTDFPMRGGLPNKEPQIQEKW\n\n>description:2\nMIEVFLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL\n\n>description:3\nMMELVLKTIIGPIVVGVVLRIVDKWLNKDK\n\n>description:4\nMDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN\n")})),(0,t.t6)("testExtraSpaces",(async()=>{o(">description:1\n MDYKETLLMPKTDFPMRGGLPNKEPQIQEKW\n\n>description:2\nMI EVF LFGIVLGLI PITLAGLFVTAY LQYRRGDQLDL\n\n>description:3\nM MELVLKTI IGPI VVGVVLR IVDKWLNKDK\n\n>description:4\nMDR TDEVSNHTHDKP TLTWFEEIFEEYHSPFHN\n ")})),(0,t.t6)("testExtraNewlines",(async()=>{o(">description:1\n\nMDYKETLLMPKTDFPMRGGLPNKEPQIQEKW\n\n>description:2\nMIEVF\nLFGIVLGLI\nPITLAGLFVTA\nYLQYRRGDQLDL\n\n>description:3\nM\nME\n\nLVLKTIIG\n\nPIVVGVVLRI\nVDKWLNKDK\n\n\n>description:4\n\nMDRT\n\nDEVSNHTHDKP\n\nTLTWFEEIFEE\n\n\n\nYHSPFHN\n")}))}));var G=n(3890);(0,t.L1)("fastaExport",(()=>{let n,i;(0,t.gM)((async()=>{n=await(0,c.Q)()})),function(e){e.single="single",e.multi="multi"}(i||(i={}));const o={[i.single]:{src:"MDYKETLLMPKTDFPMRGGLP",tgt:["MDYKETLLMP","KTDFPMRGGL","P"]},[i.multi]:{src:"M[MeI]YKETLL[MeF]PKTDFPMRGGL[MeA]",tgt:["M[MeI]YKETLL[MeF]P","KTDFPMRGGL","[MeA]"]}};let s;!function(e){e.test1="test1",e.test2="test2"}(s||(s={}));const r={[s.test1]:{srcCsv:"id,seq\n1,MDYKETLLMP\n2,KTDFPMRGGL\n3,P",idCols:["id"],seqCol:"seq",lineWidth:10,tgtFasta:">1\nMDYKETLLMP\n>2\nKTDFPMRGGL\n>3\nP\n"},[s.test2]:{srcCsv:"id,id2,seq\n1,seqA,M[MeI]YKETLL[MeF]P\n2,seqB,KTDFPMRGGL\n3,seqC,[MeA]\n",idCols:["id2","id"],seqCol:"seq",lineWidth:5,tgtFasta:">seqA|1\nM[MeI]YKE\nTLL[MeF]P\n>seqB|2\nKTDFP\nMRGGL\n>seqC|3\n[MeA]\n"}};function a(i,s=10){const r=o[i].src,a=e.Column.fromStrings("src",[r]);a.semType=e.SEMTYPE.MACROMOLECULE,a.meta.units=l.Hi.FASTA;const c=n.getSeqHandler(a).getSplitted(0),u=(0,G.aS)(c,s),h=o[i].tgt;(0,t.J6)(u,h)}async function u(i){const o=e.DataFrame.fromCsv(i.srcCsv),s=o.getCol(i.seqCol);s.semType=e.SEMTYPE.MACROMOLECULE,s.meta.units=l.Hi.FASTA;const r=i.idCols.map((e=>o.getCol(e))),a=n.getSeqHandler(s),c=(0,G.wz)(r,a,i.lineWidth);(0,t.E3)(c,i.tgtFasta)}(0,t.t6)("wrapSequenceSingle",(async()=>{a(i.single,10)})),(0,t.t6)("wrapSequenceMulti",(async()=>{a(i.multi,10)})),(0,t.t6)("saveAsFastaTest1",(async()=>{u(r[s.test1])})),(0,t.t6)("saveAsFastaTest2",(async()=>{u(r[s.test2])}))}));var B=n(4152),V=n(439);const U=V._S;(0,t.L1)("bio",(()=>{let n;(0,t.gM)((async()=>{n=await(0,c.Q)()}));const i="seq\nACGTCT\nCAGTGT\nTTCAAC";(0,t.t6)("testGetStatsHelm1",(async()=>{const n=e.DataFrame.fromCsv("seq\nPEPTIDE1{meI}$$$$").getCol("seq");n.semType=e.SEMTYPE.MACROMOLECULE,n.meta.units=l.Hi.HELM;const i=(0,A.vZ)(n,1,l.qp);(0,t.Xk)(i.freq,{meI:1}),(0,t.E3)(i.sameLength,!0)})),(0,t.t6)("testGetStatsN1",(async()=>{await function(n){const i=e.DataFrame.fromCsv(n).col("seq");i.semType=e.SEMTYPE.MACROMOLECULE,i.meta.units=l.Hi.FASTA;const o=(0,A.vZ)(i,5,l.J9);(0,t.Xk)(o.freq,{A:4,C:5,G:3,T:6}),(0,t.E3)(o.sameLength,!0)}(i)})),(0,t.t6)("testGetAlphabetSimilarity",(async()=>{await async function(){const e={A:2041,C:3015,G:3015,T:2048,[U]:1e3},n=new Set(Object.keys(r.Q.Names)),i=(0,l.nq)(e,n);(0,t.E3)(i>.6,!0)}()})),(0,t.t6)("testPickupPaletteN1",(async()=>{await async function(i){const o=e.DataFrame.fromCsv(i).col("seq");o.semType=e.SEMTYPE.MACROMOLECULE,o.meta.units=l.Hi.FASTA;const s=(0,l.SM)(o,n);(0,t.E3)(s instanceof r.A,!0)}(i)})),(0,t.t6)("testPickupPaletteN1e",(async()=>{await async function(){const i=e.DataFrame.fromCsv("seq\nACGTAT\nCAGTTG\nTTCG2C").col("seq");i.semType=e.SEMTYPE.MACROMOLECULE,i.meta.units=l.Hi.FASTA;const o=(0,l.SM)(i,n);(0,t.E3)(o instanceof r.A,!0)}()})),(0,t.t6)("testPickupPaletteAA1",(async()=>{await async function(){const i=e.DataFrame.fromCsv("seq\nFWPHEYV\nYNRQWYV\nMKPSEYV").col("seq");i.semType=e.SEMTYPE.MACROMOLECULE,i.meta.units=l.Hi.FASTA;const s=(0,l.SM)(i,n);(0,t.E3)(s instanceof o.X,!0)}()})),(0,t.t6)("testPickupPaletteX",(async()=>{await async function(){const i=e.DataFrame.fromCsv("seq\nXZJ{}2\n5Z4733\n3Z6></\n675687").col("seq");i.semType=e.SEMTYPE.MACROMOLECULE,i.meta.units=l.Hi.FASTA;const o=(0,l.SM)(i,n);(0,t.E3)(o instanceof B.$u,!0)}()}))})),(0,t.L1)("WebLogo.monomerToShort",(()=>{(0,t.t6)("longMonomerSingle",(async()=>{(0,t.E3)((0,l.zS)("S",5),"S")})),(0,t.t6)("longMonomerShort",(async()=>{(0,t.E3)((0,l.zS)("Short",5),"Short")})),(0,t.t6)("longMonomerLong56",(async()=>{(0,t.E3)((0,l.zS)("Long56",6),"Long56")})),(0,t.t6)("longMonomerComplexFirstPartShort",(async()=>{(0,t.E3)((0,l.zS)("Long-long",5),"Long…")})),(0,t.t6)("longMonomerComplexFirstPartLong56",(async()=>{(0,t.E3)((0,l.zS)("Long56-long",6),"Long5…")})),(0,t.t6)("monomerToShort",(async()=>{const e=[["AbC","AbC"],["AbCd","Ab…"],["ABc","ABc"],["ABcd","AB…"],["A_b","A_b"],["A_bc","A…"],["Ab_c","Ab…"],["A1_b","A1…"],["Abc_d","Ab…"],["Abcd_e","Ab…"],["A-b","A-b"],["A-bc","A…"],["Ab-c","Ab…"],["A1-b","A1…"],["Abc-d","Ab…"],["Abcd-e","Ab…"],["A","A"],["Ab","Ab"],["Abc","Abc"],["Ab…","Ab…"],["Abcd","Ab…"],["Abcde","Ab…"]],n=e.map((e=>e[0])),i=e.map((e=>e[1])),o=n.map((e=>(0,l.zS)(e,3)));(0,t.J6)(o,i)}))}));var W=n(250);const q=V._S;function Y(e,n){(0,t.E3)(e.name,n.name),(0,t.J6)(e.getMonomers(),n.getMonomers());for(const i of e.getMonomers())(0,t.E3)(e.getFreq(i).rowCount,n.getFreq(i).rowCount)}(0,t.L1)("WebLogo.positions",(()=>{let n;(0,t.gM)((async()=>{n=await(0,c.Q)()}));const i="seq\nATC-G-TTGC--\nATC-G-TTGC--\n-TC-G-TTGC--\n-TC-GCTTGC--\n-TC-GCTTGC--";(0,t.t6)("allPositions",(async()=>{const n=e.DataFrame.fromCsv(i),o=a.shell.addTableView(n),s=n.getCol("seq");s.semType=e.SEMTYPE.MACROMOLECULE,s.meta.units=l.Hi.FASTA,s.setTag(l.gp.alphabet,l.YI.DNA),s.setTag(l.gp.aligned,"SEQ.MSA");const r=await n.plot.fromType("WebLogo");await(0,t.PE)(r.onLayoutCalculated,(()=>{}),(()=>{o.dockManager.dock(r.root,e.DOCK_TYPE.DOWN)}),500,"Layout calculate timeout");const c=r.positions,u=[new W.Ue(0,"1",{A:new W.Tc(2),[q]:new W.Tc(3)}),new W.Ue(1,"2",{T:new W.Tc(5)}),new W.Ue(2,"3",{C:new W.Tc(5)}),new W.Ue(3,"4",{[q]:new W.Tc(5)}),new W.Ue(4,"5",{G:new W.Tc(5)}),new W.Ue(5,"6",{[q]:new W.Tc(3),C:new W.Tc(2)}),new W.Ue(6,"7",{T:new W.Tc(5)}),new W.Ue(7,"8",{T:new W.Tc(5)}),new W.Ue(8,"9",{G:new W.Tc(5)}),new W.Ue(9,"10",{C:new W.Tc(5)}),new W.Ue(10,"11",{[q]:new W.Tc(5)}),new W.Ue(11,"12",{[q]:new W.Tc(5)})];(0,t.E3)(c.length,u.length);for(let e=0;e<c.length;e++){(0,t.E3)(c[e].name,u[e].name);for(const n of c[e].getMonomers())(0,t.E3)(c[e].getFreq(n).rowCount,u[e].getFreq(n).rowCount)}await r.awaitRendered()})),(0,t.t6)("positions with shrinkEmptyTail option true (filtered)",(async()=>{const n=e.DataFrame.fromCsv("seq\n-TC-G-TTGC--\n-TC-GCTTGC--\n-T--C-GT-\n-T--C-GT-\n-T--C-GT-\n-T--CCGT-"),i=a.shell.addTableView(n),o=n.getCol("seq");o.semType=e.SEMTYPE.MACROMOLECULE,o.meta.units=l.Hi.FASTA,o.setTag(l.gp.alphabet,l.YI.DNA),o.setTag(l.gp.aligned,"SEQ"),n.filter.init((e=>e>2)),n.filter.fireChanged();const s=await n.plot.fromType("WebLogo",{shrinkEmptyTail:!0});await(0,t.PE)(s.onLayoutCalculated,(()=>{}),(()=>{i.dockManager.dock(s.root,e.DOCK_TYPE.DOWN)}),500);const r=s.positions,c=[new W.Ue(0,"1",{[q]:new W.Tc(3)}),new W.Ue(1,"2",{T:new W.Tc(3)}),new W.Ue(2,"3",{[q]:new W.Tc(3)}),new W.Ue(3,"4",{[q]:new W.Tc(3)}),new W.Ue(4,"5",{C:new W.Tc(3)}),new W.Ue(5,"6",{[q]:new W.Tc(2),C:new W.Tc(1)}),new W.Ue(6,"7",{G:new W.Tc(3)}),new W.Ue(7,"8",{T:new W.Tc(3)}),new W.Ue(8,"9",{[q]:new W.Tc(3)})];(0,t.E3)(r.length,c.length);for(let e=0;e<r.length;e++){(0,t.E3)(r[e].name,c[e].name);for(const n of r[e].getMonomers())(0,t.E3)(r[e].getFreq(n).rowCount,c[e].getFreq(n).rowCount)}await s.awaitRendered()})),(0,t.t6)("positions with skipEmptyPositions option",(async()=>{const n=e.DataFrame.fromCsv(i),o=a.shell.addTableView(n),s=n.getCol("seq");s.semType=e.SEMTYPE.MACROMOLECULE,s.meta.units=l.Hi.FASTA,s.setTag(l.gp.alphabet,l.YI.DNA),s.setTag(l.gp.aligned,"SEQ.MSA");const r=await n.plot.fromType("WebLogo",{skipEmptyPositions:!0});await(0,t.PE)(r.onLayoutCalculated,(()=>{}),(()=>{o.dockManager.dock(r.root,e.DOCK_TYPE.DOWN)}),500);const c=r.positions,u=[new W.Ue(0,"1",{A:new W.Tc(2),[q]:new W.Tc(3)}),new W.Ue(1,"2",{T:new W.Tc(5)}),new W.Ue(2,"3",{C:new W.Tc(5)}),new W.Ue(4,"5",{G:new W.Tc(5)}),new W.Ue(5,"6",{[q]:new W.Tc(3),C:new W.Tc(2)}),new W.Ue(6,"7",{T:new W.Tc(5)}),new W.Ue(7,"8",{T:new W.Tc(5)}),new W.Ue(8,"9",{G:new W.Tc(5)}),new W.Ue(9,"10",{C:new W.Tc(5)})];(0,t.E3)(c.length,u.length);for(let e=0;e<c.length;e++)Y(c[e],u[e]);await r.awaitRendered()})),(0,t.t6)("count sequences for monomer at position",(async()=>{const o=function(t,n,i){const o=e.DataFrame.fromCsv(t),s=o.getCol("seq");return s.semType=e.SEMTYPE.MACROMOLECULE,s.meta.units=n,s.setTag(l.gp.alphabet,i),s.setTag(l.gp.aligned,"SEQ.MSA"),o}(i,l.Hi.FASTA,l.YI.DNA),s=o.getCol("seq"),r=a.shell.addTableView(o),c=await o.plot.fromType("WebLogo",{startPositionName:"3",endPositionName:"7",skipEmptyPositions:!0});await(0,t.PE)(c.onLayoutCalculated,(()=>{}),(()=>{r.dockManager.dock(c.root,e.DOCK_TYPE.DOWN)}),500);const u=c.positions,h=[new W.Ue(2,"3",{C:new W.Tc(5)}),new W.Ue(4,"5",{G:new W.Tc(5)}),new W.Ue(5,"6",{[q]:new W.Tc(3),C:new W.Tc(2)}),new W.Ue(6,"7",{T:new W.Tc(5)})];(0,t.E3)(u.length,h.length);for(let e=0;e<u.length;e++)Y(u[e],h[e]);const d=u[1],p=n.getSeqHandler(s),m=(0,W.eN)(o,p,o.filter,"G",d);(0,t.E3)(m,5),await c.awaitRendered()})),(0,t.t6)("empty",(async()=>{const n=e.DataFrame.fromColumns([(()=>{const t=e.Column.fromStrings("seq",[]);return t.semType=e.SEMTYPE.MACROMOLECULE,t.meta.units=l.Hi.FASTA,t.setTag(l.gp.alphabet,l.YI.DNA),t})()]),i=a.shell.addTableView(n),o=await n.plot.fromType("WebLogo");await(0,t.PE)(o.onLayoutCalculated,(()=>{}),(()=>{i.dockManager.dock(o.root,e.DOCK_TYPE.DOWN)}),500),o.positions,await o.awaitRendered()}))})),(0,t.L1)("WebLogo.project",(()=>{(0,t.t6)("fasta",(async()=>{const n="Tests.Bio.WebLogo-project.fasta",i=await Ce.files.readCsv("tests/filter_FASTA.csv"),o=i.name,s=i.getCol("fasta");await a.data.detectSemanticTypes(i);const r=a.shell.addTableView(i),l=await i.plot.fromType("WebLogo",{sequenceColumnName:s.name});r.dockManager.dock(l),await l.awaitRendered(),await E(r.grid),await async function(t,n,i,o){const s=e.Project.create(),r=i.saveLayout();s.name=t,s.addChild(n),s.addChild(r),await a.dapi.layouts.save(i.saveLayout()),await a.dapi.tables.uploadDataFrame(o),await a.dapi.tables.save(n),await a.dapi.projects.save(s)}(n,i.getTableInfo(),r,i),a.shell.closeAll(),await(0,t.cb)(500),await a.dapi.projects.open(n);const c=a.shell.getTableView(o),u=v()(c.viewers).toArray();(0,t.E3)(u.length,2),(0,t.E3)(u.filter((e=>"Grid"===e.type)).length,1);const h=u.find((e=>"WebLogo"===e.type));(0,t.E3)(!!h,!0),await E(r.grid),await h.awaitRendered()}),{skipReason:"depends on 1.18"})})),(0,t.L1)("WebLogo.layout",(()=>{(0,t.t6)("fasta",(async()=>{const e=await Ce.files.readCsv("tests/filter_FASTA.csv"),n=e.getCol("fasta");await a.data.detectSemanticTypes(e);const i=a.shell.addTableView(e),o=await e.plot.fromType("WebLogo",{sequenceColumnName:n.name});i.dockManager.dock(o),await(0,t.cb)(2*W.VN.render),await o.awaitRendered(),await E(i.grid);const s=i.saveLayout();s.toJson(),i.loadLayout(s),await(0,t.cb)(2*W.VN.render),await o.awaitRendered(),await E(i.grid);const r=v()(i.viewers).toArray();(0,t.E3)(r.length,2),(0,t.E3)(r.filter((e=>"Grid"===e.type)).length,1),(0,t.E3)(r.filter((e=>"WebLogo"===e.type)).length,1)}))}));var j=n(966);function K(e,t){let n=null;for(const i of e.viewers)i.type===t&&(n=i);return n}(0,t.L1)("checkInputColumn",(()=>{let n;(0,t.gM)((async()=>{n=await(0,c.Q)()}));const i="seq\nseq1,\nseq2,\nseq3,\nseq4";(0,t.t6)("testMsaPos",(async()=>{const o=e.DataFrame.fromCsv(i).getCol("seq");o.semType=e.SEMTYPE.MACROMOLECULE,o.meta.units=l.Hi.FASTA,o.setTag(l.gp.alphabet,l.YI.DNA),o.setTag(l.gp.aligned,"SEQ");const[s,r]=(0,j.l)(o,"Test",n,[l.Hi.FASTA],[l.YI.DNA,l.YI.RNA,l.YI.PT]);(0,t.E3)(s,!0)})),(0,t.t6)("testMsaNegHelm",(async()=>{const o=e.DataFrame.fromCsv(i).getCol("seq");o.semType=e.SEMTYPE.MACROMOLECULE,o.meta.units=l.Hi.HELM,o.setTag(l.gp.alphabetIsMultichar,"true");const[s,r]=(0,j.l)(o,"Test",n,[l.Hi.FASTA],[l.YI.DNA,l.YI.RNA,l.YI.PT]);(0,t.E3)(s,!1)})),(0,t.t6)("testMsaNegUN",(async()=>{const o=e.DataFrame.fromCsv(i).getCol("seq");o.semType=e.SEMTYPE.MACROMOLECULE,o.meta.units=l.Hi.FASTA,o.setTag(l.gp.alphabet,"UN"),o.setTag(l.gp.alphabetSize,"11"),o.setTag(l.gp.alphabetIsMultichar,"true"),o.setTag(l.gp.aligned,"SEQ");const[s,r]=(0,j.l)(o,"Test",n,[l.Hi.FASTA],[l.YI.DNA,l.YI.RNA,l.YI.PT]);(0,t.E3)(s,!1)})),(0,t.t6)("testGetActionFunctionMeta",(async()=>{e.Func.find({package:"Bio",name:"multipleSequenceAlignmentDialog"})[0].inputs.find((e=>"sequence"==e.name))}))})),(0,t.L1)("similarity/diversity",(async()=>{(0,t.t6)("similaritySearchViewer",(async()=>{await async function(){const n=await Ce.files.readAsText("tests/sample_MSA_data.csv"),i=e.DataFrame.fromCsv(n);await a.data.detectSemanticTypes(i);const o=a.shell.addTableView(i),s=o.dataFrame.getCol("MSA");(0,t.E3)(s.semType,e.SEMTYPE.MACROMOLECULE);const r=await o.dataFrame.plot.fromType("Sequence Similarity Search");let l=!1;if(r.computeCompleted.subscribe((e=>{e&&(l=!0)})),o.dockManager.dock(r,e.DOCK_TYPE.RIGHT,null,"Similarity"),await r.renderPromise,await(0,t.bk)((()=>void 0!==K(o,"Sequence Similarity Search")),"Sequence Similarity Search viewer has not been created",100),!r.initialized)throw new Error("The viewer is not initialized.");if(!r.targetColumn)throw new Error("The viewer has not molecule column (onTableAttached).");if(!r.beforeRender())throw new Error("The viewer is not able to render.");if(!r.computeRequested)throw new Error("The viewer has not compute requested even.");if(!l)throw new Error("The viewer has not compute completed.");const c=r;await(0,t.bk)((()=>0!==c.root.getElementsByClassName("d4-grid").length),"Sequence Similarity Search viewer grid has not been created",100);(0,t.E3)(c.fingerprint,"Morgan"),(0,t.E3)(c.distanceMetric,"Hamming"),(0,t.E3)(c.scores.get(0),e.FLOAT_NULL),(0,t.E3)(c.idxs.get(0),0),(0,t.E3)(c.molCol.get(0),"D-Tyr_Et/Tyr_ab-dehydroMe/dV/E/N/D-Orn/D-aThr//Phe_4Me"),(0,t.E3)(c.scores.get(1).toFixed(2),"0.10"),(0,t.E3)(c.idxs.get(1),7),(0,t.E3)(c.molCol.get(1),"/D-Tyr_Et/meQ/dV/E/N/dV///Phe_4Me"),o.dataFrame.currentRowIdx=1,await(0,t.bk)((()=>1===c.targetMoleculeIdx),"Target molecule has not been changed",5e3),await(0,t.bk)((()=>"meI/hHis/Aca/Cys_SEt/T/dK/Thr_PO3H2/Aca/Tyr_PO3H2/D-Chg/dV/Phe_ab-dehydro/N/D-Orn/D-aThr//Phe_4Me"===c.molCol.get(0)),"Incorrect first similar molecule",5e3)}()})),(0,t.t6)("diversitySearchViewer",(async()=>{await async function(){const n=await Ce.files.readAsText("tests/sample_MSA_data.csv"),i=e.DataFrame.fromCsv(n),o=a.shell.addTableView(i);await a.data.detectSemanticTypes(i);const s=o.dataFrame.getCol("MSA");(0,t.E3)(s.semType,e.SEMTYPE.MACROMOLECULE);const r=await o.dataFrame.plot.fromType("Sequence Diversity Search");let l=!1;if(r.computeCompleted.subscribe((e=>{e&&(l=!0)})),o.dockManager.dock(r,e.DOCK_TYPE.DOWN,null,"Diversity"),await r.renderPromise,await(0,t.bk)((()=>void 0!==K(o,"Sequence Diversity Search")),"Sequence Diversity Search viewer has not been created",100),!r.initialized)throw new Error("The viewer is not initialized.");if(!r.targetColumn)throw new Error("The viewer has not molecule column (onTableAttached).");if(!r.beforeRender())throw new Error("The viewer is not able to render.");if(!r.computeRequested)throw new Error("The viewer has not compute requested even.");if(!l)throw new Error("The viewer has not compute completed.");const c=r;await(0,t.bk)((()=>0!==c.root.getElementsByClassName("d4-grid").length),"Sequence Diversity Search viewer grid has not been created",100),(0,t.E3)(c.fingerprint,"Morgan"),(0,t.E3)(c.distanceMetric,"Hamming"),(0,t.E3)(c.initialized,!0),(0,t.E3)(c.renderMolIds.length>0,!0)}()}))}));var z=n(1687),Z=n(4574);(0,t.L1)("bio-substructure-filters",(async()=>{let n,i,o;async function s(e,t){if(!t.columns.names().includes(e))throw new Error(`The column '${e}' not found. Available in data frame are ${JSON.stringify(t.columns.names())}`);const i=new z._i(n,Ce.logger);return i.attach(t),i.applyState({columnName:e}),i.column=t.col(e),i.columnName=e,i}(0,t.gM)((async()=>{n=await(0,c.Q)(),i=await(0,C.pj)(),o=await(0,x.ub)(),await i.loadMonomerLibForTests()})),(0,t.Pl)((async()=>{await(0,x.Eu)(o),await i.loadMonomerLib(!0)})),(0,t.t6)("fasta",(async()=>{const e=await S("tests/filter_FASTA.csv");await a.data.detectSemanticTypes(e);const i=new z._i(n,Ce.logger);i.attach(e),await i.awaitRendered();try{(0,t.E3)(!!i.bioFilter,!0),(0,t.E3)(i.bioFilter.type,"FastaBioFilter");const n=i.bioFilter;await(0,t.PE)(e.onRowsFiltered,(()=>{}),(()=>{n.props=new Z.n("MD",void 0,Ce.logger)}),5e3,"testEvent onRowsFiltered"),(0,t.E3)(i.dataFrame.filter.trueCount,3),(0,t.E3)(i.dataFrame?.filter.toBinaryString(),"10010000100000")}finally{i.detach()}await i.awaitRendered()})),(0,t.t6)("separator",(async()=>{const e=await S("tests/filter_MSA.csv"),i=new z._i(n,Ce.logger);await a.data.detectSemanticTypes(e),i.attach(e),await i.awaitRendered();try{(0,t.E3)(!!i.bioFilter,!0),(0,t.E3)(i.bioFilter.type,"SeparatorBioFilter");const n=i.bioFilter;await(0,t.PE)(e.onRowsFiltered,(()=>{}),(()=>{n.props=new z.AR("meI",void 0,Ce.logger)}),5e3,"testEvent onRowsFiltered"),(0,t.E3)(i.dataFrame.filter.trueCount,7),(0,t.E3)(i.dataFrame.filter.get(2),!1),await(0,t.PE)(e.onRowsFiltered,(()=>{}),(()=>{n.props=new z.AR("/meI",void 0,Ce.logger)}),5e3,"testEvent onRowsFiltered"),(0,t.E3)(i.dataFrame.filter.trueCount,0),await(0,t.PE)(e.onRowsFiltered,(()=>{}),(()=>{n.props=new z.AR("meI-hHis","-",Ce.logger)}),5e3,"testEvent onRowsFiltered"),(0,t.E3)(i.dataFrame.filter.trueCount,7),(0,t.E3)(i.dataFrame.filter.get(2),!1)}finally{i.detach()}await i.awaitRendered()})),(0,t.t6)("helm-dialog",(async()=>{if(e.Func.find({package:"Helm",name:"getHelmHelper"}).length){const e="Bio tests: substructureFilters/helm-dialog",i=await S("tests/filter_HELM.csv"),o=a.shell.addTableView(i);await a.data.detectSemanticTypes(i),await i.meta.detectSemanticTypes(),Ce.logger.debug(`${e}, filter attaching.`);const s=new z._i(n,Ce.logger);s.attach(i);const r=P.dialog("Test filters").add(s.root).show();await s.awaitRendered();try{const n=s.bioFilter;(0,t.E3)(null!==s.bioFilter,!0,"bioFilter is not created"),Ce.logger.debug(`${e}, filter 1 change awaiting...`),await(0,t.PE)(i.onRowsFiltered,(()=>{}),(()=>{n.props=new Z.n("PEPTIDE1{A.C}$$$$V2.0",void 0,Ce.logger)}),2e4),Ce.logger.debug(`${e}, filter 1 changed.`),(0,t.E3)(s.dataFrame.filter.trueCount,1),(0,t.E3)(s.dataFrame.filter.toBinaryString(),"0001"),Ce.logger.debug(`${e}, filter 2 change awaiting...`),await(0,t.PE)(i.onRowsFiltered,(()=>{}),(()=>{n.props=new Z.n("PEPTIDE1{C}$$$$V2.0",void 0,Ce.logger)}),2e4),setTimeout((()=>o.grid.invalidate()),500),await E(o.grid),await(0,t.cb)(1e3),Ce.logger.debug(`${e}, filter 2 changed.`),(0,t.E3)(s.dataFrame.filter.trueCount,2),(0,t.E3)(s.dataFrame.filter.toBinaryString(),"1001")}finally{r.close()}await s.awaitRendered(),await(0,t.cb)(3e3)}}),{}),(0,t.t6)("helm-view",(async()=>{if(e.Func.find({package:"Helm",name:"getHelmHelper"}).length){const e=await S("tests/filter_HELM.csv");e.getCol("HELM string"),await a.data.detectSemanticTypes(e);const t=a.shell.addTableView(e);t.getFiltersGroup(),await E(t.grid)}})),(0,t.t6)("sync-fasta",(async()=>{const e=await Ce.files.readCsv("tests/filter_FASTA.csv");await a.data.detectSemanticTypes(e);const n=await s("fasta",e),i=await s("fasta",e);await Promise.all([n.awaitRendered(),i.awaitRendered()]);try{(0,t.E3)(!!n.bioFilter,!0),(0,t.E3)(!!i.bioFilter,!0),(0,t.E3)(n.bioFilter.type,"FastaBioFilter"),(0,t.E3)(i.bioFilter.type,"FastaBioFilter");const o=n.bioFilter,s=i.bioFilter;await(0,t.PE)(e.onRowsFiltered,(()=>{}),(()=>{o.props=new Z.n("MD",void 0,Ce.logger)}),1e4,"await onRowsFiltered"),(0,t.E3)(e.filter.trueCount,3),await n.awaitRendered(),(0,t.E3)(s.props.substructure,"MD")}finally{n.detach(),i.detach()}await Promise.all([n.awaitRendered(),i.awaitRendered()])})),(0,t.t6)("sync-msa",(async()=>{const e=await Ce.files.readCsv("tests/filter_MSA.csv");await a.data.detectSemanticTypes(e);const n="hHis-Aca",i=await s("MSA",e),o=await s("MSA",e);await Promise.all([i.awaitRendered(),o.awaitRendered()]);try{(0,t.E3)(!!i.bioFilter,!0),(0,t.E3)(!!o.bioFilter,!0),(0,t.E3)(i.bioFilter.type,"SeparatorBioFilter"),(0,t.E3)(o.bioFilter.type,"SeparatorBioFilter");const s=i.bioFilter,r=o.bioFilter;await(0,t.PE)(e.onRowsFiltered,(()=>{}),(()=>{s.props=new z.AR(n,"-",Ce.logger)}),1e4,"await onRowsFiltered"),(0,t.E3)(e.filter.trueCount,8),(0,t.E3)(r.props.substructure,n),(0,t.E3)(r.props.separator,"-")}finally{i.detach(),o.detach()}await Promise.all([i.awaitRendered(),o.awaitRendered()])})),(0,t.t6)("sync-helm",(async()=>{if(e.Func.find({package:"Helm",name:"getHelmHelper"}).length){const e=await Ce.files.readCsv("tests/filter_HELM.csv");await a.data.detectSemanticTypes(e);const n=a.shell.addTableView(e),i="PEPTIDE1{A.C}$$$$V2.0",o=1,r=await s("HELM string",e),l=await s("HELM string",e),c=P.dialog("Test filters").add(r.root).add(l.root).show();await Promise.all([r.awaitRendered(),l.awaitRendered()]);try{(0,t.E3)(!!r.bioFilter,!0),(0,t.E3)(!!l.bioFilter,!0),(0,t.E3)(r.bioFilter.type,"HelmBioFilter"),(0,t.E3)(l.bioFilter.type,"HelmBioFilter");const s=r.bioFilter,a=l.bioFilter;await(0,t.PE)(e.onRowsFiltered,(()=>{}),(()=>{s.props=new Z.n(i,void 0,Ce.logger)}),6e4,"await onRowsFiltered"),await E(n.grid),Ce.logger.debug("Bio tests: substructureFilters/sync-helm, before changed event"),await(0,t.cb)(2*r.debounceTime),Ce.logger.debug("Bio tests: substructureFilters/sync-helm, after changed event"),(0,t.E3)(e.filter.trueCount,o),await r.awaitRendered(),(0,t.E3)(a.props.substructure,i)}finally{r.detach(),l.detach(),c.close()}await Promise.all([r.awaitRendered(),l.awaitRendered()]),await E(n.grid),await(0,t.cb)(3e3)}})),(0,t.t6)("two-columns-fasta",(async()=>{const n=e.DataFrame.fromCsv("id,seq1,seq2,trueSeq1,trueSeq2\n0,CGGCTACGGC,ATTGCATTCG,0,1,\n1,CGGCTGCCGC,ATAGCATTCG,1,1,\n2,CGGCTGCGCC,AATGCATACG,1,0,\n3,CGGCTGCATT,TTTGCATTCG,1,1,\n4,CGGCTGCATT,AAAGCATACG,1,0,\n");await a.data.detectSemanticTypes(n);const i=a.shell.addTableView(n),o="seq1",s="CGGCTG",r=n.getCol("trueSeq1").toList(),l="seq2",c="GCATT",u=n.getCol("trueSeq2").toList(),h=[{type:"Bio:bioSubstructureFilter",columnName:o},{type:"Bio:bioSubstructureFilter",columnName:l}],d=await n.plot.fromType(e.VIEWER.FILTERS,{filters:h});i.dockManager.dock(d,e.DOCK_TYPE.LEFT),await(0,t.cb)(100),await E(i.grid);const p=d.filters[0],m=d.filters[1];(0,t.E3)(p.column.name,o),(0,t.E3)(m.column.name,l);const g=p.bioFilter,f=m.bioFilter;await(0,t.PE)(n.onRowsFiltered,(()=>{}),(()=>{g.props=new Z.n(s,void 0,Ce.logger)}),1e3),await(0,t.PE)(n.onRowsFiltered,(()=>{}),(()=>{f.props=new Z.n("",void 0,Ce.logger)}),1e3,"testEvent onRowsFiltered on seq1"),(0,t.E3)(n.filter.trueCount,r.filter((e=>1===e)).length),(0,t.E3)(n.filter.toBinaryString(),r.map((e=>e.toString())).join("")),await(0,t.PE)(n.onRowsFiltered,(()=>{}),(()=>{g.props=new Z.n("",void 0,Ce.logger)}),1e3),await(0,t.PE)(n.onRowsFiltered,(()=>{}),(()=>{f.props=new Z.n(c,void 0,Ce.logger)}),1e3,"testEvent onRowsFiltered on seq2"),(0,t.E3)(n.filter.trueCount,u.filter((e=>1===e)).length),(0,t.E3)(n.filter.toBinaryString(),u.map((e=>e.toString())).join("")),await(0,t.PE)(n.onRowsFiltered,(()=>{}),(()=>{g.props=new Z.n("",void 0,Ce.logger)}),1e3),await(0,t.PE)(n.onRowsFiltered,(()=>{}),(()=>{f.props=new Z.n("",void 0,Ce.logger)}),1e3,"testEvent onRowsFiltered on neither"),(0,t.E3)(n.filter.trueCount,n.rowCount),await(0,t.PE)(n.onRowsFiltered,(()=>{}),(()=>{g.props=new Z.n(s,void 0,Ce.logger)}),5e3),await(0,t.PE)(n.onRowsFiltered,(()=>{}),(()=>{f.props=new Z.n(c,void 0,Ce.logger)}),5e3,"testEvent onRowsFiltered on both");const y=v().count(0).take(n.rowCount).map((e=>r[e]*u[e])).toArray();(0,t.E3)(n.filter.trueCount,y.filter((e=>1===e)).length),(0,t.E3)(n.filter.toBinaryString(),y.map((e=>e.toString())).join("")),await Promise.all([p.awaitRendered(),m.awaitRendered(),E(i.grid)])}),{skipReason:"Inconsistent behavior of test"}),(0,t.t6)("reset-fasta",(async()=>{const n=await S("tests/filter_FASTA.csv"),i=a.shell.addTableView(n);await a.data.detectSemanticTypes(n),await n.meta.detectSemanticTypes();const o="MD",s=await n.plot.fromType(e.VIEWER.FILTERS,{filters:[{type:"Bio:bioSubstructureFilter",columnName:"fasta"}]});i.dockManager.dock(s,e.DOCK_TYPE.LEFT),await(0,t.cb)(100),await E(i.grid);const r=s.filters[0].bioFilter;await(0,t.PE)(n.onRowsFiltered,(()=>{}),(()=>{r.props=new Z.n(o,void 0,Ce.logger)}),1e3,"testEvent onRowsFiltered"),(0,t.E3)(n.filter.trueCount,3),(0,t.E3)(r.props.substructure,o),(0,t.E3)(r.substructureInput.value,o),R()(s.root).find('i[name="icon-arrow-rotate-left"]')[0].click(),await(0,t.cb)(100),await E(i.grid),(0,t.E3)(r.props.substructure,""),(0,t.E3)(r.substructureInput.value,"")})),(0,t.t6)("reopen",(async()=>{const n=await Ce.files.readCsv("tests/filter_FASTA.csv"),i=a.shell.addTableView(n);await a.data.detectSemanticTypes(n),await n.meta.detectSemanticTypes();const o=[{type:"Bio:bioSubstructureFilter",columnName:"fasta"}],s=await n.plot.fromType(e.VIEWER.FILTERS,{filters:o});i.dockManager.dock(s,e.DOCK_TYPE.LEFT),await(0,t.cb)(100),await E(i.grid),s.close(),await E(i.grid);const r=await n.plot.fromType(e.VIEWER.FILTERS,{filters:o});i.dockManager.dock(r,e.DOCK_TYPE.LEFT),await(0,t.cb)(100),await E(i.grid)}),{})}));var X=n(8152);class J{errorList=[];warningList=[];infoList=[];debugList=[];error(e,t,n){this.errorList.push({message:e,params:t,stackTrace:n})}warning(e,t){this.warningList.push({message:e,params:t})}info(e,t){this.infoList.push({message:e,params:t})}debug(e,t){this.debugList.push({message:e,params:t})}}var Q=n(9192);(0,t.L1)("PepSeA",(()=>{(0,t.t6)("Basic alignment",(async()=>{const n=e.DataFrame.fromCsv('HELM,MSA\n"PEPTIDE1{F.L.R.G.W.[MeF].Y.S.N.N.C}$$$$","F.L.R.G.W.MeF.Y..S.N.N.C"\n"PEPTIDE1{F.L.R.G.Y.[MeF].Y.W.N.C}$$$$","F.L.R.G.Y.MeF.Y.W...N.C"\n"PEPTIDE1{F.G.Y.[MeF].Y.W.S.D.N.C}$$$$","F...G.Y.MeF.Y.W.S.D.N.C"\n"PEPTIDE1{F.L.R.G.Y.[MeF].Y.W.S.N.D.C}$$$$","F.L.R.G.Y.MeF.Y.W.S.N.D.C"\n"PEPTIDE1{F.V.R.G.Y.[MeF].Y.W.S.N.C}$$$$","F.V.R.G.Y.MeF.Y.W.S..N.C"\n'),i=await(0,X.GD)(n,n.getCol("HELM"),"msa(HELM)"),o=n.getCol("MSA");for(let e=0;e<i.length;++e)(0,t.E3)(i.get(e)==o.get(e),!0)}),{timeout:6e4,stressTest:!0,skipReason:"Fails in docker"}),(0,t.t6)("stderr",(async()=>{const n=new J,i=e.DataFrame.fromCsv('HELM,MSA\n"PEPTIDE1{F.L.Mis.G.W.[MeF].Y.S.N.N.C}$$$$","F.L.Mis.G.W.MeF.Y..S.N.N.C"\n"PEPTIDE1{F.L.Mis.G.Y.[MeF].Y.W.N.C}$$$$","F.L.Mis.G.Y.MeF.Y...W.N.C"\n"PEPTIDE1{F.G.Y.[MeF].Y.W.S.D.N.C}$$$$","F...G.Y.MeF.Y.W.S.D.N.C"\n'),o=await(0,X.GD)(i,i.getCol("HELM"),"msa(HELM)",void 0,void 0,void 0,void 0,n),s=i.getCol("MSA");(0,t.J6)(o.toList(),s.toList()),(0,t.E3)(n.warningList[0].message,"Mis not found in Monomer Map\nMeF not found in Monomer Map\n")}),{timeout:6e4,stressTest:!0,skipReason:"Fails in docker"}),(0,t.t6)("error",(async()=>{const n=new J;try{const t=e.DataFrame.fromCsv('HELM\n"PEPTIDE1{[NH2].*.A.Q.T.T.Y.K.N.Y.R.R.N.L.L.*.[COOH]}$$$$"\n"PEPTIDE1{[NH2].M.A.N.T.T.Y.K.N.Y.R.N.N.L.L.*.[COOH]}$$$$"\n"PEPTIDE1{[NH2].*.A.N.T.T.Y.K.C.Y.R.R.N.L.L.*.[COOH]}$$$$"\n"PEPTIDE1{[NH2].*.A.N.T.T.Y.K.F.Y.R.R.N.L.L.*.[COOH]}$$$$"\n');await(0,X.GD)(t,t.getCol("HELM"),"msa(HELM)",void 0,void 0,void 0,void 0,n)}catch(e){const[t,i]=(0,Q.AP)(e);n.error(t,void 0,i)}(0,t.E3)(n.errorList[0].message,"PepSeA error: The pair (*,M) couldn't be found in the substitution matrix")}),{skipReason:"Fails in docker"})})),(0,t.L1)("viewers",(()=>{const n=e.Func.find({package:"Bio",tags:["viewer"]}).map((e=>e.friendlyName));for(const e of n)(0,t.t6)(e,(async()=>{const n=await S("samples/FASTA_DNA.csv");await(0,t.Bl)(e,n,{detectSemanticTypes:!0})}),{skipReason:{"Sequence Similarity Search":"GROK-13162","Sequence Diversity Search":"GROK-13162",WebLogo:"GROK-13162",VdRegions:"GROK-13162"}[e]})}));const ee="seq\nACGTCACGTC\nCAGTGTCAGTGT\nTTCAACTTCAAC",te="seq\nAC-GT-CTAC-GT-CT\nCAC-T-GTCAC-T-GT\nACCGTACTACCGTACT",ne="seq\nabc-dfgg-abc1-cfr3-rty-wert-abc-dfgg-abc1-cfr3-rty-wert\nrut12-her2-rty-wert-abc-abc1-dfgg-rut12-her2-rty-wert-abc-abc1-dfgg\nrut12-rty-her2-abc-cfr3-wert-rut12-rut12-rty-her2-abc-cfr3-wert-rut12";var ie,oe;(0,t.L1)("SeqHandler",(()=>{let n;async function i(t){const i=e.DataFrame.fromCsv(t);await a.data.detectSemanticTypes(i);const o=n.getSeqHandler(i.getCol("seq"));return[i,o]}(0,t.gM)((async()=>{n=await(0,c.Q)()})),(0,t.t6)("Seq-Fasta",(async()=>{const[e,n]=await i(ee);(0,t.E3)(n.notation,l.Hi.FASTA),(0,t.E3)(n.isMsa(),!1)})),(0,t.t6)("Seq-Fasta-MSA",(async()=>{const[e,n]=await i(te);(0,t.E3)(n.notation,l.Hi.FASTA),(0,t.E3)(n.isMsa(),!0)})),(0,t.t6)("Seq-Fasta-units",(async()=>{const[e,n]=await i(ee);(0,t.E3)(n.notation,l.Hi.FASTA),(0,t.E3)(n.isMsa(),!1)})),(0,t.t6)("Seq-Fasta-MSA-units",(async()=>{const[e,n]=await i(te);(0,t.E3)(n.notation,l.Hi.FASTA),(0,t.E3)(n.isMsa(),!0)})),(0,t.t6)("Seq-Helm",(async()=>{const[e,n]=await i("seq\nPEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et.Tyr_ab-dehydroMe.dV.E.N.D-Orn.D-aThr.Phe_4Me}$$$$\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2.D-Chg.dV.Phe_ab-dehydro.N.D-Orn.D-aThr.Phe_4Me}$$$$\nPEPTIDE1{Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2.D-Chg.dV.Thr_PO3H2.N.D-Orn.D-aThr.Phe_4Me}$$$$\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2.D-Chg.dV.Thr_PO3H2.N.D-Orn.D-aThr.Phe_4Me}$$$$");(0,t.E3)(n.notation,l.Hi.HELM),(0,t.E3)(n.isHelm(),!0)})),(0,t.t6)("Seq-UN",(async()=>{const[e,n]=await i(ne);(0,t.E3)(n.notation,l.Hi.SEPARATOR),(0,t.E3)(n.separator,"-"),(0,t.E3)(n.alphabet,l.YI.UN)})),(0,t.t6)("Seq-UN-auto",(async()=>{const[e,n]=await i(ne);(0,t.E3)(n.notation,l.Hi.SEPARATOR),(0,t.E3)(n.separator,"-"),(0,t.E3)(n.alphabet,l.YI.UN)})),(0,t.t6)("column-version",(async()=>{const i=e.DataFrame.fromCsv(ee);await a.data.detectSemanticTypes(i);const o=i.getCol("seq"),s=n.getSeqHandler(o),r=o.version,l=n.getSeqHandler(o),c=o.version;(0,t.E3)(r,c,"Unexpected column version changed"),(0,t.E3)(s,l,"Unexpected SeqHandler object changed"),i.rows.addNew(["TACCCCTTCAAC"]);const u=n.getSeqHandler(o),h=o.version;(0,t.E3)(c<h,!0,"Stalled column version on add row"),(0,t.E3)(l!==u,!0,"Stalled SeqHandler object on add row"),o.set(1,"CAGTGTCCCCGT");const d=n.getSeqHandler(o),p=o.version;(0,t.E3)(h<p,!0,"Stalled column version on change data"),(0,t.E3)(u!==d,!0,"Stalled SeqHandler object on change data"),o.setTag("testTag","testValue");const m=n.getSeqHandler(o),g=o.version;(0,t.E3)(p<g,!0,"Stalled column version on set tag"),(0,t.E3)(d!==m,!0,"Stalled SeqHandler object on set tag")}))})),(oe=ie||(ie={})).fasta="fasta",oe.fastaMsa="fastaMsa",oe.separator="separator",oe.separatorMsa="separatorMsa",oe.helm="helm",(0,t.L1)("SeqHandler: splitted",(()=>{let n;(0,t.gM)((async()=>{n=await(0,c.Q)()})),V.b9[l.Hi.FASTA],V.b9[l.Hi.HELM];const i=V.b9[l.Hi.SEPARATOR],o={[ie.fasta]:{src:{csv:"seq\nACGTCACGTC\nCAGTGTCAGTGT\nTTCAACTTCAAC"},tgt:{notation:l.Hi.FASTA,splitted:[["A","C","G","T","C","A","C","G","T","C"],["C","A","G","T","G","T","C","A","G","T","G","T"],["T","T","C","A","A","C","T","T","C","A","A","C"]]}},[ie.fastaMsa]:{src:{csv:"seq\nAC-GT-CTAC-GT-CT\nCAC-T-GTCAC-T-GT\nACCGTACTACCGTACT"},tgt:{notation:l.Hi.FASTA,splitted:[["A","C","-","G","T","-","C","T","A","C","-","G","T","-","C","T"],["C","A","C","-","T","-","G","T","C","A","C","-","T","-","G","T"],["A","C","C","G","T","A","C","T","A","C","C","G","T","A","C","T"]]}},[ie.separator]:{src:{csv:"seq\nabc-dfgg-abc1-cfr3-rty-wert-abc-dfgg-abc1-cfr3-rty-wert\nrut12-her2-rty-wert-abc-abc1-dfgg-rut12-her2-rty-wert-abc\nrut12-rty-her2-abc-cfr3-wert-rut12-rut12-rty-her2-abc-cfr3"},tgt:{notation:l.Hi.SEPARATOR,separator:"-",splitted:[["abc","dfgg","abc1","cfr3","rty","wert","abc","dfgg","abc1","cfr3","rty","wert"],["rut12","her2","rty","wert","abc","abc1","dfgg","rut12","her2","rty","wert","abc"],["rut12","rty","her2","abc","cfr3","wert","rut12","rut12","rty","her2","abc","cfr3"]]}},[ie.separatorMsa]:{src:{csv:'seq\nrut0-dfgg-abc1-cfr3-rty-wert-abc-dfgg-abc1-cfr3-rty-wert\nrut1-her2-rty--abc1-dfgg-rut12-her2-rty--abc1-dfgg\nrut2-rty-her2---wert-rut12-rty-her2---wert\n"rut3-rty-her2-""-""-""-""-wert-rut12-rty-her2-""-""-""-""-wert"\n"""-""-rut4-her2-wert-rut12-rty-her2-wert"\n"rut5-rty-her2-wert-rut12-rty-her2-wert-""-"""'},tgt:{notation:l.Hi.SEPARATOR,separator:"-",splitted:[["rut0","dfgg","abc1","cfr3","rty","wert","abc","dfgg","abc1","cfr3","rty","wert"],["rut1","her2","rty",i,"abc1","dfgg","rut12","her2","rty",i,"abc1","dfgg"],["rut2","rty","her2",i,i,"wert","rut12","rty","her2",i,i,"wert"],["rut3","rty","her2",i,i,"wert","rut12","rty","her2",i,i,"wert"],[i,"rut4","her2","wert","rut12","rty","her2","wert"],["rut5","rty","her2","wert","rut12","rty","her2","wert",i]]}},[ie.helm]:{src:{csv:"seq\nPEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et.Thr_PO3H2.Aca.D-Tyr_Et}$$$$\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.dK.Thr_PO3H2.Aca}$$$$\nPEPTIDE1{Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.dK.Thr_PO3H2.Aca}$$$$\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.T.dK.Thr_PO3H2}$$$$,\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.T.dK}|PEPTIDE2{Thr_PO3H2}$$$$"},tgt:{notation:l.Hi.HELM,splitted:[["meI","hHis","Aca","N","T","dE","Thr_PO3H2","Aca","D-Tyr_Et","Thr_PO3H2","Aca","D-Tyr_Et"],["meI","hHis","Aca","Cys_SEt","T","dK","Thr_PO3H2","Aca","dK","Thr_PO3H2","Aca"],["Lys_Boc","hHis","Aca","Cys_SEt","T","dK","Thr_PO3H2","Aca","dK","Thr_PO3H2","Aca"],["meI","hHis","Aca","Cys_SEt","T","dK","Thr_PO3H2","T","dK","Thr_PO3H2"],["meI","hHis","Aca","Cys_SEt","T","dK","Thr_PO3H2","T","dK","Thr_PO3H2"]]}}};for(const[i,s]of Object.entries(o))(0,t.t6)(`${i}`,(async()=>{const i=e.DataFrame.fromCsv(s.src.csv).getCol("seq"),o=await a.functions.call("Bio:detectMacromolecule",{col:i});o&&(i.semType=o),(0,t.E3)(i.semType,e.SEMTYPE.MACROMOLECULE);const r=n.getSeqHandler(i);(0,t.E3)(r.notation,s.tgt.notation),(0,t.E3)(r.separator===s.tgt.separator,!0);const l=v().count(0).take(r.length).map((e=>{const t=r.getSplitted(e);return v().count(0).take(t.length).map((e=>t.getOriginal(e))).toArray()})).toArray();(0,t.J6)(l,s.tgt.splitted)}))})),(0,t.L1)("SeqHandler: getRegion",(()=>{let n;(0,t.gM)((async()=>{n=await(0,c.Q)()}));const i={fastaDna:{srcCsv:"seq\nATTCGT\nACTGCTC\nATTCCGTA",startIdx:2,endIdx:4,tgtCsv:"seq\nTCG\nTGC\nTCC",units:l.Hi.FASTA,alphabet:l.YI.DNA,positionNames:{tag:"a, b, c, d, e, f, g, h",start:"c",end:"e"}},separatorPt:{srcCsv:"seq\nM-D-Y-K-E-T-L\nM-I-E-V-F-L-F-G-I\nM-M-",startIdx:5,endIdx:null,tgtCsv:"seq\nT-L--\nL-F-G-I\n---",units:l.Hi.SEPARATOR,alphabet:l.YI.PT,positionNames:{tag:"1, 1A, 1B, 2, 3, 4, 4A, 4A, 4C",start:"4",end:null}},helm:{srcCsv:"seq\nPEPTIDE1{[meI].[hHis].[Aca].N.T.[dE].[Thr_PO3H2].[Aca].[D-Tyr_Et].[Tyr_ab-dehydroMe].[dV].E.N.[D-Orn]}$$$$\nPEPTIDE1{[meI].[hHis].[Aca].[Cys_SEt].T.[dK].[Thr_PO3H2].[Aca].[Tyr_PO3H2].[D-Chg].[dV].[Phe_ab-dehydro]}$$$$\nPEPTIDE1{[Lys_Boc].[hHis].[Aca].[Cys_SEt].T}$$$$",startIdx:3,endIdx:6,tgtCsv:"seq\nPEPTIDE1{N.T.[dE].[Thr_PO3H2]}$$$$\nPEPTIDE1{[Cys_SEt].T.[dK].[Thr_PO3H2]}$$$$\nPEPTIDE1{[Cys_SEt].T.*.*}$$$$",units:l.Hi.HELM,alphabet:l.YI.UN,positionNames:{tag:null,start:"4",end:"7"}}};for(const[o,s]of Object.entries(i))(0,t.t6)(`${o}-idx`,(async()=>{const i=e.DataFrame.fromCsv(s.srcCsv).getCol("seq"),o=await a.functions.call("Bio:detectMacromolecule",{col:i});o&&(i.semType=o);const r=n.getSeqHandler(i).getRegion(s.startIdx,s.endIdx,"regSeq"),c=e.DataFrame.fromCsv(s.tgtCsv).getCol("seq");(0,t.E3)(i.meta.units,s.units),(0,t.E3)(r.meta.units,s.units),(0,t.E3)(i.getTag(l.gp.alphabet),s.alphabet),(0,t.E3)(r.getTag(l.gp.alphabet),s.alphabet),(0,t.J6)(r.toList(),c.toList())})),s.positionNames&&(0,t.t6)(`${o}-positionNames`,(async()=>{const n=e.DataFrame.fromCsv(s.srcCsv).getCol("seq");s.positionNames.tag&&n.setTag(l.gp.positionNames,s.positionNames.tag);const i=await a.functions.call("Bio:detectMacromolecule",{col:n});i&&(n.semType=i);const o=await a.functions.call("Bio:getRegion",{sequence:n,start:s.positionNames.start,end:s.positionNames.end}),r=e.DataFrame.fromCsv(s.tgtCsv).getCol("seq");(0,t.E3)(n.meta.units,s.units),(0,t.E3)(o.meta.units,s.units),(0,t.E3)(n.getTag(l.gp.alphabet),s.alphabet),(0,t.E3)(o.getTag(l.gp.alphabet),s.alphabet),(0,t.J6)(o.toList(),r.toList())}))})),(0,t.L1)("SeqHandler: getHelm",(()=>{let n,i,o;(0,t.gM)((async()=>{n=await(0,c.Q)(),i=await(0,C.pj)(),o=await(0,x.ub)(),await i.loadMonomerLibForTests()})),(0,t.Pl)((async()=>{await(0,x.Eu)(o),await i.loadMonomerLib(!0)}));const s={fasta:{src:{seq:"MDYKETMDYKET",notation:l.Hi.FASTA},tgt:{helm:"PEPTIDE1{M.D.Y.K.E.T.M.D.Y.K.E.T}$$$$"}},separator:{src:{seq:"M-D-Y-K-E-T-M-D-Y-K-E-T",notation:l.Hi.SEPARATOR,separator:"-"},tgt:{helm:"PEPTIDE1{M.D.Y.K.E.T.M.D.Y.K.E.T}$$$$"}},helm:{src:{seq:"PEPTIDE1{M.D.Y.K.E.T}$$$$",notation:l.Hi.HELM},tgt:{helm:"PEPTIDE1{M.D.Y.K.E.T}$$$$"}},"helm-cyclic":{src:{seq:"PEPTIDE1{M.D.Y.K.E.T}$PEPTIDE1,PEPTIDE1,6:R2-1:R1$$$V2.0",notation:l.Hi.HELM},tgt:{helm:"PEPTIDE1{M.D.Y.K.E.T}$PEPTIDE1,PEPTIDE1,6:R2-1:R1$$$V2.0"}}};for(const[e,n]of Object.entries(s))(0,t.t6)(e,(async()=>{await r(n.src.seq,n.src.notation,n.src.separator,n.tgt.helm)}));async function r(i,o,s,r){const l=e.Column.fromStrings("seq",[i]),c=e.DataFrame.fromColumns([l]);await a.data.detectSemanticTypes(c);const u=n.getSeqHandler(l),h=(await u.getValue(0)).helm;(0,t.E3)(h,r)}}));var se=n(2582);(0,t.L1)("helm",(()=>{const e={"single-linear":{src:{helm:"PEPTIDE1{R.F.Y.[GGaz].T.[meI]}$$$$"},tgt:{simplePolymers:[6],connections:[],bondedRGroups:[1,2,2,2,2,1]}},"single-cyclized-C-2-2":{src:{helm:"PEPTIDE1{R.F.C.Y.G.H.[GGaz].C.T.[meI]}$PEPTIDE1,PEPTIDE1,3:R3-8:R3$$$"},tgt:{simplePolymers:[10],connections:[[["PEPTIDE1",3,"R3"],["PEPTIDE1",8,"R3"]]],bondedRGroups:[1,2,3,2,2,2,2,3,2,1]}},"single-cyclized-C-1-1":{src:{helm:"PEPTIDE1{F.C.Y.G.H.[GGaz].C.[meI]}$PEPTIDE1,PEPTIDE1,2:R3-7:R3$$$"},tgt:{simplePolymers:[8],connections:[[["PEPTIDE1",2,"R3"],["PEPTIDE1",7,"R3"]]],bondedRGroups:[1,3,2,2,2,1,3,1]}},"single-cyclized-C-0-0":{src:{helm:"PEPTIDE1{C.Y.G.H.[GGaz].C}$PEPTIDE1,PEPTIDE1,1:R3-6:R3$$$"},tgt:{simplePolymers:[6],connections:[[["PEPTIDE1",1,"R3"],["PEPTIDE1",6,"R3"]]],bondedRGroups:[2,2,2,2,2,2]}},"two-separated-5-1":{src:{helm:"PEPTIDE1{R.F.Y.[GGaz].T}|PEPTIDE2{[meI]}$$$$"},tgt:{simplePolymers:[5,1],connections:[],bondedRGroups:[1,2,2,2,1,0]}},"two-separated-1-5":{src:{helm:"PEPTIDE1{[meI]}|PEPTIDE2{R.F.Y.[GGaz].T}$$$$"},tgt:{simplePolymers:[1,5],connections:[],bondedRGroups:[0,1,2,2,2,1]}},"two-separated-4-2":{src:{helm:"PEPTIDE1{R.F.Y.[GGaz]}|PEPTIDE2{T.[meI]}$$$$"},tgt:{simplePolymers:[4,2],connections:[],bondedRGroups:[1,2,2,1,1,1]}},"two-connected-1":{src:{helm:"PEPTIDE1{R.F.Y.[GGaz].T}|PEPTIDE2{[meI]}$PEPTIDE1,PEPTIDE2,5:R2-1:R1$$$"},tgt:{simplePolymers:[5,1],connections:[[["PEPTIDE1",5,"R2"],["PEPTIDE2",1,"R1"]]],bondedRGroups:[1,2,2,2,2,1]}},"two-connected-2":{src:{helm:"PEPTIDE1{R.F.Y.[GGaz]}|PEPTIDE2{T.[meI]}$PEPTIDE1,PEPTIDE2,4:R2-1:R1$$$"},tgt:{simplePolymers:[4,2],connections:[[["PEPTIDE1",4,"R2"],["PEPTIDE2",1,"R1"]]],bondedRGroups:[1,2,2,2,2,1]}},"two-cyclized-1-9":{src:{helm:"PEPTIDE1{[meI]}|PEPTIDE2{R.F.[GGaz].T.G.H.F.Y.P}$PEPTIDE2,PEPTIDE2,3:R3-9:R2|PEPTIDE2,PEPTIDE1,3:R4-1:R1$$$V2.0"},tgt:{simplePolymers:[1,9],connections:[[["PEPTIDE2",3,"R3"],["PEPTIDE2",9,"R2"]],[["PEPTIDE2",3,"R4"],["PEPTIDE1",1,"R1"]]],bondedRGroups:[1,1,2,4,2,2,2,2,2,1]}}};for(const[n,{src:i,tgt:o}]of Object.entries(e))(0,t.t6)(n,(async()=>{const e=new se.f(i.helm),n=e.simplePolymers.map((e=>e.monomers.length)),s=n.reduce(((e,t)=>e+t),0);(0,t.J6)(n,o.simplePolymers);const r=e.connectionList.getConnectionData().map((e=>[[e[0].polymerId,e[0].bond.monomerIdx+1,`R${e[0].bond.rGroupId}`],[e[1].polymerId,e[1].bond.monomerIdx+1,`R${e[1].bond.rGroupId}`]]));(0,t.J6)(r,o.connections);const a=v().count(0).take(e.bondedRGroupsMap.length).map((t=>e.bondedRGroupsMap[t].length)).toArray();(0,t.E3)(s,a.length)}))}));var re=n(6077),ae=n(6717);const le=new e.FileSource("System:AppData/Bio"),ce={"peptides-fasta":{inPath:"tests/to-atomic-level-peptides-fasta-input.csv",outPath:"tests/to-atomic-level-peptides-fasta-output.csv"},"dna-fasta":{inPath:"tests/to-atomic-level-dna-fasta-input.csv",outPath:"tests/to-atomic-level-dna-fasta-output.csv"},"msa-separator":{inPath:"tests/to-atomic-level-msa-separator-input.csv",outPath:"tests/to-atomic-level-msa-separator-output.csv"},"msa-fasta":{inPath:"tests/to-atomic-level-msa-fasta-input.csv",outPath:"tests/to-atomic-level-msa-fasta-output.csv"}},ue="molfile(sequence)";function he(e){return e.replaceAll("\r\n","\n").replace(/\n$/,"").split("\n").map((e=>e.trimEnd())).join("\n")}(0,t.L1)("toAtomicLevel",(async()=>{const n={},i={};let o,s,r,u,h,d;async function p(e,n){const i=e.getCol("sequence");await a.functions.call("Bio:toAtomicLevel",{table:e,seqCol:i,nonlinear:!1});const o=e.getCol(ue),s=n.getCol(ue),r=v()(o.values()).map((e=>he(e))).toArray(),l=v()(s.values()).map((e=>he(e))).toArray();(0,t.J6)(r,l)}(0,t.gM)((async()=>{h=await(0,ae.j)(),r=await(0,c.Q)(),o=await(0,C.pj)(),s=await(0,x.ub)(),await o.loadMonomerLibForTests(),u=o.getMonomerLib();for(const[t,o]of Object.entries(ce))o.inPath,n[t]=e.DataFrame.fromCsv((await le.readAsText(o.inPath)).replace(/\n$/,"")),n[t].name=o.inPath.split("/").pop(),await a.data.detectSemanticTypes(n[t]),i[t]=e.DataFrame.fromCsv((await le.readAsText(o.outPath)).replace(/\n$/,""))})),(0,t.Pl)((async()=>{await(0,x.Eu)(s),await o.loadMonomerLib(!0)}));for(const[e,o]of Object.entries(ce))(0,t.t6)(`${e}`,(async()=>{await p(n[e],i[e])}));!function(e){e.fastaDna="fastaDna",e.fastaRna="fastaRna",e.fastaPt="fastaPt",e.fastaUn="fastaUn",e.separatorDna="separatorDna",e.separatorRna="separatorRna",e.separatorPt="separatorPt",e.separatorUn="separatorUn",e.helm="helm"}(d||(d={}));const m={[d.fastaDna]:"seq\nACGTCACGTC\nCAGTGTCAGTGT\nTTCAACTTCAAC",[d.fastaRna]:"seq\nACGUCACGUC\nCAGUGUCAGUGU\nUUCAACUUCAAC",[d.fastaPt]:"seq\nFWPHEYFWPHEY\nYNRQWYVYNRQWYV\nMKPSEYVMKPSEYV",[d.fastaUn]:"seq\n[meI][hHis][Aca]NT[dE][Thr_PO3H2][Aca]D[meI][hHis][Aca]NT[dE][Thr_PO3H2][Aca]D\n[meI][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2][meI][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2]\n[Lys_Boc][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2][Lys_Boc][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2]",[d.separatorDna]:"seq\nA/C/G/T/C/A/C/G/T/C\nC/A/G/T/G/T/C/A/G/T/G/T\nT/T/C/A/A/C/T/T/C/A/A/C",[d.separatorRna]:"seq\nA*C*G*U*C*A*C*G*U*C\nC*A*G*U*G*U*C*A*G*U*G*U\nU*U*C*A*A*C*U*U*C*A*A*C",[d.separatorPt]:"seq\nF-W-P-H-E-Y-F-W-P-H-E-Y\nY-N-R-Q-W-Y-V-Y-N-R-Q-W-Y-V\nM-K-P-S-E-Y-V-M-K-P-S-E-Y-V",[d.separatorUn]:"seq\nmeI-hHis-Aca-N-T-dE-Thr_PO3H2-Aca-D-meI-hHis-Aca-N-T-dE-Thr_PO3H2-Aca-D\nmeI-hHis-Aca-Cys_SEt-T-dK-Thr_PO3H2-Aca-Tyr_PO3H2-meI-hHis-Aca-Cys_SEt-T-dK-Thr_PO3H2-Aca-Tyr_PO3H2\nLys_Boc-hHis-Aca-Cys_SEt-T-dK-Thr_PO3H2-Aca-Tyr_PO3H2-Lys_Boc-hHis-Aca-Cys_SEt-T-dK-Thr_PO3H2-Aca-Tyr_PO3H2",[d.helm]:"seq\nPEPTIDE1{meI.D-gGlu.Aca.N.T.dE.Thr_PO3H2.Aca.D.Thr_PO3H2.Aca.D}$$$\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2.Thr_PO3H2.Aca.Tyr_PO3H2}$$$\nPEPTIDE1{Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2.Thr_PO3H2.Aca.Tyr_PO3H2}$$$"};async function g(t){const n=m[t],i=e.DataFrame.fromCsv(n.replace(/\n$/,""));return await a.data.detectSemanticTypes(i),i}async function f(e,t="seq",n){const i=e.getCol(t),o=await(0,re.C4)(e,i,u,r,h);return o.warnings.length>0&&Ce.logger.warning(`_toAtomicLevel() warnings ${o.warnings.join("\n")}`),o.molCol}(0,t.t6)("fastaDna",(async()=>{await f(await g(d.fastaDna),"seq")})),(0,t.t6)("fastaRna",(async()=>{await f(await g(d.fastaRna),"seq")})),(0,t.t6)("fastaPt",(async()=>{await f(await g(d.fastaPt),"seq")})),(0,t.t6)("fastaUn",(async()=>{await f(await g(d.fastaUn),"seq")})),(0,t.t6)("separatorDna",(async()=>{await f(await g(d.separatorDna),"seq")})),(0,t.t6)("separatorDna",(async()=>{await f(await g(d.separatorRna),"seq")})),(0,t.t6)("separatorPt",(async()=>{await f(await g(d.separatorPt),"seq")})),(0,t.t6)("separatorUn",(async()=>{await f(await g(d.separatorUn),"seq")})),(0,t.t6)("helm",(async()=>{await f(await g(d.helm),"seq")})),(0,t.t6)("ptFasta2",(async()=>{const n=await Ce.files.readAsText("tests/to-atomic-level-pt-fasta-2.mol"),i=e.DataFrame.fromCsv("seq\nAR"),o=i.getCol("seq");o.semType=e.SEMTYPE.MACROMOLECULE,o.meta.units=l.Hi.FASTA,o.setTag(l.gp.alphabet,l.YI.PT),r.getSeqHandler(o);const s=await f(i,"seq");(0,t.E3)(he(s.get(0)),he(n))}))}));var de=n(8754);(0,t.L1)("toAtomicLevel-ui",(()=>{let n,i,o,s,r;(0,t.gM)((async()=>{o=await(0,c.Q)(),r=await(0,ae.j)(),n=await(0,C.pj)(),i=await(0,x.ub)(),await n.loadMonomerLibForTests(),s=n.getMonomerLib()})),(0,t.Pl)((async()=>{await(0,x.Eu)(i),await n.loadMonomerLib(!0)}));const u={fasta:{src:{seq:"MDYKETLLMPK",units:l.Hi.FASTA},tgt:{atomCount:94,bondCount:95}},"fasta-with-gap":{src:{seq:"MD-YKETLLMPK",units:l.Hi.FASTA},tgt:{atomCount:94,bondCount:95}},helm:{src:{seq:"PEPTIDE1{meI.hHis.Aca.N.T.dK.Thr_PO3H2}$$$$",units:l.Hi.HELM},tgt:{atomCount:68,bondCount:68}},"helm-with-gap":{src:{seq:"PEPTIDE1{meI.hHis.*.Aca.N.T.dK.Thr_PO3H2}$$$$",units:l.Hi.HELM},tgt:{atomCount:68,bondCount:68}}},h=async t=>{const n=t.src.seq,i=e.DataFrame.fromColumns([e.Column.fromList(e.COLUMN_TYPE.STRING,"seq",[n])]);return await a.data.detectSemanticTypes(i),i.getCol("seq")};for(const[e,n]of Object.entries(u))(0,t.t6)(`${e}-linear`,(async()=>{const e=await h(n);await d(e,!1,n.tgt)}));if(e.Func.find({package:"Helm",name:"getHelmHelper"}).length)for(const[e,n]of Object.entries(u))(0,t.t6)(`${e}-nonlinear`,(async()=>{const e=await h(n);await d(e,!0,n.tgt)}));async function d(n,i,a){const l=await(0,de.V)(n.dataFrame,n,i,!1,s,o,r);(0,t.E3)(l.molCol.semType,e.SEMTYPE.MOLECULE);const c=l.molCol.get(0),u=r.get_mol(c);(0,t.E3)(null!=u,!0,"No molecule generated");try{const e=u.get_num_atoms(),n=u.get_num_bonds();(0,t.E3)(e,a.atomCount),(0,t.E3)(n,a.bondCount)}finally{u.delete()}}}));var pe=n(6863);async function me(t,n){const i=e.DataFrame.fromCsv(t),o=i.col("seq"),s=await a.functions.call("Bio:detectMacromolecule",{col:o});return s&&(o.semType=s),await a.data.detectSemanticTypes(i),n.getSeqHandler(o)}function ge(e,n,i,o){const s=i(e,n);(0,t.E3)(Number(s.toFixed(3)),Number(o.toFixed(3)))}(0,t.L1)("Distance",(async()=>{let n;(0,t.gM)((async()=>{n=await(0,c.Q)()}));const i=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],o={F:0,W:1,R:2,Y:3},s="FWRWY",r="FWRWW",a="FWY",l="FWRWY",u="FWY",h="FWRRRRY";(0,t.t6)("protein-distance-function",(async()=>{const e=(await me("seq\nFWRWYVKHPFWRWYVKHP\nYNRWYVKHPYNRWYVKHP\nMWRSWYCKHPMWRSWYCKHP",n)).getDistanceFunctionName();(0,t.E3)(e,pe.Z.LEVENSHTEIN)})),(0,t.t6)("DNA-distance-function",(async()=>{const e=(await me("seq\nATAACGATAACG\nATCGAATCGA\nATCGAATCGA",n)).getDistanceFunctionName();(0,t.E3)(e,pe.Z.LEVENSHTEIN)})),(0,t.t6)("MSA-distance-function",(async()=>{const e=(await me("seq\nATAACATAAC\nATCGAATCGA\nATCGAATCGA",n)).getDistanceFunctionName();(0,t.E3)(e,pe.Z.HAMMING)})),(0,t.t6)("levenstein-sub",(async()=>{const e=pe.V[pe.Z.LEVENSHTEIN]();ge(s,r,e,.2)})),(0,t.t6)("levenstein-del",(async()=>{const e=pe.V[pe.Z.LEVENSHTEIN]();ge(a,l,e,.4)})),(0,t.t6)("hamming",(async()=>{const e=pe.V[pe.Z.HAMMING]();ge(a,l,e,.6)})),(0,t.t6)("needleman-blosum62",(async()=>{const e=pe.V[pe.Z.NEEDLEMANN_WUNSCH]({gapOpen:8,gapExtend:2});ge(s,r,e,-6)})),(0,t.t6)("needleman-blosum62-del",(async()=>{const e=pe.V[pe.Z.NEEDLEMANN_WUNSCH]({gapOpen:8,gapExtend:2});ge(a,l,e,-3.667)})),(0,t.t6)("needleman-custom-sub",(async()=>{const e=pe.V[pe.Z.NEEDLEMANN_WUNSCH]({scoringMatrix:i,alphabetIndexes:o,gapOpen:1,gapExtend:1});ge(s,r,e,.2)})),(0,t.t6)("needleman-custom-del",(async()=>{const e=pe.V[pe.Z.NEEDLEMANN_WUNSCH]({scoringMatrix:i,alphabetIndexes:o,gapOpen:1,gapExtend:1});ge(a,l,e,.667)})),(0,t.t6)("needleman-custom-zero-extend",(async()=>{const e=pe.V[pe.Z.NEEDLEMANN_WUNSCH]({scoringMatrix:i,alphabetIndexes:o,gapOpen:1,gapExtend:0});ge(u,h,e,.333)})),(0,t.t6)("needleman-custom-half-extend",(async()=>{const e=pe.V[pe.Z.NEEDLEMANN_WUNSCH]({scoringMatrix:i,alphabetIndexes:o,gapOpen:2,gapExtend:1});ge(u,h,e,1.667)})),(0,t.t6)("needleman-custom-same-extend",(async()=>{const t=pe.V[pe.Z.NEEDLEMANN_WUNSCH]({scoringMatrix:i,alphabetIndexes:o,gapOpen:1,gapExtend:1});e.Test.isInBenchmark?ge(Array(1e3).fill(u).join(""),Array(1e3).fill(h).join(""),t,1.333):ge(u,h,t,1.333)}),{benchmark:!0})}));var fe=n(684);async function ye(n,i,o,s,r,l,c,u){await a.data.detectSemanticTypes(n),await a.functions.call("Bio:activityCliffs",{table:n,molecules:n.getCol(o),activities:n.getCol(s),similarity:r,methodName:i,similarityMetric:c,preprocessingFunction:u,options:{[`${fe.vb}`]:!0},demo:!1});const h=Array.from(a.shell.tv.viewers)[1];(0,t.E3)(h?.type===e.VIEWER.SCATTER_PLOT,!0),await(0,t.bk)((()=>{const e=Array.from(h.root.getElementsByClassName("scatter_plot_link"));return!e.length||e[0].innerText.toLowerCase()===`${l} cliffs`}),"incorrect cliffs link",3e3)}var be=n(2780),we=n(9039),ve=n(9124);async function Ae(n,i,o){const s=n.getCol(o);n.name="seqSpaceDf";const r=await a.functions.call("Bio:detectMacromolecule",{col:s});r&&(s.semType=r);const l=e.Func.find({package:"Bio",name:"macromoleculePreprocessingFunction"})[0];if(!l)throw new Error("Preprocessing function not found");await a.functions.call("Bio:sequenceSpaceTopMenu",{table:n,molecules:n.col(o),methodName:i,similarityMetric:pe.Z.LEVENSHTEIN,plotEmbeddings:!0,preprocessingFunction:l,options:{[fe.vb]:!0}});const c=a.shell.tableView(n.name),u=Array.from(c?.viewers??[])[1];(0,t.E3)(null!=u)}(0,t.L1)("activityCliffs",(async()=>{let n,i,o;const s=e.Func.find({name:"macromoleculePreprocessingFunction",package:"Bio"})[0],r=e.Func.find({name:"helmPreprocessingFunction",package:"Bio"})[0];(0,t.gM)((async()=>{e.Func.find({package:"Helm",name:"getHelmHelper"}).length&&(n=await(0,ve.b2)()),i=await(0,C.pj)(),o=await(0,x.ub)(),await i.loadMonomerLibForTests()})),(0,t.Pl)((async()=>{await(0,x.Eu)(o),await i.loadMonomerLib(!0)})),(0,t.t6)("activityCliffsOpens",(async()=>{const t=e.Test.isInBenchmark?{fileName:"tests/peptides_with_random_motif_1600.csv",tgt:{cliffCount:64}}:{fileName:"tests/100_3_clustests.csv",tgt:{cliffCount:3}},n=await S(t.fileName);a.shell.addTableView(n),await ye(n,we.c.UMAP,"sequence","Activity",90,t.tgt.cliffCount,pe.Z.LEVENSHTEIN,s)}),{benchmark:!0,skipReason:"Fails"}),(0,t.t6)("activityCliffsWithEmptyRows",(async()=>{const e=await S("tests/100_3_clustests_empty_vals.csv");a.shell.addTableView(e),await ye(e,we.c.UMAP,"sequence","Activity",90,3,pe.Z.LEVENSHTEIN,s)})),(0,t.t6)("Helm",(async()=>{if(e.Func.find({package:"Helm",name:"getHelmHelper"}).length){const e=await Ce.files.readCsv("samples/HELM_50.csv");a.shell.addTableView(e),await ye(e,we.c.UMAP,"HELM","Activity",65,20,be.aT.Tanimoto,r)}}))})),(0,t.L1)("sequenceSpace",(async()=>{let n,i,o,s;(0,t.t6)("sequenceSpaceOpens",(async()=>{const t=e.Test.isInBenchmark?{fileName:"tests/peptides_with_random_motif_1600.csv"}:{fileName:"tests/100_3_clustests.csv"};n=await S(t.fileName),i=a.shell.addTableView(n),await Ae(n,we.c.UMAP,"sequence")}),{benchmark:!0}),(0,t.t6)("sequenceSpaceWithEmptyRows",(async()=>{o=await S("tests/100_3_clustests_empty_vals.csv"),s=a.shell.addTableView(o),await Ae(o,we.c.UMAP,"sequence")}))})),(0,t.L1)("Scoring",(()=>{const n="sequence",i="expected_similarity",o="expected_identity",s=e.DataFrame.fromCsv(`${n},${i},${o}\nPEPTIDE1{Aca.Orn.gGlu.Pqa.D-His_1Bn.dH.hHis.4Abz.D-Tic.D-Dap.Y.Iva.meS.F.P.F.D-1Nal}$$$$,1.0,1.0\nPEPTIDE1{Iva.Gly_allyl.gGlu.Pqa.D-Dip.dH.hHis.4Abz.D-aHyp.D-Dap.Y.Iva.I.Tyr_26diMe.P.Asu.meC}$$$$,0.691,0.53\nPEPTIDE1{[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal]}$$$$V2.0,0.37,0.0`),r=s.getCol(n);r.meta.units=l.Hi.HELM,r.semType=e.SEMTYPE.MACROMOLECULE;const c=r.get(0);let u,h;(0,t.gM)((async()=>{u=await(0,C.pj)(),h=await(0,x.ub)(),await u.loadMonomerLibForTests()})),(0,t.Pl)((async()=>{await(0,x.Eu)(h),await u.loadMonomerLib(!0)})),(0,t.t6)("Identity",(async()=>{const e=await a.functions.call("Bio:sequenceIdentityScoring",{table:s,macromolecule:r,reference:c});for(let n=0;n<e.length;n++){const i=e.get(n),r=s.get(o,n);(0,t.Wj)(i,r,.01,`Wrong identity score for sequence at position ${n}`)}})),(0,t.t6)("Identity-shortReference",(async()=>{const e=await a.functions.call("Bio:sequenceIdentityScoring",{table:s,macromolecule:r,reference:"PEPTIDE1{Iva.Gly_allyl.gGlu.Pqa.D-Dip.dH.hHis.4Abz.D-aHyp.D-Dap.Y.Iva}$$$$"});(0,t.E3)(v().count(0).take(e.length).map((t=>e.get(t))).every((e=>null!=e&&!isNaN(e))),!0)})),(0,t.t6)("Identity-longReference",(async()=>{const e=await a.functions.call("Bio:sequenceIdentityScoring",{table:s,macromolecule:r,reference:"PEPTIDE1{Iva.Gly_allyl.gGlu.Pqa.D-Dip.dH.hHis.4Abz.D-aHyp.D-Dap.Y.Iva.I.Tyr_26diMe.P.Asu.meC.I.Tyr_26diMe.P.Asu.meC}$$$$"});(0,t.E3)(v().count(0).take(e.length).map((t=>e.get(t))).every((e=>null!=e&&!isNaN(e))),!0)})),(0,t.t6)("Similarity",(async()=>{const e=await a.functions.call("Bio:sequenceSimilarityScoring",{table:s,macromolecule:r,reference:c});for(let n=0;n<e.length;n++){const o=e.get(n),r=s.get(i,n);(0,t.Wj)(o,r,.01,`Wrong similarity score for sequence at position ${n}`)}}))}));const Ce=new e.Package;async function Te(n,i,o,s){const r=await(0,t.N$)({category:n,test:i,testContext:o,stressTest:s});return e.DataFrame.fromObjects(r)}async function Se(){await(0,t.Xb)(Ce,Ce.getModule("package-test.js"))}})(),bio_test=i})();
8
8
  //# sourceMappingURL=package-test.js.map