@datagrok/bio 2.10.14 → 2.10.15
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/package-test.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var bio_test;(()=>{var t={2012:(t,e,s)=>{"use strict";s.d(e,{f:()=>i});var n=s(9976);class i extends n.B{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,i)),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,i)),this.grokGroups}static get RasMol(){return void 0===this.rasMol&&(this.rasMol=new i({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 i.aaSynonyms?i.aaSynonyms[t]:t;return super.get(e)}}i.aaSynonyms={MeNle:"L",MeA:"A",MeG:"G",MeF:"F"};class r{static getPalette(t="grok"){switch(t){case"grok":return i.GrokGroups;case"lesk":return i.Lesk;default:throw new Error(`ChemPalette: scheme \`${t}\` does not exist`)}}static getInnerOuter(t){let e=0,s="",n="";for(const i of t)"("==i?e++:")"==i?e--:e?s+=i:n+=i;return isNaN(parseInt(s))?[n,s]:[n,""]}static getColorAAPivot(t="",e="grok"){const s=this.getPalette(e);let[n,i]=this.getInnerOuter(t);if(n=n.length>6?`${n.slice(0,3)}...`:n,i=i.length>6?`${i.slice(0,3)}...`:i,1==t.length||"("==t[1]){const e=t[0]?.toUpperCase();return e in s?[s.get(e),e,i,1]:[this.undefinedColor,n,i,1]}if("d"==t[0]&&t[1]in s&&(2==t.length||"("==t[2])){const e=t[1]?.toUpperCase();return e in s?[s.get(e),e,i,2]:[this.undefinedColor,n,i,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 s?[s.get(e),e,i,3]:[this.undefinedColor,n,i,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 s?[s.get(e),e,i,4]:[this.undefinedColor,n,i,4]}return[this.undefinedColor,n,i,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"}},7228:(t,e,s)=>{"use strict";s.d(e,{JN:()=>c,Qx:()=>u,Xk:()=>h,Z:()=>l,eD:()=>a});var n=s(976),i=s(4469),r=s(1047),o=(s(499),s(8457));function a(t){return t.every((t=>"object"==typeof t&&Object.values(r.pn).every((e=>e in t&&"string"==typeof t[e]))))}function l(t){function e(t){const e=new RegExp("\\[r\\]","g");let s=0;return t.replace(e,(t=>(++s,`[${s}*]`)))}const s=[];return t.forEach((t=>{const i={...r.zh};Object.entries(r.pn).forEach((([e,s])=>{const n=t[s];i[e]=n}));let o="smiles";const a=t[r.pn[o]],l=e(a).replace("[1*]","[H:1]").replace("[2*]","[OH:2]");i[o]=l,o="rgroups",i[o]=r.Ei,o="molfile";const h=e(a),c=n.chem.convert(h,n.chem.Notation.Smiles,n.chem.Notation.MolBlock);i[o]=c.replace("M ISO","M RGP"),s.push(i)})),console.log("resultLib:",s),s}function h(t){const e=[];for(let s=0;s<t.rowCount;s++){const n={};Object.keys(r.K4).forEach((e=>{if("symbol"===e){const i=t.get(r.K4[e],s);n[e]="."===i?t.get(r.At,s):i}else if("rgroups"===e){const i=t.get(r.K4[e],s).split("\n"),o=[];i.forEach((t=>{const e={},s=t.substring(t.lastIndexOf("]")+1),n=t.match(/\[R(\d+)\]/)[1];e.capGroupSmiles="H"===s?`[*:${n}][H]`:`O[*:${n}]`,e.alternateId="H"===s?`R${n}-H`:`R${n}-OH`,e.capGroupName="H"===s?"H":"OH",e.label=`R${n}`,o.push(e)})),n[e]=o}else r.K4[e]&&(n[e]=t.get(r.K4[e],s))})),e.push(n)}return e}async function c(){const t=n.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){t instanceof n.Column&&(t=(0,o.O)(t).columns.toList());const s=(await c()).getBioLib(),r=new Array(t.length),a=t[0].length,l=new Float32Array(a);for(let o=0;o<t.length;++o){const h=e[o],c=s.getMonomer("PEPTIDE",h)?.smiles??"",u=t[o],m=u.getRawData(),d=u.categories,g=d.indexOf("");if(r[o]={categories:d,data:m,emptyIndex:g},void 0===h)continue;const f=n.Column.fromStrings("smiles",d.map((t=>s.getMonomer("PEPTIDE",t)?.smiles??""))),p=(n.DataFrame.fromColumns([f]),(await i.chem.getSimilarities(f,c)).getRawData());for(let t=0;t<a;++t){const e=m[t];l[t]+=""!==h&&e!==g?p[e]:""===h&&e===g?1:0}}for(let s=0;s<l.length;++s){let i=l[s]/e.length;for(let o=0;o<t.length;++o){const t=r[o];if(o>=e.length&&t.data[s]!==t.emptyIndex||t.data[s]===t.emptyIndex&&o<e.length){i=n.FLOAT_NULL;break}}l[s]=i}return n.Column.fromFloat32Array("Similarity",l)}},8601:(t,e,s)=>{"use strict";s.d(e,{i0:()=>m});var n=s(4469),i=s(976),r=s(6414),o=s.n(r),a=s(1821),l=s(499);const h={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:"d",RIBOSE:"r",PHOSPHATE:"p",OXYGEN:"O",HYDROGEN:"H"};var c=s(1047);function u(t){return Math.round(h.PRECISION_FACTOR*t)/h.PRECISION_FACTOR}async function m(t,e,r){if(0===i.Func.find({package:"Chem",name:"getRdKitModule"}).length)return{col:null,warnings:['Transformation to atomic level requires the package "Chem" installed.']};if(e.semType!==i.SEMTYPE.MACROMOLECULE)return{col:null,warnings:[`Only the ${i.SEMTYPE.MACROMOLECULE} columns can be converted to atomic level, the chosen column has semType '${e.semType}'`]};let u=e;const m=l.Cn.getOrCreate(e);m.isHelm()&&(u=m.convert(a.r2.SEPARATOR,"."),u.name=e.name);const g=l.Cn.getOrCreate(u).alphabet;let f;if("PT"===g||"UN"===g)f="PEPTIDE";else{if("RNA"!==g&&"DNA"!==g)return{col:null,warnings:[`Unexpected column's '${u.name}' alphabet '${g}'.`]};f="RNA"}const p=function(t){const e=t.length,s=new Array(e),n=l.Cn.getOrCreate(t).getSplitter();for(let i=0;i<e;++i){const e=t.get(i);s[i]=e?o()(n(e)).filter((t=>""!==t)).toArray():[]}return s}(u),y=await async function(t,e,s,i){const r=function(t,e,s){const n=new Map;for(const i of t.getMonomerSymbolsByType(e)){const r=t.getMonomer(e,i);if("RNA"===e&&("Branch"===r.monomerType||"DNA"===s&&r.symbol===h.DEOXYRIBOSE||"RNA"===s&&r.symbol===h.RIBOSE||r.symbol===h.PHOSPHATE)||"PEPTIDE"===e&&"Branch"!==r.monomerType){const t={};c.rx.forEach((e=>{t[e]=r[e]})),n.set(r.symbol,t)}}return n}(e,s,i),o=new Map,a=await n.functions.call("Chem:getRdKitModule"),l={value:null};if("RNA"===s){const t="RNA"===i?[h.RIBOSE,h.PHOSPHATE]:[h.DEOXYRIBOSE,h.PHOSPHATE];for(const e of t)d(o,e,r,a,s,l)}for(let e=0;e<t.length;++e){const n=t[e];for(const t of n)if(""!==t)try{d(o,t,r,a,s,l)}catch(e){const s=e instanceof Error?e.message:e.toString(),n=e instanceof Error?e.stack:void 0;throw console.error(`bio lib: getMonomersDictFromLib() sym='${t}', error:\n${s}\n${n}`),new Error(`Can't get monomer '${t}' from library: ${s}`)}}return o}(p,r,f,g),w=u.length,{molfileList:b,molfileWarningList:T}=await async function(t,e,n,i,r){const o=Math.max(navigator.hardwareConcurrency-2,1),a=new Array(o).fill(null).map((()=>new Worker(new URL(s.p+s.u(79),s.b)))),l=r/o;let h=[],c=[];const u=new Array(o);for(let s=0;s<o;s++){const h=Math.floor(s*l),c=s===o-1?r:Math.floor((s+1)*l);a[s].postMessage({monomerSequencesArray:t,monomersDict:e,alphabet:n,polymerType:i,start:h,end:c}),u[s]=new Promise((t=>{a[s].onmessage=({data:{molfileList:e,molfileWarningList:s}})=>{t({molfileList:e,molfileWarningList:s})}}))}return(await Promise.all(u)).forEach((t=>{h=h.concat(...t.molfileList),c=c.concat(...t.molfileWarningList)})),setTimeout((()=>{a.forEach((t=>{t.terminate()}))}),0),{molfileList:h,molfileWarningList:c}}(p,y,g,f,w);if(T.length>.05*w)throw new Error("Too many errors getting molfiles.");const C=`molfile(${u.name})`,S=t.columns.getUnusedName(C),A=i.Column.fromStrings(S,b);return A.semType=i.SEMTYPE.MOLECULE,A.setTag(i.TAGS.UNITS,i.UNITS.Molecule.MOLBLOCK),{col:A,warnings:T}}function d(t,e,s,n,i,r){if(!t.has(e)){const o=function(t,e,s,n,i){if(e.has(t)){const r=e.get(t),o=function(t){const e=[];for(const s of t){let t=s.capGroupSmiles;t||(t=s.capGroupSMILES),t=t.replace(/(\[|\]|\*|:|\d)/g,""),e.push(t)}return e}(r.rgroups),a=function(t){const e=new Map;let s=t.indexOf(h.V2K_A_LINE,0),n=s;for(;-1!==s;){n=t.indexOf("\n",s);const i=parseInt(t.substring(s,n).replace(/^A\s+/,""));s=t.indexOf("R",n),n=t.indexOf("\n",s);const r=parseInt(t.substring(s,n).replace(/^R/,""));e.set(i,r),s=t.indexOf(h.V2K_A_LINE,n)}for(s=t.indexOf(h.V2K_RGP_LINE,0),n=t.indexOf("\n",s);-1!==s;){s+=h.V2K_RGP_SHIFT,n=t.indexOf("\n",s);const i=t.substring(s,n).replaceAll(/\s+/g," ").split(" ").map((t=>parseInt(t))).slice(1);for(let t=0;t<i.length;t+=2){if(e.has(i[t])&&e.get(i[t])!==i[t+1])throw new Error(`r-group index ${i[t]} has already been added with a different value`);e.set(i[t],i[t+1])}s=t.indexOf(h.V2K_RGP_LINE,n)}return e}(r.molfile),l=function(t,e){const s=e.get_mol(t),n=s.get_v3Kmolblock();return s.delete(),n}(function(t){let e=t.indexOf(h.V2K_A_LINE,0);-1===e&&(e=t.indexOf(h.V2K_RGP_LINE));const s=t.indexOf(h.V3K_END,e);return t.substring(0,e)+t.substring(s)}(r.molfile),s),c=function(t){let e=(t=t.replaceAll("\r","")).indexOf(h.V3K_BEGIN_COUNTS_LINE)+h.V3K_COUNTS_SHIFT,s=t.indexOf(" ",e+1);const n=parseInt(t.substring(e,s));return e=s+1,s=t.indexOf(" ",e+1),{atomCount:n,bondCount:parseInt(t.substring(e,s))}}(l),m=function(t,e){const s=new Array(e),n=new Float32Array(e),i=new Float32Array(e),r=new Array(e);let o=t.indexOf(h.V3K_BEGIN_ATOM_BLOCK);o=t.indexOf("\n",o);let a=o;for(let l=0;l<e;l++){o=t.indexOf(h.V3K_BEGIN_DATA_LINE,o)+h.V3K_IDX_SHIFT,a=t.indexOf(" ",o),o=a+1,a=t.indexOf(" ",o),s[l]=t.substring(o,a);const e=new Array(2);for(let s=0;s<2;++s)o=a+1,a=t.indexOf(" ",o),e[s]=parseFloat(t.substring(o,a));n[l]=e[0],i[l]=e[1],o=a,a=t.indexOf("\n",o)+1,r[l]=t.slice(o,a),o=a}return{atomTypes:s,x:n,y:i,kwargs:r}}(l,c.atomCount),d=function(t,e){const s=new Uint32Array(e),n=new Array(e),i=new Map,r=new Map;let o=t.indexOf(h.V3K_BEGIN_BOND_BLOCK);o=t.indexOf("\n",o);let a=o;for(let l=0;l<e;++l){const e=new Array(3);o=t.indexOf(h.V3K_BEGIN_DATA_LINE,a)+h.V3K_IDX_SHIFT,a=t.indexOf(" ",o);for(let s=0;s<3;++s)o=a+1,a=Math.min(t.indexOf("\n",o),t.indexOf(" ",o)),e[s]=parseInt(t.slice(o,a));s[l]=e[0],n[l]=e.slice(1);const c=t.indexOf("\n",o);let u=t.slice(a,c),m=u.indexOf(h.V3K_BOND_CONFIG);if(-1!==m){m=u.indexOf("=",m)+1;let t=u.indexOf(" ",m);-1===t&&(t=u.length);const e=parseInt(u.slice(m,t));i.set(l,e);const s=h.V3K_BOND_CONFIG+e.toString();u=u.replace(s,"")}u||r.set(l,u)}return{bondTypes:s,atomPairs:n,bondConfiguration:i,kwargs:r}}(l,c.bondCount),y={atoms:m,bonds:d,meta:g(m,d,o,a)};return"PEPTIDE"===n?function(t){const e=t.meta.terminalNodes[0]-1,s=t.meta.rNodes[0]-1,n=t.atoms.x,i=t.atoms.y;A(t,-n[e],-i[e]);const r=T(n[s],i[s]);C(t.atoms,-r),n[t.meta.rNodes[1]-1]<0&&function(t){S(t,!1)}(t);const o=function(t){const e=function(t){const e=new Map;for(const s of t.bonds.atomPairs)for(let t=0;t<2;t++){const n=s[t],i=s[(t+1)%2];e.has(n)?e.get(n)?.push(i):e.set(n,new Array(1).fill(i))}return e}(t);let s=0,n=0;for(;0===s;){const i=e.get(t.meta.terminalNodes[1])[n];t.atoms.atomTypes[i-1]===h.OXYGEN&&i!==t.meta.rNodes[1]&&(s=i),n++}return s}(t);!function(t,e){t.atoms.y[t.meta.rNodes[1]-1]<0&&t.atoms.y[e-1]<0&&(function(t){S(t,!0)}(t),C(t.atoms,-function(t,e){return T(t,e)+Math.PI/2}(t.atoms.x[t.meta.terminalNodes[1]-1],t.atoms.y[t.meta.terminalNodes[1]-1])))}(t,o),function(t,e){const s=t.atoms.x;s[t.meta.rNodes[1]-1]>s[e-1]&&function(t,e,s){const n=e-1,i=s-1,r=t.atoms.x,o=t.atoms.y,a=r[n],l=o[n];r[n]=r[i],o[n]=o[i],r[i]=a,o[i]=l}(t,e,t.meta.rNodes[1])}(t,o)}(y):t===h.RIBOSE||t===h.DEOXYRIBOSE?function(t,e){const s=t.atoms.x,n=t.atoms.y;let i=t.meta.terminalNodes[0]-1;const r=t.meta.rNodes[1]-1;A(t,-s[i],-n[i]);const o=T(s[r],n[r]);C(t.atoms,3*Math.PI/2-o),e.value=function(t){const e=t.atoms.x,s=t.atoms.y,n=t.meta.rNodes[2]-1,i=t.meta.terminalNodes[2]-1,r=e[n]-e[i],o=s[n]-s[i];return Math.atan(o/r)+Math.PI/2}(t),i=t.meta.terminalNodes[0]-1,A(t,-s[i],-n[i])}(y,i):t===h.PHOSPHATE?function(t){const e=t.meta.terminalNodes[0]-1,s=t.meta.rNodes[0]-1,n=t.atoms.x,i=t.atoms.y;A(t,-n[e],-i[e]);const r=T(n[s],i[s]);C(t.atoms,Math.PI/2-r)}(y):function(t,e){const s=t.atoms.x,n=t.atoms.y,i=t.meta.terminalNodes[0]-1,r=t.meta.rNodes[0]-1;A(t,-s[i],-n[i]);const o=T(s[r],n[r]),a=e.value;if(!a)throw new Error("The value of sugarBranchToOYAngle is null");C(t.atoms,Math.PI-o+a);const l=function(t,e){return u(Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2))}({x:s[t.meta.rNodes[0]-1],y:n[t.meta.rNodes[0]-1]},{x:s[t.meta.terminalNodes[0]-1],y:n[t.meta.terminalNodes[0]-1]});if(1!=l)for(let t=0;t<s.length;++t)s[t]=u(s[t]/l),n[t]=u(n[t]/l)}(y,i),function(t,e,s){"PEPTIDE"===t?(p(e,t),w(e,e.meta.rNodes[1])):s===h.RIBOSE||s===h.DEOXYRIBOSE?(w(e,e.meta.rNodes[1]),e.meta.rNodes[1]=e.meta.terminalNodes[1],f(e.bonds,e.meta),p(e,t),w(e,e.meta.rNodes[1]),w(e,e.meta.rNodes[0]),w(e,e.meta.rNodes[2])):s===h.PHOSPHATE&&(e.meta.terminalNodes[0]=e.meta.rNodes[0],A(e,-e.atoms.x[e.meta.terminalNodes[0]-1],-e.atoms.y[e.meta.terminalNodes[0]-1]),p(e,t),w(e,e.meta.rNodes[1]))}(n,y,t),function(t){let e=0;for(;e<t.atoms.atomTypes.length;)t.atoms.atomTypes[e]===h.HYDROGEN&&(w(t,e+1),--e),++e}(y),y}return null}(e,s,n,i,r);if(!o)throw new Error(`Monomer with symbol '${e}' is absent the monomer library`);t.set(e,o)}}function g(t,e,s,n){const i={backboneShift:null,branchShift:null,terminalNodes:[],rNodes:[]};return function(t,e,s){for(const[n,i]of s)t.atomTypes[n-1]=e[i-1]}(t,s,n),function(t,e){e.rNodes=Array.from(t.keys());for(let s=0;s<e.rNodes.length;s++)for(const n of[1,2])if(t.get(e.rNodes[s])===n){const t=e.rNodes[n-1];e.rNodes[n-1]=e.rNodes[s],e.rNodes[s]=t}}(n,i),f(e,i),i}function f(t,e){const s=e.rNodes;e.terminalNodes=new Array(s.length).fill(0);const n=e.terminalNodes,i=t.atomPairs;let r=0,o=0;for(;r<i.length&&o<n.length;){for(let t=0;t<n.length;++t)for(let e=0;e<2;++e)i[r][e]===s[t]&&(n[t]=i[r][(e+1)%2],s.length,++o);++r}}function p(t,e){t.meta.rNodes.length>1&&(t.meta.backboneShift=y(t,t.meta.rNodes[1]-1,t.meta.terminalNodes[0]-1)),"RNA"===e&&t.meta.rNodes.length>2&&(t.meta.branchShift=y(t,t.meta.rNodes[2]-1,t.meta.terminalNodes[0]-1))}function y(t,e,s){return[u(t.atoms.x[e]-t.atoms.x[s]),u(t.atoms.y[e]-t.atoms.y[s])]}function w(t,e){if(void 0!==e){const s=e-1,n=t.atoms,i=t.bonds,r=t.meta;n.atomTypes.splice(s,1),n.x=b(Float32Array,n.x,s,1),n.y=b(Float32Array,n.y,s,1),n.kwargs.splice(s,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 o=0;for(;o<i.atomPairs.length;){const t=i.atomPairs[o][0],s=i.atomPairs[o][1];t===e||s===e?(i.atomPairs.splice(o,1),i.bondTypes=b(Uint32Array,i.bondTypes,o,1),i.bondConfiguration.has(o)&&i.bondConfiguration.delete(o),i.kwargs.has(o)&&i.kwargs.delete(o),--o):(i.atomPairs[o][0]=t>e?t-1:t,i.atomPairs[o][1]=s>e?s-1:s),++o}let a=Array.from(i.bondConfiguration.keys());a.forEach((t=>{if(i.bondConfiguration.has(t)&&t>s){const e=i.bondConfiguration.get(t);i.bondConfiguration.delete(t),i.bondConfiguration.set(t-1,e)}})),a=Array.from(i.kwargs.keys()),a.forEach((t=>{if(i.kwargs.has(t)&&t>s){const e=i.kwargs.get(t);i.kwargs.delete(t),i.kwargs.set(t-1,e)}}))}}function b(t,e,s,n){const i=new t(e.length-n);let r=0,o=0;for(;r<e.length;)r===s&&(r+=n),i[o]=e[r],++o,++r;return i}function T(t,e){let s;if(0===t)s=e>0?0:Math.PI;else if(0===e)s=t>0?-Math.PI/2:Math.PI/2;else{const n=e/t,i=Math.atan(n);s=t<0?Math.PI/2+i:-Math.PI/2+i}return s}function C(t,e){if(0!==e){const s=t.x,n=t.y,i=Math.cos(e),r=Math.sin(e);for(let t=0;t<s.length;++t){const e=s[t];s[t]=u(e*i-n[t]*r),n[t]=u(e*r+n[t]*i)}}}function S(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 s=t.bonds.bondConfiguration;for(const[t,e]of s){const n=1===e?3:1;s.set(t,n)}}function A(t,e,s){const n=t.atoms.x,i=t.atoms.y;for(let t=0;t<n.length;++t)n[t]=u(n[t]+e),void 0!==s&&(i[t]=u(i[t]+s))}},6137:(t,e,s)=>{"use strict";s.d(e,{J:()=>i,V:()=>r});var n=s(9976);class i extends n.B{static get Chromatogram(){return void 0===this.chromatogram&&(this.chromatogram=new i({A:"green",C:"blue",G:"black",T:"red",U:"red",others:"gray"})),this.chromatogram}}class r{}r.SemType="Nucleotides",r.SemTypeMultipleAlignment="NucleotidesMultipleAlignment",r.Names={A:"Adenine",C:"Cytosine",G:"Guanine",T:"Thymine",U:"Uracil"}},9976:(t,e,s)=>{"use strict";s.d(e,{B:()=>n});class n{static makePalette(t,e=!1,s=n){const i={};return t.forEach((t=>{const s=t[0],n=t[1];s.forEach(((t,s)=>{i[t]=this.colourPalette[n][e?0:s]}))})),new s(i)}constructor(t){this._palette=t}get(t){return this._palette[t]}}n.undefinedColor="rgb(100,100,100)",n.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)"]}},7331:(t,e,s)=>{"use strict";s.d(e,{UE:()=>h,kQ:()=>o});var n=s(976),i=s(9976);class r{static hashCode(t){let e=0;if(0===t.length)return e;for(let s=0;s<t.length;s++)e=(e<<5)-e+t.charCodeAt(s),e|=0;return e}}class o{}class a extends o{get(t){return"#666666"}}class l extends o{static buildPalette(){return[].concat(...Object.values(i.B.colourPalette))}get(t){const e=r.hashCode(t)%l.palette.length;return function(t){if(null==t)return"rgb(100,100,100)";const e=n.Color.fromHtml(t),s=n.Color.g(e),i=n.Color.r(e),r=n.Color.b(e),o=Math.sqrt(Math.pow(0-i,2)+Math.pow(0-s,2)+Math.pow(0-r,2));return o>210?`rgb(${i/o*210},${s/o*210},${r/o*210})`:n.Color.toRgb(e)}(l.palette[e])}}l.palette=l.buildPalette();class h extends i.B{static get Gray(){return void 0===this.gray&&(this.gray=new a),this.gray}static get Color(){return void 0===this.color&&(this.color=new l),this.color}}},9611:(t,e,s)=>{"use strict";s.d(e,{A:()=>h});var n=s(4469),i=s(976),r=s(6414),o=s.n(r),a=s(8447);const l={DNA:"RNA",RNA:"RNA",PT:"PEPTIDE",UN:"PEPTIDE"};class h{get updated(){return this._updated}constructor(t,e,s){this.grid=t,this.col=e,this.propsProvider=s,this._monomerLengthList=null,this.separatorWidth=5,this._updated=!1,this._monomerLengthMap={},this._monomerStructureMap={},this.subs=[],this._splitter=(0,a.Mj)(this.col),this.props=this.propsProvider(),this._rowsProcessed=i.BitSet.create(this.col.length),this.grid&&(this.subs.push(e.dataFrame.onDataChanged.subscribe((()=>{this.props=this.propsProvider(),this._monomerLengthList=null,this._rowsProcessed=i.BitSet.create(this.col.length)}))),this.subs.push(n.events.onViewRemoved.subscribe((t=>{this.grid?.view?.id===t.id&&this.destroy()}))))}destroy(){for(const t of this.subs)t.unsubscribe()}getCellMonomerLengths(t){const e=this.props.unitsHandler.isMsa()?this.getCellMonomerLengthsForSeqMsa():this.getCellMonomerLengthsForSeq(t),s=new Array(e.length+1);s[0]=5;for(let t=1;t<s.length;t++)s[t]=s[t-1]+e[t-1];return[e,s]}getCellMonomerLengthsForSeq(t){null===this._monomerLengthList&&(this._monomerLengthList=new Array(this.col.length).fill(null),this._updated=!0);let e=this._monomerLengthList[t];if(null===e){const s=this.getSeqMonList(t);e=this._monomerLengthList[t]=new Array(s.length);for(const[t,n]of o().enumerate(s)){const s=this.props.monomerToShort(t,this.props.monomerLengthLimit),i=(this.props.unitsHandler.isSeparator()?this.separatorWidth:this.props.separatorWidth)+s.length*this.props.monomerCharWidth;e[n]=i}this._updated=!0}return e}getCellMonomerLengthsForSeqMsa(){var t;null===this._monomerLengthList&&(this._monomerLengthList=new Array(1).fill(null),this._updated=!0),(t=this._monomerLengthList)[0]??(t[0]=new Array(0));const e=this._monomerLengthList[0],s=Math.max(Math.floor((this.grid?.vertScroll.min??0)-10),0),n=Math.min(Math.ceil((this.grid?.vertScroll.max??0)+10),this.col.length);for(let t=s;t<n;t++){if(this._rowsProcessed.get(t))continue;const s=this.getSeqMonList(t);s.length>e.length&&e.push(...new Array(s.length-e.length).fill(0));for(const[t,n]of o().enumerate(s)){const s=this.props.monomerToShort(t,this.props.monomerLengthLimit),i=this.props.separatorWidth+s.length*this.props.monomerCharWidth;e[n]=Math.max(e[n]??0,i)}this._updated=!0}return e}getPosition(t,e){const[s,n]=this.getCellMonomerLengths(t),i=this.col.get(t),r=o()(this._splitter(i)).toArray();if(0===r.length)return null;let a=100,l=null,h=r.length,c=!1,u=0;if(n[0]<=e&&e<n.slice(-1)[0])for(;!c;)if(u=Math.floor((h+(l??0))/2),e>=n[u]&&e<=n[u+1]?(l=u,c=!0):e<n[u]?h=u-1:e>n[u+1]&&(l=u+1),l==h&&(c=!0),--a<=0)throw new Error(`Get position for pointer x = ${e} searching has not converged on ${JSON.stringify(n)}. `);return l}getSeqMonList(t){const e=this.col.get(t);return e?o()(this._splitter(e)).toArray():[]}getMonomer(t){const e=this.props.unitsHandler.alphabet??"UN",s=l[e];return this.props.monomerLib?.getMonomer(s,t)??null}setMonomerLengthLimit(t){this.props.monomerLengthLimit=t,this._updated=!0}setSeparatorWidth(t){this.props.separatorWidth=t,this._updated=!0}isMsa(){return this.props.unitsHandler.isMsa()}}},1047:(t,e,s)=>{"use strict";s.d(e,{At:()=>i,Ei:()=>o,K4:()=>a,pn:()=>r,rx:()=>n,zh:()=>l});const n=["symbol","molfile","rgroups","name"],i="MonomerName",r={symbol:"Short Name",name:"Medium Name",smiles:"SMILES"},o=[{capGroupSmiles:"[*:1][H]",alternateId:"R1-H",capGroupName:"H",label:"R1"},{capGroupSmiles:"O[*:2]",alternateId:"R2-OH",capGroupName:"OH",label:"R2"}],a={monomerType:null,smiles:null,name:"MonomerName",author:null,molfile:"molecule",naturalAnalog:"MonomerNaturalAnalogCode",rgroups:"MonomerCaps",createDate:null,id:null,polymerType:"MonomerType",symbol:"MonomerCode"},l={monomerType:"Backbone",smiles:"",name:"",author:"Datagrok",molfile:"",naturalAnalog:"",rgroups:[],createDate:null,id:0,polymerType:"PEPTIDE",symbol:""}},5226:(t,e,s)=>{"use strict";s.d(e,{i:()=>o});var n=s(976),i=s(499),r=s(1821);class o{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,s=0;for(;e=t.exec(this._fileContent);){const n=this._fileContent.substring(e.index+1,t.lastIndex);this._descriptionsArray.push(n),0!==s&&this._sequencesArray.push(this.parseMacromolecule(s,e.index)),s=t.lastIndex+1}this._sequencesArray.push(this.parseMacromolecule(s,-1))}importFasta(){const t=n.Column.fromStrings("description",this.descriptionsArray),e=n.Column.fromStrings("sequence",this.sequencesArray);return e.semType=n.SEMTYPE.MACROMOLECULE,e.setTag(n.TAGS.UNITS,r.r2.FASTA),i.Cn.getOrCreate(e),[n.DataFrame.fromColumns([t,e])]}constructor(t){this._descriptionsArray=[],this._sequencesArray=[],this._fileContent=t,this.parseColumns()}}},1821:(t,e,s)=>{"use strict";s.d(e,{BM:()=>o,CI:()=>r,XS:()=>l,r2:()=>n,se:()=>a});var n,i=s(6286);!function(t){t.FASTA="fasta",t.SEPARATOR="separator",t.HELM="helm"}(n||(n={}));const r=", ",o=/(?:\[([A-Za-z0-9_\-,()]+)\])|([A-Za-z\-])/g,a=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"])}}},l=[new i.L("PT",a.fasta.peptide,.5),new i.L("DNA",a.fasta.dna,.55),new i.L("RNA",a.fasta.rna,.55)]},8447:(t,e,s)=>{"use strict";s.d(e,{CI:()=>n.CI,GU:()=>i.GU,KX:()=>i.KX,Mj:()=>i.Mj,XS:()=>n.XS,dQ:()=>i.dQ,gM:()=>i.gM,gP:()=>i.gP,kB:()=>i.kB,py:()=>i.py,r2:()=>n.r2,up:()=>i.up});var n=s(1821),i=s(585)},6286:(t,e,s)=>{"use strict";s.d(e,{L:()=>n,d:()=>i});class n{constructor(t,e,s){this.name=t,this.alphabet=e,this.cutoff=s}}class i extends n{constructor(t,e,s){super(t.name,t.alphabet,t.cutoff),this.freq=e,this.similarity=s}}},585:(t,e,s)=>{"use strict";s.d(e,{Ar:()=>y,FJ:()=>p,GU:()=>v,KX:()=>M,Mj:()=>S,dQ:()=>_,gM:()=>E,gP:()=>T,jY:()=>g,kB:()=>f,py:()=>P,up:()=>L,vU:()=>C,w4:()=>N});var n=s(976),i=s(6414),r=s.n(i),o=s(6286),a=s(1821),l=s(499),h=s(3659),c=s(850),u=s(2012),m=s(6137),d=s(7331);function g(t,e,s){return t.categories,function(t,e){const s={};let n=!0,i=null;for(const r of t)if(null==i?i=r.length:r.length!==i&&(n=!1),r.length>=e)for(const t of r)t in s||(s[t]=0),s[t]+=1;return{freq:s,sameLength:n}}(r()(t.getRawData()).map((e=>s(t.categories[e]))),e)}function f(t){return r()(t.toString().matchAll(a.BM)).map((t=>t[2]??t[1])).toArray()}function p(t){return t||[]}function y(t,e=undefined){return s=>s?s.split(t,e):[]}const w=/(PEPTIDE1|DNA1|RNA1)\{([^}]+)}/g,b=/\[([^\[\]]+)]/g;function T(t){w.lastIndex=0;const e=w.exec(t.toString()),s=e?e[2]:null;return(s?s.split("."):[]).map((t=>{b.lastIndex=0;const e=b.exec(t);return e&&e.length>=2?e[1]:t}))}function C(t,e,s=undefined){if(t.toLowerCase().startsWith(a.r2.FASTA))return f;if(t.toLowerCase().startsWith(a.r2.SEPARATOR))return y(e,s);if(t.toLowerCase().startsWith(a.r2.HELM))return T;throw new Error(`Unexpected units ${t} .`)}function S(t){return l.Cn.getOrCreate(t).getSplitter()}const A=/([^\W_]+)/g;function v(t,e){if(t.length<=e)return t;const s=t.match(A),n=t.length>e||(s?.length??0)>1,i=s?.[0]??" ";return n?i.substring(0,e-1)+"…":i}function E(t){switch(t){case"DNA":return a.se.fasta.dna;case"RNA":return a.se.fasta.rna;case"PT":return a.se.fasta.peptide;default:throw new Error(`Unsupported alphabet '${t}'.`)}}function M(t,e,s="-"){const n=new Set([...new Set(Object.keys(t)),...e]);n.delete(s);const i=[],r=[];for(const s of n)i.push(s in t?t[s]:0),r.push(e.has(s)?1:0);const o=new h.OW(i),a=new h.OW(r);return(0,c.MA)(o,a)/((0,c.$G)(o)*(0,c.$G)(a))}function N(t,e,s="-"){const n=e.map((e=>{const n=M(t,e.alphabet,s);return new o.d(e,t,n)}));let i;const r=Math.max(...n.map((t=>t.similarity>t.cutoff?t.similarity:-1)));return i=r>0?n.find((t=>t.similarity===r)).name:"UN",i}function _(t,e=5){let s;return s=t.semType==n.SEMTYPE.MACROMOLECULE?l.Cn.getOrCreate(t).alphabet:N(g(t,e,f).freq,a.XS),P(s)}function P(t){switch(t){case"PT":return u.f.GrokGroups;case"DNA":case"RNA":return m.J.Chromatogram;default:return d.UE.Color}}function L(t){const e=t.columns.bySemTypeAll(n.SEMTYPE.MACROMOLECULE);let s=e.find((t=>{const e=t.getTag(n.TAGS.UNITS);return!!e&&-1!==e.indexOf("MSA")}))??null;return!s&&e.length>0&&(s=e[0]),s}},8457:(t,e,s)=>{"use strict";s.d(e,{O:()=>a});var n=s(976),i=s(6414),r=s.n(i),o=s(585);function a(t){const e=(0,o.Mj)(t),s=t=>{const e=l.columns.addNewString((t+1).toString());return i.push(e),e},i=[],a=t.length,l=n.DataFrame.create(a);for(let n=0;n<a;++n){const o=t.get(n);if(null==o)continue;const a=e(o);for(const[t,e]of r().enumerate(a))((i[e]??null)||s(e)).set(n,t||"-",!1)}return l}},499:(t,e,s)=>{"use strict";s.d(e,{Cn:()=>m,_9:()=>u});var n=s(976),i=s(6414),r=s.n(i),o=s(8447),a=s(585),l=s(489),h=s(7228);const c=new class{constructor(){this.uhTemp=`units-handler.${n.SEMTYPE.MACROMOLECULE}`}},u={[o.r2.FASTA]:"-",[o.r2.SEPARATOR]:"",[o.r2.HELM]:"*"};class m{static setUnitsToFastaColumn(t){if(t.column.semType!==n.SEMTYPE.MACROMOLECULE||t.column.getTag(n.TAGS.UNITS)!==o.r2.FASTA)throw new Error(`The column of notation '${o.r2.FASTA}' must be '${n.SEMTYPE.MACROMOLECULE}'.`);t.column.setTag(n.TAGS.UNITS,o.r2.FASTA),m.setTags(t)}static setUnitsToSeparatorColumn(t,e){if(t.column.semType!==n.SEMTYPE.MACROMOLECULE||t.column.getTag(n.TAGS.UNITS)!==o.r2.SEPARATOR)throw new Error(`The column of notation '${o.r2.SEPARATOR}' must be '${n.SEMTYPE.MACROMOLECULE}'.`);if(!e)throw new Error(`The column of notation '${o.r2.SEPARATOR}' must have the separator tag.`);t.column.setTag(n.TAGS.UNITS,o.r2.SEPARATOR),t.column.setTag("separator",e),m.setTags(t)}static setUnitsToHelmColumn(t){if(t.column.semType!==n.SEMTYPE.MACROMOLECULE)throw new Error(`The column of notation '${o.r2.HELM}' must be '${n.SEMTYPE.MACROMOLECULE}'`);t.column.setTag(n.TAGS.UNITS,o.r2.HELM),m.setTags(t)}static setTags(t){const e=t.column.getTag(n.TAGS.UNITS),s=t.stats;if(Object.keys(s.freq).some((t=>t.length>1)),[o.r2.FASTA,o.r2.SEPARATOR].includes(e)){if(0===Object.keys(s.freq).length)throw new Error("Alphabet is empty");let e=t.column.getTag("aligned");null===e&&(e=s.sameLength?"SEQ.MSA":"SEQ",t.column.setTag("aligned",e));let n=t.column.getTag("alphabet");if(null===n&&(n=(0,a.w4)(s.freq,o.XS),t.column.setTag("alphabet",n)),"UN"===n){const e=Object.keys(s.freq).length,n=Object.keys(s.freq).some((t=>t.length>1));t.column.setTag(".alphabetSize",e.toString()),t.column.setTag(".alphabetIsMultichar",n?"true":"false")}}}get column(){return this._column}get units(){return this._units}get notation(){return this._notation}get defaultGapSymbol(){return this._defaultGapSymbol}get separator(){const t=this.column.getTag("separator")??void 0;if(this.notation===o.r2.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("aligned");if(!t&&(this.isFasta()||this.isSeparator()))throw new Error("Tag aligned not set");return t}get alphabet(){const t=this.column.getTag("alphabet");if(!t&&(this.isFasta()||this.isSeparator()))throw new Error("Tag alphabet not set");return t}get helmCompatible(){return this.column.getTag(".isHelmCompatible")}getAlphabetSize(){if(this.notation==o.r2.HELM||"UN"==this.alphabet){const t=this.column.getTag(".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"PT":return 20;case"DNA":case"RNA":return 4;case"NT":return console.warn("Unexpected alphabet 'NT'."),4;default:throw new Error(`Unexpected alphabet '${this.alphabet}'.`)}}getAlphabetIsMultichar(){return this.notation===o.r2.HELM||"UN"===this.alphabet&&"true"===this.column.getTag(".alphabetIsMultichar")}get splitted(){if(null===this._splitted){const t=this.getSplitter(),e=this._column.length;this._splitted=new Array(e);const s=this._column.getRawData(),n=this._column.categories;for(let i=0;i<e;i++){const e=n[s[i]];this._splitted[i]=t(e)}}return this._splitted}get stats(){if(null===this._stats){const t={};let e=!0,s=null;for(const n of this.splitted){null==s?s=n.length:n.length!==s&&(e=!1);for(const e of n)e in t||(t[e]=0),t[e]+=1}this._stats={freq:t,sameLength:e}}return this._stats}get maxLength(){return null===this._maxLength&&(this._maxLength=Math.max(...this.splitted.map((t=>t.length)))),this._maxLength}get posList(){if(null===this._posList){const t=this.column.getTag(".positionNames");this._posList=t?t.split(o.CI).map((t=>t.trim())):r().count(1).take(this.maxLength).map((t=>t.toString())).toArray()}return this._posList}isFasta(){return this.notation===o.r2.FASTA}isSeparator(){return this.notation===o.r2.SEPARATOR}isHelm(){return this.notation===o.r2.HELM}isRna(){return"RNA"===this.alphabet}isDna(){return"DNA"===this.alphabet}isPeptide(){return"PT"===this.alphabet}isMsa(){return!!this.aligned&&this.aligned.toUpperCase().includes("MSA")}isHelmCompatible(){return"true"===this.helmCompatible}isGap(t){return!t||this.units===o.r2.FASTA&&t===u[o.r2.FASTA]||this.units===o.r2.HELM&&t===u[o.r2.HELM]}getNotation(){if(this.units.toLowerCase().startsWith(o.r2.FASTA))return o.r2.FASTA;if(this.units.toLowerCase().startsWith(o.r2.SEPARATOR))return o.r2.SEPARATOR;if(this.units.toLowerCase().startsWith(o.r2.HELM))return o.r2.HELM;throw new Error(`Column '${this.column.name}' has unexpected notation '${this.units}'.`)}getHelmWrappers(){return[this.isDna()?"DNA1{":this.isRna()||this.isHelmCompatible()?"RNA1{":"PEPTIDE1{",this.isDna()?"D(":this.isRna()?"R(":"",this.isDna()||this.isRna()?")P":"","}$$$$"]}getNewColumn(t,e){const s=this.column,i=s.length,r=t.toLowerCase()+"("+s.name+")",a=s.dataFrame.columns.getUnusedName(r),l=n.Column.fromList("string",a,new Array(i).fill(""));if(l.semType=n.SEMTYPE.MACROMOLECULE,l.setTag(n.TAGS.UNITS,t),t===o.r2.SEPARATOR){if(!e)throw new Error(`Notation '${o.r2.SEPARATOR}' requires separator value.`);l.setTag("separator",e)}l.setTag(n.TAGS.CELL_RENDERER,"Macromolecule");const h=s.getTag("aligned");h&&l.setTag("aligned",h);const c=s.getTag("alphabet");null!=c&&l.setTag("alphabet",c);let u=s.getTag(".alphabetSize");null!=c&&u&&l.setTag(".alphabetSize",u);const m=s.getTag(".alphabetIsMultichar");return null!=c&&void 0!==m&&l.setTag(".alphabetIsMultichar",m),t==o.r2.HELM&&(u=this.getAlphabetSize().toString(),l.setTag(".alphabetSize",u)),l}static getNewColumn(t){const e=m.getOrCreate(t),s=e.notation;return e.getNewColumn(s)}static unitsStringIsValid(t){return t=t.toLowerCase(),[o.r2.FASTA,o.r2.SEPARATOR,o.r2.HELM].some((e=>t.startsWith(e.toLowerCase())))}static getNewColumnFromParams(t,e,s){if(!m.unitsStringIsValid(s))throw new Error("Invalid format of 'units' parameter");const i=n.Column.fromList("string",e,new Array(t).fill(""));return i.semType=n.SEMTYPE.MACROMOLECULE,i.setTag(n.TAGS.UNITS,s),i}getSplitter(t){if(this.units.toLowerCase().startsWith(o.r2.FASTA))return null===this.column.getTag("alphabet")||this.getAlphabetIsMultichar()?a.kB:a.FJ;if(this.units.toLowerCase().startsWith(o.r2.SEPARATOR))return(0,a.Ar)(this.separator,t);if(this.units.toLowerCase().startsWith(o.r2.HELM))return a.gP;throw new Error(`Unexpected units ${this.units} .`)}getDistanceFunctionName(){if(!this.isFasta())throw new Error("Only FASTA notation is supported");return this.isMsa()?l.U.HAMMING:(this.alphabet,l.U.LEVENSHTEIN)}getDistanceFunction(){return l.o[this.getDistanceFunctionName()]()}async checkHelmCompatibility(){if(this.column.tags.has(".isHelmCompatible"))return"true"===this.column.getTag(".isHelmCompatible");const t=(await(0,h.JN)()).getBioLib().getMonomerSymbolsByType("PEPTIDE".toString()),e=new Set(t),s=(0,a.Ar)(this.separator);for(const t of this.column.categories){const n=s(t);for(const t of n)if(!e.has(t))return this.column.setTag(".isHelmCompatible","false"),!1}return this.column.setTag(".isHelmCompatible","true"),!0}get splitter(){return null===this._splitter&&(this._splitter=(0,a.Mj)(this.column)),this._splitter}toFasta(t){return t===o.r2.FASTA}toSeparator(t){return t===o.r2.SEPARATOR}toHelm(t){return t===o.r2.HELM}convertHelmToFastaSeparator(t,e,s,n){n||(n=this.toFasta(e)?u[o.r2.FASTA]:u[o.r2.SEPARATOR]),s||(s=this.toFasta(e)?"":this.separator);const i=/(R\(|D\(|\)|P)/g,r=t.startsWith("DNA")||t.startsWith("RNA"),a=this.splitter(t),l=[];for(let t=0;t<a.length;t++){let s=a[t];if(r&&(s=s.replace(i,"")),s===u[o.r2.HELM])l.push(n);else if(this.toFasta(e)&&s.length>1){const t="["+s+"]";l.push(t)}else l.push(s)}return l.join(s)}convert(t,e){const s=this.getConverter(t,e),n=this.getNewColumn(t,e);return n.init((t=>s(this.column.get(t)))),n}getRegion(t,e,s){const n=this.getNewColumn(this.notation,this.separator);n.name=s,Math.max(...this.splitted.map((t=>t.length)));const i=t??0,r=e??this.maxLength-1,a=this.getJoiner(),l=r-i+1;n.init((t=>{const e=this.splitted[t],s=new Array(l);for(let t=0;t<l;++t){const n=i+t;s[t]=n<e.length?e[n]:u[this.notation]}return a(s)}));const h=t=>{const e=t.split(",").map((t=>t.trim())),s=new Array(l);for(let t=0;t<l;++t){const n=i+t;s[t]=n<e.length?e[n]:"?"}return s.join(o.CI)},c=this.column.getTag(".positionNames");c&&n.setTag(".positionNames",h(c));const m=this.column.getTag(".positionLabels");return m&&n.setTag(".positionLabels",h(m)),n}getJoiner(){const t=this;if(this.notation===o.r2.FASTA)return function(e){return g(t,e)};if(this.notation===o.r2.SEPARATOR)return function(e){return f(t,e,t.separator)};if(this.notation===o.r2.HELM){const e="DNA"===t.alphabet||"RNA"===t.alphabet;return function(s){return p(t,s,e)}}throw new Error}getConverter(t,e=undefined){if(t===o.r2.SEPARATOR&&!e)throw new Error(`Target separator is not specified for target units '${o.r2.SEPARATOR}'.`);const s=this;if(t===o.r2.FASTA)return function(t){return function(t,e){const s=t.isHelm()?y(t,e):t.getSplitter()(e);return g(t,s)}(s,t)};if(t===o.r2.HELM)return function(t){return function(t,e){const s=e.startsWith("DNA")||e.startsWith("RNA"),n=t.getSplitter()(e);return p(t,n,s)}(s,t)};if(t===o.r2.SEPARATOR)return function(t){return function(t,e,s){const n=t.isHelm()?y(t,e):t.getSplitter()(e);return f(t,n,s)}(s,t,e)};throw new Error}constructor(t){if(this._splitter=null,this._splitted=null,this._stats=null,this._maxLength=null,this._posList=null,t.type!=n.TYPE.STRING)throw new Error(`Unexpected column type '${t.type}', must be '${n.TYPE.STRING}'.`);this._column=t;const e=this._column.getTag(n.TAGS.UNITS);if(null==e)throw new Error("Units are not specified in column");if(this._units=e,this._notation=this.getNotation(),this._defaultGapSymbol=this.isFasta()?u[o.r2.FASTA]:this.isHelm()?u[o.r2.HELM]:u[o.r2.SEPARATOR],!this.column.tags.has("aligned")||!this.column.tags.has("alphabet")||!this.column.tags.has(".alphabetIsMultichar")&&!this.isHelm()&&"UN"===this.alphabet)if(this.isFasta())m.setUnitsToFastaColumn(this);else if(this.isSeparator()){const e=t.getTag("separator");m.setUnitsToSeparatorColumn(this,e)}else{if(!this.isHelm())throw new Error(`Unexpected units '${this.column.getTag(n.TAGS.UNITS)}'.`);m.setUnitsToHelmColumn(this)}if(!this.column.tags.has(".alphabetIsMultichar"))if(this.isHelm())this.column.setTag(".alphabetIsMultichar","true");else if(["UN"].includes(this.alphabet))throw new Error(`For column '${this.column.name}' of alphabet '${this.alphabet}' tag '.alphabetIsMultichar' is mandatory.`)}static getOrCreate(t){return c.uhTemp in t.temp||(t.temp[c.uhTemp]=new m(t)),t.temp[c.uhTemp]}}const d=/[RD]\((\w)\)P?/g;function g(t,e){const s=new Array(e.length);for(const[n,i]of r().enumerate(e)){let r=n;t.isHelm()&&(r=n.replace(d,"$1")),t.isGap(r)?r=u[o.r2.FASTA]:r.length>1&&(r="["+e[i]+"]"),s[i]=r}return s.join("")}function f(t,e,s){const n=new Array(e.length);for(const[s,i]of r().enumerate(e)){let e=s;t.isGap(e)&&(e=u[o.r2.SEPARATOR]),n[i]=e}return n.map((t=>t??"")).join(s)}function p(t,e,s){const[n,i,a,l]=t.getHelmWrappers();return`${n}${r()(e).map((e=>{let n=e;return n=t.isGap(n)?u[o.r2.HELM]:s?n.replace(d,"$1"):1==e.length?`${i}${e}${a}`:`${i}[${e}]${a}`,n})).toArray().join(".")}${l}`}function y(t,e){const s=t.getSplitter()(e),n=new Array(s.length),i=e.startsWith("DNA"),o=e.startsWith("RNA");for(const[t,e]of r().enumerate(s)){let s=t;(i||o)&&(s=s.replace(d,"$1"),s="P"===s?null:s),n[e]=s}return n.filter((t=>null!==t))}},9298:(t,e,s)=>{"use strict";var n,i,r,o,a,l;s.d(e,{Ct:()=>l,DX:()=>n,ES:()=>i,dE:()=>a,iD:()=>o,vS:()=>h,vw:()=>r}),function(t){t.tooltipWebLogo=".tooltipWebLogo"}(n||(n={})),function(t){t.Entropy="Entropy",t.full="100%"}(i||(i={})),function(t){t.TOP="top",t.MIDDLE="middle",t.BOTTOM="bottom"}(r||(r={})),function(t){t.LEFT="left",t.CENTER="center",t.RIGHT="right"}(o||(o={})),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.startPositionName=null,this.endPositionName=null,this.skipEmptySequences=!0,this.skipEmptyPositions=!1,this.shrinkEmptyTail=!0,this.backgroundColor=4294967295,this.positionHeight=i.Entropy,this.positionWidth=16,this.verticalAlignment=r.MIDDLE,this.horizontalAlignment=o.CENTER,this.fixWidth=!1,this.fitArea=!0,this.minHeight=50,this.maxHeight=100,this.showPositionLabels=!0,this.positionMarginState=a.AUTO,this.positionMargin=0,this.filterSource=l.Filtered}}},2669:(t,e,s)=>{"use strict";s.d(e,{m:()=>n});class n{constructor(t=!0,e=!0){const n=navigator.hardwareConcurrency;this._workerCount=t?Math.max(n-2,1):1,this._workers=new Array(this._workerCount).fill(null).map((()=>new Worker(new URL(s.p+s.u(868),s.b)))),this._terminateOnComplete=e}async calc(t,e,s=!0){return new Promise((async(n,i)=>{try{const i=t.length,r=new Array(this._workerCount),o=i*(i-1)/2;this._workerCount=Math.min(this._workerCount,o);const a=o/this._workerCount,l=new Float32Array(o);let h=0,c=1,u=0,m=Number.MIN_VALUE;for(let s=0;s<this._workerCount;s++){const n=Math.floor(s*a),d=s===this._workerCount-1?o:Math.floor((s+1)*a),g=h,f=c;s!==this._workerCount-1&&(h=i-2-Math.floor(Math.sqrt(-8*d+4*i*(i-1)-7)/2-.5),c=d-i*h+Math.floor((h+1)*(h+2)/2)),this._workers[s].postMessage({values:t,fnName:e,startRow:g,startCol:f,chunckSize:d-n}),r[s]=new Promise(((t,e)=>{this._workers[s].onmessage=({data:{error:i,distanceMatrixData:r,min:o,max:a}})=>{this._terminateOnComplete&&this._workers[s].terminate(),i?e(i):(l.set(r,n),o<u&&(u=o),a>m&&(m=a),t())}}))}await Promise.all(r),s&&l.forEach(((t,e)=>{l[e]=(t-u)/(m-u)})),n(l)}catch(t){i(t)}}))}terminate(){this._workers.forEach((t=>t.terminate()))}}},3914:(t,e,s)=>{"use strict";s.d(e,{H:()=>i});var n=s(6814);class i{get data(){return this._data}get size(){return this._size}constructor(t,e){if(null==e){if(null==t)throw new Error("Arguments error: data or size is required.");if(this._data=t,this._size=(1+Math.sqrt(1+8*this._data.length))/2,this._size!=Math.floor(this._size))throw new Error(`Invalid data length ${this._data.length} leads to non integer size ${this._size}`)}else{this._size=e;const s=e*(e-1)/2;if(t){if(t.length!=s)throw new Error(`Invalid data length. Observations size ${e} requires data length ${s}.`);this._data=t}else this._data=new Float32Array(s)}}_linearizeIJ(t,e){if(!(t<e))throw new Error("i must be less than j");return this._size*t+e-Math.floor((t+2)*(t+1)/2)}get(t,e){return t==e?0:t<e?this._data[this._linearizeIJ(t,e)]:this._data[this._linearizeIJ(e,t)]}set(t,e,s){this._data[this._linearizeIJ(t,e)]=s}static calc(t,e){const s=t.length,r=new i(void 0,s);for(let i=0;i<s;i++)for(let o=i+1;o<s;o++)r.set(i,o,(0,n.k)(t[i])||(0,n.k)(t[o])?1:e(t[i],t[o]));return r}square(){for(let t=0;t<this._data.length;t++)this._data[t]=this._data[t]**2}add(t){if(this._size!==t._size)throw new Error(`Matrices must have the same size. This size: ${this._size}, other size: ${t._size}`);for(let e=0;e<this._data.length;e++)this._data[e]+=t._data[e]}sqrt(){for(let t=0;t<this._data.length;t++)this._data[t]=Math.sqrt(this._data[t])}normalize(){let t=0,e=this._data[0];for(let s=0;s<this._data.length;s++)this._data[s]<t&&(t=this._data[s]),this._data[s]>e&&(e=this._data[s]);const s=e-t;for(let n=0;n<this._data.length;n++)this._data[n]=0===s?this._data[n]-t:(this._data[n]-t)/(e-t)}}},6254:(t,e,s)=>{"use strict";function n(t,e){const s=i(e);function n(t,e){const n=Number(t),i=Number(e);return s(n,i)}const r={get:(t,s,i)=>"length"===s?e:new Proxy(t,function(t){return{get:(e,s,i)=>t===s?0:e[Number(t)>Number(s)?n(s,t):n(t,s)]}}(s))};return new Proxy(t,r)}function i(t){return(e,s)=>t*e+s-Math.floor((e+2)*(e+1)/2)}s.d(e,{_:()=>n,y:()=>i})},2590:(t,e,s)=>{"use strict";s.d(e,{_:()=>n});class n{constructor(){this._workerCount=Math.max(navigator.hardwareConcurrency-2,1),this._workers=new Array(this._workerCount).fill(null).map((()=>new Worker(new URL(s.p+s.u(381),s.b))))}async calc(t,e,s){const n=t.length*(t.length-1)/2,i=Math.floor(n/this._workerCount),r=new Array(this._workerCount);for(let o=0;o<this._workerCount;o++)r[o]=new Promise(((r,a)=>{const l=o*i,h=o===this._workerCount-1?n:(o+1)*i;this._workers[o].postMessage({values:t,startIdx:l,endIdx:h,threshold:s,fnName:e}),this._workers[o].onmessage=({data:{error:t,i:e,j:s,distance:n}})=>{t?a(t):(this._workers[o].terminate(),r({i:e,j:s,distance:n,idx:o}))}}));const o=await Promise.all(r),a=o.reduce(((t,e)=>t+e.i.length),0),l=new Int32Array(a),h=new Int32Array(a),c=new Float32Array(a);let u=0;for(const t of o)l.set(t.i,u),h.set(t.j,u),c.set(t.distance,u),u+=t.i.length;return{i:l,j:h,distance:c}}}},6814:(t,e,s)=>{"use strict";s.d(e,{k:()=>n});const n=t=>null==t},5697:(t,e,s)=>{"use strict";s.d(e,{Dz:()=>y,FV:()=>l,KR:()=>a,MI:()=>b,NB:()=>d,Om:()=>T,UX:()=>m,WI:()=>u,Zd:()=>c,_h:()=>h,aW:()=>f,bX:()=>S,fX:()=>w,kg:()=>r,s:()=>g,yU:()=>p});var n=s(9657),i=s(1040);i.gk.Tanimoto,i.gk.Dice,i.gk.Asymmetric,i.gk.BraunBlanquet,i.gk.Cosine,i.gk.Kulczynski,i.gk.McConnaughey,i.gk.RogotGoldberg,i.gk.Russel,i.gk.Sokal,i.gk.Hamming,i.gk.Euclidean,i.gk.Tanimoto,i.gk.Dice,i.gk.Asymmetric,i.gk.BraunBlanquet,i.gk.Cosine,i.gk.Kulczynski,i.gk.McConnaughey,i.gk.RogotGoldberg,i.gk.Russel,i.gk.Sokal,i.gk.Hamming,i.gk.Euclidean;const r=[i.gk.Tanimoto,i.gk.Dice,i.gk.Cosine];function o(t,e){const s=t.trueCount()+e.trueCount();if(0==s)return 1;const n=t.andWithCountBits(e,!0);return n/(s-n)}function a(t,e){return C(o(t,e))}function l(t,e){return C(o(new n.Z(t,32*t.length),new n.Z(e,32*e.length)))}function h(t,e){return C(function(t,e){const s=t.trueCount()+e.trueCount();return 0==s?0:2*t.andWithCountBits(e,!0)/s}(t,e))}function c(t,e){return C(function(t,e){const s=t.trueCount()*e.trueCount();return 0==s?0:t.andWithCountBits(e,!0)/Math.sqrt(s)}(t,e))}function u(t,e){return Math.sqrt(t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0))}function m(t,e){return t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0)}function d(t,e){return C(function(t,e){const s=t.trueCount()+e.trueCount(),n=t.andWithCountBits(e,!0);return n/(2*s-3*n)}(t,e))}function g(t,e){return C(function(t,e){const s=t.trueCount()+e.trueCount(),n=t.trueCount()*e.trueCount();return 0==n?0:t.andWithCountBits(e,!0)*s/(2*n)}(t,e))}function f(t,e){return C(function(t,e){const s=t.trueCount()+e.trueCount(),n=t.trueCount()*e.trueCount();return 0==n?0:(t.andWithCountBits(e,!0)*s-n)/n}(t,e))}function p(t,e){return C(function(t,e){const s=Math.min(t.trueCount(),e.trueCount());return 0==s?0:t.andWithCountBits(e,!0)/s}(t,e))}function y(t,e){return C(function(t,e){const s=Math.max(t.trueCount(),e.trueCount());return 0==s?0:t.andWithCountBits(e,!0)/s}(t,e))}function w(t,e){return C(function(t,e){return 0==t.length?0:t.andWithCountBits(e,!0)/t.length}(t,e))}function b(t,e){return C(function(t,e){const s=t.andWithCountBits(e,!0),n=t.countBits(!0)+e.countBits(!0),i=t.length,r=i-n+s;return s==i||r==i?1:s/n+r/(2*i-n)}(t,e))}function T(t){return 1/(1+t)}function C(t){return 0===t?3402823e32:1/t-1}function S(t,e){return Math.abs(t-e)}i.gk.Tanimoto,i.gk.Asymmetric,i.gk.Cosine,i.gk.Sokal},779:(t,e,s)=>{"use strict";function n(){return(t,e)=>{let s=0;t.length!==e.length&&(s=Math.abs(t.length-e.length));let n=0;for(let s=0;s<Math.min(t.length,e.length);s++)t[s]!==e[s]&&n++;return n+=s,n/=Math.max(t.length,e.length),n}}s.d(e,{j:()=>n})},489:(t,e,s)=>{"use strict";s.d(e,{U:()=>n.U,o:()=>n.o});var n=s(5540)},458:(t,e,s)=>{"use strict";s.d(e,{r:()=>i});var n=s(1811);function i(){return(t,e)=>(0,n.T)(t,e)/Math.max(t.length,e.length)}},5540:(t,e,s)=>{"use strict";s.d(e,{U:()=>n,o:()=>a});var n,i=s(779),r=s(458),o=s(6683);!function(t){t.HAMMING="Hamming",t.LEVENSHTEIN="Levenshtein",t.NEEDLEMANN_WUNSCH="Needlemann-Wunsch"}(n||(n={}));const a={[n.HAMMING]:i.j,[n.LEVENSHTEIN]:r.r,[n.NEEDLEMANN_WUNSCH]:o.n}},6683:(t,e,s)=>{"use strict";s.d(e,{n:()=>i});const n={gapOpen:8,gapExtend:2,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}};function i(t){return(e,s)=>{const{gapOpen:i,gapExtend:r,scoringMatrix:o,alphabetIndexes:a}={...n,...t},l=[new Array(e.length+1).fill(0),new Array(e.length+1).fill(0)],h=new Array(e.length+1).fill(!1),c=new Array(e.length+1).fill(!1);let u=0,m=1;for(let t=1;t<e.length+1;t++)l[0][t]=-i-(t-1)*r;for(let t=1;t<s.length+1;t++){l[m][0]=-i-(t-1)*r;for(let n=1;n<e.length+1;n++){const d=l[u][n-1]+o[a[e[n-1]]][a[s[t-1]]],g=l[u][n]-(h[n]?r:i),f=l[m][n-1]-(c[n-1]?r:i);l[m][n]=Math.max(d,f,g),l[m][n]===d?(h[n]=!1,c[n]=!1):l[m][n]===f?(h[n]=!1,c[n]=!0):(h[n]=!0,c[n]=!1)}u=m,m=(m+1)%2}const d=e.split("").map((t=>o[a[t]][a[t]])).reduce(((t,e)=>t+e),0),g=s.split("").map((t=>o[a[t]][a[t]])).reduce(((t,e)=>t+e),0),f=Math.max(d,g);return(f-l[u][e.length])/f}}},116:(t,e,s)=>{"use strict";var n;s.d(e,{AL:()=>n}),s(4221),s(7659),s(3659),s(850),s(9006),s(7861),s(9657),s(2669),s(3914),s(6254),s(2590),function(t){t.UMAP="UMAP",t.T_SNE="t-SNE"}(n||(n={}))},7656:(t,e,s)=>{"use strict";s.d(e,{I:()=>i});var n=s(850);async function i(t,e,i,r,o){const a=await async function(t,e,n,i){return new Promise((function(r,o){const a=new Worker(new URL(s.p+s.u(440),s.b));a.postMessage({columnData:t.data,method:e,measure:t.metric,options:n,parallelDistanceWorkers:i}),a.onmessage=({data:{error:t,distance:e,embedding:s}})=>{t?o(t):r({distance:e,embedding:s}),setTimeout((()=>a.terminate()),0)}}))}({data:t,metric:i},e,r,o);return a.embedding=a.embedding.map((t=>(0,n.Fv)(t))),a}},9006:(t,e,s)=>{"use strict";s.d(e,{Ek:()=>l,a1:()=>a,nR:()=>h});var n=s(850),i=s(4588),r=s(6254),o=s(2669);class a{constructor(t){this.steps=t?.steps??0,this.cycles=t?.cycles??1e6,this.cutoff=t?.cutoff??0,this.lambda=t?.lambda??2,this.dlambda=t?.dlambda??.01,this.lambda2=this.lambda/2,this.dlambda2=this.dlambda/2,this.epsilon=t?.epsilon??1e-10,this.distanceFunction=t?.distance??n.dP,this.distance=new Float32Array,this.distanceFunctionName=t?.distanceFunctionName}async initDistance(t){this.dmIndexFunct=(0,r.y)(t.length);const e=new o.m(!0,!1);this.distance=await e.calc(t,this.distanceFunctionName),e.terminate()}calcDistance(t,e,s){return this.distance[this.dmIndexFunct(e,s)]}async embed(t){const e=t.length,s=(0,n.kO)(e,a.dimension,40);let r=this.lambda2;0===this.steps&&(this.steps=t.length-1),await this.initDistance(t);for(let o=0;o<this.cycles;++o){for(let o=0;o<this.steps;++o){const o=(0,i.I)(e);let a=(0,i.I)(e);for(;o==a;)a=(0,i.I)(e);const l=s[o],h=s[a],c=this.calcDistance(t,o,a),u=(0,n.dP)(l,h);if(0==this.cutoff||c<=this.cutoff||u<c){const t=r*(c-u)/(u+this.epsilon),e=(0,n.On)(l,h,-1);s[o]=(0,n.On)(l,e,t),s[a]=(0,n.On)(h,e,-t)}}if(r-=this.dlambda2,r<=0)break}return s}}a.dimension=2;class l extends a{async embed(t){const e=t.length,s=(0,n.kO)(e,l.dimension,40);let r=this.lambda;await this.initDistance(t);for(let o=0;o<this.cycles;++o){const o=(0,i.I)(e),a=s[o];for(let i=0;i<e;++i){if(o==i)continue;const e=s[i],l=this.calcDistance(t,o,i),h=(0,n.dP)(a,e);if(0==this.cutoff||l<=this.cutoff||h<l){const t=r*(l-h)/(h+this.epsilon),o=(0,n.On)(a,e,-1);s[i]=(0,n.On)(e,o,-t)}}if(r-=this.dlambda,r<=0)break}return s}}class h extends a{constructor(t){super(t),this.cycles=t?.cycles??1e3,this.steps=t?.steps??1e5,this.radiusPercent=t?.radiusPercent??1,this.maxDistance=t?.maxDistance??null,this.maxDistanceSteps=t?.maxDistanceSteps??null}async embed(t){const e=t.length,s=(0,n.kO)(e,h.dimension,40);if(await this.initDistance(t),null===this.maxDistanceSteps&&(this.maxDistanceSteps=e*Math.floor((e-1)/2)),null===this.maxDistance){this.maxDistance=-1e37;for(let s=0;s<this.maxDistanceSteps;s++){const s=(0,i.I)(e);let n=(0,i.I)(e);for(;s==n;)n=(0,i.I)(e);const r=this.calcDistance(t,s,n);r>this.maxDistance&&(this.maxDistance=r)}}let r=this.lambda;const o=0==this.radiusPercent?this.maxDistance:this.maxDistance*this.radiusPercent;for(let a=0;a<this.cycles;++a){for(let a=0;a<this.steps;++a){const a=(0,i.I)(e);let l=(0,i.I)(e);for(;a==l;)l=(0,i.I)(e);const h=s[a],c=s[l],u=this.calcDistance(t,a,l),m=(0,n.dP)(h,c);if(u<=o||m<u){const t=.5*r*(u-m)/(m+this.epsilon),e=(0,n.On)(h,c,-1);s[a]=(0,n.On)(h,e,t),s[l]=(0,n.On)(c,e,-t)}}if(r-=(this.lambda-this.dlambda)/(this.cycles-1),r<this.dlambda)break}return s}}},1040:(t,e,s)=>{"use strict";var n,i,r,o,a,l;s.d(e,{CF:()=>i,Qe:()=>a,W:()=>n,Yc:()=>l,gd:()=>o,gk:()=>r}),function(t){t.Levenshtein="Levenshtein",t.JaroWinkler="Jaro-Winkler",t.Manhattan="Manhattan"}(n||(n={})),function(t){t.Euclidean="Euclidean"}(i||(i={})),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"}(r||(r={})),function(t){t.TanimotoIntArray="TanimotoIntArray"}(o||(o={})),function(t){t.Vector="Vector",t.String="String",t.BitArray="BitArray",t.MacroMolecule="MacroMolecule",t.Number="Number",t.IntArray="IntArray"}(a||(a={})),function(t){t.NumericDistance="NumericDistance"}(l||(l={}))},7861:(t,e,s)=>{"use strict";var n=s(1811),i=s(3979),r=s(5697),o=s(850),a=s(489),l=s(1040);const h={[l.CF.Euclidean]:o.dP},c={[l.W.Levenshtein]:n.T,[l.W.JaroWinkler]:i.H$,[l.W.Manhattan]:function(t,e){if(t.length!==e.length)return 1;{let s=0;for(let n=1;n<t.length;n++)s+=t[n]==e[n]?0:1;return s/t.length}}},u={[l.gk.Tanimoto]:r.KR,[l.gk.Dice]:r._h,[l.gk.Asymmetric]:r.yU,[l.gk.BraunBlanquet]:r.Dz,[l.gk.Cosine]:r.Zd,[l.gk.Kulczynski]:r.s,[l.gk.McConnaughey]:r.aW,[l.gk.RogotGoldberg]:r.MI,[l.gk.Russel]:r.fX,[l.gk.Sokal]:r.NB,[l.gk.Hamming]:r.UX,[l.gk.Euclidean]:r.WI},m={[l.gd.TanimotoIntArray]:r.FV},d={[l.Yc.NumericDistance]:r.bX},g={[l.Qe.Vector]:{[l.CF.Euclidean]:h[l.CF.Euclidean]},[l.Qe.String]:{[l.W.Levenshtein]:c[l.W.Levenshtein],[l.W.JaroWinkler]:c[l.W.JaroWinkler],[l.W.Manhattan]:c[l.W.Manhattan]},[l.Qe.BitArray]:{[l.gk.Tanimoto]:u[l.gk.Tanimoto],[l.gk.Dice]:u[l.gk.Dice],[l.gk.Asymmetric]:u[l.gk.Asymmetric],[l.gk.BraunBlanquet]:u[l.gk.BraunBlanquet],[l.gk.Cosine]:u[l.gk.Cosine],[l.gk.Kulczynski]:u[l.gk.Kulczynski],[l.gk.McConnaughey]:u[l.gk.McConnaughey],[l.gk.RogotGoldberg]:u[l.gk.RogotGoldberg],[l.gk.Russel]:u[l.gk.Russel],[l.gk.Sokal]:u[l.gk.Sokal]},[l.Qe.MacroMolecule]:{[a.U.HAMMING]:a.o[a.U.HAMMING],[a.U.LEVENSHTEIN]:a.o[a.U.LEVENSHTEIN],[a.U.NEEDLEMANN_WUNSCH]:a.o[a.U.NEEDLEMANN_WUNSCH]},[l.Qe.Number]:{[l.Yc.NumericDistance]:d[l.Yc.NumericDistance]},[l.Qe.IntArray]:{[l.gd.TanimotoIntArray]:m[l.gd.TanimotoIntArray]}};Object.keys(g).reduce(((t,e)=>{for(const s of Object.keys(g[e]))t[s]=e;return t}),{})},9657:(t,e,s)=>{"use strict";s.d(e,{Z:()=>n});class n{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 s=t,i=n._createBuffer(s);if(e)for(let t=0;t<i.length;t++)i[t]=-1;this._data=i,this._length=s}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,s,n){if(t<e||t>s)throw new Error(`Argument ${n} (${t}) out of range (${e}, ${s})`)}copy(t,e,s){for(let n=0;n<s;n++)e[n]=t[n]}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 s=new n(t._length);s._length=t._length,s._data=n._createBuffer(s._length),s._version=0;const i=t.lengthInInts;for(let n=0;n<i;n++)s._data[n]=t._data[n]&e._data[n];return s}static _createBuffer(t){return new Uint32Array(Math.floor((t+31)/32))}static fromValues(t){const e=new n(t.length);e._version=0;for(let s=0;s<e._length;s++)t[s]&&(e._data[Math.floor(s/32)]|=1<<(s%32&31));return e}static fromSeq(t,e){const s=new n(t);for(let n=0;n<t;++n)s.setBit(n,e(n));return s._version=0,s}static fromString(t){return n.fromSeq(t.length,(e=>"1"==t.charAt(e)))}static fromUint32Array(t,e){const s=new n(t);return s._data=e,s}static fromBytes(t){const e=t.length,s=new n(8*e);s._data=new Uint32Array(Math.floor((e+3)/4)),s._length=8*e;let i=0,r=0;for(;e-r>=4;)s._data[i++]=255&t[r]|(255&t[r+1])<<8|(255&t[r+2])<<16|(255&t[r+3])<<24,r+=4;return e-r==3&&(s._data[i]=(255&t[r+2])<<16),e-r==2&&(s._data[i]|=(255&t[r+1])<<8),e-r==1&&(s._data[i]|=255&t[r]),s._version=0,s}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 n(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 s=t?-1:0,n=this.lengthInInts;for(let t=0;t<n;t++)this._data[t]=s;this.incrementVersion(e)}setIndexes(t,e=!0,s=!0,n=!0){s&&this.setAll(!e,!1);for(const s of t)this.setFast(s,e);this.incrementVersion(n)}everyIndex(t,e=!0){for(const s of t)if(this.getBit(s)!=e)return!1;return!0}anyIndex(t,e=!0){for(const s of t)if(this.getBit(s)==e)return!0;return!1}setWhere(t,e=!0,s=!0,n=!0,i=!0){if(s&&i&&this.setAll(!e,!1),i)for(let s=0;s<this._length;s++)t(s)&&this.setFast(s,e);else for(let s=0;s<this._length;s++)this.setFast(s,t(s)?e:!e);this.incrementVersion(n)}getRange(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const s=[];for(let n=t;n<e;++n)s.push(this.getBit(n));return n.fromValues(s)}getRangeAsList(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const s=[];for(let n=t;n<e;++n)s.push(this.getBit(n));return s}setRange(t,e,s,n=!0){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length-1,"to");const i=Math.min(t,e),r=Math.max(t,e);if(s)for(let t=i;t<=r;t++)this.setTrue(t);else for(let t=i;t<=r;t++)this.setFalse(t);return this.incrementVersion(n),this}setRandom(t,e,s=!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 s=0;s<t;){const t=Math.floor(Math.random()*this._length);this.getBit(t)!=e&&(this.setFast(t,e),s++)}this.incrementVersion(s)}and(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,s=this.lengthInInts;e<s;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 s=this.lengthInInts;for(let e=0;e<s;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,s=this.lengthInInts;e<s;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,s=this.lengthInInts;e<s;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,s=this.lengthInInts;e<s;e++)this._data[e]^=t._data[e];return this.incrementVersion(e),this}insertAt(t,e,s=!1){if(this.assureInRange(t,0,this._length,"pos"),0==e)return;const n=this._length;this.setLength(this._length+e);for(let s=n-1;s>=t;s--)this.setBit(s+e,this.getBit(s));for(let n=t;n<t+e;n++)this.setBit(n,s)}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 s=t;s<this._length-e;s++)this.setBit(s,this.getBit(s+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 s=0;for(let n=-1;-1!=(n=t.findNext(n,!e));)this.setFast(s++,this.getBit(n));this._length=s,this._version++}return this}getBit(t){return 0!=(this._data[Math.floor(t/32)]&1<<(31&t))}setBit(t,e,s=!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+=n._onBitCount[255&t];let s=this._data[e];const i=31&this._length;for(0!=i&&(s&=~(4294967295<<i));0!=s;s>>>=8)this._selectedCount+=n._onBitCount[255&s];this._selectedCountVersion=this._version}return t?this._selectedCount:this._length-this._selectedCount}countWhere(t){let e=0;if(this.trueCount()==this._length)for(let s=0;s<this._length;s++)e+=t(s)?1:0;else for(let s=-1;-1!=(s=this.findNext(s,!0));)e+=t(s)?1:0;return e}andWithCountBits(t,e){if(0==this._length)return 0;let s=0;const i=this.lengthInInts;let r=0;for(;r<i-1;r++)for(let e=this._data[r]&t._data[r];0!=e;e>>>=8)s+=n._onBitCount[255&e];let o=this._data[r]&t._data[r];const a=31&this._length;for(0!=a&&(o&=~(4294967295<<a));0!=o;o>>>=8)s+=n._onBitCount[255&o];return e?s:this._length-s}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 s=31&(t=t<0?0:t+1);const i=this.lengthInInts;for(let r=Math.floor(t/32);r<i;r++){let i=e?this._data[r]:~this._data[r];if(0!=s)i&=4294967295<<s&4294967295,s=0;else if(!e&&-4294967296==i)continue;for(let e=0;0!=i;e+=8,i>>>=8){const s=n._firstOnBit[255&i];if(s>=0)return(t=s+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 s=1+(t=t<0?this._length-1:t-1)&31;for(let i=Math.floor(t/32);i>=0;i--){let t=e?this._data[i]:~this._data[i];0!=s&&(t&=~(4294967295<<s),s=0);for(let e=24;0!=t;e-=8,t<<=8){const s=n._lastOnBit[t>>>24];if(s>=0)return s+32*i+e}}return-1}}n._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]),n._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]),n._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])},4588:(t,e,s)=>{"use strict";function n(t){return Math.random()*t}function i(t){return Math.floor(n(t))}s.d(e,{I:()=>i,t:()=>n})},1061:(t,e,s)=>{"use strict";s.d(e,{AB:()=>P,Bu:()=>f,QK:()=>l,W3:()=>T,Wh:()=>w,X5:()=>S,bb:()=>C,ci:()=>v,f6:()=>b,gw:()=>M,jh:()=>y,l_:()=>p,ow:()=>N});var n=s(4469),i=s(976),r=function(t,e,s,n){return new(s||(s=Promise))((function(i,r){function o(t){try{l(n.next(t))}catch(t){r(t)}}function a(t){try{l(n.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(o,a)}l((n=n.apply(t,e||[])).next())}))};const o=3e4,a=108e5,l={},h="Auto Tests",c={};let u;var m;!function(t){t.notNull=function(t,e){if(null==t)throw new Error(`${null==e?"Value":e} not defined`)}}(m||(m={}));class d{constructor(t,e){this.catchUnhandled=!0,this.report=!1,void 0!==t&&(this.catchUnhandled=t),void 0!==e&&(this.report=e)}}class g{constructor(t,e,s,n){var i;this.category=t,this.name=e,null!=n||(n={}),null!==(i=n.timeout)&&void 0!==i||(n.timeout=o),this.options=n,this.test=()=>r(this,void 0,void 0,(function*(){return new Promise(((t,e)=>r(this,void 0,void 0,(function*(){let n="";try{n=yield s()}catch(t){e(t)}t(n)}))))}))}}function f(t,e,s){null==l[u]&&(l[u]={}),null==l[u].tests&&(l[u].tests=[]),l[u].tests.push(new g(u,t,e,s))}function p(t,e=!0,s){if(s=s?`${s}, `:"",t!==e)throw new Error(`${s}Expected "${e}", got "${t}"`)}function y(t,e,s=.001,n){if(t===Number.POSITIVE_INFINITY&&e===Number.POSITIVE_INFINITY||t===Number.NEGATIVE_INFINITY&&e===Number.NEGATIVE_INFINITY||t===Number.NaN&&e===Number.NaN||isNaN(t)&&isNaN(e))return;const i=Math.abs(t-e)<s;if(p(i,!0,`${null!=n?n:""} (tolerance = ${s})`),!i)throw new Error(`Expected ${e}, got ${t} (tolerance = ${s})`)}function w(t,e){for(const[s,n]of Object.entries(e)){if(!t.hasOwnProperty(s))throw new Error(`Expected property "${s}" not found`);const e=t[s];if(e instanceof Array&&n instanceof Array)b(e,n);else if(e instanceof Object&&n instanceof Object)w(e,n);else if(Number.isFinite(e)&&Number.isFinite(n))y(e,n);else if(e!=n)throw new Error(`Expected (${n}) for key '${s}', got (${e})`)}}function b(t,e){const s=t.length,n=e.length;if(s!=n)throw new Error(`Arrays are of different length: actual array length is ${s} and expected array length is ${n}`);for(let n=0;n<s;n++)if(t[n]instanceof Array&&e[n]instanceof Array)b(t[n],e[n]);else if(t[n]instanceof Object&&e[n]instanceof Object)w(t[n],e[n]);else if(t[n]!=e[n])throw new Error(`Expected ${e[n]} at position ${n}, got ${t[n]}`)}function T(t,e,s){var n;u=t,e(),l[u]&&(l[u].clear=null===(n=null==s?void 0:s.clear)||void 0===n||n,l[u].timeout=null==s?void 0:s.timeout)}function C(t){null==l[u]&&(l[u]={}),l[u].before=t}function S(t){null==l[u]&&(l[u]={}),l[u].after=t}function A(t,e){return t.replace(new RegExp(e.name,"gi"),e.nqName)}function v(t){var e,s,o,a,u;return r(this,void 0,void 0,(function*(){const m=null===(s=null===(e=n.functions.getCurrentCall())||void 0===e?void 0:e.func)||void 0===s?void 0:s.package;yield function(t,e){return r(this,void 0,void 0,(function*(){if(c[t])return;const e=l;if(void 0!==e[h]||Object.keys(e).find((t=>t.startsWith(h))))return void(c[t]=!0);const s=[],i=yield n.dapi.functions.filter(`package.id = "${t}"`).list(),o=new RegExp(/skip:\s*([^,\s]+)|wait:\s*(\d+)|cat:\s*([^,\s]+)/g);for(const t of i){const i=t.options.test;if(i&&Array.isArray(i)&&i.length)for(let a=0;a<i.length;a++){const l=i[a].matchAll(o),c={};Array.from(l).forEach((t=>{t[0].startsWith("skip")?c.skip=t[1]:t[0].startsWith("wait")?c.wait=parseInt(t[2]):t[0].startsWith("cat")&&(c.cat=t[3])}));const u=new g(h,1===i.length?t.name:`${t.name} ${a+1}`,(()=>r(this,void 0,void 0,(function*(){const e=yield n.functions.eval(A(i[a],t));if(c.wait&&(yield M(c.wait)),"boolean"==typeof e&&!e)throw`Failed: ${i[a]}, expected true, got ${e}`}))),{skipReason:c.skip});if(c.cat){const t=h+": "+c.cat;u.category=t,void 0===e[t]&&(e[t]={tests:[],clear:!0}),e[t].tests.push(u)}else s.push(u)}}c[t]=!0,s.length&&(e[h]={tests:s,clear:!0})}))}(m.id);const f=[];console.log("Running tests"),null!=t||(t={}),null!==(o=(u=t).testContext)&&void 0!==o||(u.testContext=new d),n.shell.lastError="";for(const[e,s]of Object.entries(l)){if(null!=(null==t?void 0:t.category)&&!e.toLowerCase().startsWith(null==t?void 0:t.category.toLowerCase()))continue;console.log(`Started ${e} category`);try{s.before&&(yield s.before())}catch(t){s.beforeStatus=t.toString()}const r=null!==(a=s.tests)&&void 0!==a?a:[],o=[];if(s.clear)for(let e=0;e<r.length;e++)o.push(yield E(r[e],null==t?void 0:t.test,s.timeout,m.name)),n.shell.closeAll(),i.Balloon.closeAll();else for(let e=0;e<r.length;e++)o.push(yield E(r[e],null==t?void 0:t.test,s.timeout,m.name));const l=(yield Promise.all(o)).filter((t=>"skipped"!=t.result));try{s.after&&(yield s.after())}catch(t){s.afterStatus=t.toString()}s.afterStatus&&l.push({category:e,name:"init",result:s.afterStatus,success:!1,ms:0,skipped:!1}),s.beforeStatus&&l.push({category:e,name:"init",result:s.beforeStatus,success:!1,ms:0,skipped:!1}),f.push(...l)}if(t.testContext.catchUnhandled&&(yield M(1e3),n.shell.lastError.length>0&&f.push({category:"Unhandled exceptions",name:"exceptions",result:n.shell.lastError,success:!1,ms:0,skipped:!1})),t.testContext.report){const t=new i.Logger,e=f.filter((t=>t.success)).length,s=f.filter((t=>t.skipped)).length,n=f.filter((t=>!t.success)),r="Package @package tested: @successful successful, @skipped skipped, @failed failed tests",o={successful:e,skipped:s,failed:n.length,package:m};for(const t of n)Object.assign(o,{[`${t.category} | ${t.name}`]:t.result});t.log(r,o,"package-tested")}return f}))}function E(t,e,s,l){var h,c,u,m,d;return r(this,void 0,void 0,(function*(){let r;const g=null!=e&&t.name.toLowerCase()!==e.toLowerCase(),f=(null===(h=t.options)||void 0===h?void 0:h.skipReason)||g,p=g?"skipped":null===(c=t.options)||void 0===c?void 0:c.skipReason;f||console.log(`Started ${t.category} ${t.name}`);const y=new Date;try{if(f)r={success:!0,result:p,ms:0,skipped:!0};else{let e=(null===(u=t.options)||void 0===u?void 0:u.timeout)===o&&s?s:null===(m=t.options)||void 0===m?void 0:m.timeout;e=i.Test.isInBenchmark&&e===o?a:e,r={success:!0,result:null!==(d=yield _(t.test,e))&&void 0!==d?d:"OK",ms:0,skipped:!1}}}catch(t){r={success:!1,result:t.toString(),ms:0,skipped:!1}}const w=new Date;if(r.ms=w-y,f||console.log(`Finished ${t.category} ${t.name} for ${r.ms} ms`),r.category=t.category,r.name=t.name,!g){let e={success:r.success,result:r.result,ms:r.ms,skipped:r.skipped,type:"package",packageName:l,category:t.category,test:t.name};if(r.result.constructor==Object){const t=Object.keys(r.result).reduce(((t,e)=>Object.assign(Object.assign({},t),{["result."+e]:r.result[e]})),{});e=Object.assign(Object.assign({},e),t)}n.log.usage(`${l}: ${t.category}: ${t.name}`,e,`test-package ${l}: ${t.category}: ${t.name}`)}return r}))}function M(t){return r(this,void 0,void 0,(function*(){yield new Promise((e=>setTimeout(e,t)))}))}function N(t,e="Timeout exceeded",s=500,n=50){return r(this,void 0,void 0,(function*(){return new Promise(((i,r)=>{setTimeout((()=>{clearInterval(o),r(new Error(e))}),s);const o=setInterval((()=>{t()&&(clearInterval(o),i())}),n)}))}))}function _(t,e){return r(this,void 0,void 0,(function*(){let s=null;const n=new Promise(((t,n)=>{s=setTimeout((()=>{n("EXECUTION TIMEOUT")}),e)}));try{return yield Promise.race([t(),n])}finally{s&&clearTimeout(s)}}))}function P(t,e,s){var o;return r(this,void 0,void 0,(function*(){(null==s?void 0:s.detectSemanticTypes)&&(yield n.data.detectSemanticTypes(e));const r=n.shell.addTableView(e),a=`[name=viewer-${t.replace(/\s+/g,"-")} i]`;let l=`${a} canvas,${a} svg,${a} img,\n ${a} input,${a} h1,${a} a`;const h=[];try{let n=r.addViewer(t);yield N((()=>null!==document.querySelector(l)),"cannot load viewer",3e3);const i=null===(o=document.querySelector(l))||void 0===o?void 0:o.tagName;if(h.push(Array.from(r.viewers).length),!(null==s?void 0:s.readOnly)){Array.from(e.row(0).cells).forEach((t=>t.value=null));const t=e.rowCount<20?Math.floor(e.rowCount/2):10;e.rows.select((e=>e.idx>=0&&e.idx<t)),yield M(50);for(let s=t;s<2*t;s++)e.filter.set(s,!1);yield M(50),e.currentRowIdx=1;const s=e.clone();e.columns.names().slice(0,Math.ceil(e.columns.length/2)).forEach((t=>e.columns.remove(t))),yield M(100),r.dataFrame=s}const c=n.getOptions(!0).look,u=n.getProperties(),m={};Object.keys(c).filter((t=>"boolean"==typeof c[t])).forEach((t=>m[t]=!c[t])),u.filter((t=>null!==t.choices)).forEach((t=>m[t.name]=t.choices.find((e=>e!==c[t.name])))),n.setOptions(m),yield M(300);const d=r.saveLayout(),g=n.getOptions().look;r.resetLayout(),h.push(Array.from(r.viewers).length),r.loadLayout(d),l=`${a} ${i}`,yield N((()=>null!==document.querySelector(l)),"cannot load viewer from layout",3e3),h.push(Array.from(r.viewers).length),n=Array.from(r.viewers).find((t=>"Grid"!==t.type)),b(h,[2,1,2]),p(JSON.stringify(n.getOptions().look),JSON.stringify(g))}finally{r.close(),n.shell.closeTable(e),i.Balloon.closeAll()}}))}},3659:(t,e,s)=>{"use strict";s.d(e,{OW:()=>n});class n extends Float32Array{}},850:(t,e,s)=>{"use strict";s.d(e,{$G:()=>a,Fv:()=>u,MA:()=>l,On:()=>o,dP:()=>c,hu:()=>r,kO:()=>h});var n=s(3659),i=s(4588);function r(t=!1,e="Assertion error."){if(!t)throw new Error(e)}function o(t,e,s=1){const i=t.length;r(i==e.length,"Vector lengths do not match.");const o=new n.OW(i);for(let n=0;n<t.length;++n)o[n]=t[n]+s*e[n];return o}function a(t){let e=0;for(let s=0;s<t.length;s++)e+=t[s]*t[s];return Math.sqrt(e)}function l(t,e){if(t.length!=e.length)throw new Error("The dimensionality of the vectors must match");let s=0;for(let n=0;n<t.length;n++)s+=t[n]*e[n];return s}function h(t,e,s=1){const r=function(t,e,s=0){return new Array(t).fill(s).map((()=>new n.OW(e).fill(s)))}(t,e);for(let n=0;n<t;++n)for(let t=0;t<e;++t)r[n][t]=(0,i.t)(s);return r}function c(t,e){const s=function(t){let e=0;for(let s=0;s<t.length;++s)e+=t[s];return e}(function(t){const e=t.length,s=new n.OW(e);for(let e=0;e<t.length;++e)s[e]=t[e]*t[e];return s}(o(t,e,-1)));return Math.sqrt(s)}function u(t){let e=0,s=0;for(let s=0;s<t.length;++s)e+=t[s];e/=t.length;for(let n=0;n<t.length;++n)s+=(t[n]-e)*(t[n]-e);s=Math.sqrt(s/t.length);for(let n=0;n<t.length;++n)t[n]=(t[n]-e)/s;return t}},7659:(t,e,s)=>{"use strict";e.Z=void 0;var n=s(6215);Object.defineProperty(e,"Z",{enumerable:!0,get:function(){return n.TSNE}})},6215:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TSNE=void 0,e.TSNE=class{constructor(t){this.returnV=!1,this.vValue=0,this.iter=0,t=t||{},this.perplexity=this.getopt(t,"perplexity",30),this.dim=this.getopt(t,"dim",2),this.epsilon=this.getopt(t,"epsilon",10)}assert(t,e){if(!t)throw e||"Assertion failed"}getopt(t,e,s){return t.hasOwnProperty(e)?t[e]:s}gaussRandom(){if(this.returnV)return this.returnV=!1,this.vValue;const t=2*Math.random()-1,e=2*Math.random()-1,s=t*t+e*e;if(0===s||s>1)return this.gaussRandom();const n=Math.sqrt(-2*Math.log(s)/s);return this.vValue=e*n,this.returnV=!0,t*n}randn(t,e){return t+this.gaussRandom()*e}zeros(t){if(void 0===t||isNaN(t))return[];if("undefined"==typeof ArrayBuffer){const e=new Array(t);for(let s=0;s<t;s++)e[s]=0;return e}return new Float64Array(t)}randn2d(t,e,s){const n=void 0!==s,i=[];for(let r=0;r<t;r++){const t=[];for(let i=0;i<e;i++)n?t.push(s):t.push(this.randn(0,1e-4));i.push(t)}return i}L2(t,e){const s=t.length;let n=0;for(let i=0;i<s;i++){const s=t[i],r=e[i];n+=(s-r)*(s-r)}return n}xtod(t){const e=t.length,s=this.zeros(e*e);for(let n=0;n<e;n++)for(let i=n+1;i<e;i++){const r=this.L2(t[n],t[i]);s[n*e+i]=r,s[i*e+n]=r}return s}d2p(t,e,s){const n=Math.sqrt(t.length),i=Math.floor(n);this.assert(i===n,"D should have square number of elements.");const r=Math.log(e),o=this.zeros(i*i),a=this.zeros(i);for(let e=0;e<i;e++){let n=-1/0,l=1/0,h=1,c=!1;const u=50;let m=0;for(;!c;){let o=0;for(let s=0;s<i;s++){let n=Math.exp(-t[e*i+s]*h);e===s&&(n=0),a[s]=n,o+=n}let d=0;for(let t=0;t<i;t++){let e;e=0===o?0:a[t]/o,a[t]=e,e>1e-7&&(d-=e*Math.log(e))}d>r?(n=h,l===1/0?h*=2:h=(h+l)/2):(l=h,n===-1/0?h/=2:h=(h+n)/2),m++,Math.abs(d-r)<s&&(c=!0),m>=u&&(c=!0)}for(let t=0;t<i;t++)o[e*i+t]=a[t]}const l=this.zeros(i*i),h=2*i;for(let t=0;t<i;t++)for(let e=0;e<i;e++)l[t*i+e]=Math.max((o[t*i+e]+o[e*i+t])/h,1e-100);return l}sign(t){return t>0?1:t<0?-1:0}initDataRaw(t){const e=t.length,s=t[0].length;this.assert(e>0," X is empty? You must have some data!"),this.assert(s>0," X[0] is empty? Where is the data?");const n=this.xtod(t);this.P=this.d2p(n,this.perplexity,1e-4),this.N=e,this.initSolution()}initDataDist(t){const e=t.length;this.assert(e>0," X is empty? You must have some data!");const s=this.zeros(e*e);for(let n=0;n<e;n++)for(let i=n+1;i<e;i++){const r=t[n][i];s[n*e+i]=r,s[i*e+n]=r}this.P=this.d2p(s,this.perplexity,1e-4),this.N=e,this.initSolution()}initSolution(){this.Y=this.randn2d(this.N,this.dim),this.gains=this.randn2d(this.N,this.dim,1),this.ystep=this.randn2d(this.N,this.dim,0),this.iter=0}getSolution(){return this.Y}step(){this.iter+=1;const t=this.N,e=this.costGrad(this.Y),s=e.cost,n=e.grad,i=this.zeros(this.dim);for(let e=0;e<t;e++)for(let t=0;t<this.dim;t++){const s=n[e][t],r=this.ystep[e][t],o=this.gains[e][t];let a=this.sign(s)===this.sign(r)?.8*o:o+.2;a<.01&&(a=.01),this.gains[e][t]=a;const l=(this.iter<250?.5:.8)*r-this.epsilon*a*n[e][t];this.ystep[e][t]=l,this.Y[e][t]+=l,i[t]+=this.Y[e][t]}for(let e=0;e<t;e++)for(let s=0;s<this.dim;s++)this.Y[e][s]-=i[s]/t;return s}debugGrad(){const t=this.N,e=this.costGrad(this.Y),s=(e.cost,e.grad),n=1e-5;for(let e=0;e<t;e++)for(let t=0;t<this.dim;t++){const i=this.Y[e][t];this.Y[e][t]=i+n;const r=this.costGrad(this.Y);this.Y[e][t]=i-n;const o=this.costGrad(this.Y),a=s[e][t],l=(r.cost-o.cost)/(2*n);console.log(e+","+t+": gradcheck analytic: "+a+" vs. numerical: "+l),this.Y[e][t]=i}}costGrad(t){const e=this.N,s=this.dim,n=this.P,i=this.iter<100?4:1,r=this.zeros(e*e);let o=0;for(let n=0;n<e;n++)for(let i=n+1;i<e;i++){let a=0;for(let e=0;e<s;e++){const s=t[n][e]-t[i][e];a+=s*s}const l=1/(1+a);r[n*e+i]=l,r[i*e+n]=l,o+=2*l}const a=e*e,l=this.zeros(a);for(let t=0;t<a;t++)l[t]=Math.max(r[t]/o,1e-100);let h=0;const c=[];for(let o=0;o<e;o++){const a=new Array(s);for(let t=0;t<s;t++)a[t]=0;for(let c=0;c<e;c++){h+=-n[o*e+c]*Math.log(l[o*e+c]);const u=4*(i*n[o*e+c]-l[o*e+c])*r[o*e+c];for(let e=0;e<s;e++)a[e]+=u*(t[o][e]-t[c][e])}c.push(a)}return{cost:h,grad:c}}}},5362:(t,e,s)=>{"use strict";s.d(e,{Z:()=>a});var n=s(7537),i=s.n(n),r=s(3645),o=s.n(r)()(i());o.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=o},9564:(t,e,s)=>{"use strict";s.d(e,{Z:()=>a});var n=s(7537),i=s.n(n),r=s(3645),o=s.n(r)()(i());o.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=o},9414:(t,e,s)=>{"use strict";s.d(e,{Z:()=>a});var n=s(7537),i=s.n(n),r=s(3645),o=s.n(r)()(i());o.push([t.id,".scatter_plot_link {\n position: absolute!important;\n right: 10px;\n}\n\n.cliffs_grid {\n top: 10px;\n}\n\n.show_only_cliffs {\n top: 30px;\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","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/ml/css/styles.css"],names:[],mappings:"AAAA;IACI,4BAA4B;IAC5B,WAAW;AACf;;AAEA;IACI,SAAS;AACb;;AAEA;IACI,SAAS;AACb;;AAEA;IACI,eAAe;IACf,kBAAkB;IAClB,YAAY;AAChB",sourcesContent:[".scatter_plot_link {\n position: absolute!important;\n right: 10px;\n}\n\n.cliffs_grid {\n top: 10px;\n}\n\n.show_only_cliffs {\n top: 30px;\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"],sourceRoot:""}]);const a=o},3645:t=>{"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var s="",n=void 0!==e[5];return e[4]&&(s+="@supports (".concat(e[4],") {")),e[2]&&(s+="@media ".concat(e[2]," {")),n&&(s+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),s+=t(e),n&&(s+="}"),e[2]&&(s+="}"),e[4]&&(s+="}"),s})).join("")},e.i=function(t,s,n,i,r){"string"==typeof t&&(t=[[null,t,void 0]]);var o={};if(n)for(var a=0;a<this.length;a++){var l=this[a][0];null!=l&&(o[l]=!0)}for(var h=0;h<t.length;h++){var c=[].concat(t[h]);n&&o[c[0]]||(void 0!==r&&(void 0===c[5]||(c[1]="@layer".concat(c[5].length>0?" ".concat(c[5]):""," {").concat(c[1],"}")),c[5]=r),s&&(c[2]?(c[1]="@media ".concat(c[2]," {").concat(c[1],"}"),c[2]=s):c[2]=s),i&&(c[4]?(c[1]="@supports (".concat(c[4],") {").concat(c[1],"}"),c[4]=i):c[4]="".concat(i)),e.push(c))}},e}},7537:t=>{"use strict";t.exports=function(t){var e=t[1],s=t[3];if(!s)return e;if("function"==typeof btoa){var n=btoa(unescape(encodeURIComponent(JSON.stringify(s)))),i="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(n),r="/*# ".concat(i," */");return[e].concat([r]).join("\n")}return[e].join("\n")}},9133:function(t,e,s){var n;!function(e,i){var r={};!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 s(t,s,n,i,r){for(var o,a,l,h,c,u,m,d,g,f,p,y,w;r>=64;){for(o=s[0],a=s[1],l=s[2],h=s[3],c=s[4],u=s[5],m=s[6],d=s[7],f=0;f<16;f++)p=i+4*f,t[f]=(255&n[p])<<24|(255&n[p+1])<<16|(255&n[p+2])<<8|255&n[p+3];for(f=16;f<64;f++)y=((g=t[f-2])>>>17|g<<15)^(g>>>19|g<<13)^g>>>10,w=((g=t[f-15])>>>7|g<<25)^(g>>>18|g<<14)^g>>>3,t[f]=(y+t[f-7]|0)+(w+t[f-16]|0);for(f=0;f<64;f++)y=(((c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7))+(c&u^~c&m)|0)+(d+(e[f]+t[f]|0)|0)|0,w=((o>>>2|o<<30)^(o>>>13|o<<19)^(o>>>22|o<<10))+(o&a^o&l^a&l)|0,d=m,m=u,u=c,c=h+y|0,h=l,l=a,a=o,o=y+w|0;s[0]+=o,s[1]+=a,s[2]+=l,s[3]+=h,s[4]+=c,s[5]+=u,s[6]+=m,s[7]+=d,i+=64,r-=64}return i}var n=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 n=0;if(this.bytesHashed+=e,this.bufferLength>0){for(;this.bufferLength<64&&e>0;)this.buffer[this.bufferLength++]=t[n++],e--;64===this.bufferLength&&(s(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(e>=64&&(n=s(this.temp,this.state,t,n,e),e%=64);e>0;)this.buffer[this.bufferLength++]=t[n++],e--;return this},e.prototype.finish=function(t){if(!this.finished){var e=this.bytesHashed,n=this.bufferLength,i=e/536870912|0,r=e<<3,o=e%64<56?64:128;this.buffer[n]=128;for(var a=n+1;a<o-8;a++)this.buffer[a]=0;this.buffer[o-8]=i>>>24&255,this.buffer[o-7]=i>>>16&255,this.buffer[o-6]=i>>>8&255,this.buffer[o-5]=i>>>0&255,this.buffer[o-4]=r>>>24&255,this.buffer[o-3]=r>>>16&255,this.buffer[o-2]=r>>>8&255,this.buffer[o-1]=r>>>0&255,s(this.temp,this.state,this.buffer,0,o),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 s=0;s<this.state.length;s++)this.state[s]=t[s];this.bytesHashed=e,this.finished=!1,this.bufferLength=0},e}();t.Hash=n;var i=function(){function t(t){this.inner=new n,this.outer=new n,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var e=new Uint8Array(this.blockSize);if(t.length>this.blockSize)(new n).update(t).finish(e).clean();else for(var s=0;s<t.length;s++)e[s]=t[s];for(s=0;s<e.length;s++)e[s]^=54;for(this.inner.update(e),s=0;s<e.length;s++)e[s]^=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),s=0;s<e.length;s++)e[s]=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 n).update(t),s=e.digest();return e.clean(),s}function o(t,e){var s=new i(t).update(e),n=s.digest();return s.clean(),n}function a(t,e,s,n){var i=n[0];if(0===i)throw new Error("hkdf: cannot expand more");e.reset(),i>1&&e.update(t),s&&e.update(s),e.update(n),e.finish(t),n[0]++}t.HMAC=i,t.hash=r,t.default=r,t.hmac=o;var l=new Uint8Array(t.digestLength);t.hkdf=function(t,e,s,n){void 0===e&&(e=l),void 0===n&&(n=32);for(var r=new Uint8Array([1]),h=o(e,t),c=new i(h),u=new Uint8Array(c.digestLength),m=u.length,d=new Uint8Array(n),g=0;g<n;g++)m===u.length&&(a(u,c,s,r),m=0),d[g]=u[m++];return c.clean(),u.fill(0),r.fill(0),d},t.pbkdf2=function(t,e,s,n){for(var r=new i(t),o=r.digestLength,a=new Uint8Array(4),l=new Uint8Array(o),h=new Uint8Array(o),c=new Uint8Array(n),u=0;u*o<n;u++){var m=u+1;a[0]=m>>>24&255,a[1]=m>>>16&255,a[2]=m>>>8&255,a[3]=m>>>0&255,r.reset(),r.update(e),r.update(a),r.finish(h);for(var d=0;d<o;d++)l[d]=h[d];for(d=2;d<=s;d++){r.reset(),r.update(h).finish(h);for(var g=0;g<o;g++)l[g]^=h[g]}for(d=0;d<o&&u*o+d<n;d++)c[u*o+d]=l[d]}for(u=0;u<o;u++)l[u]=h[u]=0;for(u=0;u<4;u++)a[u]=0;return r.clean(),c}}(r);var o=r.default;for(var a in r)o[a]=r[a];"object"==typeof t.exports?t.exports=o:void 0===(n=function(){return o}.call(r,s,r,t))||(t.exports=n)}()},1811:(t,e,s)=>{"use strict";s.d(e,{T:()=>i});const n=new Uint32Array(65536),i=(t,e)=>{if(t.length<e.length){const s=e;e=t,t=s}return 0===e.length?t.length:t.length<=32?((t,e)=>{const s=t.length,i=e.length,r=1<<s-1;let o=-1,a=0,l=s,h=s;for(;h--;)n[t.charCodeAt(h)]|=1<<h;for(h=0;h<i;h++){let t=n[e.charCodeAt(h)];const s=t|a;t|=(t&o)+o^o,a|=~(t|o),o&=t,a&r&&l++,o&r&&l--,a=a<<1|1,o=o<<1|~(s|a),a&=s}for(h=s;h--;)n[t.charCodeAt(h)]=0;return l})(t,e):((t,e)=>{const s=e.length,i=t.length,r=[],o=[],a=Math.ceil(s/32),l=Math.ceil(i/32);for(let t=0;t<a;t++)o[t]=-1,r[t]=0;let h=0;for(;h<l-1;h++){let a=0,l=-1;const c=32*h,u=Math.min(32,i)+c;for(let e=c;e<u;e++)n[t.charCodeAt(e)]|=1<<e;for(let t=0;t<s;t++){const s=n[e.charCodeAt(t)],i=o[t/32|0]>>>t&1,h=r[t/32|0]>>>t&1,c=s|a,u=((s|h)&l)+l^l|s|h;let m=a|~(u|l),d=l&u;m>>>31^i&&(o[t/32|0]^=1<<t),d>>>31^h&&(r[t/32|0]^=1<<t),m=m<<1|i,d=d<<1|h,l=d|~(c|m),a=m&c}for(let e=c;e<u;e++)n[t.charCodeAt(e)]=0}let c=0,u=-1;const m=32*h,d=Math.min(32,i-m)+m;for(let e=m;e<d;e++)n[t.charCodeAt(e)]|=1<<e;let g=i;for(let t=0;t<s;t++){const s=n[e.charCodeAt(t)],a=o[t/32|0]>>>t&1,l=r[t/32|0]>>>t&1,h=s|c,m=((s|l)&u)+u^u|s|l;let d=c|~(m|u),f=u&m;g+=d>>>i-1&1,g-=f>>>i-1&1,d>>>31^a&&(o[t/32|0]^=1<<t),f>>>31^l&&(r[t/32|0]^=1<<t),d=d<<1|a,f=f<<1|l,u=f|~(h|d),c=d&h}for(let e=m;e<d;e++)n[t.charCodeAt(e)]=0;return g})(t,e)}},3979:(t,e)=>{"use strict";e.H$=void 0,e.H$=function(t,e,s){var n=function(t,e,s){if(0===t.length||0===e.length)return 0;if(s&&!s.caseSensitive&&(t=t.toUpperCase(),e=e.toUpperCase()),t===e)return 1;for(var n=0,i=t.length,r=e.length,o=Math.floor(Math.max(i,r)/2)-1,a=new Array(i),l=new Array(r),h=0;h<i;h++)for(var c=Math.max(0,h-o);c<=Math.min(r,h+o+1);c++)if(!a[h]&&!l[c]&&t[h]===e[c]){++n,a[h]=l[c]=!0;break}if(0===n)return 0;var u=0,m=0;for(h=0;h<i;h++)if(a[h]){for(;!l[m];)m++;t.charAt(h)!==e.charAt(m++)&&u++}return(n/i+n/r+(n-(u/=2))/n)/3}(t,e,s),i=0;if(n>.7){for(var r=Math.min(t.length,e.length),o=0;t[o]===e[o]&&o<4&&o<r;)++i,o++;n+=.1*i*(1-n)}return n}},9251:(t,e,s)=>{"use strict";s.r(e),s.d(e,{default:()=>F});const n=Object.prototype.toString;function i(t){return n.call(t).endsWith("Array]")}function r(t,e,s){let n=0;const i=s(e);for(let e=0;e<t.x.length;e++)n+=Math.abs(t.y[e]-i(t.x[e]));return n}const o=Object.prototype.toString;function a(t){return o.call(t).endsWith("Array]")}const l=Object.prototype.toString;function h(t){return l.call(t).endsWith("Array]")}const c=Object.prototype.toString;const u=Object.prototype.toString;function m(t){var e,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!h(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");if(void 0!==s.output){if(!h(s.output))throw new TypeError("output option must be an array if specified");e=s.output}else e=new Array(t.length);var n=function(t){var e,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e=t,!u.call(e).endsWith("Array]"))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var n=s.fromIndex,i=void 0===n?0:n,r=s.toIndex,o=void 0===r?t.length:r;if(i<0||i>=t.length||!Number.isInteger(i))throw new Error("fromIndex must be a positive integer smaller than length");if(o<=i||o>t.length||!Number.isInteger(o))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[i],l=i+1;l<o;l++)t[l]<a&&(a=t[l]);return a}(t),i=function(t){var e,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e=t,!c.call(e).endsWith("Array]"))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var n=s.fromIndex,i=void 0===n?0:n,r=s.toIndex,o=void 0===r?t.length:r;if(i<0||i>=t.length||!Number.isInteger(i))throw new Error("fromIndex must be a positive integer smaller than length");if(o<=i||o>t.length||!Number.isInteger(o))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[i],l=i+1;l<o;l++)t[l]>a&&(a=t[l]);return a}(t);if(n===i)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var r=s.min,o=void 0===r?s.autoMinMax?n:0:r,a=s.max,l=void 0===a?s.autoMinMax?i:1:a;if(o>=l)throw new RangeError("min option must be smaller than max option");for(var m=(l-o)/(i-n),d=0;d<t.length;d++)e[d]=(t[d]-n)*m+o;return e}const d=" ".repeat(2),g=" ".repeat(4);function f(t,e={}){const{maxRows:s=15,maxColumns:n=10,maxNumSize:i=8,padMinus:r="auto"}=e;return`${t.constructor.name} {\n${d}[\n${g}${function(t,e,s,n,i){const{rows:r,columns:o}=t,a=Math.min(r,e),l=Math.min(o,s),h=[];if("auto"===i){i=!1;t:for(let e=0;e<a;e++)for(let s=0;s<l;s++)if(t.get(e,s)<0){i=!0;break t}}for(let e=0;e<a;e++){let s=[];for(let r=0;r<l;r++)s.push(p(t.get(e,r),n,i));h.push(`${s.join(" ")}`)}return l!==o&&(h[h.length-1]+=` ... ${o-s} more columns`),a!==r&&h.push(`... ${r-e} more rows`),h.join(`\n${g}`)}(t,s,n,i,r)}\n${d}]\n${d}rows: ${t.rows}\n${d}columns: ${t.columns}\n}`}function p(t,e,s){return(t>=0&&s?` ${y(t,e-1)}`:y(t,e)).padEnd(e)}function y(t,e){let s=t.toString();if(s.length<=e)return s;let n=t.toFixed(e);if(n.length>e&&(n=t.toFixed(Math.max(0,e-(n.length-e)))),n.length<=e&&!n.startsWith("0.000")&&!n.startsWith("-0.000"))return n;let i=t.toExponential(e);return i.length>e&&(i=t.toExponential(Math.max(0,e-(i.length-e)))),i.slice(0)}function w(t,e,s){let n=s?t.rows:t.rows-1;if(e<0||e>n)throw new RangeError("Row index out of range")}function b(t,e,s){let n=s?t.columns:t.columns-1;if(e<0||e>n)throw new RangeError("Column index out of range")}function T(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.columns)throw new RangeError("vector size must be the same as the number of columns");return e}function C(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.rows)throw new RangeError("vector size must be the same as the number of rows");return e}function S(t,e,s,n,i){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(v("startRow",e),v("endRow",s),v("startColumn",n),v("endColumn",i),e>s||n>i||e<0||e>=t.rows||s<0||s>=t.rows||n<0||n>=t.columns||i<0||i>=t.columns)throw new RangeError("Submatrix indices are out of range")}function A(t,e=0){let s=[];for(let n=0;n<t;n++)s.push(e);return s}function v(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function E(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class M{static from1DArray(t,e,s){if(t*e!==s.length)throw new RangeError("data length does not match given dimensions");let n=new _(t,e);for(let i=0;i<t;i++)for(let t=0;t<e;t++)n.set(i,t,s[i*e+t]);return n}static rowVector(t){let e=new _(1,t.length);for(let s=0;s<t.length;s++)e.set(0,s,t[s]);return e}static columnVector(t){let e=new _(t.length,1);for(let s=0;s<t.length;s++)e.set(s,0,t[s]);return e}static zeros(t,e){return new _(t,e)}static ones(t,e){return new _(t,e).fill(1)}static rand(t,e,s={}){if("object"!=typeof s)throw new TypeError("options must be an object");const{random:n=Math.random}=s;let i=new _(t,e);for(let s=0;s<t;s++)for(let t=0;t<e;t++)i.set(s,t,n());return i}static randInt(t,e,s={}){if("object"!=typeof s)throw new TypeError("options must be an object");const{min:n=0,max:i=1e3,random:r=Math.random}=s;if(!Number.isInteger(n))throw new TypeError("min must be an integer");if(!Number.isInteger(i))throw new TypeError("max must be an integer");if(n>=i)throw new RangeError("min must be smaller than max");let o=i-n,a=new _(t,e);for(let s=0;s<t;s++)for(let t=0;t<e;t++){let e=n+Math.round(r()*o);a.set(s,t,e)}return a}static eye(t,e,s){void 0===e&&(e=t),void 0===s&&(s=1);let n=Math.min(t,e),i=this.zeros(t,e);for(let t=0;t<n;t++)i.set(t,t,s);return i}static diag(t,e,s){let n=t.length;void 0===e&&(e=n),void 0===s&&(s=e);let i=Math.min(n,e,s),r=this.zeros(e,s);for(let e=0;e<i;e++)r.set(e,e,t[e]);return r}static min(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let s=t.rows,n=t.columns,i=new _(s,n);for(let r=0;r<s;r++)for(let s=0;s<n;s++)i.set(r,s,Math.min(t.get(r,s),e.get(r,s)));return i}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let s=t.rows,n=t.columns,i=new this(s,n);for(let r=0;r<s;r++)for(let s=0;s<n;s++)i.set(r,s,Math.max(t.get(r,s),e.get(r,s)));return i}static checkMatrix(t){return M.isMatrix(t)?t:new _(t)}static isMatrix(t){return null!=t&&"Matrix"===t.klass}get size(){return this.rows*this.columns}apply(t){if("function"!=typeof t)throw new TypeError("callback must be a function");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)t.call(this,e,s);return this}to1DArray(){let t=[];for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)t.push(this.get(e,s));return t}to2DArray(){let t=[];for(let e=0;e<this.rows;e++){t.push([]);for(let s=0;s<this.columns;s++)t[e].push(this.get(e,s))}return t}toJSON(){return this.to2DArray()}isRowVector(){return 1===this.rows}isColumnVector(){return 1===this.columns}isVector(){return 1===this.rows||1===this.columns}isSquare(){return this.rows===this.columns}isEmpty(){return 0===this.rows||0===this.columns}isSymmetric(){if(this.isSquare()){for(let t=0;t<this.rows;t++)for(let e=0;e<=t;e++)if(this.get(t,e)!==this.get(e,t))return!1;return!0}return!1}isEchelonForm(){let t=0,e=0,s=-1,n=!0,i=!1;for(;t<this.rows&&n;){for(e=0,i=!1;e<this.columns&&!1===i;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>s?(i=!0,s=e):(n=!1,i=!0);t++}return n}isReducedEchelonForm(){let t=0,e=0,s=-1,n=!0,i=!1;for(;t<this.rows&&n;){for(e=0,i=!1;e<this.columns&&!1===i;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>s?(i=!0,s=e):(n=!1,i=!0);for(let s=e+1;s<this.rows;s++)0!==this.get(t,s)&&(n=!1);t++}return n}echelonForm(){let t=this.clone(),e=0,s=0;for(;e<t.rows&&s<t.columns;){let n=e;for(let i=e;i<t.rows;i++)t.get(i,s)>t.get(n,s)&&(n=i);if(0===t.get(n,s))s++;else{t.swapRows(e,n);let i=t.get(e,s);for(let n=s;n<t.columns;n++)t.set(e,n,t.get(e,n)/i);for(let n=e+1;n<t.rows;n++){let i=t.get(n,s)/t.get(e,s);t.set(n,s,0);for(let r=s+1;r<t.columns;r++)t.set(n,r,t.get(n,r)-t.get(e,r)*i)}e++,s++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,s=t.rows,n=s-1;for(;n>=0;)if(0===t.maxRow(n))n--;else{let i=0,r=!1;for(;i<s&&!1===r;)1===t.get(n,i)?r=!0:i++;for(let s=0;s<n;s++){let r=t.get(s,i);for(let o=i;o<e;o++){let e=t.get(s,o)-r*t.get(n,o);t.set(s,o,e)}}n--}return t}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{rows:e=1,columns:s=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(s)||s<=0)throw new TypeError("columns must be a positive integer");let n=new _(this.rows*e,this.columns*s);for(let t=0;t<e;t++)for(let e=0;e<s;e++)n.setSubMatrix(this,this.rows*t,this.columns*e);return n}fill(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,t);return this}neg(){return this.mulS(-1)}getRow(t){w(this,t);let e=[];for(let s=0;s<this.columns;s++)e.push(this.get(t,s));return e}getRowVector(t){return _.rowVector(this.getRow(t))}setRow(t,e){w(this,t),e=T(this,e);for(let s=0;s<this.columns;s++)this.set(t,s,e[s]);return this}swapRows(t,e){w(this,t),w(this,e);for(let s=0;s<this.columns;s++){let n=this.get(t,s);this.set(t,s,this.get(e,s)),this.set(e,s,n)}return this}getColumn(t){b(this,t);let e=[];for(let s=0;s<this.rows;s++)e.push(this.get(s,t));return e}getColumnVector(t){return _.columnVector(this.getColumn(t))}setColumn(t,e){b(this,t),e=C(this,e);for(let s=0;s<this.rows;s++)this.set(s,t,e[s]);return this}swapColumns(t,e){b(this,t),b(this,e);for(let s=0;s<this.rows;s++){let n=this.get(s,t);this.set(s,t,this.get(s,e)),this.set(s,e,n)}return this}addRowVector(t){t=T(this,t);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)+t[s]);return this}subRowVector(t){t=T(this,t);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)-t[s]);return this}mulRowVector(t){t=T(this,t);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)*t[s]);return this}divRowVector(t){t=T(this,t);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)/t[s]);return this}addColumnVector(t){t=C(this,t);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)+t[e]);return this}subColumnVector(t){t=C(this,t);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)-t[e]);return this}mulColumnVector(t){t=C(this,t);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)*t[e]);return this}divColumnVector(t){t=C(this,t);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)/t[e]);return this}mulRow(t,e){w(this,t);for(let s=0;s<this.columns;s++)this.set(t,s,this.get(t,s)*e);return this}mulColumn(t,e){b(this,t);for(let s=0;s<this.rows;s++)this.set(s,t,this.get(s,t)*e);return this}max(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.get(e,s)>t[e]&&(t[e]=this.get(e,s));return t}case"column":{const t=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.get(e,s)>t[s]&&(t[s]=this.get(e,s));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.get(e,s)>t&&(t=this.get(e,s));return t}default:throw new Error(`invalid option: ${t}`)}}maxIndex(){E(this);let t=this.get(0,0),e=[0,0];for(let s=0;s<this.rows;s++)for(let n=0;n<this.columns;n++)this.get(s,n)>t&&(t=this.get(s,n),e[0]=s,e[1]=n);return e}min(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.get(e,s)<t[e]&&(t[e]=this.get(e,s));return t}case"column":{const t=new Array(this.columns).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.get(e,s)<t[s]&&(t[s]=this.get(e,s));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.get(e,s)<t&&(t=this.get(e,s));return t}default:throw new Error(`invalid option: ${t}`)}}minIndex(){E(this);let t=this.get(0,0),e=[0,0];for(let s=0;s<this.rows;s++)for(let n=0;n<this.columns;n++)this.get(s,n)<t&&(t=this.get(s,n),e[0]=s,e[1]=n);return e}maxRow(t){if(w(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let s=1;s<this.columns;s++)this.get(t,s)>e&&(e=this.get(t,s));return e}maxRowIndex(t){w(this,t),E(this);let e=this.get(t,0),s=[t,0];for(let n=1;n<this.columns;n++)this.get(t,n)>e&&(e=this.get(t,n),s[1]=n);return s}minRow(t){if(w(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let s=1;s<this.columns;s++)this.get(t,s)<e&&(e=this.get(t,s));return e}minRowIndex(t){w(this,t),E(this);let e=this.get(t,0),s=[t,0];for(let n=1;n<this.columns;n++)this.get(t,n)<e&&(e=this.get(t,n),s[1]=n);return s}maxColumn(t){if(b(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let s=1;s<this.rows;s++)this.get(s,t)>e&&(e=this.get(s,t));return e}maxColumnIndex(t){b(this,t),E(this);let e=this.get(0,t),s=[0,t];for(let n=1;n<this.rows;n++)this.get(n,t)>e&&(e=this.get(n,t),s[0]=n);return s}minColumn(t){if(b(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let s=1;s<this.rows;s++)this.get(s,t)<e&&(e=this.get(s,t));return e}minColumnIndex(t){b(this,t),E(this);let e=this.get(0,t),s=[0,t];for(let n=1;n<this.rows;n++)this.get(n,t)<e&&(e=this.get(n,t),s[0]=n);return s}diag(){let t=Math.min(this.rows,this.columns),e=[];for(let s=0;s<t;s++)e.push(this.get(s,s));return e}norm(t="frobenius"){let e=0;if("max"===t)return this.max();if("frobenius"===t){for(let t=0;t<this.rows;t++)for(let s=0;s<this.columns;s++)e+=this.get(t,s)*this.get(t,s);return Math.sqrt(e)}throw new RangeError(`unknown norm type: ${t}`)}cumulativeSum(){let t=0;for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)t+=this.get(e,s),this.set(e,s,t);return this}dot(t){M.isMatrix(t)&&(t=t.to1DArray());let e=this.to1DArray();if(e.length!==t.length)throw new RangeError("vectors do not have the same size");let s=0;for(let n=0;n<e.length;n++)s+=e[n]*t[n];return s}mmul(t){t=_.checkMatrix(t);let e=this.rows,s=this.columns,n=t.columns,i=new _(e,n),r=new Float64Array(s);for(let o=0;o<n;o++){for(let e=0;e<s;e++)r[e]=t.get(e,o);for(let t=0;t<e;t++){let e=0;for(let n=0;n<s;n++)e+=this.get(t,n)*r[n];i.set(t,o,e)}}return i}strassen2x2(t){t=_.checkMatrix(t);let e=new _(2,2);const s=this.get(0,0),n=t.get(0,0),i=this.get(0,1),r=t.get(0,1),o=this.get(1,0),a=t.get(1,0),l=this.get(1,1),h=t.get(1,1),c=(s+l)*(n+h),u=(o+l)*n,m=s*(r-h),d=l*(a-n),g=(s+i)*h,f=c+d-g+(i-l)*(a+h),p=m+g,y=u+d,w=c-u+m+(o-s)*(n+r);return e.set(0,0,f),e.set(0,1,p),e.set(1,0,y),e.set(1,1,w),e}strassen3x3(t){t=_.checkMatrix(t);let e=new _(3,3);const s=this.get(0,0),n=this.get(0,1),i=this.get(0,2),r=this.get(1,0),o=this.get(1,1),a=this.get(1,2),l=this.get(2,0),h=this.get(2,1),c=this.get(2,2),u=t.get(0,0),m=t.get(0,1),d=t.get(0,2),g=t.get(1,0),f=t.get(1,1),p=t.get(1,2),y=t.get(2,0),w=t.get(2,1),b=t.get(2,2),T=(s-r)*(-m+f),C=(-s+r+o)*(u-m+f),S=(r+o)*(-u+m),A=s*u,v=(-s+l+h)*(u-d+p),E=(-s+l)*(d-p),M=(l+h)*(-u+d),N=(-i+h+c)*(f+y-w),P=(i-c)*(f-w),L=i*y,R=(h+c)*(-y+w),x=(-i+o+a)*(p+y-b),I=(i-a)*(p-b),O=(o+a)*(-y+b),F=A+L+n*g,D=(s+n+i-r-o-h-c)*f+C+S+A+N+L+R,G=A+v+M+(s+n+i-o-a-l-h)*p+L+x+O,k=T+o*(-u+m+g-f-p-y+b)+C+A+L+x+I,H=T+C+S+A+a*w,W=L+x+I+O+r*d,B=A+v+E+h*(-u+d+g-f-p-y+w)+N+P+L,V=N+P+L+R+l*m,U=A+v+E+M+c*b;return e.set(0,0,F),e.set(0,1,D),e.set(0,2,G),e.set(1,0,k),e.set(1,1,H),e.set(1,2,W),e.set(2,0,B),e.set(2,1,V),e.set(2,2,U),e}mmulStrassen(t){t=_.checkMatrix(t);let e=this.clone(),s=e.rows,n=e.columns,i=t.rows,r=t.columns;function o(t,e,s){let n=t.rows,i=t.columns;if(n===e&&i===s)return t;{let n=M.zeros(e,s);return n=n.setSubMatrix(t,0,0),n}}n!==i&&console.warn(`Multiplying ${s} x ${n} and ${i} x ${r} matrix: dimensions do not match.`);let a=Math.max(s,i),l=Math.max(n,r);return e=o(e,a,l),function t(e,s,n,i){if(n<=512||i<=512)return e.mmul(s);n%2==1&&i%2==1?(e=o(e,n+1,i+1),s=o(s,n+1,i+1)):n%2==1?(e=o(e,n+1,i),s=o(s,n+1,i)):i%2==1&&(e=o(e,n,i+1),s=o(s,n,i+1));let r=parseInt(e.rows/2,10),a=parseInt(e.columns/2,10),l=e.subMatrix(0,r-1,0,a-1),h=s.subMatrix(0,r-1,0,a-1),c=e.subMatrix(0,r-1,a,e.columns-1),u=s.subMatrix(0,r-1,a,s.columns-1),m=e.subMatrix(r,e.rows-1,0,a-1),d=s.subMatrix(r,s.rows-1,0,a-1),g=e.subMatrix(r,e.rows-1,a,e.columns-1),f=s.subMatrix(r,s.rows-1,a,s.columns-1),p=t(M.add(l,g),M.add(h,f),r,a),y=t(M.add(m,g),h,r,a),w=t(l,M.sub(u,f),r,a),b=t(g,M.sub(d,h),r,a),T=t(M.add(l,c),f,r,a),C=t(M.sub(m,l),M.add(h,u),r,a),S=t(M.sub(c,g),M.add(d,f),r,a),A=M.add(p,b);A.sub(T),A.add(S);let v=M.add(w,T),E=M.add(y,b),N=M.sub(p,y);N.add(w),N.add(C);let _=M.zeros(2*A.rows,2*A.columns);return _=_.setSubMatrix(A,0,0),_=_.setSubMatrix(v,A.rows,0),_=_.setSubMatrix(E,0,A.columns),_=_.setSubMatrix(N,A.rows,A.columns),_.subMatrix(0,n-1,0,i-1)}(e,t=o(t,a,l),a,l)}scaleRows(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:s=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(s))throw new TypeError("max must be a number");if(e>=s)throw new RangeError("min must be smaller than max");let n=new _(this.rows,this.columns);for(let t=0;t<this.rows;t++){const i=this.getRow(t);i.length>0&&m(i,{min:e,max:s,output:i}),n.setRow(t,i)}return n}scaleColumns(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:s=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(s))throw new TypeError("max must be a number");if(e>=s)throw new RangeError("min must be smaller than max");let n=new _(this.rows,this.columns);for(let t=0;t<this.columns;t++){const i=this.getColumn(t);i.length&&m(i,{min:e,max:s,output:i}),n.setColumn(t,i)}return n}flipRows(){const t=Math.ceil(this.columns/2);for(let e=0;e<this.rows;e++)for(let s=0;s<t;s++){let t=this.get(e,s),n=this.get(e,this.columns-1-s);this.set(e,s,n),this.set(e,this.columns-1-s,t)}return this}flipColumns(){const t=Math.ceil(this.rows/2);for(let e=0;e<this.columns;e++)for(let s=0;s<t;s++){let t=this.get(s,e),n=this.get(this.rows-1-s,e);this.set(s,e,n),this.set(this.rows-1-s,e,t)}return this}kroneckerProduct(t){t=_.checkMatrix(t);let e=this.rows,s=this.columns,n=t.rows,i=t.columns,r=new _(e*n,s*i);for(let o=0;o<e;o++)for(let e=0;e<s;e++)for(let s=0;s<n;s++)for(let a=0;a<i;a++)r.set(n*o+s,i*e+a,this.get(o,e)*t.get(s,a));return r}kroneckerSum(t){if(t=_.checkMatrix(t),!this.isSquare()||!t.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let e=this.rows,s=t.rows,n=this.kroneckerProduct(_.eye(s,s)),i=_.eye(e,e).kroneckerProduct(t);return n.add(i)}transpose(){let t=new _(this.columns,this.rows);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)t.set(s,e,this.get(e,s));return t}sortRows(t=N){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=N){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,s,n){S(this,t,e,s,n);let i=new _(e-t+1,n-s+1);for(let r=t;r<=e;r++)for(let e=s;e<=n;e++)i.set(r-t,e-s,this.get(r,e));return i}subMatrixRow(t,e,s){if(void 0===e&&(e=0),void 0===s&&(s=this.columns-1),e>s||e<0||e>=this.columns||s<0||s>=this.columns)throw new RangeError("Argument out of range");let n=new _(t.length,s-e+1);for(let i=0;i<t.length;i++)for(let r=e;r<=s;r++){if(t[i]<0||t[i]>=this.rows)throw new RangeError(`Row index out of range: ${t[i]}`);n.set(i,r-e,this.get(t[i],r))}return n}subMatrixColumn(t,e,s){if(void 0===e&&(e=0),void 0===s&&(s=this.rows-1),e>s||e<0||e>=this.rows||s<0||s>=this.rows)throw new RangeError("Argument out of range");let n=new _(s-e+1,t.length);for(let i=0;i<t.length;i++)for(let r=e;r<=s;r++){if(t[i]<0||t[i]>=this.columns)throw new RangeError(`Column index out of range: ${t[i]}`);n.set(r-e,i,this.get(r,t[i]))}return n}setSubMatrix(t,e,s){if((t=_.checkMatrix(t)).isEmpty())return this;S(this,e,e+t.rows-1,s,s+t.columns-1);for(let n=0;n<t.rows;n++)for(let i=0;i<t.columns;i++)this.set(e+n,s+i,t.get(n,i));return this}selection(t,e){!function(t,e){if(!a(e))throw new TypeError("row indices must be an array");for(let s=0;s<e.length;s++)if(e[s]<0||e[s]>=t.rows)throw new RangeError("row indices are out of range")}(this,t),function(t,e){if(!a(e))throw new TypeError("column indices must be an array");for(let s=0;s<e.length;s++)if(e[s]<0||e[s]>=t.columns)throw new RangeError("column indices are out of range")}(this,e);let s=new _(t.length,e.length);for(let n=0;n<t.length;n++){let i=t[n];for(let t=0;t<e.length;t++){let r=e[t];s.set(n,t,this.get(i,r))}}return s}trace(){let t=Math.min(this.rows,this.columns),e=0;for(let s=0;s<t;s++)e+=this.get(s,s);return e}clone(){let t=new _(this.rows,this.columns);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)t.set(e,s,this.get(e,s));return t}sum(t){switch(t){case"row":return function(t){let e=A(t.rows);for(let s=0;s<t.rows;++s)for(let n=0;n<t.columns;++n)e[s]+=t.get(s,n);return e}(this);case"column":return function(t){let e=A(t.columns);for(let s=0;s<t.rows;++s)for(let n=0;n<t.columns;++n)e[n]+=t.get(s,n);return e}(this);case void 0:return function(t){let e=0;for(let s=0;s<t.rows;s++)for(let n=0;n<t.columns;n++)e+=t.get(s,n);return e}(this);default:throw new Error(`invalid option: ${t}`)}}product(t){switch(t){case"row":return function(t){let e=A(t.rows,1);for(let s=0;s<t.rows;++s)for(let n=0;n<t.columns;++n)e[s]*=t.get(s,n);return e}(this);case"column":return function(t){let e=A(t.columns,1);for(let s=0;s<t.rows;++s)for(let n=0;n<t.columns;++n)e[n]*=t.get(s,n);return e}(this);case void 0:return function(t){let e=1;for(let s=0;s<t.rows;s++)for(let n=0;n<t.columns;n++)e*=t.get(s,n);return e}(this);default:throw new Error(`invalid option: ${t}`)}}mean(t){const e=this.sum(t);switch(t){case"row":for(let t=0;t<this.rows;t++)e[t]/=this.columns;return e;case"column":for(let t=0;t<this.columns;t++)e[t]/=this.rows;return e;case void 0:return e/this.size;default:throw new Error(`invalid option: ${t}`)}}variance(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{unbiased:s=!0,mean:n=this.mean(t)}=e;if("boolean"!=typeof s)throw new TypeError("unbiased must be a boolean");switch(t){case"row":if(!a(n))throw new TypeError("mean must be an array");return function(t,e,s){const n=t.rows,i=t.columns,r=[];for(let o=0;o<n;o++){let n=0,a=0,l=0;for(let e=0;e<i;e++)l=t.get(o,e)-s[o],n+=l,a+=l*l;e?r.push((a-n*n/i)/(i-1)):r.push((a-n*n/i)/i)}return r}(this,s,n);case"column":if(!a(n))throw new TypeError("mean must be an array");return function(t,e,s){const n=t.rows,i=t.columns,r=[];for(let o=0;o<i;o++){let i=0,a=0,l=0;for(let e=0;e<n;e++)l=t.get(e,o)-s[o],i+=l,a+=l*l;e?r.push((a-i*i/n)/(n-1)):r.push((a-i*i/n)/n)}return r}(this,s,n);case void 0:if("number"!=typeof n)throw new TypeError("mean must be a number");return function(t,e,s){const n=t.rows,i=t.columns,r=n*i;let o=0,a=0,l=0;for(let e=0;e<n;e++)for(let n=0;n<i;n++)l=t.get(e,n)-s,o+=l,a+=l*l;return e?(a-o*o/r)/(r-1):(a-o*o/r)/r}(this,s,n);default:throw new Error(`invalid option: ${t}`)}}standardDeviation(t,e){"object"==typeof t&&(e=t,t=void 0);const s=this.variance(t,e);if(void 0===t)return Math.sqrt(s);for(let t=0;t<s.length;t++)s[t]=Math.sqrt(s[t]);return s}center(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{center:s=this.mean(t)}=e;switch(t){case"row":if(!a(s))throw new TypeError("center must be an array");return function(t,e){for(let s=0;s<t.rows;s++)for(let n=0;n<t.columns;n++)t.set(s,n,t.get(s,n)-e[s])}(this,s),this;case"column":if(!a(s))throw new TypeError("center must be an array");return function(t,e){for(let s=0;s<t.rows;s++)for(let n=0;n<t.columns;n++)t.set(s,n,t.get(s,n)-e[n])}(this,s),this;case void 0:if("number"!=typeof s)throw new TypeError("center must be a number");return function(t,e){for(let s=0;s<t.rows;s++)for(let n=0;n<t.columns;n++)t.set(s,n,t.get(s,n)-e)}(this,s),this;default:throw new Error(`invalid option: ${t}`)}}scale(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");let s=e.scale;switch(t){case"row":if(void 0===s)s=function(t){const e=[];for(let s=0;s<t.rows;s++){let n=0;for(let e=0;e<t.columns;e++)n+=Math.pow(t.get(s,e),2)/(t.columns-1);e.push(Math.sqrt(n))}return e}(this);else if(!a(s))throw new TypeError("scale must be an array");return function(t,e){for(let s=0;s<t.rows;s++)for(let n=0;n<t.columns;n++)t.set(s,n,t.get(s,n)/e[s])}(this,s),this;case"column":if(void 0===s)s=function(t){const e=[];for(let s=0;s<t.columns;s++){let n=0;for(let e=0;e<t.rows;e++)n+=Math.pow(t.get(e,s),2)/(t.rows-1);e.push(Math.sqrt(n))}return e}(this);else if(!a(s))throw new TypeError("scale must be an array");return function(t,e){for(let s=0;s<t.rows;s++)for(let n=0;n<t.columns;n++)t.set(s,n,t.get(s,n)/e[n])}(this,s),this;case void 0:if(void 0===s)s=function(t){const e=t.size-1;let s=0;for(let n=0;n<t.columns;n++)for(let i=0;i<t.rows;i++)s+=Math.pow(t.get(i,n),2)/e;return Math.sqrt(s)}(this);else if("number"!=typeof s)throw new TypeError("scale must be a number");return function(t,e){for(let s=0;s<t.rows;s++)for(let n=0;n<t.columns;n++)t.set(s,n,t.get(s,n)/e)}(this,s),this;default:throw new Error(`invalid option: ${t}`)}}toString(t){return f(this,t)}}function N(t,e){return t-e}M.prototype.klass="Matrix","undefined"!=typeof Symbol&&(M.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return f(this)}),M.random=M.rand,M.randomInt=M.randInt,M.diagonal=M.diag,M.prototype.diagonal=M.prototype.diag,M.identity=M.eye,M.prototype.negate=M.prototype.neg,M.prototype.tensorProduct=M.prototype.kroneckerProduct;class _ extends M{constructor(t,e){if(super(),_.isMatrix(t))return t.clone();if(Number.isInteger(t)&&t>=0){if(this.data=[],!(Number.isInteger(e)&&e>=0))throw new TypeError("nColumns must be a positive integer");for(let s=0;s<t;s++)this.data.push(new Float64Array(e))}else{if(!a(t))throw new TypeError("First argument must be a positive number or an array");{const s=t;if("number"!=typeof(e=(t=s.length)?s[0].length:0))throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let n=0;n<t;n++){if(s[n].length!==e)throw new RangeError("Inconsistent array dimensions");if(!s[n].every((t=>"number"==typeof t)))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(s[n]))}}}this.rows=t,this.columns=e}set(t,e,s){return this.data[t][e]=s,this}get(t,e){return this.data[t][e]}removeRow(t){return w(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),w(this,t,!0),e=Float64Array.from(T(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){b(this,t);for(let e=0;e<this.rows;e++){const s=new Float64Array(this.columns-1);for(let n=0;n<t;n++)s[n]=this.data[e][n];for(let n=t+1;n<this.columns;n++)s[n-1]=this.data[e][n];this.data[e]=s}return this.columns-=1,this}addColumn(t,e){void 0===e&&(e=t,t=this.columns),b(this,t,!0),e=C(this,e);for(let s=0;s<this.rows;s++){const n=new Float64Array(this.columns+1);let i=0;for(;i<t;i++)n[i]=this.data[s][i];for(n[i++]=e[s];i<this.columns+1;i++)n[i]=this.data[s][i-1];this.data[s]=n}return this.columns+=1,this}}!function(t,e){t.prototype.add=function(t){return"number"==typeof t?this.addS(t):this.addM(t)},t.prototype.addS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)+t);return this},t.prototype.addM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)+t.get(e,s));return this},t.add=function(t,s){return new e(t).add(s)},t.prototype.sub=function(t){return"number"==typeof t?this.subS(t):this.subM(t)},t.prototype.subS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)-t);return this},t.prototype.subM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)-t.get(e,s));return this},t.sub=function(t,s){return new e(t).sub(s)},t.prototype.subtract=t.prototype.sub,t.prototype.subtractS=t.prototype.subS,t.prototype.subtractM=t.prototype.subM,t.subtract=t.sub,t.prototype.mul=function(t){return"number"==typeof t?this.mulS(t):this.mulM(t)},t.prototype.mulS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)*t);return this},t.prototype.mulM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)*t.get(e,s));return this},t.mul=function(t,s){return new e(t).mul(s)},t.prototype.multiply=t.prototype.mul,t.prototype.multiplyS=t.prototype.mulS,t.prototype.multiplyM=t.prototype.mulM,t.multiply=t.mul,t.prototype.div=function(t){return"number"==typeof t?this.divS(t):this.divM(t)},t.prototype.divS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)/t);return this},t.prototype.divM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)/t.get(e,s));return this},t.div=function(t,s){return new e(t).div(s)},t.prototype.divide=t.prototype.div,t.prototype.divideS=t.prototype.divS,t.prototype.divideM=t.prototype.divM,t.divide=t.div,t.prototype.mod=function(t){return"number"==typeof t?this.modS(t):this.modM(t)},t.prototype.modS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)%t);return this},t.prototype.modM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)%t.get(e,s));return this},t.mod=function(t,s){return new e(t).mod(s)},t.prototype.modulus=t.prototype.mod,t.prototype.modulusS=t.prototype.modS,t.prototype.modulusM=t.prototype.modM,t.modulus=t.mod,t.prototype.and=function(t){return"number"==typeof t?this.andS(t):this.andM(t)},t.prototype.andS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)&t);return this},t.prototype.andM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)&t.get(e,s));return this},t.and=function(t,s){return new e(t).and(s)},t.prototype.or=function(t){return"number"==typeof t?this.orS(t):this.orM(t)},t.prototype.orS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)|t);return this},t.prototype.orM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)|t.get(e,s));return this},t.or=function(t,s){return new e(t).or(s)},t.prototype.xor=function(t){return"number"==typeof t?this.xorS(t):this.xorM(t)},t.prototype.xorS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)^t);return this},t.prototype.xorM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)^t.get(e,s));return this},t.xor=function(t,s){return new e(t).xor(s)},t.prototype.leftShift=function(t){return"number"==typeof t?this.leftShiftS(t):this.leftShiftM(t)},t.prototype.leftShiftS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)<<t);return this},t.prototype.leftShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)<<t.get(e,s));return this},t.leftShift=function(t,s){return new e(t).leftShift(s)},t.prototype.signPropagatingRightShift=function(t){return"number"==typeof t?this.signPropagatingRightShiftS(t):this.signPropagatingRightShiftM(t)},t.prototype.signPropagatingRightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)>>t);return this},t.prototype.signPropagatingRightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)>>t.get(e,s));return this},t.signPropagatingRightShift=function(t,s){return new e(t).signPropagatingRightShift(s)},t.prototype.rightShift=function(t){return"number"==typeof t?this.rightShiftS(t):this.rightShiftM(t)},t.prototype.rightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)>>>t);return this},t.prototype.rightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)>>>t.get(e,s));return this},t.rightShift=function(t,s){return new e(t).rightShift(s)},t.prototype.zeroFillRightShift=t.prototype.rightShift,t.prototype.zeroFillRightShiftS=t.prototype.rightShiftS,t.prototype.zeroFillRightShiftM=t.prototype.rightShiftM,t.zeroFillRightShift=t.rightShift,t.prototype.not=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,~this.get(t,e));return this},t.not=function(t){return new e(t).not()},t.prototype.abs=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.abs(this.get(t,e)));return this},t.abs=function(t){return new e(t).abs()},t.prototype.acos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acos(this.get(t,e)));return this},t.acos=function(t){return new e(t).acos()},t.prototype.acosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acosh(this.get(t,e)));return this},t.acosh=function(t){return new e(t).acosh()},t.prototype.asin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asin(this.get(t,e)));return this},t.asin=function(t){return new e(t).asin()},t.prototype.asinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asinh(this.get(t,e)));return this},t.asinh=function(t){return new e(t).asinh()},t.prototype.atan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atan(this.get(t,e)));return this},t.atan=function(t){return new e(t).atan()},t.prototype.atanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atanh(this.get(t,e)));return this},t.atanh=function(t){return new e(t).atanh()},t.prototype.cbrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cbrt(this.get(t,e)));return this},t.cbrt=function(t){return new e(t).cbrt()},t.prototype.ceil=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.ceil(this.get(t,e)));return this},t.ceil=function(t){return new e(t).ceil()},t.prototype.clz32=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.clz32(this.get(t,e)));return this},t.clz32=function(t){return new e(t).clz32()},t.prototype.cos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cos(this.get(t,e)));return this},t.cos=function(t){return new e(t).cos()},t.prototype.cosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cosh(this.get(t,e)));return this},t.cosh=function(t){return new e(t).cosh()},t.prototype.exp=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.exp(this.get(t,e)));return this},t.exp=function(t){return new e(t).exp()},t.prototype.expm1=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.expm1(this.get(t,e)));return this},t.expm1=function(t){return new e(t).expm1()},t.prototype.floor=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.floor(this.get(t,e)));return this},t.floor=function(t){return new e(t).floor()},t.prototype.fround=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.fround(this.get(t,e)));return this},t.fround=function(t){return new e(t).fround()},t.prototype.log=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log(this.get(t,e)));return this},t.log=function(t){return new e(t).log()},t.prototype.log1p=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log1p(this.get(t,e)));return this},t.log1p=function(t){return new e(t).log1p()},t.prototype.log10=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log10(this.get(t,e)));return this},t.log10=function(t){return new e(t).log10()},t.prototype.log2=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log2(this.get(t,e)));return this},t.log2=function(t){return new e(t).log2()},t.prototype.round=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.round(this.get(t,e)));return this},t.round=function(t){return new e(t).round()},t.prototype.sign=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sign(this.get(t,e)));return this},t.sign=function(t){return new e(t).sign()},t.prototype.sin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sin(this.get(t,e)));return this},t.sin=function(t){return new e(t).sin()},t.prototype.sinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sinh(this.get(t,e)));return this},t.sinh=function(t){return new e(t).sinh()},t.prototype.sqrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sqrt(this.get(t,e)));return this},t.sqrt=function(t){return new e(t).sqrt()},t.prototype.tan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tan(this.get(t,e)));return this},t.tan=function(t){return new e(t).tan()},t.prototype.tanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tanh(this.get(t,e)));return this},t.tanh=function(t){return new e(t).tanh()},t.prototype.trunc=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.trunc(this.get(t,e)));return this},t.trunc=function(t){return new e(t).trunc()},t.pow=function(t,s){return new e(t).pow(s)},t.prototype.pow=function(t){return"number"==typeof t?this.powS(t):this.powM(t)},t.prototype.powS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,Math.pow(this.get(e,s),t));return this},t.prototype.powM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,Math.pow(this.get(e,s),t.get(e,s)));return this}}(M,_);class P extends M{constructor(t){super(),this.data=t,this.rows=t.length,this.columns=t[0].length}set(t,e,s){return this.data[t][e]=s,this}get(t,e){return this.data[t][e]}}class L{constructor(t){let e,s,n,i,r,o,a,l,h,c=(t=P.checkMatrix(t)).clone(),u=c.rows,m=c.columns,d=new Float64Array(u),g=1;for(e=0;e<u;e++)d[e]=e;for(l=new Float64Array(u),s=0;s<m;s++){for(e=0;e<u;e++)l[e]=c.get(e,s);for(e=0;e<u;e++){for(h=Math.min(e,s),r=0,n=0;n<h;n++)r+=c.get(e,n)*l[n];l[e]-=r,c.set(e,s,l[e])}for(i=s,e=s+1;e<u;e++)Math.abs(l[e])>Math.abs(l[i])&&(i=e);if(i!==s){for(n=0;n<m;n++)o=c.get(i,n),c.set(i,n,c.get(s,n)),c.set(s,n,o);a=d[i],d[i]=d[s],d[s]=a,g=-g}if(s<u&&0!==c.get(s,s))for(e=s+1;e<u;e++)c.set(e,s,c.get(e,s)/c.get(s,s))}this.LU=c,this.pivotVector=d,this.pivotSign=g}isSingular(){let t=this.LU,e=t.columns;for(let s=0;s<e;s++)if(0===t.get(s,s))return!0;return!1}solve(t){t=_.checkMatrix(t);let e=this.LU;if(e.rows!==t.rows)throw new Error("Invalid matrix dimensions");if(this.isSingular())throw new Error("LU matrix is singular");let s,n,i,r=t.columns,o=t.subMatrixRow(this.pivotVector,0,r-1),a=e.columns;for(i=0;i<a;i++)for(s=i+1;s<a;s++)for(n=0;n<r;n++)o.set(s,n,o.get(s,n)-o.get(i,n)*e.get(s,i));for(i=a-1;i>=0;i--){for(n=0;n<r;n++)o.set(i,n,o.get(i,n)/e.get(i,i));for(s=0;s<i;s++)for(n=0;n<r;n++)o.set(s,n,o.get(s,n)-o.get(i,n)*e.get(s,i))}return o}get determinant(){let t=this.LU;if(!t.isSquare())throw new Error("Matrix must be square");let e=this.pivotSign,s=t.columns;for(let n=0;n<s;n++)e*=t.get(n,n);return e}get lowerTriangularMatrix(){let t=this.LU,e=t.rows,s=t.columns,n=new _(e,s);for(let i=0;i<e;i++)for(let e=0;e<s;e++)i>e?n.set(i,e,t.get(i,e)):i===e?n.set(i,e,1):n.set(i,e,0);return n}get upperTriangularMatrix(){let t=this.LU,e=t.rows,s=t.columns,n=new _(e,s);for(let i=0;i<e;i++)for(let e=0;e<s;e++)i<=e?n.set(i,e,t.get(i,e)):n.set(i,e,0);return n}get pivotPermutationVector(){return Array.from(this.pivotVector)}}function R(t,e){let s=0;return Math.abs(t)>Math.abs(e)?(s=e/t,Math.abs(t)*Math.sqrt(1+s*s)):0!==e?(s=t/e,Math.abs(e)*Math.sqrt(1+s*s)):0}class x{constructor(t){let e,s,n,i,r=(t=P.checkMatrix(t)).clone(),o=t.rows,a=t.columns,l=new Float64Array(a);for(n=0;n<a;n++){let t=0;for(e=n;e<o;e++)t=R(t,r.get(e,n));if(0!==t){for(r.get(n,n)<0&&(t=-t),e=n;e<o;e++)r.set(e,n,r.get(e,n)/t);for(r.set(n,n,r.get(n,n)+1),s=n+1;s<a;s++){for(i=0,e=n;e<o;e++)i+=r.get(e,n)*r.get(e,s);for(i=-i/r.get(n,n),e=n;e<o;e++)r.set(e,s,r.get(e,s)+i*r.get(e,n))}}l[n]=-t}this.QR=r,this.Rdiag=l}solve(t){t=_.checkMatrix(t);let e=this.QR,s=e.rows;if(t.rows!==s)throw new Error("Matrix row dimensions must agree");if(!this.isFullRank())throw new Error("Matrix is rank deficient");let n,i,r,o,a=t.columns,l=t.clone(),h=e.columns;for(r=0;r<h;r++)for(i=0;i<a;i++){for(o=0,n=r;n<s;n++)o+=e.get(n,r)*l.get(n,i);for(o=-o/e.get(r,r),n=r;n<s;n++)l.set(n,i,l.get(n,i)+o*e.get(n,r))}for(r=h-1;r>=0;r--){for(i=0;i<a;i++)l.set(r,i,l.get(r,i)/this.Rdiag[r]);for(n=0;n<r;n++)for(i=0;i<a;i++)l.set(n,i,l.get(n,i)-l.get(r,i)*e.get(n,r))}return l.subMatrix(0,h-1,0,a-1)}isFullRank(){let t=this.QR.columns;for(let e=0;e<t;e++)if(0===this.Rdiag[e])return!1;return!0}get upperTriangularMatrix(){let t,e,s=this.QR,n=s.columns,i=new _(n,n);for(t=0;t<n;t++)for(e=0;e<n;e++)t<e?i.set(t,e,s.get(t,e)):t===e?i.set(t,e,this.Rdiag[t]):i.set(t,e,0);return i}get orthogonalMatrix(){let t,e,s,n,i=this.QR,r=i.rows,o=i.columns,a=new _(r,o);for(s=o-1;s>=0;s--){for(t=0;t<r;t++)a.set(t,s,0);for(a.set(s,s,1),e=s;e<o;e++)if(0!==i.get(s,s)){for(n=0,t=s;t<r;t++)n+=i.get(t,s)*a.get(t,e);for(n=-n/i.get(s,s),t=s;t<r;t++)a.set(t,e,a.get(t,e)+n*i.get(t,s))}}return a}}class I{constructor(t,e={}){if((t=P.checkMatrix(t)).isEmpty())throw new Error("Matrix must be non-empty");let s=t.rows,n=t.columns;const{computeLeftSingularVectors:i=!0,computeRightSingularVectors:r=!0,autoTranspose:o=!1}=e;let a,l=Boolean(i),h=Boolean(r),c=!1;if(s<n)if(o){a=t.transpose(),s=a.rows,n=a.columns,c=!0;let e=l;l=h,h=e}else a=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else a=t.clone();let u=Math.min(s,n),m=Math.min(s+1,n),d=new Float64Array(m),g=new _(s,u),f=new _(n,n),p=new Float64Array(n),y=new Float64Array(s),w=new Float64Array(m);for(let t=0;t<m;t++)w[t]=t;let b=Math.min(s-1,n),T=Math.max(0,Math.min(n-2,s)),C=Math.max(b,T);for(let t=0;t<C;t++){if(t<b){d[t]=0;for(let e=t;e<s;e++)d[t]=R(d[t],a.get(e,t));if(0!==d[t]){a.get(t,t)<0&&(d[t]=-d[t]);for(let e=t;e<s;e++)a.set(e,t,a.get(e,t)/d[t]);a.set(t,t,a.get(t,t)+1)}d[t]=-d[t]}for(let e=t+1;e<n;e++){if(t<b&&0!==d[t]){let n=0;for(let i=t;i<s;i++)n+=a.get(i,t)*a.get(i,e);n=-n/a.get(t,t);for(let i=t;i<s;i++)a.set(i,e,a.get(i,e)+n*a.get(i,t))}p[e]=a.get(t,e)}if(l&&t<b)for(let e=t;e<s;e++)g.set(e,t,a.get(e,t));if(t<T){p[t]=0;for(let e=t+1;e<n;e++)p[t]=R(p[t],p[e]);if(0!==p[t]){p[t+1]<0&&(p[t]=0-p[t]);for(let e=t+1;e<n;e++)p[e]/=p[t];p[t+1]+=1}if(p[t]=-p[t],t+1<s&&0!==p[t]){for(let e=t+1;e<s;e++)y[e]=0;for(let e=t+1;e<s;e++)for(let s=t+1;s<n;s++)y[e]+=p[s]*a.get(e,s);for(let e=t+1;e<n;e++){let n=-p[e]/p[t+1];for(let i=t+1;i<s;i++)a.set(i,e,a.get(i,e)+n*y[i])}}if(h)for(let e=t+1;e<n;e++)f.set(e,t,p[e])}}let S=Math.min(n,s+1);if(b<n&&(d[b]=a.get(b,b)),s<S&&(d[S-1]=0),T+1<S&&(p[T]=a.get(T,S-1)),p[S-1]=0,l){for(let t=b;t<u;t++){for(let e=0;e<s;e++)g.set(e,t,0);g.set(t,t,1)}for(let t=b-1;t>=0;t--)if(0!==d[t]){for(let e=t+1;e<u;e++){let n=0;for(let i=t;i<s;i++)n+=g.get(i,t)*g.get(i,e);n=-n/g.get(t,t);for(let i=t;i<s;i++)g.set(i,e,g.get(i,e)+n*g.get(i,t))}for(let e=t;e<s;e++)g.set(e,t,-g.get(e,t));g.set(t,t,1+g.get(t,t));for(let e=0;e<t-1;e++)g.set(e,t,0)}else{for(let e=0;e<s;e++)g.set(e,t,0);g.set(t,t,1)}}if(h)for(let t=n-1;t>=0;t--){if(t<T&&0!==p[t])for(let e=t+1;e<n;e++){let s=0;for(let i=t+1;i<n;i++)s+=f.get(i,t)*f.get(i,e);s=-s/f.get(t+1,t);for(let i=t+1;i<n;i++)f.set(i,e,f.get(i,e)+s*f.get(i,t))}for(let e=0;e<n;e++)f.set(e,t,0);f.set(t,t,1)}let A=S-1,v=0,E=Number.EPSILON;for(;S>0;){let t,e;for(t=S-2;t>=-1&&-1!==t;t--){const e=Number.MIN_VALUE+E*Math.abs(d[t]+Math.abs(d[t+1]));if(Math.abs(p[t])<=e||Number.isNaN(p[t])){p[t]=0;break}}if(t===S-2)e=4;else{let s;for(s=S-1;s>=t&&s!==t;s--){let e=(s!==S?Math.abs(p[s]):0)+(s!==t+1?Math.abs(p[s-1]):0);if(Math.abs(d[s])<=E*e){d[s]=0;break}}s===t?e=3:s===S-1?e=1:(e=2,t=s)}switch(t++,e){case 1:{let e=p[S-2];p[S-2]=0;for(let s=S-2;s>=t;s--){let i=R(d[s],e),r=d[s]/i,o=e/i;if(d[s]=i,s!==t&&(e=-o*p[s-1],p[s-1]=r*p[s-1]),h)for(let t=0;t<n;t++)i=r*f.get(t,s)+o*f.get(t,S-1),f.set(t,S-1,-o*f.get(t,s)+r*f.get(t,S-1)),f.set(t,s,i)}break}case 2:{let e=p[t-1];p[t-1]=0;for(let n=t;n<S;n++){let i=R(d[n],e),r=d[n]/i,o=e/i;if(d[n]=i,e=-o*p[n],p[n]=r*p[n],l)for(let e=0;e<s;e++)i=r*g.get(e,n)+o*g.get(e,t-1),g.set(e,t-1,-o*g.get(e,n)+r*g.get(e,t-1)),g.set(e,n,i)}break}case 3:{const e=Math.max(Math.abs(d[S-1]),Math.abs(d[S-2]),Math.abs(p[S-2]),Math.abs(d[t]),Math.abs(p[t])),i=d[S-1]/e,r=d[S-2]/e,o=p[S-2]/e,a=d[t]/e,c=p[t]/e,u=((r+i)*(r-i)+o*o)/2,m=i*o*(i*o);let y=0;0===u&&0===m||(y=u<0?0-Math.sqrt(u*u+m):Math.sqrt(u*u+m),y=m/(u+y));let w=(a+i)*(a-i)+y,b=a*c;for(let e=t;e<S-1;e++){let i=R(w,b);0===i&&(i=Number.MIN_VALUE);let r=w/i,o=b/i;if(e!==t&&(p[e-1]=i),w=r*d[e]+o*p[e],p[e]=r*p[e]-o*d[e],b=o*d[e+1],d[e+1]=r*d[e+1],h)for(let t=0;t<n;t++)i=r*f.get(t,e)+o*f.get(t,e+1),f.set(t,e+1,-o*f.get(t,e)+r*f.get(t,e+1)),f.set(t,e,i);if(i=R(w,b),0===i&&(i=Number.MIN_VALUE),r=w/i,o=b/i,d[e]=i,w=r*p[e]+o*d[e+1],d[e+1]=-o*p[e]+r*d[e+1],b=o*p[e+1],p[e+1]=r*p[e+1],l&&e<s-1)for(let t=0;t<s;t++)i=r*g.get(t,e)+o*g.get(t,e+1),g.set(t,e+1,-o*g.get(t,e)+r*g.get(t,e+1)),g.set(t,e,i)}p[S-2]=w,v+=1;break}case 4:if(d[t]<=0&&(d[t]=d[t]<0?-d[t]:0,h))for(let e=0;e<=A;e++)f.set(e,t,-f.get(e,t));for(;t<A&&!(d[t]>=d[t+1]);){let e=d[t];if(d[t]=d[t+1],d[t+1]=e,h&&t<n-1)for(let s=0;s<n;s++)e=f.get(s,t+1),f.set(s,t+1,f.get(s,t)),f.set(s,t,e);if(l&&t<s-1)for(let n=0;n<s;n++)e=g.get(n,t+1),g.set(n,t+1,g.get(n,t)),g.set(n,t,e);t++}v=0,S--}}if(c){let t=f;f=g,g=t}this.m=s,this.n=n,this.s=d,this.U=g,this.V=f}solve(t){let e=t,s=this.threshold,n=this.s.length,i=_.zeros(n,n);for(let t=0;t<n;t++)Math.abs(this.s[t])<=s?i.set(t,t,0):i.set(t,t,1/this.s[t]);let r=this.U,o=this.rightSingularVectors,a=o.mmul(i),l=o.rows,h=r.rows,c=_.zeros(l,h);for(let t=0;t<l;t++)for(let e=0;e<h;e++){let s=0;for(let i=0;i<n;i++)s+=a.get(t,i)*r.get(e,i);c.set(t,e,s)}return c.mmul(e)}solveForDiagonal(t){return this.solve(_.diag(t))}inverse(){let t=this.V,e=this.threshold,s=t.rows,n=t.columns,i=new _(s,this.s.length);for(let r=0;r<s;r++)for(let s=0;s<n;s++)Math.abs(this.s[s])>e&&i.set(r,s,t.get(r,s)/this.s[s]);let r=this.U,o=r.rows,a=r.columns,l=new _(s,o);for(let t=0;t<s;t++)for(let e=0;e<o;e++){let s=0;for(let n=0;n<a;n++)s+=i.get(t,n)*r.get(e,n);l.set(t,e,s)}return l}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let t=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,e=0,s=this.s;for(let n=0,i=s.length;n<i;n++)s[n]>t&&e++;return e}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return _.diag(this.s)}}function O(t,e,s,n,i){let r=s*n*n,o=_.eye(e.length,e.length,r);const a=i(e);let l=new Float64Array(t.x.length);for(let e=0;e<t.x.length;e++)l[e]=a(t.x[e]);let h=function(t,e,s,n,i){const r=s.length,o=t.x.length;let a=new Array(r);for(let l=0;l<r;l++){a[l]=new Array(o);let r=s.slice();r[l]+=n;let h=i(r);for(let s=0;s<o;s++)a[l][s]=e[s]-h(t.x[s])}return new _(a)}(t,l,e,n,i),c=function(t,e){const s=t.x.length;let n=new Array(s);for(let i=0;i<s;i++)n[i]=[t.y[i]-e[i]];return new _(n)}(t,l),u=function(t,e=!1){return t=P.checkMatrix(t),e?new I(t).inverse():function(t,e,s=!1){return t=P.checkMatrix(t),e=P.checkMatrix(e),s?new I(t).solve(e):t.isSquare()?new L(t).solve(e):new x(t).solve(e)}(t,_.eye(t.rows))}(o.add(h.mmul(h.transpose())));return(e=(e=new _([e])).sub(u.mmul(h).mmul(c).mul(n).transpose())).to1DArray()}function F(t,e,s={}){let{maxIterations:n=100,gradientDifference:o=.1,damping:a=0,errorTolerance:l=.01,minValues:h,maxValues:c,initialValues:u}=s;if(a<=0)throw new Error("The damping option must be a positive number");if(!t.x||!t.y)throw new Error("The data parameter must have x and y elements");if(!i(t.x)||t.x.length<2||!i(t.y)||t.y.length<2)throw new Error("The data parameter elements must be an array with more than 2 points");if(t.x.length!==t.y.length)throw new Error("The data parameter elements must have the same size");let m=u||new Array(e.length).fill(1),d=m.length;if(c=c||new Array(d).fill(Number.MAX_SAFE_INTEGER),h=h||new Array(d).fill(Number.MIN_SAFE_INTEGER),c.length!==h.length)throw new Error("minValues and maxValues must be the same size");if(!i(m))throw new Error("initialValues must be an array");let g,f=r(t,m,e),p=f<=l;for(g=0;g<n&&!p;g++){m=O(t,m,a,o,e);for(let t=0;t<d;t++)m[t]=Math.min(Math.max(h[t],m[t]),c[t]);if(f=r(t,m,e),isNaN(f))break;p=f<=l}return{parameterValues:m,parameterError:f,iterations:g}}},3379:t=>{"use strict";var e=[];function s(t){for(var s=-1,n=0;n<e.length;n++)if(e[n].identifier===t){s=n;break}return s}function n(t,n){for(var r={},o=[],a=0;a<t.length;a++){var l=t[a],h=n.base?l[0]+n.base:l[0],c=r[h]||0,u="".concat(h," ").concat(c);r[h]=c+1;var m=s(u),d={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==m)e[m].references++,e[m].updater(d);else{var g=i(d,n);n.byIndex=a,e.splice(a,0,{identifier:u,updater:g,references:1})}o.push(u)}return o}function i(t,e){var s=e.domAPI(e);return s.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;s.update(t=e)}else s.remove()}}t.exports=function(t,i){var r=n(t=t||[],i=i||{});return function(t){t=t||[];for(var o=0;o<r.length;o++){var a=s(r[o]);e[a].references--}for(var l=n(t,i),h=0;h<r.length;h++){var c=s(r[h]);0===e[c].references&&(e[c].updater(),e.splice(c,1))}r=l}}},569:t=>{"use strict";var e={};t.exports=function(t,s){var n=function(t){if(void 0===e[t]){var s=document.querySelector(t);if(window.HTMLIFrameElement&&s instanceof window.HTMLIFrameElement)try{s=s.contentDocument.head}catch(t){s=null}e[t]=s}return e[t]}(t);if(!n)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");n.appendChild(s)}},9216:t=>{"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},3565:(t,e,s)=>{"use strict";t.exports=function(t){var e=s.nc;e&&t.setAttribute("nonce",e)}},7795:t=>{"use strict";t.exports=function(t){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=t.insertStyleElement(t);return{update:function(s){!function(t,e,s){var n="";s.supports&&(n+="@supports (".concat(s.supports,") {")),s.media&&(n+="@media ".concat(s.media," {"));var i=void 0!==s.layer;i&&(n+="@layer".concat(s.layer.length>0?" ".concat(s.layer):""," {")),n+=s.css,i&&(n+="}"),s.media&&(n+="}"),s.supports&&(n+="}");var r=s.sourceMap;r&&"undefined"!=typeof btoa&&(n+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(r))))," */")),e.styleTagTransform(n,t,e.options)}(e,t,s)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},4589: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))}}},7241:(t,e,s)=>{"use strict";s.d(e,{D:()=>c});var n=s(4469),i=s(976),r=s(6414),o=s.n(r),a=s(2397),l=s(499);const h=31;async function c(t,e=!1,s){const r=l.Cn.getOrCreate(t);let c;s??(s=new Map);const m=r.isHelm()?(0,a.getHelmMonomers)(t):Object.keys(r.stats.freq).filter((t=>""!==t));for(let t=0;t<m.length;t++)s.has(m[t])||s.set(m[t],`${s.size+1}`);if(r.isHelm())c=await n.functions.call("HELM:getMolFiles",{col:t}),c=function(t,e,s=!1){const n=new Array(t.length);for(let i=0;i<t.length;i++){let r=0,o=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(i);r=l.indexOf("\n",r)+1,r=l.indexOf("\n",r)+1,r=l.indexOf("\n",r)+1;const c=parseInt(l.substring(r,r+3)),u=parseInt(l.substring(r+3,r+6));a+=`M V30 COUNTS ${c} ${u} 0 0 0\n`,a+="M V30 BEGIN ATOM\n";for(let t=0;t<c;t++){r=l.indexOf("\n",r)+1+h,o=l.indexOf(" ",r);const n=l.substring(r,o);a+=s?`M V30 ${t+1} R${e.get(n)} 0.000 0.000 0 0\n`:`M V30 ${t+1} At 0.000 0.000 0 0 MASS=${e.get(n)}\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()),s=parseInt(l.substring(r+3,r+6).trim());a+=`M V30 ${t+1} ${parseInt(l.substring(r+6,r+9).trim())} ${e} ${s}\n`}a+="M V30 END BOND\n",a+="M V30 END CTAB\n",a+="M END",n[i]=a}return n}(c,s,e);else{c=new Array(t.length);for(let n=0;n<t.length;n++){const t=u(o()(r.splitted[n]).filter((t=>""!==t)).toArray(),s,e);c[n]=t}}return i.Column.fromStrings("monomericMols",c)}function u(t,e,s=!1){let n="\n Datagrok macromolecule handler\n\n 0 0 0 0 0 0 999 V3000\nM V30 BEGIN CTAB\n";n+=`M V30 COUNTS ${t.length} ${t.length?t.length-1:0} 0 0 0\n`,n+="M V30 BEGIN ATOM\n";for(let i=0;i<t.length;i++)n+=s?`M V30 ${i+1} R${e.get(t[i])} 0.000 0.000 0 0\n`:`M V30 ${i+1} At 0.000 0.000 0 0 MASS=${e.get(t[i])}\n`;n+="M V30 END ATOM\n",n+="M V30 BEGIN BOND\n";for(let e=0;e<t.length-1;e++)n+=`M V30 ${e+1} 1 ${e+1} ${e+2}\n`;return n+="M V30 END BOND\n",n+="M V30 END CTAB\n",n+="M END",n}},2397:(t,e,s)=>{"use strict";s.d(e,{_package:()=>Dt,activityCliffs:()=>Ht,getBioLib:()=>kt,getHelmMonomers:()=>Ut,getMonomerLibHelper:()=>Gt,importFasta:()=>Vt,sequenceIdentityScoring:()=>$t,sequenceSimilarityScoring:()=>Yt,sequenceSpaceTopMenu:()=>Wt,toAtomicLevel:()=>Bt});var n=s(4469),i=s(3870),r=s(976),o=s(6414),a=s.n(o),l=s(585);const h="rgb(100,100,100)",c="#808080",u="rgb(0,0,0)",m=l.GU;var d,g;function f(t,e,s,n,i,r,o=h,a=0,l=!1,d=1,f="",p=!1,y=g.classic,w=[],b=0,T=null,C=[],S=null,A={}){i.textAlign="start";let v=r.substring(0),E=p?"":f;y===g.MSA&&(E="");let M=!0,N=!0,_="difference";null!=T&&null!=T.cell.column&&(M=T.cell.column.temp["color-code"]??!0,N=T.cell.column.temp["compare-with-current"]??!0,_=T.cell.column.temp["highlight-difference"]??"difference");const P=C[b];N&&C.length>0&&"difference"===_&&(d=v==P?.3:d),N&&C.length>0&&"equal"===_&&(d=v!=P?.3:d),null!=S&&(v=m(v,S));const L=v+E;A[L]??(A[L]=i.measureText(L));let R=A[L];A[v]??(A[v]=i.measureText(v));let x=A[v].width;A[E]??(A[E]=i.measureText(E));const I=A[E].width,O=n/2-(R.fontBoundingBoxAscent+R.fontBoundingBoxDescent)/2+1;function F(s,n){const r=M?o:u;i.fillStyle=r,i.globalAlpha=d,y===g.classic&&(i.fillText(v,t+s,e+O),i.fillStyle=c,i.fillText(E,t+n,e+O)),y===g.MSA&&i.fillText(v,t+s,e+O)}R=R.width,y===g.MSA&&(x=w[b],R=w[b]);const D=(w[b]??0)-(w[0]??0);if(l||R>s)return F(D,D+x),t+D+x+I;{const e=(s-R)/2;return F(e,e+x),t+D+e+x}}!function(t){t.maxMonomerLength=".mm.cellRenderer.maxMonomerLength"}(d||(d={})),function(t){t.MSA="MSA",t.classic="classic"}(g||(g={})),s(9611);var p,y,w=s(8447),b=s(7331),T=s(499);function C(t){const e=!a().enumerate(t).some((([e,s])=>e.length>1&&0!=s&&s!=t.length-1)),s=[],n=e?"":" ";for(const[e,i]of a().enumerate(t)){let r=e;i<t.length&&(r+=`${e?"":"-"}${n}`),s.push(r)}return[s,e]}(y=p||(p={})).long="long",y.short="short",s(3553),w.GU;class S extends r.GridCellRenderer{constructor(){super(...arguments),this.padding=5}get name(){return"sequence"}get cellType(){return"sequence"}get defaultHeight(){return 30}get defaultWidth(){return 230}onClick(t,e){t.cell.column.temp["current-word"]=t.cell.value,t.grid.invalidate()}onMouseMove(t,e){const s=t.cell.column.temp["bio-seqCol"];if(!s)return;const r=t.bounds,o=e.offsetX-t.gridColumn.left+(t.gridColumn.left-r.x),a=s.getPosition(t.tableRowIndex,o),l=s.getSeqMonList(t.tableRowIndex);if(null!==a&&a<l.length){const t=l[a],r=[i.div(t)];if(s._monomerStructureMap[t])r.push(s._monomerStructureMap[t]);else{const e=s.getMonomer(t);if(e){const i={autoCrop:!0,autoCropMargin:0,suppressChiralText:!0},o=n.chem.svgMol(e.smiles,void 0,void 0,i);r.push(o),s._monomerStructureMap[t]=o}}i.tooltip.show(i.divV(r),e.x+16,e.y+16)}else i.tooltip.hide()}render(t,e,s,n,i,o,l){const h=o.grid,c=o.cell.column,u=c.temp,m=u["monomer-width"];if("short"===(null!=m?m:"short")){const t=parseInt(c.getTag(d.maxMonomerLength));isNaN(t)&&Dt.properties?.MaxMonomerLength}let p=c.temp["bio-seqCol"];p||new cell_renderer_monomer_placer.A(h,c,(()=>{const t=T.Cn.getOrCreate(c);return{unitsHandler:t,monomerCharWidth:7,separatorWidth:t.isMsa()?8:0,monomerToShort:cell_renderer_monomerToShortFunction,monomerLengthLimit:50,monomerLib:kt()}})),c.tags[".mm.cellRenderer.settingsChanged"]===cell_renderer_consts_rendererSettingsChangedState_true&&(u[".mm.cellRenderer.gapLength"],p.setMonomerLengthLimit(50),p.setSeparatorWidth(p.isMsa()?8:0),c.setTag(".mm.cellRenderer.settingsChanged",cell_renderer_consts_rendererSettingsChangedState_false));const[y,b]=p.getCellMonomerLengths(o.tableRowIndex);y.length,p.updated&&(u["bio-seqCol"]=p),t.save();try{const l=window.devicePixelRatio,h=-1!==o.gridRow?o.grid:null,m=o.cell.value,d=c.getTag("alphabet"),y=50;getUpdatedWidth(h,t,e,n,l),t.beginPath(),t.rect(e+this.padding,s+this.padding,n-this.padding-1,i-2*this.padding),t.clip(),t.font="12px monospace",t.textBaseline="top";const C=c.getTag(r.TAGS.UNITS),S=c.getTag("aligned"),A=(0,w.py)(d),v=c.getTag("separator")??"",E=n/5,M=T.Cn.getOrCreate(c).getSplitter(E),N=u["reference-sequence"],_=u["current-word"],P=M(null!=N&&""!=N?N:_??""),L=M(m);let R=cell_renderer_undefinedColor,x=g.classic;S&&S.includes("MSA")&&C==w.r2.SEPARATOR&&g.MSA;for(const[r,l]of a().enumerate(L)){A.get(r),t.fillStyle=cell_renderer_undefinedColor;const a=l===L.length-1;if(f(e+this.padding,s,n,i,t,r,R,0,!0,1,v,a,x,b,l,o,P,50,p._monomerLengthMap),y>n)break}}catch(t){const e=t instanceof Error?t.message:t?t.toString():"Error 'undefined'";Dt.logger.error(`Bio: MacromoleculeSequenceCellRenderer.render() error: ${e}`)}finally{t.restore()}}}class A extends r.GridCellRenderer{get name(){return"MacromoleculeDifferenceCR"}get cellType(){return constants.Of.MACROMOLECULE_DIFFERENCE}get defaultHeight(){return 30}get defaultWidth(){return 230}render(t,e,s,n,i,o,a){const h=window.devicePixelRatio,c=o.grid,u=o.cell,m=o.tableColumn,d=u.value??"",g=m.tags.separator,f=m.tags[r.TAGS.UNITS];getUpdatedWidth(c,t,e,n,h);const[p,y]=d.split("#"),w=(0,l.vU)(f,g);v(t,e,s,n,i,w(p),w(y),f)}}function v(t,e,s,n,i,r,o,l,h,c){if(r.length!==o.length){const t=function(t,e){let s=0,n=0;const i=t.length>e.length?t:e,r=t.length>e.length?e:t;for(let t=0;t<r.length;t++)i[t]===r[t]&&s++;const o=i.length-r.length;for(let t=i.length-1;t>o;t--)i[t]===r[t-o]&&n++;const a=new Array(Math.abs(t.length-e.length)).fill("");function l(t){return s>n?t.concat(a):a.concat(t)}return t.length>e.length?e=l(e):t=l(t),{subParts1:t,subParts2:e}}(a()(r).toArray(),a()(o).toArray());r=t.subParts1,o=t.subParts2}const u=t.measureText(C(r).join("")),m=t.measureText(C(o).join("")),d=Math.max(u.width,m.width);h&&(n=d+4*r.length,t.canvas.width=d+4*r.length);let g=Math.max(e,e+(n-(d+4*r.length))/2)+5;const p=Math.max(s,s+(i-28)/2);t.save(),t.beginPath(),t.rect(e,s,h?d+4*r.length:n,i),t.clip(),t.font="12px monospace",t.textBaseline="top";let y=b.UE.Color;"HELM"!=l&&(y=(0,w.py)(l.substring(l.length-2)));for(let e=0;e<r.length;e++){const s=r[e],a=o[e],l=y.get(s);if(s!=a){const r=y.get(a),o=f(g,p-7,n,i,t,s,l,0,!0),h=f(g,p+7,n,i,t,a,r,0,!0);g=Math.max(h,o),c&&(c[e]=E(s,a,l,r,p,7,i))}else g=f(g,p,n,i,t,s,l,0,!0,.5);g+=4}t.restore()}function E(t,e,s,n,i,r,o){const a=document.createElement("canvas"),l=a.getContext("2d");l.font="12px monospace";const h=l.measureText(C([t]).join("")).width,c=l.measureText(C([e]).join("")).width,u=Math.max(h,c);return a.height=o,a.width=u+4,l.font="12px monospace",l.textBaseline="top",f(0,i-r,u,o,l,t,s,0,!0),f(0,i+r,u,o,l,e,n,0,!0),a}var M,N,_,P=s(701),L=s(9298);!function(t){t.Unknown="unknown",t.FR="framework",t.CDR="cdr"}(M||(M={})),new class{constructor(){this.regionTypes=[M.CDR],this.chains=["Heavy","Light"],this.skipEmptyPositions=!1,this.fitWidth=!1,this.positionWidth=16,this.positionHeight=L.ES.Entropy}},s(833),function(t){t.STYLE="Style",t.BEHAVIOR="Behavior",t.LAYOUT="Layout",t.DATA="Data"}(N||(N={})),function(t){t.skipEmptyPositions="skipEmptyPositions",t.regionTypes="regionTypes",t.chains="chains",t.fitWidth="fitWidth",t.positionWidth="positionWidth",t.positionHeight="positionHeight"}(_||(_={}));class R extends r.JsViewer{constructor(){super(),this.viewed=!1,this.regionsFg=null,this.regionsRoot=null,this.isOpened=!1,this.panelNode=null,this.regions=[],this.viewPromise=Promise.resolve(),this.detachPromise=Promise.resolve(),this.setDataInProgress=!1,this.host=null,this.filterSourceInput=null,this.mainLayout=null,this.logos=[],this.viewSubs=[],this.calcSizeRequested=!1,this.skipEmptyPositions=this.bool(_.skipEmptyPositions,defaults.skipEmptyPositions,{category:N.DATA}),this.regionTypes=this.stringList(_.regionTypes,defaults.regionTypes,{category:N.DATA,choices:Object.values(vrt).filter((t=>t!=vrt.Unknown))}),this.chains=this.stringList(_.chains,defaults.chains,{category:N.DATA,choices:["Heavy","Light"]}),this.fitWidth=this.bool(_.fitWidth,defaults.fitWidth,{category:N.LAYOUT}),this.positionWidth=this.float(_.positionWidth,defaults.positionWidth,{category:N.LAYOUT,editor:"slider",min:0,max:64,description:"Internal WebLogo viewers property width of position."}),this.positionHeight=this.string(_.positionHeight,defaults.positionHeight,{category:N.LAYOUT,choices:Object.keys(L.ES)})}async init(){this.subs.push((0,P.fromEvent)(this.root,"mousemove").subscribe(this.rootOnMouseMove.bind(this)))}detach(){if(this.setDataInProgress)return;const t=super.detach.bind(this);this.detachPromise=this.detachPromise.then((async()=>{await this.viewPromise,this.viewed&&(await this.destroyView("detach"),this.viewed=!1),t()}))}onTableAttached(){super.onTableAttached(),this.setData(this.dataFrame,this.regions)}onPropertyChanged(t){if(super.onPropertyChanged(t),t){switch(t.name){case _.regionTypes:case _.chains:this.setData(this.dataFrame,this.regions)}switch(t.name){case _.skipEmptyPositions:for(let t=0;t<this.logos.length;++t)for(const e of this.chains)this.logos[t][e].setOptions({[web_logo_viewer.bo.skipEmptyPositions]:this.skipEmptyPositions});this.calcSize();break;case _.fitWidth:case _.positionWidth:this.calcSize();break;case _.positionHeight:for(let t=0;t<this.logos.length;++t)for(const e of this.chains)this.logos[t][e].setOptions({[web_logo_viewer.bo.positionHeight]:this.positionHeight});this.calcSize();break;default:this.setData(this.dataFrame,this.regions)}}else console.warn("Bio: VdRegionsViewer.onPropertyChanged() property is null")}setData(t,e){this.setDataInProgress||(this.setDataInProgress=!0,Dt.logger.debug("Bio: VdRegionsViewer.setData()"),this.viewPromise=this.viewPromise.then((async()=>{this.viewed&&(await this.destroyView("setData"),this.viewed=!1)})).then((async()=>{await this.detachPromise,this.regions=e,this.dataFrame.dart!==t.dart&&(this.dataFrame=t)})).then((async()=>{this.viewed||(await this.buildView("setData"),this.viewed=!0)})).catch((t=>{const e=t instanceof Error?t.message:t.toString(),s=t instanceof Error?t.stack:void 0;n.shell.error(e),Dt.logger.error(e,void 0,s)})).finally((()=>{this.setDataInProgress=!1})))}async destroyView(t){Dt.logger.debug(`Bio: VdRegionsViewer.destroyView( mainLayout = ${this.mainLayout?"value":"none"} ), purpose = '${t}'`),this.filterSourceInput&&i.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){Dt.logger.debug(`Bio: VdRegionsViewer.buildView() begin, purpose = '${t}'`);const e=this.regions.filter((t=>this.regionTypes.includes(t.type))),s=Array.from(new Set(e.map((t=>t.order)))).sort(),n=[];for(let t=0;t<s.length;t++)for(const i of this.chains){const r=e.find((e=>e.order==s[t]&&e.chain==i));n.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});return e.onSizeChanged.subscribe((()=>{this.calcSize()})),[t,i,e]})())}const r=await Promise.all(n);this.logos=new Array(s.length);for(let t=0;t<s.length;++t)this.logos[t]={};for(const[t,e,s]of r)this.logos[t][e]=s,this.viewSubs.push(s.onFreqsCalculated.subscribe((()=>{this.calcSize()})));this.mainLayout=i.table(this.chains,(t=>[...s.length>0?[i.div(t,{style:{transform:"rotate(-90deg)",font:"12px Roboto, Roboto Local, sans-serif",textAlign:"center",width:"16px",marginTop:"24px",marginLeft:"6px"}})]:[],...[...Array(s.length).keys()].map((e=>{const s=this.logos[e][t];return s.root.style.height="100%",i.div([s.root],{style:{marginTop:"4px",marginBottom:"4px"}})}))]),["",...[...Array(s.length).keys()].map((t=>e.find((e=>e.order==s[t]&&e.chain==this.chains[0])).name||"Name"))]),this.mainLayout.className="mlb-vd-regions-viewer-table2",this.filterSourceInput=i.boolInput("",!1,this.filterSourceInputOnValueChanged.bind(this)),this.filterSourceInput.root.style.position="absolute",this.filterSourceInput.root.style.left="10px",this.filterSourceInput.root.style.top="-3px",i.tooltip.bind(this.filterSourceInput.input,"Check to filter sequences for selected VRs"),Math.ceil(255*Math.random()).toString(16),this.host=i.div([this.mainLayout,this.filterSourceInput.root],{}),this.root.appendChild(this.host),this.root.style.overflowX="auto",this.calcSize(),this.viewSubs.push(i.onSizeChanged(this.root).subscribe(this.rootOnSizeChanged.bind(this))),Dt.logger.debug("Bio: VdRegionsViewer.buildView() end")}calcSize(){Dt.logger.debug("Bio: VdRegionsViewer.calcSize(), start");const t=()=>{if(!this.host)return;const t=(this.root.clientHeight-54)/this.chains.length;for(let e=0;e<this.logos.length;e++){for(const s of this.chains)this.logos[e][s].root.style.height=`${t}px`;Math.max(...this.chains.map((t=>this.logos[e][t].Length)))}if(this.fitWidth)this.logos.length,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({[web_logo_viewer.bo.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=1==this.filterSourceInput.value?L.Ct.Selected:L.Ct.Filtered;for(let e=0;e<this.logos.length;e++)for(let s=0;s<this.chains.length;s++){const n=this.chains[s];this.logos[e][n].setOptions({[web_logo_viewer.bo.filterSource]:t})}}}var x=s(7656),I=s(7983),O=s(489);async function F(t){const e=T.Cn.getOrCreate(t.seqCol),s=e.isMsa()?O.U.HAMMING:O.U.LEVENSHTEIN,n=t.seqCol.toList();if(e.getAlphabetIsMultichar()){const s=e.getSplitter(),i=n.length;let r=36;const o=new Map;for(let e=0;e<i;e++){const i=n[e];if(null===n[e]||t.seqCol.isNone(e)){n[e]=null;continue}n[e]="";const a=s(i);for(let t=0;t<a.length;t++){const s=a[t];o.has(s)||(o.set(s,String.fromCharCode(r)),r++),n[e]+=o.get(s)}}}const i=await(0,x.I)(n,t.methodName,s,t.options,!0),o=t.embedAxesNames.map(((t,e)=>r.Column.fromFloat32Array(t,i.embedding[e])));return{distance:i.distance,coordinates:new r.ColumnList(o)}}function D(t){const e=["Embed_X","Embed_Y"],s=t.columns.names().filter((t=>t.includes(e[0]))).length+1;return e.map((t=>`${t}_${s}`))}var G=s(5697),k=s(3379),H=s.n(k),W=s(7795),B=s.n(W),V=s(569),U=s.n(V),$=s(3565),Y=s.n($),K=s(9216),q=s.n(K),Z=s(4589),z=s.n(Z),X=s(9414),j={};j.styleTagTransform=z(),j.setAttributes=Y(),j.insert=U().bind(null,"head"),j.domAPI=B(),j.insertStyleElement=q(),H()(X.Z,j),X.Z&&X.Z.locals&&X.Z.locals;var Q=s(3914),J=s(6254);let tt=0;const et="cliffsDf",st=new P.Subject,nt="act_diff",it="sali",rt="sim",ot="line_index",at=["1_seq","2_seq"],lt="filterCliffs";function ht(t,e,s){const n=e.getBoundingClientRect(),i=t.clientX-n.left,r=t.clientY-n.top;let o=null,a=0;for(const t of s){const e=Math.abs(Math.hypot(t.a[0]-i,t.a[1]-r)+Math.hypot(t.b[0]-i,t.b[1]-r)-Math.hypot(t.a[0]-t.b[0],t.a[1]-t.b[1]));(!a&&e<2||e<a)&&(a=e,o=t)}return o}var ct=s(1040);async function ut(t,e,s,i,o){e.version!==e.temp["last-invalidated-version"]&&await(0,I.HV)(e,!1);const a=r.DataFrame.create(e.length);return a.columns.addNewString(i).init((t=>e.temp["monomeric-mols"].get(t))),await n.functions.call("Chem:getChemSimilaritiesMatrix",{dim:t,col:e.temp["monomeric-mols"],df:a,colName:i,simArr:o})}function mt(t){const e=i.divH([]),s=i.divV([i.divText(t.seqCol.name),i.divText(t.activityCol.name)]);return s.style.fontWeight="bold",s.style.display="flex",s.style.justifyContent="space-between",e.append(s),t.line.mols.forEach(((s,n)=>{const r=i.divText(t.activityCol.get(s).toFixed(2));r.style.display="flex",r.style.justifyContent="left",r.style.paddingLeft="30px",e.append(i.divV([i.divText(t.seqCol.get(s)),r]))})),e}function dt(t){const e=i.div();e.append(i.divText(t.seqCol.name,{style:{fontWeight:"bold"}}));const s=new Array(2),n=new Array(2);t.line.mols.forEach(((e,i)=>{s[i]=t.seqCol.get(e),n[i]=t.activityCol.get(e)}));const r={},o=T.Cn.getOrCreate(t.seqCol),a=o.getSplitter(),l=function(t,e,s,n){const i=document.createElement("canvas"),r=i.getContext("2d");return i.height=30,v(r,0,0,0,30,t,e,s,!0,n),i}(a(s[0]),a(s[1]),o.units,r);return e.append(i.div(l,{style:{width:"300px",overflow:"scroll"}})),e.append(function(t){const e=i.div();if(Object.keys(t).length>0){const s=i.divV([]);s.append(i.divH([i.divText("Pos",{style:{fontWeight:"bold",width:"30px",borderBottom:"1px solid"}}),i.divText("Difference",{style:{fontWeight:"bold",borderBottom:"1px solid"}})]));for(const e of Object.keys(t))t[e].style.borderBottom="1px solid lightgray",s.append(i.divH([i.divText((parseInt(e)+1).toString(),{style:{width:"30px",borderBottom:"1px solid lightgray"}}),t[e]]));e.append(s)}return e}(r)),e.append(gt("Activity delta",Math.abs(n[0]-n[1]))),e.append(gt("Cliff",t.sali)),e}function gt(t,e){return i.divH([i.divText(`${t}: `,{style:{fontWeight:"bold",paddingRight:"5px"}}),i.divText(e.toFixed(2))],{style:{paddingTop:"10px"}})}function ft(t,e){const s=r.Column.string("seq_diff",t.rowCount).init((s=>`${t.get(e[0],s)}#${t.get(e[1],s)}`));s.semType="MacromoleculeDifference",s.setTag(r.TAGS.UNITS,t.col(e[0]).getTag(r.TAGS.UNITS)),s.setTag("separator",t.col(e[0]).getTag("separator")),t.columns.add(s);const n=t.plot.grid();return n.col(e[0]).visible=!1,n.col(e[1]).visible=!1,n}s(7861),s(4004);var pt=s(7228),yt=s(8601),wt=s(5226);s(9133);class bt extends r.JsViewer{constructor(t){super(),this.name="",this.metricsProperties=["distanceMetric","fingerprint"],this.fingerprintChoices=["Morgan","Pattern"],this.initialized=!1,this.tags=[r.TAGS.UNITS,"aligned","separator","alphabet"],this.preComputeDistanceMatrix=!1,this.renderPromise=Promise.resolve(),this.fingerprint=this.string("fingerprint",this.fingerprintChoices[0],{choices:this.fingerprintChoices}),this.limit=this.int("limit",10),this.distanceMetric=this.string("distanceMetric",G.kg[0],{choices:G.kg}),this.moleculeColumnName=this.string("moleculeColumnName"),this.name=t}init(){this.initialized=!0}detach(){this.subs.forEach((t=>t.unsubscribe()))}async onTableAttached(){if(this.init(),this.dataFrame){this.preComputeDistanceMatrix=this.dataFrame.rowCount<=22e3,this.subs.push(r.debounce(this.dataFrame.onRowsRemoved,50).subscribe((t=>this.render(!0))));const t="diversity"!==this.name;this.subs.push(r.debounce(this.dataFrame.onCurrentRowChanged,50).subscribe((e=>this.render(t)))),this.subs.push(r.debounce(this.dataFrame.selection.onChanged,50).subscribe((t=>this.render(!1)))),this.subs.push(r.debounce(i.onSizeChanged(this.root),50).subscribe((t=>this.render(!1)))),this.moleculeColumn=this.dataFrame.columns.bySemType(r.SEMTYPE.MACROMOLECULE),this.moleculeColumnName=this.moleculeColumn?.name,this.getProperty("limit").fromOptions({min:1,max:this.dataFrame.rowCount})}this.render()}onPropertyChanged(t){if(super.onPropertyChanged(t),this.initialized){if("moleculeColumnName"===t.name){const e=this.dataFrame.col(t.get(this));e.semType===r.SEMTYPE.MACROMOLECULE&&(this.moleculeColumn=e)}this.render()}}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.dataFrame&&this.moleculeColumnName&&this.dataFrame.col(this.moleculeColumnName).semType!==r.SEMTYPE.MACROMOLECULE&&(n.shell.error(`${this.moleculeColumnName} is not Macromolecule type`),1))}}s(7241),s(4293),s(9943),s(4413);var Tt=s(1061),Ct=s(5490),St=s(116);r.SEMTYPE.MOLECULE,r.SEMTYPE.MACROMOLECULE;var At,vt=s(8457);async function Et(t,e,s,n){const i=(0,vt.O)(e),o=(0,l.vU)(e.getTag(r.TAGS.UNITS),e.getTag("separator"))(s),a=n===At.IDENTITY?function(t,e){const s=e.columns.length,n=new Array(s),i=new Array(s),o=new Array(s);for(let r=0;r<s;++r){const s=e.columns.byIndex(r);n[r]=s.getRawData(),i[r]=s.categories.indexOf(""),o[r]=s.categories.indexOf(t[r]??"")}const a=r.Column.float("Identity",e.rowCount),l=a.getRawData();for(let s=0;s<e.rowCount;++s){l[s]=0;for(let e=0;e<t.length;++e)n[e][s]===o[e]&&++l[s];l[s]/=t.length}return a}(o,i):n===At.SIMILARITY?await async function(t,e){const s=e.columns.toList();return await(0,pt.Qx)(s,t)}(o,i):null;if(null===a)throw new Error(`In bio library: Unkown sequence scoring method: ${n}`);return a.name=t.columns.getUnusedName(a.name),t.columns.add(a),a}!function(t){t.IDENTITY="identity",t.SIMILARITY="similarity"}(At||(At={}));var Mt,Nt=function(t,e,s,n){return new(s||(s=Promise))((function(i,r){function o(t){try{l(n.next(t))}catch(t){r(t)}}function a(t){try{l(n.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(o,a)}l((n=n.apply(t,e||[])).next())}))};class _t{constructor(t,e,s=!1,n){var 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=i.div([],{id:"demo-script",classes:"tutorials-root tutorials-track demo-app-script"}),this._steps=[],this._mainHeader=i.panel([],"tutorials-main-header"),this._header=i.h2(""),this._headerDiv=i.divH([],"tutorials-root-header"),this._stopStartBtn=i.button(i.iconFA("pause"),(()=>this._changeStopState()),"Play / pause"),this._restartBtn=i.button(i.iconFA("redo"),(()=>this._restartScript()),"Restart"),this._nextStepBtn=i.button(i.iconFA("play"),(()=>{this._isStepProcessed||this._nextStep()}),"Next step"),this._activity=i.panel([],"tutorials-root-description"),this._progressDiv=i.divV([],"tutorials-root-progress"),this._progress=i.element("progress"),this._progressSteps=i.divText(""),this._closeBtn=i.button(i.iconFA("chevron-left"),(()=>this._closeDock()),"Back to demo"),this.name=t,this.description=e,this._isAutomatic=s,this._autoStartFirstStep=null!==(r=null==n?void 0:n.autoStartFirstStep)&&void 0!==r&&r,this._progress.max=0,this._progress.value=1,_t.currentObject=this}get steps(){return this._steps}get stepNumber(){return this._steps.length}_addHeader(){this._createHeaderDiv(),this._createProgressDiv(),this._mainHeader.append(this._headerDiv,this._progressDiv)}_createHeaderDiv(){this._header.innerText=this.name,this._headerDiv.append(this._closeBtn),this._headerDiv.append(this._header),this._nextStepBtn.firstChild.className="grok-icon fas fa-play",this._headerDiv.append(this._isAutomatic?this._stopStartBtn:this._nextStepBtn)}_createProgressDiv(){this._progress.max=this.stepNumber,this._progressDiv.append(this._progress),this._progressSteps=i.divText(`Step: ${this._progress.value} of ${this.stepNumber}`),this._progressDiv.append(this._progressSteps)}_addDescription(){var t;this._activity.append(i.div(this.description,"tutorials-root-description"));for(let e=0;e<this.stepNumber;e++){let s=i.iconFA("clock");this._isAutomatic||0===e&&(s=i.iconFA("play",(()=>this._nextStep()),"Next step"),s.className="grok-icon fas fa-play");const n=i.div(this._steps[e].name,"grok-tutorial-entry-instruction"),r=i.div(null===(t=this._steps[e].options)||void 0===t?void 0:t.description,"grok-tutorial-step-description hidden"),o=i.divH([s,n],"grok-tutorial-entry");this._activity.append(o,r)}}_initRoot(){var t,e,s;n.shell.windows.showContextPanel=!0,n.shell.windows.showHelp=!1;const i=Array.from(n.shell.dockManager.rootNode.children)[0];this._node=n.shell.dockManager.dock(this._root,r.DOCK_TYPE.FILL,i,""),(null===(e=null===(t=i.parent.container.containerElement.firstElementChild)||void 0===t?void 0:t.lastElementChild)||void 0===e?void 0:e.classList.contains("tab-handle-list-container"))&&(null===(s=i.parent.container.containerElement.firstElementChild)||void 0===s||s.lastElementChild.remove()),this._node.container.containerElement.classList.add("tutorials-demo-script-container"),this._addHeader(),this._root.append(this._mainHeader),this._addDescription(),this._root.append(this._activity)}_nextStep(){var t,e;return Nt(this,void 0,void 0,(function*(){this._isStepProcessed=!0,this._isAutomatic||(this._nextStepBtn.classList.add("disabled"),this._nextStepBtn.firstChild.classList.add("fa-disabled"));const s=this._activity.getElementsByClassName("grok-tutorial-entry")[this._currentStep],n=this._activity.getElementsByClassName("grok-icon")[this._currentStep],r=this._activity.getElementsByClassName("grok-tutorial-step-description")[this._currentStep];n.className="grok-icon far fa-spinner-third fa-spin",r.classList.remove("hidden"),r.classList.add("visible");const o=s,a=(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;yield this._steps[this._currentStep].func(),this._scrollTo(this._root,o.offsetTop-this._mainHeader.offsetHeight),this._isAutomatic&&(yield this._countdown(s,n,a),yield(0,Tt.gw)(a));const l=i.iconFA("check");if(n.replaceWith(l),l.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=i.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")}}else this._isAutomatic?this._stopStartBtn.replaceWith(this._restartBtn):this._nextStepBtn.replaceWith(this._restartBtn)}))}_startScript(){return Nt(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,s){return Nt(this,void 0,void 0,(function*(){const n=i.div([],"demo-script-countdown");e.classList.add("hidden");let r=s/1e3;const o=this._createSVGIndicator(r);n.append(o),t.prepend(n);const a=setInterval((()=>{r--,0===r&&(clearInterval(a),n.remove(),e.classList.remove("hidden"),e.classList.add("visible"))}),1e3)}))}_createSVGIndicator(t){const e=document.createElementNS("http://www.w3.org/2000/svg","svg"),s=document.createElementNS("http://www.w3.org/2000/svg","circle");return s.setAttributeNS(null,"cx","7"),s.setAttributeNS(null,"cy","7"),s.setAttributeNS(null,"r","6"),s.setAttributeNS(null,"style",`animation: countdown ${t}s linear infinite forwards`),e.append(s),e}_changeStopState(){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||this._startScript())}_restartScript(){n.shell.dockManager.close(this._node),n.shell.closeAll(),this._clearRoot(),this._setInitParams(),this.start()}_clearRoot(){this._root=i.div([],{id:"demo-script",classes:"tutorials-root tutorials-track demo-app-script"}),this._mainHeader=i.panel([],"tutorials-main-header"),this._header=i.h2(""),this._headerDiv=i.divH([],"tutorials-root-header"),this._activity=i.panel([],"tutorials-root-description"),this._progressDiv=i.divV([],"tutorials-root-progress"),this._progress=i.element("progress"),this._progressSteps=i.divText(""),this._progress.max=0,this._progress.value=1}_setInitParams(){this._currentStep=0,this._isStopped=!1,this._isCancelled=!1,this._stopStartBtn.getElementsByClassName("grok-icon")[0].className="grok-icon fal fa-pause",this._nextStepBtn.classList.remove("disabled")}_closeDock(){n.shell.dockManager.close(this._node),this.cancelScript()}cancelScript(){this._isCancelled=!0,_t.currentObject=null}step(t,e,s){return this._steps[this.steps.length]={name:t,func:e,options:s},this}start(){return Nt(this,void 0,void 0,(function*(){this._initRoot(),n.shell.newView(this.name),this._isAutomatic?this._startScript():this._autoStartFirstStep&&(yield this._nextStep())}))}}_t.currentObject=null,function(t){t.X="Embed_X",t.Y="Embed_Y"}(Mt||(Mt={})),s(1811),s(3336),s(8341);var Pt=s(2568);s(525),s(9416),new class{constructor(){this.tooltipHandlerTemp="tooltip-handler.Monomer"}};class Lt extends r.GridCellRenderer{get name(){return constants.Of.MONOMER}get cellType(){return constants.Of.MONOMER}get defaultHeight(){return 15}get defaultWidth(){return 40}render(t,e,s,n,i,r,o){if(r.gridRow<0)return;MonomerTooltipHandler.getOrCreate(r.gridColumn),t.font="12px monospace",t.textBaseline="middle",t.textAlign="center";const a=(0,w.py)(r.cell.column.getTag("alphabet")),l=r.cell.value;if(!l)return;const h=a.get(l);t.fillStyle=h,t.fillText((0,w.GU)(l,6),e+n/2,s+i/2,n)}}class Rt extends r.Package{constructor(){super(...arguments),this._initialized=!1}get properties(){return this._properties}set properties(t){this._properties=t}get initialized(){return this._initialized}completeInit(){this._initialized=!0}handleErrorUI(t){const e=t instanceof Error?t.message:t.toString(),s=t instanceof Error?t.stack:void 0;n.shell.error(e),this.logger.error(e,void 0,s)}}class xt extends r.Widget{constructor(t){super(i.div([],{}));const e=Object.assign({},...t.map((t=>({[t.name]:t}))));this.maxMonomerLengthProp=e.MaxMonomerLength,this.tooltipWebLogo=e.TooltipWebLogo,this.defaultSeparator=e.DefaultSeparator}async init(){const t=i.intInput("Max monomer length",Dt.properties.MaxMonomerLength,(t=>{Dt.properties.MaxMonomerLength=t})),e=i.boolInput("Tooltip WebLogo",Dt.properties.TooltipWebLogo,(t=>{Dt.properties.TooltipWebLogo=t})),s=i.choiceInput("Default Separator",Dt.properties.DefaultSeparator,[".","/","-"],(t=>{Dt.properties.DefaultSeparator=t}));this.root.appendChild(i.form([t,e,s]))}}var It=s(5362),Ot={};Ot.styleTagTransform=z(),Ot.setAttributes=Y(),Ot.insert=U().bind(null,"head"),Ot.domAPI=B(),Ot.insertStyleElement=q(),H()(It.Z,Ot),It.Z&&It.Z.locals&&It.Z.locals;class Ft extends r.Widget{constructor(t){super(i.divV([])),this.viewed=!1,this.seqCol=t}async init(){const t=T.Cn.getOrCreate(this.seqCol),e=Dt.properties.TooltipWebLogo,s=this.seqCol.getTag(L.DX.tooltipWebLogo);!1===e||["false","off","disable","disabled"].includes(s)||(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}),this.wlViewer.root.style.height="50px",this.root.appendChild(this.wlViewer.root),this.root.style.width="100%")}}r.DataFrame.fromCsv("seq,value\nATCCGTCGT,0.5\nTGTTCGTCA,0.4\nATGGTCGTA,0.7\nATCCGTGCA,0.1"),["1","1A","1C","2","4","4A","4B","5","6"].join(w.CI);const Dt=new Rt;function Gt(){return Ct.NT.instance}function kt(){return Ct.NT.instance.getBioLib()}async function Ht(t,e,o,a,l,h){if(!(0,Pt.n)(e,"Activity Cliffs"))return;const c=D(t),u={units:e.getTag(r.TAGS.UNITS),aligned:e.getTag("aligned"),separator:e.getTag("separator"),alphabet:e.getTag("alphabet")},m=T.Cn.getOrCreate(e);let d=ct.gk.Tanimoto,g=e;if(m.isFasta()||m.isSeparator()&&m.alphabet&&"UN"!==m.alphabet)if(m.isFasta())d=m.getDistanceFunctionName();else{g=m.convert(w.r2.FASTA);const t=T.Cn.getOrCreate(g);d=t.getDistanceFunctionName(),u.units=w.r2.FASTA}const f=async()=>await async function(t,e,o,a,l,h,c,u,m,d,g,f,p,y,w,b,T,C){tt++;const S=c/100,A=o??e;let v=!1,E=!1;const M={};let N,_;const P={seqCol:A,methodName:m,similarityMetric:u,embedAxesNames:a,options:T},{distance:L,coordinates:R}=await f(P);for(const e of R)t.columns.add(e);let x=L;const I=Object.values(O.U).map((t=>t.toString())).includes(u);I&&!L&&(x=Q.H.calc(e.toList(),O.o[u]()).data);const F=function(t,e,s){const n=[],i=[],r=[],o=[],a=new Set;for(let l=0;l!=t.length;++l)for(let h=0;h!=t.length-l;++h){const c=t[l]?t[l].get(h):0;if(c>=e){r.push(l),o.push(l+h+1),a.add(l),a.add(l+h+1),n.push(c);const t=Math.abs(s.get(l)-s.get(l+h+1));i.push(1!=c?t/(1-c):1/0)}}return{simVals:n,saliVals:i,n1:r,n2:o,cliffsMolIds:a}}(await async function(t,e,s,n){const i=t.categories,o=t.getRawData(),a=r.Column.string("seq",t.length).init((t=>i[o[t]])),l=r.DataFrame.fromColumns([a]),h=t.length;let c=Array(h-1);return s&&e?function(t,e,s){const n=(0,J.y)(t);for(let i=0;i<t-1;++i){const o=new Float32Array(t-i-1).fill(0);for(let s=i+1;s<t;++s){const t=n(i,s);o[s-i-1]=e[t]===r.FLOAT_NULL?0:(0,G.Om)(e[t])}s[i]=r.Column.fromFloat32Array("similarity",o)}}(h,e,c):c=await n(h,t,l,"seq",c),c}(A,x,I,p),S,h),D=function(t,e,s,n,i,o){const a=new Array(t).fill(0);for(let t=0;t!=s.length;++t)e[t]!=1/0&&(o.get(s[t])>o.get(n[t])?a[s[t]]+=e[t]:a[n[t]]+=e[t]);return r.Column.fromList("double",`sali_${i[0].substring(i[0].lastIndexOf("_"))}`,a)}(A.length,F.saliVals,F.n1,F.n2,a,h);t.columns.add(D);const k=function(t,e){const s="containsCliff",n=t.columns.names().filter((t=>t.includes(s))).length+1,i=`${s}_${n}`;return r.Column.bool(i,t.rowCount).init((t=>e.has(t)))}(t,F.cliffsMolIds);t.columns.add(k);const H=function(t){const e=t.filter((t=>t!==1/0)),s=Math.min(...e);return{max:Math.max(...e),min:s}}(F.saliVals),W=.8/(H.max-H.min),B=n.shell.getTableView(t.name);B.grid.columns.byName(k.name).visible=!1;const V=B.addViewer(r.VIEWER.SCATTER_PLOT,{xColumnName:a[0],yColumnName:a[1],size:D.name,color:h.name,showXSelector:!1,showYSelector:!1,showSizeSelector:!1,showColorSelector:!1,markerMinSize:5,markerMaxSize:25,title:l}),U=V.getInfo().canvas,$=function(t,e,s,n,i){const o=new Array(t.n1.length).fill(null);for(let e=0;e<t.n1.length;e++){const s=t.n1[e],n=t.n2[e];o[e]={id:e,mols:[s,n],selected:!1,a:[],b:[]}}const a=r.DataFrame.create(o.length);return at.forEach(((t,s)=>{a.columns.addNewString(t).init((t=>e.get(o[t].mols[s]))),function(t,e){Object.keys(e).forEach((s=>{t.tags[s]=e[s]}))}(a.col(t),i),a.col(t).semType=n})),a.columns.addNewFloat(nt).init((t=>Math.abs(s.get(o[t].mols[0])-s.get(o[t].mols[1])))),a.columns.addNewInt(ot).init((t=>t)),a.columns.addNewFloat(it).init((e=>t.saliVals[e])),a.columns.addNewFloat(rt).init((e=>t.simVals[e])),a.name=`${et}${tt}`,{lines:o,linesDf:a}}(F,e,h,d,g),Y=b?b($.linesDf,at).sort([it],[!1]):$.linesDf.plot.grid().sort([it],[!1]);t.temp[".cliffsDfGrid"]=Y;const K=i.button(`${$.linesDf.rowCount} cliffs`,(()=>{B.dockManager.dock(Y,"down",null,"Activity cliffs",C??.2)}));K.classList.add("scatter_plot_link","cliffs_grid"),V.root.append(K);const q=i.switchInput("Show only cliffs",!1,(()=>{q.value?(V.dataFrame.setTag(lt,k.name),t.rows.match({[k.name]:!0}).filter(),st.next(k.name)):(V.dataFrame.setTag(lt,""),t.filter.setAll(!0,!0),st.next(""))}));q.root.classList.add("scatter_plot_link","show_only_cliffs"),V.root.append(q.root),st.subscribe((t=>{q.enabled=""===t||t===k.name}));const Z=n.events.onViewerClosed.subscribe((t=>{t.args.viewer===V&&(B.dockManager.close(Y.root),Z.unsubscribe(),B.subs=B.subs.filter((t=>t!==Z)))}));return B.subs.push(Z),$.linesDf.onCurrentCellChanged.subscribe((()=>{v=!0;const s=$.linesDf.currentCol&&$.linesDf.currentCol.name===at[1]?1:0,r=-1!==$.linesDf.currentRowIdx?$.lines[$.linesDf.currentRowIdx]:null;V.dataFrame.currentRowIdx=r?r.mols[s]:-1,V.dataFrame.filter.set(0,!$.lines[0].selected),V.dataFrame.filter.set(0,$.lines[0].selected),r&&setTimeout((()=>{!function(t,e,s,r,o,a,l,h){const c=e.getPane("Cliff Details");i.empty(c.root);const u=h({cashedData:s,line:r,df:t,seqCol:o,activityCol:a,sali:l});c.root.append(u),setTimeout((()=>{n.shell.o=e.root}),500)}(t,N,M,r,e,h,$.linesDf.get(it,r.id),w);const s=V.dataFrame.getSortedOrder(B.grid.sortByColumns,B.grid.sortTypes);B.grid.scrollToCell(e.name,s.indexOf(V.dataFrame.currentRowIdx))}),1e3)})),$.linesDf.onSelectionChanged.subscribe((e=>{if(!1===$.linesDf.selection.anyTrue)$.lines.forEach((t=>{t.selected=!1}));else if(-1!==$.linesDf.mouseOverRowIdx){const t=$.lines[$.linesDf.mouseOverRowIdx];t.selected=!t.selected}setTimeout((()=>{const e=r.BitSet.create(t.rowCount);$.lines.forEach((t=>{t.selected&&t.mols.forEach((s=>{e.set(s,t.selected,!0)}))})),t.selection.copyFrom(e),B.grid.invalidate()}),300)})),t.onSelectionChanged.subscribe((e=>{E?E=!1:!1===t.selection.anyTrue&&"number"==typeof e&&($.lines.forEach((t=>{t.selected=!1})),Y.dataFrame.selection.setAll(!1,!1),Y.invalidate())})),U.addEventListener("mousemove",(function(n){clearTimeout(_),_=s.g.setTimeout((function(){const s=ht(n,U,$.lines);s&&-1===t.mouseOverRowIdx&&i.tooltip.show(y({cashedData:M,line:s,df:t,seqCol:e,activityCol:h}),n.clientX,n.clientY)}),500)})),U.addEventListener("mousedown",(function(e){E=!0;const s=ht(e,U,$.lines);if(s&&-1===t.mouseOverRowIdx){e.ctrlKey?(s.selected=!s.selected,$.linesDf.selection.set(s.id,s.selected)):$.linesDf.currentRowIdx!==s.id&&($.linesDf.currentRowIdx=s.id,t.currentRowIdx=s.mols[0],t.filter.set(0,!$.lines[0].selected),t.filter.set(0,$.lines[0].selected));const n=$.linesDf.getSortedOrder(Y.sortByColumns,Y.sortTypes);Y.scrollToCell(at[0],n.indexOf(s.id))}})),V.onEvent("d4-before-draw-scene").subscribe((e=>{const s=function(t,e,s,n,i,r,o){const a=n.lines,l=t.getInfo().canvas.getContext("2d"),h=t.dataFrame.columns.byName(e),c=t.dataFrame.columns.byName(s);for(let e=0;e<a.length;e++){const s=t.worldToScreen(h.get(a[e].mols[0]),c.get(a[e].mols[0])),u=t.worldToScreen(h.get(a[e].mols[1]),c.get(a[e].mols[1]));a[e].a=[s.x,s.y],a[e].b=[u.x,u.y];const m=new Path2D;m.moveTo(a[e].a[0],a[e].a[1]);const d=a[e].selected?"255,255,0":"0,128,0",g=i[e]===1/0?1:.2+(i[e]-o)*r;l.strokeStyle=`rgba(${d},${g})`,l.lineWidth=a[e].id===n.linesDf.currentRowIdx?3:1,m.lineTo(a[e].b[0],a[e].b[1]),l.stroke(m)}return a}(V,a[0],a[1],$,F.saliVals,W,H.min);if(v){const t=s[$.linesDf.currentRowIdx];setTimeout((()=>{const{zoomLeft:e,zoomRight:s,zoomTop:n,zoomBottom:i}=function(t,e,s,n,i,r){const o=Math.abs(s-i),a=Math.abs(n-r),l=t/o,h=e/a,c=Math.min(l,h),u=t/c*5,m=e/c*5,d=(s<i?s:i)+o/2-u/2,g=(n>r?n:r)-a/2+m/2;return{zoomLeft:d,zoomRight:d+u,zoomTop:g,zoomBottom:g-m}}(V.viewport.width,V.viewport.height,V.dataFrame.get(a[0],t.mols[0]),V.dataFrame.get(a[1],t.mols[0]),V.dataFrame.get(a[0],t.mols[1]),V.dataFrame.get(a[1],t.mols[1]));V.zoom(e,n,s,i)}),300),v=!1}q.value?t.rows.match({[k.name]:!0}).filter():!0===q.enabled&&t.filter.setAll(!0,!1)})),V.addProperty("similarityLimit","double",S),N=function(){const t=i.accordion(),e=i.element("i");return e.className="grok-icon svg-icon svg-view-layout",t.addTitle(i.span([e,i.label("Activity cliffs")])),t.addPane("Cliff Details",(()=>i.divText("Cliff has not been selected")),!0),n.shell.o=t.root,t}(),V}(t,g,null,c,"Activity cliffs",o,a,d,l,r.SEMTYPE.MACROMOLECULE,u,F,ut,mt,dt,ft,h),p=l===St.AL.UMAP?5e3:2e3;if(t.rowCount>2e4)n.shell.warning("Too many rows, maximum for sequence activity cliffs is 20000");else{if(!(t.rowCount>p))return await f();i.dialog().add(i.divText("Activity cliffs analysis might take several minutes.\n Do you want to continue?")).onOK((async()=>{const t=r.TaskBarProgressIndicator.create("Running sequence activity cliffs ..."),e=await f();return t.close(),e})).show()}}async function Wt(t,e,s,o=ct.gk.Tanimoto,a,l,h){if(await(0,Tt.gw)(10),!(0,Pt.n)(e,"Sequence space"))return;const c=D(t),u=r.DataFrame.fromColumns([e]).clone(),m=function(t,e){const s=e.categories.map(((t,e)=>t?null:e)).filter((t=>null!==t)),n=[...e.getRawData()],i=[];let r=0;for(let e=0;e<t.rowCount;e++)s.includes(n[e])&&(t.rows.removeAt(e-r),i.push(e),r+=1);return i}(u,e),d={seqCol:u.col(e.name),methodName:s,similarityMetric:o,embedAxesNames:c,options:{...h,sparseMatrixThreshold:l??.8,usingSparseMatrix:t.rowCount>2e4}},g=s===St.AL.UMAP?1e5:15e3,f=s===St.AL.UMAP?5e3:2e3;if(t.rowCount>g)n.shell.warning(`Too many rows, maximum for sequence space is ${g}`);else{if(!(t.rowCount>f))return p(await F(d));i.dialog().add(i.divText("Sequence space analysis might take several minutes.\n Do you want to continue?")).onOK((async()=>{const t=r.TaskBarProgressIndicator.create("Running Sequence space..."),e=await F(d);return t.close(),p(e)})).show()}function p(e){const s=e.coordinates;for(const e of s){const s=e.toList();m.forEach((t=>s.splice(t,0,null))),t.columns.add(r.Column.float(e.name,t.rowCount).init((t=>s[t])))}if(a)return n.shell.tableView(t.name).scatterPlot({x:c[0],y:c[1],title:"Sequence space"})}}async function Bt(t,e){if(0===r.Func.find({package:"Chem",name:"getRdKitModule"}).length)return void n.shell.warning('Transformation to atomic level requires package "Chem" installed.');if(!(0,Pt.n)(e,"To Atomic Level"))return;const s=(await Gt()).getBioLib(),o=await(0,yt.i0)(t,e,s);null!==o.col&&(t.columns.add(o.col,!0),await n.data.detectSemanticTypes(t)),o.warnings&&o.warnings.length>0&&n.shell.warning(i.list(o.warnings))}function Vt(t){return new wt.i(t).importFasta()}function Ut(t){const e=T.Cn.getOrCreate(t).stats;return Object.keys(e.freq)}async function $t(t,e,s){return Et(t,e,s,At.IDENTITY)}async function Yt(t,e,s){return Et(t,e,s,At.SIMILARITY)}},7983:(t,e,s)=>{"use strict";s.d(e,{HV:()=>c,QF:()=>h,pf:()=>l});var n=s(4469),i=(s(3870),s(976)),r=s(7241),o=(s(4293),s(1061)),a=s(8447);function l(t,e,s){const n=s?function(t,e){const s=`${e}`.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),n=t.charAt(0)===e,i=t.charAt(t.length-1)===e,r=t.replace(new RegExp(`^${s}|${s}$`,"g"),"");return n?i?`${s}${r}${s}`:`${s}${r}${s}|${s}${r}$`:i?`^${r}${s}|${s}${r}${s}`:`^${r}${s}|${s}${r}${s}|${s}${r}$`}(t,s):t,r=i.BitSet.create(e.length);for(let s=0;s<e.length;s++){const i=e.get(s);(i.match(n)||i===t)&&r.set(s,!0,!1)}return r}async function h(t,e){e.version!==e.temp["last-invalidated-version"]&&await c(e,!0);const s=i.Column.string("helm",1).init((e=>t));s.semType=i.SEMTYPE.MACROMOLECULE,s.setTag(i.TAGS.UNITS,a.r2.HELM);const o=await(0,r.D)(s,!0,e.temp["monomers-dict"]);return(await n.functions.call("Chem:searchSubstructure",{molStringsColumn:e.temp["monomeric-mols"],molString:o.get(0),molBlockFailover:""})).get(0)}async function c(t,e){const s=i.TaskBarProgressIndicator.create(`Invalidating molfiles for ${t.name}`);await(0,o.gw)(10);const n=new Map,a=await(0,r.D)(t,e,n);t.temp["monomeric-mols"]=a,t.temp["monomers-dict"]=n,t.temp["last-invalidated-version"]=t.version,s.close()}},2568:(t,e,s)=>{"use strict";s.d(e,{l:()=>a,n:()=>o});var n=s(4469),i=s(976),r=s(499);function o(t,e,s=[],i=[],r=!0){const[o,l]=a(t,e,s,i);return r&&!o&&n.shell.warning(l),o}function a(t,e,s=[],o=[]){let a=!0,l="";const h=r.Cn.getOrCreate(t);if(t.semType!==i.SEMTYPE.MACROMOLECULE)n.shell.warning(e+" analysis is allowed for Macromolecules semantic type"),a=!1;else{const t=h.notation;if(s.length>0&&!s.some((e=>t.toUpperCase()==e.toUpperCase())))l=`${e} + ' analysis is allowed for Macromolecules with notation ${0==s.length?"any notation":`notation${s.length>1?"s":""} ${s.map((t=>`"${t}"`)).join(", ")} `}.`,a=!1;else if(!h.isHelm()){const t=h.alphabet;o.length>0&&!o.some((e=>t.toUpperCase()==e.toUpperCase()))&&(l=`${e} + ' analysis is allowed for Macromolecules with alphabet ${0==o.length?"any alphabet":`alphabet${o.length>1?"s":""} ${o.map((t=>`"${t}"`)).join(", ")}.`}.`,a=!1)}}return[a,l]}},3553:(t,e,s)=>{"use strict";s.d(e,{Of:()=>r,WY:()=>c,jB:()=>u,mU:()=>a,rs:()=>h});var n,i,r,o=s(8341);!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"}(n||(n={})),function(t){t.AAR="AAR",t.POSITION="Pos",t.SELECTION="selection"}(i||(i={})),function(t){t.MONOMER="Monomer",t.MACROMOLECULE_DIFFERENCE="MacromoleculeDifference",t.ACTIVITY="activity",t.ACTIVITY_SCALED="activityScaled"}(r||(r={}));const a="MSA";var l,h;!function(t){t.CELL_CHANGING="isCellChanging"}(l||(l={})),function(t){t.SEPARATOR="."}(h||(h={}));const c="3.3.1",u={pepsea:{gapOpen:1.53,gapExtend:0,method:o.J[0]},kalign:{gapOpen:-1,gapExtend:-1,terminalGap:-1}}},4004:(t,e,s)=>{"use strict";s.d(e,{o:()=>r}),s(976),s(3870);var n=s(4469),i=(s(3336),s(8447),s(499));async function r(t,e,s){const r=i.Cn.getOrCreate(t).convert(e,s);t.dataFrame.columns.add(r);const o=await n.functions.call("Bio:detectMacromolecule",{col:r});return o&&(r.semType=o),await n.data.detectSemanticTypes(t.dataFrame),r}},5490:(t,e,s)=>{"use strict";s.d(e,{rb:()=>p,RV:()=>g,NT:()=>S,P4:()=>y,nW:()=>b,QD:()=>T});var n,i=s(4469),r=(s(3870),s(976)),o=s(701);class a{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 s=t;const n=this.isWhitespace(s)?e:e-1;for(let t=0;t<n;t++)s=this.getNextColumnIdx(s);return s}parseAtomTypes(){const t=this.atomCount,e=new Array(t);let s=this.getAtomBlockIdx();for(let n=0;n<t;n++)s=this.shiftIdxToAtomType(s),e[n]=this.parseAtomType(s),s=this.getNextLineIdx(s);return e}parseAtomCoordinates(){const t=new Float32Array(this.atomCount),e=new Float32Array(this.atomCount),s=new Float32Array(this.atomCount);let n=this.getAtomBlockIdx();for(let i=0;i<this.atomCount;i++){n=this.shiftIdxToXColumn(n);for(const r of[t,e,s])r[i]=this.parseFloatValue(n),n=this.getNextColumnIdx(n);n=this.getNextLineIdx(n)}return{x:t,y:e,z:s}}parseBondedAtomPairs(){const t=new Array(this.bondCount);let e=this.getBondBlockIdx();for(let s=0;s<this.bondCount;s++){e=this.shiftIdxToBondedAtomsPair(e);const n=new Uint16Array(2);n[0]=this.parseIntValue(e),e=this.getNextColumnIdx(e),n[1]=this.parseIntValue(e),t[s]=n,e=this.getNextLineIdx(e)}return t}parseBondTypes(){const t=this.bondCount,e=new Uint16Array(t);let s=this.getBondBlockIdx();for(let n=0;n<t;n++)s=this.shiftIdxToBondType(s),e[n]=this.parseIntValue(s),s=this.getNextLineIdx(s);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 s=e+1;for(;!this.isWhitespace(s);)++s;return t(this.fileContent.substring(e,s))}}class l extends a{constructor(t){super(t),this.init(t)}init(t){super.init(t)}parseAtomType(t){let e=t,s=e;return this.isQuote(e)?(s=this.getNextIdenticalChar(e),e++):s=this.fileContent.indexOf(" ",s),this.fileContent.substring(e,s)}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&&!((s=this.fileContent.charCodeAt(e+1))>64&&s<91||s>96&&s<123);var s}))}isFragment(){return this.isQueryOrFragment((t=>82===t||42===t))}isQueryOrFragment(t){const e=this.atomCount;let s=this.getAtomBlockIdx();for(let n=0;n<e;n++){if(s=this.shiftIdxToAtomType(s),t(this.fileContent.charCodeAt(s),s))return!0;s=this.getNextLineIdx(s)}return!1}}!function(t){t.HEADER="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.RGP_LINE="M RGP",t.A_LINE="A ",t.END="M END"}(n||(n={}));class h extends l{constructor(t){super(t)}static validate(t){return-1!==t.indexOf(n.HEADER)&&-1!==t.indexOf(n.END)}shiftIdxToAtomType(t){return this.shiftIdxToSpecifiedColumn(t,n.ATOM_TYPE_COL)}getCountsLineIdx(){let t=0;for(let e=0;e<n.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,n.FIRST_BONDED_ATOM_COL)}shiftIdxToBondType(t){return this.shiftIdxToSpecifiedColumn(t,n.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+n.NUM_OF_COUNTS_DIGITS;const s=parseInt(this.fileContent.substring(t,e));return t=e,e+=n.NUM_OF_COUNTS_DIGITS,{atomCount:s,bondCount:parseInt(this.fileContent.substring(t,e))}}}class c extends l{constructor(t){super(t),this.init(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 validate(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 s=parseInt(this.fileContent.substring(t,e));return t=e+1,e=this.fileContent.indexOf(" ",t+1),{atomCount:s,bondCount:parseInt(this.fileContent.substring(t,e))}}}class u{constructor(){}static getInstance(t){if(h.validate(t))return new h(t);if(c.validate(t))return new c(t);throw new Error("Malformed molfile")}}var m=s(7228),d=s(2397);const g="Libraries",f="System:AppData/Bio/libraries/",p={"HELMCoreLibrary.json":"HELMCoreLibrary.json"};async function y(){return await Promise.all((await i.dapi.files.list(f,!0,"")).map((async t=>t.fullPath.substring(f.length))))}let w=Promise.resolve();async function b(){let t;return w=w.then((async()=>{const e=await i.dapi.userDataStorage.getValue(g,"Settings",!0);t=e?JSON.parse(e):{exclude:[]},t.exclude=t.exclude instanceof Array?t.exclude:[],console.debug(`Bio: getUserLibSettings()\n${JSON.stringify(t,void 0,2)}`)})),await w,t}async function T(t){w=w.then((async()=>{console.debug(`Bio: setUserLibSettings()\n${JSON.stringify(t,void 0,2)}`),await i.dapi.userDataStorage.postValue(g,"Settings",JSON.stringify(t),!0)})),await w}class C{constructor(t,e){this._monomers={},this._onChanged=new o.Subject,this._monomers=t,this.error=e}getMonomer(t,e){return t in this._monomers&&e in this._monomers[t]?this._monomers[t][e]:null}getPolymerTypes(){return Object.keys(this._monomers)}getMonomerMolsByPolymerType(t){const e={};return Object.keys(this._monomers[t]??{}).forEach((s=>{e[s]=this._monomers[t][s].molfile})),e}getMonomerSymbolsByType(t){return Object.keys(this._monomers[t])}getMonomerSymbolsByRGroup(t,e,s){let n=this.getMonomerSymbolsByType(e).map((t=>this.getMonomer(e,t)));return n=n.filter((t=>null!==t)),0===n.length?[]:(n=n.filter((e=>{if(!e?.rgroups)return!1;let s=e?.rgroups.length>=t;return u.getInstance(e.molfile).atomTypes.map(((t,e)=>"R#"===t?e:-1)).filter((t=>-1!==t)),s&&(s=!0),s})),n.map((t=>t?.symbol)))}get onChanged(){return this._onChanged}_updateInt(t){const e=t.getPolymerTypes(),s=this.getPolymerTypes();e.forEach((e=>{s.includes(e)||(this._monomers[e]={}),t.getMonomerSymbolsByType(e).forEach((s=>{this._monomers[e][s]=t.getMonomer(e,s)}))}))}update(t){this._updateInt(t),this._onChanged.next()}updateLibs(t,e=!1){e&&(this._monomers={});for(const e of t)e.error||this._updateInt(e);this._onChanged.next()}clear(){this._monomers={},this._onChanged.next()}}class S{constructor(){this._monomerLib=new C({}),this.loadLibrariesPromise=Promise.resolve()}getBioLib(){return this._monomerLib}async loadLibraries(t=!1){return this.loadLibrariesPromise=this.loadLibrariesPromise.then((async()=>{try{const[e,s]=await Promise.all([y(),b()]),n=e.filter((t=>!s.exclude.includes(t))),i=await Promise.all(n.map((t=>this.readLibrary(f,t).catch((e=>{const s=`Loading monomers from '${t}' error: ${e instanceof Error?e.message:e.toString()}`;return new C({},s)})))));this._monomerLib.updateLibs(i,t)}catch(t){const e=`Loading monomer libraries error: ${t instanceof Error?t.message:t.toString()}`;i.shell.warning(e);const s=t instanceof Error?t.stack:void 0;d._package.logger.error(e,void 0,s)}}))}async readLibrary(t,e){let s,n,o=[];const a=new r.FileSource(t);if(e.endsWith(".sdf"))1===r.Func.find({package:"Chem",name:"importSdf"}).length?(s=await a.readAsBytes(e),n=await i.functions.call("Chem:importSdf",{bytes:s}),o=(0,m.Xk)(n[0])):i.shell.warning("Chem package is not installed");else if(e.endsWith(".json")){const t=await a.readAsText(e);o=JSON.parse(t)}else{if(!e.endsWith(".csv"))throw new Error("Monomer library of unknown file format, supported formats: SDF, JSON, CSV");{const t=(l=await a.readCsv(e),Array.from({length:l.rowCount},((t,e)=>l.columns.names().reduce(((t,s)=>(t[s]=l.get(s,e),t)),{}))));if(!(0,m.eD)(t))throw new Error("Invalid format of CSV monomer lib");o=(0,m.Z)(t)}}var l;const h={},c=[];return o.forEach((t=>{c.includes(t.polymerType)||(h[t.polymerType]={},c.push(t.polymerType)),h[t.polymerType][t.symbol]=t})),new C(h)}static get instance(){return S._instance||(S._instance=new S),S._instance}}S._instance=null},525:(t,e,s)=>{"use strict";s.d(e,{K:()=>_});var n=s(4469),i=s(976),r=s(3870),o=s(8447),a=s(499),l=s(6098),h=s(8341),c=s(2568),u=s(3553),m=s(2397),d=s(3379),g=s.n(d),f=s(7795),p=s.n(f),y=s(569),w=s.n(y),b=s(3565),T=s.n(b),C=s(9216),S=s.n(C),A=s(4589),v=s.n(A),E=s(9564),M={};M.styleTagTransform=v(),M.setAttributes=T(),M.insert=w().bind(null,"head"),M.domAPI=p(),M.insertStyleElement=S(),g()(E.Z,M),E.Z&&E.Z.locals&&E.Z.locals;class N extends Error{constructor(t,e){super(t,e)}}async function _(t={}){return new Promise((async(e,s)=>{var o,a,l;t.clustersCol??(t.clustersCol=null),t.pepsea??(t.pepsea={}),(o=t.pepsea).method??(o.method=u.jB.pepsea.method),(a=t.pepsea).gapOpen??(a.gapOpen=u.jB.pepsea.gapOpen),(l=t.pepsea).gapExtend??(l.gapExtend=u.jB.pepsea.gapExtend);const c=t.col?.dataFrame??n.shell.t,m=t.col??c.columns.bySemType(i.SEMTYPE.MACROMOLECULE);if(null==m){const t="MSAError: dataset doesn't conain any Macromolecule column";n.shell.warning(t),s(new N(t))}const d=r.choiceInput("Method",t.pepsea.method,h.J);d.setTooltip("Alignment method");const g=r.floatInput("Terminal gap",t?.kalign?.terminalGap??null);g.setTooltip("Penalty for opening a gap at the beginning or end of the sequence");const f=r.p(`Kalign version: ${u.WY}`,"kalign-version"),p=r.floatInput("Gap open",t.pepsea.gapOpen);p.setTooltip("Gap opening penalty at group-to-group alignment");const y=r.floatInput("Gap extend",t.pepsea.gapExtend);y.setTooltip("Gap extension penalty to skip the alignment");const w=r.inputs([p,y,g]),b=r.button("Alignment parameters",(()=>{w.hidden=!w.hidden}),"Adjust alignment parameters such as penalties for opening and extending gaps");b.classList.add("msa-params-button"),w.hidden=!0,b.prepend(r.icons.settings((()=>null)));const T=[d.root.style],C=[g.root.style,f.style];let S;const A=r.columnInput("Sequence",c,m,(async()=>{S=await L(A.value,c,T,C,d,v,p,y,g)}),{filter:t=>t.semType===i.SEMTYPE.MACROMOLECULE});A.setTooltip("Sequences column to use for alignment");const v=r.columnInput("Clusters",c,t.clustersCol);if(v.nullable=!0,A.fireChanged(),t.col)return S=await L(t.col,c,T,C,d,v,p,y,g),void await P(A,c,S,e,s);r.dialog("MSA").add(A).add(v).add(d).add(w).add(b).add(f).onOK((async()=>{await P(A,c,S,e,s)})).show()}))}async function P(t,e,s,r,o){let a=null;const l=i.TaskBarProgressIndicator.create("Analyze for MSA ...");try{if(t.fireChanged(),t.value.semType!==i.SEMTYPE.MACROMOLECULE)throw new Error("Chosen column has to be of Macromolecule semantic type");if(void 0===s)throw new Error("Invalid column format");if(a=await s(),null==a)return o("PepSeA container has not started");e.columns.add(a),await n.data.detectSemanticTypes(e),r(a)}catch(t){const e=t instanceof Error?t.message:t.toString();n.shell.error(e),o(t)}finally{l.close()}}async function L(t,e,s,r,d,g,f,p,y){try{if(t.semType!==i.SEMTYPE.MACROMOLECULE)return;const n=e.columns.getUnusedName(`msa(${t.name})`);if((0,c.n)(t,t.name,[o.r2.FASTA,o.r2.SEPARATOR],["DNA","RNA","PT"],!1)){R(s,r,"kalign"),f.value=null,p.value=null,y.value=null;const e=a.Cn.getOrCreate(t),i=e.isFasta()?t:e.convert(o.r2.FASTA);return async()=>await(0,l.U)(i,!1,n,g.value)}if((0,c.n)(t,t.name,[o.r2.HELM],[],!1))return R(s,r,"pepsea"),f.value??(f.value=u.jB.pepsea.gapOpen),p.value??(p.value=u.jB.pepsea.gapExtend),async()=>await(0,h.f)(t,n,d.value,f.value,p.value,g.value);if((0,c.n)(t,t.name,[o.r2.SEPARATOR],["UN"],!1)){const e=a.Cn.getOrCreate(t).convert(o.r2.HELM);return R(s,r,"pepsea"),f.value??(f.value=u.jB.pepsea.gapOpen),p.value??(p.value=u.jB.pepsea.gapExtend),async()=>await(0,h.f)(e,n,d.value,f.value,p.value,g.value)}return f.value=null,p.value=null,y.value=null,void R(s,r,"kalign")}catch(t){const e=t instanceof Error?t.message:t.toString();n.shell.error(e),m._package.logger.error(e)}}function R(t,e,s){if("kalign"===s){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")}}},6098:(t,e,s)=>{"use strict";s.d(e,{U:()=>O});var n=s(976),i=s(5226);const r=Symbol("Comlink.proxy"),o=Symbol("Comlink.endpoint"),a=Symbol("Comlink.releaseProxy"),l=Symbol("Comlink.thrown"),h=t=>"object"==typeof t&&null!==t||"function"==typeof t,c=new Map([["proxy",{canHandle:t=>h(t)&&t[r],serialize(t){const{port1:e,port2:s}=new MessageChannel;return u(t,e),[s,[s]]},deserialize:t=>(t.start(),d(t))}],["throw",{canHandle:t=>h(t)&&l 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 u(t,e=self){e.addEventListener("message",(function s(n){if(!n||!n.data)return;const{id:i,type:o,path:a}=Object.assign({path:[]},n.data),h=(n.data.argumentList||[]).map(T);let c;try{const e=a.slice(0,-1).reduce(((t,e)=>t[e]),t),s=a.reduce(((t,e)=>t[e]),t);switch(o){case"GET":c=s;break;case"SET":e[a.slice(-1)[0]]=T(n.data.value),c=!0;break;case"APPLY":c=s.apply(e,h);break;case"CONSTRUCT":c=function(t){return Object.assign(t,{[r]:!0})}(new s(...h));break;case"ENDPOINT":{const{port1:e,port2:s}=new MessageChannel;u(t,s),c=function(t,e){return w.set(t,e),t}(e,[e])}break;case"RELEASE":c=void 0;break;default:return}}catch(t){c={value:t,[l]:0}}Promise.resolve(c).catch((t=>({value:t,[l]:0}))).then((t=>{const[n,r]=b(t);e.postMessage(Object.assign(Object.assign({},n),{id:i}),r),"RELEASE"===o&&(e.removeEventListener("message",s),m(e))}))})),e.start&&e.start()}function m(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function d(t,e){return f(t,[],e)}function g(t){if(t)throw new Error("Proxy has been released and is not useable")}function f(t,e=[],s=function(){}){let n=!1;const i=new Proxy(s,{get(s,r){if(g(n),r===a)return()=>C(t,{type:"RELEASE",path:e.map((t=>t.toString()))}).then((()=>{m(t),n=!0}));if("then"===r){if(0===e.length)return{then:()=>i};const s=C(t,{type:"GET",path:e.map((t=>t.toString()))}).then(T);return s.then.bind(s)}return f(t,[...e,r])},set(s,i,r){g(n);const[o,a]=b(r);return C(t,{type:"SET",path:[...e,i].map((t=>t.toString())),value:o},a).then(T)},apply(s,i,r){g(n);const a=e[e.length-1];if(a===o)return C(t,{type:"ENDPOINT"}).then(T);if("bind"===a)return f(t,e.slice(0,-1));const[l,h]=y(r);return C(t,{type:"APPLY",path:e.map((t=>t.toString())),argumentList:l},h).then(T)},construct(s,i){g(n);const[r,o]=y(i);return C(t,{type:"CONSTRUCT",path:e.map((t=>t.toString())),argumentList:r},o).then(T)}});return i}function p(t){return Array.prototype.concat.apply([],t)}function y(t){const e=t.map(b);return[e.map((t=>t[0])),p(e.map((t=>t[1])))]}const w=new WeakMap;function b(t){for(const[e,s]of c)if(s.canHandle(t)){const[n,i]=s.serialize(t);return[{type:"HANDLER",name:e,value:n},i]}return[{type:"RAW",value:t},w.get(t)||[]]}function T(t){switch(t.type){case"HANDLER":return c.get(t.name).deserialize(t.value);case"RAW":return t.value}}function C(t,e,s){return new Promise((n=>{const i=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");t.addEventListener("message",(function e(s){!s.data||!s.data.id||s.data.id!==i||(t.removeEventListener("message",e),n(s.data))})),t.start&&t.start(),t.postMessage(Object.assign({id:i},e),s)}))}const S="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0ICQ9U3ltYm9sKCJDb21saW5rLnByb3h5IiksQT1TeW1ib2woIkNvbWxpbmsuZW5kcG9pbnQiKSxSPVN5bWJvbCgiQ29tbGluay5yZWxlYXNlUHJveHkiKSx5PVN5bWJvbCgiQ29tbGluay50aHJvd24iKSxfPWU9PnR5cGVvZiBlPT0ib2JqZWN0IiYmZSE9PW51bGx8fHR5cGVvZiBlPT0iZnVuY3Rpb24iLEw9e2NhbkhhbmRsZTplPT5fKGUpJiZlWyRdLHNlcmlhbGl6ZShlKXtjb25zdHtwb3J0MTpyLHBvcnQyOml9PW5ldyBNZXNzYWdlQ2hhbm5lbDtyZXR1cm4gdyhlLHIpLFtpLFtpXV19LGRlc2VyaWFsaXplKGUpe3JldHVybiBlLnN0YXJ0KCksQyhlKX19LE89e2NhbkhhbmRsZTplPT5fKGUpJiZ5IGluIGUsc2VyaWFsaXplKHt2YWx1ZTplfSl7bGV0IHI7cmV0dXJuIGUgaW5zdGFuY2VvZiBFcnJvcj9yPXtpc0Vycm9yOiEwLHZhbHVlOnttZXNzYWdlOmUubWVzc2FnZSxuYW1lOmUubmFtZSxzdGFjazplLnN0YWNrfX06cj17aXNFcnJvcjohMSx2YWx1ZTplfSxbcixbXV19LGRlc2VyaWFsaXplKGUpe3Rocm93IGUuaXNFcnJvcj9PYmplY3QuYXNzaWduKG5ldyBFcnJvcihlLnZhbHVlLm1lc3NhZ2UpLGUudmFsdWUpOmUudmFsdWV9fSxFPW5ldyBNYXAoW1sicHJveHkiLExdLFsidGhyb3ciLE9dXSk7ZnVuY3Rpb24gdyhlLHI9c2VsZil7ci5hZGRFdmVudExpc3RlbmVyKCJtZXNzYWdlIixmdW5jdGlvbiBpKHMpe2lmKCFzfHwhcy5kYXRhKXJldHVybjtjb25zdHtpZDpvLHR5cGU6YSxwYXRoOm59PU9iamVjdC5hc3NpZ24oe3BhdGg6W119LHMuZGF0YSksdT0ocy5kYXRhLmFyZ3VtZW50TGlzdHx8W10pLm1hcChtKTtsZXQgbDt0cnl7Y29uc3QgYz1uLnNsaWNlKDAsLTEpLnJlZHVjZSgoZCxoKT0+ZFtoXSxlKSxmPW4ucmVkdWNlKChkLGgpPT5kW2hdLGUpO3N3aXRjaChhKXtjYXNlIkdFVCI6bD1mO2JyZWFrO2Nhc2UiU0VUIjpjW24uc2xpY2UoLTEpWzBdXT1tKHMuZGF0YS52YWx1ZSksbD0hMDticmVhaztjYXNlIkFQUExZIjpsPWYuYXBwbHkoYyx1KTticmVhaztjYXNlIkNPTlNUUlVDVCI6e2NvbnN0IGQ9bmV3IGYoLi4udSk7bD16KGQpfWJyZWFrO2Nhc2UiRU5EUE9JTlQiOntjb25zdHtwb3J0MTpkLHBvcnQyOmh9PW5ldyBNZXNzYWdlQ2hhbm5lbDt3KGUsaCksbD1OKGQsW2RdKX1icmVhaztjYXNlIlJFTEVBU0UiOmw9dm9pZCAwO2JyZWFrO2RlZmF1bHQ6cmV0dXJufX1jYXRjaChjKXtsPXt2YWx1ZTpjLFt5XTowfX1Qcm9taXNlLnJlc29sdmUobCkuY2F0Y2goYz0+KHt2YWx1ZTpjLFt5XTowfSkpLnRoZW4oYz0+e2NvbnN0W2YsZF09UyhjKTtyLnBvc3RNZXNzYWdlKE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSxmKSx7aWQ6b30pLGQpLGE9PT0iUkVMRUFTRSImJihyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGkpLEYocikpfSl9KSxyLnN0YXJ0JiZyLnN0YXJ0KCl9ZnVuY3Rpb24gVChlKXtyZXR1cm4gZS5jb25zdHJ1Y3Rvci5uYW1lPT09Ik1lc3NhZ2VQb3J0In1mdW5jdGlvbiBGKGUpe1QoZSkmJmUuY2xvc2UoKX1mdW5jdGlvbiBDKGUscil7cmV0dXJuIGIoZSxbXSxyKX1mdW5jdGlvbiBwKGUpe2lmKGUpdGhyb3cgbmV3IEVycm9yKCJQcm94eSBoYXMgYmVlbiByZWxlYXNlZCBhbmQgaXMgbm90IHVzZWFibGUiKX1mdW5jdGlvbiBiKGUscj1bXSxpPWZ1bmN0aW9uKCl7fSl7bGV0IHM9ITE7Y29uc3Qgbz1uZXcgUHJveHkoaSx7Z2V0KGEsbil7aWYocChzKSxuPT09UilyZXR1cm4oKT0+ZyhlLHt0eXBlOiJSRUxFQVNFIixwYXRoOnIubWFwKHU9PnUudG9TdHJpbmcoKSl9KS50aGVuKCgpPT57RihlKSxzPSEwfSk7aWYobj09PSJ0aGVuIil7aWYoci5sZW5ndGg9PT0wKXJldHVybnt0aGVuOigpPT5vfTtjb25zdCB1PWcoZSx7dHlwZToiR0VUIixwYXRoOnIubWFwKGw9PmwudG9TdHJpbmcoKSl9KS50aGVuKG0pO3JldHVybiB1LnRoZW4uYmluZCh1KX1yZXR1cm4gYihlLFsuLi5yLG5dKX0sc2V0KGEsbix1KXtwKHMpO2NvbnN0W2wsY109Uyh1KTtyZXR1cm4gZyhlLHt0eXBlOiJTRVQiLHBhdGg6Wy4uLnIsbl0ubWFwKGY9PmYudG9TdHJpbmcoKSksdmFsdWU6bH0sYykudGhlbihtKX0sYXBwbHkoYSxuLHUpe3Aocyk7Y29uc3QgbD1yW3IubGVuZ3RoLTFdO2lmKGw9PT1BKXJldHVybiBnKGUse3R5cGU6IkVORFBPSU5UIn0pLnRoZW4obSk7aWYobD09PSJiaW5kIilyZXR1cm4gYihlLHIuc2xpY2UoMCwtMSkpO2NvbnN0W2MsZl09TSh1KTtyZXR1cm4gZyhlLHt0eXBlOiJBUFBMWSIscGF0aDpyLm1hcChkPT5kLnRvU3RyaW5nKCkpLGFyZ3VtZW50TGlzdDpjfSxmKS50aGVuKG0pfSxjb25zdHJ1Y3QoYSxuKXtwKHMpO2NvbnN0W3UsbF09TShuKTtyZXR1cm4gZyhlLHt0eXBlOiJDT05TVFJVQ1QiLHBhdGg6ci5tYXAoYz0+Yy50b1N0cmluZygpKSxhcmd1bWVudExpc3Q6dX0sbCkudGhlbihtKX19KTtyZXR1cm4gb31mdW5jdGlvbiBEKGUpe3JldHVybiBBcnJheS5wcm90b3R5cGUuY29uY2F0LmFwcGx5KFtdLGUpfWZ1bmN0aW9uIE0oZSl7Y29uc3Qgcj1lLm1hcChTKTtyZXR1cm5bci5tYXAoaT0+aVswXSksRChyLm1hcChpPT5pWzFdKSldfWNvbnN0IFA9bmV3IFdlYWtNYXA7ZnVuY3Rpb24gTihlLHIpe3JldHVybiBQLnNldChlLHIpLGV9ZnVuY3Rpb24geihlKXtyZXR1cm4gT2JqZWN0LmFzc2lnbihlLHtbJF06ITB9KX1mdW5jdGlvbiBTKGUpe2Zvcihjb25zdFtyLGldb2YgRSlpZihpLmNhbkhhbmRsZShlKSl7Y29uc3RbcyxvXT1pLnNlcmlhbGl6ZShlKTtyZXR1cm5be3R5cGU6IkhBTkRMRVIiLG5hbWU6cix2YWx1ZTpzfSxvXX1yZXR1cm5be3R5cGU6IlJBVyIsdmFsdWU6ZX0sUC5nZXQoZSl8fFtdXX1mdW5jdGlvbiBtKGUpe3N3aXRjaChlLnR5cGUpe2Nhc2UiSEFORExFUiI6cmV0dXJuIEUuZ2V0KGUubmFtZSkuZGVzZXJpYWxpemUoZS52YWx1ZSk7Y2FzZSJSQVciOnJldHVybiBlLnZhbHVlfX1mdW5jdGlvbiBnKGUscixpKXtyZXR1cm4gbmV3IFByb21pc2Uocz0+e2NvbnN0IG89VSgpO2UuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsZnVuY3Rpb24gYShuKXshbi5kYXRhfHwhbi5kYXRhLmlkfHxuLmRhdGEuaWQhPT1vfHwoZS5yZW1vdmVFdmVudExpc3RlbmVyKCJtZXNzYWdlIixhKSxzKG4uZGF0YSkpfSksZS5zdGFydCYmZS5zdGFydCgpLGUucG9zdE1lc3NhZ2UoT2JqZWN0LmFzc2lnbih7aWQ6b30sciksaSl9KX1mdW5jdGlvbiBVKCl7cmV0dXJuIG5ldyBBcnJheSg0KS5maWxsKDApLm1hcCgoKT0+TWF0aC5mbG9vcihNYXRoLnJhbmRvbSgpKk51bWJlci5NQVhfU0FGRV9JTlRFR0VSKS50b1N0cmluZygxNikpLmpvaW4oIi0iKX1jb25zdCBXPWFzeW5jKCk9PldlYkFzc2VtYmx5LnZhbGlkYXRlKG5ldyBVaW50OEFycmF5KFswLDk3LDExNSwxMDksMSwwLDAsMCwxLDUsMSw5NiwwLDEsMTIzLDMsMiwxLDAsMTAsMTAsMSw4LDAsNjUsMCwyNTMsMTUsMjUzLDk4LDExXSkpLHg9ImVhZ2VyIixrPSJsYXp5IixqPXtzc3c6WyJzaW1kIl0sbWluaW1hcDI6WyJzaW1kIl19LHQ9e3Rvb2xzOltdLGNvbmZpZzp7fSxmaWxlczpbXSxiYXNlOnt9LGZzOnt9LGFzeW5jIGluaXQoKXtpZih0LnRvb2xzLmxlbmd0aD09PTApdGhyb3ciRXhwZWN0aW5nIGF0IGxlYXN0IDEgdG9vbC4iO2lmKG5ldyBTZXQodC50b29scy5tYXAocj0+YCR7ci50b29sfS8ke3IucHJvZ3JhbXx8ci50b29sfWApKS5zaXplIT09dC50b29scy5sZW5ndGgpdGhyb3ciRm91bmQgZHVwbGljYXRlIHRvb2xzOyBjYW4gb25seSBoYXZlIGVhY2ggdG9vbC9wcm9ncmFtIGNvbWJpbmF0aW9uIGF0IG1vc3Qgb25jZS4iO2lmKHQuYmFzZT10LnRvb2xzLmZpbmQocj0+ci5yZWluaXQhPT0hMCksIXQuYmFzZSl0aHJvdyJDb3VsZCBub3QgZmluZCBhIHRvb2wgd2l0aCBgcmVpbml0OiBmYWxzZWAgdG8gdXNlIGFzIHRoZSBiYXNlIG1vZHVsZS4gVG8gZml4IHRoaXMgaXNzdWUsIGluY2x1ZGUgdGhlIHRvb2wgYGJhc2UvMS4wLjBgIHdoZW4gaW5pdGlhbGl6aW5nIEFpb2xpLiI7cmV0dXJuIHQuYmFzZS5pc0Jhc2VNb2R1bGU9ITAsYXdhaXQgdGhpcy5fc2V0dXAodC5iYXNlKSxhd2FpdCB0aGlzLl9pbml0TW9kdWxlcygpLHQuX2xvZygiUmVhZHkiKSwhMH0sYXN5bmMgX2luaXRNb2R1bGVzKCl7YXdhaXQgUHJvbWlzZS5hbGwodC50b29scy5tYXAodGhpcy5fc2V0dXApKSxhd2FpdCB0aGlzLl9zZXR1cEZTKCl9LG1vdW50KGU9W10pe2NvbnN0IHI9YCR7dC5jb25maWcuZGlyU2hhcmVkfSR7dC5jb25maWcuZGlyRGF0YX1gLGk9YCR7dC5jb25maWcuZGlyU2hhcmVkfSR7dC5jb25maWcuZGlyTW91bnRlZH1gO2xldCBzPVtdLG89W10sYT1bXTshQXJyYXkuaXNBcnJheShlKSYmIShlIGluc3RhbmNlb2YgRmlsZUxpc3QpJiYoZT1bZV0pLHQuX2xvZyhgTW91bnRpbmcgJHtlLmxlbmd0aH0gZmlsZXNgKTtmb3IobGV0IG4gb2YgZSl7aWYobiBpbnN0YW5jZW9mIEZpbGV8fChuPT1udWxsP3ZvaWQgMDpuLmRhdGEpaW5zdGFuY2VvZiBCbG9iJiZuLm5hbWV8fHR5cGVvZihuPT1udWxsP3ZvaWQgMDpuLmRhdGEpPT0ic3RyaW5nIiYmbi5uYW1lKXR5cGVvZihuPT1udWxsP3ZvaWQgMDpuLmRhdGEpPT0ic3RyaW5nIiYmKG4uZGF0YT1uZXcgQmxvYihbbi5kYXRhXSx7dHlwZToidGV4dC9wbGFpbiJ9KSkscy5wdXNoKG4pO2Vsc2UgaWYobi5uYW1lJiZuLnVybClvLnB1c2gobik7ZWxzZSBpZih0eXBlb2Ygbj09InN0cmluZyImJm4uc3RhcnRzV2l0aCgiaHR0cCIpKW49e3VybDpuLG5hbWU6bi5zcGxpdCgiLy8iKS5wb3AoKS5yZXBsYWNlKC9cLy9nLCItIil9LG8ucHVzaChuKTtlbHNlIHRocm93J0Nhbm5vdCBtb3VudCBmaWxlKHMpIHNwZWNpZmllZC4gTXVzdCBiZSBhIEZpbGUsIEJsb2IsIGEgVVJMIHN0cmluZywgb3IgeyBuYW1lOiAiZmlsZS50eHQiLCBkYXRhOiAic3RyaW5nIiB9Lic7YS5wdXNoKG4ubmFtZSl9dHJ5e3QuZnMudW5tb3VudChpKX1jYXRjaHt9Zm9yKGxldCBuIG9mIG8pdC5mcy5jcmVhdGVMYXp5RmlsZShyLG4ubmFtZSxuLnVybCwhMCwhMCk7cmV0dXJuIHQuZmlsZXM9dC5maWxlcy5jb25jYXQocyksdC5iYXNlLm1vZHVsZS5GUy5tb3VudCh0LmJhc2UubW9kdWxlLldPUktFUkZTLHtmaWxlczp0LmZpbGVzLmZpbHRlcihuPT5uIGluc3RhbmNlb2YgRmlsZSksYmxvYnM6dC5maWxlcy5maWx0ZXIobj0+KG49PW51bGw/dm9pZCAwOm4uZGF0YSlpbnN0YW5jZW9mIEJsb2IpfSxpKSxzLm1hcChuPT57Y29uc3QgdT1gJHtpfS8ke24ubmFtZX1gLGw9YCR7cn0vJHtuLm5hbWV9YDt0cnl7dC5mcy51bmxpbmsobCl9Y2F0Y2h7fXQuX2xvZyhgQ3JlYXRpbmcgc3ltbGluazogJHtsfSAtLT4gJHt1fWApLHQuZnMuc3ltbGluayh1LGwpfSksYS5tYXAobj0+YCR7cn0vJHtufWApfSxhc3luYyBleGVjKGUscj1udWxsKXtpZih0Ll9sb2coYEV4ZWN1dGluZyAlYyR7ZX0lYyBhcmdzPSR7cn1gLCJjb2xvcjpkYXJrYmx1ZTsgZm9udC13ZWlnaHQ6Ym9sZCIsIiIpLCFlKXRocm93IkV4cGVjdGluZyBhIGNvbW1hbmQiO2xldCBpPWU7cj09bnVsbCYmKHI9ZS5zcGxpdCgiICIpLGk9ci5zaGlmdCgpKTtjb25zdCBzPXQudG9vbHMuZmluZChhPT57dmFyIHU7bGV0IG49aTtyZXR1cm4oKHU9YT09bnVsbD92b2lkIDA6YS5mZWF0dXJlcyk9PW51bGw/dm9pZCAwOnUuc2ltZCk9PT0hMCYmKG49YCR7bn0tc2ltZGApLGEucHJvZ3JhbT09bn0pO2lmKHM9PW51bGwpdGhyb3dgUHJvZ3JhbSAke2l9IG5vdCBmb3VuZC5gO3Muc3Rkb3V0PSIiLHMuc3RkZXJyPSIiLHMubG9hZGluZz09ayYmKHMubG9hZGluZz14LGF3YWl0IHRoaXMuX2luaXRNb2R1bGVzKCkpO3RyeXtzLm1vZHVsZS5jYWxsTWFpbihyKX1jYXRjaChhKXtjb25zb2xlLmVycm9yKGEpfXRyeXtzLm1vZHVsZS5GUy5jbG9zZShzLm1vZHVsZS5GUy5zdHJlYW1zWzFdKSxzLm1vZHVsZS5GUy5jbG9zZShzLm1vZHVsZS5GUy5zdHJlYW1zWzJdKX1jYXRjaHt9cy5tb2R1bGUuRlMuc3RyZWFtc1sxXT1zLm1vZHVsZS5GUy5vcGVuKCIvZGV2L3N0ZG91dCIsInciKSxzLm1vZHVsZS5GUy5zdHJlYW1zWzJdPXMubW9kdWxlLkZTLm9wZW4oIi9kZXYvc3RkZXJyIiwidyIpO2xldCBvPXtzdGRvdXQ6cy5zdGRvdXQsc3RkZXJyOnMuc3RkZXJyfTtpZih0LmNvbmZpZy5wcmludEludGVybGVhdmVkJiYobz1zLnN0ZG91dCkscy5yZWluaXQ9PT0hMCl7Y29uc3QgYT10LmJhc2UubW9kdWxlLkZTLmN3ZCgpO09iamVjdC5hc3NpZ24ocyxzLmNvbmZpZykscy5yZWFkeT0hMSxhd2FpdCB0aGlzLmluaXQoKSxzLmlzQmFzZU1vZHVsZSYmdGhpcy5tb3VudCgpLHRoaXMuY2QoYSl9cmV0dXJuIG99LGNhdChlKXtyZXR1cm4gdC5fZmlsZW9wKCJjYXQiLGUpfSxscyhlKXtyZXR1cm4gdC5fZmlsZW9wKCJscyIsZSl9LGRvd25sb2FkKGUpe3JldHVybiB0Ll9maWxlb3AoImRvd25sb2FkIixlKX0scHdkKCl7cmV0dXJuIHQuZnMuY3dkKCl9LGNkKGUpe2ZvcihsZXQgciBvZiB0LnRvb2xzKSFyLm1vZHVsZXx8ci5tb2R1bGUuRlMuY2hkaXIoZSl9LG1rZGlyKGUpe3JldHVybiB0LmZzLm1rZGlyKGUpLCEwfSxyZWFkKHtwYXRoOmUsbGVuZ3RoOnIsZmxhZzppPSJyIixvZmZzZXQ6cz0wLHBvc2l0aW9uOm89MH0pe2NvbnN0IGE9dC5mcy5vcGVuKGUsaSksbj1uZXcgVWludDhBcnJheShyKTtyZXR1cm4gdC5mcy5yZWFkKGEsbixzLHIsbyksdC5mcy5jbG9zZShhKSxufSx3cml0ZSh7cGF0aDplLGJ1ZmZlcjpyLGZsYWc6aT0idysiLG9mZnNldDpzPTAscG9zaXRpb246bz0wfSl7Y29uc3QgYT10LmZzLm9wZW4oZSxpKTt0LmZzLndyaXRlKGEscixzLHIubGVuZ3RoLG8pLHQuZnMuY2xvc2UoYSl9LF9zdGRpblR4dDoiIixfc3RkaW5QdHI6MCxnZXQgc3RkaW4oKXtyZXR1cm4gdC5fc3RkaW5UeHR9LHNldCBzdGRpbihlPSIiKXt0Ll9sb2coYFNldHRpbmcgc3RkaW4gdG8gJWMke2V9JWNgLCJjb2xvcjpkYXJrYmx1ZSIsIiIpLHQuX3N0ZGluVHh0PWUsdC5fc3RkaW5QdHI9MH0sYXN5bmMgX3NldHVwKGUpe2lmKGUucmVhZHkpcmV0dXJuO2lmKHQuX2xvZyhgU2V0dGluZyB1cCAke2UudG9vbH0gKGJhc2UgPSAke2UuaXNCYXNlTW9kdWxlPT09ITB9KS4uLmApLGUuY29uZmlnPU9iamVjdC5hc3NpZ24oe30sZSksZS51cmxQcmVmaXh8fChlLnVybFByZWZpeD1gJHt0LmNvbmZpZy51cmxDRE59LyR7ZS50b29sfS8ke2UudmVyc2lvbn1gKSxlLnByb2dyYW18fChlLnByb2dyYW09ZS50b29sKSxlLmZlYXR1cmVzfHwoZS5mZWF0dXJlcz17fSwoaltlLnByb2dyYW1dfHxbXSkuaW5jbHVkZXMoInNpbWQiKSYmKGF3YWl0IFcoKT8oZS5wcm9ncmFtKz0iLXNpbWQiLGUuZmVhdHVyZXMuc2ltZD0hMCk6dC5fbG9nKGBXZWJBc3NlbWJseSBTSU1EIGlzIG5vdCBzdXBwb3J0ZWQgaW4gdGhpcyBicm93c2VyOyB3aWxsIGxvYWQgbm9uLVNJTUQgdmVyc2lvbiBvZiAke2UucHJvZ3JhbX0uYCkpKSxlLmlzQmFzZU1vZHVsZSYmKGUubG9hZGluZz14KSxlLmxvYWRpbmc9PT1rKXt0Ll9sb2coYFdpbGwgbGF6eS1sb2FkICR7ZS50b29sfTsgc2tpcHBpbmcgaW5pdGlhbGl6YXRpb24uYCk7cmV0dXJufXNlbGYuaW1wb3J0U2NyaXB0cyhgJHtlLnVybFByZWZpeH0vJHtlLnByb2dyYW19LmpzYCksZS5tb2R1bGU9YXdhaXQgTW9kdWxlKHt0aGlzUHJvZ3JhbTplLnByb2dyYW0sbG9jYXRlRmlsZTooaSxzKT0+YCR7ZS51cmxQcmVmaXh9LyR7aX1gLHN0ZGluOigpPT50Ll9zdGRpblB0cjx0LnN0ZGluLmxlbmd0aD90LnN0ZGluLmNoYXJDb2RlQXQodC5fc3RkaW5QdHIrKyk6KHQuc3RkaW49IiIsbnVsbCkscHJpbnQ6aT0+ZS5zdGRvdXQrPWAke2l9CmAscHJpbnRFcnI6dC5jb25maWcucHJpbnRJbnRlcmxlYXZlZD9pPT5lLnN0ZG91dCs9YCR7aX0KYDppPT5lLnN0ZGVycis9YCR7aX0KYH0pO2NvbnN0IHI9ZS5tb2R1bGUuRlM7ZS5pc0Jhc2VNb2R1bGU/KHQuX2xvZyhgU2V0dGluZyB1cCAke2UudG9vbH0gd2l0aCBiYXNlIG1vZHVsZSBmaWxlc3lzdGVtLi4uYCksci5ta2Rpcih0LmNvbmZpZy5kaXJTaGFyZWQsNTExKSxyLm1rZGlyKGAke3QuY29uZmlnLmRpclNoYXJlZH0vJHt0LmNvbmZpZy5kaXJEYXRhfWAsNTExKSxyLm1rZGlyKGAke3QuY29uZmlnLmRpclNoYXJlZH0vJHt0LmNvbmZpZy5kaXJNb3VudGVkfWAsNTExKSxyLmNoZGlyKGAke3QuY29uZmlnLmRpclNoYXJlZH0vJHt0LmNvbmZpZy5kaXJEYXRhfWApLHQuZnM9cik6KHQuX2xvZyhgU2V0dGluZyB1cCAke2UudG9vbH0gd2l0aCBmaWxlc3lzdGVtLi4uYCksci5ta2Rpcih0LmNvbmZpZy5kaXJTaGFyZWQpLHIubW91bnQoZS5tb2R1bGUuUFJPWFlGUyx7cm9vdDp0LmNvbmZpZy5kaXJTaGFyZWQsZnM6dC5mc30sdC5jb25maWcuZGlyU2hhcmVkKSxyLmNoZGlyKHQuZnMuY3dkKCkpKSxlLnN0ZG91dD0iIixlLnN0ZGVycj0iIixlLnJlYWR5PSEwfSxhc3luYyBfc2V0dXBGUygpe2NvbnN0IGU9dC5mcztmb3IobGV0IHIgb2YgdC50b29scyl7aWYoIXIucmVhZHkpY29udGludWU7Y29uc3QgaT1yLm1vZHVsZS5GUyxzPWAvJHtyLnRvb2x9YCxvPWAke3QuY29uZmlnLmRpclNoYXJlZH0ke3N9YDshaS5hbmFseXplUGF0aChzKS5leGlzdHN8fGUuYW5hbHl6ZVBhdGgobykuZXhpc3RzfHwodC5fbG9nKGBNb3VudGluZyAke3N9IG9udG8gJHt0LmJhc2UudG9vbH0gZmlsZXN5c3RlbSBhdCAke299YCksZS5ta2RpcihvKSxlLm1vdW50KHQuYmFzZS5tb2R1bGUuUFJPWFlGUyx7cm9vdDpzLGZzOml9LG8pKX19LF9maWxlb3AoZSxyKXt0Ll9sb2coYFJ1bm5pbmcgJHtlfSAke3J9YCk7Y29uc3QgaT10LmZzLmFuYWx5emVQYXRoKHIpO2lmKCFpLmV4aXN0cylyZXR1cm4gdC5fbG9nKGBGaWxlICR7cn0gbm90IGZvdW5kLmApLCExO3N3aXRjaChlKXtjYXNlImNhdCI6cmV0dXJuIHQuZnMucmVhZEZpbGUocix7ZW5jb2Rpbmc6InV0ZjgifSk7Y2FzZSJscyI6cmV0dXJuIHQuZnMuaXNGaWxlKGkub2JqZWN0Lm1vZGUpP3QuZnMuc3RhdChyKTp0LmZzLnJlYWRkaXIocik7Y2FzZSJkb3dubG9hZCI6Y29uc3Qgcz1uZXcgQmxvYihbdGhpcy5jYXQocildKTtyZXR1cm4gVVJMLmNyZWF0ZU9iamVjdFVSTChzKX1yZXR1cm4hMX0sX2xvZyhlKXtpZighdC5jb25maWcuZGVidWcpcmV0dXJuO2xldCByPVsuLi5hcmd1bWVudHNdO3Iuc2hpZnQoKSxjb25zb2xlLmxvZyhgJWNbV2ViV29ya2VyXSVjICR7ZX1gLCJmb250LXdlaWdodDpib2xkIiwiIiwuLi5yKX19O3codCl9KSgpOwo=",A=typeof window<"u"&&window.Blob&&new Blob([atob(S)],{type:"text/javascript;charset=utf-8"});function v(){const t=A&&(window.URL||window.webkitURL).createObjectURL(A);try{return t?new Worker(t):new Worker("data:application/javascript;base64,"+S)}finally{t&&(window.URL||window.webkitURL).revokeObjectURL(t)}}const E={urlCDN:"https://biowasm.com/cdn/v3",urlCDNStg:"https://stg.biowasm.com/cdn/v3",dirShared:"/shared",dirMounted:"/mnt",dirData:"/data",printInterleaved:!0,callback:null,debug:!1,env:"prd"};class M{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({},E,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 v;this.callback&&(t.onmessage=t=>{"biowasm"===t.data.type&&this.callback(t.data.value)});const e=d(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=s(850);class _{static getAvailableScales(){return Object.entries(this.scales).map((([t,e])=>t))}static getScale(t){return(0,N.hu)(!(void 0===this.scales[t]),`Scale '${t}' was not found.`),this.scales[t]}}_.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 P{constructor(t="categorial"){this.aa2num=_.getScale(t),this.num2aa={},Object.entries(this.aa2num).forEach((([t,e])=>this.num2aa[e]=t))}static _truncateSequence(t){let e=0,s=t.length;const n=["NH2","COOH"];if(t.startsWith(n[0])){const s=n[0].length;(0,N.hu)("-"==t[s],`Wrong sequence format: ${n[0]} without following '-' in '${t}'.`),e=s}if(t.endsWith(n[1])){const e=n[1].length+1;(0,N.hu)("-"==t[s-e],`Wrong sequence format: ${n[1]} without '-' precending in '${t}'.`),s-=e}return t.substring(e,s)}static _dropDefises(t){return t.replace(/(-)([^-]+)/g,"$2")}static clean(t){return P._dropDefises(P._truncateSequence(t))}encode(t){const e=t.length,s=new Array(e).fill(0);for(let n=0;n<e;++n){const e=t[n];(0,N.hu)(e in this.aa2num,`Unknown char '${e}' found in sequence '${t}'`),s[n]=this.encodeLettter(e)}return s}encodeLettter(t){return this.aa2num[t]}decode(t){let e="";for(let s=0;s<t.length;++s){const n=t[s];(0,N.hu)(n in this.num2aa,`Unknown code '${n}' found in vector '${t}'`),e+=this.num2aa[n]}return e}}var L=s(3553);const R="input.fa",x="result.fasta";function I(t){return t.reduce(((t,e,s)=>t+`>sample${s+1}\n${e}\n`),"")}async function O(t,e=!1,s="",r=null,o,a,l){let h=t.toList();e&&(h=h.map((t=>P.clean(t).replace(/\-/g,""))));const c=t.length;r??(r=n.Column.string("Clusters",c).init("0")),r.type!=n.COLUMN_TYPE.STRING&&(r=r.convertTo(n.TYPE.STRING)),r.compact();const u=r.categories,m=r.getRawData(),d=new Array(u.length),g=new Array(u.length);for(let t=0;t<c;++t){const e=m[t];(d[e]??(d[e]=[])).push(h[t]),(g[e]??(g[e]=[])).push(t)}const f=await new M(["base/1.0.0",{tool:"kalign",version:L.WY,reinit:!0}]),p=n.Column.string(s,c);for(let t=0;t<u.length;++t){const e=I(d[t]);await f.fs.writeFile(R,e);const s=`${void 0!==o?` --gpo ${o}`:""}${void 0!==a?` --gpe ${a}`:""}${void 0!==l?` --tgpe ${l}`:""}`,n=await f.exec(`kalign ${R} -f fasta -o ${x}${s}`);console.warn(n);const r=await f.cat(x);if(!r)throw new Error("kalign output no result");const h=new i.i(r).sequencesArray,c=g[t];for(let t=0;t<h.length;++t)p.set(c[t],h[t])}const y=t.getTag(n.TAGS.UNITS),w=t.getTag("alphabet");return p.setTag(n.TAGS.UNITS,y),p.setTag("aligned","SEQ.MSA"),p.setTag("alphabet",w),p.semType=n.SEMTYPE.MACROMOLECULE,p}},8341:(t,e,s)=>{"use strict";s.d(e,{J:()=>a,f:()=>h});var n=s(4469),i=s(976),r=s(8447),o=s(3553);const a=["mafft --auto","mafft","linsi","ginsi","einsi","fftns","fftnsi","nwns","nwnsi"],l=["AlignedSeq","AlignedSubpeptide","HELM","ID","PolymerID"];async function h(t,e,s="ginsi",a=1.53,h=0,u=null){const m=await n.dapi.docker.dockerContainers.filter("bio").first();if("started"!==m.status&&"checking"!==m.status)return n.log.warning("PepSeA container has not started yet"),null;const d=t.length;u??(u=i.Column.int("Clusters",d).init(0)),u.type!=i.COLUMN_TYPE.STRING&&(u=u.convertTo(i.TYPE.STRING));const g=u.categories,f=new Array(g.length);for(let e=0;e<d;++e){const s=u.get(e);if(""===s)continue;const n=g.indexOf(s),i=t.get(e);i&&(f[n]??(f[n]=[])).push({ID:e.toString(),HELM:i})}const p=new Array(d);for(const t of f){const e=(await c(m.id,t,s,a,h)).Alignment;for(const t of e)p[parseInt(t.ID)]=Object.entries(t).filter((t=>!l.includes(t[0]))).map((t=>"-"!==t[1]?t[1]:"")).join(o.rs.SEPARATOR)}const y=i.Column.fromStrings(e,p);return y.setTag(i.TAGS.UNITS,r.r2.SEPARATOR),y.setTag("separator",o.rs.SEPARATOR),y.setTag("aligned","SEQ.MSA"),y.setTag("alphabet","UN"),y.setTag(".alphabetIsMultichar","true"),y.semType=i.SEMTYPE.MACROMOLECULE,y}async function c(t,e,s,i,r){const o={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(e)},a=`/align?method=${s}&gap_open=${i}&gap_extend=${r}`,l=await n.dapi.docker.dockerContainers.request(t,a,o);return JSON.parse(l??"{}")}},9943:(t,e,s)=>{"use strict";s.d(e,{i$:()=>a,sK:()=>l}),s(976),s(3870),s(4469);var n=s(6414),i=s.n(n),r=s(8447);s(499);const o=60;function a(t,e,s=o,n="\n"){const i=r.kB,a=[];for(let r=0;r<e.length;r++){const o=t.map((t=>t.get(r).toString())).join("|"),h=l(e.get(r),i,s);a.push(`>${o}${n}`);for(const t of h)a.push(`${t}${n}`)}return"".concat(...a)}function l(t,e,s=o){const n=e(t);let r=0;const a=n.length,l=[];for(;r<a;){const t=i()(n).slice(r,r+s).toArray(),e=t.map((t=>t.length>1?`[${t}]`:t)).join("");l.push(e),r+=t.length}return l}},9416:(t,e,s)=>{"use strict";s.d(e,{n:()=>h});var n=s(4469),i=s(976),r=s(1061),o=s(2568),a=s(8457),l=s(3553);async function h(t,e){if(await(0,r.gw)(10),!(0,o.n)(e,"Sequence space"))return t;const s=(0,a.O)(e);s.name="splitToMonomers";const h=e.dataFrame;for(const t of s.columns)t.semType=l.Of.MONOMER,t.setTag("alphabet",e.getTag("alphabet"));const c=/(\d+)(?: \((\d+)\))?/,u=t=>{c.lastIndex=0;const e=t.match(c);return e?`${e[1]} (${parseInt(e[2]??0)+1})`:t};for(let t=0;t<s.columns.length;t++){const n=s.columns.byIndex(t);n.semType=l.Of.MONOMER,n.setTag("alphabet",e.getTag("alphabet"));const i=100;let r=0;for(;h.columns.byName(n.name)&&r<i;)n.name=u(n.name),r++;h.columns.add(n)}await n.data.detectSemanticTypes(h);for(let t=0;t<s.columns.length;t++){const e=s.columns.byIndex(t);e.setTag(i.TAGS.CELL_RENDERER,"Monomer"),e.setTag(".use-as-filter","false")}return h}},4293:(t,e,s)=>{"use strict";function n(t,e){t.innerHTML="",t.append(e)}s.d(e,{Y:()=>n}),s(4469),s(976)},833:(t,e,s)=>{"use strict";s.d(e,{bo:()=>g,CK:()=>y,yW:()=>p,eZ:()=>C});var n=s(4469),i=s(3870),r=s(976),o=s(6414),a=s.n(o),l=s(701),h=s(499),c=s(8447),u=s(9298);function m(t){var e;return"string"==typeof t||t instanceof String?t:("object"==typeof t||t instanceof Object)&&"$thrownJsError"in t?m(t.$thrownJsError):t instanceof Error?null!==(e=t.stack)&&void 0!==e?e:t.message:t.toString()}var d,g,f=s(2397);HTMLCanvasElement.prototype.getCursorPosition=function(t,e){const s=this.getBoundingClientRect();return new r.Point((t.clientX-s.left)*e,(t.clientY-s.top)*e)},r.Rect.prototype.contains=function(t,e){return this.left<=t&&t<=this.right&&this.top<=e&&e<=this.bottom};class p{constructor(t=0,e){this.count=t,this.bounds=e}}class y{get label(){return this._label?this._label:this.name}constructor(t,e,s,n){this.pos=t,this.name=e,this._freqs=s??{},n?.rowCount&&(this.rowCount=n.rowCount),n?.sumForHeightCalc&&(this.sumForHeightCalc=n.sumForHeightCalc),n?.label&&(this._label=n.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 p),e}getMonomerAt(t,e){const s=Object.entries(this._freqs).find((([s,n])=>n.bounds.contains(t,e)));return s?s[0]:void 0}calcHeights(t){this.rowCount=0;for(const[t,e]of Object.entries(this._freqs))this.rowCount+=e.count;if(this.sumForHeightCalc=0,t===u.ES.Entropy)for(const[t,e]of Object.entries(this._freqs)){const t=e.count/this.rowCount;this.sumForHeightCalc+=-t*Math.log2(t)}else if(t===u.ES.full)for(const[t,e]of Object.entries(this._freqs)){const t=e.count/this.rowCount;this.sumForHeightCalc+=t}}calcScreen(t,e,s,n,i,o,a,l,h,c){const m=i==u.ES.Entropy?n*(o-this.sumForHeightCalc)/o:n;let d=c*h+(n-m-1);const g=Object.entries(this._freqs).sort(((e,s)=>t(e[0])||t(s[0])?t(e[0])&&t(s[0])?0:t(e[0])?-1:1:s[1].count-e[1].count));for(const t of g){const n=t[1],i=m*n.count/this.rowCount;n.bounds=new r.Rect((e-s)*h*a,d,l*h,i),d+=i}}render(t,e,s,n,i,r){for(const[o,a]of Object.entries(this._freqs))if(!e(o)){const e=(0,c.GU)(o,5),l=a.bounds,h=l.left;t.resetTransform(),t.strokeStyle="lightgray",t.lineWidth=1,t.rect(h,l.top,l.width,l.height),t.fillStyle=r.get(o)??r.get("other"),t.textAlign="left",t.font=s;const u=t.measureText(e);t.setTransform(l.width/u.width,0,0,l.height/i,h,l.top),t.fillText(e,0,-n)}}}!function(t){t.STYLE="Style",t.BEHAVIOR="Behavior",t.LAYOUT="Layout",t.DATA="Data"}(d||(d={})),function(t){t.sequenceColumnName="sequenceColumnName",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.showPositionLabels="showPositionLabels",t.positionMarginState="positionMarginState",t.positionMargin="positionMargin",t.filterSource="filterSource"}(g||(g={}));const w=u.vS;var b;!function(t){t[t.None=0]="None",t[t.Render=1]="Render",t[t.Layout=1]="Layout",t[t.Freqs=2]="Freqs"}(b||(b={}));class T extends r.JsViewer{get positionWidthWithMargin(){return this._positionWidthWithMargin}get Length(){return this.skipEmptyPositions?this.positions.length:this.startPosition<=this.endPosition?this.endPosition-this.startPosition+1:0}get positionMarginValue(){return this.positionMarginState===u.dE.AUTO&&!0===this.unitsHandler.getAlphabetIsMultichar()||this.positionMarginState===u.dE.ON?this.positionMargin:0}constructor(){super(),this.viewed=!1,this.viewerId=-1,this.initialized=!1,this.cp=null,this.seqCol=null,this.positions=[],this.visibleSlider=!1,this.allowResize=!0,this.turnOfResizeForOneSetValue=!1,this.backgroundColor=4294967295,this.positionMargin=0,this.positionNames=[],this.positionLabels=void 0,this.startPosition=-1,this.endPosition=-1,this.error=null,this.viewPromise=Promise.resolve(),this.detachPromise=Promise.resolve(),this.setDataInProgress=!1,this.viewSubs=[],this._onSizeChanged=new l.Subject,this._onFreqsCalculated=new l.Subject,this._onLayoutCalculated=new l.Subject,this.renderLevelRequested=b.Freqs,this.viewerId=T.viewerCount,T.viewerCount+=1,this.textBaseline="top",this.unitsHandler=null,this.sequenceColumnName=this.string(g.sequenceColumnName,w.sequenceColumnName,{category:d.DATA}),this.startPositionName=this.string(g.startPositionName,w.startPositionName,{category:d.DATA}),this.endPositionName=this.string(g.endPositionName,w.endPositionName,{category:d.DATA}),this.skipEmptySequences=this.bool(g.skipEmptySequences,w.skipEmptySequences,{category:d.DATA}),this.skipEmptyPositions=this.bool(g.skipEmptyPositions,w.skipEmptyPositions,{category:d.DATA}),this.shrinkEmptyTail=this.bool(g.shrinkEmptyTail,w.shrinkEmptyTail,{category:d.DATA}),this.backgroundColor=this.int(g.backgroundColor,w.backgroundColor,{category:d.STYLE}),this.positionHeight=this.string(g.positionHeight,w.positionHeight,{category:d.STYLE,choices:Object.values(u.ES)}),this._positionWidth=this.positionWidth=this.float(g.positionWidth,w.positionWidth,{category:d.STYLE}),this.verticalAlignment=this.string(g.verticalAlignment,w.verticalAlignment,{category:d.LAYOUT,choices:Object.values(u.vw)}),this.horizontalAlignment=this.string(g.horizontalAlignment,w.horizontalAlignment,{category:d.LAYOUT,choices:Object.values(u.iD)}),this.fixWidth=this.bool(g.fixWidth,w.fixWidth,{category:d.LAYOUT,userEditable:!1}),this.fitArea=this.bool(g.fitArea,w.fitArea,{category:d.LAYOUT}),this.minHeight=this.float(g.minHeight,w.minHeight,{category:d.LAYOUT}),this.maxHeight=this.float(g.maxHeight,w.maxHeight,{category:d.LAYOUT}),this.showPositionLabels=this.bool(g.showPositionLabels,w.showPositionLabels,{category:d.LAYOUT}),this.positionMarginState=this.string(g.positionMarginState,w.positionMarginState,{category:d.LAYOUT,choices:Object.values(u.dE)});let t=0;"auto"===this.positionMarginState&&(t=4),this.positionMargin=this.int(g.positionMargin,t,{category:d.LAYOUT,min:0,max:16}),this.filterSource=this.string(g.filterSource,w.filterSource,{category:d.BEHAVIOR,choices:Object.values(u.Ct)}),this.slider=i.rangeSlider(0,100,0,20,!1,{style:"barbell"}),this.canvas=i.canvas(),this.canvas.classList.value="bio-wl-canvas",this.canvas.style.width="100%"}setData(){this.setDataInProgress||(this.setDataInProgress=!0,f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.setData() `),this.viewPromise=this.viewPromise.then((async()=>{this.viewed&&(await this.destroyView(),this.viewed=!1)})).then((async()=>{await this.detachPromise,this.updateSeqCol()})).then((async()=>{this.viewed||(await this.buildView(),this.viewed=!0)})).finally((()=>{this.setDataInProgress=!1})))}async destroyView(){for(const t of this.viewSubs)t.unsubscribe();this.viewSubs=[];const t=this.dataFrame?"data":"null";f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.destroyView( dataFrame = ${t} ) start`),this.host.remove(),this.msgHost=void 0,this.host=void 0,f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.destroyView() end`)}async buildView(){const t=this.dataFrame?"data":"null";f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.buildView( dataFrame = ${t} ) start`),window.devicePixelRatio,this.helpUrl="/help/visualize/viewers/web-logo.md",this.msgHost=i.div("No message",{classes:"bio-wl-msg"}),this.msgHost.style.display="none",this.canvas=i.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=i.div([this.msgHost,this.canvas],{classes:"bio-wl-host",style:{display:"flex",flexDirection:"row",flexWrap:"wrap"}}),this.root.append(this.host),this.root.append(this.slider.root),this.error&&(this.msgHost.innerText=this.error.message,i.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(i.onSizeChanged(this.root).subscribe(this.rootOnSizeChanged.bind(this))),this.viewSubs.push(this.slider.onValuesChanged.subscribe(this.sliderOnValuesChanged.bind(this))),this.viewSubs.push((0,l.fromEvent)(this.canvas,"mousemove").subscribe(this.canvasOnMouseMove.bind(this))),this.viewSubs.push((0,l.fromEvent)(this.canvas,"mousedown").subscribe(this.canvasOnMouseDown.bind(this))),this.viewSubs.push((0,l.fromEvent)(this.canvas,"wheel").subscribe(this.canvasOnWheel.bind(this))),await this.render(b.Freqs,"buildView"),f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.buildView() end`)}rootOnSizeChanged(){f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.rootOnSizeChanged(), start `),this.render(b.Layout,"rootOnSizeChanged").then((()=>{}))}updateSeqCol(){if(this.dataFrame&&(this.seqCol=this.sequenceColumnName?this.dataFrame.col(this.sequenceColumnName):null,null==this.seqCol&&(this.seqCol=(0,c.up)(this.dataFrame),this.sequenceColumnName=this.seqCol?this.seqCol.name:null),this.seqCol)){try{this.unitsHandler=h.Cn.getOrCreate(this.seqCol),this.cp=(0,c.dQ)(this.seqCol),this.updatePositions(),this.error=null}catch(t){throw this.seqCol=null,this.error=t instanceof Error?t:new Error(t.toString()),t}this.seqCol||(this.unitsHandler=null,this.positionNames=[],this.positionLabels=[],this.startPosition=-1,this.endPosition=-1,this.cp=null)}}updatePositions(){if(!this.seqCol)return;const t=this.getFilter(),e=0===t.trueCount?this.unitsHandler.maxLength:a().enumerate(this.unitsHandler.splitted).map((([e,s])=>t.get(s)&&e?e.length:0)).reduce(((t,e)=>Math.max(t,e)),0),s=this.seqCol.getTag(".positionNames"),n=this.seqCol.getTag(".positionLabels");this.positionNames=s?s.split(c.CI).map((t=>t.trim())):[...Array(e).keys()].map((t=>`${t+1}`)),this.positionLabels=n?n.split(c.CI).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):e-1,this.render(b.Freqs,"updatePositions").then((()=>{}))}getFilter(){let t;switch(this.filterSource){case u.Ct.Filtered:t=this.dataFrame.filter;break;case u.Ct.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.fitArea?this.calcLayoutFitArea(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,s=Math.min(Math.max(this.minHeight,this.root.clientHeight),this.maxHeight);this.host.style.justifyContent=u.iD.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=`${s}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=s*t}calcLayoutNoFitArea(t){if(!this.host||!this.canvas||!this.slider)return;const e=this._positionWidthWithMargin*this.Length,s=Math.min(Math.max(this.minHeight,this.root.clientHeight),this.maxHeight),n=Math.min(this.root.clientWidth,e);this.canvas.style.width=`${n}px`,this.canvas.style.height=`${s}px`,this.host.style.width=`${n}px`,this.host.style.height=`${this.root.clientHeight}px`,this.host.style.justifyContent=this.horizontalAlignment,this.host.style.alignContent=this.verticalAlignment===u.vw.TOP?"start":this.verticalAlignment===u.vw.MIDDLE?"center":this.verticalAlignment===u.vw.BOTTOM?"end":"inherit",this.root.clientHeight<this.minHeight&&(this.host.style.alignContent="start",this.host.style.width=`${n+6}px`),this.host.style.width=`${this.host}px`;const i=e>n;if(this.setSliderVisibility(i),i){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 s=this.root.clientWidth/this._positionWidthWithMargin;e=Math.min(Math.max(t,0)+s,this.Length-.001),t=Math.max(0,Math.min(e,this.Length-.001)-s),this.slider.setValues(0,Math.max(this.Length-.001),t,e)}else this.slider.setValues(0,Math.max(0,this.Length-.001),0,Math.max(0,this.Length-.001));this.canvas.width=n*t,this.canvas.height=s*t}calcLayoutFitArea(t){if(!this.host||!this.canvas||!this.slider)return;const e=this._positionWidth*this.Length,s=Math.min(Math.max(this.minHeight,this.root.clientHeight),this.maxHeight),n=e>0?(this.root.clientWidth-this.positionMarginValue*this.Length)/e:0,i=this.root.clientHeight/s,r=Math.max(1,Math.min(n,i));this._positionWidth=this.positionWidth*r,this._positionWidthWithMargin=this._positionWidth+this.positionMarginValue;const o=(this._positionWidth+this.positionMarginValue)*this.Length,a=r*s,l=Math.min(this.root.clientWidth,o);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===u.vw.TOP?"start":this.verticalAlignment===u.vw.MIDDLE?"center":this.verticalAlignment===u.vw.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 h=o>l;if(this.setSliderVisibility(h),h){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 s=this.root.clientWidth/this._positionWidthWithMargin;e=Math.min(Math.max(t,0)+s,this.Length-.001),t=Math.max(0,Math.min(e,this.Length-.001)-s),this.slider.setValues(0,Math.max(0,this.Length-.001),t,e)}else this.slider.setValues(0,Math.max(0,this.Length-.001),0,Math.max(0,this.Length-.001));this.canvas.width=l*t,this.canvas.height=a*t}onPropertyChanged(t){switch(super.onPropertyChanged(t),t.name){case g.sequenceColumnName:this.updateSeqCol();break;case g.sequenceColumnName:case g.startPositionName:case g.endPositionName:case g.filterSource:case g.shrinkEmptyTail:case g.skipEmptyPositions:case g.positionHeight:this.updatePositions();break;case g.minHeight:case g.maxHeight:case g.positionWidth:case g.showPositionLabels:case g.fixWidth:case g.fitArea:case g.horizontalAlignment:case g.verticalAlignment:case g.positionMargin:case g.positionMarginState:this.render(b.Layout,`onPropertyChanged(${t.name})`).then((()=>{}));break;case g.backgroundColor:this.render(b.Render,`onPropertyChanged(${t.name})`).then((()=>{}))}}onTableAttached(){f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.onTableAttached(), `),super.onTableAttached(),this.setData()}async detach(){if(this.setDataInProgress)return;f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.detach(), `);const t=super.detach.bind(this);this.detachPromise=this.detachPromise.then((async()=>{await this.viewPromise,this.viewed&&(await this.destroyView(),this.viewed=!1),t()}))}get onSizeChanged(){return this._onSizeChanged}get onFreqsCalculated(){return this._onFreqsCalculated}get onLayoutCalculated(){return this._onLayoutCalculated}getMonomer(t,e){const s=t.x,n=Math.floor(t.x/(this._positionWidthWithMargin*e)+Math.floor(this.slider.min)),i=this.positions[n];if(void 0===i)return[n,null,null];const r=i.getMonomerAt(s,t.y);return void 0===r?[n,null,null]:[n,r,i.getFreq(r)]}_nullSequence(t="X"){return this.skipEmptySequences?"":new Array(this.Length).fill(t).join("")}_removeEmptyPositions(){this.skipEmptyPositions&&(this.positions=a()(this.positions).filter((t=>{const e=this.unitsHandler.defaultGapSymbol;return!t.hasMonomer(e)||t.getFreq(e).count!==t.rowCount})).toArray())}render(t,e){f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.render( recalcLevelVal=${t}, reason='${e}' )`);const s=()=>{if(f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.render.calculateFreqsInt(), start `),!this.host||!this.seqCol||!this.dataFrame)return;const t=this.startPosition<=this.endPosition?this.endPosition-this.startPosition+1:0;this.unitsHandler=h.Cn.getOrCreate(this.seqCol);const e=this.startPosition<=this.endPosition?this.endPosition-this.startPosition+1:0;this.positions=new Array(e);for(let e=0;e<t;e++){const t=this.positionNames[this.startPosition+e],s=this.positionLabels?this.positionLabels[this.startPosition+e]:void 0;this.positions[e]=new y(this.startPosition+e,t,{},{label:s})}const s=this.getFilter(),n=this.dataFrame.rowCount,i=this.unitsHandler.splitted;for(let e=0;e<n;++e)if(s.get(e)){const s=i[e];for(let e=0;e<t;++e){const t=s[this.startPosition+e]||this.unitsHandler.defaultGapSymbol;this.positions[e].getFreq(t).count++}}for(let e=0;e<t;e++)this.positions[e].calcHeights(this.positionHeight);this._removeEmptyPositions(),this._onFreqsCalculated.next()},i=(t,e)=>{f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.render.calculateLayoutInt(), start `);const s=this.canvas.height-e*t,i=this.getAlphabetSize();this.positionHeight==u.ES.Entropy&&null==i&&n.shell.error("WebLogo: alphabet is undefined.");const r=Math.log2(i);for(let n=Math.floor(this.slider.min);n<=Math.floor(this.slider.max);++n)n in this.positions?this.positions[n].calcScreen((t=>this.unitsHandler.isGap(t)),n,this.slider.min,s,this.positionHeight,r,this._positionWidthWithMargin,this._positionWidth,t,e):console.warn(`Bio: WebLogoViewer<${this.viewerId}>.render.calculateLayoutInt() this.positions.length = ${this.positions.length}, jPos = ${n}`);f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.render.calculateLayoutInt(), end `),this._onLayoutCalculated.next()},o=t=>{if(f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.render.renderInt( recalcLevel=${t} ), start `),this.msgHost&&(this.seqCol&&!this.cp?(this.msgHost.innerText=`Unknown palette (column semType: '${this.seqCol.semType}').`,this.msgHost.style.display=""):this.msgHost.style.display="none"),!this.seqCol||!this.dataFrame||!this.cp||null==this.host||null==this.slider)return;const e=window.devicePixelRatio,n=this.showPositionLabels?12:0;if(t>=b.Freqs&&s(),this.calcLayout(e),0===this.positions.length||-1===this.startPosition||-1===this.endPosition)return;t>=b.Layout&&i(window.devicePixelRatio,n);const o=this.canvas.getContext("2d");if(!o)return;this.Length,o.resetTransform(),o.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),o.fillRect(0,0,this.canvas.width,this.canvas.height),o.textBaseline=this.textBaseline;const a=10*e;o.resetTransform(),o.fillStyle="black",o.textAlign="center",o.font=`${a.toFixed(1)}px Roboto, Roboto Local, sans-serif`;const l=Math.max(...this.positions.map((t=>o.measureText(t.name).width))),h=l<this._positionWidth*e-2?1:(this._positionWidth*e-2)/l;n>0&&function(t,e,s,n,i,r,o,a){for(let l=Math.floor(o);l<=Math.floor(a);l++){const a=r[l];t.resetTransform(),t.setTransform(s,0,0,1,(l-o)*n*e+i*e/2,0),t.fillText(a.label,0,1)}}(o,e,h,this._positionWidthWithMargin,this._positionWidth,this.positions,this.slider.min,this.slider.max);for(let t=Math.floor(this.slider.min);t<=Math.floor(this.slider.max);t++)this.positions[t].render(o,(t=>this.unitsHandler.isGap(t)),"16px Roboto, Roboto Local, sans-serif",.25,12.2,this.cp);f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.render.renderInt( recalcLevel=${t} ), end`)};return this.renderLevelRequested=Math.max(this.renderLevelRequested,t),new Promise(((t,e)=>{window.setTimeout((()=>{try{if(this.renderLevelRequested>b.None)try{o(this.renderLevelRequested)}finally{this.renderLevelRequested=b.None}}catch(t){e(t)}}),0)}))}getAlphabetSize(){return this.unitsHandler?.getAlphabetSize()??0}sliderOnValuesChanged(t){try{const t={minRange:this.slider.minRange,min:this.slider.min,max:this.slider.max,maxRange:this.slider.maxRange};f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.sliderOnValuesChanged( ${JSON.stringify(t)} ), start`),this.render(b.Layout,"sliderOnValuesChanged").then((()=>{}))}catch(t){const e=m(t);f._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.sliderOnValuesChanged() error:\n`+e)}}dataFrameFilterOnChanged(t){f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.dataFrameFilterChanged()`);try{this.updatePositions(),this.filterSource===u.Ct.Filtered&&this.render(b.Freqs,"dataFrameFilterOnChanged").then((()=>{}))}catch(t){const e=m(t);f._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.dataFrameFilterOnChanged() error:\n`+e)}}dataFrameSelectionOnChanged(t){f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.dataFrameSelectionOnChanged()`);try{this.filterSource===u.Ct.Selected&&this.render(b.Freqs,"dataFrameSelectionOnChanged").then((()=>{}))}catch(t){const e=m(t);f._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.dataFrameSelectionOnChanged() error:\n`+e)}}canvasOnMouseMove(t){const e=window.devicePixelRatio;try{const s=t,n=this.canvas.getCursorPosition(s,e),[r,o]=this.getMonomer(n,e);if(this.dataFrame&&this.seqCol&&o){const t=this.positions[r],e=C(this.dataFrame,this.unitsHandler,this.getFilter(),o,t),n=i.div([i.div(`${o}`),i.div(`${e} rows`)]);i.tooltip.show(n,s.x+16,s.y+16)}else i.tooltip.hide()}catch(t){const e=m(t);f._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.canvasOnMouseMove() error:\n`+e)}}canvasOnMouseDown(t){try{const e=t,s=window.devicePixelRatio,[n,i]=this.getMonomer(this.canvas.getCursorPosition(e,s),s);if(this.dataFrame&&this.seqCol&&this.unitsHandler&&i){const t=this.positions[n],e=r.BitSet.create(this.dataFrame.selection.length,(e=>function(t,e,s,n,i,r){const o=e.splitted[n],a=r.pos<o.length?o[r.pos]:null;return a===i||""===a&&i===e.defaultGapSymbol}(this.dataFrame,this.unitsHandler,this.getFilter(),e,i,t)));this.dataFrame.selection.init((t=>e.get(t)))}}catch(t){const e=m(t);f._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.canvasOnMouseDown() error:\n`+e)}}canvasOnWheel(t){const e=window.devicePixelRatio;try{if(!this.visibleSlider)return;const s=this.canvas.width/(this._positionWidthWithMargin*e),n=t.deltaY/100*Math.max(Math.floor(s/5),1);this.slider.scrollBy(this.slider.min+n)}catch(t){const e=m(t);f._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.canvasOnWheel() error:\n`+e)}}}function C(t,e,s,n,i){let r=0,o=-1;for(;-1!=(o=s.findNext(o,!0));){const t=e.splitted[o],s=i.pos;(s<t.length?t[s]:null)===n&&r++}return r}T.residuesSet="nucleotides",T.viewerCount=0},4413:(t,e,s)=>{"use strict";s.d(e,{ST:()=>g});var n=s(3870),i=s(976),r=s(4469),o=s(6414),a=s.n(o),l=s(7983),h=s(701),c=s(4293),u=s(8447),m=s(1061);const d=rxjs.operators;class g extends i.Filter{get calculating(){return"initial"==this.loader.style.display}set calculating(t){this.loader.style.display=t?"initial":"none"}get filterSummary(){return this.bioFilter.substructure}get isFiltering(){return super.isFiltering&&""!==this.bioFilter.substructure}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(){super(),this.bioFilter=null,this.bitset=null,this.loader=n.loader(),this.notation=void 0,this.root=n.divV([]),this.calculating=!1}attach(t){super.attach(t),this.column=t.columns.bySemType(i.SEMTYPE.MACROMOLECULE),this.columnName??(this.columnName=this.column?.name),this.notation??(this.notation=this.column?.getTag(i.TAGS.UNITS)),this.bioFilter=this.notation===u.r2.FASTA?new p:this.notation===u.r2.SEPARATOR?new y(this.column.getTag("separator")):new w,this.root.appendChild(this.bioFilter.filterPanel),this.root.appendChild(this.loader),this.onBioFilterChangedSubs?.unsubscribe();let e=this.bioFilter.onChanged;e=e.pipe((0,d.debounceTime)(this._debounceTime)),this.onBioFilterChangedSubs=e.subscribe((async t=>await this._onInputChanged())),this.subs.push(r.events.onResetFilterRequest.subscribe((t=>{this.bioFilter?.resetFilter()})))}detach(){super.detach()}applyFilter(){this.bitset&&!this.isDetached&&this.dataFrame?.filter.and(this.bitset)}saveState(){const t=super.saveState();return t.bioSubstructure=this.bioFilter?.substructure,t}applyState(t){super.applyState(t),t.bioSubstructure&&(this.bioFilter.substructure=t.bioSubstructure);const e=this;t.bioSubstructure&&setTimeout((function(){e._onInputChanged()}),1e3)}async _onInputChanged(){if(this.isFiltering){if(a()(this.dataFrame.rows.filters).has(`${this.columnName}: ${this.filterSummary}`))return;this.calculating=!0;try{this.bitset=await(this.bioFilter?.substructureSearch(this.column)),this.calculating=!1,this.dataFrame?.rows.requestFilter()}finally{this.calculating=!1}}else this.bitset=null,this.dataFrame?.rows.requestFilter()}}class f{constructor(){this.onChanged=new h.Subject}get filterPanel(){return new HTMLElement}get substructure(){return""}set substructure(t){}async substructureSearch(t){return null}}class p extends f{constructor(){super(),this.substructureInput=n.stringInput("","",(()=>{this.onChanged.next()}),{placeholder:"Substructure"})}get filterPanel(){return this.substructureInput.root}get substructure(){return this.substructureInput.value}set substructure(t){this.substructureInput.value=t}async substructureSearch(t){return(0,l.pf)(this.substructure,t)}resetFilter(){this.substructureInput.value=""}}class y extends p{constructor(t){super(),this.colSeparator="",this.separatorInput=n.stringInput("","",(()=>{this.onChanged.next()}),{placeholder:"Separator"}),this.colSeparator=t,this.separatorInput.value=t}get filterPanel(){return n.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,l.pf)(this.substructure,t,this.colSeparator)}}class w extends f{constructor(){super(),this._filterPanel=n.div("",{style:{cursor:"pointer"}}),this.helmSubstructure="",this.init()}async init(){this.helmEditor=await r.functions.call("HELM:helmWebEditor"),await n.tools.waitForElementInDom(this._filterPanel),this.updateFilterPanel(),this._filterPanel.addEventListener("click",(t=>{const{editorDiv:e,webEditor:s}=this.helmEditor.createWebEditor(this.helmSubstructure);n.dialog({showHeader:!1,showFooter:!0}).add(e).onOK((()=>{const t=s.canvas.getHelm(!0).replace(/<\/span>/g,"").replace(/<span style='background:#bbf;'>/g,"");this.helmSubstructure=t,this.updateFilterPanel(this.substructure),setTimeout((()=>{this.onChanged.next()}),10)})).show({modal:!0,fullScreen:!0})})),n.onSizeChanged(this._filterPanel).subscribe((t=>{const e=this.helmEditor.webEditor.canvas.getHelm(!0).replace(/<\/span>/g,"").replace(/<span style='background:#bbf;'>/g,"");this.updateFilterPanel(e)}))}get filterPanel(){return this._filterPanel}get substructure(){return this.helmSubstructure}set substructure(t){this.helmEditor.editor.setHelm(t)}updateFilterPanel(t){const e=this._filterPanel.parentElement.clientWidth<100?100:this._filterPanel.parentElement.clientWidth,s=e/2;if(t)(0,c.Y)(this._filterPanel,this.helmEditor.host),this.helmEditor.editor.setHelm(t),this.helmEditor.resizeEditor(e,s);else{const t=n.divText("Click to edit","helm-substructure-filter");(0,c.Y)(this._filterPanel,t)}}async substructureSearch(t){n.setUpdateIndicator(this._filterPanel,!0),await(0,m.gw)(10);const e=await(0,l.QF)(this.substructure,t);return n.setUpdateIndicator(this._filterPanel,!1),e}resetFilter(){console.debug("Bio: HelmFilter.resetFilter()"),this.helmSubstructure="",this.updateFilterPanel(this.substructure)}}},9378:function(t,e,s){"use strict";var n=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var s in t)Object.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e.default=t,e};Object.defineProperty(e,"__esModule",{value:!0});var i=n(s(4517));function r(t,e){var s=function(s){return i.empty(t).map((function(){return i.filled(e,s)}))},n=[];return n.push(s(-1)),n.push(s(1/0)),n.push(s(0)),n}function o(t,e,s,n,i){e=Math.floor(e);var r=t[0][e],o=t[1][e];if(t[2][e],s>=o[0])return 0;for(var l=0;l<r.length;l++)if(n===r[l])return 0;return a(t,e,s,n,i)}function a(t,e,s,n,i){var r=t[0][e],o=t[1][e],a=t[2][e];if(s>=o[0])return 0;o[0]=s,r[0]=n,a[0]=i;for(var l=0,h=0;;){var c=2*l+1,u=c+1,m=t[0][0].length;if(c>=m)break;if(u>=m){if(!(o[c]>s))break;h=c}else if(o[c]>=o[u]){if(!(s<o[c]))break;h=c}else{if(!(s<o[u]))break;h=u}o[l]=o[h],r[l]=r[h],a[l]=a[h],l=h}return o[l]=s,r[l]=n,a[l]=i,1}function l(t,e,s,n){for(;2*n+1<s;){var i=2*n+1,r=i+1,o=n;if(t[o]<t[i]&&(o=i),r<s&&t[o]<t[r]&&(o=r),o===n)break;var a=t[n];t[n]=t[o],t[o]=a;var l=e[n];e[n]=e[o],e[o]=l,n=o}}e.makeHeap=r,e.rejectionSample=function(t,e,s){for(var n=i.zeros(t),r=0;r<t;r++){for(var o=!0,a=0;o;){a=i.tauRandInt(e,s);for(var l=!1,h=0;h<r;h++)if(a===n[h]){l=!0;break}l||(o=!1)}n[r]=a}return n},e.heapPush=o,e.uncheckedHeapPush=a,e.buildCandidates=function(t,e,s,n,a){for(var l=r(e,n),h=0;h<e;h++)for(var c=0;c<s;c++)if(!(t[0][h][c]<0)){var u=t[0][h][c],m=t[2][h][c],d=i.tauRand(a);o(l,h,d,u,m),o(l,u,d,h,m),t[2][h][c]=0}return l},e.deheapSort=function(t){for(var e=t[0],s=t[1],n=0;n<e.length;n++)for(var i=e[n],r=s[n],o=0;o<i.length-1;o++){var a=i.length-o-1,h=r.length-o-1,c=i[0];i[0]=i[a],i[a]=c;var u=r[0];r[0]=r[h],r[h]=u,l(r,i,h,0)}return{indices:e,weights:s}},e.smallestFlagged=function(t,e){for(var s=t[0][e],n=t[1][e],i=t[2][e],r=1/0,o=-1,a=0;a>s.length;a++)1===i[a]&&n[a]<r&&(r=n[a],o=a);return o>=0?(i[o]=0,Math.floor(s[o])):-1}},4221:(t,e,s)=>{"use strict";var n=s(4364);e.u=n.UMAP},5686:function(t,e,s){"use strict";var n,i=this&&this.__read||function(t,e){var s="function"==typeof Symbol&&t[Symbol.iterator];if(!s)return t;var n,i,r=s.call(t),o=[];try{for(;(void 0===e||e-- >0)&&!(n=r.next()).done;)o.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(s=r.return)&&s.call(r)}finally{if(i)throw i.error}}return o},r=this&&this.__values||function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],s=0;return e?e.call(t):{next:function(){return t&&s>=t.length&&(t=void 0),{value:t&&t[s++],done:!t}}}},o=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var s in t)Object.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e.default=t,e};Object.defineProperty(e,"__esModule",{value:!0});var a=o(s(4517)),l=function(){function t(t,e,s,n){if(this.entries=new Map,this.nRows=0,this.nCols=0,t.length!==e.length||t.length!==s.length)throw new Error("rows, cols and values arrays must all have the same length");this.nRows=n[0],this.nCols=n[1];for(var i=0;i<s.length;i++){var r=t[i],o=e[i];this.checkDims(r,o);var a=this.makeKey(r,o);this.entries.set(a,{value:s[i],row:r,col:o})}}return t.prototype.makeKey=function(t,e){return t+":"+e},t.prototype.checkDims=function(t,e){if(!(t<this.nRows&&e<this.nCols))throw new Error("row and/or col specified outside of matrix dimensions")},t.prototype.set=function(t,e,s){this.checkDims(t,e);var n=this.makeKey(t,e);this.entries.has(n)?this.entries.get(n).value=s:this.entries.set(n,{value:s,row:t,col:e})},t.prototype.get=function(t,e,s){void 0===s&&(s=0),this.checkDims(t,e);var n=this.makeKey(t,e);return this.entries.has(n)?this.entries.get(n).value:s},t.prototype.getAll=function(t){void 0===t&&(t=!0);var e=[];return this.entries.forEach((function(t){e.push(t)})),t&&e.sort((function(t,e){return t.row===e.row?t.col-e.col:t.row-e.row})),e},t.prototype.getDims=function(){return[this.nRows,this.nCols]},t.prototype.getRows=function(){return Array.from(this.entries,(function(t){var e=i(t,2);return e[0],e[1].row}))},t.prototype.getCols=function(){return Array.from(this.entries,(function(t){var e=i(t,2);return e[0],e[1].col}))},t.prototype.getValues=function(){return Array.from(this.entries,(function(t){var e=i(t,2);return e[0],e[1].value}))},t.prototype.forEach=function(t){this.entries.forEach((function(e){return t(e.value,e.row,e.col)}))},t.prototype.map=function(e){var s=[];this.entries.forEach((function(t){s.push(e(t.value,t.row,t.col))}));var n=[this.nRows,this.nCols];return new t(this.getRows(),this.getCols(),s,n)},t.prototype.toArray=function(){var t=this,e=a.empty(this.nRows).map((function(){return a.zeros(t.nCols)}));return this.entries.forEach((function(t){e[t.row][t.col]=t.value})),e},t}();e.SparseMatrix=l,e.transpose=function(t){var e=[],s=[],n=[];t.forEach((function(t,i,r){e.push(i),s.push(r),n.push(t)}));var i=[t.nCols,t.nRows];return new l(s,e,n,i)},e.identity=function(t){for(var e=i(t,1)[0],s=new l([],[],[],t),n=0;n<e;n++)s.set(n,n,1);return s},e.pairwiseMultiply=function(t,e){return c(t,e,(function(t,e){return t*e}))},e.add=function(t,e){return c(t,e,(function(t,e){return t+e}))},e.subtract=function(t,e){return c(t,e,(function(t,e){return t-e}))},e.maximum=function(t,e){return c(t,e,(function(t,e){return t>e?t:e}))},e.multiplyScalar=function(t,e){return t.map((function(t){return t*e}))},e.eliminateZeros=function(t){for(var e=new Set,s=t.getValues(),n=t.getRows(),i=t.getCols(),r=0;r<s.length;r++)0===s[r]&&e.add(r);var o=function(t,s){return!e.has(s)},a=s.filter(o),h=n.filter(o),c=i.filter(o);return new l(h,c,a,t.getDims())},e.normalize=function(t,e){var s,n;void 0===e&&(e="l2");var i=h[e],o=new Map;t.forEach((function(t,e,s){var n=o.get(e)||[];n.push(s),o.set(e,n)}));var a=new l([],[],[],t.getDims()),c=function(e){for(var s=o.get(e).sort(),n=s.map((function(s){return t.get(e,s)})),r=i(n),l=0;l<r.length;l++)a.set(e,s[l],r[l])};try{for(var u=r(o.keys()),m=u.next();!m.done;m=u.next())c(m.value)}catch(t){s={error:t}}finally{try{m&&!m.done&&(n=u.return)&&n.call(u)}finally{if(s)throw s.error}}return a};var h=((n={}).max=function(t){for(var e=-1/0,s=0;s<t.length;s++)e=t[s]>e?t[s]:e;return t.map((function(t){return t/e}))},n.l1=function(t){for(var e=0,s=0;s<t.length;s++)e+=t[s];return t.map((function(t){return t/e}))},n.l2=function(t){for(var e=0,s=0;s<t.length;s++)e+=Math.pow(t[s],2);return t.map((function(t){return Math.sqrt(Math.pow(t,2)/e)}))},n);function c(t,e,s){for(var n=new Set,i=[],r=[],o=[],a=function(n,a){i.push(n),r.push(a);var l=s(t.get(n,a),e.get(n,a));o.push(l)},h=t.getValues(),c=t.getRows(),u=t.getCols(),m=0;m<h.length;m++){var d=(y=c[m])+":"+(w=u[m]);n.add(d),a(y,w)}var g=e.getValues(),f=e.getRows(),p=e.getCols();for(m=0;m<g.length;m++){var y,w;d=(y=f[m])+":"+(w=p[m]),n.has(d)||a(y,w)}var b=[t.nRows,t.nCols];return new l(i,r,o,b)}e.getCSR=function(t){var e=[];t.forEach((function(t,s,n){e.push({value:t,row:s,col:n})})),e.sort((function(t,e){return t.row===e.row?t.col-e.col:t.row-e.row}));for(var s=[],n=[],i=[],r=-1,o=0;o<e.length;o++){var a=e[o],l=a.row,h=a.col,c=a.value;l!==r&&(r=l,i.push(o)),s.push(h),n.push(c)}return{indices:s,values:n,indptr:i}}},760:function(t,e,s){"use strict";var n=this&&this.__values||function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],s=0;return e?e.call(t):{next:function(){return t&&s>=t.length&&(t=void 0),{value:t&&t[s++],done:!t}}}},i=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var s in t)Object.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e.default=t,e};Object.defineProperty(e,"__esModule",{value:!0});var r=i(s(9378)),o=i(s(5686)),a=i(s(2320)),l=i(s(4517));e.makeNNDescent=function(t,e){return function(s,n,i,o,a,h,c,u){void 0===o&&(o=10),void 0===a&&(a=50),void 0===h&&(h=.001),void 0===c&&(c=.5),void 0===u&&(u=!0);for(var m=s.length,d=r.makeHeap(s.length,i),g=0;g<s.length;g++)for(var f=r.rejectionSample(i,s.length,e),p=0;p<f.length;p++){var y=t(s[g],s[f[p]]);r.heapPush(d,g,y,f[p],1),r.heapPush(d,f[p],y,g,1)}if(u)for(var w=0;w<n.length;w++)for(g=0;g<n[w].length&&!(n[w][g]<0);g++)for(p=g+1;p<n[w].length&&!(n[w][p]<0);p++)y=t(s[n[w][g]],s[n[w][p]]),r.heapPush(d,n[w][g],y,n[w][p],1),r.heapPush(d,n[w][p],y,n[w][g],1);for(w=0;w<o;w++){var b=r.buildCandidates(d,m,i,a,e),T=0;for(g=0;g<m;g++)for(p=0;p<a;p++){var C=Math.floor(b[0][g][p]);if(!(C<0||l.tauRand(e)<c))for(var S=0;S<a;S++){var A=Math.floor(b[0][g][S]),v=b[2][g][p],E=b[2][g][S];A<0||!v&&!E||(y=t(s[C],s[A]),T+=r.heapPush(d,C,y,A,1),T+=r.heapPush(d,A,y,C,1))}}if(T<=h*i*s.length)break}return r.deheapSort(d)}},e.makeInitializations=function(t){return{initFromRandom:function(e,s,n,i,o){for(var a=0;a<n.length;a++)for(var h=l.rejectionSample(e,s.length,o),c=0;c<h.length;c++)if(!(h[c]<0)){var u=t(s[h[c]],n[a]);r.heapPush(i,a,u,h[c],1)}},initFromTree:function(e,s,n,i,o){for(var l=0;l<n.length;l++)for(var h=a.searchFlatTree(n[l],e,o),c=0;c<h.length;c++){if(h[c]<0)return;var u=t(s[h[c]],n[l]);r.heapPush(i,l,u,h[c],1)}}}},e.makeInitializedNNSearch=function(t){return function(e,s,i,a){for(var l,h,c=o.getCSR(s),u=c.indices,m=c.indptr,d=0;d<a.length;d++)for(var g=new Set(i[0][d]);;){var f=r.smallestFlagged(i,d);if(-1===f)break;var p=u.slice(m[f],m[f+1]);try{for(var y=n(p),w=y.next();!w.done;w=y.next()){var b=w.value;if(b!==f&&-1!==b&&!g.has(b)){var T=t(e[b],a[d]);r.uncheckedHeapPush(i,d,T,b,1),g.add(b)}}}catch(t){l={error:t}}finally{try{w&&!w.done&&(h=y.return)&&h.call(y)}finally{if(l)throw l.error}}}return i}},e.initializeSearch=function(t,e,s,i,o,a,l){var h,c,u=r.makeHeap(s.length,i);if(o(i,e,s,u,l),t)try{for(var m=n(t),d=m.next();!d.done;d=m.next())a(d.value,e,s,u,l)}catch(t){h={error:t}}finally{try{d&&!d.done&&(c=m.return)&&c.call(m)}finally{if(h)throw h.error}}return u}},2320:function(t,e,s){"use strict";var n=this&&this.__read||function(t,e){var s="function"==typeof Symbol&&t[Symbol.iterator];if(!s)return t;var n,i,r=s.call(t),o=[];try{for(;(void 0===e||e-- >0)&&!(n=r.next()).done;)o.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(s=r.return)&&s.call(r)}finally{if(i)throw i.error}}return o},i=this&&this.__spread||function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(n(arguments[e]));return t},r=this&&this.__values||function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],s=0;return e?e.call(t):{next:function(){return t&&s>=t.length&&(t=void 0),{value:t&&t[s++],done:!t}}}},o=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var s in t)Object.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e.default=t,e};Object.defineProperty(e,"__esModule",{value:!0});var a=o(s(4517)),l=function(t,e,s,n){this.hyperplanes=t,this.offsets=e,this.children=s,this.indices=n};function h(t,e,s,n,i){if(void 0===s&&(s=30),e.length>s){var r=function(t,e,s){var n=t[0].length,i=a.tauRandInt(e.length,s),r=a.tauRandInt(e.length,s);r=(r+=i===r?1:0)%e.length;for(var o=e[i],l=e[r],h=0,c=a.zeros(n),u=0;u<c.length;u++)c[u]=t[o][u]-t[l][u],h-=c[u]*(t[o][u]+t[l][u])/2;var m=0,d=0,g=a.zeros(e.length);for(u=0;u<e.length;u++){for(var f=h,p=0;p<n;p++)f+=c[p]*t[e[u]][p];0===f?(g[u]=a.tauRandInt(2,s),0===g[u]?m+=1:d+=1):f>0?(g[u]=0,m+=1):(g[u]=1,d+=1)}var y=a.zeros(m),w=a.zeros(d);for(m=0,d=0,u=0;u<g.length;u++)0===g[u]?(y[m]=e[u],m+=1):(w[d]=e[u],d+=1);return{indicesLeft:y,indicesRight:w,hyperplane:c,offset:h}}(t,e,i),o=r.indicesLeft,l=r.indicesRight,c=r.hyperplane,u=r.offset;return{leftChild:h(t,o,s,n+1,i),rightChild:h(t,l,s,n+1,i),isLeaf:!1,hyperplane:c,offset:u}}return{indices:e,isLeaf:!0}}function c(t,e,s,n,r,o,a){var l;if(t.isLeaf)return n[o][0]=-a,(l=r[a]).splice.apply(l,i([0,t.indices.length],t.indices)),{nodeNum:o,leafNum:a+=1};e[o]=t.hyperplane,s[o]=t.offset,n[o][0]=o+1;var h=o,u=c(t.leftChild,e,s,n,r,o+1,a);return o=u.nodeNum,a=u.leafNum,n[h][1]=o+1,{nodeNum:(u=c(t.rightChild,e,s,n,r,o+1,a)).nodeNum,leafNum:u.leafNum}}function u(t){return t.isLeaf?1:1+u(t.leftChild)+u(t.rightChild)}function m(t){return t.isLeaf?1:m(t.leftChild)+m(t.rightChild)}function d(t,e,s,n){for(var i=e,r=0;r<s.length;r++)i+=t[r]*s[r];return 0===i?a.tauRandInt(2,n):i>0?0:1}e.FlatTree=l,e.makeForest=function(t,e,s,n){var i=Math.max(10,e);return a.range(s).map((function(e,s){return function(t,e,s,n){return void 0===e&&(e=30),h(t,a.range(t.length),e,s,n)}(t,i,s,n)})).map((function(t){return function(t,e){var s=u(t),n=m(t),i=a.range(s).map((function(){return a.zeros(t.hyperplane?t.hyperplane.length:0)})),r=a.zeros(s),o=a.range(s).map((function(){return[-1,-1]})),h=a.range(n).map((function(){return a.range(e).map((function(){return-1}))}));return c(t,i,r,o,h,0,0),new l(i,r,o,h)}(t,i)}))},e.makeLeafArray=function(t){var e,s;if(t.length>0){var n=[];try{for(var o=r(t),a=o.next();!a.done;a=o.next()){var l=a.value;n.push.apply(n,i(l.indices))}}catch(t){e={error:t}}finally{try{a&&!a.done&&(s=o.return)&&s.call(o)}finally{if(e)throw e.error}}return n}return[[-1]]},e.searchFlatTree=function(t,e,s){for(var n=0;e.children[n][0]>0;)n=0===d(e.hyperplanes[n],e.offsets[n],t,s)?e.children[n][0]:e.children[n][1];var i=-1*e.children[n][0];return e.indices[i]}},4364:function(t,e,s){"use strict";var n=this&&this.__awaiter||function(t,e,s,n){return new(s||(s=Promise))((function(i,r){function o(t){try{l(n.next(t))}catch(t){r(t)}}function a(t){try{l(n.throw(t))}catch(t){r(t)}}function l(t){t.done?i(t.value):new s((function(e){e(t.value)})).then(o,a)}l((n=n.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var s,n,i,r,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return r={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function a(r){return function(a){return function(r){if(s)throw new TypeError("Generator is already executing.");for(;o;)try{if(s=1,n&&(i=2&r[0]?n.return:r[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,r[1])).done)return i;switch(n=0,i&&(r=[2&r[0],i.value]),r[0]){case 0:case 1:i=r;break;case 4:return o.label++,{value:r[1],done:!1};case 5:o.label++,n=r[1],r=[0];continue;case 7:r=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==r[0]&&2!==r[0])){o=0;continue}if(3===r[0]&&(!i||r[1]>i[0]&&r[1]<i[3])){o.label=r[1];break}if(6===r[0]&&o.label<i[1]){o.label=i[1],i=r;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(r);break}i[2]&&o.ops.pop(),o.trys.pop();continue}r=e.call(t,o)}catch(t){r=[6,t],n=0}finally{s=i=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,a])}}},r=this&&this.__read||function(t,e){var s="function"==typeof Symbol&&t[Symbol.iterator];if(!s)return t;var n,i,r=s.call(t),o=[];try{for(;(void 0===e||e-- >0)&&!(n=r.next()).done;)o.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(s=r.return)&&s.call(r)}finally{if(i)throw i.error}}return o},o=this&&this.__spread||function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(r(arguments[e]));return t},a=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var s in t)Object.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e.default=t,e},l=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var h=a(s(9378)),c=a(s(5686)),u=a(s(760)),m=a(s(2320)),d=a(s(4517)),g=l(s(9251)),f=1e-5,p=.001,y=function(){function t(t){void 0===t&&(t={});var e=this;this.learningRate=1,this.localConnectivity=1,this.minDist=.1,this.nComponents=2,this.nEpochs=0,this.nNeighbors=15,this.negativeSampleRate=5,this.random=Math.random,this.repulsionStrength=1,this.setOpMixRatio=1,this.spread=1,this.transformQueueSize=4,this.targetMetric="categorical",this.targetWeight=.5,this.targetNNeighbors=this.nNeighbors,this.distanceFn=w,this.isInitialized=!1,this.rpForest=[],this.embedding=[],this.optimizationState=new b;var s=function(s){void 0!==t[s]&&(e[s]=t[s])};s("distanceFn"),s("learningRate"),s("localConnectivity"),s("minDist"),s("nComponents"),s("nEpochs"),s("nNeighbors"),s("negativeSampleRate"),s("random"),s("repulsionStrength"),s("setOpMixRatio"),s("spread"),s("transformQueueSize")}return t.prototype.fit=function(t){return this.initializeFit(t),this.optimizeLayout(),this.embedding},t.prototype.fitAsync=function(t,e){return void 0===e&&(e=function(){return!0}),n(this,void 0,void 0,(function(){return i(this,(function(s){switch(s.label){case 0:return this.initializeFit(t),[4,this.optimizeLayoutAsync(e)];case 1:return s.sent(),[2,this.embedding]}}))}))},t.prototype.setSupervisedProjection=function(t,e){void 0===e&&(e={}),this.Y=t,this.targetMetric=e.targetMetric||this.targetMetric,this.targetWeight=e.targetWeight||this.targetWeight,this.targetNNeighbors=e.targetNNeighbors||this.targetNNeighbors},t.prototype.setPrecomputedKNN=function(t,e){this.knnIndices=t,this.knnDistances=e},t.prototype.initializeFit=function(t){if(t.length<=this.nNeighbors)throw new Error("Not enough data points ("+t.length+") to create nNeighbors: "+this.nNeighbors+". Add more data points or adjust the configuration.");if(this.X===t&&this.isInitialized)return this.getNEpochs();if(this.X=t,!this.knnIndices&&!this.knnDistances){var e=this.nearestNeighbors(t);this.knnIndices=e.knnIndices,this.knnDistances=e.knnDistances}this.graph=this.fuzzySimplicialSet(t,this.nNeighbors,this.setOpMixRatio),this.makeSearchFns(),this.searchGraph=this.makeSearchGraph(t),this.processGraphForSupervisedProjection();var s=this.initializeSimplicialSetEmbedding(),n=s.head,i=s.tail,r=s.epochsPerSample;return this.optimizationState.head=n,this.optimizationState.tail=i,this.optimizationState.epochsPerSample=r,this.initializeOptimization(),this.prepareForOptimizationLoop(),this.isInitialized=!0,this.getNEpochs()},t.prototype.makeSearchFns=function(){var t=u.makeInitializations(this.distanceFn),e=t.initFromTree,s=t.initFromRandom;this.initFromTree=e,this.initFromRandom=s,this.search=u.makeInitializedNNSearch(this.distanceFn)},t.prototype.makeSearchGraph=function(t){for(var e=this.knnIndices,s=this.knnDistances,n=[t.length,t.length],i=new c.SparseMatrix([],[],[],n),r=0;r<e.length;r++)for(var o=e[r],a=s[r],l=0;l<o.length;l++){var h=o[l],u=a[l];u>0&&i.set(r,h,u)}var m=c.transpose(i);return c.maximum(i,m)},t.prototype.transform=function(t){var e=this,s=this.X;if(void 0===s||0===s.length)throw new Error("No data has been fit.");var n=Math.floor(this.nNeighbors*this.transformQueueSize);n=Math.min(s.length,n);var i=u.initializeSearch(this.rpForest,s,t,n,this.initFromRandom,this.initFromTree,this.random),r=this.search(s,this.searchGraph,i,t),o=h.deheapSort(r),a=o.indices,l=o.weights;a=a.map((function(t){return t.slice(0,e.nNeighbors)})),l=l.map((function(t){return t.slice(0,e.nNeighbors)}));var m=Math.max(0,this.localConnectivity-1),g=this.smoothKNNDistance(l,this.nNeighbors,m),f=g.sigmas,p=g.rhos,y=this.computeMembershipStrengths(a,l,f,p),w=y.rows,b=y.cols,T=y.vals,C=[t.length,s.length],S=new c.SparseMatrix(w,b,T,C),A=c.normalize(S,"l1"),v=c.getCSR(A),M=t.length,N=E(d.reshape2d(v.indices,M,this.nNeighbors),d.reshape2d(v.values,M,this.nNeighbors),this.embedding),_=this.nEpochs?this.nEpochs/3:S.nRows<=1e4?100:30,P=S.getValues().reduce((function(t,e){return e>t?e:t}),0);S=S.map((function(t){return t<P/_?0:t})),S=c.eliminateZeros(S);var L=this.makeEpochsPerSample(S.getValues(),_),R=S.getRows(),x=S.getCols();return this.assignOptimizationStateParameters({headEmbedding:N,tailEmbedding:this.embedding,head:R,tail:x,currentEpoch:0,nEpochs:_,nVertices:S.getDims()[1],epochsPerSample:L}),this.prepareForOptimizationLoop(),this.optimizeLayout()},t.prototype.processGraphForSupervisedProjection=function(){var t=this.Y,e=this.X;if(t){if(t.length!==e.length)throw new Error("Length of X and y must be equal");if("categorical"===this.targetMetric){var s=this.targetWeight<1?1/(1-this.targetWeight)*2.5:1e12;this.graph=this.categoricalSimplicialSetIntersection(this.graph,t,s)}}},t.prototype.step=function(){var t=this.optimizationState.currentEpoch;return t<this.getNEpochs()&&this.optimizeLayoutStep(t),this.optimizationState.currentEpoch},t.prototype.getEmbedding=function(){return this.embedding},t.prototype.nearestNeighbors=function(t){var e,s=this.distanceFn,n=this.nNeighbors,i=u.makeNNDescent(s,this.random),r=5+Math.floor(.5==(e=Math.pow(t.length,.5)/20)?0:Math.round(e)),o=Math.max(5,Math.floor(Math.round(function(t){return Math.log(t)/Math.log(2)}(t.length))));this.rpForest=m.makeForest(t,n,r,this.random);var a=i(t,m.makeLeafArray(this.rpForest),n,o);return{knnIndices:a.indices,knnDistances:a.weights}},t.prototype.fuzzySimplicialSet=function(t,e,s){void 0===s&&(s=1);var n=this,i=n.knnIndices,r=void 0===i?[]:i,o=n.knnDistances,a=void 0===o?[]:o,l=n.localConnectivity,h=this.smoothKNNDistance(a,e,l),u=h.sigmas,m=h.rhos,d=this.computeMembershipStrengths(r,a,u,m),g=d.rows,f=d.cols,p=d.vals,y=[t.length,t.length],w=new c.SparseMatrix(g,f,p,y),b=c.transpose(w),T=c.pairwiseMultiply(w,b),C=c.subtract(c.add(w,b),T),S=c.multiplyScalar(C,s),A=c.multiplyScalar(T,1-s);return c.add(S,A)},t.prototype.categoricalSimplicialSetIntersection=function(t,e,s,n){void 0===n&&(n=1);var i=A(t,e,n,s);return v(i=c.eliminateZeros(i))},t.prototype.smoothKNNDistance=function(t,e,s,n,i){void 0===s&&(s=1),void 0===n&&(n=64),void 0===i&&(i=1);for(var r=Math.log(e)/Math.log(2)*i,o=d.zeros(t.length),a=d.zeros(t.length),l=0;l<t.length;l++){var h=0,c=1/0,u=1,m=t[l],g=m.filter((function(t){return t>0}));if(g.length>=s){var y=Math.floor(s),w=s-y;y>0?(o[l]=g[y-1],w>f&&(o[l]+=w*(g[y]-g[y-1]))):o[l]=w*g[0]}else g.length>0&&(o[l]=d.max(g));for(var b=0;b<n;b++){for(var T=0,C=1;C<t[l].length;C++){var S=t[l][C]-o[l];T+=S>0?Math.exp(-S/u):1}if(Math.abs(T-r)<f)break;T>r?u=(h+(c=u))/2:(h=u,c===1/0?u*=2:u=(h+c)/2)}if(a[l]=u,o[l]>0){var A=d.mean(m);a[l]<p*A&&(a[l]=p*A)}else{var v=d.mean(t.map(d.mean));a[l]<p*v&&(a[l]=p*v)}}return{sigmas:a,rhos:o}},t.prototype.computeMembershipStrengths=function(t,e,s,n){for(var i=t.length,r=t[0].length,o=d.zeros(i*r),a=d.zeros(i*r),l=d.zeros(i*r),h=0;h<i;h++)for(var c=0;c<r;c++){var u=0;-1!==t[h][c]&&(u=t[h][c]===h?0:e[h][c]-n[h]<=0?1:Math.exp(-(e[h][c]-n[h])/s[h]),o[h*r+c]=h,a[h*r+c]=t[h][c],l[h*r+c]=u)}return{rows:o,cols:a,vals:l}},t.prototype.initializeSimplicialSetEmbedding=function(){for(var t=this,e=this.getNEpochs(),s=this.nComponents,n=this.graph.getValues(),i=0,r=0;r<n.length;r++){var o=n[r];i<n[r]&&(i=o)}var a=this.graph.map((function(t){return t<i/e?0:t}));this.embedding=d.zeros(a.nRows).map((function(){return d.zeros(s).map((function(){return 20*d.tauRand(t.random)-10}))}));var l=[],h=[],c=[],u=a.getAll();for(r=0;r<u.length;r++){var m=u[r];m.value&&(l.push(m.value),c.push(m.row),h.push(m.col))}return{head:h,tail:c,epochsPerSample:this.makeEpochsPerSample(l,e)}},t.prototype.makeEpochsPerSample=function(t,e){var s=d.filled(t.length,-1),n=d.max(t),i=t.map((function(t){return t/n*e}));return i.forEach((function(t,n){t>0&&(s[n]=e/i[n])})),s},t.prototype.assignOptimizationStateParameters=function(t){Object.assign(this.optimizationState,t)},t.prototype.prepareForOptimizationLoop=function(){var t=this,e=t.repulsionStrength,s=t.learningRate,n=t.negativeSampleRate,i=this.optimizationState,r=i.epochsPerSample,a=i.headEmbedding,l=i.tailEmbedding,h=a[0].length,c=a.length===l.length,u=r.map((function(t){return t/n})),m=o(u),d=o(r);this.assignOptimizationStateParameters({epochOfNextSample:d,epochOfNextNegativeSample:m,epochsPerNegativeSample:u,moveOther:c,initialAlpha:s,alpha:s,gamma:e,dim:h})},t.prototype.initializeOptimization=function(){var t=this.embedding,e=this.embedding,s=this.optimizationState,n=s.head,i=s.tail,r=s.epochsPerSample,o=this.getNEpochs(),a=this.graph.nCols,l=S(this.spread,this.minDist),h=l.a,c=l.b;this.assignOptimizationStateParameters({headEmbedding:t,tailEmbedding:e,head:n,tail:i,epochsPerSample:r,a:h,b:c,nEpochs:o,nVertices:a})},t.prototype.optimizeLayoutStep=function(t){for(var e=this.optimizationState,s=e.head,n=e.tail,i=e.headEmbedding,r=e.tailEmbedding,o=e.epochsPerSample,a=e.epochOfNextSample,l=e.epochOfNextNegativeSample,h=e.epochsPerNegativeSample,c=e.moveOther,u=e.initialAlpha,m=e.alpha,g=e.gamma,f=e.a,p=e.b,y=e.dim,w=e.nEpochs,b=e.nVertices,S=0;S<o.length;S++)if(!(a[S]>t)){var A=s[S],v=n[S],E=i[A],M=r[v],N=C(E,M),_=0;N>0&&(_=-2*f*p*Math.pow(N,p-1),_/=f*Math.pow(N,p)+1);for(var P=0;P<y;P++){var L=T(_*(E[P]-M[P]),4);E[P]+=L*m,c&&(M[P]+=-L*m)}a[S]+=o[S];for(var R=Math.floor((t-l[S])/h[S]),x=0;x<R;x++){var I=d.tauRandInt(b,this.random),O=r[I],F=C(E,O),D=0;if(F>0)D=2*g*p,D/=(.001+F)*(f*Math.pow(F,p)+1);else if(A===I)continue;for(P=0;P<y;P++)L=4,D>0&&(L=T(D*(E[P]-O[P]),4)),E[P]+=L*m}l[S]+=R*h[S]}return e.alpha=u*(1-t/w),e.currentEpoch+=1,i},t.prototype.optimizeLayoutAsync=function(t){var e=this;return void 0===t&&(t=function(){return!0}),new Promise((function(s,r){var o=function(){return n(e,void 0,void 0,(function(){var e,n,a,l,h,c;return i(this,(function(i){try{if(e=this.optimizationState,n=e.nEpochs,a=e.currentEpoch,this.embedding=this.optimizeLayoutStep(a),l=this.optimizationState.currentEpoch,h=!1===t(l),c=l===n,h||c)return[2,s(c)];setTimeout((function(){return o()}),0)}catch(t){r(t)}return[2]}))}))};setTimeout((function(){return o()}),0)}))},t.prototype.optimizeLayout=function(t){void 0===t&&(t=function(){return!0});for(var e=!1,s=[];!e;){var n=this.optimizationState,i=n.nEpochs,r=n.currentEpoch;s=this.optimizeLayoutStep(r);var o=this.optimizationState.currentEpoch,a=!1===t(o);e=o===i||a}return s},t.prototype.getNEpochs=function(){var t=this.graph;if(this.nEpochs>0)return this.nEpochs;var e=t.nRows;return e<=2500?500:e<=5e3?400:e<=7500?300:200},t}();function w(t,e){for(var s=0,n=0;n<t.length;n++)s+=Math.pow(t[n]-e[n],2);return Math.sqrt(s)}e.UMAP=y,e.euclidean=w,e.cosine=function(t,e){for(var s=0,n=0,i=0,r=0;r<t.length;r++)s+=t[r]*e[r],n+=Math.pow(t[r],2),i+=Math.pow(e[r],2);return 0===n&&0===i?0:0===n||0===i?1:1-s/Math.sqrt(n*i)};var b=function(){this.currentEpoch=0,this.headEmbedding=[],this.tailEmbedding=[],this.head=[],this.tail=[],this.epochsPerSample=[],this.epochOfNextSample=[],this.epochOfNextNegativeSample=[],this.epochsPerNegativeSample=[],this.moveOther=!0,this.initialAlpha=1,this.alpha=1,this.gamma=1,this.a=1.5769434603113077,this.b=.8950608779109733,this.dim=2,this.nEpochs=500,this.nVertices=0};function T(t,e){return t>e?e:t<-e?-e:t}function C(t,e){for(var s=0,n=0;n<t.length;n++)s+=Math.pow(t[n]-e[n],2);return s}function S(t,e){var s=d.linear(0,3*t,300).map((function(t){return t<e?1:t})),n=d.zeros(s.length).map((function(n,i){return s[i]>=e?Math.exp(-(s[i]-e)/t):n})),i={x:s,y:n},o=g.default(i,(function(t){var e=r(t,2),s=e[0],n=e[1];return function(t){return 1/(1+s*Math.pow(t,2*n))}}),{damping:1.5,initialValues:[.5,.5],gradientDifference:.1,maxIterations:100,errorTolerance:.01}).parameterValues,a=r(o,2);return{a:a[0],b:a[1]}}function A(t,e,s,n){return void 0===s&&(s=1),void 0===n&&(n=5),t.map((function(t,i,r){return-1===e[i]||-1===e[r]?t*Math.exp(-s):e[i]!==e[r]?t*Math.exp(-n):t}))}function v(t){t=c.normalize(t,"max");var e=c.transpose(t),s=c.pairwiseMultiply(e,t);return t=c.add(t,c.subtract(e,s)),c.eliminateZeros(t)}function E(t,e,s){for(var n=d.zeros(t.length).map((function(t){return d.zeros(s[0].length)})),i=0;i<t.length;i++)for(var r=0;r<t[0].length;r++)for(var o=0;o<s[0].length;o++){var a=t[i][r];n[i][o]+=e[i][r]*s[a][o]}return n}e.findABParams=S,e.fastIntersection=A,e.resetLocalConnectivity=v,e.initTransform=E},4517:function(t,e){"use strict";var s=this&&this.__values||function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],s=0;return e?e.call(t):{next:function(){return t&&s>=t.length&&(t=void 0),{value:t&&t[s++],done:!t}}}};function n(t,e){return Math.floor(e()*t)}function i(t){for(var e=[],s=0;s<t;s++)e.push(void 0);return e}function r(t,e){return i(t).map((function(){return e}))}function o(t){return r(t,0)}function a(t){return t.reduce((function(t,e){return t+e}))}Object.defineProperty(e,"__esModule",{value:!0}),e.tauRandInt=n,e.tauRand=function(t){return t()},e.norm=function(t){var e,n,i=0;try{for(var r=s(t),o=r.next();!o.done;o=r.next()){var a=o.value;i+=Math.pow(a,2)}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}return Math.sqrt(i)},e.empty=i,e.range=function(t){return i(t).map((function(t,e){return e}))},e.filled=r,e.zeros=o,e.ones=function(t){return r(t,1)},e.linear=function(t,e,s){return i(s).map((function(n,i){return t+i*((e-t)/(s-1))}))},e.sum=a,e.mean=function(t){return a(t)/t.length},e.max=function(t){for(var e=0,s=0;s<t.length;s++)e=t[s]>e?t[s]:e;return e},e.max2d=function(t){for(var e=0,s=0;s<t.length;s++)for(var n=0;n<t[s].length;n++)e=t[s][n]>e?t[s][n]:e;return e},e.rejectionSample=function(t,e,s){for(var i=o(t),r=0;r<t;r++)for(var a=!0;a;){for(var l=n(e,s),h=!1,c=0;c<r;c++)if(l===i[c]){h=!0;break}h||(a=!1),i[r]=l}return i},e.reshape2d=function(t,e,s){var n=[],i=0;if(t.length!==e*s)throw new Error("Array dimensions must match input length.");for(var r=0;r<e;r++){for(var o=[],a=0;a<s;a++)o.push(t[i]),i+=1;n.push(o)}return n}},3336:t=>{"use strict";t.exports=$},976:t=>{"use strict";t.exports=DG},4469:t=>{"use strict";t.exports=grok},701:t=>{"use strict";t.exports=rxjs},3870:t=>{"use strict";t.exports=ui},6414:t=>{"use strict";t.exports=wu}},e={};function s(n){var i=e[n];if(void 0!==i)return i.exports;var r=e[n]={id:n,exports:{}};return t[n].call(r.exports,r,r.exports,s),r.exports}s.m=t,s.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return s.d(e,{a:e}),e},s.d=(t,e)=>{for(var n in e)s.o(e,n)&&!s.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},s.u=t=>t+".js",s.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),s.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{var t;s.g.importScripts&&(t=s.g.location+"");var e=s.g.document;if(!t&&e&&(e.currentScript&&(t=e.currentScript.src),!t)){var n=e.getElementsByTagName("script");if(n.length)for(var i=n.length-1;i>-1&&!t;)t=n[i--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),s.p=t})(),s.b=document.baseURI||self.location.href,s.nc=void 0;var n={};(()=>{"use strict";s.r(n),s.d(n,{_package:()=>ut,test:()=>mt,tests:()=>e.QK});var t=s(976),e=s(1061);(0,e.W3)("_first",(()=>{(0,e.Bu)("_first",(async()=>{}))}));var i=s(2012),r=s(9976),o=s(6137);(0,e.W3)("Palettes",(()=>{(0,e.Bu)("testPaletteN",(async()=>{await async function(){const t=o.J.Chromatogram;(0,e.l_)(t instanceof r.B,!0),(0,e.l_)(t instanceof o.J,!0)}()})),(0,e.Bu)("testPaletteAA",(async()=>{await async function(){const t=i.f.Lesk,s=i.f.RasMol,n=i.f.GrokGroups;(0,e.l_)(t instanceof r.B,!0),(0,e.l_)(s instanceof r.B,!0),(0,e.l_)(n instanceof r.B,!0),(0,e.l_)(t instanceof i.f,!0),(0,e.l_)(s instanceof i.f,!0),(0,e.l_)(n instanceof i.f,!0)}()})),(0,e.Bu)("testPalettePtMe",(async()=>{const t=i.f.GrokGroups.get("MeNle"),s=i.f.GrokGroups.get("MeA"),n=i.f.GrokGroups.get("MeG"),r=i.f.GrokGroups.get("MeF"),o=i.f.GrokGroups.get("L"),a=i.f.GrokGroups.get("A"),l=i.f.GrokGroups.get("G"),h=i.f.GrokGroups.get("F");(0,e.l_)(t,o),(0,e.l_)(s,a),(0,e.l_)(n,l),(0,e.l_)(r,h)}))}));var a=s(4469),l=s(2397),h=s(8447),c=s(499);async function u(e){const s=t.Column.fromList(t.TYPE.STRING,"col1",e);if(await a.functions.call("Bio:detectMacromolecule",{col:s}),s.semType===t.SEMTYPE.MACROMOLECULE){const e=`Negative test detected semType='${s.semType}', units='${s.getTag(t.TAGS.UNITS)}'.`;throw new Error(e)}}async function m(e,s){const n=(await e()).getCol(s),i=await a.functions.call("Bio:detectMacromolecule",{col:n});if(i&&(n.semType=i),n.semType===t.SEMTYPE.MACROMOLECULE){const e=`Negative test detected semType='${n.semType}', units='${n.getTag(t.TAGS.UNITS)}'.`;throw new Error(e)}}async function d(s,n,i,r,o,l,h=null){const u=t.Column.fromList(t.TYPE.STRING,"seq",s),m=await a.functions.call("Bio:detectMacromolecule",{col:u});m&&(u.semType=m),(0,e.l_)(u.semType,t.SEMTYPE.MACROMOLECULE),(0,e.l_)(u.getTag(t.TAGS.UNITS),n),(0,e.l_)(u.getTag("aligned"),i),(0,e.l_)(u.getTag("alphabet"),r),h&&(0,e.l_)(u.getTag("separator"),h);const d=c.Cn.getOrCreate(u);(0,e.l_)(d.getAlphabetSize(),o),(0,e.l_)(d.getAlphabetIsMultichar(),l),d.isHelm()||((0,e.l_)(d.aligned,i),(0,e.l_)(d.alphabet,r))}async function g(s,n,i,r,o,l,h,u=null){const m=(await s()).col(n),d=await a.functions.call("Bio:detectMacromolecule",{col:m});d&&(m.semType=d),(0,e.l_)(m.semType,t.SEMTYPE.MACROMOLECULE),(0,e.l_)(m.getTag(t.TAGS.UNITS),i),(0,e.l_)(m.getTag("aligned"),r),(0,e.l_)(m.getTag("alphabet"),o),u&&(0,e.l_)(m.getTag("separator"),u);const g=c.Cn.getOrCreate(m);(0,e.l_)(g.getAlphabetSize(),l),(0,e.l_)(g.getAlphabetIsMultichar(),h),g.isHelm()||((0,e.l_)(g.aligned,r),(0,e.l_)(g.alphabet,o))}(0,e.W3)("detectors",(()=>{var s,n,i,r,o,l,c,y,w,b,T,C,S,A,v,E,M,N,_;const P=new(_=class{constructor(){this[s]="id,col1\n1,\n2,\n3,\n4,\n5,",this[n]="col1\n1\n2\n3",this[i]="col1\n4\n5\n6\n7",this[r]="col1\n8\n9\n10\n11\n12",this[o]="col1\nCCCCN1C(=O)CN=C(c2cc(F)ccc12)C3CCCCC3\nC1CCCCC1\nCCCCCC",this[l]="seq\nACGTC\nCAGTGT\nTTCAAC",this[c]="seq\nACGUC\nCAGUGU\nUUCAAC",this[y]="seq\nFWPHEY\nYNRQWYV\nMKPSEYV",this[w]="seq\n[meI][hHis][Aca]NT[dE][Thr_PO3H2][Aca]D\n[meI][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2]\n[Lys_Boc][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2]",this[b]="seq\nA*C*G*T*C\nC*A*G*T*G*T\nT*T*C*A*A*C",this[T]="seq\nA*C*G*U*C\nC*A*G*U*G*U\nU*U*C*A*A*C",this[C]="seq\nF-W-P-H-E-Y\nY-N-R-Q-W-Y-V\nM-K-P-S-E-Y-V",this[S]="seq\nabc-dfgg-abc1-cfr3-rty-wert\nrut12-her2-rty-wert-abc-abc1-dfgg\nrut12-rty-her2-abc-cfr3-wert-rut12",this[A]="seq\nabc/dfgg/abc1/cfr3/rty/wert\nrut12/her2/rty/wert//abc/abc1/dfgg\nrut12/rty/her2/abc/cfr3//wert/rut12",this[v]="seq\nA-C--G-T--C-T\nC-A-C--T--G-T\nA-C-C-G-T-A-C-T",this[E]="seq\nm1-M-m3-mon4-mon5-N-T-MON8-N9\nm1-mon2-m3-mon4-mon5-Num--MON8-N9\n\nmon1-M-mon3-mon4-mon5---MON8-N9",this[M]="seq\nAC-GT-CT\nCAC-T-GT\nACCGTACT",this[N]="seq\nFWR-WYV-KHP\nYNR-WYV-KHP\nMWRSWY-CKHP"}},s="negEmpty",n="neg1",i="neg2",r="neg3",o="negSmiles",l="csvFastaDna1",c="fastaRna1",y="fastaPt1",w="fastaUn",b="sepDna",T="sepRna",C="sepPt",S="sepUn1",A="sepUn2",v="sepMsaDna1",E="sepMsaUnWEmpty",M="fastaMsaDna1",N="fastaMsaPt1",_),L={fastaFasta:"System:AppData/Bio/data/sample_FASTA.fasta",fastaPtCsv:"System:AppData/Bio/data/sample_FASTA_PT.csv",msaComplex:"System:AppData/Bio/samples/MSA.csv",fastaCsv:"System:AppData/Bio/samples/FASTA.csv",helmCsv:"System:AppData/Bio/samples/HELM.csv",peptidesComplex:"System:AppData/Bio/tests/peptides_complex_msa.csv",peptidesSimple:"System:AppData/Bio/tests/peptides_simple_msa.csv",testDemogCsv:"System:AppData/Bio/tests/testDemog.csv",testHelmCsv:"System:AppData/Bio/tests/testHelm.csv",testIdCsv:"System:AppData/Bio/tests/testId.csv",testSmilesCsv:"System:AppData/Bio/tests/testSmiles.csv",testSmiles2Csv:"System:AppData/Bio/tests/testSmiles2.csv",testSmilesShort:"System:AppData/Bio/tests/testSmilesShort.csv",testActivityCliffsCsv:"System:AppData/Bio/tests/testActivityCliffs.csv",testCerealCsv:"System:AppData/Bio/tests/testCereal.csv",testUnichemSources:"System:AppData/Bio/tests/testUnichemSources.csv",testDmvOffices:"System:AppData/Bio/tests/testDmvOffices.csv",testAlertCollection:"System:AppData/Bio/tests/testAlertCollection.csv",testSpgi100:"System:AppData/Bio/tests/testSpgi100.csv",testSpgi:"System:AppData/Bio/tests/SPGI-derived.csv",testUrl:"System:AppData/Bio/tests/testUrl.csv"},R={};function x(t,e=I){return async()=>(t in R||(R[t]=(async()=>await e(L[t]))()),R[t])}async function I(e){const s=await a.dapi.files.readAsText(e);return t.DataFrame.fromCsv(s)}const O=e=>async()=>{const s=P[e],n=t.DataFrame.fromCsv(s);return await a.data.detectSemanticTypes(n),n};(0,e.Bu)("NegativeEmpty",(async()=>{await m(O("negEmpty"),"col1")})),(0,e.Bu)("Negative1",(async()=>{await m(O("neg1"),"col1")})),(0,e.Bu)("Negative2",(async()=>{await m(O("neg2"),"col1")})),(0,e.Bu)("Negative3",(async()=>{await m(O("neg3"),"col1")})),(0,e.Bu)("NegativeSmiles",(async()=>{await m(O("negSmiles"),"col1")})),(0,e.Bu)("NegativeStartEnd",(async()=>{await u(["START","END"])})),(0,e.Bu)("NegativeStartEndIntermediate",(async()=>{await u(["START","END","INTERMEDIATE"])})),(0,e.Bu)("FastaDna1",(async()=>{await g(O("csvFastaDna1"),"seq",h.r2.FASTA,"SEQ","DNA",4,!1)})),(0,e.Bu)("FastaRna1",(async()=>{await g(O("fastaRna1"),"seq",h.r2.FASTA,"SEQ","RNA",4,!1)})),(0,e.Bu)("FastaPt1",(async()=>{await g(O("fastaPt1"),"seq",h.r2.FASTA,"SEQ","PT",20,!1)})),(0,e.Bu)("FastaPtGaps",(()=>d(["FW-PH-EYY","FYNRQWYV-","FKP-Q-SEYV"],h.r2.FASTA,"SEQ","PT",20,!1))),(0,e.Bu)("FastaPtGapsMsa",(()=>d(["FW-PH-EYY","FYNRQWYV-","FKP-Q-SEY"],h.r2.FASTA,"SEQ.MSA","PT",20,!1))),(0,e.Bu)("FastaUn",(async()=>{await g(O("fastaUn"),"seq",h.r2.FASTA,"SEQ.MSA","UN",12,!0)})),(0,e.Bu)("SepMsaUnWEmpty",(async()=>{await g(O("sepMsaUnWEmpty"),"seq",h.r2.SEPARATOR,"SEQ.MSA","UN",14,!0)})),(0,e.Bu)("FastaMsaDna1",(async()=>{await g(O("fastaMsaDna1"),"seq",h.r2.FASTA,"SEQ.MSA","DNA",4,!1)})),(0,e.Bu)("FastaMsaPt1",(async()=>{await g(O("fastaMsaPt1"),"seq",h.r2.FASTA,"SEQ.MSA","PT",20,!1)})),(0,e.Bu)("SepDna",(async()=>{await g(O("sepDna"),"seq",h.r2.SEPARATOR,"SEQ","DNA",4,!1,"*")})),(0,e.Bu)("SepRna",(async()=>{await g(O("sepRna"),"seq",h.r2.SEPARATOR,"SEQ","RNA",4,!1,"*")})),(0,e.Bu)("SepPt",(async()=>{await g(O("sepPt"),"seq",h.r2.SEPARATOR,"SEQ","PT",20,!1,"-")})),(0,e.Bu)("SepUn1",(async()=>{await g(O("sepUn1"),"seq",h.r2.SEPARATOR,"SEQ","UN",8,!0,"-")})),(0,e.Bu)("SepUn2",(async()=>{await g(O("sepUn2"),"seq",h.r2.SEPARATOR,"SEQ","UN",9,!0,"/")})),(0,e.Bu)("SepMsaN1",(async()=>{await g(O("sepMsaDna1"),"seq",h.r2.SEPARATOR,"SEQ.MSA","DNA",4,!1,"-")})),(0,e.Bu)("samplesFastaCsv",(async()=>{await p(x("fastaCsv"),{Sequence:new f(h.r2.FASTA,"SEQ","PT",20,!1)})})),(0,e.Bu)("samplesFastaFasta",(async()=>{await p(x("fastaFasta"),{sequence:new f(h.r2.FASTA,"SEQ","PT",20,!1)})})),(0,e.Bu)("samplesPeptidesComplex",(async()=>{await p(x("peptidesComplex"),{})})),(0,e.Bu)("samplesMsaComplex",(async()=>{await p(x("msaComplex"),{MSA:new f(h.r2.SEPARATOR,"SEQ.MSA","UN",161,!0,"/")})})),(0,e.Bu)("samplesIdCsv",(async()=>{await p(x("testIdCsv"),{})})),(0,e.Bu)("samplesSarSmallCsv",(async()=>{await p(x("testSmilesCsv"),{})})),(0,e.Bu)("samplesHelmCsv",(async()=>{await p(x("helmCsv"),{HELM:new f(h.r2.HELM,null,null,160,!0)})})),(0,e.Bu)("samplesTestHelmCsv",(async()=>{await p(x("testHelmCsv"),{"HELM string":new f(h.r2.HELM,null,null,9,!0)})})),(0,e.Bu)("samplesTestDemogCsv",(async()=>{await p(x("testDemogCsv"),{})})),(0,e.Bu)("samplesTestSmiles2Csv",(async()=>{await p(x("testSmiles2Csv"),{})})),(0,e.Bu)("samplesTestSmilesShort",(async()=>{await p(x("testSmilesShort"),{})})),(0,e.Bu)("samplesTestActivityCliffsNegativeSmiles",(async()=>{await p(x("testActivityCliffsCsv"),{})})),(0,e.Bu)("samplesFastaPtCsv",(async()=>{await p(x("fastaPtCsv"),{sequence:new f(h.r2.FASTA,"SEQ","PT",20,!1)})})),(0,e.Bu)("samplesTestCerealCsv",(async()=>{await p(x("testCerealCsv"),{})})),(0,e.Bu)("samplesTestUnichemSources",(async()=>{await p(x("testUnichemSources"),{})})),(0,e.Bu)("samplesTestDmvOffices",(async()=>{await p(x("testDmvOffices"),{})})),(0,e.Bu)("samplesTestAlertCollection",(async()=>{await p(x("testAlertCollection"),{})})),(0,e.Bu)("samplesTestSpgi",(async()=>{await p(x("testSpgi"),{})})),(0,e.Bu)("samplesTestSpgi100",(async()=>{await p(x("testSpgi100"),{})})),(0,e.Bu)("samplesTestUrl",(async()=>{await p(x("testUrl"),{})}))}));class f{constructor(t,e,s,n,i,r){this.units=t,this.aligned=e,this.alphabet=s,this.alphabetSize=n,this.alphabetIsMultichar=i,this.separator=r}}async function p(t,e){const s=await t(),n=[];for(const i of s.columns.names())if(i in e){const s=e[i];try{await g(t,i,s.units,s.aligned,s.alphabet,s.alphabetSize,s.alphabetIsMultichar,s.separator)}catch(t){const e=t.toString();n.push(`Positive col '${i}' failed: ${e}`)}}else try{await m(t,i)}catch(t){const e=t.toString();n.push(`Negative col '${i}' failed: ${e}`)}if(n.length>0)throw new Error(n.join("\n"))}(0,e.W3)("detectors:weak-and-likely",(()=>{const s={fastaDnaWeak1:"id,colName\n1,TTTTT\n2,TTTTT\n3,TTTTT\n4,TTTTT",fastaDnaWeak1LikelyName:"id,seq\n1,TTTTT\n2,TTTTT\n3,TTTTT\n4,TTTTT",fastaRnaWeak1:"id,colName\n1,UUUUU\n2,UUUUU\n3,UUUUU\n4,UUUUU",fastaRnaWeak1LikelyName:"id,seq\n1,UUUUU\n2,UUUUU\n3,UUUUU\n4,UUUUU",fastaPtWeak1:"id,colName\n1,SLSLSPGK\n2,SLSLSPGK\n3,SLSLSPGK\n4,SLSLSPGK",fastaPtWeak1LikelyName:"id,seq\n1,SLSLSPGK\n2,SLSLSPGK\n3,SLSLSPGK\n4,SLSLSPGK",fastaUn1:"id,colName\n1,word\n2,other\n3,some\n4,another",fastaUn1LikelyName:"id,seq\n1,word\n2,other\n3,some\n4,another",fastaUn2LikelyName:'protein\nBoombastic\nMegafantastic\n"just-a-random-thought,oy!"',fastaUnMsa1LikelyName:"id,seq\n1,word\n2,male\n3,bare\n4,core"},n=e=>async()=>{const n=s[e],i=t.DataFrame.fromCsv(n);return await a.data.detectSemanticTypes(i),i};(0,e.Bu)("fastaDnaWeak1",(async()=>{await m(n("fastaDnaWeak1"),"colName")})),(0,e.Bu)("fastaDnaWeak1LikelyName",(async()=>{await g(n("fastaDnaWeak1LikelyName"),"seq",h.r2.FASTA,"SEQ.MSA","DNA",4,!1)})),(0,e.Bu)("fastaRnaWeak1",(async()=>{await m(n("fastaRnaWeak1"),"colName")})),(0,e.Bu)("fastaRnaWeak1LikelyName",(async()=>{await g(n("fastaRnaWeak1LikelyName"),"seq",h.r2.FASTA,"SEQ.MSA","RNA",4,!1)})),(0,e.Bu)("fastaPtWeak1",(async()=>{await m(n("fastaPtWeak1"),"colName")})),(0,e.Bu)("fastaPtWeak1LikelyName",(async()=>{await g(n("fastaPtWeak1LikelyName"),"seq",h.r2.FASTA,"SEQ.MSA","PT",20,!1)})),(0,e.Bu)("fastaUn1",(async()=>{await m(n("fastaUn1"),"colName")})),(0,e.Bu)("fastaUn1LikelyName",(async()=>{await m(n("fastaUn1LikelyName"),"seq")})),(0,e.Bu)("fastaUn2LikelyName",(async()=>{await m(n("fastaUn2LikelyName"),"protein")})),(0,e.Bu)("fastaUnMsa1LikelyName",(async()=>{await m(n("fastaUnMsa1LikelyName"),"seq")}))})),(0,e.W3)("detectorsBenchmark",(()=>{let s;async function n(n,i,r,o,a,l){return await async function(n,u,m,d){const g=(()=>{const e=function(e,s,n,i,r){let o;switch(e){case h.r2.FASTA:o=t=>{let e="";for(let s=0;s<t.length;s++){const n=t[s];e+=1==n.length?n:`[${n}]`}return e};break;case h.r2.SEPARATOR:o=(t,e)=>t.join(e);break;default:throw new Error(`Not supported notation '${e}'.`)}const a=(t,e)=>{const s=new Array(e);for(let n=0;n<e;n++)s[n]=t[Math.floor(Math.random()*t.length)];return o(s,r)},l=Array(i);for(let t=0;t<i;t++)l[t]=a(s,n);return t.Column.fromStrings("seq",l)}(i,[...(0,h.gM)(r)],o,a,l);return s.prepare({col:e})})(),f=Date.now(),p=await(async t=>function(t){t.callSync();const e=t.getOutputParamValue(),s=t.inputs.col;return e&&(s.semType=e),s}(t))(g),y=Date.now();(function(t,s){const n=c.Cn.getOrCreate(t);(0,e.l_)(t.semType===s.semType,!0),(0,e.l_)(n.notation===s.notation,!0),(0,e.l_)(n.alphabet===s.alphabet,!0),(0,e.l_)(n.separator===s.separator,!0)})(p,{semType:t.SEMTYPE.MACROMOLECULE,notation:i,alphabet:r,separator:l});const w=y-f;if(w>10){const t=`ET ${w} ms is more than max allowed 10 ms.`;throw console.error(t),new Error(t)}return console.log(`ET ${w} ms is OK.`),w}()}(0,e.bb)((async()=>{const e=t.Func.find({package:"Bio",name:"detectMacromolecule"});s=e[0];const n=t.Column.fromStrings("seq",["ACGT","ACGT","ACGT"]);await s.prepare({col:n}).call()})),(0,e.Bu)("fastaDnaShorts50Few50",(async()=>{await n(0,h.r2.FASTA,"DNA",50,50)}),{skipReason:"#1192"}),(0,e.Bu)("fastaDnaShorts50Many1E6",(async()=>{await n(0,h.r2.FASTA,"DNA",50,1e6)}),{skipReason:"#1192"}),(0,e.Bu)("fastaDnaLong1e6Few50",(async()=>{await n(0,h.r2.FASTA,"DNA",1e6,50)}),{skipReason:"#1192"}),(0,e.Bu)("separatorDnaShorts50Few50",(async()=>{await n(0,h.r2.SEPARATOR,"DNA",50,50,"/")})),(0,e.Bu)("separatorDnaShorts50Many1E6",(async()=>{await n(0,h.r2.SEPARATOR,"DNA",50,1e6,"/")})),(0,e.Bu)("separatorDnaLong1e6Few50",(async()=>{await n(0,h.r2.SEPARATOR,"DNA",1e6,50,"/")}))}));var y=s(6098),w=s(525);async function b(e){const s=await async function(t){return await ut.files.readAsText(t)}(e),n=t.DataFrame.fromCsv(s);return n.name=e.replace(".csv",""),n}async function T(t){const e=await b(t);return e.name=t.replace(".csv",""),a.shell.addTableView(e)}async function C(t=1e4){const s=await a.dapi.docker.dockerContainers.filter("bio").first();"started"!==s.status&&"checking"!==s.status&&await(0,e.gw)(t)}async function S(s,n){const i=t.DataFrame.fromCsv(s),r=t.DataFrame.fromCsv(n),o=i.getCol("seq"),l=await a.functions.call("Bio:detectMacromolecule",{col:o});l&&(o.semType=l);const h=r.getCol("seq"),c=await(0,y.U)(o,!0);(0,e.f6)(c.toList(),h.toList())}async function A(s,n,i,r,o,l){const h=t.DataFrame.fromCsv(s),c=t.DataFrame.fromCsv(n),u=h.getCol("seq"),m=c.getCol("seq"),d=h.getCol("seq"),g=await a.functions.call("Bio:detectMacromolecule",{col:d});g&&(d.semType=g),await a.data.detectSemanticTypes(h),(0,e.l_)(u.semType,t.SEMTYPE.MACROMOLECULE),(0,e.l_)(u.getTag(t.TAGS.UNITS),i),o&&(0,e.l_)(u.getTag("alphabet"),o);const f=await(0,w.K)({col:u,pepsea:{method:l}});(0,e.l_)(f.semType,t.SEMTYPE.MACROMOLECULE),(0,e.l_)(f.getTag(t.TAGS.UNITS),r),(0,e.l_)(f.getTag("aligned"),"SEQ.MSA"),o&&(0,e.l_)(f.getTag("alphabet"),o),(0,e.f6)(f.toList(),m.toList())}(0,e.W3)("MSA",(async()=>{(0,e.Bu)("isCorrect",(async()=>{await S("seq\nFWRWYVKHP\nYNRWYVKHP\nMWRSWYCKHP","seq\nFWR-WYVKHP\nYNR-WYVKHP\nMWRSWYCKHP")})),(0,e.Bu)("isCorrectLong",(async()=>{await S("seq\nFWRWYVKHPFWRWYVKHPFWRWYVKHPFWRWYVKHPFWRWYVKHPFWRWYVKHPFWRWYVKHPFWRWYVKHP\nYNRWYVKHPYNRWYVKHPYNRWYVKHPYNRWYVKHPYNRWYVKHPYNRWYVKHPYNRWYVKHPYNRWYVKHP\nMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHP","seq\nFWR-WYVKHPFWR-WYVKHPFWR-WYVKHPFWR-WYVKHPFWR-WYVKHPFWR-WYVKHPFWR-WYVKHPFWR-WYVKHP\nYNR-WYVKHPYNR-WYVKHPYNR-WYVKHPYNR-WYVKHPYNR-WYVKHPYNR-WYVKHPYNR-WYVKHPYNR-WYVKHP\nMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHP")})),(0,e.Bu)("isCorrectHelm",(async()=>{await C(),await A("seq\n PEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2}$$$$\n PEPTIDE1{meI.Aca.N.T.dE.Thr_PO3H2}$$$$\n PEPTIDE1{hHis.Aca.N.T.dE.Thr_PO3H2}$$$$","seq\n meI.hHis.Aca.N.T.dE.Thr_PO3H2\n .meI.Aca.N.T.dE.Thr_PO3H2\n .hHis.Aca.N.T.dE.Thr_PO3H2",h.r2.HELM,h.r2.SEPARATOR,void 0,"mafft")}),{skipReason:"GROK-13221"}),(0,e.Bu)("isCorrectHelmLong",(async()=>{await C(),await A("seq\n PEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et.dV.E.N.D-Orn.D-aThr.Phe_4Me.Thr_PO3H2}$$$$\n PEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Tyr_PO3H2.D-Chg.dV.Phe_ab-dehydro.N.D-Orn.D-aThr.Phe_4Me}$$$$\n PEPTIDE1{Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Tyr_PO3H2.D-Chg.dV.Thr_PO3H2.N.D-Orn.D-aThr.Phe_4Me}$$$$","seq\n meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et.dV.E.N.D-Orn.D-aThr.Phe_4Me.Thr_PO3H2\n meI.hHis.Aca.Cys_SEt.T.dK..Tyr_PO3H2.D-Chg.dV.Phe_ab-dehydro.N.D-Orn.D-aThr.Phe_4Me.\n Lys_Boc.hHis.Aca.Cys_SEt.T.dK..Tyr_PO3H2.D-Chg.dV.Thr_PO3H2.N.D-Orn.D-aThr.Phe_4Me.",h.r2.HELM,h.r2.SEPARATOR,void 0,"mafft")}),{skipReason:"GROK-13221"}),(0,e.Bu)("isCorrectSeparator",(async()=>{await A("seq\n F-W-P-H-E-Y\n Y-N-R-Q-W-Y-V\n M-K-P-S-E-Y-V","seq\n FWPHEY-\n YNRQWYV\n MKPSEYV",h.r2.SEPARATOR,h.r2.FASTA,"PT")})),(0,e.Bu)("isCorrectSeparatorLong",(async()=>{await A("seq\n M-I-E-V-F-L-F-G-I-V-L-G-L-I-P-I-T-L-A-G-L-F-V-T-A-Y-L-Q-Y-R-R-G-D-Q-L-D-L\n M-M-E-L-V-L-K-T-I-I-G-P-I-V-V-G-V-V-L-R-I-V-D-K-W-L-N-K-D-K\n M-D-R-T-D-E-V-S-N-H-T-H-D-K-P-T-L-T-W-F-E-E-I-F-E-E-Y-H-S-P-F-H-N","seq\n MIEV-FLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL\n MMEL-VLKTII-GPIVVGVVLRIVDKWLNKDK------\n MDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN-----",h.r2.SEPARATOR,h.r2.FASTA,"PT")}))}));var v=s(3553),E=s(9416);async function M(t,s){const n=(0,h.kB)(t);console.debug(`Bio: tests: splitters: src=${JSON.stringify(t)}, res=${JSON.stringify(n)} .`),(0,e.f6)(n,s)}async function N(t,s){const n=(0,h.gP)(t);console.debug(`Bio: tests: splitters: src=${JSON.stringify(t)}, res=${JSON.stringify(n)} .`),(0,e.f6)(n,s)}(0,e.W3)("splitters",(async()=>{(0,e.bb)((async()=>{})),(0,e.X5)((async()=>{}));const s=["M[MeI]YKETLL[MeF]PKTDFPMRGGL[MeA]",["M","MeI","Y","K","E","T","L","L","MeF","P","K","T","D","F","P","M","R","G","G","L","MeA"]],n=["[meI][Pip][dK][Thr_PO3H2][L-hArg(Et,Et)][D-Tyr_Et][Tyr_ab-dehydroMe][dV]EN[D-Orn][D-aThr][Phe_4Me]",["meI","Pip","dK","Thr_PO3H2","L-hArg(Et,Et)","D-Tyr_Et","Tyr_ab-dehydroMe","dV","E","N","D-Orn","D-aThr","Phe_4Me"]],i=["PEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et.Tyr_ab-dehydroMe.dV.E.N.D-Orn.D-aThr.Phe_4Me}$$$",["meI","hHis","Aca","N","T","dE","Thr_PO3H2","Aca","D-Tyr_Et","Tyr_ab-dehydroMe","dV","E","N","D-Orn","D-aThr","Phe_4Me"]],r=["PEPTIDE1{meI.hHis.Aca.N.T.dK.Thr_PO3H2.Aca.D-Tyr_Et.D-Dap.dV.E.N.pnG.Phe_4Me}$$$",["meI","hHis","Aca","N","T","dK","Thr_PO3H2","Aca","D-Tyr_Et","D-Dap","dV","E","N","pnG","Phe_4Me"]],o=["PEPTIDE1{[meI].[hHis].[Aca].N.T.[dK].[Thr_PO3H2].[Aca].[D-Tyr_Et].[D-Dap].[dV].E.N.[pnG].[Phe_4Me]}$$$",["meI","hHis","Aca","N","T","dK","Thr_PO3H2","Aca","D-Tyr_Et","D-Dap","dV","E","N","pnG","Phe_4Me"]],h=["RNA1{R(U)P.R(T)P.R(G)P.R(C)P.R(A)}$$$$",["R(U)P","R(T)P","R(G)P","R(C)P","R(A)"]],c=["RNA1{P.R(U)P.R(T)}$$$$",["P","R(U)P","R(T)"]],u=["RNA1{P.R(U).P.R(T)}$$$$",["P","R(U)","P","R(T)"]];(0,e.Bu)("fastaMulti",(async()=>{await M(s[0],s[1])})),(0,e.Bu)("fastaFromHelm",(async()=>{await M(n[0],n[1])})),(0,e.Bu)("helm1",(async()=>{await N(i[0],i[1])})),(0,e.Bu)("helm2",(async()=>{await N(r[0],r[1])})),(0,e.Bu)("helm3-multichar",(async()=>{await N(o[0],o[1])})),(0,e.Bu)("testHelm1",(async()=>{await N(h[0],h[1])})),(0,e.Bu)("testHelm2",(async()=>{await N(c[0],c[1])})),(0,e.Bu)("testHelm3",(async()=>{await N(u[0],u[1])})),(0,e.Bu)("splitToMonomers",(async()=>{const t=await a.dapi.files.readCsv("System:AppData/Bio/samples/MSA.csv"),s=t.getCol("MSA"),n=await a.functions.call("Bio:detectMacromolecule",{col:s});n&&(s.semType=n),s.setTag("aligned",v.mU);const i=await(0,E.n)(t,s);(0,e.l_)(i.columns.names().includes("17"),!0),await a.data.detectSemanticTypes(i);const r=a.shell.addTableView(i);await(0,e.ow)((()=>r.grid.dataFrame!=t),"View grid has wrong data frame",100)})),(0,e.Bu)("getHelmMonomers",(async()=>{const e=t.DataFrame.fromCsv("HELM,Activity\nPEPTIDE1{hHis.N.T}$$$,5.30751\nPEPTIDE1{hHis.Aca.Cys_SEt}$$$,5.72388\n");await a.data.detectSemanticTypes(e);const s=["hHis","Aca","Cys_SEt","N","T"],n=e.getCol("HELM"),i=(0,l.getHelmMonomers)(n),r=s.filter((t=>!i.includes(t))),o=i.filter((t=>!s.includes(t)));if(r.length>0||o.length){const t=[];throw r.length>0&&t.push(`Missed monomers ${JSON.stringify(r)}.`),o.length>0&&t.push(`Unexpected monomers ${JSON.stringify(o)}.`),new Error(t.join(" "))}}))}));var _=s(7228),P=s(5490);(0,e.W3)("monomerLibraries",(()=>{let t,s=null;(0,e.bb)((async()=>{t=await(0,_.JN)(),s=await a.dapi.userDataStorage.get(P.RV,!0)})),(0,e.X5)((async()=>{await a.dapi.userDataStorage.put(P.RV,s,!0)})),(0,e.Bu)("default",(async()=>{await a.dapi.userDataStorage.put(P.RV,{},!0),await t.loadLibraries(!0);const s=t.getBioLib();(0,e.l_)(s.getPolymerTypes().length>0,!0)})),(0,e.Bu)("empty",(async()=>{const s=await(0,P.nW)(),n=await(0,P.P4)();s.exclude=n,await(0,P.QD)(s),await t.loadLibraries(!0);const i=t.getBioLib();(0,e.l_)(0===i.getPolymerTypes().length,!0),i.getMonomerMolsByPolymerType("PEPTIDE")}))}));var L=s(3336),R=s.n(L),x=s(4004);function I(){const e=[];return e.push(t.Column.fromList("string","MSA",new Array(10**6).fill("meI/hHis/Aca/N/T/dE/Thr_PO3H2/Aca/D-Tyr_Et/Tyr_ab-dehydroMe/dV/E/N/D-Orn/D-aThr//Phe_4Me"))),e.push(t.Column.fromList("string","Activity",new Array(10**6).fill("5.30751"))),e}function O(){const e=[],s="meI/hHis/Aca/N/T/dE/Thr_PO3H2/Aca/D-Tyr_Et/Tyr_ab-dehydroMe/dV/E/N/D-Orn/D-aThr".repeat(10**5);return e.push(t.Column.fromList("string","MSA",new Array(100).fill(s))),e.push(t.Column.fromList("string","Activity",new Array(100).fill("7.30751"))),e}async function F(s,n){const i=s(),r=t.DataFrame.fromColumns(i);await a.data.detectSemanticTypes(r);const o=Date.now(),l=(r.columns.byName("MSA"),a.shell.addTableView(r));await(0,e.ow)((()=>l.grid.dataFrame!==r),"View grid has wrong data frame ",100);const h=Date.now()-o;console.log(`Performance test: ${n}: ${h}ms`)}(0,e.W3)("renderers",(()=>{(0,e.Bu)("long sequence performance ",(async()=>{await F(O,"Long sequences")})),(0,e.Bu)("many sequence performance",(async()=>{await F(I,"Many sequences")})),(0,e.Bu)("many sequence performance",(async()=>{await F(I,"Many sequences")})),(0,e.Bu)("rendererMacromoleculeFasta",(async()=>{await async function(){const s=await a.dapi.files.readAsText("System:AppData/Bio/samples/FASTA.csv"),n=t.DataFrame.fromCsv(s),i=n.getCol("Sequence"),r=await a.functions.call("Bio:detectMacromolecule",{col:i});r&&(i.semType=r);const o=a.shell.addTableView(n);await a.data.detectSemanticTypes(n),await(0,e.ow)((()=>o.grid.dataFrame!=n),"View grid has wrong data frame",100);const l=i.getTag(t.TAGS.CELL_RENDERER);(0,e.l_)(l,"sequence")}()})),(0,e.Bu)("rendererMacromoleculeSeparator",(async()=>{await async function(){const s=await a.dapi.files.readAsText("System:AppData/Bio/data/sample_SEPARATOR_PT.csv"),n=t.DataFrame.fromCsv(s),i=n.getCol("sequence"),r=await a.functions.call("Bio:detectMacromolecule",{col:i});r&&(i.semType=r);const o=a.shell.addTableView(n);await a.data.detectSemanticTypes(n),await(0,e.ow)((()=>o.grid.dataFrame!=n),"View grid has wrong data frame",100);const l=i.getTag(t.TAGS.CELL_RENDERER);(0,e.l_)(l,"sequence")}()})),(0,e.Bu)("rendererMacromoleculeDifference",(async()=>{await async function(){const s=t.Column.fromStrings("SequencesDiff",["meI/hHis/Aca/N/T/dK/Thr_PO3H2/Aca#D-Tyr_Et/Tyr_ab-dehydroMe/meN/E/N/dV"]);s.setTag(t.TAGS.UNITS,h.r2.SEPARATOR),s.setTag("separator","/"),s.setTag("aligned","SEQ"),s.setTag("alphabet","UN"),s.setTag(".alphabetIsMultichar","true"),s.semType=v.Of.MACROMOLECULE_DIFFERENCE;const n=t.DataFrame.fromColumns([s]),i=a.shell.addTableView(n);await a.data.detectSemanticTypes(n),await(0,e.ow)((()=>i.grid.dataFrame!=n),"View grid has wrong data frame",100);const r=s.getTag(t.TAGS.CELL_RENDERER);(0,e.l_)(r,v.Of.MACROMOLECULE_DIFFERENCE)}()})),(0,e.Bu)("afterMsa",(async()=>{await async function(){const s=await a.dapi.files.readAsText("System:AppData/Bio/data/sample_FASTA.fasta"),n=(0,l.importFasta)(s)[0],i=n.getCol("sequence"),r=await a.functions.call("Bio:detectMacromolecule",{col:i});r&&(i.semType=r);const o=a.shell.addTableView(n);await a.data.detectSemanticTypes(n),console.log("Bio: tests/renderers/afterMsa, table view"),await(0,e.ow)((()=>o.grid.dataFrame!=n),"View grid has wrong data frame",100),console.log(`Bio: tests/renderers/afterMsa, src before test semType="${i.semType}", units="${i.getTag(t.TAGS.UNITS)}", cell.renderer="${i.getTag(t.TAGS.CELL_RENDERER)}"`),(0,e.l_)(i.semType,t.SEMTYPE.MACROMOLECULE),(0,e.l_)(i.getTag(t.TAGS.UNITS),h.r2.FASTA),(0,e.l_)(i.getTag("aligned"),"SEQ"),(0,e.l_)(i.getTag("alphabet"),"PT"),(0,e.l_)(i.getTag(t.TAGS.CELL_RENDERER),"sequence");const u=await(0,w.K)({col:i});o.grid.invalidate(),await(0,e.ow)((()=>o.grid.dataFrame!=n),"View grid has wrong data frame",100),(0,e.l_)(u.semType,t.SEMTYPE.MACROMOLECULE),(0,e.l_)(u.getTag(t.TAGS.UNITS),h.r2.FASTA),(0,e.l_)(u.getTag("aligned"),"SEQ.MSA"),(0,e.l_)(u.getTag("alphabet"),"PT"),(0,e.l_)(u.getTag(t.TAGS.CELL_RENDERER),"sequence"),c.Cn.getOrCreate(u)}()})),(0,e.Bu)("afterConvert",(async()=>{await async function(){const s=await a.dapi.files.readAsText("System:AppData/Bio/data/sample_FASTA_PT.csv"),n=t.DataFrame.fromCsv(s),i=n.col("sequence"),r=await a.functions.call("Bio:detectMacromolecule",{col:i});r&&(i.semType=r);const o=a.shell.addTableView(n);await a.data.detectSemanticTypes(n);const l=await(0,x.o)(i,h.r2.SEPARATOR,"/");await(0,e.ow)((()=>o.grid.dataFrame!=n),"View grid has wrong data frame",100);const u=l.getTag(t.TAGS.CELL_RENDERER);(0,e.l_)(u,"sequence"),c.Cn.getOrCreate(l)}()})),(0,e.Bu)("selectRendererBySemType",(async()=>{await async function(){const s=t.Column.fromStrings("SequencesDiff",["meI/hHis/Aca/N/T/dK/Thr_PO3H2/Aca#D-Tyr_Et/Tyr_ab-dehydroMe/meN/E/N/dV"]);s.setTag(t.TAGS.UNITS,h.r2.SEPARATOR),s.setTag("separator","/"),s.setTag("aligned","SEQ"),s.setTag("alphabet","UN"),s.setTag(".alphabetIsMultichar","true"),s.semType=v.Of.MACROMOLECULE_DIFFERENCE;const n=t.DataFrame.fromColumns([s]);a.shell.addTableView(n),await(0,e.gw)(100);const i=s.getTag(t.TAGS.CELL_RENDERER);if("MacromoleculeDifference"!==i)throw new Error(`Units 'separator', separator '/' and semType 'MacromoleculeDifference' have been manually set on column but after df was added as table, view renderer has set to '${i}' instead of correct 'MacromoleculeDifference'.`)}()})),(0,e.Bu)("setRendererManuallyBeforeAddColumn",(async()=>{await async function(){const s=t.Column.fromStrings("SequencesDiff",["meI/hHis/Aca/N/T/dK/Thr_PO3H2/Aca#D-Tyr_Et/Tyr_ab-dehydroMe/meN/E/N/dV"]);s.setTag(t.TAGS.UNITS,h.r2.SEPARATOR),s.setTag("separator","/"),s.setTag("aligned","SEQ"),s.setTag("alphabet","UN"),s.setTag(".alphabetIsMultichar","true"),s.semType=t.SEMTYPE.MACROMOLECULE;const n="MacromoleculeDifference";s.setTag(t.TAGS.CELL_RENDERER,n);const i=t.DataFrame.fromColumns([s]);await a.data.detectSemanticTypes(i),a.shell.addTableView(i),await(0,e.ow)((()=>null!==document.querySelector("canvas")),"cannot load table",3e3);const r=s.getTag(t.TAGS.CELL_RENDERER);if(r!==n)throw new Error(`Tag 'cell.renderer' has been manually set to '${n}' for column but after df was added as table, tag 'cell.renderer' has reset to '${r}' instead of manual '${n}'.`)}()}),{skipReason:"GROK-11212"}),(0,e.Bu)("setRendererManuallyAfterAddColumn",(async()=>{await async function(){const s=t.Column.fromStrings("SequencesDiff",["meI/hHis/Aca/N/T/dK/Thr_PO3H2/Aca#D-Tyr_Et/Tyr_ab-dehydroMe/meN/E/N/dV"]);s.setTag(t.TAGS.UNITS,h.r2.SEPARATOR),s.setTag("separator","/"),s.setTag("aligned","SEQ"),s.setTag("alphabet","UN"),s.setTag(".alphabetIsMultichar","true"),s.semType=t.SEMTYPE.MACROMOLECULE;const n="MacromoleculeDifference",i=t.DataFrame.fromColumns([s]);await a.data.detectSemanticTypes(i);const r=a.shell.addTableView(i);await(0,e.ow)((()=>R()(r.root).find(".d4-grid canvas").length>0),"View grid canvas not found",200),s.setTag(t.TAGS.CELL_RENDERER,n),await(0,e.ow)((()=>R()(r.root).find(".d4-grid canvas").length>0),"View grid canvas not found",200);const o=s.getTag(t.TAGS.CELL_RENDERER);if(o!==n)throw new Error(`Tag 'cell.renderer' has been manually set to '${n}' for column but after df was added as table, tag 'cell.renderer' has reset to '${o}' instead of manual '${n}'.`)}()}),{skipReason:"GROK-11212"})}));var D=s(6414),G=s.n(D),k=s(9611);(0,e.W3)("renderers: monomerPlacer",(()=>{const s={splitter:{csv:"id,seq\nid1,m1-M-m3-mon4-mon5-N-T-MON8-N9\nid2,m1-mon2-m3-mon4-mon5-Num-MON8-N9\nid3,mon1-M-mon3-mon4-mon5-MON8-N9\n",testList:[{src:{row:0,x:-1},tgt:{pos:null}},{src:{row:1,x:0},tgt:{pos:null}},{src:{row:1,x:5},tgt:{pos:0}},{src:{row:1,x:6},tgt:{pos:0}},{src:{row:1,x:26},tgt:{pos:1}},{src:{row:1,x:160},tgt:{pos:6}},{src:{row:1,x:185},tgt:{pos:7}},{src:{row:2,x:140},tgt:{pos:5}},{src:{row:2,x:145},tgt:{pos:5}}]},splitterMsa:{csv:"id,seq\nid1,m1-M-m3-mon4-mon5-N-T-MON8-N9\nid2,m1-mon2-m3-mon4-mon5-Num--MON8-N9\nid3,\nid4,mon1-M-mon3-mon4-mon5---MON8-N9\n",testList:[{src:{row:0,x:-1},tgt:{pos:null}},{src:{row:1,x:0},tgt:{pos:null}},{src:{row:1,x:1},tgt:{pos:null}},{src:{row:1,x:4},tgt:{pos:null}},{src:{row:1,x:5},tgt:{pos:0}},{src:{row:1,x:37},tgt:{pos:0}},{src:{row:1,x:38},tgt:{pos:1}},{src:{row:1,x:170},tgt:{pos:4}},{src:{row:1,x:200},tgt:{pos:5}},{src:{row:2,x:20},tgt:{pos:null}},{src:{row:3,x:170},tgt:{pos:4}},{src:{row:3,x:200},tgt:{pos:5}},{src:{row:3,x:282},tgt:{pos:null}}]},fastaMsa:{csv:"id,seq\nid1,QQYNIYPLT\nid2,QQWSSFPYT\nid3,\nid3,QHIRE--LT\n",testList:[{src:{row:1,x:-1},tgt:{pos:null}},{src:{row:1,x:0},tgt:{pos:null}},{src:{row:1,x:1},tgt:{pos:null}},{src:{row:1,x:19},tgt:{pos:0}},{src:{row:1,x:170},tgt:{pos:8}},{src:{row:1,x:171},tgt:{pos:8}},{src:{row:2,x:5},tgt:{pos:null}},{src:{row:3,x:170},tgt:{pos:8}},{src:{row:3,x:181},tgt:{pos:null}}]}};for(const[n,i]of Object.entries(s))(0,e.Bu)(`getPosition-${n}`,(async()=>{const e=t.DataFrame.fromCsv(i.csv);await a.data.detectSemanticTypes(e);const s=e.getCol("seq"),n=new k.A(null,s,(()=>({unitsHandler:c.Cn.getOrCreate(s),monomerCharWidth:7,separatorWidth:12,monomerToShort:h.GU,monomerLengthLimit:3}))),r=i.testList;for(let t=0;t<s.length;++t)n.getCellMonomerLengths(t);const o=[];for(const[t,e]of G().enumerate(r)){const e={pos:n.getPosition(t.src.row,t.src.x)};t.tgt.pos!=e.pos&&o.push(`Test src ${JSON.stringify(t.src)} expected tgt ${JSON.stringify(t.tgt)}, but get ${JSON.stringify({res:e})}`)}if(o.length>0)throw new Error("Test failed error(s):\n"+o.join(", n"))}))})),(0,e.W3)("converters",(()=>{let s;!function(t){t.fastaPt="fastaPt",t.separatorPt="separatorPt",t.helmPt="helmPt",t.fastaDna="fastaDna",t.separatorDna="separatorDna",t.helmDna="helmDna",t.fastaRna="fastaRna",t.separatorRna="separatorRna",t.helmRna="helmRna",t.fastaGaps="fastaGaps",t.separatorGaps="separatorGaps",t.helmGaps="helmGaps",t.fastaUn="fastaUn",t.separatorUn="separatorUn",t.helmUn="helmUn",t.helmLoneDeoxyribose="helmLoneDeoxyribose",t.helmLoneRibose="helmLoneRibose",t.helmLonePhosphorus="helmLonePhosphorus",t.fastaLoneDeoxyribose="fastaLoneDeoxyribose",t.fastaLoneRibose="fastaLoneRibose",t.fastaLonePhosphorus="fastaLonePhosphorus"}(s||(s={}));const n={fastaPt:"seq\nFWPHEY\nYNRQWYV\nMKPSEYV",separatorPt:"seq\nF-W-P-H-E-Y\nY-N-R-Q-W-Y-V\nM-K-P-S-E-Y-V",helmPt:"seq\nPEPTIDE1{F.W.P.H.E.Y}$$$$\nPEPTIDE1{Y.N.R.Q.W.Y.V}$$$$\nPEPTIDE1{M.K.P.S.E.Y.V}$$$$",fastaDna:"seq\nACGTC\nCAGTGT\nTTCAAC",separatorDna:"seq\nA/C/G/T/C\nC/A/G/T/G/T\nT/T/C/A/A/C",helmDna:"seq\nDNA1{D(A)P.D(C)P.D(G)P.D(T)P.D(C)P}$$$$\nDNA1{D(C)P.D(A)P.D(G)P.D(T)P.D(G)P.D(T)P}$$$$\nDNA1{D(T)P.D(T)P.D(C)P.D(A)P.D(A)P.D(C)P}$$$$",fastaRna:"seq\nACGUC\nCAGUGU\nUUCAAC",separatorRna:"seq\nA*C*G*U*C\nC*A*G*U*G*U\nU*U*C*A*A*C",helmRna:"seq\nRNA1{R(A)P.R(C)P.R(G)P.R(U)P.R(C)P}$$$$\nRNA1{R(C)P.R(A)P.R(G)P.R(U)P.R(G)P.R(U)P}$$$$\nRNA1{R(U)P.R(U)P.R(C)P.R(A)P.R(A)P.R(C)P}$$$$",fastaGaps:"seq\nFW-PH-EYY\nFYNRQWYV-\nFKP-Q-SEYV",separatorGaps:"seq\nF/W//P/H//E/Y/Y\nF/Y/N/R/Q/W/Y/V/\nF/K/P//Q//S/E/Y/V",helmGaps:"seq\nPEPTIDE1{F.W.*.P.H.*.E.Y.Y}$$$$\nPEPTIDE1{F.Y.N.R.Q.W.Y.V.*}$$$$\nPEPTIDE1{F.K.P.*.Q.*.S.E.Y.V}$$$$",fastaUn:"seq\n[meI][hHis][Aca]NT[dE][Thr_PO3H2][Aca]D\n[meI][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2]\n[Lys_Boc][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2]",separatorUn:"seq\nmeI-hHis-Aca-N-T-dE-Thr_PO3H2-Aca-D\nmeI-hHis-Aca-Cys_SEt-T-dK-Thr_PO3H2-Aca-Tyr_PO3H2\nLys_Boc-hHis-Aca-Cys_SEt-T-dK-Thr_PO3H2-Aca-Tyr_PO3H2",helmUn:"seq\nPEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D}$$$$\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2}$$$$\nPEPTIDE1{Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2}$$$$",helmLoneDeoxyribose:"seq\nDNA1{D(A).D(C).D(G).D(T).D(C)}$$$$\nDNA1{D(C).D(A).D(G).D(T).D(G).D(T)P}$$$$\nDNA1{D(T).D(T).D(C).D(A).D(A).D(C)P}$$$$",helmLoneRibose:"seq\nRNA1{R(A).R(C).R(G).R(U).R(C)}$$$$\nRNA1{R(C).R(A).R(G).R(U).R(G).R(U)P}$$$$\nRNA1{R(U).R(U).R(C).R(A).R(A).R(C)P}$$$$",helmLonePhosphorus:"seq\nRNA1{P.P.R(A)P.R(C)P.R(G)P.R(U)P.R(C)P}$$$$\nRNA1{P.P.R(C)P.R(A)P.P.R(G)P.R(U)P.R(G)P.R(U)P}$$$$\nRNA1{P.R(U)P.R(U)P.R(C)P.R(A)P.R(A)P.R(C)P.P.P}$$$$"};async function i(e){const s=n[e],i=t.DataFrame.fromCsv(s);return await a.data.detectSemanticTypes(i),i}function r(s,n){if(s===h.r2.SEPARATOR&&!n)throw new Error(`Argument 'separator' is mandatory for target notation '${s.toString()}'.`);return function(i){const r=c.Cn.getOrCreate(i).convert(s,n);return(0,e.l_)(r.getTag(t.TAGS.UNITS),s),r}}async function o(t,s,n){const r=s((await i(t)).getCol("seq")),o=(await i(n)).getCol("seq");(0,e.f6)(r.toList(),o.toList()),c.Cn.getOrCreate(r)}(0,e.Bu)("testFastaPtToSeparator",(async()=>{await o(s.fastaPt,r(h.r2.SEPARATOR,"-"),s.separatorPt)})),(0,e.Bu)("testFastaDnaToSeparator",(async()=>{await o(s.fastaDna,r(h.r2.SEPARATOR,"/"),s.separatorDna)})),(0,e.Bu)("testFastaRnaToSeparator",(async()=>{await o(s.fastaRna,r(h.r2.SEPARATOR,"*"),s.separatorRna)})),(0,e.Bu)("testFastaGapsToSeparator",(async()=>{await o(s.fastaGaps,r(h.r2.SEPARATOR,"/"),s.separatorGaps)})),(0,e.Bu)("testFastaUnToSeparator",(async()=>{await o(s.fastaUn,r(h.r2.SEPARATOR,"-"),s.separatorUn)})),(0,e.Bu)("testFastaPtToHelm",(async()=>{await o(s.fastaPt,r(h.r2.HELM),s.helmPt)})),(0,e.Bu)("testFastaDnaToHelm",(async()=>{await o(s.fastaDna,r(h.r2.HELM),s.helmDna)})),(0,e.Bu)("testFastaRnaToHelm",(async()=>{await o(s.fastaRna,r(h.r2.HELM),s.helmRna)})),(0,e.Bu)("testFastaGapsToHelm",(async()=>{await o(s.fastaGaps,r(h.r2.HELM),s.helmGaps)})),(0,e.Bu)("testSeparatorPtToFasta",(async()=>{await o(s.separatorPt,r(h.r2.FASTA),s.fastaPt)})),(0,e.Bu)("testSeparatorDnaToFasta",(async()=>{await o(s.separatorDna,r(h.r2.FASTA),s.fastaDna)})),(0,e.Bu)("testSeparatorRnaToFasta",(async()=>{await o(s.separatorRna,r(h.r2.FASTA),s.fastaRna)})),(0,e.Bu)("testSeparatorGapsToFasta",(async()=>{await o(s.separatorGaps,r(h.r2.FASTA),s.fastaGaps)})),(0,e.Bu)("testSeparatorUnToFasta",(async()=>{await o(s.separatorUn,r(h.r2.FASTA),s.fastaUn)})),(0,e.Bu)("testSeparatorPtToHelm",(async()=>{await o(s.separatorPt,r(h.r2.HELM),s.helmPt)})),(0,e.Bu)("testSeparatorDnaToHelm",(async()=>{await o(s.separatorDna,r(h.r2.HELM),s.helmDna)})),(0,e.Bu)("testSeparatorRnaToHelm",(async()=>{await o(s.separatorRna,r(h.r2.HELM),s.helmRna)})),(0,e.Bu)("testSeparatorGapsToHelm",(async()=>{await o(s.separatorGaps,r(h.r2.HELM),s.helmGaps)})),(0,e.Bu)("testHelmDnaToFasta",(async()=>{await o(s.helmDna,r(h.r2.FASTA),s.fastaDna)})),(0,e.Bu)("testHelmRnaToFasta",(async()=>{await o(s.helmRna,r(h.r2.FASTA),s.fastaRna)})),(0,e.Bu)("testHelmPtToFasta",(async()=>{await o(s.helmPt,r(h.r2.FASTA),s.fastaPt)})),(0,e.Bu)("testHelmUnToFasta",(async()=>{await o(s.helmUn,r(h.r2.FASTA),s.fastaUn)})),(0,e.Bu)("testHelmDnaToSeparator",(async()=>{await o(s.helmDna,r(h.r2.SEPARATOR,"/"),s.separatorDna)})),(0,e.Bu)("testHelmRnaToSeparator",(async()=>{await o(s.helmRna,r(h.r2.SEPARATOR,"*"),s.separatorRna)})),(0,e.Bu)("testHelmPtToSeparator",(async()=>{await o(s.helmPt,r(h.r2.SEPARATOR,"-"),s.separatorPt)})),(0,e.Bu)("testHelmUnToSeparator",(async()=>{await o(s.helmUn,r(h.r2.SEPARATOR,"-"),s.separatorUn)})),(0,e.Bu)("testHelmLoneRibose",(async()=>{await o(s.helmLoneRibose,r(h.r2.FASTA),s.fastaRna)})),(0,e.Bu)("testHelmLoneDeoxyribose",(async()=>{await o(s.helmLoneDeoxyribose,r(h.r2.SEPARATOR,"/"),s.separatorDna)})),(0,e.Bu)("testHelmLonePhosphorus",(async()=>{await o(s.helmLonePhosphorus,r(h.r2.FASTA),s.fastaRna)}))}));var H=s(5226);(0,e.W3)("fastaFileHandler",(()=>{const s=["description:1","description:2","description:3","description:4"],n=(t.Column.fromStrings("description",s),["MDYKETLLMPKTDFPMRGGLPNKEPQIQEKW","MIEVFLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL","MMELVLKTIIGPIVVGVVLRIVDKWLNKDK","MDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN"]);function i(t){const i=new H.i(t),r=i.descriptionsArray,o=i.sequencesArray;(0,e.f6)([r,o],[s,n])}(0,e.Bu)("testNormalFormatting",(async()=>{i(">description:1\nMDYKETLLMPKTDFPMRGGLPNKEPQIQEKW\n\n>description:2\nMIEVFLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL\n\n>description:3\nMMELVLKTIIGPIVVGVVLRIVDKWLNKDK\n\n>description:4\nMDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN\n")})),(0,e.Bu)("testExtraSpaces",(async()=>{i(">description:1\n MDYKETLLMPKTDFPMRGGLPNKEPQIQEKW\n\n>description:2\nMI EVF LFGIVLGLI PITLAGLFVTAY LQYRRGDQLDL\n\n>description:3\nM MELVLKTI IGPI VVGVVLR IVDKWLNKDK\n\n>description:4\nMDR TDEVSNHTHDKP TLTWFEEIFEEYHSPFHN\n ")})),(0,e.Bu)("testExtraNewlines",(async()=>{i(">description:1\n\nMDYKETLLMPKTDFPMRGGLPNKEPQIQEKW\n\n>description:2\nMIEVF\nLFGIVLGLI\nPITLAGLFVTA\nYLQYRRGDQLDL\n\n>description:3\nM\nME\n\nLVLKTIIG\n\nPIVVGVVLRI\nVDKWLNKDK\n\n\n>description:4\n\nMDRT\n\nDEVSNHTHDKP\n\nTLTWFEEIFEE\n\n\n\nYHSPFHN\n")}))}));var W=s(9943);(0,e.W3)("fastaExport",(()=>{let s;!function(t){t.single="single",t.multi="multi"}(s||(s={}));const n={[s.single]:{src:"MDYKETLLMPKTDFPMRGGLP",tgt:["MDYKETLLMP","KTDFPMRGGL","P"]},[s.multi]:{src:"M[MeI]YKETLL[MeF]PKTDFPMRGGL[MeA]",tgt:["M[MeI]YKETLL[MeF]P","KTDFPMRGGL","[MeA]"]}};let i;!function(t){t.test1="test1",t.test2="test2"}(i||(i={}));const r={[i.test1]:{srcCsv:"id,seq\n1,MDYKETLLMP\n2,KTDFPMRGGL\n3,P",idCols:["id"],seqCol:"seq",lineWidth:10,tgtFasta:">1\nMDYKETLLMP\n>2\nKTDFPMRGGL\n>3\nP\n"},[i.test2]:{srcCsv:"id,id2,seq\n1,seqA,M[MeI]YKETLL[MeF]P\n2,seqB,KTDFPMRGGL\n3,seqC,[MeA]\n",idCols:["id2","id"],seqCol:"seq",lineWidth:5,tgtFasta:">seqA|1\nM[MeI]YKE\nTLL[MeF]P\n>seqB|2\nKTDFP\nMRGGL\n>seqC|3\n[MeA]\n"}};function o(t,s=10){const i=h.kB,r=n[t].src,o=(0,W.sK)(r,i,s),a=n[t].tgt;(0,e.f6)(o,a)}async function a(s){const n=t.DataFrame.fromCsv(s.srcCsv),i=n.getCol(s.seqCol),r=s.idCols.map((t=>n.getCol(t))),o=(0,W.i$)(r,i,s.lineWidth);(0,e.l_)(o,s.tgtFasta)}(0,e.Bu)("wrapSequenceSingle",(async()=>{o(s.single,10)})),(0,e.Bu)("wrapSequenceMulti",(async()=>{o(s.multi,10)})),(0,e.Bu)("saveAsFastaTest1",(async()=>{a(r[i.test1])})),(0,e.Bu)("saveAsFastaTest2",(async()=>{a(r[i.test2])}))}));var B=s(7331),V=s(585);(0,e.W3)("bio",(()=>{const s="seq\nACGTCT\nCAGTGT\nTTCAAC";(0,e.Bu)("testGetStatsHelm1",(async()=>{const s=t.DataFrame.fromCsv("seq\nPEPTIDE1{meI}$$$$").getCol("seq"),n=(0,V.jY)(s,1,h.gP);(0,e.Wh)(n.freq,{meI:1}),(0,e.l_)(n.sameLength,!0)})),(0,e.Bu)("testGetStatsN1",(async()=>{await async function(s){const n=t.DataFrame.fromCsv(s).col("seq"),i=(0,V.jY)(n,5,h.kB);(0,e.Wh)(i.freq,{A:4,C:5,G:3,T:6}),(0,e.l_)(i.sameLength,!0)}(s)})),(0,e.Bu)("testGetAlphabetSimilarity",(async()=>{await async function(){const t=new Set(Object.keys(o.V.Names)),s=(0,h.KX)({A:2041,C:3015,G:3015,T:2048,"-":1e3},t);(0,e.l_)(s>.6,!0)}()})),(0,e.Bu)("testPickupPaletteN1",(async()=>{await async function(s){const n=t.DataFrame.fromCsv(s).col("seq"),i=(0,h.dQ)(n);(0,e.l_)(i instanceof o.J,!0)}(s)})),(0,e.Bu)("testPickupPaletteN1e",(async()=>{await async function(s){const n=t.DataFrame.fromCsv("seq\nACGTAT\nCAGTTG\nTTCG2C").col("seq"),i=(0,h.dQ)(n);(0,e.l_)(i instanceof o.J,!0)}()})),(0,e.Bu)("testPickupPaletteAA1",(async()=>{await async function(s){const n=t.DataFrame.fromCsv("seq\nFWPHEYV\nYNRQWYV\nMKPSEYV").col("seq"),r=(0,h.dQ)(n);(0,e.l_)(r instanceof i.f,!0)}()})),(0,e.Bu)("testPickupPaletteX",(async()=>{await async function(s){const n=t.DataFrame.fromCsv("seq\nXZJ{}2\n5Z4733\n3Z6></\n675687").col("seq"),i=(0,h.dQ)(n);(0,e.l_)(i instanceof B.kQ,!0)}()}))})),(0,e.W3)("WebLogo.monomerToShort",(()=>{(0,e.Bu)("longMonomerSingle",(async()=>{(0,e.l_)((0,h.GU)("S",5),"S")})),(0,e.Bu)("longMonomerShort",(async()=>{(0,e.l_)((0,h.GU)("Short",5),"Short")})),(0,e.Bu)("longMonomerLong56",(async()=>{(0,e.l_)((0,h.GU)("Long56",6),"Long56")})),(0,e.Bu)("longMonomerComplexFirstPartShort",(async()=>{(0,e.l_)((0,h.GU)("Long-long",5),"Long…")})),(0,e.Bu)("longMonomerComplexFirstPartLong56",(async()=>{(0,e.l_)((0,h.GU)("Long56-long",6),"Long5…")})),(0,e.Bu)("monomerToShort",(async()=>{const t=[["AbC","AbC"],["AbCd","Ab…"],["ABc","ABc"],["ABcd","AB…"],["A_b","A_b"],["A_bc","A…"],["Ab_c","Ab…"],["A1_b","A1…"],["Abc_d","Ab…"],["Abcd_e","Ab…"],["A-b","A-b"],["A-bc","A…"],["Ab-c","Ab…"],["A1-b","A1…"],["Abc-d","Ab…"],["Abcd-e","Ab…"],["A","A"],["Ab","Ab"],["Abc","Abc"],["Ab…","Ab…"],["Abcd","Ab…"],["Abcde","Ab…"]],s=t.map((t=>t[0])),n=t.map((t=>t[1])),i=s.map((t=>(0,h.GU)(t,3)));(0,e.f6)(i,n)}))}));var U=s(833);function $(t,s){(0,e.l_)(t.name,s.name),(0,e.f6)(t.getMonomers(),s.getMonomers());for(const n of t.getMonomers())(0,e.l_)(t.getFreq(n).count,s.getFreq(n).count)}(0,e.W3)("WebLogo-positions",(()=>{const s="seq\nATC-G-TTGC--\nATC-G-TTGC--\n-TC-G-TTGC--\n-TC-GCTTGC--\n-TC-GCTTGC--";(0,e.Bu)("allPositions",(async()=>{const n=t.DataFrame.fromCsv(s),i=a.shell.addTableView(n),r=n.getCol("seq");r.semType=t.SEMTYPE.MACROMOLECULE,r.setTag(t.TAGS.UNITS,h.r2.FASTA),r.setTag("alphabet","DNA"),r.setTag("aligned","SEQ.MSA");const o=await n.plot.fromType("WebLogo");i.dockManager.dock(o.root,t.DOCK_TYPE.DOWN),await(0,e.ow)((()=>o.Length>0),"WebLogo.Length is zero",100);const l=o.positions,c=[new U.CK(0,"1",{A:new U.yW(2),"-":new U.yW(3)}),new U.CK(1,"2",{T:new U.yW(5)}),new U.CK(2,"3",{C:new U.yW(5)}),new U.CK(3,"4",{"-":new U.yW(5)}),new U.CK(4,"5",{G:new U.yW(5)}),new U.CK(5,"6",{"-":new U.yW(3),C:new U.yW(2)}),new U.CK(6,"7",{T:new U.yW(5)}),new U.CK(7,"8",{T:new U.yW(5)}),new U.CK(8,"9",{G:new U.yW(5)}),new U.CK(9,"10",{C:new U.yW(5)}),new U.CK(10,"11",{"-":new U.yW(5)}),new U.CK(11,"12",{"-":new U.yW(5)})];(0,e.l_)(l.length,c.length);for(let t=0;t<l.length;t++){(0,e.l_)(l[t].name,c[t].name);for(const s of l[t].getMonomers())(0,e.l_)(l[t].getFreq(s).count,c[t].getFreq(s).count)}})),(0,e.Bu)("positions with shrinkEmptyTail option true (filtered)",(async()=>{const s=t.DataFrame.fromCsv("seq\n-TC-G-TTGC--\n-TC-GCTTGC--\n-T--C-GT-\n-T--C-GT-\n-T--C-GT-\n-T--CCGT-"),n=a.shell.addTableView(s),i=s.getCol("seq");i.semType=t.SEMTYPE.MACROMOLECULE,i.setTag(t.TAGS.UNITS,h.r2.FASTA),i.setTag("alphabet","DNA"),i.setTag("aligned","SEQ"),s.filter.init((t=>t>2)),s.filter.fireChanged();const r=await s.plot.fromType("WebLogo",{shrinkEmptyTail:!0});n.dockManager.dock(r.root,t.DOCK_TYPE.DOWN),await(0,e.ow)((()=>r.Length>0),"WebLogo.Length is zero",100);const o=r.positions,l=[new U.CK(0,"1",{"-":new U.yW(3)}),new U.CK(1,"2",{T:new U.yW(3)}),new U.CK(2,"3",{"-":new U.yW(3)}),new U.CK(3,"4",{"-":new U.yW(3)}),new U.CK(4,"5",{C:new U.yW(3)}),new U.CK(5,"6",{"-":new U.yW(2),C:new U.yW(1)}),new U.CK(6,"7",{G:new U.yW(3)}),new U.CK(7,"8",{T:new U.yW(3)}),new U.CK(8,"9",{"-":new U.yW(3)})];(0,e.l_)(o.length,l.length);for(let t=0;t<o.length;t++){(0,e.l_)(o[t].name,l[t].name);for(const s of o[t].getMonomers())(0,e.l_)(o[t].getFreq(s).count,l[t].getFreq(s).count)}})),(0,e.Bu)("positions with skipEmptyPositions option",(async()=>{const n=t.DataFrame.fromCsv(s),i=a.shell.addTableView(n),r=n.getCol("seq");r.semType=t.SEMTYPE.MACROMOLECULE,r.setTag(t.TAGS.UNITS,h.r2.FASTA),r.setTag("alphabet","DNA"),r.setTag("aligned","SEQ.MSA");const o=await n.plot.fromType("WebLogo",{skipEmptyPositions:!0});i.dockManager.dock(o.root,t.DOCK_TYPE.DOWN),await(0,e.ow)((()=>o.Length>0),"WebLogo.Length is zero");const l=o.positions,c=[new U.CK(0,"1",{A:new U.yW(2),"-":new U.yW(3)}),new U.CK(1,"2",{T:new U.yW(5)}),new U.CK(2,"3",{C:new U.yW(5)}),new U.CK(4,"5",{G:new U.yW(5)}),new U.CK(5,"6",{"-":new U.yW(3),C:new U.yW(2)}),new U.CK(6,"7",{T:new U.yW(5)}),new U.CK(7,"8",{T:new U.yW(5)}),new U.CK(8,"9",{G:new U.yW(5)}),new U.CK(9,"10",{C:new U.yW(5)})];(0,e.l_)(l.length,c.length);for(let t=0;t<l.length;t++)$(l[t],c[t])})),(0,e.Bu)("count sequences for monomer at position",(async()=>{const n=function(e,s,n,i){const r=t.DataFrame.fromCsv(e),o=r.getCol("seq");return o.semType=t.SEMTYPE.MACROMOLECULE,o.setTag(t.TAGS.UNITS,s),o.setTag("alphabet","DNA"),o.setTag("aligned","SEQ.MSA"),r}(s,h.r2.FASTA),i=n.getCol("seq"),r=a.shell.addTableView(n),o=await n.plot.fromType("WebLogo",{startPositionName:"3",endPositionName:"7",skipEmptyPositions:!0});r.dockManager.dock(o.root,t.DOCK_TYPE.DOWN),await(0,e.ow)((()=>o.Length>0),"WebLogo.Length is zero",100);const l=o.positions,u=[new U.CK(2,"3",{C:new U.yW(5)}),new U.CK(4,"5",{G:new U.yW(5)}),new U.CK(5,"6",{"-":new U.yW(3),C:new U.yW(2)}),new U.CK(6,"7",{T:new U.yW(5)})];(0,e.l_)(l.length,u.length);for(let t=0;t<l.length;t++)$(l[t],u[t]);const m=l[1],d=c.Cn.getOrCreate(i),g=(0,U.eZ)(n,d,n.filter,"G",m);(0,e.l_)(g,5)}))}));var Y=s(2568);function K(t,e){let s=null;for(const n of t.viewers)n.type===e&&(s=n);return s}(0,e.W3)("checkInputColumn",(()=>{const s="seq\nseq1,\nseq2,\nseq3,\nseq4";(0,e.Bu)("testMsaPos",(async()=>{const n=t.DataFrame.fromCsv(s).getCol("seq");n.semType=t.SEMTYPE.MACROMOLECULE,n.setTag(t.TAGS.UNITS,h.r2.FASTA),n.setTag("alphabet","DNA"),n.setTag("aligned","SEQ");const[i,r]=(0,Y.l)(n,"Test",[h.r2.FASTA],["DNA","RNA","PT"]);(0,e.l_)(i,!0)})),(0,e.Bu)("testMsaNegHelm",(async()=>{const n=t.DataFrame.fromCsv(s).getCol("seq");n.semType=t.SEMTYPE.MACROMOLECULE,n.setTag(t.TAGS.UNITS,h.r2.HELM),n.setTag(".alphabetIsMultichar","true");const[i,r]=(0,Y.l)(n,"Test",[h.r2.FASTA],["DNA","RNA","PT"]);(0,e.l_)(i,!1)})),(0,e.Bu)("testMsaNegUN",(async()=>{const n=t.DataFrame.fromCsv(s).getCol("seq");n.semType=t.SEMTYPE.MACROMOLECULE,n.setTag(t.TAGS.UNITS,h.r2.FASTA),n.setTag("alphabet","UN"),n.setTag(".alphabetSize","11"),n.setTag(".alphabetIsMultichar","true"),n.setTag("aligned","SEQ");const[i,r]=(0,Y.l)(n,"Test",[h.r2.FASTA],["DNA","RNA","PT"]);(0,e.l_)(i,!1)})),(0,e.Bu)("testGetActionFunctionMeta",(async()=>{t.Func.find({package:"Bio",name:"multipleSequenceAlignmentDialog"})[0].inputs.find((t=>"sequence"==t.name))}))})),(0,e.W3)("similarity/diversity",(async()=>{(0,e.Bu)("similaritySearchViewer",(async()=>{await async function(){const s=await T("tests/sample_MSA_data.csv"),n=await s.dataFrame.plot.fromType("Sequence Similarity Search");let i=!1;if(n.computeCompleted.subscribe((t=>{t&&(i=!0)})),s.dockManager.dock(n,t.DOCK_TYPE.RIGHT,null,"Similarity"),await n.renderPromise,await(0,e.ow)((()=>void 0!==K(s,"Sequence Similarity Search")),"Sequence Similarity Search viewer has not been created",100),!n.initialized)throw new Error("The viewer is not initialized.");if(!n.moleculeColumn)throw new Error("The viewer has not molecule column (onTableAttached).");if(!n.beforeRender())throw new Error("The viewer is not able to render.");if(!n.computeRequested)throw new Error("The viewer has not compute requested even.");if(!i)throw new Error("The viewer has not compute completed.");const r=n;await(0,e.ow)((()=>0!==r.root.getElementsByClassName("d4-grid").length),"Sequence Similarity Search viewer grid has not been created",100);(0,e.l_)(r.fingerprint,"Morgan"),(0,e.l_)(r.distanceMetric,"Tanimoto"),(0,e.l_)(r.scores.get(0),t.FLOAT_NULL),(0,e.l_)(r.idxs.get(0),0),(0,e.l_)(r.molCol.get(0),"D-Tyr_Et/Tyr_ab-dehydroMe/dV/E/N/D-Orn/D-aThr//Phe_4Me"),(0,e.l_)(r.scores.get(1),.4722222089767456),(0,e.l_)(r.idxs.get(1),11),(0,e.l_)(r.molCol.get(1),"meI/hHis//Aca/meM/Tyr_ab-dehydroMe/dV/E/N/D-Orn/D-aThr//Phe_4Me"),s.dataFrame.currentRowIdx=1,await(0,e.ow)((()=>1===r.targetMoleculeIdx),"Target molecule has not been changed",5e3),await(0,e.ow)((()=>"meI/hHis/Aca/Cys_SEt/T/dK/Thr_PO3H2/Aca/Tyr_PO3H2/D-Chg/dV/Phe_ab-dehydro/N/D-Orn/D-aThr//Phe_4Me"===r.molCol.get(0)),"Incorrect first similar molecule",5e3)}()})),(0,e.Bu)("diversitySearchViewer",(async()=>{await async function(){const s=await T("tests/sample_MSA_data.csv"),n=await s.dataFrame.plot.fromType("Sequence Diversity Search");let i=!1;if(n.computeCompleted.subscribe((t=>{t&&(i=!0)})),s.dockManager.dock(n,t.DOCK_TYPE.DOWN,null,"Diversity"),await n.renderPromise,await(0,e.ow)((()=>void 0!==K(s,"Sequence Diversity Search")),"Sequence Diversity Search viewer has not been created",100),!n.initialized)throw new Error("The viewer is not initialized.");if(!n.moleculeColumn)throw new Error("The viewer has not molecule column (onTableAttached).");if(!n.beforeRender())throw new Error("The viewer is not able to render.");if(!n.computeRequested)throw new Error("The viewer has not compute requested even.");if(!i)throw new Error("The viewer has not compute completed.");const r=n;await(0,e.ow)((()=>0!==r.root.getElementsByClassName("d4-grid").length),"Sequence Diversity Search viewer grid has not been created",100),(0,e.l_)(r.fingerprint,"Morgan"),(0,e.l_)(r.distanceMetric,"Tanimoto"),(0,e.l_)(r.initialized,!0),(0,e.l_)(r.renderMolIds.length>0,!0)}()}))}));var q=s(4413);(0,e.W3)("substructureFilters",(async()=>{let t,s;(0,e.bb)((async()=>{t=await(0,_.JN)(),s=await a.dapi.userDataStorage.get(P.RV,!0),await a.dapi.userDataStorage.post(P.RV,P.rb,!0),await t.loadLibraries(!0)})),(0,e.X5)((async()=>{await a.dapi.userDataStorage.put(P.RV,s,!0),await t.loadLibraries(!0)})),(0,e.Bu)("fasta",(async()=>{const t=await b("tests/filter_FASTA.csv"),s=new q.ST;await a.data.detectSemanticTypes(t),s.attach(t),s.bioFilter.substructure="MD",await(0,e.gw)(100),(0,e.l_)(s.dataFrame.filter.trueCount,3),(0,e.l_)(s.dataFrame.filter.get(0),!0),(0,e.l_)(s.dataFrame.filter.get(3),!0),(0,e.l_)(s.dataFrame.filter.get(8),!0),(0,e.l_)(s.dataFrame.filter.get(1),!1)})),(0,e.Bu)("separator",(async()=>{const t=await b("tests/filter_MSA.csv"),s=new q.ST;await a.data.detectSemanticTypes(t),s.attach(t),s.bioFilter.substructure="meI",await(0,e.gw)(100),(0,e.l_)(s.dataFrame.filter.trueCount,7),(0,e.l_)(s.dataFrame.filter.get(2),!1),s.bioFilter.substructure="/meI",await(0,e.gw)(100),(0,e.l_)(s.dataFrame.filter.trueCount,0),s.bioFilter.substructure="meI-hHis",s.bioFilter.separatorInput.value="-",await(0,e.gw)(100),(0,e.l_)(s.dataFrame.filter.trueCount,7),(0,e.l_)(s.dataFrame.filter.get(2),!1)})),(0,e.Bu)("helm",(async()=>{const t=await b("tests/filter_HELM.csv"),s=a.shell.addTableView(t),n=new q.ST;await a.data.detectSemanticTypes(t),n.attach(t);const i=new Promise(((e,s)=>{t.onFilterChanged.subscribe((async t=>{try{e(!0)}catch(t){s(t)}}))}));n.bioFilter.helmSubstructure="PEPTIDE1{C}$$$$V2.0",n.bioFilter.onChanged.next(),await i,(0,e.l_)(n.dataFrame.filter.trueCount,2),(0,e.l_)(n.dataFrame.filter.get(0),!0),(0,e.l_)(n.dataFrame.filter.get(3),!0),n.bioFilter.helmSubstructure="PEPTIDE1{A.C}$$$$V2.0",n.bioFilter.onChanged.next(),await(0,e.gw)(100),(0,e.l_)(n.dataFrame.filter.trueCount,1),(0,e.l_)(n.dataFrame.filter.get(3),!0),s.close()}),{skipReason:"GROK-12779"})}));var Z=s(8341);(0,e.W3)("PepSeA",(()=>{(0,e.Bu)("Basic alignment",(async()=>{await C();const s=t.DataFrame.fromCsv('HELM,MSA\n "PEPTIDE1{F.L.R.G.W.[MeF].Y.S.N.N.C}$$$$","F.L.R.G.W.MeF.Y..S.N.N.C"\n "PEPTIDE1{F.L.R.G.Y.[MeF].Y.W.N.C}$$$$","F.L.R.G.Y.MeF.Y.W...N.C"\n "PEPTIDE1{F.G.Y.[MeF].Y.W.S.D.N.C}$$$$","F...G.Y.MeF.Y.W.S.D.N.C"\n "PEPTIDE1{F.L.R.G.Y.[MeF].Y.W.S.N.D.C}$$$$","F.L.R.G.Y.MeF.Y.W.S.N.D.C"\n "PEPTIDE1{F.V.R.G.Y.[MeF].Y.W.S.N.C}$$$$","F.V.R.G.Y.MeF.Y.W.S..N.C"'),n=await(0,Z.f)(s.getCol("HELM"),"msa(HELM)");(0,e.l_)(null!==n,!0,"PepSeA conainter has not started");const i=s.getCol("MSA");for(let t=0;t<n.length;++t)(0,e.l_)(n.get(t)==i.get(t),!0)}),{skipReason:"GROK-13221"})})),(0,e.W3)("viewers",(()=>{const s=t.Func.find({package:"Bio",tags:["viewer"]}).map((t=>t.friendlyName));for(const t of s)(0,e.Bu)(t,(async()=>{const s=await b("data/sample_FASTA_DNA.csv");await(0,e.AB)(t,s,{detectSemanticTypes:!0})}),{skipReason:{"Sequence Similarity Search":"GROK-13162","Sequence Diversity Search":"GROK-13162",WebLogo:"GROK-13162",VdRegions:"GROK-13162"}[t]})}));const z="seq\nACGTC\nCAGTGT\nTTCAAC",X="seq\nAC-GT-CT\nCAC-T-GT\nACCGTACT",j="seq\nabc-dfgg-abc1-cfr3-rty-wert\nrut12-her2-rty-wert-abc-abc1-dfgg\nrut12-rty-her2-abc-cfr3-wert-rut12";(0,e.W3)("UnitsHandler",(()=>{async function s(e){const s=t.DataFrame.fromCsv(e);await a.data.detectSemanticTypes(s);const n=c.Cn.getOrCreate(s.getCol("seq"));return[s,n]}(0,e.Bu)("Seq-Fasta",(async()=>{const[t,n]=await s(z);(0,e.l_)(n.notation,h.r2.FASTA),(0,e.l_)(n.isMsa(),!1)})),(0,e.Bu)("Seq-Fasta-MSA",(async()=>{const[t,n]=await s(X);(0,e.l_)(n.notation,h.r2.FASTA),(0,e.l_)(n.isMsa(),!0)})),(0,e.Bu)("Seq-Fasta-units",(async()=>{const[t,n]=await s(z);(0,e.l_)(n.notation,h.r2.FASTA),(0,e.l_)(n.isMsa(),!1)})),(0,e.Bu)("Seq-Fasta-MSA-units",(async()=>{const[t,n]=await s(X);(0,e.l_)(n.notation,h.r2.FASTA),(0,e.l_)(n.isMsa(),!0)})),(0,e.Bu)("Seq-Helm",(async()=>{const[t,n]=await s("seq\nPEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et.Tyr_ab-dehydroMe.dV.E.N.D-Orn.D-aThr.Phe_4Me}$$$$\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2.D-Chg.dV.Phe_ab-dehydro.N.D-Orn.D-aThr.Phe_4Me}$$$$\nPEPTIDE1{Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2.D-Chg.dV.Thr_PO3H2.N.D-Orn.D-aThr.Phe_4Me}$$$$\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2.D-Chg.dV.Thr_PO3H2.N.D-Orn.D-aThr.Phe_4Me}$$$$");(0,e.l_)(n.notation,h.r2.HELM),(0,e.l_)(n.isHelm(),!0)})),(0,e.Bu)("Seq-UN",(async()=>{const[t,n]=await s(j);(0,e.l_)(n.notation,h.r2.SEPARATOR),(0,e.l_)(n.separator,"-"),(0,e.l_)(n.alphabet,"UN")})),(0,e.Bu)("Seq-UN-auto",(async()=>{const[t,n]=await s(j);(0,e.l_)(n.notation,h.r2.SEPARATOR),(0,e.l_)(n.separator,"-"),(0,e.l_)(n.alphabet,"UN")}))})),(0,e.W3)("UnitsHandler",(()=>{c._9[h.r2.FASTA],c._9[h.r2.HELM];const s=c._9[h.r2.SEPARATOR],n={fasta:{src:{csv:"seq\nACGTC\nCAGTGT\nTTCAAC"},tgt:{splitted:["ACGTC","CAGTGT","TTCAAC"]}},fastaMsa:{src:{csv:"seq\nAC-GT-CT\nCAC-T-GT\nACCGTACT"},tgt:{splitted:["AC-GT-CT","CAC-T-GT","ACCGTACT"]}},separator:{src:{csv:"seq\nabc-dfgg-abc1-cfr3-rty-wert\nrut12-her2-rty-wert-abc-abc1-dfgg\nrut12-rty-her2-abc-cfr3-wert-rut12"},tgt:{splitted:[["abc","dfgg","abc1","cfr3","rty","wert"],["rut12","her2","rty","wert","abc","abc1","dfgg"],["rut12","rty","her2","abc","cfr3","wert","rut12"]]}},separatorMsa:{src:{csv:"seq\nabc-dfgg-abc1-cfr3-rty-wert\nrut12-her2-rty--abc1-dfgg\nrut12-rty-her2---wert"},tgt:{splitted:[["abc","dfgg","abc1","cfr3","rty","wert"],["rut12","her2","rty",s,"abc1","dfgg"],["rut12","rty","her2",s,s,"wert"]]}},helm:{src:{csv:"seq\nPEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et}$$$$\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca}$$$$\nPEPTIDE1{Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca}$$$$\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2}$$$$"},tgt:{splitted:[["meI","hHis","Aca","N","T","dE","Thr_PO3H2","Aca","D-Tyr_Et"],["meI","hHis","Aca","Cys_SEt","T","dK","Thr_PO3H2","Aca"],["Lys_Boc","hHis","Aca","Cys_SEt","T","dK","Thr_PO3H2","Aca"],["meI","hHis","Aca","Cys_SEt","T","dK","Thr_PO3H2"]]}}};for(const[s,i]of Object.entries(n))(0,e.Bu)(`splitted-${s}`,(async()=>{const s=t.DataFrame.fromCsv(i.src.csv).getCol("seq"),n=await a.functions.call("Bio:detectMacromolecule",{col:s});n&&(s.semType=n),(0,e.l_)(s.semType,t.SEMTYPE.MACROMOLECULE);const r=c.Cn.getOrCreate(s).splitted;(0,e.f6)(r,i.tgt.splitted)}))})),(0,e.W3)("UnitsHandler: getRegion",(()=>{const s={fastaDna:{srcCsv:"seq\nATTCGT\nACTGCTC\nATTCCGTA",startIdx:2,endIdx:4,tgtCsv:"seq\nTCG\nTGC\nTCC",units:h.r2.FASTA,alphabet:"DNA",positionNames:{tag:"a, b, c, d, e, f, g, h",start:"c",end:"e"}},separatorPt:{srcCsv:"seq\nM-D-Y-K-E-T-L\nM-I-E-V-F-L-F-G-I\nM-M-",startIdx:5,endIdx:null,tgtCsv:"seq\nT-L--\nL-F-G-I\n---",units:h.r2.SEPARATOR,alphabet:"PT",positionNames:{tag:"1, 1A, 1B, 2, 3, 4, 4A, 4A, 4C",start:"4",end:null}},helm:{srcCsv:"seq\nPEPTIDE1{[meI].[hHis].[Aca].N.T.[dE].[Thr_PO3H2].[Aca].[D-Tyr_Et].[Tyr_ab-dehydroMe].[dV].E.N.[D-Orn]}$$$$\nPEPTIDE1{[meI].[hHis].[Aca].[Cys_SEt].T.[dK].[Thr_PO3H2].[Aca].[Tyr_PO3H2].[D-Chg].[dV].[Phe_ab-dehydro]}$$$$\nPEPTIDE1{[Lys_Boc].[hHis].[Aca].[Cys_SEt].T}$$$$",startIdx:3,endIdx:6,tgtCsv:"seq\nPEPTIDE1{N.T.[dE].[Thr_PO3H2]}$$$$\nPEPTIDE1{[Cys_SEt].T.[dK].[Thr_PO3H2]}$$$$\nPEPTIDE1{[Cys_SEt].T.*.*}$$$$",units:h.r2.HELM,alphabet:null,positionNames:{tag:null,start:"4",end:"7"}}};for(const[n,i]of Object.entries(s))(0,e.Bu)(`${n}-idx`,(async()=>{const s=t.DataFrame.fromCsv(i.srcCsv).getCol("seq"),n=await a.functions.call("Bio:detectMacromolecule",{col:s});n&&(s.semType=n);const r=c.Cn.getOrCreate(s).getRegion(i.startIdx,i.endIdx,"regSeq"),o=t.DataFrame.fromCsv(i.tgtCsv).getCol("seq");(0,e.l_)(s.getTag(t.TAGS.UNITS),i.units),(0,e.l_)(r.getTag(t.TAGS.UNITS),i.units),(0,e.l_)(s.getTag("alphabet"),i.alphabet),(0,e.l_)(r.getTag("alphabet"),i.alphabet),(0,e.f6)(r.toList(),o.toList())})),i.positionNames&&(0,e.Bu)(`${n}-positionNames`,(async()=>{const s=t.DataFrame.fromCsv(i.srcCsv).getCol("seq");i.positionNames.tag&&s.setTag(".positionNames",i.positionNames.tag);const n=await a.functions.call("Bio:detectMacromolecule",{col:s});n&&(s.semType=n);const r=await a.functions.call("Bio:getRegion",{sequence:s,start:i.positionNames.start,end:i.positionNames.end}),o=t.DataFrame.fromCsv(i.tgtCsv).getCol("seq");(0,e.l_)(s.getTag(t.TAGS.UNITS),i.units),(0,e.l_)(r.getTag(t.TAGS.UNITS),i.units),(0,e.l_)(s.getTag("alphabet"),i.alphabet),(0,e.l_)(r.getTag("alphabet"),i.alphabet),(0,e.f6)(r.toList(),o.toList())}))}));var Q=s(8601);const J=new t.FileSource("System:AppData/Bio"),tt={PT:"peptides fasta",DNA:"dna fasta",MSA:"msa separator"},et={PT:"tests/to-atomic-level-peptides-fasta-input.csv",DNA:"tests/to-atomic-level-dna-fasta-input.csv",MSA:"tests/to-atomic-level-msa-separator-input.csv"},st={PT:"tests/to-atomic-level-peptides-output.csv",DNA:"tests/to-atomic-level-dna-output.csv",MSA:"tests/to-atomic-level-msa-output.csv"},nt="molfile(sequence)";async function it(t,e="seq",s){const n=t.getCol(e),i=s.getBioLib();await(0,Q.i0)(t,n,i)}(0,e.W3)("toAtomicLevel",(async()=>{const s={},n={};let i,r,o=null;async function h(t,s){const n=t.getCol("sequence");await(0,l.toAtomicLevel)(t,n);const i=t.getCol(nt),r=s.getCol(nt),o=[...i.values()],a=[...r.values()];(0,e.f6)(o,a)}(0,e.bb)((async()=>{i=await(0,l.getMonomerLibHelper)(),o=await a.dapi.userDataStorage.get(P.RV,!0),await a.dapi.userDataStorage.put(P.RV,{},!0),await i.loadLibraries(!0);for(const t in tt)s[t]=await J.readCsv(et[t]),await a.data.detectSemanticTypes(s[t]),n[t]=await J.readCsv(st[t])})),(0,e.X5)((async()=>{await a.dapi.userDataStorage.put(P.RV,o,!0),await i.loadLibraries(!0)}));for(const t in tt)(0,e.Bu)(`${tt[t]}`,(async()=>{await h(s[t],n[t])}),{skipReason:"GROK-13100"});!function(t){t.fastaDna="fastaDna",t.fastaRna="fastaRna",t.fastaPt="fastaPt",t.separatorDna="separatorDna",t.separatorRna="separatorRna",t.separatorPt="separatorPt",t.separatorUn="separatorUn",t.helm="helm"}(r||(r={}));const c={[r.fastaDna]:"seq\nACGTC\nCAGTGT\nTTCAAC",[r.fastaRna]:"seq\nACGUC\nCAGUGU\nUUCAAC",[r.fastaPt]:"seq\nFWPHEY\nYNRQWYV\nMKPSEYV",[r.separatorDna]:"seq\nA/C/G/T/C\nC/A/G/T/G/T\nT/T/C/A/A/C",[r.separatorRna]:"seq\nA*C*G*U*C\nC*A*G*U*G*U\nU*U*C*A*A*C",[r.separatorPt]:"seq\nF-W-P-H-E-Y\nY-N-R-Q-W-Y-V\nM-K-P-S-E-Y-V",[r.separatorUn]:"seq\nmeI-hHis-Aca-N-T-dE-Thr_PO3H2-Aca-D\nmeI-hHis-Aca-Cys_SEt-T-dK-Thr_PO3H2-Aca-Tyr_PO3H2\nLys_Boc-hHis-Aca-Cys_SEt-T-dK-Thr_PO3H2-Aca-Tyr_PO3H2",[r.helm]:"seq\nPEPTIDE1{meI.D-gGlu.Aca.N.T.dE.Thr_PO3H2.Aca.D}$$$\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2}$$$\nPEPTIDE1{Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2}$$$"};async function u(e){const s=c[e],n=t.DataFrame.fromCsv(s);return await a.data.detectSemanticTypes(n),n}(0,e.Bu)("fastaDna",(async()=>{await it(await u(r.fastaDna),"seq",i)})),(0,e.Bu)("fastaRna",(async()=>{await it(await u(r.fastaRna),"seq",i)})),(0,e.Bu)("fastaPt",(async()=>{await it(await u(r.fastaPt),"seq",i)})),(0,e.Bu)("separatorDna",(async()=>{await it(await u(r.separatorDna),"seq",i)})),(0,e.Bu)("separatorDna",(async()=>{await it(await u(r.separatorRna),"seq",i)})),(0,e.Bu)("separatorPt",(async()=>{await it(await u(r.separatorPt),"seq",i)})),(0,e.Bu)("separatorUn",(async()=>{await it(await u(r.separatorUn),"seq",i)})),(0,e.Bu)("helm",(async()=>{await it(await u(r.helm),"seq",i)}))}));var rt=s(489);async function ot(e){const s=t.DataFrame.fromCsv(e),n=s.col("seq"),i=await a.functions.call("Bio:detectMacromolecule",{col:n});return i&&(n.semType=i),await a.data.detectSemanticTypes(s),c.Cn.getOrCreate(n)}function at(t,s,n,i){const r=n(t,s);(0,e.l_)(Number(r.toFixed(3)),Number(i.toFixed(3)))}async function lt(t,s,n,i){await a.data.detectSemanticTypes(t);const r=await(0,l.activityCliffs)(t,t.getCol(i),t.getCol("activity"),90,n);(0,e.l_)(null!=r,!0);const o=Array.from(r.root.children).find((t=>{const e=t.className.split(" ");return["ui-btn","ui-btn-ok"].every((t=>e.includes(t)))}));(0,e.l_)(o.innerText.toLowerCase(),`${s} cliffs`)}(0,e.W3)("Distance",(async()=>{const s=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],n={F:0,W:1,R:2,Y:3},i="FWRWY",r="FWRWW",o="FWY",a="FWRWY",l="FWY",h="FWRRRRY";(0,e.Bu)("protein-distance-function",(async()=>{const t=(await ot("seq\n FWRWYVKHP\n YNRWYVKHP\n MWRSWYCKHP")).getDistanceFunctionName();(0,e.l_)(t,rt.U.LEVENSHTEIN)})),(0,e.Bu)("DNA-distance-function",(async()=>{const t=(await ot("seq\n ATAACG\n ATCGA\n ATCGA")).getDistanceFunctionName();(0,e.l_)(t,rt.U.LEVENSHTEIN)})),(0,e.Bu)("MSA-distance-function",(async()=>{const t=(await ot("seq\n ATAAC\n ATCGA\n ATCGA")).getDistanceFunctionName();(0,e.l_)(t,rt.U.HAMMING)})),(0,e.Bu)("levenstein-sub",(async()=>{const t=rt.o[rt.U.LEVENSHTEIN]();at(i,r,t,.2)})),(0,e.Bu)("levenstein-del",(async()=>{const t=rt.o[rt.U.LEVENSHTEIN]();at(o,a,t,.4)})),(0,e.Bu)("hamming",(async()=>{const t=rt.o[rt.U.HAMMING]();at(o,a,t,.6)})),(0,e.Bu)("needleman-blosum62",(async()=>{const t=rt.o[rt.U.NEEDLEMANN_WUNSCH]();at(i,r,t,.205)})),(0,e.Bu)("needleman-blosum62-del",(async()=>{const t=rt.o[rt.U.NEEDLEMANN_WUNSCH]();at(o,a,t,.65)})),(0,e.Bu)("needleman-custom-sub",(async()=>{const t=rt.o[rt.U.NEEDLEMANN_WUNSCH]({scoringMatrix:s,alphabetIndexes:n,gapOpen:1,gapExtend:1});at(i,r,t,.2)})),(0,e.Bu)("needleman-custom-del",(async()=>{const t=rt.o[rt.U.NEEDLEMANN_WUNSCH]({scoringMatrix:s,alphabetIndexes:n,gapOpen:1,gapExtend:1});at(o,a,t,.8)})),(0,e.Bu)("needleman-custom-zero-extend",(async()=>{const t=rt.o[rt.U.NEEDLEMANN_WUNSCH]({scoringMatrix:s,alphabetIndexes:n,gapOpen:1,gapExtend:0});at(l,h,t,.714)})),(0,e.Bu)("needleman-custom-half-extend",(async()=>{const t=rt.o[rt.U.NEEDLEMANN_WUNSCH]({scoringMatrix:s,alphabetIndexes:n,gapOpen:2,gapExtend:1});at(l,h,t,1.286)})),(0,e.Bu)("needleman-custom-same-extend",(async()=>{const e=rt.o[rt.U.NEEDLEMANN_WUNSCH]({scoringMatrix:s,alphabetIndexes:n,gapOpen:1,gapExtend:1});t.Test.isInBenchmark?at(Array(1e4).fill("FWRY").join(""),Array(1e4).fill("FYWRRY").join(""),e,.667):at(l,h,e,1.143)}))}));var ht=s(116);async function ct(t,s,n){const i=t.getCol(n),r=await a.functions.call("Bio:detectMacromolecule",{col:i});r&&(i.semType=r);const o=await(0,l.sequenceSpaceTopMenu)(t,t.col(n),s,rt.U.LEVENSHTEIN,!0);(0,e.l_)(null!=o,!0)}(0,e.W3)("activityCliffs",(async()=>{let s,n,i,r,o=[],l=[];(0,e.bb)((async()=>{o=[],l=[]})),(0,e.X5)((async()=>{})),(0,e.Bu)("activityCliffsOpens",(async()=>{n=await b(t.Test.isInBenchmark?"test/peptides_motif-with-random_10000.csv":"tests/100_3_clustests.csv"),l.push(n),s=a.shell.addTableView(n),o.push(s);const e=t.Test.isInBenchmark?6:3;await lt(n,e,ht.AL.UMAP,"sequence")}),{skipReason:"GROK-13952"}),(0,e.Bu)("activityCliffsWithEmptyRows",(async()=>{r=await b("tests/100_3_clustests_empty_vals.csv"),l.push(r),i=a.shell.addTableView(r),o.push(i),await lt(r,3,ht.AL.UMAP,"sequence")}),{skipReason:"GROK-13851: Unhandled exceptions"})})),(0,e.W3)("sequenceSpace",(async()=>{let s,n,i,r;(0,e.Bu)("sequenceSpaceOpens",(async()=>{s=await b(t.Test.isInBenchmark?"test/peptides_motif-with-random_10000.csv":"tests/100_3_clustests.csv"),n=a.shell.addTableView(s),await ct(s,ht.AL.UMAP,"sequence"),a.shell.closeTable(s),n.close()})),(0,e.Bu)("sequenceSpaceWithEmptyRows",(async()=>{i=await b("tests/100_3_clustests_empty_vals.csv"),r=a.shell.addTableView(i),await ct(i,ht.AL.UMAP,"sequence"),a.shell.closeTable(i),r.close()}))})),(0,e.W3)("Scoring",(()=>{const s="sequence",n="expected_similarity",i="expected_identity",r=t.DataFrame.fromCsv(`${s},${n},${i}\n PEPTIDE1{Aca.Orn.gGlu.Pqa.D-His_1Bn.dH.hHis.4Abz.D-Tic.D-Dap.Y.Iva.meS.F.P.F.D-1Nal}$$$$,1.0,1.0\n PEPTIDE1{Iva.Gly_allyl.gGlu.Pqa.D-Dip.dH.hHis.4Abz.D-aHyp.D-Dap.Y.Iva.I.Tyr_26diMe.P.Asu.meC}$$$$,0.68,0.53\n PEPTIDE1{[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal]}$$$$V2.0,0.34,0.0\n `),o=r.getCol(s);o.setTag(t.TAGS.UNITS,h.r2.HELM),o.semType=t.SEMTYPE.MACROMOLECULE;const a=o.get(0);(0,e.bb)((async()=>{const t=await(0,_.JN)();await t.loadLibraries(!0)})),(0,e.Bu)("Identity",(async()=>{const t=await(0,l.sequenceIdentityScoring)(r,o,a);for(let s=0;s<t.length;s++)(0,e.jh)(t.get(s),r.get(i,s),.01,`Wrong identity score for sequence at position ${s}`)})),(0,e.Bu)("Similarity",(async()=>{const t=await(0,l.sequenceSimilarityScoring)(r,o,a);for(let s=0;s<t.length;s++)(0,e.jh)(t.get(s),r.get(n,s),.01,`Wrong similarity score for sequence at position ${s}`)}))}));const ut=new t.Package;async function mt(s,n,i){const r=await(0,e.ci)({category:s,test:n,testContext:i});return t.DataFrame.fromObjects(r)}})(),bio_test=n})();
|
|
1
|
+
var bio_test;(()=>{var t={2012:(t,e,s)=>{"use strict";s.d(e,{f:()=>i});var n=s(9976);class i extends n.B{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,i)),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,i)),this.grokGroups}static get RasMol(){return void 0===this.rasMol&&(this.rasMol=new i({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 i.aaSynonyms?i.aaSynonyms[t]:t;return super.get(e)}}i.aaSynonyms={MeNle:"L",MeA:"A",MeG:"G",MeF:"F"};class r{static getPalette(t="grok"){switch(t){case"grok":return i.GrokGroups;case"lesk":return i.Lesk;default:throw new Error(`ChemPalette: scheme \`${t}\` does not exist`)}}static getInnerOuter(t){let e=0,s="",n="";for(const i of t)"("==i?e++:")"==i?e--:e?s+=i:n+=i;return isNaN(parseInt(s))?[n,s]:[n,""]}static getColorAAPivot(t="",e="grok"){const s=this.getPalette(e);let[n,i]=this.getInnerOuter(t);if(n=n.length>6?`${n.slice(0,3)}...`:n,i=i.length>6?`${i.slice(0,3)}...`:i,1==t.length||"("==t[1]){const e=t[0]?.toUpperCase();return e in s?[s.get(e),e,i,1]:[this.undefinedColor,n,i,1]}if("d"==t[0]&&t[1]in s&&(2==t.length||"("==t[2])){const e=t[1]?.toUpperCase();return e in s?[s.get(e),e,i,2]:[this.undefinedColor,n,i,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 s?[s.get(e),e,i,3]:[this.undefinedColor,n,i,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 s?[s.get(e),e,i,4]:[this.undefinedColor,n,i,4]}return[this.undefinedColor,n,i,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"}},7228:(t,e,s)=>{"use strict";s.d(e,{JN:()=>c,Qx:()=>u,Xk:()=>h,Z:()=>l,eD:()=>a});var n=s(976),i=s(4469),r=s(1047),o=(s(499),s(8457));function a(t){return t.every((t=>"object"==typeof t&&Object.values(r.pn).every((e=>e in t&&"string"==typeof t[e]))))}function l(t){function e(t){const e=new RegExp("\\[r\\]","g");let s=0;return t.replace(e,(t=>(++s,`[${s}*]`)))}const s=[];return t.forEach((t=>{const i={...r.zh};Object.entries(r.pn).forEach((([e,s])=>{const n=t[s];i[e]=n}));let o="smiles";const a=t[r.pn[o]],l=e(a).replace("[1*]","[H:1]").replace("[2*]","[OH:2]");i[o]=l,o="rgroups",i[o]=r.Ei,o="molfile";const h=e(a),c=n.chem.convert(h,n.chem.Notation.Smiles,n.chem.Notation.MolBlock);i[o]=c.replace("M ISO","M RGP"),s.push(i)})),console.log("resultLib:",s),s}function h(t){const e=[];for(let s=0;s<t.rowCount;s++){const n={};Object.keys(r.K4).forEach((e=>{if("symbol"===e){const i=t.get(r.K4[e],s);n[e]="."===i?t.get(r.At,s):i}else if("rgroups"===e){const i=t.get(r.K4[e],s).split("\n"),o=[];i.forEach((t=>{const e={},s=t.substring(t.lastIndexOf("]")+1),n=t.match(/\[R(\d+)\]/)[1];e.capGroupSmiles="H"===s?`[*:${n}][H]`:`O[*:${n}]`,e.alternateId="H"===s?`R${n}-H`:`R${n}-OH`,e.capGroupName="H"===s?"H":"OH",e.label=`R${n}`,o.push(e)})),n[e]=o}else r.K4[e]&&(n[e]=t.get(r.K4[e],s))})),e.push(n)}return e}async function c(){const t=n.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){t instanceof n.Column&&(t=(0,o.O)(t).columns.toList());const s=(await c()).getBioLib(),r=new Array(t.length),a=t[0].length,l=new Float32Array(a);for(let o=0;o<t.length;++o){const h=e[o],c=s.getMonomer("PEPTIDE",h)?.smiles??"",u=t[o],m=u.getRawData(),d=u.categories,g=d.indexOf("");if(r[o]={categories:d,data:m,emptyIndex:g},void 0===h)continue;const f=n.Column.fromStrings("smiles",d.map((t=>s.getMonomer("PEPTIDE",t)?.smiles??""))),p=(n.DataFrame.fromColumns([f]),(await i.chem.getSimilarities(f,c)).getRawData());for(let t=0;t<a;++t){const e=m[t];l[t]+=""!==h&&e!==g?p[e]:""===h&&e===g?1:0}}for(let s=0;s<l.length;++s){let i=l[s]/e.length;for(let o=0;o<t.length;++o){const t=r[o];if(o>=e.length&&t.data[s]!==t.emptyIndex||t.data[s]===t.emptyIndex&&o<e.length){i=n.FLOAT_NULL;break}}l[s]=i}return n.Column.fromFloat32Array("Similarity",l)}},8601:(t,e,s)=>{"use strict";s.d(e,{i0:()=>m});var n=s(4469),i=s(976),r=s(6414),o=s.n(r),a=s(1821),l=s(499);const h={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:"d",RIBOSE:"r",PHOSPHATE:"p",OXYGEN:"O",HYDROGEN:"H"};var c=s(1047);function u(t){return Math.round(h.PRECISION_FACTOR*t)/h.PRECISION_FACTOR}async function m(t,e,r){if(0===i.Func.find({package:"Chem",name:"getRdKitModule"}).length)return{col:null,warnings:['Transformation to atomic level requires the package "Chem" installed.']};if(e.semType!==i.SEMTYPE.MACROMOLECULE)return{col:null,warnings:[`Only the ${i.SEMTYPE.MACROMOLECULE} columns can be converted to atomic level, the chosen column has semType '${e.semType}'`]};let u=e;const m=l.Cn.getOrCreate(e);m.isHelm()&&(u=m.convert(a.r2.SEPARATOR,"."),u.name=e.name);const g=l.Cn.getOrCreate(u).alphabet;let f;if("PT"===g||"UN"===g)f="PEPTIDE";else{if("RNA"!==g&&"DNA"!==g)return{col:null,warnings:[`Unexpected column's '${u.name}' alphabet '${g}'.`]};f="RNA"}const p=function(t){const e=t.length,s=new Array(e),n=l.Cn.getOrCreate(t).getSplitter();for(let i=0;i<e;++i){const e=t.get(i);s[i]=e?o()(n(e)).filter((t=>""!==t)).toArray():[]}return s}(u),y=await async function(t,e,s,i){const r=function(t,e,s){const n=new Map;for(const i of t.getMonomerSymbolsByType(e)){const r=t.getMonomer(e,i);if("RNA"===e&&("Branch"===r.monomerType||"DNA"===s&&r.symbol===h.DEOXYRIBOSE||"RNA"===s&&r.symbol===h.RIBOSE||r.symbol===h.PHOSPHATE)||"PEPTIDE"===e&&"Branch"!==r.monomerType){const t={};c.rx.forEach((e=>{t[e]=r[e]})),n.set(r.symbol,t)}}return n}(e,s,i),o=new Map,a=await n.functions.call("Chem:getRdKitModule"),l={value:null};if("RNA"===s){const t="RNA"===i?[h.RIBOSE,h.PHOSPHATE]:[h.DEOXYRIBOSE,h.PHOSPHATE];for(const e of t)d(o,e,r,a,s,l)}for(let e=0;e<t.length;++e){const n=t[e];for(const t of n)if(""!==t)try{d(o,t,r,a,s,l)}catch(e){const s=e instanceof Error?e.message:e.toString(),n=e instanceof Error?e.stack:void 0;throw console.error(`bio lib: getMonomersDictFromLib() sym='${t}', error:\n${s}\n${n}`),new Error(`Can't get monomer '${t}' from library: ${s}`)}}return o}(p,r,f,g),w=u.length,{molfileList:b,molfileWarningList:T}=await async function(t,e,n,i,r){const o=Math.max(navigator.hardwareConcurrency-2,1),a=new Array(o).fill(null).map((()=>new Worker(new URL(s.p+s.u(79),s.b)))),l=r/o;let h=[],c=[];const u=new Array(o);for(let s=0;s<o;s++){const h=Math.floor(s*l),c=s===o-1?r:Math.floor((s+1)*l);a[s].postMessage({monomerSequencesArray:t,monomersDict:e,alphabet:n,polymerType:i,start:h,end:c}),u[s]=new Promise((t=>{a[s].onmessage=({data:{molfileList:e,molfileWarningList:s}})=>{t({molfileList:e,molfileWarningList:s})}}))}return(await Promise.all(u)).forEach((t=>{h=h.concat(...t.molfileList),c=c.concat(...t.molfileWarningList)})),setTimeout((()=>{a.forEach((t=>{t.terminate()}))}),0),{molfileList:h,molfileWarningList:c}}(p,y,g,f,w);if(T.length>.05*w)throw new Error("Too many errors getting molfiles.");const C=`molfile(${u.name})`,S=t.columns.getUnusedName(C),A=i.Column.fromStrings(S,b);return A.semType=i.SEMTYPE.MOLECULE,A.setTag(i.TAGS.UNITS,i.UNITS.Molecule.MOLBLOCK),{col:A,warnings:T}}function d(t,e,s,n,i,r){if(!t.has(e)){const o=function(t,e,s,n,i){if(e.has(t)){const r=e.get(t),o=function(t){const e=[];for(const s of t){let t=s.capGroupSmiles;t||(t=s.capGroupSMILES),t=t.replace(/(\[|\]|\*|:|\d)/g,""),e.push(t)}return e}(r.rgroups),a=function(t){const e=new Map;let s=t.indexOf(h.V2K_A_LINE,0),n=s;for(;-1!==s;){n=t.indexOf("\n",s);const i=parseInt(t.substring(s,n).replace(/^A\s+/,""));s=t.indexOf("R",n),n=t.indexOf("\n",s);const r=parseInt(t.substring(s,n).replace(/^R/,""));e.set(i,r),s=t.indexOf(h.V2K_A_LINE,n)}for(s=t.indexOf(h.V2K_RGP_LINE,0),n=t.indexOf("\n",s);-1!==s;){s+=h.V2K_RGP_SHIFT,n=t.indexOf("\n",s);const i=t.substring(s,n).replaceAll(/\s+/g," ").split(" ").map((t=>parseInt(t))).slice(1);for(let t=0;t<i.length;t+=2){if(e.has(i[t])&&e.get(i[t])!==i[t+1])throw new Error(`r-group index ${i[t]} has already been added with a different value`);e.set(i[t],i[t+1])}s=t.indexOf(h.V2K_RGP_LINE,n)}return e}(r.molfile),l=function(t,e){const s=e.get_mol(t),n=s.get_v3Kmolblock();return s.delete(),n}(function(t){let e=t.indexOf(h.V2K_A_LINE,0);-1===e&&(e=t.indexOf(h.V2K_RGP_LINE));const s=t.indexOf(h.V3K_END,e);return t.substring(0,e)+t.substring(s)}(r.molfile),s),c=function(t){let e=(t=t.replaceAll("\r","")).indexOf(h.V3K_BEGIN_COUNTS_LINE)+h.V3K_COUNTS_SHIFT,s=t.indexOf(" ",e+1);const n=parseInt(t.substring(e,s));return e=s+1,s=t.indexOf(" ",e+1),{atomCount:n,bondCount:parseInt(t.substring(e,s))}}(l),m=function(t,e){const s=new Array(e),n=new Float32Array(e),i=new Float32Array(e),r=new Array(e);let o=t.indexOf(h.V3K_BEGIN_ATOM_BLOCK);o=t.indexOf("\n",o);let a=o;for(let l=0;l<e;l++){o=t.indexOf(h.V3K_BEGIN_DATA_LINE,o)+h.V3K_IDX_SHIFT,a=t.indexOf(" ",o),o=a+1,a=t.indexOf(" ",o),s[l]=t.substring(o,a);const e=new Array(2);for(let s=0;s<2;++s)o=a+1,a=t.indexOf(" ",o),e[s]=parseFloat(t.substring(o,a));n[l]=e[0],i[l]=e[1],o=a,a=t.indexOf("\n",o)+1,r[l]=t.slice(o,a),o=a}return{atomTypes:s,x:n,y:i,kwargs:r}}(l,c.atomCount),d=function(t,e){const s=new Uint32Array(e),n=new Array(e),i=new Map,r=new Map;let o=t.indexOf(h.V3K_BEGIN_BOND_BLOCK);o=t.indexOf("\n",o);let a=o;for(let l=0;l<e;++l){const e=new Array(3);o=t.indexOf(h.V3K_BEGIN_DATA_LINE,a)+h.V3K_IDX_SHIFT,a=t.indexOf(" ",o);for(let s=0;s<3;++s)o=a+1,a=Math.min(t.indexOf("\n",o),t.indexOf(" ",o)),e[s]=parseInt(t.slice(o,a));s[l]=e[0],n[l]=e.slice(1);const c=t.indexOf("\n",o);let u=t.slice(a,c),m=u.indexOf(h.V3K_BOND_CONFIG);if(-1!==m){m=u.indexOf("=",m)+1;let t=u.indexOf(" ",m);-1===t&&(t=u.length);const e=parseInt(u.slice(m,t));i.set(l,e);const s=h.V3K_BOND_CONFIG+e.toString();u=u.replace(s,"")}u||r.set(l,u)}return{bondTypes:s,atomPairs:n,bondConfiguration:i,kwargs:r}}(l,c.bondCount),y={atoms:m,bonds:d,meta:g(m,d,o,a)};return"PEPTIDE"===n?function(t){const e=t.meta.terminalNodes[0]-1,s=t.meta.rNodes[0]-1,n=t.atoms.x,i=t.atoms.y;A(t,-n[e],-i[e]);const r=T(n[s],i[s]);C(t.atoms,-r),n[t.meta.rNodes[1]-1]<0&&function(t){S(t,!1)}(t);const o=function(t){const e=function(t){const e=new Map;for(const s of t.bonds.atomPairs)for(let t=0;t<2;t++){const n=s[t],i=s[(t+1)%2];e.has(n)?e.get(n)?.push(i):e.set(n,new Array(1).fill(i))}return e}(t);let s=0,n=0;for(;0===s;){const i=e.get(t.meta.terminalNodes[1])[n];t.atoms.atomTypes[i-1]===h.OXYGEN&&i!==t.meta.rNodes[1]&&(s=i),n++}return s}(t);!function(t,e){t.atoms.y[t.meta.rNodes[1]-1]<0&&t.atoms.y[e-1]<0&&(function(t){S(t,!0)}(t),C(t.atoms,-function(t,e){return T(t,e)+Math.PI/2}(t.atoms.x[t.meta.terminalNodes[1]-1],t.atoms.y[t.meta.terminalNodes[1]-1])))}(t,o),function(t,e){const s=t.atoms.x;s[t.meta.rNodes[1]-1]>s[e-1]&&function(t,e,s){const n=e-1,i=s-1,r=t.atoms.x,o=t.atoms.y,a=r[n],l=o[n];r[n]=r[i],o[n]=o[i],r[i]=a,o[i]=l}(t,e,t.meta.rNodes[1])}(t,o)}(y):t===h.RIBOSE||t===h.DEOXYRIBOSE?function(t,e){const s=t.atoms.x,n=t.atoms.y;let i=t.meta.terminalNodes[0]-1;const r=t.meta.rNodes[1]-1;A(t,-s[i],-n[i]);const o=T(s[r],n[r]);C(t.atoms,3*Math.PI/2-o),e.value=function(t){const e=t.atoms.x,s=t.atoms.y,n=t.meta.rNodes[2]-1,i=t.meta.terminalNodes[2]-1,r=e[n]-e[i],o=s[n]-s[i];return Math.atan(o/r)+Math.PI/2}(t),i=t.meta.terminalNodes[0]-1,A(t,-s[i],-n[i])}(y,i):t===h.PHOSPHATE?function(t){const e=t.meta.terminalNodes[0]-1,s=t.meta.rNodes[0]-1,n=t.atoms.x,i=t.atoms.y;A(t,-n[e],-i[e]);const r=T(n[s],i[s]);C(t.atoms,Math.PI/2-r)}(y):function(t,e){const s=t.atoms.x,n=t.atoms.y,i=t.meta.terminalNodes[0]-1,r=t.meta.rNodes[0]-1;A(t,-s[i],-n[i]);const o=T(s[r],n[r]),a=e.value;if(!a)throw new Error("The value of sugarBranchToOYAngle is null");C(t.atoms,Math.PI-o+a);const l=function(t,e){return u(Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2))}({x:s[t.meta.rNodes[0]-1],y:n[t.meta.rNodes[0]-1]},{x:s[t.meta.terminalNodes[0]-1],y:n[t.meta.terminalNodes[0]-1]});if(1!=l)for(let t=0;t<s.length;++t)s[t]=u(s[t]/l),n[t]=u(n[t]/l)}(y,i),function(t,e,s){"PEPTIDE"===t?(p(e,t),w(e,e.meta.rNodes[1])):s===h.RIBOSE||s===h.DEOXYRIBOSE?(w(e,e.meta.rNodes[1]),e.meta.rNodes[1]=e.meta.terminalNodes[1],f(e.bonds,e.meta),p(e,t),w(e,e.meta.rNodes[1]),w(e,e.meta.rNodes[0]),w(e,e.meta.rNodes[2])):s===h.PHOSPHATE&&(e.meta.terminalNodes[0]=e.meta.rNodes[0],A(e,-e.atoms.x[e.meta.terminalNodes[0]-1],-e.atoms.y[e.meta.terminalNodes[0]-1]),p(e,t),w(e,e.meta.rNodes[1]))}(n,y,t),function(t){let e=0;for(;e<t.atoms.atomTypes.length;)t.atoms.atomTypes[e]===h.HYDROGEN&&(w(t,e+1),--e),++e}(y),y}return null}(e,s,n,i,r);if(!o)throw new Error(`Monomer with symbol '${e}' is absent the monomer library`);t.set(e,o)}}function g(t,e,s,n){const i={backboneShift:null,branchShift:null,terminalNodes:[],rNodes:[]};return function(t,e,s){for(const[n,i]of s)t.atomTypes[n-1]=e[i-1]}(t,s,n),function(t,e){e.rNodes=Array.from(t.keys());for(let s=0;s<e.rNodes.length;s++)for(const n of[1,2])if(t.get(e.rNodes[s])===n){const t=e.rNodes[n-1];e.rNodes[n-1]=e.rNodes[s],e.rNodes[s]=t}}(n,i),f(e,i),i}function f(t,e){const s=e.rNodes;e.terminalNodes=new Array(s.length).fill(0);const n=e.terminalNodes,i=t.atomPairs;let r=0,o=0;for(;r<i.length&&o<n.length;){for(let t=0;t<n.length;++t)for(let e=0;e<2;++e)i[r][e]===s[t]&&(n[t]=i[r][(e+1)%2],s.length,++o);++r}}function p(t,e){t.meta.rNodes.length>1&&(t.meta.backboneShift=y(t,t.meta.rNodes[1]-1,t.meta.terminalNodes[0]-1)),"RNA"===e&&t.meta.rNodes.length>2&&(t.meta.branchShift=y(t,t.meta.rNodes[2]-1,t.meta.terminalNodes[0]-1))}function y(t,e,s){return[u(t.atoms.x[e]-t.atoms.x[s]),u(t.atoms.y[e]-t.atoms.y[s])]}function w(t,e){if(void 0!==e){const s=e-1,n=t.atoms,i=t.bonds,r=t.meta;n.atomTypes.splice(s,1),n.x=b(Float32Array,n.x,s,1),n.y=b(Float32Array,n.y,s,1),n.kwargs.splice(s,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 o=0;for(;o<i.atomPairs.length;){const t=i.atomPairs[o][0],s=i.atomPairs[o][1];t===e||s===e?(i.atomPairs.splice(o,1),i.bondTypes=b(Uint32Array,i.bondTypes,o,1),i.bondConfiguration.has(o)&&i.bondConfiguration.delete(o),i.kwargs.has(o)&&i.kwargs.delete(o),--o):(i.atomPairs[o][0]=t>e?t-1:t,i.atomPairs[o][1]=s>e?s-1:s),++o}let a=Array.from(i.bondConfiguration.keys());a.forEach((t=>{if(i.bondConfiguration.has(t)&&t>s){const e=i.bondConfiguration.get(t);i.bondConfiguration.delete(t),i.bondConfiguration.set(t-1,e)}})),a=Array.from(i.kwargs.keys()),a.forEach((t=>{if(i.kwargs.has(t)&&t>s){const e=i.kwargs.get(t);i.kwargs.delete(t),i.kwargs.set(t-1,e)}}))}}function b(t,e,s,n){const i=new t(e.length-n);let r=0,o=0;for(;r<e.length;)r===s&&(r+=n),i[o]=e[r],++o,++r;return i}function T(t,e){let s;if(0===t)s=e>0?0:Math.PI;else if(0===e)s=t>0?-Math.PI/2:Math.PI/2;else{const n=e/t,i=Math.atan(n);s=t<0?Math.PI/2+i:-Math.PI/2+i}return s}function C(t,e){if(0!==e){const s=t.x,n=t.y,i=Math.cos(e),r=Math.sin(e);for(let t=0;t<s.length;++t){const e=s[t];s[t]=u(e*i-n[t]*r),n[t]=u(e*r+n[t]*i)}}}function S(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 s=t.bonds.bondConfiguration;for(const[t,e]of s){const n=1===e?3:1;s.set(t,n)}}function A(t,e,s){const n=t.atoms.x,i=t.atoms.y;for(let t=0;t<n.length;++t)n[t]=u(n[t]+e),void 0!==s&&(i[t]=u(i[t]+s))}},6137:(t,e,s)=>{"use strict";s.d(e,{J:()=>i,V:()=>r});var n=s(9976);class i extends n.B{static get Chromatogram(){return void 0===this.chromatogram&&(this.chromatogram=new i({A:"green",C:"blue",G:"black",T:"red",U:"red",others:"gray"})),this.chromatogram}}class r{}r.SemType="Nucleotides",r.SemTypeMultipleAlignment="NucleotidesMultipleAlignment",r.Names={A:"Adenine",C:"Cytosine",G:"Guanine",T:"Thymine",U:"Uracil"}},9976:(t,e,s)=>{"use strict";s.d(e,{B:()=>n});class n{static makePalette(t,e=!1,s=n){const i={};return t.forEach((t=>{const s=t[0],n=t[1];s.forEach(((t,s)=>{i[t]=this.colourPalette[n][e?0:s]}))})),new s(i)}constructor(t){this._palette=t}get(t){return this._palette[t]}}n.undefinedColor="rgb(100,100,100)",n.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)"]}},7331:(t,e,s)=>{"use strict";s.d(e,{UE:()=>h,kQ:()=>o});var n=s(976),i=s(9976);class r{static hashCode(t){let e=0;if(0===t.length)return e;for(let s=0;s<t.length;s++)e=(e<<5)-e+t.charCodeAt(s),e|=0;return e}}class o{}class a extends o{get(t){return"#666666"}}class l extends o{static buildPalette(){return[].concat(...Object.values(i.B.colourPalette))}get(t){const e=r.hashCode(t)%l.palette.length;return function(t){if(null==t)return"rgb(100,100,100)";const e=n.Color.fromHtml(t),s=n.Color.g(e),i=n.Color.r(e),r=n.Color.b(e),o=Math.sqrt(Math.pow(0-i,2)+Math.pow(0-s,2)+Math.pow(0-r,2));return o>210?`rgb(${i/o*210},${s/o*210},${r/o*210})`:n.Color.toRgb(e)}(l.palette[e])}}l.palette=l.buildPalette();class h extends i.B{static get Gray(){return void 0===this.gray&&(this.gray=new a),this.gray}static get Color(){return void 0===this.color&&(this.color=new l),this.color}}},9611:(t,e,s)=>{"use strict";s.d(e,{A:()=>h});var n=s(4469),i=s(976),r=s(6414),o=s.n(r),a=s(8447);const l={DNA:"RNA",RNA:"RNA",PT:"PEPTIDE",UN:"PEPTIDE"};class h{get updated(){return this._updated}constructor(t,e,s){this.grid=t,this.col=e,this.propsProvider=s,this._monomerLengthList=null,this.separatorWidth=5,this._updated=!1,this._monomerLengthMap={},this._monomerStructureMap={},this.subs=[],this._splitter=(0,a.Mj)(this.col),this.props=this.propsProvider(),this._rowsProcessed=i.BitSet.create(this.col.length),this.grid&&(this.subs.push(e.dataFrame.onDataChanged.subscribe((()=>{this.props=this.propsProvider(),this._monomerLengthList=null,this._rowsProcessed=i.BitSet.create(this.col.length)}))),this.subs.push(n.events.onViewRemoved.subscribe((t=>{this.grid?.view?.id===t.id&&this.destroy()}))))}destroy(){for(const t of this.subs)t.unsubscribe()}getCellMonomerLengths(t){const e=this.props.unitsHandler.isMsa()?this.getCellMonomerLengthsForSeqMsa():this.getCellMonomerLengthsForSeq(t),s=new Array(e.length+1);s[0]=5;for(let t=1;t<s.length;t++)s[t]=s[t-1]+e[t-1];return[e,s]}getCellMonomerLengthsForSeq(t){null===this._monomerLengthList&&(this._monomerLengthList=new Array(this.col.length).fill(null),this._updated=!0);let e=this._monomerLengthList[t];if(null===e){const s=this.getSeqMonList(t);e=this._monomerLengthList[t]=new Array(s.length);for(const[t,n]of o().enumerate(s)){const s=this.props.monomerToShort(t,this.props.monomerLengthLimit),i=(this.props.unitsHandler.isSeparator()?this.separatorWidth:this.props.separatorWidth)+s.length*this.props.monomerCharWidth;e[n]=i}this._updated=!0}return e}getCellMonomerLengthsForSeqMsa(){var t;null===this._monomerLengthList&&(this._monomerLengthList=new Array(1).fill(null),this._updated=!0),(t=this._monomerLengthList)[0]??(t[0]=new Array(0));const e=this._monomerLengthList[0],s=Math.max(Math.floor((this.grid?.vertScroll.min??0)-10),0),n=Math.min(Math.ceil((this.grid?.vertScroll.max??0)+10),this.col.length);for(let t=s;t<n;t++){if(this._rowsProcessed.get(t))continue;const s=this.getSeqMonList(t);s.length>e.length&&e.push(...new Array(s.length-e.length).fill(0));for(const[t,n]of o().enumerate(s)){const s=this.props.monomerToShort(t,this.props.monomerLengthLimit),i=this.props.separatorWidth+s.length*this.props.monomerCharWidth;e[n]=Math.max(e[n]??0,i)}this._updated=!0}return e}getPosition(t,e){const[s,n]=this.getCellMonomerLengths(t),i=this.col.get(t),r=o()(this._splitter(i)).toArray();if(0===r.length)return null;let a=100,l=null,h=r.length,c=!1,u=0;if(n[0]<=e&&e<n.slice(-1)[0])for(;!c;)if(u=Math.floor((h+(l??0))/2),e>=n[u]&&e<=n[u+1]?(l=u,c=!0):e<n[u]?h=u-1:e>n[u+1]&&(l=u+1),l==h&&(c=!0),--a<=0)throw new Error(`Get position for pointer x = ${e} searching has not converged on ${JSON.stringify(n)}. `);return l}getSeqMonList(t){const e=this.col.get(t);return e?o()(this._splitter(e)).toArray():[]}getMonomer(t){const e=this.props.unitsHandler.alphabet??"UN",s=l[e];return this.props.monomerLib?.getMonomer(s,t)??null}setMonomerLengthLimit(t){this.props.monomerLengthLimit=t,this._updated=!0}setSeparatorWidth(t){this.props.separatorWidth=t,this._updated=!0}isMsa(){return this.props.unitsHandler.isMsa()}}},1047:(t,e,s)=>{"use strict";s.d(e,{At:()=>i,Ei:()=>o,K4:()=>a,pn:()=>r,rx:()=>n,zh:()=>l});const n=["symbol","molfile","rgroups","name"],i="MonomerName",r={symbol:"Short Name",name:"Medium Name",smiles:"SMILES"},o=[{capGroupSmiles:"[*:1][H]",alternateId:"R1-H",capGroupName:"H",label:"R1"},{capGroupSmiles:"O[*:2]",alternateId:"R2-OH",capGroupName:"OH",label:"R2"}],a={monomerType:null,smiles:null,name:"MonomerName",author:null,molfile:"molecule",naturalAnalog:"MonomerNaturalAnalogCode",rgroups:"MonomerCaps",createDate:null,id:null,polymerType:"MonomerType",symbol:"MonomerCode"},l={monomerType:"Backbone",smiles:"",name:"",author:"Datagrok",molfile:"",naturalAnalog:"",rgroups:[],createDate:null,id:0,polymerType:"PEPTIDE",symbol:""}},5226:(t,e,s)=>{"use strict";s.d(e,{i:()=>o});var n=s(976),i=s(499),r=s(1821);class o{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,s=0;for(;e=t.exec(this._fileContent);){const n=this._fileContent.substring(e.index+1,t.lastIndex);this._descriptionsArray.push(n),0!==s&&this._sequencesArray.push(this.parseMacromolecule(s,e.index)),s=t.lastIndex+1}this._sequencesArray.push(this.parseMacromolecule(s,-1))}importFasta(){const t=n.Column.fromStrings("description",this.descriptionsArray),e=n.Column.fromStrings("sequence",this.sequencesArray);return e.semType=n.SEMTYPE.MACROMOLECULE,e.setTag(n.TAGS.UNITS,r.r2.FASTA),i.Cn.getOrCreate(e),[n.DataFrame.fromColumns([t,e])]}constructor(t){this._descriptionsArray=[],this._sequencesArray=[],this._fileContent=t,this.parseColumns()}}},1821:(t,e,s)=>{"use strict";s.d(e,{BM:()=>o,CI:()=>r,XS:()=>l,r2:()=>n,se:()=>a});var n,i=s(6286);!function(t){t.FASTA="fasta",t.SEPARATOR="separator",t.HELM="helm"}(n||(n={}));const r=", ",o=/(?:\[([A-Za-z0-9_\-,()]+)\])|([A-Za-z\-])/g,a=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"])}}},l=[new i.L("PT",a.fasta.peptide,.5),new i.L("DNA",a.fasta.dna,.55),new i.L("RNA",a.fasta.rna,.55)]},8447:(t,e,s)=>{"use strict";s.d(e,{CI:()=>n.CI,GU:()=>i.GU,KX:()=>i.KX,Mj:()=>i.Mj,XS:()=>n.XS,dQ:()=>i.dQ,gM:()=>i.gM,gP:()=>i.gP,kB:()=>i.kB,py:()=>i.py,r2:()=>n.r2,up:()=>i.up});var n=s(1821),i=s(585)},6286:(t,e,s)=>{"use strict";s.d(e,{L:()=>n,d:()=>i});class n{constructor(t,e,s){this.name=t,this.alphabet=e,this.cutoff=s}}class i extends n{constructor(t,e,s){super(t.name,t.alphabet,t.cutoff),this.freq=e,this.similarity=s}}},585:(t,e,s)=>{"use strict";s.d(e,{Ar:()=>y,FJ:()=>p,GU:()=>v,KX:()=>M,Mj:()=>S,dQ:()=>_,gM:()=>E,gP:()=>T,jY:()=>g,kB:()=>f,py:()=>P,up:()=>L,vU:()=>C,w4:()=>N});var n=s(976),i=s(6414),r=s.n(i),o=s(6286),a=s(1821),l=s(499),h=s(3659),c=s(850),u=s(2012),m=s(6137),d=s(7331);function g(t,e,s){return t.categories,function(t,e){const s={};let n=!0,i=null;for(const r of t)if(null==i?i=r.length:r.length!==i&&(n=!1),r.length>=e)for(const t of r)t in s||(s[t]=0),s[t]+=1;return{freq:s,sameLength:n}}(r()(t.getRawData()).map((e=>s(t.categories[e]))),e)}function f(t){return r()(t.toString().matchAll(a.BM)).map((t=>t[2]??t[1])).toArray()}function p(t){return t||[]}function y(t,e=undefined){return s=>s?s.split(t,e):[]}const w=/(PEPTIDE1|DNA1|RNA1)\{([^}]+)}/g,b=/\[([^\[\]]+)]/g;function T(t){w.lastIndex=0;const e=w.exec(t.toString()),s=e?e[2]:null;return(s?s.split("."):[]).map((t=>{b.lastIndex=0;const e=b.exec(t);return e&&e.length>=2?e[1]:t}))}function C(t,e,s=undefined){if(t.toLowerCase().startsWith(a.r2.FASTA))return f;if(t.toLowerCase().startsWith(a.r2.SEPARATOR))return y(e,s);if(t.toLowerCase().startsWith(a.r2.HELM))return T;throw new Error(`Unexpected units ${t} .`)}function S(t){return l.Cn.getOrCreate(t).getSplitter()}const A=/([^\W_]+)/g;function v(t,e){if(t.length<=e)return t;const s=t.match(A),n=t.length>e||(s?.length??0)>1,i=s?.[0]??" ";return n?i.substring(0,e-1)+"…":i}function E(t){switch(t){case"DNA":return a.se.fasta.dna;case"RNA":return a.se.fasta.rna;case"PT":return a.se.fasta.peptide;default:throw new Error(`Unsupported alphabet '${t}'.`)}}function M(t,e,s="-"){const n=new Set([...new Set(Object.keys(t)),...e]);n.delete(s);const i=[],r=[];for(const s of n)i.push(s in t?t[s]:0),r.push(e.has(s)?1:0);const o=new h.OW(i),a=new h.OW(r);return(0,c.MA)(o,a)/((0,c.$G)(o)*(0,c.$G)(a))}function N(t,e,s="-"){const n=e.map((e=>{const n=M(t,e.alphabet,s);return new o.d(e,t,n)}));let i;const r=Math.max(...n.map((t=>t.similarity>t.cutoff?t.similarity:-1)));return i=r>0?n.find((t=>t.similarity===r)).name:"UN",i}function _(t,e=5){let s;return s=t.semType==n.SEMTYPE.MACROMOLECULE?l.Cn.getOrCreate(t).alphabet:N(g(t,e,f).freq,a.XS),P(s)}function P(t){switch(t){case"PT":return u.f.GrokGroups;case"DNA":case"RNA":return m.J.Chromatogram;default:return d.UE.Color}}function L(t){const e=t.columns.bySemTypeAll(n.SEMTYPE.MACROMOLECULE);let s=e.find((t=>{const e=t.getTag(n.TAGS.UNITS);return!!e&&-1!==e.indexOf("MSA")}))??null;return!s&&e.length>0&&(s=e[0]),s}},8457:(t,e,s)=>{"use strict";s.d(e,{O:()=>a});var n=s(976),i=s(6414),r=s.n(i),o=s(585);function a(t){const e=(0,o.Mj)(t),s=t=>{const e=l.columns.addNewString((t+1).toString());return i.push(e),e},i=[],a=t.length,l=n.DataFrame.create(a);for(let n=0;n<a;++n){const o=t.get(n);if(null==o)continue;const a=e(o);for(const[t,e]of r().enumerate(a))((i[e]??null)||s(e)).set(n,t||"-",!1)}return l}},499:(t,e,s)=>{"use strict";s.d(e,{Cn:()=>m,_9:()=>u});var n=s(976),i=s(6414),r=s.n(i),o=s(8447),a=s(585),l=s(489),h=s(7228);const c=new class{constructor(){this.uhTemp=`units-handler.${n.SEMTYPE.MACROMOLECULE}`}},u={[o.r2.FASTA]:"-",[o.r2.SEPARATOR]:"",[o.r2.HELM]:"*"};class m{static setUnitsToFastaColumn(t){if(t.column.semType!==n.SEMTYPE.MACROMOLECULE||t.column.getTag(n.TAGS.UNITS)!==o.r2.FASTA)throw new Error(`The column of notation '${o.r2.FASTA}' must be '${n.SEMTYPE.MACROMOLECULE}'.`);t.column.setTag(n.TAGS.UNITS,o.r2.FASTA),m.setTags(t)}static setUnitsToSeparatorColumn(t,e){if(t.column.semType!==n.SEMTYPE.MACROMOLECULE||t.column.getTag(n.TAGS.UNITS)!==o.r2.SEPARATOR)throw new Error(`The column of notation '${o.r2.SEPARATOR}' must be '${n.SEMTYPE.MACROMOLECULE}'.`);if(!e)throw new Error(`The column of notation '${o.r2.SEPARATOR}' must have the separator tag.`);t.column.setTag(n.TAGS.UNITS,o.r2.SEPARATOR),t.column.setTag("separator",e),m.setTags(t)}static setUnitsToHelmColumn(t){if(t.column.semType!==n.SEMTYPE.MACROMOLECULE)throw new Error(`The column of notation '${o.r2.HELM}' must be '${n.SEMTYPE.MACROMOLECULE}'`);t.column.setTag(n.TAGS.UNITS,o.r2.HELM),m.setTags(t)}static setTags(t){const e=t.column.getTag(n.TAGS.UNITS),s=t.stats;if(Object.keys(s.freq).some((t=>t.length>1)),[o.r2.FASTA,o.r2.SEPARATOR].includes(e)){if(0===Object.keys(s.freq).length)throw new Error("Alphabet is empty");let e=t.column.getTag("aligned");null===e&&(e=s.sameLength?"SEQ.MSA":"SEQ",t.column.setTag("aligned",e));let n=t.column.getTag("alphabet");if(null===n&&(n=(0,a.w4)(s.freq,o.XS),t.column.setTag("alphabet",n)),"UN"===n){const e=Object.keys(s.freq).length,n=Object.keys(s.freq).some((t=>t.length>1));t.column.setTag(".alphabetSize",e.toString()),t.column.setTag(".alphabetIsMultichar",n?"true":"false")}}}get column(){return this._column}get units(){return this._units}get notation(){return this._notation}get defaultGapSymbol(){return this._defaultGapSymbol}get separator(){const t=this.column.getTag("separator")??void 0;if(this.notation===o.r2.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("aligned");if(!t&&(this.isFasta()||this.isSeparator()))throw new Error("Tag aligned not set");return t}get alphabet(){const t=this.column.getTag("alphabet");if(!t&&(this.isFasta()||this.isSeparator()))throw new Error("Tag alphabet not set");return t}get helmCompatible(){return this.column.getTag(".isHelmCompatible")}getAlphabetSize(){if(this.notation==o.r2.HELM||"UN"==this.alphabet){const t=this.column.getTag(".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"PT":return 20;case"DNA":case"RNA":return 4;case"NT":return console.warn("Unexpected alphabet 'NT'."),4;default:throw new Error(`Unexpected alphabet '${this.alphabet}'.`)}}getAlphabetIsMultichar(){return this.notation===o.r2.HELM||"UN"===this.alphabet&&"true"===this.column.getTag(".alphabetIsMultichar")}get splitted(){if(null===this._splitted){const t=this.getSplitter(),e=this._column.length;this._splitted=new Array(e);const s=this._column.getRawData(),n=this._column.categories;for(let i=0;i<e;i++){const e=n[s[i]];this._splitted[i]=t(e)}}return this._splitted}get stats(){if(null===this._stats){const t={};let e=!0,s=null;for(const n of this.splitted){null==s?s=n.length:n.length!==s&&(e=!1);for(const e of n)e in t||(t[e]=0),t[e]+=1}this._stats={freq:t,sameLength:e}}return this._stats}get maxLength(){return null===this._maxLength&&(this._maxLength=Math.max(...this.splitted.map((t=>t.length)))),this._maxLength}get posList(){if(null===this._posList){const t=this.column.getTag(".positionNames");this._posList=t?t.split(o.CI).map((t=>t.trim())):r().count(1).take(this.maxLength).map((t=>t.toString())).toArray()}return this._posList}isFasta(){return this.notation===o.r2.FASTA}isSeparator(){return this.notation===o.r2.SEPARATOR}isHelm(){return this.notation===o.r2.HELM}isRna(){return"RNA"===this.alphabet}isDna(){return"DNA"===this.alphabet}isPeptide(){return"PT"===this.alphabet}isMsa(){return!!this.aligned&&this.aligned.toUpperCase().includes("MSA")}isHelmCompatible(){return"true"===this.helmCompatible}isGap(t){return!t||this.units===o.r2.FASTA&&t===u[o.r2.FASTA]||this.units===o.r2.HELM&&t===u[o.r2.HELM]}getNotation(){if(this.units.toLowerCase().startsWith(o.r2.FASTA))return o.r2.FASTA;if(this.units.toLowerCase().startsWith(o.r2.SEPARATOR))return o.r2.SEPARATOR;if(this.units.toLowerCase().startsWith(o.r2.HELM))return o.r2.HELM;throw new Error(`Column '${this.column.name}' has unexpected notation '${this.units}'.`)}getHelmWrappers(){return[this.isDna()?"DNA1{":this.isRna()||this.isHelmCompatible()?"RNA1{":"PEPTIDE1{",this.isDna()?"D(":this.isRna()?"R(":"",this.isDna()||this.isRna()?")P":"","}$$$$"]}getNewColumn(t,e){const s=this.column,i=s.length,r=t.toLowerCase()+"("+s.name+")",a=s.dataFrame.columns.getUnusedName(r),l=n.Column.fromList("string",a,new Array(i).fill(""));if(l.semType=n.SEMTYPE.MACROMOLECULE,l.setTag(n.TAGS.UNITS,t),t===o.r2.SEPARATOR){if(!e)throw new Error(`Notation '${o.r2.SEPARATOR}' requires separator value.`);l.setTag("separator",e)}l.setTag(n.TAGS.CELL_RENDERER,"Macromolecule");const h=s.getTag("aligned");h&&l.setTag("aligned",h);const c=s.getTag("alphabet");null!=c&&l.setTag("alphabet",c);let u=s.getTag(".alphabetSize");null!=c&&u&&l.setTag(".alphabetSize",u);const m=s.getTag(".alphabetIsMultichar");return null!=c&&void 0!==m&&l.setTag(".alphabetIsMultichar",m),t==o.r2.HELM&&(u=this.getAlphabetSize().toString(),l.setTag(".alphabetSize",u)),l}static getNewColumn(t){const e=m.getOrCreate(t),s=e.notation;return e.getNewColumn(s)}static unitsStringIsValid(t){return t=t.toLowerCase(),[o.r2.FASTA,o.r2.SEPARATOR,o.r2.HELM].some((e=>t.startsWith(e.toLowerCase())))}static getNewColumnFromParams(t,e,s){if(!m.unitsStringIsValid(s))throw new Error("Invalid format of 'units' parameter");const i=n.Column.fromList("string",e,new Array(t).fill(""));return i.semType=n.SEMTYPE.MACROMOLECULE,i.setTag(n.TAGS.UNITS,s),i}getSplitter(t){if(this.units.toLowerCase().startsWith(o.r2.FASTA))return null===this.column.getTag("alphabet")||this.getAlphabetIsMultichar()?a.kB:a.FJ;if(this.units.toLowerCase().startsWith(o.r2.SEPARATOR))return(0,a.Ar)(this.separator,t);if(this.units.toLowerCase().startsWith(o.r2.HELM))return a.gP;throw new Error(`Unexpected units ${this.units} .`)}getDistanceFunctionName(){if(!this.isFasta())throw new Error("Only FASTA notation is supported");return this.isMsa()?l.U.HAMMING:(this.alphabet,l.U.LEVENSHTEIN)}getDistanceFunction(){return l.o[this.getDistanceFunctionName()]()}async checkHelmCompatibility(){if(this.column.tags.has(".isHelmCompatible"))return"true"===this.column.getTag(".isHelmCompatible");const t=(await(0,h.JN)()).getBioLib().getMonomerSymbolsByType("PEPTIDE".toString()),e=new Set(t),s=(0,a.Ar)(this.separator);for(const t of this.column.categories){const n=s(t);for(const t of n)if(!e.has(t))return this.column.setTag(".isHelmCompatible","false"),!1}return this.column.setTag(".isHelmCompatible","true"),!0}get splitter(){return null===this._splitter&&(this._splitter=(0,a.Mj)(this.column)),this._splitter}toFasta(t){return t===o.r2.FASTA}toSeparator(t){return t===o.r2.SEPARATOR}toHelm(t){return t===o.r2.HELM}convertHelmToFastaSeparator(t,e,s,n){n||(n=this.toFasta(e)?u[o.r2.FASTA]:u[o.r2.SEPARATOR]),s||(s=this.toFasta(e)?"":this.separator);const i=/(R\(|D\(|\)|P)/g,r=t.startsWith("DNA")||t.startsWith("RNA"),a=this.splitter(t),l=[];for(let t=0;t<a.length;t++){let s=a[t];if(r&&(s=s.replace(i,"")),s===u[o.r2.HELM])l.push(n);else if(this.toFasta(e)&&s.length>1){const t="["+s+"]";l.push(t)}else l.push(s)}return l.join(s)}convert(t,e){const s=this.getConverter(t,e),n=this.getNewColumn(t,e);return n.init((t=>s(this.column.get(t)))),n}getRegion(t,e,s){const n=this.getNewColumn(this.notation,this.separator);n.name=s,Math.max(...this.splitted.map((t=>t.length)));const i=t??0,r=e??this.maxLength-1,a=this.getJoiner(),l=r-i+1;n.init((t=>{const e=this.splitted[t],s=new Array(l);for(let t=0;t<l;++t){const n=i+t;s[t]=n<e.length?e[n]:u[this.notation]}return a(s)}));const h=t=>{const e=t.split(",").map((t=>t.trim())),s=new Array(l);for(let t=0;t<l;++t){const n=i+t;s[t]=n<e.length?e[n]:"?"}return s.join(o.CI)},c=this.column.getTag(".positionNames");c&&n.setTag(".positionNames",h(c));const m=this.column.getTag(".positionLabels");return m&&n.setTag(".positionLabels",h(m)),n}getJoiner(){const t=this;if(this.notation===o.r2.FASTA)return function(e){return g(t,e)};if(this.notation===o.r2.SEPARATOR)return function(e){return f(t,e,t.separator)};if(this.notation===o.r2.HELM){const e="DNA"===t.alphabet||"RNA"===t.alphabet;return function(s){return p(t,s,e)}}throw new Error}getConverter(t,e=undefined){if(t===o.r2.SEPARATOR&&!e)throw new Error(`Target separator is not specified for target units '${o.r2.SEPARATOR}'.`);const s=this;if(t===o.r2.FASTA)return function(t){return function(t,e){const s=t.isHelm()?y(t,e):t.getSplitter()(e);return g(t,s)}(s,t)};if(t===o.r2.HELM)return function(t){return function(t,e){const s=e.startsWith("DNA")||e.startsWith("RNA"),n=t.getSplitter()(e);return p(t,n,s)}(s,t)};if(t===o.r2.SEPARATOR)return function(t){return function(t,e,s){const n=t.isHelm()?y(t,e):t.getSplitter()(e);return f(t,n,s)}(s,t,e)};throw new Error}constructor(t){if(this._splitter=null,this._splitted=null,this._stats=null,this._maxLength=null,this._posList=null,t.type!=n.TYPE.STRING)throw new Error(`Unexpected column type '${t.type}', must be '${n.TYPE.STRING}'.`);this._column=t;const e=this._column.getTag(n.TAGS.UNITS);if(null==e)throw new Error("Units are not specified in column");if(this._units=e,this._notation=this.getNotation(),this._defaultGapSymbol=this.isFasta()?u[o.r2.FASTA]:this.isHelm()?u[o.r2.HELM]:u[o.r2.SEPARATOR],!this.column.tags.has("aligned")||!this.column.tags.has("alphabet")||!this.column.tags.has(".alphabetIsMultichar")&&!this.isHelm()&&"UN"===this.alphabet)if(this.isFasta())m.setUnitsToFastaColumn(this);else if(this.isSeparator()){const e=t.getTag("separator");m.setUnitsToSeparatorColumn(this,e)}else{if(!this.isHelm())throw new Error(`Unexpected units '${this.column.getTag(n.TAGS.UNITS)}'.`);m.setUnitsToHelmColumn(this)}if(!this.column.tags.has(".alphabetIsMultichar"))if(this.isHelm())this.column.setTag(".alphabetIsMultichar","true");else if(["UN"].includes(this.alphabet))throw new Error(`For column '${this.column.name}' of alphabet '${this.alphabet}' tag '.alphabetIsMultichar' is mandatory.`)}static getOrCreate(t){return c.uhTemp in t.temp||(t.temp[c.uhTemp]=new m(t)),t.temp[c.uhTemp]}}const d=/[RD]\((\w)\)P?/g;function g(t,e){const s=new Array(e.length);for(const[n,i]of r().enumerate(e)){let r=n;t.isHelm()&&(r=n.replace(d,"$1")),t.isGap(r)?r=u[o.r2.FASTA]:r.length>1&&(r="["+e[i]+"]"),s[i]=r}return s.join("")}function f(t,e,s){const n=new Array(e.length);for(const[s,i]of r().enumerate(e)){let e=s;t.isGap(e)&&(e=u[o.r2.SEPARATOR]),n[i]=e}return n.map((t=>t??"")).join(s)}function p(t,e,s){const[n,i,a,l]=t.getHelmWrappers();return`${n}${r()(e).map((e=>{let n=e;return n=t.isGap(n)?u[o.r2.HELM]:s?n.replace(d,"$1"):1==e.length?`${i}${e}${a}`:`${i}[${e}]${a}`,n})).toArray().join(".")}${l}`}function y(t,e){const s=t.getSplitter()(e),n=new Array(s.length),i=e.startsWith("DNA"),o=e.startsWith("RNA");for(const[t,e]of r().enumerate(s)){let s=t;(i||o)&&(s=s.replace(d,"$1"),s="P"===s?null:s),n[e]=s}return n.filter((t=>null!==t))}},9298:(t,e,s)=>{"use strict";var n,i,r,o,a,l;s.d(e,{Ct:()=>l,DX:()=>n,ES:()=>i,dE:()=>a,iD:()=>o,vS:()=>h,vw:()=>r}),function(t){t.tooltipWebLogo=".tooltipWebLogo"}(n||(n={})),function(t){t.Entropy="Entropy",t.full="100%"}(i||(i={})),function(t){t.TOP="top",t.MIDDLE="middle",t.BOTTOM="bottom"}(r||(r={})),function(t){t.LEFT="left",t.CENTER="center",t.RIGHT="right"}(o||(o={})),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.startPositionName=null,this.endPositionName=null,this.skipEmptySequences=!0,this.skipEmptyPositions=!1,this.shrinkEmptyTail=!0,this.backgroundColor=4294967295,this.positionHeight=i.Entropy,this.positionWidth=16,this.verticalAlignment=r.MIDDLE,this.horizontalAlignment=o.CENTER,this.fixWidth=!1,this.fitArea=!0,this.minHeight=50,this.maxHeight=100,this.showPositionLabels=!0,this.positionMarginState=a.AUTO,this.positionMargin=0,this.filterSource=l.Filtered}}},2669:(t,e,s)=>{"use strict";s.d(e,{m:()=>n});class n{constructor(t=!0,e=!0){const n=navigator.hardwareConcurrency;this._workerCount=t?Math.max(n-2,1):1,this._workers=new Array(this._workerCount).fill(null).map((()=>new Worker(new URL(s.p+s.u(868),s.b)))),this._terminateOnComplete=e}async calc(t,e,s=!0){return new Promise((async(n,i)=>{try{const i=t.length,r=new Array(this._workerCount),o=i*(i-1)/2;this._workerCount=Math.min(this._workerCount,o);const a=o/this._workerCount,l=new Float32Array(o);let h=0,c=1,u=0,m=Number.MIN_VALUE;for(let s=0;s<this._workerCount;s++){const n=Math.floor(s*a),d=s===this._workerCount-1?o:Math.floor((s+1)*a),g=h,f=c;s!==this._workerCount-1&&(h=i-2-Math.floor(Math.sqrt(-8*d+4*i*(i-1)-7)/2-.5),c=d-i*h+Math.floor((h+1)*(h+2)/2)),this._workers[s].postMessage({values:t,fnName:e,startRow:g,startCol:f,chunckSize:d-n}),r[s]=new Promise(((t,e)=>{this._workers[s].onmessage=({data:{error:i,distanceMatrixData:r,min:o,max:a}})=>{this._terminateOnComplete&&this._workers[s].terminate(),i?e(i):(l.set(r,n),o<u&&(u=o),a>m&&(m=a),t())}}))}await Promise.all(r),s&&l.forEach(((t,e)=>{l[e]=(t-u)/(m-u)})),n(l)}catch(t){i(t)}}))}terminate(){this._workers.forEach((t=>t.terminate()))}}},3914:(t,e,s)=>{"use strict";s.d(e,{H:()=>i});var n=s(6814);class i{get data(){return this._data}get size(){return this._size}constructor(t,e){if(null==e){if(null==t)throw new Error("Arguments error: data or size is required.");if(this._data=t,this._size=(1+Math.sqrt(1+8*this._data.length))/2,this._size!=Math.floor(this._size))throw new Error(`Invalid data length ${this._data.length} leads to non integer size ${this._size}`)}else{this._size=e;const s=e*(e-1)/2;if(t){if(t.length!=s)throw new Error(`Invalid data length. Observations size ${e} requires data length ${s}.`);this._data=t}else this._data=new Float32Array(s)}}_linearizeIJ(t,e){if(!(t<e))throw new Error("i must be less than j");return this._size*t+e-Math.floor((t+2)*(t+1)/2)}get(t,e){return t==e?0:t<e?this._data[this._linearizeIJ(t,e)]:this._data[this._linearizeIJ(e,t)]}set(t,e,s){this._data[this._linearizeIJ(t,e)]=s}static calc(t,e){const s=t.length,r=new i(void 0,s);for(let i=0;i<s;i++)for(let o=i+1;o<s;o++)r.set(i,o,(0,n.k)(t[i])||(0,n.k)(t[o])?1:e(t[i],t[o]));return r}square(){for(let t=0;t<this._data.length;t++)this._data[t]=this._data[t]**2}add(t){if(this._size!==t._size)throw new Error(`Matrices must have the same size. This size: ${this._size}, other size: ${t._size}`);for(let e=0;e<this._data.length;e++)this._data[e]+=t._data[e]}sqrt(){for(let t=0;t<this._data.length;t++)this._data[t]=Math.sqrt(this._data[t])}normalize(){let t=0,e=this._data[0];for(let s=0;s<this._data.length;s++)this._data[s]<t&&(t=this._data[s]),this._data[s]>e&&(e=this._data[s]);const s=e-t;for(let n=0;n<this._data.length;n++)this._data[n]=0===s?this._data[n]-t:(this._data[n]-t)/(e-t)}}},6254:(t,e,s)=>{"use strict";function n(t,e){const s=i(e);function n(t,e){const n=Number(t),i=Number(e);return s(n,i)}const r={get:(t,s,i)=>"length"===s?e:new Proxy(t,function(t){return{get:(e,s,i)=>t===s?0:e[Number(t)>Number(s)?n(s,t):n(t,s)]}}(s))};return new Proxy(t,r)}function i(t){return(e,s)=>t*e+s-Math.floor((e+2)*(e+1)/2)}s.d(e,{_:()=>n,y:()=>i})},2590:(t,e,s)=>{"use strict";s.d(e,{_:()=>n});class n{constructor(){this._workerCount=Math.max(navigator.hardwareConcurrency-2,1),this._workers=new Array(this._workerCount).fill(null).map((()=>new Worker(new URL(s.p+s.u(381),s.b))))}async calc(t,e,s){const n=t.length*(t.length-1)/2,i=Math.floor(n/this._workerCount),r=new Array(this._workerCount);for(let o=0;o<this._workerCount;o++)r[o]=new Promise(((r,a)=>{const l=o*i,h=o===this._workerCount-1?n:(o+1)*i;this._workers[o].postMessage({values:t,startIdx:l,endIdx:h,threshold:s,fnName:e}),this._workers[o].onmessage=({data:{error:t,i:e,j:s,distance:n}})=>{t?a(t):(this._workers[o].terminate(),r({i:e,j:s,distance:n,idx:o}))}}));const o=await Promise.all(r),a=o.reduce(((t,e)=>t+e.i.length),0),l=new Int32Array(a),h=new Int32Array(a),c=new Float32Array(a);let u=0;for(const t of o)l.set(t.i,u),h.set(t.j,u),c.set(t.distance,u),u+=t.i.length;return{i:l,j:h,distance:c}}}},6814:(t,e,s)=>{"use strict";s.d(e,{k:()=>n});const n=t=>null==t},5697:(t,e,s)=>{"use strict";s.d(e,{Dz:()=>y,FV:()=>l,KR:()=>a,MI:()=>b,NB:()=>d,Om:()=>T,UX:()=>m,WI:()=>u,Zd:()=>c,_h:()=>h,aW:()=>f,bX:()=>S,fX:()=>w,kg:()=>r,s:()=>g,yU:()=>p});var n=s(9657),i=s(1040);i.gk.Tanimoto,i.gk.Dice,i.gk.Asymmetric,i.gk.BraunBlanquet,i.gk.Cosine,i.gk.Kulczynski,i.gk.McConnaughey,i.gk.RogotGoldberg,i.gk.Russel,i.gk.Sokal,i.gk.Hamming,i.gk.Euclidean,i.gk.Tanimoto,i.gk.Dice,i.gk.Asymmetric,i.gk.BraunBlanquet,i.gk.Cosine,i.gk.Kulczynski,i.gk.McConnaughey,i.gk.RogotGoldberg,i.gk.Russel,i.gk.Sokal,i.gk.Hamming,i.gk.Euclidean;const r=[i.gk.Tanimoto,i.gk.Dice,i.gk.Cosine];function o(t,e){const s=t.trueCount()+e.trueCount();if(0==s)return 1;const n=t.andWithCountBits(e,!0);return n/(s-n)}function a(t,e){return C(o(t,e))}function l(t,e){return C(o(new n.Z(t,32*t.length),new n.Z(e,32*e.length)))}function h(t,e){return C(function(t,e){const s=t.trueCount()+e.trueCount();return 0==s?0:2*t.andWithCountBits(e,!0)/s}(t,e))}function c(t,e){return C(function(t,e){const s=t.trueCount()*e.trueCount();return 0==s?0:t.andWithCountBits(e,!0)/Math.sqrt(s)}(t,e))}function u(t,e){return Math.sqrt(t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0))}function m(t,e){return t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0)}function d(t,e){return C(function(t,e){const s=t.trueCount()+e.trueCount(),n=t.andWithCountBits(e,!0);return n/(2*s-3*n)}(t,e))}function g(t,e){return C(function(t,e){const s=t.trueCount()+e.trueCount(),n=t.trueCount()*e.trueCount();return 0==n?0:t.andWithCountBits(e,!0)*s/(2*n)}(t,e))}function f(t,e){return C(function(t,e){const s=t.trueCount()+e.trueCount(),n=t.trueCount()*e.trueCount();return 0==n?0:(t.andWithCountBits(e,!0)*s-n)/n}(t,e))}function p(t,e){return C(function(t,e){const s=Math.min(t.trueCount(),e.trueCount());return 0==s?0:t.andWithCountBits(e,!0)/s}(t,e))}function y(t,e){return C(function(t,e){const s=Math.max(t.trueCount(),e.trueCount());return 0==s?0:t.andWithCountBits(e,!0)/s}(t,e))}function w(t,e){return C(function(t,e){return 0==t.length?0:t.andWithCountBits(e,!0)/t.length}(t,e))}function b(t,e){return C(function(t,e){const s=t.andWithCountBits(e,!0),n=t.countBits(!0)+e.countBits(!0),i=t.length,r=i-n+s;return s==i||r==i?1:s/n+r/(2*i-n)}(t,e))}function T(t){return 1/(1+t)}function C(t){return 0===t?3402823e32:1/t-1}function S(t,e){return Math.abs(t-e)}i.gk.Tanimoto,i.gk.Asymmetric,i.gk.Cosine,i.gk.Sokal},779:(t,e,s)=>{"use strict";function n(){return(t,e)=>{let s=0;t.length!==e.length&&(s=Math.abs(t.length-e.length));let n=0;for(let s=0;s<Math.min(t.length,e.length);s++)t[s]!==e[s]&&n++;return n+=s,n/=Math.max(t.length,e.length),n}}s.d(e,{j:()=>n})},489:(t,e,s)=>{"use strict";s.d(e,{U:()=>n.U,o:()=>n.o});var n=s(5540)},458:(t,e,s)=>{"use strict";s.d(e,{r:()=>i});var n=s(1811);function i(){return(t,e)=>(0,n.T)(t,e)/Math.max(t.length,e.length)}},5540:(t,e,s)=>{"use strict";s.d(e,{U:()=>n,o:()=>a});var n,i=s(779),r=s(458),o=s(6683);!function(t){t.HAMMING="Hamming",t.LEVENSHTEIN="Levenshtein",t.NEEDLEMANN_WUNSCH="Needlemann-Wunsch"}(n||(n={}));const a={[n.HAMMING]:i.j,[n.LEVENSHTEIN]:r.r,[n.NEEDLEMANN_WUNSCH]:o.n}},6683:(t,e,s)=>{"use strict";s.d(e,{n:()=>i});const n={gapOpen:8,gapExtend:2,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}};function i(t){return(e,s)=>{const{gapOpen:i,gapExtend:r,scoringMatrix:o,alphabetIndexes:a}={...n,...t},l=[new Array(e.length+1).fill(0),new Array(e.length+1).fill(0)],h=new Array(e.length+1).fill(!1),c=new Array(e.length+1).fill(!1);let u=0,m=1;for(let t=1;t<e.length+1;t++)l[0][t]=-i-(t-1)*r;for(let t=1;t<s.length+1;t++){l[m][0]=-i-(t-1)*r;for(let n=1;n<e.length+1;n++){const d=l[u][n-1]+o[a[e[n-1]]][a[s[t-1]]],g=l[u][n]-(h[n]?r:i),f=l[m][n-1]-(c[n-1]?r:i);l[m][n]=Math.max(d,f,g),l[m][n]===d?(h[n]=!1,c[n]=!1):l[m][n]===f?(h[n]=!1,c[n]=!0):(h[n]=!0,c[n]=!1)}u=m,m=(m+1)%2}const d=e.split("").map((t=>o[a[t]][a[t]])).reduce(((t,e)=>t+e),0),g=s.split("").map((t=>o[a[t]][a[t]])).reduce(((t,e)=>t+e),0),f=Math.max(d,g);return(f-l[u][e.length])/f}}},116:(t,e,s)=>{"use strict";var n;s.d(e,{AL:()=>n}),s(4221),s(7659),s(3659),s(850),s(9006),s(7861),s(9657),s(2669),s(3914),s(6254),s(2590),function(t){t.UMAP="UMAP",t.T_SNE="t-SNE"}(n||(n={}))},7656:(t,e,s)=>{"use strict";s.d(e,{I:()=>i});var n=s(850);async function i(t,e,i,r,o){const a=await async function(t,e,n,i){return new Promise((function(r,o){const a=new Worker(new URL(s.p+s.u(440),s.b));a.postMessage({columnData:t.data,method:e,measure:t.metric,options:n,parallelDistanceWorkers:i}),a.onmessage=({data:{error:t,distance:e,embedding:s}})=>{t?o(t):r({distance:e,embedding:s}),setTimeout((()=>a.terminate()),0)}}))}({data:t,metric:i},e,r,o);return a.embedding=a.embedding.map((t=>(0,n.Fv)(t))),a}},9006:(t,e,s)=>{"use strict";s.d(e,{Ek:()=>l,a1:()=>a,nR:()=>h});var n=s(850),i=s(4588),r=s(6254),o=s(2669);class a{constructor(t){this.steps=t?.steps??0,this.cycles=t?.cycles??1e6,this.cutoff=t?.cutoff??0,this.lambda=t?.lambda??2,this.dlambda=t?.dlambda??.01,this.lambda2=this.lambda/2,this.dlambda2=this.dlambda/2,this.epsilon=t?.epsilon??1e-10,this.distanceFunction=t?.distance??n.dP,this.distance=new Float32Array,this.distanceFunctionName=t?.distanceFunctionName}async initDistance(t){this.dmIndexFunct=(0,r.y)(t.length);const e=new o.m(!0,!1);this.distance=await e.calc(t,this.distanceFunctionName),e.terminate()}calcDistance(t,e,s){return this.distance[this.dmIndexFunct(e,s)]}async embed(t){const e=t.length,s=(0,n.kO)(e,a.dimension,40);let r=this.lambda2;0===this.steps&&(this.steps=t.length-1),await this.initDistance(t);for(let o=0;o<this.cycles;++o){for(let o=0;o<this.steps;++o){const o=(0,i.I)(e);let a=(0,i.I)(e);for(;o==a;)a=(0,i.I)(e);const l=s[o],h=s[a],c=this.calcDistance(t,o,a),u=(0,n.dP)(l,h);if(0==this.cutoff||c<=this.cutoff||u<c){const t=r*(c-u)/(u+this.epsilon),e=(0,n.On)(l,h,-1);s[o]=(0,n.On)(l,e,t),s[a]=(0,n.On)(h,e,-t)}}if(r-=this.dlambda2,r<=0)break}return s}}a.dimension=2;class l extends a{async embed(t){const e=t.length,s=(0,n.kO)(e,l.dimension,40);let r=this.lambda;await this.initDistance(t);for(let o=0;o<this.cycles;++o){const o=(0,i.I)(e),a=s[o];for(let i=0;i<e;++i){if(o==i)continue;const e=s[i],l=this.calcDistance(t,o,i),h=(0,n.dP)(a,e);if(0==this.cutoff||l<=this.cutoff||h<l){const t=r*(l-h)/(h+this.epsilon),o=(0,n.On)(a,e,-1);s[i]=(0,n.On)(e,o,-t)}}if(r-=this.dlambda,r<=0)break}return s}}class h extends a{constructor(t){super(t),this.cycles=t?.cycles??1e3,this.steps=t?.steps??1e5,this.radiusPercent=t?.radiusPercent??1,this.maxDistance=t?.maxDistance??null,this.maxDistanceSteps=t?.maxDistanceSteps??null}async embed(t){const e=t.length,s=(0,n.kO)(e,h.dimension,40);if(await this.initDistance(t),null===this.maxDistanceSteps&&(this.maxDistanceSteps=e*Math.floor((e-1)/2)),null===this.maxDistance){this.maxDistance=-1e37;for(let s=0;s<this.maxDistanceSteps;s++){const s=(0,i.I)(e);let n=(0,i.I)(e);for(;s==n;)n=(0,i.I)(e);const r=this.calcDistance(t,s,n);r>this.maxDistance&&(this.maxDistance=r)}}let r=this.lambda;const o=0==this.radiusPercent?this.maxDistance:this.maxDistance*this.radiusPercent;for(let a=0;a<this.cycles;++a){for(let a=0;a<this.steps;++a){const a=(0,i.I)(e);let l=(0,i.I)(e);for(;a==l;)l=(0,i.I)(e);const h=s[a],c=s[l],u=this.calcDistance(t,a,l),m=(0,n.dP)(h,c);if(u<=o||m<u){const t=.5*r*(u-m)/(m+this.epsilon),e=(0,n.On)(h,c,-1);s[a]=(0,n.On)(h,e,t),s[l]=(0,n.On)(c,e,-t)}}if(r-=(this.lambda-this.dlambda)/(this.cycles-1),r<this.dlambda)break}return s}}},1040:(t,e,s)=>{"use strict";var n,i,r,o,a,l;s.d(e,{CF:()=>i,Qe:()=>a,W:()=>n,Yc:()=>l,gd:()=>o,gk:()=>r}),function(t){t.Levenshtein="Levenshtein",t.JaroWinkler="Jaro-Winkler",t.Manhattan="Manhattan"}(n||(n={})),function(t){t.Euclidean="Euclidean"}(i||(i={})),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"}(r||(r={})),function(t){t.TanimotoIntArray="TanimotoIntArray"}(o||(o={})),function(t){t.Vector="Vector",t.String="String",t.BitArray="BitArray",t.MacroMolecule="MacroMolecule",t.Number="Number",t.IntArray="IntArray"}(a||(a={})),function(t){t.NumericDistance="NumericDistance"}(l||(l={}))},7861:(t,e,s)=>{"use strict";var n=s(1811),i=s(3979),r=s(5697),o=s(850),a=s(489),l=s(1040);const h={[l.CF.Euclidean]:o.dP},c={[l.W.Levenshtein]:n.T,[l.W.JaroWinkler]:i.H$,[l.W.Manhattan]:function(t,e){if(t.length!==e.length)return 1;{let s=0;for(let n=1;n<t.length;n++)s+=t[n]==e[n]?0:1;return s/t.length}}},u={[l.gk.Tanimoto]:r.KR,[l.gk.Dice]:r._h,[l.gk.Asymmetric]:r.yU,[l.gk.BraunBlanquet]:r.Dz,[l.gk.Cosine]:r.Zd,[l.gk.Kulczynski]:r.s,[l.gk.McConnaughey]:r.aW,[l.gk.RogotGoldberg]:r.MI,[l.gk.Russel]:r.fX,[l.gk.Sokal]:r.NB,[l.gk.Hamming]:r.UX,[l.gk.Euclidean]:r.WI},m={[l.gd.TanimotoIntArray]:r.FV},d={[l.Yc.NumericDistance]:r.bX},g={[l.Qe.Vector]:{[l.CF.Euclidean]:h[l.CF.Euclidean]},[l.Qe.String]:{[l.W.Levenshtein]:c[l.W.Levenshtein],[l.W.JaroWinkler]:c[l.W.JaroWinkler],[l.W.Manhattan]:c[l.W.Manhattan]},[l.Qe.BitArray]:{[l.gk.Tanimoto]:u[l.gk.Tanimoto],[l.gk.Dice]:u[l.gk.Dice],[l.gk.Asymmetric]:u[l.gk.Asymmetric],[l.gk.BraunBlanquet]:u[l.gk.BraunBlanquet],[l.gk.Cosine]:u[l.gk.Cosine],[l.gk.Kulczynski]:u[l.gk.Kulczynski],[l.gk.McConnaughey]:u[l.gk.McConnaughey],[l.gk.RogotGoldberg]:u[l.gk.RogotGoldberg],[l.gk.Russel]:u[l.gk.Russel],[l.gk.Sokal]:u[l.gk.Sokal]},[l.Qe.MacroMolecule]:{[a.U.HAMMING]:a.o[a.U.HAMMING],[a.U.LEVENSHTEIN]:a.o[a.U.LEVENSHTEIN],[a.U.NEEDLEMANN_WUNSCH]:a.o[a.U.NEEDLEMANN_WUNSCH]},[l.Qe.Number]:{[l.Yc.NumericDistance]:d[l.Yc.NumericDistance]},[l.Qe.IntArray]:{[l.gd.TanimotoIntArray]:m[l.gd.TanimotoIntArray]}};Object.keys(g).reduce(((t,e)=>{for(const s of Object.keys(g[e]))t[s]=e;return t}),{})},9657:(t,e,s)=>{"use strict";s.d(e,{Z:()=>n});class n{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 s=t,i=n._createBuffer(s);if(e)for(let t=0;t<i.length;t++)i[t]=-1;this._data=i,this._length=s}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,s,n){if(t<e||t>s)throw new Error(`Argument ${n} (${t}) out of range (${e}, ${s})`)}copy(t,e,s){for(let n=0;n<s;n++)e[n]=t[n]}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 s=new n(t._length);s._length=t._length,s._data=n._createBuffer(s._length),s._version=0;const i=t.lengthInInts;for(let n=0;n<i;n++)s._data[n]=t._data[n]&e._data[n];return s}static _createBuffer(t){return new Uint32Array(Math.floor((t+31)/32))}static fromValues(t){const e=new n(t.length);e._version=0;for(let s=0;s<e._length;s++)t[s]&&(e._data[Math.floor(s/32)]|=1<<(s%32&31));return e}static fromSeq(t,e){const s=new n(t);for(let n=0;n<t;++n)s.setBit(n,e(n));return s._version=0,s}static fromString(t){return n.fromSeq(t.length,(e=>"1"==t.charAt(e)))}static fromUint32Array(t,e){const s=new n(t);return s._data=e,s}static fromBytes(t){const e=t.length,s=new n(8*e);s._data=new Uint32Array(Math.floor((e+3)/4)),s._length=8*e;let i=0,r=0;for(;e-r>=4;)s._data[i++]=255&t[r]|(255&t[r+1])<<8|(255&t[r+2])<<16|(255&t[r+3])<<24,r+=4;return e-r==3&&(s._data[i]=(255&t[r+2])<<16),e-r==2&&(s._data[i]|=(255&t[r+1])<<8),e-r==1&&(s._data[i]|=255&t[r]),s._version=0,s}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 n(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 s=t?-1:0,n=this.lengthInInts;for(let t=0;t<n;t++)this._data[t]=s;this.incrementVersion(e)}setIndexes(t,e=!0,s=!0,n=!0){s&&this.setAll(!e,!1);for(const s of t)this.setFast(s,e);this.incrementVersion(n)}everyIndex(t,e=!0){for(const s of t)if(this.getBit(s)!=e)return!1;return!0}anyIndex(t,e=!0){for(const s of t)if(this.getBit(s)==e)return!0;return!1}setWhere(t,e=!0,s=!0,n=!0,i=!0){if(s&&i&&this.setAll(!e,!1),i)for(let s=0;s<this._length;s++)t(s)&&this.setFast(s,e);else for(let s=0;s<this._length;s++)this.setFast(s,t(s)?e:!e);this.incrementVersion(n)}getRange(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const s=[];for(let n=t;n<e;++n)s.push(this.getBit(n));return n.fromValues(s)}getRangeAsList(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const s=[];for(let n=t;n<e;++n)s.push(this.getBit(n));return s}setRange(t,e,s,n=!0){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length-1,"to");const i=Math.min(t,e),r=Math.max(t,e);if(s)for(let t=i;t<=r;t++)this.setTrue(t);else for(let t=i;t<=r;t++)this.setFalse(t);return this.incrementVersion(n),this}setRandom(t,e,s=!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 s=0;s<t;){const t=Math.floor(Math.random()*this._length);this.getBit(t)!=e&&(this.setFast(t,e),s++)}this.incrementVersion(s)}and(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,s=this.lengthInInts;e<s;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 s=this.lengthInInts;for(let e=0;e<s;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,s=this.lengthInInts;e<s;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,s=this.lengthInInts;e<s;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,s=this.lengthInInts;e<s;e++)this._data[e]^=t._data[e];return this.incrementVersion(e),this}insertAt(t,e,s=!1){if(this.assureInRange(t,0,this._length,"pos"),0==e)return;const n=this._length;this.setLength(this._length+e);for(let s=n-1;s>=t;s--)this.setBit(s+e,this.getBit(s));for(let n=t;n<t+e;n++)this.setBit(n,s)}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 s=t;s<this._length-e;s++)this.setBit(s,this.getBit(s+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 s=0;for(let n=-1;-1!=(n=t.findNext(n,!e));)this.setFast(s++,this.getBit(n));this._length=s,this._version++}return this}getBit(t){return 0!=(this._data[Math.floor(t/32)]&1<<(31&t))}setBit(t,e,s=!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+=n._onBitCount[255&t];let s=this._data[e];const i=31&this._length;for(0!=i&&(s&=~(4294967295<<i));0!=s;s>>>=8)this._selectedCount+=n._onBitCount[255&s];this._selectedCountVersion=this._version}return t?this._selectedCount:this._length-this._selectedCount}countWhere(t){let e=0;if(this.trueCount()==this._length)for(let s=0;s<this._length;s++)e+=t(s)?1:0;else for(let s=-1;-1!=(s=this.findNext(s,!0));)e+=t(s)?1:0;return e}andWithCountBits(t,e){if(0==this._length)return 0;let s=0;const i=this.lengthInInts;let r=0;for(;r<i-1;r++)for(let e=this._data[r]&t._data[r];0!=e;e>>>=8)s+=n._onBitCount[255&e];let o=this._data[r]&t._data[r];const a=31&this._length;for(0!=a&&(o&=~(4294967295<<a));0!=o;o>>>=8)s+=n._onBitCount[255&o];return e?s:this._length-s}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 s=31&(t=t<0?0:t+1);const i=this.lengthInInts;for(let r=Math.floor(t/32);r<i;r++){let i=e?this._data[r]:~this._data[r];if(0!=s)i&=4294967295<<s&4294967295,s=0;else if(!e&&-4294967296==i)continue;for(let e=0;0!=i;e+=8,i>>>=8){const s=n._firstOnBit[255&i];if(s>=0)return(t=s+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 s=1+(t=t<0?this._length-1:t-1)&31;for(let i=Math.floor(t/32);i>=0;i--){let t=e?this._data[i]:~this._data[i];0!=s&&(t&=~(4294967295<<s),s=0);for(let e=24;0!=t;e-=8,t<<=8){const s=n._lastOnBit[t>>>24];if(s>=0)return s+32*i+e}}return-1}}n._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]),n._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]),n._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])},4588:(t,e,s)=>{"use strict";function n(t){return Math.random()*t}function i(t){return Math.floor(n(t))}s.d(e,{I:()=>i,t:()=>n})},1061:(t,e,s)=>{"use strict";s.d(e,{AB:()=>P,Bu:()=>f,QK:()=>l,W3:()=>T,Wh:()=>w,X5:()=>S,bb:()=>C,ci:()=>v,f6:()=>b,gw:()=>M,jh:()=>y,l_:()=>p,ow:()=>N});var n=s(4469),i=s(976),r=function(t,e,s,n){return new(s||(s=Promise))((function(i,r){function o(t){try{l(n.next(t))}catch(t){r(t)}}function a(t){try{l(n.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(o,a)}l((n=n.apply(t,e||[])).next())}))};const o=3e4,a=108e5,l={},h="Auto Tests",c={};let u;var m;!function(t){t.notNull=function(t,e){if(null==t)throw new Error(`${null==e?"Value":e} not defined`)}}(m||(m={}));class d{constructor(t,e){this.catchUnhandled=!0,this.report=!1,void 0!==t&&(this.catchUnhandled=t),void 0!==e&&(this.report=e)}}class g{constructor(t,e,s,n){var i;this.category=t,this.name=e,null!=n||(n={}),null!==(i=n.timeout)&&void 0!==i||(n.timeout=o),this.options=n,this.test=()=>r(this,void 0,void 0,(function*(){return new Promise(((t,e)=>r(this,void 0,void 0,(function*(){let n="";try{n=yield s()}catch(t){e(t)}t(n)}))))}))}}function f(t,e,s){null==l[u]&&(l[u]={}),null==l[u].tests&&(l[u].tests=[]),l[u].tests.push(new g(u,t,e,s))}function p(t,e=!0,s){if(s=s?`${s}, `:"",t!==e)throw new Error(`${s}Expected "${e}", got "${t}"`)}function y(t,e,s=.001,n){if(t===Number.POSITIVE_INFINITY&&e===Number.POSITIVE_INFINITY||t===Number.NEGATIVE_INFINITY&&e===Number.NEGATIVE_INFINITY||t===Number.NaN&&e===Number.NaN||isNaN(t)&&isNaN(e))return;const i=Math.abs(t-e)<s;if(p(i,!0,`${null!=n?n:""} (tolerance = ${s})`),!i)throw new Error(`Expected ${e}, got ${t} (tolerance = ${s})`)}function w(t,e){for(const[s,n]of Object.entries(e)){if(!t.hasOwnProperty(s))throw new Error(`Expected property "${s}" not found`);const e=t[s];if(e instanceof Array&&n instanceof Array)b(e,n);else if(e instanceof Object&&n instanceof Object)w(e,n);else if(Number.isFinite(e)&&Number.isFinite(n))y(e,n);else if(e!=n)throw new Error(`Expected (${n}) for key '${s}', got (${e})`)}}function b(t,e){const s=t.length,n=e.length;if(s!=n)throw new Error(`Arrays are of different length: actual array length is ${s} and expected array length is ${n}`);for(let n=0;n<s;n++)if(t[n]instanceof Array&&e[n]instanceof Array)b(t[n],e[n]);else if(t[n]instanceof Object&&e[n]instanceof Object)w(t[n],e[n]);else if(t[n]!=e[n])throw new Error(`Expected ${e[n]} at position ${n}, got ${t[n]}`)}function T(t,e,s){var n;u=t,e(),l[u]&&(l[u].clear=null===(n=null==s?void 0:s.clear)||void 0===n||n,l[u].timeout=null==s?void 0:s.timeout)}function C(t){null==l[u]&&(l[u]={}),l[u].before=t}function S(t){null==l[u]&&(l[u]={}),l[u].after=t}function A(t,e){return t.replace(new RegExp(e.name,"gi"),e.nqName)}function v(t){var e,s,o,a,u;return r(this,void 0,void 0,(function*(){const m=null===(s=null===(e=n.functions.getCurrentCall())||void 0===e?void 0:e.func)||void 0===s?void 0:s.package;yield function(t,e){return r(this,void 0,void 0,(function*(){if(c[t])return;const e=l;if(void 0!==e[h]||Object.keys(e).find((t=>t.startsWith(h))))return void(c[t]=!0);const s=[],i=yield n.dapi.functions.filter(`package.id = "${t}"`).list(),o=new RegExp(/skip:\s*([^,\s]+)|wait:\s*(\d+)|cat:\s*([^,\s]+)/g);for(const t of i){const i=t.options.test;if(i&&Array.isArray(i)&&i.length)for(let a=0;a<i.length;a++){const l=i[a].matchAll(o),c={};Array.from(l).forEach((t=>{t[0].startsWith("skip")?c.skip=t[1]:t[0].startsWith("wait")?c.wait=parseInt(t[2]):t[0].startsWith("cat")&&(c.cat=t[3])}));const u=new g(h,1===i.length?t.name:`${t.name} ${a+1}`,(()=>r(this,void 0,void 0,(function*(){const e=yield n.functions.eval(A(i[a],t));if(c.wait&&(yield M(c.wait)),"boolean"==typeof e&&!e)throw`Failed: ${i[a]}, expected true, got ${e}`}))),{skipReason:c.skip});if(c.cat){const t=h+": "+c.cat;u.category=t,void 0===e[t]&&(e[t]={tests:[],clear:!0}),e[t].tests.push(u)}else s.push(u)}}c[t]=!0,s.length&&(e[h]={tests:s,clear:!0})}))}(m.id);const f=[];console.log("Running tests"),null!=t||(t={}),null!==(o=(u=t).testContext)&&void 0!==o||(u.testContext=new d),n.shell.lastError="";for(const[e,s]of Object.entries(l)){if(null!=(null==t?void 0:t.category)&&!e.toLowerCase().startsWith(null==t?void 0:t.category.toLowerCase()))continue;console.log(`Started ${e} category`);try{s.before&&(yield s.before())}catch(t){s.beforeStatus=t.toString()}const r=null!==(a=s.tests)&&void 0!==a?a:[],o=[];if(s.clear)for(let e=0;e<r.length;e++)o.push(yield E(r[e],null==t?void 0:t.test,s.timeout,m.name)),n.shell.closeAll(),i.Balloon.closeAll();else for(let e=0;e<r.length;e++)o.push(yield E(r[e],null==t?void 0:t.test,s.timeout,m.name));const l=(yield Promise.all(o)).filter((t=>"skipped"!=t.result));try{s.after&&(yield s.after())}catch(t){s.afterStatus=t.toString()}s.afterStatus&&l.push({category:e,name:"init",result:s.afterStatus,success:!1,ms:0,skipped:!1}),s.beforeStatus&&l.push({category:e,name:"init",result:s.beforeStatus,success:!1,ms:0,skipped:!1}),f.push(...l)}if(t.testContext.catchUnhandled&&(yield M(1e3),n.shell.lastError.length>0&&f.push({category:"Unhandled exceptions",name:"exceptions",result:n.shell.lastError,success:!1,ms:0,skipped:!1})),t.testContext.report){const t=new i.Logger,e=f.filter((t=>t.success)).length,s=f.filter((t=>t.skipped)).length,n=f.filter((t=>!t.success)),r="Package @package tested: @successful successful, @skipped skipped, @failed failed tests",o={successful:e,skipped:s,failed:n.length,package:m};for(const t of n)Object.assign(o,{[`${t.category} | ${t.name}`]:t.result});t.log(r,o,"package-tested")}return f}))}function E(t,e,s,l){var h,c,u,m,d;return r(this,void 0,void 0,(function*(){let r;const g=null!=e&&t.name.toLowerCase()!==e.toLowerCase(),f=(null===(h=t.options)||void 0===h?void 0:h.skipReason)||g,p=g?"skipped":null===(c=t.options)||void 0===c?void 0:c.skipReason;f||console.log(`Started ${t.category} ${t.name}`);const y=new Date;try{if(f)r={success:!0,result:p,ms:0,skipped:!0};else{let e=(null===(u=t.options)||void 0===u?void 0:u.timeout)===o&&s?s:null===(m=t.options)||void 0===m?void 0:m.timeout;e=i.Test.isInBenchmark&&e===o?a:e,r={success:!0,result:null!==(d=yield _(t.test,e))&&void 0!==d?d:"OK",ms:0,skipped:!1}}}catch(t){r={success:!1,result:t.toString(),ms:0,skipped:!1}}const w=new Date;if(r.ms=w-y,f||console.log(`Finished ${t.category} ${t.name} for ${r.ms} ms`),r.category=t.category,r.name=t.name,!g){let e={success:r.success,result:r.result,ms:r.ms,skipped:r.skipped,type:"package",packageName:l,category:t.category,test:t.name};if(r.result.constructor==Object){const t=Object.keys(r.result).reduce(((t,e)=>Object.assign(Object.assign({},t),{["result."+e]:r.result[e]})),{});e=Object.assign(Object.assign({},e),t)}n.log.usage(`${l}: ${t.category}: ${t.name}`,e,`test-package ${l}: ${t.category}: ${t.name}`)}return r}))}function M(t){return r(this,void 0,void 0,(function*(){yield new Promise((e=>setTimeout(e,t)))}))}function N(t,e="Timeout exceeded",s=500,n=50){return r(this,void 0,void 0,(function*(){return new Promise(((i,r)=>{setTimeout((()=>{clearInterval(o),r(new Error(e))}),s);const o=setInterval((()=>{t()&&(clearInterval(o),i())}),n)}))}))}function _(t,e){return r(this,void 0,void 0,(function*(){let s=null;const n=new Promise(((t,n)=>{s=setTimeout((()=>{n("EXECUTION TIMEOUT")}),e)}));try{return yield Promise.race([t(),n])}finally{s&&clearTimeout(s)}}))}function P(t,e,s){var o;return r(this,void 0,void 0,(function*(){(null==s?void 0:s.detectSemanticTypes)&&(yield n.data.detectSemanticTypes(e));const r=n.shell.addTableView(e),a=`[name=viewer-${t.replace(/\s+/g,"-")} i]`;let l=`${a} canvas,${a} svg,${a} img,\n ${a} input,${a} h1,${a} a`;const h=[];try{let n=r.addViewer(t);yield N((()=>null!==document.querySelector(l)),"cannot load viewer",3e3);const i=null===(o=document.querySelector(l))||void 0===o?void 0:o.tagName;if(h.push(Array.from(r.viewers).length),!(null==s?void 0:s.readOnly)){Array.from(e.row(0).cells).forEach((t=>t.value=null));const t=e.rowCount<20?Math.floor(e.rowCount/2):10;e.rows.select((e=>e.idx>=0&&e.idx<t)),yield M(50);for(let s=t;s<2*t;s++)e.filter.set(s,!1);yield M(50),e.currentRowIdx=1;const s=e.clone();e.columns.names().slice(0,Math.ceil(e.columns.length/2)).forEach((t=>e.columns.remove(t))),yield M(100),r.dataFrame=s}const c=n.getOptions(!0).look,u=n.getProperties(),m={};Object.keys(c).filter((t=>"boolean"==typeof c[t])).forEach((t=>m[t]=!c[t])),u.filter((t=>null!==t.choices)).forEach((t=>m[t.name]=t.choices.find((e=>e!==c[t.name])))),n.setOptions(m),yield M(300);const d=r.saveLayout(),g=n.getOptions().look;r.resetLayout(),h.push(Array.from(r.viewers).length),r.loadLayout(d),l=`${a} ${i}`,yield N((()=>null!==document.querySelector(l)),"cannot load viewer from layout",3e3),h.push(Array.from(r.viewers).length),n=Array.from(r.viewers).find((t=>"Grid"!==t.type)),b(h,[2,1,2]),p(JSON.stringify(n.getOptions().look),JSON.stringify(g))}finally{r.close(),n.shell.closeTable(e),i.Balloon.closeAll()}}))}},3659:(t,e,s)=>{"use strict";s.d(e,{OW:()=>n});class n extends Float32Array{}},850:(t,e,s)=>{"use strict";s.d(e,{$G:()=>a,Fv:()=>u,MA:()=>l,On:()=>o,dP:()=>c,hu:()=>r,kO:()=>h});var n=s(3659),i=s(4588);function r(t=!1,e="Assertion error."){if(!t)throw new Error(e)}function o(t,e,s=1){const i=t.length;r(i==e.length,"Vector lengths do not match.");const o=new n.OW(i);for(let n=0;n<t.length;++n)o[n]=t[n]+s*e[n];return o}function a(t){let e=0;for(let s=0;s<t.length;s++)e+=t[s]*t[s];return Math.sqrt(e)}function l(t,e){if(t.length!=e.length)throw new Error("The dimensionality of the vectors must match");let s=0;for(let n=0;n<t.length;n++)s+=t[n]*e[n];return s}function h(t,e,s=1){const r=function(t,e,s=0){return new Array(t).fill(s).map((()=>new n.OW(e).fill(s)))}(t,e);for(let n=0;n<t;++n)for(let t=0;t<e;++t)r[n][t]=(0,i.t)(s);return r}function c(t,e){const s=function(t){let e=0;for(let s=0;s<t.length;++s)e+=t[s];return e}(function(t){const e=t.length,s=new n.OW(e);for(let e=0;e<t.length;++e)s[e]=t[e]*t[e];return s}(o(t,e,-1)));return Math.sqrt(s)}function u(t){let e=0,s=0;for(let s=0;s<t.length;++s)e+=t[s];e/=t.length;for(let n=0;n<t.length;++n)s+=(t[n]-e)*(t[n]-e);s=Math.sqrt(s/t.length);for(let n=0;n<t.length;++n)t[n]=(t[n]-e)/s;return t}},7659:(t,e,s)=>{"use strict";e.Z=void 0;var n=s(6215);Object.defineProperty(e,"Z",{enumerable:!0,get:function(){return n.TSNE}})},6215:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TSNE=void 0,e.TSNE=class{constructor(t){this.returnV=!1,this.vValue=0,this.iter=0,t=t||{},this.perplexity=this.getopt(t,"perplexity",30),this.dim=this.getopt(t,"dim",2),this.epsilon=this.getopt(t,"epsilon",10)}assert(t,e){if(!t)throw e||"Assertion failed"}getopt(t,e,s){return t.hasOwnProperty(e)?t[e]:s}gaussRandom(){if(this.returnV)return this.returnV=!1,this.vValue;const t=2*Math.random()-1,e=2*Math.random()-1,s=t*t+e*e;if(0===s||s>1)return this.gaussRandom();const n=Math.sqrt(-2*Math.log(s)/s);return this.vValue=e*n,this.returnV=!0,t*n}randn(t,e){return t+this.gaussRandom()*e}zeros(t){if(void 0===t||isNaN(t))return[];if("undefined"==typeof ArrayBuffer){const e=new Array(t);for(let s=0;s<t;s++)e[s]=0;return e}return new Float64Array(t)}randn2d(t,e,s){const n=void 0!==s,i=[];for(let r=0;r<t;r++){const t=[];for(let i=0;i<e;i++)n?t.push(s):t.push(this.randn(0,1e-4));i.push(t)}return i}L2(t,e){const s=t.length;let n=0;for(let i=0;i<s;i++){const s=t[i],r=e[i];n+=(s-r)*(s-r)}return n}xtod(t){const e=t.length,s=this.zeros(e*e);for(let n=0;n<e;n++)for(let i=n+1;i<e;i++){const r=this.L2(t[n],t[i]);s[n*e+i]=r,s[i*e+n]=r}return s}d2p(t,e,s){const n=Math.sqrt(t.length),i=Math.floor(n);this.assert(i===n,"D should have square number of elements.");const r=Math.log(e),o=this.zeros(i*i),a=this.zeros(i);for(let e=0;e<i;e++){let n=-1/0,l=1/0,h=1,c=!1;const u=50;let m=0;for(;!c;){let o=0;for(let s=0;s<i;s++){let n=Math.exp(-t[e*i+s]*h);e===s&&(n=0),a[s]=n,o+=n}let d=0;for(let t=0;t<i;t++){let e;e=0===o?0:a[t]/o,a[t]=e,e>1e-7&&(d-=e*Math.log(e))}d>r?(n=h,l===1/0?h*=2:h=(h+l)/2):(l=h,n===-1/0?h/=2:h=(h+n)/2),m++,Math.abs(d-r)<s&&(c=!0),m>=u&&(c=!0)}for(let t=0;t<i;t++)o[e*i+t]=a[t]}const l=this.zeros(i*i),h=2*i;for(let t=0;t<i;t++)for(let e=0;e<i;e++)l[t*i+e]=Math.max((o[t*i+e]+o[e*i+t])/h,1e-100);return l}sign(t){return t>0?1:t<0?-1:0}initDataRaw(t){const e=t.length,s=t[0].length;this.assert(e>0," X is empty? You must have some data!"),this.assert(s>0," X[0] is empty? Where is the data?");const n=this.xtod(t);this.P=this.d2p(n,this.perplexity,1e-4),this.N=e,this.initSolution()}initDataDist(t){const e=t.length;this.assert(e>0," X is empty? You must have some data!");const s=this.zeros(e*e);for(let n=0;n<e;n++)for(let i=n+1;i<e;i++){const r=t[n][i];s[n*e+i]=r,s[i*e+n]=r}this.P=this.d2p(s,this.perplexity,1e-4),this.N=e,this.initSolution()}initSolution(){this.Y=this.randn2d(this.N,this.dim),this.gains=this.randn2d(this.N,this.dim,1),this.ystep=this.randn2d(this.N,this.dim,0),this.iter=0}getSolution(){return this.Y}step(){this.iter+=1;const t=this.N,e=this.costGrad(this.Y),s=e.cost,n=e.grad,i=this.zeros(this.dim);for(let e=0;e<t;e++)for(let t=0;t<this.dim;t++){const s=n[e][t],r=this.ystep[e][t],o=this.gains[e][t];let a=this.sign(s)===this.sign(r)?.8*o:o+.2;a<.01&&(a=.01),this.gains[e][t]=a;const l=(this.iter<250?.5:.8)*r-this.epsilon*a*n[e][t];this.ystep[e][t]=l,this.Y[e][t]+=l,i[t]+=this.Y[e][t]}for(let e=0;e<t;e++)for(let s=0;s<this.dim;s++)this.Y[e][s]-=i[s]/t;return s}debugGrad(){const t=this.N,e=this.costGrad(this.Y),s=(e.cost,e.grad),n=1e-5;for(let e=0;e<t;e++)for(let t=0;t<this.dim;t++){const i=this.Y[e][t];this.Y[e][t]=i+n;const r=this.costGrad(this.Y);this.Y[e][t]=i-n;const o=this.costGrad(this.Y),a=s[e][t],l=(r.cost-o.cost)/(2*n);console.log(e+","+t+": gradcheck analytic: "+a+" vs. numerical: "+l),this.Y[e][t]=i}}costGrad(t){const e=this.N,s=this.dim,n=this.P,i=this.iter<100?4:1,r=this.zeros(e*e);let o=0;for(let n=0;n<e;n++)for(let i=n+1;i<e;i++){let a=0;for(let e=0;e<s;e++){const s=t[n][e]-t[i][e];a+=s*s}const l=1/(1+a);r[n*e+i]=l,r[i*e+n]=l,o+=2*l}const a=e*e,l=this.zeros(a);for(let t=0;t<a;t++)l[t]=Math.max(r[t]/o,1e-100);let h=0;const c=[];for(let o=0;o<e;o++){const a=new Array(s);for(let t=0;t<s;t++)a[t]=0;for(let c=0;c<e;c++){h+=-n[o*e+c]*Math.log(l[o*e+c]);const u=4*(i*n[o*e+c]-l[o*e+c])*r[o*e+c];for(let e=0;e<s;e++)a[e]+=u*(t[o][e]-t[c][e])}c.push(a)}return{cost:h,grad:c}}}},5362:(t,e,s)=>{"use strict";s.d(e,{Z:()=>a});var n=s(7537),i=s.n(n),r=s(3645),o=s.n(r)()(i());o.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=o},9564:(t,e,s)=>{"use strict";s.d(e,{Z:()=>a});var n=s(7537),i=s.n(n),r=s(3645),o=s.n(r)()(i());o.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=o},9414:(t,e,s)=>{"use strict";s.d(e,{Z:()=>a});var n=s(7537),i=s.n(n),r=s(3645),o=s.n(r)()(i());o.push([t.id,".scatter_plot_link {\n position: absolute!important;\n right: 10px;\n}\n\n.cliffs_grid {\n top: 10px;\n}\n\n.show_only_cliffs {\n top: 30px;\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","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/ml/css/styles.css"],names:[],mappings:"AAAA;IACI,4BAA4B;IAC5B,WAAW;AACf;;AAEA;IACI,SAAS;AACb;;AAEA;IACI,SAAS;AACb;;AAEA;IACI,eAAe;IACf,kBAAkB;IAClB,YAAY;AAChB",sourcesContent:[".scatter_plot_link {\n position: absolute!important;\n right: 10px;\n}\n\n.cliffs_grid {\n top: 10px;\n}\n\n.show_only_cliffs {\n top: 30px;\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"],sourceRoot:""}]);const a=o},3645:t=>{"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var s="",n=void 0!==e[5];return e[4]&&(s+="@supports (".concat(e[4],") {")),e[2]&&(s+="@media ".concat(e[2]," {")),n&&(s+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),s+=t(e),n&&(s+="}"),e[2]&&(s+="}"),e[4]&&(s+="}"),s})).join("")},e.i=function(t,s,n,i,r){"string"==typeof t&&(t=[[null,t,void 0]]);var o={};if(n)for(var a=0;a<this.length;a++){var l=this[a][0];null!=l&&(o[l]=!0)}for(var h=0;h<t.length;h++){var c=[].concat(t[h]);n&&o[c[0]]||(void 0!==r&&(void 0===c[5]||(c[1]="@layer".concat(c[5].length>0?" ".concat(c[5]):""," {").concat(c[1],"}")),c[5]=r),s&&(c[2]?(c[1]="@media ".concat(c[2]," {").concat(c[1],"}"),c[2]=s):c[2]=s),i&&(c[4]?(c[1]="@supports (".concat(c[4],") {").concat(c[1],"}"),c[4]=i):c[4]="".concat(i)),e.push(c))}},e}},7537:t=>{"use strict";t.exports=function(t){var e=t[1],s=t[3];if(!s)return e;if("function"==typeof btoa){var n=btoa(unescape(encodeURIComponent(JSON.stringify(s)))),i="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(n),r="/*# ".concat(i," */");return[e].concat([r]).join("\n")}return[e].join("\n")}},9133:function(t,e,s){var n;!function(e,i){var r={};!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 s(t,s,n,i,r){for(var o,a,l,h,c,u,m,d,g,f,p,y,w;r>=64;){for(o=s[0],a=s[1],l=s[2],h=s[3],c=s[4],u=s[5],m=s[6],d=s[7],f=0;f<16;f++)p=i+4*f,t[f]=(255&n[p])<<24|(255&n[p+1])<<16|(255&n[p+2])<<8|255&n[p+3];for(f=16;f<64;f++)y=((g=t[f-2])>>>17|g<<15)^(g>>>19|g<<13)^g>>>10,w=((g=t[f-15])>>>7|g<<25)^(g>>>18|g<<14)^g>>>3,t[f]=(y+t[f-7]|0)+(w+t[f-16]|0);for(f=0;f<64;f++)y=(((c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7))+(c&u^~c&m)|0)+(d+(e[f]+t[f]|0)|0)|0,w=((o>>>2|o<<30)^(o>>>13|o<<19)^(o>>>22|o<<10))+(o&a^o&l^a&l)|0,d=m,m=u,u=c,c=h+y|0,h=l,l=a,a=o,o=y+w|0;s[0]+=o,s[1]+=a,s[2]+=l,s[3]+=h,s[4]+=c,s[5]+=u,s[6]+=m,s[7]+=d,i+=64,r-=64}return i}var n=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 n=0;if(this.bytesHashed+=e,this.bufferLength>0){for(;this.bufferLength<64&&e>0;)this.buffer[this.bufferLength++]=t[n++],e--;64===this.bufferLength&&(s(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(e>=64&&(n=s(this.temp,this.state,t,n,e),e%=64);e>0;)this.buffer[this.bufferLength++]=t[n++],e--;return this},e.prototype.finish=function(t){if(!this.finished){var e=this.bytesHashed,n=this.bufferLength,i=e/536870912|0,r=e<<3,o=e%64<56?64:128;this.buffer[n]=128;for(var a=n+1;a<o-8;a++)this.buffer[a]=0;this.buffer[o-8]=i>>>24&255,this.buffer[o-7]=i>>>16&255,this.buffer[o-6]=i>>>8&255,this.buffer[o-5]=i>>>0&255,this.buffer[o-4]=r>>>24&255,this.buffer[o-3]=r>>>16&255,this.buffer[o-2]=r>>>8&255,this.buffer[o-1]=r>>>0&255,s(this.temp,this.state,this.buffer,0,o),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 s=0;s<this.state.length;s++)this.state[s]=t[s];this.bytesHashed=e,this.finished=!1,this.bufferLength=0},e}();t.Hash=n;var i=function(){function t(t){this.inner=new n,this.outer=new n,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var e=new Uint8Array(this.blockSize);if(t.length>this.blockSize)(new n).update(t).finish(e).clean();else for(var s=0;s<t.length;s++)e[s]=t[s];for(s=0;s<e.length;s++)e[s]^=54;for(this.inner.update(e),s=0;s<e.length;s++)e[s]^=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),s=0;s<e.length;s++)e[s]=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 n).update(t),s=e.digest();return e.clean(),s}function o(t,e){var s=new i(t).update(e),n=s.digest();return s.clean(),n}function a(t,e,s,n){var i=n[0];if(0===i)throw new Error("hkdf: cannot expand more");e.reset(),i>1&&e.update(t),s&&e.update(s),e.update(n),e.finish(t),n[0]++}t.HMAC=i,t.hash=r,t.default=r,t.hmac=o;var l=new Uint8Array(t.digestLength);t.hkdf=function(t,e,s,n){void 0===e&&(e=l),void 0===n&&(n=32);for(var r=new Uint8Array([1]),h=o(e,t),c=new i(h),u=new Uint8Array(c.digestLength),m=u.length,d=new Uint8Array(n),g=0;g<n;g++)m===u.length&&(a(u,c,s,r),m=0),d[g]=u[m++];return c.clean(),u.fill(0),r.fill(0),d},t.pbkdf2=function(t,e,s,n){for(var r=new i(t),o=r.digestLength,a=new Uint8Array(4),l=new Uint8Array(o),h=new Uint8Array(o),c=new Uint8Array(n),u=0;u*o<n;u++){var m=u+1;a[0]=m>>>24&255,a[1]=m>>>16&255,a[2]=m>>>8&255,a[3]=m>>>0&255,r.reset(),r.update(e),r.update(a),r.finish(h);for(var d=0;d<o;d++)l[d]=h[d];for(d=2;d<=s;d++){r.reset(),r.update(h).finish(h);for(var g=0;g<o;g++)l[g]^=h[g]}for(d=0;d<o&&u*o+d<n;d++)c[u*o+d]=l[d]}for(u=0;u<o;u++)l[u]=h[u]=0;for(u=0;u<4;u++)a[u]=0;return r.clean(),c}}(r);var o=r.default;for(var a in r)o[a]=r[a];"object"==typeof t.exports?t.exports=o:void 0===(n=function(){return o}.call(r,s,r,t))||(t.exports=n)}()},1811:(t,e,s)=>{"use strict";s.d(e,{T:()=>i});const n=new Uint32Array(65536),i=(t,e)=>{if(t.length<e.length){const s=e;e=t,t=s}return 0===e.length?t.length:t.length<=32?((t,e)=>{const s=t.length,i=e.length,r=1<<s-1;let o=-1,a=0,l=s,h=s;for(;h--;)n[t.charCodeAt(h)]|=1<<h;for(h=0;h<i;h++){let t=n[e.charCodeAt(h)];const s=t|a;t|=(t&o)+o^o,a|=~(t|o),o&=t,a&r&&l++,o&r&&l--,a=a<<1|1,o=o<<1|~(s|a),a&=s}for(h=s;h--;)n[t.charCodeAt(h)]=0;return l})(t,e):((t,e)=>{const s=e.length,i=t.length,r=[],o=[],a=Math.ceil(s/32),l=Math.ceil(i/32);for(let t=0;t<a;t++)o[t]=-1,r[t]=0;let h=0;for(;h<l-1;h++){let a=0,l=-1;const c=32*h,u=Math.min(32,i)+c;for(let e=c;e<u;e++)n[t.charCodeAt(e)]|=1<<e;for(let t=0;t<s;t++){const s=n[e.charCodeAt(t)],i=o[t/32|0]>>>t&1,h=r[t/32|0]>>>t&1,c=s|a,u=((s|h)&l)+l^l|s|h;let m=a|~(u|l),d=l&u;m>>>31^i&&(o[t/32|0]^=1<<t),d>>>31^h&&(r[t/32|0]^=1<<t),m=m<<1|i,d=d<<1|h,l=d|~(c|m),a=m&c}for(let e=c;e<u;e++)n[t.charCodeAt(e)]=0}let c=0,u=-1;const m=32*h,d=Math.min(32,i-m)+m;for(let e=m;e<d;e++)n[t.charCodeAt(e)]|=1<<e;let g=i;for(let t=0;t<s;t++){const s=n[e.charCodeAt(t)],a=o[t/32|0]>>>t&1,l=r[t/32|0]>>>t&1,h=s|c,m=((s|l)&u)+u^u|s|l;let d=c|~(m|u),f=u&m;g+=d>>>i-1&1,g-=f>>>i-1&1,d>>>31^a&&(o[t/32|0]^=1<<t),f>>>31^l&&(r[t/32|0]^=1<<t),d=d<<1|a,f=f<<1|l,u=f|~(h|d),c=d&h}for(let e=m;e<d;e++)n[t.charCodeAt(e)]=0;return g})(t,e)}},3979:(t,e)=>{"use strict";e.H$=void 0,e.H$=function(t,e,s){var n=function(t,e,s){if(0===t.length||0===e.length)return 0;if(s&&!s.caseSensitive&&(t=t.toUpperCase(),e=e.toUpperCase()),t===e)return 1;for(var n=0,i=t.length,r=e.length,o=Math.floor(Math.max(i,r)/2)-1,a=new Array(i),l=new Array(r),h=0;h<i;h++)for(var c=Math.max(0,h-o);c<=Math.min(r,h+o+1);c++)if(!a[h]&&!l[c]&&t[h]===e[c]){++n,a[h]=l[c]=!0;break}if(0===n)return 0;var u=0,m=0;for(h=0;h<i;h++)if(a[h]){for(;!l[m];)m++;t.charAt(h)!==e.charAt(m++)&&u++}return(n/i+n/r+(n-(u/=2))/n)/3}(t,e,s),i=0;if(n>.7){for(var r=Math.min(t.length,e.length),o=0;t[o]===e[o]&&o<4&&o<r;)++i,o++;n+=.1*i*(1-n)}return n}},9251:(t,e,s)=>{"use strict";s.r(e),s.d(e,{default:()=>F});const n=Object.prototype.toString;function i(t){return n.call(t).endsWith("Array]")}function r(t,e,s){let n=0;const i=s(e);for(let e=0;e<t.x.length;e++)n+=Math.abs(t.y[e]-i(t.x[e]));return n}const o=Object.prototype.toString;function a(t){return o.call(t).endsWith("Array]")}const l=Object.prototype.toString;function h(t){return l.call(t).endsWith("Array]")}const c=Object.prototype.toString;const u=Object.prototype.toString;function m(t){var e,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!h(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");if(void 0!==s.output){if(!h(s.output))throw new TypeError("output option must be an array if specified");e=s.output}else e=new Array(t.length);var n=function(t){var e,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e=t,!u.call(e).endsWith("Array]"))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var n=s.fromIndex,i=void 0===n?0:n,r=s.toIndex,o=void 0===r?t.length:r;if(i<0||i>=t.length||!Number.isInteger(i))throw new Error("fromIndex must be a positive integer smaller than length");if(o<=i||o>t.length||!Number.isInteger(o))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[i],l=i+1;l<o;l++)t[l]<a&&(a=t[l]);return a}(t),i=function(t){var e,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e=t,!c.call(e).endsWith("Array]"))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var n=s.fromIndex,i=void 0===n?0:n,r=s.toIndex,o=void 0===r?t.length:r;if(i<0||i>=t.length||!Number.isInteger(i))throw new Error("fromIndex must be a positive integer smaller than length");if(o<=i||o>t.length||!Number.isInteger(o))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[i],l=i+1;l<o;l++)t[l]>a&&(a=t[l]);return a}(t);if(n===i)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var r=s.min,o=void 0===r?s.autoMinMax?n:0:r,a=s.max,l=void 0===a?s.autoMinMax?i:1:a;if(o>=l)throw new RangeError("min option must be smaller than max option");for(var m=(l-o)/(i-n),d=0;d<t.length;d++)e[d]=(t[d]-n)*m+o;return e}const d=" ".repeat(2),g=" ".repeat(4);function f(t,e={}){const{maxRows:s=15,maxColumns:n=10,maxNumSize:i=8,padMinus:r="auto"}=e;return`${t.constructor.name} {\n${d}[\n${g}${function(t,e,s,n,i){const{rows:r,columns:o}=t,a=Math.min(r,e),l=Math.min(o,s),h=[];if("auto"===i){i=!1;t:for(let e=0;e<a;e++)for(let s=0;s<l;s++)if(t.get(e,s)<0){i=!0;break t}}for(let e=0;e<a;e++){let s=[];for(let r=0;r<l;r++)s.push(p(t.get(e,r),n,i));h.push(`${s.join(" ")}`)}return l!==o&&(h[h.length-1]+=` ... ${o-s} more columns`),a!==r&&h.push(`... ${r-e} more rows`),h.join(`\n${g}`)}(t,s,n,i,r)}\n${d}]\n${d}rows: ${t.rows}\n${d}columns: ${t.columns}\n}`}function p(t,e,s){return(t>=0&&s?` ${y(t,e-1)}`:y(t,e)).padEnd(e)}function y(t,e){let s=t.toString();if(s.length<=e)return s;let n=t.toFixed(e);if(n.length>e&&(n=t.toFixed(Math.max(0,e-(n.length-e)))),n.length<=e&&!n.startsWith("0.000")&&!n.startsWith("-0.000"))return n;let i=t.toExponential(e);return i.length>e&&(i=t.toExponential(Math.max(0,e-(i.length-e)))),i.slice(0)}function w(t,e,s){let n=s?t.rows:t.rows-1;if(e<0||e>n)throw new RangeError("Row index out of range")}function b(t,e,s){let n=s?t.columns:t.columns-1;if(e<0||e>n)throw new RangeError("Column index out of range")}function T(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.columns)throw new RangeError("vector size must be the same as the number of columns");return e}function C(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.rows)throw new RangeError("vector size must be the same as the number of rows");return e}function S(t,e,s,n,i){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(v("startRow",e),v("endRow",s),v("startColumn",n),v("endColumn",i),e>s||n>i||e<0||e>=t.rows||s<0||s>=t.rows||n<0||n>=t.columns||i<0||i>=t.columns)throw new RangeError("Submatrix indices are out of range")}function A(t,e=0){let s=[];for(let n=0;n<t;n++)s.push(e);return s}function v(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function E(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class M{static from1DArray(t,e,s){if(t*e!==s.length)throw new RangeError("data length does not match given dimensions");let n=new _(t,e);for(let i=0;i<t;i++)for(let t=0;t<e;t++)n.set(i,t,s[i*e+t]);return n}static rowVector(t){let e=new _(1,t.length);for(let s=0;s<t.length;s++)e.set(0,s,t[s]);return e}static columnVector(t){let e=new _(t.length,1);for(let s=0;s<t.length;s++)e.set(s,0,t[s]);return e}static zeros(t,e){return new _(t,e)}static ones(t,e){return new _(t,e).fill(1)}static rand(t,e,s={}){if("object"!=typeof s)throw new TypeError("options must be an object");const{random:n=Math.random}=s;let i=new _(t,e);for(let s=0;s<t;s++)for(let t=0;t<e;t++)i.set(s,t,n());return i}static randInt(t,e,s={}){if("object"!=typeof s)throw new TypeError("options must be an object");const{min:n=0,max:i=1e3,random:r=Math.random}=s;if(!Number.isInteger(n))throw new TypeError("min must be an integer");if(!Number.isInteger(i))throw new TypeError("max must be an integer");if(n>=i)throw new RangeError("min must be smaller than max");let o=i-n,a=new _(t,e);for(let s=0;s<t;s++)for(let t=0;t<e;t++){let e=n+Math.round(r()*o);a.set(s,t,e)}return a}static eye(t,e,s){void 0===e&&(e=t),void 0===s&&(s=1);let n=Math.min(t,e),i=this.zeros(t,e);for(let t=0;t<n;t++)i.set(t,t,s);return i}static diag(t,e,s){let n=t.length;void 0===e&&(e=n),void 0===s&&(s=e);let i=Math.min(n,e,s),r=this.zeros(e,s);for(let e=0;e<i;e++)r.set(e,e,t[e]);return r}static min(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let s=t.rows,n=t.columns,i=new _(s,n);for(let r=0;r<s;r++)for(let s=0;s<n;s++)i.set(r,s,Math.min(t.get(r,s),e.get(r,s)));return i}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let s=t.rows,n=t.columns,i=new this(s,n);for(let r=0;r<s;r++)for(let s=0;s<n;s++)i.set(r,s,Math.max(t.get(r,s),e.get(r,s)));return i}static checkMatrix(t){return M.isMatrix(t)?t:new _(t)}static isMatrix(t){return null!=t&&"Matrix"===t.klass}get size(){return this.rows*this.columns}apply(t){if("function"!=typeof t)throw new TypeError("callback must be a function");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)t.call(this,e,s);return this}to1DArray(){let t=[];for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)t.push(this.get(e,s));return t}to2DArray(){let t=[];for(let e=0;e<this.rows;e++){t.push([]);for(let s=0;s<this.columns;s++)t[e].push(this.get(e,s))}return t}toJSON(){return this.to2DArray()}isRowVector(){return 1===this.rows}isColumnVector(){return 1===this.columns}isVector(){return 1===this.rows||1===this.columns}isSquare(){return this.rows===this.columns}isEmpty(){return 0===this.rows||0===this.columns}isSymmetric(){if(this.isSquare()){for(let t=0;t<this.rows;t++)for(let e=0;e<=t;e++)if(this.get(t,e)!==this.get(e,t))return!1;return!0}return!1}isEchelonForm(){let t=0,e=0,s=-1,n=!0,i=!1;for(;t<this.rows&&n;){for(e=0,i=!1;e<this.columns&&!1===i;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>s?(i=!0,s=e):(n=!1,i=!0);t++}return n}isReducedEchelonForm(){let t=0,e=0,s=-1,n=!0,i=!1;for(;t<this.rows&&n;){for(e=0,i=!1;e<this.columns&&!1===i;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>s?(i=!0,s=e):(n=!1,i=!0);for(let s=e+1;s<this.rows;s++)0!==this.get(t,s)&&(n=!1);t++}return n}echelonForm(){let t=this.clone(),e=0,s=0;for(;e<t.rows&&s<t.columns;){let n=e;for(let i=e;i<t.rows;i++)t.get(i,s)>t.get(n,s)&&(n=i);if(0===t.get(n,s))s++;else{t.swapRows(e,n);let i=t.get(e,s);for(let n=s;n<t.columns;n++)t.set(e,n,t.get(e,n)/i);for(let n=e+1;n<t.rows;n++){let i=t.get(n,s)/t.get(e,s);t.set(n,s,0);for(let r=s+1;r<t.columns;r++)t.set(n,r,t.get(n,r)-t.get(e,r)*i)}e++,s++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,s=t.rows,n=s-1;for(;n>=0;)if(0===t.maxRow(n))n--;else{let i=0,r=!1;for(;i<s&&!1===r;)1===t.get(n,i)?r=!0:i++;for(let s=0;s<n;s++){let r=t.get(s,i);for(let o=i;o<e;o++){let e=t.get(s,o)-r*t.get(n,o);t.set(s,o,e)}}n--}return t}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{rows:e=1,columns:s=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(s)||s<=0)throw new TypeError("columns must be a positive integer");let n=new _(this.rows*e,this.columns*s);for(let t=0;t<e;t++)for(let e=0;e<s;e++)n.setSubMatrix(this,this.rows*t,this.columns*e);return n}fill(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,t);return this}neg(){return this.mulS(-1)}getRow(t){w(this,t);let e=[];for(let s=0;s<this.columns;s++)e.push(this.get(t,s));return e}getRowVector(t){return _.rowVector(this.getRow(t))}setRow(t,e){w(this,t),e=T(this,e);for(let s=0;s<this.columns;s++)this.set(t,s,e[s]);return this}swapRows(t,e){w(this,t),w(this,e);for(let s=0;s<this.columns;s++){let n=this.get(t,s);this.set(t,s,this.get(e,s)),this.set(e,s,n)}return this}getColumn(t){b(this,t);let e=[];for(let s=0;s<this.rows;s++)e.push(this.get(s,t));return e}getColumnVector(t){return _.columnVector(this.getColumn(t))}setColumn(t,e){b(this,t),e=C(this,e);for(let s=0;s<this.rows;s++)this.set(s,t,e[s]);return this}swapColumns(t,e){b(this,t),b(this,e);for(let s=0;s<this.rows;s++){let n=this.get(s,t);this.set(s,t,this.get(s,e)),this.set(s,e,n)}return this}addRowVector(t){t=T(this,t);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)+t[s]);return this}subRowVector(t){t=T(this,t);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)-t[s]);return this}mulRowVector(t){t=T(this,t);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)*t[s]);return this}divRowVector(t){t=T(this,t);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)/t[s]);return this}addColumnVector(t){t=C(this,t);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)+t[e]);return this}subColumnVector(t){t=C(this,t);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)-t[e]);return this}mulColumnVector(t){t=C(this,t);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)*t[e]);return this}divColumnVector(t){t=C(this,t);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)/t[e]);return this}mulRow(t,e){w(this,t);for(let s=0;s<this.columns;s++)this.set(t,s,this.get(t,s)*e);return this}mulColumn(t,e){b(this,t);for(let s=0;s<this.rows;s++)this.set(s,t,this.get(s,t)*e);return this}max(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.get(e,s)>t[e]&&(t[e]=this.get(e,s));return t}case"column":{const t=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.get(e,s)>t[s]&&(t[s]=this.get(e,s));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.get(e,s)>t&&(t=this.get(e,s));return t}default:throw new Error(`invalid option: ${t}`)}}maxIndex(){E(this);let t=this.get(0,0),e=[0,0];for(let s=0;s<this.rows;s++)for(let n=0;n<this.columns;n++)this.get(s,n)>t&&(t=this.get(s,n),e[0]=s,e[1]=n);return e}min(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.get(e,s)<t[e]&&(t[e]=this.get(e,s));return t}case"column":{const t=new Array(this.columns).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.get(e,s)<t[s]&&(t[s]=this.get(e,s));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.get(e,s)<t&&(t=this.get(e,s));return t}default:throw new Error(`invalid option: ${t}`)}}minIndex(){E(this);let t=this.get(0,0),e=[0,0];for(let s=0;s<this.rows;s++)for(let n=0;n<this.columns;n++)this.get(s,n)<t&&(t=this.get(s,n),e[0]=s,e[1]=n);return e}maxRow(t){if(w(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let s=1;s<this.columns;s++)this.get(t,s)>e&&(e=this.get(t,s));return e}maxRowIndex(t){w(this,t),E(this);let e=this.get(t,0),s=[t,0];for(let n=1;n<this.columns;n++)this.get(t,n)>e&&(e=this.get(t,n),s[1]=n);return s}minRow(t){if(w(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let s=1;s<this.columns;s++)this.get(t,s)<e&&(e=this.get(t,s));return e}minRowIndex(t){w(this,t),E(this);let e=this.get(t,0),s=[t,0];for(let n=1;n<this.columns;n++)this.get(t,n)<e&&(e=this.get(t,n),s[1]=n);return s}maxColumn(t){if(b(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let s=1;s<this.rows;s++)this.get(s,t)>e&&(e=this.get(s,t));return e}maxColumnIndex(t){b(this,t),E(this);let e=this.get(0,t),s=[0,t];for(let n=1;n<this.rows;n++)this.get(n,t)>e&&(e=this.get(n,t),s[0]=n);return s}minColumn(t){if(b(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let s=1;s<this.rows;s++)this.get(s,t)<e&&(e=this.get(s,t));return e}minColumnIndex(t){b(this,t),E(this);let e=this.get(0,t),s=[0,t];for(let n=1;n<this.rows;n++)this.get(n,t)<e&&(e=this.get(n,t),s[0]=n);return s}diag(){let t=Math.min(this.rows,this.columns),e=[];for(let s=0;s<t;s++)e.push(this.get(s,s));return e}norm(t="frobenius"){let e=0;if("max"===t)return this.max();if("frobenius"===t){for(let t=0;t<this.rows;t++)for(let s=0;s<this.columns;s++)e+=this.get(t,s)*this.get(t,s);return Math.sqrt(e)}throw new RangeError(`unknown norm type: ${t}`)}cumulativeSum(){let t=0;for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)t+=this.get(e,s),this.set(e,s,t);return this}dot(t){M.isMatrix(t)&&(t=t.to1DArray());let e=this.to1DArray();if(e.length!==t.length)throw new RangeError("vectors do not have the same size");let s=0;for(let n=0;n<e.length;n++)s+=e[n]*t[n];return s}mmul(t){t=_.checkMatrix(t);let e=this.rows,s=this.columns,n=t.columns,i=new _(e,n),r=new Float64Array(s);for(let o=0;o<n;o++){for(let e=0;e<s;e++)r[e]=t.get(e,o);for(let t=0;t<e;t++){let e=0;for(let n=0;n<s;n++)e+=this.get(t,n)*r[n];i.set(t,o,e)}}return i}strassen2x2(t){t=_.checkMatrix(t);let e=new _(2,2);const s=this.get(0,0),n=t.get(0,0),i=this.get(0,1),r=t.get(0,1),o=this.get(1,0),a=t.get(1,0),l=this.get(1,1),h=t.get(1,1),c=(s+l)*(n+h),u=(o+l)*n,m=s*(r-h),d=l*(a-n),g=(s+i)*h,f=c+d-g+(i-l)*(a+h),p=m+g,y=u+d,w=c-u+m+(o-s)*(n+r);return e.set(0,0,f),e.set(0,1,p),e.set(1,0,y),e.set(1,1,w),e}strassen3x3(t){t=_.checkMatrix(t);let e=new _(3,3);const s=this.get(0,0),n=this.get(0,1),i=this.get(0,2),r=this.get(1,0),o=this.get(1,1),a=this.get(1,2),l=this.get(2,0),h=this.get(2,1),c=this.get(2,2),u=t.get(0,0),m=t.get(0,1),d=t.get(0,2),g=t.get(1,0),f=t.get(1,1),p=t.get(1,2),y=t.get(2,0),w=t.get(2,1),b=t.get(2,2),T=(s-r)*(-m+f),C=(-s+r+o)*(u-m+f),S=(r+o)*(-u+m),A=s*u,v=(-s+l+h)*(u-d+p),E=(-s+l)*(d-p),M=(l+h)*(-u+d),N=(-i+h+c)*(f+y-w),P=(i-c)*(f-w),L=i*y,R=(h+c)*(-y+w),x=(-i+o+a)*(p+y-b),I=(i-a)*(p-b),O=(o+a)*(-y+b),F=A+L+n*g,D=(s+n+i-r-o-h-c)*f+C+S+A+N+L+R,G=A+v+M+(s+n+i-o-a-l-h)*p+L+x+O,H=T+o*(-u+m+g-f-p-y+b)+C+A+L+x+I,k=T+C+S+A+a*w,W=L+x+I+O+r*d,B=A+v+E+h*(-u+d+g-f-p-y+w)+N+P+L,V=N+P+L+R+l*m,U=A+v+E+M+c*b;return e.set(0,0,F),e.set(0,1,D),e.set(0,2,G),e.set(1,0,H),e.set(1,1,k),e.set(1,2,W),e.set(2,0,B),e.set(2,1,V),e.set(2,2,U),e}mmulStrassen(t){t=_.checkMatrix(t);let e=this.clone(),s=e.rows,n=e.columns,i=t.rows,r=t.columns;function o(t,e,s){let n=t.rows,i=t.columns;if(n===e&&i===s)return t;{let n=M.zeros(e,s);return n=n.setSubMatrix(t,0,0),n}}n!==i&&console.warn(`Multiplying ${s} x ${n} and ${i} x ${r} matrix: dimensions do not match.`);let a=Math.max(s,i),l=Math.max(n,r);return e=o(e,a,l),function t(e,s,n,i){if(n<=512||i<=512)return e.mmul(s);n%2==1&&i%2==1?(e=o(e,n+1,i+1),s=o(s,n+1,i+1)):n%2==1?(e=o(e,n+1,i),s=o(s,n+1,i)):i%2==1&&(e=o(e,n,i+1),s=o(s,n,i+1));let r=parseInt(e.rows/2,10),a=parseInt(e.columns/2,10),l=e.subMatrix(0,r-1,0,a-1),h=s.subMatrix(0,r-1,0,a-1),c=e.subMatrix(0,r-1,a,e.columns-1),u=s.subMatrix(0,r-1,a,s.columns-1),m=e.subMatrix(r,e.rows-1,0,a-1),d=s.subMatrix(r,s.rows-1,0,a-1),g=e.subMatrix(r,e.rows-1,a,e.columns-1),f=s.subMatrix(r,s.rows-1,a,s.columns-1),p=t(M.add(l,g),M.add(h,f),r,a),y=t(M.add(m,g),h,r,a),w=t(l,M.sub(u,f),r,a),b=t(g,M.sub(d,h),r,a),T=t(M.add(l,c),f,r,a),C=t(M.sub(m,l),M.add(h,u),r,a),S=t(M.sub(c,g),M.add(d,f),r,a),A=M.add(p,b);A.sub(T),A.add(S);let v=M.add(w,T),E=M.add(y,b),N=M.sub(p,y);N.add(w),N.add(C);let _=M.zeros(2*A.rows,2*A.columns);return _=_.setSubMatrix(A,0,0),_=_.setSubMatrix(v,A.rows,0),_=_.setSubMatrix(E,0,A.columns),_=_.setSubMatrix(N,A.rows,A.columns),_.subMatrix(0,n-1,0,i-1)}(e,t=o(t,a,l),a,l)}scaleRows(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:s=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(s))throw new TypeError("max must be a number");if(e>=s)throw new RangeError("min must be smaller than max");let n=new _(this.rows,this.columns);for(let t=0;t<this.rows;t++){const i=this.getRow(t);i.length>0&&m(i,{min:e,max:s,output:i}),n.setRow(t,i)}return n}scaleColumns(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:s=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(s))throw new TypeError("max must be a number");if(e>=s)throw new RangeError("min must be smaller than max");let n=new _(this.rows,this.columns);for(let t=0;t<this.columns;t++){const i=this.getColumn(t);i.length&&m(i,{min:e,max:s,output:i}),n.setColumn(t,i)}return n}flipRows(){const t=Math.ceil(this.columns/2);for(let e=0;e<this.rows;e++)for(let s=0;s<t;s++){let t=this.get(e,s),n=this.get(e,this.columns-1-s);this.set(e,s,n),this.set(e,this.columns-1-s,t)}return this}flipColumns(){const t=Math.ceil(this.rows/2);for(let e=0;e<this.columns;e++)for(let s=0;s<t;s++){let t=this.get(s,e),n=this.get(this.rows-1-s,e);this.set(s,e,n),this.set(this.rows-1-s,e,t)}return this}kroneckerProduct(t){t=_.checkMatrix(t);let e=this.rows,s=this.columns,n=t.rows,i=t.columns,r=new _(e*n,s*i);for(let o=0;o<e;o++)for(let e=0;e<s;e++)for(let s=0;s<n;s++)for(let a=0;a<i;a++)r.set(n*o+s,i*e+a,this.get(o,e)*t.get(s,a));return r}kroneckerSum(t){if(t=_.checkMatrix(t),!this.isSquare()||!t.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let e=this.rows,s=t.rows,n=this.kroneckerProduct(_.eye(s,s)),i=_.eye(e,e).kroneckerProduct(t);return n.add(i)}transpose(){let t=new _(this.columns,this.rows);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)t.set(s,e,this.get(e,s));return t}sortRows(t=N){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=N){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,s,n){S(this,t,e,s,n);let i=new _(e-t+1,n-s+1);for(let r=t;r<=e;r++)for(let e=s;e<=n;e++)i.set(r-t,e-s,this.get(r,e));return i}subMatrixRow(t,e,s){if(void 0===e&&(e=0),void 0===s&&(s=this.columns-1),e>s||e<0||e>=this.columns||s<0||s>=this.columns)throw new RangeError("Argument out of range");let n=new _(t.length,s-e+1);for(let i=0;i<t.length;i++)for(let r=e;r<=s;r++){if(t[i]<0||t[i]>=this.rows)throw new RangeError(`Row index out of range: ${t[i]}`);n.set(i,r-e,this.get(t[i],r))}return n}subMatrixColumn(t,e,s){if(void 0===e&&(e=0),void 0===s&&(s=this.rows-1),e>s||e<0||e>=this.rows||s<0||s>=this.rows)throw new RangeError("Argument out of range");let n=new _(s-e+1,t.length);for(let i=0;i<t.length;i++)for(let r=e;r<=s;r++){if(t[i]<0||t[i]>=this.columns)throw new RangeError(`Column index out of range: ${t[i]}`);n.set(r-e,i,this.get(r,t[i]))}return n}setSubMatrix(t,e,s){if((t=_.checkMatrix(t)).isEmpty())return this;S(this,e,e+t.rows-1,s,s+t.columns-1);for(let n=0;n<t.rows;n++)for(let i=0;i<t.columns;i++)this.set(e+n,s+i,t.get(n,i));return this}selection(t,e){!function(t,e){if(!a(e))throw new TypeError("row indices must be an array");for(let s=0;s<e.length;s++)if(e[s]<0||e[s]>=t.rows)throw new RangeError("row indices are out of range")}(this,t),function(t,e){if(!a(e))throw new TypeError("column indices must be an array");for(let s=0;s<e.length;s++)if(e[s]<0||e[s]>=t.columns)throw new RangeError("column indices are out of range")}(this,e);let s=new _(t.length,e.length);for(let n=0;n<t.length;n++){let i=t[n];for(let t=0;t<e.length;t++){let r=e[t];s.set(n,t,this.get(i,r))}}return s}trace(){let t=Math.min(this.rows,this.columns),e=0;for(let s=0;s<t;s++)e+=this.get(s,s);return e}clone(){let t=new _(this.rows,this.columns);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)t.set(e,s,this.get(e,s));return t}sum(t){switch(t){case"row":return function(t){let e=A(t.rows);for(let s=0;s<t.rows;++s)for(let n=0;n<t.columns;++n)e[s]+=t.get(s,n);return e}(this);case"column":return function(t){let e=A(t.columns);for(let s=0;s<t.rows;++s)for(let n=0;n<t.columns;++n)e[n]+=t.get(s,n);return e}(this);case void 0:return function(t){let e=0;for(let s=0;s<t.rows;s++)for(let n=0;n<t.columns;n++)e+=t.get(s,n);return e}(this);default:throw new Error(`invalid option: ${t}`)}}product(t){switch(t){case"row":return function(t){let e=A(t.rows,1);for(let s=0;s<t.rows;++s)for(let n=0;n<t.columns;++n)e[s]*=t.get(s,n);return e}(this);case"column":return function(t){let e=A(t.columns,1);for(let s=0;s<t.rows;++s)for(let n=0;n<t.columns;++n)e[n]*=t.get(s,n);return e}(this);case void 0:return function(t){let e=1;for(let s=0;s<t.rows;s++)for(let n=0;n<t.columns;n++)e*=t.get(s,n);return e}(this);default:throw new Error(`invalid option: ${t}`)}}mean(t){const e=this.sum(t);switch(t){case"row":for(let t=0;t<this.rows;t++)e[t]/=this.columns;return e;case"column":for(let t=0;t<this.columns;t++)e[t]/=this.rows;return e;case void 0:return e/this.size;default:throw new Error(`invalid option: ${t}`)}}variance(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{unbiased:s=!0,mean:n=this.mean(t)}=e;if("boolean"!=typeof s)throw new TypeError("unbiased must be a boolean");switch(t){case"row":if(!a(n))throw new TypeError("mean must be an array");return function(t,e,s){const n=t.rows,i=t.columns,r=[];for(let o=0;o<n;o++){let n=0,a=0,l=0;for(let e=0;e<i;e++)l=t.get(o,e)-s[o],n+=l,a+=l*l;e?r.push((a-n*n/i)/(i-1)):r.push((a-n*n/i)/i)}return r}(this,s,n);case"column":if(!a(n))throw new TypeError("mean must be an array");return function(t,e,s){const n=t.rows,i=t.columns,r=[];for(let o=0;o<i;o++){let i=0,a=0,l=0;for(let e=0;e<n;e++)l=t.get(e,o)-s[o],i+=l,a+=l*l;e?r.push((a-i*i/n)/(n-1)):r.push((a-i*i/n)/n)}return r}(this,s,n);case void 0:if("number"!=typeof n)throw new TypeError("mean must be a number");return function(t,e,s){const n=t.rows,i=t.columns,r=n*i;let o=0,a=0,l=0;for(let e=0;e<n;e++)for(let n=0;n<i;n++)l=t.get(e,n)-s,o+=l,a+=l*l;return e?(a-o*o/r)/(r-1):(a-o*o/r)/r}(this,s,n);default:throw new Error(`invalid option: ${t}`)}}standardDeviation(t,e){"object"==typeof t&&(e=t,t=void 0);const s=this.variance(t,e);if(void 0===t)return Math.sqrt(s);for(let t=0;t<s.length;t++)s[t]=Math.sqrt(s[t]);return s}center(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{center:s=this.mean(t)}=e;switch(t){case"row":if(!a(s))throw new TypeError("center must be an array");return function(t,e){for(let s=0;s<t.rows;s++)for(let n=0;n<t.columns;n++)t.set(s,n,t.get(s,n)-e[s])}(this,s),this;case"column":if(!a(s))throw new TypeError("center must be an array");return function(t,e){for(let s=0;s<t.rows;s++)for(let n=0;n<t.columns;n++)t.set(s,n,t.get(s,n)-e[n])}(this,s),this;case void 0:if("number"!=typeof s)throw new TypeError("center must be a number");return function(t,e){for(let s=0;s<t.rows;s++)for(let n=0;n<t.columns;n++)t.set(s,n,t.get(s,n)-e)}(this,s),this;default:throw new Error(`invalid option: ${t}`)}}scale(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");let s=e.scale;switch(t){case"row":if(void 0===s)s=function(t){const e=[];for(let s=0;s<t.rows;s++){let n=0;for(let e=0;e<t.columns;e++)n+=Math.pow(t.get(s,e),2)/(t.columns-1);e.push(Math.sqrt(n))}return e}(this);else if(!a(s))throw new TypeError("scale must be an array");return function(t,e){for(let s=0;s<t.rows;s++)for(let n=0;n<t.columns;n++)t.set(s,n,t.get(s,n)/e[s])}(this,s),this;case"column":if(void 0===s)s=function(t){const e=[];for(let s=0;s<t.columns;s++){let n=0;for(let e=0;e<t.rows;e++)n+=Math.pow(t.get(e,s),2)/(t.rows-1);e.push(Math.sqrt(n))}return e}(this);else if(!a(s))throw new TypeError("scale must be an array");return function(t,e){for(let s=0;s<t.rows;s++)for(let n=0;n<t.columns;n++)t.set(s,n,t.get(s,n)/e[n])}(this,s),this;case void 0:if(void 0===s)s=function(t){const e=t.size-1;let s=0;for(let n=0;n<t.columns;n++)for(let i=0;i<t.rows;i++)s+=Math.pow(t.get(i,n),2)/e;return Math.sqrt(s)}(this);else if("number"!=typeof s)throw new TypeError("scale must be a number");return function(t,e){for(let s=0;s<t.rows;s++)for(let n=0;n<t.columns;n++)t.set(s,n,t.get(s,n)/e)}(this,s),this;default:throw new Error(`invalid option: ${t}`)}}toString(t){return f(this,t)}}function N(t,e){return t-e}M.prototype.klass="Matrix","undefined"!=typeof Symbol&&(M.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return f(this)}),M.random=M.rand,M.randomInt=M.randInt,M.diagonal=M.diag,M.prototype.diagonal=M.prototype.diag,M.identity=M.eye,M.prototype.negate=M.prototype.neg,M.prototype.tensorProduct=M.prototype.kroneckerProduct;class _ extends M{constructor(t,e){if(super(),_.isMatrix(t))return t.clone();if(Number.isInteger(t)&&t>=0){if(this.data=[],!(Number.isInteger(e)&&e>=0))throw new TypeError("nColumns must be a positive integer");for(let s=0;s<t;s++)this.data.push(new Float64Array(e))}else{if(!a(t))throw new TypeError("First argument must be a positive number or an array");{const s=t;if("number"!=typeof(e=(t=s.length)?s[0].length:0))throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let n=0;n<t;n++){if(s[n].length!==e)throw new RangeError("Inconsistent array dimensions");if(!s[n].every((t=>"number"==typeof t)))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(s[n]))}}}this.rows=t,this.columns=e}set(t,e,s){return this.data[t][e]=s,this}get(t,e){return this.data[t][e]}removeRow(t){return w(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),w(this,t,!0),e=Float64Array.from(T(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){b(this,t);for(let e=0;e<this.rows;e++){const s=new Float64Array(this.columns-1);for(let n=0;n<t;n++)s[n]=this.data[e][n];for(let n=t+1;n<this.columns;n++)s[n-1]=this.data[e][n];this.data[e]=s}return this.columns-=1,this}addColumn(t,e){void 0===e&&(e=t,t=this.columns),b(this,t,!0),e=C(this,e);for(let s=0;s<this.rows;s++){const n=new Float64Array(this.columns+1);let i=0;for(;i<t;i++)n[i]=this.data[s][i];for(n[i++]=e[s];i<this.columns+1;i++)n[i]=this.data[s][i-1];this.data[s]=n}return this.columns+=1,this}}!function(t,e){t.prototype.add=function(t){return"number"==typeof t?this.addS(t):this.addM(t)},t.prototype.addS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)+t);return this},t.prototype.addM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)+t.get(e,s));return this},t.add=function(t,s){return new e(t).add(s)},t.prototype.sub=function(t){return"number"==typeof t?this.subS(t):this.subM(t)},t.prototype.subS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)-t);return this},t.prototype.subM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)-t.get(e,s));return this},t.sub=function(t,s){return new e(t).sub(s)},t.prototype.subtract=t.prototype.sub,t.prototype.subtractS=t.prototype.subS,t.prototype.subtractM=t.prototype.subM,t.subtract=t.sub,t.prototype.mul=function(t){return"number"==typeof t?this.mulS(t):this.mulM(t)},t.prototype.mulS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)*t);return this},t.prototype.mulM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)*t.get(e,s));return this},t.mul=function(t,s){return new e(t).mul(s)},t.prototype.multiply=t.prototype.mul,t.prototype.multiplyS=t.prototype.mulS,t.prototype.multiplyM=t.prototype.mulM,t.multiply=t.mul,t.prototype.div=function(t){return"number"==typeof t?this.divS(t):this.divM(t)},t.prototype.divS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)/t);return this},t.prototype.divM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)/t.get(e,s));return this},t.div=function(t,s){return new e(t).div(s)},t.prototype.divide=t.prototype.div,t.prototype.divideS=t.prototype.divS,t.prototype.divideM=t.prototype.divM,t.divide=t.div,t.prototype.mod=function(t){return"number"==typeof t?this.modS(t):this.modM(t)},t.prototype.modS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)%t);return this},t.prototype.modM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)%t.get(e,s));return this},t.mod=function(t,s){return new e(t).mod(s)},t.prototype.modulus=t.prototype.mod,t.prototype.modulusS=t.prototype.modS,t.prototype.modulusM=t.prototype.modM,t.modulus=t.mod,t.prototype.and=function(t){return"number"==typeof t?this.andS(t):this.andM(t)},t.prototype.andS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)&t);return this},t.prototype.andM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)&t.get(e,s));return this},t.and=function(t,s){return new e(t).and(s)},t.prototype.or=function(t){return"number"==typeof t?this.orS(t):this.orM(t)},t.prototype.orS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)|t);return this},t.prototype.orM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)|t.get(e,s));return this},t.or=function(t,s){return new e(t).or(s)},t.prototype.xor=function(t){return"number"==typeof t?this.xorS(t):this.xorM(t)},t.prototype.xorS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)^t);return this},t.prototype.xorM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)^t.get(e,s));return this},t.xor=function(t,s){return new e(t).xor(s)},t.prototype.leftShift=function(t){return"number"==typeof t?this.leftShiftS(t):this.leftShiftM(t)},t.prototype.leftShiftS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)<<t);return this},t.prototype.leftShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)<<t.get(e,s));return this},t.leftShift=function(t,s){return new e(t).leftShift(s)},t.prototype.signPropagatingRightShift=function(t){return"number"==typeof t?this.signPropagatingRightShiftS(t):this.signPropagatingRightShiftM(t)},t.prototype.signPropagatingRightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)>>t);return this},t.prototype.signPropagatingRightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)>>t.get(e,s));return this},t.signPropagatingRightShift=function(t,s){return new e(t).signPropagatingRightShift(s)},t.prototype.rightShift=function(t){return"number"==typeof t?this.rightShiftS(t):this.rightShiftM(t)},t.prototype.rightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)>>>t);return this},t.prototype.rightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)>>>t.get(e,s));return this},t.rightShift=function(t,s){return new e(t).rightShift(s)},t.prototype.zeroFillRightShift=t.prototype.rightShift,t.prototype.zeroFillRightShiftS=t.prototype.rightShiftS,t.prototype.zeroFillRightShiftM=t.prototype.rightShiftM,t.zeroFillRightShift=t.rightShift,t.prototype.not=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,~this.get(t,e));return this},t.not=function(t){return new e(t).not()},t.prototype.abs=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.abs(this.get(t,e)));return this},t.abs=function(t){return new e(t).abs()},t.prototype.acos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acos(this.get(t,e)));return this},t.acos=function(t){return new e(t).acos()},t.prototype.acosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acosh(this.get(t,e)));return this},t.acosh=function(t){return new e(t).acosh()},t.prototype.asin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asin(this.get(t,e)));return this},t.asin=function(t){return new e(t).asin()},t.prototype.asinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asinh(this.get(t,e)));return this},t.asinh=function(t){return new e(t).asinh()},t.prototype.atan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atan(this.get(t,e)));return this},t.atan=function(t){return new e(t).atan()},t.prototype.atanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atanh(this.get(t,e)));return this},t.atanh=function(t){return new e(t).atanh()},t.prototype.cbrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cbrt(this.get(t,e)));return this},t.cbrt=function(t){return new e(t).cbrt()},t.prototype.ceil=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.ceil(this.get(t,e)));return this},t.ceil=function(t){return new e(t).ceil()},t.prototype.clz32=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.clz32(this.get(t,e)));return this},t.clz32=function(t){return new e(t).clz32()},t.prototype.cos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cos(this.get(t,e)));return this},t.cos=function(t){return new e(t).cos()},t.prototype.cosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cosh(this.get(t,e)));return this},t.cosh=function(t){return new e(t).cosh()},t.prototype.exp=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.exp(this.get(t,e)));return this},t.exp=function(t){return new e(t).exp()},t.prototype.expm1=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.expm1(this.get(t,e)));return this},t.expm1=function(t){return new e(t).expm1()},t.prototype.floor=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.floor(this.get(t,e)));return this},t.floor=function(t){return new e(t).floor()},t.prototype.fround=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.fround(this.get(t,e)));return this},t.fround=function(t){return new e(t).fround()},t.prototype.log=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log(this.get(t,e)));return this},t.log=function(t){return new e(t).log()},t.prototype.log1p=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log1p(this.get(t,e)));return this},t.log1p=function(t){return new e(t).log1p()},t.prototype.log10=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log10(this.get(t,e)));return this},t.log10=function(t){return new e(t).log10()},t.prototype.log2=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log2(this.get(t,e)));return this},t.log2=function(t){return new e(t).log2()},t.prototype.round=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.round(this.get(t,e)));return this},t.round=function(t){return new e(t).round()},t.prototype.sign=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sign(this.get(t,e)));return this},t.sign=function(t){return new e(t).sign()},t.prototype.sin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sin(this.get(t,e)));return this},t.sin=function(t){return new e(t).sin()},t.prototype.sinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sinh(this.get(t,e)));return this},t.sinh=function(t){return new e(t).sinh()},t.prototype.sqrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sqrt(this.get(t,e)));return this},t.sqrt=function(t){return new e(t).sqrt()},t.prototype.tan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tan(this.get(t,e)));return this},t.tan=function(t){return new e(t).tan()},t.prototype.tanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tanh(this.get(t,e)));return this},t.tanh=function(t){return new e(t).tanh()},t.prototype.trunc=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.trunc(this.get(t,e)));return this},t.trunc=function(t){return new e(t).trunc()},t.pow=function(t,s){return new e(t).pow(s)},t.prototype.pow=function(t){return"number"==typeof t?this.powS(t):this.powM(t)},t.prototype.powS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,Math.pow(this.get(e,s),t));return this},t.prototype.powM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,Math.pow(this.get(e,s),t.get(e,s)));return this}}(M,_);class P extends M{constructor(t){super(),this.data=t,this.rows=t.length,this.columns=t[0].length}set(t,e,s){return this.data[t][e]=s,this}get(t,e){return this.data[t][e]}}class L{constructor(t){let e,s,n,i,r,o,a,l,h,c=(t=P.checkMatrix(t)).clone(),u=c.rows,m=c.columns,d=new Float64Array(u),g=1;for(e=0;e<u;e++)d[e]=e;for(l=new Float64Array(u),s=0;s<m;s++){for(e=0;e<u;e++)l[e]=c.get(e,s);for(e=0;e<u;e++){for(h=Math.min(e,s),r=0,n=0;n<h;n++)r+=c.get(e,n)*l[n];l[e]-=r,c.set(e,s,l[e])}for(i=s,e=s+1;e<u;e++)Math.abs(l[e])>Math.abs(l[i])&&(i=e);if(i!==s){for(n=0;n<m;n++)o=c.get(i,n),c.set(i,n,c.get(s,n)),c.set(s,n,o);a=d[i],d[i]=d[s],d[s]=a,g=-g}if(s<u&&0!==c.get(s,s))for(e=s+1;e<u;e++)c.set(e,s,c.get(e,s)/c.get(s,s))}this.LU=c,this.pivotVector=d,this.pivotSign=g}isSingular(){let t=this.LU,e=t.columns;for(let s=0;s<e;s++)if(0===t.get(s,s))return!0;return!1}solve(t){t=_.checkMatrix(t);let e=this.LU;if(e.rows!==t.rows)throw new Error("Invalid matrix dimensions");if(this.isSingular())throw new Error("LU matrix is singular");let s,n,i,r=t.columns,o=t.subMatrixRow(this.pivotVector,0,r-1),a=e.columns;for(i=0;i<a;i++)for(s=i+1;s<a;s++)for(n=0;n<r;n++)o.set(s,n,o.get(s,n)-o.get(i,n)*e.get(s,i));for(i=a-1;i>=0;i--){for(n=0;n<r;n++)o.set(i,n,o.get(i,n)/e.get(i,i));for(s=0;s<i;s++)for(n=0;n<r;n++)o.set(s,n,o.get(s,n)-o.get(i,n)*e.get(s,i))}return o}get determinant(){let t=this.LU;if(!t.isSquare())throw new Error("Matrix must be square");let e=this.pivotSign,s=t.columns;for(let n=0;n<s;n++)e*=t.get(n,n);return e}get lowerTriangularMatrix(){let t=this.LU,e=t.rows,s=t.columns,n=new _(e,s);for(let i=0;i<e;i++)for(let e=0;e<s;e++)i>e?n.set(i,e,t.get(i,e)):i===e?n.set(i,e,1):n.set(i,e,0);return n}get upperTriangularMatrix(){let t=this.LU,e=t.rows,s=t.columns,n=new _(e,s);for(let i=0;i<e;i++)for(let e=0;e<s;e++)i<=e?n.set(i,e,t.get(i,e)):n.set(i,e,0);return n}get pivotPermutationVector(){return Array.from(this.pivotVector)}}function R(t,e){let s=0;return Math.abs(t)>Math.abs(e)?(s=e/t,Math.abs(t)*Math.sqrt(1+s*s)):0!==e?(s=t/e,Math.abs(e)*Math.sqrt(1+s*s)):0}class x{constructor(t){let e,s,n,i,r=(t=P.checkMatrix(t)).clone(),o=t.rows,a=t.columns,l=new Float64Array(a);for(n=0;n<a;n++){let t=0;for(e=n;e<o;e++)t=R(t,r.get(e,n));if(0!==t){for(r.get(n,n)<0&&(t=-t),e=n;e<o;e++)r.set(e,n,r.get(e,n)/t);for(r.set(n,n,r.get(n,n)+1),s=n+1;s<a;s++){for(i=0,e=n;e<o;e++)i+=r.get(e,n)*r.get(e,s);for(i=-i/r.get(n,n),e=n;e<o;e++)r.set(e,s,r.get(e,s)+i*r.get(e,n))}}l[n]=-t}this.QR=r,this.Rdiag=l}solve(t){t=_.checkMatrix(t);let e=this.QR,s=e.rows;if(t.rows!==s)throw new Error("Matrix row dimensions must agree");if(!this.isFullRank())throw new Error("Matrix is rank deficient");let n,i,r,o,a=t.columns,l=t.clone(),h=e.columns;for(r=0;r<h;r++)for(i=0;i<a;i++){for(o=0,n=r;n<s;n++)o+=e.get(n,r)*l.get(n,i);for(o=-o/e.get(r,r),n=r;n<s;n++)l.set(n,i,l.get(n,i)+o*e.get(n,r))}for(r=h-1;r>=0;r--){for(i=0;i<a;i++)l.set(r,i,l.get(r,i)/this.Rdiag[r]);for(n=0;n<r;n++)for(i=0;i<a;i++)l.set(n,i,l.get(n,i)-l.get(r,i)*e.get(n,r))}return l.subMatrix(0,h-1,0,a-1)}isFullRank(){let t=this.QR.columns;for(let e=0;e<t;e++)if(0===this.Rdiag[e])return!1;return!0}get upperTriangularMatrix(){let t,e,s=this.QR,n=s.columns,i=new _(n,n);for(t=0;t<n;t++)for(e=0;e<n;e++)t<e?i.set(t,e,s.get(t,e)):t===e?i.set(t,e,this.Rdiag[t]):i.set(t,e,0);return i}get orthogonalMatrix(){let t,e,s,n,i=this.QR,r=i.rows,o=i.columns,a=new _(r,o);for(s=o-1;s>=0;s--){for(t=0;t<r;t++)a.set(t,s,0);for(a.set(s,s,1),e=s;e<o;e++)if(0!==i.get(s,s)){for(n=0,t=s;t<r;t++)n+=i.get(t,s)*a.get(t,e);for(n=-n/i.get(s,s),t=s;t<r;t++)a.set(t,e,a.get(t,e)+n*i.get(t,s))}}return a}}class I{constructor(t,e={}){if((t=P.checkMatrix(t)).isEmpty())throw new Error("Matrix must be non-empty");let s=t.rows,n=t.columns;const{computeLeftSingularVectors:i=!0,computeRightSingularVectors:r=!0,autoTranspose:o=!1}=e;let a,l=Boolean(i),h=Boolean(r),c=!1;if(s<n)if(o){a=t.transpose(),s=a.rows,n=a.columns,c=!0;let e=l;l=h,h=e}else a=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else a=t.clone();let u=Math.min(s,n),m=Math.min(s+1,n),d=new Float64Array(m),g=new _(s,u),f=new _(n,n),p=new Float64Array(n),y=new Float64Array(s),w=new Float64Array(m);for(let t=0;t<m;t++)w[t]=t;let b=Math.min(s-1,n),T=Math.max(0,Math.min(n-2,s)),C=Math.max(b,T);for(let t=0;t<C;t++){if(t<b){d[t]=0;for(let e=t;e<s;e++)d[t]=R(d[t],a.get(e,t));if(0!==d[t]){a.get(t,t)<0&&(d[t]=-d[t]);for(let e=t;e<s;e++)a.set(e,t,a.get(e,t)/d[t]);a.set(t,t,a.get(t,t)+1)}d[t]=-d[t]}for(let e=t+1;e<n;e++){if(t<b&&0!==d[t]){let n=0;for(let i=t;i<s;i++)n+=a.get(i,t)*a.get(i,e);n=-n/a.get(t,t);for(let i=t;i<s;i++)a.set(i,e,a.get(i,e)+n*a.get(i,t))}p[e]=a.get(t,e)}if(l&&t<b)for(let e=t;e<s;e++)g.set(e,t,a.get(e,t));if(t<T){p[t]=0;for(let e=t+1;e<n;e++)p[t]=R(p[t],p[e]);if(0!==p[t]){p[t+1]<0&&(p[t]=0-p[t]);for(let e=t+1;e<n;e++)p[e]/=p[t];p[t+1]+=1}if(p[t]=-p[t],t+1<s&&0!==p[t]){for(let e=t+1;e<s;e++)y[e]=0;for(let e=t+1;e<s;e++)for(let s=t+1;s<n;s++)y[e]+=p[s]*a.get(e,s);for(let e=t+1;e<n;e++){let n=-p[e]/p[t+1];for(let i=t+1;i<s;i++)a.set(i,e,a.get(i,e)+n*y[i])}}if(h)for(let e=t+1;e<n;e++)f.set(e,t,p[e])}}let S=Math.min(n,s+1);if(b<n&&(d[b]=a.get(b,b)),s<S&&(d[S-1]=0),T+1<S&&(p[T]=a.get(T,S-1)),p[S-1]=0,l){for(let t=b;t<u;t++){for(let e=0;e<s;e++)g.set(e,t,0);g.set(t,t,1)}for(let t=b-1;t>=0;t--)if(0!==d[t]){for(let e=t+1;e<u;e++){let n=0;for(let i=t;i<s;i++)n+=g.get(i,t)*g.get(i,e);n=-n/g.get(t,t);for(let i=t;i<s;i++)g.set(i,e,g.get(i,e)+n*g.get(i,t))}for(let e=t;e<s;e++)g.set(e,t,-g.get(e,t));g.set(t,t,1+g.get(t,t));for(let e=0;e<t-1;e++)g.set(e,t,0)}else{for(let e=0;e<s;e++)g.set(e,t,0);g.set(t,t,1)}}if(h)for(let t=n-1;t>=0;t--){if(t<T&&0!==p[t])for(let e=t+1;e<n;e++){let s=0;for(let i=t+1;i<n;i++)s+=f.get(i,t)*f.get(i,e);s=-s/f.get(t+1,t);for(let i=t+1;i<n;i++)f.set(i,e,f.get(i,e)+s*f.get(i,t))}for(let e=0;e<n;e++)f.set(e,t,0);f.set(t,t,1)}let A=S-1,v=0,E=Number.EPSILON;for(;S>0;){let t,e;for(t=S-2;t>=-1&&-1!==t;t--){const e=Number.MIN_VALUE+E*Math.abs(d[t]+Math.abs(d[t+1]));if(Math.abs(p[t])<=e||Number.isNaN(p[t])){p[t]=0;break}}if(t===S-2)e=4;else{let s;for(s=S-1;s>=t&&s!==t;s--){let e=(s!==S?Math.abs(p[s]):0)+(s!==t+1?Math.abs(p[s-1]):0);if(Math.abs(d[s])<=E*e){d[s]=0;break}}s===t?e=3:s===S-1?e=1:(e=2,t=s)}switch(t++,e){case 1:{let e=p[S-2];p[S-2]=0;for(let s=S-2;s>=t;s--){let i=R(d[s],e),r=d[s]/i,o=e/i;if(d[s]=i,s!==t&&(e=-o*p[s-1],p[s-1]=r*p[s-1]),h)for(let t=0;t<n;t++)i=r*f.get(t,s)+o*f.get(t,S-1),f.set(t,S-1,-o*f.get(t,s)+r*f.get(t,S-1)),f.set(t,s,i)}break}case 2:{let e=p[t-1];p[t-1]=0;for(let n=t;n<S;n++){let i=R(d[n],e),r=d[n]/i,o=e/i;if(d[n]=i,e=-o*p[n],p[n]=r*p[n],l)for(let e=0;e<s;e++)i=r*g.get(e,n)+o*g.get(e,t-1),g.set(e,t-1,-o*g.get(e,n)+r*g.get(e,t-1)),g.set(e,n,i)}break}case 3:{const e=Math.max(Math.abs(d[S-1]),Math.abs(d[S-2]),Math.abs(p[S-2]),Math.abs(d[t]),Math.abs(p[t])),i=d[S-1]/e,r=d[S-2]/e,o=p[S-2]/e,a=d[t]/e,c=p[t]/e,u=((r+i)*(r-i)+o*o)/2,m=i*o*(i*o);let y=0;0===u&&0===m||(y=u<0?0-Math.sqrt(u*u+m):Math.sqrt(u*u+m),y=m/(u+y));let w=(a+i)*(a-i)+y,b=a*c;for(let e=t;e<S-1;e++){let i=R(w,b);0===i&&(i=Number.MIN_VALUE);let r=w/i,o=b/i;if(e!==t&&(p[e-1]=i),w=r*d[e]+o*p[e],p[e]=r*p[e]-o*d[e],b=o*d[e+1],d[e+1]=r*d[e+1],h)for(let t=0;t<n;t++)i=r*f.get(t,e)+o*f.get(t,e+1),f.set(t,e+1,-o*f.get(t,e)+r*f.get(t,e+1)),f.set(t,e,i);if(i=R(w,b),0===i&&(i=Number.MIN_VALUE),r=w/i,o=b/i,d[e]=i,w=r*p[e]+o*d[e+1],d[e+1]=-o*p[e]+r*d[e+1],b=o*p[e+1],p[e+1]=r*p[e+1],l&&e<s-1)for(let t=0;t<s;t++)i=r*g.get(t,e)+o*g.get(t,e+1),g.set(t,e+1,-o*g.get(t,e)+r*g.get(t,e+1)),g.set(t,e,i)}p[S-2]=w,v+=1;break}case 4:if(d[t]<=0&&(d[t]=d[t]<0?-d[t]:0,h))for(let e=0;e<=A;e++)f.set(e,t,-f.get(e,t));for(;t<A&&!(d[t]>=d[t+1]);){let e=d[t];if(d[t]=d[t+1],d[t+1]=e,h&&t<n-1)for(let s=0;s<n;s++)e=f.get(s,t+1),f.set(s,t+1,f.get(s,t)),f.set(s,t,e);if(l&&t<s-1)for(let n=0;n<s;n++)e=g.get(n,t+1),g.set(n,t+1,g.get(n,t)),g.set(n,t,e);t++}v=0,S--}}if(c){let t=f;f=g,g=t}this.m=s,this.n=n,this.s=d,this.U=g,this.V=f}solve(t){let e=t,s=this.threshold,n=this.s.length,i=_.zeros(n,n);for(let t=0;t<n;t++)Math.abs(this.s[t])<=s?i.set(t,t,0):i.set(t,t,1/this.s[t]);let r=this.U,o=this.rightSingularVectors,a=o.mmul(i),l=o.rows,h=r.rows,c=_.zeros(l,h);for(let t=0;t<l;t++)for(let e=0;e<h;e++){let s=0;for(let i=0;i<n;i++)s+=a.get(t,i)*r.get(e,i);c.set(t,e,s)}return c.mmul(e)}solveForDiagonal(t){return this.solve(_.diag(t))}inverse(){let t=this.V,e=this.threshold,s=t.rows,n=t.columns,i=new _(s,this.s.length);for(let r=0;r<s;r++)for(let s=0;s<n;s++)Math.abs(this.s[s])>e&&i.set(r,s,t.get(r,s)/this.s[s]);let r=this.U,o=r.rows,a=r.columns,l=new _(s,o);for(let t=0;t<s;t++)for(let e=0;e<o;e++){let s=0;for(let n=0;n<a;n++)s+=i.get(t,n)*r.get(e,n);l.set(t,e,s)}return l}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let t=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,e=0,s=this.s;for(let n=0,i=s.length;n<i;n++)s[n]>t&&e++;return e}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return _.diag(this.s)}}function O(t,e,s,n,i){let r=s*n*n,o=_.eye(e.length,e.length,r);const a=i(e);let l=new Float64Array(t.x.length);for(let e=0;e<t.x.length;e++)l[e]=a(t.x[e]);let h=function(t,e,s,n,i){const r=s.length,o=t.x.length;let a=new Array(r);for(let l=0;l<r;l++){a[l]=new Array(o);let r=s.slice();r[l]+=n;let h=i(r);for(let s=0;s<o;s++)a[l][s]=e[s]-h(t.x[s])}return new _(a)}(t,l,e,n,i),c=function(t,e){const s=t.x.length;let n=new Array(s);for(let i=0;i<s;i++)n[i]=[t.y[i]-e[i]];return new _(n)}(t,l),u=function(t,e=!1){return t=P.checkMatrix(t),e?new I(t).inverse():function(t,e,s=!1){return t=P.checkMatrix(t),e=P.checkMatrix(e),s?new I(t).solve(e):t.isSquare()?new L(t).solve(e):new x(t).solve(e)}(t,_.eye(t.rows))}(o.add(h.mmul(h.transpose())));return(e=(e=new _([e])).sub(u.mmul(h).mmul(c).mul(n).transpose())).to1DArray()}function F(t,e,s={}){let{maxIterations:n=100,gradientDifference:o=.1,damping:a=0,errorTolerance:l=.01,minValues:h,maxValues:c,initialValues:u}=s;if(a<=0)throw new Error("The damping option must be a positive number");if(!t.x||!t.y)throw new Error("The data parameter must have x and y elements");if(!i(t.x)||t.x.length<2||!i(t.y)||t.y.length<2)throw new Error("The data parameter elements must be an array with more than 2 points");if(t.x.length!==t.y.length)throw new Error("The data parameter elements must have the same size");let m=u||new Array(e.length).fill(1),d=m.length;if(c=c||new Array(d).fill(Number.MAX_SAFE_INTEGER),h=h||new Array(d).fill(Number.MIN_SAFE_INTEGER),c.length!==h.length)throw new Error("minValues and maxValues must be the same size");if(!i(m))throw new Error("initialValues must be an array");let g,f=r(t,m,e),p=f<=l;for(g=0;g<n&&!p;g++){m=O(t,m,a,o,e);for(let t=0;t<d;t++)m[t]=Math.min(Math.max(h[t],m[t]),c[t]);if(f=r(t,m,e),isNaN(f))break;p=f<=l}return{parameterValues:m,parameterError:f,iterations:g}}},3379:t=>{"use strict";var e=[];function s(t){for(var s=-1,n=0;n<e.length;n++)if(e[n].identifier===t){s=n;break}return s}function n(t,n){for(var r={},o=[],a=0;a<t.length;a++){var l=t[a],h=n.base?l[0]+n.base:l[0],c=r[h]||0,u="".concat(h," ").concat(c);r[h]=c+1;var m=s(u),d={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==m)e[m].references++,e[m].updater(d);else{var g=i(d,n);n.byIndex=a,e.splice(a,0,{identifier:u,updater:g,references:1})}o.push(u)}return o}function i(t,e){var s=e.domAPI(e);return s.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;s.update(t=e)}else s.remove()}}t.exports=function(t,i){var r=n(t=t||[],i=i||{});return function(t){t=t||[];for(var o=0;o<r.length;o++){var a=s(r[o]);e[a].references--}for(var l=n(t,i),h=0;h<r.length;h++){var c=s(r[h]);0===e[c].references&&(e[c].updater(),e.splice(c,1))}r=l}}},569:t=>{"use strict";var e={};t.exports=function(t,s){var n=function(t){if(void 0===e[t]){var s=document.querySelector(t);if(window.HTMLIFrameElement&&s instanceof window.HTMLIFrameElement)try{s=s.contentDocument.head}catch(t){s=null}e[t]=s}return e[t]}(t);if(!n)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");n.appendChild(s)}},9216:t=>{"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},3565:(t,e,s)=>{"use strict";t.exports=function(t){var e=s.nc;e&&t.setAttribute("nonce",e)}},7795:t=>{"use strict";t.exports=function(t){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=t.insertStyleElement(t);return{update:function(s){!function(t,e,s){var n="";s.supports&&(n+="@supports (".concat(s.supports,") {")),s.media&&(n+="@media ".concat(s.media," {"));var i=void 0!==s.layer;i&&(n+="@layer".concat(s.layer.length>0?" ".concat(s.layer):""," {")),n+=s.css,i&&(n+="}"),s.media&&(n+="}"),s.supports&&(n+="}");var r=s.sourceMap;r&&"undefined"!=typeof btoa&&(n+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(r))))," */")),e.styleTagTransform(n,t,e.options)}(e,t,s)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},4589: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))}}},7241:(t,e,s)=>{"use strict";s.d(e,{D:()=>c});var n=s(4469),i=s(976),r=s(6414),o=s.n(r),a=s(2397),l=s(499);const h=31;async function c(t,e=!1,s){const r=l.Cn.getOrCreate(t);let c;s??(s=new Map);const m=r.isHelm()?(0,a.getHelmMonomers)(t):Object.keys(r.stats.freq).filter((t=>""!==t));for(let t=0;t<m.length;t++)s.has(m[t])||s.set(m[t],`${s.size+1}`);if(r.isHelm())c=await n.functions.call("HELM:getMolFiles",{col:t}),c=function(t,e,s=!1){const n=new Array(t.length);for(let i=0;i<t.length;i++){let r=0,o=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(i);r=l.indexOf("\n",r)+1,r=l.indexOf("\n",r)+1,r=l.indexOf("\n",r)+1;const c=parseInt(l.substring(r,r+3)),u=parseInt(l.substring(r+3,r+6));a+=`M V30 COUNTS ${c} ${u} 0 0 0\n`,a+="M V30 BEGIN ATOM\n";for(let t=0;t<c;t++){r=l.indexOf("\n",r)+1+h,o=l.indexOf(" ",r);const n=l.substring(r,o);a+=s?`M V30 ${t+1} R${e.get(n)} 0.000 0.000 0 0\n`:`M V30 ${t+1} At 0.000 0.000 0 0 MASS=${e.get(n)}\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()),s=parseInt(l.substring(r+3,r+6).trim());a+=`M V30 ${t+1} ${parseInt(l.substring(r+6,r+9).trim())} ${e} ${s}\n`}a+="M V30 END BOND\n",a+="M V30 END CTAB\n",a+="M END",n[i]=a}return n}(c,s,e);else{c=new Array(t.length);for(let n=0;n<t.length;n++){const t=u(o()(r.splitted[n]).filter((t=>""!==t)).toArray(),s,e);c[n]=t}}return i.Column.fromStrings("monomericMols",c)}function u(t,e,s=!1){let n="\n Datagrok macromolecule handler\n\n 0 0 0 0 0 0 999 V3000\nM V30 BEGIN CTAB\n";n+=`M V30 COUNTS ${t.length} ${t.length?t.length-1:0} 0 0 0\n`,n+="M V30 BEGIN ATOM\n";for(let i=0;i<t.length;i++)n+=s?`M V30 ${i+1} R${e.get(t[i])} 0.000 0.000 0 0\n`:`M V30 ${i+1} At 0.000 0.000 0 0 MASS=${e.get(t[i])}\n`;n+="M V30 END ATOM\n",n+="M V30 BEGIN BOND\n";for(let e=0;e<t.length-1;e++)n+=`M V30 ${e+1} 1 ${e+1} ${e+2}\n`;return n+="M V30 END BOND\n",n+="M V30 END CTAB\n",n+="M END",n}},2397:(t,e,s)=>{"use strict";s.d(e,{_package:()=>Dt,activityCliffs:()=>kt,getBioLib:()=>Ht,getHelmMonomers:()=>Ut,getMonomerLibHelper:()=>Gt,importFasta:()=>Vt,sequenceIdentityScoring:()=>$t,sequenceSimilarityScoring:()=>Yt,sequenceSpaceTopMenu:()=>Wt,toAtomicLevel:()=>Bt});var n=s(4469),i=s(3870),r=s(976),o=s(6414),a=s.n(o),l=s(585);const h="rgb(100,100,100)",c="#808080",u="rgb(0,0,0)",m=l.GU;var d,g;function f(t,e,s,n,i,r,o=h,a=0,l=!1,d=1,f="",p=!1,y=g.classic,w=[],b=0,T=null,C=[],S=null,A={}){i.textAlign="start";let v=r.substring(0),E=p?"":f;y===g.MSA&&(E="");let M=!0,N=!0,_="difference";null!=T&&null!=T.cell.column&&(M=T.cell.column.temp["color-code"]??!0,N=T.cell.column.temp["compare-with-current"]??!0,_=T.cell.column.temp["highlight-difference"]??"difference");const P=C[b];N&&C.length>0&&"difference"===_&&(d=v==P?.3:d),N&&C.length>0&&"equal"===_&&(d=v!=P?.3:d),null!=S&&(v=m(v,S));const L=v+E;A[L]??(A[L]=i.measureText(L));let R=A[L];A[v]??(A[v]=i.measureText(v));let x=A[v].width;A[E]??(A[E]=i.measureText(E));const I=A[E].width,O=n/2-(R.fontBoundingBoxAscent+R.fontBoundingBoxDescent)/2+1;function F(s,n){const r=M?o:u;i.fillStyle=r,i.globalAlpha=d,y===g.classic&&(i.fillText(v,t+s,e+O),i.fillStyle=c,i.fillText(E,t+n,e+O)),y===g.MSA&&i.fillText(v,t+s,e+O)}R=R.width,y===g.MSA&&(x=w[b],R=w[b]);const D=(w[b]??0)-(w[0]??0);if(l||R>s)return F(D,D+x),t+D+x+I;{const e=(s-R)/2;return F(e,e+x),t+D+e+x}}!function(t){t.maxMonomerLength=".mm.cellRenderer.maxMonomerLength"}(d||(d={})),function(t){t.MSA="MSA",t.classic="classic"}(g||(g={})),s(9611);var p,y,w=s(8447),b=s(7331),T=s(499);function C(t){const e=!a().enumerate(t).some((([e,s])=>e.length>1&&0!=s&&s!=t.length-1)),s=[],n=e?"":" ";for(const[e,i]of a().enumerate(t)){let r=e;i<t.length&&(r+=`${e?"":"-"}${n}`),s.push(r)}return[s,e]}(y=p||(p={})).long="long",y.short="short",s(3553),w.GU;class S extends r.GridCellRenderer{constructor(){super(...arguments),this.padding=5}get name(){return"sequence"}get cellType(){return"sequence"}get defaultHeight(){return 30}get defaultWidth(){return 230}onClick(t,e){t.cell.column.temp["current-word"]=t.cell.value,t.grid.invalidate()}onMouseMove(t,e){const s=t.cell.column.temp["bio-seqCol"];if(!s)return;const r=t.bounds,o=e.offsetX-t.gridColumn.left+(t.gridColumn.left-r.x),a=s.getPosition(t.tableRowIndex,o),l=s.getSeqMonList(t.tableRowIndex);if(null!==a&&a<l.length){const t=l[a],r=[i.div(t)];if(s._monomerStructureMap[t])r.push(s._monomerStructureMap[t]);else{const e=s.getMonomer(t);if(e){const i={autoCrop:!0,autoCropMargin:0,suppressChiralText:!0},o=n.chem.svgMol(e.smiles,void 0,void 0,i);r.push(o),s._monomerStructureMap[t]=o}}i.tooltip.show(i.divV(r),e.x+16,e.y+16)}else i.tooltip.hide()}render(t,e,s,n,i,o,l){const h=o.grid,c=o.cell.column,u=c.temp,m=u["monomer-width"];if("short"===(null!=m?m:"short")){const t=parseInt(c.getTag(d.maxMonomerLength));isNaN(t)&&Dt.properties?.MaxMonomerLength}let p=c.temp["bio-seqCol"];p||new cell_renderer_monomer_placer.A(h,c,(()=>{const t=T.Cn.getOrCreate(c);return{unitsHandler:t,monomerCharWidth:7,separatorWidth:t.isMsa()?8:0,monomerToShort:cell_renderer_monomerToShortFunction,monomerLengthLimit:50,monomerLib:Ht()}})),c.tags[".mm.cellRenderer.settingsChanged"]===cell_renderer_consts_rendererSettingsChangedState_true&&(u[".mm.cellRenderer.gapLength"],p.setMonomerLengthLimit(50),p.setSeparatorWidth(p.isMsa()?8:0),c.setTag(".mm.cellRenderer.settingsChanged",cell_renderer_consts_rendererSettingsChangedState_false));const[y,b]=p.getCellMonomerLengths(o.tableRowIndex);y.length,p.updated&&(u["bio-seqCol"]=p),t.save();try{const l=window.devicePixelRatio,h=-1!==o.gridRow?o.grid:null,m=o.cell.value,d=c.getTag("alphabet"),y=50;getUpdatedWidth(h,t,e,n,l),t.beginPath(),t.rect(e+this.padding,s+this.padding,n-this.padding-1,i-2*this.padding),t.clip(),t.font="12px monospace",t.textBaseline="top";const C=c.getTag(r.TAGS.UNITS),S=c.getTag("aligned"),A=(0,w.py)(d),v=c.getTag("separator")??"",E=n/5,M=T.Cn.getOrCreate(c).getSplitter(E),N=u["reference-sequence"],_=u["current-word"],P=M(null!=N&&""!=N?N:_??""),L=M(m);let R=cell_renderer_undefinedColor,x=g.classic;S&&S.includes("MSA")&&C==w.r2.SEPARATOR&&g.MSA;for(const[r,l]of a().enumerate(L)){A.get(r),t.fillStyle=cell_renderer_undefinedColor;const a=l===L.length-1;if(f(e+this.padding,s,n,i,t,r,R,0,!0,1,v,a,x,b,l,o,P,50,p._monomerLengthMap),y>n)break}}catch(t){const e=t instanceof Error?t.message:t?t.toString():"Error 'undefined'";Dt.logger.error(`Bio: MacromoleculeSequenceCellRenderer.render() error: ${e}`)}finally{t.restore()}}}class A extends r.GridCellRenderer{get name(){return"MacromoleculeDifferenceCR"}get cellType(){return constants.Of.MACROMOLECULE_DIFFERENCE}get defaultHeight(){return 30}get defaultWidth(){return 230}render(t,e,s,n,i,o,a){const h=window.devicePixelRatio,c=o.grid,u=o.cell,m=o.tableColumn,d=u.value??"",g=m.tags.separator,f=m.tags[r.TAGS.UNITS];getUpdatedWidth(c,t,e,n,h);const[p,y]=d.split("#"),w=(0,l.vU)(f,g);v(t,e,s,n,i,w(p),w(y),f)}}function v(t,e,s,n,i,r,o,l,h,c){if(r.length!==o.length){const t=function(t,e){let s=0,n=0;const i=t.length>e.length?t:e,r=t.length>e.length?e:t;for(let t=0;t<r.length;t++)i[t]===r[t]&&s++;const o=i.length-r.length;for(let t=i.length-1;t>o;t--)i[t]===r[t-o]&&n++;const a=new Array(Math.abs(t.length-e.length)).fill("");function l(t){return s>n?t.concat(a):a.concat(t)}return t.length>e.length?e=l(e):t=l(t),{subParts1:t,subParts2:e}}(a()(r).toArray(),a()(o).toArray());r=t.subParts1,o=t.subParts2}const u=t.measureText(C(r).join("")),m=t.measureText(C(o).join("")),d=Math.max(u.width,m.width);h&&(n=d+4*r.length,t.canvas.width=d+4*r.length);let g=Math.max(e,e+(n-(d+4*r.length))/2)+5;const p=Math.max(s,s+(i-28)/2);t.save(),t.beginPath(),t.rect(e,s,h?d+4*r.length:n,i),t.clip(),t.font="12px monospace",t.textBaseline="top";let y=b.UE.Color;"HELM"!=l&&(y=(0,w.py)(l.substring(l.length-2)));for(let e=0;e<r.length;e++){const s=r[e],a=o[e],l=y.get(s);if(s!=a){const r=y.get(a),o=f(g,p-7,n,i,t,s,l,0,!0),h=f(g,p+7,n,i,t,a,r,0,!0);g=Math.max(h,o),c&&(c[e]=E(s,a,l,r,p,7,i))}else g=f(g,p,n,i,t,s,l,0,!0,.5);g+=4}t.restore()}function E(t,e,s,n,i,r,o){const a=document.createElement("canvas"),l=a.getContext("2d");l.font="12px monospace";const h=l.measureText(C([t]).join("")).width,c=l.measureText(C([e]).join("")).width,u=Math.max(h,c);return a.height=o,a.width=u+4,l.font="12px monospace",l.textBaseline="top",f(0,i-r,u,o,l,t,s,0,!0),f(0,i+r,u,o,l,e,n,0,!0),a}var M,N,_,P=s(701),L=s(9298);!function(t){t.Unknown="unknown",t.FR="framework",t.CDR="cdr"}(M||(M={})),new class{constructor(){this.regionTypes=[M.CDR],this.chains=["Heavy","Light"],this.skipEmptyPositions=!1,this.fitWidth=!1,this.positionWidth=16,this.positionHeight=L.ES.Entropy}},s(833),function(t){t.STYLE="Style",t.BEHAVIOR="Behavior",t.LAYOUT="Layout",t.DATA="Data"}(N||(N={})),function(t){t.skipEmptyPositions="skipEmptyPositions",t.regionTypes="regionTypes",t.chains="chains",t.fitWidth="fitWidth",t.positionWidth="positionWidth",t.positionHeight="positionHeight"}(_||(_={}));class R extends r.JsViewer{constructor(){super(),this.viewed=!1,this.regionsFg=null,this.regionsRoot=null,this.isOpened=!1,this.panelNode=null,this.regions=[],this.viewPromise=Promise.resolve(),this.detachPromise=Promise.resolve(),this.setDataInProgress=!1,this.host=null,this.filterSourceInput=null,this.mainLayout=null,this.logos=[],this.viewSubs=[],this.calcSizeRequested=!1,this.skipEmptyPositions=this.bool(_.skipEmptyPositions,defaults.skipEmptyPositions,{category:N.DATA}),this.regionTypes=this.stringList(_.regionTypes,defaults.regionTypes,{category:N.DATA,choices:Object.values(vrt).filter((t=>t!=vrt.Unknown))}),this.chains=this.stringList(_.chains,defaults.chains,{category:N.DATA,choices:["Heavy","Light"]}),this.fitWidth=this.bool(_.fitWidth,defaults.fitWidth,{category:N.LAYOUT}),this.positionWidth=this.float(_.positionWidth,defaults.positionWidth,{category:N.LAYOUT,editor:"slider",min:0,max:64,description:"Internal WebLogo viewers property width of position."}),this.positionHeight=this.string(_.positionHeight,defaults.positionHeight,{category:N.LAYOUT,choices:Object.keys(L.ES)})}async init(){this.subs.push((0,P.fromEvent)(this.root,"mousemove").subscribe(this.rootOnMouseMove.bind(this)))}detach(){if(this.setDataInProgress)return;const t=super.detach.bind(this);this.detachPromise=this.detachPromise.then((async()=>{await this.viewPromise,this.viewed&&(await this.destroyView("detach"),this.viewed=!1),t()}))}onTableAttached(){super.onTableAttached(),this.setData(this.dataFrame,this.regions)}onPropertyChanged(t){if(super.onPropertyChanged(t),t){switch(t.name){case _.regionTypes:case _.chains:this.setData(this.dataFrame,this.regions)}switch(t.name){case _.skipEmptyPositions:for(let t=0;t<this.logos.length;++t)for(const e of this.chains)this.logos[t][e].setOptions({[web_logo_viewer.bo.skipEmptyPositions]:this.skipEmptyPositions});this.calcSize();break;case _.fitWidth:case _.positionWidth:this.calcSize();break;case _.positionHeight:for(let t=0;t<this.logos.length;++t)for(const e of this.chains)this.logos[t][e].setOptions({[web_logo_viewer.bo.positionHeight]:this.positionHeight});this.calcSize();break;default:this.setData(this.dataFrame,this.regions)}}else console.warn("Bio: VdRegionsViewer.onPropertyChanged() property is null")}setData(t,e){this.setDataInProgress||(this.setDataInProgress=!0,Dt.logger.debug("Bio: VdRegionsViewer.setData()"),this.viewPromise=this.viewPromise.then((async()=>{this.viewed&&(await this.destroyView("setData"),this.viewed=!1)})).then((async()=>{await this.detachPromise,this.regions=e,this.dataFrame.dart!==t.dart&&(this.dataFrame=t)})).then((async()=>{this.viewed||(await this.buildView("setData"),this.viewed=!0)})).catch((t=>{const e=t instanceof Error?t.message:t.toString(),s=t instanceof Error?t.stack:void 0;n.shell.error(e),Dt.logger.error(e,void 0,s)})).finally((()=>{this.setDataInProgress=!1})))}async destroyView(t){Dt.logger.debug(`Bio: VdRegionsViewer.destroyView( mainLayout = ${this.mainLayout?"value":"none"} ), purpose = '${t}'`),this.filterSourceInput&&i.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){Dt.logger.debug(`Bio: VdRegionsViewer.buildView() begin, purpose = '${t}'`);const e=this.regions.filter((t=>this.regionTypes.includes(t.type))),s=Array.from(new Set(e.map((t=>t.order)))).sort(),n=[];for(let t=0;t<s.length;t++)for(const i of this.chains){const r=e.find((e=>e.order==s[t]&&e.chain==i));n.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});return e.onSizeChanged.subscribe((()=>{this.calcSize()})),[t,i,e]})())}const r=await Promise.all(n);this.logos=new Array(s.length);for(let t=0;t<s.length;++t)this.logos[t]={};for(const[t,e,s]of r)this.logos[t][e]=s,this.viewSubs.push(s.onFreqsCalculated.subscribe((()=>{this.calcSize()})));this.mainLayout=i.table(this.chains,(t=>[...s.length>0?[i.div(t,{style:{transform:"rotate(-90deg)",font:"12px Roboto, Roboto Local, sans-serif",textAlign:"center",width:"16px",marginTop:"24px",marginLeft:"6px"}})]:[],...[...Array(s.length).keys()].map((e=>{const s=this.logos[e][t];return s.root.style.height="100%",i.div([s.root],{style:{marginTop:"4px",marginBottom:"4px"}})}))]),["",...[...Array(s.length).keys()].map((t=>e.find((e=>e.order==s[t]&&e.chain==this.chains[0])).name||"Name"))]),this.mainLayout.className="mlb-vd-regions-viewer-table2",this.filterSourceInput=i.boolInput("",!1,this.filterSourceInputOnValueChanged.bind(this)),this.filterSourceInput.root.style.position="absolute",this.filterSourceInput.root.style.left="10px",this.filterSourceInput.root.style.top="-3px",i.tooltip.bind(this.filterSourceInput.input,"Check to filter sequences for selected VRs"),Math.ceil(255*Math.random()).toString(16),this.host=i.div([this.mainLayout,this.filterSourceInput.root],{}),this.root.appendChild(this.host),this.root.style.overflowX="auto",this.calcSize(),this.viewSubs.push(i.onSizeChanged(this.root).subscribe(this.rootOnSizeChanged.bind(this))),Dt.logger.debug("Bio: VdRegionsViewer.buildView() end")}calcSize(){Dt.logger.debug("Bio: VdRegionsViewer.calcSize(), start");const t=()=>{if(!this.host)return;const t=(this.root.clientHeight-54)/this.chains.length;for(let e=0;e<this.logos.length;e++){for(const s of this.chains)this.logos[e][s].root.style.height=`${t}px`;Math.max(...this.chains.map((t=>this.logos[e][t].Length)))}if(this.fitWidth)this.logos.length,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({[web_logo_viewer.bo.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=1==this.filterSourceInput.value?L.Ct.Selected:L.Ct.Filtered;for(let e=0;e<this.logos.length;e++)for(let s=0;s<this.chains.length;s++){const n=this.chains[s];this.logos[e][n].setOptions({[web_logo_viewer.bo.filterSource]:t})}}}var x=s(7656),I=s(7983),O=s(489);async function F(t){const e=T.Cn.getOrCreate(t.seqCol),s=e.isMsa()?O.U.HAMMING:O.U.LEVENSHTEIN,n=t.seqCol.toList();if(e.getAlphabetIsMultichar()){const s=e.getSplitter(),i=n.length;let r=36;const o=new Map;for(let e=0;e<i;e++){const i=n[e];if(null===n[e]||t.seqCol.isNone(e)){n[e]=null;continue}n[e]="";const a=s(i);for(let t=0;t<a.length;t++){const s=a[t];o.has(s)||(o.set(s,String.fromCharCode(r)),r++),n[e]+=o.get(s)}}}const i=await(0,x.I)(n,t.methodName,s,t.options,!0),o=t.embedAxesNames.map(((t,e)=>r.Column.fromFloat32Array(t,i.embedding[e])));return{distance:i.distance,coordinates:new r.ColumnList(o)}}function D(t){const e=["Embed_X","Embed_Y"],s=t.columns.names().filter((t=>t.includes(e[0]))).length+1;return e.map((t=>`${t}_${s}`))}var G=s(5697),H=s(3379),k=s.n(H),W=s(7795),B=s.n(W),V=s(569),U=s.n(V),$=s(3565),Y=s.n($),K=s(9216),q=s.n(K),Z=s(4589),z=s.n(Z),X=s(9414),j={};j.styleTagTransform=z(),j.setAttributes=Y(),j.insert=U().bind(null,"head"),j.domAPI=B(),j.insertStyleElement=q(),k()(X.Z,j),X.Z&&X.Z.locals&&X.Z.locals;var Q=s(3914),J=s(6254);let tt=0;const et="cliffsDf",st=new P.Subject,nt="act_diff",it="sali",rt="sim",ot="line_index",at=["1_seq","2_seq"],lt="filterCliffs";function ht(t,e,s){const n=e.getBoundingClientRect(),i=t.clientX-n.left,r=t.clientY-n.top;let o=null,a=0;for(const t of s){const e=Math.abs(Math.hypot(t.a[0]-i,t.a[1]-r)+Math.hypot(t.b[0]-i,t.b[1]-r)-Math.hypot(t.a[0]-t.b[0],t.a[1]-t.b[1]));(!a&&e<2||e<a)&&(a=e,o=t)}return o}var ct=s(1040);async function ut(t,e,s,i,o){e.version!==e.temp["last-invalidated-version"]&&await(0,I.HV)(e,!1);const a=r.DataFrame.create(e.length);return a.columns.addNewString(i).init((t=>e.temp["monomeric-mols"].get(t))),await n.functions.call("Chem:getChemSimilaritiesMatrix",{dim:t,col:e.temp["monomeric-mols"],df:a,colName:i,simArr:o})}function mt(t){const e=i.divH([]),s=i.divV([i.divText(t.seqCol.name),i.divText(t.activityCol.name)]);return s.style.fontWeight="bold",s.style.display="flex",s.style.justifyContent="space-between",e.append(s),t.line.mols.forEach(((s,n)=>{const r=i.divText(t.activityCol.get(s).toFixed(2));r.style.display="flex",r.style.justifyContent="left",r.style.paddingLeft="30px",e.append(i.divV([i.divText(t.seqCol.get(s)),r]))})),e}function dt(t){const e=i.div();e.append(i.divText(t.seqCol.name,{style:{fontWeight:"bold"}}));const s=new Array(2),n=new Array(2);t.line.mols.forEach(((e,i)=>{s[i]=t.seqCol.get(e),n[i]=t.activityCol.get(e)}));const r={},o=T.Cn.getOrCreate(t.seqCol),a=o.getSplitter(),l=function(t,e,s,n){const i=document.createElement("canvas"),r=i.getContext("2d");return i.height=30,v(r,0,0,0,30,t,e,s,!0,n),i}(a(s[0]),a(s[1]),o.units,r);return e.append(i.div(l,{style:{width:"300px",overflow:"scroll"}})),e.append(function(t){const e=i.div();if(Object.keys(t).length>0){const s=i.divV([]);s.append(i.divH([i.divText("Pos",{style:{fontWeight:"bold",width:"30px",borderBottom:"1px solid"}}),i.divText("Difference",{style:{fontWeight:"bold",borderBottom:"1px solid"}})]));for(const e of Object.keys(t))t[e].style.borderBottom="1px solid lightgray",s.append(i.divH([i.divText((parseInt(e)+1).toString(),{style:{width:"30px",borderBottom:"1px solid lightgray"}}),t[e]]));e.append(s)}return e}(r)),e.append(gt("Activity delta",Math.abs(n[0]-n[1]))),e.append(gt("Cliff",t.sali)),e}function gt(t,e){return i.divH([i.divText(`${t}: `,{style:{fontWeight:"bold",paddingRight:"5px"}}),i.divText(e.toFixed(2))],{style:{paddingTop:"10px"}})}function ft(t,e){const s=r.Column.string("seq_diff",t.rowCount).init((s=>`${t.get(e[0],s)}#${t.get(e[1],s)}`));s.semType="MacromoleculeDifference",s.setTag(r.TAGS.UNITS,t.col(e[0]).getTag(r.TAGS.UNITS)),s.setTag("separator",t.col(e[0]).getTag("separator")),t.columns.add(s);const n=t.plot.grid();return n.col(e[0]).visible=!1,n.col(e[1]).visible=!1,n}s(7861),s(4004);var pt=s(7228),yt=s(8601),wt=s(5226);s(9133);class bt extends r.JsViewer{constructor(t){super(),this.name="",this.metricsProperties=["distanceMetric","fingerprint"],this.fingerprintChoices=["Morgan","Pattern"],this.initialized=!1,this.tags=[r.TAGS.UNITS,"aligned","separator","alphabet"],this.preComputeDistanceMatrix=!1,this.renderPromise=Promise.resolve(),this.fingerprint=this.string("fingerprint",this.fingerprintChoices[0],{choices:this.fingerprintChoices}),this.limit=this.int("limit",10),this.distanceMetric=this.string("distanceMetric",G.kg[0],{choices:G.kg}),this.moleculeColumnName=this.string("moleculeColumnName"),this.name=t}init(){this.initialized=!0}detach(){this.subs.forEach((t=>t.unsubscribe()))}async onTableAttached(){if(this.init(),this.dataFrame){this.preComputeDistanceMatrix=this.dataFrame.rowCount<=22e3,this.subs.push(r.debounce(this.dataFrame.onRowsRemoved,50).subscribe((t=>this.render(!0))));const t="diversity"!==this.name;this.subs.push(r.debounce(this.dataFrame.onCurrentRowChanged,50).subscribe((e=>this.render(t)))),this.subs.push(r.debounce(this.dataFrame.selection.onChanged,50).subscribe((t=>this.render(!1)))),this.subs.push(r.debounce(i.onSizeChanged(this.root),50).subscribe((t=>this.render(!1)))),this.moleculeColumn=this.dataFrame.columns.bySemType(r.SEMTYPE.MACROMOLECULE),this.moleculeColumnName=this.moleculeColumn?.name,this.getProperty("limit").fromOptions({min:1,max:this.dataFrame.rowCount})}this.render()}onPropertyChanged(t){if(super.onPropertyChanged(t),this.initialized){if("moleculeColumnName"===t.name){const e=this.dataFrame.col(t.get(this));e.semType===r.SEMTYPE.MACROMOLECULE&&(this.moleculeColumn=e)}this.render()}}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.dataFrame&&this.moleculeColumnName&&this.dataFrame.col(this.moleculeColumnName).semType!==r.SEMTYPE.MACROMOLECULE&&(n.shell.error(`${this.moleculeColumnName} is not Macromolecule type`),1))}}s(7241),s(4293),s(9943),s(4413);var Tt=s(1061),Ct=s(5490),St=s(116);r.SEMTYPE.MOLECULE,r.SEMTYPE.MACROMOLECULE;var At,vt=s(8457);async function Et(t,e,s,n){const i=(0,vt.O)(e),o=(0,l.vU)(e.getTag(r.TAGS.UNITS),e.getTag("separator"))(s),a=n===At.IDENTITY?function(t,e){const s=e.columns.length,n=new Array(s),i=new Array(s),o=new Array(s);for(let r=0;r<s;++r){const s=e.columns.byIndex(r);n[r]=s.getRawData(),i[r]=s.categories.indexOf(""),o[r]=s.categories.indexOf(t[r]??"")}const a=r.Column.float("Identity",e.rowCount),l=a.getRawData();for(let s=0;s<e.rowCount;++s){l[s]=0;for(let e=0;e<t.length;++e)n[e][s]===o[e]&&++l[s];l[s]/=t.length}return a}(o,i):n===At.SIMILARITY?await async function(t,e){const s=e.columns.toList();return await(0,pt.Qx)(s,t)}(o,i):null;if(null===a)throw new Error(`In bio library: Unkown sequence scoring method: ${n}`);return a.name=t.columns.getUnusedName(a.name),t.columns.add(a),a}!function(t){t.IDENTITY="identity",t.SIMILARITY="similarity"}(At||(At={}));var Mt,Nt=function(t,e,s,n){return new(s||(s=Promise))((function(i,r){function o(t){try{l(n.next(t))}catch(t){r(t)}}function a(t){try{l(n.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(o,a)}l((n=n.apply(t,e||[])).next())}))};class _t{constructor(t,e,s=!1,n){var 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=i.div([],{id:"demo-script",classes:"tutorials-root tutorials-track demo-app-script"}),this._steps=[],this._mainHeader=i.panel([],"tutorials-main-header"),this._header=i.h2(""),this._headerDiv=i.divH([],"tutorials-root-header"),this._stopStartBtn=i.button(i.iconFA("pause"),(()=>this._changeStopState()),"Play / pause"),this._restartBtn=i.button(i.iconFA("redo"),(()=>this._restartScript()),"Restart"),this._nextStepBtn=i.button(i.iconFA("play"),(()=>{this._isStepProcessed||this._nextStep()}),"Next step"),this._activity=i.panel([],"tutorials-root-description"),this._progressDiv=i.divV([],"tutorials-root-progress"),this._progress=i.element("progress"),this._progressSteps=i.divText(""),this._closeBtn=i.button(i.iconFA("chevron-left"),(()=>this._closeDock()),"Back to demo"),this.name=t,this.description=e,this._isAutomatic=s,this._autoStartFirstStep=null!==(r=null==n?void 0:n.autoStartFirstStep)&&void 0!==r&&r,this._progress.max=0,this._progress.value=1,_t.currentObject=this}get steps(){return this._steps}get stepNumber(){return this._steps.length}_addHeader(){this._createHeaderDiv(),this._createProgressDiv(),this._mainHeader.append(this._headerDiv,this._progressDiv)}_createHeaderDiv(){this._header.innerText=this.name,this._headerDiv.append(this._closeBtn),this._headerDiv.append(this._header),this._nextStepBtn.firstChild.className="grok-icon fas fa-play",this._headerDiv.append(this._isAutomatic?this._stopStartBtn:this._nextStepBtn)}_createProgressDiv(){this._progress.max=this.stepNumber,this._progressDiv.append(this._progress),this._progressSteps=i.divText(`Step: ${this._progress.value} of ${this.stepNumber}`),this._progressDiv.append(this._progressSteps)}_addDescription(){var t;this._activity.append(i.div(this.description,"tutorials-root-description"));for(let e=0;e<this.stepNumber;e++){let s=i.iconFA("clock");this._isAutomatic||0===e&&(s=i.iconFA("play",(()=>this._nextStep()),"Next step"),s.className="grok-icon fas fa-play");const n=i.div(this._steps[e].name,"grok-tutorial-entry-instruction"),r=i.div(null===(t=this._steps[e].options)||void 0===t?void 0:t.description,"grok-tutorial-step-description hidden"),o=i.divH([s,n],"grok-tutorial-entry");this._activity.append(o,r)}}_initRoot(){var t,e,s;n.shell.windows.showContextPanel=!0,n.shell.windows.showHelp=!1;const i=Array.from(n.shell.dockManager.rootNode.children)[0];this._node=n.shell.dockManager.dock(this._root,r.DOCK_TYPE.FILL,i,""),(null===(e=null===(t=i.parent.container.containerElement.firstElementChild)||void 0===t?void 0:t.lastElementChild)||void 0===e?void 0:e.classList.contains("tab-handle-list-container"))&&(null===(s=i.parent.container.containerElement.firstElementChild)||void 0===s||s.lastElementChild.remove()),this._node.container.containerElement.classList.add("tutorials-demo-script-container"),this._addHeader(),this._root.append(this._mainHeader),this._addDescription(),this._root.append(this._activity)}_nextStep(){var t,e;return Nt(this,void 0,void 0,(function*(){this._isStepProcessed=!0,this._isAutomatic||(this._nextStepBtn.classList.add("disabled"),this._nextStepBtn.firstChild.classList.add("fa-disabled"));const s=this._activity.getElementsByClassName("grok-tutorial-entry")[this._currentStep],n=this._activity.getElementsByClassName("grok-icon")[this._currentStep],r=this._activity.getElementsByClassName("grok-tutorial-step-description")[this._currentStep];n.className="grok-icon far fa-spinner-third fa-spin",r.classList.remove("hidden"),r.classList.add("visible");const o=s,a=(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;yield this._steps[this._currentStep].func(),this._scrollTo(this._root,o.offsetTop-this._mainHeader.offsetHeight),this._isAutomatic&&(yield this._countdown(s,n,a),yield(0,Tt.gw)(a));const l=i.iconFA("check");if(n.replaceWith(l),l.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=i.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")}}else this._isAutomatic?this._stopStartBtn.replaceWith(this._restartBtn):this._nextStepBtn.replaceWith(this._restartBtn)}))}_startScript(){return Nt(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,s){return Nt(this,void 0,void 0,(function*(){const n=i.div([],"demo-script-countdown");e.classList.add("hidden");let r=s/1e3;const o=this._createSVGIndicator(r);n.append(o),t.prepend(n);const a=setInterval((()=>{r--,0===r&&(clearInterval(a),n.remove(),e.classList.remove("hidden"),e.classList.add("visible"))}),1e3)}))}_createSVGIndicator(t){const e=document.createElementNS("http://www.w3.org/2000/svg","svg"),s=document.createElementNS("http://www.w3.org/2000/svg","circle");return s.setAttributeNS(null,"cx","7"),s.setAttributeNS(null,"cy","7"),s.setAttributeNS(null,"r","6"),s.setAttributeNS(null,"style",`animation: countdown ${t}s linear infinite forwards`),e.append(s),e}_changeStopState(){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||this._startScript())}_restartScript(){n.shell.dockManager.close(this._node),n.shell.closeAll(),this._clearRoot(),this._setInitParams(),this.start()}_clearRoot(){this._root=i.div([],{id:"demo-script",classes:"tutorials-root tutorials-track demo-app-script"}),this._mainHeader=i.panel([],"tutorials-main-header"),this._header=i.h2(""),this._headerDiv=i.divH([],"tutorials-root-header"),this._activity=i.panel([],"tutorials-root-description"),this._progressDiv=i.divV([],"tutorials-root-progress"),this._progress=i.element("progress"),this._progressSteps=i.divText(""),this._progress.max=0,this._progress.value=1}_setInitParams(){this._currentStep=0,this._isStopped=!1,this._isCancelled=!1,this._stopStartBtn.getElementsByClassName("grok-icon")[0].className="grok-icon fal fa-pause",this._nextStepBtn.classList.remove("disabled")}_closeDock(){n.shell.dockManager.close(this._node),this.cancelScript()}cancelScript(){this._isCancelled=!0,_t.currentObject=null}step(t,e,s){return this._steps[this.steps.length]={name:t,func:e,options:s},this}start(){return Nt(this,void 0,void 0,(function*(){this._initRoot(),n.shell.newView(this.name),this._isAutomatic?this._startScript():this._autoStartFirstStep&&(yield this._nextStep())}))}}_t.currentObject=null,function(t){t.X="Embed_X",t.Y="Embed_Y"}(Mt||(Mt={})),s(1811),s(3336),s(8341);var Pt=s(2568);s(525),s(9416),new class{constructor(){this.tooltipHandlerTemp="tooltip-handler.Monomer"}};class Lt extends r.GridCellRenderer{get name(){return constants.Of.MONOMER}get cellType(){return constants.Of.MONOMER}get defaultHeight(){return 15}get defaultWidth(){return 40}render(t,e,s,n,i,r,o){if(r.gridRow<0)return;MonomerTooltipHandler.getOrCreate(r.gridColumn),t.font="12px monospace",t.textBaseline="middle",t.textAlign="center";const a=(0,w.py)(r.cell.column.getTag("alphabet")),l=r.cell.value;if(!l)return;const h=a.get(l);t.fillStyle=h,t.fillText((0,w.GU)(l,6),e+n/2,s+i/2,n)}}class Rt extends r.Package{constructor(){super(...arguments),this._initialized=!1}get properties(){return this._properties}set properties(t){this._properties=t}get initialized(){return this._initialized}completeInit(){this._initialized=!0}handleErrorUI(t){const e=t instanceof Error?t.message:t.toString(),s=t instanceof Error?t.stack:void 0;n.shell.error(e),this.logger.error(e,void 0,s)}}class xt extends r.Widget{constructor(t){super(i.div([],{}));const e=Object.assign({},...t.map((t=>({[t.name]:t}))));this.maxMonomerLengthProp=e.MaxMonomerLength,this.tooltipWebLogo=e.TooltipWebLogo,this.defaultSeparator=e.DefaultSeparator}async init(){const t=i.intInput("Max monomer length",Dt.properties.MaxMonomerLength,(t=>{Dt.properties.MaxMonomerLength=t})),e=i.boolInput("Tooltip WebLogo",Dt.properties.TooltipWebLogo,(t=>{Dt.properties.TooltipWebLogo=t})),s=i.choiceInput("Default Separator",Dt.properties.DefaultSeparator,[".","/","-"],(t=>{Dt.properties.DefaultSeparator=t}));this.root.appendChild(i.form([t,e,s]))}}var It=s(5362),Ot={};Ot.styleTagTransform=z(),Ot.setAttributes=Y(),Ot.insert=U().bind(null,"head"),Ot.domAPI=B(),Ot.insertStyleElement=q(),k()(It.Z,Ot),It.Z&&It.Z.locals&&It.Z.locals;class Ft extends r.Widget{constructor(t){super(i.divV([])),this.viewed=!1,this.seqCol=t}async init(){const t=T.Cn.getOrCreate(this.seqCol),e=Dt.properties.TooltipWebLogo,s=this.seqCol.getTag(L.DX.tooltipWebLogo);!1===e||["false","off","disable","disabled"].includes(s)||(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}),this.wlViewer.root.style.height="50px",this.root.appendChild(this.wlViewer.root),this.root.style.width="100%")}}r.DataFrame.fromCsv("seq,value\nATCCGTCGT,0.5\nTGTTCGTCA,0.4\nATGGTCGTA,0.7\nATCCGTGCA,0.1"),["1","1A","1C","2","4","4A","4B","5","6"].join(w.CI);const Dt=new Rt;function Gt(){return Ct.NT.instance}function Ht(){return Ct.NT.instance.getBioLib()}async function kt(t,e,o,a,l,h){if(!(0,Pt.n)(e,"Activity Cliffs"))return;const c=D(t),u={units:e.getTag(r.TAGS.UNITS),aligned:e.getTag("aligned"),separator:e.getTag("separator"),alphabet:e.getTag("alphabet")},m=T.Cn.getOrCreate(e);let d=ct.gk.Tanimoto,g=e;if(m.isFasta()||m.isSeparator()&&m.alphabet&&"UN"!==m.alphabet)if(m.isFasta())d=m.getDistanceFunctionName();else{g=m.convert(w.r2.FASTA);const t=T.Cn.getOrCreate(g);d=t.getDistanceFunctionName(),u.units=w.r2.FASTA}const f=async()=>await async function(t,e,o,a,l,h,c,u,m,d,g,f,p,y,w,b,T,C){tt++;const S=c/100,A=o??e;let v=!1,E=!1;const M={};let N,_;const P={seqCol:A,methodName:m,similarityMetric:u,embedAxesNames:a,options:T},{distance:L,coordinates:R}=await f(P);for(const e of R)t.columns.add(e);let x=L;const I=Object.values(O.U).map((t=>t.toString())).includes(u);I&&!L&&(x=Q.H.calc(e.toList(),O.o[u]()).data);const F=function(t,e,s){const n=[],i=[],r=[],o=[],a=new Set;for(let l=0;l!=t.length;++l)for(let h=0;h!=t.length-l;++h){const c=t[l]?t[l].get(h):0;if(c>=e){r.push(l),o.push(l+h+1),a.add(l),a.add(l+h+1),n.push(c);const t=Math.abs(s.get(l)-s.get(l+h+1));i.push(1!=c?t/(1-c):1/0)}}return{simVals:n,saliVals:i,n1:r,n2:o,cliffsMolIds:a}}(await async function(t,e,s,n){const i=t.categories,o=t.getRawData(),a=r.Column.string("seq",t.length).init((t=>i[o[t]])),l=r.DataFrame.fromColumns([a]),h=t.length;let c=Array(h-1);return s&&e?function(t,e,s){const n=(0,J.y)(t);for(let i=0;i<t-1;++i){const o=new Float32Array(t-i-1).fill(0);for(let s=i+1;s<t;++s){const t=n(i,s);o[s-i-1]=e[t]===r.FLOAT_NULL?0:(0,G.Om)(e[t])}s[i]=r.Column.fromFloat32Array("similarity",o)}}(h,e,c):c=await n(h,t,l,"seq",c),c}(A,x,I,p),S,h),D=function(t,e,s,n,i,o){const a=new Array(t).fill(0);for(let t=0;t!=s.length;++t)e[t]!=1/0&&(o.get(s[t])>o.get(n[t])?a[s[t]]+=e[t]:a[n[t]]+=e[t]);return r.Column.fromList("double",`sali_${i[0].substring(i[0].lastIndexOf("_"))}`,a)}(A.length,F.saliVals,F.n1,F.n2,a,h);t.columns.add(D);const H=function(t,e){const s="containsCliff",n=t.columns.names().filter((t=>t.includes(s))).length+1,i=`${s}_${n}`;return r.Column.bool(i,t.rowCount).init((t=>e.has(t)))}(t,F.cliffsMolIds);t.columns.add(H);const k=function(t){const e=t.filter((t=>t!==1/0)),s=Math.min(...e);return{max:Math.max(...e),min:s}}(F.saliVals),W=.8/(k.max-k.min),B=n.shell.getTableView(t.name);B.grid.columns.byName(H.name).visible=!1;const V=B.addViewer(r.VIEWER.SCATTER_PLOT,{xColumnName:a[0],yColumnName:a[1],size:D.name,color:h.name,showXSelector:!1,showYSelector:!1,showSizeSelector:!1,showColorSelector:!1,markerMinSize:5,markerMaxSize:25,title:l}),U=V.getInfo().canvas,$=function(t,e,s,n,i){const o=new Array(t.n1.length).fill(null);for(let e=0;e<t.n1.length;e++){const s=t.n1[e],n=t.n2[e];o[e]={id:e,mols:[s,n],selected:!1,a:[],b:[]}}const a=r.DataFrame.create(o.length);return at.forEach(((t,s)=>{a.columns.addNewString(t).init((t=>e.get(o[t].mols[s]))),function(t,e){Object.keys(e).forEach((s=>{t.tags[s]=e[s]}))}(a.col(t),i),a.col(t).semType=n})),a.columns.addNewFloat(nt).init((t=>Math.abs(s.get(o[t].mols[0])-s.get(o[t].mols[1])))),a.columns.addNewInt(ot).init((t=>t)),a.columns.addNewFloat(it).init((e=>t.saliVals[e])),a.columns.addNewFloat(rt).init((e=>t.simVals[e])),a.name=`${et}${tt}`,{lines:o,linesDf:a}}(F,e,h,d,g),Y=b?b($.linesDf,at).sort([it],[!1]):$.linesDf.plot.grid().sort([it],[!1]);t.temp[".cliffsDfGrid"]=Y;const K=i.button(`${$.linesDf.rowCount} cliffs`,(()=>{B.dockManager.dock(Y,"down",null,"Activity cliffs",C??.2)}));K.classList.add("scatter_plot_link","cliffs_grid"),V.root.append(K);const q=i.switchInput("Show only cliffs",!1,(()=>{q.value?(V.dataFrame.setTag(lt,H.name),t.rows.match({[H.name]:!0}).filter(),st.next(H.name)):(V.dataFrame.setTag(lt,""),t.filter.setAll(!0,!0),st.next(""))}));q.root.classList.add("scatter_plot_link","show_only_cliffs"),V.root.append(q.root),st.subscribe((t=>{q.enabled=""===t||t===H.name}));const Z=n.events.onViewerClosed.subscribe((t=>{t.args.viewer===V&&(B.dockManager.close(Y.root),Z.unsubscribe(),B.subs=B.subs.filter((t=>t!==Z)))}));return B.subs.push(Z),$.linesDf.onCurrentCellChanged.subscribe((()=>{v=!0;const s=$.linesDf.currentCol&&$.linesDf.currentCol.name===at[1]?1:0,r=-1!==$.linesDf.currentRowIdx?$.lines[$.linesDf.currentRowIdx]:null;V.dataFrame.currentRowIdx=r?r.mols[s]:-1,V.dataFrame.filter.set(0,!$.lines[0].selected),V.dataFrame.filter.set(0,$.lines[0].selected),r&&setTimeout((()=>{!function(t,e,s,r,o,a,l,h){const c=e.getPane("Cliff Details");i.empty(c.root);const u=h({cashedData:s,line:r,df:t,seqCol:o,activityCol:a,sali:l});c.root.append(u),setTimeout((()=>{n.shell.o=e.root}),500)}(t,N,M,r,e,h,$.linesDf.get(it,r.id),w);const s=V.dataFrame.getSortedOrder(B.grid.sortByColumns,B.grid.sortTypes);B.grid.scrollToCell(e.name,s.indexOf(V.dataFrame.currentRowIdx))}),1e3)})),$.linesDf.onSelectionChanged.subscribe((e=>{if(!1===$.linesDf.selection.anyTrue)$.lines.forEach((t=>{t.selected=!1}));else if(-1!==$.linesDf.mouseOverRowIdx){const t=$.lines[$.linesDf.mouseOverRowIdx];t.selected=!t.selected}setTimeout((()=>{const e=r.BitSet.create(t.rowCount);$.lines.forEach((t=>{t.selected&&t.mols.forEach((s=>{e.set(s,t.selected,!0)}))})),t.selection.copyFrom(e),B.grid.invalidate()}),300)})),t.onSelectionChanged.subscribe((e=>{E?E=!1:!1===t.selection.anyTrue&&"number"==typeof e&&($.lines.forEach((t=>{t.selected=!1})),Y.dataFrame.selection.setAll(!1,!1),Y.invalidate())})),U.addEventListener("mousemove",(function(n){clearTimeout(_),_=s.g.setTimeout((function(){const s=ht(n,U,$.lines);s&&-1===t.mouseOverRowIdx&&i.tooltip.show(y({cashedData:M,line:s,df:t,seqCol:e,activityCol:h}),n.clientX,n.clientY)}),500)})),U.addEventListener("mousedown",(function(e){E=!0;const s=ht(e,U,$.lines);if(s&&-1===t.mouseOverRowIdx){e.ctrlKey?(s.selected=!s.selected,$.linesDf.selection.set(s.id,s.selected)):$.linesDf.currentRowIdx!==s.id&&($.linesDf.currentRowIdx=s.id,t.currentRowIdx=s.mols[0],t.filter.set(0,!$.lines[0].selected),t.filter.set(0,$.lines[0].selected));const n=$.linesDf.getSortedOrder(Y.sortByColumns,Y.sortTypes);Y.scrollToCell(at[0],n.indexOf(s.id))}})),V.onEvent("d4-before-draw-scene").subscribe((e=>{const s=function(t,e,s,n,i,r,o){const a=n.lines,l=t.getInfo().canvas.getContext("2d"),h=t.dataFrame.columns.byName(e),c=t.dataFrame.columns.byName(s);for(let e=0;e<a.length;e++){const s=t.worldToScreen(h.get(a[e].mols[0]),c.get(a[e].mols[0])),u=t.worldToScreen(h.get(a[e].mols[1]),c.get(a[e].mols[1]));a[e].a=[s.x,s.y],a[e].b=[u.x,u.y];const m=new Path2D;m.moveTo(a[e].a[0],a[e].a[1]);const d=a[e].selected?"255,255,0":"0,128,0",g=i[e]===1/0?1:.2+(i[e]-o)*r;l.strokeStyle=`rgba(${d},${g})`,l.lineWidth=a[e].id===n.linesDf.currentRowIdx?3:1,m.lineTo(a[e].b[0],a[e].b[1]),l.stroke(m)}return a}(V,a[0],a[1],$,F.saliVals,W,k.min);if(v){const t=s[$.linesDf.currentRowIdx];setTimeout((()=>{const{zoomLeft:e,zoomRight:s,zoomTop:n,zoomBottom:i}=function(t,e,s,n,i,r){const o=Math.abs(s-i),a=Math.abs(n-r),l=t/o,h=e/a,c=Math.min(l,h),u=t/c*5,m=e/c*5,d=(s<i?s:i)+o/2-u/2,g=(n>r?n:r)-a/2+m/2;return{zoomLeft:d,zoomRight:d+u,zoomTop:g,zoomBottom:g-m}}(V.viewport.width,V.viewport.height,V.dataFrame.get(a[0],t.mols[0]),V.dataFrame.get(a[1],t.mols[0]),V.dataFrame.get(a[0],t.mols[1]),V.dataFrame.get(a[1],t.mols[1]));V.zoom(e,n,s,i)}),300),v=!1}q.value?t.rows.match({[H.name]:!0}).filter():!0===q.enabled&&t.filter.setAll(!0,!1)})),V.addProperty("similarityLimit","double",S),N=function(){const t=i.accordion(),e=i.element("i");return e.className="grok-icon svg-icon svg-view-layout",t.addTitle(i.span([e,i.label("Activity cliffs")])),t.addPane("Cliff Details",(()=>i.divText("Cliff has not been selected")),!0),n.shell.o=t.root,t}(),V}(t,g,null,c,"Activity cliffs",o,a,d,l,r.SEMTYPE.MACROMOLECULE,u,F,ut,mt,dt,ft,h),p=l===St.AL.UMAP?5e3:2e3;if(t.rowCount>2e4)n.shell.warning("Too many rows, maximum for sequence activity cliffs is 20000");else{if(!(t.rowCount>p))return await f();i.dialog().add(i.divText("Activity cliffs analysis might take several minutes.\n Do you want to continue?")).onOK((async()=>{const t=r.TaskBarProgressIndicator.create("Running sequence activity cliffs ..."),e=await f();return t.close(),e})).show()}}async function Wt(t,e,s,o=ct.gk.Tanimoto,a,l,h){if(await(0,Tt.gw)(10),!(0,Pt.n)(e,"Sequence space"))return;const c=D(t),u=r.DataFrame.fromColumns([e]).clone(),m=function(t,e){const s=e.categories.map(((t,e)=>t?null:e)).filter((t=>null!==t)),n=[...e.getRawData()],i=[];let r=0;for(let e=0;e<t.rowCount;e++)s.includes(n[e])&&(t.rows.removeAt(e-r),i.push(e),r+=1);return i}(u,e),d={seqCol:u.col(e.name),methodName:s,similarityMetric:o,embedAxesNames:c,options:{...h,sparseMatrixThreshold:l??.8,usingSparseMatrix:t.rowCount>2e4}},g=s===St.AL.UMAP?1e5:15e3,f=s===St.AL.UMAP?5e3:2e3;if(t.rowCount>g)n.shell.warning(`Too many rows, maximum for sequence space is ${g}`);else{if(!(t.rowCount>f))return p(await F(d));i.dialog().add(i.divText("Sequence space analysis might take several minutes.\n Do you want to continue?")).onOK((async()=>{const t=r.TaskBarProgressIndicator.create("Running Sequence space..."),e=await F(d);return t.close(),p(e)})).show()}function p(e){const s=e.coordinates;for(const e of s){const s=e.toList();m.forEach((t=>s.splice(t,0,null))),t.columns.add(r.Column.float(e.name,t.rowCount).init((t=>s[t])))}if(a)return n.shell.tableView(t.name).scatterPlot({x:c[0],y:c[1],title:"Sequence space"})}}async function Bt(t,e){if(0===r.Func.find({package:"Chem",name:"getRdKitModule"}).length)return void n.shell.warning('Transformation to atomic level requires package "Chem" installed.');if(!(0,Pt.n)(e,"To Atomic Level"))return;const s=(await Gt()).getBioLib(),o=await(0,yt.i0)(t,e,s);null!==o.col&&(t.columns.add(o.col,!0),await n.data.detectSemanticTypes(t)),o.warnings&&o.warnings.length>0&&n.shell.warning(i.list(o.warnings))}function Vt(t){return new wt.i(t).importFasta()}function Ut(t){const e=T.Cn.getOrCreate(t).stats;return Object.keys(e.freq)}async function $t(t,e,s){return Et(t,e,s,At.IDENTITY)}async function Yt(t,e,s){return Et(t,e,s,At.SIMILARITY)}},7983:(t,e,s)=>{"use strict";s.d(e,{HV:()=>c,QF:()=>h,pf:()=>l});var n=s(4469),i=(s(3870),s(976)),r=s(7241),o=(s(4293),s(1061)),a=s(8447);function l(t,e,s){const n=s?function(t,e){const s=`${e}`.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),n=t.charAt(0)===e,i=t.charAt(t.length-1)===e,r=t.replace(new RegExp(`^${s}|${s}$`,"g"),"");return n?i?`${s}${r}${s}`:`${s}${r}${s}|${s}${r}$`:i?`^${r}${s}|${s}${r}${s}`:`^${r}${s}|${s}${r}${s}|${s}${r}$`}(t,s):t,r=i.BitSet.create(e.length);for(let s=0;s<e.length;s++){const i=e.get(s);(i.match(n)||i===t)&&r.set(s,!0,!1)}return r}async function h(t,e){e.version!==e.temp["last-invalidated-version"]&&await c(e,!0);const s=i.Column.string("helm",1).init((e=>t));s.semType=i.SEMTYPE.MACROMOLECULE,s.setTag(i.TAGS.UNITS,a.r2.HELM);const o=await(0,r.D)(s,!0,e.temp["monomers-dict"]);return(await n.functions.call("Chem:searchSubstructure",{molStringsColumn:e.temp["monomeric-mols"],molString:o.get(0),molBlockFailover:""})).get(0)}async function c(t,e){const s=i.TaskBarProgressIndicator.create(`Invalidating molfiles for ${t.name}`);await(0,o.gw)(10);const n=new Map,a=await(0,r.D)(t,e,n);t.temp["monomeric-mols"]=a,t.temp["monomers-dict"]=n,t.temp["last-invalidated-version"]=t.version,s.close()}},2568:(t,e,s)=>{"use strict";s.d(e,{l:()=>a,n:()=>o});var n=s(4469),i=s(976),r=s(499);function o(t,e,s=[],i=[],r=!0){const[o,l]=a(t,e,s,i);return r&&!o&&n.shell.warning(l),o}function a(t,e,s=[],o=[]){let a=!0,l="";const h=r.Cn.getOrCreate(t);if(t.semType!==i.SEMTYPE.MACROMOLECULE)n.shell.warning(e+" analysis is allowed for Macromolecules semantic type"),a=!1;else{const t=h.notation;if(s.length>0&&!s.some((e=>t.toUpperCase()==e.toUpperCase())))l=`${e} + ' analysis is allowed for Macromolecules with notation ${0==s.length?"any notation":`notation${s.length>1?"s":""} ${s.map((t=>`"${t}"`)).join(", ")} `}.`,a=!1;else if(!h.isHelm()){const t=h.alphabet;o.length>0&&!o.some((e=>t.toUpperCase()==e.toUpperCase()))&&(l=`${e} + ' analysis is allowed for Macromolecules with alphabet ${0==o.length?"any alphabet":`alphabet${o.length>1?"s":""} ${o.map((t=>`"${t}"`)).join(", ")}.`}.`,a=!1)}}return[a,l]}},3553:(t,e,s)=>{"use strict";s.d(e,{Of:()=>r,WY:()=>c,jB:()=>u,mU:()=>a,rs:()=>h});var n,i,r,o=s(8341);!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"}(n||(n={})),function(t){t.AAR="AAR",t.POSITION="Pos",t.SELECTION="selection"}(i||(i={})),function(t){t.MONOMER="Monomer",t.MACROMOLECULE_DIFFERENCE="MacromoleculeDifference",t.ACTIVITY="activity",t.ACTIVITY_SCALED="activityScaled"}(r||(r={}));const a="MSA";var l,h;!function(t){t.CELL_CHANGING="isCellChanging"}(l||(l={})),function(t){t.SEPARATOR="."}(h||(h={}));const c="3.3.1",u={pepsea:{gapOpen:1.53,gapExtend:0,method:o.J[0]},kalign:{gapOpen:-1,gapExtend:-1,terminalGap:-1}}},4004:(t,e,s)=>{"use strict";s.d(e,{o:()=>r}),s(976),s(3870);var n=s(4469),i=(s(3336),s(8447),s(499));async function r(t,e,s){const r=i.Cn.getOrCreate(t).convert(e,s);t.dataFrame.columns.add(r);const o=await n.functions.call("Bio:detectMacromolecule",{col:r});return o&&(r.semType=o),await n.data.detectSemanticTypes(t.dataFrame),r}},5490:(t,e,s)=>{"use strict";s.d(e,{rb:()=>p,RV:()=>g,NT:()=>S,P4:()=>y,nW:()=>b,QD:()=>T});var n,i=s(4469),r=(s(3870),s(976)),o=s(701);class a{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 s=t;const n=this.isWhitespace(s)?e:e-1;for(let t=0;t<n;t++)s=this.getNextColumnIdx(s);return s}parseAtomTypes(){const t=this.atomCount,e=new Array(t);let s=this.getAtomBlockIdx();for(let n=0;n<t;n++)s=this.shiftIdxToAtomType(s),e[n]=this.parseAtomType(s),s=this.getNextLineIdx(s);return e}parseAtomCoordinates(){const t=new Float32Array(this.atomCount),e=new Float32Array(this.atomCount),s=new Float32Array(this.atomCount);let n=this.getAtomBlockIdx();for(let i=0;i<this.atomCount;i++){n=this.shiftIdxToXColumn(n);for(const r of[t,e,s])r[i]=this.parseFloatValue(n),n=this.getNextColumnIdx(n);n=this.getNextLineIdx(n)}return{x:t,y:e,z:s}}parseBondedAtomPairs(){const t=new Array(this.bondCount);let e=this.getBondBlockIdx();for(let s=0;s<this.bondCount;s++){e=this.shiftIdxToBondedAtomsPair(e);const n=new Uint16Array(2);n[0]=this.parseIntValue(e),e=this.getNextColumnIdx(e),n[1]=this.parseIntValue(e),t[s]=n,e=this.getNextLineIdx(e)}return t}parseBondTypes(){const t=this.bondCount,e=new Uint16Array(t);let s=this.getBondBlockIdx();for(let n=0;n<t;n++)s=this.shiftIdxToBondType(s),e[n]=this.parseIntValue(s),s=this.getNextLineIdx(s);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 s=e+1;for(;!this.isWhitespace(s);)++s;return t(this.fileContent.substring(e,s))}}class l extends a{constructor(t){super(t),this.init(t)}init(t){super.init(t)}parseAtomType(t){let e=t,s=e;return this.isQuote(e)?(s=this.getNextIdenticalChar(e),e++):s=this.fileContent.indexOf(" ",s),this.fileContent.substring(e,s)}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&&!((s=this.fileContent.charCodeAt(e+1))>64&&s<91||s>96&&s<123);var s}))}isFragment(){return this.isQueryOrFragment((t=>82===t||42===t))}isQueryOrFragment(t){const e=this.atomCount;let s=this.getAtomBlockIdx();for(let n=0;n<e;n++){if(s=this.shiftIdxToAtomType(s),t(this.fileContent.charCodeAt(s),s))return!0;s=this.getNextLineIdx(s)}return!1}}!function(t){t.HEADER="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.RGP_LINE="M RGP",t.A_LINE="A ",t.END="M END"}(n||(n={}));class h extends l{constructor(t){super(t)}static validate(t){return-1!==t.indexOf(n.HEADER)&&-1!==t.indexOf(n.END)}shiftIdxToAtomType(t){return this.shiftIdxToSpecifiedColumn(t,n.ATOM_TYPE_COL)}getCountsLineIdx(){let t=0;for(let e=0;e<n.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,n.FIRST_BONDED_ATOM_COL)}shiftIdxToBondType(t){return this.shiftIdxToSpecifiedColumn(t,n.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+n.NUM_OF_COUNTS_DIGITS;const s=parseInt(this.fileContent.substring(t,e));return t=e,e+=n.NUM_OF_COUNTS_DIGITS,{atomCount:s,bondCount:parseInt(this.fileContent.substring(t,e))}}}class c extends l{constructor(t){super(t),this.init(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 validate(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 s=parseInt(this.fileContent.substring(t,e));return t=e+1,e=this.fileContent.indexOf(" ",t+1),{atomCount:s,bondCount:parseInt(this.fileContent.substring(t,e))}}}class u{constructor(){}static getInstance(t){if(h.validate(t))return new h(t);if(c.validate(t))return new c(t);throw new Error("Malformed molfile")}}var m=s(7228),d=s(2397);const g="Libraries",f="System:AppData/Bio/libraries/",p={"HELMCoreLibrary.json":"HELMCoreLibrary.json"};async function y(){return await Promise.all((await i.dapi.files.list(f,!0,"")).map((async t=>t.fullPath.substring(f.length))))}let w=Promise.resolve();async function b(){let t;return w=w.then((async()=>{const e=await i.dapi.userDataStorage.getValue(g,"Settings",!0);t=e?JSON.parse(e):{exclude:[]},t.exclude=t.exclude instanceof Array?t.exclude:[],console.debug(`Bio: getUserLibSettings()\n${JSON.stringify(t,void 0,2)}`)})),await w,t}async function T(t){w=w.then((async()=>{console.debug(`Bio: setUserLibSettings()\n${JSON.stringify(t,void 0,2)}`),await i.dapi.userDataStorage.postValue(g,"Settings",JSON.stringify(t),!0)})),await w}class C{constructor(t,e){this._monomers={},this._onChanged=new o.Subject,this._monomers=t,this.error=e}getMonomer(t,e){return t in this._monomers&&e in this._monomers[t]?this._monomers[t][e]:null}getPolymerTypes(){return Object.keys(this._monomers)}getMonomerMolsByPolymerType(t){const e={};return Object.keys(this._monomers[t]??{}).forEach((s=>{e[s]=this._monomers[t][s].molfile})),e}getMonomerSymbolsByType(t){return Object.keys(this._monomers[t])}getMonomerSymbolsByRGroup(t,e,s){let n=this.getMonomerSymbolsByType(e).map((t=>this.getMonomer(e,t)));return n=n.filter((t=>null!==t)),0===n.length?[]:(n=n.filter((e=>{if(!e?.rgroups)return!1;let s=e?.rgroups.length>=t;return u.getInstance(e.molfile).atomTypes.map(((t,e)=>"R#"===t?e:-1)).filter((t=>-1!==t)),s&&(s=!0),s})),n.map((t=>t?.symbol)))}get onChanged(){return this._onChanged}_updateInt(t){const e=t.getPolymerTypes(),s=this.getPolymerTypes();e.forEach((e=>{s.includes(e)||(this._monomers[e]={}),t.getMonomerSymbolsByType(e).forEach((s=>{this._monomers[e][s]=t.getMonomer(e,s)}))}))}update(t){this._updateInt(t),this._onChanged.next()}updateLibs(t,e=!1){e&&(this._monomers={});for(const e of t)e.error||this._updateInt(e);this._onChanged.next()}clear(){this._monomers={},this._onChanged.next()}}class S{constructor(){this._monomerLib=new C({}),this.loadLibrariesPromise=Promise.resolve()}getBioLib(){return this._monomerLib}async loadLibraries(t=!1){return this.loadLibrariesPromise=this.loadLibrariesPromise.then((async()=>{try{const[e,s]=await Promise.all([y(),b()]),n=e.filter((t=>!s.exclude.includes(t))),i=await Promise.all(n.map((t=>this.readLibrary(f,t).catch((e=>{const s=`Loading monomers from '${t}' error: ${e instanceof Error?e.message:e.toString()}`;return new C({},s)})))));this._monomerLib.updateLibs(i,t)}catch(t){const e=`Loading monomer libraries error: ${t instanceof Error?t.message:t.toString()}`;i.shell.warning(e);const s=t instanceof Error?t.stack:void 0;d._package.logger.error(e,void 0,s)}}))}async readLibrary(t,e){let s,n,o=[];const a=new r.FileSource(t);if(e.endsWith(".sdf"))1===r.Func.find({package:"Chem",name:"importSdf"}).length?(s=await a.readAsBytes(e),n=await i.functions.call("Chem:importSdf",{bytes:s}),o=(0,m.Xk)(n[0])):i.shell.warning("Chem package is not installed");else if(e.endsWith(".json")){const t=await a.readAsText(e);o=JSON.parse(t)}else{if(!e.endsWith(".csv"))throw new Error("Monomer library of unknown file format, supported formats: SDF, JSON, CSV");{const t=(l=await a.readCsv(e),Array.from({length:l.rowCount},((t,e)=>l.columns.names().reduce(((t,s)=>(t[s]=l.get(s,e),t)),{}))));if(!(0,m.eD)(t))throw new Error("Invalid format of CSV monomer lib");o=(0,m.Z)(t)}}var l;const h={},c=[];return o.forEach((t=>{c.includes(t.polymerType)||(h[t.polymerType]={},c.push(t.polymerType)),h[t.polymerType][t.symbol]=t})),new C(h)}static get instance(){return S._instance||(S._instance=new S),S._instance}}S._instance=null},525:(t,e,s)=>{"use strict";s.d(e,{K:()=>_});var n=s(4469),i=s(976),r=s(3870),o=s(8447),a=s(499),l=s(6098),h=s(8341),c=s(2568),u=s(3553),m=s(2397),d=s(3379),g=s.n(d),f=s(7795),p=s.n(f),y=s(569),w=s.n(y),b=s(3565),T=s.n(b),C=s(9216),S=s.n(C),A=s(4589),v=s.n(A),E=s(9564),M={};M.styleTagTransform=v(),M.setAttributes=T(),M.insert=w().bind(null,"head"),M.domAPI=p(),M.insertStyleElement=S(),g()(E.Z,M),E.Z&&E.Z.locals&&E.Z.locals;class N extends Error{constructor(t,e){super(t,e)}}async function _(t={}){return new Promise((async(e,s)=>{var o,a,l;t.clustersCol??(t.clustersCol=null),t.pepsea??(t.pepsea={}),(o=t.pepsea).method??(o.method=u.jB.pepsea.method),(a=t.pepsea).gapOpen??(a.gapOpen=u.jB.pepsea.gapOpen),(l=t.pepsea).gapExtend??(l.gapExtend=u.jB.pepsea.gapExtend);const c=t.col?.dataFrame??n.shell.t,m=t.col??c.columns.bySemType(i.SEMTYPE.MACROMOLECULE);if(null==m){const t="MSAError: dataset doesn't conain any Macromolecule column";n.shell.warning(t),s(new N(t))}const d=r.choiceInput("Method",t.pepsea.method,h.J);d.setTooltip("Alignment method");const g=r.floatInput("Terminal gap",t?.kalign?.terminalGap??null);g.setTooltip("Penalty for opening a gap at the beginning or end of the sequence");const f=r.p(`Kalign version: ${u.WY}`,"kalign-version"),p=r.floatInput("Gap open",t.pepsea.gapOpen);p.setTooltip("Gap opening penalty at group-to-group alignment");const y=r.floatInput("Gap extend",t.pepsea.gapExtend);y.setTooltip("Gap extension penalty to skip the alignment");const w=r.inputs([p,y,g]),b=r.button("Alignment parameters",(()=>{w.hidden=!w.hidden}),"Adjust alignment parameters such as penalties for opening and extending gaps");b.classList.add("msa-params-button"),w.hidden=!0,b.prepend(r.icons.settings((()=>null)));const T=[d.root.style],C=[g.root.style,f.style];let S;const A=r.columnInput("Sequence",c,m,(async()=>{S=await L(A.value,c,T,C,d,v,p,y,g)}),{filter:t=>t.semType===i.SEMTYPE.MACROMOLECULE});A.setTooltip("Sequences column to use for alignment");const v=r.columnInput("Clusters",c,t.clustersCol);if(v.nullable=!0,A.fireChanged(),t.col)return S=await L(t.col,c,T,C,d,v,p,y,g),void await P(A,c,S,e,s);r.dialog("MSA").add(A).add(v).add(d).add(w).add(b).add(f).onOK((async()=>{await P(A,c,S,e,s)})).show()}))}async function P(t,e,s,r,o){let a=null;const l=i.TaskBarProgressIndicator.create("Analyze for MSA ...");try{if(t.fireChanged(),t.value.semType!==i.SEMTYPE.MACROMOLECULE)throw new Error("Chosen column has to be of Macromolecule semantic type");if(void 0===s)throw new Error("Invalid column format");if(a=await s(),null==a)return o("PepSeA container has not started");e.columns.add(a),await n.data.detectSemanticTypes(e),r(a)}catch(t){const e=t instanceof Error?t.message:t.toString();n.shell.error(e),o(t)}finally{l.close()}}async function L(t,e,s,r,d,g,f,p,y){try{if(t.semType!==i.SEMTYPE.MACROMOLECULE)return;const n=e.columns.getUnusedName(`msa(${t.name})`);if((0,c.n)(t,t.name,[o.r2.FASTA,o.r2.SEPARATOR],["DNA","RNA","PT"],!1)){R(s,r,"kalign"),f.value=null,p.value=null,y.value=null;const e=a.Cn.getOrCreate(t),i=e.isFasta()?t:e.convert(o.r2.FASTA);return async()=>await(0,l.U)(i,!1,n,g.value)}if((0,c.n)(t,t.name,[o.r2.HELM],[],!1))return R(s,r,"pepsea"),f.value??(f.value=u.jB.pepsea.gapOpen),p.value??(p.value=u.jB.pepsea.gapExtend),async()=>await(0,h.f)(t,n,d.value,f.value,p.value,g.value);if((0,c.n)(t,t.name,[o.r2.SEPARATOR],["UN"],!1)){const e=a.Cn.getOrCreate(t).convert(o.r2.HELM);return R(s,r,"pepsea"),f.value??(f.value=u.jB.pepsea.gapOpen),p.value??(p.value=u.jB.pepsea.gapExtend),async()=>await(0,h.f)(e,n,d.value,f.value,p.value,g.value)}return f.value=null,p.value=null,y.value=null,void R(s,r,"kalign")}catch(t){const e=t instanceof Error?t.message:t.toString();n.shell.error(e),m._package.logger.error(e)}}function R(t,e,s){if("kalign"===s){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")}}},6098:(t,e,s)=>{"use strict";s.d(e,{U:()=>O});var n=s(976),i=s(5226);const r=Symbol("Comlink.proxy"),o=Symbol("Comlink.endpoint"),a=Symbol("Comlink.releaseProxy"),l=Symbol("Comlink.thrown"),h=t=>"object"==typeof t&&null!==t||"function"==typeof t,c=new Map([["proxy",{canHandle:t=>h(t)&&t[r],serialize(t){const{port1:e,port2:s}=new MessageChannel;return u(t,e),[s,[s]]},deserialize:t=>(t.start(),d(t))}],["throw",{canHandle:t=>h(t)&&l 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 u(t,e=self){e.addEventListener("message",(function s(n){if(!n||!n.data)return;const{id:i,type:o,path:a}=Object.assign({path:[]},n.data),h=(n.data.argumentList||[]).map(T);let c;try{const e=a.slice(0,-1).reduce(((t,e)=>t[e]),t),s=a.reduce(((t,e)=>t[e]),t);switch(o){case"GET":c=s;break;case"SET":e[a.slice(-1)[0]]=T(n.data.value),c=!0;break;case"APPLY":c=s.apply(e,h);break;case"CONSTRUCT":c=function(t){return Object.assign(t,{[r]:!0})}(new s(...h));break;case"ENDPOINT":{const{port1:e,port2:s}=new MessageChannel;u(t,s),c=function(t,e){return w.set(t,e),t}(e,[e])}break;case"RELEASE":c=void 0;break;default:return}}catch(t){c={value:t,[l]:0}}Promise.resolve(c).catch((t=>({value:t,[l]:0}))).then((t=>{const[n,r]=b(t);e.postMessage(Object.assign(Object.assign({},n),{id:i}),r),"RELEASE"===o&&(e.removeEventListener("message",s),m(e))}))})),e.start&&e.start()}function m(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function d(t,e){return f(t,[],e)}function g(t){if(t)throw new Error("Proxy has been released and is not useable")}function f(t,e=[],s=function(){}){let n=!1;const i=new Proxy(s,{get(s,r){if(g(n),r===a)return()=>C(t,{type:"RELEASE",path:e.map((t=>t.toString()))}).then((()=>{m(t),n=!0}));if("then"===r){if(0===e.length)return{then:()=>i};const s=C(t,{type:"GET",path:e.map((t=>t.toString()))}).then(T);return s.then.bind(s)}return f(t,[...e,r])},set(s,i,r){g(n);const[o,a]=b(r);return C(t,{type:"SET",path:[...e,i].map((t=>t.toString())),value:o},a).then(T)},apply(s,i,r){g(n);const a=e[e.length-1];if(a===o)return C(t,{type:"ENDPOINT"}).then(T);if("bind"===a)return f(t,e.slice(0,-1));const[l,h]=y(r);return C(t,{type:"APPLY",path:e.map((t=>t.toString())),argumentList:l},h).then(T)},construct(s,i){g(n);const[r,o]=y(i);return C(t,{type:"CONSTRUCT",path:e.map((t=>t.toString())),argumentList:r},o).then(T)}});return i}function p(t){return Array.prototype.concat.apply([],t)}function y(t){const e=t.map(b);return[e.map((t=>t[0])),p(e.map((t=>t[1])))]}const w=new WeakMap;function b(t){for(const[e,s]of c)if(s.canHandle(t)){const[n,i]=s.serialize(t);return[{type:"HANDLER",name:e,value:n},i]}return[{type:"RAW",value:t},w.get(t)||[]]}function T(t){switch(t.type){case"HANDLER":return c.get(t.name).deserialize(t.value);case"RAW":return t.value}}function C(t,e,s){return new Promise((n=>{const i=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");t.addEventListener("message",(function e(s){!s.data||!s.data.id||s.data.id!==i||(t.removeEventListener("message",e),n(s.data))})),t.start&&t.start(),t.postMessage(Object.assign({id:i},e),s)}))}const S="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0ICQ9U3ltYm9sKCJDb21saW5rLnByb3h5IiksQT1TeW1ib2woIkNvbWxpbmsuZW5kcG9pbnQiKSxSPVN5bWJvbCgiQ29tbGluay5yZWxlYXNlUHJveHkiKSx5PVN5bWJvbCgiQ29tbGluay50aHJvd24iKSxfPWU9PnR5cGVvZiBlPT0ib2JqZWN0IiYmZSE9PW51bGx8fHR5cGVvZiBlPT0iZnVuY3Rpb24iLEw9e2NhbkhhbmRsZTplPT5fKGUpJiZlWyRdLHNlcmlhbGl6ZShlKXtjb25zdHtwb3J0MTpyLHBvcnQyOml9PW5ldyBNZXNzYWdlQ2hhbm5lbDtyZXR1cm4gdyhlLHIpLFtpLFtpXV19LGRlc2VyaWFsaXplKGUpe3JldHVybiBlLnN0YXJ0KCksQyhlKX19LE89e2NhbkhhbmRsZTplPT5fKGUpJiZ5IGluIGUsc2VyaWFsaXplKHt2YWx1ZTplfSl7bGV0IHI7cmV0dXJuIGUgaW5zdGFuY2VvZiBFcnJvcj9yPXtpc0Vycm9yOiEwLHZhbHVlOnttZXNzYWdlOmUubWVzc2FnZSxuYW1lOmUubmFtZSxzdGFjazplLnN0YWNrfX06cj17aXNFcnJvcjohMSx2YWx1ZTplfSxbcixbXV19LGRlc2VyaWFsaXplKGUpe3Rocm93IGUuaXNFcnJvcj9PYmplY3QuYXNzaWduKG5ldyBFcnJvcihlLnZhbHVlLm1lc3NhZ2UpLGUudmFsdWUpOmUudmFsdWV9fSxFPW5ldyBNYXAoW1sicHJveHkiLExdLFsidGhyb3ciLE9dXSk7ZnVuY3Rpb24gdyhlLHI9c2VsZil7ci5hZGRFdmVudExpc3RlbmVyKCJtZXNzYWdlIixmdW5jdGlvbiBpKHMpe2lmKCFzfHwhcy5kYXRhKXJldHVybjtjb25zdHtpZDpvLHR5cGU6YSxwYXRoOm59PU9iamVjdC5hc3NpZ24oe3BhdGg6W119LHMuZGF0YSksdT0ocy5kYXRhLmFyZ3VtZW50TGlzdHx8W10pLm1hcChtKTtsZXQgbDt0cnl7Y29uc3QgYz1uLnNsaWNlKDAsLTEpLnJlZHVjZSgoZCxoKT0+ZFtoXSxlKSxmPW4ucmVkdWNlKChkLGgpPT5kW2hdLGUpO3N3aXRjaChhKXtjYXNlIkdFVCI6bD1mO2JyZWFrO2Nhc2UiU0VUIjpjW24uc2xpY2UoLTEpWzBdXT1tKHMuZGF0YS52YWx1ZSksbD0hMDticmVhaztjYXNlIkFQUExZIjpsPWYuYXBwbHkoYyx1KTticmVhaztjYXNlIkNPTlNUUlVDVCI6e2NvbnN0IGQ9bmV3IGYoLi4udSk7bD16KGQpfWJyZWFrO2Nhc2UiRU5EUE9JTlQiOntjb25zdHtwb3J0MTpkLHBvcnQyOmh9PW5ldyBNZXNzYWdlQ2hhbm5lbDt3KGUsaCksbD1OKGQsW2RdKX1icmVhaztjYXNlIlJFTEVBU0UiOmw9dm9pZCAwO2JyZWFrO2RlZmF1bHQ6cmV0dXJufX1jYXRjaChjKXtsPXt2YWx1ZTpjLFt5XTowfX1Qcm9taXNlLnJlc29sdmUobCkuY2F0Y2goYz0+KHt2YWx1ZTpjLFt5XTowfSkpLnRoZW4oYz0+e2NvbnN0W2YsZF09UyhjKTtyLnBvc3RNZXNzYWdlKE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSxmKSx7aWQ6b30pLGQpLGE9PT0iUkVMRUFTRSImJihyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGkpLEYocikpfSl9KSxyLnN0YXJ0JiZyLnN0YXJ0KCl9ZnVuY3Rpb24gVChlKXtyZXR1cm4gZS5jb25zdHJ1Y3Rvci5uYW1lPT09Ik1lc3NhZ2VQb3J0In1mdW5jdGlvbiBGKGUpe1QoZSkmJmUuY2xvc2UoKX1mdW5jdGlvbiBDKGUscil7cmV0dXJuIGIoZSxbXSxyKX1mdW5jdGlvbiBwKGUpe2lmKGUpdGhyb3cgbmV3IEVycm9yKCJQcm94eSBoYXMgYmVlbiByZWxlYXNlZCBhbmQgaXMgbm90IHVzZWFibGUiKX1mdW5jdGlvbiBiKGUscj1bXSxpPWZ1bmN0aW9uKCl7fSl7bGV0IHM9ITE7Y29uc3Qgbz1uZXcgUHJveHkoaSx7Z2V0KGEsbil7aWYocChzKSxuPT09UilyZXR1cm4oKT0+ZyhlLHt0eXBlOiJSRUxFQVNFIixwYXRoOnIubWFwKHU9PnUudG9TdHJpbmcoKSl9KS50aGVuKCgpPT57RihlKSxzPSEwfSk7aWYobj09PSJ0aGVuIil7aWYoci5sZW5ndGg9PT0wKXJldHVybnt0aGVuOigpPT5vfTtjb25zdCB1PWcoZSx7dHlwZToiR0VUIixwYXRoOnIubWFwKGw9PmwudG9TdHJpbmcoKSl9KS50aGVuKG0pO3JldHVybiB1LnRoZW4uYmluZCh1KX1yZXR1cm4gYihlLFsuLi5yLG5dKX0sc2V0KGEsbix1KXtwKHMpO2NvbnN0W2wsY109Uyh1KTtyZXR1cm4gZyhlLHt0eXBlOiJTRVQiLHBhdGg6Wy4uLnIsbl0ubWFwKGY9PmYudG9TdHJpbmcoKSksdmFsdWU6bH0sYykudGhlbihtKX0sYXBwbHkoYSxuLHUpe3Aocyk7Y29uc3QgbD1yW3IubGVuZ3RoLTFdO2lmKGw9PT1BKXJldHVybiBnKGUse3R5cGU6IkVORFBPSU5UIn0pLnRoZW4obSk7aWYobD09PSJiaW5kIilyZXR1cm4gYihlLHIuc2xpY2UoMCwtMSkpO2NvbnN0W2MsZl09TSh1KTtyZXR1cm4gZyhlLHt0eXBlOiJBUFBMWSIscGF0aDpyLm1hcChkPT5kLnRvU3RyaW5nKCkpLGFyZ3VtZW50TGlzdDpjfSxmKS50aGVuKG0pfSxjb25zdHJ1Y3QoYSxuKXtwKHMpO2NvbnN0W3UsbF09TShuKTtyZXR1cm4gZyhlLHt0eXBlOiJDT05TVFJVQ1QiLHBhdGg6ci5tYXAoYz0+Yy50b1N0cmluZygpKSxhcmd1bWVudExpc3Q6dX0sbCkudGhlbihtKX19KTtyZXR1cm4gb31mdW5jdGlvbiBEKGUpe3JldHVybiBBcnJheS5wcm90b3R5cGUuY29uY2F0LmFwcGx5KFtdLGUpfWZ1bmN0aW9uIE0oZSl7Y29uc3Qgcj1lLm1hcChTKTtyZXR1cm5bci5tYXAoaT0+aVswXSksRChyLm1hcChpPT5pWzFdKSldfWNvbnN0IFA9bmV3IFdlYWtNYXA7ZnVuY3Rpb24gTihlLHIpe3JldHVybiBQLnNldChlLHIpLGV9ZnVuY3Rpb24geihlKXtyZXR1cm4gT2JqZWN0LmFzc2lnbihlLHtbJF06ITB9KX1mdW5jdGlvbiBTKGUpe2Zvcihjb25zdFtyLGldb2YgRSlpZihpLmNhbkhhbmRsZShlKSl7Y29uc3RbcyxvXT1pLnNlcmlhbGl6ZShlKTtyZXR1cm5be3R5cGU6IkhBTkRMRVIiLG5hbWU6cix2YWx1ZTpzfSxvXX1yZXR1cm5be3R5cGU6IlJBVyIsdmFsdWU6ZX0sUC5nZXQoZSl8fFtdXX1mdW5jdGlvbiBtKGUpe3N3aXRjaChlLnR5cGUpe2Nhc2UiSEFORExFUiI6cmV0dXJuIEUuZ2V0KGUubmFtZSkuZGVzZXJpYWxpemUoZS52YWx1ZSk7Y2FzZSJSQVciOnJldHVybiBlLnZhbHVlfX1mdW5jdGlvbiBnKGUscixpKXtyZXR1cm4gbmV3IFByb21pc2Uocz0+e2NvbnN0IG89VSgpO2UuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsZnVuY3Rpb24gYShuKXshbi5kYXRhfHwhbi5kYXRhLmlkfHxuLmRhdGEuaWQhPT1vfHwoZS5yZW1vdmVFdmVudExpc3RlbmVyKCJtZXNzYWdlIixhKSxzKG4uZGF0YSkpfSksZS5zdGFydCYmZS5zdGFydCgpLGUucG9zdE1lc3NhZ2UoT2JqZWN0LmFzc2lnbih7aWQ6b30sciksaSl9KX1mdW5jdGlvbiBVKCl7cmV0dXJuIG5ldyBBcnJheSg0KS5maWxsKDApLm1hcCgoKT0+TWF0aC5mbG9vcihNYXRoLnJhbmRvbSgpKk51bWJlci5NQVhfU0FGRV9JTlRFR0VSKS50b1N0cmluZygxNikpLmpvaW4oIi0iKX1jb25zdCBXPWFzeW5jKCk9PldlYkFzc2VtYmx5LnZhbGlkYXRlKG5ldyBVaW50OEFycmF5KFswLDk3LDExNSwxMDksMSwwLDAsMCwxLDUsMSw5NiwwLDEsMTIzLDMsMiwxLDAsMTAsMTAsMSw4LDAsNjUsMCwyNTMsMTUsMjUzLDk4LDExXSkpLHg9ImVhZ2VyIixrPSJsYXp5IixqPXtzc3c6WyJzaW1kIl0sbWluaW1hcDI6WyJzaW1kIl19LHQ9e3Rvb2xzOltdLGNvbmZpZzp7fSxmaWxlczpbXSxiYXNlOnt9LGZzOnt9LGFzeW5jIGluaXQoKXtpZih0LnRvb2xzLmxlbmd0aD09PTApdGhyb3ciRXhwZWN0aW5nIGF0IGxlYXN0IDEgdG9vbC4iO2lmKG5ldyBTZXQodC50b29scy5tYXAocj0+YCR7ci50b29sfS8ke3IucHJvZ3JhbXx8ci50b29sfWApKS5zaXplIT09dC50b29scy5sZW5ndGgpdGhyb3ciRm91bmQgZHVwbGljYXRlIHRvb2xzOyBjYW4gb25seSBoYXZlIGVhY2ggdG9vbC9wcm9ncmFtIGNvbWJpbmF0aW9uIGF0IG1vc3Qgb25jZS4iO2lmKHQuYmFzZT10LnRvb2xzLmZpbmQocj0+ci5yZWluaXQhPT0hMCksIXQuYmFzZSl0aHJvdyJDb3VsZCBub3QgZmluZCBhIHRvb2wgd2l0aCBgcmVpbml0OiBmYWxzZWAgdG8gdXNlIGFzIHRoZSBiYXNlIG1vZHVsZS4gVG8gZml4IHRoaXMgaXNzdWUsIGluY2x1ZGUgdGhlIHRvb2wgYGJhc2UvMS4wLjBgIHdoZW4gaW5pdGlhbGl6aW5nIEFpb2xpLiI7cmV0dXJuIHQuYmFzZS5pc0Jhc2VNb2R1bGU9ITAsYXdhaXQgdGhpcy5fc2V0dXAodC5iYXNlKSxhd2FpdCB0aGlzLl9pbml0TW9kdWxlcygpLHQuX2xvZygiUmVhZHkiKSwhMH0sYXN5bmMgX2luaXRNb2R1bGVzKCl7YXdhaXQgUHJvbWlzZS5hbGwodC50b29scy5tYXAodGhpcy5fc2V0dXApKSxhd2FpdCB0aGlzLl9zZXR1cEZTKCl9LG1vdW50KGU9W10pe2NvbnN0IHI9YCR7dC5jb25maWcuZGlyU2hhcmVkfSR7dC5jb25maWcuZGlyRGF0YX1gLGk9YCR7dC5jb25maWcuZGlyU2hhcmVkfSR7dC5jb25maWcuZGlyTW91bnRlZH1gO2xldCBzPVtdLG89W10sYT1bXTshQXJyYXkuaXNBcnJheShlKSYmIShlIGluc3RhbmNlb2YgRmlsZUxpc3QpJiYoZT1bZV0pLHQuX2xvZyhgTW91bnRpbmcgJHtlLmxlbmd0aH0gZmlsZXNgKTtmb3IobGV0IG4gb2YgZSl7aWYobiBpbnN0YW5jZW9mIEZpbGV8fChuPT1udWxsP3ZvaWQgMDpuLmRhdGEpaW5zdGFuY2VvZiBCbG9iJiZuLm5hbWV8fHR5cGVvZihuPT1udWxsP3ZvaWQgMDpuLmRhdGEpPT0ic3RyaW5nIiYmbi5uYW1lKXR5cGVvZihuPT1udWxsP3ZvaWQgMDpuLmRhdGEpPT0ic3RyaW5nIiYmKG4uZGF0YT1uZXcgQmxvYihbbi5kYXRhXSx7dHlwZToidGV4dC9wbGFpbiJ9KSkscy5wdXNoKG4pO2Vsc2UgaWYobi5uYW1lJiZuLnVybClvLnB1c2gobik7ZWxzZSBpZih0eXBlb2Ygbj09InN0cmluZyImJm4uc3RhcnRzV2l0aCgiaHR0cCIpKW49e3VybDpuLG5hbWU6bi5zcGxpdCgiLy8iKS5wb3AoKS5yZXBsYWNlKC9cLy9nLCItIil9LG8ucHVzaChuKTtlbHNlIHRocm93J0Nhbm5vdCBtb3VudCBmaWxlKHMpIHNwZWNpZmllZC4gTXVzdCBiZSBhIEZpbGUsIEJsb2IsIGEgVVJMIHN0cmluZywgb3IgeyBuYW1lOiAiZmlsZS50eHQiLCBkYXRhOiAic3RyaW5nIiB9Lic7YS5wdXNoKG4ubmFtZSl9dHJ5e3QuZnMudW5tb3VudChpKX1jYXRjaHt9Zm9yKGxldCBuIG9mIG8pdC5mcy5jcmVhdGVMYXp5RmlsZShyLG4ubmFtZSxuLnVybCwhMCwhMCk7cmV0dXJuIHQuZmlsZXM9dC5maWxlcy5jb25jYXQocyksdC5iYXNlLm1vZHVsZS5GUy5tb3VudCh0LmJhc2UubW9kdWxlLldPUktFUkZTLHtmaWxlczp0LmZpbGVzLmZpbHRlcihuPT5uIGluc3RhbmNlb2YgRmlsZSksYmxvYnM6dC5maWxlcy5maWx0ZXIobj0+KG49PW51bGw/dm9pZCAwOm4uZGF0YSlpbnN0YW5jZW9mIEJsb2IpfSxpKSxzLm1hcChuPT57Y29uc3QgdT1gJHtpfS8ke24ubmFtZX1gLGw9YCR7cn0vJHtuLm5hbWV9YDt0cnl7dC5mcy51bmxpbmsobCl9Y2F0Y2h7fXQuX2xvZyhgQ3JlYXRpbmcgc3ltbGluazogJHtsfSAtLT4gJHt1fWApLHQuZnMuc3ltbGluayh1LGwpfSksYS5tYXAobj0+YCR7cn0vJHtufWApfSxhc3luYyBleGVjKGUscj1udWxsKXtpZih0Ll9sb2coYEV4ZWN1dGluZyAlYyR7ZX0lYyBhcmdzPSR7cn1gLCJjb2xvcjpkYXJrYmx1ZTsgZm9udC13ZWlnaHQ6Ym9sZCIsIiIpLCFlKXRocm93IkV4cGVjdGluZyBhIGNvbW1hbmQiO2xldCBpPWU7cj09bnVsbCYmKHI9ZS5zcGxpdCgiICIpLGk9ci5zaGlmdCgpKTtjb25zdCBzPXQudG9vbHMuZmluZChhPT57dmFyIHU7bGV0IG49aTtyZXR1cm4oKHU9YT09bnVsbD92b2lkIDA6YS5mZWF0dXJlcyk9PW51bGw/dm9pZCAwOnUuc2ltZCk9PT0hMCYmKG49YCR7bn0tc2ltZGApLGEucHJvZ3JhbT09bn0pO2lmKHM9PW51bGwpdGhyb3dgUHJvZ3JhbSAke2l9IG5vdCBmb3VuZC5gO3Muc3Rkb3V0PSIiLHMuc3RkZXJyPSIiLHMubG9hZGluZz09ayYmKHMubG9hZGluZz14LGF3YWl0IHRoaXMuX2luaXRNb2R1bGVzKCkpO3RyeXtzLm1vZHVsZS5jYWxsTWFpbihyKX1jYXRjaChhKXtjb25zb2xlLmVycm9yKGEpfXRyeXtzLm1vZHVsZS5GUy5jbG9zZShzLm1vZHVsZS5GUy5zdHJlYW1zWzFdKSxzLm1vZHVsZS5GUy5jbG9zZShzLm1vZHVsZS5GUy5zdHJlYW1zWzJdKX1jYXRjaHt9cy5tb2R1bGUuRlMuc3RyZWFtc1sxXT1zLm1vZHVsZS5GUy5vcGVuKCIvZGV2L3N0ZG91dCIsInciKSxzLm1vZHVsZS5GUy5zdHJlYW1zWzJdPXMubW9kdWxlLkZTLm9wZW4oIi9kZXYvc3RkZXJyIiwidyIpO2xldCBvPXtzdGRvdXQ6cy5zdGRvdXQsc3RkZXJyOnMuc3RkZXJyfTtpZih0LmNvbmZpZy5wcmludEludGVybGVhdmVkJiYobz1zLnN0ZG91dCkscy5yZWluaXQ9PT0hMCl7Y29uc3QgYT10LmJhc2UubW9kdWxlLkZTLmN3ZCgpO09iamVjdC5hc3NpZ24ocyxzLmNvbmZpZykscy5yZWFkeT0hMSxhd2FpdCB0aGlzLmluaXQoKSxzLmlzQmFzZU1vZHVsZSYmdGhpcy5tb3VudCgpLHRoaXMuY2QoYSl9cmV0dXJuIG99LGNhdChlKXtyZXR1cm4gdC5fZmlsZW9wKCJjYXQiLGUpfSxscyhlKXtyZXR1cm4gdC5fZmlsZW9wKCJscyIsZSl9LGRvd25sb2FkKGUpe3JldHVybiB0Ll9maWxlb3AoImRvd25sb2FkIixlKX0scHdkKCl7cmV0dXJuIHQuZnMuY3dkKCl9LGNkKGUpe2ZvcihsZXQgciBvZiB0LnRvb2xzKSFyLm1vZHVsZXx8ci5tb2R1bGUuRlMuY2hkaXIoZSl9LG1rZGlyKGUpe3JldHVybiB0LmZzLm1rZGlyKGUpLCEwfSxyZWFkKHtwYXRoOmUsbGVuZ3RoOnIsZmxhZzppPSJyIixvZmZzZXQ6cz0wLHBvc2l0aW9uOm89MH0pe2NvbnN0IGE9dC5mcy5vcGVuKGUsaSksbj1uZXcgVWludDhBcnJheShyKTtyZXR1cm4gdC5mcy5yZWFkKGEsbixzLHIsbyksdC5mcy5jbG9zZShhKSxufSx3cml0ZSh7cGF0aDplLGJ1ZmZlcjpyLGZsYWc6aT0idysiLG9mZnNldDpzPTAscG9zaXRpb246bz0wfSl7Y29uc3QgYT10LmZzLm9wZW4oZSxpKTt0LmZzLndyaXRlKGEscixzLHIubGVuZ3RoLG8pLHQuZnMuY2xvc2UoYSl9LF9zdGRpblR4dDoiIixfc3RkaW5QdHI6MCxnZXQgc3RkaW4oKXtyZXR1cm4gdC5fc3RkaW5UeHR9LHNldCBzdGRpbihlPSIiKXt0Ll9sb2coYFNldHRpbmcgc3RkaW4gdG8gJWMke2V9JWNgLCJjb2xvcjpkYXJrYmx1ZSIsIiIpLHQuX3N0ZGluVHh0PWUsdC5fc3RkaW5QdHI9MH0sYXN5bmMgX3NldHVwKGUpe2lmKGUucmVhZHkpcmV0dXJuO2lmKHQuX2xvZyhgU2V0dGluZyB1cCAke2UudG9vbH0gKGJhc2UgPSAke2UuaXNCYXNlTW9kdWxlPT09ITB9KS4uLmApLGUuY29uZmlnPU9iamVjdC5hc3NpZ24oe30sZSksZS51cmxQcmVmaXh8fChlLnVybFByZWZpeD1gJHt0LmNvbmZpZy51cmxDRE59LyR7ZS50b29sfS8ke2UudmVyc2lvbn1gKSxlLnByb2dyYW18fChlLnByb2dyYW09ZS50b29sKSxlLmZlYXR1cmVzfHwoZS5mZWF0dXJlcz17fSwoaltlLnByb2dyYW1dfHxbXSkuaW5jbHVkZXMoInNpbWQiKSYmKGF3YWl0IFcoKT8oZS5wcm9ncmFtKz0iLXNpbWQiLGUuZmVhdHVyZXMuc2ltZD0hMCk6dC5fbG9nKGBXZWJBc3NlbWJseSBTSU1EIGlzIG5vdCBzdXBwb3J0ZWQgaW4gdGhpcyBicm93c2VyOyB3aWxsIGxvYWQgbm9uLVNJTUQgdmVyc2lvbiBvZiAke2UucHJvZ3JhbX0uYCkpKSxlLmlzQmFzZU1vZHVsZSYmKGUubG9hZGluZz14KSxlLmxvYWRpbmc9PT1rKXt0Ll9sb2coYFdpbGwgbGF6eS1sb2FkICR7ZS50b29sfTsgc2tpcHBpbmcgaW5pdGlhbGl6YXRpb24uYCk7cmV0dXJufXNlbGYuaW1wb3J0U2NyaXB0cyhgJHtlLnVybFByZWZpeH0vJHtlLnByb2dyYW19LmpzYCksZS5tb2R1bGU9YXdhaXQgTW9kdWxlKHt0aGlzUHJvZ3JhbTplLnByb2dyYW0sbG9jYXRlRmlsZTooaSxzKT0+YCR7ZS51cmxQcmVmaXh9LyR7aX1gLHN0ZGluOigpPT50Ll9zdGRpblB0cjx0LnN0ZGluLmxlbmd0aD90LnN0ZGluLmNoYXJDb2RlQXQodC5fc3RkaW5QdHIrKyk6KHQuc3RkaW49IiIsbnVsbCkscHJpbnQ6aT0+ZS5zdGRvdXQrPWAke2l9CmAscHJpbnRFcnI6dC5jb25maWcucHJpbnRJbnRlcmxlYXZlZD9pPT5lLnN0ZG91dCs9YCR7aX0KYDppPT5lLnN0ZGVycis9YCR7aX0KYH0pO2NvbnN0IHI9ZS5tb2R1bGUuRlM7ZS5pc0Jhc2VNb2R1bGU/KHQuX2xvZyhgU2V0dGluZyB1cCAke2UudG9vbH0gd2l0aCBiYXNlIG1vZHVsZSBmaWxlc3lzdGVtLi4uYCksci5ta2Rpcih0LmNvbmZpZy5kaXJTaGFyZWQsNTExKSxyLm1rZGlyKGAke3QuY29uZmlnLmRpclNoYXJlZH0vJHt0LmNvbmZpZy5kaXJEYXRhfWAsNTExKSxyLm1rZGlyKGAke3QuY29uZmlnLmRpclNoYXJlZH0vJHt0LmNvbmZpZy5kaXJNb3VudGVkfWAsNTExKSxyLmNoZGlyKGAke3QuY29uZmlnLmRpclNoYXJlZH0vJHt0LmNvbmZpZy5kaXJEYXRhfWApLHQuZnM9cik6KHQuX2xvZyhgU2V0dGluZyB1cCAke2UudG9vbH0gd2l0aCBmaWxlc3lzdGVtLi4uYCksci5ta2Rpcih0LmNvbmZpZy5kaXJTaGFyZWQpLHIubW91bnQoZS5tb2R1bGUuUFJPWFlGUyx7cm9vdDp0LmNvbmZpZy5kaXJTaGFyZWQsZnM6dC5mc30sdC5jb25maWcuZGlyU2hhcmVkKSxyLmNoZGlyKHQuZnMuY3dkKCkpKSxlLnN0ZG91dD0iIixlLnN0ZGVycj0iIixlLnJlYWR5PSEwfSxhc3luYyBfc2V0dXBGUygpe2NvbnN0IGU9dC5mcztmb3IobGV0IHIgb2YgdC50b29scyl7aWYoIXIucmVhZHkpY29udGludWU7Y29uc3QgaT1yLm1vZHVsZS5GUyxzPWAvJHtyLnRvb2x9YCxvPWAke3QuY29uZmlnLmRpclNoYXJlZH0ke3N9YDshaS5hbmFseXplUGF0aChzKS5leGlzdHN8fGUuYW5hbHl6ZVBhdGgobykuZXhpc3RzfHwodC5fbG9nKGBNb3VudGluZyAke3N9IG9udG8gJHt0LmJhc2UudG9vbH0gZmlsZXN5c3RlbSBhdCAke299YCksZS5ta2RpcihvKSxlLm1vdW50KHQuYmFzZS5tb2R1bGUuUFJPWFlGUyx7cm9vdDpzLGZzOml9LG8pKX19LF9maWxlb3AoZSxyKXt0Ll9sb2coYFJ1bm5pbmcgJHtlfSAke3J9YCk7Y29uc3QgaT10LmZzLmFuYWx5emVQYXRoKHIpO2lmKCFpLmV4aXN0cylyZXR1cm4gdC5fbG9nKGBGaWxlICR7cn0gbm90IGZvdW5kLmApLCExO3N3aXRjaChlKXtjYXNlImNhdCI6cmV0dXJuIHQuZnMucmVhZEZpbGUocix7ZW5jb2Rpbmc6InV0ZjgifSk7Y2FzZSJscyI6cmV0dXJuIHQuZnMuaXNGaWxlKGkub2JqZWN0Lm1vZGUpP3QuZnMuc3RhdChyKTp0LmZzLnJlYWRkaXIocik7Y2FzZSJkb3dubG9hZCI6Y29uc3Qgcz1uZXcgQmxvYihbdGhpcy5jYXQocildKTtyZXR1cm4gVVJMLmNyZWF0ZU9iamVjdFVSTChzKX1yZXR1cm4hMX0sX2xvZyhlKXtpZighdC5jb25maWcuZGVidWcpcmV0dXJuO2xldCByPVsuLi5hcmd1bWVudHNdO3Iuc2hpZnQoKSxjb25zb2xlLmxvZyhgJWNbV2ViV29ya2VyXSVjICR7ZX1gLCJmb250LXdlaWdodDpib2xkIiwiIiwuLi5yKX19O3codCl9KSgpOwo=",A=typeof window<"u"&&window.Blob&&new Blob([atob(S)],{type:"text/javascript;charset=utf-8"});function v(){const t=A&&(window.URL||window.webkitURL).createObjectURL(A);try{return t?new Worker(t):new Worker("data:application/javascript;base64,"+S)}finally{t&&(window.URL||window.webkitURL).revokeObjectURL(t)}}const E={urlCDN:"https://biowasm.com/cdn/v3",urlCDNStg:"https://stg.biowasm.com/cdn/v3",dirShared:"/shared",dirMounted:"/mnt",dirData:"/data",printInterleaved:!0,callback:null,debug:!1,env:"prd"};class M{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({},E,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 v;this.callback&&(t.onmessage=t=>{"biowasm"===t.data.type&&this.callback(t.data.value)});const e=d(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=s(850);class _{static getAvailableScales(){return Object.entries(this.scales).map((([t,e])=>t))}static getScale(t){return(0,N.hu)(!(void 0===this.scales[t]),`Scale '${t}' was not found.`),this.scales[t]}}_.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 P{constructor(t="categorial"){this.aa2num=_.getScale(t),this.num2aa={},Object.entries(this.aa2num).forEach((([t,e])=>this.num2aa[e]=t))}static _truncateSequence(t){let e=0,s=t.length;const n=["NH2","COOH"];if(t.startsWith(n[0])){const s=n[0].length;(0,N.hu)("-"==t[s],`Wrong sequence format: ${n[0]} without following '-' in '${t}'.`),e=s}if(t.endsWith(n[1])){const e=n[1].length+1;(0,N.hu)("-"==t[s-e],`Wrong sequence format: ${n[1]} without '-' precending in '${t}'.`),s-=e}return t.substring(e,s)}static _dropDefises(t){return t.replace(/(-)([^-]+)/g,"$2")}static clean(t){return P._dropDefises(P._truncateSequence(t))}encode(t){const e=t.length,s=new Array(e).fill(0);for(let n=0;n<e;++n){const e=t[n];(0,N.hu)(e in this.aa2num,`Unknown char '${e}' found in sequence '${t}'`),s[n]=this.encodeLettter(e)}return s}encodeLettter(t){return this.aa2num[t]}decode(t){let e="";for(let s=0;s<t.length;++s){const n=t[s];(0,N.hu)(n in this.num2aa,`Unknown code '${n}' found in vector '${t}'`),e+=this.num2aa[n]}return e}}var L=s(3553);const R="input.fa",x="result.fasta";function I(t){return t.reduce(((t,e,s)=>t+`>sample${s+1}\n${e}\n`),"")}async function O(t,e=!1,s="",r=null,o,a,l){let h=t.toList();e&&(h=h.map((t=>P.clean(t).replace(/\-/g,""))));const c=t.length;r??(r=n.Column.string("Clusters",c).init("0")),r.type!=n.COLUMN_TYPE.STRING&&(r=r.convertTo(n.TYPE.STRING)),r.compact();const u=r.categories,m=r.getRawData(),d=new Array(u.length),g=new Array(u.length);for(let t=0;t<c;++t){const e=m[t];(d[e]??(d[e]=[])).push(h[t]),(g[e]??(g[e]=[])).push(t)}const f=await new M(["base/1.0.0",{tool:"kalign",version:L.WY,reinit:!0}]),p=n.Column.string(s,c);for(let t=0;t<u.length;++t){const e=I(d[t]);await f.fs.writeFile(R,e);const s=`${void 0!==o?` --gpo ${o}`:""}${void 0!==a?` --gpe ${a}`:""}${void 0!==l?` --tgpe ${l}`:""}`,n=await f.exec(`kalign ${R} -f fasta -o ${x}${s}`);console.warn(n);const r=await f.cat(x);if(!r)throw new Error("kalign output no result");const h=new i.i(r).sequencesArray,c=g[t];for(let t=0;t<h.length;++t)p.set(c[t],h[t])}const y=t.getTag(n.TAGS.UNITS),w=t.getTag("alphabet");return p.setTag(n.TAGS.UNITS,y),p.setTag("aligned","SEQ.MSA"),p.setTag("alphabet",w),p.semType=n.SEMTYPE.MACROMOLECULE,p}},8341:(t,e,s)=>{"use strict";s.d(e,{J:()=>a,f:()=>h});var n=s(4469),i=s(976),r=s(8447),o=s(3553);const a=["mafft --auto","mafft","linsi","ginsi","einsi","fftns","fftnsi","nwns","nwnsi"],l=["AlignedSeq","AlignedSubpeptide","HELM","ID","PolymerID"];async function h(t,e,s="ginsi",a=1.53,h=0,u=null){const m=await n.dapi.docker.dockerContainers.filter("bio").first();if("started"!==m.status&&"checking"!==m.status)return n.log.warning("PepSeA container has not started yet"),null;const d=t.length;u??(u=i.Column.int("Clusters",d).init(0)),u.type!=i.COLUMN_TYPE.STRING&&(u=u.convertTo(i.TYPE.STRING));const g=u.categories,f=new Array(g.length);for(let e=0;e<d;++e){const s=u.get(e);if(""===s)continue;const n=g.indexOf(s),i=t.get(e);i&&(f[n]??(f[n]=[])).push({ID:e.toString(),HELM:i})}const p=new Array(d);for(const t of f){const e=(await c(m.id,t,s,a,h)).Alignment;for(const t of e)p[parseInt(t.ID)]=Object.entries(t).filter((t=>!l.includes(t[0]))).map((t=>"-"!==t[1]?t[1]:"")).join(o.rs.SEPARATOR)}const y=i.Column.fromStrings(e,p);return y.setTag(i.TAGS.UNITS,r.r2.SEPARATOR),y.setTag("separator",o.rs.SEPARATOR),y.setTag("aligned","SEQ.MSA"),y.setTag("alphabet","UN"),y.setTag(".alphabetIsMultichar","true"),y.semType=i.SEMTYPE.MACROMOLECULE,y}async function c(t,e,s,i,r){const o={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(e)},a=`/align?method=${s}&gap_open=${i}&gap_extend=${r}`,l=await n.dapi.docker.dockerContainers.request(t,a,o);return JSON.parse(l??"{}")}},9943:(t,e,s)=>{"use strict";s.d(e,{i$:()=>a,sK:()=>l}),s(976),s(3870),s(4469);var n=s(6414),i=s.n(n),r=s(8447);s(499);const o=60;function a(t,e,s=o,n="\n"){const i=r.kB,a=[];for(let r=0;r<e.length;r++){const o=t.map((t=>t.get(r).toString())).join("|"),h=l(e.get(r),i,s);a.push(`>${o}${n}`);for(const t of h)a.push(`${t}${n}`)}return"".concat(...a)}function l(t,e,s=o){const n=e(t);let r=0;const a=n.length,l=[];for(;r<a;){const t=i()(n).slice(r,r+s).toArray(),e=t.map((t=>t.length>1?`[${t}]`:t)).join("");l.push(e),r+=t.length}return l}},9416:(t,e,s)=>{"use strict";s.d(e,{n:()=>h});var n=s(4469),i=s(976),r=s(1061),o=s(2568),a=s(8457),l=s(3553);async function h(t,e){if(await(0,r.gw)(10),!(0,o.n)(e,"Sequence space"))return t;const s=(0,a.O)(e);s.name="splitToMonomers";const h=e.dataFrame;for(const t of s.columns)t.semType=l.Of.MONOMER,t.setTag("alphabet",e.getTag("alphabet"));const c=/(\d+)(?: \((\d+)\))?/,u=t=>{c.lastIndex=0;const e=t.match(c);return e?`${e[1]} (${parseInt(e[2]??0)+1})`:t};for(let t=0;t<s.columns.length;t++){const n=s.columns.byIndex(t);n.semType=l.Of.MONOMER,n.setTag("alphabet",e.getTag("alphabet"));const i=100;let r=0;for(;h.columns.byName(n.name)&&r<i;)n.name=u(n.name),r++;h.columns.add(n)}await n.data.detectSemanticTypes(h);for(let t=0;t<s.columns.length;t++){const e=s.columns.byIndex(t);e.setTag(i.TAGS.CELL_RENDERER,"Monomer"),e.setTag(".use-as-filter","false")}return h}},4293:(t,e,s)=>{"use strict";function n(t,e){t.innerHTML="",t.append(e)}s.d(e,{Y:()=>n}),s(4469),s(976)},833:(t,e,s)=>{"use strict";s.d(e,{bo:()=>g,CK:()=>y,yW:()=>p,eZ:()=>C});var n=s(4469),i=s(3870),r=s(976),o=s(6414),a=s.n(o),l=s(701),h=s(499),c=s(8447),u=s(9298);function m(t){var e;return"string"==typeof t||t instanceof String?t:("object"==typeof t||t instanceof Object)&&"$thrownJsError"in t?m(t.$thrownJsError):t instanceof Error?null!==(e=t.stack)&&void 0!==e?e:t.message:t.toString()}var d,g,f=s(2397);HTMLCanvasElement.prototype.getCursorPosition=function(t,e){const s=this.getBoundingClientRect();return new r.Point((t.clientX-s.left)*e,(t.clientY-s.top)*e)},r.Rect.prototype.contains=function(t,e){return this.left<=t&&t<=this.right&&this.top<=e&&e<=this.bottom};class p{constructor(t=0,e){this.count=t,this.bounds=e}}class y{get label(){return this._label?this._label:this.name}constructor(t,e,s,n){this.pos=t,this.name=e,this._freqs=s??{},n?.rowCount&&(this.rowCount=n.rowCount),n?.sumForHeightCalc&&(this.sumForHeightCalc=n.sumForHeightCalc),n?.label&&(this._label=n.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 p),e}getMonomerAt(t,e){const s=Object.entries(this._freqs).find((([s,n])=>n.bounds.contains(t,e)));return s?s[0]:void 0}calcHeights(t){this.rowCount=0;for(const[t,e]of Object.entries(this._freqs))this.rowCount+=e.count;if(this.sumForHeightCalc=0,t===u.ES.Entropy)for(const[t,e]of Object.entries(this._freqs)){const t=e.count/this.rowCount;this.sumForHeightCalc+=-t*Math.log2(t)}else if(t===u.ES.full)for(const[t,e]of Object.entries(this._freqs)){const t=e.count/this.rowCount;this.sumForHeightCalc+=t}}calcScreen(t,e,s,n,i,o,a,l,h,c){const m=i==u.ES.Entropy?n*(o-this.sumForHeightCalc)/o:n;let d=c*h+(n-m-1);const g=Object.entries(this._freqs).sort(((e,s)=>t(e[0])||t(s[0])?t(e[0])&&t(s[0])?0:t(e[0])?-1:1:s[1].count-e[1].count));for(const t of g){const n=t[1],i=m*n.count/this.rowCount;n.bounds=new r.Rect((e-s)*h*a,d,l*h,i),d+=i}}render(t,e,s,n,i,r){for(const[o,a]of Object.entries(this._freqs))if(!e(o)){const e=(0,c.GU)(o,5),l=a.bounds,h=l.left;t.resetTransform(),t.strokeStyle="lightgray",t.lineWidth=1,t.rect(h,l.top,l.width,l.height),t.fillStyle=r.get(o)??r.get("other"),t.textAlign="left",t.font=s;const u=t.measureText(e);t.setTransform(l.width/u.width,0,0,l.height/i,h,l.top),t.fillText(e,0,-n)}}}!function(t){t.STYLE="Style",t.BEHAVIOR="Behavior",t.LAYOUT="Layout",t.DATA="Data"}(d||(d={})),function(t){t.sequenceColumnName="sequenceColumnName",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.showPositionLabels="showPositionLabels",t.positionMarginState="positionMarginState",t.positionMargin="positionMargin",t.filterSource="filterSource"}(g||(g={}));const w=u.vS;var b;!function(t){t[t.None=0]="None",t[t.Render=1]="Render",t[t.Layout=1]="Layout",t[t.Freqs=2]="Freqs"}(b||(b={}));class T extends r.JsViewer{get positionWidthWithMargin(){return this._positionWidthWithMargin}get Length(){return this.skipEmptyPositions?this.positions.length:this.startPosition<=this.endPosition?this.endPosition-this.startPosition+1:0}get positionMarginValue(){return this.positionMarginState===u.dE.AUTO&&!0===this.unitsHandler.getAlphabetIsMultichar()||this.positionMarginState===u.dE.ON?this.positionMargin:0}constructor(){super(),this.viewed=!1,this.viewerId=-1,this.initialized=!1,this.cp=null,this.seqCol=null,this.positions=[],this.visibleSlider=!1,this.allowResize=!0,this.turnOfResizeForOneSetValue=!1,this.backgroundColor=4294967295,this.positionMargin=0,this.positionNames=[],this.positionLabels=void 0,this.startPosition=-1,this.endPosition=-1,this.error=null,this.viewPromise=Promise.resolve(),this.detachPromise=Promise.resolve(),this.setDataInProgress=!1,this.viewSubs=[],this._onSizeChanged=new l.Subject,this._onFreqsCalculated=new l.Subject,this._onLayoutCalculated=new l.Subject,this.renderLevelRequested=b.Freqs,this.viewerId=T.viewerCount,T.viewerCount+=1,this.textBaseline="top",this.unitsHandler=null,this.sequenceColumnName=this.string(g.sequenceColumnName,w.sequenceColumnName,{category:d.DATA}),this.startPositionName=this.string(g.startPositionName,w.startPositionName,{category:d.DATA}),this.endPositionName=this.string(g.endPositionName,w.endPositionName,{category:d.DATA}),this.skipEmptySequences=this.bool(g.skipEmptySequences,w.skipEmptySequences,{category:d.DATA}),this.skipEmptyPositions=this.bool(g.skipEmptyPositions,w.skipEmptyPositions,{category:d.DATA}),this.shrinkEmptyTail=this.bool(g.shrinkEmptyTail,w.shrinkEmptyTail,{category:d.DATA}),this.backgroundColor=this.int(g.backgroundColor,w.backgroundColor,{category:d.STYLE}),this.positionHeight=this.string(g.positionHeight,w.positionHeight,{category:d.STYLE,choices:Object.values(u.ES)}),this._positionWidth=this.positionWidth=this.float(g.positionWidth,w.positionWidth,{category:d.STYLE}),this.verticalAlignment=this.string(g.verticalAlignment,w.verticalAlignment,{category:d.LAYOUT,choices:Object.values(u.vw)}),this.horizontalAlignment=this.string(g.horizontalAlignment,w.horizontalAlignment,{category:d.LAYOUT,choices:Object.values(u.iD)}),this.fixWidth=this.bool(g.fixWidth,w.fixWidth,{category:d.LAYOUT,userEditable:!1}),this.fitArea=this.bool(g.fitArea,w.fitArea,{category:d.LAYOUT}),this.minHeight=this.float(g.minHeight,w.minHeight,{category:d.LAYOUT}),this.maxHeight=this.float(g.maxHeight,w.maxHeight,{category:d.LAYOUT}),this.showPositionLabels=this.bool(g.showPositionLabels,w.showPositionLabels,{category:d.LAYOUT}),this.positionMarginState=this.string(g.positionMarginState,w.positionMarginState,{category:d.LAYOUT,choices:Object.values(u.dE)});let t=0;"auto"===this.positionMarginState&&(t=4),this.positionMargin=this.int(g.positionMargin,t,{category:d.LAYOUT,min:0,max:16}),this.filterSource=this.string(g.filterSource,w.filterSource,{category:d.BEHAVIOR,choices:Object.values(u.Ct)}),this.slider=i.rangeSlider(0,100,0,20,!1,{style:"barbell"}),this.canvas=i.canvas(),this.canvas.classList.value="bio-wl-canvas",this.canvas.style.width="100%"}setData(){this.setDataInProgress||(this.setDataInProgress=!0,f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.setData() `),this.viewPromise=this.viewPromise.then((async()=>{this.viewed&&(await this.destroyView(),this.viewed=!1)})).then((async()=>{await this.detachPromise,this.updateSeqCol()})).then((async()=>{this.viewed||(await this.buildView(),this.viewed=!0)})).finally((()=>{this.setDataInProgress=!1})))}async destroyView(){for(const t of this.viewSubs)t.unsubscribe();this.viewSubs=[];const t=this.dataFrame?"data":"null";f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.destroyView( dataFrame = ${t} ) start`),this.host.remove(),this.msgHost=void 0,this.host=void 0,f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.destroyView() end`)}async buildView(){const t=this.dataFrame?"data":"null";f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.buildView( dataFrame = ${t} ) start`),window.devicePixelRatio,this.helpUrl="/help/visualize/viewers/web-logo.md",this.msgHost=i.div("No message",{classes:"bio-wl-msg"}),this.msgHost.style.display="none",this.canvas=i.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=i.div([this.msgHost,this.canvas],{classes:"bio-wl-host",style:{display:"flex",flexDirection:"row",flexWrap:"wrap"}}),this.root.append(this.host),this.root.append(this.slider.root),this.error&&(this.msgHost.innerText=this.error.message,i.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(i.onSizeChanged(this.root).subscribe(this.rootOnSizeChanged.bind(this))),this.viewSubs.push(this.slider.onValuesChanged.subscribe(this.sliderOnValuesChanged.bind(this))),this.viewSubs.push((0,l.fromEvent)(this.canvas,"mousemove").subscribe(this.canvasOnMouseMove.bind(this))),this.viewSubs.push((0,l.fromEvent)(this.canvas,"mousedown").subscribe(this.canvasOnMouseDown.bind(this))),this.viewSubs.push((0,l.fromEvent)(this.canvas,"wheel").subscribe(this.canvasOnWheel.bind(this))),await this.render(b.Freqs,"buildView"),f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.buildView() end`)}rootOnSizeChanged(){f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.rootOnSizeChanged(), start `),this.render(b.Layout,"rootOnSizeChanged").then((()=>{}))}updateSeqCol(){if(this.dataFrame&&(this.seqCol=this.sequenceColumnName?this.dataFrame.col(this.sequenceColumnName):null,null==this.seqCol&&(this.seqCol=(0,c.up)(this.dataFrame),this.sequenceColumnName=this.seqCol?this.seqCol.name:null),this.seqCol)){try{this.unitsHandler=h.Cn.getOrCreate(this.seqCol),this.cp=(0,c.dQ)(this.seqCol),this.updatePositions(),this.error=null}catch(t){throw this.seqCol=null,this.error=t instanceof Error?t:new Error(t.toString()),t}this.seqCol||(this.unitsHandler=null,this.positionNames=[],this.positionLabels=[],this.startPosition=-1,this.endPosition=-1,this.cp=null)}}updatePositions(){if(!this.seqCol)return;const t=this.getFilter(),e=0===t.trueCount?this.unitsHandler.maxLength:a().enumerate(this.unitsHandler.splitted).map((([e,s])=>t.get(s)&&e?e.length:0)).reduce(((t,e)=>Math.max(t,e)),0),s=this.seqCol.getTag(".positionNames"),n=this.seqCol.getTag(".positionLabels");this.positionNames=s?s.split(c.CI).map((t=>t.trim())):[...Array(e).keys()].map((t=>`${t+1}`)),this.positionLabels=n?n.split(c.CI).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):e-1,this.render(b.Freqs,"updatePositions").then((()=>{}))}getFilter(){let t;switch(this.filterSource){case u.Ct.Filtered:t=this.dataFrame.filter;break;case u.Ct.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.fitArea?this.calcLayoutFitArea(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,s=Math.min(Math.max(this.minHeight,this.root.clientHeight),this.maxHeight);this.host.style.justifyContent=u.iD.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=`${s}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=s*t}calcLayoutNoFitArea(t){if(!this.host||!this.canvas||!this.slider)return;const e=this._positionWidthWithMargin*this.Length,s=Math.min(Math.max(this.minHeight,this.root.clientHeight),this.maxHeight),n=Math.min(this.root.clientWidth,e);this.canvas.style.width=`${n}px`,this.canvas.style.height=`${s}px`,this.host.style.width=`${n}px`,this.host.style.height=`${this.root.clientHeight}px`,this.host.style.justifyContent=this.horizontalAlignment,this.host.style.alignContent=this.verticalAlignment===u.vw.TOP?"start":this.verticalAlignment===u.vw.MIDDLE?"center":this.verticalAlignment===u.vw.BOTTOM?"end":"inherit",this.root.clientHeight<this.minHeight&&(this.host.style.alignContent="start",this.host.style.width=`${n+6}px`),this.host.style.width=`${this.host}px`;const i=e>n;if(this.setSliderVisibility(i),i){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 s=this.root.clientWidth/this._positionWidthWithMargin;e=Math.min(Math.max(t,0)+s,this.Length-.001),t=Math.max(0,Math.min(e,this.Length-.001)-s),this.slider.setValues(0,Math.max(this.Length-.001),t,e)}else this.slider.setValues(0,Math.max(0,this.Length-.001),0,Math.max(0,this.Length-.001));this.canvas.width=n*t,this.canvas.height=s*t}calcLayoutFitArea(t){if(!this.host||!this.canvas||!this.slider)return;const e=this._positionWidth*this.Length,s=Math.min(Math.max(this.minHeight,this.root.clientHeight),this.maxHeight),n=e>0?(this.root.clientWidth-this.positionMarginValue*this.Length)/e:0,i=this.root.clientHeight/s,r=Math.max(1,Math.min(n,i));this._positionWidth=this.positionWidth*r,this._positionWidthWithMargin=this._positionWidth+this.positionMarginValue;const o=(this._positionWidth+this.positionMarginValue)*this.Length,a=r*s,l=Math.min(this.root.clientWidth,o);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===u.vw.TOP?"start":this.verticalAlignment===u.vw.MIDDLE?"center":this.verticalAlignment===u.vw.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 h=o>l;if(this.setSliderVisibility(h),h){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 s=this.root.clientWidth/this._positionWidthWithMargin;e=Math.min(Math.max(t,0)+s,this.Length-.001),t=Math.max(0,Math.min(e,this.Length-.001)-s),this.slider.setValues(0,Math.max(0,this.Length-.001),t,e)}else this.slider.setValues(0,Math.max(0,this.Length-.001),0,Math.max(0,this.Length-.001));this.canvas.width=l*t,this.canvas.height=a*t}onPropertyChanged(t){switch(super.onPropertyChanged(t),t.name){case g.sequenceColumnName:this.updateSeqCol();break;case g.sequenceColumnName:case g.startPositionName:case g.endPositionName:case g.filterSource:case g.shrinkEmptyTail:case g.skipEmptyPositions:case g.positionHeight:this.updatePositions();break;case g.minHeight:case g.maxHeight:case g.positionWidth:case g.showPositionLabels:case g.fixWidth:case g.fitArea:case g.horizontalAlignment:case g.verticalAlignment:case g.positionMargin:case g.positionMarginState:this.render(b.Layout,`onPropertyChanged(${t.name})`).then((()=>{}));break;case g.backgroundColor:this.render(b.Render,`onPropertyChanged(${t.name})`).then((()=>{}))}}onTableAttached(){f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.onTableAttached(), `),super.onTableAttached(),this.setData()}async detach(){if(this.setDataInProgress)return;f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.detach(), `);const t=super.detach.bind(this);this.detachPromise=this.detachPromise.then((async()=>{await this.viewPromise,this.viewed&&(await this.destroyView(),this.viewed=!1),t()}))}get onSizeChanged(){return this._onSizeChanged}get onFreqsCalculated(){return this._onFreqsCalculated}get onLayoutCalculated(){return this._onLayoutCalculated}getMonomer(t,e){const s=t.x,n=Math.floor(t.x/(this._positionWidthWithMargin*e)+Math.floor(this.slider.min)),i=this.positions[n];if(void 0===i)return[n,null,null];const r=i.getMonomerAt(s,t.y);return void 0===r?[n,null,null]:[n,r,i.getFreq(r)]}_nullSequence(t="X"){return this.skipEmptySequences?"":new Array(this.Length).fill(t).join("")}_removeEmptyPositions(){this.skipEmptyPositions&&(this.positions=a()(this.positions).filter((t=>{const e=this.unitsHandler.defaultGapSymbol;return!t.hasMonomer(e)||t.getFreq(e).count!==t.rowCount})).toArray())}render(t,e){f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.render( recalcLevelVal=${t}, reason='${e}' )`);const s=()=>{if(f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.render.calculateFreqsInt(), start `),!this.host||!this.seqCol||!this.dataFrame)return;const t=this.startPosition<=this.endPosition?this.endPosition-this.startPosition+1:0;this.unitsHandler=h.Cn.getOrCreate(this.seqCol);const e=this.startPosition<=this.endPosition?this.endPosition-this.startPosition+1:0;this.positions=new Array(e);for(let e=0;e<t;e++){const t=this.positionNames[this.startPosition+e],s=this.positionLabels?this.positionLabels[this.startPosition+e]:void 0;this.positions[e]=new y(this.startPosition+e,t,{},{label:s})}const s=this.getFilter(),n=this.dataFrame.rowCount,i=this.unitsHandler.splitted;for(let e=0;e<n;++e)if(s.get(e)){const s=i[e];for(let e=0;e<t;++e){const t=s[this.startPosition+e]||this.unitsHandler.defaultGapSymbol;this.positions[e].getFreq(t).count++}}for(let e=0;e<t;e++)this.positions[e].calcHeights(this.positionHeight);this._removeEmptyPositions(),this._onFreqsCalculated.next()},i=(t,e)=>{f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.render.calculateLayoutInt(), start `);const s=this.canvas.height-e*t,i=this.getAlphabetSize();this.positionHeight==u.ES.Entropy&&null==i&&n.shell.error("WebLogo: alphabet is undefined.");const r=Math.log2(i);for(let n=Math.floor(this.slider.min);n<=Math.floor(this.slider.max);++n)n in this.positions?this.positions[n].calcScreen((t=>this.unitsHandler.isGap(t)),n,this.slider.min,s,this.positionHeight,r,this._positionWidthWithMargin,this._positionWidth,t,e):console.warn(`Bio: WebLogoViewer<${this.viewerId}>.render.calculateLayoutInt() this.positions.length = ${this.positions.length}, jPos = ${n}`);f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.render.calculateLayoutInt(), end `),this._onLayoutCalculated.next()},o=t=>{if(f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.render.renderInt( recalcLevel=${t} ), start `),this.msgHost&&(this.seqCol&&!this.cp?(this.msgHost.innerText=`Unknown palette (column semType: '${this.seqCol.semType}').`,this.msgHost.style.display=""):this.msgHost.style.display="none"),!this.seqCol||!this.dataFrame||!this.cp||null==this.host||null==this.slider)return;const e=window.devicePixelRatio,n=this.showPositionLabels?12:0;if(t>=b.Freqs&&s(),this.calcLayout(e),0===this.positions.length||-1===this.startPosition||-1===this.endPosition)return;t>=b.Layout&&i(window.devicePixelRatio,n);const o=this.canvas.getContext("2d");if(!o)return;this.Length,o.resetTransform(),o.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),o.fillRect(0,0,this.canvas.width,this.canvas.height),o.textBaseline=this.textBaseline;const a=10*e;o.resetTransform(),o.fillStyle="black",o.textAlign="center",o.font=`${a.toFixed(1)}px Roboto, Roboto Local, sans-serif`;const l=Math.max(...this.positions.map((t=>o.measureText(t.name).width))),h=l<this._positionWidth*e-2?1:(this._positionWidth*e-2)/l;n>0&&function(t,e,s,n,i,r,o,a){for(let l=Math.floor(o);l<=Math.floor(a);l++){const a=r[l];t.resetTransform(),t.setTransform(s,0,0,1,(l-o)*n*e+i*e/2,0),t.fillText(a.label,0,1)}}(o,e,h,this._positionWidthWithMargin,this._positionWidth,this.positions,this.slider.min,this.slider.max);for(let t=Math.floor(this.slider.min);t<=Math.floor(this.slider.max);t++)this.positions[t].render(o,(t=>this.unitsHandler.isGap(t)),"16px Roboto, Roboto Local, sans-serif",.25,12.2,this.cp);f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.render.renderInt( recalcLevel=${t} ), end`)};return this.renderLevelRequested=Math.max(this.renderLevelRequested,t),new Promise(((t,e)=>{window.setTimeout((()=>{try{if(this.renderLevelRequested>b.None)try{o(this.renderLevelRequested)}finally{this.renderLevelRequested=b.None}}catch(t){e(t)}}),0)}))}getAlphabetSize(){return this.unitsHandler?.getAlphabetSize()??0}sliderOnValuesChanged(t){try{const t={minRange:this.slider.minRange,min:this.slider.min,max:this.slider.max,maxRange:this.slider.maxRange};f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.sliderOnValuesChanged( ${JSON.stringify(t)} ), start`),this.render(b.Layout,"sliderOnValuesChanged").then((()=>{}))}catch(t){const e=m(t);f._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.sliderOnValuesChanged() error:\n`+e)}}dataFrameFilterOnChanged(t){f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.dataFrameFilterChanged()`);try{this.updatePositions(),this.filterSource===u.Ct.Filtered&&this.render(b.Freqs,"dataFrameFilterOnChanged").then((()=>{}))}catch(t){const e=m(t);f._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.dataFrameFilterOnChanged() error:\n`+e)}}dataFrameSelectionOnChanged(t){f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.dataFrameSelectionOnChanged()`);try{this.filterSource===u.Ct.Selected&&this.render(b.Freqs,"dataFrameSelectionOnChanged").then((()=>{}))}catch(t){const e=m(t);f._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.dataFrameSelectionOnChanged() error:\n`+e)}}canvasOnMouseMove(t){const e=window.devicePixelRatio;try{const s=t,n=this.canvas.getCursorPosition(s,e),[r,o]=this.getMonomer(n,e);if(this.dataFrame&&this.seqCol&&o){const t=this.positions[r],e=C(this.dataFrame,this.unitsHandler,this.getFilter(),o,t),n=i.div([i.div(`${o}`),i.div(`${e} rows`)]);i.tooltip.show(n,s.x+16,s.y+16)}else i.tooltip.hide()}catch(t){const e=m(t);f._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.canvasOnMouseMove() error:\n`+e)}}canvasOnMouseDown(t){try{const e=t,s=window.devicePixelRatio,[n,i]=this.getMonomer(this.canvas.getCursorPosition(e,s),s);if(this.dataFrame&&this.seqCol&&this.unitsHandler&&i){const t=this.positions[n],e=r.BitSet.create(this.dataFrame.selection.length,(e=>function(t,e,s,n,i,r){const o=e.splitted[n],a=r.pos<o.length?o[r.pos]:null;return a===i||""===a&&i===e.defaultGapSymbol}(this.dataFrame,this.unitsHandler,this.getFilter(),e,i,t)));this.dataFrame.selection.init((t=>e.get(t)))}}catch(t){const e=m(t);f._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.canvasOnMouseDown() error:\n`+e)}}canvasOnWheel(t){const e=window.devicePixelRatio;try{if(!this.visibleSlider)return;const s=this.canvas.width/(this._positionWidthWithMargin*e),n=t.deltaY/100*Math.max(Math.floor(s/5),1);this.slider.scrollBy(this.slider.min+n)}catch(t){const e=m(t);f._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.canvasOnWheel() error:\n`+e)}}}function C(t,e,s,n,i){let r=0,o=-1;for(;-1!=(o=s.findNext(o,!0));){const t=e.splitted[o],s=i.pos;(s<t.length?t[s]:null)===n&&r++}return r}T.residuesSet="nucleotides",T.viewerCount=0},4413:(t,e,s)=>{"use strict";s.d(e,{ST:()=>g});var n=s(3870),i=s(976),r=s(4469),o=s(6414),a=s.n(o),l=s(7983),h=s(701),c=s(4293),u=s(8447),m=s(1061);const d=rxjs.operators;class g extends i.Filter{get calculating(){return"initial"==this.loader.style.display}set calculating(t){this.loader.style.display=t?"initial":"none"}get filterSummary(){return this.bioFilter.substructure}get isFiltering(){return super.isFiltering&&""!==this.bioFilter.substructure}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(){super(),this.bioFilter=null,this.bitset=null,this.loader=n.loader(),this.notation=void 0,this.root=n.divV([]),this.calculating=!1}attach(t){super.attach(t),this.column=t.columns.bySemType(i.SEMTYPE.MACROMOLECULE),this.columnName??(this.columnName=this.column?.name),this.notation??(this.notation=this.column?.getTag(i.TAGS.UNITS)),this.bioFilter=this.notation===u.r2.FASTA?new p:this.notation===u.r2.SEPARATOR?new y(this.column.getTag("separator")):new w,this.root.appendChild(this.bioFilter.filterPanel),this.root.appendChild(this.loader),this.onBioFilterChangedSubs?.unsubscribe();let e=this.bioFilter.onChanged;e=e.pipe((0,d.debounceTime)(this._debounceTime)),this.onBioFilterChangedSubs=e.subscribe((async t=>await this._onInputChanged())),this.subs.push(r.events.onResetFilterRequest.subscribe((t=>{this.bioFilter?.resetFilter()})))}detach(){super.detach()}applyFilter(){this.bitset&&!this.isDetached&&this.dataFrame?.filter.and(this.bitset)}saveState(){const t=super.saveState();return t.bioSubstructure=this.bioFilter?.substructure,t}applyState(t){super.applyState(t),t.bioSubstructure&&(this.bioFilter.substructure=t.bioSubstructure);const e=this;t.bioSubstructure&&setTimeout((function(){e._onInputChanged()}),1e3)}async _onInputChanged(){if(this.isFiltering){if(a()(this.dataFrame.rows.filters).has(`${this.columnName}: ${this.filterSummary}`))return;this.calculating=!0;try{this.bitset=await(this.bioFilter?.substructureSearch(this.column)),this.calculating=!1,this.dataFrame?.rows.requestFilter()}finally{this.calculating=!1}}else this.bitset=null,this.dataFrame?.rows.requestFilter()}}class f{constructor(){this.onChanged=new h.Subject}get filterPanel(){return new HTMLElement}get substructure(){return""}set substructure(t){}async substructureSearch(t){return null}}class p extends f{constructor(){super(),this.substructureInput=n.stringInput("","",(()=>{this.onChanged.next()}),{placeholder:"Substructure"})}get filterPanel(){return this.substructureInput.root}get substructure(){return this.substructureInput.value}set substructure(t){this.substructureInput.value=t}async substructureSearch(t){return(0,l.pf)(this.substructure,t)}resetFilter(){this.substructureInput.value=""}}class y extends p{constructor(t){super(),this.colSeparator="",this.separatorInput=n.stringInput("","",(()=>{this.onChanged.next()}),{placeholder:"Separator"}),this.colSeparator=t,this.separatorInput.value=t}get filterPanel(){return n.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,l.pf)(this.substructure,t,this.colSeparator)}}class w extends f{constructor(){super(),this._filterPanel=n.div("",{style:{cursor:"pointer"}}),this.helmSubstructure="",this.init()}async init(){this.helmEditor=await r.functions.call("HELM:helmWebEditor"),await n.tools.waitForElementInDom(this._filterPanel),this.updateFilterPanel(),this._filterPanel.addEventListener("click",(t=>{const{editorDiv:e,webEditor:s}=this.helmEditor.createWebEditor(this.helmSubstructure);n.dialog({showHeader:!1,showFooter:!0}).add(e).onOK((()=>{const t=s.canvas.getHelm(!0).replace(/<\/span>/g,"").replace(/<span style='background:#bbf;'>/g,"");this.helmSubstructure=t,this.updateFilterPanel(this.substructure),setTimeout((()=>{this.onChanged.next()}),10)})).show({modal:!0,fullScreen:!0})})),n.onSizeChanged(this._filterPanel).subscribe((t=>{const e=this.helmEditor.webEditor.canvas.getHelm(!0).replace(/<\/span>/g,"").replace(/<span style='background:#bbf;'>/g,"");this.updateFilterPanel(e)}))}get filterPanel(){return this._filterPanel}get substructure(){return this.helmSubstructure}set substructure(t){this.helmEditor.editor.setHelm(t)}updateFilterPanel(t){const e=this._filterPanel.parentElement.clientWidth<100?100:this._filterPanel.parentElement.clientWidth,s=e/2;if(t)(0,c.Y)(this._filterPanel,this.helmEditor.host),this.helmEditor.editor.setHelm(t),this.helmEditor.resizeEditor(e,s);else{const t=n.divText("Click to edit","helm-substructure-filter");(0,c.Y)(this._filterPanel,t)}}async substructureSearch(t){n.setUpdateIndicator(this._filterPanel,!0),await(0,m.gw)(10);const e=await(0,l.QF)(this.substructure,t);return n.setUpdateIndicator(this._filterPanel,!1),e}resetFilter(){console.debug("Bio: HelmFilter.resetFilter()"),this.helmSubstructure="",this.updateFilterPanel(this.substructure)}}},9378:function(t,e,s){"use strict";var n=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var s in t)Object.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e.default=t,e};Object.defineProperty(e,"__esModule",{value:!0});var i=n(s(4517));function r(t,e){var s=function(s){return i.empty(t).map((function(){return i.filled(e,s)}))},n=[];return n.push(s(-1)),n.push(s(1/0)),n.push(s(0)),n}function o(t,e,s,n,i){e=Math.floor(e);var r=t[0][e],o=t[1][e];if(t[2][e],s>=o[0])return 0;for(var l=0;l<r.length;l++)if(n===r[l])return 0;return a(t,e,s,n,i)}function a(t,e,s,n,i){var r=t[0][e],o=t[1][e],a=t[2][e];if(s>=o[0])return 0;o[0]=s,r[0]=n,a[0]=i;for(var l=0,h=0;;){var c=2*l+1,u=c+1,m=t[0][0].length;if(c>=m)break;if(u>=m){if(!(o[c]>s))break;h=c}else if(o[c]>=o[u]){if(!(s<o[c]))break;h=c}else{if(!(s<o[u]))break;h=u}o[l]=o[h],r[l]=r[h],a[l]=a[h],l=h}return o[l]=s,r[l]=n,a[l]=i,1}function l(t,e,s,n){for(;2*n+1<s;){var i=2*n+1,r=i+1,o=n;if(t[o]<t[i]&&(o=i),r<s&&t[o]<t[r]&&(o=r),o===n)break;var a=t[n];t[n]=t[o],t[o]=a;var l=e[n];e[n]=e[o],e[o]=l,n=o}}e.makeHeap=r,e.rejectionSample=function(t,e,s){for(var n=i.zeros(t),r=0;r<t;r++){for(var o=!0,a=0;o;){a=i.tauRandInt(e,s);for(var l=!1,h=0;h<r;h++)if(a===n[h]){l=!0;break}l||(o=!1)}n[r]=a}return n},e.heapPush=o,e.uncheckedHeapPush=a,e.buildCandidates=function(t,e,s,n,a){for(var l=r(e,n),h=0;h<e;h++)for(var c=0;c<s;c++)if(!(t[0][h][c]<0)){var u=t[0][h][c],m=t[2][h][c],d=i.tauRand(a);o(l,h,d,u,m),o(l,u,d,h,m),t[2][h][c]=0}return l},e.deheapSort=function(t){for(var e=t[0],s=t[1],n=0;n<e.length;n++)for(var i=e[n],r=s[n],o=0;o<i.length-1;o++){var a=i.length-o-1,h=r.length-o-1,c=i[0];i[0]=i[a],i[a]=c;var u=r[0];r[0]=r[h],r[h]=u,l(r,i,h,0)}return{indices:e,weights:s}},e.smallestFlagged=function(t,e){for(var s=t[0][e],n=t[1][e],i=t[2][e],r=1/0,o=-1,a=0;a>s.length;a++)1===i[a]&&n[a]<r&&(r=n[a],o=a);return o>=0?(i[o]=0,Math.floor(s[o])):-1}},4221:(t,e,s)=>{"use strict";var n=s(4364);e.u=n.UMAP},5686:function(t,e,s){"use strict";var n,i=this&&this.__read||function(t,e){var s="function"==typeof Symbol&&t[Symbol.iterator];if(!s)return t;var n,i,r=s.call(t),o=[];try{for(;(void 0===e||e-- >0)&&!(n=r.next()).done;)o.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(s=r.return)&&s.call(r)}finally{if(i)throw i.error}}return o},r=this&&this.__values||function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],s=0;return e?e.call(t):{next:function(){return t&&s>=t.length&&(t=void 0),{value:t&&t[s++],done:!t}}}},o=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var s in t)Object.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e.default=t,e};Object.defineProperty(e,"__esModule",{value:!0});var a=o(s(4517)),l=function(){function t(t,e,s,n){if(this.entries=new Map,this.nRows=0,this.nCols=0,t.length!==e.length||t.length!==s.length)throw new Error("rows, cols and values arrays must all have the same length");this.nRows=n[0],this.nCols=n[1];for(var i=0;i<s.length;i++){var r=t[i],o=e[i];this.checkDims(r,o);var a=this.makeKey(r,o);this.entries.set(a,{value:s[i],row:r,col:o})}}return t.prototype.makeKey=function(t,e){return t+":"+e},t.prototype.checkDims=function(t,e){if(!(t<this.nRows&&e<this.nCols))throw new Error("row and/or col specified outside of matrix dimensions")},t.prototype.set=function(t,e,s){this.checkDims(t,e);var n=this.makeKey(t,e);this.entries.has(n)?this.entries.get(n).value=s:this.entries.set(n,{value:s,row:t,col:e})},t.prototype.get=function(t,e,s){void 0===s&&(s=0),this.checkDims(t,e);var n=this.makeKey(t,e);return this.entries.has(n)?this.entries.get(n).value:s},t.prototype.getAll=function(t){void 0===t&&(t=!0);var e=[];return this.entries.forEach((function(t){e.push(t)})),t&&e.sort((function(t,e){return t.row===e.row?t.col-e.col:t.row-e.row})),e},t.prototype.getDims=function(){return[this.nRows,this.nCols]},t.prototype.getRows=function(){return Array.from(this.entries,(function(t){var e=i(t,2);return e[0],e[1].row}))},t.prototype.getCols=function(){return Array.from(this.entries,(function(t){var e=i(t,2);return e[0],e[1].col}))},t.prototype.getValues=function(){return Array.from(this.entries,(function(t){var e=i(t,2);return e[0],e[1].value}))},t.prototype.forEach=function(t){this.entries.forEach((function(e){return t(e.value,e.row,e.col)}))},t.prototype.map=function(e){var s=[];this.entries.forEach((function(t){s.push(e(t.value,t.row,t.col))}));var n=[this.nRows,this.nCols];return new t(this.getRows(),this.getCols(),s,n)},t.prototype.toArray=function(){var t=this,e=a.empty(this.nRows).map((function(){return a.zeros(t.nCols)}));return this.entries.forEach((function(t){e[t.row][t.col]=t.value})),e},t}();e.SparseMatrix=l,e.transpose=function(t){var e=[],s=[],n=[];t.forEach((function(t,i,r){e.push(i),s.push(r),n.push(t)}));var i=[t.nCols,t.nRows];return new l(s,e,n,i)},e.identity=function(t){for(var e=i(t,1)[0],s=new l([],[],[],t),n=0;n<e;n++)s.set(n,n,1);return s},e.pairwiseMultiply=function(t,e){return c(t,e,(function(t,e){return t*e}))},e.add=function(t,e){return c(t,e,(function(t,e){return t+e}))},e.subtract=function(t,e){return c(t,e,(function(t,e){return t-e}))},e.maximum=function(t,e){return c(t,e,(function(t,e){return t>e?t:e}))},e.multiplyScalar=function(t,e){return t.map((function(t){return t*e}))},e.eliminateZeros=function(t){for(var e=new Set,s=t.getValues(),n=t.getRows(),i=t.getCols(),r=0;r<s.length;r++)0===s[r]&&e.add(r);var o=function(t,s){return!e.has(s)},a=s.filter(o),h=n.filter(o),c=i.filter(o);return new l(h,c,a,t.getDims())},e.normalize=function(t,e){var s,n;void 0===e&&(e="l2");var i=h[e],o=new Map;t.forEach((function(t,e,s){var n=o.get(e)||[];n.push(s),o.set(e,n)}));var a=new l([],[],[],t.getDims()),c=function(e){for(var s=o.get(e).sort(),n=s.map((function(s){return t.get(e,s)})),r=i(n),l=0;l<r.length;l++)a.set(e,s[l],r[l])};try{for(var u=r(o.keys()),m=u.next();!m.done;m=u.next())c(m.value)}catch(t){s={error:t}}finally{try{m&&!m.done&&(n=u.return)&&n.call(u)}finally{if(s)throw s.error}}return a};var h=((n={}).max=function(t){for(var e=-1/0,s=0;s<t.length;s++)e=t[s]>e?t[s]:e;return t.map((function(t){return t/e}))},n.l1=function(t){for(var e=0,s=0;s<t.length;s++)e+=t[s];return t.map((function(t){return t/e}))},n.l2=function(t){for(var e=0,s=0;s<t.length;s++)e+=Math.pow(t[s],2);return t.map((function(t){return Math.sqrt(Math.pow(t,2)/e)}))},n);function c(t,e,s){for(var n=new Set,i=[],r=[],o=[],a=function(n,a){i.push(n),r.push(a);var l=s(t.get(n,a),e.get(n,a));o.push(l)},h=t.getValues(),c=t.getRows(),u=t.getCols(),m=0;m<h.length;m++){var d=(y=c[m])+":"+(w=u[m]);n.add(d),a(y,w)}var g=e.getValues(),f=e.getRows(),p=e.getCols();for(m=0;m<g.length;m++){var y,w;d=(y=f[m])+":"+(w=p[m]),n.has(d)||a(y,w)}var b=[t.nRows,t.nCols];return new l(i,r,o,b)}e.getCSR=function(t){var e=[];t.forEach((function(t,s,n){e.push({value:t,row:s,col:n})})),e.sort((function(t,e){return t.row===e.row?t.col-e.col:t.row-e.row}));for(var s=[],n=[],i=[],r=-1,o=0;o<e.length;o++){var a=e[o],l=a.row,h=a.col,c=a.value;l!==r&&(r=l,i.push(o)),s.push(h),n.push(c)}return{indices:s,values:n,indptr:i}}},760:function(t,e,s){"use strict";var n=this&&this.__values||function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],s=0;return e?e.call(t):{next:function(){return t&&s>=t.length&&(t=void 0),{value:t&&t[s++],done:!t}}}},i=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var s in t)Object.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e.default=t,e};Object.defineProperty(e,"__esModule",{value:!0});var r=i(s(9378)),o=i(s(5686)),a=i(s(2320)),l=i(s(4517));e.makeNNDescent=function(t,e){return function(s,n,i,o,a,h,c,u){void 0===o&&(o=10),void 0===a&&(a=50),void 0===h&&(h=.001),void 0===c&&(c=.5),void 0===u&&(u=!0);for(var m=s.length,d=r.makeHeap(s.length,i),g=0;g<s.length;g++)for(var f=r.rejectionSample(i,s.length,e),p=0;p<f.length;p++){var y=t(s[g],s[f[p]]);r.heapPush(d,g,y,f[p],1),r.heapPush(d,f[p],y,g,1)}if(u)for(var w=0;w<n.length;w++)for(g=0;g<n[w].length&&!(n[w][g]<0);g++)for(p=g+1;p<n[w].length&&!(n[w][p]<0);p++)y=t(s[n[w][g]],s[n[w][p]]),r.heapPush(d,n[w][g],y,n[w][p],1),r.heapPush(d,n[w][p],y,n[w][g],1);for(w=0;w<o;w++){var b=r.buildCandidates(d,m,i,a,e),T=0;for(g=0;g<m;g++)for(p=0;p<a;p++){var C=Math.floor(b[0][g][p]);if(!(C<0||l.tauRand(e)<c))for(var S=0;S<a;S++){var A=Math.floor(b[0][g][S]),v=b[2][g][p],E=b[2][g][S];A<0||!v&&!E||(y=t(s[C],s[A]),T+=r.heapPush(d,C,y,A,1),T+=r.heapPush(d,A,y,C,1))}}if(T<=h*i*s.length)break}return r.deheapSort(d)}},e.makeInitializations=function(t){return{initFromRandom:function(e,s,n,i,o){for(var a=0;a<n.length;a++)for(var h=l.rejectionSample(e,s.length,o),c=0;c<h.length;c++)if(!(h[c]<0)){var u=t(s[h[c]],n[a]);r.heapPush(i,a,u,h[c],1)}},initFromTree:function(e,s,n,i,o){for(var l=0;l<n.length;l++)for(var h=a.searchFlatTree(n[l],e,o),c=0;c<h.length;c++){if(h[c]<0)return;var u=t(s[h[c]],n[l]);r.heapPush(i,l,u,h[c],1)}}}},e.makeInitializedNNSearch=function(t){return function(e,s,i,a){for(var l,h,c=o.getCSR(s),u=c.indices,m=c.indptr,d=0;d<a.length;d++)for(var g=new Set(i[0][d]);;){var f=r.smallestFlagged(i,d);if(-1===f)break;var p=u.slice(m[f],m[f+1]);try{for(var y=n(p),w=y.next();!w.done;w=y.next()){var b=w.value;if(b!==f&&-1!==b&&!g.has(b)){var T=t(e[b],a[d]);r.uncheckedHeapPush(i,d,T,b,1),g.add(b)}}}catch(t){l={error:t}}finally{try{w&&!w.done&&(h=y.return)&&h.call(y)}finally{if(l)throw l.error}}}return i}},e.initializeSearch=function(t,e,s,i,o,a,l){var h,c,u=r.makeHeap(s.length,i);if(o(i,e,s,u,l),t)try{for(var m=n(t),d=m.next();!d.done;d=m.next())a(d.value,e,s,u,l)}catch(t){h={error:t}}finally{try{d&&!d.done&&(c=m.return)&&c.call(m)}finally{if(h)throw h.error}}return u}},2320:function(t,e,s){"use strict";var n=this&&this.__read||function(t,e){var s="function"==typeof Symbol&&t[Symbol.iterator];if(!s)return t;var n,i,r=s.call(t),o=[];try{for(;(void 0===e||e-- >0)&&!(n=r.next()).done;)o.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(s=r.return)&&s.call(r)}finally{if(i)throw i.error}}return o},i=this&&this.__spread||function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(n(arguments[e]));return t},r=this&&this.__values||function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],s=0;return e?e.call(t):{next:function(){return t&&s>=t.length&&(t=void 0),{value:t&&t[s++],done:!t}}}},o=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var s in t)Object.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e.default=t,e};Object.defineProperty(e,"__esModule",{value:!0});var a=o(s(4517)),l=function(t,e,s,n){this.hyperplanes=t,this.offsets=e,this.children=s,this.indices=n};function h(t,e,s,n,i){if(void 0===s&&(s=30),e.length>s){var r=function(t,e,s){var n=t[0].length,i=a.tauRandInt(e.length,s),r=a.tauRandInt(e.length,s);r=(r+=i===r?1:0)%e.length;for(var o=e[i],l=e[r],h=0,c=a.zeros(n),u=0;u<c.length;u++)c[u]=t[o][u]-t[l][u],h-=c[u]*(t[o][u]+t[l][u])/2;var m=0,d=0,g=a.zeros(e.length);for(u=0;u<e.length;u++){for(var f=h,p=0;p<n;p++)f+=c[p]*t[e[u]][p];0===f?(g[u]=a.tauRandInt(2,s),0===g[u]?m+=1:d+=1):f>0?(g[u]=0,m+=1):(g[u]=1,d+=1)}var y=a.zeros(m),w=a.zeros(d);for(m=0,d=0,u=0;u<g.length;u++)0===g[u]?(y[m]=e[u],m+=1):(w[d]=e[u],d+=1);return{indicesLeft:y,indicesRight:w,hyperplane:c,offset:h}}(t,e,i),o=r.indicesLeft,l=r.indicesRight,c=r.hyperplane,u=r.offset;return{leftChild:h(t,o,s,n+1,i),rightChild:h(t,l,s,n+1,i),isLeaf:!1,hyperplane:c,offset:u}}return{indices:e,isLeaf:!0}}function c(t,e,s,n,r,o,a){var l;if(t.isLeaf)return n[o][0]=-a,(l=r[a]).splice.apply(l,i([0,t.indices.length],t.indices)),{nodeNum:o,leafNum:a+=1};e[o]=t.hyperplane,s[o]=t.offset,n[o][0]=o+1;var h=o,u=c(t.leftChild,e,s,n,r,o+1,a);return o=u.nodeNum,a=u.leafNum,n[h][1]=o+1,{nodeNum:(u=c(t.rightChild,e,s,n,r,o+1,a)).nodeNum,leafNum:u.leafNum}}function u(t){return t.isLeaf?1:1+u(t.leftChild)+u(t.rightChild)}function m(t){return t.isLeaf?1:m(t.leftChild)+m(t.rightChild)}function d(t,e,s,n){for(var i=e,r=0;r<s.length;r++)i+=t[r]*s[r];return 0===i?a.tauRandInt(2,n):i>0?0:1}e.FlatTree=l,e.makeForest=function(t,e,s,n){var i=Math.max(10,e);return a.range(s).map((function(e,s){return function(t,e,s,n){return void 0===e&&(e=30),h(t,a.range(t.length),e,s,n)}(t,i,s,n)})).map((function(t){return function(t,e){var s=u(t),n=m(t),i=a.range(s).map((function(){return a.zeros(t.hyperplane?t.hyperplane.length:0)})),r=a.zeros(s),o=a.range(s).map((function(){return[-1,-1]})),h=a.range(n).map((function(){return a.range(e).map((function(){return-1}))}));return c(t,i,r,o,h,0,0),new l(i,r,o,h)}(t,i)}))},e.makeLeafArray=function(t){var e,s;if(t.length>0){var n=[];try{for(var o=r(t),a=o.next();!a.done;a=o.next()){var l=a.value;n.push.apply(n,i(l.indices))}}catch(t){e={error:t}}finally{try{a&&!a.done&&(s=o.return)&&s.call(o)}finally{if(e)throw e.error}}return n}return[[-1]]},e.searchFlatTree=function(t,e,s){for(var n=0;e.children[n][0]>0;)n=0===d(e.hyperplanes[n],e.offsets[n],t,s)?e.children[n][0]:e.children[n][1];var i=-1*e.children[n][0];return e.indices[i]}},4364:function(t,e,s){"use strict";var n=this&&this.__awaiter||function(t,e,s,n){return new(s||(s=Promise))((function(i,r){function o(t){try{l(n.next(t))}catch(t){r(t)}}function a(t){try{l(n.throw(t))}catch(t){r(t)}}function l(t){t.done?i(t.value):new s((function(e){e(t.value)})).then(o,a)}l((n=n.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var s,n,i,r,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return r={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function a(r){return function(a){return function(r){if(s)throw new TypeError("Generator is already executing.");for(;o;)try{if(s=1,n&&(i=2&r[0]?n.return:r[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,r[1])).done)return i;switch(n=0,i&&(r=[2&r[0],i.value]),r[0]){case 0:case 1:i=r;break;case 4:return o.label++,{value:r[1],done:!1};case 5:o.label++,n=r[1],r=[0];continue;case 7:r=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==r[0]&&2!==r[0])){o=0;continue}if(3===r[0]&&(!i||r[1]>i[0]&&r[1]<i[3])){o.label=r[1];break}if(6===r[0]&&o.label<i[1]){o.label=i[1],i=r;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(r);break}i[2]&&o.ops.pop(),o.trys.pop();continue}r=e.call(t,o)}catch(t){r=[6,t],n=0}finally{s=i=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,a])}}},r=this&&this.__read||function(t,e){var s="function"==typeof Symbol&&t[Symbol.iterator];if(!s)return t;var n,i,r=s.call(t),o=[];try{for(;(void 0===e||e-- >0)&&!(n=r.next()).done;)o.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(s=r.return)&&s.call(r)}finally{if(i)throw i.error}}return o},o=this&&this.__spread||function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(r(arguments[e]));return t},a=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var s in t)Object.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e.default=t,e},l=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var h=a(s(9378)),c=a(s(5686)),u=a(s(760)),m=a(s(2320)),d=a(s(4517)),g=l(s(9251)),f=1e-5,p=.001,y=function(){function t(t){void 0===t&&(t={});var e=this;this.learningRate=1,this.localConnectivity=1,this.minDist=.1,this.nComponents=2,this.nEpochs=0,this.nNeighbors=15,this.negativeSampleRate=5,this.random=Math.random,this.repulsionStrength=1,this.setOpMixRatio=1,this.spread=1,this.transformQueueSize=4,this.targetMetric="categorical",this.targetWeight=.5,this.targetNNeighbors=this.nNeighbors,this.distanceFn=w,this.isInitialized=!1,this.rpForest=[],this.embedding=[],this.optimizationState=new b;var s=function(s){void 0!==t[s]&&(e[s]=t[s])};s("distanceFn"),s("learningRate"),s("localConnectivity"),s("minDist"),s("nComponents"),s("nEpochs"),s("nNeighbors"),s("negativeSampleRate"),s("random"),s("repulsionStrength"),s("setOpMixRatio"),s("spread"),s("transformQueueSize")}return t.prototype.fit=function(t){return this.initializeFit(t),this.optimizeLayout(),this.embedding},t.prototype.fitAsync=function(t,e){return void 0===e&&(e=function(){return!0}),n(this,void 0,void 0,(function(){return i(this,(function(s){switch(s.label){case 0:return this.initializeFit(t),[4,this.optimizeLayoutAsync(e)];case 1:return s.sent(),[2,this.embedding]}}))}))},t.prototype.setSupervisedProjection=function(t,e){void 0===e&&(e={}),this.Y=t,this.targetMetric=e.targetMetric||this.targetMetric,this.targetWeight=e.targetWeight||this.targetWeight,this.targetNNeighbors=e.targetNNeighbors||this.targetNNeighbors},t.prototype.setPrecomputedKNN=function(t,e){this.knnIndices=t,this.knnDistances=e},t.prototype.initializeFit=function(t){if(t.length<=this.nNeighbors)throw new Error("Not enough data points ("+t.length+") to create nNeighbors: "+this.nNeighbors+". Add more data points or adjust the configuration.");if(this.X===t&&this.isInitialized)return this.getNEpochs();if(this.X=t,!this.knnIndices&&!this.knnDistances){var e=this.nearestNeighbors(t);this.knnIndices=e.knnIndices,this.knnDistances=e.knnDistances}this.graph=this.fuzzySimplicialSet(t,this.nNeighbors,this.setOpMixRatio),this.makeSearchFns(),this.searchGraph=this.makeSearchGraph(t),this.processGraphForSupervisedProjection();var s=this.initializeSimplicialSetEmbedding(),n=s.head,i=s.tail,r=s.epochsPerSample;return this.optimizationState.head=n,this.optimizationState.tail=i,this.optimizationState.epochsPerSample=r,this.initializeOptimization(),this.prepareForOptimizationLoop(),this.isInitialized=!0,this.getNEpochs()},t.prototype.makeSearchFns=function(){var t=u.makeInitializations(this.distanceFn),e=t.initFromTree,s=t.initFromRandom;this.initFromTree=e,this.initFromRandom=s,this.search=u.makeInitializedNNSearch(this.distanceFn)},t.prototype.makeSearchGraph=function(t){for(var e=this.knnIndices,s=this.knnDistances,n=[t.length,t.length],i=new c.SparseMatrix([],[],[],n),r=0;r<e.length;r++)for(var o=e[r],a=s[r],l=0;l<o.length;l++){var h=o[l],u=a[l];u>0&&i.set(r,h,u)}var m=c.transpose(i);return c.maximum(i,m)},t.prototype.transform=function(t){var e=this,s=this.X;if(void 0===s||0===s.length)throw new Error("No data has been fit.");var n=Math.floor(this.nNeighbors*this.transformQueueSize);n=Math.min(s.length,n);var i=u.initializeSearch(this.rpForest,s,t,n,this.initFromRandom,this.initFromTree,this.random),r=this.search(s,this.searchGraph,i,t),o=h.deheapSort(r),a=o.indices,l=o.weights;a=a.map((function(t){return t.slice(0,e.nNeighbors)})),l=l.map((function(t){return t.slice(0,e.nNeighbors)}));var m=Math.max(0,this.localConnectivity-1),g=this.smoothKNNDistance(l,this.nNeighbors,m),f=g.sigmas,p=g.rhos,y=this.computeMembershipStrengths(a,l,f,p),w=y.rows,b=y.cols,T=y.vals,C=[t.length,s.length],S=new c.SparseMatrix(w,b,T,C),A=c.normalize(S,"l1"),v=c.getCSR(A),M=t.length,N=E(d.reshape2d(v.indices,M,this.nNeighbors),d.reshape2d(v.values,M,this.nNeighbors),this.embedding),_=this.nEpochs?this.nEpochs/3:S.nRows<=1e4?100:30,P=S.getValues().reduce((function(t,e){return e>t?e:t}),0);S=S.map((function(t){return t<P/_?0:t})),S=c.eliminateZeros(S);var L=this.makeEpochsPerSample(S.getValues(),_),R=S.getRows(),x=S.getCols();return this.assignOptimizationStateParameters({headEmbedding:N,tailEmbedding:this.embedding,head:R,tail:x,currentEpoch:0,nEpochs:_,nVertices:S.getDims()[1],epochsPerSample:L}),this.prepareForOptimizationLoop(),this.optimizeLayout()},t.prototype.processGraphForSupervisedProjection=function(){var t=this.Y,e=this.X;if(t){if(t.length!==e.length)throw new Error("Length of X and y must be equal");if("categorical"===this.targetMetric){var s=this.targetWeight<1?1/(1-this.targetWeight)*2.5:1e12;this.graph=this.categoricalSimplicialSetIntersection(this.graph,t,s)}}},t.prototype.step=function(){var t=this.optimizationState.currentEpoch;return t<this.getNEpochs()&&this.optimizeLayoutStep(t),this.optimizationState.currentEpoch},t.prototype.getEmbedding=function(){return this.embedding},t.prototype.nearestNeighbors=function(t){var e,s=this.distanceFn,n=this.nNeighbors,i=u.makeNNDescent(s,this.random),r=5+Math.floor(.5==(e=Math.pow(t.length,.5)/20)?0:Math.round(e)),o=Math.max(5,Math.floor(Math.round(function(t){return Math.log(t)/Math.log(2)}(t.length))));this.rpForest=m.makeForest(t,n,r,this.random);var a=i(t,m.makeLeafArray(this.rpForest),n,o);return{knnIndices:a.indices,knnDistances:a.weights}},t.prototype.fuzzySimplicialSet=function(t,e,s){void 0===s&&(s=1);var n=this,i=n.knnIndices,r=void 0===i?[]:i,o=n.knnDistances,a=void 0===o?[]:o,l=n.localConnectivity,h=this.smoothKNNDistance(a,e,l),u=h.sigmas,m=h.rhos,d=this.computeMembershipStrengths(r,a,u,m),g=d.rows,f=d.cols,p=d.vals,y=[t.length,t.length],w=new c.SparseMatrix(g,f,p,y),b=c.transpose(w),T=c.pairwiseMultiply(w,b),C=c.subtract(c.add(w,b),T),S=c.multiplyScalar(C,s),A=c.multiplyScalar(T,1-s);return c.add(S,A)},t.prototype.categoricalSimplicialSetIntersection=function(t,e,s,n){void 0===n&&(n=1);var i=A(t,e,n,s);return v(i=c.eliminateZeros(i))},t.prototype.smoothKNNDistance=function(t,e,s,n,i){void 0===s&&(s=1),void 0===n&&(n=64),void 0===i&&(i=1);for(var r=Math.log(e)/Math.log(2)*i,o=d.zeros(t.length),a=d.zeros(t.length),l=0;l<t.length;l++){var h=0,c=1/0,u=1,m=t[l],g=m.filter((function(t){return t>0}));if(g.length>=s){var y=Math.floor(s),w=s-y;y>0?(o[l]=g[y-1],w>f&&(o[l]+=w*(g[y]-g[y-1]))):o[l]=w*g[0]}else g.length>0&&(o[l]=d.max(g));for(var b=0;b<n;b++){for(var T=0,C=1;C<t[l].length;C++){var S=t[l][C]-o[l];T+=S>0?Math.exp(-S/u):1}if(Math.abs(T-r)<f)break;T>r?u=(h+(c=u))/2:(h=u,c===1/0?u*=2:u=(h+c)/2)}if(a[l]=u,o[l]>0){var A=d.mean(m);a[l]<p*A&&(a[l]=p*A)}else{var v=d.mean(t.map(d.mean));a[l]<p*v&&(a[l]=p*v)}}return{sigmas:a,rhos:o}},t.prototype.computeMembershipStrengths=function(t,e,s,n){for(var i=t.length,r=t[0].length,o=d.zeros(i*r),a=d.zeros(i*r),l=d.zeros(i*r),h=0;h<i;h++)for(var c=0;c<r;c++){var u=0;-1!==t[h][c]&&(u=t[h][c]===h?0:e[h][c]-n[h]<=0?1:Math.exp(-(e[h][c]-n[h])/s[h]),o[h*r+c]=h,a[h*r+c]=t[h][c],l[h*r+c]=u)}return{rows:o,cols:a,vals:l}},t.prototype.initializeSimplicialSetEmbedding=function(){for(var t=this,e=this.getNEpochs(),s=this.nComponents,n=this.graph.getValues(),i=0,r=0;r<n.length;r++){var o=n[r];i<n[r]&&(i=o)}var a=this.graph.map((function(t){return t<i/e?0:t}));this.embedding=d.zeros(a.nRows).map((function(){return d.zeros(s).map((function(){return 20*d.tauRand(t.random)-10}))}));var l=[],h=[],c=[],u=a.getAll();for(r=0;r<u.length;r++){var m=u[r];m.value&&(l.push(m.value),c.push(m.row),h.push(m.col))}return{head:h,tail:c,epochsPerSample:this.makeEpochsPerSample(l,e)}},t.prototype.makeEpochsPerSample=function(t,e){var s=d.filled(t.length,-1),n=d.max(t),i=t.map((function(t){return t/n*e}));return i.forEach((function(t,n){t>0&&(s[n]=e/i[n])})),s},t.prototype.assignOptimizationStateParameters=function(t){Object.assign(this.optimizationState,t)},t.prototype.prepareForOptimizationLoop=function(){var t=this,e=t.repulsionStrength,s=t.learningRate,n=t.negativeSampleRate,i=this.optimizationState,r=i.epochsPerSample,a=i.headEmbedding,l=i.tailEmbedding,h=a[0].length,c=a.length===l.length,u=r.map((function(t){return t/n})),m=o(u),d=o(r);this.assignOptimizationStateParameters({epochOfNextSample:d,epochOfNextNegativeSample:m,epochsPerNegativeSample:u,moveOther:c,initialAlpha:s,alpha:s,gamma:e,dim:h})},t.prototype.initializeOptimization=function(){var t=this.embedding,e=this.embedding,s=this.optimizationState,n=s.head,i=s.tail,r=s.epochsPerSample,o=this.getNEpochs(),a=this.graph.nCols,l=S(this.spread,this.minDist),h=l.a,c=l.b;this.assignOptimizationStateParameters({headEmbedding:t,tailEmbedding:e,head:n,tail:i,epochsPerSample:r,a:h,b:c,nEpochs:o,nVertices:a})},t.prototype.optimizeLayoutStep=function(t){for(var e=this.optimizationState,s=e.head,n=e.tail,i=e.headEmbedding,r=e.tailEmbedding,o=e.epochsPerSample,a=e.epochOfNextSample,l=e.epochOfNextNegativeSample,h=e.epochsPerNegativeSample,c=e.moveOther,u=e.initialAlpha,m=e.alpha,g=e.gamma,f=e.a,p=e.b,y=e.dim,w=e.nEpochs,b=e.nVertices,S=0;S<o.length;S++)if(!(a[S]>t)){var A=s[S],v=n[S],E=i[A],M=r[v],N=C(E,M),_=0;N>0&&(_=-2*f*p*Math.pow(N,p-1),_/=f*Math.pow(N,p)+1);for(var P=0;P<y;P++){var L=T(_*(E[P]-M[P]),4);E[P]+=L*m,c&&(M[P]+=-L*m)}a[S]+=o[S];for(var R=Math.floor((t-l[S])/h[S]),x=0;x<R;x++){var I=d.tauRandInt(b,this.random),O=r[I],F=C(E,O),D=0;if(F>0)D=2*g*p,D/=(.001+F)*(f*Math.pow(F,p)+1);else if(A===I)continue;for(P=0;P<y;P++)L=4,D>0&&(L=T(D*(E[P]-O[P]),4)),E[P]+=L*m}l[S]+=R*h[S]}return e.alpha=u*(1-t/w),e.currentEpoch+=1,i},t.prototype.optimizeLayoutAsync=function(t){var e=this;return void 0===t&&(t=function(){return!0}),new Promise((function(s,r){var o=function(){return n(e,void 0,void 0,(function(){var e,n,a,l,h,c;return i(this,(function(i){try{if(e=this.optimizationState,n=e.nEpochs,a=e.currentEpoch,this.embedding=this.optimizeLayoutStep(a),l=this.optimizationState.currentEpoch,h=!1===t(l),c=l===n,h||c)return[2,s(c)];setTimeout((function(){return o()}),0)}catch(t){r(t)}return[2]}))}))};setTimeout((function(){return o()}),0)}))},t.prototype.optimizeLayout=function(t){void 0===t&&(t=function(){return!0});for(var e=!1,s=[];!e;){var n=this.optimizationState,i=n.nEpochs,r=n.currentEpoch;s=this.optimizeLayoutStep(r);var o=this.optimizationState.currentEpoch,a=!1===t(o);e=o===i||a}return s},t.prototype.getNEpochs=function(){var t=this.graph;if(this.nEpochs>0)return this.nEpochs;var e=t.nRows;return e<=2500?500:e<=5e3?400:e<=7500?300:200},t}();function w(t,e){for(var s=0,n=0;n<t.length;n++)s+=Math.pow(t[n]-e[n],2);return Math.sqrt(s)}e.UMAP=y,e.euclidean=w,e.cosine=function(t,e){for(var s=0,n=0,i=0,r=0;r<t.length;r++)s+=t[r]*e[r],n+=Math.pow(t[r],2),i+=Math.pow(e[r],2);return 0===n&&0===i?0:0===n||0===i?1:1-s/Math.sqrt(n*i)};var b=function(){this.currentEpoch=0,this.headEmbedding=[],this.tailEmbedding=[],this.head=[],this.tail=[],this.epochsPerSample=[],this.epochOfNextSample=[],this.epochOfNextNegativeSample=[],this.epochsPerNegativeSample=[],this.moveOther=!0,this.initialAlpha=1,this.alpha=1,this.gamma=1,this.a=1.5769434603113077,this.b=.8950608779109733,this.dim=2,this.nEpochs=500,this.nVertices=0};function T(t,e){return t>e?e:t<-e?-e:t}function C(t,e){for(var s=0,n=0;n<t.length;n++)s+=Math.pow(t[n]-e[n],2);return s}function S(t,e){var s=d.linear(0,3*t,300).map((function(t){return t<e?1:t})),n=d.zeros(s.length).map((function(n,i){return s[i]>=e?Math.exp(-(s[i]-e)/t):n})),i={x:s,y:n},o=g.default(i,(function(t){var e=r(t,2),s=e[0],n=e[1];return function(t){return 1/(1+s*Math.pow(t,2*n))}}),{damping:1.5,initialValues:[.5,.5],gradientDifference:.1,maxIterations:100,errorTolerance:.01}).parameterValues,a=r(o,2);return{a:a[0],b:a[1]}}function A(t,e,s,n){return void 0===s&&(s=1),void 0===n&&(n=5),t.map((function(t,i,r){return-1===e[i]||-1===e[r]?t*Math.exp(-s):e[i]!==e[r]?t*Math.exp(-n):t}))}function v(t){t=c.normalize(t,"max");var e=c.transpose(t),s=c.pairwiseMultiply(e,t);return t=c.add(t,c.subtract(e,s)),c.eliminateZeros(t)}function E(t,e,s){for(var n=d.zeros(t.length).map((function(t){return d.zeros(s[0].length)})),i=0;i<t.length;i++)for(var r=0;r<t[0].length;r++)for(var o=0;o<s[0].length;o++){var a=t[i][r];n[i][o]+=e[i][r]*s[a][o]}return n}e.findABParams=S,e.fastIntersection=A,e.resetLocalConnectivity=v,e.initTransform=E},4517:function(t,e){"use strict";var s=this&&this.__values||function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],s=0;return e?e.call(t):{next:function(){return t&&s>=t.length&&(t=void 0),{value:t&&t[s++],done:!t}}}};function n(t,e){return Math.floor(e()*t)}function i(t){for(var e=[],s=0;s<t;s++)e.push(void 0);return e}function r(t,e){return i(t).map((function(){return e}))}function o(t){return r(t,0)}function a(t){return t.reduce((function(t,e){return t+e}))}Object.defineProperty(e,"__esModule",{value:!0}),e.tauRandInt=n,e.tauRand=function(t){return t()},e.norm=function(t){var e,n,i=0;try{for(var r=s(t),o=r.next();!o.done;o=r.next()){var a=o.value;i+=Math.pow(a,2)}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}return Math.sqrt(i)},e.empty=i,e.range=function(t){return i(t).map((function(t,e){return e}))},e.filled=r,e.zeros=o,e.ones=function(t){return r(t,1)},e.linear=function(t,e,s){return i(s).map((function(n,i){return t+i*((e-t)/(s-1))}))},e.sum=a,e.mean=function(t){return a(t)/t.length},e.max=function(t){for(var e=0,s=0;s<t.length;s++)e=t[s]>e?t[s]:e;return e},e.max2d=function(t){for(var e=0,s=0;s<t.length;s++)for(var n=0;n<t[s].length;n++)e=t[s][n]>e?t[s][n]:e;return e},e.rejectionSample=function(t,e,s){for(var i=o(t),r=0;r<t;r++)for(var a=!0;a;){for(var l=n(e,s),h=!1,c=0;c<r;c++)if(l===i[c]){h=!0;break}h||(a=!1),i[r]=l}return i},e.reshape2d=function(t,e,s){var n=[],i=0;if(t.length!==e*s)throw new Error("Array dimensions must match input length.");for(var r=0;r<e;r++){for(var o=[],a=0;a<s;a++)o.push(t[i]),i+=1;n.push(o)}return n}},3336:t=>{"use strict";t.exports=$},976:t=>{"use strict";t.exports=DG},4469:t=>{"use strict";t.exports=grok},701:t=>{"use strict";t.exports=rxjs},3870:t=>{"use strict";t.exports=ui},6414:t=>{"use strict";t.exports=wu}},e={};function s(n){var i=e[n];if(void 0!==i)return i.exports;var r=e[n]={id:n,exports:{}};return t[n].call(r.exports,r,r.exports,s),r.exports}s.m=t,s.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return s.d(e,{a:e}),e},s.d=(t,e)=>{for(var n in e)s.o(e,n)&&!s.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},s.u=t=>t+".js",s.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),s.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{var t;s.g.importScripts&&(t=s.g.location+"");var e=s.g.document;if(!t&&e&&(e.currentScript&&(t=e.currentScript.src),!t)){var n=e.getElementsByTagName("script");if(n.length)for(var i=n.length-1;i>-1&&!t;)t=n[i--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),s.p=t})(),s.b=document.baseURI||self.location.href,s.nc=void 0;var n={};(()=>{"use strict";s.r(n),s.d(n,{_package:()=>ut,test:()=>mt,tests:()=>e.QK});var t=s(976),e=s(1061);(0,e.W3)("_first",(()=>{(0,e.Bu)("_first",(async()=>{}))}));var i=s(2012),r=s(9976),o=s(6137);(0,e.W3)("Palettes",(()=>{(0,e.Bu)("testPaletteN",(async()=>{await async function(){const t=o.J.Chromatogram;(0,e.l_)(t instanceof r.B,!0),(0,e.l_)(t instanceof o.J,!0)}()})),(0,e.Bu)("testPaletteAA",(async()=>{await async function(){const t=i.f.Lesk,s=i.f.RasMol,n=i.f.GrokGroups;(0,e.l_)(t instanceof r.B,!0),(0,e.l_)(s instanceof r.B,!0),(0,e.l_)(n instanceof r.B,!0),(0,e.l_)(t instanceof i.f,!0),(0,e.l_)(s instanceof i.f,!0),(0,e.l_)(n instanceof i.f,!0)}()})),(0,e.Bu)("testPalettePtMe",(async()=>{const t=i.f.GrokGroups.get("MeNle"),s=i.f.GrokGroups.get("MeA"),n=i.f.GrokGroups.get("MeG"),r=i.f.GrokGroups.get("MeF"),o=i.f.GrokGroups.get("L"),a=i.f.GrokGroups.get("A"),l=i.f.GrokGroups.get("G"),h=i.f.GrokGroups.get("F");(0,e.l_)(t,o),(0,e.l_)(s,a),(0,e.l_)(n,l),(0,e.l_)(r,h)}))}));var a=s(4469),l=s(2397),h=s(8447),c=s(499);async function u(e){const s=t.Column.fromList(t.TYPE.STRING,"col1",e);if(await a.functions.call("Bio:detectMacromolecule",{col:s}),s.semType===t.SEMTYPE.MACROMOLECULE){const e=`Negative test detected semType='${s.semType}', units='${s.getTag(t.TAGS.UNITS)}'.`;throw new Error(e)}}async function m(e,s){const n=(await e()).getCol(s),i=await a.functions.call("Bio:detectMacromolecule",{col:n});if(i&&(n.semType=i),n.semType===t.SEMTYPE.MACROMOLECULE){const e=`Negative test detected semType='${n.semType}', units='${n.getTag(t.TAGS.UNITS)}'.`;throw new Error(e)}}async function d(s,n,i,r,o,l,h=null){const u=t.Column.fromList(t.TYPE.STRING,"seq",s),m=await a.functions.call("Bio:detectMacromolecule",{col:u});m&&(u.semType=m),(0,e.l_)(u.semType,t.SEMTYPE.MACROMOLECULE),(0,e.l_)(u.getTag(t.TAGS.UNITS),n),(0,e.l_)(u.getTag("aligned"),i),(0,e.l_)(u.getTag("alphabet"),r),h&&(0,e.l_)(u.getTag("separator"),h);const d=c.Cn.getOrCreate(u);(0,e.l_)(d.getAlphabetSize(),o),(0,e.l_)(d.getAlphabetIsMultichar(),l),d.isHelm()||((0,e.l_)(d.aligned,i),(0,e.l_)(d.alphabet,r))}async function g(s,n,i,r,o,l,h,u=null){const m=(await s()).col(n),d=await a.functions.call("Bio:detectMacromolecule",{col:m});d&&(m.semType=d),(0,e.l_)(m.semType,t.SEMTYPE.MACROMOLECULE),(0,e.l_)(m.getTag(t.TAGS.UNITS),i),(0,e.l_)(m.getTag("aligned"),r),(0,e.l_)(m.getTag("alphabet"),o),u&&(0,e.l_)(m.getTag("separator"),u);const g=c.Cn.getOrCreate(m);(0,e.l_)(g.getAlphabetSize(),l),(0,e.l_)(g.getAlphabetIsMultichar(),h),g.isHelm()||((0,e.l_)(g.aligned,r),(0,e.l_)(g.alphabet,o))}(0,e.W3)("detectors",(()=>{var s,n,i,r,o,l,c,y,w,b,T,C,S,A,v,E,M,N,_;const P=new(_=class{constructor(){this[s]="id,col1\n1,\n2,\n3,\n4,\n5,",this[n]="col1\n1\n2\n3",this[i]="col1\n4\n5\n6\n7",this[r]="col1\n8\n9\n10\n11\n12",this[o]="col1\nCCCCN1C(=O)CN=C(c2cc(F)ccc12)C3CCCCC3\nC1CCCCC1\nCCCCCC",this[l]="seq\nACGTC\nCAGTGT\nTTCAAC",this[c]="seq\nACGUC\nCAGUGU\nUUCAAC",this[y]="seq\nFWPHEY\nYNRQWYV\nMKPSEYV",this[w]="seq\n[meI][hHis][Aca]NT[dE][Thr_PO3H2][Aca]D\n[meI][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2]\n[Lys_Boc][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2]",this[b]="seq\nA*C*G*T*C\nC*A*G*T*G*T\nT*T*C*A*A*C",this[T]="seq\nA*C*G*U*C\nC*A*G*U*G*U\nU*U*C*A*A*C",this[C]="seq\nF-W-P-H-E-Y\nY-N-R-Q-W-Y-V\nM-K-P-S-E-Y-V",this[S]="seq\nabc-dfgg-abc1-cfr3-rty-wert\nrut12-her2-rty-wert-abc-abc1-dfgg\nrut12-rty-her2-abc-cfr3-wert-rut12",this[A]="seq\nabc/dfgg/abc1/cfr3/rty/wert\nrut12/her2/rty/wert//abc/abc1/dfgg\nrut12/rty/her2/abc/cfr3//wert/rut12",this[v]="seq\nA-C--G-T--C-T\nC-A-C--T--G-T\nA-C-C-G-T-A-C-T",this[E]="seq\nm1-M-m3-mon4-mon5-N-T-MON8-N9\nm1-mon2-m3-mon4-mon5-Num--MON8-N9\n\nmon1-M-mon3-mon4-mon5---MON8-N9",this[M]="seq\nAC-GT-CT\nCAC-T-GT\nACCGTACT",this[N]="seq\nFWR-WYV-KHP\nYNR-WYV-KHP\nMWRSWY-CKHP"}},s="negEmpty",n="neg1",i="neg2",r="neg3",o="negSmiles",l="csvFastaDna1",c="fastaRna1",y="fastaPt1",w="fastaUn",b="sepDna",T="sepRna",C="sepPt",S="sepUn1",A="sepUn2",v="sepMsaDna1",E="sepMsaUnWEmpty",M="fastaMsaDna1",N="fastaMsaPt1",_),L={fastaFasta:"System:AppData/Bio/data/sample_FASTA.fasta",fastaPtCsv:"System:AppData/Bio/data/sample_FASTA_PT.csv",msaComplex:"System:AppData/Bio/samples/MSA.csv",fastaCsv:"System:AppData/Bio/samples/FASTA.csv",helmCsv:"System:AppData/Bio/samples/HELM.csv",peptidesComplex:"System:AppData/Bio/tests/peptides_complex_msa.csv",peptidesSimple:"System:AppData/Bio/tests/peptides_simple_msa.csv",testDemogCsv:"System:AppData/Bio/tests/testDemog.csv",testHelmCsv:"System:AppData/Bio/tests/testHelm.csv",testIdCsv:"System:AppData/Bio/tests/testId.csv",testSmilesCsv:"System:AppData/Bio/tests/testSmiles.csv",testSmiles2Csv:"System:AppData/Bio/tests/testSmiles2.csv",testSmilesShort:"System:AppData/Bio/tests/testSmilesShort.csv",testActivityCliffsCsv:"System:AppData/Bio/tests/testActivityCliffs.csv",testCerealCsv:"System:AppData/Bio/tests/testCereal.csv",testUnichemSources:"System:AppData/Bio/tests/testUnichemSources.csv",testDmvOffices:"System:AppData/Bio/tests/testDmvOffices.csv",testAlertCollection:"System:AppData/Bio/tests/testAlertCollection.csv",testSpgi100:"System:AppData/Bio/tests/testSpgi100.csv",testSpgi:"System:AppData/Bio/tests/SPGI-derived.csv",testUrl:"System:AppData/Bio/tests/testUrl.csv"},R={};function x(t,e=I){return async()=>(t in R||(R[t]=(async()=>await e(L[t]))()),R[t])}async function I(e){const s=await a.dapi.files.readAsText(e);return t.DataFrame.fromCsv(s)}const O=e=>async()=>{const s=P[e],n=t.DataFrame.fromCsv(s);return await a.data.detectSemanticTypes(n),n};(0,e.Bu)("NegativeEmpty",(async()=>{await m(O("negEmpty"),"col1")})),(0,e.Bu)("Negative1",(async()=>{await m(O("neg1"),"col1")})),(0,e.Bu)("Negative2",(async()=>{await m(O("neg2"),"col1")})),(0,e.Bu)("Negative3",(async()=>{await m(O("neg3"),"col1")})),(0,e.Bu)("NegativeSmiles",(async()=>{await m(O("negSmiles"),"col1")})),(0,e.Bu)("NegativeStartEnd",(async()=>{await u(["START","END"])})),(0,e.Bu)("NegativeStartEndIntermediate",(async()=>{await u(["START","END","INTERMEDIATE"])})),(0,e.Bu)("FastaDna1",(async()=>{await g(O("csvFastaDna1"),"seq",h.r2.FASTA,"SEQ","DNA",4,!1)})),(0,e.Bu)("FastaRna1",(async()=>{await g(O("fastaRna1"),"seq",h.r2.FASTA,"SEQ","RNA",4,!1)})),(0,e.Bu)("FastaPt1",(async()=>{await g(O("fastaPt1"),"seq",h.r2.FASTA,"SEQ","PT",20,!1)})),(0,e.Bu)("FastaPtGaps",(()=>d(["FW-PH-EYY","FYNRQWYV-","FKP-Q-SEYV"],h.r2.FASTA,"SEQ","PT",20,!1))),(0,e.Bu)("FastaPtGapsMsa",(()=>d(["FW-PH-EYY","FYNRQWYV-","FKP-Q-SEY"],h.r2.FASTA,"SEQ.MSA","PT",20,!1))),(0,e.Bu)("FastaUn",(async()=>{await g(O("fastaUn"),"seq",h.r2.FASTA,"SEQ.MSA","UN",12,!0)})),(0,e.Bu)("SepMsaUnWEmpty",(async()=>{await g(O("sepMsaUnWEmpty"),"seq",h.r2.SEPARATOR,"SEQ.MSA","UN",14,!0)})),(0,e.Bu)("FastaMsaDna1",(async()=>{await g(O("fastaMsaDna1"),"seq",h.r2.FASTA,"SEQ.MSA","DNA",4,!1)})),(0,e.Bu)("FastaMsaPt1",(async()=>{await g(O("fastaMsaPt1"),"seq",h.r2.FASTA,"SEQ.MSA","PT",20,!1)})),(0,e.Bu)("SepDna",(async()=>{await g(O("sepDna"),"seq",h.r2.SEPARATOR,"SEQ","DNA",4,!1,"*")})),(0,e.Bu)("SepRna",(async()=>{await g(O("sepRna"),"seq",h.r2.SEPARATOR,"SEQ","RNA",4,!1,"*")})),(0,e.Bu)("SepPt",(async()=>{await g(O("sepPt"),"seq",h.r2.SEPARATOR,"SEQ","PT",20,!1,"-")})),(0,e.Bu)("SepUn1",(async()=>{await g(O("sepUn1"),"seq",h.r2.SEPARATOR,"SEQ","UN",8,!0,"-")})),(0,e.Bu)("SepUn2",(async()=>{await g(O("sepUn2"),"seq",h.r2.SEPARATOR,"SEQ","UN",9,!0,"/")})),(0,e.Bu)("SepMsaN1",(async()=>{await g(O("sepMsaDna1"),"seq",h.r2.SEPARATOR,"SEQ.MSA","DNA",4,!1,"-")})),(0,e.Bu)("samplesFastaCsv",(async()=>{await p(x("fastaCsv"),{Sequence:new f(h.r2.FASTA,"SEQ","PT",20,!1)})})),(0,e.Bu)("samplesFastaFasta",(async()=>{await p(x("fastaFasta"),{sequence:new f(h.r2.FASTA,"SEQ","PT",20,!1)})})),(0,e.Bu)("samplesPeptidesComplex",(async()=>{await p(x("peptidesComplex"),{})})),(0,e.Bu)("samplesMsaComplex",(async()=>{await p(x("msaComplex"),{MSA:new f(h.r2.SEPARATOR,"SEQ.MSA","UN",161,!0,"/")})})),(0,e.Bu)("samplesIdCsv",(async()=>{await p(x("testIdCsv"),{})})),(0,e.Bu)("samplesSarSmallCsv",(async()=>{await p(x("testSmilesCsv"),{})})),(0,e.Bu)("samplesHelmCsv",(async()=>{await p(x("helmCsv"),{HELM:new f(h.r2.HELM,null,null,160,!0)})})),(0,e.Bu)("samplesTestHelmCsv",(async()=>{await p(x("testHelmCsv"),{"HELM string":new f(h.r2.HELM,null,null,9,!0)})})),(0,e.Bu)("samplesTestDemogCsv",(async()=>{await p(x("testDemogCsv"),{})})),(0,e.Bu)("samplesTestSmiles2Csv",(async()=>{await p(x("testSmiles2Csv"),{})})),(0,e.Bu)("samplesTestSmilesShort",(async()=>{await p(x("testSmilesShort"),{})})),(0,e.Bu)("samplesTestActivityCliffsNegativeSmiles",(async()=>{await p(x("testActivityCliffsCsv"),{})})),(0,e.Bu)("samplesFastaPtCsv",(async()=>{await p(x("fastaPtCsv"),{sequence:new f(h.r2.FASTA,"SEQ","PT",20,!1)})})),(0,e.Bu)("samplesTestCerealCsv",(async()=>{await p(x("testCerealCsv"),{})})),(0,e.Bu)("samplesTestUnichemSources",(async()=>{await p(x("testUnichemSources"),{})})),(0,e.Bu)("samplesTestDmvOffices",(async()=>{await p(x("testDmvOffices"),{})})),(0,e.Bu)("samplesTestAlertCollection",(async()=>{await p(x("testAlertCollection"),{})})),(0,e.Bu)("samplesTestSpgi",(async()=>{await p(x("testSpgi"),{})})),(0,e.Bu)("samplesTestSpgi100",(async()=>{await p(x("testSpgi100"),{})})),(0,e.Bu)("samplesTestUrl",(async()=>{await p(x("testUrl"),{})}))}));class f{constructor(t,e,s,n,i,r){this.units=t,this.aligned=e,this.alphabet=s,this.alphabetSize=n,this.alphabetIsMultichar=i,this.separator=r}}async function p(t,e){const s=await t(),n=[];for(const i of s.columns.names())if(i in e){const s=e[i];try{await g(t,i,s.units,s.aligned,s.alphabet,s.alphabetSize,s.alphabetIsMultichar,s.separator)}catch(t){const e=t.toString();n.push(`Positive col '${i}' failed: ${e}`)}}else try{await m(t,i)}catch(t){const e=t.toString();n.push(`Negative col '${i}' failed: ${e}`)}if(n.length>0)throw new Error(n.join("\n"))}(0,e.W3)("detectors:weak-and-likely",(()=>{const s={fastaDnaWeak1:"id,colName\n1,TTTTT\n2,TTTTT\n3,TTTTT\n4,TTTTT",fastaDnaWeak1LikelyName:"id,seq\n1,TTTTT\n2,TTTTT\n3,TTTTT\n4,TTTTT",fastaRnaWeak1:"id,colName\n1,UUUUU\n2,UUUUU\n3,UUUUU\n4,UUUUU",fastaRnaWeak1LikelyName:"id,seq\n1,UUUUU\n2,UUUUU\n3,UUUUU\n4,UUUUU",fastaPtWeak1:"id,colName\n1,SLSLSPGK\n2,SLSLSPGK\n3,SLSLSPGK\n4,SLSLSPGK",fastaPtWeak1LikelyName:"id,seq\n1,SLSLSPGK\n2,SLSLSPGK\n3,SLSLSPGK\n4,SLSLSPGK",fastaUn1:"id,colName\n1,word\n2,other\n3,some\n4,another",fastaUn1LikelyName:"id,seq\n1,word\n2,other\n3,some\n4,another",fastaUn2LikelyName:'protein\nBoombastic\nMegafantastic\n"just-a-random-thought,oy!"',fastaUnMsa1LikelyName:"id,seq\n1,word\n2,male\n3,bare\n4,core"},n=e=>async()=>{const n=s[e],i=t.DataFrame.fromCsv(n);return await a.data.detectSemanticTypes(i),i};(0,e.Bu)("fastaDnaWeak1",(async()=>{await m(n("fastaDnaWeak1"),"colName")})),(0,e.Bu)("fastaDnaWeak1LikelyName",(async()=>{await g(n("fastaDnaWeak1LikelyName"),"seq",h.r2.FASTA,"SEQ.MSA","DNA",4,!1)})),(0,e.Bu)("fastaRnaWeak1",(async()=>{await m(n("fastaRnaWeak1"),"colName")})),(0,e.Bu)("fastaRnaWeak1LikelyName",(async()=>{await g(n("fastaRnaWeak1LikelyName"),"seq",h.r2.FASTA,"SEQ.MSA","RNA",4,!1)})),(0,e.Bu)("fastaPtWeak1",(async()=>{await m(n("fastaPtWeak1"),"colName")})),(0,e.Bu)("fastaPtWeak1LikelyName",(async()=>{await g(n("fastaPtWeak1LikelyName"),"seq",h.r2.FASTA,"SEQ.MSA","PT",20,!1)})),(0,e.Bu)("fastaUn1",(async()=>{await m(n("fastaUn1"),"colName")})),(0,e.Bu)("fastaUn1LikelyName",(async()=>{await m(n("fastaUn1LikelyName"),"seq")})),(0,e.Bu)("fastaUn2LikelyName",(async()=>{await m(n("fastaUn2LikelyName"),"protein")})),(0,e.Bu)("fastaUnMsa1LikelyName",(async()=>{await m(n("fastaUnMsa1LikelyName"),"seq")}))})),(0,e.W3)("detectorsBenchmark",(()=>{let s;async function n(n,r,o,a,l,u){return await async function(n,m,d,g){const f=(()=>{const e=function(e,s,n,i,r){let o;switch(e){case h.r2.FASTA:o=t=>{let e="";for(let s=0;s<t.length;s++){const n=t[s];e+=1==n.length?n:`[${n}]`}return e};break;case h.r2.SEPARATOR:o=(t,e)=>t.join(e);break;default:throw new Error(`Not supported notation '${e}'.`)}const a=(t,e)=>{const s=new Array(e);for(let n=0;n<e;n++)s[n]=t[Math.floor(Math.random()*t.length)];return o(s,r)},l=Array(i);for(let t=0;t<i;t++)l[t]=a(s,n);return t.Column.fromStrings("seq",l)}(r,[...(0,h.gM)(o)],a,l,u),n=s.prepare({col:e});return i(n),n})(),p=Date.now(),y=await(async t=>i(t))(f),w=Date.now();(function(t,s){const n=c.Cn.getOrCreate(t);(0,e.l_)(t.semType===s.semType,!0),(0,e.l_)(n.notation===s.notation,!0),(0,e.l_)(n.alphabet===s.alphabet,!0),(0,e.l_)(n.separator===s.separator,!0)})(y,{semType:t.SEMTYPE.MACROMOLECULE,notation:r,alphabet:o,separator:u});const b=w-p;if(b>10){const t=`ET ${b} ms is more than max allowed 10 ms.`;throw console.error(t),new Error(t)}return console.log(`ET ${b} ms is OK.`),b}()}function i(t){t.callSync();const e=t.getOutputParamValue(),s=t.inputs.col;return e&&(s.semType=e),s}(0,e.bb)((async()=>{const e=t.Func.find({package:"Bio",name:"detectMacromolecule"});s=e[0];const n=t.Column.fromStrings("seq",["ACGT","ACGT","ACGT"]);await s.prepare({col:n}).call()})),(0,e.Bu)("fastaDnaShorts50Few50",(async()=>{await n(0,h.r2.FASTA,"DNA",50,50)})),(0,e.Bu)("fastaDnaShorts50Many1E6",(async()=>{await n(0,h.r2.FASTA,"DNA",50,1e6)})),(0,e.Bu)("fastaDnaLong1e6Few50",(async()=>{await n(0,h.r2.FASTA,"DNA",1e6,50)})),(0,e.Bu)("separatorDnaShorts50Few50",(async()=>{await n(0,h.r2.SEPARATOR,"DNA",50,50,"/")})),(0,e.Bu)("separatorDnaShorts50Many1E6",(async()=>{await n(0,h.r2.SEPARATOR,"DNA",50,1e6,"/")})),(0,e.Bu)("separatorDnaLong1e6Few50",(async()=>{await n(0,h.r2.SEPARATOR,"DNA",1e6,50,"/")}))}));var y=s(6098),w=s(525);async function b(e){const s=await async function(t){return await ut.files.readAsText(t)}(e),n=t.DataFrame.fromCsv(s);return n.name=e.replace(".csv",""),n}async function T(t){const e=await b(t);return e.name=t.replace(".csv",""),a.shell.addTableView(e)}async function C(t=1e4){const s=await a.dapi.docker.dockerContainers.filter("bio").first();"started"!==s.status&&"checking"!==s.status&&await(0,e.gw)(t)}async function S(s,n){const i=t.DataFrame.fromCsv(s),r=t.DataFrame.fromCsv(n),o=i.getCol("seq"),l=await a.functions.call("Bio:detectMacromolecule",{col:o});l&&(o.semType=l);const h=r.getCol("seq"),c=await(0,y.U)(o,!0);(0,e.f6)(c.toList(),h.toList())}async function A(s,n,i,r,o,l){const h=t.DataFrame.fromCsv(s),c=t.DataFrame.fromCsv(n),u=h.getCol("seq"),m=c.getCol("seq"),d=h.getCol("seq"),g=await a.functions.call("Bio:detectMacromolecule",{col:d});g&&(d.semType=g),await a.data.detectSemanticTypes(h),(0,e.l_)(u.semType,t.SEMTYPE.MACROMOLECULE),(0,e.l_)(u.getTag(t.TAGS.UNITS),i),o&&(0,e.l_)(u.getTag("alphabet"),o);const f=await(0,w.K)({col:u,pepsea:{method:l}});(0,e.l_)(f.semType,t.SEMTYPE.MACROMOLECULE),(0,e.l_)(f.getTag(t.TAGS.UNITS),r),(0,e.l_)(f.getTag("aligned"),"SEQ.MSA"),o&&(0,e.l_)(f.getTag("alphabet"),o),(0,e.f6)(f.toList(),m.toList())}(0,e.W3)("MSA",(async()=>{(0,e.Bu)("isCorrect",(async()=>{await S("seq\nFWRWYVKHP\nYNRWYVKHP\nMWRSWYCKHP","seq\nFWR-WYVKHP\nYNR-WYVKHP\nMWRSWYCKHP")})),(0,e.Bu)("isCorrectLong",(async()=>{await S("seq\nFWRWYVKHPFWRWYVKHPFWRWYVKHPFWRWYVKHPFWRWYVKHPFWRWYVKHPFWRWYVKHPFWRWYVKHP\nYNRWYVKHPYNRWYVKHPYNRWYVKHPYNRWYVKHPYNRWYVKHPYNRWYVKHPYNRWYVKHPYNRWYVKHP\nMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHP","seq\nFWR-WYVKHPFWR-WYVKHPFWR-WYVKHPFWR-WYVKHPFWR-WYVKHPFWR-WYVKHPFWR-WYVKHPFWR-WYVKHP\nYNR-WYVKHPYNR-WYVKHPYNR-WYVKHPYNR-WYVKHPYNR-WYVKHPYNR-WYVKHPYNR-WYVKHPYNR-WYVKHP\nMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHP")})),(0,e.Bu)("isCorrectHelm",(async()=>{await C(),await A("seq\n PEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2}$$$$\n PEPTIDE1{meI.Aca.N.T.dE.Thr_PO3H2}$$$$\n PEPTIDE1{hHis.Aca.N.T.dE.Thr_PO3H2}$$$$","seq\n meI.hHis.Aca.N.T.dE.Thr_PO3H2\n .meI.Aca.N.T.dE.Thr_PO3H2\n .hHis.Aca.N.T.dE.Thr_PO3H2",h.r2.HELM,h.r2.SEPARATOR,void 0,"mafft")}),{skipReason:"GROK-13221"}),(0,e.Bu)("isCorrectHelmLong",(async()=>{await C(),await A("seq\n PEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et.dV.E.N.D-Orn.D-aThr.Phe_4Me.Thr_PO3H2}$$$$\n PEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Tyr_PO3H2.D-Chg.dV.Phe_ab-dehydro.N.D-Orn.D-aThr.Phe_4Me}$$$$\n PEPTIDE1{Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Tyr_PO3H2.D-Chg.dV.Thr_PO3H2.N.D-Orn.D-aThr.Phe_4Me}$$$$","seq\n meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et.dV.E.N.D-Orn.D-aThr.Phe_4Me.Thr_PO3H2\n meI.hHis.Aca.Cys_SEt.T.dK..Tyr_PO3H2.D-Chg.dV.Phe_ab-dehydro.N.D-Orn.D-aThr.Phe_4Me.\n Lys_Boc.hHis.Aca.Cys_SEt.T.dK..Tyr_PO3H2.D-Chg.dV.Thr_PO3H2.N.D-Orn.D-aThr.Phe_4Me.",h.r2.HELM,h.r2.SEPARATOR,void 0,"mafft")}),{skipReason:"GROK-13221"}),(0,e.Bu)("isCorrectSeparator",(async()=>{await A("seq\n F-W-P-H-E-Y\n Y-N-R-Q-W-Y-V\n M-K-P-S-E-Y-V","seq\n FWPHEY-\n YNRQWYV\n MKPSEYV",h.r2.SEPARATOR,h.r2.FASTA,"PT")})),(0,e.Bu)("isCorrectSeparatorLong",(async()=>{await A("seq\n M-I-E-V-F-L-F-G-I-V-L-G-L-I-P-I-T-L-A-G-L-F-V-T-A-Y-L-Q-Y-R-R-G-D-Q-L-D-L\n M-M-E-L-V-L-K-T-I-I-G-P-I-V-V-G-V-V-L-R-I-V-D-K-W-L-N-K-D-K\n M-D-R-T-D-E-V-S-N-H-T-H-D-K-P-T-L-T-W-F-E-E-I-F-E-E-Y-H-S-P-F-H-N","seq\n MIEV-FLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL\n MMEL-VLKTII-GPIVVGVVLRIVDKWLNKDK------\n MDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN-----",h.r2.SEPARATOR,h.r2.FASTA,"PT")}))}));var v=s(3553),E=s(9416);async function M(t,s){const n=(0,h.kB)(t);console.debug(`Bio: tests: splitters: src=${JSON.stringify(t)}, res=${JSON.stringify(n)} .`),(0,e.f6)(n,s)}async function N(t,s){const n=(0,h.gP)(t);console.debug(`Bio: tests: splitters: src=${JSON.stringify(t)}, res=${JSON.stringify(n)} .`),(0,e.f6)(n,s)}(0,e.W3)("splitters",(async()=>{(0,e.bb)((async()=>{})),(0,e.X5)((async()=>{}));const s=["M[MeI]YKETLL[MeF]PKTDFPMRGGL[MeA]",["M","MeI","Y","K","E","T","L","L","MeF","P","K","T","D","F","P","M","R","G","G","L","MeA"]],n=["[meI][Pip][dK][Thr_PO3H2][L-hArg(Et,Et)][D-Tyr_Et][Tyr_ab-dehydroMe][dV]EN[D-Orn][D-aThr][Phe_4Me]",["meI","Pip","dK","Thr_PO3H2","L-hArg(Et,Et)","D-Tyr_Et","Tyr_ab-dehydroMe","dV","E","N","D-Orn","D-aThr","Phe_4Me"]],i=["PEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et.Tyr_ab-dehydroMe.dV.E.N.D-Orn.D-aThr.Phe_4Me}$$$",["meI","hHis","Aca","N","T","dE","Thr_PO3H2","Aca","D-Tyr_Et","Tyr_ab-dehydroMe","dV","E","N","D-Orn","D-aThr","Phe_4Me"]],r=["PEPTIDE1{meI.hHis.Aca.N.T.dK.Thr_PO3H2.Aca.D-Tyr_Et.D-Dap.dV.E.N.pnG.Phe_4Me}$$$",["meI","hHis","Aca","N","T","dK","Thr_PO3H2","Aca","D-Tyr_Et","D-Dap","dV","E","N","pnG","Phe_4Me"]],o=["PEPTIDE1{[meI].[hHis].[Aca].N.T.[dK].[Thr_PO3H2].[Aca].[D-Tyr_Et].[D-Dap].[dV].E.N.[pnG].[Phe_4Me]}$$$",["meI","hHis","Aca","N","T","dK","Thr_PO3H2","Aca","D-Tyr_Et","D-Dap","dV","E","N","pnG","Phe_4Me"]],h=["RNA1{R(U)P.R(T)P.R(G)P.R(C)P.R(A)}$$$$",["R(U)P","R(T)P","R(G)P","R(C)P","R(A)"]],c=["RNA1{P.R(U)P.R(T)}$$$$",["P","R(U)P","R(T)"]],u=["RNA1{P.R(U).P.R(T)}$$$$",["P","R(U)","P","R(T)"]];(0,e.Bu)("fastaMulti",(async()=>{await M(s[0],s[1])})),(0,e.Bu)("fastaFromHelm",(async()=>{await M(n[0],n[1])})),(0,e.Bu)("helm1",(async()=>{await N(i[0],i[1])})),(0,e.Bu)("helm2",(async()=>{await N(r[0],r[1])})),(0,e.Bu)("helm3-multichar",(async()=>{await N(o[0],o[1])})),(0,e.Bu)("testHelm1",(async()=>{await N(h[0],h[1])})),(0,e.Bu)("testHelm2",(async()=>{await N(c[0],c[1])})),(0,e.Bu)("testHelm3",(async()=>{await N(u[0],u[1])})),(0,e.Bu)("splitToMonomers",(async()=>{const t=await a.dapi.files.readCsv("System:AppData/Bio/samples/MSA.csv"),s=t.getCol("MSA"),n=await a.functions.call("Bio:detectMacromolecule",{col:s});n&&(s.semType=n),s.setTag("aligned",v.mU);const i=await(0,E.n)(t,s);(0,e.l_)(i.columns.names().includes("17"),!0),await a.data.detectSemanticTypes(i);const r=a.shell.addTableView(i);await(0,e.ow)((()=>r.grid.dataFrame!=t),"View grid has wrong data frame",100)})),(0,e.Bu)("getHelmMonomers",(async()=>{const e=t.DataFrame.fromCsv("HELM,Activity\nPEPTIDE1{hHis.N.T}$$$,5.30751\nPEPTIDE1{hHis.Aca.Cys_SEt}$$$,5.72388\n");await a.data.detectSemanticTypes(e);const s=["hHis","Aca","Cys_SEt","N","T"],n=e.getCol("HELM"),i=(0,l.getHelmMonomers)(n),r=s.filter((t=>!i.includes(t))),o=i.filter((t=>!s.includes(t)));if(r.length>0||o.length){const t=[];throw r.length>0&&t.push(`Missed monomers ${JSON.stringify(r)}.`),o.length>0&&t.push(`Unexpected monomers ${JSON.stringify(o)}.`),new Error(t.join(" "))}}))}));var _=s(7228),P=s(5490);(0,e.W3)("monomerLibraries",(()=>{let t,s=null;(0,e.bb)((async()=>{t=await(0,_.JN)(),s=await a.dapi.userDataStorage.get(P.RV,!0)})),(0,e.X5)((async()=>{await a.dapi.userDataStorage.put(P.RV,s,!0)})),(0,e.Bu)("default",(async()=>{await a.dapi.userDataStorage.put(P.RV,{},!0),await t.loadLibraries(!0);const s=t.getBioLib();(0,e.l_)(s.getPolymerTypes().length>0,!0)})),(0,e.Bu)("empty",(async()=>{const s=await(0,P.nW)(),n=await(0,P.P4)();s.exclude=n,await(0,P.QD)(s),await t.loadLibraries(!0);const i=t.getBioLib();(0,e.l_)(0===i.getPolymerTypes().length,!0),i.getMonomerMolsByPolymerType("PEPTIDE")}))}));var L=s(3336),R=s.n(L),x=s(4004);function I(){const e=[];return e.push(t.Column.fromList("string","MSA",new Array(10**6).fill("meI/hHis/Aca/N/T/dE/Thr_PO3H2/Aca/D-Tyr_Et/Tyr_ab-dehydroMe/dV/E/N/D-Orn/D-aThr//Phe_4Me"))),e.push(t.Column.fromList("string","Activity",new Array(10**6).fill("5.30751"))),e}function O(){const e=[],s="meI/hHis/Aca/N/T/dE/Thr_PO3H2/Aca/D-Tyr_Et/Tyr_ab-dehydroMe/dV/E/N/D-Orn/D-aThr".repeat(10**5);return e.push(t.Column.fromList("string","MSA",new Array(100).fill(s))),e.push(t.Column.fromList("string","Activity",new Array(100).fill("7.30751"))),e}async function F(s,n){const i=s(),r=t.DataFrame.fromColumns(i);await a.data.detectSemanticTypes(r);const o=Date.now(),l=(r.columns.byName("MSA"),a.shell.addTableView(r));await(0,e.ow)((()=>l.grid.dataFrame!==r),"View grid has wrong data frame ",100);const h=Date.now()-o;console.log(`Performance test: ${n}: ${h}ms`)}(0,e.W3)("renderers",(()=>{(0,e.Bu)("long sequence performance ",(async()=>{await F(O,"Long sequences")})),(0,e.Bu)("many sequence performance",(async()=>{await F(I,"Many sequences")})),(0,e.Bu)("many sequence performance",(async()=>{await F(I,"Many sequences")})),(0,e.Bu)("rendererMacromoleculeFasta",(async()=>{await async function(){const s=await a.dapi.files.readAsText("System:AppData/Bio/samples/FASTA.csv"),n=t.DataFrame.fromCsv(s),i=n.getCol("Sequence"),r=await a.functions.call("Bio:detectMacromolecule",{col:i});r&&(i.semType=r);const o=a.shell.addTableView(n);await a.data.detectSemanticTypes(n),await(0,e.ow)((()=>o.grid.dataFrame!=n),"View grid has wrong data frame",100);const l=i.getTag(t.TAGS.CELL_RENDERER);(0,e.l_)(l,"sequence")}()})),(0,e.Bu)("rendererMacromoleculeSeparator",(async()=>{await async function(){const s=await a.dapi.files.readAsText("System:AppData/Bio/data/sample_SEPARATOR_PT.csv"),n=t.DataFrame.fromCsv(s),i=n.getCol("sequence"),r=await a.functions.call("Bio:detectMacromolecule",{col:i});r&&(i.semType=r);const o=a.shell.addTableView(n);await a.data.detectSemanticTypes(n),await(0,e.ow)((()=>o.grid.dataFrame!=n),"View grid has wrong data frame",100);const l=i.getTag(t.TAGS.CELL_RENDERER);(0,e.l_)(l,"sequence")}()})),(0,e.Bu)("rendererMacromoleculeDifference",(async()=>{await async function(){const s=t.Column.fromStrings("SequencesDiff",["meI/hHis/Aca/N/T/dK/Thr_PO3H2/Aca#D-Tyr_Et/Tyr_ab-dehydroMe/meN/E/N/dV"]);s.setTag(t.TAGS.UNITS,h.r2.SEPARATOR),s.setTag("separator","/"),s.setTag("aligned","SEQ"),s.setTag("alphabet","UN"),s.setTag(".alphabetIsMultichar","true"),s.semType=v.Of.MACROMOLECULE_DIFFERENCE;const n=t.DataFrame.fromColumns([s]),i=a.shell.addTableView(n);await a.data.detectSemanticTypes(n),await(0,e.ow)((()=>i.grid.dataFrame!=n),"View grid has wrong data frame",100);const r=s.getTag(t.TAGS.CELL_RENDERER);(0,e.l_)(r,v.Of.MACROMOLECULE_DIFFERENCE)}()})),(0,e.Bu)("afterMsa",(async()=>{await async function(){const s=await a.dapi.files.readAsText("System:AppData/Bio/data/sample_FASTA.fasta"),n=(0,l.importFasta)(s)[0],i=n.getCol("sequence"),r=await a.functions.call("Bio:detectMacromolecule",{col:i});r&&(i.semType=r);const o=a.shell.addTableView(n);await a.data.detectSemanticTypes(n),console.log("Bio: tests/renderers/afterMsa, table view"),await(0,e.ow)((()=>o.grid.dataFrame!=n),"View grid has wrong data frame",100),console.log(`Bio: tests/renderers/afterMsa, src before test semType="${i.semType}", units="${i.getTag(t.TAGS.UNITS)}", cell.renderer="${i.getTag(t.TAGS.CELL_RENDERER)}"`),(0,e.l_)(i.semType,t.SEMTYPE.MACROMOLECULE),(0,e.l_)(i.getTag(t.TAGS.UNITS),h.r2.FASTA),(0,e.l_)(i.getTag("aligned"),"SEQ"),(0,e.l_)(i.getTag("alphabet"),"PT"),(0,e.l_)(i.getTag(t.TAGS.CELL_RENDERER),"sequence");const u=await(0,w.K)({col:i});o.grid.invalidate(),await(0,e.ow)((()=>o.grid.dataFrame!=n),"View grid has wrong data frame",100),(0,e.l_)(u.semType,t.SEMTYPE.MACROMOLECULE),(0,e.l_)(u.getTag(t.TAGS.UNITS),h.r2.FASTA),(0,e.l_)(u.getTag("aligned"),"SEQ.MSA"),(0,e.l_)(u.getTag("alphabet"),"PT"),(0,e.l_)(u.getTag(t.TAGS.CELL_RENDERER),"sequence"),c.Cn.getOrCreate(u)}()})),(0,e.Bu)("afterConvert",(async()=>{await async function(){const s=await a.dapi.files.readAsText("System:AppData/Bio/data/sample_FASTA_PT.csv"),n=t.DataFrame.fromCsv(s),i=n.col("sequence"),r=await a.functions.call("Bio:detectMacromolecule",{col:i});r&&(i.semType=r);const o=a.shell.addTableView(n);await a.data.detectSemanticTypes(n);const l=await(0,x.o)(i,h.r2.SEPARATOR,"/");await(0,e.ow)((()=>o.grid.dataFrame!=n),"View grid has wrong data frame",100);const u=l.getTag(t.TAGS.CELL_RENDERER);(0,e.l_)(u,"sequence"),c.Cn.getOrCreate(l)}()})),(0,e.Bu)("selectRendererBySemType",(async()=>{await async function(){const s=t.Column.fromStrings("SequencesDiff",["meI/hHis/Aca/N/T/dK/Thr_PO3H2/Aca#D-Tyr_Et/Tyr_ab-dehydroMe/meN/E/N/dV"]);s.setTag(t.TAGS.UNITS,h.r2.SEPARATOR),s.setTag("separator","/"),s.setTag("aligned","SEQ"),s.setTag("alphabet","UN"),s.setTag(".alphabetIsMultichar","true"),s.semType=v.Of.MACROMOLECULE_DIFFERENCE;const n=t.DataFrame.fromColumns([s]);a.shell.addTableView(n),await(0,e.gw)(100);const i=s.getTag(t.TAGS.CELL_RENDERER);if("MacromoleculeDifference"!==i)throw new Error(`Units 'separator', separator '/' and semType 'MacromoleculeDifference' have been manually set on column but after df was added as table, view renderer has set to '${i}' instead of correct 'MacromoleculeDifference'.`)}()})),(0,e.Bu)("setRendererManuallyBeforeAddColumn",(async()=>{await async function(){const s=t.Column.fromStrings("SequencesDiff",["meI/hHis/Aca/N/T/dK/Thr_PO3H2/Aca#D-Tyr_Et/Tyr_ab-dehydroMe/meN/E/N/dV"]);s.setTag(t.TAGS.UNITS,h.r2.SEPARATOR),s.setTag("separator","/"),s.setTag("aligned","SEQ"),s.setTag("alphabet","UN"),s.setTag(".alphabetIsMultichar","true"),s.semType=t.SEMTYPE.MACROMOLECULE;const n="MacromoleculeDifference";s.setTag(t.TAGS.CELL_RENDERER,n);const i=t.DataFrame.fromColumns([s]);await a.data.detectSemanticTypes(i),a.shell.addTableView(i),await(0,e.ow)((()=>null!==document.querySelector("canvas")),"cannot load table",3e3);const r=s.getTag(t.TAGS.CELL_RENDERER);if(r!==n)throw new Error(`Tag 'cell.renderer' has been manually set to '${n}' for column but after df was added as table, tag 'cell.renderer' has reset to '${r}' instead of manual '${n}'.`)}()}),{skipReason:"GROK-11212"}),(0,e.Bu)("setRendererManuallyAfterAddColumn",(async()=>{await async function(){const s=t.Column.fromStrings("SequencesDiff",["meI/hHis/Aca/N/T/dK/Thr_PO3H2/Aca#D-Tyr_Et/Tyr_ab-dehydroMe/meN/E/N/dV"]);s.setTag(t.TAGS.UNITS,h.r2.SEPARATOR),s.setTag("separator","/"),s.setTag("aligned","SEQ"),s.setTag("alphabet","UN"),s.setTag(".alphabetIsMultichar","true"),s.semType=t.SEMTYPE.MACROMOLECULE;const n="MacromoleculeDifference",i=t.DataFrame.fromColumns([s]);await a.data.detectSemanticTypes(i);const r=a.shell.addTableView(i);await(0,e.ow)((()=>R()(r.root).find(".d4-grid canvas").length>0),"View grid canvas not found",200),s.setTag(t.TAGS.CELL_RENDERER,n),await(0,e.ow)((()=>R()(r.root).find(".d4-grid canvas").length>0),"View grid canvas not found",200);const o=s.getTag(t.TAGS.CELL_RENDERER);if(o!==n)throw new Error(`Tag 'cell.renderer' has been manually set to '${n}' for column but after df was added as table, tag 'cell.renderer' has reset to '${o}' instead of manual '${n}'.`)}()}),{skipReason:"GROK-11212"})}));var D=s(6414),G=s.n(D),H=s(9611);(0,e.W3)("renderers: monomerPlacer",(()=>{const s={splitter:{csv:"id,seq\nid1,m1-M-m3-mon4-mon5-N-T-MON8-N9\nid2,m1-mon2-m3-mon4-mon5-Num-MON8-N9\nid3,mon1-M-mon3-mon4-mon5-MON8-N9\n",testList:[{src:{row:0,x:-1},tgt:{pos:null}},{src:{row:1,x:0},tgt:{pos:null}},{src:{row:1,x:5},tgt:{pos:0}},{src:{row:1,x:6},tgt:{pos:0}},{src:{row:1,x:26},tgt:{pos:1}},{src:{row:1,x:160},tgt:{pos:6}},{src:{row:1,x:185},tgt:{pos:7}},{src:{row:2,x:140},tgt:{pos:5}},{src:{row:2,x:145},tgt:{pos:5}}]},splitterMsa:{csv:"id,seq\nid1,m1-M-m3-mon4-mon5-N-T-MON8-N9\nid2,m1-mon2-m3-mon4-mon5-Num--MON8-N9\nid3,\nid4,mon1-M-mon3-mon4-mon5---MON8-N9\n",testList:[{src:{row:0,x:-1},tgt:{pos:null}},{src:{row:1,x:0},tgt:{pos:null}},{src:{row:1,x:1},tgt:{pos:null}},{src:{row:1,x:4},tgt:{pos:null}},{src:{row:1,x:5},tgt:{pos:0}},{src:{row:1,x:37},tgt:{pos:0}},{src:{row:1,x:38},tgt:{pos:1}},{src:{row:1,x:170},tgt:{pos:4}},{src:{row:1,x:200},tgt:{pos:5}},{src:{row:2,x:20},tgt:{pos:null}},{src:{row:3,x:170},tgt:{pos:4}},{src:{row:3,x:200},tgt:{pos:5}},{src:{row:3,x:282},tgt:{pos:null}}]},fastaMsa:{csv:"id,seq\nid1,QQYNIYPLT\nid2,QQWSSFPYT\nid3,\nid3,QHIRE--LT\n",testList:[{src:{row:1,x:-1},tgt:{pos:null}},{src:{row:1,x:0},tgt:{pos:null}},{src:{row:1,x:1},tgt:{pos:null}},{src:{row:1,x:19},tgt:{pos:0}},{src:{row:1,x:170},tgt:{pos:8}},{src:{row:1,x:171},tgt:{pos:8}},{src:{row:2,x:5},tgt:{pos:null}},{src:{row:3,x:170},tgt:{pos:8}},{src:{row:3,x:181},tgt:{pos:null}}]}};for(const[n,i]of Object.entries(s))(0,e.Bu)(`getPosition-${n}`,(async()=>{const e=t.DataFrame.fromCsv(i.csv);await a.data.detectSemanticTypes(e);const s=e.getCol("seq"),n=new H.A(null,s,(()=>({unitsHandler:c.Cn.getOrCreate(s),monomerCharWidth:7,separatorWidth:12,monomerToShort:h.GU,monomerLengthLimit:3}))),r=i.testList;for(let t=0;t<s.length;++t)n.getCellMonomerLengths(t);const o=[];for(const[t,e]of G().enumerate(r)){const e={pos:n.getPosition(t.src.row,t.src.x)};t.tgt.pos!=e.pos&&o.push(`Test src ${JSON.stringify(t.src)} expected tgt ${JSON.stringify(t.tgt)}, but get ${JSON.stringify({res:e})}`)}if(o.length>0)throw new Error("Test failed error(s):\n"+o.join(", n"))}))})),(0,e.W3)("converters",(()=>{let s;!function(t){t.fastaPt="fastaPt",t.separatorPt="separatorPt",t.helmPt="helmPt",t.fastaDna="fastaDna",t.separatorDna="separatorDna",t.helmDna="helmDna",t.fastaRna="fastaRna",t.separatorRna="separatorRna",t.helmRna="helmRna",t.fastaGaps="fastaGaps",t.separatorGaps="separatorGaps",t.helmGaps="helmGaps",t.fastaUn="fastaUn",t.separatorUn="separatorUn",t.helmUn="helmUn",t.helmLoneDeoxyribose="helmLoneDeoxyribose",t.helmLoneRibose="helmLoneRibose",t.helmLonePhosphorus="helmLonePhosphorus",t.fastaLoneDeoxyribose="fastaLoneDeoxyribose",t.fastaLoneRibose="fastaLoneRibose",t.fastaLonePhosphorus="fastaLonePhosphorus"}(s||(s={}));const n={fastaPt:"seq\nFWPHEY\nYNRQWYV\nMKPSEYV",separatorPt:"seq\nF-W-P-H-E-Y\nY-N-R-Q-W-Y-V\nM-K-P-S-E-Y-V",helmPt:"seq\nPEPTIDE1{F.W.P.H.E.Y}$$$$\nPEPTIDE1{Y.N.R.Q.W.Y.V}$$$$\nPEPTIDE1{M.K.P.S.E.Y.V}$$$$",fastaDna:"seq\nACGTC\nCAGTGT\nTTCAAC",separatorDna:"seq\nA/C/G/T/C\nC/A/G/T/G/T\nT/T/C/A/A/C",helmDna:"seq\nDNA1{D(A)P.D(C)P.D(G)P.D(T)P.D(C)P}$$$$\nDNA1{D(C)P.D(A)P.D(G)P.D(T)P.D(G)P.D(T)P}$$$$\nDNA1{D(T)P.D(T)P.D(C)P.D(A)P.D(A)P.D(C)P}$$$$",fastaRna:"seq\nACGUC\nCAGUGU\nUUCAAC",separatorRna:"seq\nA*C*G*U*C\nC*A*G*U*G*U\nU*U*C*A*A*C",helmRna:"seq\nRNA1{R(A)P.R(C)P.R(G)P.R(U)P.R(C)P}$$$$\nRNA1{R(C)P.R(A)P.R(G)P.R(U)P.R(G)P.R(U)P}$$$$\nRNA1{R(U)P.R(U)P.R(C)P.R(A)P.R(A)P.R(C)P}$$$$",fastaGaps:"seq\nFW-PH-EYY\nFYNRQWYV-\nFKP-Q-SEYV",separatorGaps:"seq\nF/W//P/H//E/Y/Y\nF/Y/N/R/Q/W/Y/V/\nF/K/P//Q//S/E/Y/V",helmGaps:"seq\nPEPTIDE1{F.W.*.P.H.*.E.Y.Y}$$$$\nPEPTIDE1{F.Y.N.R.Q.W.Y.V.*}$$$$\nPEPTIDE1{F.K.P.*.Q.*.S.E.Y.V}$$$$",fastaUn:"seq\n[meI][hHis][Aca]NT[dE][Thr_PO3H2][Aca]D\n[meI][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2]\n[Lys_Boc][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2]",separatorUn:"seq\nmeI-hHis-Aca-N-T-dE-Thr_PO3H2-Aca-D\nmeI-hHis-Aca-Cys_SEt-T-dK-Thr_PO3H2-Aca-Tyr_PO3H2\nLys_Boc-hHis-Aca-Cys_SEt-T-dK-Thr_PO3H2-Aca-Tyr_PO3H2",helmUn:"seq\nPEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D}$$$$\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2}$$$$\nPEPTIDE1{Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2}$$$$",helmLoneDeoxyribose:"seq\nDNA1{D(A).D(C).D(G).D(T).D(C)}$$$$\nDNA1{D(C).D(A).D(G).D(T).D(G).D(T)P}$$$$\nDNA1{D(T).D(T).D(C).D(A).D(A).D(C)P}$$$$",helmLoneRibose:"seq\nRNA1{R(A).R(C).R(G).R(U).R(C)}$$$$\nRNA1{R(C).R(A).R(G).R(U).R(G).R(U)P}$$$$\nRNA1{R(U).R(U).R(C).R(A).R(A).R(C)P}$$$$",helmLonePhosphorus:"seq\nRNA1{P.P.R(A)P.R(C)P.R(G)P.R(U)P.R(C)P}$$$$\nRNA1{P.P.R(C)P.R(A)P.P.R(G)P.R(U)P.R(G)P.R(U)P}$$$$\nRNA1{P.R(U)P.R(U)P.R(C)P.R(A)P.R(A)P.R(C)P.P.P}$$$$"};async function i(e){const s=n[e],i=t.DataFrame.fromCsv(s);return await a.data.detectSemanticTypes(i),i}function r(s,n){if(s===h.r2.SEPARATOR&&!n)throw new Error(`Argument 'separator' is mandatory for target notation '${s.toString()}'.`);return function(i){const r=c.Cn.getOrCreate(i).convert(s,n);return(0,e.l_)(r.getTag(t.TAGS.UNITS),s),r}}async function o(t,s,n){const r=s((await i(t)).getCol("seq")),o=(await i(n)).getCol("seq");(0,e.f6)(r.toList(),o.toList()),c.Cn.getOrCreate(r)}(0,e.Bu)("testFastaPtToSeparator",(async()=>{await o(s.fastaPt,r(h.r2.SEPARATOR,"-"),s.separatorPt)})),(0,e.Bu)("testFastaDnaToSeparator",(async()=>{await o(s.fastaDna,r(h.r2.SEPARATOR,"/"),s.separatorDna)})),(0,e.Bu)("testFastaRnaToSeparator",(async()=>{await o(s.fastaRna,r(h.r2.SEPARATOR,"*"),s.separatorRna)})),(0,e.Bu)("testFastaGapsToSeparator",(async()=>{await o(s.fastaGaps,r(h.r2.SEPARATOR,"/"),s.separatorGaps)})),(0,e.Bu)("testFastaUnToSeparator",(async()=>{await o(s.fastaUn,r(h.r2.SEPARATOR,"-"),s.separatorUn)})),(0,e.Bu)("testFastaPtToHelm",(async()=>{await o(s.fastaPt,r(h.r2.HELM),s.helmPt)})),(0,e.Bu)("testFastaDnaToHelm",(async()=>{await o(s.fastaDna,r(h.r2.HELM),s.helmDna)})),(0,e.Bu)("testFastaRnaToHelm",(async()=>{await o(s.fastaRna,r(h.r2.HELM),s.helmRna)})),(0,e.Bu)("testFastaGapsToHelm",(async()=>{await o(s.fastaGaps,r(h.r2.HELM),s.helmGaps)})),(0,e.Bu)("testSeparatorPtToFasta",(async()=>{await o(s.separatorPt,r(h.r2.FASTA),s.fastaPt)})),(0,e.Bu)("testSeparatorDnaToFasta",(async()=>{await o(s.separatorDna,r(h.r2.FASTA),s.fastaDna)})),(0,e.Bu)("testSeparatorRnaToFasta",(async()=>{await o(s.separatorRna,r(h.r2.FASTA),s.fastaRna)})),(0,e.Bu)("testSeparatorGapsToFasta",(async()=>{await o(s.separatorGaps,r(h.r2.FASTA),s.fastaGaps)})),(0,e.Bu)("testSeparatorUnToFasta",(async()=>{await o(s.separatorUn,r(h.r2.FASTA),s.fastaUn)})),(0,e.Bu)("testSeparatorPtToHelm",(async()=>{await o(s.separatorPt,r(h.r2.HELM),s.helmPt)})),(0,e.Bu)("testSeparatorDnaToHelm",(async()=>{await o(s.separatorDna,r(h.r2.HELM),s.helmDna)})),(0,e.Bu)("testSeparatorRnaToHelm",(async()=>{await o(s.separatorRna,r(h.r2.HELM),s.helmRna)})),(0,e.Bu)("testSeparatorGapsToHelm",(async()=>{await o(s.separatorGaps,r(h.r2.HELM),s.helmGaps)})),(0,e.Bu)("testHelmDnaToFasta",(async()=>{await o(s.helmDna,r(h.r2.FASTA),s.fastaDna)})),(0,e.Bu)("testHelmRnaToFasta",(async()=>{await o(s.helmRna,r(h.r2.FASTA),s.fastaRna)})),(0,e.Bu)("testHelmPtToFasta",(async()=>{await o(s.helmPt,r(h.r2.FASTA),s.fastaPt)})),(0,e.Bu)("testHelmUnToFasta",(async()=>{await o(s.helmUn,r(h.r2.FASTA),s.fastaUn)})),(0,e.Bu)("testHelmDnaToSeparator",(async()=>{await o(s.helmDna,r(h.r2.SEPARATOR,"/"),s.separatorDna)})),(0,e.Bu)("testHelmRnaToSeparator",(async()=>{await o(s.helmRna,r(h.r2.SEPARATOR,"*"),s.separatorRna)})),(0,e.Bu)("testHelmPtToSeparator",(async()=>{await o(s.helmPt,r(h.r2.SEPARATOR,"-"),s.separatorPt)})),(0,e.Bu)("testHelmUnToSeparator",(async()=>{await o(s.helmUn,r(h.r2.SEPARATOR,"-"),s.separatorUn)})),(0,e.Bu)("testHelmLoneRibose",(async()=>{await o(s.helmLoneRibose,r(h.r2.FASTA),s.fastaRna)})),(0,e.Bu)("testHelmLoneDeoxyribose",(async()=>{await o(s.helmLoneDeoxyribose,r(h.r2.SEPARATOR,"/"),s.separatorDna)})),(0,e.Bu)("testHelmLonePhosphorus",(async()=>{await o(s.helmLonePhosphorus,r(h.r2.FASTA),s.fastaRna)}))}));var k=s(5226);(0,e.W3)("fastaFileHandler",(()=>{const s=["description:1","description:2","description:3","description:4"],n=(t.Column.fromStrings("description",s),["MDYKETLLMPKTDFPMRGGLPNKEPQIQEKW","MIEVFLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL","MMELVLKTIIGPIVVGVVLRIVDKWLNKDK","MDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN"]);function i(t){const i=new k.i(t),r=i.descriptionsArray,o=i.sequencesArray;(0,e.f6)([r,o],[s,n])}(0,e.Bu)("testNormalFormatting",(async()=>{i(">description:1\nMDYKETLLMPKTDFPMRGGLPNKEPQIQEKW\n\n>description:2\nMIEVFLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL\n\n>description:3\nMMELVLKTIIGPIVVGVVLRIVDKWLNKDK\n\n>description:4\nMDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN\n")})),(0,e.Bu)("testExtraSpaces",(async()=>{i(">description:1\n MDYKETLLMPKTDFPMRGGLPNKEPQIQEKW\n\n>description:2\nMI EVF LFGIVLGLI PITLAGLFVTAY LQYRRGDQLDL\n\n>description:3\nM MELVLKTI IGPI VVGVVLR IVDKWLNKDK\n\n>description:4\nMDR TDEVSNHTHDKP TLTWFEEIFEEYHSPFHN\n ")})),(0,e.Bu)("testExtraNewlines",(async()=>{i(">description:1\n\nMDYKETLLMPKTDFPMRGGLPNKEPQIQEKW\n\n>description:2\nMIEVF\nLFGIVLGLI\nPITLAGLFVTA\nYLQYRRGDQLDL\n\n>description:3\nM\nME\n\nLVLKTIIG\n\nPIVVGVVLRI\nVDKWLNKDK\n\n\n>description:4\n\nMDRT\n\nDEVSNHTHDKP\n\nTLTWFEEIFEE\n\n\n\nYHSPFHN\n")}))}));var W=s(9943);(0,e.W3)("fastaExport",(()=>{let s;!function(t){t.single="single",t.multi="multi"}(s||(s={}));const n={[s.single]:{src:"MDYKETLLMPKTDFPMRGGLP",tgt:["MDYKETLLMP","KTDFPMRGGL","P"]},[s.multi]:{src:"M[MeI]YKETLL[MeF]PKTDFPMRGGL[MeA]",tgt:["M[MeI]YKETLL[MeF]P","KTDFPMRGGL","[MeA]"]}};let i;!function(t){t.test1="test1",t.test2="test2"}(i||(i={}));const r={[i.test1]:{srcCsv:"id,seq\n1,MDYKETLLMP\n2,KTDFPMRGGL\n3,P",idCols:["id"],seqCol:"seq",lineWidth:10,tgtFasta:">1\nMDYKETLLMP\n>2\nKTDFPMRGGL\n>3\nP\n"},[i.test2]:{srcCsv:"id,id2,seq\n1,seqA,M[MeI]YKETLL[MeF]P\n2,seqB,KTDFPMRGGL\n3,seqC,[MeA]\n",idCols:["id2","id"],seqCol:"seq",lineWidth:5,tgtFasta:">seqA|1\nM[MeI]YKE\nTLL[MeF]P\n>seqB|2\nKTDFP\nMRGGL\n>seqC|3\n[MeA]\n"}};function o(t,s=10){const i=h.kB,r=n[t].src,o=(0,W.sK)(r,i,s),a=n[t].tgt;(0,e.f6)(o,a)}async function a(s){const n=t.DataFrame.fromCsv(s.srcCsv),i=n.getCol(s.seqCol),r=s.idCols.map((t=>n.getCol(t))),o=(0,W.i$)(r,i,s.lineWidth);(0,e.l_)(o,s.tgtFasta)}(0,e.Bu)("wrapSequenceSingle",(async()=>{o(s.single,10)})),(0,e.Bu)("wrapSequenceMulti",(async()=>{o(s.multi,10)})),(0,e.Bu)("saveAsFastaTest1",(async()=>{a(r[i.test1])})),(0,e.Bu)("saveAsFastaTest2",(async()=>{a(r[i.test2])}))}));var B=s(7331),V=s(585);(0,e.W3)("bio",(()=>{const s="seq\nACGTCT\nCAGTGT\nTTCAAC";(0,e.Bu)("testGetStatsHelm1",(async()=>{const s=t.DataFrame.fromCsv("seq\nPEPTIDE1{meI}$$$$").getCol("seq"),n=(0,V.jY)(s,1,h.gP);(0,e.Wh)(n.freq,{meI:1}),(0,e.l_)(n.sameLength,!0)})),(0,e.Bu)("testGetStatsN1",(async()=>{await async function(s){const n=t.DataFrame.fromCsv(s).col("seq"),i=(0,V.jY)(n,5,h.kB);(0,e.Wh)(i.freq,{A:4,C:5,G:3,T:6}),(0,e.l_)(i.sameLength,!0)}(s)})),(0,e.Bu)("testGetAlphabetSimilarity",(async()=>{await async function(){const t=new Set(Object.keys(o.V.Names)),s=(0,h.KX)({A:2041,C:3015,G:3015,T:2048,"-":1e3},t);(0,e.l_)(s>.6,!0)}()})),(0,e.Bu)("testPickupPaletteN1",(async()=>{await async function(s){const n=t.DataFrame.fromCsv(s).col("seq"),i=(0,h.dQ)(n);(0,e.l_)(i instanceof o.J,!0)}(s)})),(0,e.Bu)("testPickupPaletteN1e",(async()=>{await async function(s){const n=t.DataFrame.fromCsv("seq\nACGTAT\nCAGTTG\nTTCG2C").col("seq"),i=(0,h.dQ)(n);(0,e.l_)(i instanceof o.J,!0)}()})),(0,e.Bu)("testPickupPaletteAA1",(async()=>{await async function(s){const n=t.DataFrame.fromCsv("seq\nFWPHEYV\nYNRQWYV\nMKPSEYV").col("seq"),r=(0,h.dQ)(n);(0,e.l_)(r instanceof i.f,!0)}()})),(0,e.Bu)("testPickupPaletteX",(async()=>{await async function(s){const n=t.DataFrame.fromCsv("seq\nXZJ{}2\n5Z4733\n3Z6></\n675687").col("seq"),i=(0,h.dQ)(n);(0,e.l_)(i instanceof B.kQ,!0)}()}))})),(0,e.W3)("WebLogo.monomerToShort",(()=>{(0,e.Bu)("longMonomerSingle",(async()=>{(0,e.l_)((0,h.GU)("S",5),"S")})),(0,e.Bu)("longMonomerShort",(async()=>{(0,e.l_)((0,h.GU)("Short",5),"Short")})),(0,e.Bu)("longMonomerLong56",(async()=>{(0,e.l_)((0,h.GU)("Long56",6),"Long56")})),(0,e.Bu)("longMonomerComplexFirstPartShort",(async()=>{(0,e.l_)((0,h.GU)("Long-long",5),"Long…")})),(0,e.Bu)("longMonomerComplexFirstPartLong56",(async()=>{(0,e.l_)((0,h.GU)("Long56-long",6),"Long5…")})),(0,e.Bu)("monomerToShort",(async()=>{const t=[["AbC","AbC"],["AbCd","Ab…"],["ABc","ABc"],["ABcd","AB…"],["A_b","A_b"],["A_bc","A…"],["Ab_c","Ab…"],["A1_b","A1…"],["Abc_d","Ab…"],["Abcd_e","Ab…"],["A-b","A-b"],["A-bc","A…"],["Ab-c","Ab…"],["A1-b","A1…"],["Abc-d","Ab…"],["Abcd-e","Ab…"],["A","A"],["Ab","Ab"],["Abc","Abc"],["Ab…","Ab…"],["Abcd","Ab…"],["Abcde","Ab…"]],s=t.map((t=>t[0])),n=t.map((t=>t[1])),i=s.map((t=>(0,h.GU)(t,3)));(0,e.f6)(i,n)}))}));var U=s(833);function $(t,s){(0,e.l_)(t.name,s.name),(0,e.f6)(t.getMonomers(),s.getMonomers());for(const n of t.getMonomers())(0,e.l_)(t.getFreq(n).count,s.getFreq(n).count)}(0,e.W3)("WebLogo-positions",(()=>{const s="seq\nATC-G-TTGC--\nATC-G-TTGC--\n-TC-G-TTGC--\n-TC-GCTTGC--\n-TC-GCTTGC--";(0,e.Bu)("allPositions",(async()=>{const n=t.DataFrame.fromCsv(s),i=a.shell.addTableView(n),r=n.getCol("seq");r.semType=t.SEMTYPE.MACROMOLECULE,r.setTag(t.TAGS.UNITS,h.r2.FASTA),r.setTag("alphabet","DNA"),r.setTag("aligned","SEQ.MSA");const o=await n.plot.fromType("WebLogo");i.dockManager.dock(o.root,t.DOCK_TYPE.DOWN),await(0,e.ow)((()=>o.Length>0),"WebLogo.Length is zero",100);const l=o.positions,c=[new U.CK(0,"1",{A:new U.yW(2),"-":new U.yW(3)}),new U.CK(1,"2",{T:new U.yW(5)}),new U.CK(2,"3",{C:new U.yW(5)}),new U.CK(3,"4",{"-":new U.yW(5)}),new U.CK(4,"5",{G:new U.yW(5)}),new U.CK(5,"6",{"-":new U.yW(3),C:new U.yW(2)}),new U.CK(6,"7",{T:new U.yW(5)}),new U.CK(7,"8",{T:new U.yW(5)}),new U.CK(8,"9",{G:new U.yW(5)}),new U.CK(9,"10",{C:new U.yW(5)}),new U.CK(10,"11",{"-":new U.yW(5)}),new U.CK(11,"12",{"-":new U.yW(5)})];(0,e.l_)(l.length,c.length);for(let t=0;t<l.length;t++){(0,e.l_)(l[t].name,c[t].name);for(const s of l[t].getMonomers())(0,e.l_)(l[t].getFreq(s).count,c[t].getFreq(s).count)}})),(0,e.Bu)("positions with shrinkEmptyTail option true (filtered)",(async()=>{const s=t.DataFrame.fromCsv("seq\n-TC-G-TTGC--\n-TC-GCTTGC--\n-T--C-GT-\n-T--C-GT-\n-T--C-GT-\n-T--CCGT-"),n=a.shell.addTableView(s),i=s.getCol("seq");i.semType=t.SEMTYPE.MACROMOLECULE,i.setTag(t.TAGS.UNITS,h.r2.FASTA),i.setTag("alphabet","DNA"),i.setTag("aligned","SEQ"),s.filter.init((t=>t>2)),s.filter.fireChanged();const r=await s.plot.fromType("WebLogo",{shrinkEmptyTail:!0});n.dockManager.dock(r.root,t.DOCK_TYPE.DOWN),await(0,e.ow)((()=>r.Length>0),"WebLogo.Length is zero",100);const o=r.positions,l=[new U.CK(0,"1",{"-":new U.yW(3)}),new U.CK(1,"2",{T:new U.yW(3)}),new U.CK(2,"3",{"-":new U.yW(3)}),new U.CK(3,"4",{"-":new U.yW(3)}),new U.CK(4,"5",{C:new U.yW(3)}),new U.CK(5,"6",{"-":new U.yW(2),C:new U.yW(1)}),new U.CK(6,"7",{G:new U.yW(3)}),new U.CK(7,"8",{T:new U.yW(3)}),new U.CK(8,"9",{"-":new U.yW(3)})];(0,e.l_)(o.length,l.length);for(let t=0;t<o.length;t++){(0,e.l_)(o[t].name,l[t].name);for(const s of o[t].getMonomers())(0,e.l_)(o[t].getFreq(s).count,l[t].getFreq(s).count)}})),(0,e.Bu)("positions with skipEmptyPositions option",(async()=>{const n=t.DataFrame.fromCsv(s),i=a.shell.addTableView(n),r=n.getCol("seq");r.semType=t.SEMTYPE.MACROMOLECULE,r.setTag(t.TAGS.UNITS,h.r2.FASTA),r.setTag("alphabet","DNA"),r.setTag("aligned","SEQ.MSA");const o=await n.plot.fromType("WebLogo",{skipEmptyPositions:!0});i.dockManager.dock(o.root,t.DOCK_TYPE.DOWN),await(0,e.ow)((()=>o.Length>0),"WebLogo.Length is zero");const l=o.positions,c=[new U.CK(0,"1",{A:new U.yW(2),"-":new U.yW(3)}),new U.CK(1,"2",{T:new U.yW(5)}),new U.CK(2,"3",{C:new U.yW(5)}),new U.CK(4,"5",{G:new U.yW(5)}),new U.CK(5,"6",{"-":new U.yW(3),C:new U.yW(2)}),new U.CK(6,"7",{T:new U.yW(5)}),new U.CK(7,"8",{T:new U.yW(5)}),new U.CK(8,"9",{G:new U.yW(5)}),new U.CK(9,"10",{C:new U.yW(5)})];(0,e.l_)(l.length,c.length);for(let t=0;t<l.length;t++)$(l[t],c[t])})),(0,e.Bu)("count sequences for monomer at position",(async()=>{const n=function(e,s,n,i){const r=t.DataFrame.fromCsv(e),o=r.getCol("seq");return o.semType=t.SEMTYPE.MACROMOLECULE,o.setTag(t.TAGS.UNITS,s),o.setTag("alphabet","DNA"),o.setTag("aligned","SEQ.MSA"),r}(s,h.r2.FASTA),i=n.getCol("seq"),r=a.shell.addTableView(n),o=await n.plot.fromType("WebLogo",{startPositionName:"3",endPositionName:"7",skipEmptyPositions:!0});r.dockManager.dock(o.root,t.DOCK_TYPE.DOWN),await(0,e.ow)((()=>o.Length>0),"WebLogo.Length is zero",100);const l=o.positions,u=[new U.CK(2,"3",{C:new U.yW(5)}),new U.CK(4,"5",{G:new U.yW(5)}),new U.CK(5,"6",{"-":new U.yW(3),C:new U.yW(2)}),new U.CK(6,"7",{T:new U.yW(5)})];(0,e.l_)(l.length,u.length);for(let t=0;t<l.length;t++)$(l[t],u[t]);const m=l[1],d=c.Cn.getOrCreate(i),g=(0,U.eZ)(n,d,n.filter,"G",m);(0,e.l_)(g,5)}))}));var Y=s(2568);function K(t,e){let s=null;for(const n of t.viewers)n.type===e&&(s=n);return s}(0,e.W3)("checkInputColumn",(()=>{const s="seq\nseq1,\nseq2,\nseq3,\nseq4";(0,e.Bu)("testMsaPos",(async()=>{const n=t.DataFrame.fromCsv(s).getCol("seq");n.semType=t.SEMTYPE.MACROMOLECULE,n.setTag(t.TAGS.UNITS,h.r2.FASTA),n.setTag("alphabet","DNA"),n.setTag("aligned","SEQ");const[i,r]=(0,Y.l)(n,"Test",[h.r2.FASTA],["DNA","RNA","PT"]);(0,e.l_)(i,!0)})),(0,e.Bu)("testMsaNegHelm",(async()=>{const n=t.DataFrame.fromCsv(s).getCol("seq");n.semType=t.SEMTYPE.MACROMOLECULE,n.setTag(t.TAGS.UNITS,h.r2.HELM),n.setTag(".alphabetIsMultichar","true");const[i,r]=(0,Y.l)(n,"Test",[h.r2.FASTA],["DNA","RNA","PT"]);(0,e.l_)(i,!1)})),(0,e.Bu)("testMsaNegUN",(async()=>{const n=t.DataFrame.fromCsv(s).getCol("seq");n.semType=t.SEMTYPE.MACROMOLECULE,n.setTag(t.TAGS.UNITS,h.r2.FASTA),n.setTag("alphabet","UN"),n.setTag(".alphabetSize","11"),n.setTag(".alphabetIsMultichar","true"),n.setTag("aligned","SEQ");const[i,r]=(0,Y.l)(n,"Test",[h.r2.FASTA],["DNA","RNA","PT"]);(0,e.l_)(i,!1)})),(0,e.Bu)("testGetActionFunctionMeta",(async()=>{t.Func.find({package:"Bio",name:"multipleSequenceAlignmentDialog"})[0].inputs.find((t=>"sequence"==t.name))}))})),(0,e.W3)("similarity/diversity",(async()=>{(0,e.Bu)("similaritySearchViewer",(async()=>{await async function(){const s=await T("tests/sample_MSA_data.csv"),n=await s.dataFrame.plot.fromType("Sequence Similarity Search");let i=!1;if(n.computeCompleted.subscribe((t=>{t&&(i=!0)})),s.dockManager.dock(n,t.DOCK_TYPE.RIGHT,null,"Similarity"),await n.renderPromise,await(0,e.ow)((()=>void 0!==K(s,"Sequence Similarity Search")),"Sequence Similarity Search viewer has not been created",100),!n.initialized)throw new Error("The viewer is not initialized.");if(!n.moleculeColumn)throw new Error("The viewer has not molecule column (onTableAttached).");if(!n.beforeRender())throw new Error("The viewer is not able to render.");if(!n.computeRequested)throw new Error("The viewer has not compute requested even.");if(!i)throw new Error("The viewer has not compute completed.");const r=n;await(0,e.ow)((()=>0!==r.root.getElementsByClassName("d4-grid").length),"Sequence Similarity Search viewer grid has not been created",100);(0,e.l_)(r.fingerprint,"Morgan"),(0,e.l_)(r.distanceMetric,"Tanimoto"),(0,e.l_)(r.scores.get(0),t.FLOAT_NULL),(0,e.l_)(r.idxs.get(0),0),(0,e.l_)(r.molCol.get(0),"D-Tyr_Et/Tyr_ab-dehydroMe/dV/E/N/D-Orn/D-aThr//Phe_4Me"),(0,e.l_)(r.scores.get(1),.4722222089767456),(0,e.l_)(r.idxs.get(1),11),(0,e.l_)(r.molCol.get(1),"meI/hHis//Aca/meM/Tyr_ab-dehydroMe/dV/E/N/D-Orn/D-aThr//Phe_4Me"),s.dataFrame.currentRowIdx=1,await(0,e.ow)((()=>1===r.targetMoleculeIdx),"Target molecule has not been changed",5e3),await(0,e.ow)((()=>"meI/hHis/Aca/Cys_SEt/T/dK/Thr_PO3H2/Aca/Tyr_PO3H2/D-Chg/dV/Phe_ab-dehydro/N/D-Orn/D-aThr//Phe_4Me"===r.molCol.get(0)),"Incorrect first similar molecule",5e3)}()})),(0,e.Bu)("diversitySearchViewer",(async()=>{await async function(){const s=await T("tests/sample_MSA_data.csv"),n=await s.dataFrame.plot.fromType("Sequence Diversity Search");let i=!1;if(n.computeCompleted.subscribe((t=>{t&&(i=!0)})),s.dockManager.dock(n,t.DOCK_TYPE.DOWN,null,"Diversity"),await n.renderPromise,await(0,e.ow)((()=>void 0!==K(s,"Sequence Diversity Search")),"Sequence Diversity Search viewer has not been created",100),!n.initialized)throw new Error("The viewer is not initialized.");if(!n.moleculeColumn)throw new Error("The viewer has not molecule column (onTableAttached).");if(!n.beforeRender())throw new Error("The viewer is not able to render.");if(!n.computeRequested)throw new Error("The viewer has not compute requested even.");if(!i)throw new Error("The viewer has not compute completed.");const r=n;await(0,e.ow)((()=>0!==r.root.getElementsByClassName("d4-grid").length),"Sequence Diversity Search viewer grid has not been created",100),(0,e.l_)(r.fingerprint,"Morgan"),(0,e.l_)(r.distanceMetric,"Tanimoto"),(0,e.l_)(r.initialized,!0),(0,e.l_)(r.renderMolIds.length>0,!0)}()}))}));var q=s(4413);(0,e.W3)("substructureFilters",(async()=>{let t,s;(0,e.bb)((async()=>{t=await(0,_.JN)(),s=await a.dapi.userDataStorage.get(P.RV,!0),await a.dapi.userDataStorage.post(P.RV,P.rb,!0),await t.loadLibraries(!0)})),(0,e.X5)((async()=>{await a.dapi.userDataStorage.put(P.RV,s,!0),await t.loadLibraries(!0)})),(0,e.Bu)("fasta",(async()=>{const t=await b("tests/filter_FASTA.csv"),s=new q.ST;await a.data.detectSemanticTypes(t),s.attach(t),s.bioFilter.substructure="MD",await(0,e.gw)(100),(0,e.l_)(s.dataFrame.filter.trueCount,3),(0,e.l_)(s.dataFrame.filter.get(0),!0),(0,e.l_)(s.dataFrame.filter.get(3),!0),(0,e.l_)(s.dataFrame.filter.get(8),!0),(0,e.l_)(s.dataFrame.filter.get(1),!1)})),(0,e.Bu)("separator",(async()=>{const t=await b("tests/filter_MSA.csv"),s=new q.ST;await a.data.detectSemanticTypes(t),s.attach(t),s.bioFilter.substructure="meI",await(0,e.gw)(100),(0,e.l_)(s.dataFrame.filter.trueCount,7),(0,e.l_)(s.dataFrame.filter.get(2),!1),s.bioFilter.substructure="/meI",await(0,e.gw)(100),(0,e.l_)(s.dataFrame.filter.trueCount,0),s.bioFilter.substructure="meI-hHis",s.bioFilter.separatorInput.value="-",await(0,e.gw)(100),(0,e.l_)(s.dataFrame.filter.trueCount,7),(0,e.l_)(s.dataFrame.filter.get(2),!1)})),(0,e.Bu)("helm",(async()=>{const t=await b("tests/filter_HELM.csv"),s=a.shell.addTableView(t),n=new q.ST;await a.data.detectSemanticTypes(t),n.attach(t);const i=new Promise(((e,s)=>{t.onFilterChanged.subscribe((async t=>{try{e(!0)}catch(t){s(t)}}))}));n.bioFilter.helmSubstructure="PEPTIDE1{C}$$$$V2.0",n.bioFilter.onChanged.next(),await i,(0,e.l_)(n.dataFrame.filter.trueCount,2),(0,e.l_)(n.dataFrame.filter.get(0),!0),(0,e.l_)(n.dataFrame.filter.get(3),!0),n.bioFilter.helmSubstructure="PEPTIDE1{A.C}$$$$V2.0",n.bioFilter.onChanged.next(),await(0,e.gw)(100),(0,e.l_)(n.dataFrame.filter.trueCount,1),(0,e.l_)(n.dataFrame.filter.get(3),!0),s.close()}),{skipReason:"GROK-12779"})}));var Z=s(8341);(0,e.W3)("PepSeA",(()=>{(0,e.Bu)("Basic alignment",(async()=>{await C();const s=t.DataFrame.fromCsv('HELM,MSA\n "PEPTIDE1{F.L.R.G.W.[MeF].Y.S.N.N.C}$$$$","F.L.R.G.W.MeF.Y..S.N.N.C"\n "PEPTIDE1{F.L.R.G.Y.[MeF].Y.W.N.C}$$$$","F.L.R.G.Y.MeF.Y.W...N.C"\n "PEPTIDE1{F.G.Y.[MeF].Y.W.S.D.N.C}$$$$","F...G.Y.MeF.Y.W.S.D.N.C"\n "PEPTIDE1{F.L.R.G.Y.[MeF].Y.W.S.N.D.C}$$$$","F.L.R.G.Y.MeF.Y.W.S.N.D.C"\n "PEPTIDE1{F.V.R.G.Y.[MeF].Y.W.S.N.C}$$$$","F.V.R.G.Y.MeF.Y.W.S..N.C"'),n=await(0,Z.f)(s.getCol("HELM"),"msa(HELM)");(0,e.l_)(null!==n,!0,"PepSeA conainter has not started");const i=s.getCol("MSA");for(let t=0;t<n.length;++t)(0,e.l_)(n.get(t)==i.get(t),!0)}),{skipReason:"GROK-13221"})})),(0,e.W3)("viewers",(()=>{const s=t.Func.find({package:"Bio",tags:["viewer"]}).map((t=>t.friendlyName));for(const t of s)(0,e.Bu)(t,(async()=>{const s=await b("data/sample_FASTA_DNA.csv");await(0,e.AB)(t,s,{detectSemanticTypes:!0})}),{skipReason:{"Sequence Similarity Search":"GROK-13162","Sequence Diversity Search":"GROK-13162",WebLogo:"GROK-13162",VdRegions:"GROK-13162"}[t]})}));const z="seq\nACGTC\nCAGTGT\nTTCAAC",X="seq\nAC-GT-CT\nCAC-T-GT\nACCGTACT",j="seq\nabc-dfgg-abc1-cfr3-rty-wert\nrut12-her2-rty-wert-abc-abc1-dfgg\nrut12-rty-her2-abc-cfr3-wert-rut12";(0,e.W3)("UnitsHandler",(()=>{async function s(e){const s=t.DataFrame.fromCsv(e);await a.data.detectSemanticTypes(s);const n=c.Cn.getOrCreate(s.getCol("seq"));return[s,n]}(0,e.Bu)("Seq-Fasta",(async()=>{const[t,n]=await s(z);(0,e.l_)(n.notation,h.r2.FASTA),(0,e.l_)(n.isMsa(),!1)})),(0,e.Bu)("Seq-Fasta-MSA",(async()=>{const[t,n]=await s(X);(0,e.l_)(n.notation,h.r2.FASTA),(0,e.l_)(n.isMsa(),!0)})),(0,e.Bu)("Seq-Fasta-units",(async()=>{const[t,n]=await s(z);(0,e.l_)(n.notation,h.r2.FASTA),(0,e.l_)(n.isMsa(),!1)})),(0,e.Bu)("Seq-Fasta-MSA-units",(async()=>{const[t,n]=await s(X);(0,e.l_)(n.notation,h.r2.FASTA),(0,e.l_)(n.isMsa(),!0)})),(0,e.Bu)("Seq-Helm",(async()=>{const[t,n]=await s("seq\nPEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et.Tyr_ab-dehydroMe.dV.E.N.D-Orn.D-aThr.Phe_4Me}$$$$\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2.D-Chg.dV.Phe_ab-dehydro.N.D-Orn.D-aThr.Phe_4Me}$$$$\nPEPTIDE1{Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2.D-Chg.dV.Thr_PO3H2.N.D-Orn.D-aThr.Phe_4Me}$$$$\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2.D-Chg.dV.Thr_PO3H2.N.D-Orn.D-aThr.Phe_4Me}$$$$");(0,e.l_)(n.notation,h.r2.HELM),(0,e.l_)(n.isHelm(),!0)})),(0,e.Bu)("Seq-UN",(async()=>{const[t,n]=await s(j);(0,e.l_)(n.notation,h.r2.SEPARATOR),(0,e.l_)(n.separator,"-"),(0,e.l_)(n.alphabet,"UN")})),(0,e.Bu)("Seq-UN-auto",(async()=>{const[t,n]=await s(j);(0,e.l_)(n.notation,h.r2.SEPARATOR),(0,e.l_)(n.separator,"-"),(0,e.l_)(n.alphabet,"UN")}))})),(0,e.W3)("UnitsHandler",(()=>{c._9[h.r2.FASTA],c._9[h.r2.HELM];const s=c._9[h.r2.SEPARATOR],n={fasta:{src:{csv:"seq\nACGTC\nCAGTGT\nTTCAAC"},tgt:{splitted:["ACGTC","CAGTGT","TTCAAC"]}},fastaMsa:{src:{csv:"seq\nAC-GT-CT\nCAC-T-GT\nACCGTACT"},tgt:{splitted:["AC-GT-CT","CAC-T-GT","ACCGTACT"]}},separator:{src:{csv:"seq\nabc-dfgg-abc1-cfr3-rty-wert\nrut12-her2-rty-wert-abc-abc1-dfgg\nrut12-rty-her2-abc-cfr3-wert-rut12"},tgt:{splitted:[["abc","dfgg","abc1","cfr3","rty","wert"],["rut12","her2","rty","wert","abc","abc1","dfgg"],["rut12","rty","her2","abc","cfr3","wert","rut12"]]}},separatorMsa:{src:{csv:"seq\nabc-dfgg-abc1-cfr3-rty-wert\nrut12-her2-rty--abc1-dfgg\nrut12-rty-her2---wert"},tgt:{splitted:[["abc","dfgg","abc1","cfr3","rty","wert"],["rut12","her2","rty",s,"abc1","dfgg"],["rut12","rty","her2",s,s,"wert"]]}},helm:{src:{csv:"seq\nPEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et}$$$$\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca}$$$$\nPEPTIDE1{Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca}$$$$\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2}$$$$"},tgt:{splitted:[["meI","hHis","Aca","N","T","dE","Thr_PO3H2","Aca","D-Tyr_Et"],["meI","hHis","Aca","Cys_SEt","T","dK","Thr_PO3H2","Aca"],["Lys_Boc","hHis","Aca","Cys_SEt","T","dK","Thr_PO3H2","Aca"],["meI","hHis","Aca","Cys_SEt","T","dK","Thr_PO3H2"]]}}};for(const[s,i]of Object.entries(n))(0,e.Bu)(`splitted-${s}`,(async()=>{const s=t.DataFrame.fromCsv(i.src.csv).getCol("seq"),n=await a.functions.call("Bio:detectMacromolecule",{col:s});n&&(s.semType=n),(0,e.l_)(s.semType,t.SEMTYPE.MACROMOLECULE);const r=c.Cn.getOrCreate(s).splitted;(0,e.f6)(r,i.tgt.splitted)}))})),(0,e.W3)("UnitsHandler: getRegion",(()=>{const s={fastaDna:{srcCsv:"seq\nATTCGT\nACTGCTC\nATTCCGTA",startIdx:2,endIdx:4,tgtCsv:"seq\nTCG\nTGC\nTCC",units:h.r2.FASTA,alphabet:"DNA",positionNames:{tag:"a, b, c, d, e, f, g, h",start:"c",end:"e"}},separatorPt:{srcCsv:"seq\nM-D-Y-K-E-T-L\nM-I-E-V-F-L-F-G-I\nM-M-",startIdx:5,endIdx:null,tgtCsv:"seq\nT-L--\nL-F-G-I\n---",units:h.r2.SEPARATOR,alphabet:"PT",positionNames:{tag:"1, 1A, 1B, 2, 3, 4, 4A, 4A, 4C",start:"4",end:null}},helm:{srcCsv:"seq\nPEPTIDE1{[meI].[hHis].[Aca].N.T.[dE].[Thr_PO3H2].[Aca].[D-Tyr_Et].[Tyr_ab-dehydroMe].[dV].E.N.[D-Orn]}$$$$\nPEPTIDE1{[meI].[hHis].[Aca].[Cys_SEt].T.[dK].[Thr_PO3H2].[Aca].[Tyr_PO3H2].[D-Chg].[dV].[Phe_ab-dehydro]}$$$$\nPEPTIDE1{[Lys_Boc].[hHis].[Aca].[Cys_SEt].T}$$$$",startIdx:3,endIdx:6,tgtCsv:"seq\nPEPTIDE1{N.T.[dE].[Thr_PO3H2]}$$$$\nPEPTIDE1{[Cys_SEt].T.[dK].[Thr_PO3H2]}$$$$\nPEPTIDE1{[Cys_SEt].T.*.*}$$$$",units:h.r2.HELM,alphabet:null,positionNames:{tag:null,start:"4",end:"7"}}};for(const[n,i]of Object.entries(s))(0,e.Bu)(`${n}-idx`,(async()=>{const s=t.DataFrame.fromCsv(i.srcCsv).getCol("seq"),n=await a.functions.call("Bio:detectMacromolecule",{col:s});n&&(s.semType=n);const r=c.Cn.getOrCreate(s).getRegion(i.startIdx,i.endIdx,"regSeq"),o=t.DataFrame.fromCsv(i.tgtCsv).getCol("seq");(0,e.l_)(s.getTag(t.TAGS.UNITS),i.units),(0,e.l_)(r.getTag(t.TAGS.UNITS),i.units),(0,e.l_)(s.getTag("alphabet"),i.alphabet),(0,e.l_)(r.getTag("alphabet"),i.alphabet),(0,e.f6)(r.toList(),o.toList())})),i.positionNames&&(0,e.Bu)(`${n}-positionNames`,(async()=>{const s=t.DataFrame.fromCsv(i.srcCsv).getCol("seq");i.positionNames.tag&&s.setTag(".positionNames",i.positionNames.tag);const n=await a.functions.call("Bio:detectMacromolecule",{col:s});n&&(s.semType=n);const r=await a.functions.call("Bio:getRegion",{sequence:s,start:i.positionNames.start,end:i.positionNames.end}),o=t.DataFrame.fromCsv(i.tgtCsv).getCol("seq");(0,e.l_)(s.getTag(t.TAGS.UNITS),i.units),(0,e.l_)(r.getTag(t.TAGS.UNITS),i.units),(0,e.l_)(s.getTag("alphabet"),i.alphabet),(0,e.l_)(r.getTag("alphabet"),i.alphabet),(0,e.f6)(r.toList(),o.toList())}))}));var Q=s(8601);const J=new t.FileSource("System:AppData/Bio"),tt={PT:"peptides fasta",DNA:"dna fasta",MSA:"msa separator"},et={PT:"tests/to-atomic-level-peptides-fasta-input.csv",DNA:"tests/to-atomic-level-dna-fasta-input.csv",MSA:"tests/to-atomic-level-msa-separator-input.csv"},st={PT:"tests/to-atomic-level-peptides-output.csv",DNA:"tests/to-atomic-level-dna-output.csv",MSA:"tests/to-atomic-level-msa-output.csv"},nt="molfile(sequence)";async function it(t,e="seq",s){const n=t.getCol(e),i=s.getBioLib();await(0,Q.i0)(t,n,i)}(0,e.W3)("toAtomicLevel",(async()=>{const s={},n={};let i,r,o=null;async function h(t,s){const n=t.getCol("sequence");await(0,l.toAtomicLevel)(t,n);const i=t.getCol(nt),r=s.getCol(nt),o=[...i.values()],a=[...r.values()];(0,e.f6)(o,a)}(0,e.bb)((async()=>{i=await(0,l.getMonomerLibHelper)(),o=await a.dapi.userDataStorage.get(P.RV,!0),await a.dapi.userDataStorage.put(P.RV,{},!0),await i.loadLibraries(!0);for(const t in tt)s[t]=await J.readCsv(et[t]),await a.data.detectSemanticTypes(s[t]),n[t]=await J.readCsv(st[t])})),(0,e.X5)((async()=>{await a.dapi.userDataStorage.put(P.RV,o,!0),await i.loadLibraries(!0)}));for(const t in tt)(0,e.Bu)(`${tt[t]}`,(async()=>{await h(s[t],n[t])}),{skipReason:"GROK-13100"});!function(t){t.fastaDna="fastaDna",t.fastaRna="fastaRna",t.fastaPt="fastaPt",t.separatorDna="separatorDna",t.separatorRna="separatorRna",t.separatorPt="separatorPt",t.separatorUn="separatorUn",t.helm="helm"}(r||(r={}));const c={[r.fastaDna]:"seq\nACGTC\nCAGTGT\nTTCAAC",[r.fastaRna]:"seq\nACGUC\nCAGUGU\nUUCAAC",[r.fastaPt]:"seq\nFWPHEY\nYNRQWYV\nMKPSEYV",[r.separatorDna]:"seq\nA/C/G/T/C\nC/A/G/T/G/T\nT/T/C/A/A/C",[r.separatorRna]:"seq\nA*C*G*U*C\nC*A*G*U*G*U\nU*U*C*A*A*C",[r.separatorPt]:"seq\nF-W-P-H-E-Y\nY-N-R-Q-W-Y-V\nM-K-P-S-E-Y-V",[r.separatorUn]:"seq\nmeI-hHis-Aca-N-T-dE-Thr_PO3H2-Aca-D\nmeI-hHis-Aca-Cys_SEt-T-dK-Thr_PO3H2-Aca-Tyr_PO3H2\nLys_Boc-hHis-Aca-Cys_SEt-T-dK-Thr_PO3H2-Aca-Tyr_PO3H2",[r.helm]:"seq\nPEPTIDE1{meI.D-gGlu.Aca.N.T.dE.Thr_PO3H2.Aca.D}$$$\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2}$$$\nPEPTIDE1{Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2}$$$"};async function u(e){const s=c[e],n=t.DataFrame.fromCsv(s);return await a.data.detectSemanticTypes(n),n}(0,e.Bu)("fastaDna",(async()=>{await it(await u(r.fastaDna),"seq",i)})),(0,e.Bu)("fastaRna",(async()=>{await it(await u(r.fastaRna),"seq",i)})),(0,e.Bu)("fastaPt",(async()=>{await it(await u(r.fastaPt),"seq",i)})),(0,e.Bu)("separatorDna",(async()=>{await it(await u(r.separatorDna),"seq",i)})),(0,e.Bu)("separatorDna",(async()=>{await it(await u(r.separatorRna),"seq",i)})),(0,e.Bu)("separatorPt",(async()=>{await it(await u(r.separatorPt),"seq",i)})),(0,e.Bu)("separatorUn",(async()=>{await it(await u(r.separatorUn),"seq",i)})),(0,e.Bu)("helm",(async()=>{await it(await u(r.helm),"seq",i)}))}));var rt=s(489);async function ot(e){const s=t.DataFrame.fromCsv(e),n=s.col("seq"),i=await a.functions.call("Bio:detectMacromolecule",{col:n});return i&&(n.semType=i),await a.data.detectSemanticTypes(s),c.Cn.getOrCreate(n)}function at(t,s,n,i){const r=n(t,s);(0,e.l_)(Number(r.toFixed(3)),Number(i.toFixed(3)))}async function lt(t,s,n,i){await a.data.detectSemanticTypes(t);const r=await(0,l.activityCliffs)(t,t.getCol(i),t.getCol("activity"),90,n);(0,e.l_)(null!=r,!0);const o=Array.from(r.root.children).find((t=>{const e=t.className.split(" ");return["ui-btn","ui-btn-ok"].every((t=>e.includes(t)))}));(0,e.l_)(o.innerText.toLowerCase(),`${s} cliffs`)}(0,e.W3)("Distance",(async()=>{const s=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],n={F:0,W:1,R:2,Y:3},i="FWRWY",r="FWRWW",o="FWY",a="FWRWY",l="FWY",h="FWRRRRY";(0,e.Bu)("protein-distance-function",(async()=>{const t=(await ot("seq\n FWRWYVKHP\n YNRWYVKHP\n MWRSWYCKHP")).getDistanceFunctionName();(0,e.l_)(t,rt.U.LEVENSHTEIN)})),(0,e.Bu)("DNA-distance-function",(async()=>{const t=(await ot("seq\n ATAACG\n ATCGA\n ATCGA")).getDistanceFunctionName();(0,e.l_)(t,rt.U.LEVENSHTEIN)})),(0,e.Bu)("MSA-distance-function",(async()=>{const t=(await ot("seq\n ATAAC\n ATCGA\n ATCGA")).getDistanceFunctionName();(0,e.l_)(t,rt.U.HAMMING)})),(0,e.Bu)("levenstein-sub",(async()=>{const t=rt.o[rt.U.LEVENSHTEIN]();at(i,r,t,.2)})),(0,e.Bu)("levenstein-del",(async()=>{const t=rt.o[rt.U.LEVENSHTEIN]();at(o,a,t,.4)})),(0,e.Bu)("hamming",(async()=>{const t=rt.o[rt.U.HAMMING]();at(o,a,t,.6)})),(0,e.Bu)("needleman-blosum62",(async()=>{const t=rt.o[rt.U.NEEDLEMANN_WUNSCH]();at(i,r,t,.205)})),(0,e.Bu)("needleman-blosum62-del",(async()=>{const t=rt.o[rt.U.NEEDLEMANN_WUNSCH]();at(o,a,t,.65)})),(0,e.Bu)("needleman-custom-sub",(async()=>{const t=rt.o[rt.U.NEEDLEMANN_WUNSCH]({scoringMatrix:s,alphabetIndexes:n,gapOpen:1,gapExtend:1});at(i,r,t,.2)})),(0,e.Bu)("needleman-custom-del",(async()=>{const t=rt.o[rt.U.NEEDLEMANN_WUNSCH]({scoringMatrix:s,alphabetIndexes:n,gapOpen:1,gapExtend:1});at(o,a,t,.8)})),(0,e.Bu)("needleman-custom-zero-extend",(async()=>{const t=rt.o[rt.U.NEEDLEMANN_WUNSCH]({scoringMatrix:s,alphabetIndexes:n,gapOpen:1,gapExtend:0});at(l,h,t,.714)})),(0,e.Bu)("needleman-custom-half-extend",(async()=>{const t=rt.o[rt.U.NEEDLEMANN_WUNSCH]({scoringMatrix:s,alphabetIndexes:n,gapOpen:2,gapExtend:1});at(l,h,t,1.286)})),(0,e.Bu)("needleman-custom-same-extend",(async()=>{const e=rt.o[rt.U.NEEDLEMANN_WUNSCH]({scoringMatrix:s,alphabetIndexes:n,gapOpen:1,gapExtend:1});t.Test.isInBenchmark?at(Array(1e4).fill("FWRY").join(""),Array(1e4).fill("FYWRRY").join(""),e,.667):at(l,h,e,1.143)}))}));var ht=s(116);async function ct(t,s,n){const i=t.getCol(n),r=await a.functions.call("Bio:detectMacromolecule",{col:i});r&&(i.semType=r);const o=await(0,l.sequenceSpaceTopMenu)(t,t.col(n),s,rt.U.LEVENSHTEIN,!0);(0,e.l_)(null!=o,!0)}(0,e.W3)("activityCliffs",(async()=>{let s,n,i,r,o=[],l=[];(0,e.bb)((async()=>{o=[],l=[]})),(0,e.X5)((async()=>{})),(0,e.Bu)("activityCliffsOpens",(async()=>{n=await b(t.Test.isInBenchmark?"test/peptides_motif-with-random_10000.csv":"tests/100_3_clustests.csv"),l.push(n),s=a.shell.addTableView(n),o.push(s);const e=t.Test.isInBenchmark?6:3;await lt(n,e,ht.AL.UMAP,"sequence")}),{skipReason:"GROK-13952"}),(0,e.Bu)("activityCliffsWithEmptyRows",(async()=>{r=await b("tests/100_3_clustests_empty_vals.csv"),l.push(r),i=a.shell.addTableView(r),o.push(i),await lt(r,3,ht.AL.UMAP,"sequence")}),{skipReason:"GROK-13851: Unhandled exceptions"})})),(0,e.W3)("sequenceSpace",(async()=>{let s,n,i,r;(0,e.Bu)("sequenceSpaceOpens",(async()=>{s=await b(t.Test.isInBenchmark?"test/peptides_motif-with-random_10000.csv":"tests/100_3_clustests.csv"),n=a.shell.addTableView(s),await ct(s,ht.AL.UMAP,"sequence"),a.shell.closeTable(s),n.close()})),(0,e.Bu)("sequenceSpaceWithEmptyRows",(async()=>{i=await b("tests/100_3_clustests_empty_vals.csv"),r=a.shell.addTableView(i),await ct(i,ht.AL.UMAP,"sequence"),a.shell.closeTable(i),r.close()}))})),(0,e.W3)("Scoring",(()=>{const s="sequence",n="expected_similarity",i="expected_identity",r=t.DataFrame.fromCsv(`${s},${n},${i}\n PEPTIDE1{Aca.Orn.gGlu.Pqa.D-His_1Bn.dH.hHis.4Abz.D-Tic.D-Dap.Y.Iva.meS.F.P.F.D-1Nal}$$$$,1.0,1.0\n PEPTIDE1{Iva.Gly_allyl.gGlu.Pqa.D-Dip.dH.hHis.4Abz.D-aHyp.D-Dap.Y.Iva.I.Tyr_26diMe.P.Asu.meC}$$$$,0.68,0.53\n PEPTIDE1{[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal]}$$$$V2.0,0.34,0.0\n `),o=r.getCol(s);o.setTag(t.TAGS.UNITS,h.r2.HELM),o.semType=t.SEMTYPE.MACROMOLECULE;const a=o.get(0);(0,e.bb)((async()=>{const t=await(0,_.JN)();await t.loadLibraries(!0)})),(0,e.Bu)("Identity",(async()=>{const t=await(0,l.sequenceIdentityScoring)(r,o,a);for(let s=0;s<t.length;s++)(0,e.jh)(t.get(s),r.get(i,s),.01,`Wrong identity score for sequence at position ${s}`)})),(0,e.Bu)("Similarity",(async()=>{const t=await(0,l.sequenceSimilarityScoring)(r,o,a);for(let s=0;s<t.length;s++)(0,e.jh)(t.get(s),r.get(n,s),.01,`Wrong similarity score for sequence at position ${s}`)}))}));const ut=new t.Package;async function mt(s,n,i){const r=await(0,e.ci)({category:s,test:n,testContext:i});return t.DataFrame.fromObjects(r)}})(),bio_test=n})();
|
|
2
2
|
//# sourceMappingURL=package-test.js.map
|