@datagrok/bio 2.22.3 → 2.22.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/455.js +1 -1
- package/dist/455.js.map +1 -1
- package/dist/package-test.js +2 -2
- package/dist/package-test.js.map +1 -1
- package/dist/package.js +3 -3
- package/dist/package.js.map +1 -1
- package/package.json +7 -7
- package/src/package-api.ts +1 -1
- package/src/package.ts +10 -4
- package/src/tests/activity-cliffs-utils.ts +3 -2
- package/src/utils/monomer-cell-renderer.ts +52 -27
- package/src/widgets/sequence-scrolling-widget.ts +6 -5
- package/test-console-output-1.log +398 -388
- package/test-record-1.mp4 +0 -0
package/dist/package.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var bio;(()=>{var t={8924:(t,e,n)=>{"use strict";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(t){const e=t in o.aaSynonyms?o.aaSynonyms[t]:t;return super.get(e)}}o.aaSynonyms={MeNle:"L",MeA:"A",MeG:"G",MeF:"F"};class r{static getPalette(t="grok"){switch(t){case"grok":return o.GrokGroups;case"lesk":return o.Lesk;default:throw new Error(`ChemPalette: scheme \`${t}\` does not exist`)}}static getInnerOuter(t){let e=0,n="",i="";for(const o of t)"("==o?e++:")"==o?e--:e?n+=o:i+=o;return isNaN(parseInt(n))?[i,n]:[i,""]}static getColorAAPivot(t="",e="grok"){const n=this.getPalette(e);let[i,o]=this.getInnerOuter(t);if(i=i.length>6?`${i.slice(0,3)}...`:i,o=o.length>6?`${o.slice(0,3)}...`:o,1==t.length||"("==t[1]){const e=t[0]?.toUpperCase();return e in n?[n.get(e),e,o,1]:[this.undefinedColor,i,o,1]}if("d"==t[0]&&t[1]in n&&(2==t.length||"("==t[2])){const e=t[1]?.toUpperCase();return e in n?[n.get(e),e,o,2]:[this.undefinedColor,i,o,2]}if(t.substring(0,3)in this.AAFullNames&&(3==t.length||"("==t[3])){const e=this.AAFullNames[t.substring(0,3)];return e in n?[n.get(e),e,o,3]:[this.undefinedColor,i,o,3]}if(t[0]?.toLowerCase()==t[0]&&t.substring(1,3)in this.AAFullNames&&(4==t.length||"("==t[4])){const e=this.AAFullNames[t.substring(1,3)];return e in n?[n.get(e),e,o,4]:[this.undefinedColor,i,o,4]}return[this.undefinedColor,i,o,0]}}r.SemType="Aminoacids",r.SemTypeMultipleAlignment="AminoacidsMultipleAlignment",r.undefinedColor="rgb(100,100,100)",r.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"},r.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"},r.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(*)*"},r.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:(t,e,n)=>{"use strict";n.d(e,{j:()=>o});var i=n(6082);async function o(){const t=i.Func.find({package:"Chem",name:"getRdKitModule"});if(0===t.length)throw new Error('Package "Chem" must be installed for getRdKitModule.');return(await t[0].prepare().call()).getOutputParamValue()}},3599:(t,e,n)=>{"use strict";n.d(e,{o:()=>i.o});var i=n(6869)},9124:(t,e,n)=>{"use strict";n.d(e,{b2:()=>r,fA:()=>s});var i=n(7389),o=n(6082);async function r(){const t="Helm",e=o.Func.find({package:t,name:"getHelmHelper"});if(0===e.length)throw new Error(`Package '${t}' must be installed for HelmHelper.`);return(await e[0].prepare().call()).getOutputParamValue()}function s(t,e){if(!t)throw new Error("Argument 'a' of type Atom or HelmType is mandatory.");let n,i;const o=t;return"ATOM"===o.T?(n=o.biotype(),i=o.elem):(n=t,i=e),[n,i]}o.JsInputBase,Error,i.input.helmAsync=async function(t,e){return(await r()).createHelmInput(t,e)}},8438:(t,e,n)=>{"use strict";function i(t){return t.startsWith("[")&&t.endsWith("]")?t.slice(1,-1):t}n.d(e,{D:()=>i})},8123:(t,e,n)=>{"use strict";n.d(e,{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:(t,e,n)=>{"use strict";n.d(e,{Eu:()=>a,ub:()=>s});var i=n(4328);const o="Libraries";let r=Promise.resolve();async function s(){let t;return r=r.then((async()=>{const e=i.userSettings.getValue(o,"Settings",!0);t=e?JSON.parse(e):{exclude:[],explicit:[],duplicateMonomerPreferences:{}},t.exclude=t.exclude instanceof Array?t.exclude:[],t.explicit=t.explicit instanceof Array?t.explicit:[],t.duplicateMonomerPreferences=t.duplicateMonomerPreferences instanceof Object?t.duplicateMonomerPreferences:{},console.debug(`Bio: getUserLibSettings()\n${JSON.stringify(t,void 0,2)}`)})),await r,t}async function a(t){r=r.then((async()=>{console.debug(`Bio: setUserLibSettings()\n${JSON.stringify(t,void 0,2)}`),i.userSettings.add(o,"Settings",JSON.stringify(t),!0)})),await r}},5553:(t,e,n)=>{"use strict";n.d(e,{Qc:()=>A,WN:()=>S});var i=n(1991),o=n.n(i);const r="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,s=new Set,a="object"==typeof process&&process?process:{},l=(t,e,n,i)=>{"function"==typeof a.emitWarning?a.emitWarning(t,e,n,i):console.error(`[${n}] ${e}: ${t}`)};let c=globalThis.AbortController,h=globalThis.AbortSignal;if(void 0===c){h=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(t,e){this._onabort.push(e)}},c=class{constructor(){e()}signal=new h;abort(t){if(!this.signal.aborted){this.signal.reason=t,this.signal.aborted=!0;for(const e of this.signal._onabort)e(t);this.signal.onabort?.(t)}}};let t="1"!==a.env?.LRU_CACHE_IGNORE_AC_WARNING;const e=()=>{t&&(t=!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",e))}}Symbol("type");const u=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),d=t=>u(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?p:null:null;class p extends Array{constructor(t){super(t),this.fill(0)}}class m{heap;length;static#t=!1;static create(t){const e=d(t);if(!e)return[];m.#t=!0;const n=new m(t,e);return m.#t=!1,n}constructor(t,e){if(!m.#t)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}}class f{#e;#n;#i;#o;#r;#s;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#a;#l;#c;#h;#u;#d;#p;#m;#f;#g;#y;#b;#v;#w;#C;#A;#S;static unsafeExposeInternals(t){return{starts:t.#v,ttls:t.#w,sizes:t.#b,keyMap:t.#c,keyList:t.#h,valList:t.#u,next:t.#d,prev:t.#p,get head(){return t.#m},get tail(){return t.#f},free:t.#g,isBackgroundFetch:e=>t.#x(e),backgroundFetch:(e,n,i,o)=>t.#E(e,n,i,o),moveToTail:e=>t.#M(e),indexes:e=>t.#T(e),rindexes:e=>t.#_(e),isStale:e=>t.#I(e)}}get max(){return this.#e}get maxSize(){return this.#n}get calculatedSize(){return this.#l}get size(){return this.#a}get fetchMethod(){return this.#r}get memoMethod(){return this.#s}get dispose(){return this.#i}get disposeAfter(){return this.#o}constructor(t){const{max:e=0,ttl:n,ttlResolution:i=1,ttlAutopurge:o,updateAgeOnGet:r,updateAgeOnHas:a,allowStale:c,dispose:h,disposeAfter:p,noDisposeOnSet:g,noUpdateTTL:y,maxSize:b=0,maxEntrySize:v=0,sizeCalculation:w,fetchMethod:C,memoMethod:A,noDeleteOnFetchRejection:S,noDeleteOnStaleGet:x,allowStaleOnFetchRejection:E,allowStaleOnFetchAbort:M,ignoreFetchAbort:T}=t;if(0!==e&&!u(e))throw new TypeError("max option must be a nonnegative integer");const _=e?d(e):Array;if(!_)throw new Error("invalid max value: "+e);if(this.#e=e,this.#n=b,this.maxEntrySize=v||this.#n,this.sizeCalculation=w,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!==A&&"function"!=typeof A)throw new TypeError("memoMethod must be a function if defined");if(this.#s=A,void 0!==C&&"function"!=typeof C)throw new TypeError("fetchMethod must be a function if specified");if(this.#r=C,this.#A=!!C,this.#c=new Map,this.#h=new Array(e).fill(void 0),this.#u=new Array(e).fill(void 0),this.#d=new _(e),this.#p=new _(e),this.#m=0,this.#f=0,this.#g=m.create(e),this.#a=0,this.#l=0,"function"==typeof h&&(this.#i=h),"function"==typeof p?(this.#o=p,this.#y=[]):(this.#o=void 0,this.#y=void 0),this.#C=!!this.#i,this.#S=!!this.#o,this.noDisposeOnSet=!!g,this.noUpdateTTL=!!y,this.noDeleteOnFetchRejection=!!S,this.allowStaleOnFetchRejection=!!E,this.allowStaleOnFetchAbort=!!M,this.ignoreFetchAbort=!!T,0!==this.maxEntrySize){if(0!==this.#n&&!u(this.#n))throw new TypeError("maxSize must be a positive integer if specified");if(!u(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#L()}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!x,this.updateAgeOnGet=!!r,this.updateAgeOnHas=!!a,this.ttlResolution=u(i)||0===i?i:1,this.ttlAutopurge=!!o,this.ttl=n||0,this.ttl){if(!u(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#N()}if(0===this.#e&&0===this.ttl&&0===this.#n)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#n){const t="LRU_CACHE_UNBOUNDED";(t=>!s.has(t))(t)&&(s.add(t),l("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",t,f))}}getRemainingTTL(t){return this.#c.has(t)?1/0:0}#N(){const t=new p(this.#e),e=new p(this.#e);this.#w=t,this.#v=e,this.#P=(n,i,o=r.now())=>{if(e[n]=0!==i?o:0,t[n]=i,0!==i&&this.ttlAutopurge){const t=setTimeout((()=>{this.#I(n)&&this.#$(this.#h[n],"expire")}),i+1);t.unref&&t.unref()}},this.#R=n=>{e[n]=0!==t[n]?r.now():0},this.#k=(o,r)=>{if(t[r]){const s=t[r],a=e[r];if(!s||!a)return;o.ttl=s,o.start=a,o.now=n||i();const l=o.now-a;o.remainingTTL=s-l}};let n=0;const i=()=>{const t=r.now();if(this.ttlResolution>0){n=t;const e=setTimeout((()=>n=0),this.ttlResolution);e.unref&&e.unref()}return t};this.getRemainingTTL=o=>{const r=this.#c.get(o);if(void 0===r)return 0;const s=t[r],a=e[r];return s&&a?s-((n||i())-a):1/0},this.#I=o=>{const r=e[o],s=t[o];return!!s&&!!r&&(n||i())-r>s}}#R=()=>{};#k=()=>{};#P=()=>{};#I=()=>!1;#L(){const t=new p(this.#e);this.#l=0,this.#b=t,this.#O=e=>{this.#l-=t[e],t[e]=0},this.#H=(t,e,n,i)=>{if(this.#x(e))return 0;if(!u(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(e,t),!u(n))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return n},this.#G=(e,n,i)=>{if(t[e]=n,this.#n){const n=this.#n-t[e];for(;this.#l>n;)this.#F(!0)}this.#l+=t[e],i&&(i.entrySize=n,i.totalCalculatedSize=this.#l)}}#O=t=>{};#G=(t,e,n)=>{};#H=(t,e,n,i)=>{if(n||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#T({allowStale:t=this.allowStale}={}){if(this.#a)for(let e=this.#f;this.#B(e)&&(!t&&this.#I(e)||(yield e),e!==this.#m);)e=this.#p[e]}*#_({allowStale:t=this.allowStale}={}){if(this.#a)for(let e=this.#m;this.#B(e)&&(!t&&this.#I(e)||(yield e),e!==this.#f);)e=this.#d[e]}#B(t){return void 0!==t&&this.#c.get(this.#h[t])===t}*entries(){for(const t of this.#T())void 0===this.#u[t]||void 0===this.#h[t]||this.#x(this.#u[t])||(yield[this.#h[t],this.#u[t]])}*rentries(){for(const t of this.#_())void 0===this.#u[t]||void 0===this.#h[t]||this.#x(this.#u[t])||(yield[this.#h[t],this.#u[t]])}*keys(){for(const t of this.#T()){const e=this.#h[t];void 0===e||this.#x(this.#u[t])||(yield e)}}*rkeys(){for(const t of this.#_()){const e=this.#h[t];void 0===e||this.#x(this.#u[t])||(yield e)}}*values(){for(const t of this.#T())void 0===this.#u[t]||this.#x(this.#u[t])||(yield this.#u[t])}*rvalues(){for(const t of this.#_())void 0===this.#u[t]||this.#x(this.#u[t])||(yield this.#u[t])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,e={}){for(const n of this.#T()){const i=this.#u[n],o=this.#x(i)?i.__staleWhileFetching:i;if(void 0!==o&&t(o,this.#h[n],this))return this.get(this.#h[n],e)}}forEach(t,e=this){for(const n of this.#T()){const i=this.#u[n],o=this.#x(i)?i.__staleWhileFetching:i;void 0!==o&&t.call(e,o,this.#h[n],this)}}rforEach(t,e=this){for(const n of this.#_()){const i=this.#u[n],o=this.#x(i)?i.__staleWhileFetching:i;void 0!==o&&t.call(e,o,this.#h[n],this)}}purgeStale(){let t=!1;for(const e of this.#_({allowStale:!0}))this.#I(e)&&(this.#$(this.#h[e],"expire"),t=!0);return t}info(t){const e=this.#c.get(t);if(void 0===e)return;const n=this.#u[e],i=this.#x(n)?n.__staleWhileFetching:n;if(void 0===i)return;const o={value:i};if(this.#w&&this.#v){const t=this.#w[e],n=this.#v[e];if(t&&n){const e=t-(r.now()-n);o.ttl=e,o.start=Date.now()}}return this.#b&&(o.size=this.#b[e]),o}dump(){const t=[];for(const e of this.#T({allowStale:!0})){const n=this.#h[e],i=this.#u[e],o=this.#x(i)?i.__staleWhileFetching:i;if(void 0===o||void 0===n)continue;const s={value:o};if(this.#w&&this.#v){s.ttl=this.#w[e];const t=r.now()-this.#v[e];s.start=Math.floor(Date.now()-t)}this.#b&&(s.size=this.#b[e]),t.unshift([n,s])}return t}load(t){this.clear();for(const[e,n]of t){if(n.start){const t=Date.now()-n.start;n.start=r.now()-t}this.set(e,n.value,n)}}set(t,e,n={}){if(void 0===e)return this.delete(t),this;const{ttl:i=this.ttl,start:o,noDisposeOnSet:r=this.noDisposeOnSet,sizeCalculation:s=this.sizeCalculation,status:a}=n;let{noUpdateTTL:l=this.noUpdateTTL}=n;const c=this.#H(t,e,n.size||0,s);if(this.maxEntrySize&&c>this.maxEntrySize)return a&&(a.set="miss",a.maxEntrySizeExceeded=!0),this.#$(t,"set"),this;let h=0===this.#a?void 0:this.#c.get(t);if(void 0===h)h=0===this.#a?this.#f:0!==this.#g.length?this.#g.pop():this.#a===this.#e?this.#F(!1):this.#a,this.#h[h]=t,this.#u[h]=e,this.#c.set(t,h),this.#d[this.#f]=h,this.#p[h]=this.#f,this.#f=h,this.#a++,this.#G(h,c,a),a&&(a.set="add"),l=!1;else{this.#M(h);const n=this.#u[h];if(e!==n){if(this.#A&&this.#x(n)){n.__abortController.abort(new Error("replaced"));const{__staleWhileFetching:e}=n;void 0===e||r||(this.#C&&this.#i?.(e,t,"set"),this.#S&&this.#y?.push([e,t,"set"]))}else r||(this.#C&&this.#i?.(n,t,"set"),this.#S&&this.#y?.push([n,t,"set"]));if(this.#O(h),this.#G(h,c,a),this.#u[h]=e,a){a.set="replace";const t=n&&this.#x(n)?n.__staleWhileFetching:n;void 0!==t&&(a.oldValue=t)}}else a&&(a.set="update")}if(0===i||this.#w||this.#N(),this.#w&&(l||this.#P(h,i,o),a&&this.#k(a,h)),!r&&this.#S&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#o?.(...e)}return this}pop(){try{for(;this.#a;){const t=this.#u[this.#m];if(this.#F(!0),this.#x(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(void 0!==t)return t}}finally{if(this.#S&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#o?.(...e)}}}#F(t){const e=this.#m,n=this.#h[e],i=this.#u[e];return this.#A&&this.#x(i)?i.__abortController.abort(new Error("evicted")):(this.#C||this.#S)&&(this.#C&&this.#i?.(i,n,"evict"),this.#S&&this.#y?.push([i,n,"evict"])),this.#O(e),t&&(this.#h[e]=void 0,this.#u[e]=void 0,this.#g.push(e)),1===this.#a?(this.#m=this.#f=0,this.#g.length=0):this.#m=this.#d[e],this.#c.delete(n),this.#a--,e}has(t,e={}){const{updateAgeOnHas:n=this.updateAgeOnHas,status:i}=e,o=this.#c.get(t);if(void 0!==o){const t=this.#u[o];if(this.#x(t)&&void 0===t.__staleWhileFetching)return!1;if(!this.#I(o))return n&&this.#R(o),i&&(i.has="hit",this.#k(i,o)),!0;i&&(i.has="stale",this.#k(i,o))}else i&&(i.has="miss");return!1}peek(t,e={}){const{allowStale:n=this.allowStale}=e,i=this.#c.get(t);if(void 0===i||!n&&this.#I(i))return;const o=this.#u[i];return this.#x(o)?o.__staleWhileFetching:o}#E(t,e,n,i){const o=void 0===e?void 0:this.#u[e];if(this.#x(o))return o;const r=new c,{signal:s}=n;s?.addEventListener("abort",(()=>r.abort(s.reason)),{signal:r.signal});const a={signal:r.signal,options:n,context:i},l=(i,o=!1)=>{const{aborted:s}=r.signal,l=n.ignoreFetchAbort&&void 0!==i;if(n.status&&(s&&!o?(n.status.fetchAborted=!0,n.status.fetchError=r.signal.reason,l&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),s&&!l&&!o)return h(r.signal.reason);const c=u;return this.#u[e]===u&&(void 0===i?c.__staleWhileFetching?this.#u[e]=c.__staleWhileFetching:this.#$(t,"fetch"):(n.status&&(n.status.fetchUpdated=!0),this.set(t,i,a.options))),i},h=i=>{const{aborted:o}=r.signal,s=o&&n.allowStaleOnFetchAbort,a=s||n.allowStaleOnFetchRejection,l=a||n.noDeleteOnFetchRejection,c=u;if(this.#u[e]===u&&(l&&void 0!==c.__staleWhileFetching?s||(this.#u[e]=c.__staleWhileFetching):this.#$(t,"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 u=new Promise(((e,i)=>{const s=this.#r?.(t,o,a);s&&s instanceof Promise&&s.then((t=>e(void 0===t?void 0:t)),i),r.signal.addEventListener("abort",(()=>{n.ignoreFetchAbort&&!n.allowStaleOnFetchAbort||(e(void 0),n.allowStaleOnFetchAbort&&(e=t=>l(t,!0)))}))})).then(l,(t=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=t),h(t)))),d=Object.assign(u,{__abortController:r,__staleWhileFetching:o,__returned:void 0});return void 0===e?(this.set(t,d,{...a.options,status:void 0}),e=this.#c.get(t)):this.#u[e]=d,d}#x(t){if(!this.#A)return!1;const e=t;return!!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof c}async fetch(t,e={}){const{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:r=this.ttl,noDisposeOnSet:s=this.noDisposeOnSet,size:a=0,sizeCalculation:l=this.sizeCalculation,noUpdateTTL:c=this.noUpdateTTL,noDeleteOnFetchRejection:h=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:u=this.allowStaleOnFetchRejection,ignoreFetchAbort:d=this.ignoreFetchAbort,allowStaleOnFetchAbort:p=this.allowStaleOnFetchAbort,context:m,forceRefresh:f=!1,status:g,signal:y}=e;if(!this.#A)return g&&(g.fetch="get"),this.get(t,{allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:o,status:g});const b={allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:o,ttl:r,noDisposeOnSet:s,size:a,sizeCalculation:l,noUpdateTTL:c,noDeleteOnFetchRejection:h,allowStaleOnFetchRejection:u,allowStaleOnFetchAbort:p,ignoreFetchAbort:d,status:g,signal:y};let v=this.#c.get(t);if(void 0===v){g&&(g.fetch="miss");const e=this.#E(t,v,b,m);return e.__returned=e}{const e=this.#u[v];if(this.#x(e)){const t=n&&void 0!==e.__staleWhileFetching;return g&&(g.fetch="inflight",t&&(g.returnedStale=!0)),t?e.__staleWhileFetching:e.__returned=e}const o=this.#I(v);if(!f&&!o)return g&&(g.fetch="hit"),this.#M(v),i&&this.#R(v),g&&this.#k(g,v),e;const r=this.#E(t,v,b,m),s=void 0!==r.__staleWhileFetching&&n;return g&&(g.fetch=o?"stale":"refresh",s&&o&&(g.returnedStale=!0)),s?r.__staleWhileFetching:r.__returned=r}}async forceFetch(t,e={}){const n=await this.fetch(t,e);if(void 0===n)throw new Error("fetch() returned undefined");return n}memo(t,e={}){const n=this.#s;if(!n)throw new Error("no memoMethod provided to constructor");const{context:i,forceRefresh:o,...r}=e,s=this.get(t,r);if(!o&&void 0!==s)return s;const a=n(t,s,{options:r,context:i});return this.set(t,a,r),a}get(t,e={}){const{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:r}=e,s=this.#c.get(t);if(void 0!==s){const e=this.#u[s],a=this.#x(e);return r&&this.#k(r,s),this.#I(s)?(r&&(r.get="stale"),a?(r&&n&&void 0!==e.__staleWhileFetching&&(r.returnedStale=!0),n?e.__staleWhileFetching:void 0):(o||this.#$(t,"expire"),r&&n&&(r.returnedStale=!0),n?e:void 0)):(r&&(r.get="hit"),a?e.__staleWhileFetching:(this.#M(s),i&&this.#R(s),e))}r&&(r.get="miss")}#D(t,e){this.#p[e]=t,this.#d[t]=e}#M(t){t!==this.#f&&(t===this.#m?this.#m=this.#d[t]:this.#D(this.#p[t],this.#d[t]),this.#D(this.#f,t),this.#f=t)}delete(t){return this.#$(t,"delete")}#$(t,e){let n=!1;if(0!==this.#a){const i=this.#c.get(t);if(void 0!==i)if(n=!0,1===this.#a)this.#V(e);else{this.#O(i);const n=this.#u[i];if(this.#x(n)?n.__abortController.abort(new Error("deleted")):(this.#C||this.#S)&&(this.#C&&this.#i?.(n,t,e),this.#S&&this.#y?.push([n,t,e])),this.#c.delete(t),this.#h[i]=void 0,this.#u[i]=void 0,i===this.#f)this.#f=this.#p[i];else if(i===this.#m)this.#m=this.#d[i];else{const t=this.#p[i];this.#d[t]=this.#d[i];const e=this.#d[i];this.#p[e]=this.#p[i]}this.#a--,this.#g.push(i)}}if(this.#S&&this.#y?.length){const t=this.#y;let e;for(;e=t?.shift();)this.#o?.(...e)}return n}clear(){return this.#V("delete")}#V(t){for(const e of this.#_({allowStale:!0})){const n=this.#u[e];if(this.#x(n))n.__abortController.abort(new Error("deleted"));else{const i=this.#h[e];this.#C&&this.#i?.(n,i,t),this.#S&&this.#y?.push([n,i,t])}}if(this.#c.clear(),this.#u.fill(void 0),this.#h.fill(void 0),this.#w&&this.#v&&(this.#w.fill(0),this.#v.fill(0)),this.#b&&this.#b.fill(0),this.#m=0,this.#f=0,this.#g.length=0,this.#l=0,this.#a=0,this.#S&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#o?.(...e)}}}function g(t){window.$monomerHover=t}var y=n(2003),b=n(6077),v=n(3561),w=n(9235);const C="MonomerHoverLinks";async function A(t,e,n,i,r,s=!1){const a=i.getSeqHandler(t),l=a.alphabet==y.YI.RNA||a.alphabet==y.YI.DNA,c=a.isHelm()&&l,h=!a.isHelm()&&l,u=t=>null==t?null:c?s?t:Math.floor(t/3):h&&s?3*t+1:t,d=s?await i.getHelmToMolfileConverter(n):null,p=new f({max:100});function m(t,e){const a=t.get(e);if(null==a)return null;let l=p.get(a);return l||p.set(a,l=function(t,e){const a=i.getSeqHandler(t);if(s){const t=a.getHelm(e);return i.helmToAtomicLevelSingle(t,d,!1,!1).monomers}{const t=a.getSplitted(e),i=a.defaultBiotype,s=o().count(0).take(t.length).map((e=>({position:e,symbol:t.getCanonical(e),biotype:i}))).toArray(),l=a.alphabet,c=l==y.YI.RNA||l==y.YI.DNA?"RNA":"PEPTIDE",h=(0,b.eM)([s],c,l,n,r);return(0,v.gU)(s,h,l,c).monomers}}(t,e)),l}const A={targetCol:e,handler:(e,i,o)=>{const r=o.grid,s=e.tableRowIndex,a=e.gridRow,l=r.cell(o.name,a),c=null!==(h=window.$monomerHover)&&void 0!==h?h:null;var h;if(!c||c&&(c.dataFrameId!=t.dataFrame.id||c.gridRowIdx!=a||c.seqColName!=t.name||c.seqPosition!=i?.position)){if(c&&(g(null),c.gridCell.render()),!i)return g(null),!0;g({gridCell:l,dataFrameId:t.dataFrame.id,gridRowIdx:a,seqColName:t.name,seqPosition:u(i?.position)??-1,getSubstruct:()=>{if(!i||"*"===i.symbol)return;const e=m(t,s);if(!e)return;const o=e.get(u(i?.position));return o?(0,w.H)([o],n):{atoms:[],bonds:[],highlightAtomColors:[],highlightBondColors:[]}}}),l.render()}return!0},getSubstruct:i=>{if("true"!=e.getTag(".sequence-src-highlight-monomers"))return;if(null==i)return;if(!t.get(i))return;const o=m(t,i);return o?(0,w.H)(o.values(),n):void 0}};return function(t,e){let n=t[C];n||(n=t[C]=[]),n.push(e),t[C]=n}(t.temp,A),function(t,e){let n=t["substruct-providers"];n||(n=t["substruct-providers"]=[]),n.push(e),t["substruct-providers"]=n}(e.temp,A),A}function S(t,e){try{const n=t.tableColumn;if(!n)return;const i=function(t){return t.temp[C]??[]}(n);for(let n=i.length-1;n>=0;--n){const o=i[n],r=t.grid.col(o.targetCol.name);if(r&&!o.handler(t,e,r))break}}catch(t){console.error(t)}}},6718:(t,e,n)=>{"use strict";n.d(e,{A7:()=>p,pj:()=>h,uL:()=>u,uX:()=>c});var i=n(6082),o=n(4328),r=n(6295),s=n(3151),a=n(3077),l=n(439);function c(t){const e=[];for(let n=0;n<t.rowCount;n++){const i={};Object.keys(s.Ec).forEach((e=>{if("symbol"===e){const o=t.get(s.Ec[e],n);i[e]="."===o?t.get(s.yw,n):o}else if("rgroups"===e){const o=t.get(s.Ec[e],n).split("\n"),r=[];o.forEach((t=>{const e={},n=t.substring(t.lastIndexOf("]")+1),i=t.match(/\[R(\d+)\]/)[1];e.capGroupSmiles="H"===n?`[*:${i}][H]`:`O[*:${i}]`,e.alternateId="H"===n?`R${i}-H`:`R${i}-OH`,e.capGroupName="H"===n?"H":"OH",e.label=`R${i}`,r.push(e)})),i[e]=r}else s.Ec[e]&&(i[e]=t.get(s.Ec[e],n))})),i.author??(i.author=""),i.id??(i.id=0),i.smiles??(i.smiles=""),i.monomerType??(i.monomerType="Backbone"),i.createDate??(i.createDate=null),e.push(i)}return e}async function h(){const t=i.Func.find({package:"Bio",name:"getMonomerLibHelper"});if(0===t.length)throw new Error('Package "Bio" must be installed for MonomerLibHelper.');return(await t[0].prepare().call()).getOutputParamValue()}async function u(t,e,n){t instanceof i.Column&&(t=(0,a.R)(t,n).columns.toList());const r=(await h()).getMonomerLib(),s=new Array(t.length),c=t[0].length,u=new Float32Array(c);for(let n=0;n<t.length;++n){const a=n<e.length?e.getCanonical(n):l._S,h=r.getMonomer("PEPTIDE",a)?.smiles??"",d=t[n],p=d.getRawData(),m=d.categories,f=m.indexOf("");if(s[n]={categories:m,data:p,emptyIndex:f},void 0===a)continue;const g=i.Column.fromStrings("smiles",m.map((t=>r.getMonomer("PEPTIDE",t)?.smiles??""))),y=(i.DataFrame.fromColumns([g]),await o.chem.getSimilarities(g,h)),b=y?y.getRawData():null;for(let t=0;t<c;++t){const e=p[t];a!==l._S&&e!==f?u[t]+=b[e]:a===l._S&&e===f&&(u[t]+=1)}}for(let n=0;n<u.length;++n){let o=u[n]/e.length;for(let r=0;r<t.length;++r){const t=s[r];if(r>=e.length&&t.data[n]!==t.emptyIndex||t.data[n]===t.emptyIndex&&r<e.length){o=i.FLOAT_NULL;break}}u[n]=o}return i.Column.fromFloat32Array("Similarity",u)}async function d(t){const e=(await h()).getMonomerLib(),n=[],r={},s=t.map((t=>e.getMonomer("PEPTIDE",t)?.smiles??"")),a=i.Column.fromStrings("smiles",s);for(let e=0;e<s.length;++e){r[t[e]]=e;const i=s[e],l=""===i?new Array(s.length).fill(0):(await o.chem.getSimilarities(a,i)).getRawData();l[e]=1,n[e]=Array.from(l)}return{scoringMatrix:n,alphabetIndexes:r}}async function p(t,e="Morgan"){const n=(await h()).getMonomerLib(),o=new Array(t.length).fill(0).map((()=>new Array(t.length).fill(0))),s={},a=t.map((t=>n.getMonomer("PEPTIDE",t)?.molfile||n.getMonomer("PEPTIDE",t)?.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(t);const c=i.Column.fromStrings("smiles",a),u=(i.DataFrame.fromColumns([c]),(await l.apply({col:c,fingerprintType:e}))?.entries);if(!u)return console.warn(`${e} Fingerprints could not be calculated for monomers from chem package.\n falling back to Morgan fingerprints`),await d(t);for(let e=0;e<u.length;++e)if(o[e][e]=1,s[t[e]]=e,u[e])for(let t=e+1;t<u.length;++t)u[t]&&(o[e][t]=o[t][e]=(0,r.$1)(u[e],u[t]));return{scoringMatrix:o,alphabetIndexes:s}}},6197:(t,e,n)=>{"use strict";n.d(e,{Y:()=>o});var i=n(3599);function o(t){let e;switch(t){case i.o.BASE:case i.o.SUGAR:case i.o.LINKER:case i.o.NUCLEOTIDE:case"nucleotide":e="RNA";break;case i.o.AA:e="PEPTIDE";break;case i.o.CHEM:e="CHEM";break;case i.o.BLOB:e="BLOB";break;default:e="PEPTIDE",console.warn(`Unexpected HelmType '${t}'`)}return e}},9235:(t,e,n)=>{"use strict";n.d(e,{H:()=>c,R:()=>l});var i=n(6082),o=n(1991),r=n.n(o),s=n(330),a=n(3599);async function l(t,e,o,l,c,h,u){const d=t.length,p=t.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=d/m,y=new Array(m),b=h.getSeqHandler(t),v="RNA"==l?a.o.NUCLEOTIDE:a.o.AA,w=r().count(0).take(t.length).map((t=>{const e=b.getSplitted(t);return r().count(0).take(e.length).map((t=>({position:t,symbol:e.getCanonical(t),biotype:v}))).toArray()})).toArray();for(let t=0;t<m;t++){const n=f[t],i=Math.floor(t*g),r=t===m-1?d:Math.floor((t+1)*g);y[t]=new Promise((t=>{n.onmessage=e=>{t(e.data)}})),n.postMessage({seqList:w,monomersDict:e,alphabet:o,polymerType:l,start:i,end:r})}const C=[],A=[];await Promise.all(y).then((t=>{for(const e of t)C.push(...e.molfiles),A.push(...e.warnings)})),setTimeout((()=>{f.forEach((t=>{t.terminate()}))}),0);const S=(0,s.qj)(p,t.name),x=i.Column.fromType(i.COLUMN_TYPE.STRING,S,t.length).init((t=>C[t]?.molfile));return x.semType=i.SEMTYPE.MOLECULE,x.meta.units=i.UNITS.Molecule.MOLBLOCK,x.setTag(".sequence-src-col",t.name),{molCol:x,warnings:A}}function c(t,e){const n={},o={};for(const r of t){const t=e.getWebEditorMonomer(r.biotype,r.symbol).backgroundcolor,a=(0,s.vG)(t??i.Color.toRgb(i.Color.mouseOverRows))??[1,0,0,.7];for(const t of r.atoms)n[t]=a;for(const t of r.bonds)o[t]=a}return{atoms:Object.keys(n).map((t=>parseInt(t))),bonds:Object.keys(o).map((t=>parseInt(t))),highlightAtomColors:n,highlightBondColors:o}}},3561:(t,e,n)=>{"use strict";n.d(e,{Hb:()=>l,YN:()=>f,gU:()=>c});var i=n(8123),o=n(294),r=n(3151),s=n(439),a=n(6197);function l(t,e,n){const o=new Map;for(const a of t.getMonomerSymbolsByType(e)){const l=t.getMonomer(e,a);if("RNA"===e&&("Branch"===l.monomerType||n===s.YI.DNA&&l.symbol===i.u.DEOXYRIBOSE.symbol||n===s.YI.RNA&&l.symbol===i.u.RIBOSE.symbol||l.symbol===i.u.PHOSPHATE.symbol)||"PEPTIDE"===e&&"Branch"!==l.monomerType){const t={};r.f6.forEach((e=>{t[e]=l[e]})),o.set(l.symbol,t)}}return o}function c(t,e,n,r){if(0===t.length)return o.vF.createEmpty();const l=m,{atomCount:c,bondCount:u,needsCapping:p}=l(t,e,n,r),g=new Array(c),y=new Array(u);let b,v=null,w=null;"PEPTIDE"===r?b=h:(b=d,v=n===s.YI.DNA?(0,o.xb)(e,i.u.DEOXYRIBOSE):(0,o.xb)(e,i.u.RIBOSE),w=(0,o.xb)(e,i.u.PHOSPHATE));const C={i:0,nodeShift:0,bondShift:0,backbonePositionShift:new Array(2).fill(0),branchPositionShift:new Array(2).fill(0),backboneAttachNode:0,branchAttachNode:0,flipFactor:1},A={sugar:v,phosphate:w,seqLength:t.length,atomCount:c,bondCount:u},S=new o.Cg,x=[];let E=0;for(C.i=0;C.i<A.seqLength;++C.i){const n=t[C.i];if(n.symbol===s._S)continue;const i=(0,o.xb)(e,{symbol:n.symbol,polymerType:(0,a.Y)(n.biotype)}),r=C.nodeShift,l=C.bondShift;b(i,g,y,C,A),i.stereoAtoms?.forEach((t=>x.push(t+E))),E+=i.atoms.x.length;const c=C.nodeShift-r,h=new Array(c);for(let t=0;t<c;++t)h[t]=r+t;const u=C.bondShift-l,d=new Array(u);for(let t=0;t<u;++t)d[t]=l+t;S.set(C.i,{biotype:n.biotype,symbol:n.symbol,atoms:h,bonds:d})}p&&function(t,e,n,o){const r=n.nodeShift+1;t[o.atomCount]=i.u.V3K_BEGIN_DATA_LINE+r+" "+i.u.OXYGEN+" "+f(n.backbonePositionShift[0])+" "+n.flipFactor*f(n.backbonePositionShift[1])+" 0.000000 0\n";const s=n.backboneAttachNode,a=r;e[o.bondCount]=i.u.V3K_BEGIN_DATA_LINE+n.bondShift+" 1 "+s+" "+a+"\n"}(g,y,C,A);const M=i.u.V3K_BEGIN_COUNTS_LINE+c+" "+u+i.u.V3K_COUNTS_LINE_ENDING;let T="";return T+=i.u.V3K_HEADER_FIRST_LINE,T+=i.u.V3K_HEADER_SECOND_LINE,T+=i.u.V3K_BEGIN_CTAB_BLOCK,T+=M,T+=i.u.V3K_BEGIN_ATOM_BLOCK,T+=g.join(""),T+=i.u.V3K_END_ATOM_BLOCK,T+=i.u.V3K_BEGIN_BOND_BLOCK,T+=y.join(""),T+=i.u.V3K_END_BOND_BLOCK,x.length>0&&(T+=function(t){const e=[];let n=`M V30 MDLV30/STEABS ATOMS=(${t.length}`;for(let i=0;i<t.length;i++){const o=`${n} ${t[i]}`;o.length>76?(e.push(`${n} -\n`),n=`M V30 ${t[i]}`):n=o,i===t.length-1&&e.push(`${n})\n`)}return`M V30 BEGIN COLLECTION\n${e.join("")}M V30 END COLLECTION\n`}(x)),T+=i.u.V3K_END_CTAB_BLOCK,T+=i.u.V3K_END,{molfile:T,monomers:S}}function h(t,e,n,i){i.flipFactor=(-1)**(i.i%2),u(t,e,n,i)}function u(t,e,n,o){!function(t,e,n){for(let o=0;o<t.atoms.atomTypes.length;++o){const r=n.nodeShift+o+1;e[n.nodeShift+o]=i.u.V3K_BEGIN_DATA_LINE+r+" "+t.atoms.atomTypes[o]+" "+f(n.backbonePositionShift[0]+t.atoms.x[o])+" "+f(n.backbonePositionShift[1]+n.flipFactor*t.atoms.y[o])+" "+t.atoms.kwargs[o]}}(t,e,o),p(t,n,o),function(t,e,n){if(0!==n.backboneAttachNode){const o=n.bondShift,r=n.backboneAttachNode,s=t.meta.terminalNodes[0]+n.nodeShift;e[n.bondShift-1]=i.u.V3K_BEGIN_DATA_LINE+o+" 1 "+r+" "+s+"\n"}}(t,n,o),null!==t.meta.branchShift&&t.meta.terminalNodes.length>2&&function(t,e){e.branchAttachNode=e.nodeShift+t.meta.terminalNodes[2];for(let n=0;n<2;++n)e.branchPositionShift[n]=e.backbonePositionShift[n]+t.meta.branchShift[n]}(t,o),function(t,e){e.backboneAttachNode=e.nodeShift+t.meta.terminalNodes[1],e.bondShift+=t.bonds.atomPairs.length+1,e.nodeShift+=t.atoms.atomTypes.length,e.backbonePositionShift[0]+=t.meta.backboneShift?.[0]??0,e.backbonePositionShift[1]+=e.flipFactor*(t.meta.backboneShift?.[1]??0)}(t,o)}function d(t,e,n,o,r){if(0===o.i)u(r.sugar,e,n,o);else for(const t of[r.phosphate,r.sugar])u(t,e,n,o);!function(t,e,n,o){(function(t,e,n){for(let o=0;o<t.atoms.atomTypes.length;++o){const r=n.nodeShift+o+1;e[n.nodeShift+o]=i.u.V3K_BEGIN_DATA_LINE+r+" "+t.atoms.atomTypes[o]+" "+f(n.branchPositionShift[0]+t.atoms.x[o])+" "+f(n.branchPositionShift[1]+n.flipFactor*t.atoms.y[o])+" "+t.atoms.kwargs[o]}})(t,e,o),p(t,n,o),function(t,e,n){const o=n.bondShift,r=n.branchAttachNode,s=t.meta.terminalNodes[0]+n.nodeShift;e[o-1]=i.u.V3K_BEGIN_DATA_LINE+o+" 1 "+r+" "+s+"\n"}(t,n,o);const r=o.bondShift,s=o.branchAttachNode,a=t.meta.terminalNodes[0]+o.nodeShift;n[r-1]=i.u.V3K_BEGIN_DATA_LINE+r+" 1 "+s+" "+a+"\n",o.bondShift+=t.bonds.atomPairs.length+1,o.nodeShift+=t.atoms.atomTypes.length}(t,e,n,o)}function p(t,e,n){for(let o=0;o<t.bonds.atomPairs.length;++o){const r=n.bondShift+o+1,s=t.bonds.atomPairs[o][0]+n.nodeShift,a=t.bonds.atomPairs[o][1]+n.nodeShift;let l="";if(t.bonds.bondConfiguration.has(o)){let e=t.bonds.bondConfiguration.get(o);n.flipFactor<0&&(e=1===e?3:1),l=" CFG="+e}const c=t.bonds.kwargs.has(o)?" "+t.bonds.kwargs.get(o):"";e[n.bondShift+o]=i.u.V3K_BEGIN_DATA_LINE+r+" "+t.bonds.bondTypes[o]+" "+s+" "+a+l+c+"\n"}}function m(t,e,n,r){let l=0,c=0,h=0,u=!0,d=null;for(const n of t)if(n.symbol!==s._S){if("*"==n.symbol)throw new Error("Gap canonical symbol is '', not '*");d=(0,o.xb)(e,{symbol:n.symbol,polymerType:(0,a.Y)(n.biotype)}),l+=d.atoms.x.length,c+=d.bonds.bondTypes.length,h++}if("PEPTIDE"===r)l+=1,c+=h,h>0&&(d?.meta?.rNodes?.length??0)<2&&(u=!1,l-=1,c-=1);else{const r=n===s.YI.DNA?(0,o.xb)(e,i.u.DEOXYRIBOSE):(0,o.xb)(e,i.u.RIBOSE),a=(0,o.xb)(e,i.u.PHOSPHATE);l+=(t.length-1)*a.atoms.x.length,l+=t.length*r.atoms.x.length,l+=1,c+=(t.length-1)*a.bonds.bondTypes.length,c+=t.length*r.bonds.bondTypes.length,c-=1,c+=3*t.length}return{atomCount:l,bondCount:c,needsCapping:u}}function f(t){return Math.round(i.u.PRECISION_FACTOR*t)/i.u.PRECISION_FACTOR}},6077:(t,e,n)=>{"use strict";n.d(e,{C4:()=>m,eM:()=>f});var i=n(4328),o=n(6082),r=n(1991),s=n.n(r),a=n(439),l=n(3561),c=n(9235),h=n(294),u=n(9192),d=n(330),p=n(8123);async function m(t,e,n,r,l){if(e.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 '${e.semType}'`]};let h=e;const p=r.getSeqHandler(e);let m,g;p.notation!==a.Hi.SEPARATOR&&(h=p.convert(a.Hi.SEPARATOR,"."),h.name=e.name);try{g=r.getSeqHandler(h).alphabet,m=(0,d.pz)(g)}catch(t){const[e,n]=(0,u.AP)(t);return{molCol:null,warnings:[e]}}const y=function(t,e){const n=t.length,o=new Array(n),r=e.getSeqHandler(t);let a=!1;const l=r.defaultBiotype;for(let t=0;t<n;++t){const e=r.getSplitted(t);a||(a=0===e.length),o[t]=s().count(0).take(e.length).filter((t=>!e.isGap(t))).map((t=>({position:t,biotype:l,symbol:e.getCanonical(t)}))).toArray()}return a&&i.shell.warning(`Some values in the "${t.name}" column are empty`),o}(h,r),b=f(y,m,g,n,l),v=h.length,w=await(0,c.R)(h,b,g,m,n,r,l);return w.warnings.length>.05*v&&i.shell.warning(`Molfile conversion resulted in ${w.warnings.length} errors`),w}function f(t,e,n,i,o){const r=(0,l.Hb)(i,e,n),s={},c={value:null};if("RNA"===e){const t=n===a.YI.RNA?[p.u.RIBOSE,p.u.PHOSPHATE]:[p.u.DEOXYRIBOSE,p.u.PHOSPHATE];for(const n of t)g(s,n.symbol,r,o,e,c)}for(let n=0;n<t.length;++n){const i=t[n];for(const t of i){const n=t.symbol;if(""!==n)try{if("RNA"===e&&3===n.split(/\(|\)/).filter((t=>!!t)).length){const t=n.split(/\(|\)/)[1];g(s,t,r,o,e,c),s[e]?.[t]&&(s[e][n]=s[e][t])}else g(s,n,r,o,e,c)}catch(t){const e=t instanceof Error?t.message:t.toString(),i=t instanceof Error?t.stack:void 0;throw console.error(`bio lib: getMonomersDictFromLib() sym='${n}', error:\n${e}\n${i}`),new Error(`Can't get monomer '${n}' from library: ${e}`)}}}return s}function g(t,e,n,i,o,r){const s={polymerType:o,symbol:e};if(!(0,h.bq)(t,s)){const a=function(t,e,n,i,o){if(e.has(t)){const s=e.get(t),a=function(t){const e=[];for(const n of t){let t=n.capGroupSmiles;t||(t=n.capGroupSMILES),t=t.replace(/(\[|\]|\*|:|\d)/g,"").replace("OH","O").replace("Oh","O"),e.push(t)}return e}(s.rgroups),c=(r=s.molfile).includes("V3000")?function(t){const e=new Map,n=/M V30 (\d+) R#.+RGROUPS=\((\d+) (\d+)\).*/gm;let i;for(;null!==(i=n.exec(t));)i.index===n.lastIndex&&n.lastIndex++,e.set(parseInt(i[1]),parseInt(i[3]));return e}(r):function(t){const e=new Map;let n=t.indexOf(p.u.V2K_A_LINE,0),i=n;for(;-1!==n;){i=t.indexOf("\n",n);const o=parseInt(t.substring(n,i).replace(/^A\s+/,""));n=t.indexOf("R",i),i=t.indexOf("\n",n);const r=parseInt(t.substring(n,i).replace(/^R/,""));e.set(o,r),n=t.indexOf(p.u.V2K_A_LINE,i)}for(n=t.indexOf(p.u.V2K_RGP_LINE,0),i=t.indexOf("\n",n);-1!==n;){n+=p.u.V2K_RGP_SHIFT,i=t.indexOf("\n",n);const o=t.substring(n,i).replaceAll(/\s+/g," ").split(" ").map((t=>parseInt(t))).slice(1);for(let t=0;t<o.length;t+=2){if(e.has(o[t])&&e.get(o[t])!==o[t+1])throw new Error(`r-group index ${o[t]} has already been added with a different value`);e.set(o[t],o[t+1])}n=t.indexOf(p.u.V2K_RGP_LINE,i)}return e}(r),h=s.molfile.includes("V3000")?s.molfile:function(t,e){const n=e.get_mol(function(t){return t.split("\n").map((t=>{const e=t.indexOf(" R# "),n=t.indexOf(" R ");if(-1===e&&-1===n)return t;const i=-1!==e?e:n,o=t.split("");for(let t=i+5;t<o.length;t++)" "!==o[t]&&(o[t]="0");return o.join("")})).join("\n")}(t)),i=n.get_v3Kmolblock();return n.delete(),i}(function(t){let e=t.indexOf(p.u.V2K_A_LINE,0);-1===e&&(e=t.indexOf(p.u.V2K_RGP_LINE));const n=t.indexOf(p.u.V3K_END,e);return t.substring(0,e)+t.substring(n)}(s.molfile),n),u=function(t){let e=(t=t.replaceAll("\r","")).indexOf(p.u.V3K_BEGIN_COUNTS_LINE)+p.u.V3K_COUNTS_SHIFT,n=t.indexOf(" ",e+1);const i=parseInt(t.substring(e,n));return e=n+1,n=t.indexOf(" ",e+1),{atomCount:i,bondCount:parseInt(t.substring(e,n))}}(h),d=function(t,e){const n=new Array(e),i=new Float32Array(e),o=new Float32Array(e),r=new Array(e);let s=t.indexOf(p.u.V3K_BEGIN_ATOM_BLOCK);s=t.indexOf("\n",s);let a=s;for(let l=0;l<e;l++){s=t.indexOf(p.u.V3K_BEGIN_DATA_LINE,s)+p.u.V3K_IDX_SHIFT,a=t.indexOf(" ",s),s=a+1,a=t.indexOf(" ",s),n[l]=t.substring(s,a);const e=new Array(2);for(let n=0;n<2;++n)s=a+1,a=t.indexOf(" ",s),e[n]=parseFloat(t.substring(s,a));i[l]=e[0],o[l]=e[1],s=a,a=t.indexOf("\n",s)+1,r[l]=t.slice(s,a),s=a}return{atomTypes:n,x:i,y:o,kwargs:r}}(h,u.atomCount),m=function(t,e){const n=new Uint32Array(e),i=new Array(e),o=new Map,r=new Map;let s=t.indexOf(p.u.V3K_BEGIN_BOND_BLOCK);s=t.indexOf("\n",s);let a=s;for(let l=0;l<e;++l){const e=new Array(3);s=t.indexOf(p.u.V3K_BEGIN_DATA_LINE,a)+p.u.V3K_IDX_SHIFT,a=t.indexOf(" ",s);for(let n=0;n<3;++n)s=a+1,a=Math.min(t.indexOf("\n",s),t.indexOf(" ",s)),e[n]=parseInt(t.slice(s,a));n[l]=e[0],i[l]=e.slice(1);const c=t.indexOf("\n",s);let h=t.slice(a,c),u=h.indexOf(p.u.V3K_BOND_CONFIG);if(-1!==u){u=h.indexOf("=",u)+1;let t=h.indexOf(" ",u);-1===t&&(t=h.length);const e=parseInt(h.slice(u,t));o.set(l,e);const n=p.u.V3K_BOND_CONFIG+e.toString();h=h.replace(n,"")}h||r.set(l,h)}return{bondTypes:n,atomPairs:i,bondConfiguration:o,kwargs:r}}(h,u.bondCount),f=function(t,e,n,i){const o={backboneShift:null,branchShift:null,terminalNodes:[],rNodes:[]};if(n&&i&&[1,2].some((t=>!Array.from(i.values()).find((e=>e==t))))){const e=[1,2].find((t=>!Array.from(i.values()).find((e=>e==t)))),o=[1,2].find((t=>Array.from(i.values()).find((e=>e==t)))),r=Array.from(i.keys()).find((t=>i.get(t)===o))-1,s=t.x[r],a=t.y[r],l=t.x.reduce(((e,n,i)=>{if(i===r)return e;const o=t.y[i];return Math.sqrt((n-s)**2+(o-a)**2)>Math.sqrt((t.x[e]-s)**2+(t.y[e]-a)**2)?i:e}),0);if(i.set(l+1,e),1===e)n.unshift(t.atomTypes[l]);else{if(2!==e)throw new Error(`Unexpected missing R-group: ${e}`);n.splice(1,0,t.atomTypes[l])}}return function(t,e,n){for(const[i,o]of n)t.atomTypes[i-1]=e[o-1]}(t,n,i),function(t,e){e.rNodes=Array.from(t.keys());for(let n=0;n<e.rNodes.length;n++)for(const i of[1,2])if(t.get(e.rNodes[n])===i){const t=e.rNodes[i-1];e.rNodes[i-1]=e.rNodes[n],e.rNodes[n]=t}}(i,o),y(e,o),o}(d,m,a,c),g=function(t){let e=[],n=t.indexOf("M V30 MDLV30/STEABS ATOMS=(");for(;-1!==n;){n+=28;const i=t.indexOf(")",n);e=e.concat(t.substring(n,i).split(" ").slice(1).map((t=>parseInt(t)))),n=i,n=t.indexOf("M V30 MDLV30/STEABS ATOMS=(",n)}return e}(h),v={atoms:d,bonds:m,meta:f,stereoAtoms:g};return"PEPTIDE"===i?function(t){const e=t.meta.terminalNodes[0]-1,n=t.meta.rNodes[0]-1,i=t.atoms.x,o=t.atoms.y;M(t,-i[e],-o[e]);const r=A(i[n],o[n]);S(t.atoms,-r),i[t.meta.rNodes[1]-1]<0&&x(t);const s=function(t){const e=function(t){const e=new Map;for(const n of t.bonds.atomPairs)for(let t=0;t<2;t++){const i=n[t],o=n[(t+1)%2];e.has(i)?e.get(i)?.push(o):e.set(i,new Array(1).fill(o))}return e}(t);let n=0;const i=t.atoms.atomTypes.length;let o=0;if(t.meta.terminalNodes.length<2)return null;for(;0===n;){const r=e.get(t.meta.terminalNodes[1])[o];if(t.atoms.atomTypes[r-1]===p.u.OXYGEN&&r!==t.meta.rNodes[1]&&(n=r),o++,o>i)return null}return n}(t);null!=s&&(function(t,e){t.atoms.y[t.meta.rNodes[1]-1]<0&&t.atoms.y[e-1]<0&&(function(t){E(t,!0)}(t),S(t.atoms,-function(t,e){return A(t,e)+Math.PI/2}(t.atoms.x[t.meta.terminalNodes[1]-1],t.atoms.y[t.meta.terminalNodes[1]-1])))}(t,s),function(t,e){const n=t.atoms.x;n[t.meta.rNodes[1]-1]>n[e-1]&&function(t,e,n){const i=e-1,o=n-1,r=t.atoms.x,s=t.atoms.y,a=r[i],l=s[i];r[i]=r[o],s[i]=s[o],r[o]=a,s[o]=l}(t,e,t.meta.rNodes[1])}(t,s))}(v):t===p.u.RIBOSE.symbol||t===p.u.DEOXYRIBOSE.symbol?function(t,e){const n=t.atoms.x,i=t.atoms.y;let o=t.meta.terminalNodes[0]-1;const r=t.meta.rNodes[1]-1;M(t,-n[o],-i[o]);const s=A(n[t.meta.rNodes[2]-1],i[t.meta.rNodes[2]-1]);S(t.atoms,-s),n[t.meta.rNodes[0]-1]>n[t.meta.rNodes[1]-1]&&x(t);const a=A(n[r],i[r]);S(t.atoms,3*Math.PI/2-a),e.value=function(t){const e=t.atoms.x,n=t.atoms.y,i=t.meta.rNodes[2]-1,o=t.meta.terminalNodes[2]-1,r=e[i]-e[o],s=n[i]-n[o];return Math.atan2(r,s)}(t),o=t.meta.terminalNodes[0]-1,M(t,-n[o],-i[o])}(v,o):t===p.u.PHOSPHATE.symbol?function(t){const e=t.meta.rNodes[1]-1,n=t.meta.rNodes[0]-1,i=t.atoms.x,o=t.atoms.y;M(t,-i[e],-o[e]);const r=A(i[n],o[n]);S(t.atoms,Math.PI/2-r)}(v):function(t,e){const n=t.atoms.x,i=t.atoms.y,o=t.meta.terminalNodes[0]-1,r=t.meta.rNodes[0]-1;M(t,-n[o],-i[o]);const s=A(n[r],i[r]),a=e.value;if(!a)throw new Error("The value of sugarBranchToOYAngle is null");S(t.atoms,Math.PI-s+a);const c=function(t,e){return(0,l.YN)(Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2))}({x:n[t.meta.rNodes[0]-1],y:i[t.meta.rNodes[0]-1]},{x:n[t.meta.terminalNodes[0]-1],y:i[t.meta.terminalNodes[0]-1]});if(1!=c)for(let t=0;t<n.length;++t)n[t]=(0,l.YN)(n[t]/c),i[t]=(0,l.YN)(i[t]/c)}(v,o),function(t,e,n){"PEPTIDE"===t?(b(e,t),w(e,e.meta.rNodes[1])):n===p.u.RIBOSE.symbol||n===p.u.DEOXYRIBOSE.symbol?(w(e,e.meta.rNodes[1]),e.meta.rNodes[1]=e.meta.terminalNodes[1],y(e.bonds,e.meta),b(e,t),w(e,e.meta.rNodes[1]),w(e,e.meta.rNodes[0]),w(e,e.meta.rNodes[2])):n===p.u.PHOSPHATE.symbol&&(e.meta.terminalNodes[0]=e.meta.rNodes[0],M(e,-e.atoms.x[e.meta.terminalNodes[0]-1],-e.atoms.y[e.meta.terminalNodes[0]-1]),b(e,t),w(e,e.meta.rNodes[1]))}(i,v,t),function(t){let e=0;for(;e<t.atoms.atomTypes.length;)t.atoms.atomTypes[e]===p.u.HYDROGEN&&(w(t,e+1),--e),++e}(v),function(t){let e=0;for(;e<t.atoms.atomTypes.length;)"oh"===t.atoms.atomTypes[e]?.toLowerCase()&&(t.atoms.atomTypes[e]="O"),"?"===t.atoms.atomTypes[e]&&(t.atoms.atomTypes[e]="H"),++e}(v),function(t){const e=" RGROUPS=(1 1)";for(let n=0;n<(t.atoms.kwargs?.length??0);n++){const i=t.atoms.kwargs[n];i&&i.includes(e)&&(t.atoms.kwargs[n]=i.replace(e,""))}}(v),v}var r;return null}(e,n,i,o,r);if(!a)throw new Error(`Monomer with symbol '${e}' is absent the monomer library`);(0,h.LQ)(t,s,a)}}function y(t,e){const n=e.rNodes;e.terminalNodes=new Array(n.length).fill(0);const i=e.terminalNodes,o=t.atomPairs;let r=0,s=0;for(;r<o.length&&s<i.length;){for(let t=0;t<i.length;++t)for(let e=0;e<2;++e)o[r][e]===n[t]&&(i[t]=o[r][(e+1)%2],n.length,++s);++r}}function b(t,e){t.meta.rNodes.length>1&&(t.meta.backboneShift=v(t,t.meta.rNodes[1]-1,t.meta.terminalNodes[0]-1)),"RNA"===e&&t.meta.rNodes.length>2&&(t.meta.branchShift=v(t,t.meta.rNodes[2]-1,t.meta.terminalNodes[0]-1))}function v(t,e,n){return[(0,l.YN)(t.atoms.x[e]-t.atoms.x[n]),(0,l.YN)(t.atoms.y[e]-t.atoms.y[n])]}function w(t,e){if(void 0!==e){const n=e-1,i=t.atoms,o=t.bonds,r=t.meta;i.atomTypes.splice(n,1),i.x=C(Float32Array,i.x,n,1),i.y=C(Float32Array,i.y,n,1),i.kwargs.splice(n,1);for(let t=0;t<r.terminalNodes.length;++t)r.terminalNodes[t]>e?--r.terminalNodes[t]:r.terminalNodes[t]===e&&(r.terminalNodes[t]=-1);for(let t=0;t<r.rNodes.length;++t)r.rNodes[t]>e?--r.rNodes[t]:r.rNodes[t]===e&&(r.rNodes[t]=-1);let s=0;for(;s<o.atomPairs.length;){const t=o.atomPairs[s][0],n=o.atomPairs[s][1];t===e||n===e?(o.atomPairs.splice(s,1),o.bondTypes=C(Uint32Array,o.bondTypes,s,1),o.bondConfiguration.has(s)&&o.bondConfiguration.delete(s),o.kwargs.has(s)&&o.kwargs.delete(s),--s):(o.atomPairs[s][0]=t>e?t-1:t,o.atomPairs[s][1]=n>e?n-1:n),++s}let a=Array.from(o.bondConfiguration.keys());a.forEach((t=>{if(o.bondConfiguration.has(t)&&t>n){const e=o.bondConfiguration.get(t);o.bondConfiguration.delete(t),o.bondConfiguration.set(t-1,e)}})),a=Array.from(o.kwargs.keys()),a.forEach((t=>{if(o.kwargs.has(t)&&t>n){const e=o.kwargs.get(t);o.kwargs.delete(t),o.kwargs.set(t-1,e)}}))}}function C(t,e,n,i){const o=new t(e.length-i);let r=0,s=0;for(;r<e.length;)r===n&&(r+=i),o[s]=e[r],++s,++r;return o}function A(t,e){let n;if(0===t)n=e>0?0:Math.PI;else if(0===e)n=t>0?-Math.PI/2:Math.PI/2;else{const i=e/t,o=Math.atan(i);n=t<0?Math.PI/2+o:-Math.PI/2+o}return n}function S(t,e){if(0!==e){const n=t.x,i=t.y,o=Math.cos(e),r=Math.sin(e);for(let t=0;t<n.length;++t){const e=n[t];n[t]=(0,l.YN)(e*o-i[t]*r),i[t]=(0,l.YN)(e*r+i[t]*o)}}}function x(t){E(t,!1)}function E(t,e){if(e){const e=t.atoms.y;for(let t=0;t<e.length;t++)e[t]=-e[t]}else{const e=t.atoms.x;for(let t=0;t<e.length;t++)e[t]=-e[t]}const n=t.bonds.bondConfiguration;for(const[t,e]of n){const i=1===e?3:1;n.set(t,i)}}function M(t,e,n){const i=t.atoms.x,o=t.atoms.y;for(let t=0;t<i.length;++t)i[t]=(0,l.YN)(i[t]+e),void 0!==n&&(o[t]=(0,l.YN)(o[t]+n))}},294:(t,e,n)=>{"use strict";function i(t,e){return t[e.polymerType]?.[e.symbol]}function o(t,e){return!!t[e.polymerType]?.[e.symbol]}function r(t,e,n){let i=t[e.polymerType];i||(i=t[e.polymerType]={}),i[e.symbol]=n}n.d(e,{Cg:()=>s,LQ:()=>r,bq:()=>o,vF:()=>a,xb:()=>i});class s extends Map{constructor(t){super(t)}}class a{constructor(t,e){this.molfile=t,this.monomers=e}static createEmpty(){return new a("",new s(null))}}},330:(t,e,n)=>{"use strict";n.d(e,{kA:()=>o,pz:()=>s,qj:()=>r,vG:()=>a});var i=n(2003);function o(t,e){return t?t.columns.getUnusedName(e):e}function r(t,e){return o(t,`molfile(${e})`)}function s(t){let e;if(t===i.YI.PT||t===i.YI.UN)e="PEPTIDE";else{if(t!==i.YI.RNA&&t!==i.YI.DNA)throw new Error(`Unexpected alphabet '${t}'.`);e="RNA"}return e}function a(t){const e=7===t.length?/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t):/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?[parseInt(e[1],16)/256,parseInt(e[2],16)/256,parseInt(e[3],16)/256,e.length>4?parseInt(e[4],16)/256:.3]:null}},1093:(t,e,n)=>{"use strict";n(7362);class i{}i.SemType="Nucleotides",i.SemTypeMultipleAlignment="NucleotidesMultipleAlignment",i.Names={A:"Adenine",C:"Cytosine",G:"Guanine",T:"Thymine",U:"Uracil"}},7362:(t,e,n)=>{"use strict";n.d(e,{e:()=>i});class i{static makePalette(t,e=!1,n=i){const o={};return t.forEach((t=>{const n=t[0],i=t[1];n.forEach(((t,n)=>{o[t]=this.colourPalette[i][e?0:n]}))})),new n(o)}constructor(t){this._palette=t}get(t,e){return this._palette[t]}}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:(t,e,n)=>{"use strict";n.d(e,{O:()=>r,n:()=>o});var i=n(1858);class o{constructor(t,e=!0,n){return this.substructure=t,this.readOnly=e,this.logger=n,new Proxy(this,{set:(t,e,n)=>{if(this.logger?.debug(`BioFilterProps.set ${e.toString()}( '${n}' )`),this.readOnly)throw new Error("Properties are immutable.");return t[e]=n,!0}})}}class r{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(t){this._propsChanging=!0;try{this._props=t,this.applyProps(),this.onChanged.next()}finally{this._propsChanging=!1}}saveProps(){const t={};for(const[e,n]of Object.entries(this.props))"_onChanged"!==e&&"logger"!==e&&(t[e]=this.props[e]);return t}async detach(){}get filterSummary(){return this.props.substructure}get isFiltering(){return""!==this.props.substructure}resetFilter(){this.props=this.emptyProps,this.onChanged.next()}}},4152:(t,e,n)=>{"use strict";var i=n(6082),o=n(7362),r=n(6718);function s(t,e=!0){if(null==t)return"rgb(100,100,100)";const n=i.Color.fromHtml(t);if(e){const t=i.Color.g(n),e=i.Color.r(n),o=i.Color.b(n),r=Math.sqrt(Math.pow(0-e,2)+Math.pow(0-t,2)+Math.pow(0-o,2));if(r>210)return`rgb(${e/r*210},${t/r*210},${o/r*210})`}return i.Color.toRgb(n)}class a{static hashCode(t){let e=0;if(0===t.length)return e;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n),e|=0;return e}}class l{}class c extends l{static get palette(){return c._pallete||(c._pallete=c.buildPalette()),c._pallete}static buildPalette(){return(0,r.pj)().then((t=>{t.awaitLoaded(1/0).then((()=>{const e=t.getMonomerLib();e.onChanged.subscribe((()=>{c.customMonomerColors={},c.polymerTypes=e.getPolymerTypes();for(const t of this.polymerTypes){const n=e.getMonomerSymbolsByType(t);for(const i of n){const n=e.getMonomer(t,i);n?.meta?.colors?.default?.background&&(this.customMonomerColors[i]||(this.customMonomerColors[i]={}),this.customMonomerColors[i][t]=s(n.meta.colors.default.background))}}}))}))})),[].concat(...Object.values(o.e.colourPalette))}get(t,e){const n=c.palette.length,i=c.customMonomerColors[t],o=e??"PEPTIDE";if(i&&i[o])return i[o];const r=a.hashCode(t)%n;return s(c.palette[r])}}c._pallete=null,c.customMonomerColors={},c.polymerTypes=[]},6642:(t,e,n)=>{"use strict";n.d(e,{BG:()=>s,sD:()=>l});var i=n(4328),o=n(1858),r=n(8070);function s(t){let e=null,n=null;try{n=t.dart?t.gridColumn:null,e=n?n.temp:null}catch{[n,e]=[null,null]}const i=t.cell.column;if(e=e??(i?i.temp:null),!e)throw new Error("Grid cell renderer back store (GridColumn or Column) not found.");return[n,i,e]}class a{onKeyDown(t,e){}onKeyPress(t,e){}onMouseEnter(t,e){}onMouseLeave(t,e){}onMouseDown(t,e){}onMouseUp(t,e){}onMouseMove(t,e){}onClick(t,e){}onDoubleClick(t,e){}}class l extends a{constructor(t,e,n){super(),this.gridCol=t,this.tableCol=e,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((t=>{try{this.destroyed||!this.tableCol||this.tableCol.dataFrame||this.destroy()}catch(t){this.logger.error(t)}})))),this.tableCol&&this.subs.push(i.events.onTableRemoved.subscribe((t=>{try{const e=t.args.dataFrame;this.tableCol?.dataFrame.id!==e.id||this.destroyed||this.destroy()}catch(t){this.logger.error(t)}}))),this.gridCol&&this.subs.push(i.events.onViewRemoving.subscribe((t=>{try{const e=t.args.view;this.gridCol?.dart&&this.gridCol.grid&&this.gridCol?.grid?.dart&&this.gridCol?.grid?.view?.id===e.id&&!this.destroyed&&this.destroy()}catch(t){this.logger.error(t)}})))}toLog(){return`${this.constructor.name}<${this.viewerId}>`}destroy(){for(const t of this.subs)t.unsubscribe();this.destroyed=!0}invalidateGrid(){this.gridCol&&this.gridCol.dart&&this.gridCol.grid?.invalidate()}reset(){this.dirty=!1}get onRendered(){return this._onRendered}invalidate(t){this.invalidateGrid()}async awaitRendered(t=1e4,e=`${t} timeout`){const n=`${this.toLog()}.awaitRendered()`;if(this.logger.debug(`${n}, start, testEvent before`),await(0,r.PE)(this._onRendered,(()=>{}),(()=>{this.invalidate()}),t,`${n}, ${e}`),this.errors.length>0){const t=this.errors[0];throw this.errors=[],t}this.logger.debug(`${n}, end`)}}l.viewerCounter=-1},673:(t,e,n)=>{"use strict";n.d(e,{s:()=>i});const i={true:"1",false:"0"}},6882:(t,e,n)=>{"use strict";n.d(e,{Jy:()=>b,S$:()=>y,U0:()=>v});var i=n(7389),o=n(6082),r=n(1991),s=n.n(r),a=n(8312),l=n(2003),c=n(6642),h=n(6718),u=n(9192),d=n(3856),p=n(673),m=n(3599),f=n(5553),g=n(9713);const y="rgb(100,100,100)";class b extends c.sD{get separatorWidth(){return this.props?.fontCharWidth?this.props?.fontCharWidth:5}constructor(t,e,n,i,r){if(super(t,e,n),this.monomerLengthLimit=i,this.propsProvider=r,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 t=[l.gp.positionShift,"renderMultiline"];this.subs.push(o.debounce(this.tableCol.dataFrame.onMetadataChanged.pipe(g.filter((e=>e.args.source===this.tableCol&&t.includes(e.args.key)))),200).subscribe((t=>{this.reset()}))),this.subs.push(o.debounce(this.tableCol.dataFrame.onMetadataChanged.pipe(g.filter((t=>t.args.source===this.tableCol&&t.args.key===l.gp.positionShift))),200).subscribe((t=>{this.reset()})))}}calculateFontBasedSpacing(t){const e=t.measureText("M");let n=12;if(this.tableCol?.temp[".mm.cellRenderer.fontSize"]){const t=this.tableCol.temp[".mm.cellRenderer.fontSize"];"number"!=typeof t||isNaN(t)||(n=Math.max(t,1))}return{lineHeight:Math.max(1.4*n,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent+4),monomerSpacing:Math.max(2,.2*this.props.fontCharWidth)}}shouldUseMultilineRendering(t){return"true"===t.getTag("renderMultiline")}calculateMultiLineLayoutDynamic(t,e,n,i,o,r){const{lineHeight:s,monomerSpacing:a}=this.calculateFontBasedSpacing(t),l=e-2*this.padding;let c=0;const h=[];if(i.length>0)for(let e=o;e<i.length;e++){const n=i.getOriginal(e),o=this.props.monomerToShort(n,r);h.push({text:o,posIdx:e}),c=Math.max(c,t.measureText(o).width)}if(0===h.length)return{lineLayouts:[],lineHeight:s};const u=c;let d=Math.floor((l+a)/(u+a));d=Math.max(1,d);const p=n-2*this.padding,m=Math.max(0,Math.floor(p/s)),f=[];let g=0;for(let t=0;t<m&&g<h.length;t++){const e=[];for(let t=0;t<d&&g<h.length;t++){const n=h[g],i=this.padding+t*(u+a);e.push({posIdx:n.posIdx,x:i,width:u,om:n.text,isSeparator:!1}),g++}f.push({lineIdx:t,elements:e})}return{lineLayouts:f,lineHeight:s}}async init(){await Promise.all([(async()=>{this.seqHelper=await(0,a.Q)(),this.invalidateGrid()})(),(async()=>{const t=await(0,h.pj)();this.sysMonomerLib=t.getMonomerLib()})()]),this.subs.push(this.sysMonomerLib.onChanged.subscribe((()=>{this.reset()}))),this.reset()}static getFontSettings(t){let e=12;return t&&t.temp[".mm.cellRenderer.fontSize"]&&"number"==typeof t.temp[".mm.cellRenderer.fontSize"]&&!isNaN(t.temp[".mm.cellRenderer.fontSize"])&&(e=Math.max(t.temp[".mm.cellRenderer.fontSize"],1)),{font:`${e}px monospace`,fontWidth:.6*e}}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(t,e){const n=this.seqHelper.getSeqHandler(this.tableCol);if(this.colWidth<e&&(this.colWidth=e,this.dirty=!0),this.dirty)try{this.reset()}catch(t){const[e,n]=(0,u.AP)(t);this.logger.error(e,void 0,n)}const i=n.isMsa()?this.getCellMonomerLengthsForSeqMsa():this.getCellMonomerLengthsForSeq(t);return[i,this.getSummedMonomerLengths(i)]}getSummedMonomerLengths(t){const e=new Array(t.length+1);e[0]=this.padding;for(let n=1;n<e.length;n++)e[n]=e[n-1]+t[n-1];let n=e[0];for(let t=1;t<e.length;t++)e[t]?n=e[t]:e[t]=n;return e}getCellMonomerLengthsForSeqValue(t,e){const n=this.seqHelper.getSeqHandler(this.tableCol),i=this.props.separatorWidth+1*this.props.fontCharWidth,o=this.positionShift,r=Math.ceil(e/i)+o,s=n.splitter(t),a=Math.min(r,s.length),l=new Array(a-o);let c=0;for(let t=o;t<a;++t){const i=s.getOriginal(t),r=this.props.monomerToShort(i,this.monomerLengthLimit),a=(n.isSeparator()?this.separatorWidth:this.props.separatorWidth)+r.length*this.props.fontCharWidth;if(l[t-o]=a,c+=a,c>e)break}return l}getCellMonomerLengthsForSeq(t){this.toLog(),null===this._monomerLengthList&&(this._monomerLengthList=new Array(this.tableCol.length).fill(null));const e=this.positionShift,n=this.seqHelper.getSeqHandler(this.tableCol),i=this.props.separatorWidth+1*this.props.fontCharWidth,o=Math.ceil(this.colWidth/i)+e,r=n.getSplitted(t),s=Math.min(o,r.length);let a=this._monomerLengthList[t];if(null===a||a.length!=s-e){a=this._monomerLengthList[t]=new Array(r.length);let i=0;for(let t=e;t<s;++t){const o=r.getOriginal(t),s=this.props.monomerToShort(o,this.monomerLengthLimit),l=(n.isSeparator()?this.separatorWidth:this.props.separatorWidth)+s.length*this.props.fontCharWidth;if(a[t-e]=l,i+=l,i>this.colWidth)break}}return a}getCellMonomerLengthsForSeqMsa(){var t;this.toLog(),null===this._monomerLengthList&&(this._monomerLengthList=new Array(1).fill(null)),(t=this._monomerLengthList)[0]??(t[0]=new Array(0));const e=this._monomerLengthList[0],{startIdx:n,endIdx:i}=(()=>{try{const t=this.gridCol&&this.gridCol.dart?this.gridCol.grid:null;return t&&t.dart?{startIdx:Math.max(Math.floor((t?.vertScroll.min??0)-10),0),endIdx:Math.min(Math.ceil((t?.vertScroll.max??0)+10),this.tableCol.length)}:{startIdx:0,endIdx:Math.min(this.tableCol.length,10)}}catch(t){return{startIdx:0,endIdx:Math.min(this.tableCol.length,10)}}})(),o=this.props.separatorWidth+1*this.props.fontCharWidth,r=this.positionShift,s=Math.ceil(this.colWidth/o)+r;for(let t=n;t<i;t++){if(this._processedRows.get(t)&&s<=this._processedMaxVisibleSeqLength)continue;const n=this.seqHelper.getSeqHandler(this.tableCol).getSplitted(t,s),i=Math.min(s,n.length);i-r>e.length&&e.push(...new Array(i-r-e.length).fill(o));let a=0;for(let t=r;t<i;++t){const i=n.getOriginal(t),o=this.props.monomerToShort(i,this.monomerLengthLimit),s=this.props.separatorWidth+o.length*this.props.fontCharWidth;if(e[t-r]=Math.max(e[t-r]??0,s),a+=s,a>=this.colWidth)break}this._processedMaxVisibleSeqLength=Math.max(this._processedMaxVisibleSeqLength,s),this._processedRows.set(t,!0)}return e}getPosition(t,e,n,i){const[o,r]=this.getCellMonomerLengths(t,n);return 0===this.seqHelper.getSeqHandler(this.tableCol).getSplitted(t).length?null:function(t,e,n){if((n??0)>0&&e<(t[0]??0)+n)return-1;e-=n??0;let i,o=100,r=0,s=t.length-1;for(;r<=s;){if(i=Math.floor((s+r)/2),t[i]<=e&&e<t[i+1])return i;if(e<t[i]?s=i-1:r=i+1,--o<=0)throw new Error(`Get position for pointer x = ${e} searching has not converged on ${JSON.stringify(t)}. `)}return null}(r,e,i)}setMonomerLengthLimit(t){this.monomerLengthLimit!=t&&(this.monomerLengthLimit=t,this.dirty=!0)}setSeparatorWidth(t){this.separatorWidth!=t&&(this.props.separatorWidth=t,this.dirty=!0)}get positionShift(){const t=Number.parseInt(this.tableCol?.tags[l.gp.positionShift]??"0")??0;return isNaN(t)?0:Math.max(t,0)}render(t,e,n,i,r,a,c){const h=a.grid?.canvas===t.canvas;if(!this.seqHelper)return;const m=this.tableCol,f=this.positionShift;t.save();try{const c=this.seqHelper.getSeqHandler(m);let u=this.monomerLengthLimit;if(d.gp.maxMonomerLength in m.tags){const t=parseInt(m.getTag(d.gp.maxMonomerLength));u=!isNaN(t)&&t?t:50}if(m.temp[".mm.cellRenderer.settingsChanged"]===p.s.true||this.monomerLengthLimit!=u){let t=0;const e=8;t=m.temp[".mm.cellRenderer.gapLength"]??t,this.setMonomerLengthLimit(u),this.setSeparatorWidth(c.isMsa()?e:t),m.temp[".mm.cellRenderer.settingsChanged"]=p.s.false}const g=a.cell.rowIndex,b=a.cell.value;h&&(i=v(a.grid,t,e,i,window.devicePixelRatio)),t.beginPath(),t.rect(e,n,i,r),t.clip(),t.font=this.props?.font??"12px monospace",t.textBaseline="top";const w=m.meta.units,C=m.getTag(l.gp.aligned),A=m.getTag(l.gp.separator)??"",S=h?c.getSplitted(g):c.splitter(b);let x=d.yg.classic;C?.includes("MSA")&&w===l.Hi.SEPARATOR&&(x=d.yg.MSA);const E=m.temp["reference-sequence"],M=this.tableCol.temp["current-word"],T=(()=>{const t=(0,c.splitter)(null!=E&&""!==E?E:M??"");return s().count(0).take(t.length).slice(f).map((e=>t.getCanonical(e))).toArray()})(),_=Number.parseInt(m.getTag(l.gp.selectedPosition)??"-200");if(this.shouldUseMultilineRendering(m)&&x!==d.yg.MSA){const s=[],l=this.calculateMultiLineLayoutDynamic(t,i,r,S,f,u);let h=n+this.padding;1===l.lineLayouts.length&&(h=n+(r-l.lineHeight)/2);for(const i of l.lineLayouts){const r=h+i.lineIdx*l.lineHeight;for(const h of i.elements){const u=e+h.x,p=h,g=p.posIdx,b=S.getCanonical(g);let v=y;const w=this.getMonomerLib();w&&(v=w.getMonomerTextColor(c.defaultBiotype,b));let C=0;if(a.tableRowIndex!==m.dataFrame.currentRowIdx&&T.length>0){const t=g-f;t>=0&&t<T.length&&b===T[t]&&(C=.7)}s.push({lineIdx:i.lineIdx,monomerIdx:g-f,bounds:new o.Rect(h.x,r-n,h.width,l.lineHeight),sequencePosition:g}),(0,d.oZ)(t,p.om,u,r,h.width,l.lineHeight,{color:v,isMultiLineContext:!0,transparencyRate:C,selectedPosition:isNaN(_)||_<1?void 0:_,wordIdx:g})}}null!==a.tableRowIndex&&this._cellBounds.set(a.tableRowIndex,s)}else{this._leftThreeDotsPadding=this.shouldRenderShiftedThreeDots(f)?t.measureText("...").width:0;let[,o]=this.getCellMonomerLengths(a.tableRowIndex,i);h||(o=this.getSummedMonomerLengths(this.getCellMonomerLengthsForSeqValue(b,i)));const s=this.props.separatorWidth+1*this.props.fontCharWidth,l=Math.min(S.length,Math.ceil(i/s)+f);for(let s=f;s<l;++s){const l=s<S.length?S.getOriginal(s):c.defaultGapOriginal,h=s<S.length?S.getCanonical(s):c.defaultGapOriginal;let p=y;this.getMonomerLib()&&(p=this.getMonomerLib().getMonomerTextColor(c.defaultBiotype,h));const m={color:p,pivot:0,left:!0,transparencyRate:0,separator:A,last:s===S.length-1,drawStyle:x,maxWord:o,wordIdx:s-f,gridCell:a,referenceSequence:T,maxLengthOfMonomer:u,monomerTextSizeMap:this._monomerLengthMap,logger:this.logger,selectedPosition:isNaN(_)||_<1?void 0:_-f};(0,d.oZ)(t,l,e+this.padding+this._leftThreeDotsPadding,n,i,r,m)}if(this.shouldRenderShiftedThreeDots(f)){const s={color:y,pivot:0,left:!0,transparencyRate:0,separator:A,last:!1,drawStyle:x,maxWord:o,wordIdx:0,gridCell:a,maxLengthOfMonomer:u,monomerTextSizeMap:this._monomerLengthMap,logger:this.logger};(0,d.oZ)(t,"...",e+this.padding,n,i,r,s)}}}catch(t){const[e,n]=(0,u.AP)(t);this.logger.error(e,void 0,n),this.errors.push(t)}finally{t.restore()}}shouldRenderShiftedThreeDots(t){return t>0&&(!this.gridCol||!this.gridCol.dart||!this.gridCol.grid||!this.gridCol.grid.dart||(this.gridCol.grid.props.colHeaderHeight??0)<=50)}onMouseMove(t,e){const n=`${this.toLog()}.onMouseMove()`;if(!this.seqHelper||null==t.tableRowIndex)return;const o=this.positionShift,r=t.bounds,s=e.offsetX-t.gridColumn.left+(t.gridColumn.left-r.x),a=e.offsetY-r.y;this.gridCol?.grid?.canvas&&(this.gridCol.grid.canvas.style.cursor="default");let c=null;const h=this._cellBounds.get(t.tableRowIndex);if(h){for(const t of h)if(t.bounds.contains(s,a)){c=t.monomerIdx;break}}else{const e=this.shouldRenderShiftedThreeDots(o)&&(this._leftThreeDotsPadding??0)>0?this._leftThreeDotsPadding:0;c=this.getPosition(t.tableRowIndex,s,r.width,e)}this.logger.debug(`${n}, argsX: ${s}, argsY: ${a}, left: ${c}`);const u=this.seqHelper.getSeqHandler(this.tableCol),d=u.getSplitted(t.tableRowIndex);if(null!==c&&c>=0&&c+o<d.length){const n=u.alphabet??l.YI.UN,r={position:c,biotype:n===l.YI.RNA||n===l.YI.DNA?m.o.NUCLEOTIDE:m.o.AA,symbol:d.getCanonical(c+o)},s=[];let a=this._monomerStructureMap[r.symbol];if(!a){const t=this.getMonomerLib();a=this._monomerStructureMap[r.symbol]=t?t.getTooltip(r.biotype,r.symbol):i.divText("Monomer library is not available")}s.push(a),i.tooltip.show(i.divV(s),e.x+16,e.y+16),(0,f.WN)(t,r)}else-1===c?i.tooltip.show(i.divText(`${Math.min(o,d.length)} hidden monomers`),e.x+16,e.y+16):i.tooltip.hide(),(0,f.WN)(t,null)}}function v(t,e,n,i,o){return t?Math.max(Math.min(t.canvas.width/o-n,i)):Math.max(e.canvas.width/o-n,0)}},3856:(t,e,n)=>{"use strict";n.d(e,{Mn:()=>h,gp:()=>c,oZ:()=>p,yg:()=>u});var i=n(6082),o=n(7278);const r="rgb(100,100,100)",s="#808080",a="rgb(0,0,0)",l=o.zS;var c,h,u;!function(t){t.maxMonomerLength=".mm.cellRenderer.maxMonomerLength"}(c||(c={})),function(t){t.applyToBackground=".m.cellRenderer.applyToBackground"}(h||(h={})),function(t){t.MSA="MSA",t.classic="classic"}(u||(u={}));const d=new class{constructor(){this.color=r,this.pivot=0,this.left=!1,this.transparencyRate=0,this.separator="",this.last=!1,this.drawStyle=u.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(t,e,n,o,c,h,p){var m,f,g;const y={...d,...p};if(y.isMultiLineContext){t.textBaseline="middle",t.textAlign="center";let i=e;null!=y.maxLengthOfMonomer&&(i=l(i,y.maxLengthOfMonomer));const s=Math.max(.1,1-(y.transparencyRate??0));t.globalAlpha=s;const u=t.measureText(i),d=u.fontBoundingBoxAscent+u.fontBoundingBoxDescent,p=o+(h-d)/2+u.fontBoundingBoxAscent;let m=y.color??r;return m&&m!==r||(m=a),t.fillStyle=m,y.selectedPosition===y.wordIdx+1&&(t.save(),t.fillStyle="rgba(60, 177, 115, 0.2)",t.fillRect(n,o,c,h),t.restore(),t.fillStyle=m),t.fillText(i,n+c/2,p),t.globalAlpha=1,t.textBaseline="top",t.textAlign="start",n+c}p.logger?.debug("Bio: printLeftOrCentered(), start"),t.textAlign="start";let b=e.substring(0),v=y.last?"":y.separator;y.drawStyle===u.MSA&&(v="");let w=!0,C=!0,A="difference";if(null!=y.gridCell&&null!=y.gridCell.cell.column&&(w=y.gridCell.cell.column.temp["color-code"]??!0,C=y.gridCell.cell.column.temp["compare-with-current"]??!0,A=y.gridCell.cell.column.temp["highlight-difference"]??"difference"),y.referenceSequence){const t=y.referenceSequence[y.wordIdx];C&&y.referenceSequence.length>0&&"difference"===A&&(y.transparencyRate=b==t?.7:y.transparencyRate),C&&y.referenceSequence.length>0&&"equal"===A&&(y.transparencyRate=b!=t?.7:y.transparencyRate)}null!=y.maxLengthOfMonomer&&(b=l(b,y.maxLengthOfMonomer));const S=b+v;(m=y.monomerTextSizeMap)[S]??(m[S]=t.measureText(S));let x=y.monomerTextSizeMap[S];(f=y.monomerTextSizeMap)[b]??(f[b]=t.measureText(b));let E=y.monomerTextSizeMap[b].width;const M=h/2-(x.fontBoundingBoxAscent+x.fontBoundingBoxDescent)/2+1;(g=y.monomerTextSizeMap)[v]??(g[v]=t.measureText(v));const T=y.monomerTextSizeMap[v].width;function _(e,r){let l=w?y.color:a;y.selectedPosition===y.wordIdx+1&&(t.fillStyle="rgba(60, 177, 115, 0.2)",t.fillRect(n+e-4,o-5,y.monomerTextSizeMap[b].width+8,h+10),l=i.Color.toHtml(i.Color.setAlpha(i.Color.fromHtml(l),255))),t.fillStyle=l,t.globalAlpha=1-y.transparencyRate,y.drawStyle===u.classic&&(t.fillText(b,n+e,o+M),t.fillStyle=s,t.fillText(v,n+r,o+M)),y.drawStyle===u.MSA&&t.fillText(b,n+e,o+M),t.globalAlpha=1}x=x.width,y.drawStyle===u.MSA&&(E=y.maxWord[y.wordIdx],x=y.maxWord[y.wordIdx]);const I=(y.maxWord[y.wordIdx]??0)-(y.maxWord[0]??0);if(y.left||x>c)return _(I,I+E),n+I+E+T;{const t=(c-x)/2;return _(t,t+E),n+I+t+E}}},6307:(t,e,n)=>{"use strict";n.d(e,{F:()=>s});var i=n(7389),o=n(6082),r=n(439);function s(t,e,n){let s=0,a=null;for(const e of Object.values(t))s+=e,a=null===a?e:Math.max(a,e);const l=a/s,c=Object.assign({},...Array.from(Object.entries(t)).sort(((t,e)=>e[1]-t[1])).map((([t,a])=>{const c=a/s;let h;try{const i=n.getMonomerColors(e,t);h=i?.backgroundcolor||"#CCCCCC"}catch(e){console.warn(`Failed to get colors for monomer ${t}:`,e),h="#CCCCCC"}const u=i.div("",{classes:"macromolecule-cell-comp-analysis-bar"});u.style.width=50*c/l+"px",u.style.backgroundColor=h,r._S===t&&(u.style.borderWidth="1px",u.style.borderStyle="solid",u.style.borderColor=o.Color.toHtml(o.Color.lightGray));const d=r._S===t?"-":t,p=i.div(`${(100*c).toFixed(2)}%`),m=i.div([u,p],{classes:"macromolecule-cell-comp-analysis-value"});return{[d]:m}}))),h=i.tableFromMap(c);return Array.from(h.rows).forEach((t=>{const e=t.getElementsByClassName("macromolecule-cell-comp-analysis-bar")[0].style.backgroundColor;t.cells[0].style.color=e})),h}},3151:(t,e,n)=>{"use strict";n.d(e,{EK:()=>l,Ec:()=>r,f6:()=>i,pe:()=>s,q7:()=>a,yw:()=>o});const i=["symbol","molfile","rgroups","name"],o="MonomerName",r={monomerType:null,smiles:null,name:"Name",author:null,molfile:"molecule",naturalAnalog:"MonomerNaturalAnalogCode",rgroups:"MonomerCaps",createDate:null,id:null,polymerType:"MonomerType",symbol:"MonomerName"},s={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:(t,e,n)=>{"use strict";function i(t){return"string"==typeof t||t instanceof String?t:"StateError"===t.constructor.name?t.message:"StateError"===t.constructor.name&&"$thrownJsError"in t?i(t.$thrownJsError):t instanceof Error?t.message:t.toString()}function o(t){return t instanceof Error?t.stack:"StateError"===t.constructor.name&&"$thrownJsError"in t?o(t.$thrownJsError):void 0}function r(t){return[i(t),o(t)]}n.d(e,{AP:()=>r})},3516:(t,e,n)=>{"use strict";n.d(e,{m:()=>r});var i=n(6082),o=n(439);class r{get descriptionsArray(){return this._descriptionsArray}get sequencesArray(){return this._sequencesArray}parseMacromolecule(t,e){return this._fileContent.slice(t,e).split(/\s/).join("")}parseColumns(){const t=/^>(.*)$/gm;let e,n=0;for(;e=t.exec(this._fileContent);){const i=this._fileContent.substring(e.index+1,t.lastIndex);this._descriptionsArray.push(i),0!==n&&this._sequencesArray.push(this.parseMacromolecule(n,e.index)),n=t.lastIndex+1}this._sequencesArray.push(this.parseMacromolecule(n,-1))}importFasta(){const t=i.Column.fromStrings("description",this.descriptionsArray),e=i.Column.fromStrings("sequence",this.sequencesArray);return e.semType=i.SEMTYPE.MACROMOLECULE,e.meta.units=o.Hi.FASTA,[i.DataFrame.fromColumns([t,e])]}constructor(t){this._descriptionsArray=[],this._sequencesArray=[],this._fileContent=t,this.parseColumns()}}},6873:(t,e,n)=>{"use strict";n.d(e,{Hx:()=>h,dW:()=>c});var i=n(6082),o=n(1991),r=n.n(o),s=n(2003),a=n(7278),l=n(439);function c(t=10**5){const e="meI/hHis/Aca/N//dE/Thr_PO3H2/Aca/D-Tyr_Et/Tyr_ab-dehydroMe".repeat(Math.ceil(t/10)).slice(0,-1),n=i.Column.fromList(i.COLUMN_TYPE.STRING,"MSA",new Array(100).fill(e));n.semType=i.SEMTYPE.MACROMOLECULE,n.meta.units=s.Hi.SEPARATOR,n.setTag(s.gp.separator,"/"),n.setTag(s.gp.alphabet,s.YI.UN),n.setTag(s.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(t,e=s.Hi.SEPARATOR,n=s.YI.PT,o=(e===s.Hi.SEPARATOR?"-":void 0),c=void 0,h="seq",u=100,d=10**6){const p=n===s.YI.UN?c?.getMonomerSymbolsByType("PEPTIDE")??[]:Array.from((0,s.Qf)(n)),m=p.length,f=i.Column.fromType(i.COLUMN_TYPE.STRING,h,u);f.semType=i.SEMTYPE.MACROMOLECULE,f.meta.units=e,f.setTag(s.gp.alphabet,n),e==s.Hi.SEPARATOR&&f.setTag(s.gp.separator,o);const g=t.getSeqHandler(f);for(let t=0;t<u;t++){const n=r().count(0).take(d).map((t=>p[Math.floor(Math.random()*m)])).toArray(),i=g.joiner(new a.Mu(n,l.b9[e]));f.set(t,i)}return f}},439:(t,e,n)=>{"use strict";n.d(e,{B5:()=>l,Hi:()=>i,Vl:()=>c,YI:()=>o,_S:()=>u,b9:()=>d,gp:()=>r,q7:()=>h,z1:()=>a});var i,o,r,s=n(2738);!function(t){t.FASTA="fasta",t.SEPARATOR="separator",t.HELM="helm",t.CUSTOM="custom"}(i||(i={})),function(t){t.DNA="DNA",t.RNA="RNA",t.PT="PT",t.UN="UN"}(o||(o={})),function(t){t.aligned="aligned",t.alphabet="alphabet",t.alphabetSize=".alphabetSize",t.alphabetIsMultichar=".alphabetIsMultichar",t.separator="separator",t.isHelmCompatible=".isHelmCompatible",t.positionNames=".positionNames",t.positionLabels=".positionLabels",t.regions=".regions",t.positionShift=".positionShift",t.selectedPosition=".selectedPosition"}(r||(r={}));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"])}}},h=[new s.a(o.PT,c.fasta.peptide,.5),new s.a(o.DNA,c.fasta.dna,.55),new s.a(o.RNA,c.fasta.rna,.55)],u="",d={[i.FASTA]:"-",[i.SEPARATOR]:"",[i.HELM]:"*"}},2003:(t,e,n)=>{"use strict";n.d(e,{Hi:()=>i.Hi,J9:()=>o.J9,Qf:()=>o.Qf,YI:()=>i.YI,dh:()=>o.dh,gp:()=>i.gp,mn:()=>o.mn,q7:()=>i.q7,qp:()=>o.qp,z1:()=>i.z1,zS:()=>o.zS});var i=n(439),o=n(7278)},2738:(t,e,n)=>{"use strict";n.d(e,{X:()=>o,a:()=>i});class i{constructor(t,e,n){this.name=t,this.alphabet=e,this.cutoff=n}}class o extends i{constructor(t,e,n){super(t.name,t.alphabet,t.cutoff),this.freq=e,this.similarity=n}}},7278:(t,e,n)=>{"use strict";n.d(e,{Iv:()=>y,J9:()=>p,Mu:()=>u,Qf:()=>w,dh:()=>f,mn:()=>S,p0:()=>A,pc:()=>C,qp:()=>g,tm:()=>m,zS:()=>v});var i=n(6082),o=n(1991),r=n.n(o),s=n(3527),a=n(3629),l=n(2738),c=n(439),h=(n(8924),n(1093),n(4152),n(8438));class u{get length(){return this.mList.length}isGap(t){return this.getOriginal(t)===this.gapOriginalMonomer}getCanonical(t){if(this.length<=t)throw new Error("Index out of bounds");const e=this.mList[t];return e!==this.gapOriginalMonomer?e:c._S}getOriginal(t){if(this.length<=t)throw new Error("Index out of bounds");return this.mList[t]}getCanonicalRegion(t,e){const n=Math.min(Math.max(0,t),this.length),i=Math.max(Math.min(this.length,e),0)-n,o=this.gapOriginalMonomer;return new Array(i).fill(null).map(((t,e)=>{const i=this.mList[e+n];return i===o?c._S:i}))}getOriginalRegion(t,e){const n=Math.min(Math.max(0,t),this.length),i=Math.max(Math.min(this.length,e),0);return new Array(i-n).fill(null).map(((t,e)=>this.mList[e+n]))}get gapOriginal(){return this.gapOriginalMonomer}constructor(t,e){this.mList=t,this.gapOriginalMonomer=e}}class d{get length(){return this.seqS.length}isGap(t){return this.getOriginal(t)===c.b9[c.Hi.FASTA]}getCanonical(t){if(this.length<=t)throw new Error("Index out of bounds");return this.isGap(t)?c._S:this.seqS[t]}getOriginal(t){if(this.length<=t)throw new Error("Index out of bounds");return this.seqS[t]}getCanonicalRegion(t,e){const n=Math.max(0,t),i=Math.min(this.length,e)-n,o=c.b9[c.Hi.FASTA];return new Array(i).fill(null).map(((t,e)=>{const i=this.seqS[e+n];return i===o?c._S:i}))}getOriginalRegion(t,e){const n=Math.max(0,t),i=Math.min(this.length,e);return this.seqS.slice(n,i)}get gapOriginal(){return c.b9[c.Hi.FASTA]}constructor(t){this.seqS=t}}const p=t=>{const e=r()(t.toString().matchAll(c.B5)).map((t=>t[2]??t[1])).toArray();return new u(e,c.b9[c.Hi.FASTA])},m=t=>t?new d(t):new u([],c.b9[c.Hi.FASTA]);function f(t,e=void 0){return n=>{if(n){let i;const o=new RegExp(`(?<=^|\\${t})("-"|'-'|[^\\${t}]*)(?=\\${t}|$)`,"g");return void 0!==e?(o.lastIndex=0,i=r()(n.matchAll(o)).take(e).map((t=>t[0])).toArray()):i=n.replaceAll('"-"',"").replaceAll("'-'","").split(t,e),new u(i,c.b9[c.Hi.SEPARATOR])}return new u([],c.b9[c.Hi.SEPARATOR])}}const g=t=>{const e=t.split("$")[0].split("|"),n=r()(e.map((t=>(t.match(/(?<=\{).+(?=})/)?.[0]?.split(".")??[]).map((t=>(0,h.D)(t)))))).flatten().toArray();return new u(n,c.b9[c.Hi.HELM])};function y(t,e,n=void 0){if(t.toLowerCase().startsWith(c.Hi.FASTA))return p;if(t.toLowerCase().startsWith(c.Hi.SEPARATOR))return f(e,n);if(t.toLowerCase().startsWith(c.Hi.HELM))return g;throw new Error(`Unexpected units ${t} .`)}const b=/([^\W_]+)/g;function v(t,e){if(t.length<=e)return t;const n=t.match(b),i=t.length>e||(n?.length??0)>1,o=n?.[0]??" ";return i?o.substring(0,e-1)+"…":o}function w(t){switch(t){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 '${t}'.`)}}function C(t,e,n="-"){const i=e.map((e=>{const i=function(t,e,n="-"){const i=new Set([...new Set(Object.keys(t)),...e]);i.delete(n);const o=[],r=[];for(const n of i)o.push(n in t?t[n]:0),r.push(e.has(n)?1:0);const l=new s.Mi(o),c=new s.Mi(r);return(0,a.KE)(l,c)/((0,a.wQ)(l)*(0,a.wQ)(c))}(t,e.alphabet,n);return new l.X(e,t,i)}));let o;const r=Math.max(...i.map((t=>t.similarity>t.cutoff?t.similarity:-1)));return o=r>0?i.find((t=>t.similarity===r)).name:c.YI.UN,o}function A(t,e,n="-"){const i=Object.keys(t),o=/\(|\)/;return C(i.filter((t=>3===t.split(o).filter((t=>!!t)).length)).length>.8*i.length?Object.entries(t).reduce(((t,[e,n])=>{const i=e.split(o)[1];return i&&(t[i]=n),t}),{}):t,e,n)}function S(t){const e=t.columns.bySemTypeAll(i.SEMTYPE.MACROMOLECULE);let n=e.find((t=>{const e=t.meta.units;return!!e&&-1!==e.indexOf("MSA")}))??null;return!n&&e.length>0&&(n=e[0]),n}},8312:(t,e,n)=>{"use strict";n.d(e,{Q:()=>o});var i=n(6082);async function o(){const t=i.Func.find({package:"Bio",name:"getSeqHelper"});if(0===t.length)throw new Error("Package 'Bio' must be installed for SeqHelper.");return(await t[0].prepare().call()).getOutputParamValue()}},3077:(t,e,n)=>{"use strict";n.d(e,{R:()=>o});var i=n(6082);function o(t,e){const n=t=>{const e=s.columns.addNewString((t+1).toString());return o.push(e),e},o=[],r=t.length,s=i.DataFrame.create(r),a=e.getSeqHandler(t);for(let t=0;t<r;++t){const e=a.getSplitted(t);for(let i=0;i<e.length;++i){const r=e.getCanonical(i);((o[i]??null)||n(i)).set(t,r,!1)}}return s}},7602:(t,e,n)=>{"use strict";n.d(e,{g:()=>r});var i,o=n(9192);!function(t){t[t.error=0]="error",t[t.warning=1]="warning",t[t.info=2]="info",t[t.debug=3]="debug"}(i||(i={}));class r{constructor(t){this.logger=t,this.promise=Promise.resolve(),this.errors=[],this.syncCounter=0}sync(t,e){const n=++this.syncCounter;this.logger.debug(`${t}, SYNC syncId = ${n}, IN `),this.promise=this.promise.then((async()=>{this.logger.debug(`${t}, SYNC syncId = ${n}, START `),await e(),this.logger.debug(`${t}, SYNC syncId = ${n}, END `)})).catch((e=>{const[i,r]=(0,o.AP)(e);this.logger.error(`${t}, SYNC syncId = ${n}, ERROR:\n${i}`,void 0,r),this.errors.push(e)}))}resetErrors(){const t=this.errors;return this.errors=[],t}}},4326:(t,e,n)=>{"use strict";n.d(e,{Fo:()=>h,Lp:()=>r,P4:()=>s,fH:()=>o,gp:()=>i,lT:()=>l,mH:()=>a});var i,o,r,s,a,l,c=n(6082);!function(t){t.tooltipWebLogo=".tooltipWebLogo"}(i||(i={})),function(t){t.Entropy="Entropy",t.full="100%"}(o||(o={})),function(t){t.TOP="top",t.MIDDLE="middle",t.BOTTOM="bottom"}(r||(r={})),function(t){t.LEFT="left",t.CENTER="center",t.RIGHT="right"}(s||(s={})),function(t){t.AUTO="auto",t.ON="on",t.OFF="off"}(a||(a={})),function(t){t.Filtered="Filtered",t.Selected="Selected"}(l||(l={}));const h=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=r.MIDDLE,this.horizontalAlignment=s.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:(t,e,n)=>{"use strict";var i;n.d(e,{o:()=>i}),function(t){t.BASE="HELM_BASE",t.SUGAR="HELM_SUGAR",t.LINKER="HELM_LINKER",t.AA="HELM_AA",t.CHEM="HELM_CHEM",t.BLOB="HELM_BLOB",t.NUCLEOTIDE="HELM_NUCLETIDE"}(i||(i={}))},5540:(t,e,n)=>{"use strict";t=n.hmd(t);var i,o=(i="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0,function(t={}){var e,n,o=void 0!==t?t:{};o.ready=new Promise((function(t,i){e=t,n=i}));var r,s=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&&(r=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)})),o.print||console.log.bind(console);var h,u,d=o.printErr||console.warn.bind(console);Object.assign(o,s),s=null,o.arguments&&o.arguments,o.thisProgram&&o.thisProgram,o.quit&&o.quit,o.wasmBinary&&(h=o.wasmBinary),o.noExitRuntime,"object"!=typeof WebAssembly&&M("no native wasm support detected");var p,m,f,g=!1;function y(){var t=u.buffer;o.HEAP8=p=new Int8Array(t),o.HEAP16=new Int16Array(t),o.HEAP32=new Int32Array(t),o.HEAPU8=m=new Uint8Array(t),o.HEAPU16=new Uint16Array(t),o.HEAPU32=f=new Uint32Array(t),o.HEAPF32=new Float32Array(t),o.HEAPF64=new Float64Array(t)}var b,v,w=[],C=[],A=[],S=0,x=null,E=null;function M(t){o.onAbort&&o.onAbort(t),d(t="Aborted("+t+")"),g=!0,t+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(t);throw n(e),e}function T(t){return t.startsWith("data:application/octet-stream;base64,")}function _(t){try{if(t==b&&h)return new Uint8Array(h);if(r)return r(t);throw"both async and sync fetching of the wasm failed"}catch(t){M(t)}}function I(t,e,n){return function(t){return h||!a&&!l||"function"!=typeof fetch?Promise.resolve().then((function(){return _(t)})):fetch(t,{credentials:"same-origin"}).then((function(e){if(!e.ok)throw"failed to load wasm binary file at '"+t+"'";return e.arrayBuffer()})).catch((function(){return _(t)}))}(t).then((function(t){return WebAssembly.instantiate(t,e)})).then((function(t){return t})).then(n,(function(t){d("failed to asynchronously prepare wasm: "+t),M(t)}))}function L(t){for(;t.length>0;)t.shift()(o)}function N(t){this.excPtr=t,this.ptr=t-24,this.set_type=function(t){f[this.ptr+4>>2]=t},this.get_type=function(){return f[this.ptr+4>>2]},this.set_destructor=function(t){f[this.ptr+8>>2]=t},this.get_destructor=function(){return f[this.ptr+8>>2]},this.set_caught=function(t){t=t?1:0,p[this.ptr+12|0]=t},this.get_caught=function(){return 0!=p[this.ptr+12|0]},this.set_rethrown=function(t){t=t?1:0,p[this.ptr+13|0]=t},this.get_rethrown=function(){return 0!=p[this.ptr+13|0]},this.init=function(t,e){this.set_adjusted_ptr(0),this.set_type(t),this.set_destructor(e)},this.set_adjusted_ptr=function(t){f[this.ptr+16>>2]=t},this.get_adjusted_ptr=function(){return f[this.ptr+16>>2]},this.get_exception_ptr=function(){if(D(this.get_type()))return f[this.excPtr>>2];var t=this.get_adjusted_ptr();return 0!==t?t:this.excPtr}}function P(t){var e=u.buffer;try{return u.grow(t-e.byteLength+65535>>>16),y(),1}catch(t){}}function $(t){return o["_"+t]}T(b="wasmDbscan.wasm")||(v=b,b=o.locateFile?o.locateFile(v,c):c+v);var R="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function k(t,e,n,i,o){var r={string:t=>{var e=0;return null!=t&&0!==t&&(e=function(t){var e=function(t){for(var e=0,n=0;n<t.length;++n){var i=t.charCodeAt(n);i<=127?e++:i<=2047?e+=2:i>=55296&&i<=57343?(e+=4,++n):e+=3}return e}(t)+1,n=B(e);return function(t,e,n){!function(t,e,n,i){if(!(i>0))return 0;for(var o=n+i-1,r=0;r<t.length;++r){var s=t.charCodeAt(r);if(s>=55296&&s<=57343&&(s=65536+((1023&s)<<10)|1023&t.charCodeAt(++r)),s<=127){if(n>=o)break;e[n++]=s}else if(s<=2047){if(n+1>=o)break;e[n++]=192|s>>6,e[n++]=128|63&s}else if(s<=65535){if(n+2>=o)break;e[n++]=224|s>>12,e[n++]=128|s>>6&63,e[n++]=128|63&s}else{if(n+3>=o)break;e[n++]=240|s>>18,e[n++]=128|s>>12&63,e[n++]=128|s>>6&63,e[n++]=128|63&s}}e[n]=0}(t,m,e,n)}(t,n,e),n}(t)),e},array:t=>{var e,n,i=B(t.length);return e=t,n=i,p.set(e,n),i}},s=$(t),a=[],l=0;if(i)for(var c=0;c<i.length;c++){var h=r[n[c]];h?(0===l&&(l=G()),a[c]=h(i[c])):a[c]=i[c]}var u=s.apply(null,a);return function(t){return 0!==l&&F(l),function(t){return"string"===e?(n=t)?function(t,e,n){for(var i=e+n,o=e;t[o]&&!(o>=i);)++o;if(o-e>16&&t.buffer&&R)return R.decode(t.subarray(e,o));for(var r="";e<o;){var s=t[e++];if(128&s){var a=63&t[e++];if(192!=(224&s)){var l=63&t[e++];if((s=224==(240&s)?(15&s)<<12|a<<6|l:(7&s)<<18|a<<12|l<<6|63&t[e++])<65536)r+=String.fromCharCode(s);else{var c=s-65536;r+=String.fromCharCode(55296|c>>10,56320|1023&c)}}else r+=String.fromCharCode((31&s)<<6|a)}else r+=String.fromCharCode(s)}return r}(m,n,i):"":"boolean"===e?Boolean(t):t;var n,i}(t)}(u)}var O,H={__cxa_throw:function(t,e,n){throw new N(t).init(e,n),t},abort:function(){M("")},emscripten_memcpy_big:function(t,e,n){m.copyWithin(t,e,e+n)},emscripten_resize_heap:function(t){var e,n=m.length,i=2147483648;if((t>>>=0)>i)return!1;for(var o=1;o<=4;o*=2){var r=n*(1+.2/o);if(r=Math.min(r,t+100663296),P(Math.min(i,(e=Math.max(t,r))+(65536-e%65536)%65536)))return!0}return!1}},G=(function(){var t,e,i,r,s={env:H,wasi_snapshot_preview1:H};function a(t,e){var n,i=t.exports;return o.asm=i,u=o.asm.memory,y(),o.asm.__indirect_function_table,n=o.asm.__wasm_call_ctors,C.unshift(n),function(){if(S--,o.monitorRunDependencies&&o.monitorRunDependencies(S),0==S&&(null!==x&&(clearInterval(x),x=null),E)){var t=E;E=null,t()}}(),i}if(S++,o.monitorRunDependencies&&o.monitorRunDependencies(S),o.instantiateWasm)try{return o.instantiateWasm(s,a)}catch(t){d("Module.instantiateWasm callback failed with error: "+t),n(t)}(t=h,e=b,i=s,r=function(t){a(t.instance)},t||"function"!=typeof WebAssembly.instantiateStreaming||T(e)||"function"!=typeof fetch?I(e,i,r):fetch(e,{credentials:"same-origin"}).then((function(t){return WebAssembly.instantiateStreaming(t,i).then(r,(function(t){return d("wasm streaming compile failed: "+t),d("falling back to ArrayBuffer instantiation"),I(e,i,r)}))}))).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(G=o.asm.stackSave).apply(null,arguments)}),F=function(){return(F=o.asm.stackRestore).apply(null,arguments)},B=function(){return(B=o.asm.stackAlloc).apply(null,arguments)},D=function(){return(D=o.asm.__cxa_is_pointer_type).apply(null,arguments)};function V(){function t(){O||(O=!0,o.calledRun=!0,g||(L(C),e(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),function(){if(o.postRun)for("function"==typeof o.postRun&&(o.postRun=[o.postRun]);o.postRun.length;)t=o.postRun.shift(),A.unshift(t);var t;L(A)}()))}S>0||(function(){if(o.preRun)for("function"==typeof o.preRun&&(o.preRun=[o.preRun]);o.preRun.length;)t=o.preRun.shift(),w.unshift(t);var t;L(w)}(),S>0||(o.setStatus?(o.setStatus("Running..."),setTimeout((function(){setTimeout((function(){o.setStatus("")}),1),t()}),1)):t()))}if(o.ccall=k,o.cwrap=function(t,e,n,i){var o=!n||n.every((t=>"number"===t||"boolean"===t));return"string"!==e&&o&&!i?$(t):function(){return k(t,e,n,arguments)}},E=function t(){O||V(),O||(E=t)},o.preInit)for("function"==typeof o.preInit&&(o.preInit=[o.preInit]);o.preInit.length>0;)o.preInit.pop()();return V(),t.ready});"object"==typeof exports?t.exports=o:"function"==typeof define&&n.amdO?define([],(function(){return o})):"object"==typeof exports&&(exports.exportCppDbscanLib=o)},6295:(t,e,n)=>{"use strict";n.d(e,{$1:()=>s,Hf:()=>h,Hr:()=>E,Ii:()=>g,Qj:()=>m,T6:()=>x,TK:()=>A,be:()=>f,gt:()=>v,ij:()=>w,jL:()=>c,lO:()=>p,lP:()=>b,rR:()=>y,tO:()=>a,v_:()=>l,w_:()=>u,yK:()=>C,zn:()=>d});var i=n(8774),o=n(8498),r=n(6863);function s(t,e){const n=t.trueCount()+e.trueCount();if(0==n)return 1;const i=t.andWithCountBits(e,!0);return i/(n-i)}function a(t,e){return 1-s(t,e)}function l(t,e){return S(s(new i.A(t,32*t.length),new i.A(e,32*e.length)))}function c(t,e){let n=0;for(let i=0;i<t.length;i++)n+=Math.pow(t[i]-e[i],2);return Math.sqrt(n)}function h(t,e){let n=0;for(let i=0;i<t.length;i++)n+=Math.abs(t[i]-e[i]);return n}function u(t,e){let n=0,i=0,o=0;for(let r=0;r<t.length;r++)n+=t[r]*e[r],i+=t[r]*t[r],o+=e[r]*e[r];return(1-n/(Math.sqrt(i)*Math.sqrt(o)))/2}function d(t,e){return 1-function(t,e){const n=t.trueCount()+e.trueCount();return 0==n?0:2*t.andWithCountBits(e,!0)/n}(t,e)}function p(t,e){return 1-function(t,e){const n=t.trueCount()*e.trueCount();return 0==n?0:t.andWithCountBits(e,!0)/Math.sqrt(n)}(t,e)}function m(t,e){return Math.sqrt(t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0))}function f(t,e){return t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0)}function g(t,e){return 1-function(t,e){const n=t.trueCount()+e.trueCount(),i=t.andWithCountBits(e,!0);return i/(2*n-3*i)}(t,e)}function y(t,e){return S(function(t,e){const n=t.trueCount()+e.trueCount(),i=t.trueCount()*e.trueCount();return 0==i?0:t.andWithCountBits(e,!0)*n/(2*i)}(t,e))}function b(t,e){return S(function(t,e){const n=t.trueCount()+e.trueCount(),i=t.trueCount()*e.trueCount();return 0==i?0:(t.andWithCountBits(e,!0)*n-i)/i}(t,e))}function v(t,e){return 1-function(t,e){const n=Math.min(t.trueCount(),e.trueCount());return 0==n?0:t.andWithCountBits(e,!0)/n}(t,e)}function w(t,e){return S(function(t,e){const n=Math.max(t.trueCount(),e.trueCount());return 0==n?0:t.andWithCountBits(e,!0)/n}(t,e))}function C(t,e){return S(function(t,e){return 0==t.length?0:t.andWithCountBits(e,!0)/t.length}(t,e))}function A(t,e){return S(function(t,e){const n=t.andWithCountBits(e,!0),i=t.countBits(!0)+e.countBits(!0),o=t.length,r=o-i+n;return n==o||r==o?1:n/i+r/(2*o-i)}(t,e))}function S(t){return t<=0?3402823e32:1/t-1}function x(t){if(t&&null!=t.range&&t.range>0){const e=t.range;return(t,n)=>Math.abs(t-n)/e}return(t,e)=>Math.abs(t-e)}function E(t){const e=function(t){const e=t?.mostCommon??new Set;return(t,n)=>{const i=t.length,o=n.length;let r=0,s=0,a=0;for(;s<i&&a<o;)t[s]===n[a]?(e?.has(t[s])||++r,++s,++a):t[s]<n[a]?++s:++a;return r}}(t);return(t,n)=>0===n.length||0===t.length?1e4:Math.min(t.length,n.length)/(e(t,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,r.Z.HAMMING,r.Z.LEVENSHTEIN,r.Z.MONOMER_CHEMICAL_DISTANCE,r.Z.NEEDLEMANN_WUNSCH},684:(t,e,n)=>{"use strict";n.d(e,{C0:()=>r,GP:()=>i,Gi:()=>a,YP:()=>c,_X:()=>s,n3:()=>o,vb:()=>l});const i="dim-red-preprocessing-function",o="supportedSemTypes",r="supportedTypes",s="supportedUnits",a="supportedDistanceFunctions",l="bypassLargeDataWarning",c="show-scatterplot-progress"},6863:(t,e,n)=>{"use strict";function i(t={}){const e=function(){if(!t||!t.scoringMatrix||!t.alphabetIndexes)return(t,e)=>t===e?0:1;if(t.scoringMatrix.length!==Object.keys(t.alphabetIndexes).length)throw new Error("Scoring matrix and alphabet indexes should have the same length");const e=t.alphabetIndexes,n=t.scoringMatrix,i=Math.min(...Object.keys(e).map((t=>t.charCodeAt(0))))+1,o=new Float32Array((n.length+i)*(n.length+i));return Object.entries(e).forEach((([t,i])=>{const r=n[i];Object.entries(e).forEach((([e,i])=>{o[t.charCodeAt(0)*n.length+e.charCodeAt(0)]=r[i]}))})),(t,e)=>1-o[t.charCodeAt(0)*n.length+e.charCodeAt(0)]}(),n=t?.threshold??0;return(t,i)=>{let o=0;const r=t.length,s=i.length,a=Math.ceil(Math.max(r,s)*(1-n));r!==s&&(o=Math.abs(r-s));let l=0;for(let n=0;n<Math.min(r,s);n++)if(t[n]!==i[n]&&(l+=e(t[n],i[n]),l>a))return 1;return l+=o,l/=Math.max(r,s),l}}n.d(e,{Z:()=>s,V:()=>a});var o=n(2787);const r={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 s;!function(t){t.HAMMING="Hamming",t.LEVENSHTEIN="Levenshtein",t.NEEDLEMANN_WUNSCH="Needlemann-Wunsch",t.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance"}(s||(s={}));const a={[s.HAMMING]:i,[s.LEVENSHTEIN]:function(){return(t,e)=>(0,o.I)(t,e)/Math.max(t.length,e.length)},[s.NEEDLEMANN_WUNSCH]:function(t){const e=new Uint16Array(65536),{gapOpen:n,gapExtend:i,scoringMatrix:o,alphabetIndexes:s}={...r,...t};Object.entries(s).forEach((([t,n])=>e[t.charCodeAt(0)]=n));const a=[new Float32Array(1e4),new Float32Array(1e4)];return(t,r)=>{const s=new Array(t.length+1).fill(!1),l=new Array(t.length+1).fill(!1);let c=0,h=1;for(let e=1;e<t.length+1;e++)a[0][e]=-i-(e-1)*i,a[1][e]=0;a[0][0]=0;for(let u=1;u<r.length+1;u++){a[h][0]=-i-(u-1)*i;for(let d=1;d<t.length+1;d++){const p=a[c][d-1]+o[e[t.charCodeAt(d-1)]][e[r.charCodeAt(u-1)]],m=a[c][d]-(s[d]||1===u||u===r.length?i:n),f=a[h][d-1]-(l[d-1]||1===d||d===t.length?i:n);a[h][d]=Math.max(p,f,m),a[h][d]===p?(s[d]=!1,l[d]=!1):a[h][d]===f?(s[d]=!1,l[d]=!0):(s[d]=!0,l[d]=!1)}c=h,h=(h+1)%2}const u=Math.min(t.length,r.length);return(u-a[c][t.length])/u}},[s.MONOMER_CHEMICAL_DISTANCE]:i}},8060:(t,e,n)=>{"use strict";n.d(e,{S:()=>i});const i="dimensionality-reducer-terminate-event"},9039:(t,e,n)=>{"use strict";var i;n.d(e,{c:()=>i}),function(t){t.UMAP="UMAP",t.T_SNE="t-SNE"}(i||(i={}))},8498:(t,e,n)=>{"use strict";var i,o,r,s,a,l,c;n.d(e,{EG:()=>a,Pn:()=>o,RR:()=>l,Wn:()=>c,aT:()=>r,m6:()=>s,xL:()=>i}),function(t){t.Levenshtein="Levenshtein",t.JaroWinkler="Jaro-Winkler",t.Manhattan="Manhattan String",t.Onehot="One-Hot"}(i||(i={})),function(t){t.Euclidean="Euclidean",t.Manhattan="Manhattan",t.Cosine="Vector Cosine"}(o||(o={})),function(t){t.Tanimoto="Tanimoto",t.Dice="Dice",t.Asymmetric="Asymmetric",t.BraunBlanquet="Braun-Blanquet",t.Cosine="Cosine",t.Kulczynski="Kulczynski",t.McConnaughey="Mc-Connaughey",t.RogotGoldberg="Rogot-Goldberg",t.Russel="Russel",t.Sokal="Sokal",t.Hamming="Hamming",t.Euclidean="Euclidean BitArray"}(r||(r={})),function(t){t.TanimotoIntArray="TanimotoIntArray"}(s||(s={})),function(t){t.Vector="Vector",t.String="String",t.BitArray="BitArray",t.MacroMolecule="MacroMolecule",t.Number="Number",t.IntArray="IntArray",t.NumberArray="NumberArray"}(a||(a={})),function(t){t.Difference="Difference"}(l||(l={})),function(t){t.CommonItems="Common Items"}(c||(c={}))},2780:(t,e,n)=>{"use strict";n(8498),n(9336)},9336:(t,e,n)=>{"use strict";var i=n(2787),o=n(944),r=n(6295),s=n(6863),a=n(8498);const l={[a.Pn.Euclidean]:r.jL,[a.Pn.Manhattan]:r.Hf,[a.Pn.Cosine]:r.w_},c={[a.xL.Levenshtein]:i.I,[a.xL.JaroWinkler]:o.Vb,[a.xL.Manhattan]:function(t,e){if(t.length!==e.length)return 1;{let n=0;for(let i=1;i<t.length;i++)n+=t[i]==e[i]?0:1;return n/t.length}},[a.xL.Onehot]:function(t,e){return t===e?0:1}},h={[a.aT.Tanimoto]:r.tO,[a.aT.Dice]:r.zn,[a.aT.Asymmetric]:r.gt,[a.aT.BraunBlanquet]:r.ij,[a.aT.Cosine]:r.lO,[a.aT.Kulczynski]:r.rR,[a.aT.McConnaughey]:r.lP,[a.aT.RogotGoldberg]:r.TK,[a.aT.Russel]:r.yK,[a.aT.Sokal]:r.Ii,[a.aT.Hamming]:r.be,[a.aT.Euclidean]:r.Qj},u={[a.m6.TanimotoIntArray]:r.v_},d={[a.RR.Difference]:r.T6},p={[a.Wn.CommonItems]:r.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]:h[a.aT.Tanimoto],[a.aT.Dice]:h[a.aT.Dice],[a.aT.Asymmetric]:h[a.aT.Asymmetric],[a.aT.BraunBlanquet]:h[a.aT.BraunBlanquet],[a.aT.Cosine]:h[a.aT.Cosine],[a.aT.Kulczynski]:h[a.aT.Kulczynski],[a.aT.McConnaughey]:h[a.aT.McConnaughey],[a.aT.RogotGoldberg]:h[a.aT.RogotGoldberg],[a.aT.Russel]:h[a.aT.Russel],[a.aT.Sokal]:h[a.aT.Sokal]},[a.EG.MacroMolecule]:{[s.Z.HAMMING]:s.V[s.Z.HAMMING],[s.Z.LEVENSHTEIN]:s.V[s.Z.LEVENSHTEIN],[s.Z.NEEDLEMANN_WUNSCH]:s.V[s.Z.NEEDLEMANN_WUNSCH],[s.Z.MONOMER_CHEMICAL_DISTANCE]:s.V[s.Z.MONOMER_CHEMICAL_DISTANCE]},[a.EG.Number]:{[a.RR.Difference]:d[a.RR.Difference]},[a.EG.IntArray]:{[a.m6.TanimotoIntArray]:u[a.m6.TanimotoIntArray]},[a.EG.NumberArray]:{[a.Wn.CommonItems]:p[a.Wn.CommonItems]}};Object.keys(m).reduce(((t,e)=>{for(const n of Object.keys(m[e]))t[n]=e;return t}),{})},8774:(t,e,n)=>{"use strict";n.d(e,{A:()=>i});class i{constructor(t,e=!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 t){const n=t,o=i._createBuffer(n);if(e)for(let t=0;t<o.length;t++)o[t]=-1;this._data=o,this._length=n}else{if(!(t instanceof Uint32Array))throw new Error("Invalid constructor");this._data=t,this._length=e}}getRawData(){return this._data}assureGoez(t,e){if(t<0)throw new Error(`${e} should be greater than zero`)}assureInRange(t,e,n,i){if(t<e||t>n)throw new Error(`Argument ${i} (${t}) out of range (${e}, ${n})`)}copy(t,e,n){for(let i=0;i<n;i++)e[i]=t[i]}copyFrom(t){if(this._length!=t._length)throw new Error(`Lengths differ (${this._length} != ${t._length})`);this.copy(t._data,this._data,this.lengthInInts),this._version++}get length(){return this._length}get buffer(){return this._data}set buffer(t){this._data=t,this._version++}get version(){return this._version}set version(t){this._version=t}incrementVersion(t=!0){this._version++}get lengthInInts(){return Math.floor((this._length+31)/32)}get versionedName(){return this._version==this._versionedNameVersion?this._versionedName:""}set versionedName(t){this._versionedName=t,this._versionedNameVersion=this._version}get self(){return this}setLength(t){if(t<0)throw new Error("should be >= 0");if(t==this._length)return;const e=Math.floor((t+31)/32);if(e>this._data.length||e+this.SHRINK_THRESHOLD<this._data.length){const t=new Uint32Array(e);this.copy(this._data,t,e>this._data.length?this._data.length:e),this._data=t}t>this._length&&(this._length%32>0&&(this._data[this.lengthInInts-1]&=(1<<(this._length%32&31))-1),this._data.fill(0,this.lengthInInts,e)),this._length=t,this._version++}static fromAnd(t,e){if(t._length!=e._length)throw new Error(`Lengths differ (${t._length} != ${e._length})`);const n=new i(t._length);n._length=t._length,n._data=i._createBuffer(n._length),n._version=0;const o=t.lengthInInts;for(let i=0;i<o;i++)n._data[i]=t._data[i]&e._data[i];return n}static _createBuffer(t){return new Uint32Array(Math.floor((t+31)/32))}static fromValues(t){const e=new i(t.length);e._version=0;for(let n=0;n<e._length;n++)t[n]&&(e._data[Math.floor(n/32)]|=1<<(n%32&31));return e}static fromSeq(t,e){const n=new i(t);for(let i=0;i<t;++i)n.setBit(i,e(i));return n._version=0,n}static fromString(t){return i.fromSeq(t.length,(e=>"1"==t.charAt(e)))}static fromUint32Array(t,e){const n=new i(t);return n._data=e,n}static fromBytes(t){const e=t.length,n=new i(8*e);n._data=new Uint32Array(Math.floor((e+3)/4)),n._length=8*e;let o=0,r=0;for(;e-r>=4;)n._data[o++]=255&t[r]|(255&t[r+1])<<8|(255&t[r+2])<<16|(255&t[r+3])<<24,r+=4;return e-r==3&&(n._data[o]=(255&t[r+2])<<16),e-r==2&&(n._data[o]|=(255&t[r+1])<<8),e-r==1&&(n._data[o]|=255&t[r]),n._version=0,n}toString(){return`${this._length} bits, ${this.countBits(!0)} set`}equals(t){if(this==t)return!0;if(null==t)return!1;if(this._length!=t._length)return!1;if(0==this._length)return!0;for(let e=0;e<this._data.length-1;e++)if(this._data[e]!=t._data[e])return!1;for(let e=8*(this._data.length-1);e<this._length;e++)if(this.getBit(e)!=t.getBit(e))return!1;return!0}clone(){const t=new i(0,!1);return t._data=Uint32Array.from(this._data),t._length=this._length,t._version=this._version,t}init(t,e){this.setAll(!1,!1);for(let e=0;e<this._length;e++)t(e)&&(this._data[Math.floor(e/32)]|=1<<(e%32&31));return this.incrementVersion(e),this}invert(t=!0){for(let t=0;t<this._data.length;t++)this._data[t]^=-1;this.incrementVersion(t)}setAll(t,e=!1){const n=t?-1:0,i=this.lengthInInts;for(let t=0;t<i;t++)this._data[t]=n;this.incrementVersion(e)}setIndexes(t,e=!0,n=!0,i=!0){n&&this.setAll(!e,!1);for(const n of t)this.setFast(n,e);this.incrementVersion(i)}everyIndex(t,e=!0){for(const n of t)if(this.getBit(n)!=e)return!1;return!0}anyIndex(t,e=!0){for(const n of t)if(this.getBit(n)==e)return!0;return!1}setWhere(t,e=!0,n=!0,i=!0,o=!0){if(n&&o&&this.setAll(!e,!1),o)for(let n=0;n<this._length;n++)t(n)&&this.setFast(n,e);else for(let n=0;n<this._length;n++)this.setFast(n,t(n)?e:!e);this.incrementVersion(i)}getRange(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const n=[];for(let i=t;i<e;++i)n.push(this.getBit(i));return i.fromValues(n)}getRangeAsList(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const n=[];for(let i=t;i<e;++i)n.push(this.getBit(i));return n}setRange(t,e,n,i=!0){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length-1,"to");const o=Math.min(t,e),r=Math.max(t,e);if(n)for(let t=o;t<=r;t++)this.setTrue(t);else for(let t=o;t<=r;t++)this.setFalse(t);return this.incrementVersion(i),this}setRandom(t,e,n=!0){if(t<0||t>this._length)throw new Error("n must be >= 0 && <= Count");t>this._length/2&&this.setRandom(this._length-t,!e),this.setAll(!e);for(let n=0;n<t;){const t=Math.floor(Math.random()*this._length);this.getBit(t)!=e&&(this.setFast(t,e),n++)}this.incrementVersion(n)}and(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]&=t._data[e];return this.incrementVersion(e),this}andNot(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");const n=this.lengthInInts;for(let e=0;e<n;e++)this._data[e]&=~t._data[e];return this.incrementVersion(e),this}notAnd(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]=~this._data[e]&t._data[e];return this.incrementVersion(e),this}not(t=!0){for(let t=0,e=this.lengthInInts;t<e;t++)this._data[t]=~this._data[t];return this.incrementVersion(t),this}or(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]|=t._data[e];return this.incrementVersion(e),this}xor(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]^=t._data[e];return this.incrementVersion(e),this}insertAt(t,e,n=!1){if(this.assureInRange(t,0,this._length,"pos"),0==e)return;const i=this._length;this.setLength(this._length+e);for(let n=i-1;n>=t;n--)this.setBit(n+e,this.getBit(n));for(let i=t;i<t+e;i++)this.setBit(i,n)}removeAt(t,e=1){if(e<0)throw new Error("n cannot be negative");if(this.assureInRange(t,0,this._length-e,"pos"),this.contains(!0))for(let n=t;n<this._length-e;n++)this.setBit(n,this.getBit(n+e));this.setLength(this._length-e)}removeByMask(t,e=!0){if(this._length!=t.length)throw new Error("length != mask.length");if(t==this)this.setLength(t.countBits(!e)),this.setAll(!e);else{let n=0;for(let i=-1;-1!=(i=t.findNext(i,!e));)this.setFast(n++,this.getBit(i));this._length=n,this._version++}return this}getBit(t){return!!(this._data[Math.floor(t/32)]&1<<(31&t))}setBit(t,e,n=!0){this.setFast(t,e),this._version++}setFast(t,e){e?this._data[Math.floor(t/32)]|=1<<(31&t):this._data[Math.floor(t/32)]&=~(1<<(31&t))}setTrue(t){this._data[Math.floor(t/32)]|=1<<(31&t)}setFalse(t){this._data[Math.floor(t/32)]&=~(1<<(31&t))}trueCount(){return this.countBits(!0)}falseCount(){return this.countBits(!1)}countBits(t){if(0==this._length)return 0;if(this._selectedCountVersion!=this._version){this._selectedCount=0;const t=this.lengthInInts;let e=0;for(;e<t-1;e++)for(let t=this._data[e];0!=t;t>>>=8)this._selectedCount+=i._onBitCount[255&t];let n=this._data[e];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 t?this._selectedCount:this._length-this._selectedCount}countWhere(t){let e=0;if(this.trueCount()==this._length)for(let n=0;n<this._length;n++)e+=t(n)?1:0;else for(let n=-1;-1!=(n=this.findNext(n,!0));)e+=t(n)?1:0;return e}andWithCountBits(t,e){if(0==this._length)return 0;let n=0;const o=this.lengthInInts;let r=0;for(;r<o-1;r++)for(let e=this._data[r]&t._data[r];0!=e;e>>>=8)n+=i._onBitCount[255&e];let s=this._data[r]&t._data[r];const a=31&this._length;for(0!=a&&(s&=~(4294967295<<a));0!=s;s>>>=8)n+=i._onBitCount[255&s];return e?n:this._length-n}clear(){this.setLength(0)}contains(t){return this.findNext(-1,t)>=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(t,e=!0){if(this.assureInRange(t,-1,this._length,"index"),t>=this._length-1)return-1;let n=31&(t=t<0?0:t+1);const o=this.lengthInInts;for(let r=Math.floor(t/32);r<o;r++){let o=e?this._data[r]:~this._data[r];if(0!=n)o&=4294967295<<n&4294967295,n=0;else if(!e&&-4294967296==o)continue;for(let e=0;0!=o;e+=8,o>>>=8){const n=i._firstOnBit[255&o];if(n>=0)return(t=n+32*r+e)>=this._length?-1:t}}return-1}findPrev(t,e=!0){if(0==t)return-1;this.assureInRange(t,-1,this._length,"index");let n=1+(t=t<0?this._length-1:t-1)&31;for(let o=Math.floor(t/32);o>=0;o--){let t=e?this._data[o]:~this._data[o];0!=n&&(t&=~(4294967295<<n),n=0);for(let e=24;0!=t;e-=8,t<<=8){const n=i._lastOnBit[t>>>24];if(n>=0)return n+32*o+e}}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:(t,e,n)=>{"use strict";n.d(e,{cb:()=>a,PE:()=>s}),n(4328);var i=n(6082);n(9982),i.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,,,,,,,,,,,,,,,,,,,,,').columns.add(i.Column.fromList(i.TYPE.BYTE_ARRAY,"BinaryImage",Array.from(new Uint8Array(11))));var o,r=function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((i=i.apply(t,e||[])).next())}))};function s(t,e,n,i=0,o="timeout"){return r(this,void 0,void 0,(function*(){return new Promise(((r,s)=>{const a=t.subscribe((t=>{try{e(t),r("OK")}catch(t){s(t)}finally{a.unsubscribe(),clearTimeout(l)}})),l=setTimeout((()=>{a.unsubscribe(),s(o)}),i);n()}))}))}function a(t){return r(this,void 0,void 0,(function*(){yield new Promise((e=>setTimeout(e,t)))}))}console.log.bind(console),console.info.bind(console),console.warn.bind(console),console.error.bind(console),function(t){t.notNull=function(t,e){if(null==t)throw new Error(`${null==e?"Value":e} not defined`)}}(o||(o={})),i.DataFrame.fromColumns([i.Column.fromStrings("col",["val1","val2","val3"])])},3527:(t,e,n)=>{"use strict";n.d(e,{Mi:()=>i});class i extends Float32Array{}},3629:(t,e,n)=>{"use strict";n.d(e,{KE:()=>a,S8:()=>l,dC:()=>r,vA:()=>o,wQ:()=>s});var i=n(3527);function o(t=!1,e="Assertion error."){if(!t)throw new Error(e)}function r(t,e,n=1){const r=t.length;o(r==e.length,"Vector lengths do not match.");const s=new i.Mi(r);for(let i=0;i<t.length;++i)s[i]=t[i]+n*e[i];return s}function s(t){let e=0;for(let n=0;n<t.length;n++)e+=t[n]*t[n];return Math.sqrt(e)}function a(t,e){if(t.length!=e.length)throw new Error("The dimensionality of the vectors must match");let n=0;for(let i=0;i<t.length;i++)n+=t[i]*e[i];return n}function l(t){const e=t.length;let n=0,i=0;for(let o=0;o<e;++o)n+=t[o],i+=Math.pow(t[o],2);const o=n/e,r=1/Math.sqrt(i/e-Math.pow(o,2));for(let n=0;n<e;++n)t[n]=(t[n]-o)*r;return t}},1913:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(3282),o=n(9029),r=n(1520),s=n(2586),a=n(8708),l=n(2023),c="errorMessage",h=new i.Name("emUsed"),u={required:"missingProperty",dependencies:"property",dependentRequired:"property"},d=/\$\{[^}]+\}/,p=/\$\{([^}]+)\}/g,m=/^""\s*\+\s*|\s*\+\s*""$/g;const f=(t,e={})=>{if(!t.opts.allErrors)throw new Error("ajv-errors: Ajv option allErrors must be true");if(t.opts.jsPropertySyntax)throw new Error("ajv-errors: ajv option jsPropertySyntax is not supported");return t.addKeyword(function(t){return{keyword:c,schemaType:["string","object"],post:!0,code(e){const{gen:n,data:f,schema:g,schemaValue:y,it:b}=e;if(!1===b.createErrors)return;const v=g,w=o.strConcat(l.default.instancePath,b.errorPath);function C(t,e){return o.and(i._`${t}.keyword !== ${c}`,i._`!${t}.${h}`,i._`${t}.instancePath === ${w}`,i._`${t}.keyword in ${e}`,i._`${t}.schemaPath.indexOf(${b.errSchemaPath}) === 0`,i._`/^\\/[^\\/]*$/.test(${t}.schemaPath.slice(${b.errSchemaPath.length}))`)}function A(t,e){const i=[];for(const n in t){const t=e[n];d.test(t)&&i.push([n,x(t)])}return n.object(...i)}function S(t){return d.test(t)?new r._Code(r.safeStringify(t).replace(p,((t,e)=>`" + JSON.stringify(${s.getData(e,b)}) + "`)).replace(m,"")):i.stringify(t)}function x(t){return i._`function(){return ${S(t)}}`}n.if(i._`${l.default.errors} > 0`,(()=>{if("object"==typeof v){const[r,s]=function(t){let e,n;for(const i in t){if("properties"===i||"items"===i)continue;const o=t[i];if("object"==typeof o){e||(e={});const t=e[i]={};for(const e in o)t[e]=[]}else n||(n={}),n[i]=[]}return[e,n]}(v);s&&function(o){const r=n.const("emErrors",i.stringify(o)),s=n.const("templates",A(o,g));n.forOf("err",l.default.vErrors,(t=>n.if(C(t,r),(()=>n.code(i._`${r}[${t}.keyword].push(${t})`).assign(i._`${t}.${h}`,!0)))));const{singleError:c}=t;if(c){const t=n.let("message",i._`""`),o=n.let("paramsErrors",i._`[]`);u((e=>{n.if(t,(()=>n.code(i._`${t} += ${"string"==typeof c?c:";"}`))),n.code(i._`${t} += ${d(e)}`),n.assign(o,i._`${o}.concat(${r}[${e}])`)})),a.reportError(e,{message:t,params:i._`{errors: ${o}}`})}else u((t=>a.reportError(e,{message:d(t),params:i._`{errors: ${r}[${t}]}`})));function u(t){n.forIn("key",r,(e=>n.if(i._`${r}[${e}].length`,(()=>t(e)))))}function d(t){return i._`${t} in ${s} ? ${s}[${t}]() : ${y}[${t}]`}}(s),r&&function(t){const o=n.const("emErrors",i.stringify(t)),r=[];for(const e in t)r.push([e,A(t[e],g[e])]);const s=n.const("templates",n.object(...r)),c=n.scopeValue("obj",{ref:u,code:i.stringify(u)}),d=n.let("emPropParams"),p=n.let("emParamsErrors");n.forOf("err",l.default.vErrors,(t=>n.if(C(t,o),(()=>{n.assign(d,i._`${c}[${t}.keyword]`),n.assign(p,i._`${o}[${t}.keyword][${t}.params[${d}]]`),n.if(p,(()=>n.code(i._`${p}.push(${t})`).assign(i._`${t}.${h}`,!0)))})))),n.forIn("key",o,(t=>n.forIn("keyProp",i._`${o}[${t}]`,(r=>{n.assign(p,i._`${o}[${t}][${r}]`),n.if(i._`${p}.length`,(()=>{const o=n.const("tmpl",i._`${s}[${t}] && ${s}[${t}][${r}]`);a.reportError(e,{message:i._`${o} ? ${o}() : ${y}[${t}][${r}]`,params:i._`{errors: ${p}}`})}))}))))}(r),function(t){const{props:r,items:s}=t;if(!r&&!s)return;const u=i._`typeof ${f} == "object"`,d=i._`Array.isArray(${f})`,p=n.let("emErrors");let m,b;const v=n.let("templates");function C(t,e){n.assign(p,i.stringify(t)),n.assign(v,A(t,e))}r&&s?(m=n.let("emChildKwd"),n.if(u),n.if(d,(()=>{C(s,g.items),n.assign(m,i.str`items`)}),(()=>{C(r,g.properties),n.assign(m,i.str`properties`)})),b=i._`[${m}]`):s?(n.if(d),C(s,g.items),b=i._`.items`):r&&(n.if(o.and(u,o.not(d))),C(r,g.properties),b=i._`.properties`),n.forOf("err",l.default.vErrors,(t=>function(t,e,r){n.if(o.and(i._`${t}.keyword !== ${c}`,i._`!${t}.${h}`,i._`${t}.instancePath.indexOf(${w}) === 0`),(()=>{const o=n.scopeValue("pattern",{ref:/^\/([^/]*)(?:\/|$)/,code:i._`new RegExp("^\\\/([^/]*)(?:\\\/|$)")`}),s=n.const("emMatches",i._`${o}.exec(${t}.instancePath.slice(${w}.length))`),a=n.const("emChild",i._`${s} && ${s}[1].replace(/~1/g, "/").replace(/~0/g, "~")`);n.if(i._`${a} !== undefined && ${a} in ${e}`,(()=>r(a)))}))}(t,p,(e=>n.code(i._`${p}[${e}].push(${t})`).assign(i._`${t}.${h}`,!0))))),n.forIn("key",p,(t=>n.if(i._`${p}[${t}].length`,(()=>{a.reportError(e,{message:i._`${t} in ${v} ? ${v}[${t}]() : ${y}${b}[${t}]`,params:i._`{errors: ${p}[${t}]}`}),n.assign(i._`${l.default.vErrors}[${l.default.errors}-1].instancePath`,i._`${w} + "/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`)})))),n.endIf()}(function({properties:t,items:e}){const n={};if(t){n.props={};for(const e in t)n.props[e]=[]}if(e){n.items={};for(let t=0;t<e.length;t++)n.items[t]=[]}return n}(v))}const r="string"==typeof v?v:v._;r&&function(t){const r=n.const("emErrs",i._`[]`);n.forOf("err",l.default.vErrors,(t=>n.if(function(t){return o.and(i._`${t}.keyword !== ${c}`,i._`!${t}.${h}`,o.or(i._`${t}.instancePath === ${w}`,o.and(i._`${t}.instancePath.indexOf(${w}) === 0`,i._`${t}.instancePath[${w}.length] === "/"`)),i._`${t}.schemaPath.indexOf(${b.errSchemaPath}) === 0`,i._`${t}.schemaPath[${b.errSchemaPath}.length] === "/"`)}(t),(()=>n.code(i._`${r}.push(${t})`).assign(i._`${t}.${h}`,!0))))),n.if(i._`${r}.length`,(()=>a.reportError(e,{message:S(t),params:i._`{errors: ${r}}`})))}(r),t.keepErrors||function(){const t=n.const("emErrs",i._`[]`);n.forOf("err",l.default.vErrors,(e=>n.if(i._`!${e}.${h}`,(()=>n.code(i._`${t}.push(${e})`))))),n.assign(l.default.vErrors,t).assign(l.default.errors,i._`${t}.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"}}}}}}(e))};e.default=f,t.exports=f,t.exports.default=f},7433:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.MissingRefError=e.ValidationError=e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=e.Ajv2020=void 0;const i=n(4042),o=n(6105),r=n(6653),s=n(9572),a="https://json-schema.org/draft/2020-12/schema";class l extends i.default{constructor(t={}){super({...t,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){super._addVocabularies(),o.default.forEach((t=>this.addVocabulary(t))),this.opts.discriminator&&this.addKeyword(r.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();const{$data:t,meta:e}=this.opts;e&&(s.default.call(this,t),this.refs["http://json-schema.org/schema"]=a)}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(a)?a:void 0)}}e.Ajv2020=l,t.exports=e=l,t.exports.Ajv2020=l,Object.defineProperty(e,"__esModule",{value:!0}),e.default=l;var c=n(2586);Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return c.KeywordCxt}});var h=n(9029);Object.defineProperty(e,"_",{enumerable:!0,get:function(){return h._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return h.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return h.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return h.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return h.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return h.CodeGen}});var u=n(3558);Object.defineProperty(e,"ValidationError",{enumerable:!0,get:function(){return u.default}});var d=n(4551);Object.defineProperty(e,"MissingRefError",{enumerable:!0,get:function(){return d.default}})},3282:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.MissingRefError=e.ValidationError=e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=e.Ajv=void 0;const i=n(4042),o=n(6144),r=n(6653),s=n(2079),a=["/properties"],l="http://json-schema.org/draft-07/schema";class c extends i.default{_addVocabularies(){super._addVocabularies(),o.default.forEach((t=>this.addVocabulary(t))),this.opts.discriminator&&this.addKeyword(r.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const t=this.opts.$data?this.$dataMetaSchema(s,a):s;this.addMetaSchema(t,l,!1),this.refs["http://json-schema.org/schema"]=l}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(l)?l:void 0)}}e.Ajv=c,t.exports=e=c,t.exports.Ajv=c,Object.defineProperty(e,"__esModule",{value:!0}),e.default=c;var h=n(2586);Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return h.KeywordCxt}});var u=n(9029);Object.defineProperty(e,"_",{enumerable:!0,get:function(){return u._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return u.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return u.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return u.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return u.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return u.CodeGen}});var d=n(3558);Object.defineProperty(e,"ValidationError",{enumerable:!0,get:function(){return d.default}});var p=n(4551);Object.defineProperty(e,"MissingRefError",{enumerable:!0,get:function(){return p.default}})},1520:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;class n{}e._CodeOrName=n,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class i extends n{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw new Error("CodeGen: name must be a valid identifier");this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}e.Name=i;class o extends n{constructor(t){super(),this._items="string"==typeof t?[t]:t}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const t=this._items[0];return""===t||'""'===t}get str(){var t;return null!==(t=this._str)&&void 0!==t?t:this._str=this._items.reduce(((t,e)=>`${t}${e}`),"")}get names(){var t;return null!==(t=this._names)&&void 0!==t?t:this._names=this._items.reduce(((t,e)=>(e instanceof i&&(t[e.str]=(t[e.str]||0)+1),t)),{})}}function r(t,...e){const n=[t[0]];let i=0;for(;i<e.length;)l(n,e[i]),n.push(t[++i]);return new o(n)}e._Code=o,e.nil=new o(""),e._=r;const s=new o("+");function a(t,...e){const n=[h(t[0])];let i=0;for(;i<e.length;)n.push(s),l(n,e[i]),n.push(s,h(t[++i]));return function(t){let e=1;for(;e<t.length-1;){if(t[e]===s){const n=c(t[e-1],t[e+1]);if(void 0!==n){t.splice(e-1,3,n);continue}t[e++]="+"}e++}}(n),new o(n)}function l(t,e){var n;e instanceof o?t.push(...e._items):e instanceof i?t.push(e):t.push("number"==typeof(n=e)||"boolean"==typeof n||null===n?n:h(Array.isArray(n)?n.join(","):n))}function c(t,e){if('""'===e)return t;if('""'===t)return e;if("string"==typeof t){if(e instanceof i||'"'!==t[t.length-1])return;return"string"!=typeof e?`${t.slice(0,-1)}${e}"`:'"'===e[0]?t.slice(0,-1)+e.slice(1):void 0}return"string"!=typeof e||'"'!==e[0]||t instanceof i?void 0:`"${t}${e.slice(1)}`}function h(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}e.str=a,e.addCodeArg=l,e.strConcat=function(t,e){return e.emptyStr()?t:t.emptyStr()?e:a`${t}${e}`},e.stringify=function(t){return new o(h(t))},e.safeStringify=h,e.getProperty=function(t){return"string"==typeof t&&e.IDENTIFIER.test(t)?new o(`.${t}`):r`[${t}]`},e.getEsmExportName=function(t){if("string"==typeof t&&e.IDENTIFIER.test(t))return new o(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)},e.regexpCode=function(t){return new o(t.toString())}},9029:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;const i=n(1520),o=n(7845);var r=n(1520);Object.defineProperty(e,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,"strConcat",{enumerable:!0,get:function(){return r.strConcat}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,"getProperty",{enumerable:!0,get:function(){return r.getProperty}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,"regexpCode",{enumerable:!0,get:function(){return r.regexpCode}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return r.Name}});var s=n(7845);Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return s.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return s.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return s.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return s.varKinds}}),e.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(t,e){return this}}class l extends a{constructor(t,e,n){super(),this.varKind=t,this.name=e,this.rhs=n}render({es5:t,_n:e}){const n=t?o.varKinds.var:this.varKind,i=void 0===this.rhs?"":` = ${this.rhs}`;return`${n} ${this.name}${i};`+e}optimizeNames(t,e){if(t[this.name.str])return this.rhs&&(this.rhs=N(this.rhs,t,e)),this}get names(){return this.rhs instanceof i._CodeOrName?this.rhs.names:{}}}class c extends a{constructor(t,e,n){super(),this.lhs=t,this.rhs=e,this.sideEffects=n}render({_n:t}){return`${this.lhs} = ${this.rhs};`+t}optimizeNames(t,e){if(!(this.lhs instanceof i.Name)||t[this.lhs.str]||this.sideEffects)return this.rhs=N(this.rhs,t,e),this}get names(){return L(this.lhs instanceof i.Name?{}:{...this.lhs.names},this.rhs)}}class h extends c{constructor(t,e,n,i){super(t,n,i),this.op=e}render({_n:t}){return`${this.lhs} ${this.op}= ${this.rhs};`+t}}class u extends a{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`${this.label}:`+t}}class d extends a{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`break${this.label?` ${this.label}`:""};`+t}}class p extends a{constructor(t){super(),this.error=t}render({_n:t}){return`throw ${this.error};`+t}get names(){return this.error.names}}class m extends a{constructor(t){super(),this.code=t}render({_n:t}){return`${this.code};`+t}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(t,e){return this.code=N(this.code,t,e),this}get names(){return this.code instanceof i._CodeOrName?this.code.names:{}}}class f extends a{constructor(t=[]){super(),this.nodes=t}render(t){return this.nodes.reduce(((e,n)=>e+n.render(t)),"")}optimizeNodes(){const{nodes:t}=this;let e=t.length;for(;e--;){const n=t[e].optimizeNodes();Array.isArray(n)?t.splice(e,1,...n):n?t[e]=n:t.splice(e,1)}return t.length>0?this:void 0}optimizeNames(t,e){const{nodes:n}=this;let i=n.length;for(;i--;){const o=n[i];o.optimizeNames(t,e)||(P(t,o.names),n.splice(i,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce(((t,e)=>I(t,e.names)),{})}}class g extends f{render(t){return"{"+t._n+super.render(t)+"}"+t._n}}class y extends f{}class b extends g{}b.kind="else";class v extends g{constructor(t,e){super(e),this.condition=t}render(t){let e=`if(${this.condition})`+super.render(t);return this.else&&(e+="else "+this.else.render(t)),e}optimizeNodes(){super.optimizeNodes();const t=this.condition;if(!0===t)return this.nodes;let e=this.else;if(e){const t=e.optimizeNodes();e=this.else=Array.isArray(t)?new b(t):t}return e?!1===t?e instanceof v?e:e.nodes:this.nodes.length?this:new v($(t),e instanceof v?[e]:e.nodes):!1!==t&&this.nodes.length?this:void 0}optimizeNames(t,e){var n;if(this.else=null===(n=this.else)||void 0===n?void 0:n.optimizeNames(t,e),super.optimizeNames(t,e)||this.else)return this.condition=N(this.condition,t,e),this}get names(){const t=super.names;return L(t,this.condition),this.else&&I(t,this.else.names),t}}v.kind="if";class w extends g{}w.kind="for";class C extends w{constructor(t){super(),this.iteration=t}render(t){return`for(${this.iteration})`+super.render(t)}optimizeNames(t,e){if(super.optimizeNames(t,e))return this.iteration=N(this.iteration,t,e),this}get names(){return I(super.names,this.iteration.names)}}class A extends w{constructor(t,e,n,i){super(),this.varKind=t,this.name=e,this.from=n,this.to=i}render(t){const e=t.es5?o.varKinds.var:this.varKind,{name:n,from:i,to:r}=this;return`for(${e} ${n}=${i}; ${n}<${r}; ${n}++)`+super.render(t)}get names(){const t=L(super.names,this.from);return L(t,this.to)}}class S extends w{constructor(t,e,n,i){super(),this.loop=t,this.varKind=e,this.name=n,this.iterable=i}render(t){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(t)}optimizeNames(t,e){if(super.optimizeNames(t,e))return this.iterable=N(this.iterable,t,e),this}get names(){return I(super.names,this.iterable.names)}}class x extends g{constructor(t,e,n){super(),this.name=t,this.args=e,this.async=n}render(t){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(t)}}x.kind="func";class E extends f{render(t){return"return "+super.render(t)}}E.kind="return";class M extends g{render(t){let e="try"+super.render(t);return this.catch&&(e+=this.catch.render(t)),this.finally&&(e+=this.finally.render(t)),e}optimizeNodes(){var t,e;return super.optimizeNodes(),null===(t=this.catch)||void 0===t||t.optimizeNodes(),null===(e=this.finally)||void 0===e||e.optimizeNodes(),this}optimizeNames(t,e){var n,i;return super.optimizeNames(t,e),null===(n=this.catch)||void 0===n||n.optimizeNames(t,e),null===(i=this.finally)||void 0===i||i.optimizeNames(t,e),this}get names(){const t=super.names;return this.catch&&I(t,this.catch.names),this.finally&&I(t,this.finally.names),t}}class T extends g{constructor(t){super(),this.error=t}render(t){return`catch(${this.error})`+super.render(t)}}T.kind="catch";class _ extends g{render(t){return"finally"+super.render(t)}}function I(t,e){for(const n in e)t[n]=(t[n]||0)+(e[n]||0);return t}function L(t,e){return e instanceof i._CodeOrName?I(t,e.names):t}function N(t,e,n){return t instanceof i.Name?r(t):(o=t)instanceof i._Code&&o._items.some((t=>t instanceof i.Name&&1===e[t.str]&&void 0!==n[t.str]))?new i._Code(t._items.reduce(((t,e)=>(e instanceof i.Name&&(e=r(e)),e instanceof i._Code?t.push(...e._items):t.push(e),t)),[])):t;var o;function r(t){const i=n[t.str];return void 0===i||1!==e[t.str]?t:(delete e[t.str],i)}}function P(t,e){for(const n in e)t[n]=(t[n]||0)-(e[n]||0)}function $(t){return"boolean"==typeof t||"number"==typeof t||null===t?!t:i._`!${H(t)}`}_.kind="finally",e.CodeGen=class{constructor(t,e={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...e,_n:e.lines?"\n":""},this._extScope=t,this._scope=new o.Scope({parent:t}),this._nodes=[new y]}toString(){return this._root.render(this.opts)}name(t){return this._scope.name(t)}scopeName(t){return this._extScope.name(t)}scopeValue(t,e){const n=this._extScope.value(t,e);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(t,e){return this._extScope.getValue(t,e)}scopeRefs(t){return this._extScope.scopeRefs(t,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(t,e,n,i){const o=this._scope.toName(e);return void 0!==n&&i&&(this._constants[o.str]=n),this._leafNode(new l(t,o,n)),o}const(t,e,n){return this._def(o.varKinds.const,t,e,n)}let(t,e,n){return this._def(o.varKinds.let,t,e,n)}var(t,e,n){return this._def(o.varKinds.var,t,e,n)}assign(t,e,n){return this._leafNode(new c(t,e,n))}add(t,n){return this._leafNode(new h(t,e.operators.ADD,n))}code(t){return"function"==typeof t?t():t!==i.nil&&this._leafNode(new m(t)),this}object(...t){const e=["{"];for(const[n,o]of t)e.length>1&&e.push(","),e.push(n),(n!==o||this.opts.es5)&&(e.push(":"),(0,i.addCodeArg)(e,o));return e.push("}"),new i._Code(e)}if(t,e,n){if(this._blockNode(new v(t)),e&&n)this.code(e).else().code(n).endIf();else if(e)this.code(e).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(t){return this._elseNode(new v(t))}else(){return this._elseNode(new b)}endIf(){return this._endBlockNode(v,b)}_for(t,e){return this._blockNode(t),e&&this.code(e).endFor(),this}for(t,e){return this._for(new C(t),e)}forRange(t,e,n,i,r=(this.opts.es5?o.varKinds.var:o.varKinds.let)){const s=this._scope.toName(t);return this._for(new A(r,s,e,n),(()=>i(s)))}forOf(t,e,n,r=o.varKinds.const){const s=this._scope.toName(t);if(this.opts.es5){const t=e instanceof i.Name?e:this.var("_arr",e);return this.forRange("_i",0,i._`${t}.length`,(e=>{this.var(s,i._`${t}[${e}]`),n(s)}))}return this._for(new S("of",r,s,e),(()=>n(s)))}forIn(t,e,n,r=(this.opts.es5?o.varKinds.var:o.varKinds.const)){if(this.opts.ownProperties)return this.forOf(t,i._`Object.keys(${e})`,n);const s=this._scope.toName(t);return this._for(new S("in",r,s,e),(()=>n(s)))}endFor(){return this._endBlockNode(w)}label(t){return this._leafNode(new u(t))}break(t){return this._leafNode(new d(t))}return(t){const e=new E;if(this._blockNode(e),this.code(t),1!==e.nodes.length)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(E)}try(t,e,n){if(!e&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');const i=new M;if(this._blockNode(i),this.code(t),e){const t=this.name("e");this._currNode=i.catch=new T(t),e(t)}return n&&(this._currNode=i.finally=new _,this.code(n)),this._endBlockNode(T,_)}throw(t){return this._leafNode(new p(t))}block(t,e){return this._blockStarts.push(this._nodes.length),t&&this.code(t).endBlock(e),this}endBlock(t){const e=this._blockStarts.pop();if(void 0===e)throw new Error("CodeGen: not in self-balancing block");const n=this._nodes.length-e;if(n<0||void 0!==t&&n!==t)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${t} expected`);return this._nodes.length=e,this}func(t,e=i.nil,n,o){return this._blockNode(new x(t,e,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(x)}optimize(t=1){for(;t-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(t){return this._currNode.nodes.push(t),this}_blockNode(t){this._currNode.nodes.push(t),this._nodes.push(t)}_endBlockNode(t,e){const n=this._currNode;if(n instanceof t||e&&n instanceof e)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${e?`${t.kind}/${e.kind}`:t.kind}"`)}_elseNode(t){const e=this._currNode;if(!(e instanceof v))throw new Error('CodeGen: "else" without "if"');return this._currNode=e.else=t,this}get _root(){return this._nodes[0]}get _currNode(){const t=this._nodes;return t[t.length-1]}set _currNode(t){const e=this._nodes;e[e.length-1]=t}},e.not=$;const R=O(e.operators.AND);e.and=function(...t){return t.reduce(R)};const k=O(e.operators.OR);function O(t){return(e,n)=>e===i.nil?n:n===i.nil?e:i._`${H(e)} ${t} ${H(n)}`}function H(t){return t instanceof i.Name?t:i._`(${t})`}e.or=function(...t){return t.reduce(k)}},7845:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;const i=n(1520);class o extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`),this.value=t.value}}var r;!function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"}(r||(e.UsedValueState=r={})),e.varKinds={const:new i.Name("const"),let:new i.Name("let"),var:new i.Name("var")};class s{constructor({prefixes:t,parent:e}={}){this._names={},this._prefixes=t,this._parent=e}toName(t){return t instanceof i.Name?t:this.name(t)}name(t){return new i.Name(this._newName(t))}_newName(t){return`${t}${(this._names[t]||this._nameGroup(t)).index++}`}_nameGroup(t){var e,n;if((null===(n=null===(e=this._parent)||void 0===e?void 0:e._prefixes)||void 0===n?void 0:n.has(t))||this._prefixes&&!this._prefixes.has(t))throw new Error(`CodeGen: prefix "${t}" is not allowed in this scope`);return this._names[t]={prefix:t,index:0}}}e.Scope=s;class a extends i.Name{constructor(t,e){super(e),this.prefix=t}setValue(t,{property:e,itemIndex:n}){this.value=t,this.scopePath=i._`.${new i.Name(e)}[${n}]`}}e.ValueScopeName=a;const l=i._`\n`;e.ValueScope=class extends s{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?l:i.nil}}get(){return this._scope}name(t){return new a(t,this._newName(t))}value(t,e){var n;if(void 0===e.ref)throw new Error("CodeGen: ref must be passed in value");const i=this.toName(t),{prefix:o}=i,r=null!==(n=e.key)&&void 0!==n?n:e.ref;let s=this._values[o];if(s){const t=s.get(r);if(t)return t}else s=this._values[o]=new Map;s.set(r,i);const a=this._scope[o]||(this._scope[o]=[]),l=a.length;return a[l]=e.ref,i.setValue(e,{property:o,itemIndex:l}),i}getValue(t,e){const n=this._values[t];if(n)return n.get(e)}scopeRefs(t,e=this._values){return this._reduceValues(e,(e=>{if(void 0===e.scopePath)throw new Error(`CodeGen: name "${e}" has no value`);return i._`${t}${e.scopePath}`}))}scopeCode(t=this._values,e,n){return this._reduceValues(t,(t=>{if(void 0===t.value)throw new Error(`CodeGen: name "${t}" has no value`);return t.value.code}),e,n)}_reduceValues(t,n,s={},a){let l=i.nil;for(const c in t){const h=t[c];if(!h)continue;const u=s[c]=s[c]||new Map;h.forEach((t=>{if(u.has(t))return;u.set(t,r.Started);let s=n(t);if(s){const n=this.opts.es5?e.varKinds.var:e.varKinds.const;l=i._`${l}${n} ${t} = ${s};${this.opts._n}`}else{if(!(s=null==a?void 0:a(t)))throw new o(t);l=i._`${l}${s}${this.opts._n}`}u.set(t,r.Completed)}))}return l}}},8708:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;const i=n(9029),o=n(4227),r=n(2023);function s(t,e){const n=t.const("err",e);t.if(i._`${r.default.vErrors} === null`,(()=>t.assign(r.default.vErrors,i._`[${n}]`)),i._`${r.default.vErrors}.push(${n})`),t.code(i._`${r.default.errors}++`)}function a(t,e){const{gen:n,validateName:o,schemaEnv:r}=t;r.$async?n.throw(i._`new ${t.ValidationError}(${e})`):(n.assign(i._`${o}.errors`,e),n.return(!1))}e.keywordError={message:({keyword:t})=>i.str`must pass "${t}" keyword validation`},e.keyword$DataError={message:({keyword:t,schemaType:e})=>e?i.str`"${t}" keyword must be ${e} ($data)`:i.str`"${t}" keyword is invalid ($data)`},e.reportError=function(t,n=e.keywordError,o,r){const{it:l}=t,{gen:h,compositeRule:u,allErrors:d}=l,p=c(t,n,o);(null!=r?r:u||d)?s(h,p):a(l,i._`[${p}]`)},e.reportExtraError=function(t,n=e.keywordError,i){const{it:o}=t,{gen:l,compositeRule:h,allErrors:u}=o;s(l,c(t,n,i)),h||u||a(o,r.default.vErrors)},e.resetErrorsCount=function(t,e){t.assign(r.default.errors,e),t.if(i._`${r.default.vErrors} !== null`,(()=>t.if(e,(()=>t.assign(i._`${r.default.vErrors}.length`,e)),(()=>t.assign(r.default.vErrors,null)))))},e.extendErrors=function({gen:t,keyword:e,schemaValue:n,data:o,errsCount:s,it:a}){if(void 0===s)throw new Error("ajv implementation error");const l=t.name("err");t.forRange("i",s,r.default.errors,(s=>{t.const(l,i._`${r.default.vErrors}[${s}]`),t.if(i._`${l}.instancePath === undefined`,(()=>t.assign(i._`${l}.instancePath`,(0,i.strConcat)(r.default.instancePath,a.errorPath)))),t.assign(i._`${l}.schemaPath`,i.str`${a.errSchemaPath}/${e}`),a.opts.verbose&&(t.assign(i._`${l}.schema`,n),t.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(t,e,n){const{createErrors:o}=t.it;return!1===o?i._`{}`:function(t,e,n={}){const{gen:o,it:s}=t,a=[h(s,n),u(t,n)];return function(t,{params:e,message:n},o){const{keyword:s,data:a,schemaValue:c,it:h}=t,{opts:u,propertyName:d,topSchemaRef:p,schemaPath:m}=h;o.push([l.keyword,s],[l.params,"function"==typeof e?e(t):e||i._`{}`]),u.messages&&o.push([l.message,"function"==typeof n?n(t):n]),u.verbose&&o.push([l.schema,c],[l.parentSchema,i._`${p}${m}`],[r.default.data,a]),d&&o.push([l.propertyName,d])}(t,e,a),o.object(...a)}(t,e,n)}function h({errorPath:t},{instancePath:e}){const n=e?i.str`${t}${(0,o.getErrorPath)(e,o.Type.Str)}`:t;return[r.default.instancePath,(0,i.strConcat)(r.default.instancePath,n)]}function u({keyword:t,it:{errSchemaPath:e}},{schemaPath:n,parentSchema:r}){let s=r?e:i.str`${e}/${t}`;return n&&(s=i.str`${s}${(0,o.getErrorPath)(n,o.Type.Str)}`),[l.schemaPath,s]}},3835:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.resolveSchema=e.getCompilingSchema=e.resolveRef=e.compileSchema=e.SchemaEnv=void 0;const i=n(9029),o=n(3558),r=n(2023),s=n(6939),a=n(4227),l=n(2586);class c{constructor(t){var e;let n;this.refs={},this.dynamicAnchors={},"object"==typeof t.schema&&(n=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=null!==(e=t.baseId)&&void 0!==e?e:(0,s.normalizeId)(null==n?void 0:n[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=null==n?void 0:n.$async,this.refs={}}}function h(t){const e=d.call(this,t);if(e)return e;const n=(0,s.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:a,lines:c}=this.opts.code,{ownProperties:h}=this.opts,u=new i.CodeGen(this.scope,{es5:a,lines:c,ownProperties:h});let p;t.$async&&(p=u.scopeValue("Error",{ref:o.default,code:i._`require("ajv/dist/runtime/validation_error").default`}));const m=u.scopeName("validate");t.validateName=m;const f={gen:u,allErrors:this.opts.allErrors,data:r.default.data,parentData:r.default.parentData,parentDataProperty:r.default.parentDataProperty,dataNames:[r.default.data],dataPathArr:[i.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:u.scopeValue("schema",!0===this.opts.code.source?{ref:t.schema,code:(0,i.stringify)(t.schema)}:{ref:t.schema}),validateName:m,ValidationError:p,schema:t.schema,schemaEnv:t,rootId:n,baseId:t.baseId||n,schemaPath:i.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:i._`""`,opts:this.opts,self:this};let g;try{this._compilations.add(t),(0,l.validateFunctionCode)(f),u.optimize(this.opts.code.optimize);const e=u.toString();g=`${u.scopeRefs(r.default.scope)}return ${e}`,this.opts.code.process&&(g=this.opts.code.process(g,t));const n=new Function(`${r.default.self}`,`${r.default.scope}`,g)(this,this.scope.get());if(this.scope.value(m,{ref:n}),n.errors=null,n.schema=t.schema,n.schemaEnv=t,t.$async&&(n.$async=!0),!0===this.opts.code.source&&(n.source={validateName:m,validateCode:e,scopeValues:u._values}),this.opts.unevaluated){const{props:t,items:e}=f;n.evaluated={props:t instanceof i.Name?void 0:t,items:e instanceof i.Name?void 0:e,dynamicProps:t instanceof i.Name,dynamicItems:e instanceof i.Name},n.source&&(n.source.evaluated=(0,i.stringify)(n.evaluated))}return t.validate=n,t}catch(e){throw delete t.validate,delete t.validateName,g&&this.logger.error("Error compiling schema, function code:",g),e}finally{this._compilations.delete(t)}}function u(t){return(0,s.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:h.call(this,t)}function d(t){for(const i of this._compilations)if(n=t,(e=i).schema===n.schema&&e.root===n.root&&e.baseId===n.baseId)return i;var e,n}function p(t,e){let n;for(;"string"==typeof(n=this.refs[e]);)e=n;return n||this.schemas[e]||m.call(this,t,e)}function m(t,e){const n=this.opts.uriResolver.parse(e),i=(0,s._getFullPath)(this.opts.uriResolver,n);let o=(0,s.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&i===o)return g.call(this,n,t);const r=(0,s.normalizeId)(i),a=this.refs[r]||this.schemas[r];if("string"==typeof a){const e=m.call(this,t,a);if("object"!=typeof(null==e?void 0:e.schema))return;return g.call(this,n,e)}if("object"==typeof(null==a?void 0:a.schema)){if(a.validate||h.call(this,a),r===(0,s.normalizeId)(e)){const{schema:e}=a,{schemaId:n}=this.opts,i=e[n];return i&&(o=(0,s.resolveUrl)(this.opts.uriResolver,o,i)),new c({schema:e,schemaId:n,root:t,baseId:o})}return g.call(this,n,a)}}e.SchemaEnv=c,e.compileSchema=h,e.resolveRef=function(t,e,n){var i;n=(0,s.resolveUrl)(this.opts.uriResolver,e,n);const o=t.refs[n];if(o)return o;let r=p.call(this,t,n);if(void 0===r){const o=null===(i=t.localRefs)||void 0===i?void 0:i[n],{schemaId:s}=this.opts;o&&(r=new c({schema:o,schemaId:s,root:t,baseId:e}))}return void 0!==r?t.refs[n]=u.call(this,r):void 0},e.getCompilingSchema=d,e.resolveSchema=m;const f=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function g(t,{baseId:e,schema:n,root:i}){var o;if("/"!==(null===(o=t.fragment)||void 0===o?void 0:o[0]))return;for(const i of t.fragment.slice(1).split("/")){if("boolean"==typeof n)return;const t=n[(0,a.unescapeFragment)(i)];if(void 0===t)return;const o="object"==typeof(n=t)&&n[this.opts.schemaId];!f.has(i)&&o&&(e=(0,s.resolveUrl)(this.opts.uriResolver,e,o))}let r;if("boolean"!=typeof n&&n.$ref&&!(0,a.schemaHasRulesButRef)(n,this.RULES)){const t=(0,s.resolveUrl)(this.opts.uriResolver,e,n.$ref);r=m.call(this,i,t)}const{schemaId:l}=this.opts;return r=r||new c({schema:n,schemaId:l,root:i,baseId:e}),r.schema!==r.root.schema?r:void 0}},2023:(t,e,n)=>{"use strict";Object.defineProperty(e,"__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")};e.default=o},4551:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(6939);class o extends Error{constructor(t,e,n,o){super(o||`can't resolve reference ${n} from id ${e}`),this.missingRef=(0,i.resolveUrl)(t,e,n),this.missingSchema=(0,i.normalizeId)((0,i.getFullPath)(t,this.missingRef))}}e.default=o},6939:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getSchemaRefs=e.resolveUrl=e.normalizeId=e._getFullPath=e.getFullPath=e.inlineRef=void 0;const i=n(4227),o=n(2017),r=n(7106),s=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);e.inlineRef=function(t,e=!0){return"boolean"==typeof t||(!0===e?!l(t):!!e&&c(t)<=e)};const a=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function l(t){for(const e in t){if(a.has(e))return!0;const n=t[e];if(Array.isArray(n)&&n.some(l))return!0;if("object"==typeof n&&l(n))return!0}return!1}function c(t){let e=0;for(const n in t){if("$ref"===n)return 1/0;if(e++,!s.has(n)&&("object"==typeof t[n]&&(0,i.eachItem)(t[n],(t=>e+=c(t))),e===1/0))return 1/0}return e}function h(t,e="",n){!1!==n&&(e=p(e));const i=t.parse(e);return u(t,i)}function u(t,e){return t.serialize(e).split("#")[0]+"#"}e.getFullPath=h,e._getFullPath=u;const d=/#\/?$/;function p(t){return t?t.replace(d,""):""}e.normalizeId=p,e.resolveUrl=function(t,e,n){return n=p(n),t.resolve(e,n)};const m=/^[a-z_][-a-z0-9._]*$/i;e.getSchemaRefs=function(t,e){if("boolean"==typeof t)return{};const{schemaId:n,uriResolver:i}=this.opts,s=p(t[n]||e),a={"":s},l=h(i,s,!1),c={},u=new Set;return r(t,{allKeys:!0},((t,e,i,o)=>{if(void 0===o)return;const r=l+e;let s=a[o];function h(e){const n=this.opts.uriResolver.resolve;if(e=p(s?n(s,e):e),u.has(e))throw f(e);u.add(e);let i=this.refs[e];return"string"==typeof i&&(i=this.refs[i]),"object"==typeof i?d(t,i.schema,e):e!==p(r)&&("#"===e[0]?(d(t,c[e],e),c[e]=t):this.refs[e]=r),e}function g(t){if("string"==typeof t){if(!m.test(t))throw new Error(`invalid anchor "${t}"`);h.call(this,`#${t}`)}}"string"==typeof t[n]&&(s=h.call(this,t[n])),g.call(this,t.$anchor),g.call(this,t.$dynamicAnchor),a[e]=s})),c;function d(t,e,n){if(void 0!==e&&!o(t,e))throw f(n)}function f(t){return new Error(`reference "${t}" resolves to more than one schema`)}}},396:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getRules=e.isJSONType=void 0;const n=new Set(["string","number","integer","boolean","null","object","array"]);e.isJSONType=function(t){return"string"==typeof t&&n.has(t)},e.getRules=function(){const t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...t,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}},4227:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.checkStrictMode=e.getErrorPath=e.Type=e.useFunc=e.setEvaluated=e.evaluatedPropsToName=e.mergeEvaluated=e.eachItem=e.unescapeJsonPointer=e.escapeJsonPointer=e.escapeFragment=e.unescapeFragment=e.schemaRefOrVal=e.schemaHasRulesButRef=e.schemaHasRules=e.checkUnknownRules=e.alwaysValidSchema=e.toHash=void 0;const i=n(9029),o=n(1520);function r(t,e=t.schema){const{opts:n,self:i}=t;if(!n.strictSchema)return;if("boolean"==typeof e)return;const o=i.RULES.keywords;for(const n in e)o[n]||m(t,`unknown keyword: "${n}"`)}function s(t,e){if("boolean"==typeof t)return!t;for(const n in t)if(e[n])return!0;return!1}function a(t){return"number"==typeof t?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}function l(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}function c({mergeNames:t,mergeToName:e,mergeValues:n,resultToName:o}){return(r,s,a,l)=>{const c=void 0===a?s:a instanceof i.Name?(s instanceof i.Name?t(r,s,a):e(r,s,a),a):s instanceof i.Name?(e(r,a,s),s):n(s,a);return l!==i.Name||c instanceof i.Name?c:o(r,c)}}function h(t,e){if(!0===e)return t.var("props",!0);const n=t.var("props",i._`{}`);return void 0!==e&&u(t,n,e),n}function u(t,e,n){Object.keys(n).forEach((n=>t.assign(i._`${e}${(0,i.getProperty)(n)}`,!0)))}e.toHash=function(t){const e={};for(const n of t)e[n]=!0;return e},e.alwaysValidSchema=function(t,e){return"boolean"==typeof e?e:0===Object.keys(e).length||(r(t,e),!s(e,t.self.RULES.all))},e.checkUnknownRules=r,e.schemaHasRules=s,e.schemaHasRulesButRef=function(t,e){if("boolean"==typeof t)return!t;for(const n in t)if("$ref"!==n&&e.all[n])return!0;return!1},e.schemaRefOrVal=function({topSchemaRef:t,schemaPath:e},n,o,r){if(!r){if("number"==typeof n||"boolean"==typeof n)return n;if("string"==typeof n)return i._`${n}`}return i._`${t}${e}${(0,i.getProperty)(o)}`},e.unescapeFragment=function(t){return l(decodeURIComponent(t))},e.escapeFragment=function(t){return encodeURIComponent(a(t))},e.escapeJsonPointer=a,e.unescapeJsonPointer=l,e.eachItem=function(t,e){if(Array.isArray(t))for(const n of t)e(n);else e(t)},e.mergeEvaluated={props:c({mergeNames:(t,e,n)=>t.if(i._`${n} !== true && ${e} !== undefined`,(()=>{t.if(i._`${e} === true`,(()=>t.assign(n,!0)),(()=>t.assign(n,i._`${n} || {}`).code(i._`Object.assign(${n}, ${e})`)))})),mergeToName:(t,e,n)=>t.if(i._`${n} !== true`,(()=>{!0===e?t.assign(n,!0):(t.assign(n,i._`${n} || {}`),u(t,n,e))})),mergeValues:(t,e)=>!0===t||{...t,...e},resultToName:h}),items:c({mergeNames:(t,e,n)=>t.if(i._`${n} !== true && ${e} !== undefined`,(()=>t.assign(n,i._`${e} === true ? true : ${n} > ${e} ? ${n} : ${e}`))),mergeToName:(t,e,n)=>t.if(i._`${n} !== true`,(()=>t.assign(n,!0===e||i._`${n} > ${e} ? ${n} : ${e}`))),mergeValues:(t,e)=>!0===t||Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})},e.evaluatedPropsToName=h,e.setEvaluated=u;const d={};var p;function m(t,e,n=t.opts.strictSchema){if(n){if(e=`strict mode: ${e}`,!0===n)throw new Error(e);t.self.logger.warn(e)}}e.useFunc=function(t,e){return t.scopeValue("func",{ref:e,code:d[e.code]||(d[e.code]=new o._Code(e.code))})},function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"}(p||(e.Type=p={})),e.getErrorPath=function(t,e,n){if(t instanceof i.Name){const o=e===p.Num;return n?o?i._`"[" + ${t} + "]"`:i._`"['" + ${t} + "']"`:o?i._`"/" + ${t}`:i._`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return n?(0,i.getProperty)(t).toString():"/"+a(t)},e.checkStrictMode=m},7887:(t,e)=>{"use strict";function n(t,e){return e.rules.some((e=>i(t,e)))}function i(t,e){var n;return void 0!==t[e.keyword]||(null===(n=e.definition.implements)||void 0===n?void 0:n.some((e=>void 0!==t[e])))}Object.defineProperty(e,"__esModule",{value:!0}),e.shouldUseRule=e.shouldUseGroup=e.schemaHasRulesForType=void 0,e.schemaHasRulesForType=function({schema:t,self:e},i){const o=e.RULES.types[i];return o&&!0!==o&&n(t,o)},e.shouldUseGroup=n,e.shouldUseRule=i},8727:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;const i=n(8708),o=n(9029),r=n(2023),s={message:"boolean schema is false"};function a(t,e){const{gen:n,data:o}=t,r={gen:n,keyword:"false schema",data:o,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,i.reportError)(r,s,void 0,e)}e.topBoolOrEmptySchema=function(t){const{gen:e,schema:n,validateName:i}=t;!1===n?a(t,!1):"object"==typeof n&&!0===n.$async?e.return(r.default.data):(e.assign(o._`${i}.errors`,null),e.return(!0))},e.boolOrEmptySchema=function(t,e){const{gen:n,schema:i}=t;!1===i?(n.var(e,!1),a(t)):n.var(e,!0)}},208:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.reportTypeError=e.checkDataTypes=e.checkDataType=e.coerceAndCheckDataType=e.getJSONTypes=e.getSchemaTypes=e.DataType=void 0;const i=n(396),o=n(7887),r=n(8708),s=n(9029),a=n(4227);var l;function c(t){const e=Array.isArray(t)?t:t?[t]:[];if(e.every(i.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}!function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"}(l||(e.DataType=l={})),e.getSchemaTypes=function(t){const e=c(t.type);if(e.includes("null")){if(!1===t.nullable)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&void 0!==t.nullable)throw new Error('"nullable" cannot be used without "type"');!0===t.nullable&&e.push("null")}return e},e.getJSONTypes=c,e.coerceAndCheckDataType=function(t,e){const{gen:n,data:i,opts:r}=t,a=function(t,e){return e?t.filter((t=>h.has(t)||"array"===e&&"array"===t)):[]}(e,r.coerceTypes),c=e.length>0&&!(0===a.length&&1===e.length&&(0,o.schemaHasRulesForType)(t,e[0]));if(c){const o=d(e,i,r.strictNumbers,l.Wrong);n.if(o,(()=>{a.length?function(t,e,n){const{gen:i,data:o,opts:r}=t,a=i.let("dataType",s._`typeof ${o}`),l=i.let("coerced",s._`undefined`);"array"===r.coerceTypes&&i.if(s._`${a} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,(()=>i.assign(o,s._`${o}[0]`).assign(a,s._`typeof ${o}`).if(d(e,o,r.strictNumbers),(()=>i.assign(l,o))))),i.if(s._`${l} !== undefined`);for(const t of n)(h.has(t)||"array"===t&&"array"===r.coerceTypes)&&c(t);function c(t){switch(t){case"string":return void i.elseIf(s._`${a} == "number" || ${a} == "boolean"`).assign(l,s._`"" + ${o}`).elseIf(s._`${o} === null`).assign(l,s._`""`);case"number":return void i.elseIf(s._`${a} == "boolean" || ${o} === null
|
|
1
|
+
var bio;(()=>{var t={8924:(t,e,n)=>{"use strict";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(t){const e=t in o.aaSynonyms?o.aaSynonyms[t]:t;return super.get(e)}}o.aaSynonyms={MeNle:"L",MeA:"A",MeG:"G",MeF:"F"};class r{static getPalette(t="grok"){switch(t){case"grok":return o.GrokGroups;case"lesk":return o.Lesk;default:throw new Error(`ChemPalette: scheme \`${t}\` does not exist`)}}static getInnerOuter(t){let e=0,n="",i="";for(const o of t)"("==o?e++:")"==o?e--:e?n+=o:i+=o;return isNaN(parseInt(n))?[i,n]:[i,""]}static getColorAAPivot(t="",e="grok"){const n=this.getPalette(e);let[i,o]=this.getInnerOuter(t);if(i=i.length>6?`${i.slice(0,3)}...`:i,o=o.length>6?`${o.slice(0,3)}...`:o,1==t.length||"("==t[1]){const e=t[0]?.toUpperCase();return e in n?[n.get(e),e,o,1]:[this.undefinedColor,i,o,1]}if("d"==t[0]&&t[1]in n&&(2==t.length||"("==t[2])){const e=t[1]?.toUpperCase();return e in n?[n.get(e),e,o,2]:[this.undefinedColor,i,o,2]}if(t.substring(0,3)in this.AAFullNames&&(3==t.length||"("==t[3])){const e=this.AAFullNames[t.substring(0,3)];return e in n?[n.get(e),e,o,3]:[this.undefinedColor,i,o,3]}if(t[0]?.toLowerCase()==t[0]&&t.substring(1,3)in this.AAFullNames&&(4==t.length||"("==t[4])){const e=this.AAFullNames[t.substring(1,3)];return e in n?[n.get(e),e,o,4]:[this.undefinedColor,i,o,4]}return[this.undefinedColor,i,o,0]}}r.SemType="Aminoacids",r.SemTypeMultipleAlignment="AminoacidsMultipleAlignment",r.undefinedColor="rgb(100,100,100)",r.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"},r.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"},r.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(*)*"},r.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:(t,e,n)=>{"use strict";n.d(e,{j:()=>o});var i=n(6082);async function o(){const t=i.Func.find({package:"Chem",name:"getRdKitModule"});if(0===t.length)throw new Error('Package "Chem" must be installed for getRdKitModule.');return(await t[0].prepare().call()).getOutputParamValue()}},3599:(t,e,n)=>{"use strict";n.d(e,{o:()=>i.o});var i=n(6869)},9124:(t,e,n)=>{"use strict";n.d(e,{b2:()=>r,fA:()=>s});var i=n(7389),o=n(6082);async function r(){const t="Helm",e=o.Func.find({package:t,name:"getHelmHelper"});if(0===e.length)throw new Error(`Package '${t}' must be installed for HelmHelper.`);return(await e[0].prepare().call()).getOutputParamValue()}function s(t,e){if(!t)throw new Error("Argument 'a' of type Atom or HelmType is mandatory.");let n,i;const o=t;return"ATOM"===o.T?(n=o.biotype(),i=o.elem):(n=t,i=e),[n,i]}o.JsInputBase,Error,i.input.helmAsync=async function(t,e){return(await r()).createHelmInput(t,e)}},8438:(t,e,n)=>{"use strict";function i(t){return t.startsWith("[")&&t.endsWith("]")?t.slice(1,-1):t}n.d(e,{D:()=>i})},8123:(t,e,n)=>{"use strict";n.d(e,{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:(t,e,n)=>{"use strict";n.d(e,{Eu:()=>a,ub:()=>s});var i=n(4328);const o="Libraries";let r=Promise.resolve();async function s(){let t;return r=r.then((async()=>{const e=i.userSettings.getValue(o,"Settings",!0);t=e?JSON.parse(e):{exclude:[],explicit:[],duplicateMonomerPreferences:{}},t.exclude=t.exclude instanceof Array?t.exclude:[],t.explicit=t.explicit instanceof Array?t.explicit:[],t.duplicateMonomerPreferences=t.duplicateMonomerPreferences instanceof Object?t.duplicateMonomerPreferences:{},console.debug(`Bio: getUserLibSettings()\n${JSON.stringify(t,void 0,2)}`)})),await r,t}async function a(t){r=r.then((async()=>{console.debug(`Bio: setUserLibSettings()\n${JSON.stringify(t,void 0,2)}`),i.userSettings.add(o,"Settings",JSON.stringify(t),!0)})),await r}},5553:(t,e,n)=>{"use strict";n.d(e,{Qc:()=>A,WN:()=>S});var i=n(1991),o=n.n(i);const r="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,s=new Set,a="object"==typeof process&&process?process:{},l=(t,e,n,i)=>{"function"==typeof a.emitWarning?a.emitWarning(t,e,n,i):console.error(`[${n}] ${e}: ${t}`)};let c=globalThis.AbortController,h=globalThis.AbortSignal;if(void 0===c){h=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(t,e){this._onabort.push(e)}},c=class{constructor(){e()}signal=new h;abort(t){if(!this.signal.aborted){this.signal.reason=t,this.signal.aborted=!0;for(const e of this.signal._onabort)e(t);this.signal.onabort?.(t)}}};let t="1"!==a.env?.LRU_CACHE_IGNORE_AC_WARNING;const e=()=>{t&&(t=!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",e))}}Symbol("type");const u=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),d=t=>u(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?p:null:null;class p extends Array{constructor(t){super(t),this.fill(0)}}class m{heap;length;static#t=!1;static create(t){const e=d(t);if(!e)return[];m.#t=!0;const n=new m(t,e);return m.#t=!1,n}constructor(t,e){if(!m.#t)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}}class f{#e;#n;#i;#o;#r;#s;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#a;#l;#c;#h;#u;#d;#p;#m;#f;#g;#y;#b;#v;#w;#C;#A;#S;static unsafeExposeInternals(t){return{starts:t.#v,ttls:t.#w,sizes:t.#b,keyMap:t.#c,keyList:t.#h,valList:t.#u,next:t.#d,prev:t.#p,get head(){return t.#m},get tail(){return t.#f},free:t.#g,isBackgroundFetch:e=>t.#x(e),backgroundFetch:(e,n,i,o)=>t.#E(e,n,i,o),moveToTail:e=>t.#T(e),indexes:e=>t.#M(e),rindexes:e=>t.#_(e),isStale:e=>t.#I(e)}}get max(){return this.#e}get maxSize(){return this.#n}get calculatedSize(){return this.#l}get size(){return this.#a}get fetchMethod(){return this.#r}get memoMethod(){return this.#s}get dispose(){return this.#i}get disposeAfter(){return this.#o}constructor(t){const{max:e=0,ttl:n,ttlResolution:i=1,ttlAutopurge:o,updateAgeOnGet:r,updateAgeOnHas:a,allowStale:c,dispose:h,disposeAfter:p,noDisposeOnSet:g,noUpdateTTL:y,maxSize:b=0,maxEntrySize:v=0,sizeCalculation:w,fetchMethod:C,memoMethod:A,noDeleteOnFetchRejection:S,noDeleteOnStaleGet:x,allowStaleOnFetchRejection:E,allowStaleOnFetchAbort:T,ignoreFetchAbort:M}=t;if(0!==e&&!u(e))throw new TypeError("max option must be a nonnegative integer");const _=e?d(e):Array;if(!_)throw new Error("invalid max value: "+e);if(this.#e=e,this.#n=b,this.maxEntrySize=v||this.#n,this.sizeCalculation=w,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!==A&&"function"!=typeof A)throw new TypeError("memoMethod must be a function if defined");if(this.#s=A,void 0!==C&&"function"!=typeof C)throw new TypeError("fetchMethod must be a function if specified");if(this.#r=C,this.#A=!!C,this.#c=new Map,this.#h=new Array(e).fill(void 0),this.#u=new Array(e).fill(void 0),this.#d=new _(e),this.#p=new _(e),this.#m=0,this.#f=0,this.#g=m.create(e),this.#a=0,this.#l=0,"function"==typeof h&&(this.#i=h),"function"==typeof p?(this.#o=p,this.#y=[]):(this.#o=void 0,this.#y=void 0),this.#C=!!this.#i,this.#S=!!this.#o,this.noDisposeOnSet=!!g,this.noUpdateTTL=!!y,this.noDeleteOnFetchRejection=!!S,this.allowStaleOnFetchRejection=!!E,this.allowStaleOnFetchAbort=!!T,this.ignoreFetchAbort=!!M,0!==this.maxEntrySize){if(0!==this.#n&&!u(this.#n))throw new TypeError("maxSize must be a positive integer if specified");if(!u(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#L()}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!x,this.updateAgeOnGet=!!r,this.updateAgeOnHas=!!a,this.ttlResolution=u(i)||0===i?i:1,this.ttlAutopurge=!!o,this.ttl=n||0,this.ttl){if(!u(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#N()}if(0===this.#e&&0===this.ttl&&0===this.#n)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#n){const t="LRU_CACHE_UNBOUNDED";(t=>!s.has(t))(t)&&(s.add(t),l("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",t,f))}}getRemainingTTL(t){return this.#c.has(t)?1/0:0}#N(){const t=new p(this.#e),e=new p(this.#e);this.#w=t,this.#v=e,this.#P=(n,i,o=r.now())=>{if(e[n]=0!==i?o:0,t[n]=i,0!==i&&this.ttlAutopurge){const t=setTimeout((()=>{this.#I(n)&&this.#$(this.#h[n],"expire")}),i+1);t.unref&&t.unref()}},this.#R=n=>{e[n]=0!==t[n]?r.now():0},this.#k=(o,r)=>{if(t[r]){const s=t[r],a=e[r];if(!s||!a)return;o.ttl=s,o.start=a,o.now=n||i();const l=o.now-a;o.remainingTTL=s-l}};let n=0;const i=()=>{const t=r.now();if(this.ttlResolution>0){n=t;const e=setTimeout((()=>n=0),this.ttlResolution);e.unref&&e.unref()}return t};this.getRemainingTTL=o=>{const r=this.#c.get(o);if(void 0===r)return 0;const s=t[r],a=e[r];return s&&a?s-((n||i())-a):1/0},this.#I=o=>{const r=e[o],s=t[o];return!!s&&!!r&&(n||i())-r>s}}#R=()=>{};#k=()=>{};#P=()=>{};#I=()=>!1;#L(){const t=new p(this.#e);this.#l=0,this.#b=t,this.#O=e=>{this.#l-=t[e],t[e]=0},this.#H=(t,e,n,i)=>{if(this.#x(e))return 0;if(!u(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(e,t),!u(n))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return n},this.#G=(e,n,i)=>{if(t[e]=n,this.#n){const n=this.#n-t[e];for(;this.#l>n;)this.#F(!0)}this.#l+=t[e],i&&(i.entrySize=n,i.totalCalculatedSize=this.#l)}}#O=t=>{};#G=(t,e,n)=>{};#H=(t,e,n,i)=>{if(n||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#M({allowStale:t=this.allowStale}={}){if(this.#a)for(let e=this.#f;this.#D(e)&&(!t&&this.#I(e)||(yield e),e!==this.#m);)e=this.#p[e]}*#_({allowStale:t=this.allowStale}={}){if(this.#a)for(let e=this.#m;this.#D(e)&&(!t&&this.#I(e)||(yield e),e!==this.#f);)e=this.#d[e]}#D(t){return void 0!==t&&this.#c.get(this.#h[t])===t}*entries(){for(const t of this.#M())void 0===this.#u[t]||void 0===this.#h[t]||this.#x(this.#u[t])||(yield[this.#h[t],this.#u[t]])}*rentries(){for(const t of this.#_())void 0===this.#u[t]||void 0===this.#h[t]||this.#x(this.#u[t])||(yield[this.#h[t],this.#u[t]])}*keys(){for(const t of this.#M()){const e=this.#h[t];void 0===e||this.#x(this.#u[t])||(yield e)}}*rkeys(){for(const t of this.#_()){const e=this.#h[t];void 0===e||this.#x(this.#u[t])||(yield e)}}*values(){for(const t of this.#M())void 0===this.#u[t]||this.#x(this.#u[t])||(yield this.#u[t])}*rvalues(){for(const t of this.#_())void 0===this.#u[t]||this.#x(this.#u[t])||(yield this.#u[t])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,e={}){for(const n of this.#M()){const i=this.#u[n],o=this.#x(i)?i.__staleWhileFetching:i;if(void 0!==o&&t(o,this.#h[n],this))return this.get(this.#h[n],e)}}forEach(t,e=this){for(const n of this.#M()){const i=this.#u[n],o=this.#x(i)?i.__staleWhileFetching:i;void 0!==o&&t.call(e,o,this.#h[n],this)}}rforEach(t,e=this){for(const n of this.#_()){const i=this.#u[n],o=this.#x(i)?i.__staleWhileFetching:i;void 0!==o&&t.call(e,o,this.#h[n],this)}}purgeStale(){let t=!1;for(const e of this.#_({allowStale:!0}))this.#I(e)&&(this.#$(this.#h[e],"expire"),t=!0);return t}info(t){const e=this.#c.get(t);if(void 0===e)return;const n=this.#u[e],i=this.#x(n)?n.__staleWhileFetching:n;if(void 0===i)return;const o={value:i};if(this.#w&&this.#v){const t=this.#w[e],n=this.#v[e];if(t&&n){const e=t-(r.now()-n);o.ttl=e,o.start=Date.now()}}return this.#b&&(o.size=this.#b[e]),o}dump(){const t=[];for(const e of this.#M({allowStale:!0})){const n=this.#h[e],i=this.#u[e],o=this.#x(i)?i.__staleWhileFetching:i;if(void 0===o||void 0===n)continue;const s={value:o};if(this.#w&&this.#v){s.ttl=this.#w[e];const t=r.now()-this.#v[e];s.start=Math.floor(Date.now()-t)}this.#b&&(s.size=this.#b[e]),t.unshift([n,s])}return t}load(t){this.clear();for(const[e,n]of t){if(n.start){const t=Date.now()-n.start;n.start=r.now()-t}this.set(e,n.value,n)}}set(t,e,n={}){if(void 0===e)return this.delete(t),this;const{ttl:i=this.ttl,start:o,noDisposeOnSet:r=this.noDisposeOnSet,sizeCalculation:s=this.sizeCalculation,status:a}=n;let{noUpdateTTL:l=this.noUpdateTTL}=n;const c=this.#H(t,e,n.size||0,s);if(this.maxEntrySize&&c>this.maxEntrySize)return a&&(a.set="miss",a.maxEntrySizeExceeded=!0),this.#$(t,"set"),this;let h=0===this.#a?void 0:this.#c.get(t);if(void 0===h)h=0===this.#a?this.#f:0!==this.#g.length?this.#g.pop():this.#a===this.#e?this.#F(!1):this.#a,this.#h[h]=t,this.#u[h]=e,this.#c.set(t,h),this.#d[this.#f]=h,this.#p[h]=this.#f,this.#f=h,this.#a++,this.#G(h,c,a),a&&(a.set="add"),l=!1;else{this.#T(h);const n=this.#u[h];if(e!==n){if(this.#A&&this.#x(n)){n.__abortController.abort(new Error("replaced"));const{__staleWhileFetching:e}=n;void 0===e||r||(this.#C&&this.#i?.(e,t,"set"),this.#S&&this.#y?.push([e,t,"set"]))}else r||(this.#C&&this.#i?.(n,t,"set"),this.#S&&this.#y?.push([n,t,"set"]));if(this.#O(h),this.#G(h,c,a),this.#u[h]=e,a){a.set="replace";const t=n&&this.#x(n)?n.__staleWhileFetching:n;void 0!==t&&(a.oldValue=t)}}else a&&(a.set="update")}if(0===i||this.#w||this.#N(),this.#w&&(l||this.#P(h,i,o),a&&this.#k(a,h)),!r&&this.#S&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#o?.(...e)}return this}pop(){try{for(;this.#a;){const t=this.#u[this.#m];if(this.#F(!0),this.#x(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(void 0!==t)return t}}finally{if(this.#S&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#o?.(...e)}}}#F(t){const e=this.#m,n=this.#h[e],i=this.#u[e];return this.#A&&this.#x(i)?i.__abortController.abort(new Error("evicted")):(this.#C||this.#S)&&(this.#C&&this.#i?.(i,n,"evict"),this.#S&&this.#y?.push([i,n,"evict"])),this.#O(e),t&&(this.#h[e]=void 0,this.#u[e]=void 0,this.#g.push(e)),1===this.#a?(this.#m=this.#f=0,this.#g.length=0):this.#m=this.#d[e],this.#c.delete(n),this.#a--,e}has(t,e={}){const{updateAgeOnHas:n=this.updateAgeOnHas,status:i}=e,o=this.#c.get(t);if(void 0!==o){const t=this.#u[o];if(this.#x(t)&&void 0===t.__staleWhileFetching)return!1;if(!this.#I(o))return n&&this.#R(o),i&&(i.has="hit",this.#k(i,o)),!0;i&&(i.has="stale",this.#k(i,o))}else i&&(i.has="miss");return!1}peek(t,e={}){const{allowStale:n=this.allowStale}=e,i=this.#c.get(t);if(void 0===i||!n&&this.#I(i))return;const o=this.#u[i];return this.#x(o)?o.__staleWhileFetching:o}#E(t,e,n,i){const o=void 0===e?void 0:this.#u[e];if(this.#x(o))return o;const r=new c,{signal:s}=n;s?.addEventListener("abort",(()=>r.abort(s.reason)),{signal:r.signal});const a={signal:r.signal,options:n,context:i},l=(i,o=!1)=>{const{aborted:s}=r.signal,l=n.ignoreFetchAbort&&void 0!==i;if(n.status&&(s&&!o?(n.status.fetchAborted=!0,n.status.fetchError=r.signal.reason,l&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),s&&!l&&!o)return h(r.signal.reason);const c=u;return this.#u[e]===u&&(void 0===i?c.__staleWhileFetching?this.#u[e]=c.__staleWhileFetching:this.#$(t,"fetch"):(n.status&&(n.status.fetchUpdated=!0),this.set(t,i,a.options))),i},h=i=>{const{aborted:o}=r.signal,s=o&&n.allowStaleOnFetchAbort,a=s||n.allowStaleOnFetchRejection,l=a||n.noDeleteOnFetchRejection,c=u;if(this.#u[e]===u&&(l&&void 0!==c.__staleWhileFetching?s||(this.#u[e]=c.__staleWhileFetching):this.#$(t,"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 u=new Promise(((e,i)=>{const s=this.#r?.(t,o,a);s&&s instanceof Promise&&s.then((t=>e(void 0===t?void 0:t)),i),r.signal.addEventListener("abort",(()=>{n.ignoreFetchAbort&&!n.allowStaleOnFetchAbort||(e(void 0),n.allowStaleOnFetchAbort&&(e=t=>l(t,!0)))}))})).then(l,(t=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=t),h(t)))),d=Object.assign(u,{__abortController:r,__staleWhileFetching:o,__returned:void 0});return void 0===e?(this.set(t,d,{...a.options,status:void 0}),e=this.#c.get(t)):this.#u[e]=d,d}#x(t){if(!this.#A)return!1;const e=t;return!!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof c}async fetch(t,e={}){const{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:r=this.ttl,noDisposeOnSet:s=this.noDisposeOnSet,size:a=0,sizeCalculation:l=this.sizeCalculation,noUpdateTTL:c=this.noUpdateTTL,noDeleteOnFetchRejection:h=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:u=this.allowStaleOnFetchRejection,ignoreFetchAbort:d=this.ignoreFetchAbort,allowStaleOnFetchAbort:p=this.allowStaleOnFetchAbort,context:m,forceRefresh:f=!1,status:g,signal:y}=e;if(!this.#A)return g&&(g.fetch="get"),this.get(t,{allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:o,status:g});const b={allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:o,ttl:r,noDisposeOnSet:s,size:a,sizeCalculation:l,noUpdateTTL:c,noDeleteOnFetchRejection:h,allowStaleOnFetchRejection:u,allowStaleOnFetchAbort:p,ignoreFetchAbort:d,status:g,signal:y};let v=this.#c.get(t);if(void 0===v){g&&(g.fetch="miss");const e=this.#E(t,v,b,m);return e.__returned=e}{const e=this.#u[v];if(this.#x(e)){const t=n&&void 0!==e.__staleWhileFetching;return g&&(g.fetch="inflight",t&&(g.returnedStale=!0)),t?e.__staleWhileFetching:e.__returned=e}const o=this.#I(v);if(!f&&!o)return g&&(g.fetch="hit"),this.#T(v),i&&this.#R(v),g&&this.#k(g,v),e;const r=this.#E(t,v,b,m),s=void 0!==r.__staleWhileFetching&&n;return g&&(g.fetch=o?"stale":"refresh",s&&o&&(g.returnedStale=!0)),s?r.__staleWhileFetching:r.__returned=r}}async forceFetch(t,e={}){const n=await this.fetch(t,e);if(void 0===n)throw new Error("fetch() returned undefined");return n}memo(t,e={}){const n=this.#s;if(!n)throw new Error("no memoMethod provided to constructor");const{context:i,forceRefresh:o,...r}=e,s=this.get(t,r);if(!o&&void 0!==s)return s;const a=n(t,s,{options:r,context:i});return this.set(t,a,r),a}get(t,e={}){const{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:r}=e,s=this.#c.get(t);if(void 0!==s){const e=this.#u[s],a=this.#x(e);return r&&this.#k(r,s),this.#I(s)?(r&&(r.get="stale"),a?(r&&n&&void 0!==e.__staleWhileFetching&&(r.returnedStale=!0),n?e.__staleWhileFetching:void 0):(o||this.#$(t,"expire"),r&&n&&(r.returnedStale=!0),n?e:void 0)):(r&&(r.get="hit"),a?e.__staleWhileFetching:(this.#T(s),i&&this.#R(s),e))}r&&(r.get="miss")}#B(t,e){this.#p[e]=t,this.#d[t]=e}#T(t){t!==this.#f&&(t===this.#m?this.#m=this.#d[t]:this.#B(this.#p[t],this.#d[t]),this.#B(this.#f,t),this.#f=t)}delete(t){return this.#$(t,"delete")}#$(t,e){let n=!1;if(0!==this.#a){const i=this.#c.get(t);if(void 0!==i)if(n=!0,1===this.#a)this.#V(e);else{this.#O(i);const n=this.#u[i];if(this.#x(n)?n.__abortController.abort(new Error("deleted")):(this.#C||this.#S)&&(this.#C&&this.#i?.(n,t,e),this.#S&&this.#y?.push([n,t,e])),this.#c.delete(t),this.#h[i]=void 0,this.#u[i]=void 0,i===this.#f)this.#f=this.#p[i];else if(i===this.#m)this.#m=this.#d[i];else{const t=this.#p[i];this.#d[t]=this.#d[i];const e=this.#d[i];this.#p[e]=this.#p[i]}this.#a--,this.#g.push(i)}}if(this.#S&&this.#y?.length){const t=this.#y;let e;for(;e=t?.shift();)this.#o?.(...e)}return n}clear(){return this.#V("delete")}#V(t){for(const e of this.#_({allowStale:!0})){const n=this.#u[e];if(this.#x(n))n.__abortController.abort(new Error("deleted"));else{const i=this.#h[e];this.#C&&this.#i?.(n,i,t),this.#S&&this.#y?.push([n,i,t])}}if(this.#c.clear(),this.#u.fill(void 0),this.#h.fill(void 0),this.#w&&this.#v&&(this.#w.fill(0),this.#v.fill(0)),this.#b&&this.#b.fill(0),this.#m=0,this.#f=0,this.#g.length=0,this.#l=0,this.#a=0,this.#S&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#o?.(...e)}}}function g(t){window.$monomerHover=t}var y=n(2003),b=n(6077),v=n(3561),w=n(9235);const C="MonomerHoverLinks";async function A(t,e,n,i,r,s=!1){const a=i.getSeqHandler(t),l=a.alphabet==y.YI.RNA||a.alphabet==y.YI.DNA,c=a.isHelm()&&l,h=!a.isHelm()&&l,u=t=>null==t?null:c?s?t:Math.floor(t/3):h&&s?3*t+1:t,d=s?await i.getHelmToMolfileConverter(n):null,p=new f({max:100});function m(t,e){const a=t.get(e);if(null==a)return null;let l=p.get(a);return l||p.set(a,l=function(t,e){const a=i.getSeqHandler(t);if(s){const t=a.getHelm(e);return i.helmToAtomicLevelSingle(t,d,!1,!1).monomers}{const t=a.getSplitted(e),i=a.defaultBiotype,s=o().count(0).take(t.length).map((e=>({position:e,symbol:t.getCanonical(e),biotype:i}))).toArray(),l=a.alphabet,c=l==y.YI.RNA||l==y.YI.DNA?"RNA":"PEPTIDE",h=(0,b.eM)([s],c,l,n,r);return(0,v.gU)(s,h,l,c).monomers}}(t,e)),l}const A={targetCol:e,handler:(e,i,o)=>{const r=o.grid,s=e.tableRowIndex,a=e.gridRow,l=r.cell(o.name,a),c=null!==(h=window.$monomerHover)&&void 0!==h?h:null;var h;if(!c||c&&(c.dataFrameId!=t.dataFrame.id||c.gridRowIdx!=a||c.seqColName!=t.name||c.seqPosition!=i?.position)){if(c&&(g(null),c.gridCell.render()),!i)return g(null),!0;g({gridCell:l,dataFrameId:t.dataFrame.id,gridRowIdx:a,seqColName:t.name,seqPosition:u(i?.position)??-1,getSubstruct:()=>{if(!i||"*"===i.symbol)return;const e=m(t,s);if(!e)return;const o=e.get(u(i?.position));return o?(0,w.H)([o],n):{atoms:[],bonds:[],highlightAtomColors:[],highlightBondColors:[]}}}),l.render()}return!0},getSubstruct:i=>{if("true"!=e.getTag(".sequence-src-highlight-monomers"))return;if(null==i)return;if(!t.get(i))return;const o=m(t,i);return o?(0,w.H)(o.values(),n):void 0}};return function(t,e){let n=t[C];n||(n=t[C]=[]),n.push(e),t[C]=n}(t.temp,A),function(t,e){let n=t["substruct-providers"];n||(n=t["substruct-providers"]=[]),n.push(e),t["substruct-providers"]=n}(e.temp,A),A}function S(t,e){try{const n=t.tableColumn;if(!n)return;const i=function(t){return t.temp[C]??[]}(n);for(let n=i.length-1;n>=0;--n){const o=i[n],r=t.grid.col(o.targetCol.name);if(r&&!o.handler(t,e,r))break}}catch(t){console.error(t)}}},6718:(t,e,n)=>{"use strict";n.d(e,{A7:()=>p,pj:()=>h,uL:()=>u,uX:()=>c});var i=n(6082),o=n(4328),r=n(6295),s=n(3151),a=n(3077),l=n(439);function c(t){const e=[];for(let n=0;n<t.rowCount;n++){const i={};Object.keys(s.Ec).forEach((e=>{if("symbol"===e){const o=t.get(s.Ec[e],n);i[e]="."===o?t.get(s.yw,n):o}else if("rgroups"===e){const o=t.get(s.Ec[e],n).split("\n"),r=[];o.forEach((t=>{const e={},n=t.substring(t.lastIndexOf("]")+1),i=t.match(/\[R(\d+)\]/)[1];e.capGroupSmiles="H"===n?`[*:${i}][H]`:`O[*:${i}]`,e.alternateId="H"===n?`R${i}-H`:`R${i}-OH`,e.capGroupName="H"===n?"H":"OH",e.label=`R${i}`,r.push(e)})),i[e]=r}else s.Ec[e]&&(i[e]=t.get(s.Ec[e],n))})),i.author??(i.author=""),i.id??(i.id=0),i.smiles??(i.smiles=""),i.monomerType??(i.monomerType="Backbone"),i.createDate??(i.createDate=null),e.push(i)}return e}async function h(){const t=i.Func.find({package:"Bio",name:"getMonomerLibHelper"});if(0===t.length)throw new Error('Package "Bio" must be installed for MonomerLibHelper.');return(await t[0].prepare().call()).getOutputParamValue()}async function u(t,e,n){t instanceof i.Column&&(t=(0,a.R)(t,n).columns.toList());const r=(await h()).getMonomerLib(),s=new Array(t.length),c=t[0].length,u=new Float32Array(c);for(let n=0;n<t.length;++n){const a=n<e.length?e.getCanonical(n):l._S,h=r.getMonomer("PEPTIDE",a)?.smiles??"",d=t[n],p=d.getRawData(),m=d.categories,f=m.indexOf("");if(s[n]={categories:m,data:p,emptyIndex:f},void 0===a)continue;const g=i.Column.fromStrings("smiles",m.map((t=>r.getMonomer("PEPTIDE",t)?.smiles??""))),y=(i.DataFrame.fromColumns([g]),await o.chem.getSimilarities(g,h)),b=y?y.getRawData():null;for(let t=0;t<c;++t){const e=p[t];a!==l._S&&e!==f?u[t]+=b[e]:a===l._S&&e===f&&(u[t]+=1)}}for(let n=0;n<u.length;++n){let o=u[n]/e.length;for(let r=0;r<t.length;++r){const t=s[r];if(r>=e.length&&t.data[n]!==t.emptyIndex||t.data[n]===t.emptyIndex&&r<e.length){o=i.FLOAT_NULL;break}}u[n]=o}return i.Column.fromFloat32Array("Similarity",u)}async function d(t){const e=(await h()).getMonomerLib(),n=[],r={},s=t.map((t=>e.getMonomer("PEPTIDE",t)?.smiles??"")),a=i.Column.fromStrings("smiles",s);for(let e=0;e<s.length;++e){r[t[e]]=e;const i=s[e],l=""===i?new Array(s.length).fill(0):(await o.chem.getSimilarities(a,i)).getRawData();l[e]=1,n[e]=Array.from(l)}return{scoringMatrix:n,alphabetIndexes:r}}async function p(t,e="Morgan"){const n=(await h()).getMonomerLib(),o=new Array(t.length).fill(0).map((()=>new Array(t.length).fill(0))),s={},a=t.map((t=>n.getMonomer("PEPTIDE",t)?.molfile||n.getMonomer("PEPTIDE",t)?.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(t);const c=i.Column.fromStrings("smiles",a),u=(i.DataFrame.fromColumns([c]),(await l.apply({col:c,fingerprintType:e}))?.entries);if(!u)return console.warn(`${e} Fingerprints could not be calculated for monomers from chem package.\n falling back to Morgan fingerprints`),await d(t);for(let e=0;e<u.length;++e)if(o[e][e]=1,s[t[e]]=e,u[e])for(let t=e+1;t<u.length;++t)u[t]&&(o[e][t]=o[t][e]=(0,r.$1)(u[e],u[t]));return{scoringMatrix:o,alphabetIndexes:s}}},6197:(t,e,n)=>{"use strict";n.d(e,{Y:()=>o});var i=n(3599);function o(t){let e;switch(t){case i.o.BASE:case i.o.SUGAR:case i.o.LINKER:case i.o.NUCLEOTIDE:case"nucleotide":e="RNA";break;case i.o.AA:e="PEPTIDE";break;case i.o.CHEM:e="CHEM";break;case i.o.BLOB:e="BLOB";break;default:e="PEPTIDE",console.warn(`Unexpected HelmType '${t}'`)}return e}},9235:(t,e,n)=>{"use strict";n.d(e,{H:()=>c,R:()=>l});var i=n(6082),o=n(1991),r=n.n(o),s=n(330),a=n(3599);async function l(t,e,o,l,c,h,u){const d=t.length,p=t.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=d/m,y=new Array(m),b=h.getSeqHandler(t),v="RNA"==l?a.o.NUCLEOTIDE:a.o.AA,w=r().count(0).take(t.length).map((t=>{const e=b.getSplitted(t);return r().count(0).take(e.length).map((t=>({position:t,symbol:e.getCanonical(t),biotype:v}))).toArray()})).toArray();for(let t=0;t<m;t++){const n=f[t],i=Math.floor(t*g),r=t===m-1?d:Math.floor((t+1)*g);y[t]=new Promise((t=>{n.onmessage=e=>{t(e.data)}})),n.postMessage({seqList:w,monomersDict:e,alphabet:o,polymerType:l,start:i,end:r})}const C=[],A=[];await Promise.all(y).then((t=>{for(const e of t)C.push(...e.molfiles),A.push(...e.warnings)})),setTimeout((()=>{f.forEach((t=>{t.terminate()}))}),0);const S=(0,s.qj)(p,t.name),x=i.Column.fromType(i.COLUMN_TYPE.STRING,S,t.length).init((t=>C[t]?.molfile));return x.semType=i.SEMTYPE.MOLECULE,x.meta.units=i.UNITS.Molecule.MOLBLOCK,x.setTag(".sequence-src-col",t.name),{molCol:x,warnings:A}}function c(t,e){const n={},o={};for(const r of t){const t=e.getWebEditorMonomer(r.biotype,r.symbol).backgroundcolor,a=(0,s.vG)(t??i.Color.toRgb(i.Color.mouseOverRows))??[1,0,0,.7];for(const t of r.atoms)n[t]=a;for(const t of r.bonds)o[t]=a}return{atoms:Object.keys(n).map((t=>parseInt(t))),bonds:Object.keys(o).map((t=>parseInt(t))),highlightAtomColors:n,highlightBondColors:o}}},3561:(t,e,n)=>{"use strict";n.d(e,{Hb:()=>l,YN:()=>f,gU:()=>c});var i=n(8123),o=n(294),r=n(3151),s=n(439),a=n(6197);function l(t,e,n){const o=new Map;for(const a of t.getMonomerSymbolsByType(e)){const l=t.getMonomer(e,a);if("RNA"===e&&("Branch"===l.monomerType||n===s.YI.DNA&&l.symbol===i.u.DEOXYRIBOSE.symbol||n===s.YI.RNA&&l.symbol===i.u.RIBOSE.symbol||l.symbol===i.u.PHOSPHATE.symbol)||"PEPTIDE"===e&&"Branch"!==l.monomerType){const t={};r.f6.forEach((e=>{t[e]=l[e]})),o.set(l.symbol,t)}}return o}function c(t,e,n,r){if(0===t.length)return o.vF.createEmpty();const l=m,{atomCount:c,bondCount:u,needsCapping:p}=l(t,e,n,r),g=new Array(c),y=new Array(u);let b,v=null,w=null;"PEPTIDE"===r?b=h:(b=d,v=n===s.YI.DNA?(0,o.xb)(e,i.u.DEOXYRIBOSE):(0,o.xb)(e,i.u.RIBOSE),w=(0,o.xb)(e,i.u.PHOSPHATE));const C={i:0,nodeShift:0,bondShift:0,backbonePositionShift:new Array(2).fill(0),branchPositionShift:new Array(2).fill(0),backboneAttachNode:0,branchAttachNode:0,flipFactor:1},A={sugar:v,phosphate:w,seqLength:t.length,atomCount:c,bondCount:u},S=new o.Cg,x=[];let E,T=0;for(C.i=0;C.i<A.seqLength;++C.i){const n=t[C.i];if(n.symbol===s._S)continue;const i=(0,o.xb)(e,{symbol:n.symbol,polymerType:(0,a.Y)(n.biotype)});E=i.terminalR2Atom;const r=C.nodeShift,l=C.bondShift;b(i,g,y,C,A),i.stereoAtoms?.forEach((t=>x.push(t+T))),T+=i.atoms.x.length;const c=C.nodeShift-r,h=new Array(c);for(let t=0;t<c;++t)h[t]=r+t;const u=C.bondShift-l,d=new Array(u);for(let t=0;t<u;++t)d[t]=l+t;S.set(C.i,{biotype:n.biotype,symbol:n.symbol,atoms:h,bonds:d})}p&&function(t,e,n,o,r=i.u.OXYGEN){const s=n.nodeShift+1;t[o.atomCount]=i.u.V3K_BEGIN_DATA_LINE+s+" "+(r??i.u.OXYGEN)+" "+f(n.backbonePositionShift[0])+" "+n.flipFactor*f(n.backbonePositionShift[1])+" 0.000000 0\n";const a=n.backboneAttachNode,l=s;e[o.bondCount]=i.u.V3K_BEGIN_DATA_LINE+n.bondShift+" 1 "+a+" "+l+"\n"}(g,y,C,A,E??i.u.OXYGEN);const M=i.u.V3K_BEGIN_COUNTS_LINE+c+" "+u+i.u.V3K_COUNTS_LINE_ENDING;let _="";return _+=i.u.V3K_HEADER_FIRST_LINE,_+=i.u.V3K_HEADER_SECOND_LINE,_+=i.u.V3K_BEGIN_CTAB_BLOCK,_+=M,_+=i.u.V3K_BEGIN_ATOM_BLOCK,_+=g.join(""),_+=i.u.V3K_END_ATOM_BLOCK,_+=i.u.V3K_BEGIN_BOND_BLOCK,_+=y.join(""),_+=i.u.V3K_END_BOND_BLOCK,x.length>0&&(_+=function(t){const e=[];let n=`M V30 MDLV30/STEABS ATOMS=(${t.length}`;for(let i=0;i<t.length;i++){const o=`${n} ${t[i]}`;o.length>76?(e.push(`${n} -\n`),n=`M V30 ${t[i]}`):n=o,i===t.length-1&&e.push(`${n})\n`)}return`M V30 BEGIN COLLECTION\n${e.join("")}M V30 END COLLECTION\n`}(x)),_+=i.u.V3K_END_CTAB_BLOCK,_+=i.u.V3K_END,{molfile:_,monomers:S}}function h(t,e,n,i){i.flipFactor=(-1)**(i.i%2),u(t,e,n,i)}function u(t,e,n,o){!function(t,e,n){for(let o=0;o<t.atoms.atomTypes.length;++o){const r=n.nodeShift+o+1;e[n.nodeShift+o]=i.u.V3K_BEGIN_DATA_LINE+r+" "+t.atoms.atomTypes[o]+" "+f(n.backbonePositionShift[0]+t.atoms.x[o])+" "+f(n.backbonePositionShift[1]+n.flipFactor*t.atoms.y[o])+" "+t.atoms.kwargs[o]}}(t,e,o),p(t,n,o),function(t,e,n){if(0!==n.backboneAttachNode){const o=n.bondShift,r=n.backboneAttachNode,s=t.meta.terminalNodes[0]+n.nodeShift;e[n.bondShift-1]=i.u.V3K_BEGIN_DATA_LINE+o+" 1 "+r+" "+s+"\n"}}(t,n,o),null!==t.meta.branchShift&&t.meta.terminalNodes.length>2&&function(t,e){e.branchAttachNode=e.nodeShift+t.meta.terminalNodes[2];for(let n=0;n<2;++n)e.branchPositionShift[n]=e.backbonePositionShift[n]+t.meta.branchShift[n]}(t,o),function(t,e){e.backboneAttachNode=e.nodeShift+t.meta.terminalNodes[1],e.bondShift+=t.bonds.atomPairs.length+1,e.nodeShift+=t.atoms.atomTypes.length,e.backbonePositionShift[0]+=t.meta.backboneShift?.[0]??0,e.backbonePositionShift[1]+=e.flipFactor*(t.meta.backboneShift?.[1]??0)}(t,o)}function d(t,e,n,o,r){if(0===o.i)u(r.sugar,e,n,o);else for(const t of[r.phosphate,r.sugar])u(t,e,n,o);!function(t,e,n,o){(function(t,e,n){for(let o=0;o<t.atoms.atomTypes.length;++o){const r=n.nodeShift+o+1;e[n.nodeShift+o]=i.u.V3K_BEGIN_DATA_LINE+r+" "+t.atoms.atomTypes[o]+" "+f(n.branchPositionShift[0]+t.atoms.x[o])+" "+f(n.branchPositionShift[1]+n.flipFactor*t.atoms.y[o])+" "+t.atoms.kwargs[o]}})(t,e,o),p(t,n,o),function(t,e,n){const o=n.bondShift,r=n.branchAttachNode,s=t.meta.terminalNodes[0]+n.nodeShift;e[o-1]=i.u.V3K_BEGIN_DATA_LINE+o+" 1 "+r+" "+s+"\n"}(t,n,o);const r=o.bondShift,s=o.branchAttachNode,a=t.meta.terminalNodes[0]+o.nodeShift;n[r-1]=i.u.V3K_BEGIN_DATA_LINE+r+" 1 "+s+" "+a+"\n",o.bondShift+=t.bonds.atomPairs.length+1,o.nodeShift+=t.atoms.atomTypes.length}(t,e,n,o)}function p(t,e,n){for(let o=0;o<t.bonds.atomPairs.length;++o){const r=n.bondShift+o+1,s=t.bonds.atomPairs[o][0]+n.nodeShift,a=t.bonds.atomPairs[o][1]+n.nodeShift;let l="";if(t.bonds.bondConfiguration.has(o)){let e=t.bonds.bondConfiguration.get(o);n.flipFactor<0&&(e=1===e?3:1),l=" CFG="+e}const c=t.bonds.kwargs.has(o)?" "+t.bonds.kwargs.get(o):"";e[n.bondShift+o]=i.u.V3K_BEGIN_DATA_LINE+r+" "+t.bonds.bondTypes[o]+" "+s+" "+a+l+c+"\n"}}function m(t,e,n,r){let l=0,c=0,h=0,u=!0,d=null;for(const n of t)if(n.symbol!==s._S){if("*"==n.symbol)throw new Error("Gap canonical symbol is '', not '*");d=(0,o.xb)(e,{symbol:n.symbol,polymerType:(0,a.Y)(n.biotype)}),l+=d.atoms.x.length,c+=d.bonds.bondTypes.length,h++}if("PEPTIDE"===r)l+=1,c+=h,h>0&&((d?.meta?.rNodes?.length??0)<2||d?.terminalR2Atom?.toLowerCase()===i.u.HYDROGEN.toLowerCase())&&(u=!1,l-=1,c-=1);else{const r=n===s.YI.DNA?(0,o.xb)(e,i.u.DEOXYRIBOSE):(0,o.xb)(e,i.u.RIBOSE),a=(0,o.xb)(e,i.u.PHOSPHATE);l+=(t.length-1)*a.atoms.x.length,l+=t.length*r.atoms.x.length,l+=1,c+=(t.length-1)*a.bonds.bondTypes.length,c+=t.length*r.bonds.bondTypes.length,c-=1,c+=3*t.length}return{atomCount:l,bondCount:c,needsCapping:u}}function f(t){return Math.round(i.u.PRECISION_FACTOR*t)/i.u.PRECISION_FACTOR}},6077:(t,e,n)=>{"use strict";n.d(e,{C4:()=>m,eM:()=>f});var i=n(4328),o=n(6082),r=n(1991),s=n.n(r),a=n(439),l=n(3561),c=n(9235),h=n(294),u=n(9192),d=n(330),p=n(8123);async function m(t,e,n,r,l){if(e.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 '${e.semType}'`]};let h=e;const p=r.getSeqHandler(e);let m,g;p.notation!==a.Hi.SEPARATOR&&(h=p.convert(a.Hi.SEPARATOR,"."),h.name=e.name);try{g=r.getSeqHandler(h).alphabet,m=(0,d.pz)(g)}catch(t){const[e,n]=(0,u.AP)(t);return{molCol:null,warnings:[e]}}const y=function(t,e){const n=t.length,o=new Array(n),r=e.getSeqHandler(t);let a=!1;const l=r.defaultBiotype;for(let t=0;t<n;++t){const e=r.getSplitted(t);a||(a=0===e.length),o[t]=s().count(0).take(e.length).filter((t=>!e.isGap(t))).map((t=>({position:t,biotype:l,symbol:e.getCanonical(t)}))).toArray()}return a&&i.shell.warning(`Some values in the "${t.name}" column are empty`),o}(h,r),b=f(y,m,g,n,l),v=h.length,w=await(0,c.R)(h,b,g,m,n,r,l);return w.warnings.length>.05*v&&i.shell.warning(`Molfile conversion resulted in ${w.warnings.length} errors`),w}function f(t,e,n,i,o){const r=(0,l.Hb)(i,e,n),s={},c={value:null};if("RNA"===e){const t=n===a.YI.RNA?[p.u.RIBOSE,p.u.PHOSPHATE]:[p.u.DEOXYRIBOSE,p.u.PHOSPHATE];for(const n of t)g(s,n.symbol,r,o,e,c)}for(let n=0;n<t.length;++n){const i=t[n];for(const t of i){const n=t.symbol;if(""!==n)try{if("RNA"===e&&3===n.split(/\(|\)/).filter((t=>!!t)).length){const t=n.split(/\(|\)/)[1];g(s,t,r,o,e,c),s[e]?.[t]&&(s[e][n]=s[e][t])}else g(s,n,r,o,e,c)}catch(t){const e=t instanceof Error?t.message:t.toString(),i=t instanceof Error?t.stack:void 0;throw console.error(`bio lib: getMonomersDictFromLib() sym='${n}', error:\n${e}\n${i}`),new Error(`Can't get monomer '${n}' from library: ${e}`)}}}return s}function g(t,e,n,i,o,r){const s={polymerType:o,symbol:e};if(!(0,h.bq)(t,s)){const a=function(t,e,n,i,o){if(e.has(t)){const s=e.get(t),a=function(t){const e=[];for(const n of t){let t=n.capGroupSmiles;t||(t=n.capGroupSMILES),t=t.replace(/(\[|\]|\*|:|\d)/g,"").replace("OH","O").replace("Oh","O"),e.push(t)}return e}(s.rgroups),c=(r=s.molfile).includes("V3000")?function(t){const e=new Map,n=/M V30 (\d+) R#.+RGROUPS=\((\d+) (\d+)\).*/gm;let i;for(;null!==(i=n.exec(t));)i.index===n.lastIndex&&n.lastIndex++,e.set(parseInt(i[1]),parseInt(i[3]));return e}(r):function(t){const e=new Map;let n=t.indexOf(p.u.V2K_A_LINE,0),i=n;for(;-1!==n;){i=t.indexOf("\n",n);const o=parseInt(t.substring(n,i).replace(/^A\s+/,""));n=t.indexOf("R",i),i=t.indexOf("\n",n);const r=parseInt(t.substring(n,i).replace(/^R/,""));e.set(o,r),n=t.indexOf(p.u.V2K_A_LINE,i)}for(n=t.indexOf(p.u.V2K_RGP_LINE,0),i=t.indexOf("\n",n);-1!==n;){n+=p.u.V2K_RGP_SHIFT,i=t.indexOf("\n",n);const o=t.substring(n,i).replaceAll(/\s+/g," ").split(" ").map((t=>parseInt(t))).slice(1);for(let t=0;t<o.length;t+=2){if(e.has(o[t])&&e.get(o[t])!==o[t+1])throw new Error(`r-group index ${o[t]} has already been added with a different value`);e.set(o[t],o[t+1])}n=t.indexOf(p.u.V2K_RGP_LINE,i)}return e}(r),h=s.molfile.includes("V3000")?s.molfile:function(t,e){const n=e.get_mol(function(t){return t.split("\n").map((t=>{const e=t.indexOf(" R# "),n=t.indexOf(" R ");if(-1===e&&-1===n)return t;const i=-1!==e?e:n,o=t.split("");for(let t=i+5;t<o.length;t++)" "!==o[t]&&(o[t]="0");return o.join("")})).join("\n")}(t)),i=n.get_v3Kmolblock();return n.delete(),i}(function(t){let e=t.indexOf(p.u.V2K_A_LINE,0);-1===e&&(e=t.indexOf(p.u.V2K_RGP_LINE));const n=t.indexOf(p.u.V3K_END,e);return t.substring(0,e)+t.substring(n)}(s.molfile),n),u=function(t){let e=(t=t.replaceAll("\r","")).indexOf(p.u.V3K_BEGIN_COUNTS_LINE)+p.u.V3K_COUNTS_SHIFT,n=t.indexOf(" ",e+1);const i=parseInt(t.substring(e,n));return e=n+1,n=t.indexOf(" ",e+1),{atomCount:i,bondCount:parseInt(t.substring(e,n))}}(h),d=function(t,e){const n=new Array(e),i=new Float32Array(e),o=new Float32Array(e),r=new Array(e);let s=t.indexOf(p.u.V3K_BEGIN_ATOM_BLOCK);s=t.indexOf("\n",s);let a=s;for(let l=0;l<e;l++){s=t.indexOf(p.u.V3K_BEGIN_DATA_LINE,s)+p.u.V3K_IDX_SHIFT,a=t.indexOf(" ",s),s=a+1,a=t.indexOf(" ",s),n[l]=t.substring(s,a);const e=new Array(2);for(let n=0;n<2;++n)s=a+1,a=t.indexOf(" ",s),e[n]=parseFloat(t.substring(s,a));i[l]=e[0],o[l]=e[1],s=a,a=t.indexOf("\n",s)+1,r[l]=t.slice(s,a),s=a}return{atomTypes:n,x:i,y:o,kwargs:r}}(h,u.atomCount),m=function(t,e){const n=new Uint32Array(e),i=new Array(e),o=new Map,r=new Map;let s=t.indexOf(p.u.V3K_BEGIN_BOND_BLOCK);s=t.indexOf("\n",s);let a=s;for(let l=0;l<e;++l){const e=new Array(3);s=t.indexOf(p.u.V3K_BEGIN_DATA_LINE,a)+p.u.V3K_IDX_SHIFT,a=t.indexOf(" ",s);for(let n=0;n<3;++n)s=a+1,a=Math.min(t.indexOf("\n",s),t.indexOf(" ",s)),e[n]=parseInt(t.slice(s,a));n[l]=e[0],i[l]=e.slice(1);const c=t.indexOf("\n",s);let h=t.slice(a,c),u=h.indexOf(p.u.V3K_BOND_CONFIG);if(-1!==u){u=h.indexOf("=",u)+1;let t=h.indexOf(" ",u);-1===t&&(t=h.length);const e=parseInt(h.slice(u,t));o.set(l,e);const n=p.u.V3K_BOND_CONFIG+e.toString();h=h.replace(n,"")}h||r.set(l,h)}return{bondTypes:n,atomPairs:i,bondConfiguration:o,kwargs:r}}(h,u.bondCount),f=function(t,e,n,i){const o={backboneShift:null,branchShift:null,terminalNodes:[],rNodes:[]};if(n&&i&&[1,2].some((t=>!Array.from(i.values()).find((e=>e==t))))){const o=[1,2].find((t=>!Array.from(i.values()).find((e=>e==t)))),r=[1,2].find((t=>Array.from(i.values()).find((e=>e==t)))),s=Array.from(i.keys()).find((t=>i.get(t)===r))-1,a=t.x[s],l=t.y[s],c=e.atomPairs.find((t=>t.includes(s+1))).find((t=>t!==s+1))-1;let h=t.x.reduce(((e,n,i)=>{if(i===s)return e;if(i===c)return e;const o=t.y[i];return Math.sqrt((n-a)**2+(o-l)**2)>Math.sqrt((t.x[e]-a)**2+(t.y[e]-l)**2)?i:e}),-1);if(-1===h&&(h=t.x.length,t.x=new Float32Array([...t.x,-a]),t.y=new Float32Array([...t.y,-l]),t.atomTypes=[...t.atomTypes,"H"],t.kwargs=[...t.kwargs,""],e.atomPairs.push([c+1,h+1]),e.bondTypes=new Uint32Array([...e.bondTypes,1]),e.kwargs.set(e.atomPairs.length-1,"")),i.set(h+1,o),1===o)n.unshift(t.atomTypes[h]);else{if(2!==o)throw new Error(`Unexpected missing R-group: ${o}`);n.splice(1,0,t.atomTypes[h])}}return function(t,e,n){for(const[i,o]of n)t.atomTypes[i-1]=e[o-1]}(t,n,i),function(t,e){e.rNodes=Array.from(t.keys());for(let n=0;n<e.rNodes.length;n++)for(const i of[1,2])if(t.get(e.rNodes[n])===i){const t=e.rNodes[i-1];e.rNodes[i-1]=e.rNodes[n],e.rNodes[n]=t}}(i,o),y(e,o),o}(d,m,a,c),g=function(t){let e=[],n=t.indexOf("M V30 MDLV30/STEABS ATOMS=(");for(;-1!==n;){n+=28;const i=t.indexOf(")",n);e=e.concat(t.substring(n,i).split(" ").slice(1).map((t=>parseInt(t)))),n=i,n=t.indexOf("M V30 MDLV30/STEABS ATOMS=(",n)}return e}(h),v={atoms:d,bonds:m,meta:f,stereoAtoms:g};return"PEPTIDE"===i?function(t){const e=t.meta.terminalNodes[0]-1,n=t.meta.rNodes[0]-1,i=t.atoms.x,o=t.atoms.y;T(t,-i[e],-o[e]);const r=A(i[n],o[n]);S(t.atoms,-r),i[t.meta.rNodes[1]-1]<0&&x(t);const s=function(t){const e=function(t){const e=new Map;for(const n of t.bonds.atomPairs)for(let t=0;t<2;t++){const i=n[t],o=n[(t+1)%2];e.has(i)?e.get(i)?.push(o):e.set(i,new Array(1).fill(o))}return e}(t);let n=0;const i=t.atoms.atomTypes.length;let o=0;if(t.meta.terminalNodes.length<2)return null;for(;0===n;){const r=e.get(t.meta.terminalNodes[1])[o];if(t.atoms.atomTypes[r-1]===p.u.OXYGEN&&r!==t.meta.rNodes[1]&&(n=r),o++,o>i)return null}return n}(t);null!=s&&(function(t,e){t.atoms.y[t.meta.rNodes[1]-1]<0&&t.atoms.y[e-1]<0&&(function(t){E(t,!0)}(t),S(t.atoms,-function(t,e){return A(t,e)+Math.PI/2}(t.atoms.x[t.meta.terminalNodes[1]-1],t.atoms.y[t.meta.terminalNodes[1]-1])))}(t,s),function(t,e){const n=t.atoms.x;n[t.meta.rNodes[1]-1]>n[e-1]&&function(t,e,n){const i=e-1,o=n-1,r=t.atoms.x,s=t.atoms.y,a=r[i],l=s[i];r[i]=r[o],s[i]=s[o],r[o]=a,s[o]=l}(t,e,t.meta.rNodes[1])}(t,s))}(v):t===p.u.RIBOSE.symbol||t===p.u.DEOXYRIBOSE.symbol?function(t,e){const n=t.atoms.x,i=t.atoms.y;let o=t.meta.terminalNodes[0]-1;const r=t.meta.rNodes[1]-1;T(t,-n[o],-i[o]);const s=A(n[t.meta.rNodes[2]-1],i[t.meta.rNodes[2]-1]);S(t.atoms,-s),n[t.meta.rNodes[0]-1]>n[t.meta.rNodes[1]-1]&&x(t);const a=A(n[r],i[r]);S(t.atoms,3*Math.PI/2-a),e.value=function(t){const e=t.atoms.x,n=t.atoms.y,i=t.meta.rNodes[2]-1,o=t.meta.terminalNodes[2]-1,r=e[i]-e[o],s=n[i]-n[o];return Math.atan2(r,s)}(t),o=t.meta.terminalNodes[0]-1,T(t,-n[o],-i[o])}(v,o):t===p.u.PHOSPHATE.symbol?function(t){const e=t.meta.rNodes[1]-1,n=t.meta.rNodes[0]-1,i=t.atoms.x,o=t.atoms.y;T(t,-i[e],-o[e]);const r=A(i[n],o[n]);S(t.atoms,Math.PI/2-r)}(v):function(t,e){const n=t.atoms.x,i=t.atoms.y,o=t.meta.terminalNodes[0]-1,r=t.meta.rNodes[0]-1;T(t,-n[o],-i[o]);const s=A(n[r],i[r]),a=e.value;if(!a)throw new Error("The value of sugarBranchToOYAngle is null");S(t.atoms,Math.PI-s+a);const c=function(t,e){return(0,l.YN)(Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2))}({x:n[t.meta.rNodes[0]-1],y:i[t.meta.rNodes[0]-1]},{x:n[t.meta.terminalNodes[0]-1],y:i[t.meta.terminalNodes[0]-1]});if(1!=c)for(let t=0;t<n.length;++t)n[t]=(0,l.YN)(n[t]/c),i[t]=(0,l.YN)(i[t]/c)}(v,o),function(t,e,n){if("PEPTIDE"===t){b(e,t);const n=w(e,e.meta.rNodes[1]);n?.removedAtom&&(e.terminalR2Atom=n.removedAtom)}else n===p.u.RIBOSE.symbol||n===p.u.DEOXYRIBOSE.symbol?(w(e,e.meta.rNodes[1]),e.meta.rNodes[1]=e.meta.terminalNodes[1],y(e.bonds,e.meta),b(e,t),w(e,e.meta.rNodes[1]),w(e,e.meta.rNodes[0]),w(e,e.meta.rNodes[2])):n===p.u.PHOSPHATE.symbol&&(e.meta.terminalNodes[0]=e.meta.rNodes[0],T(e,-e.atoms.x[e.meta.terminalNodes[0]-1],-e.atoms.y[e.meta.terminalNodes[0]-1]),b(e,t),w(e,e.meta.rNodes[1]))}(i,v,t),function(t){let e=0;for(;e<t.atoms.atomTypes.length;)t.atoms.atomTypes[e]===p.u.HYDROGEN&&(w(t,e+1),--e),++e}(v),function(t){let e=0;for(;e<t.atoms.atomTypes.length;)"oh"===t.atoms.atomTypes[e]?.toLowerCase()&&(t.atoms.atomTypes[e]="O"),"?"===t.atoms.atomTypes[e]&&(t.atoms.atomTypes[e]="H"),++e}(v),function(t){const e=" RGROUPS=(1 1)";for(let n=0;n<(t.atoms.kwargs?.length??0);n++){const i=t.atoms.kwargs[n];i&&i.includes(e)&&(t.atoms.kwargs[n]=i.replace(e,""))}}(v),v}var r;return null}(e,n,i,o,r);if(!a)throw new Error(`Monomer with symbol '${e}' is absent the monomer library`);(0,h.LQ)(t,s,a)}}function y(t,e){const n=e.rNodes;e.terminalNodes=new Array(n.length).fill(0);const i=e.terminalNodes,o=t.atomPairs;let r=0,s=0;for(;r<o.length&&s<i.length;){for(let t=0;t<i.length;++t)for(let e=0;e<2;++e)o[r][e]===n[t]&&(i[t]=o[r][(e+1)%2],n.length,++s);++r}}function b(t,e){t.meta.rNodes.length>1&&(t.meta.backboneShift=v(t,t.meta.rNodes[1]-1,t.meta.terminalNodes[0]-1)),"RNA"===e&&t.meta.rNodes.length>2&&(t.meta.branchShift=v(t,t.meta.rNodes[2]-1,t.meta.terminalNodes[0]-1))}function v(t,e,n){return[(0,l.YN)(t.atoms.x[e]-t.atoms.x[n]),(0,l.YN)(t.atoms.y[e]-t.atoms.y[n])]}function w(t,e){if(void 0!==e){const n=e-1,i=t.atoms,o=t.bonds,r=t.meta,s=i.atomTypes.splice(n,1)[0];i.x=C(Float32Array,i.x,n,1),i.y=C(Float32Array,i.y,n,1),i.kwargs.splice(n,1);for(let t=0;t<r.terminalNodes.length;++t)r.terminalNodes[t]>e?--r.terminalNodes[t]:r.terminalNodes[t]===e&&(r.terminalNodes[t]=-1);for(let t=0;t<r.rNodes.length;++t)r.rNodes[t]>e?--r.rNodes[t]:r.rNodes[t]===e&&(r.rNodes[t]=-1);let a=0;for(;a<o.atomPairs.length;){const t=o.atomPairs[a][0],n=o.atomPairs[a][1];t===e||n===e?(o.atomPairs.splice(a,1),o.bondTypes=C(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]=t>e?t-1:t,o.atomPairs[a][1]=n>e?n-1:n),++a}let l=Array.from(o.bondConfiguration.keys());return l.forEach((t=>{if(o.bondConfiguration.has(t)&&t>n){const e=o.bondConfiguration.get(t);o.bondConfiguration.delete(t),o.bondConfiguration.set(t-1,e)}})),l=Array.from(o.kwargs.keys()),l.forEach((t=>{if(o.kwargs.has(t)&&t>n){const e=o.kwargs.get(t);o.kwargs.delete(t),o.kwargs.set(t-1,e)}})),s?{removedAtom:s}:void 0}}function C(t,e,n,i){const o=new t(e.length-i);let r=0,s=0;for(;r<e.length;)r===n&&(r+=i),o[s]=e[r],++s,++r;return o}function A(t,e){let n;if(0===t)n=e>0?0:Math.PI;else if(0===e)n=t>0?-Math.PI/2:Math.PI/2;else{const i=e/t,o=Math.atan(i);n=t<0?Math.PI/2+o:-Math.PI/2+o}return n}function S(t,e){if(0!==e){const n=t.x,i=t.y,o=Math.cos(e),r=Math.sin(e);for(let t=0;t<n.length;++t){const e=n[t];n[t]=(0,l.YN)(e*o-i[t]*r),i[t]=(0,l.YN)(e*r+i[t]*o)}}}function x(t){E(t,!1)}function E(t,e){if(e){const e=t.atoms.y;for(let t=0;t<e.length;t++)e[t]=-e[t]}else{const e=t.atoms.x;for(let t=0;t<e.length;t++)e[t]=-e[t]}const n=t.bonds.bondConfiguration;for(const[t,e]of n){const i=1===e?3:1;n.set(t,i)}}function T(t,e,n){const i=t.atoms.x,o=t.atoms.y;for(let t=0;t<i.length;++t)i[t]=(0,l.YN)(i[t]+e),void 0!==n&&(o[t]=(0,l.YN)(o[t]+n))}},294:(t,e,n)=>{"use strict";function i(t,e){return t[e.polymerType]?.[e.symbol]}function o(t,e){return!!t[e.polymerType]?.[e.symbol]}function r(t,e,n){let i=t[e.polymerType];i||(i=t[e.polymerType]={}),i[e.symbol]=n}n.d(e,{Cg:()=>s,LQ:()=>r,bq:()=>o,vF:()=>a,xb:()=>i});class s extends Map{constructor(t){super(t)}}class a{constructor(t,e){this.molfile=t,this.monomers=e}static createEmpty(){return new a("",new s(null))}}},330:(t,e,n)=>{"use strict";n.d(e,{kA:()=>o,pz:()=>s,qj:()=>r,vG:()=>a});var i=n(2003);function o(t,e){return t?t.columns.getUnusedName(e):e}function r(t,e){return o(t,`molfile(${e})`)}function s(t){let e;if(t===i.YI.PT||t===i.YI.UN)e="PEPTIDE";else{if(t!==i.YI.RNA&&t!==i.YI.DNA)throw new Error(`Unexpected alphabet '${t}'.`);e="RNA"}return e}function a(t){const e=7===t.length?/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t):/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?[parseInt(e[1],16)/256,parseInt(e[2],16)/256,parseInt(e[3],16)/256,e.length>4?parseInt(e[4],16)/256:.3]:null}},1093:(t,e,n)=>{"use strict";n(7362);class i{}i.SemType="Nucleotides",i.SemTypeMultipleAlignment="NucleotidesMultipleAlignment",i.Names={A:"Adenine",C:"Cytosine",G:"Guanine",T:"Thymine",U:"Uracil"}},7362:(t,e,n)=>{"use strict";n.d(e,{e:()=>i});class i{static makePalette(t,e=!1,n=i){const o={};return t.forEach((t=>{const n=t[0],i=t[1];n.forEach(((t,n)=>{o[t]=this.colourPalette[i][e?0:n]}))})),new n(o)}constructor(t){this._palette=t}get(t,e){return this._palette[t]}}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:(t,e,n)=>{"use strict";n.d(e,{O:()=>r,n:()=>o});var i=n(1858);class o{constructor(t,e=!0,n){return this.substructure=t,this.readOnly=e,this.logger=n,new Proxy(this,{set:(t,e,n)=>{if(this.logger?.debug(`BioFilterProps.set ${e.toString()}( '${n}' )`),this.readOnly)throw new Error("Properties are immutable.");return t[e]=n,!0}})}}class r{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(t){this._propsChanging=!0;try{this._props=t,this.applyProps(),this.onChanged.next()}finally{this._propsChanging=!1}}saveProps(){const t={};for(const[e,n]of Object.entries(this.props))"_onChanged"!==e&&"logger"!==e&&(t[e]=this.props[e]);return t}async detach(){}get filterSummary(){return this.props.substructure}get isFiltering(){return""!==this.props.substructure}resetFilter(){this.props=this.emptyProps,this.onChanged.next()}}},4152:(t,e,n)=>{"use strict";var i=n(6082),o=n(7362),r=n(6718);function s(t,e=!0){if(null==t)return"rgb(100,100,100)";const n=i.Color.fromHtml(t);if(e){const t=i.Color.g(n),e=i.Color.r(n),o=i.Color.b(n),r=Math.sqrt(Math.pow(0-e,2)+Math.pow(0-t,2)+Math.pow(0-o,2));if(r>210)return`rgb(${e/r*210},${t/r*210},${o/r*210})`}return i.Color.toRgb(n)}class a{static hashCode(t){let e=0;if(0===t.length)return e;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n),e|=0;return e}}class l{}class c extends l{static get palette(){return c._pallete||(c._pallete=c.buildPalette()),c._pallete}static buildPalette(){return(0,r.pj)().then((t=>{t.awaitLoaded(1/0).then((()=>{const e=t.getMonomerLib();e.onChanged.subscribe((()=>{c.customMonomerColors={},c.polymerTypes=e.getPolymerTypes();for(const t of this.polymerTypes){const n=e.getMonomerSymbolsByType(t);for(const i of n){const n=e.getMonomer(t,i);n?.meta?.colors?.default?.background&&(this.customMonomerColors[i]||(this.customMonomerColors[i]={}),this.customMonomerColors[i][t]=s(n.meta.colors.default.background))}}}))}))})),[].concat(...Object.values(o.e.colourPalette))}get(t,e){const n=c.palette.length,i=c.customMonomerColors[t],o=e??"PEPTIDE";if(i&&i[o])return i[o];const r=a.hashCode(t)%n;return s(c.palette[r])}}c._pallete=null,c.customMonomerColors={},c.polymerTypes=[]},6642:(t,e,n)=>{"use strict";n.d(e,{BG:()=>s,sD:()=>l});var i=n(4328),o=n(1858),r=n(8070);function s(t){let e=null,n=null;try{n=t.dart?t.gridColumn:null,e=n?n.temp:null}catch{[n,e]=[null,null]}const i=t.cell.column;if(e=e??(i?i.temp:null),!e)throw new Error("Grid cell renderer back store (GridColumn or Column) not found.");return[n,i,e]}class a{onKeyDown(t,e){}onKeyPress(t,e){}onMouseEnter(t,e){}onMouseLeave(t,e){}onMouseDown(t,e){}onMouseUp(t,e){}onMouseMove(t,e){}onClick(t,e){}onDoubleClick(t,e){}}class l extends a{constructor(t,e,n){super(),this.gridCol=t,this.tableCol=e,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((t=>{try{this.destroyed||!this.tableCol||this.tableCol.dataFrame||this.destroy()}catch(t){this.logger.error(t)}})))),this.tableCol&&this.subs.push(i.events.onTableRemoved.subscribe((t=>{try{const e=t.args.dataFrame;this.tableCol?.dataFrame.id!==e.id||this.destroyed||this.destroy()}catch(t){this.logger.error(t)}}))),this.gridCol&&this.subs.push(i.events.onViewRemoving.subscribe((t=>{try{const e=t.args.view;this.gridCol?.dart&&this.gridCol.grid&&this.gridCol?.grid?.dart&&this.gridCol?.grid?.view?.id===e.id&&!this.destroyed&&this.destroy()}catch(t){this.logger.error(t)}})))}toLog(){return`${this.constructor.name}<${this.viewerId}>`}destroy(){for(const t of this.subs)t.unsubscribe();this.destroyed=!0}invalidateGrid(){this.gridCol&&this.gridCol.dart&&this.gridCol.grid?.invalidate()}reset(){this.dirty=!1}get onRendered(){return this._onRendered}invalidate(t){this.invalidateGrid()}async awaitRendered(t=1e4,e=`${t} timeout`){const n=`${this.toLog()}.awaitRendered()`;if(this.logger.debug(`${n}, start, testEvent before`),await(0,r.PE)(this._onRendered,(()=>{}),(()=>{this.invalidate()}),t,`${n}, ${e}`),this.errors.length>0){const t=this.errors[0];throw this.errors=[],t}this.logger.debug(`${n}, end`)}}l.viewerCounter=-1},673:(t,e,n)=>{"use strict";n.d(e,{s:()=>i});const i={true:"1",false:"0"}},6882:(t,e,n)=>{"use strict";n.d(e,{Jy:()=>b,S$:()=>y,U0:()=>v});var i=n(7389),o=n(6082),r=n(1991),s=n.n(r),a=n(8312),l=n(2003),c=n(6642),h=n(6718),u=n(9192),d=n(3856),p=n(673),m=n(3599),f=n(5553),g=n(9713);const y="rgb(100,100,100)";class b extends c.sD{get separatorWidth(){return this.props?.fontCharWidth?this.props?.fontCharWidth:5}constructor(t,e,n,i,r){if(super(t,e,n),this.monomerLengthLimit=i,this.propsProvider=r,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 t=[l.gp.positionShift,"renderMultiline"];this.subs.push(o.debounce(this.tableCol.dataFrame.onMetadataChanged.pipe(g.filter((e=>e.args.source===this.tableCol&&t.includes(e.args.key)))),200).subscribe((t=>{this.reset()}))),this.subs.push(o.debounce(this.tableCol.dataFrame.onMetadataChanged.pipe(g.filter((t=>t.args.source===this.tableCol&&t.args.key===l.gp.positionShift))),200).subscribe((t=>{this.reset()})))}}calculateFontBasedSpacing(t){const e=t.measureText("M");let n=12;if(this.tableCol?.temp[".mm.cellRenderer.fontSize"]){const t=this.tableCol.temp[".mm.cellRenderer.fontSize"];"number"!=typeof t||isNaN(t)||(n=Math.max(t,1))}return{lineHeight:Math.max(1.4*n,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent+4),monomerSpacing:Math.max(2,.2*this.props.fontCharWidth)}}shouldUseMultilineRendering(t){return"true"===t.getTag("renderMultiline")}calculateMultiLineLayoutDynamic(t,e,n,i,o,r){if(this.dirty)try{this.reset()}catch(t){const[e,n]=(0,u.AP)(t);this.logger.error(e,void 0,n)}const{lineHeight:s,monomerSpacing:a}=this.calculateFontBasedSpacing(t),l=e-2*this.padding;let c=0;const h=[];if(i.length>0)for(let e=o;e<i.length;e++){const n=i.getOriginal(e),o=this.props.monomerToShort(n,r);h.push({text:o,posIdx:e}),c=Math.max(c,t.measureText(o).width)}if(0===h.length)return{lineLayouts:[],lineHeight:s};const d=c;let p=Math.floor((l+a)/(d+a));p=Math.max(1,p);const m=n-2*this.padding,f=Math.max(0,Math.floor(m/s)),g=[];let y=0;for(let t=0;t<f&&y<h.length;t++){const e=[];for(let t=0;t<p&&y<h.length;t++){const n=h[y],i=this.padding+t*(d+a);e.push({posIdx:n.posIdx,x:i,width:d,om:n.text,isSeparator:!1}),y++}g.push({lineIdx:t,elements:e})}return{lineLayouts:g,lineHeight:s}}async init(){await Promise.all([(async()=>{this.seqHelper=await(0,a.Q)(),this.invalidateGrid()})(),(async()=>{const t=await(0,h.pj)();this.sysMonomerLib=t.getMonomerLib()})()]),this.subs.push(this.sysMonomerLib.onChanged.subscribe((()=>{this.reset()}))),this.reset()}static getFontSettings(t){let e=12;return t&&t.temp[".mm.cellRenderer.fontSize"]&&"number"==typeof t.temp[".mm.cellRenderer.fontSize"]&&!isNaN(t.temp[".mm.cellRenderer.fontSize"])&&(e=Math.max(t.temp[".mm.cellRenderer.fontSize"],1)),{font:`${e}px monospace`,fontWidth:.6*e}}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(t,e){const n=this.seqHelper.getSeqHandler(this.tableCol);if(this.colWidth<e&&(this.colWidth=e,this.dirty=!0),this.dirty)try{this.reset()}catch(t){const[e,n]=(0,u.AP)(t);this.logger.error(e,void 0,n)}const i=n.isMsa()?this.getCellMonomerLengthsForSeqMsa():this.getCellMonomerLengthsForSeq(t);return[i,this.getSummedMonomerLengths(i)]}getSummedMonomerLengths(t){const e=new Array(t.length+1);e[0]=this.padding;for(let n=1;n<e.length;n++)e[n]=e[n-1]+t[n-1];let n=e[0];for(let t=1;t<e.length;t++)e[t]?n=e[t]:e[t]=n;return e}getCellMonomerLengthsForSeqValue(t,e){const n=this.seqHelper.getSeqHandler(this.tableCol),i=this.props.separatorWidth+1*this.props.fontCharWidth,o=this.positionShift,r=Math.ceil(e/i)+o,s=n.splitter(t),a=Math.min(r,s.length),l=new Array(a-o);let c=0;for(let t=o;t<a;++t){const i=s.getOriginal(t),r=this.props.monomerToShort(i,this.monomerLengthLimit),a=(n.isSeparator()?this.separatorWidth:this.props.separatorWidth)+r.length*this.props.fontCharWidth;if(l[t-o]=a,c+=a,c>e)break}return l}getCellMonomerLengthsForSeq(t){this.toLog(),null===this._monomerLengthList&&(this._monomerLengthList=new Array(this.tableCol.length).fill(null));const e=this.positionShift,n=this.seqHelper.getSeqHandler(this.tableCol),i=this.props.separatorWidth+1*this.props.fontCharWidth,o=Math.ceil(this.colWidth/i)+e,r=n.getSplitted(t),s=Math.min(o,r.length);let a=this._monomerLengthList[t];if(null===a||a.length!=s-e){a=this._monomerLengthList[t]=new Array(r.length);let i=0;for(let t=e;t<s;++t){const o=r.getOriginal(t),s=this.props.monomerToShort(o,this.monomerLengthLimit),l=(n.isSeparator()?this.separatorWidth:this.props.separatorWidth)+s.length*this.props.fontCharWidth;if(a[t-e]=l,i+=l,i>this.colWidth)break}}return a}getCellMonomerLengthsForSeqMsa(){var t;this.toLog(),null===this._monomerLengthList&&(this._monomerLengthList=new Array(1).fill(null)),(t=this._monomerLengthList)[0]??(t[0]=new Array(0));const e=this._monomerLengthList[0],{startIdx:n,endIdx:i}=(()=>{try{const t=this.gridCol&&this.gridCol.dart?this.gridCol.grid:null;return t&&t.dart?{startIdx:Math.max(Math.floor((t?.vertScroll.min??0)-10),0),endIdx:Math.min(Math.ceil((t?.vertScroll.max??0)+10),this.tableCol.length)}:{startIdx:0,endIdx:Math.min(this.tableCol.length,10)}}catch(t){return{startIdx:0,endIdx:Math.min(this.tableCol.length,10)}}})(),o=this.props.separatorWidth+1*this.props.fontCharWidth,r=this.positionShift,s=Math.ceil(this.colWidth/o)+r;for(let t=n;t<i;t++){if(this._processedRows.get(t)&&s<=this._processedMaxVisibleSeqLength)continue;const n=this.seqHelper.getSeqHandler(this.tableCol).getSplitted(t,s),i=Math.min(s,n.length);i-r>e.length&&e.push(...new Array(i-r-e.length).fill(o));let a=0;for(let t=r;t<i;++t){const i=n.getOriginal(t),o=this.props.monomerToShort(i,this.monomerLengthLimit),s=this.props.separatorWidth+o.length*this.props.fontCharWidth;if(e[t-r]=Math.max(e[t-r]??0,s),a+=s,a>=this.colWidth)break}this._processedMaxVisibleSeqLength=Math.max(this._processedMaxVisibleSeqLength,s),this._processedRows.set(t,!0)}return e}getPosition(t,e,n,i){const[o,r]=this.getCellMonomerLengths(t,n);return 0===this.seqHelper.getSeqHandler(this.tableCol).getSplitted(t).length?null:function(t,e,n){if((n??0)>0&&e<(t[0]??0)+n)return-1;e-=n??0;let i,o=100,r=0,s=t.length-1;for(;r<=s;){if(i=Math.floor((s+r)/2),t[i]<=e&&e<t[i+1])return i;if(e<t[i]?s=i-1:r=i+1,--o<=0)throw new Error(`Get position for pointer x = ${e} searching has not converged on ${JSON.stringify(t)}. `)}return null}(r,e,i)}setMonomerLengthLimit(t){this.monomerLengthLimit!=t&&(this.monomerLengthLimit=t,this.dirty=!0)}setSeparatorWidth(t){this.separatorWidth!=t&&(this.props.separatorWidth=t,this.dirty=!0)}get positionShift(){const t=Number.parseInt(this.tableCol?.tags[l.gp.positionShift]??"0")??0;return isNaN(t)?0:Math.max(t,0)}render(t,e,n,i,r,a,c){const h=a.grid?.canvas===t.canvas;if(!this.seqHelper)return;const m=this.tableCol,f=this.positionShift;t.save();try{const c=this.seqHelper.getSeqHandler(m);let u=this.monomerLengthLimit;if(d.gp.maxMonomerLength in m.tags){const t=parseInt(m.getTag(d.gp.maxMonomerLength));u=!isNaN(t)&&t?t:50}if(m.temp[".mm.cellRenderer.settingsChanged"]===p.s.true||this.monomerLengthLimit!=u){let t=0;const e=8;t=m.temp[".mm.cellRenderer.gapLength"]??t,this.setMonomerLengthLimit(u),this.setSeparatorWidth(c.isMsa()?e:t),m.temp[".mm.cellRenderer.settingsChanged"]=p.s.false,this.dirty=!0}const g=a.cell.rowIndex,b=a.cell.value;h&&(i=v(a.grid,t,e,i,window.devicePixelRatio)),t.beginPath(),t.rect(e,n,i,r),t.clip(),t.font=this.props?.font??"12px monospace",t.textBaseline="top";const w=m.meta.units,C=m.getTag(l.gp.aligned),A=m.getTag(l.gp.separator)??"",S=h?c.getSplitted(g):c.splitter(b);let x=d.yg.classic;C?.includes("MSA")&&w===l.Hi.SEPARATOR&&(x=d.yg.MSA);const E=m.temp["reference-sequence"],T=this.tableCol.temp["current-word"],M=(()=>{const t=(0,c.splitter)(null!=E&&""!==E?E:T??"");return s().count(0).take(t.length).slice(f).map((e=>t.getCanonical(e))).toArray()})(),_=Number.parseInt(m.getTag(l.gp.selectedPosition)??"-200");if(this.shouldUseMultilineRendering(m)){const s=[],l=this.calculateMultiLineLayoutDynamic(t,i,r,S,f,u);let h=n+this.padding;1===l.lineLayouts.length&&(h=n+(r-l.lineHeight)/2);for(const i of l.lineLayouts){const r=h+i.lineIdx*l.lineHeight;for(const h of i.elements){const u=e+h.x,p=h,g=p.posIdx,b=S.getCanonical(g);let v=y;const w=this.getMonomerLib();w&&(v=w.getMonomerTextColor(c.defaultBiotype,b));let C=0;if(a.tableRowIndex!==m.dataFrame.currentRowIdx&&M.length>0){const t=g-f;t>=0&&t<M.length&&b===M[t]&&(C=.7)}s.push({lineIdx:i.lineIdx,monomerIdx:g-f,bounds:new o.Rect(h.x,r-n,h.width,l.lineHeight),sequencePosition:g}),(0,d.oZ)(t,p.om,u,r,h.width,l.lineHeight,{color:v,isMultiLineContext:!0,transparencyRate:C,selectedPosition:isNaN(_)||_<1?void 0:_,wordIdx:g})}}null!==a.tableRowIndex&&this._cellBounds.set(a.tableRowIndex,s)}else{this._leftThreeDotsPadding=this.shouldRenderShiftedThreeDots(f)?t.measureText("...").width:0;let[,o]=this.getCellMonomerLengths(a.tableRowIndex,i);h||(o=this.getSummedMonomerLengths(this.getCellMonomerLengthsForSeqValue(b,i)));const s=this.props.separatorWidth+1*this.props.fontCharWidth,l=Math.min(S.length,Math.ceil(i/s)+f);for(let s=f;s<l;++s){const l=s<S.length?S.getOriginal(s):c.defaultGapOriginal,h=s<S.length?S.getCanonical(s):c.defaultGapOriginal;let p=y;this.getMonomerLib()&&(p=this.getMonomerLib().getMonomerTextColor(c.defaultBiotype,h));const m={color:p,pivot:0,left:!0,transparencyRate:0,separator:A,last:s===S.length-1,drawStyle:x,maxWord:o,wordIdx:s-f,gridCell:a,referenceSequence:M,maxLengthOfMonomer:u,monomerTextSizeMap:this._monomerLengthMap,logger:this.logger,selectedPosition:isNaN(_)||_<1?void 0:_-f};(0,d.oZ)(t,l,e+this.padding+this._leftThreeDotsPadding,n,i,r,m)}if(this.shouldRenderShiftedThreeDots(f)){const s={color:y,pivot:0,left:!0,transparencyRate:0,separator:A,last:!1,drawStyle:x,maxWord:o,wordIdx:0,gridCell:a,maxLengthOfMonomer:u,monomerTextSizeMap:this._monomerLengthMap,logger:this.logger};(0,d.oZ)(t,"...",e+this.padding,n,i,r,s)}}}catch(t){const[e,n]=(0,u.AP)(t);this.logger.error(e,void 0,n),this.errors.push(t)}finally{t.restore()}}shouldRenderShiftedThreeDots(t){return t>0&&(!this.gridCol||!this.gridCol.dart||!this.gridCol.grid||!this.gridCol.grid.dart||(this.gridCol.grid.props.colHeaderHeight??0)<=50)}onMouseMove(t,e){const n=`${this.toLog()}.onMouseMove()`;if(!this.seqHelper||null==t.tableRowIndex)return;const o=this.positionShift,r=t.bounds,s=e.offsetX-t.gridColumn.left+(t.gridColumn.left-r.x),a=e.offsetY-r.y;this.gridCol?.grid?.canvas&&(this.gridCol.grid.canvas.style.cursor="default");let c=null;const h=this._cellBounds.get(t.tableRowIndex);if(h){for(const t of h)if(t.bounds.contains(s,a)){c=t.monomerIdx;break}}else{const e=this.shouldRenderShiftedThreeDots(o)&&(this._leftThreeDotsPadding??0)>0?this._leftThreeDotsPadding:0;c=this.getPosition(t.tableRowIndex,s,r.width,e)}this.logger.debug(`${n}, argsX: ${s}, argsY: ${a}, left: ${c}`);const u=this.seqHelper.getSeqHandler(this.tableCol),d=u.getSplitted(t.tableRowIndex);if(null!==c&&c>=0&&c+o<d.length){const n=u.alphabet??l.YI.UN,r={position:c,biotype:n===l.YI.RNA||n===l.YI.DNA?m.o.NUCLEOTIDE:m.o.AA,symbol:d.getCanonical(c+o)},s=[];let a=this._monomerStructureMap[r.symbol];if(!a){const t=this.getMonomerLib();a=this._monomerStructureMap[r.symbol]=t?t.getTooltip(r.biotype,r.symbol):i.divText("Monomer library is not available")}s.push(a),i.tooltip.show(i.divV(s),e.x+16,e.y+16),(0,f.WN)(t,r)}else-1===c?i.tooltip.show(i.divText(`${Math.min(o,d.length)} hidden monomers`),e.x+16,e.y+16):i.tooltip.hide(),(0,f.WN)(t,null)}}function v(t,e,n,i,o){return t?Math.max(Math.min(t.canvas.width/o-n,i)):Math.max(e.canvas.width/o-n,0)}},3856:(t,e,n)=>{"use strict";n.d(e,{Mn:()=>h,gp:()=>c,oZ:()=>p,yg:()=>u});var i=n(6082),o=n(7278);const r="rgb(100,100,100)",s="#808080",a="rgb(0,0,0)",l=o.zS;var c,h,u;!function(t){t.maxMonomerLength=".mm.cellRenderer.maxMonomerLength"}(c||(c={})),function(t){t.applyToBackground=".m.cellRenderer.applyToBackground"}(h||(h={})),function(t){t.MSA="MSA",t.classic="classic"}(u||(u={}));const d=new class{constructor(){this.color=r,this.pivot=0,this.left=!1,this.transparencyRate=0,this.separator="",this.last=!1,this.drawStyle=u.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(t,e,n,o,c,h,p){var m,f,g;const y={...d,...p};if(y.isMultiLineContext){t.textBaseline="middle",t.textAlign="center";let i=e;null!=y.maxLengthOfMonomer&&(i=l(i,y.maxLengthOfMonomer));const s=Math.max(.1,1-(y.transparencyRate??0));t.globalAlpha=s;const u=t.measureText(i),d=u.fontBoundingBoxAscent+u.fontBoundingBoxDescent,p=o+(h-d)/2+u.fontBoundingBoxAscent;let m=y.color??r;return m&&m!==r||(m=a),t.fillStyle=m,y.selectedPosition===y.wordIdx+1&&(t.save(),t.fillStyle="rgba(60, 177, 115, 0.2)",t.fillRect(n,o,c,h),t.restore(),t.fillStyle=m),t.fillText(i,n+c/2,p),t.globalAlpha=1,t.textBaseline="top",t.textAlign="start",n+c}p.logger?.debug("Bio: printLeftOrCentered(), start"),t.textAlign="start";let b=e.substring(0),v=y.last?"":y.separator;y.drawStyle===u.MSA&&(v="");let w=!0,C=!0,A="difference";if(null!=y.gridCell&&null!=y.gridCell.cell.column&&(w=y.gridCell.cell.column.temp["color-code"]??!0,C=y.gridCell.cell.column.temp["compare-with-current"]??!0,A=y.gridCell.cell.column.temp["highlight-difference"]??"difference"),y.referenceSequence){const t=y.referenceSequence[y.wordIdx];C&&y.referenceSequence.length>0&&"difference"===A&&(y.transparencyRate=b==t?.7:y.transparencyRate),C&&y.referenceSequence.length>0&&"equal"===A&&(y.transparencyRate=b!=t?.7:y.transparencyRate)}null!=y.maxLengthOfMonomer&&(b=l(b,y.maxLengthOfMonomer));const S=b+v;(m=y.monomerTextSizeMap)[S]??(m[S]=t.measureText(S));let x=y.monomerTextSizeMap[S];(f=y.monomerTextSizeMap)[b]??(f[b]=t.measureText(b));let E=y.monomerTextSizeMap[b].width;const T=h/2-(x.fontBoundingBoxAscent+x.fontBoundingBoxDescent)/2+1;(g=y.monomerTextSizeMap)[v]??(g[v]=t.measureText(v));const M=y.monomerTextSizeMap[v].width;function _(e,r){let l=w?y.color:a;y.selectedPosition===y.wordIdx+1&&(t.fillStyle="rgba(60, 177, 115, 0.2)",t.fillRect(n+e-4,o-5,y.monomerTextSizeMap[b].width+8,h+10),l=i.Color.toHtml(i.Color.setAlpha(i.Color.fromHtml(l),255))),t.fillStyle=l,t.globalAlpha=1-y.transparencyRate,y.drawStyle===u.classic&&(t.fillText(b,n+e,o+T),t.fillStyle=s,t.fillText(v,n+r,o+T)),y.drawStyle===u.MSA&&t.fillText(b,n+e,o+T),t.globalAlpha=1}x=x.width,y.drawStyle===u.MSA&&(E=y.maxWord[y.wordIdx],x=y.maxWord[y.wordIdx]);const I=(y.maxWord[y.wordIdx]??0)-(y.maxWord[0]??0);if(y.left||x>c)return _(I,I+E),n+I+E+M;{const t=(c-x)/2;return _(t,t+E),n+I+t+E}}},6307:(t,e,n)=>{"use strict";n.d(e,{F:()=>s});var i=n(7389),o=n(6082),r=n(439);function s(t,e,n){let s=0,a=null;for(const e of Object.values(t))s+=e,a=null===a?e:Math.max(a,e);const l=a/s,c=Object.assign({},...Array.from(Object.entries(t)).sort(((t,e)=>e[1]-t[1])).map((([t,a])=>{const c=a/s;let h;try{const i=n.getMonomerColors(e,t);h=i?.backgroundcolor||"#CCCCCC"}catch(e){console.warn(`Failed to get colors for monomer ${t}:`,e),h="#CCCCCC"}const u=i.div("",{classes:"macromolecule-cell-comp-analysis-bar"});u.style.width=50*c/l+"px",u.style.backgroundColor=h,r._S===t&&(u.style.borderWidth="1px",u.style.borderStyle="solid",u.style.borderColor=o.Color.toHtml(o.Color.lightGray));const d=r._S===t?"-":t,p=i.div(`${(100*c).toFixed(2)}%`),m=i.div([u,p],{classes:"macromolecule-cell-comp-analysis-value"});return{[d]:m}}))),h=i.tableFromMap(c);return Array.from(h.rows).forEach((t=>{const e=t.getElementsByClassName("macromolecule-cell-comp-analysis-bar")[0].style.backgroundColor;t.cells[0].style.color=e})),h}},3151:(t,e,n)=>{"use strict";n.d(e,{EK:()=>l,Ec:()=>r,f6:()=>i,pe:()=>s,q7:()=>a,yw:()=>o});const i=["symbol","molfile","rgroups","name"],o="MonomerName",r={monomerType:null,smiles:null,name:"Name",author:null,molfile:"molecule",naturalAnalog:"MonomerNaturalAnalogCode",rgroups:"MonomerCaps",createDate:null,id:null,polymerType:"MonomerType",symbol:"MonomerName"},s={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:(t,e,n)=>{"use strict";function i(t){return"string"==typeof t||t instanceof String?t:"StateError"===t.constructor.name?t.message:"StateError"===t.constructor.name&&"$thrownJsError"in t?i(t.$thrownJsError):t instanceof Error?t.message:t.toString()}function o(t){return t instanceof Error?t.stack:"StateError"===t.constructor.name&&"$thrownJsError"in t?o(t.$thrownJsError):void 0}function r(t){return[i(t),o(t)]}n.d(e,{AP:()=>r})},3516:(t,e,n)=>{"use strict";n.d(e,{m:()=>r});var i=n(6082),o=n(439);class r{get descriptionsArray(){return this._descriptionsArray}get sequencesArray(){return this._sequencesArray}parseMacromolecule(t,e){return this._fileContent.slice(t,e).split(/\s/).join("")}parseColumns(){const t=/^>(.*)$/gm;let e,n=0;for(;e=t.exec(this._fileContent);){const i=this._fileContent.substring(e.index+1,t.lastIndex);this._descriptionsArray.push(i),0!==n&&this._sequencesArray.push(this.parseMacromolecule(n,e.index)),n=t.lastIndex+1}this._sequencesArray.push(this.parseMacromolecule(n,-1))}importFasta(){const t=i.Column.fromStrings("description",this.descriptionsArray),e=i.Column.fromStrings("sequence",this.sequencesArray);return e.semType=i.SEMTYPE.MACROMOLECULE,e.meta.units=o.Hi.FASTA,[i.DataFrame.fromColumns([t,e])]}constructor(t){this._descriptionsArray=[],this._sequencesArray=[],this._fileContent=t,this.parseColumns()}}},6873:(t,e,n)=>{"use strict";n.d(e,{Hx:()=>h,dW:()=>c});var i=n(6082),o=n(1991),r=n.n(o),s=n(2003),a=n(7278),l=n(439);function c(t=10**5){const e="meI/hHis/Aca/N//dE/Thr_PO3H2/Aca/D-Tyr_Et/Tyr_ab-dehydroMe".repeat(Math.ceil(t/10)).slice(0,-1),n=i.Column.fromList(i.COLUMN_TYPE.STRING,"MSA",new Array(100).fill(e));n.semType=i.SEMTYPE.MACROMOLECULE,n.meta.units=s.Hi.SEPARATOR,n.setTag(s.gp.separator,"/"),n.setTag(s.gp.alphabet,s.YI.UN),n.setTag(s.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(t,e=s.Hi.SEPARATOR,n=s.YI.PT,o=(e===s.Hi.SEPARATOR?"-":void 0),c=void 0,h="seq",u=100,d=10**6){const p=n===s.YI.UN?c?.getMonomerSymbolsByType("PEPTIDE")??[]:Array.from((0,s.Qf)(n)),m=p.length,f=i.Column.fromType(i.COLUMN_TYPE.STRING,h,u);f.semType=i.SEMTYPE.MACROMOLECULE,f.meta.units=e,f.setTag(s.gp.alphabet,n),e==s.Hi.SEPARATOR&&f.setTag(s.gp.separator,o);const g=t.getSeqHandler(f);for(let t=0;t<u;t++){const n=r().count(0).take(d).map((t=>p[Math.floor(Math.random()*m)])).toArray(),i=g.joiner(new a.Mu(n,l.b9[e]));f.set(t,i)}return f}},439:(t,e,n)=>{"use strict";n.d(e,{B5:()=>l,Hi:()=>i,Vl:()=>c,YI:()=>o,_S:()=>u,b9:()=>d,gp:()=>r,ot:()=>p,q7:()=>h,z1:()=>a});var i,o,r,s=n(2738);!function(t){t.FASTA="fasta",t.SEPARATOR="separator",t.HELM="helm",t.CUSTOM="custom"}(i||(i={})),function(t){t.DNA="DNA",t.RNA="RNA",t.PT="PT",t.UN="UN"}(o||(o={})),function(t){t.aligned="aligned",t.alphabet="alphabet",t.alphabetSize=".alphabetSize",t.alphabetIsMultichar=".alphabetIsMultichar",t.separator="separator",t.isHelmCompatible=".isHelmCompatible",t.positionNames=".positionNames",t.positionLabels=".positionLabels",t.regions=".regions",t.positionShift=".positionShift",t.selectedPosition=".selectedPosition"}(r||(r={}));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"])}}},h=[new s.a(o.PT,c.fasta.peptide,.5),new s.a(o.DNA,c.fasta.dna,.55),new s.a(o.RNA,c.fasta.rna,.55)],u="",d={[i.FASTA]:"-",[i.SEPARATOR]:"",[i.HELM]:"*"},p=" , "},2003:(t,e,n)=>{"use strict";n.d(e,{Hi:()=>i.Hi,J9:()=>o.J9,Qf:()=>o.Qf,YI:()=>i.YI,dh:()=>o.dh,gp:()=>i.gp,mn:()=>o.mn,q7:()=>i.q7,qp:()=>o.qp,z1:()=>i.z1,zS:()=>o.zS});var i=n(439),o=n(7278)},2738:(t,e,n)=>{"use strict";n.d(e,{X:()=>o,a:()=>i});class i{constructor(t,e,n){this.name=t,this.alphabet=e,this.cutoff=n}}class o extends i{constructor(t,e,n){super(t.name,t.alphabet,t.cutoff),this.freq=e,this.similarity=n}}},7278:(t,e,n)=>{"use strict";n.d(e,{Iv:()=>y,J9:()=>p,Mu:()=>u,Qf:()=>w,dh:()=>f,mn:()=>S,p0:()=>A,pc:()=>C,qp:()=>g,tm:()=>m,zS:()=>v});var i=n(6082),o=n(1991),r=n.n(o),s=n(3527),a=n(3629),l=n(2738),c=n(439),h=(n(8924),n(1093),n(4152),n(8438));class u{get length(){return this.mList.length}isGap(t){return this.getOriginal(t)===this.gapOriginalMonomer}getCanonical(t){if(this.length<=t)throw new Error("Index out of bounds");const e=this.mList[t];return e!==this.gapOriginalMonomer?e:c._S}getOriginal(t){if(this.length<=t)throw new Error("Index out of bounds");return this.mList[t]}getCanonicalRegion(t,e){const n=Math.min(Math.max(0,t),this.length),i=Math.max(Math.min(this.length,e),0)-n,o=this.gapOriginalMonomer;return new Array(i).fill(null).map(((t,e)=>{const i=this.mList[e+n];return i===o?c._S:i}))}getOriginalRegion(t,e){const n=Math.min(Math.max(0,t),this.length),i=Math.max(Math.min(this.length,e),0);return new Array(i-n).fill(null).map(((t,e)=>this.mList[e+n]))}get gapOriginal(){return this.gapOriginalMonomer}constructor(t,e){this.mList=t,this.gapOriginalMonomer=e}}class d{get length(){return this.seqS.length}isGap(t){return this.getOriginal(t)===c.b9[c.Hi.FASTA]}getCanonical(t){if(this.length<=t)throw new Error("Index out of bounds");return this.isGap(t)?c._S:this.seqS[t]}getOriginal(t){if(this.length<=t)throw new Error("Index out of bounds");return this.seqS[t]}getCanonicalRegion(t,e){const n=Math.max(0,t),i=Math.min(this.length,e)-n,o=c.b9[c.Hi.FASTA];return new Array(i).fill(null).map(((t,e)=>{const i=this.seqS[e+n];return i===o?c._S:i}))}getOriginalRegion(t,e){const n=Math.max(0,t),i=Math.min(this.length,e);return this.seqS.slice(n,i)}get gapOriginal(){return c.b9[c.Hi.FASTA]}constructor(t){this.seqS=t}}const p=t=>{const e=r()(t.toString().matchAll(c.B5)).map((t=>t[2]??t[1])).toArray();return new u(e,c.b9[c.Hi.FASTA])},m=t=>t?new d(t):new u([],c.b9[c.Hi.FASTA]);function f(t,e=void 0){return n=>{if(n){let i;const o=new RegExp(`(?<=^|\\${t})("-"|'-'|[^\\${t}]*)(?=\\${t}|$)`,"g");return void 0!==e?(o.lastIndex=0,i=r()(n.matchAll(o)).take(e).map((t=>t[0])).toArray()):i=n.replaceAll('"-"',"").replaceAll("'-'","").split(t,e),new u(i,c.b9[c.Hi.SEPARATOR])}return new u([],c.b9[c.Hi.SEPARATOR])}}const g=t=>{const e=t.split("$")[0].split("|"),n=r()(e.map((t=>(t.match(/(?<=\{).+(?=})/)?.[0]?.split(".")??[]).map((t=>(0,h.D)(t)))))).flatten().toArray();return new u(n,c.b9[c.Hi.HELM])};function y(t,e,n=void 0){if(t.toLowerCase().startsWith(c.Hi.FASTA))return p;if(t.toLowerCase().startsWith(c.Hi.SEPARATOR))return f(e,n);if(t.toLowerCase().startsWith(c.Hi.HELM))return g;throw new Error(`Unexpected units ${t} .`)}const b=/([^\W_]+)/g;function v(t,e){if(t.length<=e)return t;const n=t.match(b),i=t.length>e||(n?.length??0)>1,o=n?.[0]??" ";return i?o.substring(0,e-1)+"…":o}function w(t){switch(t){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 '${t}'.`)}}function C(t,e,n="-"){const i=e.map((e=>{const i=function(t,e,n="-"){const i=new Set([...new Set(Object.keys(t)),...e]);i.delete(n);const o=[],r=[];for(const n of i)o.push(n in t?t[n]:0),r.push(e.has(n)?1:0);const l=new s.Mi(o),c=new s.Mi(r);return(0,a.KE)(l,c)/((0,a.wQ)(l)*(0,a.wQ)(c))}(t,e.alphabet,n);return new l.X(e,t,i)}));let o;const r=Math.max(...i.map((t=>t.similarity>t.cutoff?t.similarity:-1)));return o=r>0?i.find((t=>t.similarity===r)).name:c.YI.UN,o}function A(t,e,n="-"){const i=Object.keys(t),o=/\(|\)/;return C(i.filter((t=>3===t.split(o).filter((t=>!!t)).length)).length>.8*i.length?Object.entries(t).reduce(((t,[e,n])=>{const i=e.split(o)[1];return i&&(t[i]=n),t}),{}):t,e,n)}function S(t){const e=t.columns.bySemTypeAll(i.SEMTYPE.MACROMOLECULE);let n=e.find((t=>{const e=t.meta.units;return!!e&&-1!==e.indexOf("MSA")}))??null;return!n&&e.length>0&&(n=e[0]),n}},8312:(t,e,n)=>{"use strict";n.d(e,{Q:()=>o});var i=n(6082);async function o(){const t=i.Func.find({package:"Bio",name:"getSeqHelper"});if(0===t.length)throw new Error("Package 'Bio' must be installed for SeqHelper.");return(await t[0].prepare().call()).getOutputParamValue()}},3077:(t,e,n)=>{"use strict";n.d(e,{R:()=>o});var i=n(6082);function o(t,e){const n=t=>{const e=s.columns.addNewString((t+1).toString());return o.push(e),e},o=[],r=t.length,s=i.DataFrame.create(r),a=e.getSeqHandler(t);for(let t=0;t<r;++t){const e=a.getSplitted(t);for(let i=0;i<e.length;++i){const r=e.getCanonical(i);((o[i]??null)||n(i)).set(t,r,!1)}}return s}},7602:(t,e,n)=>{"use strict";n.d(e,{g:()=>r});var i,o=n(9192);!function(t){t[t.error=0]="error",t[t.warning=1]="warning",t[t.info=2]="info",t[t.debug=3]="debug"}(i||(i={}));class r{constructor(t){this.logger=t,this.promise=Promise.resolve(),this.errors=[],this.syncCounter=0}sync(t,e){const n=++this.syncCounter;this.logger.debug(`${t}, SYNC syncId = ${n}, IN `),this.promise=this.promise.then((async()=>{this.logger.debug(`${t}, SYNC syncId = ${n}, START `),await e(),this.logger.debug(`${t}, SYNC syncId = ${n}, END `)})).catch((e=>{const[i,r]=(0,o.AP)(e);this.logger.error(`${t}, SYNC syncId = ${n}, ERROR:\n${i}`,void 0,r),this.errors.push(e)}))}resetErrors(){const t=this.errors;return this.errors=[],t}}},4326:(t,e,n)=>{"use strict";n.d(e,{Fo:()=>h,Lp:()=>r,P4:()=>s,fH:()=>o,gp:()=>i,lT:()=>l,mH:()=>a});var i,o,r,s,a,l,c=n(6082);!function(t){t.tooltipWebLogo=".tooltipWebLogo"}(i||(i={})),function(t){t.Entropy="Entropy",t.full="100%"}(o||(o={})),function(t){t.TOP="top",t.MIDDLE="middle",t.BOTTOM="bottom"}(r||(r={})),function(t){t.LEFT="left",t.CENTER="center",t.RIGHT="right"}(s||(s={})),function(t){t.AUTO="auto",t.ON="on",t.OFF="off"}(a||(a={})),function(t){t.Filtered="Filtered",t.Selected="Selected"}(l||(l={}));const h=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=r.MIDDLE,this.horizontalAlignment=s.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:(t,e,n)=>{"use strict";var i;n.d(e,{o:()=>i}),function(t){t.BASE="HELM_BASE",t.SUGAR="HELM_SUGAR",t.LINKER="HELM_LINKER",t.AA="HELM_AA",t.CHEM="HELM_CHEM",t.BLOB="HELM_BLOB",t.NUCLEOTIDE="HELM_NUCLETIDE"}(i||(i={}))},5540:(t,e,n)=>{"use strict";t=n.hmd(t);var i,o=(i="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0,function(t={}){var e,n,o=void 0!==t?t:{};o.ready=new Promise((function(t,i){e=t,n=i}));var r,s=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&&(r=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)})),o.print||console.log.bind(console);var h,u,d=o.printErr||console.warn.bind(console);Object.assign(o,s),s=null,o.arguments&&o.arguments,o.thisProgram&&o.thisProgram,o.quit&&o.quit,o.wasmBinary&&(h=o.wasmBinary),o.noExitRuntime,"object"!=typeof WebAssembly&&T("no native wasm support detected");var p,m,f,g=!1;function y(){var t=u.buffer;o.HEAP8=p=new Int8Array(t),o.HEAP16=new Int16Array(t),o.HEAP32=new Int32Array(t),o.HEAPU8=m=new Uint8Array(t),o.HEAPU16=new Uint16Array(t),o.HEAPU32=f=new Uint32Array(t),o.HEAPF32=new Float32Array(t),o.HEAPF64=new Float64Array(t)}var b,v,w=[],C=[],A=[],S=0,x=null,E=null;function T(t){o.onAbort&&o.onAbort(t),d(t="Aborted("+t+")"),g=!0,t+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(t);throw n(e),e}function M(t){return t.startsWith("data:application/octet-stream;base64,")}function _(t){try{if(t==b&&h)return new Uint8Array(h);if(r)return r(t);throw"both async and sync fetching of the wasm failed"}catch(t){T(t)}}function I(t,e,n){return function(t){return h||!a&&!l||"function"!=typeof fetch?Promise.resolve().then((function(){return _(t)})):fetch(t,{credentials:"same-origin"}).then((function(e){if(!e.ok)throw"failed to load wasm binary file at '"+t+"'";return e.arrayBuffer()})).catch((function(){return _(t)}))}(t).then((function(t){return WebAssembly.instantiate(t,e)})).then((function(t){return t})).then(n,(function(t){d("failed to asynchronously prepare wasm: "+t),T(t)}))}function L(t){for(;t.length>0;)t.shift()(o)}function N(t){this.excPtr=t,this.ptr=t-24,this.set_type=function(t){f[this.ptr+4>>2]=t},this.get_type=function(){return f[this.ptr+4>>2]},this.set_destructor=function(t){f[this.ptr+8>>2]=t},this.get_destructor=function(){return f[this.ptr+8>>2]},this.set_caught=function(t){t=t?1:0,p[this.ptr+12|0]=t},this.get_caught=function(){return 0!=p[this.ptr+12|0]},this.set_rethrown=function(t){t=t?1:0,p[this.ptr+13|0]=t},this.get_rethrown=function(){return 0!=p[this.ptr+13|0]},this.init=function(t,e){this.set_adjusted_ptr(0),this.set_type(t),this.set_destructor(e)},this.set_adjusted_ptr=function(t){f[this.ptr+16>>2]=t},this.get_adjusted_ptr=function(){return f[this.ptr+16>>2]},this.get_exception_ptr=function(){if(B(this.get_type()))return f[this.excPtr>>2];var t=this.get_adjusted_ptr();return 0!==t?t:this.excPtr}}function P(t){var e=u.buffer;try{return u.grow(t-e.byteLength+65535>>>16),y(),1}catch(t){}}function $(t){return o["_"+t]}M(b="wasmDbscan.wasm")||(v=b,b=o.locateFile?o.locateFile(v,c):c+v);var R="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function k(t,e,n,i,o){var r={string:t=>{var e=0;return null!=t&&0!==t&&(e=function(t){var e=function(t){for(var e=0,n=0;n<t.length;++n){var i=t.charCodeAt(n);i<=127?e++:i<=2047?e+=2:i>=55296&&i<=57343?(e+=4,++n):e+=3}return e}(t)+1,n=D(e);return function(t,e,n){!function(t,e,n,i){if(!(i>0))return 0;for(var o=n+i-1,r=0;r<t.length;++r){var s=t.charCodeAt(r);if(s>=55296&&s<=57343&&(s=65536+((1023&s)<<10)|1023&t.charCodeAt(++r)),s<=127){if(n>=o)break;e[n++]=s}else if(s<=2047){if(n+1>=o)break;e[n++]=192|s>>6,e[n++]=128|63&s}else if(s<=65535){if(n+2>=o)break;e[n++]=224|s>>12,e[n++]=128|s>>6&63,e[n++]=128|63&s}else{if(n+3>=o)break;e[n++]=240|s>>18,e[n++]=128|s>>12&63,e[n++]=128|s>>6&63,e[n++]=128|63&s}}e[n]=0}(t,m,e,n)}(t,n,e),n}(t)),e},array:t=>{var e,n,i=D(t.length);return e=t,n=i,p.set(e,n),i}},s=$(t),a=[],l=0;if(i)for(var c=0;c<i.length;c++){var h=r[n[c]];h?(0===l&&(l=G()),a[c]=h(i[c])):a[c]=i[c]}var u=s.apply(null,a);return function(t){return 0!==l&&F(l),function(t){return"string"===e?(n=t)?function(t,e,n){for(var i=e+n,o=e;t[o]&&!(o>=i);)++o;if(o-e>16&&t.buffer&&R)return R.decode(t.subarray(e,o));for(var r="";e<o;){var s=t[e++];if(128&s){var a=63&t[e++];if(192!=(224&s)){var l=63&t[e++];if((s=224==(240&s)?(15&s)<<12|a<<6|l:(7&s)<<18|a<<12|l<<6|63&t[e++])<65536)r+=String.fromCharCode(s);else{var c=s-65536;r+=String.fromCharCode(55296|c>>10,56320|1023&c)}}else r+=String.fromCharCode((31&s)<<6|a)}else r+=String.fromCharCode(s)}return r}(m,n,i):"":"boolean"===e?Boolean(t):t;var n,i}(t)}(u)}var O,H={__cxa_throw:function(t,e,n){throw new N(t).init(e,n),t},abort:function(){T("")},emscripten_memcpy_big:function(t,e,n){m.copyWithin(t,e,e+n)},emscripten_resize_heap:function(t){var e,n=m.length,i=2147483648;if((t>>>=0)>i)return!1;for(var o=1;o<=4;o*=2){var r=n*(1+.2/o);if(r=Math.min(r,t+100663296),P(Math.min(i,(e=Math.max(t,r))+(65536-e%65536)%65536)))return!0}return!1}},G=(function(){var t,e,i,r,s={env:H,wasi_snapshot_preview1:H};function a(t,e){var n,i=t.exports;return o.asm=i,u=o.asm.memory,y(),o.asm.__indirect_function_table,n=o.asm.__wasm_call_ctors,C.unshift(n),function(){if(S--,o.monitorRunDependencies&&o.monitorRunDependencies(S),0==S&&(null!==x&&(clearInterval(x),x=null),E)){var t=E;E=null,t()}}(),i}if(S++,o.monitorRunDependencies&&o.monitorRunDependencies(S),o.instantiateWasm)try{return o.instantiateWasm(s,a)}catch(t){d("Module.instantiateWasm callback failed with error: "+t),n(t)}(t=h,e=b,i=s,r=function(t){a(t.instance)},t||"function"!=typeof WebAssembly.instantiateStreaming||M(e)||"function"!=typeof fetch?I(e,i,r):fetch(e,{credentials:"same-origin"}).then((function(t){return WebAssembly.instantiateStreaming(t,i).then(r,(function(t){return d("wasm streaming compile failed: "+t),d("falling back to ArrayBuffer instantiation"),I(e,i,r)}))}))).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(G=o.asm.stackSave).apply(null,arguments)}),F=function(){return(F=o.asm.stackRestore).apply(null,arguments)},D=function(){return(D=o.asm.stackAlloc).apply(null,arguments)},B=function(){return(B=o.asm.__cxa_is_pointer_type).apply(null,arguments)};function V(){function t(){O||(O=!0,o.calledRun=!0,g||(L(C),e(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),function(){if(o.postRun)for("function"==typeof o.postRun&&(o.postRun=[o.postRun]);o.postRun.length;)t=o.postRun.shift(),A.unshift(t);var t;L(A)}()))}S>0||(function(){if(o.preRun)for("function"==typeof o.preRun&&(o.preRun=[o.preRun]);o.preRun.length;)t=o.preRun.shift(),w.unshift(t);var t;L(w)}(),S>0||(o.setStatus?(o.setStatus("Running..."),setTimeout((function(){setTimeout((function(){o.setStatus("")}),1),t()}),1)):t()))}if(o.ccall=k,o.cwrap=function(t,e,n,i){var o=!n||n.every((t=>"number"===t||"boolean"===t));return"string"!==e&&o&&!i?$(t):function(){return k(t,e,n,arguments)}},E=function t(){O||V(),O||(E=t)},o.preInit)for("function"==typeof o.preInit&&(o.preInit=[o.preInit]);o.preInit.length>0;)o.preInit.pop()();return V(),t.ready});"object"==typeof exports?t.exports=o:"function"==typeof define&&n.amdO?define([],(function(){return o})):"object"==typeof exports&&(exports.exportCppDbscanLib=o)},6295:(t,e,n)=>{"use strict";n.d(e,{$1:()=>s,Hf:()=>h,Hr:()=>E,Ii:()=>g,Qj:()=>m,T6:()=>x,TK:()=>A,be:()=>f,gt:()=>v,ij:()=>w,jL:()=>c,lO:()=>p,lP:()=>b,rR:()=>y,tO:()=>a,v_:()=>l,w_:()=>u,yK:()=>C,zn:()=>d});var i=n(8774),o=n(8498),r=n(6863);function s(t,e){const n=t.trueCount()+e.trueCount();if(0==n)return 1;const i=t.andWithCountBits(e,!0);return i/(n-i)}function a(t,e){return 1-s(t,e)}function l(t,e){return S(s(new i.A(t,32*t.length),new i.A(e,32*e.length)))}function c(t,e){let n=0;for(let i=0;i<t.length;i++)n+=Math.pow(t[i]-e[i],2);return Math.sqrt(n)}function h(t,e){let n=0;for(let i=0;i<t.length;i++)n+=Math.abs(t[i]-e[i]);return n}function u(t,e){let n=0,i=0,o=0;for(let r=0;r<t.length;r++)n+=t[r]*e[r],i+=t[r]*t[r],o+=e[r]*e[r];return(1-n/(Math.sqrt(i)*Math.sqrt(o)))/2}function d(t,e){return 1-function(t,e){const n=t.trueCount()+e.trueCount();return 0==n?0:2*t.andWithCountBits(e,!0)/n}(t,e)}function p(t,e){return 1-function(t,e){const n=t.trueCount()*e.trueCount();return 0==n?0:t.andWithCountBits(e,!0)/Math.sqrt(n)}(t,e)}function m(t,e){return Math.sqrt(t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0))}function f(t,e){return t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0)}function g(t,e){return 1-function(t,e){const n=t.trueCount()+e.trueCount(),i=t.andWithCountBits(e,!0);return i/(2*n-3*i)}(t,e)}function y(t,e){return S(function(t,e){const n=t.trueCount()+e.trueCount(),i=t.trueCount()*e.trueCount();return 0==i?0:t.andWithCountBits(e,!0)*n/(2*i)}(t,e))}function b(t,e){return S(function(t,e){const n=t.trueCount()+e.trueCount(),i=t.trueCount()*e.trueCount();return 0==i?0:(t.andWithCountBits(e,!0)*n-i)/i}(t,e))}function v(t,e){return 1-function(t,e){const n=Math.min(t.trueCount(),e.trueCount());return 0==n?0:t.andWithCountBits(e,!0)/n}(t,e)}function w(t,e){return S(function(t,e){const n=Math.max(t.trueCount(),e.trueCount());return 0==n?0:t.andWithCountBits(e,!0)/n}(t,e))}function C(t,e){return S(function(t,e){return 0==t.length?0:t.andWithCountBits(e,!0)/t.length}(t,e))}function A(t,e){return S(function(t,e){const n=t.andWithCountBits(e,!0),i=t.countBits(!0)+e.countBits(!0),o=t.length,r=o-i+n;return n==o||r==o?1:n/i+r/(2*o-i)}(t,e))}function S(t){return t<=0?3402823e32:1/t-1}function x(t){if(t&&null!=t.range&&t.range>0){const e=t.range;return(t,n)=>Math.abs(t-n)/e}return(t,e)=>Math.abs(t-e)}function E(t){const e=function(t){const e=t?.mostCommon??new Set;return(t,n)=>{const i=t.length,o=n.length;let r=0,s=0,a=0;for(;s<i&&a<o;)t[s]===n[a]?(e?.has(t[s])||++r,++s,++a):t[s]<n[a]?++s:++a;return r}}(t);return(t,n)=>0===n.length||0===t.length?1e4:Math.min(t.length,n.length)/(e(t,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,r.Z.HAMMING,r.Z.LEVENSHTEIN,r.Z.MONOMER_CHEMICAL_DISTANCE,r.Z.NEEDLEMANN_WUNSCH},684:(t,e,n)=>{"use strict";n.d(e,{C0:()=>r,GP:()=>i,Gi:()=>a,YP:()=>c,_X:()=>s,n3:()=>o,vb:()=>l});const i="dim-red-preprocessing-function",o="supportedSemTypes",r="supportedTypes",s="supportedUnits",a="supportedDistanceFunctions",l="bypassLargeDataWarning",c="show-scatterplot-progress"},6863:(t,e,n)=>{"use strict";function i(t={}){const e=function(){if(!t||!t.scoringMatrix||!t.alphabetIndexes)return(t,e)=>t===e?0:1;if(t.scoringMatrix.length!==Object.keys(t.alphabetIndexes).length)throw new Error("Scoring matrix and alphabet indexes should have the same length");const e=t.alphabetIndexes,n=t.scoringMatrix,i=Math.min(...Object.keys(e).map((t=>t.charCodeAt(0))))+1,o=new Float32Array((n.length+i)*(n.length+i));return Object.entries(e).forEach((([t,i])=>{const r=n[i];Object.entries(e).forEach((([e,i])=>{o[t.charCodeAt(0)*n.length+e.charCodeAt(0)]=r[i]}))})),(t,e)=>1-o[t.charCodeAt(0)*n.length+e.charCodeAt(0)]}(),n=t?.threshold??0;return(t,i)=>{let o=0;const r=t.length,s=i.length,a=Math.ceil(Math.max(r,s)*(1-n));r!==s&&(o=Math.abs(r-s));let l=0;for(let n=0;n<Math.min(r,s);n++)if(t[n]!==i[n]&&(l+=e(t[n],i[n]),l>a))return 1;return l+=o,l/=Math.max(r,s),l}}n.d(e,{Z:()=>s,V:()=>a});var o=n(2787);const r={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 s;!function(t){t.HAMMING="Hamming",t.LEVENSHTEIN="Levenshtein",t.NEEDLEMANN_WUNSCH="Needlemann-Wunsch",t.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance"}(s||(s={}));const a={[s.HAMMING]:i,[s.LEVENSHTEIN]:function(){return(t,e)=>(0,o.I)(t,e)/Math.max(t.length,e.length)},[s.NEEDLEMANN_WUNSCH]:function(t){const e=new Uint16Array(65536),{gapOpen:n,gapExtend:i,scoringMatrix:o,alphabetIndexes:s}={...r,...t};Object.entries(s).forEach((([t,n])=>e[t.charCodeAt(0)]=n));const a=[new Float32Array(1e4),new Float32Array(1e4)];return(t,r)=>{const s=new Array(t.length+1).fill(!1),l=new Array(t.length+1).fill(!1);let c=0,h=1;for(let e=1;e<t.length+1;e++)a[0][e]=-i-(e-1)*i,a[1][e]=0;a[0][0]=0;for(let u=1;u<r.length+1;u++){a[h][0]=-i-(u-1)*i;for(let d=1;d<t.length+1;d++){const p=a[c][d-1]+o[e[t.charCodeAt(d-1)]][e[r.charCodeAt(u-1)]],m=a[c][d]-(s[d]||1===u||u===r.length?i:n),f=a[h][d-1]-(l[d-1]||1===d||d===t.length?i:n);a[h][d]=Math.max(p,f,m),a[h][d]===p?(s[d]=!1,l[d]=!1):a[h][d]===f?(s[d]=!1,l[d]=!0):(s[d]=!0,l[d]=!1)}c=h,h=(h+1)%2}const u=Math.min(t.length,r.length);return(u-a[c][t.length])/u}},[s.MONOMER_CHEMICAL_DISTANCE]:i}},8060:(t,e,n)=>{"use strict";n.d(e,{S:()=>i});const i="dimensionality-reducer-terminate-event"},9039:(t,e,n)=>{"use strict";var i;n.d(e,{c:()=>i}),function(t){t.UMAP="UMAP",t.T_SNE="t-SNE"}(i||(i={}))},8498:(t,e,n)=>{"use strict";var i,o,r,s,a,l,c;n.d(e,{EG:()=>a,Pn:()=>o,RR:()=>l,Wn:()=>c,aT:()=>r,m6:()=>s,xL:()=>i}),function(t){t.Levenshtein="Levenshtein",t.JaroWinkler="Jaro-Winkler",t.Manhattan="Manhattan String",t.Onehot="One-Hot"}(i||(i={})),function(t){t.Euclidean="Euclidean",t.Manhattan="Manhattan",t.Cosine="Vector Cosine"}(o||(o={})),function(t){t.Tanimoto="Tanimoto",t.Dice="Dice",t.Asymmetric="Asymmetric",t.BraunBlanquet="Braun-Blanquet",t.Cosine="Cosine",t.Kulczynski="Kulczynski",t.McConnaughey="Mc-Connaughey",t.RogotGoldberg="Rogot-Goldberg",t.Russel="Russel",t.Sokal="Sokal",t.Hamming="Hamming",t.Euclidean="Euclidean BitArray"}(r||(r={})),function(t){t.TanimotoIntArray="TanimotoIntArray"}(s||(s={})),function(t){t.Vector="Vector",t.String="String",t.BitArray="BitArray",t.MacroMolecule="MacroMolecule",t.Number="Number",t.IntArray="IntArray",t.NumberArray="NumberArray"}(a||(a={})),function(t){t.Difference="Difference"}(l||(l={})),function(t){t.CommonItems="Common Items"}(c||(c={}))},2780:(t,e,n)=>{"use strict";n(8498),n(9336)},9336:(t,e,n)=>{"use strict";var i=n(2787),o=n(944),r=n(6295),s=n(6863),a=n(8498);const l={[a.Pn.Euclidean]:r.jL,[a.Pn.Manhattan]:r.Hf,[a.Pn.Cosine]:r.w_},c={[a.xL.Levenshtein]:i.I,[a.xL.JaroWinkler]:o.Vb,[a.xL.Manhattan]:function(t,e){if(t.length!==e.length)return 1;{let n=0;for(let i=1;i<t.length;i++)n+=t[i]==e[i]?0:1;return n/t.length}},[a.xL.Onehot]:function(t,e){return t===e?0:1}},h={[a.aT.Tanimoto]:r.tO,[a.aT.Dice]:r.zn,[a.aT.Asymmetric]:r.gt,[a.aT.BraunBlanquet]:r.ij,[a.aT.Cosine]:r.lO,[a.aT.Kulczynski]:r.rR,[a.aT.McConnaughey]:r.lP,[a.aT.RogotGoldberg]:r.TK,[a.aT.Russel]:r.yK,[a.aT.Sokal]:r.Ii,[a.aT.Hamming]:r.be,[a.aT.Euclidean]:r.Qj},u={[a.m6.TanimotoIntArray]:r.v_},d={[a.RR.Difference]:r.T6},p={[a.Wn.CommonItems]:r.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]:h[a.aT.Tanimoto],[a.aT.Dice]:h[a.aT.Dice],[a.aT.Asymmetric]:h[a.aT.Asymmetric],[a.aT.BraunBlanquet]:h[a.aT.BraunBlanquet],[a.aT.Cosine]:h[a.aT.Cosine],[a.aT.Kulczynski]:h[a.aT.Kulczynski],[a.aT.McConnaughey]:h[a.aT.McConnaughey],[a.aT.RogotGoldberg]:h[a.aT.RogotGoldberg],[a.aT.Russel]:h[a.aT.Russel],[a.aT.Sokal]:h[a.aT.Sokal]},[a.EG.MacroMolecule]:{[s.Z.HAMMING]:s.V[s.Z.HAMMING],[s.Z.LEVENSHTEIN]:s.V[s.Z.LEVENSHTEIN],[s.Z.NEEDLEMANN_WUNSCH]:s.V[s.Z.NEEDLEMANN_WUNSCH],[s.Z.MONOMER_CHEMICAL_DISTANCE]:s.V[s.Z.MONOMER_CHEMICAL_DISTANCE]},[a.EG.Number]:{[a.RR.Difference]:d[a.RR.Difference]},[a.EG.IntArray]:{[a.m6.TanimotoIntArray]:u[a.m6.TanimotoIntArray]},[a.EG.NumberArray]:{[a.Wn.CommonItems]:p[a.Wn.CommonItems]}};Object.keys(m).reduce(((t,e)=>{for(const n of Object.keys(m[e]))t[n]=e;return t}),{})},8774:(t,e,n)=>{"use strict";n.d(e,{A:()=>i});class i{constructor(t,e=!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 t){const n=t,o=i._createBuffer(n);if(e)for(let t=0;t<o.length;t++)o[t]=-1;this._data=o,this._length=n}else{if(!(t instanceof Uint32Array))throw new Error("Invalid constructor");this._data=t,this._length=e}}getRawData(){return this._data}assureGoez(t,e){if(t<0)throw new Error(`${e} should be greater than zero`)}assureInRange(t,e,n,i){if(t<e||t>n)throw new Error(`Argument ${i} (${t}) out of range (${e}, ${n})`)}copy(t,e,n){for(let i=0;i<n;i++)e[i]=t[i]}copyFrom(t){if(this._length!=t._length)throw new Error(`Lengths differ (${this._length} != ${t._length})`);this.copy(t._data,this._data,this.lengthInInts),this._version++}get length(){return this._length}get buffer(){return this._data}set buffer(t){this._data=t,this._version++}get version(){return this._version}set version(t){this._version=t}incrementVersion(t=!0){this._version++}get lengthInInts(){return Math.floor((this._length+31)/32)}get versionedName(){return this._version==this._versionedNameVersion?this._versionedName:""}set versionedName(t){this._versionedName=t,this._versionedNameVersion=this._version}get self(){return this}setLength(t){if(t<0)throw new Error("should be >= 0");if(t==this._length)return;const e=Math.floor((t+31)/32);if(e>this._data.length||e+this.SHRINK_THRESHOLD<this._data.length){const t=new Uint32Array(e);this.copy(this._data,t,e>this._data.length?this._data.length:e),this._data=t}t>this._length&&(this._length%32>0&&(this._data[this.lengthInInts-1]&=(1<<(this._length%32&31))-1),this._data.fill(0,this.lengthInInts,e)),this._length=t,this._version++}static fromAnd(t,e){if(t._length!=e._length)throw new Error(`Lengths differ (${t._length} != ${e._length})`);const n=new i(t._length);n._length=t._length,n._data=i._createBuffer(n._length),n._version=0;const o=t.lengthInInts;for(let i=0;i<o;i++)n._data[i]=t._data[i]&e._data[i];return n}static _createBuffer(t){return new Uint32Array(Math.floor((t+31)/32))}static fromValues(t){const e=new i(t.length);e._version=0;for(let n=0;n<e._length;n++)t[n]&&(e._data[Math.floor(n/32)]|=1<<(n%32&31));return e}static fromSeq(t,e){const n=new i(t);for(let i=0;i<t;++i)n.setBit(i,e(i));return n._version=0,n}static fromString(t){return i.fromSeq(t.length,(e=>"1"==t.charAt(e)))}static fromUint32Array(t,e){const n=new i(t);return n._data=e,n}static fromBytes(t){const e=t.length,n=new i(8*e);n._data=new Uint32Array(Math.floor((e+3)/4)),n._length=8*e;let o=0,r=0;for(;e-r>=4;)n._data[o++]=255&t[r]|(255&t[r+1])<<8|(255&t[r+2])<<16|(255&t[r+3])<<24,r+=4;return e-r==3&&(n._data[o]=(255&t[r+2])<<16),e-r==2&&(n._data[o]|=(255&t[r+1])<<8),e-r==1&&(n._data[o]|=255&t[r]),n._version=0,n}toString(){return`${this._length} bits, ${this.countBits(!0)} set`}equals(t){if(this==t)return!0;if(null==t)return!1;if(this._length!=t._length)return!1;if(0==this._length)return!0;for(let e=0;e<this._data.length-1;e++)if(this._data[e]!=t._data[e])return!1;for(let e=8*(this._data.length-1);e<this._length;e++)if(this.getBit(e)!=t.getBit(e))return!1;return!0}clone(){const t=new i(0,!1);return t._data=Uint32Array.from(this._data),t._length=this._length,t._version=this._version,t}init(t,e){this.setAll(!1,!1);for(let e=0;e<this._length;e++)t(e)&&(this._data[Math.floor(e/32)]|=1<<(e%32&31));return this.incrementVersion(e),this}invert(t=!0){for(let t=0;t<this._data.length;t++)this._data[t]^=-1;this.incrementVersion(t)}setAll(t,e=!1){const n=t?-1:0,i=this.lengthInInts;for(let t=0;t<i;t++)this._data[t]=n;this.incrementVersion(e)}setIndexes(t,e=!0,n=!0,i=!0){n&&this.setAll(!e,!1);for(const n of t)this.setFast(n,e);this.incrementVersion(i)}everyIndex(t,e=!0){for(const n of t)if(this.getBit(n)!=e)return!1;return!0}anyIndex(t,e=!0){for(const n of t)if(this.getBit(n)==e)return!0;return!1}setWhere(t,e=!0,n=!0,i=!0,o=!0){if(n&&o&&this.setAll(!e,!1),o)for(let n=0;n<this._length;n++)t(n)&&this.setFast(n,e);else for(let n=0;n<this._length;n++)this.setFast(n,t(n)?e:!e);this.incrementVersion(i)}getRange(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const n=[];for(let i=t;i<e;++i)n.push(this.getBit(i));return i.fromValues(n)}getRangeAsList(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const n=[];for(let i=t;i<e;++i)n.push(this.getBit(i));return n}setRange(t,e,n,i=!0){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length-1,"to");const o=Math.min(t,e),r=Math.max(t,e);if(n)for(let t=o;t<=r;t++)this.setTrue(t);else for(let t=o;t<=r;t++)this.setFalse(t);return this.incrementVersion(i),this}setRandom(t,e,n=!0){if(t<0||t>this._length)throw new Error("n must be >= 0 && <= Count");t>this._length/2&&this.setRandom(this._length-t,!e),this.setAll(!e);for(let n=0;n<t;){const t=Math.floor(Math.random()*this._length);this.getBit(t)!=e&&(this.setFast(t,e),n++)}this.incrementVersion(n)}and(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]&=t._data[e];return this.incrementVersion(e),this}andNot(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");const n=this.lengthInInts;for(let e=0;e<n;e++)this._data[e]&=~t._data[e];return this.incrementVersion(e),this}notAnd(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]=~this._data[e]&t._data[e];return this.incrementVersion(e),this}not(t=!0){for(let t=0,e=this.lengthInInts;t<e;t++)this._data[t]=~this._data[t];return this.incrementVersion(t),this}or(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]|=t._data[e];return this.incrementVersion(e),this}xor(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]^=t._data[e];return this.incrementVersion(e),this}insertAt(t,e,n=!1){if(this.assureInRange(t,0,this._length,"pos"),0==e)return;const i=this._length;this.setLength(this._length+e);for(let n=i-1;n>=t;n--)this.setBit(n+e,this.getBit(n));for(let i=t;i<t+e;i++)this.setBit(i,n)}removeAt(t,e=1){if(e<0)throw new Error("n cannot be negative");if(this.assureInRange(t,0,this._length-e,"pos"),this.contains(!0))for(let n=t;n<this._length-e;n++)this.setBit(n,this.getBit(n+e));this.setLength(this._length-e)}removeByMask(t,e=!0){if(this._length!=t.length)throw new Error("length != mask.length");if(t==this)this.setLength(t.countBits(!e)),this.setAll(!e);else{let n=0;for(let i=-1;-1!=(i=t.findNext(i,!e));)this.setFast(n++,this.getBit(i));this._length=n,this._version++}return this}getBit(t){return!!(this._data[Math.floor(t/32)]&1<<(31&t))}setBit(t,e,n=!0){this.setFast(t,e),this._version++}setFast(t,e){e?this._data[Math.floor(t/32)]|=1<<(31&t):this._data[Math.floor(t/32)]&=~(1<<(31&t))}setTrue(t){this._data[Math.floor(t/32)]|=1<<(31&t)}setFalse(t){this._data[Math.floor(t/32)]&=~(1<<(31&t))}trueCount(){return this.countBits(!0)}falseCount(){return this.countBits(!1)}countBits(t){if(0==this._length)return 0;if(this._selectedCountVersion!=this._version){this._selectedCount=0;const t=this.lengthInInts;let e=0;for(;e<t-1;e++)for(let t=this._data[e];0!=t;t>>>=8)this._selectedCount+=i._onBitCount[255&t];let n=this._data[e];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 t?this._selectedCount:this._length-this._selectedCount}countWhere(t){let e=0;if(this.trueCount()==this._length)for(let n=0;n<this._length;n++)e+=t(n)?1:0;else for(let n=-1;-1!=(n=this.findNext(n,!0));)e+=t(n)?1:0;return e}andWithCountBits(t,e){if(0==this._length)return 0;let n=0;const o=this.lengthInInts;let r=0;for(;r<o-1;r++)for(let e=this._data[r]&t._data[r];0!=e;e>>>=8)n+=i._onBitCount[255&e];let s=this._data[r]&t._data[r];const a=31&this._length;for(0!=a&&(s&=~(4294967295<<a));0!=s;s>>>=8)n+=i._onBitCount[255&s];return e?n:this._length-n}clear(){this.setLength(0)}contains(t){return this.findNext(-1,t)>=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(t,e=!0){if(this.assureInRange(t,-1,this._length,"index"),t>=this._length-1)return-1;let n=31&(t=t<0?0:t+1);const o=this.lengthInInts;for(let r=Math.floor(t/32);r<o;r++){let o=e?this._data[r]:~this._data[r];if(0!=n)o&=4294967295<<n&4294967295,n=0;else if(!e&&-4294967296==o)continue;for(let e=0;0!=o;e+=8,o>>>=8){const n=i._firstOnBit[255&o];if(n>=0)return(t=n+32*r+e)>=this._length?-1:t}}return-1}findPrev(t,e=!0){if(0==t)return-1;this.assureInRange(t,-1,this._length,"index");let n=1+(t=t<0?this._length-1:t-1)&31;for(let o=Math.floor(t/32);o>=0;o--){let t=e?this._data[o]:~this._data[o];0!=n&&(t&=~(4294967295<<n),n=0);for(let e=24;0!=t;e-=8,t<<=8){const n=i._lastOnBit[t>>>24];if(n>=0)return n+32*o+e}}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:(t,e,n)=>{"use strict";n.d(e,{cb:()=>a,PE:()=>s}),n(4328);var i=n(6082);n(9982),i.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,,,,,,,,,,,,,,,,,,,,,').columns.add(i.Column.fromList(i.TYPE.BYTE_ARRAY,"BinaryImage",Array.from(new Uint8Array(11))));var o,r=function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((i=i.apply(t,e||[])).next())}))};function s(t,e,n,i=0,o="timeout"){return r(this,void 0,void 0,(function*(){return new Promise(((r,s)=>{const a=t.subscribe((t=>{try{e(t),r("OK")}catch(t){s(t)}finally{a.unsubscribe(),clearTimeout(l)}})),l=setTimeout((()=>{a.unsubscribe(),s(o)}),i);n()}))}))}function a(t){return r(this,void 0,void 0,(function*(){yield new Promise((e=>setTimeout(e,t)))}))}console.log.bind(console),console.info.bind(console),console.warn.bind(console),console.error.bind(console),function(t){t.notNull=function(t,e){if(null==t)throw new Error(`${null==e?"Value":e} not defined`)}}(o||(o={})),i.DataFrame.fromColumns([i.Column.fromStrings("col",["val1","val2","val3"])])},3527:(t,e,n)=>{"use strict";n.d(e,{Mi:()=>i});class i extends Float32Array{}},3629:(t,e,n)=>{"use strict";n.d(e,{KE:()=>a,S8:()=>l,dC:()=>r,vA:()=>o,wQ:()=>s});var i=n(3527);function o(t=!1,e="Assertion error."){if(!t)throw new Error(e)}function r(t,e,n=1){const r=t.length;o(r==e.length,"Vector lengths do not match.");const s=new i.Mi(r);for(let i=0;i<t.length;++i)s[i]=t[i]+n*e[i];return s}function s(t){let e=0;for(let n=0;n<t.length;n++)e+=t[n]*t[n];return Math.sqrt(e)}function a(t,e){if(t.length!=e.length)throw new Error("The dimensionality of the vectors must match");let n=0;for(let i=0;i<t.length;i++)n+=t[i]*e[i];return n}function l(t){const e=t.length;let n=0,i=0;for(let o=0;o<e;++o)n+=t[o],i+=Math.pow(t[o],2);const o=n/e,r=1/Math.sqrt(i/e-Math.pow(o,2));for(let n=0;n<e;++n)t[n]=(t[n]-o)*r;return t}},1913:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(3282),o=n(9029),r=n(1520),s=n(2586),a=n(8708),l=n(2023),c="errorMessage",h=new i.Name("emUsed"),u={required:"missingProperty",dependencies:"property",dependentRequired:"property"},d=/\$\{[^}]+\}/,p=/\$\{([^}]+)\}/g,m=/^""\s*\+\s*|\s*\+\s*""$/g;const f=(t,e={})=>{if(!t.opts.allErrors)throw new Error("ajv-errors: Ajv option allErrors must be true");if(t.opts.jsPropertySyntax)throw new Error("ajv-errors: ajv option jsPropertySyntax is not supported");return t.addKeyword(function(t){return{keyword:c,schemaType:["string","object"],post:!0,code(e){const{gen:n,data:f,schema:g,schemaValue:y,it:b}=e;if(!1===b.createErrors)return;const v=g,w=o.strConcat(l.default.instancePath,b.errorPath);function C(t,e){return o.and(i._`${t}.keyword !== ${c}`,i._`!${t}.${h}`,i._`${t}.instancePath === ${w}`,i._`${t}.keyword in ${e}`,i._`${t}.schemaPath.indexOf(${b.errSchemaPath}) === 0`,i._`/^\\/[^\\/]*$/.test(${t}.schemaPath.slice(${b.errSchemaPath.length}))`)}function A(t,e){const i=[];for(const n in t){const t=e[n];d.test(t)&&i.push([n,x(t)])}return n.object(...i)}function S(t){return d.test(t)?new r._Code(r.safeStringify(t).replace(p,((t,e)=>`" + JSON.stringify(${s.getData(e,b)}) + "`)).replace(m,"")):i.stringify(t)}function x(t){return i._`function(){return ${S(t)}}`}n.if(i._`${l.default.errors} > 0`,(()=>{if("object"==typeof v){const[r,s]=function(t){let e,n;for(const i in t){if("properties"===i||"items"===i)continue;const o=t[i];if("object"==typeof o){e||(e={});const t=e[i]={};for(const e in o)t[e]=[]}else n||(n={}),n[i]=[]}return[e,n]}(v);s&&function(o){const r=n.const("emErrors",i.stringify(o)),s=n.const("templates",A(o,g));n.forOf("err",l.default.vErrors,(t=>n.if(C(t,r),(()=>n.code(i._`${r}[${t}.keyword].push(${t})`).assign(i._`${t}.${h}`,!0)))));const{singleError:c}=t;if(c){const t=n.let("message",i._`""`),o=n.let("paramsErrors",i._`[]`);u((e=>{n.if(t,(()=>n.code(i._`${t} += ${"string"==typeof c?c:";"}`))),n.code(i._`${t} += ${d(e)}`),n.assign(o,i._`${o}.concat(${r}[${e}])`)})),a.reportError(e,{message:t,params:i._`{errors: ${o}}`})}else u((t=>a.reportError(e,{message:d(t),params:i._`{errors: ${r}[${t}]}`})));function u(t){n.forIn("key",r,(e=>n.if(i._`${r}[${e}].length`,(()=>t(e)))))}function d(t){return i._`${t} in ${s} ? ${s}[${t}]() : ${y}[${t}]`}}(s),r&&function(t){const o=n.const("emErrors",i.stringify(t)),r=[];for(const e in t)r.push([e,A(t[e],g[e])]);const s=n.const("templates",n.object(...r)),c=n.scopeValue("obj",{ref:u,code:i.stringify(u)}),d=n.let("emPropParams"),p=n.let("emParamsErrors");n.forOf("err",l.default.vErrors,(t=>n.if(C(t,o),(()=>{n.assign(d,i._`${c}[${t}.keyword]`),n.assign(p,i._`${o}[${t}.keyword][${t}.params[${d}]]`),n.if(p,(()=>n.code(i._`${p}.push(${t})`).assign(i._`${t}.${h}`,!0)))})))),n.forIn("key",o,(t=>n.forIn("keyProp",i._`${o}[${t}]`,(r=>{n.assign(p,i._`${o}[${t}][${r}]`),n.if(i._`${p}.length`,(()=>{const o=n.const("tmpl",i._`${s}[${t}] && ${s}[${t}][${r}]`);a.reportError(e,{message:i._`${o} ? ${o}() : ${y}[${t}][${r}]`,params:i._`{errors: ${p}}`})}))}))))}(r),function(t){const{props:r,items:s}=t;if(!r&&!s)return;const u=i._`typeof ${f} == "object"`,d=i._`Array.isArray(${f})`,p=n.let("emErrors");let m,b;const v=n.let("templates");function C(t,e){n.assign(p,i.stringify(t)),n.assign(v,A(t,e))}r&&s?(m=n.let("emChildKwd"),n.if(u),n.if(d,(()=>{C(s,g.items),n.assign(m,i.str`items`)}),(()=>{C(r,g.properties),n.assign(m,i.str`properties`)})),b=i._`[${m}]`):s?(n.if(d),C(s,g.items),b=i._`.items`):r&&(n.if(o.and(u,o.not(d))),C(r,g.properties),b=i._`.properties`),n.forOf("err",l.default.vErrors,(t=>function(t,e,r){n.if(o.and(i._`${t}.keyword !== ${c}`,i._`!${t}.${h}`,i._`${t}.instancePath.indexOf(${w}) === 0`),(()=>{const o=n.scopeValue("pattern",{ref:/^\/([^/]*)(?:\/|$)/,code:i._`new RegExp("^\\\/([^/]*)(?:\\\/|$)")`}),s=n.const("emMatches",i._`${o}.exec(${t}.instancePath.slice(${w}.length))`),a=n.const("emChild",i._`${s} && ${s}[1].replace(/~1/g, "/").replace(/~0/g, "~")`);n.if(i._`${a} !== undefined && ${a} in ${e}`,(()=>r(a)))}))}(t,p,(e=>n.code(i._`${p}[${e}].push(${t})`).assign(i._`${t}.${h}`,!0))))),n.forIn("key",p,(t=>n.if(i._`${p}[${t}].length`,(()=>{a.reportError(e,{message:i._`${t} in ${v} ? ${v}[${t}]() : ${y}${b}[${t}]`,params:i._`{errors: ${p}[${t}]}`}),n.assign(i._`${l.default.vErrors}[${l.default.errors}-1].instancePath`,i._`${w} + "/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`)})))),n.endIf()}(function({properties:t,items:e}){const n={};if(t){n.props={};for(const e in t)n.props[e]=[]}if(e){n.items={};for(let t=0;t<e.length;t++)n.items[t]=[]}return n}(v))}const r="string"==typeof v?v:v._;r&&function(t){const r=n.const("emErrs",i._`[]`);n.forOf("err",l.default.vErrors,(t=>n.if(function(t){return o.and(i._`${t}.keyword !== ${c}`,i._`!${t}.${h}`,o.or(i._`${t}.instancePath === ${w}`,o.and(i._`${t}.instancePath.indexOf(${w}) === 0`,i._`${t}.instancePath[${w}.length] === "/"`)),i._`${t}.schemaPath.indexOf(${b.errSchemaPath}) === 0`,i._`${t}.schemaPath[${b.errSchemaPath}.length] === "/"`)}(t),(()=>n.code(i._`${r}.push(${t})`).assign(i._`${t}.${h}`,!0))))),n.if(i._`${r}.length`,(()=>a.reportError(e,{message:S(t),params:i._`{errors: ${r}}`})))}(r),t.keepErrors||function(){const t=n.const("emErrs",i._`[]`);n.forOf("err",l.default.vErrors,(e=>n.if(i._`!${e}.${h}`,(()=>n.code(i._`${t}.push(${e})`))))),n.assign(l.default.vErrors,t).assign(l.default.errors,i._`${t}.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"}}}}}}(e))};e.default=f,t.exports=f,t.exports.default=f},7433:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.MissingRefError=e.ValidationError=e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=e.Ajv2020=void 0;const i=n(4042),o=n(6105),r=n(6653),s=n(9572),a="https://json-schema.org/draft/2020-12/schema";class l extends i.default{constructor(t={}){super({...t,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){super._addVocabularies(),o.default.forEach((t=>this.addVocabulary(t))),this.opts.discriminator&&this.addKeyword(r.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();const{$data:t,meta:e}=this.opts;e&&(s.default.call(this,t),this.refs["http://json-schema.org/schema"]=a)}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(a)?a:void 0)}}e.Ajv2020=l,t.exports=e=l,t.exports.Ajv2020=l,Object.defineProperty(e,"__esModule",{value:!0}),e.default=l;var c=n(2586);Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return c.KeywordCxt}});var h=n(9029);Object.defineProperty(e,"_",{enumerable:!0,get:function(){return h._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return h.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return h.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return h.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return h.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return h.CodeGen}});var u=n(3558);Object.defineProperty(e,"ValidationError",{enumerable:!0,get:function(){return u.default}});var d=n(4551);Object.defineProperty(e,"MissingRefError",{enumerable:!0,get:function(){return d.default}})},3282:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.MissingRefError=e.ValidationError=e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=e.Ajv=void 0;const i=n(4042),o=n(6144),r=n(6653),s=n(2079),a=["/properties"],l="http://json-schema.org/draft-07/schema";class c extends i.default{_addVocabularies(){super._addVocabularies(),o.default.forEach((t=>this.addVocabulary(t))),this.opts.discriminator&&this.addKeyword(r.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const t=this.opts.$data?this.$dataMetaSchema(s,a):s;this.addMetaSchema(t,l,!1),this.refs["http://json-schema.org/schema"]=l}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(l)?l:void 0)}}e.Ajv=c,t.exports=e=c,t.exports.Ajv=c,Object.defineProperty(e,"__esModule",{value:!0}),e.default=c;var h=n(2586);Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return h.KeywordCxt}});var u=n(9029);Object.defineProperty(e,"_",{enumerable:!0,get:function(){return u._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return u.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return u.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return u.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return u.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return u.CodeGen}});var d=n(3558);Object.defineProperty(e,"ValidationError",{enumerable:!0,get:function(){return d.default}});var p=n(4551);Object.defineProperty(e,"MissingRefError",{enumerable:!0,get:function(){return p.default}})},1520:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;class n{}e._CodeOrName=n,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class i extends n{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw new Error("CodeGen: name must be a valid identifier");this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}e.Name=i;class o extends n{constructor(t){super(),this._items="string"==typeof t?[t]:t}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const t=this._items[0];return""===t||'""'===t}get str(){var t;return null!==(t=this._str)&&void 0!==t?t:this._str=this._items.reduce(((t,e)=>`${t}${e}`),"")}get names(){var t;return null!==(t=this._names)&&void 0!==t?t:this._names=this._items.reduce(((t,e)=>(e instanceof i&&(t[e.str]=(t[e.str]||0)+1),t)),{})}}function r(t,...e){const n=[t[0]];let i=0;for(;i<e.length;)l(n,e[i]),n.push(t[++i]);return new o(n)}e._Code=o,e.nil=new o(""),e._=r;const s=new o("+");function a(t,...e){const n=[h(t[0])];let i=0;for(;i<e.length;)n.push(s),l(n,e[i]),n.push(s,h(t[++i]));return function(t){let e=1;for(;e<t.length-1;){if(t[e]===s){const n=c(t[e-1],t[e+1]);if(void 0!==n){t.splice(e-1,3,n);continue}t[e++]="+"}e++}}(n),new o(n)}function l(t,e){var n;e instanceof o?t.push(...e._items):e instanceof i?t.push(e):t.push("number"==typeof(n=e)||"boolean"==typeof n||null===n?n:h(Array.isArray(n)?n.join(","):n))}function c(t,e){if('""'===e)return t;if('""'===t)return e;if("string"==typeof t){if(e instanceof i||'"'!==t[t.length-1])return;return"string"!=typeof e?`${t.slice(0,-1)}${e}"`:'"'===e[0]?t.slice(0,-1)+e.slice(1):void 0}return"string"!=typeof e||'"'!==e[0]||t instanceof i?void 0:`"${t}${e.slice(1)}`}function h(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}e.str=a,e.addCodeArg=l,e.strConcat=function(t,e){return e.emptyStr()?t:t.emptyStr()?e:a`${t}${e}`},e.stringify=function(t){return new o(h(t))},e.safeStringify=h,e.getProperty=function(t){return"string"==typeof t&&e.IDENTIFIER.test(t)?new o(`.${t}`):r`[${t}]`},e.getEsmExportName=function(t){if("string"==typeof t&&e.IDENTIFIER.test(t))return new o(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)},e.regexpCode=function(t){return new o(t.toString())}},9029:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;const i=n(1520),o=n(7845);var r=n(1520);Object.defineProperty(e,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,"strConcat",{enumerable:!0,get:function(){return r.strConcat}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,"getProperty",{enumerable:!0,get:function(){return r.getProperty}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,"regexpCode",{enumerable:!0,get:function(){return r.regexpCode}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return r.Name}});var s=n(7845);Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return s.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return s.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return s.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return s.varKinds}}),e.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(t,e){return this}}class l extends a{constructor(t,e,n){super(),this.varKind=t,this.name=e,this.rhs=n}render({es5:t,_n:e}){const n=t?o.varKinds.var:this.varKind,i=void 0===this.rhs?"":` = ${this.rhs}`;return`${n} ${this.name}${i};`+e}optimizeNames(t,e){if(t[this.name.str])return this.rhs&&(this.rhs=N(this.rhs,t,e)),this}get names(){return this.rhs instanceof i._CodeOrName?this.rhs.names:{}}}class c extends a{constructor(t,e,n){super(),this.lhs=t,this.rhs=e,this.sideEffects=n}render({_n:t}){return`${this.lhs} = ${this.rhs};`+t}optimizeNames(t,e){if(!(this.lhs instanceof i.Name)||t[this.lhs.str]||this.sideEffects)return this.rhs=N(this.rhs,t,e),this}get names(){return L(this.lhs instanceof i.Name?{}:{...this.lhs.names},this.rhs)}}class h extends c{constructor(t,e,n,i){super(t,n,i),this.op=e}render({_n:t}){return`${this.lhs} ${this.op}= ${this.rhs};`+t}}class u extends a{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`${this.label}:`+t}}class d extends a{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`break${this.label?` ${this.label}`:""};`+t}}class p extends a{constructor(t){super(),this.error=t}render({_n:t}){return`throw ${this.error};`+t}get names(){return this.error.names}}class m extends a{constructor(t){super(),this.code=t}render({_n:t}){return`${this.code};`+t}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(t,e){return this.code=N(this.code,t,e),this}get names(){return this.code instanceof i._CodeOrName?this.code.names:{}}}class f extends a{constructor(t=[]){super(),this.nodes=t}render(t){return this.nodes.reduce(((e,n)=>e+n.render(t)),"")}optimizeNodes(){const{nodes:t}=this;let e=t.length;for(;e--;){const n=t[e].optimizeNodes();Array.isArray(n)?t.splice(e,1,...n):n?t[e]=n:t.splice(e,1)}return t.length>0?this:void 0}optimizeNames(t,e){const{nodes:n}=this;let i=n.length;for(;i--;){const o=n[i];o.optimizeNames(t,e)||(P(t,o.names),n.splice(i,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce(((t,e)=>I(t,e.names)),{})}}class g extends f{render(t){return"{"+t._n+super.render(t)+"}"+t._n}}class y extends f{}class b extends g{}b.kind="else";class v extends g{constructor(t,e){super(e),this.condition=t}render(t){let e=`if(${this.condition})`+super.render(t);return this.else&&(e+="else "+this.else.render(t)),e}optimizeNodes(){super.optimizeNodes();const t=this.condition;if(!0===t)return this.nodes;let e=this.else;if(e){const t=e.optimizeNodes();e=this.else=Array.isArray(t)?new b(t):t}return e?!1===t?e instanceof v?e:e.nodes:this.nodes.length?this:new v($(t),e instanceof v?[e]:e.nodes):!1!==t&&this.nodes.length?this:void 0}optimizeNames(t,e){var n;if(this.else=null===(n=this.else)||void 0===n?void 0:n.optimizeNames(t,e),super.optimizeNames(t,e)||this.else)return this.condition=N(this.condition,t,e),this}get names(){const t=super.names;return L(t,this.condition),this.else&&I(t,this.else.names),t}}v.kind="if";class w extends g{}w.kind="for";class C extends w{constructor(t){super(),this.iteration=t}render(t){return`for(${this.iteration})`+super.render(t)}optimizeNames(t,e){if(super.optimizeNames(t,e))return this.iteration=N(this.iteration,t,e),this}get names(){return I(super.names,this.iteration.names)}}class A extends w{constructor(t,e,n,i){super(),this.varKind=t,this.name=e,this.from=n,this.to=i}render(t){const e=t.es5?o.varKinds.var:this.varKind,{name:n,from:i,to:r}=this;return`for(${e} ${n}=${i}; ${n}<${r}; ${n}++)`+super.render(t)}get names(){const t=L(super.names,this.from);return L(t,this.to)}}class S extends w{constructor(t,e,n,i){super(),this.loop=t,this.varKind=e,this.name=n,this.iterable=i}render(t){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(t)}optimizeNames(t,e){if(super.optimizeNames(t,e))return this.iterable=N(this.iterable,t,e),this}get names(){return I(super.names,this.iterable.names)}}class x extends g{constructor(t,e,n){super(),this.name=t,this.args=e,this.async=n}render(t){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(t)}}x.kind="func";class E extends f{render(t){return"return "+super.render(t)}}E.kind="return";class T extends g{render(t){let e="try"+super.render(t);return this.catch&&(e+=this.catch.render(t)),this.finally&&(e+=this.finally.render(t)),e}optimizeNodes(){var t,e;return super.optimizeNodes(),null===(t=this.catch)||void 0===t||t.optimizeNodes(),null===(e=this.finally)||void 0===e||e.optimizeNodes(),this}optimizeNames(t,e){var n,i;return super.optimizeNames(t,e),null===(n=this.catch)||void 0===n||n.optimizeNames(t,e),null===(i=this.finally)||void 0===i||i.optimizeNames(t,e),this}get names(){const t=super.names;return this.catch&&I(t,this.catch.names),this.finally&&I(t,this.finally.names),t}}class M extends g{constructor(t){super(),this.error=t}render(t){return`catch(${this.error})`+super.render(t)}}M.kind="catch";class _ extends g{render(t){return"finally"+super.render(t)}}function I(t,e){for(const n in e)t[n]=(t[n]||0)+(e[n]||0);return t}function L(t,e){return e instanceof i._CodeOrName?I(t,e.names):t}function N(t,e,n){return t instanceof i.Name?r(t):(o=t)instanceof i._Code&&o._items.some((t=>t instanceof i.Name&&1===e[t.str]&&void 0!==n[t.str]))?new i._Code(t._items.reduce(((t,e)=>(e instanceof i.Name&&(e=r(e)),e instanceof i._Code?t.push(...e._items):t.push(e),t)),[])):t;var o;function r(t){const i=n[t.str];return void 0===i||1!==e[t.str]?t:(delete e[t.str],i)}}function P(t,e){for(const n in e)t[n]=(t[n]||0)-(e[n]||0)}function $(t){return"boolean"==typeof t||"number"==typeof t||null===t?!t:i._`!${H(t)}`}_.kind="finally",e.CodeGen=class{constructor(t,e={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...e,_n:e.lines?"\n":""},this._extScope=t,this._scope=new o.Scope({parent:t}),this._nodes=[new y]}toString(){return this._root.render(this.opts)}name(t){return this._scope.name(t)}scopeName(t){return this._extScope.name(t)}scopeValue(t,e){const n=this._extScope.value(t,e);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(t,e){return this._extScope.getValue(t,e)}scopeRefs(t){return this._extScope.scopeRefs(t,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(t,e,n,i){const o=this._scope.toName(e);return void 0!==n&&i&&(this._constants[o.str]=n),this._leafNode(new l(t,o,n)),o}const(t,e,n){return this._def(o.varKinds.const,t,e,n)}let(t,e,n){return this._def(o.varKinds.let,t,e,n)}var(t,e,n){return this._def(o.varKinds.var,t,e,n)}assign(t,e,n){return this._leafNode(new c(t,e,n))}add(t,n){return this._leafNode(new h(t,e.operators.ADD,n))}code(t){return"function"==typeof t?t():t!==i.nil&&this._leafNode(new m(t)),this}object(...t){const e=["{"];for(const[n,o]of t)e.length>1&&e.push(","),e.push(n),(n!==o||this.opts.es5)&&(e.push(":"),(0,i.addCodeArg)(e,o));return e.push("}"),new i._Code(e)}if(t,e,n){if(this._blockNode(new v(t)),e&&n)this.code(e).else().code(n).endIf();else if(e)this.code(e).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(t){return this._elseNode(new v(t))}else(){return this._elseNode(new b)}endIf(){return this._endBlockNode(v,b)}_for(t,e){return this._blockNode(t),e&&this.code(e).endFor(),this}for(t,e){return this._for(new C(t),e)}forRange(t,e,n,i,r=(this.opts.es5?o.varKinds.var:o.varKinds.let)){const s=this._scope.toName(t);return this._for(new A(r,s,e,n),(()=>i(s)))}forOf(t,e,n,r=o.varKinds.const){const s=this._scope.toName(t);if(this.opts.es5){const t=e instanceof i.Name?e:this.var("_arr",e);return this.forRange("_i",0,i._`${t}.length`,(e=>{this.var(s,i._`${t}[${e}]`),n(s)}))}return this._for(new S("of",r,s,e),(()=>n(s)))}forIn(t,e,n,r=(this.opts.es5?o.varKinds.var:o.varKinds.const)){if(this.opts.ownProperties)return this.forOf(t,i._`Object.keys(${e})`,n);const s=this._scope.toName(t);return this._for(new S("in",r,s,e),(()=>n(s)))}endFor(){return this._endBlockNode(w)}label(t){return this._leafNode(new u(t))}break(t){return this._leafNode(new d(t))}return(t){const e=new E;if(this._blockNode(e),this.code(t),1!==e.nodes.length)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(E)}try(t,e,n){if(!e&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');const i=new T;if(this._blockNode(i),this.code(t),e){const t=this.name("e");this._currNode=i.catch=new M(t),e(t)}return n&&(this._currNode=i.finally=new _,this.code(n)),this._endBlockNode(M,_)}throw(t){return this._leafNode(new p(t))}block(t,e){return this._blockStarts.push(this._nodes.length),t&&this.code(t).endBlock(e),this}endBlock(t){const e=this._blockStarts.pop();if(void 0===e)throw new Error("CodeGen: not in self-balancing block");const n=this._nodes.length-e;if(n<0||void 0!==t&&n!==t)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${t} expected`);return this._nodes.length=e,this}func(t,e=i.nil,n,o){return this._blockNode(new x(t,e,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(x)}optimize(t=1){for(;t-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(t){return this._currNode.nodes.push(t),this}_blockNode(t){this._currNode.nodes.push(t),this._nodes.push(t)}_endBlockNode(t,e){const n=this._currNode;if(n instanceof t||e&&n instanceof e)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${e?`${t.kind}/${e.kind}`:t.kind}"`)}_elseNode(t){const e=this._currNode;if(!(e instanceof v))throw new Error('CodeGen: "else" without "if"');return this._currNode=e.else=t,this}get _root(){return this._nodes[0]}get _currNode(){const t=this._nodes;return t[t.length-1]}set _currNode(t){const e=this._nodes;e[e.length-1]=t}},e.not=$;const R=O(e.operators.AND);e.and=function(...t){return t.reduce(R)};const k=O(e.operators.OR);function O(t){return(e,n)=>e===i.nil?n:n===i.nil?e:i._`${H(e)} ${t} ${H(n)}`}function H(t){return t instanceof i.Name?t:i._`(${t})`}e.or=function(...t){return t.reduce(k)}},7845:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;const i=n(1520);class o extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`),this.value=t.value}}var r;!function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"}(r||(e.UsedValueState=r={})),e.varKinds={const:new i.Name("const"),let:new i.Name("let"),var:new i.Name("var")};class s{constructor({prefixes:t,parent:e}={}){this._names={},this._prefixes=t,this._parent=e}toName(t){return t instanceof i.Name?t:this.name(t)}name(t){return new i.Name(this._newName(t))}_newName(t){return`${t}${(this._names[t]||this._nameGroup(t)).index++}`}_nameGroup(t){var e,n;if((null===(n=null===(e=this._parent)||void 0===e?void 0:e._prefixes)||void 0===n?void 0:n.has(t))||this._prefixes&&!this._prefixes.has(t))throw new Error(`CodeGen: prefix "${t}" is not allowed in this scope`);return this._names[t]={prefix:t,index:0}}}e.Scope=s;class a extends i.Name{constructor(t,e){super(e),this.prefix=t}setValue(t,{property:e,itemIndex:n}){this.value=t,this.scopePath=i._`.${new i.Name(e)}[${n}]`}}e.ValueScopeName=a;const l=i._`\n`;e.ValueScope=class extends s{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?l:i.nil}}get(){return this._scope}name(t){return new a(t,this._newName(t))}value(t,e){var n;if(void 0===e.ref)throw new Error("CodeGen: ref must be passed in value");const i=this.toName(t),{prefix:o}=i,r=null!==(n=e.key)&&void 0!==n?n:e.ref;let s=this._values[o];if(s){const t=s.get(r);if(t)return t}else s=this._values[o]=new Map;s.set(r,i);const a=this._scope[o]||(this._scope[o]=[]),l=a.length;return a[l]=e.ref,i.setValue(e,{property:o,itemIndex:l}),i}getValue(t,e){const n=this._values[t];if(n)return n.get(e)}scopeRefs(t,e=this._values){return this._reduceValues(e,(e=>{if(void 0===e.scopePath)throw new Error(`CodeGen: name "${e}" has no value`);return i._`${t}${e.scopePath}`}))}scopeCode(t=this._values,e,n){return this._reduceValues(t,(t=>{if(void 0===t.value)throw new Error(`CodeGen: name "${t}" has no value`);return t.value.code}),e,n)}_reduceValues(t,n,s={},a){let l=i.nil;for(const c in t){const h=t[c];if(!h)continue;const u=s[c]=s[c]||new Map;h.forEach((t=>{if(u.has(t))return;u.set(t,r.Started);let s=n(t);if(s){const n=this.opts.es5?e.varKinds.var:e.varKinds.const;l=i._`${l}${n} ${t} = ${s};${this.opts._n}`}else{if(!(s=null==a?void 0:a(t)))throw new o(t);l=i._`${l}${s}${this.opts._n}`}u.set(t,r.Completed)}))}return l}}},8708:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;const i=n(9029),o=n(4227),r=n(2023);function s(t,e){const n=t.const("err",e);t.if(i._`${r.default.vErrors} === null`,(()=>t.assign(r.default.vErrors,i._`[${n}]`)),i._`${r.default.vErrors}.push(${n})`),t.code(i._`${r.default.errors}++`)}function a(t,e){const{gen:n,validateName:o,schemaEnv:r}=t;r.$async?n.throw(i._`new ${t.ValidationError}(${e})`):(n.assign(i._`${o}.errors`,e),n.return(!1))}e.keywordError={message:({keyword:t})=>i.str`must pass "${t}" keyword validation`},e.keyword$DataError={message:({keyword:t,schemaType:e})=>e?i.str`"${t}" keyword must be ${e} ($data)`:i.str`"${t}" keyword is invalid ($data)`},e.reportError=function(t,n=e.keywordError,o,r){const{it:l}=t,{gen:h,compositeRule:u,allErrors:d}=l,p=c(t,n,o);(null!=r?r:u||d)?s(h,p):a(l,i._`[${p}]`)},e.reportExtraError=function(t,n=e.keywordError,i){const{it:o}=t,{gen:l,compositeRule:h,allErrors:u}=o;s(l,c(t,n,i)),h||u||a(o,r.default.vErrors)},e.resetErrorsCount=function(t,e){t.assign(r.default.errors,e),t.if(i._`${r.default.vErrors} !== null`,(()=>t.if(e,(()=>t.assign(i._`${r.default.vErrors}.length`,e)),(()=>t.assign(r.default.vErrors,null)))))},e.extendErrors=function({gen:t,keyword:e,schemaValue:n,data:o,errsCount:s,it:a}){if(void 0===s)throw new Error("ajv implementation error");const l=t.name("err");t.forRange("i",s,r.default.errors,(s=>{t.const(l,i._`${r.default.vErrors}[${s}]`),t.if(i._`${l}.instancePath === undefined`,(()=>t.assign(i._`${l}.instancePath`,(0,i.strConcat)(r.default.instancePath,a.errorPath)))),t.assign(i._`${l}.schemaPath`,i.str`${a.errSchemaPath}/${e}`),a.opts.verbose&&(t.assign(i._`${l}.schema`,n),t.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(t,e,n){const{createErrors:o}=t.it;return!1===o?i._`{}`:function(t,e,n={}){const{gen:o,it:s}=t,a=[h(s,n),u(t,n)];return function(t,{params:e,message:n},o){const{keyword:s,data:a,schemaValue:c,it:h}=t,{opts:u,propertyName:d,topSchemaRef:p,schemaPath:m}=h;o.push([l.keyword,s],[l.params,"function"==typeof e?e(t):e||i._`{}`]),u.messages&&o.push([l.message,"function"==typeof n?n(t):n]),u.verbose&&o.push([l.schema,c],[l.parentSchema,i._`${p}${m}`],[r.default.data,a]),d&&o.push([l.propertyName,d])}(t,e,a),o.object(...a)}(t,e,n)}function h({errorPath:t},{instancePath:e}){const n=e?i.str`${t}${(0,o.getErrorPath)(e,o.Type.Str)}`:t;return[r.default.instancePath,(0,i.strConcat)(r.default.instancePath,n)]}function u({keyword:t,it:{errSchemaPath:e}},{schemaPath:n,parentSchema:r}){let s=r?e:i.str`${e}/${t}`;return n&&(s=i.str`${s}${(0,o.getErrorPath)(n,o.Type.Str)}`),[l.schemaPath,s]}},3835:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.resolveSchema=e.getCompilingSchema=e.resolveRef=e.compileSchema=e.SchemaEnv=void 0;const i=n(9029),o=n(3558),r=n(2023),s=n(6939),a=n(4227),l=n(2586);class c{constructor(t){var e;let n;this.refs={},this.dynamicAnchors={},"object"==typeof t.schema&&(n=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=null!==(e=t.baseId)&&void 0!==e?e:(0,s.normalizeId)(null==n?void 0:n[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=null==n?void 0:n.$async,this.refs={}}}function h(t){const e=d.call(this,t);if(e)return e;const n=(0,s.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:a,lines:c}=this.opts.code,{ownProperties:h}=this.opts,u=new i.CodeGen(this.scope,{es5:a,lines:c,ownProperties:h});let p;t.$async&&(p=u.scopeValue("Error",{ref:o.default,code:i._`require("ajv/dist/runtime/validation_error").default`}));const m=u.scopeName("validate");t.validateName=m;const f={gen:u,allErrors:this.opts.allErrors,data:r.default.data,parentData:r.default.parentData,parentDataProperty:r.default.parentDataProperty,dataNames:[r.default.data],dataPathArr:[i.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:u.scopeValue("schema",!0===this.opts.code.source?{ref:t.schema,code:(0,i.stringify)(t.schema)}:{ref:t.schema}),validateName:m,ValidationError:p,schema:t.schema,schemaEnv:t,rootId:n,baseId:t.baseId||n,schemaPath:i.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:i._`""`,opts:this.opts,self:this};let g;try{this._compilations.add(t),(0,l.validateFunctionCode)(f),u.optimize(this.opts.code.optimize);const e=u.toString();g=`${u.scopeRefs(r.default.scope)}return ${e}`,this.opts.code.process&&(g=this.opts.code.process(g,t));const n=new Function(`${r.default.self}`,`${r.default.scope}`,g)(this,this.scope.get());if(this.scope.value(m,{ref:n}),n.errors=null,n.schema=t.schema,n.schemaEnv=t,t.$async&&(n.$async=!0),!0===this.opts.code.source&&(n.source={validateName:m,validateCode:e,scopeValues:u._values}),this.opts.unevaluated){const{props:t,items:e}=f;n.evaluated={props:t instanceof i.Name?void 0:t,items:e instanceof i.Name?void 0:e,dynamicProps:t instanceof i.Name,dynamicItems:e instanceof i.Name},n.source&&(n.source.evaluated=(0,i.stringify)(n.evaluated))}return t.validate=n,t}catch(e){throw delete t.validate,delete t.validateName,g&&this.logger.error("Error compiling schema, function code:",g),e}finally{this._compilations.delete(t)}}function u(t){return(0,s.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:h.call(this,t)}function d(t){for(const i of this._compilations)if(n=t,(e=i).schema===n.schema&&e.root===n.root&&e.baseId===n.baseId)return i;var e,n}function p(t,e){let n;for(;"string"==typeof(n=this.refs[e]);)e=n;return n||this.schemas[e]||m.call(this,t,e)}function m(t,e){const n=this.opts.uriResolver.parse(e),i=(0,s._getFullPath)(this.opts.uriResolver,n);let o=(0,s.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&i===o)return g.call(this,n,t);const r=(0,s.normalizeId)(i),a=this.refs[r]||this.schemas[r];if("string"==typeof a){const e=m.call(this,t,a);if("object"!=typeof(null==e?void 0:e.schema))return;return g.call(this,n,e)}if("object"==typeof(null==a?void 0:a.schema)){if(a.validate||h.call(this,a),r===(0,s.normalizeId)(e)){const{schema:e}=a,{schemaId:n}=this.opts,i=e[n];return i&&(o=(0,s.resolveUrl)(this.opts.uriResolver,o,i)),new c({schema:e,schemaId:n,root:t,baseId:o})}return g.call(this,n,a)}}e.SchemaEnv=c,e.compileSchema=h,e.resolveRef=function(t,e,n){var i;n=(0,s.resolveUrl)(this.opts.uriResolver,e,n);const o=t.refs[n];if(o)return o;let r=p.call(this,t,n);if(void 0===r){const o=null===(i=t.localRefs)||void 0===i?void 0:i[n],{schemaId:s}=this.opts;o&&(r=new c({schema:o,schemaId:s,root:t,baseId:e}))}return void 0!==r?t.refs[n]=u.call(this,r):void 0},e.getCompilingSchema=d,e.resolveSchema=m;const f=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function g(t,{baseId:e,schema:n,root:i}){var o;if("/"!==(null===(o=t.fragment)||void 0===o?void 0:o[0]))return;for(const i of t.fragment.slice(1).split("/")){if("boolean"==typeof n)return;const t=n[(0,a.unescapeFragment)(i)];if(void 0===t)return;const o="object"==typeof(n=t)&&n[this.opts.schemaId];!f.has(i)&&o&&(e=(0,s.resolveUrl)(this.opts.uriResolver,e,o))}let r;if("boolean"!=typeof n&&n.$ref&&!(0,a.schemaHasRulesButRef)(n,this.RULES)){const t=(0,s.resolveUrl)(this.opts.uriResolver,e,n.$ref);r=m.call(this,i,t)}const{schemaId:l}=this.opts;return r=r||new c({schema:n,schemaId:l,root:i,baseId:e}),r.schema!==r.root.schema?r:void 0}},2023:(t,e,n)=>{"use strict";Object.defineProperty(e,"__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")};e.default=o},4551:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(6939);class o extends Error{constructor(t,e,n,o){super(o||`can't resolve reference ${n} from id ${e}`),this.missingRef=(0,i.resolveUrl)(t,e,n),this.missingSchema=(0,i.normalizeId)((0,i.getFullPath)(t,this.missingRef))}}e.default=o},6939:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getSchemaRefs=e.resolveUrl=e.normalizeId=e._getFullPath=e.getFullPath=e.inlineRef=void 0;const i=n(4227),o=n(2017),r=n(7106),s=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);e.inlineRef=function(t,e=!0){return"boolean"==typeof t||(!0===e?!l(t):!!e&&c(t)<=e)};const a=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function l(t){for(const e in t){if(a.has(e))return!0;const n=t[e];if(Array.isArray(n)&&n.some(l))return!0;if("object"==typeof n&&l(n))return!0}return!1}function c(t){let e=0;for(const n in t){if("$ref"===n)return 1/0;if(e++,!s.has(n)&&("object"==typeof t[n]&&(0,i.eachItem)(t[n],(t=>e+=c(t))),e===1/0))return 1/0}return e}function h(t,e="",n){!1!==n&&(e=p(e));const i=t.parse(e);return u(t,i)}function u(t,e){return t.serialize(e).split("#")[0]+"#"}e.getFullPath=h,e._getFullPath=u;const d=/#\/?$/;function p(t){return t?t.replace(d,""):""}e.normalizeId=p,e.resolveUrl=function(t,e,n){return n=p(n),t.resolve(e,n)};const m=/^[a-z_][-a-z0-9._]*$/i;e.getSchemaRefs=function(t,e){if("boolean"==typeof t)return{};const{schemaId:n,uriResolver:i}=this.opts,s=p(t[n]||e),a={"":s},l=h(i,s,!1),c={},u=new Set;return r(t,{allKeys:!0},((t,e,i,o)=>{if(void 0===o)return;const r=l+e;let s=a[o];function h(e){const n=this.opts.uriResolver.resolve;if(e=p(s?n(s,e):e),u.has(e))throw f(e);u.add(e);let i=this.refs[e];return"string"==typeof i&&(i=this.refs[i]),"object"==typeof i?d(t,i.schema,e):e!==p(r)&&("#"===e[0]?(d(t,c[e],e),c[e]=t):this.refs[e]=r),e}function g(t){if("string"==typeof t){if(!m.test(t))throw new Error(`invalid anchor "${t}"`);h.call(this,`#${t}`)}}"string"==typeof t[n]&&(s=h.call(this,t[n])),g.call(this,t.$anchor),g.call(this,t.$dynamicAnchor),a[e]=s})),c;function d(t,e,n){if(void 0!==e&&!o(t,e))throw f(n)}function f(t){return new Error(`reference "${t}" resolves to more than one schema`)}}},396:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getRules=e.isJSONType=void 0;const n=new Set(["string","number","integer","boolean","null","object","array"]);e.isJSONType=function(t){return"string"==typeof t&&n.has(t)},e.getRules=function(){const t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...t,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}},4227:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.checkStrictMode=e.getErrorPath=e.Type=e.useFunc=e.setEvaluated=e.evaluatedPropsToName=e.mergeEvaluated=e.eachItem=e.unescapeJsonPointer=e.escapeJsonPointer=e.escapeFragment=e.unescapeFragment=e.schemaRefOrVal=e.schemaHasRulesButRef=e.schemaHasRules=e.checkUnknownRules=e.alwaysValidSchema=e.toHash=void 0;const i=n(9029),o=n(1520);function r(t,e=t.schema){const{opts:n,self:i}=t;if(!n.strictSchema)return;if("boolean"==typeof e)return;const o=i.RULES.keywords;for(const n in e)o[n]||m(t,`unknown keyword: "${n}"`)}function s(t,e){if("boolean"==typeof t)return!t;for(const n in t)if(e[n])return!0;return!1}function a(t){return"number"==typeof t?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}function l(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}function c({mergeNames:t,mergeToName:e,mergeValues:n,resultToName:o}){return(r,s,a,l)=>{const c=void 0===a?s:a instanceof i.Name?(s instanceof i.Name?t(r,s,a):e(r,s,a),a):s instanceof i.Name?(e(r,a,s),s):n(s,a);return l!==i.Name||c instanceof i.Name?c:o(r,c)}}function h(t,e){if(!0===e)return t.var("props",!0);const n=t.var("props",i._`{}`);return void 0!==e&&u(t,n,e),n}function u(t,e,n){Object.keys(n).forEach((n=>t.assign(i._`${e}${(0,i.getProperty)(n)}`,!0)))}e.toHash=function(t){const e={};for(const n of t)e[n]=!0;return e},e.alwaysValidSchema=function(t,e){return"boolean"==typeof e?e:0===Object.keys(e).length||(r(t,e),!s(e,t.self.RULES.all))},e.checkUnknownRules=r,e.schemaHasRules=s,e.schemaHasRulesButRef=function(t,e){if("boolean"==typeof t)return!t;for(const n in t)if("$ref"!==n&&e.all[n])return!0;return!1},e.schemaRefOrVal=function({topSchemaRef:t,schemaPath:e},n,o,r){if(!r){if("number"==typeof n||"boolean"==typeof n)return n;if("string"==typeof n)return i._`${n}`}return i._`${t}${e}${(0,i.getProperty)(o)}`},e.unescapeFragment=function(t){return l(decodeURIComponent(t))},e.escapeFragment=function(t){return encodeURIComponent(a(t))},e.escapeJsonPointer=a,e.unescapeJsonPointer=l,e.eachItem=function(t,e){if(Array.isArray(t))for(const n of t)e(n);else e(t)},e.mergeEvaluated={props:c({mergeNames:(t,e,n)=>t.if(i._`${n} !== true && ${e} !== undefined`,(()=>{t.if(i._`${e} === true`,(()=>t.assign(n,!0)),(()=>t.assign(n,i._`${n} || {}`).code(i._`Object.assign(${n}, ${e})`)))})),mergeToName:(t,e,n)=>t.if(i._`${n} !== true`,(()=>{!0===e?t.assign(n,!0):(t.assign(n,i._`${n} || {}`),u(t,n,e))})),mergeValues:(t,e)=>!0===t||{...t,...e},resultToName:h}),items:c({mergeNames:(t,e,n)=>t.if(i._`${n} !== true && ${e} !== undefined`,(()=>t.assign(n,i._`${e} === true ? true : ${n} > ${e} ? ${n} : ${e}`))),mergeToName:(t,e,n)=>t.if(i._`${n} !== true`,(()=>t.assign(n,!0===e||i._`${n} > ${e} ? ${n} : ${e}`))),mergeValues:(t,e)=>!0===t||Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})},e.evaluatedPropsToName=h,e.setEvaluated=u;const d={};var p;function m(t,e,n=t.opts.strictSchema){if(n){if(e=`strict mode: ${e}`,!0===n)throw new Error(e);t.self.logger.warn(e)}}e.useFunc=function(t,e){return t.scopeValue("func",{ref:e,code:d[e.code]||(d[e.code]=new o._Code(e.code))})},function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"}(p||(e.Type=p={})),e.getErrorPath=function(t,e,n){if(t instanceof i.Name){const o=e===p.Num;return n?o?i._`"[" + ${t} + "]"`:i._`"['" + ${t} + "']"`:o?i._`"/" + ${t}`:i._`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return n?(0,i.getProperty)(t).toString():"/"+a(t)},e.checkStrictMode=m},7887:(t,e)=>{"use strict";function n(t,e){return e.rules.some((e=>i(t,e)))}function i(t,e){var n;return void 0!==t[e.keyword]||(null===(n=e.definition.implements)||void 0===n?void 0:n.some((e=>void 0!==t[e])))}Object.defineProperty(e,"__esModule",{value:!0}),e.shouldUseRule=e.shouldUseGroup=e.schemaHasRulesForType=void 0,e.schemaHasRulesForType=function({schema:t,self:e},i){const o=e.RULES.types[i];return o&&!0!==o&&n(t,o)},e.shouldUseGroup=n,e.shouldUseRule=i},8727:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;const i=n(8708),o=n(9029),r=n(2023),s={message:"boolean schema is false"};function a(t,e){const{gen:n,data:o}=t,r={gen:n,keyword:"false schema",data:o,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,i.reportError)(r,s,void 0,e)}e.topBoolOrEmptySchema=function(t){const{gen:e,schema:n,validateName:i}=t;!1===n?a(t,!1):"object"==typeof n&&!0===n.$async?e.return(r.default.data):(e.assign(o._`${i}.errors`,null),e.return(!0))},e.boolOrEmptySchema=function(t,e){const{gen:n,schema:i}=t;!1===i?(n.var(e,!1),a(t)):n.var(e,!0)}},208:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.reportTypeError=e.checkDataTypes=e.checkDataType=e.coerceAndCheckDataType=e.getJSONTypes=e.getSchemaTypes=e.DataType=void 0;const i=n(396),o=n(7887),r=n(8708),s=n(9029),a=n(4227);var l;function c(t){const e=Array.isArray(t)?t:t?[t]:[];if(e.every(i.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}!function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"}(l||(e.DataType=l={})),e.getSchemaTypes=function(t){const e=c(t.type);if(e.includes("null")){if(!1===t.nullable)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&void 0!==t.nullable)throw new Error('"nullable" cannot be used without "type"');!0===t.nullable&&e.push("null")}return e},e.getJSONTypes=c,e.coerceAndCheckDataType=function(t,e){const{gen:n,data:i,opts:r}=t,a=function(t,e){return e?t.filter((t=>h.has(t)||"array"===e&&"array"===t)):[]}(e,r.coerceTypes),c=e.length>0&&!(0===a.length&&1===e.length&&(0,o.schemaHasRulesForType)(t,e[0]));if(c){const o=d(e,i,r.strictNumbers,l.Wrong);n.if(o,(()=>{a.length?function(t,e,n){const{gen:i,data:o,opts:r}=t,a=i.let("dataType",s._`typeof ${o}`),l=i.let("coerced",s._`undefined`);"array"===r.coerceTypes&&i.if(s._`${a} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,(()=>i.assign(o,s._`${o}[0]`).assign(a,s._`typeof ${o}`).if(d(e,o,r.strictNumbers),(()=>i.assign(l,o))))),i.if(s._`${l} !== undefined`);for(const t of n)(h.has(t)||"array"===t&&"array"===r.coerceTypes)&&c(t);function c(t){switch(t){case"string":return void i.elseIf(s._`${a} == "number" || ${a} == "boolean"`).assign(l,s._`"" + ${o}`).elseIf(s._`${o} === null`).assign(l,s._`""`);case"number":return void i.elseIf(s._`${a} == "boolean" || ${o} === null
|
|
2
2
|
|| (${a} == "string" && ${o} && ${o} == +${o})`).assign(l,s._`+${o}`);case"integer":return void i.elseIf(s._`${a} === "boolean" || ${o} === null
|
|
3
3
|
|| (${a} === "string" && ${o} && ${o} == +${o} && !(${o} % 1))`).assign(l,s._`+${o}`);case"boolean":return void i.elseIf(s._`${o} === "false" || ${o} === 0 || ${o} === null`).assign(l,!1).elseIf(s._`${o} === "true" || ${o} === 1`).assign(l,!0);case"null":return i.elseIf(s._`${o} === "" || ${o} === 0 || ${o} === false`),void i.assign(l,null);case"array":i.elseIf(s._`${a} === "string" || ${a} === "number"
|
|
4
|
-
|| ${a} === "boolean" || ${o} === null`).assign(l,s._`[${o}]`)}}i.else(),m(t),i.endIf(),i.if(s._`${l} !== undefined`,(()=>{i.assign(o,l),function({gen:t,parentData:e,parentDataProperty:n},i){t.if(s._`${e} !== undefined`,(()=>t.assign(s._`${e}[${n}]`,i)))}(t,l)}))}(t,e,a):m(t)}))}return c};const h=new Set(["string","number","integer","boolean","null"]);function u(t,e,n,i=l.Correct){const o=i===l.Correct?s.operators.EQ:s.operators.NEQ;let r;switch(t){case"null":return s._`${e} ${o} null`;case"array":r=s._`Array.isArray(${e})`;break;case"object":r=s._`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":r=a(s._`!(${e} % 1) && !isNaN(${e})`);break;case"number":r=a();break;default:return s._`typeof ${e} ${o} ${t}`}return i===l.Correct?r:(0,s.not)(r);function a(t=s.nil){return(0,s.and)(s._`typeof ${e} == "number"`,t,n?s._`isFinite(${e})`:s.nil)}}function d(t,e,n,i){if(1===t.length)return u(t[0],e,n,i);let o;const r=(0,a.toHash)(t);if(r.array&&r.object){const t=s._`typeof ${e} != "object"`;o=r.null?t:s._`!${e} || ${t}`,delete r.null,delete r.array,delete r.object}else o=s.nil;r.number&&delete r.integer;for(const t in r)o=(0,s.and)(o,u(t,e,n,i));return o}e.checkDataType=u,e.checkDataTypes=d;const p={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>"string"==typeof t?s._`{type: ${t}}`:s._`{type: ${e}}`};function m(t){const e=function(t){const{gen:e,data:n,schema:i}=t,o=(0,a.schemaRefOrVal)(t,i,"type");return{gen:e,keyword:"type",data:n,schema:i.type,schemaCode:o,schemaValue:o,parentSchema:i,params:{},it:t}}(t);(0,r.reportError)(e,p)}e.reportTypeError=m},7870:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.assignDefaults=void 0;const i=n(9029),o=n(4227);function r(t,e,n){const{gen:r,compositeRule:s,data:a,opts:l}=t;if(void 0===n)return;const c=i._`${a}${(0,i.getProperty)(e)}`;if(s)return void(0,o.checkStrictMode)(t,`default is ignored for: ${c}`);let h=i._`${c} === undefined`;"empty"===l.useDefaults&&(h=i._`${h} || ${c} === null || ${c} === ""`),r.if(h,i._`${c} = ${(0,i.stringify)(n)}`)}e.assignDefaults=function(t,e){const{properties:n,items:i}=t.schema;if("object"===e&&n)for(const e in n)r(t,e,n[e].default);else"array"===e&&Array.isArray(i)&&i.forEach(((e,n)=>r(t,n,e.default)))}},2586:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getData=e.KeywordCxt=e.validateFunctionCode=void 0;const i=n(8727),o=n(208),r=n(7887),s=n(208),a=n(7870),l=n(3673),c=n(4495),h=n(9029),u=n(2023),d=n(6939),p=n(4227),m=n(8708);function f({gen:t,validateName:e,schema:n,schemaEnv:i,opts:o},r){o.code.es5?t.func(e,h._`${u.default.data}, ${u.default.valCxt}`,i.$async,(()=>{t.code(h._`"use strict"; ${g(n,o)}`),function(t,e){t.if(u.default.valCxt,(()=>{t.var(u.default.instancePath,h._`${u.default.valCxt}.${u.default.instancePath}`),t.var(u.default.parentData,h._`${u.default.valCxt}.${u.default.parentData}`),t.var(u.default.parentDataProperty,h._`${u.default.valCxt}.${u.default.parentDataProperty}`),t.var(u.default.rootData,h._`${u.default.valCxt}.${u.default.rootData}`),e.dynamicRef&&t.var(u.default.dynamicAnchors,h._`${u.default.valCxt}.${u.default.dynamicAnchors}`)}),(()=>{t.var(u.default.instancePath,h._`""`),t.var(u.default.parentData,h._`undefined`),t.var(u.default.parentDataProperty,h._`undefined`),t.var(u.default.rootData,u.default.data),e.dynamicRef&&t.var(u.default.dynamicAnchors,h._`{}`)}))}(t,o),t.code(r)})):t.func(e,h._`${u.default.data}, ${function(t){return h._`{${u.default.instancePath}="", ${u.default.parentData}, ${u.default.parentDataProperty}, ${u.default.rootData}=${u.default.data}${t.dynamicRef?h._`, ${u.default.dynamicAnchors}={}`:h.nil}}={}`}(o)}`,i.$async,(()=>t.code(g(n,o)).code(r)))}function g(t,e){const n="object"==typeof t&&t[e.schemaId];return n&&(e.code.source||e.code.process)?h._`/*# sourceURL=${n} */`:h.nil}function y({schema:t,self:e}){if("boolean"==typeof t)return!t;for(const n in t)if(e.RULES.all[n])return!0;return!1}function b(t){return"boolean"!=typeof t.schema}function v(t){(0,p.checkUnknownRules)(t),function(t){const{schema:e,errSchemaPath:n,opts:i,self:o}=t;e.$ref&&i.ignoreKeywordsWithRef&&(0,p.schemaHasRulesButRef)(e,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${n}"`)}(t)}function w(t,e){if(t.opts.jtd)return A(t,[],!1,e);const n=(0,o.getSchemaTypes)(t.schema);A(t,n,!(0,o.coerceAndCheckDataType)(t,n),e)}function C({gen:t,schemaEnv:e,schema:n,errSchemaPath:i,opts:o}){const r=n.$comment;if(!0===o.$comment)t.code(h._`${u.default.self}.logger.log(${r})`);else if("function"==typeof o.$comment){const n=h.str`${i}/$comment`,o=t.scopeValue("root",{ref:e.root});t.code(h._`${u.default.self}.opts.$comment(${r}, ${n}, ${o}.schema)`)}}function A(t,e,n,i){const{gen:o,schema:a,data:l,allErrors:c,opts:d,self:m}=t,{RULES:f}=m;function g(p){(0,r.shouldUseGroup)(a,p)&&(p.type?(o.if((0,s.checkDataType)(p.type,l,d.strictNumbers)),S(t,p),1===e.length&&e[0]===p.type&&n&&(o.else(),(0,s.reportTypeError)(t)),o.endIf()):S(t,p),c||o.if(h._`${u.default.errors} === ${i||0}`))}!a.$ref||!d.ignoreKeywordsWithRef&&(0,p.schemaHasRulesButRef)(a,f)?(d.jtd||function(t,e){!t.schemaEnv.meta&&t.opts.strictTypes&&(function(t,e){e.length&&(t.dataTypes.length?(e.forEach((e=>{x(t.dataTypes,e)||E(t,`type "${e}" not allowed by context "${t.dataTypes.join(",")}"`)})),function(t,e){const n=[];for(const i of t.dataTypes)x(e,i)?n.push(i):e.includes("integer")&&"number"===i&&n.push("integer");t.dataTypes=n}(t,e)):t.dataTypes=e)}(t,e),t.opts.allowUnionTypes||function(t,e){e.length>1&&(2!==e.length||!e.includes("null"))&&E(t,"use allowUnionTypes to allow union type keyword")}(t,e),function(t,e){const n=t.self.RULES.all;for(const i in n){const o=n[i];if("object"==typeof o&&(0,r.shouldUseRule)(t.schema,o)){const{type:n}=o.definition;n.length&&!n.some((t=>{return i=t,(n=e).includes(i)||"number"===i&&n.includes("integer");var n,i}))&&E(t,`missing type "${n.join(",")}" for keyword "${i}"`)}}}(t,t.dataTypes))}(t,e),o.block((()=>{for(const t of f.rules)g(t);g(f.post)}))):o.block((()=>T(t,"$ref",f.all.$ref.definition)))}function S(t,e){const{gen:n,schema:i,opts:{useDefaults:o}}=t;o&&(0,a.assignDefaults)(t,e.type),n.block((()=>{for(const n of e.rules)(0,r.shouldUseRule)(i,n)&&T(t,n.keyword,n.definition,e.type)}))}function x(t,e){return t.includes(e)||"integer"===e&&t.includes("number")}function E(t,e){e+=` at "${t.schemaEnv.baseId+t.errSchemaPath}" (strictTypes)`,(0,p.checkStrictMode)(t,e,t.opts.strictTypes)}e.validateFunctionCode=function(t){b(t)&&(v(t),y(t))?function(t){const{schema:e,opts:n,gen:i}=t;f(t,(()=>{n.$comment&&e.$comment&&C(t),function(t){const{schema:e,opts:n}=t;void 0!==e.default&&n.useDefaults&&n.strictSchema&&(0,p.checkStrictMode)(t,"default is ignored in the schema root")}(t),i.let(u.default.vErrors,null),i.let(u.default.errors,0),n.unevaluated&&function(t){const{gen:e,validateName:n}=t;t.evaluated=e.const("evaluated",h._`${n}.evaluated`),e.if(h._`${t.evaluated}.dynamicProps`,(()=>e.assign(h._`${t.evaluated}.props`,h._`undefined`))),e.if(h._`${t.evaluated}.dynamicItems`,(()=>e.assign(h._`${t.evaluated}.items`,h._`undefined`)))}(t),w(t),function(t){const{gen:e,schemaEnv:n,validateName:i,ValidationError:o,opts:r}=t;n.$async?e.if(h._`${u.default.errors} === 0`,(()=>e.return(u.default.data)),(()=>e.throw(h._`new ${o}(${u.default.vErrors})`))):(e.assign(h._`${i}.errors`,u.default.vErrors),r.unevaluated&&function({gen:t,evaluated:e,props:n,items:i}){n instanceof h.Name&&t.assign(h._`${e}.props`,n),i instanceof h.Name&&t.assign(h._`${e}.items`,i)}(t),e.return(h._`${u.default.errors} === 0`))}(t)}))}(t):f(t,(()=>(0,i.topBoolOrEmptySchema)(t)))};class M{constructor(t,e,n){if((0,l.validateKeywordUsage)(t,e,n),this.gen=t.gen,this.allErrors=t.allErrors,this.keyword=n,this.data=t.data,this.schema=t.schema[n],this.$data=e.$data&&t.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,p.schemaRefOrVal)(t,this.schema,n,this.$data),this.schemaType=e.schemaType,this.parentSchema=t.schema,this.params={},this.it=t,this.def=e,this.$data)this.schemaCode=t.gen.const("vSchema",L(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,l.validSchemaType)(this.schema,e.schemaType,e.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(e.schemaType)}`);("code"in e?e.trackErrors:!1!==e.errors)&&(this.errsCount=t.gen.const("_errs",u.default.errors))}result(t,e,n){this.failResult((0,h.not)(t),e,n)}failResult(t,e,n){this.gen.if(t),n?n():this.error(),e?(this.gen.else(),e(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(t,e){this.failResult((0,h.not)(t),void 0,e)}fail(t){if(void 0===t)return this.error(),void(this.allErrors||this.gen.if(!1));this.gen.if(t),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(t){if(!this.$data)return this.fail(t);const{schemaCode:e}=this;this.fail(h._`${e} !== undefined && (${(0,h.or)(this.invalid$data(),t)})`)}error(t,e,n){if(e)return this.setParams(e),this._error(t,n),void this.setParams({});this._error(t,n)}_error(t,e){(t?m.reportExtraError:m.reportError)(this,this.def.error,e)}$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(t){this.allErrors||this.gen.if(t)}setParams(t,e){e?Object.assign(this.params,t):this.params=t}block$data(t,e,n=h.nil){this.gen.block((()=>{this.check$data(t,n),e()}))}check$data(t=h.nil,e=h.nil){if(!this.$data)return;const{gen:n,schemaCode:i,schemaType:o,def:r}=this;n.if((0,h.or)(h._`${i} === undefined`,e)),t!==h.nil&&n.assign(t,!0),(o.length||r.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==h.nil&&n.assign(t,!1)),n.else()}invalid$data(){const{gen:t,schemaCode:e,schemaType:n,def:i,it:o}=this;return(0,h.or)(function(){if(n.length){if(!(e instanceof h.Name))throw new Error("ajv implementation error");const t=Array.isArray(n)?n:[n];return h._`${(0,s.checkDataTypes)(t,e,o.opts.strictNumbers,s.DataType.Wrong)}`}return h.nil}(),function(){if(i.validateSchema){const n=t.scopeValue("validate$data",{ref:i.validateSchema});return h._`!${n}(${e})`}return h.nil}())}subschema(t,e){const n=(0,c.getSubschema)(this.it,t);(0,c.extendSubschemaData)(n,this.it,t),(0,c.extendSubschemaMode)(n,t);const o={...this.it,...n,items:void 0,props:void 0};return function(t,e){b(t)&&(v(t),y(t))?function(t,e){const{schema:n,gen:i,opts:o}=t;o.$comment&&n.$comment&&C(t),function(t){const e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,d.resolveUrl)(t.opts.uriResolver,t.baseId,e))}(t),function(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}(t);const r=i.const("_errs",u.default.errors);w(t,r),i.var(e,h._`${r} === ${u.default.errors}`)}(t,e):(0,i.boolOrEmptySchema)(t,e)}(o,e),o}mergeEvaluated(t,e){const{it:n,gen:i}=this;n.opts.unevaluated&&(!0!==n.props&&void 0!==t.props&&(n.props=p.mergeEvaluated.props(i,t.props,n.props,e)),!0!==n.items&&void 0!==t.items&&(n.items=p.mergeEvaluated.items(i,t.items,n.items,e)))}mergeValidEvaluated(t,e){const{it:n,gen:i}=this;if(n.opts.unevaluated&&(!0!==n.props||!0!==n.items))return i.if(e,(()=>this.mergeEvaluated(t,h.Name))),!0}}function T(t,e,n,i){const o=new M(t,n,e);"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)}e.KeywordCxt=M;const _=/^\/(?:[^~]|~0|~1)*$/,I=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function L(t,{dataLevel:e,dataNames:n,dataPathArr:i}){let o,r;if(""===t)return u.default.rootData;if("/"===t[0]){if(!_.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);o=t,r=u.default.rootData}else{const s=I.exec(t);if(!s)throw new Error(`Invalid JSON-pointer: ${t}`);const a=+s[1];if(o=s[2],"#"===o){if(a>=e)throw new Error(l("property/index",a));return i[e-a]}if(a>e)throw new Error(l("data",a));if(r=n[e-a],!o)return r}let s=r;const a=o.split("/");for(const t of a)t&&(r=h._`${r}${(0,h.getProperty)((0,p.unescapeJsonPointer)(t))}`,s=h._`${s} && ${r}`);return s;function l(t,n){return`Cannot access ${t} ${n} levels up, current level is ${e}`}}e.getData=L},3673:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.validateKeywordUsage=e.validSchemaType=e.funcKeywordCode=e.macroKeywordCode=void 0;const i=n(9029),o=n(2023),r=n(5765),s=n(8708);function a(t){const{gen:e,data:n,it:o}=t;e.if(o.parentData,(()=>e.assign(n,i._`${o.parentData}[${o.parentDataProperty}]`)))}function l(t,e,n){if(void 0===n)throw new Error(`keyword "${e}" failed to compile`);return t.scopeValue("keyword","function"==typeof n?{ref:n}:{ref:n,code:(0,i.stringify)(n)})}e.macroKeywordCode=function(t,e){const{gen:n,keyword:o,schema:r,parentSchema:s,it:a}=t,c=e.macro.call(a.self,r,s,a),h=l(n,o,c);!1!==a.opts.validateSchema&&a.self.validateSchema(c,!0);const u=n.name("valid");t.subschema({schema:c,schemaPath:i.nil,errSchemaPath:`${a.errSchemaPath}/${o}`,topSchemaRef:h,compositeRule:!0},u),t.pass(u,(()=>t.error(!0)))},e.funcKeywordCode=function(t,e){var n;const{gen:c,keyword:h,schema:u,parentSchema:d,$data:p,it:m}=t;!function({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}(m,e);const f=!p&&e.compile?e.compile.call(m.self,u,d,m):e.validate,g=l(c,h,f),y=c.let("valid");function b(n=(e.async?i._`await `:i.nil)){const s=m.opts.passContext?o.default.this:o.default.self,a=!("compile"in e&&!p||!1===e.schema);c.assign(y,i._`${n}${(0,r.callValidateCode)(t,g,s,a)}`,e.modifying)}function v(t){var n;c.if((0,i.not)(null!==(n=e.valid)&&void 0!==n?n:y),t)}t.block$data(y,(function(){if(!1===e.errors)b(),e.modifying&&a(t),v((()=>t.error()));else{const n=e.async?function(){const t=c.let("ruleErrs",null);return c.try((()=>b(i._`await `)),(e=>c.assign(y,!1).if(i._`${e} instanceof ${m.ValidationError}`,(()=>c.assign(t,i._`${e}.errors`)),(()=>c.throw(e))))),t}():function(){const t=i._`${g}.errors`;return c.assign(t,null),b(i.nil),t}();e.modifying&&a(t),v((()=>function(t,e){const{gen:n}=t;n.if(i._`Array.isArray(${e})`,(()=>{n.assign(o.default.vErrors,i._`${o.default.vErrors} === null ? ${e} : ${o.default.vErrors}.concat(${e})`).assign(o.default.errors,i._`${o.default.vErrors}.length`),(0,s.extendErrors)(t)}),(()=>t.error()))}(t,n)))}})),t.ok(null!==(n=e.valid)&&void 0!==n?n:y)},e.validSchemaType=function(t,e,n=!1){return!e.length||e.some((e=>"array"===e?Array.isArray(t):"object"===e?t&&"object"==typeof t&&!Array.isArray(t):typeof t==e||n&&void 0===t))},e.validateKeywordUsage=function({schema:t,opts:e,self:n,errSchemaPath:i},o,r){if(Array.isArray(o.keyword)?!o.keyword.includes(r):o.keyword!==r)throw new Error("ajv implementation error");const s=o.dependencies;if(null==s?void 0:s.some((e=>!Object.prototype.hasOwnProperty.call(t,e))))throw new Error(`parent schema must have dependencies of ${r}: ${s.join(",")}`);if(o.validateSchema&&!o.validateSchema(t[r])){const t=`keyword "${r}" value is invalid at path "${i}": `+n.errorsText(o.validateSchema.errors);if("log"!==e.validateSchema)throw new Error(t);n.logger.error(t)}}},4495:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.extendSubschemaMode=e.extendSubschemaData=e.getSubschema=void 0;const i=n(9029),o=n(4227);e.getSubschema=function(t,{keyword:e,schemaProp:n,schema:r,schemaPath:s,errSchemaPath:a,topSchemaRef:l}){if(void 0!==e&&void 0!==r)throw new Error('both "keyword" and "schema" passed, only one allowed');if(void 0!==e){const r=t.schema[e];return void 0===n?{schema:r,schemaPath:i._`${t.schemaPath}${(0,i.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:r[n],schemaPath:i._`${t.schemaPath}${(0,i.getProperty)(e)}${(0,i.getProperty)(n)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,o.escapeFragment)(n)}`}}if(void 0!==r){if(void 0===s||void 0===a||void 0===l)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:r,schemaPath:s,topSchemaRef:l,errSchemaPath:a}}throw new Error('either "keyword" or "schema" must be passed')},e.extendSubschemaData=function(t,e,{dataProp:n,dataPropType:r,data:s,dataTypes:a,propertyName:l}){if(void 0!==s&&void 0!==n)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:c}=e;if(void 0!==n){const{errorPath:s,dataPathArr:a,opts:l}=e;h(c.let("data",i._`${e.data}${(0,i.getProperty)(n)}`,!0)),t.errorPath=i.str`${s}${(0,o.getErrorPath)(n,r,l.jsPropertySyntax)}`,t.parentDataProperty=i._`${n}`,t.dataPathArr=[...a,t.parentDataProperty]}function h(n){t.data=n,t.dataLevel=e.dataLevel+1,t.dataTypes=[],e.definedProperties=new Set,t.parentData=e.data,t.dataNames=[...e.dataNames,n]}void 0!==s&&(h(s instanceof i.Name?s:c.let("data",s,!0)),void 0!==l&&(t.propertyName=l)),a&&(t.dataTypes=a)},e.extendSubschemaMode=function(t,{jtdDiscriminator:e,jtdMetadata:n,compositeRule:i,createErrors:o,allErrors:r}){void 0!==i&&(t.compositeRule=i),void 0!==o&&(t.createErrors=o),void 0!==r&&(t.allErrors=r),t.jtdDiscriminator=e,t.jtdMetadata=n}},4042:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var i=n(2586);Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return i.KeywordCxt}});var o=n(9029);Object.defineProperty(e,"_",{enumerable:!0,get:function(){return o._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return o.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return o.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return o.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return o.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return o.CodeGen}});const r=n(3558),s=n(4551),a=n(396),l=n(3835),c=n(9029),h=n(6939),u=n(208),d=n(4227),p=n(3837),m=n(5944),f=(t,e)=>new RegExp(t,e);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."},v={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'};function w(t){var e,n,i,o,r,s,a,l,c,h,u,d,p,g,y,b,v,w,C,A,S,x,E,M,T;const _=t.strict,I=null===(e=t.code)||void 0===e?void 0:e.optimize,L=!0===I||void 0===I?1:I||0,N=null!==(i=null===(n=t.code)||void 0===n?void 0:n.regExp)&&void 0!==i?i:f,P=null!==(o=t.uriResolver)&&void 0!==o?o:m.default;return{strictSchema:null===(s=null!==(r=t.strictSchema)&&void 0!==r?r:_)||void 0===s||s,strictNumbers:null===(l=null!==(a=t.strictNumbers)&&void 0!==a?a:_)||void 0===l||l,strictTypes:null!==(h=null!==(c=t.strictTypes)&&void 0!==c?c:_)&&void 0!==h?h:"log",strictTuples:null!==(d=null!==(u=t.strictTuples)&&void 0!==u?u:_)&&void 0!==d?d:"log",strictRequired:null!==(g=null!==(p=t.strictRequired)&&void 0!==p?p:_)&&void 0!==g&&g,code:t.code?{...t.code,optimize:L,regExp:N}:{optimize:L,regExp:N},loopRequired:null!==(y=t.loopRequired)&&void 0!==y?y:200,loopEnum:null!==(b=t.loopEnum)&&void 0!==b?b:200,meta:null===(v=t.meta)||void 0===v||v,messages:null===(w=t.messages)||void 0===w||w,inlineRefs:null===(C=t.inlineRefs)||void 0===C||C,schemaId:null!==(A=t.schemaId)&&void 0!==A?A:"$id",addUsedSchema:null===(S=t.addUsedSchema)||void 0===S||S,validateSchema:null===(x=t.validateSchema)||void 0===x||x,validateFormats:null===(E=t.validateFormats)||void 0===E||E,unicodeRegExp:null===(M=t.unicodeRegExp)||void 0===M||M,int32range:null===(T=t.int32range)||void 0===T||T,uriResolver:P}}class C{constructor(t={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,t=this.opts={...t,...w(t)};const{es5:e,lines:n}=this.opts.code;this.scope=new c.ValueScope({scope:{},prefixes:y,es5:e,lines:n}),this.logger=function(t){if(!1===t)return _;if(void 0===t)return console;if(t.log&&t.warn&&t.error)return t;throw new Error("logger must implement log, warn and error methods")}(t.logger);const i=t.validateFormats;t.validateFormats=!1,this.RULES=(0,a.getRules)(),A.call(this,b,t,"NOT SUPPORTED"),A.call(this,v,t,"DEPRECATED","warn"),this._metaOpts=T.call(this),t.formats&&E.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),t.keywords&&M.call(this,t.keywords),"object"==typeof t.meta&&this.addMetaSchema(t.meta),x.call(this),t.validateFormats=i}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:t,meta:e,schemaId:n}=this.opts;let i=p;"id"===n&&(i={...p},i.id=i.$id,delete i.$id),e&&t&&this.addMetaSchema(i,i[n],!1)}defaultMeta(){const{meta:t,schemaId:e}=this.opts;return this.opts.defaultMeta="object"==typeof t?t[e]||t:void 0}validate(t,e){let n;if("string"==typeof t){if(n=this.getSchema(t),!n)throw new Error(`no schema with key or ref "${t}"`)}else n=this.compile(t);const i=n(e);return"$async"in n||(this.errors=n.errors),i}compile(t,e){const n=this._addSchema(t,e);return n.validate||this._compileSchemaEnv(n)}compileAsync(t,e){if("function"!=typeof this.opts.loadSchema)throw new Error("options.loadSchema should be a function");const{loadSchema:n}=this.opts;return i.call(this,t,e);async function i(t,e){await o.call(this,t.$schema);const n=this._addSchema(t,e);return n.validate||r.call(this,n)}async function o(t){t&&!this.getSchema(t)&&await i.call(this,{$ref:t},!0)}async function r(t){try{return this._compileSchemaEnv(t)}catch(e){if(!(e instanceof s.default))throw e;return a.call(this,e),await l.call(this,e.missingSchema),r.call(this,t)}}function a({missingSchema:t,missingRef:e}){if(this.refs[t])throw new Error(`AnySchema ${t} is loaded but ${e} cannot be resolved`)}async function l(t){const n=await c.call(this,t);this.refs[t]||await o.call(this,n.$schema),this.refs[t]||this.addSchema(n,t,e)}async function c(t){const e=this._loading[t];if(e)return e;try{return await(this._loading[t]=n(t))}finally{delete this._loading[t]}}}addSchema(t,e,n,i=this.opts.validateSchema){if(Array.isArray(t)){for(const e of t)this.addSchema(e,void 0,n,i);return this}let o;if("object"==typeof t){const{schemaId:e}=this.opts;if(o=t[e],void 0!==o&&"string"!=typeof o)throw new Error(`schema ${e} must be string`)}return e=(0,h.normalizeId)(e||o),this._checkUnique(e),this.schemas[e]=this._addSchema(t,n,e,i,!0),this}addMetaSchema(t,e,n=this.opts.validateSchema){return this.addSchema(t,e,!0,n),this}validateSchema(t,e){if("boolean"==typeof t)return!0;let n;if(n=t.$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,t);if(!i&&e){const t="schema is invalid: "+this.errorsText();if("log"!==this.opts.validateSchema)throw new Error(t);this.logger.error(t)}return i}getSchema(t){let e;for(;"string"==typeof(e=S.call(this,t));)t=e;if(void 0===e){const{schemaId:n}=this.opts,i=new l.SchemaEnv({schema:{},schemaId:n});if(e=l.resolveSchema.call(this,i,t),!e)return;this.refs[t]=e}return e.validate||this._compileSchemaEnv(e)}removeSchema(t){if(t instanceof RegExp)return this._removeAllSchemas(this.schemas,t),this._removeAllSchemas(this.refs,t),this;switch(typeof t){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{const e=S.call(this,t);return"object"==typeof e&&this._cache.delete(e.schema),delete this.schemas[t],delete this.refs[t],this}case"object":{const e=t;this._cache.delete(e);let n=t[this.opts.schemaId];return n&&(n=(0,h.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(t){for(const e of t)this.addKeyword(e);return this}addKeyword(t,e){let n;if("string"==typeof t)n=t,"object"==typeof e&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),e.keyword=n);else{if("object"!=typeof t||void 0!==e)throw new Error("invalid addKeywords parameters");if(n=(e=t).keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}if(L.call(this,n,e),!e)return(0,d.eachItem)(n,(t=>N.call(this,t))),this;$.call(this,e);const i={...e,type:(0,u.getJSONTypes)(e.type),schemaType:(0,u.getJSONTypes)(e.schemaType)};return(0,d.eachItem)(n,0===i.type.length?t=>N.call(this,t,i):t=>i.type.forEach((e=>N.call(this,t,i,e)))),this}getKeyword(t){const e=this.RULES.all[t];return"object"==typeof e?e.definition:!!e}removeKeyword(t){const{RULES:e}=this;delete e.keywords[t],delete e.all[t];for(const n of e.rules){const e=n.rules.findIndex((e=>e.keyword===t));e>=0&&n.rules.splice(e,1)}return this}addFormat(t,e){return"string"==typeof e&&(e=new RegExp(e)),this.formats[t]=e,this}errorsText(t=this.errors,{separator:e=", ",dataVar:n="data"}={}){return t&&0!==t.length?t.map((t=>`${n}${t.instancePath} ${t.message}`)).reduce(((t,n)=>t+e+n)):"No errors"}$dataMetaSchema(t,e){const n=this.RULES.all;t=JSON.parse(JSON.stringify(t));for(const i of e){const e=i.split("/").slice(1);let o=t;for(const t of e)o=o[t];for(const t in n){const e=n[t];if("object"!=typeof e)continue;const{$data:i}=e.definition,r=o[t];i&&r&&(o[t]=k(r))}}return t}_removeAllSchemas(t,e){for(const n in t){const i=t[n];e&&!e.test(n)||("string"==typeof i?delete t[n]:i&&!i.meta&&(this._cache.delete(i.schema),delete t[n]))}}_addSchema(t,e,n,i=this.opts.validateSchema,o=this.opts.addUsedSchema){let r;const{schemaId:s}=this.opts;if("object"==typeof t)r=t[s];else{if(this.opts.jtd)throw new Error("schema must be object");if("boolean"!=typeof t)throw new Error("schema must be object or boolean")}let a=this._cache.get(t);if(void 0!==a)return a;n=(0,h.normalizeId)(r||n);const c=h.getSchemaRefs.call(this,t,n);return a=new l.SchemaEnv({schema:t,schemaId:s,meta:e,baseId:n,localRefs:c}),this._cache.set(a.schema,a),o&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=a),i&&this.validateSchema(t,!0),a}_checkUnique(t){if(this.schemas[t]||this.refs[t])throw new Error(`schema with key or id "${t}" already exists`)}_compileSchemaEnv(t){if(t.meta?this._compileMetaSchema(t):l.compileSchema.call(this,t),!t.validate)throw new Error("ajv implementation error");return t.validate}_compileMetaSchema(t){const e=this.opts;this.opts=this._metaOpts;try{l.compileSchema.call(this,t)}finally{this.opts=e}}}function A(t,e,n,i="error"){for(const o in t){const r=o;r in e&&this.logger[i](`${n}: option ${o}. ${t[r]}`)}}function S(t){return t=(0,h.normalizeId)(t),this.schemas[t]||this.refs[t]}function x(){const t=this.opts.schemas;if(t)if(Array.isArray(t))this.addSchema(t);else for(const e in t)this.addSchema(t[e],e)}function E(){for(const t in this.opts.formats){const e=this.opts.formats[t];e&&this.addFormat(t,e)}}function M(t){if(Array.isArray(t))this.addVocabulary(t);else{this.logger.warn("keywords option as map is deprecated, pass array");for(const e in t){const n=t[e];n.keyword||(n.keyword=e),this.addKeyword(n)}}}function T(){const t={...this.opts};for(const e of g)delete t[e];return t}C.ValidationError=r.default,C.MissingRefError=s.default,e.default=C;const _={log(){},warn(){},error(){}},I=/^[a-z_$][a-z0-9_$:-]*$/i;function L(t,e){const{RULES:n}=this;if((0,d.eachItem)(t,(t=>{if(n.keywords[t])throw new Error(`Keyword ${t} is already defined`);if(!I.test(t))throw new Error(`Keyword ${t} has invalid name`)})),e&&e.$data&&!("code"in e)&&!("validate"in e))throw new Error('$data keyword must have "code" or "validate" function')}function N(t,e,n){var i;const o=null==e?void 0:e.post;if(n&&o)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:r}=this;let s=o?r.post:r.rules.find((({type:t})=>t===n));if(s||(s={type:n,rules:[]},r.rules.push(s)),r.keywords[t]=!0,!e)return;const a={keyword:t,definition:{...e,type:(0,u.getJSONTypes)(e.type),schemaType:(0,u.getJSONTypes)(e.schemaType)}};e.before?P.call(this,s,a,e.before):s.rules.push(a),r.all[t]=a,null===(i=e.implements)||void 0===i||i.forEach((t=>this.addKeyword(t)))}function P(t,e,n){const i=t.rules.findIndex((t=>t.keyword===n));i>=0?t.rules.splice(i,0,e):(t.rules.push(e),this.logger.warn(`rule ${n} is not defined`))}function $(t){let{metaSchema:e}=t;void 0!==e&&(t.$data&&this.opts.$data&&(e=k(e)),t.validateSchema=this.compile(e,!0))}const R={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function k(t){return{anyOf:[t,R]}}},9572:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(1678),o=n(7216),r=n(9547),s=n(8226),a=n(518),l=n(4588),c=n(5707),h=n(7082),u=["/properties"];e.default=function(t){return[i,o,r,s,a,e(this,l),c,e(this,h)].forEach((t=>this.addMetaSchema(t,void 0,!1))),this;function e(e,n){return t?e.$dataMetaSchema(n,u):n}}},6250:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(2017);i.code='require("ajv/dist/runtime/equal").default',e.default=i},3853:(t,e)=>{"use strict";function n(t){const e=t.length;let n,i=0,o=0;for(;o<e;)i++,n=t.charCodeAt(o++),n>=55296&&n<=56319&&o<e&&(n=t.charCodeAt(o),56320==(64512&n)&&o++);return i}Object.defineProperty(e,"__esModule",{value:!0}),e.default=n,n.code='require("ajv/dist/runtime/ucs2length").default'},5944:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(8343);i.code='require("ajv/dist/runtime/uri").default',e.default=i},3558:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});class n extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}}e.default=n},5457:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.validateAdditionalItems=void 0;const i=n(9029),o=n(4227),r={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:{message:({params:{len:t}})=>i.str`must NOT have more than ${t} items`,params:({params:{len:t}})=>i._`{limit: ${t}}`},code(t){const{parentSchema:e,it:n}=t,{items:i}=e;Array.isArray(i)?s(t,i):(0,o.checkStrictMode)(n,'"additionalItems" is ignored when "items" is not an array of schemas')}};function s(t,e){const{gen:n,schema:r,data:s,keyword:a,it:l}=t;l.items=!0;const c=n.const("len",i._`${s}.length`);if(!1===r)t.setParams({len:e.length}),t.pass(i._`${c} <= ${e.length}`);else if("object"==typeof r&&!(0,o.alwaysValidSchema)(l,r)){const r=n.var("valid",i._`${c} <= ${e.length}`);n.if((0,i.not)(r),(()=>function(r){n.forRange("i",e.length,c,(e=>{t.subschema({keyword:a,dataProp:e,dataPropType:o.Type.Num},r),l.allErrors||n.if((0,i.not)(r),(()=>n.break()))}))}(r))),t.ok(r)}}e.validateAdditionalItems=s,e.default=r},8660:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(5765),o=n(9029),r=n(2023),s=n(4227),a={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:{message:"must NOT have additional properties",params:({params:t})=>o._`{additionalProperty: ${t.additionalProperty}}`},code(t){const{gen:e,schema:n,parentSchema:a,data:l,errsCount:c,it:h}=t;if(!c)throw new Error("ajv implementation error");const{allErrors:u,opts:d}=h;if(h.props=!0,"all"!==d.removeAdditional&&(0,s.alwaysValidSchema)(h,n))return;const p=(0,i.allSchemaProperties)(a.properties),m=(0,i.allSchemaProperties)(a.patternProperties);function f(t){e.code(o._`delete ${l}[${t}]`)}function g(i){if("all"===d.removeAdditional||d.removeAdditional&&!1===n)f(i);else{if(!1===n)return t.setParams({additionalProperty:i}),t.error(),void(u||e.break());if("object"==typeof n&&!(0,s.alwaysValidSchema)(h,n)){const n=e.name("valid");"failing"===d.removeAdditional?(y(i,n,!1),e.if((0,o.not)(n),(()=>{t.reset(),f(i)}))):(y(i,n),u||e.if((0,o.not)(n),(()=>e.break())))}}}function y(e,n,i){const o={keyword:"additionalProperties",dataProp:e,dataPropType:s.Type.Str};!1===i&&Object.assign(o,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(o,n)}e.forIn("key",l,(n=>{p.length||m.length?e.if(function(n){let r;if(p.length>8){const t=(0,s.schemaRefOrVal)(h,a.properties,"properties");r=(0,i.isOwnProperty)(e,t,n)}else r=p.length?(0,o.or)(...p.map((t=>o._`${n} === ${t}`))):o.nil;return m.length&&(r=(0,o.or)(r,...m.map((e=>o._`${(0,i.usePattern)(t,e)}.test(${n})`)))),(0,o.not)(r)}(n),(()=>g(n))):g(n)})),t.ok(o._`${c} === ${r.default.errors}`)}};e.default=a},5844:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(4227),o={keyword:"allOf",schemaType:"array",code(t){const{gen:e,schema:n,it:o}=t;if(!Array.isArray(n))throw new Error("ajv implementation error");const r=e.name("valid");n.forEach(((e,n)=>{if((0,i.alwaysValidSchema)(o,e))return;const s=t.subschema({keyword:"allOf",schemaProp:n},r);t.ok(r),t.mergeEvaluated(s)}))}};e.default=o},6505:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:n(5765).validateUnion,error:{message:"must match a schema in anyOf"}};e.default=i},2661:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(9029),o=n(4227),r={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:{message:({params:{min:t,max:e}})=>void 0===e?i.str`must contain at least ${t} valid item(s)`:i.str`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>void 0===e?i._`{minContains: ${t}}`:i._`{minContains: ${t}, maxContains: ${e}}`},code(t){const{gen:e,schema:n,parentSchema:r,data:s,it:a}=t;let l,c;const{minContains:h,maxContains:u}=r;a.opts.next?(l=void 0===h?1:h,c=u):l=1;const d=e.const("len",i._`${s}.length`);if(t.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 t.fail();if((0,o.alwaysValidSchema)(a,n)){let e=i._`${d} >= ${l}`;return void 0!==c&&(e=i._`${e} && ${d} <= ${c}`),void t.pass(e)}a.items=!0;const p=e.name("valid");function m(){const t=e.name("_valid"),n=e.let("count",0);f(t,(()=>e.if(t,(()=>function(t){e.code(i._`${t}++`),void 0===c?e.if(i._`${t} >= ${l}`,(()=>e.assign(p,!0).break())):(e.if(i._`${t} > ${c}`,(()=>e.assign(p,!1).break())),1===l?e.assign(p,!0):e.if(i._`${t} >= ${l}`,(()=>e.assign(p,!0))))}(n)))))}function f(n,i){e.forRange("i",0,d,(e=>{t.subschema({keyword:"contains",dataProp:e,dataPropType:o.Type.Num,compositeRule:!0},n),i()}))}void 0===c&&1===l?f(p,(()=>e.if(p,(()=>e.break())))):0===l?(e.let(p,!0),void 0!==c&&e.if(i._`${s}.length > 0`,m)):(e.let(p,!1),m()),t.result(p,(()=>t.reset()))}};e.default=r},3025:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;const i=n(9029),o=n(4227),r=n(5765);e.error={message:({params:{property:t,depsCount:e,deps:n}})=>{const o=1===e?"property":"properties";return i.str`must have ${o} ${n} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:n,missingProperty:o}})=>i._`{property: ${t},
|
|
4
|
+
|| ${a} === "boolean" || ${o} === null`).assign(l,s._`[${o}]`)}}i.else(),m(t),i.endIf(),i.if(s._`${l} !== undefined`,(()=>{i.assign(o,l),function({gen:t,parentData:e,parentDataProperty:n},i){t.if(s._`${e} !== undefined`,(()=>t.assign(s._`${e}[${n}]`,i)))}(t,l)}))}(t,e,a):m(t)}))}return c};const h=new Set(["string","number","integer","boolean","null"]);function u(t,e,n,i=l.Correct){const o=i===l.Correct?s.operators.EQ:s.operators.NEQ;let r;switch(t){case"null":return s._`${e} ${o} null`;case"array":r=s._`Array.isArray(${e})`;break;case"object":r=s._`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":r=a(s._`!(${e} % 1) && !isNaN(${e})`);break;case"number":r=a();break;default:return s._`typeof ${e} ${o} ${t}`}return i===l.Correct?r:(0,s.not)(r);function a(t=s.nil){return(0,s.and)(s._`typeof ${e} == "number"`,t,n?s._`isFinite(${e})`:s.nil)}}function d(t,e,n,i){if(1===t.length)return u(t[0],e,n,i);let o;const r=(0,a.toHash)(t);if(r.array&&r.object){const t=s._`typeof ${e} != "object"`;o=r.null?t:s._`!${e} || ${t}`,delete r.null,delete r.array,delete r.object}else o=s.nil;r.number&&delete r.integer;for(const t in r)o=(0,s.and)(o,u(t,e,n,i));return o}e.checkDataType=u,e.checkDataTypes=d;const p={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>"string"==typeof t?s._`{type: ${t}}`:s._`{type: ${e}}`};function m(t){const e=function(t){const{gen:e,data:n,schema:i}=t,o=(0,a.schemaRefOrVal)(t,i,"type");return{gen:e,keyword:"type",data:n,schema:i.type,schemaCode:o,schemaValue:o,parentSchema:i,params:{},it:t}}(t);(0,r.reportError)(e,p)}e.reportTypeError=m},7870:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.assignDefaults=void 0;const i=n(9029),o=n(4227);function r(t,e,n){const{gen:r,compositeRule:s,data:a,opts:l}=t;if(void 0===n)return;const c=i._`${a}${(0,i.getProperty)(e)}`;if(s)return void(0,o.checkStrictMode)(t,`default is ignored for: ${c}`);let h=i._`${c} === undefined`;"empty"===l.useDefaults&&(h=i._`${h} || ${c} === null || ${c} === ""`),r.if(h,i._`${c} = ${(0,i.stringify)(n)}`)}e.assignDefaults=function(t,e){const{properties:n,items:i}=t.schema;if("object"===e&&n)for(const e in n)r(t,e,n[e].default);else"array"===e&&Array.isArray(i)&&i.forEach(((e,n)=>r(t,n,e.default)))}},2586:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getData=e.KeywordCxt=e.validateFunctionCode=void 0;const i=n(8727),o=n(208),r=n(7887),s=n(208),a=n(7870),l=n(3673),c=n(4495),h=n(9029),u=n(2023),d=n(6939),p=n(4227),m=n(8708);function f({gen:t,validateName:e,schema:n,schemaEnv:i,opts:o},r){o.code.es5?t.func(e,h._`${u.default.data}, ${u.default.valCxt}`,i.$async,(()=>{t.code(h._`"use strict"; ${g(n,o)}`),function(t,e){t.if(u.default.valCxt,(()=>{t.var(u.default.instancePath,h._`${u.default.valCxt}.${u.default.instancePath}`),t.var(u.default.parentData,h._`${u.default.valCxt}.${u.default.parentData}`),t.var(u.default.parentDataProperty,h._`${u.default.valCxt}.${u.default.parentDataProperty}`),t.var(u.default.rootData,h._`${u.default.valCxt}.${u.default.rootData}`),e.dynamicRef&&t.var(u.default.dynamicAnchors,h._`${u.default.valCxt}.${u.default.dynamicAnchors}`)}),(()=>{t.var(u.default.instancePath,h._`""`),t.var(u.default.parentData,h._`undefined`),t.var(u.default.parentDataProperty,h._`undefined`),t.var(u.default.rootData,u.default.data),e.dynamicRef&&t.var(u.default.dynamicAnchors,h._`{}`)}))}(t,o),t.code(r)})):t.func(e,h._`${u.default.data}, ${function(t){return h._`{${u.default.instancePath}="", ${u.default.parentData}, ${u.default.parentDataProperty}, ${u.default.rootData}=${u.default.data}${t.dynamicRef?h._`, ${u.default.dynamicAnchors}={}`:h.nil}}={}`}(o)}`,i.$async,(()=>t.code(g(n,o)).code(r)))}function g(t,e){const n="object"==typeof t&&t[e.schemaId];return n&&(e.code.source||e.code.process)?h._`/*# sourceURL=${n} */`:h.nil}function y({schema:t,self:e}){if("boolean"==typeof t)return!t;for(const n in t)if(e.RULES.all[n])return!0;return!1}function b(t){return"boolean"!=typeof t.schema}function v(t){(0,p.checkUnknownRules)(t),function(t){const{schema:e,errSchemaPath:n,opts:i,self:o}=t;e.$ref&&i.ignoreKeywordsWithRef&&(0,p.schemaHasRulesButRef)(e,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${n}"`)}(t)}function w(t,e){if(t.opts.jtd)return A(t,[],!1,e);const n=(0,o.getSchemaTypes)(t.schema);A(t,n,!(0,o.coerceAndCheckDataType)(t,n),e)}function C({gen:t,schemaEnv:e,schema:n,errSchemaPath:i,opts:o}){const r=n.$comment;if(!0===o.$comment)t.code(h._`${u.default.self}.logger.log(${r})`);else if("function"==typeof o.$comment){const n=h.str`${i}/$comment`,o=t.scopeValue("root",{ref:e.root});t.code(h._`${u.default.self}.opts.$comment(${r}, ${n}, ${o}.schema)`)}}function A(t,e,n,i){const{gen:o,schema:a,data:l,allErrors:c,opts:d,self:m}=t,{RULES:f}=m;function g(p){(0,r.shouldUseGroup)(a,p)&&(p.type?(o.if((0,s.checkDataType)(p.type,l,d.strictNumbers)),S(t,p),1===e.length&&e[0]===p.type&&n&&(o.else(),(0,s.reportTypeError)(t)),o.endIf()):S(t,p),c||o.if(h._`${u.default.errors} === ${i||0}`))}!a.$ref||!d.ignoreKeywordsWithRef&&(0,p.schemaHasRulesButRef)(a,f)?(d.jtd||function(t,e){!t.schemaEnv.meta&&t.opts.strictTypes&&(function(t,e){e.length&&(t.dataTypes.length?(e.forEach((e=>{x(t.dataTypes,e)||E(t,`type "${e}" not allowed by context "${t.dataTypes.join(",")}"`)})),function(t,e){const n=[];for(const i of t.dataTypes)x(e,i)?n.push(i):e.includes("integer")&&"number"===i&&n.push("integer");t.dataTypes=n}(t,e)):t.dataTypes=e)}(t,e),t.opts.allowUnionTypes||function(t,e){e.length>1&&(2!==e.length||!e.includes("null"))&&E(t,"use allowUnionTypes to allow union type keyword")}(t,e),function(t,e){const n=t.self.RULES.all;for(const i in n){const o=n[i];if("object"==typeof o&&(0,r.shouldUseRule)(t.schema,o)){const{type:n}=o.definition;n.length&&!n.some((t=>{return i=t,(n=e).includes(i)||"number"===i&&n.includes("integer");var n,i}))&&E(t,`missing type "${n.join(",")}" for keyword "${i}"`)}}}(t,t.dataTypes))}(t,e),o.block((()=>{for(const t of f.rules)g(t);g(f.post)}))):o.block((()=>M(t,"$ref",f.all.$ref.definition)))}function S(t,e){const{gen:n,schema:i,opts:{useDefaults:o}}=t;o&&(0,a.assignDefaults)(t,e.type),n.block((()=>{for(const n of e.rules)(0,r.shouldUseRule)(i,n)&&M(t,n.keyword,n.definition,e.type)}))}function x(t,e){return t.includes(e)||"integer"===e&&t.includes("number")}function E(t,e){e+=` at "${t.schemaEnv.baseId+t.errSchemaPath}" (strictTypes)`,(0,p.checkStrictMode)(t,e,t.opts.strictTypes)}e.validateFunctionCode=function(t){b(t)&&(v(t),y(t))?function(t){const{schema:e,opts:n,gen:i}=t;f(t,(()=>{n.$comment&&e.$comment&&C(t),function(t){const{schema:e,opts:n}=t;void 0!==e.default&&n.useDefaults&&n.strictSchema&&(0,p.checkStrictMode)(t,"default is ignored in the schema root")}(t),i.let(u.default.vErrors,null),i.let(u.default.errors,0),n.unevaluated&&function(t){const{gen:e,validateName:n}=t;t.evaluated=e.const("evaluated",h._`${n}.evaluated`),e.if(h._`${t.evaluated}.dynamicProps`,(()=>e.assign(h._`${t.evaluated}.props`,h._`undefined`))),e.if(h._`${t.evaluated}.dynamicItems`,(()=>e.assign(h._`${t.evaluated}.items`,h._`undefined`)))}(t),w(t),function(t){const{gen:e,schemaEnv:n,validateName:i,ValidationError:o,opts:r}=t;n.$async?e.if(h._`${u.default.errors} === 0`,(()=>e.return(u.default.data)),(()=>e.throw(h._`new ${o}(${u.default.vErrors})`))):(e.assign(h._`${i}.errors`,u.default.vErrors),r.unevaluated&&function({gen:t,evaluated:e,props:n,items:i}){n instanceof h.Name&&t.assign(h._`${e}.props`,n),i instanceof h.Name&&t.assign(h._`${e}.items`,i)}(t),e.return(h._`${u.default.errors} === 0`))}(t)}))}(t):f(t,(()=>(0,i.topBoolOrEmptySchema)(t)))};class T{constructor(t,e,n){if((0,l.validateKeywordUsage)(t,e,n),this.gen=t.gen,this.allErrors=t.allErrors,this.keyword=n,this.data=t.data,this.schema=t.schema[n],this.$data=e.$data&&t.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,p.schemaRefOrVal)(t,this.schema,n,this.$data),this.schemaType=e.schemaType,this.parentSchema=t.schema,this.params={},this.it=t,this.def=e,this.$data)this.schemaCode=t.gen.const("vSchema",L(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,l.validSchemaType)(this.schema,e.schemaType,e.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(e.schemaType)}`);("code"in e?e.trackErrors:!1!==e.errors)&&(this.errsCount=t.gen.const("_errs",u.default.errors))}result(t,e,n){this.failResult((0,h.not)(t),e,n)}failResult(t,e,n){this.gen.if(t),n?n():this.error(),e?(this.gen.else(),e(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(t,e){this.failResult((0,h.not)(t),void 0,e)}fail(t){if(void 0===t)return this.error(),void(this.allErrors||this.gen.if(!1));this.gen.if(t),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(t){if(!this.$data)return this.fail(t);const{schemaCode:e}=this;this.fail(h._`${e} !== undefined && (${(0,h.or)(this.invalid$data(),t)})`)}error(t,e,n){if(e)return this.setParams(e),this._error(t,n),void this.setParams({});this._error(t,n)}_error(t,e){(t?m.reportExtraError:m.reportError)(this,this.def.error,e)}$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(t){this.allErrors||this.gen.if(t)}setParams(t,e){e?Object.assign(this.params,t):this.params=t}block$data(t,e,n=h.nil){this.gen.block((()=>{this.check$data(t,n),e()}))}check$data(t=h.nil,e=h.nil){if(!this.$data)return;const{gen:n,schemaCode:i,schemaType:o,def:r}=this;n.if((0,h.or)(h._`${i} === undefined`,e)),t!==h.nil&&n.assign(t,!0),(o.length||r.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==h.nil&&n.assign(t,!1)),n.else()}invalid$data(){const{gen:t,schemaCode:e,schemaType:n,def:i,it:o}=this;return(0,h.or)(function(){if(n.length){if(!(e instanceof h.Name))throw new Error("ajv implementation error");const t=Array.isArray(n)?n:[n];return h._`${(0,s.checkDataTypes)(t,e,o.opts.strictNumbers,s.DataType.Wrong)}`}return h.nil}(),function(){if(i.validateSchema){const n=t.scopeValue("validate$data",{ref:i.validateSchema});return h._`!${n}(${e})`}return h.nil}())}subschema(t,e){const n=(0,c.getSubschema)(this.it,t);(0,c.extendSubschemaData)(n,this.it,t),(0,c.extendSubschemaMode)(n,t);const o={...this.it,...n,items:void 0,props:void 0};return function(t,e){b(t)&&(v(t),y(t))?function(t,e){const{schema:n,gen:i,opts:o}=t;o.$comment&&n.$comment&&C(t),function(t){const e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,d.resolveUrl)(t.opts.uriResolver,t.baseId,e))}(t),function(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}(t);const r=i.const("_errs",u.default.errors);w(t,r),i.var(e,h._`${r} === ${u.default.errors}`)}(t,e):(0,i.boolOrEmptySchema)(t,e)}(o,e),o}mergeEvaluated(t,e){const{it:n,gen:i}=this;n.opts.unevaluated&&(!0!==n.props&&void 0!==t.props&&(n.props=p.mergeEvaluated.props(i,t.props,n.props,e)),!0!==n.items&&void 0!==t.items&&(n.items=p.mergeEvaluated.items(i,t.items,n.items,e)))}mergeValidEvaluated(t,e){const{it:n,gen:i}=this;if(n.opts.unevaluated&&(!0!==n.props||!0!==n.items))return i.if(e,(()=>this.mergeEvaluated(t,h.Name))),!0}}function M(t,e,n,i){const o=new T(t,n,e);"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)}e.KeywordCxt=T;const _=/^\/(?:[^~]|~0|~1)*$/,I=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function L(t,{dataLevel:e,dataNames:n,dataPathArr:i}){let o,r;if(""===t)return u.default.rootData;if("/"===t[0]){if(!_.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);o=t,r=u.default.rootData}else{const s=I.exec(t);if(!s)throw new Error(`Invalid JSON-pointer: ${t}`);const a=+s[1];if(o=s[2],"#"===o){if(a>=e)throw new Error(l("property/index",a));return i[e-a]}if(a>e)throw new Error(l("data",a));if(r=n[e-a],!o)return r}let s=r;const a=o.split("/");for(const t of a)t&&(r=h._`${r}${(0,h.getProperty)((0,p.unescapeJsonPointer)(t))}`,s=h._`${s} && ${r}`);return s;function l(t,n){return`Cannot access ${t} ${n} levels up, current level is ${e}`}}e.getData=L},3673:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.validateKeywordUsage=e.validSchemaType=e.funcKeywordCode=e.macroKeywordCode=void 0;const i=n(9029),o=n(2023),r=n(5765),s=n(8708);function a(t){const{gen:e,data:n,it:o}=t;e.if(o.parentData,(()=>e.assign(n,i._`${o.parentData}[${o.parentDataProperty}]`)))}function l(t,e,n){if(void 0===n)throw new Error(`keyword "${e}" failed to compile`);return t.scopeValue("keyword","function"==typeof n?{ref:n}:{ref:n,code:(0,i.stringify)(n)})}e.macroKeywordCode=function(t,e){const{gen:n,keyword:o,schema:r,parentSchema:s,it:a}=t,c=e.macro.call(a.self,r,s,a),h=l(n,o,c);!1!==a.opts.validateSchema&&a.self.validateSchema(c,!0);const u=n.name("valid");t.subschema({schema:c,schemaPath:i.nil,errSchemaPath:`${a.errSchemaPath}/${o}`,topSchemaRef:h,compositeRule:!0},u),t.pass(u,(()=>t.error(!0)))},e.funcKeywordCode=function(t,e){var n;const{gen:c,keyword:h,schema:u,parentSchema:d,$data:p,it:m}=t;!function({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}(m,e);const f=!p&&e.compile?e.compile.call(m.self,u,d,m):e.validate,g=l(c,h,f),y=c.let("valid");function b(n=(e.async?i._`await `:i.nil)){const s=m.opts.passContext?o.default.this:o.default.self,a=!("compile"in e&&!p||!1===e.schema);c.assign(y,i._`${n}${(0,r.callValidateCode)(t,g,s,a)}`,e.modifying)}function v(t){var n;c.if((0,i.not)(null!==(n=e.valid)&&void 0!==n?n:y),t)}t.block$data(y,(function(){if(!1===e.errors)b(),e.modifying&&a(t),v((()=>t.error()));else{const n=e.async?function(){const t=c.let("ruleErrs",null);return c.try((()=>b(i._`await `)),(e=>c.assign(y,!1).if(i._`${e} instanceof ${m.ValidationError}`,(()=>c.assign(t,i._`${e}.errors`)),(()=>c.throw(e))))),t}():function(){const t=i._`${g}.errors`;return c.assign(t,null),b(i.nil),t}();e.modifying&&a(t),v((()=>function(t,e){const{gen:n}=t;n.if(i._`Array.isArray(${e})`,(()=>{n.assign(o.default.vErrors,i._`${o.default.vErrors} === null ? ${e} : ${o.default.vErrors}.concat(${e})`).assign(o.default.errors,i._`${o.default.vErrors}.length`),(0,s.extendErrors)(t)}),(()=>t.error()))}(t,n)))}})),t.ok(null!==(n=e.valid)&&void 0!==n?n:y)},e.validSchemaType=function(t,e,n=!1){return!e.length||e.some((e=>"array"===e?Array.isArray(t):"object"===e?t&&"object"==typeof t&&!Array.isArray(t):typeof t==e||n&&void 0===t))},e.validateKeywordUsage=function({schema:t,opts:e,self:n,errSchemaPath:i},o,r){if(Array.isArray(o.keyword)?!o.keyword.includes(r):o.keyword!==r)throw new Error("ajv implementation error");const s=o.dependencies;if(null==s?void 0:s.some((e=>!Object.prototype.hasOwnProperty.call(t,e))))throw new Error(`parent schema must have dependencies of ${r}: ${s.join(",")}`);if(o.validateSchema&&!o.validateSchema(t[r])){const t=`keyword "${r}" value is invalid at path "${i}": `+n.errorsText(o.validateSchema.errors);if("log"!==e.validateSchema)throw new Error(t);n.logger.error(t)}}},4495:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.extendSubschemaMode=e.extendSubschemaData=e.getSubschema=void 0;const i=n(9029),o=n(4227);e.getSubschema=function(t,{keyword:e,schemaProp:n,schema:r,schemaPath:s,errSchemaPath:a,topSchemaRef:l}){if(void 0!==e&&void 0!==r)throw new Error('both "keyword" and "schema" passed, only one allowed');if(void 0!==e){const r=t.schema[e];return void 0===n?{schema:r,schemaPath:i._`${t.schemaPath}${(0,i.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:r[n],schemaPath:i._`${t.schemaPath}${(0,i.getProperty)(e)}${(0,i.getProperty)(n)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,o.escapeFragment)(n)}`}}if(void 0!==r){if(void 0===s||void 0===a||void 0===l)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:r,schemaPath:s,topSchemaRef:l,errSchemaPath:a}}throw new Error('either "keyword" or "schema" must be passed')},e.extendSubschemaData=function(t,e,{dataProp:n,dataPropType:r,data:s,dataTypes:a,propertyName:l}){if(void 0!==s&&void 0!==n)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:c}=e;if(void 0!==n){const{errorPath:s,dataPathArr:a,opts:l}=e;h(c.let("data",i._`${e.data}${(0,i.getProperty)(n)}`,!0)),t.errorPath=i.str`${s}${(0,o.getErrorPath)(n,r,l.jsPropertySyntax)}`,t.parentDataProperty=i._`${n}`,t.dataPathArr=[...a,t.parentDataProperty]}function h(n){t.data=n,t.dataLevel=e.dataLevel+1,t.dataTypes=[],e.definedProperties=new Set,t.parentData=e.data,t.dataNames=[...e.dataNames,n]}void 0!==s&&(h(s instanceof i.Name?s:c.let("data",s,!0)),void 0!==l&&(t.propertyName=l)),a&&(t.dataTypes=a)},e.extendSubschemaMode=function(t,{jtdDiscriminator:e,jtdMetadata:n,compositeRule:i,createErrors:o,allErrors:r}){void 0!==i&&(t.compositeRule=i),void 0!==o&&(t.createErrors=o),void 0!==r&&(t.allErrors=r),t.jtdDiscriminator=e,t.jtdMetadata=n}},4042:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var i=n(2586);Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return i.KeywordCxt}});var o=n(9029);Object.defineProperty(e,"_",{enumerable:!0,get:function(){return o._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return o.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return o.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return o.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return o.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return o.CodeGen}});const r=n(3558),s=n(4551),a=n(396),l=n(3835),c=n(9029),h=n(6939),u=n(208),d=n(4227),p=n(3837),m=n(5944),f=(t,e)=>new RegExp(t,e);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."},v={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'};function w(t){var e,n,i,o,r,s,a,l,c,h,u,d,p,g,y,b,v,w,C,A,S,x,E,T,M;const _=t.strict,I=null===(e=t.code)||void 0===e?void 0:e.optimize,L=!0===I||void 0===I?1:I||0,N=null!==(i=null===(n=t.code)||void 0===n?void 0:n.regExp)&&void 0!==i?i:f,P=null!==(o=t.uriResolver)&&void 0!==o?o:m.default;return{strictSchema:null===(s=null!==(r=t.strictSchema)&&void 0!==r?r:_)||void 0===s||s,strictNumbers:null===(l=null!==(a=t.strictNumbers)&&void 0!==a?a:_)||void 0===l||l,strictTypes:null!==(h=null!==(c=t.strictTypes)&&void 0!==c?c:_)&&void 0!==h?h:"log",strictTuples:null!==(d=null!==(u=t.strictTuples)&&void 0!==u?u:_)&&void 0!==d?d:"log",strictRequired:null!==(g=null!==(p=t.strictRequired)&&void 0!==p?p:_)&&void 0!==g&&g,code:t.code?{...t.code,optimize:L,regExp:N}:{optimize:L,regExp:N},loopRequired:null!==(y=t.loopRequired)&&void 0!==y?y:200,loopEnum:null!==(b=t.loopEnum)&&void 0!==b?b:200,meta:null===(v=t.meta)||void 0===v||v,messages:null===(w=t.messages)||void 0===w||w,inlineRefs:null===(C=t.inlineRefs)||void 0===C||C,schemaId:null!==(A=t.schemaId)&&void 0!==A?A:"$id",addUsedSchema:null===(S=t.addUsedSchema)||void 0===S||S,validateSchema:null===(x=t.validateSchema)||void 0===x||x,validateFormats:null===(E=t.validateFormats)||void 0===E||E,unicodeRegExp:null===(T=t.unicodeRegExp)||void 0===T||T,int32range:null===(M=t.int32range)||void 0===M||M,uriResolver:P}}class C{constructor(t={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,t=this.opts={...t,...w(t)};const{es5:e,lines:n}=this.opts.code;this.scope=new c.ValueScope({scope:{},prefixes:y,es5:e,lines:n}),this.logger=function(t){if(!1===t)return _;if(void 0===t)return console;if(t.log&&t.warn&&t.error)return t;throw new Error("logger must implement log, warn and error methods")}(t.logger);const i=t.validateFormats;t.validateFormats=!1,this.RULES=(0,a.getRules)(),A.call(this,b,t,"NOT SUPPORTED"),A.call(this,v,t,"DEPRECATED","warn"),this._metaOpts=M.call(this),t.formats&&E.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),t.keywords&&T.call(this,t.keywords),"object"==typeof t.meta&&this.addMetaSchema(t.meta),x.call(this),t.validateFormats=i}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:t,meta:e,schemaId:n}=this.opts;let i=p;"id"===n&&(i={...p},i.id=i.$id,delete i.$id),e&&t&&this.addMetaSchema(i,i[n],!1)}defaultMeta(){const{meta:t,schemaId:e}=this.opts;return this.opts.defaultMeta="object"==typeof t?t[e]||t:void 0}validate(t,e){let n;if("string"==typeof t){if(n=this.getSchema(t),!n)throw new Error(`no schema with key or ref "${t}"`)}else n=this.compile(t);const i=n(e);return"$async"in n||(this.errors=n.errors),i}compile(t,e){const n=this._addSchema(t,e);return n.validate||this._compileSchemaEnv(n)}compileAsync(t,e){if("function"!=typeof this.opts.loadSchema)throw new Error("options.loadSchema should be a function");const{loadSchema:n}=this.opts;return i.call(this,t,e);async function i(t,e){await o.call(this,t.$schema);const n=this._addSchema(t,e);return n.validate||r.call(this,n)}async function o(t){t&&!this.getSchema(t)&&await i.call(this,{$ref:t},!0)}async function r(t){try{return this._compileSchemaEnv(t)}catch(e){if(!(e instanceof s.default))throw e;return a.call(this,e),await l.call(this,e.missingSchema),r.call(this,t)}}function a({missingSchema:t,missingRef:e}){if(this.refs[t])throw new Error(`AnySchema ${t} is loaded but ${e} cannot be resolved`)}async function l(t){const n=await c.call(this,t);this.refs[t]||await o.call(this,n.$schema),this.refs[t]||this.addSchema(n,t,e)}async function c(t){const e=this._loading[t];if(e)return e;try{return await(this._loading[t]=n(t))}finally{delete this._loading[t]}}}addSchema(t,e,n,i=this.opts.validateSchema){if(Array.isArray(t)){for(const e of t)this.addSchema(e,void 0,n,i);return this}let o;if("object"==typeof t){const{schemaId:e}=this.opts;if(o=t[e],void 0!==o&&"string"!=typeof o)throw new Error(`schema ${e} must be string`)}return e=(0,h.normalizeId)(e||o),this._checkUnique(e),this.schemas[e]=this._addSchema(t,n,e,i,!0),this}addMetaSchema(t,e,n=this.opts.validateSchema){return this.addSchema(t,e,!0,n),this}validateSchema(t,e){if("boolean"==typeof t)return!0;let n;if(n=t.$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,t);if(!i&&e){const t="schema is invalid: "+this.errorsText();if("log"!==this.opts.validateSchema)throw new Error(t);this.logger.error(t)}return i}getSchema(t){let e;for(;"string"==typeof(e=S.call(this,t));)t=e;if(void 0===e){const{schemaId:n}=this.opts,i=new l.SchemaEnv({schema:{},schemaId:n});if(e=l.resolveSchema.call(this,i,t),!e)return;this.refs[t]=e}return e.validate||this._compileSchemaEnv(e)}removeSchema(t){if(t instanceof RegExp)return this._removeAllSchemas(this.schemas,t),this._removeAllSchemas(this.refs,t),this;switch(typeof t){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{const e=S.call(this,t);return"object"==typeof e&&this._cache.delete(e.schema),delete this.schemas[t],delete this.refs[t],this}case"object":{const e=t;this._cache.delete(e);let n=t[this.opts.schemaId];return n&&(n=(0,h.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(t){for(const e of t)this.addKeyword(e);return this}addKeyword(t,e){let n;if("string"==typeof t)n=t,"object"==typeof e&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),e.keyword=n);else{if("object"!=typeof t||void 0!==e)throw new Error("invalid addKeywords parameters");if(n=(e=t).keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}if(L.call(this,n,e),!e)return(0,d.eachItem)(n,(t=>N.call(this,t))),this;$.call(this,e);const i={...e,type:(0,u.getJSONTypes)(e.type),schemaType:(0,u.getJSONTypes)(e.schemaType)};return(0,d.eachItem)(n,0===i.type.length?t=>N.call(this,t,i):t=>i.type.forEach((e=>N.call(this,t,i,e)))),this}getKeyword(t){const e=this.RULES.all[t];return"object"==typeof e?e.definition:!!e}removeKeyword(t){const{RULES:e}=this;delete e.keywords[t],delete e.all[t];for(const n of e.rules){const e=n.rules.findIndex((e=>e.keyword===t));e>=0&&n.rules.splice(e,1)}return this}addFormat(t,e){return"string"==typeof e&&(e=new RegExp(e)),this.formats[t]=e,this}errorsText(t=this.errors,{separator:e=", ",dataVar:n="data"}={}){return t&&0!==t.length?t.map((t=>`${n}${t.instancePath} ${t.message}`)).reduce(((t,n)=>t+e+n)):"No errors"}$dataMetaSchema(t,e){const n=this.RULES.all;t=JSON.parse(JSON.stringify(t));for(const i of e){const e=i.split("/").slice(1);let o=t;for(const t of e)o=o[t];for(const t in n){const e=n[t];if("object"!=typeof e)continue;const{$data:i}=e.definition,r=o[t];i&&r&&(o[t]=k(r))}}return t}_removeAllSchemas(t,e){for(const n in t){const i=t[n];e&&!e.test(n)||("string"==typeof i?delete t[n]:i&&!i.meta&&(this._cache.delete(i.schema),delete t[n]))}}_addSchema(t,e,n,i=this.opts.validateSchema,o=this.opts.addUsedSchema){let r;const{schemaId:s}=this.opts;if("object"==typeof t)r=t[s];else{if(this.opts.jtd)throw new Error("schema must be object");if("boolean"!=typeof t)throw new Error("schema must be object or boolean")}let a=this._cache.get(t);if(void 0!==a)return a;n=(0,h.normalizeId)(r||n);const c=h.getSchemaRefs.call(this,t,n);return a=new l.SchemaEnv({schema:t,schemaId:s,meta:e,baseId:n,localRefs:c}),this._cache.set(a.schema,a),o&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=a),i&&this.validateSchema(t,!0),a}_checkUnique(t){if(this.schemas[t]||this.refs[t])throw new Error(`schema with key or id "${t}" already exists`)}_compileSchemaEnv(t){if(t.meta?this._compileMetaSchema(t):l.compileSchema.call(this,t),!t.validate)throw new Error("ajv implementation error");return t.validate}_compileMetaSchema(t){const e=this.opts;this.opts=this._metaOpts;try{l.compileSchema.call(this,t)}finally{this.opts=e}}}function A(t,e,n,i="error"){for(const o in t){const r=o;r in e&&this.logger[i](`${n}: option ${o}. ${t[r]}`)}}function S(t){return t=(0,h.normalizeId)(t),this.schemas[t]||this.refs[t]}function x(){const t=this.opts.schemas;if(t)if(Array.isArray(t))this.addSchema(t);else for(const e in t)this.addSchema(t[e],e)}function E(){for(const t in this.opts.formats){const e=this.opts.formats[t];e&&this.addFormat(t,e)}}function T(t){if(Array.isArray(t))this.addVocabulary(t);else{this.logger.warn("keywords option as map is deprecated, pass array");for(const e in t){const n=t[e];n.keyword||(n.keyword=e),this.addKeyword(n)}}}function M(){const t={...this.opts};for(const e of g)delete t[e];return t}C.ValidationError=r.default,C.MissingRefError=s.default,e.default=C;const _={log(){},warn(){},error(){}},I=/^[a-z_$][a-z0-9_$:-]*$/i;function L(t,e){const{RULES:n}=this;if((0,d.eachItem)(t,(t=>{if(n.keywords[t])throw new Error(`Keyword ${t} is already defined`);if(!I.test(t))throw new Error(`Keyword ${t} has invalid name`)})),e&&e.$data&&!("code"in e)&&!("validate"in e))throw new Error('$data keyword must have "code" or "validate" function')}function N(t,e,n){var i;const o=null==e?void 0:e.post;if(n&&o)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:r}=this;let s=o?r.post:r.rules.find((({type:t})=>t===n));if(s||(s={type:n,rules:[]},r.rules.push(s)),r.keywords[t]=!0,!e)return;const a={keyword:t,definition:{...e,type:(0,u.getJSONTypes)(e.type),schemaType:(0,u.getJSONTypes)(e.schemaType)}};e.before?P.call(this,s,a,e.before):s.rules.push(a),r.all[t]=a,null===(i=e.implements)||void 0===i||i.forEach((t=>this.addKeyword(t)))}function P(t,e,n){const i=t.rules.findIndex((t=>t.keyword===n));i>=0?t.rules.splice(i,0,e):(t.rules.push(e),this.logger.warn(`rule ${n} is not defined`))}function $(t){let{metaSchema:e}=t;void 0!==e&&(t.$data&&this.opts.$data&&(e=k(e)),t.validateSchema=this.compile(e,!0))}const R={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function k(t){return{anyOf:[t,R]}}},9572:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(1678),o=n(7216),r=n(9547),s=n(8226),a=n(518),l=n(4588),c=n(5707),h=n(7082),u=["/properties"];e.default=function(t){return[i,o,r,s,a,e(this,l),c,e(this,h)].forEach((t=>this.addMetaSchema(t,void 0,!1))),this;function e(e,n){return t?e.$dataMetaSchema(n,u):n}}},6250:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(2017);i.code='require("ajv/dist/runtime/equal").default',e.default=i},3853:(t,e)=>{"use strict";function n(t){const e=t.length;let n,i=0,o=0;for(;o<e;)i++,n=t.charCodeAt(o++),n>=55296&&n<=56319&&o<e&&(n=t.charCodeAt(o),56320==(64512&n)&&o++);return i}Object.defineProperty(e,"__esModule",{value:!0}),e.default=n,n.code='require("ajv/dist/runtime/ucs2length").default'},5944:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(8343);i.code='require("ajv/dist/runtime/uri").default',e.default=i},3558:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});class n extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}}e.default=n},5457:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.validateAdditionalItems=void 0;const i=n(9029),o=n(4227),r={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:{message:({params:{len:t}})=>i.str`must NOT have more than ${t} items`,params:({params:{len:t}})=>i._`{limit: ${t}}`},code(t){const{parentSchema:e,it:n}=t,{items:i}=e;Array.isArray(i)?s(t,i):(0,o.checkStrictMode)(n,'"additionalItems" is ignored when "items" is not an array of schemas')}};function s(t,e){const{gen:n,schema:r,data:s,keyword:a,it:l}=t;l.items=!0;const c=n.const("len",i._`${s}.length`);if(!1===r)t.setParams({len:e.length}),t.pass(i._`${c} <= ${e.length}`);else if("object"==typeof r&&!(0,o.alwaysValidSchema)(l,r)){const r=n.var("valid",i._`${c} <= ${e.length}`);n.if((0,i.not)(r),(()=>function(r){n.forRange("i",e.length,c,(e=>{t.subschema({keyword:a,dataProp:e,dataPropType:o.Type.Num},r),l.allErrors||n.if((0,i.not)(r),(()=>n.break()))}))}(r))),t.ok(r)}}e.validateAdditionalItems=s,e.default=r},8660:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(5765),o=n(9029),r=n(2023),s=n(4227),a={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:{message:"must NOT have additional properties",params:({params:t})=>o._`{additionalProperty: ${t.additionalProperty}}`},code(t){const{gen:e,schema:n,parentSchema:a,data:l,errsCount:c,it:h}=t;if(!c)throw new Error("ajv implementation error");const{allErrors:u,opts:d}=h;if(h.props=!0,"all"!==d.removeAdditional&&(0,s.alwaysValidSchema)(h,n))return;const p=(0,i.allSchemaProperties)(a.properties),m=(0,i.allSchemaProperties)(a.patternProperties);function f(t){e.code(o._`delete ${l}[${t}]`)}function g(i){if("all"===d.removeAdditional||d.removeAdditional&&!1===n)f(i);else{if(!1===n)return t.setParams({additionalProperty:i}),t.error(),void(u||e.break());if("object"==typeof n&&!(0,s.alwaysValidSchema)(h,n)){const n=e.name("valid");"failing"===d.removeAdditional?(y(i,n,!1),e.if((0,o.not)(n),(()=>{t.reset(),f(i)}))):(y(i,n),u||e.if((0,o.not)(n),(()=>e.break())))}}}function y(e,n,i){const o={keyword:"additionalProperties",dataProp:e,dataPropType:s.Type.Str};!1===i&&Object.assign(o,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(o,n)}e.forIn("key",l,(n=>{p.length||m.length?e.if(function(n){let r;if(p.length>8){const t=(0,s.schemaRefOrVal)(h,a.properties,"properties");r=(0,i.isOwnProperty)(e,t,n)}else r=p.length?(0,o.or)(...p.map((t=>o._`${n} === ${t}`))):o.nil;return m.length&&(r=(0,o.or)(r,...m.map((e=>o._`${(0,i.usePattern)(t,e)}.test(${n})`)))),(0,o.not)(r)}(n),(()=>g(n))):g(n)})),t.ok(o._`${c} === ${r.default.errors}`)}};e.default=a},5844:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(4227),o={keyword:"allOf",schemaType:"array",code(t){const{gen:e,schema:n,it:o}=t;if(!Array.isArray(n))throw new Error("ajv implementation error");const r=e.name("valid");n.forEach(((e,n)=>{if((0,i.alwaysValidSchema)(o,e))return;const s=t.subschema({keyword:"allOf",schemaProp:n},r);t.ok(r),t.mergeEvaluated(s)}))}};e.default=o},6505:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:n(5765).validateUnion,error:{message:"must match a schema in anyOf"}};e.default=i},2661:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(9029),o=n(4227),r={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:{message:({params:{min:t,max:e}})=>void 0===e?i.str`must contain at least ${t} valid item(s)`:i.str`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>void 0===e?i._`{minContains: ${t}}`:i._`{minContains: ${t}, maxContains: ${e}}`},code(t){const{gen:e,schema:n,parentSchema:r,data:s,it:a}=t;let l,c;const{minContains:h,maxContains:u}=r;a.opts.next?(l=void 0===h?1:h,c=u):l=1;const d=e.const("len",i._`${s}.length`);if(t.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 t.fail();if((0,o.alwaysValidSchema)(a,n)){let e=i._`${d} >= ${l}`;return void 0!==c&&(e=i._`${e} && ${d} <= ${c}`),void t.pass(e)}a.items=!0;const p=e.name("valid");function m(){const t=e.name("_valid"),n=e.let("count",0);f(t,(()=>e.if(t,(()=>function(t){e.code(i._`${t}++`),void 0===c?e.if(i._`${t} >= ${l}`,(()=>e.assign(p,!0).break())):(e.if(i._`${t} > ${c}`,(()=>e.assign(p,!1).break())),1===l?e.assign(p,!0):e.if(i._`${t} >= ${l}`,(()=>e.assign(p,!0))))}(n)))))}function f(n,i){e.forRange("i",0,d,(e=>{t.subschema({keyword:"contains",dataProp:e,dataPropType:o.Type.Num,compositeRule:!0},n),i()}))}void 0===c&&1===l?f(p,(()=>e.if(p,(()=>e.break())))):0===l?(e.let(p,!0),void 0!==c&&e.if(i._`${s}.length > 0`,m)):(e.let(p,!1),m()),t.result(p,(()=>t.reset()))}};e.default=r},3025:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;const i=n(9029),o=n(4227),r=n(5765);e.error={message:({params:{property:t,depsCount:e,deps:n}})=>{const o=1===e?"property":"properties";return i.str`must have ${o} ${n} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:n,missingProperty:o}})=>i._`{property: ${t},
|
|
5
5
|
missingProperty: ${o},
|
|
6
6
|
depsCount: ${e},
|
|
7
|
-
deps: ${n}}`};const s={keyword:"dependencies",type:"object",schemaType:"object",error:e.error,code(t){const[e,n]=function({schema:t}){const e={},n={};for(const i in t)"__proto__"!==i&&((Array.isArray(t[i])?e:n)[i]=t[i]);return[e,n]}(t);a(t,e),l(t,n)}};function a(t,e=t.schema){const{gen:n,data:o,it:s}=t;if(0===Object.keys(e).length)return;const a=n.let("missing");for(const l in e){const c=e[l];if(0===c.length)continue;const h=(0,r.propertyInData)(n,o,l,s.opts.ownProperties);t.setParams({property:l,depsCount:c.length,deps:c.join(", ")}),s.allErrors?n.if(h,(()=>{for(const e of c)(0,r.checkReportMissingProp)(t,e)})):(n.if(i._`${h} && (${(0,r.checkMissingProp)(t,c,a)})`),(0,r.reportMissingProp)(t,a),n.else())}}function l(t,e=t.schema){const{gen:n,data:i,keyword:s,it:a}=t,l=n.name("valid");for(const c in e)(0,o.alwaysValidSchema)(a,e[c])||(n.if((0,r.propertyInData)(n,i,c,a.opts.ownProperties),(()=>{const e=t.subschema({keyword:s,schemaProp:c},l);t.mergeValidEvaluated(e,l)}),(()=>n.var(l,!0))),t.ok(l))}e.validatePropertyDeps=a,e.validateSchemaDeps=l,e.default=s},4845:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(3025),o={keyword:"dependentSchemas",type:"object",schemaType:"object",code:t=>(0,i.validateSchemaDeps)(t)};e.default=o},1239:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(9029),o=n(4227),r={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:{message:({params:t})=>i.str`must match "${t.ifClause}" schema`,params:({params:t})=>i._`{failingKeyword: ${t.ifClause}}`},code(t){const{gen:e,parentSchema:n,it:r}=t;void 0===n.then&&void 0===n.else&&(0,o.checkStrictMode)(r,'"if" without "then" and "else" is ignored');const a=s(r,"then"),l=s(r,"else");if(!a&&!l)return;const c=e.let("valid",!0),h=e.name("_valid");if(function(){const e=t.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},h);t.mergeEvaluated(e)}(),t.reset(),a&&l){const n=e.let("ifClause");t.setParams({ifClause:n}),e.if(h,u("then",n),u("else",n))}else a?e.if(h,u("then")):e.if((0,i.not)(h),u("else"));function u(n,o){return()=>{const r=t.subschema({keyword:n},h);e.assign(c,h),t.mergeValidEvaluated(r,c),o?e.assign(o,i._`${n}`):t.setParams({ifClause:n})}}t.pass(c,(()=>t.error(!0)))}};function s(t,e){const n=t.schema[e];return void 0!==n&&!(0,o.alwaysValidSchema)(t,n)}e.default=r},6378:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(5457),o=n(5354),r=n(494),s=n(3966),a=n(2661),l=n(3025),c=n(2094),h=n(8660),u=n(117),d=n(5333),p=n(7923),m=n(6505),f=n(6163),g=n(5844),y=n(1239),b=n(4426);e.default=function(t=!1){const e=[p.default,m.default,f.default,g.default,y.default,b.default,c.default,h.default,l.default,u.default,d.default];return t?e.push(o.default,s.default):e.push(i.default,r.default),e.push(a.default),e}},494:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.validateTuple=void 0;const i=n(9029),o=n(4227),r=n(5765),s={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){const{schema:e,it:n}=t;if(Array.isArray(e))return a(t,"additionalItems",e);n.items=!0,(0,o.alwaysValidSchema)(n,e)||t.ok((0,r.validateArray)(t))}};function a(t,e,n=t.schema){const{gen:r,parentSchema:s,data:a,keyword:l,it:c}=t;!function(t){const{opts:i,errSchemaPath:r}=c,s=n.length,a=s===t.minItems&&(s===t.maxItems||!1===t[e]);if(i.strictTuples&&!a){const t=`"${l}" is ${s}-tuple, but minItems or maxItems/${e} are not specified or different at path "${r}"`;(0,o.checkStrictMode)(c,t,i.strictTuples)}}(s),c.opts.unevaluated&&n.length&&!0!==c.items&&(c.items=o.mergeEvaluated.items(r,n.length,c.items));const h=r.name("valid"),u=r.const("len",i._`${a}.length`);n.forEach(((e,n)=>{(0,o.alwaysValidSchema)(c,e)||(r.if(i._`${u} > ${n}`,(()=>t.subschema({keyword:l,schemaProp:n,dataProp:n},h))),t.ok(h))}))}e.validateTuple=a,e.default=s},3966:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(9029),o=n(4227),r=n(5765),s=n(5457),a={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:{message:({params:{len:t}})=>i.str`must NOT have more than ${t} items`,params:({params:{len:t}})=>i._`{limit: ${t}}`},code(t){const{schema:e,parentSchema:n,it:i}=t,{prefixItems:a}=n;i.items=!0,(0,o.alwaysValidSchema)(i,e)||(a?(0,s.validateAdditionalItems)(t,a):t.ok((0,r.validateArray)(t)))}};e.default=a},7923:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(4227),o={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){const{gen:e,schema:n,it:o}=t;if((0,i.alwaysValidSchema)(o,n))return void t.fail();const r=e.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},r),t.failResult(r,(()=>t.reset()),(()=>t.error()))},error:{message:"must NOT be valid"}};e.default=o},6163:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(9029),o=n(4227),r={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:{message:"must match exactly one schema in oneOf",params:({params:t})=>i._`{passingSchemas: ${t.passing}}`},code(t){const{gen:e,schema:n,parentSchema:r,it:s}=t;if(!Array.isArray(n))throw new Error("ajv implementation error");if(s.opts.discriminator&&r.discriminator)return;const a=n,l=e.let("valid",!1),c=e.let("passing",null),h=e.name("_valid");t.setParams({passing:c}),e.block((function(){a.forEach(((n,r)=>{let a;(0,o.alwaysValidSchema)(s,n)?e.var(h,!0):a=t.subschema({keyword:"oneOf",schemaProp:r,compositeRule:!0},h),r>0&&e.if(i._`${h} && ${l}`).assign(l,!1).assign(c,i._`[${c}, ${r}]`).else(),e.if(h,(()=>{e.assign(l,!0),e.assign(c,r),a&&t.mergeEvaluated(a,i.Name)}))}))})),t.result(l,(()=>t.reset()),(()=>t.error(!0)))}};e.default=r},5333:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(5765),o=n(9029),r=n(4227),s=n(4227),a={keyword:"patternProperties",type:"object",schemaType:"object",code(t){const{gen:e,schema:n,data:a,parentSchema:l,it:c}=t,{opts:h}=c,u=(0,i.allSchemaProperties)(n),d=u.filter((t=>(0,r.alwaysValidSchema)(c,n[t])));if(0===u.length||d.length===u.length&&(!c.opts.unevaluated||!0===c.props))return;const p=h.strictSchema&&!h.allowMatchingProperties&&l.properties,m=e.name("valid");!0===c.props||c.props instanceof o.Name||(c.props=(0,s.evaluatedPropsToName)(e,c.props));const{props:f}=c;function g(t){for(const e in p)new RegExp(t).test(e)&&(0,r.checkStrictMode)(c,`property ${e} matches pattern ${t} (use allowMatchingProperties)`)}function y(n){e.forIn("key",a,(r=>{e.if(o._`${(0,i.usePattern)(t,n)}.test(${r})`,(()=>{const i=d.includes(n);i||t.subschema({keyword:"patternProperties",schemaProp:n,dataProp:r,dataPropType:s.Type.Str},m),c.opts.unevaluated&&!0!==f?e.assign(o._`${f}[${r}]`,!0):i||c.allErrors||e.if((0,o.not)(m),(()=>e.break()))}))}))}!function(){for(const t of u)p&&g(t),c.allErrors?y(t):(e.var(m,!0),y(t),e.if(m))}()}};e.default=a},5354:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(494),o={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,i.validateTuple)(t,"items")};e.default=o},117:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(2586),o=n(5765),r=n(4227),s=n(8660),a={keyword:"properties",type:"object",schemaType:"object",code(t){const{gen:e,schema:n,parentSchema:a,data:l,it:c}=t;"all"===c.opts.removeAdditional&&void 0===a.additionalProperties&&s.default.code(new i.KeywordCxt(c,s.default,"additionalProperties"));const h=(0,o.allSchemaProperties)(n);for(const t of h)c.definedProperties.add(t);c.opts.unevaluated&&h.length&&!0!==c.props&&(c.props=r.mergeEvaluated.props(e,(0,r.toHash)(h),c.props));const u=h.filter((t=>!(0,r.alwaysValidSchema)(c,n[t])));if(0===u.length)return;const d=e.name("valid");for(const n of u)p(n)?m(n):(e.if((0,o.propertyInData)(e,l,n,c.opts.ownProperties)),m(n),c.allErrors||e.else().var(d,!0),e.endIf()),t.it.definedProperties.add(n),t.ok(d);function p(t){return c.opts.useDefaults&&!c.compositeRule&&void 0!==n[t].default}function m(e){t.subschema({keyword:"properties",schemaProp:e,dataProp:e},d)}}};e.default=a},2094:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(9029),o=n(4227),r={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:{message:"property name must be valid",params:({params:t})=>i._`{propertyName: ${t.propertyName}}`},code(t){const{gen:e,schema:n,data:r,it:s}=t;if((0,o.alwaysValidSchema)(s,n))return;const a=e.name("valid");e.forIn("key",r,(n=>{t.setParams({propertyName:n}),t.subschema({keyword:"propertyNames",data:n,dataTypes:["string"],propertyName:n,compositeRule:!0},a),e.if((0,i.not)(a),(()=>{t.error(!0),s.allErrors||e.break()}))})),t.ok(a)}};e.default=r},4426:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(4227),o={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:n}){void 0===e.if&&(0,i.checkStrictMode)(n,`"${t}" without "if" is ignored`)}};e.default=o},5765:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.validateUnion=e.validateArray=e.usePattern=e.callValidateCode=e.schemaProperties=e.allSchemaProperties=e.noPropertyInData=e.propertyInData=e.isOwnProperty=e.hasPropFunc=e.reportMissingProp=e.checkMissingProp=e.checkReportMissingProp=void 0;const i=n(9029),o=n(4227),r=n(2023),s=n(4227);function a(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:i._`Object.prototype.hasOwnProperty`})}function l(t,e,n){return i._`${a(t)}.call(${e}, ${n})`}function c(t,e,n,o){const r=i._`${e}${(0,i.getProperty)(n)} === undefined`;return o?(0,i.or)(r,(0,i.not)(l(t,e,n))):r}function h(t){return t?Object.keys(t).filter((t=>"__proto__"!==t)):[]}e.checkReportMissingProp=function(t,e){const{gen:n,data:o,it:r}=t;n.if(c(n,o,e,r.opts.ownProperties),(()=>{t.setParams({missingProperty:i._`${e}`},!0),t.error()}))},e.checkMissingProp=function({gen:t,data:e,it:{opts:n}},o,r){return(0,i.or)(...o.map((o=>(0,i.and)(c(t,e,o,n.ownProperties),i._`${r} = ${o}`))))},e.reportMissingProp=function(t,e){t.setParams({missingProperty:e},!0),t.error()},e.hasPropFunc=a,e.isOwnProperty=l,e.propertyInData=function(t,e,n,o){const r=i._`${e}${(0,i.getProperty)(n)} !== undefined`;return o?i._`${r} && ${l(t,e,n)}`:r},e.noPropertyInData=c,e.allSchemaProperties=h,e.schemaProperties=function(t,e){return h(e).filter((n=>!(0,o.alwaysValidSchema)(t,e[n])))},e.callValidateCode=function({schemaCode:t,data:e,it:{gen:n,topSchemaRef:o,schemaPath:s,errorPath:a},it:l},c,h,u){const d=u?i._`${t}, ${e}, ${o}${s}`:e,p=[[r.default.instancePath,(0,i.strConcat)(r.default.instancePath,a)],[r.default.parentData,l.parentData],[r.default.parentDataProperty,l.parentDataProperty],[r.default.rootData,r.default.rootData]];l.opts.dynamicRef&&p.push([r.default.dynamicAnchors,r.default.dynamicAnchors]);const m=i._`${d}, ${n.object(...p)}`;return h!==i.nil?i._`${c}.call(${h}, ${m})`:i._`${c}(${m})`};const u=i._`new RegExp`;e.usePattern=function({gen:t,it:{opts:e}},n){const o=e.unicodeRegExp?"u":"",{regExp:r}=e.code,a=r(n,o);return t.scopeValue("pattern",{key:a.toString(),ref:a,code:i._`${"new RegExp"===r.code?u:(0,s.useFunc)(t,r)}(${n}, ${o})`})},e.validateArray=function(t){const{gen:e,data:n,keyword:r,it:s}=t,a=e.name("valid");if(s.allErrors){const t=e.let("valid",!0);return l((()=>e.assign(t,!1))),t}return e.var(a,!0),l((()=>e.break())),a;function l(s){const l=e.const("len",i._`${n}.length`);e.forRange("i",0,l,(n=>{t.subschema({keyword:r,dataProp:n,dataPropType:o.Type.Num},a),e.if((0,i.not)(a),s)}))}},e.validateUnion=function(t){const{gen:e,schema:n,keyword:r,it:s}=t;if(!Array.isArray(n))throw new Error("ajv implementation error");if(n.some((t=>(0,o.alwaysValidSchema)(s,t)))&&!s.opts.unevaluated)return;const a=e.let("valid",!1),l=e.name("_valid");e.block((()=>n.forEach(((n,o)=>{const s=t.subschema({keyword:r,schemaProp:o,compositeRule:!0},l);e.assign(a,i._`${a} || ${l}`),t.mergeValidEvaluated(s,l)||e.if((0,i.not)(a))})))),t.result(a,(()=>t.reset()),(()=>t.error(!0)))}},3463:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};e.default=n},2128:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(3463),o=n(3693),r=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",i.default,o.default];e.default=r},3693:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.callRef=e.getValidate=void 0;const i=n(4551),o=n(5765),r=n(9029),s=n(2023),a=n(3835),l=n(4227),c={keyword:"$ref",schemaType:"string",code(t){const{gen:e,schema:n,it:o}=t,{baseId:s,schemaEnv:l,validateName:c,opts:d,self:p}=o,{root:m}=l;if(("#"===n||"#/"===n)&&s===m.baseId)return function(){if(l===m)return u(t,c,l,l.$async);const n=e.scopeValue("root",{ref:m});return u(t,r._`${n}.validate`,m,m.$async)}();const f=a.resolveRef.call(p,m,s,n);if(void 0===f)throw new i.default(o.opts.uriResolver,s,n);return f instanceof a.SchemaEnv?function(e){const n=h(t,e);u(t,n,e,e.$async)}(f):function(i){const o=e.scopeValue("schema",!0===d.code.source?{ref:i,code:(0,r.stringify)(i)}:{ref:i}),s=e.name("valid"),a=t.subschema({schema:i,dataTypes:[],schemaPath:r.nil,topSchemaRef:o,errSchemaPath:n},s);t.mergeEvaluated(a),t.ok(s)}(f)}};function h(t,e){const{gen:n}=t;return e.validate?n.scopeValue("validate",{ref:e.validate}):r._`${n.scopeValue("wrapper",{ref:e})}.validate`}function u(t,e,n,i){const{gen:a,it:c}=t,{allErrors:h,schemaEnv:u,opts:d}=c,p=d.passContext?s.default.this:r.nil;function m(t){const e=r._`${t}.errors`;a.assign(s.default.vErrors,r._`${s.default.vErrors} === null ? ${e} : ${s.default.vErrors}.concat(${e})`),a.assign(s.default.errors,r._`${s.default.vErrors}.length`)}function f(t){var e;if(!c.opts.unevaluated)return;const i=null===(e=null==n?void 0:n.validate)||void 0===e?void 0:e.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 e=a.var("props",r._`${t}.evaluated.props`);c.props=l.mergeEvaluated.props(a,e,c.props,r.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 e=a.var("items",r._`${t}.evaluated.items`);c.items=l.mergeEvaluated.items(a,e,c.items,r.Name)}}i?function(){if(!u.$async)throw new Error("async schema referenced by sync schema");const n=a.let("valid");a.try((()=>{a.code(r._`await ${(0,o.callValidateCode)(t,e,p)}`),f(e),h||a.assign(n,!0)}),(t=>{a.if(r._`!(${t} instanceof ${c.ValidationError})`,(()=>a.throw(t))),m(t),h||a.assign(n,!1)})),t.ok(n)}():t.result((0,o.callValidateCode)(t,e,p),(()=>f(e)),(()=>m(e)))}e.getValidate=h,e.callRef=u,e.default=c},6653:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(9029),o=n(7652),r=n(3835),s=n(4551),a=n(4227),l={keyword:"discriminator",type:"object",schemaType:"object",error:{message:({params:{discrError:t,tagName:e}})=>t===o.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:n}})=>i._`{error: ${t}, tag: ${n}, tagValue: ${e}}`},code(t){const{gen:e,data:n,schema:l,parentSchema:c,it:h}=t,{oneOf:u}=c;if(!h.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(!u)throw new Error("discriminator: requires oneOf keyword");const p=e.let("valid",!1),m=e.const("tag",i._`${n}${(0,i.getProperty)(d)}`);function f(n){const o=e.name("valid"),r=t.subschema({keyword:"oneOf",schemaProp:n},o);return t.mergeEvaluated(r,i.Name),o}e.if(i._`typeof ${m} == "string"`,(()=>function(){const n=function(){var t;const e={},n=o(c);let i=!0;for(let e=0;e<u.length;e++){let c=u[e];if((null==c?void 0:c.$ref)&&!(0,a.schemaHasRulesButRef)(c,h.self.RULES)){const t=c.$ref;if(c=r.resolveRef.call(h.self,h.schemaEnv.root,h.baseId,t),c instanceof r.SchemaEnv&&(c=c.schema),void 0===c)throw new s.default(h.opts.uriResolver,h.baseId,t)}const p=null===(t=null==c?void 0:c.properties)||void 0===t?void 0:t[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,e)}if(!i)throw new Error(`discriminator: "${d}" must be required`);return e;function o({required:t}){return Array.isArray(t)&&t.includes(d)}function l(t,e){if(t.const)p(t.const,e);else{if(!t.enum)throw new Error(`discriminator: "properties/${d}" must have "const" or "enum"`);for(const n of t.enum)p(n,e)}}function p(t,n){if("string"!=typeof t||t in e)throw new Error(`discriminator: "${d}" values must be unique strings`);e[t]=n}}();e.if(!1);for(const t in n)e.elseIf(i._`${m} === ${t}`),e.assign(p,f(n[t]));e.else(),t.error(!1,{discrError:o.DiscrError.Mapping,tag:m,tagName:d}),e.endIf()}()),(()=>t.error(!1,{discrError:o.DiscrError.Tag,tag:m,tagName:d}))),t.ok(p)}};e.default=l},7652:(t,e)=>{"use strict";var n;Object.defineProperty(e,"__esModule",{value:!0}),e.DiscrError=void 0,function(t){t.Tag="tag",t.Mapping="mapping"}(n||(e.DiscrError=n={}))},6105:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(2128),o=n(7060),r=n(6378),s=n(5520),a=n(5413),l=n(3265),c=n(7532),h=n(9857),u=[s.default,i.default,o.default,(0,r.default)(!0),c.default,h.metadataVocabulary,h.contentVocabulary,a.default,l.default];e.default=u},6144:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(2128),o=n(7060),r=n(6378),s=n(7532),a=n(9857),l=[i.default,o.default,(0,r.default)(),s.default,a.metadataVocabulary,a.contentVocabulary];e.default=l},2476:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.dynamicAnchor=void 0;const i=n(9029),o=n(2023),r=n(3835),s=n(3693),a={keyword:"$dynamicAnchor",schemaType:"string",code:t=>l(t,t.schema)};function l(t,e){const{gen:n,it:a}=t;a.schemaEnv.root.dynamicAnchors[e]=!0;const l=i._`${o.default.dynamicAnchors}${(0,i.getProperty)(e)}`,c="#"===a.errSchemaPath?a.validateName:function(t){const{schemaEnv:e,schema:n,self:i}=t.it,{root:o,baseId:a,localRefs:l,meta:c}=e.root,{schemaId:h}=i.opts,u=new r.SchemaEnv({schema:n,schemaId:h,root:o,baseId:a,localRefs:l,meta:c});return r.compileSchema.call(i,u),(0,s.getValidate)(t,u)}(t);n.if(i._`!${l}`,(()=>n.assign(l,c)))}e.dynamicAnchor=l,e.default=a},3252:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.dynamicRef=void 0;const i=n(9029),o=n(2023),r=n(3693),s={keyword:"$dynamicRef",schemaType:"string",code:t=>a(t,t.schema)};function a(t,e){const{gen:n,keyword:s,it:a}=t;if("#"!==e[0])throw new Error(`"${s}" only supports hash fragment reference`);const l=e.slice(1);if(a.allErrors)c();else{const e=n.let("valid",!1);c(e),t.ok(e)}function c(t){if(a.schemaEnv.root.dynamicAnchors[l]){const e=n.let("_v",i._`${o.default.dynamicAnchors}${(0,i.getProperty)(l)}`);n.if(e,h(e,t),h(a.validateName,t))}else h(a.validateName,t)()}function h(e,i){return i?()=>n.block((()=>{(0,r.callRef)(t,e),n.let(i,!0)})):()=>(0,r.callRef)(t,e)}}e.dynamicRef=a,e.default=s},5520:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(2476),o=n(3252),r=n(2721),s=n(3799),a=[i.default,o.default,r.default,s.default];e.default=a},2721:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(2476),o=n(4227),r={keyword:"$recursiveAnchor",schemaType:"boolean",code(t){t.schema?(0,i.dynamicAnchor)(t,""):(0,o.checkStrictMode)(t.it,"$recursiveAnchor: false is ignored")}};e.default=r},3799:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(3252),o={keyword:"$recursiveRef",schemaType:"string",code:t=>(0,i.dynamicRef)(t,t.schema)};e.default=o},4737:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(9029),o={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:{message:({schemaCode:t})=>i.str`must match format "${t}"`,params:({schemaCode:t})=>i._`{format: ${t}}`},code(t,e){const{gen:n,data:o,$data:r,schema:s,schemaCode:a,it:l}=t,{opts:c,errSchemaPath:h,schemaEnv:u,self:d}=l;c.validateFormats&&(r?function(){const r=n.scopeValue("formats",{ref:d.formats,code:c.code.formats}),s=n.const("fDef",i._`${r}[${a}]`),l=n.let("fType"),h=n.let("format");n.if(i._`typeof ${s} == "object" && !(${s} instanceof RegExp)`,(()=>n.assign(l,i._`${s}.type || "string"`).assign(h,i._`${s}.validate`)),(()=>n.assign(l,i._`"string"`).assign(h,s))),t.fail$data((0,i.or)(!1===c.strictSchema?i.nil:i._`${a} && !${h}`,function(){const t=u.$async?i._`(${s}.async ? await ${h}(${o}) : ${h}(${o}))`:i._`${h}(${o})`,n=i._`(typeof ${h} == "function" ? ${t} : ${h}.test(${o}))`;return i._`${h} && ${h} !== true && ${l} === ${e} && !${n}`}()))}():function(){const r=d.formats[s];if(!r)return void function(){if(!1!==c.strictSchema)throw new Error(t());function t(){return`unknown format "${s}" ignored in schema at path "${h}"`}d.logger.warn(t())}();if(!0===r)return;const[a,l,p]=function(t){const e=t instanceof RegExp?(0,i.regexpCode)(t):c.code.formats?i._`${c.code.formats}${(0,i.getProperty)(s)}`:void 0,o=n.scopeValue("formats",{key:s,ref:t,code:e});return"object"!=typeof t||t instanceof RegExp?["string",t,o]:[t.type||"string",t.validate,i._`${o}.validate`]}(r);a===e&&t.pass(function(){if("object"==typeof r&&!(r instanceof RegExp)&&r.async){if(!u.$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})`}())}())}};e.default=o},7532:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=[n(4737).default];e.default=i},9857:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.contentVocabulary=e.metadataVocabulary=void 0,e.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"],e.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]},5413:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(1846),o=n(4845),r=n(2626),s=[i.default,o.default,r.default];e.default=s},3265:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(392),o=n(3445),r=[i.default,o.default];e.default=r},3445:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(9029),o=n(4227),r={keyword:"unevaluatedItems",type:"array",schemaType:["boolean","object"],error:{message:({params:{len:t}})=>i.str`must NOT have more than ${t} items`,params:({params:{len:t}})=>i._`{limit: ${t}}`},code(t){const{gen:e,schema:n,data:r,it:s}=t,a=s.items||0;if(!0===a)return;const l=e.const("len",i._`${r}.length`);if(!1===n)t.setParams({len:a}),t.fail(i._`${l} > ${a}`);else if("object"==typeof n&&!(0,o.alwaysValidSchema)(s,n)){const n=e.var("valid",i._`${l} <= ${a}`);e.if((0,i.not)(n),(()=>function(n,r){e.forRange("i",r,l,(r=>{t.subschema({keyword:"unevaluatedItems",dataProp:r,dataPropType:o.Type.Num},n),s.allErrors||e.if((0,i.not)(n),(()=>e.break()))}))}(n,a))),t.ok(n)}s.items=!0}};e.default=r},392:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(9029),o=n(4227),r=n(2023),s={keyword:"unevaluatedProperties",type:"object",schemaType:["boolean","object"],trackErrors:!0,error:{message:"must NOT have unevaluated properties",params:({params:t})=>i._`{unevaluatedProperty: ${t.unevaluatedProperty}}`},code(t){const{gen:e,schema:n,data:s,errsCount:a,it:l}=t;if(!a)throw new Error("ajv implementation error");const{allErrors:c,props:h}=l;function u(r){if(!1===n)return t.setParams({unevaluatedProperty:r}),t.error(),void(c||e.break());if(!(0,o.alwaysValidSchema)(l,n)){const n=e.name("valid");t.subschema({keyword:"unevaluatedProperties",dataProp:r,dataPropType:o.Type.Str},n),c||e.if((0,i.not)(n),(()=>e.break()))}}h instanceof i.Name?e.if(i._`${h} !== true`,(()=>e.forIn("key",s,(t=>e.if(function(t,e){return i._`!${t} || !${t}[${e}]`}(h,t),(()=>u(t))))))):!0!==h&&e.forIn("key",s,(t=>void 0===h?u(t):e.if(function(t,e){const n=[];for(const o in t)!0===t[o]&&n.push(i._`${e} !== ${o}`);return(0,i.and)(...n)}(h,t),(()=>u(t))))),l.props=!0,t.ok(i._`${a} === ${r.default.errors}`)}};e.default=s},7935:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(9029),o=n(4227),r=n(6250),s={keyword:"const",$data:!0,error:{message:"must be equal to constant",params:({schemaCode:t})=>i._`{allowedValue: ${t}}`},code(t){const{gen:e,data:n,$data:s,schemaCode:a,schema:l}=t;s||l&&"object"==typeof l?t.fail$data(i._`!${(0,o.useFunc)(e,r.default)}(${n}, ${a})`):t.fail(i._`${l} !== ${n}`)}};e.default=s},1846:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(3025),o={keyword:"dependentRequired",type:"object",schemaType:"object",error:i.error,code:t=>(0,i.validatePropertyDeps)(t)};e.default=o},8643:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(9029),o=n(4227),r=n(6250),s={keyword:"enum",schemaType:"array",$data:!0,error:{message:"must be equal to one of the allowed values",params:({schemaCode:t})=>i._`{allowedValues: ${t}}`},code(t){const{gen:e,data:n,$data:s,schema:a,schemaCode:l,it:c}=t;if(!s&&0===a.length)throw new Error("enum must have non-empty array");const h=a.length>=c.opts.loopEnum;let u;const d=()=>null!=u?u:u=(0,o.useFunc)(e,r.default);let p;if(h||s)p=e.let("valid"),t.block$data(p,(function(){e.assign(p,!1),e.forOf("v",l,(t=>e.if(i._`${d()}(${n}, ${t})`,(()=>e.assign(p,!0).break()))))}));else{if(!Array.isArray(a))throw new Error("ajv implementation error");const t=e.const("vSchema",l);p=(0,i.or)(...a.map(((e,o)=>function(t,e){const o=a[e];return"object"==typeof o&&null!==o?i._`${d()}(${n}, ${t}[${e}])`:i._`${n} === ${o}`}(t,o))))}t.pass(p)}};e.default=s},7060:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(5882),o=n(3439),r=n(7307),s=n(422),a=n(4486),l=n(4003),c=n(1163),h=n(617),u=n(7935),d=n(8643),p=[i.default,o.default,r.default,s.default,a.default,l.default,c.default,h.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},u.default,d.default];e.default=p},2626:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(4227),o={keyword:["maxContains","minContains"],type:"array",schemaType:"number",code({keyword:t,parentSchema:e,it:n}){void 0===e.contains&&(0,i.checkStrictMode)(n,`"${t}" without "contains" is ignored`)}};e.default=o},1163:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(9029),o={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:{message({keyword:t,schemaCode:e}){const n="maxItems"===t?"more":"fewer";return i.str`must NOT have ${n} than ${e} items`},params:({schemaCode:t})=>i._`{limit: ${t}}`},code(t){const{keyword:e,data:n,schemaCode:o}=t,r="maxItems"===e?i.operators.GT:i.operators.LT;t.fail$data(i._`${n}.length ${r} ${o}`)}};e.default=o},7307:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(9029),o=n(4227),r=n(3853),s={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:{message({keyword:t,schemaCode:e}){const n="maxLength"===t?"more":"fewer";return i.str`must NOT have ${n} than ${e} characters`},params:({schemaCode:t})=>i._`{limit: ${t}}`},code(t){const{keyword:e,data:n,schemaCode:s,it:a}=t,l="maxLength"===e?i.operators.GT:i.operators.LT,c=!1===a.opts.unicode?i._`${n}.length`:i._`${(0,o.useFunc)(t.gen,r.default)}(${n})`;t.fail$data(i._`${c} ${l} ${s}`)}};e.default=s},5882:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(9029),o=i.operators,r={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}},s={message:({keyword:t,schemaCode:e})=>i.str`must be ${r[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>i._`{comparison: ${r[t].okStr}, limit: ${e}}`},a={keyword:Object.keys(r),type:"number",schemaType:"number",$data:!0,error:s,code(t){const{keyword:e,data:n,schemaCode:o}=t;t.fail$data(i._`${n} ${r[e].fail} ${o} || isNaN(${n})`)}};e.default=a},4486:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(9029),o={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:{message({keyword:t,schemaCode:e}){const n="maxProperties"===t?"more":"fewer";return i.str`must NOT have ${n} than ${e} properties`},params:({schemaCode:t})=>i._`{limit: ${t}}`},code(t){const{keyword:e,data:n,schemaCode:o}=t,r="maxProperties"===e?i.operators.GT:i.operators.LT;t.fail$data(i._`Object.keys(${n}).length ${r} ${o}`)}};e.default=o},3439:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(9029),o={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:{message:({schemaCode:t})=>i.str`must be multiple of ${t}`,params:({schemaCode:t})=>i._`{multipleOf: ${t}}`},code(t){const{gen:e,data:n,schemaCode:o,it:r}=t,s=r.opts.multipleOfPrecision,a=e.let("res"),l=s?i._`Math.abs(Math.round(${a}) - ${a}) > 1e-${s}`:i._`${a} !== parseInt(${a})`;t.fail$data(i._`(${o} === 0 || (${a} = ${n}/${o}, ${l}))`)}};e.default=o},422:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(5765),o=n(9029),r={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:{message:({schemaCode:t})=>o.str`must match pattern "${t}"`,params:({schemaCode:t})=>o._`{pattern: ${t}}`},code(t){const{data:e,$data:n,schema:r,schemaCode:s,it:a}=t,l=a.opts.unicodeRegExp?"u":"",c=n?o._`(new RegExp(${s}, ${l}))`:(0,i.usePattern)(t,r);t.fail$data(o._`!${c}.test(${e})`)}};e.default=r},4003:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(5765),o=n(9029),r=n(4227),s={keyword:"required",type:"object",schemaType:"array",$data:!0,error:{message:({params:{missingProperty:t}})=>o.str`must have required property '${t}'`,params:({params:{missingProperty:t}})=>o._`{missingProperty: ${t}}`},code(t){const{gen:e,schema:n,schemaCode:s,data:a,$data:l,it:c}=t,{opts:h}=c;if(!l&&0===n.length)return;const u=n.length>=h.loopRequired;if(c.allErrors?function(){if(u||l)t.block$data(o.nil,d);else for(const e of n)(0,i.checkReportMissingProp)(t,e)}():function(){const r=e.let("missing");if(u||l){const n=e.let("valid",!0);t.block$data(n,(()=>function(n,r){t.setParams({missingProperty:n}),e.forOf(n,s,(()=>{e.assign(r,(0,i.propertyInData)(e,a,n,h.ownProperties)),e.if((0,o.not)(r),(()=>{t.error(),e.break()}))}),o.nil)}(r,n))),t.ok(n)}else e.if((0,i.checkMissingProp)(t,n,r)),(0,i.reportMissingProp)(t,r),e.else()}(),h.strictRequired){const e=t.parentSchema.properties,{definedProperties:i}=t.it;for(const t of n)if(void 0===(null==e?void 0:e[t])&&!i.has(t)){const e=`required property "${t}" is not defined at "${c.schemaEnv.baseId+c.errSchemaPath}" (strictRequired)`;(0,r.checkStrictMode)(c,e,c.opts.strictRequired)}}function d(){e.forOf("prop",s,(n=>{t.setParams({missingProperty:n}),e.if((0,i.noPropertyInData)(e,a,n,h.ownProperties),(()=>t.error()))}))}}};e.default=s},617:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(208),o=n(9029),r=n(4227),s=n(6250),a={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:{message:({params:{i:t,j:e}})=>o.str`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>o._`{i: ${t}, j: ${e}}`},code(t){const{gen:e,data:n,$data:a,schema:l,parentSchema:c,schemaCode:h,it:u}=t;if(!a&&!l)return;const d=e.let("valid"),p=c.items?(0,i.getSchemaTypes)(c.items):[];function m(r,s){const a=e.name("item"),l=(0,i.checkDataTypes)(p,a,u.opts.strictNumbers,i.DataType.Wrong),c=e.const("indices",o._`{}`);e.for(o._`;${r}--;`,(()=>{e.let(a,o._`${n}[${r}]`),e.if(l,o._`continue`),p.length>1&&e.if(o._`typeof ${a} == "string"`,o._`${a} += "_"`),e.if(o._`typeof ${c}[${a}] == "number"`,(()=>{e.assign(s,o._`${c}[${a}]`),t.error(),e.assign(d,!1).break()})).code(o._`${c}[${a}] = ${r}`)}))}function f(i,a){const l=(0,r.useFunc)(e,s.default),c=e.name("outer");e.label(c).for(o._`;${i}--;`,(()=>e.for(o._`${a} = ${i}; ${a}--;`,(()=>e.if(o._`${l}(${n}[${i}], ${n}[${a}])`,(()=>{t.error(),e.assign(d,!1).break(c)}))))))}t.block$data(d,(function(){const i=e.let("i",o._`${n}.length`),r=e.let("j");t.setParams({i,j:r}),e.assign(d,!0),e.if(o._`${i} > 1`,(()=>(p.length>0&&!p.some((t=>"object"===t||"array"===t))?m:f)(i,r)))}),o._`${h} === false`),t.ok(d)}};e.default=a},5488:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var i=n(1354),o=n.n(i),r=n(6314),s=n.n(r)()(o());s.push([t.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=s},5999:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var i=n(1354),o=n.n(i),r=n(6314),s=n.n(r)()(o());s.push([t.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=s},857:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var i=n(1354),o=n.n(i),r=n(6314),s=n.n(r)()(o());s.push([t.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=s},6369:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var i=n(1354),o=n.n(i),r=n(6314),s=n.n(r)()(o());s.push([t.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=s},7939:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var i=n(1354),o=n.n(i),r=n(6314),s=n.n(r)()(o());s.push([t.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=s},3017:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var i=n(1354),o=n.n(i),r=n(6314),s=n.n(r)()(o());s.push([t.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=s},6314:t=>{"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var n="",i=void 0!==e[5];return e[4]&&(n+="@supports (".concat(e[4],") {")),e[2]&&(n+="@media ".concat(e[2]," {")),i&&(n+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),n+=t(e),i&&(n+="}"),e[2]&&(n+="}"),e[4]&&(n+="}"),n})).join("")},e.i=function(t,n,i,o,r){"string"==typeof t&&(t=[[null,t,void 0]]);var s={};if(i)for(var a=0;a<this.length;a++){var l=this[a][0];null!=l&&(s[l]=!0)}for(var c=0;c<t.length;c++){var h=[].concat(t[c]);i&&s[h[0]]||(void 0!==r&&(void 0===h[5]||(h[1]="@layer".concat(h[5].length>0?" ".concat(h[5]):""," {").concat(h[1],"}")),h[5]=r),n&&(h[2]?(h[1]="@media ".concat(h[2]," {").concat(h[1],"}"),h[2]=n):h[2]=n),o&&(h[4]?(h[1]="@supports (".concat(h[4],") {").concat(h[1],"}"),h[4]=o):h[4]="".concat(o)),e.push(h))}},e}},1354:t=>{"use strict";t.exports=function(t){var e=t[1],n=t[3];if(!n)return e;if("function"==typeof btoa){var i=btoa(unescape(encodeURIComponent(JSON.stringify(n)))),o="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(i),r="/*# ".concat(o," */");return[e].concat([r]).join("\n")}return[e].join("\n")}},2017:t=>{"use strict";t.exports=function t(e,n){if(e===n)return!0;if(e&&n&&"object"==typeof e&&"object"==typeof n){if(e.constructor!==n.constructor)return!1;var i,o,r;if(Array.isArray(e)){if((i=e.length)!=n.length)return!1;for(o=i;0!=o--;)if(!t(e[o],n[o]))return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if((i=(r=Object.keys(e)).length)!==Object.keys(n).length)return!1;for(o=i;0!=o--;)if(!Object.prototype.hasOwnProperty.call(n,r[o]))return!1;for(o=i;0!=o--;){var s=r[o];if(!t(e[s],n[s]))return!1}return!0}return e!=e&&n!=n}},9982:function(t,e,n){var i;!function(){var e={};!function(t){"use strict";t.__esModule=!0,t.digestLength=32,t.blockSize=64;var e=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(t,n,i,o,r){for(var s,a,l,c,h,u,d,p,m,f,g,y,b;r>=64;){for(s=n[0],a=n[1],l=n[2],c=n[3],h=n[4],u=n[5],d=n[6],p=n[7],f=0;f<16;f++)g=o+4*f,t[f]=(255&i[g])<<24|(255&i[g+1])<<16|(255&i[g+2])<<8|255&i[g+3];for(f=16;f<64;f++)y=((m=t[f-2])>>>17|m<<15)^(m>>>19|m<<13)^m>>>10,b=((m=t[f-15])>>>7|m<<25)^(m>>>18|m<<14)^m>>>3,t[f]=(y+t[f-7]|0)+(b+t[f-16]|0);for(f=0;f<64;f++)y=(((h>>>6|h<<26)^(h>>>11|h<<21)^(h>>>25|h<<7))+(h&u^~h&d)|0)+(p+(e[f]+t[f]|0)|0)|0,b=((s>>>2|s<<30)^(s>>>13|s<<19)^(s>>>22|s<<10))+(s&a^s&l^a&l)|0,p=d,d=u,u=h,h=c+y|0,c=l,l=a,a=s,s=y+b|0;n[0]+=s,n[1]+=a,n[2]+=l,n[3]+=c,n[4]+=h,n[5]+=u,n[6]+=d,n[7]+=p,o+=64,r-=64}return o}var i=function(){function e(){this.digestLength=t.digestLength,this.blockSize=t.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 e.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},e.prototype.clean=function(){for(var t=0;t<this.buffer.length;t++)this.buffer[t]=0;for(t=0;t<this.temp.length;t++)this.temp[t]=0;this.reset()},e.prototype.update=function(t,e){if(void 0===e&&(e=t.length),this.finished)throw new Error("SHA256: can't update because hash was finished.");var i=0;if(this.bytesHashed+=e,this.bufferLength>0){for(;this.bufferLength<64&&e>0;)this.buffer[this.bufferLength++]=t[i++],e--;64===this.bufferLength&&(n(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(e>=64&&(i=n(this.temp,this.state,t,i,e),e%=64);e>0;)this.buffer[this.bufferLength++]=t[i++],e--;return this},e.prototype.finish=function(t){if(!this.finished){var e=this.bytesHashed,i=this.bufferLength,o=e/536870912|0,r=e<<3,s=e%64<56?64:128;this.buffer[i]=128;for(var a=i+1;a<s-8;a++)this.buffer[a]=0;this.buffer[s-8]=o>>>24&255,this.buffer[s-7]=o>>>16&255,this.buffer[s-6]=o>>>8&255,this.buffer[s-5]=o>>>0&255,this.buffer[s-4]=r>>>24&255,this.buffer[s-3]=r>>>16&255,this.buffer[s-2]=r>>>8&255,this.buffer[s-1]=r>>>0&255,n(this.temp,this.state,this.buffer,0,s),this.finished=!0}for(a=0;a<8;a++)t[4*a+0]=this.state[a]>>>24&255,t[4*a+1]=this.state[a]>>>16&255,t[4*a+2]=this.state[a]>>>8&255,t[4*a+3]=this.state[a]>>>0&255;return this},e.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},e.prototype._saveState=function(t){for(var e=0;e<this.state.length;e++)t[e]=this.state[e]},e.prototype._restoreState=function(t,e){for(var n=0;n<this.state.length;n++)this.state[n]=t[n];this.bytesHashed=e,this.finished=!1,this.bufferLength=0},e}();t.Hash=i;var o=function(){function t(t){this.inner=new i,this.outer=new i,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var e=new Uint8Array(this.blockSize);if(t.length>this.blockSize)(new i).update(t).finish(e).clean();else for(var n=0;n<t.length;n++)e[n]=t[n];for(n=0;n<e.length;n++)e[n]^=54;for(this.inner.update(e),n=0;n<e.length;n++)e[n]^=106;for(this.outer.update(e),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate),n=0;n<e.length;n++)e[n]=0}return t.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},t.prototype.clean=function(){for(var t=0;t<this.istate.length;t++)this.ostate[t]=this.istate[t]=0;this.inner.clean(),this.outer.clean()},t.prototype.update=function(t){return this.inner.update(t),this},t.prototype.finish=function(t){return this.outer.finished?this.outer.finish(t):(this.inner.finish(t),this.outer.update(t,this.digestLength).finish(t)),this},t.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},t}();function r(t){var e=(new i).update(t),n=e.digest();return e.clean(),n}function s(t,e){var n=new o(t).update(e),i=n.digest();return n.clean(),i}function a(t,e,n,i){var o=i[0];if(0===o)throw new Error("hkdf: cannot expand more");e.reset(),o>1&&e.update(t),n&&e.update(n),e.update(i),e.finish(t),i[0]++}t.HMAC=o,t.hash=r,t.default=r,t.hmac=s;var l=new Uint8Array(t.digestLength);t.hkdf=function(t,e,n,i){void 0===e&&(e=l),void 0===i&&(i=32);for(var r=new Uint8Array([1]),c=s(e,t),h=new o(c),u=new Uint8Array(h.digestLength),d=u.length,p=new Uint8Array(i),m=0;m<i;m++)d===u.length&&(a(u,h,n,r),d=0),p[m]=u[d++];return h.clean(),u.fill(0),r.fill(0),p},t.pbkdf2=function(t,e,n,i){for(var r=new o(t),s=r.digestLength,a=new Uint8Array(4),l=new Uint8Array(s),c=new Uint8Array(s),h=new Uint8Array(i),u=0;u*s<i;u++){var d=u+1;a[0]=d>>>24&255,a[1]=d>>>16&255,a[2]=d>>>8&255,a[3]=d>>>0&255,r.reset(),r.update(e),r.update(a),r.finish(c);for(var p=0;p<s;p++)l[p]=c[p];for(p=2;p<=n;p++){r.reset(),r.update(c).finish(c);for(var m=0;m<s;m++)l[m]^=c[m]}for(p=0;p<s&&u*s+p<i;p++)h[u*s+p]=l[p]}for(u=0;u<s;u++)l[u]=c[u]=0;for(u=0;u<4;u++)a[u]=0;return r.clean(),h}}(e);var o=e.default;for(var r in e)o[r]=e[r];"object"==typeof t.exports?t.exports=o:void 0===(i=function(){return o}.call(e,n,e,t))||(t.exports=i)}()},2787:(t,e,n)=>{"use strict";n.d(e,{I:()=>o});const i=new Uint32Array(65536),o=(t,e)=>{if(t.length<e.length){const n=e;e=t,t=n}return 0===e.length?t.length:t.length<=32?((t,e)=>{const n=t.length,o=e.length,r=1<<n-1;let s=-1,a=0,l=n,c=n;for(;c--;)i[t.charCodeAt(c)]|=1<<c;for(c=0;c<o;c++){let t=i[e.charCodeAt(c)];const n=t|a;t|=(t&s)+s^s,a|=~(t|s),s&=t,a&r&&l++,s&r&&l--,a=a<<1|1,s=s<<1|~(n|a),a&=n}for(c=n;c--;)i[t.charCodeAt(c)]=0;return l})(t,e):((t,e)=>{const n=e.length,o=t.length,r=[],s=[],a=Math.ceil(n/32),l=Math.ceil(o/32);for(let t=0;t<a;t++)s[t]=-1,r[t]=0;let c=0;for(;c<l-1;c++){let a=0,l=-1;const h=32*c,u=Math.min(32,o)+h;for(let e=h;e<u;e++)i[t.charCodeAt(e)]|=1<<e;for(let t=0;t<n;t++){const n=i[e.charCodeAt(t)],o=s[t/32|0]>>>t&1,c=r[t/32|0]>>>t&1,h=n|a,u=((n|c)&l)+l^l|n|c;let d=a|~(u|l),p=l&u;d>>>31^o&&(s[t/32|0]^=1<<t),p>>>31^c&&(r[t/32|0]^=1<<t),d=d<<1|o,p=p<<1|c,l=p|~(h|d),a=d&h}for(let e=h;e<u;e++)i[t.charCodeAt(e)]=0}let h=0,u=-1;const d=32*c,p=Math.min(32,o-d)+d;for(let e=d;e<p;e++)i[t.charCodeAt(e)]|=1<<e;let m=o;for(let t=0;t<n;t++){const n=i[e.charCodeAt(t)],a=s[t/32|0]>>>t&1,l=r[t/32|0]>>>t&1,c=n|h,d=((n|l)&u)+u^u|n|l;let p=h|~(d|u),f=u&d;m+=p>>>o-1&1,m-=f>>>o-1&1,p>>>31^a&&(s[t/32|0]^=1<<t),f>>>31^l&&(r[t/32|0]^=1<<t),p=p<<1|a,f=f<<1|l,u=f|~(c|p),h=p&c}for(let e=d;e<p;e++)i[t.charCodeAt(e)]=0;return m})(t,e)}},9937:t=>{t.exports={linLogMode:!1,outboundAttractionDistribution:!1,adjustSizes:!1,edgeWeightInfluence:1,scalingRatio:1,strongGravityMode:!1,gravity:1,slowDown:1,barnesHutOptimize:!1,barnesHutTheta:.5}},1782:(t,e)=>{e.assign=function(t){t=t||{};var e,n,i,o=Array.prototype.slice.call(arguments).slice(1);for(e=0,i=o.length;e<i;e++)if(o[e])for(n in o[e])t[n]=o[e][n];return t},e.validateSettings=function(t){return"linLogMode"in t&&"boolean"!=typeof t.linLogMode?{message:"the `linLogMode` setting should be a boolean."}:"outboundAttractionDistribution"in t&&"boolean"!=typeof t.outboundAttractionDistribution?{message:"the `outboundAttractionDistribution` setting should be a boolean."}:"adjustSizes"in t&&"boolean"!=typeof t.adjustSizes?{message:"the `adjustSizes` setting should be a boolean."}:"edgeWeightInfluence"in t&&"number"!=typeof t.edgeWeightInfluence?{message:"the `edgeWeightInfluence` setting should be a number."}:!("scalingRatio"in t)||"number"==typeof t.scalingRatio&&t.scalingRatio>=0?"strongGravityMode"in t&&"boolean"!=typeof t.strongGravityMode?{message:"the `strongGravityMode` setting should be a boolean."}:!("gravity"in t)||"number"==typeof t.gravity&&t.gravity>=0?"slowDown"in t&&!("number"==typeof t.slowDown||t.slowDown>=0)?{message:"the `slowDown` setting should be a number >= 0."}:"barnesHutOptimize"in t&&"boolean"!=typeof t.barnesHutOptimize?{message:"the `barnesHutOptimize` setting should be a boolean."}:!("barnesHutTheta"in t)||"number"==typeof t.barnesHutTheta&&t.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."}},e.graphToByteArrays=function(t,e){var n,i=t.order,o=t.size,r={},s=new Float32Array(10*i),a=new Float32Array(3*o);return n=0,t.forEachNode((function(t,e){r[t]=n,s[n]=e.x,s[n+1]=e.y,s[n+2]=0,s[n+3]=0,s[n+4]=0,s[n+5]=0,s[n+6]=1,s[n+7]=1,s[n+8]=e.size||1,s[n+9]=e.fixed?1:0,n+=10})),n=0,t.forEachEdge((function(t,i,o,l,c,h,u){var d=r[o],p=r[l],m=e(t,i,o,l,c,h,u);s[d+6]+=m,s[p+6]+=m,a[n]=d,a[n+1]=p,a[n+2]=m,n+=3})),{nodes:s,edges:a}},e.assignLayoutChanges=function(t,e,n){var i=0;t.updateEachNodeAttributes((function(t,o){return o.x=e[i],o.y=e[i+1],i+=10,n?n(t,o):o}))},e.readGraphPositions=function(t,e){var n=0;t.forEachNode((function(t,i){e[n]=i.x,e[n+1]=i.y,n+=10}))},e.collectLayoutChanges=function(t,e,n){for(var i=t.nodes(),o={},r=0,s=0,a=e.length;r<a;r+=10){if(n){var l=Object.assign({},t.getNodeAttributes(i[s]));l.x=e[r],l.y=e[r+1],l=n(i[s],l),o[i[s]]={x:l.x,y:l.y}}else o[i[s]]={x:e[r],y:e[r+1]};s++}return o},e.createWorker=function(t){var e=window.URL||window.webkitURL,n=t.toString(),i=e.createObjectURL(new Blob(["("+n+").call(this);"],{type:"text/javascript"})),o=new Worker(i);return e.revokeObjectURL(i),o}},8903:(t,e,n)=>{var i=n(1736),o=n(8153).Fd,r=n(2561),s=n(1782),a=n(9937);function l(t,e,n){if(!i(e))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,h="function"==typeof n.outputReducer?n.outputReducer:null,u=s.assign({},a,n.settings),d=s.validateSettings(u);if(d)throw new Error("graphology-layout-forceatlas2: "+d.message);var p,m=s.graphToByteArrays(e,c);for(p=0;p<l;p++)r(u,m.nodes,m.edges);if(!t)return s.collectLayoutChanges(e,m.nodes);s.assignLayoutChanges(e,m.nodes,h)}var c=l.bind(null,!1);c.assign=l.bind(null,!0),c.inferSettings=function(t){var e="number"==typeof t?t:t.order;return{barnesHutOptimize:e>2e3,strongGravityMode:!0,gravity:.05,scalingRatio:10,slowDown:1+Math.log(e)}},t.exports=c},2561:t=>{var e=10;t.exports=function(t,n,i){var o,r,s,a,l,c,h,u,d,p,m,f,g,y,b,v,w,C,A,S,x,E,M,T=n.length,_=i.length,I=t.adjustSizes,L=t.barnesHutTheta*t.barnesHutTheta,N=[];for(s=0;s<T;s+=e)n[s+4]=n[s+2],n[s+5]=n[s+3],n[s+2]=0,n[s+3]=0;if(t.outboundAttractionDistribution){for(m=0,s=0;s<T;s+=e)m+=n[s+6];m/=T/e}if(t.barnesHutOptimize){var P,$,R,k=1/0,O=-1/0,H=1/0,G=-1/0;for(s=0;s<T;s+=e)k=Math.min(k,n[s+0]),O=Math.max(O,n[s+0]),H=Math.min(H,n[s+1]),G=Math.max(G,n[s+1]);var F=O-k,B=G-H;for(F>B?G=(H-=(F-B)/2)+F:O=(k-=(B-F)/2)+B,N[0]=-1,N[1]=(k+O)/2,N[2]=(H+G)/2,N[3]=Math.max(O-k,G-H),N[4]=-1,N[5]=-1,N[6]=0,N[7]=0,N[8]=0,o=1,s=0;s<T;s+=e)for(r=0,R=3;;){if(!(N[r+5]>=0)){if(N[r+0]<0){N[r+0]=s;break}if(N[r+5]=9*o,u=N[r+3]/2,N[(d=N[r+5])+0]=-1,N[d+1]=N[r+1]-u,N[d+2]=N[r+2]-u,N[d+3]=u,N[d+4]=d+9,N[d+5]=-1,N[d+6]=0,N[d+7]=0,N[d+8]=0,N[(d+=9)+0]=-1,N[d+1]=N[r+1]-u,N[d+2]=N[r+2]+u,N[d+3]=u,N[d+4]=d+9,N[d+5]=-1,N[d+6]=0,N[d+7]=0,N[d+8]=0,N[(d+=9)+0]=-1,N[d+1]=N[r+1]+u,N[d+2]=N[r+2]-u,N[d+3]=u,N[d+4]=d+9,N[d+5]=-1,N[d+6]=0,N[d+7]=0,N[d+8]=0,N[(d+=9)+0]=-1,N[d+1]=N[r+1]+u,N[d+2]=N[r+2]+u,N[d+3]=u,N[d+4]=N[r+4],N[d+5]=-1,N[d+6]=0,N[d+7]=0,N[d+8]=0,o+=4,P=n[N[r+0]+0]<N[r+1]?n[N[r+0]+1]<N[r+2]?N[r+5]:N[r+5]+9:n[N[r+0]+1]<N[r+2]?N[r+5]+18:N[r+5]+27,N[r+6]=n[N[r+0]+6],N[r+7]=n[N[r+0]+0],N[r+8]=n[N[r+0]+1],N[P+0]=N[r+0],N[r+0]=-1,P===($=n[s+0]<N[r+1]?n[s+1]<N[r+2]?N[r+5]:N[r+5]+9:n[s+1]<N[r+2]?N[r+5]+18:N[r+5]+27)){if(R--){r=P;continue}R=3;break}N[$+0]=s;break}P=n[s+0]<N[r+1]?n[s+1]<N[r+2]?N[r+5]:N[r+5]+9:n[s+1]<N[r+2]?N[r+5]+18:N[r+5]+27,N[r+7]=(N[r+7]*N[r+6]+n[s+0]*n[s+6])/(N[r+6]+n[s+6]),N[r+8]=(N[r+8]*N[r+6]+n[s+1]*n[s+6])/(N[r+6]+n[s+6]),N[r+6]+=n[s+6],r=P}}if(t.barnesHutOptimize){for(f=t.scalingRatio,s=0;s<T;s+=e)for(r=0;;)if(N[r+5]>=0){if(v=Math.pow(n[s+0]-N[r+7],2)+Math.pow(n[s+1]-N[r+8],2),4*(p=N[r+3])*p/v<L){if(g=n[s+0]-N[r+7],y=n[s+1]-N[r+8],!0===I?v>0?(w=f*n[s+6]*N[r+6]/v,n[s+2]+=g*w,n[s+3]+=y*w):v<0&&(w=-f*n[s+6]*N[r+6]/Math.sqrt(v),n[s+2]+=g*w,n[s+3]+=y*w):v>0&&(w=f*n[s+6]*N[r+6]/v,n[s+2]+=g*w,n[s+3]+=y*w),(r=N[r+4])<0)break;continue}r=N[r+5]}else if((c=N[r+0])>=0&&c!==s&&(v=(g=n[s+0]-n[c+0])*g+(y=n[s+1]-n[c+1])*y,!0===I?v>0?(w=f*n[s+6]*n[c+6]/v,n[s+2]+=g*w,n[s+3]+=y*w):v<0&&(w=-f*n[s+6]*n[c+6]/Math.sqrt(v),n[s+2]+=g*w,n[s+3]+=y*w):v>0&&(w=f*n[s+6]*n[c+6]/v,n[s+2]+=g*w,n[s+3]+=y*w)),(r=N[r+4])<0)break}else for(f=t.scalingRatio,a=0;a<T;a+=e)for(l=0;l<a;l+=e)g=n[a+0]-n[l+0],y=n[a+1]-n[l+1],!0===I?(v=Math.sqrt(g*g+y*y)-n[a+8]-n[l+8])>0?(w=f*n[a+6]*n[l+6]/v/v,n[a+2]+=g*w,n[a+3]+=y*w,n[l+2]-=g*w,n[l+3]-=y*w):v<0&&(w=100*f*n[a+6]*n[l+6],n[a+2]+=g*w,n[a+3]+=y*w,n[l+2]-=g*w,n[l+3]-=y*w):(v=Math.sqrt(g*g+y*y))>0&&(w=f*n[a+6]*n[l+6]/v/v,n[a+2]+=g*w,n[a+3]+=y*w,n[l+2]-=g*w,n[l+3]-=y*w);for(d=t.gravity/t.scalingRatio,f=t.scalingRatio,s=0;s<T;s+=e)w=0,g=n[s+0],y=n[s+1],v=Math.sqrt(Math.pow(g,2)+Math.pow(y,2)),t.strongGravityMode?v>0&&(w=f*n[s+6]*d):v>0&&(w=f*n[s+6]*d/v),n[s+2]-=g*w,n[s+3]-=y*w;for(f=1*(t.outboundAttractionDistribution?m:1),h=0;h<_;h+=3)a=i[h+0],l=i[h+1],u=i[h+2],b=Math.pow(u,t.edgeWeightInfluence),g=n[a+0]-n[l+0],y=n[a+1]-n[l+1],!0===I?(v=Math.sqrt(g*g+y*y)-n[a+8]-n[l+8],t.linLogMode?t.outboundAttractionDistribution?v>0&&(w=-f*b*Math.log(1+v)/v/n[a+6]):v>0&&(w=-f*b*Math.log(1+v)/v):t.outboundAttractionDistribution?v>0&&(w=-f*b/n[a+6]):v>0&&(w=-f*b)):(v=Math.sqrt(Math.pow(g,2)+Math.pow(y,2)),t.linLogMode?t.outboundAttractionDistribution?v>0&&(w=-f*b*Math.log(1+v)/v/n[a+6]):v>0&&(w=-f*b*Math.log(1+v)/v):t.outboundAttractionDistribution?(v=1,w=-f*b/n[a+6]):(v=1,w=-f*b)),v>0&&(n[a+2]+=g*w,n[a+3]+=y*w,n[l+2]-=g*w,n[l+3]-=y*w);if(!0===I)for(s=0;s<T;s+=e)1!==n[s+9]&&((C=Math.sqrt(Math.pow(n[s+2],2)+Math.pow(n[s+3],2)))>10&&(n[s+2]=10*n[s+2]/C,n[s+3]=10*n[s+3]/C),A=n[s+6]*Math.sqrt((n[s+4]-n[s+2])*(n[s+4]-n[s+2])+(n[s+5]-n[s+3])*(n[s+5]-n[s+3])),S=Math.sqrt((n[s+4]+n[s+2])*(n[s+4]+n[s+2])+(n[s+5]+n[s+3])*(n[s+5]+n[s+3]))/2,x=.1*Math.log(1+S)/(1+Math.sqrt(A)),E=n[s+0]+n[s+2]*(x/t.slowDown),n[s+0]=E,M=n[s+1]+n[s+3]*(x/t.slowDown),n[s+1]=M);else for(s=0;s<T;s+=e)1!==n[s+9]&&(A=n[s+6]*Math.sqrt((n[s+4]-n[s+2])*(n[s+4]-n[s+2])+(n[s+5]-n[s+3])*(n[s+5]-n[s+3])),S=Math.sqrt((n[s+4]+n[s+2])*(n[s+4]+n[s+2])+(n[s+5]+n[s+3])*(n[s+5]+n[s+3]))/2,x=n[s+7]*Math.log(1+S)/(1+Math.sqrt(A)),n[s+7]=Math.min(1,Math.sqrt(x*(Math.pow(n[s+2],2)+Math.pow(n[s+3],2))/(1+Math.sqrt(A)))),E=n[s+0]+n[s+2]*(x/t.slowDown),n[s+0]=E,M=n[s+1]+n[s+3]*(x/t.slowDown),n[s+1]=M);return{}}},8153:(t,e)=>{function n(t){return"number"!=typeof t||isNaN(t)?1:t}e.Fd=function(t){return function(t,e){var n={},i=function(t){return void 0===t?e:t};"function"==typeof e&&(i=e);var o=function(e){return i(e[t])},r=function(){return i(void 0)};return"string"==typeof t?(n.fromAttributes=o,n.fromGraph=function(t,e){return o(t.getEdgeAttributes(e))},n.fromEntry=function(t,e){return o(e)},n.fromPartialEntry=n.fromEntry,n.fromMinimalEntry=n.fromEntry):"function"==typeof t?(n.fromAttributes=function(){throw new Error("graphology-utils/getters/createEdgeValueGetter: irrelevant usage.")},n.fromGraph=function(e,n){var o=e.extremities(n);return i(t(n,e.getEdgeAttributes(n),o[0],o[1],e.getNodeAttributes(o[0]),e.getNodeAttributes(o[1]),e.isUndirected(n)))},n.fromEntry=function(e,n,o,r,s,a,l){return i(t(e,n,o,r,s,a,l))},n.fromPartialEntry=function(e,n,o,r){return i(t(e,n,o,r))},n.fromMinimalEntry=function(e,n){return i(t(e,n))}):(n.fromAttributes=r,n.fromGraph=r,n.fromEntry=r,n.fromMinimalEntry=r),n}(t,n)}},1736:t=>{t.exports=function(t){return null!==t&&"object"==typeof t&&"function"==typeof t.addUndirectedEdgeWithKey&&"function"==typeof t.dropNode&&"boolean"==typeof t.multi}},934:function(t){t.exports=function(){"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}function e(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,i(t,e)}function n(t){return n=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},n(t)}function i(t,e){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},i(t,e)}function o(t,e,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(t){return!1}}()?Reflect.construct.bind():function(t,e,n){var o=[null];o.push.apply(o,e);var r=new(Function.bind.apply(t,o));return n&&i(r,n.prototype),r},o.apply(null,arguments)}function r(t){var e="function"==typeof Map?new Map:void 0;return r=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,s)}function s(){return o(t,arguments,n(this).constructor)}return s.prototype=Object.create(t.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),i(s,t)},r(t)}function s(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}var a=function(){for(var t=arguments[0],e=1,n=arguments.length;e<n;e++)if(arguments[e])for(var i in arguments[e])t[i]=arguments[e][i];return t};function l(t,e,n,i){var o=t._nodes.get(e),r=null;return o?r="mixed"===i?o.out&&o.out[n]||o.undirected&&o.undirected[n]:"directed"===i?o.out&&o.out[n]:o.undirected&&o.undirected[n]:r}function c(e){return"object"===t(e)&&null!==e}function h(t){var e;for(e in t)return!1;return!0}function u(t,e,n){Object.defineProperty(t,e,{enumerable:!1,configurable:!1,writable:!0,value:n})}function d(t,e,n){var i={enumerable:!0,configurable:!0};"function"==typeof n?i.get=n:(i.value=n,i.writable=!1),Object.defineProperty(t,e,i)}function p(t){return!(!c(t)||t.attributes&&!Array.isArray(t.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(t,e,n){return Function.prototype.apply.call(t,e,n)};m=g&&"function"==typeof g.ownKeys?g.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var b=Number.isNaN||function(t){return t!=t};function v(){v.init.call(this)}f.exports=v,f.exports.once=function(t,e){return new Promise((function(n,i){function o(n){t.removeListener(e,r),i(n)}function r(){"function"==typeof t.removeListener&&t.removeListener("error",o),n([].slice.call(arguments))}I(t,e,r,{once:!0}),"error"!==e&&function(t,e){"function"==typeof t.on&&I(t,"error",e,{once:!0})}(t,o)}))},v.EventEmitter=v,v.prototype._events=void 0,v.prototype._eventsCount=0,v.prototype._maxListeners=void 0;var w=10;function C(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function A(t){return void 0===t._maxListeners?v.defaultMaxListeners:t._maxListeners}function S(t,e,n,i){var o,r,s,a;if(C(n),void 0===(r=t._events)?(r=t._events=Object.create(null),t._eventsCount=0):(void 0!==r.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),r=t._events),s=r[e]),void 0===s)s=r[e]=n,++t._eventsCount;else if("function"==typeof s?s=r[e]=i?[n,s]:[s,n]:i?s.unshift(n):s.push(n),(o=A(t))>0&&s.length>o&&!s.warned){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=t,l.type=e,l.count=s.length,a=l,console&&console.warn&&console.warn(a)}return t}function x(){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(t,e,n){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},o=x.bind(i);return o.listener=n,i.wrapFn=o,o}function M(t,e,n){var i=t._events;if(void 0===i)return[];var o=i[e];return void 0===o?[]:"function"==typeof o?n?[o.listener||o]:[o]:n?function(t){for(var e=new Array(t.length),n=0;n<e.length;++n)e[n]=t[n].listener||t[n];return e}(o):_(o,o.length)}function T(t){var e=this._events;if(void 0!==e){var n=e[t];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function _(t,e){for(var n=new Array(e),i=0;i<e;++i)n[i]=t[i];return n}function I(t,e,n,i){if("function"==typeof t.on)i.once?t.once(e,n):t.on(e,n);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(e,(function o(r){i.once&&t.removeEventListener(e,o),n(r)}))}}function L(t){if("function"!=typeof t)throw new Error("obliterator/iterator: expecting a function!");this.next=t}Object.defineProperty(v,"defaultMaxListeners",{enumerable:!0,get:function(){return w},set:function(t){if("number"!=typeof t||t<0||b(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");w=t}}),v.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},v.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||b(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},v.prototype.getMaxListeners=function(){return A(this)},v.prototype.emit=function(t){for(var e=[],n=1;n<arguments.length;n++)e.push(arguments[n]);var i="error"===t,o=this._events;if(void 0!==o)i=i&&void 0===o.error;else if(!i)return!1;if(i){var r;if(e.length>0&&(r=e[0]),r instanceof Error)throw r;var s=new Error("Unhandled error."+(r?" ("+r.message+")":""));throw s.context=r,s}var a=o[t];if(void 0===a)return!1;if("function"==typeof a)y(a,this,e);else{var l=a.length,c=_(a,l);for(n=0;n<l;++n)y(c[n],this,e)}return!0},v.prototype.addListener=function(t,e){return S(this,t,e,!1)},v.prototype.on=v.prototype.addListener,v.prototype.prependListener=function(t,e){return S(this,t,e,!0)},v.prototype.once=function(t,e){return C(e),this.on(t,E(this,t,e)),this},v.prototype.prependOnceListener=function(t,e){return C(e),this.prependListener(t,E(this,t,e)),this},v.prototype.removeListener=function(t,e){var n,i,o,r,s;if(C(e),void 0===(i=this._events))return this;if(void 0===(n=i[t]))return this;if(n===e||n.listener===e)0==--this._eventsCount?this._events=Object.create(null):(delete i[t],i.removeListener&&this.emit("removeListener",t,n.listener||e));else if("function"!=typeof n){for(o=-1,r=n.length-1;r>=0;r--)if(n[r]===e||n[r].listener===e){s=n[r].listener,o=r;break}if(o<0)return this;0===o?n.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(n,o),1===n.length&&(i[t]=n[0]),void 0!==i.removeListener&&this.emit("removeListener",t,s||e)}return this},v.prototype.off=v.prototype.removeListener,v.prototype.removeAllListeners=function(t){var e,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[t]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[t]),this;if(0===arguments.length){var o,r=Object.keys(n);for(i=0;i<r.length;++i)"removeListener"!==(o=r[i])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=n[t]))this.removeListener(t,e);else if(void 0!==e)for(i=e.length-1;i>=0;i--)this.removeListener(t,e[i]);return this},v.prototype.listeners=function(t){return M(this,t,!0)},v.prototype.rawListeners=function(t){return M(this,t,!1)},v.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):T.call(t,e)},v.prototype.listenerCount=T,v.prototype.eventNames=function(){return this._eventsCount>0?m(this._events):[]},"undefined"!=typeof Symbol&&(L.prototype[Symbol.iterator]=function(){return this}),L.of=function(){var t=arguments,e=t.length,n=0;return new L((function(){return n>=e?{done:!0}:{done:!1,value:t[n++]}}))},L.empty=function(){return new L((function(){return{done:!0}}))},L.fromSequence=function(t){var e=0,n=t.length;return new L((function(){return e>=n?{done:!0}:{done:!1,value:t[e++]}}))},L.is=function(t){return t instanceof L||"object"==typeof t&&null!==t&&"function"==typeof t.next};var N=L,P={};P.ARRAY_BUFFER_SUPPORT="undefined"!=typeof ArrayBuffer,P.SYMBOL_SUPPORT="undefined"!=typeof Symbol;var $=N,R=P,k=R.ARRAY_BUFFER_SUPPORT,O=R.SYMBOL_SUPPORT,H=function(t){var e=function(t){return"string"==typeof t||Array.isArray(t)||k&&ArrayBuffer.isView(t)?$.fromSequence(t):"object"!=typeof t||null===t?null:O&&"function"==typeof t[Symbol.iterator]?t[Symbol.iterator]():"function"==typeof t.next?t:null}(t);if(!e)throw new Error("obliterator: target is not iterable nor a valid iterator.");return e},G=H,F=function(t,e){for(var n,i=arguments.length>1?e:1/0,o=i!==1/0?new Array(i):[],r=0,s=G(t);;){if(r===i)return o;if((n=s.next()).done)return r!==e&&(o.length=r),o;o[r++]=n.value}},B=function(t){function n(e){var n;return(n=t.call(this)||this).name="GraphError",n.message=e,n}return e(n,t),n}(r(Error)),D=function(t){function n(e){var i;return(i=t.call(this,e)||this).name="InvalidArgumentsGraphError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(s(i),n.prototype.constructor),i}return e(n,t),n}(B),V=function(t){function n(e){var i;return(i=t.call(this,e)||this).name="NotFoundGraphError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(s(i),n.prototype.constructor),i}return e(n,t),n}(B),W=function(t){function n(e){var i;return(i=t.call(this,e)||this).name="UsageGraphError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(s(i),n.prototype.constructor),i}return e(n,t),n}(B);function U(t,e){this.key=t,this.attributes=e,this.clear()}function j(t,e){this.key=t,this.attributes=e,this.clear()}function q(t,e){this.key=t,this.attributes=e,this.clear()}function z(t,e,n,i,o){this.key=e,this.attributes=o,this.undirected=t,this.source=n,this.target=i}function Y(t,e,n,i,o,r,s){var a,l,c,h;if(i=""+i,0===n){if(!(a=t._nodes.get(i)))throw new V("Graph.".concat(e,': could not find the "').concat(i,'" node in the graph.'));c=o,h=r}else if(3===n){if(o=""+o,!(l=t._edges.get(o)))throw new V("Graph.".concat(e,': could not find the "').concat(o,'" edge in the graph.'));var u=l.source.key,d=l.target.key;if(i===u)a=l.target;else{if(i!==d)throw new V("Graph.".concat(e,': the "').concat(i,'" node is not attached to the "').concat(o,'" edge (').concat(u,", ").concat(d,")."));a=l.source}c=r,h=s}else{if(!(l=t._edges.get(i)))throw new V("Graph.".concat(e,': could not find the "').concat(i,'" edge in the graph.'));a=1===n?l.source:l.target,c=o,h=r}return[a,c,h]}U.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}},j.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}},q.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}},z.prototype.attach=function(){var t="out",e="in";this.undirected&&(t=e="undirected");var n=this.source.key,i=this.target.key;this.source[t][i]=this,this.undirected&&n===i||(this.target[e][n]=this)},z.prototype.attachMulti=function(){var t="out",e="in",n=this.source.key,i=this.target.key;this.undirected&&(t=e="undirected");var o=this.source[t],r=o[i];if(void 0===r)return o[i]=this,void(this.undirected&&n===i||(this.target[e][n]=this));r.previous=this,this.next=r,o[i]=this,this.target[e][n]=this},z.prototype.detach=function(){var t=this.source.key,e=this.target.key,n="out",i="in";this.undirected&&(n=i="undirected"),delete this.source[n][e],delete this.target[i][t]},z.prototype.detachMulti=function(){var t=this.source.key,e=this.target.key,n="out",i="in";this.undirected&&(n=i="undirected"),void 0===this.previous?void 0===this.next?(delete this.source[n][e],delete this.target[i][t]):(this.next.previous=void 0,this.source[n][e]=this.next,this.target[i][t]=this.next):(this.previous.next=this.next,void 0!==this.next&&(this.next.previous=this.previous))};var K=[{name:function(t){return"get".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,i,o){var r=Y(this,e,n,t,i,o),s=r[0],a=r[1];return s.attributes[a]}}},{name:function(t){return"get".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,i){return Y(this,e,n,t,i)[0].attributes}}},{name:function(t){return"has".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,i,o){var r=Y(this,e,n,t,i,o),s=r[0],a=r[1];return s.attributes.hasOwnProperty(a)}}},{name:function(t){return"set".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,i,o,r){var s=Y(this,e,n,t,i,o,r),a=s[0],l=s[1],c=s[2];return a.attributes[l]=c,this.emit("nodeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:l}),this}}},{name:function(t){return"update".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,i,o,r){var s=Y(this,e,n,t,i,o,r),a=s[0],l=s[1],c=s[2];if("function"!=typeof c)throw new D("Graph.".concat(e,": updater should be a function."));var h=a.attributes,u=c(h[l]);return h[l]=u,this.emit("nodeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:l}),this}}},{name:function(t){return"remove".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,i,o){var r=Y(this,e,n,t,i,o),s=r[0],a=r[1];return delete s.attributes[a],this.emit("nodeAttributesUpdated",{key:s.key,type:"remove",attributes:s.attributes,name:a}),this}}},{name:function(t){return"replace".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,i,o){var r=Y(this,e,n,t,i,o),s=r[0],a=r[1];if(!c(a))throw new D("Graph.".concat(e,": provided attributes are not a plain object."));return s.attributes=a,this.emit("nodeAttributesUpdated",{key:s.key,type:"replace",attributes:s.attributes}),this}}},{name:function(t){return"merge".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,i,o){var r=Y(this,e,n,t,i,o),s=r[0],l=r[1];if(!c(l))throw new D("Graph.".concat(e,": provided attributes are not a plain object."));return a(s.attributes,l),this.emit("nodeAttributesUpdated",{key:s.key,type:"merge",attributes:s.attributes,data:l}),this}}},{name:function(t){return"update".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,i,o){var r=Y(this,e,n,t,i,o),s=r[0],a=r[1];if("function"!=typeof a)throw new D("Graph.".concat(e,": provided updater is not a function."));return s.attributes=a(s.attributes),this.emit("nodeAttributesUpdated",{key:s.key,type:"update",attributes:s.attributes}),this}}}],Z=[{name:function(t){return"get".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,i){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new W("Graph.".concat(e,": 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=""+t,s=""+i;if(i=arguments[2],!(o=l(this,r,s,n)))throw new V("Graph.".concat(e,': could not find an edge for the given path ("').concat(r,'" - "').concat(s,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(e,": 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(t=""+t,!(o=this._edges.get(t)))throw new V("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}return o.attributes[i]}}},{name:function(t){return"get".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t){var i;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>1){if(this.multi)throw new W("Graph.".concat(e,": 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=""+t,r=""+arguments[1];if(!(i=l(this,o,r,n)))throw new V("Graph.".concat(e,': could not find an edge for the given path ("').concat(o,'" - "').concat(r,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(e,": 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(t=""+t,!(i=this._edges.get(t)))throw new V("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}return i.attributes}}},{name:function(t){return"has".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,i){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new W("Graph.".concat(e,": 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=""+t,s=""+i;if(i=arguments[2],!(o=l(this,r,s,n)))throw new V("Graph.".concat(e,': could not find an edge for the given path ("').concat(r,'" - "').concat(s,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(e,": 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(t=""+t,!(o=this._edges.get(t)))throw new V("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}return o.attributes.hasOwnProperty(i)}}},{name:function(t){return"set".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,i,o){var r;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>3){if(this.multi)throw new W("Graph.".concat(e,": 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=""+t,a=""+i;if(i=arguments[2],o=arguments[3],!(r=l(this,s,a,n)))throw new V("Graph.".concat(e,': could not find an edge for the given path ("').concat(s,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(e,": 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(t=""+t,!(r=this._edges.get(t)))throw new V("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}return r.attributes[i]=o,this.emit("edgeAttributesUpdated",{key:r.key,type:"set",attributes:r.attributes,name:i}),this}}},{name:function(t){return"update".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,i,o){var r;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>3){if(this.multi)throw new W("Graph.".concat(e,": 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=""+t,a=""+i;if(i=arguments[2],o=arguments[3],!(r=l(this,s,a,n)))throw new V("Graph.".concat(e,': could not find an edge for the given path ("').concat(s,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(e,": 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(t=""+t,!(r=this._edges.get(t)))throw new V("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}if("function"!=typeof o)throw new D("Graph.".concat(e,": updater should be a function."));return r.attributes[i]=o(r.attributes[i]),this.emit("edgeAttributesUpdated",{key:r.key,type:"set",attributes:r.attributes,name:i}),this}}},{name:function(t){return"remove".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,i){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new W("Graph.".concat(e,": 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=""+t,s=""+i;if(i=arguments[2],!(o=l(this,r,s,n)))throw new V("Graph.".concat(e,': could not find an edge for the given path ("').concat(r,'" - "').concat(s,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(e,": 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(t=""+t,!(o=this._edges.get(t)))throw new V("Graph.".concat(e,': could not find the "').concat(t,'" 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(t){return"replace".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,i){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new W("Graph.".concat(e,": 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=""+t,s=""+i;if(i=arguments[2],!(o=l(this,r,s,n)))throw new V("Graph.".concat(e,': could not find an edge for the given path ("').concat(r,'" - "').concat(s,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(e,": 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(t=""+t,!(o=this._edges.get(t)))throw new V("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}if(!c(i))throw new D("Graph.".concat(e,": 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(t){return"merge".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,i){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new W("Graph.".concat(e,": 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=""+t,s=""+i;if(i=arguments[2],!(o=l(this,r,s,n)))throw new V("Graph.".concat(e,': could not find an edge for the given path ("').concat(r,'" - "').concat(s,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(e,": 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(t=""+t,!(o=this._edges.get(t)))throw new V("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}if(!c(i))throw new D("Graph.".concat(e,": 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(t){return"update".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,i){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new W("Graph.".concat(e,": 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=""+t,s=""+i;if(i=arguments[2],!(o=l(this,r,s,n)))throw new V("Graph.".concat(e,': could not find an edge for the given path ("').concat(r,'" - "').concat(s,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(e,": 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(t=""+t,!(o=this._edges.get(t)))throw new V("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}if("function"!=typeof i)throw new D("Graph.".concat(e,": 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=N,J=H,Q=function(){var t=arguments,e=null,n=-1;return new X((function(){for(var i=null;;){if(null===e){if(++n>=t.length)return{done:!0};e=J(t[n])}if(!0!==(i=e.next()).done)break;e=null}return i}))},tt=[{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 et(t,e,n,i){var o=!1;for(var r in e)if(r!==i){var s=e[r];if(o=n(s.key,s.attributes,s.source.key,s.target.key,s.source.attributes,s.target.attributes,s.undirected),t&&o)return s.key}}function nt(t,e,n,i){var o,r,s,a=!1;for(var l in e)if(l!==i){o=e[l];do{if(r=o.source,s=o.target,a=n(o.key,o.attributes,r.key,s.key,r.attributes,s.attributes,o.undirected),t&&a)return o.key;o=o.next}while(void 0!==o)}}function it(t,e){var n,i=Object.keys(t),o=i.length,r=0;return new N((function(){do{if(n)n=n.next;else{if(r>=o)return{done:!0};var s=i[r++];if(s===e){n=void 0;continue}n=t[s]}}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 ot(t,e,n,i){var o=e[n];if(o){var r=o.source,s=o.target;return i(o.key,o.attributes,r.key,s.key,r.attributes,s.attributes,o.undirected)&&t?o.key:void 0}}function rt(t,e,n,i){var o=e[n];if(o){var r=!1;do{if(r=i(o.key,o.attributes,o.source.key,o.target.key,o.source.attributes,o.target.attributes,o.undirected),t&&r)return o.key;o=o.next}while(void 0!==o)}}function st(t,e){var n=t[e];return void 0!==n.next?new N((function(){if(!n)return{done:!0};var t={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:t}})):N.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 at(t,e,n,i){if(0!==e.size)for(var o,r,s="mixed"!==n&&n!==e.type,a="undirected"===n,l=!1,c=e._edges.values();!0!==(o=c.next()).done;)if(r=o.value,!s||r.undirected===a){var h=r,u=h.key,d=h.attributes,p=h.source,m=h.target;if(l=i(u,d,p.key,m.key,p.attributes,m.attributes,r.undirected),t&&l)return u}}function lt(t,e,n,i,o,r){var s,a=e?nt:et;if("undirected"!==n){if("out"!==i&&(s=a(t,o.in,r),t&&s))return s;if("in"!==i&&(s=a(t,o.out,r,i?void 0:o.key),t&&s))return s}if("directed"!==n&&(s=a(t,o.undirected,r),t&&s))return s}function ct(t,e,n,i,o,r,s){var a,l=n?rt:ot;if("undirected"!==e){if(void 0!==o.in&&"out"!==i&&(a=l(t,o.in,r,s),t&&a))return a;if(void 0!==o.out&&"in"!==i&&(i||o.key!==r)&&(a=l(t,o.out,r,s),t&&a))return a}if("directed"!==e&&void 0!==o.undirected&&(a=l(t,o.undirected,r,s),t&&a))return a}var ht=[{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 ut(){this.A=null,this.B=null}function dt(t,e,n,i,o){for(var r in i){var s=i[r],a=s.source,l=s.target,c=a===n?l:a;if(!e||!e.has(c.key)){var h=o(c.key,c.attributes);if(t&&h)return c.key}}}function pt(t,e,n,i,o){if("mixed"!==e){if("undirected"===e)return dt(t,null,i,i.undirected,o);if("string"==typeof n)return dt(t,null,i,i[n],o)}var r,s=new ut;if("undirected"!==e){if("out"!==n){if(r=dt(t,null,i,i.in,o),t&&r)return r;s.wrap(i.in)}if("in"!==n){if(r=dt(t,s,i,i.out,o),t&&r)return r;s.wrap(i.out)}}if("directed"!==e&&(r=dt(t,s,i,i.undirected,o),t&&r))return r}function mt(t,e,n){var i=Object.keys(n),o=i.length,r=0;return new N((function(){var s=null;do{if(r>=o)return t&&t.wrap(n),{done:!0};var a=n[i[r++]],l=a.source,c=a.target;s=l===e?c:l,t&&t.has(s.key)&&(s=null)}while(null===s);return{done:!1,value:{neighbor:s.key,attributes:s.attributes}}}))}function ft(t,e,n,i,o){for(var r,s,a,l,c,h,u,d=i._nodes.values(),p=i.type;!0!==(r=d.next()).done;){var m=!1;if(s=r.value,"undirected"!==p)for(a in l=s.out){c=l[a];do{if(h=c.target,m=!0,u=o(s.key,h.key,s.attributes,h.attributes,c.key,c.attributes,c.undirected),t&&u)return c;c=c.next}while(c)}if("directed"!==p)for(a in l=s.undirected)if(!(e&&s.key>a)){c=l[a];do{if((h=c.target).key!==a&&(h=c.source),m=!0,u=o(s.key,h.key,s.attributes,h.attributes,c.key,c.attributes,c.undirected),t&&u)return c;c=c.next}while(c)}if(n&&!m&&(u=o(s.key,null,s.attributes,null,null,null,null),t&&u))return null}}function gt(t){if(!c(t))throw new D('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in t))throw new D("Graph.import: serialized node is missing its key.");if("attributes"in t&&(!c(t.attributes)||null===t.attributes))throw new D("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function yt(t){if(!c(t))throw new D('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in t))throw new D("Graph.import: serialized edge is missing its source.");if(!("target"in t))throw new D("Graph.import: serialized edge is missing its target.");if("attributes"in t&&(!c(t.attributes)||null===t.attributes))throw new D("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in t&&"boolean"!=typeof t.undirected)throw new D("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}ut.prototype.wrap=function(t){null===this.A?this.A=t:null===this.B&&(this.B=t)},ut.prototype.has=function(t){return null!==this.A&&t in this.A||null!==this.B&&t in this.B};var bt,vt=(bt=255&Math.floor(256*Math.random()),function(){return bt++}),wt=new Set(["directed","undirected","mixed"]),Ct=new Set(["domain","_events","_eventsCount","_maxListeners"]),At={allowSelfLoops:!0,multi:!1,type:"mixed"};function St(t,e,n){var i=new t.NodeDataClass(e,n);return t._nodes.set(e,i),t.emit("nodeAdded",{key:e,attributes:n}),i}function xt(t,e,n,i,o,r,s,a){if(!i&&"undirected"===t.type)throw new W("Graph.".concat(e,": you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead."));if(i&&"directed"===t.type)throw new W("Graph.".concat(e,": you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead."));if(a&&!c(a))throw new D("Graph.".concat(e,': invalid attributes. Expecting an object but got "').concat(a,'"'));if(r=""+r,s=""+s,a=a||{},!t.allowSelfLoops&&r===s)throw new W("Graph.".concat(e,': source & target are the same ("').concat(r,"\"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false."));var l=t._nodes.get(r),h=t._nodes.get(s);if(!l)throw new V("Graph.".concat(e,': source node "').concat(r,'" not found.'));if(!h)throw new V("Graph.".concat(e,': target node "').concat(s,'" not found.'));var u={key:null,undirected:i,source:r,target:s,attributes:a};if(n)o=t._edgeKeyGenerator();else if(o=""+o,t._edges.has(o))throw new W("Graph.".concat(e,': the "').concat(o,'" edge already exists in the graph.'));if(!t.multi&&(i?void 0!==l.undirected[s]:void 0!==l.out[s]))throw new W("Graph.".concat(e,': an edge linking "').concat(r,'" to "').concat(s,"\" 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 z(i,o,l,h,a);t._edges.set(o,d);var p=r===s;return i?(l.undirectedDegree++,h.undirectedDegree++,p&&(l.undirectedLoops++,t._undirectedSelfLoopCount++)):(l.outDegree++,h.inDegree++,p&&(l.directedLoops++,t._directedSelfLoopCount++)),t.multi?d.attachMulti():d.attach(),i?t._undirectedSize++:t._directedSize++,u.key=o,t.emit("edgeAdded",u),o}function Et(t,e,n,i,o,r,s,l,h){if(!i&&"undirected"===t.type)throw new W("Graph.".concat(e,": you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead."));if(i&&"directed"===t.type)throw new W("Graph.".concat(e,": you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead."));if(l)if(h){if("function"!=typeof l)throw new D("Graph.".concat(e,': invalid updater function. Expecting a function but got "').concat(l,'"'))}else if(!c(l))throw new D("Graph.".concat(e,': invalid attributes. Expecting an object but got "').concat(l,'"'));var u;if(r=""+r,s=""+s,h&&(u=l,l=void 0),!t.allowSelfLoops&&r===s)throw new W("Graph.".concat(e,': source & target are the same ("').concat(r,"\"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false."));var d,p,m=t._nodes.get(r),f=t._nodes.get(s);if(!n&&(d=t._edges.get(o))){if(!(d.source.key===r&&d.target.key===s||i&&d.source.key===s&&d.target.key===r))throw new W("Graph.".concat(e,': inconsistency detected when attempting to merge the "').concat(o,'" edge with "').concat(r,'" source & "').concat(s,'" target vs. ("').concat(d.source.key,'", "').concat(d.target.key,'").'));p=d}if(p||t.multi||!m||(p=i?m.undirected[s]:m.out[s]),p){var g=[p.key,!1,!1,!1];if(h?!u:!l)return g;if(h){var y=p.attributes;p.attributes=u(y),t.emit("edgeAttributesUpdated",{type:"replace",key:p.key,attributes:p.attributes})}else a(p.attributes,l),t.emit("edgeAttributesUpdated",{type:"merge",key:p.key,attributes:p.attributes,data:l});return g}l=l||{},h&&u&&(l=u(l));var b={key:null,undirected:i,source:r,target:s,attributes:l};if(n)o=t._edgeKeyGenerator();else if(o=""+o,t._edges.has(o))throw new W("Graph.".concat(e,': the "').concat(o,'" edge already exists in the graph.'));var v=!1,w=!1;m||(m=St(t,r,{}),v=!0,r===s&&(f=m,w=!0)),f||(f=St(t,s,{}),w=!0),d=new z(i,o,m,f,l),t._edges.set(o,d);var C=r===s;return i?(m.undirectedDegree++,f.undirectedDegree++,C&&(m.undirectedLoops++,t._undirectedSelfLoopCount++)):(m.outDegree++,f.inDegree++,C&&(m.directedLoops++,t._directedSelfLoopCount++)),t.multi?d.attachMulti():d.attach(),i?t._undirectedSize++:t._directedSize++,b.key=o,t.emit("edgeAdded",b),[o,!0,v,w]}function Mt(t,e){t._edges.delete(e.key);var n=e.source,i=e.target,o=e.attributes,r=e.undirected,s=n===i;r?(n.undirectedDegree--,i.undirectedDegree--,s&&(n.undirectedLoops--,t._undirectedSelfLoopCount--)):(n.outDegree--,i.inDegree--,s&&(n.directedLoops--,t._directedSelfLoopCount--)),t.multi?e.detachMulti():e.detach(),r?t._undirectedSize--:t._directedSize--,t.emit("edgeDropped",{key:e.key,attributes:o,source:n.key,target:i.key,undirected:r})}var Tt=function(n){function i(t){var e;if(e=n.call(this)||this,"boolean"!=typeof(t=a({},At,t)).multi)throw new D("Graph.constructor: invalid 'multi' option. Expecting a boolean but got \"".concat(t.multi,'".'));if(!wt.has(t.type))throw new D('Graph.constructor: invalid \'type\' option. Should be one of "mixed", "directed" or "undirected" but got "'.concat(t.type,'".'));if("boolean"!=typeof t.allowSelfLoops)throw new D("Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got \"".concat(t.allowSelfLoops,'".'));var i="mixed"===t.type?U:"directed"===t.type?j:q;u(s(e),"NodeDataClass",i);var o="geid_"+vt()+"_",r=0;return u(s(e),"_attributes",{}),u(s(e),"_nodes",new Map),u(s(e),"_edges",new Map),u(s(e),"_directedSize",0),u(s(e),"_undirectedSize",0),u(s(e),"_directedSelfLoopCount",0),u(s(e),"_undirectedSelfLoopCount",0),u(s(e),"_edgeKeyGenerator",(function(){var t;do{t=o+r++}while(e._edges.has(t));return t})),u(s(e),"_options",t),Ct.forEach((function(t){return u(s(e),t,e[t])})),d(s(e),"order",(function(){return e._nodes.size})),d(s(e),"size",(function(){return e._edges.size})),d(s(e),"directedSize",(function(){return e._directedSize})),d(s(e),"undirectedSize",(function(){return e._undirectedSize})),d(s(e),"selfLoopCount",(function(){return e._directedSelfLoopCount+e._undirectedSelfLoopCount})),d(s(e),"directedSelfLoopCount",(function(){return e._directedSelfLoopCount})),d(s(e),"undirectedSelfLoopCount",(function(){return e._undirectedSelfLoopCount})),d(s(e),"multi",e._options.multi),d(s(e),"type",e._options.type),d(s(e),"allowSelfLoops",e._options.allowSelfLoops),d(s(e),"implementation",(function(){return"graphology"})),e}e(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(t){return this._nodes.has(""+t)},o.hasDirectedEdge=function(t,e){if("undirected"===this.type)return!1;if(1===arguments.length){var n=""+t,i=this._edges.get(n);return!!i&&!i.undirected}if(2===arguments.length){t=""+t,e=""+e;var o=this._nodes.get(t);return!!o&&o.out.hasOwnProperty(e)}throw new D("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(t,e){if("directed"===this.type)return!1;if(1===arguments.length){var n=""+t,i=this._edges.get(n);return!!i&&i.undirected}if(2===arguments.length){t=""+t,e=""+e;var o=this._nodes.get(t);return!!o&&o.undirected.hasOwnProperty(e)}throw new D("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(t,e){if(1===arguments.length){var n=""+t;return this._edges.has(n)}if(2===arguments.length){t=""+t,e=""+e;var i=this._nodes.get(t);return!!i&&(void 0!==i.out&&i.out.hasOwnProperty(e)||void 0!==i.undirected&&i.undirected.hasOwnProperty(e))}throw new D("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(t,e){if("undirected"!==this.type){if(t=""+t,e=""+e,this.multi)throw new W("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(t);if(!n)throw new V('Graph.directedEdge: could not find the "'.concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new V('Graph.directedEdge: could not find the "'.concat(e,'" target node in the graph.'));var i=n.out&&n.out[e]||void 0;return i?i.key:void 0}},o.undirectedEdge=function(t,e){if("directed"!==this.type){if(t=""+t,e=""+e,this.multi)throw new W("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(t);if(!n)throw new V('Graph.undirectedEdge: could not find the "'.concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new V('Graph.undirectedEdge: could not find the "'.concat(e,'" target node in the graph.'));var i=n.undirected&&n.undirected[e]||void 0;return i?i.key:void 0}},o.edge=function(t,e){if(this.multi)throw new W("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new V('Graph.edge: could not find the "'.concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new V('Graph.edge: could not find the "'.concat(e,'" target node in the graph.'));var i=n.out&&n.out[e]||n.undirected&&n.undirected[e]||void 0;if(i)return i.key},o.areDirectedNeighbors=function(t,e){t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new V('Graph.areDirectedNeighbors: could not find the "'.concat(t,'" node in the graph.'));return"undirected"!==this.type&&(e in n.in||e in n.out)},o.areOutNeighbors=function(t,e){t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new V('Graph.areOutNeighbors: could not find the "'.concat(t,'" node in the graph.'));return"undirected"!==this.type&&e in n.out},o.areInNeighbors=function(t,e){t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new V('Graph.areInNeighbors: could not find the "'.concat(t,'" node in the graph.'));return"undirected"!==this.type&&e in n.in},o.areUndirectedNeighbors=function(t,e){t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new V('Graph.areUndirectedNeighbors: could not find the "'.concat(t,'" node in the graph.'));return"directed"!==this.type&&e in n.undirected},o.areNeighbors=function(t,e){t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new V('Graph.areNeighbors: could not find the "'.concat(t,'" node in the graph.'));return"undirected"!==this.type&&(e in n.in||e in n.out)||"directed"!==this.type&&e in n.undirected},o.areInboundNeighbors=function(t,e){t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new V('Graph.areInboundNeighbors: could not find the "'.concat(t,'" node in the graph.'));return"undirected"!==this.type&&e in n.in||"directed"!==this.type&&e in n.undirected},o.areOutboundNeighbors=function(t,e){t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new V('Graph.areOutboundNeighbors: could not find the "'.concat(t,'" node in the graph.'));return"undirected"!==this.type&&e in n.out||"directed"!==this.type&&e in n.undirected},o.inDegree=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new V('Graph.inDegree: could not find the "'.concat(t,'" node in the graph.'));return"undirected"===this.type?0:e.inDegree},o.outDegree=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new V('Graph.outDegree: could not find the "'.concat(t,'" node in the graph.'));return"undirected"===this.type?0:e.outDegree},o.directedDegree=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new V('Graph.directedDegree: could not find the "'.concat(t,'" node in the graph.'));return"undirected"===this.type?0:e.inDegree+e.outDegree},o.undirectedDegree=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new V('Graph.undirectedDegree: could not find the "'.concat(t,'" node in the graph.'));return"directed"===this.type?0:e.undirectedDegree},o.inboundDegree=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new V('Graph.inboundDegree: could not find the "'.concat(t,'" node in the graph.'));var n=0;return"directed"!==this.type&&(n+=e.undirectedDegree),"undirected"!==this.type&&(n+=e.inDegree),n},o.outboundDegree=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new V('Graph.outboundDegree: could not find the "'.concat(t,'" node in the graph.'));var n=0;return"directed"!==this.type&&(n+=e.undirectedDegree),"undirected"!==this.type&&(n+=e.outDegree),n},o.degree=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new V('Graph.degree: could not find the "'.concat(t,'" node in the graph.'));var n=0;return"directed"!==this.type&&(n+=e.undirectedDegree),"undirected"!==this.type&&(n+=e.inDegree+e.outDegree),n},o.inDegreeWithoutSelfLoops=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new V('Graph.inDegreeWithoutSelfLoops: could not find the "'.concat(t,'" node in the graph.'));return"undirected"===this.type?0:e.inDegree-e.directedLoops},o.outDegreeWithoutSelfLoops=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new V('Graph.outDegreeWithoutSelfLoops: could not find the "'.concat(t,'" node in the graph.'));return"undirected"===this.type?0:e.outDegree-e.directedLoops},o.directedDegreeWithoutSelfLoops=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new V('Graph.directedDegreeWithoutSelfLoops: could not find the "'.concat(t,'" node in the graph.'));return"undirected"===this.type?0:e.inDegree+e.outDegree-2*e.directedLoops},o.undirectedDegreeWithoutSelfLoops=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new V('Graph.undirectedDegreeWithoutSelfLoops: could not find the "'.concat(t,'" node in the graph.'));return"directed"===this.type?0:e.undirectedDegree-2*e.undirectedLoops},o.inboundDegreeWithoutSelfLoops=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new V('Graph.inboundDegreeWithoutSelfLoops: could not find the "'.concat(t,'" node in the graph.'));var n=0,i=0;return"directed"!==this.type&&(n+=e.undirectedDegree,i+=2*e.undirectedLoops),"undirected"!==this.type&&(n+=e.inDegree,i+=e.directedLoops),n-i},o.outboundDegreeWithoutSelfLoops=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new V('Graph.outboundDegreeWithoutSelfLoops: could not find the "'.concat(t,'" node in the graph.'));var n=0,i=0;return"directed"!==this.type&&(n+=e.undirectedDegree,i+=2*e.undirectedLoops),"undirected"!==this.type&&(n+=e.outDegree,i+=e.directedLoops),n-i},o.degreeWithoutSelfLoops=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new V('Graph.degreeWithoutSelfLoops: could not find the "'.concat(t,'" node in the graph.'));var n=0,i=0;return"directed"!==this.type&&(n+=e.undirectedDegree,i+=2*e.undirectedLoops),"undirected"!==this.type&&(n+=e.inDegree+e.outDegree,i+=2*e.directedLoops),n-i},o.source=function(t){t=""+t;var e=this._edges.get(t);if(!e)throw new V('Graph.source: could not find the "'.concat(t,'" edge in the graph.'));return e.source.key},o.target=function(t){t=""+t;var e=this._edges.get(t);if(!e)throw new V('Graph.target: could not find the "'.concat(t,'" edge in the graph.'));return e.target.key},o.extremities=function(t){t=""+t;var e=this._edges.get(t);if(!e)throw new V('Graph.extremities: could not find the "'.concat(t,'" edge in the graph.'));return[e.source.key,e.target.key]},o.opposite=function(t,e){t=""+t,e=""+e;var n=this._edges.get(e);if(!n)throw new V('Graph.opposite: could not find the "'.concat(e,'" edge in the graph.'));var i=n.source.key,o=n.target.key;if(t===i)return o;if(t===o)return i;throw new V('Graph.opposite: the "'.concat(t,'" node is not attached to the "').concat(e,'" edge (').concat(i,", ").concat(o,")."))},o.hasExtremity=function(t,e){t=""+t,e=""+e;var n=this._edges.get(t);if(!n)throw new V('Graph.hasExtremity: could not find the "'.concat(t,'" edge in the graph.'));return n.source.key===e||n.target.key===e},o.isUndirected=function(t){t=""+t;var e=this._edges.get(t);if(!e)throw new V('Graph.isUndirected: could not find the "'.concat(t,'" edge in the graph.'));return e.undirected},o.isDirected=function(t){t=""+t;var e=this._edges.get(t);if(!e)throw new V('Graph.isDirected: could not find the "'.concat(t,'" edge in the graph.'));return!e.undirected},o.isSelfLoop=function(t){t=""+t;var e=this._edges.get(t);if(!e)throw new V('Graph.isSelfLoop: could not find the "'.concat(t,'" edge in the graph.'));return e.source===e.target},o.addNode=function(t,e){var n=function(t,e,n){if(n&&!c(n))throw new D('Graph.addNode: invalid attributes. Expecting an object but got "'.concat(n,'"'));if(e=""+e,n=n||{},t._nodes.has(e))throw new W('Graph.addNode: the "'.concat(e,'" node already exist in the graph.'));var i=new t.NodeDataClass(e,n);return t._nodes.set(e,i),t.emit("nodeAdded",{key:e,attributes:n}),i}(this,t,e);return n.key},o.mergeNode=function(t,e){if(e&&!c(e))throw new D('Graph.mergeNode: invalid attributes. Expecting an object but got "'.concat(e,'"'));t=""+t,e=e||{};var n=this._nodes.get(t);return n?(e&&(a(n.attributes,e),this.emit("nodeAttributesUpdated",{type:"merge",key:t,attributes:n.attributes,data:e})),[t,!1]):(n=new this.NodeDataClass(t,e),this._nodes.set(t,n),this.emit("nodeAdded",{key:t,attributes:e}),[t,!0])},o.updateNode=function(t,e){if(e&&"function"!=typeof e)throw new D('Graph.updateNode: invalid updater function. Expecting a function but got "'.concat(e,'"'));t=""+t;var n=this._nodes.get(t);if(n){if(e){var i=n.attributes;n.attributes=e(i),this.emit("nodeAttributesUpdated",{type:"replace",key:t,attributes:n.attributes})}return[t,!1]}var o=e?e({}):{};return n=new this.NodeDataClass(t,o),this._nodes.set(t,n),this.emit("nodeAdded",{key:t,attributes:o}),[t,!0]},o.dropNode=function(t){t=""+t;var e,n=this._nodes.get(t);if(!n)throw new V('Graph.dropNode: could not find the "'.concat(t,'" node in the graph.'));if("undirected"!==this.type){for(var i in n.out){e=n.out[i];do{Mt(this,e),e=e.next}while(e)}for(var o in n.in){e=n.in[o];do{Mt(this,e),e=e.next}while(e)}}if("directed"!==this.type)for(var r in n.undirected){e=n.undirected[r];do{Mt(this,e),e=e.next}while(e)}this._nodes.delete(t),this.emit("nodeDropped",{key:t,attributes:n.attributes})},o.dropEdge=function(t){var e;if(arguments.length>1){var n=""+arguments[0],i=""+arguments[1];if(!(e=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(t=""+t,!(e=this._edges.get(t)))throw new V('Graph.dropEdge: could not find the "'.concat(t,'" edge in the graph.'));return Mt(this,e),this},o.dropDirectedEdge=function(t,e){if(arguments.length<2)throw new W("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 W("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,t=""+t,e=""+e,"directed");if(!n)throw new V('Graph.dropDirectedEdge: could not find a "'.concat(t,'" -> "').concat(e,'" edge in the graph.'));return Mt(this,n),this},o.dropUndirectedEdge=function(t,e){if(arguments.length<2)throw new W("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 W("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,t,e,"undirected");if(!n)throw new V('Graph.dropUndirectedEdge: could not find a "'.concat(t,'" -> "').concat(e,'" edge in the graph.'));return Mt(this,n),this},o.clear=function(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")},o.clearEdges=function(){for(var t,e=this._nodes.values();!0!==(t=e.next()).done;)t.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")},o.getAttribute=function(t){return this._attributes[t]},o.getAttributes=function(){return this._attributes},o.hasAttribute=function(t){return this._attributes.hasOwnProperty(t)},o.setAttribute=function(t,e){return this._attributes[t]=e,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:t}),this},o.updateAttribute=function(t,e){if("function"!=typeof e)throw new D("Graph.updateAttribute: updater should be a function.");var n=this._attributes[t];return this._attributes[t]=e(n),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:t}),this},o.removeAttribute=function(t){return delete this._attributes[t],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:t}),this},o.replaceAttributes=function(t){if(!c(t))throw new D("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=t,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this},o.mergeAttributes=function(t){if(!c(t))throw new D("Graph.mergeAttributes: provided attributes are not a plain object.");return a(this._attributes,t),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:t}),this},o.updateAttributes=function(t){if("function"!=typeof t)throw new D("Graph.updateAttributes: provided updater is not a function.");return this._attributes=t(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this},o.updateEachNodeAttributes=function(t,e){if("function"!=typeof t)throw new D("Graph.updateEachNodeAttributes: expecting an updater function.");if(e&&!p(e))throw new D("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=t(i.key,i.attributes);this.emit("eachNodeAttributesUpdated",{hints:e||null})},o.updateEachEdgeAttributes=function(t,e){if("function"!=typeof t)throw new D("Graph.updateEachEdgeAttributes: expecting an updater function.");if(e&&!p(e))throw new D("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");for(var n,i,o,r,s=this._edges.values();!0!==(n=s.next()).done;)o=(i=n.value).source,r=i.target,i.attributes=t(i.key,i.attributes,o.key,r.key,o.attributes,r.attributes,i.undirected);this.emit("eachEdgeAttributesUpdated",{hints:e||null})},o.forEachAdjacencyEntry=function(t){if("function"!=typeof t)throw new D("Graph.forEachAdjacencyEntry: expecting a callback.");ft(!1,!1,!1,this,t)},o.forEachAdjacencyEntryWithOrphans=function(t){if("function"!=typeof t)throw new D("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");ft(!1,!1,!0,this,t)},o.forEachAssymetricAdjacencyEntry=function(t){if("function"!=typeof t)throw new D("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");ft(!1,!0,!1,this,t)},o.forEachAssymetricAdjacencyEntryWithOrphans=function(t){if("function"!=typeof t)throw new D("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");ft(!1,!0,!0,this,t)},o.nodes=function(){return"function"==typeof Array.from?Array.from(this._nodes.keys()):F(this._nodes.keys(),this._nodes.size)},o.forEachNode=function(t){if("function"!=typeof t)throw new D("Graph.forEachNode: expecting a callback.");for(var e,n,i=this._nodes.values();!0!==(e=i.next()).done;)t((n=e.value).key,n.attributes)},o.findNode=function(t){if("function"!=typeof t)throw new D("Graph.findNode: expecting a callback.");for(var e,n,i=this._nodes.values();!0!==(e=i.next()).done;)if(t((n=e.value).key,n.attributes))return n.key},o.mapNodes=function(t){if("function"!=typeof t)throw new D("Graph.mapNode: expecting a callback.");for(var e,n,i=this._nodes.values(),o=new Array(this.order),r=0;!0!==(e=i.next()).done;)n=e.value,o[r++]=t(n.key,n.attributes);return o},o.someNode=function(t){if("function"!=typeof t)throw new D("Graph.someNode: expecting a callback.");for(var e,n,i=this._nodes.values();!0!==(e=i.next()).done;)if(t((n=e.value).key,n.attributes))return!0;return!1},o.everyNode=function(t){if("function"!=typeof t)throw new D("Graph.everyNode: expecting a callback.");for(var e,n,i=this._nodes.values();!0!==(e=i.next()).done;)if(!t((n=e.value).key,n.attributes))return!1;return!0},o.filterNodes=function(t){if("function"!=typeof t)throw new D("Graph.filterNodes: expecting a callback.");for(var e,n,i=this._nodes.values(),o=[];!0!==(e=i.next()).done;)t((n=e.value).key,n.attributes)&&o.push(n.key);return o},o.reduceNodes=function(t,e){if("function"!=typeof t)throw new D("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new D("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=e,r=this._nodes.values();!0!==(n=r.next()).done;)o=t(o,(i=n.value).key,i.attributes);return o},o.nodeEntries=function(){var t=this._nodes.values();return new N((function(){var e=t.next();if(e.done)return e;var n=e.value;return{value:{node:n.key,attributes:n.attributes},done:!1}}))},o.export=function(){var t=this,e=new Array(this._nodes.size),n=0;this._nodes.forEach((function(t,i){e[n++]=function(t,e){var n={key:t};return h(e.attributes)||(n.attributes=a({},e.attributes)),n}(i,t)}));var i=new Array(this._edges.size);return n=0,this._edges.forEach((function(e,o){i[n++]=function(t,e,n){var i={key:e,source:n.source.key,target:n.target.key};return h(n.attributes)||(i.attributes=a({},n.attributes)),"mixed"===t&&n.undirected&&(i.undirected=!0),i}(t.type,o,e)})),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:e,edges:i}},o.import=function(t){var e,n,o,r,s,a=this,l=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(t instanceof i)return t.forEachNode((function(t,e){l?a.mergeNode(t,e):a.addNode(t,e)})),t.forEachEdge((function(t,e,n,i,o,r,s){l?s?a.mergeUndirectedEdgeWithKey(t,n,i,e):a.mergeDirectedEdgeWithKey(t,n,i,e):s?a.addUndirectedEdgeWithKey(t,n,i,e):a.addDirectedEdgeWithKey(t,n,i,e)})),this;if(!c(t))throw new D("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(t.attributes){if(!c(t.attributes))throw new D("Graph.import: invalid attributes. Expecting a plain object.");l?this.mergeAttributes(t.attributes):this.replaceAttributes(t.attributes)}if(t.nodes){if(o=t.nodes,!Array.isArray(o))throw new D("Graph.import: invalid nodes. Expecting an array.");for(e=0,n=o.length;e<n;e++){gt(r=o[e]);var h=r,u=h.key,d=h.attributes;l?this.mergeNode(u,d):this.addNode(u,d)}}if(t.edges){var p=!1;if("undirected"===this.type&&(p=!0),o=t.edges,!Array.isArray(o))throw new D("Graph.import: invalid edges. Expecting an array.");for(e=0,n=o.length;e<n;e++){yt(s=o[e]);var m=s,f=m.source,g=m.target,y=m.attributes,b=m.undirected,v=void 0===b?p:b;"key"in s?(l?v?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:v?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey).call(this,s.key,f,g,y):(l?v?this.mergeUndirectedEdge:this.mergeDirectedEdge:v?this.addUndirectedEdge:this.addDirectedEdge).call(this,f,g,y)}}return this},o.nullCopy=function(t){var e=new i(a({},this._options,t));return e.replaceAttributes(a({},this.getAttributes())),e},o.emptyCopy=function(t){var e=this.nullCopy(t);return this._nodes.forEach((function(t,n){var i=a({},t.attributes);t=new e.NodeDataClass(n,i),e._nodes.set(n,t)})),e},o.copy=function(t){if("string"==typeof(t=t||{}).type&&t.type!==this.type&&"mixed"!==t.type)throw new W('Graph.copy: cannot create an incompatible copy from "'.concat(this.type,'" type to "').concat(t.type,'" because this would mean losing information about the current graph.'));if("boolean"==typeof t.multi&&t.multi!==this.multi&&!0!==t.multi)throw new W("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 t.allowSelfLoops&&t.allowSelfLoops!==this.allowSelfLoops&&!0!==t.allowSelfLoops)throw new W("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 e,n,i=this.emptyCopy(t),o=this._edges.values();!0!==(e=o.next()).done;)xt(i,"copy",!1,(n=e.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 e=this,n={};this._nodes.forEach((function(t,e){n[e]=t.attributes}));var i={},o={};this._edges.forEach((function(t,n){var r,s=t.undirected?"--":"->",a="",l=t.source.key,c=t.target.key;t.undirected&&l>c&&(r=l,l=c,c=r);var h="(".concat(l,")").concat(s,"(").concat(c,")");n.startsWith("geid_")?e.multi&&(void 0===o[h]?o[h]=0:o[h]++,a+="".concat(o[h],". ")):a+="[".concat(n,"]: "),i[a+=h]=t.attributes}));var r={};for(var s in this)this.hasOwnProperty(s)&&!Ct.has(s)&&"function"!=typeof this[s]&&"symbol"!==t(s)&&(r[s]=this[s]);return r.attributes=this._attributes,r.nodes=n,r.edges=i,u(r,"constructor",this.constructor),r},i}(f.exports.EventEmitter);"undefined"!=typeof Symbol&&(Tt.prototype[Symbol.for("nodejs.util.inspect.custom")]=Tt.prototype.inspect),[{name:function(t){return"".concat(t,"Edge")},generateKey:!0},{name:function(t){return"".concat(t,"DirectedEdge")},generateKey:!0,type:"directed"},{name:function(t){return"".concat(t,"UndirectedEdge")},generateKey:!0,type:"undirected"},{name:function(t){return"".concat(t,"EdgeWithKey")}},{name:function(t){return"".concat(t,"DirectedEdgeWithKey")},type:"directed"},{name:function(t){return"".concat(t,"UndirectedEdgeWithKey")},type:"undirected"}].forEach((function(t){["add","merge","update"].forEach((function(e){var n=t.name(e),i="add"===e?xt:Et;t.generateKey?Tt.prototype[n]=function(o,r,s){return i(this,n,!0,"undirected"===(t.type||this.type),null,o,r,s,"update"===e)}:Tt.prototype[n]=function(o,r,s,a){return i(this,n,!1,"undirected"===(t.type||this.type),o,r,s,a,"update"===e)}}))})),function(t){K.forEach((function(e){var n=e.name,i=e.attacher;i(t,n("Node"),0),i(t,n("Source"),1),i(t,n("Target"),2),i(t,n("Opposite"),3)}))}(Tt),function(t){Z.forEach((function(e){var n=e.name,i=e.attacher;i(t,n("Edge"),"mixed"),i(t,n("DirectedEdge"),"directed"),i(t,n("UndirectedEdge"),"undirected")}))}(Tt),function(t){tt.forEach((function(e){!function(t,e){var n=e.name,i=e.type,o=e.direction;t.prototype[n]=function(t,e){if("mixed"!==i&&"mixed"!==this.type&&i!==this.type)return[];if(!arguments.length)return function(t,e){if(0===t.size)return[];if("mixed"===e||e===t.type)return"function"==typeof Array.from?Array.from(t._edges.keys()):F(t._edges.keys(),t._edges.size);for(var n,i,o="undirected"===e?t.undirectedSize:t.directedSize,r=new Array(o),s="undirected"===e,a=t._edges.values(),l=0;!0!==(n=a.next()).done;)(i=n.value).undirected===s&&(r[l++]=i.key);return r}(this,i);if(1===arguments.length){t=""+t;var r=this._nodes.get(t);if(void 0===r)throw new V("Graph.".concat(n,': could not find the "').concat(t,'" node in the graph.'));return function(t,e,n,i){var o=[];return lt(!1,t,e,n,i,(function(t){o.push(t)})),o}(this.multi,"mixed"===i?this.type:i,o,r)}if(2===arguments.length){t=""+t,e=""+e;var s=this._nodes.get(t);if(!s)throw new V("Graph.".concat(n,': could not find the "').concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new V("Graph.".concat(n,': could not find the "').concat(e,'" target node in the graph.'));return function(t,e,n,i,o){var r=[];return ct(!1,t,e,n,i,o,(function(t){r.push(t)})),r}(i,this.multi,o,s,e)}throw new D("Graph.".concat(n,": too many arguments (expecting 0, 1 or 2 and got ").concat(arguments.length,")."))}}(t,e),function(t,e){var n=e.name,i=e.type,o=e.direction,r="forEach"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[r]=function(t,e,n){if("mixed"===i||"mixed"===this.type||i===this.type){if(1===arguments.length)return at(!1,this,i,n=t);if(2===arguments.length){t=""+t,n=e;var s=this._nodes.get(t);if(void 0===s)throw new V("Graph.".concat(r,': could not find the "').concat(t,'" node in the graph.'));return lt(!1,this.multi,"mixed"===i?this.type:i,o,s,n)}if(3===arguments.length){t=""+t,e=""+e;var a=this._nodes.get(t);if(!a)throw new V("Graph.".concat(r,': could not find the "').concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new V("Graph.".concat(r,': could not find the "').concat(e,'" target node in the graph.'));return ct(!1,i,this.multi,o,a,e,n)}throw new D("Graph.".concat(r,": too many arguments (expecting 1, 2 or 3 and got ").concat(arguments.length,")."))}};var s="map"+n[0].toUpperCase()+n.slice(1);t.prototype[s]=function(){var t,e=Array.prototype.slice.call(arguments),n=e.pop();if(0===e.length){var o=0;"directed"!==i&&(o+=this.undirectedSize),"undirected"!==i&&(o+=this.directedSize),t=new Array(o);var s=0;e.push((function(e,i,o,r,a,l,c){t[s++]=n(e,i,o,r,a,l,c)}))}else t=[],e.push((function(e,i,o,r,s,a,l){t.push(n(e,i,o,r,s,a,l))}));return this[r].apply(this,e),t};var a="filter"+n[0].toUpperCase()+n.slice(1);t.prototype[a]=function(){var t=Array.prototype.slice.call(arguments),e=t.pop(),n=[];return t.push((function(t,i,o,r,s,a,l){e(t,i,o,r,s,a,l)&&n.push(t)})),this[r].apply(this,t),n};var l="reduce"+n[0].toUpperCase()+n.slice(1);t.prototype[l]=function(){var t,e,n=Array.prototype.slice.call(arguments);if(n.length<2||n.length>4)throw new D("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 D("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?(t=n[0],e=n[1],n=[]):3===n.length?(t=n[1],e=n[2],n=[n[0]]):4===n.length&&(t=n[2],e=n[3],n=[n[0],n[1]]);var i=e;return n.push((function(e,n,o,r,s,a,l){i=t(i,e,n,o,r,s,a,l)})),this[r].apply(this,n),i}}(t,e),function(t,e){var n=e.name,i=e.type,o=e.direction,r="find"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[r]=function(t,e,n){if("mixed"!==i&&"mixed"!==this.type&&i!==this.type)return!1;if(1===arguments.length)return at(!0,this,i,n=t);if(2===arguments.length){t=""+t,n=e;var s=this._nodes.get(t);if(void 0===s)throw new V("Graph.".concat(r,': could not find the "').concat(t,'" node in the graph.'));return lt(!0,this.multi,"mixed"===i?this.type:i,o,s,n)}if(3===arguments.length){t=""+t,e=""+e;var a=this._nodes.get(t);if(!a)throw new V("Graph.".concat(r,': could not find the "').concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new V("Graph.".concat(r,': could not find the "').concat(e,'" target node in the graph.'));return ct(!0,i,this.multi,o,a,e,n)}throw new D("Graph.".concat(r,": too many arguments (expecting 1, 2 or 3 and got ").concat(arguments.length,")."))};var s="some"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[s]=function(){var t=Array.prototype.slice.call(arguments),e=t.pop();return t.push((function(t,n,i,o,r,s,a){return e(t,n,i,o,r,s,a)})),!!this[r].apply(this,t)};var a="every"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[a]=function(){var t=Array.prototype.slice.call(arguments),e=t.pop();return t.push((function(t,n,i,o,r,s,a){return!e(t,n,i,o,r,s,a)})),!this[r].apply(this,t)}}(t,e),function(t,e){var n=e.name,i=e.type,o=e.direction,r=n.slice(0,-1)+"Entries";t.prototype[r]=function(t,e){if("mixed"!==i&&"mixed"!==this.type&&i!==this.type)return N.empty();if(!arguments.length)return function(t,e){if(0===t.size)return N.empty();var n="mixed"!==e&&e!==t.type,i="undirected"===e,o=t._edges.values();return new N((function(){for(var t,e;;){if((t=o.next()).done)return t;if(e=t.value,!n||e.undirected===i)break}return{value:{edge:e.key,attributes:e.attributes,source:e.source.key,target:e.target.key,sourceAttributes:e.source.attributes,targetAttributes:e.target.attributes,undirected:e.undirected},done:!1}}))}(this,i);if(1===arguments.length){t=""+t;var n=this._nodes.get(t);if(!n)throw new V("Graph.".concat(r,': could not find the "').concat(t,'" node in the graph.'));return function(t,e,n){var i=N.empty();return"undirected"!==t&&("out"!==e&&void 0!==n.in&&(i=Q(i,it(n.in))),"in"!==e&&void 0!==n.out&&(i=Q(i,it(n.out,e?void 0:n.key)))),"directed"!==t&&void 0!==n.undirected&&(i=Q(i,it(n.undirected))),i}(i,o,n)}if(2===arguments.length){t=""+t,e=""+e;var s=this._nodes.get(t);if(!s)throw new V("Graph.".concat(r,': could not find the "').concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new V("Graph.".concat(r,': could not find the "').concat(e,'" target node in the graph.'));return function(t,e,n,i){var o=N.empty();return"undirected"!==t&&(void 0!==n.in&&"out"!==e&&i in n.in&&(o=Q(o,st(n.in,i))),void 0!==n.out&&"in"!==e&&i in n.out&&(e||n.key!==i)&&(o=Q(o,st(n.out,i)))),"directed"!==t&&void 0!==n.undirected&&i in n.undirected&&(o=Q(o,st(n.undirected,i))),o}(i,o,s,e)}throw new D("Graph.".concat(r,": too many arguments (expecting 0, 1 or 2 and got ").concat(arguments.length,")."))}}(t,e)}))}(Tt),function(t){ht.forEach((function(e){(function(t,e){var n=e.name,i=e.type,o=e.direction;t.prototype[n]=function(t){if("mixed"!==i&&"mixed"!==this.type&&i!==this.type)return[];t=""+t;var e=this._nodes.get(t);if(void 0===e)throw new V("Graph.".concat(n,': could not find the "').concat(t,'" node in the graph.'));return function(t,e,n){if("mixed"!==t){if("undirected"===t)return Object.keys(n.undirected);if("string"==typeof e)return Object.keys(n[e])}var i=[];return pt(!1,t,e,n,(function(t){i.push(t)})),i}("mixed"===i?this.type:i,o,e)}})(t,e),function(t,e){var n=e.name,i=e.type,o=e.direction,r="forEach"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[r]=function(t,e){if("mixed"===i||"mixed"===this.type||i===this.type){t=""+t;var n=this._nodes.get(t);if(void 0===n)throw new V("Graph.".concat(r,': could not find the "').concat(t,'" node in the graph.'));pt(!1,"mixed"===i?this.type:i,o,n,e)}};var s="map"+n[0].toUpperCase()+n.slice(1);t.prototype[s]=function(t,e){var n=[];return this[r](t,(function(t,i){n.push(e(t,i))})),n};var a="filter"+n[0].toUpperCase()+n.slice(1);t.prototype[a]=function(t,e){var n=[];return this[r](t,(function(t,i){e(t,i)&&n.push(t)})),n};var l="reduce"+n[0].toUpperCase()+n.slice(1);t.prototype[l]=function(t,e,n){if(arguments.length<3)throw new D("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[r](t,(function(t,n){i=e(i,t,n)})),i}}(t,e),function(t,e){var n=e.name,i=e.type,o=e.direction,r=n[0].toUpperCase()+n.slice(1,-1),s="find"+r;t.prototype[s]=function(t,e){if("mixed"===i||"mixed"===this.type||i===this.type){t=""+t;var n=this._nodes.get(t);if(void 0===n)throw new V("Graph.".concat(s,': could not find the "').concat(t,'" node in the graph.'));return pt(!0,"mixed"===i?this.type:i,o,n,e)}};var a="some"+r;t.prototype[a]=function(t,e){return!!this[s](t,e)};var l="every"+r;t.prototype[l]=function(t,e){return!this[s](t,(function(t,n){return!e(t,n)}))}}(t,e),function(t,e){var n=e.name,i=e.type,o=e.direction,r=n.slice(0,-1)+"Entries";t.prototype[r]=function(t){if("mixed"!==i&&"mixed"!==this.type&&i!==this.type)return N.empty();t=""+t;var e=this._nodes.get(t);if(void 0===e)throw new V("Graph.".concat(r,': could not find the "').concat(t,'" node in the graph.'));return function(t,e,n){if("mixed"!==t){if("undirected"===t)return mt(null,n,n.undirected);if("string"==typeof e)return mt(null,n,n[e])}var i=N.empty(),o=new ut;return"undirected"!==t&&("out"!==e&&(i=Q(i,mt(o,n,n.in))),"in"!==e&&(i=Q(i,mt(o,n,n.out)))),"directed"!==t&&(i=Q(i,mt(o,n,n.undirected))),i}("mixed"===i?this.type:i,o,e)}}(t,e)}))}(Tt);var _t=function(t){function n(e){var n=a({type:"directed"},e);if("multi"in n&&!1!==n.multi)throw new D("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if("directed"!==n.type)throw new D('DirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return t.call(this,n)||this}return e(n,t),n}(Tt),It=function(t){function n(e){var n=a({type:"undirected"},e);if("multi"in n&&!1!==n.multi)throw new D("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if("undirected"!==n.type)throw new D('UndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return t.call(this,n)||this}return e(n,t),n}(Tt),Lt=function(t){function n(e){var n=a({multi:!0},e);if("multi"in n&&!0!==n.multi)throw new D("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");return t.call(this,n)||this}return e(n,t),n}(Tt),Nt=function(t){function n(e){var n=a({type:"directed",multi:!0},e);if("multi"in n&&!0!==n.multi)throw new D("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if("directed"!==n.type)throw new D('MultiDirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return t.call(this,n)||this}return e(n,t),n}(Tt),Pt=function(t){function n(e){var n=a({type:"undirected",multi:!0},e);if("multi"in n&&!0!==n.multi)throw new D("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if("undirected"!==n.type)throw new D('MultiUndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return t.call(this,n)||this}return e(n,t),n}(Tt);function $t(t){t.from=function(e,n){var i=a({},e.options,n),o=new t(i);return o.import(e),o}}return $t(Tt),$t(_t),$t(It),$t(Lt),$t(Nt),$t(Pt),Tt.Graph=Tt,Tt.DirectedGraph=_t,Tt.UndirectedGraph=It,Tt.MultiGraph=Lt,Tt.MultiDirectedGraph=Nt,Tt.MultiUndirectedGraph=Pt,Tt.InvalidArgumentsGraphError=D,Tt.NotFoundGraphError=V,Tt.UsageGraphError=W,Tt}()},944:(t,e)=>{"use strict";e.Vb=void 0,e.Vb=function(t,e,n){var i=function(t,e,n){if(0===t.length||0===e.length)return 0;if(n&&!n.caseSensitive&&(t=t.toUpperCase(),e=e.toUpperCase()),t===e)return 1;for(var i=0,o=t.length,r=e.length,s=Math.floor(Math.max(o,r)/2)-1,a=new Array(o),l=new Array(r),c=0;c<o;c++)for(var h=Math.max(0,c-s);h<=Math.min(r,c+s+1);h++)if(!a[c]&&!l[h]&&t[c]===e[h]){++i,a[c]=l[h]=!0;break}if(0===i)return 0;var u=0,d=0;for(c=0;c<o;c++)if(a[c]){for(;!l[d];)d++;t.charAt(c)!==e.charAt(d++)&&u++}return(i/o+i/r+(i-(u/=2))/i)/3}(t,e,n),o=0;if(i>.7){for(var r=Math.min(t.length,e.length),s=0;t[s]===e[s]&&s<4&&s<r;)++o,s++;i+=.1*o*(1-i)}return i}},7106:t=>{"use strict";var e=t.exports=function(t,e,i){"function"==typeof e&&(i=e,e={}),n(e,"function"==typeof(i=e.cb||i)?i:i.pre||function(){},i.post||function(){},t,"",t)};function n(t,i,o,r,s,a,l,c,h,u){if(r&&"object"==typeof r&&!Array.isArray(r)){for(var d in i(r,s,a,l,c,h,u),r){var p=r[d];if(Array.isArray(p)){if(d in e.arrayKeywords)for(var m=0;m<p.length;m++)n(t,i,o,p[m],s+"/"+d+"/"+m,a,s,d,r,m)}else if(d in e.propsKeywords){if(p&&"object"==typeof p)for(var f in p)n(t,i,o,p[f],s+"/"+d+"/"+f.replace(/~/g,"~0").replace(/\//g,"~1"),a,s,d,r,f)}else(d in e.keywords||t.allKeys&&!(d in e.skipKeywords))&&n(t,i,o,p,s+"/"+d,a,s,d,r)}o(r,s,a,l,c,h,u)}}e.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0},e.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},e.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},e.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:t=>{"use strict";var e=[];function n(t){for(var n=-1,i=0;i<e.length;i++)if(e[i].identifier===t){n=i;break}return n}function i(t,i){for(var r={},s=[],a=0;a<t.length;a++){var l=t[a],c=i.base?l[0]+i.base:l[0],h=r[c]||0,u="".concat(c," ").concat(h);r[c]=h+1;var d=n(u),p={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==d)e[d].references++,e[d].updater(p);else{var m=o(p,i);i.byIndex=a,e.splice(a,0,{identifier:u,updater:m,references:1})}s.push(u)}return s}function o(t,e){var n=e.domAPI(e);return n.update(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap&&e.supports===t.supports&&e.layer===t.layer)return;n.update(t=e)}else n.remove()}}t.exports=function(t,o){var r=i(t=t||[],o=o||{});return function(t){t=t||[];for(var s=0;s<r.length;s++){var a=n(r[s]);e[a].references--}for(var l=i(t,o),c=0;c<r.length;c++){var h=n(r[c]);0===e[h].references&&(e[h].updater(),e.splice(h,1))}r=l}}},7659:t=>{"use strict";var e={};t.exports=function(t,n){var i=function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(t){n=null}e[t]=n}return e[t]}(t);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:t=>{"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},5056:(t,e,n)=>{"use strict";t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},7825:t=>{"use strict";t.exports=function(t){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=t.insertStyleElement(t);return{update:function(n){!function(t,e,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 r=n.sourceMap;r&&"undefined"!=typeof btoa&&(i+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(r))))," */")),e.styleTagTransform(i,t,e.options)}(e,t,n)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},1113:t=>{"use strict";t.exports=function(t,e){if(e.styleSheet)e.styleSheet.cssText=t;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(t))}}},6723:(t,e,n)=>{"use strict";n.r(e),n.d(e,{GetRegionEditor:()=>uo,SeqActivityCliffsEditor:()=>fo,SeqPaletteCustom:()=>io,SequenceSpaceEditor:()=>mo,SplitToMonomersEditor:()=>po,SubsequenceSearchTopMenu:()=>Xo,_package:()=>eo,activityCliffs:()=>To,addCopyMenu:()=>fr,alignSequences:()=>Oo,bioSubstructureFilter:()=>sr,bioSubstructureFilterTest:()=>ar,compositionAnalysis:()=>Ho,compositionAnalysisWidget:()=>wo,convertColumnAction:()=>Do,convertDialog:()=>Bo,customSequenceCellRenderer:()=>go,demoBioActivityCliffs:()=>br,demoBioAtomicLevel:()=>vr,demoBioSequenceSpace:()=>yr,demoBioSimilarityDiversity:()=>gr,detectMacromoleculeProbe:()=>Sr,diversitySearchTopMenu:()=>Ko,diversitySearchViewer:()=>Yo,fastaSequenceCellRenderer:()=>yo,getBioLib:()=>ao,getHelmMonomers:()=>jo,getMolFromHelm:()=>Er,getMonomerLibHelper:()=>no,getRegion:()=>Eo,getRegionApp:()=>hr,getRegionHelmApp:()=>ur,getRegionPanel:()=>co,getRegionTopMenu:()=>Mo,getSeqHandler:()=>lo,getSeqHelper:()=>xr,helmPreprocessingFunction:()=>Io,importBam:()=>Fo,importFasta:()=>Go,initBio:()=>ro,libraryPanel:()=>ho,longSeqTableFasta:()=>pr,longSeqTableHelm:()=>mr,longSeqTableSeparator:()=>dr,macroMolColumnPropertyPanel:()=>vo,macromoleculeDifferenceCellRenderer:()=>Co,macromoleculePreprocessingFunction:()=>_o,manageLibrariesView:()=>er,manageMonomerLibraries:()=>tr,manageMonomerLibrariesView:()=>ir,manageMonomerLibrariesViewTreeBrowser:()=>or,manageMonomersView:()=>nr,monomerCellRenderer:()=>Vo,multipleSequenceAlignmentDialog:()=>ko,saveAsFasta:()=>rr,sdfToJsonLib:()=>wr,searchSubsequenceEditor:()=>Zo,separatorSequenceCellRenderer:()=>bo,seq2atomic:()=>Cr,seqIdentity:()=>Ar,sequence3dStructureWidget:()=>Ro,sequenceAlignment:()=>Ao,sequenceIdentityScoring:()=>Jo,sequenceSimilarityScoring:()=>Qo,sequenceSpaceTopMenu:()=>Lo,sequenceTooltip:()=>so,similaritySearchTopMenu:()=>zo,similaritySearchViewer:()=>qo,splitToMonomersTopMenu:()=>Uo,test1:()=>Mr,testDetectMacromolecule:()=>Wo,toAtomicLevel:()=>No,toAtomicLevelAction:()=>Po,toAtomicLevelPanel:()=>$o,vdRegionsViewer:()=>xo,webLogoAggApp:()=>cr,webLogoLargeApp:()=>lr,webLogoViewer:()=>So});var i,o,r=n(4328),s=n(7389),a=n(6082),l=n(684),c=n(9039);(o=i||(i={})).EUCLIDEAN="EUCLIDEAN",o.MANHATTAN="MANHATTAN";var h=n(1858),u=n(5072),d=n.n(u),p=n(7825),m=n.n(p),f=n(7659),g=n.n(f),y=n(5056),b=n.n(y),v=n(540),w=n.n(v),C=n(1113),A=n.n(C),S=n(7939),x={};x.styleTagTransform=A(),x.setAttributes=b(),x.insert=g().bind(null,"head"),x.domAPI=m(),x.insertStyleElement=w(),d()(S.A,x),S.A&&S.A.locals&&S.A.locals;var E=function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((i=i.apply(t,e||[])).next())}))};let M=null,T=null;function _(t,e){return t&&""!=t?t:e}n(2780);class I{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 t=null;return"info"in M&&(t=M.info),t?_(t.description,_(t.vendor,"No GPU description available")):"No GPU description available"}))}().then((t=>{t?(this.useWebGPU.tooltip+=` (${t})`,this.useWebGPU.value=!0):(this.useWebGPU.value=!1,this.useWebGPU.disable=!0)}))}}class L{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 N="MCL";a.SEMTYPE.MOLECULE,a.SEMTYPE.MACROMOLECULE;class P{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 ${get algorithmOptions(){const t=this.methodsParams[this.methodInput.value],e={};return Object.keys(t).forEach((n=>{null!=t[n].value&&(e[n]=t[n].value)})),e}get dbScanOptions(){return{dbScanEpsilon:this.dbScanParams.epsilon.value??.01,dbScanMinPts:this.dbScanParams.minPts.value??4}}constructor(t={}){this.editorSettings={},this.plotEmbeddingsInput=s.input.bool("Plot embeddings",{value:!0}),this.clusterEmbeddingsInput=s.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=s.inputs([]),this.dbScanSettingsDiv=s.inputs([]),this.preprocessingFuncSettingsDiv=s.inputs([]),this.preprocessingFunctionSettings={},this.methodsParams={[c.c.UMAP]:new I,[c.c.T_SNE]:new L},this.dbScanParams=new P,this.editorSettings=t,this.editorSettings.enableMCL&&this.methods.push(N),a.Func.find({tags:[l.GP]}).forEach((t=>{const e=t.options.get(l.n3)??"",n=t.friendlyName??t.name,i=t.options.get(l.C0)??"",o=t.options.get(l._X)??"",r=t.options.get(l.Gi)??"";this.editorSettings.semtype&&!e.includes(this.editorSettings.semtype)||this.editorSettings.type&&!i.includes(this.editorSettings.type)||this.editorSettings.units&&!o.includes(this.editorSettings.units)||(this.supportedFunctions[n]={func:t,semTypes:e?e.split(","):[],types:i?i.split(","):[],units:o?o.split(","):[],distanceFunctions:r?r.split(","):[]})})),this.tableInput=s.input.table("Table",{value:r.shell.tv.dataFrame,items:r.shell.tables,onValueChanged:()=>{this.onTableInputChanged()}}),this.onTableInputChanged(),this.regenerateColInput(),this.onColumnInputChanged();let e=!1,n=!1;this.methodInput=s.input.choice("Method",{value:c.c.UMAP,items:this.methods,onValueChanged:t=>{e&&this.createAlgorithmSettingsDiv(this.methodSettingsDiv,this.methodsParams[t])}}),this.methodSettingsIcon=s.icons.settings((()=>{e=!e,e?this.createAlgorithmSettingsDiv(this.methodSettingsDiv,this.methodsParams[this.methodInput.value]):s.empty(this.methodSettingsDiv)}),"Modify methods parameters"),this.dbScanSettingsIcon=s.icons.settings((()=>{n=!n,n?this.createAlgorithmSettingsDiv(this.dbScanSettingsDiv,this.dbScanParams):s.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=s.inputs([]);const i=this.columnFunctionsMap[this.colInput.value.name];this.preprocessingFunctionInput=s.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||(s.empty(this.preprocessingFunctionInputRoot),Array.from(this.preprocessingFunctionInput.root.children).forEach((t=>this.preprocessingFunctionInputRoot.append(t)))),this.preprocessingFunctionInputRoot.classList.add("ml-dim-reduction-settings-input");let h=!1;this.preprocessingFuncSettingsIcon=s.icons.settings((async()=>{h?s.empty(this.preprocessingFuncSettingsDiv):await this.createPreprocessingFuncParamsDiv(this.preprocessingFuncSettingsDiv,this.supportedFunctions[this.preprocessingFunctionInput.value].func),h=!h}),"Modify encoding function parameters"),this.preprocessingFunctionInputRoot.prepend(this.preprocessingFuncSettingsIcon),this.similarityMetricInput=s.input.choice("Similarity",{value:"",items:[]}),this.similarityMetricInput.nullable=!1,this.similarityMetricInputRoot||(this.similarityMetricInputRoot=this.similarityMetricInput.root),this.onPreprocessingFunctionChanged()}getColInput(){const t=this.tableInput.value?.columns.toList().find((t=>!!this.columnFunctionsMap[t.name]))??null,e=s.input.column("Column",{table:this.tableInput.value,value:t,onValueChanged:()=>this.onColumnInputChanged(),filter:t=>!!this.columnFunctionsMap[t.name]});return this.colInputRoot||(this.colInputRoot=e.root),e}regenerateColInput(){let t=!1;this.colInputRoot&&(t=!0,s.empty(this.colInputRoot)),this.colInput=this.getColInput(),t&&Array.from(this.colInput.root.children).forEach((t=>this.colInputRoot.append(t))),this.onColumnInputChanged()}onTableInputChanged(){const t=this.tableInput.value;t&&(this.columnFunctionsMap={},t.columns.toList().forEach((t=>{Object.keys(this.supportedFunctions).forEach((e=>{const n=this.supportedFunctions[e].semTypes,i=this.supportedFunctions[e].types,o=this.supportedFunctions[e].units,r=!n.length||t.semType&&n.includes(t.semType),s=!i.length||i.includes(t.type),a=!o.length||t.meta.units&&o.includes(t.meta.units);r&&s&&a&&(this.columnFunctionsMap[t.name]||(this.columnFunctionsMap[t.name]=[]),this.columnFunctionsMap[t.name].push(e))}))})),this.regenerateColInput())}onColumnInputChanged(){const t=this.colInput.value;if(!t)return;const e=this.columnFunctionsMap[t.name];this.preprocessingFunctionInput=s.input.choice("Preprocessing function",{value:e[0],items:e,onValueChanged:()=>{this.onPreprocessingFunctionChanged()}});let n=!1;this.preprocessingFunctionInputRoot||(this.preprocessingFunctionInputRoot=this.preprocessingFunctionInput.root,n=!0),n||(s.empty(this.preprocessingFunctionInputRoot),Array.from(this.preprocessingFunctionInput.root.children).forEach((t=>this.preprocessingFunctionInputRoot.append(t)))),this.onPreprocessingFunctionChanged()}onPreprocessingFunctionChanged(){s.empty(this.preprocessingFuncSettingsDiv),this.preprocessingFunctionSettings={};const t=this.preprocessingFunctionInput.value,e=this.supportedFunctions[t].distanceFunctions;this.availableMetrics=[...e],this.similarityMetricInput=s.input.choice("Similarity",{value:this.availableMetrics[0],items:this.availableMetrics}),this.similarityMetricInput.nullable=!1,this.similarityMetricInputRoot||(this.similarityMetricInputRoot=this.similarityMetricInput.root),s.empty(this.similarityMetricInputRoot),Array.from(this.similarityMetricInput.root.children).forEach((t=>this.similarityMetricInputRoot.append(t))),this.preprocessingFuncSettingsIcon&&(this.supportedFunctions[t].func.inputs.length<3?this.preprocessingFuncSettingsIcon.style.display="none":this.preprocessingFuncSettingsIcon.style.display="flex")}createAlgorithmSettingsDiv(t,e){return s.empty(t),Object.keys(e).forEach((n=>{const i=e[n],o="string"===i.type?s.input.string(i.uiName,{value:i.value??"",onValueChanged:t=>{i.value=t}}):"boolean"===i.type?s.input.bool(i.uiName,{value:i.value??!1,onValueChanged:t=>{i.value=t}}):s.input.float(i.uiName,{value:i.value,onValueChanged:t=>{i.value=t}});t.append(o.root),i.disable?(o.enabled=!1,s.tooltip.bind(o.input??o.root,i.disableTooltip??"")):s.tooltip.bind(o.input??o.root,i.tooltip)})),t}async createPreprocessingFuncParamsDiv(t,e){if(s.empty(t),e.inputs.length<3)return s.div();const n=e.prepare(),i=await n.buildEditor(s.div());for(let o=2;o<e.inputs.length;o++){const r=e.inputs[o];(this.preprocessingFunctionSettings[r.name]||n.inputParams[e.inputs[o].name].value||r.defaultValue)&&(this.preprocessingFunctionSettings[r.name]=this.preprocessingFunctionSettings[r.name]??n.inputParams[r.name].value??r.defaultValue);const s=i.find((t=>t.property.name===r.name));s&&(null!==this.preprocessingFunctionSettings[r.name]&&void 0!==this.preprocessingFunctionSettings[r.name]&&(s.value=this.preprocessingFunctionSettings[r.name]),s.onChanged.subscribe((t=>{this.preprocessingFunctionSettings[r.name]=t})),t.append(s.root))}return t}getEditor(){return s.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(t){try{const e=JSON.parse(t);await this.applyInput(e)}catch(t){r.shell.error("Error applying input from history"),console.error(t)}}async applyInput(t){try{const e=this.tableInput.value?.col(t.col);if(!e)throw new Error("Column not found");this.colInput.value=e,this.preprocessingFunctionInput.value=t.preprocessingFunction,this.similarityMetricInput.value=t.similarityMetric,this.plotEmbeddingsInput.value=t.plotEmbeddings,this.clusterEmbeddingsInput.value=t.clusterEmbeddings;const n=this.methodsParams[this.methodInput.value];Object.keys(n).forEach((e=>{null!=t.options[e]&&(this.methodsParams[t.methodName][e].value=t.options[e])})),this.methodInput.value=t.methodName,this.preprocessingFunctionSettings=t.options.preprocessingFuncArgs,await this.createPreprocessingFuncParamsDiv(this.preprocessingFuncSettingsDiv,this.supportedFunctions[this.preprocessingFunctionInput.value].func)}catch(t){r.shell.error("Error applying input from history"),console.error(t)}}}var R=n(9713),k=n(6295);const O=t=>null==t;function H(t,e,n,i){if(n>t[t.length-1])return;const o=t.findIndex((t=>n<t));t.pop(),t.splice(o,0,n),e.pop(),e.splice(o,0,i)}class G{constructor(t=!0,e=!0){const i=navigator.hardwareConcurrency;this._workerCount=t?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=e}async calc(t,e,n=!0,o){return await this.calcMulti([t],[e],n,[o??{}],[1],i.MANHATTAN)}async calcMulti(t,e,n=!0,o=[{}],r=[1],s=i.MANHATTAN){if(t.length<1)throw new Error("values must contain at least one array");if(e.length!==t.length||o.length!==t.length||r.length!==t.length)throw new Error("values, fnNames, weights and opts must have the same length");return new Promise((async(i,a)=>{try{const a=t[0].length,l=new Array(this._workerCount),c=a*(a-1)/2;this._workerCount=Math.min(this._workerCount,c);const h=c/this._workerCount,u=new Float32Array(c);let d=0,p=1,m=0,f=Number.MIN_VALUE;for(let n=0;n<this._workerCount;n++){const i=Math.floor(n*h),g=n===this._workerCount-1?c:Math.floor((n+1)*h),y=d,b=p;n!==this._workerCount-1&&(d=a-2-Math.floor(Math.sqrt(-8*g+4*a*(a-1)-7)/2-.5),p=g-a*d+Math.floor((d+1)*(d+2)/2)),this._workers[n].postMessage({values:t,fnNames:e,startRow:y,startCol:b,chunckSize:g-i,opts:o,weights:r,aggregationMethod:s}),l[n]=new Promise(((t,e)=>{this._workers[n].onmessage=({data:{error:o,distanceMatrixData:r,min:s,max:a}})=>{this._terminateOnComplete&&setTimeout((()=>this._workers[n].terminate())),o?e(o):(u.set(r,i),s<m&&(m=s),a>f&&(f=a),t())}}))}await Promise.all(l),n&&u.forEach(((t,e)=>{u[e]=(t-m)/(f-m)})),i(u)}catch(t){a(t)}}))}terminate(){this._workers.forEach((t=>t.terminate()))}}class F{constructor(){this._workerCount=Math.max(navigator.hardwareConcurrency-2,1)}static pruneSparseMatrix(t,e=1e6){const n=200,i=new Uint32Array(n),o=t.distance.length,r=t.distance;for(let t=0;t<o;t++)i[Math.floor(r[t]*n)]++;let s=0,a=0;for(let t=0;t<n&&(s+=i[t],a=t,!(s>=e));t++);const l=new Uint32Array(s),c=new Uint32Array(s),h=new Float32Array(s),u=t.i,d=t.j;let p=0;const m=(a+1)/n;for(let t=0;t<o;t++)r[t]<m&&(l[p]=u[t],c[p]=d[t],h[p]=r[t],p++);return{i:l,j:c,distance:h}}async calcMultiColumn(t,e,o,r=[{}],s=[1],a=i.EUCLIDEAN){const l=t[0].length*(t[0].length-1)/2,c=Math.floor(l/this._workerCount),h=t[0].length>2e4?await this.getMinimalThreshold(t,e,r,s,a):0;o<h&&(console.log(`using threshold ${h}`),o=h),r.forEach(((t,e)=>r[e].threshold=o));const u=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++)u[n]=new Promise(((i,h)=>{const u=n*c,p=n===this._workerCount-1?l:(n+1)*c;p<=u&&i({i:new Int32Array(0),j:new Int32Array(0),distance:new Float32Array(0),idx:n}),d[n].postMessage({values:t,startIdx:u,endIdx:p,threshold:o,fnNames:e,opts:r,weights:s,aggregationMethod:a}),d[n].onmessage=({data:{error:t,i:e,j:o,distance:r}})=>{t?(d[n].terminate(),h(t)):(d[n].terminate(),i({i:e,j:o,distance:r,idx:n}))}}));const p=await Promise.all(u),m=p.reduce(((t,e)=>t+e.i.length),0),f=new Int32Array(m),g=new Int32Array(m),y=new Float32Array(m);let b=0;for(const t of p)f.set(t.i,b),g.set(t.j,b),y.set(t.distance,b),b+=t.i.length;return{i:f,j:g,distance:y}}async calc(t,e,n,i={}){return await this.calcMultiColumn([t],[e],n,[i],[1])}async getKNN(t,e,n=15,i={}){return await this.multiColumnKNN([t],[e],n,[i],[1])}async getThresholdKNN(t,e,n=.8,i={}){return await this.multiColumnThresholdKnn([t],[e],n,[i],[1])}async multiColumnThresholdKnn(t,e,o=.8,r,s,a=i.EUCLIDEAN){if(t.length!==e.length||t.length!==r.length||t.length!==s.length)throw new Error("values, distance functions, options and weights arrays should have the same length");if(t.some((e=>e.length!==t[0].length)))throw new Error("all values arrays should have the same length");const l=t[0].length*(t[0].length-1)/2,c=Math.floor(l/this._workerCount),h=new Array(this._workerCount),u=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++)h[n]=new Promise(((i,h)=>{const d=n*c,p=n===this._workerCount-1?l:(n+1)*c;p<=d&&i({knnDistances:new Array(0),knnIndexes:new Array(0)}),u[n].postMessage({values:t,startIdx:d,endIdx:p,fnNames:e,opts:r,threshold:o,weights:s,aggregationMethod:a}),u[n].onmessage=({data:{error:t,knnDistances:e,knnIndexes:o}})=>{t?(u[n].terminate(),h(t)):(u[n].terminate(),i({knnDistances:e,knnIndexes:o}))}}));const d=await Promise.all(h),p=new Int32Array(t[0].length);for(const e of d)for(let n=0;n<t[0].length;++n)p[n]+=e.knnIndexes[n]?.length??0;const m={knnDistances:new Array(t[0].length).fill(null).map(((t,e)=>new Array(p[e]))),knnIndexes:new Array(t[0].length).fill(null).map(((t,e)=>new Array(p[e])))};for(const e of d)for(let n=0;n<t[0].length;++n)for(let t=0;t<(e.knnDistances[n]?.length??0);++t)m.knnDistances[n][p[n]-1]=e.knnDistances[n][t],m.knnIndexes[n][p[n]-1]=e.knnIndexes[n][t],p[n]-=1;return m}async multiColumnSingleValueKNN(t,e,o,r=15,s,a,l=i.EUCLIDEAN){if(t.length!==o.length||t.length!==s.length||t.length!==a.length)throw new Error("values, distance functions, options and weights arrays should have the same length");if(t.some((e=>e.length!==t[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)))),h=new Array(this._workerCount),u=t[0].length,d=t.map((t=>t[e])),p=Math.ceil(u/this._workerCount);for(let e=0;e<this._workerCount;e++)h[e]=new Promise(((n,i)=>{const h=e*p,m=e===this._workerCount-1?u:(e+1)*p;m<=h&&n({knnDistances:new Array(0),knnIndexes:new Array(0)}),c[e].postMessage({values:t.map((t=>t.slice(h,m))),target:d,fnNames:o,opts:s,nNeighbours:r,weights:a,aggregationMethod:l,startIdx:h}),c[e].onmessage=({data:{error:t,knnDistances:o,knnIndexes:r}})=>{t?(c[e].terminate(),i(t)):(c[e].terminate(),n({knnDistances:o,knnIndexes:r}))}}));const m=await Promise.all(h),f={knnDistances:new Array(r).fill(99999),knnIndexes:new Array(r).fill(-1)};for(const t of m)for(let e=0;e<(t.knnDistances?.length??0);++e)H(f.knnDistances,f.knnIndexes,t.knnDistances[e],t.knnIndexes[e]);return f}async multiColumnKNN(t,e,o=15,r,s,a=i.EUCLIDEAN){if(t.length!==e.length||t.length!==r.length||t.length!==s.length)throw new Error("values, distance functions, options and weights arrays should have the same length");if(t.some((e=>e.length!==t[0].length)))throw new Error("all values arrays should have the same length");const l=t[0].length*(t[0].length-1)/2,c=Math.floor(l/this._workerCount),h=new Array(this._workerCount),u=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++)h[n]=new Promise(((i,h)=>{const d=n*c,p=n===this._workerCount-1?l:(n+1)*c;p<=d&&i({knnDistances:new Array(0),knnIndexes:new Array(0)}),u[n].postMessage({values:t,startIdx:d,endIdx:p,fnNames:e,opts:r,nNeighbours:o,weights:s,aggregationMethod:a}),u[n].onmessage=({data:{error:t,knnDistances:e,knnIndexes:o}})=>{t?(u[n].terminate(),h(t)):(u[n].terminate(),i({knnDistances:e,knnIndexes:o}))}}));const d=await Promise.all(h),p={knnDistances:new Array(t[0].length).fill(null).map((()=>new Array(o).fill(99999))),knnIndexes:new Array(t[0].length).fill(null).map((()=>new Array(o).fill(-1)))};for(const e of d)for(let n=0;n<t[0].length;++n)for(let t=0;t<(e.knnDistances[n]?.length??0);++t)H(p.knnDistances[n],p.knnIndexes[n],e.knnDistances[n][t],e.knnIndexes[n][t]);return p}async getSampleDistances(t,e,o=[],r,s=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=t[0].length*(t[0].length-1)/2,i=Math.floor(n/this._workerCount),l=1e6,c=Math.max(Math.min(n/1e3,l),Math.min(n,l)),h=Math.floor(c/this._workerCount),u=new Array(this._workerCount);for(let l=0;l<this._workerCount;l++)u[l]=new Promise(((c,u)=>{const d=l*i,p=l===this._workerCount-1?n:(l+1)*i;a[l].postMessage({values:t,startIdx:d,endIdx:p,sampleLength:h,fnNames:e,opts:o,weights:r,aggregationMethod:s}),a[l].onmessage=({data:{error:t,distance:e}})=>{a[l].terminate(),t?u(t):c({distance:e})}}));const d=await Promise.all(u),p=d.reduce(((t,e)=>t+e.distance.length),0),m=new Float32Array(p);let f=0;for(const t of d)m.set(t.distance,f),f+=t.distance.length;return m.sort(),m}catch(t){return a?.forEach((t=>t?.terminate())),console.error(t),new Float32Array(1).fill(.5)}}async getMinimalThreshold(t,e,n=[],o,r=i.EUCLIDEAN){try{const i=t.length*(t.length-1)/2,s=await this.getSampleDistances(t,e,n,o,r);return 1-s[Math.floor(7e7/i*s.length)]}catch(t){return console.error(t),.5}}static calcSync(t,e,n,i){const o=[],r=[],s=[];let a=0,l=0,c=0;const h=t.length*(t.length-1)/2;for(;a<h;){const e=O(t[l])||O(t[c])?1:n(t[l],t[c]);1-e>=i&&(o.push(l),r.push(c),s.push(e)),a++,c++,c===t.length&&(l++,c=l+1)}return{i:new Int32Array(o),j:new Int32Array(r),distance:new Float32Array(s)}}}var B,D,V=n(8774);(D=B||(B={})).none="none",D.bold="bold",D.dashed="dashed";class W{get currentLineId(){return this._currentLineIdx}set currentLineId(t){t!==this._currentLineIdx&&(this._currentLineIdx=t,this.sp.render(this.ctx))}set linesToRender(t){this.updateLines(t),this.sp.render(this.ctx)}set linesVisibility(t){this.visibility=t,this.sp.render(this.ctx)}constructor(t,e,n,i,o=B.none){var r;this._currentLineIdx=-1,this.lineClicked=new h.Subject,this.lineHover=new h.Subject,this.mouseOverLineId=-1,this.arrowWidth=15,this.sp=t,this.xAxisCol=this.sp.dataFrame.columns.byName(e),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!==(r=i.visibility)&&void 0!==r?r:new V.A(this.lines.from.length),i.visibility||this.visibility.setAll(!0,!1),i.arrowSize&&(this.arrowWidth=i.arrowSize),this.canvas.onmousedown=t=>{var e;(null===(e=this.lines)||void 0===e?void 0:e.skipMouseOverDetection)&&(this.mouseOverLineId=this.checkCoordsOnLine(t.offsetX,t.offsetY)),-1!==this.mouseOverLineId&&this.lineClicked.next({x:t.clientX,y:t.clientY,id:this.mouseOverLineId,event:t})},this.canvas.onmousemove=t=>{var e;this.mouseOverLineId=(null===(e=this.lines)||void 0===e?void 0:e.skipMouseOverDetection)?-1:this.checkCoordsOnLine(t.offsetX,t.offsetY),-1!==this.mouseOverLineId&&this.lineHover.next({x:t.clientX,y:t.clientY,id:this.mouseOverLineId,event:t})},t.onEvent("d4-before-draw-scene").subscribe((t=>{this.renderLines()}))}updateLines(t){this.lines=t,this.multipleLinesCounts=new Uint8Array(this.lines.from.length),t.skipMultiLineCalculation?this.multipleLinesCounts.fill(0):this.createMultiLinesIndices()}renderLines(){var t,e,n,i,o,r,s,a,l,c,h,u,d,p,m,f,g;const y=this.lines.colors||this.lines.widths||this.lines.opacities||this.lines.drawArrowsArr;y||(this.ctx.lineWidth=null!==(t=this.lines.width)&&void 0!==t?t:1,this.ctx.strokeStyle=`rgba(${null!==(e=this.lines.color)&&void 0!==e?e:"0,128,0"},${null!==(n=this.lines.opacity)&&void 0!==n?n:1})`);const b=this.sp.dataFrame.filter,v=Math.pow(null!==(i=this.lines.shortLineThreshold)&&void 0!==i?i:5,2);for(let t=0;t<this.lines.from.length;t++)if(b.get(this.lines.from[t])&&b.get(this.lines.to[t])&&this.visibility.getBit(t)){let e=0;const n=this.sp.getMarkerSize(this.lines.from[t])/2,i=this.sp.getMarkerSize(this.lines.to[t])/2,b=this.sp.pointToScreen(this.lines.from[t]);let w=null==b?void 0:b.x,C=null==b?void 0:b.y;const A=this.sp.pointToScreen(this.lines.to[t]);let S=null==A?void 0:A.x,x=null==A?void 0:A.y;const E=Math.min(this.sp.viewBox.width,this.sp.viewBox.height);if(this.ctx.beginPath(),w&&C&&S&&x&&Math.hypot(S-w,x-C)/E>.01){if(y){const e=(null===(o=this.lines.colors)||void 0===o?void 0:o[t])?null===(r=this.lines.colors)||void 0===r?void 0:r[t]:null!==(s=this.lines.color)&&void 0!==s?s:"0,128,0",n=(null===(a=this.lines.opacities)||void 0===a?void 0:a[t])?null===(l=this.lines.opacities)||void 0===l?void 0:l[t]:null!==(c=this.lines.opacity)&&void 0!==c?c:1;this.ctx.strokeStyle=`rgba(${e},${n})`,this.ctx.lineWidth=(null===(h=this.lines.widths)||void 0===h?void 0:h[t])?null===(u=this.lines.widths)||void 0===u?void 0:u[t]:null!==(d=this.lines.width)&&void 0!==d?d:1}t===this._currentLineIdx&&this.toggleCurrentLineStyle(!0);const b=this.multipleLinesCounts[t];let A=null;if(b){e=this.getLineLength(w,C,S,x);const o=this.getPointOnDistance(w,C,S,x,i,e),r=this.getPointOnDistance(S,x,w,C,n,e);w=o.x,C=o.y,S=r.x,x=r.y,A=this.lines.from[t]>this.lines.to[t]?this.findControlPoint(b,w,C,S,x,t):this.findControlPoint(b,S,x,w,C,t),this.ctx.moveTo(w,C),this.ctx.quadraticCurveTo(A.x,A.y,S,x)}else(!this.lines.skipShortLines||Math.pow(S-w,2)+Math.pow(x-C,2)>v)&&(this.ctx.moveTo(w,C),this.ctx.lineTo(S,x));if((null!==(p=this.lines.drawArrows)&&void 0!==p?p:null===(m=this.lines.drawArrowsArr)||void 0===m?void 0:m.getBit(t))&&(e||(e=this.getLineLength(w,C,S,x)),e>this.arrowWidth)){const t=b?null:this.getPointOnDistance(w,C,S,x,i,e),n=b?A.x:w,o=b?A.y:C;this.canvasArrow(this.ctx,null!==(f=null==t?void 0:t.x)&&void 0!==f?f:w,null!==(g=null==t?void 0:t.y)&&void 0!==g?g:C,n,o)}this.ctx.stroke(),this.ctx.closePath(),t===this._currentLineIdx&&this.toggleCurrentLineStyle(!1)}}this.fillLeftBottomRect()}toggleCurrentLineStyle(t){switch(this.currentLineStyle){case B.bold:t?this.ctx.lineWidth+=2:this.ctx.lineWidth-=2;break;case B.dashed:t?this.ctx.setLineDash([5,5]):this.ctx.setLineDash([]);break;default:return}}fillLeftBottomRect(){const t=new Path2D;t.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(t),this.ctx.closePath()}createMultiLinesIndices(){const t={};for(let e=0;e<this.lines.from.length;e++){let n=0,i=0;this.lines.from[e]<this.lines.to[e]?(n=this.lines.from[e],i=this.lines.to[e]):(n=this.lines.to[e],i=this.lines.from[e]),t[`${n}|${i}`]?(1===t[`${n}|${i}`].length&&(this.multipleLinesCounts[t[`${n}|${i}`][0]]=1,t[`${n}|${i}`].push(1)),this.multipleLinesCounts[e]=++t[`${n}|${i}`][1]):t[`${n}|${i}`]=[e]}}checkCoordsOnLine(t,e){let n=-1,i=null,o=null;const r=this.sp.dataFrame.filter;for(let s=0;s<this.lines.from.length;s++)if(r.get(this.lines.from[s])&&r.get(this.lines.to[s])&&this.visibility.getBit(s)){const r=this.sp.getMarkerSize(this.lines.from[s])/2,a=this.sp.getMarkerSize(this.lines.to[s])/2,l=this.sp.worldToScreen(this.xAxisCol.get(this.lines.from[s]),this.yAxisCol.get(this.lines.from[s])),c=this.sp.worldToScreen(this.xAxisCol.get(this.lines.to[s]),this.yAxisCol.get(this.lines.to[s]));if(this.multipleLinesCounts[s]){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),h=this.getPointOnDistance(c.x,c.y,null==l?void 0:l.x,null==l?void 0:l.y,r,n),u=this.lines.from[s]>this.lines.to[s]?this.findControlPoint(this.multipleLinesCounts[s],i.x,i.y,h.x,h.y,s):this.findControlPoint(this.multipleLinesCounts[s],h.x,h.y,i.x,i.y,s);o=this.calculateDistToCurveLine(s,t,e,i,h,u)}else o=this.calculateDistToStraightLine(t,e,l,c);(!i&&null!==o&&o<5||i&&null!==o&&o<i)&&(i=o,n=s)}return n}calculateDistToStraightLine(t,e,n,i){const o=Math.min(n.x,i.x),r=Math.max(n.x,i.x),s=Math.min(n.y,i.y),a=Math.max(n.y,i.y);return t>=o-2&&t<=r+2&&e>=s-2&&e<=a+2?this.distToStraightLineSegment(t,e,n,i):null}distToStraightLineSegment(t,e,n,i){const o=(t,e,n,i)=>Math.pow(t-n,2)+Math.pow(e-i,2),r=o(n.x,n.y,i.x,i.y);if(0==r)return o(t,e,n.x,n.y);let s=((t-n.x)*(i.x-n.x)+(e-n.y)*(i.y-n.y))/r;return s=Math.max(0,Math.min(1,s)),o(t,e,n.x+s*(i.x-n.x),n.y+s*(i.y-n.y))}calculateDistToCurveLine(t,e,n,i,o,r){const s=Math.min(i.x,o.x,r.x),a=Math.max(i.x,o.x,r.x),l=Math.min(i.y,o.y,r.y),c=Math.max(i.y,o.y,r.y);if(e>=s-2&&e<=a+2&&n>=l-2&&n<=c+2){const t=a-s,h=c-l;return this.calculateDistToCurveInRect(e,n,i,r,o,t,h)}return null}calculateDistToCurveInRect(t,e,n,i,o,r,s){const a=Math.floor((r+s)/3),l=1/a,c=new Uint32Array(a),h=new Uint32Array(a),u=new Uint32Array(a);let d=null;const p=new V.A(a);for(let r=0;r<c.length;r++){const s=r*l,a=Math.pow(1-s,2)*n.x+2*s*(1-s)*i.x+Math.pow(s,2)*o.x,p=Math.pow(1-s,2)*n.y+2*s*(1-s)*i.y+Math.pow(s,2)*o.y,m=Math.abs(t-a),f=Math.abs(e-p),g=m+f;(!d||d>g)&&(d=g),u[r]=Math.max(m,f),c[r]=a,h[r]=p}for(let t=0;t<c.length;t++)u[t]<d&&p.setBit(t,!0,!1);let m=null;for(let n=-1;-1!==(n=p.findNext(n));){const i=Math.hypot(c[n]-t,h[n]-e);(!m||m>i)&&(m=i)}return m}getLineLength(t,e,n,i){return Math.sqrt(Math.pow(n-t,2)+Math.pow(i-e,2))}getPointOnDistance(t,e,n,i,o,r){const s=n-o*((n-t)/r),l=i-o*((i-e)/r);return new a.Point(s,l)}findControlPoint(t,e,n,i,o,r){const s=e+(i-e)/2,l=n+(o-n)/2;let c=s-e,h=l-n;const u=Math.sqrt(c*c+h*h);c/=u,h/=u;const d=50*Math.ceil(t/2);return t%2==0?new a.Point(s+d/2*h,l-d/2*c):new a.Point(s-d/2*h,l+d/2*c)}canvasArrow(t,e,n,i,o){const r=Math.atan2(i-e,o-n)+Math.PI;t.moveTo(e-this.arrowWidth*Math.sin(r-Math.PI/10),n-this.arrowWidth*Math.cos(r-Math.PI/10)),t.lineTo(e,n),t.lineTo(e-this.arrowWidth*Math.sin(r+Math.PI/10),n-this.arrowWidth*Math.cos(r+Math.PI/10))}}var U,j,q=n(8060),z=n(3629);async function Y(t,e,i,o,s,a,l){let c=await async function(t,e,i,o,s,a,l){if(!a.distanceFnArgs)throw new Error("options.distanceFnArgs must be defined");if(t.length!==e.length||t.length!==a.distanceFnArgs.length||t.length!==o.length)throw new Error("data, metrics and options and weights must have the same length");return new Promise((function(c,h){const u=new Worker(new URL(n.p+n.u(234),n.b));u.postMessage({columnsData:t,distanceMetrics:e,method:i,options:a,weights:o,aggregationMethod:s});const d=r.events.onCustomEvent(q.S).subscribe((()=>{try{u?.terminate()}finally{d.unsubscribe()}}));u.onmessage=({data:{error:t,embedding:e,epochNum:n,epochsLength:i}})=>{O(n)||O(i)?(d.unsubscribe(),t?h(t):c(e),setTimeout((()=>u.terminate()),100)):l&&l(n,i,e)}}))}(t,i,e,o,s,a,l);return c=c.map((t=>(0,z.S8)(t))),c}(j=U||(U={})).EUCLIDEAN="EUCLIDEAN",j.MANHATTAN="MANHATTAN";const K={[U.EUCLIDEAN]:function(t){return`\n var sum = 0.0;\n for (var i = 0u; i < ${t}; i = i + 1u) {\n sum = sum + distances[i] * distances[i] * computeInfo.weights[i] * computeInfo.weights[i];\n }\n return sqrt(sum);\n `},[U.MANHATTAN]:function(t){return`\n var sum = 0.0;\n for (var i = 0u; i < ${t}; i = i + 1u) {\n sum = sum + abs(distances[i]) * computeInfo.weights[i];\n }\n return sum;\n `}};var Z,X;(X=Z||(Z={})).HAMMING="Hamming",X.EUCLIDEAN="Euclidean",X.VECTOR_COSINE="Vector Cosine",X.MANHATTAN="Manhattan",X.TANIMOTO="Tanimoto",X.LEVENSTEIN="Levenshtein",X.NEEDLEMAN_WUNSCH="Needlemann-Wunsch",X.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance",X.SOKAL="Sokal",X.COSINE="Cosine",X.ASYMMETRIC="Asymmetric",X.Difference="Difference",X.OneHot="One-Hot";const J={[Z.HAMMING]:function(t,e){return`\n let aLength: u32 = computeInfo.entrySizes[${e}][aIndex];\n let bLength: u32 = computeInfo.entrySizes[${e}][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 < ${t}; 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 / ${t};\n `},[Z.EUCLIDEAN]:function(t,e){return`\n var dist: f32 = 0.0;\n for (var i = 0u; i < ${t}; i = i + 1u) {\n dist = dist + f32(a[i] - b[i]) * f32(a[i] - b[i]);\n }\n return sqrt(dist);\n `},[Z.MANHATTAN]:function(t,e){return`\n var dist: f32 = 0.0;\n for (var i = 0u; i < ${t}; i = i + 1u) {\n dist = dist + abs(f32(a[i] - b[i]));\n }\n return dist;\n `},[Z.VECTOR_COSINE]:function(t,e){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 < ${t}; 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 `},[Z.TANIMOTO]:function(t,e){return`\n var onBitsa: u32 = 0u;\n var onBitsb: u32 = 0u;\n for (var i = 0u; i < ${t}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 < ${t}u; i = i + 1u) {\n commonBits = commonBits + countOneBits(a[i] & b[i]);\n }\n\n return 1.0 - f32(commonBits) / f32(totalOnBits - commonBits);\n `},[Z.LEVENSTEIN]:function(t,e){return`\n let aLength: u32 = computeInfo.entrySizes[${e}][aIndex];\n let bLength: u32 = computeInfo.entrySizes[${e}][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, ${t+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 `},[Z.NEEDLEMAN_WUNSCH]:function(t,e){return`\n let aLength: u32 = computeInfo.entrySizes[${e}][aIndex];\n let bLength: u32 = computeInfo.entrySizes[${e}][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, ${t+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, ${t+1}u>;\n var horizontalGaps: array<u32, ${t+1}u>;\n\n let gapOpenPenalty: f32 = suppInfo.gapOpenPenalty${e};\n let gapExtensionPenalty: f32 = suppInfo.gapExtensionPenalty${e};\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${e}; // 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 `},[Z.MONOMER_CHEMICAL_DISTANCE]:function(t,e){return`\n let aLength: u32 = computeInfo.entrySizes[${e}][aIndex];\n let bLength: u32 = computeInfo.entrySizes[${e}][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${e}); // using pointers make things faster\n var diff: f32 = 0.0;\n for (var i = 0u; i < ${t}; 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 / ${t};\n `},[Z.SOKAL]:function(t,e){return`\n var onBitsa: u32 = 0u;\n var onBitsb: u32 = 0u;\n for (var i = 0u; i < ${t}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 < ${t}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 `},[Z.COSINE]:function(t,e){return`\n var onBitsa: u32 = 0u;\n var onBitsb: u32 = 0u;\n for (var i = 0u; i < ${t}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 < ${t}u; i = i + 1u) {\n commonBits = commonBits + countOneBits(a[i] & b[i]);\n }\n return 1.0 - f32(commonBits) / sqrt(f32(total));\n `},[Z.ASYMMETRIC]:function(t,e){return`\n var onBitsa: u32 = 0u;\n var onBitsb: u32 = 0u;\n for (var i = 0u; i < ${t}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 < ${t}u; i = i + 1u) {\n commonBits = commonBits + countOneBits(a[i] & b[i]);\n }\n return 1.0 - f32(commonBits) / f32(min);\n `},[Z.Difference]:function(t,e){return`\n let range = suppInfo.range${e};\n return f32(abs(f32(a[0]) - f32(b[0])) / range);\n `},[Z.OneHot]:function(t,e){return`\n let aLength: u32 = computeInfo.entrySizes[${e}][aIndex];\n let bLength: u32 = computeInfo.entrySizes[${e}][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 `}},Q={[Z.HAMMING]:t=>Math.ceil(t/30),[Z.EUCLIDEAN]:t=>Math.ceil(t/30),[Z.MANHATTAN]:t=>Math.ceil(t/30),[Z.TANIMOTO]:t=>Math.ceil(t/30),[Z.SOKAL]:t=>Math.ceil(t/30),[Z.COSINE]:t=>Math.ceil(t/30),[Z.ASYMMETRIC]:t=>Math.ceil(t/30),[Z.LEVENSTEIN]:t=>Math.ceil(t*t/60),[Z.NEEDLEMAN_WUNSCH]:t=>Math.ceil(t*t/60),[Z.MONOMER_CHEMICAL_DISTANCE]:t=>Math.ceil(t/25),[Z.Difference]:t=>1,[Z.OneHot]:t=>Math.ceil(t/40),[Z.VECTOR_COSINE]:t=>Math.ceil(t/30)},tt={STRING:new Set([Z.HAMMING,Z.LEVENSTEIN,Z.NEEDLEMAN_WUNSCH,Z.MONOMER_CHEMICAL_DISTANCE,Z.OneHot]),UINT32ARRAY:new Set([Z.HAMMING,Z.EUCLIDEAN,Z.MANHATTAN,Z.MONOMER_CHEMICAL_DISTANCE,Z.LEVENSTEIN,Z.NEEDLEMAN_WUNSCH,Z.TANIMOTO,Z.COSINE,Z.VECTOR_COSINE,Z.SOKAL,Z.ASYMMETRIC,Z.OneHot,Z.Difference]),INT32ARRAY:new Set([Z.EUCLIDEAN,Z.MANHATTAN,Z.OneHot,Z.Difference,Z.VECTOR_COSINE]),FLOAT32ARRAY:new Set([Z.EUCLIDEAN,Z.MANHATTAN,Z.Difference,Z.VECTOR_COSINE]),NUMBER:new Set([Z.EUCLIDEAN,Z.MANHATTAN,Z.Difference]),BITARRAY:new Set([Z.TANIMOTO,Z.COSINE,Z.SOKAL,Z.ASYMMETRIC])};var et=function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((i=i.apply(t,e||[])).next())}))};function nt(t,e,n,i){return t.map(((t,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 ${J[t](e[i],i)}\n }\n `)).join("\n")+"\n"+`\n fn combinedDistance(aIndex: u32, bIndex: u32) -> f32 {\n var distances: array<f32, ${t.length}>;\n ${t.map(((t,e)=>`distances[${e}] = distanceScript${e}(aIndex, bIndex);`)).join("\n")}\n ${K[i](t.length)}\n }\n \n `}var it=n(1991),ot=n.n(it);let rt=0;const st="cliffsDf",at=new h.Subject,lt="Δ activity",ct="SALI",ht="Similarity",ut="line index",dt=["From","To"],pt="filterCliffs";async function mt(t,e,i,o,l,c,h,u,d,p,m,f,g,y,b,v,w){rt++;const C=c/100;let A,S=!1;const x=f.inputs,_=await f.apply({[x[0].name]:e,[x[1].name]:h,...d.preprocessingFuncArgs??{}});let I=[];if(u===N){const e=await function(t,e,i,o,r,s,a=10,l=!1,c=2){const h=new Worker(new URL(n.p+n.u(980),n.b));let u;return h.postMessage({data:t,threshold:e,weights:i,aggregationMethod:o,distanceFns:r,distanceFnArgs:s,maxIterations:a,useWebGPU:l,inflate:c}),{promise:new Promise(((t,e)=>{u=t,h.onmessage=e=>{setTimeout((()=>h.terminate()),100),t(e.data.res)},h.onerror=t=>{setTimeout((()=>h.terminate()),100),e(t)}})),terminate:()=>{try{u(null),h.terminate()}catch(t){console.error(t)}}}}([_.entries],c,[1],"MANHATTAN",[h],[_.options??{}],d?.maxIterations??5,d.useWebGPU??!1).promise;t.columns.addNewInt(t.columns.getUnusedName("MCL Cluster")).init((t=>e.clusters[t])),I=[e.embedX,e.embedY]}else I=await Y([_.entries],u,[h],[1],"MANHATTAN",{...d,distanceFnArgs:[_.options??{}]});if(I.length!==i.length)throw new Error("Number of axes names should be equal to number of embedding dimensions");for(let e=0;e<I.length;++e)t.columns.addNewFloat(i[e]).init((t=>I[e][t]));let L=null;if(d.useWebGPU)try{L=await function(t,e=.8,n,i,o,r){return et(this,void 0,void 0,(function*(){const s=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 t=!1;if(T&&(T.lost.then((()=>{t=!0})),yield new Promise((t=>setTimeout(t,10)))),!T||t){const t=1e9,e=M.limits,n=e.maxBufferSize,i=e.maxStorageBufferBindingSize;try{return T=yield M.requestDevice({requiredLimits:{maxBufferSize:Math.min(n,t),maxStorageBufferBindingSize:Math.min(i,t)}}),T}catch(t){return console.error("Failed to create device with required limits",t),T=yield M.requestDevice(),T}}return T}))}();if(!s)return null;const a=Object.values(Z);if(n.some((t=>!a.includes(t))))throw new Error("Invalid distance metrics provided: "+n.join(", "));if(!Object.values(U).includes(i))throw new Error("Invalid aggregation function provided: "+i);const l=1-e;if(r.length!==t.length||r.length!==n.length||r.length!==o.length)throw new Error("Options, weigths and distance functions must be provided for each column");if(t.some((e=>e.length!==t[0].length)))throw new Error("All entry lists must be the same length");const c=t.length,h=t[0].length,u=t.map(((t,e)=>function(t,e=Z.HAMMING,n,i={gapOpenPenalty:1,gapExtensionPenalty:.6}){var o,r;let s=null;const a=t.some((t=>"string"==typeof t))?(s="STRING",t.map((t=>new Uint32Array(t.split("").map((t=>t.charCodeAt(0))))))):t.some((t=>"number"==typeof t))?(s="NUMBER",t.map((t=>new Float32Array([t])))):"object"==typeof t[0]&&t.some((t=>"_data"in t&&"_length"in t))?(s="BITARRAY",t.map((t=>t._data))):t.some((t=>t instanceof Float32Array))?(s="FLOAT32ARRAY",t):t.some((t=>t instanceof Uint32Array))?(s="UINT32ARRAY",t):t.some((t=>t instanceof Int32Array))?(s="INT32ARRAY",t):void 0;if(!a||!s)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((t=>t.length)));if(!tt[s]||!tt[s].has(e))throw new Error(`Distance metric '${e}' not supported for entry type '${s}'`);const h=c.reduce(((t,e)=>Math.max(t,e)),0),u=Q[e](h),d="INT32ARRAY"===l?Int32Array:"FLOAT32ARRAY"===l?Float32Array:Uint32Array,p=new d(a.length*h);a.forEach(((t,e)=>{p.set(t,e*h)}));let m="",f=0,g="FLOAT32ARRAY",y=null;if(e===Z.NEEDLEMAN_WUNSCH||e===Z.MONOMER_CHEMICAL_DISTANCE){let t=i.scoringMatrix&&i.alphabetIndexes?Object.keys(i.alphabetIndexes).reduce(((t,e)=>Math.max(t,e.charCodeAt(0))),0):-1;if(!i.alphabetIndexes||!i.scoringMatrix){for(let e=0;e<p.length;e++)p[e]>t&&(t=p[e]);i.scoringMatrix=new Array(t+1).fill(null).map((()=>new Array(t+1).fill(0))),i.alphabetIndexes={};for(let t=0;t<i.scoringMatrix.length;t++)i.scoringMatrix[t][t]=1,i.alphabetIndexes[String.fromCharCode(t)]=t}const e=(t+1)*(t+1),s=new Array(t+1).fill(null).map((()=>new Float32Array(t+1)));for(let e=0;e<t+1;e++)s[e][e]=1;const a=i.alphabetIndexes;for(const t of Object.keys(a))for(const e of Object.keys(a))t!==e&&(s[t.charCodeAt(0)][e.charCodeAt(0)]=i.scoringMatrix[a[t]][a[e]]);f=2+e,g="FLOAT32ARRAY",y=new Float32Array(f),y[0]=null!==(o=i.gapOpenPenalty)&&void 0!==o?o:1,y[1]=null!==(r=i.gapExtensionPenalty)&&void 0!==r?r:.6;let l=2;for(let t=0;t<s.length;t++)y.set(s[t],l),l+=s[t].length;m=`\n gapOpenPenalty${n}: f32,\n gapExtensionPenalty${n}: f32,\n similarityMatrix${n}: array<array<f32, ${t+1}>, ${t+1}>`}else if(e===Z.Difference){if(!i.range||"number"!=typeof i.range||i.range<=0){const t=p.reduce(((t,e)=>Math.min(t,e)),p[0]),e=p.reduce(((t,e)=>Math.max(t,e)),p[0]);i.range=e-t}i.range<=0&&(i.range=1),f=1,g="FLOAT32ARRAY",y=new Float32Array([i.range]),m=`\n range${n}: f32`}const b=p instanceof Int32Array?"i32":p instanceof Float32Array?"f32":"u32",v=`data${n}: array<array<${b}, ${h}>, ${a.length}>`;return{flatSourceArray:p,sourceArraySize:p.length,maxEntryLen:h,arraySizes:c,complexity:u,suppInfoBuffer:y,suppInfoSize:f,suppInfoType:g,suppInfoStructWgsl:m,entryType:s,dataTypeWGSL:b,dataStructWgsl:v,EncodedArrayConstructor:d}}(t,n[e],e,r[e])));if(0===c)throw new Error("No columns provided. Please provide at least one column of data.");1===c&&(i=U.MANHATTAN);let d=u.map((t=>t.suppInfoStructWgsl)).filter((t=>!!t&&""!=t)).join(",\n"),p=!1;d&&""!=d.trim()||(p=!0,d="\ndummy: f32\n");const m=u.map((t=>t.dataStructWgsl)).filter((t=>!!t&&""!=t)).join(",\n"),f=new Uint32Array(c*h);u.forEach(((t,e)=>{f.set(t.arraySizes,e*h)}));const g=1e4,y=100,b=u.reduce(((t,e)=>t+e.complexity),0),v=Math.ceil(6e3/b),w=Math.ceil(Math.sqrt(Math.ceil(100))),C=10*w,A=h*(h-1)/2,S=Math.ceil(A/g),x=s.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 ${S} 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, ${h}>, ${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 * ${C} + 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], ${h}u);\n let endAtRow: u32 = min(computeInfo.endAtRows[linearIndex], ${h}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 < ${v}; 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 >= ${h}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 ${nt(n,u.map((t=>t.maxEntryLen)),l,i)}\n\n\n `}),_=s.createComputePipeline({label:"sparse matrix compute pipeline",layout:"auto",compute:{module:x,entryPoint:"calcSparseMatrix"}}),I=new Uint32Array(g),L=new Uint32Array(g),N=new Uint32Array(g),P=new Uint32Array(g),$=Math.floor(A/g);let R=0,k=1;console.time("GPUthreadStarts");for(let t=0;t<g;t++){const e=9999===t?A-1:(t+1)*$,n=h-2-Math.floor(Math.sqrt(-8*e+4*h*(h-1)-7)/2-.5),i=e-h*n+Math.floor((n+1)*(n+2)/2);I[t]=k,L[t]=R,N[t]=i,P[t]=n,R=n,k=i}console.timeEnd("GPUthreadStarts");const O=4e4+h*c+c+u.reduce(((t,e)=>t+e.sourceArraySize),0),H=u.reduce(((t,e)=>t+e.suppInfoSize),0),G=1e6,F=O*Uint32Array.BYTES_PER_ELEMENT;let B=F;const D=15&F;0!==D&&(B+=16-D);const V=s.createBuffer({label:"compute info buffer",size:B,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST,mappedAtCreation:!0}),W=V.getMappedRange();let j=0;new Uint32Array(W,j,g).set(I),j+=g*Uint32Array.BYTES_PER_ELEMENT,new Uint32Array(W,j,g).set(L),j+=g*Uint32Array.BYTES_PER_ELEMENT,new Uint32Array(W,j,g).set(N),j+=g*Uint32Array.BYTES_PER_ELEMENT,new Uint32Array(W,j,g).set(P),j+=g*Uint32Array.BYTES_PER_ELEMENT,new Uint32Array(W,j,f.length).set(f),j+=f.length*Uint32Array.BYTES_PER_ELEMENT,new Float32Array(W,j,c).set(o),j+=c*Float32Array.BYTES_PER_ELEMENT;for(const t of u){const e=t.EncodedArrayConstructor,n=t.sourceArraySize;new e(W,j,n).set(t.flatSourceArray),j+=n*e.BYTES_PER_ELEMENT}V.unmap();const q=H*Uint32Array.BYTES_PER_ELEMENT;let z=q;const Y=15&q;0!==Y&&(z+=16-Y),z=Math.max(z,16);const K=s.createBuffer({label:"supp info buffer",size:z,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST,mappedAtCreation:!0}),X=K.getMappedRange();let J=0;for(const t of u)t.suppInfoBuffer&&t.suppInfoBuffer.byteLength>0&&t.suppInfoSize>0&&(new("UINT32ARRAY"===t.suppInfoType?Uint32Array:Float32Array)(X,J,t.suppInfoBuffer.length).set(t.suppInfoBuffer),J+=t.suppInfoBuffer.byteLength);0===J&&new Uint32Array(X,0,4).set([1,1,1,1]),K.unmap();const et=302e4*Uint32Array.BYTES_PER_ELEMENT;let it=et;const ot=15&et;0!==ot&&(it+=16-ot);const rt=s.createBuffer({label:"results buffer",size:it,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_SRC}),st=s.createBindGroup({label:"bindGroup for sparse matrix buffer",layout:_.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:V}},{binding:1,resource:{buffer:K}},{binding:2,resource:{buffer:rt}}]}),at=s.createBuffer({label:"results out buffer",size:rt.size,usage:GPUBufferUsage.MAP_READ|GPUBufferUsage.COPY_DST}),lt=[],ct=[],ht=[];let ut=!1;for(;!ut;){const t=s.createCommandEncoder({label:"distance encoder"}),e=t.beginComputePass({label:"distance compute pass"});e.setPipeline(_),e.setBindGroup(0,st),e.dispatchWorkgroups(w,w),e.end(),t.copyBufferToBuffer(rt,0,at,0,at.size);const n=t.finish();s.queue.submit([n]),yield s.queue.onSubmittedWorkDone(),yield at.mapAsync(GPUMapMode.READ);const i=at.getMappedRange();let o=0;const r=new Uint32Array(i,o,G);o+=G*Uint32Array.BYTES_PER_ELEMENT;const a=new Uint32Array(i,o,G);o+=G*Uint32Array.BYTES_PER_ELEMENT;const l=new Float32Array(i,o,G);o+=G*Float32Array.BYTES_PER_ELEMENT;const c=new Uint32Array(i,o,g);o+=g*Uint32Array.BYTES_PER_ELEMENT,ut=new Uint32Array(i,o,g).every((t=>1===t));const h=c.reduce(((t,e)=>t+e),0),u=new Uint32Array(h),d=new Uint32Array(h),p=new Float32Array(h);let m=0;for(let t=0;t<c.length;t++){const e=c[t];0!==e&&(u.set(r.subarray(t*y,t*y+e),m),d.set(a.subarray(t*y,t*y+e),m),p.set(l.subarray(t*y,t*y+e),m),m+=e)}lt.push(u),ct.push(d),ht.push(p),at.unmap()}const dt=lt.reduce(((t,e)=>t+e.length),0),pt=new Uint32Array(dt),mt=new Uint32Array(dt),ft=new Float32Array(dt);let gt=0;for(let t=0;t<lt.length;t++)pt.set(lt[t],gt),mt.set(ct[t],gt),ft.set(ht[t],gt),gt+=lt[t].length;return V.destroy(),K.destroy(),rt.destroy(),at.destroy(),{i:pt,j:mt,distance:ft}}))}([_.entries],C,[h],U.MANHATTAN,[1],[_.options??{}])}catch(t){console.error(t)}L||(d.useWebGPU&&console.error("WebGPU sparse matrix calculation failed, falling back to CPU implementation"),L=await(new F).calc(_.entries,h,C,_.options));const P=await async function(t,e){const n=t.distance.map(((n,i)=>{const o=Math.abs(e.get(t.i[i])-e.get(t.j[i]));return 0!=n?o/n:1/0})),i=t.distance.map((t=>1-t)),o=t.i,r=t.j,s=a.BitSet.create(e.length);return t.distance.forEach(((e,n)=>{s.set(t.i[n],!0),s.set(t.j[n],!0)})),{simVals:i,saliVals:n,n1:o,n2:r,cliffsBitSet:s}}(L,l),$=function(t,e,n,i,o,r,s){const l=new Array(t).fill(0);for(let t=0;t!=i.length;++t)n[t]!=1/0&&(s.get(i[t])>s.get(o[t])?l[i[t]]+=n[t]:l[o[t]]+=n[t]);return a.Column.fromList("double",e,l)}(e.length,`sali_${i[0].substring(i[0].lastIndexOf("_"))}`,P.saliVals,P.n1,P.n2,0,l);t.columns.add($);const k=P.cliffsBitSet,O=function(t){const e=t.filter((t=>t!==1/0)),n=e.reduce(((t,e)=>Math.min(t,e)),Number.MAX_VALUE);return{max:e.reduce(((t,e)=>Math.max(t,e)),n),min:n}}(P.saliVals),H=.8/(O.max-O.min),G=r.shell.getTableView(t.name),D=G.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}),V=function(t,e,n,i,o,r,s,l){const c={from:new Uint32Array(e.n1.length),to:new Uint32Array(e.n1.length),opacities:new Float32Array(e.n1.length),colors:new Array(e.n1.length),widths:new Float32Array(e.n1.length)};for(let n=0;n<e.n1.length;n++)c.from[n]=e.n1[n],c.to[n]=e.n2[n],c.opacities[n]=e.saliVals[n]===1/0?1:.2+(e.saliVals[n]-s.min)*l,c.colors[n]=t.selection.get(c.from[n])&&t.selection.get(c.to[n])?"255,255,0":"0,128,0",c.widths[n]=1;const h=a.DataFrame.create(c.from.length);return dt.forEach(((t,e)=>{h.columns.addNewString(t).init((t=>n.get(0===e?c.from[t]:c.to[t]))),function(t,e){Object.keys(e).forEach((n=>{t.tags[n]=e[n]}))}(h.col(t),r),h.col(t).semType=o})),h.columns.addNewFloat(lt).init((t=>Math.abs(i.get(c.from[t])-i.get(c.to[t])))),h.columns.addNewInt(ut).init((t=>t)),h.columns.addNewFloat(ct).init((t=>e.saliVals[t])),h.columns.addNewFloat(ht).init((t=>e.simVals[t])),h.name=`${st}${rt}`,{lines:c,linesDf:h}}(t,P,e,l,p,m,O,H);V.lines.skipMultiLineCalculation=!0,V.linesDf.col(ct).setTag("description","Structure−Activity Landscape Index (activity difference divided by 1 minus similarity)");const j=new W(D,i[0],i[1],V.lines,B.none),q=b?b(V.linesDf,dt).sort([ct],[!1]):V.linesDf.plot.grid().sort([ct],[!1]);q.col(ut)&&(q.col(ut).visible=!1),t.temp[".cliffsDfGrid"]=q;const z=s.button(`${V.linesDf.rowCount} cliffs`,(()=>{const t=ot()(G.viewers).some((t=>t.dataFrame.name===`${st}${rt}`));w&&!t&&G.addViewer(q),G.dockManager.dock(q,"down",null,"Activity cliffs",v??.2)}));z.classList.add("scatter_plot_link","cliffs_grid");const K=s.input.toggle("Show only cliffs",{value:!1,onValueChanged:e=>{e?(D.dataFrame.setTag(pt,i[0]),t.filter.and(k),at.next(i[0])):(D.dataFrame.setTag(pt,""),t.filter.setAll(!0),at.next(""))}});D.root.prepend(s.divH([z,K.root],"cliffs_div")),at.subscribe((t=>{K.enabled=""===t||t===i[0]})),t.onRowsFiltering.subscribe((()=>{K.value&&t.filter.and(P.cliffsBitSet)}));const X=r.events.onViewerClosed.subscribe((t=>{t.args.viewer===D&&(G.dockManager.close(q.root),X.unsubscribe(),G.subs=G.subs.filter((t=>t!==X)))}));return G.subs.push(X),V.linesDf.onCurrentCellChanged.subscribe((()=>{for(let t=0;t<V.linesDf.rowCount;t++)V.lines.widths[t]=t===V.linesDf.currentRowIdx?3:1;j.linesToRender=V.lines;const n=V.linesDf.currentCol&&V.linesDf.currentCol.name===dt[1]?V.lines.to:V.lines.from,o=-1!==V.linesDf.currentRowIdx?V.linesDf.currentRowIdx:null;if(D.dataFrame.currentRowIdx=o?n[o]:-1,null!==o){const n=V.linesDf.currentRowIdx;j.currentLineId=n;const{zoomLeft:a,zoomRight:c,zoomTop:h,zoomBottom:u}=function(t,e,n,i,o,r){const s=Math.abs(n-o),a=Math.abs(i-r),l=t/s,c=e/a,h=Math.min(l,c),u=t/h*5,d=e/h*5,p=(n<o?n:o)+s/2-u/2,m=(i>r?i:r)-a/2+d/2;return{zoomLeft:p,zoomRight:p+u,zoomTop:m,zoomBottom:m-d}}(D.viewport.width,D.viewport.height,D.dataFrame.get(i[0],V.lines.from[n]),D.dataFrame.get(i[1],V.lines.from[n]),D.dataFrame.get(i[0],V.lines.to[n]),D.dataFrame.get(i[1],V.lines.to[n]));D.zoom(a,h,c,u),K.value?t.filter.and(k):!0===K.enabled&&t.filter.setAll(!0),setTimeout((()=>{!function(t,e,n,i,o,a,l,c,h){const u=e.getPane("Cliff Details");s.empty(u.root);const d=h({points:[n,i],lineId:o,df:t,seqCol:a,activityCol:l,sali:c});u.root.append(d),setTimeout((()=>{r.shell.o=e.root}),500)}(t,A,V.lines.from[o],V.lines.to[o],o,e,l,V.linesDf.get(ct,o),y);const n=D.dataFrame.getSortedOrder(G.grid.sortByColumns,G.grid.sortTypes);G.grid.scrollToCell(e.name,n.indexOf(D.dataFrame.currentRowIdx))}),1e3)}})),V.linesDf.onSelectionChanged.subscribe((e=>{setTimeout((()=>(()=>{const e=a.BitSet.create(t.rowCount);for(let t=0;t<V.linesDf.rowCount;t++){const n=V.linesDf.selection.get(t);n&&(e.set(V.lines.from[t],!0),e.set(V.lines.to[t],!0)),V.lines.colors[t]=n?"255,255,0":"0,128,0"}t.selection.copyFrom(e),j.linesToRender=V.lines})()),100)})),t.onSelectionChanged.subscribe((e=>{!1===t.selection.anyTrue&&"number"==typeof e&&(S?S=!1:(t=>{t.selection.setAll(!1);for(let t=0;t<V.lines.colors.length;t++)V.lines.colors[t]="0,128,0";j.linesToRender=V.lines})(q.dataFrame))})),j.lineClicked.subscribe((e=>{if(S=!0,j.currentLineId=e.id,-1!==e.id){const n=V.linesDf.selection.clone();setTimeout((()=>{e.event.ctrlKey?(n.set(e.id,!n.get(e.id)),V.linesDf.selection.copyFrom(n)):(V.linesDf.currentRowIdx!==e.id&&(V.linesDf.currentRowIdx=e.id,t.currentRowIdx=V.lines.from[e.id]),V.linesDf.selection.copyFrom(n));const i=V.linesDf.getSortedOrder(q.sortByColumns,q.sortTypes);q.scrollToCell(dt[0],i.indexOf(e.id))}),500)}})),j.lineHover.pipe((0,R.debounceTime)(500)).subscribe((n=>{-1!==n.id&&-1===t.mouseOverRowIdx&&s.tooltip.show(g({lineId:n.id,points:[V.lines.from[n.id],V.lines.to[n.id]],df:t,seqCol:e,activityCol:l}),n.x,n.y)})),D.addProperty("similarityLimit","double",C),A=function(){const t=s.accordion(),e=s.element("i");return e.className="grok-icon svg-icon svg-view-layout",t.addTitle(s.span([e,s.label("Activity cliffs")])),t.addPane("Cliff Details",(()=>s.divText("Cliff has not been selected")),!0),r.shell.o=t.root,t}(),D}var ft,gt=n(2003),yt=n(3516),bt=n(6718),vt=n(3077),wt=n(439);!function(t){t.IDENTITY="identity",t.SIMILARITY="similarity"}(ft||(ft={}));var Ct=n(9192);class At{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 St extends ${constructor(t={}){super({...t,enableMCL:!0});const e=this.tableInput.value.columns.numericalNoDateTime;this.activitiesInput=s.input.column("Activities",{table:this.tableInput.value,value:a.Utils.firstOrNull(e),filter:t=>Array.from(e).includes(t)}),this.activitiesInputRoot=this.activitiesInput.root,this.similarityInput=s.input.int("Similarity cutoff",{value:80}),this.methodsParams[N]=new At}onTableInputChanged(){if(super.onTableInputChanged(),this.activitiesInputRoot){s.empty(this.activitiesInputRoot);const t=this.tableInput.value.columns.numerical;this.activitiesInput=s.input.column("Activities",{table:this.tableInput.value,value:a.Utils.firstOrNull(t),filter:e=>Array.from(t).includes(e)}),Array.from(this.activitiesInput.root.children).forEach((t=>this.activitiesInputRoot.append(t)))}}getEditor(){return s.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(t){super.applyInput(t),this.activitiesInput.value=this.tableInput.value.col(t.activityCol),this.similarityInput.value=t.simThreshold}}var xt,Et,Mt,Tt=function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((i=i.apply(t,e||[])).next())}))};function _t(t){const e=["Embed_X","Embed_Y"],n=t.columns.names().filter((t=>t.includes(e[0]))).length+1;return e.map((t=>`${t}_${n}`))}function It(t,e){return`${e} (${t.length>4?`${t.length} columns`:t.map((t=>t.name)).join(", ")})`}n(5540),function(t){t.ADD="ADD",t.SUB="SUB",t.MULT="MULT"}(xt||(xt={})),function(t){t.SQUARE="SQUARE",t.INVERSE="INVERSE",t.TRANSPOSE="TRANSPOSE",t.NORM="NORM",t.COLUMN_NORM="COLUMN_NORM"}(Et||(Et={})),function(t){t.SCALARMULT="SCALARMULT",t.SCALARADD="SCALARADD",t.SCALARPOW="SCALARPOW"}(Mt||(Mt={})),Object.prototype.toString;var Lt=n(6873),Nt=n(4356),Pt=n(6717),$t=n(4870),Rt=n(3856),kt=n(6882),Ot=n(7278),Ht=n(5553),Gt=n(6642),Ft=n(3599),Bt=n(673),Dt=n(8312);class Vt extends Gt.sD{monomerLib=null;seqHelper=null;constructor(t,e){super(t,e,eo.logger),(0,bt.pj)().then((t=>{this.monomerLib=t.getMonomerLib(),this.dirty=!0,this.gridCol?.grid?.invalidate(),this.subs.push(this.monomerLib.onChanged.subscribe((()=>{this.dirty=!0,this.gridCol?.grid?.invalidate()})))})),(0,Dt.Q)().then((t=>{this.seqHelper=t,this.dirty=!0,this.gridCol?.grid?.invalidate()}))}}var Wt=n(4139);const Ut=new class{constructor(){this.seqHandler="seq-handler",this.notationProvider="seq-handler.notation-provider"}};class jt extends a.SemanticValue{get value(){return this.seqHandler.column.get(this.rowIdx)}set value(t){this.seqHandler.column.set(this.rowIdx,t)}get helm(){return this.seqHandler.getHelm(this.rowIdx)}isDna(){return this.seqHandler.alphabet===wt.YI.DNA}isRna(){return this.seqHandler.alphabet===wt.YI.RNA}isNaturalPeptide(){return this.seqHandler.alphabet===wt.YI.PT}isHelm(){return this.seqHandler.isHelm()}constructor(t,e){if(null==e.column.dataFrame)throw new Error("Attribute .dataFrame is required for SeqValueBase from cell");const n=e.column.dataFrame.cell(t,e.column.name);super(a.SemanticValue.fromTableCell(n).dart),this.rowIdx=t,this.seqHandler=e}getSplitted(){return this.seqHandler.getSplitted(this.rowIdx)}getSplittedWithSugarsAndPhosphates(){if(!this.isDna()&&!this.isRna())return this.getSplitted();const t=(0,Ot.qp)(this.helm),e=[],n=/\(|\)/;for(let i=0;i<t.length;i++){const o=t.getOriginal(i),r=o.split(n).filter((t=>!!t));3===r.length?(e.push(r[0]),e.push(r[1]),e.push(r[2])):e.push(o)}return new Ot.Mu(e,this.seqHandler.defaultGapOriginal)}}const qt=gt.zS;function zt(t){const e=!ot().enumerate(t).some((([e,n])=>e.length>1&&0!=n&&n!=t.length-1)),n=[],i=e?"":" ";for(const[e,o]of ot().enumerate(t)){let r=e;o<t.length&&(r+=`${e?"":"-"}${i}`),n.push(r)}return[n,e]}class Yt 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=eo.seqHelper}getRendererBack(t){const[e,n,i]=(0,Gt.BG)(t);if(n.meta.units!==gt.Hi.CUSTOM)return i.rendererBack;let o=null;return this.seqHelper&&(o=this.seqHelper.getSeqHandler(n).getRendererBack(e,n)),o}onClick(t,e){if(t.cell.column.temp["current-word"]=t.cell.value,t.grid.invalidate(),t.cell.column.meta.units===gt.Hi.CUSTOM){const n=this.getRendererBack(t);n?.onClick(t,e)}}onMouseEnter(t,e){const n=this.getRendererBack(t);n?.onMouseEnter(t,e),this.hasMouseOver=!0}onMouseMove(t,e){const n=this.getRendererBack(t);n?.onMouseMove(t,e)}onMouseLeave(t,e){if((0,Ht.WN)(t,null),t?.grid){const e=t.grid.onEvent("d4-grid-show-tooltip").subscribe((t=>{e.unsubscribe(),this.hasMouseOver&&t.preventDefault()}))}this.hasMouseOver=!1}onDoubleClick(t,e){const n=this.getRendererBack(t);n?.onDoubleClick(t,e)}onKeyDown(t,e){const n=this.getRendererBack(t);n?.onKeyDown(t,e)}onKeyPress(t,e){const n=this.getRendererBack(t);n?.onKeyPress(t,e)}renderInt(t,e,n,i,o,r,s){const[a,l,c]=(0,Gt.BG)(r);if(!l)return;const h=l.temp,u=this.seqHelper.getSeqHandler(l);let d=(eo.properties?eo.properties.maxMonomerLength:4)??50;if(Rt.gp.maxMonomerLength in l.tags){const t=parseInt(l.getTag(Rt.gp.maxMonomerLength));d=!isNaN(t)&&t?t:50}if(".mm.cellRenderer.maxMonomerLength"in h){const t=h[".mm.cellRenderer.maxMonomerLength"];d=!isNaN(t)&&t?t:50}let p=c.rendererBack;p||(p=c.rendererBack=new kt.Jy(a,l,eo.logger,d,(()=>{const{font:t,fontWidth:e}=kt.Jy.getFontSettings(l);return{font:t,fontCharWidth:e,separatorWidth:u.isMsa()?8:0,monomerToShort:qt}})),l.temp[".mm.cellRenderer.settingsChanged"],Bt.s.true,p.init().then((()=>{}))),p.render(t,e,n,i,o,r,s)}render(t,e,n,i,o,r,s){if(r.cell.column?.meta?.units!==gt.Hi.CUSTOM)this.renderInt(t,e,n,i,o,r,s);else{const a=this.getRendererBack(r);a?.render(t,e,n,i,o,r,s)}}}class Kt extends Vt{constructor(t,e){super(t,e)}render(t,e,n,i,o,r,s){const a=window.devicePixelRatio,l=r.grid,c=r.cell.value??"",h=this.tableCol.tags[gt.gp.separator],u=this.tableCol.meta.units;i=(0,kt.U0)(l,t,e,i,a);const[d,p]=c.split("#"),m=this.tableCol.temp[Ut.notationProvider]?.separatorSplitter??(0,Ot.Iv)(u,h),f=m(d),g=m(p),y=ot().count(0).take(f.length).map((t=>f.getCanonical(t))).toArray(),b=ot().count(0).take(g.length).map((t=>g.getCanonical(t))).toArray(),v=this.tableCol.getTag(gt.gp.alphabet);Xt(t,e,n,i,o,y,b,v===gt.YI.RNA||v===gt.YI.DNA?Ft.o.NUCLEOTIDE:Ft.o.AA,this.monomerLib,void 0,void 0)}async awaitRendered(t=1e4,e=`${t} timeout`){return Promise.resolve()}static getOrCreate(t){const[e,n,i]=(0,Gt.BG)(t);let o=i.rendererBack;return o||(o=i.rendererBack=new Kt(e,n)),o}}class Zt extends a.GridCellRenderer{get name(){return"MacromoleculeDifferenceCR"}get cellType(){return Wt.uF.MACROMOLECULE_DIFFERENCE}get defaultHeight(){return 30}get defaultWidth(){return 230}render(t,e,n,i,o,r,s){Kt.getOrCreate(r).render(t,e,n,i,o,r,s)}}function Xt(t,e,n,i,o,r,s,a,l,c,h){if(r.length!==s.length){const t=function(t,e){let n=0,i=0;const o=t.length>e.length?t:e,r=t.length>e.length?e:t;for(let t=0;t<r.length;t++)o[t]===r[t]&&n++;const s=o.length-r.length;for(let t=o.length-1;t>s;t--)o[t]===r[t-s]&&i++;const a=new Array(Math.abs(t.length-e.length)).fill(wt.b9[gt.Hi.FASTA]);function l(t){return n>i?t.concat(a):a.concat(t)}return t.length>e.length?e=l(ot()(e).toArray()):t=l(ot()(t).toArray()),{subParts1:t,subParts2:e}}(r,s);r=t.subParts1,s=t.subParts2}const u=t.measureText(zt(r).join("")),d=t.measureText(zt(s).join("")),p=Math.max(u.width,d.width);c&&(i=p+4*r.length,t.canvas.width=p+4*r.length);let m=Math.max(e,e+(i-(p+4*r.length))/2)+5;const f=Math.max(n,n+(o-28)/2);t.save();try{t.beginPath(),t.rect(e,n,c?p+4*r.length:i,o),t.clip(),t.font="12px monospace",t.textBaseline="top";const u=7;for(let e=0;e<r.length;e++){const n=r[e],c=s[e];let d=kt.S$;if(l&&(d=l.getMonomerTextColor(a,n)),n!=c){let r=kt.S$;l&&(r=l.getMonomerTextColor(a,c));const s=(0,Rt.oZ)(t,n,m,f-u,i,o,{color:d,pivot:0,left:!0}),p=(0,Rt.oZ)(t,c,m,f+u,i,o,{color:r,pivot:0,left:!0});m=Math.max(p,s),h&&(h[e]=Jt(n,c,d,r,f,u,o))}else m=(0,Rt.oZ)(t,n,m,f,i,o,{color:d,pivot:0,left:!0,transparencyRate:.5});m+=4}}finally{t.restore()}}function Jt(t,e,n,i,o,r,s){const a=document.createElement("canvas"),l=a.getContext("2d");l.font="12px monospace";const c=l.measureText(zt([t]).join("")).width,h=l.measureText(zt([e]).join("")).width,u=Math.max(c,h);return a.height=s,a.width=u+4,l.font="12px monospace",l.textBaseline="top",(0,Rt.oZ)(l,t,0,o-r,u,s,{color:n,pivot:0,left:!0}),(0,Rt.oZ)(l,e,0,o+r,u,s,{color:i,pivot:0,left:!0}),a}var Qt,te=n(8070),ee=n(4326);!function(t){t.Unknown="unknown",t.FR="framework",t.CDR="cdr"}(Qt||(Qt={}));const ne=new class{constructor(){this.regionTypes=[Qt.CDR],this.chains=["Heavy","Light"],this.skipEmptyPositions=!1,this.fitWidth=!1,this.positionWidth=16,this.positionHeight=ee.fH.Entropy,this.filterSource=ee.Fo.filterSource}};var ie=n(7602),oe=n(250);const re=Qt;var se,ae;!function(t){t.STYLE="Style",t.BEHAVIOR="Behavior",t.LAYOUT="Layout",t.DATA="Data"}(se||(se={})),function(t){t.skipEmptyPositions="skipEmptyPositions",t.regionTypes="regionTypes",t.chains="chains",t.fitWidth="fitWidth",t.positionWidth="positionWidth",t.positionHeight="positionHeight",t.filterSource="filterSource"}(ae||(ae={}));const le=ne;class ce 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(ae.skipEmptyPositions,le.skipEmptyPositions,{category:se.DATA}),this.regionTypes=this.stringList(ae.regionTypes,le.regionTypes,{category:se.DATA,choices:Object.values(re).filter((t=>t!=re.Unknown))}),this.chains=this.stringList(ae.chains,le.chains,{category:se.DATA,choices:["Heavy","Light"]}),this.fitWidth=this.bool(ae.fitWidth,le.fitWidth,{category:se.LAYOUT}),this.positionWidth=this.float(ae.positionWidth,le.positionWidth,{category:se.LAYOUT,editor:"slider",min:0,max:64,description:"Internal WebLogo viewers property width of position."}),this.positionHeight=this.string(ae.positionHeight,le.positionHeight,{category:se.LAYOUT,choices:Object.keys(ee.fH)}),this.filterSource=this.string(ae.filterSource,le.filterSource,{category:se.BEHAVIOR,choices:Object.values(ee.lT)}),this.viewSyncer=new ie.g(eo.logger)}static viewerCounter=-1;viewerId=++ce.viewerCounter;viewerToLog(){return`VdRegionsViewer<${this.viewerId}>`}async init(){this.subs.push((0,h.fromEvent)(this.root,"mousemove").subscribe(this.rootOnMouseMove.bind(this)))}detach(){const t=`${this.viewerToLog()}.detach()`,e=super.detach.bind(this);this.viewSyncer.sync(`${t}`,(async()=>{this.setDataInProgress||(this.viewed&&(await this.destroyView("detach"),this.viewed=!1),e())}))}onTableAttached(){super.onTableAttached(),this.setData(this.regions)}onPropertyChanged(t){if(super.onPropertyChanged(t),t){switch(t.name){case ae.regionTypes:case ae.chains:this.setData(this.regions)}switch(t.name){case ae.skipEmptyPositions:for(let t=0;t<this.logos.length;++t)for(const e of this.chains)this.logos[t][e].setOptions({[oe.n5.skipEmptyPositions]:this.skipEmptyPositions});this.calcSize();break;case ae.fitWidth:case ae.positionWidth:this.calcSize();break;case ae.positionHeight:for(let t=0;t<this.logos.length;++t)for(const e of this.chains)this.logos[t][e].setOptions({[oe.n5.positionHeight]:this.positionHeight});this.calcSize();break;case ae.filterSource:this.filterSourceInput.value=this.filterSource;break;default:this.setData(this.regions)}}else console.warn("Bio: VdRegionsViewer.onPropertyChanged() property is null")}setData(t){const e=`${this.viewerToLog()}.setData()`;eo.logger.debug(`${e}, in, regions.length = ${t.length}`),this.viewSyncer.sync(`${e}`,(async()=>{if(!this.setDataInProgress){this.setDataInProgress=!0;try{this.viewed&&(await this.destroyView("setData"),this.viewed=!1),this.regions=t,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(t){eo.logger.debug(`Bio: VdRegionsViewer.destroyView( mainLayout = ${this.mainLayout?"value":"none"} ), purpose = '${t}', this.regions.length = ${this.regions.length}`),this.filterSourceInput&&s.empty(this.filterSourceInput.root),null!=this.mainLayout&&(this.mainLayout.remove(),this.host.remove(),this.host=null,this.mainLayout=null);for(const t of this.viewSubs)t.unsubscribe()}async buildView(t){eo.logger.debug(`Bio: VdRegionsViewer.buildView() begin, purpose = '${t}', this.regions.length = ${this.regions.length}`);const e=this.regions.filter((t=>this.regionTypes.includes(t.type))),n=Array.from(new Set(e.map((t=>t.order)))).sort(),i=[];for(let t=0;t<n.length;t++)for(const o of this.chains){const r=e.find((e=>e.order==n[t]&&e.chain==o));i.push((async()=>{const e=await this.dataFrame.plot.fromType("WebLogo",{sequenceColumnName:r.sequenceColumnName,startPositionName:r.positionStartName,endPositionName:r.positionEndName,fixWidth:!0,skipEmptyPositions:this.skipEmptyPositions,positionWidth:this.positionWidth,positionHeight:this.positionHeight,filterSource:this.filterSource});return e.onSizeChanged.subscribe((()=>{this.calcSize()})),[t,o,e]})())}const o=await Promise.all(i);this.logos=new Array(n.length);for(let t=0;t<n.length;++t)this.logos[t]={};for(const[t,e,n]of o)this.logos[t][e]=n,this.viewSubs.push(n.onFreqsCalculated.subscribe((()=>{this.calcSize()})));this.mainLayout=s.table(this.chains,(t=>[...n.length>0?[s.div(t,{style:{transform:"rotate(-90deg)",font:"12px Roboto, Roboto Local, sans-serif",textAlign:"center",width:"16px",marginTop:"24px",marginLeft:"6px"}})]:[],...[...Array(n.length).keys()].map((e=>{const n=this.logos[e][t];return n.root.style.height="100%",s.div([n.root],{style:{marginTop:"4px",marginBottom:"4px"}})}))]),["",...[...Array(n.length).keys()].map((t=>e.find((e=>e.order==n[t]&&e.chain==this.chains[0])).name||"Name"))]),this.mainLayout.className="mlb-vd-regions-viewer-table2",this.filterSourceInput=s.input.choice("Data source",{value:this.filterSource,items:Object.values(ee.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=s.div([this.mainLayout,this.filterSourceInput.root],{}),this.root.appendChild(this.host),this.root.style.overflowX="auto",this.calcSize(),this.viewSubs.push(s.onSizeChanged(this.root).subscribe(this.rootOnSizeChanged.bind(this))),eo.logger.debug("Bio: VdRegionsViewer.buildView() end")}calcSizeRequested=!1;calcSize(){eo.logger.debug("Bio: VdRegionsViewer.calcSize(), start");const t=()=>{if(!this.host)return;const t=(this.root.clientHeight-54)/this.chains.length;let e=0;for(let n=0;n<this.logos.length;n++){for(const e of this.chains)this.logos[n][e].root.style.height=`${t}px`;e+=Math.max(...this.chains.map((t=>this.logos[n][t].Length)))}if(this.fitWidth){if(this.logos.length>0&&e>0){const t=22,n=13,i=9,o=(this.root.clientWidth-t-(this.logos.length-1)*i-n)/e;for(let t=0;t<this.logos.length;t++)for(const e of this.chains){const n=this.logos[t][e];n.setOptions({[oe.n5.positionWidth]:o-n.positionMarginValue}),n.root.style.width=o*n.Length+"px"}}this.host.style.setProperty("overflow","hidden","important")}else{for(let t=0;t<this.logos.length;t++)for(const e of this.chains)this.logos[t][e].setOptions({[oe.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((()=>{t(),this.calcSizeRequested=!1}),0))}rootOnSizeChanged(t){this.calcSize()}rootOnMouseMove(t){}filterSourceInputOnValueChanged(){const t=`${this.viewerToLog()}.filterSourceInputOnValueChanged()`,e=this.filterSourceInput.value;this.viewSyncer.sync(`${t}`,(async()=>{if(this.filterSource!==e){this.props.getProperty(ae.filterSource).set(this,e);for(let t=0;t<this.logos.length;t++)for(let e=0;e<this.chains.length;e++){const n=this.chains[e];this.logos[t][n].setOptions({[oe.n5.filterSource]:this.filterSource})}}}))}_onRendered=new h.Subject;get onRendered(){return this._onRendered}invalidate(t){const e=`${this.viewerToLog()}.invalidate(${t?` <- ${t} `:""})`;this.viewSyncer.sync(`${e}`,(async()=>{this._onRendered.next()}))}async awaitRendered(t=5e3){await(0,te.PE)(this.onRendered,(()=>{}),(()=>{this.invalidate()}),t);const e=this.viewSyncer.resetErrors();if(e.length>0)throw e[0]}}var he=n(6625),ue=n(6863);async function de(t,e,n="Morgan",i=1,o=.6){const r=t.length,s=eo.seqHelper.getSeqHandler(t),a=Array(r);let l=1;const c=new Map,h=t.categories,u=t.getRawData();for(let e=0;e<r;e++){if(null===h[u[e]]||t.isNone(e)){a[e]=null;continue}a[e]="";const n=s.getSplitted(e);for(let t=0;t<n.length;t++){const i=n.getCanonical(t);c.has(i)||(c.set(i,String.fromCharCode(l)),l++),a[e]+=c.get(i)}}let d={};if(e===ue.Z.MONOMER_CHEMICAL_DISTANCE||e===ue.Z.NEEDLEMANN_WUNSCH){const t=Array.from(c.keys()),r=await(0,bt.A7)(t,n),s={};Object.entries(r.alphabetIndexes).forEach((([t,e])=>{s[c.get(t)]=e}));const l=a.reduce(((t,e)=>Math.max(t,e?.length||0)),0);d={scoringMatrix:r.scoringMatrix,alphabetIndexes:s,maxLength:l},e===ue.Z.NEEDLEMANN_WUNSCH&&(d.gapOpen=i,d.gapExtend=o)}return{seqList:a,options:d}}var pe=n(4954);function me(t){const e=s.divH([],{style:{gap:"10px"}}),n=s.divV([s.divText(t.seqCol.name),s.divText(t.activityCol.name)]);return n.style.fontWeight="bold",n.style.display="flex",n.style.justifyContent="space-between",e.append(n),t.points.forEach((n=>{const i=s.divText(t.activityCol.get(n).toFixed(2));i.style.display="flex",i.style.justifyContent="left",i.style.paddingLeft="30px",e.append(s.divV([s.divText(t.seqCol.get(n)),i]))})),e}function fe(t){const e=s.div();e.append(s.divText(t.seqCol.name,{style:{fontWeight:"bold"}}));const n=new Array(2);t.points.forEach(((e,i)=>{n[i]=t.activityCol.get(e)}));const i={},o=eo.seqHelper.getSeqHandler(t.seqCol),r=o.defaultBiotype,a=ye(o.getSplitted(t.points[0]),o.getSplitted(t.points[1]),r,i);return e.append(s.div(a,{style:{width:"300px",overflow:"scroll"}})),e.append(be(i)),e.append(ge("Activity delta",Math.abs(n[0]-n[1]))),e.append(ge("Cliff",t.sali)),e}function ge(t,e){return s.divH([s.divText(`${t}: `,{style:{fontWeight:"bold",paddingRight:"5px"}}),s.divText(e.toFixed(2))],{style:{paddingTop:"10px"}})}function ye(t,e,n,i){const o=document.createElement("canvas"),r=o.getContext("2d");o.height=30;const s=eo.monomerLib;return Xt(r,0,0,0,30,ot().count(0).take(t.length).map((e=>t.getCanonical(e))).toArray(),ot().count(0).take(e.length).map((t=>e.getCanonical(t))).toArray(),n,s,!0,i),o}function be(t){const e=s.div();if(Object.keys(t).length>0){const n=s.divV([]);n.append(s.divH([s.divText("Pos",{style:{fontWeight:"bold",width:"30px",borderBottom:"1px solid"}}),s.divText("Difference",{style:{fontWeight:"bold",borderBottom:"1px solid"}})]));for(const e of Object.keys(t))t[e].style.borderBottom="1px solid lightgray",n.append(s.divH([s.divText((parseInt(e)+1).toString(),{style:{width:"30px",borderBottom:"1px solid lightgray"}}),t[e]]));e.append(n)}return e}function ve(t,e){const n=a.Column.string("seq_diff",t.rowCount).init((n=>`${t.get(e[0],n)}#${t.get(e[1],n)}`));n.semType="MacromoleculeDifference",n.meta.units=t.col(e[0]).meta.units,n.setTag(gt.gp.separator,t.col(e[0]).getTag(gt.gp.separator)),t.columns.add(n);const i=t.plot.grid();return i.col(e[0]).visible=!1,i.col(e[1]).visible=!1,i}class we extends a.JsViewer{constructor(t,e){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,{...e?{semType:e}:{},nullable:!1}),this.name=t,this.semType=e}init(){this.initialized=!0}detach(){this.subs.forEach((t=>t.unsubscribe()))}async onTableAttached(){if(this.init(),this.dataFrame){this.subs.push(a.debounce(this.dataFrame.onRowsRemoved,50).subscribe((t=>this.render(!0))));const t="diversity"!==this.name;this.subs.push(a.debounce(this.dataFrame.onCurrentRowChanged,50).subscribe((e=>{this.gridSelect||this.render(t)}))),this.subs.push(a.debounce(this.dataFrame.selection.onChanged,50).subscribe((t=>this.render(!1)))),this.subs.push(a.debounce(s.onSizeChanged(this.root),50).subscribe((t=>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(t){if(super.onPropertyChanged(t),this.initialized){if("targetColumnName"===t.name){const e=this.dataFrame.col(t.get(this));e.semType===this.semType&&(this.targetColumn=e)}this.debouncedRender()}}debouncedRender(t=!0){this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout((()=>{this.render(t),this.debounceTimer=null}),100)}render(t=!0){this.renderPromise=this.renderPromise.then((async()=>{this.computeRequested=this.computeRequested||t,await this.renderInt(t)}))}async renderInt(t){}beforeRender(){return!(!this.initialized||!this.targetColumnName||this.dataFrame&&this.targetColumnName&&this.dataFrame.col(this.targetColumnName).semType!==this.semType&&(r.shell.error(`${this.targetColumnName} is not ${this.semType} type`),1))}}class Ce extends we{distanceMetric;fingerprint;gapOpen;gapExtend;metricsProperties=["distanceMetric","fingerprint","gapOpen","gapExtend"];fingerprintChoices=["Morgan","RDKit","Pattern","AtomPair","MACCS","TopologicalTorsion"];distanceFunctionChoices=[ue.Z.NEEDLEMANN_WUNSCH,ue.Z.HAMMING,ue.Z.LEVENSHTEIN,ue.Z.MONOMER_CHEMICAL_DISTANCE];tags=[a.TAGS.UNITS,gt.gp.aligned,gt.gp.separator,gt.gp.alphabet,"cell.renderer"];preComputeDistanceMatrix=!1;requiresSampling=!1;constructor(t,e){super(t,e),this.distanceMetric=this.string("distanceMetric",ue.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 t=this.dataFrame.rowCount;this.preComputeDistanceMatrix=t<=1e4,this.requiresSampling=t>1e4}}needsGapPenalties(){return this.distanceMetric===ue.Z.NEEDLEMANN_WUNSCH}needsFingerprint(){return this.distanceMetric===ue.Z.MONOMER_CHEMICAL_DISTANCE||this.distanceMetric===ue.Z.NEEDLEMANN_WUNSCH}}const Ae={gapPenalty:1,matchScore:1,gapSymbol:wt.b9[wt.Hi.FASTA],localAlignment:!1};class Se extends Ce{seqHelper;cutoff;hotSearch;similarColumnLabel;sketchedMolecule="";curIdx=0;molCol=null;idxs=null;scores=null;gridSelect=!1;targetMoleculeIdx=0;computeCompleted=new h.Subject;distanceMatrixComputed=!1;mmDistanceMatrix;knn;kPrevNeighbors=0;demo;analysisGrid;subInited=!1;lastDistanceMetric="";lastFingerprint="";lastGapOpen=0;lastGapExtend=0;constructor(t,e){super("similarity",a.SEMTYPE.MACROMOLECULE),this.seqHelper=t,this.cutoff=this.float("cutoff",.01,{min:0,max:1}),this.hotSearch=this.bool("hotSearch",!0),this.similarColumnLabel=this.string("similarColumnLabel",null),this.demo=e}init(){this.hotSearch=!0,this.initialized=!0}async renderInt(t){if(this.beforeRender()&&this.targetColumn){this.curIdx=-1==this.dataFrame.currentRowIdx?0:this.dataFrame.currentRowIdx;const e=this.lastDistanceMetric!==this.distanceMetric||this.lastFingerprint!==this.fingerprint||this.lastGapOpen!==this.gapOpen||this.lastGapExtend!==this.gapExtend;if(t&&!this.gridSelect||e){this.targetMoleculeIdx=(this.dataFrame.currentRowIdx??-1)<0?0:this.dataFrame.currentRowIdx,await this.computeByMM();const t=null!=this.similarColumnLabel?this.similarColumnLabel:`similar (${this.targetColumn})`;this.molCol=a.Column.string(t,this.idxs.length).init((t=>this.targetColumn?.get(this.idxs?.get(t)))),this.molCol.semType=a.SEMTYPE.MACROMOLECULE,this.tags.forEach((t=>this.molCol.setTag(t,this.targetColumn.getTag(t))));const e=a.DataFrame.fromColumns([this.idxs,this.molCol,this.scores]);await e.meta.detectSemanticTypes(),await r.data.detectSemanticTypes(e),this.molCol.temp["reference-sequence"]=this.targetColumn.get(this.targetMoleculeIdx),this.molCol.temp[".mm.cellRenderer.maxMonomerLength"]=4;let n=null;e.onCurrentRowChanged.subscribe((t=>{n&&clearTimeout(n),(e.currentRowIdx??-1)<0||(this.dataFrame.currentRowIdx=e.col("indexes").get(e.currentRowIdx),n=setTimeout((()=>{this.createPropertyPanel(e)}),300),this.gridSelect=!0)})),this.analysisGrid?(this.analysisGrid.dataFrame=e,this.analysisGrid.invalidate()):(this.analysisGrid=e.plot.grid(),(0,$t.Ku)(this.root,this.analysisGrid.root)),this.analysisGrid.col("indexes").visible=!1,(0,$t.Kd)(this.analysisGrid,this.molCol.name,450,30,!0);const i=this.idxs?.getRawData().findIndex((t=>t==this.targetMoleculeIdx));this.analysisGrid.cell("score",i).cell.value=null;const o=r.shell.tv;this.subInited||(o.grid.root.addEventListener("click",(t=>{this.gridSelect=!1})),this.subInited=!0),this.computeCompleted.next(!0)}}}async computeByMM(){const t=this.targetColumn.length,e=Math.min(this.limit,t-1);if(!this.knn||this.kPrevNeighbors!==e||this.lastDistanceMetric!==this.distanceMetric||this.lastFingerprint!==this.fingerprint||this.lastGapOpen!==this.gapOpen||this.lastGapExtend!==this.gapExtend){const t=this.distanceMetric,n=await de(this.targetColumn,t,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=e,this.knn=await(new F).getKNN(i,t,e,o)}const n=new Array(e).fill(0).map(((t,e)=>({idx:this.knn.knnIndexes[this.targetMoleculeIdx][e],score:1-this.knn.knnDistances[this.targetMoleculeIdx][e]})));n.sort(((t,e)=>e.score-t.score)),n.unshift({idx:this.targetMoleculeIdx,score:a.FLOAT_NULL}),this.idxs=a.Column.int("indexes",e+1).init((t=>n[t].idx)),this.scores=a.Column.float("score",e+1).init((t=>n[t].score))}createPropertyPanel(t){const e=s.div(),n={},i=this.molCol?.name,o=t.col(i),a=this.seqHelper.getSeqHandler(this.targetColumn),l=this.seqHelper.getSeqHandler(o),c=a.getSplitted(this.targetMoleculeIdx),h=l.getSplitted(t.currentRowIdx),u=function(t,e,n={}){const i={...Ae,...n},o=t.length,r=e.length,s=Array(o+1).fill(0).map((()=>Array(r+1).fill(0)));let a=-9999,l=[1,1];for(let n=1;n<o+1;n++)for(let o=1;o<r+1;o++)s[n][o]=Math.max(0,s[n-1][o-1]+(t.getCanonical(n-1)===e.getCanonical(o-1)?i.matchScore:-i.matchScore),s[n-1][o]-i.gapPenalty,s[n][o-1]-i.gapPenalty),s[n][o]>=a&&(a=s[n][o],l=[n,o]);let c=i.localAlignment?l[0]:o,h=i.localAlignment?l[1]:r,u=new Array(0),d=new Array(0);for(;c>0&&h>0;){const n=Math.max(s[c-1][h-1],s[c-1][h],s[c][h-1]);s[c][h]==s[c-1][h-1]+i.matchScore&&n==s[c-1][h-1]?(u.push(t.getCanonical(c-1)),d.push(e.getCanonical(h-1)),c-=1,h-=1):s[c][h]==s[c-1][h]-i.gapPenalty?(d.push(i.gapSymbol),u.push(t.getCanonical(c-1)),c-=1):s[c][h]==s[c][h-1]-i.gapPenalty?(u.push(i.gapSymbol),d.push(e.getCanonical(h-1)),h-=1):(u.push(t.getCanonical(c-1)),d.push(e.getCanonical(h-1)),c-=1,h-=1)}u=[...ot().count(0).take(c).map((e=>t.getCanonical(e))),...u.reverse(),...i.localAlignment?ot().count(l[0]).take(o).map((e=>t.getCanonical(e))):[]],d=[...ot().count(0).take(h).map((t=>e.getCanonical(t))),...d.reverse(),...i.localAlignment?ot().count(l[1]).take(r).map((t=>e.getCanonical(t))):[]];const p=c,m=h;return p>m?d=[...new Array(p-m).fill(i.gapSymbol.valueOf()),...d]:u=[...new Array(m-p).fill(i.gapSymbol.valueOf()),...u],d.length>u.length?u.push(...new Array(d.length-u.length).fill(i.gapSymbol.valueOf())):d.push(...new Array(u.length-d.length).fill(i.gapSymbol.valueOf())),{seq1:u.join(""),seq2:d.join(""),seq1Splitted:new Ot.Mu(u,i.gapSymbol),seq2Splitted:new Ot.Mu(d,i.gapSymbol)}}(c,h),d=ye(u.seq1Splitted,u.seq2Splitted,l.defaultBiotype,n);e.append(s.div(d,{style:{width:"300px",overflow:"scroll"}})),c.length!==h.length&&e.append(s.divV([s.divText("Different sequence length:",{style:{fontWeight:"bold"}}),s.divText(`target: ${c.length} monomers`),s.divText(`selected: ${h.length} monomers`)],{style:{paddingBottom:"10px"}})),e.append(be(n));const p=s.accordion(),m=s.element("i");m.className="grok-icon svg-icon svg-view-layout",p.addTitle(s.span([m,s.label("Similarity search")])),p.addPane("Differences",(()=>e),!0),r.shell.o=p.root}}class xe extends Ce{seqHelper;diverseColumnLabel;renderMolIds=null;columnNames=[];computeCompleted=new h.Subject;sampledIndices=null;constructor(t){super("diversity",a.SEMTYPE.MACROMOLECULE),this.seqHelper=t,this.diverseColumnLabel=this.string("diverseColumnLabel",null)}async renderInt(t){if(this.beforeRender()&&this.dataFrame&&t&&this.targetColumn){await this.computeByMM();const t=null!=this.diverseColumnLabel?this.diverseColumnLabel:`diverse (${this.targetColumnName})`,e=a.Column.string(t,this.renderMolIds.length).init((t=>this.targetColumn?.get(this.renderMolIds[t])));e.semType=a.SEMTYPE.MACROMOLECULE,this.tags.forEach((t=>e.setTag(t,this.targetColumn.getTag(t))));const n=a.DataFrame.fromColumns([e]);e.temp[".mm.cellRenderer.maxMonomerLength"]=4,n.onCurrentRowChanged.subscribe((t=>{this.dataFrame.currentRowIdx=this.renderMolIds[n.currentRowIdx]}));const i=n.plot.grid();(0,$t.Kd)(i,e.name,450,30),(0,$t.Ku)(this.root,i.root),this.computeCompleted.next(!0)}}async computeByMM(){const t=this.targetColumn.length;let e;this.requiresSampling&&t>1e4?(e=this.createRandomSample(t,1e4),this.sampledIndices=e):(e=Array.from({length:t},((t,e)=>e)),this.sampledIndices=null);const n=this.distanceMetric,i=await de(this.targetColumn,n,this.fingerprint,this.gapOpen,this.gapExtend),o=i.seqList,r=i.options,s=e.map((t=>o[t])),a=new G(!0,!1),l=await a.calc(s,n,!0,r);a.terminate();const c=e.length,h=(d=c,(t,e)=>d*t+e-Math.floor((t+2)*(t+1)/2)),u=function(t,e){function n(t,e){let n=null,i=null;for(const o of t){const t=e(o);(null==i||t>i)&&(n=o,i=t)}return n}const i=[(r=t-1,Math.floor(function(t){return Math.random()*t}(r)))],o=new Set;var r;for(let e=0;e<t;++e)i.includes(e)||o.add(e);for(;i.length<e;){const t=n(o.values(),(t=>Math.min.apply(Math,i.map((function(e,n){return l[h(t,e)]})))));null!=t&&(i.push(t),o.delete(t))}return i}(c,Math.min(c,this.limit));var d;this.renderMolIds=u.map((t=>e[t]))}createRandomSample(t,e){const n=[];for(let e=0;e<t;e++)this.targetColumn.isNone(e)||n.push(e);if(n.length<=e)return n;for(let t=n.length-1;t>0;t--){const e=Math.floor(Math.random()*(t+1)),i=n[t];n[t]=n[e],n[e]=i}return n.slice(0,e)}}var Ee,Me=n(5433),Te=n(3890),_e=n(1687);!function(t){t.TYPE="V2000",t[t.NUM_OF_HEADER_LINES=3]="NUM_OF_HEADER_LINES",t[t.NUM_OF_COUNTS_DIGITS=3]="NUM_OF_COUNTS_DIGITS",t[t.ATOM_TYPE_COL=4]="ATOM_TYPE_COL",t[t.FIRST_BONDED_ATOM_COL=1]="FIRST_BONDED_ATOM_COL",t[t.BOND_TYPE_COL=3]="BOND_TYPE_COL",t[t.RGP_SHIFT=8]="RGP_SHIFT",t[t.MAX_ATOM_COUNT=999]="MAX_ATOM_COUNT",t.RGP_LINE_START="M RGP",t.ATOM_ALIAS_LINE_START="A ",t.END="M END"}(Ee||(Ee={}));class Ie{constructor(t){this.init(t)}init(t){this.fileContent=t.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 t;return null!==(t=this.xyzAtomCoordinates)&&void 0!==t||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.x}get y(){var t;return null!==(t=this.xyzAtomCoordinates)&&void 0!==t||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.y}get z(){var t;return null!==(t=this.xyzAtomCoordinates)&&void 0!==t||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.z}get atomTypes(){var t;return null!==(t=this._atomTypes)&&void 0!==t||(this._atomTypes=this.parseAtomTypes()),this._atomTypes}get pairsOfBondedAtoms(){var t;return null!==(t=this._pairsOfBondedAtoms)&&void 0!==t||(this._pairsOfBondedAtoms=this.parseBondedAtomPairs()),this._pairsOfBondedAtoms}get bondTypes(){var t;return null!==(t=this._bondTypes)&&void 0!==t||(this._bondTypes=this.parseBondTypes()),this._bondTypes}setAtomAndBondCounts(){const{atomCount:t,bondCount:e}=this.parseAtomAndBondCounts();this._atomCount=t,this._bondCount=e}getNextColumnIdx(t){for(;!this.isWhitespace(t);)++t;for(;this.isWhitespace(t);)++t;return t}shiftIdxToSpecifiedColumn(t,e){let n=t;const i=this.isWhitespace(n)?e:e-1;for(let t=0;t<i;t++)n=this.getNextColumnIdx(n);return n}parseAtomTypes(){const t=this.atomCount,e=new Array(t);let n=this.getAtomBlockIdx();for(let i=0;i<t;i++)n=this.shiftIdxToAtomType(n),e[i]=this.parseAtomType(n),n=this.getNextLineIdx(n);return e}parseAtomCoordinates(){const t=new Float32Array(this.atomCount),e=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 r of[t,e,n])r[o]=this.parseFloatValue(i),i=this.getNextColumnIdx(i);i=this.getNextLineIdx(i)}return{x:t,y:e,z:n}}parseBondedAtomPairs(){const t=new Array(this.bondCount);let e=this.getBondBlockIdx();for(let n=0;n<this.bondCount;n++){e=this.shiftIdxToBondedAtomsPair(e);const i=new Uint16Array(2);i[0]=this.parseIntValue(e),e=this.getNextColumnIdx(e),i[1]=this.parseIntValue(e),t[n]=i,e=this.getNextLineIdx(e)}return t}parseBondTypes(){const t=this.bondCount,e=new Uint16Array(t);let n=this.getBondBlockIdx();for(let i=0;i<t;i++)n=this.shiftIdxToBondType(n),e[i]=this.parseIntValue(n),n=this.getNextLineIdx(n);return e}isWhitespace(t){const e=this.fileContent[t];return" "===e||"\t"===e}getNextLineIdx(t){return"\n"!==this.fileContent[t]?this.fileContent.indexOf("\n",t)+1:t+1}parseFloatValue(t){return this.parseNumericValue(parseFloat,t)}parseIntValue(t){return this.parseNumericValue(parseInt,t)}parseNumericValue(t,e){let n=e+1;for(;!this.isWhitespace(n);)++n;return t(this.fileContent.substring(e,n))}}class Le extends Ie{constructor(t){super(t),this.init(t)}init(t){super.init(t)}parseAtomType(t){let e=t,n=e;return this.isQuote(e)?(n=this.getNextIdenticalChar(e),e++):n=this.fileContent.indexOf(" ",n),this.fileContent.substring(e,n)}isQuote(t){const e=this.fileContent[t].charCodeAt(0);return 39===e||34===e}getNextIdenticalChar(t){const e=this.fileContent[t];return e?this.fileContent.indexOf(e,t+1):-1}isQuery(){return this.isQueryOrFragment(((t,e)=>{return 39===t||34===t||76===t&&!((n=this.fileContent.charCodeAt(e+1))>64&&n<91||n>96&&n<123);var n}))}isFragment(){return this.isQueryOrFragment((t=>82===t||42===t))}isQueryOrFragment(t){const e=this.atomCount;let n=this.getAtomBlockIdx();for(let i=0;i<e;i++){if(n=this.shiftIdxToAtomType(n),t(this.fileContent.charCodeAt(n),n))return!0;n=this.getNextLineIdx(n)}return!1}}class Ne extends Le{constructor(t){super(t)}getAtomLines(){const t=this.getAtomBlockIdx(),e=this.getBondBlockIdx();return this.fileContent.substring(t,e).split("\n").slice(0,this.atomCount)}getBondLines(){const t=this.getBondBlockIdx();return this.fileContent.substring(t).split("\n").slice(0,this.bondCount)}getRGroupIdToAtomicIdxMap(){const t=new Map,e=this.fileContent.split("\n");e.filter((t=>t.startsWith(Ee.RGP_LINE_START))).forEach((e=>{const n=this.getAtomIdxToRgpIdxList(e);for(const[e,i]of n){if(t.has(e))throw new Error(`R group ${e} is already in the map`);t.set(e,i)}}));const n=e.map(((t,e)=>{if(t.startsWith(Ee.ATOM_ALIAS_LINE_START))return e})).filter((t=>void 0!==t)),i=n.map((t=>e[t])),o=n.map((t=>e[t+1]));i.forEach(((e,n)=>{const i=parseInt(e.split(/\s+/)[1])-1,r=parseInt(o[n].substring(1));if(t.has(r))throw new Error(`R group ${r} is already in the map`);t.set(r,i)}));const r=this.getRGroupAtomicIndices().filter((e=>!Array.from(t.values()).includes(e)));if(0!==r.length)throw new Error(`Unaccounted R group indices: ${r}`);return t}getAtomIdxToRgpIdxList(t){const e=t.split(/\s+/).filter((t=>t)).slice(3).map((t=>parseInt(t))),n=new Array(e.length/2);for(let t=0;t<e.length;t+=2)n[t/2]=[e[t+1],e[t]-1];return n}getRGroupAtomicIndices(){return this.atomTypes.map(((t,e)=>{if(t.includes("R#"))return e})).filter((t=>void 0!==t))}static isValidMolfile(t){return-1!==t.indexOf(Ee.TYPE)&&-1!==t.indexOf(Ee.END)}shiftIdxToAtomType(t){return this.shiftIdxToSpecifiedColumn(t,Ee.ATOM_TYPE_COL)}getCountsLineIdx(){let t=0;for(let e=0;e<Ee.NUM_OF_HEADER_LINES;++e)t=this.getNextLineIdx(t);return t}getAtomBlockIdx(){let t=this.getCountsLineIdx();return t=this.getNextLineIdx(t),t}shiftIdxToXColumn(t){return this.getNextColumnIdx(t)}shiftIdxToBondedAtomsPair(t){return this.shiftIdxToSpecifiedColumn(t,Ee.FIRST_BONDED_ATOM_COL)}shiftIdxToBondType(t){return this.shiftIdxToSpecifiedColumn(t,Ee.BOND_TYPE_COL)}getBondBlockIdx(){let t=this.getAtomBlockIdx();for(let e=0;e<this.atomCount;e++)t=this.getNextLineIdx(t);return t}parseAtomAndBondCounts(){let t=this.getCountsLineIdx(),e=t+Ee.NUM_OF_COUNTS_DIGITS;const n=parseInt(this.fileContent.substring(t,e));return t=e,e+=Ee.NUM_OF_COUNTS_DIGITS,{atomCount:n,bondCount:parseInt(this.fileContent.substring(t,e))}}}class Pe extends Le{constructor(t){super(t),this.init(t)}getAtomLines(){const t=this.getAtomBlockIdx(),e=this.getBondBlockIdx();return this.fileContent.substring(t,e).split("\n").slice(0,this.atomCount)}getBondLines(){const t=this.getBondBlockIdx();return this.fileContent.substring(t).split("\n").slice(0,this.bondCount)}getRGroupIdToAtomicIdxMap(){const t=new Map;return this.getAtomLines().forEach(((e,n)=>{const i=e.match(/RGROUPS=\(([\d\s]+)\)/);if(i){const e=i[1].split(/\s+/).map((t=>parseInt(t)));if(e.length>2)throw new Error(`R group data ${e} has more than 2 elements`);const o=e[1];if(t.has(o))throw new Error(`R group ${o} is already in the map`);t.set(o,n)}})),t}shiftIdxToAtomType(t){return this.shiftIdxToSpecifiedColumn(t,4)}getCountsLineIdx(){return this.fileContent.indexOf("M V30 COUNTS ")}getAtomBlockIdx(){let t=this.fileContent.indexOf("M V30 BEGIN ATOM");return t=this.getNextLineIdx(t),t}shiftIdxToXColumn(t){let e=this.shiftIdxToAtomType(t);return this.isQuote(e)?(e=this.getNextIdenticalChar(e),e=this.getNextColumnIdx(e),e):this.shiftIdxToSpecifiedColumn(t,5)}shiftIdxToBondedAtomsPair(t){return this.shiftIdxToSpecifiedColumn(t,5)}shiftIdxToBondType(t){return this.shiftIdxToSpecifiedColumn(t,4)}getBondBlockIdx(){return this.getNextLineIdx(this.fileContent.indexOf("M V30 BEGIN BOND"))}static isValidMolfile(t){return-1!==t.indexOf("V3000")&&-1!==t.indexOf("M END")}parseAtomAndBondCounts(){let t=this.fileContent.indexOf("M V30 COUNTS ")+14,e=this.fileContent.indexOf(" ",t+1);const n=parseInt(this.fileContent.substring(t,e));return t=e+1,e=this.fileContent.indexOf(" ",t+1),{atomCount:n,bondCount:parseInt(this.fileContent.substring(t,e))}}}class $e{constructor(){}static getInstance(t){if($e.isMolfileV2K(t))return new Ne(t);if($e.isMolfileV3K(t))return new Pe(t);throw new Error("Malformed molfile")}static isMolfileV2K(t){return Ne.isValidMolfile(t)}static isMolfileV3K(t){return Pe.isValidMolfile(t)}}var Re=n(6197),ke=n(9124),Oe=n(3527);class He{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(t,e,n="missing",i=void 0,o=void 0,r=void 0,s){if(this.biotype=t,this.id=e,this.n=n,this.m=i,this.type=o,this.mt=r,this.smiles=s,!this.id)throw new Error("Invalid arg undefined [id].")}static objCounter=-1;objId=++He.objCounter;className="WebEditorMonomerDummy";toLog(){return`Helm: ${this.className}<${this.objId}>`}}class Ge extends He{backgroundcolor="#FFFFFF";linecolor="#808080";textcolor="#808080";constructor(t){super(t,"*","gap")}}class Fe extends He{backgroundcolor="#808080";linecolor="#000000";textcolor="#000000";constructor(t,e){super(t,e,"ambiguous")}}class Be extends He{backgroundcolor="#FF4444";linecolor="#800000";textcolor="#FFFFFF";constructor(t,e,n){super(t,e,"missing"),n&&(this.backgroundcolor="#C0C0C0",this.linecolor="#404040",this.textcolor="#404040")}}class De extends He{backgroundcolor="#FFFF44";linecolor="#800000";textcolor="#000000";constructor(t,e){super(t,e,"broken")}}class Ve{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(t,e,n,i,o,r,s,a){this.id=t,this.m=e,this.n=n,this.na=i,this.type=o,this.mt=r,this.at=s,this.smiles=a}static fromMonomer(t,e,n){let i={};const o=e.symbol,r=e.smiles;if(e.rgroups.length>0)e.rgroups.forEach((t=>{i[t.label]=t.capGroupName}));else{if(!r){if(e.lib)return new De(t,o);throw new Error("Unexpected missing monomer without .lib")}i=n.getRS(r)}const s=new Ve(e.symbol,e.molfile,e.name,e.naturalAnalog,e.polymerType,e.monomerType,i),a=n.getMonomerColors(t,e.symbol);return a&&(s.textcolor=a?.textcolor,s.linecolor=a?.linecolor,s.backgroundcolor=a?.backgroundcolor),s}}const We={[Ft.o.BASE]:{A:"#20E040",G:"#040404",T:"#FF8080",C:"#2060FF",U:"#FF8080"},[Ft.o.NUCLEOTIDE]:{A:"#20E040",G:"#040404",T:"#FF8080",C:"#2060FF",U:"#FF8080"},[Ft.o.LINKER]:{P:"#9aa5e1",p:"#9aa5e1"},[Ft.o.SUGAR]:{R:"#7a85c1",r:"#7a85c1"},[Ft.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)"},[Ft.o.CHEM]:{R:"#eeeeee"},[Ft.o.BLOB]:{B:"#999999",G:"#e2e2e2"}},Ue=/[\w()]+/,je=RegExp(String.raw`\(${Ue}(,${Ue})+\)`),qe=t=>{const e=s.canvas(250,250);return r.chem.canvasMol(0,0,250,250,e,t),e},ze=new Oe.Mi([255,255,255]),Ye=new Oe.Mi([0,0,0]),Ke=.7*(0,z.wQ)(ze);class Ze{_monomers;source;_isEmpty;get isEmpty(){return this._isEmpty}_onChanged=new h.Subject;get onChanged(){return this._onChanged}constructor(t,e){this._monomers=t,this.source=e,this._isEmpty=!this._monomers||0===Object.keys(this._monomers).length||Object.entries(this._monomers).every((([t,e])=>0===Object.keys(e).length));for(const[t,e]of Object.entries(this._monomers))for(const[t,n]of Object.entries(e))n.lib=this}getMonomerSymbolsByType(t){return Object.keys(this._monomers[t])}addMissingMonomer(t,e){let n=this._monomers[t];n||(n=this._monomers[t]={});let i=e;return e==wt._S||e===wt.b9[wt.Hi.HELM]?i="Gap":("PEPTIDE"===t&&"X"===e||"RNA"===t&&"N"===e)&&(i="Any"),n[e]={symbol:e,name:i,molfile:"",author:"MISSING",id:-1,rgroups:ot().count(1).take(9).map((t=>({capGroupSmiles:"",alternateId:"",capGroupName:"",label:`R${t.toString()}`}))).toArray(),smiles:"",polymerType:t,monomerType:void 0,createDate:null}}getMonomer(t,e){let n=e;"RNA"==t&&"R"==n&&(n="r"),"RNA"==t&&"P"==n&&(n="p");let i=null;if(t){const e=this._monomers[t];i=e?e[n]:null}else{eo.logger.warning(`Bio: MonomerLib.getMonomer() symbol '${e}', polymerType not specified.`);for(const[t,e]of Object.entries(this._monomers))if(i=e[n],i)break}return i}getWebEditorMonomer(t,e){const[n,i]=(0,ke.fA)(t,e),o=(0,Re.Y)(n);let r=this.getMonomer(o,i);if(r&&n==Ft.o.LINKER&&2!=r.rgroups.length)return null;if(r&&n==Ft.o.SUGAR&&3!=r.rgroups.length)return null;r||(r=this.addMissingMonomer(o,i));let s=r.wem??null;return s||(i===wt._S||"*"==i?s=r.wem=new Ge(n):n===Ft.o.NUCLEOTIDE&&"N"===i||n===Ft.o.AA&&"X"===i||(Ft.o.CHEM,0)||je.test(i)?s=r.wem=new Fe(n,i):r.lib||(s=r.wem=new Be(n,i,this.isEmpty)),s||(s=r.wem=Ve.fromMonomer(n,r,this))),s}getTooltip(t,e){const n=(0,Re.Y)(t),i=s.div([],{classes:"ui-form ui-tooltip"}),o=this.getWebEditorMonomer(t,e),r=this.getMonomer(n,e);if(r){const t=r.symbol,[e,n,a]=(r.name,o?[o.textcolor,o.backgroundcolor,o.linecolor]:["#202020","#A0A0A0","#202020"]);let l;if(i.append(s.divH([s.div([t],{style:{textWrap:"nowrap",marginLeft:"4px",marginRight:"4px",color:e,backgroundColor:n,borderColor:a,borderWidth:"1px",borderStyle:"solid",borderRadius:"2px",padding:"3px",minWidth:"24px",textAlign:"center"}}),s.div([r.name],{style:{padding:"4px"}})],{style:{display:"flex",flexDirection:"row",justifyContent:"left"}})),l=r.molfile?qe(r.molfile):r.smiles?s.divV([qe(r.smiles),s.divText("from smiles",{style:{fontSize:"smaller"}})]):s.divText("No structure",{style:{margin:"6px"}}),i.append(s.div(l,{style:{display:"flex",flexDirection:"row",justifyContent:"center",margin:"6px"}})),r.symbol!=wt._S){let t=r.lib?.source;t?(t.endsWith(".json")&&(t=t.substring(0,t.length-5)),t=t.replace(/_/g," ").replace(/-/g," ").replace(/([a-z])([a-z])([A-Z])/g,"$1$2 $3"),i.append(s.divText(t))):i.append(s.divText("Missed in libraries"))}}else i.append(s.divV([s.divText(`Monomer '${e}' of type '${n}' not found.`),s.divText("Open the Context Panel, then expand Manage Libraries")]));return i}getMonomerTextColor(t,e){const n=this.getMonomerColors(t,e),i=t=>{const e=/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/.exec(t);if(e)return[parseInt(e[1]),parseInt(e[2]),parseInt(e[3])];const n=a.Color.fromHtml(t);return[a.Color.r(n),a.Color.g(n),a.Color.b(n)]},o=i(n.textcolor),r=new Oe.Mi([...o.map((t=>t+1))]),s=(0,z.KE)(r,ze)/((0,z.wQ)(r)*(0,z.wQ)(ze)),l=i(n.backgroundcolor),c=new Oe.Mi([...l.map((t=>t+.01))]);let h;h=(0,z.KE)(c,ze)/((0,z.wQ)(c)*(0,z.wQ)(ze))<s?l:o;let u=new Oe.Mi(h);const d=(0,z.wQ)(u);return d>Ke&&(u=(0,z.dC)(Ye,u,Ke/d)),`rgb(${u[0]}, ${u[1]}, ${u[2]})`}getMonomerColors(t,e){const n="default";let i=n;const o=(0,Re.Y)(t),r=this.getMonomer(o,e);let s;if(r){if(r.meta&&r.meta.colors){const t=r.meta.colors;n in t||(i="default"),s=t[i]}if(!s){const e=We[t],n=e?.[r.symbol];n&&(s={textColor:a.Color.toHtml(a.Color.getContrastColor(a.Color.fromHtml(n))),lineColor:"#202020",backgroundColor:n})}const e=r.naturalAnalog;if(!s&&e)return this.getMonomerColors(t,e)}return s||(s={textColor:"#202020",lineColor:"#202020",backgroundColor:"#A0A0A0"}),{textcolor:s.text??s.textColor,linecolor:s.line??s.lineColor,backgroundcolor:s.background??s.backgroundColor}}getRS(t){const e=t.match(/(?<=\[)[^\][]*(?=])/gm),n={};let i,o="";if(e)for(let t=0;t<e.length;t++)if(null!=e[t]&&/\d/.test(e[t])){i=e[t][e[t].length-1],e[t]=e[t].replace(/[0-9]/g,"");for(let n=0;n<e[t].length;n++)":"!=e[t][n]&&(o+=e[t][n]);n["R"+i]=o,o=""}return n}}var Xe=n(5488),Je={};Je.styleTagTransform=A(),Je.setAttributes=b(),Je.insert=g().bind(null,"head"),Je.domAPI=m(),Je.insertStyleElement=w(),d()(Xe.A,Je),Xe.A&&Xe.A.locals&&Xe.A.locals;class Qe extends Ze{error;_duplicateMonomers={};get duplicateMonomers(){return this._duplicateMonomers}_duplicatesHandled=!0;get duplicatesHandled(){return this._duplicatesHandled}duplicatesNotified=!1;constructor(t,e,n=void 0){super(t,e),this.error=n}toJSON(){const t=[];for(const e of Object.values(this._monomers))for(const n of Object.values(e))t.push({...n,lib:void 0,wem:void 0});return t}getMonomer(t,e){let n=e;"RNA"==t&&"R"==n&&(n="r"),"RNA"==t&&"P"==n&&(n="p");let i=null;if(t){const e=this._monomers[t];i=e?.[n]??null}else{eo.logger.warning(`Bio: MonomerLib.getMonomer() symbol '${e}', polymerType not specified.`);for(const[t,e]of Object.entries(this._monomers))if(i=e[n],i)break}return i}_monomerSets=null;getMonomerSet(t){const e=(0,Re.Y)(t);if(this._monomerSets||(this._monomerSets={}),!(t in this._monomerSets))for(const[t,n]of Object.entries(this._monomers[e]));return this._monomerSets[t]}getPolymerTypes(){return Object.keys(this._monomers)}getMonomerMolsByPolymerType(t){const e={};return Object.keys(this._monomers[t]??{}).forEach((n=>{e[n]=this._monomers[t][n].molfile})),e}getMonomerSymbolsByRGroup(t,e,n){let i=this.getMonomerSymbolsByType(e).map((t=>this.getMonomer(e,t)));return i=i.filter((t=>null!==t)),0===i.length?[]:(i=i.filter((e=>{if(!e?.rgroups)return!1;let n=e?.rgroups.length>=t;var i;return i=$e.getInstance(e.molfile).atomTypes,i.map(((t,e)=>"R#"===t?e:-1)).filter((t=>-1!==t)),n&&=!0,n})),i.map((t=>t?.symbol)))}_updateLibInt(t){const e=t.getPolymerTypes(),n=this.getPolymerTypes();e.forEach((e=>{n.includes(e)||(this._monomers[e]={}),t.getMonomerSymbolsByType(e).forEach((n=>{this._monomers[e][n]&&(this._duplicateMonomers[e]??={},this._duplicateMonomers[e][n]??=[this._monomers[e][n]],this._duplicateMonomers[e][n].push(t.getMonomer(e,n))),this._monomers[e][n]=t.getMonomer(e,n)}))})),this._isEmpty=this.isEmpty&&t.isEmpty}updateLibs(t,e=!1){e&&(this._monomers={},this._isEmpty=!0),this._duplicateMonomers={};for(const e of t)e.error||this._updateLibInt(e);Object.entries(this.duplicateMonomers).length>0?(0,Nt.ub)().then((t=>{this.assignDuplicatePreferences(t)})):this._duplicatesHandled=!0,this._onChanged.next()}assignDuplicatePreferences(t){let e=!0;for(const n in this.duplicateMonomers)for(const i in this.duplicateMonomers[n])if(t.duplicateMonomerPreferences?.[n]?.[i]){const o=t.duplicateMonomerPreferences[n][i],r=this.duplicateMonomers[n][i].find((t=>t.lib?.source===o));r?this._monomers[n][i]=r:e=!1}else e=!1;return this._duplicatesHandled=e,e}clear(){this._monomers={},this._onChanged.next()}getSummaryObj(){const t={},e=this.getPolymerTypes();for(const n of e)t[n]=this.getMonomerSymbolsByType(n).length;return t}getSummaryDf(){const t=this.getPolymerTypes(),e=new Array(t.length);for(const[n,i]of ot().enumerate(t))e[i]=this.getMonomerSymbolsByType(n).length;return a.DataFrame.fromColumns([a.Column.fromStrings("polymerType",t),a.Column.fromList(a.COLUMN_TYPE.INT,"count",e)])}getSummary(){const t=this.getPolymerTypes();return 0==t.length?"empty":t.map((t=>`${t} ${this.getMonomerSymbolsByType(t).length}`)).join("\n")}static overrideCounter=0;override(t,e){return new tn(t,`override: ${++Qe.overrideCounter}, ${e}`,this)}}class tn extends Ze{data;base;constructor(t,e,n){super(t,e),this.data=t,this.base=n}get onChanged(){return this.base.onChanged}getMonomerSymbolsByType(t){const e=this.base.getMonomerSymbolsByType(t);for(const n of Object.keys(this.data[t]??{}))e.includes(n)||e.push(n);return e}addMissingMonomer(t,e){return this.base.addMissingMonomer(t,e)}getMonomer(t,e){const n=this.data[t]?.[e];return n??this.base.getMonomer(t,e)}}class en{monomerLib;symbol;polymerType;monomerType;monomerLinks;monomers;error=null;constructor(t,e,n,i,o){this.monomerLib=t,this.symbol=e,this.polymerType=n,this.monomerType=i,this.monomerLinks=o;try{this.monomers=this.monomerLinks.map((t=>{const n=this.monomerLib.getMonomer(this.polymerType,t.symbol);if(!n)throw new Error("Monomer not found: ");if(n.lib?.source!=t.source)throw new Error(`Monomer '${e}' found in different library.`);return n}))}catch(t){const[e,n]=(0,Ct.AP)(t);this.error=e,this.monomers=[]}}}class nn{description;placeholders;source;error;constructor(t,e,n=void 0,i=void 0){this.description=t,this.placeholders=e,this.source=n,this.error=i}updateSets(t,e=!1){e&&(this.placeholders=[]);for(const e of t)e.error||this._updateSetInt(e)}_updateSetInt(t){for(const e of t.placeholders)this.placeholders.push(e)}}var on=n(7433),rn=n.n(on),sn=n(1913),an=n.n(sn);class ln{helmMonomerSchema;validateMonomerSchema;constructor(t){this.helmMonomerSchema=t;const e=new(rn())({allErrors:!0,strictTuples:!1,allowUnionTypes:!0});an()(e),this.validateMonomerSchema=e.compile(this.helmMonomerSchema)}validateFile(t,e){const n=this.parseJson(t,e);return null!==n&&(Array.isArray(n)?this.validateJsonContent(n,e):(console.warn(`Bio: Monomer Library File Validator file '${e}': Invalid JSON format: The file must contain an array of monomers.`),!1))}parseJson(t,e){try{return JSON.parse(t)}catch(t){return console.error(`Bio: Monomer Library File Validator file '${e}': Invalid JSON format:`,t),null}}validateJsonContent(t,e){let n=!0;const i=new Set;for(const o of t){const t=o.symbol??o.id??o.name??"#N/A";if(n=this.validateMonomerSchema(o),!n){console.warn(`Bio: Monomer Library File Validator file ${e}, monomer '${t}' violating JSON schema:`,o,"\nError reason: ",JSON.stringify(this.validateMonomerSchema.errors??{}),`\nThere may be other errors in ${e} since the validation is stopped after the first error.`," Please, verify that the monomer library file satisfies the JSON schema");break}const r=`${o.polymerType??""}-${t}`;i.has(r)&&console.warn(`Bio: Monomer Library File Validator file ${e}, monomer '${t}' is duplicated.`,"Please, verify that the monomer library file does not contain duplicated monomer symbols."),i.add(r)}return n}}var cn=n(8604);class hn{fileValidator;libHelper;eventManager;logger;filesPromise=Promise.resolve();initializedPromise=Promise.resolve();constructor(t,e,n,i){let o;this.fileValidator=t,this.libHelper=e,this.eventManager=n,this.logger=i;let r=!1;this.initializedPromise=Promise.race([a.delay(1e3),new Promise((t=>o=t))]),this.eventManager.updateValidLibraryFileListRequested$.subscribe((()=>{this.updateValidLibList().then((()=>{})),r||(r=!0,o())})),this.eventManager.updateValidSetFileListRequested$.subscribe((()=>{this.updateValidSetList().then((()=>{}))}))}static objCounter=-1;objId=++hn.objCounter;toLog(){return`MonomerLibFileManager<${this.objId}>`}static async create(t,e,n){const i=await r.dapi.files.readAsText(cn.gt),o=JSON.parse(i),s=new ln(o);return new hn(s,t,e,n)}async addLibraryFile(t,e,n=!0){try{if(await r.dapi.files.exists(cn.so+`${e}`))return void r.shell.error(`File ${e} already exists`);await this.validateAgainstHELM(t,e),await r.dapi.files.writeAsText(cn.so+`${e}`,t),await this.updateValidLibList(),await r.dapi.files.exists(cn.so+`${e}`)?r.shell.info(`Added ${e} HELM library`):r.shell.error(`Failed to add ${e} library`)}catch(t){console.error(t),r.shell.error(`Failed to add ${e} library`)}}async deleteLibraryFile(t){try{await r.dapi.files.delete(cn.so+`${t}`),await this.updateValidLibList(),r.shell.info(`Deleted ${t} library`)}catch(e){console.error(e),await r.dapi.files.exists(cn.so+`${t}`)?r.shell.error(`Failed to delete ${t} library`):r.shell.warning(`File ${t} already deleted, refresh the list`)}}async loadLibraryFromFile(t,e){let n=[];const i=new a.FileSource(t),o=await i.readAsText(e);n=JSON.parse(o);const r={},s=[];return n.forEach((t=>{const e=t.polymerType,n=t.symbol;s.includes(e)||(r[e]={},s.push(e)),r[e][n]=t})),new Qe(r,e)}async loadSetFromFile(t,e,n){let i={};const o=new a.FileSource(e),r=await o.readAsText(n);i=JSON.parse(r);const s=i.description,l=Object.entries(i.placeholders).map((([e,n])=>{const i=e,o=n.polymerType,r=n.monomerType,s=n.set;return new en(t,i,o,r,s)}));return new nn(s,l)}getValidLibraryPaths(){return this.eventManager.getValidLibPathList()}getValidSetPaths(){return this.eventManager.getValidSetPathList()}async getValidLibraryPathsAsynchronously(){return await this.eventManager.getValidLibraryPathsAsynchronously()}async updateValidLibList(){const t=`${this.toLog()}.updateValidLibList()`;return this.logger.debug(`${t}, start`),this.filesPromise=this.filesPromise.then((async()=>{this.logger.debug(`${t}, IN`);const e=[],n=await this.getLibFileListAtLocation();if(!this.libListHasChanged(n))return void this.logger.debug(`${t}, end, not changed`);for(const t of n){if(!t.endsWith(".json")){e.push(t);continue}const n=await r.dapi.files.readAsText(cn.so+`${t}`);this.isValidHELMLibrary(n,t)||e.push(t)}const i=n.filter((t=>!e.includes(t)));if(this.libListHasChanged(i)&&(this.eventManager.changeValidLibPathList(i),await this.libHelper.loadMonomerLib(!0)),i.some((t=>!t.endsWith(".json")))&&this.logger.warning(`Wrong validation: ${i}`),e.length>0){const t=`Invalid monomer library files in ${cn.so}, consider fixing or removing them: ${e.join(", ")}`;this.logger.warning(t)}this.logger.debug(`${t}, OUT`)})),this.logger.debug(`${t}, end`),this.filesPromise}async updateValidSetList(){const t=`${this.toLog()}.updateValidSetList()`;return eo.logger.debug(`${t}, start`),this.filesPromise=this.filesPromise.then((async()=>{eo.logger.debug(`${t}, IN`);const e=[],n=await this.getSetFileListAtLocation();if(!this.setListHasChanged(n))return void eo.logger.debug(`${t}, end, not changed`);for(const t of n)t.endsWith(".json")?await r.dapi.files.readAsText(cn.Es+`${t}`):e.push(t);const i=n.filter((t=>!e.includes(t)));this.setListHasChanged(i)&&(this.eventManager.changeValidSetPathList(i),this.libHelper.loadMonomerSets(!0)),eo.logger.debug(`${t}, OUT`)})),eo.logger.debug(`${t}, end`),this.filesPromise}libListHasChanged(t){const e=this.eventManager.getValidLibPathList();return t.length!==e.length||t.some(((t,n)=>t!==e[n]))}setListHasChanged(t){const e=this.eventManager.getValidSetPathList();return t.length!==e.length||t.some(((t,n)=>t!==e[n]))}async validateAgainstHELM(t,e){if(!this.isValidHELMLibrary(t,e))throw new Error(`File ${e} does not satisfy HELM standard`)}isValidHELMLibrary(t,e){return this.fileValidator.validateFile(t,e)}async getLibFileListAtLocation(){const t=`${this.toLog()}.getLibFileListAtLocation()`;this.logger.debug(`${t}, start`);const e=await r.dapi.files.list(cn.so).then((t=>t.filter((t=>t.isFile)).map((t=>t.fullPath)))),n=[];return n.push(...e),n.map((t=>t.substring(cn.so.length)))}async getSetFileListAtLocation(){const t=`${this.toLog()}.getSetFileListAtLocation()`;this.logger.debug(`${t}, start`);const e=await r.dapi.files.list(cn.Es).then((t=>t.map((t=>t.fullPath)))),n=[];return n.push(...e),n.map((t=>t.substring(cn.Es.length)))}}class un{constructor(){}static _instance;static getInstance(){return un._instance||(un._instance=new un),un._instance}_libFilesUpdateSubject$=new h.BehaviorSubject([]);_setFilesUpdateSubject$=new h.BehaviorSubject([]);_addLibraryFilesSubject$=new h.Subject;_librarySelectionSubject$=new h.Subject;getValidLibPathList(){return this._libFilesUpdateSubject$.getValue()}getValidSetPathList(){return this._setFilesUpdateSubject$.getValue()}async getValidLibraryPathsAsynchronously(){return new Promise((t=>{const e=this._libFilesUpdateSubject$.pipe((0,R.skip)(1)).subscribe((n=>{t(n),e.unsubscribe()}))}))}changeValidLibPathList(t){this._libFilesUpdateSubject$.next(t)}changeValidSetPathList(t){this._setFilesUpdateSubject$.next(t)}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(t,e){this._librarySelectionSubject$.next([t,e])}}class dn{logger;_monomerLib=new Qe({},"MAIN");_monomerSets=new nn("MAIN",[]);_initialLoadCompleted=!1;get initialLoadCompleted(){return this._initialLoadCompleted}_eventManager;get eventManager(){return this._eventManager}async awaitLoaded(t=1/0){return t=t===1/0?6e4:t,await Promise.race([(async()=>{const t=await this.getFileManager();return await t.filesPromise,!0})(),(async()=>(await(0,te.cb)(t),!1))()]).then((e=>{if(!e)throw new Error(`Loading monomer libraries timeout ${t} ms.`)}))}constructor(t){this.logger=t}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(t){this._monomerLib.assignDuplicatePreferences(t)}_fileManagerPromise;async getFileManager(){return void 0===this._fileManagerPromise&&(this._fileManagerPromise=(async()=>{const t=await hn.create(this,this._eventManager,this.logger);return await t.initializedPromise,t})()),this._fileManagerPromise}loadLibrariesPromise=Promise.resolve();async loadMonomerLib(t=!1){const e=`${this.toLog()}.loadMonomerLib()`;return this.logger.debug(`${e}, start`),this.loadLibrariesPromise=this.loadLibrariesPromise.then((async()=>{this.logger.debug(`${e}, IN`);const n=a.TaskBarProgressIndicator.create("Loading monomers ...");try{const[[e],i]=await Promise.all([await this.getFileManager().then((t=>[t.getValidLibraryPaths()])),(0,Nt.ub)()]),o=e.filter((t=>{const e=!i.exclude.includes(t),n=0===i.explicit.length||i.explicit.includes(t);return e&&n}));let r=0;const s=o.length,[a]=await Promise.all([Promise.all(o.map((t=>this.readLibrary(cn.so,t).catch((e=>{const n=`Loading monomers from '${t}' error: ${e instanceof Error?e.message:e.toString()}`;return new Qe({},t,n)})).finally((()=>{n.update(Math.round(100*++r/s),`Loading monomers ${r}/${s}`)})))))]);this._monomerLib.updateLibs(a,t),this._initialLoadCompleted=!0}catch(t){const e=`Loading monomer libraries error: ${t instanceof Error?t.message:t.toString()}`;r.shell.warning(e);const n=t instanceof Error?t.stack:void 0;this.logger.error(e,void 0,n)}finally{n.close(),this.logger.debug(`${e}, OUT`)}})),this.logger.debug(`${e}, end`),this.loadLibrariesPromise}async loadLibraries(t){return this.loadMonomerLib(t)}loadSetsPromise=Promise.resolve();async loadMonomerSets(t=!1){const e=`${this.toLog()}.loadMonomerSets()`;return this.logger.debug(`${e}, start`),this.loadSetsPromise=this.loadSetsPromise.then((async()=>{this.logger.debug(`${e}, IN`);const t=a.TaskBarProgressIndicator.create("Loading monomer sets ...");try{const[[e]]=await Promise.all([await this.getFileManager().then((t=>[t.getValidSetPaths()]))]),n=e.filter((t=>!0));let i=0;const o=n.length,[r]=await Promise.all([Promise.all(n.map((e=>this.readSet(cn.Es,e).catch((t=>{const n=`Loading monomer sets from '${e}' error: ${t instanceof Error?t.message:t.toString()}`;return new nn("Broken monomer set",[],e,n)})).finally((()=>{t.update(Math.round(100*++i/o),`Loading monomers ${i}/${o}`)})))))]);this._monomerSets.updateSets(r)}catch(t){const e=`Loading monomer sets error: ${t instanceof Error?t.message:t.toString()}`;r.shell.warning(e);const n=t instanceof Error?t.stack:void 0;this.logger.error(e,void 0,n)}finally{t.close(),this.logger.debug(`${e}, OUT`)}})),this.logger.debug(`${e}, end`),this.loadSetsPromise}async readLibrary(t,e){const n=await this.getFileManager();return await n.loadLibraryFromFile(t,e)}async readSet(t,e){const n=await this.getFileManager();return await n.loadSetFromFile(this._monomerLib,t,e)}async selectSpecifiedLibraries(t){const e=await this.getInvalidFileNames(t);if(e.length>0)throw new Error(`Cannot select libraries ${e}: no such library in the list`);const n=await(0,Nt.ub)();n.exclude=(await this.getFileManager()).getValidLibraryPaths().filter((e=>!t.includes(e))),await(0,Nt.Eu)(n)}async getInvalidFileNames(t){const e=(await this.getFileManager()).getValidLibraryPaths();return t.filter((t=>!e.includes(t)))}async loadMonomerLibForTests(){await(0,Nt.Eu)(cn.G3),await this.awaitLoaded(1e4),await this.loadMonomerLib(!0)}static async getInstance(){let t=window.$monomerLibHelperPromise;return null==t&&(t=window.$monomerLibHelperPromise=(async()=>{const t=new dn(eo.logger);return t._eventManager=un.getInstance(),t})()),t}}var pn=n(1757),mn=n.n(pn),fn=n(3017),gn={};gn.styleTagTransform=A(),gn.setAttributes=b(),gn.insert=g().bind(null,"head"),gn.domAPI=m(),gn.insertStyleElement=w(),d()(fn.A,gn),fn.A&&fn.A.locals&&fn.A.locals;var yn=n(3151);class bn{constructor(t,e=[],n={}){this.onItemChanged=new h.Subject,this.onAddingItemChanged=new h.Subject,this.onItemAdded=new h.Subject,this.onItemRemoved=new h.Subject,this.options={removeButtonTooltip:"Remove item",addButtonTooltip:"Add item",allowAdd:!0,allowRemove:!0},this.addingItemInputs={},this.properties=t,this.options=Object.assign(Object.assign({},this.options),n),this._root=s.divV([],{style:{display:"grid",gridTemplateColumns:`repeat(${this.properties.length}, 1fr)`,alignItems:"center",gap:"12px"},classes:"ui-items-grid"}),this._items=e,this.render()}get root(){return this._root}get items(){return this._items}set items(t){this._items=t,this.render()}addItem(t,e=!0){this._items.push(t),this.render(),e&&this.onItemAdded.next(t)}removeItem(t,e=!0){-1!==this._items.indexOf(t)&&(this._items.splice(this._items.indexOf(t),1),this.render(),e&&this.onItemRemoved.next(t))}removeAtIndex(t,e=!0){if(t<0||t>=this._items.length)return;const n=this._items.splice(t,1);this.render(),e&&this.onItemRemoved.next(n[0])}removeAllItems(){this._items=[],this.render()}render(){var t,e,n,i,o;if(s.empty(this._root),!this.options.horizontalInputNames)for(const n of this.properties){let i=null!==(t=n.caption)&&void 0!==t?t:n.name;(null===(e=this.options.customLabels)||void 0===e?void 0:e[n.name])&&(i=this.options.customLabels[n.name]);const o=s.divText(i);o.style.fontWeight="bold",this._root.appendChild(o)}for(const t of this._items){const e=this.getItemDiv(t);for(const t of e)this._root.appendChild(t)}if(this.options.allowAdd){const t=this.getItemDiv(null!==(o=null===(i=(n=this.options).newItemFunction)||void 0===i?void 0:i.call(n))&&void 0!==o?o:void 0,!0);for(const e of t)this._root.appendChild(e)}}get addingItem(){const t={};return Object.keys(this.addingItemInputs).forEach((e=>{t[e]=this.addingItemInputs[e].value})),t}getItemDiv(t={},e){var n,i;const o=[],r={};let l=null;for(const c of this.properties){void 0===t[c.name]&&(t[c.name]=null);const h=(null===(n=this.options.customInputs)||void 0===n?void 0:n[c.name])?this.options.customInputs[c.name](t):s.input.forProperty(c,t),u=null===(i=this.options.validators)||void 0===i?void 0:i[c.name];u&&h.addValidator(u),o.push(this.options.horizontalInputNames?h.root:this.hideLabel(h.root)),c.propertyType!==a.TYPE.BOOL&&"color"!==c.name.toLowerCase()&&h.input&&(h.input.style.width="100%"),r[c.name]=h,h.onChanged.subscribe((()=>{t[c.name]=h.value,e?this.onAddingItemChanged.next({item:t,fieldName:c.name}):this.onItemChanged.next({item:t,fieldName:c.name})})),h.root.style.alignItems="center",l=h}let c=null;if(e)this.addingItemInputs=r,c=s.icons.add((()=>{const t=this.options.newItemFunction?this.options.newItemFunction():{};Object.keys(r).forEach((e=>{t[e]=r[e].value})),this._items.push(t),this.onItemAdded.next(t),this.render()}),this.options.addButtonTooltip);else{if(!this.options.allowRemove)return o;c=s.icons.delete((()=>{this._items.splice(this._items.indexOf(t),1),this.onItemRemoved.next(t),this.render()}),this.options.removeButtonTooltip)}return l&&l.addOptions?l.addOptions(c):null==l||l.root.appendChild(c),c.style.color="#2083d5",o}hideLabel(t){return t.getElementsByTagName("label")[0]&&t.removeChild(t.getElementsByTagName("label")[0]),t}hasErrors(){return this._root.querySelectorAll(".d4-invalid").length>0}}const vn={A:new V.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 V.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 V.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 V.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 V.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 V.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 V.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 V.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 V.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 V.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 V.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 V.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 V.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 V.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 V.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 V.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 V.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 V.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 V.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 V.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)},wn={RNA:{A:new V.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 V.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 V.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 V.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 V.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:vn};async function Cn(t,e,n=0){if(!Object.keys(wn).includes(e))return null;const i=await async function(t){const e=a.Func.find({package:"Chem",name:"getMorganFingerprint"})?.[0];if(!e)return null;try{const n=(await e.apply({molString:t}))?.getBuffer().buffer;if(n)return new V.A(new Uint32Array(n),2048)}catch(t){return null}}(t);if(!i)return null;if(!wn[e])return null;const o=wn[e];let r=0,s=null;for(const[t,e]of Object.entries(o)){const o=(0,k.$1)(i,e);o>r&&o>=n&&(r=o,s=t)}return s}var An,Sn=n(857),xn={};xn.styleTagTransform=A(),xn.setAttributes=b(),xn.insert=g().bind(null,"head"),xn.domAPI=m(),xn.insertStyleElement=w(),d()(Sn.A,xn),Sn.A&&Sn.A.locals&&Sn.A.locals,function(t){t.MONOMER="Monomer",t.SYMBOL="Symbol",t.NAME="Name",t.R_GROUPS="~R-Groups",t.MONOMER_TYPE="Monomer Type",t.POLYMER_TYPE="Polymer Type",t.NATURAL_ANALOG="Natural Analog",t.AUTHOR="Author",t.CREATE_DATE="Create Date",t.ID="ID",t.META="Meta",t.SOURCE="Source"}(An||(An={}));const En={[An.MONOMER]:a.COLUMN_TYPE.STRING,[An.SYMBOL]:a.COLUMN_TYPE.STRING,[An.NAME]:a.COLUMN_TYPE.STRING,[An.R_GROUPS]:a.COLUMN_TYPE.STRING,[An.MONOMER_TYPE]:a.COLUMN_TYPE.STRING,[An.POLYMER_TYPE]:a.COLUMN_TYPE.STRING,[An.NATURAL_ANALOG]:a.COLUMN_TYPE.STRING,[An.AUTHOR]:a.COLUMN_TYPE.STRING,[An.CREATE_DATE]:a.COLUMN_TYPE.DATE_TIME,[An.ID]:a.COLUMN_TYPE.INT,[An.META]:a.COLUMN_TYPE.STRING,[An.SOURCE]:a.COLUMN_TYPE.STRING};class Mn{monomerLibManamger;adjustTable(){this.tv?.dataFrame&&(r.data.detectSemanticTypes(this.tv.dataFrame),this.tv.dataFrame.meta.detectSemanticTypes()),setTimeout((()=>{this.tv?.grid&&(this.tv.grid.props.allowEdit=!1,this.tv.grid.col(An.NAME).width=100,this.tv.grid.col(An.SYMBOL).width=70)}),200)}static VIEW_NAME="Manage Monomers";_newMonomer=yn.pe;_newMonomerForm;monomerLib;tv=null;libInput;static instance;activeMonomerLib=null;constructor(t){this.monomerLibManamger=t,this.monomerLib=t.getBioLib(),this._newMonomerForm=new Nn(t,(()=>this.activeMonomerLib),(async t=>{const e=await this.getMonomersDf(this.libInput.value);this.tv?.dataFrame&&(this.tv.dataFrame=e,this.adjustTable(),null!=t&&setTimeout((()=>{const n=e.col(An.SYMBOL).toList().indexOf(t);-1!==n&&(this.tv?.grid.scrollToCell(e.columns.byIndex(0),n),e.currentRow=e.rows.get(n))}),500))}),(()=>this.tv?.dataFrame))}static async getInstance(){if(!this.instance){const t=await dn.getInstance();await t.awaitLoaded(),await t.loadLibrariesPromise,this.instance=new Mn(t)}return this.instance}static async getNewInstance(){const t=await dn.getInstance();return await t.awaitLoaded(),await t.loadLibrariesPromise,new Mn(t)}async createNewMonomerLib(t,e){this.tv?.grid&&s.setUpdateIndicator(this.tv.grid.root,!0);try{const n=JSON.stringify(e.map((t=>({...t,lib:void 0,wem:void 0}))),null,2);t.endsWith(".json")||(t+=".json"),await(await this.monomerLibManamger.getFileManager()).addLibraryFile(n,t),await r.dapi.files.writeAsText(cn.so+t,n),await this.monomerLibManamger.loadLibraries(!1),r.shell.v=await this.getViewRoot(t)}catch(t){r.shell.error("Error creating library"),console.error(t)}finally{this.tv?.grid&&s.setUpdateIndicator(this.tv.grid.root,!1)}}async createNewLibDialog(t){const e=(await this.monomerLibManamger.getFileManager()).getValidLibraryPaths(),n=s.input.string("Library Name",{placeholder:"Enter library name",nullable:!1,onValueChanged:()=>{const t=i(n.value);o.getButton("Create")?.classList?.toggle("d4-disabled",!!t)}});function i(t){return t&&t.trim()?t.endsWith(".json")&&e.includes(t)||e.includes(t+".json")?"Library with this name already exists":null:"Library name cannot be empty"}n.addValidator(i);const o=s.dialog("Create New Library").add(n).addButton("Create",(async()=>{const e=i(n.value);if(e)r.shell.warning(e);else{try{await this.createNewMonomerLib(function(){let t=n.value;return t.endsWith(".json")||(t+=".json"),t}(),t??[])}catch(t){r.shell.error("Error creating library"),console.error(t)}o.close()}})).show();o.getButton("Create")?.classList?.toggle("d4-disabled",!0)}get newMonomer(){return this._newMonomer}getNewMonomerForm(){return this._newMonomerForm}async getMonomersTableView(t,e=!0){const n=await this.getMonomersDf(t);return this.tv=a.TableView.create(n,e),this.adjustTable(),this.tv.subs.push(r.events.onContextMenu.subscribe((({args:t})=>{if(!t||!t.menu||!t.context||t.context.type!==a.VIEWER.GRID||!t.context.tableView||t.context.tableView.id!==(this.tv.id??"")||!t.item||!t.item.isTableCell||(t.item.tableRowIndex??-1)<0)return;const e=t.item.tableRowIndex;t.menu.item("Edit Monomer",(async()=>{await this.editMonomer(this.tv.dataFrame.rows.get(e))})),t.menu.item("Fix all monomers",(()=>{this.fixAllMonomers()})),this.tv.dataFrame.selection.trueCount>0?(t.menu.item("Remove Selected Monomers",(async()=>{const t=await Promise.all(Array.from(this.tv.dataFrame.selection.getSelectedIndexes()).map((t=>On(this.tv.dataFrame.rows.get(t)))));this._newMonomerForm.removeMonomers(t,this.libInput.value)})),t.menu.item("Selection To New Library",(async()=>{const t=await Promise.all(Array.from(this.tv.dataFrame.selection.getSelectedIndexes()).map((t=>On(this.tv.dataFrame.rows.get(t)))));this.createNewLibDialog(t)}))):t.menu.item("Remove Monomer",(async()=>{const t=await On(this.tv.dataFrame.rows.get(e));this._newMonomerForm.removeMonomers([t],this.libInput.value)}))}))),this.tv.grid&&(this.tv.grid.props.allowEdit=!1),this.tv}static closeAllMonomerManagers(){Array.from(r.shell.tableViews??[]).filter((t=>t.name===Mn.VIEW_NAME)).forEach((t=>t.close()))}findActiveManagerView(){if(!this.tv)return null;const t=Array.from(r.shell.tableViews??[]).find((t=>t.id===this.tv.id));return t?r.shell.v=t:Mn.closeAllMonomerManagers(),t??null}_skipLibInputOnchange=!1;async getViewRoot(t,e=!0){const n=(await this.monomerLibManamger.getFileManager()).getValidLibraryPaths();if(this._newMonomerForm.molSketcher.resize(),e&&(this.tv=this.findActiveManagerView())&&(t??this.libInput.value)){try{this._skipLibInputOnchange=!0,this.libInput&&(this.libInput.items=n),t&&(this.libInput.value=t)}catch(t){r.shell.error("Error updating library list"),console.error(t)}finally{this._skipLibInputOnchange=!1}const e=await this.getMonomersDf(t);return this.tv.dataFrame=e,this.adjustTable(),this.tv}t??=n[0],this.tv=await this.getMonomersTableView(t,e);let i=this.tv.getRibbonPanels();i.forEach(((t,e)=>{i[e]=t.filter((t=>0!==t.getElementsByClassName("grok-icon-filter").length))})),i=i.filter((t=>t.length>0));const o=s.icons.add((()=>{this._newMonomerForm.setEmptyMonomer()}),"Add New Monomer"),l=s.iconFA("wand-magic",(()=>{this.fixAllMonomers()}),"Fix all monomers"),c=s.icons.edit((async()=>{(this.tv?.dataFrame?.currentRowIdx??-1)<0||await this.editMonomer(this.tv.dataFrame.rows.get(this.tv.dataFrame.currentRowIdx))}),"Edit Monomer"),h=s.icons.delete((async()=>{const t=this.tv?.dataFrame?.currentRowIdx??-1,e=Array.from(this.tv?.dataFrame?.selection?.getSelectedIndexes()??[]);if(t<0&&0===e.length)return;if(e.length>0){const t=await Promise.all(e.map((t=>On(this.tv.dataFrame.rows.get(t)))));return void await this._newMonomerForm.removeMonomers(t,this.libInput.value)}const n=await On(this.tv.dataFrame.rows.get(t));await this._newMonomerForm.removeMonomers([n],this.libInput.value)}));s.tooltip.bind(h,(()=>(this.tv?.dataFrame?.selection?.trueCount??0)>0?"Delete selected monomers":"Delete monomer"));const u=s.iconFA("arrow-to-bottom",(async()=>{const t=this.libInput.value;if(!t)return r.shell.error("No library selected");let e=null;try{e=await r.dapi.files.readAsText(cn.so+t)}catch(e){return r.shell.error(`Error reading library ${t}`),console.error(e)}if(!e)return r.shell.error(`Library ${t} is empty`);a.Utils.download(t,e,"text/plain")}),"Download Monomer Library");i.push([o,c,l,h,u]),this.tv.setRibbonPanels(i),this.tv.name=Mn.VIEW_NAME,this.libInput=s.input.choice("Monomer Library",{value:t,items:n,nullable:!1,onValueChanged:async()=>{try{if(this._skipLibInputOnchange)return;const t=await this.getMonomersDf(this.libInput.value);this.tv.dataFrame=t,this.adjustTable()}catch(t){console.error(t)}}}),this.libInput.addOptions(s.icons.add((()=>{this.createNewLibDialog()}),"Create new monomer library..."));const d=this._newMonomerForm.form;return d.prepend(this.libInput.root),s.tools.waitForElementInDom(this.tv.root).then((()=>{this.tv.dockManager.dock(d,a.DOCK_TYPE.LEFT,null,void 0,.4)})),this.tv}async editMonomer(t){return this._newMonomer=await On(t),this._newMonomerForm.setMonomer(this._newMonomer),this._newMonomer}async getMonomersDf(t){this.tv?.grid&&s.setUpdateIndicator(this.tv.grid.root,!0);try{if(t??=(await this.monomerLibManamger.getFileManager()).getValidLibraryPaths()[0],this.activeMonomerLib=await this.monomerLibManamger.readLibrary(cn.so,t),!this.activeMonomerLib)return r.shell.error(`Library ${t} not found`),a.DataFrame.create();const e=this.activeMonomerLib.getPolymerTypes().flatMap((t=>this.activeMonomerLib.getMonomerSymbolsByType(t).map((e=>this.activeMonomerLib.getMonomer(t,e))))),n=a.DataFrame.create(e.length),i=new Set;for(const t of e)t.rgroups.forEach((t=>{t.label&&i.add(t.label)}));const o=Array.from(i);o.sort();for(const[t,e]of Object.entries(En))if(n.columns.addNew(t,e),t===An.R_GROUPS)for(const t of o)n.columns.addNew(t,a.COLUMN_TYPE.STRING);n.col(An.SYMBOL).semType="Monomer",n.col(An.SYMBOL).setTag(Rt.Mn.applyToBackground,"true");for(let t=0;t<e.length;t++){let i=$n(e[t].rgroups,e[t].smiles,e[t].molfile);i=Tn(i),e[t].rgroups=Ln(e[t].rgroups);const r=o.map((n=>{const i=e[t].rgroups.find((t=>t.label===n));return i?In(i,"capGroupSmiles"):""}));let s=null;if(e[t].createDate)try{s=Date.parse(e[t].createDate)}catch(n){console.error(`Error parsing date ${e[t].createDate}`)}n.rows.setValues(t,[i,e[t].symbol,e[t].name,JSON.stringify(e[t].rgroups??[]),...r,e[t].monomerType,e[t].polymerType,e[t].naturalAnalog,e[t].author,s,e[t].id,JSON.stringify(e[t].meta??{}),e[t].lib?.source??""]);try{s&&n.col(An.CREATE_DATE)?.set(t,s,!1)}catch(n){console.error(`Error setting date ${e[t].createDate}`)}}return n.col(An.MONOMER).semType=a.SEMTYPE.MOLECULE,o.forEach((t=>{n.col(t).semType=a.SEMTYPE.MOLECULE})),n.currentRowIdx=-1,n.onCurrentRowChanged.subscribe((async t=>{try{if(-1===n.currentRowIdx||this._newMonomerForm.molChanged)return;await this.editMonomer(n.rows.get(n.currentRowIdx))}catch(t){console.error(t)}})),n}catch(t){throw r.shell.error("Error creating monomers dataframe"),console.error(t),t}finally{this.tv?.grid&&s.setUpdateIndicator(this.tv.grid.root,!1)}}async fixAllMonomers(){s.dialog("Fix All Monomers").add(s.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(s.divText("Do you wish to continue?")).onOK((async()=>{const t=this.tv?.dataFrame;let e=this.libInput.value;if(t&&e){this.tv?.grid&&s.setUpdateIndicator(this.tv.grid.root,!0);try{const n=await Promise.all(new Array(t.rowCount).fill(0).map(((e,n)=>On(t.rows.get(n))))),i=JSON.stringify(n.map((t=>({...t,lib:void 0,wem:void 0}))),null,2);e.endsWith(".json")||(e+=".json"),await r.dapi.files.writeAsText(cn.so+e,i),await this.monomerLibManamger.loadLibraries(!0),r.shell.v=await this.getViewRoot(e)}catch(t){r.shell.error("Error saving library"),console.error(t)}finally{this.tv?.grid&&s.setUpdateIndicator(this.tv.grid.root,!1)}}else r.shell.error("No monomer library loaded")})).show()}resetCurrentRowFollowing(){this._newMonomerForm.molChanged=!1}}function Tn(t){let e=t.replaceAll(/\[R[1-9]\]/g,(t=>`[*:${t[2]}]`));return e=e.replaceAll(/\[\d\*\]/g,(t=>`[*:${t[1]}]`)),e.replaceAll(/\[\d\*\:\d\]/g,(t=>`[*:${t[1]}]`))}const _n=["alternateId","capGroupName","capGroupSMILES","label"];function In(t,e){const n=Object.keys(t).find((t=>t.toLowerCase()===e.toLowerCase()));if(n)return t[n]}function Ln(t){return t.map((t=>{const e=function(t,e){const n={};return t.forEach((t=>{const i=Object.keys(e).find((e=>e.toLowerCase()===t.toLowerCase()));i&&(n[t]=e[i])})),n}(_n,t),n=In(e,"capGroupSMILES"),i=In(e,"alternateId"),o=In(e,"capGroupName"),r=In(e,"label")??"R1";if(n&&i&&o||r.length<2)return e;if(i&&-1!==i.indexOf(`${r}-`)){const t=i.replace(`${r}-`,"");o||(e.capGroupName=t),n||(e.capGroupSMILES=`[*:${r.substring(1)}][${t}]`)}else o&&(n||(e.capGroupSMILES=`[*:${r.substring(1)}][${o}]`),i||(e.alternateId=`${r}-${o}`));return e})).sort(((t,e)=>t.label?.localeCompare(e.label??"")??0))}class Nn{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(t){this._molChanged=t}saveValidationResult=null;triggerMolChange=!0;inputsTabControl;constructor(t,e,n,i){this.monomerLibManager=t,this.getMonomerLib=e,this.refreshTable=n,this.getMonomersDataFrame=i,this.colors={line:"#000000",background:"#000000",text:"#000000"},this.colorsEditor=new Hn(this.colors),this.molSketcher=new a.chem.Sketcher,this.molSketcher.root.classList.add("monomer-manager-sketcher"),this.polymerTypeInput=s.input.choice("Polymer Type",{value:"PEPTIDE",items:["PEPTIDE","RNA","CHEM","BLOB","G"],onValueChanged:()=>this.onMonomerInputChanged(),nullable:!1}),this.monomerTypeInput=s.input.choice("Monomer Type",{value:"Backbone",items:["Backbone","Branch","Terminal"],onValueChanged:()=>this.onMonomerInputChanged(),nullable:!1}),this.monomerSymbolInput=s.input.string("Monomer Symbol",{nullable:!1,onValueChanged:()=>this.onMonomerInputChanged()}),this.monomerNameInput=s.input.string("Monomer Name",{nullable:!1,onValueChanged:()=>this.onMonomerInputChanged()}),this.monomerNameInput.nullable=!1,this.monomerIdInput=s.input.int("Monomer ID",{nullable:!0,value:0,onValueChanged:()=>this.onMonomerInputChanged()}),this.monomerNaturalAnalogInput=s.input.string("Natural Analog",{nullable:!0,onValueChanged:()=>this.onMonomerInputChanged()}),this.saveButton=s.bigButton("Save",(async()=>{const t=this.validateInputs();t?r.shell.warning(t):await this.saveMonomer()})),this.molSketcher.subs.push(this.molSketcher.onChanged.subscribe((async()=>{if(this.triggerMolChange){try{this.rgroupsGridRoot.style.display="none";const t=this.inputsTabControl.panes.find((t=>"r-groups"===t.name?.toLowerCase()));t&&t.header.style.removeProperty("background-color");let e=this.molSketcher.getSmiles();if(!e)return this.rgroupsGrid.items=[],this.rgroupsGrid.render(),this.saveValidationResult="Monomer molecule is required",void this.invalidateSaveButton();e=$n([],e);const n=this.findRgroupsInSmiles(e);if(0===n.length)return this.rgroupsGrid.items=[],this.rgroupsGrid.render(),this.saveValidationResult="At least one R-group is required",t&&t.header.style.setProperty("background-color","#ff000030"),void this.invalidateSaveButton();if(new Set(n.map((t=>t[0]))).size!==n.length)return this.saveValidationResult="Duplicate R-groups are not allowed",this.rgroupsGridRoot.style.display="flex",t&&t.header.style.setProperty("background-color","#ff000030"),void this.invalidateSaveButton();const i=n.map((t=>Number.parseInt(t[0].match(/[1-9]/g)[0]))).map((t=>this.rgroupsGrid.items.find((e=>e.label===`R${t}`))??{capGroupSMILES:`[*:${t}][H]`,alternateId:`R${t}-H`,capGroupName:"H",label:`R${t}`}));this.rgroupsGrid.items=i.sort(((t,e)=>t.label?.localeCompare(e.label??"")??0)),this.rgroupsGrid.render(),this.rgroupsGridRoot.style.display="flex";const o=await Cn(kn(e,i),this.polymerTypeInput.value??"");o&&(this.monomerNaturalAnalogInput.value=o)}catch(t){console.error(t)}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:t=>t?r.chem.checkSmiles(t)?null:"Invalid SMILES":"Cap group smiles is required",alternateId:t=>t?null:"Alternate ID is required",capGroupName:t=>t?null:"Cap group name is required",label:t=>t?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=s.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=s.divV([this.polymerTypeInput,this.monomerTypeInput,this.monomerSymbolInput,this.monomerNameInput,this.monomerIdInput,this.monomerNaturalAnalogInput]);this.inputsTabControl=s.tabControl({Monomer:c,"R-groups":this.rgroupsGridRoot,Meta:s.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 t=this.polymerTypeInput.value&&this.polymerTypeInput.value&&!!this.getMonomerLib()?.getMonomer(this.polymerTypeInput.value,this.monomerSymbolInput.value);this.saveButton.textContent=t?"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(t){this.triggerMolChange=!1,this.molSketcher.setSmiles(t.smiles),this.polymerTypeInput.value=t.polymerType,this.monomerTypeInput.value=t.monomerType,this.monomerSymbolInput.value=t.symbol,this.monomerNameInput.value=t.name,this.monomerIdInput.value=t.id,this.monomerNaturalAnalogInput.value=t.naturalAnalog??null,this.rgroupsGrid.items=Ln(t.rgroups),this.metaGrid.items=Object.entries(t.meta??{}).filter((([t,e])=>"colors"!==t?.toLowerCase())).map((([t,e])=>({Property:t,Value:e}))),this.rgroupsGrid.render(),this.metaGrid.render(),this.rgroupsGridRoot.style.display="flex",this.onMonomerInputChanged(),!t.naturalAnalog&&t.polymerType&&Cn(kn(t.smiles,this.rgroupsGrid.items),t.polymerType).then((t=>{t&&(this.monomerNaturalAnalogInput.value=t)}));const e=t.meta?.colors??"";let n={};try{n=e?JSON.parse(e)?.default:{}}catch(t){console.error(t)}this.colorsEditor.colors={line:n.line??"#000000",background:n.background??"#000000",text:n.text??"#000000"}}validateInputs(){const t=this.inputsTabControl.panes.find((t=>"r-groups"===t.name?.toLowerCase()));if(t&&t.header.style.removeProperty("background-color"),!this.molSketcher.getSmiles())return"Monomer Molecule field is required";for(const t of[this.polymerTypeInput,this.monomerTypeInput,this.monomerSymbolInput,this.monomerNameInput])if(null==t.value||""===t.value)return`${t.caption} field is required`;let e=null;if(this.rgroupsGrid.items.length<1&&(e="At least one R-group is required"),!e)t:for(const t of this.rgroupsGrid.items)for(const[n,i]of Object.entries(t))if(!i){e=`R-group ${n} field is required for ${t.label}`;break t}return!e&&this.rgroupsGrid.hasErrors()&&(e="R-group fields contain errors"),e?(t&&t.header.style.setProperty("background-color","#ff000030"),e):null}findRgroupsInSmiles(t){return[...Array.from(t.matchAll(/\[[1-9]\*\]/g)),...Array.from(t.matchAll(/\[\*\:[1-9]\]/g))]}get form(){this.inputsTabControl.root.classList.add("monomer-manager-form-tab-control"),this.inputsTabControl.header.style.marginBottom="10px";const t=s.buttonsInput([this.saveButton]);return s.tooltip.bind(t,(()=>this.saveValidationResult??"Save monomer to library")),s.divV([this.molSketcher.root,this.inputsTabControl.root,t],{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(t){const e=$n(t.rgroups,t.smiles,t.molfile),n=r.chem.drawMolecule(e,150,150),i=s.tableFromMap({name:t.name,author:t.author,createDate:t.createDate});return s.divH([n,i],{style:{alignItems:"center"}})}async removeMonomers(t,e,n=!0){let i=[];try{const t=await r.dapi.files.readAsText(cn.so+e);i=JSON.parse(t)}catch(t){return r.shell.error(`Error reading library ${e}`),console.error(t)}const o=t.map((t=>Pn(i,(e=>e.symbol===t.symbol&&e.polymerType===t.polymerType))));for(let n=0;n<o.length;n++)if(-1===o[n])return void r.shell.error(`Monomer ${t[n].symbol} not found in library ${e}`);const a=o.map((t=>i[t])),l=s.divV(a.map((t=>this.getMonomerInfoTable(t))),{style:{maxHeight:"500px",overflow:"scroll"}}),c=a.length>1,h=c?`Are you sure you want to remove monomers ${a.map((t=>t.symbol)).join(", ")} from ${e} library?`:`Are you sure you want to remove monomer with symbol ${a[0].symbol} from ${e} library?`,u=s.dialog("Remove Monomer"+(c?"s":"")).add(s.h1(h)).add(l).addButton("Remove",(async()=>{i=i.filter((t=>!a.includes(t))),await r.dapi.files.writeAsText(cn.so+e,JSON.stringify(i,null,2)),await(await dn.getInstance()).loadLibraries(!0),await this.refreshTable(),n&&r.shell.info(`Monomer${c?"s":""} ${a.map((t=>t.symbol)).join(", ")} ${c?"were":"was"} successfully removed from ${e} library`),u.close()})).show()}async addMonomerToLib(t,e){let n=[];try{const t=await r.dapi.files.readAsText(cn.so+e);n=JSON.parse(t)}catch(t){return r.shell.error(`Error reading library ${e}`),console.error(t)}const i=Pn(n,(e=>e.symbol===t.symbol&&e.polymerType===t.polymerType)),o=this.getMonomersDataFrame()?.col(An.MONOMER)?.toList()?.findIndex((e=>e===t.smiles)),a=async()=>{try{const i=n.findIndex((e=>e.symbol===t.symbol&&e.polymerType===t.polymerType));i>=0?n[i]={...t,lib:void 0,wem:void 0}:n.push({...t,lib:void 0,wem:void 0}),await r.dapi.files.writeAsText(cn.so+e,JSON.stringify(n,null,2)),await(await dn.getInstance()).loadLibraries(!0),await this.refreshTable(t.symbol),this._molChanged=!1,r.shell.info(`Monomer ${t.symbol} was successfully saved in library ${e}`)}catch(t){r.shell.error("Error saving monomer"),console.error(t)}this.onMonomerInputChanged()};let l=null,c="";if(i>=0)l=this.getMonomerInfoTable(n[i]),c=`Monomer with symbol '${t.symbol}' already exists in library ${e}.\nAre you sure you want to overwrite it?`;else if((o??-1)>=0){const t=await On(this.getMonomersDataFrame().rows.get(o));l=this.getMonomerInfoTable(t),c=`Monomer with the same structure already exists in library ${e} with different symbol (${t.symbol}).\nAre you sure you want to duplicate it?`}if(l){const t=s.dialog("Save Monomer").add(s.divText(c)).add(l).addButton("Save",(()=>{t.close(),a()})).show()}else await a()}async saveMonomer(){let t=this.molSketcher.getSmiles();if(!t||!r.chem.checkSmiles(t))return void r.shell.warning("Invalid SMILES");t=$n([],t);let e=r.chem.convert(t,a.chem.Notation.Smiles,a.chem.Notation.MolBlock);e=Rn(e);const n={};this.metaGrid.items.filter((t=>!!t.Property&&!!t.Value)).forEach((t=>{n[t.Property]=t.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:e,smiles:t,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},s=this.getMonomerLib()?.source;s?await this.addMonomerToLib(o,s):r.shell.warning("Monomer library source is not specified")}}function Pn(t,e){let n=-1;for(let i=t.length-1;i>=0;i--)if(e(t[i])){n=i;break}return n}function $n(t,e,n){const i=!e||!r.chem.checkSmiles(e);if(i&&!n)throw new Error("Both SMILES and MOL block are empty or malformed");let o=i?r.chem.convert(n,a.chem.Notation.Unknown,a.chem.Notation.Smiles):e;return o=function(t,e){let n=t;return e.forEach((t=>{const e=t.label[1]??"1",i=new RegExp(`\\[\\${t.capGroupName}:${e}\\]`,"g");n=n.replace(i,`[*:${e}]`)})),n=n.replaceAll(/\[\d[A-Z]{1,2}\]/g,(t=>`[*:${t[1]}]`)),n}(o,t),o=Tn(o),i?o:r.chem.convert(o,a.chem.Notation.Unknown,a.chem.Notation.Smiles)}function Rn(t){const e=t.split("\n"),n=e.findIndex((t=>t.startsWith("M")&&t.includes("ISO")));if(-1!==n){const t=e[n].indexOf("ISO");e[n]=e[n].substring(0,t)+"RGP"+e[n].substring(t+3)}const i=e.findIndex((t=>t.includes("V2000")));if(-1===i)return console.error("Mol start line not found"),t;const o=Number.parseInt(e[i].trim().split(" ")[0].slice(0,3).trim()),r={};for(let t=i+1;t<i+1+o;t++){const n=e[t].indexOf("R ");if(-1===n)continue;"#"!==e[t][n+1]&&(e[t]=e[t].replace("R ","R#"));const o=e[t].trim().split(" ").map((t=>t.trim())).filter(Boolean);if(r[t-i]=1,o.length<14)continue;const s=Number.parseInt(o[13]);Number.isNaN(s)||(r[t-i]=s)}const s=Object.keys(r);if(-1===e.findIndex((t=>t.startsWith("M")&&t.includes("RGP")))){const t=`M RGP${s.length.toString().padStart(3," ")}${Object.entries(r).map((([t,e])=>`${t.toString().padStart(4," ")}${e.toString().padStart(4," ")}`)).join("")}`,n=e.findIndex((t=>t.startsWith("M")&&t.includes("END")));e.splice(n,0,t)}return s.filter((t=>!!Number.parseInt(t))).map((t=>Number.parseInt(t)+i)).forEach((t=>{const n=e[t].split(" "),i=n.findIndex((t=>"R#"===t));if(-1!==i){for(let t=i+1;t<n.length;t++)n[t]&&1==n[t].length&&(Number.parseInt(n[t])??0)>0&&(n[t]="0");e[t]=n.join(" ")}})),e.join("\n")}function kn(t,e){let n=t;return e.forEach((t=>{const e=t.label[1]??"1",i=In(t,"capGroupName");n=n.replace(`[*:${e}]`,`[${i}]`)})),n}async function On(t){let e;try{e=JSON.parse(t.get(An.META)??"{}");for(const t in e)"object"==typeof e[t]&&(e[t]=JSON.stringify(e[t])),("string"!=typeof e[t]||e[t]!==a.INT_NULL.toString()&&e[t]!==a.FLOAT_NULL.toString())&&("number"!=typeof e[t]||e[t]!==a.INT_NULL&&e[t]!==a.FLOAT_NULL)||(e[t]=null)}catch(t){console.error(t)}const n=t.get(An.MONOMER);if(!n)throw new Error("Monomer SMILES is empty");let i="";try{i=r.chem.convert(n,a.chem.Notation.Smiles,a.chem.Notation.MolBlock),i=Rn(i)}catch(t){r.shell.error(`Error converting SMILES to molfile, \n ${n}`),console.error(t)}let o=t.get(An.NATURAL_ANALOG);const s=t.get(An.POLYMER_TYPE);let l=[];try{if(l=JSON.parse(t.get(An.R_GROUPS)??"[]"),!o&&s){const t=await Cn(kn(n,l),s);t&&(o=t)}}catch(t){l??=[]}return{symbol:t.get(An.SYMBOL),name:t.get(An.NAME),molfile:i,smiles:n,polymerType:s,monomerType:t.get(An.MONOMER_TYPE),naturalAnalog:o,id:t.get(An.ID),rgroups:l,meta:e,author:t.get(An.AUTHOR),createDate:t.get(An.CREATE_DATE)}}class Hn{_colors;_colorInputs;constructor(t){this._colors=t,this._colorInputs={line:s.input.color("Line",{value:t.line,onValueChanged:t=>this._colors.line=t}),background:s.input.color("Background",{value:t.background,onValueChanged:t=>this._colors.background=t}),text:s.input.color("Text",{value:t.text,onValueChanged:t=>this._colors.text=t})}}get colors(){return this._colors}set colors(t){const e={line:a.Color.toHtml(a.Color.fromHtml(t.line??"#000000")),background:a.Color.toHtml(a.Color.fromHtml(t.background??"#000000")),text:a.Color.toHtml(a.Color.fromHtml(t.text??"#000000"))};this._colors=e;for(const t in this._colorInputs)this._colorInputs[t].value=e[t]}get colorsMetaFormat(){return{colors:{default:this._colors}}}get form(){return s.form(Object.values(this._colorInputs))}}class Gn{monomer;root=s.divV([],{classes:"monomer-card-root"});_selected=!1;get selected(){return this._selected}set selected(t){this._selected=t,this.root.style.border=t?"2px solid var(--green-2)":"2px solid var(--grey-2)"}constructor(t){this.monomer=t}render(){s.empty(this.root);const t=this.monomer.smiles&&r.chem.checkSmiles(this.monomer.smiles)?r.chem.drawMolecule(this.monomer.smiles,200,200):r.chem.drawMolecule(this.monomer.molfile??"",200,200);this.root.appendChild(t);const e=s.divH([s.divText("Monomer Name: "),s.divText(this.monomer.name)],{classes:"monomer-card-info-row"});if(this.root.appendChild(e),s.tooltip.bind(e,this.monomer.name),this.monomer.lib?.source){const t=s.divH([s.divText("Source: "),s.divText(this.monomer.lib.source)],{classes:"monomer-card-info-row"});this.root.appendChild(t),s.tooltip.bind(t,this.monomer.lib.source)}const n=s.divH([s.divText("Polymer Type: "),s.divText(this.monomer.polymerType)],{classes:"monomer-card-info-row"});this.root.appendChild(n),s.tooltip.bind(n,this.monomer.polymerType),s.tooltip.bind(this.root,"Select Monomer")}}class Fn{monomerSymbol;monomers;root=s.divH([],{style:{alignItems:"center",width:"100%",overflow:"hidden",visibility:"visible"},classes:"duplicate-monomer-symbol-row"});monomerCards;constructor(t,e,n,i){this.monomerSymbol=t,this.monomers=e,this.monomerCards=e.map((t=>new Gn(t)));const o=s.divH([],{style:{overflowX:"auto",width:"100%"}}),r=s.h1(t,{style:{lineHeight:"2em",fontSize:"1.5em",marginRight:"20px",width:"100px",overflow:"hidden",textOverflow:"elipsis"}});s.tooltip.bind(r,t),this.root.appendChild(r),this.root.appendChild(o),this.monomerCards.forEach((t=>{t.root.onclick=()=>{this.monomerCards.forEach((t=>t.selected=!1)),t.selected=!0,i(t.monomer)},n&&t.monomer===n&&(t.selected=!0),o.appendChild(t.root)}))}render(){this.monomerCards.forEach((t=>t.render()))}}class Bn{monomerCardRows=[];saveSettingsPromise=Promise.resolve();searchInput;_root;monomers;settings;filteredMonomerRows=[];static _instance;vv;static async getInstance(){return Bn._instance||(Bn._instance=new Bn,await Bn._instance.refresh(),(await dn.getInstance()).getMonomerLib().onChanged.subscribe((async()=>await Bn._instance.refresh()))),Bn._instance.refresh(),Bn._instance}async refresh(){this.settings=await(0,Nt.ub)();const t=await dn.getInstance();await t.awaitLoaded(),await t.loadLibrariesPromise,this.monomers=t.duplicateMonomers,this.monomerCardRows=[];for(const e in this.monomers)for(const n in this.monomers[e]){const i=this.settings.duplicateMonomerPreferences?.[e]?.[n]??null,o=i?this.monomers[e][n].find((t=>t.lib?.source===i))??null:null;this.monomerCardRows.push(new Fn(n,this.monomers[e][n],o,(async i=>{this.saveSettingsPromise=this.saveSettingsPromise.then((async()=>{i.lib?.source&&(this.settings.duplicateMonomerPreferences=this.settings.duplicateMonomerPreferences??{},this.settings.duplicateMonomerPreferences[e]=this.settings.duplicateMonomerPreferences[e]??{},this.settings.duplicateMonomerPreferences[e][n]=i.lib.source,await(0,Nt.Eu)(this.settings),r.shell.info(`Monomer '${i.name}' from source '${i.lib.source}' selected for symbol '${n}'.`),t.assignDuplicatePreferances(this.settings))}))})))}if(this.filteredMonomerRows=this.monomerCardRows,this.vv)this.vv.setData(this.filteredMonomerRows.length,(t=>(this.filteredMonomerRows[t].render(),this.filteredMonomerRows[t].root)));else{this.vv=s.virtualView(this.monomerCardRows.length,(t=>(this.monomerCardRows[t].render(),this.monomerCardRows[t].root))),this.vv.root.classList.add("duplicate-monomers-virtual-view"),this.searchInput=s.input.string("Search",{placeholder:"Monomer Symbol",value:"",onValueChanged:()=>t(this.searchInput.value)}),this.searchInput.root.style.justifyContent="center",this.searchInput.input.style.width="200px",this._root=s.divV([s.h1("Manage Duplicate Monomer Symbols",{style:{textAlign:"center"}}),this.searchInput.root,s.divV([this.vv.root],{style:{overflowY:"auto",height:"100%"}})],{style:{height:"100%"}});const t=t=>{this.filteredMonomerRows=this.monomerCardRows.filter((e=>e.monomerSymbol.toLowerCase().includes(t.toLowerCase()))),this.vv.setData(this.filteredMonomerRows.length,(t=>(this.filteredMonomerRows[t].render(),this.filteredMonomerRows[t].root)))}}}constructor(){}get root(){return this._root}}async function Dn(){await jn.showDialog()}async function Vn(t=!0){return await qn.showView(t)}class Wn{_fileManager;_widget;get widget(){return this._widget}constructor(){}static instancePromise;static async getInstance(){return void 0===Wn.instancePromise&&(Wn.instancePromise=(async()=>{const t=new Wn,e=await(0,bt.pj)();return t._fileManager=await e.getFileManager(),t._widget=await t.createWidget(),t})()),Wn.instancePromise}static async reloadWidget(){const t=await Wn.getInstance();t._widget=await t.createWidget()}async createWidget(){const t=await this.getWidgetContent();return(await(0,bt.pj)()).eventManager.addLibraryFileRequested$.subscribe((()=>this.promptToAddLibraryFiles())),new a.Widget(t)}async getWidgetContent(){const t=await Un.createControlsForm();return mn()(t).addClass("monomer-lib-controls-form"),setTimeout((()=>{t&&mn()(t)&&mn()(t).removeClass("ui-form-condensed")}),200),s.divV([t])}async promptToAddLibraryFiles(){a.Utils.openFile({accept:".json",open:async t=>{const e=await t.text(),n=t.name,i=a.TaskBarProgressIndicator.create(`Adding ${n} as a monomer library`);try{await this._fileManager.addLibraryFile(e,n)}catch(t){r.shell.error(`File ${n} is not a valid monomer library, verify it is aligned to HELM JSON schema.`)}finally{i.close()}}})}}class Un{fileManager;userLibSettings;constructor(t,e){this.fileManager=t,this.userLibSettings=e,this.fileManager.eventManager.updateUIControlsRequested$.subscribe((()=>{this.updateControlsForm()})),this.fileManager.eventManager.librarySelectionRequested$.subscribe((([t,e])=>{this.updateLibrarySelectionStatus(e,t)}))}toLog(){return"LibraryControlsManager<#>"}static async createControlsForm(){eo.logger.debug("LibraryControlsForm.createControlsForm(), start");const[t,e]=await Promise.all([(0,bt.pj)().then((t=>t.getFileManager())),await(0,Nt.ub)()]);return new Un(t,e)._createControlsForm()}_createControlsForm(){const t=this.createLibraryControls(),e=s.wideForm(t,void 0);return mn()(e).addClass("monomer-lib-controls-form"),e}updateControlsForm(){const t=this._createControlsForm();mn()(".monomer-lib-controls-form").replaceWith(t)}createLibraryControls(){return this.fileManager.getValidLibraryPaths().map((t=>this.createLibInput(t)))}createLibInput(t){const e=`${this.toLog()}.createLibInput()`;eo.logger.debug(`${e}, libFileName = '${t}', start`);const n=!this.userLibSettings.exclude.includes(t),i=s.input.bool(t,{value:n,onValueChanged:()=>{this.fileManager.eventManager.updateLibrarySelectionStatus(t,i.value)}});s.tooltip.bind(i.root,`Include monomers from ${t}`);const o=s.iconFA("trash-alt",(()=>this.promptForLibraryDeletion(t))),a=s.icons.edit((async()=>{r.shell.v=await(await Mn.getInstance()).getViewRoot(t)}),"Edit monomer library");return s.tooltip.bind(o,`Delete ${t}`),i.addOptions(a),i.addOptions(o),eo.logger.debug(`${e}, libFileName = '${t}', end`),i}async updateLibrarySelectionStatus(t,e){this.updateLibrarySettings(t,e),await(0,Nt.Eu)(this.userLibSettings);const n=await(0,bt.pj)();await n.loadMonomerLib(!0),r.shell.info("Monomer library user settings saved")}updateLibrarySettings(t,e){t?this.userLibSettings.exclude=this.userLibSettings.exclude.filter((t=>t!==e)):this.userLibSettings.exclude.includes(e)||this.userLibSettings.exclude.push(e)}promptForLibraryDeletion(t){s.dialog("Warning").add(s.divText(`Delete file ${t}?`)).onOK((async()=>{try{const e=a.TaskBarProgressIndicator.create(`Deleting ${t} library`);await this.updateLibrarySelectionStatus(!1,t),await this.fileManager.deleteLibraryFile(t),e.close()}catch(e){console.error(e),r.shell.error(`Failed to delete ${t} library`)}})).showModal(!1)}}class jn{constructor(){}static _instance;dialog;closeDialogSubject$=new h.Subject;static async showDialog(){jn._instance||(jn._instance=new jn,jn._instance.closeDialogSubject$.subscribe((()=>{jn._instance.dialog=void 0}))),jn._instance.dialog||(jn._instance.dialog=await jn._instance.getDialog()),jn._instance.dialog.show()}async getDialog(){const t=un.getInstance(),e=(await Wn.getInstance()).widget,n=s.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",(()=>t.addLibraryFile()),void 0,"Upload new HELM monomer library"),n.add(e);const i=n.onClose.subscribe((()=>{this.closeDialogSubject$.next(),i.unsubscribe()}));return n}}class qn{constructor(){}static _instance;static viewName="Manage Monomer Libraries";_view;_duplicateManager;libManager;async getView(t=!0){const e=un.getInstance(),n=(await Wn.getInstance()).widget,i=s.bigButton("Add",(()=>e.addLibraryFile()),"Upload new HELM monomer library"),o=s.bigButton("Merge",(()=>{this.mergeSelectedLibs()}),"Merge selected libraries into one"),l=s.splitH([s.divV([n.root,s.buttonsInput([i,o])],{classes:"ui-form"}),this._duplicateManager.root],{style:{width:"100%",height:"100%"}},!0);if(this._view)try{this._view.subs.forEach((t=>t.unsubscribe())),this._view.detach(),this._view.close()}catch(t){}return this._view=a.View.fromRoot(l),this._view.name=qn.viewName,t&&r.shell.addView(this._view),s.tools.waitForElementInDom(l).then((()=>{setTimeout((()=>{const t=Array.from(l.children).filter((t=>t.classList.contains("ui-box")));if(2!==t.length)return;const[e,n]=t,i=e.getBoundingClientRect().width+n.getBoundingClientRect().width,o=.3*i;e.style.width=`${o}px`;const r=i-o;n.style.width=`${r}px`}),100),this._view.subs.push(r.events.onCurrentViewChanged.subscribe((()=>{try{const t=qn._instance;t&&t._view&&r.shell.v&&"id"in r.shell.v&&r.shell.v.id===t._view.id&&t._duplicateManager?.refresh()}catch(t){console.error(t)}})))})),this._view}static async showView(t=!0){return qn._instance||(qn._instance=new qn),qn._instance._duplicateManager||(qn._instance._duplicateManager=await Bn.getInstance()),qn._instance.libManager||(qn._instance.libManager=await dn.getInstance()),t&&qn._instance._view&&Array.from(r.shell.views).find((t=>t.id&&t.id===qn._instance._view.id))?(r.shell.v=qn._instance._view,await qn._instance._duplicateManager.refresh(),qn._instance._view):(qn.closeExistingViews(),qn._instance.getView(t))}static closeExistingViews(){Array.from(r.shell.views).filter((t=>t.name===qn.viewName)).forEach((t=>t.close()))}async mergeSelectedLibs(){const t="Library with this name already exists",e=await dn.getInstance();if(await e.awaitLoaded(),await e.loadLibrariesPromise,!e.duplicatesHandled)return void r.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=e.getBioLib().toJSON(),i=s.dialog("Merge selected libraries"),o=s.input.string("Library Name",{placeholder:"Enter new library name",nullable:!1,onValueChanged:()=>{const e=h(o.value);i.getButton("Download")?.classList?.toggle("d4-disabled",!!e&&e!==t),i.getButton("Save")?.classList?.toggle("d4-disabled",!!e)}}),l=(await this.libManager.getFileManager()).getValidLibraryPaths();function c(){let t=o.value;return t.endsWith(".json")||(t+=".json"),t}function h(e){return e&&e.trim()?e.endsWith(".json")&&l.includes(e)||l.includes(e+".json")?t:null:"Library name cannot be empty"}o.addValidator(h),i.add(o).add(s.divText(`Total monomers: ${n.length}`)).addButton("Download",(()=>{a.Utils.download(c(),JSON.stringify(n))})).addButton("Save",(async()=>{i.close();const t=c(),e=JSON.stringify(n),o=await this.libManager.getFileManager();this._view&&s.setUpdateIndicator(this._view.root,!0);try{await o.addLibraryFile(e,t,!1);const n=await(0,Nt.ub)();n.exclude=l,await(0,Nt.Eu)(n),await this.libManager.loadLibraries(!0),await Wn.reloadWidget()}catch(e){r.shell.error(`Failed to save library ${t}. see console for details.`),console.error(e)}finally{this._view&&s.setUpdateIndicator(this._view.root,!1)}})).show(),i.getButton("Download")?.classList?.add("d4-disabled"),i.getButton("Save")?.classList?.add("d4-disabled")}}var zn,Yn=function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((i=i.apply(t,e||[])).next())}))};class Kn{_setBreadcrumbsInViewName(){var t,e;const n=["Home","Demo",...(null!==(t=this._path)&&void 0!==t?t:"").split("/")],i=s.breadcrumbs(n);if(i.onPathClick.subscribe((t=>Yn(this,void 0,void 0,(function*(){const e=t[t.length-1];if(e===i.path[i.path.length-1])return;const n=r.shell.browsePanel.mainTree.getOrCreateGroup("Apps").getOrCreateGroup("Demo");n.currentItem="Demo"===e?n:n.items.find((t=>t.text===e))})))),r.shell.v){if(0!==i.path.length&&"Home"===i.path[0]){const t=s.iconFA("home",(()=>{r.shell.v.close(),r.shell.v=a.View.createByType(a.VIEW_TYPE.HOME)}));t.classList.add("demo-breadcrumbs-home-element"),i.root.firstElementChild.replaceWith(t)}const t=null===(e=r.shell.v.ribbonMenu.root.parentElement)||void 0===e?void 0:e.getElementsByClassName("d4-ribbon-name")[0];t&&(t.textContent="",t.appendChild(i.root))}}constructor(t,e,n=!1,i){var o,r;this.name="",this.description="",this._isAutomatic=!1,this._autoStartFirstStep=!1,this._currentStep=0,this._isStopped=!1,this._isCancelled=!1,this._isStepProcessed=!1,this._root=s.div([],{id:"demo-script",classes:"tutorials-root tutorials-track demo-app-script"}),this._steps=[],this._mainHeader=s.panel([],"tutorials-main-header"),this._header=s.h2(""),this._headerDiv=s.divH([],"tutorials-root-header"),this._stopStartBtn=s.button(s.iconFA("pause"),(()=>Yn(this,void 0,void 0,(function*(){return yield this._changeStopState()}))),"Play / pause"),this._restartBtn=s.button(s.iconFA("redo"),(()=>Yn(this,void 0,void 0,(function*(){return yield this._restartScript()}))),"Restart"),this._nextStepBtn=s.button(s.iconFA("play"),(()=>Yn(this,void 0,void 0,(function*(){this._isStepProcessed||(yield this._nextStep())}))),"Next step"),this._activity=s.panel([],"tutorials-root-description"),this._progressDiv=s.divV([],"tutorials-root-progress"),this._progress=s.element("progress"),this._progressSteps=s.divText(""),this._closeBtn=s.button(s.iconFA("chevron-left"),(()=>this._closeDock()),"Back to demo"),this.DEMO_PATH="apps/Tutorials/Demo",this.name=t,this.description=e,this._isAutomatic=n,this._autoStartFirstStep=null!==(o=null==i?void 0:i.autoStartFirstStep)&&void 0!==o&&o,this._path=null!==(r=null==i?void 0:i.path)&&void 0!==r?r:"",this._progress.max=0,this._progress.value=1,Kn.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=s.divText(`Step: ${this._progress.value} of ${this.stepNumber}`),this._progressDiv.append(this._progressSteps)}_addDescription(){var t;this._activity.append(s.div(this.description,"tutorials-root-description"));for(let e=0;e<this.stepNumber;e++){let n=s.iconFA("clock");this._isAutomatic||0===e&&(n=s.iconFA("play",(()=>this._nextStep()),"Next step"),n.className="grok-icon fas fa-play");const i=s.div(this._steps[e].name,"grok-tutorial-entry-instruction"),o=s.div(null===(t=this._steps[e].options)||void 0===t?void 0:t.description,"grok-tutorial-step-description hidden"),r=s.divH([n,i],"grok-tutorial-entry");this._activity.append(r,o)}}_initRoot(){r.shell.windows.showContextPanel=!0,r.shell.windows.showHelp=!1,this._node=r.shell.dockManager.dock(this._root,a.DOCK_TYPE.FILL,r.shell.dockManager.findNode(r.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 t;r.shell.v&&(r.shell.v.name=this.name,r.shell.v.path=`${this.DEMO_PATH}/${(null!==(t=this._path)&&void 0!==t?t:"").replaceAll(" ","-")}`,this._setBreadcrumbsInViewName())}_nextStep(){return Yn(this,void 0,void 0,(function*(){var t,e;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===(t=this._steps[this._currentStep].options)||void 0===t?void 0:t.delay)?null===(e=this._steps[this._currentStep].options)||void 0===e?void 0:e.delay:2e3;try{this._setViewParams(),yield this._steps[this._currentStep].func(),this._setViewParams()}catch(t){console.error(t)}this._scrollTo(this._root,l.offsetTop-this._mainHeader.offsetHeight),this._isAutomatic&&(yield this._countdown(n,i,c),yield(0,te.cb)(c));const h=s.iconFA("check");if(i.replaceWith(h),h.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 t=this._activity.getElementsByClassName("grok-icon")[this._currentStep],e=s.iconFA("play",(()=>this._nextStep()),"Next step");e.className="grok-icon fas fa-play",t.replaceWith(e),this._nextStepBtn.classList.remove("disabled"),this._nextStepBtn.firstChild.classList.remove("fa-disabled")}r.shell.v instanceof a.TableView&&(yield r.data.detectSemanticTypes(r.shell.tv.dataFrame))}else this._isAutomatic?this._stopStartBtn.replaceWith(this._restartBtn):this._nextStepBtn.replaceWith(this._restartBtn)}))}_startScript(){return Yn(this,void 0,void 0,(function*(){for(let t=this._currentStep;t<this.stepNumber&&!this._isStopped&&!this._isCancelled;t++)yield this._nextStep()}))}_scrollTo(t,e){t.focus(),t.scrollTop=e}_countdown(t,e,n){return Yn(this,void 0,void 0,(function*(){const i=s.div([],"demo-script-countdown");e.classList.add("hidden");let o=n/1e3;const r=this._createSVGIndicator(o);i.append(r),t.prepend(i);const a=setInterval((()=>{o--,0===o&&(clearInterval(a),i.remove(),e.classList.remove("hidden"),e.classList.add("visible"))}),1e3)}))}_createSVGIndicator(t){const e=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 ${t}s linear infinite forwards`),e.append(n),e}_changeStopState(){return Yn(this,void 0,void 0,(function*(){const t=this._stopStartBtn.getElementsByClassName("grok-icon");t[0].className="grok-icon fas fa-play",this._isStopped=!this._isStopped,this._isStopped||(t[0].className="grok-icon fal fa-pause",this._isStepProcessed||(yield this._startScript()))}))}_restartScript(){return Yn(this,void 0,void 0,(function*(){r.shell.dockManager.close(this._node),this._clearRoot(),this._setInitParams(),yield this.start()}))}_clearRoot(){this._root=s.div([],{id:"demo-script",classes:"tutorials-root tutorials-track demo-app-script"}),this._mainHeader=s.panel([],"tutorials-main-header"),this._header=s.h2(""),this._headerDiv=s.divH([],"tutorials-root-header"),this._activity=s.panel([],"tutorials-root-description"),this._progressDiv=s.divV([],"tutorials-root-progress"),this._progress=s.element("progress"),this._progressSteps=s.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(){r.shell.dockManager.close(this._node),this.cancelScript()}cancelScript(){this._isCancelled=!0,Kn.currentObject=null}step(t,e,n){return this._steps[this.steps.length]={name:t,func:e,options:n},this}start(){return Yn(this,void 0,void 0,(function*(){this._initRoot(),r.shell.v.name===this.name&&(r.shell.v.close(),this._node=r.shell.dockManager.dock(this._root,a.DOCK_TYPE.FILL,r.shell.dockManager.findNode(r.shell.browsePanel.root),this.name)),this._isAutomatic?yield this._startScript():this._autoStartFirstStep&&(yield this._nextStep())}))}}Kn.currentObject=null,function(t){t.X="Embed_X",t.Y="Embed_Y"}(zn||(zn={}));var Zn=n(966),Xn=n(608),Jn=n(1619);class Qn{urlParams;funcName;options;df;view;constructor(t,e,n={}){this.urlParams=t,this.funcName=e,this.options=n}async init(t){this.df=t,await this.buildView()}async buildView(){const t=ot()(this.urlParams.entries()).map((([t,e])=>`${t}=${encodeURIComponent(e)}`)).toArray().join("&");this.view=r.shell.addTableView(this.df),this.view.path=this.view.basePath=`func/${eo.name}.${this.funcName}?${t}`;const e={...this.options,sequenceColumnName:"sequence"};for(const[t,n]of this.urlParams.entries())switch(t){case oe.n5.fixWidth:case oe.n5.fitArea:e[t]=["1","on","true"].includes(n.toLowerCase());break;default:e[t]=n}const n=await this.view.dataFrame.plot.fromType("WebLogo",e);this.view.dockManager.dock(n,a.DOCK_TYPE.DOWN,null,"WebLogo",.35)}}class ti{tableInput;seqColInput;funcParamsDiv;get funcParams(){return{table:this.tableInput.value,sequence:this.seqColInput.value}}get paramsUI(){return this.funcParamsDiv}constructor(){this.tableInput=s.input.table("Table",{value:r.shell.tv.dataFrame,onValueChanged:()=>{this.onTableInputChanged()}});const t=this.tableInput.value.columns.bySemType(a.SEMTYPE.MACROMOLECULE);this.seqColInput=s.input.column("Sequence",{table:this.tableInput.value,value:t,filter:t=>t.semType===a.SEMTYPE.MACROMOLECULE}),this.funcParamsDiv=s.inputs([this.tableInput,this.seqColInput],{style:{minWidth:"320px"}})}onTableInputChanged(){this.seqColInput=s.input.column("Sequence",{table:this.tableInput.value,value:this.tableInput.value.columns.bySemType(a.SEMTYPE.MACROMOLECULE)})}}var ei=n(6869);new class{tooltipHandlerTemp="tooltip-handler.Monomer"};class ni extends Vt{constructor(t,e){super(t,e)}render(t,e,n,i,o,r,s){t.save();try{if(!r.isTableCell)return;const s=r.cell?.column&&r.cell.column?.dart&&"true"===r.cell.column.getTag(Rt.Mn.applyToBackground);t.font="12px monospace",t.textBaseline="middle",t.textAlign="center";const a=r.cell.value;if(!a||a==wt._S)return;let l=kt.S$,c="rgb(255, 255, 255)";if(this.monomerLib){const t=this.tableCol.getTag(wt.gp.alphabet),e=t===gt.YI.RNA||t===gt.YI.DNA?ei.o.NUCLEOTIDE:ei.o.AA;if(s){const t=this.monomerLib.getMonomerColors(e,a);l=t?.textcolor??l,c=t?.backgroundcolor??c}else l=this.monomerLib.getMonomerTextColor(e,a)}const h=Math.max(2,Math.floor(.15*i));s&&(t.fillStyle=c,t.fillRect(e,n,i,o)),t.fillStyle=l,t.fillText((0,gt.zS)(a,h),e+i/2,n+o/2,i)}finally{t.restore()}}onMouseMove(t,e){if(t.grid.dart!=this.gridCol?.grid.dart||t.gridColumn.dart!=this.gridCol?.dart||!t.tableColumn||!t.isTableCell)return!1;const n=t.tableColumn.getTag(wt.gp.alphabet),i=t.cell.value,o=t.grid.canvas.getBoundingClientRect(),r=t.bounds.right+o.left-4,a=t.bounds.bottom+o.top-4;if(i==wt._S)return s.tooltip.show(s.divText("gap"),r,a),!0;if(!this.monomerLib)return s.tooltip.show(s.divText("Monomer library is not available."),r,a),!0;const l=n===gt.YI.RNA||n===gt.YI.DNA?ei.o.NUCLEOTIDE:ei.o.AA,c=this.monomerLib.getTooltip(l,i);return s.tooltip.show(c,r,a),!0}async awaitRendered(t=1e4,e=`${t} timeout`){return Promise.resolve()}static getOrCreate(t){const[e,n,i]=(0,Gt.BG)(t);let o=i.rendererBack;return o||(o=i.rendererBack=new ni(e,n)),o}}class ii extends a.GridCellRenderer{get name(){return Wt.uF.MONOMER}get cellType(){return Wt.uF.MONOMER}get defaultHeight(){return 15}get defaultWidth(){return 40}render(t,e,n,i,o,r,s){ni.getOrCreate(r).render(t,e,n,i,o,r,s)}onMouseMove(t,e){ni.getOrCreate(t).onMouseMove(t,e)}}class oi{constructor(t,e,n=""){this.target=t,this.debugEnabled=e,this.prefix=n}error(t,e,n){return this.target.error(this.prefix+t,e,n)}warning(t,e){return this.target.warning(this.prefix+t,e)}info(t,e){return this.target.info(this.prefix+t,e)}debug(t,e){if(this.debugEnabled)return this.target.debug(this.prefix+t,e)}}class ri extends Map{_onPropertyChanged=new h.Subject;get onPropertyChanged(){return this._onPropertyChanged}get fontSize(){const t=super.get("FontSize");return t&&!isNaN(t)?Number.parseInt(t):12}set fontSize(t){super.set("FontSize",t),this._onPropertyChanged.next("FontSize")}get maxMonomerLength(){const t=super.get("MaxMonomerLength");return"long"===t?null:parseInt(t)}set maxMonomerLength(t){const e=null===t?"long":t.toString();super.set("MaxMonomerLength",e),this._onPropertyChanged.next("MaxMonomerLength")}get tooltipWebLogo(){return super.get("TooltipWebLogo")}set tooltipWebLogo(t){super.set("TooltipWebLogo",t),this._onPropertyChanged.next("TooltipWebLogo")}get defaultSeparator(){return super.get("DefaultSeparator")}set defaultSeparator(t){if(1!==t.length)throw new Error("The separator must be of length one.");super.set("DefaultSeparator",t),this._onPropertyChanged.next("DefaultSeparator")}constructor(t){super(Object.entries(t))}}class si 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(t){this._properties=t}_initialized=!1;get initialized(){return this._initialized}constructor(t={debug:!1}){super(),super._logger=new oi(super.logger,t.debug)}completeInit(t,e,n,i){this._seqHelper=t,this._monomerLib=e,this._monomerSets=n,this._rdKitModule=i,this._initialized=!0}handleErrorUI(t){const[e,n]=(0,Ct.AP)(t);r.shell.error(e),this.logger.error(e,void 0,n)}}var ai=n(5999),li={};li.styleTagTransform=A(),li.setAttributes=b(),li.insert=g().bind(null,"head"),li.domAPI=m(),li.insertStyleElement=w(),d()(ai.A,li),ai.A&&ai.A.locals&&ai.A.locals;var ci=n(6307);class hi extends a.Widget{seqCol;seqHelper;viewed=!1;wlViewer=null;constructor(t,e){super(s.divV([])),this.seqCol=t,this.seqHelper=e}async init(){const t=this.seqHelper.getSeqHandler(this.seqCol),e=eo.properties.tooltipWebLogo,n=this.seqCol.getTag(ee.gp.tooltipWebLogo);!1===e||["false","off","disable","disabled"].includes(n)||(this.wlViewer=await this.seqCol.dataFrame.plot.fromType("WebLogo",{sequenceColumnName:this.seqCol.name,backgroundColor:0,positionHeight:"Entropy",positionWidth:t.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 ui(t,e,n,i){const o=eo.seqHelper.getSeqHandler(t);let r=null,s=null;for(let t=0;t<o.posList.length;++t)o.posList[t]==e&&(r=t),o.posList[t]==n&&(s=t);if(null===r&&null!==e)throw new Error(`Start position ${e} not found.`);if(null===s&&null!==n)throw new Error(`End position ${n} not found.`);if(o.posList.length<s)throw new Error(`End position ${s} exceeds positions length`);const a=i||`${t.name}: (${e??""}-${n??""})`;return o.getRegion(r,s,a)}const di={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(gt.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 pi{urlParams;funcName;view;data;constructor(t,e){this.urlParams=t,this.funcName=e}async init(t){this.data=t??di;const e=this.data.df.getCol(this.data.colName);this.data.positionNames&&e.setTag(gt.gp.positionNames,this.data.positionNames),this.data.regions&&e.setTag(gt.gp.regions,JSON.stringify(this.data.regions)),await this.buildView()}async buildView(){await r.data.detectSemanticTypes(this.data.df),this.view=r.shell.addTableView(this.data.df),this.view.path=this.view.basePath=`func/${eo.name}.${this.funcName}`;const t=await this.view.dataFrame.plot.fromType("WebLogo",{sequenceColumnName:this.data.colName});this.view.dockManager.dock(t,a.DOCK_TYPE.DOWN,null,"WebLogo",.35)}}class mi{call;seqHelper;inputs=new class{table;sequence;region;start;end;name};constructor(t,e){this.call=t,this.seqHelper=e;const n=t=>this.call.inputParams[t].property.description;this.inputs.table=s.input.table("Table",{value:this.call.inputParams.table.value??r.shell.tv.dataFrame});const i=this.call.inputParams.sequence.value??this.inputs.table.value.columns.bySemType(a.SEMTYPE.MACROMOLECULE);this.inputs.sequence=s.input.column("Sequence",{table:r.shell.tv.dataFrame,value:i,onValueChanged:this.sequenceInputChanged.bind(this),filter:t=>t.semType===a.SEMTYPE.MACROMOLECULE}),this.inputs.start=s.input.choice("Start",{onValueChanged:this.startInputChanged.bind(this)}),this.inputs.end=s.input.choice("End",{onValueChanged:this.endInputChanged.bind(this)}),this.inputs.region=s.input.choice("Region",{value:null,items:[],onValueChanged:this.regionInputChanged.bind(this)}),this.inputs.name=s.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 t in this.call.inputParams)s.tooltip.bind(this.inputs[t].captionLabel,n(t));this.sequenceInputChanged()}sequenceInputChanged(){const t=this.inputs.sequence.value;t&&this.seqHelper.getSeqHandler(t),this.updateRegionItems(),this.updateStartEndInputItems(),this.updateRegion(!0),this.updateNameInput()}fixRegion=!1;regionInputChanged(){this.fixRegion=!0;try{const t=this.inputs.region.stringValue,e=t?JSON.parse(t):null;if(null!==e)this.inputs.start.value=e?.start,this.inputs.end.value=e?.end;else{const t=this.seqHelper.getSeqHandler(this.inputs.sequence.value);this.inputs.start.value=t.posList[0],this.inputs.end.value=t.posList[t.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 t=this.inputs.sequence.value,e=t?this.seqHelper.getSeqHandler(t):null,n=this.inputs.start.input,i=this.inputs.end.input;for(let t=n.options.length-1;t>=0;--t)n.options.remove(t);for(let t=i.options.length-1;t>=0;--t)i.options.remove(t);for(const t of e?.posList??[]){const e=document.createElement("option"),o=document.createElement("option");e.text=o.text=t,e.value=o.value=t,n.options.add(e),i.options.add(o)}n.value=e?.posList[0]??"",i.value=e?.posList[e?.posList.length-1]??""}updateRegionItems(){const t=this.inputs.sequence.value,e=t?t.getTag(gt.gp.regions):null,n=e?JSON.parse(e):null,i=this.inputs.region.input;for(let t=i.options.length-1;t>=0;--t)i.options.remove(t);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 t of n){const e=document.createElement("option");e.text=`${t.name}: ${t.start}-${t.end}`,e.value=JSON.stringify(t),i.options.add(e)}}else this.inputs.region.root.style.display="none"}updateRegion(t){const e=this.inputs.start.stringValue??"",n=this.inputs.end.stringValue??"";if(!this.fixRegion){const t=this.inputs.region.input;t.selectedIndex=-1;for(let i=t.options.length-1;i>=0;--i){const o=t.options[i],r=JSON.parse(o.value);r&&e===r.start&&n===r.end&&(t.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 t=this.inputs.region.stringValue,e=t?JSON.parse(t):null,n=this.inputs.sequence.value,i=this.inputs.start.stringValue??"",o=this.inputs.end.stringValue??"";return null!=e?`${n.name}(${e.name}): ${e.start}-${e.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 t=this.inputs.name.stringValue;return""==t?null:t}dialog(){const t=s.inputs(Object.values(this.inputs),{style:{minWidth:"320px"}});s.dialog({title:"Get Region"}).add(t).onOK((()=>{(async()=>{const t=this.getParams();await this.call.func.prepare(t).call(!0)})().catch((t=>{eo.handleErrorUI(t)}))})).show()}widget(){const t=s.inputs(Object.entries(this.inputs).filter((([t,e])=>!["table","sequence"].includes(t))).map((([t,e])=>e))),e=s.button("Get Region",(()=>{(async()=>{const t=this.getParams();await this.call.func.prepare(t).call(!0)})().catch((t=>{eo.handleErrorUI(t)}))}));return a.Widget.fromRoot(s.divV([t,s.div(e)]))}}var fi=n(8754);async function gi(t,e,n,i,o){const r=await async function(t,e,n,i,o){const r=(0,vt.R)(e,o),s=o.getSeqHandler(e).getNewColumnFromList("ref",[n]),l=o.getSeqHandler(s).getSplitted(0),c=i===ft.IDENTITY?function(t,e){const n=e.columns.length,i=new Array(n),o=new Array(n),r=new Array(n);for(let s=0;s<n;++s){const n=e.columns.byIndex(s);i[s]=n.getRawData(),o[s]=n.categories.indexOf("");const a=s<t.length?t.getOriginal(s):wt._S;r[s]=n.categories.indexOf(a)}const s=a.Column.float("Identity",e.rowCount),l=s.getRawData();for(let n=0;n<e.rowCount;++n){l[n]=0;for(let e=0;e<t.length;++e)(i[e]?i[e][n]:0)===r[e]&&++l[n];l[n]/=t.length}return s}(l,r):i===ft.SIMILARITY?await async function(t,e,n){const i=e.columns.toList();return await(0,bt.uL)(i,t,n)}(l,r,o):null;if(null===c)throw new Error(`In bio library: Unknown sequence scoring method: ${i}`);return c.name=t.columns.getUnusedName(c.name),t.columns.add(c),c}(t,e,n,i,o);for(let t=0;t<r.length;t++)e.isNone(t)&&r.set(t,null,!1);return r}var yi=n(294),bi=n(330);const vi=OCL;var wi=n(9099);class Ci{monomerSymbol;constructor(t){this.monomerSymbol=t}atoms;bonds;rGroups;get atomCount(){return this.atoms.count}get bondCount(){return this.bonds.count}shiftR1GroupToOrigin(){const t=this.rGroups.getAtomicIdx(1);if(null===t)return;const{x:e,y:n}=this.atoms.atomCoordinates[t];this.atoms.shift({x:-e,y:-n})}alignR2AlongX(){const t=this.rGroups.getAtomicIdx(2);if(null===t)throw new Error(`Cannot find R2 group for monomer ${this.monomerSymbol}`);const e=this.atoms.atomCoordinates[t],n=e.y/e.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(t){this.rGroups.deleteBondLineWithSpecifiedRGroup(t)}shiftCoordinates(t){this.atoms.shift(t)}rotateCoordinates(t){this.atoms.rotate(t)}getBondLines(){return this.bonds.getBondLines()}getAtomLines(){return this.atoms.atomLines}removeRGroups(t){this.rGroups.removeRGroups(t)}replaceRGroupWithAttachmentAtom(t,e){this.rGroups.replaceRGroupWithAttachmentAtom(t,e)}getAttachmentAtomByRGroupId(t){return this.rGroups.getAttachmentAtomIdByRGroupId(t)}shiftBonds(t){this.bonds.shift(t)}capRGroups(t){this.rGroups.capRGroups(t)}}var Ai=n(6956);class Si{atoms;bonds;constructor(t,e,n){this.atoms=e,this.bonds=n,this.rGroupIdToAtomicIndexMap=t.getRGroupIdToAtomicIdxMap()}rGroupIdToAtomicIndexMap;rGroupBondPositionMap=new Map;getAtomicIdx(t){const e=this.rGroupIdToAtomicIndexMap.get(t);return void 0===e?null:e}removeRGroupsFromAtomBlock(t){t.forEach((t=>{if(void 0===this.rGroupIdToAtomicIndexMap.get(t))throw new Error(`Cannot find atomic index for R group ${t}`)}));const e=Array.from(this.rGroupIdToAtomicIndexMap.entries()).filter((([e,n])=>t.includes(e))).map((([t,e])=>e));this.atoms.deleteAtoms(e)}removeRGroups(t){this.removeRGroupsFromAtomBlock(t),t.forEach((t=>{const e=this.replaceRGroupInBondsByDummy(t);this.rGroupBondPositionMap.set(t,e)}))}replaceRGroupInBondsByDummy(t){const e=this.rGroupIdToAtomicIndexMap.get(t);if(this.rGroupBondPositionMap.has(t))throw new Error(`R group ${t} is already handled`);const n=this.bonds.getPositionsInBonds(e+1);if(0===n.length)throw new Error(`Cannot find position for R group ${t}`);if(n.length>1)throw new Error(`More than one position for R group ${t}`);const i=n[0];return this.bonds.replacePositionsInBondsByDummy([i]),this.bonds.removeAtomIdFromBonds(e+1),this.removeRGroupFromAtomicIdxMap(t,e),i}removeRGroupFromAtomicIdxMap(t,e){this.rGroupIdToAtomicIndexMap.delete(t);for(const[t,n]of this.rGroupIdToAtomicIndexMap)n>e&&this.rGroupIdToAtomicIndexMap.set(t,n-1)}deleteBondLineWithSpecifiedRGroup(t){const e=this.rGroupBondPositionMap.get(t);if(!e)throw new Error(`Cannot find position for R group ${t}`);const{bondLineIdx:n}=e;this.bonds.deleteBondLines([n]),this.rGroupBondPositionMap.delete(t),this.rGroupIdToAtomicIndexMap.delete(t),this.rGroupBondPositionMap.forEach((t=>{t.bondLineIdx>n&&(t.bondLineIdx-=1)}))}replaceRGroupWithAttachmentAtom(t,e){const n=this.rGroupBondPositionMap.get(t);if(!n)throw new Error(`Cannot find position for R group ${t}`);const{bondLineIdx:i,nodeIdx:o}=n;this.bonds.bondedAtoms[i][o]=e}getAttachmentAtomIdByRGroupId(t){const e=this.rGroupBondPositionMap.get(t);if(!e)throw new Error(`Cannot find position for R group ${t}`);const{bondLineIdx:n,nodeIdx:i}=e;return this.bonds.bondedAtoms[n][(i+1)%2]}capRGroups(t){this.rGroupIdToAtomicIndexMap.forEach(((e,n)=>{const i=t[n-1];i===Ai.mP?(this.removeRGroups([n]),this.deleteBondLineWithSpecifiedRGroup(n)):this.atoms.replaceRGroupSymbolByElement(e,i)}))}}class xi{coordinates=[];rawAtomLines=[];get count(){return this.coordinates.length}get atomCoordinates(){return this.coordinates}replaceRGroupSymbolByElement(t,e){this.rawAtomLines[t]=this.rawAtomLines[t].replace("R#",e)}deleteAtoms(t){this.coordinates=this.coordinates.filter(((e,n)=>!t.includes(n))),this.rawAtomLines=this.rawAtomLines.filter(((e,n)=>!t.includes(n)))}shift(t){this.coordinates=this.coordinates.map((e=>{const n=e.x+t.x,i=e.y+t.y;if(isNaN(n)||isNaN(i))throw new Error(`Cannot shift coordinates by ${t.x}, ${t.y}`);return{x:n,y:i}}))}rotate(t){this.coordinates=this.coordinates.map((e=>{const n=e.x,i=e.y,o=n*Math.cos(t)-i*Math.sin(t),r=n*Math.sin(t)+i*Math.cos(t);if(isNaN(o)||isNaN(r))throw new Error(`Cannot rotate coordinates by ${t}`);return{x:o,y:r}}))}}class Ei extends xi{constructor(t){super(),this.rawAtomLines=t.getAtomLines(),this.coordinates=this.rawAtomLines.map((t=>({x:parseFloat(t.substring(0,10)),y:parseFloat(t.substring(10,20))})))}get atomLines(){return this.rawAtomLines.map(((t,e)=>{const n=this.coordinates[e];return`${n.x.toFixed(4).padStart(10," ")}${n.y.toFixed(4).padStart(10," ")}${t.substring(20)}`}))}}class Mi{bondedAtomPairs=[];rawBondLines=[];get count(){return this.bondedAtomPairs.length}get bondedAtoms(){return this.bondedAtomPairs}deleteBondLines(t){this.rawBondLines=this.rawBondLines.filter(((e,n)=>!t.includes(n))),this.bondedAtomPairs=this.bondedAtomPairs.filter(((e,n)=>!t.includes(n)))}getPositionsInBonds(t){const e=[];return this.bondedAtomPairs.forEach(((n,i)=>{n.forEach(((n,o)=>{n===t&&e.push({bondLineIdx:i,nodeIdx:o})}))})),e}replacePositionsInBondsByDummy(t,e){void 0===e&&(e=-1),t.forEach((t=>{const{bondLineIdx:n,nodeIdx:i}=t;this.bondedAtomPairs[n][i]=e}))}removeAtomIdFromBonds(t){this.bondedAtomPairs=this.bondedAtomPairs.map((e=>e.map((e=>e>t?e-1:e))))}shift(t){this.bondedAtomPairs=this.bondedAtomPairs.map((e=>e.map((e=>e+t))))}}class Ti extends Mi{constructor(t){super(),this.rawBondLines=t.getBondLines(),this.bondedAtomPairs=this.rawBondLines.map((t=>[parseInt(t.substring(0,3)),parseInt(t.substring(3,6))]))}getBondLines(){return this.bondedAtomPairs.map(((t,e)=>{if(t.some((t=>-1===t)))throw new Error(`Bonded pair ${t} contains -1`);return`${t[0].toString().padStart(3," ")}${t[1].toString().padStart(3," ")}${this.rawBondLines[e].substring(6)}`}))}}class _i extends Ci{constructor(t,e){super(e);const n=$e.getInstance(t);this.atoms=new Ei(n),this.bonds=new Ti(n),this.rGroups=new Si(n,this.atoms,this.bonds),this.shiftMonomerToDefaultPosition()}}class Ii extends xi{molfileHandler;constructor(t){super(),this.molfileHandler=t,this.rawAtomLines=t.getAtomLines(),this.coordinates=this.getCoordinates()}getCoordinates(){const t=this.molfileHandler.x,e=this.molfileHandler.y;return Array.from(t).map(((t,n)=>({x:t,y:e[n]})))}get atomLines(){const t=/^(M V30 [^-]*)(-?\d+\.\d+)( )(-?\d+\.\d+)( -?\d+\.\d+.*)$/,e=/\sRGROUPS=\(\d+(\s+\d+)*\)/;return this.rawAtomLines.map(((n,i)=>{const o=this.coordinates[i],r=o.x.toFixed(4)+"00",s=o.y.toFixed(4)+"00";return n.replace(t,((t,e,n,i,o,a)=>e+r+i+s+a)).replace(e,"")}))}replaceRGroupSymbolByElement(t,e){super.replaceRGroupSymbolByElement(t,e);const n=this.rawAtomLines[t].substring(3).split(" ");n.length>7&&(this.rawAtomLines[t]=`M ${n.slice(0,7).join(" ")}`)}}class Li extends Mi{molfileHandler;constructor(t){super(),this.molfileHandler=t,this.rawBondLines=t.getBondLines(),this.bondedAtomPairs=this.getBondedAtomPairs()}getBondedAtomPairs(){return this.molfileHandler.pairsOfBondedAtoms.map((t=>[t[0],t[1]]))}getBondLines(){const t=/^(M\s+V30\s+\d+\s+\d+\s+)(\d+)(\s+)(\d+)(.*)$/;return this.bondedAtomPairs.map(((e,n)=>{if(e.some((t=>-1===t)))throw new Error(`Bonded pair ${e} contains -1`);return this.rawBondLines[n].replace(t,((t,n,i,o,r,s)=>`${n}${e[0]}${o}${e[1]}${s}`))}))}}class Ni extends Ci{constructor(t,e){super(e);const n=$e.getInstance(t);this.atoms=new Ii(n),this.bonds=new Li(n),this.rGroups=new Si(n,this.atoms,this.bonds),this.shiftMonomerToDefaultPosition()}}class Pi{static getInstance(t,e){if($e.isMolfileV2K(t))return new _i(t,e);if($e.isMolfileV3K(t))return new Ni(t,e);throw new Error("Unsupported molfile version")}}class $i{monomerSymbol;monomerIdx;helm;monomerLib;molfileWrapper;capGroupElements=[];static molfileV2KToV3KCache=new Map;constructor(t,e,n,i,o,r){this.monomerSymbol=t,this.monomerIdx=e,this.helm=n,this.monomerLib=r;const s=this.getLibraryMonomerObject();let a=s.molfile;$e.isMolfileV2K(a)&&(a=this.convertMolfileToV3KFormat(a,t,o)),this.molfileWrapper=Pi.getInstance(a,t),this.capGroupElements=this.getCapGroupElements(s),this.removeRGroups(n.bondedRGroupsMap[e]),this.capRemainingRGroups(),this.shiftCoordinates(i)}get atomCount(){return this.molfileWrapper.atomCount}get bondCount(){return this.molfileWrapper.bondCount}convertMolfileToV3KFormat(t,e,n){if($i.molfileV2KToV3KCache.has(t))return $i.molfileV2KToV3KCache.get(t);let i=null;try{if(i=n.get_mol(t,JSON.stringify({mergeQueryHs:!0})),i){const e=i.get_v3Kmolblock();return $i.molfileV2KToV3KCache.set(t,e),e}throw new Error(`Cannot convert ${e} to molV3000`)}finally{i?.delete()}}getLibraryMonomerObject(){const t=this.helm.getPolymerTypeByMonomerIdx(this.monomerIdx),e=this.monomerLib.getMonomer(t,this.monomerSymbol);if(!e)throw new Error(`Monomer ${this.monomerSymbol} is not found in the library`);return e}getCapGroupElements(t){return t.rgroups.map((t=>(t.capGroupSmiles||t.capGroupSMILES).replace(/(\[|\]|\*|:|\d)/g,"")))}shiftCoordinates(t){this.molfileWrapper.shiftCoordinates(t)}getAtomLines(){return this.molfileWrapper.getAtomLines()}getBondLines(){return this.molfileWrapper.getBondLines()}removeRGroups(t){this.molfileWrapper.removeRGroups(t)}capRemainingRGroups(){this.molfileWrapper.capRGroups(this.capGroupElements)}replaceRGroupWithAttachmentAtom(t,e){this.molfileWrapper.replaceRGroupWithAttachmentAtom(t,e)}getAttachmentAtomByRGroupId(t){return this.molfileWrapper.getAttachmentAtomByRGroupId(t)}deleteBondLineWithSpecifiedRGroup(t){this.molfileWrapper.deleteBondLineWithSpecifiedRGroup(t)}shiftBonds(t){this.molfileWrapper.shiftBonds(t)}}class Ri{rdKitModule;monomerLib;constructor(t,e,n){this.rdKitModule=e,this.monomerLib=n,this.helm=new wi.f(t)}monomerWrappers=[];helm;addMonomer(t,e,n){if(t===wt.b9[gt.Hi.HELM])return;const i=this.monomerWrappers.length,o=new $i(t,i,this.helm,n,this.rdKitModule,this.monomerLib);this.monomerWrappers.push(o)}getAtomNumberShifts(){const t=[];let e=0;return this.monomerWrappers.forEach((n=>{t.push(e),e+=n.getAtomLines().length})),t}restoreBondsBetweenMonomers(){this.helm.bondData.forEach((t=>{const e=t.map((t=>t.monomerIdx)),n=t.map((t=>t.rGroupId)),i=e.map((t=>this.monomerWrappers[t])),o=i[1].getAttachmentAtomByRGroupId(n[1]);i[0].replaceRGroupWithAttachmentAtom(n[0],o),i[1].deleteBondLineWithSpecifiedRGroup(n[1])}))}compileToMolfile(){const t=[],e=[],n=this.getAtomNumberShifts();this.monomerWrappers.forEach(((t,e)=>{t.shiftBonds(n[e])})),this.restoreBondsBetweenMonomers();const i=new yi.Cg;for(const[n,o]of ot().enumerate(this.monomerWrappers)){const r=t.length,s=e.length;t.push(...n.getAtomLines()),e.push(...n.getBondLines());const a="RNA"==this.helm.getPolymerTypeByMonomerIdx(o)?Ft.o.NUCLEOTIDE:Ft.o.AA;i.set(o,{biotype:a,symbol:n.monomerSymbol,atoms:ot().count(r).take(n.atomCount).toArray(),bonds:ot().count(s).take(n.bondCount).toArray()})}const o=t.length,r=e.length;return{molfile:[this.getV3KHeader(o,r),this.getV3KAtomBlock(t),this.getV3KBondBlock(e),"M V30 END CTAB\nM END"].join("\n"),monomers:i}}getV3KHeader(t,e){return`\n Datagrok\n\n 0 0 0 0 0 0 0 0 0 0999 V3000\nM V30 BEGIN CTAB\nM V30 COUNTS ${t} ${e} 0 0 1`}getV3KAtomBlock(t){const e=/^(M V30 )(\d+)( .*)$/;return["M V30 BEGIN ATOM",...t.map(((t,n)=>{const i=n+1;return t.replace(e,((t,e,n,o)=>e+i+o))})),"M V30 END ATOM"].join("\n")}getV3KBondBlock(t){const e=/^(M V30 )(\d+)( .*)$/;return["M V30 BEGIN BOND",...t.map(((t,n)=>{const i=n+1;return t.replace(e,((t,e,n,o)=>e+i+o))})),"M V30 END BOND"].join("\n")}}class ki{constructor(t){this.molfileHandler=$e.getInstance(t)}molfileHandler;get monomerSymbols(){return this.molfileHandler.atomTypes}getMonomerShifts(t){return{x:this.molfileHandler.x[t],y:this.molfileHandler.y[t]}}}class Oi{helmHelper;rdKitModule;monomerLib;constructor(t,e,n){this.helmHelper=t,this.rdKitModule=e,this.monomerLib=n}convertToSmiles(t){const e=t.dataFrame,n=this.getSmilesList(t),i=`smiles(${t.name})`,o=e?e.columns.getUnusedName(i):i;return a.Column.fromStrings(o,n.map((t=>null===t?"":t)))}getSmilesList(t){return this.convertToMolfileV3KColumn(t).toList().map((t=>a.chem.convert(t,a.chem.Notation.MolBlock,a.chem.Notation.Smiles)))}molV3KtoMolV3KOCL(t){try{if(!t)return"";return vi.Molecule.fromMolfile(t).toMolfileV3().replace("STERAC1","STEABS")}catch(t){const[e,n]=(0,Ct.AP)(t);return eo.logger.error(e,void 0,n),""}}getMolV3000ViaOCL(t,e){const n=t.map((t=>{if(null===t)return"";const e=t.get_v3Kmolblock();return t.delete(),e})),i=new Array(n.length),o=a.TaskBarProgressIndicator.create("Handling chirality...");for(let t=0;t<n.length;t++){i[t]=this.molV3KtoMolV3KOCL(n[t]);const e=t/n.length*100;o.update(e,`${e?.toFixed(2)}% of molecules completed`)}return o.close(),a.Column.fromStrings(e,i)}convertToRdKitBeautifiedMolfileColumn(t,e,n,i){const o=t.dataFrame,r=this.convertToMolfileV3KColumn(t).toList().map((t=>{if(""===t)return null;const e=n.get_mol(t);return e?(e.set_new_coords(),e.normalize_depiction(1),e.straighten_depiction(!0),e):null})),s=`molfile(${t.name})`,l=o?o.columns.getUnusedName(s):s;return e?this.getMolV3000ViaOCL(r,l):a.Column.fromStrings(l,r.map((t=>{if(null===t)return"";const e=t.get_v3Kmolblock();return t.delete(),e})))}convertToMolfileV3KColumn(t){const e=t.dataFrame,n=this.convertToMolfileV3K(t.toList()).map((t=>t.molfile)),i=(0,bi.kA)(e,`molfileV3K(${t.name})`);return a.Column.fromList("string",i,n)}convertToMolfileV3K(t){const e=new Array(t.length);for(let n=0;n<t.length;++n){const i=t[n];if(!i){e[n]=yi.vF.createEmpty();continue}let o;try{o=this.getPolymerMolfile(i)}catch(t){const[e,n]=(0,Ct.AP)(t);eo.logger.error(e,void 0,n),o=yi.vF.createEmpty()}e[n]=o}return e}getPolymerGraphColumn(t){const e=t.toList(),n=this.helmHelper.getMolfiles(e);return a.Column.fromStrings("mols",n)}getPolymerMolfile(t){const e=this.helmHelper.removeGaps(t),n=e.resHelm,i=new Map;for(const[t,n]of e.monomerMap?.entries()??[])i.set(n,t);const o=this.helmHelper.getMolfiles([n])[0],r=new ki(o),s=new Ri(n,this.rdKitModule,this.monomerLib);r.monomerSymbols.forEach(((t,e)=>{const n=r.getMonomerShifts(e);s.addMonomer(t,e,n)}));const a=s.compileToMolfile(),l=new yi.Cg;for(const[t,e]of a.monomers.entries()){const n=i.get(t);l.set(n,e)}return new yi.vF(a.molfile,l)}}class Hi{seqHelper;_column;_units;_notation;_defaultGapOriginal;notationProvider;_splitter=null;constructor(t,e){if(this.seqHelper=e,t.type!==a.TYPE.STRING)throw new Error(`Unexpected column type '${t.type}', must be '${a.TYPE.STRING}'.`);this._column=t;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[Ut.notationProvider]??null);const i=this.isFasta()?wt.b9[gt.Hi.FASTA]:this.isSeparator()?wt.b9[gt.Hi.SEPARATOR]:this.isHelm()?wt.b9[gt.Hi.HELM]:this.isCustom()?this.notationProvider?.defaultGapOriginal??wt.b9[gt.Hi.SEPARATOR]:void 0;if(null==i)throw new Error(`Unexpected defaultGapOriginal for notation '${this.notation}'`);if(this._defaultGapOriginal=i,!this.column.tags.has(gt.gp.aligned)||!this.column.tags.has(gt.gp.alphabet)||!this.column.tags.has(gt.gp.alphabetIsMultichar)&&!this.isHelm()&&this.alphabet===gt.YI.UN)if(this.isFasta())this.seqHelper.setUnitsToFastaColumn(this);else if(this.isSeparator()){const e=t.getTag(gt.gp.separator);this.seqHelper.setUnitsToSeparatorColumn(this,e)}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(gt.gp.alphabetIsMultichar))if(this.isHelm())this.column.setTag(gt.gp.alphabetIsMultichar,"true");else if(["UN"].includes(this.alphabet))throw new Error(`For column '${this.column.name}' of alphabet '${this.alphabet}' tag '${gt.gp.alphabetIsMultichar}' is mandatory.`);this.columnVersion=this.column.version,!this.isSeparator()||this.isCustom()&&this.notationProvider||t.temp.seqHandlerRefined||(this.refineSeparatorNotation(),t.temp.seqHandlerRefined=!0)}async refineSeparatorNotation(){const t=((t,e,n)=>{const i={};let o=!0,r=null;for(const e of t){const t=e?n(e):[];if(null===r?r=t.length:t.length!==r&&(o=!1),t.length>=3)for(const e of t)e in i||(i[e]=0),i[e]+=1}return{freq:i,sameLength:o}})([...new Set((this.column.length<100?ot().count(0).take(Math.min(100,this.column.length)).map((t=>this.column.get(t))):this.column.categories.slice(0,100)).map((t=>t?t.substring(0,500):"")).filter((t=>0!==t.length)))],0,(t=>t.split(this.separator)));let e=!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:t,separator:this.separator}),r=(await o.call()).getOutputParamValue();e||=r}catch(t){console.error(t)}e&&(delete this.column.temp[Ut.seqHandler],this.column.fireValuesChanged())}static setTags(t){const e=t.column.meta.units;if([gt.Hi.FASTA,gt.Hi.SEPARATOR].includes(e)){if(!t.column.getTag(gt.gp.alphabet)&&0===Object.keys(t.stats.freq).length)throw new Error("Alphabet is empty and not annotated.");let e=t.column.getTag(gt.gp.aligned);null===e&&(e=t.stats.sameLength?"SEQ.MSA":"SEQ",t.column.setTag(gt.gp.aligned,e));let n=t.column.getTag(gt.gp.alphabet);if(null===n&&(n=(0,Ot.pc)(t.stats.freq,gt.q7),t.column.setTag(gt.gp.alphabet,n)),n===gt.YI.UN){const e=Object.keys(t.stats.freq).length,n=Object.keys(t.stats.freq).some((t=>t.length>1));t.column.setTag(gt.gp.alphabetSize,e.toString()),t.column.setTag(gt.gp.alphabetIsMultichar,n?"true":"false")}}else if(e===gt.Hi.HELM){let e=t.column.getTag(gt.gp.alphabet);null===e&&(e=(0,Ot.p0)(t.stats.freq,gt.q7,t.defaultGapOriginal),t.column.setTag(gt.gp.alphabet,e))}}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 t=this.column.getTag(gt.gp.separator)??void 0;if(this.notation===gt.Hi.SEPARATOR&&void 0===t)throw new Error(`Separator is mandatory for column '${this.column.name}' of notation '${this.notation}'.`);return t}get aligned(){const t=this.column.getTag(gt.gp.aligned);if(!t&&(this.isFasta()||this.isSeparator()))throw new Error("Tag aligned not set");return t}get alphabet(){const t=this.column.getTag(gt.gp.alphabet);if(!t&&(this.isFasta()||this.isSeparator()))throw new Error("Tag alphabet not set");return t}get defaultBiotype(){return this.alphabet===gt.YI.RNA||this.alphabet===gt.YI.DNA?Ft.o.NUCLEOTIDE:Ft.o.AA}get helmCompatible(){return this.column.getTag(gt.gp.isHelmCompatible)}getAlphabetSize(){if(this.notation==gt.Hi.HELM||this.alphabet==gt.YI.UN){const t=this.column.getTag(gt.gp.alphabetSize);let e;if(t)e=parseInt(t);else{const t=this.stats;e=Object.keys(t.freq).length}return e}switch(this.alphabet){case gt.YI.PT:return 20;case gt.YI.DNA:case gt.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===gt.Hi.HELM||this.alphabet===gt.YI.UN&&"true"===this.column.getTag(gt.gp.alphabetIsMultichar)}cached=!0;_splitted=null;columnVersion=null;getSplitted(t,e){if(this.cached&&void 0===e){this.column.version===this.columnVersion&&null!==this._splitted||(this.columnVersion=this.column.version,this._splitted=new Array(this.column.length));let e=this._splitted[t]?this._splitted[t].deref():void 0;if(!e){const n=this.column.get(t);e=this.splitter(n),this._splitted[t]=new WeakRef(e)}return e}{const n=this.column.get(t);return this.getSplitter(e)(n)}}getMonomerAtPosition(t,e,n){if(this.isCanonicalAlphabet&&this.isFasta()&&!this.getAlphabetIsMultichar()){const i=(this.column.get(t)??"")[e];return n?i===wt.b9[gt.Hi.FASTA]?wt._S:i??wt._S:i??""}const i=this.getSplitted(t);return e<0||e>=i.length?this.defaultGapOriginal:n?i.getCanonical(e):i.getOriginal(e)}getMonomersAtPosition(t,e){const n=this.column.length,i=new Array(n).fill(wt._S);if(this.isCanonicalAlphabet&&this.isFasta()&&!this.getAlphabetIsMultichar()){const o=this.column.categories,r=this.column.getRawData();for(let s=0;s<n;s++){const n=o[r[s]]??"";if(t<n.length){const o=n[t];i[s]=e?o===wt.b9[gt.Hi.FASTA]?wt._S:o??wt._S:o??""}}}else for(let o=0;o<n;o++){const n=this.getSplitted(o);t>=0&&t<n.length&&(i[o]=e?n.getCanonical(t):n.getOriginal(t))}return i}getValue(t,e){return this.column.get(t),new jt(t,this)}getHelm(t){let e;const n=this.column.get(t);return e=this.notation===gt.Hi.HELM?n:this.notation===gt.Hi.CUSTOM?this.notationProvider.getHelm(n,{}):this.getConverter(gt.Hi.HELM)(n),e}_stats=null;get isCanonicalAlphabet(){const t=this.alphabet;return t===gt.YI.DNA||t===gt.YI.RNA||t===gt.YI.PT}get stats(){if(null===this._stats){const t={};let e=!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&&(e=!1);for(let e=0;e<i.length;++e){const n=i.getCanonical(e);n in t||(t[n]=0),t[n]+=1}}this._stats={freq:t,sameLength:e}}return this._stats}_maxLength=null;get maxLength(){return null===this._maxLength&&(this._maxLength=0===this.column.length?0:ot().count(0).take(this.column.length).map((t=>this.getSplitted(t).length)).reduce(((t,e)=>t>e?t:e),0)),this._maxLength}_posList=null;get posList(){if(null===this._posList){const t=this.column.getTag(gt.gp.positionNames);this._posList=t?t.split(gt.z1).map((t=>t.trim())):ot().count(1).take(this.maxLength).map((t=>t.toString())).toArray()}return this._posList}isFasta(){return this.notation===gt.Hi.FASTA}isSeparator(){return this.notation===gt.Hi.SEPARATOR||!!this.separator}isFastaOrSeparator(){return this.isFasta()||this.isSeparator()}isHelm(){return this.notation===gt.Hi.HELM}isCustom(){return this.notation===gt.Hi.CUSTOM}isRna(){return this.alphabet===gt.YI.RNA}isDna(){return this.alphabet===gt.YI.DNA}isPeptide(){return this.alphabet===gt.YI.PT}isMsa(){return!!this.aligned&&this.aligned.toUpperCase().includes("MSA")}isHelmCompatible(){return"true"===this.helmCompatible}isGap(t){return!t||t===this._defaultGapOriginal}getNotation(){if(this.units.toLowerCase().startsWith(gt.Hi.FASTA))return gt.Hi.FASTA;if(this.units.toLowerCase().startsWith(gt.Hi.SEPARATOR))return gt.Hi.SEPARATOR;if(this.units.toLowerCase().startsWith(gt.Hi.HELM))return gt.Hi.HELM;if(this.units.toLowerCase().startsWith(gt.Hi.CUSTOM))return gt.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(t,e,n,i){const o=this.column,r=t.toLowerCase()+"("+o.name+")",s=n??o.dataFrame?.columns.getUnusedName(r)??r,l=a.Column.fromList("string",s,i??new Array(this.column.length).fill(""));if(l.semType=a.SEMTYPE.MACROMOLECULE,l.meta.units=t,t===gt.Hi.SEPARATOR){if(!e)throw new Error(`Notation '${gt.Hi.SEPARATOR}' requires separator value.`);l.setTag(gt.gp.separator,e)}l.setTag(a.TAGS.CELL_RENDERER,t===gt.Hi.HELM?"helm":"sequence");const c=o.getTag(gt.gp.aligned);c&&l.setTag(gt.gp.aligned,c);let h=o.getTag(gt.gp.alphabet);h||this.notation!==gt.Hi.HELM||t===gt.Hi.HELM||(h=gt.YI.UN),null!=h&&l.setTag(gt.gp.alphabet,h);let u=o.getTag(gt.gp.alphabetSize);null!=h&&u&&l.setTag(gt.gp.alphabetSize,u);const d=o.getTag(gt.gp.alphabetIsMultichar);return null!=h&&void 0!==d&&l.setTag(gt.gp.alphabetIsMultichar,d),t==gt.Hi.HELM&&(u=this.getAlphabetSize().toString(),l.setTag(gt.gp.alphabetSize,u)),l}getNewColumnFromList(t,e){return this.getNewColumn(this.notation,this.separator,t,e)}static unitsStringIsValid(t){return t=t.toLowerCase(),[gt.Hi.FASTA,gt.Hi.SEPARATOR,gt.Hi.HELM].some((e=>t.startsWith(e.toLowerCase())))}static getNewColumnFromParams(t,e,n){if(!Hi.unitsStringIsValid(n))throw new Error("Invalid format of 'units' parameter");const i=a.Column.fromList("string",e,new Array(t).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(t){let e=null;if(e=this.notationProvider?this.notationProvider.splitter:null,e)return e;if(this.units.toLowerCase().startsWith(gt.Hi.FASTA))return null===this.column.getTag(gt.gp.alphabet)||this.getAlphabetIsMultichar()?gt.J9:Ot.tm;if(this.units.toLowerCase().startsWith(gt.Hi.SEPARATOR))return(0,gt.dh)(this.separator,t);if(this.units.toLowerCase().startsWith(gt.Hi.HELM))return gt.qp;throw new Error(`Unexpected units ${this.units} .`)}split(t){return this.splitter(t)}getDistanceFunctionName(){if(!this.isFasta())throw new Error("Only FASTA notation is supported");if(this.isMsa())return ue.Z.HAMMING;switch(this.alphabet){case gt.YI.DNA:case gt.YI.RNA:case gt.YI.PT:}return ue.Z.LEVENSHTEIN}getDistanceFunction(){return ue.V[this.getDistanceFunctionName()]()}async checkHelmCompatibility(){if(this.column.tags.has(gt.gp.isHelmCompatible))return"true"===this.column.getTag(gt.gp.isHelmCompatible);const t=(await(0,bt.pj)()).getMonomerLib().getMonomerSymbolsByType("PEPTIDE"),e=new Set(t),n=((0,gt.dh)(this.separator),new Set),i=this.column.length,o=this.column.getRawData();for(let t=0;t<i;++t){const i=o[t];if(!(i in n)){n.add(i);const o=this.getSplitted(t);for(let t=0;t<o.length;++t){const n=o.getCanonical(t);if(!e.has(n))return this.column.setTag(gt.gp.isHelmCompatible,"false"),!1}}}return this.column.setTag(gt.gp.isHelmCompatible,"true"),!0}toFasta(t){return t===gt.Hi.FASTA}toSeparator(t){return t===gt.Hi.SEPARATOR}toHelm(t){return t===gt.Hi.HELM}convertHelmToFastaSeparator(t,e,n,i){i||(i=this.toFasta(e)?wt.b9[gt.Hi.FASTA]:wt.b9[gt.Hi.SEPARATOR]),n||(n=this.toFasta(e)?"":this.separator);const o=t.startsWith("RNA"),r=(0,gt.qp)(t),s=[];for(let t=0;t<r.length;++t){let n=r.getOriginal(t);if(o&&(n=n.replace(yn.EK,"$1")),n===wt.b9[gt.Hi.HELM])s.push(i);else if(this.toFasta(e)&&n.length>1){const t="["+n+"]";s.push(t)}else s.push(n)}return s.join(n)}convert(t,e){const n=this.getJoiner({notation:t,separator:e}),i=this.getNewColumn(t,e);return i.init((t=>{const e=this.getSplitted(t);return n(e)})),i}getRegion(t,e,n){const i=this.getNewColumn(this.notation,this.separator);i.name=n;const o=t??0,r=e??this.maxLength-1,s=this.getJoiner(),a=r-o+1,l=wt.b9[this.notation];i.init((t=>{const e=this.getSplitted(t),n=new Array(a);for(let t=0;t<a;++t){const i=o+t;n[t]=i<e.length?e.getOriginal(i):l}return s(new Ot.Mu(n,l))}));const c=t=>{const e=t.split(",").map((t=>t.trim())),n=new Array(a);for(let t=0;t<a;++t){const i=o+t;n[t]=i<e.length?e[i]:"?"}return n.join(gt.z1)},h=this.column.getTag(gt.gp.positionNames);h&&i.setTag(gt.gp.positionNames,c(h));const u=this.column.getTag(gt.gp.positionLabels);return u&&i.setTag(gt.gp.positionLabels,c(u)),i}_joiner=void 0;get joiner(){return this._joiner||(this._joiner=this.getJoiner()),this._joiner}getJoiner(t){const e=t?t.notation:this.notation,n=t?t.separator:this.separator;let i;const o=this;switch(e){case gt.Hi.FASTA:i=function(t){return o.joinToFasta(t,o.isHelm())};break;case gt.Hi.SEPARATOR:if(!n)throw new Error(`Separator is mandatory for notation '${e}'.`);i=function(t){return Gi(t,n,o.isHelm())};break;case gt.Hi.HELM:{const t=o.alphabet===gt.YI.DNA||o.alphabet===gt.YI.RNA,e=o.getHelmWrappers();i=function(n){return Fi(n,e,t)};break}default:throw new Error(`Unexpected notation '${e}'.`)}return i}getConverter(t,e=void 0){if(t===gt.Hi.SEPARATOR&&!e)throw new Error(`Target separator is not specified for target units '${gt.Hi.SEPARATOR}'.`);const n=this;if(t===gt.Hi.FASTA)return function(t){return n.convertToFasta(t)};if(t===gt.Hi.HELM)return function(t){return n.convertToHelm(t)};if(t===gt.Hi.SEPARATOR)return function(t){return n.convertToSeparator(t,e)};throw new Error}static forColumn(t,e){let n=t.temp[Ut.seqHandler];return n&&n.columnVersion===t.version||(n=t.temp[Ut.seqHandler]=new Hi(t,e)),n}joinToFasta(t,e){const n=new Array(t.length);for(let i=0;i<t.length;++i){const o=t.getOriginal(i);let r=t.getOriginal(i);e&&(r=r.replace(yn.EK,"$1")),o===wt._S?r=wt.b9[gt.Hi.FASTA]:o===yn.q7?r="":r.length>1&&(r="["+r+"]"),n[i]=r}return n.join("")}convertToFasta(t){const e=this.splitter,n=this.isHelm()?this.splitterAsHelmNucl(t):e(t);return this.joinToFasta(n,this.isHelm())}convertToSeparator(t,e){return Gi(this.isHelm()?this.splitterAsHelmNucl(t):this.splitter(t),e,this.isHelm())}convertToHelm(t){if(this.notation==gt.Hi.HELM)return t;const e=this.getHelmWrappers(),n=t.startsWith("DNA")||t.startsWith("RNA");return Fi(this.splitter(t),e,n)}splitterAsHelmNucl(t){const e=this.splitter(t),n=new Array(e.length),i=t.startsWith("DNA"),o=t.startsWith("RNA");for(let t=0;t<e.length;++t){let r=e.getOriginal(t);(i||o)&&(r=r.replace(yn.EK,"$1"),r=r===yn.q7?null:r),n[t]=r||null}return new Ot.Mu(n.filter((t=>!!t)),wt.b9[gt.Hi.HELM])}getRendererBack(t,e){const n=this.column.temp;let i=n.rendererBack;return i||(i=n.rendererBack=this.notationProvider.createCellRendererBack(t,e)),i}}function Gi(t,e,n){const i=new Array(t.length);for(let e=0;e<t.length;++e){const o=t.getCanonical(e);let r=t.getOriginal(e);n&&(r=r.replace(yn.EK,"$1")),o===wt._S?r=wt.b9[gt.Hi.SEPARATOR]:o===yn.q7&&(r=""),i[e]=r}return i.join(e)}function Fi(t,e,n){const[i,o,r,s]=e,a=new Array(t.length);for(let e=0;e<t.length;++e){const i=t.getCanonical(e);let s=t.getOriginal(e);i===wt._S?s=wt.b9[gt.Hi.HELM]:(n&&(s=s.replace(yn.EK,"$1")),s=1===s.length?`${o}${s}${r}`:`${o}[${s}]${r}`),a[e]=s}return`${i}${a.join(".")}${s}`}class Bi{libHelper;rdKitModule;constructor(t,e){this.libHelper=t,this.rdKitModule=e}getSeqHandler(t){return Hi.forColumn(t,this)}getSeqMonomers(t){const e=this.getSeqHandler(t);return Object.keys(e.stats.freq)}async getHelmToMolfileConverter(t){const e=await(0,ke.b2)();return new Oi(e,this.rdKitModule,t)}helmToAtomicLevelSingle(t,e,n,i=!0){if(!t)return yi.vF.createEmpty();const o=e.convertToMolfileV3K([t])[0];if(!o||!o.molfile)return yi.vF.createEmpty();let r=null;try{let t=o.molfile;if(i){if(r=this.rdKitModule.get_mol(t),!r)return yi.vF.createEmpty();r.set_new_coords(),r.normalize_depiction(1),r.straighten_depiction(!0),t=r.get_v3Kmolblock()}return n&&(t=e.molV3KtoMolV3KOCL(t)),new yi.vF(t,o.monomers)}catch(t){const[e,n]=(0,Ct.AP)(t);return eo.logger.error(e,void 0,n),yi.vF.createEmpty()}finally{r?.delete()}}async helmToAtomicLevel(t,e,n,i){const o=i??this.libHelper.getMonomerLib(),s=t.dataFrame,l=(0,bi.qj)(s,t.name),c=await this.getHelmToMolfileConverter(o),h=t.toList(),u=new Array(t.length),d=a.Func.find({package:"Chem",name:"beautifyMols"})[0],p=a.Func.find({package:"Chem",name:"convertToV3KViaOCL"})[0];for(let n=0;n<t.length;n++)u[n]=this.helmToAtomicLevelSingle(h[n],c,e&&!p,!d).molfile;if(d){const e=await d.apply({mols:u});if(e&&Array.isArray(e)&&e.length===t.length)for(let n=0;n<t.length;n++)e[n]&&(u[n]=e[n])}if(e&&p){const e=await p.apply({mols:u});if(e&&Array.isArray(e)&&e.length===t.length)for(let n=0;n<t.length;n++)e[n]&&(u[n]=e[n]);else r.shell.warning("OCL function returned an unexpected result")}const m=a.Column.fromStrings(l,u);return m.semType=a.SEMTYPE.MOLECULE,m.meta.units=a.UNITS.Molecule.MOLBLOCK,m.setTag(".sequence-src-col",t.name),{molCol:m,warnings:[]}}setUnitsToFastaColumn(t){if(t.column.semType!==a.SEMTYPE.MACROMOLECULE||t.column.meta.units!==gt.Hi.FASTA)throw new Error(`The column of notation '${gt.Hi.FASTA}' must be '${a.SEMTYPE.MACROMOLECULE}'.`);t.column.meta.units=gt.Hi.FASTA,Hi.setTags(t)}setUnitsToSeparatorColumn(t,e){if(t.column.semType!==a.SEMTYPE.MACROMOLECULE||t.column.meta.units!==gt.Hi.SEPARATOR)throw new Error(`The column of notation '${gt.Hi.SEPARATOR}' must be '${a.SEMTYPE.MACROMOLECULE}'.`);if(!e)throw new Error(`The column of notation '${gt.Hi.SEPARATOR}' must have the separator tag.`);t.column.meta.units=gt.Hi.SEPARATOR,t.column.setTag(gt.gp.separator,e),Hi.setTags(t)}setUnitsToHelmColumn(t){if(t.column.semType!==a.SEMTYPE.MACROMOLECULE)throw new Error(`The column of notation '${gt.Hi.HELM}' must be '${a.SEMTYPE.MACROMOLECULE}'`);t.column.meta.units=gt.Hi.HELM,Hi.setTags(t)}}async function Di(t){let e="";try{if(!t||!t.value)return e="No sequence provided",{errorText:e,mol:""};if(!(t.cell&&t.cell.dart&&t.cell.dataFrame&&t.cell.column))return e="Atomic level conversion requeires a sequence column",{errorText:e,mol:""};if(![gt.Hi.FASTA,gt.Hi.SEPARATOR,gt.Hi.HELM].includes(t.cell.column.meta.units?.toLowerCase()??""))return e="Unsupported sequence notation. please use Bio | Polytool | Convert",{errorText:e,mol:""};const n=(await xr()).getSeqHandler(t.cell.column);if(!n)return e="No sequence handler found",{errorText:e,mol:""};if((n.getSplitted(t.cell.rowIndex,50)?.length??100)>40)return e="Maximum number of monomers is 40",{errorText:e,mol:""};const i=a.Column.fromStrings("singleVal",[t.value]),o=a.DataFrame.fromColumns([i]);if(Object.entries(t.cell.column.tags).forEach((([t,e])=>{i.setTag(t,e)})),await No(o,i,t.cell.column.meta.units===gt.Hi.HELM,!1),o.columns.length<2)return e="No structure generated",{errorText:e,mol:""};const r=o.columns.byIndex(1).get(0);return r?{errorText:"",mol:r}:(e="No structure generated",{errorText:e,mol:""})}catch(t){eo.logger.error(t)}return e="No Structure generated",{errorText:e,mol:""}}const Vi="#333333",Wi="rgba(60, 177, 115, 0.1)",Ui="rgba(240, 240, 240, 0.5)",ji="rgba(100, 100, 100, 0.3)";class qi{constructor(t=Ki.DEFAULT_TRACK_HEIGHT,e=Ki.MIN_TRACK_HEIGHT,n=""){this.ctx=null,this.visible=!0,this.title="",this.tooltipEnabled=!1,this.tooltipContent=null,this.height=t,this.defaultHeight=t,this.minHeight=e,this.title=n}init(t){this.ctx=t}getMonomerAt(t,e,n){return null}enableTooltip(t){this.tooltipEnabled=t}setTooltipContentGenerator(t){this.tooltipContent=t}getTooltipContent(t,e){if(!this.tooltipEnabled||!this.tooltipContent)return null;const n=this.getPositionData(t)??new Map;return this.tooltipContent(t,e,n)}getPositionData(t){return null}setVisible(t){this.visible=t}getHeight(){return this.visible?this.height:0}getDefaultHeight(){return this.defaultHeight}getMinHeight(){return this.minHeight}setHeight(t){this.height=Math.max(this.minHeight,t)}resetHeight(){this.height=this.defaultHeight}isVisible(){return this.visible}setTitle(t){this.title=t}getTitle(){return this.title}}class zi extends qi{constructor(t=new Map,e=Ki.DEFAULT_TRACK_HEIGHT,n="",i="WebLogo"){super(e,Ki.DEFAULT_TRACK_HEIGHT,i),this.data=new Map,this.monomerLib=null,this.biotype="HELM_AA",this.hoveredPosition=-1,this.hoveredMonomer=null,this.data=t,this.visible=t.size>0}setHovered(t,e){this.hoveredPosition=t,this.hoveredMonomer=e}getPositionData(t){return this.data.get(t)||null}setupDefaultTooltip(){this.enableTooltip(!0),this.setTooltipContentGenerator(((t,e,n)=>this.createTooltipContent(t,e,n)))}createFrequencyTable(t){let e;switch(this.biotype){case"HELM_BASE":case"HELM_SUGAR":case"HELM_NUCLETIDE":e=Ft.o.NUCLEOTIDE;break;default:e=Ft.o.AA}const n=Array.from(t.values()).reduce(((t,e)=>t+e),0),i={};for(const[e,o]of t.entries())i[e]=Math.max(1,Math.round(o/n*100));const o=(0,ci.F)(i,e,this.monomerLib);return o.style.fontSize="11px",o.style.marginTop="4px",o}createTooltipContent(t,e,n){const i=[];if(i.push(s.divText(`Position: ${t+1}`,{style:{fontWeight:"bold",marginBottom:"6px",fontSize:"13px"}})),e&&(i.push(s.divText(`Monomer: ${e}`,{style:{marginBottom:"6px",fontSize:"13px"}})),n.has(e)&&i.push(s.divText(`${(100*n.get(e)).toFixed(2)}%`,{style:{marginBottom:"6px",fontSize:"13px"}}))),n&&n.size>0){const t=this.createFrequencyTable(n);i.push(t)}else i.push(s.divText("No data available",{style:{fontStyle:"italic",color:"#666"}}));const o=s.divV(i);return o.style.maxHeight="80vh",o}setMonomerLib(t){this.monomerLib=t}setBiotype(t){this.biotype=t}getMonomerAt(t,e,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=e,r=Array.from(i.entries()).sort(((t,e)=>e[1]-t[1])),s=r.reduce(((t,[e,n])=>t+n),0),a=this.height;let l=0;for(const[t,e]of r){const n=e*a/s;if(o>=l&&o<l+n)return t;l+=n}return null}updateData(t){this.data=t,this.visible=t.size>0}draw(t,e,n,i,o,r,s,a){if(!this.ctx||!this.visible||0===this.data.size)return;const l=Math.floor(n/r),c=i-4,h=e+2;for(let u=0;u<l;u++)this.drawWebLogoColumn(u,t,e,n,i,o,r,s,a,h,c)}drawWebLogoColumn(t,e,n,i,o,r,s,a,l,c,h){const u=r+t-1;if(u<0||u>=a)return;const d=this.data.get(u);if(!d||0===d.size)return;const p=e+t*s,m=s-2;r+t===l&&(this.ctx.fillStyle=Wi,this.ctx.fillRect(p,n,s,o)),this.ctx.fillStyle=Ui,this.ctx.fillRect(p+1,c,m,h),this.drawLettersInColumn(u,p,m,c,h,d),this.drawColumnBorder(p,c,m,h)}drawLettersInColumn(t,e,n,i,o,r){const s=Array.from(r.entries()).sort(((t,e)=>e[1]-t[1])),a=s.reduce(((t,[e,n])=>t+n),0),l=Math.min(1,o/(a*o));let c=i;const h=i+o;for(const[i,r]of s){const s=r*o*l,a=Math.max(4,Math.floor(s));if(a<4)continue;const u=t===this.hoveredPosition&&i===this.hoveredMonomer,d=Math.min(a,h-c);if(d<4)break;this.drawLetter(i,e+1,c,n,d,u),c+=d}}drawColumnBorder(t,e,n,i){this.ctx.strokeStyle=ji,this.ctx.lineWidth=1,this.ctx.strokeRect(t+1,e,n,i)}drawLetter(t,e,n,i,o,r=!1){if(!this.ctx)return;const s=this.getMonomerBackgroundColor(t),a=this.getMonomerTextColor(t);this.ctx.fillStyle=s,this.ctx.fillRect(e,n,i,o),r&&(this.ctx.shadowColor="rgba(255, 255, 255, 0.8)",this.ctx.shadowBlur=8,this.ctx.strokeStyle="white",this.ctx.lineWidth=2,this.ctx.strokeRect(e,n,i,o),this.ctx.shadowBlur=0),this.drawLetterSeparators(e,n,i,o),this.drawLetterText(t,e,n,i,o,a)}drawLetterSeparators(t,e,n,i){this.ctx.strokeStyle="rgba(255, 255, 255, 0.4)",this.ctx.lineWidth=1,e+i<e+this.ctx.canvas.height&&(this.ctx.beginPath(),this.ctx.moveTo(t,e+i),this.ctx.lineTo(t+n,e+i),this.ctx.stroke())}drawLetterText(t,e,n,i,o,r){const s=Math.min(.8*o,.8*i);s>=7&&(this.ctx.fillStyle=r,this.ctx.font=`bold ${s}px Roboto, Roboto Local`,this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillText(t,e+i/2,n+o/2))}getMonomerBackgroundColor(t){if(this.monomerLib)try{const e=this.monomerLib.getMonomerColors(this.biotype,t);if(e&&e.backgroundcolor)return e.backgroundcolor}catch(t){console.warn("Error getting background color from monomerLib:",t)}return"#CCCCCC"}getMonomerTextColor(t){const e=this.getMonomerBackgroundColor(t);try{const t=a.Color.fromHtml(e),n=a.Color.getContrastColor(t);return a.Color.toHtml(n)}catch(t){return console.warn("Error calculating contrast color:",t),"#000000"}}}class Yi extends qi{constructor(t,e=Ki.DEFAULT_TRACK_HEIGHT,n="default",i="Conservation"){super(e,Ki.MIN_TRACK_HEIGHT,i),this.data=t,this.colorScheme=n,this.visible=t.length>0}updateData(t){this.data=t,this.visible=t.length>0}draw(t,e,n,i,o,r,s,a){if(!this.ctx||!this.visible||0===this.data.length)return;const l=Math.floor(n/r);for(let n=0;n<l;n++){const l=o+n;if(l>s)break;const c=t+n*r,h=r,u=c+h/2;l-1<this.data.length&&(this.drawConservationBar(l-1,c,h,u,e,i),l===a&&(this.ctx.fillStyle=Wi,this.ctx.fillRect(c,e,h,i)))}}drawConservationBar(t,e,n,i,o,r){if(!this.ctx)return;const s=this.data[t];this.ctx.fillStyle=Ui,this.ctx.fillRect(e+2,o,n-4,r);let a="#3CB173";if("default"===this.colorScheme)s<.5?a="#E74C3C":s<.75&&(a="#F39C12");else if("rainbow"===this.colorScheme)a=s<.2?"#E74C3C":s<.4?"#FF7F00":s<.6?"#FFFF00":s<.8?"#00FF00":"#0000FF";else if("heatmap"===this.colorScheme){const t=Math.round(255*s);a=`rgb(255, ${t}, ${t})`}const l=s*r;this.ctx.fillStyle=a,this.ctx.fillRect(e+2,o+r-l,n-4,l),this.ctx.strokeStyle=ji,this.ctx.lineWidth=1,this.ctx.strokeRect(e+2,o,n-4,r),n>20&&(this.ctx.fillStyle=Vi,this.ctx.font="9px monospace",this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillText(`${Math.round(100*s)}%`,i,o+r/2))}}const Ki={TITLE_HEIGHT:16,TRACK_GAP:4,DOTTED_CELL_HEIGHT:30,SLIDER_HEIGHT:8,TOP_PADDING:5,DEFAULT_TRACK_HEIGHT:45,MIN_TRACK_HEIGHT:35},Zi={BASE:Ki.DOTTED_CELL_HEIGHT+Ki.SLIDER_HEIGHT,WITH_TITLE:function(){return this.BASE+Ki.TITLE_HEIGHT+Ki.TRACK_GAP},WITH_WEBLOGO:function(){return this.WITH_TITLE()+Ki.DEFAULT_TRACK_HEIGHT+Ki.TRACK_GAP},WITH_BOTH:function(){return this.WITH_WEBLOGO()+Ki.DEFAULT_TRACK_HEIGHT+Ki.TRACK_GAP}};class Xi{constructor(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:t.x||0,y:t.y||0,width:t.width||0,height:t.height||0,windowStartPosition:t.windowStartPosition||1,positionWidth:t.positionWidth||15,totalPositions:t.totalPositions||5e3,headerHeight:t.headerHeight||Zi.BASE,sliderHeight:t.sliderHeight||Ki.SLIDER_HEIGHT,currentPosition:t.currentPosition||1,cellBackground:void 0===t.cellBackground||t.cellBackground,sliderColor:t.sliderColor||"rgba(220, 220, 220, 0.4)",onPositionChange:t.onPositionChange||((t,e)=>{}),onHeaderHeightChange:t.onHeaderHeightChange||(()=>{}),...t},this.eventElement=s.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 t=this.config.headerHeight,e=this.getTrack("weblogo"),n=this.getTrack("conservation");if(this.tracks.forEach((t=>{t.setVisible(!1),t.setHeight(Ki.DEFAULT_TRACK_HEIGHT)})),!(t<Zi.WITH_TITLE()||t<Zi.WITH_WEBLOGO()))if(t<Zi.WITH_BOTH()){if(e){e.setVisible(!0);const n=t-Zi.WITH_WEBLOGO();e.setHeight(Ki.DEFAULT_TRACK_HEIGHT+n)}}else{if(e&&e.setVisible(!0),n&&n.setVisible(!0),e&&t>Zi.WITH_BOTH()){const n=t-Zi.WITH_BOTH();e.setHeight(Ki.DEFAULT_TRACK_HEIGHT+n)}this.userSelectedTracks&&(this.tracks.forEach(((t,e)=>{this.userSelectedTracks[e]||t.setVisible(!1)})),t<Zi.WITH_WEBLOGO()&&e&&e.setVisible(!1),t<Zi.WITH_BOTH()&&n&&n.setVisible(!1))}}drawTrackButtons(){if(!this.ctx||this.config.width<280)return;this.trackButtons=[];const t=this.getTrack("conservation"),e=this.getTrack("weblogo"),n=t?.isVisible()??!1,i=e?.isVisible()??!1;let o=this.config.width-16;const r=this.config.headerHeight>=Zi.WITH_TITLE()?(Ki.TITLE_HEIGHT-14)/2:2;n&&i||(!n&&t&&(o-=70,this.drawTrackButton("conservation","Conservation",o,r,70,14),o-=4),!i&&e&&(o-=70,this.drawTrackButton("weblogo","WebLogo",o,r,70,14)))}drawTrackButton(t,e,n,i,o,r,s=!1){this.ctx&&(this.trackButtons.push({id:t,label:e,x:n,y:i,width:o,height:r}),this.ctx.fillStyle=s?"rgba(100, 150, 200, 0.8)":"rgba(240, 240, 240, 0.8)",this.ctx.fillRect(n,i,o,r),this.ctx.strokeStyle=s?"rgba(70, 120, 170, 0.8)":"rgba(180, 180, 180, 0.8)",this.ctx.lineWidth=1,this.ctx.strokeRect(n,i,o,r),this.ctx.fillStyle=s?"#ffffff":"#666666",this.ctx.font="9px Roboto, Roboto Local",this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillText(e,n+o/2,i+r/2))}handleTrackButtonClick(t,e){for(const n of this.trackButtons)if(t>=n.x&&t<=n.x+n.width&&e>=n.y&&e<=n.y+n.height)return this.snapToTrackHeight(n.id),!0;return!1}snapToTrackHeight(t){let e;if("weblogo"===t)e=Zi.WITH_WEBLOGO();else{if("conservation"!==t)return;e=Zi.WITH_BOTH()}this.userSelectedTracks||(this.userSelectedTracks={},this.tracks.forEach(((t,e)=>{this.userSelectedTracks[e]=!1}))),"conservation"===t?(this.userSelectedTracks.weblogo=!0,this.userSelectedTracks.conservation=!0):"weblogo"===t&&(this.userSelectedTracks.weblogo=!0),this.config.onHeaderHeightChange&&this.config.onHeaderHeightChange(e),window.requestAnimationFrame((()=>this.redraw()))}resetToAutoMode(){this.userSelectedTracks=null;const t=this.tracks.size>0?Zi.WITH_BOTH():Zi.BASE;this.config.onHeaderHeightChange&&this.config.onHeaderHeightChange(t),window.requestAnimationFrame((()=>this.redraw()))}drawColumnTitle(t,e,n,i){this.ctx&&i&&this.config.headerHeight>=Zi.WITH_TITLE()&&(this.ctx.fillStyle="rgba(255, 255, 255, 0.95)",this.ctx.fillRect(t,e,n,Ki.TITLE_HEIGHT),this.ctx.fillStyle=Vi,this.ctx.font="bold 13px Roboto, Roboto Local",this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillText(i,t+n/2,e+Ki.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((t=>{t instanceof zi&&t.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(t,e,n,i){this.dataFrame=t,this.seqColumn=e,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(t){if(!this.isValid)return;const{x:e,y:n}=this.getCoords(t),i=this.config.positionWidth,o=Math.floor(e/i),r=this.config.windowStartPosition+o-1;if(r<0||r>=this.config.totalPositions)return this.hideTooltip(),void this.clearHoverStates();const a=this.config.headerHeight>=Zi.WITH_TITLE()?Ki.TITLE_HEIGHT:0,l=this.config.headerHeight-Ki.SLIDER_HEIGHT-Ki.DOTTED_CELL_HEIGHT,c=l-Ki.TRACK_GAP;if(n>=l||n<a)return this.hideTooltip(),void this.clearHoverStates();let h=null,u=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 f=c;for(const{id:t,track:e}of d){const i=f-e.getHeight();if(n>=i&&n<f){h=t,u=n-i;break}f=i-Ki.TRACK_GAP}let g=null;if(h){const t=this.tracks.get(h);t&&(g=t.getMonomerAt(e,u,r))}if((this.previousHoverPosition!==r||this.previousHoverTrack!==h||this.previousHoverMonomer!==g)&&(this.previousHoverPosition=r,this.previousHoverTrack=h,this.previousHoverMonomer=g,h)){const t=this.tracks.get(h);t instanceof zi&&(t.setHovered(r,g),window.requestAnimationFrame((()=>this.redraw())))}if((r!==this.currentHoverPosition||h!==this.currentHoverTrack||g!==this.currentHoverMonomer)&&(this.currentHoverPosition=r,this.currentHoverTrack=h,this.currentHoverMonomer=g,h)){const e=this.tracks.get(h);if(e){const n=e.getTooltipContent(r,g);if(n)return void s.tooltip.show(n,t.clientX+16,t.clientY+16)}}h&&g||(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,s.tooltip.hide()}draw(t,e,n,i,o,r,s,a){if(Object.assign(this.config,{x:t,y:e,width:n,height:i,currentPosition:o,windowStartPosition:r}),!this.isValid)return void(this.eventElement.style.display="none");this.ctx.save(),this.ctx.clearRect(t,e,n,i),this.ctx.translate(t,e),this.ctx.rect(0,0,n,i),this.ctx.clip(),this.determineVisibleTracks();const l=this.config.headerHeight>=Zi.WITH_TITLE();l&&Ki.TITLE_HEIGHT,a&&l&&this.drawColumnTitle(0,0,n,a);const c=i-Ki.SLIDER_HEIGHT,h=c-Ki.DOTTED_CELL_HEIGHT,u=h-Ki.TRACK_GAP,d=[],p=[],m=this.getTrack("weblogo");m&&m.isVisible()&&p.push({id:"weblogo",track:m});const f=this.getTrack("conservation");f&&f.isVisible()&&p.push({id:"conservation",track:f});let g=u;for(const{track:t}of p){const e=t.getHeight(),i=g-e;t.draw(0,i,n,e,this.config.windowStartPosition,this.config.positionWidth,this.config.totalPositions,this.config.currentPosition),d.unshift({y:i,height:e}),g=i-Ki.TRACK_GAP}if(this.drawDottedCells(0,h,n,Ki.DOTTED_CELL_HEIGHT,c),d.push({y:h,height:Ki.DOTTED_CELL_HEIGHT}),this.config.currentPosition>=1&&this.config.currentPosition<=this.config.totalPositions){const t=this.config.positionWidth,e=this.config.currentPosition-this.config.windowStartPosition;if(e>=0&&e<Math.floor(n/t)){const n=e*t+t/2;for(let t=0;t<d.length-1;t++){const e=d[t],i=d[t+1];this.ctx.strokeStyle="rgba(60, 177, 115, 0.4)",this.ctx.lineWidth=1,this.ctx.beginPath(),this.ctx.moveTo(n,e.y+e.height),this.ctx.lineTo(n,i.y),this.ctx.stroke()}}}this.drawTrackButtons(),this.ctx.restore(),s.preventDefault(),this.setupEventElement()}drawDottedCells(t,e,n,i,o){if(!this.ctx)return;const r=this.config.totalPositions,s=this.config.positionWidth,a=this.config.currentPosition,l=this.config.windowStartPosition,c=Math.floor(n/s),h=e+Ki.TOP_PADDING;this.drawSlider(t,o,n);for(let n=0;n<c;n++){const c=l+n;if(c>r)break;const u=t+n*s,d=s,p=u+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(u,e,d,i),this.ctx.strokeStyle="rgba(220, 220, 220, 0.7)",this.ctx.beginPath(),this.ctx.moveTo(u,e),this.ctx.lineTo(u,o),this.ctx.stroke()),this.ctx.fillStyle="#999999",this.ctx.beginPath(),this.ctx.arc(p,h+5,1,0,2*Math.PI),this.ctx.fill(),(c===a||(1===c||c%10==0)&&Math.abs(c-a)>1)&&(this.ctx.fillStyle=Vi,this.ctx.font="12px monospace",this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillText(c.toString(),p,h+15)),c===a&&(this.ctx.fillStyle="rgba(60, 177, 115, 0.2)",this.ctx.fillRect(u,e,d,i))}}drawSlider(t,e,n){if(!this.ctx)return;this.ctx.fillStyle=this.config.sliderColor,this.ctx.fillRect(t,e,n,Ki.SLIDER_HEIGHT);const i=Math.floor(n/this.config.positionWidth),o=this.config.windowStartPosition,r=this.config.totalPositions-i,s=this.sliderWidth,a=r<=0?0:(o-1)/r*(n-s),l=r<=0?n:s;if(this.ctx.fillStyle="rgba(150, 150, 150, 0.5)",this.ctx.fillRect(t+a,e,l,Ki.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(t+o-1,e-2,3,Ki.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(t){const e=this.canvas.getBoundingClientRect();return{x:t.clientX-e.left-this.config.x,y:t.clientY-e.top-this.config.y}}isInHeaderArea(t){const{x:e,y:n}=this.getCoords(t);return e>=0&&e<=this.config.width&&n>=0&&n<=this.config.headerHeight}get positionWidth(){return this.config.positionWidth}set positionWidth(t){this.config.positionWidth=t}isInSliderArea(t){const{y:e}=this.getCoords(t),n=this.config.headerHeight-Ki.SLIDER_HEIGHT;return e>n&&e<n+Ki.SLIDER_HEIGHT}get sliderWidth(){const t=this.config.width/this.config.totalPositions*(this.config.width/this.config.positionWidth);return Math.max(t,20)}isInSliderDraggableArea(t){const{x:e,y:n}=this.getCoords(t),i=this.config.headerHeight-Ki.SLIDER_HEIGHT,o=Math.floor(this.config.width/this.config.positionWidth),r=this.config.windowStartPosition,s=this.config.totalPositions-o,a=s<=0?0:(r-1)/s*(this.config.width-this.sliderWidth);return n>i&&n<i+Ki.SLIDER_HEIGHT&&e>=a&&e<a+this.sliderWidth}setupEventListeners(){this.eventElement.addEventListener("mousemove",(t=>{this.isValid&&(this.isInSliderDraggableArea(t)?this.eventElement.style.cursor="grab":this.isInSliderArea(t)||this.isInHeaderArea(t)?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(t){if(!(this.isValid&&this.dataFrame&&this.seqColumn&&this.seqHandler))return;const{x:e,y:n}=this.getCoords(t);if(this.handleTrackButtonClick(e,n))return;const i=this.config.positionWidth,o=Math.floor(e/i),r=this.config.windowStartPosition+o-1;if(r<0||r>=this.config.totalPositions)return;const s=this.config.headerHeight>=Zi.WITH_TITLE()?Ki.TITLE_HEIGHT:0,a=this.config.headerHeight-Ki.SLIDER_HEIGHT-Ki.DOTTED_CELL_HEIGHT,l=a-Ki.TRACK_GAP;if(n>=a||n<s)return;let c=null,h=0;const u=[],d=this.getTrack("weblogo");d&&d.isVisible()&&u.push({id:"weblogo",track:d});const p=this.getTrack("conservation");p&&p.isVisible()&&u.push({id:"conservation",track:p});let m=l;for(const{id:t,track:e}of u){const i=m-e.getHeight();if(n>=i&&n<m){c=t,h=n-i;break}m=i-Ki.TRACK_GAP}if(c){const n=this.tracks.get(c);if(n){const i=n.getMonomerAt(e,h,r);if(i){if(this.onSelectionCallback)return void this.onSelectionCallback(r,i);this.selectRowsWithMonomerAtPosition(r,i),t.stopPropagation(),t.stopImmediatePropagation()}}}}selectRowsWithMonomerAtPosition(t,e){if(this.dataFrame&&this.seqHandler)try{const n=this.dataFrame.selection,i=this.seqHandler.getMonomersAtPosition(t,!0);n.init((t=>i[t]===e))}catch(t){console.error("Error selecting rows:",t)}}init(){if(this.canvas=this.config.canvas,!this.canvas)return void console.error("Canvas not found");const t=this.canvas.getContext("2d");t?(this.ctx=t,this.tracks.forEach((e=>e.init(t)))):console.error("Failed to get 2D context from canvas")}addTrack(t,e){this.ctx&&e.init(this.ctx),this.tracks.set(t,e)}removeTrack(t){this.tracks.delete(t)}getTrack(t){return this.tracks.get(t)}updateTrack(t,e){const n=this.getTrack(t);n&&e(n)}get isValid(){return!!this.canvas&&!!this.ctx&&this.config.height>=Zi.WITH_TITLE()}handleMouseDown(t){if(!this.isValid)return;const{x:e}=this.getCoords(t);this.isInSliderDraggableArea(t)&&(this.state.isDragging=!0,this.state.dragStartX=e,this.handleSliderDrag(e),t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation())}handleMouseWheel(t){if(this.isValid&&this.isInHeaderArea(t)){t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation();const e=t.shiftKey?Math.sign(t.deltaY):Math.sign(t.deltaX||t.deltaY),n=t.shiftKey?3:1,i=this.config.windowStartPosition+e*n,o=Math.floor(this.config.width/this.config.positionWidth),r=this.config.totalPositions-o+1;this.config.windowStartPosition=Math.max(1,Math.min(r,i)),"function"==typeof this.config.onPositionChange&&this.config.onPositionChange(this.config.currentPosition,this.getWindowRange())}}handleMouseMove(t){if(!this.state.isDragging||!this.isValid)return;const e=this.canvas.getBoundingClientRect(),n=t.clientX-e.left-this.config.x;this.handleSliderDrag(n),t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation()}handleKeyDown(t){if(this.isValid&&!(this.config.currentPosition<1)&&document.activeElement?.contains(this.eventElement)&&"block"===this.eventElement.style.display){if("ArrowLeft"===t.key||"ArrowRight"===t.key){t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation();const e="ArrowLeft"===t.key?-1:1,n=Math.min(Math.max(this.config.currentPosition+e,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=e<0?n:Math.max(1,n-i+1))}else{if("Escape"!==t.key)return;this.config.currentPosition=-2,t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation()}"function"==typeof this.config.onPositionChange&&this.config.onPositionChange(this.config.currentPosition,this.getWindowRange())}}handleMouseUp(){this.state.isDragging=!1}handleSliderDrag(t){if(!this.isValid)return;const e=this.sliderWidth,n=this.config.width-e,i=Math.max(0,Math.min(this.config.width,t)),o=Math.floor(this.config.width/this.config.positionWidth),r=Math.floor(this.config.width/this.config.positionWidth),s=this.config.totalPositions-r,a=Math.max(0,i-e/2)/n*s;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(t){this.config.headerHeight=t}handleClick(t){if(!this.isValid)return;t.clientX,this.canvas.getBoundingClientRect().left,t.clientY,this.canvas.getBoundingClientRect().top;const{x:e,y:n}=this.getCoords(t);if(this.handleTrackButtonClick(e,n))return t.preventDefault(),void t.stopPropagation();if(n<this.config.headerHeight-Ki.SLIDER_HEIGHT&&n>=0){const t=this.config.positionWidth,n=Math.round(e/t-.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(t){Object.assign(this.config,t),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(t){this.config.currentPosition=Math.max(1,Math.min(this.config.totalPositions,t)),"function"==typeof this.config.onPositionChange&&this.config.onPositionChange(this.config.currentPosition,this.getWindowRange())}getHeightThresholds(){return{BASE:Zi.BASE,WITH_TITLE:Zi.WITH_TITLE(),WITH_WEBLOGO:Zi.WITH_WEBLOGO(),WITH_BOTH:Zi.WITH_BOTH()}}}class Ji{static conservationCache=new a.LruCache(100);static webLogoCache=new a.LruCache(100);static lastInvalidationTime=0;static CHUNK_SIZE=50;static clearAllCaches(){Ji.conservationCache=new a.LruCache(100),Ji.webLogoCache=new a.LruCache(100),Ji.lastInvalidationTime=Date.now()}static getLastInvalidationTime(){return Ji.lastInvalidationTime}static getChunkCacheKey(t,e,n){const i=t.dataFrame;return`${i.id}_${t.name}_f${i.filter.version}_${e}_${n}`}static getConservationChunk(t,e,n,i){return Ji.conservationCache.getOrCreate(i,(()=>{const o=Ji.getWebLogoChunk(t,e,n,i),r=new Array(n-e).fill(0);for(let i=e;i<n;i++){const n=o.get(i);if(!n||0===n.size)continue;let s=0,a=0;const l=t.defaultGapOriginal;for(const[t,e]of n.entries())t&&t!==l&&(s+=e,e>a&&(a=e));r[i-e]=s>0?a/s:0}return r}))}static getWebLogoChunk(t,e,n,i){return Ji.webLogoCache.getOrCreate(i,(()=>{const i=t.column.dataFrame,o=new Map,r=i.filter.trueCount;if(r<=1)return o;for(let t=e;t<n;t++)o.set(t,new Map);const s=i.filter,a=1/r;for(let i=-1;-1!==(i=s.findNext(i,!0));){const r=t.getSplitted(i).getOriginalRegion(e,n);if(0!==r.length)for(let t=0;t<r.length;t++){const n=r[t],i=o.get(e+t);i.set(n,(i.get(n)||0)+a)}}return o}))}static getConservationForViewport(t,e,n,i){const o=new Array(i).fill(0),r=Math.floor(e/Ji.CHUNK_SIZE)*Ji.CHUNK_SIZE,s=Math.ceil(n/Ji.CHUNK_SIZE)*Ji.CHUNK_SIZE;for(let e=r;e<s;e+=Ji.CHUNK_SIZE){const n=Math.min(e+Ji.CHUNK_SIZE,i),r=Ji.getChunkCacheKey(t.column,e,n),s=Ji.getConservationChunk(t,e,n,r);for(let t=0;t<s.length&&e+t<i;t++)o[e+t]=s[t]}return o}static getWebLogoForViewport(t,e,n,i){const o=new Map,r=Math.floor(e/Ji.CHUNK_SIZE)*Ji.CHUNK_SIZE,s=Math.ceil(n/Ji.CHUNK_SIZE)*Ji.CHUNK_SIZE;for(let e=r;e<s;e+=Ji.CHUNK_SIZE){const n=Math.min(e+Ji.CHUNK_SIZE,i),r=Ji.getChunkCacheKey(t.column,e,n),s=Ji.getWebLogoChunk(t,e,n,r);for(const[t,e]of s.entries())t<i&&o.set(t,e)}return o}}class Qi extends zi{seqHandler;maxLength;lastViewportStart=-1;lastViewportEnd=-1;lastInvalidationTime=0;forceNextUpdate=!1;constructor(t,e,n=45,i="WebLogo"){super(new Map,n,"",i),this.seqHandler=t,this.maxLength=e,this.visible=t.column.dataFrame.filter.trueCount>1}forceUpdate(){this.forceNextUpdate=!0}resetViewportTracking(){this.lastViewportStart=-1,this.lastViewportEnd=-1}updateForViewport(t,e){const n=Ji.getLastInvalidationTime(),i=n>this.lastInvalidationTime;if(!(Math.abs(this.lastViewportStart-t)>=10||Math.abs(this.lastViewportEnd-e)>=10||i||this.forceNextUpdate))return;this.forceNextUpdate=!1,this.lastViewportStart=t,this.lastViewportEnd=e,this.lastInvalidationTime=n;const o=Math.max(0,t-20),r=Math.min(this.maxLength,e+20),s=Ji.getWebLogoForViewport(this.seqHandler,o,r,this.maxLength);this.updateData(s)}draw(t,e,n,i,o,r,s,a){const l=Math.ceil(n/r)+2,c=Math.min(o+l,s);this.updateForViewport(o-1,c-1),super.draw(t,e,n,i,o,r,s,a)}}class to extends Yi{seqHandler;maxLength;lastViewportStart=-1;lastViewportEnd=-1;lastInvalidationTime=0;forceNextUpdate=!1;constructor(t,e,n=45,i="default",o="Conservation"){super([],n,i,o),this.seqHandler=t,this.maxLength=e,this.visible=t.column.dataFrame.filter.trueCount>1}forceUpdate(){this.forceNextUpdate=!0}resetViewportTracking(){this.lastViewportStart=-1,this.lastViewportEnd=-1}updateForViewport(t,e){const n=Ji.getLastInvalidationTime(),i=n>this.lastInvalidationTime;if(!(Math.abs(this.lastViewportStart-t)>=10||Math.abs(this.lastViewportEnd-e)>=10||i||this.forceNextUpdate))return;this.forceNextUpdate=!1,this.lastViewportStart=t,this.lastViewportEnd=e,this.lastInvalidationTime=n;const o=Math.max(0,t-20),r=Math.min(this.maxLength,e+20),s=Ji.getConservationForViewport(this.seqHandler,o,r,this.maxLength);this.updateData(s)}draw(t,e,n,i,o,r,s,a){const l=Math.ceil(n/r)+2,c=Math.min(o+l,s);this.updateForViewport(o-1,c-1),super.draw(t,e,n,i,o,r,s,a)}}const eo=new si;async function no(){return await dn.getInstance()}class io{_palette;constructor(t){this._palette=t}get(t){return this._palette[t]}}let oo=null;async function ro(){null===oo&&(oo=async function(){const t="Bio: _package.initBio()";eo.logger.debug(`${t}, start`);const e=window.performance.now(),n=await(0,Pt.j)(),i=await eo.getProperties(),o=new ri(i);eo.properties=o;const s=await dn.getInstance(),l=await(0,Nt.ub)();l.explicit&&(l.explicit=[],await(0,Nt.Eu)(l)),await s.awaitLoaded(1/0),s.initialLoadCompleted||await s.loadMonomerLib(),s.loadMonomerSets();const c=s.getMonomerLib(),u=s.getMonomerSets(),d=window.performance.now();eo.logger.debug(`${t}, loading ET: ${d-e} ms`);const p=new Bi(s,n);eo.completeInit(p,c,u,n),eo.logger.debug(`${t}, end`),function(){const t=t=>{setTimeout((()=>{if(t.isDetached)return;const e=t.dataFrame;if(!e)return;const n=e.columns.bySemTypeAll(a.SEMTYPE.MACROMOLECULE);for(const i of n){let n=null;try{n=eo.seqHelper.getSeqHandler(i)}catch(t){continue}if(!n)continue;if(n.isHelm()||n.alphabet===gt.YI.UN)continue;const o=t.col(i.name);if(!o)continue;let s=!!t.tableView&&Array.from(t.tableView.viewers).some((t=>"Sequence Position Statistics"===t.type));if(n.isMsa()){const l=(t,e)=>Number.isNaN(t)?e:t,c=()=>l(Math.max(Number.parseInt(i.getTag(gt.gp.positionShift)??"0"),0),0)+1,u=()=>l(Number.parseInt(i.getTag(gt.gp.selectedPosition)??"-2"),-2),d=()=>kt.Jy.getFontSettings(i).fontWidth;let p=0,m=0;const f=i.categories;for(let t=0;t<f.length;t++){const e=f[t];e&&e.length>m&&(m=e.length,p=t)}const g=f[p],y=n.splitter(g),b=y?y.length:30,v={WITH_TITLE:58,WITH_WEBLOGO:107,WITH_BOTH:156};let w;w=i.length>1e5||b<50?v.WITH_TITLE:i.length>5e4?v.WITH_WEBLOGO:v.WITH_BOTH;let C=null,A=null;const S=a.debounce(h.merge(e.onFilterChanged,e.onDataChanged.pipe((0,R.filter)((t=>t?.args?.column===i)))),100).subscribe((()=>{Ji.clearAllCaches(),C&&(C.resetViewportTracking(),C.forceUpdate()),A&&(A.resetViewportTracking(),A.forceUpdate()),setTimeout((()=>{t.isDetached||t.invalidate()}),50)}));t.sub(S);const x=r=>{const l=[],h=new to(n,b,45,"default","Conservation");A=h,l.push({id:"conservation",track:h,priority:1});const p=new Qi(n,b,45,"WebLogo");C=p,r&&(p.setMonomerLib(r),p.setBiotype(n.defaultBiotype||"HELM_AA")),p.setupDefaultTooltip(),l.push({id:"weblogo",track:p,priority:2});const m=new Xi({canvas:t.overlay,headerHeight:w,totalPositions:b+1,onPositionChange:(e,n)=>{setTimeout((()=>{const o=c(),r=u();if(o!==n.start&&i.setTag(gt.gp.positionShift,(n.start-1).toString()),r!==e&&(i.setTag(gt.gp.selectedPosition,e.toString()),e>=0&&!s&&t.tableView)){s=!0;const e=t.tableView.addViewer("Sequence Position Statistics",{sequenceColumnName:i.name});t.tableView.dockManager.dock(e,a.DOCK_TYPE.DOWN,null,"Sequence Position Statistics",.4)}}))},onHeaderHeightChange:e=>{t.isDetached||e<v.WITH_TITLE||setTimeout((()=>t.props.colHeaderHeight=e))}});m.setupTooltipHandling(),l.forEach((({id:t,track:e})=>{m.addTrack(t,e)})),m.setSelectionData(e,i,n),b>50&&(t.props.colHeaderHeight=w,setTimeout((()=>{t.isDetached||(o.width=400)}),300)),t.sub(t.onCellRender.subscribe((t=>{const e=t.cell;if(!e||!e.isColHeader||e?.gridColumn?.name!==o?.name)return;const n=t.bounds;if(!n)return;m.headerHeight=n.height;const r=d();m.positionWidth=r+8;const s=c();m.draw(n.x+0,n.y,n.width-0,n.height,u(),s,t,i.name)})))};(0,bt.pj)().then((t=>{const e=t.getMonomerLib();x(e)})).catch((t=>{r.shell.warning("Failed to initialize monomer library"),console.error("Failed to initialize monomer library:",t)}))}}}),1e3)},e=(r.events.onViewerAdded.subscribe((e=>{if(!(e.args&&e.args.viewer instanceof a.Grid))return;const n=e.args.viewer;t(n)})),r.shell.tableViews);for(const n of e){const e=n?.grid;e&&t(e)}}()}()),await oo}function so(t){const e=new hi(t,eo.seqHelper);return e.init().then((()=>{})).catch((t=>{const e=t instanceof Error?t.message:t.toString();r.shell.error(e)})),e}function ao(){return eo.monomerLib}function lo(t){return eo.seqHelper.getSeqHandler(t)}function co(t){const e="getRegionTopMenu",n=a.Func.find({package:eo.name,name:e});if(1!==n.length)throw new Error(`Package '${eo.name}' func '${e}' not found`);const i=n[0].prepare({table:t.dataFrame,sequence:t});return new mi(i,eo.seqHelper).widget()}async function ho(t){return async function(){const t=s.label("Manage monomer libraries");return mn()(t).addClass("d4-link-action"),t.onclick=async()=>await Dn(),new a.Widget(t)}()}function uo(t){try{new mi(t,eo.seqHelper).dialog()}catch(t){const e=t instanceof Error?t.message:t.toString(),n=t instanceof Error?t.stack:void 0;r.shell.error(`Get region editor error: ${e}`),eo.logger.error(e,void 0,n)}}function po(t){const e=new ti;s.dialog({title:"Split to Monomers"}).add(e.paramsUI).onOK((async()=>t.func.prepare(e.funcParams).call(!0))).show()}function mo(t){const e=new $({semtype:a.SEMTYPE.MACROMOLECULE}),n=s.dialog({title:"Sequence Space"}).add(e.getEditor()).onOK((async()=>{const n=e.getParams();return t.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:e.getStringInput()})),(t=>e.applyStringInput(t.editorSettings))),n.show()}function fo(t){const e=new St({semtype:a.SEMTYPE.MACROMOLECULE}),n=s.dialog({title:"Activity Cliffs"}).add(e.getEditor()).onOK((async()=>{const n=e.getParams();return t.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:e.getStringInput()})),(t=>e.applyStringInput(t.editorSettings))),n.show()}function go(){return new Yt}function yo(){return new Yt}function bo(){return new Yt}function vo(t){return function(t){const e=Array.from(t.dataFrame.columns).filter((t=>t.semType===a.SEMTYPE.MOLECULE)).map((t=>t.name));new Set(e).delete(t.name);let n=eo.properties?eo.properties.maxMonomerLength:4;if(Rt.gp.maxMonomerLength in t.tags){const e=parseInt(t.getTag(Rt.gp.maxMonomerLength));n=isNaN(e)?n:e}if(".mm.cellRenderer.maxMonomerLength"in t.temp){const e=parseInt(t.temp[".mm.cellRenderer.maxMonomerLength"]);n=isNaN(e)?n:e}const i=s.input.int("Max Monomer Length",{value:n,nullable:!0,min:1,max:50,step:1,onValueChanged:e=>{if(0==e)setTimeout((()=>{i.value=null}),0);else{const n=e??"",i=null==n?"":n.toString();t.temp[".mm.cellRenderer.maxMonomerLength"]=i,t.temp[".mm.cellRenderer.settingsChanged"]=Bt.s.true,t.dataFrame.fireValuesChanged()}},tooltipText:"The max length of monomer symbol displayed without shortening, empty to no limit"});let o=eo.properties?eo.properties.fontSize:12;".mm.cellRenderer.fontSize"in t.temp&&t.temp[".mm.cellRenderer.fontSize"]&&!isNaN(t.temp[".mm.cellRenderer.fontSize"])&&(o=t.temp[".mm.cellRenderer.fontSize"]);const r=s.input.int("Font Size",{value:o,nullable:!0,min:1,max:50,step:1,onValueChanged:e=>{if(e&&e>0){const n=e??12;t.temp[".mm.cellRenderer.fontSize"]=n,t.temp[".mm.cellRenderer.settingsChanged"]=Bt.s.true,t.dataFrame.fireValuesChanged()}},tooltipText:"The font size of monomer symbol in sequence renderer"}),l=s.input.int("Monomer Margin",{value:t.temp[".mm.cellRenderer.gapLength"]??0,onValueChanged:e=>{t.temp[".mm.cellRenderer.gapLength"]=e,t.temp[".mm.cellRenderer.settingsChanged"]=Bt.s.true,t.dataFrame.fireValuesChanged()},tooltipText:"The size of margin between monomers (in pixels)"}),c=s.input.bool("Color Code",{value:null==t?.temp["color-code"]||t.temp["color-code"],onValueChanged:e=>{t.temp["color-code"]=e,t.dataFrame.fireValuesChanged()},tooltipText:"Color code"}),h=s.input.string("Reference Sequence",{value:null!=t?.temp["reference-sequence"]?t?.temp["reference-sequence"]:"",nullable:!0,onValueChanged:e=>{t.temp["reference-sequence"]=e,t.dataFrame.fireValuesChanged()},tooltipText:"Reference sequence is not empty, then the sequence will be render \nas a difference from the reference sequence"}),u=s.input.bool("Compare with current",{value:null==t?.temp["compare-with-current"]||t.temp["compare-with-current"],onValueChanged:e=>{t.temp["compare-with-current"]=e,t.dataFrame.fireValuesChanged()},tooltipText:'When on, all sequences get rendered in the "diff" mode'});let d=null;(()=>{const e=t.meta.units;return e!==gt.Hi.HELM&&e!==gt.Hi.CUSTOM})()&&(d=s.input.bool("Multiline Rendering",{value:"true"===t.getTag("renderMultiline"),onValueChanged:e=>{t.tags.renderMultiline=e?"true":"false",t.dataFrame.fireValuesChanged()},tooltipText:"Render sequences across multiple lines when they exceed cell width"}));const p=[r,i,l,h,c,u];d&&p.push(d);const m=s.inputs(p);return new a.Widget(m)}(t)}function wo(t){return function(t,e,n){const i=s.div();i.classList.add("macromolecule-cell-comp-analysis-host");const o=t.cell.column.tags[gt.gp.alphabet],r=o===gt.YI.DNA||o===gt.YI.RNA?Ft.o.NUCLEOTIDE:Ft.o.AA,l={},c=n.getSeqHandler(t.cell.column),h=t.cell.rowIndex,u=c.getSplitted(h);ot().count(0).take(u.length).filter((t=>!u.isGap(t))).forEach((t=>{let e=u.getCanonical(t);r===Ft.o.NUCLEOTIDE&&c.isHelm()&&"("===e[1]&&")"===e[e.length-2]&&(e=e.substring(2,e.length-2));const n=l[e]||0;l[e]=n+1}));const d=(0,ci.F)(l,r,e);return Array.from(d.rows).forEach((t=>{const e=t.getElementsByClassName("macromolecule-cell-comp-analysis-bar")[0].style.backgroundColor;t.cells[0].style.color=e})),i.appendChild(d),new a.Widget(i)}(t,eo.monomerLib,eo.seqHelper)}function Co(){return new Zt}function Ao(t,e,n,i,o){const r=new he.$(i,o,n,e);return"Local alignment"==t?r.smithWaterman():r.needlemanWunsch()}function So(){return new oe.oP}function xo(){return new ce}function Eo(t,e,n,i){return ui(t,e??null,n??null,i??null)}async function Mo(t,e,n,i,o){const s=ui(e,n??null,i??null,o??null);e.dataFrame.columns.add(s),await r.data.detectSemanticTypes(e.dataFrame)}async function To(t,e,n,i,o,h,u,d,p){if(t.name!==r.shell.tv.dataFrame.name)return void r.shell.error(`Table ${t.name} is not a current table view`);if(!(0,Zn.V)(e,"Activity Cliffs"))return;const m=_t(t),f={units:e.meta.units,aligned:e.getTag(gt.gp.aligned),separator:e.getTag(gt.gp.separator),alphabet:e.getTag(gt.gp.alphabet)},g=h,y=e,b=async()=>await mt(t,y,m,"Activity cliffs",n,i,g,o,{...d??{}},a.SEMTYPE.MACROMOLECULE,f,u,me,fe,ve,void 0,p),v=o===c.c.UMAP?2e5:2e4,w=o===c.c.UMAP?5e3:2e3;if(t.rowCount>v)return void r.shell.warning(`Too many rows, maximum for sequence activity cliffs is ${v}`);const C=a.TaskBarProgressIndicator.create("Running sequence activity cliffs ...");return new Promise(((e,n)=>{t.rowCount>w&&!d?.[l.vb]?s.dialog().add(s.divText("Activity cliffs analysis might take several minutes.\n Do you want to continue?")).onOK((async()=>{b().then((t=>e(t))).catch((t=>n(t)))})).onCancel((()=>{e(void 0)})).show():b().then((t=>e(t))).catch((t=>n(t)))})).catch((t=>{const[e,n]=(0,Ct.AP)(t);throw eo.logger.error(e,void 0,n),t})).finally((()=>{C.close()}))}async function _o(t,e,n=1,i=.6,o="Morgan"){if(t.semType!==a.SEMTYPE.MACROMOLECULE)return{entries:t.toList(),options:{}};const{seqList:r,options:s}=await de(t,e,o,n,i);return{entries:r,options:s}}async function Io(t,e){t.version!==t.temp["last-invalidated-version"]&&await(0,pe.BQ)(t,eo.seqHelper,!1);const n=t.temp["monomeric-mols"],i=await r.functions.call("Chem:getMorganFingerprints",{molColumn:n}),o=new Array(i.length).fill(null);for(let t=0;t<i.length;t++){if(i.isNone(t)||!i.get(t))continue;const e=i.get(t);o[t]=V.A.fromUint32Array(e.length,new Uint32Array(e.getBuffer().buffer))}return{entries:o,options:{}}}async function Lo(t,e,i,o,c,h,u,d,p){if(t.name!==r.shell.tv.dataFrame.name)return void r.shell.error(`Table ${t.name} is not a current table view`);const m=r.shell.tv.dataFrame==t?r.shell.tv:void 0;return(0,Zn.V)(e,"Sequence Space")?(h||(h=a.Func.find({name:"macromoleculePreprocessingFunction",package:"Bio"})[0]),u??={},await async function(t,e,i,o,c,h,u,d=!0,p=!1,m={preprocessingFuncArgs:[]},f={},g=null,y={},b){const v={showXAxis:!1,showYAxis:!1,showXSelector:!1,showYSelector:!1};if(e.length!==o.length||e.length!==h.length||e.length!==c.length||e.length!==m.preprocessingFuncArgs.length)throw new Error("columns, metrics and preprocessing functions, weights and function argumentsmust have the same length");const w=d?f.tableView??r.shell.tableView(t.name)??r.shell.addTableView(t):null,C=async()=>{const C=a.TaskBarProgressIndicator.create(`Initializing ${f.scatterPlotName??"dimensionality reduction"} ...`);let A;try{const S=_t(t);function x(n,o,r){let c=null,h=null;t.columns.names().includes(S[0])?(c=t.columns.byName(S[0]),h=t.columns.byName(S[1])):(c=t.columns.add(a.Column.float(S[0],t.rowCount)),h=t.columns.add(a.Column.float(S[1],t.rowCount)),d&&!A&&(A=w.scatterPlot({...v,x:S[0],y:S[1],title:f.scatterPlotName??It(e,i)}))),f[l.YP]&&(A?.root&&s.setUpdateIndicator(A.root,!1),c.init((t=>r[0]?r[0][t]:void 0)),h.init((t=>r[1]?r[1][t]:void 0)));const u=n/o*100;C.update(u,`Running ${f.scatterPlotName??"dimensionality reduction"}... ${u.toFixed(0)}%`)}async function E(){t.columns.add(a.Column.float(S[0],t.rowCount)),t.columns.add(a.Column.float(S[1],t.rowCount));let n=null;d&&(A=w.scatterPlot({...v,x:S[0],y:S[1],title:f.scatterPlotName??It(e,i)}),s.setUpdateIndicator(A.root,!0));const p=r.events.onViewerClosed.subscribe((t=>{const e=t.args.viewer;e?.getOptions()?.look?.title&&A?.getOptions()?.look?.title&&e?.getOptions()?.look?.title===A?.getOptions()?.look?.title&&(r.events.fireCustomEvent(q.S,{}),p.unsubscribe(),n?.(),C.close())})),g=new Promise((async(r,s)=>{try{n=r;const s=[];let a=o,d=c,p=u;if(b&&e.every((t=>t.isNumerical))){const n=e.map((t=>t.toList())),i=new Array(t.rowCount).fill(0).map(((t,n)=>new Float32Array(e.length)));for(let o=0;o<e.length;++o)for(let e=0;e<t.rowCount;++e)i[e][o]=n[o][e];m.distanceFnArgs=[{}],s.push({entries:i,options:{}}),a=[b],d=[1],p="MANHATTAN"}else for(let t=0;t<h.length;++t){const n=h[t];if(m.distanceFnArgs||(m.distanceFnArgs=[]),n){const i=n.inputs[0].name,r=n.inputs[1].name,{entries:a,options:l}=await n.apply({[i]:e[t],[r]:o[t],...m.preprocessingFuncArgs[t]??{}});s.push({entries:a,options:l}),m.distanceFnArgs.push(l)}else{const n=e[t].toList(),i={};s.push({entries:n,options:i}),m.distanceFnArgs.push(i)}}r(await Y(s.map((t=>t.entries)),i,a,d,u,m,f[l.vb]?void 0:x))}catch(t){s(t)}})),y=await g;return C.close(),p.unsubscribe(),y}const M=await E();if(p&&M){const T=a.TaskBarProgressIndicator.create("Clustering embeddings ...");try{const _=await function(t,e,i,o){return Tt(this,void 0,void 0,(function*(){return new Promise((function(r,s){const a=new Worker(new URL(n.p+n.u(682),n.b));a.postMessage({embedX:t,embedY:e,minPts:o,epsilon:i}),a.onmessage=({data:{error:t,clusters:e}})=>{a.terminate(),t?s(t):r(e)}}))}))}(M[0],M[1],m.dbScanEpsilon??.01,m.dbScanMinPts??4),I=t.columns.getUnusedName("Cluster (DBSCAN)");t.columns.addNewString(I).init((t=>_[t].toString())),A&&(A.props.colorColumnName=I)}catch(L){r.shell.error("Clustering embeddings failed"),console.error(L)}finally{T.close()}}if(M){const N=t.columns.byName(S[0]),P=t.columns.byName(S[1]);if(N.init((t=>M[0][t])),P.init((t=>M[1][t])),g)try{const $=g.inputs[0].name,R=g.inputs[1].name;await g.prepare({[$]:N,[R]:P,...y}).call(!0)}catch(k){r.shell.error("Post-processing failed"),console.error(k)}if(A)return s.setUpdateIndicator(A.root,!1),A.helpUrl="/help/compute/sequence-space",A}}catch(O){r.shell.error("Dimensionality reduction failed"),console.error(O),C.close(),A&&s.setUpdateIndicator(A.root,!1)}};return new Promise((async(e,n)=>{try{if(f.fastRowCount&&t.rowCount>f.fastRowCount&&!f[l.vb])s.dialog().add(s.divText("Analysis might take several minutes. Do you want to continue?")).onOK((async()=>{try{const t=await C();e(t)}catch(t){n(t)}})).onCancel((()=>e(void 0))).show();else{const t=await C();e(t)}}catch(t){n(t)}}))}(t,[e],i,[o],[1],[h],"MANHATTAN",c,d??!1,{...u,preprocessingFuncArgs:[u.preprocessingFuncArgs??{}]},{fastRowCount:1e4,scatterPlotName:"Sequence space",bypassLargeDataWarning:u?.[l.vb],tableView:m})):void 0}async function No(t,e,n,i=!1){const o=a.TaskBarProgressIndicator.create("Converting to atomic level ...");try{await oo;const o=e.temp[".mm.cellRenderer.overriddenLibrary"]??eo.monomerLib,r=eo.seqHelper,s=eo.rdKitModule;await(0,fi.V)(t,e,n,i,o,r,s)}finally{o.close()}}async function Po(t){if(!t?.dataFrame)throw new Error("Sequence column is not found or its data frame is not empty");const e=a.Func.find({name:"toAtomicLevel",package:"Bio"})[0];if(!e)throw new Error("To Atomic level Function not found");e.prepare({table:t.dataFrame,seqCol:t}).edit()}async function $o(t){return async function(t){const e=await Di(t);if(e.errorText||!e.mol)return a.Widget.fromRoot(s.divText(e.errorText??"No structure generated"));try{const t=a.SemanticValue.fromValueType(e.mol,a.SEMTYPE.MOLECULE),n=s.panels.infoPanel(t);let i=null;n&&(i=a.Widget.fromRoot(n.root));const o=r.chem.drawMolecule(e.mol,300,300,!1);return o.style.cursor="pointer",s.tooltip.bind(o,"Click to expand"),o.onclick=()=>{const t=window.innerWidth-200,n=window.innerHeight-200,i=r.chem.drawMolecule(e.mol,t,n,!1);s.dialog({title:"Molecule"}).add(i).showModal(!0)},i&&i.root.prepend(o),i??a.Widget.fromRoot(o)}catch(t){eo.logger.error(t)}return a.Widget.fromRoot(s.divText("No structure generated"))}(t)}async function Ro(t){return async function(t){const e=a.TaskBarProgressIndicator.create("Creating 3D view");let n,i="";try{await(a.Func.find({name:"getPdbHelper"})[0]?.apply({}));try{const o=await Di(t);if(o.errorText||!o.mol)return n=s.divText(o.errorText??"No structure generated"),e.close(),new a.Widget(n);const l=o.mol;i=await r.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(t){console.warn(t)}try{i=i.replaceAll("\\n","\n");const t=new Blob([i],{type:"text/plain"}),e=s.div([],{classes:"d4-ngl-viewer",id:"ngl-3d-host"});e.style.setProperty("height","100%","important");const o=new NGL.Stage(e,{backgroundColor:"white"});o.loadFile(t,{ext:"sdf"}).then((function(t){o.setSize(300,300),t.addRepresentation("ball+stick"),t.autoView()})),n=s.div([e],{style:{aspectRatio:"1"}})}catch(t){n=s.divText("Couldn't get 3D structure")}}catch(t){n=s.divText("Couldn't get 3D structure")}return e.close(),new a.Widget(n)}(t)}function ko(){(0,Jn.D)({},eo.seqHelper).catch((t=>{const[e,n]=(0,Ct.AP)(t);if(t instanceof Xn.Ap)return r.shell.warning(t.element),void eo.logger.warning(e);r.shell.error(e),eo.logger.error(e,void 0,n)}))}async function Oo(t=null,e=null,n){return(0,Jn.D)({col:t,clustersCol:e,...n},eo.seqHelper)}async function Ho(){const t=r.shell.tv,e=t.dataFrame.columns.toList().filter((t=>t.semType==a.SEMTYPE.MACROMOLECULE&&(eo.seqHelper.getSeqHandler(t),!0))),n=async e=>{if(!(0,Zn.V)(e,"Composition"))return;const n=t.addViewer("WebLogo",{sequenceColumnName:e.name});r.shell.tv.dockManager.dock(n,a.DOCK_TYPE.DOWN,null,"Composition analysis",.25)};let i=null;if(0!=e.length){if(e.length>1){const t=e.map((t=>t.name)),i=e.find((t=>eo.seqHelper.getSeqHandler(t).isMsa())),o=s.input.choice("Column",{value:i?i.name:t[0],items:t});s.dialog({title:"Composition Analysis",helpUrl:"https://datagrok.ai/help/datagrok/solutions/domains/bio/#sequence-composition"}).add(s.div([o])).onOK((async()=>{const t=e.find((t=>t.name==o.value))??null;t&&await n(t)})).show()}else i=e[0];i&&await n(i)}else r.shell.error("Current table does not contain sequences")}function Go(t){return new yt.m(t).importFasta()}function Fo(t){return console.log(t),[]}function Bo(){const t=(0,$t.me)()[0];(0,Me.C)(t,eo.seqHelper)}function Do(t){(0,Me.C)(t,eo.seqHelper)}function Vo(){return new ii}async function Wo(t){const e=a.TaskBarProgressIndicator.create("Test detectMacromolecule..."),n=(await r.dapi.files.list(t,!0,"")).filter((t=>t.fileName.endsWith(".csv")));let i=0;const o=[];for(const s of n)try{const e=await r.dapi.files.readAsText(t+s.fullPath),n=a.DataFrame.fromCsv(e);for(const t of n.columns)await r.functions.call("Bio:detectMacromolecule",{col:t})===a.SEMTYPE.MACROMOLECULE&&o.push({file:s.path,result:"detected",column:t.name,message:`units: ${t.meta.units}`})}catch(t){o.push({file:s.path,result:"error",column:null,message:t instanceof Error?t.message:t.toString()})}finally{i+=1,e.update(100*i/n.length,`Test ${s.fileName}`)}r.shell.info("Test Demo:Files for detectMacromolecule finished."),e.close();const s=a.DataFrame.fromObjects(o);return s.name=`datasets_detectMacromolecule_${t}`,s}async function Uo(t,e){return await async function(t,e){if(await(0,te.cb)(10),!(0,Zn.V)(e,"Sequence space"))return t;const n=eo.seqHelper,i=(0,vt.R)(e,n);i.name="splitToMonomers";const o=e.dataFrame;for(const t of i.columns)t.semType=Wt.uF.MONOMER,t.setTag(wt.gp.alphabet,e.getTag(wt.gp.alphabet));const s=/(\d+)(?: \((\d+)\))?/,l=t=>{s.lastIndex=0;const e=t.match(s);return e?`${e[1]} (${parseInt(e[2]??"0")+1})`:t};for(let t=0;t<i.columns.length;t++){const n=i.columns.byIndex(t);n.semType=Wt.uF.MONOMER,n.setTag(wt.gp.alphabet,e.getTag(wt.gp.alphabet));const r=100;let s=0;for(;o.columns.byName(n.name)&&s<r;)n.name=l(n.name),s++;o.columns.add(n)}await r.data.detectSemanticTypes(o);for(let t=0;t<i.columns.length;t++){const e=i.columns.byIndex(t);e.setTag(a.TAGS.CELL_RENDERER,"Monomer"),e.setTag(".use-as-filter","false")}return o}(t,e)}function jo(t){return eo.seqHelper.getSeqMonomers(t)}function qo(){return new Se(eo.seqHelper)}function zo(){const t=r.shell.v,e=t.addViewer("Sequence Similarity Search");t.dockManager.dock(e,"down")}function Yo(){return new xe(eo.seqHelper)}function Ko(){const t=r.shell.v,e=t.addViewer("Sequence Diversity Search");t.dockManager.dock(e,"down")}function Zo(t){const e=(0,$t.me)();1===e.length?t.func.prepare({macromolecules:e[0]}).call(!0):new pe.a7(e,eo.seqHelper)}function Xo(t){r.shell.tv.getFiltersGroup({createDefaultFilters:!1}).updateOrAdd({type:"Bio:bioSubstructureFilter",column:t.name,columnName:t.name}),r.shell.tv.grid.scrollToCell(t,0)}async function Jo(t,e,n){const i=eo.seqHelper;return gi(t,e,n,ft.IDENTITY,i)}async function Qo(t,e,n){const i=eo.seqHelper;return gi(t,e,n,ft.SIMILARITY,i)}async function tr(){Dn()}async function er(){await Vn()}async function nr(){const t=await Mn.getInstance();await t.getViewRoot()}async function ir(){return await Vn(!1)}async function or(t,e){(await(await dn.getInstance()).getFileManager()).getValidLibraryPaths().forEach((e=>{const n=e.endsWith(".json")?e.substring(0,e.length-5):e;t.item(n).onSelected.subscribe((async()=>{const t=await Mn.getInstance();await t.getViewRoot(e,!0),t.resetCurrentRowFollowing()}))}))}function rr(){(0,Te.TE)()}function sr(){return new _e._i(eo.seqHelper,eo.logger)}function ar(){return new _e._i(eo.seqHelper,eo.logger)}async function lr(){const t=a.TaskBarProgressIndicator.create("WebLogo");try{const t=new URLSearchParams(window.location.search),e=new Qn(t,"webLogoLargeApp"),n=await eo.files.readCsv("data/sample_PT_100000x5.csv");await r.data.detectSemanticTypes(n),await e.init(n)}finally{t.close()}}async function cr(){const t=a.TaskBarProgressIndicator.create("WebLogo ...");try{const t=new URLSearchParams(window.location.search),e=new Qn(t,"webLogoAggApp"),n=await eo.files.readCsv("samples/FASTA_PT_activity.csv");await r.data.detectSemanticTypes(n),await e.init(n)}finally{t.close()}}async function hr(){const t=a.TaskBarProgressIndicator.create("getRegion ...");try{const t=new URLSearchParams(window.location.search),e=new pi(t,"getRegionApp");await e.init()}finally{t.close()}}async function ur(){const t=a.TaskBarProgressIndicator.create("getRegion ...");try{const t=new URLSearchParams(window.location.search),e=await eo.files.readCsv("samples/HELM_empty_vals.csv"),n=new pi(t,"getRegionHelmApp");await n.init({df:e,colName:"HELM"})}finally{t.close()}}function dr(){const t=a.DataFrame.fromColumns((0,Lt.dW)());r.shell.addTableView(t)}function pr(){const t=a.DataFrame.fromColumns([(0,Lt.Hx)(eo.seqHelper,gt.Hi.FASTA)]);r.shell.addTableView(t)}function mr(){const t=a.DataFrame.fromColumns([(0,Lt.Hx)(eo.seqHelper,gt.Hi.HELM)]);r.shell.addTableView(t)}function fr(t,e){!function(t,e,n){const i=Object.values(gt.Hi).filter((t=>t!==gt.Hi.CUSTOM));e.group("Copy").items(i,(e=>{const i=t.column,o=t.rowIndex,s=n.getSeqHandler(i),a=e===gt.Hi.SEPARATOR?eo.properties.defaultSeparator??"-":void 0,l=s.getJoiner({notation:e,separator:a})(s.getSplitted(o));navigator.clipboard?(navigator.clipboard.writeText(l),r.shell.info(`Value of notation '${e}' copied to clipboard`)):r.shell.warning("The clipboard functionality requires a secure origin — either HTTPS or localhost")}))}(t,e,eo.seqHelper)}async function gr(){await async function(){const t=await eo.files.readCsv("samples/peptides-non-natural.csv");t.name="Similarity and Diversity Demo",t.col("activity").setTag("format","3 significant digits"),t.col("sequence").temp[".mm.cellRenderer.maxMonomerLength"]=4;const e=r.shell.addTableView(t);await t.meta.detectSemanticTypes(),await r.data.detectSemanticTypes(t);const n=e.addViewer("Sequence Similarity Search",{limit:20}),i=e.dockManager.dock(n,a.DOCK_TYPE.RIGHT,null,"Similarity search",.45);(0,$t.Kd)(e.grid,"sequence",500,30);const o=e.addViewer("Sequence Diversity Search",{limit:20});e.dockManager.dock(o,a.DOCK_TYPE.DOWN,i,"Diversity search",.4),r.functions.call("Dendrogram:HierarchicalClustering",{df:r.shell.t,colNameList:["sequence"],distance:"euclidian",linkage:"complete"})}()}async function yr(){await async function(){const t=await r.functions.eval("Bio:SeqSpaceDemo"),e=await r.dapi.projects.find(t.id);await e.open(),r.shell.windows.help.showHelp("/help/datagrok/solutions/domains/bio/bio.md#sequence-space")}()}async function br(){await async function(){const t=await eo.files.readCsv("tests/helm_cyclic_cliffs.csv");t.name="Activity Cliffs Demo",await r.data.detectSemanticTypes(t),await t.meta.detectSemanticTypes();const e=r.shell.addTableView(t);s.setUpdateIndicator(e.root,!0);try{const n=a.Func.find({name:"macromoleculePreprocessingFunction",package:"Bio"})[0],i=await To(t,t.getCol("Sequence"),t.getCol("Activity"),96,c.c.UMAP,ue.Z.MONOMER_CHEMICAL_DISTANCE,n,{},!0);e.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),e.grid.props.rowHeight=180,e.grid.col("sequence")&&(e.grid.col("sequence").width=300),e.grid.col("structure")&&(e.grid.col("structure").width=300);const o=Array.from(e.viewers).find((t=>t!==e.grid&&t.type===a.VIEWER.GRID));o&&(o.props.rowHeight=40,o.col("seq_diff").width=600,e.dockManager.dock(o,a.DOCK_TYPE.DOWN,null,"Cliffs",.35),e.dockManager.dock(i,a.DOCK_TYPE.RIGHT,null,"Activity Cliffs",.55))}catch(t){!function(t){const e=t instanceof Error?t.message:t.toString(),n=t instanceof Error?t.stack:void 0;r.shell.error(e),eo.logger.error(t.message,void 0,n)}(t)}finally{s.setUpdateIndicator(e.root,!1)}r.shell.windows.help.showHelp("/help/datagrok/solutions/domains/bio/bio.md#activity-cliffs")}()}async function vr(){await async function(){const t=await eo.files.readCsv("samples/HELM_BI_CYCLIC.csv");t.name="To Atomic Level",await t.meta.detectSemanticTypes(),await r.data.detectSemanticTypes(t);const e=r.shell.addTableView(t),n=t.col("HELM");await No(t,n,!0,!1),(0,$t.Kd)(e.grid,"molfile(HELM)",500,300,!0),(0,$t.Kd)(e.grid,"HELM",500,void 0,!0),r.shell.info("Hover over monomers in HELM column to highlight them in molecular structure.",{timeout:10}),r.shell.windows.help.showHelp("/help/datagrok/solutions/domains/bio/bio.md#get-atomic-level-structure")}()}async function wr(t){const e=(0,bt.uX)(t),n=JSON.stringify(e);a.Utils.download(`${t.name}.json`,n)}async function Cr(t,e){if(!t.trim())return"";try{const n=a.Column.fromList(a.COLUMN_TYPE.STRING,"helm",[t]),i=a.DataFrame.fromColumns([n]),o=await r.functions.call("Bio:detectMacromolecule",{col:n});o&&(n.semType=o);const s=(await no()).getMonomerLib(),l=eo.seqHelper,c=await(0,Pt.j)(),h=(await(0,fi.V)(i,n,e,!1,s,l,c))?.molCol?.get(0);return h??void 0}catch(t){const[e,n]=(0,Ct.AP)(t);throw eo.logger.error(e,void 0,n),t}}async function Ar(t,e){if(!t.trim())return null;try{const n=a.Column.fromList(a.COLUMN_TYPE.STRING,"seq",[t]),i=a.DataFrame.fromColumns([n]);if(!await r.functions.call("Bio:detectMacromolecule",{col:n}))throw new Error("Macromolecule required");return(await gi(i,n,e,ft.IDENTITY,eo.seqHelper)).get(0)}catch(t){const[e,n]=(0,Ct.AP)(t);throw eo.logger.error(e,void 0,n),t}}async function Sr(t,e,n){const i=await t.readAsString();await async function(t,e,n){const i=a.TaskBarProgressIndicator.create("detectMacromolecule probe ...");try{let o=0;const s=await r.functions.call("Bio:detectMacromoleculeEnableStore");let l=0;for(let c=0;c<n;++c){const h=a.DataFrame.fromCsv(t),u=e?h.getCol(e):h.columns.byIndex(0);await r.functions.call("Bio:detectMacromolecule",{col:u})!==a.SEMTYPE.MACROMOLECULE&&(++l,console.warn(`Reject reason: ${s.last.rejectReason}`));const d=c/n;d-o>=.1&&(o=d,i.update(100*d,`detectMacromolecule probe ${l}/${c}/${n} ...`),await(0,te.cb)(0))}l>0?r.shell.warning(`detectMacromolecule failed ${l} / ${n}`):r.shell.info(`detectMacromolecule success ${n}`)}finally{i.close()}}(i,e,n)}async function xr(){return await ro(),eo.seqHelper}function Er(t,e,n){return async function(t,e,n=!0,i){const o=eo.seqHelper,r=(await o.getHelmToMolfileConverter(i)).convertToRdKitBeautifiedMolfileColumn(e,n,eo.rdKitModule,i);return r.semType=a.SEMTYPE.MOLECULE,r}(0,e,n,eo.monomerLib)}function Mr(){return eo.logger.debug("Bio:test1() function"),{value:"value1"}}},6625:(t,e,n)=>{"use strict";n.d(e,{$:()=>r});class i{value;parentI;parentJ;constructor(){this.value=0,this.parentI=0,this.parentJ=0}}class o{seq1;seq2;score;constructor(t,e,n){this.seq1=t,this.seq2=e,this.score=n}}class r{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 t=0;t<=this.len1;t++)this.dpGrid[t][0].value=-t*this.gap,this.dpGrid[t][0].parentI=t-1,this.dpGrid[t][0].parentJ=0;for(let t=1;t<=this.len2;t++)this.dpGrid[0][t].value=-t*this.gap,this.dpGrid[0][t].parentI=0,this.dpGrid[0][t].parentJ=t-1}fillOne(t,e){this.dpGrid[t][e].value=Math.max(this.dpGrid[t-1][e-1].value+this.scores[t-1][e-1],Math.max(this.dpGrid[t-1][e].value-this.gap,this.dpGrid[t][e-1].value-this.gap)),this.dpGrid[t][e].value==this.dpGrid[t-1][e-1].value+this.scores[t-1][e-1]?(this.dpGrid[t][e].parentI=t-1,this.dpGrid[t][e].parentJ=e-1):this.dpGrid[t][e].value==this.dpGrid[t-1][e].value-this.gap?(this.dpGrid[t][e].parentI=t-1,this.dpGrid[t][e].parentJ=e):(this.dpGrid[t][e].parentI=t,this.dpGrid[t][e].parentJ=e-1)}gridFromName(t){switch(t){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(t,e){let n="",i="",r="";const s=this.dpGrid[t][e].value;for(let t=0;t<this.step;t++)r+="|";for(;t>0||e>0;){this.dpGrid[t][e].parentI==t?(n=r+n,i=this.seq2.substr((e-1)*this.step,this.step)+i):this.dpGrid[t][e].parentJ==e?(i=r+i,n=this.seq1.substr((t-1)*this.step,this.step)+n):(n=t-1>=0?this.seq1.substr((t-1)*this.step,this.step)+n:r+n,i=e-1>=0?this.seq2.substr((e-1)*this.step,this.step)+i:r+i);const o=t;t=this.dpGrid[t][e].parentI,e=this.dpGrid[o][e].parentJ}return new o(n,i,s)}fillScores(){this.scores=[];for(let t=0;t<this.len1;t++){this.scores.push([]);for(let e=0;e<this.len2;e++)this.scores[t].push(this.alignGrid[this.connections[this.seq1.substr(t*this.step,this.step)]][this.connections[this.seq2.substr(e*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 t=0;t<this.len1+1;t++){const t=[];for(let e=0;e<this.len2+1;e++)t.push(new i);this.dpGrid.push(t)}this.fillNeedleman();for(let t=1;t<=this.len1;t++)for(let e=1;e<=this.len2;e++)this.fillOne(t,e);return this.constructResult(this.len1,this.len2)}smithWaterman(){this.dpGrid=[];for(let t=0;t<this.len1+1;t++){const t=[];for(let e=0;e<this.len2+1;e++)t.push(new i);this.dpGrid.push(t)}let t=0,e=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>t&&(t=this.dpGrid[i][o].value,e=i,n=o);return this.constructResult(e,n)}setSequences(t,e){this.seq1=t,this.seq2=e,this.len1=this.seq1.length/this.step,this.len2=this.seq2.length/this.step,this.fillScores()}setGap(t){this.gap=t}setMethod(t=""){"AUTO"==t&&(t=this.typeRec()),this.gridFromName(t)}constructor(t,e,n,i=""){this.setMethod(i),this.setSequences(t,e),this.setGap(n)}}},4954:(t,e,n)=>{"use strict";n.d(e,{a7:()=>m,if:()=>g,BQ:()=>y,nI:()=>f});var i=n(4328),o=n(7389),r=n(6082),s=n(8070),a=n(2003),l=n(439);const c=31;async function h(t,e,n=!1,o){const s=e.getSeqHandler(t);let a;o??=new Map;const l=s.isHelm()?e.getSeqMonomers(t):Object.keys(s.stats.freq).filter((t=>""!==t));for(let t=0;t<l.length;t++)o.has(l[t])||o.set(l[t],`${o.size+1}`);if(s.isHelm())a=await i.functions.call("HELM:getMolFiles",{col:t}),a=function(t,e,n=!1){const i=new Array(t.length);for(let o=0;o<t.length;o++){let r=0,s=0,a="\n Datagrok macromolecule handler\n\n 0 0 0 0 0 0 999 V3000\nM V30 BEGIN CTAB\n";const l=t.get(o);r=l.indexOf("\n",r)+1,r=l.indexOf("\n",r)+1,r=l.indexOf("\n",r)+1;const h=parseInt(l.substring(r,r+3)),u=parseInt(l.substring(r+3,r+6));a+=`M V30 COUNTS ${h} ${u} 0 0 0\n`,a+="M V30 BEGIN ATOM\n";for(let t=0;t<h;t++){r=l.indexOf("\n",r)+1+c,s=l.indexOf(" ",r);const i=l.substring(r,s);a+=n?`M V30 ${t+1} R${e.get(i)} 0.000 0.000 0 0\n`:`M V30 ${t+1} At 0.000 0.000 0 0 MASS=${e.get(i)}\n`}a+="M V30 END ATOM\n",a+="M V30 BEGIN BOND\n";for(let t=0;t<u;t++){r=l.indexOf("\n",r)+1;const e=parseInt(l.substring(r,r+3).trim()),n=parseInt(l.substring(r+3,r+6).trim());a+=`M V30 ${t+1} ${parseInt(l.substring(r+6,r+9).trim())} ${e} ${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(t.length);for(let e=0;e<t.length;e++){const t=u(s.getSplitted(e),o,n);a[e]=t}}return r.Column.fromStrings("monomericMols",a)}function u(t,e,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 ${t.length} ${t.length?t.length-1:0} 0 0 0\n`,i+="M V30 BEGIN ATOM\n";for(let o=0;o<t.length;o++){const r=t.getCanonical(o);r!==l._S&&(i+=n?`M V30 ${o+1} R${e.get(r)} 0.000 0.000 0 0\n`:`M V30 ${o+1} At 0.000 0.000 0 0 MASS=${e.get(r)}\n`)}i+="M V30 END ATOM\n",i+="M V30 BEGIN BOND\n";for(let e=0;e<t.length-1;e++)i+=`M V30 ${e+1} 1 ${e+1} ${e+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(t,e){this.seqHelper=e,this.col=t[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 t=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,t)}updateNotationDiv(){this.units=this.col.meta.units,this.separator=this.col.getTag(a.gp.separator);const t=this.dialog.root.getElementsByClassName("notation-text")[0];t&&(t.textContent=`Notation: ${this.units}`)}createUI(){const t=i.shell.tv.dataFrame;this.columnsInput=o.input.column("Column",{table:t,value:this.col,onValueChanged:t=>{this.col=t,this.updateNotationDiv(),this.updateInputs()},filter:t=>t.semType===r.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 e=r.DataFrame.create(1);e.columns.addNewString(p).init((t=>"")),e.col(p).semType=this.col.semType,e.col(p).meta.units=a.Hi.HELM,this.grid=e.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 t,n=this.units===a.Hi.HELM?e.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)),t=this.units===a.Hi.HELM?await g(n,this.col,this.seqHelper):f(n,this.col),this.col.dataFrame.filter.and(t)})).show()}}function f(t,e,n){const i=n?function(t,e){const n=`${e}`.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),i=t.charAt(0)===e,o=t.charAt(t.length-1)===e,r=t.replace(new RegExp(`^${n}|${n}$`,"g"),"");return i?o?`${n}${r}${n}`:`${n}${r}${n}|${n}${r}$`:o?`^${r}${n}|${n}${r}${n}`:`^${r}${n}|${n}${r}${n}|${n}${r}$`}(t,n):t,o=r.BitSet.create(e.length);for(let n=0;n<e.length;n++){const r=e.get(n);(r.match(i)||r===t)&&o.set(n,!0,!1)}return o}async function g(t,e,n){e.version!==e.temp["last-invalidated-version"]&&await y(e,n,!0);const o=r.Column.string("helm",1).init((e=>t));o.semType=r.SEMTYPE.MACROMOLECULE,o.meta.units=a.Hi.HELM;const s=await h(o,n,!0,e.temp["monomers-dict"]);return(await i.functions.call("Chem:searchSubstructure",{molStringsColumn:e.temp["monomeric-mols"],molString:s.get(0),molBlockFailover:""})).get(0)}async function y(t,e,n){const i=r.TaskBarProgressIndicator.create(`Invalidating molfiles for ${t.name}`);try{await(0,s.cb)(10);const i=new Map,o=await h(t,e,n,i);t.temp["monomeric-mols"]=o,t.temp["monomers-dict"]=i,t.temp["last-invalidated-version"]=t.version}finally{i.close()}}},966:(t,e,n)=>{"use strict";n.d(e,{V:()=>s,l:()=>a});var i=n(4328),o=n(6082),r=n(6723);function s(t,e,n=[],o=[],s=!0){const l=r._package.seqHelper,[c,h]=a(t,e,l,n,o);return s&&!c&&i.shell.warning(h),c}function a(t,e,n,r=[],s=[]){let a=!0,l="";if(t.semType!==o.SEMTYPE.MACROMOLECULE)i.shell.warning(e+" analysis is allowed for Macromolecules semantic type"),a=!1;else{const i=n.getSeqHandler(t),o=i.notation;if(r.length>0&&!r.some((t=>o.toUpperCase()==t.toUpperCase())))l=`${e} + ' analysis is allowed for Macromolecules with notation ${0==r.length?"any notation":`notation${r.length>1?"s":""} ${r.map((t=>`"${t}"`)).join(", ")} `}.`,a=!1;else if(!i.isHelm()){const t=i.alphabet;s.length>0&&!s.some((e=>t.toUpperCase()==e.toUpperCase()))&&(l=`${e} + ' analysis is allowed for Macromolecules with alphabet ${0==s.length?"any alphabet":`alphabet${s.length>1?"s":""} ${s.map((t=>`"${t}"`)).join(", ")}.`}.`,a=!1)}}return[a,l]}},4139:(t,e,n)=>{"use strict";n.d(e,{HX:()=>h,J:()=>a,b9:()=>c,uF:()=>r});var i,o,r,s,a,l=n(8152);!function(t){t.SPLIT_COL="~split",t.ACTIVITY="~activity",t.ACTIVITY_SCALED="activity_scaled",t.ALIGNED_SEQUENCE="~aligned_sequence",t.AMINO_ACID_RESIDUE="AAR",t.POSITION="Pos",t.P_VALUE="pValue",t.MEAN_DIFFERENCE="Mean difference"}(i||(i={})),function(t){t.AAR="AAR",t.POSITION="Pos",t.SELECTION="selection"}(o||(o={})),function(t){t.MONOMER="Monomer",t.MACROMOLECULE_DIFFERENCE="MacromoleculeDifference",t.ACTIVITY="activity",t.ACTIVITY_SCALED="activityScaled"}(r||(r={})),function(t){t.CELL_CHANGING="isCellChanging"}(s||(s={})),function(t){t.SEPARATOR="."}(a||(a={}));const c="3.3.1",h={pepsea:{gapOpen:1.53,gapExtend:0,method:l.ZY[0]},kalign:{gapOpen:-1,gapExtend:-1,terminalGap:-1}}},5433:(t,e,n)=>{"use strict";n.d(e,{C:()=>u});var i=n(6082),o=n(7389),r=n(4328),s=n(1757),a=n.n(s),l=n(2003);let c=null,h=[];function u(t,e){let n=t??r.shell.t.columns.bySemType("Macromolecule");if(!n)throw new Error("No column with Macromolecule semantic type found");let s=e.getSeqHandler(n),u=s.notation;const d=o.divText("Current notation: "+u,{style:{"text-align":"center","font-weight":"bold","font-size":"14px",padding:"5px"}}),p=[l.Hi.FASTA,l.Hi.SEPARATOR,l.Hi.HELM],m=o.input.column("Column",{table:r.shell.t,value:n,filter:t=>t.semType===i.SEMTYPE.MACROMOLECULE,nullable:!1,onValueChanged:t=>(n=t,s=e.getSeqHandler(n),u=s.notation,u===l.Hi.HELM&&(y.value="/"),d.textContent="Current notation: "+u,g=p.filter((t=>t!==u)),v=o.input.choice("Convert to",{value:g[0],items:g,onValueChanged:b}),b(),c?.clear(),void c?.add(o.div([d,m.root,v.root,y.root])))}),f=["-",".","/"];let g=p.filter((t=>t!==u));const y=o.input.choice("Separator",{value:f[0],items:f}),b=()=>{v.value!==l.Hi.SEPARATOR?a()(y.root).hide():a()(y.root).show()};let v=o.input.choice("Convert to",{value:g[0],items:g,onValueChanged:b});b(),v.onChanged.subscribe((()=>{b()})),null==c&&(c=o.dialog("Convert Sequence Notation").add(o.div([d,m.root,v.root,y.root])).onOK((async()=>{const t=v.value,i=t===l.Hi.SEPARATOR?y.value:void 0;await async function(t,e,n,i){const o=e.getSeqHandler(t).convert(n,i);t.dataFrame.columns.add(o);const s=await r.functions.call("Bio:detectMacromolecule",{col:o});return s&&(o.semType=s),await r.data.detectSemanticTypes(t.dataFrame),o}(n,e,t,i)})).show({x:350,y:100}),h.push(c.onClose.subscribe((t=>{h.forEach((t=>{t.unsubscribe()})),h=[],c=null}))))}},536:(t,e,n)=>{"use strict";n.d(e,{Z:()=>o});var i=n(6956);class o{constructor(t){const e=t.split(i.xe).filter((t=>t));e.forEach((t=>this.validateConnectionItem(t))),this.connectionItems=e}connectionItems;validateConnectionItem(t){const e="(PEPTIDE|RNA)",n=new RegExp(`${e}[0-9]+,${e}[0-9]+,[0-9]+:R[0-9]+-[0-9]+:R[0-9]+`,"g");if(!t.match(n))throw new Error(`Cannot parse connection item from ${t}`)}getConnectionData(){const t=[];return this.connectionItems.forEach((e=>{const n=[],i=e.split(",");i[2].split("-").forEach(((t,e)=>{const o=i[e],r=t.split(":"),s={monomerIdx:parseInt(r[0])-1,rGroupId:parseInt(r[1].slice(1))};n.push({polymerId:o,bond:s})})),t.push(n)})),t}}},6956:(t,e,n)=>{"use strict";n.d(e,{mP:()=>r,pk:()=>o,xe:()=>i});const i="|",o="$",r="H"},9099:(t,e,n)=>{"use strict";n.d(e,{f:()=>s});var i=n(536),o=n(6956),r=n(9034);class s{helmString;constructor(t){this.helmString=t;const e=this.helmString.split(o.pk),n=e[0].split(o.xe);this.simplePolymers=n.map((t=>new r.d(t))),this.connectionList=new i.Z(e[1]),this.bondData=this.getBondData(),this.bondedRGroupsMap=this.getBondedRGroupsMap()}bondData;simplePolymers;connectionList;bondedRGroupsMap;getBondedRGroupsMap(){const t=this.simplePolymers.map((t=>t.monomers.length)).reduce(((t,e)=>t+e),0),e=Array.from({length:t},(()=>[]));return this.bondData.forEach((t=>{t.forEach((t=>{const n=t.monomerIdx,i=t.rGroupId;e[n].push(i)}))})),e}toString(){return this.helmString}getPolymerTypeByMonomerIdx(t){return this.getSimplePolymerByMonomerIdx(t).polymerType}getSimplePolymerByMonomerIdx(t){const e=this.getMonomerIdxShifts(),n=Object.values(e).sort(((t,e)=>t-e)).find((e=>t>=e));if(void 0===n)throw new Error(`Cannot find simple polymer for monomer ${t}`);const i=Object.keys(e).find((t=>e[t]===n));return this.simplePolymers.find((t=>t.id===i))}shiftBondMonomerIds(t,e){e.forEach((e=>{e.forEach((e=>{e.monomerIdx+=t}))}))}getMonomerIdxShifts(){const t={};let e=0;return this.simplePolymers.forEach((n=>{t[n.id]=e,e+=n.monomers.length})),t}getBondData(){const t=this.getMonomerIdxShifts(),e=[];return this.simplePolymers.forEach((n=>{const i=n.getBondData(),o=t[n.id];this.shiftBondMonomerIds(o,i),e.push(...i)})),this.connectionList.getConnectionData().forEach((n=>{const i=[];n.forEach((e=>{const n=t[e.polymerId],o=e.bond;o.monomerIdx+=n,i.push(o)})),e.push(i)})),e}}},9034:(t,e,n)=>{"use strict";n.d(e,{d:()=>o});var i=n(8438);class o{simplePolymer;isNucleotideSequence=!1;constructor(t){this.simplePolymer=t,this.polymerType=this.getPolymerType(),this.isNucleotideSequence="RNA"===this.polymerType,this.idx=this.getIdx();const{monomers:e,monomerTypes:n}=this.getMonomerSymbolsAndTypes();this.monomers=e,this.monomerTypes=n}polymerType;monomers;idx;monomerTypes;get id(){return this.polymerType+this.idx.toString()}getPolymerType(){const t=new RegExp("(PEPTIDE|RNA)[0-9]+{"),e=this.simplePolymer.match(t);if(!e)throw new Error(`Unsupported polymer type in ${this.simplePolymer}`);return e[1]}getIdx(){const t=new RegExp(`${this.polymerType}([0-9]+){`),e=this.simplePolymer.match(t);if(!e)throw new Error(`Cannot parse simple polymer id from ${this.simplePolymer}`);return parseInt(e[1])}getMonomerSymbolsAndTypes(){const t=new RegExp(`${this.polymerType}${this.idx}{|}`,"g"),e=this.simplePolymer.replace(t,"").split("."),n=[],o=[];return e.forEach((t=>{if(this.isNucleotideSequence){const e=t.split(/\(|\)/).filter((t=>!!t)).map((t=>(0,i.D)(t)));n.push(...e),e.forEach(((t,e)=>o.push(e%3==1?"Branch":"Backbone")))}else n.push((0,i.D)(t)),o.push("Backbone")})),{monomers:n,monomerTypes:o}}getBondData(){const t=[],e=this.monomerTypes.map(((t,e)=>{if("Backbone"===t)return e})).filter((t=>void 0!==t)),n=this.monomerTypes.map(((t,e)=>{if("Branch"===t)return e})).filter((t=>void 0!==t));for(let n=0;n<e.length-1;n++){const i=e[n],o=e[n+1];t.push([{monomerIdx:i,rGroupId:2},{monomerIdx:o,rGroupId:1}])}for(let e=0;e<n.length;e++){const i=n[e],o=i-1;t.push([{monomerIdx:o,rGroupId:3},{monomerIdx:i,rGroupId:1}])}return t}}},8604:(t,e,n)=>{"use strict";n.d(e,{Es:()=>o,G3:()=>s,gt:()=>r,so:()=>i});const i="System:AppData/Bio/monomer-libraries/",o="System:AppData/Bio/monomer-sets/",r="System:AppData/Bio/tests/libraries/HELMmonomerSchema.json",s={explicit:["HELMCoreLibrary.json","polytool-lib.json"],exclude:[],duplicateMonomerPreferences:{}}},1619:(t,e,n)=>{"use strict";n.d(e,{D:()=>T});var i=n(4328),o=n(6082),r=n(7389),s=n(8070),a=n(2003),l=n(608),c=n(8152),h=n(966),u=n(4139),d=n(5072),p=n.n(d),m=n(7825),f=n.n(m),g=n(7659),y=n.n(g),b=n(5056),v=n.n(b),w=n(540),C=n.n(w),A=n(1113),S=n.n(A),x=n(6369),E={};E.styleTagTransform=S(),E.setAttributes=v(),E.insert=y().bind(null,"head"),E.domAPI=f(),E.insertStyleElement=C(),p()(x.A,E),x.A&&x.A.locals&&x.A.locals;var M=n(6723);async function T(t,e){return new Promise((async(n,a)=>{t.clustersCol??=null,t.pepsea??={},t.pepsea.method??=u.HX.pepsea.method,t.pepsea.gapOpen??=u.HX.pepsea.gapOpen,t.pepsea.gapExtend??=u.HX.pepsea.gapExtend;const h=t.col?.dataFrame??i.shell.t;if(!h){const t="Multiple Sequence Alignment analysis requires a dataset with a macromolecule column.";return void a(new l.Ap(r.divText(t)))}const d=t.col??h.columns.bySemType(o.SEMTYPE.MACROMOLECULE);if(null==d){const t="Multiple Sequence Alignment analysis requires a dataset with a macromolecule column.";return void a(new l.Ap(r.divText(t)))}const p=r.input.choice("Method",{value:t.pepsea.method,items:c.ZY});p.setTooltip("Alignment method");const m=r.input.float("Terminal gap",{value:t?.kalign?.terminalGap});m.setTooltip("Penalty for opening a gap at the beginning or end of the sequence");const f=r.p(`Kalign version: ${u.b9}`,"kalign-version"),g=r.input.float("Gap open",{value:t.pepsea.gapOpen});g.setTooltip("Gap opening penalty at group-to-group alignment");const y=r.input.float("Gap extend",{value:t.pepsea.gapExtend});y.setTooltip("Gap extension penalty to skip the alignment");const b=r.input.bool("Selected Rows Only",{value:!1}),v=r.inputs([g,y,m]),w=r.button("Alignment parameters",(()=>{v.hidden=!v.hidden,[g,y,m].forEach((t=>{t.root.style.removeProperty("max-width"),t.captionLabel.style.removeProperty("max-width")}))}),"Adjust alignment parameters such as penalties for opening and extending gaps");w.classList.add("msa-params-button"),v.hidden=!0,w.prepend(r.icons.settings((()=>null)));const C=[p.root.style],A=[m.root.style,f.style];let S,x=d;const E=r.input.column("Sequence",{table:h,value:d,onValueChanged:async t=>{if(!t||t.semType!==o.SEMTYPE.MACROMOLECULE)return L.disabled=!0,await(0,s.cb)(0),void(E.value=x);x=t,L.disabled=!1,S=await I(E.value,h,e,C,A,p,M,g,y,m,b)},filter:t=>t.semType===o.SEMTYPE.MACROMOLECULE});E.setTooltip("Sequences column to use for alignment");const M=r.input.column("Clusters",{table:h,value:t.clustersCol});M.nullable=!0;const T=r.dialog("MSA").add(E).add(M).add(p).add(v).add(w).add(b).add(f).onOK((async()=>{await _(E,h,S,n,a)})),L=T.getButton("OK");if(E.fireChanged(),t.col)return S=await I(t.col,h,e,C,A,p,M,g,y,m,b),void await _(E,h,S,n,a);T.show()}))}async function _(t,e,n,r,s){let a=null;const l=o.TaskBarProgressIndicator.create("Analyze for MSA ...");try{if(t.fireChanged(),t.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 s("PepSeA container has not started");e.columns.add(a),await i.data.detectSemanticTypes(e),r(a)}catch(t){s(t)}finally{l.close()}}async function I(t,e,n,r,s,d,p,m,f,g,y){try{if(t.semType!==o.SEMTYPE.MACROMOLECULE)return;const i=e.columns.getUnusedName(`msa(${t.name})`);if((0,h.l)(t,t.name,n,[a.Hi.FASTA,a.Hi.SEPARATOR],[a.YI.DNA,a.YI.RNA,a.YI.PT])[0]){L(r,s,"kalign"),m.value=null,f.value=null,g.value=null;const o=n.getSeqHandler(t),c=o.isFasta()?t:o.convert(a.Hi.FASTA);return async()=>await(0,l.eE)(e,c,!1,i,p.value,void 0,void 0,void 0,y.value)}if((0,h.l)(t,t.name,n,[a.Hi.HELM],[])[0])return L(r,s,"pepsea"),m.value??=u.HX.pepsea.gapOpen,f.value??=u.HX.pepsea.gapExtend,async()=>(0,c.GD)(e,t,i,d.value,m.value,f.value,p.value,void 0,y.value);if((0,h.l)(t,t.name,n,[a.Hi.SEPARATOR],[a.YI.UN])[0]){const o=n.getSeqHandler(t).convert(a.Hi.HELM);return L(r,s,"pepsea"),m.value??=u.HX.pepsea.gapOpen,f.value??=u.HX.pepsea.gapExtend,async()=>(0,c.GD)(e,o,i,d.value,m.value,f.value,p.value,void 0,y.value)}return m.value=null,f.value=null,g.value=null,void L(r,s,"kalign")}catch(t){const e=t instanceof Error?t.message:t.toString();i.shell.error(e),M._package.logger.error(e)}}function L(t,e,n){if("kalign"===n){for(const e of t)e.display="none";for(const t of e)t.removeProperty("display")}else{for(const t of e)t.display="none";for(const e of t)e.removeProperty("display")}}},608:(t,e,n)=>{"use strict";n.d(e,{Ap:()=>H,aZ:()=>D,eE:()=>F});var i=n(7389),o=n(6082),r=n(1991),s=n.n(r),a=n(3516),l=n(2003);const c=Symbol("Comlink.proxy"),h=Symbol("Comlink.endpoint"),u=Symbol("Comlink.releaseProxy"),d=Symbol("Comlink.thrown"),p=t=>"object"==typeof t&&null!==t||"function"==typeof t,m=new Map([["proxy",{canHandle:t=>p(t)&&t[c],serialize(t){const{port1:e,port2:n}=new MessageChannel;return f(t,e),[n,[n]]},deserialize:t=>(t.start(),y(t))}],["throw",{canHandle:t=>p(t)&&d in t,serialize({value:t}){let e;return e=t instanceof Error?{isError:!0,value:{message:t.message,name:t.name,stack:t.stack}}:{isError:!1,value:t},[e,[]]},deserialize(t){throw t.isError?Object.assign(new Error(t.value.message),t.value):t.value}}]]);function f(t,e=self){e.addEventListener("message",(function n(i){if(!i||!i.data)return;const{id:o,type:r,path:s}=Object.assign({path:[]},i.data),a=(i.data.argumentList||[]).map(x);let l;try{const e=s.slice(0,-1).reduce(((t,e)=>t[e]),t),n=s.reduce(((t,e)=>t[e]),t);switch(r){case"GET":l=n;break;case"SET":e[s.slice(-1)[0]]=x(i.data.value),l=!0;break;case"APPLY":l=n.apply(e,a);break;case"CONSTRUCT":l=function(t){return Object.assign(t,{[c]:!0})}(new n(...a));break;case"ENDPOINT":{const{port1:e,port2:n}=new MessageChannel;f(t,n),l=function(t,e){return A.set(t,e),t}(e,[e])}break;case"RELEASE":l=void 0;break;default:return}}catch(t){l={value:t,[d]:0}}Promise.resolve(l).catch((t=>({value:t,[d]:0}))).then((t=>{const[i,s]=S(t);e.postMessage(Object.assign(Object.assign({},i),{id:o}),s),"RELEASE"===r&&(e.removeEventListener("message",n),g(e))}))})),e.start&&e.start()}function g(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function y(t,e){return v(t,[],e)}function b(t){if(t)throw new Error("Proxy has been released and is not useable")}function v(t,e=[],n=function(){}){let i=!1;const o=new Proxy(n,{get(n,r){if(b(i),r===u)return()=>E(t,{type:"RELEASE",path:e.map((t=>t.toString()))}).then((()=>{g(t),i=!0}));if("then"===r){if(0===e.length)return{then:()=>o};const n=E(t,{type:"GET",path:e.map((t=>t.toString()))}).then(x);return n.then.bind(n)}return v(t,[...e,r])},set(n,o,r){b(i);const[s,a]=S(r);return E(t,{type:"SET",path:[...e,o].map((t=>t.toString())),value:s},a).then(x)},apply(n,o,r){b(i);const s=e[e.length-1];if(s===h)return E(t,{type:"ENDPOINT"}).then(x);if("bind"===s)return v(t,e.slice(0,-1));const[a,l]=C(r);return E(t,{type:"APPLY",path:e.map((t=>t.toString())),argumentList:a},l).then(x)},construct(n,o){b(i);const[r,s]=C(o);return E(t,{type:"CONSTRUCT",path:e.map((t=>t.toString())),argumentList:r},s).then(x)}});return o}function w(t){return Array.prototype.concat.apply([],t)}function C(t){const e=t.map(S);return[e.map((t=>t[0])),w(e.map((t=>t[1])))]}const A=new WeakMap;function S(t){for(const[e,n]of m)if(n.canHandle(t)){const[i,o]=n.serialize(t);return[{type:"HANDLER",name:e,value:i},o]}return[{type:"RAW",value:t},A.get(t)||[]]}function x(t){switch(t.type){case"HANDLER":return m.get(t.name).deserialize(t.value);case"RAW":return t.value}}function E(t,e,n){return new Promise((i=>{const o=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");t.addEventListener("message",(function e(n){!n.data||!n.data.id||n.data.id!==o||(t.removeEventListener("message",e),i(n.data))})),t.start&&t.start(),t.postMessage(Object.assign({id:o},e),n)}))}const M="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0ICQ9U3ltYm9sKCJDb21saW5rLnByb3h5IiksQT1TeW1ib2woIkNvbWxpbmsuZW5kcG9pbnQiKSxSPVN5bWJvbCgiQ29tbGluay5yZWxlYXNlUHJveHkiKSx5PVN5bWJvbCgiQ29tbGluay50aHJvd24iKSxfPWU9PnR5cGVvZiBlPT0ib2JqZWN0IiYmZSE9PW51bGx8fHR5cGVvZiBlPT0iZnVuY3Rpb24iLEw9e2NhbkhhbmRsZTplPT5fKGUpJiZlWyRdLHNlcmlhbGl6ZShlKXtjb25zdHtwb3J0MTpyLHBvcnQyOml9PW5ldyBNZXNzYWdlQ2hhbm5lbDtyZXR1cm4gdyhlLHIpLFtpLFtpXV19LGRlc2VyaWFsaXplKGUpe3JldHVybiBlLnN0YXJ0KCksQyhlKX19LE89e2NhbkhhbmRsZTplPT5fKGUpJiZ5IGluIGUsc2VyaWFsaXplKHt2YWx1ZTplfSl7bGV0IHI7cmV0dXJuIGUgaW5zdGFuY2VvZiBFcnJvcj9yPXtpc0Vycm9yOiEwLHZhbHVlOnttZXNzYWdlOmUubWVzc2FnZSxuYW1lOmUubmFtZSxzdGFjazplLnN0YWNrfX06cj17aXNFcnJvcjohMSx2YWx1ZTplfSxbcixbXV19LGRlc2VyaWFsaXplKGUpe3Rocm93IGUuaXNFcnJvcj9PYmplY3QuYXNzaWduKG5ldyBFcnJvcihlLnZhbHVlLm1lc3NhZ2UpLGUudmFsdWUpOmUudmFsdWV9fSxFPW5ldyBNYXAoW1sicHJveHkiLExdLFsidGhyb3ciLE9dXSk7ZnVuY3Rpb24gdyhlLHI9c2VsZil7ci5hZGRFdmVudExpc3RlbmVyKCJtZXNzYWdlIixmdW5jdGlvbiBpKHMpe2lmKCFzfHwhcy5kYXRhKXJldHVybjtjb25zdHtpZDpvLHR5cGU6YSxwYXRoOm59PU9iamVjdC5hc3NpZ24oe3BhdGg6W119LHMuZGF0YSksYz0ocy5kYXRhLmFyZ3VtZW50TGlzdHx8W10pLm1hcChtKTtsZXQgbDt0cnl7Y29uc3QgdT1uLnNsaWNlKDAsLTEpLnJlZHVjZSgoZCxwKT0+ZFtwXSxlKSxmPW4ucmVkdWNlKChkLHApPT5kW3BdLGUpO3N3aXRjaChhKXtjYXNlIkdFVCI6bD1mO2JyZWFrO2Nhc2UiU0VUIjp1W24uc2xpY2UoLTEpWzBdXT1tKHMuZGF0YS52YWx1ZSksbD0hMDticmVhaztjYXNlIkFQUExZIjpsPWYuYXBwbHkodSxjKTticmVhaztjYXNlIkNPTlNUUlVDVCI6e2NvbnN0IGQ9bmV3IGYoLi4uYyk7bD16KGQpfWJyZWFrO2Nhc2UiRU5EUE9JTlQiOntjb25zdHtwb3J0MTpkLHBvcnQyOnB9PW5ldyBNZXNzYWdlQ2hhbm5lbDt3KGUscCksbD1OKGQsW2RdKX1icmVhaztjYXNlIlJFTEVBU0UiOmw9dm9pZCAwO2JyZWFrO2RlZmF1bHQ6cmV0dXJufX1jYXRjaCh1KXtsPXt2YWx1ZTp1LFt5XTowfX1Qcm9taXNlLnJlc29sdmUobCkuY2F0Y2godT0+KHt2YWx1ZTp1LFt5XTowfSkpLnRoZW4odT0+e2NvbnN0W2YsZF09Uyh1KTtyLnBvc3RNZXNzYWdlKE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSxmKSx7aWQ6b30pLGQpLGE9PT0iUkVMRUFTRSImJihyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGkpLE0ocikpfSl9KSxyLnN0YXJ0JiZyLnN0YXJ0KCl9ZnVuY3Rpb24gVChlKXtyZXR1cm4gZS5jb25zdHJ1Y3Rvci5uYW1lPT09Ik1lc3NhZ2VQb3J0In1mdW5jdGlvbiBNKGUpe1QoZSkmJmUuY2xvc2UoKX1mdW5jdGlvbiBDKGUscil7cmV0dXJuIGIoZSxbXSxyKX1mdW5jdGlvbiBoKGUpe2lmKGUpdGhyb3cgbmV3IEVycm9yKCJQcm94eSBoYXMgYmVlbiByZWxlYXNlZCBhbmQgaXMgbm90IHVzZWFibGUiKX1mdW5jdGlvbiBiKGUscj1bXSxpPWZ1bmN0aW9uKCl7fSl7bGV0IHM9ITE7Y29uc3Qgbz1uZXcgUHJveHkoaSx7Z2V0KGEsbil7aWYoaChzKSxuPT09UilyZXR1cm4oKT0+ZyhlLHt0eXBlOiJSRUxFQVNFIixwYXRoOnIubWFwKGM9PmMudG9TdHJpbmcoKSl9KS50aGVuKCgpPT57TShlKSxzPSEwfSk7aWYobj09PSJ0aGVuIil7aWYoci5sZW5ndGg9PT0wKXJldHVybnt0aGVuOigpPT5vfTtjb25zdCBjPWcoZSx7dHlwZToiR0VUIixwYXRoOnIubWFwKGw9PmwudG9TdHJpbmcoKSl9KS50aGVuKG0pO3JldHVybiBjLnRoZW4uYmluZChjKX1yZXR1cm4gYihlLFsuLi5yLG5dKX0sc2V0KGEsbixjKXtoKHMpO2NvbnN0W2wsdV09UyhjKTtyZXR1cm4gZyhlLHt0eXBlOiJTRVQiLHBhdGg6Wy4uLnIsbl0ubWFwKGY9PmYudG9TdHJpbmcoKSksdmFsdWU6bH0sdSkudGhlbihtKX0sYXBwbHkoYSxuLGMpe2gocyk7Y29uc3QgbD1yW3IubGVuZ3RoLTFdO2lmKGw9PT1BKXJldHVybiBnKGUse3R5cGU6IkVORFBPSU5UIn0pLnRoZW4obSk7aWYobD09PSJiaW5kIilyZXR1cm4gYihlLHIuc2xpY2UoMCwtMSkpO2NvbnN0W3UsZl09RihjKTtyZXR1cm4gZyhlLHt0eXBlOiJBUFBMWSIscGF0aDpyLm1hcChkPT5kLnRvU3RyaW5nKCkpLGFyZ3VtZW50TGlzdDp1fSxmKS50aGVuKG0pfSxjb25zdHJ1Y3QoYSxuKXtoKHMpO2NvbnN0W2MsbF09RihuKTtyZXR1cm4gZyhlLHt0eXBlOiJDT05TVFJVQ1QiLHBhdGg6ci5tYXAodT0+dS50b1N0cmluZygpKSxhcmd1bWVudExpc3Q6Y30sbCkudGhlbihtKX19KTtyZXR1cm4gb31mdW5jdGlvbiBEKGUpe3JldHVybiBBcnJheS5wcm90b3R5cGUuY29uY2F0LmFwcGx5KFtdLGUpfWZ1bmN0aW9uIEYoZSl7Y29uc3Qgcj1lLm1hcChTKTtyZXR1cm5bci5tYXAoaT0+aVswXSksRChyLm1hcChpPT5pWzFdKSldfWNvbnN0IFA9bmV3IFdlYWtNYXA7ZnVuY3Rpb24gTihlLHIpe3JldHVybiBQLnNldChlLHIpLGV9ZnVuY3Rpb24geihlKXtyZXR1cm4gT2JqZWN0LmFzc2lnbihlLHtbJF06ITB9KX1mdW5jdGlvbiBTKGUpe2Zvcihjb25zdFtyLGldb2YgRSlpZihpLmNhbkhhbmRsZShlKSl7Y29uc3RbcyxvXT1pLnNlcmlhbGl6ZShlKTtyZXR1cm5be3R5cGU6IkhBTkRMRVIiLG5hbWU6cix2YWx1ZTpzfSxvXX1yZXR1cm5be3R5cGU6IlJBVyIsdmFsdWU6ZX0sUC5nZXQoZSl8fFtdXX1mdW5jdGlvbiBtKGUpe3N3aXRjaChlLnR5cGUpe2Nhc2UiSEFORExFUiI6cmV0dXJuIEUuZ2V0KGUubmFtZSkuZGVzZXJpYWxpemUoZS52YWx1ZSk7Y2FzZSJSQVciOnJldHVybiBlLnZhbHVlfX1mdW5jdGlvbiBnKGUscixpKXtyZXR1cm4gbmV3IFByb21pc2Uocz0+e2NvbnN0IG89VSgpO2UuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsZnVuY3Rpb24gYShuKXshbi5kYXRhfHwhbi5kYXRhLmlkfHxuLmRhdGEuaWQhPT1vfHwoZS5yZW1vdmVFdmVudExpc3RlbmVyKCJtZXNzYWdlIixhKSxzKG4uZGF0YSkpfSksZS5zdGFydCYmZS5zdGFydCgpLGUucG9zdE1lc3NhZ2UoT2JqZWN0LmFzc2lnbih7aWQ6b30sciksaSl9KX1mdW5jdGlvbiBVKCl7cmV0dXJuIG5ldyBBcnJheSg0KS5maWxsKDApLm1hcCgoKT0+TWF0aC5mbG9vcihNYXRoLnJhbmRvbSgpKk51bWJlci5NQVhfU0FGRV9JTlRFR0VSKS50b1N0cmluZygxNikpLmpvaW4oIi0iKX1jb25zdCBXPWFzeW5jKCk9PldlYkFzc2VtYmx5LnZhbGlkYXRlKG5ldyBVaW50OEFycmF5KFswLDk3LDExNSwxMDksMSwwLDAsMCwxLDUsMSw5NiwwLDEsMTIzLDMsMiwxLDAsMTAsMTAsMSw4LDAsNjUsMCwyNTMsMTUsMjUzLDk4LDExXSkpLGs9ImVhZ2VyIix4PSJsYXp5IixqPXtzc3c6WyJzaW1kIl0sbWluaW1hcDI6WyJzaW1kIl19LHQ9e3Rvb2xzOltdLGNvbmZpZzp7fSxmaWxlczpbXSxiYXNlOnt9LGZzOnt9LGFzeW5jIGluaXQoKXtpZih0LnRvb2xzLmxlbmd0aD09PTApdGhyb3ciRXhwZWN0aW5nIGF0IGxlYXN0IDEgdG9vbC4iO2lmKG5ldyBTZXQodC50b29scy5tYXAocj0+YCR7ci50b29sfS8ke3IucHJvZ3JhbXx8ci50b29sfWApKS5zaXplIT09dC50b29scy5sZW5ndGgpdGhyb3ciRm91bmQgZHVwbGljYXRlIHRvb2xzOyBjYW4gb25seSBoYXZlIGVhY2ggdG9vbC9wcm9ncmFtIGNvbWJpbmF0aW9uIGF0IG1vc3Qgb25jZS4iO2lmKHQuYmFzZT10LnRvb2xzLmZpbmQocj0+ci5yZWluaXQhPT0hMCksIXQuYmFzZSl0aHJvdyJDb3VsZCBub3QgZmluZCBhIHRvb2wgd2l0aCBgcmVpbml0OiBmYWxzZWAgdG8gdXNlIGFzIHRoZSBiYXNlIG1vZHVsZS4gVG8gZml4IHRoaXMgaXNzdWUsIGluY2x1ZGUgdGhlIHRvb2wgYGJhc2UvMS4wLjBgIHdoZW4gaW5pdGlhbGl6aW5nIEFpb2xpLiI7cmV0dXJuIHQuYmFzZS5pc0Jhc2VNb2R1bGU9ITAsYXdhaXQgdGhpcy5fc2V0dXAodC5iYXNlKSxhd2FpdCB0aGlzLl9pbml0TW9kdWxlcygpLHQuX2xvZygiUmVhZHkiKSwhMH0sYXN5bmMgX2luaXRNb2R1bGVzKCl7YXdhaXQgUHJvbWlzZS5hbGwodC50b29scy5tYXAodGhpcy5fc2V0dXApKSxhd2FpdCB0aGlzLl9zZXR1cEZTKCl9LG1vdW50KGU9W10pe2NvbnN0IHI9YCR7dC5jb25maWcuZGlyU2hhcmVkfSR7dC5jb25maWcuZGlyRGF0YX1gLGk9YCR7dC5jb25maWcuZGlyU2hhcmVkfSR7dC5jb25maWcuZGlyTW91bnRlZH1gO2xldCBzPVtdLG89W10sYT1bXTshQXJyYXkuaXNBcnJheShlKSYmIShlIGluc3RhbmNlb2YgRmlsZUxpc3QpJiYoZT1bZV0pLHQuX2xvZyhgTW91bnRpbmcgJHtlLmxlbmd0aH0gZmlsZXNgKTtmb3IobGV0IG4gb2YgZSl7aWYobiBpbnN0YW5jZW9mIEZpbGV8fChuPT1udWxsP3ZvaWQgMDpuLmRhdGEpaW5zdGFuY2VvZiBCbG9iJiZuLm5hbWV8fHR5cGVvZihuPT1udWxsP3ZvaWQgMDpuLmRhdGEpPT0ic3RyaW5nIiYmbi5uYW1lKXR5cGVvZihuPT1udWxsP3ZvaWQgMDpuLmRhdGEpPT0ic3RyaW5nIiYmKG4uZGF0YT1uZXcgQmxvYihbbi5kYXRhXSx7dHlwZToidGV4dC9wbGFpbiJ9KSkscy5wdXNoKG4pO2Vsc2UgaWYobi5uYW1lJiZuLnVybClvLnB1c2gobik7ZWxzZSBpZih0eXBlb2Ygbj09InN0cmluZyImJm4uc3RhcnRzV2l0aCgiaHR0cCIpKW49e3VybDpuLG5hbWU6bi5zcGxpdCgiLy8iKS5wb3AoKS5yZXBsYWNlKC9cLy9nLCItIil9LG8ucHVzaChuKTtlbHNlIHRocm93J0Nhbm5vdCBtb3VudCBmaWxlKHMpIHNwZWNpZmllZC4gTXVzdCBiZSBhIEZpbGUsIEJsb2IsIGEgVVJMIHN0cmluZywgb3IgeyBuYW1lOiAiZmlsZS50eHQiLCBkYXRhOiAic3RyaW5nIiB9Lic7YS5wdXNoKG4ubmFtZSl9dHJ5e3QuZnMudW5tb3VudChpKX1jYXRjaHt9Zm9yKGxldCBuIG9mIG8pdC5mcy5jcmVhdGVMYXp5RmlsZShyLG4ubmFtZSxuLnVybCwhMCwhMCk7cmV0dXJuIHQuZmlsZXM9dC5maWxlcy5jb25jYXQocyksdC5iYXNlLm1vZHVsZS5GUy5tb3VudCh0LmJhc2UubW9kdWxlLldPUktFUkZTLHtmaWxlczp0LmZpbGVzLmZpbHRlcihuPT5uIGluc3RhbmNlb2YgRmlsZSksYmxvYnM6dC5maWxlcy5maWx0ZXIobj0+KG49PW51bGw/dm9pZCAwOm4uZGF0YSlpbnN0YW5jZW9mIEJsb2IpfSxpKSxzLm1hcChuPT57Y29uc3QgYz1gJHtpfS8ke24ubmFtZX1gLGw9YCR7cn0vJHtuLm5hbWV9YDt0cnl7dC5mcy51bmxpbmsobCl9Y2F0Y2h7fXQuX2xvZyhgQ3JlYXRpbmcgc3ltbGluazogJHtsfSAtLT4gJHtjfWApLHQuZnMuc3ltbGluayhjLGwpfSksYS5tYXAobj0+YCR7cn0vJHtufWApfSxhc3luYyBleGVjKGUscj1udWxsKXtpZih0Ll9sb2coYEV4ZWN1dGluZyAlYyR7ZX0lYyBhcmdzPSR7cn1gLCJjb2xvcjpkYXJrYmx1ZTsgZm9udC13ZWlnaHQ6Ym9sZCIsIiIpLCFlKXRocm93IkV4cGVjdGluZyBhIGNvbW1hbmQiO2xldCBpPWU7cj09bnVsbCYmKHI9ZS5zcGxpdCgiICIpLGk9ci5zaGlmdCgpKTtjb25zdCBzPXQudG9vbHMuZmluZChhPT57dmFyIGM7bGV0IG49aTtyZXR1cm4oKGM9YT09bnVsbD92b2lkIDA6YS5mZWF0dXJlcyk9PW51bGw/dm9pZCAwOmMuc2ltZCk9PT0hMCYmKG49YCR7bn0tc2ltZGApLGEucHJvZ3JhbT09bn0pO2lmKHM9PW51bGwpdGhyb3dgUHJvZ3JhbSAke2l9IG5vdCBmb3VuZC5gO3Muc3Rkb3V0PSIiLHMuc3RkZXJyPSIiLHMubG9hZGluZz09eCYmKHMubG9hZGluZz1rLGF3YWl0IHRoaXMuX2luaXRNb2R1bGVzKCkpO3RyeXtzLm1vZHVsZS5jYWxsTWFpbihyKX1jYXRjaChhKXtjb25zb2xlLmVycm9yKGEpfXRyeXtzLm1vZHVsZS5GUy5jbG9zZShzLm1vZHVsZS5GUy5zdHJlYW1zWzFdKSxzLm1vZHVsZS5GUy5jbG9zZShzLm1vZHVsZS5GUy5zdHJlYW1zWzJdKX1jYXRjaHt9cy5tb2R1bGUuRlMuc3RyZWFtc1sxXT1zLm1vZHVsZS5GUy5vcGVuKCIvZGV2L3N0ZG91dCIsInciKSxzLm1vZHVsZS5GUy5zdHJlYW1zWzJdPXMubW9kdWxlLkZTLm9wZW4oIi9kZXYvc3RkZXJyIiwidyIpO2xldCBvPXtzdGRvdXQ6cy5zdGRvdXQsc3RkZXJyOnMuc3RkZXJyfTtyZXR1cm4gdC5jb25maWcucHJpbnRJbnRlcmxlYXZlZCYmKG89cy5zdGRvdXQpLHMucmVpbml0PT09ITAmJmF3YWl0IHRoaXMucmVpbml0KHMudG9vbCksb30sY2F0KGUpe3JldHVybiB0Ll9maWxlb3AoImNhdCIsZSl9LGxzKGUpe3JldHVybiB0Ll9maWxlb3AoImxzIixlKX0sZG93bmxvYWQoZSl7cmV0dXJuIHQuX2ZpbGVvcCgiZG93bmxvYWQiLGUpfSxwd2QoKXtyZXR1cm4gdC5mcy5jd2QoKX0sY2QoZSl7Zm9yKGxldCByIG9mIHQudG9vbHMpIXIubW9kdWxlfHxyLm1vZHVsZS5GUy5jaGRpcihlKX0sbWtkaXIoZSl7cmV0dXJuIHQuZnMubWtkaXIoZSksITB9LHJlYWQoe3BhdGg6ZSxsZW5ndGg6cixmbGFnOmk9InIiLG9mZnNldDpzPTAscG9zaXRpb246bz0wfSl7Y29uc3QgYT10LmZzLm9wZW4oZSxpKSxuPW5ldyBVaW50OEFycmF5KHIpO3JldHVybiB0LmZzLnJlYWQoYSxuLHMscixvKSx0LmZzLmNsb3NlKGEpLG59LHdyaXRlKHtwYXRoOmUsYnVmZmVyOnIsZmxhZzppPSJ3KyIsb2Zmc2V0OnM9MCxwb3NpdGlvbjpvPTB9KXtjb25zdCBhPXQuZnMub3BlbihlLGkpO3QuZnMud3JpdGUoYSxyLHMsci5sZW5ndGgsbyksdC5mcy5jbG9zZShhKX0sYXN5bmMgcmVpbml0KGUpe2NvbnN0IHI9dC50b29scy5maW5kKHM9PnMudG9vbD09ZSksaT10LmJhc2UubW9kdWxlLkZTLmN3ZCgpO09iamVjdC5hc3NpZ24ocixyLmNvbmZpZyksci5yZWFkeT0hMSxhd2FpdCB0aGlzLmluaXQoKSxyLmlzQmFzZU1vZHVsZSYmdGhpcy5tb3VudCgpLHRoaXMuY2QoaSl9LF9zdGRpblR4dDoiIixfc3RkaW5QdHI6MCxnZXQgc3RkaW4oKXtyZXR1cm4gdC5fc3RkaW5UeHR9LHNldCBzdGRpbihlPSIiKXt0Ll9sb2coYFNldHRpbmcgc3RkaW4gdG8gJWMke2V9JWNgLCJjb2xvcjpkYXJrYmx1ZSIsIiIpLHQuX3N0ZGluVHh0PWUsdC5fc3RkaW5QdHI9MH0sYXN5bmMgX3NldHVwKGUpe2lmKGUucmVhZHkpcmV0dXJuO2lmKHQuX2xvZyhgU2V0dGluZyB1cCAke2UudG9vbH0gKGJhc2UgPSAke2UuaXNCYXNlTW9kdWxlPT09ITB9KS4uLmApLGUuY29uZmlnPU9iamVjdC5hc3NpZ24oe30sZSksZS51cmxQcmVmaXh8fChlLnVybFByZWZpeD1gJHt0LmNvbmZpZy51cmxDRE59LyR7ZS50b29sfS8ke2UudmVyc2lvbn1gKSxlLnByb2dyYW18fChlLnByb2dyYW09ZS50b29sKSxlLmZlYXR1cmVzfHwoZS5mZWF0dXJlcz17fSwoaltlLnByb2dyYW1dfHxbXSkuaW5jbHVkZXMoInNpbWQiKSYmKGF3YWl0IFcoKT8oZS5wcm9ncmFtKz0iLXNpbWQiLGUuZmVhdHVyZXMuc2ltZD0hMCk6dC5fbG9nKGBXZWJBc3NlbWJseSBTSU1EIGlzIG5vdCBzdXBwb3J0ZWQgaW4gdGhpcyBicm93c2VyOyB3aWxsIGxvYWQgbm9uLVNJTUQgdmVyc2lvbiBvZiAke2UucHJvZ3JhbX0uYCkpKSxlLmlzQmFzZU1vZHVsZSYmKGUubG9hZGluZz1rKSxlLmxvYWRpbmc9PT14KXt0Ll9sb2coYFdpbGwgbGF6eS1sb2FkICR7ZS50b29sfTsgc2tpcHBpbmcgaW5pdGlhbGl6YXRpb24uYCk7cmV0dXJufXNlbGYuaW1wb3J0U2NyaXB0cyhgJHtlLnVybFByZWZpeH0vJHtlLnByb2dyYW19LmpzYCksZS5tb2R1bGU9YXdhaXQgTW9kdWxlKHt0aGlzUHJvZ3JhbTplLnByb2dyYW0sbG9jYXRlRmlsZTooaSxzKT0+YCR7ZS51cmxQcmVmaXh9LyR7aX1gLHN0ZGluOigpPT50Ll9zdGRpblB0cjx0LnN0ZGluLmxlbmd0aD90LnN0ZGluLmNoYXJDb2RlQXQodC5fc3RkaW5QdHIrKyk6KHQuc3RkaW49IiIsbnVsbCkscHJpbnQ6aT0+e3QuY29uZmlnLnByaW50U3RyZWFtP3Bvc3RNZXNzYWdlKHt0eXBlOiJiaW93YXNtIix2YWx1ZTp7c3Rkb3V0Oml9fSk6ZS5zdGRvdXQrPWkrYApgfSxwcmludEVycjppPT57Y29uc3Qgcz10LmNvbmZpZy5wcmludEludGVybGVhdmVkPyJzdGRvdXQiOiJzdGRlcnIiO3QuY29uZmlnLnByaW50U3RyZWFtP3Bvc3RNZXNzYWdlKHt0eXBlOiJiaW93YXNtIix2YWx1ZTp7W3NdOml9fSk6ZVtzXSs9aStgCmB9fSk7Y29uc3Qgcj1lLm1vZHVsZS5GUztlLmlzQmFzZU1vZHVsZT8odC5fbG9nKGBTZXR0aW5nIHVwICR7ZS50b29sfSB3aXRoIGJhc2UgbW9kdWxlIGZpbGVzeXN0ZW0uLi5gKSxyLm1rZGlyKHQuY29uZmlnLmRpclNoYXJlZCw1MTEpLHIubWtkaXIoYCR7dC5jb25maWcuZGlyU2hhcmVkfS8ke3QuY29uZmlnLmRpckRhdGF9YCw1MTEpLHIubWtkaXIoYCR7dC5jb25maWcuZGlyU2hhcmVkfS8ke3QuY29uZmlnLmRpck1vdW50ZWR9YCw1MTEpLHIuY2hkaXIoYCR7dC5jb25maWcuZGlyU2hhcmVkfS8ke3QuY29uZmlnLmRpckRhdGF9YCksdC5mcz1yKToodC5fbG9nKGBTZXR0aW5nIHVwICR7ZS50b29sfSB3aXRoIGZpbGVzeXN0ZW0uLi5gKSxyLm1rZGlyKHQuY29uZmlnLmRpclNoYXJlZCksci5tb3VudChlLm1vZHVsZS5QUk9YWUZTLHtyb290OnQuY29uZmlnLmRpclNoYXJlZCxmczp0LmZzfSx0LmNvbmZpZy5kaXJTaGFyZWQpLHIuY2hkaXIodC5mcy5jd2QoKSkpLGUuc3Rkb3V0PSIiLGUuc3RkZXJyPSIiLGUucmVhZHk9ITB9LGFzeW5jIF9zZXR1cEZTKCl7Y29uc3QgZT10LmZzO2ZvcihsZXQgciBvZiB0LnRvb2xzKXtpZighci5yZWFkeSljb250aW51ZTtjb25zdCBpPXIubW9kdWxlLkZTLHM9YC8ke3IudG9vbH1gLG89YCR7dC5jb25maWcuZGlyU2hhcmVkfSR7c31gOyFpLmFuYWx5emVQYXRoKHMpLmV4aXN0c3x8ZS5hbmFseXplUGF0aChvKS5leGlzdHN8fCh0Ll9sb2coYE1vdW50aW5nICR7c30gb250byAke3QuYmFzZS50b29sfSBmaWxlc3lzdGVtIGF0ICR7b31gKSxlLm1rZGlyKG8pLGUubW91bnQodC5iYXNlLm1vZHVsZS5QUk9YWUZTLHtyb290OnMsZnM6aX0sbykpfX0sX2ZpbGVvcChlLHIpe3QuX2xvZyhgUnVubmluZyAke2V9ICR7cn1gKTtjb25zdCBpPXQuZnMuYW5hbHl6ZVBhdGgocik7aWYoIWkuZXhpc3RzKXJldHVybiB0Ll9sb2coYEZpbGUgJHtyfSBub3QgZm91bmQuYCksITE7c3dpdGNoKGUpe2Nhc2UiY2F0IjpyZXR1cm4gdC5mcy5yZWFkRmlsZShyLHtlbmNvZGluZzoidXRmOCJ9KTtjYXNlImxzIjpyZXR1cm4gdC5mcy5pc0ZpbGUoaS5vYmplY3QubW9kZSk/dC5mcy5zdGF0KHIpOnQuZnMucmVhZGRpcihyKTtjYXNlImRvd25sb2FkIjpjb25zdCBzPW5ldyBCbG9iKFt0aGlzLmNhdChyKV0pO3JldHVybiBVUkwuY3JlYXRlT2JqZWN0VVJMKHMpfXJldHVybiExfSxfbG9nKGUpe2lmKCF0LmNvbmZpZy5kZWJ1ZylyZXR1cm47bGV0IHI9Wy4uLmFyZ3VtZW50c107ci5zaGlmdCgpLGNvbnNvbGUubG9nKGAlY1tXZWJXb3JrZXJdJWMgJHtlfWAsImZvbnQtd2VpZ2h0OmJvbGQiLCIiLC4uLnIpfX07dyh0KX0pKCk7Cg==",T=typeof window<"u"&&window.Blob&&new Blob([atob(M)],{type:"text/javascript;charset=utf-8"});function _(){const t=T&&(window.URL||window.webkitURL).createObjectURL(T);try{return t?new Worker(t):new Worker("data:application/javascript;base64,"+M)}finally{t&&(window.URL||window.webkitURL).revokeObjectURL(t)}}const I={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 L{constructor(t,e={}){if(null==t)throw"Expecting array of tools as input to Aioli constructor.";return Array.isArray(t)||(t=[t]),e=Object.assign({},I,e),t=t.map(this._parseTool),"stg"===e.env&&(e.urlCDN=e.urlCDNStg),this.tools=t,this.config=e,null!=this.config.callback&&(this.callback=this.config.callback),delete this.config.callback,this.init()}async init(){const t=new _;this.callback&&(t.onmessage=t=>{"biowasm"===t.data.type&&this.callback(t.data.value)});const e=y(t);return e.tools=this.tools,e.config=this.config,await e.init(),e}_parseTool(t){if("string"!=typeof t)return t;const e=t.split("/");if(2!=e.length&&3!=e.length)throw"Expecting '<tool>/<version>' or '<tool>/<program>/<version>'";return{tool:e[0],program:3==e.length?e[1]:e[0],version:e[e.length-1]}}}var N=n(3629);class P{static getAvailableScales(){return Object.entries(this.scales).map((([t,e])=>t))}static getScale(t){return(0,N.vA)(!(void 0===this.scales[t]),`Scale '${t}' was not found.`),this.scales[t]}}P.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 ${constructor(t="categorial"){this.aa2num=P.getScale(t),this.num2aa={},Object.entries(this.aa2num).forEach((([t,e])=>this.num2aa[e]=t))}static _truncateSequence(t){let e=0,n=t.length;const i=["NH2","COOH"];if(t.startsWith(i[0])){const n=i[0].length;(0,N.vA)("-"==t[n],`Wrong sequence format: ${i[0]} without following '-' in '${t}'.`),e=n}if(t.endsWith(i[1])){const e=i[1].length+1;(0,N.vA)("-"==t[n-e],`Wrong sequence format: ${i[1]} without '-' precending in '${t}'.`),n-=e}return t.substring(e,n)}static _dropDefises(t){return t.replace(/(-)([^-]+)/g,"$2")}static clean(t){return $._dropDefises($._truncateSequence(t))}encode(t){const e=t.length,n=new Array(e).fill(0);for(let i=0;i<e;++i){const e=t[i];(0,N.vA)(e in this.aa2num,`Unknown char '${e}' found in sequence '${t}'`),n[i]=this.encodeLettter(e)}return n}encodeLettter(t){return this.aa2num[t]}decode(t){let e="";for(let n=0;n<t.length;++n){const i=t[n];(0,N.vA)(i in this.num2aa,`Unknown code '${i}' found in vector '${t}'`),e+=this.num2aa[i]}return e}}var R=n(4139);const k="input.fa",O="result.fasta";class H extends Error{element;constructor(t,e){super(t.innerText,e),this.element=t}}function G(t){return t.reduce(((t,e,n)=>t+`>sample${n+1}\n${e}\n`),"")}async function F(t,e,n=!1,i="",r=null,s,c,h,u){let d=e.toList();n&&(d=d.map((t=>$.clean(t).replace(/\-/g,""))));const p=e.length;r??=o.Column.string("Clusters",p).init("0"),r.type!=o.COLUMN_TYPE.STRING&&(r=r.convertTo(o.TYPE.STRING)),r.compact();const m=r.categories,f=r.getRawData(),g=new Array(m.length),y=new Array(m.length);if(u){const e=t.selection;if(0===e.length)throw new Error("No selected rows in the table.");for(let t=-1;-1!==(t=e.findNext(t,!0));){const e=f[t];(g[e]??=[]).push(d[t]),(y[e]??=[]).push(t)}}else for(let t=0;t<p;++t){const e=f[t];(g[e]??=[]).push(d[t]),(y[e]??=[]).push(t)}D(y,m);const b=await new L(["base/1.0.0",{tool:"kalign",version:R.b9,reinit:!0}]),v=o.Column.string(i,p);for(let t=0;t<m.length;++t){const e=g[t];if(!e||0===e.length)continue;const n=G(e);await b.fs.writeFile(k,n);const i=`${void 0!==s?` --gpo ${s}`:""}${void 0!==c?` --gpe ${c}`:""}${void 0!==h?` --tgpe ${h}`:""}`,o=await b.exec(`kalign ${k} -f fasta -o ${O}${i}`);console.warn(o);const r=await b.cat(O);if(!r){const t=B(o,1);throw new Error(t)}const l=new a.m(r).sequencesArray,u=y[t];for(let t=0;t<l.length;++t)v.set(u[t],l[t])}const w=e.meta.units,C=e.getTag(l.gp.alphabet);return v.meta.units=w,v.setTag(l.gp.aligned,"SEQ.MSA"),v.setTag(l.gp.alphabet,C),v.semType=o.SEMTYPE.MACROMOLECULE,v}function B(t,e){const n=[],i=/^.+ERROR : (.+)$/gm;let o;for(;null!=(o=i.exec(t))&&(void 0===e||n.length<e);)n.push(o[1]);return n.join("\n")}function D(t,e){const n=t.map(((t,e)=>[t,e])).filter((([t,e])=>1==t.length)).map((([t,e])=>e));if(n.length>0){const t=i.div([i.divText(`MSA analysis is not available on single sequence clusters #${n.length}:`),...s()(n).take(3).map((t=>{let o=e[t];return o.length>25&&(o=o.slice(0,25)+"..."),i.divText(`"${o}"${t<n.length-1?", ":"."}`)})).toArray(),...n.length>3?[i.divText("...")]:[]]);throw new H(t)}}},8152:(t,e,n)=>{"use strict";n.d(e,{GD:()=>d,ZY:()=>h});var i=n(4328),o=n(6082),r=n(2003),s=n(608),a=n(4139),l=n(6723);const c=new class{dcName="bio";async getDockerContainer(){return await i.dapi.docker.dockerContainers.filter(this.dcName).first()}},h=["mafft --auto","mafft","linsi","ginsi","einsi","fftns","fftnsi","nwns","nwnsi"],u=["AlignedSeq","AlignedSubpeptide","HELM","ID","PolymerID"];async function d(t,e,n,i="ginsi",l=1.53,h=0,d=null,m,f=!1){const g=await c.getDockerContainer(),y=e.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,v=d.getRawData(),w=new Array(b.length),C=new Array(b.length);if(f){const n=t.selection;for(let t=-1;-1!==(t=n.findNext(t,!0));){const n=v[t];if(!b[n])continue;const i=n,o=e.get(t);o&&((w[i]??=[]).push({ID:t.toString(),HELM:o}),(C[n]??=[]).push(t))}}else for(let t=0;t<y;++t){const n=v[t];if(!b[n])continue;const i=n,o=e.get(t);o&&((w[i]??=[]).push({ID:t.toString(),HELM:o}),(C[n]??=[]).push(t))}(0,s.aZ)(C,b);const A=new Array(y).fill(null);for(const t of w){if(!t||0===t.length)continue;const e=(await p(g.id,t,i,l,h,m)).Alignment;for(const t of e)A[parseInt(t.ID)]=Object.entries(t).filter((t=>!u.includes(t[0]))).map((t=>"-"!==t[1]?t[1]:"")).join(a.J.SEPARATOR)}const S=o.Column.fromStrings(n,A);return S.meta.units=r.Hi.SEPARATOR,S.setTag(r.gp.separator,a.J.SEPARATOR),S.setTag(r.gp.aligned,"SEQ.MSA"),S.setTag(r.gp.alphabet,r.YI.UN),S.setTag(r.gp.alphabetIsMultichar,"true"),S.semType=o.SEMTYPE.MACROMOLECULE,S}async function p(t,e,n,o,r,s){const a={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(e)},c=`/align?method=${n}&gap_open=${o}&gap_extend=${r}`,h=window.performance.now(),u=await i.dapi.docker.dockerContainers.fetchProxy(t,c,a),d=window.performance.now();l._package.logger.debug(`Bio: requestAlignedObjects() dockerContainers.fetchProxy(), ET: ${d-h} ms`);const p="application/json"===u.headers.get("content-type");if(!u.ok&&p){const t=await u.json(),e=t["pepsea-error"];if(e)throw new Error(`PepSeA error: ${e}`);const n=t["datagrok-error"];if(n)throw new Error(`Datagrok error: ${n}`);throw new Error(u.statusText)}if(!u.ok&&!p){const t=await u.text();throw new Error(`Error: ${t}`)}if(!p){const t=await u.text();throw new Error(`Error: PepSeA expected JSON response, got '${t}'.`)}const m=await u.json();if("pepsea-stderr"in m){const t=m["pepsea-stderr"];s?.warning(t)}return m}},3890:(t,e,n)=>{"use strict";n.d(e,{TE:()=>h});var i=n(6082),o=n(7389),r=n(4328),s=n(1991),a=n.n(s),l=n(6723);const c=60;function h(){const t=r.shell.tv.grid,e=a().count(0).take(t.columns.length).map((e=>t.columns.byIndex(e))).filter((t=>!!t.column&&t.column.semType!==i.SEMTYPE.MACROMOLECULE)).toArray(),n=e.find((t=>-1!==t.name.toLowerCase().indexOf("id"))),s=n?[n.name]:[],h=o.input.multiChoice("Seq id columns",{value:s,items:e.map((t=>t.name))}),d=a().count(0).take(t.columns.length).map((e=>t.columns.byIndex(e))).filter((t=>{const e=t.column;return!(!e||e.semType!==i.SEMTYPE.MACROMOLECULE)&&l._package.seqHelper.getSeqHandler(e).isFasta()})).toArray(),p=d.length>0?d[0].name:[],m=o.input.choice("Seq column",{value:p,items:d.map((t=>t.name))}),f=o.input.int("FASTA line width",{value:c});o.dialog({title:"Save as FASTA"}).add(o.inputs([h,m,f])).onOK((()=>{const e=h.value?h.value.map((e=>t.columns.byName(e).column)):[],n=m.value?t.columns.byName(m.value).column:null,i=f.value??c;n||r.shell.warning("Seq column is mandatory to save as FASTA.");const o=function(t,e,n=c,i="\n"){const o=[];for(let r=0;r<e.length;r++){const s=t.map((t=>t.get(r).toString())).join("|"),a=u(e.getSplitted(r),n);o.push(`>${s}${i}`);for(const t of a)o.push(`${t}${i}`)}return"".concat(...o)}(e,l._package.seqHelper.getSeqHandler(n),i),s=document.createElement("a");s.setAttribute("href",`data:text/plain;charset=utf-8,${encodeURIComponent(o)}`),s.setAttribute("download",`${t.dataFrame.name}.fasta`),s.click()})).show()}function u(t,e=c){let n=0;const i=t.length,o=[];for(;n<i;){const i=a().count(n).take(Math.min(t.length-n,e)).map((e=>t.getOriginal(e))).toArray(),r=i.map((t=>t.length>1?`[${t}]`:t)).reduce(((t,e)=>t+e),"");o.push(r),n+=i.length}return o}},8754:(t,e,n)=>{"use strict";n.d(e,{V:()=>h});var i=n(4328),o=n(6077),r=n(2003),s=n(8312),a=n(5553),l=n(966),c=n(330);async function h(t,e,n,h,u,d,p){let m;if(n){const n=await(0,s.Q)(),i=n.getSeqHandler(e);let o,a;i.isHelm()?o=e:(a=e.name,e.name=`__${a}`,o=i.convert(r.Hi.HELM),o.name=a,t.columns.add(o,!1));try{m=await n.helmToAtomicLevel(o,!0,!0,u)}finally{o!==e&&(t.columns.remove(o.name),e.name=a)}}else{if(!(0,l.l)(e,"To Atomic Level",d)[0])return{molCol:null,warnings:["Column is not suitable"]};m=await(0,o.C4)(t,e,u,d,p)}if(m.molCol){const o=(0,c.qj)(t,e.name);m.molCol.name=o,t.columns.add(m.molCol,!0),await(0,a.Qc)(e,m.molCol,u,d,p,n),m.molCol.setTag(".sequence-src-highlight-monomers",String(h)),await i.data.detectSemanticTypes(t)}return m}},4870:(t,e,n)=>{"use strict";n.d(e,{Kd:()=>a,Ku:()=>s,me:()=>r});var i=n(4328),o=n(6082);function r(){const t=i.shell.t.columns.bySemTypeAll(o.SEMTYPE.MACROMOLECULE);return null===t?(i.shell.error("Current table does not contain macromolecules"),[]):t}function s(t,e){t.innerHTML="",t.append(e)}function a(t,e,n,i,o){const r=()=>{const o=t.col(e);o&&(o.width=n),i&&(t.props.rowHeight=i)};if(o)return void r();const s=t.onAfterDrawOverlay.subscribe((()=>{s.unsubscribe(),setTimeout((()=>{r()}))}))}},250:(t,e,n)=>{"use strict";n.d(e,{n5:()=>C,oP:()=>_});var i=n(4328),o=n(7389),r=n(6082),s=n(1757),a=n.n(s),l=n(1991),c=n.n(l),h=n(1858),u=n(2003),d=n(4326);function p(t){var e;return"string"==typeof t||t instanceof String?t:("object"==typeof t||t instanceof Object)&&"$thrownJsError"in t?p(t.$thrownJsError):t instanceof Error?null!==(e=t.stack)&&void 0!==e?e:t.message:t.toString()}var m=n(8070),f=n(7602),g=n(439),y=n(6882);var b=n(6723);function v(t,e,n){return Math.abs(t-e)<=n}var w,C,A=n(6307);HTMLCanvasElement.prototype.getCursorPosition=function(t,e){const n=this.getBoundingClientRect();return new r.Point((t.clientX-n.left)*e,(t.clientY-n.top)*e)},r.Rect.prototype.contains=function(t,e){return this.left<=t&&t<=this.right&&this.top<=e&&e<=this.bottom};class S{rowCount;value;plotValue;valueList=null;valueIdx=0;bounds;constructor(t=0,e){this.value=this.rowCount=t,this.bounds=e}push(t){this.valueList||(this.valueList=new Array(this.rowCount),this.valueIdx=0),this.valueList[this.valueIdx]=t,++this.valueIdx}aggregate(t){this.value=t(this.valueList)??0,this.valueList=null}}class x{pos;name;_label;get label(){return this._label?this._label:this.name}_freqs;sumRowCount=0;sumPlotValue;sumPlotValueForHeight;constructor(t,e,n,i){this.pos=t,this.name=e,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(t){return t in this._freqs}getFreq(t){let e=this._freqs[t];return e||(e=this._freqs[t]=new S),e}aggregate(t){const e=function(t){return e=>{const n=function(t){let e;const n="agg";return e=t instanceof Float32Array?r.Column.fromFloat32Array(n,t):t instanceof Int32Array?r.Column.fromInt32Array(n,t):r.Column.fromList(r.COLUMN_TYPE.FLOAT,n,t),e}(e);return n.aggregate(t)}}(t);for(const[t,n]of Object.entries(this._freqs))n.aggregate(e)}getMinValue(){return Math.min(...Object.values(this._freqs).map((t=>t.value)))}calcPlotValue(t){for(const e of Object.values(this._freqs))e.plotValue=e.value-t}calcHeights(t){this.sumPlotValue=0;for(const t of Object.values(this._freqs))this.sumPlotValue+=t.plotValue;if(this.sumPlotValueForHeight=0,t===d.fH.Entropy){const t=Object.keys(this._freqs).length,e=.01*this.sumPlotValue,n=e/t;for(const t of Object.values(this._freqs)){const i=(t.plotValue+n)/(this.sumPlotValue+e);this.sumPlotValueForHeight+=-i*Math.log2(i)}}else if(t===d.fH.full)for(const[t,e]of Object.entries(this._freqs)){const t=e.plotValue/this.sumPlotValue;this.sumPlotValueForHeight+=t}}calcScreen(t,e,n,i,o,s,a,l,c){const h=i===d.fH.Entropy?n*(o-this.sumPlotValueForHeight)/o:n;let u=c*l+(n-h-1);const p=Object.entries(this._freqs).sort(((t,e)=>t[0]!==g._S&&e[0]!==g._S?e[1].value-t[1].value:t[0]===g._S&&e[0]===g._S?0:t[0]===g._S?-1:1));for(const[n,i]of p){const n=h*i.plotValue/this.sumPlotValue;i.bounds=new r.Rect((t-e)*l*s,u,a*l,n),u+=n}}render(t,e,n,i,o,r,s){for(const[a,l]of Object.entries(this._freqs))if(a!==g._S){const c=(0,u.zS)(a,s),h=l.bounds,d=h.left;let p=y.S$;r&&(p=r.getMonomerTextColor(o,a)),t.resetTransform(),t.strokeStyle="lightgray",t.lineWidth=1,t.rect(d,h.top,h.width,h.height),t.fillStyle=p,t.textAlign="left",t.font=e;const m=t.measureText(c);t.setTransform(h.width/m.width,0,0,h.height/i,d,h.top),t.fillText(c,0,-n)}}getMonomerAt(t,e){const n=Object.entries(this._freqs).find((([n,i])=>i.bounds.contains(t,e)));return n?n[0]:void 0}buildCompositionTable(t,e){if("-"in this._freqs)throw new Error("Unexpected monomer symbol '-'.");return(0,A.F)(Object.assign({},...Object.entries(this._freqs).map((([t,e])=>({[t]:e.rowCount})))),t,e)}}!function(t){t.STYLE="Style",t.BEHAVIOR="Behavior",t.LAYOUT="Layout",t.DATA="Data"}(w||(w={})),function(t){t.sequenceColumnName="sequenceColumnName",t.valueAggrType="valueAggrType",t.valueColumnName="valueColumnName",t.startPositionName="startPositionName",t.endPositionName="endPositionName",t.skipEmptySequences="skipEmptySequences",t.skipEmptyPositions="skipEmptyPositions",t.shrinkEmptyTail="shrinkEmptyTail",t.backgroundColor="backgroundColor",t.positionHeight="positionHeight",t.positionWidth="positionWidth",t.verticalAlignment="verticalAlignment",t.horizontalAlignment="horizontalAlignment",t.fixWidth="fixWidth",t.fitArea="fitArea",t.minHeight="minHeight",t.maxHeight="maxHeight",t.maxMonomerLetters="maxMonomerLetters",t.showPositionLabels="showPositionLabels",t.positionMarginState="positionMarginState",t.positionMargin="positionMargin",t.filterSource="filterSource"}(C||(C={}));const E=d.Fo;var M;!function(t){t[t.None=0]="None",t[t.Render=1]="Render",t[t.Layout=1]="Layout",t[t.Freqs=2]="Freqs"}(M||(M={}));const T=new class{render=20};class _ extends r.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(C.sequenceColumnName,E.sequenceColumnName,{category:w.DATA,semType:r.SEMTYPE.MACROMOLECULE,description:"Column with sequences"});const t=[r.AGG.KEY,r.AGG.PIVOT,r.AGG.MISSING_VALUE_COUNT,r.AGG.SKEW,r.AGG.KURT,r.AGG.SELECTED_ROWS_COUNT],e=Object.values(r.AGG).filter((e=>!t.includes(e)));this.valueColumnName=this.string(C.valueColumnName,E.valueColumnName,{category:w.DATA,columnTypeFilter:"numerical",description:"Column with values used in aggregation for position heights"}),this.valueAggrType=this.string(C.valueAggrType,E.valueAggrType,{category:w.DATA,choices:e,description:"Aggregation method for value column"}),this.startPositionName=this.string(C.startPositionName,E.startPositionName,{category:w.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(C.endPositionName,E.endPositionName,{category:w.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(C.skipEmptySequences,E.skipEmptySequences,{category:w.DATA,description:"Skip sequences which are empty in all positions"}),this.skipEmptyPositions=this.bool(C.skipEmptyPositions,E.skipEmptyPositions,{category:w.DATA,description:"Skip positions which are empty in all sequences"}),this.shrinkEmptyTail=this.bool(C.shrinkEmptyTail,E.shrinkEmptyTail,{category:w.DATA,description:"Skip empty tail (if found for all sequences within a subset) in WebLogo"}),this.backgroundColor=this.int(C.backgroundColor,E.backgroundColor,{category:w.STYLE,description:"Background color of WebLogo canvas"}),this.positionHeight=this.string(C.positionHeight,E.positionHeight,{category:w.STYLE,choices:Object.values(d.fH),description:"Monomer-Position height mode. Entropy of 100%(full height)"}),this._positionWidth=this.positionWidth=this.float(C.positionWidth,E.positionWidth,{category:w.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(C.verticalAlignment,E.verticalAlignment,{category:w.LAYOUT,choices:Object.values(d.Lp)}),this.horizontalAlignment=this.string(C.horizontalAlignment,E.horizontalAlignment,{category:w.LAYOUT,choices:Object.values(d.P4)}),this.fixWidth=this.bool(C.fixWidth,E.fixWidth,{category:w.LAYOUT,userEditable:!1}),this.fitArea=this.bool(C.fitArea,E.fitArea,{category:w.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(C.minHeight,E.minHeight,{category:w.LAYOUT,editor:"slider",min:10,max:250,description:"Minimum height of WebLogo"}),this.maxHeight=this.int(C.maxHeight,E.maxHeight,{category:w.LAYOUT,editor:"slider",min:25,max:Math.max(window.innerHeight??0,1e3),nullable:!0,description:"Maximum height of WebLogo"}),this.maxMonomerLetters=this.int(C.maxMonomerLetters,E.maxMonomerLetters,{category:w.LAYOUT,editor:"slider",min:1,max:40,description:"Maximum monomer letters to display before shortening"}),this.showPositionLabels=this.bool(C.showPositionLabels,E.showPositionLabels,{category:w.LAYOUT,description:"Show position labels on top of the weblogo"}),this.positionMarginState=this.string(C.positionMarginState,E.positionMarginState,{category:w.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(C.positionMargin,n,{category:w.LAYOUT,min:0,max:25,description:"Margin between positions in WebLogo"}),this.filterSource=this.string(C.filterSource,E.filterSource,{category:w.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%",(0,b.getMonomerLibHelper)().then((t=>{this.monomerLib=t.getMonomerLib(),this.render(M.Render,"monomerLib"),this.subs.push(this.monomerLib.onChanged.subscribe((()=>{this.render(M.Render,"monomerLib changed")})))})),this.viewSyncer=new f.g(b._package.logger)}static viewerCounter=-1;viewerId=++_.viewerCounter;toLog(){return`WebLogoViewer<${this.viewerId}>`}setData(){const t=`${this.toLog()}.setData()`;b._package.logger.debug(`${t}, in`),this.viewSyncer.sync(`${t}`,(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(`${t}, out`)}viewSyncer;setDataInProgress=!1;viewSubs=[];async destroyView(){for(const t of this.viewSubs)t.unsubscribe();this.viewSubs=[];const t=this.dataFrame?"data":"null";b._package.logger.debug(`${this.toLog()}.destroyView( dataFrame = ${t} ) start`),this.host.remove(),this.msgHost=void 0,this.host=void 0,b._package.logger.debug(`${this.toLog()}.destroyView() end`)}async buildView(){const t=this.dataFrame?"data":"null";b._package.logger.debug(`${this.toLog()}.buildView( dataFrame = ${t} ) start`),window.devicePixelRatio,this.viewSubs.push(r.debounce(this.renderRequest,T.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,h.fromEvent)(this.canvas,"mousemove").subscribe(this.canvasOnMouseMove.bind(this))),this.viewSubs.push((0,h.fromEvent)(this.canvas,"mousedown").subscribe(this.canvasOnMouseDown.bind(this))),this.viewSubs.push((0,h.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(t){const e={width:t.target.clientWidth,height:t.target.clientHeight};this.lastSize.width==e.width&&this.lastSize.height==e.height||(b._package.logger.debug(`${this.toLog()}.rootOnSizeChanged(), ${JSON.stringify(e)}, start `),this.render(M.Layout,"rootOnSizeChanged")),this.lastSize=e}updateEditors(){this.props.getProperty(C.valueColumnName).choices=c()(this.dataFrame.columns.numerical).map((t=>t.name)).toArray()}updateSeqCol(){if(this.dataFrame&&(this.seqCol=this.sequenceColumnName?this.dataFrame.col(this.sequenceColumnName):null,null==this.seqCol&&(this.seqCol=(0,u.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(t){throw this.seqCol=null,this.error=t instanceof Error?t:new Error(t.toString()),t}this.seqCol||(this.seqHandler=null,this.positionNames=[],this.positionLabels=[],this.startPosition=-1,this.endPosition=-1)}}getFilter(){let t;switch(this.filterSource){case d.lT.Filtered:t=this.dataFrame.filter;break;case d.lT.Selected:t=0===this.dataFrame.selection.trueCount?this.dataFrame.filter:this.dataFrame.selection}return t}setSliderVisibility(t){t?(this.slider.root.style.display="inherit",this.visibleSlider=!0):(this.slider.root.style.display="none",this.visibleSlider=!1)}calcLayout(t){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(t):this.calcLayoutNoFitArea(t),this.slider.root.style.width=`${this.host.clientWidth}px`)}calcLayoutFixWidth(t){if(!this.host||!this.canvas||!this.slider)return;this.host.classList.add("bio-wl-fixWidth"),this.canvas.classList.add("bio-wl-fitArea");const e=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=`${e}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=e*t,this.canvas.height=n*t}calcLayoutNoFitArea(t){if(!this.host||!this.canvas||!this.slider)return;let e=this._positionWidthWithMargin*this.Length,n=Math.min(this.root.clientWidth,e);this.fitArea&&e<this.root.clientWidth&&(this._positionWidth=Math.floor(this._positionWidth*this.root.clientWidth/e),this._positionWidthWithMargin=this._positionWidth+this.positionMarginValue,e=this._positionWidthWithMargin*this.Length,n=Math.min(this.root.clientWidth,e));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=e>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 t=Math.min(Math.max(0,this.slider.min),this.Length-.001),e=Math.min(Math.max(0,this.slider.max),this.Length-.001);const n=this.canvas.clientWidth/this._positionWidthWithMargin;e=Math.min(Math.max(t,0)+n,this.Length-.001),t=Math.max(0,Math.min(e,this.Length-.001)-n),this.safeUpdateSlider(0,Math.max(this.Length-.001),t,e)}else this.safeUpdateSlider(0,Math.max(0,this.Length-.001),0,Math.max(0,this.Length-.001));this.canvas.width=n*t,this.canvas.height=i*t}calcLayoutFitArea(t){if(!this.host||!this.canvas||!this.slider)return;const e=this._positionWidth*this.Length,n=Math.min(Math.max(this.minHeight,this.root.clientHeight),this.maxHeight??this.root.clientHeight),i=e>0?(this.root.clientWidth-this.positionMarginValue*this.Length)/e:0,o=this.root.clientHeight/n,r=Math.max(1,Math.min(i,o));this._positionWidth=this.positionWidth*r,this._positionWidthWithMargin=this._positionWidth+this.positionMarginValue;const s=(this._positionWidth+this.positionMarginValue)*this.Length,a=r*n,l=Math.min(this.root.clientWidth,s);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=s>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 t=Math.min(Math.max(0,this.slider.min),this.Length-.001),e=Math.min(Math.max(0,this.slider.max),this.Length-.001);const n=this.root.clientWidth/this._positionWidthWithMargin;e=Math.min(Math.max(t,0)+n,this.Length-.001),t=Math.max(0,Math.min(e,this.Length-.001)-n),this.safeUpdateSlider(0,Math.max(0,this.Length-.001),t,e)}else this.safeUpdateSlider(0,Math.max(0,this.Length-.001),0,Math.max(0,this.Length-.001));this.canvas.width=l*t,this.canvas.height=a*t}safeUpdateSlider(t,e,n,i){v(t,this.slider.minRange,.1)&&v(e,this.slider.maxRange,.1)&&v(n,this.slider.min,.1)&&v(i,this.slider.max,.1)||this.slider.setValues(t,e,n,i)}onPropertyChanged(t){switch(super.onPropertyChanged(t),t.name){case C.sequenceColumnName:this.updateSeqCol();break;case C.sequenceColumnName:case C.startPositionName:case C.endPositionName:case C.filterSource:case C.shrinkEmptyTail:case C.skipEmptyPositions:case C.positionHeight:case C.valueColumnName:case C.valueAggrType:this.render(M.Freqs,`onPropertyChanged( ${t.name} )`);break;case C.minHeight:case C.maxHeight:case C.maxMonomerLetters:case C.positionWidth:case C.showPositionLabels:case C.fixWidth:case C.fitArea:case C.horizontalAlignment:case C.verticalAlignment:case C.positionMargin:case C.positionMarginState:this.render(M.Layout,`onPropertyChanged(${t.name})`);break;case C.backgroundColor:this.render(M.Render,`onPropertyChanged(${t.name})`)}}onTableAttached(){b._package.logger.debug(`${this.toLog()}.onTableAttached(), `),super.onTableAttached(),this.setData()}detach(){const t=`${this.toLog()}.detach()`;b._package.logger.debug(`${t}, in`);const e=super.detach.bind(this);this.viewSyncer.sync(`${t}`,(async()=>{this.setDataInProgress||(this.viewed&&(await this.destroyView(),this.viewed=!1),e())})),b._package.logger.debug(`${t}, out`)}_onSizeChanged=new h.Subject;get onSizeChanged(){return this._onSizeChanged}_onFreqsCalculated=new h.Subject;get onFreqsCalculated(){return this._onFreqsCalculated}_onLayoutCalculated=new h.Subject;get onLayoutCalculated(){return this._onLayoutCalculated}getMonomer(t,e){const n=t.x,i=Math.floor(t.x/(this._positionWidthWithMargin*e)+Math.floor(this.slider.min)),o=this.positions[i];if(!o)return[null,null,null];const r=o.getMonomerAt(n,t.y);return void 0===r?[o,null,null]:[o,r,o.getFreq(r)]}_nullSequence(t="X"){return this.skipEmptySequences?"":new Array(this.Length).fill(t).join("")}_removeEmptyPositions(){this.skipEmptyPositions&&(this.positions=c()(this.positions).filter((t=>!t.hasMonomer(g._S)||t.getFreq(g._S).rowCount!==t.sumRowCount)).toArray())}requestedRenderLevel=M.Freqs;renderRequest=new h.Subject;renderRequestSub;render(t,e){b._package.logger.debug(`${this.toLog()}.render( recalcLevelVal=${t}, reason='${e}' )`),this.requestedRenderLevel=Math.max(this.requestedRenderLevel,t),this.renderRequest.next(this.requestedRenderLevel)}async renderInt(t){if(b._package.logger.debug(`${this.toLog()}.render.renderInt( renderLevel=${t} ), start `),this.msgHost&&(this.msgHost.style.display="none"),!this.seqCol||!this.dataFrame||null==this.host||null==this.slider)return;const e=window.devicePixelRatio,n=this.showPositionLabels?12:0;if(t>=M.Freqs&&(()=>{if(b._package.logger.debug(`${this.toLog()}.render.calculateFreqsInt(), start `),!this.host||!this.seqCol||!this.dataFrame)return;const t=this.seqCol.getTag(u.gp.positionNames),e=this.seqCol.getTag(u.gp.positionLabels);let n;!t&&this.endPositionName&&/\d+/.test(this.endPositionName)?n=Number(this.endPositionName):t&&this.endPositionName&&(n=t.split(u.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((t=>{const e=this.seqHandler.getSplitted(t,n);return i.get(t)&&e?e.length:0})).reduce(((t,e)=>Math.max(t,e)),0);this.positionNames=t?t.split(u.z1).map((t=>t.trim())):[...Array(o).keys()].map((t=>`${t+1}`)),this.positionLabels=e?e.split(u.z1).map((t=>t.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 s=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 t=0;t<s;t++){const e=this.positionNames[this.startPosition+t],n=this.positionLabels?this.positionLabels[this.startPosition+t]:void 0;this.positions[t]=new x(this.startPosition+t,e,{},{label:n})}this.dataFrame.rowCount;const l=i.getSelectedIndexes();for(let t=0;t<s;++t){for(const e of l){const n=this.seqHandler.getSplitted(e),i=t+this.startPosition<n.length?n.getCanonical(this.startPosition+t):this.seqHandler.defaultGapOriginal,o=this.seqHandler.defaultGapOriginal===i?g._S:i,r=this.positions[t],s=r.getFreq(o);++r.sumRowCount,s.value=++s.rowCount}if(this.valueAggrType===r.AGG.TOTAL_COUNT)continue;let e=null;try{e=this.dataFrame.getCol(this.valueColumnName),e.matches("numerical")||(e=null)}catch{e=null}if(e){for(const n of l){const i=this.seqHandler.getSplitted(n),o=t+this.startPosition<i.length?i.getCanonical(this.startPosition+t):this.seqHandler.defaultGapOriginal,r=this.seqHandler.defaultGapOriginal===o?g._S:o,s=e.get(n);this.positions[t].getFreq(r).push(s)}this.positions[t].aggregate(this.valueAggrType)}}const h=this.valueAggrType===r.AGG.TOTAL_COUNT?0:Math.min(0,Math.min(...this.positions.map((t=>t.getMinValue()))));for(let t=0;t<s;++t)this.positions[t].calcPlotValue(h),this.positions[t].calcHeights(this.positionHeight);this._removeEmptyPositions(),this._onFreqsCalculated.next()})(),this.calcLayout(e),-1===this.startPosition)return;const o=Math.max(Math.floor(this.slider.min),0),s=Math.min(this.positions.length-1,Math.floor(this.slider.max));t>=M.Layout&&((t,e,n,o)=>{b._package.logger.debug(`${this.toLog()}.render.calculateLayoutInt(), start `);const s=this.canvas.height-o*n;let a;if(this.valueAggrType===r.AGG.TOTAL_COUNT){const t=this.seqHandler.getAlphabetSize();this.positionHeight==d.fH.Entropy&&null==t&&i.shell.error("WebLogo: alphabet is undefined."),a=Math.log2(t)}else a=Math.max(...c().count(t).takeWhile((t=>t<=e)).map((t=>this.positions[t].sumPlotValueForHeight)));for(let i=t;i<=e;++i)i in this.positions?this.positions[i].calcScreen(i,this.slider.min,s,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,s,window.devicePixelRatio,n);const a=this.canvas.getContext("2d");if(a){a.save();try{this.Length,a.resetTransform(),a.fillStyle=function(t){const e=r.Color.a(t);return`#${(16777215&t).toString(16).padStart(6,"0")}`+e.toString(16).padStart(2,"0")}(this.backgroundColor),a.fillRect(0,0,this.canvas.width,this.canvas.height),a.textBaseline=this.textBaseline;const t=10*e;a.resetTransform(),a.fillStyle="black",a.textAlign="center",a.font=`${t.toFixed(1)}px Roboto, Roboto Local, sans-serif`,n>0&&this.positions.length>0&&function(t,e,n,i,o,r,s,a){t.save();try{t.textAlign="center";let l=null,c=null;for(let e=Math.floor(s);e<=Math.floor(a);e++){const n=r[e],i=t.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 h=l<i*e-2?1:(i*e-2)/l;for(let l=Math.floor(s);l<=Math.floor(a);l++){const a=r[l],u=(l-s)*n*e+i*e/2,d=(o*e-c)/2;t.setTransform(h,0,0,1,u,d),t.measureText(a.label),t.fillText(a.label,0,0)}}finally{t.restore()}}(a,e,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,h=this.seqHandler.defaultBiotype;for(let t=o;t<=s;t++)this.positions[t].render(a,i,l,c,h,this.monomerLib,this.maxMonomerLetters)}finally{a.restore()}b._package.logger.debug(`${this.toLog()}.render.renderInt( recalcLevel=${t} ), end`)}}renderRequestOnDebounce(t){const e=`${this.toLog()}.renderRequestOnDebounce()`;"HTML"!==a()(this.root).offsetParent().get()[0]?.tagName?(this.requestedRenderLevel=M.None,this.viewSyncer.sync(e,(async()=>{await this.renderInt(t)}))):b._package.logger.warning(`${e}, $(this.root).offsetParent() is the 'HTML' tag.`)}_lastWidth;_lastHeight;sliderOnValuesChanged(t){try{const t={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 e=t.max-t.min,n=this.canvas.offsetWidth/e-this.positionMarginValue;v(n,this.positionWidth,.1)?this.render(M.Layout,"sliderOnValuesChanged"):this.getProperty(C.positionWidth)?.set(this,n)}}catch(t){const e=p(t);b._package.logger.error(`${this.toLog()}.sliderOnValuesChanged() error:\n`+e)}}dataFrameFilterOnChanged(t){b._package.logger.debug(`${this.toLog()}.dataFrameFilterChanged()`);try{this.filterSource===d.lT.Filtered&&this.render(M.Freqs,"dataFrameFilterOnChanged")}catch(t){const e=p(t);b._package.logger.error(`${this.toLog()}.dataFrameFilterOnChanged() error:\n`+e)}}dataFrameSelectionOnChanged(t){b._package.logger.debug(`${this.toLog()}.dataFrameSelectionOnChanged()`);try{this.filterSource===d.lT.Selected&&this.render(M.Freqs,"dataFrameSelectionOnChanged")}catch(t){const e=p(t);b._package.logger.error(`${this.toLog()}.dataFrameSelectionOnChanged() error:\n`+e)}}canvasOnMouseMove(t){if(!this.monomerLib||!this.seqHandler)return;const e=window.devicePixelRatio;try{const n=t,i=this.canvas.getCursorPosition(n,e),[s,a]=this.getMonomer(i,e),l=this.showPositionLabels?12*e:0;if(null!==s&&null===a&&0<=i.y&&i.y<=l){const t=[o.divText(`Position ${s.label}`)];if(this.valueAggrType===r.AGG.TOTAL_COUNT){const e=this.seqHandler.defaultBiotype;t.push(s.buildCompositionTable(e,this.monomerLib))}const e=o.divV(t);e.style.maxHeight="80vh",o.tooltip.show(e,n.x+16,n.y+16)}else if(null!==s&&a&&this.dataFrame&&this.seqCol&&this.seqHandler){const t=s.getFreq(a),e=[o.div(`${a}`),o.div(`${t.rowCount} rows`)];this.valueAggrType!==r.AGG.TOTAL_COUNT&&e.push(o.div(`${this.valueAggrType}: ${t.value.toFixed(3)}`));const i=o.divV(e);o.tooltip.show(i,n.x+16,n.y+16)}else o.tooltip.hide()}catch(t){const e=p(t);b._package.logger.error(`${this.toLog()}.canvasOnMouseMove() error:\n`+e)}}canvasOnMouseDown(t){try{const e=t,n=window.devicePixelRatio,[i,o]=this.getMonomer(this.canvas.getCursorPosition(e,n),n);if(null!==i&&null!==o&&this.dataFrame&&this.seqCol&&this.seqHandler){const t=r.BitSet.create(this.dataFrame.selection.length,(t=>function(t,e,n,i,o,r){const s=e.getSplitted(i),a=r.pos<s.length?s.getCanonical(r.pos):null;return null!==a&&a===o}(this.dataFrame,this.seqHandler,this.getFilter(),t,o,i)));this.dataFrame.selection.init((e=>t.get(e)))}}catch(t){const e=p(t);b._package.logger.error(`${this.toLog()}.canvasOnMouseDown() error:\n`+e)}}canvasOnWheel(t){const e=window.devicePixelRatio;try{if(!this.visibleSlider)return;const n=this.canvas.width/(this._positionWidthWithMargin*e),i=t.deltaY/100*Math.max(Math.floor(n/5),1);this.slider.scrollBy(this.slider.min+i)}catch(t){const e=p(t);b._package.logger.error(`${this.toLog()}.canvasOnWheel() error:\n`+e)}}_onRendered=new h.Subject;get onRendered(){return this._onRendered}invalidate(t){const e=`invalidate(${t?` <- ${t} `:""})`,n=`${this.toLog()}.${e}`;this.render(M.None,e),this.viewSyncer.sync(`${n}`,(async()=>{this._onRendered.next()}))}async awaitRendered(t=5e3){await(0,m.PE)(this.onRendered,(()=>{}),(()=>{this.invalidate()}),t);const e=this.viewSyncer.resetErrors();if(e.length>0)throw e[0]}}},1687:(t,e,n)=>{"use strict";n.d(e,{_i:()=>x});var i=n(7389),o=n(6082),r=n(4328),s=n(1991),a=n.n(s),l=n(1858),c=n(2003),h=n(8070),u=n(7602),d=n(4954),p=n(4574),m=n(1757),f=n.n(m),g=n(9124),y=n(9192),b=n(4870),v=n(6723);class w extends p.O{seqHelper;emptyProps=new p.n("",void 0,v._package.logger);helmEditor;_filterPanel=i.div("",{style:{cursor:"pointer"}});logger;static viewerCounter=-1;viewerId=++w.viewerCounter;viewerToLog(){return`HelmBioFilter<${this.viewerId}>`}get type(){return"HelmBioFilter"}constructor(t){super(),this.seqHelper=t,this.logger=v._package.logger}viewSubs=[];async detach(){await super.detach();for(const t of this.viewSubs)t.unsubscribe()}async attach(){this.viewerToLog();try{const t=await(0,g.b2)();let e,n;this.helmEditor=t.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((()=>{e=i.div(),n=t.createWebEditorApp(e,this.props.substructure),i.dialog({showHeader:!1,showFooter:!0}).add(e).onOK((()=>{try{const t=n.canvas.getHelm(!0).replace(/<\/span>/g,"").replace(/<span style='background:#bbf;'>/g,"");this.props=new p.n(t,void 0,v._package.logger)}catch(t){this.logger.error(t)}finally{f()(e).empty(),e=null,n=null}})).onCancel((()=>{f()(e).empty(),e=null,n=null})).show({modal:!0,fullScreen:!0})}))),this.viewSubs.push(i.onSizeChanged(this._filterPanel).subscribe((t=>{try{if(n){const t=n.canvas.getHelm(!0).replace(/<\/span>/g,"").replace(/<span style='background:#bbf;'>/g,"");this.updateFilterPanel(t)}}catch(t){const[e,n]=(0,y.AP)(t);this.logger.error(e,void 0,n)}})))}catch(t){const[e,n]=(0,y.AP)(t),o=this._filterPanel;o.innerText="error",o.classList.add("d4-error"),i.tooltip.bind(o,e)}}applyProps(){this.helmEditor&&this.updateFilterPanel(this.props.substructure)}get filterPanel(){return this._filterPanel}updateFilterPanel(t){if(!this.helmEditor)throw new Error("helmEditor is not created, the filter is not in dom yet");const e=this._filterPanel.parentElement.clientWidth<100?100:this._filterPanel.parentElement.clientWidth,n=e/2;if(t)(0,b.Ku)(this._filterPanel,this.helmEditor.host),this.helmEditor.editor.setHelm(t),this.helmEditor.resizeEditor(e,n);else{const t=i.divText("Click to edit","helm-substructure-filter");(0,b.Ku)(this._filterPanel,t)}}async substructureSearch(t){const e=`${this.viewerToLog()}.substructureSearch( column = <${t.name}> )`;v._package.logger.debug(`${e}, start`);try{return await(0,h.cb)(10),await(0,d.if)(this.props.substructure,t,this.seqHelper)}finally{v._package.logger.debug(`${e}, end`)}}}const C="bio-substructure-filter";class A{props;filterId;dataFrameId;columnName;bitset;constructor(t,e,n,i,o){this.props=t,this.filterId=e,this.dataFrameId=n,this.columnName=i,this.bitset=o}}class S extends p.n{separator;constructor(t,e,n){super(t,!1,n),this.separator=e,this.readOnly=!0}}class x extends o.Filter{seqHelper;logger;bioFilter=null;bitset=null;loader;notation=void 0;filterSyncer;get calculating(){return"initial"==this.loader.style.display}set calculating(t){this.loader.style.display=t?"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 t=this.column.length;return t<500?0:t>1e4?1e3:Math.floor((t-500)/9500*1e3)}constructor(t,e){super(),this.seqHelper=t,this.logger=e,this.root=i.divV([]),this.loader=i.loader(),this.calculating=!1,this.filterSyncer=new u.g(this.logger)}static filterCounter=-1;filterId=++x.filterCounter;filterToLog(){return`BioSubstructureFilter<${this.filterId}>`}viewSubs=[];attach(t){const e=super.attach.bind(this),n=`${this.filterToLog()}.attach()`;this.filterSyncer.sync(n,(async()=>{e(t),this.column||(this.columnName?this.column=this.dataFrame.getCol(this.columnName):this.column=t.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 w(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(r.events.onResetFilterRequest.subscribe(this.grokEventsOnResetFilterRequest.bind(this))),this.viewSubs.push(r.events.onCustomEvent(C).subscribe(this.filterOnSync.bind(this)))}))}detach(){const t=super.detach.bind(this),e=`${this.filterToLog()}.detach()`;this.filterSyncer.sync(e,(async()=>{for(const t of this.viewSubs)t.unsubscribe();this.viewSubs=[],t(),this.bioFilter&&this.bioFilter.detach(),this.bioFilter=null}))}filterOnSync(t){t.filterId!==this.filterId&&t.dataFrameId===this.dataFrame.id&&t.columnName===this.columnName&&(this.bioFilter.props=t.props)}applyFilter(){const t=`${this.filterToLog()}.applyFilter()`;this.logger.debug(`${t}, IN`),this.bitset&&!this.isDetached&&this.dataFrame?.filter.and(this.bitset)}saveState(){const t=`${this.filterToLog()}.saveState()`,e=super.saveState();return this.logger.debug(`${t}, super.state = ${JSON.stringify(e)}`),e.props=this.bioFilter.saveProps(),e}applyState(t){const e=`${this.filterToLog()}.applyState()`;super.applyState(t),this.filterSyncer.sync(e,(async()=>{t.props&&this.bioFilter&&(this.bioFilter.props=o.toJs(t.props??{}))}))}fireFilterSync(){const t=`${this.filterToLog()}.fireFilterSync()`;this.logger.debug(`${t}, bioFilter = ${this.bioFilter?this.bioFilter.constructor.name:"null"}`+(this.bioFilter?`, props = ${JSON.stringify(this.bioFilter.saveProps())}`:"")),r.events.fireCustomEvent(C,new A(this.bioFilter.props,this.filterId,this.dataFrame.id,this.columnName,this.bitset))}bioFilterOnChangedDebounced(){if(!this.dataFrame)return;const t=`${this.filterToLog()}.bioFilterOnChangedDebounced()`;if(this.logger.debug(`${t}, 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(t,(async()=>{this.calculating=!0;try{this.logger.debug(`${t}, before substructureSearch`),this.bitset=await(this.bioFilter?.substructureSearch(this.column)),this.logger.debug(`${t}, after substructureSearch`),this.calculating=!1,this.fireFilterSync(),this.dataFrame?.rows.requestFilter()}finally{this.calculating=!1,this.logger.debug(`${t}, end`)}}))}grokEventsOnResetFilterRequest(){const t=`${this.filterToLog()}.grokEventsOnResetFilterRequest()`;this.logger.debug(`${t}`),this.bioFilter?.resetFilter()}_onRendered=new l.Subject;get onRendered(){return this._onRendered}invalidate(t){const e=`${this.filterToLog()}.invalidate(${t?` <- ${t} `:""})`;this.filterSyncer.sync(e,(async()=>{this._onRendered.next()}))}async awaitRendered(t=1e4){const e=`awaitRendered( ${t} )`,n=`${this.filterToLog()}.${e}`;await(0,h.cb)(10),await(0,h.PE)(this.onRendered,(()=>{this.logger.debug(`${n}, _onRendered event caught`)}),(()=>{this.invalidate(e)}),t,`${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,v._package.logger);substructureInput;get type(){return"FastaBioFilter"}constructor(){super(),this.substructureInput=i.input.string("",{value:"",onValueChanged:t=>{window.setTimeout((()=>{this.props=new p.n(t,void 0,v._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(t){return(0,d.nI)(this.props.substructure,t)}async attach(){}async detach(){await super.detach()}}class M extends p.O{emptyProps=new S("",void 0,v._package.logger);substructureInput;separatorInput;colSeparator="";get type(){return"SeparatorBioFilter"}constructor(t){super(),this.substructureInput=i.input.string("",{value:"",onValueChanged:t=>{this.props=new S(t,this.props.separator,v._package.logger),setTimeout((()=>{this._propsChanging||this.onChanged.next()}))},placeholder:"Substructure"}),this.separatorInput=i.input.string("",{value:this.colSeparator=t,onValueChanged:t=>{const e=t||"";this.props=new S(this.props.substructure,e,v._package.logger),setTimeout((()=>{this._propsChanging||this.onChanged.next()}))},placeholder:"Separator"})}applyProps(){this.substructureInput.value!==this.props.substructure&&(this.substructureInput.value=this.props.substructure);const t=this.props.separator??this.colSeparator;this.separatorInput.value!==t&&(this.separatorInput.value=t)}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 S("",void 0,v._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(t){this.substructureInput.value=t}async substructureSearch(t){return(0,d.nI)(this.substructure,t,this.colSeparator)}async attach(){}async detach(){await super.detach()}}},1757:t=>{"use strict";t.exports=$},6082:t=>{"use strict";t.exports=DG},4328:t=>{"use strict";t.exports=grok},1858:t=>{"use strict";t.exports=rxjs},9713:t=>{"use strict";t.exports=rxjs.operators},7389:t=>{"use strict";t.exports=ui},1991:t=>{"use strict";t.exports=wu},8343:(t,e,n)=>{"use strict";const{normalizeIPv6:i,normalizeIPv4:o,removeDotSegments:r,recomposeAuthority:s,normalizeComponentEncoding:a}=n(4834),l=n(343);function c(t,e,n,i){const o={};return i||(t=p(h(t,n),n),e=p(h(e,n),n)),!(n=n||{}).tolerant&&e.scheme?(o.scheme=e.scheme,o.userinfo=e.userinfo,o.host=e.host,o.port=e.port,o.path=r(e.path||""),o.query=e.query):(void 0!==e.userinfo||void 0!==e.host||void 0!==e.port?(o.userinfo=e.userinfo,o.host=e.host,o.port=e.port,o.path=r(e.path||""),o.query=e.query):(e.path?("/"===e.path.charAt(0)?o.path=r(e.path):(void 0===t.userinfo&&void 0===t.host&&void 0===t.port||t.path?t.path?o.path=t.path.slice(0,t.path.lastIndexOf("/")+1)+e.path:o.path=e.path:o.path="/"+e.path,o.path=r(o.path)),o.query=e.query):(o.path=t.path,void 0!==e.query?o.query=e.query:o.query=t.query),o.userinfo=t.userinfo,o.host=t.host,o.port=t.port),o.scheme=t.scheme),o.fragment=e.fragment,o}function h(t,e){const n={host:t.host,scheme:t.scheme,userinfo:t.userinfo,port:t.port,path:t.path,query:t.query,nid:t.nid,nss:t.nss,uuid:t.uuid,fragment:t.fragment,reference:t.reference,resourceName:t.resourceName,secure:t.secure,error:""},i=Object.assign({},e),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=s(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 t=n.path;i.absolutePath||a&&a.absolutePath||(t=r(t)),void 0===c&&(t=t.replace(/^\/\//u,"/%2F")),o.push(t)}return void 0!==n.query&&o.push("?",n.query),void 0!==n.fragment&&o.push("#",n.fragment),o.join("")}const u=Array.from({length:127},((t,e)=>/[^!"$&'()*+,\-.;=_`a-z{}~]/u.test(String.fromCharCode(e)))),d=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function p(t,e){const n=Object.assign({},e),r={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},s=-1!==t.indexOf("%");let a=!1;"suffix"===n.reference&&(t=(n.scheme?n.scheme+":":"")+"//"+t);const c=t.match(d);if(c){if(r.scheme=c[1],r.userinfo=c[3],r.host=c[4],r.port=parseInt(c[5],10),r.path=c[6]||"",r.query=c[7],r.fragment=c[8],isNaN(r.port)&&(r.port=c[5]),r.host){const t=o(r.host);if(!1===t.isIPV4){const e=i(t.host);r.host=e.host.toLowerCase(),a=e.isIPV6}else r.host=t.host,a=!0}void 0!==r.scheme||void 0!==r.userinfo||void 0!==r.host||void 0!==r.port||void 0!==r.query||r.path?void 0===r.scheme?r.reference="relative":void 0===r.fragment?r.reference="absolute":r.reference="uri":r.reference="same-document",n.reference&&"suffix"!==n.reference&&n.reference!==r.reference&&(r.error=r.error||"URI is not a "+n.reference+" reference.");const t=l[(n.scheme||r.scheme||"").toLowerCase()];if(!(n.unicodeSupport||t&&t.unicodeSupport)&&r.host&&(n.domainHost||t&&t.domainHost)&&!1===a&&function(t){let e=0;for(let n=0,i=t.length;n<i;++n)if(e=t.charCodeAt(n),e>126||u[e])return!0;return!1}(r.host))try{r.host=URL.domainToASCII(r.host.toLowerCase())}catch(t){r.error=r.error||"Host's domain name can not be converted to ASCII: "+t}(!t||t&&!t.skipNormalize)&&(s&&void 0!==r.scheme&&(r.scheme=unescape(r.scheme)),s&&void 0!==r.host&&(r.host=unescape(r.host)),r.path&&(r.path=escape(unescape(r.path))),r.fragment&&(r.fragment=encodeURI(decodeURIComponent(r.fragment)))),t&&t.parse&&t.parse(r,n)}else r.error=r.error||"URI can not be parsed.";return r}const m={SCHEMES:l,normalize:function(t,e){return"string"==typeof t?t=h(p(t,e),e):"object"==typeof t&&(t=p(h(t,e),e)),t},resolve:function(t,e,n){const i=Object.assign({scheme:"null"},n);return h(c(p(t,i),p(e,i),i,!0),{...i,skipEscape:!0})},resolveComponents:c,equal:function(t,e,n){return"string"==typeof t?(t=unescape(t),t=h(a(p(t,n),!0),{...n,skipEscape:!0})):"object"==typeof t&&(t=h(a(t,!0),{...n,skipEscape:!0})),"string"==typeof e?(e=unescape(e),e=h(a(p(e,n),!0),{...n,skipEscape:!0})):"object"==typeof e&&(e=h(a(e,!0),{...n,skipEscape:!0})),t.toLowerCase()===e.toLowerCase()},serialize:h,parse:p};t.exports=m,t.exports.default=m,t.exports.fastUri=m},343:t=>{"use strict";const e=/^[\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(t){return"boolean"==typeof t.secure?t.secure:"wss"===String(t.scheme).toLowerCase()}function o(t){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t}function r(t){const e="https"===String(t.scheme).toLowerCase();return t.port!==(e?443:80)&&""!==t.port||(t.port=void 0),t.path||(t.path="/"),t}const s={scheme:"http",domainHost:!0,parse:o,serialize:r},a={scheme:"ws",domainHost:!0,parse:function(t){return t.secure=i(t),t.resourceName=(t.path||"/")+(t.query?"?"+t.query:""),t.path=void 0,t.query=void 0,t},serialize:function(t){if(t.port!==(i(t)?443:80)&&""!==t.port||(t.port=void 0),"boolean"==typeof t.secure&&(t.scheme=t.secure?"wss":"ws",t.secure=void 0),t.resourceName){const[e,n]=t.resourceName.split("?");t.path=e&&"/"!==e?e:void 0,t.query=n,t.resourceName=void 0}return t.fragment=void 0,t}},l={http:s,https:{scheme:"https",domainHost:s.domainHost,parse:o,serialize:r},ws:a,wss:{scheme:"wss",domainHost:a.domainHost,parse:a.parse,serialize:a.serialize},urn:{scheme:"urn",parse:function(t,e){if(!t.path)return t.error="URN can not be parsed",t;const i=t.path.match(n);if(i){const n=e.scheme||t.scheme||"urn";t.nid=i[1].toLowerCase(),t.nss=i[2];const o=`${n}:${e.nid||t.nid}`,r=l[o];t.path=void 0,r&&(t=r.parse(t,e))}else t.error=t.error||"URN can not be parsed.";return t},serialize:function(t,e){const n=e.scheme||t.scheme||"urn",i=t.nid.toLowerCase(),o=`${n}:${e.nid||i}`,r=l[o];r&&(t=r.serialize(t,e));const s=t,a=t.nss;return s.path=`${i||e.nid}:${a}`,e.skipEscape=!0,s},skipNormalize:!0},"urn:uuid":{scheme:"urn:uuid",parse:function(t,n){const i=t;return i.uuid=i.nss,i.nss=void 0,n.tolerant||i.uuid&&e.test(i.uuid)||(i.error=i.error||"UUID is not valid."),i},serialize:function(t){const e=t;return e.nss=(t.uuid||"").toLowerCase(),e},skipNormalize:!0}};t.exports=l},4914:t=>{"use strict";t.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:(t,e,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 r(t){if(c(t,".")<3)return{host:t,isIPV4:!1};const e=t.match(o)||[],[n]=e;return n?{host:l(n,"."),isIPV4:!0}:{host:t,isIPV4:!1}}function s(t,e=!1){let n="",o=!0;for(const e of t){if(void 0===i[e])return;"0"!==e&&!0===o&&(o=!1),o||(n+=e)}return e&&0===n.length&&(n="0"),n}function a(t){if(c(t,":")<2)return{host:t,isIPV6:!1};const e=function(t){let e=0;const n={error:!1,address:"",zone:""},i=[],o=[];let r=!1,a=!1,l=!1;function c(){if(o.length){if(!1===r){const t=s(o);if(void 0===t)return n.error=!0,!1;i.push(t)}o.length=0}return!0}for(let s=0;s<t.length;s++){const h=t[s];if("["!==h&&"]"!==h)if(":"!==h)if("%"===h){if(!c())break;r=!0}else o.push(h);else{if(!0===a&&(l=!0),!c())break;if(e++,i.push(":"),e>7){n.error=!0;break}s-1>=0&&":"===t[s-1]&&(a=!0)}}return o.length&&(r?n.zone=o.join(""):l?i.push(o.join("")):i.push(s(o))),n.address=i.join(""),n}(t);if(e.error)return{host:t,isIPV6:!1};{let t=e.address,n=e.address;return e.zone&&(t+="%"+e.zone,n+="%25"+e.zone),{host:t,escapedHost:n,isIPV6:!0}}}function l(t,e){let n="",i=!0;const o=t.length;for(let r=0;r<o;r++){const s=t[r];"0"===s&&i?(r+1<=o&&t[r+1]===e||r+1===o)&&(n+=s,i=!1):(i=s===e,n+=s)}return n}function c(t,e){let n=0;for(let i=0;i<t.length;i++)t[i]===e&&n++;return n}const h=/^\.\.?\//u,u=/^\/\.(?:\/|$)/u,d=/^\/\.\.(?:\/|$)/u,p=/^\/?(?:.|\n)*?(?=\/|$)/u;t.exports={recomposeAuthority:function(t){const e=[];if(void 0!==t.userinfo&&(e.push(t.userinfo),e.push("@")),void 0!==t.host){let n=unescape(t.host);const i=r(n);if(i.isIPV4)n=i.host;else{const e=a(i.host);n=!0===e.isIPV6?`[${e.escapedHost}]`:t.host}e.push(n)}return"number"!=typeof t.port&&"string"!=typeof t.port||(e.push(":"),e.push(String(t.port))),e.length?e.join(""):void 0},normalizeComponentEncoding:function(t,e){const n=!0!==e?escape:unescape;return void 0!==t.scheme&&(t.scheme=n(t.scheme)),void 0!==t.userinfo&&(t.userinfo=n(t.userinfo)),void 0!==t.host&&(t.host=n(t.host)),void 0!==t.path&&(t.path=n(t.path)),void 0!==t.query&&(t.query=n(t.query)),void 0!==t.fragment&&(t.fragment=n(t.fragment)),t},removeDotSegments:function(t){const e=[];for(;t.length;)if(t.match(h))t=t.replace(h,"");else if(t.match(u))t=t.replace(u,"/");else if(t.match(d))t=t.replace(d,"/"),e.pop();else if("."===t||".."===t)t="";else{const n=t.match(p);if(!n)throw new Error("Unexpected dot segment condition");{const i=n[0];t=t.slice(i.length),e.push(i)}}return e.join("")},normalizeIPv4:r,normalizeIPv6:a,stringArrayToHexStripped:s}},3837:t=>{"use strict";t.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:t=>{"use strict";t.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:t=>{"use strict";t.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:t=>{"use strict";t.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:t=>{"use strict";t.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:t=>{"use strict";t.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:t=>{"use strict";t.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:t=>{"use strict";t.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:t=>{"use strict";t.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:t=>{"use strict";t.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}')}},e={};function n(i){var o=e[i];if(void 0!==o)return o.exports;var r=e[i]={id:i,loaded:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.loaded=!0,r.exports}n.m=t,n.amdO={},n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.u=t=>t+".js",n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.hmd=t=>((t=Object.create(t)).children||(t.children=[]),Object.defineProperty(t,"exports",{enumerable:!0,set:()=>{throw new Error("ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: "+t.id)}}),t),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{var t;n.g.importScripts&&(t=n.g.location+"");var e=n.g.document;if(!t&&e&&(e.currentScript&&"SCRIPT"===e.currentScript.tagName.toUpperCase()&&(t=e.currentScript.src),!t)){var i=e.getElementsByTagName("script");if(i.length)for(var o=i.length-1;o>-1&&(!t||!/^http(s?):/.test(t));)t=i[o--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=t})(),n.b=document.baseURI||self.location.href,n.nc=void 0;var i=n(6723);bio=i})();
|
|
7
|
+
deps: ${n}}`};const s={keyword:"dependencies",type:"object",schemaType:"object",error:e.error,code(t){const[e,n]=function({schema:t}){const e={},n={};for(const i in t)"__proto__"!==i&&((Array.isArray(t[i])?e:n)[i]=t[i]);return[e,n]}(t);a(t,e),l(t,n)}};function a(t,e=t.schema){const{gen:n,data:o,it:s}=t;if(0===Object.keys(e).length)return;const a=n.let("missing");for(const l in e){const c=e[l];if(0===c.length)continue;const h=(0,r.propertyInData)(n,o,l,s.opts.ownProperties);t.setParams({property:l,depsCount:c.length,deps:c.join(", ")}),s.allErrors?n.if(h,(()=>{for(const e of c)(0,r.checkReportMissingProp)(t,e)})):(n.if(i._`${h} && (${(0,r.checkMissingProp)(t,c,a)})`),(0,r.reportMissingProp)(t,a),n.else())}}function l(t,e=t.schema){const{gen:n,data:i,keyword:s,it:a}=t,l=n.name("valid");for(const c in e)(0,o.alwaysValidSchema)(a,e[c])||(n.if((0,r.propertyInData)(n,i,c,a.opts.ownProperties),(()=>{const e=t.subschema({keyword:s,schemaProp:c},l);t.mergeValidEvaluated(e,l)}),(()=>n.var(l,!0))),t.ok(l))}e.validatePropertyDeps=a,e.validateSchemaDeps=l,e.default=s},4845:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(3025),o={keyword:"dependentSchemas",type:"object",schemaType:"object",code:t=>(0,i.validateSchemaDeps)(t)};e.default=o},1239:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(9029),o=n(4227),r={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:{message:({params:t})=>i.str`must match "${t.ifClause}" schema`,params:({params:t})=>i._`{failingKeyword: ${t.ifClause}}`},code(t){const{gen:e,parentSchema:n,it:r}=t;void 0===n.then&&void 0===n.else&&(0,o.checkStrictMode)(r,'"if" without "then" and "else" is ignored');const a=s(r,"then"),l=s(r,"else");if(!a&&!l)return;const c=e.let("valid",!0),h=e.name("_valid");if(function(){const e=t.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},h);t.mergeEvaluated(e)}(),t.reset(),a&&l){const n=e.let("ifClause");t.setParams({ifClause:n}),e.if(h,u("then",n),u("else",n))}else a?e.if(h,u("then")):e.if((0,i.not)(h),u("else"));function u(n,o){return()=>{const r=t.subschema({keyword:n},h);e.assign(c,h),t.mergeValidEvaluated(r,c),o?e.assign(o,i._`${n}`):t.setParams({ifClause:n})}}t.pass(c,(()=>t.error(!0)))}};function s(t,e){const n=t.schema[e];return void 0!==n&&!(0,o.alwaysValidSchema)(t,n)}e.default=r},6378:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(5457),o=n(5354),r=n(494),s=n(3966),a=n(2661),l=n(3025),c=n(2094),h=n(8660),u=n(117),d=n(5333),p=n(7923),m=n(6505),f=n(6163),g=n(5844),y=n(1239),b=n(4426);e.default=function(t=!1){const e=[p.default,m.default,f.default,g.default,y.default,b.default,c.default,h.default,l.default,u.default,d.default];return t?e.push(o.default,s.default):e.push(i.default,r.default),e.push(a.default),e}},494:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.validateTuple=void 0;const i=n(9029),o=n(4227),r=n(5765),s={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){const{schema:e,it:n}=t;if(Array.isArray(e))return a(t,"additionalItems",e);n.items=!0,(0,o.alwaysValidSchema)(n,e)||t.ok((0,r.validateArray)(t))}};function a(t,e,n=t.schema){const{gen:r,parentSchema:s,data:a,keyword:l,it:c}=t;!function(t){const{opts:i,errSchemaPath:r}=c,s=n.length,a=s===t.minItems&&(s===t.maxItems||!1===t[e]);if(i.strictTuples&&!a){const t=`"${l}" is ${s}-tuple, but minItems or maxItems/${e} are not specified or different at path "${r}"`;(0,o.checkStrictMode)(c,t,i.strictTuples)}}(s),c.opts.unevaluated&&n.length&&!0!==c.items&&(c.items=o.mergeEvaluated.items(r,n.length,c.items));const h=r.name("valid"),u=r.const("len",i._`${a}.length`);n.forEach(((e,n)=>{(0,o.alwaysValidSchema)(c,e)||(r.if(i._`${u} > ${n}`,(()=>t.subschema({keyword:l,schemaProp:n,dataProp:n},h))),t.ok(h))}))}e.validateTuple=a,e.default=s},3966:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(9029),o=n(4227),r=n(5765),s=n(5457),a={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:{message:({params:{len:t}})=>i.str`must NOT have more than ${t} items`,params:({params:{len:t}})=>i._`{limit: ${t}}`},code(t){const{schema:e,parentSchema:n,it:i}=t,{prefixItems:a}=n;i.items=!0,(0,o.alwaysValidSchema)(i,e)||(a?(0,s.validateAdditionalItems)(t,a):t.ok((0,r.validateArray)(t)))}};e.default=a},7923:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(4227),o={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){const{gen:e,schema:n,it:o}=t;if((0,i.alwaysValidSchema)(o,n))return void t.fail();const r=e.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},r),t.failResult(r,(()=>t.reset()),(()=>t.error()))},error:{message:"must NOT be valid"}};e.default=o},6163:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(9029),o=n(4227),r={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:{message:"must match exactly one schema in oneOf",params:({params:t})=>i._`{passingSchemas: ${t.passing}}`},code(t){const{gen:e,schema:n,parentSchema:r,it:s}=t;if(!Array.isArray(n))throw new Error("ajv implementation error");if(s.opts.discriminator&&r.discriminator)return;const a=n,l=e.let("valid",!1),c=e.let("passing",null),h=e.name("_valid");t.setParams({passing:c}),e.block((function(){a.forEach(((n,r)=>{let a;(0,o.alwaysValidSchema)(s,n)?e.var(h,!0):a=t.subschema({keyword:"oneOf",schemaProp:r,compositeRule:!0},h),r>0&&e.if(i._`${h} && ${l}`).assign(l,!1).assign(c,i._`[${c}, ${r}]`).else(),e.if(h,(()=>{e.assign(l,!0),e.assign(c,r),a&&t.mergeEvaluated(a,i.Name)}))}))})),t.result(l,(()=>t.reset()),(()=>t.error(!0)))}};e.default=r},5333:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(5765),o=n(9029),r=n(4227),s=n(4227),a={keyword:"patternProperties",type:"object",schemaType:"object",code(t){const{gen:e,schema:n,data:a,parentSchema:l,it:c}=t,{opts:h}=c,u=(0,i.allSchemaProperties)(n),d=u.filter((t=>(0,r.alwaysValidSchema)(c,n[t])));if(0===u.length||d.length===u.length&&(!c.opts.unevaluated||!0===c.props))return;const p=h.strictSchema&&!h.allowMatchingProperties&&l.properties,m=e.name("valid");!0===c.props||c.props instanceof o.Name||(c.props=(0,s.evaluatedPropsToName)(e,c.props));const{props:f}=c;function g(t){for(const e in p)new RegExp(t).test(e)&&(0,r.checkStrictMode)(c,`property ${e} matches pattern ${t} (use allowMatchingProperties)`)}function y(n){e.forIn("key",a,(r=>{e.if(o._`${(0,i.usePattern)(t,n)}.test(${r})`,(()=>{const i=d.includes(n);i||t.subschema({keyword:"patternProperties",schemaProp:n,dataProp:r,dataPropType:s.Type.Str},m),c.opts.unevaluated&&!0!==f?e.assign(o._`${f}[${r}]`,!0):i||c.allErrors||e.if((0,o.not)(m),(()=>e.break()))}))}))}!function(){for(const t of u)p&&g(t),c.allErrors?y(t):(e.var(m,!0),y(t),e.if(m))}()}};e.default=a},5354:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(494),o={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,i.validateTuple)(t,"items")};e.default=o},117:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(2586),o=n(5765),r=n(4227),s=n(8660),a={keyword:"properties",type:"object",schemaType:"object",code(t){const{gen:e,schema:n,parentSchema:a,data:l,it:c}=t;"all"===c.opts.removeAdditional&&void 0===a.additionalProperties&&s.default.code(new i.KeywordCxt(c,s.default,"additionalProperties"));const h=(0,o.allSchemaProperties)(n);for(const t of h)c.definedProperties.add(t);c.opts.unevaluated&&h.length&&!0!==c.props&&(c.props=r.mergeEvaluated.props(e,(0,r.toHash)(h),c.props));const u=h.filter((t=>!(0,r.alwaysValidSchema)(c,n[t])));if(0===u.length)return;const d=e.name("valid");for(const n of u)p(n)?m(n):(e.if((0,o.propertyInData)(e,l,n,c.opts.ownProperties)),m(n),c.allErrors||e.else().var(d,!0),e.endIf()),t.it.definedProperties.add(n),t.ok(d);function p(t){return c.opts.useDefaults&&!c.compositeRule&&void 0!==n[t].default}function m(e){t.subschema({keyword:"properties",schemaProp:e,dataProp:e},d)}}};e.default=a},2094:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(9029),o=n(4227),r={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:{message:"property name must be valid",params:({params:t})=>i._`{propertyName: ${t.propertyName}}`},code(t){const{gen:e,schema:n,data:r,it:s}=t;if((0,o.alwaysValidSchema)(s,n))return;const a=e.name("valid");e.forIn("key",r,(n=>{t.setParams({propertyName:n}),t.subschema({keyword:"propertyNames",data:n,dataTypes:["string"],propertyName:n,compositeRule:!0},a),e.if((0,i.not)(a),(()=>{t.error(!0),s.allErrors||e.break()}))})),t.ok(a)}};e.default=r},4426:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(4227),o={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:n}){void 0===e.if&&(0,i.checkStrictMode)(n,`"${t}" without "if" is ignored`)}};e.default=o},5765:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.validateUnion=e.validateArray=e.usePattern=e.callValidateCode=e.schemaProperties=e.allSchemaProperties=e.noPropertyInData=e.propertyInData=e.isOwnProperty=e.hasPropFunc=e.reportMissingProp=e.checkMissingProp=e.checkReportMissingProp=void 0;const i=n(9029),o=n(4227),r=n(2023),s=n(4227);function a(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:i._`Object.prototype.hasOwnProperty`})}function l(t,e,n){return i._`${a(t)}.call(${e}, ${n})`}function c(t,e,n,o){const r=i._`${e}${(0,i.getProperty)(n)} === undefined`;return o?(0,i.or)(r,(0,i.not)(l(t,e,n))):r}function h(t){return t?Object.keys(t).filter((t=>"__proto__"!==t)):[]}e.checkReportMissingProp=function(t,e){const{gen:n,data:o,it:r}=t;n.if(c(n,o,e,r.opts.ownProperties),(()=>{t.setParams({missingProperty:i._`${e}`},!0),t.error()}))},e.checkMissingProp=function({gen:t,data:e,it:{opts:n}},o,r){return(0,i.or)(...o.map((o=>(0,i.and)(c(t,e,o,n.ownProperties),i._`${r} = ${o}`))))},e.reportMissingProp=function(t,e){t.setParams({missingProperty:e},!0),t.error()},e.hasPropFunc=a,e.isOwnProperty=l,e.propertyInData=function(t,e,n,o){const r=i._`${e}${(0,i.getProperty)(n)} !== undefined`;return o?i._`${r} && ${l(t,e,n)}`:r},e.noPropertyInData=c,e.allSchemaProperties=h,e.schemaProperties=function(t,e){return h(e).filter((n=>!(0,o.alwaysValidSchema)(t,e[n])))},e.callValidateCode=function({schemaCode:t,data:e,it:{gen:n,topSchemaRef:o,schemaPath:s,errorPath:a},it:l},c,h,u){const d=u?i._`${t}, ${e}, ${o}${s}`:e,p=[[r.default.instancePath,(0,i.strConcat)(r.default.instancePath,a)],[r.default.parentData,l.parentData],[r.default.parentDataProperty,l.parentDataProperty],[r.default.rootData,r.default.rootData]];l.opts.dynamicRef&&p.push([r.default.dynamicAnchors,r.default.dynamicAnchors]);const m=i._`${d}, ${n.object(...p)}`;return h!==i.nil?i._`${c}.call(${h}, ${m})`:i._`${c}(${m})`};const u=i._`new RegExp`;e.usePattern=function({gen:t,it:{opts:e}},n){const o=e.unicodeRegExp?"u":"",{regExp:r}=e.code,a=r(n,o);return t.scopeValue("pattern",{key:a.toString(),ref:a,code:i._`${"new RegExp"===r.code?u:(0,s.useFunc)(t,r)}(${n}, ${o})`})},e.validateArray=function(t){const{gen:e,data:n,keyword:r,it:s}=t,a=e.name("valid");if(s.allErrors){const t=e.let("valid",!0);return l((()=>e.assign(t,!1))),t}return e.var(a,!0),l((()=>e.break())),a;function l(s){const l=e.const("len",i._`${n}.length`);e.forRange("i",0,l,(n=>{t.subschema({keyword:r,dataProp:n,dataPropType:o.Type.Num},a),e.if((0,i.not)(a),s)}))}},e.validateUnion=function(t){const{gen:e,schema:n,keyword:r,it:s}=t;if(!Array.isArray(n))throw new Error("ajv implementation error");if(n.some((t=>(0,o.alwaysValidSchema)(s,t)))&&!s.opts.unevaluated)return;const a=e.let("valid",!1),l=e.name("_valid");e.block((()=>n.forEach(((n,o)=>{const s=t.subschema({keyword:r,schemaProp:o,compositeRule:!0},l);e.assign(a,i._`${a} || ${l}`),t.mergeValidEvaluated(s,l)||e.if((0,i.not)(a))})))),t.result(a,(()=>t.reset()),(()=>t.error(!0)))}},3463:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};e.default=n},2128:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(3463),o=n(3693),r=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",i.default,o.default];e.default=r},3693:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.callRef=e.getValidate=void 0;const i=n(4551),o=n(5765),r=n(9029),s=n(2023),a=n(3835),l=n(4227),c={keyword:"$ref",schemaType:"string",code(t){const{gen:e,schema:n,it:o}=t,{baseId:s,schemaEnv:l,validateName:c,opts:d,self:p}=o,{root:m}=l;if(("#"===n||"#/"===n)&&s===m.baseId)return function(){if(l===m)return u(t,c,l,l.$async);const n=e.scopeValue("root",{ref:m});return u(t,r._`${n}.validate`,m,m.$async)}();const f=a.resolveRef.call(p,m,s,n);if(void 0===f)throw new i.default(o.opts.uriResolver,s,n);return f instanceof a.SchemaEnv?function(e){const n=h(t,e);u(t,n,e,e.$async)}(f):function(i){const o=e.scopeValue("schema",!0===d.code.source?{ref:i,code:(0,r.stringify)(i)}:{ref:i}),s=e.name("valid"),a=t.subschema({schema:i,dataTypes:[],schemaPath:r.nil,topSchemaRef:o,errSchemaPath:n},s);t.mergeEvaluated(a),t.ok(s)}(f)}};function h(t,e){const{gen:n}=t;return e.validate?n.scopeValue("validate",{ref:e.validate}):r._`${n.scopeValue("wrapper",{ref:e})}.validate`}function u(t,e,n,i){const{gen:a,it:c}=t,{allErrors:h,schemaEnv:u,opts:d}=c,p=d.passContext?s.default.this:r.nil;function m(t){const e=r._`${t}.errors`;a.assign(s.default.vErrors,r._`${s.default.vErrors} === null ? ${e} : ${s.default.vErrors}.concat(${e})`),a.assign(s.default.errors,r._`${s.default.vErrors}.length`)}function f(t){var e;if(!c.opts.unevaluated)return;const i=null===(e=null==n?void 0:n.validate)||void 0===e?void 0:e.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 e=a.var("props",r._`${t}.evaluated.props`);c.props=l.mergeEvaluated.props(a,e,c.props,r.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 e=a.var("items",r._`${t}.evaluated.items`);c.items=l.mergeEvaluated.items(a,e,c.items,r.Name)}}i?function(){if(!u.$async)throw new Error("async schema referenced by sync schema");const n=a.let("valid");a.try((()=>{a.code(r._`await ${(0,o.callValidateCode)(t,e,p)}`),f(e),h||a.assign(n,!0)}),(t=>{a.if(r._`!(${t} instanceof ${c.ValidationError})`,(()=>a.throw(t))),m(t),h||a.assign(n,!1)})),t.ok(n)}():t.result((0,o.callValidateCode)(t,e,p),(()=>f(e)),(()=>m(e)))}e.getValidate=h,e.callRef=u,e.default=c},6653:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(9029),o=n(7652),r=n(3835),s=n(4551),a=n(4227),l={keyword:"discriminator",type:"object",schemaType:"object",error:{message:({params:{discrError:t,tagName:e}})=>t===o.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:n}})=>i._`{error: ${t}, tag: ${n}, tagValue: ${e}}`},code(t){const{gen:e,data:n,schema:l,parentSchema:c,it:h}=t,{oneOf:u}=c;if(!h.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(!u)throw new Error("discriminator: requires oneOf keyword");const p=e.let("valid",!1),m=e.const("tag",i._`${n}${(0,i.getProperty)(d)}`);function f(n){const o=e.name("valid"),r=t.subschema({keyword:"oneOf",schemaProp:n},o);return t.mergeEvaluated(r,i.Name),o}e.if(i._`typeof ${m} == "string"`,(()=>function(){const n=function(){var t;const e={},n=o(c);let i=!0;for(let e=0;e<u.length;e++){let c=u[e];if((null==c?void 0:c.$ref)&&!(0,a.schemaHasRulesButRef)(c,h.self.RULES)){const t=c.$ref;if(c=r.resolveRef.call(h.self,h.schemaEnv.root,h.baseId,t),c instanceof r.SchemaEnv&&(c=c.schema),void 0===c)throw new s.default(h.opts.uriResolver,h.baseId,t)}const p=null===(t=null==c?void 0:c.properties)||void 0===t?void 0:t[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,e)}if(!i)throw new Error(`discriminator: "${d}" must be required`);return e;function o({required:t}){return Array.isArray(t)&&t.includes(d)}function l(t,e){if(t.const)p(t.const,e);else{if(!t.enum)throw new Error(`discriminator: "properties/${d}" must have "const" or "enum"`);for(const n of t.enum)p(n,e)}}function p(t,n){if("string"!=typeof t||t in e)throw new Error(`discriminator: "${d}" values must be unique strings`);e[t]=n}}();e.if(!1);for(const t in n)e.elseIf(i._`${m} === ${t}`),e.assign(p,f(n[t]));e.else(),t.error(!1,{discrError:o.DiscrError.Mapping,tag:m,tagName:d}),e.endIf()}()),(()=>t.error(!1,{discrError:o.DiscrError.Tag,tag:m,tagName:d}))),t.ok(p)}};e.default=l},7652:(t,e)=>{"use strict";var n;Object.defineProperty(e,"__esModule",{value:!0}),e.DiscrError=void 0,function(t){t.Tag="tag",t.Mapping="mapping"}(n||(e.DiscrError=n={}))},6105:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(2128),o=n(7060),r=n(6378),s=n(5520),a=n(5413),l=n(3265),c=n(7532),h=n(9857),u=[s.default,i.default,o.default,(0,r.default)(!0),c.default,h.metadataVocabulary,h.contentVocabulary,a.default,l.default];e.default=u},6144:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(2128),o=n(7060),r=n(6378),s=n(7532),a=n(9857),l=[i.default,o.default,(0,r.default)(),s.default,a.metadataVocabulary,a.contentVocabulary];e.default=l},2476:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.dynamicAnchor=void 0;const i=n(9029),o=n(2023),r=n(3835),s=n(3693),a={keyword:"$dynamicAnchor",schemaType:"string",code:t=>l(t,t.schema)};function l(t,e){const{gen:n,it:a}=t;a.schemaEnv.root.dynamicAnchors[e]=!0;const l=i._`${o.default.dynamicAnchors}${(0,i.getProperty)(e)}`,c="#"===a.errSchemaPath?a.validateName:function(t){const{schemaEnv:e,schema:n,self:i}=t.it,{root:o,baseId:a,localRefs:l,meta:c}=e.root,{schemaId:h}=i.opts,u=new r.SchemaEnv({schema:n,schemaId:h,root:o,baseId:a,localRefs:l,meta:c});return r.compileSchema.call(i,u),(0,s.getValidate)(t,u)}(t);n.if(i._`!${l}`,(()=>n.assign(l,c)))}e.dynamicAnchor=l,e.default=a},3252:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.dynamicRef=void 0;const i=n(9029),o=n(2023),r=n(3693),s={keyword:"$dynamicRef",schemaType:"string",code:t=>a(t,t.schema)};function a(t,e){const{gen:n,keyword:s,it:a}=t;if("#"!==e[0])throw new Error(`"${s}" only supports hash fragment reference`);const l=e.slice(1);if(a.allErrors)c();else{const e=n.let("valid",!1);c(e),t.ok(e)}function c(t){if(a.schemaEnv.root.dynamicAnchors[l]){const e=n.let("_v",i._`${o.default.dynamicAnchors}${(0,i.getProperty)(l)}`);n.if(e,h(e,t),h(a.validateName,t))}else h(a.validateName,t)()}function h(e,i){return i?()=>n.block((()=>{(0,r.callRef)(t,e),n.let(i,!0)})):()=>(0,r.callRef)(t,e)}}e.dynamicRef=a,e.default=s},5520:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(2476),o=n(3252),r=n(2721),s=n(3799),a=[i.default,o.default,r.default,s.default];e.default=a},2721:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(2476),o=n(4227),r={keyword:"$recursiveAnchor",schemaType:"boolean",code(t){t.schema?(0,i.dynamicAnchor)(t,""):(0,o.checkStrictMode)(t.it,"$recursiveAnchor: false is ignored")}};e.default=r},3799:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(3252),o={keyword:"$recursiveRef",schemaType:"string",code:t=>(0,i.dynamicRef)(t,t.schema)};e.default=o},4737:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(9029),o={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:{message:({schemaCode:t})=>i.str`must match format "${t}"`,params:({schemaCode:t})=>i._`{format: ${t}}`},code(t,e){const{gen:n,data:o,$data:r,schema:s,schemaCode:a,it:l}=t,{opts:c,errSchemaPath:h,schemaEnv:u,self:d}=l;c.validateFormats&&(r?function(){const r=n.scopeValue("formats",{ref:d.formats,code:c.code.formats}),s=n.const("fDef",i._`${r}[${a}]`),l=n.let("fType"),h=n.let("format");n.if(i._`typeof ${s} == "object" && !(${s} instanceof RegExp)`,(()=>n.assign(l,i._`${s}.type || "string"`).assign(h,i._`${s}.validate`)),(()=>n.assign(l,i._`"string"`).assign(h,s))),t.fail$data((0,i.or)(!1===c.strictSchema?i.nil:i._`${a} && !${h}`,function(){const t=u.$async?i._`(${s}.async ? await ${h}(${o}) : ${h}(${o}))`:i._`${h}(${o})`,n=i._`(typeof ${h} == "function" ? ${t} : ${h}.test(${o}))`;return i._`${h} && ${h} !== true && ${l} === ${e} && !${n}`}()))}():function(){const r=d.formats[s];if(!r)return void function(){if(!1!==c.strictSchema)throw new Error(t());function t(){return`unknown format "${s}" ignored in schema at path "${h}"`}d.logger.warn(t())}();if(!0===r)return;const[a,l,p]=function(t){const e=t instanceof RegExp?(0,i.regexpCode)(t):c.code.formats?i._`${c.code.formats}${(0,i.getProperty)(s)}`:void 0,o=n.scopeValue("formats",{key:s,ref:t,code:e});return"object"!=typeof t||t instanceof RegExp?["string",t,o]:[t.type||"string",t.validate,i._`${o}.validate`]}(r);a===e&&t.pass(function(){if("object"==typeof r&&!(r instanceof RegExp)&&r.async){if(!u.$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})`}())}())}};e.default=o},7532:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=[n(4737).default];e.default=i},9857:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.contentVocabulary=e.metadataVocabulary=void 0,e.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"],e.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]},5413:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(1846),o=n(4845),r=n(2626),s=[i.default,o.default,r.default];e.default=s},3265:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(392),o=n(3445),r=[i.default,o.default];e.default=r},3445:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(9029),o=n(4227),r={keyword:"unevaluatedItems",type:"array",schemaType:["boolean","object"],error:{message:({params:{len:t}})=>i.str`must NOT have more than ${t} items`,params:({params:{len:t}})=>i._`{limit: ${t}}`},code(t){const{gen:e,schema:n,data:r,it:s}=t,a=s.items||0;if(!0===a)return;const l=e.const("len",i._`${r}.length`);if(!1===n)t.setParams({len:a}),t.fail(i._`${l} > ${a}`);else if("object"==typeof n&&!(0,o.alwaysValidSchema)(s,n)){const n=e.var("valid",i._`${l} <= ${a}`);e.if((0,i.not)(n),(()=>function(n,r){e.forRange("i",r,l,(r=>{t.subschema({keyword:"unevaluatedItems",dataProp:r,dataPropType:o.Type.Num},n),s.allErrors||e.if((0,i.not)(n),(()=>e.break()))}))}(n,a))),t.ok(n)}s.items=!0}};e.default=r},392:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(9029),o=n(4227),r=n(2023),s={keyword:"unevaluatedProperties",type:"object",schemaType:["boolean","object"],trackErrors:!0,error:{message:"must NOT have unevaluated properties",params:({params:t})=>i._`{unevaluatedProperty: ${t.unevaluatedProperty}}`},code(t){const{gen:e,schema:n,data:s,errsCount:a,it:l}=t;if(!a)throw new Error("ajv implementation error");const{allErrors:c,props:h}=l;function u(r){if(!1===n)return t.setParams({unevaluatedProperty:r}),t.error(),void(c||e.break());if(!(0,o.alwaysValidSchema)(l,n)){const n=e.name("valid");t.subschema({keyword:"unevaluatedProperties",dataProp:r,dataPropType:o.Type.Str},n),c||e.if((0,i.not)(n),(()=>e.break()))}}h instanceof i.Name?e.if(i._`${h} !== true`,(()=>e.forIn("key",s,(t=>e.if(function(t,e){return i._`!${t} || !${t}[${e}]`}(h,t),(()=>u(t))))))):!0!==h&&e.forIn("key",s,(t=>void 0===h?u(t):e.if(function(t,e){const n=[];for(const o in t)!0===t[o]&&n.push(i._`${e} !== ${o}`);return(0,i.and)(...n)}(h,t),(()=>u(t))))),l.props=!0,t.ok(i._`${a} === ${r.default.errors}`)}};e.default=s},7935:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(9029),o=n(4227),r=n(6250),s={keyword:"const",$data:!0,error:{message:"must be equal to constant",params:({schemaCode:t})=>i._`{allowedValue: ${t}}`},code(t){const{gen:e,data:n,$data:s,schemaCode:a,schema:l}=t;s||l&&"object"==typeof l?t.fail$data(i._`!${(0,o.useFunc)(e,r.default)}(${n}, ${a})`):t.fail(i._`${l} !== ${n}`)}};e.default=s},1846:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(3025),o={keyword:"dependentRequired",type:"object",schemaType:"object",error:i.error,code:t=>(0,i.validatePropertyDeps)(t)};e.default=o},8643:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(9029),o=n(4227),r=n(6250),s={keyword:"enum",schemaType:"array",$data:!0,error:{message:"must be equal to one of the allowed values",params:({schemaCode:t})=>i._`{allowedValues: ${t}}`},code(t){const{gen:e,data:n,$data:s,schema:a,schemaCode:l,it:c}=t;if(!s&&0===a.length)throw new Error("enum must have non-empty array");const h=a.length>=c.opts.loopEnum;let u;const d=()=>null!=u?u:u=(0,o.useFunc)(e,r.default);let p;if(h||s)p=e.let("valid"),t.block$data(p,(function(){e.assign(p,!1),e.forOf("v",l,(t=>e.if(i._`${d()}(${n}, ${t})`,(()=>e.assign(p,!0).break()))))}));else{if(!Array.isArray(a))throw new Error("ajv implementation error");const t=e.const("vSchema",l);p=(0,i.or)(...a.map(((e,o)=>function(t,e){const o=a[e];return"object"==typeof o&&null!==o?i._`${d()}(${n}, ${t}[${e}])`:i._`${n} === ${o}`}(t,o))))}t.pass(p)}};e.default=s},7060:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(5882),o=n(3439),r=n(7307),s=n(422),a=n(4486),l=n(4003),c=n(1163),h=n(617),u=n(7935),d=n(8643),p=[i.default,o.default,r.default,s.default,a.default,l.default,c.default,h.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},u.default,d.default];e.default=p},2626:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(4227),o={keyword:["maxContains","minContains"],type:"array",schemaType:"number",code({keyword:t,parentSchema:e,it:n}){void 0===e.contains&&(0,i.checkStrictMode)(n,`"${t}" without "contains" is ignored`)}};e.default=o},1163:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(9029),o={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:{message({keyword:t,schemaCode:e}){const n="maxItems"===t?"more":"fewer";return i.str`must NOT have ${n} than ${e} items`},params:({schemaCode:t})=>i._`{limit: ${t}}`},code(t){const{keyword:e,data:n,schemaCode:o}=t,r="maxItems"===e?i.operators.GT:i.operators.LT;t.fail$data(i._`${n}.length ${r} ${o}`)}};e.default=o},7307:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(9029),o=n(4227),r=n(3853),s={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:{message({keyword:t,schemaCode:e}){const n="maxLength"===t?"more":"fewer";return i.str`must NOT have ${n} than ${e} characters`},params:({schemaCode:t})=>i._`{limit: ${t}}`},code(t){const{keyword:e,data:n,schemaCode:s,it:a}=t,l="maxLength"===e?i.operators.GT:i.operators.LT,c=!1===a.opts.unicode?i._`${n}.length`:i._`${(0,o.useFunc)(t.gen,r.default)}(${n})`;t.fail$data(i._`${c} ${l} ${s}`)}};e.default=s},5882:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(9029),o=i.operators,r={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}},s={message:({keyword:t,schemaCode:e})=>i.str`must be ${r[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>i._`{comparison: ${r[t].okStr}, limit: ${e}}`},a={keyword:Object.keys(r),type:"number",schemaType:"number",$data:!0,error:s,code(t){const{keyword:e,data:n,schemaCode:o}=t;t.fail$data(i._`${n} ${r[e].fail} ${o} || isNaN(${n})`)}};e.default=a},4486:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(9029),o={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:{message({keyword:t,schemaCode:e}){const n="maxProperties"===t?"more":"fewer";return i.str`must NOT have ${n} than ${e} properties`},params:({schemaCode:t})=>i._`{limit: ${t}}`},code(t){const{keyword:e,data:n,schemaCode:o}=t,r="maxProperties"===e?i.operators.GT:i.operators.LT;t.fail$data(i._`Object.keys(${n}).length ${r} ${o}`)}};e.default=o},3439:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(9029),o={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:{message:({schemaCode:t})=>i.str`must be multiple of ${t}`,params:({schemaCode:t})=>i._`{multipleOf: ${t}}`},code(t){const{gen:e,data:n,schemaCode:o,it:r}=t,s=r.opts.multipleOfPrecision,a=e.let("res"),l=s?i._`Math.abs(Math.round(${a}) - ${a}) > 1e-${s}`:i._`${a} !== parseInt(${a})`;t.fail$data(i._`(${o} === 0 || (${a} = ${n}/${o}, ${l}))`)}};e.default=o},422:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(5765),o=n(9029),r={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:{message:({schemaCode:t})=>o.str`must match pattern "${t}"`,params:({schemaCode:t})=>o._`{pattern: ${t}}`},code(t){const{data:e,$data:n,schema:r,schemaCode:s,it:a}=t,l=a.opts.unicodeRegExp?"u":"",c=n?o._`(new RegExp(${s}, ${l}))`:(0,i.usePattern)(t,r);t.fail$data(o._`!${c}.test(${e})`)}};e.default=r},4003:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(5765),o=n(9029),r=n(4227),s={keyword:"required",type:"object",schemaType:"array",$data:!0,error:{message:({params:{missingProperty:t}})=>o.str`must have required property '${t}'`,params:({params:{missingProperty:t}})=>o._`{missingProperty: ${t}}`},code(t){const{gen:e,schema:n,schemaCode:s,data:a,$data:l,it:c}=t,{opts:h}=c;if(!l&&0===n.length)return;const u=n.length>=h.loopRequired;if(c.allErrors?function(){if(u||l)t.block$data(o.nil,d);else for(const e of n)(0,i.checkReportMissingProp)(t,e)}():function(){const r=e.let("missing");if(u||l){const n=e.let("valid",!0);t.block$data(n,(()=>function(n,r){t.setParams({missingProperty:n}),e.forOf(n,s,(()=>{e.assign(r,(0,i.propertyInData)(e,a,n,h.ownProperties)),e.if((0,o.not)(r),(()=>{t.error(),e.break()}))}),o.nil)}(r,n))),t.ok(n)}else e.if((0,i.checkMissingProp)(t,n,r)),(0,i.reportMissingProp)(t,r),e.else()}(),h.strictRequired){const e=t.parentSchema.properties,{definedProperties:i}=t.it;for(const t of n)if(void 0===(null==e?void 0:e[t])&&!i.has(t)){const e=`required property "${t}" is not defined at "${c.schemaEnv.baseId+c.errSchemaPath}" (strictRequired)`;(0,r.checkStrictMode)(c,e,c.opts.strictRequired)}}function d(){e.forOf("prop",s,(n=>{t.setParams({missingProperty:n}),e.if((0,i.noPropertyInData)(e,a,n,h.ownProperties),(()=>t.error()))}))}}};e.default=s},617:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(208),o=n(9029),r=n(4227),s=n(6250),a={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:{message:({params:{i:t,j:e}})=>o.str`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>o._`{i: ${t}, j: ${e}}`},code(t){const{gen:e,data:n,$data:a,schema:l,parentSchema:c,schemaCode:h,it:u}=t;if(!a&&!l)return;const d=e.let("valid"),p=c.items?(0,i.getSchemaTypes)(c.items):[];function m(r,s){const a=e.name("item"),l=(0,i.checkDataTypes)(p,a,u.opts.strictNumbers,i.DataType.Wrong),c=e.const("indices",o._`{}`);e.for(o._`;${r}--;`,(()=>{e.let(a,o._`${n}[${r}]`),e.if(l,o._`continue`),p.length>1&&e.if(o._`typeof ${a} == "string"`,o._`${a} += "_"`),e.if(o._`typeof ${c}[${a}] == "number"`,(()=>{e.assign(s,o._`${c}[${a}]`),t.error(),e.assign(d,!1).break()})).code(o._`${c}[${a}] = ${r}`)}))}function f(i,a){const l=(0,r.useFunc)(e,s.default),c=e.name("outer");e.label(c).for(o._`;${i}--;`,(()=>e.for(o._`${a} = ${i}; ${a}--;`,(()=>e.if(o._`${l}(${n}[${i}], ${n}[${a}])`,(()=>{t.error(),e.assign(d,!1).break(c)}))))))}t.block$data(d,(function(){const i=e.let("i",o._`${n}.length`),r=e.let("j");t.setParams({i,j:r}),e.assign(d,!0),e.if(o._`${i} > 1`,(()=>(p.length>0&&!p.some((t=>"object"===t||"array"===t))?m:f)(i,r)))}),o._`${h} === false`),t.ok(d)}};e.default=a},5488:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var i=n(1354),o=n.n(i),r=n(6314),s=n.n(r)()(o());s.push([t.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=s},5999:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var i=n(1354),o=n.n(i),r=n(6314),s=n.n(r)()(o());s.push([t.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=s},857:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var i=n(1354),o=n.n(i),r=n(6314),s=n.n(r)()(o());s.push([t.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=s},6369:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var i=n(1354),o=n.n(i),r=n(6314),s=n.n(r)()(o());s.push([t.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=s},7939:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var i=n(1354),o=n.n(i),r=n(6314),s=n.n(r)()(o());s.push([t.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=s},3017:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var i=n(1354),o=n.n(i),r=n(6314),s=n.n(r)()(o());s.push([t.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=s},6314:t=>{"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var n="",i=void 0!==e[5];return e[4]&&(n+="@supports (".concat(e[4],") {")),e[2]&&(n+="@media ".concat(e[2]," {")),i&&(n+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),n+=t(e),i&&(n+="}"),e[2]&&(n+="}"),e[4]&&(n+="}"),n})).join("")},e.i=function(t,n,i,o,r){"string"==typeof t&&(t=[[null,t,void 0]]);var s={};if(i)for(var a=0;a<this.length;a++){var l=this[a][0];null!=l&&(s[l]=!0)}for(var c=0;c<t.length;c++){var h=[].concat(t[c]);i&&s[h[0]]||(void 0!==r&&(void 0===h[5]||(h[1]="@layer".concat(h[5].length>0?" ".concat(h[5]):""," {").concat(h[1],"}")),h[5]=r),n&&(h[2]?(h[1]="@media ".concat(h[2]," {").concat(h[1],"}"),h[2]=n):h[2]=n),o&&(h[4]?(h[1]="@supports (".concat(h[4],") {").concat(h[1],"}"),h[4]=o):h[4]="".concat(o)),e.push(h))}},e}},1354:t=>{"use strict";t.exports=function(t){var e=t[1],n=t[3];if(!n)return e;if("function"==typeof btoa){var i=btoa(unescape(encodeURIComponent(JSON.stringify(n)))),o="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(i),r="/*# ".concat(o," */");return[e].concat([r]).join("\n")}return[e].join("\n")}},2017:t=>{"use strict";t.exports=function t(e,n){if(e===n)return!0;if(e&&n&&"object"==typeof e&&"object"==typeof n){if(e.constructor!==n.constructor)return!1;var i,o,r;if(Array.isArray(e)){if((i=e.length)!=n.length)return!1;for(o=i;0!=o--;)if(!t(e[o],n[o]))return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if((i=(r=Object.keys(e)).length)!==Object.keys(n).length)return!1;for(o=i;0!=o--;)if(!Object.prototype.hasOwnProperty.call(n,r[o]))return!1;for(o=i;0!=o--;){var s=r[o];if(!t(e[s],n[s]))return!1}return!0}return e!=e&&n!=n}},9982:function(t,e,n){var i;!function(){var e={};!function(t){"use strict";t.__esModule=!0,t.digestLength=32,t.blockSize=64;var e=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(t,n,i,o,r){for(var s,a,l,c,h,u,d,p,m,f,g,y,b;r>=64;){for(s=n[0],a=n[1],l=n[2],c=n[3],h=n[4],u=n[5],d=n[6],p=n[7],f=0;f<16;f++)g=o+4*f,t[f]=(255&i[g])<<24|(255&i[g+1])<<16|(255&i[g+2])<<8|255&i[g+3];for(f=16;f<64;f++)y=((m=t[f-2])>>>17|m<<15)^(m>>>19|m<<13)^m>>>10,b=((m=t[f-15])>>>7|m<<25)^(m>>>18|m<<14)^m>>>3,t[f]=(y+t[f-7]|0)+(b+t[f-16]|0);for(f=0;f<64;f++)y=(((h>>>6|h<<26)^(h>>>11|h<<21)^(h>>>25|h<<7))+(h&u^~h&d)|0)+(p+(e[f]+t[f]|0)|0)|0,b=((s>>>2|s<<30)^(s>>>13|s<<19)^(s>>>22|s<<10))+(s&a^s&l^a&l)|0,p=d,d=u,u=h,h=c+y|0,c=l,l=a,a=s,s=y+b|0;n[0]+=s,n[1]+=a,n[2]+=l,n[3]+=c,n[4]+=h,n[5]+=u,n[6]+=d,n[7]+=p,o+=64,r-=64}return o}var i=function(){function e(){this.digestLength=t.digestLength,this.blockSize=t.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 e.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},e.prototype.clean=function(){for(var t=0;t<this.buffer.length;t++)this.buffer[t]=0;for(t=0;t<this.temp.length;t++)this.temp[t]=0;this.reset()},e.prototype.update=function(t,e){if(void 0===e&&(e=t.length),this.finished)throw new Error("SHA256: can't update because hash was finished.");var i=0;if(this.bytesHashed+=e,this.bufferLength>0){for(;this.bufferLength<64&&e>0;)this.buffer[this.bufferLength++]=t[i++],e--;64===this.bufferLength&&(n(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(e>=64&&(i=n(this.temp,this.state,t,i,e),e%=64);e>0;)this.buffer[this.bufferLength++]=t[i++],e--;return this},e.prototype.finish=function(t){if(!this.finished){var e=this.bytesHashed,i=this.bufferLength,o=e/536870912|0,r=e<<3,s=e%64<56?64:128;this.buffer[i]=128;for(var a=i+1;a<s-8;a++)this.buffer[a]=0;this.buffer[s-8]=o>>>24&255,this.buffer[s-7]=o>>>16&255,this.buffer[s-6]=o>>>8&255,this.buffer[s-5]=o>>>0&255,this.buffer[s-4]=r>>>24&255,this.buffer[s-3]=r>>>16&255,this.buffer[s-2]=r>>>8&255,this.buffer[s-1]=r>>>0&255,n(this.temp,this.state,this.buffer,0,s),this.finished=!0}for(a=0;a<8;a++)t[4*a+0]=this.state[a]>>>24&255,t[4*a+1]=this.state[a]>>>16&255,t[4*a+2]=this.state[a]>>>8&255,t[4*a+3]=this.state[a]>>>0&255;return this},e.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},e.prototype._saveState=function(t){for(var e=0;e<this.state.length;e++)t[e]=this.state[e]},e.prototype._restoreState=function(t,e){for(var n=0;n<this.state.length;n++)this.state[n]=t[n];this.bytesHashed=e,this.finished=!1,this.bufferLength=0},e}();t.Hash=i;var o=function(){function t(t){this.inner=new i,this.outer=new i,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var e=new Uint8Array(this.blockSize);if(t.length>this.blockSize)(new i).update(t).finish(e).clean();else for(var n=0;n<t.length;n++)e[n]=t[n];for(n=0;n<e.length;n++)e[n]^=54;for(this.inner.update(e),n=0;n<e.length;n++)e[n]^=106;for(this.outer.update(e),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate),n=0;n<e.length;n++)e[n]=0}return t.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},t.prototype.clean=function(){for(var t=0;t<this.istate.length;t++)this.ostate[t]=this.istate[t]=0;this.inner.clean(),this.outer.clean()},t.prototype.update=function(t){return this.inner.update(t),this},t.prototype.finish=function(t){return this.outer.finished?this.outer.finish(t):(this.inner.finish(t),this.outer.update(t,this.digestLength).finish(t)),this},t.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},t}();function r(t){var e=(new i).update(t),n=e.digest();return e.clean(),n}function s(t,e){var n=new o(t).update(e),i=n.digest();return n.clean(),i}function a(t,e,n,i){var o=i[0];if(0===o)throw new Error("hkdf: cannot expand more");e.reset(),o>1&&e.update(t),n&&e.update(n),e.update(i),e.finish(t),i[0]++}t.HMAC=o,t.hash=r,t.default=r,t.hmac=s;var l=new Uint8Array(t.digestLength);t.hkdf=function(t,e,n,i){void 0===e&&(e=l),void 0===i&&(i=32);for(var r=new Uint8Array([1]),c=s(e,t),h=new o(c),u=new Uint8Array(h.digestLength),d=u.length,p=new Uint8Array(i),m=0;m<i;m++)d===u.length&&(a(u,h,n,r),d=0),p[m]=u[d++];return h.clean(),u.fill(0),r.fill(0),p},t.pbkdf2=function(t,e,n,i){for(var r=new o(t),s=r.digestLength,a=new Uint8Array(4),l=new Uint8Array(s),c=new Uint8Array(s),h=new Uint8Array(i),u=0;u*s<i;u++){var d=u+1;a[0]=d>>>24&255,a[1]=d>>>16&255,a[2]=d>>>8&255,a[3]=d>>>0&255,r.reset(),r.update(e),r.update(a),r.finish(c);for(var p=0;p<s;p++)l[p]=c[p];for(p=2;p<=n;p++){r.reset(),r.update(c).finish(c);for(var m=0;m<s;m++)l[m]^=c[m]}for(p=0;p<s&&u*s+p<i;p++)h[u*s+p]=l[p]}for(u=0;u<s;u++)l[u]=c[u]=0;for(u=0;u<4;u++)a[u]=0;return r.clean(),h}}(e);var o=e.default;for(var r in e)o[r]=e[r];"object"==typeof t.exports?t.exports=o:void 0===(i=function(){return o}.call(e,n,e,t))||(t.exports=i)}()},2787:(t,e,n)=>{"use strict";n.d(e,{I:()=>o});const i=new Uint32Array(65536),o=(t,e)=>{if(t.length<e.length){const n=e;e=t,t=n}return 0===e.length?t.length:t.length<=32?((t,e)=>{const n=t.length,o=e.length,r=1<<n-1;let s=-1,a=0,l=n,c=n;for(;c--;)i[t.charCodeAt(c)]|=1<<c;for(c=0;c<o;c++){let t=i[e.charCodeAt(c)];const n=t|a;t|=(t&s)+s^s,a|=~(t|s),s&=t,a&r&&l++,s&r&&l--,a=a<<1|1,s=s<<1|~(n|a),a&=n}for(c=n;c--;)i[t.charCodeAt(c)]=0;return l})(t,e):((t,e)=>{const n=e.length,o=t.length,r=[],s=[],a=Math.ceil(n/32),l=Math.ceil(o/32);for(let t=0;t<a;t++)s[t]=-1,r[t]=0;let c=0;for(;c<l-1;c++){let a=0,l=-1;const h=32*c,u=Math.min(32,o)+h;for(let e=h;e<u;e++)i[t.charCodeAt(e)]|=1<<e;for(let t=0;t<n;t++){const n=i[e.charCodeAt(t)],o=s[t/32|0]>>>t&1,c=r[t/32|0]>>>t&1,h=n|a,u=((n|c)&l)+l^l|n|c;let d=a|~(u|l),p=l&u;d>>>31^o&&(s[t/32|0]^=1<<t),p>>>31^c&&(r[t/32|0]^=1<<t),d=d<<1|o,p=p<<1|c,l=p|~(h|d),a=d&h}for(let e=h;e<u;e++)i[t.charCodeAt(e)]=0}let h=0,u=-1;const d=32*c,p=Math.min(32,o-d)+d;for(let e=d;e<p;e++)i[t.charCodeAt(e)]|=1<<e;let m=o;for(let t=0;t<n;t++){const n=i[e.charCodeAt(t)],a=s[t/32|0]>>>t&1,l=r[t/32|0]>>>t&1,c=n|h,d=((n|l)&u)+u^u|n|l;let p=h|~(d|u),f=u&d;m+=p>>>o-1&1,m-=f>>>o-1&1,p>>>31^a&&(s[t/32|0]^=1<<t),f>>>31^l&&(r[t/32|0]^=1<<t),p=p<<1|a,f=f<<1|l,u=f|~(c|p),h=p&c}for(let e=d;e<p;e++)i[t.charCodeAt(e)]=0;return m})(t,e)}},9937:t=>{t.exports={linLogMode:!1,outboundAttractionDistribution:!1,adjustSizes:!1,edgeWeightInfluence:1,scalingRatio:1,strongGravityMode:!1,gravity:1,slowDown:1,barnesHutOptimize:!1,barnesHutTheta:.5}},1782:(t,e)=>{e.assign=function(t){t=t||{};var e,n,i,o=Array.prototype.slice.call(arguments).slice(1);for(e=0,i=o.length;e<i;e++)if(o[e])for(n in o[e])t[n]=o[e][n];return t},e.validateSettings=function(t){return"linLogMode"in t&&"boolean"!=typeof t.linLogMode?{message:"the `linLogMode` setting should be a boolean."}:"outboundAttractionDistribution"in t&&"boolean"!=typeof t.outboundAttractionDistribution?{message:"the `outboundAttractionDistribution` setting should be a boolean."}:"adjustSizes"in t&&"boolean"!=typeof t.adjustSizes?{message:"the `adjustSizes` setting should be a boolean."}:"edgeWeightInfluence"in t&&"number"!=typeof t.edgeWeightInfluence?{message:"the `edgeWeightInfluence` setting should be a number."}:!("scalingRatio"in t)||"number"==typeof t.scalingRatio&&t.scalingRatio>=0?"strongGravityMode"in t&&"boolean"!=typeof t.strongGravityMode?{message:"the `strongGravityMode` setting should be a boolean."}:!("gravity"in t)||"number"==typeof t.gravity&&t.gravity>=0?"slowDown"in t&&!("number"==typeof t.slowDown||t.slowDown>=0)?{message:"the `slowDown` setting should be a number >= 0."}:"barnesHutOptimize"in t&&"boolean"!=typeof t.barnesHutOptimize?{message:"the `barnesHutOptimize` setting should be a boolean."}:!("barnesHutTheta"in t)||"number"==typeof t.barnesHutTheta&&t.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."}},e.graphToByteArrays=function(t,e){var n,i=t.order,o=t.size,r={},s=new Float32Array(10*i),a=new Float32Array(3*o);return n=0,t.forEachNode((function(t,e){r[t]=n,s[n]=e.x,s[n+1]=e.y,s[n+2]=0,s[n+3]=0,s[n+4]=0,s[n+5]=0,s[n+6]=1,s[n+7]=1,s[n+8]=e.size||1,s[n+9]=e.fixed?1:0,n+=10})),n=0,t.forEachEdge((function(t,i,o,l,c,h,u){var d=r[o],p=r[l],m=e(t,i,o,l,c,h,u);s[d+6]+=m,s[p+6]+=m,a[n]=d,a[n+1]=p,a[n+2]=m,n+=3})),{nodes:s,edges:a}},e.assignLayoutChanges=function(t,e,n){var i=0;t.updateEachNodeAttributes((function(t,o){return o.x=e[i],o.y=e[i+1],i+=10,n?n(t,o):o}))},e.readGraphPositions=function(t,e){var n=0;t.forEachNode((function(t,i){e[n]=i.x,e[n+1]=i.y,n+=10}))},e.collectLayoutChanges=function(t,e,n){for(var i=t.nodes(),o={},r=0,s=0,a=e.length;r<a;r+=10){if(n){var l=Object.assign({},t.getNodeAttributes(i[s]));l.x=e[r],l.y=e[r+1],l=n(i[s],l),o[i[s]]={x:l.x,y:l.y}}else o[i[s]]={x:e[r],y:e[r+1]};s++}return o},e.createWorker=function(t){var e=window.URL||window.webkitURL,n=t.toString(),i=e.createObjectURL(new Blob(["("+n+").call(this);"],{type:"text/javascript"})),o=new Worker(i);return e.revokeObjectURL(i),o}},8903:(t,e,n)=>{var i=n(1736),o=n(8153).Fd,r=n(2561),s=n(1782),a=n(9937);function l(t,e,n){if(!i(e))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,h="function"==typeof n.outputReducer?n.outputReducer:null,u=s.assign({},a,n.settings),d=s.validateSettings(u);if(d)throw new Error("graphology-layout-forceatlas2: "+d.message);var p,m=s.graphToByteArrays(e,c);for(p=0;p<l;p++)r(u,m.nodes,m.edges);if(!t)return s.collectLayoutChanges(e,m.nodes);s.assignLayoutChanges(e,m.nodes,h)}var c=l.bind(null,!1);c.assign=l.bind(null,!0),c.inferSettings=function(t){var e="number"==typeof t?t:t.order;return{barnesHutOptimize:e>2e3,strongGravityMode:!0,gravity:.05,scalingRatio:10,slowDown:1+Math.log(e)}},t.exports=c},2561:t=>{var e=10;t.exports=function(t,n,i){var o,r,s,a,l,c,h,u,d,p,m,f,g,y,b,v,w,C,A,S,x,E,T,M=n.length,_=i.length,I=t.adjustSizes,L=t.barnesHutTheta*t.barnesHutTheta,N=[];for(s=0;s<M;s+=e)n[s+4]=n[s+2],n[s+5]=n[s+3],n[s+2]=0,n[s+3]=0;if(t.outboundAttractionDistribution){for(m=0,s=0;s<M;s+=e)m+=n[s+6];m/=M/e}if(t.barnesHutOptimize){var P,$,R,k=1/0,O=-1/0,H=1/0,G=-1/0;for(s=0;s<M;s+=e)k=Math.min(k,n[s+0]),O=Math.max(O,n[s+0]),H=Math.min(H,n[s+1]),G=Math.max(G,n[s+1]);var F=O-k,D=G-H;for(F>D?G=(H-=(F-D)/2)+F:O=(k-=(D-F)/2)+D,N[0]=-1,N[1]=(k+O)/2,N[2]=(H+G)/2,N[3]=Math.max(O-k,G-H),N[4]=-1,N[5]=-1,N[6]=0,N[7]=0,N[8]=0,o=1,s=0;s<M;s+=e)for(r=0,R=3;;){if(!(N[r+5]>=0)){if(N[r+0]<0){N[r+0]=s;break}if(N[r+5]=9*o,u=N[r+3]/2,N[(d=N[r+5])+0]=-1,N[d+1]=N[r+1]-u,N[d+2]=N[r+2]-u,N[d+3]=u,N[d+4]=d+9,N[d+5]=-1,N[d+6]=0,N[d+7]=0,N[d+8]=0,N[(d+=9)+0]=-1,N[d+1]=N[r+1]-u,N[d+2]=N[r+2]+u,N[d+3]=u,N[d+4]=d+9,N[d+5]=-1,N[d+6]=0,N[d+7]=0,N[d+8]=0,N[(d+=9)+0]=-1,N[d+1]=N[r+1]+u,N[d+2]=N[r+2]-u,N[d+3]=u,N[d+4]=d+9,N[d+5]=-1,N[d+6]=0,N[d+7]=0,N[d+8]=0,N[(d+=9)+0]=-1,N[d+1]=N[r+1]+u,N[d+2]=N[r+2]+u,N[d+3]=u,N[d+4]=N[r+4],N[d+5]=-1,N[d+6]=0,N[d+7]=0,N[d+8]=0,o+=4,P=n[N[r+0]+0]<N[r+1]?n[N[r+0]+1]<N[r+2]?N[r+5]:N[r+5]+9:n[N[r+0]+1]<N[r+2]?N[r+5]+18:N[r+5]+27,N[r+6]=n[N[r+0]+6],N[r+7]=n[N[r+0]+0],N[r+8]=n[N[r+0]+1],N[P+0]=N[r+0],N[r+0]=-1,P===($=n[s+0]<N[r+1]?n[s+1]<N[r+2]?N[r+5]:N[r+5]+9:n[s+1]<N[r+2]?N[r+5]+18:N[r+5]+27)){if(R--){r=P;continue}R=3;break}N[$+0]=s;break}P=n[s+0]<N[r+1]?n[s+1]<N[r+2]?N[r+5]:N[r+5]+9:n[s+1]<N[r+2]?N[r+5]+18:N[r+5]+27,N[r+7]=(N[r+7]*N[r+6]+n[s+0]*n[s+6])/(N[r+6]+n[s+6]),N[r+8]=(N[r+8]*N[r+6]+n[s+1]*n[s+6])/(N[r+6]+n[s+6]),N[r+6]+=n[s+6],r=P}}if(t.barnesHutOptimize){for(f=t.scalingRatio,s=0;s<M;s+=e)for(r=0;;)if(N[r+5]>=0){if(v=Math.pow(n[s+0]-N[r+7],2)+Math.pow(n[s+1]-N[r+8],2),4*(p=N[r+3])*p/v<L){if(g=n[s+0]-N[r+7],y=n[s+1]-N[r+8],!0===I?v>0?(w=f*n[s+6]*N[r+6]/v,n[s+2]+=g*w,n[s+3]+=y*w):v<0&&(w=-f*n[s+6]*N[r+6]/Math.sqrt(v),n[s+2]+=g*w,n[s+3]+=y*w):v>0&&(w=f*n[s+6]*N[r+6]/v,n[s+2]+=g*w,n[s+3]+=y*w),(r=N[r+4])<0)break;continue}r=N[r+5]}else if((c=N[r+0])>=0&&c!==s&&(v=(g=n[s+0]-n[c+0])*g+(y=n[s+1]-n[c+1])*y,!0===I?v>0?(w=f*n[s+6]*n[c+6]/v,n[s+2]+=g*w,n[s+3]+=y*w):v<0&&(w=-f*n[s+6]*n[c+6]/Math.sqrt(v),n[s+2]+=g*w,n[s+3]+=y*w):v>0&&(w=f*n[s+6]*n[c+6]/v,n[s+2]+=g*w,n[s+3]+=y*w)),(r=N[r+4])<0)break}else for(f=t.scalingRatio,a=0;a<M;a+=e)for(l=0;l<a;l+=e)g=n[a+0]-n[l+0],y=n[a+1]-n[l+1],!0===I?(v=Math.sqrt(g*g+y*y)-n[a+8]-n[l+8])>0?(w=f*n[a+6]*n[l+6]/v/v,n[a+2]+=g*w,n[a+3]+=y*w,n[l+2]-=g*w,n[l+3]-=y*w):v<0&&(w=100*f*n[a+6]*n[l+6],n[a+2]+=g*w,n[a+3]+=y*w,n[l+2]-=g*w,n[l+3]-=y*w):(v=Math.sqrt(g*g+y*y))>0&&(w=f*n[a+6]*n[l+6]/v/v,n[a+2]+=g*w,n[a+3]+=y*w,n[l+2]-=g*w,n[l+3]-=y*w);for(d=t.gravity/t.scalingRatio,f=t.scalingRatio,s=0;s<M;s+=e)w=0,g=n[s+0],y=n[s+1],v=Math.sqrt(Math.pow(g,2)+Math.pow(y,2)),t.strongGravityMode?v>0&&(w=f*n[s+6]*d):v>0&&(w=f*n[s+6]*d/v),n[s+2]-=g*w,n[s+3]-=y*w;for(f=1*(t.outboundAttractionDistribution?m:1),h=0;h<_;h+=3)a=i[h+0],l=i[h+1],u=i[h+2],b=Math.pow(u,t.edgeWeightInfluence),g=n[a+0]-n[l+0],y=n[a+1]-n[l+1],!0===I?(v=Math.sqrt(g*g+y*y)-n[a+8]-n[l+8],t.linLogMode?t.outboundAttractionDistribution?v>0&&(w=-f*b*Math.log(1+v)/v/n[a+6]):v>0&&(w=-f*b*Math.log(1+v)/v):t.outboundAttractionDistribution?v>0&&(w=-f*b/n[a+6]):v>0&&(w=-f*b)):(v=Math.sqrt(Math.pow(g,2)+Math.pow(y,2)),t.linLogMode?t.outboundAttractionDistribution?v>0&&(w=-f*b*Math.log(1+v)/v/n[a+6]):v>0&&(w=-f*b*Math.log(1+v)/v):t.outboundAttractionDistribution?(v=1,w=-f*b/n[a+6]):(v=1,w=-f*b)),v>0&&(n[a+2]+=g*w,n[a+3]+=y*w,n[l+2]-=g*w,n[l+3]-=y*w);if(!0===I)for(s=0;s<M;s+=e)1!==n[s+9]&&((C=Math.sqrt(Math.pow(n[s+2],2)+Math.pow(n[s+3],2)))>10&&(n[s+2]=10*n[s+2]/C,n[s+3]=10*n[s+3]/C),A=n[s+6]*Math.sqrt((n[s+4]-n[s+2])*(n[s+4]-n[s+2])+(n[s+5]-n[s+3])*(n[s+5]-n[s+3])),S=Math.sqrt((n[s+4]+n[s+2])*(n[s+4]+n[s+2])+(n[s+5]+n[s+3])*(n[s+5]+n[s+3]))/2,x=.1*Math.log(1+S)/(1+Math.sqrt(A)),E=n[s+0]+n[s+2]*(x/t.slowDown),n[s+0]=E,T=n[s+1]+n[s+3]*(x/t.slowDown),n[s+1]=T);else for(s=0;s<M;s+=e)1!==n[s+9]&&(A=n[s+6]*Math.sqrt((n[s+4]-n[s+2])*(n[s+4]-n[s+2])+(n[s+5]-n[s+3])*(n[s+5]-n[s+3])),S=Math.sqrt((n[s+4]+n[s+2])*(n[s+4]+n[s+2])+(n[s+5]+n[s+3])*(n[s+5]+n[s+3]))/2,x=n[s+7]*Math.log(1+S)/(1+Math.sqrt(A)),n[s+7]=Math.min(1,Math.sqrt(x*(Math.pow(n[s+2],2)+Math.pow(n[s+3],2))/(1+Math.sqrt(A)))),E=n[s+0]+n[s+2]*(x/t.slowDown),n[s+0]=E,T=n[s+1]+n[s+3]*(x/t.slowDown),n[s+1]=T);return{}}},8153:(t,e)=>{function n(t){return"number"!=typeof t||isNaN(t)?1:t}e.Fd=function(t){return function(t,e){var n={},i=function(t){return void 0===t?e:t};"function"==typeof e&&(i=e);var o=function(e){return i(e[t])},r=function(){return i(void 0)};return"string"==typeof t?(n.fromAttributes=o,n.fromGraph=function(t,e){return o(t.getEdgeAttributes(e))},n.fromEntry=function(t,e){return o(e)},n.fromPartialEntry=n.fromEntry,n.fromMinimalEntry=n.fromEntry):"function"==typeof t?(n.fromAttributes=function(){throw new Error("graphology-utils/getters/createEdgeValueGetter: irrelevant usage.")},n.fromGraph=function(e,n){var o=e.extremities(n);return i(t(n,e.getEdgeAttributes(n),o[0],o[1],e.getNodeAttributes(o[0]),e.getNodeAttributes(o[1]),e.isUndirected(n)))},n.fromEntry=function(e,n,o,r,s,a,l){return i(t(e,n,o,r,s,a,l))},n.fromPartialEntry=function(e,n,o,r){return i(t(e,n,o,r))},n.fromMinimalEntry=function(e,n){return i(t(e,n))}):(n.fromAttributes=r,n.fromGraph=r,n.fromEntry=r,n.fromMinimalEntry=r),n}(t,n)}},1736:t=>{t.exports=function(t){return null!==t&&"object"==typeof t&&"function"==typeof t.addUndirectedEdgeWithKey&&"function"==typeof t.dropNode&&"boolean"==typeof t.multi}},934:function(t){t.exports=function(){"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}function e(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,i(t,e)}function n(t){return n=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},n(t)}function i(t,e){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},i(t,e)}function o(t,e,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(t){return!1}}()?Reflect.construct.bind():function(t,e,n){var o=[null];o.push.apply(o,e);var r=new(Function.bind.apply(t,o));return n&&i(r,n.prototype),r},o.apply(null,arguments)}function r(t){var e="function"==typeof Map?new Map:void 0;return r=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,s)}function s(){return o(t,arguments,n(this).constructor)}return s.prototype=Object.create(t.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),i(s,t)},r(t)}function s(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}var a=function(){for(var t=arguments[0],e=1,n=arguments.length;e<n;e++)if(arguments[e])for(var i in arguments[e])t[i]=arguments[e][i];return t};function l(t,e,n,i){var o=t._nodes.get(e),r=null;return o?r="mixed"===i?o.out&&o.out[n]||o.undirected&&o.undirected[n]:"directed"===i?o.out&&o.out[n]:o.undirected&&o.undirected[n]:r}function c(e){return"object"===t(e)&&null!==e}function h(t){var e;for(e in t)return!1;return!0}function u(t,e,n){Object.defineProperty(t,e,{enumerable:!1,configurable:!1,writable:!0,value:n})}function d(t,e,n){var i={enumerable:!0,configurable:!0};"function"==typeof n?i.get=n:(i.value=n,i.writable=!1),Object.defineProperty(t,e,i)}function p(t){return!(!c(t)||t.attributes&&!Array.isArray(t.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(t,e,n){return Function.prototype.apply.call(t,e,n)};m=g&&"function"==typeof g.ownKeys?g.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var b=Number.isNaN||function(t){return t!=t};function v(){v.init.call(this)}f.exports=v,f.exports.once=function(t,e){return new Promise((function(n,i){function o(n){t.removeListener(e,r),i(n)}function r(){"function"==typeof t.removeListener&&t.removeListener("error",o),n([].slice.call(arguments))}I(t,e,r,{once:!0}),"error"!==e&&function(t,e){"function"==typeof t.on&&I(t,"error",e,{once:!0})}(t,o)}))},v.EventEmitter=v,v.prototype._events=void 0,v.prototype._eventsCount=0,v.prototype._maxListeners=void 0;var w=10;function C(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function A(t){return void 0===t._maxListeners?v.defaultMaxListeners:t._maxListeners}function S(t,e,n,i){var o,r,s,a;if(C(n),void 0===(r=t._events)?(r=t._events=Object.create(null),t._eventsCount=0):(void 0!==r.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),r=t._events),s=r[e]),void 0===s)s=r[e]=n,++t._eventsCount;else if("function"==typeof s?s=r[e]=i?[n,s]:[s,n]:i?s.unshift(n):s.push(n),(o=A(t))>0&&s.length>o&&!s.warned){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=t,l.type=e,l.count=s.length,a=l,console&&console.warn&&console.warn(a)}return t}function x(){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(t,e,n){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},o=x.bind(i);return o.listener=n,i.wrapFn=o,o}function T(t,e,n){var i=t._events;if(void 0===i)return[];var o=i[e];return void 0===o?[]:"function"==typeof o?n?[o.listener||o]:[o]:n?function(t){for(var e=new Array(t.length),n=0;n<e.length;++n)e[n]=t[n].listener||t[n];return e}(o):_(o,o.length)}function M(t){var e=this._events;if(void 0!==e){var n=e[t];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function _(t,e){for(var n=new Array(e),i=0;i<e;++i)n[i]=t[i];return n}function I(t,e,n,i){if("function"==typeof t.on)i.once?t.once(e,n):t.on(e,n);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(e,(function o(r){i.once&&t.removeEventListener(e,o),n(r)}))}}function L(t){if("function"!=typeof t)throw new Error("obliterator/iterator: expecting a function!");this.next=t}Object.defineProperty(v,"defaultMaxListeners",{enumerable:!0,get:function(){return w},set:function(t){if("number"!=typeof t||t<0||b(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");w=t}}),v.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},v.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||b(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},v.prototype.getMaxListeners=function(){return A(this)},v.prototype.emit=function(t){for(var e=[],n=1;n<arguments.length;n++)e.push(arguments[n]);var i="error"===t,o=this._events;if(void 0!==o)i=i&&void 0===o.error;else if(!i)return!1;if(i){var r;if(e.length>0&&(r=e[0]),r instanceof Error)throw r;var s=new Error("Unhandled error."+(r?" ("+r.message+")":""));throw s.context=r,s}var a=o[t];if(void 0===a)return!1;if("function"==typeof a)y(a,this,e);else{var l=a.length,c=_(a,l);for(n=0;n<l;++n)y(c[n],this,e)}return!0},v.prototype.addListener=function(t,e){return S(this,t,e,!1)},v.prototype.on=v.prototype.addListener,v.prototype.prependListener=function(t,e){return S(this,t,e,!0)},v.prototype.once=function(t,e){return C(e),this.on(t,E(this,t,e)),this},v.prototype.prependOnceListener=function(t,e){return C(e),this.prependListener(t,E(this,t,e)),this},v.prototype.removeListener=function(t,e){var n,i,o,r,s;if(C(e),void 0===(i=this._events))return this;if(void 0===(n=i[t]))return this;if(n===e||n.listener===e)0==--this._eventsCount?this._events=Object.create(null):(delete i[t],i.removeListener&&this.emit("removeListener",t,n.listener||e));else if("function"!=typeof n){for(o=-1,r=n.length-1;r>=0;r--)if(n[r]===e||n[r].listener===e){s=n[r].listener,o=r;break}if(o<0)return this;0===o?n.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(n,o),1===n.length&&(i[t]=n[0]),void 0!==i.removeListener&&this.emit("removeListener",t,s||e)}return this},v.prototype.off=v.prototype.removeListener,v.prototype.removeAllListeners=function(t){var e,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[t]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[t]),this;if(0===arguments.length){var o,r=Object.keys(n);for(i=0;i<r.length;++i)"removeListener"!==(o=r[i])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=n[t]))this.removeListener(t,e);else if(void 0!==e)for(i=e.length-1;i>=0;i--)this.removeListener(t,e[i]);return this},v.prototype.listeners=function(t){return T(this,t,!0)},v.prototype.rawListeners=function(t){return T(this,t,!1)},v.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):M.call(t,e)},v.prototype.listenerCount=M,v.prototype.eventNames=function(){return this._eventsCount>0?m(this._events):[]},"undefined"!=typeof Symbol&&(L.prototype[Symbol.iterator]=function(){return this}),L.of=function(){var t=arguments,e=t.length,n=0;return new L((function(){return n>=e?{done:!0}:{done:!1,value:t[n++]}}))},L.empty=function(){return new L((function(){return{done:!0}}))},L.fromSequence=function(t){var e=0,n=t.length;return new L((function(){return e>=n?{done:!0}:{done:!1,value:t[e++]}}))},L.is=function(t){return t instanceof L||"object"==typeof t&&null!==t&&"function"==typeof t.next};var N=L,P={};P.ARRAY_BUFFER_SUPPORT="undefined"!=typeof ArrayBuffer,P.SYMBOL_SUPPORT="undefined"!=typeof Symbol;var $=N,R=P,k=R.ARRAY_BUFFER_SUPPORT,O=R.SYMBOL_SUPPORT,H=function(t){var e=function(t){return"string"==typeof t||Array.isArray(t)||k&&ArrayBuffer.isView(t)?$.fromSequence(t):"object"!=typeof t||null===t?null:O&&"function"==typeof t[Symbol.iterator]?t[Symbol.iterator]():"function"==typeof t.next?t:null}(t);if(!e)throw new Error("obliterator: target is not iterable nor a valid iterator.");return e},G=H,F=function(t,e){for(var n,i=arguments.length>1?e:1/0,o=i!==1/0?new Array(i):[],r=0,s=G(t);;){if(r===i)return o;if((n=s.next()).done)return r!==e&&(o.length=r),o;o[r++]=n.value}},D=function(t){function n(e){var n;return(n=t.call(this)||this).name="GraphError",n.message=e,n}return e(n,t),n}(r(Error)),B=function(t){function n(e){var i;return(i=t.call(this,e)||this).name="InvalidArgumentsGraphError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(s(i),n.prototype.constructor),i}return e(n,t),n}(D),V=function(t){function n(e){var i;return(i=t.call(this,e)||this).name="NotFoundGraphError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(s(i),n.prototype.constructor),i}return e(n,t),n}(D),W=function(t){function n(e){var i;return(i=t.call(this,e)||this).name="UsageGraphError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(s(i),n.prototype.constructor),i}return e(n,t),n}(D);function U(t,e){this.key=t,this.attributes=e,this.clear()}function j(t,e){this.key=t,this.attributes=e,this.clear()}function q(t,e){this.key=t,this.attributes=e,this.clear()}function z(t,e,n,i,o){this.key=e,this.attributes=o,this.undirected=t,this.source=n,this.target=i}function Y(t,e,n,i,o,r,s){var a,l,c,h;if(i=""+i,0===n){if(!(a=t._nodes.get(i)))throw new V("Graph.".concat(e,': could not find the "').concat(i,'" node in the graph.'));c=o,h=r}else if(3===n){if(o=""+o,!(l=t._edges.get(o)))throw new V("Graph.".concat(e,': could not find the "').concat(o,'" edge in the graph.'));var u=l.source.key,d=l.target.key;if(i===u)a=l.target;else{if(i!==d)throw new V("Graph.".concat(e,': the "').concat(i,'" node is not attached to the "').concat(o,'" edge (').concat(u,", ").concat(d,")."));a=l.source}c=r,h=s}else{if(!(l=t._edges.get(i)))throw new V("Graph.".concat(e,': could not find the "').concat(i,'" edge in the graph.'));a=1===n?l.source:l.target,c=o,h=r}return[a,c,h]}U.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}},j.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}},q.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}},z.prototype.attach=function(){var t="out",e="in";this.undirected&&(t=e="undirected");var n=this.source.key,i=this.target.key;this.source[t][i]=this,this.undirected&&n===i||(this.target[e][n]=this)},z.prototype.attachMulti=function(){var t="out",e="in",n=this.source.key,i=this.target.key;this.undirected&&(t=e="undirected");var o=this.source[t],r=o[i];if(void 0===r)return o[i]=this,void(this.undirected&&n===i||(this.target[e][n]=this));r.previous=this,this.next=r,o[i]=this,this.target[e][n]=this},z.prototype.detach=function(){var t=this.source.key,e=this.target.key,n="out",i="in";this.undirected&&(n=i="undirected"),delete this.source[n][e],delete this.target[i][t]},z.prototype.detachMulti=function(){var t=this.source.key,e=this.target.key,n="out",i="in";this.undirected&&(n=i="undirected"),void 0===this.previous?void 0===this.next?(delete this.source[n][e],delete this.target[i][t]):(this.next.previous=void 0,this.source[n][e]=this.next,this.target[i][t]=this.next):(this.previous.next=this.next,void 0!==this.next&&(this.next.previous=this.previous))};var K=[{name:function(t){return"get".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,i,o){var r=Y(this,e,n,t,i,o),s=r[0],a=r[1];return s.attributes[a]}}},{name:function(t){return"get".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,i){return Y(this,e,n,t,i)[0].attributes}}},{name:function(t){return"has".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,i,o){var r=Y(this,e,n,t,i,o),s=r[0],a=r[1];return s.attributes.hasOwnProperty(a)}}},{name:function(t){return"set".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,i,o,r){var s=Y(this,e,n,t,i,o,r),a=s[0],l=s[1],c=s[2];return a.attributes[l]=c,this.emit("nodeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:l}),this}}},{name:function(t){return"update".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,i,o,r){var s=Y(this,e,n,t,i,o,r),a=s[0],l=s[1],c=s[2];if("function"!=typeof c)throw new B("Graph.".concat(e,": updater should be a function."));var h=a.attributes,u=c(h[l]);return h[l]=u,this.emit("nodeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:l}),this}}},{name:function(t){return"remove".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,i,o){var r=Y(this,e,n,t,i,o),s=r[0],a=r[1];return delete s.attributes[a],this.emit("nodeAttributesUpdated",{key:s.key,type:"remove",attributes:s.attributes,name:a}),this}}},{name:function(t){return"replace".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,i,o){var r=Y(this,e,n,t,i,o),s=r[0],a=r[1];if(!c(a))throw new B("Graph.".concat(e,": provided attributes are not a plain object."));return s.attributes=a,this.emit("nodeAttributesUpdated",{key:s.key,type:"replace",attributes:s.attributes}),this}}},{name:function(t){return"merge".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,i,o){var r=Y(this,e,n,t,i,o),s=r[0],l=r[1];if(!c(l))throw new B("Graph.".concat(e,": provided attributes are not a plain object."));return a(s.attributes,l),this.emit("nodeAttributesUpdated",{key:s.key,type:"merge",attributes:s.attributes,data:l}),this}}},{name:function(t){return"update".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,i,o){var r=Y(this,e,n,t,i,o),s=r[0],a=r[1];if("function"!=typeof a)throw new B("Graph.".concat(e,": provided updater is not a function."));return s.attributes=a(s.attributes),this.emit("nodeAttributesUpdated",{key:s.key,type:"update",attributes:s.attributes}),this}}}],Z=[{name:function(t){return"get".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,i){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new W("Graph.".concat(e,": 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=""+t,s=""+i;if(i=arguments[2],!(o=l(this,r,s,n)))throw new V("Graph.".concat(e,': could not find an edge for the given path ("').concat(r,'" - "').concat(s,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(e,": 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(t=""+t,!(o=this._edges.get(t)))throw new V("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}return o.attributes[i]}}},{name:function(t){return"get".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t){var i;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>1){if(this.multi)throw new W("Graph.".concat(e,": 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=""+t,r=""+arguments[1];if(!(i=l(this,o,r,n)))throw new V("Graph.".concat(e,': could not find an edge for the given path ("').concat(o,'" - "').concat(r,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(e,": 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(t=""+t,!(i=this._edges.get(t)))throw new V("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}return i.attributes}}},{name:function(t){return"has".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,i){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new W("Graph.".concat(e,": 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=""+t,s=""+i;if(i=arguments[2],!(o=l(this,r,s,n)))throw new V("Graph.".concat(e,': could not find an edge for the given path ("').concat(r,'" - "').concat(s,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(e,": 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(t=""+t,!(o=this._edges.get(t)))throw new V("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}return o.attributes.hasOwnProperty(i)}}},{name:function(t){return"set".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,i,o){var r;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>3){if(this.multi)throw new W("Graph.".concat(e,": 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=""+t,a=""+i;if(i=arguments[2],o=arguments[3],!(r=l(this,s,a,n)))throw new V("Graph.".concat(e,': could not find an edge for the given path ("').concat(s,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(e,": 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(t=""+t,!(r=this._edges.get(t)))throw new V("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}return r.attributes[i]=o,this.emit("edgeAttributesUpdated",{key:r.key,type:"set",attributes:r.attributes,name:i}),this}}},{name:function(t){return"update".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,i,o){var r;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>3){if(this.multi)throw new W("Graph.".concat(e,": 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=""+t,a=""+i;if(i=arguments[2],o=arguments[3],!(r=l(this,s,a,n)))throw new V("Graph.".concat(e,': could not find an edge for the given path ("').concat(s,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(e,": 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(t=""+t,!(r=this._edges.get(t)))throw new V("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}if("function"!=typeof o)throw new B("Graph.".concat(e,": updater should be a function."));return r.attributes[i]=o(r.attributes[i]),this.emit("edgeAttributesUpdated",{key:r.key,type:"set",attributes:r.attributes,name:i}),this}}},{name:function(t){return"remove".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,i){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new W("Graph.".concat(e,": 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=""+t,s=""+i;if(i=arguments[2],!(o=l(this,r,s,n)))throw new V("Graph.".concat(e,': could not find an edge for the given path ("').concat(r,'" - "').concat(s,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(e,": 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(t=""+t,!(o=this._edges.get(t)))throw new V("Graph.".concat(e,': could not find the "').concat(t,'" 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(t){return"replace".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,i){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new W("Graph.".concat(e,": 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=""+t,s=""+i;if(i=arguments[2],!(o=l(this,r,s,n)))throw new V("Graph.".concat(e,': could not find an edge for the given path ("').concat(r,'" - "').concat(s,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(e,": 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(t=""+t,!(o=this._edges.get(t)))throw new V("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}if(!c(i))throw new B("Graph.".concat(e,": 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(t){return"merge".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,i){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new W("Graph.".concat(e,": 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=""+t,s=""+i;if(i=arguments[2],!(o=l(this,r,s,n)))throw new V("Graph.".concat(e,': could not find an edge for the given path ("').concat(r,'" - "').concat(s,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(e,": 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(t=""+t,!(o=this._edges.get(t)))throw new V("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}if(!c(i))throw new B("Graph.".concat(e,": 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(t){return"update".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,i){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new W("Graph.".concat(e,": 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=""+t,s=""+i;if(i=arguments[2],!(o=l(this,r,s,n)))throw new V("Graph.".concat(e,': could not find an edge for the given path ("').concat(r,'" - "').concat(s,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(e,": 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(t=""+t,!(o=this._edges.get(t)))throw new V("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}if("function"!=typeof i)throw new B("Graph.".concat(e,": 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=N,J=H,Q=function(){var t=arguments,e=null,n=-1;return new X((function(){for(var i=null;;){if(null===e){if(++n>=t.length)return{done:!0};e=J(t[n])}if(!0!==(i=e.next()).done)break;e=null}return i}))},tt=[{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 et(t,e,n,i){var o=!1;for(var r in e)if(r!==i){var s=e[r];if(o=n(s.key,s.attributes,s.source.key,s.target.key,s.source.attributes,s.target.attributes,s.undirected),t&&o)return s.key}}function nt(t,e,n,i){var o,r,s,a=!1;for(var l in e)if(l!==i){o=e[l];do{if(r=o.source,s=o.target,a=n(o.key,o.attributes,r.key,s.key,r.attributes,s.attributes,o.undirected),t&&a)return o.key;o=o.next}while(void 0!==o)}}function it(t,e){var n,i=Object.keys(t),o=i.length,r=0;return new N((function(){do{if(n)n=n.next;else{if(r>=o)return{done:!0};var s=i[r++];if(s===e){n=void 0;continue}n=t[s]}}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 ot(t,e,n,i){var o=e[n];if(o){var r=o.source,s=o.target;return i(o.key,o.attributes,r.key,s.key,r.attributes,s.attributes,o.undirected)&&t?o.key:void 0}}function rt(t,e,n,i){var o=e[n];if(o){var r=!1;do{if(r=i(o.key,o.attributes,o.source.key,o.target.key,o.source.attributes,o.target.attributes,o.undirected),t&&r)return o.key;o=o.next}while(void 0!==o)}}function st(t,e){var n=t[e];return void 0!==n.next?new N((function(){if(!n)return{done:!0};var t={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:t}})):N.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 at(t,e,n,i){if(0!==e.size)for(var o,r,s="mixed"!==n&&n!==e.type,a="undirected"===n,l=!1,c=e._edges.values();!0!==(o=c.next()).done;)if(r=o.value,!s||r.undirected===a){var h=r,u=h.key,d=h.attributes,p=h.source,m=h.target;if(l=i(u,d,p.key,m.key,p.attributes,m.attributes,r.undirected),t&&l)return u}}function lt(t,e,n,i,o,r){var s,a=e?nt:et;if("undirected"!==n){if("out"!==i&&(s=a(t,o.in,r),t&&s))return s;if("in"!==i&&(s=a(t,o.out,r,i?void 0:o.key),t&&s))return s}if("directed"!==n&&(s=a(t,o.undirected,r),t&&s))return s}function ct(t,e,n,i,o,r,s){var a,l=n?rt:ot;if("undirected"!==e){if(void 0!==o.in&&"out"!==i&&(a=l(t,o.in,r,s),t&&a))return a;if(void 0!==o.out&&"in"!==i&&(i||o.key!==r)&&(a=l(t,o.out,r,s),t&&a))return a}if("directed"!==e&&void 0!==o.undirected&&(a=l(t,o.undirected,r,s),t&&a))return a}var ht=[{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 ut(){this.A=null,this.B=null}function dt(t,e,n,i,o){for(var r in i){var s=i[r],a=s.source,l=s.target,c=a===n?l:a;if(!e||!e.has(c.key)){var h=o(c.key,c.attributes);if(t&&h)return c.key}}}function pt(t,e,n,i,o){if("mixed"!==e){if("undirected"===e)return dt(t,null,i,i.undirected,o);if("string"==typeof n)return dt(t,null,i,i[n],o)}var r,s=new ut;if("undirected"!==e){if("out"!==n){if(r=dt(t,null,i,i.in,o),t&&r)return r;s.wrap(i.in)}if("in"!==n){if(r=dt(t,s,i,i.out,o),t&&r)return r;s.wrap(i.out)}}if("directed"!==e&&(r=dt(t,s,i,i.undirected,o),t&&r))return r}function mt(t,e,n){var i=Object.keys(n),o=i.length,r=0;return new N((function(){var s=null;do{if(r>=o)return t&&t.wrap(n),{done:!0};var a=n[i[r++]],l=a.source,c=a.target;s=l===e?c:l,t&&t.has(s.key)&&(s=null)}while(null===s);return{done:!1,value:{neighbor:s.key,attributes:s.attributes}}}))}function ft(t,e,n,i,o){for(var r,s,a,l,c,h,u,d=i._nodes.values(),p=i.type;!0!==(r=d.next()).done;){var m=!1;if(s=r.value,"undirected"!==p)for(a in l=s.out){c=l[a];do{if(h=c.target,m=!0,u=o(s.key,h.key,s.attributes,h.attributes,c.key,c.attributes,c.undirected),t&&u)return c;c=c.next}while(c)}if("directed"!==p)for(a in l=s.undirected)if(!(e&&s.key>a)){c=l[a];do{if((h=c.target).key!==a&&(h=c.source),m=!0,u=o(s.key,h.key,s.attributes,h.attributes,c.key,c.attributes,c.undirected),t&&u)return c;c=c.next}while(c)}if(n&&!m&&(u=o(s.key,null,s.attributes,null,null,null,null),t&&u))return null}}function gt(t){if(!c(t))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 t))throw new B("Graph.import: serialized node is missing its key.");if("attributes"in t&&(!c(t.attributes)||null===t.attributes))throw new B("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function yt(t){if(!c(t))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 t))throw new B("Graph.import: serialized edge is missing its source.");if(!("target"in t))throw new B("Graph.import: serialized edge is missing its target.");if("attributes"in t&&(!c(t.attributes)||null===t.attributes))throw new B("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in t&&"boolean"!=typeof t.undirected)throw new B("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}ut.prototype.wrap=function(t){null===this.A?this.A=t:null===this.B&&(this.B=t)},ut.prototype.has=function(t){return null!==this.A&&t in this.A||null!==this.B&&t in this.B};var bt,vt=(bt=255&Math.floor(256*Math.random()),function(){return bt++}),wt=new Set(["directed","undirected","mixed"]),Ct=new Set(["domain","_events","_eventsCount","_maxListeners"]),At={allowSelfLoops:!0,multi:!1,type:"mixed"};function St(t,e,n){var i=new t.NodeDataClass(e,n);return t._nodes.set(e,i),t.emit("nodeAdded",{key:e,attributes:n}),i}function xt(t,e,n,i,o,r,s,a){if(!i&&"undirected"===t.type)throw new W("Graph.".concat(e,": you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead."));if(i&&"directed"===t.type)throw new W("Graph.".concat(e,": 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(e,': invalid attributes. Expecting an object but got "').concat(a,'"'));if(r=""+r,s=""+s,a=a||{},!t.allowSelfLoops&&r===s)throw new W("Graph.".concat(e,': source & target are the same ("').concat(r,"\"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false."));var l=t._nodes.get(r),h=t._nodes.get(s);if(!l)throw new V("Graph.".concat(e,': source node "').concat(r,'" not found.'));if(!h)throw new V("Graph.".concat(e,': target node "').concat(s,'" not found.'));var u={key:null,undirected:i,source:r,target:s,attributes:a};if(n)o=t._edgeKeyGenerator();else if(o=""+o,t._edges.has(o))throw new W("Graph.".concat(e,': the "').concat(o,'" edge already exists in the graph.'));if(!t.multi&&(i?void 0!==l.undirected[s]:void 0!==l.out[s]))throw new W("Graph.".concat(e,': an edge linking "').concat(r,'" to "').concat(s,"\" 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 z(i,o,l,h,a);t._edges.set(o,d);var p=r===s;return i?(l.undirectedDegree++,h.undirectedDegree++,p&&(l.undirectedLoops++,t._undirectedSelfLoopCount++)):(l.outDegree++,h.inDegree++,p&&(l.directedLoops++,t._directedSelfLoopCount++)),t.multi?d.attachMulti():d.attach(),i?t._undirectedSize++:t._directedSize++,u.key=o,t.emit("edgeAdded",u),o}function Et(t,e,n,i,o,r,s,l,h){if(!i&&"undirected"===t.type)throw new W("Graph.".concat(e,": you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead."));if(i&&"directed"===t.type)throw new W("Graph.".concat(e,": you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead."));if(l)if(h){if("function"!=typeof l)throw new B("Graph.".concat(e,': invalid updater function. Expecting a function but got "').concat(l,'"'))}else if(!c(l))throw new B("Graph.".concat(e,': invalid attributes. Expecting an object but got "').concat(l,'"'));var u;if(r=""+r,s=""+s,h&&(u=l,l=void 0),!t.allowSelfLoops&&r===s)throw new W("Graph.".concat(e,': source & target are the same ("').concat(r,"\"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false."));var d,p,m=t._nodes.get(r),f=t._nodes.get(s);if(!n&&(d=t._edges.get(o))){if(!(d.source.key===r&&d.target.key===s||i&&d.source.key===s&&d.target.key===r))throw new W("Graph.".concat(e,': inconsistency detected when attempting to merge the "').concat(o,'" edge with "').concat(r,'" source & "').concat(s,'" target vs. ("').concat(d.source.key,'", "').concat(d.target.key,'").'));p=d}if(p||t.multi||!m||(p=i?m.undirected[s]:m.out[s]),p){var g=[p.key,!1,!1,!1];if(h?!u:!l)return g;if(h){var y=p.attributes;p.attributes=u(y),t.emit("edgeAttributesUpdated",{type:"replace",key:p.key,attributes:p.attributes})}else a(p.attributes,l),t.emit("edgeAttributesUpdated",{type:"merge",key:p.key,attributes:p.attributes,data:l});return g}l=l||{},h&&u&&(l=u(l));var b={key:null,undirected:i,source:r,target:s,attributes:l};if(n)o=t._edgeKeyGenerator();else if(o=""+o,t._edges.has(o))throw new W("Graph.".concat(e,': the "').concat(o,'" edge already exists in the graph.'));var v=!1,w=!1;m||(m=St(t,r,{}),v=!0,r===s&&(f=m,w=!0)),f||(f=St(t,s,{}),w=!0),d=new z(i,o,m,f,l),t._edges.set(o,d);var C=r===s;return i?(m.undirectedDegree++,f.undirectedDegree++,C&&(m.undirectedLoops++,t._undirectedSelfLoopCount++)):(m.outDegree++,f.inDegree++,C&&(m.directedLoops++,t._directedSelfLoopCount++)),t.multi?d.attachMulti():d.attach(),i?t._undirectedSize++:t._directedSize++,b.key=o,t.emit("edgeAdded",b),[o,!0,v,w]}function Tt(t,e){t._edges.delete(e.key);var n=e.source,i=e.target,o=e.attributes,r=e.undirected,s=n===i;r?(n.undirectedDegree--,i.undirectedDegree--,s&&(n.undirectedLoops--,t._undirectedSelfLoopCount--)):(n.outDegree--,i.inDegree--,s&&(n.directedLoops--,t._directedSelfLoopCount--)),t.multi?e.detachMulti():e.detach(),r?t._undirectedSize--:t._directedSize--,t.emit("edgeDropped",{key:e.key,attributes:o,source:n.key,target:i.key,undirected:r})}var Mt=function(n){function i(t){var e;if(e=n.call(this)||this,"boolean"!=typeof(t=a({},At,t)).multi)throw new B("Graph.constructor: invalid 'multi' option. Expecting a boolean but got \"".concat(t.multi,'".'));if(!wt.has(t.type))throw new B('Graph.constructor: invalid \'type\' option. Should be one of "mixed", "directed" or "undirected" but got "'.concat(t.type,'".'));if("boolean"!=typeof t.allowSelfLoops)throw new B("Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got \"".concat(t.allowSelfLoops,'".'));var i="mixed"===t.type?U:"directed"===t.type?j:q;u(s(e),"NodeDataClass",i);var o="geid_"+vt()+"_",r=0;return u(s(e),"_attributes",{}),u(s(e),"_nodes",new Map),u(s(e),"_edges",new Map),u(s(e),"_directedSize",0),u(s(e),"_undirectedSize",0),u(s(e),"_directedSelfLoopCount",0),u(s(e),"_undirectedSelfLoopCount",0),u(s(e),"_edgeKeyGenerator",(function(){var t;do{t=o+r++}while(e._edges.has(t));return t})),u(s(e),"_options",t),Ct.forEach((function(t){return u(s(e),t,e[t])})),d(s(e),"order",(function(){return e._nodes.size})),d(s(e),"size",(function(){return e._edges.size})),d(s(e),"directedSize",(function(){return e._directedSize})),d(s(e),"undirectedSize",(function(){return e._undirectedSize})),d(s(e),"selfLoopCount",(function(){return e._directedSelfLoopCount+e._undirectedSelfLoopCount})),d(s(e),"directedSelfLoopCount",(function(){return e._directedSelfLoopCount})),d(s(e),"undirectedSelfLoopCount",(function(){return e._undirectedSelfLoopCount})),d(s(e),"multi",e._options.multi),d(s(e),"type",e._options.type),d(s(e),"allowSelfLoops",e._options.allowSelfLoops),d(s(e),"implementation",(function(){return"graphology"})),e}e(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(t){return this._nodes.has(""+t)},o.hasDirectedEdge=function(t,e){if("undirected"===this.type)return!1;if(1===arguments.length){var n=""+t,i=this._edges.get(n);return!!i&&!i.undirected}if(2===arguments.length){t=""+t,e=""+e;var o=this._nodes.get(t);return!!o&&o.out.hasOwnProperty(e)}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(t,e){if("directed"===this.type)return!1;if(1===arguments.length){var n=""+t,i=this._edges.get(n);return!!i&&i.undirected}if(2===arguments.length){t=""+t,e=""+e;var o=this._nodes.get(t);return!!o&&o.undirected.hasOwnProperty(e)}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(t,e){if(1===arguments.length){var n=""+t;return this._edges.has(n)}if(2===arguments.length){t=""+t,e=""+e;var i=this._nodes.get(t);return!!i&&(void 0!==i.out&&i.out.hasOwnProperty(e)||void 0!==i.undirected&&i.undirected.hasOwnProperty(e))}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(t,e){if("undirected"!==this.type){if(t=""+t,e=""+e,this.multi)throw new W("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(t);if(!n)throw new V('Graph.directedEdge: could not find the "'.concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new V('Graph.directedEdge: could not find the "'.concat(e,'" target node in the graph.'));var i=n.out&&n.out[e]||void 0;return i?i.key:void 0}},o.undirectedEdge=function(t,e){if("directed"!==this.type){if(t=""+t,e=""+e,this.multi)throw new W("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(t);if(!n)throw new V('Graph.undirectedEdge: could not find the "'.concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new V('Graph.undirectedEdge: could not find the "'.concat(e,'" target node in the graph.'));var i=n.undirected&&n.undirected[e]||void 0;return i?i.key:void 0}},o.edge=function(t,e){if(this.multi)throw new W("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new V('Graph.edge: could not find the "'.concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new V('Graph.edge: could not find the "'.concat(e,'" target node in the graph.'));var i=n.out&&n.out[e]||n.undirected&&n.undirected[e]||void 0;if(i)return i.key},o.areDirectedNeighbors=function(t,e){t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new V('Graph.areDirectedNeighbors: could not find the "'.concat(t,'" node in the graph.'));return"undirected"!==this.type&&(e in n.in||e in n.out)},o.areOutNeighbors=function(t,e){t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new V('Graph.areOutNeighbors: could not find the "'.concat(t,'" node in the graph.'));return"undirected"!==this.type&&e in n.out},o.areInNeighbors=function(t,e){t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new V('Graph.areInNeighbors: could not find the "'.concat(t,'" node in the graph.'));return"undirected"!==this.type&&e in n.in},o.areUndirectedNeighbors=function(t,e){t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new V('Graph.areUndirectedNeighbors: could not find the "'.concat(t,'" node in the graph.'));return"directed"!==this.type&&e in n.undirected},o.areNeighbors=function(t,e){t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new V('Graph.areNeighbors: could not find the "'.concat(t,'" node in the graph.'));return"undirected"!==this.type&&(e in n.in||e in n.out)||"directed"!==this.type&&e in n.undirected},o.areInboundNeighbors=function(t,e){t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new V('Graph.areInboundNeighbors: could not find the "'.concat(t,'" node in the graph.'));return"undirected"!==this.type&&e in n.in||"directed"!==this.type&&e in n.undirected},o.areOutboundNeighbors=function(t,e){t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new V('Graph.areOutboundNeighbors: could not find the "'.concat(t,'" node in the graph.'));return"undirected"!==this.type&&e in n.out||"directed"!==this.type&&e in n.undirected},o.inDegree=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new V('Graph.inDegree: could not find the "'.concat(t,'" node in the graph.'));return"undirected"===this.type?0:e.inDegree},o.outDegree=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new V('Graph.outDegree: could not find the "'.concat(t,'" node in the graph.'));return"undirected"===this.type?0:e.outDegree},o.directedDegree=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new V('Graph.directedDegree: could not find the "'.concat(t,'" node in the graph.'));return"undirected"===this.type?0:e.inDegree+e.outDegree},o.undirectedDegree=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new V('Graph.undirectedDegree: could not find the "'.concat(t,'" node in the graph.'));return"directed"===this.type?0:e.undirectedDegree},o.inboundDegree=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new V('Graph.inboundDegree: could not find the "'.concat(t,'" node in the graph.'));var n=0;return"directed"!==this.type&&(n+=e.undirectedDegree),"undirected"!==this.type&&(n+=e.inDegree),n},o.outboundDegree=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new V('Graph.outboundDegree: could not find the "'.concat(t,'" node in the graph.'));var n=0;return"directed"!==this.type&&(n+=e.undirectedDegree),"undirected"!==this.type&&(n+=e.outDegree),n},o.degree=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new V('Graph.degree: could not find the "'.concat(t,'" node in the graph.'));var n=0;return"directed"!==this.type&&(n+=e.undirectedDegree),"undirected"!==this.type&&(n+=e.inDegree+e.outDegree),n},o.inDegreeWithoutSelfLoops=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new V('Graph.inDegreeWithoutSelfLoops: could not find the "'.concat(t,'" node in the graph.'));return"undirected"===this.type?0:e.inDegree-e.directedLoops},o.outDegreeWithoutSelfLoops=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new V('Graph.outDegreeWithoutSelfLoops: could not find the "'.concat(t,'" node in the graph.'));return"undirected"===this.type?0:e.outDegree-e.directedLoops},o.directedDegreeWithoutSelfLoops=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new V('Graph.directedDegreeWithoutSelfLoops: could not find the "'.concat(t,'" node in the graph.'));return"undirected"===this.type?0:e.inDegree+e.outDegree-2*e.directedLoops},o.undirectedDegreeWithoutSelfLoops=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new V('Graph.undirectedDegreeWithoutSelfLoops: could not find the "'.concat(t,'" node in the graph.'));return"directed"===this.type?0:e.undirectedDegree-2*e.undirectedLoops},o.inboundDegreeWithoutSelfLoops=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new V('Graph.inboundDegreeWithoutSelfLoops: could not find the "'.concat(t,'" node in the graph.'));var n=0,i=0;return"directed"!==this.type&&(n+=e.undirectedDegree,i+=2*e.undirectedLoops),"undirected"!==this.type&&(n+=e.inDegree,i+=e.directedLoops),n-i},o.outboundDegreeWithoutSelfLoops=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new V('Graph.outboundDegreeWithoutSelfLoops: could not find the "'.concat(t,'" node in the graph.'));var n=0,i=0;return"directed"!==this.type&&(n+=e.undirectedDegree,i+=2*e.undirectedLoops),"undirected"!==this.type&&(n+=e.outDegree,i+=e.directedLoops),n-i},o.degreeWithoutSelfLoops=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new V('Graph.degreeWithoutSelfLoops: could not find the "'.concat(t,'" node in the graph.'));var n=0,i=0;return"directed"!==this.type&&(n+=e.undirectedDegree,i+=2*e.undirectedLoops),"undirected"!==this.type&&(n+=e.inDegree+e.outDegree,i+=2*e.directedLoops),n-i},o.source=function(t){t=""+t;var e=this._edges.get(t);if(!e)throw new V('Graph.source: could not find the "'.concat(t,'" edge in the graph.'));return e.source.key},o.target=function(t){t=""+t;var e=this._edges.get(t);if(!e)throw new V('Graph.target: could not find the "'.concat(t,'" edge in the graph.'));return e.target.key},o.extremities=function(t){t=""+t;var e=this._edges.get(t);if(!e)throw new V('Graph.extremities: could not find the "'.concat(t,'" edge in the graph.'));return[e.source.key,e.target.key]},o.opposite=function(t,e){t=""+t,e=""+e;var n=this._edges.get(e);if(!n)throw new V('Graph.opposite: could not find the "'.concat(e,'" edge in the graph.'));var i=n.source.key,o=n.target.key;if(t===i)return o;if(t===o)return i;throw new V('Graph.opposite: the "'.concat(t,'" node is not attached to the "').concat(e,'" edge (').concat(i,", ").concat(o,")."))},o.hasExtremity=function(t,e){t=""+t,e=""+e;var n=this._edges.get(t);if(!n)throw new V('Graph.hasExtremity: could not find the "'.concat(t,'" edge in the graph.'));return n.source.key===e||n.target.key===e},o.isUndirected=function(t){t=""+t;var e=this._edges.get(t);if(!e)throw new V('Graph.isUndirected: could not find the "'.concat(t,'" edge in the graph.'));return e.undirected},o.isDirected=function(t){t=""+t;var e=this._edges.get(t);if(!e)throw new V('Graph.isDirected: could not find the "'.concat(t,'" edge in the graph.'));return!e.undirected},o.isSelfLoop=function(t){t=""+t;var e=this._edges.get(t);if(!e)throw new V('Graph.isSelfLoop: could not find the "'.concat(t,'" edge in the graph.'));return e.source===e.target},o.addNode=function(t,e){var n=function(t,e,n){if(n&&!c(n))throw new B('Graph.addNode: invalid attributes. Expecting an object but got "'.concat(n,'"'));if(e=""+e,n=n||{},t._nodes.has(e))throw new W('Graph.addNode: the "'.concat(e,'" node already exist in the graph.'));var i=new t.NodeDataClass(e,n);return t._nodes.set(e,i),t.emit("nodeAdded",{key:e,attributes:n}),i}(this,t,e);return n.key},o.mergeNode=function(t,e){if(e&&!c(e))throw new B('Graph.mergeNode: invalid attributes. Expecting an object but got "'.concat(e,'"'));t=""+t,e=e||{};var n=this._nodes.get(t);return n?(e&&(a(n.attributes,e),this.emit("nodeAttributesUpdated",{type:"merge",key:t,attributes:n.attributes,data:e})),[t,!1]):(n=new this.NodeDataClass(t,e),this._nodes.set(t,n),this.emit("nodeAdded",{key:t,attributes:e}),[t,!0])},o.updateNode=function(t,e){if(e&&"function"!=typeof e)throw new B('Graph.updateNode: invalid updater function. Expecting a function but got "'.concat(e,'"'));t=""+t;var n=this._nodes.get(t);if(n){if(e){var i=n.attributes;n.attributes=e(i),this.emit("nodeAttributesUpdated",{type:"replace",key:t,attributes:n.attributes})}return[t,!1]}var o=e?e({}):{};return n=new this.NodeDataClass(t,o),this._nodes.set(t,n),this.emit("nodeAdded",{key:t,attributes:o}),[t,!0]},o.dropNode=function(t){t=""+t;var e,n=this._nodes.get(t);if(!n)throw new V('Graph.dropNode: could not find the "'.concat(t,'" node in the graph.'));if("undirected"!==this.type){for(var i in n.out){e=n.out[i];do{Tt(this,e),e=e.next}while(e)}for(var o in n.in){e=n.in[o];do{Tt(this,e),e=e.next}while(e)}}if("directed"!==this.type)for(var r in n.undirected){e=n.undirected[r];do{Tt(this,e),e=e.next}while(e)}this._nodes.delete(t),this.emit("nodeDropped",{key:t,attributes:n.attributes})},o.dropEdge=function(t){var e;if(arguments.length>1){var n=""+arguments[0],i=""+arguments[1];if(!(e=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(t=""+t,!(e=this._edges.get(t)))throw new V('Graph.dropEdge: could not find the "'.concat(t,'" edge in the graph.'));return Tt(this,e),this},o.dropDirectedEdge=function(t,e){if(arguments.length<2)throw new W("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 W("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,t=""+t,e=""+e,"directed");if(!n)throw new V('Graph.dropDirectedEdge: could not find a "'.concat(t,'" -> "').concat(e,'" edge in the graph.'));return Tt(this,n),this},o.dropUndirectedEdge=function(t,e){if(arguments.length<2)throw new W("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 W("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,t,e,"undirected");if(!n)throw new V('Graph.dropUndirectedEdge: could not find a "'.concat(t,'" -> "').concat(e,'" edge in the graph.'));return Tt(this,n),this},o.clear=function(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")},o.clearEdges=function(){for(var t,e=this._nodes.values();!0!==(t=e.next()).done;)t.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")},o.getAttribute=function(t){return this._attributes[t]},o.getAttributes=function(){return this._attributes},o.hasAttribute=function(t){return this._attributes.hasOwnProperty(t)},o.setAttribute=function(t,e){return this._attributes[t]=e,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:t}),this},o.updateAttribute=function(t,e){if("function"!=typeof e)throw new B("Graph.updateAttribute: updater should be a function.");var n=this._attributes[t];return this._attributes[t]=e(n),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:t}),this},o.removeAttribute=function(t){return delete this._attributes[t],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:t}),this},o.replaceAttributes=function(t){if(!c(t))throw new B("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=t,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this},o.mergeAttributes=function(t){if(!c(t))throw new B("Graph.mergeAttributes: provided attributes are not a plain object.");return a(this._attributes,t),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:t}),this},o.updateAttributes=function(t){if("function"!=typeof t)throw new B("Graph.updateAttributes: provided updater is not a function.");return this._attributes=t(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this},o.updateEachNodeAttributes=function(t,e){if("function"!=typeof t)throw new B("Graph.updateEachNodeAttributes: expecting an updater function.");if(e&&!p(e))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=t(i.key,i.attributes);this.emit("eachNodeAttributesUpdated",{hints:e||null})},o.updateEachEdgeAttributes=function(t,e){if("function"!=typeof t)throw new B("Graph.updateEachEdgeAttributes: expecting an updater function.");if(e&&!p(e))throw new B("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");for(var n,i,o,r,s=this._edges.values();!0!==(n=s.next()).done;)o=(i=n.value).source,r=i.target,i.attributes=t(i.key,i.attributes,o.key,r.key,o.attributes,r.attributes,i.undirected);this.emit("eachEdgeAttributesUpdated",{hints:e||null})},o.forEachAdjacencyEntry=function(t){if("function"!=typeof t)throw new B("Graph.forEachAdjacencyEntry: expecting a callback.");ft(!1,!1,!1,this,t)},o.forEachAdjacencyEntryWithOrphans=function(t){if("function"!=typeof t)throw new B("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");ft(!1,!1,!0,this,t)},o.forEachAssymetricAdjacencyEntry=function(t){if("function"!=typeof t)throw new B("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");ft(!1,!0,!1,this,t)},o.forEachAssymetricAdjacencyEntryWithOrphans=function(t){if("function"!=typeof t)throw new B("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");ft(!1,!0,!0,this,t)},o.nodes=function(){return"function"==typeof Array.from?Array.from(this._nodes.keys()):F(this._nodes.keys(),this._nodes.size)},o.forEachNode=function(t){if("function"!=typeof t)throw new B("Graph.forEachNode: expecting a callback.");for(var e,n,i=this._nodes.values();!0!==(e=i.next()).done;)t((n=e.value).key,n.attributes)},o.findNode=function(t){if("function"!=typeof t)throw new B("Graph.findNode: expecting a callback.");for(var e,n,i=this._nodes.values();!0!==(e=i.next()).done;)if(t((n=e.value).key,n.attributes))return n.key},o.mapNodes=function(t){if("function"!=typeof t)throw new B("Graph.mapNode: expecting a callback.");for(var e,n,i=this._nodes.values(),o=new Array(this.order),r=0;!0!==(e=i.next()).done;)n=e.value,o[r++]=t(n.key,n.attributes);return o},o.someNode=function(t){if("function"!=typeof t)throw new B("Graph.someNode: expecting a callback.");for(var e,n,i=this._nodes.values();!0!==(e=i.next()).done;)if(t((n=e.value).key,n.attributes))return!0;return!1},o.everyNode=function(t){if("function"!=typeof t)throw new B("Graph.everyNode: expecting a callback.");for(var e,n,i=this._nodes.values();!0!==(e=i.next()).done;)if(!t((n=e.value).key,n.attributes))return!1;return!0},o.filterNodes=function(t){if("function"!=typeof t)throw new B("Graph.filterNodes: expecting a callback.");for(var e,n,i=this._nodes.values(),o=[];!0!==(e=i.next()).done;)t((n=e.value).key,n.attributes)&&o.push(n.key);return o},o.reduceNodes=function(t,e){if("function"!=typeof t)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=e,r=this._nodes.values();!0!==(n=r.next()).done;)o=t(o,(i=n.value).key,i.attributes);return o},o.nodeEntries=function(){var t=this._nodes.values();return new N((function(){var e=t.next();if(e.done)return e;var n=e.value;return{value:{node:n.key,attributes:n.attributes},done:!1}}))},o.export=function(){var t=this,e=new Array(this._nodes.size),n=0;this._nodes.forEach((function(t,i){e[n++]=function(t,e){var n={key:t};return h(e.attributes)||(n.attributes=a({},e.attributes)),n}(i,t)}));var i=new Array(this._edges.size);return n=0,this._edges.forEach((function(e,o){i[n++]=function(t,e,n){var i={key:e,source:n.source.key,target:n.target.key};return h(n.attributes)||(i.attributes=a({},n.attributes)),"mixed"===t&&n.undirected&&(i.undirected=!0),i}(t.type,o,e)})),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:e,edges:i}},o.import=function(t){var e,n,o,r,s,a=this,l=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(t instanceof i)return t.forEachNode((function(t,e){l?a.mergeNode(t,e):a.addNode(t,e)})),t.forEachEdge((function(t,e,n,i,o,r,s){l?s?a.mergeUndirectedEdgeWithKey(t,n,i,e):a.mergeDirectedEdgeWithKey(t,n,i,e):s?a.addUndirectedEdgeWithKey(t,n,i,e):a.addDirectedEdgeWithKey(t,n,i,e)})),this;if(!c(t))throw new B("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(t.attributes){if(!c(t.attributes))throw new B("Graph.import: invalid attributes. Expecting a plain object.");l?this.mergeAttributes(t.attributes):this.replaceAttributes(t.attributes)}if(t.nodes){if(o=t.nodes,!Array.isArray(o))throw new B("Graph.import: invalid nodes. Expecting an array.");for(e=0,n=o.length;e<n;e++){gt(r=o[e]);var h=r,u=h.key,d=h.attributes;l?this.mergeNode(u,d):this.addNode(u,d)}}if(t.edges){var p=!1;if("undirected"===this.type&&(p=!0),o=t.edges,!Array.isArray(o))throw new B("Graph.import: invalid edges. Expecting an array.");for(e=0,n=o.length;e<n;e++){yt(s=o[e]);var m=s,f=m.source,g=m.target,y=m.attributes,b=m.undirected,v=void 0===b?p:b;"key"in s?(l?v?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:v?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey).call(this,s.key,f,g,y):(l?v?this.mergeUndirectedEdge:this.mergeDirectedEdge:v?this.addUndirectedEdge:this.addDirectedEdge).call(this,f,g,y)}}return this},o.nullCopy=function(t){var e=new i(a({},this._options,t));return e.replaceAttributes(a({},this.getAttributes())),e},o.emptyCopy=function(t){var e=this.nullCopy(t);return this._nodes.forEach((function(t,n){var i=a({},t.attributes);t=new e.NodeDataClass(n,i),e._nodes.set(n,t)})),e},o.copy=function(t){if("string"==typeof(t=t||{}).type&&t.type!==this.type&&"mixed"!==t.type)throw new W('Graph.copy: cannot create an incompatible copy from "'.concat(this.type,'" type to "').concat(t.type,'" because this would mean losing information about the current graph.'));if("boolean"==typeof t.multi&&t.multi!==this.multi&&!0!==t.multi)throw new W("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 t.allowSelfLoops&&t.allowSelfLoops!==this.allowSelfLoops&&!0!==t.allowSelfLoops)throw new W("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 e,n,i=this.emptyCopy(t),o=this._edges.values();!0!==(e=o.next()).done;)xt(i,"copy",!1,(n=e.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 e=this,n={};this._nodes.forEach((function(t,e){n[e]=t.attributes}));var i={},o={};this._edges.forEach((function(t,n){var r,s=t.undirected?"--":"->",a="",l=t.source.key,c=t.target.key;t.undirected&&l>c&&(r=l,l=c,c=r);var h="(".concat(l,")").concat(s,"(").concat(c,")");n.startsWith("geid_")?e.multi&&(void 0===o[h]?o[h]=0:o[h]++,a+="".concat(o[h],". ")):a+="[".concat(n,"]: "),i[a+=h]=t.attributes}));var r={};for(var s in this)this.hasOwnProperty(s)&&!Ct.has(s)&&"function"!=typeof this[s]&&"symbol"!==t(s)&&(r[s]=this[s]);return r.attributes=this._attributes,r.nodes=n,r.edges=i,u(r,"constructor",this.constructor),r},i}(f.exports.EventEmitter);"undefined"!=typeof Symbol&&(Mt.prototype[Symbol.for("nodejs.util.inspect.custom")]=Mt.prototype.inspect),[{name:function(t){return"".concat(t,"Edge")},generateKey:!0},{name:function(t){return"".concat(t,"DirectedEdge")},generateKey:!0,type:"directed"},{name:function(t){return"".concat(t,"UndirectedEdge")},generateKey:!0,type:"undirected"},{name:function(t){return"".concat(t,"EdgeWithKey")}},{name:function(t){return"".concat(t,"DirectedEdgeWithKey")},type:"directed"},{name:function(t){return"".concat(t,"UndirectedEdgeWithKey")},type:"undirected"}].forEach((function(t){["add","merge","update"].forEach((function(e){var n=t.name(e),i="add"===e?xt:Et;t.generateKey?Mt.prototype[n]=function(o,r,s){return i(this,n,!0,"undirected"===(t.type||this.type),null,o,r,s,"update"===e)}:Mt.prototype[n]=function(o,r,s,a){return i(this,n,!1,"undirected"===(t.type||this.type),o,r,s,a,"update"===e)}}))})),function(t){K.forEach((function(e){var n=e.name,i=e.attacher;i(t,n("Node"),0),i(t,n("Source"),1),i(t,n("Target"),2),i(t,n("Opposite"),3)}))}(Mt),function(t){Z.forEach((function(e){var n=e.name,i=e.attacher;i(t,n("Edge"),"mixed"),i(t,n("DirectedEdge"),"directed"),i(t,n("UndirectedEdge"),"undirected")}))}(Mt),function(t){tt.forEach((function(e){!function(t,e){var n=e.name,i=e.type,o=e.direction;t.prototype[n]=function(t,e){if("mixed"!==i&&"mixed"!==this.type&&i!==this.type)return[];if(!arguments.length)return function(t,e){if(0===t.size)return[];if("mixed"===e||e===t.type)return"function"==typeof Array.from?Array.from(t._edges.keys()):F(t._edges.keys(),t._edges.size);for(var n,i,o="undirected"===e?t.undirectedSize:t.directedSize,r=new Array(o),s="undirected"===e,a=t._edges.values(),l=0;!0!==(n=a.next()).done;)(i=n.value).undirected===s&&(r[l++]=i.key);return r}(this,i);if(1===arguments.length){t=""+t;var r=this._nodes.get(t);if(void 0===r)throw new V("Graph.".concat(n,': could not find the "').concat(t,'" node in the graph.'));return function(t,e,n,i){var o=[];return lt(!1,t,e,n,i,(function(t){o.push(t)})),o}(this.multi,"mixed"===i?this.type:i,o,r)}if(2===arguments.length){t=""+t,e=""+e;var s=this._nodes.get(t);if(!s)throw new V("Graph.".concat(n,': could not find the "').concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new V("Graph.".concat(n,': could not find the "').concat(e,'" target node in the graph.'));return function(t,e,n,i,o){var r=[];return ct(!1,t,e,n,i,o,(function(t){r.push(t)})),r}(i,this.multi,o,s,e)}throw new B("Graph.".concat(n,": too many arguments (expecting 0, 1 or 2 and got ").concat(arguments.length,")."))}}(t,e),function(t,e){var n=e.name,i=e.type,o=e.direction,r="forEach"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[r]=function(t,e,n){if("mixed"===i||"mixed"===this.type||i===this.type){if(1===arguments.length)return at(!1,this,i,n=t);if(2===arguments.length){t=""+t,n=e;var s=this._nodes.get(t);if(void 0===s)throw new V("Graph.".concat(r,': could not find the "').concat(t,'" node in the graph.'));return lt(!1,this.multi,"mixed"===i?this.type:i,o,s,n)}if(3===arguments.length){t=""+t,e=""+e;var a=this._nodes.get(t);if(!a)throw new V("Graph.".concat(r,': could not find the "').concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new V("Graph.".concat(r,': could not find the "').concat(e,'" target node in the graph.'));return ct(!1,i,this.multi,o,a,e,n)}throw new B("Graph.".concat(r,": too many arguments (expecting 1, 2 or 3 and got ").concat(arguments.length,")."))}};var s="map"+n[0].toUpperCase()+n.slice(1);t.prototype[s]=function(){var t,e=Array.prototype.slice.call(arguments),n=e.pop();if(0===e.length){var o=0;"directed"!==i&&(o+=this.undirectedSize),"undirected"!==i&&(o+=this.directedSize),t=new Array(o);var s=0;e.push((function(e,i,o,r,a,l,c){t[s++]=n(e,i,o,r,a,l,c)}))}else t=[],e.push((function(e,i,o,r,s,a,l){t.push(n(e,i,o,r,s,a,l))}));return this[r].apply(this,e),t};var a="filter"+n[0].toUpperCase()+n.slice(1);t.prototype[a]=function(){var t=Array.prototype.slice.call(arguments),e=t.pop(),n=[];return t.push((function(t,i,o,r,s,a,l){e(t,i,o,r,s,a,l)&&n.push(t)})),this[r].apply(this,t),n};var l="reduce"+n[0].toUpperCase()+n.slice(1);t.prototype[l]=function(){var t,e,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?(t=n[0],e=n[1],n=[]):3===n.length?(t=n[1],e=n[2],n=[n[0]]):4===n.length&&(t=n[2],e=n[3],n=[n[0],n[1]]);var i=e;return n.push((function(e,n,o,r,s,a,l){i=t(i,e,n,o,r,s,a,l)})),this[r].apply(this,n),i}}(t,e),function(t,e){var n=e.name,i=e.type,o=e.direction,r="find"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[r]=function(t,e,n){if("mixed"!==i&&"mixed"!==this.type&&i!==this.type)return!1;if(1===arguments.length)return at(!0,this,i,n=t);if(2===arguments.length){t=""+t,n=e;var s=this._nodes.get(t);if(void 0===s)throw new V("Graph.".concat(r,': could not find the "').concat(t,'" node in the graph.'));return lt(!0,this.multi,"mixed"===i?this.type:i,o,s,n)}if(3===arguments.length){t=""+t,e=""+e;var a=this._nodes.get(t);if(!a)throw new V("Graph.".concat(r,': could not find the "').concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new V("Graph.".concat(r,': could not find the "').concat(e,'" target node in the graph.'));return ct(!0,i,this.multi,o,a,e,n)}throw new B("Graph.".concat(r,": too many arguments (expecting 1, 2 or 3 and got ").concat(arguments.length,")."))};var s="some"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[s]=function(){var t=Array.prototype.slice.call(arguments),e=t.pop();return t.push((function(t,n,i,o,r,s,a){return e(t,n,i,o,r,s,a)})),!!this[r].apply(this,t)};var a="every"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[a]=function(){var t=Array.prototype.slice.call(arguments),e=t.pop();return t.push((function(t,n,i,o,r,s,a){return!e(t,n,i,o,r,s,a)})),!this[r].apply(this,t)}}(t,e),function(t,e){var n=e.name,i=e.type,o=e.direction,r=n.slice(0,-1)+"Entries";t.prototype[r]=function(t,e){if("mixed"!==i&&"mixed"!==this.type&&i!==this.type)return N.empty();if(!arguments.length)return function(t,e){if(0===t.size)return N.empty();var n="mixed"!==e&&e!==t.type,i="undirected"===e,o=t._edges.values();return new N((function(){for(var t,e;;){if((t=o.next()).done)return t;if(e=t.value,!n||e.undirected===i)break}return{value:{edge:e.key,attributes:e.attributes,source:e.source.key,target:e.target.key,sourceAttributes:e.source.attributes,targetAttributes:e.target.attributes,undirected:e.undirected},done:!1}}))}(this,i);if(1===arguments.length){t=""+t;var n=this._nodes.get(t);if(!n)throw new V("Graph.".concat(r,': could not find the "').concat(t,'" node in the graph.'));return function(t,e,n){var i=N.empty();return"undirected"!==t&&("out"!==e&&void 0!==n.in&&(i=Q(i,it(n.in))),"in"!==e&&void 0!==n.out&&(i=Q(i,it(n.out,e?void 0:n.key)))),"directed"!==t&&void 0!==n.undirected&&(i=Q(i,it(n.undirected))),i}(i,o,n)}if(2===arguments.length){t=""+t,e=""+e;var s=this._nodes.get(t);if(!s)throw new V("Graph.".concat(r,': could not find the "').concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new V("Graph.".concat(r,': could not find the "').concat(e,'" target node in the graph.'));return function(t,e,n,i){var o=N.empty();return"undirected"!==t&&(void 0!==n.in&&"out"!==e&&i in n.in&&(o=Q(o,st(n.in,i))),void 0!==n.out&&"in"!==e&&i in n.out&&(e||n.key!==i)&&(o=Q(o,st(n.out,i)))),"directed"!==t&&void 0!==n.undirected&&i in n.undirected&&(o=Q(o,st(n.undirected,i))),o}(i,o,s,e)}throw new B("Graph.".concat(r,": too many arguments (expecting 0, 1 or 2 and got ").concat(arguments.length,")."))}}(t,e)}))}(Mt),function(t){ht.forEach((function(e){(function(t,e){var n=e.name,i=e.type,o=e.direction;t.prototype[n]=function(t){if("mixed"!==i&&"mixed"!==this.type&&i!==this.type)return[];t=""+t;var e=this._nodes.get(t);if(void 0===e)throw new V("Graph.".concat(n,': could not find the "').concat(t,'" node in the graph.'));return function(t,e,n){if("mixed"!==t){if("undirected"===t)return Object.keys(n.undirected);if("string"==typeof e)return Object.keys(n[e])}var i=[];return pt(!1,t,e,n,(function(t){i.push(t)})),i}("mixed"===i?this.type:i,o,e)}})(t,e),function(t,e){var n=e.name,i=e.type,o=e.direction,r="forEach"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[r]=function(t,e){if("mixed"===i||"mixed"===this.type||i===this.type){t=""+t;var n=this._nodes.get(t);if(void 0===n)throw new V("Graph.".concat(r,': could not find the "').concat(t,'" node in the graph.'));pt(!1,"mixed"===i?this.type:i,o,n,e)}};var s="map"+n[0].toUpperCase()+n.slice(1);t.prototype[s]=function(t,e){var n=[];return this[r](t,(function(t,i){n.push(e(t,i))})),n};var a="filter"+n[0].toUpperCase()+n.slice(1);t.prototype[a]=function(t,e){var n=[];return this[r](t,(function(t,i){e(t,i)&&n.push(t)})),n};var l="reduce"+n[0].toUpperCase()+n.slice(1);t.prototype[l]=function(t,e,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[r](t,(function(t,n){i=e(i,t,n)})),i}}(t,e),function(t,e){var n=e.name,i=e.type,o=e.direction,r=n[0].toUpperCase()+n.slice(1,-1),s="find"+r;t.prototype[s]=function(t,e){if("mixed"===i||"mixed"===this.type||i===this.type){t=""+t;var n=this._nodes.get(t);if(void 0===n)throw new V("Graph.".concat(s,': could not find the "').concat(t,'" node in the graph.'));return pt(!0,"mixed"===i?this.type:i,o,n,e)}};var a="some"+r;t.prototype[a]=function(t,e){return!!this[s](t,e)};var l="every"+r;t.prototype[l]=function(t,e){return!this[s](t,(function(t,n){return!e(t,n)}))}}(t,e),function(t,e){var n=e.name,i=e.type,o=e.direction,r=n.slice(0,-1)+"Entries";t.prototype[r]=function(t){if("mixed"!==i&&"mixed"!==this.type&&i!==this.type)return N.empty();t=""+t;var e=this._nodes.get(t);if(void 0===e)throw new V("Graph.".concat(r,': could not find the "').concat(t,'" node in the graph.'));return function(t,e,n){if("mixed"!==t){if("undirected"===t)return mt(null,n,n.undirected);if("string"==typeof e)return mt(null,n,n[e])}var i=N.empty(),o=new ut;return"undirected"!==t&&("out"!==e&&(i=Q(i,mt(o,n,n.in))),"in"!==e&&(i=Q(i,mt(o,n,n.out)))),"directed"!==t&&(i=Q(i,mt(o,n,n.undirected))),i}("mixed"===i?this.type:i,o,e)}}(t,e)}))}(Mt);var _t=function(t){function n(e){var n=a({type:"directed"},e);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 t.call(this,n)||this}return e(n,t),n}(Mt),It=function(t){function n(e){var n=a({type:"undirected"},e);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 t.call(this,n)||this}return e(n,t),n}(Mt),Lt=function(t){function n(e){var n=a({multi:!0},e);if("multi"in n&&!0!==n.multi)throw new B("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");return t.call(this,n)||this}return e(n,t),n}(Mt),Nt=function(t){function n(e){var n=a({type:"directed",multi:!0},e);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 t.call(this,n)||this}return e(n,t),n}(Mt),Pt=function(t){function n(e){var n=a({type:"undirected",multi:!0},e);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 t.call(this,n)||this}return e(n,t),n}(Mt);function $t(t){t.from=function(e,n){var i=a({},e.options,n),o=new t(i);return o.import(e),o}}return $t(Mt),$t(_t),$t(It),$t(Lt),$t(Nt),$t(Pt),Mt.Graph=Mt,Mt.DirectedGraph=_t,Mt.UndirectedGraph=It,Mt.MultiGraph=Lt,Mt.MultiDirectedGraph=Nt,Mt.MultiUndirectedGraph=Pt,Mt.InvalidArgumentsGraphError=B,Mt.NotFoundGraphError=V,Mt.UsageGraphError=W,Mt}()},944:(t,e)=>{"use strict";e.Vb=void 0,e.Vb=function(t,e,n){var i=function(t,e,n){if(0===t.length||0===e.length)return 0;if(n&&!n.caseSensitive&&(t=t.toUpperCase(),e=e.toUpperCase()),t===e)return 1;for(var i=0,o=t.length,r=e.length,s=Math.floor(Math.max(o,r)/2)-1,a=new Array(o),l=new Array(r),c=0;c<o;c++)for(var h=Math.max(0,c-s);h<=Math.min(r,c+s+1);h++)if(!a[c]&&!l[h]&&t[c]===e[h]){++i,a[c]=l[h]=!0;break}if(0===i)return 0;var u=0,d=0;for(c=0;c<o;c++)if(a[c]){for(;!l[d];)d++;t.charAt(c)!==e.charAt(d++)&&u++}return(i/o+i/r+(i-(u/=2))/i)/3}(t,e,n),o=0;if(i>.7){for(var r=Math.min(t.length,e.length),s=0;t[s]===e[s]&&s<4&&s<r;)++o,s++;i+=.1*o*(1-i)}return i}},7106:t=>{"use strict";var e=t.exports=function(t,e,i){"function"==typeof e&&(i=e,e={}),n(e,"function"==typeof(i=e.cb||i)?i:i.pre||function(){},i.post||function(){},t,"",t)};function n(t,i,o,r,s,a,l,c,h,u){if(r&&"object"==typeof r&&!Array.isArray(r)){for(var d in i(r,s,a,l,c,h,u),r){var p=r[d];if(Array.isArray(p)){if(d in e.arrayKeywords)for(var m=0;m<p.length;m++)n(t,i,o,p[m],s+"/"+d+"/"+m,a,s,d,r,m)}else if(d in e.propsKeywords){if(p&&"object"==typeof p)for(var f in p)n(t,i,o,p[f],s+"/"+d+"/"+f.replace(/~/g,"~0").replace(/\//g,"~1"),a,s,d,r,f)}else(d in e.keywords||t.allKeys&&!(d in e.skipKeywords))&&n(t,i,o,p,s+"/"+d,a,s,d,r)}o(r,s,a,l,c,h,u)}}e.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0},e.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},e.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},e.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:t=>{"use strict";var e=[];function n(t){for(var n=-1,i=0;i<e.length;i++)if(e[i].identifier===t){n=i;break}return n}function i(t,i){for(var r={},s=[],a=0;a<t.length;a++){var l=t[a],c=i.base?l[0]+i.base:l[0],h=r[c]||0,u="".concat(c," ").concat(h);r[c]=h+1;var d=n(u),p={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==d)e[d].references++,e[d].updater(p);else{var m=o(p,i);i.byIndex=a,e.splice(a,0,{identifier:u,updater:m,references:1})}s.push(u)}return s}function o(t,e){var n=e.domAPI(e);return n.update(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap&&e.supports===t.supports&&e.layer===t.layer)return;n.update(t=e)}else n.remove()}}t.exports=function(t,o){var r=i(t=t||[],o=o||{});return function(t){t=t||[];for(var s=0;s<r.length;s++){var a=n(r[s]);e[a].references--}for(var l=i(t,o),c=0;c<r.length;c++){var h=n(r[c]);0===e[h].references&&(e[h].updater(),e.splice(h,1))}r=l}}},7659:t=>{"use strict";var e={};t.exports=function(t,n){var i=function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(t){n=null}e[t]=n}return e[t]}(t);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:t=>{"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},5056:(t,e,n)=>{"use strict";t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},7825:t=>{"use strict";t.exports=function(t){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=t.insertStyleElement(t);return{update:function(n){!function(t,e,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 r=n.sourceMap;r&&"undefined"!=typeof btoa&&(i+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(r))))," */")),e.styleTagTransform(i,t,e.options)}(e,t,n)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},1113:t=>{"use strict";t.exports=function(t,e){if(e.styleSheet)e.styleSheet.cssText=t;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(t))}}},6723:(t,e,n)=>{"use strict";n.r(e),n.d(e,{GetRegionEditor:()=>mo,SeqActivityCliffsEditor:()=>yo,SeqPaletteCustom:()=>ro,SequenceSpaceEditor:()=>go,SplitToMonomersEditor:()=>fo,SubsequenceSearchTopMenu:()=>Qo,_package:()=>io,activityCliffs:()=>Io,addCopyMenu:()=>yr,alignSequences:()=>Go,bioSubstructureFilter:()=>lr,bioSubstructureFilterTest:()=>cr,compositionAnalysis:()=>Fo,compositionAnalysisWidget:()=>Ao,convertColumnAction:()=>Wo,convertDialog:()=>Vo,customSequenceCellRenderer:()=>bo,demoBioActivityCliffs:()=>wr,demoBioAtomicLevel:()=>Cr,demoBioSequenceSpace:()=>vr,demoBioSimilarityDiversity:()=>br,detectMacromoleculeProbe:()=>Er,diversitySearchTopMenu:()=>Xo,diversitySearchViewer:()=>Zo,fastaSequenceCellRenderer:()=>vo,getBioLib:()=>co,getHelmMonomers:()=>zo,getMolFromHelm:()=>Mr,getMonomerLibHelper:()=>oo,getRegion:()=>Mo,getRegionApp:()=>dr,getRegionHelmApp:()=>pr,getRegionPanel:()=>uo,getRegionTopMenu:()=>_o,getSeqHandler:()=>ho,getSeqHelper:()=>Tr,helmPreprocessingFunction:()=>No,importBam:()=>Bo,importFasta:()=>Do,initBio:()=>ao,libraryPanel:()=>po,longSeqTableFasta:()=>fr,longSeqTableHelm:()=>gr,longSeqTableSeparator:()=>mr,macroMolColumnPropertyPanel:()=>Co,macromoleculeDifferenceCellRenderer:()=>So,macromoleculePreprocessingFunction:()=>Lo,manageLibrariesView:()=>ir,manageMonomerLibraries:()=>nr,manageMonomerLibrariesView:()=>rr,manageMonomerLibrariesViewTreeBrowser:()=>sr,manageMonomersView:()=>or,monomerCellRenderer:()=>Uo,multipleSequenceAlignmentDialog:()=>Ho,saveAsFasta:()=>ar,sdfToJsonLib:()=>Ar,searchSubsequenceEditor:()=>Jo,separatorSequenceCellRenderer:()=>wo,seq2atomic:()=>Sr,seqIdentity:()=>xr,sequence3dStructureWidget:()=>Oo,sequenceAlignment:()=>xo,sequenceIdentityScoring:()=>tr,sequenceSimilarityScoring:()=>er,sequenceSpaceTopMenu:()=>Po,sequenceTooltip:()=>lo,similaritySearchTopMenu:()=>Ko,similaritySearchViewer:()=>Yo,splitToMonomersTopMenu:()=>qo,test1:()=>_r,testDetectMacromolecule:()=>jo,toAtomicLevel:()=>$o,toAtomicLevelAction:()=>Ro,toAtomicLevelPanel:()=>ko,vdRegionsViewer:()=>To,webLogoAggApp:()=>ur,webLogoLargeApp:()=>hr,webLogoViewer:()=>Eo});var i,o,r=n(4328),s=n(7389),a=n(6082),l=n(684),c=n(9039);(o=i||(i={})).EUCLIDEAN="EUCLIDEAN",o.MANHATTAN="MANHATTAN";var h=n(1858),u=n(5072),d=n.n(u),p=n(7825),m=n.n(p),f=n(7659),g=n.n(f),y=n(5056),b=n.n(y),v=n(540),w=n.n(v),C=n(1113),A=n.n(C),S=n(7939),x={};x.styleTagTransform=A(),x.setAttributes=b(),x.insert=g().bind(null,"head"),x.domAPI=m(),x.insertStyleElement=w(),d()(S.A,x),S.A&&S.A.locals&&S.A.locals;var E=function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((i=i.apply(t,e||[])).next())}))};let T=null,M=null;function _(t,e){return t&&""!=t?t:e}n(2780);class I{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(!T&&(T=yield navigator.gpu.requestAdapter(),null==T))return null;let t=null;return"info"in T&&(t=T.info),t?_(t.description,_(t.vendor,"No GPU description available")):"No GPU description available"}))}().then((t=>{t?(this.useWebGPU.tooltip+=` (${t})`,this.useWebGPU.value=!0):(this.useWebGPU.value=!1,this.useWebGPU.disable=!0)}))}}class L{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 N="MCL";var P=n(1991),$=n.n(P);a.SEMTYPE.MOLECULE,a.SEMTYPE.MACROMOLECULE;class R{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 k{get algorithmOptions(){const t=this.methodsParams[this.methodInput.value],e={};return Object.keys(t).forEach((n=>{null!=t[n].value&&(e[n]=t[n].value)})),e}get dbScanOptions(){return{dbScanEpsilon:this.dbScanParams.epsilon.value??.01,dbScanMinPts:this.dbScanParams.minPts.value??4}}constructor(t={}){this.editorSettings={},this.plotEmbeddingsInput=s.input.bool("Plot embeddings",{value:!0}),this.clusterEmbeddingsInput=s.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=s.inputs([]),this.dbScanSettingsDiv=s.inputs([]),this.preprocessingFuncSettingsDiv=s.inputs([]),this.preprocessingFunctionSettings={},this.methodsParams={[c.c.UMAP]:new I,[c.c.T_SNE]:new L},this.dbScanParams=new R,this.editorSettings=t,this.editorSettings.enableMCL&&this.methods.push(N),a.Func.find({tags:[l.GP]}).forEach((t=>{const e=t.options.get(l.n3)??"",n=t.friendlyName??t.name,i=t.options.get(l.C0)??"",o=t.options.get(l._X)??"",r=t.options.get(l.Gi)??"";this.editorSettings.semtype&&!e.includes(this.editorSettings.semtype)||this.editorSettings.type&&!i.includes(this.editorSettings.type)||this.editorSettings.units&&!o.includes(this.editorSettings.units)||(this.supportedFunctions[n]={func:t,semTypes:e?e.split(","):[],types:i?i.split(","):[],units:o?o.split(","):[],distanceFunctions:r?r.split(","):[]})})),this.tableInput=s.input.table("Table",{value:r.shell.tv.dataFrame,items:r.shell.tables,onValueChanged:()=>{this.onTableInputChanged()}}),this.onTableInputChanged(),this.regenerateColInput(),this.onColumnInputChanged();let e=!1,n=!1;this.methodInput=s.input.choice("Method",{value:c.c.UMAP,items:this.methods,onValueChanged:t=>{e&&this.createAlgorithmSettingsDiv(this.methodSettingsDiv,this.methodsParams[t])}}),this.methodSettingsIcon=s.icons.settings((()=>{e=!e,e?this.createAlgorithmSettingsDiv(this.methodSettingsDiv,this.methodsParams[this.methodInput.value]):s.empty(this.methodSettingsDiv)}),"Modify methods parameters"),this.dbScanSettingsIcon=s.icons.settings((()=>{n=!n,n?this.createAlgorithmSettingsDiv(this.dbScanSettingsDiv,this.dbScanParams):s.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=s.inputs([]);const i=this.columnFunctionsMap[this.colInput.value.name];this.preprocessingFunctionInput=s.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||(s.empty(this.preprocessingFunctionInputRoot),Array.from(this.preprocessingFunctionInput.root.children).forEach((t=>this.preprocessingFunctionInputRoot.append(t)))),this.preprocessingFunctionInputRoot.classList.add("ml-dim-reduction-settings-input");let h=!1;this.preprocessingFuncSettingsIcon=s.icons.settings((async()=>{h?s.empty(this.preprocessingFuncSettingsDiv):await this.createPreprocessingFuncParamsDiv(this.preprocessingFuncSettingsDiv,this.supportedFunctions[this.preprocessingFunctionInput.value].func),h=!h}),"Modify encoding function parameters"),this.preprocessingFunctionInputRoot.prepend(this.preprocessingFuncSettingsIcon),this.similarityMetricInput=s.input.choice("Similarity",{value:"",items:[]}),this.similarityMetricInput.nullable=!1,this.similarityMetricInputRoot||(this.similarityMetricInputRoot=this.similarityMetricInput.root),this.onPreprocessingFunctionChanged()}getColInput(){const t=this.tableInput.value?.columns.toList().find((t=>!!this.columnFunctionsMap[t.name]))??null,e=s.input.column("Column",{table:this.tableInput.value,value:t,nullable:!1,onValueChanged:()=>this.onColumnInputChanged(),filter:t=>!!this.columnFunctionsMap[t.name]});return this.colInputRoot||(this.colInputRoot=e.root),e}regenerateColInput(){let t=!1;this.colInputRoot&&(t=!0,s.empty(this.colInputRoot)),this.colInput=this.getColInput(),t&&Array.from(this.colInput.root.children).forEach((t=>this.colInputRoot.append(t))),this.onColumnInputChanged()}onTableInputChanged(){const t=this.tableInput.value;if(!t)return;const e=()=>{this.columnFunctionsMap={},t.columns.toList().forEach((t=>{Object.keys(this.supportedFunctions).forEach((e=>{const n=this.supportedFunctions[e].semTypes,i=this.supportedFunctions[e].types,o=this.supportedFunctions[e].units,r=!n.length||t.semType&&n.includes(t.semType),s=!i.length||i.includes(t.type),a=!o.length||t.meta.units&&o.includes(t.meta.units);r&&s&&a&&(this.columnFunctionsMap[t.name]||(this.columnFunctionsMap[t.name]=[]),this.columnFunctionsMap[t.name].push(e))}))})),this.regenerateColInput()};e(),$()(t.columns).some((t=>!!t.getTag(a.Tags.SemanticDetectionDuration)))||t.meta.detectSemanticTypes().then((()=>{e()}))}onColumnInputChanged(){const t=this.colInput.value;if(!t)return;const e=this.columnFunctionsMap[t.name];this.preprocessingFunctionInput=s.input.choice("Preprocessing function",{value:e[0],items:e,onValueChanged:()=>{this.onPreprocessingFunctionChanged()}});let n=!1;this.preprocessingFunctionInputRoot||(this.preprocessingFunctionInputRoot=this.preprocessingFunctionInput.root,n=!0),n||(s.empty(this.preprocessingFunctionInputRoot),Array.from(this.preprocessingFunctionInput.root.children).forEach((t=>this.preprocessingFunctionInputRoot.append(t)))),this.onPreprocessingFunctionChanged()}onPreprocessingFunctionChanged(){s.empty(this.preprocessingFuncSettingsDiv),this.preprocessingFunctionSettings={};const t=this.preprocessingFunctionInput.value,e=this.supportedFunctions[t].distanceFunctions;this.availableMetrics=[...e],this.similarityMetricInput=s.input.choice("Similarity",{value:this.availableMetrics[0],items:this.availableMetrics}),this.similarityMetricInput.nullable=!1,this.similarityMetricInputRoot||(this.similarityMetricInputRoot=this.similarityMetricInput.root),s.empty(this.similarityMetricInputRoot),Array.from(this.similarityMetricInput.root.children).forEach((t=>this.similarityMetricInputRoot.append(t))),this.preprocessingFuncSettingsIcon&&(this.supportedFunctions[t].func.inputs.length<3?this.preprocessingFuncSettingsIcon.style.display="none":this.preprocessingFuncSettingsIcon.style.display="flex")}createAlgorithmSettingsDiv(t,e){return s.empty(t),Object.keys(e).forEach((n=>{const i=e[n],o="string"===i.type?s.input.string(i.uiName,{value:i.value??"",onValueChanged:t=>{i.value=t}}):"boolean"===i.type?s.input.bool(i.uiName,{value:i.value??!1,onValueChanged:t=>{i.value=t}}):s.input.float(i.uiName,{value:i.value,onValueChanged:t=>{i.value=t}});t.append(o.root),i.disable?(o.enabled=!1,s.tooltip.bind(o.input??o.root,i.disableTooltip??"")):s.tooltip.bind(o.input??o.root,i.tooltip)})),t}async createPreprocessingFuncParamsDiv(t,e){if(s.empty(t),e.inputs.length<3)return s.div();const n=e.prepare(),i=await n.buildEditor(s.div());for(let o=2;o<e.inputs.length;o++){const r=e.inputs[o];(this.preprocessingFunctionSettings[r.name]||n.inputParams[e.inputs[o].name].value||r.defaultValue)&&(this.preprocessingFunctionSettings[r.name]=this.preprocessingFunctionSettings[r.name]??n.inputParams[r.name].value??r.defaultValue);const s=i.find((t=>t.property.name===r.name));s&&(null!==this.preprocessingFunctionSettings[r.name]&&void 0!==this.preprocessingFunctionSettings[r.name]&&(s.value=this.preprocessingFunctionSettings[r.name]),s.onChanged.subscribe((t=>{this.preprocessingFunctionSettings[r.name]=t})),t.append(s.root))}return t}getEditor(){return s.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(t){try{const e=JSON.parse(t);await this.applyInput(e)}catch(t){r.shell.error("Error applying input from history"),console.error(t)}}async applyInput(t){try{const e=this.tableInput.value?.col(t.col);if(!e)throw new Error("Column not found");this.colInput.value=e,this.preprocessingFunctionInput.value=t.preprocessingFunction,this.similarityMetricInput.value=t.similarityMetric,this.plotEmbeddingsInput.value=t.plotEmbeddings,this.clusterEmbeddingsInput.value=t.clusterEmbeddings;const n=this.methodsParams[this.methodInput.value];Object.keys(n).forEach((e=>{null!=t.options[e]&&(this.methodsParams[t.methodName][e].value=t.options[e])})),this.methodInput.value=t.methodName,this.preprocessingFunctionSettings=t.options.preprocessingFuncArgs,await this.createPreprocessingFuncParamsDiv(this.preprocessingFuncSettingsDiv,this.supportedFunctions[this.preprocessingFunctionInput.value].func)}catch(t){r.shell.error("Error applying input from history"),console.error(t)}}}var O=n(9713),H=n(6295);const G=t=>null==t;function F(t,e,n,i){if(n>t[t.length-1])return;const o=t.findIndex((t=>n<t));t.pop(),t.splice(o,0,n),e.pop(),e.splice(o,0,i)}class D{constructor(t=!0,e=!0){const i=navigator.hardwareConcurrency;this._workerCount=t?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=e}async calc(t,e,n=!0,o){return await this.calcMulti([t],[e],n,[o??{}],[1],i.MANHATTAN)}async calcMulti(t,e,n=!0,o=[{}],r=[1],s=i.MANHATTAN){if(t.length<1)throw new Error("values must contain at least one array");if(e.length!==t.length||o.length!==t.length||r.length!==t.length)throw new Error("values, fnNames, weights and opts must have the same length");return new Promise((async(i,a)=>{try{const a=t[0].length,l=new Array(this._workerCount),c=a*(a-1)/2;this._workerCount=Math.min(this._workerCount,c);const h=c/this._workerCount,u=new Float32Array(c);let d=0,p=1,m=0,f=Number.MIN_VALUE;for(let n=0;n<this._workerCount;n++){const i=Math.floor(n*h),g=n===this._workerCount-1?c:Math.floor((n+1)*h),y=d,b=p;n!==this._workerCount-1&&(d=a-2-Math.floor(Math.sqrt(-8*g+4*a*(a-1)-7)/2-.5),p=g-a*d+Math.floor((d+1)*(d+2)/2)),this._workers[n].postMessage({values:t,fnNames:e,startRow:y,startCol:b,chunckSize:g-i,opts:o,weights:r,aggregationMethod:s}),l[n]=new Promise(((t,e)=>{this._workers[n].onmessage=({data:{error:o,distanceMatrixData:r,min:s,max:a}})=>{this._terminateOnComplete&&setTimeout((()=>this._workers[n].terminate())),o?e(o):(u.set(r,i),s<m&&(m=s),a>f&&(f=a),t())}}))}await Promise.all(l),n&&u.forEach(((t,e)=>{u[e]=(t-m)/(f-m)})),i(u)}catch(t){a(t)}}))}terminate(){this._workers.forEach((t=>t.terminate()))}}class B{constructor(){this._workerCount=Math.max(navigator.hardwareConcurrency-2,1)}static pruneSparseMatrix(t,e=1e6){const n=200,i=new Uint32Array(n),o=t.distance.length,r=t.distance;for(let t=0;t<o;t++)i[Math.floor(r[t]*n)]++;let s=0,a=0;for(let t=0;t<n&&(s+=i[t],a=t,!(s>=e));t++);const l=new Uint32Array(s),c=new Uint32Array(s),h=new Float32Array(s),u=t.i,d=t.j;let p=0;const m=(a+1)/n;for(let t=0;t<o;t++)r[t]<m&&(l[p]=u[t],c[p]=d[t],h[p]=r[t],p++);return{i:l,j:c,distance:h}}async calcMultiColumn(t,e,o,r=[{}],s=[1],a=i.EUCLIDEAN){const l=t[0].length*(t[0].length-1)/2,c=Math.floor(l/this._workerCount),h=t[0].length>2e4?await this.getMinimalThreshold(t,e,r,s,a):0;o<h&&(console.log(`using threshold ${h}`),o=h),r.forEach(((t,e)=>r[e].threshold=o));const u=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++)u[n]=new Promise(((i,h)=>{const u=n*c,p=n===this._workerCount-1?l:(n+1)*c;p<=u&&i({i:new Int32Array(0),j:new Int32Array(0),distance:new Float32Array(0),idx:n}),d[n].postMessage({values:t,startIdx:u,endIdx:p,threshold:o,fnNames:e,opts:r,weights:s,aggregationMethod:a}),d[n].onmessage=({data:{error:t,i:e,j:o,distance:r}})=>{t?(d[n].terminate(),h(t)):(d[n].terminate(),i({i:e,j:o,distance:r,idx:n}))}}));const p=await Promise.all(u),m=p.reduce(((t,e)=>t+e.i.length),0),f=new Int32Array(m),g=new Int32Array(m),y=new Float32Array(m);let b=0;for(const t of p)f.set(t.i,b),g.set(t.j,b),y.set(t.distance,b),b+=t.i.length;return{i:f,j:g,distance:y}}async calc(t,e,n,i={}){return await this.calcMultiColumn([t],[e],n,[i],[1])}async getKNN(t,e,n=15,i={}){return await this.multiColumnKNN([t],[e],n,[i],[1])}async getThresholdKNN(t,e,n=.8,i={}){return await this.multiColumnThresholdKnn([t],[e],n,[i],[1])}async multiColumnThresholdKnn(t,e,o=.8,r,s,a=i.EUCLIDEAN){if(t.length!==e.length||t.length!==r.length||t.length!==s.length)throw new Error("values, distance functions, options and weights arrays should have the same length");if(t.some((e=>e.length!==t[0].length)))throw new Error("all values arrays should have the same length");const l=t[0].length*(t[0].length-1)/2,c=Math.floor(l/this._workerCount),h=new Array(this._workerCount),u=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++)h[n]=new Promise(((i,h)=>{const d=n*c,p=n===this._workerCount-1?l:(n+1)*c;p<=d&&i({knnDistances:new Array(0),knnIndexes:new Array(0)}),u[n].postMessage({values:t,startIdx:d,endIdx:p,fnNames:e,opts:r,threshold:o,weights:s,aggregationMethod:a}),u[n].onmessage=({data:{error:t,knnDistances:e,knnIndexes:o}})=>{t?(u[n].terminate(),h(t)):(u[n].terminate(),i({knnDistances:e,knnIndexes:o}))}}));const d=await Promise.all(h),p=new Int32Array(t[0].length);for(const e of d)for(let n=0;n<t[0].length;++n)p[n]+=e.knnIndexes[n]?.length??0;const m={knnDistances:new Array(t[0].length).fill(null).map(((t,e)=>new Array(p[e]))),knnIndexes:new Array(t[0].length).fill(null).map(((t,e)=>new Array(p[e])))};for(const e of d)for(let n=0;n<t[0].length;++n)for(let t=0;t<(e.knnDistances[n]?.length??0);++t)m.knnDistances[n][p[n]-1]=e.knnDistances[n][t],m.knnIndexes[n][p[n]-1]=e.knnIndexes[n][t],p[n]-=1;return m}async multiColumnSingleValueKNN(t,e,o,r=15,s,a,l=i.EUCLIDEAN){if(t.length!==o.length||t.length!==s.length||t.length!==a.length)throw new Error("values, distance functions, options and weights arrays should have the same length");if(t.some((e=>e.length!==t[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)))),h=new Array(this._workerCount),u=t[0].length,d=t.map((t=>t[e])),p=Math.ceil(u/this._workerCount);for(let e=0;e<this._workerCount;e++)h[e]=new Promise(((n,i)=>{const h=e*p,m=e===this._workerCount-1?u:(e+1)*p;m<=h&&n({knnDistances:new Array(0),knnIndexes:new Array(0)}),c[e].postMessage({values:t.map((t=>t.slice(h,m))),target:d,fnNames:o,opts:s,nNeighbours:r,weights:a,aggregationMethod:l,startIdx:h}),c[e].onmessage=({data:{error:t,knnDistances:o,knnIndexes:r}})=>{t?(c[e].terminate(),i(t)):(c[e].terminate(),n({knnDistances:o,knnIndexes:r}))}}));const m=await Promise.all(h),f={knnDistances:new Array(r).fill(99999),knnIndexes:new Array(r).fill(-1)};for(const t of m)for(let e=0;e<(t.knnDistances?.length??0);++e)F(f.knnDistances,f.knnIndexes,t.knnDistances[e],t.knnIndexes[e]);return f}async multiColumnKNN(t,e,o=15,r,s,a=i.EUCLIDEAN){if(t.length!==e.length||t.length!==r.length||t.length!==s.length)throw new Error("values, distance functions, options and weights arrays should have the same length");if(t.some((e=>e.length!==t[0].length)))throw new Error("all values arrays should have the same length");const l=t[0].length*(t[0].length-1)/2,c=Math.floor(l/this._workerCount),h=new Array(this._workerCount),u=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++)h[n]=new Promise(((i,h)=>{const d=n*c,p=n===this._workerCount-1?l:(n+1)*c;p<=d&&i({knnDistances:new Array(0),knnIndexes:new Array(0)}),u[n].postMessage({values:t,startIdx:d,endIdx:p,fnNames:e,opts:r,nNeighbours:o,weights:s,aggregationMethod:a}),u[n].onmessage=({data:{error:t,knnDistances:e,knnIndexes:o}})=>{t?(u[n].terminate(),h(t)):(u[n].terminate(),i({knnDistances:e,knnIndexes:o}))}}));const d=await Promise.all(h),p={knnDistances:new Array(t[0].length).fill(null).map((()=>new Array(o).fill(99999))),knnIndexes:new Array(t[0].length).fill(null).map((()=>new Array(o).fill(-1)))};for(const e of d)for(let n=0;n<t[0].length;++n)for(let t=0;t<(e.knnDistances[n]?.length??0);++t)F(p.knnDistances[n],p.knnIndexes[n],e.knnDistances[n][t],e.knnIndexes[n][t]);return p}async getSampleDistances(t,e,o=[],r,s=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=t[0].length*(t[0].length-1)/2,i=Math.floor(n/this._workerCount),l=1e6,c=Math.max(Math.min(n/1e3,l),Math.min(n,l)),h=Math.floor(c/this._workerCount),u=new Array(this._workerCount);for(let l=0;l<this._workerCount;l++)u[l]=new Promise(((c,u)=>{const d=l*i,p=l===this._workerCount-1?n:(l+1)*i;a[l].postMessage({values:t,startIdx:d,endIdx:p,sampleLength:h,fnNames:e,opts:o,weights:r,aggregationMethod:s}),a[l].onmessage=({data:{error:t,distance:e}})=>{a[l].terminate(),t?u(t):c({distance:e})}}));const d=await Promise.all(u),p=d.reduce(((t,e)=>t+e.distance.length),0),m=new Float32Array(p);let f=0;for(const t of d)m.set(t.distance,f),f+=t.distance.length;return m.sort(),m}catch(t){return a?.forEach((t=>t?.terminate())),console.error(t),new Float32Array(1).fill(.5)}}async getMinimalThreshold(t,e,n=[],o,r=i.EUCLIDEAN){try{const i=t.length*(t.length-1)/2,s=await this.getSampleDistances(t,e,n,o,r);return 1-s[Math.floor(7e7/i*s.length)]}catch(t){return console.error(t),.5}}static calcSync(t,e,n,i){const o=[],r=[],s=[];let a=0,l=0,c=0;const h=t.length*(t.length-1)/2;for(;a<h;){const e=G(t[l])||G(t[c])?1:n(t[l],t[c]);1-e>=i&&(o.push(l),r.push(c),s.push(e)),a++,c++,c===t.length&&(l++,c=l+1)}return{i:new Int32Array(o),j:new Int32Array(r),distance:new Float32Array(s)}}}var V,W,U=n(8774);(W=V||(V={})).none="none",W.bold="bold",W.dashed="dashed";class j{get currentLineId(){return this._currentLineIdx}set currentLineId(t){t!==this._currentLineIdx&&(this._currentLineIdx=t,this.sp.render(this.ctx))}set linesToRender(t){this.updateLines(t),this.sp.render(this.ctx)}set linesVisibility(t){this.visibility=t,this.sp.render(this.ctx)}constructor(t,e,n,i,o=V.none){var r;this._currentLineIdx=-1,this.lineClicked=new h.Subject,this.lineHover=new h.Subject,this.mouseOverLineId=-1,this.arrowWidth=15,this.sp=t,this.xAxisCol=this.sp.dataFrame.columns.byName(e),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!==(r=i.visibility)&&void 0!==r?r:new U.A(this.lines.from.length),i.visibility||this.visibility.setAll(!0,!1),i.arrowSize&&(this.arrowWidth=i.arrowSize),this.canvas.onmousedown=t=>{var e;(null===(e=this.lines)||void 0===e?void 0:e.skipMouseOverDetection)&&(this.mouseOverLineId=this.checkCoordsOnLine(t.offsetX,t.offsetY)),-1!==this.mouseOverLineId&&this.lineClicked.next({x:t.clientX,y:t.clientY,id:this.mouseOverLineId,event:t})},this.canvas.onmousemove=t=>{var e;this.mouseOverLineId=(null===(e=this.lines)||void 0===e?void 0:e.skipMouseOverDetection)?-1:this.checkCoordsOnLine(t.offsetX,t.offsetY),-1!==this.mouseOverLineId&&this.lineHover.next({x:t.clientX,y:t.clientY,id:this.mouseOverLineId,event:t})},t.onEvent("d4-before-draw-scene").subscribe((t=>{this.renderLines()}))}updateLines(t){this.lines=t,this.multipleLinesCounts=new Uint8Array(this.lines.from.length),t.skipMultiLineCalculation?this.multipleLinesCounts.fill(0):this.createMultiLinesIndices()}renderLines(){var t,e,n,i,o,r,s,a,l,c,h,u,d,p,m,f,g;const y=this.lines.colors||this.lines.widths||this.lines.opacities||this.lines.drawArrowsArr;y||(this.ctx.lineWidth=null!==(t=this.lines.width)&&void 0!==t?t:1,this.ctx.strokeStyle=`rgba(${null!==(e=this.lines.color)&&void 0!==e?e:"0,128,0"},${null!==(n=this.lines.opacity)&&void 0!==n?n:1})`);const b=this.sp.dataFrame.filter,v=Math.pow(null!==(i=this.lines.shortLineThreshold)&&void 0!==i?i:5,2);for(let t=0;t<this.lines.from.length;t++)if(b.get(this.lines.from[t])&&b.get(this.lines.to[t])&&this.visibility.getBit(t)){let e=0;const n=this.sp.getMarkerSize(this.lines.from[t])/2,i=this.sp.getMarkerSize(this.lines.to[t])/2,b=this.sp.pointToScreen(this.lines.from[t]);let w=null==b?void 0:b.x,C=null==b?void 0:b.y;const A=this.sp.pointToScreen(this.lines.to[t]);let S=null==A?void 0:A.x,x=null==A?void 0:A.y;const E=Math.min(this.sp.viewBox.width,this.sp.viewBox.height);if(this.ctx.beginPath(),w&&C&&S&&x&&Math.hypot(S-w,x-C)/E>.01){if(y){const e=(null===(o=this.lines.colors)||void 0===o?void 0:o[t])?null===(r=this.lines.colors)||void 0===r?void 0:r[t]:null!==(s=this.lines.color)&&void 0!==s?s:"0,128,0",n=(null===(a=this.lines.opacities)||void 0===a?void 0:a[t])?null===(l=this.lines.opacities)||void 0===l?void 0:l[t]:null!==(c=this.lines.opacity)&&void 0!==c?c:1;this.ctx.strokeStyle=`rgba(${e},${n})`,this.ctx.lineWidth=(null===(h=this.lines.widths)||void 0===h?void 0:h[t])?null===(u=this.lines.widths)||void 0===u?void 0:u[t]:null!==(d=this.lines.width)&&void 0!==d?d:1}t===this._currentLineIdx&&this.toggleCurrentLineStyle(!0);const b=this.multipleLinesCounts[t];let A=null;if(b){e=this.getLineLength(w,C,S,x);const o=this.getPointOnDistance(w,C,S,x,i,e),r=this.getPointOnDistance(S,x,w,C,n,e);w=o.x,C=o.y,S=r.x,x=r.y,A=this.lines.from[t]>this.lines.to[t]?this.findControlPoint(b,w,C,S,x,t):this.findControlPoint(b,S,x,w,C,t),this.ctx.moveTo(w,C),this.ctx.quadraticCurveTo(A.x,A.y,S,x)}else(!this.lines.skipShortLines||Math.pow(S-w,2)+Math.pow(x-C,2)>v)&&(this.ctx.moveTo(w,C),this.ctx.lineTo(S,x));if((null!==(p=this.lines.drawArrows)&&void 0!==p?p:null===(m=this.lines.drawArrowsArr)||void 0===m?void 0:m.getBit(t))&&(e||(e=this.getLineLength(w,C,S,x)),e>this.arrowWidth)){const t=b?null:this.getPointOnDistance(w,C,S,x,i,e),n=b?A.x:w,o=b?A.y:C;this.canvasArrow(this.ctx,null!==(f=null==t?void 0:t.x)&&void 0!==f?f:w,null!==(g=null==t?void 0:t.y)&&void 0!==g?g:C,n,o)}this.ctx.stroke(),this.ctx.closePath(),t===this._currentLineIdx&&this.toggleCurrentLineStyle(!1)}}this.fillLeftBottomRect()}toggleCurrentLineStyle(t){switch(this.currentLineStyle){case V.bold:t?this.ctx.lineWidth+=2:this.ctx.lineWidth-=2;break;case V.dashed:t?this.ctx.setLineDash([5,5]):this.ctx.setLineDash([]);break;default:return}}fillLeftBottomRect(){const t=new Path2D;t.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(t),this.ctx.closePath()}createMultiLinesIndices(){const t={};for(let e=0;e<this.lines.from.length;e++){let n=0,i=0;this.lines.from[e]<this.lines.to[e]?(n=this.lines.from[e],i=this.lines.to[e]):(n=this.lines.to[e],i=this.lines.from[e]),t[`${n}|${i}`]?(1===t[`${n}|${i}`].length&&(this.multipleLinesCounts[t[`${n}|${i}`][0]]=1,t[`${n}|${i}`].push(1)),this.multipleLinesCounts[e]=++t[`${n}|${i}`][1]):t[`${n}|${i}`]=[e]}}checkCoordsOnLine(t,e){let n=-1,i=null,o=null;const r=this.sp.dataFrame.filter;for(let s=0;s<this.lines.from.length;s++)if(r.get(this.lines.from[s])&&r.get(this.lines.to[s])&&this.visibility.getBit(s)){const r=this.sp.getMarkerSize(this.lines.from[s])/2,a=this.sp.getMarkerSize(this.lines.to[s])/2,l=this.sp.worldToScreen(this.xAxisCol.get(this.lines.from[s]),this.yAxisCol.get(this.lines.from[s])),c=this.sp.worldToScreen(this.xAxisCol.get(this.lines.to[s]),this.yAxisCol.get(this.lines.to[s]));if(this.multipleLinesCounts[s]){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),h=this.getPointOnDistance(c.x,c.y,null==l?void 0:l.x,null==l?void 0:l.y,r,n),u=this.lines.from[s]>this.lines.to[s]?this.findControlPoint(this.multipleLinesCounts[s],i.x,i.y,h.x,h.y,s):this.findControlPoint(this.multipleLinesCounts[s],h.x,h.y,i.x,i.y,s);o=this.calculateDistToCurveLine(s,t,e,i,h,u)}else o=this.calculateDistToStraightLine(t,e,l,c);(!i&&null!==o&&o<5||i&&null!==o&&o<i)&&(i=o,n=s)}return n}calculateDistToStraightLine(t,e,n,i){const o=Math.min(n.x,i.x),r=Math.max(n.x,i.x),s=Math.min(n.y,i.y),a=Math.max(n.y,i.y);return t>=o-2&&t<=r+2&&e>=s-2&&e<=a+2?this.distToStraightLineSegment(t,e,n,i):null}distToStraightLineSegment(t,e,n,i){const o=(t,e,n,i)=>Math.pow(t-n,2)+Math.pow(e-i,2),r=o(n.x,n.y,i.x,i.y);if(0==r)return o(t,e,n.x,n.y);let s=((t-n.x)*(i.x-n.x)+(e-n.y)*(i.y-n.y))/r;return s=Math.max(0,Math.min(1,s)),o(t,e,n.x+s*(i.x-n.x),n.y+s*(i.y-n.y))}calculateDistToCurveLine(t,e,n,i,o,r){const s=Math.min(i.x,o.x,r.x),a=Math.max(i.x,o.x,r.x),l=Math.min(i.y,o.y,r.y),c=Math.max(i.y,o.y,r.y);if(e>=s-2&&e<=a+2&&n>=l-2&&n<=c+2){const t=a-s,h=c-l;return this.calculateDistToCurveInRect(e,n,i,r,o,t,h)}return null}calculateDistToCurveInRect(t,e,n,i,o,r,s){const a=Math.floor((r+s)/3),l=1/a,c=new Uint32Array(a),h=new Uint32Array(a),u=new Uint32Array(a);let d=null;const p=new U.A(a);for(let r=0;r<c.length;r++){const s=r*l,a=Math.pow(1-s,2)*n.x+2*s*(1-s)*i.x+Math.pow(s,2)*o.x,p=Math.pow(1-s,2)*n.y+2*s*(1-s)*i.y+Math.pow(s,2)*o.y,m=Math.abs(t-a),f=Math.abs(e-p),g=m+f;(!d||d>g)&&(d=g),u[r]=Math.max(m,f),c[r]=a,h[r]=p}for(let t=0;t<c.length;t++)u[t]<d&&p.setBit(t,!0,!1);let m=null;for(let n=-1;-1!==(n=p.findNext(n));){const i=Math.hypot(c[n]-t,h[n]-e);(!m||m>i)&&(m=i)}return m}getLineLength(t,e,n,i){return Math.sqrt(Math.pow(n-t,2)+Math.pow(i-e,2))}getPointOnDistance(t,e,n,i,o,r){const s=n-o*((n-t)/r),l=i-o*((i-e)/r);return new a.Point(s,l)}findControlPoint(t,e,n,i,o,r){const s=e+(i-e)/2,l=n+(o-n)/2;let c=s-e,h=l-n;const u=Math.sqrt(c*c+h*h);c/=u,h/=u;const d=50*Math.ceil(t/2);return t%2==0?new a.Point(s+d/2*h,l-d/2*c):new a.Point(s-d/2*h,l+d/2*c)}canvasArrow(t,e,n,i,o){const r=Math.atan2(i-e,o-n)+Math.PI;t.moveTo(e-this.arrowWidth*Math.sin(r-Math.PI/10),n-this.arrowWidth*Math.cos(r-Math.PI/10)),t.lineTo(e,n),t.lineTo(e-this.arrowWidth*Math.sin(r+Math.PI/10),n-this.arrowWidth*Math.cos(r+Math.PI/10))}}var q,z,Y=n(8060),K=n(3629);async function Z(t,e,i,o,s,a,l){let c=await async function(t,e,i,o,s,a,l){if(!a.distanceFnArgs)throw new Error("options.distanceFnArgs must be defined");if(t.length!==e.length||t.length!==a.distanceFnArgs.length||t.length!==o.length)throw new Error("data, metrics and options and weights must have the same length");return new Promise((function(c,h){const u=new Worker(new URL(n.p+n.u(234),n.b));u.postMessage({columnsData:t,distanceMetrics:e,method:i,options:a,weights:o,aggregationMethod:s});const d=r.events.onCustomEvent(Y.S).subscribe((()=>{try{u?.terminate()}finally{d.unsubscribe()}}));u.onmessage=({data:{error:t,embedding:e,epochNum:n,epochsLength:i}})=>{G(n)||G(i)?(d.unsubscribe(),t?h(t):c(e),setTimeout((()=>u.terminate()),100)):l&&l(n,i,e)}}))}(t,i,e,o,s,a,l);return c=c.map((t=>(0,K.S8)(t))),c}(z=q||(q={})).EUCLIDEAN="EUCLIDEAN",z.MANHATTAN="MANHATTAN";const X={[q.EUCLIDEAN]:function(t){return`\n var sum = 0.0;\n for (var i = 0u; i < ${t}; i = i + 1u) {\n sum = sum + distances[i] * distances[i] * computeInfo.weights[i] * computeInfo.weights[i];\n }\n return sqrt(sum);\n `},[q.MANHATTAN]:function(t){return`\n var sum = 0.0;\n for (var i = 0u; i < ${t}; 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 tt={[J.HAMMING]:function(t,e){return`\n let aLength: u32 = computeInfo.entrySizes[${e}][aIndex];\n let bLength: u32 = computeInfo.entrySizes[${e}][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 < ${t}; 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 / ${t};\n `},[J.EUCLIDEAN]:function(t,e){return`\n var dist: f32 = 0.0;\n for (var i = 0u; i < ${t}; 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(t,e){return`\n var dist: f32 = 0.0;\n for (var i = 0u; i < ${t}; i = i + 1u) {\n dist = dist + abs(f32(a[i] - b[i]));\n }\n return dist;\n `},[J.VECTOR_COSINE]:function(t,e){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 < ${t}; 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(t,e){return`\n var onBitsa: u32 = 0u;\n var onBitsb: u32 = 0u;\n for (var i = 0u; i < ${t}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 < ${t}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(t,e){return`\n let aLength: u32 = computeInfo.entrySizes[${e}][aIndex];\n let bLength: u32 = computeInfo.entrySizes[${e}][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, ${t+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(t,e){return`\n let aLength: u32 = computeInfo.entrySizes[${e}][aIndex];\n let bLength: u32 = computeInfo.entrySizes[${e}][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, ${t+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, ${t+1}u>;\n var horizontalGaps: array<u32, ${t+1}u>;\n\n let gapOpenPenalty: f32 = suppInfo.gapOpenPenalty${e};\n let gapExtensionPenalty: f32 = suppInfo.gapExtensionPenalty${e};\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${e}; // 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(t,e){return`\n let aLength: u32 = computeInfo.entrySizes[${e}][aIndex];\n let bLength: u32 = computeInfo.entrySizes[${e}][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${e}); // using pointers make things faster\n var diff: f32 = 0.0;\n for (var i = 0u; i < ${t}; 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 / ${t};\n `},[J.SOKAL]:function(t,e){return`\n var onBitsa: u32 = 0u;\n var onBitsb: u32 = 0u;\n for (var i = 0u; i < ${t}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 < ${t}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(t,e){return`\n var onBitsa: u32 = 0u;\n var onBitsb: u32 = 0u;\n for (var i = 0u; i < ${t}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 < ${t}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(t,e){return`\n var onBitsa: u32 = 0u;\n var onBitsb: u32 = 0u;\n for (var i = 0u; i < ${t}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 < ${t}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(t,e){return`\n let range = suppInfo.range${e};\n return f32(abs(f32(a[0]) - f32(b[0])) / range);\n `},[J.OneHot]:function(t,e){return`\n let aLength: u32 = computeInfo.entrySizes[${e}][aIndex];\n let bLength: u32 = computeInfo.entrySizes[${e}][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 `}},et={[J.HAMMING]:t=>Math.ceil(t/30),[J.EUCLIDEAN]:t=>Math.ceil(t/30),[J.MANHATTAN]:t=>Math.ceil(t/30),[J.TANIMOTO]:t=>Math.ceil(t/30),[J.SOKAL]:t=>Math.ceil(t/30),[J.COSINE]:t=>Math.ceil(t/30),[J.ASYMMETRIC]:t=>Math.ceil(t/30),[J.LEVENSTEIN]:t=>Math.ceil(t*t/60),[J.NEEDLEMAN_WUNSCH]:t=>Math.ceil(t*t/60),[J.MONOMER_CHEMICAL_DISTANCE]:t=>Math.ceil(t/25),[J.Difference]:t=>1,[J.OneHot]:t=>Math.ceil(t/40),[J.VECTOR_COSINE]:t=>Math.ceil(t/30)},nt={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])};var it=function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((i=i.apply(t,e||[])).next())}))};function ot(t,e,n,i){return t.map(((t,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 ${tt[t](e[i],i)}\n }\n `)).join("\n")+"\n"+`\n fn combinedDistance(aIndex: u32, bIndex: u32) -> f32 {\n var distances: array<f32, ${t.length}>;\n ${t.map(((t,e)=>`distances[${e}] = distanceScript${e}(aIndex, bIndex);`)).join("\n")}\n ${X[i](t.length)}\n }\n \n `}let rt=0;const st="cliffsDf",at=new h.Subject,lt="Δ activity",ct="SALI",ht="Similarity",ut="line index",dt=["From","To"],pt="filterCliffs";async function mt(t,e,i,o,l,c,h,u,d,p,m,f,g,y,b,v,w){rt++;const C=c/100;let A,S=!1;const x=f.inputs,_=await f.apply({[x[0].name]:e,[x[1].name]:h,...d.preprocessingFuncArgs??{}});let I=[];if(u===N){const e=await function(t,e,i,o,r,s,a=10,l=!1,c=2){const h=new Worker(new URL(n.p+n.u(980),n.b));let u;return h.postMessage({data:t,threshold:e,weights:i,aggregationMethod:o,distanceFns:r,distanceFnArgs:s,maxIterations:a,useWebGPU:l,inflate:c}),{promise:new Promise(((t,e)=>{u=t,h.onmessage=e=>{setTimeout((()=>h.terminate()),100),t(e.data.res)},h.onerror=t=>{setTimeout((()=>h.terminate()),100),e(t)}})),terminate:()=>{try{u(null),h.terminate()}catch(t){console.error(t)}}}}([_.entries],c,[1],"MANHATTAN",[h],[_.options??{}],d?.maxIterations??5,d.useWebGPU??!1).promise;t.columns.addNewInt(t.columns.getUnusedName("MCL Cluster")).init((t=>e.clusters[t])),I=[e.embedX,e.embedY]}else I=await Z([_.entries],u,[h],[1],"MANHATTAN",{...d,distanceFnArgs:[_.options??{}]});if(I.length!==i.length)throw new Error("Number of axes names should be equal to number of embedding dimensions");for(let e=0;e<I.length;++e)t.columns.addNewFloat(i[e]).init((t=>I[e][t]));let L=null;if(d.useWebGPU)try{L=await function(t,e=.8,n,i,o,r){return it(this,void 0,void 0,(function*(){const s=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(!T&&(T=yield navigator.gpu.requestAdapter({powerPreference:"high-performance"}),null==T))return null;let t=!1;if(M&&(M.lost.then((()=>{t=!0})),yield new Promise((t=>setTimeout(t,10)))),!M||t){const t=1e9,e=T.limits,n=e.maxBufferSize,i=e.maxStorageBufferBindingSize;try{return M=yield T.requestDevice({requiredLimits:{maxBufferSize:Math.min(n,t),maxStorageBufferBindingSize:Math.min(i,t)}}),M}catch(t){return console.error("Failed to create device with required limits",t),M=yield T.requestDevice(),M}}return M}))}();if(!s)return null;const a=Object.values(J);if(n.some((t=>!a.includes(t))))throw new Error("Invalid distance metrics provided: "+n.join(", "));if(!Object.values(q).includes(i))throw new Error("Invalid aggregation function provided: "+i);const l=1-e;if(r.length!==t.length||r.length!==n.length||r.length!==o.length)throw new Error("Options, weigths and distance functions must be provided for each column");if(t.some((e=>e.length!==t[0].length)))throw new Error("All entry lists must be the same length");const c=t.length,h=t[0].length,u=t.map(((t,e)=>function(t,e=J.HAMMING,n,i={gapOpenPenalty:1,gapExtensionPenalty:.6}){var o,r;let s=null;const a=t.some((t=>"string"==typeof t))?(s="STRING",t.map((t=>new Uint32Array(t.split("").map((t=>t.charCodeAt(0))))))):t.some((t=>"number"==typeof t))?(s="NUMBER",t.map((t=>new Float32Array([t])))):"object"==typeof t[0]&&t.some((t=>"_data"in t&&"_length"in t))?(s="BITARRAY",t.map((t=>t._data))):t.some((t=>t instanceof Float32Array))?(s="FLOAT32ARRAY",t):t.some((t=>t instanceof Uint32Array))?(s="UINT32ARRAY",t):t.some((t=>t instanceof Int32Array))?(s="INT32ARRAY",t):void 0;if(!a||!s)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((t=>t.length)));if(!nt[s]||!nt[s].has(e))throw new Error(`Distance metric '${e}' not supported for entry type '${s}'`);const h=c.reduce(((t,e)=>Math.max(t,e)),0),u=et[e](h),d="INT32ARRAY"===l?Int32Array:"FLOAT32ARRAY"===l?Float32Array:Uint32Array,p=new d(a.length*h);a.forEach(((t,e)=>{p.set(t,e*h)}));let m="",f=0,g="FLOAT32ARRAY",y=null;if(e===J.NEEDLEMAN_WUNSCH||e===J.MONOMER_CHEMICAL_DISTANCE){let t=i.scoringMatrix&&i.alphabetIndexes?Object.keys(i.alphabetIndexes).reduce(((t,e)=>Math.max(t,e.charCodeAt(0))),0):-1;if(!i.alphabetIndexes||!i.scoringMatrix){for(let e=0;e<p.length;e++)p[e]>t&&(t=p[e]);i.scoringMatrix=new Array(t+1).fill(null).map((()=>new Array(t+1).fill(0))),i.alphabetIndexes={};for(let t=0;t<i.scoringMatrix.length;t++)i.scoringMatrix[t][t]=1,i.alphabetIndexes[String.fromCharCode(t)]=t}const e=(t+1)*(t+1),s=new Array(t+1).fill(null).map((()=>new Float32Array(t+1)));for(let e=0;e<t+1;e++)s[e][e]=1;const a=i.alphabetIndexes;for(const t of Object.keys(a))for(const e of Object.keys(a))t!==e&&(s[t.charCodeAt(0)][e.charCodeAt(0)]=i.scoringMatrix[a[t]][a[e]]);f=2+e,g="FLOAT32ARRAY",y=new Float32Array(f),y[0]=null!==(o=i.gapOpenPenalty)&&void 0!==o?o:1,y[1]=null!==(r=i.gapExtensionPenalty)&&void 0!==r?r:.6;let l=2;for(let t=0;t<s.length;t++)y.set(s[t],l),l+=s[t].length;m=`\n gapOpenPenalty${n}: f32,\n gapExtensionPenalty${n}: f32,\n similarityMatrix${n}: array<array<f32, ${t+1}>, ${t+1}>`}else if(e===J.Difference){if(!i.range||"number"!=typeof i.range||i.range<=0){const t=p.reduce(((t,e)=>Math.min(t,e)),p[0]),e=p.reduce(((t,e)=>Math.max(t,e)),p[0]);i.range=e-t}i.range<=0&&(i.range=1),f=1,g="FLOAT32ARRAY",y=new Float32Array([i.range]),m=`\n range${n}: f32`}const b=p instanceof Int32Array?"i32":p instanceof Float32Array?"f32":"u32",v=`data${n}: array<array<${b}, ${h}>, ${a.length}>`;return{flatSourceArray:p,sourceArraySize:p.length,maxEntryLen:h,arraySizes:c,complexity:u,suppInfoBuffer:y,suppInfoSize:f,suppInfoType:g,suppInfoStructWgsl:m,entryType:s,dataTypeWGSL:b,dataStructWgsl:v,EncodedArrayConstructor:d}}(t,n[e],e,r[e])));if(0===c)throw new Error("No columns provided. Please provide at least one column of data.");1===c&&(i=q.MANHATTAN);let d=u.map((t=>t.suppInfoStructWgsl)).filter((t=>!!t&&""!=t)).join(",\n"),p=!1;d&&""!=d.trim()||(p=!0,d="\ndummy: f32\n");const m=u.map((t=>t.dataStructWgsl)).filter((t=>!!t&&""!=t)).join(",\n"),f=new Uint32Array(c*h);u.forEach(((t,e)=>{f.set(t.arraySizes,e*h)}));const g=1e4,y=100,b=u.reduce(((t,e)=>t+e.complexity),0),v=Math.ceil(6e3/b),w=Math.ceil(Math.sqrt(Math.ceil(100))),C=10*w,A=h*(h-1)/2,S=Math.ceil(A/g),x=s.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 ${S} 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, ${h}>, ${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 * ${C} + 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], ${h}u);\n let endAtRow: u32 = min(computeInfo.endAtRows[linearIndex], ${h}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 < ${v}; 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 >= ${h}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 ${ot(n,u.map((t=>t.maxEntryLen)),l,i)}\n\n\n `}),_=s.createComputePipeline({label:"sparse matrix compute pipeline",layout:"auto",compute:{module:x,entryPoint:"calcSparseMatrix"}}),I=new Uint32Array(g),L=new Uint32Array(g),N=new Uint32Array(g),P=new Uint32Array(g),$=Math.floor(A/g);let R=0,k=1;console.time("GPUthreadStarts");for(let t=0;t<g;t++){const e=9999===t?A-1:(t+1)*$,n=h-2-Math.floor(Math.sqrt(-8*e+4*h*(h-1)-7)/2-.5),i=e-h*n+Math.floor((n+1)*(n+2)/2);I[t]=k,L[t]=R,N[t]=i,P[t]=n,R=n,k=i}console.timeEnd("GPUthreadStarts");const O=4e4+h*c+c+u.reduce(((t,e)=>t+e.sourceArraySize),0),H=u.reduce(((t,e)=>t+e.suppInfoSize),0),G=1e6,F=O*Uint32Array.BYTES_PER_ELEMENT;let D=F;const B=15&F;0!==B&&(D+=16-B);const V=s.createBuffer({label:"compute info buffer",size:D,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST,mappedAtCreation:!0}),W=V.getMappedRange();let U=0;new Uint32Array(W,U,g).set(I),U+=g*Uint32Array.BYTES_PER_ELEMENT,new Uint32Array(W,U,g).set(L),U+=g*Uint32Array.BYTES_PER_ELEMENT,new Uint32Array(W,U,g).set(N),U+=g*Uint32Array.BYTES_PER_ELEMENT,new Uint32Array(W,U,g).set(P),U+=g*Uint32Array.BYTES_PER_ELEMENT,new Uint32Array(W,U,f.length).set(f),U+=f.length*Uint32Array.BYTES_PER_ELEMENT,new Float32Array(W,U,c).set(o),U+=c*Float32Array.BYTES_PER_ELEMENT;for(const t of u){const e=t.EncodedArrayConstructor,n=t.sourceArraySize;new e(W,U,n).set(t.flatSourceArray),U+=n*e.BYTES_PER_ELEMENT}V.unmap();const j=H*Uint32Array.BYTES_PER_ELEMENT;let z=j;const Y=15&j;0!==Y&&(z+=16-Y),z=Math.max(z,16);const K=s.createBuffer({label:"supp info buffer",size:z,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST,mappedAtCreation:!0}),Z=K.getMappedRange();let X=0;for(const t of u)t.suppInfoBuffer&&t.suppInfoBuffer.byteLength>0&&t.suppInfoSize>0&&(new("UINT32ARRAY"===t.suppInfoType?Uint32Array:Float32Array)(Z,X,t.suppInfoBuffer.length).set(t.suppInfoBuffer),X+=t.suppInfoBuffer.byteLength);0===X&&new Uint32Array(Z,0,4).set([1,1,1,1]),K.unmap();const Q=302e4*Uint32Array.BYTES_PER_ELEMENT;let tt=Q;const it=15&Q;0!==it&&(tt+=16-it);const rt=s.createBuffer({label:"results buffer",size:tt,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_SRC}),st=s.createBindGroup({label:"bindGroup for sparse matrix buffer",layout:_.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:V}},{binding:1,resource:{buffer:K}},{binding:2,resource:{buffer:rt}}]}),at=s.createBuffer({label:"results out buffer",size:rt.size,usage:GPUBufferUsage.MAP_READ|GPUBufferUsage.COPY_DST}),lt=[],ct=[],ht=[];let ut=!1;for(;!ut;){const t=s.createCommandEncoder({label:"distance encoder"}),e=t.beginComputePass({label:"distance compute pass"});e.setPipeline(_),e.setBindGroup(0,st),e.dispatchWorkgroups(w,w),e.end(),t.copyBufferToBuffer(rt,0,at,0,at.size);const n=t.finish();s.queue.submit([n]),yield s.queue.onSubmittedWorkDone(),yield at.mapAsync(GPUMapMode.READ);const i=at.getMappedRange();let o=0;const r=new Uint32Array(i,o,G);o+=G*Uint32Array.BYTES_PER_ELEMENT;const a=new Uint32Array(i,o,G);o+=G*Uint32Array.BYTES_PER_ELEMENT;const l=new Float32Array(i,o,G);o+=G*Float32Array.BYTES_PER_ELEMENT;const c=new Uint32Array(i,o,g);o+=g*Uint32Array.BYTES_PER_ELEMENT,ut=new Uint32Array(i,o,g).every((t=>1===t));const h=c.reduce(((t,e)=>t+e),0),u=new Uint32Array(h),d=new Uint32Array(h),p=new Float32Array(h);let m=0;for(let t=0;t<c.length;t++){const e=c[t];0!==e&&(u.set(r.subarray(t*y,t*y+e),m),d.set(a.subarray(t*y,t*y+e),m),p.set(l.subarray(t*y,t*y+e),m),m+=e)}lt.push(u),ct.push(d),ht.push(p),at.unmap()}const dt=lt.reduce(((t,e)=>t+e.length),0),pt=new Uint32Array(dt),mt=new Uint32Array(dt),ft=new Float32Array(dt);let gt=0;for(let t=0;t<lt.length;t++)pt.set(lt[t],gt),mt.set(ct[t],gt),ft.set(ht[t],gt),gt+=lt[t].length;return V.destroy(),K.destroy(),rt.destroy(),at.destroy(),{i:pt,j:mt,distance:ft}}))}([_.entries],C,[h],q.MANHATTAN,[1],[_.options??{}])}catch(t){console.error(t)}L||(d.useWebGPU&&console.error("WebGPU sparse matrix calculation failed, falling back to CPU implementation"),L=await(new B).calc(_.entries,h,C,_.options));const P=await async function(t,e){const n=t.distance.map(((n,i)=>{const o=Math.abs(e.get(t.i[i])-e.get(t.j[i]));return 0!=n?o/n:1/0})),i=t.distance.map((t=>1-t)),o=t.i,r=t.j,s=a.BitSet.create(e.length);return t.distance.forEach(((e,n)=>{s.set(t.i[n],!0),s.set(t.j[n],!0)})),{simVals:i,saliVals:n,n1:o,n2:r,cliffsBitSet:s}}(L,l),R=function(t,e,n,i,o,r,s){const l=new Array(t).fill(0);for(let t=0;t!=i.length;++t)n[t]!=1/0&&(s.get(i[t])>s.get(o[t])?l[i[t]]+=n[t]:l[o[t]]+=n[t]);return a.Column.fromList("double",e,l)}(e.length,`sali_${i[0].substring(i[0].lastIndexOf("_"))}`,P.saliVals,P.n1,P.n2,0,l);t.columns.add(R);const k=P.cliffsBitSet,H=function(t){const e=t.filter((t=>t!==1/0)),n=e.reduce(((t,e)=>Math.min(t,e)),Number.MAX_VALUE);return{max:e.reduce(((t,e)=>Math.max(t,e)),n),min:n}}(P.saliVals),G=.8/(H.max-H.min),F=r.shell.getTableView(t.name),D=F.addViewer(a.VIEWER.SCATTER_PLOT,{xColumnName:i[0],yColumnName:i[1],size:R.name,color:l.name,showXSelector:!1,showYSelector:!1,showSizeSelector:!1,showColorSelector:!1,markerMinSize:5,markerMaxSize:25,title:o}),W=function(t,e,n,i,o,r,s,l){const c={from:new Uint32Array(e.n1.length),to:new Uint32Array(e.n1.length),opacities:new Float32Array(e.n1.length),colors:new Array(e.n1.length),widths:new Float32Array(e.n1.length)};for(let n=0;n<e.n1.length;n++)c.from[n]=e.n1[n],c.to[n]=e.n2[n],c.opacities[n]=e.saliVals[n]===1/0?1:.2+(e.saliVals[n]-s.min)*l,c.colors[n]=t.selection.get(c.from[n])&&t.selection.get(c.to[n])?"255,255,0":"0,128,0",c.widths[n]=1;const h=a.DataFrame.create(c.from.length);return dt.forEach(((t,e)=>{h.columns.addNewString(t).init((t=>n.get(0===e?c.from[t]:c.to[t]))),function(t,e){Object.keys(e).forEach((n=>{t.tags[n]=e[n]}))}(h.col(t),r),h.col(t).semType=o})),h.columns.addNewFloat(lt).init((t=>Math.abs(i.get(c.from[t])-i.get(c.to[t])))),h.columns.addNewInt(ut).init((t=>t)),h.columns.addNewFloat(ct).init((t=>e.saliVals[t])),h.columns.addNewFloat(ht).init((t=>e.simVals[t])),h.name=`${st}${rt}`,{lines:c,linesDf:h}}(t,P,e,l,p,m,H,G);W.lines.skipMultiLineCalculation=!0,W.linesDf.col(ct).setTag("description","Structure−Activity Landscape Index (activity difference divided by 1 minus similarity)");const U=new j(D,i[0],i[1],W.lines,V.none),z=b?b(W.linesDf,dt).sort([ct],[!1]):W.linesDf.plot.grid().sort([ct],[!1]);z.col(ut)&&(z.col(ut).visible=!1),t.temp[".cliffsDfGrid"]=z;const Y=s.button(`${W.linesDf.rowCount} cliffs`,(()=>{const t=$()(F.viewers).some((t=>t.dataFrame.name===`${st}${rt}`));w&&!t&&F.addViewer(z),F.dockManager.dock(z,"down",null,"Activity cliffs",v??.2)}));Y.classList.add("scatter_plot_link","cliffs_grid");const K=s.input.toggle("Show only cliffs",{value:!1,onValueChanged:e=>{e?(D.dataFrame.setTag(pt,i[0]),t.filter.and(k),at.next(i[0])):(D.dataFrame.setTag(pt,""),t.filter.setAll(!0),at.next(""))}});D.root.prepend(s.divH([Y,K.root],"cliffs_div")),at.subscribe((t=>{K.enabled=""===t||t===i[0]})),t.onRowsFiltering.subscribe((()=>{K.value&&t.filter.and(P.cliffsBitSet)}));const X=r.events.onViewerClosed.subscribe((t=>{t.args.viewer===D&&(F.dockManager.close(z.root),X.unsubscribe(),F.subs=F.subs.filter((t=>t!==X)))}));return F.subs.push(X),W.linesDf.onCurrentCellChanged.subscribe((()=>{for(let t=0;t<W.linesDf.rowCount;t++)W.lines.widths[t]=t===W.linesDf.currentRowIdx?3:1;U.linesToRender=W.lines;const n=W.linesDf.currentCol&&W.linesDf.currentCol.name===dt[1]?W.lines.to:W.lines.from,o=-1!==W.linesDf.currentRowIdx?W.linesDf.currentRowIdx:null;if(D.dataFrame.currentRowIdx=o?n[o]:-1,null!==o){const n=W.linesDf.currentRowIdx;U.currentLineId=n;const{zoomLeft:a,zoomRight:c,zoomTop:h,zoomBottom:u}=function(t,e,n,i,o,r){const s=Math.abs(n-o),a=Math.abs(i-r),l=t/s,c=e/a,h=Math.min(l,c),u=t/h*5,d=e/h*5,p=(n<o?n:o)+s/2-u/2,m=(i>r?i:r)-a/2+d/2;return{zoomLeft:p,zoomRight:p+u,zoomTop:m,zoomBottom:m-d}}(D.viewport.width,D.viewport.height,D.dataFrame.get(i[0],W.lines.from[n]),D.dataFrame.get(i[1],W.lines.from[n]),D.dataFrame.get(i[0],W.lines.to[n]),D.dataFrame.get(i[1],W.lines.to[n]));D.zoom(a,h,c,u),K.value?t.filter.and(k):!0===K.enabled&&t.filter.setAll(!0),setTimeout((()=>{!function(t,e,n,i,o,a,l,c,h){const u=e.getPane("Cliff Details");s.empty(u.root);const d=h({points:[n,i],lineId:o,df:t,seqCol:a,activityCol:l,sali:c});u.root.append(d),setTimeout((()=>{r.shell.o=e.root}),500)}(t,A,W.lines.from[o],W.lines.to[o],o,e,l,W.linesDf.get(ct,o),y);const n=D.dataFrame.getSortedOrder(F.grid.sortByColumns,F.grid.sortTypes);F.grid.scrollToCell(e.name,n.indexOf(D.dataFrame.currentRowIdx))}),1e3)}})),W.linesDf.onSelectionChanged.subscribe((e=>{setTimeout((()=>(()=>{const e=a.BitSet.create(t.rowCount);for(let t=0;t<W.linesDf.rowCount;t++){const n=W.linesDf.selection.get(t);n&&(e.set(W.lines.from[t],!0),e.set(W.lines.to[t],!0)),W.lines.colors[t]=n?"255,255,0":"0,128,0"}t.selection.copyFrom(e),U.linesToRender=W.lines})()),100)})),t.onSelectionChanged.subscribe((e=>{!1===t.selection.anyTrue&&"number"==typeof e&&(S?S=!1:(t=>{t.selection.setAll(!1);for(let t=0;t<W.lines.colors.length;t++)W.lines.colors[t]="0,128,0";U.linesToRender=W.lines})(z.dataFrame))})),U.lineClicked.subscribe((e=>{if(S=!0,U.currentLineId=e.id,-1!==e.id){const n=W.linesDf.selection.clone();setTimeout((()=>{e.event.ctrlKey?(n.set(e.id,!n.get(e.id)),W.linesDf.selection.copyFrom(n)):(W.linesDf.currentRowIdx!==e.id&&(W.linesDf.currentRowIdx=e.id,t.currentRowIdx=W.lines.from[e.id]),W.linesDf.selection.copyFrom(n));const i=W.linesDf.getSortedOrder(z.sortByColumns,z.sortTypes);z.scrollToCell(dt[0],i.indexOf(e.id))}),500)}})),U.lineHover.pipe((0,O.debounceTime)(500)).subscribe((n=>{-1!==n.id&&-1===t.mouseOverRowIdx&&s.tooltip.show(g({lineId:n.id,points:[W.lines.from[n.id],W.lines.to[n.id]],df:t,seqCol:e,activityCol:l}),n.x,n.y)})),D.addProperty("similarityLimit","double",C),A=function(){const t=s.accordion(),e=s.element("i");return e.className="grok-icon svg-icon svg-view-layout",t.addTitle(s.span([e,s.label("Activity cliffs")])),t.addPane("Cliff Details",(()=>s.divText("Cliff has not been selected")),!0),r.shell.o=t.root,t}(),D}var ft,gt=n(2003),yt=n(3516),bt=n(6718),vt=n(3077),wt=n(439);!function(t){t.IDENTITY="identity",t.SIMILARITY="similarity"}(ft||(ft={}));var Ct=n(9192);class At{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 St extends k{constructor(t={}){super({...t,enableMCL:!0});const e=Array.from(this.tableInput.value.columns.numericalNoDateTime);this.activitiesInput=s.input.column("Activities",{table:this.tableInput.value,value:e.length?e[0]:null,filter:t=>e.includes(t)}),this.activitiesInputRoot=this.activitiesInput.root,this.similarityInput=s.input.int("Similarity cutoff",{value:80}),this.methodsParams[N]=new At}onTableInputChanged(){if(super.onTableInputChanged(),this.activitiesInputRoot){s.empty(this.activitiesInputRoot);const t=Array.from(this.tableInput.value.columns.numerical);this.activitiesInput=s.input.column("Activities",{table:this.tableInput.value,value:t.length?t[0]:null,filter:e=>t.includes(e)}),Array.from(this.activitiesInput.root.children).forEach((t=>this.activitiesInputRoot.append(t)))}}getEditor(){return s.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(t){super.applyInput(t),this.activitiesInput.value=this.tableInput.value.col(t.activityCol),this.similarityInput.value=t.simThreshold}}var xt,Et,Tt,Mt=function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((i=i.apply(t,e||[])).next())}))};function _t(t){const e=["Embed_X","Embed_Y"],n=t.columns.names().filter((t=>t.includes(e[0]))).length+1;return e.map((t=>`${t}_${n}`))}function It(t,e){return`${e} (${t.length>4?`${t.length} columns`:t.map((t=>t.name)).join(", ")})`}n(5540),function(t){t.ADD="ADD",t.SUB="SUB",t.MULT="MULT"}(xt||(xt={})),function(t){t.SQUARE="SQUARE",t.INVERSE="INVERSE",t.TRANSPOSE="TRANSPOSE",t.NORM="NORM",t.COLUMN_NORM="COLUMN_NORM"}(Et||(Et={})),function(t){t.SCALARMULT="SCALARMULT",t.SCALARADD="SCALARADD",t.SCALARPOW="SCALARPOW"}(Tt||(Tt={})),Object.prototype.toString;var Lt=n(6873),Nt=n(4356),Pt=n(6717),$t=n(4870),Rt=n(3856),kt=n(6882),Ot=n(7278),Ht=n(5553),Gt=n(6642),Ft=n(3599),Dt=n(673),Bt=n(8312);class Vt extends Gt.sD{monomerLib=null;seqHelper=null;constructor(t,e){super(t,e,io.logger),(0,bt.pj)().then((t=>{this.monomerLib=t.getMonomerLib(),this.dirty=!0,this.gridCol?.grid?.invalidate(),this.subs.push(this.monomerLib.onChanged.subscribe((()=>{this.dirty=!0,this.gridCol?.grid?.invalidate()})))})),(0,Bt.Q)().then((t=>{this.seqHelper=t,this.dirty=!0,this.gridCol?.grid?.invalidate()}))}}var Wt=n(4139);const Ut=new class{constructor(){this.seqHandler="seq-handler",this.notationProvider="seq-handler.notation-provider"}};class jt extends a.SemanticValue{get value(){return this.seqHandler.column.get(this.rowIdx)}set value(t){this.seqHandler.column.set(this.rowIdx,t)}get helm(){return this.seqHandler.getHelm(this.rowIdx)}isDna(){return this.seqHandler.alphabet===wt.YI.DNA}isRna(){return this.seqHandler.alphabet===wt.YI.RNA}isNaturalPeptide(){return this.seqHandler.alphabet===wt.YI.PT}isHelm(){return this.seqHandler.isHelm()}constructor(t,e){if(null==e.column.dataFrame)throw new Error("Attribute .dataFrame is required for SeqValueBase from cell");const n=e.column.dataFrame.cell(t,e.column.name);super(a.SemanticValue.fromTableCell(n).dart),this.rowIdx=t,this.seqHandler=e}getSplitted(){return this.seqHandler.getSplitted(this.rowIdx)}getSplittedWithSugarsAndPhosphates(){if(!this.isDna()&&!this.isRna())return this.getSplitted();const t=(0,Ot.qp)(this.helm),e=[],n=/\(|\)/;for(let i=0;i<t.length;i++){const o=t.getOriginal(i),r=o.split(n).filter((t=>!!t));3===r.length?(e.push(r[0]),e.push(r[1]),e.push(r[2])):e.push(o)}return new Ot.Mu(e,this.seqHandler.defaultGapOriginal)}}const qt=gt.zS;function zt(t){const e=!$().enumerate(t).some((([e,n])=>e.length>1&&0!=n&&n!=t.length-1)),n=[],i=e?"":" ";for(const[e,o]of $().enumerate(t)){let r=e;o<t.length&&(r+=`${e?"":"-"}${i}`),n.push(r)}return[n,e]}class Yt 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=io.seqHelper}getRendererBack(t){const[e,n,i]=(0,Gt.BG)(t);if(n.meta.units!==gt.Hi.CUSTOM)return i.rendererBack;let o=null;return this.seqHelper&&(o=this.seqHelper.getSeqHandler(n).getRendererBack(e,n)),o}onClick(t,e){if(t.cell.column.temp["current-word"]=t.cell.value,t.grid.invalidate(),t.cell.column.meta.units===gt.Hi.CUSTOM){const n=this.getRendererBack(t);n?.onClick(t,e)}}onMouseEnter(t,e){const n=this.getRendererBack(t);n?.onMouseEnter(t,e),this.hasMouseOver=!0}onMouseMove(t,e){const n=this.getRendererBack(t);n?.onMouseMove(t,e)}onMouseLeave(t,e){if((0,Ht.WN)(t,null),t?.grid){const e=t.grid.onEvent("d4-grid-show-tooltip").subscribe((t=>{e.unsubscribe(),this.hasMouseOver&&t.preventDefault()}))}this.hasMouseOver=!1}onDoubleClick(t,e){const n=this.getRendererBack(t);n?.onDoubleClick(t,e)}onKeyDown(t,e){const n=this.getRendererBack(t);n?.onKeyDown(t,e)}onKeyPress(t,e){const n=this.getRendererBack(t);n?.onKeyPress(t,e)}renderInt(t,e,n,i,o,r,s){const[a,l,c]=(0,Gt.BG)(r);if(!l)return;const h=l.temp,u=this.seqHelper.getSeqHandler(l);let d=(io.properties?io.properties.maxMonomerLength:4)??50;if(Rt.gp.maxMonomerLength in l.tags){const t=parseInt(l.getTag(Rt.gp.maxMonomerLength));d=!isNaN(t)&&t?t:50}if(".mm.cellRenderer.maxMonomerLength"in h){const t=h[".mm.cellRenderer.maxMonomerLength"];d=!isNaN(t)&&t?t:50}let p=c.rendererBack;p||(p=c.rendererBack=new kt.Jy(a,l,io.logger,d,(()=>{const{font:t,fontWidth:e}=kt.Jy.getFontSettings(l);return{font:t,fontCharWidth:e,separatorWidth:u.isMsa()?8:0,monomerToShort:qt}})),l.temp[".mm.cellRenderer.settingsChanged"],Dt.s.true,p.init().then((()=>{}))),p.render(t,e,n,i,o,r,s)}render(t,e,n,i,o,r,s){if(r.cell.column?.meta?.units!==gt.Hi.CUSTOM)this.renderInt(t,e,n,i,o,r,s);else{const a=this.getRendererBack(r);a?.render(t,e,n,i,o,r,s)}}}class Kt extends Vt{constructor(t,e){super(t,e)}render(t,e,n,i,o,r,s){const a=window.devicePixelRatio,l=r.grid,c=r.cell.value??"",h=this.tableCol.tags[gt.gp.separator],u=this.tableCol.meta.units;i=(0,kt.U0)(l,t,e,i,a);const[d,p]=c.split("#"),m=this.tableCol.temp[Ut.notationProvider]?.separatorSplitter??(0,Ot.Iv)(u,h),f=m(d),g=m(p),y=$().count(0).take(f.length).map((t=>f.getCanonical(t))).toArray(),b=$().count(0).take(g.length).map((t=>g.getCanonical(t))).toArray(),v=this.tableCol.getTag(gt.gp.alphabet);Xt(t,e,n,i,o,y,b,v===gt.YI.RNA||v===gt.YI.DNA?Ft.o.NUCLEOTIDE:Ft.o.AA,this.monomerLib,void 0,void 0)}async awaitRendered(t=1e4,e=`${t} timeout`){return Promise.resolve()}static getOrCreate(t){const[e,n,i]=(0,Gt.BG)(t);let o=i.rendererBack;return o||(o=i.rendererBack=new Kt(e,n)),o}}class Zt extends a.GridCellRenderer{get name(){return"MacromoleculeDifferenceCR"}get cellType(){return Wt.uF.MACROMOLECULE_DIFFERENCE}get defaultHeight(){return 30}get defaultWidth(){return 230}render(t,e,n,i,o,r,s){Kt.getOrCreate(r).render(t,e,n,i,o,r,s)}}function Xt(t,e,n,i,o,r,s,a,l,c,h){if(r.length!==s.length){const t=function(t,e){let n=0,i=0;const o=t.length>e.length?t:e,r=t.length>e.length?e:t;for(let t=0;t<r.length;t++)o[t]===r[t]&&n++;const s=o.length-r.length;for(let t=o.length-1;t>s;t--)o[t]===r[t-s]&&i++;const a=new Array(Math.abs(t.length-e.length)).fill(wt.b9[gt.Hi.FASTA]);function l(t){return n>i?t.concat(a):a.concat(t)}return t.length>e.length?e=l($()(e).toArray()):t=l($()(t).toArray()),{subParts1:t,subParts2:e}}(r,s);r=t.subParts1,s=t.subParts2}const u=t.measureText(zt(r).join("")),d=t.measureText(zt(s).join("")),p=Math.max(u.width,d.width);c&&(i=p+4*r.length,t.canvas.width=p+4*r.length);let m=Math.max(e,e+(i-(p+4*r.length))/2)+5;const f=Math.max(n,n+(o-28)/2);t.save();try{t.beginPath(),t.rect(e,n,c?p+4*r.length:i,o),t.clip(),t.font="12px monospace",t.textBaseline="top";const u=7;for(let e=0;e<r.length;e++){const n=r[e],c=s[e];let d=kt.S$;if(l&&(d=l.getMonomerTextColor(a,n)),n!=c){let r=kt.S$;l&&(r=l.getMonomerTextColor(a,c));const s=(0,Rt.oZ)(t,n,m,f-u,i,o,{color:d,pivot:0,left:!0}),p=(0,Rt.oZ)(t,c,m,f+u,i,o,{color:r,pivot:0,left:!0});m=Math.max(p,s),h&&(h[e]=Jt(n,c,d,r,f,u,o))}else m=(0,Rt.oZ)(t,n,m,f,i,o,{color:d,pivot:0,left:!0,transparencyRate:.5});m+=4}}finally{t.restore()}}function Jt(t,e,n,i,o,r,s){const a=document.createElement("canvas"),l=a.getContext("2d");l.font="12px monospace";const c=l.measureText(zt([t]).join("")).width,h=l.measureText(zt([e]).join("")).width,u=Math.max(c,h);return a.height=s,a.width=u+4,l.font="12px monospace",l.textBaseline="top",(0,Rt.oZ)(l,t,0,o-r,u,s,{color:n,pivot:0,left:!0}),(0,Rt.oZ)(l,e,0,o+r,u,s,{color:i,pivot:0,left:!0}),a}var Qt,te=n(8070),ee=n(4326);!function(t){t.Unknown="unknown",t.FR="framework",t.CDR="cdr"}(Qt||(Qt={}));const ne=new class{constructor(){this.regionTypes=[Qt.CDR],this.chains=["Heavy","Light"],this.skipEmptyPositions=!1,this.fitWidth=!1,this.positionWidth=16,this.positionHeight=ee.fH.Entropy,this.filterSource=ee.Fo.filterSource}};var ie=n(7602),oe=n(250);const re=Qt;var se,ae;!function(t){t.STYLE="Style",t.BEHAVIOR="Behavior",t.LAYOUT="Layout",t.DATA="Data"}(se||(se={})),function(t){t.skipEmptyPositions="skipEmptyPositions",t.regionTypes="regionTypes",t.chains="chains",t.fitWidth="fitWidth",t.positionWidth="positionWidth",t.positionHeight="positionHeight",t.filterSource="filterSource"}(ae||(ae={}));const le=ne;class ce 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(ae.skipEmptyPositions,le.skipEmptyPositions,{category:se.DATA}),this.regionTypes=this.stringList(ae.regionTypes,le.regionTypes,{category:se.DATA,choices:Object.values(re).filter((t=>t!=re.Unknown))}),this.chains=this.stringList(ae.chains,le.chains,{category:se.DATA,choices:["Heavy","Light"]}),this.fitWidth=this.bool(ae.fitWidth,le.fitWidth,{category:se.LAYOUT}),this.positionWidth=this.float(ae.positionWidth,le.positionWidth,{category:se.LAYOUT,editor:"slider",min:0,max:64,description:"Internal WebLogo viewers property width of position."}),this.positionHeight=this.string(ae.positionHeight,le.positionHeight,{category:se.LAYOUT,choices:Object.keys(ee.fH)}),this.filterSource=this.string(ae.filterSource,le.filterSource,{category:se.BEHAVIOR,choices:Object.values(ee.lT)}),this.viewSyncer=new ie.g(io.logger)}static viewerCounter=-1;viewerId=++ce.viewerCounter;viewerToLog(){return`VdRegionsViewer<${this.viewerId}>`}async init(){this.subs.push((0,h.fromEvent)(this.root,"mousemove").subscribe(this.rootOnMouseMove.bind(this)))}detach(){const t=`${this.viewerToLog()}.detach()`,e=super.detach.bind(this);this.viewSyncer.sync(`${t}`,(async()=>{this.setDataInProgress||(this.viewed&&(await this.destroyView("detach"),this.viewed=!1),e())}))}onTableAttached(){super.onTableAttached(),this.setData(this.regions)}onPropertyChanged(t){if(super.onPropertyChanged(t),t){switch(t.name){case ae.regionTypes:case ae.chains:this.setData(this.regions)}switch(t.name){case ae.skipEmptyPositions:for(let t=0;t<this.logos.length;++t)for(const e of this.chains)this.logos[t][e].setOptions({[oe.n5.skipEmptyPositions]:this.skipEmptyPositions});this.calcSize();break;case ae.fitWidth:case ae.positionWidth:this.calcSize();break;case ae.positionHeight:for(let t=0;t<this.logos.length;++t)for(const e of this.chains)this.logos[t][e].setOptions({[oe.n5.positionHeight]:this.positionHeight});this.calcSize();break;case ae.filterSource:this.filterSourceInput.value=this.filterSource;break;default:this.setData(this.regions)}}else console.warn("Bio: VdRegionsViewer.onPropertyChanged() property is null")}setData(t){const e=`${this.viewerToLog()}.setData()`;io.logger.debug(`${e}, in, regions.length = ${t.length}`),this.viewSyncer.sync(`${e}`,(async()=>{if(!this.setDataInProgress){this.setDataInProgress=!0;try{this.viewed&&(await this.destroyView("setData"),this.viewed=!1),this.regions=t,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(t){io.logger.debug(`Bio: VdRegionsViewer.destroyView( mainLayout = ${this.mainLayout?"value":"none"} ), purpose = '${t}', this.regions.length = ${this.regions.length}`),this.filterSourceInput&&s.empty(this.filterSourceInput.root),null!=this.mainLayout&&(this.mainLayout.remove(),this.host.remove(),this.host=null,this.mainLayout=null);for(const t of this.viewSubs)t.unsubscribe()}async buildView(t){io.logger.debug(`Bio: VdRegionsViewer.buildView() begin, purpose = '${t}', this.regions.length = ${this.regions.length}`);const e=this.regions.filter((t=>this.regionTypes.includes(t.type))),n=Array.from(new Set(e.map((t=>t.order)))).sort(),i=[];for(let t=0;t<n.length;t++)for(const o of this.chains){const r=e.find((e=>e.order==n[t]&&e.chain==o));i.push((async()=>{const e=await this.dataFrame.plot.fromType("WebLogo",{sequenceColumnName:r.sequenceColumnName,startPositionName:r.positionStartName,endPositionName:r.positionEndName,fixWidth:!0,skipEmptyPositions:this.skipEmptyPositions,positionWidth:this.positionWidth,positionHeight:this.positionHeight,filterSource:this.filterSource});return e.onSizeChanged.subscribe((()=>{this.calcSize()})),[t,o,e]})())}const o=await Promise.all(i);this.logos=new Array(n.length);for(let t=0;t<n.length;++t)this.logos[t]={};for(const[t,e,n]of o)this.logos[t][e]=n,this.viewSubs.push(n.onFreqsCalculated.subscribe((()=>{this.calcSize()})));this.mainLayout=s.table(this.chains,(t=>[...n.length>0?[s.div(t,{style:{transform:"rotate(-90deg)",font:"12px Roboto, Roboto Local, sans-serif",textAlign:"center",width:"16px",marginTop:"24px",marginLeft:"6px"}})]:[],...[...Array(n.length).keys()].map((e=>{const n=this.logos[e][t];return n.root.style.height="100%",s.div([n.root],{style:{marginTop:"4px",marginBottom:"4px"}})}))]),["",...[...Array(n.length).keys()].map((t=>e.find((e=>e.order==n[t]&&e.chain==this.chains[0])).name||"Name"))]),this.mainLayout.className="mlb-vd-regions-viewer-table2",this.filterSourceInput=s.input.choice("Data source",{value:this.filterSource,items:Object.values(ee.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=s.div([this.mainLayout,this.filterSourceInput.root],{}),this.root.appendChild(this.host),this.root.style.overflowX="auto",this.calcSize(),this.viewSubs.push(s.onSizeChanged(this.root).subscribe(this.rootOnSizeChanged.bind(this))),io.logger.debug("Bio: VdRegionsViewer.buildView() end")}calcSizeRequested=!1;calcSize(){io.logger.debug("Bio: VdRegionsViewer.calcSize(), start");const t=()=>{if(!this.host)return;const t=(this.root.clientHeight-54)/this.chains.length;let e=0;for(let n=0;n<this.logos.length;n++){for(const e of this.chains)this.logos[n][e].root.style.height=`${t}px`;e+=Math.max(...this.chains.map((t=>this.logos[n][t].Length)))}if(this.fitWidth){if(this.logos.length>0&&e>0){const t=22,n=13,i=9,o=(this.root.clientWidth-t-(this.logos.length-1)*i-n)/e;for(let t=0;t<this.logos.length;t++)for(const e of this.chains){const n=this.logos[t][e];n.setOptions({[oe.n5.positionWidth]:o-n.positionMarginValue}),n.root.style.width=o*n.Length+"px"}}this.host.style.setProperty("overflow","hidden","important")}else{for(let t=0;t<this.logos.length;t++)for(const e of this.chains)this.logos[t][e].setOptions({[oe.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((()=>{t(),this.calcSizeRequested=!1}),0))}rootOnSizeChanged(t){this.calcSize()}rootOnMouseMove(t){}filterSourceInputOnValueChanged(){const t=`${this.viewerToLog()}.filterSourceInputOnValueChanged()`,e=this.filterSourceInput.value;this.viewSyncer.sync(`${t}`,(async()=>{if(this.filterSource!==e){this.props.getProperty(ae.filterSource).set(this,e);for(let t=0;t<this.logos.length;t++)for(let e=0;e<this.chains.length;e++){const n=this.chains[e];this.logos[t][n].setOptions({[oe.n5.filterSource]:this.filterSource})}}}))}_onRendered=new h.Subject;get onRendered(){return this._onRendered}invalidate(t){const e=`${this.viewerToLog()}.invalidate(${t?` <- ${t} `:""})`;this.viewSyncer.sync(`${e}`,(async()=>{this._onRendered.next()}))}async awaitRendered(t=5e3){await(0,te.PE)(this.onRendered,(()=>{}),(()=>{this.invalidate()}),t);const e=this.viewSyncer.resetErrors();if(e.length>0)throw e[0]}}var he=n(6625),ue=n(6863);async function de(t,e,n="Morgan",i=1,o=.6){const r=t.length,s=io.seqHelper.getSeqHandler(t),a=Array(r);let l=1;const c=new Map,h=t.categories,u=t.getRawData();for(let e=0;e<r;e++){if(null===h[u[e]]||t.isNone(e)){a[e]=null;continue}a[e]="";const n=s.getSplitted(e);for(let t=0;t<n.length;t++){const i=n.getCanonical(t);c.has(i)||(c.set(i,String.fromCharCode(l)),l++),a[e]+=c.get(i)}}let d={};if(e===ue.Z.MONOMER_CHEMICAL_DISTANCE||e===ue.Z.NEEDLEMANN_WUNSCH){const t=Array.from(c.keys()),r=await(0,bt.A7)(t,n),s={};Object.entries(r.alphabetIndexes).forEach((([t,e])=>{s[c.get(t)]=e}));const l=a.reduce(((t,e)=>Math.max(t,e?.length||0)),0);d={scoringMatrix:r.scoringMatrix,alphabetIndexes:s,maxLength:l},e===ue.Z.NEEDLEMANN_WUNSCH&&(d.gapOpen=i,d.gapExtend=o)}return{seqList:a,options:d}}var pe=n(4954);function me(t){const e=s.divH([],{style:{gap:"10px"}}),n=s.divV([s.divText(t.seqCol.name),s.divText(t.activityCol.name)]);return n.style.fontWeight="bold",n.style.display="flex",n.style.justifyContent="space-between",e.append(n),t.points.forEach((n=>{const i=s.divText(t.activityCol.get(n).toFixed(2));i.style.display="flex",i.style.justifyContent="left",i.style.paddingLeft="30px",e.append(s.divV([s.divText(t.seqCol.get(n)),i]))})),e}function fe(t){const e=s.div();e.append(s.divText(t.seqCol.name,{style:{fontWeight:"bold"}}));const n=new Array(2);t.points.forEach(((e,i)=>{n[i]=t.activityCol.get(e)}));const i={},o=io.seqHelper.getSeqHandler(t.seqCol),r=o.defaultBiotype,a=ye(o.getSplitted(t.points[0]),o.getSplitted(t.points[1]),r,i);return e.append(s.div(a,{style:{width:"300px",overflow:"scroll"}})),e.append(be(i)),e.append(ge("Activity delta",Math.abs(n[0]-n[1]))),e.append(ge("Cliff",t.sali)),e}function ge(t,e){return s.divH([s.divText(`${t}: `,{style:{fontWeight:"bold",paddingRight:"5px"}}),s.divText(e.toFixed(2))],{style:{paddingTop:"10px"}})}function ye(t,e,n,i){const o=document.createElement("canvas"),r=o.getContext("2d");o.height=30;const s=io.monomerLib;return Xt(r,0,0,0,30,$().count(0).take(t.length).map((e=>t.getCanonical(e))).toArray(),$().count(0).take(e.length).map((t=>e.getCanonical(t))).toArray(),n,s,!0,i),o}function be(t){const e=s.div();if(Object.keys(t).length>0){const n=s.divV([]);n.append(s.divH([s.divText("Pos",{style:{fontWeight:"bold",width:"30px",borderBottom:"1px solid"}}),s.divText("Difference",{style:{fontWeight:"bold",borderBottom:"1px solid"}})]));for(const e of Object.keys(t))t[e].style.borderBottom="1px solid lightgray",n.append(s.divH([s.divText((parseInt(e)+1).toString(),{style:{width:"30px",borderBottom:"1px solid lightgray"}}),t[e]]));e.append(n)}return e}function ve(t,e){const n=a.Column.string("seq_diff",t.rowCount).init((n=>`${t.get(e[0],n)}#${t.get(e[1],n)}`));n.semType="MacromoleculeDifference",n.meta.units=t.col(e[0]).meta.units,n.setTag(gt.gp.separator,t.col(e[0]).getTag(gt.gp.separator)),t.columns.add(n);const i=t.plot.grid();return i.col(e[0]).visible=!1,i.col(e[1]).visible=!1,i}class we extends a.JsViewer{constructor(t,e){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,{...e?{semType:e}:{},nullable:!1}),this.name=t,this.semType=e}init(){this.initialized=!0}detach(){this.subs.forEach((t=>t.unsubscribe()))}async onTableAttached(){if(this.init(),this.dataFrame){this.subs.push(a.debounce(this.dataFrame.onRowsRemoved,50).subscribe((t=>this.render(!0))));const t="diversity"!==this.name;this.subs.push(a.debounce(this.dataFrame.onCurrentRowChanged,50).subscribe((e=>{this.gridSelect||this.render(t)}))),this.subs.push(a.debounce(this.dataFrame.selection.onChanged,50).subscribe((t=>this.render(!1)))),this.subs.push(a.debounce(s.onSizeChanged(this.root),50).subscribe((t=>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(t){if(super.onPropertyChanged(t),this.initialized){if("targetColumnName"===t.name){const e=this.dataFrame.col(t.get(this));e.semType===this.semType&&(this.targetColumn=e)}this.debouncedRender()}}debouncedRender(t=!0){this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout((()=>{this.render(t),this.debounceTimer=null}),100)}render(t=!0){this.renderPromise=this.renderPromise.then((async()=>{this.computeRequested=this.computeRequested||t,await this.renderInt(t)}))}async renderInt(t){}beforeRender(){return!(!this.initialized||!this.targetColumnName||this.dataFrame&&this.targetColumnName&&this.dataFrame.col(this.targetColumnName).semType!==this.semType&&(r.shell.error(`${this.targetColumnName} is not ${this.semType} type`),1))}}class Ce extends we{distanceMetric;fingerprint;gapOpen;gapExtend;metricsProperties=["distanceMetric","fingerprint","gapOpen","gapExtend"];fingerprintChoices=["Morgan","RDKit","Pattern","AtomPair","MACCS","TopologicalTorsion"];distanceFunctionChoices=[ue.Z.NEEDLEMANN_WUNSCH,ue.Z.HAMMING,ue.Z.LEVENSHTEIN,ue.Z.MONOMER_CHEMICAL_DISTANCE];tags=[a.TAGS.UNITS,gt.gp.aligned,gt.gp.separator,gt.gp.alphabet,"cell.renderer"];preComputeDistanceMatrix=!1;requiresSampling=!1;constructor(t,e){super(t,e),this.distanceMetric=this.string("distanceMetric",ue.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 t=this.dataFrame.rowCount;this.preComputeDistanceMatrix=t<=1e4,this.requiresSampling=t>1e4}}needsGapPenalties(){return this.distanceMetric===ue.Z.NEEDLEMANN_WUNSCH}needsFingerprint(){return this.distanceMetric===ue.Z.MONOMER_CHEMICAL_DISTANCE||this.distanceMetric===ue.Z.NEEDLEMANN_WUNSCH}}const Ae={gapPenalty:1,matchScore:1,gapSymbol:wt.b9[wt.Hi.FASTA],localAlignment:!1};class Se extends Ce{seqHelper;cutoff;hotSearch;similarColumnLabel;sketchedMolecule="";curIdx=0;molCol=null;idxs=null;scores=null;gridSelect=!1;targetMoleculeIdx=0;computeCompleted=new h.Subject;distanceMatrixComputed=!1;mmDistanceMatrix;knn;kPrevNeighbors=0;demo;analysisGrid;subInited=!1;lastDistanceMetric="";lastFingerprint="";lastGapOpen=0;lastGapExtend=0;constructor(t,e){super("similarity",a.SEMTYPE.MACROMOLECULE),this.seqHelper=t,this.cutoff=this.float("cutoff",.01,{min:0,max:1}),this.hotSearch=this.bool("hotSearch",!0),this.similarColumnLabel=this.string("similarColumnLabel",null),this.demo=e}init(){this.hotSearch=!0,this.initialized=!0}async renderInt(t){if(this.beforeRender()&&this.targetColumn){this.curIdx=-1==this.dataFrame.currentRowIdx?0:this.dataFrame.currentRowIdx;const e=this.lastDistanceMetric!==this.distanceMetric||this.lastFingerprint!==this.fingerprint||this.lastGapOpen!==this.gapOpen||this.lastGapExtend!==this.gapExtend;if(t&&!this.gridSelect||e){this.targetMoleculeIdx=(this.dataFrame.currentRowIdx??-1)<0?0:this.dataFrame.currentRowIdx,await this.computeByMM();const t=null!=this.similarColumnLabel?this.similarColumnLabel:`similar (${this.targetColumn})`;this.molCol=a.Column.string(t,this.idxs.length).init((t=>this.targetColumn?.get(this.idxs?.get(t)))),this.molCol.semType=a.SEMTYPE.MACROMOLECULE,this.tags.forEach((t=>this.molCol.setTag(t,this.targetColumn.getTag(t))));const e=a.DataFrame.fromColumns([this.idxs,this.molCol,this.scores]);await e.meta.detectSemanticTypes(),await r.data.detectSemanticTypes(e),this.molCol.temp["reference-sequence"]=this.targetColumn.get(this.targetMoleculeIdx),this.molCol.temp[".mm.cellRenderer.maxMonomerLength"]=4;let n=null;e.onCurrentRowChanged.subscribe((t=>{n&&clearTimeout(n),(e.currentRowIdx??-1)<0||(this.dataFrame.currentRowIdx=e.col("indexes").get(e.currentRowIdx),n=setTimeout((()=>{this.createPropertyPanel(e)}),300),this.gridSelect=!0)})),this.analysisGrid?(this.analysisGrid.dataFrame=e,this.analysisGrid.invalidate()):(this.analysisGrid=e.plot.grid(),(0,$t.Ku)(this.root,this.analysisGrid.root)),this.analysisGrid.col("indexes").visible=!1,(0,$t.Kd)(this.analysisGrid,this.molCol.name,450,30,!0);const i=this.idxs?.getRawData().findIndex((t=>t==this.targetMoleculeIdx));this.analysisGrid.cell("score",i).cell.value=null;const o=r.shell.tv;this.subInited||(o.grid.root.addEventListener("click",(t=>{this.gridSelect=!1})),this.subInited=!0),this.computeCompleted.next(!0)}}}async computeByMM(){const t=this.targetColumn.length,e=Math.min(this.limit,t-1);if(!this.knn||this.kPrevNeighbors!==e||this.lastDistanceMetric!==this.distanceMetric||this.lastFingerprint!==this.fingerprint||this.lastGapOpen!==this.gapOpen||this.lastGapExtend!==this.gapExtend){const t=this.distanceMetric,n=await de(this.targetColumn,t,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=e,this.knn=await(new B).getKNN(i,t,e,o)}const n=new Array(e).fill(0).map(((t,e)=>({idx:this.knn.knnIndexes[this.targetMoleculeIdx][e],score:1-this.knn.knnDistances[this.targetMoleculeIdx][e]})));n.sort(((t,e)=>e.score-t.score)),n.unshift({idx:this.targetMoleculeIdx,score:a.FLOAT_NULL}),this.idxs=a.Column.int("indexes",e+1).init((t=>n[t].idx)),this.scores=a.Column.float("score",e+1).init((t=>n[t].score))}createPropertyPanel(t){const e=s.div(),n={},i=this.molCol?.name,o=t.col(i),a=this.seqHelper.getSeqHandler(this.targetColumn),l=this.seqHelper.getSeqHandler(o),c=a.getSplitted(this.targetMoleculeIdx),h=l.getSplitted(t.currentRowIdx),u=function(t,e,n={}){const i={...Ae,...n},o=t.length,r=e.length,s=Array(o+1).fill(0).map((()=>Array(r+1).fill(0)));let a=-9999,l=[1,1];for(let n=1;n<o+1;n++)for(let o=1;o<r+1;o++)s[n][o]=Math.max(0,s[n-1][o-1]+(t.getCanonical(n-1)===e.getCanonical(o-1)?i.matchScore:-i.matchScore),s[n-1][o]-i.gapPenalty,s[n][o-1]-i.gapPenalty),s[n][o]>=a&&(a=s[n][o],l=[n,o]);let c=i.localAlignment?l[0]:o,h=i.localAlignment?l[1]:r,u=new Array(0),d=new Array(0);for(;c>0&&h>0;){const n=Math.max(s[c-1][h-1],s[c-1][h],s[c][h-1]);s[c][h]==s[c-1][h-1]+i.matchScore&&n==s[c-1][h-1]?(u.push(t.getCanonical(c-1)),d.push(e.getCanonical(h-1)),c-=1,h-=1):s[c][h]==s[c-1][h]-i.gapPenalty?(d.push(i.gapSymbol),u.push(t.getCanonical(c-1)),c-=1):s[c][h]==s[c][h-1]-i.gapPenalty?(u.push(i.gapSymbol),d.push(e.getCanonical(h-1)),h-=1):(u.push(t.getCanonical(c-1)),d.push(e.getCanonical(h-1)),c-=1,h-=1)}u=[...$().count(0).take(c).map((e=>t.getCanonical(e))),...u.reverse(),...i.localAlignment?$().count(l[0]).take(o).map((e=>t.getCanonical(e))):[]],d=[...$().count(0).take(h).map((t=>e.getCanonical(t))),...d.reverse(),...i.localAlignment?$().count(l[1]).take(r).map((t=>e.getCanonical(t))):[]];const p=c,m=h;return p>m?d=[...new Array(p-m).fill(i.gapSymbol.valueOf()),...d]:u=[...new Array(m-p).fill(i.gapSymbol.valueOf()),...u],d.length>u.length?u.push(...new Array(d.length-u.length).fill(i.gapSymbol.valueOf())):d.push(...new Array(u.length-d.length).fill(i.gapSymbol.valueOf())),{seq1:u.join(""),seq2:d.join(""),seq1Splitted:new Ot.Mu(u,i.gapSymbol),seq2Splitted:new Ot.Mu(d,i.gapSymbol)}}(c,h),d=ye(u.seq1Splitted,u.seq2Splitted,l.defaultBiotype,n);e.append(s.div(d,{style:{width:"300px",overflow:"scroll"}})),c.length!==h.length&&e.append(s.divV([s.divText("Different sequence length:",{style:{fontWeight:"bold"}}),s.divText(`target: ${c.length} monomers`),s.divText(`selected: ${h.length} monomers`)],{style:{paddingBottom:"10px"}})),e.append(be(n));const p=s.accordion(),m=s.element("i");m.className="grok-icon svg-icon svg-view-layout",p.addTitle(s.span([m,s.label("Similarity search")])),p.addPane("Differences",(()=>e),!0),r.shell.o=p.root}}class xe extends Ce{seqHelper;diverseColumnLabel;renderMolIds=null;columnNames=[];computeCompleted=new h.Subject;sampledIndices=null;constructor(t){super("diversity",a.SEMTYPE.MACROMOLECULE),this.seqHelper=t,this.diverseColumnLabel=this.string("diverseColumnLabel",null)}async renderInt(t){if(this.beforeRender()&&this.dataFrame&&t&&this.targetColumn){await this.computeByMM();const t=null!=this.diverseColumnLabel?this.diverseColumnLabel:`diverse (${this.targetColumnName})`,e=a.Column.string(t,this.renderMolIds.length).init((t=>this.targetColumn?.get(this.renderMolIds[t])));e.semType=a.SEMTYPE.MACROMOLECULE,this.tags.forEach((t=>e.setTag(t,this.targetColumn.getTag(t))));const n=a.DataFrame.fromColumns([e]);e.temp[".mm.cellRenderer.maxMonomerLength"]=4,n.onCurrentRowChanged.subscribe((t=>{this.dataFrame.currentRowIdx=this.renderMolIds[n.currentRowIdx]}));const i=n.plot.grid();(0,$t.Kd)(i,e.name,450,30),(0,$t.Ku)(this.root,i.root),this.computeCompleted.next(!0)}}async computeByMM(){const t=this.targetColumn.length;let e;this.requiresSampling&&t>1e4?(e=this.createRandomSample(t,1e4),this.sampledIndices=e):(e=Array.from({length:t},((t,e)=>e)),this.sampledIndices=null);const n=this.distanceMetric,i=await de(this.targetColumn,n,this.fingerprint,this.gapOpen,this.gapExtend),o=i.seqList,r=i.options,s=e.map((t=>o[t])),a=new D(!0,!1),l=await a.calc(s,n,!0,r);a.terminate();const c=e.length,h=(d=c,(t,e)=>d*t+e-Math.floor((t+2)*(t+1)/2)),u=function(t,e){function n(t,e){let n=null,i=null;for(const o of t){const t=e(o);(null==i||t>i)&&(n=o,i=t)}return n}const i=[(r=t-1,Math.floor(function(t){return Math.random()*t}(r)))],o=new Set;var r;for(let e=0;e<t;++e)i.includes(e)||o.add(e);for(;i.length<e;){const t=n(o.values(),(t=>Math.min.apply(Math,i.map((function(e,n){return l[h(t,e)]})))));null!=t&&(i.push(t),o.delete(t))}return i}(c,Math.min(c,this.limit));var d;this.renderMolIds=u.map((t=>e[t]))}createRandomSample(t,e){const n=[];for(let e=0;e<t;e++)this.targetColumn.isNone(e)||n.push(e);if(n.length<=e)return n;for(let t=n.length-1;t>0;t--){const e=Math.floor(Math.random()*(t+1)),i=n[t];n[t]=n[e],n[e]=i}return n.slice(0,e)}}var Ee,Te=n(5433),Me=n(3890),_e=n(1687);!function(t){t.TYPE="V2000",t[t.NUM_OF_HEADER_LINES=3]="NUM_OF_HEADER_LINES",t[t.NUM_OF_COUNTS_DIGITS=3]="NUM_OF_COUNTS_DIGITS",t[t.ATOM_TYPE_COL=4]="ATOM_TYPE_COL",t[t.FIRST_BONDED_ATOM_COL=1]="FIRST_BONDED_ATOM_COL",t[t.BOND_TYPE_COL=3]="BOND_TYPE_COL",t[t.RGP_SHIFT=8]="RGP_SHIFT",t[t.MAX_ATOM_COUNT=999]="MAX_ATOM_COUNT",t.RGP_LINE_START="M RGP",t.ATOM_ALIAS_LINE_START="A ",t.END="M END"}(Ee||(Ee={}));class Ie{constructor(t){this.init(t)}init(t){this.fileContent=t.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 t;return null!==(t=this.xyzAtomCoordinates)&&void 0!==t||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.x}get y(){var t;return null!==(t=this.xyzAtomCoordinates)&&void 0!==t||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.y}get z(){var t;return null!==(t=this.xyzAtomCoordinates)&&void 0!==t||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.z}get atomTypes(){var t;return null!==(t=this._atomTypes)&&void 0!==t||(this._atomTypes=this.parseAtomTypes()),this._atomTypes}get pairsOfBondedAtoms(){var t;return null!==(t=this._pairsOfBondedAtoms)&&void 0!==t||(this._pairsOfBondedAtoms=this.parseBondedAtomPairs()),this._pairsOfBondedAtoms}get bondTypes(){var t;return null!==(t=this._bondTypes)&&void 0!==t||(this._bondTypes=this.parseBondTypes()),this._bondTypes}setAtomAndBondCounts(){const{atomCount:t,bondCount:e}=this.parseAtomAndBondCounts();this._atomCount=t,this._bondCount=e}getNextColumnIdx(t){for(;!this.isWhitespace(t);)++t;for(;this.isWhitespace(t);)++t;return t}shiftIdxToSpecifiedColumn(t,e){let n=t;const i=this.isWhitespace(n)?e:e-1;for(let t=0;t<i;t++)n=this.getNextColumnIdx(n);return n}parseAtomTypes(){const t=this.atomCount,e=new Array(t);let n=this.getAtomBlockIdx();for(let i=0;i<t;i++)n=this.shiftIdxToAtomType(n),e[i]=this.parseAtomType(n),n=this.getNextLineIdx(n);return e}parseAtomCoordinates(){const t=new Float32Array(this.atomCount),e=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 r of[t,e,n])r[o]=this.parseFloatValue(i),i=this.getNextColumnIdx(i);i=this.getNextLineIdx(i)}return{x:t,y:e,z:n}}parseBondedAtomPairs(){const t=new Array(this.bondCount);let e=this.getBondBlockIdx();for(let n=0;n<this.bondCount;n++){e=this.shiftIdxToBondedAtomsPair(e);const i=new Uint16Array(2);i[0]=this.parseIntValue(e),e=this.getNextColumnIdx(e),i[1]=this.parseIntValue(e),t[n]=i,e=this.getNextLineIdx(e)}return t}parseBondTypes(){const t=this.bondCount,e=new Uint16Array(t);let n=this.getBondBlockIdx();for(let i=0;i<t;i++)n=this.shiftIdxToBondType(n),e[i]=this.parseIntValue(n),n=this.getNextLineIdx(n);return e}isWhitespace(t){const e=this.fileContent[t];return" "===e||"\t"===e}getNextLineIdx(t){return"\n"!==this.fileContent[t]?this.fileContent.indexOf("\n",t)+1:t+1}parseFloatValue(t){return this.parseNumericValue(parseFloat,t)}parseIntValue(t){return this.parseNumericValue(parseInt,t)}parseNumericValue(t,e){let n=e+1;for(;!this.isWhitespace(n);)++n;return t(this.fileContent.substring(e,n))}}class Le extends Ie{constructor(t){super(t),this.init(t)}init(t){super.init(t)}parseAtomType(t){let e=t,n=e;return this.isQuote(e)?(n=this.getNextIdenticalChar(e),e++):n=this.fileContent.indexOf(" ",n),this.fileContent.substring(e,n)}isQuote(t){const e=this.fileContent[t].charCodeAt(0);return 39===e||34===e}getNextIdenticalChar(t){const e=this.fileContent[t];return e?this.fileContent.indexOf(e,t+1):-1}isQuery(){return this.isQueryOrFragment(((t,e)=>{return 39===t||34===t||76===t&&!((n=this.fileContent.charCodeAt(e+1))>64&&n<91||n>96&&n<123);var n}))}isFragment(){return this.isQueryOrFragment((t=>82===t||42===t))}isQueryOrFragment(t){const e=this.atomCount;let n=this.getAtomBlockIdx();for(let i=0;i<e;i++){if(n=this.shiftIdxToAtomType(n),t(this.fileContent.charCodeAt(n),n))return!0;n=this.getNextLineIdx(n)}return!1}}class Ne extends Le{constructor(t){super(t)}getAtomLines(){const t=this.getAtomBlockIdx(),e=this.getBondBlockIdx();return this.fileContent.substring(t,e).split("\n").slice(0,this.atomCount)}getBondLines(){const t=this.getBondBlockIdx();return this.fileContent.substring(t).split("\n").slice(0,this.bondCount)}getRGroupIdToAtomicIdxMap(){const t=new Map,e=this.fileContent.split("\n");e.filter((t=>t.startsWith(Ee.RGP_LINE_START))).forEach((e=>{const n=this.getAtomIdxToRgpIdxList(e);for(const[e,i]of n){if(t.has(e))throw new Error(`R group ${e} is already in the map`);t.set(e,i)}}));const n=e.map(((t,e)=>{if(t.startsWith(Ee.ATOM_ALIAS_LINE_START))return e})).filter((t=>void 0!==t)),i=n.map((t=>e[t])),o=n.map((t=>e[t+1]));i.forEach(((e,n)=>{const i=parseInt(e.split(/\s+/)[1])-1,r=parseInt(o[n].substring(1));if(t.has(r))throw new Error(`R group ${r} is already in the map`);t.set(r,i)}));const r=this.getRGroupAtomicIndices().filter((e=>!Array.from(t.values()).includes(e)));if(0!==r.length)throw new Error(`Unaccounted R group indices: ${r}`);return t}getAtomIdxToRgpIdxList(t){const e=t.split(/\s+/).filter((t=>t)).slice(3).map((t=>parseInt(t))),n=new Array(e.length/2);for(let t=0;t<e.length;t+=2)n[t/2]=[e[t+1],e[t]-1];return n}getRGroupAtomicIndices(){return this.atomTypes.map(((t,e)=>{if(t.includes("R#"))return e})).filter((t=>void 0!==t))}static isValidMolfile(t){return-1!==t.indexOf(Ee.TYPE)&&-1!==t.indexOf(Ee.END)}shiftIdxToAtomType(t){return this.shiftIdxToSpecifiedColumn(t,Ee.ATOM_TYPE_COL)}getCountsLineIdx(){let t=0;for(let e=0;e<Ee.NUM_OF_HEADER_LINES;++e)t=this.getNextLineIdx(t);return t}getAtomBlockIdx(){let t=this.getCountsLineIdx();return t=this.getNextLineIdx(t),t}shiftIdxToXColumn(t){return this.getNextColumnIdx(t)}shiftIdxToBondedAtomsPair(t){return this.shiftIdxToSpecifiedColumn(t,Ee.FIRST_BONDED_ATOM_COL)}shiftIdxToBondType(t){return this.shiftIdxToSpecifiedColumn(t,Ee.BOND_TYPE_COL)}getBondBlockIdx(){let t=this.getAtomBlockIdx();for(let e=0;e<this.atomCount;e++)t=this.getNextLineIdx(t);return t}parseAtomAndBondCounts(){let t=this.getCountsLineIdx(),e=t+Ee.NUM_OF_COUNTS_DIGITS;const n=parseInt(this.fileContent.substring(t,e));return t=e,e+=Ee.NUM_OF_COUNTS_DIGITS,{atomCount:n,bondCount:parseInt(this.fileContent.substring(t,e))}}}class Pe extends Le{constructor(t){super(t),this.init(t)}getAtomLines(){const t=this.getAtomBlockIdx(),e=this.getBondBlockIdx();return this.fileContent.substring(t,e).split("\n").slice(0,this.atomCount)}getBondLines(){const t=this.getBondBlockIdx();return this.fileContent.substring(t).split("\n").slice(0,this.bondCount)}getRGroupIdToAtomicIdxMap(){const t=new Map;return this.getAtomLines().forEach(((e,n)=>{const i=e.match(/RGROUPS=\(([\d\s]+)\)/);if(i){const e=i[1].split(/\s+/).map((t=>parseInt(t)));if(e.length>2)throw new Error(`R group data ${e} has more than 2 elements`);const o=e[1];if(t.has(o))throw new Error(`R group ${o} is already in the map`);t.set(o,n)}})),t}shiftIdxToAtomType(t){return this.shiftIdxToSpecifiedColumn(t,4)}getCountsLineIdx(){return this.fileContent.indexOf("M V30 COUNTS ")}getAtomBlockIdx(){let t=this.fileContent.indexOf("M V30 BEGIN ATOM");return t=this.getNextLineIdx(t),t}shiftIdxToXColumn(t){let e=this.shiftIdxToAtomType(t);return this.isQuote(e)?(e=this.getNextIdenticalChar(e),e=this.getNextColumnIdx(e),e):this.shiftIdxToSpecifiedColumn(t,5)}shiftIdxToBondedAtomsPair(t){return this.shiftIdxToSpecifiedColumn(t,5)}shiftIdxToBondType(t){return this.shiftIdxToSpecifiedColumn(t,4)}getBondBlockIdx(){return this.getNextLineIdx(this.fileContent.indexOf("M V30 BEGIN BOND"))}static isValidMolfile(t){return-1!==t.indexOf("V3000")&&-1!==t.indexOf("M END")}parseAtomAndBondCounts(){let t=this.fileContent.indexOf("M V30 COUNTS ")+14,e=this.fileContent.indexOf(" ",t+1);const n=parseInt(this.fileContent.substring(t,e));return t=e+1,e=this.fileContent.indexOf(" ",t+1),{atomCount:n,bondCount:parseInt(this.fileContent.substring(t,e))}}}class $e{constructor(){}static getInstance(t){if($e.isMolfileV2K(t))return new Ne(t);if($e.isMolfileV3K(t))return new Pe(t);throw new Error("Malformed molfile")}static isMolfileV2K(t){return Ne.isValidMolfile(t)}static isMolfileV3K(t){return Pe.isValidMolfile(t)}}var Re=n(6197),ke=n(9124),Oe=n(3527);class He{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(t,e,n="missing",i=void 0,o=void 0,r=void 0,s){if(this.biotype=t,this.id=e,this.n=n,this.m=i,this.type=o,this.mt=r,this.smiles=s,!this.id)throw new Error("Invalid arg undefined [id].")}static objCounter=-1;objId=++He.objCounter;className="WebEditorMonomerDummy";toLog(){return`Helm: ${this.className}<${this.objId}>`}}class Ge extends He{backgroundcolor="#FFFFFF";linecolor="#808080";textcolor="#808080";constructor(t){super(t,"*","gap")}}class Fe extends He{backgroundcolor="#808080";linecolor="#000000";textcolor="#000000";constructor(t,e){super(t,e,"ambiguous")}}class De extends He{backgroundcolor="#FF4444";linecolor="#800000";textcolor="#FFFFFF";constructor(t,e,n){super(t,e,"missing"),n&&(this.backgroundcolor="#C0C0C0",this.linecolor="#404040",this.textcolor="#404040")}}class Be extends He{backgroundcolor="#FFFF44";linecolor="#800000";textcolor="#000000";constructor(t,e){super(t,e,"broken")}}class Ve{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(t,e,n,i,o,r,s,a){this.id=t,this.m=e,this.n=n,this.na=i,this.type=o,this.mt=r,this.at=s,this.smiles=a}static fromMonomer(t,e,n){let i={};const o=e.symbol,r=e.smiles;if(e.rgroups.length>0)e.rgroups.forEach((t=>{i[t.label]=t.capGroupName}));else{if(!r){if(e.lib)return new Be(t,o);throw new Error("Unexpected missing monomer without .lib")}i=n.getRS(r)}const s=new Ve(e.symbol,e.molfile,e.name,e.naturalAnalog,e.polymerType,e.monomerType,i),a=n.getMonomerColors(t,e.symbol);return a&&(s.textcolor=a?.textcolor,s.linecolor=a?.linecolor,s.backgroundcolor=a?.backgroundcolor),s}}const We={[Ft.o.BASE]:{A:"#20E040",G:"#040404",T:"#FF8080",C:"#2060FF",U:"#FF8080"},[Ft.o.NUCLEOTIDE]:{A:"#20E040",G:"#040404",T:"#FF8080",C:"#2060FF",U:"#FF8080"},[Ft.o.LINKER]:{P:"#9aa5e1",p:"#9aa5e1"},[Ft.o.SUGAR]:{R:"#7a85c1",r:"#7a85c1"},[Ft.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)"},[Ft.o.CHEM]:{R:"#eeeeee"},[Ft.o.BLOB]:{B:"#999999",G:"#e2e2e2"}},Ue=/[\w()]+/,je=RegExp(String.raw`\(${Ue}(,${Ue})+\)`),qe=t=>{const e=s.canvas(250,250);return r.chem.canvasMol(0,0,250,250,e,t),e},ze=new Oe.Mi([255,255,255]),Ye=new Oe.Mi([0,0,0]),Ke=.7*(0,K.wQ)(ze);class Ze{_monomers;source;_isEmpty;get isEmpty(){return this._isEmpty}_onChanged=new h.Subject;get onChanged(){return this._onChanged}constructor(t,e){this._monomers=t,this.source=e,this._isEmpty=!this._monomers||0===Object.keys(this._monomers).length||Object.entries(this._monomers).every((([t,e])=>0===Object.keys(e).length));for(const[t,e]of Object.entries(this._monomers))for(const[t,n]of Object.entries(e))n.lib=this}getMonomerSymbolsByType(t){return Object.keys(this._monomers[t])}addMissingMonomer(t,e){let n=this._monomers[t];n||(n=this._monomers[t]={});let i=e;return e==wt._S||e===wt.b9[wt.Hi.HELM]?i="Gap":("PEPTIDE"===t&&"X"===e||"RNA"===t&&"N"===e)&&(i="Any"),n[e]={symbol:e,name:i,molfile:"",author:"MISSING",id:-1,rgroups:$().count(1).take(9).map((t=>({capGroupSmiles:"",alternateId:"",capGroupName:"",label:`R${t.toString()}`}))).toArray(),smiles:"",polymerType:t,monomerType:void 0,createDate:null}}getMonomer(t,e){let n=e;"RNA"==t&&"R"==n&&(n="r"),"RNA"==t&&"P"==n&&(n="p");let i=null;if(t){const e=this._monomers[t];i=e?e[n]:null}else{io.logger.warning(`Bio: MonomerLib.getMonomer() symbol '${e}', polymerType not specified.`);for(const[t,e]of Object.entries(this._monomers))if(i=e[n],i)break}return i}getWebEditorMonomer(t,e){const[n,i]=(0,ke.fA)(t,e),o=(0,Re.Y)(n);let r=this.getMonomer(o,i);if(r&&n==Ft.o.LINKER&&2!=r.rgroups.length)return null;if(r&&n==Ft.o.SUGAR&&3!=r.rgroups.length)return null;r||(r=this.addMissingMonomer(o,i));let s=r.wem??null;return s||(i===wt._S||"*"==i?s=r.wem=new Ge(n):n===Ft.o.NUCLEOTIDE&&"N"===i||n===Ft.o.AA&&"X"===i||(Ft.o.CHEM,0)||je.test(i)?s=r.wem=new Fe(n,i):r.lib||(s=r.wem=new De(n,i,this.isEmpty)),s||(s=r.wem=Ve.fromMonomer(n,r,this))),s}getTooltip(t,e){const n=(0,Re.Y)(t),i=s.div([],{classes:"ui-form ui-tooltip"}),o=this.getWebEditorMonomer(t,e),r=this.getMonomer(n,e);if(r){const t=r.symbol,[e,n,a]=(r.name,o?[o.textcolor,o.backgroundcolor,o.linecolor]:["#202020","#A0A0A0","#202020"]);let l;if(i.append(s.divH([s.div([t],{style:{textWrap:"nowrap",marginLeft:"4px",marginRight:"4px",color:e,backgroundColor:n,borderColor:a,borderWidth:"1px",borderStyle:"solid",borderRadius:"2px",padding:"3px",minWidth:"24px",textAlign:"center"}}),s.div([r.name],{style:{padding:"4px"}})],{style:{display:"flex",flexDirection:"row",justifyContent:"left"}})),l=r.molfile?qe(r.molfile):r.smiles?s.divV([qe(r.smiles),s.divText("from smiles",{style:{fontSize:"smaller"}})]):s.divText("No structure",{style:{margin:"6px"}}),i.append(s.div(l,{style:{display:"flex",flexDirection:"row",justifyContent:"center",margin:"6px"}})),r.symbol!=wt._S){let t=r.lib?.source;t?(t.endsWith(".json")&&(t=t.substring(0,t.length-5)),t=t.replace(/_/g," ").replace(/-/g," ").replace(/([a-z])([a-z])([A-Z])/g,"$1$2 $3"),i.append(s.divText(t))):i.append(s.divText("Missed in libraries"))}}else i.append(s.divV([s.divText(`Monomer '${e}' of type '${n}' not found.`),s.divText("Open the Context Panel, then expand Manage Libraries")]));return i}getMonomerTextColor(t,e){const n=this.getMonomerColors(t,e),i=t=>{const e=/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/.exec(t);if(e)return[parseInt(e[1]),parseInt(e[2]),parseInt(e[3])];const n=a.Color.fromHtml(t);return[a.Color.r(n),a.Color.g(n),a.Color.b(n)]},o=i(n.textcolor),r=new Oe.Mi([...o.map((t=>t+1))]),s=(0,K.KE)(r,ze)/((0,K.wQ)(r)*(0,K.wQ)(ze)),l=i(n.backgroundcolor),c=new Oe.Mi([...l.map((t=>t+.01))]);let h;h=(0,K.KE)(c,ze)/((0,K.wQ)(c)*(0,K.wQ)(ze))<s?l:o;let u=new Oe.Mi(h);const d=(0,K.wQ)(u);return d>Ke&&(u=(0,K.dC)(Ye,u,Ke/d)),`rgb(${u[0]}, ${u[1]}, ${u[2]})`}getMonomerColors(t,e){const n="default";let i=n;const o=(0,Re.Y)(t),r=this.getMonomer(o,e);let s;if(r){if(r.meta&&r.meta.colors){const t=r.meta.colors;n in t||(i="default"),s=t[i]}if(!s){const e=We[t],n=e?.[r.symbol];n&&(s={textColor:a.Color.toHtml(a.Color.getContrastColor(a.Color.fromHtml(n))),lineColor:"#202020",backgroundColor:n})}const e=r.naturalAnalog;if(!s&&e)return this.getMonomerColors(t,e)}return s||(s={textColor:"#202020",lineColor:"#202020",backgroundColor:"#A0A0A0"}),{textcolor:s.text??s.textColor,linecolor:s.line??s.lineColor,backgroundcolor:s.background??s.backgroundColor}}getRS(t){const e=t.match(/(?<=\[)[^\][]*(?=])/gm),n={};let i,o="";if(e)for(let t=0;t<e.length;t++)if(null!=e[t]&&/\d/.test(e[t])){i=e[t][e[t].length-1],e[t]=e[t].replace(/[0-9]/g,"");for(let n=0;n<e[t].length;n++)":"!=e[t][n]&&(o+=e[t][n]);n["R"+i]=o,o=""}return n}}var Xe=n(5488),Je={};Je.styleTagTransform=A(),Je.setAttributes=b(),Je.insert=g().bind(null,"head"),Je.domAPI=m(),Je.insertStyleElement=w(),d()(Xe.A,Je),Xe.A&&Xe.A.locals&&Xe.A.locals;class Qe extends Ze{error;_duplicateMonomers={};get duplicateMonomers(){return this._duplicateMonomers}_duplicatesHandled=!0;get duplicatesHandled(){return this._duplicatesHandled}duplicatesNotified=!1;constructor(t,e,n=void 0){super(t,e),this.error=n}toJSON(){const t=[];for(const e of Object.values(this._monomers))for(const n of Object.values(e))t.push({...n,lib:void 0,wem:void 0});return t}getMonomer(t,e){let n=e;"RNA"==t&&"R"==n&&(n="r"),"RNA"==t&&"P"==n&&(n="p");let i=null;if(t){const e=this._monomers[t];i=e?.[n]??null}else{io.logger.warning(`Bio: MonomerLib.getMonomer() symbol '${e}', polymerType not specified.`);for(const[t,e]of Object.entries(this._monomers))if(i=e[n],i)break}return i}_monomerSets=null;getMonomerSet(t){const e=(0,Re.Y)(t);if(this._monomerSets||(this._monomerSets={}),!(t in this._monomerSets))for(const[t,n]of Object.entries(this._monomers[e]));return this._monomerSets[t]}getPolymerTypes(){return Object.keys(this._monomers)}getMonomerMolsByPolymerType(t){const e={};return Object.keys(this._monomers[t]??{}).forEach((n=>{e[n]=this._monomers[t][n].molfile})),e}getMonomerSymbolsByRGroup(t,e,n){let i=this.getMonomerSymbolsByType(e).map((t=>this.getMonomer(e,t)));return i=i.filter((t=>null!==t)),0===i.length?[]:(i=i.filter((e=>{if(!e?.rgroups)return!1;let n=e?.rgroups.length>=t;var i;return i=$e.getInstance(e.molfile).atomTypes,i.map(((t,e)=>"R#"===t?e:-1)).filter((t=>-1!==t)),n&&=!0,n})),i.map((t=>t?.symbol)))}_updateLibInt(t){const e=t.getPolymerTypes(),n=this.getPolymerTypes();e.forEach((e=>{n.includes(e)||(this._monomers[e]={}),t.getMonomerSymbolsByType(e).forEach((n=>{this._monomers[e][n]&&(this._duplicateMonomers[e]??={},this._duplicateMonomers[e][n]??=[this._monomers[e][n]],this._duplicateMonomers[e][n].push(t.getMonomer(e,n))),this._monomers[e][n]=t.getMonomer(e,n)}))})),this._isEmpty=this.isEmpty&&t.isEmpty}updateLibs(t,e=!1){e&&(this._monomers={},this._isEmpty=!0),this._duplicateMonomers={};for(const e of t)e.error||this._updateLibInt(e);Object.entries(this.duplicateMonomers).length>0?(0,Nt.ub)().then((t=>{this.assignDuplicatePreferences(t)})):this._duplicatesHandled=!0,this._onChanged.next()}assignDuplicatePreferences(t){let e=!0;for(const n in this.duplicateMonomers)for(const i in this.duplicateMonomers[n])if(t.duplicateMonomerPreferences?.[n]?.[i]){const o=t.duplicateMonomerPreferences[n][i],r=this.duplicateMonomers[n][i].find((t=>t.lib?.source===o));r?this._monomers[n][i]=r:e=!1}else e=!1;return this._duplicatesHandled=e,e}clear(){this._monomers={},this._onChanged.next()}getSummaryObj(){const t={},e=this.getPolymerTypes();for(const n of e)t[n]=this.getMonomerSymbolsByType(n).length;return t}getSummaryDf(){const t=this.getPolymerTypes(),e=new Array(t.length);for(const[n,i]of $().enumerate(t))e[i]=this.getMonomerSymbolsByType(n).length;return a.DataFrame.fromColumns([a.Column.fromStrings("polymerType",t),a.Column.fromList(a.COLUMN_TYPE.INT,"count",e)])}getSummary(){const t=this.getPolymerTypes();return 0==t.length?"empty":t.map((t=>`${t} ${this.getMonomerSymbolsByType(t).length}`)).join("\n")}static overrideCounter=0;override(t,e){return new tn(t,`override: ${++Qe.overrideCounter}, ${e}`,this)}}class tn extends Ze{data;base;constructor(t,e,n){super(t,e),this.data=t,this.base=n}get onChanged(){return this.base.onChanged}getMonomerSymbolsByType(t){const e=this.base.getMonomerSymbolsByType(t);for(const n of Object.keys(this.data[t]??{}))e.includes(n)||e.push(n);return e}addMissingMonomer(t,e){return this.base.addMissingMonomer(t,e)}getMonomer(t,e){const n=this.data[t]?.[e];return n??this.base.getMonomer(t,e)}}class en{monomerLib;symbol;polymerType;monomerType;monomerLinks;monomers;error=null;constructor(t,e,n,i,o){this.monomerLib=t,this.symbol=e,this.polymerType=n,this.monomerType=i,this.monomerLinks=o;try{this.monomers=this.monomerLinks.map((t=>{const n=this.monomerLib.getMonomer(this.polymerType,t.symbol);if(!n)throw new Error("Monomer not found: ");if(n.lib?.source!=t.source)throw new Error(`Monomer '${e}' found in different library.`);return n}))}catch(t){const[e,n]=(0,Ct.AP)(t);this.error=e,this.monomers=[]}}}class nn{description;placeholders;source;error;constructor(t,e,n=void 0,i=void 0){this.description=t,this.placeholders=e,this.source=n,this.error=i}updateSets(t,e=!1){e&&(this.placeholders=[]);for(const e of t)e.error||this._updateSetInt(e)}_updateSetInt(t){for(const e of t.placeholders)this.placeholders.push(e)}}var on=n(7433),rn=n.n(on),sn=n(1913),an=n.n(sn);class ln{helmMonomerSchema;validateMonomerSchema;constructor(t){this.helmMonomerSchema=t;const e=new(rn())({allErrors:!0,strictTuples:!1,allowUnionTypes:!0});an()(e),this.validateMonomerSchema=e.compile(this.helmMonomerSchema)}validateFile(t,e){const n=this.parseJson(t,e);return null!==n&&(Array.isArray(n)?this.validateJsonContent(n,e):(console.warn(`Bio: Monomer Library File Validator file '${e}': Invalid JSON format: The file must contain an array of monomers.`),!1))}parseJson(t,e){try{return JSON.parse(t)}catch(t){return console.error(`Bio: Monomer Library File Validator file '${e}': Invalid JSON format:`,t),null}}validateJsonContent(t,e){let n=!0;const i=new Set;for(const o of t){const t=o.symbol??o.id??o.name??"#N/A";if(n=this.validateMonomerSchema(o),!n){console.warn(`Bio: Monomer Library File Validator file ${e}, monomer '${t}' violating JSON schema:`,o,"\nError reason: ",JSON.stringify(this.validateMonomerSchema.errors??{}),`\nThere may be other errors in ${e} since the validation is stopped after the first error.`," Please, verify that the monomer library file satisfies the JSON schema");break}const r=`${o.polymerType??""}-${t}`;i.has(r)&&console.warn(`Bio: Monomer Library File Validator file ${e}, monomer '${t}' is duplicated.`,"Please, verify that the monomer library file does not contain duplicated monomer symbols."),i.add(r)}return n}}var cn=n(8604);class hn{fileValidator;libHelper;eventManager;logger;filesPromise=Promise.resolve();initializedPromise=Promise.resolve();constructor(t,e,n,i){let o;this.fileValidator=t,this.libHelper=e,this.eventManager=n,this.logger=i;let r=!1;this.initializedPromise=Promise.race([a.delay(1e3),new Promise((t=>o=t))]),this.eventManager.updateValidLibraryFileListRequested$.subscribe((()=>{this.updateValidLibList().then((()=>{})),r||(r=!0,o())})),this.eventManager.updateValidSetFileListRequested$.subscribe((()=>{this.updateValidSetList().then((()=>{}))}))}static objCounter=-1;objId=++hn.objCounter;toLog(){return`MonomerLibFileManager<${this.objId}>`}static async create(t,e,n){const i=await r.dapi.files.readAsText(cn.gt),o=JSON.parse(i),s=new ln(o);return new hn(s,t,e,n)}async addLibraryFile(t,e,n=!0){try{if(await r.dapi.files.exists(cn.so+`${e}`))return void r.shell.error(`File ${e} already exists`);await this.validateAgainstHELM(t,e),await r.dapi.files.writeAsText(cn.so+`${e}`,t),await this.updateValidLibList(),await r.dapi.files.exists(cn.so+`${e}`)?r.shell.info(`Added ${e} HELM library`):r.shell.error(`Failed to add ${e} library`)}catch(t){console.error(t),r.shell.error(`Failed to add ${e} library`)}}async deleteLibraryFile(t){try{await r.dapi.files.delete(cn.so+`${t}`),await this.updateValidLibList(),r.shell.info(`Deleted ${t} library`)}catch(e){console.error(e),await r.dapi.files.exists(cn.so+`${t}`)?r.shell.error(`Failed to delete ${t} library`):r.shell.warning(`File ${t} already deleted, refresh the list`)}}async loadLibraryFromFile(t,e){let n=[];const i=new a.FileSource(t),o=await i.readAsText(e);n=JSON.parse(o);const r={},s=[];return n.forEach((t=>{const e=t.polymerType,n=t.symbol;s.includes(e)||(r[e]={},s.push(e)),r[e][n]=t})),new Qe(r,e)}async loadSetFromFile(t,e,n){let i={};const o=new a.FileSource(e),r=await o.readAsText(n);i=JSON.parse(r);const s=i.description,l=Object.entries(i.placeholders).map((([e,n])=>{const i=e,o=n.polymerType,r=n.monomerType,s=n.set;return new en(t,i,o,r,s)}));return new nn(s,l)}getValidLibraryPaths(){return this.eventManager.getValidLibPathList()}getValidSetPaths(){return this.eventManager.getValidSetPathList()}async getValidLibraryPathsAsynchronously(){return await this.eventManager.getValidLibraryPathsAsynchronously()}async updateValidLibList(){const t=`${this.toLog()}.updateValidLibList()`;return this.logger.debug(`${t}, start`),this.filesPromise=this.filesPromise.then((async()=>{this.logger.debug(`${t}, IN`);const e=[],n=await this.getLibFileListAtLocation();if(!this.libListHasChanged(n))return void this.logger.debug(`${t}, end, not changed`);for(const t of n){if(!t.endsWith(".json")){e.push(t);continue}const n=await r.dapi.files.readAsText(cn.so+`${t}`);this.isValidHELMLibrary(n,t)||e.push(t)}const i=n.filter((t=>!e.includes(t)));if(this.libListHasChanged(i)&&(this.eventManager.changeValidLibPathList(i),await this.libHelper.loadMonomerLib(!0)),i.some((t=>!t.endsWith(".json")))&&this.logger.warning(`Wrong validation: ${i}`),e.length>0){const t=`Invalid monomer library files in ${cn.so}, consider fixing or removing them: ${e.join(", ")}`;this.logger.warning(t)}this.logger.debug(`${t}, OUT`)})),this.logger.debug(`${t}, end`),this.filesPromise}async updateValidSetList(){const t=`${this.toLog()}.updateValidSetList()`;return io.logger.debug(`${t}, start`),this.filesPromise=this.filesPromise.then((async()=>{io.logger.debug(`${t}, IN`);const e=[],n=await this.getSetFileListAtLocation();if(!this.setListHasChanged(n))return void io.logger.debug(`${t}, end, not changed`);for(const t of n)t.endsWith(".json")?await r.dapi.files.readAsText(cn.Es+`${t}`):e.push(t);const i=n.filter((t=>!e.includes(t)));this.setListHasChanged(i)&&(this.eventManager.changeValidSetPathList(i),this.libHelper.loadMonomerSets(!0)),io.logger.debug(`${t}, OUT`)})),io.logger.debug(`${t}, end`),this.filesPromise}libListHasChanged(t){const e=this.eventManager.getValidLibPathList();return t.length!==e.length||t.some(((t,n)=>t!==e[n]))}setListHasChanged(t){const e=this.eventManager.getValidSetPathList();return t.length!==e.length||t.some(((t,n)=>t!==e[n]))}async validateAgainstHELM(t,e){if(!this.isValidHELMLibrary(t,e))throw new Error(`File ${e} does not satisfy HELM standard`)}isValidHELMLibrary(t,e){return this.fileValidator.validateFile(t,e)}async getLibFileListAtLocation(){const t=`${this.toLog()}.getLibFileListAtLocation()`;this.logger.debug(`${t}, start`);const e=await r.dapi.files.list(cn.so).then((t=>t.filter((t=>t.isFile)).map((t=>t.fullPath)))),n=[];return n.push(...e),n.map((t=>t.substring(cn.so.length)))}async getSetFileListAtLocation(){const t=`${this.toLog()}.getSetFileListAtLocation()`;this.logger.debug(`${t}, start`);const e=await r.dapi.files.list(cn.Es).then((t=>t.map((t=>t.fullPath)))),n=[];return n.push(...e),n.map((t=>t.substring(cn.Es.length)))}}class un{constructor(){}static _instance;static getInstance(){return un._instance||(un._instance=new un),un._instance}_libFilesUpdateSubject$=new h.BehaviorSubject([]);_setFilesUpdateSubject$=new h.BehaviorSubject([]);_addLibraryFilesSubject$=new h.Subject;_librarySelectionSubject$=new h.Subject;getValidLibPathList(){return this._libFilesUpdateSubject$.getValue()}getValidSetPathList(){return this._setFilesUpdateSubject$.getValue()}async getValidLibraryPathsAsynchronously(){return new Promise((t=>{const e=this._libFilesUpdateSubject$.pipe((0,O.skip)(1)).subscribe((n=>{t(n),e.unsubscribe()}))}))}changeValidLibPathList(t){this._libFilesUpdateSubject$.next(t)}changeValidSetPathList(t){this._setFilesUpdateSubject$.next(t)}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(t,e){this._librarySelectionSubject$.next([t,e])}}class dn{logger;_monomerLib=new Qe({},"MAIN");_monomerSets=new nn("MAIN",[]);_initialLoadCompleted=!1;get initialLoadCompleted(){return this._initialLoadCompleted}_eventManager;get eventManager(){return this._eventManager}async awaitLoaded(t=1/0){return t=t===1/0?6e4:t,await Promise.race([(async()=>{const t=await this.getFileManager();return await t.filesPromise,!0})(),(async()=>(await(0,te.cb)(t),!1))()]).then((e=>{if(!e)throw new Error(`Loading monomer libraries timeout ${t} ms.`)}))}constructor(t){this.logger=t}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(t){this._monomerLib.assignDuplicatePreferences(t)}_fileManagerPromise;async getFileManager(){return void 0===this._fileManagerPromise&&(this._fileManagerPromise=(async()=>{const t=await hn.create(this,this._eventManager,this.logger);return await t.initializedPromise,t})()),this._fileManagerPromise}loadLibrariesPromise=Promise.resolve();async loadMonomerLib(t=!1){const e=`${this.toLog()}.loadMonomerLib()`;return this.logger.debug(`${e}, start`),this.loadLibrariesPromise=this.loadLibrariesPromise.then((async()=>{this.logger.debug(`${e}, IN`);const n=a.TaskBarProgressIndicator.create("Loading monomers ...");try{const[[e],i]=await Promise.all([await this.getFileManager().then((t=>[t.getValidLibraryPaths()])),(0,Nt.ub)()]),o=e.filter((t=>{const e=!i.exclude.includes(t),n=0===i.explicit.length||i.explicit.includes(t);return e&&n}));let r=0;const s=o.length,[a]=await Promise.all([Promise.all(o.map((t=>this.readLibrary(cn.so,t).catch((e=>{const n=`Loading monomers from '${t}' error: ${e instanceof Error?e.message:e.toString()}`;return new Qe({},t,n)})).finally((()=>{n.update(Math.round(100*++r/s),`Loading monomers ${r}/${s}`)})))))]);this._monomerLib.updateLibs(a,t),this._initialLoadCompleted=!0}catch(t){const e=`Loading monomer libraries error: ${t instanceof Error?t.message:t.toString()}`;r.shell.warning(e);const n=t instanceof Error?t.stack:void 0;this.logger.error(e,void 0,n)}finally{n.close(),this.logger.debug(`${e}, OUT`)}})),this.logger.debug(`${e}, end`),this.loadLibrariesPromise}async loadLibraries(t){return this.loadMonomerLib(t)}loadSetsPromise=Promise.resolve();async loadMonomerSets(t=!1){const e=`${this.toLog()}.loadMonomerSets()`;return this.logger.debug(`${e}, start`),this.loadSetsPromise=this.loadSetsPromise.then((async()=>{this.logger.debug(`${e}, IN`);const t=a.TaskBarProgressIndicator.create("Loading monomer sets ...");try{const[[e]]=await Promise.all([await this.getFileManager().then((t=>[t.getValidSetPaths()]))]),n=e.filter((t=>!0));let i=0;const o=n.length,[r]=await Promise.all([Promise.all(n.map((e=>this.readSet(cn.Es,e).catch((t=>{const n=`Loading monomer sets from '${e}' error: ${t instanceof Error?t.message:t.toString()}`;return new nn("Broken monomer set",[],e,n)})).finally((()=>{t.update(Math.round(100*++i/o),`Loading monomers ${i}/${o}`)})))))]);this._monomerSets.updateSets(r)}catch(t){const e=`Loading monomer sets error: ${t instanceof Error?t.message:t.toString()}`;r.shell.warning(e);const n=t instanceof Error?t.stack:void 0;this.logger.error(e,void 0,n)}finally{t.close(),this.logger.debug(`${e}, OUT`)}})),this.logger.debug(`${e}, end`),this.loadSetsPromise}async readLibrary(t,e){const n=await this.getFileManager();return await n.loadLibraryFromFile(t,e)}async readSet(t,e){const n=await this.getFileManager();return await n.loadSetFromFile(this._monomerLib,t,e)}async selectSpecifiedLibraries(t){const e=await this.getInvalidFileNames(t);if(e.length>0)throw new Error(`Cannot select libraries ${e}: no such library in the list`);const n=await(0,Nt.ub)();n.exclude=(await this.getFileManager()).getValidLibraryPaths().filter((e=>!t.includes(e))),await(0,Nt.Eu)(n)}async getInvalidFileNames(t){const e=(await this.getFileManager()).getValidLibraryPaths();return t.filter((t=>!e.includes(t)))}async loadMonomerLibForTests(){await(0,Nt.Eu)(cn.G3),await this.awaitLoaded(1e4),await this.loadMonomerLib(!0)}static async getInstance(){let t=window.$monomerLibHelperPromise;return null==t&&(t=window.$monomerLibHelperPromise=(async()=>{const t=new dn(io.logger);return t._eventManager=un.getInstance(),t})()),t}}var pn=n(1757),mn=n.n(pn),fn=n(3017),gn={};gn.styleTagTransform=A(),gn.setAttributes=b(),gn.insert=g().bind(null,"head"),gn.domAPI=m(),gn.insertStyleElement=w(),d()(fn.A,gn),fn.A&&fn.A.locals&&fn.A.locals;var yn=n(3151);class bn{constructor(t,e=[],n={}){this.onItemChanged=new h.Subject,this.onAddingItemChanged=new h.Subject,this.onItemAdded=new h.Subject,this.onItemRemoved=new h.Subject,this.options={removeButtonTooltip:"Remove item",addButtonTooltip:"Add item",allowAdd:!0,allowRemove:!0},this.addingItemInputs={},this.properties=t,this.options=Object.assign(Object.assign({},this.options),n),this._root=s.divV([],{style:{display:"grid",gridTemplateColumns:`repeat(${this.properties.length}, 1fr)`,alignItems:"center",gap:"12px"},classes:"ui-items-grid"}),this._items=e,this.render()}get root(){return this._root}get items(){return this._items}set items(t){this._items=t,this.render()}addItem(t,e=!0){this._items.push(t),this.render(),e&&this.onItemAdded.next(t)}removeItem(t,e=!0){-1!==this._items.indexOf(t)&&(this._items.splice(this._items.indexOf(t),1),this.render(),e&&this.onItemRemoved.next(t))}removeAtIndex(t,e=!0){if(t<0||t>=this._items.length)return;const n=this._items.splice(t,1);this.render(),e&&this.onItemRemoved.next(n[0])}removeAllItems(){this._items=[],this.render()}render(){var t,e,n,i,o;if(s.empty(this._root),!this.options.horizontalInputNames)for(const n of this.properties){let i=null!==(t=n.caption)&&void 0!==t?t:n.name;(null===(e=this.options.customLabels)||void 0===e?void 0:e[n.name])&&(i=this.options.customLabels[n.name]);const o=s.divText(i);o.style.fontWeight="bold",this._root.appendChild(o)}for(const t of this._items){const e=this.getItemDiv(t);for(const t of e)this._root.appendChild(t)}if(this.options.allowAdd){const t=this.getItemDiv(null!==(o=null===(i=(n=this.options).newItemFunction)||void 0===i?void 0:i.call(n))&&void 0!==o?o:void 0,!0);for(const e of t)this._root.appendChild(e)}}get addingItem(){const t={};return Object.keys(this.addingItemInputs).forEach((e=>{t[e]=this.addingItemInputs[e].value})),t}getItemDiv(t={},e){var n,i;const o=[],r={};let l=null;for(const c of this.properties){void 0===t[c.name]&&(t[c.name]=null);const h=(null===(n=this.options.customInputs)||void 0===n?void 0:n[c.name])?this.options.customInputs[c.name](t):s.input.forProperty(c,t),u=null===(i=this.options.validators)||void 0===i?void 0:i[c.name];u&&h.addValidator(u),o.push(this.options.horizontalInputNames?h.root:this.hideLabel(h.root)),c.propertyType!==a.TYPE.BOOL&&"color"!==c.name.toLowerCase()&&h.input&&(h.input.style.width="100%"),r[c.name]=h,h.onChanged.subscribe((()=>{t[c.name]=h.value,e?this.onAddingItemChanged.next({item:t,fieldName:c.name}):this.onItemChanged.next({item:t,fieldName:c.name})})),h.root.style.alignItems="center",l=h}let c=null;if(e)this.addingItemInputs=r,c=s.icons.add((()=>{const t=this.options.newItemFunction?this.options.newItemFunction():{};Object.keys(r).forEach((e=>{t[e]=r[e].value})),this._items.push(t),this.onItemAdded.next(t),this.render()}),this.options.addButtonTooltip);else{if(!this.options.allowRemove)return o;c=s.icons.delete((()=>{this._items.splice(this._items.indexOf(t),1),this.onItemRemoved.next(t),this.render()}),this.options.removeButtonTooltip)}return l&&l.addOptions?l.addOptions(c):null==l||l.root.appendChild(c),c.style.color="#2083d5",o}hideLabel(t){return t.getElementsByTagName("label")[0]&&t.removeChild(t.getElementsByTagName("label")[0]),t}hasErrors(){return this._root.querySelectorAll(".d4-invalid").length>0}}const vn={A:new U.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 U.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 U.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 U.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 U.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 U.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 U.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 U.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 U.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 U.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 U.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 U.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 U.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 U.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 U.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 U.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 U.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 U.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 U.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 U.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)},wn={RNA:{A:new U.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 U.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 U.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 U.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 U.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:vn};async function Cn(t,e,n=0){if(!Object.keys(wn).includes(e))return null;const i=await async function(t){const e=a.Func.find({package:"Chem",name:"getMorganFingerprint"})?.[0];if(!e)return null;try{const n=(await e.apply({molString:t}))?.getBuffer().buffer;if(n)return new U.A(new Uint32Array(n),2048)}catch(t){return null}}(t);if(!i)return null;if(!wn[e])return null;const o=wn[e];let r=0,s=null;for(const[t,e]of Object.entries(o)){const o=(0,H.$1)(i,e);o>r&&o>=n&&(r=o,s=t)}return s}var An,Sn=n(857),xn={};xn.styleTagTransform=A(),xn.setAttributes=b(),xn.insert=g().bind(null,"head"),xn.domAPI=m(),xn.insertStyleElement=w(),d()(Sn.A,xn),Sn.A&&Sn.A.locals&&Sn.A.locals,function(t){t.MONOMER="Monomer",t.SYMBOL="Symbol",t.NAME="Name",t.R_GROUPS="~R-Groups",t.MONOMER_TYPE="Monomer Type",t.POLYMER_TYPE="Polymer Type",t.NATURAL_ANALOG="Natural Analog",t.AUTHOR="Author",t.CREATE_DATE="Create Date",t.ID="ID",t.META="Meta",t.SOURCE="Source"}(An||(An={}));const En={[An.MONOMER]:a.COLUMN_TYPE.STRING,[An.SYMBOL]:a.COLUMN_TYPE.STRING,[An.NAME]:a.COLUMN_TYPE.STRING,[An.R_GROUPS]:a.COLUMN_TYPE.STRING,[An.MONOMER_TYPE]:a.COLUMN_TYPE.STRING,[An.POLYMER_TYPE]:a.COLUMN_TYPE.STRING,[An.NATURAL_ANALOG]:a.COLUMN_TYPE.STRING,[An.AUTHOR]:a.COLUMN_TYPE.STRING,[An.CREATE_DATE]:a.COLUMN_TYPE.DATE_TIME,[An.ID]:a.COLUMN_TYPE.INT,[An.META]:a.COLUMN_TYPE.STRING,[An.SOURCE]:a.COLUMN_TYPE.STRING};class Tn{monomerLibManamger;adjustTable(){this.tv?.dataFrame&&(r.data.detectSemanticTypes(this.tv.dataFrame),this.tv.dataFrame.meta.detectSemanticTypes()),setTimeout((()=>{this.tv?.grid&&(this.tv.grid.props.allowEdit=!1,this.tv.grid.col(An.NAME).width=100,this.tv.grid.col(An.SYMBOL).width=70)}),200)}static VIEW_NAME="Manage Monomers";_newMonomer=yn.pe;_newMonomerForm;monomerLib;tv=null;libInput;static instance;activeMonomerLib=null;constructor(t){this.monomerLibManamger=t,this.monomerLib=t.getBioLib(),this._newMonomerForm=new Nn(t,(()=>this.activeMonomerLib),(async t=>{const e=await this.getMonomersDf(this.libInput.value);this.tv?.dataFrame&&(this.tv.dataFrame=e,this.adjustTable(),null!=t&&setTimeout((()=>{const n=e.col(An.SYMBOL).toList().indexOf(t);-1!==n&&(this.tv?.grid.scrollToCell(e.columns.byIndex(0),n),e.currentRow=e.rows.get(n))}),500))}),(()=>this.tv?.dataFrame))}static async getInstance(){if(!this.instance){const t=await dn.getInstance();await t.awaitLoaded(),await t.loadLibrariesPromise,this.instance=new Tn(t)}return this.instance}static async getNewInstance(){const t=await dn.getInstance();return await t.awaitLoaded(),await t.loadLibrariesPromise,new Tn(t)}async createNewMonomerLib(t,e){this.tv?.grid&&s.setUpdateIndicator(this.tv.grid.root,!0);try{const n=JSON.stringify(e.map((t=>({...t,lib:void 0,wem:void 0}))),null,2);t.endsWith(".json")||(t+=".json"),await(await this.monomerLibManamger.getFileManager()).addLibraryFile(n,t),await r.dapi.files.writeAsText(cn.so+t,n),await this.monomerLibManamger.loadLibraries(!1),r.shell.v=await this.getViewRoot(t)}catch(t){r.shell.error("Error creating library"),console.error(t)}finally{this.tv?.grid&&s.setUpdateIndicator(this.tv.grid.root,!1)}}async createNewLibDialog(t){const e=(await this.monomerLibManamger.getFileManager()).getValidLibraryPaths(),n=s.input.string("Library Name",{placeholder:"Enter library name",nullable:!1,onValueChanged:()=>{const t=i(n.value);o.getButton("Create")?.classList?.toggle("d4-disabled",!!t)}});function i(t){return t&&t.trim()?t.endsWith(".json")&&e.includes(t)||e.includes(t+".json")?"Library with this name already exists":null:"Library name cannot be empty"}n.addValidator(i);const o=s.dialog("Create New Library").add(n).addButton("Create",(async()=>{const e=i(n.value);if(e)r.shell.warning(e);else{try{await this.createNewMonomerLib(function(){let t=n.value;return t.endsWith(".json")||(t+=".json"),t}(),t??[])}catch(t){r.shell.error("Error creating library"),console.error(t)}o.close()}})).show();o.getButton("Create")?.classList?.toggle("d4-disabled",!0)}get newMonomer(){return this._newMonomer}getNewMonomerForm(){return this._newMonomerForm}async getMonomersTableView(t,e=!0){const n=await this.getMonomersDf(t);return this.tv=a.TableView.create(n,e),this.adjustTable(),this.tv.subs.push(r.events.onContextMenu.subscribe((({args:t})=>{if(!t||!t.menu||!t.context||t.context.type!==a.VIEWER.GRID||!t.context.tableView||t.context.tableView.id!==(this.tv.id??"")||!t.item||!t.item.isTableCell||(t.item.tableRowIndex??-1)<0)return;const e=t.item.tableRowIndex;t.menu.item("Edit Monomer",(async()=>{await this.editMonomer(this.tv.dataFrame.rows.get(e))})),t.menu.item("Fix all monomers",(()=>{this.fixAllMonomers()})),this.tv.dataFrame.selection.trueCount>0?(t.menu.item("Remove Selected Monomers",(async()=>{const t=await Promise.all(Array.from(this.tv.dataFrame.selection.getSelectedIndexes()).map((t=>On(this.tv.dataFrame.rows.get(t)))));this._newMonomerForm.removeMonomers(t,this.libInput.value)})),t.menu.item("Selection To New Library",(async()=>{const t=await Promise.all(Array.from(this.tv.dataFrame.selection.getSelectedIndexes()).map((t=>On(this.tv.dataFrame.rows.get(t)))));this.createNewLibDialog(t)}))):t.menu.item("Remove Monomer",(async()=>{const t=await On(this.tv.dataFrame.rows.get(e));this._newMonomerForm.removeMonomers([t],this.libInput.value)}))}))),this.tv.grid&&(this.tv.grid.props.allowEdit=!1),this.tv}static closeAllMonomerManagers(){Array.from(r.shell.tableViews??[]).filter((t=>t.name===Tn.VIEW_NAME)).forEach((t=>t.close()))}findActiveManagerView(){if(!this.tv)return null;const t=Array.from(r.shell.tableViews??[]).find((t=>t.id===this.tv.id));return t?r.shell.v=t:Tn.closeAllMonomerManagers(),t??null}_skipLibInputOnchange=!1;async getViewRoot(t,e=!0){const n=(await this.monomerLibManamger.getFileManager()).getValidLibraryPaths();if(this._newMonomerForm.molSketcher.resize(),e&&(this.tv=this.findActiveManagerView())&&(t??this.libInput.value)){try{this._skipLibInputOnchange=!0,this.libInput&&(this.libInput.items=n),t&&(this.libInput.value=t)}catch(t){r.shell.error("Error updating library list"),console.error(t)}finally{this._skipLibInputOnchange=!1}const e=await this.getMonomersDf(t);return this.tv.dataFrame=e,this.adjustTable(),this.tv}t??=n[0],this.tv=await this.getMonomersTableView(t,e);let i=this.tv.getRibbonPanels();i.forEach(((t,e)=>{i[e]=t.filter((t=>0!==t.getElementsByClassName("grok-icon-filter").length))})),i=i.filter((t=>t.length>0));const o=s.icons.add((()=>{this._newMonomerForm.setEmptyMonomer()}),"Add New Monomer"),l=s.iconFA("wand-magic",(()=>{this.fixAllMonomers()}),"Fix all monomers"),c=s.icons.edit((async()=>{(this.tv?.dataFrame?.currentRowIdx??-1)<0||await this.editMonomer(this.tv.dataFrame.rows.get(this.tv.dataFrame.currentRowIdx))}),"Edit Monomer"),h=s.icons.delete((async()=>{const t=this.tv?.dataFrame?.currentRowIdx??-1,e=Array.from(this.tv?.dataFrame?.selection?.getSelectedIndexes()??[]);if(t<0&&0===e.length)return;if(e.length>0){const t=await Promise.all(e.map((t=>On(this.tv.dataFrame.rows.get(t)))));return void await this._newMonomerForm.removeMonomers(t,this.libInput.value)}const n=await On(this.tv.dataFrame.rows.get(t));await this._newMonomerForm.removeMonomers([n],this.libInput.value)}));s.tooltip.bind(h,(()=>(this.tv?.dataFrame?.selection?.trueCount??0)>0?"Delete selected monomers":"Delete monomer"));const u=s.iconFA("arrow-to-bottom",(async()=>{const t=this.libInput.value;if(!t)return r.shell.error("No library selected");let e=null;try{e=await r.dapi.files.readAsText(cn.so+t)}catch(e){return r.shell.error(`Error reading library ${t}`),console.error(e)}if(!e)return r.shell.error(`Library ${t} is empty`);a.Utils.download(t,e,"text/plain")}),"Download Monomer Library");i.push([o,c,l,h,u]),this.tv.setRibbonPanels(i),this.tv.name=Tn.VIEW_NAME,this.libInput=s.input.choice("Monomer Library",{value:t,items:n,nullable:!1,onValueChanged:async()=>{try{if(this._skipLibInputOnchange)return;const t=await this.getMonomersDf(this.libInput.value);this.tv.dataFrame=t,this.adjustTable()}catch(t){console.error(t)}}}),this.libInput.addOptions(s.icons.add((()=>{this.createNewLibDialog()}),"Create new monomer library..."));const d=this._newMonomerForm.form;return d.prepend(this.libInput.root),s.tools.waitForElementInDom(this.tv.root).then((()=>{this.tv.dockManager.dock(d,a.DOCK_TYPE.LEFT,null,void 0,.4)})),this.tv}async editMonomer(t){return this._newMonomer=await On(t),this._newMonomerForm.setMonomer(this._newMonomer),this._newMonomer}async getMonomersDf(t){this.tv?.grid&&s.setUpdateIndicator(this.tv.grid.root,!0);try{if(t??=(await this.monomerLibManamger.getFileManager()).getValidLibraryPaths()[0],this.activeMonomerLib=await this.monomerLibManamger.readLibrary(cn.so,t),!this.activeMonomerLib)return r.shell.error(`Library ${t} not found`),a.DataFrame.create();const e=this.activeMonomerLib.getPolymerTypes().flatMap((t=>this.activeMonomerLib.getMonomerSymbolsByType(t).map((e=>this.activeMonomerLib.getMonomer(t,e))))),n=a.DataFrame.create(e.length),i=new Set;for(const t of e)t.rgroups.forEach((t=>{t.label&&i.add(t.label)}));const o=Array.from(i);o.sort();for(const[t,e]of Object.entries(En))if(n.columns.addNew(t,e),t===An.R_GROUPS)for(const t of o)n.columns.addNew(t,a.COLUMN_TYPE.STRING);n.col(An.SYMBOL).semType="Monomer",n.col(An.SYMBOL).setTag(Rt.Mn.applyToBackground,"true");for(let t=0;t<e.length;t++){let i=$n(e[t].rgroups,e[t].smiles,e[t].molfile);i=Mn(i),e[t].rgroups=Ln(e[t].rgroups);const r=o.map((n=>{const i=e[t].rgroups.find((t=>t.label===n));return i?In(i,"capGroupSmiles"):""}));let s=null;if(e[t].createDate)try{s=Date.parse(e[t].createDate)}catch(n){console.error(`Error parsing date ${e[t].createDate}`)}n.rows.setValues(t,[i,e[t].symbol,e[t].name,JSON.stringify(e[t].rgroups??[]),...r,e[t].monomerType,e[t].polymerType,e[t].naturalAnalog,e[t].author,s,e[t].id,JSON.stringify(e[t].meta??{}),e[t].lib?.source??""]);try{s&&n.col(An.CREATE_DATE)?.set(t,s,!1)}catch(n){console.error(`Error setting date ${e[t].createDate}`)}}return n.col(An.MONOMER).semType=a.SEMTYPE.MOLECULE,o.forEach((t=>{n.col(t).semType=a.SEMTYPE.MOLECULE})),n.currentRowIdx=-1,n.onCurrentRowChanged.subscribe((async t=>{try{if(-1===n.currentRowIdx||this._newMonomerForm.molChanged)return;await this.editMonomer(n.rows.get(n.currentRowIdx))}catch(t){console.error(t)}})),n}catch(t){throw r.shell.error("Error creating monomers dataframe"),console.error(t),t}finally{this.tv?.grid&&s.setUpdateIndicator(this.tv.grid.root,!1)}}async fixAllMonomers(){s.dialog("Fix All Monomers").add(s.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(s.divText("Do you wish to continue?")).onOK((async()=>{const t=this.tv?.dataFrame;let e=this.libInput.value;if(t&&e){this.tv?.grid&&s.setUpdateIndicator(this.tv.grid.root,!0);try{const n=await Promise.all(new Array(t.rowCount).fill(0).map(((e,n)=>On(t.rows.get(n))))),i=JSON.stringify(n.map((t=>({...t,lib:void 0,wem:void 0}))),null,2);e.endsWith(".json")||(e+=".json"),await r.dapi.files.writeAsText(cn.so+e,i),await this.monomerLibManamger.loadLibraries(!0),r.shell.v=await this.getViewRoot(e)}catch(t){r.shell.error("Error saving library"),console.error(t)}finally{this.tv?.grid&&s.setUpdateIndicator(this.tv.grid.root,!1)}}else r.shell.error("No monomer library loaded")})).show()}resetCurrentRowFollowing(){this._newMonomerForm.molChanged=!1}}function Mn(t){let e=t.replaceAll(/\[R[1-9]\]/g,(t=>`[*:${t[2]}]`));return e=e.replaceAll(/\[\d\*\]/g,(t=>`[*:${t[1]}]`)),e.replaceAll(/\[\d\*\:\d\]/g,(t=>`[*:${t[1]}]`))}const _n=["alternateId","capGroupName","capGroupSMILES","label"];function In(t,e){const n=Object.keys(t).find((t=>t.toLowerCase()===e.toLowerCase()));if(n)return t[n]}function Ln(t){return t.map((t=>{const e=function(t,e){const n={};return t.forEach((t=>{const i=Object.keys(e).find((e=>e.toLowerCase()===t.toLowerCase()));i&&(n[t]=e[i])})),n}(_n,t),n=In(e,"capGroupSMILES"),i=In(e,"alternateId"),o=In(e,"capGroupName"),r=In(e,"label")??"R1";if(n&&i&&o||r.length<2)return e;if(i&&-1!==i.indexOf(`${r}-`)){const t=i.replace(`${r}-`,"");o||(e.capGroupName=t),n||(e.capGroupSMILES=`[*:${r.substring(1)}][${t}]`)}else o&&(n||(e.capGroupSMILES=`[*:${r.substring(1)}][${o}]`),i||(e.alternateId=`${r}-${o}`));return e})).sort(((t,e)=>t.label?.localeCompare(e.label??"")??0))}class Nn{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(t){this._molChanged=t}saveValidationResult=null;triggerMolChange=!0;inputsTabControl;constructor(t,e,n,i){this.monomerLibManager=t,this.getMonomerLib=e,this.refreshTable=n,this.getMonomersDataFrame=i,this.colors={line:"#000000",background:"#000000",text:"#000000"},this.colorsEditor=new Hn(this.colors),this.molSketcher=new a.chem.Sketcher,this.molSketcher.root.classList.add("monomer-manager-sketcher"),this.polymerTypeInput=s.input.choice("Polymer Type",{value:"PEPTIDE",items:["PEPTIDE","RNA","CHEM","BLOB","G"],onValueChanged:()=>this.onMonomerInputChanged(),nullable:!1}),this.monomerTypeInput=s.input.choice("Monomer Type",{value:"Backbone",items:["Backbone","Branch","Terminal"],onValueChanged:()=>this.onMonomerInputChanged(),nullable:!1}),this.monomerSymbolInput=s.input.string("Monomer Symbol",{nullable:!1,onValueChanged:()=>this.onMonomerInputChanged()}),this.monomerNameInput=s.input.string("Monomer Name",{nullable:!1,onValueChanged:()=>this.onMonomerInputChanged()}),this.monomerNameInput.nullable=!1,this.monomerIdInput=s.input.int("Monomer ID",{nullable:!0,value:0,onValueChanged:()=>this.onMonomerInputChanged()}),this.monomerNaturalAnalogInput=s.input.string("Natural Analog",{nullable:!0,onValueChanged:()=>this.onMonomerInputChanged()}),this.saveButton=s.bigButton("Save",(async()=>{const t=this.validateInputs();t?r.shell.warning(t):await this.saveMonomer()})),this.molSketcher.subs.push(this.molSketcher.onChanged.subscribe((async()=>{if(this.triggerMolChange){try{this.rgroupsGridRoot.style.display="none";const t=this.inputsTabControl.panes.find((t=>"r-groups"===t.name?.toLowerCase()));t&&t.header.style.removeProperty("background-color");let e=this.molSketcher.getSmiles();if(!e)return this.rgroupsGrid.items=[],this.rgroupsGrid.render(),this.saveValidationResult="Monomer molecule is required",void this.invalidateSaveButton();e=$n([],e);const n=this.findRgroupsInSmiles(e);if(0===n.length)return this.rgroupsGrid.items=[],this.rgroupsGrid.render(),this.saveValidationResult="At least one R-group is required",t&&t.header.style.setProperty("background-color","#ff000030"),void this.invalidateSaveButton();if(new Set(n.map((t=>t[0]))).size!==n.length)return this.saveValidationResult="Duplicate R-groups are not allowed",this.rgroupsGridRoot.style.display="flex",t&&t.header.style.setProperty("background-color","#ff000030"),void this.invalidateSaveButton();const i=n.map((t=>Number.parseInt(t[0].match(/[1-9]/g)[0]))).map((t=>this.rgroupsGrid.items.find((e=>e.label===`R${t}`))??{capGroupSMILES:`[*:${t}][H]`,alternateId:`R${t}-H`,capGroupName:"H",label:`R${t}`}));this.rgroupsGrid.items=i.sort(((t,e)=>t.label?.localeCompare(e.label??"")??0)),this.rgroupsGrid.render(),this.rgroupsGridRoot.style.display="flex";const o=await Cn(kn(e,i),this.polymerTypeInput.value??"");o&&(this.monomerNaturalAnalogInput.value=o)}catch(t){console.error(t)}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:t=>t?r.chem.checkSmiles(t)?null:"Invalid SMILES":"Cap group smiles is required",alternateId:t=>t?null:"Alternate ID is required",capGroupName:t=>t?null:"Cap group name is required",label:t=>t?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=s.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=s.divV([this.polymerTypeInput,this.monomerTypeInput,this.monomerSymbolInput,this.monomerNameInput,this.monomerIdInput,this.monomerNaturalAnalogInput]);this.inputsTabControl=s.tabControl({Monomer:c,"R-groups":this.rgroupsGridRoot,Meta:s.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 t=this.polymerTypeInput.value&&this.polymerTypeInput.value&&!!this.getMonomerLib()?.getMonomer(this.polymerTypeInput.value,this.monomerSymbolInput.value);this.saveButton.textContent=t?"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(t){this.triggerMolChange=!1,this.molSketcher.setSmiles(t.smiles),this.polymerTypeInput.value=t.polymerType,this.monomerTypeInput.value=t.monomerType,this.monomerSymbolInput.value=t.symbol,this.monomerNameInput.value=t.name,this.monomerIdInput.value=t.id,this.monomerNaturalAnalogInput.value=t.naturalAnalog??null,this.rgroupsGrid.items=Ln(t.rgroups),this.metaGrid.items=Object.entries(t.meta??{}).filter((([t,e])=>"colors"!==t?.toLowerCase())).map((([t,e])=>({Property:t,Value:e}))),this.rgroupsGrid.render(),this.metaGrid.render(),this.rgroupsGridRoot.style.display="flex",this.onMonomerInputChanged(),!t.naturalAnalog&&t.polymerType&&Cn(kn(t.smiles,this.rgroupsGrid.items),t.polymerType).then((t=>{t&&(this.monomerNaturalAnalogInput.value=t)}));const e=t.meta?.colors??"";let n={};try{n=e?JSON.parse(e)?.default:{}}catch(t){console.error(t)}this.colorsEditor.colors={line:n.line??"#000000",background:n.background??"#000000",text:n.text??"#000000"}}validateInputs(){const t=this.inputsTabControl.panes.find((t=>"r-groups"===t.name?.toLowerCase()));if(t&&t.header.style.removeProperty("background-color"),!this.molSketcher.getSmiles())return"Monomer Molecule field is required";for(const t of[this.polymerTypeInput,this.monomerTypeInput,this.monomerSymbolInput,this.monomerNameInput])if(null==t.value||""===t.value)return`${t.caption} field is required`;let e=null;if(this.rgroupsGrid.items.length<1&&(e="At least one R-group is required"),!e)t:for(const t of this.rgroupsGrid.items)for(const[n,i]of Object.entries(t))if(!i){e=`R-group ${n} field is required for ${t.label}`;break t}return!e&&this.rgroupsGrid.hasErrors()&&(e="R-group fields contain errors"),e?(t&&t.header.style.setProperty("background-color","#ff000030"),e):null}findRgroupsInSmiles(t){return[...Array.from(t.matchAll(/\[[1-9]\*\]/g)),...Array.from(t.matchAll(/\[\*\:[1-9]\]/g))]}get form(){this.inputsTabControl.root.classList.add("monomer-manager-form-tab-control"),this.inputsTabControl.header.style.marginBottom="10px";const t=s.buttonsInput([this.saveButton]);return s.tooltip.bind(t,(()=>this.saveValidationResult??"Save monomer to library")),s.divV([this.molSketcher.root,this.inputsTabControl.root,t],{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(t){const e=$n(t.rgroups,t.smiles,t.molfile),n=r.chem.drawMolecule(e,150,150),i=s.tableFromMap({name:t.name,author:t.author,createDate:t.createDate});return s.divH([n,i],{style:{alignItems:"center"}})}async removeMonomers(t,e,n=!0){let i=[];try{const t=await r.dapi.files.readAsText(cn.so+e);i=JSON.parse(t)}catch(t){return r.shell.error(`Error reading library ${e}`),console.error(t)}const o=t.map((t=>Pn(i,(e=>e.symbol===t.symbol&&e.polymerType===t.polymerType))));for(let n=0;n<o.length;n++)if(-1===o[n])return void r.shell.error(`Monomer ${t[n].symbol} not found in library ${e}`);const a=o.map((t=>i[t])),l=s.divV(a.map((t=>this.getMonomerInfoTable(t))),{style:{maxHeight:"500px",overflow:"scroll"}}),c=a.length>1,h=c?`Are you sure you want to remove monomers ${a.map((t=>t.symbol)).join(", ")} from ${e} library?`:`Are you sure you want to remove monomer with symbol ${a[0].symbol} from ${e} library?`,u=s.dialog("Remove Monomer"+(c?"s":"")).add(s.h1(h)).add(l).addButton("Remove",(async()=>{i=i.filter((t=>!a.includes(t))),await r.dapi.files.writeAsText(cn.so+e,JSON.stringify(i,null,2)),await(await dn.getInstance()).loadLibraries(!0),await this.refreshTable(),n&&r.shell.info(`Monomer${c?"s":""} ${a.map((t=>t.symbol)).join(", ")} ${c?"were":"was"} successfully removed from ${e} library`),u.close()})).show()}async addMonomerToLib(t,e){let n=[];try{const t=await r.dapi.files.readAsText(cn.so+e);n=JSON.parse(t)}catch(t){return r.shell.error(`Error reading library ${e}`),console.error(t)}const i=Pn(n,(e=>e.symbol===t.symbol&&e.polymerType===t.polymerType)),o=this.getMonomersDataFrame()?.col(An.MONOMER)?.toList()?.findIndex((e=>e===t.smiles)),a=async()=>{try{const i=n.findIndex((e=>e.symbol===t.symbol&&e.polymerType===t.polymerType));i>=0?n[i]={...t,lib:void 0,wem:void 0}:n.push({...t,lib:void 0,wem:void 0}),await r.dapi.files.writeAsText(cn.so+e,JSON.stringify(n,null,2)),await(await dn.getInstance()).loadLibraries(!0),await this.refreshTable(t.symbol),this._molChanged=!1,r.shell.info(`Monomer ${t.symbol} was successfully saved in library ${e}`)}catch(t){r.shell.error("Error saving monomer"),console.error(t)}this.onMonomerInputChanged()};let l=null,c="";if(i>=0)l=this.getMonomerInfoTable(n[i]),c=`Monomer with symbol '${t.symbol}' already exists in library ${e}.\nAre you sure you want to overwrite it?`;else if((o??-1)>=0){const t=await On(this.getMonomersDataFrame().rows.get(o));l=this.getMonomerInfoTable(t),c=`Monomer with the same structure already exists in library ${e} with different symbol (${t.symbol}).\nAre you sure you want to duplicate it?`}if(l){const t=s.dialog("Save Monomer").add(s.divText(c)).add(l).addButton("Save",(()=>{t.close(),a()})).show()}else await a()}async saveMonomer(){let t=this.molSketcher.getSmiles();if(!t||!r.chem.checkSmiles(t))return void r.shell.warning("Invalid SMILES");t=$n([],t);let e=r.chem.convert(t,a.chem.Notation.Smiles,a.chem.Notation.MolBlock);e=Rn(e);const n={};this.metaGrid.items.filter((t=>!!t.Property&&!!t.Value)).forEach((t=>{n[t.Property]=t.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:e,smiles:t,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},s=this.getMonomerLib()?.source;s?await this.addMonomerToLib(o,s):r.shell.warning("Monomer library source is not specified")}}function Pn(t,e){let n=-1;for(let i=t.length-1;i>=0;i--)if(e(t[i])){n=i;break}return n}function $n(t,e,n){const i=!e||!r.chem.checkSmiles(e);if(i&&!n)throw new Error("Both SMILES and MOL block are empty or malformed");let o=i?r.chem.convert(n,a.chem.Notation.Unknown,a.chem.Notation.Smiles):e;return o=function(t,e){let n=t;return e.forEach((t=>{const e=t.label[1]??"1",i=new RegExp(`\\[\\${t.capGroupName}:${e}\\]`,"g");n=n.replace(i,`[*:${e}]`)})),n=n.replaceAll(/\[\d[A-Z]{1,2}\]/g,(t=>`[*:${t[1]}]`)),n}(o,t),o=Mn(o),i?o:r.chem.convert(o,a.chem.Notation.Unknown,a.chem.Notation.Smiles)}function Rn(t){const e=t.split("\n"),n=e.findIndex((t=>t.startsWith("M")&&t.includes("ISO")));if(-1!==n){const t=e[n].indexOf("ISO");e[n]=e[n].substring(0,t)+"RGP"+e[n].substring(t+3)}const i=e.findIndex((t=>t.includes("V2000")));if(-1===i)return console.error("Mol start line not found"),t;const o=Number.parseInt(e[i].trim().split(" ")[0].slice(0,3).trim()),r={};for(let t=i+1;t<i+1+o;t++){const n=e[t].indexOf("R ");if(-1===n)continue;"#"!==e[t][n+1]&&(e[t]=e[t].replace("R ","R#"));const o=e[t].trim().split(" ").map((t=>t.trim())).filter(Boolean);if(r[t-i]=1,o.length<14)continue;const s=Number.parseInt(o[13]);Number.isNaN(s)||(r[t-i]=s)}const s=Object.keys(r);if(-1===e.findIndex((t=>t.startsWith("M")&&t.includes("RGP")))){const t=`M RGP${s.length.toString().padStart(3," ")}${Object.entries(r).map((([t,e])=>`${t.toString().padStart(4," ")}${e.toString().padStart(4," ")}`)).join("")}`,n=e.findIndex((t=>t.startsWith("M")&&t.includes("END")));e.splice(n,0,t)}return s.filter((t=>!!Number.parseInt(t))).map((t=>Number.parseInt(t)+i)).forEach((t=>{const n=e[t].split(" "),i=n.findIndex((t=>"R#"===t));if(-1!==i){for(let t=i+1;t<n.length;t++)n[t]&&1==n[t].length&&(Number.parseInt(n[t])??0)>0&&(n[t]="0");e[t]=n.join(" ")}})),e.join("\n")}function kn(t,e){let n=t;return e.forEach((t=>{const e=t.label[1]??"1",i=In(t,"capGroupName");n=n.replace(`[*:${e}]`,`[${i}]`)})),n}async function On(t){let e;try{e=JSON.parse(t.get(An.META)??"{}");for(const t in e)"object"==typeof e[t]&&(e[t]=JSON.stringify(e[t])),("string"!=typeof e[t]||e[t]!==a.INT_NULL.toString()&&e[t]!==a.FLOAT_NULL.toString())&&("number"!=typeof e[t]||e[t]!==a.INT_NULL&&e[t]!==a.FLOAT_NULL)||(e[t]=null)}catch(t){console.error(t)}const n=t.get(An.MONOMER);if(!n)throw new Error("Monomer SMILES is empty");let i="";try{i=r.chem.convert(n,a.chem.Notation.Smiles,a.chem.Notation.MolBlock),i=Rn(i)}catch(t){r.shell.error(`Error converting SMILES to molfile, \n ${n}`),console.error(t)}let o=t.get(An.NATURAL_ANALOG);const s=t.get(An.POLYMER_TYPE);let l=[];try{if(l=JSON.parse(t.get(An.R_GROUPS)??"[]"),!o&&s){const t=await Cn(kn(n,l),s);t&&(o=t)}}catch(t){l??=[]}return{symbol:t.get(An.SYMBOL),name:t.get(An.NAME),molfile:i,smiles:n,polymerType:s,monomerType:t.get(An.MONOMER_TYPE),naturalAnalog:o,id:t.get(An.ID),rgroups:l,meta:e,author:t.get(An.AUTHOR),createDate:t.get(An.CREATE_DATE)}}class Hn{_colors;_colorInputs;constructor(t){this._colors=t,this._colorInputs={line:s.input.color("Line",{value:t.line,onValueChanged:t=>this._colors.line=t}),background:s.input.color("Background",{value:t.background,onValueChanged:t=>this._colors.background=t}),text:s.input.color("Text",{value:t.text,onValueChanged:t=>this._colors.text=t})}}get colors(){return this._colors}set colors(t){const e={line:a.Color.toHtml(a.Color.fromHtml(t.line??"#000000")),background:a.Color.toHtml(a.Color.fromHtml(t.background??"#000000")),text:a.Color.toHtml(a.Color.fromHtml(t.text??"#000000"))};this._colors=e;for(const t in this._colorInputs)this._colorInputs[t].value=e[t]}get colorsMetaFormat(){return{colors:{default:this._colors}}}get form(){return s.form(Object.values(this._colorInputs))}}class Gn{monomer;root=s.divV([],{classes:"monomer-card-root"});_selected=!1;get selected(){return this._selected}set selected(t){this._selected=t,this.root.style.border=t?"2px solid var(--green-2)":"2px solid var(--grey-2)"}constructor(t){this.monomer=t}render(){s.empty(this.root);const t=this.monomer.smiles&&r.chem.checkSmiles(this.monomer.smiles)?r.chem.drawMolecule(this.monomer.smiles,200,200):r.chem.drawMolecule(this.monomer.molfile??"",200,200);this.root.appendChild(t);const e=s.divH([s.divText("Monomer Name: "),s.divText(this.monomer.name)],{classes:"monomer-card-info-row"});if(this.root.appendChild(e),s.tooltip.bind(e,this.monomer.name),this.monomer.lib?.source){const t=s.divH([s.divText("Source: "),s.divText(this.monomer.lib.source)],{classes:"monomer-card-info-row"});this.root.appendChild(t),s.tooltip.bind(t,this.monomer.lib.source)}const n=s.divH([s.divText("Polymer Type: "),s.divText(this.monomer.polymerType)],{classes:"monomer-card-info-row"});this.root.appendChild(n),s.tooltip.bind(n,this.monomer.polymerType),s.tooltip.bind(this.root,"Select Monomer")}}class Fn{monomerSymbol;monomers;root=s.divH([],{style:{alignItems:"center",width:"100%",overflow:"hidden",visibility:"visible"},classes:"duplicate-monomer-symbol-row"});monomerCards;constructor(t,e,n,i){this.monomerSymbol=t,this.monomers=e,this.monomerCards=e.map((t=>new Gn(t)));const o=s.divH([],{style:{overflowX:"auto",width:"100%"}}),r=s.h1(t,{style:{lineHeight:"2em",fontSize:"1.5em",marginRight:"20px",width:"100px",overflow:"hidden",textOverflow:"elipsis"}});s.tooltip.bind(r,t),this.root.appendChild(r),this.root.appendChild(o),this.monomerCards.forEach((t=>{t.root.onclick=()=>{this.monomerCards.forEach((t=>t.selected=!1)),t.selected=!0,i(t.monomer)},n&&t.monomer===n&&(t.selected=!0),o.appendChild(t.root)}))}render(){this.monomerCards.forEach((t=>t.render()))}}class Dn{monomerCardRows=[];saveSettingsPromise=Promise.resolve();searchInput;_root;monomers;settings;filteredMonomerRows=[];static _instance;vv;static async getInstance(){return Dn._instance||(Dn._instance=new Dn,await Dn._instance.refresh(),(await dn.getInstance()).getMonomerLib().onChanged.subscribe((async()=>await Dn._instance.refresh()))),Dn._instance.refresh(),Dn._instance}async refresh(){this.settings=await(0,Nt.ub)();const t=await dn.getInstance();await t.awaitLoaded(),await t.loadLibrariesPromise,this.monomers=t.duplicateMonomers,this.monomerCardRows=[];for(const e in this.monomers)for(const n in this.monomers[e]){const i=this.settings.duplicateMonomerPreferences?.[e]?.[n]??null,o=i?this.monomers[e][n].find((t=>t.lib?.source===i))??null:null;this.monomerCardRows.push(new Fn(n,this.monomers[e][n],o,(async i=>{this.saveSettingsPromise=this.saveSettingsPromise.then((async()=>{i.lib?.source&&(this.settings.duplicateMonomerPreferences=this.settings.duplicateMonomerPreferences??{},this.settings.duplicateMonomerPreferences[e]=this.settings.duplicateMonomerPreferences[e]??{},this.settings.duplicateMonomerPreferences[e][n]=i.lib.source,await(0,Nt.Eu)(this.settings),r.shell.info(`Monomer '${i.name}' from source '${i.lib.source}' selected for symbol '${n}'.`),t.assignDuplicatePreferances(this.settings))}))})))}if(this.filteredMonomerRows=this.monomerCardRows,this.vv)this.vv.setData(this.filteredMonomerRows.length,(t=>(this.filteredMonomerRows[t].render(),this.filteredMonomerRows[t].root)));else{this.vv=s.virtualView(this.monomerCardRows.length,(t=>(this.monomerCardRows[t].render(),this.monomerCardRows[t].root))),this.vv.root.classList.add("duplicate-monomers-virtual-view"),this.searchInput=s.input.string("Search",{placeholder:"Monomer Symbol",value:"",onValueChanged:()=>t(this.searchInput.value)}),this.searchInput.root.style.justifyContent="center",this.searchInput.input.style.width="200px",this._root=s.divV([s.h1("Manage Duplicate Monomer Symbols",{style:{textAlign:"center"}}),this.searchInput.root,s.divV([this.vv.root],{style:{overflowY:"auto",height:"100%"}})],{style:{height:"100%"}});const t=t=>{this.filteredMonomerRows=this.monomerCardRows.filter((e=>e.monomerSymbol.toLowerCase().includes(t.toLowerCase()))),this.vv.setData(this.filteredMonomerRows.length,(t=>(this.filteredMonomerRows[t].render(),this.filteredMonomerRows[t].root)))}}}constructor(){}get root(){return this._root}}async function Bn(){await jn.showDialog()}async function Vn(t=!0){return await qn.showView(t)}class Wn{_fileManager;_widget;get widget(){return this._widget}constructor(){}static instancePromise;static async getInstance(){return void 0===Wn.instancePromise&&(Wn.instancePromise=(async()=>{const t=new Wn,e=await(0,bt.pj)();return t._fileManager=await e.getFileManager(),t._widget=await t.createWidget(),t})()),Wn.instancePromise}static async reloadWidget(){const t=await Wn.getInstance();t._widget=await t.createWidget()}async createWidget(){const t=await this.getWidgetContent();return(await(0,bt.pj)()).eventManager.addLibraryFileRequested$.subscribe((()=>this.promptToAddLibraryFiles())),new a.Widget(t)}async getWidgetContent(){const t=await Un.createControlsForm();return mn()(t).addClass("monomer-lib-controls-form"),setTimeout((()=>{t&&mn()(t)&&mn()(t).removeClass("ui-form-condensed")}),200),s.divV([t])}async promptToAddLibraryFiles(){a.Utils.openFile({accept:".json",open:async t=>{const e=await t.text(),n=t.name,i=a.TaskBarProgressIndicator.create(`Adding ${n} as a monomer library`);try{await this._fileManager.addLibraryFile(e,n)}catch(t){r.shell.error(`File ${n} is not a valid monomer library, verify it is aligned to HELM JSON schema.`)}finally{i.close()}}})}}class Un{fileManager;userLibSettings;constructor(t,e){this.fileManager=t,this.userLibSettings=e,this.fileManager.eventManager.updateUIControlsRequested$.subscribe((()=>{this.updateControlsForm()})),this.fileManager.eventManager.librarySelectionRequested$.subscribe((([t,e])=>{this.updateLibrarySelectionStatus(e,t)}))}toLog(){return"LibraryControlsManager<#>"}static async createControlsForm(){io.logger.debug("LibraryControlsForm.createControlsForm(), start");const[t,e]=await Promise.all([(0,bt.pj)().then((t=>t.getFileManager())),await(0,Nt.ub)()]);return new Un(t,e)._createControlsForm()}_createControlsForm(){const t=this.createLibraryControls(),e=s.wideForm(t,void 0);return mn()(e).addClass("monomer-lib-controls-form"),e}updateControlsForm(){const t=this._createControlsForm();mn()(".monomer-lib-controls-form").replaceWith(t)}createLibraryControls(){return this.fileManager.getValidLibraryPaths().map((t=>this.createLibInput(t)))}createLibInput(t){const e=`${this.toLog()}.createLibInput()`;io.logger.debug(`${e}, libFileName = '${t}', start`);const n=!this.userLibSettings.exclude.includes(t),i=s.input.bool(t,{value:n,onValueChanged:()=>{this.fileManager.eventManager.updateLibrarySelectionStatus(t,i.value)}});s.tooltip.bind(i.root,`Include monomers from ${t}`);const o=s.iconFA("trash-alt",(()=>this.promptForLibraryDeletion(t))),a=s.icons.edit((async()=>{r.shell.v=await(await Tn.getInstance()).getViewRoot(t)}),"Edit monomer library");return s.tooltip.bind(o,`Delete ${t}`),i.addOptions(a),i.addOptions(o),io.logger.debug(`${e}, libFileName = '${t}', end`),i}async updateLibrarySelectionStatus(t,e){this.updateLibrarySettings(t,e),await(0,Nt.Eu)(this.userLibSettings);const n=await(0,bt.pj)();await n.loadMonomerLib(!0),r.shell.info("Monomer library user settings saved")}updateLibrarySettings(t,e){t?this.userLibSettings.exclude=this.userLibSettings.exclude.filter((t=>t!==e)):this.userLibSettings.exclude.includes(e)||this.userLibSettings.exclude.push(e)}promptForLibraryDeletion(t){s.dialog("Warning").add(s.divText(`Delete file ${t}?`)).onOK((async()=>{try{const e=a.TaskBarProgressIndicator.create(`Deleting ${t} library`);await this.updateLibrarySelectionStatus(!1,t),await this.fileManager.deleteLibraryFile(t),e.close()}catch(e){console.error(e),r.shell.error(`Failed to delete ${t} library`)}})).showModal(!1)}}class jn{constructor(){}static _instance;dialog;closeDialogSubject$=new h.Subject;static async showDialog(){jn._instance||(jn._instance=new jn,jn._instance.closeDialogSubject$.subscribe((()=>{jn._instance.dialog=void 0}))),jn._instance.dialog||(jn._instance.dialog=await jn._instance.getDialog()),jn._instance.dialog.show()}async getDialog(){const t=un.getInstance(),e=(await Wn.getInstance()).widget,n=s.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",(()=>t.addLibraryFile()),void 0,"Upload new HELM monomer library"),n.add(e);const i=n.onClose.subscribe((()=>{this.closeDialogSubject$.next(),i.unsubscribe()}));return n}}class qn{constructor(){}static _instance;static viewName="Manage Monomer Libraries";_view;_duplicateManager;libManager;async getView(t=!0){const e=un.getInstance(),n=(await Wn.getInstance()).widget,i=s.bigButton("Add",(()=>e.addLibraryFile()),"Upload new HELM monomer library"),o=s.bigButton("Merge",(()=>{this.mergeSelectedLibs()}),"Merge selected libraries into one"),l=s.splitH([s.divV([n.root,s.buttonsInput([i,o])],{classes:"ui-form"}),this._duplicateManager.root],{style:{width:"100%",height:"100%"}},!0);if(this._view)try{this._view.subs.forEach((t=>t.unsubscribe())),this._view.detach(),this._view.close()}catch(t){}return this._view=a.View.fromRoot(l),this._view.name=qn.viewName,t&&r.shell.addView(this._view),s.tools.waitForElementInDom(l).then((()=>{setTimeout((()=>{const t=Array.from(l.children).filter((t=>t.classList.contains("ui-box")));if(2!==t.length)return;const[e,n]=t,i=e.getBoundingClientRect().width+n.getBoundingClientRect().width,o=.3*i;e.style.width=`${o}px`;const r=i-o;n.style.width=`${r}px`}),100),this._view.subs.push(r.events.onCurrentViewChanged.subscribe((()=>{try{const t=qn._instance;t&&t._view&&r.shell.v&&"id"in r.shell.v&&r.shell.v.id===t._view.id&&t._duplicateManager?.refresh()}catch(t){console.error(t)}})))})),this._view}static async showView(t=!0){return qn._instance||(qn._instance=new qn),qn._instance._duplicateManager||(qn._instance._duplicateManager=await Dn.getInstance()),qn._instance.libManager||(qn._instance.libManager=await dn.getInstance()),t&&qn._instance._view&&Array.from(r.shell.views).find((t=>t.id&&t.id===qn._instance._view.id))?(r.shell.v=qn._instance._view,await qn._instance._duplicateManager.refresh(),qn._instance._view):(qn.closeExistingViews(),qn._instance.getView(t))}static closeExistingViews(){Array.from(r.shell.views).filter((t=>t.name===qn.viewName)).forEach((t=>t.close()))}async mergeSelectedLibs(){const t="Library with this name already exists",e=await dn.getInstance();if(await e.awaitLoaded(),await e.loadLibrariesPromise,!e.duplicatesHandled)return void r.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=e.getBioLib().toJSON(),i=s.dialog("Merge selected libraries"),o=s.input.string("Library Name",{placeholder:"Enter new library name",nullable:!1,onValueChanged:()=>{const e=h(o.value);i.getButton("Download")?.classList?.toggle("d4-disabled",!!e&&e!==t),i.getButton("Save")?.classList?.toggle("d4-disabled",!!e)}}),l=(await this.libManager.getFileManager()).getValidLibraryPaths();function c(){let t=o.value;return t.endsWith(".json")||(t+=".json"),t}function h(e){return e&&e.trim()?e.endsWith(".json")&&l.includes(e)||l.includes(e+".json")?t:null:"Library name cannot be empty"}o.addValidator(h),i.add(o).add(s.divText(`Total monomers: ${n.length}`)).addButton("Download",(()=>{a.Utils.download(c(),JSON.stringify(n))})).addButton("Save",(async()=>{i.close();const t=c(),e=JSON.stringify(n),o=await this.libManager.getFileManager();this._view&&s.setUpdateIndicator(this._view.root,!0);try{await o.addLibraryFile(e,t,!1);const n=await(0,Nt.ub)();n.exclude=l,await(0,Nt.Eu)(n),await this.libManager.loadLibraries(!0),await Wn.reloadWidget()}catch(e){r.shell.error(`Failed to save library ${t}. see console for details.`),console.error(e)}finally{this._view&&s.setUpdateIndicator(this._view.root,!1)}})).show(),i.getButton("Download")?.classList?.add("d4-disabled"),i.getButton("Save")?.classList?.add("d4-disabled")}}var zn,Yn=function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((i=i.apply(t,e||[])).next())}))};class Kn{_setBreadcrumbsInViewName(){var t,e;const n=["Home","Demo",...(null!==(t=this._path)&&void 0!==t?t:"").split("/")],i=s.breadcrumbs(n);if(i.onPathClick.subscribe((t=>Yn(this,void 0,void 0,(function*(){const e=t[t.length-1];if(e===i.path[i.path.length-1])return;const n=r.shell.browsePanel.mainTree.getOrCreateGroup("Apps").getOrCreateGroup("Demo");n.currentItem="Demo"===e?n:n.items.find((t=>t.text===e))})))),r.shell.v){if(0!==i.path.length&&"Home"===i.path[0]){const t=s.iconFA("home",(()=>{r.shell.v.close(),r.shell.v=a.View.createByType(a.VIEW_TYPE.HOME)}));t.classList.add("demo-breadcrumbs-home-element"),i.root.firstElementChild.replaceWith(t)}const t=null===(e=r.shell.v.ribbonMenu.root.parentElement)||void 0===e?void 0:e.getElementsByClassName("d4-ribbon-name")[0];t&&(t.textContent="",t.appendChild(i.root))}}constructor(t,e,n=!1,i){var o,r;this.name="",this.description="",this._isAutomatic=!1,this._autoStartFirstStep=!1,this._currentStep=0,this._isStopped=!1,this._isCancelled=!1,this._isStepProcessed=!1,this._root=s.div([],{id:"demo-script",classes:"tutorials-root tutorials-track demo-app-script"}),this._steps=[],this._mainHeader=s.panel([],"tutorials-main-header"),this._header=s.h2(""),this._headerDiv=s.divH([],"tutorials-root-header"),this._stopStartBtn=s.button(s.iconFA("pause"),(()=>Yn(this,void 0,void 0,(function*(){return yield this._changeStopState()}))),"Play / pause"),this._restartBtn=s.button(s.iconFA("redo"),(()=>Yn(this,void 0,void 0,(function*(){return yield this._restartScript()}))),"Restart"),this._nextStepBtn=s.button(s.iconFA("play"),(()=>Yn(this,void 0,void 0,(function*(){this._isStepProcessed||(yield this._nextStep())}))),"Next step"),this._activity=s.panel([],"tutorials-root-description"),this._progressDiv=s.divV([],"tutorials-root-progress"),this._progress=s.element("progress"),this._progressSteps=s.divText(""),this._closeBtn=s.button(s.iconFA("chevron-left"),(()=>this._closeDock()),"Back to demo"),this.DEMO_PATH="apps/Tutorials/Demo",this.name=t,this.description=e,this._isAutomatic=n,this._autoStartFirstStep=null!==(o=null==i?void 0:i.autoStartFirstStep)&&void 0!==o&&o,this._path=null!==(r=null==i?void 0:i.path)&&void 0!==r?r:"",this._progress.max=0,this._progress.value=1,Kn.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=s.divText(`Step: ${this._progress.value} of ${this.stepNumber}`),this._progressDiv.append(this._progressSteps)}_addDescription(){var t;this._activity.append(s.div(this.description,"tutorials-root-description"));for(let e=0;e<this.stepNumber;e++){let n=s.iconFA("clock");this._isAutomatic||0===e&&(n=s.iconFA("play",(()=>this._nextStep()),"Next step"),n.className="grok-icon fas fa-play");const i=s.div(this._steps[e].name,"grok-tutorial-entry-instruction"),o=s.div(null===(t=this._steps[e].options)||void 0===t?void 0:t.description,"grok-tutorial-step-description hidden"),r=s.divH([n,i],"grok-tutorial-entry");this._activity.append(r,o)}}_initRoot(){r.shell.windows.showContextPanel=!0,r.shell.windows.showHelp=!1,this._node=r.shell.dockManager.dock(this._root,a.DOCK_TYPE.FILL,r.shell.dockManager.findNode(r.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 t;r.shell.v&&(r.shell.v.name=this.name,r.shell.v.path=`${this.DEMO_PATH}/${(null!==(t=this._path)&&void 0!==t?t:"").replaceAll(" ","-")}`,this._setBreadcrumbsInViewName())}_nextStep(){return Yn(this,void 0,void 0,(function*(){var t,e;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===(t=this._steps[this._currentStep].options)||void 0===t?void 0:t.delay)?null===(e=this._steps[this._currentStep].options)||void 0===e?void 0:e.delay:2e3;try{this._setViewParams(),yield this._steps[this._currentStep].func(),this._setViewParams()}catch(t){console.error(t)}this._scrollTo(this._root,l.offsetTop-this._mainHeader.offsetHeight),this._isAutomatic&&(yield this._countdown(n,i,c),yield(0,te.cb)(c));const h=s.iconFA("check");if(i.replaceWith(h),h.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 t=this._activity.getElementsByClassName("grok-icon")[this._currentStep],e=s.iconFA("play",(()=>this._nextStep()),"Next step");e.className="grok-icon fas fa-play",t.replaceWith(e),this._nextStepBtn.classList.remove("disabled"),this._nextStepBtn.firstChild.classList.remove("fa-disabled")}r.shell.v instanceof a.TableView&&(yield r.data.detectSemanticTypes(r.shell.tv.dataFrame))}else this._isAutomatic?this._stopStartBtn.replaceWith(this._restartBtn):this._nextStepBtn.replaceWith(this._restartBtn)}))}_startScript(){return Yn(this,void 0,void 0,(function*(){for(let t=this._currentStep;t<this.stepNumber&&!this._isStopped&&!this._isCancelled;t++)yield this._nextStep()}))}_scrollTo(t,e){t.focus(),t.scrollTop=e}_countdown(t,e,n){return Yn(this,void 0,void 0,(function*(){const i=s.div([],"demo-script-countdown");e.classList.add("hidden");let o=n/1e3;const r=this._createSVGIndicator(o);i.append(r),t.prepend(i);const a=setInterval((()=>{o--,0===o&&(clearInterval(a),i.remove(),e.classList.remove("hidden"),e.classList.add("visible"))}),1e3)}))}_createSVGIndicator(t){const e=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 ${t}s linear infinite forwards`),e.append(n),e}_changeStopState(){return Yn(this,void 0,void 0,(function*(){const t=this._stopStartBtn.getElementsByClassName("grok-icon");t[0].className="grok-icon fas fa-play",this._isStopped=!this._isStopped,this._isStopped||(t[0].className="grok-icon fal fa-pause",this._isStepProcessed||(yield this._startScript()))}))}_restartScript(){return Yn(this,void 0,void 0,(function*(){r.shell.dockManager.close(this._node),this._clearRoot(),this._setInitParams(),yield this.start()}))}_clearRoot(){this._root=s.div([],{id:"demo-script",classes:"tutorials-root tutorials-track demo-app-script"}),this._mainHeader=s.panel([],"tutorials-main-header"),this._header=s.h2(""),this._headerDiv=s.divH([],"tutorials-root-header"),this._activity=s.panel([],"tutorials-root-description"),this._progressDiv=s.divV([],"tutorials-root-progress"),this._progress=s.element("progress"),this._progressSteps=s.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(){r.shell.dockManager.close(this._node),this.cancelScript()}cancelScript(){this._isCancelled=!0,Kn.currentObject=null}step(t,e,n){return this._steps[this.steps.length]={name:t,func:e,options:n},this}start(){return Yn(this,void 0,void 0,(function*(){this._initRoot(),r.shell.v.name===this.name&&(r.shell.v.close(),this._node=r.shell.dockManager.dock(this._root,a.DOCK_TYPE.FILL,r.shell.dockManager.findNode(r.shell.browsePanel.root),this.name)),this._isAutomatic?yield this._startScript():this._autoStartFirstStep&&(yield this._nextStep())}))}}Kn.currentObject=null,function(t){t.X="Embed_X",t.Y="Embed_Y"}(zn||(zn={}));var Zn=n(966),Xn=n(608),Jn=n(1619);class Qn{urlParams;funcName;options;df;view;constructor(t,e,n={}){this.urlParams=t,this.funcName=e,this.options=n}async init(t){this.df=t,await this.buildView()}async buildView(){const t=$()(this.urlParams.entries()).map((([t,e])=>`${t}=${encodeURIComponent(e)}`)).toArray().join("&");this.view=r.shell.addTableView(this.df),this.view.path=this.view.basePath=`func/${io.name}.${this.funcName}?${t}`;const e={...this.options,sequenceColumnName:"sequence"};for(const[t,n]of this.urlParams.entries())switch(t){case oe.n5.fixWidth:case oe.n5.fitArea:e[t]=["1","on","true"].includes(n.toLowerCase());break;default:e[t]=n}const n=await this.view.dataFrame.plot.fromType("WebLogo",e);this.view.dockManager.dock(n,a.DOCK_TYPE.DOWN,null,"WebLogo",.35)}}class ti{tableInput;seqColInput;funcParamsDiv;get funcParams(){return{table:this.tableInput.value,sequence:this.seqColInput.value}}get paramsUI(){return this.funcParamsDiv}constructor(){this.tableInput=s.input.table("Table",{value:r.shell.tv.dataFrame,onValueChanged:()=>{this.onTableInputChanged()}});const t=this.tableInput.value.columns.bySemType(a.SEMTYPE.MACROMOLECULE);this.seqColInput=s.input.column("Sequence",{table:this.tableInput.value,value:t,filter:t=>t.semType===a.SEMTYPE.MACROMOLECULE}),this.funcParamsDiv=s.inputs([this.tableInput,this.seqColInput],{style:{minWidth:"320px"}})}onTableInputChanged(){this.seqColInput=s.input.column("Sequence",{table:this.tableInput.value,value:this.tableInput.value.columns.bySemType(a.SEMTYPE.MACROMOLECULE)})}}var ei=n(6869);new class{tooltipHandlerTemp="tooltip-handler.Monomer"};const ni="-";class ii extends Vt{constructor(t,e){super(t,e)}render(t,e,n,i,o,r,s){t.save(),t.beginPath(),t.rect(e,n,i,o),t.clip();try{if(!r.isTableCell)return;const s=r.cell?.column&&r.cell.column?.dart&&"true"===r.cell.column.getTag(Rt.Mn.applyToBackground);t.font="12px monospace",t.textBaseline="middle",t.textAlign="left";let a=r.cell.value;a&&a!==wt._S||(a=ni);const l=a.split(wt.ot).map((t=>t&&t!==wt._S?t.trim():ni)),c=l.map((t=>(0,gt.zS)(t,Math.max(2,Math.floor(.15*i/l.length))))),h=c.map((e=>t.measureText(e).width)),u=h.reduce(((t,e)=>t+e),0);let d=e+(i-u)/2;const p=this.tableCol.getTag(wt.gp.alphabet),m=p===gt.YI.RNA||p===gt.YI.DNA?ei.o.NUCLEOTIDE:ei.o.AA;for(let r=0;r<c.length;r++){const a=l[r];let u=kt.S$,p="rgb(255, 255, 255)";if(this.monomerLib)if(s){const t=this.monomerLib.getMonomerColors(m,a);u=t?.textcolor??u,p=t?.backgroundcolor??p}else u=this.monomerLib.getMonomerTextColor(m,a);s&&1==l.length&&(t.fillStyle=p,t.fillRect(e,n,i,o)),t.fillStyle=u,t.fillText(c[r],d,n+o/2,i),d+=h[r]}}finally{t.restore()}}onMouseMove(t,e){if(t.grid.dart!=this.gridCol?.grid.dart||t.gridColumn.dart!=this.gridCol?.dart||!t.tableColumn||!t.isTableCell)return!1;const n=t.tableColumn.getTag(wt.gp.alphabet),i=t.cell.value,o=t.grid.canvas.getBoundingClientRect(),r=t.bounds.right+o.left-4,a=t.bounds.bottom+o.top-4;if(!i||i==wt._S||i==ni)return s.tooltip.show(s.divText("gap"),r,a),!0;if(!this.monomerLib)return s.tooltip.show(s.divText("Monomer library is not available."),r,a),!0;const l=n===gt.YI.RNA||n===gt.YI.DNA?ei.o.NUCLEOTIDE:ei.o.AA,c=i.split(wt.ot).map((t=>t&&t!==wt._S&&t!==ni?this.monomerLib.getTooltip(l,t):s.divText("gap"))),h=s.divH(c,{style:{alignItems:"top"}}),u=Array.from(h.querySelectorAll("canvas"));if(u.length>2){const t=Math.floor(550/u.length);u.forEach((e=>{e.style.setProperty("max-width",`${t}px`,"important"),e.style.setProperty("max-height",`${t}px`,"important")}))}return s.tooltip.show(h,r,a),!0}async awaitRendered(t=1e4,e=`${t} timeout`){return Promise.resolve()}static getOrCreate(t){const[e,n,i]=(0,Gt.BG)(t);let o=i.rendererBack;return o||(o=i.rendererBack=new ii(e,n)),o}}class oi extends a.GridCellRenderer{get name(){return Wt.uF.MONOMER}get cellType(){return Wt.uF.MONOMER}get defaultHeight(){return 15}get defaultWidth(){return 40}render(t,e,n,i,o,r,s){ii.getOrCreate(r).render(t,e,n,i,o,r,s)}onMouseMove(t,e){ii.getOrCreate(t).onMouseMove(t,e)}}class ri{constructor(t,e,n=""){this.target=t,this.debugEnabled=e,this.prefix=n}error(t,e,n){return this.target.error(this.prefix+t,e,n)}warning(t,e){return this.target.warning(this.prefix+t,e)}info(t,e){return this.target.info(this.prefix+t,e)}debug(t,e){if(this.debugEnabled)return this.target.debug(this.prefix+t,e)}}class si extends Map{_onPropertyChanged=new h.Subject;get onPropertyChanged(){return this._onPropertyChanged}get fontSize(){const t=super.get("FontSize");return t&&!isNaN(t)?Number.parseInt(t):12}set fontSize(t){super.set("FontSize",t),this._onPropertyChanged.next("FontSize")}get maxMonomerLength(){const t=super.get("MaxMonomerLength");return"long"===t?null:parseInt(t)}set maxMonomerLength(t){const e=null===t?"long":t.toString();super.set("MaxMonomerLength",e),this._onPropertyChanged.next("MaxMonomerLength")}get tooltipWebLogo(){return super.get("TooltipWebLogo")}set tooltipWebLogo(t){super.set("TooltipWebLogo",t),this._onPropertyChanged.next("TooltipWebLogo")}get defaultSeparator(){return super.get("DefaultSeparator")}set defaultSeparator(t){if(1!==t.length)throw new Error("The separator must be of length one.");super.set("DefaultSeparator",t),this._onPropertyChanged.next("DefaultSeparator")}constructor(t){super(Object.entries(t))}}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(t){this._properties=t}_initialized=!1;get initialized(){return this._initialized}constructor(t={debug:!1}){super(),super._logger=new ri(super.logger,t.debug)}completeInit(t,e,n,i){this._seqHelper=t,this._monomerLib=e,this._monomerSets=n,this._rdKitModule=i,this._initialized=!0}handleErrorUI(t){const[e,n]=(0,Ct.AP)(t);r.shell.error(e),this.logger.error(e,void 0,n)}}var li=n(5999),ci={};ci.styleTagTransform=A(),ci.setAttributes=b(),ci.insert=g().bind(null,"head"),ci.domAPI=m(),ci.insertStyleElement=w(),d()(li.A,ci),li.A&&li.A.locals&&li.A.locals;var hi=n(6307);class ui extends a.Widget{seqCol;seqHelper;viewed=!1;wlViewer=null;constructor(t,e){super(s.divV([])),this.seqCol=t,this.seqHelper=e}async init(){const t=this.seqHelper.getSeqHandler(this.seqCol),e=io.properties.tooltipWebLogo,n=this.seqCol.getTag(ee.gp.tooltipWebLogo);!1===e||["false","off","disable","disabled"].includes(n)||(this.wlViewer=await this.seqCol.dataFrame.plot.fromType("WebLogo",{sequenceColumnName:this.seqCol.name,backgroundColor:0,positionHeight:"Entropy",positionWidth:t.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(t,e,n,i){const o=io.seqHelper.getSeqHandler(t);let r=null,s=null;for(let t=0;t<o.posList.length;++t)o.posList[t]==e&&(r=t),o.posList[t]==n&&(s=t);if(null===r&&null!==e)throw new Error(`Start position ${e} not found.`);if(null===s&&null!==n)throw new Error(`End position ${n} not found.`);if(o.posList.length<s)throw new Error(`End position ${s} exceeds positions length`);const a=i||`${t.name}: (${e??""}-${n??""})`;return o.getRegion(r,s,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(gt.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(t,e){this.urlParams=t,this.funcName=e}async init(t){this.data=t??pi;const e=this.data.df.getCol(this.data.colName);this.data.positionNames&&e.setTag(gt.gp.positionNames,this.data.positionNames),this.data.regions&&e.setTag(gt.gp.regions,JSON.stringify(this.data.regions)),await this.buildView()}async buildView(){await r.data.detectSemanticTypes(this.data.df),this.view=r.shell.addTableView(this.data.df),this.view.path=this.view.basePath=`func/${io.name}.${this.funcName}`;const t=await this.view.dataFrame.plot.fromType("WebLogo",{sequenceColumnName:this.data.colName});this.view.dockManager.dock(t,a.DOCK_TYPE.DOWN,null,"WebLogo",.35)}}class fi{call;seqHelper;inputs=new class{table;sequence;region;start;end;name};constructor(t,e){this.call=t,this.seqHelper=e;const n=t=>this.call.inputParams[t].property.description;this.inputs.table=s.input.table("Table",{value:this.call.inputParams.table.value??r.shell.tv.dataFrame});const i=this.call.inputParams.sequence.value??this.inputs.table.value.columns.bySemType(a.SEMTYPE.MACROMOLECULE);this.inputs.sequence=s.input.column("Sequence",{table:r.shell.tv.dataFrame,value:i,onValueChanged:this.sequenceInputChanged.bind(this),filter:t=>t.semType===a.SEMTYPE.MACROMOLECULE}),this.inputs.start=s.input.choice("Start",{onValueChanged:this.startInputChanged.bind(this)}),this.inputs.end=s.input.choice("End",{onValueChanged:this.endInputChanged.bind(this)}),this.inputs.region=s.input.choice("Region",{value:null,items:[],onValueChanged:this.regionInputChanged.bind(this)}),this.inputs.name=s.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 t in this.call.inputParams)s.tooltip.bind(this.inputs[t].captionLabel,n(t));this.sequenceInputChanged()}sequenceInputChanged(){const t=this.inputs.sequence.value;t&&this.seqHelper.getSeqHandler(t),this.updateRegionItems(),this.updateStartEndInputItems(),this.updateRegion(!0),this.updateNameInput()}fixRegion=!1;regionInputChanged(){this.fixRegion=!0;try{const t=this.inputs.region.stringValue,e=t?JSON.parse(t):null;if(null!==e)this.inputs.start.value=e?.start,this.inputs.end.value=e?.end;else{const t=this.seqHelper.getSeqHandler(this.inputs.sequence.value);this.inputs.start.value=t.posList[0],this.inputs.end.value=t.posList[t.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 t=this.inputs.sequence.value,e=t?this.seqHelper.getSeqHandler(t):null,n=this.inputs.start.input,i=this.inputs.end.input;for(let t=n.options.length-1;t>=0;--t)n.options.remove(t);for(let t=i.options.length-1;t>=0;--t)i.options.remove(t);for(const t of e?.posList??[]){const e=document.createElement("option"),o=document.createElement("option");e.text=o.text=t,e.value=o.value=t,n.options.add(e),i.options.add(o)}n.value=e?.posList[0]??"",i.value=e?.posList[e?.posList.length-1]??""}updateRegionItems(){const t=this.inputs.sequence.value,e=t?t.getTag(gt.gp.regions):null,n=e?JSON.parse(e):null,i=this.inputs.region.input;for(let t=i.options.length-1;t>=0;--t)i.options.remove(t);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 t of n){const e=document.createElement("option");e.text=`${t.name}: ${t.start}-${t.end}`,e.value=JSON.stringify(t),i.options.add(e)}}else this.inputs.region.root.style.display="none"}updateRegion(t){const e=this.inputs.start.stringValue??"",n=this.inputs.end.stringValue??"";if(!this.fixRegion){const t=this.inputs.region.input;t.selectedIndex=-1;for(let i=t.options.length-1;i>=0;--i){const o=t.options[i],r=JSON.parse(o.value);r&&e===r.start&&n===r.end&&(t.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 t=this.inputs.region.stringValue,e=t?JSON.parse(t):null,n=this.inputs.sequence.value,i=this.inputs.start.stringValue??"",o=this.inputs.end.stringValue??"";return null!=e?`${n.name}(${e.name}): ${e.start}-${e.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 t=this.inputs.name.stringValue;return""==t?null:t}dialog(){const t=s.inputs(Object.values(this.inputs),{style:{minWidth:"320px"}});s.dialog({title:"Get Region"}).add(t).onOK((()=>{(async()=>{const t=this.getParams();await this.call.func.prepare(t).call(!0)})().catch((t=>{io.handleErrorUI(t)}))})).show()}widget(){const t=s.inputs(Object.entries(this.inputs).filter((([t,e])=>!["table","sequence"].includes(t))).map((([t,e])=>e))),e=s.button("Get Region",(()=>{(async()=>{const t=this.getParams();await this.call.func.prepare(t).call(!0)})().catch((t=>{io.handleErrorUI(t)}))}));return a.Widget.fromRoot(s.divV([t,s.div(e)]))}}var gi=n(8754);async function yi(t,e,n,i,o){const r=await async function(t,e,n,i,o){const r=(0,vt.R)(e,o),s=o.getSeqHandler(e).getNewColumnFromList("ref",[n]),l=o.getSeqHandler(s).getSplitted(0),c=i===ft.IDENTITY?function(t,e){const n=e.columns.length,i=new Array(n),o=new Array(n),r=new Array(n);for(let s=0;s<n;++s){const n=e.columns.byIndex(s);i[s]=n.getRawData(),o[s]=n.categories.indexOf("");const a=s<t.length?t.getOriginal(s):wt._S;r[s]=n.categories.indexOf(a)}const s=a.Column.float("Identity",e.rowCount),l=s.getRawData();for(let n=0;n<e.rowCount;++n){l[n]=0;for(let e=0;e<t.length;++e)(i[e]?i[e][n]:0)===r[e]&&++l[n];l[n]/=t.length}return s}(l,r):i===ft.SIMILARITY?await async function(t,e,n){const i=e.columns.toList();return await(0,bt.uL)(i,t,n)}(l,r,o):null;if(null===c)throw new Error(`In bio library: Unknown sequence scoring method: ${i}`);return c.name=t.columns.getUnusedName(c.name),t.columns.add(c),c}(t,e,n,i,o);for(let t=0;t<r.length;t++)e.isNone(t)&&r.set(t,null,!1);return r}var bi=n(294),vi=n(330);const wi=OCL;var Ci=n(9099);class Ai{monomerSymbol;constructor(t){this.monomerSymbol=t}atoms;bonds;rGroups;get atomCount(){return this.atoms.count}get bondCount(){return this.bonds.count}shiftR1GroupToOrigin(){const t=this.rGroups.getAtomicIdx(1);if(null===t)return;const{x:e,y:n}=this.atoms.atomCoordinates[t];this.atoms.shift({x:-e,y:-n})}alignR2AlongX(){const t=this.rGroups.getAtomicIdx(2);if(null===t)throw new Error(`Cannot find R2 group for monomer ${this.monomerSymbol}`);const e=this.atoms.atomCoordinates[t],n=e.y/e.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(t){this.rGroups.deleteBondLineWithSpecifiedRGroup(t)}shiftCoordinates(t){this.atoms.shift(t)}rotateCoordinates(t){this.atoms.rotate(t)}getBondLines(){return this.bonds.getBondLines()}getAtomLines(){return this.atoms.atomLines}removeRGroups(t){this.rGroups.removeRGroups(t)}replaceRGroupWithAttachmentAtom(t,e){this.rGroups.replaceRGroupWithAttachmentAtom(t,e)}getAttachmentAtomByRGroupId(t){return this.rGroups.getAttachmentAtomIdByRGroupId(t)}shiftBonds(t){this.bonds.shift(t)}capRGroups(t){this.rGroups.capRGroups(t)}}var Si=n(6956);class xi{atoms;bonds;constructor(t,e,n){this.atoms=e,this.bonds=n,this.rGroupIdToAtomicIndexMap=t.getRGroupIdToAtomicIdxMap()}rGroupIdToAtomicIndexMap;rGroupBondPositionMap=new Map;getAtomicIdx(t){const e=this.rGroupIdToAtomicIndexMap.get(t);return void 0===e?null:e}removeRGroupsFromAtomBlock(t){t.forEach((t=>{if(void 0===this.rGroupIdToAtomicIndexMap.get(t))throw new Error(`Cannot find atomic index for R group ${t}`)}));const e=Array.from(this.rGroupIdToAtomicIndexMap.entries()).filter((([e,n])=>t.includes(e))).map((([t,e])=>e));this.atoms.deleteAtoms(e)}removeRGroups(t){this.removeRGroupsFromAtomBlock(t),t.forEach((t=>{const e=this.replaceRGroupInBondsByDummy(t);this.rGroupBondPositionMap.set(t,e)}))}replaceRGroupInBondsByDummy(t){const e=this.rGroupIdToAtomicIndexMap.get(t);if(this.rGroupBondPositionMap.has(t))throw new Error(`R group ${t} is already handled`);const n=this.bonds.getPositionsInBonds(e+1);if(0===n.length)throw new Error(`Cannot find position for R group ${t}`);if(n.length>1)throw new Error(`More than one position for R group ${t}`);const i=n[0];return this.bonds.replacePositionsInBondsByDummy([i]),this.bonds.removeAtomIdFromBonds(e+1),this.removeRGroupFromAtomicIdxMap(t,e),i}removeRGroupFromAtomicIdxMap(t,e){this.rGroupIdToAtomicIndexMap.delete(t);for(const[t,n]of this.rGroupIdToAtomicIndexMap)n>e&&this.rGroupIdToAtomicIndexMap.set(t,n-1)}deleteBondLineWithSpecifiedRGroup(t){const e=this.rGroupBondPositionMap.get(t);if(!e)throw new Error(`Cannot find position for R group ${t}`);const{bondLineIdx:n}=e;this.bonds.deleteBondLines([n]),this.rGroupBondPositionMap.delete(t),this.rGroupIdToAtomicIndexMap.delete(t),this.rGroupBondPositionMap.forEach((t=>{t.bondLineIdx>n&&(t.bondLineIdx-=1)}))}replaceRGroupWithAttachmentAtom(t,e){const n=this.rGroupBondPositionMap.get(t);if(!n)throw new Error(`Cannot find position for R group ${t}`);const{bondLineIdx:i,nodeIdx:o}=n;this.bonds.bondedAtoms[i][o]=e}getAttachmentAtomIdByRGroupId(t){const e=this.rGroupBondPositionMap.get(t);if(!e)throw new Error(`Cannot find position for R group ${t}`);const{bondLineIdx:n,nodeIdx:i}=e;return this.bonds.bondedAtoms[n][(i+1)%2]}capRGroups(t){this.rGroupIdToAtomicIndexMap.forEach(((e,n)=>{const i=t[n-1];i===Si.mP?(this.removeRGroups([n]),this.deleteBondLineWithSpecifiedRGroup(n)):this.atoms.replaceRGroupSymbolByElement(e,i)}))}}class Ei{coordinates=[];rawAtomLines=[];get count(){return this.coordinates.length}get atomCoordinates(){return this.coordinates}replaceRGroupSymbolByElement(t,e){this.rawAtomLines[t]=this.rawAtomLines[t].replace("R#",e)}deleteAtoms(t){this.coordinates=this.coordinates.filter(((e,n)=>!t.includes(n))),this.rawAtomLines=this.rawAtomLines.filter(((e,n)=>!t.includes(n)))}shift(t){this.coordinates=this.coordinates.map((e=>{const n=e.x+t.x,i=e.y+t.y;if(isNaN(n)||isNaN(i))throw new Error(`Cannot shift coordinates by ${t.x}, ${t.y}`);return{x:n,y:i}}))}rotate(t){this.coordinates=this.coordinates.map((e=>{const n=e.x,i=e.y,o=n*Math.cos(t)-i*Math.sin(t),r=n*Math.sin(t)+i*Math.cos(t);if(isNaN(o)||isNaN(r))throw new Error(`Cannot rotate coordinates by ${t}`);return{x:o,y:r}}))}}class Ti extends Ei{constructor(t){super(),this.rawAtomLines=t.getAtomLines(),this.coordinates=this.rawAtomLines.map((t=>({x:parseFloat(t.substring(0,10)),y:parseFloat(t.substring(10,20))})))}get atomLines(){return this.rawAtomLines.map(((t,e)=>{const n=this.coordinates[e];return`${n.x.toFixed(4).padStart(10," ")}${n.y.toFixed(4).padStart(10," ")}${t.substring(20)}`}))}}class Mi{bondedAtomPairs=[];rawBondLines=[];get count(){return this.bondedAtomPairs.length}get bondedAtoms(){return this.bondedAtomPairs}deleteBondLines(t){this.rawBondLines=this.rawBondLines.filter(((e,n)=>!t.includes(n))),this.bondedAtomPairs=this.bondedAtomPairs.filter(((e,n)=>!t.includes(n)))}getPositionsInBonds(t){const e=[];return this.bondedAtomPairs.forEach(((n,i)=>{n.forEach(((n,o)=>{n===t&&e.push({bondLineIdx:i,nodeIdx:o})}))})),e}replacePositionsInBondsByDummy(t,e){void 0===e&&(e=-1),t.forEach((t=>{const{bondLineIdx:n,nodeIdx:i}=t;this.bondedAtomPairs[n][i]=e}))}removeAtomIdFromBonds(t){this.bondedAtomPairs=this.bondedAtomPairs.map((e=>e.map((e=>e>t?e-1:e))))}shift(t){this.bondedAtomPairs=this.bondedAtomPairs.map((e=>e.map((e=>e+t))))}}class _i extends Mi{constructor(t){super(),this.rawBondLines=t.getBondLines(),this.bondedAtomPairs=this.rawBondLines.map((t=>[parseInt(t.substring(0,3)),parseInt(t.substring(3,6))]))}getBondLines(){return this.bondedAtomPairs.map(((t,e)=>{if(t.some((t=>-1===t)))throw new Error(`Bonded pair ${t} contains -1`);return`${t[0].toString().padStart(3," ")}${t[1].toString().padStart(3," ")}${this.rawBondLines[e].substring(6)}`}))}}class Ii extends Ai{constructor(t,e){super(e);const n=$e.getInstance(t);this.atoms=new Ti(n),this.bonds=new _i(n),this.rGroups=new xi(n,this.atoms,this.bonds),this.shiftMonomerToDefaultPosition()}}class Li extends Ei{molfileHandler;constructor(t){super(),this.molfileHandler=t,this.rawAtomLines=t.getAtomLines(),this.coordinates=this.getCoordinates()}getCoordinates(){const t=this.molfileHandler.x,e=this.molfileHandler.y;return Array.from(t).map(((t,n)=>({x:t,y:e[n]})))}get atomLines(){const t=/^(M V30 [^-]*)(-?\d+\.\d+)( )(-?\d+\.\d+)( -?\d+\.\d+.*)$/,e=/\sRGROUPS=\(\d+(\s+\d+)*\)/;return this.rawAtomLines.map(((n,i)=>{const o=this.coordinates[i],r=o.x.toFixed(4)+"00",s=o.y.toFixed(4)+"00";return n.replace(t,((t,e,n,i,o,a)=>e+r+i+s+a)).replace(e,"")}))}replaceRGroupSymbolByElement(t,e){super.replaceRGroupSymbolByElement(t,e);const n=this.rawAtomLines[t].substring(3).split(" ");n.length>7&&(this.rawAtomLines[t]=`M ${n.slice(0,7).join(" ")}`)}}class Ni extends Mi{molfileHandler;constructor(t){super(),this.molfileHandler=t,this.rawBondLines=t.getBondLines(),this.bondedAtomPairs=this.getBondedAtomPairs()}getBondedAtomPairs(){return this.molfileHandler.pairsOfBondedAtoms.map((t=>[t[0],t[1]]))}getBondLines(){const t=/^(M\s+V30\s+\d+\s+\d+\s+)(\d+)(\s+)(\d+)(.*)$/;return this.bondedAtomPairs.map(((e,n)=>{if(e.some((t=>-1===t)))throw new Error(`Bonded pair ${e} contains -1`);return this.rawBondLines[n].replace(t,((t,n,i,o,r,s)=>`${n}${e[0]}${o}${e[1]}${s}`))}))}}class Pi extends Ai{constructor(t,e){super(e);const n=$e.getInstance(t);this.atoms=new Li(n),this.bonds=new Ni(n),this.rGroups=new xi(n,this.atoms,this.bonds),this.shiftMonomerToDefaultPosition()}}class $i{static getInstance(t,e){if($e.isMolfileV2K(t))return new Ii(t,e);if($e.isMolfileV3K(t))return new Pi(t,e);throw new Error("Unsupported molfile version")}}class Ri{monomerSymbol;monomerIdx;helm;monomerLib;molfileWrapper;capGroupElements=[];static molfileV2KToV3KCache=new Map;constructor(t,e,n,i,o,r){this.monomerSymbol=t,this.monomerIdx=e,this.helm=n,this.monomerLib=r;const s=this.getLibraryMonomerObject();let a=s.molfile;$e.isMolfileV2K(a)&&(a=this.convertMolfileToV3KFormat(a,t,o)),this.molfileWrapper=$i.getInstance(a,t),this.capGroupElements=this.getCapGroupElements(s),this.removeRGroups(n.bondedRGroupsMap[e]),this.capRemainingRGroups(),this.shiftCoordinates(i)}get atomCount(){return this.molfileWrapper.atomCount}get bondCount(){return this.molfileWrapper.bondCount}convertMolfileToV3KFormat(t,e,n){if(Ri.molfileV2KToV3KCache.has(t))return Ri.molfileV2KToV3KCache.get(t);let i=null;try{if(i=n.get_mol(t,JSON.stringify({mergeQueryHs:!0})),i){const e=i.get_v3Kmolblock();return Ri.molfileV2KToV3KCache.set(t,e),e}throw new Error(`Cannot convert ${e} to molV3000`)}finally{i?.delete()}}getLibraryMonomerObject(){const t=this.helm.getPolymerTypeByMonomerIdx(this.monomerIdx),e=this.monomerLib.getMonomer(t,this.monomerSymbol);if(!e)throw new Error(`Monomer ${this.monomerSymbol} is not found in the library`);return e}getCapGroupElements(t){return t.rgroups.map((t=>(t.capGroupSmiles||t.capGroupSMILES).replace(/(\[|\]|\*|:|\d)/g,"")))}shiftCoordinates(t){this.molfileWrapper.shiftCoordinates(t)}getAtomLines(){return this.molfileWrapper.getAtomLines()}getBondLines(){return this.molfileWrapper.getBondLines()}removeRGroups(t){this.molfileWrapper.removeRGroups(t)}capRemainingRGroups(){this.molfileWrapper.capRGroups(this.capGroupElements)}replaceRGroupWithAttachmentAtom(t,e){this.molfileWrapper.replaceRGroupWithAttachmentAtom(t,e)}getAttachmentAtomByRGroupId(t){return this.molfileWrapper.getAttachmentAtomByRGroupId(t)}deleteBondLineWithSpecifiedRGroup(t){this.molfileWrapper.deleteBondLineWithSpecifiedRGroup(t)}shiftBonds(t){this.molfileWrapper.shiftBonds(t)}}class ki{rdKitModule;monomerLib;constructor(t,e,n){this.rdKitModule=e,this.monomerLib=n,this.helm=new Ci.f(t)}monomerWrappers=[];helm;addMonomer(t,e,n){if(t===wt.b9[gt.Hi.HELM])return;const i=this.monomerWrappers.length,o=new Ri(t,i,this.helm,n,this.rdKitModule,this.monomerLib);this.monomerWrappers.push(o)}getAtomNumberShifts(){const t=[];let e=0;return this.monomerWrappers.forEach((n=>{t.push(e),e+=n.getAtomLines().length})),t}restoreBondsBetweenMonomers(){this.helm.bondData.forEach((t=>{const e=t.map((t=>t.monomerIdx)),n=t.map((t=>t.rGroupId)),i=e.map((t=>this.monomerWrappers[t])),o=i[1].getAttachmentAtomByRGroupId(n[1]);i[0].replaceRGroupWithAttachmentAtom(n[0],o),i[1].deleteBondLineWithSpecifiedRGroup(n[1])}))}compileToMolfile(){const t=[],e=[],n=this.getAtomNumberShifts();this.monomerWrappers.forEach(((t,e)=>{t.shiftBonds(n[e])})),this.restoreBondsBetweenMonomers();const i=new bi.Cg;for(const[n,o]of $().enumerate(this.monomerWrappers)){const r=t.length,s=e.length;t.push(...n.getAtomLines()),e.push(...n.getBondLines());const a="RNA"==this.helm.getPolymerTypeByMonomerIdx(o)?Ft.o.NUCLEOTIDE:Ft.o.AA;i.set(o,{biotype:a,symbol:n.monomerSymbol,atoms:$().count(r).take(n.atomCount).toArray(),bonds:$().count(s).take(n.bondCount).toArray()})}const o=t.length,r=e.length;return{molfile:[this.getV3KHeader(o,r),this.getV3KAtomBlock(t),this.getV3KBondBlock(e),"M V30 END CTAB\nM END"].join("\n"),monomers:i}}getV3KHeader(t,e){return`\n Datagrok\n\n 0 0 0 0 0 0 0 0 0 0999 V3000\nM V30 BEGIN CTAB\nM V30 COUNTS ${t} ${e} 0 0 1`}getV3KAtomBlock(t){const e=/^(M V30 )(\d+)( .*)$/;return["M V30 BEGIN ATOM",...t.map(((t,n)=>{const i=n+1;return t.replace(e,((t,e,n,o)=>e+i+o))})),"M V30 END ATOM"].join("\n")}getV3KBondBlock(t){const e=/^(M V30 )(\d+)( .*)$/;return["M V30 BEGIN BOND",...t.map(((t,n)=>{const i=n+1;return t.replace(e,((t,e,n,o)=>e+i+o))})),"M V30 END BOND"].join("\n")}}class Oi{constructor(t){this.molfileHandler=$e.getInstance(t)}molfileHandler;get monomerSymbols(){return this.molfileHandler.atomTypes}getMonomerShifts(t){return{x:this.molfileHandler.x[t],y:this.molfileHandler.y[t]}}}class Hi{helmHelper;rdKitModule;monomerLib;constructor(t,e,n){this.helmHelper=t,this.rdKitModule=e,this.monomerLib=n}convertToSmiles(t){const e=t.dataFrame,n=this.getSmilesList(t),i=`smiles(${t.name})`,o=e?e.columns.getUnusedName(i):i;return a.Column.fromStrings(o,n.map((t=>null===t?"":t)))}getSmilesList(t){return this.convertToMolfileV3KColumn(t).toList().map((t=>a.chem.convert(t,a.chem.Notation.MolBlock,a.chem.Notation.Smiles)))}molV3KtoMolV3KOCL(t){try{if(!t)return"";return wi.Molecule.fromMolfile(t).toMolfileV3().replace("STERAC1","STEABS")}catch(t){const[e,n]=(0,Ct.AP)(t);return io.logger.error(e,void 0,n),""}}getMolV3000ViaOCL(t,e){const n=t.map((t=>{if(null===t)return"";const e=t.get_v3Kmolblock();return t.delete(),e})),i=new Array(n.length),o=a.TaskBarProgressIndicator.create("Handling chirality...");for(let t=0;t<n.length;t++){i[t]=this.molV3KtoMolV3KOCL(n[t]);const e=t/n.length*100;o.update(e,`${e?.toFixed(2)}% of molecules completed`)}return o.close(),a.Column.fromStrings(e,i)}convertToRdKitBeautifiedMolfileColumn(t,e,n,i){const o=t.dataFrame,r=this.convertToMolfileV3KColumn(t).toList().map((t=>{if(""===t)return null;const e=n.get_mol(t);return e?(e.set_new_coords(),e.normalize_depiction(1),e.straighten_depiction(!0),e):null})),s=`molfile(${t.name})`,l=o?o.columns.getUnusedName(s):s;return e?this.getMolV3000ViaOCL(r,l):a.Column.fromStrings(l,r.map((t=>{if(null===t)return"";const e=t.get_v3Kmolblock();return t.delete(),e})))}convertToMolfileV3KColumn(t){const e=t.dataFrame,n=this.convertToMolfileV3K(t.toList()).map((t=>t.molfile)),i=(0,vi.kA)(e,`molfileV3K(${t.name})`);return a.Column.fromList("string",i,n)}convertToMolfileV3K(t){const e=new Array(t.length);for(let n=0;n<t.length;++n){const i=t[n];if(!i){e[n]=bi.vF.createEmpty();continue}let o;try{o=this.getPolymerMolfile(i)}catch(t){const[e,n]=(0,Ct.AP)(t);io.logger.error(e,void 0,n),o=bi.vF.createEmpty()}e[n]=o}return e}getPolymerGraphColumn(t){const e=t.toList(),n=this.helmHelper.getMolfiles(e);return a.Column.fromStrings("mols",n)}getPolymerMolfile(t){const e=this.helmHelper.removeGaps(t),n=e.resHelm,i=new Map;for(const[t,n]of e.monomerMap?.entries()??[])i.set(n,t);const o=this.helmHelper.getMolfiles([n])[0],r=new Oi(o),s=new ki(n,this.rdKitModule,this.monomerLib);r.monomerSymbols.forEach(((t,e)=>{const n=r.getMonomerShifts(e);s.addMonomer(t,e,n)}));const a=s.compileToMolfile(),l=new bi.Cg;for(const[t,e]of a.monomers.entries()){const n=i.get(t);l.set(n,e)}return new bi.vF(a.molfile,l)}}class Gi{seqHelper;_column;_units;_notation;_defaultGapOriginal;notationProvider;_splitter=null;constructor(t,e){if(this.seqHelper=e,t.type!==a.TYPE.STRING)throw new Error(`Unexpected column type '${t.type}', must be '${a.TYPE.STRING}'.`);this._column=t;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[Ut.notationProvider]??null);const i=this.isFasta()?wt.b9[gt.Hi.FASTA]:this.isSeparator()?wt.b9[gt.Hi.SEPARATOR]:this.isHelm()?wt.b9[gt.Hi.HELM]:this.isCustom()?this.notationProvider?.defaultGapOriginal??wt.b9[gt.Hi.SEPARATOR]:void 0;if(null==i)throw new Error(`Unexpected defaultGapOriginal for notation '${this.notation}'`);if(this._defaultGapOriginal=i,!this.column.tags.has(gt.gp.aligned)||!this.column.tags.has(gt.gp.alphabet)||!this.column.tags.has(gt.gp.alphabetIsMultichar)&&!this.isHelm()&&this.alphabet===gt.YI.UN)if(this.isFasta())this.seqHelper.setUnitsToFastaColumn(this);else if(this.isSeparator()){const e=t.getTag(gt.gp.separator);this.seqHelper.setUnitsToSeparatorColumn(this,e)}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(gt.gp.alphabetIsMultichar))if(this.isHelm())this.column.setTag(gt.gp.alphabetIsMultichar,"true");else if(["UN"].includes(this.alphabet))throw new Error(`For column '${this.column.name}' of alphabet '${this.alphabet}' tag '${gt.gp.alphabetIsMultichar}' is mandatory.`);this.columnVersion=this.column.version,!this.isSeparator()||this.isCustom()&&this.notationProvider||t.temp.seqHandlerRefined||(this.refineSeparatorNotation(),t.temp.seqHandlerRefined=!0)}async refineSeparatorNotation(){const t=((t,e,n)=>{const i={};let o=!0,r=null;for(const e of t){const t=e?n(e):[];if(null===r?r=t.length:t.length!==r&&(o=!1),t.length>=3)for(const e of t)e in i||(i[e]=0),i[e]+=1}return{freq:i,sameLength:o}})([...new Set((this.column.length<100?$().count(0).take(Math.min(100,this.column.length)).map((t=>this.column.get(t))):this.column.categories.slice(0,100)).map((t=>t?t.substring(0,500):"")).filter((t=>0!==t.length)))],0,(t=>t.split(this.separator)));let e=!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:t,separator:this.separator}),r=(await o.call()).getOutputParamValue();e||=r}catch(t){console.error(t)}e&&(delete this.column.temp[Ut.seqHandler],this.column.fireValuesChanged())}static setTags(t){const e=t.column.meta.units;if([gt.Hi.FASTA,gt.Hi.SEPARATOR].includes(e)){if(!t.column.getTag(gt.gp.alphabet)&&0===Object.keys(t.stats.freq).length)throw new Error("Alphabet is empty and not annotated.");let e=t.column.getTag(gt.gp.aligned);null===e&&(e=t.stats.sameLength?"SEQ.MSA":"SEQ",t.column.setTag(gt.gp.aligned,e));let n=t.column.getTag(gt.gp.alphabet);if(null===n&&(n=(0,Ot.pc)(t.stats.freq,gt.q7),t.column.setTag(gt.gp.alphabet,n)),n===gt.YI.UN){const e=Object.keys(t.stats.freq).length,n=Object.keys(t.stats.freq).some((t=>t.length>1));t.column.setTag(gt.gp.alphabetSize,e.toString()),t.column.setTag(gt.gp.alphabetIsMultichar,n?"true":"false")}}else if(e===gt.Hi.HELM){let e=t.column.getTag(gt.gp.alphabet);null===e&&(e=(0,Ot.p0)(t.stats.freq,gt.q7,t.defaultGapOriginal),t.column.setTag(gt.gp.alphabet,e))}}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 t=this.column.getTag(gt.gp.separator)??void 0;if(this.notation===gt.Hi.SEPARATOR&&void 0===t)throw new Error(`Separator is mandatory for column '${this.column.name}' of notation '${this.notation}'.`);return t}get aligned(){const t=this.column.getTag(gt.gp.aligned);if(!t&&(this.isFasta()||this.isSeparator()))throw new Error("Tag aligned not set");return t}get alphabet(){const t=this.column.getTag(gt.gp.alphabet);if(!t&&(this.isFasta()||this.isSeparator()))throw new Error("Tag alphabet not set");return t}get defaultBiotype(){return this.alphabet===gt.YI.RNA||this.alphabet===gt.YI.DNA?Ft.o.NUCLEOTIDE:Ft.o.AA}get helmCompatible(){return this.column.getTag(gt.gp.isHelmCompatible)}getAlphabetSize(){if(this.notation==gt.Hi.HELM||this.alphabet==gt.YI.UN){const t=this.column.getTag(gt.gp.alphabetSize);let e;if(t)e=parseInt(t);else{const t=this.stats;e=Object.keys(t.freq).length}return e}switch(this.alphabet){case gt.YI.PT:return 20;case gt.YI.DNA:case gt.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===gt.Hi.HELM||this.alphabet===gt.YI.UN&&"true"===this.column.getTag(gt.gp.alphabetIsMultichar)}cached=!0;_splitted=null;columnVersion=null;getSplitted(t,e){if(this.cached&&void 0===e){this.column.version===this.columnVersion&&null!==this._splitted||(this.columnVersion=this.column.version,this._splitted=new Array(this.column.length));let e=this._splitted[t]?this._splitted[t].deref():void 0;if(!e){const n=this.column.get(t);e=this.splitter(n),this._splitted[t]=new WeakRef(e)}return e}{const n=this.column.get(t);return this.getSplitter(e)(n)}}getMonomerAtPosition(t,e,n){if(this.isCanonicalAlphabet&&this.isFasta()&&!this.getAlphabetIsMultichar()){const i=(this.column.get(t)??"")[e];return n?i===wt.b9[gt.Hi.FASTA]?wt._S:i??wt._S:i??""}const i=this.getSplitted(t);return e<0||e>=i.length?this.defaultGapOriginal:n?i.getCanonical(e):i.getOriginal(e)}getMonomersAtPosition(t,e){const n=this.column.length,i=new Array(n).fill(wt._S);if(this.isCanonicalAlphabet&&this.isFasta()&&!this.getAlphabetIsMultichar()){const o=this.column.categories,r=this.column.getRawData();for(let s=0;s<n;s++){const n=o[r[s]]??"";if(t<n.length){const o=n[t];i[s]=e?o===wt.b9[gt.Hi.FASTA]?wt._S:o??wt._S:o??""}}}else for(let o=0;o<n;o++){const n=this.getSplitted(o);t>=0&&t<n.length&&(i[o]=e?n.getCanonical(t):n.getOriginal(t))}return i}getValue(t,e){return this.column.get(t),new jt(t,this)}getHelm(t){let e;const n=this.column.get(t);return e=this.notation===gt.Hi.HELM?n:this.notation===gt.Hi.CUSTOM?this.notationProvider.getHelm(n,{}):this.getConverter(gt.Hi.HELM)(n),e}_stats=null;get isCanonicalAlphabet(){const t=this.alphabet;return t===gt.YI.DNA||t===gt.YI.RNA||t===gt.YI.PT}get stats(){if(null===this._stats){const t={};let e=!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&&(e=!1);for(let e=0;e<i.length;++e){const n=i.getCanonical(e);n in t||(t[n]=0),t[n]+=1}}this._stats={freq:t,sameLength:e}}return this._stats}_maxLength=null;get maxLength(){return null===this._maxLength&&(this._maxLength=0===this.column.length?0:$().count(0).take(this.column.length).map((t=>this.getSplitted(t).length)).reduce(((t,e)=>t>e?t:e),0)),this._maxLength}_posList=null;get posList(){if(null===this._posList){const t=this.column.getTag(gt.gp.positionNames);this._posList=t?t.split(gt.z1).map((t=>t.trim())):$().count(1).take(this.maxLength).map((t=>t.toString())).toArray()}return this._posList}isFasta(){return this.notation===gt.Hi.FASTA}isSeparator(){return this.notation===gt.Hi.SEPARATOR||!!this.separator}isFastaOrSeparator(){return this.isFasta()||this.isSeparator()}isHelm(){return this.notation===gt.Hi.HELM}isCustom(){return this.notation===gt.Hi.CUSTOM}isRna(){return this.alphabet===gt.YI.RNA}isDna(){return this.alphabet===gt.YI.DNA}isPeptide(){return this.alphabet===gt.YI.PT}isMsa(){return!!this.aligned&&this.aligned.toUpperCase().includes("MSA")}isHelmCompatible(){return"true"===this.helmCompatible}isGap(t){return!t||t===this._defaultGapOriginal}getNotation(){if(this.units.toLowerCase().startsWith(gt.Hi.FASTA))return gt.Hi.FASTA;if(this.units.toLowerCase().startsWith(gt.Hi.SEPARATOR))return gt.Hi.SEPARATOR;if(this.units.toLowerCase().startsWith(gt.Hi.HELM))return gt.Hi.HELM;if(this.units.toLowerCase().startsWith(gt.Hi.CUSTOM))return gt.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(t,e,n,i){const o=this.column,r=t.toLowerCase()+"("+o.name+")",s=n??o.dataFrame?.columns.getUnusedName(r)??r,l=a.Column.fromList("string",s,i??new Array(this.column.length).fill(""));if(l.semType=a.SEMTYPE.MACROMOLECULE,l.meta.units=t,t===gt.Hi.SEPARATOR){if(!e)throw new Error(`Notation '${gt.Hi.SEPARATOR}' requires separator value.`);l.setTag(gt.gp.separator,e)}l.setTag(a.TAGS.CELL_RENDERER,t===gt.Hi.HELM?"helm":"sequence");const c=o.getTag(gt.gp.aligned);c&&l.setTag(gt.gp.aligned,c);let h=o.getTag(gt.gp.alphabet);h||this.notation!==gt.Hi.HELM||t===gt.Hi.HELM||(h=gt.YI.UN),null!=h&&l.setTag(gt.gp.alphabet,h);let u=o.getTag(gt.gp.alphabetSize);null!=h&&u&&l.setTag(gt.gp.alphabetSize,u);const d=o.getTag(gt.gp.alphabetIsMultichar);return null!=h&&void 0!==d&&l.setTag(gt.gp.alphabetIsMultichar,d),t==gt.Hi.HELM&&(u=this.getAlphabetSize().toString(),l.setTag(gt.gp.alphabetSize,u)),l}getNewColumnFromList(t,e){return this.getNewColumn(this.notation,this.separator,t,e)}static unitsStringIsValid(t){return t=t.toLowerCase(),[gt.Hi.FASTA,gt.Hi.SEPARATOR,gt.Hi.HELM].some((e=>t.startsWith(e.toLowerCase())))}static getNewColumnFromParams(t,e,n){if(!Gi.unitsStringIsValid(n))throw new Error("Invalid format of 'units' parameter");const i=a.Column.fromList("string",e,new Array(t).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(t){let e=null;if(e=this.notationProvider?this.notationProvider.splitter:null,e)return e;if(this.units.toLowerCase().startsWith(gt.Hi.FASTA))return null===this.column.getTag(gt.gp.alphabet)||this.getAlphabetIsMultichar()?gt.J9:Ot.tm;if(this.units.toLowerCase().startsWith(gt.Hi.SEPARATOR))return(0,gt.dh)(this.separator,t);if(this.units.toLowerCase().startsWith(gt.Hi.HELM))return gt.qp;throw new Error(`Unexpected units ${this.units} .`)}split(t){return this.splitter(t)}getDistanceFunctionName(){if(!this.isFasta())throw new Error("Only FASTA notation is supported");if(this.isMsa())return ue.Z.HAMMING;switch(this.alphabet){case gt.YI.DNA:case gt.YI.RNA:case gt.YI.PT:}return ue.Z.LEVENSHTEIN}getDistanceFunction(){return ue.V[this.getDistanceFunctionName()]()}async checkHelmCompatibility(){if(this.column.tags.has(gt.gp.isHelmCompatible))return"true"===this.column.getTag(gt.gp.isHelmCompatible);const t=(await(0,bt.pj)()).getMonomerLib().getMonomerSymbolsByType("PEPTIDE"),e=new Set(t),n=((0,gt.dh)(this.separator),new Set),i=this.column.length,o=this.column.getRawData();for(let t=0;t<i;++t){const i=o[t];if(!(i in n)){n.add(i);const o=this.getSplitted(t);for(let t=0;t<o.length;++t){const n=o.getCanonical(t);if(!e.has(n))return this.column.setTag(gt.gp.isHelmCompatible,"false"),!1}}}return this.column.setTag(gt.gp.isHelmCompatible,"true"),!0}toFasta(t){return t===gt.Hi.FASTA}toSeparator(t){return t===gt.Hi.SEPARATOR}toHelm(t){return t===gt.Hi.HELM}convertHelmToFastaSeparator(t,e,n,i){i||(i=this.toFasta(e)?wt.b9[gt.Hi.FASTA]:wt.b9[gt.Hi.SEPARATOR]),n||(n=this.toFasta(e)?"":this.separator);const o=t.startsWith("RNA"),r=(0,gt.qp)(t),s=[];for(let t=0;t<r.length;++t){let n=r.getOriginal(t);if(o&&(n=n.replace(yn.EK,"$1")),n===wt.b9[gt.Hi.HELM])s.push(i);else if(this.toFasta(e)&&n.length>1){const t="["+n+"]";s.push(t)}else s.push(n)}return s.join(n)}convert(t,e){const n=this.getJoiner({notation:t,separator:e}),i=this.getNewColumn(t,e);return i.init((t=>{const e=this.getSplitted(t);return n(e)})),i}getRegion(t,e,n){const i=this.getNewColumn(this.notation,this.separator);i.name=n;const o=t??0,r=e??this.maxLength-1,s=this.getJoiner(),a=r-o+1,l=wt.b9[this.notation];i.init((t=>{const e=this.getSplitted(t),n=new Array(a);for(let t=0;t<a;++t){const i=o+t;n[t]=i<e.length?e.getOriginal(i):l}return s(new Ot.Mu(n,l))}));const c=t=>{const e=t.split(",").map((t=>t.trim())),n=new Array(a);for(let t=0;t<a;++t){const i=o+t;n[t]=i<e.length?e[i]:"?"}return n.join(gt.z1)},h=this.column.getTag(gt.gp.positionNames);h&&i.setTag(gt.gp.positionNames,c(h));const u=this.column.getTag(gt.gp.positionLabels);return u&&i.setTag(gt.gp.positionLabels,c(u)),i}_joiner=void 0;get joiner(){return this._joiner||(this._joiner=this.getJoiner()),this._joiner}getJoiner(t){const e=t?t.notation:this.notation,n=t?t.separator:this.separator;let i;const o=this;switch(e){case gt.Hi.FASTA:i=function(t){return o.joinToFasta(t,o.isHelm())};break;case gt.Hi.SEPARATOR:if(!n)throw new Error(`Separator is mandatory for notation '${e}'.`);i=function(t){return Fi(t,n,o.isHelm())};break;case gt.Hi.HELM:{const t=o.alphabet===gt.YI.DNA||o.alphabet===gt.YI.RNA,e=o.getHelmWrappers();i=function(n){return Di(n,e,t)};break}default:throw new Error(`Unexpected notation '${e}'.`)}return i}getConverter(t,e=void 0){if(t===gt.Hi.SEPARATOR&&!e)throw new Error(`Target separator is not specified for target units '${gt.Hi.SEPARATOR}'.`);const n=this;if(t===gt.Hi.FASTA)return function(t){return n.convertToFasta(t)};if(t===gt.Hi.HELM)return function(t){return n.convertToHelm(t)};if(t===gt.Hi.SEPARATOR)return function(t){return n.convertToSeparator(t,e)};throw new Error}static forColumn(t,e){let n=t.temp[Ut.seqHandler];return n&&n.columnVersion===t.version||(n=t.temp[Ut.seqHandler]=new Gi(t,e)),n}joinToFasta(t,e){const n=new Array(t.length);for(let i=0;i<t.length;++i){const o=t.getOriginal(i);let r=t.getOriginal(i);e&&(r=r.replace(yn.EK,"$1")),o===wt._S?r=wt.b9[gt.Hi.FASTA]:o===yn.q7?r="":r.length>1&&(r="["+r+"]"),n[i]=r}return n.join("")}convertToFasta(t){const e=this.splitter,n=this.isHelm()?this.splitterAsHelmNucl(t):e(t);return this.joinToFasta(n,this.isHelm())}convertToSeparator(t,e){return Fi(this.isHelm()?this.splitterAsHelmNucl(t):this.splitter(t),e,this.isHelm())}convertToHelm(t){if(this.notation==gt.Hi.HELM)return t;const e=this.getHelmWrappers(),n=t.startsWith("DNA")||t.startsWith("RNA");return Di(this.splitter(t),e,n)}splitterAsHelmNucl(t){const e=this.splitter(t),n=new Array(e.length),i=t.startsWith("DNA"),o=t.startsWith("RNA");for(let t=0;t<e.length;++t){let r=e.getOriginal(t);(i||o)&&(r=r.replace(yn.EK,"$1"),r=r===yn.q7?null:r),n[t]=r||null}return new Ot.Mu(n.filter((t=>!!t)),wt.b9[gt.Hi.HELM])}getRendererBack(t,e){const n=this.column.temp;let i=n.rendererBack;return i||(i=n.rendererBack=this.notationProvider.createCellRendererBack(t,e)),i}}function Fi(t,e,n){const i=new Array(t.length);for(let e=0;e<t.length;++e){const o=t.getCanonical(e);let r=t.getOriginal(e);n&&(r=r.replace(yn.EK,"$1")),o===wt._S?r=wt.b9[gt.Hi.SEPARATOR]:o===yn.q7&&(r=""),i[e]=r}return i.join(e)}function Di(t,e,n){const[i,o,r,s]=e,a=new Array(t.length);for(let e=0;e<t.length;++e){const i=t.getCanonical(e);let s=t.getOriginal(e);i===wt._S?s=wt.b9[gt.Hi.HELM]:(n&&(s=s.replace(yn.EK,"$1")),s=1===s.length?`${o}${s}${r}`:`${o}[${s}]${r}`),a[e]=s}return`${i}${a.join(".")}${s}`}class Bi{libHelper;rdKitModule;constructor(t,e){this.libHelper=t,this.rdKitModule=e}getSeqHandler(t){return Gi.forColumn(t,this)}getSeqMonomers(t){const e=this.getSeqHandler(t);return Object.keys(e.stats.freq)}async getHelmToMolfileConverter(t){const e=await(0,ke.b2)();return new Hi(e,this.rdKitModule,t)}helmToAtomicLevelSingle(t,e,n,i=!0){if(!t)return bi.vF.createEmpty();const o=e.convertToMolfileV3K([t])[0];if(!o||!o.molfile)return bi.vF.createEmpty();let r=null;try{let t=o.molfile;if(i){if(r=this.rdKitModule.get_mol(t),!r)return bi.vF.createEmpty();r.set_new_coords(),r.normalize_depiction(1),r.straighten_depiction(!0),t=r.get_v3Kmolblock()}return n&&(t=e.molV3KtoMolV3KOCL(t)),new bi.vF(t,o.monomers)}catch(t){const[e,n]=(0,Ct.AP)(t);return io.logger.error(e,void 0,n),bi.vF.createEmpty()}finally{r?.delete()}}async helmToAtomicLevel(t,e,n,i){const o=i??this.libHelper.getMonomerLib(),s=t.dataFrame,l=(0,vi.qj)(s,t.name),c=await this.getHelmToMolfileConverter(o),h=t.toList(),u=new Array(t.length),d=a.Func.find({package:"Chem",name:"beautifyMols"})[0],p=a.Func.find({package:"Chem",name:"convertToV3KViaOCL"})[0];for(let n=0;n<t.length;n++)u[n]=this.helmToAtomicLevelSingle(h[n],c,e&&!p,!d).molfile;if(d){const e=await d.apply({mols:u});if(e&&Array.isArray(e)&&e.length===t.length)for(let n=0;n<t.length;n++)e[n]&&(u[n]=e[n])}if(e&&p){const e=await p.apply({mols:u});if(e&&Array.isArray(e)&&e.length===t.length)for(let n=0;n<t.length;n++)e[n]&&(u[n]=e[n]);else r.shell.warning("OCL function returned an unexpected result")}const m=a.Column.fromStrings(l,u);return m.semType=a.SEMTYPE.MOLECULE,m.meta.units=a.UNITS.Molecule.MOLBLOCK,m.setTag(".sequence-src-col",t.name),{molCol:m,warnings:[]}}setUnitsToFastaColumn(t){if(t.column.semType!==a.SEMTYPE.MACROMOLECULE||t.column.meta.units!==gt.Hi.FASTA)throw new Error(`The column of notation '${gt.Hi.FASTA}' must be '${a.SEMTYPE.MACROMOLECULE}'.`);t.column.meta.units=gt.Hi.FASTA,Gi.setTags(t)}setUnitsToSeparatorColumn(t,e){if(t.column.semType!==a.SEMTYPE.MACROMOLECULE||t.column.meta.units!==gt.Hi.SEPARATOR)throw new Error(`The column of notation '${gt.Hi.SEPARATOR}' must be '${a.SEMTYPE.MACROMOLECULE}'.`);if(!e)throw new Error(`The column of notation '${gt.Hi.SEPARATOR}' must have the separator tag.`);t.column.meta.units=gt.Hi.SEPARATOR,t.column.setTag(gt.gp.separator,e),Gi.setTags(t)}setUnitsToHelmColumn(t){if(t.column.semType!==a.SEMTYPE.MACROMOLECULE)throw new Error(`The column of notation '${gt.Hi.HELM}' must be '${a.SEMTYPE.MACROMOLECULE}'`);t.column.meta.units=gt.Hi.HELM,Gi.setTags(t)}}async function Vi(t){let e="";try{if(!t||!t.value)return e="No sequence provided",{errorText:e,mol:""};if(!(t.cell&&t.cell.dart&&t.cell.dataFrame&&t.cell.column))return e="Atomic level conversion requeires a sequence column",{errorText:e,mol:""};if(![gt.Hi.FASTA,gt.Hi.SEPARATOR,gt.Hi.HELM].includes(t.cell.column.meta.units?.toLowerCase()??""))return e="Unsupported sequence notation. please use Bio | Polytool | Convert",{errorText:e,mol:""};const n=(await Tr()).getSeqHandler(t.cell.column);if(!n)return e="No sequence handler found",{errorText:e,mol:""};if((n.getSplitted(t.cell.rowIndex,50)?.length??100)>40)return e="Maximum number of monomers is 40",{errorText:e,mol:""};const i=a.Column.fromStrings("singleVal",[t.value]),o=a.DataFrame.fromColumns([i]);if(Object.entries(t.cell.column.tags).forEach((([t,e])=>{i.setTag(t,e)})),await $o(o,i,t.cell.column.meta.units===gt.Hi.HELM,!1),o.columns.length<2)return e="No structure generated",{errorText:e,mol:""};const r=o.columns.byIndex(1).get(0);return r?{errorText:"",mol:r}:(e="No structure generated",{errorText:e,mol:""})}catch(t){io.logger.error(t)}return e="No Structure generated",{errorText:e,mol:""}}const Wi="#333333",Ui="rgba(60, 177, 115, 0.1)",ji="rgba(240, 240, 240, 0.5)",qi="rgba(100, 100, 100, 0.3)";class zi{constructor(t=Zi.DEFAULT_TRACK_HEIGHT,e=Zi.MIN_TRACK_HEIGHT,n=""){this.ctx=null,this.visible=!0,this.title="",this.tooltipEnabled=!1,this.tooltipContent=null,this.height=t,this.defaultHeight=t,this.minHeight=e,this.title=n}init(t){this.ctx=t}getMonomerAt(t,e,n){return null}enableTooltip(t){this.tooltipEnabled=t}setTooltipContentGenerator(t){this.tooltipContent=t}getTooltipContent(t,e){if(!this.tooltipEnabled||!this.tooltipContent)return null;const n=this.getPositionData(t)??new Map;return this.tooltipContent(t,e,n)}getPositionData(t){return null}setVisible(t){this.visible=t}getHeight(){return this.visible?this.height:0}getDefaultHeight(){return this.defaultHeight}getMinHeight(){return this.minHeight}setHeight(t){this.height=Math.max(this.minHeight,t)}resetHeight(){this.height=this.defaultHeight}isVisible(){return this.visible}setTitle(t){this.title=t}getTitle(){return this.title}}class Yi extends zi{constructor(t=new Map,e=Zi.DEFAULT_TRACK_HEIGHT,n="",i="WebLogo"){super(e,Zi.DEFAULT_TRACK_HEIGHT,i),this.data=new Map,this.monomerLib=null,this.biotype="HELM_AA",this.hoveredPosition=-1,this.hoveredMonomer=null,this.data=t,this.visible=t.size>0}setHovered(t,e){this.hoveredPosition=t,this.hoveredMonomer=e}getPositionData(t){return this.data.get(t)||null}setupDefaultTooltip(){this.enableTooltip(!0),this.setTooltipContentGenerator(((t,e,n)=>this.createTooltipContent(t,e,n)))}createFrequencyTable(t){let e;switch(this.biotype){case"HELM_BASE":case"HELM_SUGAR":case"HELM_NUCLETIDE":e=Ft.o.NUCLEOTIDE;break;default:e=Ft.o.AA}const n=Array.from(t.values()).reduce(((t,e)=>t+e),0),i={};for(const[e,o]of t.entries())i[e]=Math.max(1,Math.round(o/n*100));const o=(0,hi.F)(i,e,this.monomerLib);return o.style.fontSize="11px",o.style.marginTop="4px",o}createTooltipContent(t,e,n){const i=[];if(i.push(s.divText(`Position: ${t+1}`,{style:{fontWeight:"bold",marginBottom:"6px",fontSize:"13px"}})),e&&(i.push(s.divText(`Monomer: ${e}`,{style:{marginBottom:"6px",fontSize:"13px"}})),n.has(e)&&i.push(s.divText(`${(100*n.get(e)).toFixed(2)}%`,{style:{marginBottom:"6px",fontSize:"13px"}}))),n&&n.size>0){const t=this.createFrequencyTable(n);i.push(t)}else i.push(s.divText("No data available",{style:{fontStyle:"italic",color:"#666"}}));const o=s.divV(i);return o.style.maxHeight="80vh",o}setMonomerLib(t){this.monomerLib=t}setBiotype(t){this.biotype=t}getMonomerAt(t,e,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=e,r=Array.from(i.entries()).sort(((t,e)=>e[1]-t[1])),s=r.reduce(((t,[e,n])=>t+n),0),a=this.height;let l=0;for(const[t,e]of r){const n=e*a/s;if(o>=l&&o<l+n)return t;l+=n}return null}updateData(t){this.data=t,this.visible=t.size>0}draw(t,e,n,i,o,r,s,a){if(!this.ctx||!this.visible||0===this.data.size)return;const l=Math.floor(n/r),c=i-4,h=e+2;for(let u=0;u<l;u++)this.drawWebLogoColumn(u,t,e,n,i,o,r,s,a,h,c)}drawWebLogoColumn(t,e,n,i,o,r,s,a,l,c,h){const u=r+t-1;if(u<0||u>=a)return;const d=this.data.get(u);if(!d||0===d.size)return;const p=e+t*s,m=s-2;r+t===l&&(this.ctx.fillStyle=Ui,this.ctx.fillRect(p,n,s,o)),this.ctx.fillStyle=ji,this.ctx.fillRect(p+1,c,m,h),this.drawLettersInColumn(u,p,m,c,h,d),this.drawColumnBorder(p,c,m,h)}drawLettersInColumn(t,e,n,i,o,r){const s=Array.from(r.entries()).sort(((t,e)=>e[1]-t[1])),a=s.reduce(((t,[e,n])=>t+n),0),l=Math.min(1,o/(a*o));let c=i;const h=i+o;for(const[i,r]of s){const s=r*o*l,a=Math.max(4,Math.floor(s));if(a<4)continue;const u=t===this.hoveredPosition&&i===this.hoveredMonomer,d=Math.min(a,h-c);if(d<4)break;this.drawLetter(i,e+1,c,n,d,u),c+=d}}drawColumnBorder(t,e,n,i){this.ctx.strokeStyle=qi,this.ctx.lineWidth=1,this.ctx.strokeRect(t+1,e,n,i)}drawLetter(t,e,n,i,o,r=!1){if(!this.ctx)return;const s=this.getMonomerBackgroundColor(t),a=this.getMonomerTextColor(t);this.ctx.fillStyle=s,this.ctx.fillRect(e,n,i,o),r&&(this.ctx.shadowColor="rgba(255, 255, 255, 0.8)",this.ctx.shadowBlur=8,this.ctx.strokeStyle="white",this.ctx.lineWidth=2,this.ctx.strokeRect(e,n,i,o),this.ctx.shadowBlur=0),this.drawLetterSeparators(e,n,i,o),this.drawLetterText(t,e,n,i,o,a)}drawLetterSeparators(t,e,n,i){this.ctx.strokeStyle="rgba(255, 255, 255, 0.4)",this.ctx.lineWidth=1,e+i<e+this.ctx.canvas.height&&(this.ctx.beginPath(),this.ctx.moveTo(t,e+i),this.ctx.lineTo(t+n,e+i),this.ctx.stroke())}drawLetterText(t,e,n,i,o,r){const s=Math.min(.8*o,.8*i);s>=7&&(this.ctx.fillStyle=r,this.ctx.font=`bold ${s}px Roboto, Roboto Local`,this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillText(t,e+i/2,n+o/2))}getMonomerBackgroundColor(t){if(this.monomerLib)try{const e=this.monomerLib.getMonomerColors(this.biotype,t);if(e&&e.backgroundcolor)return e.backgroundcolor}catch(t){console.warn("Error getting background color from monomerLib:",t)}return"#CCCCCC"}getMonomerTextColor(t){const e=this.getMonomerBackgroundColor(t);try{const t=a.Color.fromHtml(e),n=a.Color.getContrastColor(t);return a.Color.toHtml(n)}catch(t){return console.warn("Error calculating contrast color:",t),"#000000"}}}class Ki extends zi{constructor(t,e=Zi.DEFAULT_TRACK_HEIGHT,n="default",i="Conservation"){super(e,Zi.MIN_TRACK_HEIGHT,i),this.data=t,this.colorScheme=n,this.visible=t.length>0}updateData(t){this.data=t,this.visible=t.length>0}draw(t,e,n,i,o,r,s,a){if(!this.ctx||!this.visible||0===this.data.length)return;const l=Math.floor(n/r);for(let n=0;n<l;n++){const l=o+n;if(l>s)break;const c=t+n*r,h=r,u=c+h/2;l-1<this.data.length&&(this.drawConservationBar(l-1,c,h,u,e,i),l===a&&(this.ctx.fillStyle=Ui,this.ctx.fillRect(c,e,h,i)))}}drawConservationBar(t,e,n,i,o,r){if(!this.ctx)return;const s=this.data[t];this.ctx.fillStyle=ji,this.ctx.fillRect(e+2,o,n-4,r);let a="#3CB173";if("default"===this.colorScheme)s<.5?a="#E74C3C":s<.75&&(a="#F39C12");else if("rainbow"===this.colorScheme)a=s<.2?"#E74C3C":s<.4?"#FF7F00":s<.6?"#FFFF00":s<.8?"#00FF00":"#0000FF";else if("heatmap"===this.colorScheme){const t=Math.round(255*s);a=`rgb(255, ${t}, ${t})`}const l=s*r;this.ctx.fillStyle=a,this.ctx.fillRect(e+2,o+r-l,n-4,l),this.ctx.strokeStyle=qi,this.ctx.lineWidth=1,this.ctx.strokeRect(e+2,o,n-4,r),n>20&&(this.ctx.fillStyle=Wi,this.ctx.font="9px monospace",this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillText(`${Math.round(100*s)}%`,i,o+r/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(t,e){this.gridColumn=e,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:t.x||0,y:t.y||0,width:t.width||0,height:t.height||0,windowStartPosition:t.windowStartPosition||1,positionWidth:t.positionWidth||15,totalPositions:t.totalPositions||5e3,headerHeight:t.headerHeight||Xi.BASE,sliderHeight:t.sliderHeight||Zi.SLIDER_HEIGHT,currentPosition:t.currentPosition||1,cellBackground:void 0===t.cellBackground||t.cellBackground,sliderColor:t.sliderColor||"rgba(220, 220, 220, 0.4)",onPositionChange:t.onPositionChange||((t,e)=>{}),onHeaderHeightChange:t.onHeaderHeightChange||(()=>{}),...t},this.eventElement=s.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 t=this.config.headerHeight,e=this.getTrack("weblogo"),n=this.getTrack("conservation");if(this.tracks.forEach((t=>{t.setVisible(!1),t.setHeight(Zi.DEFAULT_TRACK_HEIGHT)})),!(t<Xi.WITH_TITLE()||t<Xi.WITH_WEBLOGO()))if(t<Xi.WITH_BOTH()){if(e){e.setVisible(!0);const n=t-Xi.WITH_WEBLOGO();e.setHeight(Zi.DEFAULT_TRACK_HEIGHT+n)}}else{if(e&&e.setVisible(!0),n&&n.setVisible(!0),e&&t>Xi.WITH_BOTH()){const n=t-Xi.WITH_BOTH();e.setHeight(Zi.DEFAULT_TRACK_HEIGHT+n)}this.userSelectedTracks&&(this.tracks.forEach(((t,e)=>{this.userSelectedTracks[e]||t.setVisible(!1)})),t<Xi.WITH_WEBLOGO()&&e&&e.setVisible(!1),t<Xi.WITH_BOTH()&&n&&n.setVisible(!1))}}drawTrackButtons(){if(!this.ctx||this.config.width<280)return;this.trackButtons=[];const t=this.getTrack("conservation"),e=this.getTrack("weblogo"),n=t?.isVisible()??!1,i=e?.isVisible()??!1;let o=this.config.width-16;const r=this.config.headerHeight>=Xi.WITH_TITLE()?(Zi.TITLE_HEIGHT-14)/2:2;n&&i||(!n&&t&&(o-=70,this.drawTrackButton("conservation","Conservation",o,r,70,14),o-=4),!i&&e&&(o-=70,this.drawTrackButton("weblogo","WebLogo",o,r,70,14)))}drawTrackButton(t,e,n,i,o,r,s=!1){this.ctx&&(this.trackButtons.push({id:t,label:e,x:n,y:i,width:o,height:r}),this.ctx.fillStyle=s?"rgba(100, 150, 200, 0.8)":"rgba(240, 240, 240, 0.8)",this.ctx.fillRect(n,i,o,r),this.ctx.strokeStyle=s?"rgba(70, 120, 170, 0.8)":"rgba(180, 180, 180, 0.8)",this.ctx.lineWidth=1,this.ctx.strokeRect(n,i,o,r),this.ctx.fillStyle=s?"#ffffff":"#666666",this.ctx.font="9px Roboto, Roboto Local",this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillText(e,n+o/2,i+r/2))}handleTrackButtonClick(t,e){for(const n of this.trackButtons)if(t>=n.x&&t<=n.x+n.width&&e>=n.y&&e<=n.y+n.height)return this.snapToTrackHeight(n.id),!0;return!1}isInsideColumnHeaderArea(t,e){return e<(this.config.headerHeight>=Xi.WITH_TITLE()?Zi.TITLE_HEIGHT:0)}snapToTrackHeight(t){let e;if("weblogo"===t)e=Xi.WITH_WEBLOGO();else{if("conservation"!==t)return;e=Xi.WITH_BOTH()}this.userSelectedTracks||(this.userSelectedTracks={},this.tracks.forEach(((t,e)=>{this.userSelectedTracks[e]=!1}))),"conservation"===t?(this.userSelectedTracks.weblogo=!0,this.userSelectedTracks.conservation=!0):"weblogo"===t&&(this.userSelectedTracks.weblogo=!0),this.config.onHeaderHeightChange&&this.config.onHeaderHeightChange(e),window.requestAnimationFrame((()=>this.redraw()))}resetToAutoMode(){this.userSelectedTracks=null;const t=this.tracks.size>0?Xi.WITH_BOTH():Xi.BASE;this.config.onHeaderHeightChange&&this.config.onHeaderHeightChange(t),window.requestAnimationFrame((()=>this.redraw()))}drawColumnTitle(t,e,n,i){this.ctx&&i&&this.config.headerHeight>=Xi.WITH_TITLE()&&(this.ctx.fillStyle="rgba(255, 255, 255, 0.95)",this.ctx.fillRect(t,e,n,Zi.TITLE_HEIGHT),this.ctx.fillStyle=Wi,this.ctx.font="bold 13px Roboto, Roboto Local",this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillText(i,t+n/2,e+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((t=>{t instanceof Yi&&t.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(t,e,n,i){this.dataFrame=t,this.seqColumn=e,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(t){if(!this.isValid)return;const{x:e,y:n}=this.getCoords(t),i=this.config.positionWidth,o=Math.floor(e/i),r=this.config.windowStartPosition+o-1;if(r<0||r>=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 h=null,u=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 f=c;for(const{id:t,track:e}of d){const i=f-e.getHeight();if(n>=i&&n<f){h=t,u=n-i;break}f=i-Zi.TRACK_GAP}let g=null;if(h){const t=this.tracks.get(h);t&&(g=t.getMonomerAt(e,u,r))}if((this.previousHoverPosition!==r||this.previousHoverTrack!==h||this.previousHoverMonomer!==g)&&(this.previousHoverPosition=r,this.previousHoverTrack=h,this.previousHoverMonomer=g,h)){const t=this.tracks.get(h);t instanceof Yi&&(t.setHovered(r,g),window.requestAnimationFrame((()=>this.redraw())))}if((r!==this.currentHoverPosition||h!==this.currentHoverTrack||g!==this.currentHoverMonomer)&&(this.currentHoverPosition=r,this.currentHoverTrack=h,this.currentHoverMonomer=g,h)){const e=this.tracks.get(h);if(e){const n=e.getTooltipContent(r,g);if(n)return void s.tooltip.show(n,t.clientX+16,t.clientY+16)}}h&&g||(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,s.tooltip.hide()}draw(t,e,n,i,o,r,s,a){if(Object.assign(this.config,{x:t,y:e,width:n,height:i,currentPosition:o,windowStartPosition:r}),!this.isValid)return void(this.eventElement.style.display="none");this.ctx.save(),this.ctx.clearRect(t,e,n,i),this.ctx.translate(t,e),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,h=c-Zi.DOTTED_CELL_HEIGHT,u=h-Zi.TRACK_GAP,d=[],p=[],m=this.getTrack("weblogo");m&&m.isVisible()&&p.push({id:"weblogo",track:m});const f=this.getTrack("conservation");f&&f.isVisible()&&p.push({id:"conservation",track:f});let g=u;for(const{track:t}of p){const e=t.getHeight(),i=g-e;t.draw(0,i,n,e,this.config.windowStartPosition,this.config.positionWidth,this.config.totalPositions,this.config.currentPosition),d.unshift({y:i,height:e}),g=i-Zi.TRACK_GAP}if(this.drawDottedCells(0,h,n,Zi.DOTTED_CELL_HEIGHT,c),d.push({y:h,height:Zi.DOTTED_CELL_HEIGHT}),this.config.currentPosition>=1&&this.config.currentPosition<=this.config.totalPositions){const t=this.config.positionWidth,e=this.config.currentPosition-this.config.windowStartPosition;if(e>=0&&e<Math.floor(n/t)){const n=e*t+t/2;for(let t=0;t<d.length-1;t++){const e=d[t],i=d[t+1];this.ctx.strokeStyle="rgba(60, 177, 115, 0.4)",this.ctx.lineWidth=1,this.ctx.beginPath(),this.ctx.moveTo(n,e.y+e.height),this.ctx.lineTo(n,i.y),this.ctx.stroke()}}}this.drawTrackButtons(),this.ctx.restore(),s.preventDefault(),this.setupEventElement()}drawDottedCells(t,e,n,i,o){if(!this.ctx)return;const r=this.config.totalPositions,s=this.config.positionWidth,a=this.config.currentPosition,l=this.config.windowStartPosition,c=Math.floor(n/s),h=e+Zi.TOP_PADDING;this.drawSlider(t,o,n);for(let n=0;n<c;n++){const c=l+n;if(c>r)break;const u=t+n*s,d=s,p=u+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(u,e,d,i),this.ctx.strokeStyle="rgba(220, 220, 220, 0.7)",this.ctx.beginPath(),this.ctx.moveTo(u,e),this.ctx.lineTo(u,o),this.ctx.stroke()),this.ctx.fillStyle="#999999",this.ctx.beginPath(),this.ctx.arc(p,h+5,1,0,2*Math.PI),this.ctx.fill(),(c===a||(1===c||c%10==0)&&Math.abs(c-a)>1)&&(this.ctx.fillStyle=Wi,this.ctx.font="12px monospace",this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillText(c.toString(),p,h+15)),c===a&&(this.ctx.fillStyle="rgba(60, 177, 115, 0.2)",this.ctx.fillRect(u,e,d,i))}}drawSlider(t,e,n){if(!this.ctx)return;this.ctx.fillStyle=this.config.sliderColor,this.ctx.fillRect(t,e,n,Zi.SLIDER_HEIGHT);const i=Math.floor(n/this.config.positionWidth),o=this.config.windowStartPosition,r=this.config.totalPositions-i,s=this.sliderWidth,a=r<=0?0:(o-1)/r*(n-s),l=r<=0?n:s;if(this.ctx.fillStyle="rgba(150, 150, 150, 0.5)",this.ctx.fillRect(t+a,e,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(t+o-1,e-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(t){const e=this.canvas.getBoundingClientRect();return{x:t.clientX-e.left-this.config.x,y:t.clientY-e.top-this.config.y}}isInHeaderArea(t){const{x:e,y:n}=this.getCoords(t);return e>=0&&e<=this.config.width&&n>=0&&n<=this.config.headerHeight}get positionWidth(){return this.config.positionWidth}set positionWidth(t){this.config.positionWidth=t}isInSliderArea(t){const{y:e}=this.getCoords(t),n=this.config.headerHeight-Zi.SLIDER_HEIGHT;return e>n&&e<n+Zi.SLIDER_HEIGHT}get sliderWidth(){const t=this.config.width/this.config.totalPositions*(this.config.width/this.config.positionWidth);return Math.max(t,20)}isInSliderDraggableArea(t){const{x:e,y:n}=this.getCoords(t),i=this.config.headerHeight-Zi.SLIDER_HEIGHT,o=Math.floor(this.config.width/this.config.positionWidth),r=this.config.windowStartPosition,s=this.config.totalPositions-o,a=s<=0?0:(r-1)/s*(this.config.width-this.sliderWidth);return n>i&&n<i+Zi.SLIDER_HEIGHT&&e>=a&&e<a+this.sliderWidth}setupEventListeners(){this.eventElement.addEventListener("mousemove",(t=>{this.isValid&&(this.isInSliderDraggableArea(t)?this.eventElement.style.cursor="grab":this.isInSliderArea(t)||this.isInHeaderArea(t)?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(t){if(!(this.isValid&&this.dataFrame&&this.seqColumn&&this.seqHandler))return;const{x:e,y:n}=this.getCoords(t);if(this.handleTrackButtonClick(e,n))return;if(this.isInsideColumnHeaderArea(e,n))return;const i=this.config.positionWidth,o=Math.floor(e/i),r=this.config.windowStartPosition+o-1;if(r<0||r>=this.config.totalPositions)return;const s=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<s)return;let c=null,h=0;const u=[],d=this.getTrack("weblogo");d&&d.isVisible()&&u.push({id:"weblogo",track:d});const p=this.getTrack("conservation");p&&p.isVisible()&&u.push({id:"conservation",track:p});let m=l;for(const{id:t,track:e}of u){const i=m-e.getHeight();if(n>=i&&n<m){c=t,h=n-i;break}m=i-Zi.TRACK_GAP}if(c){const n=this.tracks.get(c);if(n){const i=n.getMonomerAt(e,h,r);if(i){if(this.onSelectionCallback)return void this.onSelectionCallback(r,i);this.selectRowsWithMonomerAtPosition(r,i),t.stopPropagation(),t.stopImmediatePropagation()}}}}selectRowsWithMonomerAtPosition(t,e){if(this.dataFrame&&this.seqHandler)try{const n=this.dataFrame.selection,i=this.seqHandler.getMonomersAtPosition(t,!0);n.init((t=>i[t]===e))}catch(t){console.error("Error selecting rows:",t)}}init(){if(this.canvas=this.config.canvas,!this.canvas)return void console.error("Canvas not found");const t=this.canvas.getContext("2d");t?(this.ctx=t,this.tracks.forEach((e=>e.init(t)))):console.error("Failed to get 2D context from canvas")}addTrack(t,e){this.ctx&&e.init(this.ctx),this.tracks.set(t,e)}removeTrack(t){this.tracks.delete(t)}getTrack(t){return this.tracks.get(t)}updateTrack(t,e){const n=this.getTrack(t);n&&e(n)}get isValid(){const t=this.gridColumn,e=t?.grid,n=e?.horzScroll?.min||0,i=e?.horzScroll?.max||1e7;return!!this.canvas&&!!this.ctx&&this.config.height>=Xi.WITH_TITLE()&&e&&(Qi(t.left??0,n,i)||Qi(t.right??1/0,n,i))}handleMouseDown(t){if(!this.isValid)return;const{x:e}=this.getCoords(t);this.isInSliderDraggableArea(t)&&(this.state.isDragging=!0,this.state.dragStartX=e,this.handleSliderDrag(e),t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation())}handleMouseWheel(t){if(this.isValid&&this.isInHeaderArea(t)){t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation();const e=t.shiftKey?Math.sign(t.deltaY):Math.sign(t.deltaX||t.deltaY),n=t.shiftKey?3:1,i=this.config.windowStartPosition+e*n,o=Math.floor(this.config.width/this.config.positionWidth),r=this.config.totalPositions-o+1;this.config.windowStartPosition=Math.max(1,Math.min(r,i)),"function"==typeof this.config.onPositionChange&&this.config.onPositionChange(this.config.currentPosition,this.getWindowRange())}}handleMouseMove(t){if(!this.state.isDragging||!this.isValid)return;const e=this.canvas.getBoundingClientRect(),n=t.clientX-e.left-this.config.x;this.handleSliderDrag(n),t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation()}handleKeyDown(t){if(this.isValid&&!(this.config.currentPosition<1)&&document.activeElement?.contains(this.eventElement)&&"block"===this.eventElement.style.display){if("ArrowLeft"===t.key||"ArrowRight"===t.key){t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation();const e="ArrowLeft"===t.key?-1:1,n=Math.min(Math.max(this.config.currentPosition+e,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=e<0?n:Math.max(1,n-i+1))}else{if("Escape"!==t.key)return;this.config.currentPosition=-2,t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation()}"function"==typeof this.config.onPositionChange&&this.config.onPositionChange(this.config.currentPosition,this.getWindowRange())}}handleMouseUp(){this.state.isDragging=!1}handleSliderDrag(t){if(!this.isValid)return;const e=this.sliderWidth,n=this.config.width-e,i=Math.max(0,Math.min(this.config.width,t)),o=Math.floor(this.config.width/this.config.positionWidth),r=Math.floor(this.config.width/this.config.positionWidth),s=this.config.totalPositions-r,a=Math.max(0,i-e/2)/n*s;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(t){this.config.headerHeight=t}handleClick(t){if(!this.isValid)return;t.clientX,this.canvas.getBoundingClientRect().left,t.clientY,this.canvas.getBoundingClientRect().top;const{x:e,y:n}=this.getCoords(t);if(this.handleTrackButtonClick(e,n))return t.preventDefault(),void t.stopPropagation();if(!this.isInsideColumnHeaderArea(e,n)&&n<this.config.headerHeight-Zi.SLIDER_HEIGHT&&n>=0){const t=this.config.positionWidth,n=Math.round(e/t-.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(t){Object.assign(this.config,t),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(t){this.config.currentPosition=Math.max(1,Math.min(this.config.totalPositions,t)),"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(t,e,n){return t>=e&&t<=n}class to{static conservationCache=new a.LruCache(100);static webLogoCache=new a.LruCache(100);static lastInvalidationTime=0;static CHUNK_SIZE=50;static clearAllCaches(){to.conservationCache=new a.LruCache(100),to.webLogoCache=new a.LruCache(100),to.lastInvalidationTime=Date.now()}static getLastInvalidationTime(){return to.lastInvalidationTime}static getChunkCacheKey(t,e,n){const i=t.dataFrame;return`${i.id}_${t.name}_f${i.filter.version}_${e}_${n}`}static getConservationChunk(t,e,n,i){return to.conservationCache.getOrCreate(i,(()=>{const o=to.getWebLogoChunk(t,e,n,i),r=new Array(n-e).fill(0);for(let i=e;i<n;i++){const n=o.get(i);if(!n||0===n.size)continue;let s=0,a=0;const l=t.defaultGapOriginal;for(const[t,e]of n.entries())t&&t!==l&&(s+=e,e>a&&(a=e));r[i-e]=s>0?a/s:0}return r}))}static getWebLogoChunk(t,e,n,i){return to.webLogoCache.getOrCreate(i,(()=>{const i=t.column.dataFrame,o=new Map,r=i.filter.trueCount;if(r<=1)return o;for(let t=e;t<n;t++)o.set(t,new Map);const s=i.filter,a=1/r;for(let i=-1;-1!==(i=s.findNext(i,!0));){const r=t.getSplitted(i).getOriginalRegion(e,n);if(0!==r.length)for(let t=0;t<r.length;t++){const n=r[t],i=o.get(e+t);i.set(n,(i.get(n)||0)+a)}}return o}))}static getConservationForViewport(t,e,n,i){const o=new Array(i).fill(0),r=Math.floor(e/to.CHUNK_SIZE)*to.CHUNK_SIZE,s=Math.ceil(n/to.CHUNK_SIZE)*to.CHUNK_SIZE;for(let e=r;e<s;e+=to.CHUNK_SIZE){const n=Math.min(e+to.CHUNK_SIZE,i),r=to.getChunkCacheKey(t.column,e,n),s=to.getConservationChunk(t,e,n,r);for(let t=0;t<s.length&&e+t<i;t++)o[e+t]=s[t]}return o}static getWebLogoForViewport(t,e,n,i){const o=new Map,r=Math.floor(e/to.CHUNK_SIZE)*to.CHUNK_SIZE,s=Math.ceil(n/to.CHUNK_SIZE)*to.CHUNK_SIZE;for(let e=r;e<s;e+=to.CHUNK_SIZE){const n=Math.min(e+to.CHUNK_SIZE,i),r=to.getChunkCacheKey(t.column,e,n),s=to.getWebLogoChunk(t,e,n,r);for(const[t,e]of s.entries())t<i&&o.set(t,e)}return o}}class eo extends Yi{seqHandler;maxLength;lastViewportStart=-1;lastViewportEnd=-1;lastInvalidationTime=0;forceNextUpdate=!1;constructor(t,e,n=45,i="WebLogo"){super(new Map,n,"",i),this.seqHandler=t,this.maxLength=e,this.visible=t.column.dataFrame.filter.trueCount>1}forceUpdate(){this.forceNextUpdate=!0}resetViewportTracking(){this.lastViewportStart=-1,this.lastViewportEnd=-1}updateForViewport(t,e){const n=to.getLastInvalidationTime(),i=n>this.lastInvalidationTime;if(!(Math.abs(this.lastViewportStart-t)>=10||Math.abs(this.lastViewportEnd-e)>=10||i||this.forceNextUpdate))return;this.forceNextUpdate=!1,this.lastViewportStart=t,this.lastViewportEnd=e,this.lastInvalidationTime=n;const o=Math.max(0,t-20),r=Math.min(this.maxLength,e+20),s=to.getWebLogoForViewport(this.seqHandler,o,r,this.maxLength);this.updateData(s)}draw(t,e,n,i,o,r,s,a){const l=Math.ceil(n/r)+2,c=Math.min(o+l,s);this.updateForViewport(o-1,c-1),super.draw(t,e,n,i,o,r,s,a)}}class no extends Ki{seqHandler;maxLength;lastViewportStart=-1;lastViewportEnd=-1;lastInvalidationTime=0;forceNextUpdate=!1;constructor(t,e,n=45,i="default",o="Conservation"){super([],n,i,o),this.seqHandler=t,this.maxLength=e,this.visible=t.column.dataFrame.filter.trueCount>1}forceUpdate(){this.forceNextUpdate=!0}resetViewportTracking(){this.lastViewportStart=-1,this.lastViewportEnd=-1}updateForViewport(t,e){const n=to.getLastInvalidationTime(),i=n>this.lastInvalidationTime;if(!(Math.abs(this.lastViewportStart-t)>=10||Math.abs(this.lastViewportEnd-e)>=10||i||this.forceNextUpdate))return;this.forceNextUpdate=!1,this.lastViewportStart=t,this.lastViewportEnd=e,this.lastInvalidationTime=n;const o=Math.max(0,t-20),r=Math.min(this.maxLength,e+20),s=to.getConservationForViewport(this.seqHandler,o,r,this.maxLength);this.updateData(s)}draw(t,e,n,i,o,r,s,a){const l=Math.ceil(n/r)+2,c=Math.min(o+l,s);this.updateForViewport(o-1,c-1),super.draw(t,e,n,i,o,r,s,a)}}const io=new ai;async function oo(){return await dn.getInstance()}class ro{_palette;constructor(t){this._palette=t}get(t){return this._palette[t]}}let so=null;async function ao(){null===so&&(so=async function(){const t="Bio: _package.initBio()";io.logger.debug(`${t}, start`);const e=window.performance.now(),n=await(0,Pt.j)(),i=await io.getProperties(),o=new si(i);io.properties=o;const s=await dn.getInstance(),l=await(0,Nt.ub)();l.explicit&&(l.explicit=[],await(0,Nt.Eu)(l)),await s.awaitLoaded(1/0),s.initialLoadCompleted||await s.loadMonomerLib(),s.loadMonomerSets();const c=s.getMonomerLib(),u=s.getMonomerSets(),d=window.performance.now();io.logger.debug(`${t}, loading ET: ${d-e} ms`);const p=new Bi(s,n);io.completeInit(p,c,u,n),io.logger.debug(`${t}, end`),function(){const t=t=>{setTimeout((()=>{if(t.isDetached)return;const e=t.dataFrame;if(!e)return;const n=e.columns.bySemTypeAll(a.SEMTYPE.MACROMOLECULE);for(const i of n){let n=null;try{n=io.seqHelper.getSeqHandler(i)}catch(t){continue}if(!n)continue;if(n.isHelm()||n.alphabet===gt.YI.UN)continue;const o=t.col(i.name);if(!o)continue;let s=!!t.tableView&&Array.from(t.tableView.viewers).some((t=>"Sequence Position Statistics"===t.type));if(n.isMsa()){const l=(t,e)=>Number.isNaN(t)?e:t,c=()=>l(Math.max(Number.parseInt(i.getTag(gt.gp.positionShift)??"0"),0),0)+1,u=()=>l(Number.parseInt(i.getTag(gt.gp.selectedPosition)??"-2"),-2),d=()=>kt.Jy.getFontSettings(i).fontWidth;let p=0,m=0;const f=i.categories;for(let t=0;t<f.length;t++){const e=f[t];e&&e.length>m&&(m=e.length,p=t)}const g=f[p],y=n.splitter(g),b=y?y.length:30,v={WITH_TITLE:58,WITH_WEBLOGO:107,WITH_BOTH:156};let w;w=i.length>1e5||b<50?v.WITH_TITLE:i.length>5e4?v.WITH_WEBLOGO:v.WITH_BOTH;let C=null,A=null;const S=a.debounce(h.merge(e.onFilterChanged,e.onDataChanged.pipe((0,O.filter)((t=>t?.args?.column===i)))),100).subscribe((()=>{to.clearAllCaches(),C&&(C.resetViewportTracking(),C.forceUpdate()),A&&(A.resetViewportTracking(),A.forceUpdate()),setTimeout((()=>{t.isDetached||t.invalidate()}),50)}));t.sub(S);const x=r=>{const l=[],h=new no(n,b,45,"default","Conservation");A=h,l.push({id:"conservation",track:h,priority:1});const p=new eo(n,b,45,"WebLogo");C=p,r&&(p.setMonomerLib(r),p.setBiotype(n.defaultBiotype||"HELM_AA")),p.setupDefaultTooltip(),l.push({id:"weblogo",track:p,priority:2});const m=new Ji({canvas:t.overlay,headerHeight:w,totalPositions:b+1,onPositionChange:(e,n)=>{setTimeout((()=>{const o=c(),r=u();if(o!==n.start&&i.setTag(gt.gp.positionShift,(n.start-1).toString()),r!==e&&(i.setTag(gt.gp.selectedPosition,e.toString()),e>=0&&!s&&t.tableView&&$()(t.dataFrame?.columns.numerical).find((t=>!0)))){s=!0;const e=t.tableView.addViewer("Sequence Position Statistics",{sequenceColumnName:i.name});t.tableView.dockManager.dock(e,a.DOCK_TYPE.DOWN,null,"Sequence Position Statistics",.4)}}))},onHeaderHeightChange:e=>{t.isDetached||e<v.WITH_TITLE||setTimeout((()=>t.props.colHeaderHeight=e))}},o);m.setupTooltipHandling(),l.forEach((({id:t,track:e})=>{m.addTrack(t,e)})),m.setSelectionData(e,i,n),b>50&&(t.props.colHeaderHeight=w,setTimeout((()=>{t.isDetached||(o.width=400)}),300)),t.sub(t.onCellRender.subscribe((t=>{const e=t.cell;if(!e||!e.isColHeader||e?.gridColumn?.name!==o?.name)return;const n=t.bounds;if(!n)return;m.headerHeight=n.height;const r=d();m.positionWidth=r+8;const s=c();m.draw(n.x,n.y,n.width,n.height,u(),s,t,i.name)})))};(0,bt.pj)().then((t=>{const e=t.getMonomerLib();x(e)})).catch((t=>{r.shell.warning("Failed to initialize monomer library"),console.error("Failed to initialize monomer library:",t)}))}}}),1e3)},e=(r.events.onViewerAdded.subscribe((e=>{if(!(e.args&&e.args.viewer instanceof a.Grid))return;const n=e.args.viewer;t(n)})),r.shell.tableViews);for(const n of e){const e=n?.grid;e&&t(e)}}()}()),await so}function lo(t){const e=new ui(t,io.seqHelper);return e.init().then((()=>{})).catch((t=>{const e=t instanceof Error?t.message:t.toString();r.shell.error(e)})),e}function co(){return io.monomerLib}function ho(t){return io.seqHelper.getSeqHandler(t)}function uo(t){const e="getRegionTopMenu",n=a.Func.find({package:io.name,name:e});if(1!==n.length)throw new Error(`Package '${io.name}' func '${e}' not found`);const i=n[0].prepare({table:t.dataFrame,sequence:t});return new fi(i,io.seqHelper).widget()}async function po(t){return async function(){const t=s.label("Manage monomer libraries");return mn()(t).addClass("d4-link-action"),t.onclick=async()=>await Bn(),new a.Widget(t)}()}function mo(t){try{new fi(t,io.seqHelper).dialog()}catch(t){const e=t instanceof Error?t.message:t.toString(),n=t instanceof Error?t.stack:void 0;r.shell.error(`Get region editor error: ${e}`),io.logger.error(e,void 0,n)}}function fo(t){const e=new ti;s.dialog({title:"Split to Monomers"}).add(e.paramsUI).onOK((async()=>t.func.prepare(e.funcParams).call(!0))).show()}function go(t){const e=new k({semtype:a.SEMTYPE.MACROMOLECULE}),n=s.dialog({title:"Sequence Space"}).add(e.getEditor()).onOK((async()=>{const n=e.getParams();return t.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:e.getStringInput()})),(t=>e.applyStringInput(t.editorSettings))),n.show()}function yo(t){const e=new St({semtype:a.SEMTYPE.MACROMOLECULE}),n=s.dialog({title:"Activity Cliffs"}).add(e.getEditor()).onOK((async()=>{const n=e.getParams();return t.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:e.getStringInput()})),(t=>e.applyStringInput(t.editorSettings))),n.show()}function bo(){return new Yt}function vo(){return new Yt}function wo(){return new Yt}function Co(t){return function(t){const e=Array.from(t.dataFrame.columns).filter((t=>t.semType===a.SEMTYPE.MOLECULE)).map((t=>t.name));new Set(e).delete(t.name);let n=io.properties?io.properties.maxMonomerLength:4;if(Rt.gp.maxMonomerLength in t.tags){const e=parseInt(t.getTag(Rt.gp.maxMonomerLength));n=isNaN(e)?n:e}if(".mm.cellRenderer.maxMonomerLength"in t.temp){const e=parseInt(t.temp[".mm.cellRenderer.maxMonomerLength"]);n=isNaN(e)?n:e}const i=s.input.int("Max Monomer Length",{value:n,nullable:!0,min:1,max:50,step:1,onValueChanged:e=>{if(0==e)setTimeout((()=>{i.value=null}),0);else{const n=e??"",i=null==n?"":n.toString();t.temp[".mm.cellRenderer.maxMonomerLength"]=i,t.temp[".mm.cellRenderer.settingsChanged"]=Dt.s.true,t.dataFrame.fireValuesChanged()}},tooltipText:"The max length of monomer symbol displayed without shortening, empty to no limit"});let o=io.properties?io.properties.fontSize:12;".mm.cellRenderer.fontSize"in t.temp&&t.temp[".mm.cellRenderer.fontSize"]&&!isNaN(t.temp[".mm.cellRenderer.fontSize"])&&(o=t.temp[".mm.cellRenderer.fontSize"]);const r=s.input.int("Font Size",{value:o,nullable:!0,min:1,max:50,step:1,onValueChanged:e=>{if(e&&e>0){const n=e??12;t.temp[".mm.cellRenderer.fontSize"]=n,t.temp[".mm.cellRenderer.settingsChanged"]=Dt.s.true,t.dataFrame.fireValuesChanged()}},tooltipText:"The font size of monomer symbol in sequence renderer"}),l=s.input.int("Monomer Margin",{value:t.temp[".mm.cellRenderer.gapLength"]??0,onValueChanged:e=>{t.temp[".mm.cellRenderer.gapLength"]=e,t.temp[".mm.cellRenderer.settingsChanged"]=Dt.s.true,t.dataFrame.fireValuesChanged()},tooltipText:"The size of margin between monomers (in pixels)"}),c=s.input.bool("Color Code",{value:null==t?.temp["color-code"]||t.temp["color-code"],onValueChanged:e=>{t.temp["color-code"]=e,t.dataFrame.fireValuesChanged()},tooltipText:"Color code"}),h=s.input.string("Reference Sequence",{value:null!=t?.temp["reference-sequence"]?t?.temp["reference-sequence"]:"",nullable:!0,onValueChanged:e=>{t.temp["reference-sequence"]=e,t.dataFrame.fireValuesChanged()},tooltipText:"Reference sequence is not empty, then the sequence will be render \nas a difference from the reference sequence"}),u=s.input.bool("Compare with current",{value:null==t?.temp["compare-with-current"]||t.temp["compare-with-current"],onValueChanged:e=>{t.temp["compare-with-current"]=e,t.dataFrame.fireValuesChanged()},tooltipText:'When on, all sequences get rendered in the "diff" mode'});let d=null;(()=>{const e=t.meta.units;return e!==gt.Hi.HELM&&e!==gt.Hi.CUSTOM})()&&(d=s.input.bool("Multiline Rendering",{value:"true"===t.getTag("renderMultiline"),onValueChanged:e=>{t.tags.renderMultiline=e?"true":"false",t.dataFrame.fireValuesChanged()},tooltipText:"Render sequences across multiple lines when they exceed cell width"}));const p=[r,i,l,h,c,u];d&&p.push(d);const m=s.inputs(p);return new a.Widget(m)}(t)}function Ao(t){return function(t,e,n){const i=s.div();i.classList.add("macromolecule-cell-comp-analysis-host");const o=t.cell.column.tags[gt.gp.alphabet],r=o===gt.YI.DNA||o===gt.YI.RNA?Ft.o.NUCLEOTIDE:Ft.o.AA,l={},c=n.getSeqHandler(t.cell.column),h=t.cell.rowIndex,u=c.getSplitted(h);$().count(0).take(u.length).filter((t=>!u.isGap(t))).forEach((t=>{let e=u.getCanonical(t);r===Ft.o.NUCLEOTIDE&&c.isHelm()&&"("===e[1]&&")"===e[e.length-2]&&(e=e.substring(2,e.length-2));const n=l[e]||0;l[e]=n+1}));const d=(0,hi.F)(l,r,e);return Array.from(d.rows).forEach((t=>{const e=t.getElementsByClassName("macromolecule-cell-comp-analysis-bar")[0].style.backgroundColor;t.cells[0].style.color=e})),i.appendChild(d),new a.Widget(i)}(t,io.monomerLib,io.seqHelper)}function So(){return new Zt}function xo(t,e,n,i,o){const r=new he.$(i,o,n,e);return"Local alignment"==t?r.smithWaterman():r.needlemanWunsch()}function Eo(){return new oe.oP}function To(){return new ce}function Mo(t,e,n,i){return di(t,e??null,n??null,i??null)}async function _o(t,e,n,i,o){const s=di(e,n??null,i??null,o??null);e.dataFrame.columns.add(s),await r.data.detectSemanticTypes(e.dataFrame)}async function Io(t,e,n,i,o,h,u,d,p){if(t!==r.shell.tv.dataFrame)return void r.shell.error(`Table ${t.name} is not a current table view`);if(r.shell.tv,!(0,Zn.V)(e,"Activity Cliffs"))return;const m=_t(t),f={units:e.meta.units,aligned:e.getTag(gt.gp.aligned),separator:e.getTag(gt.gp.separator),alphabet:e.getTag(gt.gp.alphabet)},g=h,y=e,b=async()=>await mt(t,y,m,"Activity cliffs",n,i,g,o,{...d??{}},a.SEMTYPE.MACROMOLECULE,f,u,me,fe,ve,void 0,p),v=o===c.c.UMAP?2e5:2e4,w=o===c.c.UMAP?5e3:2e3;if(t.rowCount>v)return void r.shell.warning(`Too many rows, maximum for sequence activity cliffs is ${v}`);const C=a.TaskBarProgressIndicator.create("Running sequence activity cliffs ..."),A=await new Promise(((e,n)=>{t.rowCount>w&&!d?.[l.vb]?s.dialog().add(s.divText("Activity cliffs analysis might take several minutes.\n Do you want to continue?")).onOK((async()=>{b().then((t=>e(t))).catch((t=>n(t)))})).onCancel((()=>{e(void 0)})).show():b().then((t=>e(t))).catch((t=>n(t)))})).catch((t=>{const[e,n]=(0,Ct.AP)(t);throw io.logger.error(e,void 0,n),t})).finally((()=>{C.close()}));return A?.props?.xColumnName&&A?.props?.yColumnName&&t.col(A.props.xColumnName)&&t.col(A.props.yColumnName)&&(t.col(A.props.xColumnName).set(0,t.col(A.props.xColumnName).get(0)),t.col(A.props.yColumnName).set(0,t.col(A.props.yColumnName).get(0))),A}async function Lo(t,e,n=1,i=.6,o="Morgan"){if(t.semType!==a.SEMTYPE.MACROMOLECULE)return{entries:t.toList(),options:{}};const{seqList:r,options:s}=await de(t,e,o,n,i);return{entries:r,options:s}}async function No(t,e){t.version!==t.temp["last-invalidated-version"]&&await(0,pe.BQ)(t,io.seqHelper,!1);const n=t.temp["monomeric-mols"],i=await r.functions.call("Chem:getMorganFingerprints",{molColumn:n}),o=new Array(i.length).fill(null);for(let t=0;t<i.length;t++){if(i.isNone(t)||!i.get(t))continue;const e=i.get(t);o[t]=U.A.fromUint32Array(e.length,new Uint32Array(e.getBuffer().buffer))}return{entries:o,options:{}}}async function Po(t,e,i,o,c,h,u,d,p){if(t.name!==r.shell.tv.dataFrame.name)return void r.shell.error(`Table ${t.name} is not a current table view`);const m=r.shell.tv.dataFrame==t?r.shell.tv:void 0;return(0,Zn.V)(e,"Sequence Space")?(h||(h=a.Func.find({name:"macromoleculePreprocessingFunction",package:"Bio"})[0]),u??={},await async function(t,e,i,o,c,h,u,d=!0,p=!1,m={preprocessingFuncArgs:[]},f={},g=null,y={},b){const v={showXAxis:!1,showYAxis:!1,showXSelector:!1,showYSelector:!1};if(e.length!==o.length||e.length!==h.length||e.length!==c.length||e.length!==m.preprocessingFuncArgs.length)throw new Error("columns, metrics and preprocessing functions, weights and function argumentsmust have the same length");const w=d?f.tableView??r.shell.tableView(t.name)??r.shell.addTableView(t):null,C=async()=>{const C=a.TaskBarProgressIndicator.create(`Initializing ${f.scatterPlotName??"dimensionality reduction"} ...`);let A;try{const S=_t(t);function x(n,o,r){let c=null,h=null;t.columns.names().includes(S[0])?(c=t.columns.byName(S[0]),h=t.columns.byName(S[1])):(c=t.columns.add(a.Column.float(S[0],t.rowCount)),h=t.columns.add(a.Column.float(S[1],t.rowCount)),d&&!A&&(A=w.scatterPlot({...v,x:S[0],y:S[1],title:f.scatterPlotName??It(e,i)}))),f[l.YP]&&(A?.root&&s.setUpdateIndicator(A.root,!1),c.init((t=>r[0]?r[0][t]:void 0)),h.init((t=>r[1]?r[1][t]:void 0)));const u=n/o*100;C.update(u,`Running ${f.scatterPlotName??"dimensionality reduction"}... ${u.toFixed(0)}%`)}async function E(){t.columns.add(a.Column.float(S[0],t.rowCount)),t.columns.add(a.Column.float(S[1],t.rowCount));let n=null;d&&(A=w.scatterPlot({...v,x:S[0],y:S[1],title:f.scatterPlotName??It(e,i)}),s.setUpdateIndicator(A.root,!0));const p=r.events.onViewerClosed.subscribe((t=>{const e=t.args.viewer;e?.getOptions()?.look?.title&&A?.getOptions()?.look?.title&&e?.getOptions()?.look?.title===A?.getOptions()?.look?.title&&(r.events.fireCustomEvent(Y.S,{}),p.unsubscribe(),n?.(),C.close())})),g=new Promise((async(r,s)=>{try{n=r;const s=[];let a=o,d=c,p=u;if(b&&e.every((t=>t.isNumerical))){const n=e.map((t=>t.toList())),i=new Array(t.rowCount).fill(0).map(((t,n)=>new Float32Array(e.length)));for(let o=0;o<e.length;++o)for(let e=0;e<t.rowCount;++e)i[e][o]=n[o][e];m.distanceFnArgs=[{}],s.push({entries:i,options:{}}),a=[b],d=[1],p="MANHATTAN"}else for(let t=0;t<h.length;++t){const n=h[t];if(m.distanceFnArgs||(m.distanceFnArgs=[]),n){const i=n.inputs[0].name,r=n.inputs[1].name,{entries:a,options:l}=await n.apply({[i]:e[t],[r]:o[t],...m.preprocessingFuncArgs[t]??{}});s.push({entries:a,options:l}),m.distanceFnArgs.push(l)}else{const n=e[t].toList(),i={};s.push({entries:n,options:i}),m.distanceFnArgs.push(i)}}r(await Z(s.map((t=>t.entries)),i,a,d,u,m,f[l.vb]?void 0:x))}catch(t){s(t)}})),y=await g;return C.close(),p.unsubscribe(),y}const T=await E();if(p&&T){const M=a.TaskBarProgressIndicator.create("Clustering embeddings ...");try{const _=await function(t,e,i,o){return Mt(this,void 0,void 0,(function*(){return new Promise((function(r,s){const a=new Worker(new URL(n.p+n.u(682),n.b));a.postMessage({embedX:t,embedY:e,minPts:o,epsilon:i}),a.onmessage=({data:{error:t,clusters:e}})=>{a.terminate(),t?s(t):r(e)}}))}))}(T[0],T[1],m.dbScanEpsilon??.01,m.dbScanMinPts??4),I=t.columns.getUnusedName("Cluster (DBSCAN)");t.columns.addNewString(I).init((t=>_[t].toString())),A&&(A.props.colorColumnName=I)}catch(L){r.shell.error("Clustering embeddings failed"),console.error(L)}finally{M.close()}}if(T){const N=t.columns.byName(S[0]),P=t.columns.byName(S[1]);if(N.init((t=>T[0][t])),P.init((t=>T[1][t])),g)try{const $=g.inputs[0].name,R=g.inputs[1].name;await g.prepare({[$]:N,[R]:P,...y}).call(!0)}catch(k){r.shell.error("Post-processing failed"),console.error(k)}if(A)return s.setUpdateIndicator(A.root,!1),A.helpUrl="/help/compute/sequence-space",A}}catch(O){r.shell.error("Dimensionality reduction failed"),console.error(O),C.close(),A&&s.setUpdateIndicator(A.root,!1)}};return new Promise((async(e,n)=>{try{if(f.fastRowCount&&t.rowCount>f.fastRowCount&&!f[l.vb])s.dialog().add(s.divText("Analysis might take several minutes. Do you want to continue?")).onOK((async()=>{try{const t=await C();e(t)}catch(t){n(t)}})).onCancel((()=>e(void 0))).show();else{const t=await C();e(t)}}catch(t){n(t)}}))}(t,[e],i,[o],[1],[h],"MANHATTAN",c,d??!1,{...u,preprocessingFuncArgs:[u.preprocessingFuncArgs??{}]},{fastRowCount:1e4,scatterPlotName:"Sequence space",bypassLargeDataWarning:u?.[l.vb],tableView:m})):void 0}async function $o(t,e,n,i=!1){const o=a.TaskBarProgressIndicator.create("Converting to atomic level ...");try{await so;const o=e.temp[".mm.cellRenderer.overriddenLibrary"]??io.monomerLib,r=io.seqHelper,s=io.rdKitModule;await(0,gi.V)(t,e,n,i,o,r,s)}finally{o.close()}}async function Ro(t){if(!t?.dataFrame)throw new Error("Sequence column is not found or its data frame is not empty");const e=a.Func.find({name:"toAtomicLevel",package:"Bio"})[0];if(!e)throw new Error("To Atomic level Function not found");e.prepare({table:t.dataFrame,seqCol:t}).edit()}async function ko(t){return async function(t){const e=await Vi(t);if(e.errorText||!e.mol)return a.Widget.fromRoot(s.divText(e.errorText??"No structure generated"));try{const t=a.SemanticValue.fromValueType(e.mol,a.SEMTYPE.MOLECULE),n=s.panels.infoPanel(t);let i=null;n&&(i=a.Widget.fromRoot(n.root));const o=r.chem.drawMolecule(e.mol,300,300,!1);return o.style.cursor="pointer",s.tooltip.bind(o,"Click to expand"),o.onclick=()=>{const t=window.innerWidth-200,n=window.innerHeight-200,i=r.chem.drawMolecule(e.mol,t,n,!1);s.dialog({title:"Molecule"}).add(i).showModal(!0)},i&&i.root.prepend(o),i??a.Widget.fromRoot(o)}catch(t){io.logger.error(t)}return a.Widget.fromRoot(s.divText("No structure generated"))}(t)}async function Oo(t){return async function(t){const e=a.TaskBarProgressIndicator.create("Creating 3D view");let n,i="";try{await(a.Func.find({name:"getPdbHelper"})[0]?.apply({}));try{const o=await Vi(t);if(o.errorText||!o.mol)return n=s.divText(o.errorText??"No structure generated"),e.close(),new a.Widget(n);const l=o.mol;i=await r.functions.call("Bio:Embed",{molecule:l});const c=wi.Molecule.fromMolfile(i);c?i=c.toMolfile():console.warn("Failed to convert molv3 to molv2")}catch(t){console.warn(t)}try{i=i.replaceAll("\\n","\n");const t=new Blob([i],{type:"text/plain"}),e=s.div([],{classes:"d4-ngl-viewer",id:"ngl-3d-host"});e.style.setProperty("height","100%","important");const o=new NGL.Stage(e,{backgroundColor:"white"});o.loadFile(t,{ext:"sdf"}).then((function(t){o.setSize(300,300),t.addRepresentation("ball+stick"),t.autoView()})),n=s.div([e],{style:{aspectRatio:"1"}})}catch(t){n=s.divText("Couldn't get 3D structure")}}catch(t){n=s.divText("Couldn't get 3D structure")}return e.close(),new a.Widget(n)}(t)}function Ho(){(0,Jn.D)({},io.seqHelper).catch((t=>{const[e,n]=(0,Ct.AP)(t);if(t instanceof Xn.Ap)return r.shell.warning(t.element),void io.logger.warning(e);r.shell.error(e),io.logger.error(e,void 0,n)}))}async function Go(t=null,e=null,n){return(0,Jn.D)({col:t,clustersCol:e,...n},io.seqHelper)}async function Fo(){const t=r.shell.tv,e=t.dataFrame.columns.toList().filter((t=>t.semType==a.SEMTYPE.MACROMOLECULE&&(io.seqHelper.getSeqHandler(t),!0))),n=async e=>{if(!(0,Zn.V)(e,"Composition"))return;const n=t.addViewer("WebLogo",{sequenceColumnName:e.name});r.shell.tv.dockManager.dock(n,a.DOCK_TYPE.DOWN,null,"Composition analysis",.25)};let i=null;if(0!=e.length){if(e.length>1){const t=e.map((t=>t.name)),i=e.find((t=>io.seqHelper.getSeqHandler(t).isMsa())),o=s.input.choice("Column",{value:i?i.name:t[0],items:t});s.dialog({title:"Composition Analysis",helpUrl:"https://datagrok.ai/help/datagrok/solutions/domains/bio/#sequence-composition"}).add(s.div([o])).onOK((async()=>{const t=e.find((t=>t.name==o.value))??null;t&&await n(t)})).show()}else i=e[0];i&&await n(i)}else r.shell.error("Current table does not contain sequences")}function Do(t){return new yt.m(t).importFasta()}function Bo(t){return console.log(t),[]}function Vo(){const t=(0,$t.me)()[0];(0,Te.C)(t,io.seqHelper)}function Wo(t){(0,Te.C)(t,io.seqHelper)}function Uo(){return new oi}async function jo(t){const e=a.TaskBarProgressIndicator.create("Test detectMacromolecule..."),n=(await r.dapi.files.list(t,!0,"")).filter((t=>t.fileName.endsWith(".csv")));let i=0;const o=[];for(const s of n)try{const e=await r.dapi.files.readAsText(t+s.fullPath),n=a.DataFrame.fromCsv(e);for(const t of n.columns)await r.functions.call("Bio:detectMacromolecule",{col:t})===a.SEMTYPE.MACROMOLECULE&&o.push({file:s.path,result:"detected",column:t.name,message:`units: ${t.meta.units}`})}catch(t){o.push({file:s.path,result:"error",column:null,message:t instanceof Error?t.message:t.toString()})}finally{i+=1,e.update(100*i/n.length,`Test ${s.fileName}`)}r.shell.info("Test Demo:Files for detectMacromolecule finished."),e.close();const s=a.DataFrame.fromObjects(o);return s.name=`datasets_detectMacromolecule_${t}`,s}async function qo(t,e){return await async function(t,e){if(await(0,te.cb)(10),!(0,Zn.V)(e,"Sequence space"))return t;const n=io.seqHelper,i=(0,vt.R)(e,n);i.name="splitToMonomers";const o=e.dataFrame;for(const t of i.columns)t.semType=Wt.uF.MONOMER,t.setTag(wt.gp.alphabet,e.getTag(wt.gp.alphabet));const s=/(\d+)(?: \((\d+)\))?/,l=t=>{s.lastIndex=0;const e=t.match(s);return e?`${e[1]} (${parseInt(e[2]??"0")+1})`:t};for(let t=0;t<i.columns.length;t++){const n=i.columns.byIndex(t);n.semType=Wt.uF.MONOMER,n.setTag(wt.gp.alphabet,e.getTag(wt.gp.alphabet));const r=100;let s=0;for(;o.columns.byName(n.name)&&s<r;)n.name=l(n.name),s++;o.columns.add(n)}await r.data.detectSemanticTypes(o);for(let t=0;t<i.columns.length;t++){const e=i.columns.byIndex(t);e.setTag(a.TAGS.CELL_RENDERER,"Monomer"),e.setTag(".use-as-filter","false")}return o}(t,e)}function zo(t){return io.seqHelper.getSeqMonomers(t)}function Yo(){return new Se(io.seqHelper)}function Ko(){const t=r.shell.v,e=t.addViewer("Sequence Similarity Search");t.dockManager.dock(e,"down")}function Zo(){return new xe(io.seqHelper)}function Xo(){const t=r.shell.v,e=t.addViewer("Sequence Diversity Search");t.dockManager.dock(e,"down")}function Jo(t){const e=(0,$t.me)();1===e.length?t.func.prepare({macromolecules:e[0]}).call(!0):new pe.a7(e,io.seqHelper)}function Qo(t){r.shell.tv.getFiltersGroup({createDefaultFilters:!1}).updateOrAdd({type:"Bio:bioSubstructureFilter",column:t.name,columnName:t.name}),r.shell.tv.grid.scrollToCell(t,0)}async function tr(t,e,n){const i=io.seqHelper;return yi(t,e,n,ft.IDENTITY,i)}async function er(t,e,n){const i=io.seqHelper;return yi(t,e,n,ft.SIMILARITY,i)}async function nr(){Bn()}async function ir(){await Vn()}async function or(){const t=await Tn.getInstance();await t.getViewRoot()}async function rr(){return await Vn(!1)}async function sr(t,e){(await(await dn.getInstance()).getFileManager()).getValidLibraryPaths().forEach((e=>{const n=e.endsWith(".json")?e.substring(0,e.length-5):e;t.item(n).onSelected.subscribe((async()=>{const t=await Tn.getInstance();await t.getViewRoot(e,!0),t.resetCurrentRowFollowing()}))}))}function ar(){(0,Me.TE)()}function lr(){return new _e._i(io.seqHelper,io.logger)}function cr(){return new _e._i(io.seqHelper,io.logger)}async function hr(){const t=a.TaskBarProgressIndicator.create("WebLogo");try{const t=new URLSearchParams(window.location.search),e=new Qn(t,"webLogoLargeApp"),n=await io.files.readCsv("data/sample_PT_100000x5.csv");await r.data.detectSemanticTypes(n),await e.init(n)}finally{t.close()}}async function ur(){const t=a.TaskBarProgressIndicator.create("WebLogo ...");try{const t=new URLSearchParams(window.location.search),e=new Qn(t,"webLogoAggApp"),n=await io.files.readCsv("samples/FASTA_PT_activity.csv");await r.data.detectSemanticTypes(n),await e.init(n)}finally{t.close()}}async function dr(){const t=a.TaskBarProgressIndicator.create("getRegion ...");try{const t=new URLSearchParams(window.location.search),e=new mi(t,"getRegionApp");await e.init()}finally{t.close()}}async function pr(){const t=a.TaskBarProgressIndicator.create("getRegion ...");try{const t=new URLSearchParams(window.location.search),e=await io.files.readCsv("samples/HELM_empty_vals.csv"),n=new mi(t,"getRegionHelmApp");await n.init({df:e,colName:"HELM"})}finally{t.close()}}function mr(){const t=a.DataFrame.fromColumns((0,Lt.dW)());r.shell.addTableView(t)}function fr(){const t=a.DataFrame.fromColumns([(0,Lt.Hx)(io.seqHelper,gt.Hi.FASTA)]);r.shell.addTableView(t)}function gr(){const t=a.DataFrame.fromColumns([(0,Lt.Hx)(io.seqHelper,gt.Hi.HELM)]);r.shell.addTableView(t)}function yr(t,e){!function(t,e,n){const i=Object.values(gt.Hi).filter((t=>t!==gt.Hi.CUSTOM));e.group("Copy").items(i,(e=>{const i=t.column,o=t.rowIndex,s=n.getSeqHandler(i),a=e===gt.Hi.SEPARATOR?io.properties.defaultSeparator??"-":void 0,l=s.getJoiner({notation:e,separator:a})(s.getSplitted(o));navigator.clipboard?(navigator.clipboard.writeText(l),r.shell.info(`Value of notation '${e}' copied to clipboard`)):r.shell.warning("The clipboard functionality requires a secure origin — either HTTPS or localhost")}))}(t,e,io.seqHelper)}async function br(){await async function(){const t=await io.files.readCsv("samples/peptides-non-natural.csv");t.name="Similarity and Diversity Demo",t.col("activity").setTag("format","3 significant digits"),t.col("sequence").temp[".mm.cellRenderer.maxMonomerLength"]=4;const e=r.shell.addTableView(t);await t.meta.detectSemanticTypes(),await r.data.detectSemanticTypes(t);const n=e.addViewer("Sequence Similarity Search",{limit:20}),i=e.dockManager.dock(n,a.DOCK_TYPE.RIGHT,null,"Similarity search",.45);(0,$t.Kd)(e.grid,"sequence",500,30);const o=e.addViewer("Sequence Diversity Search",{limit:20});e.dockManager.dock(o,a.DOCK_TYPE.DOWN,i,"Diversity search",.4),r.functions.call("Dendrogram:HierarchicalClustering",{df:r.shell.t,colNameList:["sequence"],distance:"euclidian",linkage:"complete"})}()}async function vr(){await async function(){const t=await r.functions.eval("Bio:SeqSpaceDemo"),e=await r.dapi.projects.find(t.id);await e.open(),r.shell.windows.help.showHelp("/help/datagrok/solutions/domains/bio/bio.md#sequence-space")}()}async function wr(){await async function(){const t=await io.files.readCsv("tests/helm_cyclic_cliffs.csv");t.name="Activity Cliffs Demo",await r.data.detectSemanticTypes(t),await t.meta.detectSemanticTypes();const e=r.shell.addTableView(t);s.setUpdateIndicator(e.root,!0);try{const n=a.Func.find({name:"macromoleculePreprocessingFunction",package:"Bio"})[0],i=await Io(t,t.getCol("Sequence"),t.getCol("Activity"),96,c.c.UMAP,ue.Z.MONOMER_CHEMICAL_DISTANCE,n,{},!0);e.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),e.grid.props.rowHeight=180,e.grid.col("sequence")&&(e.grid.col("sequence").width=300),e.grid.col("structure")&&(e.grid.col("structure").width=300);const o=Array.from(e.viewers).find((t=>t!==e.grid&&t.type===a.VIEWER.GRID));o&&(o.props.rowHeight=40,o.col("seq_diff").width=600,e.dockManager.dock(o,a.DOCK_TYPE.DOWN,null,"Cliffs",.35),e.dockManager.dock(i,a.DOCK_TYPE.RIGHT,null,"Activity Cliffs",.55))}catch(t){!function(t){const e=t instanceof Error?t.message:t.toString(),n=t instanceof Error?t.stack:void 0;r.shell.error(e),io.logger.error(t.message,void 0,n)}(t)}finally{s.setUpdateIndicator(e.root,!1)}r.shell.windows.help.showHelp("/help/datagrok/solutions/domains/bio/bio.md#activity-cliffs")}()}async function Cr(){await async function(){const t=await io.files.readCsv("samples/HELM_BI_CYCLIC.csv");t.name="To Atomic Level",await t.meta.detectSemanticTypes(),await r.data.detectSemanticTypes(t);const e=r.shell.addTableView(t),n=t.col("HELM");await $o(t,n,!0,!1),(0,$t.Kd)(e.grid,"molfile(HELM)",500,300,!0),(0,$t.Kd)(e.grid,"HELM",500,void 0,!0),r.shell.info("Hover over monomers in HELM column to highlight them in molecular structure.",{timeout:10}),r.shell.windows.help.showHelp("/help/datagrok/solutions/domains/bio/bio.md#get-atomic-level-structure")}()}async function Ar(t){const e=(0,bt.uX)(t),n=JSON.stringify(e);a.Utils.download(`${t.name}.json`,n)}async function Sr(t,e){if(!t.trim())return"";try{const n=a.Column.fromList(a.COLUMN_TYPE.STRING,"helm",[t]),i=a.DataFrame.fromColumns([n]),o=await r.functions.call("Bio:detectMacromolecule",{col:n});o&&(n.semType=o);const s=(await oo()).getMonomerLib(),l=io.seqHelper,c=await(0,Pt.j)(),h=(await(0,gi.V)(i,n,e,!1,s,l,c))?.molCol?.get(0);return h??void 0}catch(t){const[e,n]=(0,Ct.AP)(t);throw io.logger.error(e,void 0,n),t}}async function xr(t,e){if(!t.trim())return null;try{const n=a.Column.fromList(a.COLUMN_TYPE.STRING,"seq",[t]),i=a.DataFrame.fromColumns([n]);if(!await r.functions.call("Bio:detectMacromolecule",{col:n}))throw new Error("Macromolecule required");return(await yi(i,n,e,ft.IDENTITY,io.seqHelper)).get(0)}catch(t){const[e,n]=(0,Ct.AP)(t);throw io.logger.error(e,void 0,n),t}}async function Er(t,e,n){const i=await t.readAsString();await async function(t,e,n){const i=a.TaskBarProgressIndicator.create("detectMacromolecule probe ...");try{let o=0;const s=await r.functions.call("Bio:detectMacromoleculeEnableStore");let l=0;for(let c=0;c<n;++c){const h=a.DataFrame.fromCsv(t),u=e?h.getCol(e):h.columns.byIndex(0);await r.functions.call("Bio:detectMacromolecule",{col:u})!==a.SEMTYPE.MACROMOLECULE&&(++l,console.warn(`Reject reason: ${s.last.rejectReason}`));const d=c/n;d-o>=.1&&(o=d,i.update(100*d,`detectMacromolecule probe ${l}/${c}/${n} ...`),await(0,te.cb)(0))}l>0?r.shell.warning(`detectMacromolecule failed ${l} / ${n}`):r.shell.info(`detectMacromolecule success ${n}`)}finally{i.close()}}(i,e,n)}async function Tr(){return await ao(),io.seqHelper}function Mr(t,e,n){return async function(t,e,n=!0,i){const o=io.seqHelper,r=(await o.getHelmToMolfileConverter(i)).convertToRdKitBeautifiedMolfileColumn(e,n,io.rdKitModule,i);return r.semType=a.SEMTYPE.MOLECULE,r}(0,e,n,io.monomerLib)}function _r(){return io.logger.debug("Bio:test1() function"),{value:"value1"}}},6625:(t,e,n)=>{"use strict";n.d(e,{$:()=>r});class i{value;parentI;parentJ;constructor(){this.value=0,this.parentI=0,this.parentJ=0}}class o{seq1;seq2;score;constructor(t,e,n){this.seq1=t,this.seq2=e,this.score=n}}class r{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 t=0;t<=this.len1;t++)this.dpGrid[t][0].value=-t*this.gap,this.dpGrid[t][0].parentI=t-1,this.dpGrid[t][0].parentJ=0;for(let t=1;t<=this.len2;t++)this.dpGrid[0][t].value=-t*this.gap,this.dpGrid[0][t].parentI=0,this.dpGrid[0][t].parentJ=t-1}fillOne(t,e){this.dpGrid[t][e].value=Math.max(this.dpGrid[t-1][e-1].value+this.scores[t-1][e-1],Math.max(this.dpGrid[t-1][e].value-this.gap,this.dpGrid[t][e-1].value-this.gap)),this.dpGrid[t][e].value==this.dpGrid[t-1][e-1].value+this.scores[t-1][e-1]?(this.dpGrid[t][e].parentI=t-1,this.dpGrid[t][e].parentJ=e-1):this.dpGrid[t][e].value==this.dpGrid[t-1][e].value-this.gap?(this.dpGrid[t][e].parentI=t-1,this.dpGrid[t][e].parentJ=e):(this.dpGrid[t][e].parentI=t,this.dpGrid[t][e].parentJ=e-1)}gridFromName(t){switch(t){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(t,e){let n="",i="",r="";const s=this.dpGrid[t][e].value;for(let t=0;t<this.step;t++)r+="|";for(;t>0||e>0;){this.dpGrid[t][e].parentI==t?(n=r+n,i=this.seq2.substr((e-1)*this.step,this.step)+i):this.dpGrid[t][e].parentJ==e?(i=r+i,n=this.seq1.substr((t-1)*this.step,this.step)+n):(n=t-1>=0?this.seq1.substr((t-1)*this.step,this.step)+n:r+n,i=e-1>=0?this.seq2.substr((e-1)*this.step,this.step)+i:r+i);const o=t;t=this.dpGrid[t][e].parentI,e=this.dpGrid[o][e].parentJ}return new o(n,i,s)}fillScores(){this.scores=[];for(let t=0;t<this.len1;t++){this.scores.push([]);for(let e=0;e<this.len2;e++)this.scores[t].push(this.alignGrid[this.connections[this.seq1.substr(t*this.step,this.step)]][this.connections[this.seq2.substr(e*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 t=0;t<this.len1+1;t++){const t=[];for(let e=0;e<this.len2+1;e++)t.push(new i);this.dpGrid.push(t)}this.fillNeedleman();for(let t=1;t<=this.len1;t++)for(let e=1;e<=this.len2;e++)this.fillOne(t,e);return this.constructResult(this.len1,this.len2)}smithWaterman(){this.dpGrid=[];for(let t=0;t<this.len1+1;t++){const t=[];for(let e=0;e<this.len2+1;e++)t.push(new i);this.dpGrid.push(t)}let t=0,e=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>t&&(t=this.dpGrid[i][o].value,e=i,n=o);return this.constructResult(e,n)}setSequences(t,e){this.seq1=t,this.seq2=e,this.len1=this.seq1.length/this.step,this.len2=this.seq2.length/this.step,this.fillScores()}setGap(t){this.gap=t}setMethod(t=""){"AUTO"==t&&(t=this.typeRec()),this.gridFromName(t)}constructor(t,e,n,i=""){this.setMethod(i),this.setSequences(t,e),this.setGap(n)}}},4954:(t,e,n)=>{"use strict";n.d(e,{a7:()=>m,if:()=>g,BQ:()=>y,nI:()=>f});var i=n(4328),o=n(7389),r=n(6082),s=n(8070),a=n(2003),l=n(439);const c=31;async function h(t,e,n=!1,o){const s=e.getSeqHandler(t);let a;o??=new Map;const l=s.isHelm()?e.getSeqMonomers(t):Object.keys(s.stats.freq).filter((t=>""!==t));for(let t=0;t<l.length;t++)o.has(l[t])||o.set(l[t],`${o.size+1}`);if(s.isHelm())a=await i.functions.call("HELM:getMolFiles",{col:t}),a=function(t,e,n=!1){const i=new Array(t.length);for(let o=0;o<t.length;o++){let r=0,s=0,a="\n Datagrok macromolecule handler\n\n 0 0 0 0 0 0 999 V3000\nM V30 BEGIN CTAB\n";const l=t.get(o);r=l.indexOf("\n",r)+1,r=l.indexOf("\n",r)+1,r=l.indexOf("\n",r)+1;const h=parseInt(l.substring(r,r+3)),u=parseInt(l.substring(r+3,r+6));a+=`M V30 COUNTS ${h} ${u} 0 0 0\n`,a+="M V30 BEGIN ATOM\n";for(let t=0;t<h;t++){r=l.indexOf("\n",r)+1+c,s=l.indexOf(" ",r);const i=l.substring(r,s);a+=n?`M V30 ${t+1} R${e.get(i)} 0.000 0.000 0 0\n`:`M V30 ${t+1} At 0.000 0.000 0 0 MASS=${e.get(i)}\n`}a+="M V30 END ATOM\n",a+="M V30 BEGIN BOND\n";for(let t=0;t<u;t++){r=l.indexOf("\n",r)+1;const e=parseInt(l.substring(r,r+3).trim()),n=parseInt(l.substring(r+3,r+6).trim());a+=`M V30 ${t+1} ${parseInt(l.substring(r+6,r+9).trim())} ${e} ${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(t.length);for(let e=0;e<t.length;e++){const t=u(s.getSplitted(e),o,n);a[e]=t}}return r.Column.fromStrings("monomericMols",a)}function u(t,e,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 ${t.length} ${t.length?t.length-1:0} 0 0 0\n`,i+="M V30 BEGIN ATOM\n";for(let o=0;o<t.length;o++){const r=t.getCanonical(o);r!==l._S&&(i+=n?`M V30 ${o+1} R${e.get(r)} 0.000 0.000 0 0\n`:`M V30 ${o+1} At 0.000 0.000 0 0 MASS=${e.get(r)}\n`)}i+="M V30 END ATOM\n",i+="M V30 BEGIN BOND\n";for(let e=0;e<t.length-1;e++)i+=`M V30 ${e+1} 1 ${e+1} ${e+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(t,e){this.seqHelper=e,this.col=t[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 t=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,t)}updateNotationDiv(){this.units=this.col.meta.units,this.separator=this.col.getTag(a.gp.separator);const t=this.dialog.root.getElementsByClassName("notation-text")[0];t&&(t.textContent=`Notation: ${this.units}`)}createUI(){const t=i.shell.tv.dataFrame;this.columnsInput=o.input.column("Column",{table:t,value:this.col,onValueChanged:t=>{this.col=t,this.updateNotationDiv(),this.updateInputs()},filter:t=>t.semType===r.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 e=r.DataFrame.create(1);e.columns.addNewString(p).init((t=>"")),e.col(p).semType=this.col.semType,e.col(p).meta.units=a.Hi.HELM,this.grid=e.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 t,n=this.units===a.Hi.HELM?e.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)),t=this.units===a.Hi.HELM?await g(n,this.col,this.seqHelper):f(n,this.col),this.col.dataFrame.filter.and(t)})).show()}}function f(t,e,n){const i=n?function(t,e){const n=`${e}`.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),i=t.charAt(0)===e,o=t.charAt(t.length-1)===e,r=t.replace(new RegExp(`^${n}|${n}$`,"g"),"");return i?o?`${n}${r}${n}`:`${n}${r}${n}|${n}${r}$`:o?`^${r}${n}|${n}${r}${n}`:`^${r}${n}|${n}${r}${n}|${n}${r}$`}(t,n):t,o=r.BitSet.create(e.length);for(let n=0;n<e.length;n++){const r=e.get(n);(r.match(i)||r===t)&&o.set(n,!0,!1)}return o}async function g(t,e,n){e.version!==e.temp["last-invalidated-version"]&&await y(e,n,!0);const o=r.Column.string("helm",1).init((e=>t));o.semType=r.SEMTYPE.MACROMOLECULE,o.meta.units=a.Hi.HELM;const s=await h(o,n,!0,e.temp["monomers-dict"]);return(await i.functions.call("Chem:searchSubstructure",{molStringsColumn:e.temp["monomeric-mols"],molString:s.get(0),molBlockFailover:""})).get(0)}async function y(t,e,n){const i=r.TaskBarProgressIndicator.create(`Invalidating molfiles for ${t.name}`);try{await(0,s.cb)(10);const i=new Map,o=await h(t,e,n,i);t.temp["monomeric-mols"]=o,t.temp["monomers-dict"]=i,t.temp["last-invalidated-version"]=t.version}finally{i.close()}}},966:(t,e,n)=>{"use strict";n.d(e,{V:()=>s,l:()=>a});var i=n(4328),o=n(6082),r=n(6723);function s(t,e,n=[],o=[],s=!0){const l=r._package.seqHelper,[c,h]=a(t,e,l,n,o);return s&&!c&&i.shell.warning(h),c}function a(t,e,n,r=[],s=[]){let a=!0,l="";if(t.semType!==o.SEMTYPE.MACROMOLECULE)i.shell.warning(e+" analysis is allowed for Macromolecules semantic type"),a=!1;else{const i=n.getSeqHandler(t),o=i.notation;if(r.length>0&&!r.some((t=>o.toUpperCase()==t.toUpperCase())))l=`${e} + ' analysis is allowed for Macromolecules with notation ${0==r.length?"any notation":`notation${r.length>1?"s":""} ${r.map((t=>`"${t}"`)).join(", ")} `}.`,a=!1;else if(!i.isHelm()){const t=i.alphabet;s.length>0&&!s.some((e=>t.toUpperCase()==e.toUpperCase()))&&(l=`${e} + ' analysis is allowed for Macromolecules with alphabet ${0==s.length?"any alphabet":`alphabet${s.length>1?"s":""} ${s.map((t=>`"${t}"`)).join(", ")}.`}.`,a=!1)}}return[a,l]}},4139:(t,e,n)=>{"use strict";n.d(e,{HX:()=>h,J:()=>a,b9:()=>c,uF:()=>r});var i,o,r,s,a,l=n(8152);!function(t){t.SPLIT_COL="~split",t.ACTIVITY="~activity",t.ACTIVITY_SCALED="activity_scaled",t.ALIGNED_SEQUENCE="~aligned_sequence",t.AMINO_ACID_RESIDUE="AAR",t.POSITION="Pos",t.P_VALUE="pValue",t.MEAN_DIFFERENCE="Mean difference"}(i||(i={})),function(t){t.AAR="AAR",t.POSITION="Pos",t.SELECTION="selection"}(o||(o={})),function(t){t.MONOMER="Monomer",t.MACROMOLECULE_DIFFERENCE="MacromoleculeDifference",t.ACTIVITY="activity",t.ACTIVITY_SCALED="activityScaled"}(r||(r={})),function(t){t.CELL_CHANGING="isCellChanging"}(s||(s={})),function(t){t.SEPARATOR="."}(a||(a={}));const c="3.3.1",h={pepsea:{gapOpen:1.53,gapExtend:0,method:l.ZY[0]},kalign:{gapOpen:-1,gapExtend:-1,terminalGap:-1}}},5433:(t,e,n)=>{"use strict";n.d(e,{C:()=>u});var i=n(6082),o=n(7389),r=n(4328),s=n(1757),a=n.n(s),l=n(2003);let c=null,h=[];function u(t,e){let n=t??r.shell.t.columns.bySemType("Macromolecule");if(!n)throw new Error("No column with Macromolecule semantic type found");let s=e.getSeqHandler(n),u=s.notation;const d=o.divText("Current notation: "+u,{style:{"text-align":"center","font-weight":"bold","font-size":"14px",padding:"5px"}}),p=[l.Hi.FASTA,l.Hi.SEPARATOR,l.Hi.HELM],m=o.input.column("Column",{table:r.shell.t,value:n,filter:t=>t.semType===i.SEMTYPE.MACROMOLECULE,nullable:!1,onValueChanged:t=>(n=t,s=e.getSeqHandler(n),u=s.notation,u===l.Hi.HELM&&(y.value="/"),d.textContent="Current notation: "+u,g=p.filter((t=>t!==u)),v=o.input.choice("Convert to",{value:g[0],items:g,onValueChanged:b}),b(),c?.clear(),void c?.add(o.div([d,m.root,v.root,y.root])))}),f=["-",".","/"];let g=p.filter((t=>t!==u));const y=o.input.choice("Separator",{value:f[0],items:f}),b=()=>{v.value!==l.Hi.SEPARATOR?a()(y.root).hide():a()(y.root).show()};let v=o.input.choice("Convert to",{value:g[0],items:g,onValueChanged:b});b(),v.onChanged.subscribe((()=>{b()})),null==c&&(c=o.dialog("Convert Sequence Notation").add(o.div([d,m.root,v.root,y.root])).onOK((async()=>{const t=v.value,i=t===l.Hi.SEPARATOR?y.value:void 0;await async function(t,e,n,i){const o=e.getSeqHandler(t).convert(n,i);t.dataFrame.columns.add(o);const s=await r.functions.call("Bio:detectMacromolecule",{col:o});return s&&(o.semType=s),await r.data.detectSemanticTypes(t.dataFrame),o}(n,e,t,i)})).show({x:350,y:100}),h.push(c.onClose.subscribe((t=>{h.forEach((t=>{t.unsubscribe()})),h=[],c=null}))))}},536:(t,e,n)=>{"use strict";n.d(e,{Z:()=>o});var i=n(6956);class o{constructor(t){const e=t.split(i.xe).filter((t=>t));e.forEach((t=>this.validateConnectionItem(t))),this.connectionItems=e}connectionItems;validateConnectionItem(t){const e="(PEPTIDE|RNA)",n=new RegExp(`${e}[0-9]+,${e}[0-9]+,[0-9]+:R[0-9]+-[0-9]+:R[0-9]+`,"g");if(!t.match(n))throw new Error(`Cannot parse connection item from ${t}`)}getConnectionData(){const t=[];return this.connectionItems.forEach((e=>{const n=[],i=e.split(",");i[2].split("-").forEach(((t,e)=>{const o=i[e],r=t.split(":"),s={monomerIdx:parseInt(r[0])-1,rGroupId:parseInt(r[1].slice(1))};n.push({polymerId:o,bond:s})})),t.push(n)})),t}}},6956:(t,e,n)=>{"use strict";n.d(e,{mP:()=>r,pk:()=>o,xe:()=>i});const i="|",o="$",r="H"},9099:(t,e,n)=>{"use strict";n.d(e,{f:()=>s});var i=n(536),o=n(6956),r=n(9034);class s{helmString;constructor(t){this.helmString=t;const e=this.helmString.split(o.pk),n=e[0].split(o.xe);this.simplePolymers=n.map((t=>new r.d(t))),this.connectionList=new i.Z(e[1]),this.bondData=this.getBondData(),this.bondedRGroupsMap=this.getBondedRGroupsMap()}bondData;simplePolymers;connectionList;bondedRGroupsMap;getBondedRGroupsMap(){const t=this.simplePolymers.map((t=>t.monomers.length)).reduce(((t,e)=>t+e),0),e=Array.from({length:t},(()=>[]));return this.bondData.forEach((t=>{t.forEach((t=>{const n=t.monomerIdx,i=t.rGroupId;e[n].push(i)}))})),e}toString(){return this.helmString}getPolymerTypeByMonomerIdx(t){return this.getSimplePolymerByMonomerIdx(t).polymerType}getSimplePolymerByMonomerIdx(t){const e=this.getMonomerIdxShifts(),n=Object.values(e).sort(((t,e)=>t-e)).find((e=>t>=e));if(void 0===n)throw new Error(`Cannot find simple polymer for monomer ${t}`);const i=Object.keys(e).find((t=>e[t]===n));return this.simplePolymers.find((t=>t.id===i))}shiftBondMonomerIds(t,e){e.forEach((e=>{e.forEach((e=>{e.monomerIdx+=t}))}))}getMonomerIdxShifts(){const t={};let e=0;return this.simplePolymers.forEach((n=>{t[n.id]=e,e+=n.monomers.length})),t}getBondData(){const t=this.getMonomerIdxShifts(),e=[];return this.simplePolymers.forEach((n=>{const i=n.getBondData(),o=t[n.id];this.shiftBondMonomerIds(o,i),e.push(...i)})),this.connectionList.getConnectionData().forEach((n=>{const i=[];n.forEach((e=>{const n=t[e.polymerId],o=e.bond;o.monomerIdx+=n,i.push(o)})),e.push(i)})),e}}},9034:(t,e,n)=>{"use strict";n.d(e,{d:()=>o});var i=n(8438);class o{simplePolymer;isNucleotideSequence=!1;constructor(t){this.simplePolymer=t,this.polymerType=this.getPolymerType(),this.isNucleotideSequence="RNA"===this.polymerType,this.idx=this.getIdx();const{monomers:e,monomerTypes:n}=this.getMonomerSymbolsAndTypes();this.monomers=e,this.monomerTypes=n}polymerType;monomers;idx;monomerTypes;get id(){return this.polymerType+this.idx.toString()}getPolymerType(){const t=new RegExp("(PEPTIDE|RNA)[0-9]+{"),e=this.simplePolymer.match(t);if(!e)throw new Error(`Unsupported polymer type in ${this.simplePolymer}`);return e[1]}getIdx(){const t=new RegExp(`${this.polymerType}([0-9]+){`),e=this.simplePolymer.match(t);if(!e)throw new Error(`Cannot parse simple polymer id from ${this.simplePolymer}`);return parseInt(e[1])}getMonomerSymbolsAndTypes(){const t=new RegExp(`${this.polymerType}${this.idx}{|}`,"g"),e=this.simplePolymer.replace(t,"").split("."),n=[],o=[];return e.forEach((t=>{if(this.isNucleotideSequence){const e=t.split(/\(|\)/).filter((t=>!!t)).map((t=>(0,i.D)(t)));n.push(...e),e.forEach(((t,e)=>o.push(e%3==1?"Branch":"Backbone")))}else n.push((0,i.D)(t)),o.push("Backbone")})),{monomers:n,monomerTypes:o}}getBondData(){const t=[],e=this.monomerTypes.map(((t,e)=>{if("Backbone"===t)return e})).filter((t=>void 0!==t)),n=this.monomerTypes.map(((t,e)=>{if("Branch"===t)return e})).filter((t=>void 0!==t));for(let n=0;n<e.length-1;n++){const i=e[n],o=e[n+1];t.push([{monomerIdx:i,rGroupId:2},{monomerIdx:o,rGroupId:1}])}for(let e=0;e<n.length;e++){const i=n[e],o=i-1;t.push([{monomerIdx:o,rGroupId:3},{monomerIdx:i,rGroupId:1}])}return t}}},8604:(t,e,n)=>{"use strict";n.d(e,{Es:()=>o,G3:()=>s,gt:()=>r,so:()=>i});const i="System:AppData/Bio/monomer-libraries/",o="System:AppData/Bio/monomer-sets/",r="System:AppData/Bio/tests/libraries/HELMmonomerSchema.json",s={explicit:["HELMCoreLibrary.json","polytool-lib.json"],exclude:[],duplicateMonomerPreferences:{}}},1619:(t,e,n)=>{"use strict";n.d(e,{D:()=>M});var i=n(4328),o=n(6082),r=n(7389),s=n(8070),a=n(2003),l=n(608),c=n(8152),h=n(966),u=n(4139),d=n(5072),p=n.n(d),m=n(7825),f=n.n(m),g=n(7659),y=n.n(g),b=n(5056),v=n.n(b),w=n(540),C=n.n(w),A=n(1113),S=n.n(A),x=n(6369),E={};E.styleTagTransform=S(),E.setAttributes=v(),E.insert=y().bind(null,"head"),E.domAPI=f(),E.insertStyleElement=C(),p()(x.A,E),x.A&&x.A.locals&&x.A.locals;var T=n(6723);async function M(t,e){return new Promise((async(n,a)=>{t.clustersCol??=null,t.pepsea??={},t.pepsea.method??=u.HX.pepsea.method,t.pepsea.gapOpen??=u.HX.pepsea.gapOpen,t.pepsea.gapExtend??=u.HX.pepsea.gapExtend;const h=t.col?.dataFrame??i.shell.t;if(!h){const t="Multiple Sequence Alignment analysis requires a dataset with a macromolecule column.";return void a(new l.Ap(r.divText(t)))}const d=t.col??h.columns.bySemType(o.SEMTYPE.MACROMOLECULE);if(null==d){const t="Multiple Sequence Alignment analysis requires a dataset with a macromolecule column.";return void a(new l.Ap(r.divText(t)))}const p=r.input.choice("Method",{value:t.pepsea.method,items:c.ZY});p.setTooltip("Alignment method");const m=r.input.float("Terminal gap",{value:t?.kalign?.terminalGap});m.setTooltip("Penalty for opening a gap at the beginning or end of the sequence");const f=r.p(`Kalign version: ${u.b9}`,"kalign-version"),g=r.input.float("Gap open",{value:t.pepsea.gapOpen});g.setTooltip("Gap opening penalty at group-to-group alignment");const y=r.input.float("Gap extend",{value:t.pepsea.gapExtend});y.setTooltip("Gap extension penalty to skip the alignment");const b=r.input.bool("Selected Rows Only",{value:!1}),v=r.inputs([g,y,m]),w=r.button("Alignment parameters",(()=>{v.hidden=!v.hidden,[g,y,m].forEach((t=>{t.root.style.removeProperty("max-width"),t.captionLabel.style.removeProperty("max-width")}))}),"Adjust alignment parameters such as penalties for opening and extending gaps");w.classList.add("msa-params-button"),v.hidden=!0,w.prepend(r.icons.settings((()=>null)));const C=[p.root.style],A=[m.root.style,f.style];let S,x=d;const E=r.input.column("Sequence",{table:h,value:d,onValueChanged:async t=>{if(!t||t.semType!==o.SEMTYPE.MACROMOLECULE)return L.disabled=!0,await(0,s.cb)(0),void(E.value=x);x=t,L.disabled=!1,S=await I(E.value,h,e,C,A,p,T,g,y,m,b)},filter:t=>t.semType===o.SEMTYPE.MACROMOLECULE});E.setTooltip("Sequences column to use for alignment");const T=r.input.column("Clusters",{table:h,value:t.clustersCol});T.nullable=!0;const M=r.dialog("MSA").add(E).add(T).add(p).add(v).add(w).add(b).add(f).onOK((async()=>{await _(E,h,S,n,a)})),L=M.getButton("OK");if(E.fireChanged(),t.col)return S=await I(t.col,h,e,C,A,p,T,g,y,m,b),void await _(E,h,S,n,a);M.show()}))}async function _(t,e,n,r,s){let a=null;const l=o.TaskBarProgressIndicator.create("Analyze for MSA ...");try{if(t.fireChanged(),t.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 s("PepSeA container has not started");e.columns.add(a),await i.data.detectSemanticTypes(e),r(a)}catch(t){s(t)}finally{l.close()}}async function I(t,e,n,r,s,d,p,m,f,g,y){try{if(t.semType!==o.SEMTYPE.MACROMOLECULE)return;const i=e.columns.getUnusedName(`msa(${t.name})`);if((0,h.l)(t,t.name,n,[a.Hi.FASTA,a.Hi.SEPARATOR],[a.YI.DNA,a.YI.RNA,a.YI.PT])[0]){L(r,s,"kalign"),m.value=null,f.value=null,g.value=null;const o=n.getSeqHandler(t),c=o.isFasta()?t:o.convert(a.Hi.FASTA);return async()=>await(0,l.eE)(e,c,!1,i,p.value,void 0,void 0,void 0,y.value)}if((0,h.l)(t,t.name,n,[a.Hi.HELM],[])[0])return L(r,s,"pepsea"),m.value??=u.HX.pepsea.gapOpen,f.value??=u.HX.pepsea.gapExtend,async()=>(0,c.GD)(e,t,i,d.value,m.value,f.value,p.value,void 0,y.value);if((0,h.l)(t,t.name,n,[a.Hi.SEPARATOR],[a.YI.UN])[0]){const o=n.getSeqHandler(t).convert(a.Hi.HELM);return L(r,s,"pepsea"),m.value??=u.HX.pepsea.gapOpen,f.value??=u.HX.pepsea.gapExtend,async()=>(0,c.GD)(e,o,i,d.value,m.value,f.value,p.value,void 0,y.value)}return m.value=null,f.value=null,g.value=null,void L(r,s,"kalign")}catch(t){const e=t instanceof Error?t.message:t.toString();i.shell.error(e),T._package.logger.error(e)}}function L(t,e,n){if("kalign"===n){for(const e of t)e.display="none";for(const t of e)t.removeProperty("display")}else{for(const t of e)t.display="none";for(const e of t)e.removeProperty("display")}}},608:(t,e,n)=>{"use strict";n.d(e,{Ap:()=>H,aZ:()=>B,eE:()=>F});var i=n(7389),o=n(6082),r=n(1991),s=n.n(r),a=n(3516),l=n(2003);const c=Symbol("Comlink.proxy"),h=Symbol("Comlink.endpoint"),u=Symbol("Comlink.releaseProxy"),d=Symbol("Comlink.thrown"),p=t=>"object"==typeof t&&null!==t||"function"==typeof t,m=new Map([["proxy",{canHandle:t=>p(t)&&t[c],serialize(t){const{port1:e,port2:n}=new MessageChannel;return f(t,e),[n,[n]]},deserialize:t=>(t.start(),y(t))}],["throw",{canHandle:t=>p(t)&&d in t,serialize({value:t}){let e;return e=t instanceof Error?{isError:!0,value:{message:t.message,name:t.name,stack:t.stack}}:{isError:!1,value:t},[e,[]]},deserialize(t){throw t.isError?Object.assign(new Error(t.value.message),t.value):t.value}}]]);function f(t,e=self){e.addEventListener("message",(function n(i){if(!i||!i.data)return;const{id:o,type:r,path:s}=Object.assign({path:[]},i.data),a=(i.data.argumentList||[]).map(x);let l;try{const e=s.slice(0,-1).reduce(((t,e)=>t[e]),t),n=s.reduce(((t,e)=>t[e]),t);switch(r){case"GET":l=n;break;case"SET":e[s.slice(-1)[0]]=x(i.data.value),l=!0;break;case"APPLY":l=n.apply(e,a);break;case"CONSTRUCT":l=function(t){return Object.assign(t,{[c]:!0})}(new n(...a));break;case"ENDPOINT":{const{port1:e,port2:n}=new MessageChannel;f(t,n),l=function(t,e){return A.set(t,e),t}(e,[e])}break;case"RELEASE":l=void 0;break;default:return}}catch(t){l={value:t,[d]:0}}Promise.resolve(l).catch((t=>({value:t,[d]:0}))).then((t=>{const[i,s]=S(t);e.postMessage(Object.assign(Object.assign({},i),{id:o}),s),"RELEASE"===r&&(e.removeEventListener("message",n),g(e))}))})),e.start&&e.start()}function g(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function y(t,e){return v(t,[],e)}function b(t){if(t)throw new Error("Proxy has been released and is not useable")}function v(t,e=[],n=function(){}){let i=!1;const o=new Proxy(n,{get(n,r){if(b(i),r===u)return()=>E(t,{type:"RELEASE",path:e.map((t=>t.toString()))}).then((()=>{g(t),i=!0}));if("then"===r){if(0===e.length)return{then:()=>o};const n=E(t,{type:"GET",path:e.map((t=>t.toString()))}).then(x);return n.then.bind(n)}return v(t,[...e,r])},set(n,o,r){b(i);const[s,a]=S(r);return E(t,{type:"SET",path:[...e,o].map((t=>t.toString())),value:s},a).then(x)},apply(n,o,r){b(i);const s=e[e.length-1];if(s===h)return E(t,{type:"ENDPOINT"}).then(x);if("bind"===s)return v(t,e.slice(0,-1));const[a,l]=C(r);return E(t,{type:"APPLY",path:e.map((t=>t.toString())),argumentList:a},l).then(x)},construct(n,o){b(i);const[r,s]=C(o);return E(t,{type:"CONSTRUCT",path:e.map((t=>t.toString())),argumentList:r},s).then(x)}});return o}function w(t){return Array.prototype.concat.apply([],t)}function C(t){const e=t.map(S);return[e.map((t=>t[0])),w(e.map((t=>t[1])))]}const A=new WeakMap;function S(t){for(const[e,n]of m)if(n.canHandle(t)){const[i,o]=n.serialize(t);return[{type:"HANDLER",name:e,value:i},o]}return[{type:"RAW",value:t},A.get(t)||[]]}function x(t){switch(t.type){case"HANDLER":return m.get(t.name).deserialize(t.value);case"RAW":return t.value}}function E(t,e,n){return new Promise((i=>{const o=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");t.addEventListener("message",(function e(n){!n.data||!n.data.id||n.data.id!==o||(t.removeEventListener("message",e),i(n.data))})),t.start&&t.start(),t.postMessage(Object.assign({id:o},e),n)}))}const T="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0ICQ9U3ltYm9sKCJDb21saW5rLnByb3h5IiksQT1TeW1ib2woIkNvbWxpbmsuZW5kcG9pbnQiKSxSPVN5bWJvbCgiQ29tbGluay5yZWxlYXNlUHJveHkiKSx5PVN5bWJvbCgiQ29tbGluay50aHJvd24iKSxfPWU9PnR5cGVvZiBlPT0ib2JqZWN0IiYmZSE9PW51bGx8fHR5cGVvZiBlPT0iZnVuY3Rpb24iLEw9e2NhbkhhbmRsZTplPT5fKGUpJiZlWyRdLHNlcmlhbGl6ZShlKXtjb25zdHtwb3J0MTpyLHBvcnQyOml9PW5ldyBNZXNzYWdlQ2hhbm5lbDtyZXR1cm4gdyhlLHIpLFtpLFtpXV19LGRlc2VyaWFsaXplKGUpe3JldHVybiBlLnN0YXJ0KCksQyhlKX19LE89e2NhbkhhbmRsZTplPT5fKGUpJiZ5IGluIGUsc2VyaWFsaXplKHt2YWx1ZTplfSl7bGV0IHI7cmV0dXJuIGUgaW5zdGFuY2VvZiBFcnJvcj9yPXtpc0Vycm9yOiEwLHZhbHVlOnttZXNzYWdlOmUubWVzc2FnZSxuYW1lOmUubmFtZSxzdGFjazplLnN0YWNrfX06cj17aXNFcnJvcjohMSx2YWx1ZTplfSxbcixbXV19LGRlc2VyaWFsaXplKGUpe3Rocm93IGUuaXNFcnJvcj9PYmplY3QuYXNzaWduKG5ldyBFcnJvcihlLnZhbHVlLm1lc3NhZ2UpLGUudmFsdWUpOmUudmFsdWV9fSxFPW5ldyBNYXAoW1sicHJveHkiLExdLFsidGhyb3ciLE9dXSk7ZnVuY3Rpb24gdyhlLHI9c2VsZil7ci5hZGRFdmVudExpc3RlbmVyKCJtZXNzYWdlIixmdW5jdGlvbiBpKHMpe2lmKCFzfHwhcy5kYXRhKXJldHVybjtjb25zdHtpZDpvLHR5cGU6YSxwYXRoOm59PU9iamVjdC5hc3NpZ24oe3BhdGg6W119LHMuZGF0YSksYz0ocy5kYXRhLmFyZ3VtZW50TGlzdHx8W10pLm1hcChtKTtsZXQgbDt0cnl7Y29uc3QgdT1uLnNsaWNlKDAsLTEpLnJlZHVjZSgoZCxwKT0+ZFtwXSxlKSxmPW4ucmVkdWNlKChkLHApPT5kW3BdLGUpO3N3aXRjaChhKXtjYXNlIkdFVCI6bD1mO2JyZWFrO2Nhc2UiU0VUIjp1W24uc2xpY2UoLTEpWzBdXT1tKHMuZGF0YS52YWx1ZSksbD0hMDticmVhaztjYXNlIkFQUExZIjpsPWYuYXBwbHkodSxjKTticmVhaztjYXNlIkNPTlNUUlVDVCI6e2NvbnN0IGQ9bmV3IGYoLi4uYyk7bD16KGQpfWJyZWFrO2Nhc2UiRU5EUE9JTlQiOntjb25zdHtwb3J0MTpkLHBvcnQyOnB9PW5ldyBNZXNzYWdlQ2hhbm5lbDt3KGUscCksbD1OKGQsW2RdKX1icmVhaztjYXNlIlJFTEVBU0UiOmw9dm9pZCAwO2JyZWFrO2RlZmF1bHQ6cmV0dXJufX1jYXRjaCh1KXtsPXt2YWx1ZTp1LFt5XTowfX1Qcm9taXNlLnJlc29sdmUobCkuY2F0Y2godT0+KHt2YWx1ZTp1LFt5XTowfSkpLnRoZW4odT0+e2NvbnN0W2YsZF09Uyh1KTtyLnBvc3RNZXNzYWdlKE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSxmKSx7aWQ6b30pLGQpLGE9PT0iUkVMRUFTRSImJihyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGkpLE0ocikpfSl9KSxyLnN0YXJ0JiZyLnN0YXJ0KCl9ZnVuY3Rpb24gVChlKXtyZXR1cm4gZS5jb25zdHJ1Y3Rvci5uYW1lPT09Ik1lc3NhZ2VQb3J0In1mdW5jdGlvbiBNKGUpe1QoZSkmJmUuY2xvc2UoKX1mdW5jdGlvbiBDKGUscil7cmV0dXJuIGIoZSxbXSxyKX1mdW5jdGlvbiBoKGUpe2lmKGUpdGhyb3cgbmV3IEVycm9yKCJQcm94eSBoYXMgYmVlbiByZWxlYXNlZCBhbmQgaXMgbm90IHVzZWFibGUiKX1mdW5jdGlvbiBiKGUscj1bXSxpPWZ1bmN0aW9uKCl7fSl7bGV0IHM9ITE7Y29uc3Qgbz1uZXcgUHJveHkoaSx7Z2V0KGEsbil7aWYoaChzKSxuPT09UilyZXR1cm4oKT0+ZyhlLHt0eXBlOiJSRUxFQVNFIixwYXRoOnIubWFwKGM9PmMudG9TdHJpbmcoKSl9KS50aGVuKCgpPT57TShlKSxzPSEwfSk7aWYobj09PSJ0aGVuIil7aWYoci5sZW5ndGg9PT0wKXJldHVybnt0aGVuOigpPT5vfTtjb25zdCBjPWcoZSx7dHlwZToiR0VUIixwYXRoOnIubWFwKGw9PmwudG9TdHJpbmcoKSl9KS50aGVuKG0pO3JldHVybiBjLnRoZW4uYmluZChjKX1yZXR1cm4gYihlLFsuLi5yLG5dKX0sc2V0KGEsbixjKXtoKHMpO2NvbnN0W2wsdV09UyhjKTtyZXR1cm4gZyhlLHt0eXBlOiJTRVQiLHBhdGg6Wy4uLnIsbl0ubWFwKGY9PmYudG9TdHJpbmcoKSksdmFsdWU6bH0sdSkudGhlbihtKX0sYXBwbHkoYSxuLGMpe2gocyk7Y29uc3QgbD1yW3IubGVuZ3RoLTFdO2lmKGw9PT1BKXJldHVybiBnKGUse3R5cGU6IkVORFBPSU5UIn0pLnRoZW4obSk7aWYobD09PSJiaW5kIilyZXR1cm4gYihlLHIuc2xpY2UoMCwtMSkpO2NvbnN0W3UsZl09RihjKTtyZXR1cm4gZyhlLHt0eXBlOiJBUFBMWSIscGF0aDpyLm1hcChkPT5kLnRvU3RyaW5nKCkpLGFyZ3VtZW50TGlzdDp1fSxmKS50aGVuKG0pfSxjb25zdHJ1Y3QoYSxuKXtoKHMpO2NvbnN0W2MsbF09RihuKTtyZXR1cm4gZyhlLHt0eXBlOiJDT05TVFJVQ1QiLHBhdGg6ci5tYXAodT0+dS50b1N0cmluZygpKSxhcmd1bWVudExpc3Q6Y30sbCkudGhlbihtKX19KTtyZXR1cm4gb31mdW5jdGlvbiBEKGUpe3JldHVybiBBcnJheS5wcm90b3R5cGUuY29uY2F0LmFwcGx5KFtdLGUpfWZ1bmN0aW9uIEYoZSl7Y29uc3Qgcj1lLm1hcChTKTtyZXR1cm5bci5tYXAoaT0+aVswXSksRChyLm1hcChpPT5pWzFdKSldfWNvbnN0IFA9bmV3IFdlYWtNYXA7ZnVuY3Rpb24gTihlLHIpe3JldHVybiBQLnNldChlLHIpLGV9ZnVuY3Rpb24geihlKXtyZXR1cm4gT2JqZWN0LmFzc2lnbihlLHtbJF06ITB9KX1mdW5jdGlvbiBTKGUpe2Zvcihjb25zdFtyLGldb2YgRSlpZihpLmNhbkhhbmRsZShlKSl7Y29uc3RbcyxvXT1pLnNlcmlhbGl6ZShlKTtyZXR1cm5be3R5cGU6IkhBTkRMRVIiLG5hbWU6cix2YWx1ZTpzfSxvXX1yZXR1cm5be3R5cGU6IlJBVyIsdmFsdWU6ZX0sUC5nZXQoZSl8fFtdXX1mdW5jdGlvbiBtKGUpe3N3aXRjaChlLnR5cGUpe2Nhc2UiSEFORExFUiI6cmV0dXJuIEUuZ2V0KGUubmFtZSkuZGVzZXJpYWxpemUoZS52YWx1ZSk7Y2FzZSJSQVciOnJldHVybiBlLnZhbHVlfX1mdW5jdGlvbiBnKGUscixpKXtyZXR1cm4gbmV3IFByb21pc2Uocz0+e2NvbnN0IG89VSgpO2UuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsZnVuY3Rpb24gYShuKXshbi5kYXRhfHwhbi5kYXRhLmlkfHxuLmRhdGEuaWQhPT1vfHwoZS5yZW1vdmVFdmVudExpc3RlbmVyKCJtZXNzYWdlIixhKSxzKG4uZGF0YSkpfSksZS5zdGFydCYmZS5zdGFydCgpLGUucG9zdE1lc3NhZ2UoT2JqZWN0LmFzc2lnbih7aWQ6b30sciksaSl9KX1mdW5jdGlvbiBVKCl7cmV0dXJuIG5ldyBBcnJheSg0KS5maWxsKDApLm1hcCgoKT0+TWF0aC5mbG9vcihNYXRoLnJhbmRvbSgpKk51bWJlci5NQVhfU0FGRV9JTlRFR0VSKS50b1N0cmluZygxNikpLmpvaW4oIi0iKX1jb25zdCBXPWFzeW5jKCk9PldlYkFzc2VtYmx5LnZhbGlkYXRlKG5ldyBVaW50OEFycmF5KFswLDk3LDExNSwxMDksMSwwLDAsMCwxLDUsMSw5NiwwLDEsMTIzLDMsMiwxLDAsMTAsMTAsMSw4LDAsNjUsMCwyNTMsMTUsMjUzLDk4LDExXSkpLGs9ImVhZ2VyIix4PSJsYXp5IixqPXtzc3c6WyJzaW1kIl0sbWluaW1hcDI6WyJzaW1kIl19LHQ9e3Rvb2xzOltdLGNvbmZpZzp7fSxmaWxlczpbXSxiYXNlOnt9LGZzOnt9LGFzeW5jIGluaXQoKXtpZih0LnRvb2xzLmxlbmd0aD09PTApdGhyb3ciRXhwZWN0aW5nIGF0IGxlYXN0IDEgdG9vbC4iO2lmKG5ldyBTZXQodC50b29scy5tYXAocj0+YCR7ci50b29sfS8ke3IucHJvZ3JhbXx8ci50b29sfWApKS5zaXplIT09dC50b29scy5sZW5ndGgpdGhyb3ciRm91bmQgZHVwbGljYXRlIHRvb2xzOyBjYW4gb25seSBoYXZlIGVhY2ggdG9vbC9wcm9ncmFtIGNvbWJpbmF0aW9uIGF0IG1vc3Qgb25jZS4iO2lmKHQuYmFzZT10LnRvb2xzLmZpbmQocj0+ci5yZWluaXQhPT0hMCksIXQuYmFzZSl0aHJvdyJDb3VsZCBub3QgZmluZCBhIHRvb2wgd2l0aCBgcmVpbml0OiBmYWxzZWAgdG8gdXNlIGFzIHRoZSBiYXNlIG1vZHVsZS4gVG8gZml4IHRoaXMgaXNzdWUsIGluY2x1ZGUgdGhlIHRvb2wgYGJhc2UvMS4wLjBgIHdoZW4gaW5pdGlhbGl6aW5nIEFpb2xpLiI7cmV0dXJuIHQuYmFzZS5pc0Jhc2VNb2R1bGU9ITAsYXdhaXQgdGhpcy5fc2V0dXAodC5iYXNlKSxhd2FpdCB0aGlzLl9pbml0TW9kdWxlcygpLHQuX2xvZygiUmVhZHkiKSwhMH0sYXN5bmMgX2luaXRNb2R1bGVzKCl7YXdhaXQgUHJvbWlzZS5hbGwodC50b29scy5tYXAodGhpcy5fc2V0dXApKSxhd2FpdCB0aGlzLl9zZXR1cEZTKCl9LG1vdW50KGU9W10pe2NvbnN0IHI9YCR7dC5jb25maWcuZGlyU2hhcmVkfSR7dC5jb25maWcuZGlyRGF0YX1gLGk9YCR7dC5jb25maWcuZGlyU2hhcmVkfSR7dC5jb25maWcuZGlyTW91bnRlZH1gO2xldCBzPVtdLG89W10sYT1bXTshQXJyYXkuaXNBcnJheShlKSYmIShlIGluc3RhbmNlb2YgRmlsZUxpc3QpJiYoZT1bZV0pLHQuX2xvZyhgTW91bnRpbmcgJHtlLmxlbmd0aH0gZmlsZXNgKTtmb3IobGV0IG4gb2YgZSl7aWYobiBpbnN0YW5jZW9mIEZpbGV8fChuPT1udWxsP3ZvaWQgMDpuLmRhdGEpaW5zdGFuY2VvZiBCbG9iJiZuLm5hbWV8fHR5cGVvZihuPT1udWxsP3ZvaWQgMDpuLmRhdGEpPT0ic3RyaW5nIiYmbi5uYW1lKXR5cGVvZihuPT1udWxsP3ZvaWQgMDpuLmRhdGEpPT0ic3RyaW5nIiYmKG4uZGF0YT1uZXcgQmxvYihbbi5kYXRhXSx7dHlwZToidGV4dC9wbGFpbiJ9KSkscy5wdXNoKG4pO2Vsc2UgaWYobi5uYW1lJiZuLnVybClvLnB1c2gobik7ZWxzZSBpZih0eXBlb2Ygbj09InN0cmluZyImJm4uc3RhcnRzV2l0aCgiaHR0cCIpKW49e3VybDpuLG5hbWU6bi5zcGxpdCgiLy8iKS5wb3AoKS5yZXBsYWNlKC9cLy9nLCItIil9LG8ucHVzaChuKTtlbHNlIHRocm93J0Nhbm5vdCBtb3VudCBmaWxlKHMpIHNwZWNpZmllZC4gTXVzdCBiZSBhIEZpbGUsIEJsb2IsIGEgVVJMIHN0cmluZywgb3IgeyBuYW1lOiAiZmlsZS50eHQiLCBkYXRhOiAic3RyaW5nIiB9Lic7YS5wdXNoKG4ubmFtZSl9dHJ5e3QuZnMudW5tb3VudChpKX1jYXRjaHt9Zm9yKGxldCBuIG9mIG8pdC5mcy5jcmVhdGVMYXp5RmlsZShyLG4ubmFtZSxuLnVybCwhMCwhMCk7cmV0dXJuIHQuZmlsZXM9dC5maWxlcy5jb25jYXQocyksdC5iYXNlLm1vZHVsZS5GUy5tb3VudCh0LmJhc2UubW9kdWxlLldPUktFUkZTLHtmaWxlczp0LmZpbGVzLmZpbHRlcihuPT5uIGluc3RhbmNlb2YgRmlsZSksYmxvYnM6dC5maWxlcy5maWx0ZXIobj0+KG49PW51bGw/dm9pZCAwOm4uZGF0YSlpbnN0YW5jZW9mIEJsb2IpfSxpKSxzLm1hcChuPT57Y29uc3QgYz1gJHtpfS8ke24ubmFtZX1gLGw9YCR7cn0vJHtuLm5hbWV9YDt0cnl7dC5mcy51bmxpbmsobCl9Y2F0Y2h7fXQuX2xvZyhgQ3JlYXRpbmcgc3ltbGluazogJHtsfSAtLT4gJHtjfWApLHQuZnMuc3ltbGluayhjLGwpfSksYS5tYXAobj0+YCR7cn0vJHtufWApfSxhc3luYyBleGVjKGUscj1udWxsKXtpZih0Ll9sb2coYEV4ZWN1dGluZyAlYyR7ZX0lYyBhcmdzPSR7cn1gLCJjb2xvcjpkYXJrYmx1ZTsgZm9udC13ZWlnaHQ6Ym9sZCIsIiIpLCFlKXRocm93IkV4cGVjdGluZyBhIGNvbW1hbmQiO2xldCBpPWU7cj09bnVsbCYmKHI9ZS5zcGxpdCgiICIpLGk9ci5zaGlmdCgpKTtjb25zdCBzPXQudG9vbHMuZmluZChhPT57dmFyIGM7bGV0IG49aTtyZXR1cm4oKGM9YT09bnVsbD92b2lkIDA6YS5mZWF0dXJlcyk9PW51bGw/dm9pZCAwOmMuc2ltZCk9PT0hMCYmKG49YCR7bn0tc2ltZGApLGEucHJvZ3JhbT09bn0pO2lmKHM9PW51bGwpdGhyb3dgUHJvZ3JhbSAke2l9IG5vdCBmb3VuZC5gO3Muc3Rkb3V0PSIiLHMuc3RkZXJyPSIiLHMubG9hZGluZz09eCYmKHMubG9hZGluZz1rLGF3YWl0IHRoaXMuX2luaXRNb2R1bGVzKCkpO3RyeXtzLm1vZHVsZS5jYWxsTWFpbihyKX1jYXRjaChhKXtjb25zb2xlLmVycm9yKGEpfXRyeXtzLm1vZHVsZS5GUy5jbG9zZShzLm1vZHVsZS5GUy5zdHJlYW1zWzFdKSxzLm1vZHVsZS5GUy5jbG9zZShzLm1vZHVsZS5GUy5zdHJlYW1zWzJdKX1jYXRjaHt9cy5tb2R1bGUuRlMuc3RyZWFtc1sxXT1zLm1vZHVsZS5GUy5vcGVuKCIvZGV2L3N0ZG91dCIsInciKSxzLm1vZHVsZS5GUy5zdHJlYW1zWzJdPXMubW9kdWxlLkZTLm9wZW4oIi9kZXYvc3RkZXJyIiwidyIpO2xldCBvPXtzdGRvdXQ6cy5zdGRvdXQsc3RkZXJyOnMuc3RkZXJyfTtyZXR1cm4gdC5jb25maWcucHJpbnRJbnRlcmxlYXZlZCYmKG89cy5zdGRvdXQpLHMucmVpbml0PT09ITAmJmF3YWl0IHRoaXMucmVpbml0KHMudG9vbCksb30sY2F0KGUpe3JldHVybiB0Ll9maWxlb3AoImNhdCIsZSl9LGxzKGUpe3JldHVybiB0Ll9maWxlb3AoImxzIixlKX0sZG93bmxvYWQoZSl7cmV0dXJuIHQuX2ZpbGVvcCgiZG93bmxvYWQiLGUpfSxwd2QoKXtyZXR1cm4gdC5mcy5jd2QoKX0sY2QoZSl7Zm9yKGxldCByIG9mIHQudG9vbHMpIXIubW9kdWxlfHxyLm1vZHVsZS5GUy5jaGRpcihlKX0sbWtkaXIoZSl7cmV0dXJuIHQuZnMubWtkaXIoZSksITB9LHJlYWQoe3BhdGg6ZSxsZW5ndGg6cixmbGFnOmk9InIiLG9mZnNldDpzPTAscG9zaXRpb246bz0wfSl7Y29uc3QgYT10LmZzLm9wZW4oZSxpKSxuPW5ldyBVaW50OEFycmF5KHIpO3JldHVybiB0LmZzLnJlYWQoYSxuLHMscixvKSx0LmZzLmNsb3NlKGEpLG59LHdyaXRlKHtwYXRoOmUsYnVmZmVyOnIsZmxhZzppPSJ3KyIsb2Zmc2V0OnM9MCxwb3NpdGlvbjpvPTB9KXtjb25zdCBhPXQuZnMub3BlbihlLGkpO3QuZnMud3JpdGUoYSxyLHMsci5sZW5ndGgsbyksdC5mcy5jbG9zZShhKX0sYXN5bmMgcmVpbml0KGUpe2NvbnN0IHI9dC50b29scy5maW5kKHM9PnMudG9vbD09ZSksaT10LmJhc2UubW9kdWxlLkZTLmN3ZCgpO09iamVjdC5hc3NpZ24ocixyLmNvbmZpZyksci5yZWFkeT0hMSxhd2FpdCB0aGlzLmluaXQoKSxyLmlzQmFzZU1vZHVsZSYmdGhpcy5tb3VudCgpLHRoaXMuY2QoaSl9LF9zdGRpblR4dDoiIixfc3RkaW5QdHI6MCxnZXQgc3RkaW4oKXtyZXR1cm4gdC5fc3RkaW5UeHR9LHNldCBzdGRpbihlPSIiKXt0Ll9sb2coYFNldHRpbmcgc3RkaW4gdG8gJWMke2V9JWNgLCJjb2xvcjpkYXJrYmx1ZSIsIiIpLHQuX3N0ZGluVHh0PWUsdC5fc3RkaW5QdHI9MH0sYXN5bmMgX3NldHVwKGUpe2lmKGUucmVhZHkpcmV0dXJuO2lmKHQuX2xvZyhgU2V0dGluZyB1cCAke2UudG9vbH0gKGJhc2UgPSAke2UuaXNCYXNlTW9kdWxlPT09ITB9KS4uLmApLGUuY29uZmlnPU9iamVjdC5hc3NpZ24oe30sZSksZS51cmxQcmVmaXh8fChlLnVybFByZWZpeD1gJHt0LmNvbmZpZy51cmxDRE59LyR7ZS50b29sfS8ke2UudmVyc2lvbn1gKSxlLnByb2dyYW18fChlLnByb2dyYW09ZS50b29sKSxlLmZlYXR1cmVzfHwoZS5mZWF0dXJlcz17fSwoaltlLnByb2dyYW1dfHxbXSkuaW5jbHVkZXMoInNpbWQiKSYmKGF3YWl0IFcoKT8oZS5wcm9ncmFtKz0iLXNpbWQiLGUuZmVhdHVyZXMuc2ltZD0hMCk6dC5fbG9nKGBXZWJBc3NlbWJseSBTSU1EIGlzIG5vdCBzdXBwb3J0ZWQgaW4gdGhpcyBicm93c2VyOyB3aWxsIGxvYWQgbm9uLVNJTUQgdmVyc2lvbiBvZiAke2UucHJvZ3JhbX0uYCkpKSxlLmlzQmFzZU1vZHVsZSYmKGUubG9hZGluZz1rKSxlLmxvYWRpbmc9PT14KXt0Ll9sb2coYFdpbGwgbGF6eS1sb2FkICR7ZS50b29sfTsgc2tpcHBpbmcgaW5pdGlhbGl6YXRpb24uYCk7cmV0dXJufXNlbGYuaW1wb3J0U2NyaXB0cyhgJHtlLnVybFByZWZpeH0vJHtlLnByb2dyYW19LmpzYCksZS5tb2R1bGU9YXdhaXQgTW9kdWxlKHt0aGlzUHJvZ3JhbTplLnByb2dyYW0sbG9jYXRlRmlsZTooaSxzKT0+YCR7ZS51cmxQcmVmaXh9LyR7aX1gLHN0ZGluOigpPT50Ll9zdGRpblB0cjx0LnN0ZGluLmxlbmd0aD90LnN0ZGluLmNoYXJDb2RlQXQodC5fc3RkaW5QdHIrKyk6KHQuc3RkaW49IiIsbnVsbCkscHJpbnQ6aT0+e3QuY29uZmlnLnByaW50U3RyZWFtP3Bvc3RNZXNzYWdlKHt0eXBlOiJiaW93YXNtIix2YWx1ZTp7c3Rkb3V0Oml9fSk6ZS5zdGRvdXQrPWkrYApgfSxwcmludEVycjppPT57Y29uc3Qgcz10LmNvbmZpZy5wcmludEludGVybGVhdmVkPyJzdGRvdXQiOiJzdGRlcnIiO3QuY29uZmlnLnByaW50U3RyZWFtP3Bvc3RNZXNzYWdlKHt0eXBlOiJiaW93YXNtIix2YWx1ZTp7W3NdOml9fSk6ZVtzXSs9aStgCmB9fSk7Y29uc3Qgcj1lLm1vZHVsZS5GUztlLmlzQmFzZU1vZHVsZT8odC5fbG9nKGBTZXR0aW5nIHVwICR7ZS50b29sfSB3aXRoIGJhc2UgbW9kdWxlIGZpbGVzeXN0ZW0uLi5gKSxyLm1rZGlyKHQuY29uZmlnLmRpclNoYXJlZCw1MTEpLHIubWtkaXIoYCR7dC5jb25maWcuZGlyU2hhcmVkfS8ke3QuY29uZmlnLmRpckRhdGF9YCw1MTEpLHIubWtkaXIoYCR7dC5jb25maWcuZGlyU2hhcmVkfS8ke3QuY29uZmlnLmRpck1vdW50ZWR9YCw1MTEpLHIuY2hkaXIoYCR7dC5jb25maWcuZGlyU2hhcmVkfS8ke3QuY29uZmlnLmRpckRhdGF9YCksdC5mcz1yKToodC5fbG9nKGBTZXR0aW5nIHVwICR7ZS50b29sfSB3aXRoIGZpbGVzeXN0ZW0uLi5gKSxyLm1rZGlyKHQuY29uZmlnLmRpclNoYXJlZCksci5tb3VudChlLm1vZHVsZS5QUk9YWUZTLHtyb290OnQuY29uZmlnLmRpclNoYXJlZCxmczp0LmZzfSx0LmNvbmZpZy5kaXJTaGFyZWQpLHIuY2hkaXIodC5mcy5jd2QoKSkpLGUuc3Rkb3V0PSIiLGUuc3RkZXJyPSIiLGUucmVhZHk9ITB9LGFzeW5jIF9zZXR1cEZTKCl7Y29uc3QgZT10LmZzO2ZvcihsZXQgciBvZiB0LnRvb2xzKXtpZighci5yZWFkeSljb250aW51ZTtjb25zdCBpPXIubW9kdWxlLkZTLHM9YC8ke3IudG9vbH1gLG89YCR7dC5jb25maWcuZGlyU2hhcmVkfSR7c31gOyFpLmFuYWx5emVQYXRoKHMpLmV4aXN0c3x8ZS5hbmFseXplUGF0aChvKS5leGlzdHN8fCh0Ll9sb2coYE1vdW50aW5nICR7c30gb250byAke3QuYmFzZS50b29sfSBmaWxlc3lzdGVtIGF0ICR7b31gKSxlLm1rZGlyKG8pLGUubW91bnQodC5iYXNlLm1vZHVsZS5QUk9YWUZTLHtyb290OnMsZnM6aX0sbykpfX0sX2ZpbGVvcChlLHIpe3QuX2xvZyhgUnVubmluZyAke2V9ICR7cn1gKTtjb25zdCBpPXQuZnMuYW5hbHl6ZVBhdGgocik7aWYoIWkuZXhpc3RzKXJldHVybiB0Ll9sb2coYEZpbGUgJHtyfSBub3QgZm91bmQuYCksITE7c3dpdGNoKGUpe2Nhc2UiY2F0IjpyZXR1cm4gdC5mcy5yZWFkRmlsZShyLHtlbmNvZGluZzoidXRmOCJ9KTtjYXNlImxzIjpyZXR1cm4gdC5mcy5pc0ZpbGUoaS5vYmplY3QubW9kZSk/dC5mcy5zdGF0KHIpOnQuZnMucmVhZGRpcihyKTtjYXNlImRvd25sb2FkIjpjb25zdCBzPW5ldyBCbG9iKFt0aGlzLmNhdChyKV0pO3JldHVybiBVUkwuY3JlYXRlT2JqZWN0VVJMKHMpfXJldHVybiExfSxfbG9nKGUpe2lmKCF0LmNvbmZpZy5kZWJ1ZylyZXR1cm47bGV0IHI9Wy4uLmFyZ3VtZW50c107ci5zaGlmdCgpLGNvbnNvbGUubG9nKGAlY1tXZWJXb3JrZXJdJWMgJHtlfWAsImZvbnQtd2VpZ2h0OmJvbGQiLCIiLC4uLnIpfX07dyh0KX0pKCk7Cg==",M=typeof window<"u"&&window.Blob&&new Blob([atob(T)],{type:"text/javascript;charset=utf-8"});function _(){const t=M&&(window.URL||window.webkitURL).createObjectURL(M);try{return t?new Worker(t):new Worker("data:application/javascript;base64,"+T)}finally{t&&(window.URL||window.webkitURL).revokeObjectURL(t)}}const I={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 L{constructor(t,e={}){if(null==t)throw"Expecting array of tools as input to Aioli constructor.";return Array.isArray(t)||(t=[t]),e=Object.assign({},I,e),t=t.map(this._parseTool),"stg"===e.env&&(e.urlCDN=e.urlCDNStg),this.tools=t,this.config=e,null!=this.config.callback&&(this.callback=this.config.callback),delete this.config.callback,this.init()}async init(){const t=new _;this.callback&&(t.onmessage=t=>{"biowasm"===t.data.type&&this.callback(t.data.value)});const e=y(t);return e.tools=this.tools,e.config=this.config,await e.init(),e}_parseTool(t){if("string"!=typeof t)return t;const e=t.split("/");if(2!=e.length&&3!=e.length)throw"Expecting '<tool>/<version>' or '<tool>/<program>/<version>'";return{tool:e[0],program:3==e.length?e[1]:e[0],version:e[e.length-1]}}}var N=n(3629);class P{static getAvailableScales(){return Object.entries(this.scales).map((([t,e])=>t))}static getScale(t){return(0,N.vA)(!(void 0===this.scales[t]),`Scale '${t}' was not found.`),this.scales[t]}}P.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 ${constructor(t="categorial"){this.aa2num=P.getScale(t),this.num2aa={},Object.entries(this.aa2num).forEach((([t,e])=>this.num2aa[e]=t))}static _truncateSequence(t){let e=0,n=t.length;const i=["NH2","COOH"];if(t.startsWith(i[0])){const n=i[0].length;(0,N.vA)("-"==t[n],`Wrong sequence format: ${i[0]} without following '-' in '${t}'.`),e=n}if(t.endsWith(i[1])){const e=i[1].length+1;(0,N.vA)("-"==t[n-e],`Wrong sequence format: ${i[1]} without '-' precending in '${t}'.`),n-=e}return t.substring(e,n)}static _dropDefises(t){return t.replace(/(-)([^-]+)/g,"$2")}static clean(t){return $._dropDefises($._truncateSequence(t))}encode(t){const e=t.length,n=new Array(e).fill(0);for(let i=0;i<e;++i){const e=t[i];(0,N.vA)(e in this.aa2num,`Unknown char '${e}' found in sequence '${t}'`),n[i]=this.encodeLettter(e)}return n}encodeLettter(t){return this.aa2num[t]}decode(t){let e="";for(let n=0;n<t.length;++n){const i=t[n];(0,N.vA)(i in this.num2aa,`Unknown code '${i}' found in vector '${t}'`),e+=this.num2aa[i]}return e}}var R=n(4139);const k="input.fa",O="result.fasta";class H extends Error{element;constructor(t,e){super(t.innerText,e),this.element=t}}function G(t){return t.reduce(((t,e,n)=>t+`>sample${n+1}\n${e}\n`),"")}async function F(t,e,n=!1,i="",r=null,s,c,h,u){let d=e.toList();n&&(d=d.map((t=>$.clean(t).replace(/\-/g,""))));const p=e.length;r??=o.Column.string("Clusters",p).init("0"),r.type!=o.COLUMN_TYPE.STRING&&(r=r.convertTo(o.TYPE.STRING)),r.compact();const m=r.categories,f=r.getRawData(),g=new Array(m.length),y=new Array(m.length);if(u){const e=t.selection;if(0===e.length)throw new Error("No selected rows in the table.");for(let t=-1;-1!==(t=e.findNext(t,!0));){const e=f[t];(g[e]??=[]).push(d[t]),(y[e]??=[]).push(t)}}else for(let t=0;t<p;++t){const e=f[t];(g[e]??=[]).push(d[t]),(y[e]??=[]).push(t)}B(y,m);const b=await new L(["base/1.0.0",{tool:"kalign",version:R.b9,reinit:!0}]),v=o.Column.string(i,p);for(let t=0;t<m.length;++t){const e=g[t];if(!e||0===e.length)continue;const n=G(e);await b.fs.writeFile(k,n);const i=`${void 0!==s?` --gpo ${s}`:""}${void 0!==c?` --gpe ${c}`:""}${void 0!==h?` --tgpe ${h}`:""}`,o=await b.exec(`kalign ${k} -f fasta -o ${O}${i}`);console.warn(o);const r=await b.cat(O);if(!r){const t=D(o,1);throw new Error(t)}const l=new a.m(r).sequencesArray,u=y[t];for(let t=0;t<l.length;++t)v.set(u[t],l[t])}const w=e.meta.units,C=e.getTag(l.gp.alphabet);return v.meta.units=w,v.setTag(l.gp.aligned,"SEQ.MSA"),v.setTag(l.gp.alphabet,C),v.semType=o.SEMTYPE.MACROMOLECULE,v}function D(t,e){const n=[],i=/^.+ERROR : (.+)$/gm;let o;for(;null!=(o=i.exec(t))&&(void 0===e||n.length<e);)n.push(o[1]);return n.join("\n")}function B(t,e){const n=t.map(((t,e)=>[t,e])).filter((([t,e])=>1==t.length)).map((([t,e])=>e));if(n.length>0){const t=i.div([i.divText(`MSA analysis is not available on single sequence clusters #${n.length}:`),...s()(n).take(3).map((t=>{let o=e[t];return o.length>25&&(o=o.slice(0,25)+"..."),i.divText(`"${o}"${t<n.length-1?", ":"."}`)})).toArray(),...n.length>3?[i.divText("...")]:[]]);throw new H(t)}}},8152:(t,e,n)=>{"use strict";n.d(e,{GD:()=>d,ZY:()=>h});var i=n(4328),o=n(6082),r=n(2003),s=n(608),a=n(4139),l=n(6723);const c=new class{dcName="bio";async getDockerContainer(){return await i.dapi.docker.dockerContainers.filter(this.dcName).first()}},h=["mafft --auto","mafft","linsi","ginsi","einsi","fftns","fftnsi","nwns","nwnsi"],u=["AlignedSeq","AlignedSubpeptide","HELM","ID","PolymerID"];async function d(t,e,n,i="ginsi",l=1.53,h=0,d=null,m,f=!1){const g=await c.getDockerContainer(),y=e.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,v=d.getRawData(),w=new Array(b.length),C=new Array(b.length);if(f){const n=t.selection;for(let t=-1;-1!==(t=n.findNext(t,!0));){const n=v[t];if(!b[n])continue;const i=n,o=e.get(t);o&&((w[i]??=[]).push({ID:t.toString(),HELM:o}),(C[n]??=[]).push(t))}}else for(let t=0;t<y;++t){const n=v[t];if(!b[n])continue;const i=n,o=e.get(t);o&&((w[i]??=[]).push({ID:t.toString(),HELM:o}),(C[n]??=[]).push(t))}(0,s.aZ)(C,b);const A=new Array(y).fill(null);for(const t of w){if(!t||0===t.length)continue;const e=(await p(g.id,t,i,l,h,m)).Alignment;for(const t of e)A[parseInt(t.ID)]=Object.entries(t).filter((t=>!u.includes(t[0]))).map((t=>"-"!==t[1]?t[1]:"")).join(a.J.SEPARATOR)}const S=o.Column.fromStrings(n,A);return S.meta.units=r.Hi.SEPARATOR,S.setTag(r.gp.separator,a.J.SEPARATOR),S.setTag(r.gp.aligned,"SEQ.MSA"),S.setTag(r.gp.alphabet,r.YI.UN),S.setTag(r.gp.alphabetIsMultichar,"true"),S.semType=o.SEMTYPE.MACROMOLECULE,S}async function p(t,e,n,o,r,s){const a={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(e)},c=`/align?method=${n}&gap_open=${o}&gap_extend=${r}`,h=window.performance.now(),u=await i.dapi.docker.dockerContainers.fetchProxy(t,c,a),d=window.performance.now();l._package.logger.debug(`Bio: requestAlignedObjects() dockerContainers.fetchProxy(), ET: ${d-h} ms`);const p="application/json"===u.headers.get("content-type");if(!u.ok&&p){const t=await u.json(),e=t["pepsea-error"];if(e)throw new Error(`PepSeA error: ${e}`);const n=t["datagrok-error"];if(n)throw new Error(`Datagrok error: ${n}`);throw new Error(u.statusText)}if(!u.ok&&!p){const t=await u.text();throw new Error(`Error: ${t}`)}if(!p){const t=await u.text();throw new Error(`Error: PepSeA expected JSON response, got '${t}'.`)}const m=await u.json();if("pepsea-stderr"in m){const t=m["pepsea-stderr"];s?.warning(t)}return m}},3890:(t,e,n)=>{"use strict";n.d(e,{TE:()=>h});var i=n(6082),o=n(7389),r=n(4328),s=n(1991),a=n.n(s),l=n(6723);const c=60;function h(){const t=r.shell.tv.grid,e=a().count(0).take(t.columns.length).map((e=>t.columns.byIndex(e))).filter((t=>!!t.column&&t.column.semType!==i.SEMTYPE.MACROMOLECULE)).toArray(),n=e.find((t=>-1!==t.name.toLowerCase().indexOf("id"))),s=n?[n.name]:[],h=o.input.multiChoice("Seq id columns",{value:s,items:e.map((t=>t.name))}),d=a().count(0).take(t.columns.length).map((e=>t.columns.byIndex(e))).filter((t=>{const e=t.column;return!(!e||e.semType!==i.SEMTYPE.MACROMOLECULE)&&l._package.seqHelper.getSeqHandler(e).isFasta()})).toArray(),p=d.length>0?d[0].name:[],m=o.input.choice("Seq column",{value:p,items:d.map((t=>t.name))}),f=o.input.int("FASTA line width",{value:c});o.dialog({title:"Save as FASTA"}).add(o.inputs([h,m,f])).onOK((()=>{const e=h.value?h.value.map((e=>t.columns.byName(e).column)):[],n=m.value?t.columns.byName(m.value).column:null,i=f.value??c;n||r.shell.warning("Seq column is mandatory to save as FASTA.");const o=function(t,e,n=c,i="\n"){const o=[];for(let r=0;r<e.length;r++){const s=t.map((t=>t.get(r).toString())).join("|"),a=u(e.getSplitted(r),n);o.push(`>${s}${i}`);for(const t of a)o.push(`${t}${i}`)}return"".concat(...o)}(e,l._package.seqHelper.getSeqHandler(n),i),s=document.createElement("a");s.setAttribute("href",`data:text/plain;charset=utf-8,${encodeURIComponent(o)}`),s.setAttribute("download",`${t.dataFrame.name}.fasta`),s.click()})).show()}function u(t,e=c){let n=0;const i=t.length,o=[];for(;n<i;){const i=a().count(n).take(Math.min(t.length-n,e)).map((e=>t.getOriginal(e))).toArray(),r=i.map((t=>t.length>1?`[${t}]`:t)).reduce(((t,e)=>t+e),"");o.push(r),n+=i.length}return o}},8754:(t,e,n)=>{"use strict";n.d(e,{V:()=>h});var i=n(4328),o=n(6077),r=n(2003),s=n(8312),a=n(5553),l=n(966),c=n(330);async function h(t,e,n,h,u,d,p){let m;if(n){const n=await(0,s.Q)(),i=n.getSeqHandler(e);let o,a;i.isHelm()?o=e:(a=e.name,e.name=`__${a}`,o=i.convert(r.Hi.HELM),o.name=a,t.columns.add(o,!1));try{m=await n.helmToAtomicLevel(o,!0,!0,u)}finally{o!==e&&(t.columns.remove(o.name),e.name=a)}}else{if(!(0,l.l)(e,"To Atomic Level",d)[0])return{molCol:null,warnings:["Column is not suitable"]};m=await(0,o.C4)(t,e,u,d,p)}if(m.molCol){const o=(0,c.qj)(t,e.name);m.molCol.name=o,t.columns.add(m.molCol,!0),await(0,a.Qc)(e,m.molCol,u,d,p,n),m.molCol.setTag(".sequence-src-highlight-monomers",String(h)),await i.data.detectSemanticTypes(t)}return m}},4870:(t,e,n)=>{"use strict";n.d(e,{Kd:()=>a,Ku:()=>s,me:()=>r});var i=n(4328),o=n(6082);function r(){const t=i.shell.t.columns.bySemTypeAll(o.SEMTYPE.MACROMOLECULE);return null===t?(i.shell.error("Current table does not contain macromolecules"),[]):t}function s(t,e){t.innerHTML="",t.append(e)}function a(t,e,n,i,o){const r=()=>{const o=t.col(e);o&&(o.width=n),i&&(t.props.rowHeight=i)};if(o)return void r();const s=t.onAfterDrawOverlay.subscribe((()=>{s.unsubscribe(),setTimeout((()=>{r()}))}))}},250:(t,e,n)=>{"use strict";n.d(e,{n5:()=>C,oP:()=>_});var i=n(4328),o=n(7389),r=n(6082),s=n(1757),a=n.n(s),l=n(1991),c=n.n(l),h=n(1858),u=n(2003),d=n(4326);function p(t){var e;return"string"==typeof t||t instanceof String?t:("object"==typeof t||t instanceof Object)&&"$thrownJsError"in t?p(t.$thrownJsError):t instanceof Error?null!==(e=t.stack)&&void 0!==e?e:t.message:t.toString()}var m=n(8070),f=n(7602),g=n(439),y=n(6882);var b=n(6723);function v(t,e,n){return Math.abs(t-e)<=n}var w,C,A=n(6307);HTMLCanvasElement.prototype.getCursorPosition=function(t,e){const n=this.getBoundingClientRect();return new r.Point((t.clientX-n.left)*e,(t.clientY-n.top)*e)},r.Rect.prototype.contains=function(t,e){return this.left<=t&&t<=this.right&&this.top<=e&&e<=this.bottom};class S{rowCount;value;plotValue;valueList=null;valueIdx=0;bounds;constructor(t=0,e){this.value=this.rowCount=t,this.bounds=e}push(t){this.valueList||(this.valueList=new Array(this.rowCount),this.valueIdx=0),this.valueList[this.valueIdx]=t,++this.valueIdx}aggregate(t){this.value=t(this.valueList)??0,this.valueList=null}}class x{pos;name;_label;get label(){return this._label?this._label:this.name}_freqs;sumRowCount=0;sumPlotValue;sumPlotValueForHeight;constructor(t,e,n,i){this.pos=t,this.name=e,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(t){return t in this._freqs}getFreq(t){let e=this._freqs[t];return e||(e=this._freqs[t]=new S),e}aggregate(t){const e=function(t){return e=>{const n=function(t){let e;const n="agg";return e=t instanceof Float32Array?r.Column.fromFloat32Array(n,t):t instanceof Int32Array?r.Column.fromInt32Array(n,t):r.Column.fromList(r.COLUMN_TYPE.FLOAT,n,t),e}(e);return n.aggregate(t)}}(t);for(const[t,n]of Object.entries(this._freqs))n.aggregate(e)}getMinValue(){return Math.min(...Object.values(this._freqs).map((t=>t.value)))}calcPlotValue(t){for(const e of Object.values(this._freqs))e.plotValue=e.value-t}calcHeights(t){this.sumPlotValue=0;for(const t of Object.values(this._freqs))this.sumPlotValue+=t.plotValue;if(this.sumPlotValueForHeight=0,t===d.fH.Entropy){const t=Object.keys(this._freqs).length,e=.01*this.sumPlotValue,n=e/t;for(const t of Object.values(this._freqs)){const i=(t.plotValue+n)/(this.sumPlotValue+e);this.sumPlotValueForHeight+=-i*Math.log2(i)}}else if(t===d.fH.full)for(const[t,e]of Object.entries(this._freqs)){const t=e.plotValue/this.sumPlotValue;this.sumPlotValueForHeight+=t}}calcScreen(t,e,n,i,o,s,a,l,c){const h=i===d.fH.Entropy?n*(o-this.sumPlotValueForHeight)/o:n;let u=c*l+(n-h-1);const p=Object.entries(this._freqs).sort(((t,e)=>t[0]!==g._S&&e[0]!==g._S?e[1].value-t[1].value:t[0]===g._S&&e[0]===g._S?0:t[0]===g._S?-1:1));for(const[n,i]of p){const n=h*i.plotValue/this.sumPlotValue;i.bounds=new r.Rect((t-e)*l*s,u,a*l,n),u+=n}}render(t,e,n,i,o,r,s){for(const[a,l]of Object.entries(this._freqs))if(a!==g._S){const c=(0,u.zS)(a,s),h=l.bounds,d=h.left;let p=y.S$;r&&(p=r.getMonomerTextColor(o,a)),t.resetTransform(),t.strokeStyle="lightgray",t.lineWidth=1,t.rect(d,h.top,h.width,h.height),t.fillStyle=p,t.textAlign="left",t.font=e;const m=t.measureText(c);t.setTransform(h.width/m.width,0,0,h.height/i,d,h.top),t.fillText(c,0,-n)}}getMonomerAt(t,e){const n=Object.entries(this._freqs).find((([n,i])=>i.bounds.contains(t,e)));return n?n[0]:void 0}buildCompositionTable(t,e){if("-"in this._freqs)throw new Error("Unexpected monomer symbol '-'.");return(0,A.F)(Object.assign({},...Object.entries(this._freqs).map((([t,e])=>({[t]:e.rowCount})))),t,e)}}!function(t){t.STYLE="Style",t.BEHAVIOR="Behavior",t.LAYOUT="Layout",t.DATA="Data"}(w||(w={})),function(t){t.sequenceColumnName="sequenceColumnName",t.valueAggrType="valueAggrType",t.valueColumnName="valueColumnName",t.startPositionName="startPositionName",t.endPositionName="endPositionName",t.skipEmptySequences="skipEmptySequences",t.skipEmptyPositions="skipEmptyPositions",t.shrinkEmptyTail="shrinkEmptyTail",t.backgroundColor="backgroundColor",t.positionHeight="positionHeight",t.positionWidth="positionWidth",t.verticalAlignment="verticalAlignment",t.horizontalAlignment="horizontalAlignment",t.fixWidth="fixWidth",t.fitArea="fitArea",t.minHeight="minHeight",t.maxHeight="maxHeight",t.maxMonomerLetters="maxMonomerLetters",t.showPositionLabels="showPositionLabels",t.positionMarginState="positionMarginState",t.positionMargin="positionMargin",t.filterSource="filterSource"}(C||(C={}));const E=d.Fo;var T;!function(t){t[t.None=0]="None",t[t.Render=1]="Render",t[t.Layout=1]="Layout",t[t.Freqs=2]="Freqs"}(T||(T={}));const M=new class{render=20};class _ extends r.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(C.sequenceColumnName,E.sequenceColumnName,{category:w.DATA,semType:r.SEMTYPE.MACROMOLECULE,description:"Column with sequences"});const t=[r.AGG.KEY,r.AGG.PIVOT,r.AGG.MISSING_VALUE_COUNT,r.AGG.SKEW,r.AGG.KURT,r.AGG.SELECTED_ROWS_COUNT],e=Object.values(r.AGG).filter((e=>!t.includes(e)));this.valueColumnName=this.string(C.valueColumnName,E.valueColumnName,{category:w.DATA,columnTypeFilter:"numerical",description:"Column with values used in aggregation for position heights"}),this.valueAggrType=this.string(C.valueAggrType,E.valueAggrType,{category:w.DATA,choices:e,description:"Aggregation method for value column"}),this.startPositionName=this.string(C.startPositionName,E.startPositionName,{category:w.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(C.endPositionName,E.endPositionName,{category:w.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(C.skipEmptySequences,E.skipEmptySequences,{category:w.DATA,description:"Skip sequences which are empty in all positions"}),this.skipEmptyPositions=this.bool(C.skipEmptyPositions,E.skipEmptyPositions,{category:w.DATA,description:"Skip positions which are empty in all sequences"}),this.shrinkEmptyTail=this.bool(C.shrinkEmptyTail,E.shrinkEmptyTail,{category:w.DATA,description:"Skip empty tail (if found for all sequences within a subset) in WebLogo"}),this.backgroundColor=this.int(C.backgroundColor,E.backgroundColor,{category:w.STYLE,description:"Background color of WebLogo canvas"}),this.positionHeight=this.string(C.positionHeight,E.positionHeight,{category:w.STYLE,choices:Object.values(d.fH),description:"Monomer-Position height mode. Entropy of 100%(full height)"}),this._positionWidth=this.positionWidth=this.float(C.positionWidth,E.positionWidth,{category:w.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(C.verticalAlignment,E.verticalAlignment,{category:w.LAYOUT,choices:Object.values(d.Lp)}),this.horizontalAlignment=this.string(C.horizontalAlignment,E.horizontalAlignment,{category:w.LAYOUT,choices:Object.values(d.P4)}),this.fixWidth=this.bool(C.fixWidth,E.fixWidth,{category:w.LAYOUT,userEditable:!1}),this.fitArea=this.bool(C.fitArea,E.fitArea,{category:w.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(C.minHeight,E.minHeight,{category:w.LAYOUT,editor:"slider",min:10,max:250,description:"Minimum height of WebLogo"}),this.maxHeight=this.int(C.maxHeight,E.maxHeight,{category:w.LAYOUT,editor:"slider",min:25,max:Math.max(window.innerHeight??0,1e3),nullable:!0,description:"Maximum height of WebLogo"}),this.maxMonomerLetters=this.int(C.maxMonomerLetters,E.maxMonomerLetters,{category:w.LAYOUT,editor:"slider",min:1,max:40,description:"Maximum monomer letters to display before shortening"}),this.showPositionLabels=this.bool(C.showPositionLabels,E.showPositionLabels,{category:w.LAYOUT,description:"Show position labels on top of the weblogo"}),this.positionMarginState=this.string(C.positionMarginState,E.positionMarginState,{category:w.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(C.positionMargin,n,{category:w.LAYOUT,min:0,max:25,description:"Margin between positions in WebLogo"}),this.filterSource=this.string(C.filterSource,E.filterSource,{category:w.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%",(0,b.getMonomerLibHelper)().then((t=>{this.monomerLib=t.getMonomerLib(),this.render(T.Render,"monomerLib"),this.subs.push(this.monomerLib.onChanged.subscribe((()=>{this.render(T.Render,"monomerLib changed")})))})),this.viewSyncer=new f.g(b._package.logger)}static viewerCounter=-1;viewerId=++_.viewerCounter;toLog(){return`WebLogoViewer<${this.viewerId}>`}setData(){const t=`${this.toLog()}.setData()`;b._package.logger.debug(`${t}, in`),this.viewSyncer.sync(`${t}`,(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(`${t}, out`)}viewSyncer;setDataInProgress=!1;viewSubs=[];async destroyView(){for(const t of this.viewSubs)t.unsubscribe();this.viewSubs=[];const t=this.dataFrame?"data":"null";b._package.logger.debug(`${this.toLog()}.destroyView( dataFrame = ${t} ) start`),this.host.remove(),this.msgHost=void 0,this.host=void 0,b._package.logger.debug(`${this.toLog()}.destroyView() end`)}async buildView(){const t=this.dataFrame?"data":"null";b._package.logger.debug(`${this.toLog()}.buildView( dataFrame = ${t} ) start`),window.devicePixelRatio,this.viewSubs.push(r.debounce(this.renderRequest,M.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,h.fromEvent)(this.canvas,"mousemove").subscribe(this.canvasOnMouseMove.bind(this))),this.viewSubs.push((0,h.fromEvent)(this.canvas,"mousedown").subscribe(this.canvasOnMouseDown.bind(this))),this.viewSubs.push((0,h.fromEvent)(this.canvas,"wheel").subscribe(this.canvasOnWheel.bind(this))),this.render(T.Freqs,"buildView"),b._package.logger.debug(`${this.toLog()}.buildView() end`)}lastSize={width:-1,height:-1};rootOnSizeChanged(t){const e={width:t.target.clientWidth,height:t.target.clientHeight};this.lastSize.width==e.width&&this.lastSize.height==e.height||(b._package.logger.debug(`${this.toLog()}.rootOnSizeChanged(), ${JSON.stringify(e)}, start `),this.render(T.Layout,"rootOnSizeChanged")),this.lastSize=e}updateEditors(){this.props.getProperty(C.valueColumnName).choices=c()(this.dataFrame.columns.numerical).map((t=>t.name)).toArray()}updateSeqCol(){if(this.dataFrame&&(this.seqCol=this.sequenceColumnName?this.dataFrame.col(this.sequenceColumnName):null,null==this.seqCol&&(this.seqCol=(0,u.mn)(this.dataFrame),this.sequenceColumnName=this.seqCol?this.seqCol.name:null),this.seqCol)){try{this.seqHandler=this.seqHelper.getSeqHandler(this.seqCol),this.render(T.Freqs,"updateSeqCol()"),this.error=null}catch(t){throw this.seqCol=null,this.error=t instanceof Error?t:new Error(t.toString()),t}this.seqCol||(this.seqHandler=null,this.positionNames=[],this.positionLabels=[],this.startPosition=-1,this.endPosition=-1)}}getFilter(){let t;switch(this.filterSource){case d.lT.Filtered:t=this.dataFrame.filter;break;case d.lT.Selected:t=0===this.dataFrame.selection.trueCount?this.dataFrame.filter:this.dataFrame.selection}return t}setSliderVisibility(t){t?(this.slider.root.style.display="inherit",this.visibleSlider=!0):(this.slider.root.style.display="none",this.visibleSlider=!1)}calcLayout(t){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(t):this.calcLayoutNoFitArea(t),this.slider.root.style.width=`${this.host.clientWidth}px`)}calcLayoutFixWidth(t){if(!this.host||!this.canvas||!this.slider)return;this.host.classList.add("bio-wl-fixWidth"),this.canvas.classList.add("bio-wl-fitArea");const e=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=`${e}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=e*t,this.canvas.height=n*t}calcLayoutNoFitArea(t){if(!this.host||!this.canvas||!this.slider)return;let e=this._positionWidthWithMargin*this.Length,n=Math.min(this.root.clientWidth,e);this.fitArea&&e<this.root.clientWidth&&(this._positionWidth=Math.floor(this._positionWidth*this.root.clientWidth/e),this._positionWidthWithMargin=this._positionWidth+this.positionMarginValue,e=this._positionWidthWithMargin*this.Length,n=Math.min(this.root.clientWidth,e));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=e>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 t=Math.min(Math.max(0,this.slider.min),this.Length-.001),e=Math.min(Math.max(0,this.slider.max),this.Length-.001);const n=this.canvas.clientWidth/this._positionWidthWithMargin;e=Math.min(Math.max(t,0)+n,this.Length-.001),t=Math.max(0,Math.min(e,this.Length-.001)-n),this.safeUpdateSlider(0,Math.max(this.Length-.001),t,e)}else this.safeUpdateSlider(0,Math.max(0,this.Length-.001),0,Math.max(0,this.Length-.001));this.canvas.width=n*t,this.canvas.height=i*t}calcLayoutFitArea(t){if(!this.host||!this.canvas||!this.slider)return;const e=this._positionWidth*this.Length,n=Math.min(Math.max(this.minHeight,this.root.clientHeight),this.maxHeight??this.root.clientHeight),i=e>0?(this.root.clientWidth-this.positionMarginValue*this.Length)/e:0,o=this.root.clientHeight/n,r=Math.max(1,Math.min(i,o));this._positionWidth=this.positionWidth*r,this._positionWidthWithMargin=this._positionWidth+this.positionMarginValue;const s=(this._positionWidth+this.positionMarginValue)*this.Length,a=r*n,l=Math.min(this.root.clientWidth,s);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=s>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 t=Math.min(Math.max(0,this.slider.min),this.Length-.001),e=Math.min(Math.max(0,this.slider.max),this.Length-.001);const n=this.root.clientWidth/this._positionWidthWithMargin;e=Math.min(Math.max(t,0)+n,this.Length-.001),t=Math.max(0,Math.min(e,this.Length-.001)-n),this.safeUpdateSlider(0,Math.max(0,this.Length-.001),t,e)}else this.safeUpdateSlider(0,Math.max(0,this.Length-.001),0,Math.max(0,this.Length-.001));this.canvas.width=l*t,this.canvas.height=a*t}safeUpdateSlider(t,e,n,i){v(t,this.slider.minRange,.1)&&v(e,this.slider.maxRange,.1)&&v(n,this.slider.min,.1)&&v(i,this.slider.max,.1)||this.slider.setValues(t,e,n,i)}onPropertyChanged(t){switch(super.onPropertyChanged(t),t.name){case C.sequenceColumnName:this.updateSeqCol();break;case C.sequenceColumnName:case C.startPositionName:case C.endPositionName:case C.filterSource:case C.shrinkEmptyTail:case C.skipEmptyPositions:case C.positionHeight:case C.valueColumnName:case C.valueAggrType:this.render(T.Freqs,`onPropertyChanged( ${t.name} )`);break;case C.minHeight:case C.maxHeight:case C.maxMonomerLetters:case C.positionWidth:case C.showPositionLabels:case C.fixWidth:case C.fitArea:case C.horizontalAlignment:case C.verticalAlignment:case C.positionMargin:case C.positionMarginState:this.render(T.Layout,`onPropertyChanged(${t.name})`);break;case C.backgroundColor:this.render(T.Render,`onPropertyChanged(${t.name})`)}}onTableAttached(){b._package.logger.debug(`${this.toLog()}.onTableAttached(), `),super.onTableAttached(),this.setData()}detach(){const t=`${this.toLog()}.detach()`;b._package.logger.debug(`${t}, in`);const e=super.detach.bind(this);this.viewSyncer.sync(`${t}`,(async()=>{this.setDataInProgress||(this.viewed&&(await this.destroyView(),this.viewed=!1),e())})),b._package.logger.debug(`${t}, out`)}_onSizeChanged=new h.Subject;get onSizeChanged(){return this._onSizeChanged}_onFreqsCalculated=new h.Subject;get onFreqsCalculated(){return this._onFreqsCalculated}_onLayoutCalculated=new h.Subject;get onLayoutCalculated(){return this._onLayoutCalculated}getMonomer(t,e){const n=t.x,i=Math.floor(t.x/(this._positionWidthWithMargin*e)+Math.floor(this.slider.min)),o=this.positions[i];if(!o)return[null,null,null];const r=o.getMonomerAt(n,t.y);return void 0===r?[o,null,null]:[o,r,o.getFreq(r)]}_nullSequence(t="X"){return this.skipEmptySequences?"":new Array(this.Length).fill(t).join("")}_removeEmptyPositions(){this.skipEmptyPositions&&(this.positions=c()(this.positions).filter((t=>!t.hasMonomer(g._S)||t.getFreq(g._S).rowCount!==t.sumRowCount)).toArray())}requestedRenderLevel=T.Freqs;renderRequest=new h.Subject;renderRequestSub;render(t,e){b._package.logger.debug(`${this.toLog()}.render( recalcLevelVal=${t}, reason='${e}' )`),this.requestedRenderLevel=Math.max(this.requestedRenderLevel,t),this.renderRequest.next(this.requestedRenderLevel)}async renderInt(t){if(b._package.logger.debug(`${this.toLog()}.render.renderInt( renderLevel=${t} ), start `),this.msgHost&&(this.msgHost.style.display="none"),!this.seqCol||!this.dataFrame||null==this.host||null==this.slider)return;const e=window.devicePixelRatio,n=this.showPositionLabels?12:0;if(t>=T.Freqs&&(()=>{if(b._package.logger.debug(`${this.toLog()}.render.calculateFreqsInt(), start `),!this.host||!this.seqCol||!this.dataFrame)return;const t=this.seqCol.getTag(u.gp.positionNames),e=this.seqCol.getTag(u.gp.positionLabels);let n;!t&&this.endPositionName&&/\d+/.test(this.endPositionName)?n=Number(this.endPositionName):t&&this.endPositionName&&(n=t.split(u.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((t=>{const e=this.seqHandler.getSplitted(t,n);return i.get(t)&&e?e.length:0})).reduce(((t,e)=>Math.max(t,e)),0);this.positionNames=t?t.split(u.z1).map((t=>t.trim())):[...Array(o).keys()].map((t=>`${t+1}`)),this.positionLabels=e?e.split(u.z1).map((t=>t.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 s=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 t=0;t<s;t++){const e=this.positionNames[this.startPosition+t],n=this.positionLabels?this.positionLabels[this.startPosition+t]:void 0;this.positions[t]=new x(this.startPosition+t,e,{},{label:n})}this.dataFrame.rowCount;const l=i.getSelectedIndexes();for(let t=0;t<s;++t){for(const e of l){const n=this.seqHandler.getSplitted(e),i=t+this.startPosition<n.length?n.getCanonical(this.startPosition+t):this.seqHandler.defaultGapOriginal,o=this.seqHandler.defaultGapOriginal===i?g._S:i,r=this.positions[t],s=r.getFreq(o);++r.sumRowCount,s.value=++s.rowCount}if(this.valueAggrType===r.AGG.TOTAL_COUNT)continue;let e=null;try{e=this.dataFrame.getCol(this.valueColumnName),e.matches("numerical")||(e=null)}catch{e=null}if(e){for(const n of l){const i=this.seqHandler.getSplitted(n),o=t+this.startPosition<i.length?i.getCanonical(this.startPosition+t):this.seqHandler.defaultGapOriginal,r=this.seqHandler.defaultGapOriginal===o?g._S:o,s=e.get(n);this.positions[t].getFreq(r).push(s)}this.positions[t].aggregate(this.valueAggrType)}}const h=this.valueAggrType===r.AGG.TOTAL_COUNT?0:Math.min(0,Math.min(...this.positions.map((t=>t.getMinValue()))));for(let t=0;t<s;++t)this.positions[t].calcPlotValue(h),this.positions[t].calcHeights(this.positionHeight);this._removeEmptyPositions(),this._onFreqsCalculated.next()})(),this.calcLayout(e),-1===this.startPosition)return;const o=Math.max(Math.floor(this.slider.min),0),s=Math.min(this.positions.length-1,Math.floor(this.slider.max));t>=T.Layout&&((t,e,n,o)=>{b._package.logger.debug(`${this.toLog()}.render.calculateLayoutInt(), start `);const s=this.canvas.height-o*n;let a;if(this.valueAggrType===r.AGG.TOTAL_COUNT){const t=this.seqHandler.getAlphabetSize();this.positionHeight==d.fH.Entropy&&null==t&&i.shell.error("WebLogo: alphabet is undefined."),a=Math.log2(t)}else a=Math.max(...c().count(t).takeWhile((t=>t<=e)).map((t=>this.positions[t].sumPlotValueForHeight)));for(let i=t;i<=e;++i)i in this.positions?this.positions[i].calcScreen(i,this.slider.min,s,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,s,window.devicePixelRatio,n);const a=this.canvas.getContext("2d");if(a){a.save();try{this.Length,a.resetTransform(),a.fillStyle=function(t){const e=r.Color.a(t);return`#${(16777215&t).toString(16).padStart(6,"0")}`+e.toString(16).padStart(2,"0")}(this.backgroundColor),a.fillRect(0,0,this.canvas.width,this.canvas.height),a.textBaseline=this.textBaseline;const t=10*e;a.resetTransform(),a.fillStyle="black",a.textAlign="center",a.font=`${t.toFixed(1)}px Roboto, Roboto Local, sans-serif`,n>0&&this.positions.length>0&&function(t,e,n,i,o,r,s,a){t.save();try{t.textAlign="center";let l=null,c=null;for(let e=Math.floor(s);e<=Math.floor(a);e++){const n=r[e],i=t.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 h=l<i*e-2?1:(i*e-2)/l;for(let l=Math.floor(s);l<=Math.floor(a);l++){const a=r[l],u=(l-s)*n*e+i*e/2,d=(o*e-c)/2;t.setTransform(h,0,0,1,u,d),t.measureText(a.label),t.fillText(a.label,0,0)}}finally{t.restore()}}(a,e,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,h=this.seqHandler.defaultBiotype;for(let t=o;t<=s;t++)this.positions[t].render(a,i,l,c,h,this.monomerLib,this.maxMonomerLetters)}finally{a.restore()}b._package.logger.debug(`${this.toLog()}.render.renderInt( recalcLevel=${t} ), end`)}}renderRequestOnDebounce(t){const e=`${this.toLog()}.renderRequestOnDebounce()`;"HTML"!==a()(this.root).offsetParent().get()[0]?.tagName?(this.requestedRenderLevel=T.None,this.viewSyncer.sync(e,(async()=>{await this.renderInt(t)}))):b._package.logger.warning(`${e}, $(this.root).offsetParent() is the 'HTML' tag.`)}_lastWidth;_lastHeight;sliderOnValuesChanged(t){try{const t={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 e=t.max-t.min,n=this.canvas.offsetWidth/e-this.positionMarginValue;v(n,this.positionWidth,.1)?this.render(T.Layout,"sliderOnValuesChanged"):this.getProperty(C.positionWidth)?.set(this,n)}}catch(t){const e=p(t);b._package.logger.error(`${this.toLog()}.sliderOnValuesChanged() error:\n`+e)}}dataFrameFilterOnChanged(t){b._package.logger.debug(`${this.toLog()}.dataFrameFilterChanged()`);try{this.filterSource===d.lT.Filtered&&this.render(T.Freqs,"dataFrameFilterOnChanged")}catch(t){const e=p(t);b._package.logger.error(`${this.toLog()}.dataFrameFilterOnChanged() error:\n`+e)}}dataFrameSelectionOnChanged(t){b._package.logger.debug(`${this.toLog()}.dataFrameSelectionOnChanged()`);try{this.filterSource===d.lT.Selected&&this.render(T.Freqs,"dataFrameSelectionOnChanged")}catch(t){const e=p(t);b._package.logger.error(`${this.toLog()}.dataFrameSelectionOnChanged() error:\n`+e)}}canvasOnMouseMove(t){if(!this.monomerLib||!this.seqHandler)return;const e=window.devicePixelRatio;try{const n=t,i=this.canvas.getCursorPosition(n,e),[s,a]=this.getMonomer(i,e),l=this.showPositionLabels?12*e:0;if(null!==s&&null===a&&0<=i.y&&i.y<=l){const t=[o.divText(`Position ${s.label}`)];if(this.valueAggrType===r.AGG.TOTAL_COUNT){const e=this.seqHandler.defaultBiotype;t.push(s.buildCompositionTable(e,this.monomerLib))}const e=o.divV(t);e.style.maxHeight="80vh",o.tooltip.show(e,n.x+16,n.y+16)}else if(null!==s&&a&&this.dataFrame&&this.seqCol&&this.seqHandler){const t=s.getFreq(a),e=[o.div(`${a}`),o.div(`${t.rowCount} rows`)];this.valueAggrType!==r.AGG.TOTAL_COUNT&&e.push(o.div(`${this.valueAggrType}: ${t.value.toFixed(3)}`));const i=o.divV(e);o.tooltip.show(i,n.x+16,n.y+16)}else o.tooltip.hide()}catch(t){const e=p(t);b._package.logger.error(`${this.toLog()}.canvasOnMouseMove() error:\n`+e)}}canvasOnMouseDown(t){try{const e=t,n=window.devicePixelRatio,[i,o]=this.getMonomer(this.canvas.getCursorPosition(e,n),n);if(null!==i&&null!==o&&this.dataFrame&&this.seqCol&&this.seqHandler){const t=r.BitSet.create(this.dataFrame.selection.length,(t=>function(t,e,n,i,o,r){const s=e.getSplitted(i),a=r.pos<s.length?s.getCanonical(r.pos):null;return null!==a&&a===o}(this.dataFrame,this.seqHandler,this.getFilter(),t,o,i)));this.dataFrame.selection.init((e=>t.get(e)))}}catch(t){const e=p(t);b._package.logger.error(`${this.toLog()}.canvasOnMouseDown() error:\n`+e)}}canvasOnWheel(t){const e=window.devicePixelRatio;try{if(!this.visibleSlider)return;const n=this.canvas.width/(this._positionWidthWithMargin*e),i=t.deltaY/100*Math.max(Math.floor(n/5),1);this.slider.scrollBy(this.slider.min+i)}catch(t){const e=p(t);b._package.logger.error(`${this.toLog()}.canvasOnWheel() error:\n`+e)}}_onRendered=new h.Subject;get onRendered(){return this._onRendered}invalidate(t){const e=`invalidate(${t?` <- ${t} `:""})`,n=`${this.toLog()}.${e}`;this.render(T.None,e),this.viewSyncer.sync(`${n}`,(async()=>{this._onRendered.next()}))}async awaitRendered(t=5e3){await(0,m.PE)(this.onRendered,(()=>{}),(()=>{this.invalidate()}),t);const e=this.viewSyncer.resetErrors();if(e.length>0)throw e[0]}}},1687:(t,e,n)=>{"use strict";n.d(e,{_i:()=>x});var i=n(7389),o=n(6082),r=n(4328),s=n(1991),a=n.n(s),l=n(1858),c=n(2003),h=n(8070),u=n(7602),d=n(4954),p=n(4574),m=n(1757),f=n.n(m),g=n(9124),y=n(9192),b=n(4870),v=n(6723);class w extends p.O{seqHelper;emptyProps=new p.n("",void 0,v._package.logger);helmEditor;_filterPanel=i.div("",{style:{cursor:"pointer"}});logger;static viewerCounter=-1;viewerId=++w.viewerCounter;viewerToLog(){return`HelmBioFilter<${this.viewerId}>`}get type(){return"HelmBioFilter"}constructor(t){super(),this.seqHelper=t,this.logger=v._package.logger}viewSubs=[];async detach(){await super.detach();for(const t of this.viewSubs)t.unsubscribe()}async attach(){this.viewerToLog();try{const t=await(0,g.b2)();let e,n;this.helmEditor=t.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((()=>{e=i.div(),n=t.createWebEditorApp(e,this.props.substructure),i.dialog({showHeader:!1,showFooter:!0}).add(e).onOK((()=>{try{const t=n.canvas.getHelm(!0).replace(/<\/span>/g,"").replace(/<span style='background:#bbf;'>/g,"");this.props=new p.n(t,void 0,v._package.logger)}catch(t){this.logger.error(t)}finally{f()(e).empty(),e=null,n=null}})).onCancel((()=>{f()(e).empty(),e=null,n=null})).show({modal:!0,fullScreen:!0})}))),this.viewSubs.push(i.onSizeChanged(this._filterPanel).subscribe((t=>{try{if(n){const t=n.canvas.getHelm(!0).replace(/<\/span>/g,"").replace(/<span style='background:#bbf;'>/g,"");this.updateFilterPanel(t)}}catch(t){const[e,n]=(0,y.AP)(t);this.logger.error(e,void 0,n)}})))}catch(t){const[e,n]=(0,y.AP)(t),o=this._filterPanel;o.innerText="error",o.classList.add("d4-error"),i.tooltip.bind(o,e)}}applyProps(){this.helmEditor&&this.updateFilterPanel(this.props.substructure)}get filterPanel(){return this._filterPanel}updateFilterPanel(t){if(!this.helmEditor)throw new Error("helmEditor is not created, the filter is not in dom yet");const e=this._filterPanel.parentElement.clientWidth<100?100:this._filterPanel.parentElement.clientWidth,n=e/2;if(t)(0,b.Ku)(this._filterPanel,this.helmEditor.host),this.helmEditor.editor.setHelm(t),this.helmEditor.resizeEditor(e,n);else{const t=i.divText("Click to edit","helm-substructure-filter");(0,b.Ku)(this._filterPanel,t)}}async substructureSearch(t){const e=`${this.viewerToLog()}.substructureSearch( column = <${t.name}> )`;v._package.logger.debug(`${e}, start`);try{return await(0,h.cb)(10),await(0,d.if)(this.props.substructure,t,this.seqHelper)}finally{v._package.logger.debug(`${e}, end`)}}}const C="bio-substructure-filter";class A{props;filterId;dataFrameId;columnName;bitset;constructor(t,e,n,i,o){this.props=t,this.filterId=e,this.dataFrameId=n,this.columnName=i,this.bitset=o}}class S extends p.n{separator;constructor(t,e,n){super(t,!1,n),this.separator=e,this.readOnly=!0}}class x extends o.Filter{seqHelper;logger;bioFilter=null;bitset=null;loader;notation=void 0;filterSyncer;get calculating(){return"initial"==this.loader.style.display}set calculating(t){this.loader.style.display=t?"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 t=this.column.length;return t<500?0:t>1e4?1e3:Math.floor((t-500)/9500*1e3)}constructor(t,e){super(),this.seqHelper=t,this.logger=e,this.root=i.divV([]),this.loader=i.loader(),this.calculating=!1,this.filterSyncer=new u.g(this.logger)}static filterCounter=-1;filterId=++x.filterCounter;filterToLog(){return`BioSubstructureFilter<${this.filterId}>`}viewSubs=[];attach(t){const e=super.attach.bind(this),n=`${this.filterToLog()}.attach()`;this.filterSyncer.sync(n,(async()=>{e(t),this.column||(this.columnName?this.column=this.dataFrame.getCol(this.columnName):this.column=t.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 T(this.column.getTag(c.gp.separator)):new w(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(r.events.onResetFilterRequest.subscribe(this.grokEventsOnResetFilterRequest.bind(this))),this.viewSubs.push(r.events.onCustomEvent(C).subscribe(this.filterOnSync.bind(this)))}))}detach(){const t=super.detach.bind(this),e=`${this.filterToLog()}.detach()`;this.filterSyncer.sync(e,(async()=>{for(const t of this.viewSubs)t.unsubscribe();this.viewSubs=[],t(),this.bioFilter&&this.bioFilter.detach(),this.bioFilter=null}))}filterOnSync(t){t.filterId!==this.filterId&&t.dataFrameId===this.dataFrame.id&&t.columnName===this.columnName&&(this.bioFilter.props=t.props)}applyFilter(){const t=`${this.filterToLog()}.applyFilter()`;this.logger.debug(`${t}, IN`),this.bitset&&!this.isDetached&&this.dataFrame?.filter.and(this.bitset)}saveState(){const t=`${this.filterToLog()}.saveState()`,e=super.saveState();return this.logger.debug(`${t}, super.state = ${JSON.stringify(e)}`),e.props=this.bioFilter.saveProps(),e}applyState(t){const e=`${this.filterToLog()}.applyState()`;super.applyState(t),this.filterSyncer.sync(e,(async()=>{t.props&&this.bioFilter&&(this.bioFilter.props=o.toJs(t.props??{}))}))}fireFilterSync(){const t=`${this.filterToLog()}.fireFilterSync()`;this.logger.debug(`${t}, bioFilter = ${this.bioFilter?this.bioFilter.constructor.name:"null"}`+(this.bioFilter?`, props = ${JSON.stringify(this.bioFilter.saveProps())}`:"")),r.events.fireCustomEvent(C,new A(this.bioFilter.props,this.filterId,this.dataFrame.id,this.columnName,this.bitset))}bioFilterOnChangedDebounced(){if(!this.dataFrame)return;const t=`${this.filterToLog()}.bioFilterOnChangedDebounced()`;if(this.logger.debug(`${t}, 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(t,(async()=>{this.calculating=!0;try{this.logger.debug(`${t}, before substructureSearch`),this.bitset=await(this.bioFilter?.substructureSearch(this.column)),this.logger.debug(`${t}, after substructureSearch`),this.calculating=!1,this.fireFilterSync(),this.dataFrame?.rows.requestFilter()}finally{this.calculating=!1,this.logger.debug(`${t}, end`)}}))}grokEventsOnResetFilterRequest(){const t=`${this.filterToLog()}.grokEventsOnResetFilterRequest()`;this.logger.debug(`${t}`),this.bioFilter?.resetFilter()}_onRendered=new l.Subject;get onRendered(){return this._onRendered}invalidate(t){const e=`${this.filterToLog()}.invalidate(${t?` <- ${t} `:""})`;this.filterSyncer.sync(e,(async()=>{this._onRendered.next()}))}async awaitRendered(t=1e4){const e=`awaitRendered( ${t} )`,n=`${this.filterToLog()}.${e}`;await(0,h.cb)(10),await(0,h.PE)(this.onRendered,(()=>{this.logger.debug(`${n}, _onRendered event caught`)}),(()=>{this.invalidate(e)}),t,`${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,v._package.logger);substructureInput;get type(){return"FastaBioFilter"}constructor(){super(),this.substructureInput=i.input.string("",{value:"",onValueChanged:t=>{window.setTimeout((()=>{this.props=new p.n(t,void 0,v._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(t){return(0,d.nI)(this.props.substructure,t)}async attach(){}async detach(){await super.detach()}}class T extends p.O{emptyProps=new S("",void 0,v._package.logger);substructureInput;separatorInput;colSeparator="";get type(){return"SeparatorBioFilter"}constructor(t){super(),this.substructureInput=i.input.string("",{value:"",onValueChanged:t=>{this.props=new S(t,this.props.separator,v._package.logger),setTimeout((()=>{this._propsChanging||this.onChanged.next()}))},placeholder:"Substructure"}),this.separatorInput=i.input.string("",{value:this.colSeparator=t,onValueChanged:t=>{const e=t||"";this.props=new S(this.props.substructure,e,v._package.logger),setTimeout((()=>{this._propsChanging||this.onChanged.next()}))},placeholder:"Separator"})}applyProps(){this.substructureInput.value!==this.props.substructure&&(this.substructureInput.value=this.props.substructure);const t=this.props.separator??this.colSeparator;this.separatorInput.value!==t&&(this.separatorInput.value=t)}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 S("",void 0,v._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(t){this.substructureInput.value=t}async substructureSearch(t){return(0,d.nI)(this.substructure,t,this.colSeparator)}async attach(){}async detach(){await super.detach()}}},1757:t=>{"use strict";t.exports=$},6082:t=>{"use strict";t.exports=DG},4328:t=>{"use strict";t.exports=grok},1858:t=>{"use strict";t.exports=rxjs},9713:t=>{"use strict";t.exports=rxjs.operators},7389:t=>{"use strict";t.exports=ui},1991:t=>{"use strict";t.exports=wu},8343:(t,e,n)=>{"use strict";const{normalizeIPv6:i,normalizeIPv4:o,removeDotSegments:r,recomposeAuthority:s,normalizeComponentEncoding:a}=n(4834),l=n(343);function c(t,e,n,i){const o={};return i||(t=p(h(t,n),n),e=p(h(e,n),n)),!(n=n||{}).tolerant&&e.scheme?(o.scheme=e.scheme,o.userinfo=e.userinfo,o.host=e.host,o.port=e.port,o.path=r(e.path||""),o.query=e.query):(void 0!==e.userinfo||void 0!==e.host||void 0!==e.port?(o.userinfo=e.userinfo,o.host=e.host,o.port=e.port,o.path=r(e.path||""),o.query=e.query):(e.path?("/"===e.path.charAt(0)?o.path=r(e.path):(void 0===t.userinfo&&void 0===t.host&&void 0===t.port||t.path?t.path?o.path=t.path.slice(0,t.path.lastIndexOf("/")+1)+e.path:o.path=e.path:o.path="/"+e.path,o.path=r(o.path)),o.query=e.query):(o.path=t.path,void 0!==e.query?o.query=e.query:o.query=t.query),o.userinfo=t.userinfo,o.host=t.host,o.port=t.port),o.scheme=t.scheme),o.fragment=e.fragment,o}function h(t,e){const n={host:t.host,scheme:t.scheme,userinfo:t.userinfo,port:t.port,path:t.path,query:t.query,nid:t.nid,nss:t.nss,uuid:t.uuid,fragment:t.fragment,reference:t.reference,resourceName:t.resourceName,secure:t.secure,error:""},i=Object.assign({},e),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=s(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 t=n.path;i.absolutePath||a&&a.absolutePath||(t=r(t)),void 0===c&&(t=t.replace(/^\/\//u,"/%2F")),o.push(t)}return void 0!==n.query&&o.push("?",n.query),void 0!==n.fragment&&o.push("#",n.fragment),o.join("")}const u=Array.from({length:127},((t,e)=>/[^!"$&'()*+,\-.;=_`a-z{}~]/u.test(String.fromCharCode(e)))),d=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function p(t,e){const n=Object.assign({},e),r={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},s=-1!==t.indexOf("%");let a=!1;"suffix"===n.reference&&(t=(n.scheme?n.scheme+":":"")+"//"+t);const c=t.match(d);if(c){if(r.scheme=c[1],r.userinfo=c[3],r.host=c[4],r.port=parseInt(c[5],10),r.path=c[6]||"",r.query=c[7],r.fragment=c[8],isNaN(r.port)&&(r.port=c[5]),r.host){const t=o(r.host);if(!1===t.isIPV4){const e=i(t.host);r.host=e.host.toLowerCase(),a=e.isIPV6}else r.host=t.host,a=!0}void 0!==r.scheme||void 0!==r.userinfo||void 0!==r.host||void 0!==r.port||void 0!==r.query||r.path?void 0===r.scheme?r.reference="relative":void 0===r.fragment?r.reference="absolute":r.reference="uri":r.reference="same-document",n.reference&&"suffix"!==n.reference&&n.reference!==r.reference&&(r.error=r.error||"URI is not a "+n.reference+" reference.");const t=l[(n.scheme||r.scheme||"").toLowerCase()];if(!(n.unicodeSupport||t&&t.unicodeSupport)&&r.host&&(n.domainHost||t&&t.domainHost)&&!1===a&&function(t){let e=0;for(let n=0,i=t.length;n<i;++n)if(e=t.charCodeAt(n),e>126||u[e])return!0;return!1}(r.host))try{r.host=URL.domainToASCII(r.host.toLowerCase())}catch(t){r.error=r.error||"Host's domain name can not be converted to ASCII: "+t}(!t||t&&!t.skipNormalize)&&(s&&void 0!==r.scheme&&(r.scheme=unescape(r.scheme)),s&&void 0!==r.host&&(r.host=unescape(r.host)),r.path&&(r.path=escape(unescape(r.path))),r.fragment&&(r.fragment=encodeURI(decodeURIComponent(r.fragment)))),t&&t.parse&&t.parse(r,n)}else r.error=r.error||"URI can not be parsed.";return r}const m={SCHEMES:l,normalize:function(t,e){return"string"==typeof t?t=h(p(t,e),e):"object"==typeof t&&(t=p(h(t,e),e)),t},resolve:function(t,e,n){const i=Object.assign({scheme:"null"},n);return h(c(p(t,i),p(e,i),i,!0),{...i,skipEscape:!0})},resolveComponents:c,equal:function(t,e,n){return"string"==typeof t?(t=unescape(t),t=h(a(p(t,n),!0),{...n,skipEscape:!0})):"object"==typeof t&&(t=h(a(t,!0),{...n,skipEscape:!0})),"string"==typeof e?(e=unescape(e),e=h(a(p(e,n),!0),{...n,skipEscape:!0})):"object"==typeof e&&(e=h(a(e,!0),{...n,skipEscape:!0})),t.toLowerCase()===e.toLowerCase()},serialize:h,parse:p};t.exports=m,t.exports.default=m,t.exports.fastUri=m},343:t=>{"use strict";const e=/^[\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(t){return"boolean"==typeof t.secure?t.secure:"wss"===String(t.scheme).toLowerCase()}function o(t){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t}function r(t){const e="https"===String(t.scheme).toLowerCase();return t.port!==(e?443:80)&&""!==t.port||(t.port=void 0),t.path||(t.path="/"),t}const s={scheme:"http",domainHost:!0,parse:o,serialize:r},a={scheme:"ws",domainHost:!0,parse:function(t){return t.secure=i(t),t.resourceName=(t.path||"/")+(t.query?"?"+t.query:""),t.path=void 0,t.query=void 0,t},serialize:function(t){if(t.port!==(i(t)?443:80)&&""!==t.port||(t.port=void 0),"boolean"==typeof t.secure&&(t.scheme=t.secure?"wss":"ws",t.secure=void 0),t.resourceName){const[e,n]=t.resourceName.split("?");t.path=e&&"/"!==e?e:void 0,t.query=n,t.resourceName=void 0}return t.fragment=void 0,t}},l={http:s,https:{scheme:"https",domainHost:s.domainHost,parse:o,serialize:r},ws:a,wss:{scheme:"wss",domainHost:a.domainHost,parse:a.parse,serialize:a.serialize},urn:{scheme:"urn",parse:function(t,e){if(!t.path)return t.error="URN can not be parsed",t;const i=t.path.match(n);if(i){const n=e.scheme||t.scheme||"urn";t.nid=i[1].toLowerCase(),t.nss=i[2];const o=`${n}:${e.nid||t.nid}`,r=l[o];t.path=void 0,r&&(t=r.parse(t,e))}else t.error=t.error||"URN can not be parsed.";return t},serialize:function(t,e){const n=e.scheme||t.scheme||"urn",i=t.nid.toLowerCase(),o=`${n}:${e.nid||i}`,r=l[o];r&&(t=r.serialize(t,e));const s=t,a=t.nss;return s.path=`${i||e.nid}:${a}`,e.skipEscape=!0,s},skipNormalize:!0},"urn:uuid":{scheme:"urn:uuid",parse:function(t,n){const i=t;return i.uuid=i.nss,i.nss=void 0,n.tolerant||i.uuid&&e.test(i.uuid)||(i.error=i.error||"UUID is not valid."),i},serialize:function(t){const e=t;return e.nss=(t.uuid||"").toLowerCase(),e},skipNormalize:!0}};t.exports=l},4914:t=>{"use strict";t.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:(t,e,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 r(t){if(c(t,".")<3)return{host:t,isIPV4:!1};const e=t.match(o)||[],[n]=e;return n?{host:l(n,"."),isIPV4:!0}:{host:t,isIPV4:!1}}function s(t,e=!1){let n="",o=!0;for(const e of t){if(void 0===i[e])return;"0"!==e&&!0===o&&(o=!1),o||(n+=e)}return e&&0===n.length&&(n="0"),n}function a(t){if(c(t,":")<2)return{host:t,isIPV6:!1};const e=function(t){let e=0;const n={error:!1,address:"",zone:""},i=[],o=[];let r=!1,a=!1,l=!1;function c(){if(o.length){if(!1===r){const t=s(o);if(void 0===t)return n.error=!0,!1;i.push(t)}o.length=0}return!0}for(let s=0;s<t.length;s++){const h=t[s];if("["!==h&&"]"!==h)if(":"!==h)if("%"===h){if(!c())break;r=!0}else o.push(h);else{if(!0===a&&(l=!0),!c())break;if(e++,i.push(":"),e>7){n.error=!0;break}s-1>=0&&":"===t[s-1]&&(a=!0)}}return o.length&&(r?n.zone=o.join(""):l?i.push(o.join("")):i.push(s(o))),n.address=i.join(""),n}(t);if(e.error)return{host:t,isIPV6:!1};{let t=e.address,n=e.address;return e.zone&&(t+="%"+e.zone,n+="%25"+e.zone),{host:t,escapedHost:n,isIPV6:!0}}}function l(t,e){let n="",i=!0;const o=t.length;for(let r=0;r<o;r++){const s=t[r];"0"===s&&i?(r+1<=o&&t[r+1]===e||r+1===o)&&(n+=s,i=!1):(i=s===e,n+=s)}return n}function c(t,e){let n=0;for(let i=0;i<t.length;i++)t[i]===e&&n++;return n}const h=/^\.\.?\//u,u=/^\/\.(?:\/|$)/u,d=/^\/\.\.(?:\/|$)/u,p=/^\/?(?:.|\n)*?(?=\/|$)/u;t.exports={recomposeAuthority:function(t){const e=[];if(void 0!==t.userinfo&&(e.push(t.userinfo),e.push("@")),void 0!==t.host){let n=unescape(t.host);const i=r(n);if(i.isIPV4)n=i.host;else{const e=a(i.host);n=!0===e.isIPV6?`[${e.escapedHost}]`:t.host}e.push(n)}return"number"!=typeof t.port&&"string"!=typeof t.port||(e.push(":"),e.push(String(t.port))),e.length?e.join(""):void 0},normalizeComponentEncoding:function(t,e){const n=!0!==e?escape:unescape;return void 0!==t.scheme&&(t.scheme=n(t.scheme)),void 0!==t.userinfo&&(t.userinfo=n(t.userinfo)),void 0!==t.host&&(t.host=n(t.host)),void 0!==t.path&&(t.path=n(t.path)),void 0!==t.query&&(t.query=n(t.query)),void 0!==t.fragment&&(t.fragment=n(t.fragment)),t},removeDotSegments:function(t){const e=[];for(;t.length;)if(t.match(h))t=t.replace(h,"");else if(t.match(u))t=t.replace(u,"/");else if(t.match(d))t=t.replace(d,"/"),e.pop();else if("."===t||".."===t)t="";else{const n=t.match(p);if(!n)throw new Error("Unexpected dot segment condition");{const i=n[0];t=t.slice(i.length),e.push(i)}}return e.join("")},normalizeIPv4:r,normalizeIPv6:a,stringArrayToHexStripped:s}},3837:t=>{"use strict";t.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:t=>{"use strict";t.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:t=>{"use strict";t.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:t=>{"use strict";t.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:t=>{"use strict";t.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:t=>{"use strict";t.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:t=>{"use strict";t.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:t=>{"use strict";t.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:t=>{"use strict";t.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:t=>{"use strict";t.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}')}},e={};function n(i){var o=e[i];if(void 0!==o)return o.exports;var r=e[i]={id:i,loaded:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.loaded=!0,r.exports}n.m=t,n.amdO={},n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.u=t=>t+".js",n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.hmd=t=>((t=Object.create(t)).children||(t.children=[]),Object.defineProperty(t,"exports",{enumerable:!0,set:()=>{throw new Error("ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: "+t.id)}}),t),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{var t;n.g.importScripts&&(t=n.g.location+"");var e=n.g.document;if(!t&&e&&(e.currentScript&&"SCRIPT"===e.currentScript.tagName.toUpperCase()&&(t=e.currentScript.src),!t)){var i=e.getElementsByTagName("script");if(i.length)for(var o=i.length-1;o>-1&&(!t||!/^http(s?):/.test(t));)t=i[o--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=t})(),n.b=document.baseURI||self.location.href,n.nc=void 0;var i=n(6723);bio=i})();
|
|
8
8
|
//# sourceMappingURL=package.js.map
|