@datagrok/sequence-translator 1.10.14 → 1.10.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
1
  /*! For license information please see package-test.js.LICENSE.txt */
2
- var sequencetranslator_test;(()=>{var t={6717:(t,e,n)=>{"use strict";n.d(e,{j:()=>o});var r=n(6082);async function o(){const t=r.Func.find({package:"Chem",name:"getRdKitModule"});if(0===t.length)throw new Error('Package "Chem" must be installed for getRdKitModule.');return(await t[0].prepare().call()).getOutputParamValue()}},3599:(t,e,n)=>{"use strict";n.d(e,{o:()=>r.o});var r=n(6869)},9124:(t,e,n)=>{"use strict";n.d(e,{b2:()=>i});var r=n(7389),o=n(6082);async function i(){const t="Helm",e=o.Func.find({package:t,name:"getHelmHelper"});if(0===e.length)throw new Error(`Package '${t}' must be installed for HelmHelper.`);return(await e[0].prepare().call()).getOutputParamValue()}o.JsInputBase,Error,r.input.helmAsync=async function(t,e){return(await i()).createHelmInput(t,e)}},8438:(t,e,n)=>{"use strict";function r(t){return t.startsWith("[")&&t.endsWith("]")?t.slice(1,-1):t}n.d(e,{D:()=>r})},8123:(t,e,n)=>{"use strict";n.d(e,{u:()=>r});const r={V2K_RGP_SHIFT:8,V2K_RGP_LINE:"M RGP",V2K_A_LINE:"A ",V3K_COUNTS_SHIFT:14,V3K_IDX_SHIFT:7,V3K_HEADER_FIRST_LINE:"\nDatagrok macromolecule handler\n\n",V3K_HEADER_SECOND_LINE:" 0 0 0 0 0 0 999 V3000\n",V3K_BEGIN_CTAB_BLOCK:"M V30 BEGIN CTAB\n",V3K_END_CTAB_BLOCK:"M V30 END CTAB\n",V3K_BEGIN_COUNTS_LINE:"M V30 COUNTS ",V3K_COUNTS_LINE_ENDING:" 0 0 0\n",V3K_BEGIN_ATOM_BLOCK:"M V30 BEGIN ATOM\n",V3K_END_ATOM_BLOCK:"M V30 END ATOM\n",V3K_BEGIN_BOND_BLOCK:"M V30 BEGIN BOND\n",V3K_END_BOND_BLOCK:"M V30 END BOND\n",V3K_BOND_CONFIG:" CFG=",V3K_BEGIN_DATA_LINE:"M V30 ",V3K_END:"M END",PRECISION_FACTOR:1e4,DEOXYRIBOSE:{polymerType:"RNA",symbol:"d"},RIBOSE:{polymerType:"RNA",symbol:"r"},PHOSPHATE:{polymerType:"RNA",symbol:"p"},OXYGEN:"O",HYDROGEN:"H"}},6197:(t,e,n)=>{"use strict";n.d(e,{Y:()=>o});var r=n(3599);function o(t){let e;switch(t){case r.o.BASE:case r.o.SUGAR:case r.o.LINKER:case r.o.NUCLEOTIDE:case"nucleotide":e="RNA";break;case r.o.AA:e="PEPTIDE";break;case r.o.CHEM:e="CHEM";break;case r.o.BLOB:e="BLOB";break;default:e="PEPTIDE",console.warn(`Unexpected HelmType '${t}'`)}return e}},9235:(t,e,n)=>{"use strict";n.d(e,{H:()=>c,R:()=>l});var r=n(6082),o=n(1991),i=n.n(o),s=n(330),a=n(3599);async function l(t,e,o,l,c,u,h){const d=t.length,p=t.dataFrame,f=Math.max(navigator.hardwareConcurrency-2,1),m=new Array(f).fill(null).map((()=>new Worker(new URL(n.p+n.u(455),n.b)))),g=d/f,y=new Array(f),b=u.getSeqHandler(t),v="RNA"==l?a.o.NUCLEOTIDE:a.o.AA,C=i().count(0).take(t.length).map((t=>{const e=b.getSplitted(t);return i().count(0).take(e.length).map((t=>({position:t,symbol:e.getCanonical(t),biotype:v}))).toArray()})).toArray();for(let t=0;t<f;t++){const n=m[t],r=Math.floor(t*g),i=t===f-1?d:Math.floor((t+1)*g);y[t]=new Promise((t=>{n.onmessage=e=>{t(e.data)}})),n.postMessage({seqList:C,monomersDict:e,alphabet:o,polymerType:l,start:r,end:i})}const x=[],w=[];await Promise.all(y).then((t=>{for(const e of t)x.push(...e.molfiles),w.push(...e.warnings)})),setTimeout((()=>{m.forEach((t=>{t.terminate()}))}),0);const A=(0,s.qj)(p,t.name),T=r.Column.fromType(r.COLUMN_TYPE.STRING,A,t.length).init((t=>x[t]?.molfile));return T.semType=r.SEMTYPE.MOLECULE,T.meta.units=r.UNITS.Molecule.MOLBLOCK,T.setTag(".sequence-src-col",t.name),{molCol:T,warnings:w}}function c(t,e){const n={},o={};for(const i of t){const t=e.getWebEditorMonomer(i.biotype,i.symbol).backgroundcolor,a=(0,s.vG)(t??r.Color.toRgb(r.Color.mouseOverRows))??[1,0,0,.7];for(const t of i.atoms)n[t]=a;for(const t of i.bonds)o[t]=a}return{atoms:Object.keys(n).map((t=>parseInt(t))),bonds:Object.keys(o).map((t=>parseInt(t))),highlightAtomColors:n,highlightBondColors:o}}},3561:(t,e,n)=>{"use strict";n.d(e,{Hb:()=>l,YN:()=>m,gU:()=>c});var r=n(8123),o=n(294),i=n(3151),s=n(439),a=n(6197);function l(t,e,n){const o=new Map;for(const a of t.getMonomerSymbolsByType(e)){const l=t.getMonomer(e,a);if("RNA"===e&&("Branch"===l.monomerType||n===s.YI.DNA&&l.symbol===r.u.DEOXYRIBOSE.symbol||n===s.YI.RNA&&l.symbol===r.u.RIBOSE.symbol||l.symbol===r.u.PHOSPHATE.symbol)||"PEPTIDE"===e&&"Branch"!==l.monomerType){const t={};i.f6.forEach((e=>{t[e]=l[e]})),o.set(a,t)}}return o}function c(t,e,n,i){if(0===t.length)return o.vF.createEmpty();const l=f,{atomCount:c,bondCount:h,needsCapping:p}=l(t,e,n,i),g=new Array(c),y=new Array(h);let b,v=null,C=null;"PEPTIDE"===i?b=u:(b=d,v=n===s.YI.DNA?(0,o.xb)(e,r.u.DEOXYRIBOSE):(0,o.xb)(e,r.u.RIBOSE),C=(0,o.xb)(e,r.u.PHOSPHATE));const x={i:0,nodeShift:0,bondShift:0,backbonePositionShift:new Array(2).fill(0),branchPositionShift:new Array(2).fill(0),backboneAttachNode:0,branchAttachNode:0,flipFactor:1},w={sugar:v,phosphate:C,seqLength:t.length,atomCount:c,bondCount:h},A=new o.Cg,T=[];let E,S=0;for(x.i=0;x.i<w.seqLength;++x.i){const n=t[x.i];if(n.symbol===s._S)continue;const r=(0,o.xb)(e,{symbol:n.symbol,polymerType:(0,a.Y)(n.biotype)});E=r.terminalR2Atom;const i=x.nodeShift,l=x.bondShift;b(r,g,y,x,w),r.stereoAtoms?.forEach((t=>T.push(t+S))),S+=r.atoms.x.length;const c=x.nodeShift-i,u=new Array(c);for(let t=0;t<c;++t)u[t]=i+t;const h=x.bondShift-l,d=new Array(h);for(let t=0;t<h;++t)d[t]=l+t;A.set(x.i,{biotype:n.biotype,symbol:n.symbol,atoms:u,bonds:d})}p&&function(t,e,n,o,i=r.u.OXYGEN){const s=n.nodeShift+1;t[o.atomCount]=r.u.V3K_BEGIN_DATA_LINE+s+" "+(i??r.u.OXYGEN)+" "+m(n.backbonePositionShift[0])+" "+n.flipFactor*m(n.backbonePositionShift[1])+" 0.000000 0\n";const a=n.backboneAttachNode,l=s;e[o.bondCount]=r.u.V3K_BEGIN_DATA_LINE+n.bondShift+" 1 "+a+" "+l+"\n"}(g,y,x,w,E??r.u.OXYGEN);const I=r.u.V3K_BEGIN_COUNTS_LINE+c+" "+h+r.u.V3K_COUNTS_LINE_ENDING;let N="";return N+=r.u.V3K_HEADER_FIRST_LINE,N+=r.u.V3K_HEADER_SECOND_LINE,N+=r.u.V3K_BEGIN_CTAB_BLOCK,N+=I,N+=r.u.V3K_BEGIN_ATOM_BLOCK,N+=g.join(""),N+=r.u.V3K_END_ATOM_BLOCK,N+=r.u.V3K_BEGIN_BOND_BLOCK,N+=y.join(""),N+=r.u.V3K_END_BOND_BLOCK,T.length>0&&(N+=function(t){const e=[];let n=`M V30 MDLV30/STEABS ATOMS=(${t.length}`;for(let r=0;r<t.length;r++){const o=`${n} ${t[r]}`;o.length>76?(e.push(`${n} -\n`),n=`M V30 ${t[r]}`):n=o,r===t.length-1&&e.push(`${n})\n`)}return`M V30 BEGIN COLLECTION\n${e.join("")}M V30 END COLLECTION\n`}(T)),N+=r.u.V3K_END_CTAB_BLOCK,N+=r.u.V3K_END,{molfile:N,monomers:A}}function u(t,e,n,r){r.flipFactor=(-1)**(r.i%2),h(t,e,n,r)}function h(t,e,n,o){!function(t,e,n){for(let o=0;o<t.atoms.atomTypes.length;++o){const i=n.nodeShift+o+1;e[n.nodeShift+o]=r.u.V3K_BEGIN_DATA_LINE+i+" "+t.atoms.atomTypes[o]+" "+m(n.backbonePositionShift[0]+t.atoms.x[o])+" "+m(n.backbonePositionShift[1]+n.flipFactor*t.atoms.y[o])+" "+t.atoms.kwargs[o]}}(t,e,o),p(t,n,o),function(t,e,n){if(0!==n.backboneAttachNode){const o=n.bondShift,i=n.backboneAttachNode,s=t.meta.terminalNodes[0]+n.nodeShift;e[n.bondShift-1]=r.u.V3K_BEGIN_DATA_LINE+o+" 1 "+i+" "+s+"\n"}}(t,n,o),null!==t.meta.branchShift&&t.meta.terminalNodes.length>2&&function(t,e){e.branchAttachNode=e.nodeShift+t.meta.terminalNodes[2];for(let n=0;n<2;++n)e.branchPositionShift[n]=e.backbonePositionShift[n]+t.meta.branchShift[n]}(t,o),function(t,e){e.backboneAttachNode=e.nodeShift+t.meta.terminalNodes[1],e.bondShift+=t.bonds.atomPairs.length+1,e.nodeShift+=t.atoms.atomTypes.length,e.backbonePositionShift[0]+=t.meta.backboneShift?.[0]??0,e.backbonePositionShift[1]+=e.flipFactor*(t.meta.backboneShift?.[1]??0)}(t,o)}function d(t,e,n,o,i){if(0===o.i)h(i.sugar,e,n,o);else for(const t of[i.phosphate,i.sugar])h(t,e,n,o);!function(t,e,n,o){(function(t,e,n){for(let o=0;o<t.atoms.atomTypes.length;++o){const i=n.nodeShift+o+1;e[n.nodeShift+o]=r.u.V3K_BEGIN_DATA_LINE+i+" "+t.atoms.atomTypes[o]+" "+m(n.branchPositionShift[0]+t.atoms.x[o])+" "+m(n.branchPositionShift[1]+n.flipFactor*t.atoms.y[o])+" "+t.atoms.kwargs[o]}})(t,e,o),p(t,n,o),function(t,e,n){const o=n.bondShift,i=n.branchAttachNode,s=t.meta.terminalNodes[0]+n.nodeShift;e[o-1]=r.u.V3K_BEGIN_DATA_LINE+o+" 1 "+i+" "+s+"\n"}(t,n,o);const i=o.bondShift,s=o.branchAttachNode,a=t.meta.terminalNodes[0]+o.nodeShift;n[i-1]=r.u.V3K_BEGIN_DATA_LINE+i+" 1 "+s+" "+a+"\n",o.bondShift+=t.bonds.atomPairs.length+1,o.nodeShift+=t.atoms.atomTypes.length}(t,e,n,o)}function p(t,e,n){for(let o=0;o<t.bonds.atomPairs.length;++o){const i=n.bondShift+o+1,s=t.bonds.atomPairs[o][0]+n.nodeShift,a=t.bonds.atomPairs[o][1]+n.nodeShift;let l="";if(t.bonds.bondConfiguration.has(o)){let e=t.bonds.bondConfiguration.get(o);n.flipFactor<0&&(e=1===e?3:1),l=" CFG="+e}const c=t.bonds.kwargs.has(o)?" "+t.bonds.kwargs.get(o):"";e[n.bondShift+o]=r.u.V3K_BEGIN_DATA_LINE+i+" "+t.bonds.bondTypes[o]+" "+s+" "+a+l+c+"\n"}}function f(t,e,n,i){let l=0,c=0,u=0,h=!0,d=null;for(const n of t)if(n.symbol!==s._S){if("*"==n.symbol)throw new Error("Gap canonical symbol is '', not '*");d=(0,o.xb)(e,{symbol:n.symbol,polymerType:(0,a.Y)(n.biotype)}),l+=d.atoms.x.length,c+=d.bonds.bondTypes.length,u++}if("PEPTIDE"===i)l+=1,c+=u,u>0&&((d?.meta?.rNodes?.length??0)<2||d?.terminalR2Atom?.toLowerCase()===r.u.HYDROGEN.toLowerCase())&&(h=!1,l-=1,c-=1);else{const i=n===s.YI.DNA?(0,o.xb)(e,r.u.DEOXYRIBOSE):(0,o.xb)(e,r.u.RIBOSE),a=(0,o.xb)(e,r.u.PHOSPHATE);l+=(t.length-1)*a.atoms.x.length,l+=t.length*i.atoms.x.length,l+=1,c+=(t.length-1)*a.bonds.bondTypes.length,c+=t.length*i.bonds.bondTypes.length,c-=1,c+=3*t.length}return{atomCount:l,bondCount:c,needsCapping:h}}function m(t){return Math.round(r.u.PRECISION_FACTOR*t)/r.u.PRECISION_FACTOR}},6077:(t,e,n)=>{"use strict";n.d(e,{C4:()=>f,eM:()=>m});var r=n(4328),o=n(6082),i=n(1991),s=n.n(i),a=n(439),l=n(3561),c=n(9235),u=n(294),h=n(9192),d=n(330),p=n(8123);async function f(t,e,n,i,l){if(e.semType!==o.SEMTYPE.MACROMOLECULE)return{molCol:null,warnings:[`Only the ${o.SEMTYPE.MACROMOLECULE} columns can be converted to atomic level, the chosen column has semType '${e.semType}'`]};let u=e;const p=i.getSeqHandler(e);let f,g;p.notation!==a.Hi.SEPARATOR&&p.notation!==a.Hi.BILN&&(u=p.convert(a.Hi.SEPARATOR,"."),u.name=e.name);try{g=i.getSeqHandler(u).alphabet,f=(0,d.pz)(g)}catch(t){const[e,n]=(0,h.AP)(t);return{molCol:null,warnings:[e]}}const y=function(t,e){const n=t.length,o=new Array(n),i=e.getSeqHandler(t);let a=!1;const l=i.defaultBiotype;for(let t=0;t<n;++t){const e=i.getSplitted(t);a||(a=0===e.length),o[t]=s().count(0).take(e.length).filter((t=>!e.isGap(t))).map((t=>({position:t,biotype:l,symbol:e.getCanonical(t)}))).toArray()}return a&&r.shell.warning(`Some values in the "${t.name}" column are empty`),o}(u,i),b=m(y,f,g,n,l),v=u.length,C=await(0,c.R)(u,b,g,f,n,i,l);C.warnings.length>.05*v&&r.shell.warning(`Molfile conversion resulted in ${C.warnings.length} errors`);const x=o.Func.find({name:"convertToV3KViaOCL"})[0];if(x&&C.molCol)try{const t=C.molCol.toList(),e=await x.apply({mols:t});C.molCol.init((n=>e[n]?e[n]:t[n]))}catch(t){console.error(t)}return C}function m(t,e,n,r,o){const i=(0,l.Hb)(r,e,n),s={},c={value:null};if("RNA"===e){const t=n===a.YI.RNA?[p.u.RIBOSE,p.u.PHOSPHATE]:[p.u.DEOXYRIBOSE,p.u.PHOSPHATE];for(const n of t)g(s,n.symbol,i,o,e,c)}for(let n=0;n<t.length;++n){const r=t[n];for(const t of r){const n=t.symbol;if(""!==n)try{if("RNA"===e&&3===n.split(/\(|\)/).filter((t=>!!t)).length){const t=n.split(/\(|\)/)[1];g(s,t,i,o,e,c),s[e]?.[t]&&(s[e][n]=s[e][t])}else g(s,n,i,o,e,c)}catch(t){const e=t instanceof Error?t.message:t.toString(),r=t instanceof Error?t.stack:void 0;throw console.error(`bio lib: getMonomersDictFromLib() sym='${n}', error:\n${e}\n${r}`),new Error(`Can't get monomer '${n}' from library: ${e}`)}}}return s}function g(t,e,n,r,o,i){const s={polymerType:o,symbol:e};if(!(0,u.bq)(t,s)){const a=function(t,e,n,r,o){if(e.has(t)){const s=e.get(t),a=function(t){const e=[];for(const n of t){let t=n.capGroupSmiles;t||(t=n.capGroupSMILES),t=t.replace(/(\[|\]|\*|:|\d)/g,"").replace("OH","O").replace("Oh","O"),e.push(t)}return e}(s.rgroups),c=(i=s.molfile).includes("V3000")?function(t){const e=new Map,n=/M V30 (\d+) R#.+RGROUPS=\((\d+) (\d+)\).*/gm;let r;for(;null!==(r=n.exec(t));)r.index===n.lastIndex&&n.lastIndex++,e.set(parseInt(r[1]),parseInt(r[3]));return e}(i):function(t){const e=new Map;let n=t.indexOf(p.u.V2K_A_LINE,0),r=n;for(;-1!==n;){r=t.indexOf("\n",n);const o=parseInt(t.substring(n,r).replace(/^A\s+/,""));n=t.indexOf("R",r),r=t.indexOf("\n",n);const i=parseInt(t.substring(n,r).replace(/^R/,""));e.set(o,i),n=t.indexOf(p.u.V2K_A_LINE,r)}for(n=t.indexOf(p.u.V2K_RGP_LINE,0),r=t.indexOf("\n",n);-1!==n;){n+=p.u.V2K_RGP_SHIFT,r=t.indexOf("\n",n);const o=t.substring(n,r).replaceAll(/\s+/g," ").split(" ").map((t=>parseInt(t))).slice(1);for(let t=0;t<o.length;t+=2){if(e.has(o[t])&&e.get(o[t])!==o[t+1])throw new Error(`r-group index ${o[t]} has already been added with a different value`);e.set(o[t],o[t+1])}n=t.indexOf(p.u.V2K_RGP_LINE,r)}return e}(i),u=s.molfile.includes("V3000")?s.molfile:function(t,e){const n=e.get_mol(function(t){return t.split("\n").map((t=>{const e=t.indexOf(" R# "),n=t.indexOf(" R ");if(-1===e&&-1===n)return t;const r=-1!==e?e:n,o=t.split("");for(let t=r+5;t<o.length;t++)" "!==o[t]&&(o[t]="0");return o.join("")})).join("\n")}(t)),r=n.get_v3Kmolblock();return n.delete(),r}(function(t){let e=t.indexOf(p.u.V2K_A_LINE,0);-1===e&&(e=t.indexOf(p.u.V2K_RGP_LINE));const n=t.indexOf(p.u.V3K_END,e);return t.substring(0,e)+t.substring(n)}(s.molfile),n),h=function(t){let e=(t=t.replaceAll("\r","")).indexOf(p.u.V3K_BEGIN_COUNTS_LINE)+p.u.V3K_COUNTS_SHIFT,n=t.indexOf(" ",e+1);const r=parseInt(t.substring(e,n));return e=n+1,n=t.indexOf(" ",e+1),{atomCount:r,bondCount:parseInt(t.substring(e,n))}}(u),d=function(t,e){const n=new Array(e),r=new Float32Array(e),o=new Float32Array(e),i=new Array(e);let s=t.indexOf(p.u.V3K_BEGIN_ATOM_BLOCK);s=t.indexOf("\n",s);let a=s;for(let l=0;l<e;l++){s=t.indexOf(p.u.V3K_BEGIN_DATA_LINE,s)+p.u.V3K_IDX_SHIFT,a=t.indexOf(" ",s),s=a+1,a=t.indexOf(" ",s),n[l]=t.substring(s,a);const e=new Array(2);for(let n=0;n<2;++n)s=a+1,a=t.indexOf(" ",s),e[n]=parseFloat(t.substring(s,a));r[l]=e[0],o[l]=e[1],s=a,a=t.indexOf("\n",s)+1,i[l]=t.slice(s,a),s=a}return{atomTypes:n,x:r,y:o,kwargs:i}}(u,h.atomCount),f=function(t,e){const n=new Uint32Array(e),r=new Array(e),o=new Map,i=new Map;let s=t.indexOf(p.u.V3K_BEGIN_BOND_BLOCK);s=t.indexOf("\n",s);let a=s;for(let l=0;l<e;++l){const e=new Array(3);s=t.indexOf(p.u.V3K_BEGIN_DATA_LINE,a)+p.u.V3K_IDX_SHIFT,a=t.indexOf(" ",s);for(let n=0;n<3;++n)s=a+1,a=Math.min(t.indexOf("\n",s),t.indexOf(" ",s)),e[n]=parseInt(t.slice(s,a));n[l]=e[0],r[l]=e.slice(1);const c=t.indexOf("\n",s);let u=t.slice(a,c),h=u.indexOf(p.u.V3K_BOND_CONFIG);if(-1!==h){h=u.indexOf("=",h)+1;let t=u.indexOf(" ",h);-1===t&&(t=u.length);const e=parseInt(u.slice(h,t));o.set(l,e);const n=p.u.V3K_BOND_CONFIG+e.toString();u=u.replace(n,"")}u||i.set(l,u)}return{bondTypes:n,atomPairs:r,bondConfiguration:o,kwargs:i}}(u,h.bondCount),m=function(t,e,n,r){const o={backboneShift:null,branchShift:null,terminalNodes:[],rNodes:[]};if(n&&r&&[1,2].some((t=>!Array.from(r.values()).find((e=>e==t))))){const o=[1,2].find((t=>!Array.from(r.values()).find((e=>e==t)))),i=[1,2].find((t=>Array.from(r.values()).find((e=>e==t)))),s=Array.from(r.keys()).find((t=>r.get(t)===i))-1,a=t.x[s],l=t.y[s],c=e.atomPairs.find((t=>t.includes(s+1))).find((t=>t!==s+1))-1;let u=t.x.reduce(((e,n,r)=>{if(r===s)return e;if(r===c)return e;const o=t.y[r];return Math.sqrt((n-a)**2+(o-l)**2)>Math.sqrt((t.x[e]-a)**2+(t.y[e]-l)**2)?r:e}),-1);if(-1===u&&(u=t.x.length,t.x=new Float32Array([...t.x,-a]),t.y=new Float32Array([...t.y,-l]),t.atomTypes=[...t.atomTypes,"H"],t.kwargs=[...t.kwargs,""],e.atomPairs.push([c+1,u+1]),e.bondTypes=new Uint32Array([...e.bondTypes,1]),e.kwargs.set(e.atomPairs.length-1,"")),r.set(u+1,o),1===o)n.unshift(t.atomTypes[u]);else{if(2!==o)throw new Error(`Unexpected missing R-group: ${o}`);n.splice(1,0,t.atomTypes[u])}}return function(t,e,n){for(const[r,o]of n)t.atomTypes[r-1]=e[o-1]}(t,n,r),function(t,e){e.rNodes=Array.from(t.keys());for(let n=0;n<e.rNodes.length;n++)for(const r of[1,2])if(t.get(e.rNodes[n])===r){const t=e.rNodes[r-1];e.rNodes[r-1]=e.rNodes[n],e.rNodes[n]=t}}(r,o),y(e,o),o}(d,f,a,c),g=function(t){let e=[],n=t.indexOf("M V30 MDLV30/STEABS ATOMS=(");for(;-1!==n;){n+=28;const r=t.indexOf(")",n);e=e.concat(t.substring(n,r).split(" ").slice(1).map((t=>parseInt(t)))),n=r,n=t.indexOf("M V30 MDLV30/STEABS ATOMS=(",n)}return e}(u),v={atoms:d,bonds:f,meta:m,stereoAtoms:g};return"PEPTIDE"===r?function(t){const e=t.meta.terminalNodes[0]-1,n=t.meta.rNodes[0]-1,r=t.atoms.x,o=t.atoms.y;S(t,-r[e],-o[e]);const i=w(r[n],o[n]);A(t.atoms,-i),r[t.meta.rNodes[1]-1]<0&&T(t);const s=function(t){const e=function(t){const e=new Map;for(const n of t.bonds.atomPairs)for(let t=0;t<2;t++){const r=n[t],o=n[(t+1)%2];e.has(r)?e.get(r)?.push(o):e.set(r,new Array(1).fill(o))}return e}(t);let n=0;const r=t.atoms.atomTypes.length;let o=0;if(t.meta.terminalNodes.length<2)return null;for(;0===n;){const i=e.get(t.meta.terminalNodes[1])[o];if(t.atoms.atomTypes[i-1]===p.u.OXYGEN&&i!==t.meta.rNodes[1]&&(n=i),o++,o>r)return null}return n}(t);null!=s&&(function(t,e){t.atoms.y[t.meta.rNodes[1]-1]<0&&t.atoms.y[e-1]<0&&(function(t){E(t,!0)}(t),A(t.atoms,-function(t,e){return w(t,e)+Math.PI/2}(t.atoms.x[t.meta.terminalNodes[1]-1],t.atoms.y[t.meta.terminalNodes[1]-1])))}(t,s),function(t,e){const n=t.atoms.x;n[t.meta.rNodes[1]-1]>n[e-1]&&function(t,e,n){const r=e-1,o=n-1,i=t.atoms.x,s=t.atoms.y,a=i[r],l=s[r];i[r]=i[o],s[r]=s[o],i[o]=a,s[o]=l}(t,e,t.meta.rNodes[1])}(t,s))}(v):t===p.u.RIBOSE.symbol||t===p.u.DEOXYRIBOSE.symbol?function(t,e){const n=t.atoms.x,r=t.atoms.y;let o=t.meta.terminalNodes[0]-1;const i=t.meta.rNodes[1]-1;S(t,-n[o],-r[o]);const s=w(n[t.meta.rNodes[2]-1],r[t.meta.rNodes[2]-1]);A(t.atoms,-s),n[t.meta.rNodes[0]-1]>n[t.meta.rNodes[1]-1]&&T(t);const a=w(n[i],r[i]);A(t.atoms,3*Math.PI/2-a),e.value=function(t){const e=t.atoms.x,n=t.atoms.y,r=t.meta.rNodes[2]-1,o=t.meta.terminalNodes[2]-1,i=e[r]-e[o],s=n[r]-n[o];return Math.atan2(i,s)}(t),o=t.meta.terminalNodes[0]-1,S(t,-n[o],-r[o])}(v,o):t===p.u.PHOSPHATE.symbol?function(t){const e=t.meta.rNodes[1]-1,n=t.meta.rNodes[0]-1,r=t.atoms.x,o=t.atoms.y;S(t,-r[e],-o[e]);const i=w(r[n],o[n]);A(t.atoms,Math.PI/2-i)}(v):function(t,e){const n=t.atoms.x,r=t.atoms.y,o=t.meta.terminalNodes[0]-1,i=t.meta.rNodes[0]-1;S(t,-n[o],-r[o]);const s=w(n[i],r[i]),a=e.value;if(!a)throw new Error("The value of sugarBranchToOYAngle is null");A(t.atoms,Math.PI-s+a);const c=function(t,e){return(0,l.YN)(Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2))}({x:n[t.meta.rNodes[0]-1],y:r[t.meta.rNodes[0]-1]},{x:n[t.meta.terminalNodes[0]-1],y:r[t.meta.terminalNodes[0]-1]});if(1!=c)for(let t=0;t<n.length;++t)n[t]=(0,l.YN)(n[t]/c),r[t]=(0,l.YN)(r[t]/c)}(v,o),function(t,e,n){if("PEPTIDE"===t){b(e,t);const n=C(e,e.meta.rNodes[1]);n?.removedAtom&&(e.terminalR2Atom=n.removedAtom)}else n===p.u.RIBOSE.symbol||n===p.u.DEOXYRIBOSE.symbol?(C(e,e.meta.rNodes[1]),e.meta.rNodes[1]=e.meta.terminalNodes[1],y(e.bonds,e.meta),b(e,t),C(e,e.meta.rNodes[1]),C(e,e.meta.rNodes[0]),C(e,e.meta.rNodes[2])):n===p.u.PHOSPHATE.symbol&&(e.meta.terminalNodes[0]=e.meta.rNodes[0],S(e,-e.atoms.x[e.meta.terminalNodes[0]-1],-e.atoms.y[e.meta.terminalNodes[0]-1]),b(e,t),C(e,e.meta.rNodes[1]))}(r,v,t),function(t){let e=0;for(;e<t.atoms.atomTypes.length;)t.atoms.atomTypes[e]===p.u.HYDROGEN&&(C(t,e+1),--e),++e}(v),function(t){let e=0;for(;e<t.atoms.atomTypes.length;)"oh"===t.atoms.atomTypes[e]?.toLowerCase()&&(t.atoms.atomTypes[e]="O"),"?"===t.atoms.atomTypes[e]&&(t.atoms.atomTypes[e]="H"),++e}(v),function(t){const e=" RGROUPS=(1 1)";for(let n=0;n<(t.atoms.kwargs?.length??0);n++){const r=t.atoms.kwargs[n];r&&r.includes(e)&&(t.atoms.kwargs[n]=r.replace(e,""))}}(v),v}var i;return null}(e,n,r,o,i);if(!a)throw new Error(`Monomer with symbol '${e}' is absent the monomer library`);(0,u.LQ)(t,s,a)}}function y(t,e){const n=e.rNodes;e.terminalNodes=new Array(n.length).fill(0);const r=e.terminalNodes,o=t.atomPairs;let i=0,s=0;for(;i<o.length&&s<r.length;){for(let t=0;t<r.length;++t)for(let e=0;e<2;++e)o[i][e]===n[t]&&(r[t]=o[i][(e+1)%2],n.length,++s);++i}}function b(t,e){t.meta.rNodes.length>1&&(t.meta.backboneShift=v(t,t.meta.rNodes[1]-1,t.meta.terminalNodes[0]-1)),"RNA"===e&&t.meta.rNodes.length>2&&(t.meta.branchShift=v(t,t.meta.rNodes[2]-1,t.meta.terminalNodes[0]-1))}function v(t,e,n){return[(0,l.YN)(t.atoms.x[e]-t.atoms.x[n]),(0,l.YN)(t.atoms.y[e]-t.atoms.y[n])]}function C(t,e){if(void 0!==e){const n=e-1,r=t.atoms,o=t.bonds,i=t.meta,s=r.atomTypes.splice(n,1)[0];r.x=x(Float32Array,r.x,n,1),r.y=x(Float32Array,r.y,n,1),r.kwargs.splice(n,1);for(let t=0;t<i.terminalNodes.length;++t)i.terminalNodes[t]>e?--i.terminalNodes[t]:i.terminalNodes[t]===e&&(i.terminalNodes[t]=-1);for(let t=0;t<i.rNodes.length;++t)i.rNodes[t]>e?--i.rNodes[t]:i.rNodes[t]===e&&(i.rNodes[t]=-1);let a=0;for(;a<o.atomPairs.length;){const t=o.atomPairs[a][0],n=o.atomPairs[a][1];t===e||n===e?(o.atomPairs.splice(a,1),o.bondTypes=x(Uint32Array,o.bondTypes,a,1),o.bondConfiguration.has(a)&&o.bondConfiguration.delete(a),o.kwargs.has(a)&&o.kwargs.delete(a),--a):(o.atomPairs[a][0]=t>e?t-1:t,o.atomPairs[a][1]=n>e?n-1:n),++a}let l=Array.from(o.bondConfiguration.keys());return l.forEach((t=>{if(o.bondConfiguration.has(t)&&t>n){const e=o.bondConfiguration.get(t);o.bondConfiguration.delete(t),o.bondConfiguration.set(t-1,e)}})),l=Array.from(o.kwargs.keys()),l.forEach((t=>{if(o.kwargs.has(t)&&t>n){const e=o.kwargs.get(t);o.kwargs.delete(t),o.kwargs.set(t-1,e)}})),s?{removedAtom:s}:void 0}}function x(t,e,n,r){const o=new t(e.length-r);let i=0,s=0;for(;i<e.length;)i===n&&(i+=r),o[s]=e[i],++s,++i;return o}function w(t,e){let n;if(0===t)n=e>0?0:Math.PI;else if(0===e)n=t>0?-Math.PI/2:Math.PI/2;else{const r=e/t,o=Math.atan(r);n=t<0?Math.PI/2+o:-Math.PI/2+o}return n}function A(t,e){if(0!==e){const n=t.x,r=t.y,o=Math.cos(e),i=Math.sin(e);for(let t=0;t<n.length;++t){const e=n[t];n[t]=(0,l.YN)(e*o-r[t]*i),r[t]=(0,l.YN)(e*i+r[t]*o)}}}function T(t){E(t,!1)}function E(t,e){if(e){const e=t.atoms.y;for(let t=0;t<e.length;t++)e[t]=-e[t]}else{const e=t.atoms.x;for(let t=0;t<e.length;t++)e[t]=-e[t]}const n=t.bonds.bondConfiguration;for(const[t,e]of n){const r=1===e?3:1;n.set(t,r)}}function S(t,e,n){const r=t.atoms.x,o=t.atoms.y;for(let t=0;t<r.length;++t)r[t]=(0,l.YN)(r[t]+e),void 0!==n&&(o[t]=(0,l.YN)(o[t]+n))}},294:(t,e,n)=>{"use strict";function r(t,e){return t[e.polymerType]?.[e.symbol]}function o(t,e){return!!t[e.polymerType]?.[e.symbol]}function i(t,e,n){let r=t[e.polymerType];r||(r=t[e.polymerType]={}),r[e.symbol]=n}n.d(e,{Cg:()=>s,LQ:()=>i,bq:()=>o,vF:()=>a,xb:()=>r});class s extends Map{constructor(t){super(t)}}class a{constructor(t,e){this.molfile=t,this.monomers=e}static createEmpty(){return new a("",new s(null))}}},330:(t,e,n)=>{"use strict";n.d(e,{pz:()=>i,qj:()=>o,vG:()=>s});var r=n(2003);function o(t,e){return function(t,e){return t?t.columns.getUnusedName(e):e}(t,`molfile(${e})`)}function i(t){let e;if(t===r.YI.PT||t===r.YI.UN)e="PEPTIDE";else{if(t!==r.YI.RNA&&t!==r.YI.DNA)throw new Error(`Unexpected alphabet '${t}'.`);e="RNA"}return e}function s(t){const e=7===t.length?/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t):/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?[parseInt(e[1],16)/256,parseInt(e[2],16)/256,parseInt(e[3],16)/256,e.length>4?parseInt(e[4],16)/256:.3]:null}},4971:(t,e,n)=>{"use strict";n.d(e,{pj:()=>o});var r=n(6082);async function o(){const t=r.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()}},3151:(t,e,n)=>{"use strict";n.d(e,{f6:()=>r,pe:()=>o});const r=["symbol","molfile","rgroups","name"],o={monomerType:"Backbone",smiles:"",name:"",author:"Datagrok",molfile:"",naturalAnalog:"",rgroups:[],createDate:null,id:0,polymerType:"PEPTIDE",symbol:""};new RegExp("[rd]\\((\\w)\\)p?","g")},9192:(t,e,n)=>{"use strict";function r(t){return"string"==typeof t||t instanceof String?t:"StateError"===t.constructor.name?t.message:"StateError"===t.constructor.name&&"$thrownJsError"in t?r(t.$thrownJsError):t instanceof Error?t.message:t.toString()}function o(t){return t instanceof Error?t.stack:"StateError"===t.constructor.name&&"$thrownJsError"in t?o(t.$thrownJsError):void 0}function i(t){return[r(t),o(t)]}n.d(e,{AP:()=>i})},439:(t,e,n)=>{"use strict";n.d(e,{Hi:()=>r,VR:()=>u,YI:()=>o,_S:()=>l,b9:()=>c,gp:()=>i,qE:()=>i});var r,o,i,s=n(2738);!function(t){t.FASTA="fasta",t.SEPARATOR="separator",t.HELM="helm",t.CUSTOM="custom",t.BILN="biln"}(r||(r={})),function(t){t.DNA="DNA",t.RNA="RNA",t.PT="PT",t.UN="UN"}(o||(o={})),function(t){t.aligned="aligned",t.alphabet="alphabet",t.alphabetSize=".alphabetSize",t.alphabetIsMultichar=".alphabetIsMultichar",t.separator="separator",t.isHelmCompatible=".isHelmCompatible",t.positionNames=".positionNames",t.positionLabels=".positionLabels",t.regions=".regions",t.positionShift=".positionShift",t.selectedPosition=".selectedPosition",t.polymerTypeColumnName=".polymerTypeColumnName",t.annotations=".annotations",t.numberingScheme=".numberingScheme",t.annotationColumnName=".annotationColumnName"}(i||(i={}));const 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 s.aD(o.PT,a.fasta.peptide,.5),new s.aD(o.DNA,a.fasta.dna,.55),new s.aD(o.RNA,a.fasta.rna,.55),""),c={[r.FASTA]:"-",[r.SEPARATOR]:"",[r.HELM]:"*",[r.BILN]:""},u="notationProviderConstructor"},2003:(t,e,n)=>{"use strict";n.d(e,{Hi:()=>r.Hi,YI:()=>r.YI,dh:()=>o.dh,gp:()=>r.gp,qp:()=>o.qp,zS:()=>o.zS});var r=n(439),o=n(7291)},2738:(t,e,n)=>{"use strict";n.d(e,{$G:()=>o,aD:()=>i});var r=n(439);class o{static get notationName(){return"Custom"}static get implementsFromHelm(){return!1}static convertFromHelm(t,e){throw new Error("Method convertFromHelm not implemented for this notation provider")}static async getProviderConstructors(){if(window?.DG){const t=window.DG.Func.find({meta:{role:r.VR}});return Promise.all(t.map((t=>t.apply({}))))}return[]}}class i{constructor(t,e,n){this.name=t,this.alphabet=e,this.cutoff=n}}},7291:(t,e,n)=>{"use strict";n.d(e,{Mu:()=>b,dh:()=>C,zS:()=>A,MD:()=>T,qp:()=>x});var r=n(6082),o=n(1991),i=n.n(o),s=(n(2738),n(439));class a{static makePalette(t,e=!1,n=a){const r={};return t.forEach((t=>{const n=t[0],o=t[1];n.forEach(((t,n)=>{r[t]=this.colourPalette[o][e?0:n]}))})),new n(r)}constructor(t){this._palette=t}get(t,e){return this._palette[t]}}a.undefinedColor="rgb(100,100,100)",a.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)"]};class l extends a{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,l)),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,l)),this.grokGroups}static get RasMol(){return void 0===this.rasMol&&(this.rasMol=new l({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 l.aaSynonyms?l.aaSynonyms[t]:t;return super.get(e)}}l.aaSynonyms={MeNle:"L",MeA:"A",MeG:"G",MeF:"F"};class c{static getPalette(t="grok"){switch(t){case"grok":return l.GrokGroups;case"lesk":return l.Lesk;default:throw new Error(`ChemPalette: scheme \`${t}\` does not exist`)}}static getInnerOuter(t){let e=0,n="",r="";for(const o of t)"("==o?e++:")"==o?e--:e?n+=o:r+=o;return isNaN(parseInt(n))?[r,n]:[r,""]}static getColorAAPivot(t="",e="grok"){const n=this.getPalette(e);let[r,o]=this.getInnerOuter(t);if(r=r.length>6?`${r.slice(0,3)}...`:r,o=o.length>6?`${o.slice(0,3)}...`:o,1==t.length||"("==t[1]){const e=t[0]?.toUpperCase();return e in n?[n.get(e),e,o,1]:[this.undefinedColor,r,o,1]}if("d"==t[0]&&t[1]in n&&(2==t.length||"("==t[2])){const e=t[1]?.toUpperCase();return e in n?[n.get(e),e,o,2]:[this.undefinedColor,r,o,2]}if(t.substring(0,3)in this.AAFullNames&&(3==t.length||"("==t[3])){const e=this.AAFullNames[t.substring(0,3)];return e in n?[n.get(e),e,o,3]:[this.undefinedColor,r,o,3]}if(t[0]?.toLowerCase()==t[0]&&t.substring(1,3)in this.AAFullNames&&(4==t.length||"("==t[4])){const e=this.AAFullNames[t.substring(1,3)];return e in n?[n.get(e),e,o,4]:[this.undefinedColor,r,o,4]}return[this.undefinedColor,r,o,0]}}c.SemType="Aminoacids",c.SemTypeMultipleAlignment="AminoacidsMultipleAlignment",c.undefinedColor="rgb(100,100,100)",c.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"},c.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"},c.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(*)*"},c.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"};class u{}u.SemType="Nucleotides",u.SemTypeMultipleAlignment="NucleotidesMultipleAlignment",u.Names={A:"Adenine",C:"Cytosine",G:"Guanine",T:"Thymine",U:"Uracil"};var h=n(4971);function d(t,e=!0){if(null==t)return"rgb(100,100,100)";const n=r.Color.fromHtml(t);if(e){const t=r.Color.g(n),e=r.Color.r(n),o=r.Color.b(n),i=Math.sqrt(Math.pow(0-e,2)+Math.pow(0-t,2)+Math.pow(0-o,2));if(i>210)return`rgb(${e/i*210},${t/i*210},${o/i*210})`}return r.Color.toRgb(n)}class p{static hashCode(t){let e=0;if(0===t.length)return e;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n),e|=0;return e}}class f{}class m extends f{static get palette(){return m._pallete||(m._pallete=m.buildPalette()),m._pallete}static buildPalette(){return(0,h.pj)().then((t=>{t.awaitLoaded(1/0).then((()=>{const e=t.getMonomerLib();e.onChanged.subscribe((()=>{m.customMonomerColors={},m.polymerTypes=e.getPolymerTypes();for(const t of this.polymerTypes){const n=e.getMonomerSymbolsByType(t);for(const r of n){const n=e.getMonomer(t,r);n?.meta?.colors?.default?.background&&(this.customMonomerColors[r]||(this.customMonomerColors[r]={}),this.customMonomerColors[r][t]=d(n.meta.colors.default.background))}}}))}))})),[].concat(...Object.values(a.colourPalette))}get(t,e){const n=m.palette.length,r=m.customMonomerColors[t],o=e??"PEPTIDE";if(r&&r[o])return r[o];const i=p.hashCode(t)%n;return d(m.palette[i])}}m._pallete=null,m.customMonomerColors={},m.polymerTypes=[];var g=n(8438),y=n(3599);class b{get length(){return this.mList.length}get graphInfo(){}isGap(t){return this.getOriginal(t)===this.gapOriginalMonomer}getCanonical(t){if(this.length<=t)throw new Error("Index out of bounds");const e=this.mList[t];return e!==this.gapOriginalMonomer?e:s._S}getOriginal(t){if(this.length<=t)throw new Error("Index out of bounds");return this.mList[t]}getCanonicalRegion(t,e){const n=Math.min(Math.max(0,t),this.length),r=Math.max(Math.min(this.length,e),0)-n,o=this.gapOriginalMonomer;return new Array(r).fill(null).map(((t,e)=>{const r=this.mList[e+n];return r===o?s._S:r}))}getOriginalRegion(t,e){const n=Math.min(Math.max(0,t),this.length),r=Math.max(Math.min(this.length,e),0);return new Array(r-n).fill(null).map(((t,e)=>this.mList[e+n]))}get gapOriginal(){return this.gapOriginalMonomer}constructor(t,e){this.mList=t,this.gapOriginalMonomer=e}}class v extends b{constructor(t,e,n,r){super(t.flat(),r),this.mListSeparated=t,this.connections=e,this._graphInfo=void 0,this.polymerTypes=t.map(((t,e)=>new Array(t.length).fill(n[e]))).flat()}get graphInfo(){return this._graphInfo??(this._graphInfo=this.parseConnections()),this._graphInfo}parseConnections(){const t={connections:[],disjointSeqStarts:[],polymerTypes:this.polymerTypes};if((this.connections?.length??0)>0){let e=0;for(let n=0;n<this.mListSeparated.length;++n)t.disjointSeqStarts.push(e),e+=this.mListSeparated[n].length;const n=(this.connections??"").split("|").filter((t=>(t?.length??0)>0)),r=/^(PEPTIDE|RNA|BLOB|CHEM)\d{1,2}$/,o=/^\d{1,2}:R\d{1}-\d{1,2}:R\d{1}$/;for(const e of n){const n=e.split(",");if(3!==n.length||!o.test(n[2])||!r.test(n[0])||!r.test(n[1]))continue;const i=parseInt(n[0].replace(/^(PEPTIDE|RNA|BLOB|CHEM)/,""))-1,s=parseInt(n[1].replace(/^(PEPTIDE|RNA|BLOB|CHEM)/,""))-1,a=n[0].replace(/\d{1,2}$/,""),l=n[1].replace(/\d{1,2}$/,"");if(i<0||i>=this.mListSeparated.length||s<0||s>=this.mListSeparated.length)continue;const c=n[2].split("-");if(2!==c.length)continue;const u=c[0].split(":"),h=c[1].split(":");if(2!==u.length||2!==h.length)continue;const d=parseInt(u[0])-1,p=parseInt(h[0])-1;d<0||d>=this.mListSeparated[i].length||p<0||p>=this.mListSeparated[s].length||t.connections.push({seq1Type:a,seq2Type:l,seqIndex1:i,seqIndex2:s,monomerIndex1:d,monomerIndex2:p,rGroup1:parseInt(u[1].substring(1)),rGroup2:parseInt(h[1].substring(1))})}}return t}}function C(t,e=void 0){return n=>{if(n){let r;const o=new RegExp(`(?<=^|\\${t})("-"|'-'|[^\\${t}]*)(?=\\${t}|$)`,"g");return null!=e?(o.lastIndex=0,r=i()(n.matchAll(o)).take(e).map((t=>t[0])).toArray()):r=n.replaceAll('"-"',"").replaceAll("'-'","").split(t,e),new b(r,s.b9[s.Hi.SEPARATOR])}return new b([],s.b9[s.Hi.SEPARATOR])}}const x=t=>{const e=t.indexOf("}$"),n=t.substring(0,e+1),r=t.indexOf("$",e+2),o=t.substring(e+2,r),i=n.split("}|");for(let t=0;t<i.length-1;t++)i[t]=i[t]+"}";const a=i.map((t=>(t.match(/(?<=\{).+(?=})/)?.[0]?.split(".")??[]).map((t=>(0,g.D)(t))))),l=i.map((t=>t.replace(/\d{1,2}\{.+\}/,"")));return new v(a,o??"",l,s.b9[s.Hi.HELM])},w=/([^\W_]+)/g;function A(t,e){if(t.length<=e)return t;const n=t.match(w),r=t.length>e||(n?.length??0)>1,o=n?.[0]??" ";return r?o.substring(0,e-1)+"…":o}function T(t){switch(t){case"PEPTIDE":default:return y.o.AA;case"RNA":return y.o.NUCLEOTIDE;case"CHEM":return y.o.CHEM;case"BLOB":return y.o.BLOB}}},8312:(t,e,n)=>{"use strict";n.d(e,{Q:()=>o});var r=n(6082);async function o(){const t=r.Func.find({package:"Bio",name:"getSeqHelper"});if(0===t.length)throw new Error("Package 'Bio' must be installed for SeqHelper.");return(await t[0].prepare().call()).getOutputParamValue()}},6869:(t,e,n)=>{"use strict";var r;n.d(e,{o:()=>r}),function(t){t.BASE="HELM_BASE",t.SUGAR="HELM_SUGAR",t.LINKER="HELM_LINKER",t.AA="HELM_AA",t.CHEM="HELM_CHEM",t.BLOB="HELM_BLOB",t.NUCLEOTIDE="HELM_NUCLETIDE"}(r||(r={}))},2074:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var r=n(1354),o=n.n(r),i=n(6314),s=n.n(i)()(o());s.push([t.id,".st-colored-text-input > textarea {\n width: 100%;\n color: transparent !important;\n caret-color: var(--grey-6);\n -webkit-text-fill-color: transparent !important;\n background-color: transparent;\n position: relative;\n z-index: 1;\n resize: none;\n height: 22px; /* Fine tuned value to avoid \"jumping\" of the textarea upon autoresize */\n}\n\n.st-colored-text-input > div {\n /* The values here are fine tuned to those of the ui.input textarea in order\n * to achieve precise overlap */\n overflow: auto;\n position: absolute;\n pointer-events: none;\n cursor: text;\n z-index: 0;\n max-width: 100%;\n padding: 2px;\n line-height: normal;\n font-family: 'Roboto', 'Roboto Local', sans-serif;\n font-size: 13px;\n padding-top: 6px !important;\n color: transparent;\n white-space: pre-wrap;\n word-wrap: break-word;\n}\n","",{version:3,sources:["webpack://./src/apps/common/view/components/colored-input/style.css"],names:[],mappings:"AAAA;EACE,WAAW;EACX,6BAA6B;EAC7B,0BAA0B;EAC1B,+CAA+C;EAC/C,6BAA6B;EAC7B,kBAAkB;EAClB,UAAU;EACV,YAAY;EACZ,YAAY,EAAE,wEAAwE;AACxF;;AAEA;EACE;iCAC+B;EAC/B,cAAc;EACd,kBAAkB;EAClB,oBAAoB;EACpB,YAAY;EACZ,UAAU;EACV,eAAe;EACf,YAAY;EACZ,mBAAmB;EACnB,iDAAiD;EACjD,eAAe;EACf,2BAA2B;EAC3B,kBAAkB;EAClB,qBAAqB;EACrB,qBAAqB;AACvB",sourcesContent:[".st-colored-text-input > textarea {\n width: 100%;\n color: transparent !important;\n caret-color: var(--grey-6);\n -webkit-text-fill-color: transparent !important;\n background-color: transparent;\n position: relative;\n z-index: 1;\n resize: none;\n height: 22px; /* Fine tuned value to avoid \"jumping\" of the textarea upon autoresize */\n}\n\n.st-colored-text-input > div {\n /* The values here are fine tuned to those of the ui.input textarea in order\n * to achieve precise overlap */\n overflow: auto;\n position: absolute;\n pointer-events: none;\n cursor: text;\n z-index: 0;\n max-width: 100%;\n padding: 2px;\n line-height: normal;\n font-family: 'Roboto', 'Roboto Local', sans-serif;\n font-size: 13px;\n padding-top: 6px !important;\n color: transparent;\n white-space: pre-wrap;\n word-wrap: break-word;\n}\n"],sourceRoot:""}]);const a=s},9252:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var r=n(1354),o=n.n(r),i=n(6314),s=n.n(i)()(o());s.push([t.id,"/* Naming convention: class names should begin with st and app name to avoid naming collitions */\n\n.st-pattern-text-input > textarea {\n resize: none;\n}\n","",{version:3,sources:["webpack://./src/apps/pattern/view/style.css"],names:[],mappings:"AAAA,gGAAgG;;AAEhG;EACE,YAAY;AACd",sourcesContent:["/* Naming convention: class names should begin with st and app name to avoid naming collitions */\n\n.st-pattern-text-input > textarea {\n resize: none;\n}\n"],sourceRoot:""}]);const a=s},8507:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var r=n(1354),o=n.n(r),i=n(6314),s=n.n(i)()(o());s.push([t.id,"/* Naming convention: class names should begin with st and app name to avoid naming collitions */\n\n.st-structure-body {\n padding-right: 20px;\n height: 100%;\n display: flex;\n flex-direction: column;\n}\n\n.st-structure-mol-img {\n flex: 1 1 0;\n min-height: 100px;\n min-width: 0;\n transform: translateX(-50px);\n overflow: hidden;\n}\n\n.st-structure-mol-img canvas {\n max-width: 100% !important;\n height: auto !important;\n}\n\n.st-structure-bool-button-block {\n justify-content: right;\n margin-bottom: 10px;\n}\n\n.st-structure-bottom {\n flex: 1 1 0;\n padding-top: 20px;\n min-height: 0;\n}\n\n.st-structure-clear-buttons {\n justify-content: space-between;\n padding: 13px 10px 13px 10px;\n}\n\n.st-direction-inputs {\n align-items: end;\n}\n\n.st-structure-inputs {\n flex-grow: 2;\n padding-left: 10px;\n}","",{version:3,sources:["webpack://./src/apps/structure/view/style.css"],names:[],mappings:"AAAA,gGAAgG;;AAEhG;EACE,mBAAmB;EACnB,YAAY;EACZ,aAAa;EACb,sBAAsB;AACxB;;AAEA;EACE,WAAW;EACX,iBAAiB;EACjB,YAAY;EACZ,4BAA4B;EAC5B,gBAAgB;AAClB;;AAEA;EACE,0BAA0B;EAC1B,uBAAuB;AACzB;;AAEA;EACE,sBAAsB;EACtB,mBAAmB;AACrB;;AAEA;EACE,WAAW;EACX,iBAAiB;EACjB,aAAa;AACf;;AAEA;EACE,8BAA8B;EAC9B,4BAA4B;AAC9B;;AAEA;EACE,gBAAgB;AAClB;;AAEA;EACE,YAAY;EACZ,kBAAkB;AACpB",sourcesContent:["/* Naming convention: class names should begin with st and app name to avoid naming collitions */\n\n.st-structure-body {\n padding-right: 20px;\n height: 100%;\n display: flex;\n flex-direction: column;\n}\n\n.st-structure-mol-img {\n flex: 1 1 0;\n min-height: 100px;\n min-width: 0;\n transform: translateX(-50px);\n overflow: hidden;\n}\n\n.st-structure-mol-img canvas {\n max-width: 100% !important;\n height: auto !important;\n}\n\n.st-structure-bool-button-block {\n justify-content: right;\n margin-bottom: 10px;\n}\n\n.st-structure-bottom {\n flex: 1 1 0;\n padding-top: 20px;\n min-height: 0;\n}\n\n.st-structure-clear-buttons {\n justify-content: space-between;\n padding: 13px 10px 13px 10px;\n}\n\n.st-direction-inputs {\n align-items: end;\n}\n\n.st-structure-inputs {\n flex-grow: 2;\n padding-left: 10px;\n}"],sourceRoot:""}]);const a=s},5254:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var r=n(1354),o=n.n(r),i=n(6314),s=n.n(i)()(o());s.push([t.id,"/* Naming convention: class names should begin with st and app name to avoid naming collitions */\n.st-translator-input-table {\n /* width: 100%; */\n margin-right: 20px;\n}\n\n.st-translator-input-table td:has(textarea) {\n width: 100%;\n}\n\n.st-translator-input-table td:has(select) {\n min-width: 120px;\n vertical-align: top;\n}\n\n.st-translator-output-table {\n margin-top: 20px;\n margin-right: 20px;\n margin-bottom: 10px;\n}\n\n.st-translator-output-table table {\n width: 100%;\n table-layout: fixed;\n}\n\n.st-translator-output-table td {\n padding-top: 6px;\n padding-bottom: 6px;\n}\n.st-translator-output-table tr:nth-child(even) {\n background-color: var(--grey-1);\n}\n\n.st-translator-output-table td:nth-child(odd) {\n width: 120px;\n vertical-align: top;\n}\n\n.st-translator-output-table td a {\n overflow-wrap: break-word;\n}\n","",{version:3,sources:["webpack://./src/apps/translator/view/style.css"],names:[],mappings:"AAAA,gGAAgG;AAChG;EACE,iBAAiB;EACjB,kBAAkB;AACpB;;AAEA;EACE,WAAW;AACb;;AAEA;EACE,gBAAgB;EAChB,mBAAmB;AACrB;;AAEA;EACE,gBAAgB;EAChB,kBAAkB;EAClB,mBAAmB;AACrB;;AAEA;EACE,WAAW;EACX,mBAAmB;AACrB;;AAEA;EACE,gBAAgB;EAChB,mBAAmB;AACrB;AACA;EACE,+BAA+B;AACjC;;AAEA;EACE,YAAY;EACZ,mBAAmB;AACrB;;AAEA;EACE,yBAAyB;AAC3B",sourcesContent:["/* Naming convention: class names should begin with st and app name to avoid naming collitions */\n.st-translator-input-table {\n /* width: 100%; */\n margin-right: 20px;\n}\n\n.st-translator-input-table td:has(textarea) {\n width: 100%;\n}\n\n.st-translator-input-table td:has(select) {\n min-width: 120px;\n vertical-align: top;\n}\n\n.st-translator-output-table {\n margin-top: 20px;\n margin-right: 20px;\n margin-bottom: 10px;\n}\n\n.st-translator-output-table table {\n width: 100%;\n table-layout: fixed;\n}\n\n.st-translator-output-table td {\n padding-top: 6px;\n padding-bottom: 6px;\n}\n.st-translator-output-table tr:nth-child(even) {\n background-color: var(--grey-1);\n}\n\n.st-translator-output-table td:nth-child(odd) {\n width: 120px;\n vertical-align: top;\n}\n\n.st-translator-output-table td a {\n overflow-wrap: break-word;\n}\n"],sourceRoot:""}]);const a=s},890:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var r=n(1354),o=n.n(r),i=n(6314),s=n.n(i)()(o());s.push([t.id,".monomer-card-rule-root {\n border: 2px solid var(--grey-2);\n border-radius: 5px;\n padding: 5px;\n margin: 5px;\n overflow: hidden;\n align-items: center;\n cursor: pointer;\n width: 200px;\n height: 240px;\n min-width: 200px;\n min-height: 240px;\n}\n\n.monomer-card-info-rules {\n width: 100%;\n overflow: hidden;\n text-overflow: ellipsis;\n margin-bottom: 10px;\n}\n\n.monomer-card-info-rules > div:nth-child(2) {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.monomer-card-info-rules > div:nth-child(1) {\n font-weight: bold;\n margin-right: 5px;\n text-wrap: nowrap;\n}\n","",{version:3,sources:["webpack://./src/polytool/conversion/style.css"],names:[],mappings:"AAAA;IACI,+BAA+B;IAC/B,kBAAkB;IAClB,YAAY;IACZ,WAAW;IACX,gBAAgB;IAChB,mBAAmB;IACnB,eAAe;IACf,YAAY;IACZ,aAAa;IACb,gBAAgB;IAChB,iBAAiB;AACrB;;AAEA;IACI,WAAW;IACX,gBAAgB;IAChB,uBAAuB;IACvB,mBAAmB;AACvB;;AAEA;IACI,mBAAmB;IACnB,gBAAgB;IAChB,uBAAuB;AAC3B;;AAEA;IACI,iBAAiB;IACjB,iBAAiB;IACjB,iBAAiB;AACrB",sourcesContent:[".monomer-card-rule-root {\n border: 2px solid var(--grey-2);\n border-radius: 5px;\n padding: 5px;\n margin: 5px;\n overflow: hidden;\n align-items: center;\n cursor: pointer;\n width: 200px;\n height: 240px;\n min-width: 200px;\n min-height: 240px;\n}\n\n.monomer-card-info-rules {\n width: 100%;\n overflow: hidden;\n text-overflow: ellipsis;\n margin-bottom: 10px;\n}\n\n.monomer-card-info-rules > div:nth-child(2) {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.monomer-card-info-rules > div:nth-child(1) {\n font-weight: bold;\n margin-right: 5px;\n text-wrap: nowrap;\n}\n"],sourceRoot:""}]);const a=s},6314:t=>{"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var n="",r=void 0!==e[5];return e[4]&&(n+="@supports (".concat(e[4],") {")),e[2]&&(n+="@media ".concat(e[2]," {")),r&&(n+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),n+=t(e),r&&(n+="}"),e[2]&&(n+="}"),e[4]&&(n+="}"),n})).join("")},e.i=function(t,n,r,o,i){"string"==typeof t&&(t=[[null,t,void 0]]);var s={};if(r)for(var a=0;a<this.length;a++){var l=this[a][0];null!=l&&(s[l]=!0)}for(var c=0;c<t.length;c++){var u=[].concat(t[c]);r&&s[u[0]]||(void 0!==i&&(void 0===u[5]||(u[1]="@layer".concat(u[5].length>0?" ".concat(u[5]):""," {").concat(u[1],"}")),u[5]=i),n&&(u[2]?(u[1]="@media ".concat(u[2]," {").concat(u[1],"}"),u[2]=n):u[2]=n),o&&(u[4]?(u[1]="@supports (".concat(u[4],") {").concat(u[1],"}"),u[4]=o):u[4]="".concat(o)),e.push(u))}},e}},1354:t=>{"use strict";t.exports=function(t){var e=t[1],n=t[3];if(!n)return e;if("function"==typeof btoa){var r=btoa(unescape(encodeURIComponent(JSON.stringify(n)))),o="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(r),i="/*# ".concat(o," */");return[e].concat([i]).join("\n")}return[e].join("\n")}},9982:function(t,e,n){var r;!function(){var e={};!function(t){"use strict";t.__esModule=!0,t.digestLength=32,t.blockSize=64;var e=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function n(t,n,r,o,i){for(var s,a,l,c,u,h,d,p,f,m,g,y,b;i>=64;){for(s=n[0],a=n[1],l=n[2],c=n[3],u=n[4],h=n[5],d=n[6],p=n[7],m=0;m<16;m++)g=o+4*m,t[m]=(255&r[g])<<24|(255&r[g+1])<<16|(255&r[g+2])<<8|255&r[g+3];for(m=16;m<64;m++)y=((f=t[m-2])>>>17|f<<15)^(f>>>19|f<<13)^f>>>10,b=((f=t[m-15])>>>7|f<<25)^(f>>>18|f<<14)^f>>>3,t[m]=(y+t[m-7]|0)+(b+t[m-16]|0);for(m=0;m<64;m++)y=(((u>>>6|u<<26)^(u>>>11|u<<21)^(u>>>25|u<<7))+(u&h^~u&d)|0)+(p+(e[m]+t[m]|0)|0)|0,b=((s>>>2|s<<30)^(s>>>13|s<<19)^(s>>>22|s<<10))+(s&a^s&l^a&l)|0,p=d,d=h,h=u,u=c+y|0,c=l,l=a,a=s,s=y+b|0;n[0]+=s,n[1]+=a,n[2]+=l,n[3]+=c,n[4]+=u,n[5]+=h,n[6]+=d,n[7]+=p,o+=64,i-=64}return o}var r=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 r=0;if(this.bytesHashed+=e,this.bufferLength>0){for(;this.bufferLength<64&&e>0;)this.buffer[this.bufferLength++]=t[r++],e--;64===this.bufferLength&&(n(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(e>=64&&(r=n(this.temp,this.state,t,r,e),e%=64);e>0;)this.buffer[this.bufferLength++]=t[r++],e--;return this},e.prototype.finish=function(t){if(!this.finished){var e=this.bytesHashed,r=this.bufferLength,o=e/536870912|0,i=e<<3,s=e%64<56?64:128;this.buffer[r]=128;for(var a=r+1;a<s-8;a++)this.buffer[a]=0;this.buffer[s-8]=o>>>24&255,this.buffer[s-7]=o>>>16&255,this.buffer[s-6]=o>>>8&255,this.buffer[s-5]=o>>>0&255,this.buffer[s-4]=i>>>24&255,this.buffer[s-3]=i>>>16&255,this.buffer[s-2]=i>>>8&255,this.buffer[s-1]=i>>>0&255,n(this.temp,this.state,this.buffer,0,s),this.finished=!0}for(a=0;a<8;a++)t[4*a+0]=this.state[a]>>>24&255,t[4*a+1]=this.state[a]>>>16&255,t[4*a+2]=this.state[a]>>>8&255,t[4*a+3]=this.state[a]>>>0&255;return this},e.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},e.prototype._saveState=function(t){for(var e=0;e<this.state.length;e++)t[e]=this.state[e]},e.prototype._restoreState=function(t,e){for(var n=0;n<this.state.length;n++)this.state[n]=t[n];this.bytesHashed=e,this.finished=!1,this.bufferLength=0},e}();t.Hash=r;var o=function(){function t(t){this.inner=new r,this.outer=new r,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var e=new Uint8Array(this.blockSize);if(t.length>this.blockSize)(new r).update(t).finish(e).clean();else for(var n=0;n<t.length;n++)e[n]=t[n];for(n=0;n<e.length;n++)e[n]^=54;for(this.inner.update(e),n=0;n<e.length;n++)e[n]^=106;for(this.outer.update(e),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate),n=0;n<e.length;n++)e[n]=0}return t.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},t.prototype.clean=function(){for(var t=0;t<this.istate.length;t++)this.ostate[t]=this.istate[t]=0;this.inner.clean(),this.outer.clean()},t.prototype.update=function(t){return this.inner.update(t),this},t.prototype.finish=function(t){return this.outer.finished?this.outer.finish(t):(this.inner.finish(t),this.outer.update(t,this.digestLength).finish(t)),this},t.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},t}();function i(t){var e=(new r).update(t),n=e.digest();return e.clean(),n}function s(t,e){var n=new o(t).update(e),r=n.digest();return n.clean(),r}function a(t,e,n,r){var o=r[0];if(0===o)throw new Error("hkdf: cannot expand more");e.reset(),o>1&&e.update(t),n&&e.update(n),e.update(r),e.finish(t),r[0]++}t.HMAC=o,t.hash=i,t.default=i,t.hmac=s;var l=new Uint8Array(t.digestLength);t.hkdf=function(t,e,n,r){void 0===e&&(e=l),void 0===r&&(r=32);for(var i=new Uint8Array([1]),c=s(e,t),u=new o(c),h=new Uint8Array(u.digestLength),d=h.length,p=new Uint8Array(r),f=0;f<r;f++)d===h.length&&(a(h,u,n,i),d=0),p[f]=h[d++];return u.clean(),h.fill(0),i.fill(0),p},t.pbkdf2=function(t,e,n,r){for(var i=new o(t),s=i.digestLength,a=new Uint8Array(4),l=new Uint8Array(s),c=new Uint8Array(s),u=new Uint8Array(r),h=0;h*s<r;h++){var d=h+1;a[0]=d>>>24&255,a[1]=d>>>16&255,a[2]=d>>>8&255,a[3]=d>>>0&255,i.reset(),i.update(e),i.update(a),i.finish(c);for(var p=0;p<s;p++)l[p]=c[p];for(p=2;p<=n;p++){i.reset(),i.update(c).finish(c);for(var f=0;f<s;f++)l[f]^=c[f]}for(p=0;p<s&&h*s+p<r;p++)u[h*s+p]=l[p]}for(h=0;h<s;h++)l[h]=c[h]=0;for(h=0;h<4;h++)a[h]=0;return i.clean(),u}}(e);var o=e.default;for(var i in e)o[i]=e[i];"object"==typeof t.exports?t.exports=o:void 0===(r=function(){return o}.call(e,n,e,t))||(t.exports=r)}()},2543:function(t,e,n){var r;t=n.nmd(t),function(){var o,i="Expected a function",s="__lodash_hash_undefined__",a="__lodash_placeholder__",l=32,c=128,u=1/0,h=9007199254740991,d=NaN,p=4294967295,f=[["ary",c],["bind",1],["bindKey",2],["curry",8],["curryRight",16],["flip",512],["partial",l],["partialRight",64],["rearg",256]],m="[object Arguments]",g="[object Array]",y="[object Boolean]",b="[object Date]",v="[object Error]",C="[object Function]",x="[object GeneratorFunction]",w="[object Map]",A="[object Number]",T="[object Object]",E="[object Promise]",S="[object RegExp]",I="[object Set]",N="[object String]",_="[object Symbol]",P="[object WeakMap]",M="[object ArrayBuffer]",L="[object DataView]",O="[object Float32Array]",R="[object Float64Array]",D="[object Int8Array]",$="[object Int16Array]",B="[object Int32Array]",F="[object Uint8Array]",k="[object Uint8ClampedArray]",H="[object Uint16Array]",G="[object Uint32Array]",V=/\b__p \+= '';/g,U=/\b(__p \+=) '' \+/g,j=/(__e\(.*?\)|\b__t\)) \+\n'';/g,q=/&(?:amp|lt|gt|quot|#39);/g,W=/[&<>"']/g,z=RegExp(q.source),Y=RegExp(W.source),K=/<%-([\s\S]+?)%>/g,Q=/<%([\s\S]+?)%>/g,J=/<%=([\s\S]+?)%>/g,X=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Z=/^\w*$/,tt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,et=/[\\^$.*+?()[\]{}|]/g,nt=RegExp(et.source),rt=/^\s+/,ot=/\s/,it=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,st=/\{\n\/\* \[wrapped with (.+)\] \*/,at=/,? & /,lt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,ct=/[()=,{}\[\]\/\s]/,ut=/\\(\\)?/g,ht=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,dt=/\w*$/,pt=/^[-+]0x[0-9a-f]+$/i,ft=/^0b[01]+$/i,mt=/^\[object .+?Constructor\]$/,gt=/^0o[0-7]+$/i,yt=/^(?:0|[1-9]\d*)$/,bt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,vt=/($^)/,Ct=/['\n\r\u2028\u2029\\]/g,xt="\\ud800-\\udfff",wt="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",At="\\u2700-\\u27bf",Tt="a-z\\xdf-\\xf6\\xf8-\\xff",Et="A-Z\\xc0-\\xd6\\xd8-\\xde",St="\\ufe0e\\ufe0f",It="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Nt="["+xt+"]",_t="["+It+"]",Pt="["+wt+"]",Mt="\\d+",Lt="["+At+"]",Ot="["+Tt+"]",Rt="[^"+xt+It+Mt+At+Tt+Et+"]",Dt="\\ud83c[\\udffb-\\udfff]",$t="[^"+xt+"]",Bt="(?:\\ud83c[\\udde6-\\uddff]){2}",Ft="[\\ud800-\\udbff][\\udc00-\\udfff]",kt="["+Et+"]",Ht="\\u200d",Gt="(?:"+Ot+"|"+Rt+")",Vt="(?:"+kt+"|"+Rt+")",Ut="(?:['’](?:d|ll|m|re|s|t|ve))?",jt="(?:['’](?:D|LL|M|RE|S|T|VE))?",qt="(?:"+Pt+"|"+Dt+")?",Wt="["+St+"]?",zt=Wt+qt+"(?:"+Ht+"(?:"+[$t,Bt,Ft].join("|")+")"+Wt+qt+")*",Yt="(?:"+[Lt,Bt,Ft].join("|")+")"+zt,Kt="(?:"+[$t+Pt+"?",Pt,Bt,Ft,Nt].join("|")+")",Qt=RegExp("['’]","g"),Jt=RegExp(Pt,"g"),Xt=RegExp(Dt+"(?="+Dt+")|"+Kt+zt,"g"),Zt=RegExp([kt+"?"+Ot+"+"+Ut+"(?="+[_t,kt,"$"].join("|")+")",Vt+"+"+jt+"(?="+[_t,kt+Gt,"$"].join("|")+")",kt+"?"+Gt+"+"+Ut,kt+"+"+jt,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Mt,Yt].join("|"),"g"),te=RegExp("["+Ht+xt+wt+St+"]"),ee=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,ne=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],re=-1,oe={};oe[O]=oe[R]=oe[D]=oe[$]=oe[B]=oe[F]=oe[k]=oe[H]=oe[G]=!0,oe[m]=oe[g]=oe[M]=oe[y]=oe[L]=oe[b]=oe[v]=oe[C]=oe[w]=oe[A]=oe[T]=oe[S]=oe[I]=oe[N]=oe[P]=!1;var ie={};ie[m]=ie[g]=ie[M]=ie[L]=ie[y]=ie[b]=ie[O]=ie[R]=ie[D]=ie[$]=ie[B]=ie[w]=ie[A]=ie[T]=ie[S]=ie[I]=ie[N]=ie[_]=ie[F]=ie[k]=ie[H]=ie[G]=!0,ie[v]=ie[C]=ie[P]=!1;var se={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},ae=parseFloat,le=parseInt,ce="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,ue="object"==typeof self&&self&&self.Object===Object&&self,he=ce||ue||Function("return this")(),de=e&&!e.nodeType&&e,pe=de&&t&&!t.nodeType&&t,fe=pe&&pe.exports===de,me=fe&&ce.process,ge=function(){try{return pe&&pe.require&&pe.require("util").types||me&&me.binding&&me.binding("util")}catch(t){}}(),ye=ge&&ge.isArrayBuffer,be=ge&&ge.isDate,ve=ge&&ge.isMap,Ce=ge&&ge.isRegExp,xe=ge&&ge.isSet,we=ge&&ge.isTypedArray;function Ae(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}function Te(t,e,n,r){for(var o=-1,i=null==t?0:t.length;++o<i;){var s=t[o];e(r,s,n(s),t)}return r}function Ee(t,e){for(var n=-1,r=null==t?0:t.length;++n<r&&!1!==e(t[n],n,t););return t}function Se(t,e){for(var n=null==t?0:t.length;n--&&!1!==e(t[n],n,t););return t}function Ie(t,e){for(var n=-1,r=null==t?0:t.length;++n<r;)if(!e(t[n],n,t))return!1;return!0}function Ne(t,e){for(var n=-1,r=null==t?0:t.length,o=0,i=[];++n<r;){var s=t[n];e(s,n,t)&&(i[o++]=s)}return i}function _e(t,e){return!(null==t||!t.length)&&ke(t,e,0)>-1}function Pe(t,e,n){for(var r=-1,o=null==t?0:t.length;++r<o;)if(n(e,t[r]))return!0;return!1}function Me(t,e){for(var n=-1,r=null==t?0:t.length,o=Array(r);++n<r;)o[n]=e(t[n],n,t);return o}function Le(t,e){for(var n=-1,r=e.length,o=t.length;++n<r;)t[o+n]=e[n];return t}function Oe(t,e,n,r){var o=-1,i=null==t?0:t.length;for(r&&i&&(n=t[++o]);++o<i;)n=e(n,t[o],o,t);return n}function Re(t,e,n,r){var o=null==t?0:t.length;for(r&&o&&(n=t[--o]);o--;)n=e(n,t[o],o,t);return n}function De(t,e){for(var n=-1,r=null==t?0:t.length;++n<r;)if(e(t[n],n,t))return!0;return!1}var $e=Ue("length");function Be(t,e,n){var r;return n(t,(function(t,n,o){if(e(t,n,o))return r=n,!1})),r}function Fe(t,e,n,r){for(var o=t.length,i=n+(r?1:-1);r?i--:++i<o;)if(e(t[i],i,t))return i;return-1}function ke(t,e,n){return e==e?function(t,e,n){for(var r=n-1,o=t.length;++r<o;)if(t[r]===e)return r;return-1}(t,e,n):Fe(t,Ge,n)}function He(t,e,n,r){for(var o=n-1,i=t.length;++o<i;)if(r(t[o],e))return o;return-1}function Ge(t){return t!=t}function Ve(t,e){var n=null==t?0:t.length;return n?We(t,e)/n:d}function Ue(t){return function(e){return null==e?o:e[t]}}function je(t){return function(e){return null==t?o:t[e]}}function qe(t,e,n,r,o){return o(t,(function(t,o,i){n=r?(r=!1,t):e(n,t,o,i)})),n}function We(t,e){for(var n,r=-1,i=t.length;++r<i;){var s=e(t[r]);s!==o&&(n=n===o?s:n+s)}return n}function ze(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}function Ye(t){return t?t.slice(0,dn(t)+1).replace(rt,""):t}function Ke(t){return function(e){return t(e)}}function Qe(t,e){return Me(e,(function(e){return t[e]}))}function Je(t,e){return t.has(e)}function Xe(t,e){for(var n=-1,r=t.length;++n<r&&ke(e,t[n],0)>-1;);return n}function Ze(t,e){for(var n=t.length;n--&&ke(e,t[n],0)>-1;);return n}var tn=je({À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"}),en=je({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"});function nn(t){return"\\"+se[t]}function rn(t){return te.test(t)}function on(t){var e=-1,n=Array(t.size);return t.forEach((function(t,r){n[++e]=[r,t]})),n}function sn(t,e){return function(n){return t(e(n))}}function an(t,e){for(var n=-1,r=t.length,o=0,i=[];++n<r;){var s=t[n];s!==e&&s!==a||(t[n]=a,i[o++]=n)}return i}function ln(t){var e=-1,n=Array(t.size);return t.forEach((function(t){n[++e]=t})),n}function cn(t){var e=-1,n=Array(t.size);return t.forEach((function(t){n[++e]=[t,t]})),n}function un(t){return rn(t)?function(t){for(var e=Xt.lastIndex=0;Xt.test(t);)++e;return e}(t):$e(t)}function hn(t){return rn(t)?function(t){return t.match(Xt)||[]}(t):function(t){return t.split("")}(t)}function dn(t){for(var e=t.length;e--&&ot.test(t.charAt(e)););return e}var pn=je({"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"}),fn=function t(e){var n,r=(e=null==e?he:fn.defaults(he.Object(),e,fn.pick(he,ne))).Array,ot=e.Date,xt=e.Error,wt=e.Function,At=e.Math,Tt=e.Object,Et=e.RegExp,St=e.String,It=e.TypeError,Nt=r.prototype,_t=wt.prototype,Pt=Tt.prototype,Mt=e["__core-js_shared__"],Lt=_t.toString,Ot=Pt.hasOwnProperty,Rt=0,Dt=(n=/[^.]+$/.exec(Mt&&Mt.keys&&Mt.keys.IE_PROTO||""))?"Symbol(src)_1."+n:"",$t=Pt.toString,Bt=Lt.call(Tt),Ft=he._,kt=Et("^"+Lt.call(Ot).replace(et,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ht=fe?e.Buffer:o,Gt=e.Symbol,Vt=e.Uint8Array,Ut=Ht?Ht.allocUnsafe:o,jt=sn(Tt.getPrototypeOf,Tt),qt=Tt.create,Wt=Pt.propertyIsEnumerable,zt=Nt.splice,Yt=Gt?Gt.isConcatSpreadable:o,Kt=Gt?Gt.iterator:o,Xt=Gt?Gt.toStringTag:o,te=function(){try{var t=ci(Tt,"defineProperty");return t({},"",{}),t}catch(t){}}(),se=e.clearTimeout!==he.clearTimeout&&e.clearTimeout,ce=ot&&ot.now!==he.Date.now&&ot.now,ue=e.setTimeout!==he.setTimeout&&e.setTimeout,de=At.ceil,pe=At.floor,me=Tt.getOwnPropertySymbols,ge=Ht?Ht.isBuffer:o,$e=e.isFinite,je=Nt.join,mn=sn(Tt.keys,Tt),gn=At.max,yn=At.min,bn=ot.now,vn=e.parseInt,Cn=At.random,xn=Nt.reverse,wn=ci(e,"DataView"),An=ci(e,"Map"),Tn=ci(e,"Promise"),En=ci(e,"Set"),Sn=ci(e,"WeakMap"),In=ci(Tt,"create"),Nn=Sn&&new Sn,_n={},Pn=Bi(wn),Mn=Bi(An),Ln=Bi(Tn),On=Bi(En),Rn=Bi(Sn),Dn=Gt?Gt.prototype:o,$n=Dn?Dn.valueOf:o,Bn=Dn?Dn.toString:o;function Fn(t){if(ta(t)&&!Us(t)&&!(t instanceof Vn)){if(t instanceof Gn)return t;if(Ot.call(t,"__wrapped__"))return Fi(t)}return new Gn(t)}var kn=function(){function t(){}return function(e){if(!Zs(e))return{};if(qt)return qt(e);t.prototype=e;var n=new t;return t.prototype=o,n}}();function Hn(){}function Gn(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=o}function Vn(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=p,this.__views__=[]}function Un(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function jn(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function qn(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function Wn(t){var e=-1,n=null==t?0:t.length;for(this.__data__=new qn;++e<n;)this.add(t[e])}function zn(t){var e=this.__data__=new jn(t);this.size=e.size}function Yn(t,e){var n=Us(t),r=!n&&Vs(t),o=!n&&!r&&zs(t),i=!n&&!r&&!o&&la(t),s=n||r||o||i,a=s?ze(t.length,St):[],l=a.length;for(var c in t)!e&&!Ot.call(t,c)||s&&("length"==c||o&&("offset"==c||"parent"==c)||i&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||gi(c,l))||a.push(c);return a}function Kn(t){var e=t.length;return e?t[qr(0,e-1)]:o}function Qn(t,e){return Li(Io(t),ir(e,0,t.length))}function Jn(t){return Li(Io(t))}function Xn(t,e,n){(n!==o&&!ks(t[e],n)||n===o&&!(e in t))&&rr(t,e,n)}function Zn(t,e,n){var r=t[e];Ot.call(t,e)&&ks(r,n)&&(n!==o||e in t)||rr(t,e,n)}function tr(t,e){for(var n=t.length;n--;)if(ks(t[n][0],e))return n;return-1}function er(t,e,n,r){return ur(t,(function(t,o,i){e(r,t,n(t),i)})),r}function nr(t,e){return t&&No(e,Pa(e),t)}function rr(t,e,n){"__proto__"==e&&te?te(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}function or(t,e){for(var n=-1,i=e.length,s=r(i),a=null==t;++n<i;)s[n]=a?o:Ea(t,e[n]);return s}function ir(t,e,n){return t==t&&(n!==o&&(t=t<=n?t:n),e!==o&&(t=t>=e?t:e)),t}function sr(t,e,n,r,i,s){var a,l=1&e,c=2&e,u=4&e;if(n&&(a=i?n(t,r,i,s):n(t)),a!==o)return a;if(!Zs(t))return t;var h=Us(t);if(h){if(a=function(t){var e=t.length,n=new t.constructor(e);return e&&"string"==typeof t[0]&&Ot.call(t,"index")&&(n.index=t.index,n.input=t.input),n}(t),!l)return Io(t,a)}else{var d=di(t),p=d==C||d==x;if(zs(t))return xo(t,l);if(d==T||d==m||p&&!i){if(a=c||p?{}:fi(t),!l)return c?function(t,e){return No(t,hi(t),e)}(t,function(t,e){return t&&No(e,Ma(e),t)}(a,t)):function(t,e){return No(t,ui(t),e)}(t,nr(a,t))}else{if(!ie[d])return i?t:{};a=function(t,e,n){var r,o=t.constructor;switch(e){case M:return wo(t);case y:case b:return new o(+t);case L:return function(t,e){var n=e?wo(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}(t,n);case O:case R:case D:case $:case B:case F:case k:case H:case G:return Ao(t,n);case w:return new o;case A:case N:return new o(t);case S:return function(t){var e=new t.constructor(t.source,dt.exec(t));return e.lastIndex=t.lastIndex,e}(t);case I:return new o;case _:return r=t,$n?Tt($n.call(r)):{}}}(t,d,l)}}s||(s=new zn);var f=s.get(t);if(f)return f;s.set(t,a),ia(t)?t.forEach((function(r){a.add(sr(r,e,n,r,t,s))})):ea(t)&&t.forEach((function(r,o){a.set(o,sr(r,e,n,o,t,s))}));var g=h?o:(u?c?ni:ei:c?Ma:Pa)(t);return Ee(g||t,(function(r,o){g&&(r=t[o=r]),Zn(a,o,sr(r,e,n,o,t,s))})),a}function ar(t,e,n){var r=n.length;if(null==t)return!r;for(t=Tt(t);r--;){var i=n[r],s=e[i],a=t[i];if(a===o&&!(i in t)||!s(a))return!1}return!0}function lr(t,e,n){if("function"!=typeof t)throw new It(i);return Ni((function(){t.apply(o,n)}),e)}function cr(t,e,n,r){var o=-1,i=_e,s=!0,a=t.length,l=[],c=e.length;if(!a)return l;n&&(e=Me(e,Ke(n))),r?(i=Pe,s=!1):e.length>=200&&(i=Je,s=!1,e=new Wn(e));t:for(;++o<a;){var u=t[o],h=null==n?u:n(u);if(u=r||0!==u?u:0,s&&h==h){for(var d=c;d--;)if(e[d]===h)continue t;l.push(u)}else i(e,h,r)||l.push(u)}return l}Fn.templateSettings={escape:K,evaluate:Q,interpolate:J,variable:"",imports:{_:Fn}},Fn.prototype=Hn.prototype,Fn.prototype.constructor=Fn,Gn.prototype=kn(Hn.prototype),Gn.prototype.constructor=Gn,Vn.prototype=kn(Hn.prototype),Vn.prototype.constructor=Vn,Un.prototype.clear=function(){this.__data__=In?In(null):{},this.size=0},Un.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},Un.prototype.get=function(t){var e=this.__data__;if(In){var n=e[t];return n===s?o:n}return Ot.call(e,t)?e[t]:o},Un.prototype.has=function(t){var e=this.__data__;return In?e[t]!==o:Ot.call(e,t)},Un.prototype.set=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=In&&e===o?s:e,this},jn.prototype.clear=function(){this.__data__=[],this.size=0},jn.prototype.delete=function(t){var e=this.__data__,n=tr(e,t);return!(n<0||(n==e.length-1?e.pop():zt.call(e,n,1),--this.size,0))},jn.prototype.get=function(t){var e=this.__data__,n=tr(e,t);return n<0?o:e[n][1]},jn.prototype.has=function(t){return tr(this.__data__,t)>-1},jn.prototype.set=function(t,e){var n=this.__data__,r=tr(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this},qn.prototype.clear=function(){this.size=0,this.__data__={hash:new Un,map:new(An||jn),string:new Un}},qn.prototype.delete=function(t){var e=ai(this,t).delete(t);return this.size-=e?1:0,e},qn.prototype.get=function(t){return ai(this,t).get(t)},qn.prototype.has=function(t){return ai(this,t).has(t)},qn.prototype.set=function(t,e){var n=ai(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this},Wn.prototype.add=Wn.prototype.push=function(t){return this.__data__.set(t,s),this},Wn.prototype.has=function(t){return this.__data__.has(t)},zn.prototype.clear=function(){this.__data__=new jn,this.size=0},zn.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},zn.prototype.get=function(t){return this.__data__.get(t)},zn.prototype.has=function(t){return this.__data__.has(t)},zn.prototype.set=function(t,e){var n=this.__data__;if(n instanceof jn){var r=n.__data__;if(!An||r.length<199)return r.push([t,e]),this.size=++n.size,this;n=this.__data__=new qn(r)}return n.set(t,e),this.size=n.size,this};var ur=Mo(br),hr=Mo(vr,!0);function dr(t,e){var n=!0;return ur(t,(function(t,r,o){return n=!!e(t,r,o)})),n}function pr(t,e,n){for(var r=-1,i=t.length;++r<i;){var s=t[r],a=e(s);if(null!=a&&(l===o?a==a&&!aa(a):n(a,l)))var l=a,c=s}return c}function fr(t,e){var n=[];return ur(t,(function(t,r,o){e(t,r,o)&&n.push(t)})),n}function mr(t,e,n,r,o){var i=-1,s=t.length;for(n||(n=mi),o||(o=[]);++i<s;){var a=t[i];e>0&&n(a)?e>1?mr(a,e-1,n,r,o):Le(o,a):r||(o[o.length]=a)}return o}var gr=Lo(),yr=Lo(!0);function br(t,e){return t&&gr(t,e,Pa)}function vr(t,e){return t&&yr(t,e,Pa)}function Cr(t,e){return Ne(e,(function(e){return Qs(t[e])}))}function xr(t,e){for(var n=0,r=(e=yo(e,t)).length;null!=t&&n<r;)t=t[$i(e[n++])];return n&&n==r?t:o}function wr(t,e,n){var r=e(t);return Us(t)?r:Le(r,n(t))}function Ar(t){return null==t?t===o?"[object Undefined]":"[object Null]":Xt&&Xt in Tt(t)?function(t){var e=Ot.call(t,Xt),n=t[Xt];try{t[Xt]=o;var r=!0}catch(t){}var i=$t.call(t);return r&&(e?t[Xt]=n:delete t[Xt]),i}(t):function(t){return $t.call(t)}(t)}function Tr(t,e){return t>e}function Er(t,e){return null!=t&&Ot.call(t,e)}function Sr(t,e){return null!=t&&e in Tt(t)}function Ir(t,e,n){for(var i=n?Pe:_e,s=t[0].length,a=t.length,l=a,c=r(a),u=1/0,h=[];l--;){var d=t[l];l&&e&&(d=Me(d,Ke(e))),u=yn(d.length,u),c[l]=!n&&(e||s>=120&&d.length>=120)?new Wn(l&&d):o}d=t[0];var p=-1,f=c[0];t:for(;++p<s&&h.length<u;){var m=d[p],g=e?e(m):m;if(m=n||0!==m?m:0,!(f?Je(f,g):i(h,g,n))){for(l=a;--l;){var y=c[l];if(!(y?Je(y,g):i(t[l],g,n)))continue t}f&&f.push(g),h.push(m)}}return h}function Nr(t,e,n){var r=null==(t=Ei(t,e=yo(e,t)))?t:t[$i(Ki(e))];return null==r?o:Ae(r,t,n)}function _r(t){return ta(t)&&Ar(t)==m}function Pr(t,e,n,r,i){return t===e||(null==t||null==e||!ta(t)&&!ta(e)?t!=t&&e!=e:function(t,e,n,r,i,s){var a=Us(t),l=Us(e),c=a?g:di(t),u=l?g:di(e),h=(c=c==m?T:c)==T,d=(u=u==m?T:u)==T,p=c==u;if(p&&zs(t)){if(!zs(e))return!1;a=!0,h=!1}if(p&&!h)return s||(s=new zn),a||la(t)?Zo(t,e,n,r,i,s):function(t,e,n,r,o,i,s){switch(n){case L:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case M:return!(t.byteLength!=e.byteLength||!i(new Vt(t),new Vt(e)));case y:case b:case A:return ks(+t,+e);case v:return t.name==e.name&&t.message==e.message;case S:case N:return t==e+"";case w:var a=on;case I:var l=1&r;if(a||(a=ln),t.size!=e.size&&!l)return!1;var c=s.get(t);if(c)return c==e;r|=2,s.set(t,e);var u=Zo(a(t),a(e),r,o,i,s);return s.delete(t),u;case _:if($n)return $n.call(t)==$n.call(e)}return!1}(t,e,c,n,r,i,s);if(!(1&n)){var f=h&&Ot.call(t,"__wrapped__"),C=d&&Ot.call(e,"__wrapped__");if(f||C){var x=f?t.value():t,E=C?e.value():e;return s||(s=new zn),i(x,E,n,r,s)}}return!!p&&(s||(s=new zn),function(t,e,n,r,i,s){var a=1&n,l=ei(t),c=l.length;if(c!=ei(e).length&&!a)return!1;for(var u=c;u--;){var h=l[u];if(!(a?h in e:Ot.call(e,h)))return!1}var d=s.get(t),p=s.get(e);if(d&&p)return d==e&&p==t;var f=!0;s.set(t,e),s.set(e,t);for(var m=a;++u<c;){var g=t[h=l[u]],y=e[h];if(r)var b=a?r(y,g,h,e,t,s):r(g,y,h,t,e,s);if(!(b===o?g===y||i(g,y,n,r,s):b)){f=!1;break}m||(m="constructor"==h)}if(f&&!m){var v=t.constructor,C=e.constructor;v==C||!("constructor"in t)||!("constructor"in e)||"function"==typeof v&&v instanceof v&&"function"==typeof C&&C instanceof C||(f=!1)}return s.delete(t),s.delete(e),f}(t,e,n,r,i,s))}(t,e,n,r,Pr,i))}function Mr(t,e,n,r){var i=n.length,s=i,a=!r;if(null==t)return!s;for(t=Tt(t);i--;){var l=n[i];if(a&&l[2]?l[1]!==t[l[0]]:!(l[0]in t))return!1}for(;++i<s;){var c=(l=n[i])[0],u=t[c],h=l[1];if(a&&l[2]){if(u===o&&!(c in t))return!1}else{var d=new zn;if(r)var p=r(u,h,c,t,e,d);if(!(p===o?Pr(h,u,3,r,d):p))return!1}}return!0}function Lr(t){return!(!Zs(t)||(e=t,Dt&&Dt in e))&&(Qs(t)?kt:mt).test(Bi(t));var e}function Or(t){return"function"==typeof t?t:null==t?nl:"object"==typeof t?Us(t)?Fr(t[0],t[1]):Br(t):hl(t)}function Rr(t){if(!xi(t))return mn(t);var e=[];for(var n in Tt(t))Ot.call(t,n)&&"constructor"!=n&&e.push(n);return e}function Dr(t,e){return t<e}function $r(t,e){var n=-1,o=qs(t)?r(t.length):[];return ur(t,(function(t,r,i){o[++n]=e(t,r,i)})),o}function Br(t){var e=li(t);return 1==e.length&&e[0][2]?Ai(e[0][0],e[0][1]):function(n){return n===t||Mr(n,t,e)}}function Fr(t,e){return bi(t)&&wi(e)?Ai($i(t),e):function(n){var r=Ea(n,t);return r===o&&r===e?Sa(n,t):Pr(e,r,3)}}function kr(t,e,n,r,i){t!==e&&gr(e,(function(s,a){if(i||(i=new zn),Zs(s))!function(t,e,n,r,i,s,a){var l=Si(t,n),c=Si(e,n),u=a.get(c);if(u)Xn(t,n,u);else{var h=s?s(l,c,n+"",t,e,a):o,d=h===o;if(d){var p=Us(c),f=!p&&zs(c),m=!p&&!f&&la(c);h=c,p||f||m?Us(l)?h=l:Ws(l)?h=Io(l):f?(d=!1,h=xo(c,!0)):m?(d=!1,h=Ao(c,!0)):h=[]:ra(c)||Vs(c)?(h=l,Vs(l)?h=ga(l):Zs(l)&&!Qs(l)||(h=fi(c))):d=!1}d&&(a.set(c,h),i(h,c,r,s,a),a.delete(c)),Xn(t,n,h)}}(t,e,a,n,kr,r,i);else{var l=r?r(Si(t,a),s,a+"",t,e,i):o;l===o&&(l=s),Xn(t,a,l)}}),Ma)}function Hr(t,e){var n=t.length;if(n)return gi(e+=e<0?n:0,n)?t[e]:o}function Gr(t,e,n){e=e.length?Me(e,(function(t){return Us(t)?function(e){return xr(e,1===t.length?t[0]:t)}:t})):[nl];var r=-1;e=Me(e,Ke(si()));var o=$r(t,(function(t,n,o){var i=Me(e,(function(e){return e(t)}));return{criteria:i,index:++r,value:t}}));return function(t){var e=t.length;for(t.sort((function(t,e){return function(t,e,n){for(var r=-1,o=t.criteria,i=e.criteria,s=o.length,a=n.length;++r<s;){var l=To(o[r],i[r]);if(l)return r>=a?l:l*("desc"==n[r]?-1:1)}return t.index-e.index}(t,e,n)}));e--;)t[e]=t[e].value;return t}(o)}function Vr(t,e,n){for(var r=-1,o=e.length,i={};++r<o;){var s=e[r],a=xr(t,s);n(a,s)&&Qr(i,yo(s,t),a)}return i}function Ur(t,e,n,r){var o=r?He:ke,i=-1,s=e.length,a=t;for(t===e&&(e=Io(e)),n&&(a=Me(t,Ke(n)));++i<s;)for(var l=0,c=e[i],u=n?n(c):c;(l=o(a,u,l,r))>-1;)a!==t&&zt.call(a,l,1),zt.call(t,l,1);return t}function jr(t,e){for(var n=t?e.length:0,r=n-1;n--;){var o=e[n];if(n==r||o!==i){var i=o;gi(o)?zt.call(t,o,1):lo(t,o)}}return t}function qr(t,e){return t+pe(Cn()*(e-t+1))}function Wr(t,e){var n="";if(!t||e<1||e>h)return n;do{e%2&&(n+=t),(e=pe(e/2))&&(t+=t)}while(e);return n}function zr(t,e){return _i(Ti(t,e,nl),t+"")}function Yr(t){return Kn(ka(t))}function Kr(t,e){var n=ka(t);return Li(n,ir(e,0,n.length))}function Qr(t,e,n,r){if(!Zs(t))return t;for(var i=-1,s=(e=yo(e,t)).length,a=s-1,l=t;null!=l&&++i<s;){var c=$i(e[i]),u=n;if("__proto__"===c||"constructor"===c||"prototype"===c)return t;if(i!=a){var h=l[c];(u=r?r(h,c,l):o)===o&&(u=Zs(h)?h:gi(e[i+1])?[]:{})}Zn(l,c,u),l=l[c]}return t}var Jr=Nn?function(t,e){return Nn.set(t,e),t}:nl,Xr=te?function(t,e){return te(t,"toString",{configurable:!0,enumerable:!1,value:Za(e),writable:!0})}:nl;function Zr(t){return Li(ka(t))}function to(t,e,n){var o=-1,i=t.length;e<0&&(e=-e>i?0:i+e),(n=n>i?i:n)<0&&(n+=i),i=e>n?0:n-e>>>0,e>>>=0;for(var s=r(i);++o<i;)s[o]=t[o+e];return s}function eo(t,e){var n;return ur(t,(function(t,r,o){return!(n=e(t,r,o))})),!!n}function no(t,e,n){var r=0,o=null==t?r:t.length;if("number"==typeof e&&e==e&&o<=2147483647){for(;r<o;){var i=r+o>>>1,s=t[i];null!==s&&!aa(s)&&(n?s<=e:s<e)?r=i+1:o=i}return o}return ro(t,e,nl,n)}function ro(t,e,n,r){var i=0,s=null==t?0:t.length;if(0===s)return 0;for(var a=(e=n(e))!=e,l=null===e,c=aa(e),u=e===o;i<s;){var h=pe((i+s)/2),d=n(t[h]),p=d!==o,f=null===d,m=d==d,g=aa(d);if(a)var y=r||m;else y=u?m&&(r||p):l?m&&p&&(r||!f):c?m&&p&&!f&&(r||!g):!f&&!g&&(r?d<=e:d<e);y?i=h+1:s=h}return yn(s,4294967294)}function oo(t,e){for(var n=-1,r=t.length,o=0,i=[];++n<r;){var s=t[n],a=e?e(s):s;if(!n||!ks(a,l)){var l=a;i[o++]=0===s?0:s}}return i}function io(t){return"number"==typeof t?t:aa(t)?d:+t}function so(t){if("string"==typeof t)return t;if(Us(t))return Me(t,so)+"";if(aa(t))return Bn?Bn.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function ao(t,e,n){var r=-1,o=_e,i=t.length,s=!0,a=[],l=a;if(n)s=!1,o=Pe;else if(i>=200){var c=e?null:zo(t);if(c)return ln(c);s=!1,o=Je,l=new Wn}else l=e?[]:a;t:for(;++r<i;){var u=t[r],h=e?e(u):u;if(u=n||0!==u?u:0,s&&h==h){for(var d=l.length;d--;)if(l[d]===h)continue t;e&&l.push(h),a.push(u)}else o(l,h,n)||(l!==a&&l.push(h),a.push(u))}return a}function lo(t,e){return null==(t=Ei(t,e=yo(e,t)))||delete t[$i(Ki(e))]}function co(t,e,n,r){return Qr(t,e,n(xr(t,e)),r)}function uo(t,e,n,r){for(var o=t.length,i=r?o:-1;(r?i--:++i<o)&&e(t[i],i,t););return n?to(t,r?0:i,r?i+1:o):to(t,r?i+1:0,r?o:i)}function ho(t,e){var n=t;return n instanceof Vn&&(n=n.value()),Oe(e,(function(t,e){return e.func.apply(e.thisArg,Le([t],e.args))}),n)}function po(t,e,n){var o=t.length;if(o<2)return o?ao(t[0]):[];for(var i=-1,s=r(o);++i<o;)for(var a=t[i],l=-1;++l<o;)l!=i&&(s[i]=cr(s[i]||a,t[l],e,n));return ao(mr(s,1),e,n)}function fo(t,e,n){for(var r=-1,i=t.length,s=e.length,a={};++r<i;){var l=r<s?e[r]:o;n(a,t[r],l)}return a}function mo(t){return Ws(t)?t:[]}function go(t){return"function"==typeof t?t:nl}function yo(t,e){return Us(t)?t:bi(t,e)?[t]:Di(ya(t))}var bo=zr;function vo(t,e,n){var r=t.length;return n=n===o?r:n,!e&&n>=r?t:to(t,e,n)}var Co=se||function(t){return he.clearTimeout(t)};function xo(t,e){if(e)return t.slice();var n=t.length,r=Ut?Ut(n):new t.constructor(n);return t.copy(r),r}function wo(t){var e=new t.constructor(t.byteLength);return new Vt(e).set(new Vt(t)),e}function Ao(t,e){var n=e?wo(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}function To(t,e){if(t!==e){var n=t!==o,r=null===t,i=t==t,s=aa(t),a=e!==o,l=null===e,c=e==e,u=aa(e);if(!l&&!u&&!s&&t>e||s&&a&&c&&!l&&!u||r&&a&&c||!n&&c||!i)return 1;if(!r&&!s&&!u&&t<e||u&&n&&i&&!r&&!s||l&&n&&i||!a&&i||!c)return-1}return 0}function Eo(t,e,n,o){for(var i=-1,s=t.length,a=n.length,l=-1,c=e.length,u=gn(s-a,0),h=r(c+u),d=!o;++l<c;)h[l]=e[l];for(;++i<a;)(d||i<s)&&(h[n[i]]=t[i]);for(;u--;)h[l++]=t[i++];return h}function So(t,e,n,o){for(var i=-1,s=t.length,a=-1,l=n.length,c=-1,u=e.length,h=gn(s-l,0),d=r(h+u),p=!o;++i<h;)d[i]=t[i];for(var f=i;++c<u;)d[f+c]=e[c];for(;++a<l;)(p||i<s)&&(d[f+n[a]]=t[i++]);return d}function Io(t,e){var n=-1,o=t.length;for(e||(e=r(o));++n<o;)e[n]=t[n];return e}function No(t,e,n,r){var i=!n;n||(n={});for(var s=-1,a=e.length;++s<a;){var l=e[s],c=r?r(n[l],t[l],l,n,t):o;c===o&&(c=t[l]),i?rr(n,l,c):Zn(n,l,c)}return n}function _o(t,e){return function(n,r){var o=Us(n)?Te:er,i=e?e():{};return o(n,t,si(r,2),i)}}function Po(t){return zr((function(e,n){var r=-1,i=n.length,s=i>1?n[i-1]:o,a=i>2?n[2]:o;for(s=t.length>3&&"function"==typeof s?(i--,s):o,a&&yi(n[0],n[1],a)&&(s=i<3?o:s,i=1),e=Tt(e);++r<i;){var l=n[r];l&&t(e,l,r,s)}return e}))}function Mo(t,e){return function(n,r){if(null==n)return n;if(!qs(n))return t(n,r);for(var o=n.length,i=e?o:-1,s=Tt(n);(e?i--:++i<o)&&!1!==r(s[i],i,s););return n}}function Lo(t){return function(e,n,r){for(var o=-1,i=Tt(e),s=r(e),a=s.length;a--;){var l=s[t?a:++o];if(!1===n(i[l],l,i))break}return e}}function Oo(t){return function(e){var n=rn(e=ya(e))?hn(e):o,r=n?n[0]:e.charAt(0),i=n?vo(n,1).join(""):e.slice(1);return r[t]()+i}}function Ro(t){return function(e){return Oe(Qa(Va(e).replace(Qt,"")),t,"")}}function Do(t){return function(){var e=arguments;switch(e.length){case 0:return new t;case 1:return new t(e[0]);case 2:return new t(e[0],e[1]);case 3:return new t(e[0],e[1],e[2]);case 4:return new t(e[0],e[1],e[2],e[3]);case 5:return new t(e[0],e[1],e[2],e[3],e[4]);case 6:return new t(e[0],e[1],e[2],e[3],e[4],e[5]);case 7:return new t(e[0],e[1],e[2],e[3],e[4],e[5],e[6])}var n=kn(t.prototype),r=t.apply(n,e);return Zs(r)?r:n}}function $o(t){return function(e,n,r){var i=Tt(e);if(!qs(e)){var s=si(n,3);e=Pa(e),n=function(t){return s(i[t],t,i)}}var a=t(e,n,r);return a>-1?i[s?e[a]:a]:o}}function Bo(t){return ti((function(e){var n=e.length,r=n,s=Gn.prototype.thru;for(t&&e.reverse();r--;){var a=e[r];if("function"!=typeof a)throw new It(i);if(s&&!l&&"wrapper"==oi(a))var l=new Gn([],!0)}for(r=l?r:n;++r<n;){var c=oi(a=e[r]),u="wrapper"==c?ri(a):o;l=u&&vi(u[0])&&424==u[1]&&!u[4].length&&1==u[9]?l[oi(u[0])].apply(l,u[3]):1==a.length&&vi(a)?l[c]():l.thru(a)}return function(){var t=arguments,r=t[0];if(l&&1==t.length&&Us(r))return l.plant(r).value();for(var o=0,i=n?e[o].apply(this,t):r;++o<n;)i=e[o].call(this,i);return i}}))}function Fo(t,e,n,i,s,a,l,u,h,d){var p=e&c,f=1&e,m=2&e,g=24&e,y=512&e,b=m?o:Do(t);return function c(){for(var v=arguments.length,C=r(v),x=v;x--;)C[x]=arguments[x];if(g)var w=ii(c),A=function(t,e){for(var n=t.length,r=0;n--;)t[n]===e&&++r;return r}(C,w);if(i&&(C=Eo(C,i,s,g)),a&&(C=So(C,a,l,g)),v-=A,g&&v<d){var T=an(C,w);return qo(t,e,Fo,c.placeholder,n,C,T,u,h,d-v)}var E=f?n:this,S=m?E[t]:t;return v=C.length,u?C=function(t,e){for(var n=t.length,r=yn(e.length,n),i=Io(t);r--;){var s=e[r];t[r]=gi(s,n)?i[s]:o}return t}(C,u):y&&v>1&&C.reverse(),p&&h<v&&(C.length=h),this&&this!==he&&this instanceof c&&(S=b||Do(S)),S.apply(E,C)}}function ko(t,e){return function(n,r){return function(t,e,n,r){return br(t,(function(t,o,i){e(r,n(t),o,i)})),r}(n,t,e(r),{})}}function Ho(t,e){return function(n,r){var i;if(n===o&&r===o)return e;if(n!==o&&(i=n),r!==o){if(i===o)return r;"string"==typeof n||"string"==typeof r?(n=so(n),r=so(r)):(n=io(n),r=io(r)),i=t(n,r)}return i}}function Go(t){return ti((function(e){return e=Me(e,Ke(si())),zr((function(n){var r=this;return t(e,(function(t){return Ae(t,r,n)}))}))}))}function Vo(t,e){var n=(e=e===o?" ":so(e)).length;if(n<2)return n?Wr(e,t):e;var r=Wr(e,de(t/un(e)));return rn(e)?vo(hn(r),0,t).join(""):r.slice(0,t)}function Uo(t){return function(e,n,i){return i&&"number"!=typeof i&&yi(e,n,i)&&(n=i=o),e=da(e),n===o?(n=e,e=0):n=da(n),function(t,e,n,o){for(var i=-1,s=gn(de((e-t)/(n||1)),0),a=r(s);s--;)a[o?s:++i]=t,t+=n;return a}(e,n,i=i===o?e<n?1:-1:da(i),t)}}function jo(t){return function(e,n){return"string"==typeof e&&"string"==typeof n||(e=ma(e),n=ma(n)),t(e,n)}}function qo(t,e,n,r,i,s,a,c,u,h){var d=8&e;e|=d?l:64,4&(e&=~(d?64:l))||(e&=-4);var p=[t,e,i,d?s:o,d?a:o,d?o:s,d?o:a,c,u,h],f=n.apply(o,p);return vi(t)&&Ii(f,p),f.placeholder=r,Pi(f,t,e)}function Wo(t){var e=At[t];return function(t,n){if(t=ma(t),(n=null==n?0:yn(pa(n),292))&&$e(t)){var r=(ya(t)+"e").split("e");return+((r=(ya(e(r[0]+"e"+(+r[1]+n)))+"e").split("e"))[0]+"e"+(+r[1]-n))}return e(t)}}var zo=En&&1/ln(new En([,-0]))[1]==u?function(t){return new En(t)}:al;function Yo(t){return function(e){var n=di(e);return n==w?on(e):n==I?cn(e):function(t,e){return Me(e,(function(e){return[e,t[e]]}))}(e,t(e))}}function Ko(t,e,n,s,u,h,d,p){var f=2&e;if(!f&&"function"!=typeof t)throw new It(i);var m=s?s.length:0;if(m||(e&=-97,s=u=o),d=d===o?d:gn(pa(d),0),p=p===o?p:pa(p),m-=u?u.length:0,64&e){var g=s,y=u;s=u=o}var b=f?o:ri(t),v=[t,e,n,s,u,g,y,h,d,p];if(b&&function(t,e){var n=t[1],r=e[1],o=n|r,i=o<131,s=r==c&&8==n||r==c&&256==n&&t[7].length<=e[8]||384==r&&e[7].length<=e[8]&&8==n;if(!i&&!s)return t;1&r&&(t[2]=e[2],o|=1&n?0:4);var l=e[3];if(l){var u=t[3];t[3]=u?Eo(u,l,e[4]):l,t[4]=u?an(t[3],a):e[4]}(l=e[5])&&(u=t[5],t[5]=u?So(u,l,e[6]):l,t[6]=u?an(t[5],a):e[6]),(l=e[7])&&(t[7]=l),r&c&&(t[8]=null==t[8]?e[8]:yn(t[8],e[8])),null==t[9]&&(t[9]=e[9]),t[0]=e[0],t[1]=o}(v,b),t=v[0],e=v[1],n=v[2],s=v[3],u=v[4],!(p=v[9]=v[9]===o?f?0:t.length:gn(v[9]-m,0))&&24&e&&(e&=-25),e&&1!=e)C=8==e||16==e?function(t,e,n){var i=Do(t);return function s(){for(var a=arguments.length,l=r(a),c=a,u=ii(s);c--;)l[c]=arguments[c];var h=a<3&&l[0]!==u&&l[a-1]!==u?[]:an(l,u);return(a-=h.length)<n?qo(t,e,Fo,s.placeholder,o,l,h,o,o,n-a):Ae(this&&this!==he&&this instanceof s?i:t,this,l)}}(t,e,p):e!=l&&33!=e||u.length?Fo.apply(o,v):function(t,e,n,o){var i=1&e,s=Do(t);return function e(){for(var a=-1,l=arguments.length,c=-1,u=o.length,h=r(u+l),d=this&&this!==he&&this instanceof e?s:t;++c<u;)h[c]=o[c];for(;l--;)h[c++]=arguments[++a];return Ae(d,i?n:this,h)}}(t,e,n,s);else var C=function(t,e,n){var r=1&e,o=Do(t);return function e(){return(this&&this!==he&&this instanceof e?o:t).apply(r?n:this,arguments)}}(t,e,n);return Pi((b?Jr:Ii)(C,v),t,e)}function Qo(t,e,n,r){return t===o||ks(t,Pt[n])&&!Ot.call(r,n)?e:t}function Jo(t,e,n,r,i,s){return Zs(t)&&Zs(e)&&(s.set(e,t),kr(t,e,o,Jo,s),s.delete(e)),t}function Xo(t){return ra(t)?o:t}function Zo(t,e,n,r,i,s){var a=1&n,l=t.length,c=e.length;if(l!=c&&!(a&&c>l))return!1;var u=s.get(t),h=s.get(e);if(u&&h)return u==e&&h==t;var d=-1,p=!0,f=2&n?new Wn:o;for(s.set(t,e),s.set(e,t);++d<l;){var m=t[d],g=e[d];if(r)var y=a?r(g,m,d,e,t,s):r(m,g,d,t,e,s);if(y!==o){if(y)continue;p=!1;break}if(f){if(!De(e,(function(t,e){if(!Je(f,e)&&(m===t||i(m,t,n,r,s)))return f.push(e)}))){p=!1;break}}else if(m!==g&&!i(m,g,n,r,s)){p=!1;break}}return s.delete(t),s.delete(e),p}function ti(t){return _i(Ti(t,o,ji),t+"")}function ei(t){return wr(t,Pa,ui)}function ni(t){return wr(t,Ma,hi)}var ri=Nn?function(t){return Nn.get(t)}:al;function oi(t){for(var e=t.name+"",n=_n[e],r=Ot.call(_n,e)?n.length:0;r--;){var o=n[r],i=o.func;if(null==i||i==t)return o.name}return e}function ii(t){return(Ot.call(Fn,"placeholder")?Fn:t).placeholder}function si(){var t=Fn.iteratee||rl;return t=t===rl?Or:t,arguments.length?t(arguments[0],arguments[1]):t}function ai(t,e){var n,r,o=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof e?"string":"hash"]:o.map}function li(t){for(var e=Pa(t),n=e.length;n--;){var r=e[n],o=t[r];e[n]=[r,o,wi(o)]}return e}function ci(t,e){var n=function(t,e){return null==t?o:t[e]}(t,e);return Lr(n)?n:o}var ui=me?function(t){return null==t?[]:(t=Tt(t),Ne(me(t),(function(e){return Wt.call(t,e)})))}:fl,hi=me?function(t){for(var e=[];t;)Le(e,ui(t)),t=jt(t);return e}:fl,di=Ar;function pi(t,e,n){for(var r=-1,o=(e=yo(e,t)).length,i=!1;++r<o;){var s=$i(e[r]);if(!(i=null!=t&&n(t,s)))break;t=t[s]}return i||++r!=o?i:!!(o=null==t?0:t.length)&&Xs(o)&&gi(s,o)&&(Us(t)||Vs(t))}function fi(t){return"function"!=typeof t.constructor||xi(t)?{}:kn(jt(t))}function mi(t){return Us(t)||Vs(t)||!!(Yt&&t&&t[Yt])}function gi(t,e){var n=typeof t;return!!(e=null==e?h:e)&&("number"==n||"symbol"!=n&&yt.test(t))&&t>-1&&t%1==0&&t<e}function yi(t,e,n){if(!Zs(n))return!1;var r=typeof e;return!!("number"==r?qs(n)&&gi(e,n.length):"string"==r&&e in n)&&ks(n[e],t)}function bi(t,e){if(Us(t))return!1;var n=typeof t;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=t&&!aa(t))||Z.test(t)||!X.test(t)||null!=e&&t in Tt(e)}function vi(t){var e=oi(t),n=Fn[e];if("function"!=typeof n||!(e in Vn.prototype))return!1;if(t===n)return!0;var r=ri(n);return!!r&&t===r[0]}(wn&&di(new wn(new ArrayBuffer(1)))!=L||An&&di(new An)!=w||Tn&&di(Tn.resolve())!=E||En&&di(new En)!=I||Sn&&di(new Sn)!=P)&&(di=function(t){var e=Ar(t),n=e==T?t.constructor:o,r=n?Bi(n):"";if(r)switch(r){case Pn:return L;case Mn:return w;case Ln:return E;case On:return I;case Rn:return P}return e});var Ci=Mt?Qs:ml;function xi(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Pt)}function wi(t){return t==t&&!Zs(t)}function Ai(t,e){return function(n){return null!=n&&n[t]===e&&(e!==o||t in Tt(n))}}function Ti(t,e,n){return e=gn(e===o?t.length-1:e,0),function(){for(var o=arguments,i=-1,s=gn(o.length-e,0),a=r(s);++i<s;)a[i]=o[e+i];i=-1;for(var l=r(e+1);++i<e;)l[i]=o[i];return l[e]=n(a),Ae(t,this,l)}}function Ei(t,e){return e.length<2?t:xr(t,to(e,0,-1))}function Si(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var Ii=Mi(Jr),Ni=ue||function(t,e){return he.setTimeout(t,e)},_i=Mi(Xr);function Pi(t,e,n){var r=e+"";return _i(t,function(t,e){var n=e.length;if(!n)return t;var r=n-1;return e[r]=(n>1?"& ":"")+e[r],e=e.join(n>2?", ":" "),t.replace(it,"{\n/* [wrapped with "+e+"] */\n")}(r,function(t,e){return Ee(f,(function(n){var r="_."+n[0];e&n[1]&&!_e(t,r)&&t.push(r)})),t.sort()}(function(t){var e=t.match(st);return e?e[1].split(at):[]}(r),n)))}function Mi(t){var e=0,n=0;return function(){var r=bn(),i=16-(r-n);if(n=r,i>0){if(++e>=800)return arguments[0]}else e=0;return t.apply(o,arguments)}}function Li(t,e){var n=-1,r=t.length,i=r-1;for(e=e===o?r:e;++n<e;){var s=qr(n,i),a=t[s];t[s]=t[n],t[n]=a}return t.length=e,t}var Oi,Ri,Di=(Oi=Os((function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(tt,(function(t,n,r,o){e.push(r?o.replace(ut,"$1"):n||t)})),e}),(function(t){return 500===Ri.size&&Ri.clear(),t})),Ri=Oi.cache,Oi);function $i(t){if("string"==typeof t||aa(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function Bi(t){if(null!=t){try{return Lt.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function Fi(t){if(t instanceof Vn)return t.clone();var e=new Gn(t.__wrapped__,t.__chain__);return e.__actions__=Io(t.__actions__),e.__index__=t.__index__,e.__values__=t.__values__,e}var ki=zr((function(t,e){return Ws(t)?cr(t,mr(e,1,Ws,!0)):[]})),Hi=zr((function(t,e){var n=Ki(e);return Ws(n)&&(n=o),Ws(t)?cr(t,mr(e,1,Ws,!0),si(n,2)):[]})),Gi=zr((function(t,e){var n=Ki(e);return Ws(n)&&(n=o),Ws(t)?cr(t,mr(e,1,Ws,!0),o,n):[]}));function Vi(t,e,n){var r=null==t?0:t.length;if(!r)return-1;var o=null==n?0:pa(n);return o<0&&(o=gn(r+o,0)),Fe(t,si(e,3),o)}function Ui(t,e,n){var r=null==t?0:t.length;if(!r)return-1;var i=r-1;return n!==o&&(i=pa(n),i=n<0?gn(r+i,0):yn(i,r-1)),Fe(t,si(e,3),i,!0)}function ji(t){return null!=t&&t.length?mr(t,1):[]}function qi(t){return t&&t.length?t[0]:o}var Wi=zr((function(t){var e=Me(t,mo);return e.length&&e[0]===t[0]?Ir(e):[]})),zi=zr((function(t){var e=Ki(t),n=Me(t,mo);return e===Ki(n)?e=o:n.pop(),n.length&&n[0]===t[0]?Ir(n,si(e,2)):[]})),Yi=zr((function(t){var e=Ki(t),n=Me(t,mo);return(e="function"==typeof e?e:o)&&n.pop(),n.length&&n[0]===t[0]?Ir(n,o,e):[]}));function Ki(t){var e=null==t?0:t.length;return e?t[e-1]:o}var Qi=zr(Ji);function Ji(t,e){return t&&t.length&&e&&e.length?Ur(t,e):t}var Xi=ti((function(t,e){var n=null==t?0:t.length,r=or(t,e);return jr(t,Me(e,(function(t){return gi(t,n)?+t:t})).sort(To)),r}));function Zi(t){return null==t?t:xn.call(t)}var ts=zr((function(t){return ao(mr(t,1,Ws,!0))})),es=zr((function(t){var e=Ki(t);return Ws(e)&&(e=o),ao(mr(t,1,Ws,!0),si(e,2))})),ns=zr((function(t){var e=Ki(t);return e="function"==typeof e?e:o,ao(mr(t,1,Ws,!0),o,e)}));function rs(t){if(!t||!t.length)return[];var e=0;return t=Ne(t,(function(t){if(Ws(t))return e=gn(t.length,e),!0})),ze(e,(function(e){return Me(t,Ue(e))}))}function os(t,e){if(!t||!t.length)return[];var n=rs(t);return null==e?n:Me(n,(function(t){return Ae(e,o,t)}))}var is=zr((function(t,e){return Ws(t)?cr(t,e):[]})),ss=zr((function(t){return po(Ne(t,Ws))})),as=zr((function(t){var e=Ki(t);return Ws(e)&&(e=o),po(Ne(t,Ws),si(e,2))})),ls=zr((function(t){var e=Ki(t);return e="function"==typeof e?e:o,po(Ne(t,Ws),o,e)})),cs=zr(rs),us=zr((function(t){var e=t.length,n=e>1?t[e-1]:o;return n="function"==typeof n?(t.pop(),n):o,os(t,n)}));function hs(t){var e=Fn(t);return e.__chain__=!0,e}function ds(t,e){return e(t)}var ps=ti((function(t){var e=t.length,n=e?t[0]:0,r=this.__wrapped__,i=function(e){return or(e,t)};return!(e>1||this.__actions__.length)&&r instanceof Vn&&gi(n)?((r=r.slice(n,+n+(e?1:0))).__actions__.push({func:ds,args:[i],thisArg:o}),new Gn(r,this.__chain__).thru((function(t){return e&&!t.length&&t.push(o),t}))):this.thru(i)})),fs=_o((function(t,e,n){Ot.call(t,n)?++t[n]:rr(t,n,1)})),ms=$o(Vi),gs=$o(Ui);function ys(t,e){return(Us(t)?Ee:ur)(t,si(e,3))}function bs(t,e){return(Us(t)?Se:hr)(t,si(e,3))}var vs=_o((function(t,e,n){Ot.call(t,n)?t[n].push(e):rr(t,n,[e])})),Cs=zr((function(t,e,n){var o=-1,i="function"==typeof e,s=qs(t)?r(t.length):[];return ur(t,(function(t){s[++o]=i?Ae(e,t,n):Nr(t,e,n)})),s})),xs=_o((function(t,e,n){rr(t,n,e)}));function ws(t,e){return(Us(t)?Me:$r)(t,si(e,3))}var As=_o((function(t,e,n){t[n?0:1].push(e)}),(function(){return[[],[]]})),Ts=zr((function(t,e){if(null==t)return[];var n=e.length;return n>1&&yi(t,e[0],e[1])?e=[]:n>2&&yi(e[0],e[1],e[2])&&(e=[e[0]]),Gr(t,mr(e,1),[])})),Es=ce||function(){return he.Date.now()};function Ss(t,e,n){return e=n?o:e,e=t&&null==e?t.length:e,Ko(t,c,o,o,o,o,e)}function Is(t,e){var n;if("function"!=typeof e)throw new It(i);return t=pa(t),function(){return--t>0&&(n=e.apply(this,arguments)),t<=1&&(e=o),n}}var Ns=zr((function(t,e,n){var r=1;if(n.length){var o=an(n,ii(Ns));r|=l}return Ko(t,r,e,n,o)})),_s=zr((function(t,e,n){var r=3;if(n.length){var o=an(n,ii(_s));r|=l}return Ko(e,r,t,n,o)}));function Ps(t,e,n){var r,s,a,l,c,u,h=0,d=!1,p=!1,f=!0;if("function"!=typeof t)throw new It(i);function m(e){var n=r,i=s;return r=s=o,h=e,l=t.apply(i,n)}function g(t){var n=t-u;return u===o||n>=e||n<0||p&&t-h>=a}function y(){var t=Es();if(g(t))return b(t);c=Ni(y,function(t){var n=e-(t-u);return p?yn(n,a-(t-h)):n}(t))}function b(t){return c=o,f&&r?m(t):(r=s=o,l)}function v(){var t=Es(),n=g(t);if(r=arguments,s=this,u=t,n){if(c===o)return function(t){return h=t,c=Ni(y,e),d?m(t):l}(u);if(p)return Co(c),c=Ni(y,e),m(u)}return c===o&&(c=Ni(y,e)),l}return e=ma(e)||0,Zs(n)&&(d=!!n.leading,a=(p="maxWait"in n)?gn(ma(n.maxWait)||0,e):a,f="trailing"in n?!!n.trailing:f),v.cancel=function(){c!==o&&Co(c),h=0,r=u=s=c=o},v.flush=function(){return c===o?l:b(Es())},v}var Ms=zr((function(t,e){return lr(t,1,e)})),Ls=zr((function(t,e,n){return lr(t,ma(e)||0,n)}));function Os(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new It(i);var n=function(){var r=arguments,o=e?e.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var s=t.apply(this,r);return n.cache=i.set(o,s)||i,s};return n.cache=new(Os.Cache||qn),n}function Rs(t){if("function"!=typeof t)throw new It(i);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}Os.Cache=qn;var Ds=bo((function(t,e){var n=(e=1==e.length&&Us(e[0])?Me(e[0],Ke(si())):Me(mr(e,1),Ke(si()))).length;return zr((function(r){for(var o=-1,i=yn(r.length,n);++o<i;)r[o]=e[o].call(this,r[o]);return Ae(t,this,r)}))})),$s=zr((function(t,e){var n=an(e,ii($s));return Ko(t,l,o,e,n)})),Bs=zr((function(t,e){var n=an(e,ii(Bs));return Ko(t,64,o,e,n)})),Fs=ti((function(t,e){return Ko(t,256,o,o,o,e)}));function ks(t,e){return t===e||t!=t&&e!=e}var Hs=jo(Tr),Gs=jo((function(t,e){return t>=e})),Vs=_r(function(){return arguments}())?_r:function(t){return ta(t)&&Ot.call(t,"callee")&&!Wt.call(t,"callee")},Us=r.isArray,js=ye?Ke(ye):function(t){return ta(t)&&Ar(t)==M};function qs(t){return null!=t&&Xs(t.length)&&!Qs(t)}function Ws(t){return ta(t)&&qs(t)}var zs=ge||ml,Ys=be?Ke(be):function(t){return ta(t)&&Ar(t)==b};function Ks(t){if(!ta(t))return!1;var e=Ar(t);return e==v||"[object DOMException]"==e||"string"==typeof t.message&&"string"==typeof t.name&&!ra(t)}function Qs(t){if(!Zs(t))return!1;var e=Ar(t);return e==C||e==x||"[object AsyncFunction]"==e||"[object Proxy]"==e}function Js(t){return"number"==typeof t&&t==pa(t)}function Xs(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=h}function Zs(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function ta(t){return null!=t&&"object"==typeof t}var ea=ve?Ke(ve):function(t){return ta(t)&&di(t)==w};function na(t){return"number"==typeof t||ta(t)&&Ar(t)==A}function ra(t){if(!ta(t)||Ar(t)!=T)return!1;var e=jt(t);if(null===e)return!0;var n=Ot.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&Lt.call(n)==Bt}var oa=Ce?Ke(Ce):function(t){return ta(t)&&Ar(t)==S},ia=xe?Ke(xe):function(t){return ta(t)&&di(t)==I};function sa(t){return"string"==typeof t||!Us(t)&&ta(t)&&Ar(t)==N}function aa(t){return"symbol"==typeof t||ta(t)&&Ar(t)==_}var la=we?Ke(we):function(t){return ta(t)&&Xs(t.length)&&!!oe[Ar(t)]},ca=jo(Dr),ua=jo((function(t,e){return t<=e}));function ha(t){if(!t)return[];if(qs(t))return sa(t)?hn(t):Io(t);if(Kt&&t[Kt])return function(t){for(var e,n=[];!(e=t.next()).done;)n.push(e.value);return n}(t[Kt]());var e=di(t);return(e==w?on:e==I?ln:ka)(t)}function da(t){return t?(t=ma(t))===u||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}function pa(t){var e=da(t),n=e%1;return e==e?n?e-n:e:0}function fa(t){return t?ir(pa(t),0,p):0}function ma(t){if("number"==typeof t)return t;if(aa(t))return d;if(Zs(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=Zs(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=Ye(t);var n=ft.test(t);return n||gt.test(t)?le(t.slice(2),n?2:8):pt.test(t)?d:+t}function ga(t){return No(t,Ma(t))}function ya(t){return null==t?"":so(t)}var ba=Po((function(t,e){if(xi(e)||qs(e))No(e,Pa(e),t);else for(var n in e)Ot.call(e,n)&&Zn(t,n,e[n])})),va=Po((function(t,e){No(e,Ma(e),t)})),Ca=Po((function(t,e,n,r){No(e,Ma(e),t,r)})),xa=Po((function(t,e,n,r){No(e,Pa(e),t,r)})),wa=ti(or),Aa=zr((function(t,e){t=Tt(t);var n=-1,r=e.length,i=r>2?e[2]:o;for(i&&yi(e[0],e[1],i)&&(r=1);++n<r;)for(var s=e[n],a=Ma(s),l=-1,c=a.length;++l<c;){var u=a[l],h=t[u];(h===o||ks(h,Pt[u])&&!Ot.call(t,u))&&(t[u]=s[u])}return t})),Ta=zr((function(t){return t.push(o,Jo),Ae(Oa,o,t)}));function Ea(t,e,n){var r=null==t?o:xr(t,e);return r===o?n:r}function Sa(t,e){return null!=t&&pi(t,e,Sr)}var Ia=ko((function(t,e,n){null!=e&&"function"!=typeof e.toString&&(e=$t.call(e)),t[e]=n}),Za(nl)),Na=ko((function(t,e,n){null!=e&&"function"!=typeof e.toString&&(e=$t.call(e)),Ot.call(t,e)?t[e].push(n):t[e]=[n]}),si),_a=zr(Nr);function Pa(t){return qs(t)?Yn(t):Rr(t)}function Ma(t){return qs(t)?Yn(t,!0):function(t){if(!Zs(t))return function(t){var e=[];if(null!=t)for(var n in Tt(t))e.push(n);return e}(t);var e=xi(t),n=[];for(var r in t)("constructor"!=r||!e&&Ot.call(t,r))&&n.push(r);return n}(t)}var La=Po((function(t,e,n){kr(t,e,n)})),Oa=Po((function(t,e,n,r){kr(t,e,n,r)})),Ra=ti((function(t,e){var n={};if(null==t)return n;var r=!1;e=Me(e,(function(e){return e=yo(e,t),r||(r=e.length>1),e})),No(t,ni(t),n),r&&(n=sr(n,7,Xo));for(var o=e.length;o--;)lo(n,e[o]);return n})),Da=ti((function(t,e){return null==t?{}:function(t,e){return Vr(t,e,(function(e,n){return Sa(t,n)}))}(t,e)}));function $a(t,e){if(null==t)return{};var n=Me(ni(t),(function(t){return[t]}));return e=si(e),Vr(t,n,(function(t,n){return e(t,n[0])}))}var Ba=Yo(Pa),Fa=Yo(Ma);function ka(t){return null==t?[]:Qe(t,Pa(t))}var Ha=Ro((function(t,e,n){return e=e.toLowerCase(),t+(n?Ga(e):e)}));function Ga(t){return Ka(ya(t).toLowerCase())}function Va(t){return(t=ya(t))&&t.replace(bt,tn).replace(Jt,"")}var Ua=Ro((function(t,e,n){return t+(n?"-":"")+e.toLowerCase()})),ja=Ro((function(t,e,n){return t+(n?" ":"")+e.toLowerCase()})),qa=Oo("toLowerCase"),Wa=Ro((function(t,e,n){return t+(n?"_":"")+e.toLowerCase()})),za=Ro((function(t,e,n){return t+(n?" ":"")+Ka(e)})),Ya=Ro((function(t,e,n){return t+(n?" ":"")+e.toUpperCase()})),Ka=Oo("toUpperCase");function Qa(t,e,n){return t=ya(t),(e=n?o:e)===o?function(t){return ee.test(t)}(t)?function(t){return t.match(Zt)||[]}(t):function(t){return t.match(lt)||[]}(t):t.match(e)||[]}var Ja=zr((function(t,e){try{return Ae(t,o,e)}catch(t){return Ks(t)?t:new xt(t)}})),Xa=ti((function(t,e){return Ee(e,(function(e){e=$i(e),rr(t,e,Ns(t[e],t))})),t}));function Za(t){return function(){return t}}var tl=Bo(),el=Bo(!0);function nl(t){return t}function rl(t){return Or("function"==typeof t?t:sr(t,1))}var ol=zr((function(t,e){return function(n){return Nr(n,t,e)}})),il=zr((function(t,e){return function(n){return Nr(t,n,e)}}));function sl(t,e,n){var r=Pa(e),o=Cr(e,r);null!=n||Zs(e)&&(o.length||!r.length)||(n=e,e=t,t=this,o=Cr(e,Pa(e)));var i=!(Zs(n)&&"chain"in n&&!n.chain),s=Qs(t);return Ee(o,(function(n){var r=e[n];t[n]=r,s&&(t.prototype[n]=function(){var e=this.__chain__;if(i||e){var n=t(this.__wrapped__);return(n.__actions__=Io(this.__actions__)).push({func:r,args:arguments,thisArg:t}),n.__chain__=e,n}return r.apply(t,Le([this.value()],arguments))})})),t}function al(){}var ll=Go(Me),cl=Go(Ie),ul=Go(De);function hl(t){return bi(t)?Ue($i(t)):function(t){return function(e){return xr(e,t)}}(t)}var dl=Uo(),pl=Uo(!0);function fl(){return[]}function ml(){return!1}var gl,yl=Ho((function(t,e){return t+e}),0),bl=Wo("ceil"),vl=Ho((function(t,e){return t/e}),1),Cl=Wo("floor"),xl=Ho((function(t,e){return t*e}),1),wl=Wo("round"),Al=Ho((function(t,e){return t-e}),0);return Fn.after=function(t,e){if("function"!=typeof e)throw new It(i);return t=pa(t),function(){if(--t<1)return e.apply(this,arguments)}},Fn.ary=Ss,Fn.assign=ba,Fn.assignIn=va,Fn.assignInWith=Ca,Fn.assignWith=xa,Fn.at=wa,Fn.before=Is,Fn.bind=Ns,Fn.bindAll=Xa,Fn.bindKey=_s,Fn.castArray=function(){if(!arguments.length)return[];var t=arguments[0];return Us(t)?t:[t]},Fn.chain=hs,Fn.chunk=function(t,e,n){e=(n?yi(t,e,n):e===o)?1:gn(pa(e),0);var i=null==t?0:t.length;if(!i||e<1)return[];for(var s=0,a=0,l=r(de(i/e));s<i;)l[a++]=to(t,s,s+=e);return l},Fn.compact=function(t){for(var e=-1,n=null==t?0:t.length,r=0,o=[];++e<n;){var i=t[e];i&&(o[r++]=i)}return o},Fn.concat=function(){var t=arguments.length;if(!t)return[];for(var e=r(t-1),n=arguments[0],o=t;o--;)e[o-1]=arguments[o];return Le(Us(n)?Io(n):[n],mr(e,1))},Fn.cond=function(t){var e=null==t?0:t.length,n=si();return t=e?Me(t,(function(t){if("function"!=typeof t[1])throw new It(i);return[n(t[0]),t[1]]})):[],zr((function(n){for(var r=-1;++r<e;){var o=t[r];if(Ae(o[0],this,n))return Ae(o[1],this,n)}}))},Fn.conforms=function(t){return function(t){var e=Pa(t);return function(n){return ar(n,t,e)}}(sr(t,1))},Fn.constant=Za,Fn.countBy=fs,Fn.create=function(t,e){var n=kn(t);return null==e?n:nr(n,e)},Fn.curry=function t(e,n,r){var i=Ko(e,8,o,o,o,o,o,n=r?o:n);return i.placeholder=t.placeholder,i},Fn.curryRight=function t(e,n,r){var i=Ko(e,16,o,o,o,o,o,n=r?o:n);return i.placeholder=t.placeholder,i},Fn.debounce=Ps,Fn.defaults=Aa,Fn.defaultsDeep=Ta,Fn.defer=Ms,Fn.delay=Ls,Fn.difference=ki,Fn.differenceBy=Hi,Fn.differenceWith=Gi,Fn.drop=function(t,e,n){var r=null==t?0:t.length;return r?to(t,(e=n||e===o?1:pa(e))<0?0:e,r):[]},Fn.dropRight=function(t,e,n){var r=null==t?0:t.length;return r?to(t,0,(e=r-(e=n||e===o?1:pa(e)))<0?0:e):[]},Fn.dropRightWhile=function(t,e){return t&&t.length?uo(t,si(e,3),!0,!0):[]},Fn.dropWhile=function(t,e){return t&&t.length?uo(t,si(e,3),!0):[]},Fn.fill=function(t,e,n,r){var i=null==t?0:t.length;return i?(n&&"number"!=typeof n&&yi(t,e,n)&&(n=0,r=i),function(t,e,n,r){var i=t.length;for((n=pa(n))<0&&(n=-n>i?0:i+n),(r=r===o||r>i?i:pa(r))<0&&(r+=i),r=n>r?0:fa(r);n<r;)t[n++]=e;return t}(t,e,n,r)):[]},Fn.filter=function(t,e){return(Us(t)?Ne:fr)(t,si(e,3))},Fn.flatMap=function(t,e){return mr(ws(t,e),1)},Fn.flatMapDeep=function(t,e){return mr(ws(t,e),u)},Fn.flatMapDepth=function(t,e,n){return n=n===o?1:pa(n),mr(ws(t,e),n)},Fn.flatten=ji,Fn.flattenDeep=function(t){return null!=t&&t.length?mr(t,u):[]},Fn.flattenDepth=function(t,e){return null!=t&&t.length?mr(t,e=e===o?1:pa(e)):[]},Fn.flip=function(t){return Ko(t,512)},Fn.flow=tl,Fn.flowRight=el,Fn.fromPairs=function(t){for(var e=-1,n=null==t?0:t.length,r={};++e<n;){var o=t[e];r[o[0]]=o[1]}return r},Fn.functions=function(t){return null==t?[]:Cr(t,Pa(t))},Fn.functionsIn=function(t){return null==t?[]:Cr(t,Ma(t))},Fn.groupBy=vs,Fn.initial=function(t){return null!=t&&t.length?to(t,0,-1):[]},Fn.intersection=Wi,Fn.intersectionBy=zi,Fn.intersectionWith=Yi,Fn.invert=Ia,Fn.invertBy=Na,Fn.invokeMap=Cs,Fn.iteratee=rl,Fn.keyBy=xs,Fn.keys=Pa,Fn.keysIn=Ma,Fn.map=ws,Fn.mapKeys=function(t,e){var n={};return e=si(e,3),br(t,(function(t,r,o){rr(n,e(t,r,o),t)})),n},Fn.mapValues=function(t,e){var n={};return e=si(e,3),br(t,(function(t,r,o){rr(n,r,e(t,r,o))})),n},Fn.matches=function(t){return Br(sr(t,1))},Fn.matchesProperty=function(t,e){return Fr(t,sr(e,1))},Fn.memoize=Os,Fn.merge=La,Fn.mergeWith=Oa,Fn.method=ol,Fn.methodOf=il,Fn.mixin=sl,Fn.negate=Rs,Fn.nthArg=function(t){return t=pa(t),zr((function(e){return Hr(e,t)}))},Fn.omit=Ra,Fn.omitBy=function(t,e){return $a(t,Rs(si(e)))},Fn.once=function(t){return Is(2,t)},Fn.orderBy=function(t,e,n,r){return null==t?[]:(Us(e)||(e=null==e?[]:[e]),Us(n=r?o:n)||(n=null==n?[]:[n]),Gr(t,e,n))},Fn.over=ll,Fn.overArgs=Ds,Fn.overEvery=cl,Fn.overSome=ul,Fn.partial=$s,Fn.partialRight=Bs,Fn.partition=As,Fn.pick=Da,Fn.pickBy=$a,Fn.property=hl,Fn.propertyOf=function(t){return function(e){return null==t?o:xr(t,e)}},Fn.pull=Qi,Fn.pullAll=Ji,Fn.pullAllBy=function(t,e,n){return t&&t.length&&e&&e.length?Ur(t,e,si(n,2)):t},Fn.pullAllWith=function(t,e,n){return t&&t.length&&e&&e.length?Ur(t,e,o,n):t},Fn.pullAt=Xi,Fn.range=dl,Fn.rangeRight=pl,Fn.rearg=Fs,Fn.reject=function(t,e){return(Us(t)?Ne:fr)(t,Rs(si(e,3)))},Fn.remove=function(t,e){var n=[];if(!t||!t.length)return n;var r=-1,o=[],i=t.length;for(e=si(e,3);++r<i;){var s=t[r];e(s,r,t)&&(n.push(s),o.push(r))}return jr(t,o),n},Fn.rest=function(t,e){if("function"!=typeof t)throw new It(i);return zr(t,e=e===o?e:pa(e))},Fn.reverse=Zi,Fn.sampleSize=function(t,e,n){return e=(n?yi(t,e,n):e===o)?1:pa(e),(Us(t)?Qn:Kr)(t,e)},Fn.set=function(t,e,n){return null==t?t:Qr(t,e,n)},Fn.setWith=function(t,e,n,r){return r="function"==typeof r?r:o,null==t?t:Qr(t,e,n,r)},Fn.shuffle=function(t){return(Us(t)?Jn:Zr)(t)},Fn.slice=function(t,e,n){var r=null==t?0:t.length;return r?(n&&"number"!=typeof n&&yi(t,e,n)?(e=0,n=r):(e=null==e?0:pa(e),n=n===o?r:pa(n)),to(t,e,n)):[]},Fn.sortBy=Ts,Fn.sortedUniq=function(t){return t&&t.length?oo(t):[]},Fn.sortedUniqBy=function(t,e){return t&&t.length?oo(t,si(e,2)):[]},Fn.split=function(t,e,n){return n&&"number"!=typeof n&&yi(t,e,n)&&(e=n=o),(n=n===o?p:n>>>0)?(t=ya(t))&&("string"==typeof e||null!=e&&!oa(e))&&!(e=so(e))&&rn(t)?vo(hn(t),0,n):t.split(e,n):[]},Fn.spread=function(t,e){if("function"!=typeof t)throw new It(i);return e=null==e?0:gn(pa(e),0),zr((function(n){var r=n[e],o=vo(n,0,e);return r&&Le(o,r),Ae(t,this,o)}))},Fn.tail=function(t){var e=null==t?0:t.length;return e?to(t,1,e):[]},Fn.take=function(t,e,n){return t&&t.length?to(t,0,(e=n||e===o?1:pa(e))<0?0:e):[]},Fn.takeRight=function(t,e,n){var r=null==t?0:t.length;return r?to(t,(e=r-(e=n||e===o?1:pa(e)))<0?0:e,r):[]},Fn.takeRightWhile=function(t,e){return t&&t.length?uo(t,si(e,3),!1,!0):[]},Fn.takeWhile=function(t,e){return t&&t.length?uo(t,si(e,3)):[]},Fn.tap=function(t,e){return e(t),t},Fn.throttle=function(t,e,n){var r=!0,o=!0;if("function"!=typeof t)throw new It(i);return Zs(n)&&(r="leading"in n?!!n.leading:r,o="trailing"in n?!!n.trailing:o),Ps(t,e,{leading:r,maxWait:e,trailing:o})},Fn.thru=ds,Fn.toArray=ha,Fn.toPairs=Ba,Fn.toPairsIn=Fa,Fn.toPath=function(t){return Us(t)?Me(t,$i):aa(t)?[t]:Io(Di(ya(t)))},Fn.toPlainObject=ga,Fn.transform=function(t,e,n){var r=Us(t),o=r||zs(t)||la(t);if(e=si(e,4),null==n){var i=t&&t.constructor;n=o?r?new i:[]:Zs(t)&&Qs(i)?kn(jt(t)):{}}return(o?Ee:br)(t,(function(t,r,o){return e(n,t,r,o)})),n},Fn.unary=function(t){return Ss(t,1)},Fn.union=ts,Fn.unionBy=es,Fn.unionWith=ns,Fn.uniq=function(t){return t&&t.length?ao(t):[]},Fn.uniqBy=function(t,e){return t&&t.length?ao(t,si(e,2)):[]},Fn.uniqWith=function(t,e){return e="function"==typeof e?e:o,t&&t.length?ao(t,o,e):[]},Fn.unset=function(t,e){return null==t||lo(t,e)},Fn.unzip=rs,Fn.unzipWith=os,Fn.update=function(t,e,n){return null==t?t:co(t,e,go(n))},Fn.updateWith=function(t,e,n,r){return r="function"==typeof r?r:o,null==t?t:co(t,e,go(n),r)},Fn.values=ka,Fn.valuesIn=function(t){return null==t?[]:Qe(t,Ma(t))},Fn.without=is,Fn.words=Qa,Fn.wrap=function(t,e){return $s(go(e),t)},Fn.xor=ss,Fn.xorBy=as,Fn.xorWith=ls,Fn.zip=cs,Fn.zipObject=function(t,e){return fo(t||[],e||[],Zn)},Fn.zipObjectDeep=function(t,e){return fo(t||[],e||[],Qr)},Fn.zipWith=us,Fn.entries=Ba,Fn.entriesIn=Fa,Fn.extend=va,Fn.extendWith=Ca,sl(Fn,Fn),Fn.add=yl,Fn.attempt=Ja,Fn.camelCase=Ha,Fn.capitalize=Ga,Fn.ceil=bl,Fn.clamp=function(t,e,n){return n===o&&(n=e,e=o),n!==o&&(n=(n=ma(n))==n?n:0),e!==o&&(e=(e=ma(e))==e?e:0),ir(ma(t),e,n)},Fn.clone=function(t){return sr(t,4)},Fn.cloneDeep=function(t){return sr(t,5)},Fn.cloneDeepWith=function(t,e){return sr(t,5,e="function"==typeof e?e:o)},Fn.cloneWith=function(t,e){return sr(t,4,e="function"==typeof e?e:o)},Fn.conformsTo=function(t,e){return null==e||ar(t,e,Pa(e))},Fn.deburr=Va,Fn.defaultTo=function(t,e){return null==t||t!=t?e:t},Fn.divide=vl,Fn.endsWith=function(t,e,n){t=ya(t),e=so(e);var r=t.length,i=n=n===o?r:ir(pa(n),0,r);return(n-=e.length)>=0&&t.slice(n,i)==e},Fn.eq=ks,Fn.escape=function(t){return(t=ya(t))&&Y.test(t)?t.replace(W,en):t},Fn.escapeRegExp=function(t){return(t=ya(t))&&nt.test(t)?t.replace(et,"\\$&"):t},Fn.every=function(t,e,n){var r=Us(t)?Ie:dr;return n&&yi(t,e,n)&&(e=o),r(t,si(e,3))},Fn.find=ms,Fn.findIndex=Vi,Fn.findKey=function(t,e){return Be(t,si(e,3),br)},Fn.findLast=gs,Fn.findLastIndex=Ui,Fn.findLastKey=function(t,e){return Be(t,si(e,3),vr)},Fn.floor=Cl,Fn.forEach=ys,Fn.forEachRight=bs,Fn.forIn=function(t,e){return null==t?t:gr(t,si(e,3),Ma)},Fn.forInRight=function(t,e){return null==t?t:yr(t,si(e,3),Ma)},Fn.forOwn=function(t,e){return t&&br(t,si(e,3))},Fn.forOwnRight=function(t,e){return t&&vr(t,si(e,3))},Fn.get=Ea,Fn.gt=Hs,Fn.gte=Gs,Fn.has=function(t,e){return null!=t&&pi(t,e,Er)},Fn.hasIn=Sa,Fn.head=qi,Fn.identity=nl,Fn.includes=function(t,e,n,r){t=qs(t)?t:ka(t),n=n&&!r?pa(n):0;var o=t.length;return n<0&&(n=gn(o+n,0)),sa(t)?n<=o&&t.indexOf(e,n)>-1:!!o&&ke(t,e,n)>-1},Fn.indexOf=function(t,e,n){var r=null==t?0:t.length;if(!r)return-1;var o=null==n?0:pa(n);return o<0&&(o=gn(r+o,0)),ke(t,e,o)},Fn.inRange=function(t,e,n){return e=da(e),n===o?(n=e,e=0):n=da(n),function(t,e,n){return t>=yn(e,n)&&t<gn(e,n)}(t=ma(t),e,n)},Fn.invoke=_a,Fn.isArguments=Vs,Fn.isArray=Us,Fn.isArrayBuffer=js,Fn.isArrayLike=qs,Fn.isArrayLikeObject=Ws,Fn.isBoolean=function(t){return!0===t||!1===t||ta(t)&&Ar(t)==y},Fn.isBuffer=zs,Fn.isDate=Ys,Fn.isElement=function(t){return ta(t)&&1===t.nodeType&&!ra(t)},Fn.isEmpty=function(t){if(null==t)return!0;if(qs(t)&&(Us(t)||"string"==typeof t||"function"==typeof t.splice||zs(t)||la(t)||Vs(t)))return!t.length;var e=di(t);if(e==w||e==I)return!t.size;if(xi(t))return!Rr(t).length;for(var n in t)if(Ot.call(t,n))return!1;return!0},Fn.isEqual=function(t,e){return Pr(t,e)},Fn.isEqualWith=function(t,e,n){var r=(n="function"==typeof n?n:o)?n(t,e):o;return r===o?Pr(t,e,o,n):!!r},Fn.isError=Ks,Fn.isFinite=function(t){return"number"==typeof t&&$e(t)},Fn.isFunction=Qs,Fn.isInteger=Js,Fn.isLength=Xs,Fn.isMap=ea,Fn.isMatch=function(t,e){return t===e||Mr(t,e,li(e))},Fn.isMatchWith=function(t,e,n){return n="function"==typeof n?n:o,Mr(t,e,li(e),n)},Fn.isNaN=function(t){return na(t)&&t!=+t},Fn.isNative=function(t){if(Ci(t))throw new xt("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");return Lr(t)},Fn.isNil=function(t){return null==t},Fn.isNull=function(t){return null===t},Fn.isNumber=na,Fn.isObject=Zs,Fn.isObjectLike=ta,Fn.isPlainObject=ra,Fn.isRegExp=oa,Fn.isSafeInteger=function(t){return Js(t)&&t>=-9007199254740991&&t<=h},Fn.isSet=ia,Fn.isString=sa,Fn.isSymbol=aa,Fn.isTypedArray=la,Fn.isUndefined=function(t){return t===o},Fn.isWeakMap=function(t){return ta(t)&&di(t)==P},Fn.isWeakSet=function(t){return ta(t)&&"[object WeakSet]"==Ar(t)},Fn.join=function(t,e){return null==t?"":je.call(t,e)},Fn.kebabCase=Ua,Fn.last=Ki,Fn.lastIndexOf=function(t,e,n){var r=null==t?0:t.length;if(!r)return-1;var i=r;return n!==o&&(i=(i=pa(n))<0?gn(r+i,0):yn(i,r-1)),e==e?function(t,e,n){for(var r=n+1;r--;)if(t[r]===e)return r;return r}(t,e,i):Fe(t,Ge,i,!0)},Fn.lowerCase=ja,Fn.lowerFirst=qa,Fn.lt=ca,Fn.lte=ua,Fn.max=function(t){return t&&t.length?pr(t,nl,Tr):o},Fn.maxBy=function(t,e){return t&&t.length?pr(t,si(e,2),Tr):o},Fn.mean=function(t){return Ve(t,nl)},Fn.meanBy=function(t,e){return Ve(t,si(e,2))},Fn.min=function(t){return t&&t.length?pr(t,nl,Dr):o},Fn.minBy=function(t,e){return t&&t.length?pr(t,si(e,2),Dr):o},Fn.stubArray=fl,Fn.stubFalse=ml,Fn.stubObject=function(){return{}},Fn.stubString=function(){return""},Fn.stubTrue=function(){return!0},Fn.multiply=xl,Fn.nth=function(t,e){return t&&t.length?Hr(t,pa(e)):o},Fn.noConflict=function(){return he._===this&&(he._=Ft),this},Fn.noop=al,Fn.now=Es,Fn.pad=function(t,e,n){t=ya(t);var r=(e=pa(e))?un(t):0;if(!e||r>=e)return t;var o=(e-r)/2;return Vo(pe(o),n)+t+Vo(de(o),n)},Fn.padEnd=function(t,e,n){t=ya(t);var r=(e=pa(e))?un(t):0;return e&&r<e?t+Vo(e-r,n):t},Fn.padStart=function(t,e,n){t=ya(t);var r=(e=pa(e))?un(t):0;return e&&r<e?Vo(e-r,n)+t:t},Fn.parseInt=function(t,e,n){return n||null==e?e=0:e&&(e=+e),vn(ya(t).replace(rt,""),e||0)},Fn.random=function(t,e,n){if(n&&"boolean"!=typeof n&&yi(t,e,n)&&(e=n=o),n===o&&("boolean"==typeof e?(n=e,e=o):"boolean"==typeof t&&(n=t,t=o)),t===o&&e===o?(t=0,e=1):(t=da(t),e===o?(e=t,t=0):e=da(e)),t>e){var r=t;t=e,e=r}if(n||t%1||e%1){var i=Cn();return yn(t+i*(e-t+ae("1e-"+((i+"").length-1))),e)}return qr(t,e)},Fn.reduce=function(t,e,n){var r=Us(t)?Oe:qe,o=arguments.length<3;return r(t,si(e,4),n,o,ur)},Fn.reduceRight=function(t,e,n){var r=Us(t)?Re:qe,o=arguments.length<3;return r(t,si(e,4),n,o,hr)},Fn.repeat=function(t,e,n){return e=(n?yi(t,e,n):e===o)?1:pa(e),Wr(ya(t),e)},Fn.replace=function(){var t=arguments,e=ya(t[0]);return t.length<3?e:e.replace(t[1],t[2])},Fn.result=function(t,e,n){var r=-1,i=(e=yo(e,t)).length;for(i||(i=1,t=o);++r<i;){var s=null==t?o:t[$i(e[r])];s===o&&(r=i,s=n),t=Qs(s)?s.call(t):s}return t},Fn.round=wl,Fn.runInContext=t,Fn.sample=function(t){return(Us(t)?Kn:Yr)(t)},Fn.size=function(t){if(null==t)return 0;if(qs(t))return sa(t)?un(t):t.length;var e=di(t);return e==w||e==I?t.size:Rr(t).length},Fn.snakeCase=Wa,Fn.some=function(t,e,n){var r=Us(t)?De:eo;return n&&yi(t,e,n)&&(e=o),r(t,si(e,3))},Fn.sortedIndex=function(t,e){return no(t,e)},Fn.sortedIndexBy=function(t,e,n){return ro(t,e,si(n,2))},Fn.sortedIndexOf=function(t,e){var n=null==t?0:t.length;if(n){var r=no(t,e);if(r<n&&ks(t[r],e))return r}return-1},Fn.sortedLastIndex=function(t,e){return no(t,e,!0)},Fn.sortedLastIndexBy=function(t,e,n){return ro(t,e,si(n,2),!0)},Fn.sortedLastIndexOf=function(t,e){if(null!=t&&t.length){var n=no(t,e,!0)-1;if(ks(t[n],e))return n}return-1},Fn.startCase=za,Fn.startsWith=function(t,e,n){return t=ya(t),n=null==n?0:ir(pa(n),0,t.length),e=so(e),t.slice(n,n+e.length)==e},Fn.subtract=Al,Fn.sum=function(t){return t&&t.length?We(t,nl):0},Fn.sumBy=function(t,e){return t&&t.length?We(t,si(e,2)):0},Fn.template=function(t,e,n){var r=Fn.templateSettings;n&&yi(t,e,n)&&(e=o),t=ya(t),e=Ca({},e,r,Qo);var i,s,a=Ca({},e.imports,r.imports,Qo),l=Pa(a),c=Qe(a,l),u=0,h=e.interpolate||vt,d="__p += '",p=Et((e.escape||vt).source+"|"+h.source+"|"+(h===J?ht:vt).source+"|"+(e.evaluate||vt).source+"|$","g"),f="//# sourceURL="+(Ot.call(e,"sourceURL")?(e.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++re+"]")+"\n";t.replace(p,(function(e,n,r,o,a,l){return r||(r=o),d+=t.slice(u,l).replace(Ct,nn),n&&(i=!0,d+="' +\n__e("+n+") +\n'"),a&&(s=!0,d+="';\n"+a+";\n__p += '"),r&&(d+="' +\n((__t = ("+r+")) == null ? '' : __t) +\n'"),u=l+e.length,e})),d+="';\n";var m=Ot.call(e,"variable")&&e.variable;if(m){if(ct.test(m))throw new xt("Invalid `variable` option passed into `_.template`")}else d="with (obj) {\n"+d+"\n}\n";d=(s?d.replace(V,""):d).replace(U,"$1").replace(j,"$1;"),d="function("+(m||"obj")+") {\n"+(m?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(i?", __e = _.escape":"")+(s?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+d+"return __p\n}";var g=Ja((function(){return wt(l,f+"return "+d).apply(o,c)}));if(g.source=d,Ks(g))throw g;return g},Fn.times=function(t,e){if((t=pa(t))<1||t>h)return[];var n=p,r=yn(t,p);e=si(e),t-=p;for(var o=ze(r,e);++n<t;)e(n);return o},Fn.toFinite=da,Fn.toInteger=pa,Fn.toLength=fa,Fn.toLower=function(t){return ya(t).toLowerCase()},Fn.toNumber=ma,Fn.toSafeInteger=function(t){return t?ir(pa(t),-9007199254740991,h):0===t?t:0},Fn.toString=ya,Fn.toUpper=function(t){return ya(t).toUpperCase()},Fn.trim=function(t,e,n){if((t=ya(t))&&(n||e===o))return Ye(t);if(!t||!(e=so(e)))return t;var r=hn(t),i=hn(e);return vo(r,Xe(r,i),Ze(r,i)+1).join("")},Fn.trimEnd=function(t,e,n){if((t=ya(t))&&(n||e===o))return t.slice(0,dn(t)+1);if(!t||!(e=so(e)))return t;var r=hn(t);return vo(r,0,Ze(r,hn(e))+1).join("")},Fn.trimStart=function(t,e,n){if((t=ya(t))&&(n||e===o))return t.replace(rt,"");if(!t||!(e=so(e)))return t;var r=hn(t);return vo(r,Xe(r,hn(e))).join("")},Fn.truncate=function(t,e){var n=30,r="...";if(Zs(e)){var i="separator"in e?e.separator:i;n="length"in e?pa(e.length):n,r="omission"in e?so(e.omission):r}var s=(t=ya(t)).length;if(rn(t)){var a=hn(t);s=a.length}if(n>=s)return t;var l=n-un(r);if(l<1)return r;var c=a?vo(a,0,l).join(""):t.slice(0,l);if(i===o)return c+r;if(a&&(l+=c.length-l),oa(i)){if(t.slice(l).search(i)){var u,h=c;for(i.global||(i=Et(i.source,ya(dt.exec(i))+"g")),i.lastIndex=0;u=i.exec(h);)var d=u.index;c=c.slice(0,d===o?l:d)}}else if(t.indexOf(so(i),l)!=l){var p=c.lastIndexOf(i);p>-1&&(c=c.slice(0,p))}return c+r},Fn.unescape=function(t){return(t=ya(t))&&z.test(t)?t.replace(q,pn):t},Fn.uniqueId=function(t){var e=++Rt;return ya(t)+e},Fn.upperCase=Ya,Fn.upperFirst=Ka,Fn.each=ys,Fn.eachRight=bs,Fn.first=qi,sl(Fn,(gl={},br(Fn,(function(t,e){Ot.call(Fn.prototype,e)||(gl[e]=t)})),gl),{chain:!1}),Fn.VERSION="4.17.21",Ee(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(t){Fn[t].placeholder=Fn})),Ee(["drop","take"],(function(t,e){Vn.prototype[t]=function(n){n=n===o?1:gn(pa(n),0);var r=this.__filtered__&&!e?new Vn(this):this.clone();return r.__filtered__?r.__takeCount__=yn(n,r.__takeCount__):r.__views__.push({size:yn(n,p),type:t+(r.__dir__<0?"Right":"")}),r},Vn.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}})),Ee(["filter","map","takeWhile"],(function(t,e){var n=e+1,r=1==n||3==n;Vn.prototype[t]=function(t){var e=this.clone();return e.__iteratees__.push({iteratee:si(t,3),type:n}),e.__filtered__=e.__filtered__||r,e}})),Ee(["head","last"],(function(t,e){var n="take"+(e?"Right":"");Vn.prototype[t]=function(){return this[n](1).value()[0]}})),Ee(["initial","tail"],(function(t,e){var n="drop"+(e?"":"Right");Vn.prototype[t]=function(){return this.__filtered__?new Vn(this):this[n](1)}})),Vn.prototype.compact=function(){return this.filter(nl)},Vn.prototype.find=function(t){return this.filter(t).head()},Vn.prototype.findLast=function(t){return this.reverse().find(t)},Vn.prototype.invokeMap=zr((function(t,e){return"function"==typeof t?new Vn(this):this.map((function(n){return Nr(n,t,e)}))})),Vn.prototype.reject=function(t){return this.filter(Rs(si(t)))},Vn.prototype.slice=function(t,e){t=pa(t);var n=this;return n.__filtered__&&(t>0||e<0)?new Vn(n):(t<0?n=n.takeRight(-t):t&&(n=n.drop(t)),e!==o&&(n=(e=pa(e))<0?n.dropRight(-e):n.take(e-t)),n)},Vn.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},Vn.prototype.toArray=function(){return this.take(p)},br(Vn.prototype,(function(t,e){var n=/^(?:filter|find|map|reject)|While$/.test(e),r=/^(?:head|last)$/.test(e),i=Fn[r?"take"+("last"==e?"Right":""):e],s=r||/^find/.test(e);i&&(Fn.prototype[e]=function(){var e=this.__wrapped__,a=r?[1]:arguments,l=e instanceof Vn,c=a[0],u=l||Us(e),h=function(t){var e=i.apply(Fn,Le([t],a));return r&&d?e[0]:e};u&&n&&"function"==typeof c&&1!=c.length&&(l=u=!1);var d=this.__chain__,p=!!this.__actions__.length,f=s&&!d,m=l&&!p;if(!s&&u){e=m?e:new Vn(this);var g=t.apply(e,a);return g.__actions__.push({func:ds,args:[h],thisArg:o}),new Gn(g,d)}return f&&m?t.apply(this,a):(g=this.thru(h),f?r?g.value()[0]:g.value():g)})})),Ee(["pop","push","shift","sort","splice","unshift"],(function(t){var e=Nt[t],n=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",r=/^(?:pop|shift)$/.test(t);Fn.prototype[t]=function(){var t=arguments;if(r&&!this.__chain__){var o=this.value();return e.apply(Us(o)?o:[],t)}return this[n]((function(n){return e.apply(Us(n)?n:[],t)}))}})),br(Vn.prototype,(function(t,e){var n=Fn[e];if(n){var r=n.name+"";Ot.call(_n,r)||(_n[r]=[]),_n[r].push({name:e,func:n})}})),_n[Fo(o,2).name]=[{name:"wrapper",func:o}],Vn.prototype.clone=function(){var t=new Vn(this.__wrapped__);return t.__actions__=Io(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=Io(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=Io(this.__views__),t},Vn.prototype.reverse=function(){if(this.__filtered__){var t=new Vn(this);t.__dir__=-1,t.__filtered__=!0}else(t=this.clone()).__dir__*=-1;return t},Vn.prototype.value=function(){var t=this.__wrapped__.value(),e=this.__dir__,n=Us(t),r=e<0,o=n?t.length:0,i=function(t,e,n){for(var r=-1,o=n.length;++r<o;){var i=n[r],s=i.size;switch(i.type){case"drop":t+=s;break;case"dropRight":e-=s;break;case"take":e=yn(e,t+s);break;case"takeRight":t=gn(t,e-s)}}return{start:t,end:e}}(0,o,this.__views__),s=i.start,a=i.end,l=a-s,c=r?a:s-1,u=this.__iteratees__,h=u.length,d=0,p=yn(l,this.__takeCount__);if(!n||!r&&o==l&&p==l)return ho(t,this.__actions__);var f=[];t:for(;l--&&d<p;){for(var m=-1,g=t[c+=e];++m<h;){var y=u[m],b=y.iteratee,v=y.type,C=b(g);if(2==v)g=C;else if(!C){if(1==v)continue t;break t}}f[d++]=g}return f},Fn.prototype.at=ps,Fn.prototype.chain=function(){return hs(this)},Fn.prototype.commit=function(){return new Gn(this.value(),this.__chain__)},Fn.prototype.next=function(){this.__values__===o&&(this.__values__=ha(this.value()));var t=this.__index__>=this.__values__.length;return{done:t,value:t?o:this.__values__[this.__index__++]}},Fn.prototype.plant=function(t){for(var e,n=this;n instanceof Hn;){var r=Fi(n);r.__index__=0,r.__values__=o,e?i.__wrapped__=r:e=r;var i=r;n=n.__wrapped__}return i.__wrapped__=t,e},Fn.prototype.reverse=function(){var t=this.__wrapped__;if(t instanceof Vn){var e=t;return this.__actions__.length&&(e=new Vn(this)),(e=e.reverse()).__actions__.push({func:ds,args:[Zi],thisArg:o}),new Gn(e,this.__chain__)}return this.thru(Zi)},Fn.prototype.toJSON=Fn.prototype.valueOf=Fn.prototype.value=function(){return ho(this.__wrapped__,this.__actions__)},Fn.prototype.first=Fn.prototype.head,Kt&&(Fn.prototype[Kt]=function(){return this}),Fn}();he._=fn,(r=function(){return fn}.call(e,n,e,t))===o||(t.exports=r)}.call(this)},4802:t=>{t.exports=function t(e,n,r){function o(s,a){if(!n[s]){if(!e[s]){if(i)return i(s,!0);throw new Error("Cannot find module '"+s+"'")}a=n[s]={exports:{}},e[s][0].call(a.exports,(function(t){return o(e[s][1][t]||t)}),a,a.exports,t,e,n,r)}return n[s].exports}for(var i=void 0,s=0;s<r.length;s++)o(r[s]);return o}({1:[function(t,e,n){(function(r,o,i,s,a,l,c,u,h){"use strict";var d=t("crypto");function p(t,e){var n;return void 0===(n="passthrough"!==(e=g(t,e)).algorithm?d.createHash(e.algorithm):new v).write&&(n.write=n.update,n.end=n.update),b(e,n).dispatch(t),n.update||n.end(""),n.digest?n.digest("buffer"===e.encoding?void 0:e.encoding):(t=n.read(),"buffer"!==e.encoding?t.toString(e.encoding):t)}(n=e.exports=p).sha1=function(t){return p(t)},n.keys=function(t){return p(t,{excludeValues:!0,algorithm:"sha1",encoding:"hex"})},n.MD5=function(t){return p(t,{algorithm:"md5",encoding:"hex"})},n.keysMD5=function(t){return p(t,{algorithm:"md5",encoding:"hex",excludeValues:!0})};var f=d.getHashes?d.getHashes().slice():["sha1","md5"],m=(f.push("passthrough"),["buffer","hex","binary","base64"]);function g(t,e){var n={};if(n.algorithm=(e=e||{}).algorithm||"sha1",n.encoding=e.encoding||"hex",n.excludeValues=!!e.excludeValues,n.algorithm=n.algorithm.toLowerCase(),n.encoding=n.encoding.toLowerCase(),n.ignoreUnknown=!0===e.ignoreUnknown,n.respectType=!1!==e.respectType,n.respectFunctionNames=!1!==e.respectFunctionNames,n.respectFunctionProperties=!1!==e.respectFunctionProperties,n.unorderedArrays=!0===e.unorderedArrays,n.unorderedSets=!1!==e.unorderedSets,n.unorderedObjects=!1!==e.unorderedObjects,n.replacer=e.replacer||void 0,n.excludeKeys=e.excludeKeys||void 0,void 0===t)throw new Error("Object argument required.");for(var r=0;r<f.length;++r)f[r].toLowerCase()===n.algorithm.toLowerCase()&&(n.algorithm=f[r]);if(-1===f.indexOf(n.algorithm))throw new Error('Algorithm "'+n.algorithm+'" not supported. supported values: '+f.join(", "));if(-1===m.indexOf(n.encoding)&&"passthrough"!==n.algorithm)throw new Error('Encoding "'+n.encoding+'" not supported. supported values: '+m.join(", "));return n}function y(t){if("function"==typeof t)return null!=/^function\s+\w*\s*\(\s*\)\s*{\s+\[native code\]\s+}$/i.exec(Function.prototype.toString.call(t))}function b(t,e,n){function r(t){return e.update?e.update(t,"utf8"):e.write(t,"utf8")}return n=n||[],{dispatch:function(e){return this["_"+(null===(e=t.replacer?t.replacer(e):e)?"null":typeof e)](e)},_object:function(e){var o,s=Object.prototype.toString.call(e),a=/\[object (.*)\]/i.exec(s);if(a=(a=a?a[1]:"unknown:["+s+"]").toLowerCase(),0<=(s=n.indexOf(e)))return this.dispatch("[CIRCULAR:"+s+"]");if(n.push(e),void 0!==i&&i.isBuffer&&i.isBuffer(e))return r("buffer:"),r(e);if("object"===a||"function"===a||"asyncfunction"===a)return s=Object.keys(e),t.unorderedObjects&&(s=s.sort()),!1===t.respectType||y(e)||s.splice(0,0,"prototype","__proto__","constructor"),t.excludeKeys&&(s=s.filter((function(e){return!t.excludeKeys(e)}))),r("object:"+s.length+":"),o=this,s.forEach((function(n){o.dispatch(n),r(":"),t.excludeValues||o.dispatch(e[n]),r(",")}));if(!this["_"+a]){if(t.ignoreUnknown)return r("["+a+"]");throw new Error('Unknown object type "'+a+'"')}this["_"+a](e)},_array:function(e,o){o=void 0!==o?o:!1!==t.unorderedArrays;var i=this;if(r("array:"+e.length+":"),!o||e.length<=1)return e.forEach((function(t){return i.dispatch(t)}));var s=[];return o=e.map((function(e){var r=new v,o=n.slice();return b(t,r,o).dispatch(e),s=s.concat(o.slice(n.length)),r.read().toString()})),n=n.concat(s),o.sort(),this._array(o,!1)},_date:function(t){return r("date:"+t.toJSON())},_symbol:function(t){return r("symbol:"+t.toString())},_error:function(t){return r("error:"+t.toString())},_boolean:function(t){return r("bool:"+t.toString())},_string:function(t){r("string:"+t.length+":"),r(t.toString())},_function:function(e){r("fn:"),y(e)?this.dispatch("[native]"):this.dispatch(e.toString()),!1!==t.respectFunctionNames&&this.dispatch("function-name:"+String(e.name)),t.respectFunctionProperties&&this._object(e)},_number:function(t){return r("number:"+t.toString())},_xml:function(t){return r("xml:"+t.toString())},_null:function(){return r("Null")},_undefined:function(){return r("Undefined")},_regexp:function(t){return r("regex:"+t.toString())},_uint8array:function(t){return r("uint8array:"),this.dispatch(Array.prototype.slice.call(t))},_uint8clampedarray:function(t){return r("uint8clampedarray:"),this.dispatch(Array.prototype.slice.call(t))},_int8array:function(t){return r("int8array:"),this.dispatch(Array.prototype.slice.call(t))},_uint16array:function(t){return r("uint16array:"),this.dispatch(Array.prototype.slice.call(t))},_int16array:function(t){return r("int16array:"),this.dispatch(Array.prototype.slice.call(t))},_uint32array:function(t){return r("uint32array:"),this.dispatch(Array.prototype.slice.call(t))},_int32array:function(t){return r("int32array:"),this.dispatch(Array.prototype.slice.call(t))},_float32array:function(t){return r("float32array:"),this.dispatch(Array.prototype.slice.call(t))},_float64array:function(t){return r("float64array:"),this.dispatch(Array.prototype.slice.call(t))},_arraybuffer:function(t){return r("arraybuffer:"),this.dispatch(new Uint8Array(t))},_url:function(t){return r("url:"+t.toString())},_map:function(e){return r("map:"),e=Array.from(e),this._array(e,!1!==t.unorderedSets)},_set:function(e){return r("set:"),e=Array.from(e),this._array(e,!1!==t.unorderedSets)},_file:function(t){return r("file:"),this.dispatch([t.name,t.size,t.type,t.lastModfied])},_blob:function(){if(t.ignoreUnknown)return r("[blob]");throw Error('Hashing Blob objects is currently not supported\n(see https://github.com/puleos/object-hash/issues/26)\nUse "options.replacer" or "options.ignoreUnknown"\n')},_domwindow:function(){return r("domwindow")},_bigint:function(t){return r("bigint:"+t.toString())},_process:function(){return r("process")},_timer:function(){return r("timer")},_pipe:function(){return r("pipe")},_tcp:function(){return r("tcp")},_udp:function(){return r("udp")},_tty:function(){return r("tty")},_statwatcher:function(){return r("statwatcher")},_securecontext:function(){return r("securecontext")},_connection:function(){return r("connection")},_zlib:function(){return r("zlib")},_context:function(){return r("context")},_nodescript:function(){return r("nodescript")},_httpparser:function(){return r("httpparser")},_dataview:function(){return r("dataview")},_signal:function(){return r("signal")},_fsevent:function(){return r("fsevent")},_tlswrap:function(){return r("tlswrap")}}}function v(){return{buf:"",write:function(t){this.buf+=t},end:function(t){this.buf+=t},read:function(){return this.buf}}}n.writeToStream=function(t,e,n){return void 0===n&&(n=e,e={}),b(e=g(t,e),n).dispatch(t)}}).call(this,t("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/fake_9a5aa49d.js","/")},{buffer:3,crypto:5,lYpoI2:11}],2:[function(t,e,n){(function(t,e,r,o,i,s,a,l,c){!function(t){"use strict";var e="undefined"!=typeof Uint8Array?Uint8Array:Array,n="+".charCodeAt(0),r="/".charCodeAt(0),o="0".charCodeAt(0),i="a".charCodeAt(0),s="A".charCodeAt(0),a="-".charCodeAt(0),l="_".charCodeAt(0);function c(t){return(t=t.charCodeAt(0))===n||t===a?62:t===r||t===l?63:t<o?-1:t<o+10?t-o+26+26:t<s+26?t-s:t<i+26?t-i+26:void 0}t.toByteArray=function(t){var n,r;if(0<t.length%4)throw new Error("Invalid string. Length must be a multiple of 4");var o=t.length,i=(o="="===t.charAt(o-2)?2:"="===t.charAt(o-1)?1:0,new e(3*t.length/4-o)),s=0<o?t.length-4:t.length,a=0;function l(t){i[a++]=t}for(n=0;n<s;n+=4,0)l((16711680&(r=c(t.charAt(n))<<18|c(t.charAt(n+1))<<12|c(t.charAt(n+2))<<6|c(t.charAt(n+3))))>>16),l((65280&r)>>8),l(255&r);return 2==o?l(255&(r=c(t.charAt(n))<<2|c(t.charAt(n+1))>>4)):1==o&&(l((r=c(t.charAt(n))<<10|c(t.charAt(n+1))<<4|c(t.charAt(n+2))>>2)>>8&255),l(255&r)),i},t.fromByteArray=function(t){var e,n,r,o,i=t.length%3,s="";function a(t){return"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(t)}for(e=0,r=t.length-i;e<r;e+=3)s+=a((o=n=(t[e]<<16)+(t[e+1]<<8)+t[e+2])>>18&63)+a(o>>12&63)+a(o>>6&63)+a(63&o);switch(i){case 1:s=(s+=a((n=t[t.length-1])>>2))+a(n<<4&63)+"==";break;case 2:s=(s=(s+=a((n=(t[t.length-2]<<8)+t[t.length-1])>>10))+a(n>>4&63))+a(n<<2&63)+"="}return s}}(void 0===n?this.base64js={}:n)}).call(this,t("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/base64-js/lib/b64.js","/node_modules/gulp-browserify/node_modules/base64-js/lib")},{buffer:3,lYpoI2:11}],3:[function(t,e,n){(function(e,r,o,i,s,a,l,c,u){var h=t("base64-js"),d=t("ieee754");function o(t,e,n){if(!(this instanceof o))return new o(t,e,n);var r,i,s,a,l=typeof t;if("base64"===e&&"string"==l)for(t=(a=t).trim?a.trim():a.replace(/^\s+|\s+$/g,"");t.length%4!=0;)t+="=";if("number"==l)r=I(t);else if("string"==l)r=o.byteLength(t,e);else{if("object"!=l)throw new Error("First argument needs to be a number, array or string.");r=I(t.length)}if(o._useTypedArrays?i=o._augment(new Uint8Array(r)):((i=this).length=r,i._isBuffer=!0),o._useTypedArrays&&"number"==typeof t.byteLength)i._set(t);else if(N(a=t)||o.isBuffer(a)||a&&"object"==typeof a&&"number"==typeof a.length)for(s=0;s<r;s++)o.isBuffer(t)?i[s]=t.readUInt8(s):i[s]=t[s];else if("string"==l)i.write(t,0,e);else if("number"==l&&!o._useTypedArrays&&!n)for(s=0;s<r;s++)i[s]=0;return i}function p(t,e,n,r){var o;if(r||(B("boolean"==typeof n,"missing or invalid endian"),B(null!=e,"missing offset"),B(e+1<t.length,"Trying to read beyond buffer length")),!((r=t.length)<=e))return n?(o=t[e],e+1<r&&(o|=t[e+1]<<8)):(o=t[e]<<8,e+1<r&&(o|=t[e+1])),o}function f(t,e,n,r){var o;if(r||(B("boolean"==typeof n,"missing or invalid endian"),B(null!=e,"missing offset"),B(e+3<t.length,"Trying to read beyond buffer length")),!((r=t.length)<=e))return n?(e+2<r&&(o=t[e+2]<<16),e+1<r&&(o|=t[e+1]<<8),o|=t[e],e+3<r&&(o+=t[e+3]<<24>>>0)):(e+1<r&&(o=t[e+1]<<16),e+2<r&&(o|=t[e+2]<<8),e+3<r&&(o|=t[e+3]),o+=t[e]<<24>>>0),o}function m(t,e,n,r){if(r||(B("boolean"==typeof n,"missing or invalid endian"),B(null!=e,"missing offset"),B(e+1<t.length,"Trying to read beyond buffer length")),!(t.length<=e))return 32768&(r=p(t,e,n,!0))?-1*(65535-r+1):r}function g(t,e,n,r){if(r||(B("boolean"==typeof n,"missing or invalid endian"),B(null!=e,"missing offset"),B(e+3<t.length,"Trying to read beyond buffer length")),!(t.length<=e))return 2147483648&(r=f(t,e,n,!0))?-1*(4294967295-r+1):r}function y(t,e,n,r){return r||(B("boolean"==typeof n,"missing or invalid endian"),B(e+3<t.length,"Trying to read beyond buffer length")),d.read(t,e,n,23,4)}function b(t,e,n,r){return r||(B("boolean"==typeof n,"missing or invalid endian"),B(e+7<t.length,"Trying to read beyond buffer length")),d.read(t,e,n,52,8)}function v(t,e,n,r,o){if(o||(B(null!=e,"missing value"),B("boolean"==typeof r,"missing or invalid endian"),B(null!=n,"missing offset"),B(n+1<t.length,"trying to write beyond buffer length"),R(e,65535)),!((o=t.length)<=n))for(var i=0,s=Math.min(o-n,2);i<s;i++)t[n+i]=(e&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function C(t,e,n,r,o){if(o||(B(null!=e,"missing value"),B("boolean"==typeof r,"missing or invalid endian"),B(null!=n,"missing offset"),B(n+3<t.length,"trying to write beyond buffer length"),R(e,4294967295)),!((o=t.length)<=n))for(var i=0,s=Math.min(o-n,4);i<s;i++)t[n+i]=e>>>8*(r?i:3-i)&255}function x(t,e,n,r,o){o||(B(null!=e,"missing value"),B("boolean"==typeof r,"missing or invalid endian"),B(null!=n,"missing offset"),B(n+1<t.length,"Trying to write beyond buffer length"),D(e,32767,-32768)),t.length<=n||v(t,0<=e?e:65535+e+1,n,r,o)}function w(t,e,n,r,o){o||(B(null!=e,"missing value"),B("boolean"==typeof r,"missing or invalid endian"),B(null!=n,"missing offset"),B(n+3<t.length,"Trying to write beyond buffer length"),D(e,2147483647,-2147483648)),t.length<=n||C(t,0<=e?e:4294967295+e+1,n,r,o)}function A(t,e,n,r,o){o||(B(null!=e,"missing value"),B("boolean"==typeof r,"missing or invalid endian"),B(null!=n,"missing offset"),B(n+3<t.length,"Trying to write beyond buffer length"),$(e,34028234663852886e22,-34028234663852886e22)),t.length<=n||d.write(t,e,n,r,23,4)}function T(t,e,n,r,o){o||(B(null!=e,"missing value"),B("boolean"==typeof r,"missing or invalid endian"),B(null!=n,"missing offset"),B(n+7<t.length,"Trying to write beyond buffer length"),$(e,17976931348623157e292,-17976931348623157e292)),t.length<=n||d.write(t,e,n,r,52,8)}n.Buffer=o,n.SlowBuffer=o,n.INSPECT_MAX_BYTES=50,o.poolSize=8192,o._useTypedArrays=function(){try{var t=new ArrayBuffer(0),e=new Uint8Array(t);return e.foo=function(){return 42},42===e.foo()&&"function"==typeof e.subarray}catch(t){return!1}}(),o.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.isBuffer=function(t){return!(null==t||!t._isBuffer)},o.byteLength=function(t,e){var n;switch(t+="",e||"utf8"){case"hex":n=t.length/2;break;case"utf8":case"utf-8":n=P(t).length;break;case"ascii":case"binary":case"raw":n=t.length;break;case"base64":n=M(t).length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":n=2*t.length;break;default:throw new Error("Unknown encoding")}return n},o.concat=function(t,e){if(B(N(t),"Usage: Buffer.concat(list, [totalLength])\nlist should be an Array."),0===t.length)return new o(0);if(1===t.length)return t[0];if("number"!=typeof e)for(i=e=0;i<t.length;i++)e+=t[i].length;for(var n=new o(e),r=0,i=0;i<t.length;i++){var s=t[i];s.copy(n,r),r+=s.length}return n},o.prototype.write=function(t,e,n,r){isFinite(e)?isFinite(n)||(r=n,n=void 0):(c=r,r=e,e=n,n=c),e=Number(e)||0;var i,s,a,l,c=this.length-e;switch((!n||c<(n=Number(n)))&&(n=c),r=String(r||"utf8").toLowerCase()){case"hex":i=function(t,e,n,r){n=Number(n)||0;var i=t.length-n;(!r||i<(r=Number(r)))&&(r=i),B((i=e.length)%2==0,"Invalid hex string"),i/2<r&&(r=i/2);for(var s=0;s<r;s++){var a=parseInt(e.substr(2*s,2),16);B(!isNaN(a),"Invalid hex string"),t[n+s]=a}return o._charsWritten=2*s,s}(this,t,e,n);break;case"utf8":case"utf-8":s=this,a=e,l=n,i=o._charsWritten=L(P(t),s,a,l);break;case"ascii":case"binary":i=function(t,e,n,r){return o._charsWritten=L(function(t){for(var e=[],n=0;n<t.length;n++)e.push(255&t.charCodeAt(n));return e}(e),t,n,r)}(this,t,e,n);break;case"base64":s=this,a=e,l=n,i=o._charsWritten=L(M(t),s,a,l);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":i=function(t,e,n,r){return o._charsWritten=L(function(t){for(var e,n,r=[],o=0;o<t.length;o++)e=(n=t.charCodeAt(o))>>8,n%=256,r.push(n),r.push(e);return r}(e),t,n,r)}(this,t,e,n);break;default:throw new Error("Unknown encoding")}return i},o.prototype.toString=function(t,e,n){var r,o,i,s,a=this;if(t=String(t||"utf8").toLowerCase(),e=Number(e)||0,(n=void 0!==n?Number(n):a.length)===e)return"";switch(t){case"hex":r=function(t,e,n){var r=t.length;(!e||e<0)&&(e=0),(!n||n<0||r<n)&&(n=r);for(var o="",i=e;i<n;i++)o+=_(t[i]);return o}(a,e,n);break;case"utf8":case"utf-8":r=function(t,e,n){var r="",o="";n=Math.min(t.length,n);for(var i=e;i<n;i++)t[i]<=127?(r+=O(o)+String.fromCharCode(t[i]),o=""):o+="%"+t[i].toString(16);return r+O(o)}(a,e,n);break;case"ascii":case"binary":r=function(t,e,n){var r="";n=Math.min(t.length,n);for(var o=e;o<n;o++)r+=String.fromCharCode(t[o]);return r}(a,e,n);break;case"base64":o=a,s=n,r=0===(i=e)&&s===o.length?h.fromByteArray(o):h.fromByteArray(o.slice(i,s));break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":r=function(t,e,n){for(var r=t.slice(e,n),o="",i=0;i<r.length;i+=2)o+=String.fromCharCode(r[i]+256*r[i+1]);return o}(a,e,n);break;default:throw new Error("Unknown encoding")}return r},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},o.prototype.copy=function(t,e,n,r){if(e=e||0,(r=r||0===r?r:this.length)!==(n=n||0)&&0!==t.length&&0!==this.length){B(n<=r,"sourceEnd < sourceStart"),B(0<=e&&e<t.length,"targetStart out of bounds"),B(0<=n&&n<this.length,"sourceStart out of bounds"),B(0<=r&&r<=this.length,"sourceEnd out of bounds"),r>this.length&&(r=this.length);var i=(r=t.length-e<r-n?t.length-e+n:r)-n;if(i<100||!o._useTypedArrays)for(var s=0;s<i;s++)t[s+e]=this[s+n];else t._set(this.subarray(n,n+i),e)}},o.prototype.slice=function(t,e){var n=this.length;if(t=S(t,n,0),e=S(e,n,n),o._useTypedArrays)return o._augment(this.subarray(t,e));for(var r=e-t,i=new o(r,void 0,!0),s=0;s<r;s++)i[s]=this[s+t];return i},o.prototype.get=function(t){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(t)},o.prototype.set=function(t,e){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(t,e)},o.prototype.readUInt8=function(t,e){if(e||(B(null!=t,"missing offset"),B(t<this.length,"Trying to read beyond buffer length")),!(t>=this.length))return this[t]},o.prototype.readUInt16LE=function(t,e){return p(this,t,!0,e)},o.prototype.readUInt16BE=function(t,e){return p(this,t,!1,e)},o.prototype.readUInt32LE=function(t,e){return f(this,t,!0,e)},o.prototype.readUInt32BE=function(t,e){return f(this,t,!1,e)},o.prototype.readInt8=function(t,e){if(e||(B(null!=t,"missing offset"),B(t<this.length,"Trying to read beyond buffer length")),!(t>=this.length))return 128&this[t]?-1*(255-this[t]+1):this[t]},o.prototype.readInt16LE=function(t,e){return m(this,t,!0,e)},o.prototype.readInt16BE=function(t,e){return m(this,t,!1,e)},o.prototype.readInt32LE=function(t,e){return g(this,t,!0,e)},o.prototype.readInt32BE=function(t,e){return g(this,t,!1,e)},o.prototype.readFloatLE=function(t,e){return y(this,t,!0,e)},o.prototype.readFloatBE=function(t,e){return y(this,t,!1,e)},o.prototype.readDoubleLE=function(t,e){return b(this,t,!0,e)},o.prototype.readDoubleBE=function(t,e){return b(this,t,!1,e)},o.prototype.writeUInt8=function(t,e,n){n||(B(null!=t,"missing value"),B(null!=e,"missing offset"),B(e<this.length,"trying to write beyond buffer length"),R(t,255)),e>=this.length||(this[e]=t)},o.prototype.writeUInt16LE=function(t,e,n){v(this,t,e,!0,n)},o.prototype.writeUInt16BE=function(t,e,n){v(this,t,e,!1,n)},o.prototype.writeUInt32LE=function(t,e,n){C(this,t,e,!0,n)},o.prototype.writeUInt32BE=function(t,e,n){C(this,t,e,!1,n)},o.prototype.writeInt8=function(t,e,n){n||(B(null!=t,"missing value"),B(null!=e,"missing offset"),B(e<this.length,"Trying to write beyond buffer length"),D(t,127,-128)),e>=this.length||(0<=t?this.writeUInt8(t,e,n):this.writeUInt8(255+t+1,e,n))},o.prototype.writeInt16LE=function(t,e,n){x(this,t,e,!0,n)},o.prototype.writeInt16BE=function(t,e,n){x(this,t,e,!1,n)},o.prototype.writeInt32LE=function(t,e,n){w(this,t,e,!0,n)},o.prototype.writeInt32BE=function(t,e,n){w(this,t,e,!1,n)},o.prototype.writeFloatLE=function(t,e,n){A(this,t,e,!0,n)},o.prototype.writeFloatBE=function(t,e,n){A(this,t,e,!1,n)},o.prototype.writeDoubleLE=function(t,e,n){T(this,t,e,!0,n)},o.prototype.writeDoubleBE=function(t,e,n){T(this,t,e,!1,n)},o.prototype.fill=function(t,e,n){if(e=e||0,n=n||this.length,B("number"==typeof(t="string"==typeof(t=t||0)?t.charCodeAt(0):t)&&!isNaN(t),"value is not a number"),B(e<=n,"end < start"),n!==e&&0!==this.length){B(0<=e&&e<this.length,"start out of bounds"),B(0<=n&&n<=this.length,"end out of bounds");for(var r=e;r<n;r++)this[r]=t}},o.prototype.inspect=function(){for(var t=[],e=this.length,r=0;r<e;r++)if(t[r]=_(this[r]),r===n.INSPECT_MAX_BYTES){t[r+1]="...";break}return"<Buffer "+t.join(" ")+">"},o.prototype.toArrayBuffer=function(){if("undefined"==typeof Uint8Array)throw new Error("Buffer.toArrayBuffer not supported in this browser");if(o._useTypedArrays)return new o(this).buffer;for(var t=new Uint8Array(this.length),e=0,n=t.length;e<n;e+=1)t[e]=this[e];return t.buffer};var E=o.prototype;function S(t,e,n){return"number"!=typeof t?n:e<=(t=~~t)?e:0<=t||0<=(t+=e)?t:0}function I(t){return(t=~~Math.ceil(+t))<0?0:t}function N(t){return(Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)})(t)}function _(t){return t<16?"0"+t.toString(16):t.toString(16)}function P(t){for(var e=[],n=0;n<t.length;n++){var r=t.charCodeAt(n);if(r<=127)e.push(t.charCodeAt(n));else for(var o=n,i=(55296<=r&&r<=57343&&n++,encodeURIComponent(t.slice(o,n+1)).substr(1).split("%")),s=0;s<i.length;s++)e.push(parseInt(i[s],16))}return e}function M(t){return h.toByteArray(t)}function L(t,e,n,r){for(var o=0;o<r&&!(o+n>=e.length||o>=t.length);o++)e[o+n]=t[o];return o}function O(t){try{return decodeURIComponent(t)}catch(t){return String.fromCharCode(65533)}}function R(t,e){B("number"==typeof t,"cannot write a non-number as a number"),B(0<=t,"specified a negative value for writing an unsigned value"),B(t<=e,"value is larger than maximum value for type"),B(Math.floor(t)===t,"value has a fractional component")}function D(t,e,n){B("number"==typeof t,"cannot write a non-number as a number"),B(t<=e,"value larger than maximum allowed value"),B(n<=t,"value smaller than minimum allowed value"),B(Math.floor(t)===t,"value has a fractional component")}function $(t,e,n){B("number"==typeof t,"cannot write a non-number as a number"),B(t<=e,"value larger than maximum allowed value"),B(n<=t,"value smaller than minimum allowed value")}function B(t,e){if(!t)throw new Error(e||"Failed assertion")}o._augment=function(t){return t._isBuffer=!0,t._get=t.get,t._set=t.set,t.get=E.get,t.set=E.set,t.write=E.write,t.toString=E.toString,t.toLocaleString=E.toString,t.toJSON=E.toJSON,t.copy=E.copy,t.slice=E.slice,t.readUInt8=E.readUInt8,t.readUInt16LE=E.readUInt16LE,t.readUInt16BE=E.readUInt16BE,t.readUInt32LE=E.readUInt32LE,t.readUInt32BE=E.readUInt32BE,t.readInt8=E.readInt8,t.readInt16LE=E.readInt16LE,t.readInt16BE=E.readInt16BE,t.readInt32LE=E.readInt32LE,t.readInt32BE=E.readInt32BE,t.readFloatLE=E.readFloatLE,t.readFloatBE=E.readFloatBE,t.readDoubleLE=E.readDoubleLE,t.readDoubleBE=E.readDoubleBE,t.writeUInt8=E.writeUInt8,t.writeUInt16LE=E.writeUInt16LE,t.writeUInt16BE=E.writeUInt16BE,t.writeUInt32LE=E.writeUInt32LE,t.writeUInt32BE=E.writeUInt32BE,t.writeInt8=E.writeInt8,t.writeInt16LE=E.writeInt16LE,t.writeInt16BE=E.writeInt16BE,t.writeInt32LE=E.writeInt32LE,t.writeInt32BE=E.writeInt32BE,t.writeFloatLE=E.writeFloatLE,t.writeFloatBE=E.writeFloatBE,t.writeDoubleLE=E.writeDoubleLE,t.writeDoubleBE=E.writeDoubleBE,t.fill=E.fill,t.inspect=E.inspect,t.toArrayBuffer=E.toArrayBuffer,t}}).call(this,t("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/buffer/index.js","/node_modules/gulp-browserify/node_modules/buffer")},{"base64-js":2,buffer:3,ieee754:10,lYpoI2:11}],4:[function(t,e,n){(function(n,r,o,i,s,a,l,c,u){o=t("buffer").Buffer;var h=new o(4);h.fill(0),e.exports={hash:function(t,e,n,r){for(var i=e(function(t,e){t.length%4!=0&&(n=t.length+(4-t.length%4),t=o.concat([t,h],n));for(var n,r=[],i=e?t.readInt32BE:t.readInt32LE,s=0;s<t.length;s+=4)r.push(i.call(t,s));return r}(t=o.isBuffer(t)?t:new o(t),r),8*t.length),s=(e=r,new o(n)),a=e?s.writeInt32BE:s.writeInt32LE,l=0;l<i.length;l++)a.call(s,i[l],4*l,!0);return s}}}).call(this,t("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/helpers.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{buffer:3,lYpoI2:11}],5:[function(t,e,n){(function(e,r,o,i,s,a,l,c,u){o=t("buffer").Buffer;var h=t("./sha"),d=t("./sha256"),p=t("./rng"),f={sha1:h,sha256:d,md5:t("./md5")},m=64,g=new o(m);function y(t,e){var n=f[t=t||"sha1"],r=[];return n||b("algorithm:",t,"is not yet supported"),{update:function(t){return o.isBuffer(t)||(t=new o(t)),r.push(t),t.length,this},digest:function(t){var i=o.concat(r);return i=e?function(t,e,n){o.isBuffer(e)||(e=new o(e)),o.isBuffer(n)||(n=new o(n)),e.length>m?e=t(e):e.length<m&&(e=o.concat([e,g],m));for(var r=new o(m),i=new o(m),s=0;s<m;s++)r[s]=54^e[s],i[s]=92^e[s];return n=t(o.concat([r,n])),t(o.concat([i,n]))}(n,e,i):n(i),r=null,t?i.toString(t):i}}}function b(){var t=[].slice.call(arguments).join(" ");throw new Error([t,"we accept pull requests","http://github.com/dominictarr/crypto-browserify"].join("\n"))}g.fill(0),n.createHash=function(t){return y(t)},n.createHmac=y,n.randomBytes=function(t,e){if(!e||!e.call)return new o(p(t));try{e.call(this,void 0,new o(p(t)))}catch(t){e(t)}};var v,C=["createCredentials","createCipher","createCipheriv","createDecipher","createDecipheriv","createSign","createVerify","createDiffieHellman","pbkdf2"],x=function(t){n[t]=function(){b("sorry,",t,"is not implemented yet")}};for(v in C)x(C[v])}).call(this,t("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/index.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./md5":6,"./rng":7,"./sha":8,"./sha256":9,buffer:3,lYpoI2:11}],6:[function(t,e,n){(function(n,r,o,i,s,a,l,c,u){var h=t("./helpers");function d(t,e){t[e>>5]|=128<<e%32,t[14+(e+64>>>9<<4)]=e;for(var n=1732584193,r=-271733879,o=-1732584194,i=271733878,s=0;s<t.length;s+=16){var a=n,l=r,c=o,u=i;n=f(n,r,o,i,t[s+0],7,-680876936),i=f(i,n,r,o,t[s+1],12,-389564586),o=f(o,i,n,r,t[s+2],17,606105819),r=f(r,o,i,n,t[s+3],22,-1044525330),n=f(n,r,o,i,t[s+4],7,-176418897),i=f(i,n,r,o,t[s+5],12,1200080426),o=f(o,i,n,r,t[s+6],17,-1473231341),r=f(r,o,i,n,t[s+7],22,-45705983),n=f(n,r,o,i,t[s+8],7,1770035416),i=f(i,n,r,o,t[s+9],12,-1958414417),o=f(o,i,n,r,t[s+10],17,-42063),r=f(r,o,i,n,t[s+11],22,-1990404162),n=f(n,r,o,i,t[s+12],7,1804603682),i=f(i,n,r,o,t[s+13],12,-40341101),o=f(o,i,n,r,t[s+14],17,-1502002290),n=m(n,r=f(r,o,i,n,t[s+15],22,1236535329),o,i,t[s+1],5,-165796510),i=m(i,n,r,o,t[s+6],9,-1069501632),o=m(o,i,n,r,t[s+11],14,643717713),r=m(r,o,i,n,t[s+0],20,-373897302),n=m(n,r,o,i,t[s+5],5,-701558691),i=m(i,n,r,o,t[s+10],9,38016083),o=m(o,i,n,r,t[s+15],14,-660478335),r=m(r,o,i,n,t[s+4],20,-405537848),n=m(n,r,o,i,t[s+9],5,568446438),i=m(i,n,r,o,t[s+14],9,-1019803690),o=m(o,i,n,r,t[s+3],14,-187363961),r=m(r,o,i,n,t[s+8],20,1163531501),n=m(n,r,o,i,t[s+13],5,-1444681467),i=m(i,n,r,o,t[s+2],9,-51403784),o=m(o,i,n,r,t[s+7],14,1735328473),n=g(n,r=m(r,o,i,n,t[s+12],20,-1926607734),o,i,t[s+5],4,-378558),i=g(i,n,r,o,t[s+8],11,-2022574463),o=g(o,i,n,r,t[s+11],16,1839030562),r=g(r,o,i,n,t[s+14],23,-35309556),n=g(n,r,o,i,t[s+1],4,-1530992060),i=g(i,n,r,o,t[s+4],11,1272893353),o=g(o,i,n,r,t[s+7],16,-155497632),r=g(r,o,i,n,t[s+10],23,-1094730640),n=g(n,r,o,i,t[s+13],4,681279174),i=g(i,n,r,o,t[s+0],11,-358537222),o=g(o,i,n,r,t[s+3],16,-722521979),r=g(r,o,i,n,t[s+6],23,76029189),n=g(n,r,o,i,t[s+9],4,-640364487),i=g(i,n,r,o,t[s+12],11,-421815835),o=g(o,i,n,r,t[s+15],16,530742520),n=y(n,r=g(r,o,i,n,t[s+2],23,-995338651),o,i,t[s+0],6,-198630844),i=y(i,n,r,o,t[s+7],10,1126891415),o=y(o,i,n,r,t[s+14],15,-1416354905),r=y(r,o,i,n,t[s+5],21,-57434055),n=y(n,r,o,i,t[s+12],6,1700485571),i=y(i,n,r,o,t[s+3],10,-1894986606),o=y(o,i,n,r,t[s+10],15,-1051523),r=y(r,o,i,n,t[s+1],21,-2054922799),n=y(n,r,o,i,t[s+8],6,1873313359),i=y(i,n,r,o,t[s+15],10,-30611744),o=y(o,i,n,r,t[s+6],15,-1560198380),r=y(r,o,i,n,t[s+13],21,1309151649),n=y(n,r,o,i,t[s+4],6,-145523070),i=y(i,n,r,o,t[s+11],10,-1120210379),o=y(o,i,n,r,t[s+2],15,718787259),r=y(r,o,i,n,t[s+9],21,-343485551),n=b(n,a),r=b(r,l),o=b(o,c),i=b(i,u)}return Array(n,r,o,i)}function p(t,e,n,r,o,i){return b((e=b(b(e,t),b(r,i)))<<o|e>>>32-o,n)}function f(t,e,n,r,o,i,s){return p(e&n|~e&r,t,e,o,i,s)}function m(t,e,n,r,o,i,s){return p(e&r|n&~r,t,e,o,i,s)}function g(t,e,n,r,o,i,s){return p(e^n^r,t,e,o,i,s)}function y(t,e,n,r,o,i,s){return p(n^(e|~r),t,e,o,i,s)}function b(t,e){var n=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(n>>16)<<16|65535&n}e.exports=function(t){return h.hash(t,d,16)}}).call(this,t("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/md5.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],7:[function(t,e,n){(function(t,n,r,o,i,s,a,l,c){e.exports=function(t){for(var e,n=new Array(t),r=0;r<t;r++)!(3&r)&&(e=4294967296*Math.random()),n[r]=e>>>((3&r)<<3)&255;return n}}).call(this,t("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/rng.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{buffer:3,lYpoI2:11}],8:[function(t,e,n){(function(n,r,o,i,s,a,l,c,u){var h=t("./helpers");function d(t,e){t[e>>5]|=128<<24-e%32,t[15+(e+64>>9<<4)]=e;for(var n,r,o,i=Array(80),s=1732584193,a=-271733879,l=-1732584194,c=271733878,u=-1009589776,h=0;h<t.length;h+=16){for(var d=s,m=a,g=l,y=c,b=u,v=0;v<80;v++){i[v]=v<16?t[h+v]:f(i[v-3]^i[v-8]^i[v-14]^i[v-16],1);var C=p(p(f(s,5),(C=a,r=l,o=c,(n=v)<20?C&r|~C&o:!(n<40)&&n<60?C&r|C&o|r&o:C^r^o)),p(p(u,i[v]),(n=v)<20?1518500249:n<40?1859775393:n<60?-1894007588:-899497514));u=c,c=l,l=f(a,30),a=s,s=C}s=p(s,d),a=p(a,m),l=p(l,g),c=p(c,y),u=p(u,b)}return Array(s,a,l,c,u)}function p(t,e){var n=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(n>>16)<<16|65535&n}function f(t,e){return t<<e|t>>>32-e}e.exports=function(t){return h.hash(t,d,20,!0)}}).call(this,t("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/sha.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],9:[function(t,e,n){(function(n,r,o,i,s,a,l,c,u){function h(t,e){var n=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(n>>16)<<16|65535&n}function d(t,e){var n,r=new Array(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),o=new Array(1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225),i=new Array(64);t[e>>5]|=128<<24-e%32,t[15+(e+64>>9<<4)]=e;for(var s,a,l=0;l<t.length;l+=16){for(var c=o[0],u=o[1],d=o[2],p=o[3],g=o[4],y=o[5],b=o[6],v=o[7],C=0;C<64;C++)i[C]=C<16?t[C+l]:h(h(h((a=i[C-2],f(a,17)^f(a,19)^m(a,10)),i[C-7]),(a=i[C-15],f(a,7)^f(a,18)^m(a,3))),i[C-16]),n=h(h(h(h(v,f(a=g,6)^f(a,11)^f(a,25)),g&y^~g&b),r[C]),i[C]),s=h(f(s=c,2)^f(s,13)^f(s,22),c&u^c&d^u&d),v=b,b=y,y=g,g=h(p,n),p=d,d=u,u=c,c=h(n,s);o[0]=h(c,o[0]),o[1]=h(u,o[1]),o[2]=h(d,o[2]),o[3]=h(p,o[3]),o[4]=h(g,o[4]),o[5]=h(y,o[5]),o[6]=h(b,o[6]),o[7]=h(v,o[7])}return o}var p=t("./helpers"),f=function(t,e){return t>>>e|t<<32-e},m=function(t,e){return t>>>e};e.exports=function(t){return p.hash(t,d,32,!0)}}).call(this,t("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/sha256.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],10:[function(t,e,n){(function(t,e,r,o,i,s,a,l,c){n.read=function(t,e,n,r,o){var i,s,a=8*o-r-1,l=(1<<a)-1,c=l>>1,u=-7,h=n?o-1:0,d=n?-1:1;for(o=t[e+h],h+=d,i=o&(1<<-u)-1,o>>=-u,u+=a;0<u;i=256*i+t[e+h],h+=d,u-=8);for(s=i&(1<<-u)-1,i>>=-u,u+=r;0<u;s=256*s+t[e+h],h+=d,u-=8);if(0===i)i=1-c;else{if(i===l)return s?NaN:1/0*(o?-1:1);s+=Math.pow(2,r),i-=c}return(o?-1:1)*s*Math.pow(2,i-r)},n.write=function(t,e,n,r,o,i){var s,a,l=8*i-o-1,c=(1<<l)-1,u=c>>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:i-1,p=r?1:-1;for(i=e<0||0===e&&1/e<0?1:0,e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=c):(s=Math.floor(Math.log(e)/Math.LN2),e*(r=Math.pow(2,-s))<1&&(s--,r*=2),2<=(e+=1<=s+u?h/r:h*Math.pow(2,1-u))*r&&(s++,r/=2),c<=s+u?(a=0,s=c):1<=s+u?(a=(e*r-1)*Math.pow(2,o),s+=u):(a=e*Math.pow(2,u-1)*Math.pow(2,o),s=0));8<=o;t[n+d]=255&a,d+=p,a/=256,o-=8);for(s=s<<o|a,l+=o;0<l;t[n+d]=255&s,d+=p,s/=256,l-=8);t[n+d-p]|=128*i}}).call(this,t("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/ieee754/index.js","/node_modules/gulp-browserify/node_modules/ieee754")},{buffer:3,lYpoI2:11}],11:[function(t,e,n){(function(t,n,r,o,i,s,a,l,c){var u,h,d;function p(){}(t=e.exports={}).nextTick=(h="undefined"!=typeof window&&window.setImmediate,d="undefined"!=typeof window&&window.postMessage&&window.addEventListener,h?function(t){return window.setImmediate(t)}:d?(u=[],window.addEventListener("message",(function(t){var e=t.source;e!==window&&null!==e||"process-tick"!==t.data||(t.stopPropagation(),0<u.length&&u.shift()())}),!0),function(t){u.push(t),window.postMessage("process-tick","*")}):function(t){setTimeout(t,0)}),t.title="browser",t.browser=!0,t.env={},t.argv=[],t.on=p,t.addListener=p,t.once=p,t.off=p,t.removeListener=p,t.removeAllListeners=p,t.emit=p,t.binding=function(t){throw new Error("process.binding is not supported")},t.cwd=function(){return"/"},t.chdir=function(t){throw new Error("process.chdir is not supported")}}).call(this,t("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/process/browser.js","/node_modules/gulp-browserify/node_modules/process")},{buffer:3,lYpoI2:11}]},{},[1])(1)},9146:(t,e)=>{"use strict";var n;!function(){var r=e||{}||this||window;void 0===(n=function(){return r}.apply(e,[]))||(t.exports=n),r.default=r;var o="http://www.w3.org/2000/xmlns/",i="http://www.w3.org/2000/svg",s=/url\(["']?(.+?)["']?\)/,a={woff2:"font/woff2",woff:"font/woff",otf:"application/x-font-opentype",ttf:"application/x-font-ttf",eot:"application/vnd.ms-fontobject",sfnt:"application/font-sfnt",svg:"image/svg+xml"},l=function(t){return t instanceof HTMLElement||t instanceof SVGElement},c=function(t){if(!l(t))throw new Error("an HTMLElement or SVGElement is required; got "+t)},u=function(t){return new Promise((function(e,n){l(t)?e(t):n(new Error("an HTMLElement or SVGElement is required; got "+t))}))},h=function(t,e,n){var r=t.viewBox&&t.viewBox.baseVal&&t.viewBox.baseVal[n]||null!==e.getAttribute(n)&&!e.getAttribute(n).match(/%$/)&&parseInt(e.getAttribute(n))||t.getBoundingClientRect()[n]||parseInt(e.style[n])||parseInt(window.getComputedStyle(t).getPropertyValue(n));return null==r||isNaN(parseFloat(r))?0:r},d=function(t){for(var e=window.atob(t.split(",")[1]),n=t.split(",")[0].split(":")[1].split(";")[0],r=new ArrayBuffer(e.length),o=new Uint8Array(r),i=0;i<e.length;i++)o[i]=e.charCodeAt(i);return new Blob([r],{type:n})},p={},f=null,m=function(t,e){var n=e||{},r=n.selectorRemap,o=n.modifyStyle,i=n.modifyCss,l=n.fonts,c=n.excludeUnusedCss,u=i||function(t,e){return(r?r(t):t)+"{"+(o?o(e):e)+"}\n"},h=[],d=void 0===l,m=l||[];return(f||(f=Array.from(document.styleSheets).map((function(t){try{return{rules:t.cssRules,href:t.href}}catch(e){return console.warn("Stylesheet could not be loaded: "+t.href,e),{}}})))).forEach((function(e){var n=e.rules,r=e.href;n&&Array.from(n).forEach((function(e){if(void 0!==e.style)if(function(t,e){if(e)try{return t.querySelector(e)||t.parentNode&&t.parentNode.querySelector(e)}catch(t){console.warn('Invalid CSS selector "'+e+'"',t)}}(t,e.selectorText))h.push(u(e.selectorText,e.style.cssText));else if(d&&e.cssText.match(/^@font-face/)){var n=function(t,e){var n=t.cssText.match(s),r=n&&n[1]||"";if(r&&!r.match(/^data:/)&&"about:blank"!==r){var o,i,l=r.startsWith("../")?e+"/../"+r:r.startsWith("./")?e+"/."+r:r;return{text:t.cssText,format:(o=l,i=Object.keys(a).filter((function(t){return o.indexOf("."+t)>0})).map((function(t){return a[t]})),i?i[0]:(console.error("Unknown font format for "+o+". Fonts may not be working correctly."),"application/octet-stream")),url:l}}}(e,r);n&&m.push(n)}else c||h.push(e.cssText)}))})),function(t){return Promise.all(t.map((function(t){return new Promise((function(e,n){if(p[t.url])return e(p[t.url]);var r=new XMLHttpRequest;r.addEventListener("load",(function(){var n=function(t){for(var e="",n=new Uint8Array(t),r=0;r<n.byteLength;r++)e+=String.fromCharCode(n[r]);return window.btoa(e)}(r.response),o=t.text.replace(s,'url("data:'+t.format+";base64,"+n+'")')+"\n";p[t.url]=o,e(o)})),r.addEventListener("error",(function(n){console.warn("Failed to load font from: "+t.url,n),p[t.url]=null,e(null)})),r.addEventListener("abort",(function(n){console.warn("Aborted loading font from: "+t.url,n),e(null)})),r.open("GET",t.url),r.responseType="arraybuffer",r.send()}))}))).then((function(t){return t.filter((function(t){return t})).join("")}))}(m).then((function(t){return h.join("\n")+t}))},g=function(){if(!navigator.msSaveOrOpenBlob&&!("download"in document.createElement("a")))return{popup:window.open()}};r.prepareSvg=function(t,e,n){c(t);var r=e||{},s=r.left,a=void 0===s?0:s,l=r.top,u=void 0===l?0:l,d=r.width,p=r.height,f=r.scale,g=void 0===f?1:f,y=r.responsive,b=void 0!==y&&y,v=r.excludeCss,C=void 0!==v&&v;return function(t){return Promise.all(Array.from(t.querySelectorAll("image")).map((function(t){var e,n=t.getAttributeNS("http://www.w3.org/1999/xlink","href")||t.getAttribute("href");return n?((e=n)&&0===e.lastIndexOf("http",0)&&-1===e.lastIndexOf(window.location.host)&&(n+=(-1===n.indexOf("?")?"?":"&")+"t="+(new Date).valueOf()),new Promise((function(e,r){var o=document.createElement("canvas"),i=new Image;i.crossOrigin="anonymous",i.src=n,i.onerror=function(){return r(new Error("Could not load "+n))},i.onload=function(){o.width=i.width,o.height=i.height,o.getContext("2d").drawImage(i,0,0),t.setAttributeNS("http://www.w3.org/1999/xlink","href",o.toDataURL("image/png")),e(!0)}}))):Promise.resolve(null)})))}(t).then((function(){var r=t.cloneNode(!0);r.style.backgroundColor=(e||{}).backgroundColor||t.style.backgroundColor;var s=function(t,e,n,r){if("svg"===t.tagName)return{width:n||h(t,e,"width"),height:r||h(t,e,"height")};if(t.getBBox){var o=t.getBBox(),i=o.x,s=o.y;return{width:i+o.width,height:s+o.height}}}(t,r,d,p),l=s.width,c=s.height;if("svg"!==t.tagName){if(!t.getBBox)return void console.error("Attempted to render non-SVG element",t);null!=r.getAttribute("transform")&&r.setAttribute("transform",r.getAttribute("transform").replace(/translate\(.*?\)/,""));var f=document.createElementNS("http://www.w3.org/2000/svg","svg");f.appendChild(r),r=f}if(r.setAttribute("version","1.1"),r.setAttribute("viewBox",[a,u,l,c].join(" ")),r.getAttribute("xmlns")||r.setAttributeNS(o,"xmlns",i),r.getAttribute("xmlns:xlink")||r.setAttributeNS(o,"xmlns:xlink","http://www.w3.org/1999/xlink"),b?(r.removeAttribute("width"),r.removeAttribute("height"),r.setAttribute("preserveAspectRatio","xMinYMin meet")):(r.setAttribute("width",l*g),r.setAttribute("height",c*g)),Array.from(r.querySelectorAll("foreignObject > *")).forEach((function(t){t.setAttributeNS(o,"xmlns","svg"===t.tagName?i:"http://www.w3.org/1999/xhtml")})),!C)return m(t,e).then((function(t){var e=document.createElement("style");e.setAttribute("type","text/css"),e.innerHTML="<![CDATA[\n"+t+"\n]]>";var o=document.createElement("defs");o.appendChild(e),r.insertBefore(o,r.firstChild);var i=document.createElement("div");i.appendChild(r);var s=i.innerHTML.replace(/NS\d+:href/gi,'xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href');if("function"!=typeof n)return{src:s,width:l,height:c};n(s,l,c)}));var y=document.createElement("div");y.appendChild(r);var v=y.innerHTML;if("function"!=typeof n)return{src:v,width:l,height:c};n(v,l,c)}))},r.svgAsDataUri=function(t,e,n){return c(t),r.prepareSvg(t,e).then((function(t){var e=t.src,r=t.width,o=t.height,i="data:image/svg+xml;base64,"+window.btoa(decodeURIComponent(encodeURIComponent('<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [<!ENTITY nbsp "&#160;">]>'+e).replace(/%([0-9A-F]{2})/g,(function(t,e){var n=String.fromCharCode("0x"+e);return"%"===n?"%25":n}))));return"function"==typeof n&&n(i,r,o),i}))},r.svgAsPngUri=function(t,e,n){c(t);var o=e||{},i=o.encoderType,s=void 0===i?"image/png":i,a=o.encoderOptions,l=void 0===a?.8:a,u=o.canvg,h=function(t){var e=t.src,r=t.width,o=t.height,i=document.createElement("canvas"),a=i.getContext("2d"),c=window.devicePixelRatio||1;i.width=r*c,i.height=o*c,i.style.width=i.width+"px",i.style.height=i.height+"px",a.setTransform(c,0,0,c,0,0),u?u(i,e):a.drawImage(e,0,0);var h=void 0;try{h=i.toDataURL(s,l)}catch(t){if("undefined"!=typeof SecurityError&&t instanceof SecurityError||"SecurityError"===t.name)return void console.error("Rendered SVG images cannot be downloaded in this browser.");throw t}return"function"==typeof n&&n(h,i.width,i.height),Promise.resolve(h)};return u?r.prepareSvg(t,e).then(h):r.svgAsDataUri(t,e).then((function(t){return new Promise((function(e,n){var r=new Image;r.onload=function(){return e(h({src:r,width:r.width,height:r.height}))},r.onerror=function(){n("There was an error loading the data URI as an image on the following SVG\n"+window.atob(t.slice(26))+"Open the following link to see browser's diagnosis\n"+t)},r.src=t}))}))},r.download=function(t,e,n){if(navigator.msSaveOrOpenBlob)navigator.msSaveOrOpenBlob(d(e),t);else{var r=document.createElement("a");if("download"in r){r.download=t,r.style.display="none",document.body.appendChild(r);try{var o=d(e),i=URL.createObjectURL(o);r.href=i,r.onclick=function(){return requestAnimationFrame((function(){return URL.revokeObjectURL(i)}))}}catch(t){console.error(t),console.warn("Error while getting object URL. Falling back to string URL."),r.href=e}r.click(),document.body.removeChild(r)}else n&&n.popup&&(n.popup.document.title=t,n.popup.location.replace(e))}},r.saveSvg=function(t,e,n){var o=g();return u(t).then((function(t){return r.svgAsDataUri(t,n||{})})).then((function(t){return r.download(e,t,o)}))},r.saveSvgAsPng=function(t,e,n){var o=g();return u(t).then((function(t){return r.svgAsPngUri(t,n||{})})).then((function(t){return r.download(e,t,o)}))}}()},5072:t=>{"use strict";var e=[];function n(t){for(var n=-1,r=0;r<e.length;r++)if(e[r].identifier===t){n=r;break}return n}function r(t,r){for(var i={},s=[],a=0;a<t.length;a++){var l=t[a],c=r.base?l[0]+r.base:l[0],u=i[c]||0,h="".concat(c," ").concat(u);i[c]=u+1;var d=n(h),p={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==d)e[d].references++,e[d].updater(p);else{var f=o(p,r);r.byIndex=a,e.splice(a,0,{identifier:h,updater:f,references:1})}s.push(h)}return s}function o(t,e){var n=e.domAPI(e);return n.update(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap&&e.supports===t.supports&&e.layer===t.layer)return;n.update(t=e)}else n.remove()}}t.exports=function(t,o){var i=r(t=t||[],o=o||{});return function(t){t=t||[];for(var s=0;s<i.length;s++){var a=n(i[s]);e[a].references--}for(var l=r(t,o),c=0;c<i.length;c++){var u=n(i[c]);0===e[u].references&&(e[u].updater(),e.splice(u,1))}i=l}}},7659:t=>{"use strict";var e={};t.exports=function(t,n){var r=function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(t){n=null}e[t]=n}return e[t]}(t);if(!r)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");r.appendChild(n)}},540:t=>{"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},5056:(t,e,n)=>{"use strict";t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},7825:t=>{"use strict";t.exports=function(t){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=t.insertStyleElement(t);return{update:function(n){!function(t,e,n){var r="";n.supports&&(r+="@supports (".concat(n.supports,") {")),n.media&&(r+="@media ".concat(n.media," {"));var o=void 0!==n.layer;o&&(r+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),r+=n.css,o&&(r+="}"),n.media&&(r+="}"),n.supports&&(r+="}");var i=n.sourceMap;i&&"undefined"!=typeof btoa&&(r+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(i))))," */")),e.styleTagTransform(r,t,e.options)}(e,t,n)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},1113:t=>{"use strict";t.exports=function(t,e){if(e.styleSheet)e.styleSheet.cssText=t;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(t))}}},6686:(t,e,n)=>{"use strict";n.d(e,{AL:()=>r,NO:()=>o});const r=["A","G","C","U"];var o;!function(t){t.HELM="HELM",t.AXOLABS="Axolabs"}(o||(o={}))},9537:(t,e,n)=>{"use strict";n.d(e,{iL:()=>i,q7:()=>o,ti:()=>r});const r={NUCLEOSIDE:"nucleoside",LINKAGE:"phosphateBackbone"},o="p",i="<?>"},3480:(t,e,n)=>{"use strict";n.d(e,{C6:()=>l,Hs:()=>a,OT:()=>c,bD:()=>s});var r=n(6686),o=n(5067),i=n(9537);function s(t,e,n,o){const i=Object.keys(o.jsonData.codesToHelmDict).concat([r.NO.HELM]);if(!t||-1!==e&&n!==r.NO.HELM)return{};if(!i.includes(n))throw new Error(`${n} format is not supported by SequenceTranslator`);const s=i.filter((t=>t!=n)).sort(((t,e)=>t.localeCompare(e))),l=o.createFormatConverter(t,n),c=Object.fromEntries(s.map((t=>{let e;try{e=l.convertTo(t)}catch{e=null}return[t,e]})).filter((([t,e])=>e))),u=a(n===r.NO.HELM?t:c[r.NO.HELM],o.monomerLibWrapper);return u&&(c.Nucleotides=u),c}function a(t,e){const n=new RegExp("\\([^()]*\\)","g"),o=t.match(n);return o?o.map((t=>{const n=t.replace(/[\[\]()]/g,"");return r.AL.includes(n)?n:e.getNaturalAnalogBySymbol(n)})).map((t=>t||i.iL)).join(""):null}function l(t,e,n,i){const s=i.createFormatConverter(t,e);return n===o.qP?a(s.convertTo(r.NO.HELM),i.monomerLibWrapper):s.convertTo(n)}function c(t){return Object.keys(t.jsonData.codesToHelmDict).concat([r.NO.HELM,o.qP]).sort()}},5067:(t,e,n)=>{"use strict";n.d(e,{U_:()=>o,n_:()=>r,qP:()=>i});const r="Copied",o="Copy sequence",i="Nucleotides"},2018:(t,e,n)=>{"use strict";n.d(e,{PackageFunctions:()=>Qr,_package:()=>Yr});var r=n(4328),o=n(6082),i=n(439),s=n(7291);const a=new class{constructor(){this.seqHandler="seq-handler",this.notationProvider="seq-handler.notation-provider"}};o.SemanticValue;var l=n(4971);class c{constructor(t,e,n=""){this.target=t,this.debugEnabled=e,this.prefix=n}error(t,e,n){return this.target.error(this.prefix+t,e,n)}warning(t,e){return this.target.warning(this.prefix+t,e)}info(t,e){return this.target.info(this.prefix+t,e)}debug(t,e){if(this.debugEnabled)return this.target.debug(this.prefix+t,e)}}const u="System:AppData/SequenceTranslator/monomers-sample",h="pattern-app-data.json",d="formats-to-helm.json",p="codes-to-symbols.json",f="linkers.json";var m=n(6686);function g(t){return t.sort(((t,e)=>e.length-t.length))}function y(t,e){const n=document.createElement("a");n.setAttribute("href","data:text/plain;charset=utf-8,"+e),n.setAttribute("download",t),n.click()}async function b(t,e,n="Oligo app"){try{return await t()}catch(t){const e=t.hasOwnProperty("message")?t.message:t.toString();throw r.shell.error(`${n} error: `+e),t}finally{e&&e()}}class v{constructor(t,e){this.sequence=t,this.th=e,this.libWrapper=this.th.monomerLibWrapper}getInvalidCodeIndex(t){if(t===m.NO.HELM)return this.sequence.length;const e=["r","d"],n=g(this.libWrapper.getCodesByFormat(t));let r=0;for(;r<this.sequence.length;){const t=n.find((t=>t===this.sequence.substring(r,r+t.length)));if(!t)break;if(r>1&&m.AL.includes(this.sequence[r])&&e.includes(this.sequence[r-2]))break;if(e.includes(this.sequence[r+1])&&m.AL.includes(this.sequence[r])){r++;break}r+=t.length}return r===this.sequence.length&&(r=-1),r}isValidSequence(t){return-1===this.getInvalidCodeIndex(t)}}class C{constructor(t,e,n,r){this.patternAppData=t,this.codesToHelmDict=e,this.codesToSymbolsDict=n,this.monomersWithPhosphate=r}}async function x(t){const e=await Promise.all([h,d,p,f].map((e=>async function(t,e){const n=t.endsWith("/")?`${t}${e}`:`${t}/${e}`;try{const t=await r.dapi.files.readAsText(n);return JSON.parse(t)}catch(t){console.error(`Error loading json from '${n}':`,t)}}(t,e))));return new C(e[0],e[1],e[2],e[3])}class w{constructor(t,e){if(this.lib=t,this.jsonData=e,null===this.lib)throw new Error("SequenceTranslator: monomer library is null");this.allMonomers=this.getAllMonomers()}formatMonomerForViewer(t){const e={};return e.name=t.symbol,e.symbol=t.symbol,e.molfile=t.molfile,this.getAllFormats().forEach((n=>{if(n===m.NO.HELM)return;const r=this.jsonData.codesToSymbolsDict[n],o=Object.keys(r).filter((e=>r[e]===t.symbol));e[n]=o.join(", ")})),e}getAllMonomers(){const t=this.lib.getPolymerTypes();let e=[];for(const n of t){const t=this.lib.getMonomerSymbolsByType(n).map((t=>this.lib.getMonomer(n,t))).filter((t=>null!==t));e=e.concat(t)}return e}getMonomer(t){const e=this.lib.getMonomer("RNA",t);if(void 0===e)throw new Error(`SequenceTranslator: no monomer with symbol ${t}`);return e}getMolfileBySymbol(t){return this.getMonomer(t).molfile}getNaturalAnalogBySymbol(t){const e=this.getMonomer(t).naturalAnalog;if(!e)throw new Error(`ST: no natural analog for ${t}`);return e}isModification(t){return!!this.getMolfileBySymbol(t).includes("MODIFICATION")}getCodeToSymbolMap(t){return new Map(Object.entries(this.jsonData.codesToSymbolsDict[t]))}getCodesByFormat(t){return Object.keys(this.jsonData.codesToSymbolsDict[t])}getAllFormats(){return Object.keys(this.jsonData.codesToSymbolsDict)}getTableForViewer(){const t=this.allMonomers.map((t=>this.formatMonomerForViewer(t)));return o.DataFrame.fromObjects(t)}getCodesToWeightsMap(){const t=new Map;return Object.entries(this.jsonData.codesToSymbolsDict).forEach((([e,n])=>{Object.entries(n).forEach((([e,n])=>{const r=this.getMonomer(n),o=r.meta?.molecularWeight;t.set(e,o)}))})),t}}var A=n(9537);const T=(t,e)=>e.length-t.length;class E{constructor(t){this.th=t,this.formats=this.getFormats()}getFormatNames(){return this.formats.sort()}getCodesByFormat(t){if(this.validateFormat(t),this.isHelm(t))throw new Error("Codes cannot be obtained for HELM");return this.getFormatCodes(t)}getHelmToFormatDict(t){return this.validateFormat(t),function(t){const e={};return Object.values(t).forEach((t=>{Object.entries(t).forEach((([t,n])=>{const r=n.replace(/\)p/g,")").replace(/\]p/g,"]");void 0===e[r]?e[r]=[t]:e[r].push(t)}))})),Object.entries(e).forEach((([t,n])=>{const r=n.sort(T);e[t]=r[0]})),e}(this.th.jsonData.codesToHelmDict[t])}getFormatToHelmDict(t){this.validateFormat(t);const e=this.th.jsonData.codesToHelmDict[t];return Object.assign({},...Object.values(e))}getTargetFormatHelmCodes(t){this.validateFormat(t);const e=this.getHelmToFormatDict(t);return Object.keys(e).sort(T)}getTargetFormatHelmCodesRegExp(t){this.validateFormat(t);const e=this.getTargetFormatHelmCodes(t);return new RegExp(S(e)+"|.","g")}getFormatRegExp(t){if(this.validateFormat(t),this.isHelm(t))throw new Error("Helm RegExp can be built for non-HELM target formats");return this.getNonHelmFormatRegExp(t)}getPhosphateHelmCodesRegExp(t){this.validateFormat(t);const e=this.th.jsonData.codesToHelmDict[t],n=S(Array.from(new Set(Object.values(e[A.ti.LINKAGE]))).sort(T));return new RegExp(`${A.q7}.(${n})`,"g")}isValidFormat(t){return this.formats.includes(t)}getFormats(){return Object.keys(this.th.jsonData.codesToHelmDict)}validateFormat(t){if(!this.isValidFormat(t))throw new Error(`Invalid format: ${t}`)}isHelm(t){return t===m.NO.HELM}getFormatCodes(t){const e=this.getFormatToHelmDict(t);return Object.keys(e).sort(T)}getNonHelmFormatRegExp(t){const e=this.getCodesByFormat(t);return new RegExp(S(e)+"|\\([^()]*\\)|.","g")}}function S(t){return t.map((t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"))).map((t=>t.includes("(")||t.includes(")")?t:`(?<!\\([^()]*)${t}(?![^()]*\\))`)).join("|")}const I={LEFT:"RNA1{",RIGHT:"}$$$$"};class N{constructor(t,e,n){this.sequence=t,this.sourceFormat=e,this.th=n,this.formats=new E(this.th)}convertTo(t){const e=this.formats.getFormatNames();if(this.sourceFormat===m.NO.HELM&&e.includes(t))return this.helmToFormat(this.sequence,t);if(e.includes(this.sourceFormat)&&t===m.NO.HELM)return this.formatToHelm(this.sequence,this.sourceFormat);if([this.sourceFormat,t].every((t=>e.includes(t)))){const e=this.formatToHelm(this.sequence,this.sourceFormat);return this.helmToFormat(e,t)}throw new Error(`ST: unsupported translation direction ${this.sourceFormat} -> ${t}`)}helmToFormat(t,e){const n=new RegExp(S(Object.values(I)),"g");let r=t.replace(n,"");const o=this.formats.getHelmToFormatDict(e),i=this.formats.getTargetFormatHelmCodes(e),s=this.formats.getTargetFormatHelmCodesRegExp(e);return r=r.replace(s,(t=>i.includes(t)?o[t]:"p"===t||"."===t?t:"?")).replace(/\?+/g,A.iL).replace(/p\.|\./g,""),r=r.replace(/<empty>/g,""),r=r.replace(/\/\//g,"/"),r}formatToHelm(t,e){const n=this.formats.getFormatToHelmDict(e),r=this.formats.getCodesByFormat(e),o=this.formats.getFormatRegExp(e),i=this.formats.getPhosphateHelmCodesRegExp(e);let s=t?t.replace(o,(t=>r.includes(t)?n[t]+".":"?")):"";return s=s.replace(/\?+/g,`${A.iL}.`),s=s.slice(0,-1),s[s.length-1]===A.q7&&(s=s.slice(0,-1)),s=s.replace(i,((t,e)=>e)),s=s.replace(/<empty>/g,""),`${I.LEFT+s+I.RIGHT}`}}class _{constructor(t,e){this.sequence=t,this.th=e,this.libWrapper=this.th.monomerLibWrapper,this.formats=Object.keys(this.th.jsonData.codesToHelmDict)}getFormat(){if(this.sequence.startsWith("RNA"))return m.NO.HELM;const t=this.getListOfPossibleSynthesizersByFirstMatchedCode();if(0===t.length)return null;const e=this.th.createSequenceValidator(this.sequence),n=Array(t.length).fill(0);for(let r=0;r<t.length;++r){const o=t[r];n[r]=e.getInvalidCodeIndex(o)}const r=n.some((t=>-1===t))?-1:Math.max(...n);return t[n.indexOf(r)]}getListOfPossibleSynthesizersByFirstMatchedCode(){const t=this.sequence,e=[];for(const n of this.formats){const r=g(this.libWrapper.getCodesByFormat(n));let o=0;for(let e=0;e<t.length;e++)if(")"===t[e]&&e!==t.length-1){o=e+1;break}r.some((e=>e===t.slice(o,o+e.length)))&&e.push(n)}return e}}var P=n(7389);const M=$;var L=n.n(M);function O(t,e){let n=0;const r=e.createFormatDetector(t).getFormat();null!==r&&(n=new v(t,e).getInvalidCodeIndex(r));const o=n<0||""===t,i=P.span([]);L()(i).css("-webkit-text-fill-color","var(--grey-6)");const s=P.span([]);return L()(s).css("-webkit-text-fill-color","red"),o?i.innerHTML=t:(i.innerHTML=t.slice(0,n),s.innerHTML=t.slice(n)),[i,s]}class R extends o.Package{get helmHelper(){if(!this._helmHelper)throw new Error("Package SequenceTranslator .helmHelper is not initialized");return this._helmHelper}get seqHelper(){return this._helmHelper.seqHelper}get monomerLib(){if(!this._monomerLib)throw new Error("Monomer lib not loaded");return this._monomerLib}get jsonData(){if(!this._jsonData)throw new Error("Json data not loaded");return this._jsonData}get monomerLibWrapper(){if(!this._monomerLibWrapper)throw new Error("Monomer lib wrapper not loaded");return this._monomerLibWrapper}get initPromise(){return this._initPromise}constructor(t={debug:!1}){super(),this.highlightInvalidSubsequence=t=>O(t,this),super._logger=new c(super.logger,t.debug)}startInit(t){this._initPromise=t}completeInit(t){this._helmHelper=t}async initLibData(){return this.initLibDataPromise||(this.initLibDataPromise=(async()=>{const t=await this.getSettings();let e=t instanceof Map?t.get("MonomersPath"):t.MonomersPath;e&&await r.dapi.files.exists(e)||(this.logger.warning(`Monomers path '${e}' not found. Fallback to monomers sample path '${u}'.`),e=u),[this._jsonData,this._monomerLib]=await Promise.all([x(e),D(e)]),this._monomerLibWrapper=new w(this.monomerLib,this.jsonData)})()),this.initLibDataPromise}async getTranslationHelper(){return await r.functions.call(`${this.name}:getTranslationHelper`)}createSequenceValidator(t){return new v(t,this)}createFormatConverter(t,e){return new N(t,e,this)}createFormatDetector(t){return new _(t,this)}}async function D(t){const e=o.TaskBarProgressIndicator.create("Initializing Oligo Toolkit monomer library ...");try{const e=await(0,l.pj)(),n=(t.endsWith("/")?t:t+"/")+"monomer-lib.json";return await e.readLibraryFromFilePath(n)}finally{e.close()}}class B{constructor(t,e){this.appName=t,this.parentAppName=e}async getAppView(){const t=o.TaskBarProgressIndicator.create(`Loading ${this.appName}...`),e=r.shell.v?.root;e&&P.setUpdateIndicator(e,!0);try{return await this.constructView()}finally{t.close(),e&&P.setUpdateIndicator(e,!1)}}}class F extends B{constructor(t){super(t),this.view=o.View.create(),this.configureView()}async constructView(){await this.initView();const t=this.parentAppName?this.parentAppName+"/"+this.appName:this.appName;return this.view.path=`/apps/${Yr.name}/${t.replace(/\s/g,"")}/`,this.view}async initView(){const t=await this.getContent();this.view.append(t)}configureView(){this.view.box=!0,this.view.name=this.appName;const t=r.shell.windows;t.showProperties=!1,t.showToolbox=!1,t.showHelp=!1}getView(){return this.view}}const k=["SS","AS"],H={SS:"Sense strand",AS:"Anti sense"},G=["3'","5'"],V="OligoToolkit";var U,j,q,W;!function(t){t.IS_ANTISENSE_STRAND_INCLUDED="isAntisenseStrandIncluded",t.NUCLEOTIDE_SEQUENCES="nucleotideSequences",t.PHOSPHOROTHIOATE_LINKAGE_FLAGS="phosphorothioateLinkageFlags",t.STRAND_TERMINUS_MODIFICATIONS="strandTerminusModifications"}(U||(U={})),function(t){t.PATTERN_NAME="patternName",t.PATTERN_COMMENT="patternComment",t.NUCLEOTIDES_WITH_NUMERIC_LABELS="nucleotidesWithNumericLabels"}(j||(j={})),function(t){t.PATTERN_CONFIG="patternConfig",t.AUTHOR_ID="authorID",t.DATE="date"}(q||(q={})),function(t){t.CREATE="create",t.MODIFY="modify"}(W||(W={}));const z=[U.IS_ANTISENSE_STRAND_INCLUDED,U.NUCLEOTIDE_SEQUENCES,U.PHOSPHOROTHIOATE_LINKAGE_FLAGS,U.STRAND_TERMINUS_MODIFICATIONS],Y=(j.PATTERN_NAME,j.PATTERN_COMMENT,j.NUCLEOTIDES_WITH_NUMERIC_LABELS,{patternConfig:{patternName:"<default example>",isAntisenseStrandIncluded:!0,nucleotideSequences:{SS:["RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA"],AS:["RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA"]},phosphorothioateLinkageFlags:{SS:[!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0],AS:[!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0]},strandTerminusModifications:{SS:{"3'":"","5'":""},AS:{"3'":"","5'":""}},patternComment:"",nucleotidesWithNumericLabels:["RNA"]},authorID:""}),K="2024-01-01T18:00:00.000Z";class Q extends Error{constructor(t){super(t),this.name="PatternNameExistsError"}}class J extends Error{constructor(t){super(t),this.name="PatternExistsError"}}var X=n(4802),Z=n.n(X);class tt{constructor(t){this.th=t,this.otherUsersPatternNameToHash=new Map,this.currentUserPatternNameToHash=new Map}static async getInstance(){const t=await Yr.getTranslationHelper(),e=new tt(t);e.currentUserName=await e.fetchCurrentUserName(),e.currentUserId=await e.fetchCurrentUserId();const n=e.fetchPatterns();return await e.initializePatternMaps(n),e}getCurrentUserPatternNames(){return Array.from(this.currentUserPatternNameToHash.keys()).sort(((t,e)=>t.toLowerCase().localeCompare(e.toLowerCase())))}getOtherUsersPatternNames(){return Array.from(this.otherUsersPatternNameToHash.keys()).sort(((t,e)=>t.toLowerCase().localeCompare(e.toLowerCase())))}getCurrentUserName(){return this.currentUserName}validatePatternNameUniqueness(t){if(this.currentUserPatternNameToHash.has(t))throw new Q(`Pattern with name ${t} already exists`)}validatePatternUniqueness(t){if(Array.from(this.currentUserPatternNameToHash.values()).concat(Array.from(this.otherUsersPatternNameToHash.values())).includes(t))throw new J(t)}getPatternHash(t,e){const n=e?this.currentUserPatternNameToHash.get(t):this.otherUsersPatternNameToHash.get(t);if(void 0===n)throw new Error(`Pattern with name ${t} not found`);return n}async getPatternRecordByHash(t){if(null===t||""===t)return null;try{const e=r.userSettings.getValue(V,t,!1)??"null";return JSON.parse(e)}catch{return null}}async getPatternConfig(t){if(""===t||null===t)return null;const e=await this.getPatternRecordByHash(t);return null===e?null:e[q.PATTERN_CONFIG]}getDefaultPatternRecord(){const t=Y;return t[q.AUTHOR_ID]=this.currentUserId,t}getDefaultPatternConfig(){return Y[q.PATTERN_CONFIG]}getAuthorCategoryByHash(t){if(this.isCurrentUserPattern(t))return this.getCurrentUserAuthorshipCategory();if(this.isOtherUserPattern(t))return this.getOtherUsersAuthorshipCategory();throw new Error(`Pattern with hash ${t} not found`)}isCurrentUserPattern(t){return Array.from(this.currentUserPatternNameToHash.values()).includes(t)}isOtherUserPattern(t){return Array.from(this.otherUsersPatternNameToHash.values()).includes(t)}getPatternNameByHash(t){const e=[this.currentUserPatternNameToHash,this.otherUsersPatternNameToHash];for(const n of e)for(const[e,r]of n.entries())if(r===t)return e;throw new Error(`Pattern with hash ${t} not found`)}getHashOfPatternToBeLoadedAfterDeletion(){const t=this.getCurrentUserPatternNames()[0];if(!t)throw new Error("Cannot load pattern after deletion, as there are no patterns left");const e=this.currentUserPatternNameToHash.get(t);if(void 0===e)throw new Error(`Pattern with name ${t} not found`);return e}async getRecordFromPattern(t){return{[q.PATTERN_CONFIG]:t,[q.AUTHOR_ID]:await r.dapi.users.current().then((t=>t.id))}}getHash(t){const e=z.reduce(((e,n)=>(e[n]=t[n],e)),{});return Z().sha1(e)}async savePatternToUserStorage(t){const e=t.getPatternConfig();try{const n=this.getHash(e);this.validatePatternUniqueness(n);const o=e[j.PATTERN_NAME];this.validatePatternNameUniqueness(o);const i=await this.getRecordFromPattern(e),s=(new Date).toISOString();i[q.DATE]={[W.CREATE]:s,[W.MODIFY]:s};const a=JSON.stringify(i);r.userSettings.add(V,n,a,!1),this.currentUserPatternNameToHash.set(o,n),t.selectAuthor(this.getCurrentUserAuthorshipCategory()),t.updatePatternList(),t.requestPatternLoad(n),t.updateUrlState(n)}catch(t){if(t instanceof Q||t instanceof J)throw t;console.error("Error while saving pattern to user storage",t)}}async overwriteExistingPatternInUserStorage(t){const e=t.getPatternConfig(),n=e[j.PATTERN_NAME],o=this.currentUserPatternNameToHash.get(n);if(void 0===o)throw new Error("Old hash is undefined");const i=this.getHash(e),s=await this.getRecordFromPattern(e),a=(new Date).toISOString();s[q.DATE]={[W.MODIFY]:a};const l=r.userSettings.getValue(V,o,!1)??"null",c=JSON.parse(l);void 0!==c[q.DATE]&&null!=c[q.DATE][W.CREATE]&&(s[q.DATE][W.CREATE]=c[q.DATE][W.CREATE]);const u=JSON.stringify(s);r.userSettings.add(V,i,u,!1),r.userSettings.delete(V,o,!1),this.currentUserPatternNameToHash.set(n,i),t.requestPatternLoad(i),t.updateUrlState(i)}async deletePattern(t,e){const n=this.currentUserPatternNameToHash.get(t);if(t===this.getDefaultPatternName())return void r.shell.warning("Cannot delete default pattern");if(void 0===n)throw new Error(`Pattern with name ${t} not found`);r.userSettings.delete(V,n,!1),this.currentUserPatternNameToHash.delete(t),e.updatePatternList();const o=this.getHashOfPatternToBeLoadedAfterDeletion();e.requestPatternLoad(o)}fetchDefaultNucleobase(){return this.fetchAvailableNucleotideBases()[0]}fetchAvailableNucleotideBases(){const t=Object.keys(this.th.jsonData.patternAppData)[0];return Object.keys(this.th.jsonData.patternAppData[t])}async fetchCurrentUserName(){return(await r.dapi.users.current()).friendlyName}async fetchCurrentUserId(){return(await r.dapi.users.current()).id}fetchPatterns(){return r.userSettings.get(V,!1)??{}}async initializePatternMaps(t){if(!this.currentUserId)throw new Error("Current user ID is not set");const e=new Map;for(const[n,r]of Object.entries(t))await this.extractDataFromRecordToMaps(n,r,e);this.setDefaultPattern()}setDefaultPattern(){const t=Y[q.PATTERN_CONFIG];this.currentUserPatternNameToHash.set(t[j.PATTERN_NAME],"")}async extractDataFromRecordToMaps(t,e,n){const o=JSON.parse(e),i=o[q.PATTERN_CONFIG].patternName,s=o[q.AUTHOR_ID];if(this.isCurrentUserId(s))this.currentUserPatternNameToHash.set(i,t);else{if(!n.has(s)){let t="<UNKNOWN_USER>";try{t=(await r.dapi.users.find(s)).friendlyName}catch(t){}n.set(s,t)}const e=i+` (created by ${n.get(s)})`;this.otherUsersPatternNameToHash.set(e,t)}}getDefaultPatternName(){return Y[q.PATTERN_CONFIG][j.PATTERN_NAME]}getCurrentUserAuthorshipCategory(){return this.currentUserName+" (me)"}getOtherUsersAuthorshipCategory(){return"Other users"}isCurrentUserId(t){return t===this.currentUserId}}const et=rxjs,nt=rxjs.operators;function rt(t){return t.endsWith("(o)")}function ot(t){const e=Object.values(t).flat().reduce(((t,e)=>(t[e]=(t[e]||0)+1,t)),{});return Object.entries(e).reduce(((t,e)=>t[1]>e[1]?t:e),["",0])[0]}var it;function st(t){const e=Array.from(new Set(t));return Array.from(e).sort(((t,e)=>t.toLowerCase().localeCompare(e.toLowerCase())))}!function(t){t.getTruncatedStrandData=function(t,e,n){return{nucleotides:t.slice(0,n),ptoFlags:e.slice(0,n+1)}},t.getExtendedStrandData=function(t,e,n,r){const o=n-t.length,i=t.concat(new Array(n-t.length).fill(r)),s=0===t.length?n+1:o;return{nucleotides:i,ptoFlags:e.concat(new Array(s).fill(!0))}}}(it||(it={}));var at=n(2543),lt=n.n(at);class ct{constructor(t,e){this.dataManager=t,this._patternListUpdated$=new et.Subject,this._patternLoadRequested$=new et.Subject,this._patternLoaded$=new et.Subject,this._uniqueNucleotides$=new et.BehaviorSubject([]),this._patternDeletionRequested$=new et.Subject,this._tableSelection$=new et.BehaviorSubject(null),this._svgSaveRequested$=new et.Subject,this._loadPatternInNewTabRequested$=new et.Subject,this._urlStateUpdated$=new et.Subject,this._patternHasUnsavedChanges$=new et.BehaviorSubject(!1),this._selectedStrandColumn=new et.BehaviorSubject(null),this._selectedIdColumn=new et.BehaviorSubject(null),this.initializeAuthorSelection(e),this.initializePatternState(e),this._lastLoadedPatternConfig=new et.BehaviorSubject(lt().cloneDeep(this.getPatternConfig())),this.setupSubscriptions()}setupSubscriptions(){this._nucleotideSequences$.subscribe((()=>{this.updateUniqueNucleotides(),this.updateSequenceBase()})),this._isAntisenseStrandActive$.subscribe((t=>{t||G.forEach((t=>{this.updateTerminusModification("AS",t,"")}))})),this.patternStateChanged$.pipe((0,nt.debounceTime)(20)).subscribe((()=>{const t=this._lastLoadedPatternConfig.getValue(),e=this.getPatternConfig(),n=!lt().isEqual(e,t);this._patternHasUnsavedChanges$.next(n)}))}updateUniqueNucleotides(){const t=(e=this._nucleotideSequences$.getValue(),st(Object.values(e).flat()));var e;this._uniqueNucleotides$.next(t)}updateSequenceBase(){const t=ot(this._nucleotideSequences$.getValue());this._sequenceBase$.next(t)}get nucleotideSequencesChanged$(){return this._nucleotideSequences$.asObservable()}initializeAuthorSelection(t){const e=t[q.AUTHOR_ID];this.dataManager.isCurrentUserId(e)?this._patternAuthorSelection$=new et.BehaviorSubject(this.dataManager.getCurrentUserAuthorshipCategory()):this._patternAuthorSelection$=new et.BehaviorSubject(this.dataManager.getOtherUsersAuthorshipCategory())}initializePatternState(t){const e=t[q.PATTERN_CONFIG];this._patternName$=new et.BehaviorSubject(e[j.PATTERN_NAME]),this._isAntisenseStrandActive$=new et.BehaviorSubject(e[U.IS_ANTISENSE_STRAND_INCLUDED]),this._nucleotideSequences$=new et.BehaviorSubject(e[U.NUCLEOTIDE_SEQUENCES]),this._phosphorothioateLinkageFlags=new et.BehaviorSubject(e[U.PHOSPHOROTHIOATE_LINKAGE_FLAGS]),this._terminalModifications=new et.BehaviorSubject(e[U.STRAND_TERMINUS_MODIFICATIONS]),this._comment$=new et.BehaviorSubject(e[j.PATTERN_COMMENT]),this._modificationsWithNumericLabels$=new et.BehaviorSubject(e[j.NUCLEOTIDES_WITH_NUMERIC_LABELS]),this._sequenceBase$=new et.BehaviorSubject(ot(e[U.NUCLEOTIDE_SEQUENCES]))}getPatternName(){return this._patternName$.getValue()}updatePatternName(t){this._patternName$.next(t)}get antisenseStrandToggled$(){return this._isAntisenseStrandActive$.asObservable()}isAntisenseStrandActive(){return this._isAntisenseStrandActive$.getValue()}toggleAntisenseStrand(t){t?this.updateStrandLength("AS",this.getNucleotideSequences().SS.length):this.updateStrandLength("AS",0),this._isAntisenseStrandActive$.next(t)}getNucleotideSequences(){return this._nucleotideSequences$.getValue()}updateNucleotideSequences(t){this._nucleotideSequences$.next(t)}updateStrandLength(t,e){const n=this.getNucleotideSequences()[t];if(n.length===e)return;const r=this.getPhosphorothioateLinkageFlags()[t];if(0===e)return void this.setNewStrandData([],[],t);if(n.length>e){const{nucleotides:o,ptoFlags:i}=it.getTruncatedStrandData(n,r,e);return void this.setNewStrandData(o,i,t)}const o=this.getSequenceBase(),{nucleotides:i,ptoFlags:s}=it.getExtendedStrandData(n,r,e,o);this.setNewStrandData(i,s,t)}setNewStrandData(t,e,n){this.updateNucleotideSequences({...this.getNucleotideSequences(),[n]:t}),this.updatePhosphorothioateLinkageFlags({...this.getPhosphorothioateLinkageFlags(),[n]:e})}getPhosphorothioateLinkageFlags(){return this._phosphorothioateLinkageFlags.getValue()}updatePhosphorothioateLinkageFlags(t){this._phosphorothioateLinkageFlags.next(t)}get phosphorothioateLingeFlagsChanged$(){return this._phosphorothioateLinkageFlags.asObservable()}getTerminalModifications(){return this._terminalModifications.getValue()}updateTerminalModifications(t){this._terminalModifications.next(t)}updateTerminusModification(t,e,n){const r=this.getTerminalModifications();r[t][e]=n,this.updateTerminalModifications(r)}terminalModificationsUpdated$(){return this._terminalModifications.asObservable()}getComment(){return this._comment$.getValue()}updateComment(t){this._comment$.next(t)}getModificationsWithNumericLabels(){return this._modificationsWithNumericLabels$.getValue()}updateModificationsWithNumericLabels(t){const e=function(t){return st(t).filter((t=>!rt(t)))}(t);this._modificationsWithNumericLabels$.next(e)}get patternLoadRequested$(){return this._patternLoadRequested$.asObservable()}requestPatternLoad(t){this._patternLoadRequested$.next(t)}get patternListUpdated$(){return this._patternListUpdated$.asObservable()}updatePatternList(){this._patternListUpdated$.next()}get tableSelectionChanged$(){return this._tableSelection$.asObservable()}selectTable(t){this._tableSelection$.next(t)}getTableSelection(){return this._tableSelection$.getValue()}requestPatternDeletion(t){this._patternDeletionRequested$.next(t)}get patternDeletionRequested$(){return this._patternDeletionRequested$.asObservable()}replaceSequenceBase(t){const e=this._nucleotideSequences$.getValue(),n={};k.forEach((r=>{n[r]=e[r].map((()=>t))})),this._nucleotideSequences$.next(n);const r=this._modificationsWithNumericLabels$.getValue();r.includes(t)||this.updateModificationsWithNumericLabels(r.concat(t))}get patternStateChanged$(){return et.merge(this._patternName$.pipe((0,nt.debounceTime)(300),(0,nt.map)((()=>{}))),this._isAntisenseStrandActive$,this._nucleotideSequences$,this._phosphorothioateLinkageFlags,this._terminalModifications,this._comment$.pipe((0,nt.debounceTime)(300)),this._modificationsWithNumericLabels$)}getSequenceBase(){return this._sequenceBase$.getValue()}uniqueNucleotidesChanged$(){return this.patternStateChanged$.pipe((0,nt.switchMap)((()=>this._uniqueNucleotides$)))}getUniqueNucleotides(){return this._uniqueNucleotides$.getValue()}get svgSaveRequested$(){return this._svgSaveRequested$.asObservable()}requestSvgSave(){this._svgSaveRequested$.next()}setAllPTOLinkages(t){const e=this.getPhosphorothioateLinkageFlags();k.forEach((n=>{e[n]=e[n].map((()=>t))})),this.updatePhosphorothioateLinkageFlags(e)}setPatternConfig(t){this._patternName$.next(t[j.PATTERN_NAME]),this._isAntisenseStrandActive$.next(t[U.IS_ANTISENSE_STRAND_INCLUDED]),this._nucleotideSequences$.next(t[U.NUCLEOTIDE_SEQUENCES]),this._phosphorothioateLinkageFlags.next(t[U.PHOSPHOROTHIOATE_LINKAGE_FLAGS]),this._terminalModifications.next(t[U.STRAND_TERMINUS_MODIFICATIONS]),this._comment$.next(t[j.PATTERN_COMMENT]),this._modificationsWithNumericLabels$.next(t[j.NUCLEOTIDES_WITH_NUMERIC_LABELS])}setLastLoadedPatternConfig(t){this._lastLoadedPatternConfig.next(lt().cloneDeep(t))}getPatternConfig(){return{[j.PATTERN_NAME]:this.getPatternName(),[U.IS_ANTISENSE_STRAND_INCLUDED]:this.isAntisenseStrandActive(),[U.NUCLEOTIDE_SEQUENCES]:this.getNucleotideSequences(),[U.PHOSPHOROTHIOATE_LINKAGE_FLAGS]:this.getPhosphorothioateLinkageFlags(),[U.STRAND_TERMINUS_MODIFICATIONS]:this.getTerminalModifications(),[j.PATTERN_COMMENT]:this.getComment(),[j.NUCLEOTIDES_WITH_NUMERIC_LABELS]:this.getModificationsWithNumericLabels()}}setPhosphorothioateLinkageFlag(t,e,n){const r=this.getPhosphorothioateLinkageFlags();r[t][e]=n,this.updatePhosphorothioateLinkageFlags(r)}setNucleotide(t,e,n){const r=this.getNucleotideSequences();r[t][e]=n;const o=this.getModificationsWithNumericLabels();this.updateModificationsWithNumericLabels(o.concat(n)),this.updateNucleotideSequences(r)}get strandsUpdated$(){return et.merge(this._isAntisenseStrandActive$.asObservable().pipe((0,nt.map)((()=>{}))),this._nucleotideSequences$.asObservable().pipe((0,nt.map)((()=>{}))),this._patternLoaded$.asObservable().pipe((0,nt.map)((()=>{})))).pipe((0,nt.debounceTime)(10))}get strandsLinkagesAndTerminalsUpdated$(){return et.merge(this.strandsUpdated$,this._phosphorothioateLinkageFlags.asObservable().pipe((0,nt.map)((()=>{}))),this._terminalModifications.asObservable().pipe((0,nt.map)((()=>{}))))}updateControlsUponPatternLoaded(t){this._patternLoaded$.next(t)}get patternLoaded$(){return this._patternLoaded$.asObservable()}get userSelection$(){return this._patternAuthorSelection$.asObservable().pipe((0,nt.skip)(1))}selectAuthor(t){if("string"!=typeof t)throw new Error("Selected user must be defined");this._patternAuthorSelection$.next(t)}getSelectedAuthor(){return this._patternAuthorSelection$.getValue()}get loadPatternInNewTabRequested$(){return this._loadPatternInNewTabRequested$.asObservable()}requestLoadPatternInNewTab(t){this._loadPatternInNewTabRequested$.next(t)}updateUrlState(t){this._urlStateUpdated$.next(t)}get urlStateUpdated$(){return this._urlStateUpdated$.asObservable()}get patternHasUnsavedChanges$(){return this._patternHasUnsavedChanges$.asObservable()}selectStrandColumn(t,e){this._selectedStrandColumn.next({...this._selectedStrandColumn.getValue(),[t]:e})}getSelectedStrandColumn(t){const e=this._selectedStrandColumn.getValue();return e?e[t]:null}selectIdColumn(t){this._selectedIdColumn.next(t)}getSelectedIdColumn(){return this._selectedIdColumn.getValue()}get updateSvgContainer$(){return this.patternStateChanged$.pipe((0,nt.debounceTime)(100))}}const ut="pattern";class ht{constructor(){this.urlSearchParams=new URLSearchParams(window.location.search)}subscribeToObservables(t){t.urlStateUpdated$.subscribe((t=>this.setPatternURL(t))),t.loadPatternInNewTabRequested$.subscribe((t=>{const e=`${window.location.origin}${window.location.pathname}?${ut}=${t}`;window.open(e,"_blank")})),window.addEventListener("popstate",(()=>{this.urlSearchParams=new URLSearchParams(window.location.search);const e=this.getPatternHash();null!==e&&t.requestPatternLoad(e)}))}getPatternHash(){return this.urlSearchParams.get(ut)}setPatternURL(t){null!==t&&""!==t?(this.urlSearchParams.set(ut,t),window.history.pushState({},"",`${window.location.pathname}?${this.urlSearchParams}`)):this.clearPatternURL()}clearPatternURL(){this.urlSearchParams.delete(ut),window.history.pushState({},"",`${window.location.pathname}`)}}var dt=n(5072),pt=n.n(dt),ft=n(7825),mt=n.n(ft),gt=n(7659),yt=n.n(gt),bt=n(5056),vt=n.n(bt),Ct=n(540),xt=n.n(Ct),wt=n(1113),At=n.n(wt),Tt=n(9252),Et={};Et.styleTagTransform=At(),Et.setAttributes=vt(),Et.insert=yt().bind(null,"head"),Et.domAPI=mt(),Et.insertStyleElement=xt(),pt()(Tt.A,Et),Tt.A&&Tt.A.locals&&Tt.A.locals;class St{constructor(t){this.eventBus=t,this.columnControlsContainer=P.div([]),this.eventBus.tableSelectionChanged$.subscribe((()=>this.handleTableChoice())),this.refreshColumnControls()}getColumnControlsContainer(){return this.columnControlsContainer}get selectedTable(){return this.eventBus.getTableSelection()}handleTableChoice(){this.refreshColumnControls()}refreshColumnControls(){L()(this.columnControlsContainer).empty(),L()(this.columnControlsContainer).append(this.constructColumnControls())}constructColumnControls(){const t=this.createStrandColumnInput(),e=t.SS,n=t.AS;this.eventBus.antisenseStrandToggled$.subscribe((t=>{L()(n).toggle(t)}));const r=this.createIdColumnInput();return[e,n,r]}createStrandColumnInput(){const t=this.selectedTable?this.selectedTable.columns.names().sort(((t,e)=>t.localeCompare(e))):[];return Object.fromEntries(k.map((e=>{const n=P.input.choice(`${H[e]} column`,{value:t[0],items:t,onValueChanged:t=>this.eventBus.selectStrandColumn(e,t)});return this.eventBus.selectStrandColumn(e,t[0]),[e,n.root]})))}createIdColumnInput(){const t=this.selectedTable?this.selectedTable.columns.names():[],e=P.input.choice("ID column",{value:t[0],items:t,onValueChanged:t=>this.eventBus.selectIdColumn(t)});return this.eventBus.selectIdColumn(t[0]),e.root}}class It{constructor(t){this.eventBus=t,this.availableTables=[],this.tableInputContainer=P.div([]),this.subscribeToTableEvents(),this.refreshTableInput()}getTableInputContainer(){return this.tableInputContainer}subscribeToTableEvents(){r.events.onTableAdded.subscribe((t=>this.handleTableAdded(t))),r.events.onTableRemoved.subscribe((t=>this.handleTableRemoved(t))),this.eventBus.tableSelectionChanged$.subscribe((()=>this.handleTableChoice()))}getTableFromEventData(t){if(!t&&t.args&&t.args.dataFrame instanceof o.DataFrame)throw new Error("EventData does not contain a dataframe",t);return t.args.dataFrame}handleTableAdded(t){const e=this.getTableFromEventData(t);this.availableTables.some((t=>t.name===e.name))||(this.availableTables.push(e),this.eventBus.selectTable(e),this.refreshTableInput())}handleTableRemoved(t){const e=this.getTableFromEventData(t);this.availableTables=this.availableTables.filter((t=>t.name!==e.name));const n=this.availableTables[0];this.eventBus.selectTable(n||null),this.refreshTableInput()}refreshTableInput(){const t=this.createTableInput();L()(this.tableInputContainer).empty(),this.tableInputContainer.append(t.root)}createTableInput(){const t=this.eventBus.getTableSelection();return P.input.table("Tables",{value:t,items:this.availableTables,onValueChanged:t=>{null!==t&&this.eventBus.selectTable(t)}})}handleTableChoice(){const t=this.eventBus.getTableSelection();t&&(this.isTableDisplayed(t)||this.displayTable(t))}isTableDisplayed(t){return r.shell.tableNames.includes(t.name)}displayTable(t){const e=r.shell.v;r.shell.addTableView(t),r.shell.v=e}}function Nt(t,e,n,r){const o=function(t,e,n){const r=new Array(t.length+e.filter((t=>t)).length+G.length);r[0]=n["5'"],r[r.length-1]=n["3'"];let o=1;return e[0]&&(r[o]="ps",o++),t.forEach(((t,n)=>{r[n+o]=t,e[n+1]&&(r[n+o+1]="ps",o++)})),r}(t.split("").map(((t,n)=>{const r=function(t,e,n){const r=Object.keys(n.patternAppData)[0],o=n.patternAppData[r][e].substitution;return t.replace(/([AGCTU])/,o)}(t,e[n],Yr.jsonData);return r})),n,r);return o.join("")}class _t{constructor(t){this.eventBus=t,this.tableInputManager=new It(t),this.columnInputManager=new St(t)}createControls(){const t=P.h1("Bulk convert"),e=this.tableInputManager.getTableInputContainer(),n=this.columnInputManager.getColumnControlsContainer(),r=P.bigButton("Convert",(()=>this.processConvertButtonClick()));return[t,e,n,P.buttonsInput([r])]}processConvertButtonClick(){!function(t){const e=t.getTableSelection();if(!e)return void r.shell.warning("Please select a table");const n=k.filter((e=>!("AS"===e&&!t.isAntisenseStrandActive()))).map((e=>({strand:e,column:t.getSelectedStrandColumn(e)}))).filter((t=>t.column));if(0===n.length)return void r.shell.warning("Select a sense strand column");const o=t.getSelectedIdColumn();if(!o)throw new Error("No ID column selected");e.getCol(o);const i=n.map((t=>({strand:t.strand,column:e.getCol(t.column)})));!function(t,e){const n=e.getNucleotideSequences();return t.every((t=>{const e=n[t.strand].length;return t.column.toList().every((t=>t.length===e))}))}(i,t)?r.shell.warning("Some strands in the table input do not match pattern length"):i.forEach((n=>{const r=n.column,o=n.strand,i=t.getNucleotideSequences()[o],s=t.getTerminalModifications()[o],a=t.getPhosphorothioateLinkageFlags()[o],l=`${t.getPatternName()}(${r.name})`;e.columns.addNewString(l).init((t=>Nt(r.get(t),i,a,s)))}))}(this.eventBus)}}class Pt{constructor(t,e,n){this.eventBus=t,this.initialPatternConfig=e,this.subscriptions=n}create(){return P.divV([P.h1("PTO"),P.divH([this.createAllPtoActivationInput().root,...this.createFirstPtoInputs().map((t=>t.root))],{style:{gap:"12px"}})])}areAllPtoLinkagesSet(t){return k.map((e=>t[e].filter((t=>t)).length)).reduce(((t,e)=>t+e),0)===k.map((t=>this.initialPatternConfig.nucleotideSequences[t].length)).reduce(((t,e)=>t+e),0)+k.filter((e=>t[e].length)).length}createAllPtoActivationInput(){const t=this.initialPatternConfig.phosphorothioateLinkageFlags,e=this.areAllPtoLinkagesSet(t),n=P.input.bool("All PTO",{value:e});n.onInput.subscribe((()=>{const t=n.value;this.eventBus.setAllPTOLinkages(t)}));const r=this.eventBus.phosphorothioateLingeFlagsChanged$.subscribe((()=>{const t=this.eventBus.getPatternConfig().phosphorothioateLinkageFlags,e=this.areAllPtoLinkagesSet(t);n.value=e}));return this.subscriptions.add(r),this.addStyleToPtoInput(n),P.tooltip.bind(n.captionLabel,"Activate all phosphothioates"),n}addStyleToPtoInput(t){const e=t.captionLabel;e.classList.add("ui-label-right"),Object.assign(e.style,{textAlign:"left",maxWidth:"100px",minWidth:"40px",width:"auto"})}createFirstPtoInputs(){return k.map((t=>{if(!this.eventBus.isAntisenseStrandActive()&&"AS"===t)return;const e=this.isFirstPtoActive(t),n=P.input.bool(`First ${t} PTO`,{value:e});n.onInput.subscribe((()=>{const e=n.value;this.eventBus.setPhosphorothioateLinkageFlag(t,0,e)}));const r=this.eventBus.phosphorothioateLingeFlagsChanged$.subscribe((e=>{const r=e[t][0];n.value=r}));return this.subscriptions.add(r),this.addStyleToPtoInput(n),P.tooltip.bind(n.captionLabel,`Activate first phosphothioate in ${t}`),n})).filter((t=>void 0!==t))}isFirstPtoActive(t){return this.initialPatternConfig.phosphorothioateLinkageFlags[t][0]}}class Mt{constructor(t,e,n){this.eventBus=t,this.dataManager=e,this.subscriptions=n;const r=this.eventBus.nucleotideSequencesChanged$.subscribe((()=>{this.displayedInputLabels=this.computeDisplayedInputLabels()}));this.subscriptions.add(r)}create(){const t=k.map((t=>this.constructControlsPanel(t)));return P.divH(t,{style:{gap:"24px"}})}constructControlsPanel(t){if(!this.eventBus.isAntisenseStrandActive()&&"AS"===t)return P.div([]);const e=this.constructHeader(),n=this.createControls(t);return P.block([P.h1(`${H[t]}`),e,n],{style:{paddingTop:"12px"}})}constructHeader(){return P.divH([P.div([P.divText("#")],{style:{width:"20px"}}),P.block75([P.divText("Modification")]),P.div([P.divText("PTO")])])}createControls(t){const e=this.createNucleobaseInputs(t),n=this.createLabelDivs(t),r=this.createPTOFlagInputs(t);return P.div(e.map(((t,e)=>P.divH([n[e],P.block75([t.root]),r[e].root],{style:{alignItems:"center"}}))))}createNucleobaseInputs(t){const e=this.dataManager.fetchAvailableNucleotideBases().sort(((t,e)=>t.toLowerCase().localeCompare(e.toLowerCase())));return this.eventBus.getNucleotideSequences()[t].map(((n,r)=>{const o=P.input.choice("",{value:n,items:e});return o.onInput.subscribe((()=>{const e=o.value;this.eventBus.setNucleotide(t,r,e)})),o}))}createPTOFlagInputs(t){return this.eventBus.getPhosphorothioateLinkageFlags()[t].slice(1).map(((e,n)=>{const r=P.input.bool("",{value:e});r.onInput.subscribe((()=>{const e=r.value;this.eventBus.setPhosphorothioateLinkageFlag(t,n+1,e)}));const o=this.eventBus.phosphorothioateLingeFlagsChanged$.subscribe((e=>{const o=e[t][n+1];r.value=o}));return this.subscriptions.add(o),r}))}computeDisplayedInputLabels(){const t=this.eventBus.getNucleotideSequences(),e=new Map;return k.forEach((n=>{let r=1;const o=t[n].map((t=>{if(rt(t))return"";const e=String(r);return r++,e}));e.set(n,o)})),e}createLabelDivs(t){const e=this.createLabels(t).map((t=>P.div([t],{style:{width:"20px"}}))),n=this.eventBus.nucleotideSequencesChanged$.subscribe((()=>{this.createLabels(t).forEach(((t,n)=>{L()(e[n]).empty(),L()(e[n]).append(t)}))}));return this.subscriptions.add(n),e}createLabels(t){return this.eventBus.getNucleotideSequences()[t].map(((e,n)=>{const r=this.displayedInputLabels.get(t)[n];return P.label(r)}))}}class Lt{constructor(){this.rxjsSubscriptions=[],this.dgSubscriptions=[]}add(t){t instanceof et.Subscription?this.rxjsSubscriptions.push(t):this.dgSubscriptions.push(t)}unsubscribeAll(){for(const t of[this.rxjsSubscriptions,this.dgSubscriptions])t.forEach((t=>t.unsubscribe())),t.length=0}}class Ot{constructor(t,e){this.eventBus=t,this.dataManager=e,this.subscriptions=new Lt}static open(t,e){Ot.isDialogOpen||(Ot.instance||(Ot.instance=new Ot(t,e)),Ot.instance.openDialog())}openDialog(){this.initialPatternConfig=lt().cloneDeep(this.eventBus.getPatternConfig()),Ot.isDialogOpen=!0,this.createDialog().show()}createDialog(){const t=P.divV([]);this.subscriptions.add(this.eventBus.strandsUpdated$.subscribe((()=>this.onStrandsUpdated(t))));const e=P.dialog("Edit strands").add(t).onOK((()=>{})).onCancel((()=>this.resetToInitialState()));return this.subscriptions.add(e.onClose.subscribe((()=>{Ot.isDialogOpen=!1,this.subscriptions.unsubscribeAll()}))),e}onStrandsUpdated(t){const e=new Pt(this.eventBus,this.initialPatternConfig,this.subscriptions).create(),n=new Mt(this.eventBus,this.dataManager,this.subscriptions).create();L()(t).empty(),L()(t).append(e,n)}resetToInitialState(){this.eventBus.setPatternConfig(this.initialPatternConfig)}}Ot.isDialogOpen=!1;class Rt{constructor(t){this.eventBus=t,this.subscriptions=new Lt}static open(t){Rt.isDialogOpen||(Rt.instance||(Rt.instance=new Rt(t)),Rt.instance.openDialog())}openDialog(){this.initialPatternConfig=lt().cloneDeep(this.eventBus.getPatternConfig()),Rt.isDialogOpen=!0,this.createDialog().show()}createDialog(){const t=P.divV([]);this.subscriptions.add(this.eventBus.strandsUpdated$.subscribe((()=>this.onStrandsUpdated(t))));const e=P.dialog("Edit terminal modifications").add(t).onOK((()=>{})).onCancel((()=>this.resetToInitialState()));return this.subscriptions.add(e.onClose.subscribe((()=>{Rt.isDialogOpen=!1,this.subscriptions.unsubscribeAll()}))),e}onStrandsUpdated(t){const e=new Dt(this.eventBus).create();L()(t).empty(),L()(t).append(e)}resetToInitialState(){this.eventBus.setPatternConfig(this.initialPatternConfig)}}Rt.isDialogOpen=!1;class Dt{constructor(t){this.eventBus=t}create(){const t=k.map((t=>this.constructControlsPanel(t)));return P.divH(t,{style:{gap:"24px"}})}constructControlsPanel(t){if(!this.eventBus.isAntisenseStrandActive()&&"AS"===t)return P.div([]);const e=this.createInputs(t);return P.block([P.h1(`${H[t]}`),e],{style:{paddingTop:"12px"}})}createInputs(t){const e=("SS"===t?[...G].reverse():G).map((e=>this.createInputForTerminus(t,e)));return P.form(e)}createInputForTerminus(t,e){const n=this.eventBus.getTerminalModifications()[t][e],r=P.input.textArea(e,{value:n});return this.applyStylingToInput(r),r.onInput.subscribe((()=>{const n=r.value;null!==n&&this.eventBus.updateTerminusModification(t,e,n)})),r}applyStylingToInput(t){const e=t.root.getElementsByTagName("textarea")[0];L()(e).css("resize","none")}}class $t{constructor(t,e){this.eventBus=t,this.dataManager=e}createControls(){const t=this.createAntisenseStrandToggle(),e=this.createStrandLengthInputs(),n=e.SS.root,r=e.AS.root,o=this.createSequenceBaseInput().root,i=this.createPatternCommentInput().root,s=this.createPatternNameInputBlock(),a=this.createEditPatternButton(),l=this.createEditTerminalModificationsButton();return[P.h1("Edit"),t,n,r,o,s,i,P.buttonsInput([l,a])]}createEditPatternButton(){const t=P.button("Edit strands",(()=>Ot.open(this.eventBus,this.dataManager)));return P.tooltip.bind(t,"Edit strand modifications and PTOs"),t}createEditTerminalModificationsButton(){const t=P.button("Edit terminals",(()=>Rt.open(this.eventBus)));return P.tooltip.bind(t,"Edit terminal modifications"),L()(t).css("margin-right","20px"),t}createAntisenseStrandToggle(){const t=P.input.toggle(`${H.AS} strand`,{value:this.eventBus.isAntisenseStrandActive()});return t.onInput.subscribe((()=>this.eventBus.toggleAntisenseStrand(t.value))),this.eventBus.patternLoaded$.subscribe((()=>{t.value=this.eventBus.isAntisenseStrandActive()})),t.setTooltip("Toggle antisense strand"),t.root}createStrandLengthInputs(){const t=t=>{const n=this.eventBus.getNucleotideSequences()[t].length,r=P.input.int(`${H[t]} length`,{value:n});return r.onInput.subscribe((()=>e(t,r))),this.eventBus.nucleotideSequencesChanged$.subscribe((()=>{r.value=this.eventBus.getNucleotideSequences()[t].length})),r.setTooltip(`Number of nucleotides in ${t}, including overhangs`),[t,r]},e=(t,e)=>{const n=e.value;null!==n&&(n<=0&&(r.shell.warning("Sequence length must be greater than 0"),e.value=1),n>34&&(r.shell.warning("Sequence length must be less than 35"),e.value=34),this.eventBus.updateStrandLength(t,e.value))},n=Object.fromEntries(k.map((e=>t(e))));return this.eventBus.antisenseStrandToggled$.subscribe((t=>{L()(n.AS.root).toggle(t)})),n}createSequenceBaseInput(){const t=this.dataManager.fetchAvailableNucleotideBases().sort(((t,e)=>t.toLowerCase().localeCompare(e.toLowerCase()))),e=this.dataManager.fetchDefaultNucleobase(),n=P.input.choice("Sequence basis",{value:e,items:t});return n.onInput.subscribe((()=>this.eventBus.replaceSequenceBase(n.value))),this.eventBus.nucleotideSequencesChanged$.subscribe((()=>{n.value=this.eventBus.getSequenceBase()})),n.setTooltip("Most frequent nucleobase in the strands"),n}createPatternCommentInput(){const t=P.input.textArea("Comment",{value:this.eventBus.getComment()});return L()(t.root).addClass("st-pattern-text-input"),t.onInput.subscribe((()=>this.eventBus.updateComment(t.value))),this.eventBus.patternLoaded$.subscribe((()=>{t.value=this.eventBus.getComment()})),t}createPatternNameInputBlock(){const t=P.input.textArea("Pattern name",{value:this.eventBus.getPatternName()});return L()(t.root).addClass("st-pattern-text-input"),t.onInput.subscribe((()=>this.eventBus.updatePatternName(t.value))),this.eventBus.patternLoaded$.subscribe((()=>{t.value=this.eventBus.getPatternName()})),t.setTooltip("Name under which pattern will be saved"),t.root}}class Bt{constructor(t,e){this.eventBus=t,this.dataManager=e,this.subscriptions=new Lt,this.authorSelectedByUser=!1,this.eventBus.patternLoadRequested$.subscribe((t=>this.handlePatternChoice(t))),this.eventBus.patternDeletionRequested$.subscribe((async t=>{await this.dataManager.deletePattern(t,this.eventBus)}))}async handlePatternChoice(t){let e=await this.dataManager.getPatternConfig(t);null===e&&(e=this.dataManager.getDefaultPatternConfig()),this.eventBus.setPatternConfig(e),this.eventBus.updateControlsUponPatternLoaded(t),this.eventBus.setLastLoadedPatternConfig(e)}isCurrentUserSelected(){return this.eventBus.getSelectedAuthor()!==this.dataManager.getOtherUsersAuthorshipCategory()}createControls(){const t=this.getPatternInputsContainer();return[P.h1("Load"),t]}getPatternInputsContainer(){const t=P.divH(this.createPatternInputs());return this.eventBus.patternListUpdated$.subscribe((()=>{this.subscriptions.unsubscribeAll(),L()(t).empty(),L()(t).append(this.createPatternInputs())})),t}createPatternInputs(){const t=this.createAuthorChoiceInput(),e=this.createPatternChoiceInputContainer(),n=this.createDeletePatternButton();return[t.root,e,n]}createPatternChoiceInputContainer(){const t=this.createPatternChoiceInput(),e=P.div([t.root]),n=this.eventBus.userSelection$.subscribe((()=>{L()(e).empty(),L()(e).append(this.createPatternChoiceInput().root)}));return this.subscriptions.add(n),e}createAuthorChoiceInput(){const t=[this.dataManager.getCurrentUserAuthorshipCategory()];this.dataManager.getOtherUsersPatternNames().length>0&&t.push(this.dataManager.getOtherUsersAuthorshipCategory());const e=P.input.choice("Author",{value:this.eventBus.getSelectedAuthor(),items:t});return e.onInput.subscribe((()=>{if(this.authorSelectedByUser=!0,null===e.value)throw new Error("author choice must be non-null");this.eventBus.selectAuthor(e.value)})),this.setAuthorChoiceInputStyle(e),e.setTooltip("Select pattern author"),e}setAuthorChoiceInputStyle(t){L()(t.input).css({"max-width":"100px","min-width":"100px"}),L()(t.root).css({"padding-right":"30px","padding-left":"30px"})}createPatternChoiceInput(){const t=this.isCurrentUserSelected()?this.dataManager.getCurrentUserPatternNames():this.dataManager.getOtherUsersPatternNames();if(this.authorSelectedByUser){const e=this.dataManager.getPatternHash(t[0],this.isCurrentUserSelected());this.eventBus.requestPatternLoad(e),this.eventBus.updateUrlState(e),this.authorSelectedByUser=!1}const e=this.getPatternName(t),n=P.input.choice("Pattern",{value:e,items:t});return n.setTooltip("Select pattern to load"),L()(n.input).css({"max-width":"100px","min-width":"100px"}),this.subscriptions.add(n.onInput.subscribe((()=>{const t=this.dataManager.getPatternHash(n.value,this.isCurrentUserSelected());this.eventBus.requestPatternLoad(t),this.eventBus.updateUrlState(t)}))),this.subscriptions.add(this.eventBus.patternLoaded$.subscribe((()=>{const e=this.eventBus.getPatternName();n.value!==e&&(n.value=this.getPatternName(t))}))),n}getPatternName(t){return t.find((t=>t.split(" (")[0]===this.eventBus.getPatternName()))??t[0]}createDeletePatternButton(){const t=P.button(P.iconFA("trash-alt"),(()=>{this.eventBus.getPatternName()!==this.dataManager.getDefaultPatternName()?this.showDeletePatternDialog():r.shell.warning("Cannot delete example pattern")}));P.tooltip.bind(t,"Delete pattern from user storage");const e=this.eventBus.userSelection$.subscribe((()=>{t.disabled=!this.isCurrentUserSelected()}));return this.subscriptions.add(e),t}showDeletePatternDialog(){const t=P.dialog("Delete pattern"),e=this.eventBus.getPatternName();t.add(P.divText(`Are you sure you want to delete pattern ${e}?`)),t.onOK((()=>this.eventBus.requestPatternDeletion(e))),t.show()}}class Ft{constructor(t,e){this.eventBus=t,this.dataManager=e}getLayout(){const t=new Bt(this.eventBus,this.dataManager),e=new $t(this.eventBus,this.dataManager),n=new _t(this.eventBus),r=t.createControls(),o=e.createControls(),i=n.createControls(),s=P.div(r);L()(s).css({"padding-bottom":"20px"});const a=P.div([...o,...i],"ui-form"),l=P.div([s,a]);return L()(l).css({padding:"25px"}),P.box(l,{style:{maxWidth:"450px"}})}}var kt=n(9146);class Ht{constructor(t,e,n){this.svgElementFactory=t,this.config=e,this.yShift=n}shiftElements(t){this.svgElements.forEach((e=>{const n=e.getAttribute("transform")||"",r=`translate(${t.x},${t.y})`;e.setAttribute("transform",`${n} ${r}`)}))}}class Gt{constructor(){}static getInstance(){return Gt.instance||(Gt.instance=new Gt,Gt.instance.canvas=document.createElement("canvas")),Gt.instance}static getTextDimensions(t,e){const n=Gt.getInstance().canvas.getContext("2d");if(!n)throw new Error("Canvas 2D context is not available");return n.font=`${e}px Arial`,{width:1.1*n.measureText(t).width,height:1.1*e}}}function Vt(t){const e=Object.keys(Yr.jsonData.patternAppData)[0];if(!e)throw new Error(`No format found in '${h}'`);return Yr.jsonData.patternAppData[e][t].color||""}class Ut extends Ht{constructor(t,e,n){super(t,e,n);const r=k.filter((t=>e.nucleotideSequences[t].length>0));this.strands=r.map((t=>new jt(this.svgElementFactory,e,n,t))),this.terminalModifications=r.map(((t,r)=>new Wt(this.svgElementFactory,e,n,t,this.strands[r]))),this.labels=r.map(((t,r)=>new qt(this.svgElementFactory,e,n,t,this.terminalModifications[r])))}get svgElements(){return[...this.strands,...this.terminalModifications,...this.labels].map((t=>t.svgElements)).flat()}getContentWidth(){return Math.max(...this.labels.map((t=>t.getContentWidth())))}getContentHeight(){return this.strands.reduce(((t,e)=>t+e.getContentHeight()),0)}}class jt extends Ht{constructor(t,e,n,r){super(t,e,n),this.svgElementFactory=t,this.config=e,this.yShift=n,this.strand=r,this.nucleotideNumericLabels=this.computeNucleotideNumericLabels(),"AS"===this.strand&&(this.config.phosphorothioateLinkageFlags[this.strand].reverse(),this.config.nucleotideSequences[this.strand].reverse(),this.nucleotideNumericLabels.reverse()),this._svgElements=[this.createStrandCircles(),this.createPTOLinkageStars()].flat()}computeNucleotideNumericLabels(){let t=0;return this.config.nucleotideSequences[this.strand].map((e=>rt(e)?null:(t++,t)))}get svgElements(){return this._svgElements}getStrandCircleYShift(){return zt(this.strand,this.yShift)}createStrandCircles(){const t={x:80,y:this.getStrandCircleYShift()};return this.config.nucleotideSequences[this.strand].map(((e,n)=>this.createNucleotideElementGroup(e,n,t))).flat()}createNucleotideElementGroup(t,e,n){return[...this.createNucleotideCircleElements(t,e,n),this.config.nucleotidesWithNumericLabels.includes(t)?this.createNucleotideNumericLabel(e,n):null].filter((t=>null!==t))}createNucleotideCircleElements(t,e,n){const r=Vt(t),o={...n,x:n.x+30*e};return[this.svgElementFactory.createCircleElement(o,15,r),this.createNucleotideLetterLabel(e,n,t)]}getNucleotideCircleCenterPosition(t,e){return{x:e.x+30*t,y:e.y}}createNucleotideLetterLabel(t,e,n){if(!m.AL.includes(n))return null;const r=function(t){return!rt(t)&&m.AL.includes(t)?t:""}(n),o=function(t){const e=Vt(t),n=e.match(/\d+/g)?.map(Number);if(!n||n.length<3)return"#ffffff";const[r,o,i]=n;return.299*r+.587*o+.114*i>186?"#333333":"#ffffff"}(n),i=this.getPositionForNucleotideLabel(t,e);return this.svgElementFactory.createTextElement(r,i,17,o)}getPositionForNucleotideLabel(t,e){const n=this.getNucleotideCircleCenterPosition(t,e),r=Gt.getTextDimensions("A",17);return{x:n.x-r.width/2,y:n.y+r.height/3}}getNumericLabelYShift(t){return"SS"===this.strand?t.y-20:t.y+15+5+15}createNucleotideNumericLabel(t,e){const n=this.nucleotideNumericLabels[t];if(null===n)return null;const r=Gt.getTextDimensions(n.toString(),15).width,o={x:e.x+30*t-r/2,y:this.getNumericLabelYShift(e)};return this.svgElementFactory.createTextElement(n.toString(),o,15,"var(--grey-6)")}createPTOLinkageStars(){const t=this.config.phosphorothioateLinkageFlags[this.strand],e=this.getStrandCircleYShift()+12;return t.map(((t,n)=>{if(!t)return null;const r={x:65+30*n,y:e};return this.svgElementFactory.createStarElement(r,"red")})).filter((t=>null!==t))}getContentWidth(){return 30*this.config.nucleotideSequences[this.strand].length}getContentHeight(){return 62}}class qt extends Ht{constructor(t,e,n,r,o){super(t,e,n),this.svgElementFactory=t,this.config=e,this.yShift=n,this.strand=r,this.terminalModifications=o,this._svgElements=this.createSVGElements()}createSVGElements(){return[this.createLeftLabel(),this.createRightLabel()]}getLeftLabelWidth(){return 55}getRightLabelWidth(){return 20}createLeftLabel(){const t="SS"===this.strand?"5'":"3'",e=`${this.strand}: ${t} `,n=Gt.getTextDimensions(e,17),r={x:10,y:zt(this.strand,this.yShift)+n.height/3};return this.svgElementFactory.createTextElement(e,r,17,"var(--grey-6)")}createRightLabel(){const t=" "+("SS"===this.strand?"3'":"5'"),e=Gt.getTextDimensions(t,17),n={x:65+this.terminalModifications.getContentWidth()+5,y:zt(this.strand,this.yShift)+e.height/3};return this.svgElementFactory.createTextElement(t,n,17,"var(--grey-6)")}get svgElements(){return this._svgElements}getContentWidth(){return this.terminalModifications.getContentWidth()+this.getLeftLabelWidth()+this.getRightLabelWidth()+10}getContentHeight(){return this.terminalModifications.getContentHeight()}}class Wt extends Ht{constructor(t,e,n,r,o){super(t,e,n),this.svgElementFactory=t,this.config=e,this.yShift=n,this.strand=r,this.strandSvgWrapper=o,this._svgElements=this.createSVGElements()}createSVGElements(){return this.createTerminalModifications()}getTerminalModification(t){return this.config.strandTerminusModifications[this.strand][t]}getTerminalModificationTextDimensions(t){const e=this.getTerminalModification(t);return Gt.getTextDimensions(e,17)}getLeftTerminus(){return"SS"===this.strand?"5'":"3'"}createTerminalModification(t){const e=this.getTerminalModification(t),n=this.getTerminalModificationTextDimensions(t),r=t===this.getLeftTerminus(),o={x:r?65:65+this.getTerminalModificationTextDimensions(this.getLeftTerminus()).width+this.strandSvgWrapper.getContentWidth(),y:zt(this.strand,this.yShift)+n.height/3};return r&&this.strandSvgWrapper.shiftElements({x:n.width,y:0}),this.svgElementFactory.createTextElement(e,o,17,"red")}createTerminalModifications(){return("AS"===this.strand?G:Array.from(G).reverse()).map((t=>this.createTerminalModification(t)))}get svgElements(){return this._svgElements}getContentWidth(){return this.strandSvgWrapper.getContentWidth()+G.map((t=>this.getTerminalModificationTextDimensions(t).width)).reduce(((t,e)=>t+e),0)}getContentHeight(){return this.strandSvgWrapper.getContentHeight()}}function zt(t,e){return"SS"===t?e+5+15+15:e+52+10+15}class Yt{constructor(){this.xmlNamespace="http://www.w3.org/2000/svg"}createElement(t){return document.createElementNS(this.xmlNamespace,t)}setAttributes(t,e){Object.entries(e).forEach((([e,n])=>{t.setAttribute(e,String(n))}))}createCanvas(t,e){const n=this.createElement("svg");return this.setAttributes(n,{id:"mySvg",width:t,height:e}),n}createCircleElement(t,e,n){const r=this.createElement("circle");return this.setAttributes(r,{cx:t.x,cy:t.y,r:e,fill:n}),r}createTextElement(t,e,n,r){const o=this.createElement("text");return this.setAttributes(o,{x:e.x,y:e.y,"font-size":n,"font-weight":"normal","font-family":"Arial",fill:r}),o.textContent=t,o}createStarElement(t,e){const n=this.createElement("polygon"),r=this.computeStarVertexCoordinates(t).map((t=>t.join(","))).join(" ");return this.setAttributes(n,{points:r,fill:e}),n}computeStarVertexCoordinates(t){const e=Math.PI/5,n=-e/2;return Array.from({length:10},((r,o)=>{const i=o%2==0?6:3,s=o*e+n;return[t.x+Math.cos(s)*i,t.y+Math.sin(s)*i]}))}createRectangleElement(t,e,n,r){const o=this.createElement("rect");return this.setAttributes(o,{x:t.x,y:t.y,width:e,height:n,fill:r}),o}}class Kt extends Ht{constructor(t,e,n){super(t,e,n),this.svgElementFactory=t,this.config=e,this.yShift=n,this._svgElements=[],this.titleText=this.getTitleText(),this._svgElements=[this.getTitle()]}get svgElements(){return this._svgElements}getTitle(){return this.svgElementFactory.createTextElement(this.titleText,{x:15,y:this.yShift+17},17,"black")}getContentWidth(){return Gt.getTextDimensions(this.titleText,17).width}getContentHeight(){return Gt.getTextDimensions(this.titleText,17).height}getTitleText(){const t=`${this.config.nucleotideSequences.SS.length}`,e=this.config.isAntisenseStrandIncluded?`/${this.config.nucleotideSequences.AS.length}`:"";return`${this.config.patternName} for ${t}${e}-mer`}}class Qt extends Ht{constructor(t,e,n){super(t,e,n),this._svgElements=[];const{elements:r,width:o}=this.createLegendItems();this._svgElements=r,this.width=o}isPhosphorothioatePresent(){return Object.values(this.config.phosphorothioateLinkageFlags).flat().some((t=>t))}getModificationTypesList(){return[...new Set(Object.values(this.config.nucleotideSequences).flat().sort(((t,e)=>t.toLowerCase().localeCompare(e.toLowerCase()))))]}get svgElements(){return this._svgElements}createLegendItem(t,e){const n={x:e,y:this.yShift-6},r=t.includes("linkage")?this.svgElementFactory.createStarElement(n,"red"):this.svgElementFactory.createCircleElement(n,6,Vt(t));e+=12;const o={y:this.yShift,x:e};return{elements:[r,this.svgElementFactory.createTextElement(t,o,15,"var(--grey-6)")],width:12+Gt.getTextDimensions(t,15).width}}createLegendItems(){let t=10;const e=[],n=e=>t+=e+15;if(this.isPhosphorothioatePresent()){const{elements:r,width:o}=this.createLegendItem("PTO linkage",t);n(o),e.push(r)}return this.getModificationTypesList().forEach((r=>{const{elements:o,width:i}=this.createLegendItem(r,t);n(i),e.push(o)})),{elements:e.flat(),width:t}}getContentHeight(){return 20}getContentWidth(){return this.width}}class Jt{constructor(t){this.svgElementFactory=new Yt;const e=lt().cloneDeep(t);let n=10;this.title=new Kt(this.svgElementFactory,e,n),n+=this.title.getContentHeight(),this.strands=new Ut(this.svgElementFactory,e,n),n+=this.strands.getContentHeight()+10,this.legend=new Qt(this.svgElementFactory,e,n)}renderPattern(){const t=this.getGlobalWidth(),e=this.getGlobalHeight(),n=this.svgElementFactory.createCanvas(t,e),r=[this.title,this.strands,this.legend].map((t=>t.svgElements)).flat();return n.append(...r),n}getGlobalWidth(){const t=[this.title,this.strands,this.legend];return Math.max(...t.map((t=>t.getContentWidth())))}getGlobalHeight(){return[this.title,this.strands,this.legend].reduce(((t,e)=>t+e.getContentHeight()),10)}}class Xt{constructor(t){this.eventBus=t,this.svgDisplayDiv=P.div([]),t.updateSvgContainer$.subscribe((()=>this.updateSvgContainer())),t.svgSaveRequested$.subscribe((()=>this.saveSvgAsPng()))}static createSvgDiv(t){return new Xt(t).svgDisplayDiv}updateSvgContainer(){$(this.svgDisplayDiv).empty();const t=this.eventBus.getPatternConfig();this.svgElement=this.createSvg(t),this.svgDisplayDiv.append(this.svgElement)}createSvg(t){return new Jt(t).renderPattern()}saveSvgAsPng(){const t=this.eventBus.getPatternName();kt.saveSvgAsPng(this.svgElement,t,{backgroundColor:"white"})}}class Zt{constructor(t){this.eventBus=t,this.togglesContainer=P.div([]),this.eventBus.uniqueNucleotidesChanged$().subscribe((()=>{this.updateContainer()}))}getContainer(){return this.togglesContainer}updateContainer(){L()(this.togglesContainer).empty(),L()(this.togglesContainer).append(this.createInputs())}createInputs(){const t=this.eventBus.getUniqueNucleotides().filter((t=>!rt(t))).map((t=>this.createSingleInput(t)));return t.sort(((t,e)=>t.captionLabel.textContent.localeCompare(e.captionLabel.textContent))),P.divH(t.map((t=>t.root)))}createSingleInput(t){const e=this.eventBus.getModificationsWithNumericLabels().includes(t),n=P.input.bool(t,{value:e,onValueChanged:e=>this.handleNumericLabelToggle(t,e)});return L()(n.root).css("padding-right","20px"),n.setTooltip(`Show numeric labels for ${t}`),n}handleNumericLabelToggle(t,e){const n=this.eventBus.getModificationsWithNumericLabels();if(n.includes(t)===e)return;const r=e?n.concat(t):n.filter((e=>e!==t));this.eventBus.updateModificationsWithNumericLabels(r)}}class te{constructor(t,e){this.eventBus=t,this.dataManager=e,this.subscriptions=new Lt}createContainer(){return P.div([P.h1("Translation example"),this.createTranslationExamples()],{style:{paddingTop:"20px"}})}createTranslationExamples(){const t=P.divH([...this.getExampleElements()],"ui-form");return this.eventBus.antisenseStrandToggled$.subscribe((()=>{this.subscriptions.unsubscribeAll(),L()(t).empty(),L()(t).append(this.getExampleElements())})),t}getExampleElements(){return k.map((t=>new ee(t,this.eventBus,this.subscriptions).create()))}}class ee{constructor(t,e,n){this.strand=t,this.eventBus=e,this.subscriptions=n}create(){return this.eventBus.isAntisenseStrandActive()||"AS"!==this.strand?(this.inputExample=this.createInputExample(),this.outputExample=this.createOutputExample(this.inputExample.value),this.subscribeToEvents(),P.block50([P.h2(H[this.strand]),this.inputExample.root,this.outputExample.root],{style:{paddingRight:"20px"}})):P.div([])}subscribeToEvents(){const t=this.eventBus.strandsLinkagesAndTerminalsUpdated$.subscribe((()=>{const t=this.generateExampleSequence();this.inputExample.value=t,this.outputExample.value=this.computeOutputValue(t)}));"AS"===this.strand&&this.subscriptions.add(t)}createInputExample(){const t=this.createTextInputForExamples(),e=this.generateExampleSequence();return t.value=e,t.setTooltip(`Example raw nucleotides input for ${H[this.strand]}`),t}generateExampleSequence(){return this.eventBus.getNucleotideSequences()[this.strand].map(((t,e)=>m.AL[e%m.AL.length])).join("")}createOutputExample(t){const e=this.createTextInputForExamples();return e.value=this.computeOutputValue(t),e.setTooltip(`Pattern applied to the example input for ${H[this.strand]}`),e}computeOutputValue(t){const e=this.eventBus.getNucleotideSequences()[this.strand],n=this.eventBus.getTerminalModifications()[this.strand];return Nt(t,e,this.eventBus.getPhosphorothioateLinkageFlags()[this.strand],n)}createTextInputForExamples(){const t=P.input.textArea("",{value:""});return this.applyStylingToInput(t),t}applyStylingToInput(t){const e=t.root.getElementsByTagName("textarea")[0];e.setAttribute("readonly","true"),L()(e).css("resize","none"),L()(t.root).css("opacity","75%")}}class ne{constructor(t,e){this.eventBus=t,this.dataManager=e,this.svgDisplay=Xt.createSvgDiv(t)}getLayout(){const t=new Zt(this.eventBus).getContainer(),e=this.generateDownloadControls(),n=new te(this.eventBus,this.dataManager).createContainer();return P.panel([this.svgDisplay,t,e,n],{style:{overflowX:"scroll",padding:"12px 24px"}})}generateDownloadControls(){return P.divH([this.createSavePatternButton(),this.createDownloadPngButton(),this.createShareLinkButton(),this.createInfoButton()],{style:{gap:"12px",marginTop:"12px"}})}createDownloadPngButton(){const t=P.button("Get PNG",(()=>this.eventBus.requestSvgSave()));return P.tooltip.bind(t,"Download pattern as PNG"),t}createInfoButton(){const t=P.button(P.iconFA("info-circle"),(()=>this.openInfoDialog()));return this.eventBus.patternHasUnsavedChanges$.subscribe((e=>{t.disabled=e})),P.tooltip.bind(t,"View pattern metadata"),t}async openInfoDialog(){let t=this.dataManager.getCurrentUserName(),e=this.dataManager.getDefaultPatternName(),n=K,o=K;const i=new URLSearchParams(window.location.search).get("pattern");if(null!==i){const s=await this.dataManager.getPatternRecordByHash(i);if(null!==s){const i=s[q.AUTHOR_ID];if(t=(await r.dapi.users.find(i)).friendlyName,e=s[q.PATTERN_CONFIG][j.PATTERN_NAME],void 0!==s[q.DATE]){const t=s[q.DATE][W.CREATE];void 0!==t&&(n=t);const e=s[q.DATE][W.MODIFY];void 0!==e&&(o=e)}}}const s=P.divV([P.divText(`Pattern Name: ${e}`),P.divText(`Author: ${t}`),P.divText(`Created: ${oe(new Date(n))}`),P.divText(`Modified: ${oe(new Date(o))}`)]);r.shell.info(s)}createShareLinkButton(){const t=P.button(P.iconFA("link"),(()=>navigator.clipboard.writeText(window.location.href).then((()=>r.shell.info("Link to pattern copied to clipboard")))));return this.eventBus.patternHasUnsavedChanges$.subscribe((e=>{t.disabled=e})),P.tooltip.bind(t,"Share pattern link"),t}createSavePatternButton(){const t=P.button("Save",(()=>this.processSaveButtonClick()));return this.eventBus.patternHasUnsavedChanges$.subscribe((e=>{t.disabled=!e})),P.tooltip.bind(t,"Save pattern to user storage"),t}processSaveButtonClick(){const t=this.eventBus.getPatternName();t!==this.dataManager.getDefaultPatternName()?""!==t?this.dataManager.savePatternToUserStorage(this.eventBus).then((()=>{r.shell.info(`Pattern ${t} saved`)})).catch((t=>this.handleErrorWhileSavingPattern(t))):r.shell.warning("Insert pattern name"):r.shell.warning("Cannot save default pattern")}handleErrorWhileSavingPattern(t){t instanceof Q?new re(this.eventBus,this.dataManager).show():t instanceof J?r.shell.warning(P.div([P.divText("Pattern already exists"),P.button("Load",(()=>{const e=t.message;this.eventBus.requestLoadPatternInNewTab(e)}))])):console.error("Error while saving pattern",t)}}class re{constructor(t,e){this.eventBus=t,this.dataManager=e}show(){const t=this.eventBus.getPatternName(),e=P.dialog(`Pattern "${t}" already exists`);e.add(P.divText(`Pattern "${t}" already exists. Do you want to overwrite it?`)),e.show(),e.onOK((()=>this.processOverwriteNamesakePattern()))}processOverwriteNamesakePattern(){const t=this.eventBus.getPatternName();this.dataManager.overwriteExistingPatternInUserStorage(this.eventBus).then((()=>{r.shell.info(`Pattern ${t} overwritten`)})).catch((t=>{console.error("Error while overwriting pattern in user storage",t),r.shell.error("Error while overwriting pattern")}))}}function oe(t){return t.toLocaleString().split(":").slice(0,-1).join(":")}class ie extends F{constructor(t){super("Oligo Pattern"),this.th=t}getContent(){return async function(){const t=await tt.getInstance(),e=new ht,n=await async function(t,e){const n=e.getPatternHash();if(!n)return e.clearPatternURL(),t.getDefaultPatternRecord();let r=await t.getPatternRecordByHash(n);return r||(e.clearPatternURL(),r=t.getDefaultPatternRecord()),r}(t,e),r=new ct(t,n);e.subscribeToObservables(r);const o=new Ft(r,t).getLayout(),i=new ne(r,t).getLayout();return P.splitH([o,i],{},!0)}()}}var se=n(8507),ae={};function le(t){var e;return"string"==typeof t||t instanceof String?t:("object"==typeof t||t instanceof Object)&&"$thrownJsError"in t?le(t.$thrownJsError):t instanceof Error?null!==(e=t.stack)&&void 0!==e?e:t.message:t.toString()}ae.styleTagTransform=At(),ae.setAttributes=vt(),ae.insert=yt().bind(null,"head"),ae.domAPI=mt(),ae.insertStyleElement=xt(),pt()(se.A,ae),se.A&&se.A.locals&&se.A.locals;var ce,ue=n(2074),he={};he.styleTagTransform=At(),he.setAttributes=vt(),he.insert=yt().bind(null,"head"),he.domAPI=mt(),he.insertStyleElement=xt(),pt()(ue.A,he),ue.A&&ue.A.locals&&ue.A.locals;class de{constructor(t,e,n=!0){this.textInputBase=t,this.painter=e,L()(this.root).addClass("st-colored-text-input"),n&&this.textInputBase.onChanged.subscribe((()=>{L()(this.textArea).css("height",0),L()(this.textArea).css("height",this.textArea.scrollHeight+"px")})),this.highlights=P.div([]),this.root.appendChild(this.highlights),this.colorize(),this.textInputBase.onChanged.subscribe((()=>this.colorize()))}get textArea(){return this.textInputBase.root.getElementsByTagName("textarea").item(0)}get inputBase(){return this.textInputBase}get root(){return this.textInputBase.root}colorize(){const t=this.painter(this.textInputBase.value);this.highlights.innerHTML="",t.forEach((t=>this.highlights.appendChild(t)))}}!function(t){t.TYPE="V2000",t[t.NUM_OF_HEADER_LINES=3]="NUM_OF_HEADER_LINES",t[t.NUM_OF_COUNTS_DIGITS=3]="NUM_OF_COUNTS_DIGITS",t[t.ATOM_TYPE_COL=4]="ATOM_TYPE_COL",t[t.FIRST_BONDED_ATOM_COL=1]="FIRST_BONDED_ATOM_COL",t[t.BOND_TYPE_COL=3]="BOND_TYPE_COL",t[t.RGP_SHIFT=8]="RGP_SHIFT",t[t.MAX_ATOM_COUNT=999]="MAX_ATOM_COUNT",t.RGP_LINE_START="M RGP",t.ATOM_ALIAS_LINE_START="A ",t.END="M END"}(ce||(ce={}));class pe{constructor(t){this.init(t)}init(t){this.fileContent=t.replace(/\r/g,""),this._atomCount=void 0,this._atomTypes=void 0,this._bondCount=void 0,this._bondTypes=void 0,this.xyzAtomCoordinates=void 0,this._pairsOfBondedAtoms=void 0}get atomCount(){return void 0===this._atomCount&&this.setAtomAndBondCounts(),this._atomCount}get bondCount(){return void 0===this._bondCount&&this.setAtomAndBondCounts(),this._bondCount}get x(){var t;return null!==(t=this.xyzAtomCoordinates)&&void 0!==t||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.x}get y(){var t;return null!==(t=this.xyzAtomCoordinates)&&void 0!==t||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.y}get z(){var t;return null!==(t=this.xyzAtomCoordinates)&&void 0!==t||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.z}get atomTypes(){var t;return null!==(t=this._atomTypes)&&void 0!==t||(this._atomTypes=this.parseAtomTypes()),this._atomTypes}get pairsOfBondedAtoms(){var t;return null!==(t=this._pairsOfBondedAtoms)&&void 0!==t||(this._pairsOfBondedAtoms=this.parseBondedAtomPairs()),this._pairsOfBondedAtoms}get bondTypes(){var t;return null!==(t=this._bondTypes)&&void 0!==t||(this._bondTypes=this.parseBondTypes()),this._bondTypes}setAtomAndBondCounts(){const{atomCount:t,bondCount:e}=this.parseAtomAndBondCounts();this._atomCount=t,this._bondCount=e}getNextColumnIdx(t){for(;!this.isWhitespace(t);)++t;for(;this.isWhitespace(t);)++t;return t}shiftIdxToSpecifiedColumn(t,e){let n=t;const r=this.isWhitespace(n)?e:e-1;for(let t=0;t<r;t++)n=this.getNextColumnIdx(n);return n}parseAtomTypes(){const t=this.atomCount,e=new Array(t);let n=this.getAtomBlockIdx();for(let r=0;r<t;r++)n=this.shiftIdxToAtomType(n),e[r]=this.parseAtomType(n),n=this.getNextLineIdx(n);return e}parseAtomCoordinates(){const t=new Float32Array(this.atomCount),e=new Float32Array(this.atomCount),n=new Float32Array(this.atomCount);let r=this.getAtomBlockIdx();for(let o=0;o<this.atomCount;o++){r=this.shiftIdxToXColumn(r);for(const i of[t,e,n])i[o]=this.parseFloatValue(r),r=this.getNextColumnIdx(r);r=this.getNextLineIdx(r)}return{x:t,y:e,z:n}}parseBondedAtomPairs(){const t=new Array(this.bondCount);let e=this.getBondBlockIdx();for(let n=0;n<this.bondCount;n++){e=this.shiftIdxToBondedAtomsPair(e);const r=new Uint16Array(2);r[0]=this.parseIntValue(e),e=this.getNextColumnIdx(e),r[1]=this.parseIntValue(e),t[n]=r,e=this.getNextLineIdx(e)}return t}parseBondTypes(){const t=this.bondCount,e=new Uint16Array(t);let n=this.getBondBlockIdx();for(let r=0;r<t;r++)n=this.shiftIdxToBondType(n),e[r]=this.parseIntValue(n),n=this.getNextLineIdx(n);return e}isWhitespace(t){const e=this.fileContent[t];return" "===e||"\t"===e}getNextLineIdx(t){return"\n"!==this.fileContent[t]?this.fileContent.indexOf("\n",t)+1:t+1}parseFloatValue(t){return this.parseNumericValue(parseFloat,t)}parseIntValue(t){return this.parseNumericValue(parseInt,t)}parseNumericValue(t,e){let n=e+1;for(;!this.isWhitespace(n);)++n;return t(this.fileContent.substring(e,n))}}class fe extends pe{constructor(t){super(t),this.init(t)}init(t){super.init(t)}parseAtomType(t){let e=t,n=e;return this.isQuote(e)?(n=this.getNextIdenticalChar(e),e++):n=this.fileContent.indexOf(" ",n),this.fileContent.substring(e,n)}isQuote(t){const e=this.fileContent[t].charCodeAt(0);return 39===e||34===e}getNextIdenticalChar(t){const e=this.fileContent[t];return e?this.fileContent.indexOf(e,t+1):-1}isQuery(){return this.isQueryOrFragment(((t,e)=>{return 39===t||34===t||76===t&&!((n=this.fileContent.charCodeAt(e+1))>64&&n<91||n>96&&n<123);var n}))}isFragment(){return this.isQueryOrFragment((t=>82===t||42===t))}isQueryOrFragment(t){const e=this.atomCount;let n=this.getAtomBlockIdx();for(let r=0;r<e;r++){if(n=this.shiftIdxToAtomType(n),t(this.fileContent.charCodeAt(n),n))return!0;n=this.getNextLineIdx(n)}return!1}}class me extends fe{constructor(t){super(t)}getAtomLines(){const t=this.getAtomBlockIdx(),e=this.getBondBlockIdx();return this.fileContent.substring(t,e).split("\n").slice(0,this.atomCount)}getBondLines(){const t=this.getBondBlockIdx();return this.fileContent.substring(t).split("\n").slice(0,this.bondCount)}getRGroupIdToAtomicIdxMap(){const t=new Map,e=this.fileContent.split("\n");e.filter((t=>t.startsWith(ce.RGP_LINE_START))).forEach((e=>{const n=this.getAtomIdxToRgpIdxList(e);for(const[e,r]of n){if(t.has(e))throw new Error(`R group ${e} is already in the map`);t.set(e,r)}}));const n=e.map(((t,e)=>{if(t.startsWith(ce.ATOM_ALIAS_LINE_START))return e})).filter((t=>void 0!==t)),r=n.map((t=>e[t])),o=n.map((t=>e[t+1]));r.forEach(((e,n)=>{const r=parseInt(e.split(/\s+/)[1])-1,i=parseInt(o[n].substring(1));if(t.has(i))throw new Error(`R group ${i} is already in the map`);t.set(i,r)}));const i=this.getRGroupAtomicIndices().filter((e=>!Array.from(t.values()).includes(e)));if(0!==i.length)throw new Error(`Unaccounted R group indices: ${i}`);return t}getAtomIdxToRgpIdxList(t){const e=t.split(/\s+/).filter((t=>t)).slice(3).map((t=>parseInt(t))),n=new Array(e.length/2);for(let t=0;t<e.length;t+=2)n[t/2]=[e[t+1],e[t]-1];return n}getRGroupAtomicIndices(){return this.atomTypes.map(((t,e)=>{if(t.includes("R#"))return e})).filter((t=>void 0!==t))}static isValidMolfile(t){return-1!==t.indexOf(ce.TYPE)&&-1!==t.indexOf(ce.END)}shiftIdxToAtomType(t){return this.shiftIdxToSpecifiedColumn(t,ce.ATOM_TYPE_COL)}getCountsLineIdx(){let t=0;for(let e=0;e<ce.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,ce.FIRST_BONDED_ATOM_COL)}shiftIdxToBondType(t){return this.shiftIdxToSpecifiedColumn(t,ce.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+ce.NUM_OF_COUNTS_DIGITS;const n=parseInt(this.fileContent.substring(t,e));return t=e,e+=ce.NUM_OF_COUNTS_DIGITS,{atomCount:n,bondCount:parseInt(this.fileContent.substring(t,e))}}}class ge extends fe{constructor(t){super(t),this.init(t)}getAtomLines(){const t=this.getAtomBlockIdx(),e=this.getBondBlockIdx();return this.fileContent.substring(t,e).split("\n").slice(0,this.atomCount)}getBondLines(){const t=this.getBondBlockIdx();return this.fileContent.substring(t).split("\n").slice(0,this.bondCount)}getRGroupIdToAtomicIdxMap(){const t=new Map;return this.getAtomLines().forEach(((e,n)=>{const r=e.match(/RGROUPS=\(([\d\s]+)\)/);if(r){const e=r[1].split(/\s+/).map((t=>parseInt(t)));if(e.length>2)throw new Error(`R group data ${e} has more than 2 elements`);const o=e[1];if(t.has(o))throw new Error(`R group ${o} is already in the map`);t.set(o,n)}})),t}shiftIdxToAtomType(t){return this.shiftIdxToSpecifiedColumn(t,4)}getCountsLineIdx(){return this.fileContent.indexOf("M V30 COUNTS ")}getAtomBlockIdx(){let t=this.fileContent.indexOf("M V30 BEGIN ATOM");return t=this.getNextLineIdx(t),t}shiftIdxToXColumn(t){let e=this.shiftIdxToAtomType(t);return this.isQuote(e)?(e=this.getNextIdenticalChar(e),e=this.getNextColumnIdx(e),e):this.shiftIdxToSpecifiedColumn(t,5)}shiftIdxToBondedAtomsPair(t){return this.shiftIdxToSpecifiedColumn(t,5)}shiftIdxToBondType(t){return this.shiftIdxToSpecifiedColumn(t,4)}getBondBlockIdx(){return this.getNextLineIdx(this.fileContent.indexOf("M V30 BEGIN BOND"))}static isValidMolfile(t){return-1!==t.indexOf("V3000")&&-1!==t.indexOf("M END")}parseAtomAndBondCounts(){let t=this.fileContent.indexOf("M V30 COUNTS ")+14,e=this.fileContent.indexOf(" ",t+1);const n=parseInt(this.fileContent.substring(t,e));return t=e+1,e=this.fileContent.indexOf(" ",t+1),{atomCount:n,bondCount:parseInt(this.fileContent.substring(t,e))}}}class ye{constructor(){}static getInstance(t){if(ye.isMolfileV2K(t))return new me(t);if(ye.isMolfileV3K(t))return new ge(t);throw new Error("Malformed molfile")}static isMolfileV2K(t){return me.isValidMolfile(t)}static isMolfileV3K(t){return ge.isValidMolfile(t)}}const be=class extends Error{constructor(t){super(t)}};class ve{constructor(t){this.molblock=t}get molblock(){return this._validMolBlock}set molblock(t){if(""!==t){try{this.validateMolBlock(t)}catch(e){e instanceof be&&(t="");const n=le(e);console.error(n)}this._validMolBlock=t}else this._validMolBlock=t}validateMolBlock(t){if(""===t)throw new be("MoleculeImage: invalid molblock")}async drawMolBlockOnCanvas(t){try{await r.functions.call("Chem:canvasMol",{x:0,y:0,w:t.width,h:t.height,canvas:t,molString:this.molblock,scaffoldMolString:"",options:{normalizeDepiction:!1,straightenDepiction:!1}})}catch(t){const e=le(t);console.error(e)}}getMoleculeDimensions(){const t=ye.getInstance(this.molblock),e=Math.max(...t.x)-Math.min(...t.x);return{height:Math.max(...t.y)-Math.min(...t.y),width:e}}async zoomIn(){const t=P.dialog({title:"Molecule",showFooter:!1}),e=.7*L()(window).height(),n=this.getMoleculeDimensions(),r=e/n.height,o=e,i=n.width*r,s=P.canvas(i,o);await this.drawMolBlockOnCanvas(s);const a=P.block([s],{style:{overflowX:"scroll"}});t.add(a).showModal(!0),L()(t.root).find(".d4-dialog-contents").removeClass("ui-form"),L()(t.root).find(".d4-dialog-contents").removeClass("ui-panel"),L()(t.root).find(".d4-dialog-contents").addClass("ui-box"),L()(t.root).find(".d4-dialog-contents").css("padding","0")}async drawMolecule(t,e,n){t.innerHTML="";const r=P.canvas(e*window.devicePixelRatio,n*window.devicePixelRatio);r.style.width=`${e}px`,r.style.height=`${n}px`,r.style.cursor="zoom-in",this.drawMolBlockOnCanvas(r),r.addEventListener("click",(async()=>{await this.zoomIn()})),t.append(P.tooltip.bind(r,"Click to zoom"))}}class Ce extends Error{constructor(t,e){super(t,e)}}class xe{constructor(t,e){this.sequence=t,this.codeMap=e}parseSequence(){const t=this.parseRawSequence();return this.addLinkers(t)}addLinkers(t){const e=[];return t.forEach(((n,r)=>{const o=this.getSymbolForCode(n);r>0&&function(t){return Yr.jsonData.monomersWithPhosphate.left.includes(t)}(o)&&e.pop(),e.push(o);const i=we(o),s=r===t.length-1,a=r+1<t.length&&we(this.getSymbolForCode(t[r+1]));i||function(t){return Yr.jsonData.monomersWithPhosphate.right.includes(t)}(o)||a||s||e.push("p")})),e}getSymbolForCode(t){let e=this.codeMap.get(t);return e??(e=t),e}parseRawSequence(){const t=this.getAllCodesOfFormat(),e=[];let n=0;for(;n<this.sequence.length;){const r=t.find((t=>t===this.sequence.substring(n,n+t.length)));if(void 0===r)throw new Ce(`Unable to match a monomer for the rest of the sequence '${this.sequence.slice(n)}'.`);e.push(r),n+=r.length}return e}getAllCodesOfFormat(){return g(Array.from(this.codeMap.keys()))}}function we(t){return Yr.jsonData.monomersWithPhosphate.phosphate.includes(t)}class Ae{constructor(t,e=!1,n){this.invert=e,this.lib=Yr.monomerLibWrapper;const r=this.lib.getCodeToSymbolMap(n);this.parser=new xe(t,r)}convert(){const t=this.parser.parseSequence(),e=[];t.forEach(((t,n)=>{const r=this.getMonomerMolfile(t,n);e.push(r)}));let n=this.getPolymerMolfile(e);return this.invert&&(n=this.reflect(n),n=this.invertBondConfiguration(n)),n}invertBondConfiguration(t){const e=t.indexOf("M V30 BEGIN BOND"),n=t.indexOf("M V30 END BOND");let r=t.substring(e,n);return r=r.replace(/(CFG=)([13])/g,((t,e,n)=>"1"===n?`${e}3`:"3"===n?`${e}1`:t)),t.substring(0,e)+r+t.substring(n)}getMonomerMolfile(t,e){const n=this.lib.getMolfileBySymbol(t);return this.lib.isModification(t)?0===e?this.reflect(n):n:this.rotateNucleotidesV3000(n)}getPolymerMolfile(t){return this.linkV3000(t)}reflect(t){const e=this.extractAtomDataV3000(t),n=e.atomIndex.length,r=e.atomIndex.indexOf(1),o=e.atomIndex.indexOf(n),i=(e.x[o]+e.x[r])/2,s=(e.y[o]+e.y[r])/2;for(let t=0;t<n;t++)e.x[t]-=i,e.y[t]-=s;for(let t=0;t<n;t++)e.x[t]=-e.x[t];const a=e.x[r];for(let t=0;t<n;t++)e.x[t]-=a;let l=t.indexOf("M V30 BEGIN ATOM");l=t.indexOf("\n",l);let c=l;for(let r=0;r<n;r++)l=t.indexOf("V30",l)+4,l=t.indexOf(" ",l)+1,l=t.indexOf(" ",l)+1,c=t.indexOf(" ",l)+1,c=t.indexOf(" ",c),l=(t=t.slice(0,l)+e.x[r]+" "+e.y[r]+t.slice(c)).indexOf("\n",l)+1;return t}extractAtomDataV3000(t){const e=this.extractAtomsBondsNumbersV3000(t);let n=t.indexOf("M V30 BEGIN ATOM");n=t.indexOf("\n",n);let r=n;const o=Array(e.natom),i=Array(e.natom),s=Array(e.natom),a=Array(e.natom);for(let l=0;l<e.natom;l++)n=t.indexOf("V30",n)+4,r=t.indexOf(" ",n),o[l]=parseInt(t.substring(n,r)),n=r+1,r=t.indexOf(" ",n),i[l]=t.substring(n,r),n=r+1,r=t.indexOf(" ",n),s[l]=parseFloat(t.substring(n,r)),n=r+1,r=t.indexOf(" ",n),a[l]=parseFloat(t.substring(n,r)),n=t.indexOf("\n",n)+1;return{atomIndex:o,atomType:i,x:s,y:a}}extractAtomsBondsNumbersV3000(t){let e=(t=t.replaceAll("\r","")).indexOf("COUNTS")+7,n=t.indexOf(" ",e);const r=parseInt(t.substring(e,n));return e=n+1,n=t.indexOf(" ",e),{natom:r,nbond:parseInt(t.substring(e,n))}}rotateNucleotidesV3000(t){const e=this.extractAtomDataV3000(t),n=e.atomIndex.length,r=e.atomIndex.indexOf(1),o=e.atomIndex.indexOf(n);n>8&&this.fix5Prime(e,r,o);const i=(e.x[o]+e.x[r])/2,s=(e.y[o]+e.y[r])/2;for(let t=0;t<n;t++)e.x[t]-=i,e.y[t]-=s;let a=0;if(0===e.x[r])a=e.y[r]>e.y[o]?Math.PI/2:3*Math.PI/2;else if(0===e.y[r])a=e.x[r]>e.x[o]?Math.PI:0;else{const t=e.y[r]/e.x[r];a=t>0?e.x[r]>0?Math.PI-Math.atan(t):2*Math.PI-Math.atan(t):e.x[r]>0?-Math.PI-Math.atan(t):Math.atan(t)}const l=Math.cos(a),c=Math.sin(a);for(let t=0;t<n;t++){const n=e.x[t];e.x[t]=n*l-e.y[t]*c,e.y[t]=n*c+e.y[t]*l}const u=e.x[r];for(let t=0;t<n;t++)e.x[t]-=u;let h=t.indexOf("M V30 BEGIN ATOM");h=t.indexOf("\n",h);let d=h;for(let r=0;r<n;r++)h=t.indexOf("V30",h)+4,h=t.indexOf(" ",h)+1,h=t.indexOf(" ",h)+1,d=t.indexOf(" ",h)+1,d=t.indexOf(" ",d),h=(t=t.slice(0,h)+e.x[r]+" "+e.y[r]+t.slice(d)).indexOf("\n",h)+1;return t}linkV3000(t,e=!0){let n="\n Datagrok macromolecule handler\n\n";n+=" 0 0 0 0 0 0 999 V3000\n",n+="M V30 BEGIN CTAB\n";let r="",o="",i="";const s=[];let a=0,l=0,c=0;for(let e=0;e<t.length;e++){const n=t[e].includes("MODIFICATION")&&0===e;let i=0;n&&(i=this.extractAtomDataV3000(t[e]).atomIndex.length),t[e]=t[e].replaceAll("(-\nM V30 ","(").replaceAll("-\nM V30 ","").replaceAll(" )",")");const u=this.extractAtomsBondsNumbersV3000(t[e]),h=this.extractAtomDataV3000(t[e]);let d=t[e].indexOf("M V30 BEGIN ATOM");d=t[e].indexOf("\n",d);let p=d,f=d;for(let r=0;r<u.natom;r++)if(1!==h.atomIndex[r]||0===e){p=t[e].indexOf("V30",p)+4,f=t[e].indexOf(" ",p);let r=0;n?(r=parseInt(t[e].substring(p,f)),1===r?r=i:r===i&&(r=1),r+=a):r=parseInt(t[e].substring(p,f))+a,t[e]=t[e].slice(0,p)+r+t[e].slice(f),p=t[e].indexOf(" ",p)+1,p=t[e].indexOf(" ",p)+1,f=t[e].indexOf(" ",p);const o=c-h.x[0];let s=Math.round(1e4*(parseFloat(t[e].substring(p,f))+o))/1e4;t[e]=t[e].slice(0,p)+s+t[e].slice(f),p=t[e].indexOf(" ",p)+1,f=t[e].indexOf(" ",p),s=Math.round(1e4*parseFloat(t[e].substring(p,f)))/1e4,t[e]=t[e].slice(0,p)+s+t[e].slice(f),p=t[e].indexOf("\n",p)+1}else p=t[e].indexOf("M V30",p)-1,f=t[e].indexOf("\n",p+1),t[e]=t[e].slice(0,p)+t[e].slice(f);const m=t[e].indexOf("M V30 END ATOM");r+=t[e].substring(d+1,m);let g=t[e].indexOf("M V30 BEGIN BOND");g=t[e].indexOf("\n",g),p=g,f=g;for(let r=0;r<u.nbond;r++){p=t[e].indexOf("V30",p)+4,f=t[e].indexOf(" ",p);const r=parseInt(t[e].substring(p,f))+l;t[e]=t[e].slice(0,p)+r+t[e].slice(f),p=t[e].indexOf(" ",p)+1,p=t[e].indexOf(" ",p)+1,f=t[e].indexOf(" ",p);let o=0;n?(o=parseInt(t[e].substring(p,f)),1===o?o=i:o===i&&(o=1),o+=a):o=parseInt(t[e].substring(p,f))+a,t[e]=t[e].slice(0,p)+o+t[e].slice(f),p=t[e].indexOf(" ",p)+1,f=Math.min(t[e].indexOf("\n",p),t[e].indexOf(" ",p)),o=0,n?(o=parseInt(t[e].substring(p,f)),1===o?o=i:o===i&&(o=1),o+=a):o=parseInt(t[e].substring(p,f))+a,t[e]=t[e].slice(0,p)+o+t[e].slice(f),p=t[e].indexOf("\n",p)+1}const y=t[e].indexOf("M V30 END BOND");o+=t[e].substring(g+1,y);let b=t[e].indexOf("M V30 MDLV30/STEABS ATOMS=(");for(;-1!==b;){b+=28;const n=t[e].indexOf(")",b);t[e].substring(b,n).split(" ").slice(1).forEach((t=>{s.push(parseInt(t)+a)})),b=n,b=t[e].indexOf("M V30 MDLV30/STEABS ATOMS=(",b)}a+=u.natom-1,l+=u.nbond,c+=n?Math.max(...h.x):h.x[u.natom-1]-h.x[0]}const u=Math.ceil(s.length/4);i+="M V30 MDLV30/STEABS ATOMS=("+s.length+" -\n";for(let t=0;t<u;t++){i+="M V30 ";const e=t+1===u?s.length-4*(u-1):4;for(let n=0;n<e;n++)i+=n+1===e?t===u-1?s[4*t+n]+")\n":s[4*t+n]+" -\n":s[4*t+n]+" "}return a++,n+="M V30 COUNTS "+a+" "+l+" 0 0 0\n",n+="M V30 BEGIN ATOM\n",n+=r,n+="M V30 END ATOM\n",n+="M V30 BEGIN BOND\n",n+=o,n+="M V30 END BOND\n",e&&s.length>0?(n+="M V30 BEGIN COLLECTION\n",n+=i,n+="M V30 END COLLECTION\n"):n=n.replace(/ CFG=\d/g," "),n+="M V30 END CTAB\n",n+="M END",n}fix5Prime(t,e,n){const r=e+1,o=t.x[r],i=t.y[r],s=t.x[n]-o,a=t.y[n]-i,l=t.x[e]-o,c=t.y[e]-i,u=l*Math.cos(2*Math.PI/3)-c*Math.sin(2*Math.PI/3),h=l*Math.sin(2*Math.PI/3)+c*Math.cos(2*Math.PI/3),d=l-s,p=c-a,f=u-s,m=h-a;Math.sqrt(m*m+f*f)>=Math.sqrt(p*p+d*d)&&(t.x[e]=u+o,t.y[e]=h+i)}}function Te(t,e=!0){let n="\n Datagrok macromolecule handler\n\n";n+=" 0 0 0 0 0 0 999 V3000\n",n+="M V30 BEGIN CTAB\n";let r="",o="",i="";const s=[];let a=0,l=0,c=0;if(t.antiStrands.length>0)for(let e=0;e<t.antiStrands.length;e++)t.antiStrands[e]=Ee(t.antiStrands[e]);let u=!1;const h=t.senseStrands.concat(t.antiStrands);let d=0;for(let e=0;e<h.length;e++){h[e]=h[e].replaceAll("(-\nM V30 ","(").replaceAll("-\nM V30 ","").replaceAll(" )",")");const n=Se(h[e]),i=Ie(h[e]);if(e>=t.senseStrands.length?!1===u&&(u=!0,c=0):d=Math.min(d,Math.min(...i.y.filter((t=>t<0)))),u){const t=Math.min(...i.x)-c,e=Math.max(...i.y)+5;for(let e=0;e<i.x.length;e++)i.x[e]-=t;for(let t=0;t<i.y.length;t++)i.y[t]-=e-d}let p=h[e].indexOf("M V30 BEGIN ATOM");p=h[e].indexOf("\n",p);let f=p,m=p;for(let t=0;t<n.natom;t++){f=h[e].indexOf("V30",f)+4,m=h[e].indexOf(" ",f);const n=parseInt(h[e].substring(f,m))+a;h[e]=h[e].slice(0,f)+n+h[e].slice(m),f=h[e].indexOf(" ",f)+1,f=h[e].indexOf(" ",f)+1,m=h[e].indexOf(" ",f);let r=Math.round(1e4*i.x[t])/1e4;h[e]=h[e].slice(0,f)+r+h[e].slice(m),f=h[e].indexOf(" ",f)+1,m=h[e].indexOf(" ",f),r=Math.round(1e4*i.y[t])/1e4,h[e]=h[e].slice(0,f)+r+h[e].slice(m),f=h[e].indexOf("\n",f)+1}const g=h[e].indexOf("M V30 END ATOM");r+=h[e].substring(p+1,g);let y=h[e].indexOf("M V30 BEGIN BOND");y=h[e].indexOf("\n",y),f=y,m=y;for(let t=0;t<n.nbond;t++){f=h[e].indexOf("V30",f)+4,m=h[e].indexOf(" ",f);const t=parseInt(h[e].substring(f,m))+l;h[e]=h[e].slice(0,f)+t+h[e].slice(m),f=h[e].indexOf(" ",f)+1,f=h[e].indexOf(" ",f)+1,m=h[e].indexOf(" ",f);let n=parseInt(h[e].substring(f,m))+a;h[e]=h[e].slice(0,f)+n+h[e].slice(m),f=h[e].indexOf(" ",f)+1,m=Math.min(h[e].indexOf("\n",f),h[e].indexOf(" ",f)),n=parseInt(h[e].substring(f,m))+a,h[e]=h[e].slice(0,f)+n+h[e].slice(m),f=h[e].indexOf("\n",f)+1}const b=h[e].indexOf("M V30 END BOND");o+=h[e].substring(y+1,b);let v=h[e].indexOf("M V30 MDLV30/STEABS ATOMS=(");for(;-1!==v;){v+=28;const t=h[e].indexOf(")",v);h[e].substring(v,t).split(" ").slice(1).forEach((t=>{s.push(parseInt(t)+a)})),v=t,v=h[e].indexOf("M V30 MDLV30/STEABS ATOMS=(",v)}a+=n.natom,l+=n.nbond,c+=Math.max(...i.x)+5}const p=Math.ceil(s.length/4);i+="M V30 MDLV30/STEABS ATOMS=("+s.length+" -\n";for(let t=0;t<p;t++){i+="M V30 ";const e=t+1===p?s.length-4*(p-1):4;for(let n=0;n<e;n++)i+=n+1===e?t===p-1?s[4*t+n]+")\n":s[4*t+n]+" -\n":s[4*t+n]+" "}return n+="M V30 COUNTS "+a+" "+l+" 0 0 0\n",n+="M V30 BEGIN ATOM\n",n+=r,n+="M V30 END ATOM\n",n+="M V30 BEGIN BOND\n",n+=o,n+="M V30 END BOND\n",e&&s.length>0?(n+="M V30 BEGIN COLLECTION\n",n+=i,n+="M V30 END COLLECTION\n"):n=n.replace(/ CFG=\d/g," "),n+="M V30 END CTAB\n",n+="M END",n}function Ee(t){const e=Ie(t),n=e.atomIndex.length,r=(Math.max(...e.x)+Math.min(...e.x))/2,o=(Math.max(...e.y)+Math.min(...e.y))/2;for(let t=0;t<n;t++)e.x[t]-=r,e.y[t]-=o;const i=Math.PI,s=Math.cos(i),a=Math.sin(i);for(let t=0;t<n;t++){const n=e.x[t];e.x[t]=n*s-e.y[t]*a,e.y[t]=n*a+e.y[t]*s}const l=Math.max(...e.y);for(let t=0;t<n;t++)e.x[t]+=r,e.y[t]-=l;let c=t.indexOf("M V30 BEGIN ATOM");c=t.indexOf("\n",c);let u=c;for(let r=0;r<n;r++)c=t.indexOf("V30",c)+4,c=t.indexOf(" ",c)+1,c=t.indexOf(" ",c)+1,u=t.indexOf(" ",c)+1,u=t.indexOf(" ",u),c=(t=t.slice(0,c)+e.x[r]+" "+e.y[r]+t.slice(u)).indexOf("\n",c)+1;return t}function Se(t){let e=(t=t.replaceAll("\r","")).indexOf("COUNTS")+7,n=t.indexOf(" ",e);const r=parseInt(t.substring(e,n));return e=n+1,n=t.indexOf(" ",e),{natom:r,nbond:parseInt(t.substring(e,n))}}function Ie(t){const e=Se(t);let n=t.indexOf("M V30 BEGIN ATOM");n=t.indexOf("\n",n);let r=n;const o=Array(e.natom),i=Array(e.natom),s=Array(e.natom),a=Array(e.natom);for(let l=0;l<e.natom;l++)n=t.indexOf("V30",n)+4,r=t.indexOf(" ",n),o[l]=parseInt(t.substring(n,r)),n=r+1,r=t.indexOf(" ",n),i[l]=t.substring(n,r),n=r+1,r=t.indexOf(" ",n),s[l]=parseFloat(t.substring(n,r)),n=r+1,r=t.indexOf(" ",n),a[l]=parseFloat(t.substring(n,r)),n=t.indexOf("\n",n)+1;return{atomIndex:o,atomType:i,x:s,y:a}}function Ne(t,e,n){if(""===t)return"";const r=n.createFormatDetector(t).getFormat();if(!r)return"";let o="";try{o=new Ae(t,e,r).convert()}catch(t){const e=le(t);console.error(e)}return o}function _e(t,e,n,r,o){const i=[t,e,n].filter((t=>""!==t.strand));return 1===i.length?Ne(i[0].strand,i[0].invert,o):Te({senseStrands:[Ne(t.strand,t.invert,o)],antiStrands:[Ne(e.strand,e.invert,o),Ne(n.strand,n.invert,o)].filter((t=>""!==t))},r)}const Pe=["ss","as","as2"];class Me{constructor(){this.th=Yr,this.onInput=new et.Subject,this.onInvalidInput=new et.Subject,this.inputBase=Object.fromEntries(Pe.map((t=>{const e=P.input.textArea(t.toUpperCase(),{value:"",onValueChanged:()=>{this.onInput.next(),L()(e.root.getElementsByTagName("div")).css("padding-left","38px")}});return[t,e]}))),this.useChiralInput=P.input.bool("Use chiral",{value:!0}),this.saveAllStrandsInput=P.input.bool("Save as one entity",{value:!0}),P.tooltip.bind(this.saveAllStrandsInput.root,"Save SDF with all strands in one molfile"),this.directionInversion=Object.fromEntries(Pe.map((t=>[t,!1]))),this.moleculeImgDiv=P.block([]),L()(this.moleculeImgDiv).addClass("st-structure-mol-img"),o.debounce(this.onInput,300).subscribe((async()=>{await this.updateMoleculeImg()})),o.debounce(this.onInvalidInput,1e3).subscribe((async()=>{r.shell.warning("Insert Sense strand")}))}async getHtmlDivElement(t){const e=this.getTableInput(t),n=this.getBoolInputsAndButton();await this.updateMoleculeImg();const r=P.divH([this.moleculeImgDiv,n]);L()(r).addClass("st-structure-bottom");const o=P.divV([e,r]);return L()(o).addClass("st-structure-body"),o}getBoolInputsAndButton(){const t=P.buttonsInput([P.bigButton("Save SDF",(()=>{const t=this.getStrandData();!function(t,e,n,o,i,s){const a=[t.strand,e.strand,n.strand].filter((t=>""!==t));if(0===a.length||1===a.length&&""===t.strand)r.shell.warning("Enter SENSE_STRAND and optionally ANTISENSE_STRAND/AS2 to save SDF");else{let l;if(i)l=_e(t,e,n,o,s)+"\n$$$$\n";else{const h=Ne(t.strand,t.invert,s),d=Ne(e.strand,e.invert,s),p=Ne(n.strand,n.invert,s);l=h+"\n> <Sequence>\nSense Strand\n$$$$\n",d&&(l+=d+"\n> <Sequence>\nAnti Sense\n$$$$\n"),p&&(l+=p+"\n> <Sequence>\nAnti Sense 2\n$$$$\n")}const c=new Date;function u(t){return t>=10?t.toString():"0"+t.toString()}y(`SequenceTranslator-${c.getFullYear()+"-"+u(c.getMonth()+1)+"-"+u(c.getDate())+"_"+u(c.getHours())+"-"+u(c.getMinutes())+"-"+u(c.getSeconds())}.sdf`,encodeURIComponent(l))}}(t.ss,t.as,t.as2,this.useChiralInput.value,this.saveAllStrandsInput.value,this.th)}))]),e=[this.saveAllStrandsInput.root,this.useChiralInput.root,t],n=P.divV(e);for(const t of e)L()(t).addClass("st-structure-bool-button-block");return n}getTableInput(t){const e=Object.fromEntries(Pe.map((e=>[e,new de(this.inputBase[e],t.highlightInvalidSubsequence)]))),n=Object.fromEntries(Pe.map(((t,e)=>{const n=0===e?"5′ → 3′":"3′ → 5′";return[t,P.input.choice(`${t.toUpperCase()} direction`,{value:n,items:["5′ → 3′","3′ → 5′"]})]})));Pe.forEach(((t,e)=>{n[t].onChanged.subscribe((n=>{let r="3′ → 5′"===n;e>0&&(r=!r),this.directionInversion[t]=r,this.onInput.next()}))}));const r=["Sense Strand","Anti Sense","Anti Sense 2"],o=new Map(Pe.map(((t,e)=>[t,r[e]]))),i=(Object.fromEntries(Pe.map((t=>[t,P.label(o.get(t))]))),Object.fromEntries(Pe.map((t=>{const n=P.icons.delete((()=>{e[t].inputBase.value=""}),"Delete"),r=P.button(n,(()=>{}));return P.tooltip.bind(r,`Clear ${t.toUpperCase()}`),[t,n]})))),s=P.form([],"st-structure-inputs"),a=P.divV([],"st-structure-clear-buttons"),l=P.form([],"st-direction-inputs");for(const t of Pe)s.append(this.inputBase[t].root),a.append(i[t]),l.append(n[t].root);return P.divH([s,a,l])}getStrandData(){return Object.fromEntries(Pe.map((t=>{const e=this.directionInversion[t];return[t,{strand:this.inputBase[t].value.replace(/\s*/g,""),invert:e}]})))}getMolfile(t,e,n){return _e(t,e,n,this.useChiralInput.value,this.th)}async updateMoleculeImg(){let t="";try{const e=this.getStrandData();Object.values(e).some((t=>""!==t.strand))&&(t=this.getMolfile(e.ss,e.as,e.as2))}catch(t){const e=le(t);console.error(e)}const e=new ve(t);await e.drawMolecule(this.moleculeImgDiv,650,150)}}class Le extends F{constructor(t){super("Oligo Structure"),this.th=t,this.layout=new Me}getContent(){return this.layout.getHtmlDivElement(this.th)}}var Oe=n(2003);async function Re(t){try{const e={overflowX:"scroll"},n=P.div([],{style:e}),o=Ie(t),i=.7*L()(window).height(),s=Math.max(...o.x)-Math.min(...o.x),a=Math.max(...o.y)-Math.min(...o.y),l=i/a,c=l*s,u=l*a,h=P.canvas(c*window.devicePixelRatio,u*window.devicePixelRatio);h.style.width=`${c}px`,h.style.height=`${u}px`,await async function(t,e){await r.functions.call("Chem:canvasMol",{x:0,y:0,w:t.width,h:t.height,canvas:t,molString:e,scaffoldMolString:"",options:{normalizeDepiction:!1,straightenDepiction:!1}})}(h,t),n.appendChild(h),P.dialog("Molecule").add(n).showModal(!0)}catch(t){const e=le(t);console.error(e)}}class De{static async view(){const t=Yr.monomerLibWrapper.getTableForViewer();t.name="Monomer Library";const e=r.shell.addTableView(t);e.grid.props.allowEdit=!1,e.grid.onCellDoubleClick.subscribe((async t=>{const e=t.cell.value;"Molecule"===t.tableColumn?.semType&&await Re(e)}))}}var $e=n(3480),Be=n(5067),Fe=n(5254),ke={};ke.styleTagTransform=At(),ke.setAttributes=vt(),ke.insert=yt().bind(null,"head"),ke.domAPI=mt(),ke.insertStyleElement=xt(),pt()(Fe.A,ke),Fe.A&&Fe.A.locals&&Fe.A.locals;const He=["Sequence"];class Ge{constructor(t){this.th=t,this.inputFormats=Object.keys(Yr.jsonData.codesToHelmDict).concat(m.NO.HELM),this.seqHelper=Yr.seqHelper,this.onInput=new et.Subject,this.moleculeImgDiv=P.div([]),this.moleculeImgDiv.className="mol-host",this.moleculeImgDiv.style.border="1px solid var(--grey-2)",this.moleculeImgDiv.style.borderRadius="1px",this.moleculeImgDiv.style.marginTop="12px",this.outputTableDiv=P.div([]),this.formatChoiceInput=P.input.choice("",{value:m.NO.HELM,items:this.inputFormats,onValueChanged:async(t,e)=>{this.format=t,this.updateTable(),await this.updateMolImg()}}),this.sequenceInputBase=P.input.textArea("",{value:"Afcgacsu",onValueChanged:()=>{this.onInput.next()}}),this.init(),o.debounce(this.onInput,300).subscribe((async()=>{this.init(),this.formatChoiceInput.value=this.format,this.updateTable(),await this.updateMolImg()})),this.eventBus=qe.getInstance()}async getHtmlElement(){const t=this.constructSingleSequenceControls(),e=this.constructBulkTranslationControls(),n=P.box(P.panel([t,e,P.block([P.box(this.moleculeImgDiv)])]));return this.formatChoiceInput.value=this.format,this.updateTable(),await this.updateMolImg(),n}constructBulkTranslationControls(){const t=P.h1("Bulk");P.tooltip.bind(t,"Bulk translation from table input");const e=new Ve(this.eventBus).createUIComponents(),n=P.input.choice("Input format",{value:m.NO.AXOLABS,items:this.inputFormats,onValueChanged:t=>this.eventBus.selectInputFormat(t)}),r=P.input.choice("Output format",{value:Be.qP,items:(0,$e.OT)(this.th),onValueChanged:t=>this.eventBus.selectOutputFormat(t)}),o=this.createConvertBulkButton(),i=P.div([...e,n,r,o],"ui-form");return P.block25([t,i])}createConvertBulkButton(){const t=P.bigButton("Convert",(()=>this.processConvertBulkButtonClick()));return P.tooltip.bind(t,"Convert sequences from table input"),L()(t).css({float:"right","margin-top":"20px"}),t}processConvertBulkButtonClick(){const t=this.eventBus.getSelectedTable();if(!t)return void r.shell.warning("No table selected");const e=this.eventBus.getSelectedInputFormat(),n=this.eventBus.getSelectedOutputFormat(),i=this.eventBus.getSelectedColumn("Sequence");if(!i)return void r.shell.warning("No sequence column selected");const s=`${i.name} (${n})`,a=o.Column.fromList(o.TYPE.STRING,s,i.toList().map((t=>(0,$e.C6)(t,e,n,this.th))));if(n===Be.qP||n===m.NO.HELM){a.semType=o.SEMTYPE.MACROMOLECULE;const t=n==Be.qP?Oe.Hi.FASTA:Oe.Hi.HELM;a.meta.units=t;const e=this.seqHelper.getSeqHandler(a);(n==Be.qP?this.seqHelper.setUnitsToFastaColumn:this.seqHelper.setUnitsToHelmColumn)(e)}t.columns.add(a),r.data.detectSemanticTypes(t),r.shell.v=r.shell.getTableView(t.name)}constructSingleSequenceControls(){const t=new de(this.sequenceInputBase,(t=>O(t,this.th))),e=P.button("Get SDF",(()=>{this.saveMolfile()}),"Save structure as SDF"),n=P.button("Copy SMILES",(()=>{this.copySmiles()}),"Copy SMILES for the sequence"),r=P.div([this.formatChoiceInput]),o=P.button(P.icons.delete((()=>{t.inputBase.value=""}),"Delete"),(()=>{}));P.tooltip.bind(o,"Clear input");const i={format:r,textInput:t.root,clearBtn:o},s=P.table([i],(t=>[t.format,t.textInput,t.clearBtn]));s.classList.add("st-translator-input-table");const a=P.block([this.outputTableDiv,e,n]);return P.block75([P.h1("Single sequence"),s,a])}saveMolfile(){try{const t=new Ae(this.sequence,!1,this.formatChoiceInput.value).convert()+"\n$$$$";y(this.sequence+".sdf",encodeURIComponent(t))}catch(t){r.shell.warning("Unable to save SDF: "+t.message)}}copySmiles(){const t=o.chem.convert(this.molfile,o.chem.Notation.MolBlock,o.chem.Notation.Smiles);navigator.clipboard.writeText(t).then((()=>r.shell.info(Be.n_)))}updateTable(){this.outputTableDiv.innerHTML="";const t=this.format?this.th.createSequenceValidator(this.sequence).getInvalidCodeIndex(this.format):0,e=(0,$e.bD)(this.sequence,t,this.format,this.th),n=[];for(const t of Object.keys(e)){const o="indexOfFirstInvalidChar"in e?P.divH([]):P.link(e[t],(()=>navigator.clipboard.writeText(e[t]).then((()=>r.shell.info(Be.n_)))),Be.U_,"");n.push({format:t,sequence:o})}const o=P.table(n,(t=>[t.format,t.sequence]),["FORMAT","SEQUENCE"]);this.outputTableDiv.append(o),this.outputTableDiv.classList.add("st-translator-output-table")}async updateMolImg(){const t=new ve(this.molfile);await t.drawMolecule(this.moleculeImgDiv,500,170)}init(){this.sequence=this.getFormattedSequence(),this.format=this.th.createFormatDetector(this.sequence).getFormat(),this.molfile=this.getMolfile()}getFormattedSequence(){return this.sequenceInputBase.value.replace(/\s/g,"")}getMolfile(){if(!this.format)return"";if(this.format===m.NO.HELM){const t=this.th.createFormatConverter(this.sequence,this.format).convertTo(m.NO.AXOLABS);return new Ae(t,!1,m.NO.AXOLABS).convert()}return new Ae(this.sequence,!1,this.format).convert()}}class Ve{constructor(t){this.tableInputManager=new Ue(t),this.columnInputManager=new je(t)}createUIComponents(){return[this.tableInputManager.getTableInputContainer(),this.columnInputManager.getColumnControlsContainer()]}}class Ue{constructor(t){this.eventBus=t,this.availableTables=[],this.tableInputContainer=P.div([]),this.subscribeToTableEvents(),this.refreshTableInput()}getTableInputContainer(){return this.tableInputContainer}subscribeToTableEvents(){r.events.onTableAdded.subscribe((t=>this.handleTableAdded(t))),r.events.onTableRemoved.subscribe((t=>this.handleTableRemoved(t))),this.eventBus.tableSelected$.subscribe((()=>this.handleTableChoice()))}getTableFromEventData(t){return t.args.dataFrame}handleTableAdded(t){const e=this.getTableFromEventData(t);this.availableTables.some((t=>t.name===e.name))||(this.availableTables.push(e),this.eventBus.selectTable(e),this.refreshTableInput())}handleTableRemoved(t){const e=this.getTableFromEventData(t);this.availableTables=this.availableTables.filter((t=>t.name!==e.name));const n=this.availableTables[0];this.eventBus.selectTable(n||null),this.refreshTableInput()}refreshTableInput(){const t=this.createTableInput();L()(this.tableInputContainer).empty(),this.tableInputContainer.append(t.root)}createTableInput(){const t=this.eventBus.getSelectedTable();return P.input.table("Table",{value:t,items:this.availableTables,onValueChanged:t=>{null!==t&&this.eventBus.selectTable(t)}})}handleTableChoice(){const t=this.eventBus.getSelectedTable();t&&(this.isTableDisplayed(t)||this.displayTable(t))}isTableDisplayed(t){return r.shell.tableNames.includes(t.name)}displayTable(t){const e=r.shell.v;r.shell.addTableView(t),r.shell.v=e}}class je{constructor(t){this.eventBus=t,this.columnControlsContainer=P.div([]),this.eventBus.tableSelected$.subscribe((()=>this.handleTableChoice())),this.refreshColumnControls()}getColumnControlsContainer(){return this.columnControlsContainer}handleTableChoice(){this.refreshColumnControls()}refreshColumnControls(){const t=this.createColumnInputs();L()(this.columnControlsContainer).empty();const e=t.map((t=>t.root));this.columnControlsContainer.append(...e)}createColumnInputs(){const t=this.eventBus.getSelectedTable(),e=null!==t?t.columns.names().sort(((t,e)=>t.localeCompare(e))):[];return He.map((n=>this.createColumnInput(n,e,t)))}createColumnInput(t,e,n){const r=t.toLowerCase(),o=e.find((t=>t.toLowerCase().includes(r)))||e[0];return this.selectColumnIfTableNotNull(n,o,t),P.input.choice(`${t}`,{value:o,items:e,onValueChanged:e=>this.selectColumnIfTableNotNull(n,e,t)})}selectColumnIfTableNotNull(t,e,n){if(null!==t&&e){const r=t.col(e);r&&this.eventBus.selectColumn(n,r)}}}class qe{constructor(){this._tableSelection$=new et.BehaviorSubject(null),this._columnSelection=Object.fromEntries(He.map((t=>[t,new et.BehaviorSubject(null)]))),this._inputFormatSelection$=new et.BehaviorSubject(m.NO.AXOLABS),this._outputFormatSelection$=new et.BehaviorSubject(Be.qP)}static getInstance(){return void 0===qe._instance&&(qe._instance=new qe),qe._instance}get tableSelected$(){return this._tableSelection$.asObservable()}getSelectedTable(){return this._tableSelection$.getValue()}selectTable(t){this._tableSelection$.next(t)}selectColumn(t,e){this._columnSelection[t].next(e)}getSelectedColumn(t){return this._columnSelection[t].getValue()}getSelectedInputFormat(){return this._inputFormatSelection$.getValue()}selectInputFormat(t){this._inputFormatSelection$.next(t)}selectOutputFormat(t){this._outputFormatSelection$.next(t)}getSelectedOutputFormat(){return this._outputFormatSelection$.getValue()}}class We extends F{constructor(t){super("Oligo Translator"),this.th=t,this.th=Yr,this.layout=new Ge(this.th);const e=P.iconFA("book",De.view,"View monomer library");this.topPanel=[e],this.view.setRibbonPanels([this.topPanel])}getContent(){return this.layout.getHtmlElement()}}class ze extends F{constructor(t,e){super(t),this.content=e}getContent(){return Promise.resolve(this.content)}}class Ye extends B{constructor(t,e){super("Oligo Toolkit"),this.externalViewFactories=t,this.th=e;const n=this.getViewFactories(this.th);this.multiView=new o.MultiView({viewFactories:n})}getViewFactories(t){function e(e){o.View.create();const n=new e(t);return n.initView().catch((t=>console.error(`Failed to initialize ${e.name}: ${t}`))),()=>n.getView()}let n={TRANSLATOR:e(We),PATTERN:e(ie),STRUCTURE:e(Le)};return this.externalViewFactories&&(n=Object.assign({},n,this.externalViewFactories)),n}getCurrentPanePath(){let t=this.multiView.tabs.currentPane.name;return t=t.charAt(0).toUpperCase()+t.substring(1).toLowerCase(),`/apps/${Yr.name}/OligoToolkit/${t}`}setUrl(){this.multiView.path=this.getCurrentPanePath()}async constructView(){return this.multiView.tabs.onTabChanged.subscribe((()=>this.setUrl())),this.setUrl(),this.multiView}}function Ke(t){const e=P.input.textArea("",{value:""});return{coloredInput:new de(e,t.highlightInvalidSubsequence),codes:t.jsonData.codesToSymbolsDict}}var Qe=n(9124),Je=n(9192),Xe=n(8312),Ze=n(1991),tn=n.n(Ze);const en="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,nn=new Set,rn="object"==typeof process&&process?process:{},on=(t,e,n,r)=>{"function"==typeof rn.emitWarning?rn.emitWarning(t,e,n,r):console.error(`[${n}] ${e}: ${t}`)};let sn=globalThis.AbortController,an=globalThis.AbortSignal;if(void 0===sn){an=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(t,e){this._onabort.push(e)}},sn=class{constructor(){e()}signal=new an;abort(t){if(!this.signal.aborted){this.signal.reason=t,this.signal.aborted=!0;for(const e of this.signal._onabort)e(t);this.signal.onabort?.(t)}}};let t="1"!==rn.env?.LRU_CACHE_IGNORE_AC_WARNING;const e=()=>{t&&(t=!1,on("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e))}}Symbol("type");const ln=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),cn=t=>ln(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?un:null:null;class un extends Array{constructor(t){super(t),this.fill(0)}}class hn{heap;length;static#t=!1;static create(t){const e=cn(t);if(!e)return[];hn.#t=!0;const n=new hn(t,e);return hn.#t=!1,n}constructor(t,e){if(!hn.#t)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}}class dn{#e;#n;#r;#o;#i;#s;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#a;#l;#c;#u;#h;#d;#p;#f;#m;#g;#y;#b;#v;#C;#x;#w;#A;static unsafeExposeInternals(t){return{starts:t.#v,ttls:t.#C,sizes:t.#b,keyMap:t.#c,keyList:t.#u,valList:t.#h,next:t.#d,prev:t.#p,get head(){return t.#f},get tail(){return t.#m},free:t.#g,isBackgroundFetch:e=>t.#T(e),backgroundFetch:(e,n,r,o)=>t.#E(e,n,r,o),moveToTail:e=>t.#S(e),indexes:e=>t.#I(e),rindexes:e=>t.#N(e),isStale:e=>t.#_(e)}}get max(){return this.#e}get maxSize(){return this.#n}get calculatedSize(){return this.#l}get size(){return this.#a}get fetchMethod(){return this.#i}get memoMethod(){return this.#s}get dispose(){return this.#r}get disposeAfter(){return this.#o}constructor(t){const{max:e=0,ttl:n,ttlResolution:r=1,ttlAutopurge:o,updateAgeOnGet:i,updateAgeOnHas:s,allowStale:a,dispose:l,disposeAfter:c,noDisposeOnSet:u,noUpdateTTL:h,maxSize:d=0,maxEntrySize:p=0,sizeCalculation:f,fetchMethod:m,memoMethod:g,noDeleteOnFetchRejection:y,noDeleteOnStaleGet:b,allowStaleOnFetchRejection:v,allowStaleOnFetchAbort:C,ignoreFetchAbort:x}=t;if(0!==e&&!ln(e))throw new TypeError("max option must be a nonnegative integer");const w=e?cn(e):Array;if(!w)throw new Error("invalid max value: "+e);if(this.#e=e,this.#n=d,this.maxEntrySize=p||this.#n,this.sizeCalculation=f,this.sizeCalculation){if(!this.#n&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if("function"!=typeof this.sizeCalculation)throw new TypeError("sizeCalculation set to non-function")}if(void 0!==g&&"function"!=typeof g)throw new TypeError("memoMethod must be a function if defined");if(this.#s=g,void 0!==m&&"function"!=typeof m)throw new TypeError("fetchMethod must be a function if specified");if(this.#i=m,this.#w=!!m,this.#c=new Map,this.#u=new Array(e).fill(void 0),this.#h=new Array(e).fill(void 0),this.#d=new w(e),this.#p=new w(e),this.#f=0,this.#m=0,this.#g=hn.create(e),this.#a=0,this.#l=0,"function"==typeof l&&(this.#r=l),"function"==typeof c?(this.#o=c,this.#y=[]):(this.#o=void 0,this.#y=void 0),this.#x=!!this.#r,this.#A=!!this.#o,this.noDisposeOnSet=!!u,this.noUpdateTTL=!!h,this.noDeleteOnFetchRejection=!!y,this.allowStaleOnFetchRejection=!!v,this.allowStaleOnFetchAbort=!!C,this.ignoreFetchAbort=!!x,0!==this.maxEntrySize){if(0!==this.#n&&!ln(this.#n))throw new TypeError("maxSize must be a positive integer if specified");if(!ln(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#P()}if(this.allowStale=!!a,this.noDeleteOnStaleGet=!!b,this.updateAgeOnGet=!!i,this.updateAgeOnHas=!!s,this.ttlResolution=ln(r)||0===r?r:1,this.ttlAutopurge=!!o,this.ttl=n||0,this.ttl){if(!ln(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#M()}if(0===this.#e&&0===this.ttl&&0===this.#n)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#n){const t="LRU_CACHE_UNBOUNDED";(t=>!nn.has(t))(t)&&(nn.add(t),on("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",t,dn))}}getRemainingTTL(t){return this.#c.has(t)?1/0:0}#M(){const t=new un(this.#e),e=new un(this.#e);this.#C=t,this.#v=e,this.#L=(n,r,o=en.now())=>{if(e[n]=0!==r?o:0,t[n]=r,0!==r&&this.ttlAutopurge){const t=setTimeout((()=>{this.#_(n)&&this.#O(this.#u[n],"expire")}),r+1);t.unref&&t.unref()}},this.#R=n=>{e[n]=0!==t[n]?en.now():0},this.#D=(o,i)=>{if(t[i]){const s=t[i],a=e[i];if(!s||!a)return;o.ttl=s,o.start=a,o.now=n||r();const l=o.now-a;o.remainingTTL=s-l}};let n=0;const r=()=>{const t=en.now();if(this.ttlResolution>0){n=t;const e=setTimeout((()=>n=0),this.ttlResolution);e.unref&&e.unref()}return t};this.getRemainingTTL=o=>{const i=this.#c.get(o);if(void 0===i)return 0;const s=t[i],a=e[i];return s&&a?s-((n||r())-a):1/0},this.#_=o=>{const i=e[o],s=t[o];return!!s&&!!i&&(n||r())-i>s}}#R=()=>{};#D=()=>{};#L=()=>{};#_=()=>!1;#P(){const t=new un(this.#e);this.#l=0,this.#b=t,this.#$=e=>{this.#l-=t[e],t[e]=0},this.#B=(t,e,n,r)=>{if(this.#T(e))return 0;if(!ln(n)){if(!r)throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");if("function"!=typeof r)throw new TypeError("sizeCalculation must be a function");if(n=r(e,t),!ln(n))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return n},this.#F=(e,n,r)=>{if(t[e]=n,this.#n){const n=this.#n-t[e];for(;this.#l>n;)this.#k(!0)}this.#l+=t[e],r&&(r.entrySize=n,r.totalCalculatedSize=this.#l)}}#$=t=>{};#F=(t,e,n)=>{};#B=(t,e,n,r)=>{if(n||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#I({allowStale:t=this.allowStale}={}){if(this.#a)for(let e=this.#m;this.#H(e)&&(!t&&this.#_(e)||(yield e),e!==this.#f);)e=this.#p[e]}*#N({allowStale:t=this.allowStale}={}){if(this.#a)for(let e=this.#f;this.#H(e)&&(!t&&this.#_(e)||(yield e),e!==this.#m);)e=this.#d[e]}#H(t){return void 0!==t&&this.#c.get(this.#u[t])===t}*entries(){for(const t of this.#I())void 0===this.#h[t]||void 0===this.#u[t]||this.#T(this.#h[t])||(yield[this.#u[t],this.#h[t]])}*rentries(){for(const t of this.#N())void 0===this.#h[t]||void 0===this.#u[t]||this.#T(this.#h[t])||(yield[this.#u[t],this.#h[t]])}*keys(){for(const t of this.#I()){const e=this.#u[t];void 0===e||this.#T(this.#h[t])||(yield e)}}*rkeys(){for(const t of this.#N()){const e=this.#u[t];void 0===e||this.#T(this.#h[t])||(yield e)}}*values(){for(const t of this.#I())void 0===this.#h[t]||this.#T(this.#h[t])||(yield this.#h[t])}*rvalues(){for(const t of this.#N())void 0===this.#h[t]||this.#T(this.#h[t])||(yield this.#h[t])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,e={}){for(const n of this.#I()){const r=this.#h[n],o=this.#T(r)?r.__staleWhileFetching:r;if(void 0!==o&&t(o,this.#u[n],this))return this.get(this.#u[n],e)}}forEach(t,e=this){for(const n of this.#I()){const r=this.#h[n],o=this.#T(r)?r.__staleWhileFetching:r;void 0!==o&&t.call(e,o,this.#u[n],this)}}rforEach(t,e=this){for(const n of this.#N()){const r=this.#h[n],o=this.#T(r)?r.__staleWhileFetching:r;void 0!==o&&t.call(e,o,this.#u[n],this)}}purgeStale(){let t=!1;for(const e of this.#N({allowStale:!0}))this.#_(e)&&(this.#O(this.#u[e],"expire"),t=!0);return t}info(t){const e=this.#c.get(t);if(void 0===e)return;const n=this.#h[e],r=this.#T(n)?n.__staleWhileFetching:n;if(void 0===r)return;const o={value:r};if(this.#C&&this.#v){const t=this.#C[e],n=this.#v[e];if(t&&n){const e=t-(en.now()-n);o.ttl=e,o.start=Date.now()}}return this.#b&&(o.size=this.#b[e]),o}dump(){const t=[];for(const e of this.#I({allowStale:!0})){const n=this.#u[e],r=this.#h[e],o=this.#T(r)?r.__staleWhileFetching:r;if(void 0===o||void 0===n)continue;const i={value:o};if(this.#C&&this.#v){i.ttl=this.#C[e];const t=en.now()-this.#v[e];i.start=Math.floor(Date.now()-t)}this.#b&&(i.size=this.#b[e]),t.unshift([n,i])}return t}load(t){this.clear();for(const[e,n]of t){if(n.start){const t=Date.now()-n.start;n.start=en.now()-t}this.set(e,n.value,n)}}set(t,e,n={}){if(void 0===e)return this.delete(t),this;const{ttl:r=this.ttl,start:o,noDisposeOnSet:i=this.noDisposeOnSet,sizeCalculation:s=this.sizeCalculation,status:a}=n;let{noUpdateTTL:l=this.noUpdateTTL}=n;const c=this.#B(t,e,n.size||0,s);if(this.maxEntrySize&&c>this.maxEntrySize)return a&&(a.set="miss",a.maxEntrySizeExceeded=!0),this.#O(t,"set"),this;let u=0===this.#a?void 0:this.#c.get(t);if(void 0===u)u=0===this.#a?this.#m:0!==this.#g.length?this.#g.pop():this.#a===this.#e?this.#k(!1):this.#a,this.#u[u]=t,this.#h[u]=e,this.#c.set(t,u),this.#d[this.#m]=u,this.#p[u]=this.#m,this.#m=u,this.#a++,this.#F(u,c,a),a&&(a.set="add"),l=!1;else{this.#S(u);const n=this.#h[u];if(e!==n){if(this.#w&&this.#T(n)){n.__abortController.abort(new Error("replaced"));const{__staleWhileFetching:e}=n;void 0===e||i||(this.#x&&this.#r?.(e,t,"set"),this.#A&&this.#y?.push([e,t,"set"]))}else i||(this.#x&&this.#r?.(n,t,"set"),this.#A&&this.#y?.push([n,t,"set"]));if(this.#$(u),this.#F(u,c,a),this.#h[u]=e,a){a.set="replace";const t=n&&this.#T(n)?n.__staleWhileFetching:n;void 0!==t&&(a.oldValue=t)}}else a&&(a.set="update")}if(0===r||this.#C||this.#M(),this.#C&&(l||this.#L(u,r,o),a&&this.#D(a,u)),!i&&this.#A&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#o?.(...e)}return this}pop(){try{for(;this.#a;){const t=this.#h[this.#f];if(this.#k(!0),this.#T(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(void 0!==t)return t}}finally{if(this.#A&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#o?.(...e)}}}#k(t){const e=this.#f,n=this.#u[e],r=this.#h[e];return this.#w&&this.#T(r)?r.__abortController.abort(new Error("evicted")):(this.#x||this.#A)&&(this.#x&&this.#r?.(r,n,"evict"),this.#A&&this.#y?.push([r,n,"evict"])),this.#$(e),t&&(this.#u[e]=void 0,this.#h[e]=void 0,this.#g.push(e)),1===this.#a?(this.#f=this.#m=0,this.#g.length=0):this.#f=this.#d[e],this.#c.delete(n),this.#a--,e}has(t,e={}){const{updateAgeOnHas:n=this.updateAgeOnHas,status:r}=e,o=this.#c.get(t);if(void 0!==o){const t=this.#h[o];if(this.#T(t)&&void 0===t.__staleWhileFetching)return!1;if(!this.#_(o))return n&&this.#R(o),r&&(r.has="hit",this.#D(r,o)),!0;r&&(r.has="stale",this.#D(r,o))}else r&&(r.has="miss");return!1}peek(t,e={}){const{allowStale:n=this.allowStale}=e,r=this.#c.get(t);if(void 0===r||!n&&this.#_(r))return;const o=this.#h[r];return this.#T(o)?o.__staleWhileFetching:o}#E(t,e,n,r){const o=void 0===e?void 0:this.#h[e];if(this.#T(o))return o;const i=new sn,{signal:s}=n;s?.addEventListener("abort",(()=>i.abort(s.reason)),{signal:i.signal});const a={signal:i.signal,options:n,context:r},l=(r,o=!1)=>{const{aborted:s}=i.signal,l=n.ignoreFetchAbort&&void 0!==r;if(n.status&&(s&&!o?(n.status.fetchAborted=!0,n.status.fetchError=i.signal.reason,l&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),s&&!l&&!o)return c(i.signal.reason);const h=u;return this.#h[e]===u&&(void 0===r?h.__staleWhileFetching?this.#h[e]=h.__staleWhileFetching:this.#O(t,"fetch"):(n.status&&(n.status.fetchUpdated=!0),this.set(t,r,a.options))),r},c=r=>{const{aborted:o}=i.signal,s=o&&n.allowStaleOnFetchAbort,a=s||n.allowStaleOnFetchRejection,l=a||n.noDeleteOnFetchRejection,c=u;if(this.#h[e]===u&&(l&&void 0!==c.__staleWhileFetching?s||(this.#h[e]=c.__staleWhileFetching):this.#O(t,"fetch")),a)return n.status&&void 0!==c.__staleWhileFetching&&(n.status.returnedStale=!0),c.__staleWhileFetching;if(c.__returned===c)throw r};n.status&&(n.status.fetchDispatched=!0);const u=new Promise(((e,r)=>{const s=this.#i?.(t,o,a);s&&s instanceof Promise&&s.then((t=>e(void 0===t?void 0:t)),r),i.signal.addEventListener("abort",(()=>{n.ignoreFetchAbort&&!n.allowStaleOnFetchAbort||(e(void 0),n.allowStaleOnFetchAbort&&(e=t=>l(t,!0)))}))})).then(l,(t=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=t),c(t)))),h=Object.assign(u,{__abortController:i,__staleWhileFetching:o,__returned:void 0});return void 0===e?(this.set(t,h,{...a.options,status:void 0}),e=this.#c.get(t)):this.#h[e]=h,h}#T(t){if(!this.#w)return!1;const e=t;return!!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof sn}async fetch(t,e={}){const{allowStale:n=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:i=this.ttl,noDisposeOnSet:s=this.noDisposeOnSet,size:a=0,sizeCalculation:l=this.sizeCalculation,noUpdateTTL:c=this.noUpdateTTL,noDeleteOnFetchRejection:u=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:h=this.allowStaleOnFetchRejection,ignoreFetchAbort:d=this.ignoreFetchAbort,allowStaleOnFetchAbort:p=this.allowStaleOnFetchAbort,context:f,forceRefresh:m=!1,status:g,signal:y}=e;if(!this.#w)return g&&(g.fetch="get"),this.get(t,{allowStale:n,updateAgeOnGet:r,noDeleteOnStaleGet:o,status:g});const b={allowStale:n,updateAgeOnGet:r,noDeleteOnStaleGet:o,ttl:i,noDisposeOnSet:s,size:a,sizeCalculation:l,noUpdateTTL:c,noDeleteOnFetchRejection:u,allowStaleOnFetchRejection:h,allowStaleOnFetchAbort:p,ignoreFetchAbort:d,status:g,signal:y};let v=this.#c.get(t);if(void 0===v){g&&(g.fetch="miss");const e=this.#E(t,v,b,f);return e.__returned=e}{const e=this.#h[v];if(this.#T(e)){const t=n&&void 0!==e.__staleWhileFetching;return g&&(g.fetch="inflight",t&&(g.returnedStale=!0)),t?e.__staleWhileFetching:e.__returned=e}const o=this.#_(v);if(!m&&!o)return g&&(g.fetch="hit"),this.#S(v),r&&this.#R(v),g&&this.#D(g,v),e;const i=this.#E(t,v,b,f),s=void 0!==i.__staleWhileFetching&&n;return g&&(g.fetch=o?"stale":"refresh",s&&o&&(g.returnedStale=!0)),s?i.__staleWhileFetching:i.__returned=i}}async forceFetch(t,e={}){const n=await this.fetch(t,e);if(void 0===n)throw new Error("fetch() returned undefined");return n}memo(t,e={}){const n=this.#s;if(!n)throw new Error("no memoMethod provided to constructor");const{context:r,forceRefresh:o,...i}=e,s=this.get(t,i);if(!o&&void 0!==s)return s;const a=n(t,s,{options:i,context:r});return this.set(t,a,i),a}get(t,e={}){const{allowStale:n=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:i}=e,s=this.#c.get(t);if(void 0!==s){const e=this.#h[s],a=this.#T(e);return i&&this.#D(i,s),this.#_(s)?(i&&(i.get="stale"),a?(i&&n&&void 0!==e.__staleWhileFetching&&(i.returnedStale=!0),n?e.__staleWhileFetching:void 0):(o||this.#O(t,"expire"),i&&n&&(i.returnedStale=!0),n?e:void 0)):(i&&(i.get="hit"),a?e.__staleWhileFetching:(this.#S(s),r&&this.#R(s),e))}i&&(i.get="miss")}#G(t,e){this.#p[e]=t,this.#d[t]=e}#S(t){t!==this.#m&&(t===this.#f?this.#f=this.#d[t]:this.#G(this.#p[t],this.#d[t]),this.#G(this.#m,t),this.#m=t)}delete(t){return this.#O(t,"delete")}#O(t,e){let n=!1;if(0!==this.#a){const r=this.#c.get(t);if(void 0!==r)if(n=!0,1===this.#a)this.#V(e);else{this.#$(r);const n=this.#h[r];if(this.#T(n)?n.__abortController.abort(new Error("deleted")):(this.#x||this.#A)&&(this.#x&&this.#r?.(n,t,e),this.#A&&this.#y?.push([n,t,e])),this.#c.delete(t),this.#u[r]=void 0,this.#h[r]=void 0,r===this.#m)this.#m=this.#p[r];else if(r===this.#f)this.#f=this.#d[r];else{const t=this.#p[r];this.#d[t]=this.#d[r];const e=this.#d[r];this.#p[e]=this.#p[r]}this.#a--,this.#g.push(r)}}if(this.#A&&this.#y?.length){const t=this.#y;let e;for(;e=t?.shift();)this.#o?.(...e)}return n}clear(){return this.#V("delete")}#V(t){for(const e of this.#N({allowStale:!0})){const n=this.#h[e];if(this.#T(n))n.__abortController.abort(new Error("deleted"));else{const r=this.#u[e];this.#x&&this.#r?.(n,r,t),this.#A&&this.#y?.push([n,r,t])}}if(this.#c.clear(),this.#h.fill(void 0),this.#u.fill(void 0),this.#C&&this.#v&&(this.#C.fill(0),this.#v.fill(0)),this.#b&&this.#b.fill(0),this.#f=0,this.#m=0,this.#g.length=0,this.#l=0,this.#a=0,this.#A&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#o?.(...e)}}}function pn(){var t;return null!==(t=window.$monomerHover)&&void 0!==t?t:null}function fn(t){window.$monomerHover=t}function mn(t,e){let n=t["substruct-providers"];n||(n=t["substruct-providers"]=[]),n.push(e),t["substruct-providers"]=n}var gn=n(6077),yn=n(3561),bn=n(9235);const vn="MonomerHoverLinks";function Cn(t,e){let n=t[vn];n||(n=t[vn]=[]),n.push(e),t[vn]=n}function xn(t,e){try{const n=t.tableColumn;if(!n)return;const r=function(t){return t.temp[vn]??[]}(n);for(let n=r.length-1;n>=0;--n){const o=r[n],i=t.grid.col(o.targetCol.name);if(i&&!o.handler(t,e,i))break}}catch(t){console.error(t)}}var wn=n(6717),An=n(6694),Tn=n(4229),En=n(5174);function Sn(t,e=!0){const[n,o]=(0,Je.AP)(t);return Yr.logger.error(n,void 0,o),e&&r.shell.error(n),[n,o]}const In={symbol:"Short Name",name:"Medium Name",smiles:"SMILES"},Nn=[{capGroupSmiles:"[*:1][H]",alternateId:"R1-H",capGroupName:"H",label:"R1"},{capGroupSmiles:"O[*:2]",alternateId:"R2-OH",capGroupName:"OH",label:"R2"},{capGroupSmiles:"[*:3][H]",alternateId:"R3-H",capGroupName:"H",label:"R3"}],_n="Get HELM",Pn="Chirality engine",Mn="Highlight monomers",Ln="PolyTool Conversion",On="PolyTool Helm Enumeration",Rn="Rules used",Dn={single:"Each position is enumerated independently. Total results = sum of monomers across all positions.",parallel:"The i-th result uses the i-th monomer from every position (zip). All positions must have the same number of monomers. Total results = number of monomers per position.",matrix:"Cartesian product of all positions. Total results = product of monomer counts across all positions."};var $n=n(5412);async function Bn(t,e,n,i,s,a){const l=o.TaskBarProgressIndicator.create("PolyTool converting...");try{const l=(t,e)=>t?t.columns.getUnusedName(e):e,c=await(0,Qe.b2)(),u=t.dataFrame,h=await(0,An.Q4)(a),[d,p,f]=(0,Tn.b)(t.toList(),h,c),m=l(u,`transformed(${t.name})`),g=o.Column.fromType(o.COLUMN_TYPE.STRING,m,d.length).init((t=>d[t]));g.semType=o.SEMTYPE.MACROMOLECULE,g.meta.units=Oe.Hi.HELM,g.setTag(o.TAGS.CELL_RENDERER,"helm"),e&&u&&u.columns.add(g,!0);const y=await(0,wn.j)(),b=await(0,Xe.Q)(),v=await(0,En.A)(h),C=g.temp;C[".mm.cellRenderer.overriddenLibrary"]=v,g.temp=C;const x=await(0,$n.m)(g,d,p,i,s,n,v,y,b);return x.name=l(u,`molfile(${t.name})`),x.semType=o.SEMTYPE.MOLECULE,u&&(u.columns.add(x,!0),await r.data.detectSemanticTypes(u)),function(t,e,n,r,o,i,s){const a=new dn({max:100});function l(t,e){const n=t.get(e);if(null==n)return null;let s=a.get(n);return s||a.set(n,s=function(t,e){const n=o.getSeqHandler(t),s=n.getSplitted(e),a=n.defaultBiotype,l=tn().count(0).take(s.length).map((t=>({position:t,symbol:s.getCanonical(t),biotype:a}))).toArray(),c=n.alphabet,u=c==Oe.YI.RNA||c==Oe.YI.DNA?"RNA":"PEPTIDE",h=(0,gn.eM)([l],u,c,r,i);return(0,yn.gU)(l,h,c,u).monomers}(t,e)),s}const c={targetCol:n,handler:(t,n,o)=>{if(!t||!o.grid||!e.dataFrame)return!0;const i=o.grid,a=t.tableRowIndex,c=t.gridRow,u=i.cell(o.name,c),h=s[c],d=pn();if(!d||d&&(d.dataFrameId!=e.dataFrame?.id||d.gridRowIdx!=c||d.seqColName!=e.name||d.seqPosition!=n?.position)){if(d&&(fn(null),d.gridCell.render()),!n)return fn(null),!0;fn({gridCell:u,dataFrameId:e.dataFrame.id,gridRowIdx:c,seqColName:e.name,seqPosition:n?n.position:-1,getSubstruct:()=>{if(!n||"*"===n.symbol)return;const t=l(e,a);if(!t)return;const o=[],i=h[n.position];for(const e of i){const n=t.get(e);if(!n)return{atoms:[],bonds:[],highlightAtomColors:[],highlightBondColors:[]};o.push((0,bn.H)([n],r))}return function(t){var e,n,r,o;const i={atoms:[],bonds:[],highlightAtomColors:{},highlightBondColors:{}};for(const s of t)i.atoms=[...null!==(e=i.atoms)&&void 0!==e?e:[],...null!==(n=s.atoms)&&void 0!==n?n:[]],i.bonds=[...null!==(r=i.bonds)&&void 0!==r?r:[],...null!==(o=s.bonds)&&void 0!==o?o:[]],i.highlightAtomColors=Object.assign(Object.assign({},i.highlightAtomColors),s.highlightAtomColors),i.highlightBondColors=Object.assign(Object.assign({},i.highlightBondColors),s.highlightBondColors);return i}(o)}}),u.render()}return!0},getSubstruct:t=>{if("true"!=n.getTag(".sequence-src-highlight-monomers"))return;if(null==t)return;if(!e.get(t))return;const o=l(e,t);return o?(0,bn.H)(o.values(),r):void 0}};Cn(t.temp,c),mn(n.temp,c)}(t,g,x,v,b,y,f),[g,x]}finally{l.close()}}var Fn=n(3309);const kn="PolyTool Chem Enumeration",Hn={[Fn.PI.Zip]:"Zip: every R-group list must have the same length N. The i-th result uses the i-th entry from every list. Produces N results per core.",[Fn.PI.Cartesian]:"Cartesian: every combination of entries across R-group lists. Produces ∏|Rᵢ| results per core."},Gn=110,Vn=104,Un=100,jn=72,qn=320,Wn=260;function zn(t,e,n,o){P.empty(t);try{const i=r.chem.drawMolecule(e,n,o);i.style.width=`${n}px`,i.style.height=`${o}px`,i.style.maxWidth=`${n}px`,i.style.maxHeight=`${o}px`,i.style.display="block",t.appendChild(i)}catch{t.appendChild(P.divText("—",{style:{color:"var(--grey-4)"}}))}}function Yn(t){const e=P.div([],{style:{width:`${Un}px`,height:`${jn}px`,display:"flex",alignItems:"center",justifyContent:"center",background:"transparent",overflow:"hidden",flex:"0 0 auto"}});t.smiles&&!t.error?zn(e,t.smiles,Un,jn):e.appendChild(P.divText("—",{style:{color:"var(--grey-4)"}}));const n=P.divText(t.subtitle,{style:{fontSize:"10px",color:t.error?"var(--red-3)":"var(--grey-5)",textAlign:"center",padding:"2px 4px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}}),r=P.divV([e,n],{style:{width:`${Gn}px`,minWidth:`${Gn}px`,height:`${Vn}px`,border:"2px solid "+(t.error?"var(--red-3)":"var(--grey-2)"),borderRadius:"4px",position:"relative",background:"var(--white)",boxSizing:"border-box",margin:"0 4px 0 0",overflow:"hidden",flex:"0 0 auto"}});if(t.smiles&&!t.error){let e=null;P.tooltip.bind(r,(()=>(e||(e=P.div([],{style:{width:`${qn}px`,height:`${Wn}px`}}),zn(e,t.smiles,qn,Wn)),e)))}else t.error&&P.tooltip.bind(r,t.error);const o=P.divH([],{style:{position:"absolute",top:"2px",right:"2px",gap:"2px",background:"rgba(255,255,255,0.85)",borderRadius:"4px",padding:"1px 2px",display:"none"}});if(t.onEdit){const e=P.icons.edit((e=>{e.stopPropagation(),t.onEdit()}),"Edit");o.appendChild(e)}if(t.onRemove){const e=P.icons.delete((e=>{e.stopPropagation(),t.onRemove()}),"Remove");o.appendChild(e)}return r.addEventListener("mouseenter",(()=>{o.style.display="flex"})),r.addEventListener("mouseleave",(()=>{o.style.display="none"})),(t.onEdit||t.onRemove)&&r.appendChild(o),r}async function Kn(t,e){const n=t.getMolFile();if(!n||""===n.trim())return null;if(!o.chem.isMolBlock(n))return n.trim();try{return(await r.functions.call("Chem:convertMolNotation",{molecule:n,sourceNotation:o.chem.Notation.MolBlock,targetNotation:o.chem.Notation.Smiles})??"").toString().trim()||null}catch{return null}}async function Qn(t,e){return new Promise((n=>{const r=new o.chem.Sketcher(o.chem.SKETCHER_MODE.INPLACE);r.syncCurrentObject=!1,e&&r.setMolFile(e);const i=P.divText("",{style:{fontSize:"11px",padding:"4px 0",minHeight:"18px"}});let s=null,a=null;const l=async()=>{s=await Kn(r);const t=s?(0,Fn.Qk)(s):[];s?0===t.length?(i.innerText="No R-group detected — add e.g. [*:1] to mark an attachment point.",i.style.color="var(--red-3)"):(i.innerText=`Detected R-groups: ${t.map((t=>"R"+t)).join(", ")}.`,i.style.color="var(--green-2)"):(i.innerText="Draw a molecule with at least one R-group label.",i.style.color="var(--grey-4)"),a&&(a.disabled=!(s&&t.length>0))};r.onChanged.subscribe((()=>{l()}));const c=P.divV([r.root,i]),u=P.dialog({title:e?"Edit Core":"Draw Core"}).add(c).onOK((()=>n(s?(0,Fn.KS)(s,"",t):null))).onCancel((()=>n(null)));u.show({resizable:!0}),a=u.getButton("OK"),a.disabled=!0,l()}))}async function Jn(t,e,n){return new Promise((r=>{const i=new o.chem.Sketcher(o.chem.SKETCHER_MODE.INPLACE);i.syncCurrentObject=!1,e&&i.setMolFile(e);const s=P.input.int("Target R#",{value:n,min:1}),a=P.divText("",{style:{fontSize:"11px",padding:"4px 0",minHeight:"18px"}});let l=null,c=[],u=null,h=!1;s.onChanged.subscribe((()=>{h=!0,d()}));const d=()=>{const t=s.value,e=null!=l&&null!=t&&t>=1&&1===c.length;u&&(u.disabled=!e)},p=async()=>{l=await Kn(i),c=l?(0,Fn.Qk)(l):[],l?0===c.length?(a.innerText="No R-group detected — add [*:N] to mark the attachment point.",a.style.color="var(--red-3)"):c.length>1?(a.innerText=`R-group must contain exactly one attachment point. Found ${c.length}: ${c.map((t=>"R"+t)).join(", ")}.`,a.style.color="var(--red-3)"):(h&&null!=s.value||(s.value=c[0]),a.innerText=`Detected R${c[0]}. Target R# is used for joining; change it to remap.`,a.style.color="var(--green-2)"):(a.innerText="Draw an R-group with exactly one attachment point.",a.style.color="var(--grey-4)"),d()};i.onChanged.subscribe((()=>{p()}));const f=P.divV([i.root,s.root,a]),m=P.dialog({title:e?"Edit R-Group":"Draw R-Group"}).add(f).onOK((()=>{const e=s.value;r(l&&null!=e?(0,Fn.ah)(l,e,"",t):null)})).onCancel((()=>r(null)));m.show({resizable:!0}),u=m.getButton("OK"),u.disabled=!0,p()}))}async function Xn(t,e,n){return new Promise((i=>{const s=t=>t.semType===o.SEMTYPE.MOLECULE,a=P.input.table("Table",{value:r.shell.t??void 0}),l=P.input.choice("Column",{items:[],nullable:!0}),c="rgroups"===t?P.input.int("Target R#",{value:1,min:1}):null,u=P.input.bool("Remove duplicates",{value:n});P.tooltip.bind(u.input,"cores"===t?"When checked, identical cores in the selected column are collapsed into one entry.":"When checked, identical R-groups are collapsed. Leave off for Zip mode if your lists are intentionally aligned by position.");const h=t=>{const e=a.value;if(!e)return l.items=[],void(l.value=null);const n=e.columns.toList().filter(s);if(l.items=n.map((t=>t.name)),t){const t=n.find((t=>t.semType===o.SEMTYPE.MOLECULE));l.value=(t??n[0])?.name??null}},d=P.div([],{style:{height:`${Vn+26}px`,overflow:"hidden",padding:"4px"}}),p=P.divText("",{style:{fontSize:"11px",color:"var(--grey-5)",margin:"4px 0"}}),f=Zn();let m={},g=null,y=null;const b=()=>{f.setErrors([]),m={};const n=(()=>{const t=a.value,e=l.value;return t&&e?t.col(e):null})();if(!n)return p.innerText="",g&&(g.disabled=!0),void(y&&y.setData(0,(()=>P.div())));const r=[];for(let t=0;t<n.length;t++){if(n.isNone(t))continue;const e=n.get(t);null!=e&&""!==String(e).trim()&&r.push(String(e))}const o=u.value,i=[],s=[];if("cores"===t){const t=r.map((t=>(0,Fn.KS)(t,"",e)));let n=t,a=0;if(o){const e=new Set;n=[];for(const r of t){const t=r.error?`err:${r.originalSmiles}`:r.smiles;e.has(t)?a++:(e.add(t),n.push(r))}}m.cores=n,n.forEach(((t,e)=>{t.error&&s.push(`Core ${e+1}: ${t.error}`),i.push({smi:t.error?"":t.smiles,err:t.error,subtitle:t.error?"invalid":t.rNumbers.map((t=>"R"+t)).join(", ")})})),p.innerText=`${n.length} core${1===n.length?"":"s"}`+(o&&a?` (${a} duplicate${1===a?"":"s"} skipped)`:"")+"."}else{const t=c.value??1,n=r.map((n=>(0,Fn.ah)(n,t,"",e)));let a=n,l=0;if(o){const t=new Set;a=[];for(const e of n){const n=e.error?`err:${e.originalSmiles}`:e.smiles;t.has(n)?l++:(t.add(n),a.push(e))}}m.rGroups=a,a.forEach(((t,e)=>{t.error&&s.push(`R-group ${e+1}: ${t.error}`),i.push({smi:t.error?"":t.smiles,err:t.error,subtitle:t.error?"invalid":`R${t.rNumber}${null!=t.sourceRNumber&&t.sourceRNumber!==t.rNumber?` (from R${t.sourceRNumber})`:""}`})})),p.innerText=`${a.length} R-group${1===a.length?"":"s"} for R${t}`+(o&&l?` (${l} duplicate${1===l?"":"s"} skipped)`:"")+"."}f.setErrors(s),y?y.setData(i.length,(t=>Yn({smiles:i[t].smi,subtitle:i[t].subtitle,error:i[t].err}))):(y=P.virtualView(i.length,(t=>Yn({smiles:i[t].smi,subtitle:i[t].subtitle,error:i[t].err})),!1,1),y.root.style.height=`${Vn+12}px`,y.root.style.width="100%",d.appendChild(y.root)),g&&(g.disabled=0===r.length)};a.onChanged.subscribe((async()=>{const t=a.value;t&&(await t.meta.detectSemanticTypes(),await r.data.detectSemanticTypes(t)),h(!0),b()})),l.onChanged.subscribe((()=>{if("rgroups"===t&&l.value){const t=function(t){const e=t.match(/r[\s_\-:]*(\d+)/i);return e?parseInt(e[1],10):null}(l.value);null!=t&&(c.value=t)}b()})),c&&c.onChanged.subscribe((()=>b())),u.onChanged.subscribe((()=>b()));const v=P.divV([a.root,l.root,...c?[c.root]:[],u.root,P.divH([p,f.root],{style:{alignItems:"center",gap:"8px"}}),d]),C=P.dialog({title:"cores"===t?"Import Cores":"Import R-Groups"}).add(v).onOK((()=>i(m))).onCancel((()=>i(null)));C.show({resizable:!0,width:640}),g=C.getButton("OK"),g.disabled=!0,a.value&&a.value.meta.detectSemanticTypes().then((()=>{h(!0),b()}))}))}function Zn(){const t=P.div([],{style:{display:"none",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"10px",background:"var(--red-2)",color:"var(--red-3)",fontSize:"11px",fontWeight:"600",cursor:"help"}});return{root:t,setErrors(e){0!==e.length?(t.style.display="inline-flex",t.innerText=`⚠ ${e.length} issue${1===e.length?"":"s"}`,P.tooltip.bind(t,e.join("\n"))):t.style.display="none"}}}async function tr(t){await Yr.initPromise;try{const e=await(0,wn.j)();let n=null;if(t){const i=await async function(t){try{if(!t||t.rowIndex<0||t.column?.semType!==o.SEMTYPE.MOLECULE)return null;const e=t.value;return e?o.chem.isMolBlock(e)?e:await r.functions.call("Chem:convertMolNotation",{molecule:e,sourceNotation:t.column.getTag(o.TAGS.UNITS)??o.chem.Notation.Unknown,targetNotation:o.chem.Notation.MolBlock})??null:null}catch{return null}}(t);if(i){const t=await r.functions.call("Chem:convertMolNotation",{molecule:i,sourceNotation:o.chem.Notation.MolBlock,targetNotation:o.chem.Notation.Smiles});if(t){const o=(0,Fn.KS)(t,"",e);o.error?r.shell.info("Selected molecule has no R-group — add at least one R-label to use it as a core."):n=o}}}const i=er(e,n),s=P.dialog({title:kn}).add(i.root).onOK((async()=>{await i.execute()}));i.bindActionButton(s.getButton("OK")),s.show({resizable:!0,width:960})}catch(t){Sn(t)}}function er(t,e){const n={cores:e?[e]:[],rGroupsByNum:new Map,mode:Fn.PI.Cartesian,appendToTable:null},i=Vn+16,s=P.divText("No cores — draw or import at least one.",{style:{color:"var(--grey-4)",padding:"20px 12px",fontSize:"12px"}}),a=P.div([],{style:{width:"100%",height:`${i}px`,overflow:"hidden"}});let l=null;const c=e=>{const r=n.cores[e];return Yn({smiles:r.error?"":r.smiles,subtitle:r.error?"invalid":`core ${e+1} · ${r.rNumbers.map((t=>"R"+t)).join(", ")}`,error:r.error,onEdit:async()=>{const o=await Qn(t,r.smiles);o&&(n.cores[e]=o,A())},onRemove:()=>{n.cores.splice(e,1),A()}})};function u(t){t.style.width="100%",t.style.height=`${i}px`,t.style.setProperty("overflow-y","hidden","important"),t.style.setProperty("overflow-x","auto","important");const e=t.firstElementChild;e&&(e.style.setProperty("overflow-y","hidden","important"),e.style.setProperty("overflow-x","auto","important"),e.style.height=`${i}px`)}const h=P.div([],{style:{width:"100%",padding:"2px 0",flex:"1 1 auto",minHeight:"0",overflowY:"auto",overflowX:"hidden"}}),d=P.divText("No R-groups — draw or import for each R number used by your cores.",{style:{color:"var(--grey-4)",padding:"12px",fontSize:"12px"}}),p=new Map,f=P.div([],{style:{width:"100%",display:"flex",flexWrap:"wrap",gap:"6px",alignContent:"flex-start",padding:"2px 0",maxHeight:"450px",overflow:"scroll"}}),m=P.divText("",{style:{fontSize:"12px",color:"var(--grey-6)"}}),g=Zn(),y=P.input.choice("Enumerator type",{value:n.mode,items:Object.values(Fn.PI),onValueChanged:t=>{n.mode=t,b(),A()}}),b=()=>P.tooltip.bind(y.input,Hn[n.mode]??"");b();const v=P.input.table("Append to table",{items:r.shell.tables,nullable:!0,onValueChanged:t=>{n.appendToTable=t}});let C,x,w=null;const A=()=>{(()=>{if(0===n.cores.length)return a.firstChild&&P.empty(a),l=null,s.parentElement!==a.parentElement&&a.parentElement?.insertBefore(s,a.nextSibling),a.style.display="none",void(s.style.display="block");a.style.display="block",s.style.display="none",l?l.setData(n.cores.length,c):(l=P.virtualView(n.cores.length,c,!1,1),u(l.root),a.appendChild(l.root))})(),(()=>{if(P.empty(h),p.clear(),0===n.rGroupsByNum.size)return void h.appendChild(d);const e=[...n.rGroupsByNum.keys()].sort(((t,e)=>t-e));for(const r of e){const e=n.rGroupsByNum.get(r),o=P.divText(`R${r} (${e.length})`,{style:{fontWeight:"600",fontSize:"12px",color:"var(--grey-6)",alignSelf:"center"}}),i=P.button("Remove all",(()=>{n.rGroupsByNum.delete(r),A()}));i.style.marginLeft="4px",P.tooltip.bind(i,`Remove all R${r} groups`);const s=P.divH([o,i],{style:{alignItems:"center",justifyContent:"flex-start",gap:"0",margin:"6px 0 2px"}}),a=o=>{const i=e[o],s=null!=i.sourceRNumber&&i.sourceRNumber!==i.rNumber?` (from R${i.sourceRNumber})`:"";return Yn({smiles:i.error?"":i.smiles,subtitle:i.error?"invalid":`r group ${o+1} · R${i.rNumber}${s}`,error:i.error,onEdit:async()=>{const r=await Jn(t,i.smiles,i.rNumber);if(r){if(r.rNumber!==i.rNumber){e.splice(o,1),0===e.length&&n.rGroupsByNum.delete(i.rNumber);const t=n.rGroupsByNum.get(r.rNumber)??[];t.push(r),n.rGroupsByNum.set(r.rNumber,t)}else e[o]=r;A()}},onRemove:()=>{e.splice(o,1),0===e.length&&n.rGroupsByNum.delete(r),A()}})},l=P.virtualView(e.length,a,!1,1);u(l.root);const c=P.divV([s,l.root]);h.appendChild(c),p.set(r,{row:c,vv:l,header:s})}})();const e=(0,Fn.XB)({cores:n.cores,rGroups:n.rGroupsByNum,mode:n.mode});m.innerText=e.predictedCount>0?`${e.predictedCount.toLocaleString()} molecule${1===e.predictedCount?"":"s"} will be generated`:"",g.setErrors((()=>{const t=[];n.cores.forEach(((e,n)=>{e.error&&t.push(`Core ${n+1}: ${e.error}`)}));const e=[...n.rGroupsByNum.keys()].sort(((t,e)=>t-e));for(const r of e)n.rGroupsByNum.get(r).forEach(((e,n)=>{e.error&&t.push(`R${r} group ${n+1}: ${e.error}`)}));const r=(0,Fn.XB)({cores:n.cores,rGroups:n.rGroupsByNum,mode:n.mode});for(const e of r.errors)/^Core "/.test(e)||t.push(e);return t})()),w&&(w.disabled=!e.ok),C&&(C.disabled=0===n.cores.length),x&&(x.disabled=0===n.rGroupsByNum.size),(()=>{P.empty(f);const t=(0,Fn.xD)({cores:n.cores,rGroups:n.rGroupsByNum,mode:n.mode,maxResults:Math.min(Fn.u8,1e3)},12);0!==t.length?t.forEach(((t,e)=>{const n=[...t.rGroupSmilesByNum.keys()].sort(((t,e)=>t-e)).map((t=>"R"+t)).join(",");f.appendChild(Yn({smiles:t.smiles,subtitle:`sample ${e+1} · ${n}`}))})):f.appendChild(P.divText("Preview will appear once cores and R-groups are valid.",{style:{color:"var(--grey-4)",padding:"20px 12px",fontSize:"12px"}}))})()},T=(t,e,n,r)=>{const o=[P.divText(t,{style:{fontWeight:"600",fontSize:"12px",color:"var(--grey-6)",alignSelf:"center",minWidth:"60px"}})];if(e){const n=P.button("+ Draw",e);n.style.marginLeft="4px",P.tooltip.bind(n,`${t}: open sketcher`),o.push(n)}if(n){const e=P.button("↓ Import…",n);e.style.marginLeft="4px",P.tooltip.bind(e,`${t}: pick a table + column`),o.push(e)}let i;return r&&(i=P.button("Remove all",r),i.style.marginLeft="4px",P.tooltip.bind(i,`Remove all ${t.toLowerCase()}`),o.push(i)),{root:P.divH(o,{style:{alignItems:"center",justifyContent:"flex-start",gap:"0",margin:"0 0 2px",flex:"0 0 auto"}}),clearBtn:i}},E={display:"flex",flexDirection:"column",minHeight:"150px",padding:"4px 0"},S=T("Cores",(async()=>{const e=await Qn(t);e&&(n.cores.push(e),A())}),(async()=>{const e=await Xn("cores",t,n.mode===Fn.PI.Cartesian);e?.cores&&(n.cores.push(...e.cores),A())}),(()=>{n.cores.splice(0,n.cores.length),A()}));C=S.clearBtn;const I=P.divV([S.root,P.div([a,s],{style:{padding:"0"}})],{style:E}),N=T("R-Groups",(async()=>{const e=await Jn(t);if(!e)return;const r=n.rGroupsByNum.get(e.rNumber)??[];r.push(e),n.rGroupsByNum.set(e.rNumber,r),A()}),(async()=>{const e=await Xn("rgroups",t,n.mode===Fn.PI.Cartesian);if(e?.rGroups){for(const t of e.rGroups){const e=n.rGroupsByNum.get(t.rNumber)??[];e.push(t),n.rGroupsByNum.set(t.rNumber,e)}A()}}),(()=>{n.rGroupsByNum.clear(),A()}));x=N.clearBtn;const _=P.divV([N.root,h],{style:{display:"flex",flexDirection:"column",maxHeight:"300px",padding:"4px 0"}}),M=P.divV([T("Preview").root,f],{style:{...E,width:"100%",height:"100%",overflowY:"auto",overflowX:"hidden"}}),L=P.divV([I,_],{style:{flex:"0 0 60%",width:"60%",display:"flex",flexDirection:"column",gap:"4px",paddingRight:"8px",borderRight:"1px solid var(--grey-2)"}}),O=P.divV([M],{style:{flex:"0 0 40%",width:"40%",display:"flex",flexDirection:"column",paddingLeft:"8px"}}),R=P.divH([L,O],{style:{width:"100%",alignItems:"stretch",gap:"0"}}),D=P.divH([y.root,m,g.root],{style:{alignItems:"center",gap:"16px",padding:"4px 0"}}),$=P.div([v.root],{style:{padding:"2px 0"}}),B=P.divV([R,D,$],{style:{width:"100%",padding:"4px",display:"flex",flexDirection:"column",gap:"4px"}});return A(),{root:B,state:n,execute:()=>async function(t){const e=o.TaskBarProgressIndicator.create("Enumerating...");try{e.update(10,"Building molecules...");const n=(0,Fn.jp)({cores:t.cores,rGroups:t.rGroupsByNum,mode:t.mode});if(!n)return void r.shell.warning("Enumeration failed — check validation messages in the dialog.");if(0===n.length)return void r.shell.warning("No molecules produced.");const i=new Set;for(const t of n)for(const e of t.rGroupSmilesByNum.keys())i.add(e);const s=[...i].sort(((t,e)=>t-e)),a=o.Column.fromStrings("Enumerated",n.map((t=>t.smiles)));a.semType=o.SEMTYPE.MOLECULE;const l=o.Column.fromStrings("Core",n.map((t=>t.coreSmiles)));l.semType=o.SEMTYPE.MOLECULE;const c=s.map((t=>o.Column.fromStrings(`R${t}`,n.map((e=>e.rGroupSmilesByNum.get(t)??"")))));for(const t of c)t.semType=o.SEMTYPE.MOLECULE;const u=o.DataFrame.fromColumns([a,l,...c]);u.name="Chem Enumeration",e.update(40,`Canonicalizing ${n.length.toLocaleString()} molecule(s)...`);try{await r.functions.call("Chem:convertNotation",{data:u,molecules:a,targetNotation:o.chem.Notation.Smiles,overwrite:!0,join:!1,kekulize:!1})}catch(t){Yr.logger.warning(`Canonicalization skipped: ${t?.message??t}`)}e.update(90,"Finalizing..."),await r.data.detectSemanticTypes(u),t.appendToTable?(t.appendToTable.append(u,!0),await t.appendToTable.meta.detectSemanticTypes()):r.shell.addTableView(u)}catch(t){Sn(t)}finally{e.close()}}(n),bindActionButton:t=>{w=t,A()}}}var nr=n(6197);class rr extends o.InputBase{constructor(t,e){super(P.input.column(t,e).dart,e?.onValueChanged),this.options=e}setColumnInputTable(t){P.input.setColumnInputTable(this,t,this.options?.filter)}}P.input.column2=function(t,e){return new rr(t,e)};var or=n(1296),ir=n(3820);class sr extends o.JsInputBase{get inputType(){return"Positions"}get dataType(){return o.TYPE.DATA_FRAME}getInput(){return this.gridHost}getValue(){return this.grid.dataFrame}setValue(t){this.setDataFrame(t)}getStringValue(){return this.grid.dataFrame.toCsv()}setStringValue(t){this.setDataFrame(o.DataFrame.fromCsv(t))}clearInput(){const t=o.DataFrame.fromColumns([o.Column.fromType(o.COLUMN_TYPE.STRING,"Remove",0),o.Column.fromType(o.COLUMN_TYPE.INT,"Position",0),o.Column.fromType(o.COLUMN_TYPE.STRING,"Monomers",0)]);this.setDataFrame(t)}get placeholdersValue(){return function(t){const e=[];for(let n=0;n<t.rowCount;n++){if(t.getCol("Position").isNone(n))continue;const r=parseInt(t.get("Position",n))-1;if(!isNaN(r)){const o=ar(t.get("Monomers",n));e.push({position:r,monomers:o})}}return e}(this.grid.dataFrame)}invalidateGrid(){if(this.grid){const t=this.grid.root.style.width;this.grid.root.style.width="99.9%",setTimeout((()=>{t?this.grid.root.style.width=t:this.grid.root.style.removeProperty("width")}),100)}}constructor(t,e,n){super(),this.name=t,this.onMonomerCellEdit=null,this.subs=[],this.dataFrameSubs=[],this.caption=t??"",this.root.classList.add("ui-input-polytool-pos-grid"),this.root.append(this.gridHost=P.div([],{classes:"ui-input-editor",style:{width:"100%",height:"100%",marginTop:"-8px",marginBottom:"8px",paddingBottom:"4px"}})),this.render(e,n).then((()=>{}))}detach(){for(const t of this.subs)t.unsubscribe();for(const t of this.dataFrameSubs)t.unsubscribe()}async render(t,e){let n;const r=o.DataFrame.fromColumns([n=o.Column.fromType(o.COLUMN_TYPE.STRING,"Remove",0),o.Column.fromType(o.COLUMN_TYPE.INT,"Position",0),o.Column.fromType(o.COLUMN_TYPE.STRING,"Monomers",0)]);n.setTag(o.TAGS.FRIENDLY_NAME,""),this.grid=await r.plot.fromType(o.VIEWER.GRID,e),this.grid.sort(["Position"]),this.grid.columns.byIndex(1).width=this.grid.props.rowHeight+2,this.grid.onCellRender.subscribe((t=>{const e=t.cell;e.tableColumn?.name==n.name&&(e?.tableRowIndex??-1)>=0&&(e.element=P.div(P.icons.delete((()=>{this.grid.dataFrame.rows.removeAt(e.tableRowIndex)}),"Delete"),{style:{height:`${e.grid.props.rowHeight}px`,color:"var(--grey-6)",display:"flex",flexDirection:"row",justifyContent:"center"}}))}));const i=this.grid.columns.byName("Monomers");i&&(i.editable=!1),this.subs.push(this.grid.onCellDoubleClick.subscribe((t=>{"Monomers"===t.tableColumn?.name&&null!=t.tableRowIndex&&t.tableRowIndex>=0&&this.handleMonomerCellDoubleClick(t.tableRowIndex)}))),this.updateGridHeight(t??this.grid.dataFrame.rowCount+.7),this.subs.push(P.onSizeChanged(this.grid.root).subscribe(this.gridRootOnSizeChanged.bind(this))),this.subs.push((0,et.fromEvent)(this.grid.root,"keydown").subscribe((t=>{"Enter"===t.key&&t.stopPropagation()}))),this.setDataFrame(r),this.grid.root.style.width="100%",this.gridHost.append(this.grid.root)}setDataFrame(t){for(const t of this.dataFrameSubs)t.unsubscribe();this.grid.dataFrame=t,this.dataFrameSubs.push(this.grid.dataFrame.onRowsRemoved.subscribe((()=>{this.updateGridHeight(this.grid.dataFrame.rowCount+.7),this.fireChanged()}))),this.dataFrameSubs.push(this.grid.dataFrame.onRowsAdded.subscribe((()=>{this.updateGridHeight(this.grid.dataFrame.rowCount+.7)}))),this.dataFrameSubs.push(this.grid.dataFrame.onDataChanged.subscribe((()=>{this.fireChanged()}))),this.updateGridHeight(this.grid.dataFrame.rowCount+.7),this.fireChanged()}addPosition(t,e){const n=this.grid.dataFrame,r=n.columns.byName("Position").toList();let o=r.indexOf(t+1);-1===o&&(o=r.findIndex((t=>isNaN(t))),-1===o&&(o=n.rows.addNew(["",t+1,e??""]).idx),this.grid.cell("Monomers",o)),n.currentCell=n.cell(o,"Monomers")}setMonomersValue(t,e){const n=this.grid.dataFrame;n.rowCount<=t||n.set("Monomers",t,e)}static async create(t,e,n){return new sr(t,n,e)}updateGridHeight(t){const e=this.grid.colHeaderHeight+t*this.grid.props.rowHeight+6+2;this.grid.root.style.height=`${e}px`}async handleMonomerCellDoubleClick(t){if(!this.onMonomerCellEdit)return;const e=this.grid.dataFrame,n=parseInt(e.get("Position",t))-1;if(isNaN(n))return;const r=ar(e.get("Monomers",t)??""),o=await this.onMonomerCellEdit(n,r);null!==o&&e.set("Monomers",t,o.join(", "))}gridRootOnSizeChanged(){this.grid.columns.byIndex(3).width=this.grid.root.clientWidth-this.grid.horzScroll.root.offsetWidth-this.grid.columns.byIndex(0).width-this.grid.columns.byIndex(1).width-this.grid.columns.byIndex(2).width-10}}function ar(t){return t.split(/,(?![^(]*\))/).map((t=>('"'===(t=t.trim()).slice(0,1)&&'"'===t.slice(-1)&&(t=t.slice(1,-1)),"'"===t.slice(0,1)&&"'"===t.slice(-1)&&(t=t.slice(1,-1)),t.trim()))).filter((t=>!!t))}class lr{constructor(t,e,n,r){this.currentMenu=null,this.menuItems=[],this.highlightedIndex=-1,this.monomerLib=t,this.polymerType=e,this.helmType=(0,s.MD)(e),this.allSymbols=t.getMonomerSymbolsByType(e),this.libHelper=r,this.selectedMonomers=n?[...n]:[],this.tagsHost=P.div([],{style:{display:"flex",flexWrap:"wrap",gap:"4px",marginTop:"4px",maxHeight:"150px",overflowY:"auto"}}),this.countLabel=P.divText("",{style:{fontSize:"11px",color:"var(--grey-4)",marginTop:"4px"}});const o=P.input.string("Search",{value:""});this.inputEl=o.input,this.inputEl.setAttribute("autocomplete","off"),this.inputEl.placeholder="Type to search monomers...",this.setupInputListeners();const i=this.createLibrarySection(),a=this.createCollectionSection(),l=P.button("Clear all",(()=>{this.selectedMonomers.length=0,this.renderTags()}));l.style.fontSize="11px",l.style.marginTop="4px",this.renderTags(),this.root=P.div([o.root,i,a,P.divH([this.countLabel,l],{style:{justifyContent:"space-between",alignItems:"center"}}),this.tagsHost],{style:{minWidth:"300px"}})}getSelectedMonomers(){return[...this.selectedMonomers]}setSelectedMonomers(t){this.selectedMonomers.length=0,this.selectedMonomers.push(...t),this.renderTags()}setPolymerType(t){this.polymerType=t,this.helmType=(0,s.MD)(t),this.allSymbols=this.monomerLib.getMonomerSymbolsByType(t)}focus(){this.inputEl.focus()}updateCountLabel(){this.countLabel.textContent=this.selectedMonomers.length>0?`${this.selectedMonomers.length} monomer(s) selected`:""}renderTags(){this.tagsHost.innerHTML="";for(const t of this.selectedMonomers){const e=P.iconFA("times",(()=>{const e=this.selectedMonomers.indexOf(t);e>=0&&(this.selectedMonomers.splice(e,1),this.renderTags(),this.updateCountLabel())}));e.style.marginLeft="4px",e.style.cursor="pointer";const n=P.div([P.span([t]),e],{style:{display:"inline-flex",alignItems:"center",padding:"2px 6px",borderRadius:"4px",backgroundColor:"var(--grey-2)",border:"1px solid var(--grey-3)",fontSize:"12px",cursor:"default"}});n.addEventListener("mouseenter",(()=>{const e=this.monomerLib.getTooltip(this.helmType,t);P.tooltip.show(e,n.getBoundingClientRect().left,n.getBoundingClientRect().bottom+16)})),n.addEventListener("mouseleave",(()=>{P.tooltip.hide()})),this.tagsHost.appendChild(n)}this.updateCountLabel()}addMonomer(t){this.selectedMonomers.includes(t)||(this.selectedMonomers.push(t),this.renderTags()),this.inputEl.value="",this.hideMenu(),this.inputEl.focus()}addMonomers(t){let e=!1;for(const n of t)this.selectedMonomers.includes(n)||(this.selectedMonomers.push(n),e=!0);e&&this.renderTags()}hideMenu(){this.currentMenu&&(this.currentMenu.hide(),this.currentMenu=null),this.menuItems=[],this.highlightedIndex=-1}getSuggestions(t){const e=t.toLowerCase(),n=[];for(const t of this.allSymbols){if(this.selectedMonomers.includes(t))continue;const r=this.monomerLib.getMonomer(this.polymerType,t),o=t.toLowerCase(),i=r?.name?.toLowerCase()??"";o.startsWith(e)?n.push({symbol:t,monomer:r,rank:0}):o.includes(e)?n.push({symbol:t,monomer:r,rank:1}):i.includes(e)&&n.push({symbol:t,monomer:r,rank:2})}return n.sort(((t,e)=>t.rank-e.rank||t.symbol.localeCompare(e.symbol))),n.slice(0,20)}showSuggestions(){this.hideMenu();const t=this.inputEl.value.trim();if(!t)return;const e=this.getSuggestions(t);if(0===e.length)return;this.currentMenu=o.Menu.popup();const n=e.reduce(((t,e)=>{const n=e.monomer?.name?`${e.symbol} - ${e.monomer.name}`:e.symbol;return t.length<n.length?n:t}),"");this.currentMenu.item(n,(()=>{}));const r=new MouseEvent("mousemove",{clientX:this.inputEl.getBoundingClientRect().left,clientY:this.inputEl.getBoundingClientRect().bottom});this.currentMenu.show({causedBy:r,y:this.inputEl.offsetHeight+this.inputEl.offsetTop,x:this.inputEl.offsetLeft}),setTimeout((()=>{this.currentMenu?.clear();for(const t of e){const e=t.monomer?.name?`${t.symbol} - ${t.monomer.name}`:t.symbol;this.currentMenu?.item(e,(()=>{this.addMonomer(t.symbol)}))}const t=document.querySelector(".d4-menu-popup:last-of-type");t&&(this.menuItems=Array.from(t.querySelectorAll(".d4-menu-item"))),this.highlightedIndex=-1}),0)}updateHighlight(t){0!==this.menuItems.length&&(this.highlightedIndex>=0&&this.highlightedIndex<this.menuItems.length&&this.menuItems[this.highlightedIndex].classList.remove("d4-menu-item-hover"),this.highlightedIndex=t,this.highlightedIndex>=0&&this.highlightedIndex<this.menuItems.length&&(this.menuItems[this.highlightedIndex].classList.add("d4-menu-item-hover"),this.menuItems[this.highlightedIndex].scrollIntoView({block:"nearest"})))}setupInputListeners(){this.inputEl.addEventListener("input",(()=>{this.showSuggestions()})),this.inputEl.addEventListener("paste",(t=>{const e=t.clipboardData?.getData("text");if(!e)return;const n=e.split(/[\n\r]+/).map((t=>t.trim())).filter((t=>t.length>0)),r=[];for(const t of n){const e=t.split(/,(?![^(]*\))/).map((t=>('"'===(t=t.trim()).slice(0,1)&&'"'===t.slice(-1)&&(t=t.slice(1,-1)),"'"===t.slice(0,1)&&"'"===t.slice(-1)&&(t=t.slice(1,-1)),t.trim()))).filter((t=>!!t));1===e.length&&t.includes(" ")&&!t.includes(",")?r.push(...t.split(/\s+/).map((t=>t.trim())).filter((t=>t.length>0))):r.push(...e)}if(!(r.length<=1)){t.preventDefault();for(const t of r)this.selectedMonomers.includes(t)||this.selectedMonomers.push(t);this.renderTags(),this.inputEl.value="",this.hideMenu(),this.inputEl.focus()}})),this.inputEl.addEventListener("keydown",(t=>{if("ArrowDown"===t.key){if(t.preventDefault(),this.menuItems.length>0){const t=(this.highlightedIndex+1)%this.menuItems.length;this.updateHighlight(t)}}else if("ArrowUp"===t.key){if(t.preventDefault(),this.menuItems.length>0){const t=(this.highlightedIndex-1+this.menuItems.length)%this.menuItems.length;this.updateHighlight(t)}}else if("Enter"===t.key)if(t.preventDefault(),t.stopPropagation(),this.highlightedIndex>=0&&this.highlightedIndex<this.menuItems.length)this.menuItems[this.highlightedIndex].click();else{const t=this.inputEl.value.trim();t&&this.addMonomer(t)}else"Escape"===t.key&&this.hideMenu()}))}createLibrarySection(){const t=P.div([],{style:{marginTop:"8px"}});if(!this.libHelper)return t;const e=this.libHelper,n=P.input.choice("Add from library",{items:[],nullable:!0}),r=P.divText("",{style:{fontSize:"11px",color:"var(--green-2)",marginLeft:"8px",minHeight:"16px"}});return e.getAvaliableLibraryNames().then((t=>{n.items=t})),n.onChanged.subscribe((async()=>{const t=n.value;if(t){r.textContent="Loading...";try{const n=await e.readSingleLibraryByName(t);if(n){const e=n.getMonomerSymbolsByType(this.polymerType),o=this.selectedMonomers.length;this.addMonomers(e);const i=this.selectedMonomers.length-o;r.textContent=`Added ${i} monomer(s) from "${t}"`}else r.textContent=`Library "${t}" not found`}catch(t){r.textContent="Error loading library"}n.value=null,setTimeout((()=>{r.textContent=""}),4e3)}})),t.appendChild(P.divV([n.root,r])),t}createCollectionSection(){const t=P.div([],{style:{marginTop:"4px"}});if(!this.libHelper)return t;const e=this.libHelper,n=P.input.choice("Add from collection",{items:[],nullable:!0}),r=P.divText("",{style:{fontSize:"11px",color:"var(--green-2)",marginLeft:"8px",minHeight:"16px"}});return e.listMonomerCollections().then((t=>{n.items=t})),n.onChanged.subscribe((async()=>{const t=n.value;if(t){r.textContent="Loading...";try{const n=(await e.readMonomerCollection(t)).monomerSymbols??[],o=this.selectedMonomers.length;this.addMonomers(n);const i=this.selectedMonomers.length-o,s=t.replace(/\.json$/,"");r.textContent=`Added ${i} monomer(s) from "${s}"`}catch(t){r.textContent="Error loading collection"}n.value=null,setTimeout((()=>{r.textContent=""}),4e3)}})),t.appendChild(P.divV([n.root,r])),t}}async function cr(t,e,n,r){return new Promise((o=>{const i=new lr(t,e,n,r);P.dialog({title:"Select Monomers",showFooter:!0}).add(P.div([i.root],{style:{minWidth:"400px",minHeight:"250px",maxWidth:"800px"}})).onOK((()=>{o(i.getSelectedMonomers())})).onCancel((()=>{o(null)})).show({resizable:!0}),i.focus()}))}class ur extends o.JsInputBase{get inputType(){return"Breadth"}get dataType(){return o.TYPE.DATA_FRAME}getInput(){return this.gridHost}getValue(){return this.grid.dataFrame}setValue(t){this.setDataFrame(t)}invalidateGrid(){if(this.grid){const t=this.grid.root.style.width;this.grid.root.style.width="99.9%",setTimeout((()=>{t?this.grid.root.style.width=t:this.grid.root.style.removeProperty("width")}),100)}}getStringValue(){return this.grid.dataFrame.toCsv()}setStringValue(t){this.setDataFrame(o.DataFrame.fromCsv(t))}get placeholdersBreadthValue(){return function(t){const e=[];for(let n=0;n<t.rowCount;n++){const r=parseInt(t.get("Start",n))-1,o=parseInt(t.get("End",n))-1;if(!isNaN(r)&&!isNaN(o)){const i=ar(t.get("Monomers",n));e.push({start:r,end:o,monomers:i})}}return e}(this.grid.dataFrame)}constructor(t,e,n){super(),this.name=t,this.onMonomerCellEdit=null,this.subs=[],this.dataFrameSubs=[],this.caption=t??"",this.root.classList.add("ui-input-polytool-pos-grid"),this.root.append(this.gridHost=P.div([],{classes:"ui-input-editor",style:{width:"100%",height:"100%",marginTop:"-8px",marginBottom:"8px",paddingBottom:"4px"}})),this.render(e,n).then((()=>{}))}detach(){for(const t of this.subs)t.unsubscribe();for(const t of this.dataFrameSubs)t.unsubscribe()}clearInput(){const t=o.DataFrame.fromColumns([o.Column.fromType(o.COLUMN_TYPE.STRING,"Remove",0),o.Column.fromType(o.COLUMN_TYPE.INT,"Start",0),o.Column.fromType(o.COLUMN_TYPE.INT,"End",0),o.Column.fromType(o.COLUMN_TYPE.STRING,"Monomers",0)]);this.setDataFrame(t)}async render(t,e){let n;const r=o.DataFrame.fromColumns([n=o.Column.fromType(o.COLUMN_TYPE.STRING,"Remove",0),o.Column.fromType(o.COLUMN_TYPE.INT,"Start",0),o.Column.fromType(o.COLUMN_TYPE.INT,"End",0),o.Column.fromType(o.COLUMN_TYPE.STRING,"Monomers",0)]);n.setTag(o.TAGS.FRIENDLY_NAME,""),this.grid=await r.plot.fromType(o.VIEWER.GRID,e),this.grid.sort(["Start","End"]),this.grid.columns.byIndex(1).width=this.grid.props.rowHeight+2,this.grid.onCellRender.subscribe((t=>{const e=t.cell;e.tableColumn?.name==n.name&&(e?.tableRowIndex??-1)>=0&&(e.element=P.div(P.icons.delete((()=>{this.grid.dataFrame.rows.removeAt(e.tableRowIndex)}),"Delete"),{style:{height:`${e.grid.props.rowHeight}px`,color:"var(--grey-6)",display:"flex",flexDirection:"row",justifyContent:"center"}}))}));const i=this.grid.columns.byName("Monomers");i&&(i.editable=!1),this.subs.push(this.grid.onCellDoubleClick.subscribe((t=>{"Monomers"===t.tableColumn?.name&&null!=t.tableRowIndex&&t.tableRowIndex>=0&&this.handleMonomerCellDoubleClick(t.tableRowIndex)}))),this.updateGridHeight(t??this.grid.dataFrame.rowCount+.7),this.subs.push(P.onSizeChanged(this.grid.root).subscribe(this.gridRootOnSizeChanged.bind(this))),this.subs.push((0,et.fromEvent)(this.grid.root,"keydown").subscribe((t=>{"Enter"===t.key&&t.stopPropagation()}))),this.setDataFrame(r),this.grid.root.style.width="100%",this.gridHost.append(this.grid.root)}setDataFrame(t){for(const t of this.dataFrameSubs)t.unsubscribe();this.grid.dataFrame=t,this.dataFrameSubs.push(this.grid.dataFrame.onRowsRemoved.subscribe((()=>{this.updateGridHeight(this.grid.dataFrame.rowCount+.7),this.fireChanged()}))),this.dataFrameSubs.push(this.grid.dataFrame.onRowsAdded.subscribe((()=>{this.updateGridHeight(this.grid.dataFrame.rowCount+.7)}))),this.dataFrameSubs.push(this.grid.dataFrame.onDataChanged.subscribe((()=>{this.fireChanged()}))),this.updateGridHeight(this.grid.dataFrame.rowCount+.7),this.fireChanged()}static async create(t,e,n){return new ur(t,n,e)}updateGridHeight(t){const e=this.grid.colHeaderHeight+t*this.grid.props.rowHeight+6+2;this.grid.root.style.height=`${e}px`}async handleMonomerCellDoubleClick(t){if(!this.onMonomerCellEdit)return;const e=this.grid.dataFrame,n=parseInt(e.get("Start",t))-1,r=parseInt(e.get("End",t))-1;if(isNaN(n)||isNaN(r))return;const o=ar(e.get("Monomers",t)??""),i=await this.onMonomerCellEdit(n,r,o);null!==i&&e.set("Monomers",t,i.join(", "))}gridRootOnSizeChanged(){this.grid.columns.byIndex(4).width=this.grid.root.clientWidth-this.grid.horzScroll.root.offsetWidth-this.grid.columns.byIndex(0).width-this.grid.columns.byIndex(1).width-this.grid.columns.byIndex(2).width-this.grid.columns.byIndex(3).width-10}}var hr=n(6307),dr=n(2738);n(9982),DG.DataFrame.fromCsv('countries,fasta,smiles,molregno,LON,Zip Code,Street Address Line 1,ImageUrl,user_id,error_message,xray,flag,magnitude,CS-id,pdb_id,accel_a,time_offset,chart,fit,Questions,empty_number,empty_string\nBelgium,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C(=O)OCCCc1cccnc1)c2cccc(c2)C(=O)c3ccccc3,1480014,36.276729583740234,995042300,14016 ROUTE 31W,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,1,1,1QBS,1,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.497360340644872, 1.7058694986686864, 5.278052678195135, 0.16000320889028383],""points"":[{""x"":0.10000000149011612,""y"":2.374499797821045},{""x"":0.6000000238418579,""y"":2.6242473125457764},{""x"":1.100000023841858,""y"":2.367267608642578},{""x"":1.600000023841858,""y"":2.6723148822784424},{""x"":2.0999999046325684,""y"":2.6537344455718994},{""x"":2.5999999046325684,""y"":2.3651671409606934},{""x"":3.0999999046325684,""y"":2.5654284954071045},{""x"":3.5999999046325684,""y"":2.4160959720611572},{""x"":4.099999904632568,""y"":2.286726713180542},{""x"":4.599999904632568,""y"":2.5100042819976807},{""x"":5.099999904632568,""y"":1.6676985025405884},{""x"":5.599999904632568,""y"":0.680136501789093},{""x"":6.099999904632568,""y"":0.3391543924808502},{""x"":6.599999904632568,""y"":0.09038983285427094},{""x"":7.099999904632568,""y"":0.19802775979042053}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[7.525235855508179, 1.3186911876809984, 5.335672608564294, 0.7860743343958098],""points"":[{""x"":0.10000000149011612,""y"":7.988070487976074},{""x"":0.6000000238418579,""y"":7.018453121185303},{""x"":1.100000023841858,""y"":8.115279197692871},{""x"":1.600000023841858,""y"":7.486658096313477},{""x"":2.0999999046325684,""y"":7.396438121795654},{""x"":2.5999999046325684,""y"":7.477052211761475},{""x"":3.0999999046325684,""y"":6.913095474243164},{""x"":3.5999999046325684,""y"":8.01385498046875},{""x"":4.099999904632568,""y"":6.985900402069092},{""x"":4.599999904632568,""y"":6.970335960388184},{""x"":5.099999904632568,""y"":5.448817253112793},{""x"":5.599999904632568,""y"":2.5534818172454834},{""x"":6.099999904632568,""y"":1.893947958946228},{""x"":6.599999904632568,""y"":0.6340042352676392},{""x"":7.099999904632568,""y"":0.8403874039649963}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,100,abc\nBurundi,MDYKETLLMPKTDFPMRGGLPNKEPQIQEKW,COc1ccc2cc(ccc2c1)C(C)C(=O)Oc3ccc(C)cc3OC,1480015,36.276729583740234,995073444,80 STATE HIGHWAY 310,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,2,2,1ZP8,2,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.431460753103398, 2.1691498799246745, 5.266445597102774, 0.7825762827017926],""points"":[{""x"":0.10000000149011612,""y"":4.751083850860596},{""x"":0.6000000238418579,""y"":4.203000068664551},{""x"":1.100000023841858,""y"":4.415858745574951},{""x"":1.600000023841858,""y"":4.68414306640625},{""x"":2.0999999046325684,""y"":4.198400974273682},{""x"":2.5999999046325684,""y"":4.179222106933594},{""x"":3.0999999046325684,""y"":4.638473987579346},{""x"":3.5999999046325684,""y"":4.708553314208984},{""x"":4.099999904632568,""y"":4.291589260101318},{""x"":4.599999904632568,""y"":4.038082599639893},{""x"":5.099999904632568,""y"":3.4349939823150635},{""x"":5.599999904632568,""y"":1.2194708585739136},{""x"":6.099999904632568,""y"":1.1920831203460693},{""x"":6.599999904632568,""y"":0.5352635979652405},{""x"":7.099999904632568,""y"":0.3346920311450958}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.339458017970126, -1.0734184310171178, 4.746332950550934, 0.2482416857595658],""points"":[{""x"":0.10000000149011612,""y"":0.2139337658882141},{""x"":0.6000000238418579,""y"":0.4269562065601349},{""x"":1.100000023841858,""y"":0.2441573292016983},{""x"":1.600000023841858,""y"":0.146635964512825},{""x"":2.0999999046325684,""y"":0.08818462491035461},{""x"":2.5999999046325684,""y"":0.2560656666755676},{""x"":3.0999999046325684,""y"":0.42434045672416687},{""x"":3.5999999046325684,""y"":0.37111231684684753},{""x"":4.099999904632568,""y"":0.5581737160682678},{""x"":4.599999904632568,""y"":1.183590054512024},{""x"":5.099999904632568,""y"":1.5629843473434448},{""x"":5.599999904632568,""y"":2.3211288452148438},{""x"":6.099999904632568,""y"":2.229961633682251},{""x"":6.599999904632568,""y"":2.2560226917266846},{""x"":7.099999904632568,""y"":2.2142398357391357}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCameroon,MIEVFLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL,COc1ccc2cc(ccc2c1)C(C)C(=O)OCCCc3cccnc3,1480016,36.26095962524414,995153596,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,3,3,2BDJ,3,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.6760652578642325, 0.9046956320756703, 5.651408971856738, 0.07738846012184185],""points"":[{""x"":0.10000000149011612,""y"":4.32425594329834},{""x"":0.6000000238418579,""y"":4.668442249298096},{""x"":1.100000023841858,""y"":4.379785060882568},{""x"":1.600000023841858,""y"":5.0345139503479},{""x"":2.0999999046325684,""y"":4.878653526306152},{""x"":2.5999999046325684,""y"":4.3451313972473145},{""x"":3.0999999046325684,""y"":4.336992263793945},{""x"":3.5999999046325684,""y"":5.037430286407471},{""x"":4.099999904632568,""y"":5.0092692375183105},{""x"":4.599999904632568,""y"":4.151902675628662},{""x"":5.099999904632568,""y"":3.4066951274871826},{""x"":5.599999904632568,""y"":2.3732759952545166},{""x"":6.099999904632568,""y"":1.673728108406067},{""x"":6.599999904632568,""y"":0.48574790358543396},{""x"":7.099999904632568,""y"":0.2783052325248718}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.938395863010111, -1.4658480661392117, 5.462702751996584, 0.3473139023615039],""points"":[{""x"":0.10000000149011612,""y"":0.4941710829734802},{""x"":0.6000000238418579,""y"":0.15323974192142487},{""x"":1.100000023841858,""y"":0.46373432874679565},{""x"":1.600000023841858,""y"":0.3370431363582611},{""x"":2.0999999046325684,""y"":0.5179030299186707},{""x"":2.5999999046325684,""y"":0.27899765968322754},{""x"":3.0999999046325684,""y"":0.22075064480304718},{""x"":3.5999999046325684,""y"":0.5789918899536133},{""x"":4.099999904632568,""y"":0.21169911324977875},{""x"":4.599999904632568,""y"":0.27857646346092224},{""x"":5.099999904632568,""y"":1.0906332731246948},{""x"":5.599999904632568,""y"":1.8520300388336182},{""x"":6.099999904632568,""y"":2.7177059650421143},{""x"":6.599999904632568,""y"":2.8680918216705322},{""x"":7.099999904632568,""y"":3.2413077354431152}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCanada,MMELVLKTIIGPIVVGVVLRIVDKWLNKDK,CC(C(=O)NCCS)c1cccc(c1)C(=O)c2ccccc2,1480017,36.26095962524414,99515,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,4,4,1IAN,4,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[0.8597390975430008, 1.0957625732481946, 5.260537067987958, 0.07974187998177736],""points"":[{""x"":0.10000000149011612,""y"":0.8190152645111084},{""x"":0.6000000238418579,""y"":0.8421689867973328},{""x"":1.100000023841858,""y"":0.8740922212600708},{""x"":1.600000023841858,""y"":0.8924275040626526},{""x"":2.0999999046325684,""y"":0.8249067664146423},{""x"":2.5999999046325684,""y"":0.9327669143676758},{""x"":3.0999999046325684,""y"":0.8522974252700806},{""x"":3.5999999046325684,""y"":0.8174492716789246},{""x"":4.099999904632568,""y"":0.8394647240638733},{""x"":4.599999904632568,""y"":0.7139387726783752},{""x"":5.099999904632568,""y"":0.5561167597770691},{""x"":5.599999904632568,""y"":0.3276226818561554},{""x"":6.099999904632568,""y"":0.12479474395513535},{""x"":6.599999904632568,""y"":0.13006797432899475},{""x"":7.099999904632568,""y"":0.059702079743146896}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.760930219582546, 1.6591793293833013, 4.667155929720851, 0.7858109544121652],""points"":[{""x"":0.10000000149011612,""y"":6.156993389129639},{""x"":0.6000000238418579,""y"":5.236701965332031},{""x"":1.100000023841858,""y"":6.010560512542725},{""x"":1.600000023841858,""y"":5.495512962341309},{""x"":2.0999999046325684,""y"":6.087770462036133},{""x"":2.5999999046325684,""y"":5.79986572265625},{""x"":3.0999999046325684,""y"":5.597546577453613},{""x"":3.5999999046325684,""y"":5.520902156829834},{""x"":4.099999904632568,""y"":5.360654354095459},{""x"":4.599999904632568,""y"":3.5539746284484863},{""x"":5.099999904632568,""y"":1.577236294746399},{""x"":5.599999904632568,""y"":1.0001264810562134},{""x"":6.099999904632568,""y"":0.9305797815322876},{""x"":6.599999904632568,""y"":0.6033638715744019},{""x"":7.099999904632568,""y"":0.4203685522079468}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nColombia,MDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN,FC(F)(F)c1ccc(OC2CCNCC2)cc1,1480029,36.3309440612793,995152050,1 COURT HOUSE SQUARE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,5,5,4UJ1,5,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[6.4995088314153655, 2.4270351004539914, 5.178659535348579, 0.625653346241577],""points"":[{""x"":0.10000000149011612,""y"":6.496231555938721},{""x"":0.6000000238418579,""y"":6.42543363571167},{""x"":1.100000023841858,""y"":7.040063858032227},{""x"":1.600000023841858,""y"":6.1115403175354},{""x"":2.0999999046325684,""y"":6.680728435516357},{""x"":2.5999999046325684,""y"":6.406774520874023},{""x"":3.0999999046325684,""y"":6.611269474029541},{""x"":3.5999999046325684,""y"":5.889094352722168},{""x"":4.099999904632568,""y"":6.75344705581665},{""x"":4.599999904632568,""y"":6.361435890197754},{""x"":5.099999904632568,""y"":4.1666975021362305},{""x"":5.599999904632568,""y"":1.172118902206421},{""x"":6.099999904632568,""y"":0.801048994064331},{""x"":6.599999904632568,""y"":0.4640021026134491},{""x"":7.099999904632568,""y"":0.0010357667924836278}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[1.4734381347446401, 1.1649805188074196, 4.82958608866421, 0.09500545496710007],""points"":[{""x"":0.10000000149011612,""y"":1.5279096364974976},{""x"":0.6000000238418579,""y"":1.3559974431991577},{""x"":1.100000023841858,""y"":1.5246378183364868},{""x"":1.600000023841858,""y"":1.5567657947540283},{""x"":2.0999999046325684,""y"":1.4114240407943726},{""x"":2.5999999046325684,""y"":1.4045010805130005},{""x"":3.0999999046325684,""y"":1.4769829511642456},{""x"":3.5999999046325684,""y"":1.4875500202178955},{""x"":4.099999904632568,""y"":1.2991987466812134},{""x"":4.599999904632568,""y"":0.922961413860321},{""x"":5.099999904632568,""y"":0.6520044803619385},{""x"":5.599999904632568,""y"":0.15350978076457977},{""x"":6.099999904632568,""y"":0.1078903079032898},{""x"":6.599999904632568,""y"":0.17276449501514435},{""x"":7.099999904632568,""y"":0.14066608250141144}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCosta Rica,MKSTKEEIQTIKTLLKDSRTAKYHKRLQIVL,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCCc3ccccc3,1480018,36.3309440612793,995084218,4041 SOUTHWESTERN BLVD,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,6,6,2BPW,6,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.4833641843311227, -1.8945978742090062, 4.671127708092568, 0.24159861311815153],""points"":[{""x"":0.10000000149011612,""y"":0.0969524160027504},{""x"":0.6000000238418579,""y"":0.028483040630817413},{""x"":1.100000023841858,""y"":0.22087176144123077},{""x"":1.600000023841858,""y"":0.0068915546871721745},{""x"":2.0999999046325684,""y"":0.4305879771709442},{""x"":2.5999999046325684,""y"":0.44774115085601807},{""x"":3.0999999046325684,""y"":0.45346319675445557},{""x"":3.5999999046325684,""y"":0.2370593100786209},{""x"":4.099999904632568,""y"":0.4657953977584839},{""x"":4.599999904632568,""y"":1.155200719833374},{""x"":5.099999904632568,""y"":2.2294070720672607},{""x"":5.599999904632568,""y"":2.4311530590057373},{""x"":6.099999904632568,""y"":2.33846116065979},{""x"":6.599999904632568,""y"":2.608201026916504},{""x"":7.099999904632568,""y"":2.8136143684387207}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.224573521642033, 1.4454033924198528, 5.6014197746076535, 0.2823216054197577],""points"":[{""x"":0.10000000149011612,""y"":4.95027494430542},{""x"":0.6000000238418579,""y"":5.1754679679870605},{""x"":1.100000023841858,""y"":5.276752948760986},{""x"":1.600000023841858,""y"":5.589294910430908},{""x"":2.0999999046325684,""y"":5.616994857788086},{""x"":2.5999999046325684,""y"":5.120813846588135},{""x"":3.0999999046325684,""y"":5.340766906738281},{""x"":3.5999999046325684,""y"":4.876471042633057},{""x"":4.099999904632568,""y"":4.94999361038208},{""x"":4.599999904632568,""y"":5.162564754486084},{""x"":5.099999904632568,""y"":4.399557590484619},{""x"":5.599999904632568,""y"":2.7977969646453857},{""x"":6.099999904632568,""y"":1.0229872465133667},{""x"":6.599999904632568,""y"":0.48275601863861084},{""x"":7.099999904632568,""y"":0.10408931970596313}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCuba,MHAILRYFIRRLFYHIFYKIYSLISKKHQSLPSDVRQF,COc1ccc2c(c1)c(CC(=O)N3CCCC3C(=O)Oc4ccc(C)cc4OC)c(C)n2C(=O)c5ccc(Cl)cc5,1480019,36.33115768432617,995081928,1227 US HIGHWAY 11,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,7,7,1QBS,7,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.320838679713925, -1.2421619987316728, 4.831325425225256, 0.3236011098403072],""points"":[{""x"":0.10000000149011612,""y"":0.3727470338344574},{""x"":0.6000000238418579,""y"":0.12365014106035233},{""x"":1.100000023841858,""y"":0.48422467708587646},{""x"":1.600000023841858,""y"":0.2264465093612671},{""x"":2.0999999046325684,""y"":0.16821794211864471},{""x"":2.5999999046325684,""y"":0.3879014551639557},{""x"":3.0999999046325684,""y"":0.5470244884490967},{""x"":3.5999999046325684,""y"":0.3419053554534912},{""x"":4.099999904632568,""y"":0.7655120491981506},{""x"":4.599999904632568,""y"":1.2346516847610474},{""x"":5.099999904632568,""y"":2.453336715698242},{""x"":5.599999904632568,""y"":2.9565491676330566},{""x"":6.099999904632568,""y"":3.335299491882324},{""x"":6.599999904632568,""y"":3.240290880203247},{""x"":7.099999904632568,""y"":3.1107218265533447}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.6401853521511094, 1.26211588875013, 5.399028074402744, 0.5089580830068091],""points"":[{""x"":0.10000000149011612,""y"":3.8585598468780518},{""x"":0.6000000238418579,""y"":3.6077206134796143},{""x"":1.100000023841858,""y"":3.855252265930176},{""x"":1.600000023841858,""y"":3.619039297103882},{""x"":2.0999999046325684,""y"":3.839388370513916},{""x"":2.5999999046325684,""y"":3.335283041000366},{""x"":3.0999999046325684,""y"":3.571141481399536},{""x"":3.5999999046325684,""y"":3.4155046939849854},{""x"":4.099999904632568,""y"":3.7316646575927734},{""x"":4.599999904632568,""y"":3.0680155754089355},{""x"":5.099999904632568,""y"":2.891066551208496},{""x"":5.599999904632568,""y"":1.6022753715515137},{""x"":6.099999904632568,""y"":0.7652576565742493},{""x"":6.599999904632568,""y"":0.6875326037406921},{""x"":7.099999904632568,""y"":0.5828871726989746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nItaly,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO[N+](=O)[O-],1480020,36.33115768432617,99502,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,8,8,1ZP8,8,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.293592105923809, 1.3781586549141835, 5.1025898038676605, 0.03493851245291291],""points"":[{""x"":0.10000000149011612,""y"":2.1287283897399902},{""x"":0.6000000238418579,""y"":2.267972230911255},{""x"":1.100000023841858,""y"":2.398442506790161},{""x"":1.600000023841858,""y"":2.5130622386932373},{""x"":2.0999999046325684,""y"":2.3255116939544678},{""x"":2.5999999046325684,""y"":2.127340793609619},{""x"":3.0999999046325684,""y"":2.47259783744812},{""x"":3.5999999046325684,""y"":2.131181478500366},{""x"":4.099999904632568,""y"":2.090421438217163},{""x"":4.599999904632568,""y"":2.02299165725708},{""x"":5.099999904632568,""y"":1.1105059385299683},{""x"":5.599999904632568,""y"":0.4494485855102539},{""x"":6.099999904632568,""y"":0.1375635862350464},{""x"":6.599999904632568,""y"":0.036351121962070465},{""x"":7.099999904632568,""y"":0.1619771122932434}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.953125499439879, 1.2528620255306528, 5.187637440149802, 0.3110348753260886],""points"":[{""x"":0.10000000149011612,""y"":5.6585283279418945},{""x"":0.6000000238418579,""y"":5.911152362823486},{""x"":1.100000023841858,""y"":5.924920082092285},{""x"":1.600000023841858,""y"":5.8469438552856445},{""x"":2.0999999046325684,""y"":5.929472923278809},{""x"":2.5999999046325684,""y"":6.190037727355957},{""x"":3.0999999046325684,""y"":6.236179828643799},{""x"":3.5999999046325684,""y"":6.141019344329834},{""x"":4.099999904632568,""y"":5.295210838317871},{""x"":4.599999904632568,""y"":5.265801906585693},{""x"":5.099999904632568,""y"":3.3722851276397705},{""x"":5.599999904632568,""y"":1.8299226760864258},{""x"":6.099999904632568,""y"":0.32690900564193726},{""x"":6.599999904632568,""y"":0.6274543404579163},{""x"":7.099999904632568,""y"":0.8441857099533081}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nRwanda,MPNSEPASLLELFNSIATQGELVRSLKAGNASK,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO,1480021,36.33137130737305,995037247,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,9,9,2BDJ,9,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.8209972202654474, 1.3779216716448506, 5.299882228439686, 0.06040645519069608],""points"":[{""x"":0.10000000149011612,""y"":3.7821109294891357},{""x"":0.6000000238418579,""y"":3.542433023452759},{""x"":1.100000023841858,""y"":3.7008674144744873},{""x"":1.600000023841858,""y"":3.717301607131958},{""x"":2.0999999046325684,""y"":4.024452209472656},{""x"":2.5999999046325684,""y"":4.013899326324463},{""x"":3.0999999046325684,""y"":3.945094347000122},{""x"":3.5999999046325684,""y"":3.866621971130371},{""x"":4.099999904632568,""y"":3.7461626529693604},{""x"":4.599999904632568,""y"":3.3454740047454834},{""x"":5.099999904632568,""y"":2.61944317817688},{""x"":5.599999904632568,""y"":0.999405026435852},{""x"":6.099999904632568,""y"":0.46259793639183044},{""x"":6.599999904632568,""y"":0.054134611040353775},{""x"":7.099999904632568,""y"":0.05711187422275543}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.6318079657726035, 1.8495493770000595, 5.391793312471116, 0.17060707587348442],""points"":[{""x"":0.10000000149011612,""y"":5.458079814910889},{""x"":0.6000000238418579,""y"":5.554427146911621},{""x"":1.100000023841858,""y"":5.799983024597168},{""x"":1.600000023841858,""y"":5.364140033721924},{""x"":2.0999999046325684,""y"":5.864485740661621},{""x"":2.5999999046325684,""y"":5.4509806632995605},{""x"":3.0999999046325684,""y"":5.702574729919434},{""x"":3.5999999046325684,""y"":5.7314534187316895},{""x"":4.099999904632568,""y"":5.5123443603515625},{""x"":4.599999904632568,""y"":5.724395751953125},{""x"":5.099999904632568,""y"":4.354506969451904},{""x"":5.599999904632568,""y"":1.7307666540145874},{""x"":6.099999904632568,""y"":0.6305936574935913},{""x"":6.599999904632568,""y"":0.035183437168598175},{""x"":7.099999904632568,""y"":0.7575169205665588}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nSwitzerland,IRVVGRYLIEVWKAAGMDMDKVLFLWSSDEI,CN1CCC(CC1)Oc2ccc(cc2)C(F)(F)F,1480028,36.33137130737305,99504,92-11 179TH PLACE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,9,10,1IAN,10,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[1.1190255865097471, 2.3163895161544437, 5.4968866182279195, 0.2035204047289052],""points"":[{""x"":0.10000000149011612,""y"":1.1057683229446411},{""x"":0.6000000238418579,""y"":1.1019697189331055},{""x"":1.100000023841858,""y"":1.0818607807159424},{""x"":1.600000023841858,""y"":1.062997817993164},{""x"":2.0999999046325684,""y"":1.046447515487671},{""x"":2.5999999046325684,""y"":1.1217249631881714},{""x"":3.0999999046325684,""y"":1.2166996002197266},{""x"":3.5999999046325684,""y"":1.215477705001831},{""x"":4.099999904632568,""y"":1.0581893920898438},{""x"":4.599999904632568,""y"":1.1747995615005493},{""x"":5.099999904632568,""y"":1.0181127786636353},{""x"":5.599999904632568,""y"":0.5344523191452026},{""x"":6.099999904632568,""y"":0.2569526433944702},{""x"":6.599999904632568,""y"":0.1912207305431366},{""x"":7.099999904632568,""y"":0.15060538053512573}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.1038581025805785, 2.0032224204185245, 5.087602825989163, 0.13277988512492753],""points"":[{""x"":0.10000000149011612,""y"":3.0498509407043457},{""x"":0.6000000238418579,""y"":2.805217742919922},{""x"":1.100000023841858,""y"":3.3415253162384033},{""x"":1.600000023841858,""y"":3.0549843311309814},{""x"":2.0999999046325684,""y"":3.250074863433838},{""x"":2.5999999046325684,""y"":3.0432586669921875},{""x"":3.0999999046325684,""y"":3.265852451324463},{""x"":3.5999999046325684,""y"":2.9475724697113037},{""x"":4.099999904632568,""y"":3.1929898262023926},{""x"":4.599999904632568,""y"":2.7460060119628906},{""x"":5.099999904632568,""y"":1.6175861358642578},{""x"":5.599999904632568,""y"":0.3006608486175537},{""x"":6.099999904632568,""y"":0.3444803059101105},{""x"":6.599999904632568,""y"":0.015537971630692482},{""x"":7.099999904632568,""y"":0.5527358055114746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\n,,,,,,,,,,,,,,,,,,,,,').columns.add(DG.Column.fromList(DG.TYPE.BYTE_ARRAY,"BinaryImage",Array.from(new Uint8Array(11))));var pr;console.log.bind(console),console.info.bind(console),console.warn.bind(console),console.error.bind(console),function(t){t.notNull=function(t,e){if(null==t)throw new Error(`${null==e?"Value":e} not defined`)}}(pr||(pr={})),DG.DataFrame.fromColumns([DG.Column.fromStrings("col",["val1","val2","val3"])]);class fr{onKeyDown(t,e){}onKeyPress(t,e){}onMouseEnter(t,e){}onMouseLeave(t,e){}onMouseDown(t,e){}onMouseUp(t,e){}onMouseMove(t,e){}onClick(t,e){}onDoubleClick(t,e){}}class mr extends fr{constructor(t,e,n){super(),this.gridCol=t,this.tableCol=e,this.logger=n,this.subs=[],this.dirty=!0,this.destroyed=!1,this.viewerId=++mr.viewerCounter,this.errors=[],this._onRendered=new et.Subject,this.tableCol&&this.tableCol.dataFrame&&(this.subs.push(this.tableCol.dataFrame.onDataChanged.subscribe((()=>{this.dirty=!0}))),this.subs.push(this.tableCol.dataFrame.onColumnsRemoved.subscribe((t=>{try{this.destroyed||!this.tableCol||this.tableCol.dataFrame||this.destroy()}catch(t){this.logger.error(t)}})))),this.tableCol&&this.subs.push(r.events.onTableRemoved.subscribe((t=>{try{const e=t.args.dataFrame;this.tableCol?.dataFrame.id!==e.id||this.destroyed||this.destroy()}catch(t){this.logger.error(t)}}))),this.gridCol&&this.subs.push(r.events.onViewRemoving.subscribe((t=>{try{const e=t.args.view;this.gridCol?.dart&&this.gridCol.grid&&this.gridCol?.grid?.dart&&this.gridCol?.grid?.view?.id===e.id&&!this.destroyed&&this.destroy()}catch(t){this.logger.error(t)}})))}toLog(){return`${this.constructor.name}<${this.viewerId}>`}destroy(){for(const t of this.subs)t.unsubscribe();this.destroyed=!0}invalidateGrid(){this.gridCol&&this.gridCol.dart&&this.gridCol.grid?.invalidate()}reset(){this.dirty=!1}get onRendered(){return this._onRendered}invalidate(t){this.invalidateGrid()}async awaitRendered(t=1e4,e=`${t} timeout`){const n=`${this.toLog()}.awaitRendered()`;if(this.logger.debug(`${n}, start, testEvent before`),await function(t,e,n,r=0,o="timeout"){return function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{l(r.next(t))}catch(t){i(t)}}function a(t){try{l(r.throw(t))}catch(t){i(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((r=r.apply(t,e||[])).next())}))}(this,void 0,void 0,(function*(){return new Promise(((i,s)=>{const a=t.subscribe((t=>{try{e(t),i("OK")}catch(t){s(t)}finally{a.unsubscribe(),clearTimeout(l)}})),l=setTimeout((()=>{a.unsubscribe(),s(o)}),r);n()}))}))}(this._onRendered,(()=>{}),(()=>{this.invalidate()}),t,`${n}, ${e}`),this.errors.length>0){const t=this.errors[0];throw this.errors=[],t}this.logger.debug(`${n}, end`)}}mr.viewerCounter=-1;const gr="rgb(100,100,100)",yr="rgb(0,0,0)",br=s.zS;var vr,Cr,xr;!function(t){t.maxMonomerLength=".mm.cellRenderer.maxMonomerLength"}(vr||(vr={})),function(t){t.applyToBackground=".m.cellRenderer.applyToBackground"}(Cr||(Cr={})),function(t){t.MSA="MSA",t.classic="classic"}(xr||(xr={}));const wr=new class{constructor(){this.color=gr,this.pivot=0,this.left=!1,this.transparencyRate=0,this.separator="",this.last=!1,this.drawStyle=xr.classic,this.maxWord=[],this.wordIdx=0,this.gridCell=null,this.referenceSequence=null,this.maxLengthOfMonomer=null,this.monomerTextSizeMap={},this.logger=void 0,this.selectedPosition=void 0,this.isMultiLineContext=!1,this.lineNumber=0}};function Ar(t,e,n,r,i,s,a){var l,c,u;const h={...wr,...a};if(h.isMultiLineContext){t.textBaseline="middle",t.textAlign="center";let o=e;null!=h.maxLengthOfMonomer&&(o=br(o,h.maxLengthOfMonomer));const a=Math.max(.1,1-(h.transparencyRate??0));t.globalAlpha=a;const l=t.measureText(o),c=l.fontBoundingBoxAscent+l.fontBoundingBoxDescent,u=r+(s-c)/2+l.fontBoundingBoxAscent;let d=h.color??gr;return d&&d!==gr||(d=yr),t.fillStyle=d,h.selectedPosition===h.wordIdx+1&&(t.save(),t.fillStyle="rgba(60, 177, 115, 0.2)",t.fillRect(n,r,i,s),t.restore(),t.fillStyle=d),t.fillText(o,n+i/2,u),t.globalAlpha=1,t.textBaseline="top",t.textAlign="start",n+i}a.logger?.debug("Bio: printLeftOrCentered(), start"),t.textAlign="start";let d=e.substring(0),p=h.last?"":h.separator;h.drawStyle===xr.MSA&&(p="");let f=!0,m=!0,g="difference";if(null!=h.gridCell&&null!=h.gridCell.cell.column&&(f=h.gridCell.cell.column.temp["color-code"]??!0,m=h.gridCell.cell.column.temp["compare-with-current"]??!0,g=h.gridCell.cell.column.temp["highlight-difference"]??"difference"),h.referenceSequence){const t=h.referenceSequence[h.wordIdx];m&&h.referenceSequence.length>0&&"difference"===g&&(h.transparencyRate=d==t?.7:h.transparencyRate),m&&h.referenceSequence.length>0&&"equal"===g&&(h.transparencyRate=d!=t?.7:h.transparencyRate)}null!=h.maxLengthOfMonomer&&(d=br(d,h.maxLengthOfMonomer));const y=d+p;(l=h.monomerTextSizeMap)[y]??(l[y]=t.measureText(y));let b=h.monomerTextSizeMap[y];(c=h.monomerTextSizeMap)[d]??(c[d]=t.measureText(d));let v=h.monomerTextSizeMap[d].width;const C=s/2-(b.fontBoundingBoxAscent+b.fontBoundingBoxDescent)/2+1;(u=h.monomerTextSizeMap)[p]??(u[p]=t.measureText(p));const x=h.monomerTextSizeMap[p].width;function w(e,i){let a=f?h.color:yr;h.selectedPosition===h.wordIdx+1&&(t.fillStyle="rgba(60, 177, 115, 0.2)",t.fillRect(n+e-4,r-5,h.monomerTextSizeMap[d].width+8,s+10),a=o.Color.toHtml(o.Color.setAlpha(o.Color.fromHtml(a),255))),t.fillStyle=a,t.globalAlpha=1-h.transparencyRate,h.drawStyle===xr.classic&&(t.fillText(d,n+e,r+C),t.fillStyle="#808080",t.fillText(p,n+i,r+C)),h.drawStyle===xr.MSA&&t.fillText(d,n+e,r+C),t.globalAlpha=1}b=b.width,h.drawStyle===xr.MSA&&(v=h.maxWord[h.wordIdx],b=h.maxWord[h.wordIdx]);const A=(h.maxWord[h.wordIdx]??0)-(h.maxWord[0]??0);if(h.left||b>i)return w(A,A+v),n+A+v+x;{const t=(i-b)/2;return w(t,t+v),n+A+t+v}}var Tr,Er,Sr;!function(t){t.Region="region",t.Point="point",t.Motif="motif"}(Tr||(Tr={})),function(t){t.Structure="structure",t.Liability="liability",t.PTM="ptm",t.Custom="custom"}(Er||(Er={})),function(t){t.High="high",t.Medium="medium",t.Low="low",t.Info="info"}(Sr||(Sr={}));const Ir={structure:{FR:["#0095ff","#289dfd","#48adff","#3ba5fc"],CDR:["#ffdca3","#facb83","#f7a224"]},liability:{deamidation:"#E53935",isomerization:"#FF9800",oxidation:"#9C27B0",glycosylation:"#4CAF50",freeCysteine:"#607D8B"}};class Nr{constructor(t){this.tableCol=t,this._cache=null,this._rowCache=null,this._annotCol=null,this._annotColLookupVersion=-1}hasAnnotations(){return this._ensureCache(),null!==this._cache&&this._cache.annotations.length>0}getAnnotations(){return this._ensureCache(),this._cache?.annotations??[]}getRegionNameAtPosition(t,e){if(null!=e){const n=this._findRowRegionHit(e,t);if(n){const t=this._cache?.annotations.find((t=>t.id===n.annotationId));return t?.name??null}if(this._rowHasRegionData(e))return null}return this._ensureCache(),this._cache?.positionRegionNames.get(t)??null}getHitsAtPosition(t,e){if(this._ensureRowCache(),!this._rowCache)return[];const n=this._rowCache.data[t];return n?n.filter((t=>null==t.endPositionIndex&&(t.positionIndex===e||t.matchedMonomers.length>1&&e>t.positionIndex&&e<t.positionIndex+t.matchedMonomers.length))):[]}drawPositionBackground(t,e,n,r,o,i,s,a){if(this._ensureCache(),!this._cache)return;let l;this._ensureRowCache();const c=this._findRowRegionHit(s,i);if(c){const t=this._cache.annotations.find((t=>t.id===c.annotationId));l=t?.color??(t?this._getDefaultRegionColor(t):void 0)}if(l||this._rowHasRegionData(s)||(l=this._cache.positionRegionColors.get(i)),l&&(t.save(),t.globalAlpha=.25,t.fillStyle=l,t.fillRect(e,n,r,o),t.restore()),this._rowCache){const l=this._rowCache.data[s];if(l)for(const s of l)if(null==s.endPositionIndex&&i>=s.positionIndex&&i<s.positionIndex+s.matchedMonomers.length){const i=this._cache.annotations.find((t=>t.id===s.annotationId));if(i?.color){const s=null!=a?a+1:n+o-3;t.fillStyle=i.color,t.fillRect(e,s,r,3)}break}}}getTooltipInfo(t,e){this._ensureCache();const n=[];if(!this._cache)return n;this._ensureRowCache();let r=null;const o=this._findRowRegionHit(e,t);if(o){const t=this._cache.annotations.find((t=>t.id===o.annotationId));if(t){r=t.name;const e=t.sourceScheme??"";n.push(`Region: ${t.name}${e?` (${e} ${t.start}-${t.end})`:""}`)}}if(!r&&!this._rowHasRegionData(e)){const e=this._cache.positionRegionNames.get(t);if(e){const t=this._cache.annotations.find((t=>t.name===e&&t.category===Er.Structure)),r=t?.sourceScheme??"";n.push(`Region: ${e}${r?` (${r} ${t?.start}-${t?.end})`:""}`)}}if(this._rowCache){const r=this._rowCache.data[e];if(r)for(const e of r)if(null==e.endPositionIndex&&t>=e.positionIndex&&t<e.positionIndex+e.matchedMonomers.length){const t=this._cache.annotations.find((t=>t.id===e.annotationId));if(t){const e=t.severity?` - ${t.severity.charAt(0).toUpperCase()+t.severity.slice(1)}`:"";n.push(`⚠ ${t.name}${e}`)}}}return n}_findRowRegionHit(t,e){if(this._ensureRowCache(),!this._rowCache)return null;const n=this._rowCache.data[t];if(!n)return null;for(const t of n)if(null!=t.endPositionIndex&&e>=t.positionIndex&&e<=t.endPositionIndex)return t;return null}_rowHasRegionData(t){if(this._ensureRowCache(),!this._rowCache)return!1;const e=this._rowCache.data[t];return!!e&&e.some((t=>null!=t.endPositionIndex))}_ensureCache(){const t=this.tableCol.version;if(this._cache&&this._cache.colVersion===t)return;const e=this.tableCol.getTag(i.gp.annotations);if(!e)return void(this._cache=null);let n;try{n=JSON.parse(e)}catch{return void(this._cache=null)}if(!n||0===n.length)return void(this._cache=null);const r=new Map,o=new Map,s=this._getPosList();for(const t of n){if(t.category!==Er.Structure)continue;if(null==t.start||null==t.end)continue;const e=s.indexOf(t.start),n=s.indexOf(t.end);if(e<0||n<0)continue;const i=t.color??this._getDefaultRegionColor(t);for(let s=e;s<=n;s++)r.set(s,i),o.set(s,t.name)}this._cache={colVersion:t,annotations:n,positionRegionColors:r,positionRegionNames:o}}_ensureRowCache(){const t=this.tableCol.version;if(this._annotColLookupVersion!==t){this._annotColLookupVersion=t;const e=this.tableCol.getTag(i.gp.annotationColumnName);if(e)try{this._annotCol=this.tableCol.dataFrame.columns.byName(e)}catch{this._annotCol=null}else this._annotCol=null}if(!this._annotCol)return void(this._rowCache=null);const e=this._annotCol.version;if(this._rowCache&&this._rowCache.colVersion===e)return;const n=new Array(this._annotCol.length);for(let t=0;t<this._annotCol.length;t++){const e=this._annotCol.get(t);if(e)try{n[t]=JSON.parse(e)}catch{n[t]=null}else n[t]=null}this._rowCache={colVersion:e,data:n}}_getPosList(){const t=this.tableCol.getTag(i.gp.positionNames);return t?t.split(", "):[]}_getDefaultRegionColor(t){if(t.name.startsWith("CDR")){const e=parseInt(t.name.replace("CDR",""))-1;return Ir.structure.CDR[e%Ir.structure.CDR.length]}if(t.name.startsWith("FR")){const e=parseInt(t.name.replace("FR",""))-1;return Ir.structure.FR[e%Ir.structure.FR.length]}return"#90CAF9"}}var _r=n(3599);const Pr="rgb(100,100,100)";class Mr extends mr{get separatorWidth(){return this.props?.fontCharWidth?this.props?.fontCharWidth:5}getAnnotationRenderer(){return this._annotationRenderer||(this._annotationRenderer=new Nr(this.tableCol)),this._annotationRenderer.hasAnnotations()?this._annotationRenderer:null}constructor(t,e,n,r,i){if(super(t,e,n),this.monomerLengthLimit=r,this.propsProvider=i,this.colWidth=0,this._monomerLengthList=null,this._processedMaxVisibleSeqLength=0,this._monomerLengthMap={},this._monomerStructureMap={},this._ellipsisBounds=void 0,this._totalLinesNeeded=0,this._lineHeight=20,this._cellBounds=new Map,this.sysMonomerLib=null,this._annotationRenderer=null,this.padding=5,this._leftThreeDotsPadding=0,this.props=this.propsProvider(),this._processedRows=o.BitSet.create(this.tableCol.length),this.gridCol&&this.subs.push(this.gridCol.grid.onAfterDrawContent.subscribe((()=>{this._onRendered.next()}))),this.tableCol&&this.gridCol){this.subs.push(this.tableCol.dataFrame.onCurrentRowChanged.subscribe((()=>{-1===this.tableCol.dataFrame.currentRowIdx&&(this.tableCol.temp["reference-sequence"]=null,this.tableCol.temp["current-word"]=null,this.invalidateGrid())})));const t=[Oe.gp.positionShift,"renderMultiline"];this.subs.push(o.debounce(this.tableCol.dataFrame.onMetadataChanged.pipe(nt.filter((e=>e.args.source===this.tableCol&&t.includes(e.args.key)))),200).subscribe((t=>{this.reset()}))),this.subs.push(o.debounce(this.tableCol.dataFrame.onMetadataChanged.pipe(nt.filter((t=>t.args.source===this.tableCol&&t.args.key===Oe.gp.positionShift))),200).subscribe((t=>{this.reset()})))}}calculateFontBasedSpacing(t){const e=t.measureText("M");let n=12;if(this.tableCol?.temp[".mm.cellRenderer.fontSize"]){const t=this.tableCol.temp[".mm.cellRenderer.fontSize"];"number"!=typeof t||isNaN(t)||(n=Math.max(t,1))}return{lineHeight:Math.max(1.4*n,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent+4),monomerSpacing:Math.max(2,.2*this.props.fontCharWidth)}}shouldUseMultilineRendering(t){return"true"===t.getTag("renderMultiline")}calculateMultiLineLayoutDynamic(t,e,n,r,o,i){if(this.dirty)try{this.reset()}catch(t){const[e,n]=(0,Je.AP)(t);this.logger.error(e,void 0,n)}const{lineHeight:s,monomerSpacing:a}=this.calculateFontBasedSpacing(t),l=e-2*this.padding;let c=0;const u=[];if(r.length>0)for(let e=o;e<r.length;e++){const n=r.getOriginal(e),o=this.props.monomerToShort(n,i);u.push({text:o,posIdx:e}),c=Math.max(c,t.measureText(o).width)}if(0===u.length)return{lineLayouts:[],lineHeight:s};const h=c;let d=Math.floor((l+a)/(h+a));d=Math.max(1,d);const p=n-2*this.padding,f=Math.max(0,Math.floor(p/s)),m=[];let g=0;for(let t=0;t<f&&g<u.length;t++){const e=[];for(let t=0;t<d&&g<u.length;t++){const n=u[g],r=this.padding+t*(h+a);e.push({posIdx:n.posIdx,x:r,width:h,om:n.text,isSeparator:!1}),g++}m.push({lineIdx:t,elements:e})}return{lineLayouts:m,lineHeight:s}}async init(){await Promise.all([(async()=>{this.seqHelper=await(0,Xe.Q)(),this.invalidateGrid()})(),(async()=>{const t=await(0,l.pj)();this.sysMonomerLib=t.getMonomerLib()})()]),this.subs.push(this.sysMonomerLib.onChanged.subscribe((()=>{this.reset()}))),this.reset()}static getFontSettings(t){let e=12;return t&&t.temp[".mm.cellRenderer.fontSize"]&&"number"==typeof t.temp[".mm.cellRenderer.fontSize"]&&!isNaN(t.temp[".mm.cellRenderer.fontSize"])&&(e=Math.max(t.temp[".mm.cellRenderer.fontSize"],1)),{font:`${e}px monospace`,fontWidth:.6*e}}toLog(){return`MonomerPlacer<${this.viewerId}>`}getMonomerLib(){return this.tableCol.temp[".mm.cellRenderer.overriddenLibrary"]??this.sysMonomerLib}reset(){this.propsProvider&&(this.props=this.propsProvider()),this._processedRows=o.BitSet.create(this.tableCol.length),this._monomerLengthList=null,this._monomerLengthMap={},this._monomerStructureMap={},this._cellBounds.clear(),super.reset(),this.invalidateGrid()}invalidateGrid(){this.gridCol&&this.gridCol.dart&&this.gridCol.grid?.invalidate()}getCellMonomerLengths(t,e){const n=this.seqHelper.getSeqHandler(this.tableCol);if(this.colWidth<e&&(this.colWidth=e,this.dirty=!0),this.dirty)try{this.reset()}catch(t){const[e,n]=(0,Je.AP)(t);this.logger.error(e,void 0,n)}const r=n.isMsa()?this.getCellMonomerLengthsForSeqMsa():this.getCellMonomerLengthsForSeq(t);return[r,this.getSummedMonomerLengths(r)]}getSummedMonomerLengths(t){const e=new Array(t.length+1);e[0]=this.padding;for(let n=1;n<e.length;n++)e[n]=e[n-1]+t[n-1];let n=e[0];for(let t=1;t<e.length;t++)e[t]?n=e[t]:e[t]=n;return e}getCellMonomerLengthsForSeqValue(t,e){const n=this.seqHelper.getSeqHandler(this.tableCol),r=this.props.separatorWidth+1*this.props.fontCharWidth,o=this.positionShift,i=Math.ceil(e/r)+o,s=n.splitter(t),a=Math.min(i,s.length),l=new Array(a-o);let c=0;for(let t=o;t<a;++t){const r=s.getOriginal(t),i=this.props.monomerToShort(r,this.monomerLengthLimit),a=(n.isSeparator()?this.separatorWidth:this.props.separatorWidth)+i.length*this.props.fontCharWidth;if(l[t-o]=a,c+=a,c>e)break}return l}getCellMonomerLengthsForSeq(t){this.toLog(),null==this._monomerLengthList&&(this._monomerLengthList=new Array(this.tableCol.length).fill(null));const e=this.positionShift,n=this.seqHelper.getSeqHandler(this.tableCol),r=this.props.separatorWidth+1*this.props.fontCharWidth,o=Math.ceil(this.colWidth/r)+e,i=n.getSplitted(t),s=Math.min(o,i.length);let a=this._monomerLengthList[t];if(null==a||a.length!=s-e){a=this._monomerLengthList[t]=new Array(i.length);let r=0;for(let t=e;t<s;++t){const o=i.getOriginal(t),s=this.props.monomerToShort(o,this.monomerLengthLimit),l=(n.isSeparator()?this.separatorWidth:this.props.separatorWidth)+s.length*this.props.fontCharWidth;if(a[t-e]=l,r+=l,r>this.colWidth)break}}return a}getCellMonomerLengthsForSeqMsa(){var t;this.toLog(),null==this._monomerLengthList&&(this._monomerLengthList=new Array(1).fill(null)),(t=this._monomerLengthList)[0]??(t[0]=new Array(0));const e=this._monomerLengthList[0],{startIdx:n,endIdx:r}=(()=>{try{const t=this.gridCol&&this.gridCol.dart?this.gridCol.grid:null;return t&&t.dart?{startIdx:Math.max(Math.floor((t?.vertScroll.min??0)-10),0),endIdx:Math.min(Math.ceil((t?.vertScroll.max??0)+10),this.tableCol.length)}:{startIdx:0,endIdx:Math.min(this.tableCol.length,10)}}catch(t){return{startIdx:0,endIdx:Math.min(this.tableCol.length,10)}}})(),o=this.props.separatorWidth+1*this.props.fontCharWidth,i=this.positionShift,s=Math.ceil(this.colWidth/o)+i;for(let t=n;t<r;t++){if(this._processedRows.get(t)&&s<=this._processedMaxVisibleSeqLength)continue;const n=this.seqHelper.getSeqHandler(this.tableCol).getSplitted(t,s),r=Math.min(s,n.length);r-i>e.length&&e.push(...new Array(r-i-e.length).fill(o));let a=0;for(let t=i;t<r;++t){const r=n.getOriginal(t),o=this.props.monomerToShort(r,this.monomerLengthLimit),s=this.props.separatorWidth+o.length*this.props.fontCharWidth;if(e[t-i]=Math.max(e[t-i]??0,s),a+=s,a>=this.colWidth)break}this._processedMaxVisibleSeqLength=Math.max(this._processedMaxVisibleSeqLength,s),this._processedRows.set(t,!0)}return e}getPosition(t,e,n,r){const[o,i]=this.getCellMonomerLengths(t,n);return 0===this.seqHelper.getSeqHandler(this.tableCol).getSplitted(t).length?null:function(t,e,n){if((n??0)>0&&e<(t[0]??0)+n)return-1;e-=n??0;let r,o=100,i=0,s=t.length-1;for(;i<=s;){if(r=Math.floor((s+i)/2),t[r]<=e&&e<t[r+1])return r;if(e<t[r]?s=r-1:i=r+1,--o<=0)throw new Error(`Get position for pointer x = ${e} searching has not converged on ${JSON.stringify(t)}. `)}return null}(i,e,r)}setMonomerLengthLimit(t){this.monomerLengthLimit!=t&&(this.monomerLengthLimit=t,this.dirty=!0)}setSeparatorWidth(t){this.separatorWidth!=t&&(this.props.separatorWidth=t,this.dirty=!0)}get positionShift(){const t=Number.parseInt(this.tableCol?.tags[Oe.gp.positionShift]??"0")??0;return isNaN(t)?0:Math.max(t,0)}render(t,e,n,r,i,s,a){const l=s.grid?.dart&&s.grid?.canvas===t.canvas;if(!this.seqHelper)return;const c=this.tableCol,u=this.positionShift;t.save();try{const a=this.seqHelper.getSeqHandler(c);let h=this.monomerLengthLimit;if(vr.maxMonomerLength in c.tags){const t=parseInt(c.getTag(vr.maxMonomerLength));h=!isNaN(t)&&t?t:50}if(".mm.cellRenderer.maxMonomerLength"in c.temp){const t=c.temp[".mm.cellRenderer.maxMonomerLength"],e="number"==typeof t?t:parseInt(t);h=!isNaN(e)&&e?e:50}if("1"===c.temp[".mm.cellRenderer.settingsChanged"]||this.monomerLengthLimit!=h){let t=0;const e=8;t=c.temp[".mm.cellRenderer.gapLength"]??t,this.setMonomerLengthLimit(h),this.setSeparatorWidth(a.isMsa()?e:t),c.temp[".mm.cellRenderer.settingsChanged"]="0",this.dirty=!0}const d=s.cell.rowIndex,p=s.cell.value;l&&(r=function(t,e,n,r,o){return t?Math.max(Math.min(t.canvas.width/o-n,r)):Math.max(e.canvas.width/o-n,0)}(s.grid,t,e,r,window.devicePixelRatio)),t.beginPath(),t.rect(e,n,r,i),t.clip(),t.font=this.props?.font??"12px monospace",t.textBaseline="top";const f=c.meta.units,m=c.getTag(Oe.gp.aligned),g=c.getTag(Oe.gp.separator)??"",y=l?a.getSplitted(d):a.splitter(p);let b=xr.classic;m?.includes("MSA")&&f===Oe.Hi.SEPARATOR&&(b=xr.MSA);const v=c.temp["reference-sequence"],C=this.tableCol.temp["current-word"],x=(()=>{const t=(0,a.splitter)(null!=v&&""!==v?v:C??"");return tn().count(0).take(t.length).slice(u).map((e=>t.getCanonical(e))).toArray()})(),w=Number.parseInt(c.getTag(Oe.gp.selectedPosition)??"-200"),A=this.shouldUseMultilineRendering(c),T=this.getAnnotationRenderer();if(A){const l=[],d=this.calculateMultiLineLayoutDynamic(t,r,i,y,u,h);let p=n+this.padding;1===d.lineLayouts.length&&(p=n+(i-d.lineHeight)/2);for(const r of d.lineLayouts){const i=p+r.lineIdx*d.lineHeight;for(const h of r.elements){const p=e+h.x,f=h,m=f.posIdx,g=y.getCanonical(m);let b=Pr;const v=this.getMonomerLib();v&&(b=v.getMonomerTextColor(a.defaultBiotype,g));let C=0;if(s.tableRowIndex!==c.dataFrame.currentRowIdx&&x.length>0){const t=m-u;t>=0&&t<x.length&&g===x[t]&&(C=.7)}l.push({lineIdx:r.lineIdx,monomerIdx:m-u,bounds:new o.Rect(h.x,i-n,h.width,d.lineHeight),sequencePosition:m}),T&&T.drawPositionBackground(t,p,i,h.width+2,d.lineHeight,m,s.tableRowIndex),Ar(t,f.om,p,i,h.width,d.lineHeight,{color:b,isMultiLineContext:!0,transparencyRate:C,selectedPosition:isNaN(w)||w<1?void 0:w,wordIdx:m})}}null!==s.tableRowIndex&&this._cellBounds.set(s.tableRowIndex,l)}else{this._leftThreeDotsPadding=this.shouldRenderShiftedThreeDots(u)?t.measureText("...").width:0;let[,o]=this.getCellMonomerLengths(s.tableRowIndex,r);l||(o=this.getSummedMonomerLengths(this.getCellMonomerLengthsForSeqValue(p,r)));const c=this.props.separatorWidth+1*this.props.fontCharWidth,d=Math.min(y.length,Math.ceil(r/c)+u);let f;if(T){const e=t.measureText("M"),r=e.fontBoundingBoxAscent+e.fontBoundingBoxDescent;f=n+(i/2-r/2+1)+r}for(let l=u;l<d;++l){const c=l<y.length?y.getOriginal(l):a.defaultGapOriginal,d=l<y.length?y.getCanonical(l):a.defaultGapOriginal;let p=Pr;this.getMonomerLib()&&(p=this.getMonomerLib().getMonomerTextColor(a.defaultBiotype,d));const m=l===y.length-1,v=(y?.graphInfo?.disjointSeqStarts?.indexOf(l+1)??0)>0?"|":g;if(T&&null!=s.tableRowIndex){const r=l-u,a=(o[r]??0)-(o[0]??0),c=(r+1<o.length?(o[r+1]??0)-(o[0]??0):a+this.props.fontCharWidth)-a;T.drawPositionBackground(t,e+this.padding+this._leftThreeDotsPadding+a,n,c,i,l,s.tableRowIndex,f)}const C={color:p,pivot:0,left:!0,transparencyRate:0,separator:v,last:m,drawStyle:b,maxWord:o,wordIdx:l-u,gridCell:s,referenceSequence:x,maxLengthOfMonomer:h,monomerTextSizeMap:this._monomerLengthMap,logger:this.logger,selectedPosition:isNaN(w)||w<1?void 0:w-u};Ar(t,c,e+this.padding+this._leftThreeDotsPadding,n,r,i,C)}if(this.shouldRenderShiftedThreeDots(u)){const a={color:Pr,pivot:0,left:!0,transparencyRate:0,separator:g,last:!1,drawStyle:b,maxWord:o,wordIdx:0,gridCell:s,maxLengthOfMonomer:h,monomerTextSizeMap:this._monomerLengthMap,logger:this.logger};Ar(t,"...",e+this.padding,n,r,i,a)}}}catch(t){const[e,n]=(0,Je.AP)(t);this.logger.error(e,void 0,n),this.errors.push(t)}finally{t.restore()}}shouldRenderShiftedThreeDots(t){return t>0&&(!this.gridCol||!this.gridCol.dart||!this.gridCol.grid||!this.gridCol.grid.dart||(this.gridCol.grid.props.colHeaderHeight??0)<=50)}onMouseMove(t,e){const n=`${this.toLog()}.onMouseMove()`;if(!this.seqHelper||null==t.tableRowIndex)return;const r=this.positionShift,o=t.bounds,i=e.offsetX-t.gridColumn.left+(t.gridColumn.left-o.x),s=e.offsetY-o.y;this.gridCol?.grid?.canvas&&(this.gridCol.grid.canvas.style.cursor="default");let a=null;const l=this._cellBounds.get(t.tableRowIndex);if(l){for(const t of l)if(t.bounds.contains(i,s)){a=t.monomerIdx;break}}else{const e=this.shouldRenderShiftedThreeDots(r)&&(this._leftThreeDotsPadding??0)>0?this._leftThreeDotsPadding:0;a=this.getPosition(t.tableRowIndex,i,o.width,e)}this.logger.debug(`${n}, argsX: ${i}, argsY: ${s}, left: ${a}`);const c=this.seqHelper.getSeqHandler(this.tableCol),u=c.getSplitted(t.tableRowIndex);if(null!==a&&a>=0&&a+r<u.length){const n=c.alphabet??Oe.YI.UN,o={position:a,biotype:n===Oe.YI.RNA||n===Oe.YI.DNA?_r.o.NUCLEOTIDE:_r.o.AA,symbol:u.getCanonical(a+r)},i=[];let s=this._monomerStructureMap[o.symbol];if(!s){const t=this.getMonomerLib();s=this._monomerStructureMap[o.symbol]=t?t.getTooltip(o.biotype,o.symbol):P.divText("Monomer library is not available")}i.push(s);const l=this.getAnnotationRenderer();if(l){const e=l.getTooltipInfo(a+r,t.tableRowIndex);if(e.length>0){const t=document.createElement("hr");t.style.margin="4px 0",t.style.border="none",t.style.borderTop="1px solid #ccc",i.push(t);for(const t of e)i.push(P.divText(t,{style:{fontSize:"12px",marginBottom:"2px"}}))}}P.tooltip.show(P.divV(i),e.x+16,e.y+16),xn(t,o)}else-1===a?P.tooltip.show(P.divText(`${Math.min(r,u.length)} hidden monomers`),e.x+16,e.y+16):P.tooltip.hide(),xn(t,null)}}class Lr extends Mr{constructor(t,e,n,r){super(t,e,Yr.logger,n,(()=>{const t=r.getSeqHandler(e),{font:n,fontWidth:o}=Mr.getFontSettings(e);return{seqHandler:t,font:n,fontCharWidth:o,separatorWidth:11,monomerToShort:Oe.zS}}))}onMouseMove(t,e){super.onMouseMove(t,e)}}class Or extends dr.$G{static get notationName(){return"Harmonized Sequence"}static get implementsFromHelm(){return!1}static convertFromHelm(t,e){throw new Error("converting from helm not supported yet")}get defaultGapOriginal(){return""}constructor(t,e){super(),this.separator=t,this.helmHelper=e,this.separatorSplitter=(0,Oe.dh)(this.separator),this.splitter=this._splitter.bind(this)}setUnits(){}_splitter(t){const e=this.separatorSplitter(t);return new Rr(tn().count(0).take(e.length).map((t=>e.getOriginal(t))).toArray(),i.b9[i.Hi.SEPARATOR])}getHelm(t,e){return hr.s.fromSeparator(t,this.helmHelper).getHelm()}createCellRendererBack(t,e){const n=new Lr(t,e,4,this.helmHelper.seqHelper);return n.init().then((()=>{})),n}}class Rr extends s.Mu{getCanonical(t){if(this.isGap(t))return i._S;const e=this.getOriginal(t);let n=e;return e.startsWith("{")?n=e.slice(1):e.endsWith("}")?n=e.slice(0,-1):e.startsWith("(")?n=e.replace(/^\(.\d+\)/,""):e.endsWith(")")&&(n=e.replace(/\(\d+\)$/,"")),n}constructor(t,e){super(t,e)}}async function Dr(t){await Yr.initPromise;const e=window.innerWidth,n=window.innerHeight;try{let i;function s(){if(null==i)return;const t=L()(i.root).find("div.d4-dialog-contents").get(0),e=t.clientHeight,n={0:1},r=Object.values(n).reduce(((t,e)=>t+e),0),o=e-tn().count(0).take(t.children.length).filter((t=>!(t in n))).map((e=>t.children[e])).filter((t=>t instanceof HTMLElement)).map((t=>t.offsetHeight)).reduce(((t,e)=>t+e),0)-38;for(const e of tn().count(0).take(t.children.length))if(e in n){const i=t.children[e],s=o*n[e]/r;i.style.height=`${s}px`}}i=await async function(t,e){const n="ST: PT: HelmDialog()";let i;const s=[];let c=or.aK.Single;const u=()=>{for(const t of s)t.unsubscribe();i.placeholders.detach()};try{const h=await(0,l.pj)(),d=h.getMonomerLib(),p=await(0,Xe.Q)(),f=await(0,Qe.b2)(),m=f.buildMonomersFuncsFromLib(d),g=t=>{let e,n,r=null;if(t&&t.rowIndex>=0&&t?.column.semType==o.SEMTYPE.MACROMOLECULE){if(e=p.getSeqHandler(t.column).getValue(t.rowIndex),t.column.temp?.[a.notationProvider]&&!(t.column.temp[a.notationProvider]instanceof Or)){let n;r=t.column.temp[a.notationProvider].getHelm(e.value,{}),o.DataFrame.fromColumns([n=o.Column.fromList(o.COLUMN_TYPE.STRING,"seq",[r])]),n.semType=o.SEMTYPE.MACROMOLECULE,n.meta.units=Oe.Hi.HELM,e=p.getSeqHandler(n).getValue(0)}n=e.tags["polytool-data-role"]??"macromolecule"}else{const t=o.Column.fromList(o.COLUMN_TYPE.STRING,"seq",[ir.d]);t.semType=o.SEMTYPE.MACROMOLECULE,o.DataFrame.fromColumns([t]),t.meta.units=Oe.Hi.HELM,e=p.getSeqHandler(t).getValue(0),n="macromolecule"}return[e,n]};let y,b,[v,C]=g(t),x=null;const w=P.divText("",{style:{color:"red"}}),A=P.divText("",{style:{fontSize:"11px",color:"var(--grey-4)",marginTop:"2px",marginLeft:"4px",whiteSpace:"nowrap"}});i={macromolecule:f.createHelmInput("Macromolecule",{editable:!1,editorOptions:{drawOptions:{monomerNumbering:1,getMonomer:(e,n)=>{const r=e;if("ATOM"!==r.T)return m.getMonomer(e,n);try{if(v.isDna()||v.isRna()){const t=v.getSplittedWithSugarsAndPhosphates().getCanonical(r.bio.continuousId-1);return m.getMonomer(r.bio.type,t)}if(t?.column?.temp?.[a.notationProvider]instanceof Or){const t=v.getSplitted().getCanonical(r.bio.continuousId-1);return m.getMonomer(r.bio.type,t)}{const t=r.elem;return m.getMonomer(r.bio.type,t)}}catch(t){return m.getMonomer(e,n)}}}}}),placeholders:await sr.create("Placeholders",{showAddNewRowIcon:!0,showRemoveRowIcon:!0,showRowHeader:!1,showCellTooltip:!1}),enumeratorType:P.input.choice("Enumerator type",{value:c,items:Object.values(or.aK)}),placeholdersBreadth:await ur.create("Breadth",{showAddNewRowIcon:!0,showRemoveRowIcon:!0,showRowHeader:!1,showCellTooltip:!1}),keepOriginal:P.input.bool("Keep original",{value:!1}),toAtomicLevel:P.input.bool("To atomic level",{value:!1,onValueChanged:(t,e)=>{I()}}),generateHelm:P.input.bool(_n,{value:!0}),chiralityEngine:P.input.bool(Pn,{value:!1}),highlightMonomers:P.input.bool(Mn,{value:!1}),rules:{header:P.inlineText([Rn]),form:await(b=new An._v(An.MU,An.yy,".json",{onValueChanged:t=>{y=t}})).getForm()},trivialName:P.input.string("Trivial name",{value:"",onValueChanged:t=>{const e=t?.trim();x=e?{value:e,colName:"Trivial name"}:null}}),appendToTable:P.input.table("Append to table",{items:r.shell.tables,nullable:!0})};const T=()=>{const t=Dn[i.enumeratorType.value]??"";P.tooltip.bind(i.enumeratorType.input,t)};if(T(),t?.dataFrame){const e=P.iconFA("columns",(e=>{o.Menu.popup().singleColumnSelector(t.dataFrame,{columnFilter:e=>e.type===o.COLUMN_TYPE.STRING&&e!==t.column,onChange:(e,n,r)=>{r&&(i.trivialName.value=n.get(t.rowIndex)??"")}}).show({x:e.clientX,y:e.clientY})}),"Pick trivial name from a column");i.trivialName.addOptions(e)}i.trivialName.root.style.maxWidth="450px",i.placeholders.onMonomerCellEdit=async(t,e)=>{const n=i.macromolecule.molValue;if(t<0||t>=n.atoms.length)return null;const r=n.atoms[t].biotype(),o=(0,nr.Y)(r);return cr(d,o,e,h)},i.placeholdersBreadth.onMonomerCellEdit=async(t,e,n)=>{const r=i.macromolecule.molValue;if(t<0||t>=r.atoms.length)return null;const o=r.atoms[t].biotype(),s=(0,nr.Y)(o);return cr(d,s,n,h)};let E=null;i.placeholders.addValidator((t=>{E=null;const e=[];setTimeout((()=>{_()}),100);try{if(i.enumeratorType.value===or.aK.Parallel){const t=i.placeholders.placeholdersValue.filter((t=>t.monomers.length>0));if(t.length>1){const e=t[0].monomers.length,n=t.find((t=>t.monomers.length!==e));n&&(E=`Parallel mode requires all positions to have the same number of monomers. Position ${t[0].position+1} has ${e}, but position ${n.position+1} has ${n.monomers.length}.`)}}if("macromolecule"!==C)return null;const t=[];for(const n of i.placeholders.placeholdersValue){const r=n.position;if(null==r)continue;if(r>=i.macromolecule.molValue.atoms.length){e.push(`There is no monomer at position ${r+1}.`);continue}const o=i.macromolecule.molValue.atoms[r];if(o){const e=o.biotype(),r=(0,nr.Y)(e);for(const e of n.monomers){const n=d.getMonomer(r,e);n&&n.lib||t.push({polymerType:r,symbol:e})}}}const n={};for(const e of t){let t=n[e.polymerType];t||(t=n[e.polymerType]=[]),t.push(e.symbol)}const r=Object.entries(n).map((([t,e])=>`${t}: ${e.join(", ")}`)).join("\n");Object.keys(r).length>0&&e.push(`Placeholders contain missed monomers: ${r}`),E=e.length>0?e.join("\n"):E}catch(t){const[e,n]=Sn(t,!1);E=e}return setTimeout((()=>{_()}),0),E})),i.enumeratorType.onChanged.subscribe((t=>{c=i.enumeratorType.value,T(),i.placeholders.fireChanged()})),s.push(i.macromolecule.onMouseMove.subscribe((t=>{try{Yr.logger.debug(`${n}, placeholdersInput.onMouseMove()`);const e=t.offsetX,r=t.offsetY,o=i.macromolecule.molValue,s=f.getHoveredAtom(e,r,o,i.macromolecule.root.clientHeight);if(s){const e=s._parent.atoms.indexOf(s),n=i.placeholders.placeholdersValue.find((t=>t.position===e))?.monomers;if(n){const e=P.divText(n.join(", "));i.macromolecule.showTooltip(e,s),t.preventDefault(),t.stopPropagation()}}}catch(t){Sn(t,!1)}}))),s.push(i.macromolecule.onClick.subscribe((t=>{try{Yr.logger.debug(`${n}, placeholdersInput.onClick()`);const e=t.offsetX,r=t.offsetY,o=i.macromolecule.molValue,s=f.getHoveredAtom(e,r,o,i.macromolecule.root.clientHeight);if(s){const t=s._parent.atoms.indexOf(s);i.placeholders.addPosition(t,"")}}catch(t){Sn(t)}}))),s.push(i.placeholders.onChanged.subscribe((()=>{S(),M()}))),s.push(i.placeholdersBreadth.onChanged.subscribe((()=>{M()}))),s.push(i.keepOriginal.onChanged.subscribe((()=>{M()}))),s.push(P.onSizeChanged(i.placeholders.root).subscribe((()=>{e&&e()}))),s.push(r.events.onCurrentCellChanged.subscribe((()=>{const t=r.shell.tv.dataFrame.currentCell;t.column.semType===o.SEMTYPE.MACROMOLECULE&&([v,C]=g(t),O(v,C,t))}))),i.macromolecule.root.style.setProperty("min-width","250px","important");const S=()=>{const t=new Set(i.placeholders.placeholdersValue.map((t=>t.position))),e=i.macromolecule.molValue;for(let n=0;n<e.atoms.length;n++)e.atoms[n].highlighted=t.has(n);i.macromolecule.redraw()},I=()=>{i.toAtomicLevel.value&&"template"===C?(i.generateHelm.root.style.removeProperty("display"),i.chiralityEngine.root.style.removeProperty("display"),i.highlightMonomers.root.style.removeProperty("display"),i.rules.header.style.removeProperty("display"),i.rules.form.style.removeProperty("display")):(i.generateHelm.root.style.display=i.chiralityEngine.root.style.display=i.highlightMonomers.root.style.display="none",i.rules.header.style.display=i.rules.form.style.display="none"),e&&e()};let N=null;const _=()=>{const t=E,e=w;t?(e.innerText=t,e.style.removeProperty("display"),N&&(N.disabled=!0)):(e.innerText="",e.style.setProperty("display","none"),N&&(N.disabled=!1))},M=()=>{try{const t=i.placeholders.placeholdersValue.filter((t=>t.monomers.length>0)),e=i.placeholdersBreadth.placeholdersBreadthValue.filter((t=>t.monomers.length>0&&null!=t.start&&null!=t.end));let n=0;switch(i.enumeratorType.value){case or.aK.Single:n=t.reduce(((t,e)=>t+e.monomers.length),0);break;case or.aK.Parallel:t.length>0&&(n=t.every((e=>e.monomers.length===t[0].monomers.length))?t[0].monomers.length:0);break;case or.aK.Matrix:n=t.length>0?t.reduce(((t,e)=>t*e.monomers.length),1):0}let r=0;e.length>0&&(r=e.reduce(((t,e)=>{const n=Math.abs(e.end-e.start)+1;return t*(e.monomers.length*n)}),1));let o=n+r;i.keepOriginal.value&&o>0&&(o+=1),A.textContent=o>0?`${o} sequence${1!==o?"s":""} will be generated`:""}catch(t){A.textContent=""}},L=t=>{e&&e()},O=(t,e,n)=>{i.macromolecule.value=t;const r=n?.dataFrame;L(r)};O(v,C,t),I(),M();const R=async()=>{try{const e=i.macromolecule.stringValue;if(void 0===e||""===e)r.shell.warning("PolyTool: no molecule was provided");else{if(0===Object.keys(i.placeholders.placeholdersValue).length&&0===Object.keys(i.placeholdersBreadth.placeholdersBreadthValue).length)return void r.shell.warning(`${On}: placeholders are empty`);await(0,Qe.b2)();const n=i.placeholders.placeholdersValue,o=i.enumeratorType.value;if(o===or.aK.Parallel){const t=n.filter((t=>t.monomers.length>0));if(t.length>1){const e=t[0].monomers.length;if(t.some((t=>t.monomers.length!==e)))return void r.shell.warning("Parallel mode requires all positions to have the same number of monomers")}}const s={placeholders:n,type:o,breadthPlaceholders:i.placeholdersBreadth.placeholdersBreadthValue,keepOriginal:i.keepOriginal.value};if(t?.column?.temp?.[a.notationProvider]&&!(t.column.temp[a.notationProvider]instanceof Or)){const e=t.column.temp[a.notationProvider];if(e.constructor.implementsFromHelm){const t=e.constructor;s.fromHelmNotation={notationName:t.notationName,convert:e=>t.convertFromHelm(e,{})}}}const l=i.toAtomicLevel.value,c=await $r(e,C,x,s,!!l&&{generateHelm:i.generateHelm.value,chiralityEngine:i.chiralityEngine.value,highlightMonomers:i.highlightMonomers.value,rules:await b.getActive()},f),u=i.appendToTable.value;u?(u.append(c,!0),u.meta.detectSemanticTypes()):r.shell.addTableView(c)}}catch(t){Sn(t)}},D=P.dialog({title:On,showFooter:!0}).add(i.macromolecule.root).add(P.divH([P.divV([i.placeholders.root,P.divH([i.enumeratorType.root,A],{style:{alignItems:"center"}})],{style:{width:"50%"}}),P.divV([i.placeholdersBreadth.root],{style:{width:"50%"}})],{style:{width:"100%"}})).add(P.divH([P.divV([i.trivialName.root,i.keepOriginal.root,i.appendToTable.root],{style:{width:"50%"}}),P.divV([P.divH([i.toAtomicLevel.root,i.generateHelm.root]),P.divH([i.chiralityEngine.root,i.highlightMonomers.root]),i.rules.header,i.rules.form],{style:{width:"50%"}})],{style:{width:"100%"}})).add(w).onOK((()=>{if(E)return _(),void r.shell.warning("Please fix validation errors before running enumeration");R()}));return N=D.getButton("OK"),s.push(D.onClose.subscribe((()=>{u()}))),D.history((()=>({description:`${i.enumeratorType.value} ${i.placeholders.placeholdersValue?.map((t=>(t.position?.toString()??"")+": "+t.monomers?.join(", "))).join("; ")}`,placeholders:i.placeholders.stringValue,enumeratorType:i.enumeratorType.value,placeholdersBreadth:i.placeholdersBreadth.stringValue,trivialName:i.trivialName.value,keepOriginal:i.keepOriginal.value,toAtomicLevel:i.toAtomicLevel.value,generateHelm:i.generateHelm.value,chiralityEngine:i.chiralityEngine.value,highlightMonomers:i.highlightMonomers.value,rules:y})),(t=>{i.enumeratorType.value=t.enumeratorType??or.aK.Single,i.placeholders.stringValue=t.placeholders,i.placeholdersBreadth.stringValue=t.placeholdersBreadth,t.trivialName&&(i.trivialName.value=t.trivialName),i.keepOriginal.value=t.keepOriginal??!1,i.toAtomicLevel.value=t.toAtomicLevel??!0,i.generateHelm.value=t.generateHelm??!0,i.chiralityEngine.value=t.chiralityEngine??!1,i.highlightMonomers.value=t.highlightMonomers??!1,b.setActive(t.rules),setTimeout((()=>{i.placeholders.invalidateGrid(),i.placeholdersBreadth.invalidateGrid(),M()}),100)})),D}catch(t){throw u(),t}}(t,s);let c=!0;P.onSizeChanged(i.root).subscribe((()=>{if(c){const t=.7*e,r=.7*n;i.root.style.width=`${Math.min(e,t)}px`,i.root.style.height=`${Math.min(n,r)}px`,i.root.style.left=`${Math.floor((e-i.root.offsetWidth)/2)}px`,i.root.style.top=`${Math.floor((n-i.root.offsetHeight)/2)}px`,c=!1}s()})),s(),Yr.logger.debug("PolyToolEnumerateHelmUI: dialog before show"),i.show({width:Math.max(350,.7*e),resizable:!0}),Yr.logger.debug("PolyToolEnumerateHelmUI: dialog after show")}catch(u){const[h,d]=(0,Je.AP)(u);Yr.logger.error(h,void 0,d)}}async function $r(t,e,n,i,s,a){const c=o.TaskBarProgressIndicator.create("PolyTool enumerating...");try{const c=await(0,l.pj)(),u=await(0,wn.j)(),h=c.getMonomerLib(),d=(0,ir.o)(t,n?.value??"",i);let p;switch(e){case"macromolecule":p=o.Column.fromType(o.COLUMN_TYPE.STRING,"Enumerated",d.length).init((t=>d[t][0]));break;case"template":{const t=new Array(d.length);for(let e=0;e<d.length;e++){const n=d[e][0],r=hr.s.fromHelm(n,a);t[e]=r.getNotation()}p=o.Column.fromList(o.COLUMN_TYPE.STRING,"Enumerated",t),p.semType=o.SEMTYPE.MACROMOLECULE,p.setTag("polytool-data-role","template"),Qr.applyNotationProviderForCyclized(p,"-");break}}const f=o.DataFrame.fromColumns([p]);if("macromolecule"===e&&i.fromHelmNotation){const t=o.Column.fromType(o.COLUMN_TYPE.STRING,`${i.fromHelmNotation.notationName}(${p.name})`,f.rowCount).init((t=>p.isNone(t)?null:i.fromHelmNotation.convert(p.get(t))));f.columns.add(t)}if(await r.data.detectSemanticTypes(f),"template"==e&&Qr.applyNotationProviderForCyclized(p,"-"),s){let t;if("macromolecule"===e){t=p;const e=await a.seqHelper.helmToAtomicLevel(t,s.chiralityEngine,s.highlightMonomers);f.columns.add(e.molCol,!1);const n=e.molCol;await async function(t,e,n,r,o,i=!1){const s=r.getSeqHandler(t),a=s.alphabet==Oe.YI.RNA||s.alphabet==Oe.YI.DNA,l=s.isHelm()&&a,c=!s.isHelm()&&a,u=t=>null==t?null:l?i?t:Math.floor(t/3):c&&i?3*t+1:t,h=i?await r.getHelmToMolfileConverter(n):null,d=new dn({max:100});function p(t,e){const s=t.get(e);if(null==s)return null;let a=d.get(s);return a||d.set(s,a=function(t,e){const s=r.getSeqHandler(t);if(i){const t=s.getHelm(e);return r.helmToAtomicLevelSingle(t,h,!1,!1).monomers}{const t=s.getSplitted(e),r=s.defaultBiotype,i=tn().count(0).take(t.length).map((e=>({position:e,symbol:t.getCanonical(e),biotype:r}))).toArray(),a=s.alphabet,l=a==Oe.YI.RNA||a==Oe.YI.DNA?"RNA":"PEPTIDE",c=(0,gn.eM)([i],l,a,n,o);return(0,yn.gU)(i,c,a,l).monomers}}(t,e)),a}const f={targetCol:e,handler:(e,r,o)=>{const i=o.grid,s=e.tableRowIndex,a=e.gridRow,l=i.cell(o.name,a),c=pn();if(!c||c&&(c.dataFrameId!=t.dataFrame.id||c.gridRowIdx!=a||c.seqColName!=t.name||c.seqPosition!=r?.position)){if(c&&(fn(null),c.gridCell.render()),!r)return fn(null),!0;fn({gridCell:l,dataFrameId:t.dataFrame.id,gridRowIdx:a,seqColName:t.name,seqPosition:u(r?.position)??-1,getSubstruct:()=>{if(!r||"*"===r.symbol)return;const e=p(t,s);if(!e)return;const o=e.get(u(r?.position));return o?(0,bn.H)([o],n):{atoms:[],bonds:[],highlightAtomColors:[],highlightBondColors:[]}}}),l.render()}return!0},getSubstruct:r=>{if("true"!=e.getTag(".sequence-src-highlight-monomers"))return;if(null==r)return;if(!t.get(r))return;const o=p(t,r);return o?(0,bn.H)(o.values(),n):void 0}};return Cn(t.temp,f),mn(e.temp,f),f}(t,n,h,a.seqHelper,u,!0)}else"template"===e&&(t=(await Bn(p,s.generateHelm,!1,s.chiralityEngine,!1,s.rules))[0])}if(n){const t=o.Column.fromType(o.COLUMN_TYPE.STRING,n.colName,d.length).init((t=>d[t][1]));f.columns.add(t)}return f}finally{c.close()}}var Br,Fr=n(3151);class kr{constructor(t){this.rawLib=t}isValid(){return this.rawLib.every((t=>"object"==typeof t&&Object.values(In).every((e=>e in t&&"string"==typeof t[e]))))}getJsonMonomerLib(){const t=[];return this.rawLib.forEach((e=>{const n=this.prepareMonomer(e);t.push(n)})),t}prepareMonomer(t){const e={...Fr.pe};Object.entries(In).forEach((([n,r])=>{const o=t[r];e[n]=o}));let n="smiles";const r=t[In[n]],o=new Hr(r),i=o.getCappedSmiles();return e[n]=i,n="rgroups",e[n]=Gr.getRGroups(o.getNumberOfRGroups()),n="molfile",e[n]=new Vr(o.getSmilesWithRGroups()).getMolfile(),e}}class Hr{constructor(t){let e=0;this.smilesWithRGroups=t.replace(/\[R(\d+)\]/g,((t,n)=>(++e,`[${n}*]`))),this.numberOfRGroups=e}getSmilesWithRGroups(){return this.smilesWithRGroups}getCappedSmiles(){return this.capRGroups()}getNumberOfRGroups(){return this.numberOfRGroups}capRGroups(){let t=this.smilesWithRGroups.replace("[1*]","[H:1]");return t=t.replace("[2*]","[OH:2]"),t.replace("[3*]","[H:3]")}}class Gr{constructor(){}static getRGroups(t){return Nn.slice(0,t)}}class Vr{constructor(t){this.smilesWithRGroups=t}getMolfile(){let t=o.chem.convert(this.smilesWithRGroups,o.chem.Notation.Smiles,o.chem.Notation.MolBlock);return t=this.restoreRGPLine(t),t=this.fixRGroupSymbols(t),t}restoreRGPLine(t){return t.replace("M ISO","M RGP")}fixRGroupSymbols(t){return t.replace(/\bR\b/g,"R#")}}class Ur{constructor(t,e){this.fileName=t,this.fileContent=e,this.validateFileType();const n=o.DataFrame.fromCsv(this.fileContent),r=this.toJson(n);this.polyToolMonomerLib=new kr(r),this.validateContent()}async getJson(){return this.polyToolMonomerLib.getJsonMonomerLib()}toJson(t){return Array.from({length:t.rowCount},((e,n)=>t.columns.names().reduce(((e,r)=>(e[r]=t.get(r,n),e)),{})))}validateFileType(){if(!this.fileName.endsWith(".csv"))throw new Error(`File ${this.fileName} is not an CSV file`)}validateContent(){if(!this.polyToolMonomerLib.isValid())throw new Error("Invalid format of CSV monomer lib")}}!function(t){t.table="table",t.seqCol="seqCol",t.generateHelm="generateHelm",t.chiralityEngine="chiralityEngine",t.rules="rules"}(Br||(Br={}));class jr{constructor(t){this.call=t,this.ruleInputs=new An._v(An.MU,An.yy,".json")}async initInputs(){const t=t=>this.call.inputParams[t],e=await this.ruleInputs.getForm();this.inputs={table:(()=>{const e=t(Br.table);return P.input.table(e.property.caption,{value:e.value})})(),seqCol:(()=>{const e=t(Br.seqCol);return P.input.column(e.property.caption,{value:e.value,table:e.value.dataFrame})})(),generateHelm:P.input.forProperty(t(Br.generateHelm).property),chiralityEngine:P.input.forProperty(t(Br.chiralityEngine).property),rules:{header:P.inlineText([Rn]),form:e}}}static async create(t){const e=new jr(t);return await e.initInputs(),e}async getParams(){return{table:this.inputs.table.value,seqCol:this.inputs.seqCol.value,generateHelm:this.inputs.generateHelm.value,chiralityEngine:this.inputs.chiralityEngine.value,rules:await this.ruleInputs.getActive()}}async showDialog(){const t=P.div([this.inputs.table,this.inputs.seqCol,this.inputs.generateHelm,this.inputs.chiralityEngine,this.inputs.rules.header,this.inputs.rules.form],{style:{minWidth:"320px"}});return new Promise(((e,n)=>{P.dialog({title:Ln}).add(t).onOK((async()=>{const t=await this.getParams(),n=(await this.call.func.prepare(t).call(!0)).getOutputParamValue();e(n)})).onCancel((()=>{n(new Error("Cancelled by user"))})).show()}))}widget(){throw new Error("not implemented")}}var qr=function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s},Wr=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},zr=function(t,e){return function(n,r){e(n,r,t)}};r.decorators||(r.decorators={}),["func","init","param","panel","editor","demo","app","appTreeBrowser","fileHandler","fileExporter","model","viewer","filter","cellRenderer","autostart","dashboard","folderViewer","semTypeDetector","packageSettingsEditor","functionAnalysis","converter","fileViewer","model","treeBrowser","polyfill"].forEach((t=>{r.decorators[t]||(r.decorators[t]=function(t){return function(t,e,n){}})}));const Yr=new R({debug:!0});let Kr=null;class Qr{static async oligoToolkitApp(){await Yr.initLibData();const t=await async function(t){const e={"Mermadesynthesis:merMadeSynthesis":{tabName:"SYNTHESIZE",parameters:Ke(t)}},n={};for(const[t,o]of Object.entries(e)){let e;try{e=await r.functions.call(t,o.parameters);const i=new ze(o.tabName,e);i.initView(),n[o.tabName]=()=>i.getView()}catch(e){console.warn(`Plugin ${t} not loaded, reason:`,e);continue}}return n}(Yr);if(!t)throw new Error("External app view factories not loaded");const e=new Ye(t,Yr);return await e.getAppView()}static async init(){return null===Kr&&Yr.startInit(Kr=async function(){const[t]=await Promise.all([(0,Qe.b2)()]);Yr.completeInit(t)}()),Kr}static async oligoTranslatorApp(){return await Jr("Oligo Translator")}static async oligoPatternApp(){return await Jr("Oligo Pattern")}static async oligoStructureApp(){return await Jr("Oligo Structure")}static async getTranslationHelper(){return await Yr.initLibData(),Yr}static getCodeToWeightsMap(){const t=Yr.monomerLibWrapper.getCodesToWeightsMap();return Object.fromEntries(t)}static validateSequence(t){const e=Yr.createSequenceValidator(t),n=Yr.createFormatDetector(t).getFormat();return null!==n&&e.isValidSequence(n)}static getMolfileFromGcrsSequence(t,e){return new Ae(t,e,"GCRS").convert()}static linkStrands(t){return Te(t,!0)}static async demoTranslateSequence(){await async function(){await b((async()=>{const t=await Qr.oligoTranslatorApp();r.shell.addView(t)}))}()}static async demoOligoPattern(){await async function(){await b((async()=>{const t=await Qr.oligoPatternApp();r.shell.addView(t)}))}()}static async demoOligoStructure(){await async function(){await b((async()=>{const t=await Qr.oligoStructureApp();r.shell.addView(t),["Afcgacsu","Afcgacsu","Afcgacsu"].forEach((async(t,e)=>{await async function(t,e){await o.delay(500);const n=document.querySelectorAll(".st-colored-text-input > textarea")[t];n.value=e;const r=new Event("input");n.dispatchEvent(r)}(e,t)}))}))}()}static async translateOligonucleotideSequence(t,e,n){return await Yr.initLibData(),Yr.createFormatConverter(t,e).convertTo(n)}static async polyToolConvertTopMenu(){await async function(){await Yr.initPromise;let t=null;try{t=await async function(){const t=[],e=()=>{for(const e of t)e.unsubscribe()};try{let n;const i=r.shell.t.columns.bySemTypeAll(o.SEMTYPE.MACROMOLECULE),s=i.filter((t=>Yr.seqHelper.getSeqHandler(t).notation===Oe.Hi.CUSTOM));if(!n){if(i.length<1)throw new Error("No dataframe with macromolecule columns open");if(s.length<1){const t=o.Func.find({package:"Bio",name:"toAtomicLevel"})[0];return t?(t.prepare().edit(),null):(r.shell.warning("Polytool requires a macromolecule column with custom notation. \n\nUse Top menu | Bio | Transform | To Atomic Level."),null)}n=i[0]}const a=P.input.column("Column",{table:n.dataFrame,value:n,filter:t=>s.includes(t)}),l=P.input.bool(_n,{value:!0});P.tooltip.bind(l.root,"Add HELM column");const c=P.input.bool("Linearize",{value:!0});P.tooltip.bind(c.root,"Make representation linear if possible");const u=P.input.bool(Pn,{value:!0}),h=P.input.bool(Mn,{value:!0});let d;const p=new An._v(An.MU,An.yy,".json",{onValueChanged:t=>{d=t}}),f=P.inlineText([Rn]);P.tooltip.bind(f,"Add or specify rules to use");const m=await p.getForm(),g=P.divV([a,l,c,u,h,f,m]),y=async()=>{try{const t=await p.getActive();await Bn(a.value,l.value,c.value,u.value,h.value,t)}catch(t){Sn(t)}},b=P.dialog(Ln).add(g).onOK((()=>{y()}));return t.push(b.onClose.subscribe((()=>{e()}))),b.history((()=>({generateHelm:l.value,chiralityEngine:u.value,rules:d})),(t=>{l.value=t.generateHelm,u.value=t.chiralityEngine,p.setActive(t.rules)})),b}catch(t){throw e(),t}}(),t?.show()}catch(t){const[e,n]=(0,Je.AP)(t);r.shell.warning("To run PolyTool Conversion, open a dataframe with macromolecules"),Yr.logger.error(e,void 0,n)}}()}static async getPolyToolConvertEditor(t){const e=await jr.create(t);return await e.showDialog()}static async polyToolConvert2(t,e,n,r,o){return(await Bn(e,n,!1,r,!1,o))[0]}static async polyToolEnumerateHelmTopMenu(){await Dr(r.shell.tv?.dataFrame.currentCell)}static async polyToolEnumerateChemTopMenu(){tr()}static async chemEnumerateReactionsTopMenu(){tr()}static async polyToolColumnChoice(t,e){var n;(function(t){t.semType=o.SEMTYPE.MACROMOLECULE,t.setTag("aligned","SEQ"),t.setTag("alphabet",Oe.YI.PT)})(n=e),n.meta.units=Oe.Hi.SEPARATOR,n.setTag("separator","-"),await r.data.detectSemanticTypes(t)}static async createMonomerLibraryForPolyTool(t){const e=await t.readAsString(),n=new Ur(t.fileName,e),r=await n.getJson(),i=t.fileName.replace(/\.csv$/,".json"),s=JSON.stringify(r,null,2);o.Utils.download(i,s)}static async ptEnumeratorHelmApp(){await Dr()}static async ptEnumeratorChemApp(){return await async function(){await Yr.initPromise;try{const t=er(await(0,wn.j)(),null),e=P.bigButton("Enumerate",(async()=>{await t.execute()}));t.bindActionButton(e);const n=o.View.create();return n.name=kn,n.box=!0,n.root.appendChild(P.divV([t.root,P.div([e],{style:{padding:"8px 4px 0"}})],{style:{height:"100%",width:"100%",padding:"8px"}})),n}catch(t){return Sn(t),null}}()}static async getPtHelmEnumeratorDialog(t){return Dr(t)}static async getPtChemEnumeratorDialog(t){return tr(t)}static async enumerateSingleHelmSequence(t,e,n,r=!1){return await $r(t,"macromolecule",null,{type:or.aK.Single,placeholders:e.map(((t,e)=>({position:t,monomers:n[e]})))},!!r&&{generateHelm:!0,chiralityEngine:!0,highlightMonomers:!1,rules:[]},Yr.helmHelper)}static async enumerateSingleHelmSequenceWithNaturalAAs(t,e=!1){const n=(0,Oe.qp)(t).length,r=Array.from({length:n},((t,e)=>e)),o=r.map((t=>["A","C","D","E","F","G","H","I","K","L","M","N","P","Q","R","S","T","V","W","Y"]));return await Qr.enumerateSingleHelmSequence(t,r,o,e)}static async getPolyToolCombineDialog(){!async function(){const t=[],e=P.divV([]),n=i=>{const s=(()=>{const t=P.divH([]),e=P.input.table("Table",{value:void 0,tooltipText:"Table with sequences"}),n=P.input.choice("Column",{items:[],value:void 0,tooltipText:"Sequence column"});return e.onChanged.subscribe((async()=>{const t=e.value;if(!t)return n.items=[],void(n.value=null);await t.meta.detectSemanticTypes(),await r.data.detectSemanticTypes(t);const i=Array.from(t.columns.categorical),s=i.map((t=>t.name));n.items=s,n.value=i.find((t=>t.semType===o.SEMTYPE.MACROMOLECULE))?.name??s.find((t=>{const e=t.toLowerCase();return e.includes("seq")||e.includes("pep")}))??s[0]})),t.appendChild(e.root),t.appendChild(n.root),t.style.alignItems="center",{root:t,getValue:()=>({table:e.value,column:n.value})}})(),a=P.icons.delete((()=>{if(!s.root.parentElement||t.length<2)return;s.root.remove();const e=t.indexOf(s);-1!==e&&t.splice(e,1)}),"Remove"),l=P.icons.add((()=>{let e=t.indexOf(s);-1===e&&(e=t.length),n(e+1)}),"Add");s.root.appendChild(a),s.root.appendChild(l),a.style.marginLeft="8px",a.style.marginRight="8px",a.style.color="var(--blue-1)",l.style.color="var(--blue-1)";const c=t[i];c?e.insertBefore(s.root,c.root):e.appendChild(s.root),t.splice(i,0,s)};n(0);const i=P.input.string("Separator",{value:"-",tooltipText:"Separator for sequences",nullable:!1});P.dialog("Combine Sequences").add(e).add(i.root).onOK((async()=>{if(!function(){const e=t.map((t=>t.getValue())),n=e.map((t=>t.table)),r=e.map((t=>t.column));return n.every((t=>!!t))&&r.every((t=>!!t))}())return void r.shell.error("Please fill all the fields");const e=t.map((t=>t.getValue())),n=e.map((t=>t.table)),s=e.map((t=>t.column)),a=i.value,l=s.map(((t,e)=>n[e].col(t).toList().filter((t=>!!t))));let c=0;const u=l.reduce(((t,e)=>t*e.length),1);if(u>1e7)return void r.shell.error("Too many combinations. Maximum allowed is 10M");const h=new Array(u).fill(null),d=(t,e)=>{if(e===l.length)return void(h[c++]=t);const n=`${t}${t?a:""}`,r=l[e];for(let t=0;t<l[e].length;t++)d(n+r[t],e+1)};d("",0);const p=o.DataFrame.fromColumns([o.Column.fromStrings("Combined Sequences",h)]);p.name="Combined Sequences",await p.meta.detectSemanticTypes(),await r.data.detectSemanticTypes(p),r.shell.addTableView(p)})).show({resizable:!0})}()}static applyNotationProviderForCyclized(t,e){t.setTag("aligned","SEQ"),t.setTag("alphabet","UN"),t.setTag(".alphabetIsMultichar","true"),t.meta.units=i.Hi.CUSTOM,e&&!t.tags[i.qE.separator]&&(t.tags[i.qE.separator]=e),t.tags["polytool-data-role"]="template",t.temp[a.notationProvider]=new Or(e,Yr.helmHelper)}static async harmonizedSequenceNotationProviderConstructor(){return Or}}async function Jr(t){await Yr.initLibData();const e=function(t,e){switch(t){case"Oligo Translator":return new We(e);case"Oligo Pattern":return new ie(e);case"Oligo Structure":return new Le(e);default:throw new Error(`Unknown app name: ${t}`)}}(t,Yr);return await e.getAppView()}qr([r.decorators.app({icon:"img/icons/toolkit.png",browsePath:"Peptides | Oligo Toolkit",name:"Oligo Toolkit",tags:["app"]}),Wr("design:type",Function),Wr("design:paramtypes",[]),Wr("design:returntype",Promise)],Qr,"oligoToolkitApp",null),qr([r.decorators.init({tags:["init"]}),Wr("design:type",Function),Wr("design:paramtypes",[]),Wr("design:returntype",Promise)],Qr,"init",null),qr([r.decorators.app({icon:"img/icons/translator.png",browsePath:"Peptides | Oligo Toolkit",name:"Oligo Translator",tags:["app"]}),Wr("design:type",Function),Wr("design:paramtypes",[]),Wr("design:returntype",Promise)],Qr,"oligoTranslatorApp",null),qr([r.decorators.app({icon:"img/icons/pattern.png",browsePath:"Peptides | Oligo Toolkit",name:"Oligo Pattern",tags:["app"]}),Wr("design:type",Function),Wr("design:paramtypes",[]),Wr("design:returntype",Promise)],Qr,"oligoPatternApp",null),qr([r.decorators.app({icon:"img/icons/structure.png",browsePath:"Peptides | Oligo Toolkit",name:"Oligo Structure",tags:["app"]}),Wr("design:type",Function),Wr("design:paramtypes",[]),Wr("design:returntype",Promise)],Qr,"oligoStructureApp",null),qr([r.decorators.func({outputs:[{type:"object",name:"result"}]}),Wr("design:type",Function),Wr("design:paramtypes",[]),Wr("design:returntype",Promise)],Qr,"getTranslationHelper",null),qr([r.decorators.func({outputs:[{type:"object",name:"result"}]}),Wr("design:type",Function),Wr("design:paramtypes",[]),Wr("design:returntype",Object)],Qr,"getCodeToWeightsMap",null),qr([r.decorators.func(),Wr("design:type",Function),Wr("design:paramtypes",[String]),Wr("design:returntype",Boolean)],Qr,"validateSequence",null),qr([r.decorators.func({name:"validateSequence"}),Wr("design:type",Function),Wr("design:paramtypes",[String,Boolean]),Wr("design:returntype",String)],Qr,"getMolfileFromGcrsSequence",null),qr([r.decorators.func(),zr(0,r.decorators.param({type:"object"})),Wr("design:type",Function),Wr("design:paramtypes",[Object]),Wr("design:returntype",String)],Qr,"linkStrands",null),qr([r.decorators.func({meta:{demoPath:"Bioinformatics | Oligo Toolkit | Translator",path:"/apps/Tutorials/Demo/Bioinformatics/Oligonucleotide%20Sequence:%20Translate",demoSkip:"GROK-14320"},name:"demoOligoTranslator",description:"Translate oligonucleotide sequences across various formats accepted by different synthesizers"}),Wr("design:type",Function),Wr("design:paramtypes",[]),Wr("design:returntype",Promise)],Qr,"demoTranslateSequence",null),qr([r.decorators.func({meta:{demoPath:"Bioinformatics | Oligo Toolkit | Pattern",path:"%20/apps/Tutorials/Demo/Bioinformatics/Oligonucleotide%20Sequence:%20Visualize%20duplex"},description:"Design a modification pattern for an oligonucleotide sequence"}),Wr("design:type",Function),Wr("design:paramtypes",[]),Wr("design:returntype",Promise)],Qr,"demoOligoPattern",null),qr([r.decorators.func({meta:{demoPath:"Bioinformatics | Oligo Toolkit | Structure",path:"%20/apps/Tutorials/Demo/Bioinformatics/Oligonucleotide%20Sequence:%20Visualize%20duplex"},description:"Visualize duplex and save SDF"}),Wr("design:type",Function),Wr("design:paramtypes",[]),Wr("design:returntype",Promise)],Qr,"demoOligoStructure",null),qr([r.decorators.func(),Wr("design:type",Function),Wr("design:paramtypes",[String,String,String]),Wr("design:returntype",Promise)],Qr,"translateOligonucleotideSequence",null),qr([r.decorators.func({"top-menu":"Bio | PolyTool | Convert...",name:"polyToolConvert",description:"editor for Performing conversion of sequences in custom notation to molfiles"}),Wr("design:type",Function),Wr("design:paramtypes",[]),Wr("design:returntype",Promise)],Qr,"polyToolConvertTopMenu",null),qr([r.decorators.editor({tags:["editor"]}),Wr("design:type",Function),Wr("design:paramtypes",[o.FuncCall]),Wr("design:returntype",Promise)],Qr,"getPolyToolConvertEditor",null),qr([r.decorators.func({editor:"SequenceTranslator:getPolyToolConvertEditor"}),zr(1,r.decorators.param({options:{caption:"Sequence"}})),zr(2,r.decorators.param({options:{initialValue:"true"}})),zr(3,r.decorators.param({options:{initialValue:"true"}})),zr(4,r.decorators.param({type:"object"})),Wr("design:type",Function),Wr("design:paramtypes",[o.DataFrame,o.Column,Boolean,Boolean,Array]),Wr("design:returntype",Promise)],Qr,"polyToolConvert2",null),qr([r.decorators.func({"top-menu":"Bio | PolyTool | Enumerate HELM...",name:"polyToolEnumerateHelm",description:"Dialog for configuring enumeration of a HELM sequence"}),Wr("design:type",Function),Wr("design:paramtypes",[]),Wr("design:returntype",Promise)],Qr,"polyToolEnumerateHelmTopMenu",null),qr([r.decorators.func({"top-menu":"Bio | PolyTool | Enumerate Chem...",name:"polyToolEnumerateChem",description:"Perform enumeration of a molecule using different fragments at specified positions"}),Wr("design:type",Function),Wr("design:paramtypes",[]),Wr("design:returntype",Promise)],Qr,"polyToolEnumerateChemTopMenu",null),qr([r.decorators.func({"top-menu":"Chem | Transform | Reactions | Enumerate...",name:"chemEnumerateReactions",description:"Enumerate cores and R-group lists into a molecule table (Zip or Cartesian)"}),Wr("design:type",Function),Wr("design:paramtypes",[]),Wr("design:returntype",Promise)],Qr,"chemEnumerateReactionsTopMenu",null),qr([r.decorators.func(),zr(0,r.decorators.param({options:{description:"Input data table"}})),Wr("design:type",Function),Wr("design:paramtypes",[o.DataFrame,o.Column]),Wr("design:returntype",Promise)],Qr,"polyToolColumnChoice",null),qr([r.decorators.func(),Wr("design:type",Function),Wr("design:paramtypes",[o.FileInfo]),Wr("design:returntype",Promise)],Qr,"createMonomerLibraryForPolyTool",null),qr([r.decorators.func({meta:{icon:"img/icons/structure.png",browsePath:"Peptides | PolyTool",role:"app"},name:"HELM Enumerator",tags:["app"]}),Wr("design:type",Function),Wr("design:paramtypes",[]),Wr("design:returntype",Promise)],Qr,"ptEnumeratorHelmApp",null),qr([r.decorators.func({meta:{icon:"img/icons/structure.png",browsePath:"Chem | PolyTool",role:"app"},name:"Chem Enumerator",tags:["app"],outputs:[{type:"view",name:"result"}]}),Wr("design:type",Function),Wr("design:paramtypes",[]),Wr("design:returntype",Promise)],Qr,"ptEnumeratorChemApp",null),qr([r.decorators.func({name:"Polytool Helm Enumerator dialog"}),zr(0,r.decorators.param({type:"object",options:{nullable:!0}})),Wr("design:type",Function),Wr("design:paramtypes",[o.Cell]),Wr("design:returntype",Promise)],Qr,"getPtHelmEnumeratorDialog",null),qr([r.decorators.func({name:"Polytool Chem Enumerator dialog"}),zr(0,r.decorators.param({type:"object",options:{nullable:!0}})),Wr("design:type",Function),Wr("design:paramtypes",[o.Cell]),Wr("design:returntype",Promise)],Qr,"getPtChemEnumeratorDialog",null),qr([r.decorators.func({name:"Enumerate Single HELM Sequence",description:"Enumerate provided HELM sequence on provided positions with provided monomers and generates new table",outputs:[{type:"dataframe",name:"result"}]}),Wr("design:type",Function),Wr("design:paramtypes",[String,Array,Array,Boolean]),Wr("design:returntype",Promise)],Qr,"enumerateSingleHelmSequence",null),qr([r.decorators.func({name:"Enumerate Single HELM Sequence with natural amino acids",description:'Enumerate provided HELM sequence on all positions with natural amino acids and generates new table. Generated table has sequence column called "Enumerated", and molecule column called "Molfile(Enumerated) if toAtomicLevel is set to true. Keywords: Optimize, enumerate, HELM optimization, Maximize Minimize property. When you want to optimize certain peptide using for example logS, set toAtomicLevel to true and use generated molecule column to calculate given property using chem package functions.',outputs:[{type:"dataframe",name:"result"}]}),Wr("design:type",Function),Wr("design:paramtypes",[String,Boolean]),Wr("design:returntype",Promise)],Qr,"enumerateSingleHelmSequenceWithNaturalAAs",null),qr([r.decorators.func({name:"Combine Sequences","top-menu":"Bio | PolyTool | Combine Sequences..."}),Wr("design:type",Function),Wr("design:paramtypes",[]),Wr("design:returntype",Promise)],Qr,"getPolyToolCombineDialog",null),qr([r.decorators.func({name:"applyNotationProviderForHarmonizedSequence"}),zr(0,r.decorators.param({type:"column"})),Wr("design:type",Function),Wr("design:paramtypes",[o.Column,String]),Wr("design:returntype",void 0)],Qr,"applyNotationProviderForCyclized",null),qr([r.decorators.func({name:"harmonizedSequenceNotationProviderConstructor",meta:{role:"notationProviderConstructor"}}),Wr("design:type",Function),Wr("design:paramtypes",[]),Wr("design:returntype",Promise)],Qr,"harmonizedSequenceNotationProviderConstructor",null)},5412:(t,e,n)=>{"use strict";n.d(e,{m:()=>l});var r=n(6082),o=n(4328),i=n(4971),s=n(6077),a=n(2003);async function l(t,e,n,l,c,u,h,d,p){const f=(await p.helmToAtomicLevel(t,l,c,h)).molCol,m=n.filter((t=>t)).length;if(u&&m>0){const t=new Array(m);let l=0;for(let r=0;r<n.length;r++)n[r]&&(t[l]=e[r],l++);const c=r.Column.fromStrings("helm",t);c.semType=r.SEMTYPE.MACROMOLECULE,c.meta.units=a.Hi.HELM,c.setTag(r.TAGS.CELL_RENDERER,"helm");const u=(await(0,i.pj)()).getMonomerLib();try{const t=await(0,s.C4)(r.DataFrame.create(0),c,u,p,d);l=0;for(let e=0;e<n.length;e++)n[e]&&(f.set(e,t.molCol.get(l)),l++)}catch(t){o.shell.warning("PolyTool was not able to linearize sequences")}}return function(t){for(let e=0;e<t.length;e++)t.set(e,t.get(e).replaceAll("undefined","H")),t.set(e,t.get(e).replaceAll("Oh","O").replaceAll("OH","O")),t.set(e,t.get(e).replaceAll("0.000000 3","0.000000 0")),t.set(e,t.get(e).replaceAll("?","O")),t.set(e,t.get(e).replaceAll(" 0 3\n"," 0 0\n")),t.set(e,t.get(e).replaceAll("RGROUPS=(1 1)",""))}(f),f}},6307:(t,e,n)=>{"use strict";n.d(e,{s:()=>p});var r=n(2125),o=n(8438),i=n(6694);function s(t,e){let n="";for(let t=0;t<e.length;t++){t>0&&(n+="|"),n+=`PEPTIDE${t+1}{`;for(let r=0;r<e[t].length;r++){r>0&&(n+=".");const o=e[t][r];n+=o.length>1?`[${o}]`:o}n+="}"}n+="$";for(let o=0;o<t.length;o++)o>0&&(n+="|"),n+=`PEPTIDE${t[o].fChain+1},PEPTIDE${t[o].sChain+1},`,n+=`${(0,r.M)(t[o].fMonomer-1,e)[0]+1}:R${t[o].fR}-`,n+=`${(0,r.M)(t[o].sMonomer-1,e)[0]+1}:R${t[o].sR}`;return n+="$$$V2.0",n}function a(t,e,n,r=0,o=[],i=[]){let[s,a,l,c,u]=[!1,!1,!1,-1,-1];for(let h=0;h<t.length;h++)if(t[h].includes(e)){if(s){if(l&&(n||t[h]==i[r]+e)){a=!0,u=h;break}if(l||!n&&t[h]!=o[r]+e)continue;a=!0,u=h;break}if(n)s=!0,l=!0,c=h;else if(t[h]==o[r]+e)s=!0,l=!0,c=h;else{if(t[h]!=i[r]+e)continue;s=!0,l=!!n,c=h}}return[s,a,l,c,u]}function l(t,e){const n=[];for(let r=0;r<e.length;r++){const o=`(${e[r].code})`,[s,l]=(0,i.Ln)(e[r]);if(s.length>0)for(let e=0;e<s.length;e++){const[i,c,u,h,d]=a(t,o,!1,e,s,l);i&&c&&(u?n.push({firstIdx:h,secondIdx:d,ruleIdx:r}):n.push({firstIdx:d,secondIdx:h,ruleIdx:r}))}else{const[e,i,s,l,c]=a(t,o,!0);if(!e||!i)continue;s?n.push({firstIdx:l,secondIdx:c,ruleIdx:r}):n.push({firstIdx:c,secondIdx:l,ruleIdx:r})}}return n}function c(t,e,n){const r=[],o=[],i=[],s=[],a=n.length;for(let l=0;l<a;l++){if(-1==n[l].firstIdx)continue;const a=n[l].ruleIdx,c=t[a].code;e[n[l].firstIdx]=e[n[l].firstIdx].replace(`(${c})`,""),e[n[l].secondIdx]=e[n[l].secondIdx].replace(`(${c})`,""),r.push(n[l].firstIdx+1),o.push(n[l].secondIdx+1),i.push(t[a].firstLinkingGroup),s.push(t[a].secondLinkingGroup)}return[r,o,i,s]}function u(t,e,n){const r=[],o=[],i=[],s=n.length;for(let a=0;a<s;a++){if(-1==n[a].firstIdx)continue;const s=n[a].firstIdx,l=n[a].secondIdx,c=n[a].ruleIdx,u=t[c].code;e[s]=e[s].replace(`(${u})`,"")+`_${t[c].name}`,e[l]=e[l].replace(`(${u})`,"")+`_${t[c].name}`,r.push(s+1),o.push(l+1),i.push(n[a].ruleIdx)}return[r,o,i]}var h=n(3599);function d(t,e,n){const r=n.createHelmWebEditor().editor.m;let o=0;const i=new JSDraw2.Point(0,0);for(let t=0;t<e.length;t++)for(let n=0;n<e[t].length;n++){if(e[t][n]){const s=e[t][n],a={type:h.o.AA,i:t,j:n,continuousId:o},l=new JSDraw2.Atom(i,s,a);if(r.addAtom(l),0!==n){const t=r.atoms[o-1],e=r.atoms[o],n=new JSDraw2.Bond(t,e);n.r1=2,n.r2=1,r.addBond(n)}o++,i.x+=JSDraw2.Editor.BONDLENGTH}i.y+=4*JSDraw2.Editor.BONDLENGTH}for(let e=0;e<t.length;e++){const n=r.atoms[t[e].fMonomer-1],o=r.atoms[t[e].sMonomer-1],i=new JSDraw2.Bond(n,o);i.r1=t[e].fR,i.r2=t[e].sR,r.addBond(i)}return r}class p{constructor(t,e,n){this.helmHelper=n,this.underRules=!1,this.posToPosUnderRules=[],this.linkages=e,this.monomers=t,this.mol=d(e,t,n)}static fromSeparator(t,e){const[n,r]=function(t){const e=[],n=[],r=/(\(.\d+\))?\{[^\}]*\}/g,o=[];o.push(t.replaceAll(r,""));const i=t.matchAll(r);for(const t of i){const e=t[0];e&&o.push(e)}let s=0;for(let t=0;t<o.length;t++){const r=o[t].split("-"),i=new Array(r.length);let a=0;for(let e=0;e<r.length;e++){const o=r[e].replace("{","").replace("}","");""!==o?(i[e]=o,s++,a++):n.push({fChain:t,sChain:t+1,fMonomer:s,sMonomer:s+1,fR:1,sR:1})}e.push(i.slice(0,a))}return[n,e]}(t);return new p(r,n,e)}static fromHelm(t,e){const[n,i]=function(t){const e=/(\w+\{.*\})\$(.*)\$(.*)\$(.*)\$/g.exec(t),n=[e[1],e[2],e[3],e[4]],i=n[0].split("|"),s=n[1].split("|"),a=new Array(i.length),l=[];for(let t=0;t<i.length;t++){const e=i[t].indexOf("{"),n=i[t].indexOf("}");a[t]=i[t].slice(e+1,n).split(".").map((t=>(0,o.D)(t)))}for(let t=0;t<s.length;t++)if(""!==s[t]&&"V2.0"!==s[t]){const e=s[t].split(","),n=parseInt(e[0].replace("PEPTIDE",""))-1,o=parseInt(e[1].replace("PEPTIDE",""))-1,i=e[2].split("-"),c=i[0].split(":"),u=i[1].split(":");l.push({fChain:n,sChain:o,fMonomer:(0,r.j)(parseInt(c[0]),n,a),sMonomer:(0,r.j)(parseInt(u[0]),o,a),fR:parseInt(c[1].replace("R","")),sR:parseInt(u[1].replace("R",""))})}return[l,a]}(t);return new p(i,n,e)}getNotation(){return function(t){const e=t.atoms,n=t.bonds,r=[],o=[];for(let t=0;t<n.length;t++)n[t].a1.bio.i!==n[t].a2.bio.i&&o.push(t);for(let t=0;t<e.length;t++){const n=e[t].bio?.i;n+1>r.length?r.push(1):r[n]++}const i=new Array(r.length);let s=0;for(let t=0;t<r.length;t++){const n=new Array(r[t]);for(let o=0;o<r[t];o++)n[o]=e[s].elem,s++;i[t]=n}let a="";for(let t=0;t<i.length;t++){let e="";for(let n=0;n<i[t].length;n++)e+=`${0==n?"":"-"}${i[t][n]}`;if(0!==t){const t=/(\(.\d+\))/,n=e.match(t);e=e.replace(n?.[0],""),e=`${n?n?.[0]:""}{${e}}`}else if(i.length>1){const t=0==n[o[0]].a1.bio.i&&0==n[o[0]].a1.bio.j,r=1==n[o[0]].a2.bio.i&&0==n[o[0]].a1.bio.j;t&&r&&(e+="-")}a+=e}return a}(this.mol)}getHelm(){return this.underRules?s(this.linkagesUnderRules,this.monomersUnderRules):s(this.linkages,this.monomers)}applyRules(t){const e=this.getNotation(),[n,r,o]=function(t,e){const n=[],r=[],o=[],i=e.heterodimerCode,s=e.homodimerCode,a=null!==i?t.split(`(${e.heterodimerCode})`):"";null!==i&&a.length>1?(o.push({fChain:0,sChain:1,fMonomer:1,sMonomer:1,fR:1,sR:1}),n.push(a[1].replaceAll("{","").replaceAll("}","")),n.push(a[2].replaceAll("{","").replaceAll("}","")),r.push(!1),r.push(!1)):(n.push(t),r.push(!1));for(let t=0;t<n.length;t++)if(null!==s&&n[t].includes(`(${s})`)){const e=n.length;o.push({fChain:t,sChain:e,fMonomer:1,sMonomer:1,fR:1,sR:1});const i=n[t].replace(`(${s})`,""),a=i.indexOf("{"),l=i.slice(0,a),c=i.replace(l,"").replaceAll("{","").replaceAll("}","");n[t]=l+c,n.push(c),r.push(!0)}return[o,n,r]}(e,t),i=new Array(r.length);let s=0;for(let t=0;t<r.length;t++)if(i[t]=r[t].split("-"),o[t]){const e=this.posToPosUnderRules.length-i[t].length;for(let n=0;n<i[t].length;n++)this.posToPosUnderRules[e+n].push(s),s++}else for(let e=0;e<i[t].length;e++)this.posToPosUnderRules.push([s]),s++;!function(t,e,n){for(let r=0;r<t.length;r++){const o=t[r],i=l(o,n.linkRules),[s,a,u,h]=c(n.linkRules,o,i);for(let t=0;t<s.length;t++)e.push({fChain:r,sChain:r,fMonomer:s[t],sMonomer:a[t],fR:u[t],sR:h[t]});t[r]=o}}(i,n,t),function(t,e,n){for(let r=0;r<t.length;r++){const o=l(t[r],n.reactionRules),[i,s,a]=u(n.reactionRules,t[r],o);i.length>=1&&(e.push({fChain:r,sChain:t.length,fMonomer:i[0],sMonomer:1,fR:3,sR:1}),e.push({fChain:r,sChain:t.length,fMonomer:s[0],sMonomer:1,fR:3,sR:2}),t.push([n.reactionRules[a[0]].name]))}}(i,n,t),this.underRules=!0,this.linkagesUnderRules=n,this.monomersUnderRules=i,this.molUnderRules=d(n,i,this.helmHelper)}check(t=!1){const e=[],n=this.monomers.map((t=>t.length)).reduce(((t,e)=>t+e),0);this.mol.atoms.length!==n&&e.push(`The mol atoms count ${this.mol.atoms.length} does not match the total number ${n} of chains' monomers.`);const r=this.monomers.map((t=>t.length-1)).reduce(((t,e)=>t+e),0)+this.linkages.length;this.mol.bonds.length!==r&&e.push(`The mol bonds count ${this.mol.bonds.length} does not match the total number ${r} in- and inter-chain linkages.`);let o=0;for(let t=0;t<this.monomers.length;++t){const n=this.monomers[t];for(let t=0;t<n.length;++t)try{const r=n[t],i=this.mol.atoms[o];i.bio.continuousId!==o&&e.push(`Atom #${o} has incorrect .bio.continuousId: ${i.bio.continuousId}.`),i.elem!==r&&e.push(`Atom #${o} elem: '${i.elem}' does not match chain monomer: '${r}'.`)}finally{o++}}if(t&&e.length>0)throw new Error(`Chain errors:\n${e.map((t=>` ${t}`)).join("\n")}`);return e}}},4229:(t,e,n)=>{"use strict";n.d(e,{b:()=>s});var r=n(9192),o=n(6307),i=n(2018);function s(t,e,n){const s=new Array(t.length),a=new Array(t.length),l=new Array(t.length);for(let c=0;c<t.length;c++)try{if(null==t[c])s[c]="";else{const r=o.s.fromSeparator(t[c],n);r.applyRules(e),a[c]=!(r.monomersUnderRules.length>1||r.linkagesUnderRules.length>0),s[c]=r.getHelm(),l[c]=r.posToPosUnderRules}}catch(t){const[e,n]=(0,r.AP)(t);i._package.logger.error(e,void 0,n),s[c]=""}return[s,a,l]}},2125:(t,e,n)=>{"use strict";function r(t,e){let n,r=t;for(n=0;n<e.length&&r>=e[n].length;++n)r-=e[n].length;return[r,n]}function o(t,e,n){let r=0;for(let t=0;t<e;++t)r+=n[t].length;return r+t}n.d(e,{M:()=>r,j:()=>o})},6694:(t,e,n)=>{"use strict";n.d(e,{MU:()=>U,yy:()=>j,_v:()=>J,Ln:()=>et,Q4:()=>tt});var r=n(6082),o=n(4328),i=n(7389),s=n(1991),a=n.n(s),l=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{l(r.next(t))}catch(t){i(t)}}function a(t){try{l(r.throw(t))}catch(t){i(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((r=r.apply(t,e||[])).next())}))};class c{constructor(t,e,n=".csv",r){this.path=t,this.userStorageName=e,this.ext=n,this.options=r,this.inputs=null,"/"!==this.path[this.path.length-1]&&(this.path+="/"),"."!==this.ext[0]&&(this.ext="."+this.ext)}getUserSettings(){return l(this,void 0,void 0,(function*(){if(this.settings)return this.settings;const t=o.userSettings.getValue(this.userStorageName,"Settings"),e=t?JSON.parse(t):{excluded:[],explicit:[]};return e.explicit=e.explicit instanceof Array?e.explicit:[],e.excluded=e.excluded instanceof Array?e.excluded:[],this.settings=e}))}setUserSettings(t){this.settings=t,o.userSettings.add(this.userStorageName,"Settings",JSON.stringify(t))}getAllAvailable(){return l(this,void 0,void 0,(function*(){return(yield o.dapi.files.list(this.path)).map((t=>t.fullPath.replace(`${this.path}`,"")))}))}getActive(){return l(this,void 0,void 0,(function*(){const t=yield this.getUserSettings();return t.explicit.length>0?t.explicit:(yield this.getAllAvailable()).filter((e=>!t.excluded.includes(e)))}))}setActive(t){const e=new Set(t);for(const[t,n]of this.inputs.entries())n.value=e.has(t)}createInput(t,e){const n=i.input.bool(t,{value:e,onValueChanged:e=>this.updateSelectionStatus(t,e)});return n.addOptions(i.button(i.iconFA("trash"),(()=>{i.dialog({title:"Warning"}).add(i.divText(`Delete file '${t}'?`)).onOK((()=>{n.root.remove(),this.availableRemove(t)})).show()}),`Delete ${t}`)),n}getInputs(){return l(this,void 0,void 0,(function*(){this.inputs=new Map;const t=yield this.getAllAvailable(),e=yield this.getActive(),n=new Array(t.length);for(let r=0;r<t.length;r++){const o=e.includes(t[r]);n[r]=this.createInput(t[r],o),this.inputs.set(t[r],n[r])}return this.fireOnValueChanged(),n}))}getForm(){return l(this,void 0,void 0,(function*(){const t=yield this.getInputs(),e=i.divV(t);return i.divV([e,i.button("ADD",(()=>l(this,void 0,void 0,(function*(){let t="";if(t=yield this.getNewAvailable(),""!==t){const n=this.createInput(t,!0);e.append(n.root),this.inputs.set(t,n),this.fireOnValueChanged()}}))))])}))}fireOnValueChanged(){var t;null===(t=this.options)||void 0===t||t.onValueChanged(a()(this.inputs.entries()).filter((([t,e])=>e.value)).map((([t,e])=>t)).toArray())}updateSelectionStatus(t,e){return l(this,void 0,void 0,(function*(){const n=yield this.getUserSettings();if(!n.excluded.includes(t)!==e){if(e){const e=n.excluded.indexOf(t);e>-1&&n.excluded.splice(e,1)}else n.excluded.push(t);this.fireOnValueChanged(),this.setUserSettings(n)}}))}availableRemove(t){return l(this,void 0,void 0,(function*(){this.inputs.delete(t),this.fireOnValueChanged();const e=yield this.getUserSettings(),n=e.excluded.indexOf(t);n>-1&&e.excluded.splice(n,1),this.setUserSettings(e),yield o.dapi.files.delete(this.path+t),o.shell.info(`File ${t} successfully deleted`)}))}getNewAvailable(){return l(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{r.Utils.openFile({accept:this.ext,open:e=>l(this,void 0,void 0,(function*(){const n=e.name,r=yield e.arrayBuffer();yield o.dapi.files.write(this.path+`${e.name}`,new Uint8Array(r)),t(n)}))})}))}))}}var u=n(2018),h=n(9124),d=n(4229),p=n(439),f=n(5174),m=n(5412),g=n(6717),y=n(8312);function b(t){let e=t.replaceAll(/\[R[1-9]\]/g,(t=>`[*:${t[2]}]`));return e=e.replaceAll(/\[\d\*\]/g,(t=>`[*:${t[1]}]`)),e.replaceAll(/\[\d\*\:\d\]/g,(t=>`[*:${t[1]}]`))}function v(t){return t.replaceAll(/\[\*\:\d\]/g,(t=>`[C:${t[3]}]`))}function C(t){return t.replaceAll(/\[C\:\d\]/g,(t=>`[*:${t[3]}]`))}function x(t,e){const n=e?.firstReactantSmiles?C(e.firstReactantSmiles):"[*:1]C",r=e?.secondReactantSmiles?C(e.secondReactantSmiles):"[*:2]C",s=e?.productSmiles?C(e.productSmiles):"[*:1]CC[*:2]",a=e?.code,l=e?.firstMonomers??[],c=e?.secondMonomers??[],u=e?.resultMonomerName??"",h=i.input.int("Code",{value:a,nullable:!1,showPlusMinus:!1,showSlider:!1,tooltipText:"Reaction code"}),d=i.input.string("First monomers",{value:l.join(","),nullable:!1,tooltipText:"Comma-separated list of monomers for the first reactant"}),p=i.input.string("Second monomers",{value:c.join(","),nullable:!1,tooltipText:"Comma-separated list of monomers for the second reactant"}),f=i.input.string("Result monomer name",{value:u,nullable:!1,tooltipText:"Name of the resulting pseudo-monomer generated by the reaction of the two reactants"}),m=i.input.molecule("First reactant",{value:n,nullable:!1,tooltipText:"Reactant fragment of first monomer(s). Use numbered R groups in correspondence with the rest of the molecule."}),g=i.input.molecule("Second reactant",{value:r,nullable:!1,tooltipText:"Reactant fragment of second monomer(s). Use numbered R groups in correspondence with the rest of the molecule."}),y=i.input.molecule("Product",{value:s,nullable:!1,tooltipText:"Product fragment of the resulting monomer from the reaction of the two reactants. Use numbered R groups in correspondence with the reactants."}),x=()=>{if(!m||!g||!y)return"Inputs not initialized yet";const t=v(b(o.chem.convert(m.value??"",o.chem.Notation.Unknown,o.chem.Notation.Smiles))),e=v(b(o.chem.convert(g.value??"",o.chem.Notation.Unknown,o.chem.Notation.Smiles))),n=v(b(o.chem.convert(y.value??"",o.chem.Notation.Unknown,o.chem.Notation.Smiles)));return t&&e&&n?-1==t.indexOf("[C:1]")?"First Reactant must contain R1-group":-1==e.indexOf("[C:2]")?"Second Reactant must contain R2-group":-1==n.indexOf("[C:1]")||-1==n.indexOf("[C:2]")?"Product must contain R1- and R2-groups":null:"First/Second Reactants and Product must all be set"};m.addValidator(x),g.addValidator(x),y.addValidator(x);const w=i.dialog(e?"Edit Reaction Rule":"Add Reaction Rule").add(h).add(f).add(d).add(p).add(m).add(g).add(y);w.addButton("Save",(()=>{const n=x();if(null!=n)return void o.shell.warning(n);const r=v(b(o.chem.convert(m.value??"",o.chem.Notation.Unknown,o.chem.Notation.Smiles))),i=v(b(o.chem.convert(g.value??"",o.chem.Notation.Unknown,o.chem.Notation.Smiles))),s=v(b(o.chem.convert(y.value??"",o.chem.Notation.Unknown,o.chem.Notation.Smiles)));t({code:h.value,resultMonomerName:f.value,firstMonomers:d.value.split(",").map((t=>t.trim())).filter((t=>t.length>0)),secondMonomers:p.value.split(",").map((t=>t.trim())).filter((t=>t.length>0)),firstReactantSmiles:r,secondReactantSmiles:i,productSmiles:s,rowIndex:e?.rowIndex}),w.close()})),w.show()}const w="Links",A="Reactions";class T{constructor(t,e){this.v=null,this.substituteReactionGridDataFrame=null,this.rules=t;const n=this.rules.getLinkRulesDf();this.linkRuleDataFrame=n.res,this.addLinkRulesFunc=n.addNewRow;const r=this.rules.getSynthesisRulesDf();this.addSynthRulesFunc=t=>{r.addNewRow(t),this.rules.setSynthesisRules(r.df),this.synthRuleDataFrame=r.df,this.substituteReactionGridDataFrame?.(),this.save()},this.synthRuleDataFrame=r.df,this.fileName=e;const o=this.rules.homodimerCode?this.rules.homodimerCode:"",s=this.rules.heterodimerCode?this.rules.heterodimerCode:"";this.homoDimerInput=i.input.string("Homo dimer",{value:o,onValueChanged:()=>{},nullable:!1}),this.heteroDimerInput=i.input.string("Hetero dimer",{value:s,onValueChanged:()=>{},nullable:!1})}async getAndAddView(){if(this.v)try{const t=Array.from(o.shell.views).find((t=>t.name===this.v.name));if(!t)throw this.v.detach(),this.v.close(),new Error("View is closed, making it null in catch statement");o.shell.v=t}catch(t){this.v=null}return this.v||(this.v=r.View.create(),this.v.name=`Manage Polytool Rules - ${this.fileName}`,this.v.append(await this.getForm()),this.v=o.shell.addView(this.v),o.shell.v=this.v),this.v}static async getInstance(t){if(!this.instances[t]){const e=await tt([t]);this.instances[t]=new T(e,t)}return this.instances[t]}save(){this.rules.homodimerCode=this.homoDimerInput.value,this.rules.heterodimerCode=this.heteroDimerInput.value,this.rules.setLinkRules(this.linkRuleDataFrame),this.rules.setSynthesisRules(this.synthRuleDataFrame);const t={homodimerCode:this.rules.homodimerCode,heterodimerCode:this.rules.heterodimerCode,linkRules:this.rules.linkRules,reactionRules:this.rules.reactionRules},e=JSON.stringify(t,void 0,2);u._package.files.writeAsText(`polytool-rules/${this.fileName}`,e),o.shell.info(`Polytool rules at ${this.fileName} was updated`)}createGridDiv(t,e,n){const r=i.h1(t,"polytool-grid-header");i.tooltip.bind(r,n),r.style.marginTop="10px",r.style.marginRight="10px",e.root.style.height="100%";const o=i.splitV([i.box(r,{style:{maxHeight:"60px"}}),e.root]);return o.style.height="100%",o}async getLinkExamplesGrid(){const t=[];for(let e=0;e<this.rules.linkRules.length;e++){const n=this.rules.linkRules[e].code,[r,o]=et(this.rules.linkRules[e]);for(let e=0;e<r.length;e++){const i=`${r[e]}(${n})-A-A-A-A-${o[e]}(${n})`;t.push(i)}}const e=await(0,h.b2)(),[n,o,i]=(0,d.b)(t,this.rules,e),s=r.Column.fromStrings("Monomers",t),a=r.Column.fromStrings("Helm",n);return u.PackageFunctions.applyNotationProviderForCyclized(s,"-"),s.semType=r.SEMTYPE.MACROMOLECULE,a.semType=r.SEMTYPE.MACROMOLECULE,a.meta.units=p.Hi.HELM,a.setTag(r.TAGS.CELL_RENDERER,"helm"),r.DataFrame.fromColumns([s,a]).plot.grid()}async getReactionExamplesGrid(){const t=[];for(let e=0;e<this.rules.reactionRules.length;e++){const n=this.rules.reactionRules[e].code,[r,o]=et(this.rules.reactionRules[e]);for(let e=0;e<r.length;e++){const i=`${r[e]}(${n})-A-A-A-A-${o[e]}(${n})`;t.push(i)}}const e=await(0,h.b2)(),[n,o,i]=(0,d.b)(t,this.rules,e),s=r.Column.fromStrings("Monomers",t),a=r.Column.fromStrings("Helm",n),l=r.DataFrame.fromColumns([s,a]);s.semType=r.SEMTYPE.MACROMOLECULE;const c=await(0,g.j)(),b=await(0,y.Q)();u.PackageFunctions.applyNotationProviderForCyclized(s,"-"),s.tags[r.TAGS.CELL_RENDERER]="Sequence",a.semType=r.SEMTYPE.MACROMOLECULE,a.meta.units=p.Hi.HELM,a.setTag(r.TAGS.CELL_RENDERER,"helm");const v=await(0,f.A)(this.rules),C=a.temp;C[".mm.cellRenderer.overriddenLibrary"]=v,a.temp=C;const x=await(0,m.m)(a,t,o,!0,!1,!1,v,c,b);return x.name="molfile(sequence)",x.semType=r.SEMTYPE.MOLECULE,l.columns.add(x),l.plot.grid()}async getForm(){const t=this.linkRuleDataFrame.plot.grid({showAddNewRowIcon:!1,allowEdit:!1,rowHeight:60});t.onCellDoubleClick.subscribe((()=>{if(!t.dataFrame||-1==t.dataFrame.currentRowIdx||null==t.dataFrame.currentRowIdx)return;const e=t.dataFrame.currentRowIdx,n={row:e,code:this.linkRuleDataFrame.get("code",e),firstMonomers:this.linkRuleDataFrame.get("firstMonomers",e),secondMonomers:this.linkRuleDataFrame.get("secondMonomers",e),firstLinkingGroup:this.linkRuleDataFrame.get("firstLinkingGroup",e),secondLinkingGroup:this.linkRuleDataFrame.get("secondLinkingGroup",e)};this.getAddNewLinkRuleDialog(n)}));const e=this.createGridDiv("Rules",t,"specification for monomers to link and linking positions"),n=this.createGridDiv("Examples",await this.getLinkExamplesGrid(),"specification for monomers to link and linking positions");e.style.width="50%",n.style.width="50%";const r=i.h1("Monomers","polytool-grid-header");i.tooltip.bind(r,"Click different cobination to see how monomers will link"),this.linkCards=await this.rules.getLinkCards();const o=i.splitV([i.box(r,{style:{maxHeight:"30px"}}),this.linkCards[0].root]);this.linkCards[0].render(),await this.linkCards[0].reset(),this.linkRuleDataFrame.currentRowIdx=0,this.linkRuleDataFrame.onCurrentRowChanged.subscribe((async()=>{const t=this.linkRuleDataFrame.currentRowIdx;-1!==t&&null!=t&&(i.empty(o),o.append(i.splitV([i.box(r,{style:{maxHeight:"30px"}}),this.linkCards[t].root])),this.linkCards[t].render(),await this.linkCards[t].reset())}));const s=i.splitH([e,o],null,!0),a=this.synthRuleDataFrame.plot.grid({showAddNewRowIcon:!1,allowEdit:!1,rowHeight:130});a.onCellDoubleClick.subscribe((()=>{if(!a.dataFrame||-1==a.dataFrame.currentRowIdx||null==a.dataFrame.currentRowIdx)return;const t=a.dataFrame.currentRowIdx;x((t=>this.addSynthRulesFunc(t)),{rowIndex:t,code:this.synthRuleDataFrame.get("code",t),firstMonomers:this.synthRuleDataFrame.get("firstMonomers",t).split(",").map((t=>t.trim())).filter((t=>t)),secondMonomers:this.synthRuleDataFrame.get("secondMonomers",t).split(",").map((t=>t.trim())).filter((t=>t)),resultMonomerName:this.synthRuleDataFrame.get("name",t),firstReactantSmiles:this.synthRuleDataFrame.get("firstReactant",t),secondReactantSmiles:this.synthRuleDataFrame.get("secondReactant",t),productSmiles:this.synthRuleDataFrame.get("product",t)})}));const l=this.createGridDiv("Rules",a),c=await this.getReactionExamplesGrid(),u=this.createGridDiv("Examples",c);this.substituteReactionGridDataFrame=async()=>{const t=await this.getReactionExamplesGrid();c.dataFrame=t.dataFrame},l.style.width="50%",u.style.width="50%";const h=i.divH([l,u]),d=i.divV([this.homoDimerInput,this.heteroDimerInput]),p=i.tabControl({Links:s,Reactions:h,Dimers:d},!1);i.tooltip.bind(p.getPane(w).header,"Specify rules to link monomers based on HELM notation"),i.tooltip.bind(p.getPane(A).header,"Specify rules to perform reactions within monomers"),i.tooltip.bind(p.getPane("Dimers").header,"Specify symbols for homodimeric and heterodimeric codes"),p.root.style.height="100%",p.root.style.width="100%",p.root.classList.add("rules-manager-form-tab-control"),p.header.style.marginBottom="10px";const f=i.divV([p.root]),m=[i.bigButton("Save",(()=>{this.save()})),i.button("Add rule",(()=>{const t=p.currentPane.name;t==w?this.getAddNewLinkRuleDialog():t==A&&x((t=>this.addSynthRulesFunc(t)))})),i.button("Remove rule",(()=>{const e=p.currentPane.name;if(e==w){if(null==this.linkRuleDataFrame||-1==this.linkRuleDataFrame.currentRowIdx||null==this.linkRuleDataFrame.currentRowIdx)return;const e=t.dataFrame.currentRowIdx;i.dialog("Are you sure you want to remove the rule?").add(i.divText("This action is irreversible!")).onOK((()=>{this.linkRuleDataFrame.rows.removeAt(e),this.rules.setLinkRules(this.linkRuleDataFrame),this.save()})).show()}else if(e==A){if(null==this.synthRuleDataFrame||-1==this.synthRuleDataFrame.currentRowIdx||null==this.synthRuleDataFrame.currentRowIdx)return;const t=a.dataFrame.currentRowIdx;i.dialog("Are you sure you want to remove the rule?").add(i.divText("This action is irreversible!")).onOK((()=>{this.synthRuleDataFrame.rows.removeAt(t),this.rules.setSynthesisRules(this.synthRuleDataFrame),this.substituteReactionGridDataFrame?.(),this.save()})).show()}}))];return this.v.setRibbonPanels([m]),f.style.height="100%",f.style.alignItems="center",p.root}getAddNewLinkRuleDialog(t){const e=i.input.int("Code",{nullable:!1,value:t?.code}),n=i.input.string("First monomers",{placeholder:"E.g. C,D,E",value:t?.firstMonomers,tooltipText:"Comma separated list of first monomers applicable for the rule. If left empty, all monomers will be considered",nullable:!0}),r=i.input.string("Second monomers",{placeholder:"E.g. C,D,E",value:t?.secondMonomers,tooltipText:"Comma separated list of second monomers applicable for the rule. If left empty, all monomers will be considered",nullable:!0}),o=t?.firstLinkingGroup?`R${t.firstLinkingGroup}`:"R3",s=t?.secondLinkingGroup?`R${t.secondLinkingGroup}`:"R3",a=i.input.choice("First linking group",{value:o,items:["R1","R2","R3","R4"],tooltipText:"Specifies which R-group of the first monomer will be used for linking",nullable:!1}),l=i.input.choice("Second linking group",{value:s,items:["R1","R2","R3","R4"],tooltipText:"Specifies which R-group of the second monomer will be used for linking",nullable:!1});i.dialog("Add new link rule").add(e).add(n).add(r).add(a).add(l).onOK((async()=>{const o=e.value,i=(n.value??"").split(",").map((t=>t.trim())).filter((t=>t)).join(","),s=(r.value??"").split(",").map((t=>t.trim())).filter((t=>t)).join(","),c=parseInt(a.value.substring(1)),u=parseInt(l.value.substring(1));this.addLinkRulesFunc({code:o,firstMonomers:i??"",secondMonomers:s??"",firstLinkingGroup:c,secondLinkingGroup:u,row:t?.row}),this.rules.setLinkRules(this.linkRuleDataFrame),this.linkCards=await this.rules.getLinkCards(),this.save()})).show()}}T.instances={};var E=n(5072),S=n.n(E),I=n(7825),N=n.n(I),_=n(7659),P=n.n(_),M=n(5056),L=n.n(M),O=n(540),R=n.n(O),D=n(1113),$=n.n(D),B=n(890),F={};F.styleTagTransform=$(),F.setAttributes=L(),F.insert=P().bind(null,"head"),F.domAPI=N(),F.insertStyleElement=R(),S()(B.A,F),B.A&&B.A.locals&&B.A.locals;var k=n(2003);class H{get selected(){return this._selected}set selected(t){this._selected=t,this.root.style.border=t?"2px solid var(--green-2)":"2px solid var(--grey-2)"}constructor(t,e){this.monomer=t,this.monomerSymbol=e,this.root=i.divV([],{classes:"monomer-card-rule-root"}),this._selected=!1}render(){if(i.empty(this.root),this.root.appendChild(i.h2(this.monomerSymbol,{style:{textAlign:"center"}})),this.monomer){const t=this.monomer.smiles&&o.chem.checkSmiles(this.monomer.smiles)?o.chem.drawMolecule(this.monomer.smiles,150,120):o.chem.drawMolecule(this.monomer.molfile??"",150,120);this.root.appendChild(t);const e=i.divH([i.divText("Monomer Name: "),i.divText(this.monomer.name)],{classes:"monomer-card-info-rules"});if(this.root.appendChild(e),i.tooltip.bind(e,this.monomer.name),this.monomer.lib?.source){const t=i.divH([i.divText("Source: "),i.divText(this.monomer.lib.source)],{classes:"monomer-card-info-rules"});this.root.appendChild(t),i.tooltip.bind(t,this.monomer.lib.source)}const n=i.divH([i.divText("Polymer Type: "),i.divText(this.monomer.polymerType)],{classes:"monomer-card-info-rules"});this.root.appendChild(n),i.tooltip.bind(n,this.monomer.polymerType),i.tooltip.bind(this.root,"Select Monomer")}else this.root.appendChild(i.divV([`Monomer ${this.monomerSymbol} not found in libraries`],{style:{textAlign:"center",height:"100%"}}))}}class G{constructor(t,e,n,r,o){this.firstMonomers=t,this.secondMonomers=e,this.code=r,this.rules=o,this.root=i.divH([],{style:{width:"100%",overflow:"hidden",visibility:"visible"},classes:"monomer-cards"});const s=!t?.length,a=!e?.length;s&&(this.firstMonomers=t=["C","D","E","F","G"]),a&&(this.secondMonomers=e=["D","C","E","F","G"]),this.actionable=!0;const l=i.divH([],{style:{overflowX:"auto",width:"100%"}}),c=i.divH([],{style:{overflowX:"auto",width:"100%"}});this.resulting=i.divH([],{style:{overflowX:"auto",width:"100%",minHeight:"150px"}});const u=i.h2("First Monomer"+(s?" (Applied to all monomers, example list shown)":""),{style:{width:"100%"}}),h=i.h2("Second Monomer"+(a?" (Applied to all monomers, example list shown)":""),{style:{width:"100%"}}),d=i.divV([u,l,h,c,this.resulting]);this.cardsFirst=t.map((t=>new H(n.getMonomer("PEPTIDE",t),t))),this.cardsSecond=e.map((t=>new H(n.getMonomer("PEPTIDE",t),t))),this.cardsFirst.forEach((t=>{t.root.onclick=()=>{this.cardsFirst.forEach((t=>t.selected=!1)),t.selected=!0,this.firstCard=t,this.reset()},l.appendChild(t.root)})),this.cardsSecond.forEach((t=>{t.root.onclick=()=>{this.cardsSecond.forEach((t=>t.selected=!1)),t.selected=!0,this.secondCard=t,this.reset()},c.appendChild(t.root)})),this.cardsFirst[0].selected=!0,this.cardsSecond[0].selected=!0,this.firstCard=this.cardsFirst[0],this.secondCard=this.cardsSecond[0],this.root.appendChild(d)}async reset(){if(this.actionable){const t=[`${this.firstCard.monomer?.symbol}(${this.code})-A-A-A-A-${this.secondCard.monomer?.symbol}(${this.code})`],e=await(0,h.b2)(),[n,s,a]=(0,d.b)(t,this.rules,e),l=r.Column.fromType(r.COLUMN_TYPE.STRING,"helm",n.length).init((t=>n[t]));l.semType=r.SEMTYPE.MACROMOLECULE,l.meta.units=k.Hi.HELM,l.setTag(r.TAGS.CELL_RENDERER,"helm");const c=await(0,g.j)(),u=await(0,y.Q)(),p=await(0,f.A)(this.rules),b=l.temp;l.temp=b;const v=(await(0,m.m)(l,n,s,!0,!1,!1,p,c,u)).get(0),C=v&&o.chem.checkSmiles(v)?o.chem.drawMolecule(v,200,200):o.chem.drawMolecule(v??"",200,200);v&&(C.style.cursor="pointer",C.onclick=()=>{const t=window.innerWidth-200,e=window.innerHeight-200,n=o.chem.checkSmiles(v)?o.chem.drawMolecule(v,t,e):o.chem.drawMolecule(v??"",t,e);i.dialog({title:"Molecule"}).add(n).showModal(!0)},i.tooltip.bind(C,"Click to expand"));const x=i.divV([i.h2("Example Result:"),i.h2(t[0])],{style:{width:"200px"}});i.empty(this.resulting),this.resulting.append(i.divH([x,C],{style:{overflowX:"auto",width:"100%",minHeight:"150px"}}))}}render(){this.actionable&&(this.cardsFirst.forEach((t=>t.render())),this.cardsSecond.forEach((t=>t.render())))}}var V=n(4971);const U="System:AppData/SequenceTranslator/polytool-rules/",j="Polytool",q="code",W="firstMonomers",z="secondMonomers",Y="name",K="firstLinkingGroup",Q="secondLinkingGroup";class J extends c{constructor(t,e,n,r){super(t,e,n,r)}createInput(t,e){const n=super.createInput(t,e),o=i.icons.edit((async()=>{const e=await T.getInstance(t);r.Dialog.getOpenDialogs()?.filter((t=>t.root.contains(o))).forEach((t=>t.close())),await e.getAndAddView()}),"Edit rules");return n.addOptions(o),n}async getForm(){const t=await super.getForm();return this.processRulesForm(t),t}async processRulesForm(t){const e=Array.from(t.getElementsByTagName("label")??[]).filter((t=>t.textContent?.endsWith(".json")&&null!=t.parentElement));for(const t of e){const e=t.textContent.trim(),n=t.parentElement.getElementsByTagName("input")[0];i.tooltip.bind(n,i.wait((async()=>{var t;return(t=J.ruleDescriptions)[e]??(t[e]=(async()=>{try{const t=JSON.parse(await o.dapi.files.readAsText(`${U}/${e}`)),n=i.divV([i.h1(e)]),r=t.linkRules??[];if(r.length>0){n.appendChild(i.h3("Linkage Rules"));const t=i.table(r,(t=>[t.code?.toString()??"",X((t.firstMonomers??[]).join(", ")),X((t.secondMonomers??[]).join(", ")),t.firstLinkingGroup?.toString()??"",t.secondLinkingGroup?.toString()??""]),["Code","M1","M2","L1","L2"]);n.appendChild(t)}const s=t.reactionRules??[];if(s.length>0){n.appendChild(i.h3("Synthesis Rules"));const t=i.table(s,(t=>[t.code?.toString()??"",X((t.firstMonomers??[]).join(", ")),X((t.secondMonomers??[]).join(", ")),X(t.name??""),o.chem.drawMolecule(t.reaction?.split(">>")[1]??"",70,70)]),["Code","M1","M2","Name","Product"]);n.appendChild(t)}return n}catch(t){return u._package.logger.error(`Failed to load rule ${e}: ${t?.toString?.()}`),console.error(t),i.divText(`Failed to load rule ${e}`)}})()),await J.ruleDescriptions[e]})))}}}function X(t,e=30){return t.length<=e?t:`${t.substring(0,e)}...`}J.ruleDescriptions={};class Z{constructor(t,e,n,r){this.homodimerCode=t,this.heterodimerCode=e,this.linkRules=n,this.reactionRules=r}set homodimer(t){this.homodimerCode=t}set heterodimer(t){this.heterodimerCode=t}addLinkRules(t){for(let e=0;e<t.length;e++)this.linkRules.push(t[e])}addSynthesisRules(t){for(let e=0;e<t.length;e++)this.reactionRules.push(t[e])}getLinkRulesDf(){const t=this.linkRules.length,e=r.Column.int(q,t);e.setTag("friendlyName","Code");const n=r.Column.string(W,t);n.temp[".mm.cellRenderer.fontSize"]=16,n.setTag("friendlyName","First monomers"),n.semType=r.SEMTYPE.MACROMOLECULE,u.PackageFunctions.applyNotationProviderForCyclized(n,",");const o=r.Column.string(z,t);o.setTag("friendlyName","Second monomers"),o.temp[".mm.cellRenderer.fontSize"]=16,o.semType=r.SEMTYPE.MACROMOLECULE,u.PackageFunctions.applyNotationProviderForCyclized(o,",");const i=r.Column.int(K,t);i.setTag("friendlyName","First group");const s=r.Column.int(Q,t);s.setTag("friendlyName","Second group");for(let r=0;r<t;r++)e.set(r,this.linkRules[r].code),n.set(r,this.linkRules[r].firstMonomers.toString()),o.set(r,this.linkRules[r].secondMonomers.toString()),i.set(r,this.linkRules[r].firstLinkingGroup),s.set(r,this.linkRules[r].secondLinkingGroup);const a=r.DataFrame.fromColumns([e,n,o,i,s]);return{res:a,addNewRow:t=>{if(null!=t.row&&t.row<a.rowCount&&t.row>=0)e.set(t.row,t.code),n.set(t.row,t.firstMonomers),o.set(t.row,t.secondMonomers),i.set(t.row,t.firstLinkingGroup),s.set(t.row,t.secondLinkingGroup);else{const{code:e,firstMonomers:n,secondMonomers:r,firstLinkingGroup:o,secondLinkingGroup:i}=t;a.rows.addNew([e,n??"",r??"",o??1,i??2])}}}}async getLinkCards(){const t=this.linkRules.length,e=new Array(t),n=(await(0,V.pj)()).getMonomerLib();for(let r=0;r<t;r++)e[r]=new G(this.linkRules[r].firstMonomers,this.linkRules[r].secondMonomers,n,this.linkRules[r].code,this);return e}getSynthesisRulesDf(){const t=this.reactionRules.length,e=r.Column.int(q,t);e.setTag("friendlyName","Code");const n=r.Column.string(W,t);n.setTag("friendlyName","First monomers");const o=r.Column.string(z,t);o.setTag("friendlyName","Second monomers"),n.semType=r.SEMTYPE.MACROMOLECULE,n.temp[".mm.cellRenderer.fontSize"]=16,u.PackageFunctions.applyNotationProviderForCyclized(n,","),o.semType=r.SEMTYPE.MACROMOLECULE,o.temp[".mm.cellRenderer.fontSize"]=16,u.PackageFunctions.applyNotationProviderForCyclized(o,","),o.setTag(r.TAGS.CELL_RENDERER,"Sequence"),n.setTag(r.TAGS.CELL_RENDERER,"Sequence");const i=r.Column.string(Y,t);i.setTag("friendlyName","Name");const s=r.Column.string("firstReactant",t);s.setTag("friendlyName","First reactant");const a=r.Column.string("secondReactant",t);a.setTag("friendlyName","Second reactant");const l=r.Column.string("product",t);l.setTag("friendlyName","Product");for(let r=0;r<t;r++){e.set(r,this.reactionRules[r].code),n.set(r,this.reactionRules[r].firstMonomers.toString()),o.set(r,this.reactionRules[r].secondMonomers.toString()),i.set(r,this.reactionRules[r].name);const t=this.reactionRules[r].reaction.split(">>"),c=t[0].split(".");s.set(r,c[0]),a.set(r,c[1]),l.set(r,t[1])}s.semType=r.SEMTYPE.MOLECULE,a.semType=r.SEMTYPE.MOLECULE,l.semType=r.SEMTYPE.MOLECULE;const c=r.DataFrame.fromColumns([i,s,a,l,e,n,o]);return{df:c,addNewRow:t=>{if(null!=t.rowIndex&&t.rowIndex<c.rowCount&&t.rowIndex>=0)i.set(t.rowIndex,t.resultMonomerName),e.set(t.rowIndex,t.code),n.set(t.rowIndex,t.firstMonomers.join(",")),o.set(t.rowIndex,t.secondMonomers.join(",")),s.set(t.rowIndex,t.firstReactantSmiles),a.set(t.rowIndex,t.secondReactantSmiles),l.set(t.rowIndex,t.productSmiles);else{const{resultMonomerName:e,code:n,firstMonomers:r,secondMonomers:o,firstReactantSmiles:i,secondReactantSmiles:s,productSmiles:a}=t;c.rows.addNew([e,i,s,a,n,r.join(","),o.join(",")])}}}}setLinkRules(t){const e=t.rowCount,n=new Array(e),r=t.columns.byName(q),o=t.columns.byName(W),i=t.columns.byName(z),s=t.columns.byName(K),a=t.columns.byName(Q);for(let t=0;t<e;t++){const e=o.get(t).split(","),l=i.get(t).split(","),c={code:r.get(t),firstMonomers:""!==e[0]?e:[],secondMonomers:""!==l[0]?l:[],firstLinkingGroup:s.get(t),secondLinkingGroup:a.get(t)};n[t]=c}this.linkRules=n}setSynthesisRules(t){const e=t.rowCount,n=new Array(e),r=t.columns.byName(q),o=t.columns.byName(W),i=t.columns.byName(z),s=t.columns.byName(Y),a=t.columns.byName("firstReactant"),l=t.columns.byName("secondReactant"),c=t.columns.byName("product");for(let t=0;t<e;t++){const e=`${a.get(t)}.${l.get(t)}>>${c.get(t)}`,u=o.get(t).split(","),h=i.get(t).split(","),d={code:r.get(t),firstMonomers:""!==u[0]?u:[],secondMonomers:""!==h[0]?h:[],reaction:e,name:s.get(t)};n[t]=d}this.reactionRules=n}}async function tt(t){const e=new r.FileSource(U),n=new Z(null,null,[],[]);for(let r=0;r<t.length;r++){const o=await e.readAsText(t[r].replace(U,"")),i=JSON.parse(o);n.homodimer=i.homodimerCode,n.heterodimer=i.heterodimerCode,n.addLinkRules(i.linkRules),n.addSynthesisRules(i.reactionRules)}return n}function et(t){const e=t.firstMonomers.length*t.secondMonomers.length,n=new Array(e),r=new Array(e);let o=0;for(let e=0;e<t.firstMonomers.length;e++)for(let i=0;i<t.secondMonomers.length;i++)n[o]=t.firstMonomers[e],r[o]=t.secondMonomers[i],o++;return[n,r]}},5174:(t,e,n)=>{"use strict";n.d(e,{A:()=>u,T:()=>h});var r=n(6717),o=n(1296),i=n(9192),s=n(4328),a=n(1991),l=n.n(a),c=n(4971);async function u(t){const e=(await(0,c.pj)()).getMonomerLib(),n=await(0,r.j)(),o={};let i=[],a=[];for(let r=0;r<t.reactionRules.length;r++)try{[i,a]=h(n,e,t.reactionRules[r])}catch(t){i=[],a=[],console.error(t),s.shell.warning(t)}finally{for(let t=0;t<i.length;t++)null!=i[t]&&null!=a[t]&&(o[i[t]]=a[t])}const u={PEPTIDE:o};return e.override(u,"ST-PT-reactions."+l().repeat(1).map((()=>Math.floor(36*Math.random()).toString(36))).take(4).toArray().join(""))}function h(t,e,n){const r=n.reaction,o=n.name,s=n.firstMonomers.length+n.secondMonomers.length+1,a=n.reaction.split(">>"),l=a[0].split("."),c=new Array(s),u=new Array(s),h=new Array(s),m=p(t,r),g=`${l[0]}>>[C:1]C`,y=`${l[1]}>>[C:2]C`,b=p(t,g),v=p(t,y);let C=0;for(let r=0;r<n.firstMonomers.length;r++){const i=e.getMonomer("PEPTIDE",n.firstMonomers[r]);if(i&&i.molfile)try{const e=d(t,i.molfile,b,i.name);h[C]=e,c[C]=`${i.symbol}_${o}`}catch(t){console.error(t)}C++}for(let r=0;r<n.secondMonomers.length;r++){const i=e.getMonomer("PEPTIDE",n.secondMonomers[r]);if(i&&i.molfile)try{const e=d(t,i.molfile,v,i.name);h[C]=e,c[C]=`${i.symbol}_${o}`}catch(t){console.error(t)}C++}let x=null;a[1]=a[1].replace("[C:1]","[1*]").replace("[C:2]","[2*]").replace("[C:3]","[3*]");let w="";try{x=t.get_mol(a[1]),w=x?.get_molblock()}catch(t){const[e,n]=(0,i.AP)(t);throw console.error(`Can not assemble monomer '${o}': ${e}.`),t}finally{x?.delete()}h[C]=w,c[C]=o;for(let t=0;t<s-1;t++)h[t]&&(h[t]=h[t].replace(" 0.0000 0.0000 0.0000 C "," 0.0000 0.0000 0.0000 R# ").replace("M RGP 2","M RGP 3 2 3"));h[s-1]=function(t){const e=t.replace("M RAD","M RGP").replace("M ISO","M RGP").split("\n"),n=e.findIndex((t=>t.startsWith("M RGP"))),r=Number(e[n].substring(9,13)),o=Number(e[n].substring(17,21)),i=Number(e[n].substring(13,17)),s=Number(e[n].substring(21,25));e[n]=e[n].substring(0,13)+` ${i}`+e[n].substring(17,21)+` ${s}`,e[3+r]=e[3+r].substring(0,30)+" R# 0 0 0 0 0 0 0 0 0 0 0 0",e[3+o]=e[3+o].substring(0,30)+" R# 0 0 0 0 0 0 0 0 0 0 0 0";let a="";for(let t=0;t<e.length;t++)a+=e[t]+"\n";return a}(h[s-1]);for(let t=0;t<s;t++){const e=t==s-1;if(!h[t]||!c[t])continue;const n={symbol:c[t],name:c[t],molfile:h[t],author:"",id:0,rgroups:f(e),smiles:"",polymerType:"PEPTIDE",monomerType:"Backbone",createDate:null};n.meta=Object.assign(n.meta??{},{colors:{default:{line:"#2083D5",text:"#2083D5",background:"#F2F2F5"}}}),c[t]=c[t],u[t]=n}return m.delete(),b.delete(),v.delete(),[c,u]}function d(t,e,n,r){let o=null,s=null,a=null,l=null,c="";try{o=new t.MolList,s=t.get_mol(e),o.append(s),a=n.run_reactants(o,1),l=a.get(0).next(),c=l?.get_molblock()}catch(t){const[e,n]=(0,i.AP)(t);throw console.error(`Can not assemble monomer '${r}': ${e}.`),t}finally{o?.delete(),s?.delete(),a?.delete(),l?.delete()}return c}function p(t,e){let n=null;try{if(n=t.get_rxn(e),!n)throw new o.J5(e)}catch(t){n?.delete();const[r,o]=(0,i.AP)(t);throw console.error(`Can not assemble monomer '${e}': ${r}.`),t}return n}function f(t){if(t){const t=new Array(2),e={capGroupSMILES:"[*:1][H]",alternateId:"R1-H",capGroupName:"H",label:"R1"},n={capGroupSMILES:"[*:2][H]",alternateId:"R2-H",capGroupName:"H",label:"R2"};return t[0]=e,t[1]=n,t}return[{capGroupSMILES:"[*:3][H]",alternateId:"R3-H",capGroupName:"H",label:"R3"}]}},3309:(t,e,n)=>{"use strict";n.d(e,{BG:()=>y,HL:()=>A,Ii:()=>C,KS:()=>h,PI:()=>o,Qk:()=>c,XB:()=>m,ah:()=>d,aj:()=>u,j7:()=>l,jp:()=>T,k5:()=>f,u8:()=>r,xD:()=>E,yw:()=>v,z9:()=>b});const r=1e6,o={Zip:"Zip",Cartesian:"Cartesian"},i=String.raw`\[(?:(\d+)\*|\*:(\d+)|\*(\d+)|R(\d+)|R:(\d+))\]`;function s(){return new RegExp(i,"g")}function a(t){for(const e of t)if(void 0!==e)return parseInt(e,10);return null}function l(t){return t.replace(s(),((t,e,n,r,o,i)=>{const s=a([e,n,r,o,i]);return null===s?t:`[*:${s}]`}))}function c(t){const e=new Set;for(const n of t.matchAll(s())){const t=a([n[1],n[2],n[3],n[4],n[5]]);null!==t&&e.add(t)}return[...e].sort(((t,e)=>t-e))}function u(t,e){return t.replace(s(),(()=>`[*:${e}]`))}function h(t,e,n){const r=(t??"").trim();if(""===r)return{smiles:"",originalSmiles:t,rNumbers:[],id:e,error:"Empty SMILES"};const o=l(r),i=c(o);if(0===i.length)return{smiles:o,originalSmiles:t,rNumbers:i,id:e,error:"Core must contain at least one R group"};if(n){const r=p(o,n);if(r)return{smiles:o,originalSmiles:t,rNumbers:i,id:e,error:`Invalid SMILES: ${r}`}}return{smiles:o,originalSmiles:t,rNumbers:i,id:e}}function d(t,e,n,r){const o=(t??"").trim();if(""===o)return{smiles:"",originalSmiles:t,rNumber:e,id:n,error:"Empty SMILES"};const i=l(o),s=c(i);if(0===s.length)return{smiles:i,originalSmiles:t,rNumber:e,id:n,error:"R-group must contain exactly one R label (found none)"};if(s.length>1)return{smiles:i,originalSmiles:t,rNumber:e,id:n,sourceRNumber:s[0],error:`R-group must contain exactly one R label (found ${s.length}: ${s.map((t=>"R"+t)).join(", ")})`};const a=s[0],h=u(i,e);if(r){const o=p(h,r);if(o)return{smiles:h,originalSmiles:t,rNumber:e,id:n,sourceRNumber:a,error:`Invalid SMILES: ${o}`}}return{smiles:h,originalSmiles:t,rNumber:e,id:n,sourceRNumber:a}}function p(t,e){let n=null;try{return n=e.get_mol(t),n&&n.is_valid()?null:"failed to parse"}catch(t){return(t?.message??String(t)).toString().slice(0,120)}finally{n?.delete()}}function f(t,e,n){const r=[],i=[];for(const n of t.rNumbers){const t=e.get(n);t&&0!==t.length?i.push(t.filter((t=>!t.error)).length):r.push(n)}if(r.length>0)return{count:0,uncovered:r};if(i.some((t=>0===t)))return{count:0,uncovered:r};if(n===o.Zip){if(0===i.length)return{count:0,uncovered:r};const t=i[0];return{count:i.every((e=>e===t))?t:-1,uncovered:r}}return{count:i.reduce(((t,e)=>t*e),1),uncovered:r}}function m(t){const e=t.maxResults??r,n=[];let i=0;const s=t.cores.filter((t=>!t.error));0===s.length&&n.push("No valid cores provided.");const a=new Set;for(const t of s)for(const e of t.rNumbers)a.add(e);const l=new Map;for(const e of a){const r=(t.rGroups.get(e)??[]).filter((t=>!t.error)).length;l.set(e,r),0===r&&n.push(`No valid R-group provided for R${e}.`)}if(t.mode===o.Zip){const t=[...l.values()].filter((t=>t>0));t.length>1&&!t.every((e=>e===t[0]))&&n.push(`Zip mode requires every R-group list to have the same number of entries. Got ${[...l.entries()].map((([t,e])=>`R${t}=${e}`)).join(", ")}.`)}for(const r of s){const{count:o,uncovered:s}=f(r,t.rGroups,t.mode);if(s.length>0)n.push(`Core "${r.id}" references uncovered R-number${s.length>1?"s":""}: ${s.map((t=>"R"+t)).join(", ")}.`);else if(!(o<0)&&(i+=o,i>e))break}const c=i>e;return c&&n.push(`Too many combinations (> ${e.toLocaleString()}). Reduce the number of cores or R-groups, or switch to Zip mode.`),{ok:0===n.length,errors:n,predictedCount:i,overCap:c}}function g(t,e){if(0===e.size)return null;const n=b(t),r=new Map;for(const[t,n]of e)r.set(t,b(n));const o=C([n,...r.values()],e.size);if(o.length<e.size)return null;const i=new Map;let s=0;for(const t of e.keys())i.set(t,x(o[s++]));let a=n;for(const[t,e]of i)a=v(a,t,e);const l=[];for(const[t,e]of r)l.push(v(e,t,i.get(t)));return[a,...l].join(".")}function y(t,e,n){const r=g(t,e);if(!r)return null;let o=null;try{return o=n.get_mol(r),o&&o.is_valid()?o.get_smiles():null}catch{return null}finally{o?.delete()}}function b(t){const e=t.match(/^(\[\*:\d+\])([-=#:/\\])?(\[[^\]]+\]|Br|Cl|[BCNOPSFIbcnops])(.*)$/s);if(!e)return t;const[,n,r,o,i]=e;return`${o}(${r??""}${n})${i}`}function v(t,e,n){const r=`[*:${e}]`,o=new RegExp(`\\(\\s*\\[\\*:${e}\\]\\s*\\)`,"g");return(t=t.replace(o,n)).split(r).join(n)}function C(t,e){const n=new Set;for(const e of t){const t=e.replace(/\[[^\]]*\]/g,"");for(const e of t.matchAll(/%(\d{2})/g))n.add(parseInt(e[1],10));for(const e of t){const t=e.charCodeAt(0)-48;t>=0&&t<=9&&n.add(t)}}const r=[];for(let t=1;t<100&&r.length<e;t++)n.has(t)||r.push(t);return r}function x(t){if(t<0||t>99)throw new Error(`Ring digit out of range: ${t}`);return t<=9?`${t}`:`%${t.toString().padStart(2,"0")}`}function*w(t){const e=t.maxResults??r;let n=0;for(const r of t.cores){if(r.error)continue;const i=r.rNumbers,s=[];let a=!1;for(const e of i){const n=(t.rGroups.get(e)??[]).filter((t=>!t.error));if(0===n.length){a=!0;break}s.push(n)}if(!a)if(t.mode===o.Zip){if(0===s.length)continue;const t=s[0].length;if(!s.every((e=>e.length===t)))continue;for(let o=0;o<t;o++){const t=new Map;for(let e=0;e<i.length;e++)t.set(i[e],s[e][o]);if(yield{core:r,assignment:t},++n>=e)return}}else{const t=new Array(s.length).fill(0);for(;;){const o=new Map;for(let e=0;e<i.length;e++)o.set(i[e],s[e][t[e]]);if(yield{core:r,assignment:o},++n>=e)return;let a=t.length-1;for(;a>=0&&(t[a]++,!(t[a]<s[a].length));)t[a]=0,a--;if(a<0)break}}}}function A(t,e){if(!m(t).ok)return null;const n=[];for(const{core:r,assignment:o}of w(t)){const t=new Map;for(const[e,n]of o)t.set(e,n.smiles);const i=y(r.smiles,t,e);if(!i)continue;const s=new Map;for(const[t,e]of o)s.set(t,e.originalSmiles);n.push({smiles:i,coreSmiles:r.originalSmiles,rGroupSmilesByNum:s})}return n}function T(t){if(!m(t).ok)return null;const e=[];for(const{core:n,assignment:r}of w(t)){const t=new Map;for(const[e,n]of r)t.set(e,n.smiles);const o=g(n.smiles,t);if(!o)continue;const i=new Map;for(const[t,e]of r)i.set(t,e.originalSmiles);e.push({smiles:o,coreSmiles:n.originalSmiles,rGroupSmilesByNum:i})}return e}function E(t,e,n=Math.random){const r=[];let o=0;for(const{core:i,assignment:s}of w(t)){const t=new Map;for(const[e,n]of s)t.set(e,n.smiles);const a=g(i.smiles,t);if(!a)continue;const l=new Map;for(const[t,e]of s)l.set(t,e.originalSmiles);const c={smiles:a,coreSmiles:i.originalSmiles,rGroupSmilesByNum:l};if(r.length<e)r.push(c);else{const t=Math.floor(n()*(o+1));t<e&&(r[t]=c)}o++}return r}},3820:(t,e,n)=>{"use strict";n.d(e,{d:()=>o,o:()=>s});var r=n(1296);const o="PEPTIDE1{R.[Aca].T.G.H.F.G.A.A.Y.P.E.[meI]}$$$$";function i(t,e,n,r){const o=new Array(r.length*(n-e+1));for(let i=0;i<r.length;++i){const s=n-e+1;for(let n=0;n<s;++n){const a=e+n,l=r[i],c=o[i*s+n]=t.clone(),u=c.atoms[a].elem;c.atoms[a].elem=l;const h=u?.length>1?`[${u}]`:u,d=l?.length>1?`[${l}]`:l;c.name=`${t.name}-${h}${a+1}${d}`}}return o}function s(t,e,n){const o=new JSDraw2.MolHandler,s=new org.helm.webeditor.Plugin(o);org.helm.webeditor.IO.parseHelm(s,t,new JSDraw2.Point(0,0),void 0);const a=o.m;a.name=e;let l=[];if(n.placeholders)switch(n.type){case r.aK.Single:l=function(t,e){return e.map((e=>i(t,e.position,e.position,e.monomers))).reduce(((t,e)=>t.concat(e)),[])}(o.m,n.placeholders);break;case r.aK.Parallel:l=function(t,e){if(0===e.length)return[];const n=e[0].monomers.length;for(const t of e)if(t.monomers.length!==n)throw new Error("Parallel enumeration requires all positions to have the same number of monomers");const r=new Array(n);for(let o=0;o<n;o++){const n=t.clone(),i=[];for(const t of e){const e=t.position,r=t.monomers[o],s=n.atoms[e].elem;n.atoms[e].elem=r;const a=s?.length>1?`[${s}]`:s,l=r?.length>1?`[${r}]`:r;i.push(`${a}${e+1}${l}`)}n.name=`${t.name}-${i.join("-")}`,r[o]=n}return r}(o.m,n.placeholders);break;case r.aK.Matrix:l=function(t,e){let n=[t];for(const t of e){const e=n.map((e=>i(e,t.position,t.position,t.monomers)));n=e.reduce(((t,e)=>t.concat(e)),[])}return n}(o.m,n.placeholders)}let c=[];n.breadthPlaceholders&&(c=function(t,e){if(0==e.length)return[];let n=[t];for(const t of e){const e=n.map((e=>i(e,t.start,t.end,t.monomers)));n=e.reduce(((t,e)=>t.concat(e)),[])}return n}(o.m,n.breadthPlaceholders)),l=l.concat(c),n.keepOriginal&&(l=[a,...l]);const u=l.map((t=>[org.helm.webeditor.IO.getHelm(t),t.name]));return u}},1296:(t,e,n)=>{"use strict";var r;n.d(e,{J5:()=>o,aK:()=>r}),function(t){t.Single="single",t.Parallel="parallel",t.Matrix="matrix"}(r||(r={})),Error;class o extends Error{constructor(t,e){super(`Invalid reaction '${t}'.`),this.type="InvalidReactionError"}}},6082:t=>{"use strict";t.exports=DG},4328:t=>{"use strict";t.exports=grok},7389:t=>{"use strict";t.exports=ui},1991:t=>{"use strict";t.exports=wu}},e={};function n(r){var o=e[r];if(void 0!==o)return o.exports;var i=e[r]={id:r,loaded:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}n.m=t,n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.u=t=>t+".js",n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.nmd=t=>(t.paths=[],t.children||(t.children=[]),t),(()=>{var t;n.g.importScripts&&(t=n.g.location+"");var e=n.g.document;if(!t&&e&&(e.currentScript&&"SCRIPT"===e.currentScript.tagName.toUpperCase()&&(t=e.currentScript.src),!t)){var r=e.getElementsByTagName("script");if(r.length)for(var o=r.length-1;o>-1&&(!t||!/^http(s?):/.test(t));)t=r[o--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=t})(),n.b=document.baseURI||self.location.href,n.nc=void 0;var r={};(()=>{"use strict";n.r(r),n.d(r,{_package:()=>yt,initAutoTests:()=>vt,test:()=>bt,tests:()=>h});var t=n(6082);n(9982);const e=DG.DataFrame.fromCsv('countries,fasta,smiles,molregno,LON,Zip Code,Street Address Line 1,ImageUrl,user_id,error_message,xray,flag,magnitude,CS-id,pdb_id,accel_a,time_offset,chart,fit,Questions,empty_number,empty_string\nBelgium,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C(=O)OCCCc1cccnc1)c2cccc(c2)C(=O)c3ccccc3,1480014,36.276729583740234,995042300,14016 ROUTE 31W,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,1,1,1QBS,1,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.497360340644872, 1.7058694986686864, 5.278052678195135, 0.16000320889028383],""points"":[{""x"":0.10000000149011612,""y"":2.374499797821045},{""x"":0.6000000238418579,""y"":2.6242473125457764},{""x"":1.100000023841858,""y"":2.367267608642578},{""x"":1.600000023841858,""y"":2.6723148822784424},{""x"":2.0999999046325684,""y"":2.6537344455718994},{""x"":2.5999999046325684,""y"":2.3651671409606934},{""x"":3.0999999046325684,""y"":2.5654284954071045},{""x"":3.5999999046325684,""y"":2.4160959720611572},{""x"":4.099999904632568,""y"":2.286726713180542},{""x"":4.599999904632568,""y"":2.5100042819976807},{""x"":5.099999904632568,""y"":1.6676985025405884},{""x"":5.599999904632568,""y"":0.680136501789093},{""x"":6.099999904632568,""y"":0.3391543924808502},{""x"":6.599999904632568,""y"":0.09038983285427094},{""x"":7.099999904632568,""y"":0.19802775979042053}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[7.525235855508179, 1.3186911876809984, 5.335672608564294, 0.7860743343958098],""points"":[{""x"":0.10000000149011612,""y"":7.988070487976074},{""x"":0.6000000238418579,""y"":7.018453121185303},{""x"":1.100000023841858,""y"":8.115279197692871},{""x"":1.600000023841858,""y"":7.486658096313477},{""x"":2.0999999046325684,""y"":7.396438121795654},{""x"":2.5999999046325684,""y"":7.477052211761475},{""x"":3.0999999046325684,""y"":6.913095474243164},{""x"":3.5999999046325684,""y"":8.01385498046875},{""x"":4.099999904632568,""y"":6.985900402069092},{""x"":4.599999904632568,""y"":6.970335960388184},{""x"":5.099999904632568,""y"":5.448817253112793},{""x"":5.599999904632568,""y"":2.5534818172454834},{""x"":6.099999904632568,""y"":1.893947958946228},{""x"":6.599999904632568,""y"":0.6340042352676392},{""x"":7.099999904632568,""y"":0.8403874039649963}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,100,abc\nBurundi,MDYKETLLMPKTDFPMRGGLPNKEPQIQEKW,COc1ccc2cc(ccc2c1)C(C)C(=O)Oc3ccc(C)cc3OC,1480015,36.276729583740234,995073444,80 STATE HIGHWAY 310,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,2,2,1ZP8,2,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.431460753103398, 2.1691498799246745, 5.266445597102774, 0.7825762827017926],""points"":[{""x"":0.10000000149011612,""y"":4.751083850860596},{""x"":0.6000000238418579,""y"":4.203000068664551},{""x"":1.100000023841858,""y"":4.415858745574951},{""x"":1.600000023841858,""y"":4.68414306640625},{""x"":2.0999999046325684,""y"":4.198400974273682},{""x"":2.5999999046325684,""y"":4.179222106933594},{""x"":3.0999999046325684,""y"":4.638473987579346},{""x"":3.5999999046325684,""y"":4.708553314208984},{""x"":4.099999904632568,""y"":4.291589260101318},{""x"":4.599999904632568,""y"":4.038082599639893},{""x"":5.099999904632568,""y"":3.4349939823150635},{""x"":5.599999904632568,""y"":1.2194708585739136},{""x"":6.099999904632568,""y"":1.1920831203460693},{""x"":6.599999904632568,""y"":0.5352635979652405},{""x"":7.099999904632568,""y"":0.3346920311450958}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.339458017970126, -1.0734184310171178, 4.746332950550934, 0.2482416857595658],""points"":[{""x"":0.10000000149011612,""y"":0.2139337658882141},{""x"":0.6000000238418579,""y"":0.4269562065601349},{""x"":1.100000023841858,""y"":0.2441573292016983},{""x"":1.600000023841858,""y"":0.146635964512825},{""x"":2.0999999046325684,""y"":0.08818462491035461},{""x"":2.5999999046325684,""y"":0.2560656666755676},{""x"":3.0999999046325684,""y"":0.42434045672416687},{""x"":3.5999999046325684,""y"":0.37111231684684753},{""x"":4.099999904632568,""y"":0.5581737160682678},{""x"":4.599999904632568,""y"":1.183590054512024},{""x"":5.099999904632568,""y"":1.5629843473434448},{""x"":5.599999904632568,""y"":2.3211288452148438},{""x"":6.099999904632568,""y"":2.229961633682251},{""x"":6.599999904632568,""y"":2.2560226917266846},{""x"":7.099999904632568,""y"":2.2142398357391357}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCameroon,MIEVFLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL,COc1ccc2cc(ccc2c1)C(C)C(=O)OCCCc3cccnc3,1480016,36.26095962524414,995153596,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,3,3,2BDJ,3,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.6760652578642325, 0.9046956320756703, 5.651408971856738, 0.07738846012184185],""points"":[{""x"":0.10000000149011612,""y"":4.32425594329834},{""x"":0.6000000238418579,""y"":4.668442249298096},{""x"":1.100000023841858,""y"":4.379785060882568},{""x"":1.600000023841858,""y"":5.0345139503479},{""x"":2.0999999046325684,""y"":4.878653526306152},{""x"":2.5999999046325684,""y"":4.3451313972473145},{""x"":3.0999999046325684,""y"":4.336992263793945},{""x"":3.5999999046325684,""y"":5.037430286407471},{""x"":4.099999904632568,""y"":5.0092692375183105},{""x"":4.599999904632568,""y"":4.151902675628662},{""x"":5.099999904632568,""y"":3.4066951274871826},{""x"":5.599999904632568,""y"":2.3732759952545166},{""x"":6.099999904632568,""y"":1.673728108406067},{""x"":6.599999904632568,""y"":0.48574790358543396},{""x"":7.099999904632568,""y"":0.2783052325248718}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.938395863010111, -1.4658480661392117, 5.462702751996584, 0.3473139023615039],""points"":[{""x"":0.10000000149011612,""y"":0.4941710829734802},{""x"":0.6000000238418579,""y"":0.15323974192142487},{""x"":1.100000023841858,""y"":0.46373432874679565},{""x"":1.600000023841858,""y"":0.3370431363582611},{""x"":2.0999999046325684,""y"":0.5179030299186707},{""x"":2.5999999046325684,""y"":0.27899765968322754},{""x"":3.0999999046325684,""y"":0.22075064480304718},{""x"":3.5999999046325684,""y"":0.5789918899536133},{""x"":4.099999904632568,""y"":0.21169911324977875},{""x"":4.599999904632568,""y"":0.27857646346092224},{""x"":5.099999904632568,""y"":1.0906332731246948},{""x"":5.599999904632568,""y"":1.8520300388336182},{""x"":6.099999904632568,""y"":2.7177059650421143},{""x"":6.599999904632568,""y"":2.8680918216705322},{""x"":7.099999904632568,""y"":3.2413077354431152}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCanada,MMELVLKTIIGPIVVGVVLRIVDKWLNKDK,CC(C(=O)NCCS)c1cccc(c1)C(=O)c2ccccc2,1480017,36.26095962524414,99515,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,4,4,1IAN,4,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[0.8597390975430008, 1.0957625732481946, 5.260537067987958, 0.07974187998177736],""points"":[{""x"":0.10000000149011612,""y"":0.8190152645111084},{""x"":0.6000000238418579,""y"":0.8421689867973328},{""x"":1.100000023841858,""y"":0.8740922212600708},{""x"":1.600000023841858,""y"":0.8924275040626526},{""x"":2.0999999046325684,""y"":0.8249067664146423},{""x"":2.5999999046325684,""y"":0.9327669143676758},{""x"":3.0999999046325684,""y"":0.8522974252700806},{""x"":3.5999999046325684,""y"":0.8174492716789246},{""x"":4.099999904632568,""y"":0.8394647240638733},{""x"":4.599999904632568,""y"":0.7139387726783752},{""x"":5.099999904632568,""y"":0.5561167597770691},{""x"":5.599999904632568,""y"":0.3276226818561554},{""x"":6.099999904632568,""y"":0.12479474395513535},{""x"":6.599999904632568,""y"":0.13006797432899475},{""x"":7.099999904632568,""y"":0.059702079743146896}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.760930219582546, 1.6591793293833013, 4.667155929720851, 0.7858109544121652],""points"":[{""x"":0.10000000149011612,""y"":6.156993389129639},{""x"":0.6000000238418579,""y"":5.236701965332031},{""x"":1.100000023841858,""y"":6.010560512542725},{""x"":1.600000023841858,""y"":5.495512962341309},{""x"":2.0999999046325684,""y"":6.087770462036133},{""x"":2.5999999046325684,""y"":5.79986572265625},{""x"":3.0999999046325684,""y"":5.597546577453613},{""x"":3.5999999046325684,""y"":5.520902156829834},{""x"":4.099999904632568,""y"":5.360654354095459},{""x"":4.599999904632568,""y"":3.5539746284484863},{""x"":5.099999904632568,""y"":1.577236294746399},{""x"":5.599999904632568,""y"":1.0001264810562134},{""x"":6.099999904632568,""y"":0.9305797815322876},{""x"":6.599999904632568,""y"":0.6033638715744019},{""x"":7.099999904632568,""y"":0.4203685522079468}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nColombia,MDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN,FC(F)(F)c1ccc(OC2CCNCC2)cc1,1480029,36.3309440612793,995152050,1 COURT HOUSE SQUARE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,5,5,4UJ1,5,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[6.4995088314153655, 2.4270351004539914, 5.178659535348579, 0.625653346241577],""points"":[{""x"":0.10000000149011612,""y"":6.496231555938721},{""x"":0.6000000238418579,""y"":6.42543363571167},{""x"":1.100000023841858,""y"":7.040063858032227},{""x"":1.600000023841858,""y"":6.1115403175354},{""x"":2.0999999046325684,""y"":6.680728435516357},{""x"":2.5999999046325684,""y"":6.406774520874023},{""x"":3.0999999046325684,""y"":6.611269474029541},{""x"":3.5999999046325684,""y"":5.889094352722168},{""x"":4.099999904632568,""y"":6.75344705581665},{""x"":4.599999904632568,""y"":6.361435890197754},{""x"":5.099999904632568,""y"":4.1666975021362305},{""x"":5.599999904632568,""y"":1.172118902206421},{""x"":6.099999904632568,""y"":0.801048994064331},{""x"":6.599999904632568,""y"":0.4640021026134491},{""x"":7.099999904632568,""y"":0.0010357667924836278}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[1.4734381347446401, 1.1649805188074196, 4.82958608866421, 0.09500545496710007],""points"":[{""x"":0.10000000149011612,""y"":1.5279096364974976},{""x"":0.6000000238418579,""y"":1.3559974431991577},{""x"":1.100000023841858,""y"":1.5246378183364868},{""x"":1.600000023841858,""y"":1.5567657947540283},{""x"":2.0999999046325684,""y"":1.4114240407943726},{""x"":2.5999999046325684,""y"":1.4045010805130005},{""x"":3.0999999046325684,""y"":1.4769829511642456},{""x"":3.5999999046325684,""y"":1.4875500202178955},{""x"":4.099999904632568,""y"":1.2991987466812134},{""x"":4.599999904632568,""y"":0.922961413860321},{""x"":5.099999904632568,""y"":0.6520044803619385},{""x"":5.599999904632568,""y"":0.15350978076457977},{""x"":6.099999904632568,""y"":0.1078903079032898},{""x"":6.599999904632568,""y"":0.17276449501514435},{""x"":7.099999904632568,""y"":0.14066608250141144}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCosta Rica,MKSTKEEIQTIKTLLKDSRTAKYHKRLQIVL,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCCc3ccccc3,1480018,36.3309440612793,995084218,4041 SOUTHWESTERN BLVD,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,6,6,2BPW,6,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.4833641843311227, -1.8945978742090062, 4.671127708092568, 0.24159861311815153],""points"":[{""x"":0.10000000149011612,""y"":0.0969524160027504},{""x"":0.6000000238418579,""y"":0.028483040630817413},{""x"":1.100000023841858,""y"":0.22087176144123077},{""x"":1.600000023841858,""y"":0.0068915546871721745},{""x"":2.0999999046325684,""y"":0.4305879771709442},{""x"":2.5999999046325684,""y"":0.44774115085601807},{""x"":3.0999999046325684,""y"":0.45346319675445557},{""x"":3.5999999046325684,""y"":0.2370593100786209},{""x"":4.099999904632568,""y"":0.4657953977584839},{""x"":4.599999904632568,""y"":1.155200719833374},{""x"":5.099999904632568,""y"":2.2294070720672607},{""x"":5.599999904632568,""y"":2.4311530590057373},{""x"":6.099999904632568,""y"":2.33846116065979},{""x"":6.599999904632568,""y"":2.608201026916504},{""x"":7.099999904632568,""y"":2.8136143684387207}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.224573521642033, 1.4454033924198528, 5.6014197746076535, 0.2823216054197577],""points"":[{""x"":0.10000000149011612,""y"":4.95027494430542},{""x"":0.6000000238418579,""y"":5.1754679679870605},{""x"":1.100000023841858,""y"":5.276752948760986},{""x"":1.600000023841858,""y"":5.589294910430908},{""x"":2.0999999046325684,""y"":5.616994857788086},{""x"":2.5999999046325684,""y"":5.120813846588135},{""x"":3.0999999046325684,""y"":5.340766906738281},{""x"":3.5999999046325684,""y"":4.876471042633057},{""x"":4.099999904632568,""y"":4.94999361038208},{""x"":4.599999904632568,""y"":5.162564754486084},{""x"":5.099999904632568,""y"":4.399557590484619},{""x"":5.599999904632568,""y"":2.7977969646453857},{""x"":6.099999904632568,""y"":1.0229872465133667},{""x"":6.599999904632568,""y"":0.48275601863861084},{""x"":7.099999904632568,""y"":0.10408931970596313}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCuba,MHAILRYFIRRLFYHIFYKIYSLISKKHQSLPSDVRQF,COc1ccc2c(c1)c(CC(=O)N3CCCC3C(=O)Oc4ccc(C)cc4OC)c(C)n2C(=O)c5ccc(Cl)cc5,1480019,36.33115768432617,995081928,1227 US HIGHWAY 11,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,7,7,1QBS,7,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.320838679713925, -1.2421619987316728, 4.831325425225256, 0.3236011098403072],""points"":[{""x"":0.10000000149011612,""y"":0.3727470338344574},{""x"":0.6000000238418579,""y"":0.12365014106035233},{""x"":1.100000023841858,""y"":0.48422467708587646},{""x"":1.600000023841858,""y"":0.2264465093612671},{""x"":2.0999999046325684,""y"":0.16821794211864471},{""x"":2.5999999046325684,""y"":0.3879014551639557},{""x"":3.0999999046325684,""y"":0.5470244884490967},{""x"":3.5999999046325684,""y"":0.3419053554534912},{""x"":4.099999904632568,""y"":0.7655120491981506},{""x"":4.599999904632568,""y"":1.2346516847610474},{""x"":5.099999904632568,""y"":2.453336715698242},{""x"":5.599999904632568,""y"":2.9565491676330566},{""x"":6.099999904632568,""y"":3.335299491882324},{""x"":6.599999904632568,""y"":3.240290880203247},{""x"":7.099999904632568,""y"":3.1107218265533447}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.6401853521511094, 1.26211588875013, 5.399028074402744, 0.5089580830068091],""points"":[{""x"":0.10000000149011612,""y"":3.8585598468780518},{""x"":0.6000000238418579,""y"":3.6077206134796143},{""x"":1.100000023841858,""y"":3.855252265930176},{""x"":1.600000023841858,""y"":3.619039297103882},{""x"":2.0999999046325684,""y"":3.839388370513916},{""x"":2.5999999046325684,""y"":3.335283041000366},{""x"":3.0999999046325684,""y"":3.571141481399536},{""x"":3.5999999046325684,""y"":3.4155046939849854},{""x"":4.099999904632568,""y"":3.7316646575927734},{""x"":4.599999904632568,""y"":3.0680155754089355},{""x"":5.099999904632568,""y"":2.891066551208496},{""x"":5.599999904632568,""y"":1.6022753715515137},{""x"":6.099999904632568,""y"":0.7652576565742493},{""x"":6.599999904632568,""y"":0.6875326037406921},{""x"":7.099999904632568,""y"":0.5828871726989746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nItaly,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO[N+](=O)[O-],1480020,36.33115768432617,99502,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,8,8,1ZP8,8,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.293592105923809, 1.3781586549141835, 5.1025898038676605, 0.03493851245291291],""points"":[{""x"":0.10000000149011612,""y"":2.1287283897399902},{""x"":0.6000000238418579,""y"":2.267972230911255},{""x"":1.100000023841858,""y"":2.398442506790161},{""x"":1.600000023841858,""y"":2.5130622386932373},{""x"":2.0999999046325684,""y"":2.3255116939544678},{""x"":2.5999999046325684,""y"":2.127340793609619},{""x"":3.0999999046325684,""y"":2.47259783744812},{""x"":3.5999999046325684,""y"":2.131181478500366},{""x"":4.099999904632568,""y"":2.090421438217163},{""x"":4.599999904632568,""y"":2.02299165725708},{""x"":5.099999904632568,""y"":1.1105059385299683},{""x"":5.599999904632568,""y"":0.4494485855102539},{""x"":6.099999904632568,""y"":0.1375635862350464},{""x"":6.599999904632568,""y"":0.036351121962070465},{""x"":7.099999904632568,""y"":0.1619771122932434}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.953125499439879, 1.2528620255306528, 5.187637440149802, 0.3110348753260886],""points"":[{""x"":0.10000000149011612,""y"":5.6585283279418945},{""x"":0.6000000238418579,""y"":5.911152362823486},{""x"":1.100000023841858,""y"":5.924920082092285},{""x"":1.600000023841858,""y"":5.8469438552856445},{""x"":2.0999999046325684,""y"":5.929472923278809},{""x"":2.5999999046325684,""y"":6.190037727355957},{""x"":3.0999999046325684,""y"":6.236179828643799},{""x"":3.5999999046325684,""y"":6.141019344329834},{""x"":4.099999904632568,""y"":5.295210838317871},{""x"":4.599999904632568,""y"":5.265801906585693},{""x"":5.099999904632568,""y"":3.3722851276397705},{""x"":5.599999904632568,""y"":1.8299226760864258},{""x"":6.099999904632568,""y"":0.32690900564193726},{""x"":6.599999904632568,""y"":0.6274543404579163},{""x"":7.099999904632568,""y"":0.8441857099533081}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nRwanda,MPNSEPASLLELFNSIATQGELVRSLKAGNASK,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO,1480021,36.33137130737305,995037247,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,9,9,2BDJ,9,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.8209972202654474, 1.3779216716448506, 5.299882228439686, 0.06040645519069608],""points"":[{""x"":0.10000000149011612,""y"":3.7821109294891357},{""x"":0.6000000238418579,""y"":3.542433023452759},{""x"":1.100000023841858,""y"":3.7008674144744873},{""x"":1.600000023841858,""y"":3.717301607131958},{""x"":2.0999999046325684,""y"":4.024452209472656},{""x"":2.5999999046325684,""y"":4.013899326324463},{""x"":3.0999999046325684,""y"":3.945094347000122},{""x"":3.5999999046325684,""y"":3.866621971130371},{""x"":4.099999904632568,""y"":3.7461626529693604},{""x"":4.599999904632568,""y"":3.3454740047454834},{""x"":5.099999904632568,""y"":2.61944317817688},{""x"":5.599999904632568,""y"":0.999405026435852},{""x"":6.099999904632568,""y"":0.46259793639183044},{""x"":6.599999904632568,""y"":0.054134611040353775},{""x"":7.099999904632568,""y"":0.05711187422275543}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.6318079657726035, 1.8495493770000595, 5.391793312471116, 0.17060707587348442],""points"":[{""x"":0.10000000149011612,""y"":5.458079814910889},{""x"":0.6000000238418579,""y"":5.554427146911621},{""x"":1.100000023841858,""y"":5.799983024597168},{""x"":1.600000023841858,""y"":5.364140033721924},{""x"":2.0999999046325684,""y"":5.864485740661621},{""x"":2.5999999046325684,""y"":5.4509806632995605},{""x"":3.0999999046325684,""y"":5.702574729919434},{""x"":3.5999999046325684,""y"":5.7314534187316895},{""x"":4.099999904632568,""y"":5.5123443603515625},{""x"":4.599999904632568,""y"":5.724395751953125},{""x"":5.099999904632568,""y"":4.354506969451904},{""x"":5.599999904632568,""y"":1.7307666540145874},{""x"":6.099999904632568,""y"":0.6305936574935913},{""x"":6.599999904632568,""y"":0.035183437168598175},{""x"":7.099999904632568,""y"":0.7575169205665588}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nSwitzerland,IRVVGRYLIEVWKAAGMDMDKVLFLWSSDEI,CN1CCC(CC1)Oc2ccc(cc2)C(F)(F)F,1480028,36.33137130737305,99504,92-11 179TH PLACE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,9,10,1IAN,10,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[1.1190255865097471, 2.3163895161544437, 5.4968866182279195, 0.2035204047289052],""points"":[{""x"":0.10000000149011612,""y"":1.1057683229446411},{""x"":0.6000000238418579,""y"":1.1019697189331055},{""x"":1.100000023841858,""y"":1.0818607807159424},{""x"":1.600000023841858,""y"":1.062997817993164},{""x"":2.0999999046325684,""y"":1.046447515487671},{""x"":2.5999999046325684,""y"":1.1217249631881714},{""x"":3.0999999046325684,""y"":1.2166996002197266},{""x"":3.5999999046325684,""y"":1.215477705001831},{""x"":4.099999904632568,""y"":1.0581893920898438},{""x"":4.599999904632568,""y"":1.1747995615005493},{""x"":5.099999904632568,""y"":1.0181127786636353},{""x"":5.599999904632568,""y"":0.5344523191452026},{""x"":6.099999904632568,""y"":0.2569526433944702},{""x"":6.599999904632568,""y"":0.1912207305431366},{""x"":7.099999904632568,""y"":0.15060538053512573}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.1038581025805785, 2.0032224204185245, 5.087602825989163, 0.13277988512492753],""points"":[{""x"":0.10000000149011612,""y"":3.0498509407043457},{""x"":0.6000000238418579,""y"":2.805217742919922},{""x"":1.100000023841858,""y"":3.3415253162384033},{""x"":1.600000023841858,""y"":3.0549843311309814},{""x"":2.0999999046325684,""y"":3.250074863433838},{""x"":2.5999999046325684,""y"":3.0432586669921875},{""x"":3.0999999046325684,""y"":3.265852451324463},{""x"":3.5999999046325684,""y"":2.9475724697113037},{""x"":4.099999904632568,""y"":3.1929898262023926},{""x"":4.599999904632568,""y"":2.7460060119628906},{""x"":5.099999904632568,""y"":1.6175861358642578},{""x"":5.599999904632568,""y"":0.3006608486175537},{""x"":6.099999904632568,""y"":0.3444803059101105},{""x"":6.599999904632568,""y"":0.015537971630692482},{""x"":7.099999904632568,""y"":0.5527358055114746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\n,,,,,,,,,,,,,,,,,,,,,');e.columns.add(DG.Column.fromList(DG.TYPE.BYTE_ARRAY,"BinaryImage",Array.from(new Uint8Array(11))));var o=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{l(r.next(t))}catch(t){i(t)}}function a(t){try{l(r.throw(t))}catch(t){i(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((r=r.apply(t,e||[])).next())}))};const i=3e4,s=108e5,a=console.log.bind(console),l=console.info.bind(console),c=console.warn.bind(console),u=console.error.bind(console),h={},d="Auto Tests",p="Demo",f="Detectors",m="Core",g={};let y;var b;!function(t){t.notNull=function(t,e){if(null==t)throw new Error(`${null==e?"Value":e} not defined`)}}(b||(b={}));class v{constructor(t,e,n){this.catchUnhandled=!0,this.report=!1,this.returnOnFail=!1,void 0!==t&&(this.catchUnhandled=t),void 0!==e&&(this.report=e),void 0!==n&&(this.returnOnFail=n)}}class C{constructor(t,e,n,r){var s;this.category=t,this.name=e,null!=r||(r={}),null!==(s=r.timeout)&&void 0!==s||(r.timeout=i),this.options=r,this.test=()=>o(this,void 0,void 0,(function*(){return new Promise(((t,e)=>o(this,void 0,void 0,(function*(){var r;let o="";try{DG.Test.isInDebug;let t=yield n();try{o=null!==(r=null==t?void 0:t.toString())&&void 0!==r?r:""}catch(t){o="Can't convert test's result to string",console.error(`Can't convert test's result to string in the ${this.category}:${this.name} test`)}}catch(t){e(t)}t(o)}))))}))}}function x(t,e,n){null==h[y]&&(h[y]={}),null==h[y].tests&&(h[y].tests=[]),h[y].tests.push(new C(y,t,e,n))}function w(t,e=!0,n){if(n=n?`${n}, `:"",t!==e)throw new Error(`${n}Expected "${e}", got "${t}"`)}function A(t,e,n=.001,r){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 o=Math.abs(t-e)<n;if(w(o,!0,`${null!=r?r:""} (tolerance = ${n}; a = ${t}, e = ${e})`),!o)throw new Error(`Expected ${e}, got ${t} (tolerance = ${n})`)}function T(t,e){for(const[n,r]of Object.entries(e)){if(!t.hasOwnProperty(n))throw new Error(`Expected property "${n}" not found`);const e=t[n];if(e instanceof Array&&r instanceof Array)E(e,r);else if(e instanceof Object&&r instanceof Object)T(e,r);else if(Number.isFinite(e)&&Number.isFinite(r))A(e,r);else if(e!=r)throw new Error(`Expected (${r}) for key '${n}', got (${e})`)}}function E(t,e){const n=t.length,r=e.length;if(n!=r)throw new Error(`Arrays are of different length: actual array length is ${n} and expected array length is ${r}`);for(let r=0;r<n;r++)if(t[r]instanceof Array&&e[r]instanceof Array)E(t[r],e[r]);else if(t[r]instanceof Object&&e[r]instanceof Object)T(t[r],e[r]);else if(t[r]!=e[r])throw new Error(`Expected ${e[r]} at position ${r}, got ${t[r]}`)}function S(t,e,n){var r;y=t,e(),h[y]&&(h[y].clear=null===(r=null==n?void 0:n.clear)||void 0===r||r,h[y].timeout=null==n?void 0:n.timeout,h[y].benchmarks=null==n?void 0:n.benchmarks,h[y].stressTests=null==n?void 0:n.stressTests,h[y].owner=null==n?void 0:n.owner)}function I(t){null==h[y]&&(h[y]={}),h[y].before=t}function N(t){null==h[y]&&(h[y]={}),h[y].after=t}function _(t,e){return t.replace(new RegExp(e.name,"gi"),e.nqName)}function P(t,n){var r,a,l,c,u,y,b,v,x,A;return o(this,void 0,void 0,(function*(){const T=t.id;if(g[T])return;const E=n?n.tests:h;if("DevTools"===t.name||n&&"DevTools"===n._package.name)for(const t of window.dartTests){const e=t.name.split(/\s*\|\s*!/g);let n=null!==(r=e.pop())&&void 0!==r?r:t.name,o=e.length?m+": "+e.join(": "):m,s=n.split(" | ");n=s[s.length-1],s.unshift(o),s.pop(),o=s.join(": "),void 0===E[o]&&(E[o]={tests:[],clear:!0}),E[o].tests.push(new C(o,n,t.test,{isAggregated:!1,timeout:null!==(l=null===(a=t.options)||void 0===a?void 0:a.timeout)&&void 0!==l?l:i,skipReason:null===(c=t.options)||void 0===c?void 0:c.skipReason,owner:null===(u=t.options)||void 0===u?void 0:u.owner,benchmark:null!==(b=null===(y=t.options)||void 0===y?void 0:y.benchmark)&&void 0!==b&&b}))}const S=[],I=[],N=[],P=yield grok.dapi.functions.filter(`package.id = "${T}"`).list(),M=new RegExp(/skip:\s*([^,\s]+)|wait:\s*(\d+)|cat:\s*([^,\s]+)|timeout:\s*(\d+)/g);for(const n of P){const r=n.options.test,a=n.options.demoPath;if(r&&Array.isArray(r)&&r.length)for(let t=0;t<r.length;t++){const e=r[t].matchAll(M),a={};Array.from(e).forEach((t=>{t[0].startsWith("skip")?a.skip=t[1]:t[0].startsWith("wait")?a.wait=parseInt(t[2]):t[0].startsWith("cat")?a.cat=t[3]:t[0].startsWith("timeout")&&(a.timeout=parseInt(t[4]))}));const l=new C(null!==(v=a.cat)&&void 0!==v?v:d,1===r.length?n.name:`${n.name} ${t+1}`,(()=>o(this,void 0,void 0,(function*(){const e=yield grok.functions.eval(_(r[t],n));if(a.wait&&(yield R(a.wait)),"boolean"==typeof e&&!e)throw`Failed: ${r[t]}, expected true, got ${e}`}))),{skipReason:a.skip,timeout:DG.Test.isInBenchmark?null!==(x=a.benchmarkTimeout)&&void 0!==x?x:s:null!==(A=a.timeout)&&void 0!==A?A:i});if(a.cat){const t=a.cat;void 0===E[t]&&(E[t]={tests:[],clear:!0}),E[t].tests||(E[t].tests=[]),E[t].tests.push(l)}else S.push(l)}if(a){const t=n.options.demoWait?parseInt(n.options.demoWait):void 0,e=new C(p,n.friendlyName,(()=>o(this,void 0,void 0,(function*(){yield R(300),grok.shell.clearLastError(),yield n.apply(),yield R(t||2e3);const e=yield grok.shell.lastError;if(e)throw new Error(e)}))),{skipReason:n.options.demoSkip});I.push(e)}if(n.hasTag("semTypeDetector")){let r=e;n.options.testData&&(r=yield grok.data.files.openTable(`System:AppData/${t.nqName}/${n.options.testData}`));const i=new C(f,n.friendlyName,(()=>o(this,void 0,void 0,(function*(){const e=[];console.log(`System:AppData/${t.nqName}/${n.options.testData}`);for(const t of r.clone().columns){const r=yield n.apply([t]);e.push(r||t.semType)}const o=e.filter((t=>t));w(o.length,1),n.options.testDataColumnName&&w(o[0],n.options.testDataColumnName)}))),{skipReason:n.options.skipTest});N.push(i)}}g[T]=!0,S.length>0&&(E[d]={tests:S,clear:!0}),I.length>0&&(E[p]={tests:I,clear:!0}),N.length>0&&(E[f]={tests:N,clear:!1})}))}function M(t){return o(this,void 0,void 0,(function*(){return`${t.toString()}\n${t.stack?yield DG.Logger.translateStackTrace(t.stack):""}`}))}function L(t,e,n,r,s,l){var c,h,d,p,f,m,g,y,b,v,C,x,w,A;return o(this,void 0,void 0,(function*(){let o;n.length=0;const T=null!=e&&t.name.toLowerCase()!==e.toLowerCase();let E=(null===(c=t.options)||void 0===c?void 0:c.skipReason)||T,S=T?"skipped":null===(h=t.options)||void 0===h?void 0:h.skipReason;if(DG.Test.isInBenchmark&&!(null===(d=t.options)||void 0===d?void 0:d.benchmark))return void a(`Package testing: Skipped {{${t.category}}} {{${t.name}}} doesnt available in benchmark mode`);E&&!DG.Test.isInBenchmark&&a(`Package testing: Skipped {{${t.category}}} {{${t.name}}}`),E||a(`Package testing: Started {{${t.category}}} {{${t.name}}}`);const I=Date.now(),N=new Date(I).toISOString();try{if(E)o={name:t.name,owner:null!==(f=null===(p=t.options)||void 0===p?void 0:p.owner)&&void 0!==f?f:"",category:t.category,logs:"",date:N,success:!0,result:S,ms:0,skipped:!0,package:null!=s?s:"",flaking:DG.Test.isReproducing};else{let e=null!=r?r:i;DG.Test.isProfiling&&console.profile(`${t.category}: ${t.name}`),o={name:t.name,owner:null!==(g=null===(m=t.options)||void 0===m?void 0:m.owner)&&void 0!==g?g:"",category:t.category,logs:"",date:N,success:!0,result:null!==(y=(yield D(t.test,e)).toString())&&void 0!==y?y:"OK",ms:0,skipped:!1,package:null!=s?s:"",flaking:DG.Test.isReproducing},DG.Test.isProfiling&&(console.profileEnd(`${t.category}: ${t.name}`),grok.shell.info(`Profiling of ${t.category}: ${t.name} finished \n Please ensure that you have opened DevTools (F12) / Performance panel before test starts.`))}}catch(e){u(e),o={name:t.name,owner:null!==(v=null===(b=t.options)||void 0===b?void 0:b.owner)&&void 0!==v?v:"",category:t.category,logs:"",date:N,success:!1,result:yield M(e),ms:0,skipped:!1,package:null!=s?s:"",flaking:!1}}if((null===(C=t.options)||void 0===C?void 0:C.isAggregated)&&o.result.constructor===DG.DataFrame){const t=o.result.col("success");if(t&&(o.success=t.stats.sum===t.length),!l){const t=o.result;t.columns.remove("stack"),t.rows.removeWhere((t=>t.get("success"))),o.result=t}o.result=o.result.toCsv()}if(o.logs=n.join("\n"),o.ms=Date.now()-I,E||a(`Package testing: Finished {{${t.category}}} {{${t.name}}} with {{${o.success?"success":"error"}}} for ${o.ms} ms`),o.success||a(`Package testing: Result for {{${t.category}}} {{${t.name}}}: ${o.result}`),o.category=t.category,o.name=t.name,o.owner=null!==(w=null===(x=t.options)||void 0===x?void 0:x.owner)&&void 0!==w?w:"",!T){let e={success:o.success,result:o.result,ms:o.ms,date:o.date,skipped:o.skipped,category:t.category,name:t.name,logs:o.logs,owner:o.owner,flaking:DG.Test.isReproducing&&o.success,package:o.package};if(o.result.constructor==Object){const t=Object.keys(o.result).reduce(((t,e)=>Object.assign(Object.assign({},t),{["result."+e]:o.result[e]})),{});e=Object.assign(Object.assign({},e),t)}e.result instanceof DG.DataFrame&&(e.result=JSON.stringify(null===(A=e.result)||void 0===A?void 0:A.toJson())||""),yield grok.shell.reportTest("package",e)}return o}))}function O(t){const e=t.slice();return e.sort((()=>Math.random()-.5)),e}function R(t){return o(this,void 0,void 0,(function*(){yield new Promise((e=>setTimeout(e,t)))}))}function D(t,e,n="EXECUTION TIMEOUT"){return o(this,void 0,void 0,(function*(){let r=null;const o=new Promise(((t,o)=>{r=setTimeout((()=>{o(n)}),e)}));try{return yield Promise.race([t(),o])}finally{r&&clearTimeout(r)}}))}DG.DataFrame.fromColumns([DG.Column.fromStrings("col",["val1","val2","val3"])]);var $=n(4328),B=n(6686);class F extends t.Package{async getTranslationHelper(){return await $.functions.call(`${this.name}:getTranslationHelper`)}}function k(t,e,n){return n.createFormatConverter(t,e).convertTo(B.NO.HELM)}function H(t,e,n){return n.createFormatConverter(t,B.NO.HELM).convertTo(e)}const G={Axolabs:{UfAfsCfsGfuacg:"RNA1{[fR](U)p.[fR](A)[sp].[fR](C)[sp].[fR](G)p.[25r](U)p.[25r](A)p.[25r](C)p.[25r](G)}$$$$"},BioSpring:{"A*GC*123456789":"RNA1{r(A)[sp].r(G)p.r(C)[sp].[fR](U)p.[fR](A)p.[fR](C)p.[fR](G)p.[25r](U)p.[25r](A)p.[25r](C)p.[25r](G)p.d([m5C])}$$$$"},Mermade12:{hefglijkLIJKHEFG:"RNA1{[25r](U)[sp].[25r](A)[sp].[25r](C)[sp].[25r](G)[sp].[fR](U)[sp].[fR](A)[sp].[fR](C)[sp].[fR](G)[sp].[fR](U)p.[fR](A)p.[fR](C)p.[fR](G)p.[25r](U)p.[25r](A)p.[25r](C)p.[25r](G)}$$$$"}},V={"RNA1{[fR](U)p.[fR](A)[sp].[fR](C)[sp].[fR](G)p.[25r](U)p.[25r](A)p.[25r](C)p.[25r](G)}$$$$":"UACGUACG","RNA1{r(A)[sp].r(G)p.r(C)[sp].[fR](U)p.[fR](A)p.[fR](C)p.[fR](G)p.[25r](U)p.[25r](A)p.[25r](C)p.[25r](G)p}$$$$":"AGCUACGUACG","RNA1{[25r](U)[sp].[25r](A)[sp].[25r](C)[sp].[25r](G)[sp].[fR](U)[sp].[fR](A)[sp].[fR](C)[sp].[fR](G)[sp].[fR](U)p.[fR](A)p.[fR](C)p.[fR](G)p.[25r](U)p.[25r](A)p.[25r](C)p.[25r](G)}$$$$":"UACGUACGUACGUACG"};S("Formats to HELM",(()=>{let t;I((async()=>{t=await yt.getTranslationHelper()}));for(const e of Object.keys(G))for(const[n,r]of Object.entries(G[e]))x(`${e} to HELM`,(async()=>{const o=r;w(k(n,e,t),o)}))})),S("HELM to Formats",(()=>{let t;I((async()=>{t=await yt.getTranslationHelper()}));for(const e of Object.keys(G))for(const[n,r]of Object.entries(G[e]))x(`${e} to HELM`,(async()=>{const o=n;w(H(r,e,t),o)}))}));var U=n(3480);S("HELM to Nucleotides",(()=>{let t;I((async()=>{t=await yt.getTranslationHelper()})),Object.entries(V).forEach((([e,n],r)=>{x(`Sequence ${r+1} to nucleotides`,(async()=>{const r=n;w((0,U.Hs)(e,t.monomerLibWrapper),r)}))}))}));const j={[B.NO.AXOLABS]:"Afcgacsu",[B.NO.HELM]:"RNA1{[fR](A)p.[25r](C)p.[25r](G)p.[25r](A)p.[25r](C)[sp].[25r](U)}$$$$"};S("Formats support",(()=>{let t;I((async()=>{t=await yt.getTranslationHelper()})),Object.entries(j).forEach((([e,n])=>{x(`All formats for ${e}`,(async()=>{const r=function(t,e,n){const r=n.createSequenceValidator(t).getInvalidCodeIndex(e);return(0,U.bD)(t,r,e,n)}(n,e,t),o=Object.keys(r).length;w(!0,Object.keys(G).length+1<=o)}))}))}));var q=n(9192);S("files",(()=>{let e;I((async()=>{e=await yt.getTranslationHelper()})),x("list",(async()=>{let n;const r=t.DataFrame.fromColumns([t.Column.string("subTest"),n=t.Column.bool("success"),t.Column.string("format"),t.Column.string("src"),t.Column.string("res"),t.Column.string("tgt"),t.Column.string("error"),t.Column.string("stack")]),o=await yt.files.list("tests",!0,".csv");for(const n of o){const o=t.DataFrame.fromCsv(await n.readAsString()),i=o.columns.byIndex(0),s=i.name,a=o.columns.byIndex(1),l=o.rowCount;for(let t=0;t<l;++t){const o=r.rows.addNew();o.subTest=`${n.name}, row: ${t}`;try{const n=i.get(t),r=a.get(t);o.format=s,o.src=n,o.tgt=r,w(o.res=k(n,s,e),r),o.success=!0}catch(t){const[e,n]=(0,q.AP)(t);o.error=e,o.stack=n,o.success=!1}}}0==r.rowCount&&r.rows.addNew(["empty",!0,"",""]);const i=n.toList().findIndex((t=>1!=t));if(-1!=i){const t=r.rows.get(i);throw new Error(`Subtest '${t.subTest}' failed: ${t.error}`)}return r}),{skipReason:"Can not create test in async manner based on files in Shares."})}));var W=n(8312),z=n(2003);class Y{constructor(t,e,n,r,o,i){this.units=t,this.aligned=e,this.alphabet=n,this.alphabetSize=r,this.alphabetIsMultichar=o,this.separator=i}}async function K(e,n){const r=(await e()).getCol(n),o=await $.functions.call("Bio:detectMacromolecule",{col:r});if(o&&(r.semType=o),r.semType===t.SEMTYPE.MACROMOLECULE){const t=`Negative test detected semType='${r.semType}', units='${r.meta.units}'.`;throw new Error(t)}}async function Q(e,n,r,o,i,s,a,l,c=null){const u=(await e()).col(n),h=await $.functions.call("Bio:detectMacromolecule",{col:u});h&&(u.semType=h),w(u.semType,t.SEMTYPE.MACROMOLECULE),w(u.meta.units,o),w(u.getTag(z.gp.aligned),i),w(u.getTag(z.gp.alphabet),s),c&&w(u.getTag(z.gp.separator),c);const d=r.getSeqHandler(u);w(d.getAlphabetSize(),a),w(d.getAlphabetIsMultichar(),l),d.isHelm()||(w(d.aligned,i),w(d.alphabet,s))}S("PolyTool: detectors",(()=>{let e;I((async()=>{e=await(0,W.Q)()}));const n={cyclized1:{csv:"n,seq\n1,R-F-C(1)-T-G-H-F-Y-G-H-F-Y-G-H-F-Y-P-C(1)-meI\n2,C(1)-T-G-H-F-Y-P-C(1)-meI\n3,R-F-C(1)-T-G-H-F-Y-P-C(1)\n4,C(1)-T-G-H-F-H-P-C(1)\n5,R-F-D(2)-T-G-H-F-Y-P-NH2(2)\n6,R-F-aG(4)-T-G-H-F-Y-P-azG(4)-meI",pos:{seq:new Y(z.Hi.CUSTOM,"SEQ",z.YI.UN,13,!0,"-")}}};for(const[r,o]of Object.entries(n))x(`${r}`,(async()=>{const n=async()=>t.DataFrame.fromCsv(o.csv);for(const t of o.neg??[])await K(n,t);for(const[t,r]of Object.entries(o.pos??{}))await Q(n,t,e,r.units,r.aligned,r.alphabet,r.alphabetSize,r.alphabetIsMultichar,r.separator)}),{skipReason:"3156"})}));var J=n(4971);const X="Libraries",Z="Settings",tt="DuplicateMonomerPreferences",et=4e3,nt="nextChunk";let rt=Promise.resolve();async function ot(){let t;return rt=rt.then((async()=>{const e=await $.userSettings.getValue(X,Z,!0);t=e?JSON.parse(e):{exclude:[],explicit:[],duplicateMonomerPreferences:{}};const n=await async function(){let t=await $.userSettings.getValue(X,tt,!0)??"";if(!t)return{};for(;t.endsWith(nt);){const e=`${tt}${t.charAt(t.length-9-1)}`,n=await $.userSettings.getValue(X,e,!0)??"";t=t.slice(0,t.length-9-1)+n}return JSON.parse(t)}();t.exclude=t.exclude instanceof Array?t.exclude:[],t.explicit=t.explicit instanceof Array?t.explicit:[],t.duplicateMonomerPreferences=t.duplicateMonomerPreferences instanceof Object?t.duplicateMonomerPreferences:{};for(const e in n){t.duplicateMonomerPreferences[e]=t.duplicateMonomerPreferences[e]??{};for(const r in n[e])for(const o of n[e][r])t.duplicateMonomerPreferences[e][o]=r}})),await rt,t}async function it(t){rt=rt.then((async()=>{t.duplicateMonomerPreferences=t.duplicateMonomerPreferences??{};const e={};for(const n in t.duplicateMonomerPreferences){e[n]={};for(const r in t.duplicateMonomerPreferences[n]){const o=t.duplicateMonomerPreferences[n][r];e[n][o]=e[n][o]??[],e[n][o].push(r)}}await async function(t){const e=JSON.stringify(t),n=Math.ceil(e.length/et);for(let t=0;t<n;t++){const r=0===t?tt:`${tt}${t}`,o=t<n-1?`${t+1}`:"",i=e.slice(t*et,(t+1)*et),s=o?i+o+nt:i;await $.userSettings.add(X,r,s,!0)}}(e),t.duplicateMonomerPreferences={},await $.userSettings.add(X,Z,JSON.stringify(t),!0)})),await rt}var st=n(6717),at=n(9124),lt=n(4229),ct=n(5174),ut=n(6694);S("PolyTool: Convert",(()=>{let e,n,r,i,s;I((async()=>{r=await(0,st.j)(),e=await(0,at.b2)(),n=await(0,W.Q)(),i=await(0,J.pj)(),s=await ot(),await i.loadMonomerLibForTests()})),N((async()=>{await it(s),await i.loadMonomerLib(!0)}));const a={"cyclized-C(1)-2-1":{src:{seq:"R-F-C(1)-T-G-H-F-Y-P-C(1)-meI"},tgt:{helm:"PEPTIDE1{R.F.C.T.G.H.F.Y.P.C.[meI]}$PEPTIDE1,PEPTIDE1,3:R3-10:R3$$$V2.0",mol:{atomCount:95,bondCount:100,inchiKey:"LMJUFVBPWWJJPN-AJJYTACESA-N"}}},"cyclized-C(1)-0-1":{src:{seq:"C(1)-T-G-H-F-Y-P-C(1)-meI"},tgt:{helm:"PEPTIDE1{C.T.G.H.F.Y.P.C.[meI]}$PEPTIDE1,PEPTIDE1,1:R3-8:R3$$$V2.0",mol:{atomCount:73,bondCount:77,inchiKey:"KLFRBMUPPMMGJM-HXTBFBBASA-N"}}},"cyclized-C(1)-0-0":{src:{seq:"C(1)-T-G-H-F-Y-P-C(1)"},tgt:{helm:"PEPTIDE1{C.T.G.H.F.Y.P.C}$PEPTIDE1,PEPTIDE1,1:R3-8:R3$$$V2.0",mol:{atomCount:64,bondCount:68,inchiKey:"LOSMDBLEXLWPLB-OFZKBENXSA-N"}}},"cyclized-D(2)-NH2(2)-3-0":{src:{seq:"R-F-D(2)-T-G-H-F-Y-P-NH2(2)"},tgt:{helm:"PEPTIDE1{R.F.D.T.G.H.F.Y.P.[NH2]}$PEPTIDE1,PEPTIDE1,3:R3-10:R2$$$V2.0",mol:{atomCount:81,bondCount:86,inchiKey:"CBMGNYKOZWNVNK-AHGCAHLCSA-N"}}},"cyclized-D(2)-NH2(2)-0-0":{src:{seq:"D(2)-T-G-H-F-Y-P-NH2(2)"},tgt:{helm:"PEPTIDE1{D.T.G.H.F.Y.P.[NH2]}$PEPTIDE1,PEPTIDE1,1:R3-8:R2$$$V2.0",mol:{atomCount:59,bondCount:63,inchiKey:"HGRHAUQBJXFERJ-MUFWPYSASA-N"}}}};for(const[t,n]of Object.entries(a))x(`toHelm-${t}`,(async()=>{const t=await(0,ut.Q4)(["rules_example.json"]);w((0,lt.b)([n.src.seq],t,e)[0][0],n.tgt.helm)}));for(const[o,i]of Object.entries(a))x(`toAtomicLevel-${o}`,(async()=>{const o=await(0,ut.Q4)(["rules_example.json"]),[s,a,l]=(0,lt.b)([i.src.seq],o,e),c=await(0,ct.A)(o),u=t.Column.fromStrings("helm",s);u.semType=t.SEMTYPE.MACROMOLECULE,u.meta.units=z.Hi.HELM;const h=await n.helmToAtomicLevel(u,!1,!1,c);if(h.warnings&&h.warnings.length>0)throw new Error(h.warnings[0]);w(null!=h.molCol,!0,".molCol is not null");const d=h.molCol.get(0),p=r.get_mol(d);try{T({atomCount:p.get_num_atoms(),bondCount:p.get_num_bonds(),inchiKey:r.get_inchikey_for_inchi(p.get_inchi())},i.tgt.mol)}finally{p.delete()}}));x("ui-col-wo-table",(async()=>{const e=yt.name,n=Object.values(a).map((t=>t.src.seq)),r=Object.values(a).map((t=>t.tgt.helm)),o=t.Column.fromStrings("seq",n),i=await $.functions.call(`${e}:polyToolConvert2`,{seqCol:o,generateHelm:!0,chiralityEngine:!0,rules:["rules_example.json"]});E(i.toList(),r),w(i.semType,t.SEMTYPE.MACROMOLECULE),w(i.meta.units,z.Hi.HELM),w(i.dataFrame,null)})),x("ui-col",(async()=>{const e=yt.name,n=Object.values(a).map((t=>t.src.seq)),r=Object.values(a).map((t=>t.tgt.helm)),i=t.Column.fromStrings("seq",n),s=t.DataFrame.fromColumns([i]),l=$.shell.addTableView(s),c=await $.functions.call(`${e}:polyToolConvert2`,{seqCol:i,generateHelm:!0,chiralityEngine:!0,rules:["rules_example.json"]});E(c.toList(),r),w(c.semType,t.SEMTYPE.MACROMOLECULE),w(c.meta.units,z.Hi.HELM),w(c.dataFrame.id,s.id),await function(t,e,n,r=0,i="timeout"){return o(this,void 0,void 0,(function*(){return new Promise(((o,s)=>{const a=t.subscribe((t=>{try{e(t),o("OK")}catch(t){s(t)}finally{a.unsubscribe(),clearTimeout(l)}})),l=setTimeout((()=>{a.unsubscribe(),s(i)}),r);n()}))}))}(l.grid.onAfterDrawContent,(()=>{}),(async()=>{l.grid.invalidate()}),15e3),w(c.getTag(t.TAGS.CELL_RENDERER),"helm")}))}));var ht=n(1296),dt=n(3820);S("PolyTool: Enumerate",(()=>{let t,e,n;I((async()=>{t=await(0,at.b2)(),e=await(0,J.pj)(),n=await ot(),await e.loadMonomerLibForTests()})),N((async()=>{await it(n),await e.loadMonomerLib(!0)}));const r={single1:{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:ht.aK.Single,placeholders:[{position:4,monomers:["K","P","F4COO"]},{position:6,monomers:["Y","T"]}]},tgt:[{seq:"PEPTIDE1{[Ac(1)].F.W.G.K.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5K"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5P"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.[F4COO].L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5[F4COO]"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.P.L.Y.[C(1)].G.[NH2]}$$$$V2.0",name:"-[Tic]7Y"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.P.L.T.[C(1)].G.[NH2]}$$$$V2.0",name:"-[Tic]7T"}]},"single-with-original":{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:ht.aK.Single,placeholders:[{position:4,monomers:["K","P","F4COO"]},{position:6,monomers:["Y","T"]}],keepOriginal:!0},tgt:[{seq:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:""},{seq:"PEPTIDE1{[Ac(1)].F.W.G.K.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5K"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5P"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.[F4COO].L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5[F4COO]"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.P.L.Y.[C(1)].G.[NH2]}$$$$V2.0",name:"-[Tic]7Y"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.P.L.T.[C(1)].G.[NH2]}$$$$V2.0",name:"-[Tic]7T"}]},parallel1:{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:ht.aK.Parallel,placeholders:[{position:1,monomers:["D","L"]},{position:6,monomers:["Y","T"]}]},tgt:[{seq:"PEPTIDE1{[Ac(1)].D.W.G.P.L.Y.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2D-[Tic]7Y"},{seq:"PEPTIDE1{[Ac(1)].L.W.G.P.L.T.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2L-[Tic]7T"}]},"parallel-three-positions":{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:ht.aK.Parallel,placeholders:[{position:1,monomers:["D","L","K"]},{position:4,monomers:["K","P","F4COO"]},{position:6,monomers:["Y","T","A"]}]},tgt:[{seq:"PEPTIDE1{[Ac(1)].D.W.G.K.L.Y.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2D-P5K-[Tic]7Y"},{seq:"PEPTIDE1{[Ac(1)].L.W.G.P.L.T.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2L-P5P-[Tic]7T"},{seq:"PEPTIDE1{[Ac(1)].K.W.G.[F4COO].L.A.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2K-P5[F4COO]-[Tic]7A"}]},"parallel-with-original":{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:ht.aK.Parallel,placeholders:[{position:1,monomers:["D","L"]},{position:6,monomers:["Y","T"]}],keepOriginal:!0},tgt:[{seq:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:""},{seq:"PEPTIDE1{[Ac(1)].D.W.G.P.L.Y.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2D-[Tic]7Y"},{seq:"PEPTIDE1{[Ac(1)].L.W.G.P.L.T.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2L-[Tic]7T"}]},"parallel-single-position":{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:ht.aK.Parallel,placeholders:[{position:4,monomers:["K","P","F4COO"]}]},tgt:[{seq:"PEPTIDE1{[Ac(1)].F.W.G.K.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5K"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5P"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.[F4COO].L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5[F4COO]"}]},matrix1:{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:ht.aK.Matrix,placeholders:[{position:1,monomers:["D","L"]},{position:4,monomers:["K","P","F4COO"]},{position:6,monomers:["Y","T"]}]},tgt:[{seq:"PEPTIDE1{[Ac(1)].D.W.G.K.L.Y.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2D-P5K-[Tic]7Y"},{seq:"PEPTIDE1{[Ac(1)].D.W.G.K.L.T.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2D-P5K-[Tic]7T"},{seq:"PEPTIDE1{[Ac(1)].D.W.G.P.L.Y.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2D-P5P-[Tic]7Y"},{seq:"PEPTIDE1{[Ac(1)].D.W.G.P.L.T.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2D-P5P-[Tic]7T"},{seq:"PEPTIDE1{[Ac(1)].D.W.G.[F4COO].L.Y.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2D-P5[F4COO]-[Tic]7Y"},{seq:"PEPTIDE1{[Ac(1)].D.W.G.[F4COO].L.T.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2D-P5[F4COO]-[Tic]7T"},{seq:"PEPTIDE1{[Ac(1)].L.W.G.K.L.Y.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2L-P5K-[Tic]7Y"},{seq:"PEPTIDE1{[Ac(1)].L.W.G.K.L.T.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2L-P5K-[Tic]7T"},{seq:"PEPTIDE1{[Ac(1)].L.W.G.P.L.Y.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2L-P5P-[Tic]7Y"},{seq:"PEPTIDE1{[Ac(1)].L.W.G.P.L.T.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2L-P5P-[Tic]7T"},{seq:"PEPTIDE1{[Ac(1)].L.W.G.[F4COO].L.Y.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2L-P5[F4COO]-[Tic]7Y"},{seq:"PEPTIDE1{[Ac(1)].L.W.G.[F4COO].L.T.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2L-P5[F4COO]-[Tic]7T"}]}};for(const[t,e]of Object.entries(r))x(`${t}`,(async()=>{E((0,dt.o)(e.src,"",e.params),e.tgt.map((t=>[t.seq,t.name])))}))})),S("PolyTool: Enumerate",(()=>{let t,e,n;I((async()=>{t=await(0,at.b2)(),e=await(0,J.pj)(),n=await ot(),await e.loadMonomerLibForTests()})),N((async()=>{await it(n),await e.loadMonomerLib(!0)}));const r={breadth1:{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:ht.aK.Single,breadthPlaceholders:[{start:2,end:4,monomers:["K"]}]},tgt:[{seq:"PEPTIDE1{[Ac(1)].F.K.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-W3K"},{seq:"PEPTIDE1{[Ac(1)].F.W.K.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-G4K"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.K.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5K"}]},"breadth1-with-original":{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:ht.aK.Single,breadthPlaceholders:[{start:2,end:4,monomers:["K"]}],keepOriginal:!0},tgt:[{seq:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:""},{seq:"PEPTIDE1{[Ac(1)].F.K.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-W3K"},{seq:"PEPTIDE1{[Ac(1)].F.W.K.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-G4K"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.K.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5K"}]},breadth2:{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:ht.aK.Single,breadthPlaceholders:[{start:2,end:4,monomers:["K","Y"]}]},tgt:[{seq:"PEPTIDE1{[Ac(1)].F.K.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-W3K"},{seq:"PEPTIDE1{[Ac(1)].F.W.K.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-G4K"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.K.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5K"},{seq:"PEPTIDE1{[Ac(1)].F.Y.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-W3Y"},{seq:"PEPTIDE1{[Ac(1)].F.W.Y.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-G4Y"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.Y.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5Y"}]},"breadth-double":{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:ht.aK.Single,breadthPlaceholders:[{start:2,end:4,monomers:["K"]},{start:2,end:4,monomers:["Y"]}]},tgt:[{seq:"PEPTIDE1{[Ac(1)].F.Y.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-W3K-K3Y"},{seq:"PEPTIDE1{[Ac(1)].F.K.Y.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-W3K-G4Y"},{seq:"PEPTIDE1{[Ac(1)].F.K.G.Y.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-W3K-P5Y"},{seq:"PEPTIDE1{[Ac(1)].F.Y.K.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-G4K-W3Y"},{seq:"PEPTIDE1{[Ac(1)].F.W.Y.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-G4K-K4Y"},{seq:"PEPTIDE1{[Ac(1)].F.W.K.Y.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-G4K-P5Y"},{seq:"PEPTIDE1{[Ac(1)].F.Y.G.K.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5K-W3Y"},{seq:"PEPTIDE1{[Ac(1)].F.W.Y.K.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5K-G4Y"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.Y.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5K-K5Y"}]}};for(const[t,e]of Object.entries(r))x(`${t}`,(async()=>{E((0,dt.o)(e.src,"",e.params),e.tgt.map((t=>[t.seq,t.name])))}))}));var pt=n(3309);function ft(t,e){const n=e.get_mol(t);try{return w(n.is_valid(),!0,`RDKit rejected SMILES: ${t}`),n.get_smiles()}finally{n.delete()}}S("PolyTool: ChemEnum: R-labels",(()=>{x("extract from every supported form",(async()=>{E((0,pt.Qk)("C[1*]"),[1]),E((0,pt.Qk)("C[*:1]"),[1]),E((0,pt.Qk)("C[*1]"),[1]),E((0,pt.Qk)("C[R1]"),[1]),E((0,pt.Qk)("C[R:1]"),[1])})),x("extract multi-digit numbers",(async()=>{E((0,pt.Qk)("C1CC(C[*:100])(N[*:1])C([*:101])N1[*:2]"),[1,2,100,101]),E((0,pt.Qk)("C[R100]N[R:101]"),[100,101])})),x("normalize all spellings to [*:N]",(async()=>{w((0,pt.j7)("C[1*]"),"C[*:1]"),w((0,pt.j7)("C[*:1]"),"C[*:1]"),w((0,pt.j7)("C[*1]"),"C[*:1]"),w((0,pt.j7)("C[R1]"),"C[*:1]"),w((0,pt.j7)("C[R:1]"),"C[*:1]"),w((0,pt.j7)("C[R100]N[R:101]"),"C[*:100]N[*:101]")})),x("remap the one-and-only R-label to a new slot",(async()=>{w((0,pt.aj)("C[1*]",5),"C[*:5]"),w((0,pt.aj)("C[R:3]CC",1),"C[*:1]CC"),w((0,pt.aj)("[*:7]C",2),"[*:2]C")})),x("deduplicate repeated R numbers",(async()=>{E((0,pt.Qk)("C[*:1]C[*:1]"),[1])})),x("normalize does not touch regular bracket atoms",(async()=>{w((0,pt.j7)("C[NH3+]C[*:1]"),"C[NH3+]C[*:1]"),w((0,pt.j7)("[13C]C[*:2]"),"[13C]C[*:2]")}))})),S("PolyTool: ChemEnum: SMILES surgery",(()=>{x("moveStartRLabelToBranch: bare atom at start",(async()=>{w((0,pt.z9)("[*:1]CC"),"C([*:1])C"),w((0,pt.z9)("[*:1]Cl"),"Cl([*:1])"),w((0,pt.z9)("[*:1][NH3+]C"),"[NH3+]([*:1])C")})),x("moveStartRLabelToBranch: with explicit bond",(async()=>{w((0,pt.z9)("[*:1]=CC"),"C(=[*:1])C"),w((0,pt.z9)("[*:1]#C"),"C(#[*:1])")})),x("moveStartRLabelToBranch: leaves interior unchanged",(async()=>{w((0,pt.z9)("CC[*:1]"),"CC[*:1]"),w((0,pt.z9)("CC([*:1])CC"),"CC([*:1])CC")})),x("substituteRLabelWithRingDigit collapses branch form",(async()=>{w((0,pt.yw)("CC([*:1])CC",1,"9"),"CC9CC"),w((0,pt.yw)("CC([*:2])([*:1])CC",1,"%50"),"CC([*:2])%50CC")})),x("substituteRLabelWithRingDigit handles trailing form",(async()=>{w((0,pt.yw)("CC[*:1]",1,"7"),"CC7"),w((0,pt.yw)("CC=[*:2]",2,"%42"),"CC=%42")})),x("pickFreeRingDigits avoids digits already in use",(async()=>{const t=(0,pt.Ii)(["C1CCCCC1[*:1]","[*:1]C"],2);w(t.includes(1),!1),w(t.length,2)})),x("pickFreeRingDigits ignores digits inside bracket atoms",(async()=>{E((0,pt.Ii)(["C[*:1]","[*:1]C"],1),[1])}))})),S("PolyTool: ChemEnum: validators",(()=>{x("core without any R-label is rejected",(async()=>{w(null!=(0,pt.KS)("CCO","row 1").error,!0)})),x("r-group with zero R-labels is rejected",(async()=>{w(null!=(0,pt.ah)("CC",1,"row 1").error,!0)})),x("r-group with multiple R-labels is rejected",(async()=>{w(null!=(0,pt.ah)("[*:1]CC[*:2]",1,"row 1").error,!0)})),x("r-group with wrong R-number is auto-remapped",(async()=>{const t=(0,pt.ah)("CC[*:3]",1,"row 1");w(null==t.error,!0),w(t.rNumber,1),w(t.sourceRNumber,3),w(t.smiles,"CC[*:1]")}))})),S("PolyTool: ChemEnum: count & validate",(()=>{x("zip length mismatch is flagged",(async()=>{const t=(0,pt.KS)("C[*:1]C[*:2]","c1"),e=(0,pt.XB)({cores:[t],rGroups:new Map([[1,[(0,pt.ah)("C[*:1]",1,"r1-a"),(0,pt.ah)("N[*:1]",1,"r1-b")]],[2,[(0,pt.ah)("O[*:2]",2,"r2-a")]]]),mode:pt.PI.Zip});w(e.ok,!1),w(e.errors.some((t=>t.includes("Zip"))),!0)})),x("cartesian count = product across Rs, summed over cores",(async()=>{const t=(0,pt.KS)("C[*:1]","a"),e=(0,pt.KS)("C[*:1]N[*:2]","b"),n=(0,pt.XB)({cores:[t,e],rGroups:new Map([[1,[(0,pt.ah)("C[*:1]",1,"a"),(0,pt.ah)("N[*:1]",1,"b"),(0,pt.ah)("O[*:1]",1,"c")]],[2,[(0,pt.ah)("C[*:2]",2,"a"),(0,pt.ah)("N[*:2]",2,"b")]]]),mode:pt.PI.Cartesian});w(n.predictedCount,9),w(n.ok,!0)})),x("zip count = N per core, summed",(async()=>{const t=(0,pt.KS)("C[*:1]","a"),e=(0,pt.KS)("C[*:1]N[*:2]","b");w((0,pt.XB)({cores:[t,e],rGroups:new Map([[1,[(0,pt.ah)("C[*:1]",1,"a"),(0,pt.ah)("N[*:1]",1,"b")]],[2,[(0,pt.ah)("O[*:2]",2,"a"),(0,pt.ah)("S[*:2]",2,"b")]]]),mode:pt.PI.Zip}).predictedCount,4)})),x("uncovered R-number is flagged per core",(async()=>{const t=(0,pt.KS)("C[*:1]N[*:7]","c"),e=(0,pt.XB)({cores:[t],rGroups:new Map([[1,[(0,pt.ah)("O[*:1]",1,"a")]]]),mode:pt.PI.Cartesian});w(e.ok,!1),w(e.errors.some((t=>t.includes("R7"))),!0)})),x("hard cap rejects over-limit enumerations",(async()=>{const t=(0,pt.KS)("C[*:1]N[*:2]","c"),e=Array.from({length:1e3},((t,e)=>(0,pt.ah)("C[*:1]",1,`r1-${e}`))),n=Array.from({length:1001},((t,e)=>(0,pt.ah)("O[*:2]",2,`r2-${e}`))),r=(0,pt.XB)({cores:[t],rGroups:new Map([[1,e],[2,n]]),mode:pt.PI.Cartesian,maxResults:1e6});w(r.overCap,!0),w(r.ok,!1)})),x("countForCore: zip with mismatched per-core lengths → -1",(async()=>{const t=(0,pt.KS)("C[*:1]N[*:2]","c"),{count:e}=(0,pt.k5)(t,new Map([[1,[(0,pt.ah)("C[*:1]",1,"a"),(0,pt.ah)("N[*:1]",1,"b")]],[2,[(0,pt.ah)("O[*:2]",2,"a")]]]),pt.PI.Zip);w(e,-1)}))})),S("PolyTool: ChemEnum: assembly",(()=>{let t;I((async()=>{t=await(0,st.j)()})),x("single R-group: joins correctly",(async()=>{const e=(0,pt.BG)("C[*:1]",new Map([[1,"O[*:1]"]]),t);w(null!=e,!0),w(e,ft("CO",t))})),x("multi R-group: R1 and R2 both joined",(async()=>{const e=(0,pt.BG)("C[*:1]N[*:2]",new Map([[1,"O[*:1]"],[2,"S[*:2]"]]),t);w(null!=e,!0),w(e,ft("OCNS",t))})),x("R-label at SMILES start is handled",(async()=>{const e=(0,pt.BG)("[*:1]CC",new Map([[1,"Br[*:1]"]]),t);w(null!=e,!0),w(e,ft("BrCC",t))})),x("core uses existing ring digit 1 — free digit is picked",(async()=>{const e=(0,pt.BG)("C1CCCCC1[*:1]",new Map([[1,"O[*:1]"]]),t);w(null!=e,!0),w(e,ft("OC1CCCCC1",t))})),x("multi-digit R numbers (R100, R101)",(async()=>{const e=(0,pt.BG)("C1CC(C[*:100])(N[*:1])C([*:101])N1[*:2]",new Map([[1,"C[*:1]"],[2,"C[*:2]"],[100,"C[*:100]"],[101,"C[*:101]"]]),t);w(null!=e,!0);const n=t.get_mol(e);try{w(n.is_valid(),!0),w(e.includes("[*:"),!1)}finally{n.delete()}}))})),S("PolyTool: ChemEnum: enumerate",(()=>{let t;I((async()=>{t=await(0,st.j)()})),x("cartesian across two cores with different R-sets",(async()=>{const e=(0,pt.KS)("C[*:1]","A"),n=(0,pt.KS)("C[*:1]N[*:2]","B"),r=[(0,pt.ah)("O[*:1]",1,"r1-a"),(0,pt.ah)("S[*:1]",1,"r1-b")],o=[(0,pt.ah)("C[*:2]",2,"r2-a"),(0,pt.ah)("N[*:2]",2,"r2-b"),(0,pt.ah)("F[*:2]",2,"r2-c")],i=(0,pt.HL)({cores:[e,n],rGroups:new Map([[1,r],[2,o]]),mode:pt.PI.Cartesian},t);w(i.length,8);const s=i.filter((t=>"C[*:1]"===t.coreSmiles)),a=i.filter((t=>"C[*:1]N[*:2]"===t.coreSmiles));w(s.length,2),w(a.length,6)})),x("zip across two cores with shared R-list length",(async()=>{const e=(0,pt.KS)("C[*:1]","A"),n=(0,pt.KS)("C[*:1]N[*:2]","B"),r=[(0,pt.ah)("O[*:1]",1,"r1-a"),(0,pt.ah)("S[*:1]",1,"r1-b")],o=[(0,pt.ah)("C[*:2]",2,"r2-a"),(0,pt.ah)("N[*:2]",2,"r2-b")],i=(0,pt.HL)({cores:[e,n],rGroups:new Map([[1,r],[2,o]]),mode:pt.PI.Zip},t);w(i.length,4);const s=i.filter((t=>"C[*:1]N[*:2]"===t.coreSmiles));w(s.length,2),w(s[0].rGroupSmilesByNum.get(1),"O[*:1]"),w(s[0].rGroupSmilesByNum.get(2),"C[*:2]"),w(s[1].rGroupSmilesByNum.get(1),"S[*:1]"),w(s[1].rGroupSmilesByNum.get(2),"N[*:2]")})),x("invalid params return null from enumerate()",(async()=>{const e=(0,pt.KS)("C[*:1]N[*:2]","c");w((0,pt.HL)({cores:[e],rGroups:new Map([[1,[(0,pt.ah)("O[*:1]",1,"x")]]]),mode:pt.PI.Cartesian},t),null)}))})),S("PolyTool: ChemEnum: CSV fixtures",(()=>{let e;async function n(e){const n=await yt.files.readAsText(e);return t.DataFrame.fromCsv(n)}I((async()=>{e=await(0,st.j)()})),x("cores file parses and all rows validate",(async()=>{const t=(await n("tests/chem_enum_cores.csv")).col("Core"),r=Array.from({length:t.length},((n,r)=>(0,pt.KS)(t.get(r),`Cores[${r}]`,e)));w(r.length,4),w(r.every((t=>!t.error)),!0,r.map((t=>t.error??"")).filter((t=>t)).join("; "));for(const t of r)w(t.rNumbers.includes(1)&&t.rNumbers.includes(2),!0,`core ${t.id} R-numbers: ${t.rNumbers}`)})),x("r-groups file: columns R1, R2, R3 populate their slots",(async()=>{const t=await n("tests/chem_enum_rgroups.csv"),r=(n,r)=>{const o=t.col(n),i=[];for(let t=0;t<o.length;t++){const s=o.get(t);null!=s&&""!==String(s).trim()&&i.push((0,pt.ah)(String(s),r,`${n}[${t}]`,e))}return i},o=r("R1",1),i=r("R2",2),s=r("R3",3);w(o.length,4),w(i.length,4),w(s.length,1);for(const t of[o,i,s])w(t.every((t=>!t.error)),!0,t.map((t=>t.error??"")).filter((t=>t)).join("; "))})),x("end-to-end cartesian with CSV fixtures produces valid, canonical SMILES",(async()=>{const t=await n("tests/chem_enum_cores.csv"),r=await n("tests/chem_enum_rgroups.csv"),o=t.col("Core"),i=Array.from({length:o.length},((t,n)=>(0,pt.KS)(o.get(n),`Cores[${n}]`,e))),s=new Map;for(const t of["R1","R2","R3"]){const n=parseInt(t.substring(1),10),o=r.col(t),i=[];for(let r=0;r<o.length;r++){const s=o.get(r);null!=s&&""!==String(s).trim()&&i.push((0,pt.ah)(String(s),n,`${t}[${r}]`,e))}s.set(n,i)}const a=(0,pt.HL)({cores:i,rGroups:s,mode:pt.PI.Cartesian},e);w(null!=a&&a.length>0,!0);for(const t of a){w(t.smiles.includes("[*:"),!1,`residual R-label in result: ${t.smiles}`);const n=e.get_mol(t.smiles);try{w(n.is_valid(),!0,`invalid SMILES: ${t.smiles}`)}finally{n.delete()}}}))}));var mt=n(6307),gt=n(2125);S("PolyTool: Chain: parseNotation",(()=>{let t;I((async()=>{t=await(0,at.b2)()}));const e={cyclized:{src:{seq:"R-F-C(1)-T-G-H-F-Y-P-C(1)-meI"},tgt:{helm:"PEPTIDE1{R.F.[C(1)].T.G.H.F.Y.P.[C(1)].[meI]}$$$$V2.0"}},dimerized1:{src:{seq:"(#3)Succ-{A(CHOL)-F-C(1)-T-G-H-Y-P-C(1)-NH2}"},tgt:{helm:"PEPTIDE1{[(#3)Succ]}|PEPTIDE2{[A(CHOL)].F.[C(1)].T.G.H.Y.P.[C(1)].[NH2]}$PEPTIDE1,PEPTIDE2,1:R1-1:R1$$$V2.0"}},dimerized2:{src:{seq:"($3)Succ-{R-F-C(1)-T-G-H-F-P-C(1)-NH2}($2){A(CHOL)-F-C(1)-T-G-H-F-P-C(1)-NH2}"},tgt:{helm:"PEPTIDE1{[($3)Succ]}|PEPTIDE2{R.F.[C(1)].T.G.H.F.P.[C(1)].[NH2]}|PEPTIDE3{[($2)A(CHOL)].F.[C(1)].T.G.H.F.P.[C(1)].[NH2]}$PEPTIDE1,PEPTIDE2,1:R1-1:R1$$$V2.0"}}};for(const[n,r]of Object.entries(e))x(`${n}`,(async()=>{await(0,ut.Q4)(["rules_example.json"]);const e=await mt.s.fromSeparator(r.src.seq,t),n=e.mol,o=t.createHelmWebEditor();o.editor.setMol(n);const i=o.editor.getHelm(),s=e.getHelm();w(i,r.tgt.helm),w(s,r.tgt.helm)}),"reaction2"==n?{skipReason:"reverse reaction"}:void 0);const n={"0-in-4-4-3":{inIdx:0,spIdx:0,outIdx:0,monomers:[["0","1","2","3"],["4","5","6","7"],["8","9","10"]]},"3-in-4-4-3":{inIdx:3,spIdx:0,outIdx:3,monomers:[["0","1","2","3"],["4","5","6","7"],["8","9","10"]]},"4-in-4-4-3":{inIdx:0,spIdx:1,outIdx:4,monomers:[["0","1","2","3"],["4","5","6","7"],["8","9","10"]]},"7-in-4-4-3":{inIdx:3,spIdx:1,outIdx:7,monomers:[["0","1","2","3"],["4","5","6","7"],["8","9","10"]]},"8-in-4-4-3":{inIdx:0,spIdx:2,outIdx:8,monomers:[["0","1","2","3"],["4","5","6","7"],["8","9","10"]]},"0-in-1-1-6-3":{inIdx:0,spIdx:0,outIdx:0,monomers:[["0"],["1"],["2","3","4","5","6","7"],["8","9","10"]]},"1-in-1-1-6-3":{inIdx:0,spIdx:1,outIdx:1,monomers:[["0"],["1"],["2","3","4","5","6","7"],["8","9","10"]]},"2-in-1-1-6-3":{inIdx:0,spIdx:2,outIdx:2,monomers:[["0"],["1"],["2","3","4","5","6","7"],["8","9","10"]]},"3-in-1-1-6-3":{inIdx:1,spIdx:2,outIdx:3,monomers:[["0"],["1"],["2","3","4","5","6","7"],["8","9","10"]]},"7-in-1-1-6-3":{inIdx:5,spIdx:2,outIdx:7,monomers:[["0"],["1"],["2","3","4","5","6","7"],["8","9","10"]]},"8-in-1-1-6-3":{inIdx:0,spIdx:3,outIdx:8,monomers:[["0"],["1"],["2","3","4","5","6","7"],["8","9","10"]]}};for(const[t,{inIdx:e,spIdx:r,outIdx:o,monomers:i}]of Object.entries(n))x(`innerIdx-${t}`,(async()=>{const[t,n]=(0,gt.M)(o,i);w(t,e),w(n,r)}));for(const[t,{inIdx:e,spIdx:r,outIdx:o,monomers:i}]of Object.entries(n))x(`outerIdx-${t}`,(async()=>{w((0,gt.j)(e,r,i),o)}))})),S("PolyTool: Chain",(()=>{let t;I((async()=>{t=await(0,at.b2)()}));const e={cyclized:{data:{templateSeq:"R-F-C(1)-T-G-H-F-Y-P-C(1)-meI",templateHelm:"PEPTIDE1{R.F.[C(1)].T.G.H.F.Y.P.[C(1)].[meI]}$$$$V2.0",mmHelm:"PEPTIDE1{R.F.C.T.G.H.F.Y.P.C.[meI]}$PEPTIDE1,PEPTIDE1,3:R3-10:R3$$$V2.0"},tgt:{templateChain:{monomerCount:[11],linkageCount:0},mmChain:{monomerCount:[11],linkageCount:0}}},dimerized1:{data:{templateSeq:"(#3)Succ-{A(CHOL)-F-C(1)-T-G-H-Y-P-C(1)-NH2}",templateHelm:"PEPTIDE1{[(#3)Succ]}|PEPTIDE2{[A(CHOL)].F.[C(1)].T.G.H.Y.P.[C(1)].[NH2]}$PEPTIDE1,PEPTIDE2,1:R1-1:R1$$$V2.0",mmHelm:"PEPTIDE1{[(#3)Succ].[{A(CHOL)].F.C.T.G.H.Y.P.C.[NH2}]}$PEPTIDE1,PEPTIDE1,4:R3-10:R3$$$V2.0"},tgt:{templateChain:{monomerCount:[1,10],linkageCount:1},mmChain:{monomerCount:[11],linkageCount:1}}},dimerized2:{data:{templateSeq:"($3)Succ-{R-F-C(1)-T-G-H-F-P-C(1)-NH2}($3){A(CHOL)-F-C(1)-Y-H-G-D-N-C(1)-meI}",templateHelm:"PEPTIDE1{[($3)Succ]}|PEPTIDE2{R.F.[C(1)].T.G.H.F.P.[C(1)].[NH2]}|PEPTIDE3{[($3)A(CHOL)].F.[C(1)].Y.H.G.D.N.[C(1)].[meI]}$PEPTIDE1,PEPTIDE2,1:R1-1:R1$$$V2.0",mmHelm:"PEPTIDE1{[($3)Succ].[{R].F.C.T.G.H.F.P.C.[NH2}($3){A(CHOL)].F.[C(1)].Y.H.G.D.N.[C(1)].[meI}]}$PEPTIDE1,PEPTIDE1,4:R3-10:R3$$$V2.0"},tgt:{templateChain:{monomerCount:[1,10,10],linkageCount:1},mmChain:{monomerCount:[20],linkageCount:1}}}};for(const[n,{data:r,tgt:o}]of Object.entries(e))x(`fromNotation-${n}`,(async()=>{const e=await(0,ut.Q4)(["rules_example.json"]),n=mt.s.fromSeparator(r.templateSeq,t);n.applyRules(e),n.check(!0),E(n.monomers.map((t=>t.length)),o.mmChain.monomerCount),w(n.linkages.length,o.mmChain.linkageCount),w(n.getHelm(),r.mmHelm)}),{skipReason:"3157"});for(const[n,{data:r,tgt:o}]of Object.entries(e))x(`parseNotation-${n}`,(async()=>{await(0,ut.Q4)(["rules_example.json"]);const e=mt.s.fromSeparator(r.templateSeq,t);e.check(!0),E(e.monomers.map((t=>t.length)),o.templateChain.monomerCount),w(e.linkages.length,o.templateChain.linkageCount),w(e.getHelm(),r.templateHelm),w(e.getNotation(),r.templateSeq)}));for(const[n,{data:r,tgt:o}]of Object.entries(e))x(`parseHelm-${n}`,(async()=>{await(0,ut.Q4)(["rules_example.json"]);const e=mt.s.fromHelm(r.templateHelm,t);e.check(!0),E(e.monomers.map((t=>t.length)),o.templateChain.monomerCount),w(e.linkages.length,o.templateChain.linkageCount),w(e.getHelm(),r.templateHelm),w(e.getNotation(),r.templateSeq)}));for(const[n,{data:r,tgt:o}]of Object.entries(e))x(`applyRules-${n}`,(async()=>{const e=await(0,ut.Q4)(["rules_example.json"]),n=mt.s.fromSeparator(r.templateSeq,t);n.applyRules(e),n.check(!0),E(n.monomers.map((t=>t.length)),o.mmChain.monomerCount),w(n.linkages.length,o.mmChain.linkageCount),w(n.getHelm(),r.mmHelm)}),{skipReason:"applyRules is not implemented"})})),S("toAtomicLevel",(()=>{let e,n,r;I((async()=>{n=await(0,J.pj)(),e=await ot(),r=await(0,st.j)(),await n.loadMonomerLibForTests()})),N((async()=>{await it(e),await n.loadMonomerLib(!0)})),x("override",(async()=>{const e=n.getMonomerLib(),o=await yt.files.readAsText("tests/polytool-reaction-lib.json"),i=JSON.parse(o).find((t=>"GGaz"===t.symbol));w(null!=i,!0,"Monomer 'GGaz' not found.");const s={PEPTIDE:{GGaz:i}},a=e.override(s,"test"),l=await(0,W.Q)(),c=t.Column.fromList(t.COLUMN_TYPE.STRING,"helm",["PEPTIDE1{F.P.Y.[GGaz].H.A.A.G.G.A.C}|PEPTIDE2{A.A.A}$PEPTIDE1,PEPTIDE2,4:R4-1:R1|PEPTIDE1,PEPTIDE1,11:R2-4:R3$$$V2.0"]);c.semType=t.SEMTYPE.MACROMOLECULE,c.meta.units=z.Hi.HELM;const u=await l.helmToAtomicLevel(c,!1,!1,a);w(null!=u.molCol,!0,"Result molCol is null");const h=u.molCol.get(0);w(!!h,!0,"Molfile is empty");const d=r.get_mol(h);try{const t=d.get_inchi(),e=r.get_inchikey_for_inchi(t);w(d.get_num_bonds(),103),w(d.get_num_atoms(),98),w(e,"XPQUTLNSNIMERR-WKBTUBAPSA-N")}finally{d.delete()}})),x("getNewMonomer",(async()=>{const t=await(0,st.j)(),e=n.getMonomerLib(),r=(await(0,ut.Q4)(["rules_example.json"])).reactionRules.find((t=>"GGaz"==t.name)),[o,i]=(0,ct.T)(t,e,r);w(o?.[0],"azG_GGaz");const s=t.get_mol(i[0].molfile);try{const e=s.get_inchi();t.get_inchikey_for_inchi(e),w(s.get_num_bonds(),7),w(s.get_num_atoms(),8)}finally{s.delete()}}))}));const yt=new F;async function bt(e,n,r){const d=await function(t){var e,n,r;return o(this,void 0,void 0,(function*(){const d=(null==t?void 0:t.nodeOptions)?t.nodeOptions.package:grok.functions.getCurrentCall().func.package;if(!d)throw new Error("Can't run tests outside of the package");const p=null===(e=d.packageOwner)||void 0===e?void 0:e.match(/<([^>]*)>/),f=p?p[1]:"";null!=d&&(yield P(d));const m=[];console.log("Running tests..."),console.log(t),null!=t||(t={}),null!==(n=(r=t).testContext)&&void 0!==n||(r.testContext=new v),grok.shell.clearLastError();const g=function(){const t=[];return console.log=(...e)=>{t.push(...e),a(...e)},console.info=(...e)=>{t.push(...e),l(...e)},console.warn=(...e)=>{t.push(...e),c(...e)},console.error=(...e)=>{t.push(...e),u(...e)},t}();yield function(t,e){var n,r,i,s,h,p;return o(this,void 0,void 0,(function*(){try{let l=null!=(null==e?void 0:e.skipToCategory),c=!1;for(const[u,g]of Object.entries(t)){if(null===(n=e.exclude)||void 0===n?void 0:n.some((t=>u.startsWith(t))))continue;if(null!=(null==e?void 0:e.category)&&!u.toLowerCase().startsWith(null==e?void 0:e.category.toLowerCase().trim()))continue;if(l)if(c)l=!1;else{if(null==(null==e?void 0:e.skipToCategory)||u.toLowerCase().trim()!==(null==e?void 0:e.skipToCategory.toLowerCase().trim()))continue;c=!0}const t=null===(r=g.tests)||void 0===r?void 0:r.every((t=>{var n;return(null===(n=t.options)||void 0===n?void 0:n.skipReason)||null!=(null==e?void 0:e.test)&&e.test.toLowerCase()!==t.name.toLowerCase()}));if(!t){const t=(null!==(i=g.tests)&&void 0!==i?i:[]).filter((t=>{var n;return(null===(n=t.options)||void 0===n?void 0:n.skipReason)||null!=(null==e?void 0:e.test)&&e.test.toLowerCase()!==t.name.toLowerCase()})).length;a(`Package testing: Started {{${u}}}${t>0?` skipped {{${t}}}`:""}`),g.beforeStatus=yield y(g.before,u)}let v,C=null!==(s=g.tests)&&void 0!==s?s:[];e.stressTest&&(C=C.filter((t=>{var e;return null===(e=t.options)||void 0===e?void 0:e.stressTest})),C=O(C)),(null!==(p=null===(h=e.tags)||void 0===h?void 0:h.length)&&void 0!==p?p:0)>0&&(C=C.filter((t=>{var n,r;return null===(r=null===(n=t.options)||void 0===n?void 0:n.tags)||void 0===r?void 0:r.some((t=>{var n;return(null!==(n=null==e?void 0:e.tags)&&void 0!==n?n:[]).includes(t)}))}))),g.beforeStatus?(v=Array.from(C.map((t=>({date:(new Date).toISOString(),category:u,name:t.name,success:!1,result:"before() failed",ms:0,skipped:!1,logs:"",owner:f,package:d.name,widgetsDifference:0,flaking:DG.Test.isReproducing})))),v.forEach((t=>o(this,void 0,void 0,(function*(){return yield grok.shell.reportTest("package",t)}))))):v=yield b(g,e,l);const x=v.filter((t=>"skipped"!=t.result));if(t||(g.afterStatus=yield y(g.after,u)),g.afterStatus&&(a(`Package testing: Category after() {{${u}}} failed`),a(`Package testing: Result for {{${u}}} after: ${g.afterStatus}`),x.push({date:(new Date).toISOString(),category:u,name:"after",success:!1,result:g.afterStatus,ms:0,skipped:!1,logs:"",owner:f,package:d.name,widgetsDifference:0,flaking:DG.Test.isReproducing})),g.beforeStatus&&(a(`Package testing: Category before() {{${u}}} failed`),a(`Package testing: Result for {{${u}}} before: ${g.beforeStatus}`),x.push({date:(new Date).toISOString(),category:u,name:"before",success:!1,result:g.beforeStatus,ms:0,skipped:!1,logs:"",owner:f,package:d.name,widgetsDifference:0,flaking:DG.Test.isReproducing})),m.push(...x),e.returnOnFail&&x.some((t=>!t.success&&!t.skipped&&t.name!==e.skipToTest)))break}}finally{console.log=a,console.info=l,console.warn=c,console.error=u}if(e.testContext.catchUnhandled&&!DG.Test.isInBenchmark){yield R(1e3);const t=yield grok.shell.lastError;if(null!=t){const e={logs:"",date:(new Date).toISOString(),category:"Unhandled exceptions",name:"Exception",result:null!=t?t:"",success:!t,ms:0,skipped:!1,owner:null!=f?f:"",package:d.name,widgetsDifference:0};a(`Package testing: Unhandled Exception: ${t}`),m.push(Object.assign(Object.assign({},e),{flaking:DG.Test.isReproducing&&!t})),e.package=d.name,yield grok.shell.reportTest("package",e)}}}))}(h,t);for(let t of m)t.result=t.result.toString().replace(/"/g,"'"),null!=t.logs&&(t.logs=t.logs.toString().replace(/"/g,"'"));return m;function y(t,e){return o(this,void 0,void 0,(function*(){let n;try{void 0!==t&&(yield D((()=>o(this,void 0,void 0,(function*(){yield t()}))),1e5,`before ${e}: timeout error`))}catch(t){n=yield M(t)}return n}))}function b(t,e,n){var r,a,l,c,u,h,p,m,y,b,v,x,w,A,T,E,S,I;return o(this,void 0,void 0,(function*(){let o=null!==(r=t.tests)&&void 0!==r?r:[];const N=[],_=C();if(t.clear){let r=n&&null!=e.skipToTest;for(let n=0;n<o.length;n++){o[n].options&&void 0===(null===(a=o[n].options)||void 0===a?void 0:a.benchmark)&&(o[n].options||(o[n].options={}),o[n].options.benchmark=null!==(l=t.benchmarks)&&void 0!==l&&l);let x=o[n];if(e.test&&e.test.toLowerCase()!==x.name.toLowerCase())continue;if(r){if(null==(null==e?void 0:e.skipToTest)||x.name.toLowerCase().trim()!==(null==e?void 0:e.skipToTest.toLowerCase().trim()))continue;r=!1}(null==x?void 0:x.options)&&(x.options.owner=null!==(p=null!==(h=null!==(u=null===(c=o[n].options)||void 0===c?void 0:c.owner)&&void 0!==u?u:null==t?void 0:t.owner)&&void 0!==h?h:f)&&void 0!==p?p:"");let w=yield L(x,null==e?void 0:e.test,g,DG.Test.isInBenchmark?null!==(y=null===(m=o[n].options)||void 0===m?void 0:m.benchmarkTimeout)&&void 0!==y?y:s:null!==(v=null===(b=o[n].options)||void 0===b?void 0:b.timeout)&&void 0!==v?v:i,d.name,e.verbose);if(w&&(N.push(Object.assign(Object.assign({},w),{widgetsDifference:C()-_})),e.returnOnFail&&e.skipToTest!==x.name&&!w.success&&!w.skipped))return N;e.nodeOptions||(grok.shell.closeAll(),DG.Balloon.closeAll())}}else{let r=n&&null!=e.skipToTest;for(let n=0;n<o.length;n++){let i=o[n];if(e.test&&e.test.toLowerCase()!==i.name.toLowerCase())continue;if(r){null!=(null==e?void 0:e.skipToTest)&&i.name.toLowerCase().trim()===(null==e?void 0:e.skipToTest.toLowerCase().trim())&&(r=!1);continue}(null==i?void 0:i.options)&&(i.options.owner=null!==(T=null!==(A=null!==(w=null===(x=o[n].options)||void 0===x?void 0:x.owner)&&void 0!==w?w:null==t?void 0:t.owner)&&void 0!==A?A:f)&&void 0!==T?T:"");let a=yield L(i,null==e?void 0:e.test,g,DG.Test.isInBenchmark?null!==(S=null===(E=o[n].options)||void 0===E?void 0:E.benchmarkTimeout)&&void 0!==S?S:s:null===(I=o[n].options)||void 0===I?void 0:I.timeout,d.name,e.verbose);if(a&&(N.push(Object.assign(Object.assign({},a),{widgetsDifference:C()-_})),e.returnOnFail&&e.skipToTest!==i.name&&!a.success&&!a.skipped))return N}}return N}))}function C(){var t;if("undefined"!=typeof process)return 0;let e=-1;try{e=DG.Widget.getAll().length}catch(e){console.warn(null!==(t=e.message)&&void 0!==t?t:e)}return e}}))}({category:e,test:n,testContext:r,verbose:!0});return t.DataFrame.fromObjects(d)}async function vt(){await P(yt,yt.getModule("package-test.js"))}})(),sequencetranslator_test=r})();
2
+ var sequencetranslator_test;(()=>{var e={6717:(e,t,n)=>{"use strict";n.d(t,{j:()=>r});var o=n(6082);async function r(){const e=o.Func.find({package:"Chem",name:"getRdKitModule"});if(0===e.length)throw new Error('Package "Chem" must be installed for getRdKitModule.');return(await e[0].prepare().call()).getOutputParamValue()}},3599:(e,t,n)=>{"use strict";n.d(t,{o:()=>o.o});var o=n(6869)},9124:(e,t,n)=>{"use strict";n.d(t,{b2:()=>i});var o=n(7389),r=n(6082);async function i(){const e="Helm",t=r.Func.find({package:e,name:"getHelmHelper"});if(0===t.length)throw new Error(`Package '${e}' must be installed for HelmHelper.`);return(await t[0].prepare().call()).getOutputParamValue()}r.JsInputBase,Error,o.input.helmAsync=async function(e,t){return(await i()).createHelmInput(e,t)}},8438:(e,t,n)=>{"use strict";function o(e){return e.startsWith("[")&&e.endsWith("]")?e.slice(1,-1):e}n.d(t,{D:()=>o})},8123:(e,t,n)=>{"use strict";n.d(t,{u:()=>o});const o={V2K_RGP_SHIFT:8,V2K_RGP_LINE:"M RGP",V2K_A_LINE:"A ",V3K_COUNTS_SHIFT:14,V3K_IDX_SHIFT:7,V3K_HEADER_FIRST_LINE:"\nDatagrok macromolecule handler\n\n",V3K_HEADER_SECOND_LINE:" 0 0 0 0 0 0 999 V3000\n",V3K_BEGIN_CTAB_BLOCK:"M V30 BEGIN CTAB\n",V3K_END_CTAB_BLOCK:"M V30 END CTAB\n",V3K_BEGIN_COUNTS_LINE:"M V30 COUNTS ",V3K_COUNTS_LINE_ENDING:" 0 0 0\n",V3K_BEGIN_ATOM_BLOCK:"M V30 BEGIN ATOM\n",V3K_END_ATOM_BLOCK:"M V30 END ATOM\n",V3K_BEGIN_BOND_BLOCK:"M V30 BEGIN BOND\n",V3K_END_BOND_BLOCK:"M V30 END BOND\n",V3K_BOND_CONFIG:" CFG=",V3K_BEGIN_DATA_LINE:"M V30 ",V3K_END:"M END",PRECISION_FACTOR:1e4,DEOXYRIBOSE:{polymerType:"RNA",symbol:"d"},RIBOSE:{polymerType:"RNA",symbol:"r"},PHOSPHATE:{polymerType:"RNA",symbol:"p"},OXYGEN:"O",HYDROGEN:"H"}},6197:(e,t,n)=>{"use strict";n.d(t,{Y:()=>r});var o=n(3599);function r(e){let t;switch(e){case o.o.BASE:case o.o.SUGAR:case o.o.LINKER:case o.o.NUCLEOTIDE:case"nucleotide":t="RNA";break;case o.o.AA:t="PEPTIDE";break;case o.o.CHEM:t="CHEM";break;case o.o.BLOB:t="BLOB";break;default:t="PEPTIDE",console.warn(`Unexpected HelmType '${e}'`)}return t}},9235:(e,t,n)=>{"use strict";n.d(t,{H:()=>c,R:()=>l});var o=n(6082),r=n(1991),i=n.n(r),s=n(330),a=n(3599);async function l(e,t,r,l,c,u,h,d){const p=e.length,m=e.dataFrame,f=Math.max(navigator.hardwareConcurrency-2,1),g=new Array(f).fill(null).map((()=>new Worker(new URL(n.p+n.u(455),n.b)))),y=p/f,b=new Array(f),v=u.getSeqHandler(e),C="RNA"==l?a.o.NUCLEOTIDE:a.o.AA,x=i().count(0).take(e.length).map((e=>{const t=v.getSplitted(e);return i().count(0).take(t.length).map((e=>({position:e,symbol:t.getCanonical(e),biotype:C}))).toArray()})).toArray();for(let e=0;e<f;e++){const n=g[e],o=Math.floor(e*y),i=e===f-1?p:Math.floor((e+1)*y);b[e]=new Promise((e=>{n.onmessage=t=>{e(t.data)}})),n.postMessage({seqList:x,rolesList:d,monomersDict:t,alphabet:r,polymerType:l,start:o,end:i})}const w=[],A=[];await Promise.all(b).then((e=>{for(const t of e)w.push(...t.molfiles),A.push(...t.warnings)})),setTimeout((()=>{g.forEach((e=>{e.terminate()}))}),0);const T=(0,s.qj)(m,e.name),E=o.Column.fromType(o.COLUMN_TYPE.STRING,T,e.length).init((e=>w[e]?.molfile));return E.semType=o.SEMTYPE.MOLECULE,E.meta.units=o.UNITS.Molecule.MOLBLOCK,E.setTag(".sequence-src-col",e.name),{molCol:E,warnings:A}}function c(e,t){const n={},r={};for(const i of e){const e=t.getWebEditorMonomer(i.biotype,i.symbol).backgroundcolor,a=(0,s.vG)(e??o.Color.toRgb(o.Color.mouseOverRows))??[1,0,0,.7];for(const e of i.atoms)n[e]=a;for(const e of i.bonds)r[e]=a}return{atoms:Object.keys(n).map((e=>parseInt(e))),bonds:Object.keys(r).map((e=>parseInt(e))),highlightAtomColors:n,highlightBondColors:r}}},3561:(e,t,n)=>{"use strict";n.d(t,{Hb:()=>l,YN:()=>f,gU:()=>c});var o=n(8123),r=n(294),i=n(3151),s=n(439),a=n(6197);function l(e,t,n){const o=new Map;for(const n of e.getMonomerSymbolsByType(t)){const r=e.getMonomer(t,n);if("RNA"===t||"PEPTIDE"===t&&"Branch"!==r.monomerType){const e={};i.f6.forEach((t=>{e[t]=r[t]})),o.set(n,e)}}return o}function c(e,t,n,i,l){if(0===e.length)return r.vF.createEmpty();const c="RNA"===i&&!!l&&l.length===e.length,{atomCount:m,bondCount:g,needsCapping:y}=function(e,t,n,i,l,c){let u=0,h=0,d=0,p=!0,m=null,f=null;for(let n=0;n<e.length;++n){const o=e[n];if(o.symbol!==s._S){if("*"==o.symbol)throw new Error("Gap canonical symbol is '', not '*");m=(0,r.xb)(t,{symbol:o.symbol,polymerType:(0,a.Y)(o.biotype)}),u+=m.atoms.x.length,h+=m.bonds.bondTypes.length,d++,l&&n%3==2&&(f=m)}}if("PEPTIDE"===i)u+=1,h+=d,d>0&&((m?.meta?.rNodes?.length??0)<2||m?.terminalR2Atom?.toLowerCase()===o.u.HYDROGEN.toLowerCase())&&(p=!1,u-=1,h-=1);else if(l)h+=d,c&&c.length>0&&c[c.length-1]===r.ZN.TERMINAL_3P?p=!1:u+=1;else{const i=n===s.YI.DNA?(0,r.xb)(t,o.u.DEOXYRIBOSE):(0,r.xb)(t,o.u.RIBOSE),a=(0,r.xb)(t,o.u.PHOSPHATE);u+=(e.length-1)*a.atoms.x.length,u+=e.length*i.atoms.x.length,u+=1,h+=(e.length-1)*a.bonds.bondTypes.length,h+=e.length*i.bonds.bondTypes.length,h-=1,h+=3*e.length}return{atomCount:u,bondCount:h,needsCapping:p}}(e,t,n,i,c,l),b=new Array(m),v=new Array(g);let C,x=null,w=null;"PEPTIDE"===i?C=u:(C=d,c||(x=n===s.YI.DNA?(0,r.xb)(t,o.u.DEOXYRIBOSE):(0,r.xb)(t,o.u.RIBOSE),w=(0,r.xb)(t,o.u.PHOSPHATE)));const A={i:0,nodeShift:0,bondShift:0,backbonePositionShift:new Array(2).fill(0),branchPositionShift:new Array(2).fill(0),backboneAttachNode:0,branchAttachNode:0,flipFactor:1},T={sugar:x,phosphate:w,seqLength:c?Math.ceil(e.length/3):e.length,atomCount:m,bondCount:g},E=new r.Cg,S=[];let N,I=0;if(c)!function(e,t,n,o,i,s,l,c,u,d,m){const f=t.length>0&&t[0]===r.ZN.TERMINAL_5P,g=t.length>0&&t[t.length-1]===r.ZN.TERMINAL_3P,y=f?1:0,b=(g?t.length-1:t.length)-y,v=Math.ceil(b/3),C=b===3*v,x=(e,t)=>{const l=(0,r.xb)(n,{symbol:e.symbol,polymerType:(0,a.Y)(e.biotype)}),p=s.nodeShift,f=s.bondShift;h(l,o,i,s),l.stereoAtoms?.forEach((e=>u.push(e+m()))),d(l.atoms.x.length);const g=[];for(let e=p;e<s.nodeShift;++e)g.push(e);const y=[];for(let e=f;e<s.bondShift;++e)y.push(e);c.set(t,{biotype:e.biotype,symbol:e.symbol,atoms:g,bonds:y})};f&&(s.i=0,x(e[0],0));for(let t=0;t<v;++t){s.i=t+(f?1:0);const l=y+3*t,g=l+1,b=e[l],v=e[g],C=(0,r.xb)(n,{symbol:b.symbol,polymerType:(0,a.Y)(b.biotype)}),w=(0,r.xb)(n,{symbol:v.symbol,polymerType:(0,a.Y)(v.biotype)});if(t>=1){const n=y+3*(t-1)+2;x(e[n],n)}const A=s.nodeShift,T=s.bondShift;h(C,o,i,s),C.stereoAtoms?.forEach((e=>u.push(e+m()))),d(C.atoms.x.length);const E=[];for(let e=A;e<s.nodeShift;++e)E.push(e);const S=[];for(let e=T;e<s.bondShift;++e)S.push(e);c.set(l,{biotype:b.biotype,symbol:b.symbol,atoms:E,bonds:S});const N=s.nodeShift,I=s.bondShift;p(w,o,i,s),w.stereoAtoms?.forEach((e=>u.push(e+m()))),d(w.atoms.x.length);const M=[];for(let e=N;e<s.nodeShift;++e)M.push(e);const P=[];for(let e=I;e<s.bondShift;++e)P.push(e);c.set(g,{biotype:v.biotype,symbol:v.symbol,atoms:M,bonds:P})}if(C){const t=y+3*(v-1)+2;x(e[t],t)}g&&(s.i=v+(f?1:0),x(e[t.length-1],t.length-1))}(e,l,t,b,v,A,0,E,S,(e=>{I+=e}),(()=>I));else for(A.i=0;A.i<T.seqLength;++A.i){const n=e[A.i];if(n.symbol===s._S)continue;const o=(0,r.xb)(t,{symbol:n.symbol,polymerType:(0,a.Y)(n.biotype)});N=o.terminalR2Atom;const i=A.nodeShift,l=A.bondShift;C(o,b,v,A,T),o.stereoAtoms?.forEach((e=>S.push(e+I))),I+=o.atoms.x.length;const c=A.nodeShift-i,u=new Array(c);for(let e=0;e<c;++e)u[e]=i+e;const h=A.bondShift-l,d=new Array(h);for(let e=0;e<h;++e)d[e]=l+e;E.set(A.i,{biotype:n.biotype,symbol:n.symbol,atoms:u,bonds:d})}y&&function(e,t,n,r,i=o.u.OXYGEN){const s=n.nodeShift+1;e[r.atomCount]=o.u.V3K_BEGIN_DATA_LINE+s+" "+(i??o.u.OXYGEN)+" "+f(n.backbonePositionShift[0])+" "+n.flipFactor*f(n.backbonePositionShift[1])+" 0.000000 0\n";const a=n.backboneAttachNode,l=s;t[r.bondCount]=o.u.V3K_BEGIN_DATA_LINE+n.bondShift+" 1 "+a+" "+l+"\n"}(b,v,A,T,N??o.u.OXYGEN);const M=o.u.V3K_BEGIN_COUNTS_LINE+m+" "+g+o.u.V3K_COUNTS_LINE_ENDING;let P="";return P+=o.u.V3K_HEADER_FIRST_LINE,P+=o.u.V3K_HEADER_SECOND_LINE,P+=o.u.V3K_BEGIN_CTAB_BLOCK,P+=M,P+=o.u.V3K_BEGIN_ATOM_BLOCK,P+=b.join(""),P+=o.u.V3K_END_ATOM_BLOCK,P+=o.u.V3K_BEGIN_BOND_BLOCK,P+=v.join(""),P+=o.u.V3K_END_BOND_BLOCK,S.length>0&&(P+=function(e){const t=[];let n=`M V30 MDLV30/STEABS ATOMS=(${e.length}`;for(let o=0;o<e.length;o++){const r=`${n} ${e[o]}`;r.length>76?(t.push(`${n} -\n`),n=`M V30 ${e[o]}`):n=r,o===e.length-1&&t.push(`${n})\n`)}return`M V30 BEGIN COLLECTION\n${t.join("")}M V30 END COLLECTION\n`}(S)),P+=o.u.V3K_END_CTAB_BLOCK,P+=o.u.V3K_END,{molfile:P,monomers:E}}function u(e,t,n,o){o.flipFactor=(-1)**(o.i%2),h(e,t,n,o)}function h(e,t,n,r){!function(e,t,n){for(let r=0;r<e.atoms.atomTypes.length;++r){const i=n.nodeShift+r+1;t[n.nodeShift+r]=o.u.V3K_BEGIN_DATA_LINE+i+" "+e.atoms.atomTypes[r]+" "+f(n.backbonePositionShift[0]+e.atoms.x[r])+" "+f(n.backbonePositionShift[1]+n.flipFactor*e.atoms.y[r])+" "+e.atoms.kwargs[r]}}(e,t,r),m(e,n,r),function(e,t,n){if(0!==n.backboneAttachNode){const r=n.bondShift,i=n.backboneAttachNode,s=e.meta.terminalNodes[0]+n.nodeShift;t[n.bondShift-1]=o.u.V3K_BEGIN_DATA_LINE+r+" 1 "+i+" "+s+"\n"}}(e,n,r),null!==e.meta.branchShift&&e.meta.terminalNodes.length>2&&function(e,t){t.branchAttachNode=t.nodeShift+e.meta.terminalNodes[2];for(let n=0;n<2;++n)t.branchPositionShift[n]=t.backbonePositionShift[n]+e.meta.branchShift[n]}(e,r),function(e,t){t.backboneAttachNode=t.nodeShift+e.meta.terminalNodes[1],t.bondShift+=e.bonds.atomPairs.length+1,t.nodeShift+=e.atoms.atomTypes.length,t.backbonePositionShift[0]+=e.meta.backboneShift?.[0]??0,t.backbonePositionShift[1]+=t.flipFactor*(e.meta.backboneShift?.[1]??0)}(e,r)}function d(e,t,n,o,r){if(0===o.i)h(r.sugar,t,n,o);else for(const e of[r.phosphate,r.sugar])h(e,t,n,o);p(e,t,n,o)}function p(e,t,n,r){!function(e,t,n){for(let r=0;r<e.atoms.atomTypes.length;++r){const i=n.nodeShift+r+1;t[n.nodeShift+r]=o.u.V3K_BEGIN_DATA_LINE+i+" "+e.atoms.atomTypes[r]+" "+f(n.branchPositionShift[0]+e.atoms.x[r])+" "+f(n.branchPositionShift[1]+n.flipFactor*e.atoms.y[r])+" "+e.atoms.kwargs[r]}}(e,t,r),m(e,n,r),function(e,t,n){const r=n.bondShift,i=n.branchAttachNode,s=e.meta.terminalNodes[0]+n.nodeShift;t[r-1]=o.u.V3K_BEGIN_DATA_LINE+r+" 1 "+i+" "+s+"\n"}(e,n,r);const i=r.bondShift,s=r.branchAttachNode,a=e.meta.terminalNodes[0]+r.nodeShift;n[i-1]=o.u.V3K_BEGIN_DATA_LINE+i+" 1 "+s+" "+a+"\n",r.bondShift+=e.bonds.atomPairs.length+1,r.nodeShift+=e.atoms.atomTypes.length}function m(e,t,n){for(let r=0;r<e.bonds.atomPairs.length;++r){const i=n.bondShift+r+1,s=e.bonds.atomPairs[r][0]+n.nodeShift,a=e.bonds.atomPairs[r][1]+n.nodeShift;let l="";if(e.bonds.bondConfiguration.has(r)){let t=e.bonds.bondConfiguration.get(r);n.flipFactor<0&&(t=1===t?3:1),l=" CFG="+t}const c=e.bonds.kwargs.has(r)?" "+e.bonds.kwargs.get(r):"";t[n.bondShift+r]=o.u.V3K_BEGIN_DATA_LINE+i+" "+e.bonds.bondTypes[r]+" "+s+" "+a+l+c+"\n"}}function f(e){return Math.round(o.u.PRECISION_FACTOR*e)/o.u.PRECISION_FACTOR}},6077:(e,t,n)=>{"use strict";n.d(t,{C4:()=>f,eM:()=>y});var o=n(4328),r=n(6082),i=n(1991),s=n.n(i),a=n(439),l=n(3561),c=n(9235),u=n(294),h=n(9192),d=n(330),p=n(3599),m=n(8123);async function f(e,t,n,i,l){if(t.semType!==r.SEMTYPE.MACROMOLECULE)return{molCol:null,warnings:[`Only the ${r.SEMTYPE.MACROMOLECULE} columns can be converted to atomic level, the chosen column has semType '${t.semType}'`]};let f=t;const b=i.getSeqHandler(t),v=b.notation===a.Hi.HELM&&function(e,t){const n=t.getSeqHandler(e);if(n.notation!==a.Hi.HELM)return!1;let o=!1;for(let t=0;t<e.length;++t){const e=n.getSplitted(t);if(0===e.length)continue;const r=e.graphInfo,i=r?.polymerTypes;if(!i||i.length!==e.length)return!1;for(const e of i)if("RNA"!==e)return!1;o=!0}return o}(t,i);let C,x;v||b.notation===a.Hi.SEPARATOR||b.notation===a.Hi.BILN||(f=b.convert(a.Hi.SEPARATOR,"."),f.name=t.name);try{v?(C="RNA",x=function(e,t){const n=t.getSeqHandler(e);for(let t=0;t<e.length;++t){const e=n.getSplitted(t);for(let t=0;t<e.length;++t)if(t%3==0&&e.getCanonical(t)===m.u.DEOXYRIBOSE.symbol)return a.YI.DNA}return a.YI.RNA}(t,i)):(x=i.getSeqHandler(f).alphabet,C=(0,d.pz)(x))}catch(e){const[t,n]=(0,h.AP)(e);return{molCol:null,warnings:[t]}}const w=function(e,t){const n=e.length,r=new Array(n),i=t.getSeqHandler(e);let a=!1;const l=i.defaultBiotype;for(let e=0;e<n;++e){const t=i.getSplitted(e);a||(a=0===t.length),r[e]=s().count(0).take(t.length).filter((e=>!t.isGap(e))).map((e=>({position:e,biotype:l,symbol:t.getCanonical(e)}))).toArray()}return a&&o.shell.warning(`Some values in the "${e.name}" column are empty`),r}(f,i),A=v?function(e,t,n){const o=new Array(e.length);for(let r=0;r<e.length;++r){const i=e[r];if(0===i.length){o[r]=void 0;continue}const s=i.length>=1&&null!==g(t,n,i[0].symbol),a=i.length>=1&&!(s&&1===i.length)&&null!==g(t,n,i[i.length-1].symbol),l=i.length-(s?1:0)-(a?1:0);if(l<0||l%3!=0&&l%3!=2){o[r]=void 0;continue}const c=new Array(i.length);let h=0;for(let e=0;e<i.length;++e)0===e&&s?c[e]=u.ZN.TERMINAL_5P:e===i.length-1&&a?c[e]=u.ZN.TERMINAL_3P:(c[e]=h%3,h++);o[r]=c}return o}(w,n,C):new Array(w.length).fill(void 0);if(v)for(const e of w)for(const t of e)t.biotype=p.o.NUCLEOTIDE;const T=y(w,A,C,x,n,l),E=f.length,S=await(0,c.R)(f,T,x,C,n,i,l,A);S.warnings.length>.05*E&&o.shell.warning(`Molfile conversion resulted in ${S.warnings.length} errors`);const N=r.Func.find({name:"convertToV3KViaOCL"})[0];if(N&&S.molCol)try{const e=S.molCol.toList(),t=await N.apply({mols:e});S.molCol.init((n=>t[n]?t[n]:e[n]))}catch(e){console.error(e)}return S}function g(e,t,n){const o=e.getMonomer(t,n);if(!o||!o.rgroups||1!==o.rgroups.length)return null;if("Branch"===o.monomerType)return null;const r=o.rgroups[0].label;return"R1"===r?"r1-only":"R2"===r?"r2-only":null}function y(e,t,n,o,r,i){const s=(0,l.Hb)(r,n,o),c={},h={value:null};if("RNA"===n&&t.some((e=>void 0===e))){const e=o===a.YI.RNA?[m.u.RIBOSE,m.u.PHOSPHATE]:[m.u.DEOXYRIBOSE,m.u.PHOSPHATE];for(const t of e)b(c,t.symbol,s,i,n,h,void 0)}for(let o=0;o<e.length;++o){const r=e[o],a=t[o];for(let e=0;e<r.length;++e){const t=r[e].symbol;if(""===t)continue;const o=a?a[e]:void 0;try{if("RNA"===n&&void 0===o&&3===t.split(/\(|\)/).filter((e=>!!e)).length){const e=t.split(/\(|\)/)[1];b(c,e,s,i,n,h,u.ZN.BASE),c[n]?.[e]&&(c[n][t]=c[n][e])}else b(c,t,s,i,n,h,o)}catch(e){const n=e instanceof Error?e.message:e.toString(),o=e instanceof Error?e.stack:void 0;throw console.error(`bio lib: getMonomersDictFromLib() sym='${t}', error:\n${n}\n${o}`),new Error(`Can't get monomer '${t}' from library: ${n}`)}}}return c}function b(e,t,n,o,r,i,s){const a={polymerType:r,symbol:t};if(!(0,u.bq)(e,a)){const c=function(e,t,n,o,r,i){if(t.has(e)){const a=t.get(e),c=function(e){const t=[];for(const n of e){let e=n.capGroupSmiles;e||(e=n.capGroupSMILES),e=e.replace(/(\[|\]|\*|:|\d)/g,"").replace("OH","O").replace("Oh","O"),t.push(e)}return t}(a.rgroups),h=(s=a.molfile).includes("V3000")?function(e){const t=new Map,n=/M V30 (\d+) R#.+RGROUPS=\((\d+) (\d+)\).*/gm;let o;for(;null!==(o=n.exec(e));)o.index===n.lastIndex&&n.lastIndex++,t.set(parseInt(o[1]),parseInt(o[3]));return t}(s):function(e){const t=new Map;let n=e.indexOf(m.u.V2K_A_LINE,0),o=n;for(;-1!==n;){o=e.indexOf("\n",n);const r=parseInt(e.substring(n,o).replace(/^A\s+/,""));n=e.indexOf("R",o),o=e.indexOf("\n",n);const i=parseInt(e.substring(n,o).replace(/^R/,""));t.set(r,i),n=e.indexOf(m.u.V2K_A_LINE,o)}for(n=e.indexOf(m.u.V2K_RGP_LINE,0),o=e.indexOf("\n",n);-1!==n;){n+=m.u.V2K_RGP_SHIFT,o=e.indexOf("\n",n);const r=e.substring(n,o).replaceAll(/\s+/g," ").split(" ").map((e=>parseInt(e))).slice(1);for(let e=0;e<r.length;e+=2){if(t.has(r[e])&&t.get(r[e])!==r[e+1])throw new Error(`r-group index ${r[e]} has already been added with a different value`);t.set(r[e],r[e+1])}n=e.indexOf(m.u.V2K_RGP_LINE,o)}return t}(s),d=a.molfile.includes("V3000")?a.molfile:function(e,t){const n=t.get_mol(function(e){return e.split("\n").map((e=>{const t=e.indexOf(" R# "),n=e.indexOf(" R ");if(-1===t&&-1===n)return e;const o=-1!==t?t:n,r=e.split("");for(let e=o+5;e<r.length;e++)" "!==r[e]&&(r[e]="0");return r.join("")})).join("\n")}(e)),o=n.get_v3Kmolblock();return n.delete(),o}(function(e){let t=e.indexOf(m.u.V2K_A_LINE,0);-1===t&&(t=e.indexOf(m.u.V2K_RGP_LINE));const n=e.indexOf(m.u.V3K_END,t);return e.substring(0,t)+e.substring(n)}(a.molfile),n),p=function(e){let t=(e=e.replaceAll("\r","")).indexOf(m.u.V3K_BEGIN_COUNTS_LINE)+m.u.V3K_COUNTS_SHIFT,n=e.indexOf(" ",t+1);const o=parseInt(e.substring(t,n));return t=n+1,n=e.indexOf(" ",t+1),{atomCount:o,bondCount:parseInt(e.substring(t,n))}}(d),f=function(e,t){const n=new Array(t),o=new Float32Array(t),r=new Float32Array(t),i=new Array(t);let s=e.indexOf(m.u.V3K_BEGIN_ATOM_BLOCK);s=e.indexOf("\n",s);let a=s;for(let l=0;l<t;l++){s=e.indexOf(m.u.V3K_BEGIN_DATA_LINE,s)+m.u.V3K_IDX_SHIFT,a=e.indexOf(" ",s),s=a+1,a=e.indexOf(" ",s),n[l]=e.substring(s,a);const t=new Array(2);for(let n=0;n<2;++n)s=a+1,a=e.indexOf(" ",s),t[n]=parseFloat(e.substring(s,a));o[l]=t[0],r[l]=t[1],s=a,a=e.indexOf("\n",s)+1,i[l]=e.slice(s,a),s=a}return{atomTypes:n,x:o,y:r,kwargs:i}}(d,p.atomCount),g=function(e,t){const n=new Uint32Array(t),o=new Array(t),r=new Map,i=new Map;let s=e.indexOf(m.u.V3K_BEGIN_BOND_BLOCK);s=e.indexOf("\n",s);let a=s;for(let l=0;l<t;++l){const t=new Array(3);s=e.indexOf(m.u.V3K_BEGIN_DATA_LINE,a)+m.u.V3K_IDX_SHIFT,a=e.indexOf(" ",s);for(let n=0;n<3;++n)s=a+1,a=Math.min(e.indexOf("\n",s),e.indexOf(" ",s)),t[n]=parseInt(e.slice(s,a));n[l]=t[0],o[l]=t.slice(1);const c=e.indexOf("\n",s);let u=e.slice(a,c),h=u.indexOf(m.u.V3K_BOND_CONFIG);if(-1!==h){h=u.indexOf("=",h)+1;let e=u.indexOf(" ",h);-1===e&&(e=u.length);const t=parseInt(u.slice(h,e));r.set(l,t);const n=m.u.V3K_BOND_CONFIG+t.toString();u=u.replace(n,"")}u||i.set(l,u)}return{bondTypes:n,atomPairs:o,bondConfiguration:r,kwargs:i}}(d,p.bondCount),y=function(e,t,n,o){const r={backboneShift:null,branchShift:null,terminalNodes:[],rNodes:[]};if(n&&o&&[1,2].some((e=>!Array.from(o.values()).find((t=>t==e))))){const r=[1,2].find((e=>!Array.from(o.values()).find((t=>t==e)))),i=[1,2].find((e=>Array.from(o.values()).find((t=>t==e)))),s=Array.from(o.keys()).find((e=>o.get(e)===i))-1,a=e.x[s],l=e.y[s],c=t.atomPairs.find((e=>e.includes(s+1))).find((e=>e!==s+1))-1;let u=e.x.reduce(((t,n,o)=>{if(o===s)return t;if(o===c)return t;const r=e.y[o];return Math.sqrt((n-a)**2+(r-l)**2)>Math.sqrt((e.x[t]-a)**2+(e.y[t]-l)**2)?o:t}),-1);if(-1===u&&(u=e.x.length,e.x=new Float32Array([...e.x,-a]),e.y=new Float32Array([...e.y,-l]),e.atomTypes=[...e.atomTypes,"H"],e.kwargs=[...e.kwargs,""],t.atomPairs.push([c+1,u+1]),t.bondTypes=new Uint32Array([...t.bondTypes,1]),t.kwargs.set(t.atomPairs.length-1,"")),o.set(u+1,r),1===r)n.unshift(e.atomTypes[u]);else{if(2!==r)throw new Error(`Unexpected missing R-group: ${r}`);n.splice(1,0,e.atomTypes[u])}}return function(e,t,n){for(const[o,r]of n)e.atomTypes[o-1]=t[r-1]}(e,n,o),function(e,t){t.rNodes=Array.from(e.keys());for(let n=0;n<t.rNodes.length;n++)for(const o of[1,2])if(e.get(t.rNodes[n])===o){const e=t.rNodes[o-1];t.rNodes[o-1]=t.rNodes[n],t.rNodes[n]=e}}(o,r),v(t,r),r}(f,g,c,h),b=function(e){let t=[],n=e.indexOf("M V30 MDLV30/STEABS ATOMS=(");for(;-1!==n;){n+=28;const o=e.indexOf(")",n);t=t.concat(e.substring(n,o).split(" ").slice(1).map((e=>parseInt(e)))),n=o,n=e.indexOf("M V30 MDLV30/STEABS ATOMS=(",n)}return t}(d),x={atoms:f,bonds:g,meta:y,stereoAtoms:b};if("PEPTIDE"===o)T(x);else{const t=i===u.ZN.SUGAR||void 0===i&&(e===m.u.RIBOSE.symbol||e===m.u.DEOXYRIBOSE.symbol),n=i===u.ZN.PHOSPHATE||void 0===i&&e===m.u.PHOSPHATE.symbol;if(i===u.ZN.TERMINAL_5P||i===u.ZN.TERMINAL_3P){const e=a.rgroups?.[0]?.label,t="R1"===e?0:"R2"===e?1:-1,n=i===u.ZN.TERMINAL_5P?1:0;-1!==t&&t!==n&&([x.meta.rNodes[0],x.meta.rNodes[1]]=[x.meta.rNodes[1],x.meta.rNodes[0]],[x.meta.terminalNodes[0],x.meta.terminalNodes[1]]=[x.meta.terminalNodes[1],x.meta.terminalNodes[0]]),T(x)}else t?function(e,t){const n=e.atoms.x,o=e.atoms.y;let r=e.meta.terminalNodes[0]-1;const i=e.meta.rNodes[1]-1;M(e,-n[r],-o[r]);const s=E(n[e.meta.rNodes[2]-1],o[e.meta.rNodes[2]-1]);S(e.atoms,-s),n[e.meta.rNodes[0]-1]>n[e.meta.rNodes[1]-1]&&N(e);const a=E(n[i],o[i]);S(e.atoms,3*Math.PI/2-a),t.value=function(e){const t=e.atoms.x,n=e.atoms.y,o=e.meta.rNodes[2]-1,r=e.meta.terminalNodes[2]-1,i=t[o]-t[r],s=n[o]-n[r];return Math.atan2(i,s)}(e),r=e.meta.terminalNodes[0]-1,M(e,-n[r],-o[r])}(x,r):n?function(e){const t=e.meta.rNodes[1]-1,n=e.meta.rNodes[0]-1,o=e.atoms.x,r=e.atoms.y;M(e,-o[t],-r[t]);const i=E(o[n],r[n]);S(e.atoms,Math.PI/2-i)}(x):function(e,t){const n=e.atoms.x,o=e.atoms.y,r=e.meta.terminalNodes[0]-1,i=e.meta.rNodes[0]-1;M(e,-n[r],-o[r]);const s=E(n[i],o[i]),a=t.value;if(!a)throw new Error("The value of sugarBranchToOYAngle is null");S(e.atoms,Math.PI-s+a);const c=function(e,t){return(0,l.YN)(Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2))}({x:n[e.meta.rNodes[0]-1],y:o[e.meta.rNodes[0]-1]},{x:n[e.meta.terminalNodes[0]-1],y:o[e.meta.terminalNodes[0]-1]});if(1!=c)for(let e=0;e<n.length;++e)n[e]=(0,l.YN)(n[e]/c),o[e]=(0,l.YN)(o[e]/c)}(x,r)}return function(e,t,n,o){if("PEPTIDE"===e){C(t,e);const n=w(t,t.meta.rNodes[1]);n?.removedAtom&&(t.terminalR2Atom=n.removedAtom)}else if(o===u.ZN.TERMINAL_5P)C(t,e),w(t,t.meta.rNodes[1]);else if(o===u.ZN.TERMINAL_3P)w(t,t.meta.rNodes[0]);else{const r=o===u.ZN.SUGAR||void 0===o&&(n===m.u.RIBOSE.symbol||n===m.u.DEOXYRIBOSE.symbol),i=o===u.ZN.PHOSPHATE||void 0===o&&n===m.u.PHOSPHATE.symbol;if(r)w(t,t.meta.rNodes[1]),t.meta.rNodes[1]=t.meta.terminalNodes[1],v(t.bonds,t.meta),C(t,e),w(t,t.meta.rNodes[1]),w(t,t.meta.rNodes[0]),w(t,t.meta.rNodes[2]);else if(i){const n=t.meta.rNodes[0]-1,o=t.atoms.atomTypes[n];o?.toUpperCase()===m.u.HYDROGEN||(t.meta.terminalNodes[0]=t.meta.rNodes[0],M(t,-t.atoms.x[t.meta.terminalNodes[0]-1],-t.atoms.y[t.meta.terminalNodes[0]-1])),C(t,e),w(t,t.meta.rNodes[1])}}}(o,x,e,i),function(e){let t=0;for(;t<e.atoms.atomTypes.length;)e.atoms.atomTypes[t]===m.u.HYDROGEN&&(w(e,t+1),--t),++t}(x),function(e){let t=0;for(;t<e.atoms.atomTypes.length;)"oh"===e.atoms.atomTypes[t]?.toLowerCase()&&(e.atoms.atomTypes[t]="O"),"?"===e.atoms.atomTypes[t]&&(e.atoms.atomTypes[t]="H"),++t}(x),function(e){const t=" RGROUPS=(1 1)";for(let n=0;n<(e.atoms.kwargs?.length??0);n++){const o=e.atoms.kwargs[n];o&&o.includes(t)&&(e.atoms.kwargs[n]=o.replace(t,""))}}(x),x}var s;return null}(t,n,o,r,i,s);if(!c)throw new Error(`Monomer with symbol '${t}' is absent the monomer library`);(0,u.LQ)(e,a,c)}}function v(e,t){const n=t.rNodes;t.terminalNodes=new Array(n.length).fill(0);const o=t.terminalNodes,r=e.atomPairs;let i=0,s=0;for(;i<r.length&&s<o.length;){for(let e=0;e<o.length;++e)for(let t=0;t<2;++t)r[i][t]===n[e]&&(o[e]=r[i][(t+1)%2],n.length,++s);++i}}function C(e,t){e.meta.rNodes.length>1&&(e.meta.backboneShift=x(e,e.meta.rNodes[1]-1,e.meta.terminalNodes[0]-1)),"RNA"===t&&e.meta.rNodes.length>2&&(e.meta.branchShift=x(e,e.meta.rNodes[2]-1,e.meta.terminalNodes[0]-1))}function x(e,t,n){return[(0,l.YN)(e.atoms.x[t]-e.atoms.x[n]),(0,l.YN)(e.atoms.y[t]-e.atoms.y[n])]}function w(e,t){if(void 0!==t){const n=t-1,o=e.atoms,r=e.bonds,i=e.meta,s=o.atomTypes.splice(n,1)[0];o.x=A(Float32Array,o.x,n,1),o.y=A(Float32Array,o.y,n,1),o.kwargs.splice(n,1);for(let e=0;e<i.terminalNodes.length;++e)i.terminalNodes[e]>t?--i.terminalNodes[e]:i.terminalNodes[e]===t&&(i.terminalNodes[e]=-1);for(let e=0;e<i.rNodes.length;++e)i.rNodes[e]>t?--i.rNodes[e]:i.rNodes[e]===t&&(i.rNodes[e]=-1);let a=0;for(;a<r.atomPairs.length;){const e=r.atomPairs[a][0],n=r.atomPairs[a][1];e===t||n===t?(r.atomPairs.splice(a,1),r.bondTypes=A(Uint32Array,r.bondTypes,a,1),r.bondConfiguration.has(a)&&r.bondConfiguration.delete(a),r.kwargs.has(a)&&r.kwargs.delete(a),--a):(r.atomPairs[a][0]=e>t?e-1:e,r.atomPairs[a][1]=n>t?n-1:n),++a}let l=Array.from(r.bondConfiguration.keys());return l.forEach((e=>{if(r.bondConfiguration.has(e)&&e>n){const t=r.bondConfiguration.get(e);r.bondConfiguration.delete(e),r.bondConfiguration.set(e-1,t)}})),l=Array.from(r.kwargs.keys()),l.forEach((e=>{if(r.kwargs.has(e)&&e>n){const t=r.kwargs.get(e);r.kwargs.delete(e),r.kwargs.set(e-1,t)}})),s?{removedAtom:s}:void 0}}function A(e,t,n,o){const r=new e(t.length-o);let i=0,s=0;for(;i<t.length;)i===n&&(i+=o),r[s]=t[i],++s,++i;return r}function T(e){const t=e.meta.terminalNodes[0]-1,n=e.meta.rNodes[0]-1,o=e.atoms.x,r=e.atoms.y;M(e,-o[t],-r[t]);const i=E(o[n],r[n]);S(e.atoms,-i),o[e.meta.rNodes[1]-1]<0&&N(e);const s=function(e){const t=function(e){const t=new Map;for(const n of e.bonds.atomPairs)for(let e=0;e<2;e++){const o=n[e],r=n[(e+1)%2];t.has(o)?t.get(o)?.push(r):t.set(o,new Array(1).fill(r))}return t}(e);let n=0;const o=e.atoms.atomTypes.length;let r=0;if(e.meta.terminalNodes.length<2)return null;for(;0===n;){const i=t.get(e.meta.terminalNodes[1])[r];if(e.atoms.atomTypes[i-1]===m.u.OXYGEN&&i!==e.meta.rNodes[1]&&(n=i),r++,r>o)return null}return n}(e);null!=s&&(function(e,t){e.atoms.y[e.meta.rNodes[1]-1]<0&&e.atoms.y[t-1]<0&&(function(e){I(e,!0)}(e),S(e.atoms,-function(e,t){return E(e,t)+Math.PI/2}(e.atoms.x[e.meta.terminalNodes[1]-1],e.atoms.y[e.meta.terminalNodes[1]-1])))}(e,s),function(e,t){const n=e.atoms.x;n[e.meta.rNodes[1]-1]>n[t-1]&&function(e,t,n){const o=t-1,r=n-1,i=e.atoms.x,s=e.atoms.y,a=i[o],l=s[o];i[o]=i[r],s[o]=s[r],i[r]=a,s[r]=l}(e,t,e.meta.rNodes[1])}(e,s))}function E(e,t){let n;if(0===e)n=t>0?0:Math.PI;else if(0===t)n=e>0?-Math.PI/2:Math.PI/2;else{const o=t/e,r=Math.atan(o);n=e<0?Math.PI/2+r:-Math.PI/2+r}return n}function S(e,t){if(0!==t){const n=e.x,o=e.y,r=Math.cos(t),i=Math.sin(t);for(let e=0;e<n.length;++e){const t=n[e];n[e]=(0,l.YN)(t*r-o[e]*i),o[e]=(0,l.YN)(t*i+o[e]*r)}}}function N(e){I(e,!1)}function I(e,t){if(t){const t=e.atoms.y;for(let e=0;e<t.length;e++)t[e]=-t[e]}else{const t=e.atoms.x;for(let e=0;e<t.length;e++)t[e]=-t[e]}const n=e.bonds.bondConfiguration;for(const[e,t]of n){const o=1===t?3:1;n.set(e,o)}}function M(e,t,n){const o=e.atoms.x,r=e.atoms.y;for(let e=0;e<o.length;++e)o[e]=(0,l.YN)(o[e]+t),void 0!==n&&(r[e]=(0,l.YN)(r[e]+n))}},294:(e,t,n)=>{"use strict";function o(e,t){return e[t.polymerType]?.[t.symbol]}function r(e,t){return!!e[t.polymerType]?.[t.symbol]}function i(e,t,n){let o=e[t.polymerType];o||(o=e[t.polymerType]={}),o[t.symbol]=n}var s;n.d(t,{Cg:()=>a,LQ:()=>i,ZN:()=>s,bq:()=>r,vF:()=>l,xb:()=>o}),function(e){e[e.SUGAR=0]="SUGAR",e[e.BASE=1]="BASE",e[e.PHOSPHATE=2]="PHOSPHATE",e[e.TERMINAL_5P=3]="TERMINAL_5P",e[e.TERMINAL_3P=4]="TERMINAL_3P"}(s||(s={}));class a extends Map{constructor(e){super(e)}}class l{constructor(e,t){this.molfile=e,this.monomers=t}static createEmpty(){return new l("",new a(null))}}},330:(e,t,n)=>{"use strict";n.d(t,{pz:()=>i,qj:()=>r,vG:()=>s});var o=n(2003);function r(e,t){return function(e,t){return e?e.columns.getUnusedName(t):t}(e,`molfile(${t})`)}function i(e){let t;if(e===o.YI.PT||e===o.YI.UN)t="PEPTIDE";else{if(e!==o.YI.RNA&&e!==o.YI.DNA)throw new Error(`Unexpected alphabet '${e}'.`);t="RNA"}return t}function s(e){const t=7===e.length?/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e):/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?[parseInt(t[1],16)/256,parseInt(t[2],16)/256,parseInt(t[3],16)/256,t.length>4?parseInt(t[4],16)/256:.3]:null}},4971:(e,t,n)=>{"use strict";n.d(t,{pj:()=>r});var o=n(6082);async function r(){const e=o.Func.find({package:"Bio",name:"getMonomerLibHelper"});if(0===e.length)throw new Error('Package "Bio" must be installed for MonomerLibHelper.');return(await e[0].prepare().call()).getOutputParamValue()}},3151:(e,t,n)=>{"use strict";n.d(t,{f6:()=>o,pe:()=>r});const o=["symbol","molfile","rgroups","name"],r={monomerType:"Backbone",smiles:"",name:"",author:"Datagrok",molfile:"",naturalAnalog:"",rgroups:[],createDate:null,id:0,polymerType:"PEPTIDE",symbol:""};new RegExp("[rd]\\((\\w)\\)p?","g")},9192:(e,t,n)=>{"use strict";function o(e){return"string"==typeof e||e instanceof String?e:"StateError"===e.constructor.name?e.message:"StateError"===e.constructor.name&&"$thrownJsError"in e?o(e.$thrownJsError):e instanceof Error?e.message:e.toString()}function r(e){return e instanceof Error?e.stack:"StateError"===e.constructor.name&&"$thrownJsError"in e?r(e.$thrownJsError):void 0}function i(e){return[o(e),r(e)]}n.d(t,{AP:()=>i})},439:(e,t,n)=>{"use strict";n.d(t,{Hi:()=>o,VR:()=>u,YI:()=>r,_S:()=>l,b9:()=>c,gp:()=>i,qE:()=>i});var o,r,i,s=n(2738);!function(e){e.FASTA="fasta",e.SEPARATOR="separator",e.HELM="helm",e.CUSTOM="custom",e.BILN="biln"}(o||(o={})),function(e){e.DNA="DNA",e.RNA="RNA",e.PT="PT",e.UN="UN"}(r||(r={})),function(e){e.aligned="aligned",e.alphabet="alphabet",e.alphabetSize=".alphabetSize",e.alphabetIsMultichar=".alphabetIsMultichar",e.separator="separator",e.isHelmCompatible=".isHelmCompatible",e.positionNames=".positionNames",e.positionLabels=".positionLabels",e.regions=".regions",e.positionShift=".positionShift",e.selectedPosition=".selectedPosition",e.polymerTypeColumnName=".polymerTypeColumnName",e.annotations=".annotations",e.numberingScheme=".numberingScheme",e.annotationColumnName=".annotationColumnName"}(i||(i={}));const 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 s.aD(r.PT,a.fasta.peptide,.5),new s.aD(r.DNA,a.fasta.dna,.55),new s.aD(r.RNA,a.fasta.rna,.55),""),c={[o.FASTA]:"-",[o.SEPARATOR]:"",[o.HELM]:"*",[o.BILN]:""},u="notationProviderConstructor"},2003:(e,t,n)=>{"use strict";n.d(t,{Hi:()=>o.Hi,YI:()=>o.YI,dh:()=>r.dh,gp:()=>o.gp,qp:()=>r.qp,zS:()=>r.zS});var o=n(439),r=n(7291)},2738:(e,t,n)=>{"use strict";n.d(t,{$G:()=>r,aD:()=>i});var o=n(439);class r{static get notationName(){return"Custom"}static get implementsFromHelm(){return!1}static convertFromHelm(e,t){throw new Error("Method convertFromHelm not implemented for this notation provider")}static async getProviderConstructors(){if(window?.DG){const e=window.DG.Func.find({meta:{role:o.VR}});return Promise.all(e.map((e=>e.apply({}))))}return[]}}class i{constructor(e,t,n){this.name=e,this.alphabet=t,this.cutoff=n}}},7291:(e,t,n)=>{"use strict";n.d(t,{Mu:()=>b,dh:()=>C,zS:()=>E,MD:()=>S,qp:()=>A});var o=n(6082),r=n(1991),i=n.n(r),s=(n(2738),n(439));class a{static makePalette(e,t=!1,n=a){const o={};return e.forEach((e=>{const n=e[0],r=e[1];n.forEach(((e,n)=>{o[e]=this.colourPalette[r][t?0:n]}))})),new n(o)}constructor(e){this._palette=e}get(e,t){return this._palette[e]}}a.undefinedColor="rgb(100,100,100)",a.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)"]};class l extends a{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,l)),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,l)),this.grokGroups}static get RasMol(){return void 0===this.rasMol&&(this.rasMol=new l({D:"#E60A0A",E:"#E60A0A",C:"#E6E600",M:"#E6E600",K:"#145AFF",R:"#145AFF",S:"#FA9600",T:"#FA9600",F:"#3232AA",Y:"#3232AA",N:"#00DCDC",Q:"#00DCDC",G:"#EBEBEB",L:"#0F820F",V:"#0F820F",I:"#0F820F",A:"#C8C8C8",W:"#B45AB4",H:"#8282D2",P:"#DC9682",others:"#BEA06E"})),this.rasMol}get(e){const t=e in l.aaSynonyms?l.aaSynonyms[e]:e;return super.get(t)}}l.aaSynonyms={MeNle:"L",MeA:"A",MeG:"G",MeF:"F"};class c{static getPalette(e="grok"){switch(e){case"grok":return l.GrokGroups;case"lesk":return l.Lesk;default:throw new Error(`ChemPalette: scheme \`${e}\` does not exist`)}}static getInnerOuter(e){let t=0,n="",o="";for(const r of e)"("==r?t++:")"==r?t--:t?n+=r:o+=r;return isNaN(parseInt(n))?[o,n]:[o,""]}static getColorAAPivot(e="",t="grok"){const n=this.getPalette(t);let[o,r]=this.getInnerOuter(e);if(o=o.length>6?`${o.slice(0,3)}...`:o,r=r.length>6?`${r.slice(0,3)}...`:r,1==e.length||"("==e[1]){const t=e[0]?.toUpperCase();return t in n?[n.get(t),t,r,1]:[this.undefinedColor,o,r,1]}if("d"==e[0]&&e[1]in n&&(2==e.length||"("==e[2])){const t=e[1]?.toUpperCase();return t in n?[n.get(t),t,r,2]:[this.undefinedColor,o,r,2]}if(e.substring(0,3)in this.AAFullNames&&(3==e.length||"("==e[3])){const t=this.AAFullNames[e.substring(0,3)];return t in n?[n.get(t),t,r,3]:[this.undefinedColor,o,r,3]}if(e[0]?.toLowerCase()==e[0]&&e.substring(1,3)in this.AAFullNames&&(4==e.length||"("==e[4])){const t=this.AAFullNames[e.substring(1,3)];return t in n?[n.get(t),t,r,4]:[this.undefinedColor,o,r,4]}return[this.undefinedColor,o,r,0]}}c.SemType="Aminoacids",c.SemTypeMultipleAlignment="AminoacidsMultipleAlignment",c.undefinedColor="rgb(100,100,100)",c.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"},c.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"},c.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(*)*"},c.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"};class u{}u.SemType="Nucleotides",u.SemTypeMultipleAlignment="NucleotidesMultipleAlignment",u.Names={A:"Adenine",C:"Cytosine",G:"Guanine",T:"Thymine",U:"Uracil"};var h=n(4971);function d(e,t=!0){if(null==e)return"rgb(100,100,100)";const n=o.Color.fromHtml(e);if(t){const e=o.Color.g(n),t=o.Color.r(n),r=o.Color.b(n),i=Math.sqrt(Math.pow(0-t,2)+Math.pow(0-e,2)+Math.pow(0-r,2));if(i>210)return`rgb(${t/i*210},${e/i*210},${r/i*210})`}return o.Color.toRgb(n)}class p{static hashCode(e){let t=0;if(0===e.length)return t;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t}}class m{}class f extends m{static get palette(){return f._pallete||(f._pallete=f.buildPalette()),f._pallete}static buildPalette(){return(0,h.pj)().then((e=>{e.awaitLoaded(1/0).then((()=>{const t=e.getMonomerLib();t.onChanged.subscribe((()=>{f.customMonomerColors={},f.polymerTypes=t.getPolymerTypes();for(const e of this.polymerTypes){const n=t.getMonomerSymbolsByType(e);for(const o of n){const n=t.getMonomer(e,o);n?.meta?.colors?.default?.background&&(this.customMonomerColors[o]||(this.customMonomerColors[o]={}),this.customMonomerColors[o][e]=d(n.meta.colors.default.background))}}}))}))})),[].concat(...Object.values(a.colourPalette))}get(e,t){const n=f.palette.length,o=f.customMonomerColors[e],r=t??"PEPTIDE";if(o&&o[r])return o[r];const i=p.hashCode(e)%n;return d(f.palette[i])}}f._pallete=null,f.customMonomerColors={},f.polymerTypes=[];var g=n(8438),y=n(3599);class b{get length(){return this.mList.length}get graphInfo(){}isGap(e){return this.getOriginal(e)===this.gapOriginalMonomer}getCanonical(e){if(this.length<=e)throw new Error("Index out of bounds");const t=this.mList[e];return t!==this.gapOriginalMonomer?t:s._S}getOriginal(e){if(this.length<=e)throw new Error("Index out of bounds");return this.mList[e]}getCanonicalRegion(e,t){const n=Math.min(Math.max(0,e),this.length),o=Math.max(Math.min(this.length,t),0)-n,r=this.gapOriginalMonomer;return new Array(o).fill(null).map(((e,t)=>{const o=this.mList[t+n];return o===r?s._S:o}))}getOriginalRegion(e,t){const n=Math.min(Math.max(0,e),this.length),o=Math.max(Math.min(this.length,t),0);return new Array(o-n).fill(null).map(((e,t)=>this.mList[t+n]))}get gapOriginal(){return this.gapOriginalMonomer}constructor(e,t){this.mList=e,this.gapOriginalMonomer=t}}class v extends b{constructor(e,t,n,o){super(e.flat(),o),this.mListSeparated=e,this.connections=t,this._graphInfo=void 0,this.polymerTypes=e.map(((e,t)=>new Array(e.length).fill(n[t]))).flat()}get graphInfo(){return this._graphInfo??(this._graphInfo=this.parseConnections()),this._graphInfo}parseConnections(){const e={connections:[],disjointSeqStarts:[],polymerTypes:this.polymerTypes};if((this.connections?.length??0)>0){let t=0;for(let n=0;n<this.mListSeparated.length;++n)e.disjointSeqStarts.push(t),t+=this.mListSeparated[n].length;const n=(this.connections??"").split("|").filter((e=>(e?.length??0)>0)),o=/^(PEPTIDE|RNA|BLOB|CHEM)\d{1,2}$/,r=/^\d{1,2}:R\d{1}-\d{1,2}:R\d{1}$/;for(const t of n){const n=t.split(",");if(3!==n.length||!r.test(n[2])||!o.test(n[0])||!o.test(n[1]))continue;const i=parseInt(n[0].replace(/^(PEPTIDE|RNA|BLOB|CHEM)/,""))-1,s=parseInt(n[1].replace(/^(PEPTIDE|RNA|BLOB|CHEM)/,""))-1,a=n[0].replace(/\d{1,2}$/,""),l=n[1].replace(/\d{1,2}$/,"");if(i<0||i>=this.mListSeparated.length||s<0||s>=this.mListSeparated.length)continue;const c=n[2].split("-");if(2!==c.length)continue;const u=c[0].split(":"),h=c[1].split(":");if(2!==u.length||2!==h.length)continue;const d=parseInt(u[0])-1,p=parseInt(h[0])-1;d<0||d>=this.mListSeparated[i].length||p<0||p>=this.mListSeparated[s].length||e.connections.push({seq1Type:a,seq2Type:l,seqIndex1:i,seqIndex2:s,monomerIndex1:d,monomerIndex2:p,rGroup1:parseInt(u[1].substring(1)),rGroup2:parseInt(h[1].substring(1))})}}return e}}function C(e,t=void 0){return n=>{if(n){let o;const r=new RegExp(`(?<=^|\\${e})("-"|'-'|[^\\${e}]*)(?=\\${e}|$)`,"g");return null!=t?(r.lastIndex=0,o=i()(n.matchAll(r)).take(t).map((e=>e[0])).toArray()):o=n.replaceAll('"-"',"").replaceAll("'-'","").split(e,t),new b(o,s.b9[s.Hi.SEPARATOR])}return new b([],s.b9[s.Hi.SEPARATOR])}}const x=/^((?:[^\[\]()]|\[[^\[\]]*\])+)\(((?:[^\[\]()]|\[[^\[\]]*\])+)\)((?:[^\[\]()]|\[[^\[\]]*\])+)$/,w=/^((?:[^\[\]()]|\[[^\[\]]*\])+)\(((?:[^\[\]()]|\[[^\[\]]*\])+)\)$/,A=e=>{const t=e.indexOf("}$"),n=e.substring(0,t+1),o=e.indexOf("$",t+2),r=e.substring(t+2,o),i=n.split("}|");for(let e=0;e<i.length-1;e++)i[e]=i[e]+"}";const a=i.map((e=>e.replace(/\d{1,2}\{.+\}/,""))),l=i.map(((e,t)=>(e.match(/(?<=\{).+(?=})/)?.[0]?.split(".")??[]).flatMap((e=>{if("RNA"===a[t]){const t=x.exec(e);if(null!=t)return[(0,g.D)(t[1]),(0,g.D)(t[2]),(0,g.D)(t[3])];const n=w.exec(e);if(null!=n)return[(0,g.D)(n[1]),(0,g.D)(n[2])]}return[(0,g.D)(e)]}))));return new v(l,r??"",a,s.b9[s.Hi.HELM])},T=/([^\W_]+)/g;function E(e,t){if(e.length<=t)return e;const n=e.match(T),o=e.length>t||(n?.length??0)>1,r=n?.[0]??" ";return o?r.substring(0,t-1)+"…":r}function S(e){switch(e){case"PEPTIDE":default:return y.o.AA;case"RNA":return y.o.NUCLEOTIDE;case"CHEM":return y.o.CHEM;case"BLOB":return y.o.BLOB}}},8312:(e,t,n)=>{"use strict";n.d(t,{Q:()=>r});var o=n(6082);async function r(){const e=o.Func.find({package:"Bio",name:"getSeqHelper"});if(0===e.length)throw new Error("Package 'Bio' must be installed for SeqHelper.");return(await e[0].prepare().call()).getOutputParamValue()}},6869:(e,t,n)=>{"use strict";var o;n.d(t,{o:()=>o}),function(e){e.BASE="HELM_BASE",e.SUGAR="HELM_SUGAR",e.LINKER="HELM_LINKER",e.AA="HELM_AA",e.CHEM="HELM_CHEM",e.BLOB="HELM_BLOB",e.NUCLEOTIDE="HELM_NUCLETIDE"}(o||(o={}))},2074:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var o=n(1354),r=n.n(o),i=n(6314),s=n.n(i)()(r());s.push([e.id,".st-colored-text-input > textarea {\n width: 100%;\n color: transparent !important;\n caret-color: var(--grey-6);\n -webkit-text-fill-color: transparent !important;\n background-color: transparent;\n position: relative;\n z-index: 1;\n resize: none;\n height: 22px; /* Fine tuned value to avoid \"jumping\" of the textarea upon autoresize */\n}\n\n.st-colored-text-input > div {\n /* The values here are fine tuned to those of the ui.input textarea in order\n * to achieve precise overlap */\n overflow: auto;\n position: absolute;\n pointer-events: none;\n cursor: text;\n z-index: 0;\n max-width: 100%;\n padding: 2px;\n line-height: normal;\n font-family: 'Roboto', 'Roboto Local', sans-serif;\n font-size: 13px;\n padding-top: 6px !important;\n color: transparent;\n white-space: pre-wrap;\n word-wrap: break-word;\n}\n","",{version:3,sources:["webpack://./src/apps/common/view/components/colored-input/style.css"],names:[],mappings:"AAAA;EACE,WAAW;EACX,6BAA6B;EAC7B,0BAA0B;EAC1B,+CAA+C;EAC/C,6BAA6B;EAC7B,kBAAkB;EAClB,UAAU;EACV,YAAY;EACZ,YAAY,EAAE,wEAAwE;AACxF;;AAEA;EACE;iCAC+B;EAC/B,cAAc;EACd,kBAAkB;EAClB,oBAAoB;EACpB,YAAY;EACZ,UAAU;EACV,eAAe;EACf,YAAY;EACZ,mBAAmB;EACnB,iDAAiD;EACjD,eAAe;EACf,2BAA2B;EAC3B,kBAAkB;EAClB,qBAAqB;EACrB,qBAAqB;AACvB",sourcesContent:[".st-colored-text-input > textarea {\n width: 100%;\n color: transparent !important;\n caret-color: var(--grey-6);\n -webkit-text-fill-color: transparent !important;\n background-color: transparent;\n position: relative;\n z-index: 1;\n resize: none;\n height: 22px; /* Fine tuned value to avoid \"jumping\" of the textarea upon autoresize */\n}\n\n.st-colored-text-input > div {\n /* The values here are fine tuned to those of the ui.input textarea in order\n * to achieve precise overlap */\n overflow: auto;\n position: absolute;\n pointer-events: none;\n cursor: text;\n z-index: 0;\n max-width: 100%;\n padding: 2px;\n line-height: normal;\n font-family: 'Roboto', 'Roboto Local', sans-serif;\n font-size: 13px;\n padding-top: 6px !important;\n color: transparent;\n white-space: pre-wrap;\n word-wrap: break-word;\n}\n"],sourceRoot:""}]);const a=s},9252:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var o=n(1354),r=n.n(o),i=n(6314),s=n.n(i)()(r());s.push([e.id,"/* Naming convention: class names should begin with st and app name to avoid naming collitions */\n\n.st-pattern-text-input > textarea {\n resize: none;\n}\n","",{version:3,sources:["webpack://./src/apps/pattern/view/style.css"],names:[],mappings:"AAAA,gGAAgG;;AAEhG;EACE,YAAY;AACd",sourcesContent:["/* Naming convention: class names should begin with st and app name to avoid naming collitions */\n\n.st-pattern-text-input > textarea {\n resize: none;\n}\n"],sourceRoot:""}]);const a=s},8507:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var o=n(1354),r=n.n(o),i=n(6314),s=n.n(i)()(r());s.push([e.id,"/* Naming convention: class names should begin with st and app name to avoid naming collitions */\n\n.st-structure-body {\n padding-right: 20px;\n height: 100%;\n display: flex;\n flex-direction: column;\n}\n\n.st-structure-mol-img {\n flex: 1 1 0;\n min-height: 100px;\n min-width: 0;\n transform: translateX(-50px);\n overflow: hidden;\n}\n\n.st-structure-mol-img canvas {\n max-width: 100% !important;\n height: auto !important;\n}\n\n.st-structure-bool-button-block {\n justify-content: right;\n margin-bottom: 10px;\n}\n\n.st-structure-bottom {\n flex: 1 1 0;\n padding-top: 20px;\n min-height: 0;\n}\n\n.st-structure-clear-buttons {\n justify-content: space-between;\n padding: 13px 10px 13px 10px;\n}\n\n.st-direction-inputs {\n align-items: end;\n}\n\n.st-structure-inputs {\n flex-grow: 2;\n padding-left: 10px;\n}","",{version:3,sources:["webpack://./src/apps/structure/view/style.css"],names:[],mappings:"AAAA,gGAAgG;;AAEhG;EACE,mBAAmB;EACnB,YAAY;EACZ,aAAa;EACb,sBAAsB;AACxB;;AAEA;EACE,WAAW;EACX,iBAAiB;EACjB,YAAY;EACZ,4BAA4B;EAC5B,gBAAgB;AAClB;;AAEA;EACE,0BAA0B;EAC1B,uBAAuB;AACzB;;AAEA;EACE,sBAAsB;EACtB,mBAAmB;AACrB;;AAEA;EACE,WAAW;EACX,iBAAiB;EACjB,aAAa;AACf;;AAEA;EACE,8BAA8B;EAC9B,4BAA4B;AAC9B;;AAEA;EACE,gBAAgB;AAClB;;AAEA;EACE,YAAY;EACZ,kBAAkB;AACpB",sourcesContent:["/* Naming convention: class names should begin with st and app name to avoid naming collitions */\n\n.st-structure-body {\n padding-right: 20px;\n height: 100%;\n display: flex;\n flex-direction: column;\n}\n\n.st-structure-mol-img {\n flex: 1 1 0;\n min-height: 100px;\n min-width: 0;\n transform: translateX(-50px);\n overflow: hidden;\n}\n\n.st-structure-mol-img canvas {\n max-width: 100% !important;\n height: auto !important;\n}\n\n.st-structure-bool-button-block {\n justify-content: right;\n margin-bottom: 10px;\n}\n\n.st-structure-bottom {\n flex: 1 1 0;\n padding-top: 20px;\n min-height: 0;\n}\n\n.st-structure-clear-buttons {\n justify-content: space-between;\n padding: 13px 10px 13px 10px;\n}\n\n.st-direction-inputs {\n align-items: end;\n}\n\n.st-structure-inputs {\n flex-grow: 2;\n padding-left: 10px;\n}"],sourceRoot:""}]);const a=s},5254:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var o=n(1354),r=n.n(o),i=n(6314),s=n.n(i)()(r());s.push([e.id,"/* Naming convention: class names should begin with st and app name to avoid naming collitions */\n.st-translator-input-table {\n /* width: 100%; */\n margin-right: 20px;\n}\n\n.st-translator-input-table td:has(textarea) {\n width: 100%;\n}\n\n.st-translator-input-table td:has(select) {\n min-width: 120px;\n vertical-align: top;\n}\n\n.st-translator-output-table {\n margin-top: 20px;\n margin-right: 20px;\n margin-bottom: 10px;\n}\n\n.st-translator-output-table table {\n width: 100%;\n table-layout: fixed;\n}\n\n.st-translator-output-table td {\n padding-top: 6px;\n padding-bottom: 6px;\n}\n.st-translator-output-table tr:nth-child(even) {\n background-color: var(--grey-1);\n}\n\n.st-translator-output-table td:nth-child(odd) {\n width: 120px;\n vertical-align: top;\n}\n\n.st-translator-output-table td a {\n overflow-wrap: break-word;\n}\n","",{version:3,sources:["webpack://./src/apps/translator/view/style.css"],names:[],mappings:"AAAA,gGAAgG;AAChG;EACE,iBAAiB;EACjB,kBAAkB;AACpB;;AAEA;EACE,WAAW;AACb;;AAEA;EACE,gBAAgB;EAChB,mBAAmB;AACrB;;AAEA;EACE,gBAAgB;EAChB,kBAAkB;EAClB,mBAAmB;AACrB;;AAEA;EACE,WAAW;EACX,mBAAmB;AACrB;;AAEA;EACE,gBAAgB;EAChB,mBAAmB;AACrB;AACA;EACE,+BAA+B;AACjC;;AAEA;EACE,YAAY;EACZ,mBAAmB;AACrB;;AAEA;EACE,yBAAyB;AAC3B",sourcesContent:["/* Naming convention: class names should begin with st and app name to avoid naming collitions */\n.st-translator-input-table {\n /* width: 100%; */\n margin-right: 20px;\n}\n\n.st-translator-input-table td:has(textarea) {\n width: 100%;\n}\n\n.st-translator-input-table td:has(select) {\n min-width: 120px;\n vertical-align: top;\n}\n\n.st-translator-output-table {\n margin-top: 20px;\n margin-right: 20px;\n margin-bottom: 10px;\n}\n\n.st-translator-output-table table {\n width: 100%;\n table-layout: fixed;\n}\n\n.st-translator-output-table td {\n padding-top: 6px;\n padding-bottom: 6px;\n}\n.st-translator-output-table tr:nth-child(even) {\n background-color: var(--grey-1);\n}\n\n.st-translator-output-table td:nth-child(odd) {\n width: 120px;\n vertical-align: top;\n}\n\n.st-translator-output-table td a {\n overflow-wrap: break-word;\n}\n"],sourceRoot:""}]);const a=s},890:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var o=n(1354),r=n.n(o),i=n(6314),s=n.n(i)()(r());s.push([e.id,".monomer-card-rule-root {\n border: 2px solid var(--grey-2);\n border-radius: 5px;\n padding: 5px;\n margin: 5px;\n overflow: hidden;\n align-items: center;\n cursor: pointer;\n width: 200px;\n height: 240px;\n min-width: 200px;\n min-height: 240px;\n}\n\n.monomer-card-info-rules {\n width: 100%;\n overflow: hidden;\n text-overflow: ellipsis;\n margin-bottom: 10px;\n}\n\n.monomer-card-info-rules > div:nth-child(2) {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.monomer-card-info-rules > div:nth-child(1) {\n font-weight: bold;\n margin-right: 5px;\n text-wrap: nowrap;\n}\n","",{version:3,sources:["webpack://./src/polytool/conversion/style.css"],names:[],mappings:"AAAA;IACI,+BAA+B;IAC/B,kBAAkB;IAClB,YAAY;IACZ,WAAW;IACX,gBAAgB;IAChB,mBAAmB;IACnB,eAAe;IACf,YAAY;IACZ,aAAa;IACb,gBAAgB;IAChB,iBAAiB;AACrB;;AAEA;IACI,WAAW;IACX,gBAAgB;IAChB,uBAAuB;IACvB,mBAAmB;AACvB;;AAEA;IACI,mBAAmB;IACnB,gBAAgB;IAChB,uBAAuB;AAC3B;;AAEA;IACI,iBAAiB;IACjB,iBAAiB;IACjB,iBAAiB;AACrB",sourcesContent:[".monomer-card-rule-root {\n border: 2px solid var(--grey-2);\n border-radius: 5px;\n padding: 5px;\n margin: 5px;\n overflow: hidden;\n align-items: center;\n cursor: pointer;\n width: 200px;\n height: 240px;\n min-width: 200px;\n min-height: 240px;\n}\n\n.monomer-card-info-rules {\n width: 100%;\n overflow: hidden;\n text-overflow: ellipsis;\n margin-bottom: 10px;\n}\n\n.monomer-card-info-rules > div:nth-child(2) {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.monomer-card-info-rules > div:nth-child(1) {\n font-weight: bold;\n margin-right: 5px;\n text-wrap: nowrap;\n}\n"],sourceRoot:""}]);const a=s},6314:e=>{"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var n="",o=void 0!==t[5];return t[4]&&(n+="@supports (".concat(t[4],") {")),t[2]&&(n+="@media ".concat(t[2]," {")),o&&(n+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),n+=e(t),o&&(n+="}"),t[2]&&(n+="}"),t[4]&&(n+="}"),n})).join("")},t.i=function(e,n,o,r,i){"string"==typeof e&&(e=[[null,e,void 0]]);var s={};if(o)for(var a=0;a<this.length;a++){var l=this[a][0];null!=l&&(s[l]=!0)}for(var c=0;c<e.length;c++){var u=[].concat(e[c]);o&&s[u[0]]||(void 0!==i&&(void 0===u[5]||(u[1]="@layer".concat(u[5].length>0?" ".concat(u[5]):""," {").concat(u[1],"}")),u[5]=i),n&&(u[2]?(u[1]="@media ".concat(u[2]," {").concat(u[1],"}"),u[2]=n):u[2]=n),r&&(u[4]?(u[1]="@supports (".concat(u[4],") {").concat(u[1],"}"),u[4]=r):u[4]="".concat(r)),t.push(u))}},t}},1354:e=>{"use strict";e.exports=function(e){var t=e[1],n=e[3];if(!n)return t;if("function"==typeof btoa){var o=btoa(unescape(encodeURIComponent(JSON.stringify(n)))),r="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(o),i="/*# ".concat(r," */");return[t].concat([i]).join("\n")}return[t].join("\n")}},9982:function(e,t,n){var o;!function(){var t={};!function(e){"use strict";e.__esModule=!0,e.digestLength=32,e.blockSize=64;var t=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function n(e,n,o,r,i){for(var s,a,l,c,u,h,d,p,m,f,g,y,b;i>=64;){for(s=n[0],a=n[1],l=n[2],c=n[3],u=n[4],h=n[5],d=n[6],p=n[7],f=0;f<16;f++)g=r+4*f,e[f]=(255&o[g])<<24|(255&o[g+1])<<16|(255&o[g+2])<<8|255&o[g+3];for(f=16;f<64;f++)y=((m=e[f-2])>>>17|m<<15)^(m>>>19|m<<13)^m>>>10,b=((m=e[f-15])>>>7|m<<25)^(m>>>18|m<<14)^m>>>3,e[f]=(y+e[f-7]|0)+(b+e[f-16]|0);for(f=0;f<64;f++)y=(((u>>>6|u<<26)^(u>>>11|u<<21)^(u>>>25|u<<7))+(u&h^~u&d)|0)+(p+(t[f]+e[f]|0)|0)|0,b=((s>>>2|s<<30)^(s>>>13|s<<19)^(s>>>22|s<<10))+(s&a^s&l^a&l)|0,p=d,d=h,h=u,u=c+y|0,c=l,l=a,a=s,s=y+b|0;n[0]+=s,n[1]+=a,n[2]+=l,n[3]+=c,n[4]+=u,n[5]+=h,n[6]+=d,n[7]+=p,r+=64,i-=64}return r}var o=function(){function t(){this.digestLength=e.digestLength,this.blockSize=e.blockSize,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this.reset()}return t.prototype.reset=function(){return this.state[0]=1779033703,this.state[1]=3144134277,this.state[2]=1013904242,this.state[3]=2773480762,this.state[4]=1359893119,this.state[5]=2600822924,this.state[6]=528734635,this.state[7]=1541459225,this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this},t.prototype.clean=function(){for(var e=0;e<this.buffer.length;e++)this.buffer[e]=0;for(e=0;e<this.temp.length;e++)this.temp[e]=0;this.reset()},t.prototype.update=function(e,t){if(void 0===t&&(t=e.length),this.finished)throw new Error("SHA256: can't update because hash was finished.");var o=0;if(this.bytesHashed+=t,this.bufferLength>0){for(;this.bufferLength<64&&t>0;)this.buffer[this.bufferLength++]=e[o++],t--;64===this.bufferLength&&(n(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(t>=64&&(o=n(this.temp,this.state,e,o,t),t%=64);t>0;)this.buffer[this.bufferLength++]=e[o++],t--;return this},t.prototype.finish=function(e){if(!this.finished){var t=this.bytesHashed,o=this.bufferLength,r=t/536870912|0,i=t<<3,s=t%64<56?64:128;this.buffer[o]=128;for(var a=o+1;a<s-8;a++)this.buffer[a]=0;this.buffer[s-8]=r>>>24&255,this.buffer[s-7]=r>>>16&255,this.buffer[s-6]=r>>>8&255,this.buffer[s-5]=r>>>0&255,this.buffer[s-4]=i>>>24&255,this.buffer[s-3]=i>>>16&255,this.buffer[s-2]=i>>>8&255,this.buffer[s-1]=i>>>0&255,n(this.temp,this.state,this.buffer,0,s),this.finished=!0}for(a=0;a<8;a++)e[4*a+0]=this.state[a]>>>24&255,e[4*a+1]=this.state[a]>>>16&255,e[4*a+2]=this.state[a]>>>8&255,e[4*a+3]=this.state[a]>>>0&255;return this},t.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},t.prototype._saveState=function(e){for(var t=0;t<this.state.length;t++)e[t]=this.state[t]},t.prototype._restoreState=function(e,t){for(var n=0;n<this.state.length;n++)this.state[n]=e[n];this.bytesHashed=t,this.finished=!1,this.bufferLength=0},t}();e.Hash=o;var r=function(){function e(e){this.inner=new o,this.outer=new o,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var t=new Uint8Array(this.blockSize);if(e.length>this.blockSize)(new o).update(e).finish(t).clean();else for(var n=0;n<e.length;n++)t[n]=e[n];for(n=0;n<t.length;n++)t[n]^=54;for(this.inner.update(t),n=0;n<t.length;n++)t[n]^=106;for(this.outer.update(t),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate),n=0;n<t.length;n++)t[n]=0}return e.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},e.prototype.clean=function(){for(var e=0;e<this.istate.length;e++)this.ostate[e]=this.istate[e]=0;this.inner.clean(),this.outer.clean()},e.prototype.update=function(e){return this.inner.update(e),this},e.prototype.finish=function(e){return this.outer.finished?this.outer.finish(e):(this.inner.finish(e),this.outer.update(e,this.digestLength).finish(e)),this},e.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},e}();function i(e){var t=(new o).update(e),n=t.digest();return t.clean(),n}function s(e,t){var n=new r(e).update(t),o=n.digest();return n.clean(),o}function a(e,t,n,o){var r=o[0];if(0===r)throw new Error("hkdf: cannot expand more");t.reset(),r>1&&t.update(e),n&&t.update(n),t.update(o),t.finish(e),o[0]++}e.HMAC=r,e.hash=i,e.default=i,e.hmac=s;var l=new Uint8Array(e.digestLength);e.hkdf=function(e,t,n,o){void 0===t&&(t=l),void 0===o&&(o=32);for(var i=new Uint8Array([1]),c=s(t,e),u=new r(c),h=new Uint8Array(u.digestLength),d=h.length,p=new Uint8Array(o),m=0;m<o;m++)d===h.length&&(a(h,u,n,i),d=0),p[m]=h[d++];return u.clean(),h.fill(0),i.fill(0),p},e.pbkdf2=function(e,t,n,o){for(var i=new r(e),s=i.digestLength,a=new Uint8Array(4),l=new Uint8Array(s),c=new Uint8Array(s),u=new Uint8Array(o),h=0;h*s<o;h++){var d=h+1;a[0]=d>>>24&255,a[1]=d>>>16&255,a[2]=d>>>8&255,a[3]=d>>>0&255,i.reset(),i.update(t),i.update(a),i.finish(c);for(var p=0;p<s;p++)l[p]=c[p];for(p=2;p<=n;p++){i.reset(),i.update(c).finish(c);for(var m=0;m<s;m++)l[m]^=c[m]}for(p=0;p<s&&h*s+p<o;p++)u[h*s+p]=l[p]}for(h=0;h<s;h++)l[h]=c[h]=0;for(h=0;h<4;h++)a[h]=0;return i.clean(),u}}(t);var r=t.default;for(var i in t)r[i]=t[i];"object"==typeof e.exports?e.exports=r:void 0===(o=function(){return r}.call(t,n,t,e))||(e.exports=o)}()},2543:function(e,t,n){var o;e=n.nmd(e),function(){var r,i="Expected a function",s="__lodash_hash_undefined__",a="__lodash_placeholder__",l=32,c=128,u=1/0,h=9007199254740991,d=NaN,p=4294967295,m=[["ary",c],["bind",1],["bindKey",2],["curry",8],["curryRight",16],["flip",512],["partial",l],["partialRight",64],["rearg",256]],f="[object Arguments]",g="[object Array]",y="[object Boolean]",b="[object Date]",v="[object Error]",C="[object Function]",x="[object GeneratorFunction]",w="[object Map]",A="[object Number]",T="[object Object]",E="[object Promise]",S="[object RegExp]",N="[object Set]",I="[object String]",M="[object Symbol]",P="[object WeakMap]",_="[object ArrayBuffer]",L="[object DataView]",O="[object Float32Array]",R="[object Float64Array]",$="[object Int8Array]",D="[object Int16Array]",B="[object Int32Array]",F="[object Uint8Array]",k="[object Uint8ClampedArray]",H="[object Uint16Array]",G="[object Uint32Array]",U=/\b__p \+= '';/g,V=/\b(__p \+=) '' \+/g,j=/(__e\(.*?\)|\b__t\)) \+\n'';/g,q=/&(?:amp|lt|gt|quot|#39);/g,W=/[&<>"']/g,z=RegExp(q.source),Y=RegExp(W.source),K=/<%-([\s\S]+?)%>/g,Q=/<%([\s\S]+?)%>/g,J=/<%=([\s\S]+?)%>/g,X=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Z=/^\w*$/,ee=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,te=/[\\^$.*+?()[\]{}|]/g,ne=RegExp(te.source),oe=/^\s+/,re=/\s/,ie=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,se=/\{\n\/\* \[wrapped with (.+)\] \*/,ae=/,? & /,le=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,ce=/[()=,{}\[\]\/\s]/,ue=/\\(\\)?/g,he=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,de=/\w*$/,pe=/^[-+]0x[0-9a-f]+$/i,me=/^0b[01]+$/i,fe=/^\[object .+?Constructor\]$/,ge=/^0o[0-7]+$/i,ye=/^(?:0|[1-9]\d*)$/,be=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,ve=/($^)/,Ce=/['\n\r\u2028\u2029\\]/g,xe="\\ud800-\\udfff",we="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",Ae="\\u2700-\\u27bf",Te="a-z\\xdf-\\xf6\\xf8-\\xff",Ee="A-Z\\xc0-\\xd6\\xd8-\\xde",Se="\\ufe0e\\ufe0f",Ne="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Ie="["+xe+"]",Me="["+Ne+"]",Pe="["+we+"]",_e="\\d+",Le="["+Ae+"]",Oe="["+Te+"]",Re="[^"+xe+Ne+_e+Ae+Te+Ee+"]",$e="\\ud83c[\\udffb-\\udfff]",De="[^"+xe+"]",Be="(?:\\ud83c[\\udde6-\\uddff]){2}",Fe="[\\ud800-\\udbff][\\udc00-\\udfff]",ke="["+Ee+"]",He="\\u200d",Ge="(?:"+Oe+"|"+Re+")",Ue="(?:"+ke+"|"+Re+")",Ve="(?:['’](?:d|ll|m|re|s|t|ve))?",je="(?:['’](?:D|LL|M|RE|S|T|VE))?",qe="(?:"+Pe+"|"+$e+")?",We="["+Se+"]?",ze=We+qe+"(?:"+He+"(?:"+[De,Be,Fe].join("|")+")"+We+qe+")*",Ye="(?:"+[Le,Be,Fe].join("|")+")"+ze,Ke="(?:"+[De+Pe+"?",Pe,Be,Fe,Ie].join("|")+")",Qe=RegExp("['’]","g"),Je=RegExp(Pe,"g"),Xe=RegExp($e+"(?="+$e+")|"+Ke+ze,"g"),Ze=RegExp([ke+"?"+Oe+"+"+Ve+"(?="+[Me,ke,"$"].join("|")+")",Ue+"+"+je+"(?="+[Me,ke+Ge,"$"].join("|")+")",ke+"?"+Ge+"+"+Ve,ke+"+"+je,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",_e,Ye].join("|"),"g"),et=RegExp("["+He+xe+we+Se+"]"),tt=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,nt=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],ot=-1,rt={};rt[O]=rt[R]=rt[$]=rt[D]=rt[B]=rt[F]=rt[k]=rt[H]=rt[G]=!0,rt[f]=rt[g]=rt[_]=rt[y]=rt[L]=rt[b]=rt[v]=rt[C]=rt[w]=rt[A]=rt[T]=rt[S]=rt[N]=rt[I]=rt[P]=!1;var it={};it[f]=it[g]=it[_]=it[L]=it[y]=it[b]=it[O]=it[R]=it[$]=it[D]=it[B]=it[w]=it[A]=it[T]=it[S]=it[N]=it[I]=it[M]=it[F]=it[k]=it[H]=it[G]=!0,it[v]=it[C]=it[P]=!1;var st={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},at=parseFloat,lt=parseInt,ct="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,ut="object"==typeof self&&self&&self.Object===Object&&self,ht=ct||ut||Function("return this")(),dt=t&&!t.nodeType&&t,pt=dt&&e&&!e.nodeType&&e,mt=pt&&pt.exports===dt,ft=mt&&ct.process,gt=function(){try{return pt&&pt.require&&pt.require("util").types||ft&&ft.binding&&ft.binding("util")}catch(e){}}(),yt=gt&&gt.isArrayBuffer,bt=gt&&gt.isDate,vt=gt&&gt.isMap,Ct=gt&&gt.isRegExp,xt=gt&&gt.isSet,wt=gt&&gt.isTypedArray;function At(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function Tt(e,t,n,o){for(var r=-1,i=null==e?0:e.length;++r<i;){var s=e[r];t(o,s,n(s),e)}return o}function Et(e,t){for(var n=-1,o=null==e?0:e.length;++n<o&&!1!==t(e[n],n,e););return e}function St(e,t){for(var n=null==e?0:e.length;n--&&!1!==t(e[n],n,e););return e}function Nt(e,t){for(var n=-1,o=null==e?0:e.length;++n<o;)if(!t(e[n],n,e))return!1;return!0}function It(e,t){for(var n=-1,o=null==e?0:e.length,r=0,i=[];++n<o;){var s=e[n];t(s,n,e)&&(i[r++]=s)}return i}function Mt(e,t){return!(null==e||!e.length)&&kt(e,t,0)>-1}function Pt(e,t,n){for(var o=-1,r=null==e?0:e.length;++o<r;)if(n(t,e[o]))return!0;return!1}function _t(e,t){for(var n=-1,o=null==e?0:e.length,r=Array(o);++n<o;)r[n]=t(e[n],n,e);return r}function Lt(e,t){for(var n=-1,o=t.length,r=e.length;++n<o;)e[r+n]=t[n];return e}function Ot(e,t,n,o){var r=-1,i=null==e?0:e.length;for(o&&i&&(n=e[++r]);++r<i;)n=t(n,e[r],r,e);return n}function Rt(e,t,n,o){var r=null==e?0:e.length;for(o&&r&&(n=e[--r]);r--;)n=t(n,e[r],r,e);return n}function $t(e,t){for(var n=-1,o=null==e?0:e.length;++n<o;)if(t(e[n],n,e))return!0;return!1}var Dt=Vt("length");function Bt(e,t,n){var o;return n(e,(function(e,n,r){if(t(e,n,r))return o=n,!1})),o}function Ft(e,t,n,o){for(var r=e.length,i=n+(o?1:-1);o?i--:++i<r;)if(t(e[i],i,e))return i;return-1}function kt(e,t,n){return t==t?function(e,t,n){for(var o=n-1,r=e.length;++o<r;)if(e[o]===t)return o;return-1}(e,t,n):Ft(e,Gt,n)}function Ht(e,t,n,o){for(var r=n-1,i=e.length;++r<i;)if(o(e[r],t))return r;return-1}function Gt(e){return e!=e}function Ut(e,t){var n=null==e?0:e.length;return n?Wt(e,t)/n:d}function Vt(e){return function(t){return null==t?r:t[e]}}function jt(e){return function(t){return null==e?r:e[t]}}function qt(e,t,n,o,r){return r(e,(function(e,r,i){n=o?(o=!1,e):t(n,e,r,i)})),n}function Wt(e,t){for(var n,o=-1,i=e.length;++o<i;){var s=t(e[o]);s!==r&&(n=n===r?s:n+s)}return n}function zt(e,t){for(var n=-1,o=Array(e);++n<e;)o[n]=t(n);return o}function Yt(e){return e?e.slice(0,dn(e)+1).replace(oe,""):e}function Kt(e){return function(t){return e(t)}}function Qt(e,t){return _t(t,(function(t){return e[t]}))}function Jt(e,t){return e.has(t)}function Xt(e,t){for(var n=-1,o=e.length;++n<o&&kt(t,e[n],0)>-1;);return n}function Zt(e,t){for(var n=e.length;n--&&kt(t,e[n],0)>-1;);return n}var en=jt({À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"}),tn=jt({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"});function nn(e){return"\\"+st[e]}function on(e){return et.test(e)}function rn(e){var t=-1,n=Array(e.size);return e.forEach((function(e,o){n[++t]=[o,e]})),n}function sn(e,t){return function(n){return e(t(n))}}function an(e,t){for(var n=-1,o=e.length,r=0,i=[];++n<o;){var s=e[n];s!==t&&s!==a||(e[n]=a,i[r++]=n)}return i}function ln(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=e})),n}function cn(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=[e,e]})),n}function un(e){return on(e)?function(e){for(var t=Xe.lastIndex=0;Xe.test(e);)++t;return t}(e):Dt(e)}function hn(e){return on(e)?function(e){return e.match(Xe)||[]}(e):function(e){return e.split("")}(e)}function dn(e){for(var t=e.length;t--&&re.test(e.charAt(t)););return t}var pn=jt({"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"}),mn=function e(t){var n,o=(t=null==t?ht:mn.defaults(ht.Object(),t,mn.pick(ht,nt))).Array,re=t.Date,xe=t.Error,we=t.Function,Ae=t.Math,Te=t.Object,Ee=t.RegExp,Se=t.String,Ne=t.TypeError,Ie=o.prototype,Me=we.prototype,Pe=Te.prototype,_e=t["__core-js_shared__"],Le=Me.toString,Oe=Pe.hasOwnProperty,Re=0,$e=(n=/[^.]+$/.exec(_e&&_e.keys&&_e.keys.IE_PROTO||""))?"Symbol(src)_1."+n:"",De=Pe.toString,Be=Le.call(Te),Fe=ht._,ke=Ee("^"+Le.call(Oe).replace(te,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),He=mt?t.Buffer:r,Ge=t.Symbol,Ue=t.Uint8Array,Ve=He?He.allocUnsafe:r,je=sn(Te.getPrototypeOf,Te),qe=Te.create,We=Pe.propertyIsEnumerable,ze=Ie.splice,Ye=Ge?Ge.isConcatSpreadable:r,Ke=Ge?Ge.iterator:r,Xe=Ge?Ge.toStringTag:r,et=function(){try{var e=ci(Te,"defineProperty");return e({},"",{}),e}catch(e){}}(),st=t.clearTimeout!==ht.clearTimeout&&t.clearTimeout,ct=re&&re.now!==ht.Date.now&&re.now,ut=t.setTimeout!==ht.setTimeout&&t.setTimeout,dt=Ae.ceil,pt=Ae.floor,ft=Te.getOwnPropertySymbols,gt=He?He.isBuffer:r,Dt=t.isFinite,jt=Ie.join,fn=sn(Te.keys,Te),gn=Ae.max,yn=Ae.min,bn=re.now,vn=t.parseInt,Cn=Ae.random,xn=Ie.reverse,wn=ci(t,"DataView"),An=ci(t,"Map"),Tn=ci(t,"Promise"),En=ci(t,"Set"),Sn=ci(t,"WeakMap"),Nn=ci(Te,"create"),In=Sn&&new Sn,Mn={},Pn=Bi(wn),_n=Bi(An),Ln=Bi(Tn),On=Bi(En),Rn=Bi(Sn),$n=Ge?Ge.prototype:r,Dn=$n?$n.valueOf:r,Bn=$n?$n.toString:r;function Fn(e){if(ea(e)&&!Vs(e)&&!(e instanceof Un)){if(e instanceof Gn)return e;if(Oe.call(e,"__wrapped__"))return Fi(e)}return new Gn(e)}var kn=function(){function e(){}return function(t){if(!Zs(t))return{};if(qe)return qe(t);e.prototype=t;var n=new e;return e.prototype=r,n}}();function Hn(){}function Gn(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=r}function Un(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=p,this.__views__=[]}function Vn(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var o=e[t];this.set(o[0],o[1])}}function jn(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var o=e[t];this.set(o[0],o[1])}}function qn(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var o=e[t];this.set(o[0],o[1])}}function Wn(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new qn;++t<n;)this.add(e[t])}function zn(e){var t=this.__data__=new jn(e);this.size=t.size}function Yn(e,t){var n=Vs(e),o=!n&&Us(e),r=!n&&!o&&zs(e),i=!n&&!o&&!r&&la(e),s=n||o||r||i,a=s?zt(e.length,Se):[],l=a.length;for(var c in e)!t&&!Oe.call(e,c)||s&&("length"==c||r&&("offset"==c||"parent"==c)||i&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||gi(c,l))||a.push(c);return a}function Kn(e){var t=e.length;return t?e[Wo(0,t-1)]:r}function Qn(e,t){return Li(Nr(e),io(t,0,e.length))}function Jn(e){return Li(Nr(e))}function Xn(e,t,n){(n!==r&&!ks(e[t],n)||n===r&&!(t in e))&&oo(e,t,n)}function Zn(e,t,n){var o=e[t];Oe.call(e,t)&&ks(o,n)&&(n!==r||t in e)||oo(e,t,n)}function eo(e,t){for(var n=e.length;n--;)if(ks(e[n][0],t))return n;return-1}function to(e,t,n,o){return uo(e,(function(e,r,i){t(o,e,n(e),i)})),o}function no(e,t){return e&&Ir(t,Pa(t),e)}function oo(e,t,n){"__proto__"==t&&et?et(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function ro(e,t){for(var n=-1,i=t.length,s=o(i),a=null==e;++n<i;)s[n]=a?r:Ea(e,t[n]);return s}function io(e,t,n){return e==e&&(n!==r&&(e=e<=n?e:n),t!==r&&(e=e>=t?e:t)),e}function so(e,t,n,o,i,s){var a,l=1&t,c=2&t,u=4&t;if(n&&(a=i?n(e,o,i,s):n(e)),a!==r)return a;if(!Zs(e))return e;var h=Vs(e);if(h){if(a=function(e){var t=e.length,n=new e.constructor(t);return t&&"string"==typeof e[0]&&Oe.call(e,"index")&&(n.index=e.index,n.input=e.input),n}(e),!l)return Nr(e,a)}else{var d=di(e),p=d==C||d==x;if(zs(e))return xr(e,l);if(d==T||d==f||p&&!i){if(a=c||p?{}:mi(e),!l)return c?function(e,t){return Ir(e,hi(e),t)}(e,function(e,t){return e&&Ir(t,_a(t),e)}(a,e)):function(e,t){return Ir(e,ui(e),t)}(e,no(a,e))}else{if(!it[d])return i?e:{};a=function(e,t,n){var o,r=e.constructor;switch(t){case _:return wr(e);case y:case b:return new r(+e);case L:return function(e,t){var n=t?wr(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}(e,n);case O:case R:case $:case D:case B:case F:case k:case H:case G:return Ar(e,n);case w:return new r;case A:case I:return new r(e);case S:return function(e){var t=new e.constructor(e.source,de.exec(e));return t.lastIndex=e.lastIndex,t}(e);case N:return new r;case M:return o=e,Dn?Te(Dn.call(o)):{}}}(e,d,l)}}s||(s=new zn);var m=s.get(e);if(m)return m;s.set(e,a),ia(e)?e.forEach((function(o){a.add(so(o,t,n,o,e,s))})):ta(e)&&e.forEach((function(o,r){a.set(r,so(o,t,n,r,e,s))}));var g=h?r:(u?c?ni:ti:c?_a:Pa)(e);return Et(g||e,(function(o,r){g&&(o=e[r=o]),Zn(a,r,so(o,t,n,r,e,s))})),a}function ao(e,t,n){var o=n.length;if(null==e)return!o;for(e=Te(e);o--;){var i=n[o],s=t[i],a=e[i];if(a===r&&!(i in e)||!s(a))return!1}return!0}function lo(e,t,n){if("function"!=typeof e)throw new Ne(i);return Ii((function(){e.apply(r,n)}),t)}function co(e,t,n,o){var r=-1,i=Mt,s=!0,a=e.length,l=[],c=t.length;if(!a)return l;n&&(t=_t(t,Kt(n))),o?(i=Pt,s=!1):t.length>=200&&(i=Jt,s=!1,t=new Wn(t));e:for(;++r<a;){var u=e[r],h=null==n?u:n(u);if(u=o||0!==u?u:0,s&&h==h){for(var d=c;d--;)if(t[d]===h)continue e;l.push(u)}else i(t,h,o)||l.push(u)}return l}Fn.templateSettings={escape:K,evaluate:Q,interpolate:J,variable:"",imports:{_:Fn}},Fn.prototype=Hn.prototype,Fn.prototype.constructor=Fn,Gn.prototype=kn(Hn.prototype),Gn.prototype.constructor=Gn,Un.prototype=kn(Hn.prototype),Un.prototype.constructor=Un,Vn.prototype.clear=function(){this.__data__=Nn?Nn(null):{},this.size=0},Vn.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Vn.prototype.get=function(e){var t=this.__data__;if(Nn){var n=t[e];return n===s?r:n}return Oe.call(t,e)?t[e]:r},Vn.prototype.has=function(e){var t=this.__data__;return Nn?t[e]!==r:Oe.call(t,e)},Vn.prototype.set=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=Nn&&t===r?s:t,this},jn.prototype.clear=function(){this.__data__=[],this.size=0},jn.prototype.delete=function(e){var t=this.__data__,n=eo(t,e);return!(n<0||(n==t.length-1?t.pop():ze.call(t,n,1),--this.size,0))},jn.prototype.get=function(e){var t=this.__data__,n=eo(t,e);return n<0?r:t[n][1]},jn.prototype.has=function(e){return eo(this.__data__,e)>-1},jn.prototype.set=function(e,t){var n=this.__data__,o=eo(n,e);return o<0?(++this.size,n.push([e,t])):n[o][1]=t,this},qn.prototype.clear=function(){this.size=0,this.__data__={hash:new Vn,map:new(An||jn),string:new Vn}},qn.prototype.delete=function(e){var t=ai(this,e).delete(e);return this.size-=t?1:0,t},qn.prototype.get=function(e){return ai(this,e).get(e)},qn.prototype.has=function(e){return ai(this,e).has(e)},qn.prototype.set=function(e,t){var n=ai(this,e),o=n.size;return n.set(e,t),this.size+=n.size==o?0:1,this},Wn.prototype.add=Wn.prototype.push=function(e){return this.__data__.set(e,s),this},Wn.prototype.has=function(e){return this.__data__.has(e)},zn.prototype.clear=function(){this.__data__=new jn,this.size=0},zn.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},zn.prototype.get=function(e){return this.__data__.get(e)},zn.prototype.has=function(e){return this.__data__.has(e)},zn.prototype.set=function(e,t){var n=this.__data__;if(n instanceof jn){var o=n.__data__;if(!An||o.length<199)return o.push([e,t]),this.size=++n.size,this;n=this.__data__=new qn(o)}return n.set(e,t),this.size=n.size,this};var uo=_r(vo),ho=_r(Co,!0);function po(e,t){var n=!0;return uo(e,(function(e,o,r){return n=!!t(e,o,r)})),n}function mo(e,t,n){for(var o=-1,i=e.length;++o<i;){var s=e[o],a=t(s);if(null!=a&&(l===r?a==a&&!aa(a):n(a,l)))var l=a,c=s}return c}function fo(e,t){var n=[];return uo(e,(function(e,o,r){t(e,o,r)&&n.push(e)})),n}function go(e,t,n,o,r){var i=-1,s=e.length;for(n||(n=fi),r||(r=[]);++i<s;){var a=e[i];t>0&&n(a)?t>1?go(a,t-1,n,o,r):Lt(r,a):o||(r[r.length]=a)}return r}var yo=Lr(),bo=Lr(!0);function vo(e,t){return e&&yo(e,t,Pa)}function Co(e,t){return e&&bo(e,t,Pa)}function xo(e,t){return It(t,(function(t){return Qs(e[t])}))}function wo(e,t){for(var n=0,o=(t=yr(t,e)).length;null!=e&&n<o;)e=e[Di(t[n++])];return n&&n==o?e:r}function Ao(e,t,n){var o=t(e);return Vs(e)?o:Lt(o,n(e))}function To(e){return null==e?e===r?"[object Undefined]":"[object Null]":Xe&&Xe in Te(e)?function(e){var t=Oe.call(e,Xe),n=e[Xe];try{e[Xe]=r;var o=!0}catch(e){}var i=De.call(e);return o&&(t?e[Xe]=n:delete e[Xe]),i}(e):function(e){return De.call(e)}(e)}function Eo(e,t){return e>t}function So(e,t){return null!=e&&Oe.call(e,t)}function No(e,t){return null!=e&&t in Te(e)}function Io(e,t,n){for(var i=n?Pt:Mt,s=e[0].length,a=e.length,l=a,c=o(a),u=1/0,h=[];l--;){var d=e[l];l&&t&&(d=_t(d,Kt(t))),u=yn(d.length,u),c[l]=!n&&(t||s>=120&&d.length>=120)?new Wn(l&&d):r}d=e[0];var p=-1,m=c[0];e:for(;++p<s&&h.length<u;){var f=d[p],g=t?t(f):f;if(f=n||0!==f?f:0,!(m?Jt(m,g):i(h,g,n))){for(l=a;--l;){var y=c[l];if(!(y?Jt(y,g):i(e[l],g,n)))continue e}m&&m.push(g),h.push(f)}}return h}function Mo(e,t,n){var o=null==(e=Ei(e,t=yr(t,e)))?e:e[Di(Ki(t))];return null==o?r:At(o,e,n)}function Po(e){return ea(e)&&To(e)==f}function _o(e,t,n,o,i){return e===t||(null==e||null==t||!ea(e)&&!ea(t)?e!=e&&t!=t:function(e,t,n,o,i,s){var a=Vs(e),l=Vs(t),c=a?g:di(e),u=l?g:di(t),h=(c=c==f?T:c)==T,d=(u=u==f?T:u)==T,p=c==u;if(p&&zs(e)){if(!zs(t))return!1;a=!0,h=!1}if(p&&!h)return s||(s=new zn),a||la(e)?Zr(e,t,n,o,i,s):function(e,t,n,o,r,i,s){switch(n){case L:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case _:return!(e.byteLength!=t.byteLength||!i(new Ue(e),new Ue(t)));case y:case b:case A:return ks(+e,+t);case v:return e.name==t.name&&e.message==t.message;case S:case I:return e==t+"";case w:var a=rn;case N:var l=1&o;if(a||(a=ln),e.size!=t.size&&!l)return!1;var c=s.get(e);if(c)return c==t;o|=2,s.set(e,t);var u=Zr(a(e),a(t),o,r,i,s);return s.delete(e),u;case M:if(Dn)return Dn.call(e)==Dn.call(t)}return!1}(e,t,c,n,o,i,s);if(!(1&n)){var m=h&&Oe.call(e,"__wrapped__"),C=d&&Oe.call(t,"__wrapped__");if(m||C){var x=m?e.value():e,E=C?t.value():t;return s||(s=new zn),i(x,E,n,o,s)}}return!!p&&(s||(s=new zn),function(e,t,n,o,i,s){var a=1&n,l=ti(e),c=l.length;if(c!=ti(t).length&&!a)return!1;for(var u=c;u--;){var h=l[u];if(!(a?h in t:Oe.call(t,h)))return!1}var d=s.get(e),p=s.get(t);if(d&&p)return d==t&&p==e;var m=!0;s.set(e,t),s.set(t,e);for(var f=a;++u<c;){var g=e[h=l[u]],y=t[h];if(o)var b=a?o(y,g,h,t,e,s):o(g,y,h,e,t,s);if(!(b===r?g===y||i(g,y,n,o,s):b)){m=!1;break}f||(f="constructor"==h)}if(m&&!f){var v=e.constructor,C=t.constructor;v==C||!("constructor"in e)||!("constructor"in t)||"function"==typeof v&&v instanceof v&&"function"==typeof C&&C instanceof C||(m=!1)}return s.delete(e),s.delete(t),m}(e,t,n,o,i,s))}(e,t,n,o,_o,i))}function Lo(e,t,n,o){var i=n.length,s=i,a=!o;if(null==e)return!s;for(e=Te(e);i--;){var l=n[i];if(a&&l[2]?l[1]!==e[l[0]]:!(l[0]in e))return!1}for(;++i<s;){var c=(l=n[i])[0],u=e[c],h=l[1];if(a&&l[2]){if(u===r&&!(c in e))return!1}else{var d=new zn;if(o)var p=o(u,h,c,e,t,d);if(!(p===r?_o(h,u,3,o,d):p))return!1}}return!0}function Oo(e){return!(!Zs(e)||(t=e,$e&&$e in t))&&(Qs(e)?ke:fe).test(Bi(e));var t}function Ro(e){return"function"==typeof e?e:null==e?nl:"object"==typeof e?Vs(e)?ko(e[0],e[1]):Fo(e):hl(e)}function $o(e){if(!xi(e))return fn(e);var t=[];for(var n in Te(e))Oe.call(e,n)&&"constructor"!=n&&t.push(n);return t}function Do(e,t){return e<t}function Bo(e,t){var n=-1,r=qs(e)?o(e.length):[];return uo(e,(function(e,o,i){r[++n]=t(e,o,i)})),r}function Fo(e){var t=li(e);return 1==t.length&&t[0][2]?Ai(t[0][0],t[0][1]):function(n){return n===e||Lo(n,e,t)}}function ko(e,t){return bi(e)&&wi(t)?Ai(Di(e),t):function(n){var o=Ea(n,e);return o===r&&o===t?Sa(n,e):_o(t,o,3)}}function Ho(e,t,n,o,i){e!==t&&yo(t,(function(s,a){if(i||(i=new zn),Zs(s))!function(e,t,n,o,i,s,a){var l=Si(e,n),c=Si(t,n),u=a.get(c);if(u)Xn(e,n,u);else{var h=s?s(l,c,n+"",e,t,a):r,d=h===r;if(d){var p=Vs(c),m=!p&&zs(c),f=!p&&!m&&la(c);h=c,p||m||f?Vs(l)?h=l:Ws(l)?h=Nr(l):m?(d=!1,h=xr(c,!0)):f?(d=!1,h=Ar(c,!0)):h=[]:oa(c)||Us(c)?(h=l,Us(l)?h=ga(l):Zs(l)&&!Qs(l)||(h=mi(c))):d=!1}d&&(a.set(c,h),i(h,c,o,s,a),a.delete(c)),Xn(e,n,h)}}(e,t,a,n,Ho,o,i);else{var l=o?o(Si(e,a),s,a+"",e,t,i):r;l===r&&(l=s),Xn(e,a,l)}}),_a)}function Go(e,t){var n=e.length;if(n)return gi(t+=t<0?n:0,n)?e[t]:r}function Uo(e,t,n){t=t.length?_t(t,(function(e){return Vs(e)?function(t){return wo(t,1===e.length?e[0]:e)}:e})):[nl];var o=-1;t=_t(t,Kt(si()));var r=Bo(e,(function(e,n,r){var i=_t(t,(function(t){return t(e)}));return{criteria:i,index:++o,value:e}}));return function(e){var t=e.length;for(e.sort((function(e,t){return function(e,t,n){for(var o=-1,r=e.criteria,i=t.criteria,s=r.length,a=n.length;++o<s;){var l=Tr(r[o],i[o]);if(l)return o>=a?l:l*("desc"==n[o]?-1:1)}return e.index-t.index}(e,t,n)}));t--;)e[t]=e[t].value;return e}(r)}function Vo(e,t,n){for(var o=-1,r=t.length,i={};++o<r;){var s=t[o],a=wo(e,s);n(a,s)&&Jo(i,yr(s,e),a)}return i}function jo(e,t,n,o){var r=o?Ht:kt,i=-1,s=t.length,a=e;for(e===t&&(t=Nr(t)),n&&(a=_t(e,Kt(n)));++i<s;)for(var l=0,c=t[i],u=n?n(c):c;(l=r(a,u,l,o))>-1;)a!==e&&ze.call(a,l,1),ze.call(e,l,1);return e}function qo(e,t){for(var n=e?t.length:0,o=n-1;n--;){var r=t[n];if(n==o||r!==i){var i=r;gi(r)?ze.call(e,r,1):cr(e,r)}}return e}function Wo(e,t){return e+pt(Cn()*(t-e+1))}function zo(e,t){var n="";if(!e||t<1||t>h)return n;do{t%2&&(n+=e),(t=pt(t/2))&&(e+=e)}while(t);return n}function Yo(e,t){return Mi(Ti(e,t,nl),e+"")}function Ko(e){return Kn(ka(e))}function Qo(e,t){var n=ka(e);return Li(n,io(t,0,n.length))}function Jo(e,t,n,o){if(!Zs(e))return e;for(var i=-1,s=(t=yr(t,e)).length,a=s-1,l=e;null!=l&&++i<s;){var c=Di(t[i]),u=n;if("__proto__"===c||"constructor"===c||"prototype"===c)return e;if(i!=a){var h=l[c];(u=o?o(h,c,l):r)===r&&(u=Zs(h)?h:gi(t[i+1])?[]:{})}Zn(l,c,u),l=l[c]}return e}var Xo=In?function(e,t){return In.set(e,t),e}:nl,Zo=et?function(e,t){return et(e,"toString",{configurable:!0,enumerable:!1,value:Za(t),writable:!0})}:nl;function er(e){return Li(ka(e))}function tr(e,t,n){var r=-1,i=e.length;t<0&&(t=-t>i?0:i+t),(n=n>i?i:n)<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var s=o(i);++r<i;)s[r]=e[r+t];return s}function nr(e,t){var n;return uo(e,(function(e,o,r){return!(n=t(e,o,r))})),!!n}function or(e,t,n){var o=0,r=null==e?o:e.length;if("number"==typeof t&&t==t&&r<=2147483647){for(;o<r;){var i=o+r>>>1,s=e[i];null!==s&&!aa(s)&&(n?s<=t:s<t)?o=i+1:r=i}return r}return rr(e,t,nl,n)}function rr(e,t,n,o){var i=0,s=null==e?0:e.length;if(0===s)return 0;for(var a=(t=n(t))!=t,l=null===t,c=aa(t),u=t===r;i<s;){var h=pt((i+s)/2),d=n(e[h]),p=d!==r,m=null===d,f=d==d,g=aa(d);if(a)var y=o||f;else y=u?f&&(o||p):l?f&&p&&(o||!m):c?f&&p&&!m&&(o||!g):!m&&!g&&(o?d<=t:d<t);y?i=h+1:s=h}return yn(s,4294967294)}function ir(e,t){for(var n=-1,o=e.length,r=0,i=[];++n<o;){var s=e[n],a=t?t(s):s;if(!n||!ks(a,l)){var l=a;i[r++]=0===s?0:s}}return i}function sr(e){return"number"==typeof e?e:aa(e)?d:+e}function ar(e){if("string"==typeof e)return e;if(Vs(e))return _t(e,ar)+"";if(aa(e))return Bn?Bn.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function lr(e,t,n){var o=-1,r=Mt,i=e.length,s=!0,a=[],l=a;if(n)s=!1,r=Pt;else if(i>=200){var c=t?null:zr(e);if(c)return ln(c);s=!1,r=Jt,l=new Wn}else l=t?[]:a;e:for(;++o<i;){var u=e[o],h=t?t(u):u;if(u=n||0!==u?u:0,s&&h==h){for(var d=l.length;d--;)if(l[d]===h)continue e;t&&l.push(h),a.push(u)}else r(l,h,n)||(l!==a&&l.push(h),a.push(u))}return a}function cr(e,t){return null==(e=Ei(e,t=yr(t,e)))||delete e[Di(Ki(t))]}function ur(e,t,n,o){return Jo(e,t,n(wo(e,t)),o)}function hr(e,t,n,o){for(var r=e.length,i=o?r:-1;(o?i--:++i<r)&&t(e[i],i,e););return n?tr(e,o?0:i,o?i+1:r):tr(e,o?i+1:0,o?r:i)}function dr(e,t){var n=e;return n instanceof Un&&(n=n.value()),Ot(t,(function(e,t){return t.func.apply(t.thisArg,Lt([e],t.args))}),n)}function pr(e,t,n){var r=e.length;if(r<2)return r?lr(e[0]):[];for(var i=-1,s=o(r);++i<r;)for(var a=e[i],l=-1;++l<r;)l!=i&&(s[i]=co(s[i]||a,e[l],t,n));return lr(go(s,1),t,n)}function mr(e,t,n){for(var o=-1,i=e.length,s=t.length,a={};++o<i;){var l=o<s?t[o]:r;n(a,e[o],l)}return a}function fr(e){return Ws(e)?e:[]}function gr(e){return"function"==typeof e?e:nl}function yr(e,t){return Vs(e)?e:bi(e,t)?[e]:$i(ya(e))}var br=Yo;function vr(e,t,n){var o=e.length;return n=n===r?o:n,!t&&n>=o?e:tr(e,t,n)}var Cr=st||function(e){return ht.clearTimeout(e)};function xr(e,t){if(t)return e.slice();var n=e.length,o=Ve?Ve(n):new e.constructor(n);return e.copy(o),o}function wr(e){var t=new e.constructor(e.byteLength);return new Ue(t).set(new Ue(e)),t}function Ar(e,t){var n=t?wr(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function Tr(e,t){if(e!==t){var n=e!==r,o=null===e,i=e==e,s=aa(e),a=t!==r,l=null===t,c=t==t,u=aa(t);if(!l&&!u&&!s&&e>t||s&&a&&c&&!l&&!u||o&&a&&c||!n&&c||!i)return 1;if(!o&&!s&&!u&&e<t||u&&n&&i&&!o&&!s||l&&n&&i||!a&&i||!c)return-1}return 0}function Er(e,t,n,r){for(var i=-1,s=e.length,a=n.length,l=-1,c=t.length,u=gn(s-a,0),h=o(c+u),d=!r;++l<c;)h[l]=t[l];for(;++i<a;)(d||i<s)&&(h[n[i]]=e[i]);for(;u--;)h[l++]=e[i++];return h}function Sr(e,t,n,r){for(var i=-1,s=e.length,a=-1,l=n.length,c=-1,u=t.length,h=gn(s-l,0),d=o(h+u),p=!r;++i<h;)d[i]=e[i];for(var m=i;++c<u;)d[m+c]=t[c];for(;++a<l;)(p||i<s)&&(d[m+n[a]]=e[i++]);return d}function Nr(e,t){var n=-1,r=e.length;for(t||(t=o(r));++n<r;)t[n]=e[n];return t}function Ir(e,t,n,o){var i=!n;n||(n={});for(var s=-1,a=t.length;++s<a;){var l=t[s],c=o?o(n[l],e[l],l,n,e):r;c===r&&(c=e[l]),i?oo(n,l,c):Zn(n,l,c)}return n}function Mr(e,t){return function(n,o){var r=Vs(n)?Tt:to,i=t?t():{};return r(n,e,si(o,2),i)}}function Pr(e){return Yo((function(t,n){var o=-1,i=n.length,s=i>1?n[i-1]:r,a=i>2?n[2]:r;for(s=e.length>3&&"function"==typeof s?(i--,s):r,a&&yi(n[0],n[1],a)&&(s=i<3?r:s,i=1),t=Te(t);++o<i;){var l=n[o];l&&e(t,l,o,s)}return t}))}function _r(e,t){return function(n,o){if(null==n)return n;if(!qs(n))return e(n,o);for(var r=n.length,i=t?r:-1,s=Te(n);(t?i--:++i<r)&&!1!==o(s[i],i,s););return n}}function Lr(e){return function(t,n,o){for(var r=-1,i=Te(t),s=o(t),a=s.length;a--;){var l=s[e?a:++r];if(!1===n(i[l],l,i))break}return t}}function Or(e){return function(t){var n=on(t=ya(t))?hn(t):r,o=n?n[0]:t.charAt(0),i=n?vr(n,1).join(""):t.slice(1);return o[e]()+i}}function Rr(e){return function(t){return Ot(Qa(Ua(t).replace(Qe,"")),e,"")}}function $r(e){return function(){var t=arguments;switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3]);case 5:return new e(t[0],t[1],t[2],t[3],t[4]);case 6:return new e(t[0],t[1],t[2],t[3],t[4],t[5]);case 7:return new e(t[0],t[1],t[2],t[3],t[4],t[5],t[6])}var n=kn(e.prototype),o=e.apply(n,t);return Zs(o)?o:n}}function Dr(e){return function(t,n,o){var i=Te(t);if(!qs(t)){var s=si(n,3);t=Pa(t),n=function(e){return s(i[e],e,i)}}var a=e(t,n,o);return a>-1?i[s?t[a]:a]:r}}function Br(e){return ei((function(t){var n=t.length,o=n,s=Gn.prototype.thru;for(e&&t.reverse();o--;){var a=t[o];if("function"!=typeof a)throw new Ne(i);if(s&&!l&&"wrapper"==ri(a))var l=new Gn([],!0)}for(o=l?o:n;++o<n;){var c=ri(a=t[o]),u="wrapper"==c?oi(a):r;l=u&&vi(u[0])&&424==u[1]&&!u[4].length&&1==u[9]?l[ri(u[0])].apply(l,u[3]):1==a.length&&vi(a)?l[c]():l.thru(a)}return function(){var e=arguments,o=e[0];if(l&&1==e.length&&Vs(o))return l.plant(o).value();for(var r=0,i=n?t[r].apply(this,e):o;++r<n;)i=t[r].call(this,i);return i}}))}function Fr(e,t,n,i,s,a,l,u,h,d){var p=t&c,m=1&t,f=2&t,g=24&t,y=512&t,b=f?r:$r(e);return function c(){for(var v=arguments.length,C=o(v),x=v;x--;)C[x]=arguments[x];if(g)var w=ii(c),A=function(e,t){for(var n=e.length,o=0;n--;)e[n]===t&&++o;return o}(C,w);if(i&&(C=Er(C,i,s,g)),a&&(C=Sr(C,a,l,g)),v-=A,g&&v<d){var T=an(C,w);return qr(e,t,Fr,c.placeholder,n,C,T,u,h,d-v)}var E=m?n:this,S=f?E[e]:e;return v=C.length,u?C=function(e,t){for(var n=e.length,o=yn(t.length,n),i=Nr(e);o--;){var s=t[o];e[o]=gi(s,n)?i[s]:r}return e}(C,u):y&&v>1&&C.reverse(),p&&h<v&&(C.length=h),this&&this!==ht&&this instanceof c&&(S=b||$r(S)),S.apply(E,C)}}function kr(e,t){return function(n,o){return function(e,t,n,o){return vo(e,(function(e,r,i){t(o,n(e),r,i)})),o}(n,e,t(o),{})}}function Hr(e,t){return function(n,o){var i;if(n===r&&o===r)return t;if(n!==r&&(i=n),o!==r){if(i===r)return o;"string"==typeof n||"string"==typeof o?(n=ar(n),o=ar(o)):(n=sr(n),o=sr(o)),i=e(n,o)}return i}}function Gr(e){return ei((function(t){return t=_t(t,Kt(si())),Yo((function(n){var o=this;return e(t,(function(e){return At(e,o,n)}))}))}))}function Ur(e,t){var n=(t=t===r?" ":ar(t)).length;if(n<2)return n?zo(t,e):t;var o=zo(t,dt(e/un(t)));return on(t)?vr(hn(o),0,e).join(""):o.slice(0,e)}function Vr(e){return function(t,n,i){return i&&"number"!=typeof i&&yi(t,n,i)&&(n=i=r),t=da(t),n===r?(n=t,t=0):n=da(n),function(e,t,n,r){for(var i=-1,s=gn(dt((t-e)/(n||1)),0),a=o(s);s--;)a[r?s:++i]=e,e+=n;return a}(t,n,i=i===r?t<n?1:-1:da(i),e)}}function jr(e){return function(t,n){return"string"==typeof t&&"string"==typeof n||(t=fa(t),n=fa(n)),e(t,n)}}function qr(e,t,n,o,i,s,a,c,u,h){var d=8&t;t|=d?l:64,4&(t&=~(d?64:l))||(t&=-4);var p=[e,t,i,d?s:r,d?a:r,d?r:s,d?r:a,c,u,h],m=n.apply(r,p);return vi(e)&&Ni(m,p),m.placeholder=o,Pi(m,e,t)}function Wr(e){var t=Ae[e];return function(e,n){if(e=fa(e),(n=null==n?0:yn(pa(n),292))&&Dt(e)){var o=(ya(e)+"e").split("e");return+((o=(ya(t(o[0]+"e"+(+o[1]+n)))+"e").split("e"))[0]+"e"+(+o[1]-n))}return t(e)}}var zr=En&&1/ln(new En([,-0]))[1]==u?function(e){return new En(e)}:al;function Yr(e){return function(t){var n=di(t);return n==w?rn(t):n==N?cn(t):function(e,t){return _t(t,(function(t){return[t,e[t]]}))}(t,e(t))}}function Kr(e,t,n,s,u,h,d,p){var m=2&t;if(!m&&"function"!=typeof e)throw new Ne(i);var f=s?s.length:0;if(f||(t&=-97,s=u=r),d=d===r?d:gn(pa(d),0),p=p===r?p:pa(p),f-=u?u.length:0,64&t){var g=s,y=u;s=u=r}var b=m?r:oi(e),v=[e,t,n,s,u,g,y,h,d,p];if(b&&function(e,t){var n=e[1],o=t[1],r=n|o,i=r<131,s=o==c&&8==n||o==c&&256==n&&e[7].length<=t[8]||384==o&&t[7].length<=t[8]&&8==n;if(!i&&!s)return e;1&o&&(e[2]=t[2],r|=1&n?0:4);var l=t[3];if(l){var u=e[3];e[3]=u?Er(u,l,t[4]):l,e[4]=u?an(e[3],a):t[4]}(l=t[5])&&(u=e[5],e[5]=u?Sr(u,l,t[6]):l,e[6]=u?an(e[5],a):t[6]),(l=t[7])&&(e[7]=l),o&c&&(e[8]=null==e[8]?t[8]:yn(e[8],t[8])),null==e[9]&&(e[9]=t[9]),e[0]=t[0],e[1]=r}(v,b),e=v[0],t=v[1],n=v[2],s=v[3],u=v[4],!(p=v[9]=v[9]===r?m?0:e.length:gn(v[9]-f,0))&&24&t&&(t&=-25),t&&1!=t)C=8==t||16==t?function(e,t,n){var i=$r(e);return function s(){for(var a=arguments.length,l=o(a),c=a,u=ii(s);c--;)l[c]=arguments[c];var h=a<3&&l[0]!==u&&l[a-1]!==u?[]:an(l,u);return(a-=h.length)<n?qr(e,t,Fr,s.placeholder,r,l,h,r,r,n-a):At(this&&this!==ht&&this instanceof s?i:e,this,l)}}(e,t,p):t!=l&&33!=t||u.length?Fr.apply(r,v):function(e,t,n,r){var i=1&t,s=$r(e);return function t(){for(var a=-1,l=arguments.length,c=-1,u=r.length,h=o(u+l),d=this&&this!==ht&&this instanceof t?s:e;++c<u;)h[c]=r[c];for(;l--;)h[c++]=arguments[++a];return At(d,i?n:this,h)}}(e,t,n,s);else var C=function(e,t,n){var o=1&t,r=$r(e);return function t(){return(this&&this!==ht&&this instanceof t?r:e).apply(o?n:this,arguments)}}(e,t,n);return Pi((b?Xo:Ni)(C,v),e,t)}function Qr(e,t,n,o){return e===r||ks(e,Pe[n])&&!Oe.call(o,n)?t:e}function Jr(e,t,n,o,i,s){return Zs(e)&&Zs(t)&&(s.set(t,e),Ho(e,t,r,Jr,s),s.delete(t)),e}function Xr(e){return oa(e)?r:e}function Zr(e,t,n,o,i,s){var a=1&n,l=e.length,c=t.length;if(l!=c&&!(a&&c>l))return!1;var u=s.get(e),h=s.get(t);if(u&&h)return u==t&&h==e;var d=-1,p=!0,m=2&n?new Wn:r;for(s.set(e,t),s.set(t,e);++d<l;){var f=e[d],g=t[d];if(o)var y=a?o(g,f,d,t,e,s):o(f,g,d,e,t,s);if(y!==r){if(y)continue;p=!1;break}if(m){if(!$t(t,(function(e,t){if(!Jt(m,t)&&(f===e||i(f,e,n,o,s)))return m.push(t)}))){p=!1;break}}else if(f!==g&&!i(f,g,n,o,s)){p=!1;break}}return s.delete(e),s.delete(t),p}function ei(e){return Mi(Ti(e,r,ji),e+"")}function ti(e){return Ao(e,Pa,ui)}function ni(e){return Ao(e,_a,hi)}var oi=In?function(e){return In.get(e)}:al;function ri(e){for(var t=e.name+"",n=Mn[t],o=Oe.call(Mn,t)?n.length:0;o--;){var r=n[o],i=r.func;if(null==i||i==e)return r.name}return t}function ii(e){return(Oe.call(Fn,"placeholder")?Fn:e).placeholder}function si(){var e=Fn.iteratee||ol;return e=e===ol?Ro:e,arguments.length?e(arguments[0],arguments[1]):e}function ai(e,t){var n,o,r=e.__data__;return("string"==(o=typeof(n=t))||"number"==o||"symbol"==o||"boolean"==o?"__proto__"!==n:null===n)?r["string"==typeof t?"string":"hash"]:r.map}function li(e){for(var t=Pa(e),n=t.length;n--;){var o=t[n],r=e[o];t[n]=[o,r,wi(r)]}return t}function ci(e,t){var n=function(e,t){return null==e?r:e[t]}(e,t);return Oo(n)?n:r}var ui=ft?function(e){return null==e?[]:(e=Te(e),It(ft(e),(function(t){return We.call(e,t)})))}:ml,hi=ft?function(e){for(var t=[];e;)Lt(t,ui(e)),e=je(e);return t}:ml,di=To;function pi(e,t,n){for(var o=-1,r=(t=yr(t,e)).length,i=!1;++o<r;){var s=Di(t[o]);if(!(i=null!=e&&n(e,s)))break;e=e[s]}return i||++o!=r?i:!!(r=null==e?0:e.length)&&Xs(r)&&gi(s,r)&&(Vs(e)||Us(e))}function mi(e){return"function"!=typeof e.constructor||xi(e)?{}:kn(je(e))}function fi(e){return Vs(e)||Us(e)||!!(Ye&&e&&e[Ye])}function gi(e,t){var n=typeof e;return!!(t=null==t?h:t)&&("number"==n||"symbol"!=n&&ye.test(e))&&e>-1&&e%1==0&&e<t}function yi(e,t,n){if(!Zs(n))return!1;var o=typeof t;return!!("number"==o?qs(n)&&gi(t,n.length):"string"==o&&t in n)&&ks(n[t],e)}function bi(e,t){if(Vs(e))return!1;var n=typeof e;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=e&&!aa(e))||Z.test(e)||!X.test(e)||null!=t&&e in Te(t)}function vi(e){var t=ri(e),n=Fn[t];if("function"!=typeof n||!(t in Un.prototype))return!1;if(e===n)return!0;var o=oi(n);return!!o&&e===o[0]}(wn&&di(new wn(new ArrayBuffer(1)))!=L||An&&di(new An)!=w||Tn&&di(Tn.resolve())!=E||En&&di(new En)!=N||Sn&&di(new Sn)!=P)&&(di=function(e){var t=To(e),n=t==T?e.constructor:r,o=n?Bi(n):"";if(o)switch(o){case Pn:return L;case _n:return w;case Ln:return E;case On:return N;case Rn:return P}return t});var Ci=_e?Qs:fl;function xi(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Pe)}function wi(e){return e==e&&!Zs(e)}function Ai(e,t){return function(n){return null!=n&&n[e]===t&&(t!==r||e in Te(n))}}function Ti(e,t,n){return t=gn(t===r?e.length-1:t,0),function(){for(var r=arguments,i=-1,s=gn(r.length-t,0),a=o(s);++i<s;)a[i]=r[t+i];i=-1;for(var l=o(t+1);++i<t;)l[i]=r[i];return l[t]=n(a),At(e,this,l)}}function Ei(e,t){return t.length<2?e:wo(e,tr(t,0,-1))}function Si(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}var Ni=_i(Xo),Ii=ut||function(e,t){return ht.setTimeout(e,t)},Mi=_i(Zo);function Pi(e,t,n){var o=t+"";return Mi(e,function(e,t){var n=t.length;if(!n)return e;var o=n-1;return t[o]=(n>1?"& ":"")+t[o],t=t.join(n>2?", ":" "),e.replace(ie,"{\n/* [wrapped with "+t+"] */\n")}(o,function(e,t){return Et(m,(function(n){var o="_."+n[0];t&n[1]&&!Mt(e,o)&&e.push(o)})),e.sort()}(function(e){var t=e.match(se);return t?t[1].split(ae):[]}(o),n)))}function _i(e){var t=0,n=0;return function(){var o=bn(),i=16-(o-n);if(n=o,i>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(r,arguments)}}function Li(e,t){var n=-1,o=e.length,i=o-1;for(t=t===r?o:t;++n<t;){var s=Wo(n,i),a=e[s];e[s]=e[n],e[n]=a}return e.length=t,e}var Oi,Ri,$i=(Oi=Os((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(ee,(function(e,n,o,r){t.push(o?r.replace(ue,"$1"):n||e)})),t}),(function(e){return 500===Ri.size&&Ri.clear(),e})),Ri=Oi.cache,Oi);function Di(e){if("string"==typeof e||aa(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function Bi(e){if(null!=e){try{return Le.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function Fi(e){if(e instanceof Un)return e.clone();var t=new Gn(e.__wrapped__,e.__chain__);return t.__actions__=Nr(e.__actions__),t.__index__=e.__index__,t.__values__=e.__values__,t}var ki=Yo((function(e,t){return Ws(e)?co(e,go(t,1,Ws,!0)):[]})),Hi=Yo((function(e,t){var n=Ki(t);return Ws(n)&&(n=r),Ws(e)?co(e,go(t,1,Ws,!0),si(n,2)):[]})),Gi=Yo((function(e,t){var n=Ki(t);return Ws(n)&&(n=r),Ws(e)?co(e,go(t,1,Ws,!0),r,n):[]}));function Ui(e,t,n){var o=null==e?0:e.length;if(!o)return-1;var r=null==n?0:pa(n);return r<0&&(r=gn(o+r,0)),Ft(e,si(t,3),r)}function Vi(e,t,n){var o=null==e?0:e.length;if(!o)return-1;var i=o-1;return n!==r&&(i=pa(n),i=n<0?gn(o+i,0):yn(i,o-1)),Ft(e,si(t,3),i,!0)}function ji(e){return null!=e&&e.length?go(e,1):[]}function qi(e){return e&&e.length?e[0]:r}var Wi=Yo((function(e){var t=_t(e,fr);return t.length&&t[0]===e[0]?Io(t):[]})),zi=Yo((function(e){var t=Ki(e),n=_t(e,fr);return t===Ki(n)?t=r:n.pop(),n.length&&n[0]===e[0]?Io(n,si(t,2)):[]})),Yi=Yo((function(e){var t=Ki(e),n=_t(e,fr);return(t="function"==typeof t?t:r)&&n.pop(),n.length&&n[0]===e[0]?Io(n,r,t):[]}));function Ki(e){var t=null==e?0:e.length;return t?e[t-1]:r}var Qi=Yo(Ji);function Ji(e,t){return e&&e.length&&t&&t.length?jo(e,t):e}var Xi=ei((function(e,t){var n=null==e?0:e.length,o=ro(e,t);return qo(e,_t(t,(function(e){return gi(e,n)?+e:e})).sort(Tr)),o}));function Zi(e){return null==e?e:xn.call(e)}var es=Yo((function(e){return lr(go(e,1,Ws,!0))})),ts=Yo((function(e){var t=Ki(e);return Ws(t)&&(t=r),lr(go(e,1,Ws,!0),si(t,2))})),ns=Yo((function(e){var t=Ki(e);return t="function"==typeof t?t:r,lr(go(e,1,Ws,!0),r,t)}));function os(e){if(!e||!e.length)return[];var t=0;return e=It(e,(function(e){if(Ws(e))return t=gn(e.length,t),!0})),zt(t,(function(t){return _t(e,Vt(t))}))}function rs(e,t){if(!e||!e.length)return[];var n=os(e);return null==t?n:_t(n,(function(e){return At(t,r,e)}))}var is=Yo((function(e,t){return Ws(e)?co(e,t):[]})),ss=Yo((function(e){return pr(It(e,Ws))})),as=Yo((function(e){var t=Ki(e);return Ws(t)&&(t=r),pr(It(e,Ws),si(t,2))})),ls=Yo((function(e){var t=Ki(e);return t="function"==typeof t?t:r,pr(It(e,Ws),r,t)})),cs=Yo(os),us=Yo((function(e){var t=e.length,n=t>1?e[t-1]:r;return n="function"==typeof n?(e.pop(),n):r,rs(e,n)}));function hs(e){var t=Fn(e);return t.__chain__=!0,t}function ds(e,t){return t(e)}var ps=ei((function(e){var t=e.length,n=t?e[0]:0,o=this.__wrapped__,i=function(t){return ro(t,e)};return!(t>1||this.__actions__.length)&&o instanceof Un&&gi(n)?((o=o.slice(n,+n+(t?1:0))).__actions__.push({func:ds,args:[i],thisArg:r}),new Gn(o,this.__chain__).thru((function(e){return t&&!e.length&&e.push(r),e}))):this.thru(i)})),ms=Mr((function(e,t,n){Oe.call(e,n)?++e[n]:oo(e,n,1)})),fs=Dr(Ui),gs=Dr(Vi);function ys(e,t){return(Vs(e)?Et:uo)(e,si(t,3))}function bs(e,t){return(Vs(e)?St:ho)(e,si(t,3))}var vs=Mr((function(e,t,n){Oe.call(e,n)?e[n].push(t):oo(e,n,[t])})),Cs=Yo((function(e,t,n){var r=-1,i="function"==typeof t,s=qs(e)?o(e.length):[];return uo(e,(function(e){s[++r]=i?At(t,e,n):Mo(e,t,n)})),s})),xs=Mr((function(e,t,n){oo(e,n,t)}));function ws(e,t){return(Vs(e)?_t:Bo)(e,si(t,3))}var As=Mr((function(e,t,n){e[n?0:1].push(t)}),(function(){return[[],[]]})),Ts=Yo((function(e,t){if(null==e)return[];var n=t.length;return n>1&&yi(e,t[0],t[1])?t=[]:n>2&&yi(t[0],t[1],t[2])&&(t=[t[0]]),Uo(e,go(t,1),[])})),Es=ct||function(){return ht.Date.now()};function Ss(e,t,n){return t=n?r:t,t=e&&null==t?e.length:t,Kr(e,c,r,r,r,r,t)}function Ns(e,t){var n;if("function"!=typeof t)throw new Ne(i);return e=pa(e),function(){return--e>0&&(n=t.apply(this,arguments)),e<=1&&(t=r),n}}var Is=Yo((function(e,t,n){var o=1;if(n.length){var r=an(n,ii(Is));o|=l}return Kr(e,o,t,n,r)})),Ms=Yo((function(e,t,n){var o=3;if(n.length){var r=an(n,ii(Ms));o|=l}return Kr(t,o,e,n,r)}));function Ps(e,t,n){var o,s,a,l,c,u,h=0,d=!1,p=!1,m=!0;if("function"!=typeof e)throw new Ne(i);function f(t){var n=o,i=s;return o=s=r,h=t,l=e.apply(i,n)}function g(e){var n=e-u;return u===r||n>=t||n<0||p&&e-h>=a}function y(){var e=Es();if(g(e))return b(e);c=Ii(y,function(e){var n=t-(e-u);return p?yn(n,a-(e-h)):n}(e))}function b(e){return c=r,m&&o?f(e):(o=s=r,l)}function v(){var e=Es(),n=g(e);if(o=arguments,s=this,u=e,n){if(c===r)return function(e){return h=e,c=Ii(y,t),d?f(e):l}(u);if(p)return Cr(c),c=Ii(y,t),f(u)}return c===r&&(c=Ii(y,t)),l}return t=fa(t)||0,Zs(n)&&(d=!!n.leading,a=(p="maxWait"in n)?gn(fa(n.maxWait)||0,t):a,m="trailing"in n?!!n.trailing:m),v.cancel=function(){c!==r&&Cr(c),h=0,o=u=s=c=r},v.flush=function(){return c===r?l:b(Es())},v}var _s=Yo((function(e,t){return lo(e,1,t)})),Ls=Yo((function(e,t,n){return lo(e,fa(t)||0,n)}));function Os(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new Ne(i);var n=function(){var o=arguments,r=t?t.apply(this,o):o[0],i=n.cache;if(i.has(r))return i.get(r);var s=e.apply(this,o);return n.cache=i.set(r,s)||i,s};return n.cache=new(Os.Cache||qn),n}function Rs(e){if("function"!=typeof e)throw new Ne(i);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}Os.Cache=qn;var $s=br((function(e,t){var n=(t=1==t.length&&Vs(t[0])?_t(t[0],Kt(si())):_t(go(t,1),Kt(si()))).length;return Yo((function(o){for(var r=-1,i=yn(o.length,n);++r<i;)o[r]=t[r].call(this,o[r]);return At(e,this,o)}))})),Ds=Yo((function(e,t){var n=an(t,ii(Ds));return Kr(e,l,r,t,n)})),Bs=Yo((function(e,t){var n=an(t,ii(Bs));return Kr(e,64,r,t,n)})),Fs=ei((function(e,t){return Kr(e,256,r,r,r,t)}));function ks(e,t){return e===t||e!=e&&t!=t}var Hs=jr(Eo),Gs=jr((function(e,t){return e>=t})),Us=Po(function(){return arguments}())?Po:function(e){return ea(e)&&Oe.call(e,"callee")&&!We.call(e,"callee")},Vs=o.isArray,js=yt?Kt(yt):function(e){return ea(e)&&To(e)==_};function qs(e){return null!=e&&Xs(e.length)&&!Qs(e)}function Ws(e){return ea(e)&&qs(e)}var zs=gt||fl,Ys=bt?Kt(bt):function(e){return ea(e)&&To(e)==b};function Ks(e){if(!ea(e))return!1;var t=To(e);return t==v||"[object DOMException]"==t||"string"==typeof e.message&&"string"==typeof e.name&&!oa(e)}function Qs(e){if(!Zs(e))return!1;var t=To(e);return t==C||t==x||"[object AsyncFunction]"==t||"[object Proxy]"==t}function Js(e){return"number"==typeof e&&e==pa(e)}function Xs(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=h}function Zs(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function ea(e){return null!=e&&"object"==typeof e}var ta=vt?Kt(vt):function(e){return ea(e)&&di(e)==w};function na(e){return"number"==typeof e||ea(e)&&To(e)==A}function oa(e){if(!ea(e)||To(e)!=T)return!1;var t=je(e);if(null===t)return!0;var n=Oe.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&Le.call(n)==Be}var ra=Ct?Kt(Ct):function(e){return ea(e)&&To(e)==S},ia=xt?Kt(xt):function(e){return ea(e)&&di(e)==N};function sa(e){return"string"==typeof e||!Vs(e)&&ea(e)&&To(e)==I}function aa(e){return"symbol"==typeof e||ea(e)&&To(e)==M}var la=wt?Kt(wt):function(e){return ea(e)&&Xs(e.length)&&!!rt[To(e)]},ca=jr(Do),ua=jr((function(e,t){return e<=t}));function ha(e){if(!e)return[];if(qs(e))return sa(e)?hn(e):Nr(e);if(Ke&&e[Ke])return function(e){for(var t,n=[];!(t=e.next()).done;)n.push(t.value);return n}(e[Ke]());var t=di(e);return(t==w?rn:t==N?ln:ka)(e)}function da(e){return e?(e=fa(e))===u||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}function pa(e){var t=da(e),n=t%1;return t==t?n?t-n:t:0}function ma(e){return e?io(pa(e),0,p):0}function fa(e){if("number"==typeof e)return e;if(aa(e))return d;if(Zs(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=Zs(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=Yt(e);var n=me.test(e);return n||ge.test(e)?lt(e.slice(2),n?2:8):pe.test(e)?d:+e}function ga(e){return Ir(e,_a(e))}function ya(e){return null==e?"":ar(e)}var ba=Pr((function(e,t){if(xi(t)||qs(t))Ir(t,Pa(t),e);else for(var n in t)Oe.call(t,n)&&Zn(e,n,t[n])})),va=Pr((function(e,t){Ir(t,_a(t),e)})),Ca=Pr((function(e,t,n,o){Ir(t,_a(t),e,o)})),xa=Pr((function(e,t,n,o){Ir(t,Pa(t),e,o)})),wa=ei(ro),Aa=Yo((function(e,t){e=Te(e);var n=-1,o=t.length,i=o>2?t[2]:r;for(i&&yi(t[0],t[1],i)&&(o=1);++n<o;)for(var s=t[n],a=_a(s),l=-1,c=a.length;++l<c;){var u=a[l],h=e[u];(h===r||ks(h,Pe[u])&&!Oe.call(e,u))&&(e[u]=s[u])}return e})),Ta=Yo((function(e){return e.push(r,Jr),At(Oa,r,e)}));function Ea(e,t,n){var o=null==e?r:wo(e,t);return o===r?n:o}function Sa(e,t){return null!=e&&pi(e,t,No)}var Na=kr((function(e,t,n){null!=t&&"function"!=typeof t.toString&&(t=De.call(t)),e[t]=n}),Za(nl)),Ia=kr((function(e,t,n){null!=t&&"function"!=typeof t.toString&&(t=De.call(t)),Oe.call(e,t)?e[t].push(n):e[t]=[n]}),si),Ma=Yo(Mo);function Pa(e){return qs(e)?Yn(e):$o(e)}function _a(e){return qs(e)?Yn(e,!0):function(e){if(!Zs(e))return function(e){var t=[];if(null!=e)for(var n in Te(e))t.push(n);return t}(e);var t=xi(e),n=[];for(var o in e)("constructor"!=o||!t&&Oe.call(e,o))&&n.push(o);return n}(e)}var La=Pr((function(e,t,n){Ho(e,t,n)})),Oa=Pr((function(e,t,n,o){Ho(e,t,n,o)})),Ra=ei((function(e,t){var n={};if(null==e)return n;var o=!1;t=_t(t,(function(t){return t=yr(t,e),o||(o=t.length>1),t})),Ir(e,ni(e),n),o&&(n=so(n,7,Xr));for(var r=t.length;r--;)cr(n,t[r]);return n})),$a=ei((function(e,t){return null==e?{}:function(e,t){return Vo(e,t,(function(t,n){return Sa(e,n)}))}(e,t)}));function Da(e,t){if(null==e)return{};var n=_t(ni(e),(function(e){return[e]}));return t=si(t),Vo(e,n,(function(e,n){return t(e,n[0])}))}var Ba=Yr(Pa),Fa=Yr(_a);function ka(e){return null==e?[]:Qt(e,Pa(e))}var Ha=Rr((function(e,t,n){return t=t.toLowerCase(),e+(n?Ga(t):t)}));function Ga(e){return Ka(ya(e).toLowerCase())}function Ua(e){return(e=ya(e))&&e.replace(be,en).replace(Je,"")}var Va=Rr((function(e,t,n){return e+(n?"-":"")+t.toLowerCase()})),ja=Rr((function(e,t,n){return e+(n?" ":"")+t.toLowerCase()})),qa=Or("toLowerCase"),Wa=Rr((function(e,t,n){return e+(n?"_":"")+t.toLowerCase()})),za=Rr((function(e,t,n){return e+(n?" ":"")+Ka(t)})),Ya=Rr((function(e,t,n){return e+(n?" ":"")+t.toUpperCase()})),Ka=Or("toUpperCase");function Qa(e,t,n){return e=ya(e),(t=n?r:t)===r?function(e){return tt.test(e)}(e)?function(e){return e.match(Ze)||[]}(e):function(e){return e.match(le)||[]}(e):e.match(t)||[]}var Ja=Yo((function(e,t){try{return At(e,r,t)}catch(e){return Ks(e)?e:new xe(e)}})),Xa=ei((function(e,t){return Et(t,(function(t){t=Di(t),oo(e,t,Is(e[t],e))})),e}));function Za(e){return function(){return e}}var el=Br(),tl=Br(!0);function nl(e){return e}function ol(e){return Ro("function"==typeof e?e:so(e,1))}var rl=Yo((function(e,t){return function(n){return Mo(n,e,t)}})),il=Yo((function(e,t){return function(n){return Mo(e,n,t)}}));function sl(e,t,n){var o=Pa(t),r=xo(t,o);null!=n||Zs(t)&&(r.length||!o.length)||(n=t,t=e,e=this,r=xo(t,Pa(t)));var i=!(Zs(n)&&"chain"in n&&!n.chain),s=Qs(e);return Et(r,(function(n){var o=t[n];e[n]=o,s&&(e.prototype[n]=function(){var t=this.__chain__;if(i||t){var n=e(this.__wrapped__);return(n.__actions__=Nr(this.__actions__)).push({func:o,args:arguments,thisArg:e}),n.__chain__=t,n}return o.apply(e,Lt([this.value()],arguments))})})),e}function al(){}var ll=Gr(_t),cl=Gr(Nt),ul=Gr($t);function hl(e){return bi(e)?Vt(Di(e)):function(e){return function(t){return wo(t,e)}}(e)}var dl=Vr(),pl=Vr(!0);function ml(){return[]}function fl(){return!1}var gl,yl=Hr((function(e,t){return e+t}),0),bl=Wr("ceil"),vl=Hr((function(e,t){return e/t}),1),Cl=Wr("floor"),xl=Hr((function(e,t){return e*t}),1),wl=Wr("round"),Al=Hr((function(e,t){return e-t}),0);return Fn.after=function(e,t){if("function"!=typeof t)throw new Ne(i);return e=pa(e),function(){if(--e<1)return t.apply(this,arguments)}},Fn.ary=Ss,Fn.assign=ba,Fn.assignIn=va,Fn.assignInWith=Ca,Fn.assignWith=xa,Fn.at=wa,Fn.before=Ns,Fn.bind=Is,Fn.bindAll=Xa,Fn.bindKey=Ms,Fn.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return Vs(e)?e:[e]},Fn.chain=hs,Fn.chunk=function(e,t,n){t=(n?yi(e,t,n):t===r)?1:gn(pa(t),0);var i=null==e?0:e.length;if(!i||t<1)return[];for(var s=0,a=0,l=o(dt(i/t));s<i;)l[a++]=tr(e,s,s+=t);return l},Fn.compact=function(e){for(var t=-1,n=null==e?0:e.length,o=0,r=[];++t<n;){var i=e[t];i&&(r[o++]=i)}return r},Fn.concat=function(){var e=arguments.length;if(!e)return[];for(var t=o(e-1),n=arguments[0],r=e;r--;)t[r-1]=arguments[r];return Lt(Vs(n)?Nr(n):[n],go(t,1))},Fn.cond=function(e){var t=null==e?0:e.length,n=si();return e=t?_t(e,(function(e){if("function"!=typeof e[1])throw new Ne(i);return[n(e[0]),e[1]]})):[],Yo((function(n){for(var o=-1;++o<t;){var r=e[o];if(At(r[0],this,n))return At(r[1],this,n)}}))},Fn.conforms=function(e){return function(e){var t=Pa(e);return function(n){return ao(n,e,t)}}(so(e,1))},Fn.constant=Za,Fn.countBy=ms,Fn.create=function(e,t){var n=kn(e);return null==t?n:no(n,t)},Fn.curry=function e(t,n,o){var i=Kr(t,8,r,r,r,r,r,n=o?r:n);return i.placeholder=e.placeholder,i},Fn.curryRight=function e(t,n,o){var i=Kr(t,16,r,r,r,r,r,n=o?r:n);return i.placeholder=e.placeholder,i},Fn.debounce=Ps,Fn.defaults=Aa,Fn.defaultsDeep=Ta,Fn.defer=_s,Fn.delay=Ls,Fn.difference=ki,Fn.differenceBy=Hi,Fn.differenceWith=Gi,Fn.drop=function(e,t,n){var o=null==e?0:e.length;return o?tr(e,(t=n||t===r?1:pa(t))<0?0:t,o):[]},Fn.dropRight=function(e,t,n){var o=null==e?0:e.length;return o?tr(e,0,(t=o-(t=n||t===r?1:pa(t)))<0?0:t):[]},Fn.dropRightWhile=function(e,t){return e&&e.length?hr(e,si(t,3),!0,!0):[]},Fn.dropWhile=function(e,t){return e&&e.length?hr(e,si(t,3),!0):[]},Fn.fill=function(e,t,n,o){var i=null==e?0:e.length;return i?(n&&"number"!=typeof n&&yi(e,t,n)&&(n=0,o=i),function(e,t,n,o){var i=e.length;for((n=pa(n))<0&&(n=-n>i?0:i+n),(o=o===r||o>i?i:pa(o))<0&&(o+=i),o=n>o?0:ma(o);n<o;)e[n++]=t;return e}(e,t,n,o)):[]},Fn.filter=function(e,t){return(Vs(e)?It:fo)(e,si(t,3))},Fn.flatMap=function(e,t){return go(ws(e,t),1)},Fn.flatMapDeep=function(e,t){return go(ws(e,t),u)},Fn.flatMapDepth=function(e,t,n){return n=n===r?1:pa(n),go(ws(e,t),n)},Fn.flatten=ji,Fn.flattenDeep=function(e){return null!=e&&e.length?go(e,u):[]},Fn.flattenDepth=function(e,t){return null!=e&&e.length?go(e,t=t===r?1:pa(t)):[]},Fn.flip=function(e){return Kr(e,512)},Fn.flow=el,Fn.flowRight=tl,Fn.fromPairs=function(e){for(var t=-1,n=null==e?0:e.length,o={};++t<n;){var r=e[t];o[r[0]]=r[1]}return o},Fn.functions=function(e){return null==e?[]:xo(e,Pa(e))},Fn.functionsIn=function(e){return null==e?[]:xo(e,_a(e))},Fn.groupBy=vs,Fn.initial=function(e){return null!=e&&e.length?tr(e,0,-1):[]},Fn.intersection=Wi,Fn.intersectionBy=zi,Fn.intersectionWith=Yi,Fn.invert=Na,Fn.invertBy=Ia,Fn.invokeMap=Cs,Fn.iteratee=ol,Fn.keyBy=xs,Fn.keys=Pa,Fn.keysIn=_a,Fn.map=ws,Fn.mapKeys=function(e,t){var n={};return t=si(t,3),vo(e,(function(e,o,r){oo(n,t(e,o,r),e)})),n},Fn.mapValues=function(e,t){var n={};return t=si(t,3),vo(e,(function(e,o,r){oo(n,o,t(e,o,r))})),n},Fn.matches=function(e){return Fo(so(e,1))},Fn.matchesProperty=function(e,t){return ko(e,so(t,1))},Fn.memoize=Os,Fn.merge=La,Fn.mergeWith=Oa,Fn.method=rl,Fn.methodOf=il,Fn.mixin=sl,Fn.negate=Rs,Fn.nthArg=function(e){return e=pa(e),Yo((function(t){return Go(t,e)}))},Fn.omit=Ra,Fn.omitBy=function(e,t){return Da(e,Rs(si(t)))},Fn.once=function(e){return Ns(2,e)},Fn.orderBy=function(e,t,n,o){return null==e?[]:(Vs(t)||(t=null==t?[]:[t]),Vs(n=o?r:n)||(n=null==n?[]:[n]),Uo(e,t,n))},Fn.over=ll,Fn.overArgs=$s,Fn.overEvery=cl,Fn.overSome=ul,Fn.partial=Ds,Fn.partialRight=Bs,Fn.partition=As,Fn.pick=$a,Fn.pickBy=Da,Fn.property=hl,Fn.propertyOf=function(e){return function(t){return null==e?r:wo(e,t)}},Fn.pull=Qi,Fn.pullAll=Ji,Fn.pullAllBy=function(e,t,n){return e&&e.length&&t&&t.length?jo(e,t,si(n,2)):e},Fn.pullAllWith=function(e,t,n){return e&&e.length&&t&&t.length?jo(e,t,r,n):e},Fn.pullAt=Xi,Fn.range=dl,Fn.rangeRight=pl,Fn.rearg=Fs,Fn.reject=function(e,t){return(Vs(e)?It:fo)(e,Rs(si(t,3)))},Fn.remove=function(e,t){var n=[];if(!e||!e.length)return n;var o=-1,r=[],i=e.length;for(t=si(t,3);++o<i;){var s=e[o];t(s,o,e)&&(n.push(s),r.push(o))}return qo(e,r),n},Fn.rest=function(e,t){if("function"!=typeof e)throw new Ne(i);return Yo(e,t=t===r?t:pa(t))},Fn.reverse=Zi,Fn.sampleSize=function(e,t,n){return t=(n?yi(e,t,n):t===r)?1:pa(t),(Vs(e)?Qn:Qo)(e,t)},Fn.set=function(e,t,n){return null==e?e:Jo(e,t,n)},Fn.setWith=function(e,t,n,o){return o="function"==typeof o?o:r,null==e?e:Jo(e,t,n,o)},Fn.shuffle=function(e){return(Vs(e)?Jn:er)(e)},Fn.slice=function(e,t,n){var o=null==e?0:e.length;return o?(n&&"number"!=typeof n&&yi(e,t,n)?(t=0,n=o):(t=null==t?0:pa(t),n=n===r?o:pa(n)),tr(e,t,n)):[]},Fn.sortBy=Ts,Fn.sortedUniq=function(e){return e&&e.length?ir(e):[]},Fn.sortedUniqBy=function(e,t){return e&&e.length?ir(e,si(t,2)):[]},Fn.split=function(e,t,n){return n&&"number"!=typeof n&&yi(e,t,n)&&(t=n=r),(n=n===r?p:n>>>0)?(e=ya(e))&&("string"==typeof t||null!=t&&!ra(t))&&!(t=ar(t))&&on(e)?vr(hn(e),0,n):e.split(t,n):[]},Fn.spread=function(e,t){if("function"!=typeof e)throw new Ne(i);return t=null==t?0:gn(pa(t),0),Yo((function(n){var o=n[t],r=vr(n,0,t);return o&&Lt(r,o),At(e,this,r)}))},Fn.tail=function(e){var t=null==e?0:e.length;return t?tr(e,1,t):[]},Fn.take=function(e,t,n){return e&&e.length?tr(e,0,(t=n||t===r?1:pa(t))<0?0:t):[]},Fn.takeRight=function(e,t,n){var o=null==e?0:e.length;return o?tr(e,(t=o-(t=n||t===r?1:pa(t)))<0?0:t,o):[]},Fn.takeRightWhile=function(e,t){return e&&e.length?hr(e,si(t,3),!1,!0):[]},Fn.takeWhile=function(e,t){return e&&e.length?hr(e,si(t,3)):[]},Fn.tap=function(e,t){return t(e),e},Fn.throttle=function(e,t,n){var o=!0,r=!0;if("function"!=typeof e)throw new Ne(i);return Zs(n)&&(o="leading"in n?!!n.leading:o,r="trailing"in n?!!n.trailing:r),Ps(e,t,{leading:o,maxWait:t,trailing:r})},Fn.thru=ds,Fn.toArray=ha,Fn.toPairs=Ba,Fn.toPairsIn=Fa,Fn.toPath=function(e){return Vs(e)?_t(e,Di):aa(e)?[e]:Nr($i(ya(e)))},Fn.toPlainObject=ga,Fn.transform=function(e,t,n){var o=Vs(e),r=o||zs(e)||la(e);if(t=si(t,4),null==n){var i=e&&e.constructor;n=r?o?new i:[]:Zs(e)&&Qs(i)?kn(je(e)):{}}return(r?Et:vo)(e,(function(e,o,r){return t(n,e,o,r)})),n},Fn.unary=function(e){return Ss(e,1)},Fn.union=es,Fn.unionBy=ts,Fn.unionWith=ns,Fn.uniq=function(e){return e&&e.length?lr(e):[]},Fn.uniqBy=function(e,t){return e&&e.length?lr(e,si(t,2)):[]},Fn.uniqWith=function(e,t){return t="function"==typeof t?t:r,e&&e.length?lr(e,r,t):[]},Fn.unset=function(e,t){return null==e||cr(e,t)},Fn.unzip=os,Fn.unzipWith=rs,Fn.update=function(e,t,n){return null==e?e:ur(e,t,gr(n))},Fn.updateWith=function(e,t,n,o){return o="function"==typeof o?o:r,null==e?e:ur(e,t,gr(n),o)},Fn.values=ka,Fn.valuesIn=function(e){return null==e?[]:Qt(e,_a(e))},Fn.without=is,Fn.words=Qa,Fn.wrap=function(e,t){return Ds(gr(t),e)},Fn.xor=ss,Fn.xorBy=as,Fn.xorWith=ls,Fn.zip=cs,Fn.zipObject=function(e,t){return mr(e||[],t||[],Zn)},Fn.zipObjectDeep=function(e,t){return mr(e||[],t||[],Jo)},Fn.zipWith=us,Fn.entries=Ba,Fn.entriesIn=Fa,Fn.extend=va,Fn.extendWith=Ca,sl(Fn,Fn),Fn.add=yl,Fn.attempt=Ja,Fn.camelCase=Ha,Fn.capitalize=Ga,Fn.ceil=bl,Fn.clamp=function(e,t,n){return n===r&&(n=t,t=r),n!==r&&(n=(n=fa(n))==n?n:0),t!==r&&(t=(t=fa(t))==t?t:0),io(fa(e),t,n)},Fn.clone=function(e){return so(e,4)},Fn.cloneDeep=function(e){return so(e,5)},Fn.cloneDeepWith=function(e,t){return so(e,5,t="function"==typeof t?t:r)},Fn.cloneWith=function(e,t){return so(e,4,t="function"==typeof t?t:r)},Fn.conformsTo=function(e,t){return null==t||ao(e,t,Pa(t))},Fn.deburr=Ua,Fn.defaultTo=function(e,t){return null==e||e!=e?t:e},Fn.divide=vl,Fn.endsWith=function(e,t,n){e=ya(e),t=ar(t);var o=e.length,i=n=n===r?o:io(pa(n),0,o);return(n-=t.length)>=0&&e.slice(n,i)==t},Fn.eq=ks,Fn.escape=function(e){return(e=ya(e))&&Y.test(e)?e.replace(W,tn):e},Fn.escapeRegExp=function(e){return(e=ya(e))&&ne.test(e)?e.replace(te,"\\$&"):e},Fn.every=function(e,t,n){var o=Vs(e)?Nt:po;return n&&yi(e,t,n)&&(t=r),o(e,si(t,3))},Fn.find=fs,Fn.findIndex=Ui,Fn.findKey=function(e,t){return Bt(e,si(t,3),vo)},Fn.findLast=gs,Fn.findLastIndex=Vi,Fn.findLastKey=function(e,t){return Bt(e,si(t,3),Co)},Fn.floor=Cl,Fn.forEach=ys,Fn.forEachRight=bs,Fn.forIn=function(e,t){return null==e?e:yo(e,si(t,3),_a)},Fn.forInRight=function(e,t){return null==e?e:bo(e,si(t,3),_a)},Fn.forOwn=function(e,t){return e&&vo(e,si(t,3))},Fn.forOwnRight=function(e,t){return e&&Co(e,si(t,3))},Fn.get=Ea,Fn.gt=Hs,Fn.gte=Gs,Fn.has=function(e,t){return null!=e&&pi(e,t,So)},Fn.hasIn=Sa,Fn.head=qi,Fn.identity=nl,Fn.includes=function(e,t,n,o){e=qs(e)?e:ka(e),n=n&&!o?pa(n):0;var r=e.length;return n<0&&(n=gn(r+n,0)),sa(e)?n<=r&&e.indexOf(t,n)>-1:!!r&&kt(e,t,n)>-1},Fn.indexOf=function(e,t,n){var o=null==e?0:e.length;if(!o)return-1;var r=null==n?0:pa(n);return r<0&&(r=gn(o+r,0)),kt(e,t,r)},Fn.inRange=function(e,t,n){return t=da(t),n===r?(n=t,t=0):n=da(n),function(e,t,n){return e>=yn(t,n)&&e<gn(t,n)}(e=fa(e),t,n)},Fn.invoke=Ma,Fn.isArguments=Us,Fn.isArray=Vs,Fn.isArrayBuffer=js,Fn.isArrayLike=qs,Fn.isArrayLikeObject=Ws,Fn.isBoolean=function(e){return!0===e||!1===e||ea(e)&&To(e)==y},Fn.isBuffer=zs,Fn.isDate=Ys,Fn.isElement=function(e){return ea(e)&&1===e.nodeType&&!oa(e)},Fn.isEmpty=function(e){if(null==e)return!0;if(qs(e)&&(Vs(e)||"string"==typeof e||"function"==typeof e.splice||zs(e)||la(e)||Us(e)))return!e.length;var t=di(e);if(t==w||t==N)return!e.size;if(xi(e))return!$o(e).length;for(var n in e)if(Oe.call(e,n))return!1;return!0},Fn.isEqual=function(e,t){return _o(e,t)},Fn.isEqualWith=function(e,t,n){var o=(n="function"==typeof n?n:r)?n(e,t):r;return o===r?_o(e,t,r,n):!!o},Fn.isError=Ks,Fn.isFinite=function(e){return"number"==typeof e&&Dt(e)},Fn.isFunction=Qs,Fn.isInteger=Js,Fn.isLength=Xs,Fn.isMap=ta,Fn.isMatch=function(e,t){return e===t||Lo(e,t,li(t))},Fn.isMatchWith=function(e,t,n){return n="function"==typeof n?n:r,Lo(e,t,li(t),n)},Fn.isNaN=function(e){return na(e)&&e!=+e},Fn.isNative=function(e){if(Ci(e))throw new xe("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");return Oo(e)},Fn.isNil=function(e){return null==e},Fn.isNull=function(e){return null===e},Fn.isNumber=na,Fn.isObject=Zs,Fn.isObjectLike=ea,Fn.isPlainObject=oa,Fn.isRegExp=ra,Fn.isSafeInteger=function(e){return Js(e)&&e>=-9007199254740991&&e<=h},Fn.isSet=ia,Fn.isString=sa,Fn.isSymbol=aa,Fn.isTypedArray=la,Fn.isUndefined=function(e){return e===r},Fn.isWeakMap=function(e){return ea(e)&&di(e)==P},Fn.isWeakSet=function(e){return ea(e)&&"[object WeakSet]"==To(e)},Fn.join=function(e,t){return null==e?"":jt.call(e,t)},Fn.kebabCase=Va,Fn.last=Ki,Fn.lastIndexOf=function(e,t,n){var o=null==e?0:e.length;if(!o)return-1;var i=o;return n!==r&&(i=(i=pa(n))<0?gn(o+i,0):yn(i,o-1)),t==t?function(e,t,n){for(var o=n+1;o--;)if(e[o]===t)return o;return o}(e,t,i):Ft(e,Gt,i,!0)},Fn.lowerCase=ja,Fn.lowerFirst=qa,Fn.lt=ca,Fn.lte=ua,Fn.max=function(e){return e&&e.length?mo(e,nl,Eo):r},Fn.maxBy=function(e,t){return e&&e.length?mo(e,si(t,2),Eo):r},Fn.mean=function(e){return Ut(e,nl)},Fn.meanBy=function(e,t){return Ut(e,si(t,2))},Fn.min=function(e){return e&&e.length?mo(e,nl,Do):r},Fn.minBy=function(e,t){return e&&e.length?mo(e,si(t,2),Do):r},Fn.stubArray=ml,Fn.stubFalse=fl,Fn.stubObject=function(){return{}},Fn.stubString=function(){return""},Fn.stubTrue=function(){return!0},Fn.multiply=xl,Fn.nth=function(e,t){return e&&e.length?Go(e,pa(t)):r},Fn.noConflict=function(){return ht._===this&&(ht._=Fe),this},Fn.noop=al,Fn.now=Es,Fn.pad=function(e,t,n){e=ya(e);var o=(t=pa(t))?un(e):0;if(!t||o>=t)return e;var r=(t-o)/2;return Ur(pt(r),n)+e+Ur(dt(r),n)},Fn.padEnd=function(e,t,n){e=ya(e);var o=(t=pa(t))?un(e):0;return t&&o<t?e+Ur(t-o,n):e},Fn.padStart=function(e,t,n){e=ya(e);var o=(t=pa(t))?un(e):0;return t&&o<t?Ur(t-o,n)+e:e},Fn.parseInt=function(e,t,n){return n||null==t?t=0:t&&(t=+t),vn(ya(e).replace(oe,""),t||0)},Fn.random=function(e,t,n){if(n&&"boolean"!=typeof n&&yi(e,t,n)&&(t=n=r),n===r&&("boolean"==typeof t?(n=t,t=r):"boolean"==typeof e&&(n=e,e=r)),e===r&&t===r?(e=0,t=1):(e=da(e),t===r?(t=e,e=0):t=da(t)),e>t){var o=e;e=t,t=o}if(n||e%1||t%1){var i=Cn();return yn(e+i*(t-e+at("1e-"+((i+"").length-1))),t)}return Wo(e,t)},Fn.reduce=function(e,t,n){var o=Vs(e)?Ot:qt,r=arguments.length<3;return o(e,si(t,4),n,r,uo)},Fn.reduceRight=function(e,t,n){var o=Vs(e)?Rt:qt,r=arguments.length<3;return o(e,si(t,4),n,r,ho)},Fn.repeat=function(e,t,n){return t=(n?yi(e,t,n):t===r)?1:pa(t),zo(ya(e),t)},Fn.replace=function(){var e=arguments,t=ya(e[0]);return e.length<3?t:t.replace(e[1],e[2])},Fn.result=function(e,t,n){var o=-1,i=(t=yr(t,e)).length;for(i||(i=1,e=r);++o<i;){var s=null==e?r:e[Di(t[o])];s===r&&(o=i,s=n),e=Qs(s)?s.call(e):s}return e},Fn.round=wl,Fn.runInContext=e,Fn.sample=function(e){return(Vs(e)?Kn:Ko)(e)},Fn.size=function(e){if(null==e)return 0;if(qs(e))return sa(e)?un(e):e.length;var t=di(e);return t==w||t==N?e.size:$o(e).length},Fn.snakeCase=Wa,Fn.some=function(e,t,n){var o=Vs(e)?$t:nr;return n&&yi(e,t,n)&&(t=r),o(e,si(t,3))},Fn.sortedIndex=function(e,t){return or(e,t)},Fn.sortedIndexBy=function(e,t,n){return rr(e,t,si(n,2))},Fn.sortedIndexOf=function(e,t){var n=null==e?0:e.length;if(n){var o=or(e,t);if(o<n&&ks(e[o],t))return o}return-1},Fn.sortedLastIndex=function(e,t){return or(e,t,!0)},Fn.sortedLastIndexBy=function(e,t,n){return rr(e,t,si(n,2),!0)},Fn.sortedLastIndexOf=function(e,t){if(null!=e&&e.length){var n=or(e,t,!0)-1;if(ks(e[n],t))return n}return-1},Fn.startCase=za,Fn.startsWith=function(e,t,n){return e=ya(e),n=null==n?0:io(pa(n),0,e.length),t=ar(t),e.slice(n,n+t.length)==t},Fn.subtract=Al,Fn.sum=function(e){return e&&e.length?Wt(e,nl):0},Fn.sumBy=function(e,t){return e&&e.length?Wt(e,si(t,2)):0},Fn.template=function(e,t,n){var o=Fn.templateSettings;n&&yi(e,t,n)&&(t=r),e=ya(e),t=Ca({},t,o,Qr);var i,s,a=Ca({},t.imports,o.imports,Qr),l=Pa(a),c=Qt(a,l),u=0,h=t.interpolate||ve,d="__p += '",p=Ee((t.escape||ve).source+"|"+h.source+"|"+(h===J?he:ve).source+"|"+(t.evaluate||ve).source+"|$","g"),m="//# sourceURL="+(Oe.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++ot+"]")+"\n";e.replace(p,(function(t,n,o,r,a,l){return o||(o=r),d+=e.slice(u,l).replace(Ce,nn),n&&(i=!0,d+="' +\n__e("+n+") +\n'"),a&&(s=!0,d+="';\n"+a+";\n__p += '"),o&&(d+="' +\n((__t = ("+o+")) == null ? '' : __t) +\n'"),u=l+t.length,t})),d+="';\n";var f=Oe.call(t,"variable")&&t.variable;if(f){if(ce.test(f))throw new xe("Invalid `variable` option passed into `_.template`")}else d="with (obj) {\n"+d+"\n}\n";d=(s?d.replace(U,""):d).replace(V,"$1").replace(j,"$1;"),d="function("+(f||"obj")+") {\n"+(f?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(i?", __e = _.escape":"")+(s?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+d+"return __p\n}";var g=Ja((function(){return we(l,m+"return "+d).apply(r,c)}));if(g.source=d,Ks(g))throw g;return g},Fn.times=function(e,t){if((e=pa(e))<1||e>h)return[];var n=p,o=yn(e,p);t=si(t),e-=p;for(var r=zt(o,t);++n<e;)t(n);return r},Fn.toFinite=da,Fn.toInteger=pa,Fn.toLength=ma,Fn.toLower=function(e){return ya(e).toLowerCase()},Fn.toNumber=fa,Fn.toSafeInteger=function(e){return e?io(pa(e),-9007199254740991,h):0===e?e:0},Fn.toString=ya,Fn.toUpper=function(e){return ya(e).toUpperCase()},Fn.trim=function(e,t,n){if((e=ya(e))&&(n||t===r))return Yt(e);if(!e||!(t=ar(t)))return e;var o=hn(e),i=hn(t);return vr(o,Xt(o,i),Zt(o,i)+1).join("")},Fn.trimEnd=function(e,t,n){if((e=ya(e))&&(n||t===r))return e.slice(0,dn(e)+1);if(!e||!(t=ar(t)))return e;var o=hn(e);return vr(o,0,Zt(o,hn(t))+1).join("")},Fn.trimStart=function(e,t,n){if((e=ya(e))&&(n||t===r))return e.replace(oe,"");if(!e||!(t=ar(t)))return e;var o=hn(e);return vr(o,Xt(o,hn(t))).join("")},Fn.truncate=function(e,t){var n=30,o="...";if(Zs(t)){var i="separator"in t?t.separator:i;n="length"in t?pa(t.length):n,o="omission"in t?ar(t.omission):o}var s=(e=ya(e)).length;if(on(e)){var a=hn(e);s=a.length}if(n>=s)return e;var l=n-un(o);if(l<1)return o;var c=a?vr(a,0,l).join(""):e.slice(0,l);if(i===r)return c+o;if(a&&(l+=c.length-l),ra(i)){if(e.slice(l).search(i)){var u,h=c;for(i.global||(i=Ee(i.source,ya(de.exec(i))+"g")),i.lastIndex=0;u=i.exec(h);)var d=u.index;c=c.slice(0,d===r?l:d)}}else if(e.indexOf(ar(i),l)!=l){var p=c.lastIndexOf(i);p>-1&&(c=c.slice(0,p))}return c+o},Fn.unescape=function(e){return(e=ya(e))&&z.test(e)?e.replace(q,pn):e},Fn.uniqueId=function(e){var t=++Re;return ya(e)+t},Fn.upperCase=Ya,Fn.upperFirst=Ka,Fn.each=ys,Fn.eachRight=bs,Fn.first=qi,sl(Fn,(gl={},vo(Fn,(function(e,t){Oe.call(Fn.prototype,t)||(gl[t]=e)})),gl),{chain:!1}),Fn.VERSION="4.17.21",Et(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(e){Fn[e].placeholder=Fn})),Et(["drop","take"],(function(e,t){Un.prototype[e]=function(n){n=n===r?1:gn(pa(n),0);var o=this.__filtered__&&!t?new Un(this):this.clone();return o.__filtered__?o.__takeCount__=yn(n,o.__takeCount__):o.__views__.push({size:yn(n,p),type:e+(o.__dir__<0?"Right":"")}),o},Un.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}})),Et(["filter","map","takeWhile"],(function(e,t){var n=t+1,o=1==n||3==n;Un.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:si(e,3),type:n}),t.__filtered__=t.__filtered__||o,t}})),Et(["head","last"],(function(e,t){var n="take"+(t?"Right":"");Un.prototype[e]=function(){return this[n](1).value()[0]}})),Et(["initial","tail"],(function(e,t){var n="drop"+(t?"":"Right");Un.prototype[e]=function(){return this.__filtered__?new Un(this):this[n](1)}})),Un.prototype.compact=function(){return this.filter(nl)},Un.prototype.find=function(e){return this.filter(e).head()},Un.prototype.findLast=function(e){return this.reverse().find(e)},Un.prototype.invokeMap=Yo((function(e,t){return"function"==typeof e?new Un(this):this.map((function(n){return Mo(n,e,t)}))})),Un.prototype.reject=function(e){return this.filter(Rs(si(e)))},Un.prototype.slice=function(e,t){e=pa(e);var n=this;return n.__filtered__&&(e>0||t<0)?new Un(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),t!==r&&(n=(t=pa(t))<0?n.dropRight(-t):n.take(t-e)),n)},Un.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},Un.prototype.toArray=function(){return this.take(p)},vo(Un.prototype,(function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),o=/^(?:head|last)$/.test(t),i=Fn[o?"take"+("last"==t?"Right":""):t],s=o||/^find/.test(t);i&&(Fn.prototype[t]=function(){var t=this.__wrapped__,a=o?[1]:arguments,l=t instanceof Un,c=a[0],u=l||Vs(t),h=function(e){var t=i.apply(Fn,Lt([e],a));return o&&d?t[0]:t};u&&n&&"function"==typeof c&&1!=c.length&&(l=u=!1);var d=this.__chain__,p=!!this.__actions__.length,m=s&&!d,f=l&&!p;if(!s&&u){t=f?t:new Un(this);var g=e.apply(t,a);return g.__actions__.push({func:ds,args:[h],thisArg:r}),new Gn(g,d)}return m&&f?e.apply(this,a):(g=this.thru(h),m?o?g.value()[0]:g.value():g)})})),Et(["pop","push","shift","sort","splice","unshift"],(function(e){var t=Ie[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",o=/^(?:pop|shift)$/.test(e);Fn.prototype[e]=function(){var e=arguments;if(o&&!this.__chain__){var r=this.value();return t.apply(Vs(r)?r:[],e)}return this[n]((function(n){return t.apply(Vs(n)?n:[],e)}))}})),vo(Un.prototype,(function(e,t){var n=Fn[t];if(n){var o=n.name+"";Oe.call(Mn,o)||(Mn[o]=[]),Mn[o].push({name:t,func:n})}})),Mn[Fr(r,2).name]=[{name:"wrapper",func:r}],Un.prototype.clone=function(){var e=new Un(this.__wrapped__);return e.__actions__=Nr(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=Nr(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=Nr(this.__views__),e},Un.prototype.reverse=function(){if(this.__filtered__){var e=new Un(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},Un.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,n=Vs(e),o=t<0,r=n?e.length:0,i=function(e,t,n){for(var o=-1,r=n.length;++o<r;){var i=n[o],s=i.size;switch(i.type){case"drop":e+=s;break;case"dropRight":t-=s;break;case"take":t=yn(t,e+s);break;case"takeRight":e=gn(e,t-s)}}return{start:e,end:t}}(0,r,this.__views__),s=i.start,a=i.end,l=a-s,c=o?a:s-1,u=this.__iteratees__,h=u.length,d=0,p=yn(l,this.__takeCount__);if(!n||!o&&r==l&&p==l)return dr(e,this.__actions__);var m=[];e:for(;l--&&d<p;){for(var f=-1,g=e[c+=t];++f<h;){var y=u[f],b=y.iteratee,v=y.type,C=b(g);if(2==v)g=C;else if(!C){if(1==v)continue e;break e}}m[d++]=g}return m},Fn.prototype.at=ps,Fn.prototype.chain=function(){return hs(this)},Fn.prototype.commit=function(){return new Gn(this.value(),this.__chain__)},Fn.prototype.next=function(){this.__values__===r&&(this.__values__=ha(this.value()));var e=this.__index__>=this.__values__.length;return{done:e,value:e?r:this.__values__[this.__index__++]}},Fn.prototype.plant=function(e){for(var t,n=this;n instanceof Hn;){var o=Fi(n);o.__index__=0,o.__values__=r,t?i.__wrapped__=o:t=o;var i=o;n=n.__wrapped__}return i.__wrapped__=e,t},Fn.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof Un){var t=e;return this.__actions__.length&&(t=new Un(this)),(t=t.reverse()).__actions__.push({func:ds,args:[Zi],thisArg:r}),new Gn(t,this.__chain__)}return this.thru(Zi)},Fn.prototype.toJSON=Fn.prototype.valueOf=Fn.prototype.value=function(){return dr(this.__wrapped__,this.__actions__)},Fn.prototype.first=Fn.prototype.head,Ke&&(Fn.prototype[Ke]=function(){return this}),Fn}();ht._=mn,(o=function(){return mn}.call(t,n,t,e))===r||(e.exports=o)}.call(this)},4802:e=>{e.exports=function e(t,n,o){function r(s,a){if(!n[s]){if(!t[s]){if(i)return i(s,!0);throw new Error("Cannot find module '"+s+"'")}a=n[s]={exports:{}},t[s][0].call(a.exports,(function(e){return r(t[s][1][e]||e)}),a,a.exports,e,t,n,o)}return n[s].exports}for(var i=void 0,s=0;s<o.length;s++)r(o[s]);return r}({1:[function(e,t,n){(function(o,r,i,s,a,l,c,u,h){"use strict";var d=e("crypto");function p(e,t){var n;return void 0===(n="passthrough"!==(t=g(e,t)).algorithm?d.createHash(t.algorithm):new v).write&&(n.write=n.update,n.end=n.update),b(t,n).dispatch(e),n.update||n.end(""),n.digest?n.digest("buffer"===t.encoding?void 0:t.encoding):(e=n.read(),"buffer"!==t.encoding?e.toString(t.encoding):e)}(n=t.exports=p).sha1=function(e){return p(e)},n.keys=function(e){return p(e,{excludeValues:!0,algorithm:"sha1",encoding:"hex"})},n.MD5=function(e){return p(e,{algorithm:"md5",encoding:"hex"})},n.keysMD5=function(e){return p(e,{algorithm:"md5",encoding:"hex",excludeValues:!0})};var m=d.getHashes?d.getHashes().slice():["sha1","md5"],f=(m.push("passthrough"),["buffer","hex","binary","base64"]);function g(e,t){var n={};if(n.algorithm=(t=t||{}).algorithm||"sha1",n.encoding=t.encoding||"hex",n.excludeValues=!!t.excludeValues,n.algorithm=n.algorithm.toLowerCase(),n.encoding=n.encoding.toLowerCase(),n.ignoreUnknown=!0===t.ignoreUnknown,n.respectType=!1!==t.respectType,n.respectFunctionNames=!1!==t.respectFunctionNames,n.respectFunctionProperties=!1!==t.respectFunctionProperties,n.unorderedArrays=!0===t.unorderedArrays,n.unorderedSets=!1!==t.unorderedSets,n.unorderedObjects=!1!==t.unorderedObjects,n.replacer=t.replacer||void 0,n.excludeKeys=t.excludeKeys||void 0,void 0===e)throw new Error("Object argument required.");for(var o=0;o<m.length;++o)m[o].toLowerCase()===n.algorithm.toLowerCase()&&(n.algorithm=m[o]);if(-1===m.indexOf(n.algorithm))throw new Error('Algorithm "'+n.algorithm+'" not supported. supported values: '+m.join(", "));if(-1===f.indexOf(n.encoding)&&"passthrough"!==n.algorithm)throw new Error('Encoding "'+n.encoding+'" not supported. supported values: '+f.join(", "));return n}function y(e){if("function"==typeof e)return null!=/^function\s+\w*\s*\(\s*\)\s*{\s+\[native code\]\s+}$/i.exec(Function.prototype.toString.call(e))}function b(e,t,n){function o(e){return t.update?t.update(e,"utf8"):t.write(e,"utf8")}return n=n||[],{dispatch:function(t){return this["_"+(null===(t=e.replacer?e.replacer(t):t)?"null":typeof t)](t)},_object:function(t){var r,s=Object.prototype.toString.call(t),a=/\[object (.*)\]/i.exec(s);if(a=(a=a?a[1]:"unknown:["+s+"]").toLowerCase(),0<=(s=n.indexOf(t)))return this.dispatch("[CIRCULAR:"+s+"]");if(n.push(t),void 0!==i&&i.isBuffer&&i.isBuffer(t))return o("buffer:"),o(t);if("object"===a||"function"===a||"asyncfunction"===a)return s=Object.keys(t),e.unorderedObjects&&(s=s.sort()),!1===e.respectType||y(t)||s.splice(0,0,"prototype","__proto__","constructor"),e.excludeKeys&&(s=s.filter((function(t){return!e.excludeKeys(t)}))),o("object:"+s.length+":"),r=this,s.forEach((function(n){r.dispatch(n),o(":"),e.excludeValues||r.dispatch(t[n]),o(",")}));if(!this["_"+a]){if(e.ignoreUnknown)return o("["+a+"]");throw new Error('Unknown object type "'+a+'"')}this["_"+a](t)},_array:function(t,r){r=void 0!==r?r:!1!==e.unorderedArrays;var i=this;if(o("array:"+t.length+":"),!r||t.length<=1)return t.forEach((function(e){return i.dispatch(e)}));var s=[];return r=t.map((function(t){var o=new v,r=n.slice();return b(e,o,r).dispatch(t),s=s.concat(r.slice(n.length)),o.read().toString()})),n=n.concat(s),r.sort(),this._array(r,!1)},_date:function(e){return o("date:"+e.toJSON())},_symbol:function(e){return o("symbol:"+e.toString())},_error:function(e){return o("error:"+e.toString())},_boolean:function(e){return o("bool:"+e.toString())},_string:function(e){o("string:"+e.length+":"),o(e.toString())},_function:function(t){o("fn:"),y(t)?this.dispatch("[native]"):this.dispatch(t.toString()),!1!==e.respectFunctionNames&&this.dispatch("function-name:"+String(t.name)),e.respectFunctionProperties&&this._object(t)},_number:function(e){return o("number:"+e.toString())},_xml:function(e){return o("xml:"+e.toString())},_null:function(){return o("Null")},_undefined:function(){return o("Undefined")},_regexp:function(e){return o("regex:"+e.toString())},_uint8array:function(e){return o("uint8array:"),this.dispatch(Array.prototype.slice.call(e))},_uint8clampedarray:function(e){return o("uint8clampedarray:"),this.dispatch(Array.prototype.slice.call(e))},_int8array:function(e){return o("int8array:"),this.dispatch(Array.prototype.slice.call(e))},_uint16array:function(e){return o("uint16array:"),this.dispatch(Array.prototype.slice.call(e))},_int16array:function(e){return o("int16array:"),this.dispatch(Array.prototype.slice.call(e))},_uint32array:function(e){return o("uint32array:"),this.dispatch(Array.prototype.slice.call(e))},_int32array:function(e){return o("int32array:"),this.dispatch(Array.prototype.slice.call(e))},_float32array:function(e){return o("float32array:"),this.dispatch(Array.prototype.slice.call(e))},_float64array:function(e){return o("float64array:"),this.dispatch(Array.prototype.slice.call(e))},_arraybuffer:function(e){return o("arraybuffer:"),this.dispatch(new Uint8Array(e))},_url:function(e){return o("url:"+e.toString())},_map:function(t){return o("map:"),t=Array.from(t),this._array(t,!1!==e.unorderedSets)},_set:function(t){return o("set:"),t=Array.from(t),this._array(t,!1!==e.unorderedSets)},_file:function(e){return o("file:"),this.dispatch([e.name,e.size,e.type,e.lastModfied])},_blob:function(){if(e.ignoreUnknown)return o("[blob]");throw Error('Hashing Blob objects is currently not supported\n(see https://github.com/puleos/object-hash/issues/26)\nUse "options.replacer" or "options.ignoreUnknown"\n')},_domwindow:function(){return o("domwindow")},_bigint:function(e){return o("bigint:"+e.toString())},_process:function(){return o("process")},_timer:function(){return o("timer")},_pipe:function(){return o("pipe")},_tcp:function(){return o("tcp")},_udp:function(){return o("udp")},_tty:function(){return o("tty")},_statwatcher:function(){return o("statwatcher")},_securecontext:function(){return o("securecontext")},_connection:function(){return o("connection")},_zlib:function(){return o("zlib")},_context:function(){return o("context")},_nodescript:function(){return o("nodescript")},_httpparser:function(){return o("httpparser")},_dataview:function(){return o("dataview")},_signal:function(){return o("signal")},_fsevent:function(){return o("fsevent")},_tlswrap:function(){return o("tlswrap")}}}function v(){return{buf:"",write:function(e){this.buf+=e},end:function(e){this.buf+=e},read:function(){return this.buf}}}n.writeToStream=function(e,t,n){return void 0===n&&(n=t,t={}),b(t=g(e,t),n).dispatch(e)}}).call(this,e("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/fake_9a5aa49d.js","/")},{buffer:3,crypto:5,lYpoI2:11}],2:[function(e,t,n){(function(e,t,o,r,i,s,a,l,c){!function(e){"use strict";var t="undefined"!=typeof Uint8Array?Uint8Array:Array,n="+".charCodeAt(0),o="/".charCodeAt(0),r="0".charCodeAt(0),i="a".charCodeAt(0),s="A".charCodeAt(0),a="-".charCodeAt(0),l="_".charCodeAt(0);function c(e){return(e=e.charCodeAt(0))===n||e===a?62:e===o||e===l?63:e<r?-1:e<r+10?e-r+26+26:e<s+26?e-s:e<i+26?e-i+26:void 0}e.toByteArray=function(e){var n,o;if(0<e.length%4)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.length,i=(r="="===e.charAt(r-2)?2:"="===e.charAt(r-1)?1:0,new t(3*e.length/4-r)),s=0<r?e.length-4:e.length,a=0;function l(e){i[a++]=e}for(n=0;n<s;n+=4,0)l((16711680&(o=c(e.charAt(n))<<18|c(e.charAt(n+1))<<12|c(e.charAt(n+2))<<6|c(e.charAt(n+3))))>>16),l((65280&o)>>8),l(255&o);return 2==r?l(255&(o=c(e.charAt(n))<<2|c(e.charAt(n+1))>>4)):1==r&&(l((o=c(e.charAt(n))<<10|c(e.charAt(n+1))<<4|c(e.charAt(n+2))>>2)>>8&255),l(255&o)),i},e.fromByteArray=function(e){var t,n,o,r,i=e.length%3,s="";function a(e){return"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(e)}for(t=0,o=e.length-i;t<o;t+=3)s+=a((r=n=(e[t]<<16)+(e[t+1]<<8)+e[t+2])>>18&63)+a(r>>12&63)+a(r>>6&63)+a(63&r);switch(i){case 1:s=(s+=a((n=e[e.length-1])>>2))+a(n<<4&63)+"==";break;case 2:s=(s=(s+=a((n=(e[e.length-2]<<8)+e[e.length-1])>>10))+a(n>>4&63))+a(n<<2&63)+"="}return s}}(void 0===n?this.base64js={}:n)}).call(this,e("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/base64-js/lib/b64.js","/node_modules/gulp-browserify/node_modules/base64-js/lib")},{buffer:3,lYpoI2:11}],3:[function(e,t,n){(function(t,o,r,i,s,a,l,c,u){var h=e("base64-js"),d=e("ieee754");function r(e,t,n){if(!(this instanceof r))return new r(e,t,n);var o,i,s,a,l=typeof e;if("base64"===t&&"string"==l)for(e=(a=e).trim?a.trim():a.replace(/^\s+|\s+$/g,"");e.length%4!=0;)e+="=";if("number"==l)o=N(e);else if("string"==l)o=r.byteLength(e,t);else{if("object"!=l)throw new Error("First argument needs to be a number, array or string.");o=N(e.length)}if(r._useTypedArrays?i=r._augment(new Uint8Array(o)):((i=this).length=o,i._isBuffer=!0),r._useTypedArrays&&"number"==typeof e.byteLength)i._set(e);else if(I(a=e)||r.isBuffer(a)||a&&"object"==typeof a&&"number"==typeof a.length)for(s=0;s<o;s++)r.isBuffer(e)?i[s]=e.readUInt8(s):i[s]=e[s];else if("string"==l)i.write(e,0,t);else if("number"==l&&!r._useTypedArrays&&!n)for(s=0;s<o;s++)i[s]=0;return i}function p(e,t,n,o){var r;if(o||(B("boolean"==typeof n,"missing or invalid endian"),B(null!=t,"missing offset"),B(t+1<e.length,"Trying to read beyond buffer length")),!((o=e.length)<=t))return n?(r=e[t],t+1<o&&(r|=e[t+1]<<8)):(r=e[t]<<8,t+1<o&&(r|=e[t+1])),r}function m(e,t,n,o){var r;if(o||(B("boolean"==typeof n,"missing or invalid endian"),B(null!=t,"missing offset"),B(t+3<e.length,"Trying to read beyond buffer length")),!((o=e.length)<=t))return n?(t+2<o&&(r=e[t+2]<<16),t+1<o&&(r|=e[t+1]<<8),r|=e[t],t+3<o&&(r+=e[t+3]<<24>>>0)):(t+1<o&&(r=e[t+1]<<16),t+2<o&&(r|=e[t+2]<<8),t+3<o&&(r|=e[t+3]),r+=e[t]<<24>>>0),r}function f(e,t,n,o){if(o||(B("boolean"==typeof n,"missing or invalid endian"),B(null!=t,"missing offset"),B(t+1<e.length,"Trying to read beyond buffer length")),!(e.length<=t))return 32768&(o=p(e,t,n,!0))?-1*(65535-o+1):o}function g(e,t,n,o){if(o||(B("boolean"==typeof n,"missing or invalid endian"),B(null!=t,"missing offset"),B(t+3<e.length,"Trying to read beyond buffer length")),!(e.length<=t))return 2147483648&(o=m(e,t,n,!0))?-1*(4294967295-o+1):o}function y(e,t,n,o){return o||(B("boolean"==typeof n,"missing or invalid endian"),B(t+3<e.length,"Trying to read beyond buffer length")),d.read(e,t,n,23,4)}function b(e,t,n,o){return o||(B("boolean"==typeof n,"missing or invalid endian"),B(t+7<e.length,"Trying to read beyond buffer length")),d.read(e,t,n,52,8)}function v(e,t,n,o,r){if(r||(B(null!=t,"missing value"),B("boolean"==typeof o,"missing or invalid endian"),B(null!=n,"missing offset"),B(n+1<e.length,"trying to write beyond buffer length"),R(t,65535)),!((r=e.length)<=n))for(var i=0,s=Math.min(r-n,2);i<s;i++)e[n+i]=(t&255<<8*(o?i:1-i))>>>8*(o?i:1-i)}function C(e,t,n,o,r){if(r||(B(null!=t,"missing value"),B("boolean"==typeof o,"missing or invalid endian"),B(null!=n,"missing offset"),B(n+3<e.length,"trying to write beyond buffer length"),R(t,4294967295)),!((r=e.length)<=n))for(var i=0,s=Math.min(r-n,4);i<s;i++)e[n+i]=t>>>8*(o?i:3-i)&255}function x(e,t,n,o,r){r||(B(null!=t,"missing value"),B("boolean"==typeof o,"missing or invalid endian"),B(null!=n,"missing offset"),B(n+1<e.length,"Trying to write beyond buffer length"),$(t,32767,-32768)),e.length<=n||v(e,0<=t?t:65535+t+1,n,o,r)}function w(e,t,n,o,r){r||(B(null!=t,"missing value"),B("boolean"==typeof o,"missing or invalid endian"),B(null!=n,"missing offset"),B(n+3<e.length,"Trying to write beyond buffer length"),$(t,2147483647,-2147483648)),e.length<=n||C(e,0<=t?t:4294967295+t+1,n,o,r)}function A(e,t,n,o,r){r||(B(null!=t,"missing value"),B("boolean"==typeof o,"missing or invalid endian"),B(null!=n,"missing offset"),B(n+3<e.length,"Trying to write beyond buffer length"),D(t,34028234663852886e22,-34028234663852886e22)),e.length<=n||d.write(e,t,n,o,23,4)}function T(e,t,n,o,r){r||(B(null!=t,"missing value"),B("boolean"==typeof o,"missing or invalid endian"),B(null!=n,"missing offset"),B(n+7<e.length,"Trying to write beyond buffer length"),D(t,17976931348623157e292,-17976931348623157e292)),e.length<=n||d.write(e,t,n,o,52,8)}n.Buffer=r,n.SlowBuffer=r,n.INSPECT_MAX_BYTES=50,r.poolSize=8192,r._useTypedArrays=function(){try{var e=new ArrayBuffer(0),t=new Uint8Array(e);return t.foo=function(){return 42},42===t.foo()&&"function"==typeof t.subarray}catch(e){return!1}}(),r.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},r.isBuffer=function(e){return!(null==e||!e._isBuffer)},r.byteLength=function(e,t){var n;switch(e+="",t||"utf8"){case"hex":n=e.length/2;break;case"utf8":case"utf-8":n=P(e).length;break;case"ascii":case"binary":case"raw":n=e.length;break;case"base64":n=_(e).length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":n=2*e.length;break;default:throw new Error("Unknown encoding")}return n},r.concat=function(e,t){if(B(I(e),"Usage: Buffer.concat(list, [totalLength])\nlist should be an Array."),0===e.length)return new r(0);if(1===e.length)return e[0];if("number"!=typeof t)for(i=t=0;i<e.length;i++)t+=e[i].length;for(var n=new r(t),o=0,i=0;i<e.length;i++){var s=e[i];s.copy(n,o),o+=s.length}return n},r.prototype.write=function(e,t,n,o){isFinite(t)?isFinite(n)||(o=n,n=void 0):(c=o,o=t,t=n,n=c),t=Number(t)||0;var i,s,a,l,c=this.length-t;switch((!n||c<(n=Number(n)))&&(n=c),o=String(o||"utf8").toLowerCase()){case"hex":i=function(e,t,n,o){n=Number(n)||0;var i=e.length-n;(!o||i<(o=Number(o)))&&(o=i),B((i=t.length)%2==0,"Invalid hex string"),i/2<o&&(o=i/2);for(var s=0;s<o;s++){var a=parseInt(t.substr(2*s,2),16);B(!isNaN(a),"Invalid hex string"),e[n+s]=a}return r._charsWritten=2*s,s}(this,e,t,n);break;case"utf8":case"utf-8":s=this,a=t,l=n,i=r._charsWritten=L(P(e),s,a,l);break;case"ascii":case"binary":i=function(e,t,n,o){return r._charsWritten=L(function(e){for(var t=[],n=0;n<e.length;n++)t.push(255&e.charCodeAt(n));return t}(t),e,n,o)}(this,e,t,n);break;case"base64":s=this,a=t,l=n,i=r._charsWritten=L(_(e),s,a,l);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":i=function(e,t,n,o){return r._charsWritten=L(function(e){for(var t,n,o=[],r=0;r<e.length;r++)t=(n=e.charCodeAt(r))>>8,n%=256,o.push(n),o.push(t);return o}(t),e,n,o)}(this,e,t,n);break;default:throw new Error("Unknown encoding")}return i},r.prototype.toString=function(e,t,n){var o,r,i,s,a=this;if(e=String(e||"utf8").toLowerCase(),t=Number(t)||0,(n=void 0!==n?Number(n):a.length)===t)return"";switch(e){case"hex":o=function(e,t,n){var o=e.length;(!t||t<0)&&(t=0),(!n||n<0||o<n)&&(n=o);for(var r="",i=t;i<n;i++)r+=M(e[i]);return r}(a,t,n);break;case"utf8":case"utf-8":o=function(e,t,n){var o="",r="";n=Math.min(e.length,n);for(var i=t;i<n;i++)e[i]<=127?(o+=O(r)+String.fromCharCode(e[i]),r=""):r+="%"+e[i].toString(16);return o+O(r)}(a,t,n);break;case"ascii":case"binary":o=function(e,t,n){var o="";n=Math.min(e.length,n);for(var r=t;r<n;r++)o+=String.fromCharCode(e[r]);return o}(a,t,n);break;case"base64":r=a,s=n,o=0===(i=t)&&s===r.length?h.fromByteArray(r):h.fromByteArray(r.slice(i,s));break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":o=function(e,t,n){for(var o=e.slice(t,n),r="",i=0;i<o.length;i+=2)r+=String.fromCharCode(o[i]+256*o[i+1]);return r}(a,t,n);break;default:throw new Error("Unknown encoding")}return o},r.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},r.prototype.copy=function(e,t,n,o){if(t=t||0,(o=o||0===o?o:this.length)!==(n=n||0)&&0!==e.length&&0!==this.length){B(n<=o,"sourceEnd < sourceStart"),B(0<=t&&t<e.length,"targetStart out of bounds"),B(0<=n&&n<this.length,"sourceStart out of bounds"),B(0<=o&&o<=this.length,"sourceEnd out of bounds"),o>this.length&&(o=this.length);var i=(o=e.length-t<o-n?e.length-t+n:o)-n;if(i<100||!r._useTypedArrays)for(var s=0;s<i;s++)e[s+t]=this[s+n];else e._set(this.subarray(n,n+i),t)}},r.prototype.slice=function(e,t){var n=this.length;if(e=S(e,n,0),t=S(t,n,n),r._useTypedArrays)return r._augment(this.subarray(e,t));for(var o=t-e,i=new r(o,void 0,!0),s=0;s<o;s++)i[s]=this[s+e];return i},r.prototype.get=function(e){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(e)},r.prototype.set=function(e,t){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(e,t)},r.prototype.readUInt8=function(e,t){if(t||(B(null!=e,"missing offset"),B(e<this.length,"Trying to read beyond buffer length")),!(e>=this.length))return this[e]},r.prototype.readUInt16LE=function(e,t){return p(this,e,!0,t)},r.prototype.readUInt16BE=function(e,t){return p(this,e,!1,t)},r.prototype.readUInt32LE=function(e,t){return m(this,e,!0,t)},r.prototype.readUInt32BE=function(e,t){return m(this,e,!1,t)},r.prototype.readInt8=function(e,t){if(t||(B(null!=e,"missing offset"),B(e<this.length,"Trying to read beyond buffer length")),!(e>=this.length))return 128&this[e]?-1*(255-this[e]+1):this[e]},r.prototype.readInt16LE=function(e,t){return f(this,e,!0,t)},r.prototype.readInt16BE=function(e,t){return f(this,e,!1,t)},r.prototype.readInt32LE=function(e,t){return g(this,e,!0,t)},r.prototype.readInt32BE=function(e,t){return g(this,e,!1,t)},r.prototype.readFloatLE=function(e,t){return y(this,e,!0,t)},r.prototype.readFloatBE=function(e,t){return y(this,e,!1,t)},r.prototype.readDoubleLE=function(e,t){return b(this,e,!0,t)},r.prototype.readDoubleBE=function(e,t){return b(this,e,!1,t)},r.prototype.writeUInt8=function(e,t,n){n||(B(null!=e,"missing value"),B(null!=t,"missing offset"),B(t<this.length,"trying to write beyond buffer length"),R(e,255)),t>=this.length||(this[t]=e)},r.prototype.writeUInt16LE=function(e,t,n){v(this,e,t,!0,n)},r.prototype.writeUInt16BE=function(e,t,n){v(this,e,t,!1,n)},r.prototype.writeUInt32LE=function(e,t,n){C(this,e,t,!0,n)},r.prototype.writeUInt32BE=function(e,t,n){C(this,e,t,!1,n)},r.prototype.writeInt8=function(e,t,n){n||(B(null!=e,"missing value"),B(null!=t,"missing offset"),B(t<this.length,"Trying to write beyond buffer length"),$(e,127,-128)),t>=this.length||(0<=e?this.writeUInt8(e,t,n):this.writeUInt8(255+e+1,t,n))},r.prototype.writeInt16LE=function(e,t,n){x(this,e,t,!0,n)},r.prototype.writeInt16BE=function(e,t,n){x(this,e,t,!1,n)},r.prototype.writeInt32LE=function(e,t,n){w(this,e,t,!0,n)},r.prototype.writeInt32BE=function(e,t,n){w(this,e,t,!1,n)},r.prototype.writeFloatLE=function(e,t,n){A(this,e,t,!0,n)},r.prototype.writeFloatBE=function(e,t,n){A(this,e,t,!1,n)},r.prototype.writeDoubleLE=function(e,t,n){T(this,e,t,!0,n)},r.prototype.writeDoubleBE=function(e,t,n){T(this,e,t,!1,n)},r.prototype.fill=function(e,t,n){if(t=t||0,n=n||this.length,B("number"==typeof(e="string"==typeof(e=e||0)?e.charCodeAt(0):e)&&!isNaN(e),"value is not a number"),B(t<=n,"end < start"),n!==t&&0!==this.length){B(0<=t&&t<this.length,"start out of bounds"),B(0<=n&&n<=this.length,"end out of bounds");for(var o=t;o<n;o++)this[o]=e}},r.prototype.inspect=function(){for(var e=[],t=this.length,o=0;o<t;o++)if(e[o]=M(this[o]),o===n.INSPECT_MAX_BYTES){e[o+1]="...";break}return"<Buffer "+e.join(" ")+">"},r.prototype.toArrayBuffer=function(){if("undefined"==typeof Uint8Array)throw new Error("Buffer.toArrayBuffer not supported in this browser");if(r._useTypedArrays)return new r(this).buffer;for(var e=new Uint8Array(this.length),t=0,n=e.length;t<n;t+=1)e[t]=this[t];return e.buffer};var E=r.prototype;function S(e,t,n){return"number"!=typeof e?n:t<=(e=~~e)?t:0<=e||0<=(e+=t)?e:0}function N(e){return(e=~~Math.ceil(+e))<0?0:e}function I(e){return(Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)})(e)}function M(e){return e<16?"0"+e.toString(16):e.toString(16)}function P(e){for(var t=[],n=0;n<e.length;n++){var o=e.charCodeAt(n);if(o<=127)t.push(e.charCodeAt(n));else for(var r=n,i=(55296<=o&&o<=57343&&n++,encodeURIComponent(e.slice(r,n+1)).substr(1).split("%")),s=0;s<i.length;s++)t.push(parseInt(i[s],16))}return t}function _(e){return h.toByteArray(e)}function L(e,t,n,o){for(var r=0;r<o&&!(r+n>=t.length||r>=e.length);r++)t[r+n]=e[r];return r}function O(e){try{return decodeURIComponent(e)}catch(e){return String.fromCharCode(65533)}}function R(e,t){B("number"==typeof e,"cannot write a non-number as a number"),B(0<=e,"specified a negative value for writing an unsigned value"),B(e<=t,"value is larger than maximum value for type"),B(Math.floor(e)===e,"value has a fractional component")}function $(e,t,n){B("number"==typeof e,"cannot write a non-number as a number"),B(e<=t,"value larger than maximum allowed value"),B(n<=e,"value smaller than minimum allowed value"),B(Math.floor(e)===e,"value has a fractional component")}function D(e,t,n){B("number"==typeof e,"cannot write a non-number as a number"),B(e<=t,"value larger than maximum allowed value"),B(n<=e,"value smaller than minimum allowed value")}function B(e,t){if(!e)throw new Error(t||"Failed assertion")}r._augment=function(e){return e._isBuffer=!0,e._get=e.get,e._set=e.set,e.get=E.get,e.set=E.set,e.write=E.write,e.toString=E.toString,e.toLocaleString=E.toString,e.toJSON=E.toJSON,e.copy=E.copy,e.slice=E.slice,e.readUInt8=E.readUInt8,e.readUInt16LE=E.readUInt16LE,e.readUInt16BE=E.readUInt16BE,e.readUInt32LE=E.readUInt32LE,e.readUInt32BE=E.readUInt32BE,e.readInt8=E.readInt8,e.readInt16LE=E.readInt16LE,e.readInt16BE=E.readInt16BE,e.readInt32LE=E.readInt32LE,e.readInt32BE=E.readInt32BE,e.readFloatLE=E.readFloatLE,e.readFloatBE=E.readFloatBE,e.readDoubleLE=E.readDoubleLE,e.readDoubleBE=E.readDoubleBE,e.writeUInt8=E.writeUInt8,e.writeUInt16LE=E.writeUInt16LE,e.writeUInt16BE=E.writeUInt16BE,e.writeUInt32LE=E.writeUInt32LE,e.writeUInt32BE=E.writeUInt32BE,e.writeInt8=E.writeInt8,e.writeInt16LE=E.writeInt16LE,e.writeInt16BE=E.writeInt16BE,e.writeInt32LE=E.writeInt32LE,e.writeInt32BE=E.writeInt32BE,e.writeFloatLE=E.writeFloatLE,e.writeFloatBE=E.writeFloatBE,e.writeDoubleLE=E.writeDoubleLE,e.writeDoubleBE=E.writeDoubleBE,e.fill=E.fill,e.inspect=E.inspect,e.toArrayBuffer=E.toArrayBuffer,e}}).call(this,e("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/buffer/index.js","/node_modules/gulp-browserify/node_modules/buffer")},{"base64-js":2,buffer:3,ieee754:10,lYpoI2:11}],4:[function(e,t,n){(function(n,o,r,i,s,a,l,c,u){r=e("buffer").Buffer;var h=new r(4);h.fill(0),t.exports={hash:function(e,t,n,o){for(var i=t(function(e,t){e.length%4!=0&&(n=e.length+(4-e.length%4),e=r.concat([e,h],n));for(var n,o=[],i=t?e.readInt32BE:e.readInt32LE,s=0;s<e.length;s+=4)o.push(i.call(e,s));return o}(e=r.isBuffer(e)?e:new r(e),o),8*e.length),s=(t=o,new r(n)),a=t?s.writeInt32BE:s.writeInt32LE,l=0;l<i.length;l++)a.call(s,i[l],4*l,!0);return s}}}).call(this,e("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/helpers.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{buffer:3,lYpoI2:11}],5:[function(e,t,n){(function(t,o,r,i,s,a,l,c,u){r=e("buffer").Buffer;var h=e("./sha"),d=e("./sha256"),p=e("./rng"),m={sha1:h,sha256:d,md5:e("./md5")},f=64,g=new r(f);function y(e,t){var n=m[e=e||"sha1"],o=[];return n||b("algorithm:",e,"is not yet supported"),{update:function(e){return r.isBuffer(e)||(e=new r(e)),o.push(e),e.length,this},digest:function(e){var i=r.concat(o);return i=t?function(e,t,n){r.isBuffer(t)||(t=new r(t)),r.isBuffer(n)||(n=new r(n)),t.length>f?t=e(t):t.length<f&&(t=r.concat([t,g],f));for(var o=new r(f),i=new r(f),s=0;s<f;s++)o[s]=54^t[s],i[s]=92^t[s];return n=e(r.concat([o,n])),e(r.concat([i,n]))}(n,t,i):n(i),o=null,e?i.toString(e):i}}}function b(){var e=[].slice.call(arguments).join(" ");throw new Error([e,"we accept pull requests","http://github.com/dominictarr/crypto-browserify"].join("\n"))}g.fill(0),n.createHash=function(e){return y(e)},n.createHmac=y,n.randomBytes=function(e,t){if(!t||!t.call)return new r(p(e));try{t.call(this,void 0,new r(p(e)))}catch(e){t(e)}};var v,C=["createCredentials","createCipher","createCipheriv","createDecipher","createDecipheriv","createSign","createVerify","createDiffieHellman","pbkdf2"],x=function(e){n[e]=function(){b("sorry,",e,"is not implemented yet")}};for(v in C)x(C[v])}).call(this,e("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/index.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./md5":6,"./rng":7,"./sha":8,"./sha256":9,buffer:3,lYpoI2:11}],6:[function(e,t,n){(function(n,o,r,i,s,a,l,c,u){var h=e("./helpers");function d(e,t){e[t>>5]|=128<<t%32,e[14+(t+64>>>9<<4)]=t;for(var n=1732584193,o=-271733879,r=-1732584194,i=271733878,s=0;s<e.length;s+=16){var a=n,l=o,c=r,u=i;n=m(n,o,r,i,e[s+0],7,-680876936),i=m(i,n,o,r,e[s+1],12,-389564586),r=m(r,i,n,o,e[s+2],17,606105819),o=m(o,r,i,n,e[s+3],22,-1044525330),n=m(n,o,r,i,e[s+4],7,-176418897),i=m(i,n,o,r,e[s+5],12,1200080426),r=m(r,i,n,o,e[s+6],17,-1473231341),o=m(o,r,i,n,e[s+7],22,-45705983),n=m(n,o,r,i,e[s+8],7,1770035416),i=m(i,n,o,r,e[s+9],12,-1958414417),r=m(r,i,n,o,e[s+10],17,-42063),o=m(o,r,i,n,e[s+11],22,-1990404162),n=m(n,o,r,i,e[s+12],7,1804603682),i=m(i,n,o,r,e[s+13],12,-40341101),r=m(r,i,n,o,e[s+14],17,-1502002290),n=f(n,o=m(o,r,i,n,e[s+15],22,1236535329),r,i,e[s+1],5,-165796510),i=f(i,n,o,r,e[s+6],9,-1069501632),r=f(r,i,n,o,e[s+11],14,643717713),o=f(o,r,i,n,e[s+0],20,-373897302),n=f(n,o,r,i,e[s+5],5,-701558691),i=f(i,n,o,r,e[s+10],9,38016083),r=f(r,i,n,o,e[s+15],14,-660478335),o=f(o,r,i,n,e[s+4],20,-405537848),n=f(n,o,r,i,e[s+9],5,568446438),i=f(i,n,o,r,e[s+14],9,-1019803690),r=f(r,i,n,o,e[s+3],14,-187363961),o=f(o,r,i,n,e[s+8],20,1163531501),n=f(n,o,r,i,e[s+13],5,-1444681467),i=f(i,n,o,r,e[s+2],9,-51403784),r=f(r,i,n,o,e[s+7],14,1735328473),n=g(n,o=f(o,r,i,n,e[s+12],20,-1926607734),r,i,e[s+5],4,-378558),i=g(i,n,o,r,e[s+8],11,-2022574463),r=g(r,i,n,o,e[s+11],16,1839030562),o=g(o,r,i,n,e[s+14],23,-35309556),n=g(n,o,r,i,e[s+1],4,-1530992060),i=g(i,n,o,r,e[s+4],11,1272893353),r=g(r,i,n,o,e[s+7],16,-155497632),o=g(o,r,i,n,e[s+10],23,-1094730640),n=g(n,o,r,i,e[s+13],4,681279174),i=g(i,n,o,r,e[s+0],11,-358537222),r=g(r,i,n,o,e[s+3],16,-722521979),o=g(o,r,i,n,e[s+6],23,76029189),n=g(n,o,r,i,e[s+9],4,-640364487),i=g(i,n,o,r,e[s+12],11,-421815835),r=g(r,i,n,o,e[s+15],16,530742520),n=y(n,o=g(o,r,i,n,e[s+2],23,-995338651),r,i,e[s+0],6,-198630844),i=y(i,n,o,r,e[s+7],10,1126891415),r=y(r,i,n,o,e[s+14],15,-1416354905),o=y(o,r,i,n,e[s+5],21,-57434055),n=y(n,o,r,i,e[s+12],6,1700485571),i=y(i,n,o,r,e[s+3],10,-1894986606),r=y(r,i,n,o,e[s+10],15,-1051523),o=y(o,r,i,n,e[s+1],21,-2054922799),n=y(n,o,r,i,e[s+8],6,1873313359),i=y(i,n,o,r,e[s+15],10,-30611744),r=y(r,i,n,o,e[s+6],15,-1560198380),o=y(o,r,i,n,e[s+13],21,1309151649),n=y(n,o,r,i,e[s+4],6,-145523070),i=y(i,n,o,r,e[s+11],10,-1120210379),r=y(r,i,n,o,e[s+2],15,718787259),o=y(o,r,i,n,e[s+9],21,-343485551),n=b(n,a),o=b(o,l),r=b(r,c),i=b(i,u)}return Array(n,o,r,i)}function p(e,t,n,o,r,i){return b((t=b(b(t,e),b(o,i)))<<r|t>>>32-r,n)}function m(e,t,n,o,r,i,s){return p(t&n|~t&o,e,t,r,i,s)}function f(e,t,n,o,r,i,s){return p(t&o|n&~o,e,t,r,i,s)}function g(e,t,n,o,r,i,s){return p(t^n^o,e,t,r,i,s)}function y(e,t,n,o,r,i,s){return p(n^(t|~o),e,t,r,i,s)}function b(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}t.exports=function(e){return h.hash(e,d,16)}}).call(this,e("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/md5.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],7:[function(e,t,n){(function(e,n,o,r,i,s,a,l,c){t.exports=function(e){for(var t,n=new Array(e),o=0;o<e;o++)!(3&o)&&(t=4294967296*Math.random()),n[o]=t>>>((3&o)<<3)&255;return n}}).call(this,e("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/rng.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{buffer:3,lYpoI2:11}],8:[function(e,t,n){(function(n,o,r,i,s,a,l,c,u){var h=e("./helpers");function d(e,t){e[t>>5]|=128<<24-t%32,e[15+(t+64>>9<<4)]=t;for(var n,o,r,i=Array(80),s=1732584193,a=-271733879,l=-1732584194,c=271733878,u=-1009589776,h=0;h<e.length;h+=16){for(var d=s,f=a,g=l,y=c,b=u,v=0;v<80;v++){i[v]=v<16?e[h+v]:m(i[v-3]^i[v-8]^i[v-14]^i[v-16],1);var C=p(p(m(s,5),(C=a,o=l,r=c,(n=v)<20?C&o|~C&r:!(n<40)&&n<60?C&o|C&r|o&r:C^o^r)),p(p(u,i[v]),(n=v)<20?1518500249:n<40?1859775393:n<60?-1894007588:-899497514));u=c,c=l,l=m(a,30),a=s,s=C}s=p(s,d),a=p(a,f),l=p(l,g),c=p(c,y),u=p(u,b)}return Array(s,a,l,c,u)}function p(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function m(e,t){return e<<t|e>>>32-t}t.exports=function(e){return h.hash(e,d,20,!0)}}).call(this,e("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/sha.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],9:[function(e,t,n){(function(n,o,r,i,s,a,l,c,u){function h(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function d(e,t){var n,o=new Array(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),r=new Array(1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225),i=new Array(64);e[t>>5]|=128<<24-t%32,e[15+(t+64>>9<<4)]=t;for(var s,a,l=0;l<e.length;l+=16){for(var c=r[0],u=r[1],d=r[2],p=r[3],g=r[4],y=r[5],b=r[6],v=r[7],C=0;C<64;C++)i[C]=C<16?e[C+l]:h(h(h((a=i[C-2],m(a,17)^m(a,19)^f(a,10)),i[C-7]),(a=i[C-15],m(a,7)^m(a,18)^f(a,3))),i[C-16]),n=h(h(h(h(v,m(a=g,6)^m(a,11)^m(a,25)),g&y^~g&b),o[C]),i[C]),s=h(m(s=c,2)^m(s,13)^m(s,22),c&u^c&d^u&d),v=b,b=y,y=g,g=h(p,n),p=d,d=u,u=c,c=h(n,s);r[0]=h(c,r[0]),r[1]=h(u,r[1]),r[2]=h(d,r[2]),r[3]=h(p,r[3]),r[4]=h(g,r[4]),r[5]=h(y,r[5]),r[6]=h(b,r[6]),r[7]=h(v,r[7])}return r}var p=e("./helpers"),m=function(e,t){return e>>>t|e<<32-t},f=function(e,t){return e>>>t};t.exports=function(e){return p.hash(e,d,32,!0)}}).call(this,e("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/sha256.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],10:[function(e,t,n){(function(e,t,o,r,i,s,a,l,c){n.read=function(e,t,n,o,r){var i,s,a=8*r-o-1,l=(1<<a)-1,c=l>>1,u=-7,h=n?r-1:0,d=n?-1:1;for(r=e[t+h],h+=d,i=r&(1<<-u)-1,r>>=-u,u+=a;0<u;i=256*i+e[t+h],h+=d,u-=8);for(s=i&(1<<-u)-1,i>>=-u,u+=o;0<u;s=256*s+e[t+h],h+=d,u-=8);if(0===i)i=1-c;else{if(i===l)return s?NaN:1/0*(r?-1:1);s+=Math.pow(2,o),i-=c}return(r?-1:1)*s*Math.pow(2,i-o)},n.write=function(e,t,n,o,r,i){var s,a,l=8*i-r-1,c=(1<<l)-1,u=c>>1,h=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,d=o?0:i-1,p=o?1:-1;for(i=t<0||0===t&&1/t<0?1:0,t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=c):(s=Math.floor(Math.log(t)/Math.LN2),t*(o=Math.pow(2,-s))<1&&(s--,o*=2),2<=(t+=1<=s+u?h/o:h*Math.pow(2,1-u))*o&&(s++,o/=2),c<=s+u?(a=0,s=c):1<=s+u?(a=(t*o-1)*Math.pow(2,r),s+=u):(a=t*Math.pow(2,u-1)*Math.pow(2,r),s=0));8<=r;e[n+d]=255&a,d+=p,a/=256,r-=8);for(s=s<<r|a,l+=r;0<l;e[n+d]=255&s,d+=p,s/=256,l-=8);e[n+d-p]|=128*i}}).call(this,e("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/ieee754/index.js","/node_modules/gulp-browserify/node_modules/ieee754")},{buffer:3,lYpoI2:11}],11:[function(e,t,n){(function(e,n,o,r,i,s,a,l,c){var u,h,d;function p(){}(e=t.exports={}).nextTick=(h="undefined"!=typeof window&&window.setImmediate,d="undefined"!=typeof window&&window.postMessage&&window.addEventListener,h?function(e){return window.setImmediate(e)}:d?(u=[],window.addEventListener("message",(function(e){var t=e.source;t!==window&&null!==t||"process-tick"!==e.data||(e.stopPropagation(),0<u.length&&u.shift()())}),!0),function(e){u.push(e),window.postMessage("process-tick","*")}):function(e){setTimeout(e,0)}),e.title="browser",e.browser=!0,e.env={},e.argv=[],e.on=p,e.addListener=p,e.once=p,e.off=p,e.removeListener=p,e.removeAllListeners=p,e.emit=p,e.binding=function(e){throw new Error("process.binding is not supported")},e.cwd=function(){return"/"},e.chdir=function(e){throw new Error("process.chdir is not supported")}}).call(this,e("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/process/browser.js","/node_modules/gulp-browserify/node_modules/process")},{buffer:3,lYpoI2:11}]},{},[1])(1)},9146:(e,t)=>{"use strict";var n;!function(){var o=t||{}||this||window;void 0===(n=function(){return o}.apply(t,[]))||(e.exports=n),o.default=o;var r="http://www.w3.org/2000/xmlns/",i="http://www.w3.org/2000/svg",s=/url\(["']?(.+?)["']?\)/,a={woff2:"font/woff2",woff:"font/woff",otf:"application/x-font-opentype",ttf:"application/x-font-ttf",eot:"application/vnd.ms-fontobject",sfnt:"application/font-sfnt",svg:"image/svg+xml"},l=function(e){return e instanceof HTMLElement||e instanceof SVGElement},c=function(e){if(!l(e))throw new Error("an HTMLElement or SVGElement is required; got "+e)},u=function(e){return new Promise((function(t,n){l(e)?t(e):n(new Error("an HTMLElement or SVGElement is required; got "+e))}))},h=function(e,t,n){var o=e.viewBox&&e.viewBox.baseVal&&e.viewBox.baseVal[n]||null!==t.getAttribute(n)&&!t.getAttribute(n).match(/%$/)&&parseInt(t.getAttribute(n))||e.getBoundingClientRect()[n]||parseInt(t.style[n])||parseInt(window.getComputedStyle(e).getPropertyValue(n));return null==o||isNaN(parseFloat(o))?0:o},d=function(e){for(var t=window.atob(e.split(",")[1]),n=e.split(",")[0].split(":")[1].split(";")[0],o=new ArrayBuffer(t.length),r=new Uint8Array(o),i=0;i<t.length;i++)r[i]=t.charCodeAt(i);return new Blob([o],{type:n})},p={},m=null,f=function(e,t){var n=t||{},o=n.selectorRemap,r=n.modifyStyle,i=n.modifyCss,l=n.fonts,c=n.excludeUnusedCss,u=i||function(e,t){return(o?o(e):e)+"{"+(r?r(t):t)+"}\n"},h=[],d=void 0===l,f=l||[];return(m||(m=Array.from(document.styleSheets).map((function(e){try{return{rules:e.cssRules,href:e.href}}catch(t){return console.warn("Stylesheet could not be loaded: "+e.href,t),{}}})))).forEach((function(t){var n=t.rules,o=t.href;n&&Array.from(n).forEach((function(t){if(void 0!==t.style)if(function(e,t){if(t)try{return e.querySelector(t)||e.parentNode&&e.parentNode.querySelector(t)}catch(e){console.warn('Invalid CSS selector "'+t+'"',e)}}(e,t.selectorText))h.push(u(t.selectorText,t.style.cssText));else if(d&&t.cssText.match(/^@font-face/)){var n=function(e,t){var n=e.cssText.match(s),o=n&&n[1]||"";if(o&&!o.match(/^data:/)&&"about:blank"!==o){var r,i,l=o.startsWith("../")?t+"/../"+o:o.startsWith("./")?t+"/."+o:o;return{text:e.cssText,format:(r=l,i=Object.keys(a).filter((function(e){return r.indexOf("."+e)>0})).map((function(e){return a[e]})),i?i[0]:(console.error("Unknown font format for "+r+". Fonts may not be working correctly."),"application/octet-stream")),url:l}}}(t,o);n&&f.push(n)}else c||h.push(t.cssText)}))})),function(e){return Promise.all(e.map((function(e){return new Promise((function(t,n){if(p[e.url])return t(p[e.url]);var o=new XMLHttpRequest;o.addEventListener("load",(function(){var n=function(e){for(var t="",n=new Uint8Array(e),o=0;o<n.byteLength;o++)t+=String.fromCharCode(n[o]);return window.btoa(t)}(o.response),r=e.text.replace(s,'url("data:'+e.format+";base64,"+n+'")')+"\n";p[e.url]=r,t(r)})),o.addEventListener("error",(function(n){console.warn("Failed to load font from: "+e.url,n),p[e.url]=null,t(null)})),o.addEventListener("abort",(function(n){console.warn("Aborted loading font from: "+e.url,n),t(null)})),o.open("GET",e.url),o.responseType="arraybuffer",o.send()}))}))).then((function(e){return e.filter((function(e){return e})).join("")}))}(f).then((function(e){return h.join("\n")+e}))},g=function(){if(!navigator.msSaveOrOpenBlob&&!("download"in document.createElement("a")))return{popup:window.open()}};o.prepareSvg=function(e,t,n){c(e);var o=t||{},s=o.left,a=void 0===s?0:s,l=o.top,u=void 0===l?0:l,d=o.width,p=o.height,m=o.scale,g=void 0===m?1:m,y=o.responsive,b=void 0!==y&&y,v=o.excludeCss,C=void 0!==v&&v;return function(e){return Promise.all(Array.from(e.querySelectorAll("image")).map((function(e){var t,n=e.getAttributeNS("http://www.w3.org/1999/xlink","href")||e.getAttribute("href");return n?((t=n)&&0===t.lastIndexOf("http",0)&&-1===t.lastIndexOf(window.location.host)&&(n+=(-1===n.indexOf("?")?"?":"&")+"t="+(new Date).valueOf()),new Promise((function(t,o){var r=document.createElement("canvas"),i=new Image;i.crossOrigin="anonymous",i.src=n,i.onerror=function(){return o(new Error("Could not load "+n))},i.onload=function(){r.width=i.width,r.height=i.height,r.getContext("2d").drawImage(i,0,0),e.setAttributeNS("http://www.w3.org/1999/xlink","href",r.toDataURL("image/png")),t(!0)}}))):Promise.resolve(null)})))}(e).then((function(){var o=e.cloneNode(!0);o.style.backgroundColor=(t||{}).backgroundColor||e.style.backgroundColor;var s=function(e,t,n,o){if("svg"===e.tagName)return{width:n||h(e,t,"width"),height:o||h(e,t,"height")};if(e.getBBox){var r=e.getBBox(),i=r.x,s=r.y;return{width:i+r.width,height:s+r.height}}}(e,o,d,p),l=s.width,c=s.height;if("svg"!==e.tagName){if(!e.getBBox)return void console.error("Attempted to render non-SVG element",e);null!=o.getAttribute("transform")&&o.setAttribute("transform",o.getAttribute("transform").replace(/translate\(.*?\)/,""));var m=document.createElementNS("http://www.w3.org/2000/svg","svg");m.appendChild(o),o=m}if(o.setAttribute("version","1.1"),o.setAttribute("viewBox",[a,u,l,c].join(" ")),o.getAttribute("xmlns")||o.setAttributeNS(r,"xmlns",i),o.getAttribute("xmlns:xlink")||o.setAttributeNS(r,"xmlns:xlink","http://www.w3.org/1999/xlink"),b?(o.removeAttribute("width"),o.removeAttribute("height"),o.setAttribute("preserveAspectRatio","xMinYMin meet")):(o.setAttribute("width",l*g),o.setAttribute("height",c*g)),Array.from(o.querySelectorAll("foreignObject > *")).forEach((function(e){e.setAttributeNS(r,"xmlns","svg"===e.tagName?i:"http://www.w3.org/1999/xhtml")})),!C)return f(e,t).then((function(e){var t=document.createElement("style");t.setAttribute("type","text/css"),t.innerHTML="<![CDATA[\n"+e+"\n]]>";var r=document.createElement("defs");r.appendChild(t),o.insertBefore(r,o.firstChild);var i=document.createElement("div");i.appendChild(o);var s=i.innerHTML.replace(/NS\d+:href/gi,'xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href');if("function"!=typeof n)return{src:s,width:l,height:c};n(s,l,c)}));var y=document.createElement("div");y.appendChild(o);var v=y.innerHTML;if("function"!=typeof n)return{src:v,width:l,height:c};n(v,l,c)}))},o.svgAsDataUri=function(e,t,n){return c(e),o.prepareSvg(e,t).then((function(e){var t=e.src,o=e.width,r=e.height,i="data:image/svg+xml;base64,"+window.btoa(decodeURIComponent(encodeURIComponent('<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [<!ENTITY nbsp "&#160;">]>'+t).replace(/%([0-9A-F]{2})/g,(function(e,t){var n=String.fromCharCode("0x"+t);return"%"===n?"%25":n}))));return"function"==typeof n&&n(i,o,r),i}))},o.svgAsPngUri=function(e,t,n){c(e);var r=t||{},i=r.encoderType,s=void 0===i?"image/png":i,a=r.encoderOptions,l=void 0===a?.8:a,u=r.canvg,h=function(e){var t=e.src,o=e.width,r=e.height,i=document.createElement("canvas"),a=i.getContext("2d"),c=window.devicePixelRatio||1;i.width=o*c,i.height=r*c,i.style.width=i.width+"px",i.style.height=i.height+"px",a.setTransform(c,0,0,c,0,0),u?u(i,t):a.drawImage(t,0,0);var h=void 0;try{h=i.toDataURL(s,l)}catch(e){if("undefined"!=typeof SecurityError&&e instanceof SecurityError||"SecurityError"===e.name)return void console.error("Rendered SVG images cannot be downloaded in this browser.");throw e}return"function"==typeof n&&n(h,i.width,i.height),Promise.resolve(h)};return u?o.prepareSvg(e,t).then(h):o.svgAsDataUri(e,t).then((function(e){return new Promise((function(t,n){var o=new Image;o.onload=function(){return t(h({src:o,width:o.width,height:o.height}))},o.onerror=function(){n("There was an error loading the data URI as an image on the following SVG\n"+window.atob(e.slice(26))+"Open the following link to see browser's diagnosis\n"+e)},o.src=e}))}))},o.download=function(e,t,n){if(navigator.msSaveOrOpenBlob)navigator.msSaveOrOpenBlob(d(t),e);else{var o=document.createElement("a");if("download"in o){o.download=e,o.style.display="none",document.body.appendChild(o);try{var r=d(t),i=URL.createObjectURL(r);o.href=i,o.onclick=function(){return requestAnimationFrame((function(){return URL.revokeObjectURL(i)}))}}catch(e){console.error(e),console.warn("Error while getting object URL. Falling back to string URL."),o.href=t}o.click(),document.body.removeChild(o)}else n&&n.popup&&(n.popup.document.title=e,n.popup.location.replace(t))}},o.saveSvg=function(e,t,n){var r=g();return u(e).then((function(e){return o.svgAsDataUri(e,n||{})})).then((function(e){return o.download(t,e,r)}))},o.saveSvgAsPng=function(e,t,n){var r=g();return u(e).then((function(e){return o.svgAsPngUri(e,n||{})})).then((function(e){return o.download(t,e,r)}))}}()},5072:e=>{"use strict";var t=[];function n(e){for(var n=-1,o=0;o<t.length;o++)if(t[o].identifier===e){n=o;break}return n}function o(e,o){for(var i={},s=[],a=0;a<e.length;a++){var l=e[a],c=o.base?l[0]+o.base:l[0],u=i[c]||0,h="".concat(c," ").concat(u);i[c]=u+1;var d=n(h),p={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==d)t[d].references++,t[d].updater(p);else{var m=r(p,o);o.byIndex=a,t.splice(a,0,{identifier:h,updater:m,references:1})}s.push(h)}return s}function r(e,t){var n=t.domAPI(t);return n.update(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap&&t.supports===e.supports&&t.layer===e.layer)return;n.update(e=t)}else n.remove()}}e.exports=function(e,r){var i=o(e=e||[],r=r||{});return function(e){e=e||[];for(var s=0;s<i.length;s++){var a=n(i[s]);t[a].references--}for(var l=o(e,r),c=0;c<i.length;c++){var u=n(i[c]);0===t[u].references&&(t[u].updater(),t.splice(u,1))}i=l}}},7659:e=>{"use strict";var t={};e.exports=function(e,n){var o=function(e){if(void 0===t[e]){var n=document.querySelector(e);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(e){n=null}t[e]=n}return t[e]}(e);if(!o)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");o.appendChild(n)}},540:e=>{"use strict";e.exports=function(e){var t=document.createElement("style");return e.setAttributes(t,e.attributes),e.insert(t,e.options),t}},5056:(e,t,n)=>{"use strict";e.exports=function(e){var t=n.nc;t&&e.setAttribute("nonce",t)}},7825:e=>{"use strict";e.exports=function(e){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var t=e.insertStyleElement(e);return{update:function(n){!function(e,t,n){var o="";n.supports&&(o+="@supports (".concat(n.supports,") {")),n.media&&(o+="@media ".concat(n.media," {"));var r=void 0!==n.layer;r&&(o+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),o+=n.css,r&&(o+="}"),n.media&&(o+="}"),n.supports&&(o+="}");var i=n.sourceMap;i&&"undefined"!=typeof btoa&&(o+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(i))))," */")),t.styleTagTransform(o,e,t.options)}(t,e,n)},remove:function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(t)}}}},1113:e=>{"use strict";e.exports=function(e,t){if(t.styleSheet)t.styleSheet.cssText=e;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(e))}}},6686:(e,t,n)=>{"use strict";n.d(t,{AL:()=>o,NO:()=>r});const o=["A","G","C","U"];var r;!function(e){e.HELM="HELM",e.AXOLABS="Axolabs"}(r||(r={}))},9537:(e,t,n)=>{"use strict";n.d(t,{iL:()=>i,q7:()=>r,ti:()=>o});const o={NUCLEOSIDE:"nucleoside",LINKAGE:"phosphateBackbone"},r="p",i="<?>"},3480:(e,t,n)=>{"use strict";n.d(t,{C6:()=>l,Hs:()=>a,OT:()=>c,bD:()=>s});var o=n(6686),r=n(5067),i=n(9537);function s(e,t,n,r){const i=Object.keys(r.jsonData.codesToHelmDict).concat([o.NO.HELM]);if(!e||-1!==t&&n!==o.NO.HELM)return{};if(!i.includes(n))throw new Error(`${n} format is not supported by SequenceTranslator`);const s=i.filter((e=>e!=n)).sort(((e,t)=>e.localeCompare(t))),l=r.createFormatConverter(e,n),c=Object.fromEntries(s.map((e=>{let t;try{t=l.convertTo(e)}catch{t=null}return[e,t]})).filter((([e,t])=>t))),u=a(n===o.NO.HELM?e:c[o.NO.HELM],r.monomerLibWrapper);return u&&(c.Nucleotides=u),c}function a(e,t){const n=new RegExp("\\([^()]*\\)","g"),r=e.match(n);return r?r.map((e=>{const n=e.replace(/[\[\]()]/g,"");return o.AL.includes(n)?n:t.getNaturalAnalogBySymbol(n)})).map((e=>e||i.iL)).join(""):null}function l(e,t,n,i){const s=i.createFormatConverter(e,t);return n===r.qP?a(s.convertTo(o.NO.HELM),i.monomerLibWrapper):s.convertTo(n)}function c(e){return Object.keys(e.jsonData.codesToHelmDict).concat([o.NO.HELM,r.qP]).sort()}},5067:(e,t,n)=>{"use strict";n.d(t,{U_:()=>r,n_:()=>o,qP:()=>i});const o="Copied",r="Copy sequence",i="Nucleotides"},5733:(e,t,n)=>{"use strict";n.d(t,{CB:()=>M,Z4:()=>C,aA:()=>g});var o=n(1536);const r={showLetters:!0,pairAlign:!0},i=1.25,s=.5,a=.32,l=5,c=17,u=4,h=30,d=.85,p=.5,m=.22,f=.55;function g(e,t,n,o={}){const d={...r,...o},p=n.sense.monomers.length,m=n.antisense?n.antisense.monomers.length:0,f=m>0,g=f?2:1,b=Math.max(1,p,m),C=Math.max(0,e-h-2*u)/(b+Math.max(0,b-1)*a),x=g+Math.max(0,g-1)*s,w=(t-2*u)/x/i;let A=Math.min(c,C,w);const T=A<l;A<l&&(A=l);const E=A*i,S=Math.max(2,A*a),N=E*s,I=Math.max(7,Math.min(13,.62*A)),M=g*E+(g-1)*N,P=Math.max(u,(t-M)/2),_=P,L=f?P+E+N:-1,O=u+h,R=e-u,$={chipW:A,chipH:E,chipGap:S,strandGap:N,fontSize:I,labelW:h,padding:u,senseY:_,antiY:L,seqX:O,textOnlyFallback:T};if(T)return{...$,senseChips:[],antiChips:[],senseLinks:[],antiLinks:[],antiReversed:!1};const D=f&&d.pairAlign,B=v(n.sense.monomers,!1,A,I,S),F=f?v(n.antisense.monomers,D,A,I,S):0,k=Math.max(B,F),H=O+(k-B),G=O+(k-F),U=y(n.sense,!1,_,H,R,$,"sense"),V=f?y(n.antisense,D,L,G,R,$,"antisense"):{chips:[],links:[]};return{...$,senseChips:U.chips,antiChips:V.chips,senseLinks:U.links,antiLinks:V.links,antiReversed:D}}function y(e,t,n,o,r,i,s){const a=t?e.monomers.slice().reverse():e.monomers,l=[],c=[];let u=o;for(let e=0;e<a.length;e++){const t=a[e],o="conjugate"===t.kind?b(t.symbol,i.chipW,i.fontSize):i.chipW;if(u+o>r)break;if(l.push({x:u,w:o,monomer:t,origIdx:t.position,strand:s}),"nucleotide"===t.kind&&e<a.length-1){const e=t;e.phosphate&&c.push({x:u+o,w:i.chipGap,y:n,h:i.chipH,phosphateSymbol:e.phosphate,ownerOrigIdx:e.position,strand:s})}u+=o+i.chipGap}return{chips:l,links:c}}function b(e,t,n){const r=.55*n,i=(0,o.rK)(e).meta.short.length*r,s=.6*t;return Math.max(t,Math.min(4*t,i+s))}function v(e,t,n,o,r){const i=t?e.slice().reverse():e;let s=0;for(const e of i){if("conjugate"!==e.kind)break;s+=b(e.symbol,n,o)+r}return s}function C(e,t,n,o,i,s,a={}){const l={...r,...a},c=g(o,i,s,l);if(e.save(),e.beginPath(),e.rect(t,n,o,i),e.clip(),e.translate(t,n),c.textOnlyFallback)return function(e,t,n,o,r){const i=o.sense.monomers.length,s=o.antisense?o.antisense.monomers.length:0,a=o.antisense?`${i}+${s} nt duplex`:`${i} nt`;e.fillStyle="#8b949e",e.font=`${Math.max(8,r.fontSize)}px ui-monospace, Menlo, monospace`,e.textBaseline="middle",e.textAlign="left",e.fillText(a,4,n/2)}(e,0,i,s,c),e.restore(),c;x(e,"S","5'",c.padding,c.senseY+c.chipH/2,c);for(const t of c.senseLinks)E(e,t);if(A(e,c.senseChips,c,l),w(e,c.senseChips,s.sense.monomers.length,c),c.antiY>=0&&s.antisense){x(e,"AS",c.antiReversed?"3'":"5'",c.padding,c.antiY+c.chipH/2,c);for(const t of c.antiLinks)E(e,t);A(e,c.antiChips,c,l),w(e,c.antiChips,s.antisense.monomers.length,c)}return e.restore(),c}function x(e,t,n,o,r,i){e.fillStyle="#8b949e",e.font=`${Math.max(8,i.fontSize-1)}px ui-monospace, Menlo, monospace`,e.textBaseline="middle",e.textAlign="left",e.fillText(`${t} ${n}`,o,r)}function w(e,t,n,o){if(t.length>=n)return;const r=t[t.length-1];r&&(e.fillStyle="#6e7681",e.font=`${Math.max(7,o.fontSize-1)}px ui-monospace, Menlo, monospace`,e.textBaseline="middle",e.textAlign="left",e.fillText("…",r.x+r.w+1,o.senseY+o.chipH/2))}function A(e,t,n,o){const r="sense"===t[0]?.strand?n.senseY:n.antiY;for(const i of t)"conjugate"===i.monomer.kind?S(e,i.monomer.symbol,i.x,r,i.w,n.chipH,n.fontSize):T(e,i.monomer,i.x,r,i.w,n.chipH,n.fontSize,o)}function T(e,t,n,r,i,s,a,l){const c=(0,o.xh)(t.sugar,t.base),u=o.L1[t.base??""]??o.FN,h=function(e){const t=(0,o.Jy)(e);return"r"!==t&&"d"!==t}(t.sugar),f=Math.min(2.5,i/4);if(N(e,n,r,i,s,f),e.fillStyle=function(e,t){const n=`${e}|${t}`,o=I.get(n);if(o)return o;const r=document.createElement("span");r.style.color=e,document.body.appendChild(r);const i=getComputedStyle(r).color;document.body.removeChild(r);const s=i.match(/\d+/g),a=s?`rgba(${s[0]},${s[1]},${s[2]},${t})`:e;return I.size>256&&I.clear(),I.set(n,a),a}(u,d),e.fill(),e.lineWidth=p,e.strokeStyle="rgba(0,0,0,0.22)",e.stroke(),h){const t=Math.max(2,s*m);e.save(),N(e,n,r,i,s,f),e.clip(),e.fillStyle=c.color,e.fillRect(n,r+s-t,i,t),e.restore()}if(l.showLetters&&t.base&&a>=8){const o=h?Math.max(2,s*m):0;e.fillStyle="#1a1a1a",e.font=`600 ${a}px system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif`,e.textBaseline="middle",e.textAlign="center",e.fillText(t.base,n+i/2,r+(s-o)/2+.5)}}function E(e,t){const n=(0,o.bM)(t.phosphateSymbol);if("PS"!==n.meta.short&&"PS₂"!==n.meta.short&&"MeP"!==n.meta.short)return;const r=Math.max(2.5,t.w*f),i=t.x+(t.w-r)/2;e.fillStyle=n.color,e.fillRect(i,t.y+1,r,t.h-2)}function S(e,t,n,r,i,s,a){const l=(0,o.rK)(t);N(e,n,r,i,s,s/2),e.fillStyle=l.color,e.fill(),e.lineWidth=.5,e.strokeStyle="rgba(0,0,0,0.2)",e.stroke(),a>=8&&(e.fillStyle="#ffffff",e.font=`600 ${Math.max(8,a-1)}px system-ui, sans-serif`,e.textBaseline="middle",e.textAlign="center",e.fillText(l.meta.short,n+i/2,r+s/2+.5))}function N(e,t,n,o,r,i){e.beginPath(),e.moveTo(t+i,n),e.lineTo(t+o-i,n),e.quadraticCurveTo(t+o,n,t+o,n+i),e.lineTo(t+o,n+r-i),e.quadraticCurveTo(t+o,n+r,t+o-i,n+r),e.lineTo(t+i,n+r),e.quadraticCurveTo(t,n+r,t,n+r-i),e.lineTo(t,n+i),e.quadraticCurveTo(t,n,t+i,n),e.closePath()}const I=new Map;function M(e,t,n,o){if(o.textOnlyFallback)return null;if(t>=o.senseY&&t<=o.senseY+o.chipH){const r=P(e,o.senseChips);if(r)return{strand:"sense",position:r.origIdx,monomer:r.monomer};const i=_(e,t,o.senseLinks);if(i)return L(i,n.sense,"sense")}if(o.antiY>=0&&t>=o.antiY&&t<=o.antiY+o.chipH){const r=P(e,o.antiChips);if(r)return{strand:"antisense",position:r.origIdx,monomer:r.monomer};const i=_(e,t,o.antiLinks);if(i&&n.antisense)return L(i,n.antisense,"antisense")}return null}function P(e,t){for(const n of t)if(e>=n.x&&e<n.x+n.w)return n;return null}function _(e,t,n){for(const o of n)if(e>=o.x&&e<o.x+o.w&&t>=o.y&&t<o.y+o.h)return o;return null}function L(e,t,n){const o=t.monomers.find((t=>t.position===e.ownerOrigIdx));return{strand:n,position:e.ownerOrigIdx,monomer:o,linkage:{phosphateSymbol:e.phosphateSymbol}}}},5613:(e,t,n)=>{"use strict";n.d(t,{On:()=>r,nj:()=>u,yO:()=>l});var o=n(1536);function r(e){const t=((e??"").split("$")[0]??"").split("|").map((e=>e.trim())).filter((e=>e.length>0)).map(i);return{sense:t[0]??{type:"RNA",monomers:[]},antisense:t[1]??null,raw:e}}function i(e){const t=e.match(/^(RNA|DNA|CHEM|PEPTIDE|BLOB)\d+\{(.*)\}$/);return t?{type:t[1],monomers:s(t[2])}:{type:"CHEM",monomers:[]}}function s(e){const t=[];let n=0,o="",r=0;for(const i of e){if("["===i||"("===i)n++;else if("]"===i||")"===i)n--;else if("."===i&&0===n){o&&t.push(a(o,r++)),o="";continue}o+=i}return o&&t.push(a(o,r)),t}function a(e,t){let n=0,o="",r=null,i="";const s=e;if("["===e[0]){const t=e.indexOf("]");o=e.substring(1,t),n=t+1}else o=e[0]??"",n=1;if("("===e[n]){const t=e.indexOf(")",n);r=e.substring(n+1,t),n=t+1}if(n<e.length)if("["===e[n]){const t=e.indexOf("]",n);i=e.substring(n+1,t),n=t+1}else i=e.substring(n);return null===r?{kind:"conjugate",position:t,symbol:o,raw:s}:{kind:"nucleotide",position:t,sugar:o,base:r,phosphate:i,raw:s}}function l(e){return/^\s*(?:RNA|DNA|PEPTIDE|CHEM|BLOB)\d+\s*\{/.test(e??"")}function c(e){if("conjugate"===e.kind)return`[${e.symbol}]`;const t=e,n=(0,o.Jy)(t.sugar),r=(0,o.$T)(t.phosphate),i=1===n.length?n:`[${n}]`,s=r?1===r.length?r:`[${r}]`:"";return`${i}${t.base?`(${t.base})`:""}${s}`}function u(e){return`${(e??"").split("$")[0].split("|").map((e=>e.trim())).filter(Boolean).map((e=>{const t=e.match(/^((?:RNA|DNA|PEPTIDE|CHEM|BLOB)\d+)\{(.*)\}$/);if(!t)return e;const[,n,o]=t;return`${n}{${function(e){return s(e).map(c).join(".")}(o)}}`})).join("|")}$$$$`}},1536:(e,t,n)=>{"use strict";n.d(t,{$T:()=>m,D2:()=>r,FN:()=>h,Jy:()=>p,L1:()=>u,P4:()=>a,bM:()=>g,e8:()=>d,mU:()=>o,pt:()=>c,rK:()=>y,xh:()=>f});const o="OligoNucleotide",r="helm",i=Object.freeze({r:{name:"Ribose",short:"RNA",color:"#D0D0D0",category:"sugar"},d:{name:"Deoxyribose",short:"DNA",color:"#BDBDBD",category:"sugar"},m:{name:"2'-O-Methyl",short:"2'-OMe",color:"#4A90E2",category:"sugar"},"25r":{name:"2'-O-Methyl (2,5)",short:"2'-OMe",color:"#4A90E2",category:"sugar"},fl2r:{name:"2'-Fluoro",short:"2'-F",color:"#50C878",category:"sugar"},lna:{name:"LNA",short:"LNA",color:"#E89D3C",category:"sugar"},cet:{name:"cEt",short:"cEt",color:"#E07B30",category:"sugar"},ena:{name:"ENA",short:"ENA",color:"#D26C20",category:"sugar"},moe:{name:"2'-MOE",short:"2'-MOE",color:"#66CDAA",category:"sugar"},Rgna:{name:"(R)-GNA",short:"GNA",color:"#C7A981",category:"sugar"},Sgna:{name:"(S)-GNA",short:"GNA",color:"#C7A981",category:"sugar"},una:{name:"UNA",short:"UNA",color:"#ED68B8",category:"sugar"},fana:{name:"FANA",short:"FANA",color:"#76B947",category:"sugar"},hna:{name:"HNA",short:"HNA",color:"#A4D080",category:"sugar"}}),s=Object.freeze({R:"r",dR:"d",mR:"m",fR:"fl2r",LR:"lna",L:"lna",MOE:"moe",GNA:"Sgna",UNA:"una"}),a=Object.freeze({p:{name:"Phosphate",short:"PO",color:"#888888",category:"phosphate"},sp:{name:"Phosphorothioate",short:"PS",color:"#6B46C1",category:"phosphate"},s2p:{name:"Phosphorodithioate",short:"PS₂",color:"#7E2BC4",category:"phosphate"},mp:{name:"Methylphosphonate",short:"MeP",color:"#9B5DE5",category:"phosphate"}}),l=Object.freeze({P:"p",sP:"sp"}),c=Object.freeze({GalNAc:{name:"GalNAc",short:"GalNAc",color:"#E91E63",category:"conjugate"},L3:{name:"GalNAc-L3 linker",short:"L3",color:"#E91E63",category:"conjugate"},Chol:{name:"Cholesterol",short:"Chol",color:"#B57F50",category:"conjugate"},Bio:{name:"Biotin",short:"Bio",color:"#FFC107",category:"conjugate"}}),u=Object.freeze({A:"#C1E7C5",C:"#C5DCF0",G:"#E8DCA9",U:"#F0C5C5",T:"#F0C5C5"}),h="#BCBCBC";function d(e){let t=0;for(let n=0;n<e.length;n++)t=31*t+e.charCodeAt(n)|0;return`hsl(${(t>>>0)%360}, 42%, 60%)`}function p(e){return s[e]??e}function m(e){return l[e]??e}function f(e,t){const n=p(e),o=i[n];if(o)return("r"===n||"d"===n)&&t&&u[t]?{color:u[t],meta:o}:{color:o.color,meta:o};const r=d(n);return{color:r,meta:{name:n,short:n,color:r,category:"sugar"}}}function g(e){if(!e)return{color:"#888",meta:{name:"(none)",short:"",color:"#888",category:"phosphate"}};const t=m(e),n=a[t];if(n)return{color:n.color,meta:n};const o=d(t);return{color:o,meta:{name:t,short:t,color:o,category:"phosphate"}}}function y(e){const t=c[e];return t?{color:t.color,meta:t}:{color:d(e),meta:{name:e,short:e.length>6?e.slice(0,6):e,color:d(e),category:"conjugate"}}}},9022:(e,t,n)=>{"use strict";n.d(t,{PackageFunctions:()=>Cr,_package:()=>br});var o=n(4328),r=n(6082),i=n(439),s=n(7291);const a=new class{constructor(){this.seqHandler="seq-handler",this.notationProvider="seq-handler.notation-provider"}};r.SemanticValue;var l=n(4971);class c{constructor(e,t,n=""){this.target=e,this.debugEnabled=t,this.prefix=n}error(e,t,n){return this.target.error(this.prefix+e,t,n)}warning(e,t){return this.target.warning(this.prefix+e,t)}info(e,t){return this.target.info(this.prefix+e,t)}debug(e,t){if(this.debugEnabled)return this.target.debug(this.prefix+e,t)}}const u="System:AppData/SequenceTranslator/monomers-sample",h="pattern-app-data.json",d="formats-to-helm.json",p="codes-to-symbols.json",m="linkers.json";var f=n(6686);function g(e){return e.sort(((e,t)=>t.length-e.length))}function y(e,t){const n=document.createElement("a");n.setAttribute("href","data:text/plain;charset=utf-8,"+t),n.setAttribute("download",e),n.click()}async function b(e,t,n="Oligo app"){try{return await e()}catch(e){const t=e.hasOwnProperty("message")?e.message:e.toString();throw o.shell.error(`${n} error: `+t),e}finally{t&&t()}}class v{constructor(e,t){this.sequence=e,this.th=t,this.libWrapper=this.th.monomerLibWrapper}getInvalidCodeIndex(e){if(e===f.NO.HELM)return this.sequence.length;const t=["r","d"],n=g(this.libWrapper.getCodesByFormat(e));let o=0;for(;o<this.sequence.length;){const e=n.find((e=>e===this.sequence.substring(o,o+e.length)));if(!e)break;if(o>1&&f.AL.includes(this.sequence[o])&&t.includes(this.sequence[o-2]))break;if(t.includes(this.sequence[o+1])&&f.AL.includes(this.sequence[o])){o++;break}o+=e.length}return o===this.sequence.length&&(o=-1),o}isValidSequence(e){return-1===this.getInvalidCodeIndex(e)}}class C{constructor(e,t,n,o){this.patternAppData=e,this.codesToHelmDict=t,this.codesToSymbolsDict=n,this.monomersWithPhosphate=o}}async function x(e){const t=await Promise.all([h,d,p,m].map((t=>async function(e,t){const n=e.endsWith("/")?`${e}${t}`:`${e}/${t}`;try{const e=await o.dapi.files.readAsText(n);return JSON.parse(e)}catch(e){console.error(`Error loading json from '${n}':`,e)}}(e,t))));return new C(t[0],t[1],t[2],t[3])}class w{constructor(e,t){if(this.lib=e,this.jsonData=t,null===this.lib)throw new Error("SequenceTranslator: monomer library is null");this.allMonomers=this.getAllMonomers()}formatMonomerForViewer(e){const t={};return t.name=e.symbol,t.symbol=e.symbol,t.molfile=e.molfile,this.getAllFormats().forEach((n=>{if(n===f.NO.HELM)return;const o=this.jsonData.codesToSymbolsDict[n],r=Object.keys(o).filter((t=>o[t]===e.symbol));t[n]=r.join(", ")})),t}getAllMonomers(){const e=this.lib.getPolymerTypes();let t=[];for(const n of e){const e=this.lib.getMonomerSymbolsByType(n).map((e=>this.lib.getMonomer(n,e))).filter((e=>null!==e));t=t.concat(e)}return t}getMonomer(e){const t=this.lib.getMonomer("RNA",e);if(void 0===t)throw new Error(`SequenceTranslator: no monomer with symbol ${e}`);return t}getMolfileBySymbol(e){return this.getMonomer(e).molfile}getNaturalAnalogBySymbol(e){const t=this.getMonomer(e).naturalAnalog;if(!t)throw new Error(`ST: no natural analog for ${e}`);return t}isModification(e){return!!this.getMolfileBySymbol(e).includes("MODIFICATION")}getCodeToSymbolMap(e){return new Map(Object.entries(this.jsonData.codesToSymbolsDict[e]))}getCodesByFormat(e){return Object.keys(this.jsonData.codesToSymbolsDict[e])}getAllFormats(){return Object.keys(this.jsonData.codesToSymbolsDict)}getTableForViewer(){const e=this.allMonomers.map((e=>this.formatMonomerForViewer(e)));return r.DataFrame.fromObjects(e)}getCodesToWeightsMap(){const e=new Map;return Object.entries(this.jsonData.codesToSymbolsDict).forEach((([t,n])=>{Object.entries(n).forEach((([t,n])=>{const o=this.getMonomer(n),r=o.meta?.molecularWeight;e.set(t,r)}))})),e}}var A=n(9537);const T=(e,t)=>t.length-e.length;class E{constructor(e){this.th=e,this.formats=this.getFormats()}getFormatNames(){return this.formats.sort()}getCodesByFormat(e){if(this.validateFormat(e),this.isHelm(e))throw new Error("Codes cannot be obtained for HELM");return this.getFormatCodes(e)}getHelmToFormatDict(e){return this.validateFormat(e),function(e){const t={};return Object.values(e).forEach((e=>{Object.entries(e).forEach((([e,n])=>{const o=n.replace(/\)p/g,")").replace(/\]p/g,"]");void 0===t[o]?t[o]=[e]:t[o].push(e)}))})),Object.entries(t).forEach((([e,n])=>{const o=n.sort(T);t[e]=o[0]})),t}(this.th.jsonData.codesToHelmDict[e])}getFormatToHelmDict(e){this.validateFormat(e);const t=this.th.jsonData.codesToHelmDict[e];return Object.assign({},...Object.values(t))}getTargetFormatHelmCodes(e){this.validateFormat(e);const t=this.getHelmToFormatDict(e);return Object.keys(t).sort(T)}getTargetFormatHelmCodesRegExp(e){this.validateFormat(e);const t=this.getTargetFormatHelmCodes(e);return new RegExp(S(t)+"|.","g")}getFormatRegExp(e){if(this.validateFormat(e),this.isHelm(e))throw new Error("Helm RegExp can be built for non-HELM target formats");return this.getNonHelmFormatRegExp(e)}getPhosphateHelmCodesRegExp(e){this.validateFormat(e);const t=this.th.jsonData.codesToHelmDict[e],n=S(Array.from(new Set(Object.values(t[A.ti.LINKAGE]))).sort(T));return new RegExp(`${A.q7}.(${n})`,"g")}isValidFormat(e){return this.formats.includes(e)}getFormats(){return Object.keys(this.th.jsonData.codesToHelmDict)}validateFormat(e){if(!this.isValidFormat(e))throw new Error(`Invalid format: ${e}`)}isHelm(e){return e===f.NO.HELM}getFormatCodes(e){const t=this.getFormatToHelmDict(e);return Object.keys(t).sort(T)}getNonHelmFormatRegExp(e){const t=this.getCodesByFormat(e);return new RegExp(S(t)+"|\\([^()]*\\)|.","g")}}function S(e){return e.map((e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"))).map((e=>e.includes("(")||e.includes(")")?e:`(?<!\\([^()]*)${e}(?![^()]*\\))`)).join("|")}const N={LEFT:"RNA1{",RIGHT:"}$$$$"};class I{constructor(e,t,n){this.sequence=e,this.sourceFormat=t,this.th=n,this.formats=new E(this.th)}convertTo(e){const t=this.formats.getFormatNames();if(this.sourceFormat===f.NO.HELM&&t.includes(e))return this.helmToFormat(this.sequence,e);if(t.includes(this.sourceFormat)&&e===f.NO.HELM)return this.formatToHelm(this.sequence,this.sourceFormat);if([this.sourceFormat,e].every((e=>t.includes(e)))){const t=this.formatToHelm(this.sequence,this.sourceFormat);return this.helmToFormat(t,e)}throw new Error(`ST: unsupported translation direction ${this.sourceFormat} -> ${e}`)}helmToFormat(e,t){const n=new RegExp(S(Object.values(N)),"g");let o=e.replace(n,"");const r=this.formats.getHelmToFormatDict(t),i=this.formats.getTargetFormatHelmCodes(t),s=this.formats.getTargetFormatHelmCodesRegExp(t);return o=o.replace(s,(e=>i.includes(e)?r[e]:"p"===e||"."===e?e:"?")).replace(/\?+/g,A.iL).replace(/p\.|\./g,""),o=o.replace(/<empty>/g,""),o=o.replace(/\/\//g,"/"),o}formatToHelm(e,t){const n=this.formats.getFormatToHelmDict(t),o=this.formats.getCodesByFormat(t),r=this.formats.getFormatRegExp(t),i=this.formats.getPhosphateHelmCodesRegExp(t);let s=e?e.replace(r,(e=>o.includes(e)?n[e]+".":"?")):"";return s=s.replace(/\?+/g,`${A.iL}.`),s=s.slice(0,-1),s[s.length-1]===A.q7&&(s=s.slice(0,-1)),s=s.replace(i,((e,t)=>t)),s=s.replace(/<empty>/g,""),`${N.LEFT+s+N.RIGHT}`}}class M{constructor(e,t){this.sequence=e,this.th=t,this.libWrapper=this.th.monomerLibWrapper,this.formats=Object.keys(this.th.jsonData.codesToHelmDict)}getFormat(){if(this.sequence.startsWith("RNA"))return f.NO.HELM;const e=this.getListOfPossibleSynthesizersByFirstMatchedCode();if(0===e.length)return null;const t=this.th.createSequenceValidator(this.sequence),n=Array(e.length).fill(0);for(let o=0;o<e.length;++o){const r=e[o];n[o]=t.getInvalidCodeIndex(r)}const o=n.some((e=>-1===e))?-1:Math.max(...n);return e[n.indexOf(o)]}getListOfPossibleSynthesizersByFirstMatchedCode(){const e=this.sequence,t=[];for(const n of this.formats){const o=g(this.libWrapper.getCodesByFormat(n));let r=0;for(let t=0;t<e.length;t++)if(")"===e[t]&&t!==e.length-1){r=t+1;break}o.some((t=>t===e.slice(r,r+t.length)))&&t.push(n)}return t}}var P=n(7389);const _=$;var L=n.n(_);function O(e,t){let n=0;const o=t.createFormatDetector(e).getFormat();null!==o&&(n=new v(e,t).getInvalidCodeIndex(o));const r=n<0||""===e,i=P.span([]);L()(i).css("-webkit-text-fill-color","var(--grey-6)");const s=P.span([]);return L()(s).css("-webkit-text-fill-color","red"),r?i.innerHTML=e:(i.innerHTML=e.slice(0,n),s.innerHTML=e.slice(n)),[i,s]}class R extends r.Package{get helmHelper(){if(!this._helmHelper)throw new Error("Package SequenceTranslator .helmHelper is not initialized");return this._helmHelper}get seqHelper(){return this._helmHelper.seqHelper}get monomerLib(){if(!this._monomerLib)throw new Error("Monomer lib not loaded");return this._monomerLib}get jsonData(){if(!this._jsonData)throw new Error("Json data not loaded");return this._jsonData}get monomerLibWrapper(){if(!this._monomerLibWrapper)throw new Error("Monomer lib wrapper not loaded");return this._monomerLibWrapper}get initPromise(){return this._initPromise}constructor(e={debug:!1}){super(),this.highlightInvalidSubsequence=e=>O(e,this),super._logger=new c(super.logger,e.debug)}startInit(e){this._initPromise=e}completeInit(e){this._helmHelper=e}async initLibData(){return this.initLibDataPromise||(this.initLibDataPromise=(async()=>{const e=await this.getSettings();let t=e instanceof Map?e.get("MonomersPath"):e.MonomersPath;t&&await o.dapi.files.exists(t)||(this.logger.warning(`Monomers path '${t}' not found. Fallback to monomers sample path '${u}'.`),t=u),[this._jsonData,this._monomerLib]=await Promise.all([x(t),D(t)]),this._monomerLibWrapper=new w(this.monomerLib,this.jsonData)})()),this.initLibDataPromise}async getTranslationHelper(){return await o.functions.call(`${this.name}:getTranslationHelper`)}createSequenceValidator(e){return new v(e,this)}createFormatConverter(e,t){return new I(e,t,this)}createFormatDetector(e){return new M(e,this)}}async function D(e){const t=r.TaskBarProgressIndicator.create("Initializing Oligo Toolkit monomer library ...");try{const t=await(0,l.pj)(),n=(e.endsWith("/")?e:e+"/")+"monomer-lib.json";return await t.readLibraryFromFilePath(n)}finally{t.close()}}class B{constructor(e,t){this.appName=e,this.parentAppName=t}async getAppView(){const e=r.TaskBarProgressIndicator.create(`Loading ${this.appName}...`),t=o.shell.v?.root;t&&P.setUpdateIndicator(t,!0);try{return await this.constructView()}finally{e.close(),t&&P.setUpdateIndicator(t,!1)}}}class F extends B{constructor(e){super(e),this.view=r.View.create(),this.configureView()}async constructView(){await this.initView();const e=this.parentAppName?this.parentAppName+"/"+this.appName:this.appName;return this.view.path=`/apps/${br.name}/${e.replace(/\s/g,"")}/`,this.view}async initView(){const e=await this.getContent();this.view.append(e)}configureView(){this.view.box=!0,this.view.name=this.appName;const e=o.shell.windows;e.showProperties=!1,e.showToolbox=!1,e.showHelp=!1}getView(){return this.view}}const k=["SS","AS"],H={SS:"Sense strand",AS:"Anti sense"},G=["3'","5'"],U="OligoToolkit";var V,j,q,W;!function(e){e.IS_ANTISENSE_STRAND_INCLUDED="isAntisenseStrandIncluded",e.NUCLEOTIDE_SEQUENCES="nucleotideSequences",e.PHOSPHOROTHIOATE_LINKAGE_FLAGS="phosphorothioateLinkageFlags",e.STRAND_TERMINUS_MODIFICATIONS="strandTerminusModifications"}(V||(V={})),function(e){e.PATTERN_NAME="patternName",e.PATTERN_COMMENT="patternComment",e.NUCLEOTIDES_WITH_NUMERIC_LABELS="nucleotidesWithNumericLabels"}(j||(j={})),function(e){e.PATTERN_CONFIG="patternConfig",e.AUTHOR_ID="authorID",e.DATE="date"}(q||(q={})),function(e){e.CREATE="create",e.MODIFY="modify"}(W||(W={}));const z=[V.IS_ANTISENSE_STRAND_INCLUDED,V.NUCLEOTIDE_SEQUENCES,V.PHOSPHOROTHIOATE_LINKAGE_FLAGS,V.STRAND_TERMINUS_MODIFICATIONS],Y=(j.PATTERN_NAME,j.PATTERN_COMMENT,j.NUCLEOTIDES_WITH_NUMERIC_LABELS,{patternConfig:{patternName:"<default example>",isAntisenseStrandIncluded:!0,nucleotideSequences:{SS:["RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA"],AS:["RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA"]},phosphorothioateLinkageFlags:{SS:[!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0],AS:[!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0]},strandTerminusModifications:{SS:{"3'":"","5'":""},AS:{"3'":"","5'":""}},patternComment:"",nucleotidesWithNumericLabels:["RNA"]},authorID:""}),K="2024-01-01T18:00:00.000Z";class Q extends Error{constructor(e){super(e),this.name="PatternNameExistsError"}}class J extends Error{constructor(e){super(e),this.name="PatternExistsError"}}var X=n(4802),Z=n.n(X);class ee{constructor(e){this.th=e,this.otherUsersPatternNameToHash=new Map,this.currentUserPatternNameToHash=new Map}static async getInstance(){const e=await br.getTranslationHelper(),t=new ee(e);t.currentUserName=await t.fetchCurrentUserName(),t.currentUserId=await t.fetchCurrentUserId();const n=t.fetchPatterns();return await t.initializePatternMaps(n),t}getCurrentUserPatternNames(){return Array.from(this.currentUserPatternNameToHash.keys()).sort(((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase())))}getOtherUsersPatternNames(){return Array.from(this.otherUsersPatternNameToHash.keys()).sort(((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase())))}getCurrentUserName(){return this.currentUserName}validatePatternNameUniqueness(e){if(this.currentUserPatternNameToHash.has(e))throw new Q(`Pattern with name ${e} already exists`)}validatePatternUniqueness(e){if(Array.from(this.currentUserPatternNameToHash.values()).concat(Array.from(this.otherUsersPatternNameToHash.values())).includes(e))throw new J(e)}getPatternHash(e,t){const n=t?this.currentUserPatternNameToHash.get(e):this.otherUsersPatternNameToHash.get(e);if(void 0===n)throw new Error(`Pattern with name ${e} not found`);return n}async getPatternRecordByHash(e){if(null===e||""===e)return null;try{const t=o.userSettings.getValue(U,e,!1)??"null";return JSON.parse(t)}catch{return null}}async getPatternConfig(e){if(""===e||null===e)return null;const t=await this.getPatternRecordByHash(e);return null===t?null:t[q.PATTERN_CONFIG]}getDefaultPatternRecord(){const e=Y;return e[q.AUTHOR_ID]=this.currentUserId,e}getDefaultPatternConfig(){return Y[q.PATTERN_CONFIG]}getAuthorCategoryByHash(e){if(this.isCurrentUserPattern(e))return this.getCurrentUserAuthorshipCategory();if(this.isOtherUserPattern(e))return this.getOtherUsersAuthorshipCategory();throw new Error(`Pattern with hash ${e} not found`)}isCurrentUserPattern(e){return Array.from(this.currentUserPatternNameToHash.values()).includes(e)}isOtherUserPattern(e){return Array.from(this.otherUsersPatternNameToHash.values()).includes(e)}getPatternNameByHash(e){const t=[this.currentUserPatternNameToHash,this.otherUsersPatternNameToHash];for(const n of t)for(const[t,o]of n.entries())if(o===e)return t;throw new Error(`Pattern with hash ${e} not found`)}getHashOfPatternToBeLoadedAfterDeletion(){const e=this.getCurrentUserPatternNames()[0];if(!e)throw new Error("Cannot load pattern after deletion, as there are no patterns left");const t=this.currentUserPatternNameToHash.get(e);if(void 0===t)throw new Error(`Pattern with name ${e} not found`);return t}async getRecordFromPattern(e){return{[q.PATTERN_CONFIG]:e,[q.AUTHOR_ID]:await o.dapi.users.current().then((e=>e.id))}}getHash(e){const t=z.reduce(((t,n)=>(t[n]=e[n],t)),{});return Z().sha1(t)}async savePatternToUserStorage(e){const t=e.getPatternConfig();try{const n=this.getHash(t);this.validatePatternUniqueness(n);const r=t[j.PATTERN_NAME];this.validatePatternNameUniqueness(r);const i=await this.getRecordFromPattern(t),s=(new Date).toISOString();i[q.DATE]={[W.CREATE]:s,[W.MODIFY]:s};const a=JSON.stringify(i);o.userSettings.add(U,n,a,!1),this.currentUserPatternNameToHash.set(r,n),e.selectAuthor(this.getCurrentUserAuthorshipCategory()),e.updatePatternList(),e.requestPatternLoad(n),e.updateUrlState(n)}catch(e){if(e instanceof Q||e instanceof J)throw e;console.error("Error while saving pattern to user storage",e)}}async overwriteExistingPatternInUserStorage(e){const t=e.getPatternConfig(),n=t[j.PATTERN_NAME],r=this.currentUserPatternNameToHash.get(n);if(void 0===r)throw new Error("Old hash is undefined");const i=this.getHash(t),s=await this.getRecordFromPattern(t),a=(new Date).toISOString();s[q.DATE]={[W.MODIFY]:a};const l=o.userSettings.getValue(U,r,!1)??"null",c=JSON.parse(l);void 0!==c[q.DATE]&&null!=c[q.DATE][W.CREATE]&&(s[q.DATE][W.CREATE]=c[q.DATE][W.CREATE]);const u=JSON.stringify(s);o.userSettings.add(U,i,u,!1),o.userSettings.delete(U,r,!1),this.currentUserPatternNameToHash.set(n,i),e.requestPatternLoad(i),e.updateUrlState(i)}async deletePattern(e,t){const n=this.currentUserPatternNameToHash.get(e);if(e===this.getDefaultPatternName())return void o.shell.warning("Cannot delete default pattern");if(void 0===n)throw new Error(`Pattern with name ${e} not found`);o.userSettings.delete(U,n,!1),this.currentUserPatternNameToHash.delete(e),t.updatePatternList();const r=this.getHashOfPatternToBeLoadedAfterDeletion();t.requestPatternLoad(r)}fetchDefaultNucleobase(){return this.fetchAvailableNucleotideBases()[0]}fetchAvailableNucleotideBases(){const e=Object.keys(this.th.jsonData.patternAppData)[0];return Object.keys(this.th.jsonData.patternAppData[e])}async fetchCurrentUserName(){return(await o.dapi.users.current()).friendlyName}async fetchCurrentUserId(){return(await o.dapi.users.current()).id}fetchPatterns(){return o.userSettings.get(U,!1)??{}}async initializePatternMaps(e){if(!this.currentUserId)throw new Error("Current user ID is not set");const t=new Map;for(const[n,o]of Object.entries(e))await this.extractDataFromRecordToMaps(n,o,t);this.setDefaultPattern()}setDefaultPattern(){const e=Y[q.PATTERN_CONFIG];this.currentUserPatternNameToHash.set(e[j.PATTERN_NAME],"")}async extractDataFromRecordToMaps(e,t,n){const r=JSON.parse(t),i=r[q.PATTERN_CONFIG].patternName,s=r[q.AUTHOR_ID];if(this.isCurrentUserId(s))this.currentUserPatternNameToHash.set(i,e);else{if(!n.has(s)){let e="<UNKNOWN_USER>";try{e=(await o.dapi.users.find(s)).friendlyName}catch(e){}n.set(s,e)}const t=i+` (created by ${n.get(s)})`;this.otherUsersPatternNameToHash.set(t,e)}}getDefaultPatternName(){return Y[q.PATTERN_CONFIG][j.PATTERN_NAME]}getCurrentUserAuthorshipCategory(){return this.currentUserName+" (me)"}getOtherUsersAuthorshipCategory(){return"Other users"}isCurrentUserId(e){return e===this.currentUserId}}const te=rxjs,ne=rxjs.operators;function oe(e){return e.endsWith("(o)")}function re(e){const t=Object.values(e).flat().reduce(((e,t)=>(e[t]=(e[t]||0)+1,e)),{});return Object.entries(t).reduce(((e,t)=>e[1]>t[1]?e:t),["",0])[0]}var ie;function se(e){const t=Array.from(new Set(e));return Array.from(t).sort(((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase())))}!function(e){e.getTruncatedStrandData=function(e,t,n){return{nucleotides:e.slice(0,n),ptoFlags:t.slice(0,n+1)}},e.getExtendedStrandData=function(e,t,n,o){const r=n-e.length,i=e.concat(new Array(n-e.length).fill(o)),s=0===e.length?n+1:r;return{nucleotides:i,ptoFlags:t.concat(new Array(s).fill(!0))}}}(ie||(ie={}));var ae=n(2543),le=n.n(ae);class ce{constructor(e,t){this.dataManager=e,this._patternListUpdated$=new te.Subject,this._patternLoadRequested$=new te.Subject,this._patternLoaded$=new te.Subject,this._uniqueNucleotides$=new te.BehaviorSubject([]),this._patternDeletionRequested$=new te.Subject,this._tableSelection$=new te.BehaviorSubject(null),this._svgSaveRequested$=new te.Subject,this._loadPatternInNewTabRequested$=new te.Subject,this._urlStateUpdated$=new te.Subject,this._patternHasUnsavedChanges$=new te.BehaviorSubject(!1),this._selectedStrandColumn=new te.BehaviorSubject(null),this._selectedIdColumn=new te.BehaviorSubject(null),this.initializeAuthorSelection(t),this.initializePatternState(t),this._lastLoadedPatternConfig=new te.BehaviorSubject(le().cloneDeep(this.getPatternConfig())),this.setupSubscriptions()}setupSubscriptions(){this._nucleotideSequences$.subscribe((()=>{this.updateUniqueNucleotides(),this.updateSequenceBase()})),this._isAntisenseStrandActive$.subscribe((e=>{e||G.forEach((e=>{this.updateTerminusModification("AS",e,"")}))})),this.patternStateChanged$.pipe((0,ne.debounceTime)(20)).subscribe((()=>{const e=this._lastLoadedPatternConfig.getValue(),t=this.getPatternConfig(),n=!le().isEqual(t,e);this._patternHasUnsavedChanges$.next(n)}))}updateUniqueNucleotides(){const e=(t=this._nucleotideSequences$.getValue(),se(Object.values(t).flat()));var t;this._uniqueNucleotides$.next(e)}updateSequenceBase(){const e=re(this._nucleotideSequences$.getValue());this._sequenceBase$.next(e)}get nucleotideSequencesChanged$(){return this._nucleotideSequences$.asObservable()}initializeAuthorSelection(e){const t=e[q.AUTHOR_ID];this.dataManager.isCurrentUserId(t)?this._patternAuthorSelection$=new te.BehaviorSubject(this.dataManager.getCurrentUserAuthorshipCategory()):this._patternAuthorSelection$=new te.BehaviorSubject(this.dataManager.getOtherUsersAuthorshipCategory())}initializePatternState(e){const t=e[q.PATTERN_CONFIG];this._patternName$=new te.BehaviorSubject(t[j.PATTERN_NAME]),this._isAntisenseStrandActive$=new te.BehaviorSubject(t[V.IS_ANTISENSE_STRAND_INCLUDED]),this._nucleotideSequences$=new te.BehaviorSubject(t[V.NUCLEOTIDE_SEQUENCES]),this._phosphorothioateLinkageFlags=new te.BehaviorSubject(t[V.PHOSPHOROTHIOATE_LINKAGE_FLAGS]),this._terminalModifications=new te.BehaviorSubject(t[V.STRAND_TERMINUS_MODIFICATIONS]),this._comment$=new te.BehaviorSubject(t[j.PATTERN_COMMENT]),this._modificationsWithNumericLabels$=new te.BehaviorSubject(t[j.NUCLEOTIDES_WITH_NUMERIC_LABELS]),this._sequenceBase$=new te.BehaviorSubject(re(t[V.NUCLEOTIDE_SEQUENCES]))}getPatternName(){return this._patternName$.getValue()}updatePatternName(e){this._patternName$.next(e)}get antisenseStrandToggled$(){return this._isAntisenseStrandActive$.asObservable()}isAntisenseStrandActive(){return this._isAntisenseStrandActive$.getValue()}toggleAntisenseStrand(e){e?this.updateStrandLength("AS",this.getNucleotideSequences().SS.length):this.updateStrandLength("AS",0),this._isAntisenseStrandActive$.next(e)}getNucleotideSequences(){return this._nucleotideSequences$.getValue()}updateNucleotideSequences(e){this._nucleotideSequences$.next(e)}updateStrandLength(e,t){const n=this.getNucleotideSequences()[e];if(n.length===t)return;const o=this.getPhosphorothioateLinkageFlags()[e];if(0===t)return void this.setNewStrandData([],[],e);if(n.length>t){const{nucleotides:r,ptoFlags:i}=ie.getTruncatedStrandData(n,o,t);return void this.setNewStrandData(r,i,e)}const r=this.getSequenceBase(),{nucleotides:i,ptoFlags:s}=ie.getExtendedStrandData(n,o,t,r);this.setNewStrandData(i,s,e)}setNewStrandData(e,t,n){this.updateNucleotideSequences({...this.getNucleotideSequences(),[n]:e}),this.updatePhosphorothioateLinkageFlags({...this.getPhosphorothioateLinkageFlags(),[n]:t})}getPhosphorothioateLinkageFlags(){return this._phosphorothioateLinkageFlags.getValue()}updatePhosphorothioateLinkageFlags(e){this._phosphorothioateLinkageFlags.next(e)}get phosphorothioateLingeFlagsChanged$(){return this._phosphorothioateLinkageFlags.asObservable()}getTerminalModifications(){return this._terminalModifications.getValue()}updateTerminalModifications(e){this._terminalModifications.next(e)}updateTerminusModification(e,t,n){const o=this.getTerminalModifications();o[e][t]=n,this.updateTerminalModifications(o)}terminalModificationsUpdated$(){return this._terminalModifications.asObservable()}getComment(){return this._comment$.getValue()}updateComment(e){this._comment$.next(e)}getModificationsWithNumericLabels(){return this._modificationsWithNumericLabels$.getValue()}updateModificationsWithNumericLabels(e){const t=function(e){return se(e).filter((e=>!oe(e)))}(e);this._modificationsWithNumericLabels$.next(t)}get patternLoadRequested$(){return this._patternLoadRequested$.asObservable()}requestPatternLoad(e){this._patternLoadRequested$.next(e)}get patternListUpdated$(){return this._patternListUpdated$.asObservable()}updatePatternList(){this._patternListUpdated$.next()}get tableSelectionChanged$(){return this._tableSelection$.asObservable()}selectTable(e){this._tableSelection$.next(e)}getTableSelection(){return this._tableSelection$.getValue()}requestPatternDeletion(e){this._patternDeletionRequested$.next(e)}get patternDeletionRequested$(){return this._patternDeletionRequested$.asObservable()}replaceSequenceBase(e){const t=this._nucleotideSequences$.getValue(),n={};k.forEach((o=>{n[o]=t[o].map((()=>e))})),this._nucleotideSequences$.next(n);const o=this._modificationsWithNumericLabels$.getValue();o.includes(e)||this.updateModificationsWithNumericLabels(o.concat(e))}get patternStateChanged$(){return te.merge(this._patternName$.pipe((0,ne.debounceTime)(300),(0,ne.map)((()=>{}))),this._isAntisenseStrandActive$,this._nucleotideSequences$,this._phosphorothioateLinkageFlags,this._terminalModifications,this._comment$.pipe((0,ne.debounceTime)(300)),this._modificationsWithNumericLabels$)}getSequenceBase(){return this._sequenceBase$.getValue()}uniqueNucleotidesChanged$(){return this.patternStateChanged$.pipe((0,ne.switchMap)((()=>this._uniqueNucleotides$)))}getUniqueNucleotides(){return this._uniqueNucleotides$.getValue()}get svgSaveRequested$(){return this._svgSaveRequested$.asObservable()}requestSvgSave(){this._svgSaveRequested$.next()}setAllPTOLinkages(e){const t=this.getPhosphorothioateLinkageFlags();k.forEach((n=>{t[n]=t[n].map((()=>e))})),this.updatePhosphorothioateLinkageFlags(t)}setPatternConfig(e){this._patternName$.next(e[j.PATTERN_NAME]),this._isAntisenseStrandActive$.next(e[V.IS_ANTISENSE_STRAND_INCLUDED]),this._nucleotideSequences$.next(e[V.NUCLEOTIDE_SEQUENCES]),this._phosphorothioateLinkageFlags.next(e[V.PHOSPHOROTHIOATE_LINKAGE_FLAGS]),this._terminalModifications.next(e[V.STRAND_TERMINUS_MODIFICATIONS]),this._comment$.next(e[j.PATTERN_COMMENT]),this._modificationsWithNumericLabels$.next(e[j.NUCLEOTIDES_WITH_NUMERIC_LABELS])}setLastLoadedPatternConfig(e){this._lastLoadedPatternConfig.next(le().cloneDeep(e))}getPatternConfig(){return{[j.PATTERN_NAME]:this.getPatternName(),[V.IS_ANTISENSE_STRAND_INCLUDED]:this.isAntisenseStrandActive(),[V.NUCLEOTIDE_SEQUENCES]:this.getNucleotideSequences(),[V.PHOSPHOROTHIOATE_LINKAGE_FLAGS]:this.getPhosphorothioateLinkageFlags(),[V.STRAND_TERMINUS_MODIFICATIONS]:this.getTerminalModifications(),[j.PATTERN_COMMENT]:this.getComment(),[j.NUCLEOTIDES_WITH_NUMERIC_LABELS]:this.getModificationsWithNumericLabels()}}setPhosphorothioateLinkageFlag(e,t,n){const o=this.getPhosphorothioateLinkageFlags();o[e][t]=n,this.updatePhosphorothioateLinkageFlags(o)}setNucleotide(e,t,n){const o=this.getNucleotideSequences();o[e][t]=n;const r=this.getModificationsWithNumericLabels();this.updateModificationsWithNumericLabels(r.concat(n)),this.updateNucleotideSequences(o)}get strandsUpdated$(){return te.merge(this._isAntisenseStrandActive$.asObservable().pipe((0,ne.map)((()=>{}))),this._nucleotideSequences$.asObservable().pipe((0,ne.map)((()=>{}))),this._patternLoaded$.asObservable().pipe((0,ne.map)((()=>{})))).pipe((0,ne.debounceTime)(10))}get strandsLinkagesAndTerminalsUpdated$(){return te.merge(this.strandsUpdated$,this._phosphorothioateLinkageFlags.asObservable().pipe((0,ne.map)((()=>{}))),this._terminalModifications.asObservable().pipe((0,ne.map)((()=>{}))))}updateControlsUponPatternLoaded(e){this._patternLoaded$.next(e)}get patternLoaded$(){return this._patternLoaded$.asObservable()}get userSelection$(){return this._patternAuthorSelection$.asObservable().pipe((0,ne.skip)(1))}selectAuthor(e){if("string"!=typeof e)throw new Error("Selected user must be defined");this._patternAuthorSelection$.next(e)}getSelectedAuthor(){return this._patternAuthorSelection$.getValue()}get loadPatternInNewTabRequested$(){return this._loadPatternInNewTabRequested$.asObservable()}requestLoadPatternInNewTab(e){this._loadPatternInNewTabRequested$.next(e)}updateUrlState(e){this._urlStateUpdated$.next(e)}get urlStateUpdated$(){return this._urlStateUpdated$.asObservable()}get patternHasUnsavedChanges$(){return this._patternHasUnsavedChanges$.asObservable()}selectStrandColumn(e,t){this._selectedStrandColumn.next({...this._selectedStrandColumn.getValue(),[e]:t})}getSelectedStrandColumn(e){const t=this._selectedStrandColumn.getValue();return t?t[e]:null}selectIdColumn(e){this._selectedIdColumn.next(e)}getSelectedIdColumn(){return this._selectedIdColumn.getValue()}get updateSvgContainer$(){return this.patternStateChanged$.pipe((0,ne.debounceTime)(100))}}const ue="pattern";class he{constructor(){this.urlSearchParams=new URLSearchParams(window.location.search)}subscribeToObservables(e){e.urlStateUpdated$.subscribe((e=>this.setPatternURL(e))),e.loadPatternInNewTabRequested$.subscribe((e=>{const t=`${window.location.origin}${window.location.pathname}?${ue}=${e}`;window.open(t,"_blank")})),window.addEventListener("popstate",(()=>{this.urlSearchParams=new URLSearchParams(window.location.search);const t=this.getPatternHash();null!==t&&e.requestPatternLoad(t)}))}getPatternHash(){return this.urlSearchParams.get(ue)}setPatternURL(e){null!==e&&""!==e?(this.urlSearchParams.set(ue,e),window.history.pushState({},"",`${window.location.pathname}?${this.urlSearchParams}`)):this.clearPatternURL()}clearPatternURL(){this.urlSearchParams.delete(ue),window.history.pushState({},"",`${window.location.pathname}`)}}var de=n(5072),pe=n.n(de),me=n(7825),fe=n.n(me),ge=n(7659),ye=n.n(ge),be=n(5056),ve=n.n(be),Ce=n(540),xe=n.n(Ce),we=n(1113),Ae=n.n(we),Te=n(9252),Ee={};Ee.styleTagTransform=Ae(),Ee.setAttributes=ve(),Ee.insert=ye().bind(null,"head"),Ee.domAPI=fe(),Ee.insertStyleElement=xe(),pe()(Te.A,Ee),Te.A&&Te.A.locals&&Te.A.locals;class Se{constructor(e){this.eventBus=e,this.columnControlsContainer=P.div([]),this.eventBus.tableSelectionChanged$.subscribe((()=>this.handleTableChoice())),this.refreshColumnControls()}getColumnControlsContainer(){return this.columnControlsContainer}get selectedTable(){return this.eventBus.getTableSelection()}handleTableChoice(){this.refreshColumnControls()}refreshColumnControls(){L()(this.columnControlsContainer).empty(),L()(this.columnControlsContainer).append(this.constructColumnControls())}constructColumnControls(){const e=this.createStrandColumnInput(),t=e.SS,n=e.AS;this.eventBus.antisenseStrandToggled$.subscribe((e=>{L()(n).toggle(e)}));const o=this.createIdColumnInput();return[t,n,o]}createStrandColumnInput(){const e=this.selectedTable?this.selectedTable.columns.names().sort(((e,t)=>e.localeCompare(t))):[];return Object.fromEntries(k.map((t=>{const n=P.input.choice(`${H[t]} column`,{value:e[0],items:e,onValueChanged:e=>this.eventBus.selectStrandColumn(t,e)});return this.eventBus.selectStrandColumn(t,e[0]),[t,n.root]})))}createIdColumnInput(){const e=this.selectedTable?this.selectedTable.columns.names():[],t=P.input.choice("ID column",{value:e[0],items:e,onValueChanged:e=>this.eventBus.selectIdColumn(e)});return this.eventBus.selectIdColumn(e[0]),t.root}}class Ne{constructor(e){this.eventBus=e,this.availableTables=[],this.tableInputContainer=P.div([]),this.subscribeToTableEvents(),this.refreshTableInput()}getTableInputContainer(){return this.tableInputContainer}subscribeToTableEvents(){o.events.onTableAdded.subscribe((e=>this.handleTableAdded(e))),o.events.onTableRemoved.subscribe((e=>this.handleTableRemoved(e))),this.eventBus.tableSelectionChanged$.subscribe((()=>this.handleTableChoice()))}getTableFromEventData(e){if(!e&&e.args&&e.args.dataFrame instanceof r.DataFrame)throw new Error("EventData does not contain a dataframe",e);return e.args.dataFrame}handleTableAdded(e){const t=this.getTableFromEventData(e);this.availableTables.some((e=>e.name===t.name))||(this.availableTables.push(t),this.eventBus.selectTable(t),this.refreshTableInput())}handleTableRemoved(e){const t=this.getTableFromEventData(e);this.availableTables=this.availableTables.filter((e=>e.name!==t.name));const n=this.availableTables[0];this.eventBus.selectTable(n||null),this.refreshTableInput()}refreshTableInput(){const e=this.createTableInput();L()(this.tableInputContainer).empty(),this.tableInputContainer.append(e.root)}createTableInput(){const e=this.eventBus.getTableSelection();return P.input.table("Tables",{value:e,items:this.availableTables,onValueChanged:e=>{null!==e&&this.eventBus.selectTable(e)}})}handleTableChoice(){const e=this.eventBus.getTableSelection();e&&(this.isTableDisplayed(e)||this.displayTable(e))}isTableDisplayed(e){return o.shell.tableNames.includes(e.name)}displayTable(e){const t=o.shell.v;o.shell.addTableView(e),o.shell.v=t}}function Ie(e,t,n,o){const r=function(e,t,n){const o=new Array(e.length+t.filter((e=>e)).length+G.length);o[0]=n["5'"],o[o.length-1]=n["3'"];let r=1;return t[0]&&(o[r]="ps",r++),e.forEach(((e,n)=>{o[n+r]=e,t[n+1]&&(o[n+r+1]="ps",r++)})),o}(e.split("").map(((e,n)=>{const o=function(e,t,n){const o=Object.keys(n.patternAppData)[0],r=n.patternAppData[o][t].substitution;return e.replace(/([AGCTU])/,r)}(e,t[n],br.jsonData);return o})),n,o);return r.join("")}class Me{constructor(e){this.eventBus=e,this.tableInputManager=new Ne(e),this.columnInputManager=new Se(e)}createControls(){const e=P.h1("Bulk convert"),t=this.tableInputManager.getTableInputContainer(),n=this.columnInputManager.getColumnControlsContainer(),o=P.bigButton("Convert",(()=>this.processConvertButtonClick()));return[e,t,n,P.buttonsInput([o])]}processConvertButtonClick(){!function(e){const t=e.getTableSelection();if(!t)return void o.shell.warning("Please select a table");const n=k.filter((t=>!("AS"===t&&!e.isAntisenseStrandActive()))).map((t=>({strand:t,column:e.getSelectedStrandColumn(t)}))).filter((e=>e.column));if(0===n.length)return void o.shell.warning("Select a sense strand column");const r=e.getSelectedIdColumn();if(!r)throw new Error("No ID column selected");t.getCol(r);const i=n.map((e=>({strand:e.strand,column:t.getCol(e.column)})));!function(e,t){const n=t.getNucleotideSequences();return e.every((e=>{const t=n[e.strand].length;return e.column.toList().every((e=>e.length===t))}))}(i,e)?o.shell.warning("Some strands in the table input do not match pattern length"):i.forEach((n=>{const o=n.column,r=n.strand,i=e.getNucleotideSequences()[r],s=e.getTerminalModifications()[r],a=e.getPhosphorothioateLinkageFlags()[r],l=`${e.getPatternName()}(${o.name})`;t.columns.addNewString(l).init((e=>Ie(o.get(e),i,a,s)))}))}(this.eventBus)}}class Pe{constructor(e,t,n){this.eventBus=e,this.initialPatternConfig=t,this.subscriptions=n}create(){return P.divV([P.h1("PTO"),P.divH([this.createAllPtoActivationInput().root,...this.createFirstPtoInputs().map((e=>e.root))],{style:{gap:"12px"}})])}areAllPtoLinkagesSet(e){return k.map((t=>e[t].filter((e=>e)).length)).reduce(((e,t)=>e+t),0)===k.map((e=>this.initialPatternConfig.nucleotideSequences[e].length)).reduce(((e,t)=>e+t),0)+k.filter((t=>e[t].length)).length}createAllPtoActivationInput(){const e=this.initialPatternConfig.phosphorothioateLinkageFlags,t=this.areAllPtoLinkagesSet(e),n=P.input.bool("All PTO",{value:t});n.onInput.subscribe((()=>{const e=n.value;this.eventBus.setAllPTOLinkages(e)}));const o=this.eventBus.phosphorothioateLingeFlagsChanged$.subscribe((()=>{const e=this.eventBus.getPatternConfig().phosphorothioateLinkageFlags,t=this.areAllPtoLinkagesSet(e);n.value=t}));return this.subscriptions.add(o),this.addStyleToPtoInput(n),P.tooltip.bind(n.captionLabel,"Activate all phosphothioates"),n}addStyleToPtoInput(e){const t=e.captionLabel;t.classList.add("ui-label-right"),Object.assign(t.style,{textAlign:"left",maxWidth:"100px",minWidth:"40px",width:"auto"})}createFirstPtoInputs(){return k.map((e=>{if(!this.eventBus.isAntisenseStrandActive()&&"AS"===e)return;const t=this.isFirstPtoActive(e),n=P.input.bool(`First ${e} PTO`,{value:t});n.onInput.subscribe((()=>{const t=n.value;this.eventBus.setPhosphorothioateLinkageFlag(e,0,t)}));const o=this.eventBus.phosphorothioateLingeFlagsChanged$.subscribe((t=>{const o=t[e][0];n.value=o}));return this.subscriptions.add(o),this.addStyleToPtoInput(n),P.tooltip.bind(n.captionLabel,`Activate first phosphothioate in ${e}`),n})).filter((e=>void 0!==e))}isFirstPtoActive(e){return this.initialPatternConfig.phosphorothioateLinkageFlags[e][0]}}class _e{constructor(e,t,n){this.eventBus=e,this.dataManager=t,this.subscriptions=n;const o=this.eventBus.nucleotideSequencesChanged$.subscribe((()=>{this.displayedInputLabels=this.computeDisplayedInputLabels()}));this.subscriptions.add(o)}create(){const e=k.map((e=>this.constructControlsPanel(e)));return P.divH(e,{style:{gap:"24px"}})}constructControlsPanel(e){if(!this.eventBus.isAntisenseStrandActive()&&"AS"===e)return P.div([]);const t=this.constructHeader(),n=this.createControls(e);return P.block([P.h1(`${H[e]}`),t,n],{style:{paddingTop:"12px"}})}constructHeader(){return P.divH([P.div([P.divText("#")],{style:{width:"20px"}}),P.block75([P.divText("Modification")]),P.div([P.divText("PTO")])])}createControls(e){const t=this.createNucleobaseInputs(e),n=this.createLabelDivs(e),o=this.createPTOFlagInputs(e);return P.div(t.map(((e,t)=>P.divH([n[t],P.block75([e.root]),o[t].root],{style:{alignItems:"center"}}))))}createNucleobaseInputs(e){const t=this.dataManager.fetchAvailableNucleotideBases().sort(((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase())));return this.eventBus.getNucleotideSequences()[e].map(((n,o)=>{const r=P.input.choice("",{value:n,items:t});return r.onInput.subscribe((()=>{const t=r.value;this.eventBus.setNucleotide(e,o,t)})),r}))}createPTOFlagInputs(e){return this.eventBus.getPhosphorothioateLinkageFlags()[e].slice(1).map(((t,n)=>{const o=P.input.bool("",{value:t});o.onInput.subscribe((()=>{const t=o.value;this.eventBus.setPhosphorothioateLinkageFlag(e,n+1,t)}));const r=this.eventBus.phosphorothioateLingeFlagsChanged$.subscribe((t=>{const r=t[e][n+1];o.value=r}));return this.subscriptions.add(r),o}))}computeDisplayedInputLabels(){const e=this.eventBus.getNucleotideSequences(),t=new Map;return k.forEach((n=>{let o=1;const r=e[n].map((e=>{if(oe(e))return"";const t=String(o);return o++,t}));t.set(n,r)})),t}createLabelDivs(e){const t=this.createLabels(e).map((e=>P.div([e],{style:{width:"20px"}}))),n=this.eventBus.nucleotideSequencesChanged$.subscribe((()=>{this.createLabels(e).forEach(((e,n)=>{L()(t[n]).empty(),L()(t[n]).append(e)}))}));return this.subscriptions.add(n),t}createLabels(e){return this.eventBus.getNucleotideSequences()[e].map(((t,n)=>{const o=this.displayedInputLabels.get(e)[n];return P.label(o)}))}}class Le{constructor(){this.rxjsSubscriptions=[],this.dgSubscriptions=[]}add(e){e instanceof te.Subscription?this.rxjsSubscriptions.push(e):this.dgSubscriptions.push(e)}unsubscribeAll(){for(const e of[this.rxjsSubscriptions,this.dgSubscriptions])e.forEach((e=>e.unsubscribe())),e.length=0}}class Oe{constructor(e,t){this.eventBus=e,this.dataManager=t,this.subscriptions=new Le}static open(e,t){Oe.isDialogOpen||(Oe.instance||(Oe.instance=new Oe(e,t)),Oe.instance.openDialog())}openDialog(){this.initialPatternConfig=le().cloneDeep(this.eventBus.getPatternConfig()),Oe.isDialogOpen=!0,this.createDialog().show()}createDialog(){const e=P.divV([]);this.subscriptions.add(this.eventBus.strandsUpdated$.subscribe((()=>this.onStrandsUpdated(e))));const t=P.dialog("Edit strands").add(e).onOK((()=>{})).onCancel((()=>this.resetToInitialState()));return this.subscriptions.add(t.onClose.subscribe((()=>{Oe.isDialogOpen=!1,this.subscriptions.unsubscribeAll()}))),t}onStrandsUpdated(e){const t=new Pe(this.eventBus,this.initialPatternConfig,this.subscriptions).create(),n=new _e(this.eventBus,this.dataManager,this.subscriptions).create();L()(e).empty(),L()(e).append(t,n)}resetToInitialState(){this.eventBus.setPatternConfig(this.initialPatternConfig)}}Oe.isDialogOpen=!1;class Re{constructor(e){this.eventBus=e,this.subscriptions=new Le}static open(e){Re.isDialogOpen||(Re.instance||(Re.instance=new Re(e)),Re.instance.openDialog())}openDialog(){this.initialPatternConfig=le().cloneDeep(this.eventBus.getPatternConfig()),Re.isDialogOpen=!0,this.createDialog().show()}createDialog(){const e=P.divV([]);this.subscriptions.add(this.eventBus.strandsUpdated$.subscribe((()=>this.onStrandsUpdated(e))));const t=P.dialog("Edit terminal modifications").add(e).onOK((()=>{})).onCancel((()=>this.resetToInitialState()));return this.subscriptions.add(t.onClose.subscribe((()=>{Re.isDialogOpen=!1,this.subscriptions.unsubscribeAll()}))),t}onStrandsUpdated(e){const t=new $e(this.eventBus).create();L()(e).empty(),L()(e).append(t)}resetToInitialState(){this.eventBus.setPatternConfig(this.initialPatternConfig)}}Re.isDialogOpen=!1;class $e{constructor(e){this.eventBus=e}create(){const e=k.map((e=>this.constructControlsPanel(e)));return P.divH(e,{style:{gap:"24px"}})}constructControlsPanel(e){if(!this.eventBus.isAntisenseStrandActive()&&"AS"===e)return P.div([]);const t=this.createInputs(e);return P.block([P.h1(`${H[e]}`),t],{style:{paddingTop:"12px"}})}createInputs(e){const t=("SS"===e?[...G].reverse():G).map((t=>this.createInputForTerminus(e,t)));return P.form(t)}createInputForTerminus(e,t){const n=this.eventBus.getTerminalModifications()[e][t],o=P.input.textArea(t,{value:n});return this.applyStylingToInput(o),o.onInput.subscribe((()=>{const n=o.value;null!==n&&this.eventBus.updateTerminusModification(e,t,n)})),o}applyStylingToInput(e){const t=e.root.getElementsByTagName("textarea")[0];L()(t).css("resize","none")}}class De{constructor(e,t){this.eventBus=e,this.dataManager=t}createControls(){const e=this.createAntisenseStrandToggle(),t=this.createStrandLengthInputs(),n=t.SS.root,o=t.AS.root,r=this.createSequenceBaseInput().root,i=this.createPatternCommentInput().root,s=this.createPatternNameInputBlock(),a=this.createEditPatternButton(),l=this.createEditTerminalModificationsButton();return[P.h1("Edit"),e,n,o,r,s,i,P.buttonsInput([l,a])]}createEditPatternButton(){const e=P.button("Edit strands",(()=>Oe.open(this.eventBus,this.dataManager)));return P.tooltip.bind(e,"Edit strand modifications and PTOs"),e}createEditTerminalModificationsButton(){const e=P.button("Edit terminals",(()=>Re.open(this.eventBus)));return P.tooltip.bind(e,"Edit terminal modifications"),L()(e).css("margin-right","20px"),e}createAntisenseStrandToggle(){const e=P.input.toggle(`${H.AS} strand`,{value:this.eventBus.isAntisenseStrandActive()});return e.onInput.subscribe((()=>this.eventBus.toggleAntisenseStrand(e.value))),this.eventBus.patternLoaded$.subscribe((()=>{e.value=this.eventBus.isAntisenseStrandActive()})),e.setTooltip("Toggle antisense strand"),e.root}createStrandLengthInputs(){const e=e=>{const n=this.eventBus.getNucleotideSequences()[e].length,o=P.input.int(`${H[e]} length`,{value:n});return o.onInput.subscribe((()=>t(e,o))),this.eventBus.nucleotideSequencesChanged$.subscribe((()=>{o.value=this.eventBus.getNucleotideSequences()[e].length})),o.setTooltip(`Number of nucleotides in ${e}, including overhangs`),[e,o]},t=(e,t)=>{const n=t.value;null!==n&&(n<=0&&(o.shell.warning("Sequence length must be greater than 0"),t.value=1),n>34&&(o.shell.warning("Sequence length must be less than 35"),t.value=34),this.eventBus.updateStrandLength(e,t.value))},n=Object.fromEntries(k.map((t=>e(t))));return this.eventBus.antisenseStrandToggled$.subscribe((e=>{L()(n.AS.root).toggle(e)})),n}createSequenceBaseInput(){const e=this.dataManager.fetchAvailableNucleotideBases().sort(((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase()))),t=this.dataManager.fetchDefaultNucleobase(),n=P.input.choice("Sequence basis",{value:t,items:e});return n.onInput.subscribe((()=>this.eventBus.replaceSequenceBase(n.value))),this.eventBus.nucleotideSequencesChanged$.subscribe((()=>{n.value=this.eventBus.getSequenceBase()})),n.setTooltip("Most frequent nucleobase in the strands"),n}createPatternCommentInput(){const e=P.input.textArea("Comment",{value:this.eventBus.getComment()});return L()(e.root).addClass("st-pattern-text-input"),e.onInput.subscribe((()=>this.eventBus.updateComment(e.value))),this.eventBus.patternLoaded$.subscribe((()=>{e.value=this.eventBus.getComment()})),e}createPatternNameInputBlock(){const e=P.input.textArea("Pattern name",{value:this.eventBus.getPatternName()});return L()(e.root).addClass("st-pattern-text-input"),e.onInput.subscribe((()=>this.eventBus.updatePatternName(e.value))),this.eventBus.patternLoaded$.subscribe((()=>{e.value=this.eventBus.getPatternName()})),e.setTooltip("Name under which pattern will be saved"),e.root}}class Be{constructor(e,t){this.eventBus=e,this.dataManager=t,this.subscriptions=new Le,this.authorSelectedByUser=!1,this.eventBus.patternLoadRequested$.subscribe((e=>this.handlePatternChoice(e))),this.eventBus.patternDeletionRequested$.subscribe((async e=>{await this.dataManager.deletePattern(e,this.eventBus)}))}async handlePatternChoice(e){let t=await this.dataManager.getPatternConfig(e);null===t&&(t=this.dataManager.getDefaultPatternConfig()),this.eventBus.setPatternConfig(t),this.eventBus.updateControlsUponPatternLoaded(e),this.eventBus.setLastLoadedPatternConfig(t)}isCurrentUserSelected(){return this.eventBus.getSelectedAuthor()!==this.dataManager.getOtherUsersAuthorshipCategory()}createControls(){const e=this.getPatternInputsContainer();return[P.h1("Load"),e]}getPatternInputsContainer(){const e=P.divH(this.createPatternInputs());return this.eventBus.patternListUpdated$.subscribe((()=>{this.subscriptions.unsubscribeAll(),L()(e).empty(),L()(e).append(this.createPatternInputs())})),e}createPatternInputs(){const e=this.createAuthorChoiceInput(),t=this.createPatternChoiceInputContainer(),n=this.createDeletePatternButton();return[e.root,t,n]}createPatternChoiceInputContainer(){const e=this.createPatternChoiceInput(),t=P.div([e.root]),n=this.eventBus.userSelection$.subscribe((()=>{L()(t).empty(),L()(t).append(this.createPatternChoiceInput().root)}));return this.subscriptions.add(n),t}createAuthorChoiceInput(){const e=[this.dataManager.getCurrentUserAuthorshipCategory()];this.dataManager.getOtherUsersPatternNames().length>0&&e.push(this.dataManager.getOtherUsersAuthorshipCategory());const t=P.input.choice("Author",{value:this.eventBus.getSelectedAuthor(),items:e});return t.onInput.subscribe((()=>{if(this.authorSelectedByUser=!0,null===t.value)throw new Error("author choice must be non-null");this.eventBus.selectAuthor(t.value)})),this.setAuthorChoiceInputStyle(t),t.setTooltip("Select pattern author"),t}setAuthorChoiceInputStyle(e){L()(e.input).css({"max-width":"100px","min-width":"100px"}),L()(e.root).css({"padding-right":"30px","padding-left":"30px"})}createPatternChoiceInput(){const e=this.isCurrentUserSelected()?this.dataManager.getCurrentUserPatternNames():this.dataManager.getOtherUsersPatternNames();if(this.authorSelectedByUser){const t=this.dataManager.getPatternHash(e[0],this.isCurrentUserSelected());this.eventBus.requestPatternLoad(t),this.eventBus.updateUrlState(t),this.authorSelectedByUser=!1}const t=this.getPatternName(e),n=P.input.choice("Pattern",{value:t,items:e});return n.setTooltip("Select pattern to load"),L()(n.input).css({"max-width":"100px","min-width":"100px"}),this.subscriptions.add(n.onInput.subscribe((()=>{const e=this.dataManager.getPatternHash(n.value,this.isCurrentUserSelected());this.eventBus.requestPatternLoad(e),this.eventBus.updateUrlState(e)}))),this.subscriptions.add(this.eventBus.patternLoaded$.subscribe((()=>{const t=this.eventBus.getPatternName();n.value!==t&&(n.value=this.getPatternName(e))}))),n}getPatternName(e){return e.find((e=>e.split(" (")[0]===this.eventBus.getPatternName()))??e[0]}createDeletePatternButton(){const e=P.button(P.iconFA("trash-alt"),(()=>{this.eventBus.getPatternName()!==this.dataManager.getDefaultPatternName()?this.showDeletePatternDialog():o.shell.warning("Cannot delete example pattern")}));P.tooltip.bind(e,"Delete pattern from user storage");const t=this.eventBus.userSelection$.subscribe((()=>{e.disabled=!this.isCurrentUserSelected()}));return this.subscriptions.add(t),e}showDeletePatternDialog(){const e=P.dialog("Delete pattern"),t=this.eventBus.getPatternName();e.add(P.divText(`Are you sure you want to delete pattern ${t}?`)),e.onOK((()=>this.eventBus.requestPatternDeletion(t))),e.show()}}class Fe{constructor(e,t){this.eventBus=e,this.dataManager=t}getLayout(){const e=new Be(this.eventBus,this.dataManager),t=new De(this.eventBus,this.dataManager),n=new Me(this.eventBus),o=e.createControls(),r=t.createControls(),i=n.createControls(),s=P.div(o);L()(s).css({"padding-bottom":"20px"});const a=P.div([...r,...i],"ui-form"),l=P.div([s,a]);return L()(l).css({padding:"25px"}),P.box(l,{style:{maxWidth:"450px"}})}}var ke=n(9146);class He{constructor(e,t,n){this.svgElementFactory=e,this.config=t,this.yShift=n}shiftElements(e){this.svgElements.forEach((t=>{const n=t.getAttribute("transform")||"",o=`translate(${e.x},${e.y})`;t.setAttribute("transform",`${n} ${o}`)}))}}class Ge{constructor(){}static getInstance(){return Ge.instance||(Ge.instance=new Ge,Ge.instance.canvas=document.createElement("canvas")),Ge.instance}static getTextDimensions(e,t){const n=Ge.getInstance().canvas.getContext("2d");if(!n)throw new Error("Canvas 2D context is not available");return n.font=`${t}px Arial`,{width:1.1*n.measureText(e).width,height:1.1*t}}}function Ue(e){const t=Object.keys(br.jsonData.patternAppData)[0];if(!t)throw new Error(`No format found in '${h}'`);return br.jsonData.patternAppData[t][e].color||""}class Ve extends He{constructor(e,t,n){super(e,t,n);const o=k.filter((e=>t.nucleotideSequences[e].length>0));this.strands=o.map((e=>new je(this.svgElementFactory,t,n,e))),this.terminalModifications=o.map(((e,o)=>new We(this.svgElementFactory,t,n,e,this.strands[o]))),this.labels=o.map(((e,o)=>new qe(this.svgElementFactory,t,n,e,this.terminalModifications[o])))}get svgElements(){return[...this.strands,...this.terminalModifications,...this.labels].map((e=>e.svgElements)).flat()}getContentWidth(){return Math.max(...this.labels.map((e=>e.getContentWidth())))}getContentHeight(){return this.strands.reduce(((e,t)=>e+t.getContentHeight()),0)}}class je extends He{constructor(e,t,n,o){super(e,t,n),this.svgElementFactory=e,this.config=t,this.yShift=n,this.strand=o,this.nucleotideNumericLabels=this.computeNucleotideNumericLabels(),"AS"===this.strand&&(this.config.phosphorothioateLinkageFlags[this.strand].reverse(),this.config.nucleotideSequences[this.strand].reverse(),this.nucleotideNumericLabels.reverse()),this._svgElements=[this.createStrandCircles(),this.createPTOLinkageStars()].flat()}computeNucleotideNumericLabels(){let e=0;return this.config.nucleotideSequences[this.strand].map((t=>oe(t)?null:(e++,e)))}get svgElements(){return this._svgElements}getStrandCircleYShift(){return ze(this.strand,this.yShift)}createStrandCircles(){const e={x:80,y:this.getStrandCircleYShift()};return this.config.nucleotideSequences[this.strand].map(((t,n)=>this.createNucleotideElementGroup(t,n,e))).flat()}createNucleotideElementGroup(e,t,n){return[...this.createNucleotideCircleElements(e,t,n),this.config.nucleotidesWithNumericLabels.includes(e)?this.createNucleotideNumericLabel(t,n):null].filter((e=>null!==e))}createNucleotideCircleElements(e,t,n){const o=Ue(e),r={...n,x:n.x+30*t};return[this.svgElementFactory.createCircleElement(r,15,o),this.createNucleotideLetterLabel(t,n,e)]}getNucleotideCircleCenterPosition(e,t){return{x:t.x+30*e,y:t.y}}createNucleotideLetterLabel(e,t,n){if(!f.AL.includes(n))return null;const o=function(e){return!oe(e)&&f.AL.includes(e)?e:""}(n),r=function(e){const t=Ue(e),n=t.match(/\d+/g)?.map(Number);if(!n||n.length<3)return"#ffffff";const[o,r,i]=n;return.299*o+.587*r+.114*i>186?"#333333":"#ffffff"}(n),i=this.getPositionForNucleotideLabel(e,t);return this.svgElementFactory.createTextElement(o,i,17,r)}getPositionForNucleotideLabel(e,t){const n=this.getNucleotideCircleCenterPosition(e,t),o=Ge.getTextDimensions("A",17);return{x:n.x-o.width/2,y:n.y+o.height/3}}getNumericLabelYShift(e){return"SS"===this.strand?e.y-20:e.y+15+5+15}createNucleotideNumericLabel(e,t){const n=this.nucleotideNumericLabels[e];if(null===n)return null;const o=Ge.getTextDimensions(n.toString(),15).width,r={x:t.x+30*e-o/2,y:this.getNumericLabelYShift(t)};return this.svgElementFactory.createTextElement(n.toString(),r,15,"var(--grey-6)")}createPTOLinkageStars(){const e=this.config.phosphorothioateLinkageFlags[this.strand],t=this.getStrandCircleYShift()+12;return e.map(((e,n)=>{if(!e)return null;const o={x:65+30*n,y:t};return this.svgElementFactory.createStarElement(o,"red")})).filter((e=>null!==e))}getContentWidth(){return 30*this.config.nucleotideSequences[this.strand].length}getContentHeight(){return 62}}class qe extends He{constructor(e,t,n,o,r){super(e,t,n),this.svgElementFactory=e,this.config=t,this.yShift=n,this.strand=o,this.terminalModifications=r,this._svgElements=this.createSVGElements()}createSVGElements(){return[this.createLeftLabel(),this.createRightLabel()]}getLeftLabelWidth(){return 55}getRightLabelWidth(){return 20}createLeftLabel(){const e="SS"===this.strand?"5'":"3'",t=`${this.strand}: ${e} `,n=Ge.getTextDimensions(t,17),o={x:10,y:ze(this.strand,this.yShift)+n.height/3};return this.svgElementFactory.createTextElement(t,o,17,"var(--grey-6)")}createRightLabel(){const e=" "+("SS"===this.strand?"3'":"5'"),t=Ge.getTextDimensions(e,17),n={x:65+this.terminalModifications.getContentWidth()+5,y:ze(this.strand,this.yShift)+t.height/3};return this.svgElementFactory.createTextElement(e,n,17,"var(--grey-6)")}get svgElements(){return this._svgElements}getContentWidth(){return this.terminalModifications.getContentWidth()+this.getLeftLabelWidth()+this.getRightLabelWidth()+10}getContentHeight(){return this.terminalModifications.getContentHeight()}}class We extends He{constructor(e,t,n,o,r){super(e,t,n),this.svgElementFactory=e,this.config=t,this.yShift=n,this.strand=o,this.strandSvgWrapper=r,this._svgElements=this.createSVGElements()}createSVGElements(){return this.createTerminalModifications()}getTerminalModification(e){return this.config.strandTerminusModifications[this.strand][e]}getTerminalModificationTextDimensions(e){const t=this.getTerminalModification(e);return Ge.getTextDimensions(t,17)}getLeftTerminus(){return"SS"===this.strand?"5'":"3'"}createTerminalModification(e){const t=this.getTerminalModification(e),n=this.getTerminalModificationTextDimensions(e),o=e===this.getLeftTerminus(),r={x:o?65:65+this.getTerminalModificationTextDimensions(this.getLeftTerminus()).width+this.strandSvgWrapper.getContentWidth(),y:ze(this.strand,this.yShift)+n.height/3};return o&&this.strandSvgWrapper.shiftElements({x:n.width,y:0}),this.svgElementFactory.createTextElement(t,r,17,"red")}createTerminalModifications(){return("AS"===this.strand?G:Array.from(G).reverse()).map((e=>this.createTerminalModification(e)))}get svgElements(){return this._svgElements}getContentWidth(){return this.strandSvgWrapper.getContentWidth()+G.map((e=>this.getTerminalModificationTextDimensions(e).width)).reduce(((e,t)=>e+t),0)}getContentHeight(){return this.strandSvgWrapper.getContentHeight()}}function ze(e,t){return"SS"===e?t+5+15+15:t+52+10+15}class Ye{constructor(){this.xmlNamespace="http://www.w3.org/2000/svg"}createElement(e){return document.createElementNS(this.xmlNamespace,e)}setAttributes(e,t){Object.entries(t).forEach((([t,n])=>{e.setAttribute(t,String(n))}))}createCanvas(e,t){const n=this.createElement("svg");return this.setAttributes(n,{id:"mySvg",width:e,height:t}),n}createCircleElement(e,t,n){const o=this.createElement("circle");return this.setAttributes(o,{cx:e.x,cy:e.y,r:t,fill:n}),o}createTextElement(e,t,n,o){const r=this.createElement("text");return this.setAttributes(r,{x:t.x,y:t.y,"font-size":n,"font-weight":"normal","font-family":"Arial",fill:o}),r.textContent=e,r}createStarElement(e,t){const n=this.createElement("polygon"),o=this.computeStarVertexCoordinates(e).map((e=>e.join(","))).join(" ");return this.setAttributes(n,{points:o,fill:t}),n}computeStarVertexCoordinates(e){const t=Math.PI/5,n=-t/2;return Array.from({length:10},((o,r)=>{const i=r%2==0?6:3,s=r*t+n;return[e.x+Math.cos(s)*i,e.y+Math.sin(s)*i]}))}createRectangleElement(e,t,n,o){const r=this.createElement("rect");return this.setAttributes(r,{x:e.x,y:e.y,width:t,height:n,fill:o}),r}}class Ke extends He{constructor(e,t,n){super(e,t,n),this.svgElementFactory=e,this.config=t,this.yShift=n,this._svgElements=[],this.titleText=this.getTitleText(),this._svgElements=[this.getTitle()]}get svgElements(){return this._svgElements}getTitle(){return this.svgElementFactory.createTextElement(this.titleText,{x:15,y:this.yShift+17},17,"black")}getContentWidth(){return Ge.getTextDimensions(this.titleText,17).width}getContentHeight(){return Ge.getTextDimensions(this.titleText,17).height}getTitleText(){const e=`${this.config.nucleotideSequences.SS.length}`,t=this.config.isAntisenseStrandIncluded?`/${this.config.nucleotideSequences.AS.length}`:"";return`${this.config.patternName} for ${e}${t}-mer`}}class Qe extends He{constructor(e,t,n){super(e,t,n),this._svgElements=[];const{elements:o,width:r}=this.createLegendItems();this._svgElements=o,this.width=r}isPhosphorothioatePresent(){return Object.values(this.config.phosphorothioateLinkageFlags).flat().some((e=>e))}getModificationTypesList(){return[...new Set(Object.values(this.config.nucleotideSequences).flat().sort(((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase()))))]}get svgElements(){return this._svgElements}createLegendItem(e,t){const n={x:t,y:this.yShift-6},o=e.includes("linkage")?this.svgElementFactory.createStarElement(n,"red"):this.svgElementFactory.createCircleElement(n,6,Ue(e));t+=12;const r={y:this.yShift,x:t};return{elements:[o,this.svgElementFactory.createTextElement(e,r,15,"var(--grey-6)")],width:12+Ge.getTextDimensions(e,15).width}}createLegendItems(){let e=10;const t=[],n=t=>e+=t+15;if(this.isPhosphorothioatePresent()){const{elements:o,width:r}=this.createLegendItem("PTO linkage",e);n(r),t.push(o)}return this.getModificationTypesList().forEach((o=>{const{elements:r,width:i}=this.createLegendItem(o,e);n(i),t.push(r)})),{elements:t.flat(),width:e}}getContentHeight(){return 20}getContentWidth(){return this.width}}class Je{constructor(e){this.svgElementFactory=new Ye;const t=le().cloneDeep(e);let n=10;this.title=new Ke(this.svgElementFactory,t,n),n+=this.title.getContentHeight(),this.strands=new Ve(this.svgElementFactory,t,n),n+=this.strands.getContentHeight()+10,this.legend=new Qe(this.svgElementFactory,t,n)}renderPattern(){const e=this.getGlobalWidth(),t=this.getGlobalHeight(),n=this.svgElementFactory.createCanvas(e,t),o=[this.title,this.strands,this.legend].map((e=>e.svgElements)).flat();return n.append(...o),n}getGlobalWidth(){const e=[this.title,this.strands,this.legend];return Math.max(...e.map((e=>e.getContentWidth())))}getGlobalHeight(){return[this.title,this.strands,this.legend].reduce(((e,t)=>e+t.getContentHeight()),10)}}class Xe{constructor(e){this.eventBus=e,this.svgDisplayDiv=P.div([]),e.updateSvgContainer$.subscribe((()=>this.updateSvgContainer())),e.svgSaveRequested$.subscribe((()=>this.saveSvgAsPng()))}static createSvgDiv(e){return new Xe(e).svgDisplayDiv}updateSvgContainer(){$(this.svgDisplayDiv).empty();const e=this.eventBus.getPatternConfig();this.svgElement=this.createSvg(e),this.svgDisplayDiv.append(this.svgElement)}createSvg(e){return new Je(e).renderPattern()}saveSvgAsPng(){const e=this.eventBus.getPatternName();ke.saveSvgAsPng(this.svgElement,e,{backgroundColor:"white"})}}class Ze{constructor(e){this.eventBus=e,this.togglesContainer=P.div([]),this.eventBus.uniqueNucleotidesChanged$().subscribe((()=>{this.updateContainer()}))}getContainer(){return this.togglesContainer}updateContainer(){L()(this.togglesContainer).empty(),L()(this.togglesContainer).append(this.createInputs())}createInputs(){const e=this.eventBus.getUniqueNucleotides().filter((e=>!oe(e))).map((e=>this.createSingleInput(e)));return e.sort(((e,t)=>e.captionLabel.textContent.localeCompare(t.captionLabel.textContent))),P.divH(e.map((e=>e.root)))}createSingleInput(e){const t=this.eventBus.getModificationsWithNumericLabels().includes(e),n=P.input.bool(e,{value:t,onValueChanged:t=>this.handleNumericLabelToggle(e,t)});return L()(n.root).css("padding-right","20px"),n.setTooltip(`Show numeric labels for ${e}`),n}handleNumericLabelToggle(e,t){const n=this.eventBus.getModificationsWithNumericLabels();if(n.includes(e)===t)return;const o=t?n.concat(e):n.filter((t=>t!==e));this.eventBus.updateModificationsWithNumericLabels(o)}}class et{constructor(e,t){this.eventBus=e,this.dataManager=t,this.subscriptions=new Le}createContainer(){return P.div([P.h1("Translation example"),this.createTranslationExamples()],{style:{paddingTop:"20px"}})}createTranslationExamples(){const e=P.divH([...this.getExampleElements()],"ui-form");return this.eventBus.antisenseStrandToggled$.subscribe((()=>{this.subscriptions.unsubscribeAll(),L()(e).empty(),L()(e).append(this.getExampleElements())})),e}getExampleElements(){return k.map((e=>new tt(e,this.eventBus,this.subscriptions).create()))}}class tt{constructor(e,t,n){this.strand=e,this.eventBus=t,this.subscriptions=n}create(){return this.eventBus.isAntisenseStrandActive()||"AS"!==this.strand?(this.inputExample=this.createInputExample(),this.outputExample=this.createOutputExample(this.inputExample.value),this.subscribeToEvents(),P.block50([P.h2(H[this.strand]),this.inputExample.root,this.outputExample.root],{style:{paddingRight:"20px"}})):P.div([])}subscribeToEvents(){const e=this.eventBus.strandsLinkagesAndTerminalsUpdated$.subscribe((()=>{const e=this.generateExampleSequence();this.inputExample.value=e,this.outputExample.value=this.computeOutputValue(e)}));"AS"===this.strand&&this.subscriptions.add(e)}createInputExample(){const e=this.createTextInputForExamples(),t=this.generateExampleSequence();return e.value=t,e.setTooltip(`Example raw nucleotides input for ${H[this.strand]}`),e}generateExampleSequence(){return this.eventBus.getNucleotideSequences()[this.strand].map(((e,t)=>f.AL[t%f.AL.length])).join("")}createOutputExample(e){const t=this.createTextInputForExamples();return t.value=this.computeOutputValue(e),t.setTooltip(`Pattern applied to the example input for ${H[this.strand]}`),t}computeOutputValue(e){const t=this.eventBus.getNucleotideSequences()[this.strand],n=this.eventBus.getTerminalModifications()[this.strand];return Ie(e,t,this.eventBus.getPhosphorothioateLinkageFlags()[this.strand],n)}createTextInputForExamples(){const e=P.input.textArea("",{value:""});return this.applyStylingToInput(e),e}applyStylingToInput(e){const t=e.root.getElementsByTagName("textarea")[0];t.setAttribute("readonly","true"),L()(t).css("resize","none"),L()(e.root).css("opacity","75%")}}class nt{constructor(e,t){this.eventBus=e,this.dataManager=t,this.svgDisplay=Xe.createSvgDiv(e)}getLayout(){const e=new Ze(this.eventBus).getContainer(),t=this.generateDownloadControls(),n=new et(this.eventBus,this.dataManager).createContainer();return P.panel([this.svgDisplay,e,t,n],{style:{overflowX:"scroll",padding:"12px 24px"}})}generateDownloadControls(){return P.divH([this.createSavePatternButton(),this.createDownloadPngButton(),this.createShareLinkButton(),this.createInfoButton()],{style:{gap:"12px",marginTop:"12px"}})}createDownloadPngButton(){const e=P.button("Get PNG",(()=>this.eventBus.requestSvgSave()));return P.tooltip.bind(e,"Download pattern as PNG"),e}createInfoButton(){const e=P.button(P.iconFA("info-circle"),(()=>this.openInfoDialog()));return this.eventBus.patternHasUnsavedChanges$.subscribe((t=>{e.disabled=t})),P.tooltip.bind(e,"View pattern metadata"),e}async openInfoDialog(){let e=this.dataManager.getCurrentUserName(),t=this.dataManager.getDefaultPatternName(),n=K,r=K;const i=new URLSearchParams(window.location.search).get("pattern");if(null!==i){const s=await this.dataManager.getPatternRecordByHash(i);if(null!==s){const i=s[q.AUTHOR_ID];if(e=(await o.dapi.users.find(i)).friendlyName,t=s[q.PATTERN_CONFIG][j.PATTERN_NAME],void 0!==s[q.DATE]){const e=s[q.DATE][W.CREATE];void 0!==e&&(n=e);const t=s[q.DATE][W.MODIFY];void 0!==t&&(r=t)}}}const s=P.divV([P.divText(`Pattern Name: ${t}`),P.divText(`Author: ${e}`),P.divText(`Created: ${rt(new Date(n))}`),P.divText(`Modified: ${rt(new Date(r))}`)]);o.shell.info(s)}createShareLinkButton(){const e=P.button(P.iconFA("link"),(()=>navigator.clipboard.writeText(window.location.href).then((()=>o.shell.info("Link to pattern copied to clipboard")))));return this.eventBus.patternHasUnsavedChanges$.subscribe((t=>{e.disabled=t})),P.tooltip.bind(e,"Share pattern link"),e}createSavePatternButton(){const e=P.button("Save",(()=>this.processSaveButtonClick()));return this.eventBus.patternHasUnsavedChanges$.subscribe((t=>{e.disabled=!t})),P.tooltip.bind(e,"Save pattern to user storage"),e}processSaveButtonClick(){const e=this.eventBus.getPatternName();e!==this.dataManager.getDefaultPatternName()?""!==e?this.dataManager.savePatternToUserStorage(this.eventBus).then((()=>{o.shell.info(`Pattern ${e} saved`)})).catch((e=>this.handleErrorWhileSavingPattern(e))):o.shell.warning("Insert pattern name"):o.shell.warning("Cannot save default pattern")}handleErrorWhileSavingPattern(e){e instanceof Q?new ot(this.eventBus,this.dataManager).show():e instanceof J?o.shell.warning(P.div([P.divText("Pattern already exists"),P.button("Load",(()=>{const t=e.message;this.eventBus.requestLoadPatternInNewTab(t)}))])):console.error("Error while saving pattern",e)}}class ot{constructor(e,t){this.eventBus=e,this.dataManager=t}show(){const e=this.eventBus.getPatternName(),t=P.dialog(`Pattern "${e}" already exists`);t.add(P.divText(`Pattern "${e}" already exists. Do you want to overwrite it?`)),t.show(),t.onOK((()=>this.processOverwriteNamesakePattern()))}processOverwriteNamesakePattern(){const e=this.eventBus.getPatternName();this.dataManager.overwriteExistingPatternInUserStorage(this.eventBus).then((()=>{o.shell.info(`Pattern ${e} overwritten`)})).catch((e=>{console.error("Error while overwriting pattern in user storage",e),o.shell.error("Error while overwriting pattern")}))}}function rt(e){return e.toLocaleString().split(":").slice(0,-1).join(":")}class it extends F{constructor(e){super("Oligo Pattern"),this.th=e}getContent(){return async function(){const e=await ee.getInstance(),t=new he,n=await async function(e,t){const n=t.getPatternHash();if(!n)return t.clearPatternURL(),e.getDefaultPatternRecord();let o=await e.getPatternRecordByHash(n);return o||(t.clearPatternURL(),o=e.getDefaultPatternRecord()),o}(e,t),o=new ce(e,n);t.subscribeToObservables(o);const r=new Fe(o,e).getLayout(),i=new nt(o,e).getLayout();return P.splitH([r,i],{},!0)}()}}var st=n(8507),at={};function lt(e){var t;return"string"==typeof e||e instanceof String?e:("object"==typeof e||e instanceof Object)&&"$thrownJsError"in e?lt(e.$thrownJsError):e instanceof Error?null!==(t=e.stack)&&void 0!==t?t:e.message:e.toString()}at.styleTagTransform=Ae(),at.setAttributes=ve(),at.insert=ye().bind(null,"head"),at.domAPI=fe(),at.insertStyleElement=xe(),pe()(st.A,at),st.A&&st.A.locals&&st.A.locals;var ct,ut=n(2074),ht={};ht.styleTagTransform=Ae(),ht.setAttributes=ve(),ht.insert=ye().bind(null,"head"),ht.domAPI=fe(),ht.insertStyleElement=xe(),pe()(ut.A,ht),ut.A&&ut.A.locals&&ut.A.locals;class dt{constructor(e,t,n=!0){this.textInputBase=e,this.painter=t,L()(this.root).addClass("st-colored-text-input"),n&&this.textInputBase.onChanged.subscribe((()=>{L()(this.textArea).css("height",0),L()(this.textArea).css("height",this.textArea.scrollHeight+"px")})),this.highlights=P.div([]),this.root.appendChild(this.highlights),this.colorize(),this.textInputBase.onChanged.subscribe((()=>this.colorize()))}get textArea(){return this.textInputBase.root.getElementsByTagName("textarea").item(0)}get inputBase(){return this.textInputBase}get root(){return this.textInputBase.root}colorize(){const e=this.painter(this.textInputBase.value);this.highlights.innerHTML="",e.forEach((e=>this.highlights.appendChild(e)))}}!function(e){e.TYPE="V2000",e[e.NUM_OF_HEADER_LINES=3]="NUM_OF_HEADER_LINES",e[e.NUM_OF_COUNTS_DIGITS=3]="NUM_OF_COUNTS_DIGITS",e[e.ATOM_TYPE_COL=4]="ATOM_TYPE_COL",e[e.FIRST_BONDED_ATOM_COL=1]="FIRST_BONDED_ATOM_COL",e[e.BOND_TYPE_COL=3]="BOND_TYPE_COL",e[e.RGP_SHIFT=8]="RGP_SHIFT",e[e.MAX_ATOM_COUNT=999]="MAX_ATOM_COUNT",e.RGP_LINE_START="M RGP",e.ATOM_ALIAS_LINE_START="A ",e.END="M END"}(ct||(ct={}));class pt{constructor(e){this.init(e)}init(e){this.fileContent=e.replace(/\r/g,""),this._atomCount=void 0,this._atomTypes=void 0,this._bondCount=void 0,this._bondTypes=void 0,this.xyzAtomCoordinates=void 0,this._pairsOfBondedAtoms=void 0}get atomCount(){return void 0===this._atomCount&&this.setAtomAndBondCounts(),this._atomCount}get bondCount(){return void 0===this._bondCount&&this.setAtomAndBondCounts(),this._bondCount}get x(){var e;return null!==(e=this.xyzAtomCoordinates)&&void 0!==e||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.x}get y(){var e;return null!==(e=this.xyzAtomCoordinates)&&void 0!==e||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.y}get z(){var e;return null!==(e=this.xyzAtomCoordinates)&&void 0!==e||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.z}get atomTypes(){var e;return null!==(e=this._atomTypes)&&void 0!==e||(this._atomTypes=this.parseAtomTypes()),this._atomTypes}get pairsOfBondedAtoms(){var e;return null!==(e=this._pairsOfBondedAtoms)&&void 0!==e||(this._pairsOfBondedAtoms=this.parseBondedAtomPairs()),this._pairsOfBondedAtoms}get bondTypes(){var e;return null!==(e=this._bondTypes)&&void 0!==e||(this._bondTypes=this.parseBondTypes()),this._bondTypes}setAtomAndBondCounts(){const{atomCount:e,bondCount:t}=this.parseAtomAndBondCounts();this._atomCount=e,this._bondCount=t}getNextColumnIdx(e){for(;!this.isWhitespace(e);)++e;for(;this.isWhitespace(e);)++e;return e}shiftIdxToSpecifiedColumn(e,t){let n=e;const o=this.isWhitespace(n)?t:t-1;for(let e=0;e<o;e++)n=this.getNextColumnIdx(n);return n}parseAtomTypes(){const e=this.atomCount,t=new Array(e);let n=this.getAtomBlockIdx();for(let o=0;o<e;o++)n=this.shiftIdxToAtomType(n),t[o]=this.parseAtomType(n),n=this.getNextLineIdx(n);return t}parseAtomCoordinates(){const e=new Float32Array(this.atomCount),t=new Float32Array(this.atomCount),n=new Float32Array(this.atomCount);let o=this.getAtomBlockIdx();for(let r=0;r<this.atomCount;r++){o=this.shiftIdxToXColumn(o);for(const i of[e,t,n])i[r]=this.parseFloatValue(o),o=this.getNextColumnIdx(o);o=this.getNextLineIdx(o)}return{x:e,y:t,z:n}}parseBondedAtomPairs(){const e=new Array(this.bondCount);let t=this.getBondBlockIdx();for(let n=0;n<this.bondCount;n++){t=this.shiftIdxToBondedAtomsPair(t);const o=new Uint16Array(2);o[0]=this.parseIntValue(t),t=this.getNextColumnIdx(t),o[1]=this.parseIntValue(t),e[n]=o,t=this.getNextLineIdx(t)}return e}parseBondTypes(){const e=this.bondCount,t=new Uint16Array(e);let n=this.getBondBlockIdx();for(let o=0;o<e;o++)n=this.shiftIdxToBondType(n),t[o]=this.parseIntValue(n),n=this.getNextLineIdx(n);return t}isWhitespace(e){const t=this.fileContent[e];return" "===t||"\t"===t}getNextLineIdx(e){return"\n"!==this.fileContent[e]?this.fileContent.indexOf("\n",e)+1:e+1}parseFloatValue(e){return this.parseNumericValue(parseFloat,e)}parseIntValue(e){return this.parseNumericValue(parseInt,e)}parseNumericValue(e,t){let n=t+1;for(;!this.isWhitespace(n);)++n;return e(this.fileContent.substring(t,n))}}class mt extends pt{constructor(e){super(e),this.init(e)}init(e){super.init(e)}parseAtomType(e){let t=e,n=t;return this.isQuote(t)?(n=this.getNextIdenticalChar(t),t++):n=this.fileContent.indexOf(" ",n),this.fileContent.substring(t,n)}isQuote(e){const t=this.fileContent[e].charCodeAt(0);return 39===t||34===t}getNextIdenticalChar(e){const t=this.fileContent[e];return t?this.fileContent.indexOf(t,e+1):-1}isQuery(){return this.isQueryOrFragment(((e,t)=>{return 39===e||34===e||76===e&&!((n=this.fileContent.charCodeAt(t+1))>64&&n<91||n>96&&n<123);var n}))}isFragment(){return this.isQueryOrFragment((e=>82===e||42===e))}isQueryOrFragment(e){const t=this.atomCount;let n=this.getAtomBlockIdx();for(let o=0;o<t;o++){if(n=this.shiftIdxToAtomType(n),e(this.fileContent.charCodeAt(n),n))return!0;n=this.getNextLineIdx(n)}return!1}}class ft extends mt{constructor(e){super(e)}getAtomLines(){const e=this.getAtomBlockIdx(),t=this.getBondBlockIdx();return this.fileContent.substring(e,t).split("\n").slice(0,this.atomCount)}getBondLines(){const e=this.getBondBlockIdx();return this.fileContent.substring(e).split("\n").slice(0,this.bondCount)}getRGroupIdToAtomicIdxMap(){const e=new Map,t=this.fileContent.split("\n");t.filter((e=>e.startsWith(ct.RGP_LINE_START))).forEach((t=>{const n=this.getAtomIdxToRgpIdxList(t);for(const[t,o]of n){if(e.has(t))throw new Error(`R group ${t} is already in the map`);e.set(t,o)}}));const n=t.map(((e,t)=>{if(e.startsWith(ct.ATOM_ALIAS_LINE_START))return t})).filter((e=>void 0!==e)),o=n.map((e=>t[e])),r=n.map((e=>t[e+1]));o.forEach(((t,n)=>{const o=parseInt(t.split(/\s+/)[1])-1,i=parseInt(r[n].substring(1));if(e.has(i))throw new Error(`R group ${i} is already in the map`);e.set(i,o)}));const i=this.getRGroupAtomicIndices().filter((t=>!Array.from(e.values()).includes(t)));if(0!==i.length)throw new Error(`Unaccounted R group indices: ${i}`);return e}getAtomIdxToRgpIdxList(e){const t=e.split(/\s+/).filter((e=>e)).slice(3).map((e=>parseInt(e))),n=new Array(t.length/2);for(let e=0;e<t.length;e+=2)n[e/2]=[t[e+1],t[e]-1];return n}getRGroupAtomicIndices(){return this.atomTypes.map(((e,t)=>{if(e.includes("R#"))return t})).filter((e=>void 0!==e))}static isValidMolfile(e){return-1!==e.indexOf(ct.TYPE)&&-1!==e.indexOf(ct.END)}shiftIdxToAtomType(e){return this.shiftIdxToSpecifiedColumn(e,ct.ATOM_TYPE_COL)}getCountsLineIdx(){let e=0;for(let t=0;t<ct.NUM_OF_HEADER_LINES;++t)e=this.getNextLineIdx(e);return e}getAtomBlockIdx(){let e=this.getCountsLineIdx();return e=this.getNextLineIdx(e),e}shiftIdxToXColumn(e){return this.getNextColumnIdx(e)}shiftIdxToBondedAtomsPair(e){return this.shiftIdxToSpecifiedColumn(e,ct.FIRST_BONDED_ATOM_COL)}shiftIdxToBondType(e){return this.shiftIdxToSpecifiedColumn(e,ct.BOND_TYPE_COL)}getBondBlockIdx(){let e=this.getAtomBlockIdx();for(let t=0;t<this.atomCount;t++)e=this.getNextLineIdx(e);return e}parseAtomAndBondCounts(){let e=this.getCountsLineIdx(),t=e+ct.NUM_OF_COUNTS_DIGITS;const n=parseInt(this.fileContent.substring(e,t));return e=t,t+=ct.NUM_OF_COUNTS_DIGITS,{atomCount:n,bondCount:parseInt(this.fileContent.substring(e,t))}}}class gt extends mt{constructor(e){super(e),this.init(e)}getAtomLines(){const e=this.getAtomBlockIdx(),t=this.getBondBlockIdx();return this.fileContent.substring(e,t).split("\n").slice(0,this.atomCount)}getBondLines(){const e=this.getBondBlockIdx();return this.fileContent.substring(e).split("\n").slice(0,this.bondCount)}getRGroupIdToAtomicIdxMap(){const e=new Map;return this.getAtomLines().forEach(((t,n)=>{const o=t.match(/RGROUPS=\(([\d\s]+)\)/);if(o){const t=o[1].split(/\s+/).map((e=>parseInt(e)));if(t.length>2)throw new Error(`R group data ${t} has more than 2 elements`);const r=t[1];if(e.has(r))throw new Error(`R group ${r} is already in the map`);e.set(r,n)}})),e}shiftIdxToAtomType(e){return this.shiftIdxToSpecifiedColumn(e,4)}getCountsLineIdx(){return this.fileContent.indexOf("M V30 COUNTS ")}getAtomBlockIdx(){let e=this.fileContent.indexOf("M V30 BEGIN ATOM");return e=this.getNextLineIdx(e),e}shiftIdxToXColumn(e){let t=this.shiftIdxToAtomType(e);return this.isQuote(t)?(t=this.getNextIdenticalChar(t),t=this.getNextColumnIdx(t),t):this.shiftIdxToSpecifiedColumn(e,5)}shiftIdxToBondedAtomsPair(e){return this.shiftIdxToSpecifiedColumn(e,5)}shiftIdxToBondType(e){return this.shiftIdxToSpecifiedColumn(e,4)}getBondBlockIdx(){return this.getNextLineIdx(this.fileContent.indexOf("M V30 BEGIN BOND"))}static isValidMolfile(e){return-1!==e.indexOf("V3000")&&-1!==e.indexOf("M END")}parseAtomAndBondCounts(){let e=this.fileContent.indexOf("M V30 COUNTS ")+14,t=this.fileContent.indexOf(" ",e+1);const n=parseInt(this.fileContent.substring(e,t));return e=t+1,t=this.fileContent.indexOf(" ",e+1),{atomCount:n,bondCount:parseInt(this.fileContent.substring(e,t))}}}class yt{constructor(){}static getInstance(e){if(yt.isMolfileV2K(e))return new ft(e);if(yt.isMolfileV3K(e))return new gt(e);throw new Error("Malformed molfile")}static isMolfileV2K(e){return ft.isValidMolfile(e)}static isMolfileV3K(e){return gt.isValidMolfile(e)}}const bt=class extends Error{constructor(e){super(e)}};class vt{constructor(e){this.molblock=e}get molblock(){return this._validMolBlock}set molblock(e){if(""!==e){try{this.validateMolBlock(e)}catch(t){t instanceof bt&&(e="");const n=lt(t);console.error(n)}this._validMolBlock=e}else this._validMolBlock=e}validateMolBlock(e){if(""===e)throw new bt("MoleculeImage: invalid molblock")}async drawMolBlockOnCanvas(e){try{await o.functions.call("Chem:canvasMol",{x:0,y:0,w:e.width,h:e.height,canvas:e,molString:this.molblock,scaffoldMolString:"",options:{normalizeDepiction:!1,straightenDepiction:!1}})}catch(e){const t=lt(e);console.error(t)}}getMoleculeDimensions(){const e=yt.getInstance(this.molblock),t=Math.max(...e.x)-Math.min(...e.x);return{height:Math.max(...e.y)-Math.min(...e.y),width:t}}async zoomIn(){const e=P.dialog({title:"Molecule",showFooter:!1}),t=.7*L()(window).height(),n=this.getMoleculeDimensions(),o=t/n.height,r=t,i=n.width*o,s=P.canvas(i,r);await this.drawMolBlockOnCanvas(s);const a=P.block([s],{style:{overflowX:"scroll"}});e.add(a).showModal(!0),L()(e.root).find(".d4-dialog-contents").removeClass("ui-form"),L()(e.root).find(".d4-dialog-contents").removeClass("ui-panel"),L()(e.root).find(".d4-dialog-contents").addClass("ui-box"),L()(e.root).find(".d4-dialog-contents").css("padding","0")}async drawMolecule(e,t,n){e.innerHTML="";const o=P.canvas(t*window.devicePixelRatio,n*window.devicePixelRatio);o.style.width=`${t}px`,o.style.height=`${n}px`,o.style.cursor="zoom-in",this.drawMolBlockOnCanvas(o),o.addEventListener("click",(async()=>{await this.zoomIn()})),e.append(P.tooltip.bind(o,"Click to zoom"))}}class Ct extends Error{constructor(e,t){super(e,t)}}class xt{constructor(e,t){this.sequence=e,this.codeMap=t}parseSequence(){const e=this.parseRawSequence();return this.addLinkers(e)}addLinkers(e){const t=[];return e.forEach(((n,o)=>{const r=this.getSymbolForCode(n);o>0&&function(e){return br.jsonData.monomersWithPhosphate.left.includes(e)}(r)&&t.pop(),t.push(r);const i=wt(r),s=o===e.length-1,a=o+1<e.length&&wt(this.getSymbolForCode(e[o+1]));i||function(e){return br.jsonData.monomersWithPhosphate.right.includes(e)}(r)||a||s||t.push("p")})),t}getSymbolForCode(e){let t=this.codeMap.get(e);return t??(t=e),t}parseRawSequence(){const e=this.getAllCodesOfFormat(),t=[];let n=0;for(;n<this.sequence.length;){const o=e.find((e=>e===this.sequence.substring(n,n+e.length)));if(void 0===o)throw new Ct(`Unable to match a monomer for the rest of the sequence '${this.sequence.slice(n)}'.`);t.push(o),n+=o.length}return t}getAllCodesOfFormat(){return g(Array.from(this.codeMap.keys()))}}function wt(e){return br.jsonData.monomersWithPhosphate.phosphate.includes(e)}class At{constructor(e,t=!1,n){this.invert=t,this.lib=br.monomerLibWrapper;const o=this.lib.getCodeToSymbolMap(n);this.parser=new xt(e,o)}convert(){const e=this.parser.parseSequence(),t=[];e.forEach(((e,n)=>{const o=this.getMonomerMolfile(e,n);t.push(o)}));let n=this.getPolymerMolfile(t);return this.invert&&(n=this.reflect(n),n=this.invertBondConfiguration(n)),n}invertBondConfiguration(e){const t=e.indexOf("M V30 BEGIN BOND"),n=e.indexOf("M V30 END BOND");let o=e.substring(t,n);return o=o.replace(/(CFG=)([13])/g,((e,t,n)=>"1"===n?`${t}3`:"3"===n?`${t}1`:e)),e.substring(0,t)+o+e.substring(n)}getMonomerMolfile(e,t){const n=this.lib.getMolfileBySymbol(e);return this.lib.isModification(e)?0===t?this.reflect(n):n:this.rotateNucleotidesV3000(n)}getPolymerMolfile(e){return this.linkV3000(e)}reflect(e){const t=this.extractAtomDataV3000(e),n=t.atomIndex.length,o=t.atomIndex.indexOf(1),r=t.atomIndex.indexOf(n),i=(t.x[r]+t.x[o])/2,s=(t.y[r]+t.y[o])/2;for(let e=0;e<n;e++)t.x[e]-=i,t.y[e]-=s;for(let e=0;e<n;e++)t.x[e]=-t.x[e];const a=t.x[o];for(let e=0;e<n;e++)t.x[e]-=a;let l=e.indexOf("M V30 BEGIN ATOM");l=e.indexOf("\n",l);let c=l;for(let o=0;o<n;o++)l=e.indexOf("V30",l)+4,l=e.indexOf(" ",l)+1,l=e.indexOf(" ",l)+1,c=e.indexOf(" ",l)+1,c=e.indexOf(" ",c),l=(e=e.slice(0,l)+t.x[o]+" "+t.y[o]+e.slice(c)).indexOf("\n",l)+1;return e}extractAtomDataV3000(e){const t=this.extractAtomsBondsNumbersV3000(e);let n=e.indexOf("M V30 BEGIN ATOM");n=e.indexOf("\n",n);let o=n;const r=Array(t.natom),i=Array(t.natom),s=Array(t.natom),a=Array(t.natom);for(let l=0;l<t.natom;l++)n=e.indexOf("V30",n)+4,o=e.indexOf(" ",n),r[l]=parseInt(e.substring(n,o)),n=o+1,o=e.indexOf(" ",n),i[l]=e.substring(n,o),n=o+1,o=e.indexOf(" ",n),s[l]=parseFloat(e.substring(n,o)),n=o+1,o=e.indexOf(" ",n),a[l]=parseFloat(e.substring(n,o)),n=e.indexOf("\n",n)+1;return{atomIndex:r,atomType:i,x:s,y:a}}extractAtomsBondsNumbersV3000(e){let t=(e=e.replaceAll("\r","")).indexOf("COUNTS")+7,n=e.indexOf(" ",t);const o=parseInt(e.substring(t,n));return t=n+1,n=e.indexOf(" ",t),{natom:o,nbond:parseInt(e.substring(t,n))}}rotateNucleotidesV3000(e){const t=this.extractAtomDataV3000(e),n=t.atomIndex.length,o=t.atomIndex.indexOf(1),r=t.atomIndex.indexOf(n);n>8&&this.fix5Prime(t,o,r);const i=(t.x[r]+t.x[o])/2,s=(t.y[r]+t.y[o])/2;for(let e=0;e<n;e++)t.x[e]-=i,t.y[e]-=s;let a=0;if(0===t.x[o])a=t.y[o]>t.y[r]?Math.PI/2:3*Math.PI/2;else if(0===t.y[o])a=t.x[o]>t.x[r]?Math.PI:0;else{const e=t.y[o]/t.x[o];a=e>0?t.x[o]>0?Math.PI-Math.atan(e):2*Math.PI-Math.atan(e):t.x[o]>0?-Math.PI-Math.atan(e):Math.atan(e)}const l=Math.cos(a),c=Math.sin(a);for(let e=0;e<n;e++){const n=t.x[e];t.x[e]=n*l-t.y[e]*c,t.y[e]=n*c+t.y[e]*l}const u=t.x[o];for(let e=0;e<n;e++)t.x[e]-=u;let h=e.indexOf("M V30 BEGIN ATOM");h=e.indexOf("\n",h);let d=h;for(let o=0;o<n;o++)h=e.indexOf("V30",h)+4,h=e.indexOf(" ",h)+1,h=e.indexOf(" ",h)+1,d=e.indexOf(" ",h)+1,d=e.indexOf(" ",d),h=(e=e.slice(0,h)+t.x[o]+" "+t.y[o]+e.slice(d)).indexOf("\n",h)+1;return e}linkV3000(e,t=!0){let n="\n Datagrok macromolecule handler\n\n";n+=" 0 0 0 0 0 0 999 V3000\n",n+="M V30 BEGIN CTAB\n";let o="",r="",i="";const s=[];let a=0,l=0,c=0;for(let t=0;t<e.length;t++){const n=e[t].includes("MODIFICATION")&&0===t;let i=0;n&&(i=this.extractAtomDataV3000(e[t]).atomIndex.length),e[t]=e[t].replaceAll("(-\nM V30 ","(").replaceAll("-\nM V30 ","").replaceAll(" )",")");const u=this.extractAtomsBondsNumbersV3000(e[t]),h=this.extractAtomDataV3000(e[t]);let d=e[t].indexOf("M V30 BEGIN ATOM");d=e[t].indexOf("\n",d);let p=d,m=d;for(let o=0;o<u.natom;o++)if(1!==h.atomIndex[o]||0===t){p=e[t].indexOf("V30",p)+4,m=e[t].indexOf(" ",p);let o=0;n?(o=parseInt(e[t].substring(p,m)),1===o?o=i:o===i&&(o=1),o+=a):o=parseInt(e[t].substring(p,m))+a,e[t]=e[t].slice(0,p)+o+e[t].slice(m),p=e[t].indexOf(" ",p)+1,p=e[t].indexOf(" ",p)+1,m=e[t].indexOf(" ",p);const r=c-h.x[0];let s=Math.round(1e4*(parseFloat(e[t].substring(p,m))+r))/1e4;e[t]=e[t].slice(0,p)+s+e[t].slice(m),p=e[t].indexOf(" ",p)+1,m=e[t].indexOf(" ",p),s=Math.round(1e4*parseFloat(e[t].substring(p,m)))/1e4,e[t]=e[t].slice(0,p)+s+e[t].slice(m),p=e[t].indexOf("\n",p)+1}else p=e[t].indexOf("M V30",p)-1,m=e[t].indexOf("\n",p+1),e[t]=e[t].slice(0,p)+e[t].slice(m);const f=e[t].indexOf("M V30 END ATOM");o+=e[t].substring(d+1,f);let g=e[t].indexOf("M V30 BEGIN BOND");g=e[t].indexOf("\n",g),p=g,m=g;for(let o=0;o<u.nbond;o++){p=e[t].indexOf("V30",p)+4,m=e[t].indexOf(" ",p);const o=parseInt(e[t].substring(p,m))+l;e[t]=e[t].slice(0,p)+o+e[t].slice(m),p=e[t].indexOf(" ",p)+1,p=e[t].indexOf(" ",p)+1,m=e[t].indexOf(" ",p);let r=0;n?(r=parseInt(e[t].substring(p,m)),1===r?r=i:r===i&&(r=1),r+=a):r=parseInt(e[t].substring(p,m))+a,e[t]=e[t].slice(0,p)+r+e[t].slice(m),p=e[t].indexOf(" ",p)+1,m=Math.min(e[t].indexOf("\n",p),e[t].indexOf(" ",p)),r=0,n?(r=parseInt(e[t].substring(p,m)),1===r?r=i:r===i&&(r=1),r+=a):r=parseInt(e[t].substring(p,m))+a,e[t]=e[t].slice(0,p)+r+e[t].slice(m),p=e[t].indexOf("\n",p)+1}const y=e[t].indexOf("M V30 END BOND");r+=e[t].substring(g+1,y);let b=e[t].indexOf("M V30 MDLV30/STEABS ATOMS=(");for(;-1!==b;){b+=28;const n=e[t].indexOf(")",b);e[t].substring(b,n).split(" ").slice(1).forEach((e=>{s.push(parseInt(e)+a)})),b=n,b=e[t].indexOf("M V30 MDLV30/STEABS ATOMS=(",b)}a+=u.natom-1,l+=u.nbond,c+=n?Math.max(...h.x):h.x[u.natom-1]-h.x[0]}const u=Math.ceil(s.length/4);i+="M V30 MDLV30/STEABS ATOMS=("+s.length+" -\n";for(let e=0;e<u;e++){i+="M V30 ";const t=e+1===u?s.length-4*(u-1):4;for(let n=0;n<t;n++)i+=n+1===t?e===u-1?s[4*e+n]+")\n":s[4*e+n]+" -\n":s[4*e+n]+" "}return a++,n+="M V30 COUNTS "+a+" "+l+" 0 0 0\n",n+="M V30 BEGIN ATOM\n",n+=o,n+="M V30 END ATOM\n",n+="M V30 BEGIN BOND\n",n+=r,n+="M V30 END BOND\n",t&&s.length>0?(n+="M V30 BEGIN COLLECTION\n",n+=i,n+="M V30 END COLLECTION\n"):n=n.replace(/ CFG=\d/g," "),n+="M V30 END CTAB\n",n+="M END",n}fix5Prime(e,t,n){const o=t+1,r=e.x[o],i=e.y[o],s=e.x[n]-r,a=e.y[n]-i,l=e.x[t]-r,c=e.y[t]-i,u=l*Math.cos(2*Math.PI/3)-c*Math.sin(2*Math.PI/3),h=l*Math.sin(2*Math.PI/3)+c*Math.cos(2*Math.PI/3),d=l-s,p=c-a,m=u-s,f=h-a;Math.sqrt(f*f+m*m)>=Math.sqrt(p*p+d*d)&&(e.x[t]=u+r,e.y[t]=h+i)}}function Tt(e,t=!0){let n="\n Datagrok macromolecule handler\n\n";n+=" 0 0 0 0 0 0 999 V3000\n",n+="M V30 BEGIN CTAB\n";let o="",r="",i="";const s=[];let a=0,l=0,c=0;if(e.antiStrands.length>0)for(let t=0;t<e.antiStrands.length;t++)e.antiStrands[t]=Et(e.antiStrands[t]);let u=!1;const h=e.senseStrands.concat(e.antiStrands);let d=0;for(let t=0;t<h.length;t++){h[t]=h[t].replaceAll("(-\nM V30 ","(").replaceAll("-\nM V30 ","").replaceAll(" )",")");const n=St(h[t]),i=Nt(h[t]);if(t>=e.senseStrands.length?!1===u&&(u=!0,c=0):d=Math.min(d,Math.min(...i.y.filter((e=>e<0)))),u){const e=Math.min(...i.x)-c,t=Math.max(...i.y)+5;for(let t=0;t<i.x.length;t++)i.x[t]-=e;for(let e=0;e<i.y.length;e++)i.y[e]-=t-d}let p=h[t].indexOf("M V30 BEGIN ATOM");p=h[t].indexOf("\n",p);let m=p,f=p;for(let e=0;e<n.natom;e++){m=h[t].indexOf("V30",m)+4,f=h[t].indexOf(" ",m);const n=parseInt(h[t].substring(m,f))+a;h[t]=h[t].slice(0,m)+n+h[t].slice(f),m=h[t].indexOf(" ",m)+1,m=h[t].indexOf(" ",m)+1,f=h[t].indexOf(" ",m);let o=Math.round(1e4*i.x[e])/1e4;h[t]=h[t].slice(0,m)+o+h[t].slice(f),m=h[t].indexOf(" ",m)+1,f=h[t].indexOf(" ",m),o=Math.round(1e4*i.y[e])/1e4,h[t]=h[t].slice(0,m)+o+h[t].slice(f),m=h[t].indexOf("\n",m)+1}const g=h[t].indexOf("M V30 END ATOM");o+=h[t].substring(p+1,g);let y=h[t].indexOf("M V30 BEGIN BOND");y=h[t].indexOf("\n",y),m=y,f=y;for(let e=0;e<n.nbond;e++){m=h[t].indexOf("V30",m)+4,f=h[t].indexOf(" ",m);const e=parseInt(h[t].substring(m,f))+l;h[t]=h[t].slice(0,m)+e+h[t].slice(f),m=h[t].indexOf(" ",m)+1,m=h[t].indexOf(" ",m)+1,f=h[t].indexOf(" ",m);let n=parseInt(h[t].substring(m,f))+a;h[t]=h[t].slice(0,m)+n+h[t].slice(f),m=h[t].indexOf(" ",m)+1,f=Math.min(h[t].indexOf("\n",m),h[t].indexOf(" ",m)),n=parseInt(h[t].substring(m,f))+a,h[t]=h[t].slice(0,m)+n+h[t].slice(f),m=h[t].indexOf("\n",m)+1}const b=h[t].indexOf("M V30 END BOND");r+=h[t].substring(y+1,b);let v=h[t].indexOf("M V30 MDLV30/STEABS ATOMS=(");for(;-1!==v;){v+=28;const e=h[t].indexOf(")",v);h[t].substring(v,e).split(" ").slice(1).forEach((e=>{s.push(parseInt(e)+a)})),v=e,v=h[t].indexOf("M V30 MDLV30/STEABS ATOMS=(",v)}a+=n.natom,l+=n.nbond,c+=Math.max(...i.x)+5}const p=Math.ceil(s.length/4);i+="M V30 MDLV30/STEABS ATOMS=("+s.length+" -\n";for(let e=0;e<p;e++){i+="M V30 ";const t=e+1===p?s.length-4*(p-1):4;for(let n=0;n<t;n++)i+=n+1===t?e===p-1?s[4*e+n]+")\n":s[4*e+n]+" -\n":s[4*e+n]+" "}return n+="M V30 COUNTS "+a+" "+l+" 0 0 0\n",n+="M V30 BEGIN ATOM\n",n+=o,n+="M V30 END ATOM\n",n+="M V30 BEGIN BOND\n",n+=r,n+="M V30 END BOND\n",t&&s.length>0?(n+="M V30 BEGIN COLLECTION\n",n+=i,n+="M V30 END COLLECTION\n"):n=n.replace(/ CFG=\d/g," "),n+="M V30 END CTAB\n",n+="M END",n}function Et(e){const t=Nt(e),n=t.atomIndex.length,o=(Math.max(...t.x)+Math.min(...t.x))/2,r=(Math.max(...t.y)+Math.min(...t.y))/2;for(let e=0;e<n;e++)t.x[e]-=o,t.y[e]-=r;const i=Math.PI,s=Math.cos(i),a=Math.sin(i);for(let e=0;e<n;e++){const n=t.x[e];t.x[e]=n*s-t.y[e]*a,t.y[e]=n*a+t.y[e]*s}const l=Math.max(...t.y);for(let e=0;e<n;e++)t.x[e]+=o,t.y[e]-=l;let c=e.indexOf("M V30 BEGIN ATOM");c=e.indexOf("\n",c);let u=c;for(let o=0;o<n;o++)c=e.indexOf("V30",c)+4,c=e.indexOf(" ",c)+1,c=e.indexOf(" ",c)+1,u=e.indexOf(" ",c)+1,u=e.indexOf(" ",u),c=(e=e.slice(0,c)+t.x[o]+" "+t.y[o]+e.slice(u)).indexOf("\n",c)+1;return e}function St(e){let t=(e=e.replaceAll("\r","")).indexOf("COUNTS")+7,n=e.indexOf(" ",t);const o=parseInt(e.substring(t,n));return t=n+1,n=e.indexOf(" ",t),{natom:o,nbond:parseInt(e.substring(t,n))}}function Nt(e){const t=St(e);let n=e.indexOf("M V30 BEGIN ATOM");n=e.indexOf("\n",n);let o=n;const r=Array(t.natom),i=Array(t.natom),s=Array(t.natom),a=Array(t.natom);for(let l=0;l<t.natom;l++)n=e.indexOf("V30",n)+4,o=e.indexOf(" ",n),r[l]=parseInt(e.substring(n,o)),n=o+1,o=e.indexOf(" ",n),i[l]=e.substring(n,o),n=o+1,o=e.indexOf(" ",n),s[l]=parseFloat(e.substring(n,o)),n=o+1,o=e.indexOf(" ",n),a[l]=parseFloat(e.substring(n,o)),n=e.indexOf("\n",n)+1;return{atomIndex:r,atomType:i,x:s,y:a}}function It(e,t,n){if(""===e)return"";const o=n.createFormatDetector(e).getFormat();if(!o)return"";let r="";try{r=new At(e,t,o).convert()}catch(e){const t=lt(e);console.error(t)}return r}function Mt(e,t,n,o,r){const i=[e,t,n].filter((e=>""!==e.strand));return 1===i.length?It(i[0].strand,i[0].invert,r):Tt({senseStrands:[It(e.strand,e.invert,r)],antiStrands:[It(t.strand,t.invert,r),It(n.strand,n.invert,r)].filter((e=>""!==e))},o)}const Pt=["ss","as","as2"];class _t{constructor(){this.th=br,this.onInput=new te.Subject,this.onInvalidInput=new te.Subject,this.inputBase=Object.fromEntries(Pt.map((e=>{const t=P.input.textArea(e.toUpperCase(),{value:"",onValueChanged:()=>{this.onInput.next(),L()(t.root.getElementsByTagName("div")).css("padding-left","38px")}});return[e,t]}))),this.useChiralInput=P.input.bool("Use chiral",{value:!0}),this.saveAllStrandsInput=P.input.bool("Save as one entity",{value:!0}),P.tooltip.bind(this.saveAllStrandsInput.root,"Save SDF with all strands in one molfile"),this.directionInversion=Object.fromEntries(Pt.map((e=>[e,!1]))),this.moleculeImgDiv=P.block([]),L()(this.moleculeImgDiv).addClass("st-structure-mol-img"),r.debounce(this.onInput,300).subscribe((async()=>{await this.updateMoleculeImg()})),r.debounce(this.onInvalidInput,1e3).subscribe((async()=>{o.shell.warning("Insert Sense strand")}))}async getHtmlDivElement(e){const t=this.getTableInput(e),n=this.getBoolInputsAndButton();await this.updateMoleculeImg();const o=P.divH([this.moleculeImgDiv,n]);L()(o).addClass("st-structure-bottom");const r=P.divV([t,o]);return L()(r).addClass("st-structure-body"),r}getBoolInputsAndButton(){const e=P.buttonsInput([P.bigButton("Save SDF",(()=>{const e=this.getStrandData();!function(e,t,n,r,i,s){const a=[e.strand,t.strand,n.strand].filter((e=>""!==e));if(0===a.length||1===a.length&&""===e.strand)o.shell.warning("Enter SENSE_STRAND and optionally ANTISENSE_STRAND/AS2 to save SDF");else{let l;if(i)l=Mt(e,t,n,r,s)+"\n$$$$\n";else{const h=It(e.strand,e.invert,s),d=It(t.strand,t.invert,s),p=It(n.strand,n.invert,s);l=h+"\n> <Sequence>\nSense Strand\n$$$$\n",d&&(l+=d+"\n> <Sequence>\nAnti Sense\n$$$$\n"),p&&(l+=p+"\n> <Sequence>\nAnti Sense 2\n$$$$\n")}const c=new Date;function u(e){return e>=10?e.toString():"0"+e.toString()}y(`SequenceTranslator-${c.getFullYear()+"-"+u(c.getMonth()+1)+"-"+u(c.getDate())+"_"+u(c.getHours())+"-"+u(c.getMinutes())+"-"+u(c.getSeconds())}.sdf`,encodeURIComponent(l))}}(e.ss,e.as,e.as2,this.useChiralInput.value,this.saveAllStrandsInput.value,this.th)}))]),t=[this.saveAllStrandsInput.root,this.useChiralInput.root,e],n=P.divV(t);for(const e of t)L()(e).addClass("st-structure-bool-button-block");return n}getTableInput(e){const t=Object.fromEntries(Pt.map((t=>[t,new dt(this.inputBase[t],e.highlightInvalidSubsequence)]))),n=Object.fromEntries(Pt.map(((e,t)=>{const n=0===t?"5′ → 3′":"3′ → 5′";return[e,P.input.choice(`${e.toUpperCase()} direction`,{value:n,items:["5′ → 3′","3′ → 5′"]})]})));Pt.forEach(((e,t)=>{n[e].onChanged.subscribe((n=>{let o="3′ → 5′"===n;t>0&&(o=!o),this.directionInversion[e]=o,this.onInput.next()}))}));const o=["Sense Strand","Anti Sense","Anti Sense 2"],r=new Map(Pt.map(((e,t)=>[e,o[t]]))),i=(Object.fromEntries(Pt.map((e=>[e,P.label(r.get(e))]))),Object.fromEntries(Pt.map((e=>{const n=P.icons.delete((()=>{t[e].inputBase.value=""}),"Delete"),o=P.button(n,(()=>{}));return P.tooltip.bind(o,`Clear ${e.toUpperCase()}`),[e,n]})))),s=P.form([],"st-structure-inputs"),a=P.divV([],"st-structure-clear-buttons"),l=P.form([],"st-direction-inputs");for(const e of Pt)s.append(this.inputBase[e].root),a.append(i[e]),l.append(n[e].root);return P.divH([s,a,l])}getStrandData(){return Object.fromEntries(Pt.map((e=>{const t=this.directionInversion[e];return[e,{strand:this.inputBase[e].value.replace(/\s*/g,""),invert:t}]})))}getMolfile(e,t,n){return Mt(e,t,n,this.useChiralInput.value,this.th)}async updateMoleculeImg(){let e="";try{const t=this.getStrandData();Object.values(t).some((e=>""!==e.strand))&&(e=this.getMolfile(t.ss,t.as,t.as2))}catch(e){const t=lt(e);console.error(t)}const t=new vt(e);await t.drawMolecule(this.moleculeImgDiv,650,150)}}class Lt extends F{constructor(e){super("Oligo Structure"),this.th=e,this.layout=new _t}getContent(){return this.layout.getHtmlDivElement(this.th)}}var Ot=n(2003);async function Rt(e){try{const t={overflowX:"scroll"},n=P.div([],{style:t}),r=Nt(e),i=.7*L()(window).height(),s=Math.max(...r.x)-Math.min(...r.x),a=Math.max(...r.y)-Math.min(...r.y),l=i/a,c=l*s,u=l*a,h=P.canvas(c*window.devicePixelRatio,u*window.devicePixelRatio);h.style.width=`${c}px`,h.style.height=`${u}px`,await async function(e,t){await o.functions.call("Chem:canvasMol",{x:0,y:0,w:e.width,h:e.height,canvas:e,molString:t,scaffoldMolString:"",options:{normalizeDepiction:!1,straightenDepiction:!1}})}(h,e),n.appendChild(h),P.dialog("Molecule").add(n).showModal(!0)}catch(e){const t=lt(e);console.error(t)}}class $t{static async view(){const e=br.monomerLibWrapper.getTableForViewer();e.name="Monomer Library";const t=o.shell.addTableView(e);t.grid.props.allowEdit=!1,t.grid.onCellDoubleClick.subscribe((async e=>{const t=e.cell.value;"Molecule"===e.tableColumn?.semType&&await Rt(t)}))}}var Dt=n(3480),Bt=n(5067),Ft=n(5254),kt={};kt.styleTagTransform=Ae(),kt.setAttributes=ve(),kt.insert=ye().bind(null,"head"),kt.domAPI=fe(),kt.insertStyleElement=xe(),pe()(Ft.A,kt),Ft.A&&Ft.A.locals&&Ft.A.locals;const Ht=["Sequence"];class Gt{constructor(e){this.th=e,this.inputFormats=Object.keys(br.jsonData.codesToHelmDict).concat(f.NO.HELM),this.seqHelper=br.seqHelper,this.onInput=new te.Subject,this.moleculeImgDiv=P.div([]),this.moleculeImgDiv.className="mol-host",this.moleculeImgDiv.style.border="1px solid var(--grey-2)",this.moleculeImgDiv.style.borderRadius="1px",this.moleculeImgDiv.style.marginTop="12px",this.outputTableDiv=P.div([]),this.formatChoiceInput=P.input.choice("",{value:f.NO.HELM,items:this.inputFormats,onValueChanged:async(e,t)=>{this.format=e,this.updateTable(),await this.updateMolImg()}}),this.sequenceInputBase=P.input.textArea("",{value:"Afcgacsu",onValueChanged:()=>{this.onInput.next()}}),this.init(),r.debounce(this.onInput,300).subscribe((async()=>{this.init(),this.formatChoiceInput.value=this.format,this.updateTable(),await this.updateMolImg()})),this.eventBus=qt.getInstance()}async getHtmlElement(){const e=this.constructSingleSequenceControls(),t=this.constructBulkTranslationControls(),n=P.box(P.panel([e,t,P.block([P.box(this.moleculeImgDiv)])]));return this.formatChoiceInput.value=this.format,this.updateTable(),await this.updateMolImg(),n}constructBulkTranslationControls(){const e=P.h1("Bulk");P.tooltip.bind(e,"Bulk translation from table input");const t=new Ut(this.eventBus).createUIComponents(),n=P.input.choice("Input format",{value:f.NO.AXOLABS,items:this.inputFormats,onValueChanged:e=>this.eventBus.selectInputFormat(e)}),o=P.input.choice("Output format",{value:Bt.qP,items:(0,Dt.OT)(this.th),onValueChanged:e=>this.eventBus.selectOutputFormat(e)}),r=this.createConvertBulkButton(),i=P.div([...t,n,o,r],"ui-form");return P.block25([e,i])}createConvertBulkButton(){const e=P.bigButton("Convert",(()=>this.processConvertBulkButtonClick()));return P.tooltip.bind(e,"Convert sequences from table input"),L()(e).css({float:"right","margin-top":"20px"}),e}processConvertBulkButtonClick(){const e=this.eventBus.getSelectedTable();if(!e)return void o.shell.warning("No table selected");const t=this.eventBus.getSelectedInputFormat(),n=this.eventBus.getSelectedOutputFormat(),i=this.eventBus.getSelectedColumn("Sequence");if(!i)return void o.shell.warning("No sequence column selected");const s=`${i.name} (${n})`,a=r.Column.fromList(r.TYPE.STRING,s,i.toList().map((e=>(0,Dt.C6)(e,t,n,this.th))));if(n===Bt.qP||n===f.NO.HELM){a.semType=r.SEMTYPE.MACROMOLECULE;const e=n==Bt.qP?Ot.Hi.FASTA:Ot.Hi.HELM;a.meta.units=e;const t=this.seqHelper.getSeqHandler(a);(n==Bt.qP?this.seqHelper.setUnitsToFastaColumn:this.seqHelper.setUnitsToHelmColumn)(t)}e.columns.add(a),o.data.detectSemanticTypes(e),o.shell.v=o.shell.getTableView(e.name)}constructSingleSequenceControls(){const e=new dt(this.sequenceInputBase,(e=>O(e,this.th))),t=P.button("Get SDF",(()=>{this.saveMolfile()}),"Save structure as SDF"),n=P.button("Copy SMILES",(()=>{this.copySmiles()}),"Copy SMILES for the sequence"),o=P.div([this.formatChoiceInput]),r=P.button(P.icons.delete((()=>{e.inputBase.value=""}),"Delete"),(()=>{}));P.tooltip.bind(r,"Clear input");const i={format:o,textInput:e.root,clearBtn:r},s=P.table([i],(e=>[e.format,e.textInput,e.clearBtn]));s.classList.add("st-translator-input-table");const a=P.block([this.outputTableDiv,t,n]);return P.block75([P.h1("Single sequence"),s,a])}saveMolfile(){try{const e=new At(this.sequence,!1,this.formatChoiceInput.value).convert()+"\n$$$$";y(this.sequence+".sdf",encodeURIComponent(e))}catch(e){o.shell.warning("Unable to save SDF: "+e.message)}}copySmiles(){const e=r.chem.convert(this.molfile,r.chem.Notation.MolBlock,r.chem.Notation.Smiles);navigator.clipboard.writeText(e).then((()=>o.shell.info(Bt.n_)))}updateTable(){this.outputTableDiv.innerHTML="";const e=this.format?this.th.createSequenceValidator(this.sequence).getInvalidCodeIndex(this.format):0,t=(0,Dt.bD)(this.sequence,e,this.format,this.th),n=[];for(const e of Object.keys(t)){const r="indexOfFirstInvalidChar"in t?P.divH([]):P.link(t[e],(()=>navigator.clipboard.writeText(t[e]).then((()=>o.shell.info(Bt.n_)))),Bt.U_,"");n.push({format:e,sequence:r})}const r=P.table(n,(e=>[e.format,e.sequence]),["FORMAT","SEQUENCE"]);this.outputTableDiv.append(r),this.outputTableDiv.classList.add("st-translator-output-table")}async updateMolImg(){const e=new vt(this.molfile);await e.drawMolecule(this.moleculeImgDiv,500,170)}init(){this.sequence=this.getFormattedSequence(),this.format=this.th.createFormatDetector(this.sequence).getFormat(),this.molfile=this.getMolfile()}getFormattedSequence(){return this.sequenceInputBase.value.replace(/\s/g,"")}getMolfile(){if(!this.format)return"";if(this.format===f.NO.HELM){const e=this.th.createFormatConverter(this.sequence,this.format).convertTo(f.NO.AXOLABS);return new At(e,!1,f.NO.AXOLABS).convert()}return new At(this.sequence,!1,this.format).convert()}}class Ut{constructor(e){this.tableInputManager=new Vt(e),this.columnInputManager=new jt(e)}createUIComponents(){return[this.tableInputManager.getTableInputContainer(),this.columnInputManager.getColumnControlsContainer()]}}class Vt{constructor(e){this.eventBus=e,this.availableTables=[],this.tableInputContainer=P.div([]),this.subscribeToTableEvents(),this.refreshTableInput()}getTableInputContainer(){return this.tableInputContainer}subscribeToTableEvents(){o.events.onTableAdded.subscribe((e=>this.handleTableAdded(e))),o.events.onTableRemoved.subscribe((e=>this.handleTableRemoved(e))),this.eventBus.tableSelected$.subscribe((()=>this.handleTableChoice()))}getTableFromEventData(e){return e.args.dataFrame}handleTableAdded(e){const t=this.getTableFromEventData(e);this.availableTables.some((e=>e.name===t.name))||(this.availableTables.push(t),this.eventBus.selectTable(t),this.refreshTableInput())}handleTableRemoved(e){const t=this.getTableFromEventData(e);this.availableTables=this.availableTables.filter((e=>e.name!==t.name));const n=this.availableTables[0];this.eventBus.selectTable(n||null),this.refreshTableInput()}refreshTableInput(){const e=this.createTableInput();L()(this.tableInputContainer).empty(),this.tableInputContainer.append(e.root)}createTableInput(){const e=this.eventBus.getSelectedTable();return P.input.table("Table",{value:e,items:this.availableTables,onValueChanged:e=>{null!==e&&this.eventBus.selectTable(e)}})}handleTableChoice(){const e=this.eventBus.getSelectedTable();e&&(this.isTableDisplayed(e)||this.displayTable(e))}isTableDisplayed(e){return o.shell.tableNames.includes(e.name)}displayTable(e){const t=o.shell.v;o.shell.addTableView(e),o.shell.v=t}}class jt{constructor(e){this.eventBus=e,this.columnControlsContainer=P.div([]),this.eventBus.tableSelected$.subscribe((()=>this.handleTableChoice())),this.refreshColumnControls()}getColumnControlsContainer(){return this.columnControlsContainer}handleTableChoice(){this.refreshColumnControls()}refreshColumnControls(){const e=this.createColumnInputs();L()(this.columnControlsContainer).empty();const t=e.map((e=>e.root));this.columnControlsContainer.append(...t)}createColumnInputs(){const e=this.eventBus.getSelectedTable(),t=null!==e?e.columns.names().sort(((e,t)=>e.localeCompare(t))):[];return Ht.map((n=>this.createColumnInput(n,t,e)))}createColumnInput(e,t,n){const o=e.toLowerCase(),r=t.find((e=>e.toLowerCase().includes(o)))||t[0];return this.selectColumnIfTableNotNull(n,r,e),P.input.choice(`${e}`,{value:r,items:t,onValueChanged:t=>this.selectColumnIfTableNotNull(n,t,e)})}selectColumnIfTableNotNull(e,t,n){if(null!==e&&t){const o=e.col(t);o&&this.eventBus.selectColumn(n,o)}}}class qt{constructor(){this._tableSelection$=new te.BehaviorSubject(null),this._columnSelection=Object.fromEntries(Ht.map((e=>[e,new te.BehaviorSubject(null)]))),this._inputFormatSelection$=new te.BehaviorSubject(f.NO.AXOLABS),this._outputFormatSelection$=new te.BehaviorSubject(Bt.qP)}static getInstance(){return void 0===qt._instance&&(qt._instance=new qt),qt._instance}get tableSelected$(){return this._tableSelection$.asObservable()}getSelectedTable(){return this._tableSelection$.getValue()}selectTable(e){this._tableSelection$.next(e)}selectColumn(e,t){this._columnSelection[e].next(t)}getSelectedColumn(e){return this._columnSelection[e].getValue()}getSelectedInputFormat(){return this._inputFormatSelection$.getValue()}selectInputFormat(e){this._inputFormatSelection$.next(e)}selectOutputFormat(e){this._outputFormatSelection$.next(e)}getSelectedOutputFormat(){return this._outputFormatSelection$.getValue()}}class Wt extends F{constructor(e){super("Oligo Translator"),this.th=e,this.th=br,this.layout=new Gt(this.th);const t=P.iconFA("book",$t.view,"View monomer library");this.topPanel=[t],this.view.setRibbonPanels([this.topPanel])}getContent(){return this.layout.getHtmlElement()}}class zt extends F{constructor(e,t){super(e),this.content=t}getContent(){return Promise.resolve(this.content)}}class Yt extends B{constructor(e,t){super("Oligo Toolkit"),this.externalViewFactories=e,this.th=t;const n=this.getViewFactories(this.th);this.multiView=new r.MultiView({viewFactories:n})}getViewFactories(e){function t(t){r.View.create();const n=new t(e);return n.initView().catch((e=>console.error(`Failed to initialize ${t.name}: ${e}`))),()=>n.getView()}let n={TRANSLATOR:t(Wt),PATTERN:t(it),STRUCTURE:t(Lt)};return this.externalViewFactories&&(n=Object.assign({},n,this.externalViewFactories)),n}getCurrentPanePath(){let e=this.multiView.tabs.currentPane.name;return e=e.charAt(0).toUpperCase()+e.substring(1).toLowerCase(),`/apps/${br.name}/OligoToolkit/${e}`}setUrl(){this.multiView.path=this.getCurrentPanePath()}async constructView(){return this.multiView.tabs.onTabChanged.subscribe((()=>this.setUrl())),this.setUrl(),this.multiView}}function Kt(e){const t=P.input.textArea("",{value:""});return{coloredInput:new dt(t,e.highlightInvalidSubsequence),codes:e.jsonData.codesToSymbolsDict}}var Qt=n(5733),Jt=n(5613),Xt=n(1536);const Zt=110,en=90;function tn(e,t,n=!1){return P.divH([P.divText(e,{style:{color:"var(--grey-4, #888)",width:"90px",flexShrink:"0"}}),P.divText(t,{style:n?{fontFamily:"ui-monospace, Menlo, monospace",wordBreak:"break-all"}:{}})],{style:{gap:"6px"}})}let nn=null;function on(e,t,n){const o=[t];"sugar"===n?o.push((0,Xt.Jy)(t)):"phosphate"===n&&o.push((0,Xt.$T)(t));const r=e.getPolymerTypes().filter((e=>"RNA"===e||"CHEM"===e)).concat(e.getPolymerTypes().filter((e=>"RNA"!==e&&"CHEM"!==e)));for(const t of o)for(const n of r){const o=e.getMonomer(n,t);if(o&&o.molfile)return o.molfile}return null}function rn(e){let t=e.symbol;return"sugar"===e.kind?t=(0,Xt.Jy)(e.symbol):"phosphate"===e.kind&&(t=(0,Xt.$T)(e.symbol)),`${e.kind}:${t}`}function sn(e){const t=P.div([],{style:{borderRadius:"4px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"10px",color:"var(--grey-4, #888)",textAlign:"center",padding:"4px"}}),n=P.divText(e,{style:{fontSize:"10px",color:"var(--grey-5, #555)",textAlign:"center",marginTop:"2px",letterSpacing:"0.04em",textTransform:"uppercase",fontWeight:"600"}});return{root:P.divV([t,n],{style:{display:"inline-flex"}}),body:t}}const an=new Map;function ln(e,t,n){try{let r=an.get(n);r||(r=o.chem.drawMolecule(t,Zt,en,!1),an.size>256&&an.clear(),an.set(n,r)),e.innerHTML="",e.appendChild(r)}catch{e.textContent="Render failed"}}const cn="OligoNucleotide";class un extends r.GridCellRenderer{constructor(){super(...arguments),this.modelCache=new Map,this.layoutCache=new Map}get name(){return cn}get cellType(){return cn}get defaultWidth(){return 320}get defaultHeight(){return 64}render(e,t,n,o,r,i,s){const a=i.cell.value;if(!a||!(0,Jt.yO)(a))return e.save(),e.beginPath(),e.rect(t,n,o,r),e.clip(),e.fillStyle="#8b949e",e.font="11px ui-monospace, Menlo, monospace",e.textBaseline="middle",e.textAlign="left",e.fillText(a??"",t+4,n+r/2),void e.restore();const l=this.getOrParse(a),c=(0,Qt.Z4)(e,t,n,o,r,l);this.layoutCache.set(this.cellKey(i),c),this.layoutCache.size>5e3&&this.layoutCache.clear()}onMouseMove(e,t){const n=e.cell.value;if(!n||!(0,Jt.yO)(n))return void P.tooltip.hide();const o=this.getOrParse(n),r=this.layoutCache.get(this.cellKey(e));if(!r)return;const i=e.bounds,s=t.offsetX-i.x,a=t.offsetY-i.y,c=(0,Qt.CB)(s,a,o,r);c?function(e,t,n){const o=function(e){const t=e.monomer,n=P.divText("",{style:{fontWeight:"600",marginBottom:"4px"}}),o=[];if(e.linkage){const t=(0,Xt.bM)(e.linkage.phosphateSymbol);n.textContent=`${t.meta.name} linkage`,o.push(tn("Strand","sense"===e.strand?"Sense":"Antisense"),tn("Between",`pos ${e.position+1} – ${e.position+2}`),tn("HELM symbol",`[${(0,Xt.$T)(e.linkage.phosphateSymbol)}]`,!0))}else if("nucleotide"===t.kind){const r=t,i=(0,Xt.xh)(r.sugar,r.base),s=(0,Xt.bM)(r.phosphate);n.textContent=`${r.base??"?"}${e.position+1} — ${i.meta.name}`,o.push(tn("Strand","sense"===e.strand?"Sense":"Antisense"),tn("Position",String(e.position+1)),tn("Base",r.base??"—"),tn("Sugar",i.meta.name),tn("3'-linkage",s.meta.name),tn("HELM",r.raw,!0))}else{const r=(0,Xt.rK)(t.symbol);n.textContent=r.meta.name,o.push(tn("Strand","sense"===e.strand?"Sense":"Antisense"),tn("Position",String(e.position+1)),tn("Type","Terminal conjugate / linker"),tn("HELM",t.raw,!0))}const r=P.div([],{style:{marginTop:"8px",display:"flex",flexDirection:"row",gap:"6px",flexWrap:"wrap"}});r.dataset.role="struct";const i=P.divText("Loading structures…",{style:{fontSize:"11px",color:"var(--grey-4, #888)"}});return r.appendChild(i),P.divV([n,...o,r],{style:{fontSize:"12px",lineHeight:"1.45",minWidth:"240px",maxWidth:"380px"}})}(e);P.tooltip.show(o,t+14,n+14),async function(e,t){const n=e.querySelector('[data-role="struct"]');if(!n)return;let o,r;if(t.linkage)o=[{label:"Linkage",symbol:t.linkage.phosphateSymbol,kind:"phosphate"}];else if("nucleotide"===t.monomer.kind){const e=t.monomer;o=[{label:"Sugar",symbol:e.sugar,kind:"sugar"}],e.base&&o.push({label:"Base",symbol:e.base,kind:"base"}),e.phosphate&&o.push({label:"3'-linkage",symbol:e.phosphate,kind:"phosphate"})}else o=[{label:"Conjugate",symbol:t.monomer.symbol,kind:"conjugate"}];try{r=await(nn||(nn=(async()=>(await(0,l.pj)()).getMonomerLib())()),nn)}catch{return n.innerHTML="",void n.appendChild(P.divText("Monomer library unavailable",{style:{fontSize:"11px",color:"var(--grey-4, #888)"}}))}n.innerHTML="";for(const e of o){const t=sn(e.label);n.appendChild(t.root);const o=on(r,e.symbol,e.kind);o?ln(t.body,o,rn(e)):t.body.textContent=`Not in HELMCore: ${e.symbol}`}}(o,e)}(c,t.clientX,t.clientY):P.tooltip.hide()}onMouseLeave(e,t){P.tooltip.hide()}getOrParse(e){let t=this.modelCache.get(e);return t||(t=(0,Jt.On)(e),this.modelCache.size>5e3&&this.modelCache.clear(),this.modelCache.set(e,t)),t}cellKey(e){return`${e.tableColumn?.name??e.gridColumn?.name??"?"}::${e.tableRowIndex??-1}`}}function hn(e,t){e.set(t,(e.get(t)??0)+1)}function dn(e,t){const n=[],o=new Map;for(const[t,n]of e.entries()){const e=(0,Xt.xh)(t,null).meta;"RNA"!==e.short&&"DNA"!==e.short&&o.set(e.short,(o.get(e.short)??0)+n)}for(const[e,t]of o.entries())n.push(`${e} ×${t}`);const r=new Map;for(const[e,n]of t.entries()){const t=(0,Xt.bM)(e).meta;"PO"!==t.short&&r.set(t.short,(r.get(t.short)??0)+n)}for(const[e,t]of r.entries())n.push(`${e} ×${t}`);return n.length?n.join(", "):"unmodified"}function pn(e,t){return P.divV([P.divText(e,{style:{fontWeight:"600",marginTop:"8px",marginBottom:"4px",color:"var(--grey-5, #555)",textTransform:"uppercase",fontSize:"10px",letterSpacing:"0.04em"}}),t])}const mn=/^(RNA|DNA|PEPTIDE|CHEM|BLOB)\d+\{/;function fn(e,t){const n=P.div([],{style:{minHeight:"60px"}});return n.appendChild(P.divText("Building structure…",{style:{fontSize:"11px",color:"var(--grey-4, #888)",padding:"4px"}})),(async()=>{try{const t=r.SemanticValue.fromTableCell(e),i=await o.functions.call("Bio:toAtomicLevelPanel",{sequence:t});n.innerHTML="",n.appendChild(i?.root??P.divText("Structure not available",{style:{fontSize:"11px",color:"var(--grey-4, #888)"}}))}catch(e){n.innerHTML="",n.appendChild(P.divText(`${t} render failed: ${e?.message??String(e)}`,{style:{fontSize:"11px",color:"var(--grey-4, #888)"}}))}})(),n}function gn(e){return e.semType=Xt.mU,e.meta.units=Xt.D2,e.setTag("cell.renderer",Xt.mU),e.setTag("quality",Xt.mU),e}function yn(e,t){return e.split("$")[0].replace(/^(RNA|DNA|PEPTIDE|CHEM|BLOB)\d+\{/,`$1${t}{`)}var bn=n(9124),vn=n(9192),Cn=n(8312),xn=n(1991),wn=n.n(xn);const An="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,Tn=new Set,En="object"==typeof process&&process?process:{},Sn=(e,t,n,o)=>{"function"==typeof En.emitWarning?En.emitWarning(e,t,n,o):console.error(`[${n}] ${t}: ${e}`)};let Nn=globalThis.AbortController,In=globalThis.AbortSignal;if(void 0===Nn){In=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(e,t){this._onabort.push(t)}},Nn=class{constructor(){t()}signal=new In;abort(e){if(!this.signal.aborted){this.signal.reason=e,this.signal.aborted=!0;for(const t of this.signal._onabort)t(e);this.signal.onabort?.(e)}}};let e="1"!==En.env?.LRU_CACHE_IGNORE_AC_WARNING;const t=()=>{e&&(e=!1,Sn("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",t))}}Symbol("type");const Mn=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),Pn=e=>Mn(e)?e<=Math.pow(2,8)?Uint8Array:e<=Math.pow(2,16)?Uint16Array:e<=Math.pow(2,32)?Uint32Array:e<=Number.MAX_SAFE_INTEGER?_n:null:null;class _n extends Array{constructor(e){super(e),this.fill(0)}}class Ln{heap;length;static#e=!1;static create(e){const t=Pn(e);if(!t)return[];Ln.#e=!0;const n=new Ln(e,t);return Ln.#e=!1,n}constructor(e,t){if(!Ln.#e)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}}class On{#t;#n;#o;#r;#i;#s;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#a;#l;#c;#u;#h;#d;#p;#m;#f;#g;#y;#b;#v;#C;#x;#w;#A;static unsafeExposeInternals(e){return{starts:e.#v,ttls:e.#C,sizes:e.#b,keyMap:e.#c,keyList:e.#u,valList:e.#h,next:e.#d,prev:e.#p,get head(){return e.#m},get tail(){return e.#f},free:e.#g,isBackgroundFetch:t=>e.#T(t),backgroundFetch:(t,n,o,r)=>e.#E(t,n,o,r),moveToTail:t=>e.#S(t),indexes:t=>e.#N(t),rindexes:t=>e.#I(t),isStale:t=>e.#M(t)}}get max(){return this.#t}get maxSize(){return this.#n}get calculatedSize(){return this.#l}get size(){return this.#a}get fetchMethod(){return this.#i}get memoMethod(){return this.#s}get dispose(){return this.#o}get disposeAfter(){return this.#r}constructor(e){const{max:t=0,ttl:n,ttlResolution:o=1,ttlAutopurge:r,updateAgeOnGet:i,updateAgeOnHas:s,allowStale:a,dispose:l,disposeAfter:c,noDisposeOnSet:u,noUpdateTTL:h,maxSize:d=0,maxEntrySize:p=0,sizeCalculation:m,fetchMethod:f,memoMethod:g,noDeleteOnFetchRejection:y,noDeleteOnStaleGet:b,allowStaleOnFetchRejection:v,allowStaleOnFetchAbort:C,ignoreFetchAbort:x}=e;if(0!==t&&!Mn(t))throw new TypeError("max option must be a nonnegative integer");const w=t?Pn(t):Array;if(!w)throw new Error("invalid max value: "+t);if(this.#t=t,this.#n=d,this.maxEntrySize=p||this.#n,this.sizeCalculation=m,this.sizeCalculation){if(!this.#n&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if("function"!=typeof this.sizeCalculation)throw new TypeError("sizeCalculation set to non-function")}if(void 0!==g&&"function"!=typeof g)throw new TypeError("memoMethod must be a function if defined");if(this.#s=g,void 0!==f&&"function"!=typeof f)throw new TypeError("fetchMethod must be a function if specified");if(this.#i=f,this.#w=!!f,this.#c=new Map,this.#u=new Array(t).fill(void 0),this.#h=new Array(t).fill(void 0),this.#d=new w(t),this.#p=new w(t),this.#m=0,this.#f=0,this.#g=Ln.create(t),this.#a=0,this.#l=0,"function"==typeof l&&(this.#o=l),"function"==typeof c?(this.#r=c,this.#y=[]):(this.#r=void 0,this.#y=void 0),this.#x=!!this.#o,this.#A=!!this.#r,this.noDisposeOnSet=!!u,this.noUpdateTTL=!!h,this.noDeleteOnFetchRejection=!!y,this.allowStaleOnFetchRejection=!!v,this.allowStaleOnFetchAbort=!!C,this.ignoreFetchAbort=!!x,0!==this.maxEntrySize){if(0!==this.#n&&!Mn(this.#n))throw new TypeError("maxSize must be a positive integer if specified");if(!Mn(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#P()}if(this.allowStale=!!a,this.noDeleteOnStaleGet=!!b,this.updateAgeOnGet=!!i,this.updateAgeOnHas=!!s,this.ttlResolution=Mn(o)||0===o?o:1,this.ttlAutopurge=!!r,this.ttl=n||0,this.ttl){if(!Mn(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#_()}if(0===this.#t&&0===this.ttl&&0===this.#n)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#t&&!this.#n){const e="LRU_CACHE_UNBOUNDED";(e=>!Tn.has(e))(e)&&(Tn.add(e),Sn("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",e,On))}}getRemainingTTL(e){return this.#c.has(e)?1/0:0}#_(){const e=new _n(this.#t),t=new _n(this.#t);this.#C=e,this.#v=t,this.#L=(n,o,r=An.now())=>{if(t[n]=0!==o?r:0,e[n]=o,0!==o&&this.ttlAutopurge){const e=setTimeout((()=>{this.#M(n)&&this.#O(this.#u[n],"expire")}),o+1);e.unref&&e.unref()}},this.#R=n=>{t[n]=0!==e[n]?An.now():0},this.#$=(r,i)=>{if(e[i]){const s=e[i],a=t[i];if(!s||!a)return;r.ttl=s,r.start=a,r.now=n||o();const l=r.now-a;r.remainingTTL=s-l}};let n=0;const o=()=>{const e=An.now();if(this.ttlResolution>0){n=e;const t=setTimeout((()=>n=0),this.ttlResolution);t.unref&&t.unref()}return e};this.getRemainingTTL=r=>{const i=this.#c.get(r);if(void 0===i)return 0;const s=e[i],a=t[i];return s&&a?s-((n||o())-a):1/0},this.#M=r=>{const i=t[r],s=e[r];return!!s&&!!i&&(n||o())-i>s}}#R=()=>{};#$=()=>{};#L=()=>{};#M=()=>!1;#P(){const e=new _n(this.#t);this.#l=0,this.#b=e,this.#D=t=>{this.#l-=e[t],e[t]=0},this.#B=(e,t,n,o)=>{if(this.#T(t))return 0;if(!Mn(n)){if(!o)throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");if("function"!=typeof o)throw new TypeError("sizeCalculation must be a function");if(n=o(t,e),!Mn(n))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return n},this.#F=(t,n,o)=>{if(e[t]=n,this.#n){const n=this.#n-e[t];for(;this.#l>n;)this.#k(!0)}this.#l+=e[t],o&&(o.entrySize=n,o.totalCalculatedSize=this.#l)}}#D=e=>{};#F=(e,t,n)=>{};#B=(e,t,n,o)=>{if(n||o)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#N({allowStale:e=this.allowStale}={}){if(this.#a)for(let t=this.#f;this.#H(t)&&(!e&&this.#M(t)||(yield t),t!==this.#m);)t=this.#p[t]}*#I({allowStale:e=this.allowStale}={}){if(this.#a)for(let t=this.#m;this.#H(t)&&(!e&&this.#M(t)||(yield t),t!==this.#f);)t=this.#d[t]}#H(e){return void 0!==e&&this.#c.get(this.#u[e])===e}*entries(){for(const e of this.#N())void 0===this.#h[e]||void 0===this.#u[e]||this.#T(this.#h[e])||(yield[this.#u[e],this.#h[e]])}*rentries(){for(const e of this.#I())void 0===this.#h[e]||void 0===this.#u[e]||this.#T(this.#h[e])||(yield[this.#u[e],this.#h[e]])}*keys(){for(const e of this.#N()){const t=this.#u[e];void 0===t||this.#T(this.#h[e])||(yield t)}}*rkeys(){for(const e of this.#I()){const t=this.#u[e];void 0===t||this.#T(this.#h[e])||(yield t)}}*values(){for(const e of this.#N())void 0===this.#h[e]||this.#T(this.#h[e])||(yield this.#h[e])}*rvalues(){for(const e of this.#I())void 0===this.#h[e]||this.#T(this.#h[e])||(yield this.#h[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,t={}){for(const n of this.#N()){const o=this.#h[n],r=this.#T(o)?o.__staleWhileFetching:o;if(void 0!==r&&e(r,this.#u[n],this))return this.get(this.#u[n],t)}}forEach(e,t=this){for(const n of this.#N()){const o=this.#h[n],r=this.#T(o)?o.__staleWhileFetching:o;void 0!==r&&e.call(t,r,this.#u[n],this)}}rforEach(e,t=this){for(const n of this.#I()){const o=this.#h[n],r=this.#T(o)?o.__staleWhileFetching:o;void 0!==r&&e.call(t,r,this.#u[n],this)}}purgeStale(){let e=!1;for(const t of this.#I({allowStale:!0}))this.#M(t)&&(this.#O(this.#u[t],"expire"),e=!0);return e}info(e){const t=this.#c.get(e);if(void 0===t)return;const n=this.#h[t],o=this.#T(n)?n.__staleWhileFetching:n;if(void 0===o)return;const r={value:o};if(this.#C&&this.#v){const e=this.#C[t],n=this.#v[t];if(e&&n){const t=e-(An.now()-n);r.ttl=t,r.start=Date.now()}}return this.#b&&(r.size=this.#b[t]),r}dump(){const e=[];for(const t of this.#N({allowStale:!0})){const n=this.#u[t],o=this.#h[t],r=this.#T(o)?o.__staleWhileFetching:o;if(void 0===r||void 0===n)continue;const i={value:r};if(this.#C&&this.#v){i.ttl=this.#C[t];const e=An.now()-this.#v[t];i.start=Math.floor(Date.now()-e)}this.#b&&(i.size=this.#b[t]),e.unshift([n,i])}return e}load(e){this.clear();for(const[t,n]of e){if(n.start){const e=Date.now()-n.start;n.start=An.now()-e}this.set(t,n.value,n)}}set(e,t,n={}){if(void 0===t)return this.delete(e),this;const{ttl:o=this.ttl,start:r,noDisposeOnSet:i=this.noDisposeOnSet,sizeCalculation:s=this.sizeCalculation,status:a}=n;let{noUpdateTTL:l=this.noUpdateTTL}=n;const c=this.#B(e,t,n.size||0,s);if(this.maxEntrySize&&c>this.maxEntrySize)return a&&(a.set="miss",a.maxEntrySizeExceeded=!0),this.#O(e,"set"),this;let u=0===this.#a?void 0:this.#c.get(e);if(void 0===u)u=0===this.#a?this.#f:0!==this.#g.length?this.#g.pop():this.#a===this.#t?this.#k(!1):this.#a,this.#u[u]=e,this.#h[u]=t,this.#c.set(e,u),this.#d[this.#f]=u,this.#p[u]=this.#f,this.#f=u,this.#a++,this.#F(u,c,a),a&&(a.set="add"),l=!1;else{this.#S(u);const n=this.#h[u];if(t!==n){if(this.#w&&this.#T(n)){n.__abortController.abort(new Error("replaced"));const{__staleWhileFetching:t}=n;void 0===t||i||(this.#x&&this.#o?.(t,e,"set"),this.#A&&this.#y?.push([t,e,"set"]))}else i||(this.#x&&this.#o?.(n,e,"set"),this.#A&&this.#y?.push([n,e,"set"]));if(this.#D(u),this.#F(u,c,a),this.#h[u]=t,a){a.set="replace";const e=n&&this.#T(n)?n.__staleWhileFetching:n;void 0!==e&&(a.oldValue=e)}}else a&&(a.set="update")}if(0===o||this.#C||this.#_(),this.#C&&(l||this.#L(u,o,r),a&&this.#$(a,u)),!i&&this.#A&&this.#y){const e=this.#y;let t;for(;t=e?.shift();)this.#r?.(...t)}return this}pop(){try{for(;this.#a;){const e=this.#h[this.#m];if(this.#k(!0),this.#T(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(void 0!==e)return e}}finally{if(this.#A&&this.#y){const e=this.#y;let t;for(;t=e?.shift();)this.#r?.(...t)}}}#k(e){const t=this.#m,n=this.#u[t],o=this.#h[t];return this.#w&&this.#T(o)?o.__abortController.abort(new Error("evicted")):(this.#x||this.#A)&&(this.#x&&this.#o?.(o,n,"evict"),this.#A&&this.#y?.push([o,n,"evict"])),this.#D(t),e&&(this.#u[t]=void 0,this.#h[t]=void 0,this.#g.push(t)),1===this.#a?(this.#m=this.#f=0,this.#g.length=0):this.#m=this.#d[t],this.#c.delete(n),this.#a--,t}has(e,t={}){const{updateAgeOnHas:n=this.updateAgeOnHas,status:o}=t,r=this.#c.get(e);if(void 0!==r){const e=this.#h[r];if(this.#T(e)&&void 0===e.__staleWhileFetching)return!1;if(!this.#M(r))return n&&this.#R(r),o&&(o.has="hit",this.#$(o,r)),!0;o&&(o.has="stale",this.#$(o,r))}else o&&(o.has="miss");return!1}peek(e,t={}){const{allowStale:n=this.allowStale}=t,o=this.#c.get(e);if(void 0===o||!n&&this.#M(o))return;const r=this.#h[o];return this.#T(r)?r.__staleWhileFetching:r}#E(e,t,n,o){const r=void 0===t?void 0:this.#h[t];if(this.#T(r))return r;const i=new Nn,{signal:s}=n;s?.addEventListener("abort",(()=>i.abort(s.reason)),{signal:i.signal});const a={signal:i.signal,options:n,context:o},l=(o,r=!1)=>{const{aborted:s}=i.signal,l=n.ignoreFetchAbort&&void 0!==o;if(n.status&&(s&&!r?(n.status.fetchAborted=!0,n.status.fetchError=i.signal.reason,l&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),s&&!l&&!r)return c(i.signal.reason);const h=u;return this.#h[t]===u&&(void 0===o?h.__staleWhileFetching?this.#h[t]=h.__staleWhileFetching:this.#O(e,"fetch"):(n.status&&(n.status.fetchUpdated=!0),this.set(e,o,a.options))),o},c=o=>{const{aborted:r}=i.signal,s=r&&n.allowStaleOnFetchAbort,a=s||n.allowStaleOnFetchRejection,l=a||n.noDeleteOnFetchRejection,c=u;if(this.#h[t]===u&&(l&&void 0!==c.__staleWhileFetching?s||(this.#h[t]=c.__staleWhileFetching):this.#O(e,"fetch")),a)return n.status&&void 0!==c.__staleWhileFetching&&(n.status.returnedStale=!0),c.__staleWhileFetching;if(c.__returned===c)throw o};n.status&&(n.status.fetchDispatched=!0);const u=new Promise(((t,o)=>{const s=this.#i?.(e,r,a);s&&s instanceof Promise&&s.then((e=>t(void 0===e?void 0:e)),o),i.signal.addEventListener("abort",(()=>{n.ignoreFetchAbort&&!n.allowStaleOnFetchAbort||(t(void 0),n.allowStaleOnFetchAbort&&(t=e=>l(e,!0)))}))})).then(l,(e=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=e),c(e)))),h=Object.assign(u,{__abortController:i,__staleWhileFetching:r,__returned:void 0});return void 0===t?(this.set(e,h,{...a.options,status:void 0}),t=this.#c.get(e)):this.#h[t]=h,h}#T(e){if(!this.#w)return!1;const t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof Nn}async fetch(e,t={}){const{allowStale:n=this.allowStale,updateAgeOnGet:o=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,ttl:i=this.ttl,noDisposeOnSet:s=this.noDisposeOnSet,size:a=0,sizeCalculation:l=this.sizeCalculation,noUpdateTTL:c=this.noUpdateTTL,noDeleteOnFetchRejection:u=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:h=this.allowStaleOnFetchRejection,ignoreFetchAbort:d=this.ignoreFetchAbort,allowStaleOnFetchAbort:p=this.allowStaleOnFetchAbort,context:m,forceRefresh:f=!1,status:g,signal:y}=t;if(!this.#w)return g&&(g.fetch="get"),this.get(e,{allowStale:n,updateAgeOnGet:o,noDeleteOnStaleGet:r,status:g});const b={allowStale:n,updateAgeOnGet:o,noDeleteOnStaleGet:r,ttl:i,noDisposeOnSet:s,size:a,sizeCalculation:l,noUpdateTTL:c,noDeleteOnFetchRejection:u,allowStaleOnFetchRejection:h,allowStaleOnFetchAbort:p,ignoreFetchAbort:d,status:g,signal:y};let v=this.#c.get(e);if(void 0===v){g&&(g.fetch="miss");const t=this.#E(e,v,b,m);return t.__returned=t}{const t=this.#h[v];if(this.#T(t)){const e=n&&void 0!==t.__staleWhileFetching;return g&&(g.fetch="inflight",e&&(g.returnedStale=!0)),e?t.__staleWhileFetching:t.__returned=t}const r=this.#M(v);if(!f&&!r)return g&&(g.fetch="hit"),this.#S(v),o&&this.#R(v),g&&this.#$(g,v),t;const i=this.#E(e,v,b,m),s=void 0!==i.__staleWhileFetching&&n;return g&&(g.fetch=r?"stale":"refresh",s&&r&&(g.returnedStale=!0)),s?i.__staleWhileFetching:i.__returned=i}}async forceFetch(e,t={}){const n=await this.fetch(e,t);if(void 0===n)throw new Error("fetch() returned undefined");return n}memo(e,t={}){const n=this.#s;if(!n)throw new Error("no memoMethod provided to constructor");const{context:o,forceRefresh:r,...i}=t,s=this.get(e,i);if(!r&&void 0!==s)return s;const a=n(e,s,{options:i,context:o});return this.set(e,a,i),a}get(e,t={}){const{allowStale:n=this.allowStale,updateAgeOnGet:o=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,status:i}=t,s=this.#c.get(e);if(void 0!==s){const t=this.#h[s],a=this.#T(t);return i&&this.#$(i,s),this.#M(s)?(i&&(i.get="stale"),a?(i&&n&&void 0!==t.__staleWhileFetching&&(i.returnedStale=!0),n?t.__staleWhileFetching:void 0):(r||this.#O(e,"expire"),i&&n&&(i.returnedStale=!0),n?t:void 0)):(i&&(i.get="hit"),a?t.__staleWhileFetching:(this.#S(s),o&&this.#R(s),t))}i&&(i.get="miss")}#G(e,t){this.#p[t]=e,this.#d[e]=t}#S(e){e!==this.#f&&(e===this.#m?this.#m=this.#d[e]:this.#G(this.#p[e],this.#d[e]),this.#G(this.#f,e),this.#f=e)}delete(e){return this.#O(e,"delete")}#O(e,t){let n=!1;if(0!==this.#a){const o=this.#c.get(e);if(void 0!==o)if(n=!0,1===this.#a)this.#U(t);else{this.#D(o);const n=this.#h[o];if(this.#T(n)?n.__abortController.abort(new Error("deleted")):(this.#x||this.#A)&&(this.#x&&this.#o?.(n,e,t),this.#A&&this.#y?.push([n,e,t])),this.#c.delete(e),this.#u[o]=void 0,this.#h[o]=void 0,o===this.#f)this.#f=this.#p[o];else if(o===this.#m)this.#m=this.#d[o];else{const e=this.#p[o];this.#d[e]=this.#d[o];const t=this.#d[o];this.#p[t]=this.#p[o]}this.#a--,this.#g.push(o)}}if(this.#A&&this.#y?.length){const e=this.#y;let t;for(;t=e?.shift();)this.#r?.(...t)}return n}clear(){return this.#U("delete")}#U(e){for(const t of this.#I({allowStale:!0})){const n=this.#h[t];if(this.#T(n))n.__abortController.abort(new Error("deleted"));else{const o=this.#u[t];this.#x&&this.#o?.(n,o,e),this.#A&&this.#y?.push([n,o,e])}}if(this.#c.clear(),this.#h.fill(void 0),this.#u.fill(void 0),this.#C&&this.#v&&(this.#C.fill(0),this.#v.fill(0)),this.#b&&this.#b.fill(0),this.#m=0,this.#f=0,this.#g.length=0,this.#l=0,this.#a=0,this.#A&&this.#y){const e=this.#y;let t;for(;t=e?.shift();)this.#r?.(...t)}}}function Rn(){var e;return null!==(e=window.$monomerHover)&&void 0!==e?e:null}function $n(e){window.$monomerHover=e}function Dn(e,t){let n=e["substruct-providers"];n||(n=e["substruct-providers"]=[]),n.push(t),e["substruct-providers"]=n}var Bn=n(6077),Fn=n(3561),kn=n(9235);const Hn="MonomerHoverLinks";function Gn(e,t){let n=e[Hn];n||(n=e[Hn]=[]),n.push(t),e[Hn]=n}function Un(e,t){try{const n=e.tableColumn;if(!n)return;const o=function(e){return e.temp[Hn]??[]}(n);for(let n=o.length-1;n>=0;--n){const r=o[n],i=e.grid.col(r.targetCol.name);if(i&&!r.handler(e,t,i))break}}catch(e){console.error(e)}}var Vn=n(6717),jn=n(6694),qn=n(4229),Wn=n(5174);function zn(e,t=!0){const[n,r]=(0,vn.AP)(e);return br.logger.error(n,void 0,r),t&&o.shell.error(n),[n,r]}const Yn={symbol:"Short Name",name:"Medium Name",smiles:"SMILES"},Kn=[{capGroupSmiles:"[*:1][H]",alternateId:"R1-H",capGroupName:"H",label:"R1"},{capGroupSmiles:"O[*:2]",alternateId:"R2-OH",capGroupName:"OH",label:"R2"},{capGroupSmiles:"[*:3][H]",alternateId:"R3-H",capGroupName:"H",label:"R3"}],Qn="Get HELM",Jn="Chirality engine",Xn="Highlight monomers",Zn="PolyTool Conversion",eo="PolyTool Helm Enumeration",to="Rules used",no={single:"Each position is enumerated independently. Total results = sum of monomers across all positions.",parallel:"The i-th result uses the i-th monomer from every position (zip). All positions must have the same number of monomers. Total results = number of monomers per position.",matrix:"Cartesian product of all positions. Total results = product of monomer counts across all positions."};var oo=n(5412);async function ro(e,t,n,i,s,a){const l=r.TaskBarProgressIndicator.create("PolyTool converting...");try{const l=(e,t)=>e?e.columns.getUnusedName(t):t,c=await(0,bn.b2)(),u=e.dataFrame,h=await(0,jn.Q4)(a),[d,p,m]=(0,qn.b)(e.toList(),h,c),f=l(u,`transformed(${e.name})`),g=r.Column.fromType(r.COLUMN_TYPE.STRING,f,d.length).init((e=>d[e]));g.semType=r.SEMTYPE.MACROMOLECULE,g.meta.units=Ot.Hi.HELM,g.setTag(r.TAGS.CELL_RENDERER,"helm"),t&&u&&u.columns.add(g,!0);const y=await(0,Vn.j)(),b=await(0,Cn.Q)(),v=await(0,Wn.A)(h),C=g.temp;C[".mm.cellRenderer.overriddenLibrary"]=v,g.temp=C;const x=await(0,oo.m)(g,d,p,i,s,n,v,y,b);return x.name=l(u,`molfile(${e.name})`),x.semType=r.SEMTYPE.MOLECULE,u&&(u.columns.add(x,!0),await o.data.detectSemanticTypes(u)),function(e,t,n,o,r,i,s){const a=new On({max:100});function l(e,t){const n=e.get(t);if(null==n)return null;let s=a.get(n);return s||a.set(n,s=function(e,t){const n=r.getSeqHandler(e),s=n.getSplitted(t),a=n.defaultBiotype,l=wn().count(0).take(s.length).map((e=>({position:e,symbol:s.getCanonical(e),biotype:a}))).toArray(),c=n.alphabet,u=c==Ot.YI.RNA||c==Ot.YI.DNA?"RNA":"PEPTIDE",h=(0,Bn.eM)([l],[void 0],u,c,o,i);return(0,Fn.gU)(l,h,c,u).monomers}(e,t)),s}const c={targetCol:n,handler:(e,n,r)=>{if(!e||!r.grid||!t.dataFrame)return!0;const i=r.grid,a=e.tableRowIndex,c=e.gridRow,u=i.cell(r.name,c),h=s[c],d=Rn();if(!d||d&&(d.dataFrameId!=t.dataFrame?.id||d.gridRowIdx!=c||d.seqColName!=t.name||d.seqPosition!=n?.position)){if(d&&($n(null),d.gridCell.render()),!n)return $n(null),!0;$n({gridCell:u,dataFrameId:t.dataFrame.id,gridRowIdx:c,seqColName:t.name,seqPosition:n?n.position:-1,getSubstruct:()=>{if(!n||"*"===n.symbol)return;const e=l(t,a);if(!e)return;const r=[],i=h[n.position];for(const t of i){const n=e.get(t);if(!n)return{atoms:[],bonds:[],highlightAtomColors:[],highlightBondColors:[]};r.push((0,kn.H)([n],o))}return function(e){var t,n,o,r;const i={atoms:[],bonds:[],highlightAtomColors:{},highlightBondColors:{}};for(const s of e)i.atoms=[...null!==(t=i.atoms)&&void 0!==t?t:[],...null!==(n=s.atoms)&&void 0!==n?n:[]],i.bonds=[...null!==(o=i.bonds)&&void 0!==o?o:[],...null!==(r=s.bonds)&&void 0!==r?r:[]],i.highlightAtomColors=Object.assign(Object.assign({},i.highlightAtomColors),s.highlightAtomColors),i.highlightBondColors=Object.assign(Object.assign({},i.highlightBondColors),s.highlightBondColors);return i}(r)}}),u.render()}return!0},getSubstruct:e=>{if("true"!=n.getTag(".sequence-src-highlight-monomers"))return;if(null==e)return;if(!t.get(e))return;const r=l(t,e);return r?(0,kn.H)(r.values(),o):void 0}};Gn(e.temp,c),Dn(n.temp,c)}(e,g,x,v,b,y,m),[g,x]}finally{l.close()}}var io=n(3309);const so="PolyTool Chem Enumeration",ao={[io.PI.Zip]:"Zip: every R-group list must have the same length N. The i-th result uses the i-th entry from every list. Produces N results per core.",[io.PI.Cartesian]:"Cartesian: every combination of entries across R-group lists. Produces ∏|Rᵢ| results per core."},lo=110,co=104,uo=100,ho=72,po=320,mo=260;function fo(e,t,n,r){P.empty(e);try{const i=o.chem.drawMolecule(t,n,r);i.style.width=`${n}px`,i.style.height=`${r}px`,i.style.maxWidth=`${n}px`,i.style.maxHeight=`${r}px`,i.style.display="block",e.appendChild(i)}catch{e.appendChild(P.divText("—",{style:{color:"var(--grey-4)"}}))}}function go(e){const t=P.div([],{style:{width:`${uo}px`,height:`${ho}px`,display:"flex",alignItems:"center",justifyContent:"center",background:"transparent",overflow:"hidden",flex:"0 0 auto"}});e.smiles&&!e.error?fo(t,e.smiles,uo,ho):t.appendChild(P.divText("—",{style:{color:"var(--grey-4)"}}));const n=P.divText(e.subtitle,{style:{fontSize:"10px",color:e.error?"var(--red-3)":"var(--grey-5)",textAlign:"center",padding:"2px 4px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}}),o=P.divV([t,n],{style:{width:`${lo}px`,minWidth:`${lo}px`,height:`${co}px`,border:"2px solid "+(e.error?"var(--red-3)":"var(--grey-2)"),borderRadius:"4px",position:"relative",background:"var(--white)",boxSizing:"border-box",margin:"0 4px 0 0",overflow:"hidden",flex:"0 0 auto"}});if(e.smiles&&!e.error){let t=null;P.tooltip.bind(o,(()=>(t||(t=P.div([],{style:{width:`${po}px`,height:`${mo}px`}}),fo(t,e.smiles,po,mo)),t)))}else e.error&&P.tooltip.bind(o,e.error);const r=P.divH([],{style:{position:"absolute",top:"2px",right:"2px",gap:"2px",background:"rgba(255,255,255,0.85)",borderRadius:"4px",padding:"1px 2px",display:"none"}});if(e.onEdit){const t=P.icons.edit((t=>{t.stopPropagation(),e.onEdit()}),"Edit");r.appendChild(t)}if(e.onRemove){const t=P.icons.delete((t=>{t.stopPropagation(),e.onRemove()}),"Remove");r.appendChild(t)}return o.addEventListener("mouseenter",(()=>{r.style.display="flex"})),o.addEventListener("mouseleave",(()=>{r.style.display="none"})),(e.onEdit||e.onRemove)&&o.appendChild(r),o}async function yo(e,t){const n=e.getMolFile();if(!n||""===n.trim())return null;if(!r.chem.isMolBlock(n))return n.trim();try{return(await o.functions.call("Chem:convertMolNotation",{molecule:n,sourceNotation:r.chem.Notation.MolBlock,targetNotation:r.chem.Notation.Smiles})??"").toString().trim()||null}catch{return null}}async function bo(e,t){return new Promise((n=>{const o=new r.chem.Sketcher(r.chem.SKETCHER_MODE.INPLACE);o.syncCurrentObject=!1,t&&o.setMolFile(t);const i=P.divText("",{style:{fontSize:"11px",padding:"4px 0",minHeight:"18px"}});let s=null,a=null;const l=async()=>{s=await yo(o);const e=s?(0,io.Qk)(s):[];s?0===e.length?(i.innerText="No R-group detected — add e.g. [*:1] to mark an attachment point.",i.style.color="var(--red-3)"):(i.innerText=`Detected R-groups: ${e.map((e=>"R"+e)).join(", ")}.`,i.style.color="var(--green-2)"):(i.innerText="Draw a molecule with at least one R-group label.",i.style.color="var(--grey-4)"),a&&(a.disabled=!(s&&e.length>0))};o.onChanged.subscribe((()=>{l()}));const c=P.divV([o.root,i]),u=P.dialog({title:t?"Edit Core":"Draw Core"}).add(c).onOK((()=>n(s?(0,io.KS)(s,"",e):null))).onCancel((()=>n(null)));u.show({resizable:!0}),a=u.getButton("OK"),a.disabled=!0,l()}))}async function vo(e,t,n){return new Promise((o=>{const i=new r.chem.Sketcher(r.chem.SKETCHER_MODE.INPLACE);i.syncCurrentObject=!1,t&&i.setMolFile(t);const s=P.input.int("Target R#",{value:n,min:1}),a=P.divText("",{style:{fontSize:"11px",padding:"4px 0",minHeight:"18px"}});let l=null,c=[],u=null,h=!1;s.onChanged.subscribe((()=>{h=!0,d()}));const d=()=>{const e=s.value,t=null!=l&&null!=e&&e>=1&&1===c.length;u&&(u.disabled=!t)},p=async()=>{l=await yo(i),c=l?(0,io.Qk)(l):[],l?0===c.length?(a.innerText="No R-group detected — add [*:N] to mark the attachment point.",a.style.color="var(--red-3)"):c.length>1?(a.innerText=`R-group must contain exactly one attachment point. Found ${c.length}: ${c.map((e=>"R"+e)).join(", ")}.`,a.style.color="var(--red-3)"):(h&&null!=s.value||(s.value=c[0]),a.innerText=`Detected R${c[0]}. Target R# is used for joining; change it to remap.`,a.style.color="var(--green-2)"):(a.innerText="Draw an R-group with exactly one attachment point.",a.style.color="var(--grey-4)"),d()};i.onChanged.subscribe((()=>{p()}));const m=P.divV([i.root,s.root,a]),f=P.dialog({title:t?"Edit R-Group":"Draw R-Group"}).add(m).onOK((()=>{const t=s.value;o(l&&null!=t?(0,io.ah)(l,t,"",e):null)})).onCancel((()=>o(null)));f.show({resizable:!0}),u=f.getButton("OK"),u.disabled=!0,p()}))}async function Co(e,t,n){return new Promise((i=>{const s=e=>e.semType===r.SEMTYPE.MOLECULE,a=P.input.table("Table",{value:o.shell.t??void 0}),l=P.input.choice("Column",{items:[],nullable:!0}),c="rgroups"===e?P.input.int("Target R#",{value:1,min:1}):null,u=P.input.bool("Remove duplicates",{value:n});P.tooltip.bind(u.input,"cores"===e?"When checked, identical cores in the selected column are collapsed into one entry.":"When checked, identical R-groups are collapsed. Leave off for Zip mode if your lists are intentionally aligned by position.");const h=e=>{const t=a.value;if(!t)return l.items=[],void(l.value=null);const n=t.columns.toList().filter(s);if(l.items=n.map((e=>e.name)),e){const e=n.find((e=>e.semType===r.SEMTYPE.MOLECULE));l.value=(e??n[0])?.name??null}},d=P.div([],{style:{height:`${co+26}px`,overflow:"hidden",padding:"4px"}}),p=P.divText("",{style:{fontSize:"11px",color:"var(--grey-5)",margin:"4px 0"}}),m=xo();let f={},g=null,y=null;const b=()=>{m.setErrors([]),f={};const n=(()=>{const e=a.value,t=l.value;return e&&t?e.col(t):null})();if(!n)return p.innerText="",g&&(g.disabled=!0),void(y&&y.setData(0,(()=>P.div())));const o=[];for(let e=0;e<n.length;e++){if(n.isNone(e))continue;const t=n.get(e);null!=t&&""!==String(t).trim()&&o.push(String(t))}const r=u.value,i=[],s=[];if("cores"===e){const e=o.map((e=>(0,io.KS)(e,"",t)));let n=e,a=0;if(r){const t=new Set;n=[];for(const o of e){const e=o.error?`err:${o.originalSmiles}`:o.smiles;t.has(e)?a++:(t.add(e),n.push(o))}}f.cores=n,n.forEach(((e,t)=>{e.error&&s.push(`Core ${t+1}: ${e.error}`),i.push({smi:e.error?"":e.smiles,err:e.error,subtitle:e.error?"invalid":e.rNumbers.map((e=>"R"+e)).join(", ")})})),p.innerText=`${n.length} core${1===n.length?"":"s"}`+(r&&a?` (${a} duplicate${1===a?"":"s"} skipped)`:"")+"."}else{const e=c.value??1,n=o.map((n=>(0,io.ah)(n,e,"",t)));let a=n,l=0;if(r){const e=new Set;a=[];for(const t of n){const n=t.error?`err:${t.originalSmiles}`:t.smiles;e.has(n)?l++:(e.add(n),a.push(t))}}f.rGroups=a,a.forEach(((e,t)=>{e.error&&s.push(`R-group ${t+1}: ${e.error}`),i.push({smi:e.error?"":e.smiles,err:e.error,subtitle:e.error?"invalid":`R${e.rNumber}${null!=e.sourceRNumber&&e.sourceRNumber!==e.rNumber?` (from R${e.sourceRNumber})`:""}`})})),p.innerText=`${a.length} R-group${1===a.length?"":"s"} for R${e}`+(r&&l?` (${l} duplicate${1===l?"":"s"} skipped)`:"")+"."}m.setErrors(s),y?y.setData(i.length,(e=>go({smiles:i[e].smi,subtitle:i[e].subtitle,error:i[e].err}))):(y=P.virtualView(i.length,(e=>go({smiles:i[e].smi,subtitle:i[e].subtitle,error:i[e].err})),!1,1),y.root.style.height=`${co+12}px`,y.root.style.width="100%",d.appendChild(y.root)),g&&(g.disabled=0===o.length)};a.onChanged.subscribe((async()=>{const e=a.value;e&&(await e.meta.detectSemanticTypes(),await o.data.detectSemanticTypes(e)),h(!0),b()})),l.onChanged.subscribe((()=>{if("rgroups"===e&&l.value){const e=function(e){const t=e.match(/r[\s_\-:]*(\d+)/i);return t?parseInt(t[1],10):null}(l.value);null!=e&&(c.value=e)}b()})),c&&c.onChanged.subscribe((()=>b())),u.onChanged.subscribe((()=>b()));const v=P.divV([a.root,l.root,...c?[c.root]:[],u.root,P.divH([p,m.root],{style:{alignItems:"center",gap:"8px"}}),d]),C=P.dialog({title:"cores"===e?"Import Cores":"Import R-Groups"}).add(v).onOK((()=>i(f))).onCancel((()=>i(null)));C.show({resizable:!0,width:640}),g=C.getButton("OK"),g.disabled=!0,a.value&&a.value.meta.detectSemanticTypes().then((()=>{h(!0),b()}))}))}function xo(){const e=P.div([],{style:{display:"none",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"10px",background:"var(--red-2)",color:"var(--red-3)",fontSize:"11px",fontWeight:"600",cursor:"help"}});return{root:e,setErrors(t){0!==t.length?(e.style.display="inline-flex",e.innerText=`⚠ ${t.length} issue${1===t.length?"":"s"}`,P.tooltip.bind(e,t.join("\n"))):e.style.display="none"}}}async function wo(e){await br.initPromise;try{const t=await(0,Vn.j)();let n=null;if(e){const i=await async function(e){try{if(!e||e.rowIndex<0||e.column?.semType!==r.SEMTYPE.MOLECULE)return null;const t=e.value;return t?r.chem.isMolBlock(t)?t:await o.functions.call("Chem:convertMolNotation",{molecule:t,sourceNotation:e.column.getTag(r.TAGS.UNITS)??r.chem.Notation.Unknown,targetNotation:r.chem.Notation.MolBlock})??null:null}catch{return null}}(e);if(i){const e=await o.functions.call("Chem:convertMolNotation",{molecule:i,sourceNotation:r.chem.Notation.MolBlock,targetNotation:r.chem.Notation.Smiles});if(e){const r=(0,io.KS)(e,"",t);r.error?o.shell.info("Selected molecule has no R-group — add at least one R-label to use it as a core."):n=r}}}const i=Ao(t,n),s=P.dialog({title:so}).add(i.root).onOK((async()=>{await i.execute()}));i.bindActionButton(s.getButton("OK")),s.show({resizable:!0,width:960})}catch(e){zn(e)}}function Ao(e,t){const n={cores:t?[t]:[],rGroupsByNum:new Map,mode:io.PI.Cartesian,appendToTable:null},i=co+16,s=P.divText("No cores — draw or import at least one.",{style:{color:"var(--grey-4)",padding:"20px 12px",fontSize:"12px"}}),a=P.div([],{style:{width:"100%",height:`${i}px`,overflow:"hidden"}});let l=null;const c=t=>{const o=n.cores[t];return go({smiles:o.error?"":o.smiles,subtitle:o.error?"invalid":`core ${t+1} · ${o.rNumbers.map((e=>"R"+e)).join(", ")}`,error:o.error,onEdit:async()=>{const r=await bo(e,o.smiles);r&&(n.cores[t]=r,A())},onRemove:()=>{n.cores.splice(t,1),A()}})};function u(e){e.style.width="100%",e.style.height=`${i}px`,e.style.setProperty("overflow-y","hidden","important"),e.style.setProperty("overflow-x","auto","important");const t=e.firstElementChild;t&&(t.style.setProperty("overflow-y","hidden","important"),t.style.setProperty("overflow-x","auto","important"),t.style.height=`${i}px`)}const h=P.div([],{style:{width:"100%",padding:"2px 0",flex:"1 1 auto",minHeight:"0",overflowY:"auto",overflowX:"hidden"}}),d=P.divText("No R-groups — draw or import for each R number used by your cores.",{style:{color:"var(--grey-4)",padding:"12px",fontSize:"12px"}}),p=new Map,m=P.div([],{style:{width:"100%",display:"flex",flexWrap:"wrap",gap:"6px",alignContent:"flex-start",padding:"2px 0",maxHeight:"450px",overflow:"scroll"}}),f=P.divText("",{style:{fontSize:"12px",color:"var(--grey-6)"}}),g=xo(),y=P.input.choice("Enumerator type",{value:n.mode,items:Object.values(io.PI),onValueChanged:e=>{n.mode=e,b(),A()}}),b=()=>P.tooltip.bind(y.input,ao[n.mode]??"");b();const v=P.input.table("Append to table",{items:o.shell.tables,nullable:!0,onValueChanged:e=>{n.appendToTable=e}});let C,x,w=null;const A=()=>{(()=>{if(0===n.cores.length)return a.firstChild&&P.empty(a),l=null,s.parentElement!==a.parentElement&&a.parentElement?.insertBefore(s,a.nextSibling),a.style.display="none",void(s.style.display="block");a.style.display="block",s.style.display="none",l?l.setData(n.cores.length,c):(l=P.virtualView(n.cores.length,c,!1,1),u(l.root),a.appendChild(l.root))})(),(()=>{if(P.empty(h),p.clear(),0===n.rGroupsByNum.size)return void h.appendChild(d);const t=[...n.rGroupsByNum.keys()].sort(((e,t)=>e-t));for(const o of t){const t=n.rGroupsByNum.get(o),r=P.divText(`R${o} (${t.length})`,{style:{fontWeight:"600",fontSize:"12px",color:"var(--grey-6)",alignSelf:"center"}}),i=P.button("Remove all",(()=>{n.rGroupsByNum.delete(o),A()}));i.style.marginLeft="4px",P.tooltip.bind(i,`Remove all R${o} groups`);const s=P.divH([r,i],{style:{alignItems:"center",justifyContent:"flex-start",gap:"0",margin:"6px 0 2px"}}),a=r=>{const i=t[r],s=null!=i.sourceRNumber&&i.sourceRNumber!==i.rNumber?` (from R${i.sourceRNumber})`:"";return go({smiles:i.error?"":i.smiles,subtitle:i.error?"invalid":`r group ${r+1} · R${i.rNumber}${s}`,error:i.error,onEdit:async()=>{const o=await vo(e,i.smiles,i.rNumber);if(o){if(o.rNumber!==i.rNumber){t.splice(r,1),0===t.length&&n.rGroupsByNum.delete(i.rNumber);const e=n.rGroupsByNum.get(o.rNumber)??[];e.push(o),n.rGroupsByNum.set(o.rNumber,e)}else t[r]=o;A()}},onRemove:()=>{t.splice(r,1),0===t.length&&n.rGroupsByNum.delete(o),A()}})},l=P.virtualView(t.length,a,!1,1);u(l.root);const c=P.divV([s,l.root]);h.appendChild(c),p.set(o,{row:c,vv:l,header:s})}})();const t=(0,io.XB)({cores:n.cores,rGroups:n.rGroupsByNum,mode:n.mode});f.innerText=t.predictedCount>0?`${t.predictedCount.toLocaleString()} molecule${1===t.predictedCount?"":"s"} will be generated`:"",g.setErrors((()=>{const e=[];n.cores.forEach(((t,n)=>{t.error&&e.push(`Core ${n+1}: ${t.error}`)}));const t=[...n.rGroupsByNum.keys()].sort(((e,t)=>e-t));for(const o of t)n.rGroupsByNum.get(o).forEach(((t,n)=>{t.error&&e.push(`R${o} group ${n+1}: ${t.error}`)}));const o=(0,io.XB)({cores:n.cores,rGroups:n.rGroupsByNum,mode:n.mode});for(const t of o.errors)/^Core "/.test(t)||e.push(t);return e})()),w&&(w.disabled=!t.ok),C&&(C.disabled=0===n.cores.length),x&&(x.disabled=0===n.rGroupsByNum.size),(()=>{P.empty(m);const e=(0,io.xD)({cores:n.cores,rGroups:n.rGroupsByNum,mode:n.mode,maxResults:Math.min(io.u8,1e3)},12);0!==e.length?e.forEach(((e,t)=>{const n=[...e.rGroupSmilesByNum.keys()].sort(((e,t)=>e-t)).map((e=>"R"+e)).join(",");m.appendChild(go({smiles:e.smiles,subtitle:`sample ${t+1} · ${n}`}))})):m.appendChild(P.divText("Preview will appear once cores and R-groups are valid.",{style:{color:"var(--grey-4)",padding:"20px 12px",fontSize:"12px"}}))})()},T=(e,t,n,o)=>{const r=[P.divText(e,{style:{fontWeight:"600",fontSize:"12px",color:"var(--grey-6)",alignSelf:"center",minWidth:"60px"}})];if(t){const n=P.button("+ Draw",t);n.style.marginLeft="4px",P.tooltip.bind(n,`${e}: open sketcher`),r.push(n)}if(n){const t=P.button("↓ Import…",n);t.style.marginLeft="4px",P.tooltip.bind(t,`${e}: pick a table + column`),r.push(t)}let i;return o&&(i=P.button("Remove all",o),i.style.marginLeft="4px",P.tooltip.bind(i,`Remove all ${e.toLowerCase()}`),r.push(i)),{root:P.divH(r,{style:{alignItems:"center",justifyContent:"flex-start",gap:"0",margin:"0 0 2px",flex:"0 0 auto"}}),clearBtn:i}},E={display:"flex",flexDirection:"column",minHeight:"150px",padding:"4px 0"},S=T("Cores",(async()=>{const t=await bo(e);t&&(n.cores.push(t),A())}),(async()=>{const t=await Co("cores",e,n.mode===io.PI.Cartesian);t?.cores&&(n.cores.push(...t.cores),A())}),(()=>{n.cores.splice(0,n.cores.length),A()}));C=S.clearBtn;const N=P.divV([S.root,P.div([a,s],{style:{padding:"0"}})],{style:E}),I=T("R-Groups",(async()=>{const t=await vo(e);if(!t)return;const o=n.rGroupsByNum.get(t.rNumber)??[];o.push(t),n.rGroupsByNum.set(t.rNumber,o),A()}),(async()=>{const t=await Co("rgroups",e,n.mode===io.PI.Cartesian);if(t?.rGroups){for(const e of t.rGroups){const t=n.rGroupsByNum.get(e.rNumber)??[];t.push(e),n.rGroupsByNum.set(e.rNumber,t)}A()}}),(()=>{n.rGroupsByNum.clear(),A()}));x=I.clearBtn;const M=P.divV([I.root,h],{style:{display:"flex",flexDirection:"column",maxHeight:"300px",padding:"4px 0"}}),_=P.divV([T("Preview").root,m],{style:{...E,width:"100%",height:"100%",overflowY:"auto",overflowX:"hidden"}}),L=P.divV([N,M],{style:{flex:"0 0 60%",width:"60%",display:"flex",flexDirection:"column",gap:"4px",paddingRight:"8px",borderRight:"1px solid var(--grey-2)"}}),O=P.divV([_],{style:{flex:"0 0 40%",width:"40%",display:"flex",flexDirection:"column",paddingLeft:"8px"}}),R=P.divH([L,O],{style:{width:"100%",alignItems:"stretch",gap:"0"}}),$=P.divH([y.root,f,g.root],{style:{alignItems:"center",gap:"16px",padding:"4px 0"}}),D=P.div([v.root],{style:{padding:"2px 0"}}),B=P.divV([R,$,D],{style:{width:"100%",padding:"4px",display:"flex",flexDirection:"column",gap:"4px"}});return A(),{root:B,state:n,execute:()=>async function(e){const t=r.TaskBarProgressIndicator.create("Enumerating...");try{t.update(10,"Building molecules...");const n=(0,io.jp)({cores:e.cores,rGroups:e.rGroupsByNum,mode:e.mode});if(!n)return void o.shell.warning("Enumeration failed — check validation messages in the dialog.");if(0===n.length)return void o.shell.warning("No molecules produced.");const i=new Set;for(const e of n)for(const t of e.rGroupSmilesByNum.keys())i.add(t);const s=[...i].sort(((e,t)=>e-t)),a=r.Column.fromStrings("Enumerated",n.map((e=>e.smiles)));a.semType=r.SEMTYPE.MOLECULE;const l=r.Column.fromStrings("Core",n.map((e=>e.coreSmiles)));l.semType=r.SEMTYPE.MOLECULE;const c=s.map((e=>r.Column.fromStrings(`R${e}`,n.map((t=>t.rGroupSmilesByNum.get(e)??"")))));for(const e of c)e.semType=r.SEMTYPE.MOLECULE;const u=r.DataFrame.fromColumns([a,l,...c]);u.name="Chem Enumeration",t.update(40,`Canonicalizing ${n.length.toLocaleString()} molecule(s)...`);try{await o.functions.call("Chem:convertNotation",{data:u,molecules:a,targetNotation:r.chem.Notation.Smiles,overwrite:!0,join:!1,kekulize:!1})}catch(e){br.logger.warning(`Canonicalization skipped: ${e?.message??e}`)}t.update(90,"Finalizing..."),await o.data.detectSemanticTypes(u),e.appendToTable?(e.appendToTable.append(u,!0),await e.appendToTable.meta.detectSemanticTypes()):o.shell.addTableView(u)}catch(e){zn(e)}finally{t.close()}}(n),bindActionButton:e=>{w=e,A()}}}var To=n(6197);class Eo extends r.InputBase{constructor(e,t){super(P.input.column(e,t).dart,t?.onValueChanged),this.options=t}setColumnInputTable(e){P.input.setColumnInputTable(this,e,this.options?.filter)}}P.input.column2=function(e,t){return new Eo(e,t)};var So=n(1296),No=n(3820);class Io extends r.JsInputBase{get inputType(){return"Positions"}get dataType(){return r.TYPE.DATA_FRAME}getInput(){return this.gridHost}getValue(){return this.grid.dataFrame}setValue(e){this.setDataFrame(e)}getStringValue(){return this.grid.dataFrame.toCsv()}setStringValue(e){this.setDataFrame(r.DataFrame.fromCsv(e))}clearInput(){const e=r.DataFrame.fromColumns([r.Column.fromType(r.COLUMN_TYPE.STRING,"Remove",0),r.Column.fromType(r.COLUMN_TYPE.INT,"Position",0),r.Column.fromType(r.COLUMN_TYPE.STRING,"Monomers",0)]);this.setDataFrame(e)}get placeholdersValue(){return function(e){const t=[];for(let n=0;n<e.rowCount;n++){if(e.getCol("Position").isNone(n))continue;const o=parseInt(e.get("Position",n))-1;if(!isNaN(o)){const r=Mo(e.get("Monomers",n));t.push({position:o,monomers:r})}}return t}(this.grid.dataFrame)}invalidateGrid(){if(this.grid){const e=this.grid.root.style.width;this.grid.root.style.width="99.9%",setTimeout((()=>{e?this.grid.root.style.width=e:this.grid.root.style.removeProperty("width")}),100)}}constructor(e,t,n){super(),this.name=e,this.onMonomerCellEdit=null,this.subs=[],this.dataFrameSubs=[],this.caption=e??"",this.root.classList.add("ui-input-polytool-pos-grid"),this.root.append(this.gridHost=P.div([],{classes:"ui-input-editor",style:{width:"100%",height:"100%",marginTop:"-8px",marginBottom:"8px",paddingBottom:"4px"}})),this.render(t,n).then((()=>{}))}detach(){for(const e of this.subs)e.unsubscribe();for(const e of this.dataFrameSubs)e.unsubscribe()}async render(e,t){let n;const o=r.DataFrame.fromColumns([n=r.Column.fromType(r.COLUMN_TYPE.STRING,"Remove",0),r.Column.fromType(r.COLUMN_TYPE.INT,"Position",0),r.Column.fromType(r.COLUMN_TYPE.STRING,"Monomers",0)]);n.setTag(r.TAGS.FRIENDLY_NAME,""),this.grid=await o.plot.fromType(r.VIEWER.GRID,t),this.grid.sort(["Position"]),this.grid.columns.byIndex(1).width=this.grid.props.rowHeight+2,this.grid.onCellRender.subscribe((e=>{const t=e.cell;t.tableColumn?.name==n.name&&(t?.tableRowIndex??-1)>=0&&(t.element=P.div(P.icons.delete((()=>{this.grid.dataFrame.rows.removeAt(t.tableRowIndex)}),"Delete"),{style:{height:`${t.grid.props.rowHeight}px`,color:"var(--grey-6)",display:"flex",flexDirection:"row",justifyContent:"center"}}))}));const i=this.grid.columns.byName("Monomers");i&&(i.editable=!1),this.subs.push(this.grid.onCellDoubleClick.subscribe((e=>{"Monomers"===e.tableColumn?.name&&null!=e.tableRowIndex&&e.tableRowIndex>=0&&this.handleMonomerCellDoubleClick(e.tableRowIndex)}))),this.updateGridHeight(e??this.grid.dataFrame.rowCount+.7),this.subs.push(P.onSizeChanged(this.grid.root).subscribe(this.gridRootOnSizeChanged.bind(this))),this.subs.push((0,te.fromEvent)(this.grid.root,"keydown").subscribe((e=>{"Enter"===e.key&&e.stopPropagation()}))),this.setDataFrame(o),this.grid.root.style.width="100%",this.gridHost.append(this.grid.root)}setDataFrame(e){for(const e of this.dataFrameSubs)e.unsubscribe();this.grid.dataFrame=e,this.dataFrameSubs.push(this.grid.dataFrame.onRowsRemoved.subscribe((()=>{this.updateGridHeight(this.grid.dataFrame.rowCount+.7),this.fireChanged()}))),this.dataFrameSubs.push(this.grid.dataFrame.onRowsAdded.subscribe((()=>{this.updateGridHeight(this.grid.dataFrame.rowCount+.7)}))),this.dataFrameSubs.push(this.grid.dataFrame.onDataChanged.subscribe((()=>{this.fireChanged()}))),this.updateGridHeight(this.grid.dataFrame.rowCount+.7),this.fireChanged()}addPosition(e,t){const n=this.grid.dataFrame,o=n.columns.byName("Position").toList();let r=o.indexOf(e+1);-1===r&&(r=o.findIndex((e=>isNaN(e))),-1===r&&(r=n.rows.addNew(["",e+1,t??""]).idx),this.grid.cell("Monomers",r)),n.currentCell=n.cell(r,"Monomers")}setMonomersValue(e,t){const n=this.grid.dataFrame;n.rowCount<=e||n.set("Monomers",e,t)}static async create(e,t,n){return new Io(e,n,t)}updateGridHeight(e){const t=this.grid.colHeaderHeight+e*this.grid.props.rowHeight+6+2;this.grid.root.style.height=`${t}px`}async handleMonomerCellDoubleClick(e){if(!this.onMonomerCellEdit)return;const t=this.grid.dataFrame,n=parseInt(t.get("Position",e))-1;if(isNaN(n))return;const o=Mo(t.get("Monomers",e)??""),r=await this.onMonomerCellEdit(n,o);null!==r&&t.set("Monomers",e,r.join(", "))}gridRootOnSizeChanged(){this.grid.columns.byIndex(3).width=this.grid.root.clientWidth-this.grid.horzScroll.root.offsetWidth-this.grid.columns.byIndex(0).width-this.grid.columns.byIndex(1).width-this.grid.columns.byIndex(2).width-10}}function Mo(e){return e.split(/,(?![^(]*\))/).map((e=>('"'===(e=e.trim()).slice(0,1)&&'"'===e.slice(-1)&&(e=e.slice(1,-1)),"'"===e.slice(0,1)&&"'"===e.slice(-1)&&(e=e.slice(1,-1)),e.trim()))).filter((e=>!!e))}class Po{constructor(e,t,n,o){this.currentMenu=null,this.menuItems=[],this.highlightedIndex=-1,this.monomerLib=e,this.polymerType=t,this.helmType=(0,s.MD)(t),this.allSymbols=e.getMonomerSymbolsByType(t),this.libHelper=o,this.selectedMonomers=n?[...n]:[],this.tagsHost=P.div([],{style:{display:"flex",flexWrap:"wrap",gap:"4px",marginTop:"4px",maxHeight:"150px",overflowY:"auto"}}),this.countLabel=P.divText("",{style:{fontSize:"11px",color:"var(--grey-4)",marginTop:"4px"}});const r=P.input.string("Search",{value:""});this.inputEl=r.input,this.inputEl.setAttribute("autocomplete","off"),this.inputEl.placeholder="Type to search monomers...",this.setupInputListeners();const i=this.createLibrarySection(),a=this.createCollectionSection(),l=P.button("Clear all",(()=>{this.selectedMonomers.length=0,this.renderTags()}));l.style.fontSize="11px",l.style.marginTop="4px",this.renderTags(),this.root=P.div([r.root,i,a,P.divH([this.countLabel,l],{style:{justifyContent:"space-between",alignItems:"center"}}),this.tagsHost],{style:{minWidth:"300px"}})}getSelectedMonomers(){return[...this.selectedMonomers]}setSelectedMonomers(e){this.selectedMonomers.length=0,this.selectedMonomers.push(...e),this.renderTags()}setPolymerType(e){this.polymerType=e,this.helmType=(0,s.MD)(e),this.allSymbols=this.monomerLib.getMonomerSymbolsByType(e)}focus(){this.inputEl.focus()}updateCountLabel(){this.countLabel.textContent=this.selectedMonomers.length>0?`${this.selectedMonomers.length} monomer(s) selected`:""}renderTags(){this.tagsHost.innerHTML="";for(const e of this.selectedMonomers){const t=P.iconFA("times",(()=>{const t=this.selectedMonomers.indexOf(e);t>=0&&(this.selectedMonomers.splice(t,1),this.renderTags(),this.updateCountLabel())}),"Remove");t.style.marginLeft="4px",t.style.cursor="pointer";const n=P.div([P.span([e]),t],{style:{display:"inline-flex",alignItems:"center",padding:"2px 6px",borderRadius:"4px",backgroundColor:"var(--grey-2)",border:"1px solid var(--grey-3)",fontSize:"12px",cursor:"default"}});n.addEventListener("mouseenter",(()=>{const t=this.monomerLib.getTooltip(this.helmType,e);P.tooltip.show(t,n.getBoundingClientRect().left,n.getBoundingClientRect().bottom+16)})),n.addEventListener("mouseleave",(()=>{P.tooltip.hide()})),this.tagsHost.appendChild(n)}this.updateCountLabel()}addMonomer(e){this.selectedMonomers.includes(e)||(this.selectedMonomers.push(e),this.renderTags()),this.inputEl.value="",this.hideMenu(),this.inputEl.focus()}addMonomers(e){let t=!1;for(const n of e)this.selectedMonomers.includes(n)||(this.selectedMonomers.push(n),t=!0);t&&this.renderTags()}hideMenu(){this.currentMenu&&(this.currentMenu.hide(),this.currentMenu=null),this.menuItems=[],this.highlightedIndex=-1}getSuggestions(e){const t=e.toLowerCase(),n=[];for(const e of this.allSymbols){if(this.selectedMonomers.includes(e))continue;const o=this.monomerLib.getMonomer(this.polymerType,e),r=e.toLowerCase(),i=o?.name?.toLowerCase()??"";r.startsWith(t)?n.push({symbol:e,monomer:o,rank:0}):r.includes(t)?n.push({symbol:e,monomer:o,rank:1}):i.includes(t)&&n.push({symbol:e,monomer:o,rank:2})}return n.sort(((e,t)=>e.rank-t.rank||e.symbol.localeCompare(t.symbol))),n.slice(0,20)}showSuggestions(){this.hideMenu();const e=this.inputEl.value.trim();if(!e)return;const t=this.getSuggestions(e);if(0===t.length)return;this.currentMenu=r.Menu.popup();const n=t.reduce(((e,t)=>{const n=t.monomer?.name?`${t.symbol} - ${t.monomer.name}`:t.symbol;return e.length<n.length?n:e}),"");this.currentMenu.item(n,(()=>{}));const o=new MouseEvent("mousemove",{clientX:this.inputEl.getBoundingClientRect().left,clientY:this.inputEl.getBoundingClientRect().bottom});this.currentMenu.show({causedBy:o,y:this.inputEl.offsetHeight+this.inputEl.offsetTop,x:this.inputEl.offsetLeft}),setTimeout((()=>{this.currentMenu?.clear();for(const e of t){const t=e.monomer?.name?`${e.symbol} - ${e.monomer.name}`:e.symbol;this.currentMenu?.item(t,(()=>{this.addMonomer(e.symbol)}))}const e=document.querySelector(".d4-menu-popup:last-of-type");e&&(this.menuItems=Array.from(e.querySelectorAll(".d4-menu-item"))),this.highlightedIndex=-1}),0)}updateHighlight(e){0!==this.menuItems.length&&(this.highlightedIndex>=0&&this.highlightedIndex<this.menuItems.length&&this.menuItems[this.highlightedIndex].classList.remove("d4-menu-item-hover"),this.highlightedIndex=e,this.highlightedIndex>=0&&this.highlightedIndex<this.menuItems.length&&(this.menuItems[this.highlightedIndex].classList.add("d4-menu-item-hover"),this.menuItems[this.highlightedIndex].scrollIntoView({block:"nearest"})))}setupInputListeners(){this.inputEl.addEventListener("input",(()=>{this.showSuggestions()})),this.inputEl.addEventListener("paste",(e=>{const t=e.clipboardData?.getData("text");if(!t)return;const n=t.split(/[\n\r]+/).map((e=>e.trim())).filter((e=>e.length>0)),o=[];for(const e of n){const t=e.split(/,(?![^(]*\))/).map((e=>('"'===(e=e.trim()).slice(0,1)&&'"'===e.slice(-1)&&(e=e.slice(1,-1)),"'"===e.slice(0,1)&&"'"===e.slice(-1)&&(e=e.slice(1,-1)),e.trim()))).filter((e=>!!e));1===t.length&&e.includes(" ")&&!e.includes(",")?o.push(...e.split(/\s+/).map((e=>e.trim())).filter((e=>e.length>0))):o.push(...t)}if(!(o.length<=1)){e.preventDefault();for(const e of o)this.selectedMonomers.includes(e)||this.selectedMonomers.push(e);this.renderTags(),this.inputEl.value="",this.hideMenu(),this.inputEl.focus()}})),this.inputEl.addEventListener("keydown",(e=>{if("ArrowDown"===e.key){if(e.preventDefault(),this.menuItems.length>0){const e=(this.highlightedIndex+1)%this.menuItems.length;this.updateHighlight(e)}}else if("ArrowUp"===e.key){if(e.preventDefault(),this.menuItems.length>0){const e=(this.highlightedIndex-1+this.menuItems.length)%this.menuItems.length;this.updateHighlight(e)}}else if("Enter"===e.key)if(e.preventDefault(),e.stopPropagation(),this.highlightedIndex>=0&&this.highlightedIndex<this.menuItems.length)this.menuItems[this.highlightedIndex].click();else{const e=this.inputEl.value.trim();e&&this.addMonomer(e)}else"Escape"===e.key&&this.hideMenu()}))}createLibrarySection(){const e=P.div([],{style:{marginTop:"8px"}});if(!this.libHelper)return e;const t=this.libHelper,n=P.input.choice("Add from library",{items:[],nullable:!0}),o=P.divText("",{style:{fontSize:"11px",color:"var(--green-2)",marginLeft:"8px",minHeight:"16px"}});return t.getAvaliableLibraryNames().then((e=>{n.items=e})),n.onChanged.subscribe((async()=>{const e=n.value;if(e){o.textContent="Loading...";try{const n=await t.readSingleLibraryByName(e);if(n){const t=n.getMonomerSymbolsByType(this.polymerType),r=this.selectedMonomers.length;this.addMonomers(t);const i=this.selectedMonomers.length-r;o.textContent=`Added ${i} monomer(s) from "${e}"`}else o.textContent=`Library "${e}" not found`}catch(e){o.textContent="Error loading library"}n.value=null,setTimeout((()=>{o.textContent=""}),4e3)}})),e.appendChild(P.divV([n.root,o])),e}createCollectionSection(){const e=P.div([],{style:{marginTop:"4px"}});if(!this.libHelper)return e;const t=this.libHelper,n=P.input.choice("Add from collection",{items:[],nullable:!0}),o=P.divText("",{style:{fontSize:"11px",color:"var(--green-2)",marginLeft:"8px",minHeight:"16px"}});return t.listMonomerCollections().then((e=>{n.items=e})),n.onChanged.subscribe((async()=>{const e=n.value;if(e){o.textContent="Loading...";try{const n=(await t.readMonomerCollection(e)).monomerSymbols??[],r=this.selectedMonomers.length;this.addMonomers(n);const i=this.selectedMonomers.length-r,s=e.replace(/\.json$/,"");o.textContent=`Added ${i} monomer(s) from "${s}"`}catch(e){o.textContent="Error loading collection"}n.value=null,setTimeout((()=>{o.textContent=""}),4e3)}})),e.appendChild(P.divV([n.root,o])),e}}async function _o(e,t,n,o){return new Promise((r=>{const i=new Po(e,t,n,o);P.dialog({title:"Select Monomers",showFooter:!0}).add(P.div([i.root],{style:{minWidth:"400px",minHeight:"250px",maxWidth:"800px"}})).onOK((()=>{r(i.getSelectedMonomers())})).onCancel((()=>{r(null)})).show({resizable:!0}),i.focus()}))}class Lo extends r.JsInputBase{get inputType(){return"Breadth"}get dataType(){return r.TYPE.DATA_FRAME}getInput(){return this.gridHost}getValue(){return this.grid.dataFrame}setValue(e){this.setDataFrame(e)}invalidateGrid(){if(this.grid){const e=this.grid.root.style.width;this.grid.root.style.width="99.9%",setTimeout((()=>{e?this.grid.root.style.width=e:this.grid.root.style.removeProperty("width")}),100)}}getStringValue(){return this.grid.dataFrame.toCsv()}setStringValue(e){this.setDataFrame(r.DataFrame.fromCsv(e))}get placeholdersBreadthValue(){return function(e){const t=[];for(let n=0;n<e.rowCount;n++){const o=parseInt(e.get("Start",n))-1,r=parseInt(e.get("End",n))-1;if(!isNaN(o)&&!isNaN(r)){const i=Mo(e.get("Monomers",n));t.push({start:o,end:r,monomers:i})}}return t}(this.grid.dataFrame)}constructor(e,t,n){super(),this.name=e,this.onMonomerCellEdit=null,this.subs=[],this.dataFrameSubs=[],this.caption=e??"",this.root.classList.add("ui-input-polytool-pos-grid"),this.root.append(this.gridHost=P.div([],{classes:"ui-input-editor",style:{width:"100%",height:"100%",marginTop:"-8px",marginBottom:"8px",paddingBottom:"4px"}})),this.render(t,n).then((()=>{}))}detach(){for(const e of this.subs)e.unsubscribe();for(const e of this.dataFrameSubs)e.unsubscribe()}clearInput(){const e=r.DataFrame.fromColumns([r.Column.fromType(r.COLUMN_TYPE.STRING,"Remove",0),r.Column.fromType(r.COLUMN_TYPE.INT,"Start",0),r.Column.fromType(r.COLUMN_TYPE.INT,"End",0),r.Column.fromType(r.COLUMN_TYPE.STRING,"Monomers",0)]);this.setDataFrame(e)}async render(e,t){let n;const o=r.DataFrame.fromColumns([n=r.Column.fromType(r.COLUMN_TYPE.STRING,"Remove",0),r.Column.fromType(r.COLUMN_TYPE.INT,"Start",0),r.Column.fromType(r.COLUMN_TYPE.INT,"End",0),r.Column.fromType(r.COLUMN_TYPE.STRING,"Monomers",0)]);n.setTag(r.TAGS.FRIENDLY_NAME,""),this.grid=await o.plot.fromType(r.VIEWER.GRID,t),this.grid.sort(["Start","End"]),this.grid.columns.byIndex(1).width=this.grid.props.rowHeight+2,this.grid.onCellRender.subscribe((e=>{const t=e.cell;t.tableColumn?.name==n.name&&(t?.tableRowIndex??-1)>=0&&(t.element=P.div(P.icons.delete((()=>{this.grid.dataFrame.rows.removeAt(t.tableRowIndex)}),"Delete"),{style:{height:`${t.grid.props.rowHeight}px`,color:"var(--grey-6)",display:"flex",flexDirection:"row",justifyContent:"center"}}))}));const i=this.grid.columns.byName("Monomers");i&&(i.editable=!1),this.subs.push(this.grid.onCellDoubleClick.subscribe((e=>{"Monomers"===e.tableColumn?.name&&null!=e.tableRowIndex&&e.tableRowIndex>=0&&this.handleMonomerCellDoubleClick(e.tableRowIndex)}))),this.updateGridHeight(e??this.grid.dataFrame.rowCount+.7),this.subs.push(P.onSizeChanged(this.grid.root).subscribe(this.gridRootOnSizeChanged.bind(this))),this.subs.push((0,te.fromEvent)(this.grid.root,"keydown").subscribe((e=>{"Enter"===e.key&&e.stopPropagation()}))),this.setDataFrame(o),this.grid.root.style.width="100%",this.gridHost.append(this.grid.root)}setDataFrame(e){for(const e of this.dataFrameSubs)e.unsubscribe();this.grid.dataFrame=e,this.dataFrameSubs.push(this.grid.dataFrame.onRowsRemoved.subscribe((()=>{this.updateGridHeight(this.grid.dataFrame.rowCount+.7),this.fireChanged()}))),this.dataFrameSubs.push(this.grid.dataFrame.onRowsAdded.subscribe((()=>{this.updateGridHeight(this.grid.dataFrame.rowCount+.7)}))),this.dataFrameSubs.push(this.grid.dataFrame.onDataChanged.subscribe((()=>{this.fireChanged()}))),this.updateGridHeight(this.grid.dataFrame.rowCount+.7),this.fireChanged()}static async create(e,t,n){return new Lo(e,n,t)}updateGridHeight(e){const t=this.grid.colHeaderHeight+e*this.grid.props.rowHeight+6+2;this.grid.root.style.height=`${t}px`}async handleMonomerCellDoubleClick(e){if(!this.onMonomerCellEdit)return;const t=this.grid.dataFrame,n=parseInt(t.get("Start",e))-1,o=parseInt(t.get("End",e))-1;if(isNaN(n)||isNaN(o))return;const r=Mo(t.get("Monomers",e)??""),i=await this.onMonomerCellEdit(n,o,r);null!==i&&t.set("Monomers",e,i.join(", "))}gridRootOnSizeChanged(){this.grid.columns.byIndex(4).width=this.grid.root.clientWidth-this.grid.horzScroll.root.offsetWidth-this.grid.columns.byIndex(0).width-this.grid.columns.byIndex(1).width-this.grid.columns.byIndex(2).width-this.grid.columns.byIndex(3).width-10}}var Oo=n(6307),Ro=n(2738);n(9982),DG.DataFrame.fromCsv('countries,fasta,smiles,molregno,LON,Zip Code,Street Address Line 1,ImageUrl,user_id,error_message,xray,flag,magnitude,CS-id,pdb_id,accel_a,time_offset,chart,fit,Questions,empty_number,empty_string\nBelgium,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C(=O)OCCCc1cccnc1)c2cccc(c2)C(=O)c3ccccc3,1480014,36.276729583740234,995042300,14016 ROUTE 31W,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,1,1,1QBS,1,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.497360340644872, 1.7058694986686864, 5.278052678195135, 0.16000320889028383],""points"":[{""x"":0.10000000149011612,""y"":2.374499797821045},{""x"":0.6000000238418579,""y"":2.6242473125457764},{""x"":1.100000023841858,""y"":2.367267608642578},{""x"":1.600000023841858,""y"":2.6723148822784424},{""x"":2.0999999046325684,""y"":2.6537344455718994},{""x"":2.5999999046325684,""y"":2.3651671409606934},{""x"":3.0999999046325684,""y"":2.5654284954071045},{""x"":3.5999999046325684,""y"":2.4160959720611572},{""x"":4.099999904632568,""y"":2.286726713180542},{""x"":4.599999904632568,""y"":2.5100042819976807},{""x"":5.099999904632568,""y"":1.6676985025405884},{""x"":5.599999904632568,""y"":0.680136501789093},{""x"":6.099999904632568,""y"":0.3391543924808502},{""x"":6.599999904632568,""y"":0.09038983285427094},{""x"":7.099999904632568,""y"":0.19802775979042053}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[7.525235855508179, 1.3186911876809984, 5.335672608564294, 0.7860743343958098],""points"":[{""x"":0.10000000149011612,""y"":7.988070487976074},{""x"":0.6000000238418579,""y"":7.018453121185303},{""x"":1.100000023841858,""y"":8.115279197692871},{""x"":1.600000023841858,""y"":7.486658096313477},{""x"":2.0999999046325684,""y"":7.396438121795654},{""x"":2.5999999046325684,""y"":7.477052211761475},{""x"":3.0999999046325684,""y"":6.913095474243164},{""x"":3.5999999046325684,""y"":8.01385498046875},{""x"":4.099999904632568,""y"":6.985900402069092},{""x"":4.599999904632568,""y"":6.970335960388184},{""x"":5.099999904632568,""y"":5.448817253112793},{""x"":5.599999904632568,""y"":2.5534818172454834},{""x"":6.099999904632568,""y"":1.893947958946228},{""x"":6.599999904632568,""y"":0.6340042352676392},{""x"":7.099999904632568,""y"":0.8403874039649963}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,100,abc\nBurundi,MDYKETLLMPKTDFPMRGGLPNKEPQIQEKW,COc1ccc2cc(ccc2c1)C(C)C(=O)Oc3ccc(C)cc3OC,1480015,36.276729583740234,995073444,80 STATE HIGHWAY 310,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,2,2,1ZP8,2,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.431460753103398, 2.1691498799246745, 5.266445597102774, 0.7825762827017926],""points"":[{""x"":0.10000000149011612,""y"":4.751083850860596},{""x"":0.6000000238418579,""y"":4.203000068664551},{""x"":1.100000023841858,""y"":4.415858745574951},{""x"":1.600000023841858,""y"":4.68414306640625},{""x"":2.0999999046325684,""y"":4.198400974273682},{""x"":2.5999999046325684,""y"":4.179222106933594},{""x"":3.0999999046325684,""y"":4.638473987579346},{""x"":3.5999999046325684,""y"":4.708553314208984},{""x"":4.099999904632568,""y"":4.291589260101318},{""x"":4.599999904632568,""y"":4.038082599639893},{""x"":5.099999904632568,""y"":3.4349939823150635},{""x"":5.599999904632568,""y"":1.2194708585739136},{""x"":6.099999904632568,""y"":1.1920831203460693},{""x"":6.599999904632568,""y"":0.5352635979652405},{""x"":7.099999904632568,""y"":0.3346920311450958}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.339458017970126, -1.0734184310171178, 4.746332950550934, 0.2482416857595658],""points"":[{""x"":0.10000000149011612,""y"":0.2139337658882141},{""x"":0.6000000238418579,""y"":0.4269562065601349},{""x"":1.100000023841858,""y"":0.2441573292016983},{""x"":1.600000023841858,""y"":0.146635964512825},{""x"":2.0999999046325684,""y"":0.08818462491035461},{""x"":2.5999999046325684,""y"":0.2560656666755676},{""x"":3.0999999046325684,""y"":0.42434045672416687},{""x"":3.5999999046325684,""y"":0.37111231684684753},{""x"":4.099999904632568,""y"":0.5581737160682678},{""x"":4.599999904632568,""y"":1.183590054512024},{""x"":5.099999904632568,""y"":1.5629843473434448},{""x"":5.599999904632568,""y"":2.3211288452148438},{""x"":6.099999904632568,""y"":2.229961633682251},{""x"":6.599999904632568,""y"":2.2560226917266846},{""x"":7.099999904632568,""y"":2.2142398357391357}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCameroon,MIEVFLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL,COc1ccc2cc(ccc2c1)C(C)C(=O)OCCCc3cccnc3,1480016,36.26095962524414,995153596,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,3,3,2BDJ,3,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.6760652578642325, 0.9046956320756703, 5.651408971856738, 0.07738846012184185],""points"":[{""x"":0.10000000149011612,""y"":4.32425594329834},{""x"":0.6000000238418579,""y"":4.668442249298096},{""x"":1.100000023841858,""y"":4.379785060882568},{""x"":1.600000023841858,""y"":5.0345139503479},{""x"":2.0999999046325684,""y"":4.878653526306152},{""x"":2.5999999046325684,""y"":4.3451313972473145},{""x"":3.0999999046325684,""y"":4.336992263793945},{""x"":3.5999999046325684,""y"":5.037430286407471},{""x"":4.099999904632568,""y"":5.0092692375183105},{""x"":4.599999904632568,""y"":4.151902675628662},{""x"":5.099999904632568,""y"":3.4066951274871826},{""x"":5.599999904632568,""y"":2.3732759952545166},{""x"":6.099999904632568,""y"":1.673728108406067},{""x"":6.599999904632568,""y"":0.48574790358543396},{""x"":7.099999904632568,""y"":0.2783052325248718}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.938395863010111, -1.4658480661392117, 5.462702751996584, 0.3473139023615039],""points"":[{""x"":0.10000000149011612,""y"":0.4941710829734802},{""x"":0.6000000238418579,""y"":0.15323974192142487},{""x"":1.100000023841858,""y"":0.46373432874679565},{""x"":1.600000023841858,""y"":0.3370431363582611},{""x"":2.0999999046325684,""y"":0.5179030299186707},{""x"":2.5999999046325684,""y"":0.27899765968322754},{""x"":3.0999999046325684,""y"":0.22075064480304718},{""x"":3.5999999046325684,""y"":0.5789918899536133},{""x"":4.099999904632568,""y"":0.21169911324977875},{""x"":4.599999904632568,""y"":0.27857646346092224},{""x"":5.099999904632568,""y"":1.0906332731246948},{""x"":5.599999904632568,""y"":1.8520300388336182},{""x"":6.099999904632568,""y"":2.7177059650421143},{""x"":6.599999904632568,""y"":2.8680918216705322},{""x"":7.099999904632568,""y"":3.2413077354431152}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCanada,MMELVLKTIIGPIVVGVVLRIVDKWLNKDK,CC(C(=O)NCCS)c1cccc(c1)C(=O)c2ccccc2,1480017,36.26095962524414,99515,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,4,4,1IAN,4,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[0.8597390975430008, 1.0957625732481946, 5.260537067987958, 0.07974187998177736],""points"":[{""x"":0.10000000149011612,""y"":0.8190152645111084},{""x"":0.6000000238418579,""y"":0.8421689867973328},{""x"":1.100000023841858,""y"":0.8740922212600708},{""x"":1.600000023841858,""y"":0.8924275040626526},{""x"":2.0999999046325684,""y"":0.8249067664146423},{""x"":2.5999999046325684,""y"":0.9327669143676758},{""x"":3.0999999046325684,""y"":0.8522974252700806},{""x"":3.5999999046325684,""y"":0.8174492716789246},{""x"":4.099999904632568,""y"":0.8394647240638733},{""x"":4.599999904632568,""y"":0.7139387726783752},{""x"":5.099999904632568,""y"":0.5561167597770691},{""x"":5.599999904632568,""y"":0.3276226818561554},{""x"":6.099999904632568,""y"":0.12479474395513535},{""x"":6.599999904632568,""y"":0.13006797432899475},{""x"":7.099999904632568,""y"":0.059702079743146896}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.760930219582546, 1.6591793293833013, 4.667155929720851, 0.7858109544121652],""points"":[{""x"":0.10000000149011612,""y"":6.156993389129639},{""x"":0.6000000238418579,""y"":5.236701965332031},{""x"":1.100000023841858,""y"":6.010560512542725},{""x"":1.600000023841858,""y"":5.495512962341309},{""x"":2.0999999046325684,""y"":6.087770462036133},{""x"":2.5999999046325684,""y"":5.79986572265625},{""x"":3.0999999046325684,""y"":5.597546577453613},{""x"":3.5999999046325684,""y"":5.520902156829834},{""x"":4.099999904632568,""y"":5.360654354095459},{""x"":4.599999904632568,""y"":3.5539746284484863},{""x"":5.099999904632568,""y"":1.577236294746399},{""x"":5.599999904632568,""y"":1.0001264810562134},{""x"":6.099999904632568,""y"":0.9305797815322876},{""x"":6.599999904632568,""y"":0.6033638715744019},{""x"":7.099999904632568,""y"":0.4203685522079468}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nColombia,MDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN,FC(F)(F)c1ccc(OC2CCNCC2)cc1,1480029,36.3309440612793,995152050,1 COURT HOUSE SQUARE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,5,5,4UJ1,5,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[6.4995088314153655, 2.4270351004539914, 5.178659535348579, 0.625653346241577],""points"":[{""x"":0.10000000149011612,""y"":6.496231555938721},{""x"":0.6000000238418579,""y"":6.42543363571167},{""x"":1.100000023841858,""y"":7.040063858032227},{""x"":1.600000023841858,""y"":6.1115403175354},{""x"":2.0999999046325684,""y"":6.680728435516357},{""x"":2.5999999046325684,""y"":6.406774520874023},{""x"":3.0999999046325684,""y"":6.611269474029541},{""x"":3.5999999046325684,""y"":5.889094352722168},{""x"":4.099999904632568,""y"":6.75344705581665},{""x"":4.599999904632568,""y"":6.361435890197754},{""x"":5.099999904632568,""y"":4.1666975021362305},{""x"":5.599999904632568,""y"":1.172118902206421},{""x"":6.099999904632568,""y"":0.801048994064331},{""x"":6.599999904632568,""y"":0.4640021026134491},{""x"":7.099999904632568,""y"":0.0010357667924836278}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[1.4734381347446401, 1.1649805188074196, 4.82958608866421, 0.09500545496710007],""points"":[{""x"":0.10000000149011612,""y"":1.5279096364974976},{""x"":0.6000000238418579,""y"":1.3559974431991577},{""x"":1.100000023841858,""y"":1.5246378183364868},{""x"":1.600000023841858,""y"":1.5567657947540283},{""x"":2.0999999046325684,""y"":1.4114240407943726},{""x"":2.5999999046325684,""y"":1.4045010805130005},{""x"":3.0999999046325684,""y"":1.4769829511642456},{""x"":3.5999999046325684,""y"":1.4875500202178955},{""x"":4.099999904632568,""y"":1.2991987466812134},{""x"":4.599999904632568,""y"":0.922961413860321},{""x"":5.099999904632568,""y"":0.6520044803619385},{""x"":5.599999904632568,""y"":0.15350978076457977},{""x"":6.099999904632568,""y"":0.1078903079032898},{""x"":6.599999904632568,""y"":0.17276449501514435},{""x"":7.099999904632568,""y"":0.14066608250141144}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCosta Rica,MKSTKEEIQTIKTLLKDSRTAKYHKRLQIVL,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCCc3ccccc3,1480018,36.3309440612793,995084218,4041 SOUTHWESTERN BLVD,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,6,6,2BPW,6,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.4833641843311227, -1.8945978742090062, 4.671127708092568, 0.24159861311815153],""points"":[{""x"":0.10000000149011612,""y"":0.0969524160027504},{""x"":0.6000000238418579,""y"":0.028483040630817413},{""x"":1.100000023841858,""y"":0.22087176144123077},{""x"":1.600000023841858,""y"":0.0068915546871721745},{""x"":2.0999999046325684,""y"":0.4305879771709442},{""x"":2.5999999046325684,""y"":0.44774115085601807},{""x"":3.0999999046325684,""y"":0.45346319675445557},{""x"":3.5999999046325684,""y"":0.2370593100786209},{""x"":4.099999904632568,""y"":0.4657953977584839},{""x"":4.599999904632568,""y"":1.155200719833374},{""x"":5.099999904632568,""y"":2.2294070720672607},{""x"":5.599999904632568,""y"":2.4311530590057373},{""x"":6.099999904632568,""y"":2.33846116065979},{""x"":6.599999904632568,""y"":2.608201026916504},{""x"":7.099999904632568,""y"":2.8136143684387207}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.224573521642033, 1.4454033924198528, 5.6014197746076535, 0.2823216054197577],""points"":[{""x"":0.10000000149011612,""y"":4.95027494430542},{""x"":0.6000000238418579,""y"":5.1754679679870605},{""x"":1.100000023841858,""y"":5.276752948760986},{""x"":1.600000023841858,""y"":5.589294910430908},{""x"":2.0999999046325684,""y"":5.616994857788086},{""x"":2.5999999046325684,""y"":5.120813846588135},{""x"":3.0999999046325684,""y"":5.340766906738281},{""x"":3.5999999046325684,""y"":4.876471042633057},{""x"":4.099999904632568,""y"":4.94999361038208},{""x"":4.599999904632568,""y"":5.162564754486084},{""x"":5.099999904632568,""y"":4.399557590484619},{""x"":5.599999904632568,""y"":2.7977969646453857},{""x"":6.099999904632568,""y"":1.0229872465133667},{""x"":6.599999904632568,""y"":0.48275601863861084},{""x"":7.099999904632568,""y"":0.10408931970596313}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCuba,MHAILRYFIRRLFYHIFYKIYSLISKKHQSLPSDVRQF,COc1ccc2c(c1)c(CC(=O)N3CCCC3C(=O)Oc4ccc(C)cc4OC)c(C)n2C(=O)c5ccc(Cl)cc5,1480019,36.33115768432617,995081928,1227 US HIGHWAY 11,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,7,7,1QBS,7,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.320838679713925, -1.2421619987316728, 4.831325425225256, 0.3236011098403072],""points"":[{""x"":0.10000000149011612,""y"":0.3727470338344574},{""x"":0.6000000238418579,""y"":0.12365014106035233},{""x"":1.100000023841858,""y"":0.48422467708587646},{""x"":1.600000023841858,""y"":0.2264465093612671},{""x"":2.0999999046325684,""y"":0.16821794211864471},{""x"":2.5999999046325684,""y"":0.3879014551639557},{""x"":3.0999999046325684,""y"":0.5470244884490967},{""x"":3.5999999046325684,""y"":0.3419053554534912},{""x"":4.099999904632568,""y"":0.7655120491981506},{""x"":4.599999904632568,""y"":1.2346516847610474},{""x"":5.099999904632568,""y"":2.453336715698242},{""x"":5.599999904632568,""y"":2.9565491676330566},{""x"":6.099999904632568,""y"":3.335299491882324},{""x"":6.599999904632568,""y"":3.240290880203247},{""x"":7.099999904632568,""y"":3.1107218265533447}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.6401853521511094, 1.26211588875013, 5.399028074402744, 0.5089580830068091],""points"":[{""x"":0.10000000149011612,""y"":3.8585598468780518},{""x"":0.6000000238418579,""y"":3.6077206134796143},{""x"":1.100000023841858,""y"":3.855252265930176},{""x"":1.600000023841858,""y"":3.619039297103882},{""x"":2.0999999046325684,""y"":3.839388370513916},{""x"":2.5999999046325684,""y"":3.335283041000366},{""x"":3.0999999046325684,""y"":3.571141481399536},{""x"":3.5999999046325684,""y"":3.4155046939849854},{""x"":4.099999904632568,""y"":3.7316646575927734},{""x"":4.599999904632568,""y"":3.0680155754089355},{""x"":5.099999904632568,""y"":2.891066551208496},{""x"":5.599999904632568,""y"":1.6022753715515137},{""x"":6.099999904632568,""y"":0.7652576565742493},{""x"":6.599999904632568,""y"":0.6875326037406921},{""x"":7.099999904632568,""y"":0.5828871726989746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nItaly,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO[N+](=O)[O-],1480020,36.33115768432617,99502,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,8,8,1ZP8,8,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.293592105923809, 1.3781586549141835, 5.1025898038676605, 0.03493851245291291],""points"":[{""x"":0.10000000149011612,""y"":2.1287283897399902},{""x"":0.6000000238418579,""y"":2.267972230911255},{""x"":1.100000023841858,""y"":2.398442506790161},{""x"":1.600000023841858,""y"":2.5130622386932373},{""x"":2.0999999046325684,""y"":2.3255116939544678},{""x"":2.5999999046325684,""y"":2.127340793609619},{""x"":3.0999999046325684,""y"":2.47259783744812},{""x"":3.5999999046325684,""y"":2.131181478500366},{""x"":4.099999904632568,""y"":2.090421438217163},{""x"":4.599999904632568,""y"":2.02299165725708},{""x"":5.099999904632568,""y"":1.1105059385299683},{""x"":5.599999904632568,""y"":0.4494485855102539},{""x"":6.099999904632568,""y"":0.1375635862350464},{""x"":6.599999904632568,""y"":0.036351121962070465},{""x"":7.099999904632568,""y"":0.1619771122932434}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.953125499439879, 1.2528620255306528, 5.187637440149802, 0.3110348753260886],""points"":[{""x"":0.10000000149011612,""y"":5.6585283279418945},{""x"":0.6000000238418579,""y"":5.911152362823486},{""x"":1.100000023841858,""y"":5.924920082092285},{""x"":1.600000023841858,""y"":5.8469438552856445},{""x"":2.0999999046325684,""y"":5.929472923278809},{""x"":2.5999999046325684,""y"":6.190037727355957},{""x"":3.0999999046325684,""y"":6.236179828643799},{""x"":3.5999999046325684,""y"":6.141019344329834},{""x"":4.099999904632568,""y"":5.295210838317871},{""x"":4.599999904632568,""y"":5.265801906585693},{""x"":5.099999904632568,""y"":3.3722851276397705},{""x"":5.599999904632568,""y"":1.8299226760864258},{""x"":6.099999904632568,""y"":0.32690900564193726},{""x"":6.599999904632568,""y"":0.6274543404579163},{""x"":7.099999904632568,""y"":0.8441857099533081}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nRwanda,MPNSEPASLLELFNSIATQGELVRSLKAGNASK,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO,1480021,36.33137130737305,995037247,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,9,9,2BDJ,9,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.8209972202654474, 1.3779216716448506, 5.299882228439686, 0.06040645519069608],""points"":[{""x"":0.10000000149011612,""y"":3.7821109294891357},{""x"":0.6000000238418579,""y"":3.542433023452759},{""x"":1.100000023841858,""y"":3.7008674144744873},{""x"":1.600000023841858,""y"":3.717301607131958},{""x"":2.0999999046325684,""y"":4.024452209472656},{""x"":2.5999999046325684,""y"":4.013899326324463},{""x"":3.0999999046325684,""y"":3.945094347000122},{""x"":3.5999999046325684,""y"":3.866621971130371},{""x"":4.099999904632568,""y"":3.7461626529693604},{""x"":4.599999904632568,""y"":3.3454740047454834},{""x"":5.099999904632568,""y"":2.61944317817688},{""x"":5.599999904632568,""y"":0.999405026435852},{""x"":6.099999904632568,""y"":0.46259793639183044},{""x"":6.599999904632568,""y"":0.054134611040353775},{""x"":7.099999904632568,""y"":0.05711187422275543}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.6318079657726035, 1.8495493770000595, 5.391793312471116, 0.17060707587348442],""points"":[{""x"":0.10000000149011612,""y"":5.458079814910889},{""x"":0.6000000238418579,""y"":5.554427146911621},{""x"":1.100000023841858,""y"":5.799983024597168},{""x"":1.600000023841858,""y"":5.364140033721924},{""x"":2.0999999046325684,""y"":5.864485740661621},{""x"":2.5999999046325684,""y"":5.4509806632995605},{""x"":3.0999999046325684,""y"":5.702574729919434},{""x"":3.5999999046325684,""y"":5.7314534187316895},{""x"":4.099999904632568,""y"":5.5123443603515625},{""x"":4.599999904632568,""y"":5.724395751953125},{""x"":5.099999904632568,""y"":4.354506969451904},{""x"":5.599999904632568,""y"":1.7307666540145874},{""x"":6.099999904632568,""y"":0.6305936574935913},{""x"":6.599999904632568,""y"":0.035183437168598175},{""x"":7.099999904632568,""y"":0.7575169205665588}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nSwitzerland,IRVVGRYLIEVWKAAGMDMDKVLFLWSSDEI,CN1CCC(CC1)Oc2ccc(cc2)C(F)(F)F,1480028,36.33137130737305,99504,92-11 179TH PLACE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,9,10,1IAN,10,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[1.1190255865097471, 2.3163895161544437, 5.4968866182279195, 0.2035204047289052],""points"":[{""x"":0.10000000149011612,""y"":1.1057683229446411},{""x"":0.6000000238418579,""y"":1.1019697189331055},{""x"":1.100000023841858,""y"":1.0818607807159424},{""x"":1.600000023841858,""y"":1.062997817993164},{""x"":2.0999999046325684,""y"":1.046447515487671},{""x"":2.5999999046325684,""y"":1.1217249631881714},{""x"":3.0999999046325684,""y"":1.2166996002197266},{""x"":3.5999999046325684,""y"":1.215477705001831},{""x"":4.099999904632568,""y"":1.0581893920898438},{""x"":4.599999904632568,""y"":1.1747995615005493},{""x"":5.099999904632568,""y"":1.0181127786636353},{""x"":5.599999904632568,""y"":0.5344523191452026},{""x"":6.099999904632568,""y"":0.2569526433944702},{""x"":6.599999904632568,""y"":0.1912207305431366},{""x"":7.099999904632568,""y"":0.15060538053512573}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.1038581025805785, 2.0032224204185245, 5.087602825989163, 0.13277988512492753],""points"":[{""x"":0.10000000149011612,""y"":3.0498509407043457},{""x"":0.6000000238418579,""y"":2.805217742919922},{""x"":1.100000023841858,""y"":3.3415253162384033},{""x"":1.600000023841858,""y"":3.0549843311309814},{""x"":2.0999999046325684,""y"":3.250074863433838},{""x"":2.5999999046325684,""y"":3.0432586669921875},{""x"":3.0999999046325684,""y"":3.265852451324463},{""x"":3.5999999046325684,""y"":2.9475724697113037},{""x"":4.099999904632568,""y"":3.1929898262023926},{""x"":4.599999904632568,""y"":2.7460060119628906},{""x"":5.099999904632568,""y"":1.6175861358642578},{""x"":5.599999904632568,""y"":0.3006608486175537},{""x"":6.099999904632568,""y"":0.3444803059101105},{""x"":6.599999904632568,""y"":0.015537971630692482},{""x"":7.099999904632568,""y"":0.5527358055114746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\n,,,,,,,,,,,,,,,,,,,,,').columns.add(DG.Column.fromList(DG.TYPE.BYTE_ARRAY,"BinaryImage",Array.from(new Uint8Array(11))));var $o;console.log.bind(console),console.info.bind(console),console.warn.bind(console),console.error.bind(console),function(e){e.notNull=function(e,t){if(null==e)throw new Error(`${null==t?"Value":t} not defined`)}}($o||($o={})),DG.DataFrame.fromColumns([DG.Column.fromStrings("col",["val1","val2","val3"])]);class Do{onKeyDown(e,t){}onKeyPress(e,t){}onMouseEnter(e,t){}onMouseLeave(e,t){}onMouseDown(e,t){}onMouseUp(e,t){}onMouseMove(e,t){}onClick(e,t){}onDoubleClick(e,t){}}class Bo extends Do{constructor(e,t,n){super(),this.gridCol=e,this.tableCol=t,this.logger=n,this.subs=[],this.dirty=!0,this.destroyed=!1,this.viewerId=++Bo.viewerCounter,this.errors=[],this._onRendered=new te.Subject,this.tableCol&&this.tableCol.dataFrame&&(this.subs.push(this.tableCol.dataFrame.onDataChanged.subscribe((()=>{this.dirty=!0}))),this.subs.push(this.tableCol.dataFrame.onColumnsRemoved.subscribe((e=>{try{this.destroyed||!this.tableCol||this.tableCol.dataFrame||this.destroy()}catch(e){this.logger.error(e)}})))),this.tableCol&&this.subs.push(o.events.onTableRemoved.subscribe((e=>{try{const t=e.args.dataFrame;this.tableCol?.dataFrame.id!==t.id||this.destroyed||this.destroy()}catch(e){this.logger.error(e)}}))),this.gridCol&&this.subs.push(o.events.onViewRemoving.subscribe((e=>{try{const t=e.args.view;this.gridCol?.dart&&this.gridCol.grid&&this.gridCol?.grid?.dart&&this.gridCol?.grid?.view?.id===t.id&&!this.destroyed&&this.destroy()}catch(e){this.logger.error(e)}})))}toLog(){return`${this.constructor.name}<${this.viewerId}>`}destroy(){for(const e of this.subs)e.unsubscribe();this.destroyed=!0}invalidateGrid(){this.gridCol&&this.gridCol.dart&&this.gridCol.grid?.invalidate()}reset(){this.dirty=!1}get onRendered(){return this._onRendered}invalidate(e){this.invalidateGrid()}async awaitRendered(e=1e4,t=`${e} timeout`){const n=`${this.toLog()}.awaitRendered()`;if(this.logger.debug(`${n}, start, testEvent before`),await function(e,t,n,o=0,r="timeout"){return function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((o=o.apply(e,t||[])).next())}))}(this,void 0,void 0,(function*(){return new Promise(((i,s)=>{const a=e.subscribe((e=>{try{t(e),i("OK")}catch(e){s(e)}finally{a.unsubscribe(),clearTimeout(l)}})),l=setTimeout((()=>{a.unsubscribe(),s(r)}),o);n()}))}))}(this._onRendered,(()=>{}),(()=>{this.invalidate()}),e,`${n}, ${t}`),this.errors.length>0){const e=this.errors[0];throw this.errors=[],e}this.logger.debug(`${n}, end`)}}Bo.viewerCounter=-1;const Fo="rgb(100,100,100)",ko="rgb(0,0,0)",Ho=s.zS;var Go,Uo,Vo;!function(e){e.maxMonomerLength=".mm.cellRenderer.maxMonomerLength"}(Go||(Go={})),function(e){e.applyToBackground=".m.cellRenderer.applyToBackground"}(Uo||(Uo={})),function(e){e.MSA="MSA",e.classic="classic"}(Vo||(Vo={}));const jo=new class{constructor(){this.color=Fo,this.pivot=0,this.left=!1,this.transparencyRate=0,this.separator="",this.last=!1,this.drawStyle=Vo.classic,this.maxWord=[],this.wordIdx=0,this.gridCell=null,this.referenceSequence=null,this.maxLengthOfMonomer=null,this.monomerTextSizeMap={},this.logger=void 0,this.selectedPosition=void 0,this.isMultiLineContext=!1,this.lineNumber=0}};function qo(e,t,n,o,i,s,a){var l,c,u;const h={...jo,...a};if(h.isMultiLineContext){e.textBaseline="middle",e.textAlign="center";let r=t;null!=h.maxLengthOfMonomer&&(r=Ho(r,h.maxLengthOfMonomer));const a=Math.max(.1,1-(h.transparencyRate??0));e.globalAlpha=a;const l=e.measureText(r),c=l.fontBoundingBoxAscent+l.fontBoundingBoxDescent,u=o+(s-c)/2+l.fontBoundingBoxAscent;let d=h.color??Fo;return d&&d!==Fo||(d=ko),e.fillStyle=d,h.selectedPosition===h.wordIdx+1&&(e.save(),e.fillStyle="rgba(60, 177, 115, 0.2)",e.fillRect(n,o,i,s),e.restore(),e.fillStyle=d),e.fillText(r,n+i/2,u),e.globalAlpha=1,e.textBaseline="top",e.textAlign="start",n+i}a.logger?.debug("Bio: printLeftOrCentered(), start"),e.textAlign="start";let d=t.substring(0),p=h.last?"":h.separator;h.drawStyle===Vo.MSA&&(p="");let m=!0,f=!0,g="difference";if(null!=h.gridCell&&null!=h.gridCell.cell.column&&(m=h.gridCell.cell.column.temp["color-code"]??!0,f=h.gridCell.cell.column.temp["compare-with-current"]??!0,g=h.gridCell.cell.column.temp["highlight-difference"]??"difference"),h.referenceSequence){const e=h.referenceSequence[h.wordIdx];f&&h.referenceSequence.length>0&&"difference"===g&&(h.transparencyRate=d==e?.7:h.transparencyRate),f&&h.referenceSequence.length>0&&"equal"===g&&(h.transparencyRate=d!=e?.7:h.transparencyRate)}null!=h.maxLengthOfMonomer&&(d=Ho(d,h.maxLengthOfMonomer));const y=d+p;(l=h.monomerTextSizeMap)[y]??(l[y]=e.measureText(y));let b=h.monomerTextSizeMap[y];(c=h.monomerTextSizeMap)[d]??(c[d]=e.measureText(d));let v=h.monomerTextSizeMap[d].width;const C=s/2-(b.fontBoundingBoxAscent+b.fontBoundingBoxDescent)/2+1;(u=h.monomerTextSizeMap)[p]??(u[p]=e.measureText(p));const x=h.monomerTextSizeMap[p].width;function w(t,i){let a=m?h.color:ko;h.selectedPosition===h.wordIdx+1&&(e.fillStyle="rgba(60, 177, 115, 0.2)",e.fillRect(n+t-4,o-5,h.monomerTextSizeMap[d].width+8,s+10),a=r.Color.toHtml(r.Color.setAlpha(r.Color.fromHtml(a),255))),e.fillStyle=a,e.globalAlpha=1-h.transparencyRate,h.drawStyle===Vo.classic&&(e.fillText(d,n+t,o+C),e.fillStyle="#808080",e.fillText(p,n+i,o+C)),h.drawStyle===Vo.MSA&&e.fillText(d,n+t,o+C),e.globalAlpha=1}b=b.width,h.drawStyle===Vo.MSA&&(v=h.maxWord[h.wordIdx],b=h.maxWord[h.wordIdx]);const A=(h.maxWord[h.wordIdx]??0)-(h.maxWord[0]??0);if(h.left||b>i)return w(A,A+v),n+A+v+x;{const e=(i-b)/2;return w(e,e+v),n+A+e+v}}var Wo,zo,Yo;!function(e){e.Region="region",e.Point="point",e.Motif="motif"}(Wo||(Wo={})),function(e){e.Structure="structure",e.Liability="liability",e.PTM="ptm",e.Custom="custom"}(zo||(zo={})),function(e){e.High="high",e.Medium="medium",e.Low="low",e.Info="info"}(Yo||(Yo={}));const Ko={structure:{FR:["#0095ff","#289dfd","#48adff","#3ba5fc"],CDR:["#ffdca3","#facb83","#f7a224"]},liability:{deamidation:"#E53935",isomerization:"#FF9800",oxidation:"#9C27B0",glycosylation:"#4CAF50",freeCysteine:"#607D8B"}};class Qo{constructor(e){this.tableCol=e,this._cache=null,this._rowCache=null,this._annotCol=null,this._annotColLookupVersion=-1}hasAnnotations(){return this._ensureCache(),null!==this._cache&&this._cache.annotations.length>0}getAnnotations(){return this._ensureCache(),this._cache?.annotations??[]}getRegionNameAtPosition(e,t){if(null!=t){const n=this._findRowRegionHit(t,e);if(n){const e=this._cache?.annotations.find((e=>e.id===n.annotationId));return e?.name??null}if(this._rowHasRegionData(t))return null}return this._ensureCache(),this._cache?.positionRegionNames.get(e)??null}getHitsAtPosition(e,t){if(this._ensureRowCache(),!this._rowCache)return[];const n=this._rowCache.data[e];return n?n.filter((e=>null==e.endPositionIndex&&(e.positionIndex===t||e.matchedMonomers.length>1&&t>e.positionIndex&&t<e.positionIndex+e.matchedMonomers.length))):[]}drawPositionBackground(e,t,n,o,r,i,s,a){if(this._ensureCache(),!this._cache)return;let l;this._ensureRowCache();const c=this._findRowRegionHit(s,i);if(c){const e=this._cache.annotations.find((e=>e.id===c.annotationId));l=e?.color??(e?this._getDefaultRegionColor(e):void 0)}if(l||this._rowHasRegionData(s)||(l=this._cache.positionRegionColors.get(i)),l&&(e.save(),e.globalAlpha=.25,e.fillStyle=l,e.fillRect(t,n,o,r),e.restore()),this._rowCache){const l=this._rowCache.data[s];if(l)for(const s of l)if(null==s.endPositionIndex&&i>=s.positionIndex&&i<s.positionIndex+s.matchedMonomers.length){const i=this._cache.annotations.find((e=>e.id===s.annotationId));if(i?.color){const s=null!=a?a+1:n+r-3;e.fillStyle=i.color,e.fillRect(t,s,o,3)}break}}}getTooltipInfo(e,t){this._ensureCache();const n=[];if(!this._cache)return n;this._ensureRowCache();let o=null;const r=this._findRowRegionHit(t,e);if(r){const e=this._cache.annotations.find((e=>e.id===r.annotationId));if(e){o=e.name;const t=e.sourceScheme??"";n.push(`Region: ${e.name}${t?` (${t} ${e.start}-${e.end})`:""}`)}}if(!o&&!this._rowHasRegionData(t)){const t=this._cache.positionRegionNames.get(e);if(t){const e=this._cache.annotations.find((e=>e.name===t&&e.category===zo.Structure)),o=e?.sourceScheme??"";n.push(`Region: ${t}${o?` (${o} ${e?.start}-${e?.end})`:""}`)}}if(this._rowCache){const o=this._rowCache.data[t];if(o)for(const t of o)if(null==t.endPositionIndex&&e>=t.positionIndex&&e<t.positionIndex+t.matchedMonomers.length){const e=this._cache.annotations.find((e=>e.id===t.annotationId));if(e){const t=e.severity?` - ${e.severity.charAt(0).toUpperCase()+e.severity.slice(1)}`:"";n.push(`⚠ ${e.name}${t}`)}}}return n}_findRowRegionHit(e,t){if(this._ensureRowCache(),!this._rowCache)return null;const n=this._rowCache.data[e];if(!n)return null;for(const e of n)if(null!=e.endPositionIndex&&t>=e.positionIndex&&t<=e.endPositionIndex)return e;return null}_rowHasRegionData(e){if(this._ensureRowCache(),!this._rowCache)return!1;const t=this._rowCache.data[e];return!!t&&t.some((e=>null!=e.endPositionIndex))}_ensureCache(){const e=this.tableCol.version;if(this._cache&&this._cache.colVersion===e)return;const t=this.tableCol.getTag(i.gp.annotations);if(!t)return void(this._cache=null);let n;try{n=JSON.parse(t)}catch{return void(this._cache=null)}if(!n||0===n.length)return void(this._cache=null);const o=new Map,r=new Map,s=this._getPosList();for(const e of n){if(e.category!==zo.Structure)continue;if(null==e.start||null==e.end)continue;const t=s.indexOf(e.start),n=s.indexOf(e.end);if(t<0||n<0)continue;const i=e.color??this._getDefaultRegionColor(e);for(let s=t;s<=n;s++)o.set(s,i),r.set(s,e.name)}this._cache={colVersion:e,annotations:n,positionRegionColors:o,positionRegionNames:r}}_ensureRowCache(){const e=this.tableCol.version;if(this._annotColLookupVersion!==e){this._annotColLookupVersion=e;const t=this.tableCol.getTag(i.gp.annotationColumnName);if(t)try{this._annotCol=this.tableCol.dataFrame.columns.byName(t)}catch{this._annotCol=null}else this._annotCol=null}if(!this._annotCol)return void(this._rowCache=null);const t=this._annotCol.version;if(this._rowCache&&this._rowCache.colVersion===t)return;const n=new Array(this._annotCol.length);for(let e=0;e<this._annotCol.length;e++){const t=this._annotCol.get(e);if(t)try{n[e]=JSON.parse(t)}catch{n[e]=null}else n[e]=null}this._rowCache={colVersion:t,data:n}}_getPosList(){const e=this.tableCol.getTag(i.gp.positionNames);return e?e.split(", "):[]}_getDefaultRegionColor(e){if(e.name.startsWith("CDR")){const t=parseInt(e.name.replace("CDR",""))-1;return Ko.structure.CDR[t%Ko.structure.CDR.length]}if(e.name.startsWith("FR")){const t=parseInt(e.name.replace("FR",""))-1;return Ko.structure.FR[t%Ko.structure.FR.length]}return"#90CAF9"}}var Jo=n(3599);const Xo="bio.macromolecule.highlightMonomers",Zo=r.Color.argb(255,255,220,0);r.Color.argb(255,230,140,0);const er="rgb(100,100,100)";class tr extends Bo{get separatorWidth(){return this.props?.fontCharWidth?this.props?.fontCharWidth:5}getAnnotationRenderer(){return this._annotationRenderer||(this._annotationRenderer=new Qo(this.tableCol)),this._annotationRenderer.hasAnnotations()?this._annotationRenderer:null}constructor(e,t,n,o,i){if(super(e,t,n),this.monomerLengthLimit=o,this.propsProvider=i,this.colWidth=0,this._monomerLengthList=null,this._processedMaxVisibleSeqLength=0,this._monomerLengthMap={},this._monomerStructureMap={},this._ellipsisBounds=void 0,this._totalLinesNeeded=0,this._lineHeight=20,this._cellBounds=new Map,this.sysMonomerLib=null,this._annotationRenderer=null,this.padding=5,this._leftThreeDotsPadding=0,this.props=this.propsProvider(),this._processedRows=r.BitSet.create(this.tableCol.length),this.gridCol&&this.subs.push(this.gridCol.grid.onAfterDrawContent.subscribe((()=>{this._onRendered.next()}))),this.tableCol&&this.gridCol){this.subs.push(this.tableCol.dataFrame.onCurrentRowChanged.subscribe((()=>{-1===this.tableCol.dataFrame.currentRowIdx&&(this.tableCol.temp["reference-sequence"]=null,this.tableCol.temp["current-word"]=null,this.invalidateGrid())})));const e=[Ot.gp.positionShift,"renderMultiline"];this.subs.push(r.debounce(this.tableCol.dataFrame.onMetadataChanged.pipe(ne.filter((t=>t.args.source===this.tableCol&&e.includes(t.args.key)))),200).subscribe((e=>{this.reset()}))),this.subs.push(r.debounce(this.tableCol.dataFrame.onMetadataChanged.pipe(ne.filter((e=>e.args.source===this.tableCol&&e.args.key===Ot.gp.positionShift))),200).subscribe((e=>{this.reset()})))}}calculateFontBasedSpacing(e){const t=e.measureText("M");let n=12;if(this.tableCol?.temp[".mm.cellRenderer.fontSize"]){const e=this.tableCol.temp[".mm.cellRenderer.fontSize"];"number"!=typeof e||isNaN(e)||(n=Math.max(e,1))}return{lineHeight:Math.max(1.4*n,t.fontBoundingBoxAscent+t.fontBoundingBoxDescent+4),monomerSpacing:Math.max(2,.2*this.props.fontCharWidth)}}shouldUseMultilineRendering(e){return"true"===e.getTag("renderMultiline")}calculateMultiLineLayoutDynamic(e,t,n,o,r,i){if(this.dirty)try{this.reset()}catch(e){const[t,n]=(0,vn.AP)(e);this.logger.error(t,void 0,n)}const{lineHeight:s,monomerSpacing:a}=this.calculateFontBasedSpacing(e),l=t-2*this.padding;let c=0;const u=[];if(o.length>0)for(let t=r;t<o.length;t++){const n=o.getOriginal(t),r=this.props.monomerToShort(n,i);u.push({text:r,posIdx:t}),c=Math.max(c,e.measureText(r).width)}if(0===u.length)return{lineLayouts:[],lineHeight:s};const h=c;let d=Math.floor((l+a)/(h+a));d=Math.max(1,d);const p=n-2*this.padding,m=Math.max(0,Math.floor(p/s)),f=[];let g=0;for(let e=0;e<m&&g<u.length;e++){const t=[];for(let e=0;e<d&&g<u.length;e++){const n=u[g],o=this.padding+e*(h+a);t.push({posIdx:n.posIdx,x:o,width:h,om:n.text,isSeparator:!1}),g++}f.push({lineIdx:e,elements:t})}return{lineLayouts:f,lineHeight:s}}async init(){await Promise.all([(async()=>{this.seqHelper=await(0,Cn.Q)(),this.invalidateGrid()})(),(async()=>{const e=await(0,l.pj)();this.sysMonomerLib=e.getMonomerLib()})()]),this.subs.push(this.sysMonomerLib.onChanged.subscribe((()=>{this.reset()}))),this.subs.push(o.events.onCustomEvent("bio-macromolecule-monomer-highlight").subscribe((e=>this.handleHighlightEvent(e)))),this.reset()}handleHighlightEvent(e){var t;if(!e||!this.tableCol||!this.tableCol.dataFrame)return;if(e.columnName!==this.tableCol.name)return;const n=this.tableCol.dataFrame;if(e.tableId&&n.id!==e.tableId)return;if(e.tableName&&n.name!==e.tableName)return;const o=(t=this.tableCol.temp)[Xo]??(t[Xo]=new Map);null==e.monomers||0===e.monomers.length?o.delete(e.rowIdx):o.set(e.rowIdx,{monomers:e.monomers.slice(),fillColor:e.fillColor,strokeColor:e.strokeColor}),this.invalidateGrid()}getHighlightForRow(e){if(null==e)return null;const t=this.tableCol.temp[Xo];return t?.get(e)??null}drawHighlightBackground(e,t,n,o,i,s,a){const l=this.getHighlightForRow(t);if(!l||!l.monomers||0===l.monomers.length)return;if(!l.monomers.includes(n))return;const c=(u=l.fillColor??Zo,`rgba(${r.Color.r(u)},${r.Color.g(u)},${r.Color.b(u)},0.4)`);var u;e.save();try{e.fillStyle=c,e.fillRect(o,i,s,a)}finally{e.restore()}}static getFontSettings(e){let t=12;return e&&e.temp[".mm.cellRenderer.fontSize"]&&"number"==typeof e.temp[".mm.cellRenderer.fontSize"]&&!isNaN(e.temp[".mm.cellRenderer.fontSize"])&&(t=Math.max(e.temp[".mm.cellRenderer.fontSize"],1)),{font:`${t}px monospace`,fontWidth:.6*t}}toLog(){return`MonomerPlacer<${this.viewerId}>`}getMonomerLib(){return this.tableCol.temp[".mm.cellRenderer.overriddenLibrary"]??this.sysMonomerLib}reset(){this.propsProvider&&(this.props=this.propsProvider()),this._processedRows=r.BitSet.create(this.tableCol.length),this._monomerLengthList=null,this._monomerLengthMap={},this._monomerStructureMap={},this._cellBounds.clear(),super.reset(),this.invalidateGrid()}invalidateGrid(){this.gridCol&&this.gridCol.dart&&this.gridCol.grid?.invalidate()}getCellMonomerLengths(e,t){const n=this.seqHelper.getSeqHandler(this.tableCol);if(this.colWidth<t&&(this.colWidth=t,this.dirty=!0),this.dirty)try{this.reset()}catch(e){const[t,n]=(0,vn.AP)(e);this.logger.error(t,void 0,n)}const o=n.isMsa()?this.getCellMonomerLengthsForSeqMsa():this.getCellMonomerLengthsForSeq(e);return[o,this.getSummedMonomerLengths(o)]}getSummedMonomerLengths(e){const t=new Array(e.length+1);t[0]=this.padding;for(let n=1;n<t.length;n++)t[n]=t[n-1]+e[n-1];let n=t[0];for(let e=1;e<t.length;e++)t[e]?n=t[e]:t[e]=n;return t}getCellMonomerLengthsForSeqValue(e,t){const n=this.seqHelper.getSeqHandler(this.tableCol),o=this.props.separatorWidth+1*this.props.fontCharWidth,r=this.positionShift,i=Math.ceil(t/o)+r,s=n.splitter(e),a=Math.min(i,s.length),l=new Array(a-r);let c=0;for(let e=r;e<a;++e){const o=s.getOriginal(e),i=this.props.monomerToShort(o,this.monomerLengthLimit),a=(n.isSeparator()?this.separatorWidth:this.props.separatorWidth)+i.length*this.props.fontCharWidth;if(l[e-r]=a,c+=a,c>t)break}return l}getCellMonomerLengthsForSeq(e){this.toLog(),null==this._monomerLengthList&&(this._monomerLengthList=new Array(this.tableCol.length).fill(null));const t=this.positionShift,n=this.seqHelper.getSeqHandler(this.tableCol),o=this.props.separatorWidth+1*this.props.fontCharWidth,r=Math.ceil(this.colWidth/o)+t,i=n.getSplitted(e),s=Math.min(r,i.length);let a=this._monomerLengthList[e];if(null==a||a.length!=s-t){a=this._monomerLengthList[e]=new Array(i.length);let o=0;for(let e=t;e<s;++e){const r=i.getOriginal(e),s=this.props.monomerToShort(r,this.monomerLengthLimit),l=(n.isSeparator()?this.separatorWidth:this.props.separatorWidth)+s.length*this.props.fontCharWidth;if(a[e-t]=l,o+=l,o>this.colWidth)break}}return a}getCellMonomerLengthsForSeqMsa(){var e;this.toLog(),null==this._monomerLengthList&&(this._monomerLengthList=new Array(1).fill(null)),(e=this._monomerLengthList)[0]??(e[0]=new Array(0));const t=this._monomerLengthList[0],{startIdx:n,endIdx:o}=(()=>{try{const e=this.gridCol&&this.gridCol.dart?this.gridCol.grid:null;return e&&e.dart?{startIdx:Math.max(Math.floor((e?.vertScroll.min??0)-10),0),endIdx:Math.min(Math.ceil((e?.vertScroll.max??0)+10),this.tableCol.length)}:{startIdx:0,endIdx:Math.min(this.tableCol.length,10)}}catch(e){return{startIdx:0,endIdx:Math.min(this.tableCol.length,10)}}})(),r=this.props.separatorWidth+1*this.props.fontCharWidth,i=this.positionShift,s=Math.ceil(this.colWidth/r)+i;for(let e=n;e<o;e++){if(this._processedRows.get(e)&&s<=this._processedMaxVisibleSeqLength)continue;const n=this.seqHelper.getSeqHandler(this.tableCol).getSplitted(e,s),o=Math.min(s,n.length);o-i>t.length&&t.push(...new Array(o-i-t.length).fill(r));let a=0;for(let e=i;e<o;++e){const o=n.getOriginal(e),r=this.props.monomerToShort(o,this.monomerLengthLimit),s=this.props.separatorWidth+r.length*this.props.fontCharWidth;if(t[e-i]=Math.max(t[e-i]??0,s),a+=s,a>=this.colWidth)break}this._processedMaxVisibleSeqLength=Math.max(this._processedMaxVisibleSeqLength,s),this._processedRows.set(e,!0)}return t}getPosition(e,t,n,o){const[r,i]=this.getCellMonomerLengths(e,n);return 0===this.seqHelper.getSeqHandler(this.tableCol).getSplitted(e).length?null:function(e,t,n){if((n??0)>0&&t<(e[0]??0)+n)return-1;t-=n??0;let o,r=100,i=0,s=e.length-1;for(;i<=s;){if(o=Math.floor((s+i)/2),e[o]<=t&&t<e[o+1])return o;if(t<e[o]?s=o-1:i=o+1,--r<=0)throw new Error(`Get position for pointer x = ${t} searching has not converged on ${JSON.stringify(e)}. `)}return null}(i,t,o)}setMonomerLengthLimit(e){this.monomerLengthLimit!=e&&(this.monomerLengthLimit=e,this.dirty=!0)}setSeparatorWidth(e){this.separatorWidth!=e&&(this.props.separatorWidth=e,this.dirty=!0)}get positionShift(){const e=Number.parseInt(this.tableCol?.tags[Ot.gp.positionShift]??"0")??0;return isNaN(e)?0:Math.max(e,0)}render(e,t,n,o,i,s,a){const l=s.grid?.dart&&s.grid?.canvas===e.canvas;if(!this.seqHelper)return;const c=this.tableCol,u=this.positionShift;e.save();try{const a=this.seqHelper.getSeqHandler(c);let h=this.monomerLengthLimit;if(Go.maxMonomerLength in c.tags){const e=parseInt(c.getTag(Go.maxMonomerLength));h=!isNaN(e)&&e?e:50}if(".mm.cellRenderer.maxMonomerLength"in c.temp){const e=c.temp[".mm.cellRenderer.maxMonomerLength"],t="number"==typeof e?e:parseInt(e);h=!isNaN(t)&&t?t:50}if("1"===c.temp[".mm.cellRenderer.settingsChanged"]||this.monomerLengthLimit!=h){let e=0;const t=8;e=c.temp[".mm.cellRenderer.gapLength"]??e,this.setMonomerLengthLimit(h),this.setSeparatorWidth(a.isMsa()?t:e),c.temp[".mm.cellRenderer.settingsChanged"]="0",this.dirty=!0}const d=s.cell.rowIndex,p=s.cell.value;l&&(o=function(e,t,n,o,r){return e?Math.max(Math.min(e.canvas.width/r-n,o)):Math.max(t.canvas.width/r-n,0)}(s.grid,e,t,o,window.devicePixelRatio)),e.beginPath(),e.rect(t,n,o,i),e.clip(),e.font=this.props?.font??"12px monospace",e.textBaseline="top";const m=c.meta.units,f=c.getTag(Ot.gp.aligned),g=c.getTag(Ot.gp.separator)??"",y=l?a.getSplitted(d):a.splitter(p);let b=Vo.classic;f?.includes("MSA")&&m===Ot.Hi.SEPARATOR&&(b=Vo.MSA);const v=c.temp["reference-sequence"],C=this.tableCol.temp["current-word"],x=(()=>{const e=(0,a.splitter)(null!=v&&""!==v?v:C??"");return wn().count(0).take(e.length).slice(u).map((t=>e.getCanonical(t))).toArray()})(),w=Number.parseInt(c.getTag(Ot.gp.selectedPosition)??"-200"),A=this.shouldUseMultilineRendering(c),T=this.getAnnotationRenderer();if(A){const l=[],d=this.calculateMultiLineLayoutDynamic(e,o,i,y,u,h);let p=n+this.padding;1===d.lineLayouts.length&&(p=n+(i-d.lineHeight)/2);for(const o of d.lineLayouts){const i=p+o.lineIdx*d.lineHeight;for(const h of o.elements){const p=t+h.x,m=h,f=m.posIdx,g=y.getCanonical(f);let b=er;const v=this.getMonomerLib();v&&(b=v.getMonomerTextColor(a.defaultBiotype,g));let C=0;if(s.tableRowIndex!==c.dataFrame.currentRowIdx&&x.length>0){const e=f-u;e>=0&&e<x.length&&g===x[e]&&(C=.7)}l.push({lineIdx:o.lineIdx,monomerIdx:f-u,bounds:new r.Rect(h.x,i-n,h.width,d.lineHeight),sequencePosition:f}),T&&T.drawPositionBackground(e,p,i,h.width+2,d.lineHeight,f,s.tableRowIndex),this.drawHighlightBackground(e,s.tableRowIndex,f,p,i,h.width+2,d.lineHeight),qo(e,m.om,p,i,h.width,d.lineHeight,{color:b,isMultiLineContext:!0,transparencyRate:C,selectedPosition:isNaN(w)||w<1?void 0:w,wordIdx:f})}}null!==s.tableRowIndex&&this._cellBounds.set(s.tableRowIndex,l)}else{this._leftThreeDotsPadding=this.shouldRenderShiftedThreeDots(u)?e.measureText("...").width:0;let[,r]=this.getCellMonomerLengths(s.tableRowIndex,o);l||(r=this.getSummedMonomerLengths(this.getCellMonomerLengthsForSeqValue(p,o)));const c=this.props.separatorWidth+1*this.props.fontCharWidth,d=Math.min(y.length,Math.ceil(o/c)+u);let m;const f=e.measureText("M"),v=f.fontBoundingBoxAscent+f.fontBoundingBoxDescent,C=4,A=Math.min(i,v+C),E=n+(i-A)/2;T&&(m=n+(i/2-v/2+1)+v);for(let l=u;l<d;++l){const c=l<y.length?y.getOriginal(l):a.defaultGapOriginal,d=l<y.length?y.getCanonical(l):a.defaultGapOriginal;let p=er;this.getMonomerLib()&&(p=this.getMonomerLib().getMonomerTextColor(a.defaultBiotype,d));const f=l===y.length-1,v=(y?.graphInfo?.disjointSeqStarts?.indexOf(l+1)??0)>0?"|":g,C=l-u,S=(r[C]??0)-(r[0]??0),N=(C+1<r.length?(r[C+1]??0)-(r[0]??0):S+this.props.fontCharWidth)-S,I=t+this.padding+this._leftThreeDotsPadding+S;T&&null!=s.tableRowIndex&&T.drawPositionBackground(e,I,n,N,i,l,s.tableRowIndex,m),this.drawHighlightBackground(e,s.tableRowIndex,l,I,E,N,A);const M={color:p,pivot:0,left:!0,transparencyRate:0,separator:v,last:f,drawStyle:b,maxWord:r,wordIdx:l-u,gridCell:s,referenceSequence:x,maxLengthOfMonomer:h,monomerTextSizeMap:this._monomerLengthMap,logger:this.logger,selectedPosition:isNaN(w)||w<1?void 0:w-u};qo(e,c,t+this.padding+this._leftThreeDotsPadding,n,o,i,M)}if(this.shouldRenderShiftedThreeDots(u)){const a={color:er,pivot:0,left:!0,transparencyRate:0,separator:g,last:!1,drawStyle:b,maxWord:r,wordIdx:0,gridCell:s,maxLengthOfMonomer:h,monomerTextSizeMap:this._monomerLengthMap,logger:this.logger};qo(e,"...",t+this.padding,n,o,i,a)}}}catch(e){const[t,n]=(0,vn.AP)(e);this.logger.error(t,void 0,n),this.errors.push(e)}finally{e.restore()}}shouldRenderShiftedThreeDots(e){return e>0&&(!this.gridCol||!this.gridCol.dart||!this.gridCol.grid||!this.gridCol.grid.dart||(this.gridCol.grid.props.colHeaderHeight??0)<=50)}onMouseMove(e,t){const n=`${this.toLog()}.onMouseMove()`;if(!this.seqHelper||null==e.tableRowIndex)return;const o=this.positionShift,r=e.bounds,i=t.offsetX-e.gridColumn.left+(e.gridColumn.left-r.x),s=t.offsetY-r.y;this.gridCol?.grid?.canvas&&(this.gridCol.grid.canvas.style.cursor="default");let a=null;const l=this._cellBounds.get(e.tableRowIndex);if(l){for(const e of l)if(e.bounds.contains(i,s)){a=e.monomerIdx;break}}else{const t=this.shouldRenderShiftedThreeDots(o)&&(this._leftThreeDotsPadding??0)>0?this._leftThreeDotsPadding:0;a=this.getPosition(e.tableRowIndex,i,r.width,t)}this.logger.debug(`${n}, argsX: ${i}, argsY: ${s}, left: ${a}`);const c=this.seqHelper.getSeqHandler(this.tableCol),u=c.getSplitted(e.tableRowIndex);if(null!==a&&a>=0&&a+o<u.length){const n=c.alphabet??Ot.YI.UN,r={position:a,biotype:n===Ot.YI.RNA||n===Ot.YI.DNA?Jo.o.NUCLEOTIDE:Jo.o.AA,symbol:u.getCanonical(a+o)},i=[];let s=this._monomerStructureMap[r.symbol];if(!s){const e=this.getMonomerLib();s=this._monomerStructureMap[r.symbol]=e?e.getTooltip(r.biotype,r.symbol):P.divText("Monomer library is not available")}i.push(s);const l=this.getAnnotationRenderer();if(l){const t=l.getTooltipInfo(a+o,e.tableRowIndex);if(t.length>0){const e=document.createElement("hr");e.style.margin="4px 0",e.style.border="none",e.style.borderTop="1px solid #ccc",i.push(e);for(const e of t)i.push(P.divText(e,{style:{fontSize:"12px",marginBottom:"2px"}}))}}P.tooltip.show(P.divV(i),t.x+16,t.y+16),Un(e,r)}else-1===a?P.tooltip.show(P.divText(`${Math.min(o,u.length)} hidden monomers`),t.x+16,t.y+16):P.tooltip.hide(),Un(e,null)}}class nr extends tr{constructor(e,t,n,o){super(e,t,br.logger,n,(()=>{const e=o.getSeqHandler(t),{font:n,fontWidth:r}=tr.getFontSettings(t);return{seqHandler:e,font:n,fontCharWidth:r,separatorWidth:11,monomerToShort:Ot.zS}}))}onMouseMove(e,t){super.onMouseMove(e,t)}}class or extends Ro.$G{static get notationName(){return"Harmonized Sequence"}static get implementsFromHelm(){return!1}static convertFromHelm(e,t){throw new Error("converting from helm not supported yet")}get defaultGapOriginal(){return""}constructor(e,t){super(),this.separator=e,this.helmHelper=t,this.separatorSplitter=(0,Ot.dh)(this.separator),this.splitter=this._splitter.bind(this)}setUnits(){}_splitter(e){const t=this.separatorSplitter(e);return new rr(wn().count(0).take(t.length).map((e=>t.getOriginal(e))).toArray(),i.b9[i.Hi.SEPARATOR])}getHelm(e,t){return Oo.s.fromSeparator(e,this.helmHelper).getHelm()}createCellRendererBack(e,t){const n=new nr(e,t,4,this.helmHelper.seqHelper);return n.init().then((()=>{})),n}}class rr extends s.Mu{getCanonical(e){if(this.isGap(e))return i._S;const t=this.getOriginal(e);let n=t;return t.startsWith("{")?n=t.slice(1):t.endsWith("}")?n=t.slice(0,-1):t.startsWith("(")?n=t.replace(/^\(.\d+\)/,""):t.endsWith(")")&&(n=t.replace(/\(\d+\)$/,"")),n}constructor(e,t){super(e,t)}}async function ir(e){await br.initPromise;const t=window.innerWidth,n=window.innerHeight;try{let i;function s(){if(null==i)return;const e=L()(i.root).find("div.d4-dialog-contents").get(0),t=e.clientHeight,n={0:1},o=Object.values(n).reduce(((e,t)=>e+t),0),r=t-wn().count(0).take(e.children.length).filter((e=>!(e in n))).map((t=>e.children[t])).filter((e=>e instanceof HTMLElement)).map((e=>e.offsetHeight)).reduce(((e,t)=>e+t),0)-38;for(const t of wn().count(0).take(e.children.length))if(t in n){const i=e.children[t],s=r*n[t]/o;i.style.height=`${s}px`}}i=await async function(e,t){const n="ST: PT: HelmDialog()";let i;const s=[];let c=So.aK.Single;const u=()=>{for(const e of s)e.unsubscribe();i.placeholders.detach()};try{const h=await(0,l.pj)(),d=h.getMonomerLib(),p=await(0,Cn.Q)(),m=await(0,bn.b2)(),f=m.buildMonomersFuncsFromLib(d),g=e=>{let t,n,o=null;if(e&&e.rowIndex>=0&&e?.column.semType==r.SEMTYPE.MACROMOLECULE){if(t=p.getSeqHandler(e.column).getValue(e.rowIndex),e.column.temp?.[a.notationProvider]&&!(e.column.temp[a.notationProvider]instanceof or)){let n;o=e.column.temp[a.notationProvider].getHelm(t.value,{}),r.DataFrame.fromColumns([n=r.Column.fromList(r.COLUMN_TYPE.STRING,"seq",[o])]),n.semType=r.SEMTYPE.MACROMOLECULE,n.meta.units=Ot.Hi.HELM,t=p.getSeqHandler(n).getValue(0)}n=t.tags["polytool-data-role"]??"macromolecule"}else{const e=r.Column.fromList(r.COLUMN_TYPE.STRING,"seq",[No.d]);e.semType=r.SEMTYPE.MACROMOLECULE,r.DataFrame.fromColumns([e]),e.meta.units=Ot.Hi.HELM,t=p.getSeqHandler(e).getValue(0),n="macromolecule"}return[t,n]};let y,b,[v,C]=g(e),x=null;const w=P.divText("",{style:{color:"red"}}),A=P.divText("",{style:{fontSize:"11px",color:"var(--grey-4)",marginTop:"2px",marginLeft:"4px",whiteSpace:"nowrap"}});i={macromolecule:m.createHelmInput("Macromolecule",{editable:!1,editorOptions:{drawOptions:{monomerNumbering:1,getMonomer:(t,n)=>{const o=t;if("ATOM"!==o.T)return f.getMonomer(t,n);try{if(v.isDna()||v.isRna()){const e=v.getSplittedWithSugarsAndPhosphates().getCanonical(o.bio.continuousId-1);return f.getMonomer(o.bio.type,e)}if(e?.column?.temp?.[a.notationProvider]instanceof or){const e=v.getSplitted().getCanonical(o.bio.continuousId-1);return f.getMonomer(o.bio.type,e)}{const e=o.elem;return f.getMonomer(o.bio.type,e)}}catch(e){return f.getMonomer(t,n)}}}}}),placeholders:await Io.create("Placeholders",{showAddNewRowIcon:!0,showRemoveRowIcon:!0,showRowHeader:!1,showCellTooltip:!1}),enumeratorType:P.input.choice("Enumerator type",{value:c,items:Object.values(So.aK)}),placeholdersBreadth:await Lo.create("Breadth",{showAddNewRowIcon:!0,showRemoveRowIcon:!0,showRowHeader:!1,showCellTooltip:!1}),keepOriginal:P.input.bool("Keep original",{value:!1}),toAtomicLevel:P.input.bool("To atomic level",{value:!1,onValueChanged:(e,t)=>{N()}}),generateHelm:P.input.bool(Qn,{value:!0}),chiralityEngine:P.input.bool(Jn,{value:!1}),highlightMonomers:P.input.bool(Xn,{value:!1}),rules:{header:P.inlineText([to]),form:await(b=new jn._v(jn.MU,jn.yy,".json",{onValueChanged:e=>{y=e}})).getForm()},trivialName:P.input.string("Trivial name",{value:"",onValueChanged:e=>{const t=e?.trim();x=t?{value:t,colName:"Trivial name"}:null}}),appendToTable:P.input.table("Append to table",{items:o.shell.tables,nullable:!0})};const T=()=>{const e=no[i.enumeratorType.value]??"";P.tooltip.bind(i.enumeratorType.input,e)};if(T(),e?.dataFrame){const t=P.iconFA("columns",(t=>{r.Menu.popup().singleColumnSelector(e.dataFrame,{columnFilter:t=>t.type===r.COLUMN_TYPE.STRING&&t!==e.column,onChange:(t,n,o)=>{o&&(i.trivialName.value=n.get(e.rowIndex)??"")}}).show({x:t.clientX,y:t.clientY})}),"Pick trivial name from a column");i.trivialName.addOptions(t)}i.trivialName.root.style.maxWidth="450px",i.placeholders.onMonomerCellEdit=async(e,t)=>{const n=i.macromolecule.molValue;if(e<0||e>=n.atoms.length)return null;const o=n.atoms[e].biotype(),r=(0,To.Y)(o);return _o(d,r,t,h)},i.placeholdersBreadth.onMonomerCellEdit=async(e,t,n)=>{const o=i.macromolecule.molValue;if(e<0||e>=o.atoms.length)return null;const r=o.atoms[e].biotype(),s=(0,To.Y)(r);return _o(d,s,n,h)};let E=null;i.placeholders.addValidator((e=>{E=null;const t=[];setTimeout((()=>{M()}),100);try{if(i.enumeratorType.value===So.aK.Parallel){const e=i.placeholders.placeholdersValue.filter((e=>e.monomers.length>0));if(e.length>1){const t=e[0].monomers.length,n=e.find((e=>e.monomers.length!==t));n&&(E=`Parallel mode requires all positions to have the same number of monomers. Position ${e[0].position+1} has ${t}, but position ${n.position+1} has ${n.monomers.length}.`)}}if("macromolecule"!==C)return null;const e=[];for(const n of i.placeholders.placeholdersValue){const o=n.position;if(null==o)continue;if(o>=i.macromolecule.molValue.atoms.length){t.push(`There is no monomer at position ${o+1}.`);continue}const r=i.macromolecule.molValue.atoms[o];if(r){const t=r.biotype(),o=(0,To.Y)(t);for(const t of n.monomers){const n=d.getMonomer(o,t);n&&n.lib||e.push({polymerType:o,symbol:t})}}}const n={};for(const t of e){let e=n[t.polymerType];e||(e=n[t.polymerType]=[]),e.push(t.symbol)}const o=Object.entries(n).map((([e,t])=>`${e}: ${t.join(", ")}`)).join("\n");Object.keys(o).length>0&&t.push(`Placeholders contain missed monomers: ${o}`),E=t.length>0?t.join("\n"):E}catch(e){const[t,n]=zn(e,!1);E=t}return setTimeout((()=>{M()}),0),E})),i.enumeratorType.onChanged.subscribe((e=>{c=i.enumeratorType.value,T(),i.placeholders.fireChanged()})),s.push(i.macromolecule.onMouseMove.subscribe((e=>{try{br.logger.debug(`${n}, placeholdersInput.onMouseMove()`);const t=e.offsetX,o=e.offsetY,r=i.macromolecule.molValue,s=m.getHoveredAtom(t,o,r,i.macromolecule.root.clientHeight);if(s){const t=s._parent.atoms.indexOf(s),n=i.placeholders.placeholdersValue.find((e=>e.position===t))?.monomers;if(n){const t=P.divText(n.join(", "));i.macromolecule.showTooltip(t,s),e.preventDefault(),e.stopPropagation()}}}catch(e){zn(e,!1)}}))),s.push(i.macromolecule.onClick.subscribe((e=>{try{br.logger.debug(`${n}, placeholdersInput.onClick()`);const t=e.offsetX,o=e.offsetY,r=i.macromolecule.molValue,s=m.getHoveredAtom(t,o,r,i.macromolecule.root.clientHeight);if(s){const e=s._parent.atoms.indexOf(s);i.placeholders.addPosition(e,"")}}catch(e){zn(e)}}))),s.push(i.placeholders.onChanged.subscribe((()=>{S(),_()}))),s.push(i.placeholdersBreadth.onChanged.subscribe((()=>{_()}))),s.push(i.keepOriginal.onChanged.subscribe((()=>{_()}))),s.push(P.onSizeChanged(i.placeholders.root).subscribe((()=>{t&&t()}))),s.push(o.events.onCurrentCellChanged.subscribe((()=>{const e=o.shell.tv.dataFrame.currentCell;e.column.semType===r.SEMTYPE.MACROMOLECULE&&([v,C]=g(e),O(v,C,e))}))),i.macromolecule.root.style.setProperty("min-width","250px","important");const S=()=>{const e=new Set(i.placeholders.placeholdersValue.map((e=>e.position))),t=i.macromolecule.molValue;for(let n=0;n<t.atoms.length;n++)t.atoms[n].highlighted=e.has(n);i.macromolecule.redraw()},N=()=>{i.toAtomicLevel.value&&"template"===C?(i.generateHelm.root.style.removeProperty("display"),i.chiralityEngine.root.style.removeProperty("display"),i.highlightMonomers.root.style.removeProperty("display"),i.rules.header.style.removeProperty("display"),i.rules.form.style.removeProperty("display")):(i.generateHelm.root.style.display=i.chiralityEngine.root.style.display=i.highlightMonomers.root.style.display="none",i.rules.header.style.display=i.rules.form.style.display="none"),t&&t()};let I=null;const M=()=>{const e=E,t=w;e?(t.innerText=e,t.style.removeProperty("display"),I&&(I.disabled=!0)):(t.innerText="",t.style.setProperty("display","none"),I&&(I.disabled=!1))},_=()=>{try{const e=i.placeholders.placeholdersValue.filter((e=>e.monomers.length>0)),t=i.placeholdersBreadth.placeholdersBreadthValue.filter((e=>e.monomers.length>0&&null!=e.start&&null!=e.end));let n=0;switch(i.enumeratorType.value){case So.aK.Single:n=e.reduce(((e,t)=>e+t.monomers.length),0);break;case So.aK.Parallel:e.length>0&&(n=e.every((t=>t.monomers.length===e[0].monomers.length))?e[0].monomers.length:0);break;case So.aK.Matrix:n=e.length>0?e.reduce(((e,t)=>e*t.monomers.length),1):0}let o=0;t.length>0&&(o=t.reduce(((e,t)=>{const n=Math.abs(t.end-t.start)+1;return e*(t.monomers.length*n)}),1));let r=n+o;i.keepOriginal.value&&r>0&&(r+=1),A.textContent=r>0?`${r} sequence${1!==r?"s":""} will be generated`:""}catch(e){A.textContent=""}},L=e=>{t&&t()},O=(e,t,n)=>{i.macromolecule.value=e;const o=n?.dataFrame;L(o)};O(v,C,e),N(),_();const R=async()=>{try{const t=i.macromolecule.stringValue;if(void 0===t||""===t)o.shell.warning("PolyTool: no molecule was provided");else{if(0===Object.keys(i.placeholders.placeholdersValue).length&&0===Object.keys(i.placeholdersBreadth.placeholdersBreadthValue).length)return void o.shell.warning(`${eo}: placeholders are empty`);await(0,bn.b2)();const n=i.placeholders.placeholdersValue,r=i.enumeratorType.value;if(r===So.aK.Parallel){const e=n.filter((e=>e.monomers.length>0));if(e.length>1){const t=e[0].monomers.length;if(e.some((e=>e.monomers.length!==t)))return void o.shell.warning("Parallel mode requires all positions to have the same number of monomers")}}const s={placeholders:n,type:r,breadthPlaceholders:i.placeholdersBreadth.placeholdersBreadthValue,keepOriginal:i.keepOriginal.value};if(e?.column?.temp?.[a.notationProvider]&&!(e.column.temp[a.notationProvider]instanceof or)){const t=e.column.temp[a.notationProvider];if(t.constructor.implementsFromHelm){const e=t.constructor;s.fromHelmNotation={notationName:e.notationName,convert:t=>e.convertFromHelm(t,{})}}}const l=i.toAtomicLevel.value,c=await sr(t,C,x,s,!!l&&{generateHelm:i.generateHelm.value,chiralityEngine:i.chiralityEngine.value,highlightMonomers:i.highlightMonomers.value,rules:await b.getActive()},m),u=i.appendToTable.value;u?(u.append(c,!0),u.meta.detectSemanticTypes()):o.shell.addTableView(c)}}catch(e){zn(e)}},$=P.dialog({title:eo,showFooter:!0}).add(i.macromolecule.root).add(P.divH([P.divV([i.placeholders.root,P.divH([i.enumeratorType.root,A],{style:{alignItems:"center"}})],{style:{width:"50%"}}),P.divV([i.placeholdersBreadth.root],{style:{width:"50%"}})],{style:{width:"100%"}})).add(P.divH([P.divV([i.trivialName.root,i.keepOriginal.root,i.appendToTable.root],{style:{width:"50%"}}),P.divV([P.divH([i.toAtomicLevel.root,i.generateHelm.root]),P.divH([i.chiralityEngine.root,i.highlightMonomers.root]),i.rules.header,i.rules.form],{style:{width:"50%"}})],{style:{width:"100%"}})).add(w).onOK((()=>{if(E)return M(),void o.shell.warning("Please fix validation errors before running enumeration");R()}));return I=$.getButton("OK"),s.push($.onClose.subscribe((()=>{u()}))),$.history((()=>({description:`${i.enumeratorType.value} ${i.placeholders.placeholdersValue?.map((e=>(e.position?.toString()??"")+": "+e.monomers?.join(", "))).join("; ")}`,placeholders:i.placeholders.stringValue,enumeratorType:i.enumeratorType.value,placeholdersBreadth:i.placeholdersBreadth.stringValue,trivialName:i.trivialName.value,keepOriginal:i.keepOriginal.value,toAtomicLevel:i.toAtomicLevel.value,generateHelm:i.generateHelm.value,chiralityEngine:i.chiralityEngine.value,highlightMonomers:i.highlightMonomers.value,rules:y})),(e=>{i.enumeratorType.value=e.enumeratorType??So.aK.Single,i.placeholders.stringValue=e.placeholders,i.placeholdersBreadth.stringValue=e.placeholdersBreadth,e.trivialName&&(i.trivialName.value=e.trivialName),i.keepOriginal.value=e.keepOriginal??!1,i.toAtomicLevel.value=e.toAtomicLevel??!0,i.generateHelm.value=e.generateHelm??!0,i.chiralityEngine.value=e.chiralityEngine??!1,i.highlightMonomers.value=e.highlightMonomers??!1,b.setActive(e.rules),setTimeout((()=>{i.placeholders.invalidateGrid(),i.placeholdersBreadth.invalidateGrid(),_()}),100)})),$}catch(e){throw u(),e}}(e,s);let c=!0;P.onSizeChanged(i.root).subscribe((()=>{if(c){const e=.7*t,o=.7*n;i.root.style.width=`${Math.min(t,e)}px`,i.root.style.height=`${Math.min(n,o)}px`,i.root.style.left=`${Math.floor((t-i.root.offsetWidth)/2)}px`,i.root.style.top=`${Math.floor((n-i.root.offsetHeight)/2)}px`,c=!1}s()})),s(),br.logger.debug("PolyToolEnumerateHelmUI: dialog before show"),i.show({width:Math.max(350,.7*t),resizable:!0}),br.logger.debug("PolyToolEnumerateHelmUI: dialog after show")}catch(u){const[h,d]=(0,vn.AP)(u);br.logger.error(h,void 0,d)}}async function sr(e,t,n,i,s,a){const c=r.TaskBarProgressIndicator.create("PolyTool enumerating...");try{const c=await(0,l.pj)(),u=await(0,Vn.j)(),h=c.getMonomerLib(),d=(0,No.o)(e,n?.value??"",i);let p;switch(t){case"macromolecule":p=r.Column.fromType(r.COLUMN_TYPE.STRING,"Enumerated",d.length).init((e=>d[e][0]));break;case"template":{const e=new Array(d.length);for(let t=0;t<d.length;t++){const n=d[t][0],o=Oo.s.fromHelm(n,a);e[t]=o.getNotation()}p=r.Column.fromList(r.COLUMN_TYPE.STRING,"Enumerated",e),p.semType=r.SEMTYPE.MACROMOLECULE,p.setTag("polytool-data-role","template"),Cr.applyNotationProviderForCyclized(p,"-");break}}const m=r.DataFrame.fromColumns([p]);if("macromolecule"===t&&i.fromHelmNotation){const e=r.Column.fromType(r.COLUMN_TYPE.STRING,`${i.fromHelmNotation.notationName}(${p.name})`,m.rowCount).init((e=>p.isNone(e)?null:i.fromHelmNotation.convert(p.get(e))));m.columns.add(e)}if(await o.data.detectSemanticTypes(m),"template"==t&&Cr.applyNotationProviderForCyclized(p,"-"),s){let e;if("macromolecule"===t){e=p;const t=await a.seqHelper.helmToAtomicLevel(e,s.chiralityEngine,s.highlightMonomers);m.columns.add(t.molCol,!1);const n=t.molCol;await async function(e,t,n,o,r,i=!1){const s=o.getSeqHandler(e),a=s.alphabet==Ot.YI.RNA||s.alphabet==Ot.YI.DNA,l=s.isHelm()&&a,c=!s.isHelm()&&a,u=e=>null==e?null:l?i?e:Math.floor(e/3):c&&i?3*e+1:e,h=i?await o.getHelmToMolfileConverter(n):null,d=new On({max:100});function p(e,t){const s=e.get(t);if(null==s)return null;let a=d.get(s);return a||d.set(s,a=function(e,t){const s=o.getSeqHandler(e);if(i){const e=s.getHelm(t);return o.helmToAtomicLevelSingle(e,h,!1,!1).monomers}{const e=s.getSplitted(t),o=s.defaultBiotype,i=wn().count(0).take(e.length).map((t=>({position:t,symbol:e.getCanonical(t),biotype:o}))).toArray(),a=s.alphabet,l=a==Ot.YI.RNA||a==Ot.YI.DNA?"RNA":"PEPTIDE",c=(0,Bn.eM)([i],[void 0],l,a,n,r);return(0,Fn.gU)(i,c,a,l).monomers}}(e,t)),a}const m={targetCol:t,handler:(t,o,r)=>{const i=r.grid,s=t.tableRowIndex,a=t.gridRow,l=i.cell(r.name,a),c=Rn();if(!c||c&&(c.dataFrameId!=e.dataFrame.id||c.gridRowIdx!=a||c.seqColName!=e.name||c.seqPosition!=o?.position)){if(c&&($n(null),c.gridCell.render()),!o)return $n(null),!0;$n({gridCell:l,dataFrameId:e.dataFrame.id,gridRowIdx:a,seqColName:e.name,seqPosition:u(o?.position)??-1,getSubstruct:()=>{if(!o||"*"===o.symbol)return;const t=p(e,s);if(!t)return;const r=t.get(u(o?.position));return r?(0,kn.H)([r],n):{atoms:[],bonds:[],highlightAtomColors:[],highlightBondColors:[]}}}),l.render()}return!0},getSubstruct:o=>{if("true"!=t.getTag(".sequence-src-highlight-monomers"))return;if(null==o)return;if(!e.get(o))return;const r=p(e,o);return r?(0,kn.H)(r.values(),n):void 0}};return Gn(e.temp,m),Dn(t.temp,m),m}(e,n,h,a.seqHelper,u,!0)}else"template"===t&&(e=(await ro(p,s.generateHelm,!1,s.chiralityEngine,!1,s.rules))[0])}if(n){const e=r.Column.fromType(r.COLUMN_TYPE.STRING,n.colName,d.length).init((e=>d[e][1]));m.columns.add(e)}return m}finally{c.close()}}var ar,lr=n(3151);class cr{constructor(e){this.rawLib=e}isValid(){return this.rawLib.every((e=>"object"==typeof e&&Object.values(Yn).every((t=>t in e&&"string"==typeof e[t]))))}getJsonMonomerLib(){const e=[];return this.rawLib.forEach((t=>{const n=this.prepareMonomer(t);e.push(n)})),e}prepareMonomer(e){const t={...lr.pe};Object.entries(Yn).forEach((([n,o])=>{const r=e[o];t[n]=r}));let n="smiles";const o=e[Yn[n]],r=new ur(o),i=r.getCappedSmiles();return t[n]=i,n="rgroups",t[n]=hr.getRGroups(r.getNumberOfRGroups()),n="molfile",t[n]=new dr(r.getSmilesWithRGroups()).getMolfile(),t}}class ur{constructor(e){let t=0;this.smilesWithRGroups=e.replace(/\[R(\d+)\]/g,((e,n)=>(++t,`[${n}*]`))),this.numberOfRGroups=t}getSmilesWithRGroups(){return this.smilesWithRGroups}getCappedSmiles(){return this.capRGroups()}getNumberOfRGroups(){return this.numberOfRGroups}capRGroups(){let e=this.smilesWithRGroups.replace("[1*]","[H:1]");return e=e.replace("[2*]","[OH:2]"),e.replace("[3*]","[H:3]")}}class hr{constructor(){}static getRGroups(e){return Kn.slice(0,e)}}class dr{constructor(e){this.smilesWithRGroups=e}getMolfile(){let e=r.chem.convert(this.smilesWithRGroups,r.chem.Notation.Smiles,r.chem.Notation.MolBlock);return e=this.restoreRGPLine(e),e=this.fixRGroupSymbols(e),e}restoreRGPLine(e){return e.replace("M ISO","M RGP")}fixRGroupSymbols(e){return e.replace(/\bR\b/g,"R#")}}class pr{constructor(e,t){this.fileName=e,this.fileContent=t,this.validateFileType();const n=r.DataFrame.fromCsv(this.fileContent),o=this.toJson(n);this.polyToolMonomerLib=new cr(o),this.validateContent()}async getJson(){return this.polyToolMonomerLib.getJsonMonomerLib()}toJson(e){return Array.from({length:e.rowCount},((t,n)=>e.columns.names().reduce(((t,o)=>(t[o]=e.get(o,n),t)),{})))}validateFileType(){if(!this.fileName.endsWith(".csv"))throw new Error(`File ${this.fileName} is not an CSV file`)}validateContent(){if(!this.polyToolMonomerLib.isValid())throw new Error("Invalid format of CSV monomer lib")}}!function(e){e.table="table",e.seqCol="seqCol",e.generateHelm="generateHelm",e.chiralityEngine="chiralityEngine",e.rules="rules"}(ar||(ar={}));class mr{constructor(e){this.call=e,this.ruleInputs=new jn._v(jn.MU,jn.yy,".json")}async initInputs(){const e=e=>this.call.inputParams[e],t=await this.ruleInputs.getForm();this.inputs={table:(()=>{const t=e(ar.table);return P.input.table(t.property.caption,{value:t.value})})(),seqCol:(()=>{const t=e(ar.seqCol);return P.input.column(t.property.caption,{value:t.value,table:t.value.dataFrame})})(),generateHelm:P.input.forProperty(e(ar.generateHelm).property),chiralityEngine:P.input.forProperty(e(ar.chiralityEngine).property),rules:{header:P.inlineText([to]),form:t}}}static async create(e){const t=new mr(e);return await t.initInputs(),t}async getParams(){return{table:this.inputs.table.value,seqCol:this.inputs.seqCol.value,generateHelm:this.inputs.generateHelm.value,chiralityEngine:this.inputs.chiralityEngine.value,rules:await this.ruleInputs.getActive()}}async showDialog(){const e=P.div([this.inputs.table,this.inputs.seqCol,this.inputs.generateHelm,this.inputs.chiralityEngine,this.inputs.rules.header,this.inputs.rules.form],{style:{minWidth:"320px"}});return new Promise(((t,n)=>{P.dialog({title:Zn}).add(e).onOK((async()=>{const e=await this.getParams(),n=(await this.call.func.prepare(e).call(!0)).getOutputParamValue();t(n)})).onCancel((()=>{n(new Error("Cancelled by user"))})).show()}))}widget(){throw new Error("not implemented")}}var fr=function(e,t,n,o){var r,i=arguments.length,s=i<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(s=(i<3?r(s):i>3?r(t,n,s):r(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},gr=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},yr=function(e,t){return function(n,o){t(n,o,e)}};o.decorators||(o.decorators={}),["func","init","param","panel","editor","demo","app","appTreeBrowser","fileHandler","fileExporter","model","viewer","filter","cellRenderer","autostart","dashboard","folderViewer","semTypeDetector","packageSettingsEditor","functionAnalysis","converter","fileViewer","model","treeBrowser","polyfill"].forEach((e=>{o.decorators[e]||(o.decorators[e]=function(e){return function(e,t,n){}})}));const br=new R({debug:!0});let vr=null;class Cr{static async oligoToolkitApp(){await br.initLibData();const e=await async function(e){const t={"Mermadesynthesis:merMadeSynthesis":{tabName:"SYNTHESIZE",parameters:Kt(e)}},n={};for(const[e,r]of Object.entries(t)){let t;try{t=await o.functions.call(e,r.parameters);const i=new zt(r.tabName,t);i.initView(),n[r.tabName]=()=>i.getView()}catch(t){console.warn(`Plugin ${e} not loaded, reason:`,t);continue}}return n}(br);if(!e)throw new Error("External app view factories not loaded");const t=new Yt(e,br);return await t.getAppView()}static async init(){return null===vr&&br.startInit(vr=async function(){const[e]=await Promise.all([(0,bn.b2)()]);br.completeInit(e)}()),vr}static async oligoTranslatorApp(){return await xr("Oligo Translator")}static async oligoPatternApp(){return await xr("Oligo Pattern")}static async oligoStructureApp(){return await xr("Oligo Structure")}static async getTranslationHelper(){return await br.initLibData(),br}static getCodeToWeightsMap(){const e=br.monomerLibWrapper.getCodesToWeightsMap();return Object.fromEntries(e)}static validateSequence(e){const t=br.createSequenceValidator(e),n=br.createFormatDetector(e).getFormat();return null!==n&&t.isValidSequence(n)}static getMolfileFromGcrsSequence(e,t){return new At(e,t,"GCRS").convert()}static linkStrands(e){return Tt(e,!0)}static async demoTranslateSequence(){await async function(){await b((async()=>{const e=await Cr.oligoTranslatorApp();o.shell.addView(e)}))}()}static async demoOligoPattern(){await async function(){await b((async()=>{const e=await Cr.oligoPatternApp();o.shell.addView(e)}))}()}static async demoOligoStructure(){await async function(){await b((async()=>{const e=await Cr.oligoStructureApp();o.shell.addView(e),["Afcgacsu","Afcgacsu","Afcgacsu"].forEach((async(e,t)=>{await async function(e,t){await r.delay(500);const n=document.querySelectorAll(".st-colored-text-input > textarea")[e];n.value=t;const o=new Event("input");n.dispatchEvent(o)}(t,e)}))}))}()}static async translateOligonucleotideSequence(e,t,n){return await br.initLibData(),br.createFormatConverter(e,t).convertTo(n)}static async polyToolConvertTopMenu(){await async function(){await br.initPromise;let e=null;try{e=await async function(){const e=[],t=()=>{for(const t of e)t.unsubscribe()};try{let n;const i=o.shell.t.columns.bySemTypeAll(r.SEMTYPE.MACROMOLECULE),s=i.filter((e=>br.seqHelper.getSeqHandler(e).notation===Ot.Hi.CUSTOM));if(!n){if(i.length<1)throw new Error("No dataframe with macromolecule columns open");if(s.length<1){const e=r.Func.find({package:"Bio",name:"toAtomicLevel"})[0];return e?(e.prepare().edit(),null):(o.shell.warning("Polytool requires a macromolecule column with custom notation. \n\nUse Top menu | Bio | Transform | To Atomic Level."),null)}n=i[0]}const a=P.input.column("Column",{table:n.dataFrame,value:n,filter:e=>s.includes(e)}),l=P.input.bool(Qn,{value:!0});P.tooltip.bind(l.root,"Add HELM column");const c=P.input.bool("Linearize",{value:!0});P.tooltip.bind(c.root,"Make representation linear if possible");const u=P.input.bool(Jn,{value:!0}),h=P.input.bool(Xn,{value:!0});let d;const p=new jn._v(jn.MU,jn.yy,".json",{onValueChanged:e=>{d=e}}),m=P.inlineText([to]);P.tooltip.bind(m,"Add or specify rules to use");const f=await p.getForm(),g=P.divV([a,l,c,u,h,m,f]),y=async()=>{try{const e=await p.getActive();await ro(a.value,l.value,c.value,u.value,h.value,e)}catch(e){zn(e)}},b=P.dialog(Zn).add(g).onOK((()=>{y()}));return e.push(b.onClose.subscribe((()=>{t()}))),b.history((()=>({generateHelm:l.value,chiralityEngine:u.value,rules:d})),(e=>{l.value=e.generateHelm,u.value=e.chiralityEngine,p.setActive(e.rules)})),b}catch(e){throw t(),e}}(),e?.show()}catch(e){const[t,n]=(0,vn.AP)(e);o.shell.warning("To run PolyTool Conversion, open a dataframe with macromolecules"),br.logger.error(t,void 0,n)}}()}static async getPolyToolConvertEditor(e){const t=await mr.create(e);return await t.showDialog()}static async polyToolConvert2(e,t,n,o,r){return(await ro(t,n,!1,o,!1,r))[0]}static async polyToolEnumerateHelmTopMenu(){await ir(o.shell.tv?.dataFrame.currentCell)}static async polyToolEnumerateChemTopMenu(){wo()}static async chemEnumerateReactionsTopMenu(){wo()}static async polyToolColumnChoice(e,t){var n;(function(e){e.semType=r.SEMTYPE.MACROMOLECULE,e.setTag("aligned","SEQ"),e.setTag("alphabet",Ot.YI.PT)})(n=t),n.meta.units=Ot.Hi.SEPARATOR,n.setTag("separator","-"),await o.data.detectSemanticTypes(e)}static async createMonomerLibraryForPolyTool(e){const t=await e.readAsString(),n=new pr(e.fileName,t),o=await n.getJson(),i=e.fileName.replace(/\.csv$/,".json"),s=JSON.stringify(o,null,2);r.Utils.download(i,s)}static async ptEnumeratorHelmApp(){await ir()}static async ptEnumeratorChemApp(){return await async function(){await br.initPromise;try{const e=Ao(await(0,Vn.j)(),null),t=P.bigButton("Enumerate",(async()=>{await e.execute()}));e.bindActionButton(t);const n=r.View.create();return n.name=so,n.box=!0,n.root.appendChild(P.divV([e.root,P.div([t],{style:{padding:"8px 4px 0"}})],{style:{height:"100%",width:"100%",padding:"8px"}})),n}catch(e){return zn(e),null}}()}static async getPtHelmEnumeratorDialog(e){return ir(e)}static async getPtChemEnumeratorDialog(e){return wo(e)}static async enumerateSingleHelmSequence(e,t,n,o=!1){return await sr(e,"macromolecule",null,{type:So.aK.Single,placeholders:t.map(((e,t)=>({position:e,monomers:n[t]})))},!!o&&{generateHelm:!0,chiralityEngine:!0,highlightMonomers:!1,rules:[]},br.helmHelper)}static async enumerateSingleHelmSequenceWithNaturalAAs(e,t=!1){const n=(0,Ot.qp)(e).length,o=Array.from({length:n},((e,t)=>t)),r=o.map((e=>["A","C","D","E","F","G","H","I","K","L","M","N","P","Q","R","S","T","V","W","Y"]));return await Cr.enumerateSingleHelmSequence(e,o,r,t)}static async getPolyToolCombineDialog(){!async function(){const e=[],t=P.divV([]),n=i=>{const s=(()=>{const e=P.divH([]),t=P.input.table("Table",{value:void 0,tooltipText:"Table with sequences"}),n=P.input.choice("Column",{items:[],value:void 0,tooltipText:"Sequence column"});return t.onChanged.subscribe((async()=>{const e=t.value;if(!e)return n.items=[],void(n.value=null);await e.meta.detectSemanticTypes(),await o.data.detectSemanticTypes(e);const i=Array.from(e.columns.categorical),s=i.map((e=>e.name));n.items=s,n.value=i.find((e=>e.semType===r.SEMTYPE.MACROMOLECULE))?.name??s.find((e=>{const t=e.toLowerCase();return t.includes("seq")||t.includes("pep")}))??s[0]})),e.appendChild(t.root),e.appendChild(n.root),e.style.alignItems="center",{root:e,getValue:()=>({table:t.value,column:n.value})}})(),a=P.icons.delete((()=>{if(!s.root.parentElement||e.length<2)return;s.root.remove();const t=e.indexOf(s);-1!==t&&e.splice(t,1)}),"Remove"),l=P.icons.add((()=>{let t=e.indexOf(s);-1===t&&(t=e.length),n(t+1)}),"Add");s.root.appendChild(a),s.root.appendChild(l),a.style.marginLeft="8px",a.style.marginRight="8px",a.style.color="var(--blue-1)",l.style.color="var(--blue-1)";const c=e[i];c?t.insertBefore(s.root,c.root):t.appendChild(s.root),e.splice(i,0,s)};n(0);const i=P.input.string("Separator",{value:"-",tooltipText:"Separator for sequences",nullable:!1});P.dialog("Combine Sequences").add(t).add(i.root).onOK((async()=>{if(!function(){const t=e.map((e=>e.getValue())),n=t.map((e=>e.table)),o=t.map((e=>e.column));return n.every((e=>!!e))&&o.every((e=>!!e))}())return void o.shell.error("Please fill all the fields");const t=e.map((e=>e.getValue())),n=t.map((e=>e.table)),s=t.map((e=>e.column)),a=i.value,l=s.map(((e,t)=>n[t].col(e).toList().filter((e=>!!e))));let c=0;const u=l.reduce(((e,t)=>e*t.length),1);if(u>1e7)return void o.shell.error("Too many combinations. Maximum allowed is 10M");const h=new Array(u).fill(null),d=(e,t)=>{if(t===l.length)return void(h[c++]=e);const n=`${e}${e?a:""}`,o=l[t];for(let e=0;e<l[t].length;e++)d(n+o[e],t+1)};d("",0);const p=r.DataFrame.fromColumns([r.Column.fromStrings("Combined Sequences",h)]);p.name="Combined Sequences",await p.meta.detectSemanticTypes(),await o.data.detectSemanticTypes(p),o.shell.addTableView(p)})).show({resizable:!0})}()}static oligoNucleotideCellRenderer(){return new un}static oligoNucleotidePanel(e){return function(e){const t=e.value??"",n=(0,Jt.On)(t),o=n.sense.monomers.filter((e=>"nucleotide"===e.kind)).length,i=n.antisense?n.antisense.monomers.filter((e=>"nucleotide"===e.kind)).length:0,s=new Map,a=new Map,l=new Map,c=[...n.sense.monomers,...n.antisense?.monomers??[]];for(const e of c)if("nucleotide"===e.kind){const t=e;hn(s,t.sugar),t.phosphate&&hn(a,t.phosphate)}else hn(l,e.symbol);const u=P.divV([],{style:{fontSize:"12px"}});return u.appendChild(pn("Summary",P.tableFromMap({"Sense length":`${o} nt`,"Antisense length":i?`${i} nt`:"single-strand","Modifications used":dn(s,a),Conjugates:l.size?Array.from(l.entries()).map((([e,t])=>`${(0,Xt.rK)(e).meta.name} ×${t}`)).join(", "):"—"}))),u.appendChild(pn("Legend",function(e,t,n){const o=[],r=new Map;for(const[t,n]of e.entries()){const e=(0,Xt.Jy)(t);"r"!==e&&"d"!==e&&r.set(e,(r.get(e)??0)+n)}for(const[e,t]of r.entries()){const n=(0,Xt.xh)(e,null).meta;o.push({label:n.name,color:n.color,count:t})}const i=new Map;for(const[e,n]of t.entries()){const t=(0,Xt.$T)(e);"p"!==t&&i.set(t,(i.get(t)??0)+n)}for(const[e,t]of i.entries()){const n=(0,Xt.bM)(e).meta;o.push({label:`${n.name} (linkage)`,color:n.color,count:t})}for(const[e,t]of n.entries()){const n=(0,Xt.rK)(e).meta;o.push({label:n.name,color:n.color,count:t})}if(0===o.length)return P.divText("No modifications. Chip color reflects the base (A/C/G/U).",{style:{fontSize:"12px",color:"var(--grey-4, #888)",lineHeight:"1.4"}});const s=o.map((({label:e,color:t,count:n})=>P.divH([P.div([],{style:{width:"14px",height:"14px",borderRadius:"3px",background:t,border:"1px solid rgba(0,0,0,0.15)",flexShrink:"0"}}),P.divText(e,{style:{fontSize:"12px",flex:"1"}}),P.divText(`×${n}`,{style:{fontSize:"11px",color:"var(--grey-4, #888)",fontVariantNumeric:"tabular-nums"}})],{style:{gap:"6px",alignItems:"center",marginBottom:"3px"}})));return P.divV(s)}(s,a,l))),r.Widget.fromRoot(u)}(e)}static oligoNucleotideStructuresPanel(e){return function(e){const t=(e.value??"").split("$")[0].split("|").map((e=>e.trim())).filter((e=>e.length>0));if(0===t.length)return r.Widget.fromRoot(P.divText("No HELM chains found",{style:{fontSize:"12px",color:"var(--grey-4, #888)"}}));const n=t.map((e=>(0,Jt.nj)(e.replace(mn,"$11{")+"$$$$"))),o=1===t.length?["Strand"]:["Sense","Antisense"],i=r.Column.fromStrings("helm",n);i.semType=r.SEMTYPE.MACROMOLECULE,i.meta.units="helm",i.setTag("aligned","SEQ"),i.setTag("alphabet","RNA"),i.setTag("cell.renderer","helm");const s=r.DataFrame.fromColumns([i]),a=P.accordion("oligo chemical structures");for(let e=0;e<s.rowCount;e++){const t=o[e],n=s.cell(e,"helm");a.addPane(t,(()=>fn(n,t)))}return r.Widget.fromRoot(a.root)}(e)}static async convertHelmToOligoNucleotide(e,t){const n=function(e,t){const n=new Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.get(e)??"";const o=r.Column.fromStrings(e.columns.getUnusedName(`${t.name} (oligo)`),n);return gn(o),e.columns.add(o),o}(e,t);return await o.data.detectSemanticTypes(e),n}static async combineSenseAntisenseToOligoNucleotide(e,t,n){const i=function(e,t,n){if(t.length!==n.length)throw new Error("Sense and antisense columns must have the same length");const o=new Array(t.length);for(let e=0;e<t.length;e++){const r=t.get(e)??"",i=n.get(e)??"";if(!(0,Jt.yO)(r)){o[e]="";continue}const s=yn(r,1),a=(0,Jt.yO)(i)?yn(i,2):"",l=a?`${s}|${a}`:s;o[e]=`${l}$$$$`}const i=r.Column.fromStrings(e.columns.getUnusedName(`${t.name}+${n.name} (oligo)`),o);return gn(i),e.columns.add(i),i}(e,t,n);return await o.data.detectSemanticTypes(e),i}static applyNotationProviderForCyclized(e,t){e.setTag("aligned","SEQ"),e.setTag("alphabet","UN"),e.setTag(".alphabetIsMultichar","true"),e.meta.units=i.Hi.CUSTOM,t&&!e.tags[i.qE.separator]&&(e.tags[i.qE.separator]=t),e.tags["polytool-data-role"]="template",e.temp[a.notationProvider]=new or(t,br.helmHelper)}static async harmonizedSequenceNotationProviderConstructor(){return or}}async function xr(e){await br.initLibData();const t=function(e,t){switch(e){case"Oligo Translator":return new Wt(t);case"Oligo Pattern":return new it(t);case"Oligo Structure":return new Lt(t);default:throw new Error(`Unknown app name: ${e}`)}}(e,br);return await t.getAppView()}fr([o.decorators.app({icon:"img/icons/toolkit.png",browsePath:"Peptides | Oligo Toolkit",name:"Oligo Toolkit",tags:["app"]}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"oligoToolkitApp",null),fr([o.decorators.init({tags:["init"]}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"init",null),fr([o.decorators.app({icon:"img/icons/translator.png",browsePath:"Peptides | Oligo Toolkit",name:"Oligo Translator",tags:["app"]}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"oligoTranslatorApp",null),fr([o.decorators.app({icon:"img/icons/pattern.png",browsePath:"Peptides | Oligo Toolkit",name:"Oligo Pattern",tags:["app"]}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"oligoPatternApp",null),fr([o.decorators.app({icon:"img/icons/structure.png",browsePath:"Peptides | Oligo Toolkit",name:"Oligo Structure",tags:["app"]}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"oligoStructureApp",null),fr([o.decorators.func({outputs:[{type:"object",name:"result"}]}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"getTranslationHelper",null),fr([o.decorators.func({outputs:[{type:"object",name:"result"}]}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Object)],Cr,"getCodeToWeightsMap",null),fr([o.decorators.func(),gr("design:type",Function),gr("design:paramtypes",[String]),gr("design:returntype",Boolean)],Cr,"validateSequence",null),fr([o.decorators.func({name:"validateSequence"}),gr("design:type",Function),gr("design:paramtypes",[String,Boolean]),gr("design:returntype",String)],Cr,"getMolfileFromGcrsSequence",null),fr([o.decorators.func(),yr(0,o.decorators.param({type:"object"})),gr("design:type",Function),gr("design:paramtypes",[Object]),gr("design:returntype",String)],Cr,"linkStrands",null),fr([o.decorators.func({meta:{demoPath:"Bioinformatics | Oligo Toolkit | Translator",path:"/apps/Tutorials/Demo/Bioinformatics/Oligonucleotide%20Sequence:%20Translate",demoSkip:"GROK-14320"},name:"demoOligoTranslator",description:"Translate oligonucleotide sequences across various formats accepted by different synthesizers"}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"demoTranslateSequence",null),fr([o.decorators.func({meta:{demoPath:"Bioinformatics | Oligo Toolkit | Pattern",path:"%20/apps/Tutorials/Demo/Bioinformatics/Oligonucleotide%20Sequence:%20Visualize%20duplex"},description:"Design a modification pattern for an oligonucleotide sequence"}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"demoOligoPattern",null),fr([o.decorators.func({meta:{demoPath:"Bioinformatics | Oligo Toolkit | Structure",path:"%20/apps/Tutorials/Demo/Bioinformatics/Oligonucleotide%20Sequence:%20Visualize%20duplex"},description:"Visualize duplex and save SDF"}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"demoOligoStructure",null),fr([o.decorators.func(),gr("design:type",Function),gr("design:paramtypes",[String,String,String]),gr("design:returntype",Promise)],Cr,"translateOligonucleotideSequence",null),fr([o.decorators.func({"top-menu":"Bio | PolyTool | Convert...",name:"polyToolConvert",description:"editor for Performing conversion of sequences in custom notation to molfiles"}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"polyToolConvertTopMenu",null),fr([o.decorators.editor({tags:["editor"]}),gr("design:type",Function),gr("design:paramtypes",[r.FuncCall]),gr("design:returntype",Promise)],Cr,"getPolyToolConvertEditor",null),fr([o.decorators.func({editor:"SequenceTranslator:getPolyToolConvertEditor"}),yr(1,o.decorators.param({options:{caption:"Sequence"}})),yr(2,o.decorators.param({options:{initialValue:"true"}})),yr(3,o.decorators.param({options:{initialValue:"true"}})),yr(4,o.decorators.param({type:"object"})),gr("design:type",Function),gr("design:paramtypes",[r.DataFrame,r.Column,Boolean,Boolean,Array]),gr("design:returntype",Promise)],Cr,"polyToolConvert2",null),fr([o.decorators.func({"top-menu":"Bio | PolyTool | Enumerate HELM...",name:"polyToolEnumerateHelm",description:"Dialog for configuring enumeration of a HELM sequence"}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"polyToolEnumerateHelmTopMenu",null),fr([o.decorators.func({"top-menu":"Bio | PolyTool | Enumerate Chem...",name:"polyToolEnumerateChem",description:"Perform enumeration of a molecule using different fragments at specified positions"}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"polyToolEnumerateChemTopMenu",null),fr([o.decorators.func({"top-menu":"Chem | Transform | Reactions | Enumerate...",name:"chemEnumerateReactions",description:"Enumerate cores and R-group lists into a molecule table (Zip or Cartesian)"}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"chemEnumerateReactionsTopMenu",null),fr([o.decorators.func(),yr(0,o.decorators.param({options:{description:"Input data table"}})),gr("design:type",Function),gr("design:paramtypes",[r.DataFrame,r.Column]),gr("design:returntype",Promise)],Cr,"polyToolColumnChoice",null),fr([o.decorators.func(),gr("design:type",Function),gr("design:paramtypes",[r.FileInfo]),gr("design:returntype",Promise)],Cr,"createMonomerLibraryForPolyTool",null),fr([o.decorators.func({meta:{icon:"img/icons/structure.png",browsePath:"Peptides | PolyTool",role:"app"},name:"HELM Enumerator",tags:["app"]}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"ptEnumeratorHelmApp",null),fr([o.decorators.func({meta:{icon:"img/icons/structure.png",browsePath:"Chem | PolyTool",role:"app"},name:"Chem Enumerator",tags:["app"],outputs:[{type:"view",name:"result"}]}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"ptEnumeratorChemApp",null),fr([o.decorators.func({name:"Polytool Helm Enumerator dialog"}),yr(0,o.decorators.param({type:"object",options:{nullable:!0}})),gr("design:type",Function),gr("design:paramtypes",[r.Cell]),gr("design:returntype",Promise)],Cr,"getPtHelmEnumeratorDialog",null),fr([o.decorators.func({name:"Polytool Chem Enumerator dialog"}),yr(0,o.decorators.param({type:"object",options:{nullable:!0}})),gr("design:type",Function),gr("design:paramtypes",[r.Cell]),gr("design:returntype",Promise)],Cr,"getPtChemEnumeratorDialog",null),fr([o.decorators.func({name:"Enumerate Single HELM Sequence",description:"Enumerate provided HELM sequence on provided positions with provided monomers and generates new table",outputs:[{type:"dataframe",name:"result"}]}),gr("design:type",Function),gr("design:paramtypes",[String,Array,Array,Boolean]),gr("design:returntype",Promise)],Cr,"enumerateSingleHelmSequence",null),fr([o.decorators.func({name:"Enumerate Single HELM Sequence with natural amino acids",description:'Enumerate provided HELM sequence on all positions with natural amino acids and generates new table. Generated table has sequence column called "Enumerated", and molecule column called "Molfile(Enumerated) if toAtomicLevel is set to true. Keywords: Optimize, enumerate, HELM optimization, Maximize Minimize property. When you want to optimize certain peptide using for example logS, set toAtomicLevel to true and use generated molecule column to calculate given property using chem package functions.',outputs:[{type:"dataframe",name:"result"}]}),gr("design:type",Function),gr("design:paramtypes",[String,Boolean]),gr("design:returntype",Promise)],Cr,"enumerateSingleHelmSequenceWithNaturalAAs",null),fr([o.decorators.func({name:"Combine Sequences","top-menu":"Bio | PolyTool | Combine Sequences..."}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"getPolyToolCombineDialog",null),fr([o.decorators.func({name:"oligoNucleotideCellRenderer",description:"Renders OligoNucleotide (siRNA / ASO) duplex view in grid cells",tags:["cellRenderer"],meta:{cellType:"OligoNucleotide",columnTags:"quality=OligoNucleotide",role:"cellRenderer"},outputs:[{type:"grid_cell_renderer",name:"result"}]}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",r.GridCellRenderer)],Cr,"oligoNucleotideCellRenderer",null),fr([o.decorators.func({name:"Oligo-Nucleotide",description:"Modifications, lengths, conjugates and color legend for an OligoNucleotide cell",tags:["panel","widgets"],outputs:[{type:"widget",name:"result"}]}),yr(0,o.decorators.param({type:"semantic_value",options:{semType:"OligoNucleotide"}})),gr("design:type",Function),gr("design:paramtypes",[r.SemanticValue]),gr("design:returntype",r.Widget)],Cr,"oligoNucleotidePanel",null),fr([o.decorators.func({name:"Oligo Structures",description:"Sense and antisense full molecular structures rendered separately",tags:["panel","widgets"],outputs:[{type:"widget",name:"result"}]}),yr(0,o.decorators.param({type:"semantic_value",options:{semType:"OligoNucleotide"}})),gr("design:type",Function),gr("design:paramtypes",[r.SemanticValue]),gr("design:returntype",r.Widget)],Cr,"oligoNucleotideStructuresPanel",null),fr([o.decorators.func({name:"convertHelmToOligoNucleotide",description:"Create a new column tagged as OligoNucleotide so HELM duplex cells render with the oligo view"}),yr(1,o.decorators.param({options:{caption:"HELM column",semType:"Macromolecule"}})),gr("design:type",Function),gr("design:paramtypes",[r.DataFrame,r.Column]),gr("design:returntype",Promise)],Cr,"convertHelmToOligoNucleotide",null),fr([o.decorators.func({name:"combineSenseAntisenseToOligoNucleotide",description:"Combine separate sense + antisense HELM columns into one OligoNucleotide column"}),yr(1,o.decorators.param({options:{caption:"Sense",semType:"Macromolecule"}})),yr(2,o.decorators.param({options:{caption:"Antisense",semType:"Macromolecule"}})),gr("design:type",Function),gr("design:paramtypes",[r.DataFrame,r.Column,r.Column]),gr("design:returntype",Promise)],Cr,"combineSenseAntisenseToOligoNucleotide",null),fr([o.decorators.func({name:"applyNotationProviderForHarmonizedSequence"}),yr(0,o.decorators.param({type:"column"})),gr("design:type",Function),gr("design:paramtypes",[r.Column,String]),gr("design:returntype",void 0)],Cr,"applyNotationProviderForCyclized",null),fr([o.decorators.func({name:"harmonizedSequenceNotationProviderConstructor",meta:{role:"notationProviderConstructor"}}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"harmonizedSequenceNotationProviderConstructor",null)},5412:(e,t,n)=>{"use strict";n.d(t,{m:()=>l});var o=n(6082),r=n(4328),i=n(4971),s=n(6077),a=n(2003);async function l(e,t,n,l,c,u,h,d,p){const m=(await p.helmToAtomicLevel(e,l,c,h)).molCol,f=n.filter((e=>e)).length;if(u&&f>0){const e=new Array(f);let l=0;for(let o=0;o<n.length;o++)n[o]&&(e[l]=t[o],l++);const c=o.Column.fromStrings("helm",e);c.semType=o.SEMTYPE.MACROMOLECULE,c.meta.units=a.Hi.HELM,c.setTag(o.TAGS.CELL_RENDERER,"helm");const u=(await(0,i.pj)()).getMonomerLib();try{const e=await(0,s.C4)(o.DataFrame.create(0),c,u,p,d);l=0;for(let t=0;t<n.length;t++)n[t]&&(m.set(t,e.molCol.get(l)),l++)}catch(e){r.shell.warning("PolyTool was not able to linearize sequences")}}return function(e){for(let t=0;t<e.length;t++)e.set(t,e.get(t).replaceAll("undefined","H")),e.set(t,e.get(t).replaceAll("Oh","O").replaceAll("OH","O")),e.set(t,e.get(t).replaceAll("0.000000 3","0.000000 0")),e.set(t,e.get(t).replaceAll("?","O")),e.set(t,e.get(t).replaceAll(" 0 3\n"," 0 0\n")),e.set(t,e.get(t).replaceAll("RGROUPS=(1 1)",""))}(m),m}},6307:(e,t,n)=>{"use strict";n.d(t,{s:()=>p});var o=n(2125),r=n(8438),i=n(6694);function s(e,t){let n="";for(let e=0;e<t.length;e++){e>0&&(n+="|"),n+=`PEPTIDE${e+1}{`;for(let o=0;o<t[e].length;o++){o>0&&(n+=".");const r=t[e][o];n+=r.length>1?`[${r}]`:r}n+="}"}n+="$";for(let r=0;r<e.length;r++)r>0&&(n+="|"),n+=`PEPTIDE${e[r].fChain+1},PEPTIDE${e[r].sChain+1},`,n+=`${(0,o.M)(e[r].fMonomer-1,t)[0]+1}:R${e[r].fR}-`,n+=`${(0,o.M)(e[r].sMonomer-1,t)[0]+1}:R${e[r].sR}`;return n+="$$$V2.0",n}function a(e,t,n,o=0,r=[],i=[]){let[s,a,l,c,u]=[!1,!1,!1,-1,-1];for(let h=0;h<e.length;h++)if(e[h].includes(t)){if(s){if(l&&(n||e[h]==i[o]+t)){a=!0,u=h;break}if(l||!n&&e[h]!=r[o]+t)continue;a=!0,u=h;break}if(n)s=!0,l=!0,c=h;else if(e[h]==r[o]+t)s=!0,l=!0,c=h;else{if(e[h]!=i[o]+t)continue;s=!0,l=!!n,c=h}}return[s,a,l,c,u]}function l(e,t){const n=[];for(let o=0;o<t.length;o++){const r=`(${t[o].code})`,[s,l]=(0,i.Ln)(t[o]);if(s.length>0)for(let t=0;t<s.length;t++){const[i,c,u,h,d]=a(e,r,!1,t,s,l);i&&c&&(u?n.push({firstIdx:h,secondIdx:d,ruleIdx:o}):n.push({firstIdx:d,secondIdx:h,ruleIdx:o}))}else{const[t,i,s,l,c]=a(e,r,!0);if(!t||!i)continue;s?n.push({firstIdx:l,secondIdx:c,ruleIdx:o}):n.push({firstIdx:c,secondIdx:l,ruleIdx:o})}}return n}function c(e,t,n){const o=[],r=[],i=[],s=[],a=n.length;for(let l=0;l<a;l++){if(-1==n[l].firstIdx)continue;const a=n[l].ruleIdx,c=e[a].code;t[n[l].firstIdx]=t[n[l].firstIdx].replace(`(${c})`,""),t[n[l].secondIdx]=t[n[l].secondIdx].replace(`(${c})`,""),o.push(n[l].firstIdx+1),r.push(n[l].secondIdx+1),i.push(e[a].firstLinkingGroup),s.push(e[a].secondLinkingGroup)}return[o,r,i,s]}function u(e,t,n){const o=[],r=[],i=[],s=n.length;for(let a=0;a<s;a++){if(-1==n[a].firstIdx)continue;const s=n[a].firstIdx,l=n[a].secondIdx,c=n[a].ruleIdx,u=e[c].code;t[s]=t[s].replace(`(${u})`,"")+`_${e[c].name}`,t[l]=t[l].replace(`(${u})`,"")+`_${e[c].name}`,o.push(s+1),r.push(l+1),i.push(n[a].ruleIdx)}return[o,r,i]}var h=n(3599);function d(e,t,n){const o=n.createHelmWebEditor().editor.m;let r=0;const i=new JSDraw2.Point(0,0);for(let e=0;e<t.length;e++)for(let n=0;n<t[e].length;n++){if(t[e][n]){const s=t[e][n],a={type:h.o.AA,i:e,j:n,continuousId:r},l=new JSDraw2.Atom(i,s,a);if(o.addAtom(l),0!==n){const e=o.atoms[r-1],t=o.atoms[r],n=new JSDraw2.Bond(e,t);n.r1=2,n.r2=1,o.addBond(n)}r++,i.x+=JSDraw2.Editor.BONDLENGTH}i.y+=4*JSDraw2.Editor.BONDLENGTH}for(let t=0;t<e.length;t++){const n=o.atoms[e[t].fMonomer-1],r=o.atoms[e[t].sMonomer-1],i=new JSDraw2.Bond(n,r);i.r1=e[t].fR,i.r2=e[t].sR,o.addBond(i)}return o}class p{constructor(e,t,n){this.helmHelper=n,this.underRules=!1,this.posToPosUnderRules=[],this.linkages=t,this.monomers=e,this.mol=d(t,e,n)}static fromSeparator(e,t){const[n,o]=function(e){const t=[],n=[],o=/(\(.\d+\))?\{[^\}]*\}/g,r=[];r.push(e.replaceAll(o,""));const i=e.matchAll(o);for(const e of i){const t=e[0];t&&r.push(t)}let s=0;for(let e=0;e<r.length;e++){const o=r[e].split("-"),i=new Array(o.length);let a=0;for(let t=0;t<o.length;t++){const r=o[t].replace("{","").replace("}","");""!==r?(i[t]=r,s++,a++):n.push({fChain:e,sChain:e+1,fMonomer:s,sMonomer:s+1,fR:1,sR:1})}t.push(i.slice(0,a))}return[n,t]}(e);return new p(o,n,t)}static fromHelm(e,t){const[n,i]=function(e){const t=/(\w+\{.*\})\$(.*)\$(.*)\$(.*)\$/g.exec(e),n=[t[1],t[2],t[3],t[4]],i=n[0].split("|"),s=n[1].split("|"),a=new Array(i.length),l=[];for(let e=0;e<i.length;e++){const t=i[e].indexOf("{"),n=i[e].indexOf("}");a[e]=i[e].slice(t+1,n).split(".").map((e=>(0,r.D)(e)))}for(let e=0;e<s.length;e++)if(""!==s[e]&&"V2.0"!==s[e]){const t=s[e].split(","),n=parseInt(t[0].replace("PEPTIDE",""))-1,r=parseInt(t[1].replace("PEPTIDE",""))-1,i=t[2].split("-"),c=i[0].split(":"),u=i[1].split(":");l.push({fChain:n,sChain:r,fMonomer:(0,o.j)(parseInt(c[0]),n,a),sMonomer:(0,o.j)(parseInt(u[0]),r,a),fR:parseInt(c[1].replace("R","")),sR:parseInt(u[1].replace("R",""))})}return[l,a]}(e);return new p(i,n,t)}getNotation(){return function(e){const t=e.atoms,n=e.bonds,o=[],r=[];for(let e=0;e<n.length;e++)n[e].a1.bio.i!==n[e].a2.bio.i&&r.push(e);for(let e=0;e<t.length;e++){const n=t[e].bio?.i;n+1>o.length?o.push(1):o[n]++}const i=new Array(o.length);let s=0;for(let e=0;e<o.length;e++){const n=new Array(o[e]);for(let r=0;r<o[e];r++)n[r]=t[s].elem,s++;i[e]=n}let a="";for(let e=0;e<i.length;e++){let t="";for(let n=0;n<i[e].length;n++)t+=`${0==n?"":"-"}${i[e][n]}`;if(0!==e){const e=/(\(.\d+\))/,n=t.match(e);t=t.replace(n?.[0],""),t=`${n?n?.[0]:""}{${t}}`}else if(i.length>1){const e=0==n[r[0]].a1.bio.i&&0==n[r[0]].a1.bio.j,o=1==n[r[0]].a2.bio.i&&0==n[r[0]].a1.bio.j;e&&o&&(t+="-")}a+=t}return a}(this.mol)}getHelm(){return this.underRules?s(this.linkagesUnderRules,this.monomersUnderRules):s(this.linkages,this.monomers)}applyRules(e){const t=this.getNotation(),[n,o,r]=function(e,t){const n=[],o=[],r=[],i=t.heterodimerCode,s=t.homodimerCode,a=null!==i?e.split(`(${t.heterodimerCode})`):"";null!==i&&a.length>1?(r.push({fChain:0,sChain:1,fMonomer:1,sMonomer:1,fR:1,sR:1}),n.push(a[1].replaceAll("{","").replaceAll("}","")),n.push(a[2].replaceAll("{","").replaceAll("}","")),o.push(!1),o.push(!1)):(n.push(e),o.push(!1));for(let e=0;e<n.length;e++)if(null!==s&&n[e].includes(`(${s})`)){const t=n.length;r.push({fChain:e,sChain:t,fMonomer:1,sMonomer:1,fR:1,sR:1});const i=n[e].replace(`(${s})`,""),a=i.indexOf("{"),l=i.slice(0,a),c=i.replace(l,"").replaceAll("{","").replaceAll("}","");n[e]=l+c,n.push(c),o.push(!0)}return[r,n,o]}(t,e),i=new Array(o.length);let s=0;for(let e=0;e<o.length;e++)if(i[e]=o[e].split("-"),r[e]){const t=this.posToPosUnderRules.length-i[e].length;for(let n=0;n<i[e].length;n++)this.posToPosUnderRules[t+n].push(s),s++}else for(let t=0;t<i[e].length;t++)this.posToPosUnderRules.push([s]),s++;!function(e,t,n){for(let o=0;o<e.length;o++){const r=e[o],i=l(r,n.linkRules),[s,a,u,h]=c(n.linkRules,r,i);for(let e=0;e<s.length;e++)t.push({fChain:o,sChain:o,fMonomer:s[e],sMonomer:a[e],fR:u[e],sR:h[e]});e[o]=r}}(i,n,e),function(e,t,n){for(let o=0;o<e.length;o++){const r=l(e[o],n.reactionRules),[i,s,a]=u(n.reactionRules,e[o],r);i.length>=1&&(t.push({fChain:o,sChain:e.length,fMonomer:i[0],sMonomer:1,fR:3,sR:1}),t.push({fChain:o,sChain:e.length,fMonomer:s[0],sMonomer:1,fR:3,sR:2}),e.push([n.reactionRules[a[0]].name]))}}(i,n,e),this.underRules=!0,this.linkagesUnderRules=n,this.monomersUnderRules=i,this.molUnderRules=d(n,i,this.helmHelper)}check(e=!1){const t=[],n=this.monomers.map((e=>e.length)).reduce(((e,t)=>e+t),0);this.mol.atoms.length!==n&&t.push(`The mol atoms count ${this.mol.atoms.length} does not match the total number ${n} of chains' monomers.`);const o=this.monomers.map((e=>e.length-1)).reduce(((e,t)=>e+t),0)+this.linkages.length;this.mol.bonds.length!==o&&t.push(`The mol bonds count ${this.mol.bonds.length} does not match the total number ${o} in- and inter-chain linkages.`);let r=0;for(let e=0;e<this.monomers.length;++e){const n=this.monomers[e];for(let e=0;e<n.length;++e)try{const o=n[e],i=this.mol.atoms[r];i.bio.continuousId!==r&&t.push(`Atom #${r} has incorrect .bio.continuousId: ${i.bio.continuousId}.`),i.elem!==o&&t.push(`Atom #${r} elem: '${i.elem}' does not match chain monomer: '${o}'.`)}finally{r++}}if(e&&t.length>0)throw new Error(`Chain errors:\n${t.map((e=>` ${e}`)).join("\n")}`);return t}}},4229:(e,t,n)=>{"use strict";n.d(t,{b:()=>s});var o=n(9192),r=n(6307),i=n(9022);function s(e,t,n){const s=new Array(e.length),a=new Array(e.length),l=new Array(e.length);for(let c=0;c<e.length;c++)try{if(null==e[c])s[c]="";else{const o=r.s.fromSeparator(e[c],n);o.applyRules(t),a[c]=!(o.monomersUnderRules.length>1||o.linkagesUnderRules.length>0),s[c]=o.getHelm(),l[c]=o.posToPosUnderRules}}catch(e){const[t,n]=(0,o.AP)(e);i._package.logger.error(t,void 0,n),s[c]=""}return[s,a,l]}},2125:(e,t,n)=>{"use strict";function o(e,t){let n,o=e;for(n=0;n<t.length&&o>=t[n].length;++n)o-=t[n].length;return[o,n]}function r(e,t,n){let o=0;for(let e=0;e<t;++e)o+=n[e].length;return o+e}n.d(t,{M:()=>o,j:()=>r})},6694:(e,t,n)=>{"use strict";n.d(t,{MU:()=>V,yy:()=>j,_v:()=>J,Ln:()=>te,Q4:()=>ee});var o=n(6082),r=n(4328),i=n(7389),s=n(1991),a=n.n(s),l=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((o=o.apply(e,t||[])).next())}))};class c{constructor(e,t,n=".csv",o){this.path=e,this.userStorageName=t,this.ext=n,this.options=o,this.inputs=null,"/"!==this.path[this.path.length-1]&&(this.path+="/"),"."!==this.ext[0]&&(this.ext="."+this.ext)}getUserSettings(){return l(this,void 0,void 0,(function*(){if(this.settings)return this.settings;const e=r.userSettings.getValue(this.userStorageName,"Settings"),t=e?JSON.parse(e):{excluded:[],explicit:[]};return t.explicit=t.explicit instanceof Array?t.explicit:[],t.excluded=t.excluded instanceof Array?t.excluded:[],this.settings=t}))}setUserSettings(e){this.settings=e,r.userSettings.add(this.userStorageName,"Settings",JSON.stringify(e))}getAllAvailable(){return l(this,void 0,void 0,(function*(){return(yield r.dapi.files.list(this.path)).map((e=>e.fullPath.replace(`${this.path}`,"")))}))}getActive(){return l(this,void 0,void 0,(function*(){const e=yield this.getUserSettings();return e.explicit.length>0?e.explicit:(yield this.getAllAvailable()).filter((t=>!e.excluded.includes(t)))}))}setActive(e){const t=new Set(e);for(const[e,n]of this.inputs.entries())n.value=t.has(e)}createInput(e,t){const n=i.input.bool(e,{value:t,onValueChanged:t=>this.updateSelectionStatus(e,t)});return n.addOptions(i.button(i.iconFA("trash"),(()=>{i.dialog({title:"Warning"}).add(i.divText(`Delete file '${e}'?`)).onOK((()=>{n.root.remove(),this.availableRemove(e)})).show()}),`Delete ${e}`)),n}getInputs(){return l(this,void 0,void 0,(function*(){this.inputs=new Map;const e=yield this.getAllAvailable(),t=yield this.getActive(),n=new Array(e.length);for(let o=0;o<e.length;o++){const r=t.includes(e[o]);n[o]=this.createInput(e[o],r),this.inputs.set(e[o],n[o])}return this.fireOnValueChanged(),n}))}getForm(){return l(this,void 0,void 0,(function*(){const e=yield this.getInputs(),t=i.divV(e);return i.divV([t,i.button("ADD",(()=>l(this,void 0,void 0,(function*(){let e="";if(e=yield this.getNewAvailable(),""!==e){const n=this.createInput(e,!0);t.append(n.root),this.inputs.set(e,n),this.fireOnValueChanged()}}))))])}))}fireOnValueChanged(){var e;null===(e=this.options)||void 0===e||e.onValueChanged(a()(this.inputs.entries()).filter((([e,t])=>t.value)).map((([e,t])=>e)).toArray())}updateSelectionStatus(e,t){return l(this,void 0,void 0,(function*(){const n=yield this.getUserSettings();if(!n.excluded.includes(e)!==t){if(t){const t=n.excluded.indexOf(e);t>-1&&n.excluded.splice(t,1)}else n.excluded.push(e);this.fireOnValueChanged(),this.setUserSettings(n)}}))}availableRemove(e){return l(this,void 0,void 0,(function*(){this.inputs.delete(e),this.fireOnValueChanged();const t=yield this.getUserSettings(),n=t.excluded.indexOf(e);n>-1&&t.excluded.splice(n,1),this.setUserSettings(t),yield r.dapi.files.delete(this.path+e),r.shell.info(`File ${e} successfully deleted`)}))}getNewAvailable(){return l(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{o.Utils.openFile({accept:this.ext,open:t=>l(this,void 0,void 0,(function*(){const n=t.name,o=yield t.arrayBuffer();yield r.dapi.files.write(this.path+`${t.name}`,new Uint8Array(o)),e(n)}))})}))}))}}var u=n(9022),h=n(9124),d=n(4229),p=n(439),m=n(5174),f=n(5412),g=n(6717),y=n(8312);function b(e){let t=e.replaceAll(/\[R[1-9]\]/g,(e=>`[*:${e[2]}]`));return t=t.replaceAll(/\[\d\*\]/g,(e=>`[*:${e[1]}]`)),t.replaceAll(/\[\d\*\:\d\]/g,(e=>`[*:${e[1]}]`))}function v(e){return e.replaceAll(/\[\*\:\d\]/g,(e=>`[C:${e[3]}]`))}function C(e){return e.replaceAll(/\[C\:\d\]/g,(e=>`[*:${e[3]}]`))}function x(e,t){const n=t?.firstReactantSmiles?C(t.firstReactantSmiles):"[*:1]C",o=t?.secondReactantSmiles?C(t.secondReactantSmiles):"[*:2]C",s=t?.productSmiles?C(t.productSmiles):"[*:1]CC[*:2]",a=t?.code,l=t?.firstMonomers??[],c=t?.secondMonomers??[],u=t?.resultMonomerName??"",h=i.input.int("Code",{value:a,nullable:!1,showPlusMinus:!1,showSlider:!1,tooltipText:"Reaction code"}),d=i.input.string("First monomers",{value:l.join(","),nullable:!1,tooltipText:"Comma-separated list of monomers for the first reactant"}),p=i.input.string("Second monomers",{value:c.join(","),nullable:!1,tooltipText:"Comma-separated list of monomers for the second reactant"}),m=i.input.string("Result monomer name",{value:u,nullable:!1,tooltipText:"Name of the resulting pseudo-monomer generated by the reaction of the two reactants"}),f=i.input.molecule("First reactant",{value:n,nullable:!1,tooltipText:"Reactant fragment of first monomer(s). Use numbered R groups in correspondence with the rest of the molecule."}),g=i.input.molecule("Second reactant",{value:o,nullable:!1,tooltipText:"Reactant fragment of second monomer(s). Use numbered R groups in correspondence with the rest of the molecule."}),y=i.input.molecule("Product",{value:s,nullable:!1,tooltipText:"Product fragment of the resulting monomer from the reaction of the two reactants. Use numbered R groups in correspondence with the reactants."}),x=()=>{if(!f||!g||!y)return"Inputs not initialized yet";const e=v(b(r.chem.convert(f.value??"",r.chem.Notation.Unknown,r.chem.Notation.Smiles))),t=v(b(r.chem.convert(g.value??"",r.chem.Notation.Unknown,r.chem.Notation.Smiles))),n=v(b(r.chem.convert(y.value??"",r.chem.Notation.Unknown,r.chem.Notation.Smiles)));return e&&t&&n?-1==e.indexOf("[C:1]")?"First Reactant must contain R1-group":-1==t.indexOf("[C:2]")?"Second Reactant must contain R2-group":-1==n.indexOf("[C:1]")||-1==n.indexOf("[C:2]")?"Product must contain R1- and R2-groups":null:"First/Second Reactants and Product must all be set"};f.addValidator(x),g.addValidator(x),y.addValidator(x);const w=i.dialog(t?"Edit Reaction Rule":"Add Reaction Rule").add(h).add(m).add(d).add(p).add(f).add(g).add(y);w.addButton("Save",(()=>{const n=x();if(null!=n)return void r.shell.warning(n);const o=v(b(r.chem.convert(f.value??"",r.chem.Notation.Unknown,r.chem.Notation.Smiles))),i=v(b(r.chem.convert(g.value??"",r.chem.Notation.Unknown,r.chem.Notation.Smiles))),s=v(b(r.chem.convert(y.value??"",r.chem.Notation.Unknown,r.chem.Notation.Smiles)));e({code:h.value,resultMonomerName:m.value,firstMonomers:d.value.split(",").map((e=>e.trim())).filter((e=>e.length>0)),secondMonomers:p.value.split(",").map((e=>e.trim())).filter((e=>e.length>0)),firstReactantSmiles:o,secondReactantSmiles:i,productSmiles:s,rowIndex:t?.rowIndex}),w.close()})),w.show()}const w="Links",A="Reactions";class T{constructor(e,t){this.v=null,this.substituteReactionGridDataFrame=null,this.rules=e;const n=this.rules.getLinkRulesDf();this.linkRuleDataFrame=n.res,this.addLinkRulesFunc=n.addNewRow;const o=this.rules.getSynthesisRulesDf();this.addSynthRulesFunc=e=>{o.addNewRow(e),this.rules.setSynthesisRules(o.df),this.synthRuleDataFrame=o.df,this.substituteReactionGridDataFrame?.(),this.save()},this.synthRuleDataFrame=o.df,this.fileName=t;const r=this.rules.homodimerCode?this.rules.homodimerCode:"",s=this.rules.heterodimerCode?this.rules.heterodimerCode:"";this.homoDimerInput=i.input.string("Homo dimer",{value:r,onValueChanged:()=>{},nullable:!1}),this.heteroDimerInput=i.input.string("Hetero dimer",{value:s,onValueChanged:()=>{},nullable:!1})}async getAndAddView(){if(this.v)try{const e=Array.from(r.shell.views).find((e=>e.name===this.v.name));if(!e)throw this.v.detach(),this.v.close(),new Error("View is closed, making it null in catch statement");r.shell.v=e}catch(e){this.v=null}return this.v||(this.v=o.View.create(),this.v.name=`Manage Polytool Rules - ${this.fileName}`,this.v.append(await this.getForm()),this.v=r.shell.addView(this.v),r.shell.v=this.v),this.v}static async getInstance(e){if(!this.instances[e]){const t=await ee([e]);this.instances[e]=new T(t,e)}return this.instances[e]}save(){this.rules.homodimerCode=this.homoDimerInput.value,this.rules.heterodimerCode=this.heteroDimerInput.value,this.rules.setLinkRules(this.linkRuleDataFrame),this.rules.setSynthesisRules(this.synthRuleDataFrame);const e={homodimerCode:this.rules.homodimerCode,heterodimerCode:this.rules.heterodimerCode,linkRules:this.rules.linkRules,reactionRules:this.rules.reactionRules},t=JSON.stringify(e,void 0,2);u._package.files.writeAsText(`polytool-rules/${this.fileName}`,t),r.shell.info(`Polytool rules at ${this.fileName} was updated`)}createGridDiv(e,t,n){const o=i.h1(e,"polytool-grid-header");i.tooltip.bind(o,n),o.style.marginTop="10px",o.style.marginRight="10px",t.root.style.height="100%";const r=i.splitV([i.box(o,{style:{maxHeight:"60px"}}),t.root]);return r.style.height="100%",r}async getLinkExamplesGrid(){const e=[];for(let t=0;t<this.rules.linkRules.length;t++){const n=this.rules.linkRules[t].code,[o,r]=te(this.rules.linkRules[t]);for(let t=0;t<o.length;t++){const i=`${o[t]}(${n})-A-A-A-A-${r[t]}(${n})`;e.push(i)}}const t=await(0,h.b2)(),[n,r,i]=(0,d.b)(e,this.rules,t),s=o.Column.fromStrings("Monomers",e),a=o.Column.fromStrings("Helm",n);return u.PackageFunctions.applyNotationProviderForCyclized(s,"-"),s.semType=o.SEMTYPE.MACROMOLECULE,a.semType=o.SEMTYPE.MACROMOLECULE,a.meta.units=p.Hi.HELM,a.setTag(o.TAGS.CELL_RENDERER,"helm"),o.DataFrame.fromColumns([s,a]).plot.grid()}async getReactionExamplesGrid(){const e=[];for(let t=0;t<this.rules.reactionRules.length;t++){const n=this.rules.reactionRules[t].code,[o,r]=te(this.rules.reactionRules[t]);for(let t=0;t<o.length;t++){const i=`${o[t]}(${n})-A-A-A-A-${r[t]}(${n})`;e.push(i)}}const t=await(0,h.b2)(),[n,r,i]=(0,d.b)(e,this.rules,t),s=o.Column.fromStrings("Monomers",e),a=o.Column.fromStrings("Helm",n),l=o.DataFrame.fromColumns([s,a]);s.semType=o.SEMTYPE.MACROMOLECULE;const c=await(0,g.j)(),b=await(0,y.Q)();u.PackageFunctions.applyNotationProviderForCyclized(s,"-"),s.tags[o.TAGS.CELL_RENDERER]="Sequence",a.semType=o.SEMTYPE.MACROMOLECULE,a.meta.units=p.Hi.HELM,a.setTag(o.TAGS.CELL_RENDERER,"helm");const v=await(0,m.A)(this.rules),C=a.temp;C[".mm.cellRenderer.overriddenLibrary"]=v,a.temp=C;const x=await(0,f.m)(a,e,r,!0,!1,!1,v,c,b);return x.name="molfile(sequence)",x.semType=o.SEMTYPE.MOLECULE,l.columns.add(x),l.plot.grid()}async getForm(){const e=this.linkRuleDataFrame.plot.grid({showAddNewRowIcon:!1,allowEdit:!1,rowHeight:60});e.onCellDoubleClick.subscribe((()=>{if(!e.dataFrame||-1==e.dataFrame.currentRowIdx||null==e.dataFrame.currentRowIdx)return;const t=e.dataFrame.currentRowIdx,n={row:t,code:this.linkRuleDataFrame.get("code",t),firstMonomers:this.linkRuleDataFrame.get("firstMonomers",t),secondMonomers:this.linkRuleDataFrame.get("secondMonomers",t),firstLinkingGroup:this.linkRuleDataFrame.get("firstLinkingGroup",t),secondLinkingGroup:this.linkRuleDataFrame.get("secondLinkingGroup",t)};this.getAddNewLinkRuleDialog(n)}));const t=this.createGridDiv("Rules",e,"specification for monomers to link and linking positions"),n=this.createGridDiv("Examples",await this.getLinkExamplesGrid(),"specification for monomers to link and linking positions");t.style.width="50%",n.style.width="50%";const o=i.h1("Monomers","polytool-grid-header");i.tooltip.bind(o,"Click different cobination to see how monomers will link"),this.linkCards=await this.rules.getLinkCards();const r=i.splitV([i.box(o,{style:{maxHeight:"30px"}}),this.linkCards[0].root]);this.linkCards[0].render(),await this.linkCards[0].reset(),this.linkRuleDataFrame.currentRowIdx=0,this.linkRuleDataFrame.onCurrentRowChanged.subscribe((async()=>{const e=this.linkRuleDataFrame.currentRowIdx;-1!==e&&null!=e&&(i.empty(r),r.append(i.splitV([i.box(o,{style:{maxHeight:"30px"}}),this.linkCards[e].root])),this.linkCards[e].render(),await this.linkCards[e].reset())}));const s=i.splitH([t,r],null,!0),a=this.synthRuleDataFrame.plot.grid({showAddNewRowIcon:!1,allowEdit:!1,rowHeight:130});a.onCellDoubleClick.subscribe((()=>{if(!a.dataFrame||-1==a.dataFrame.currentRowIdx||null==a.dataFrame.currentRowIdx)return;const e=a.dataFrame.currentRowIdx;x((e=>this.addSynthRulesFunc(e)),{rowIndex:e,code:this.synthRuleDataFrame.get("code",e),firstMonomers:this.synthRuleDataFrame.get("firstMonomers",e).split(",").map((e=>e.trim())).filter((e=>e)),secondMonomers:this.synthRuleDataFrame.get("secondMonomers",e).split(",").map((e=>e.trim())).filter((e=>e)),resultMonomerName:this.synthRuleDataFrame.get("name",e),firstReactantSmiles:this.synthRuleDataFrame.get("firstReactant",e),secondReactantSmiles:this.synthRuleDataFrame.get("secondReactant",e),productSmiles:this.synthRuleDataFrame.get("product",e)})}));const l=this.createGridDiv("Rules",a),c=await this.getReactionExamplesGrid(),u=this.createGridDiv("Examples",c);this.substituteReactionGridDataFrame=async()=>{const e=await this.getReactionExamplesGrid();c.dataFrame=e.dataFrame},l.style.width="50%",u.style.width="50%";const h=i.divH([l,u]),d=i.divV([this.homoDimerInput,this.heteroDimerInput]),p=i.tabControl({Links:s,Reactions:h,Dimers:d},!1);i.tooltip.bind(p.getPane(w).header,"Specify rules to link monomers based on HELM notation"),i.tooltip.bind(p.getPane(A).header,"Specify rules to perform reactions within monomers"),i.tooltip.bind(p.getPane("Dimers").header,"Specify symbols for homodimeric and heterodimeric codes"),p.root.style.height="100%",p.root.style.width="100%",p.root.classList.add("rules-manager-form-tab-control"),p.header.style.marginBottom="10px";const m=i.divV([p.root]),f=[i.bigButton("Save",(()=>{this.save()})),i.button("Add rule",(()=>{const e=p.currentPane.name;e==w?this.getAddNewLinkRuleDialog():e==A&&x((e=>this.addSynthRulesFunc(e)))})),i.button("Remove rule",(()=>{const t=p.currentPane.name;if(t==w){if(null==this.linkRuleDataFrame||-1==this.linkRuleDataFrame.currentRowIdx||null==this.linkRuleDataFrame.currentRowIdx)return;const t=e.dataFrame.currentRowIdx;i.dialog("Are you sure you want to remove the rule?").add(i.divText("This action is irreversible!")).onOK((()=>{this.linkRuleDataFrame.rows.removeAt(t),this.rules.setLinkRules(this.linkRuleDataFrame),this.save()})).show()}else if(t==A){if(null==this.synthRuleDataFrame||-1==this.synthRuleDataFrame.currentRowIdx||null==this.synthRuleDataFrame.currentRowIdx)return;const e=a.dataFrame.currentRowIdx;i.dialog("Are you sure you want to remove the rule?").add(i.divText("This action is irreversible!")).onOK((()=>{this.synthRuleDataFrame.rows.removeAt(e),this.rules.setSynthesisRules(this.synthRuleDataFrame),this.substituteReactionGridDataFrame?.(),this.save()})).show()}}))];return this.v.setRibbonPanels([f]),m.style.height="100%",m.style.alignItems="center",p.root}getAddNewLinkRuleDialog(e){const t=i.input.int("Code",{nullable:!1,value:e?.code}),n=i.input.string("First monomers",{placeholder:"E.g. C,D,E",value:e?.firstMonomers,tooltipText:"Comma separated list of first monomers applicable for the rule. If left empty, all monomers will be considered",nullable:!0}),o=i.input.string("Second monomers",{placeholder:"E.g. C,D,E",value:e?.secondMonomers,tooltipText:"Comma separated list of second monomers applicable for the rule. If left empty, all monomers will be considered",nullable:!0}),r=e?.firstLinkingGroup?`R${e.firstLinkingGroup}`:"R3",s=e?.secondLinkingGroup?`R${e.secondLinkingGroup}`:"R3",a=i.input.choice("First linking group",{value:r,items:["R1","R2","R3","R4"],tooltipText:"Specifies which R-group of the first monomer will be used for linking",nullable:!1}),l=i.input.choice("Second linking group",{value:s,items:["R1","R2","R3","R4"],tooltipText:"Specifies which R-group of the second monomer will be used for linking",nullable:!1});i.dialog("Add new link rule").add(t).add(n).add(o).add(a).add(l).onOK((async()=>{const r=t.value,i=(n.value??"").split(",").map((e=>e.trim())).filter((e=>e)).join(","),s=(o.value??"").split(",").map((e=>e.trim())).filter((e=>e)).join(","),c=parseInt(a.value.substring(1)),u=parseInt(l.value.substring(1));this.addLinkRulesFunc({code:r,firstMonomers:i??"",secondMonomers:s??"",firstLinkingGroup:c,secondLinkingGroup:u,row:e?.row}),this.rules.setLinkRules(this.linkRuleDataFrame),this.linkCards=await this.rules.getLinkCards(),this.save()})).show()}}T.instances={};var E=n(5072),S=n.n(E),N=n(7825),I=n.n(N),M=n(7659),P=n.n(M),_=n(5056),L=n.n(_),O=n(540),R=n.n(O),$=n(1113),D=n.n($),B=n(890),F={};F.styleTagTransform=D(),F.setAttributes=L(),F.insert=P().bind(null,"head"),F.domAPI=I(),F.insertStyleElement=R(),S()(B.A,F),B.A&&B.A.locals&&B.A.locals;var k=n(2003);class H{get selected(){return this._selected}set selected(e){this._selected=e,this.root.style.border=e?"2px solid var(--green-2)":"2px solid var(--grey-2)"}constructor(e,t){this.monomer=e,this.monomerSymbol=t,this.root=i.divV([],{classes:"monomer-card-rule-root"}),this._selected=!1}render(){if(i.empty(this.root),this.root.appendChild(i.h2(this.monomerSymbol,{style:{textAlign:"center"}})),this.monomer){const e=this.monomer.smiles&&r.chem.checkSmiles(this.monomer.smiles)?r.chem.drawMolecule(this.monomer.smiles,150,120):r.chem.drawMolecule(this.monomer.molfile??"",150,120);this.root.appendChild(e);const t=i.divH([i.divText("Monomer Name: "),i.divText(this.monomer.name)],{classes:"monomer-card-info-rules"});if(this.root.appendChild(t),i.tooltip.bind(t,this.monomer.name),this.monomer.lib?.source){const e=i.divH([i.divText("Source: "),i.divText(this.monomer.lib.source)],{classes:"monomer-card-info-rules"});this.root.appendChild(e),i.tooltip.bind(e,this.monomer.lib.source)}const n=i.divH([i.divText("Polymer Type: "),i.divText(this.monomer.polymerType)],{classes:"monomer-card-info-rules"});this.root.appendChild(n),i.tooltip.bind(n,this.monomer.polymerType),i.tooltip.bind(this.root,"Select Monomer")}else this.root.appendChild(i.divV([`Monomer ${this.monomerSymbol} not found in libraries`],{style:{textAlign:"center",height:"100%"}}))}}class G{constructor(e,t,n,o,r){this.firstMonomers=e,this.secondMonomers=t,this.code=o,this.rules=r,this.root=i.divH([],{style:{width:"100%",overflow:"hidden",visibility:"visible"},classes:"monomer-cards"});const s=!e?.length,a=!t?.length;s&&(this.firstMonomers=e=["C","D","E","F","G"]),a&&(this.secondMonomers=t=["D","C","E","F","G"]),this.actionable=!0;const l=i.divH([],{style:{overflowX:"auto",width:"100%"}}),c=i.divH([],{style:{overflowX:"auto",width:"100%"}});this.resulting=i.divH([],{style:{overflowX:"auto",width:"100%",minHeight:"150px"}});const u=i.h2("First Monomer"+(s?" (Applied to all monomers, example list shown)":""),{style:{width:"100%"}}),h=i.h2("Second Monomer"+(a?" (Applied to all monomers, example list shown)":""),{style:{width:"100%"}}),d=i.divV([u,l,h,c,this.resulting]);this.cardsFirst=e.map((e=>new H(n.getMonomer("PEPTIDE",e),e))),this.cardsSecond=t.map((e=>new H(n.getMonomer("PEPTIDE",e),e))),this.cardsFirst.forEach((e=>{e.root.onclick=()=>{this.cardsFirst.forEach((e=>e.selected=!1)),e.selected=!0,this.firstCard=e,this.reset()},l.appendChild(e.root)})),this.cardsSecond.forEach((e=>{e.root.onclick=()=>{this.cardsSecond.forEach((e=>e.selected=!1)),e.selected=!0,this.secondCard=e,this.reset()},c.appendChild(e.root)})),this.cardsFirst[0].selected=!0,this.cardsSecond[0].selected=!0,this.firstCard=this.cardsFirst[0],this.secondCard=this.cardsSecond[0],this.root.appendChild(d)}async reset(){if(this.actionable){const e=[`${this.firstCard.monomer?.symbol}(${this.code})-A-A-A-A-${this.secondCard.monomer?.symbol}(${this.code})`],t=await(0,h.b2)(),[n,s,a]=(0,d.b)(e,this.rules,t),l=o.Column.fromType(o.COLUMN_TYPE.STRING,"helm",n.length).init((e=>n[e]));l.semType=o.SEMTYPE.MACROMOLECULE,l.meta.units=k.Hi.HELM,l.setTag(o.TAGS.CELL_RENDERER,"helm");const c=await(0,g.j)(),u=await(0,y.Q)(),p=await(0,m.A)(this.rules),b=l.temp;l.temp=b;const v=(await(0,f.m)(l,n,s,!0,!1,!1,p,c,u)).get(0),C=v&&r.chem.checkSmiles(v)?r.chem.drawMolecule(v,200,200):r.chem.drawMolecule(v??"",200,200);v&&(C.style.cursor="pointer",C.onclick=()=>{const e=window.innerWidth-200,t=window.innerHeight-200,n=r.chem.checkSmiles(v)?r.chem.drawMolecule(v,e,t):r.chem.drawMolecule(v??"",e,t);i.dialog({title:"Molecule"}).add(n).showModal(!0)},i.tooltip.bind(C,"Click to expand"));const x=i.divV([i.h2("Example Result:"),i.h2(e[0])],{style:{width:"200px"}});i.empty(this.resulting),this.resulting.append(i.divH([x,C],{style:{overflowX:"auto",width:"100%",minHeight:"150px"}}))}}render(){this.actionable&&(this.cardsFirst.forEach((e=>e.render())),this.cardsSecond.forEach((e=>e.render())))}}var U=n(4971);const V="System:AppData/SequenceTranslator/polytool-rules/",j="Polytool",q="code",W="firstMonomers",z="secondMonomers",Y="name",K="firstLinkingGroup",Q="secondLinkingGroup";class J extends c{constructor(e,t,n,o){super(e,t,n,o)}createInput(e,t){const n=super.createInput(e,t),r=i.icons.edit((async()=>{const t=await T.getInstance(e);o.Dialog.getOpenDialogs()?.filter((e=>e.root.contains(r))).forEach((e=>e.close())),await t.getAndAddView()}),"Edit rules");return n.addOptions(r),n}async getForm(){const e=await super.getForm();return this.processRulesForm(e),e}async processRulesForm(e){const t=Array.from(e.getElementsByTagName("label")??[]).filter((e=>e.textContent?.endsWith(".json")&&null!=e.parentElement));for(const e of t){const t=e.textContent.trim(),n=e.parentElement.getElementsByTagName("input")[0];i.tooltip.bind(n,i.wait((async()=>{var e;return(e=J.ruleDescriptions)[t]??(e[t]=(async()=>{try{const e=JSON.parse(await r.dapi.files.readAsText(`${V}/${t}`)),n=i.divV([i.h1(t)]),o=e.linkRules??[];if(o.length>0){n.appendChild(i.h3("Linkage Rules"));const e=i.table(o,(e=>[e.code?.toString()??"",X((e.firstMonomers??[]).join(", ")),X((e.secondMonomers??[]).join(", ")),e.firstLinkingGroup?.toString()??"",e.secondLinkingGroup?.toString()??""]),["Code","M1","M2","L1","L2"]);n.appendChild(e)}const s=e.reactionRules??[];if(s.length>0){n.appendChild(i.h3("Synthesis Rules"));const e=i.table(s,(e=>[e.code?.toString()??"",X((e.firstMonomers??[]).join(", ")),X((e.secondMonomers??[]).join(", ")),X(e.name??""),r.chem.drawMolecule(e.reaction?.split(">>")[1]??"",70,70)]),["Code","M1","M2","Name","Product"]);n.appendChild(e)}return n}catch(e){return u._package.logger.error(`Failed to load rule ${t}: ${e?.toString?.()}`),console.error(e),i.divText(`Failed to load rule ${t}`)}})()),await J.ruleDescriptions[t]})))}}}function X(e,t=30){return e.length<=t?e:`${e.substring(0,t)}...`}J.ruleDescriptions={};class Z{constructor(e,t,n,o){this.homodimerCode=e,this.heterodimerCode=t,this.linkRules=n,this.reactionRules=o}set homodimer(e){this.homodimerCode=e}set heterodimer(e){this.heterodimerCode=e}addLinkRules(e){for(let t=0;t<e.length;t++)this.linkRules.push(e[t])}addSynthesisRules(e){for(let t=0;t<e.length;t++)this.reactionRules.push(e[t])}getLinkRulesDf(){const e=this.linkRules.length,t=o.Column.int(q,e);t.setTag("friendlyName","Code");const n=o.Column.string(W,e);n.temp[".mm.cellRenderer.fontSize"]=16,n.setTag("friendlyName","First monomers"),n.semType=o.SEMTYPE.MACROMOLECULE,u.PackageFunctions.applyNotationProviderForCyclized(n,",");const r=o.Column.string(z,e);r.setTag("friendlyName","Second monomers"),r.temp[".mm.cellRenderer.fontSize"]=16,r.semType=o.SEMTYPE.MACROMOLECULE,u.PackageFunctions.applyNotationProviderForCyclized(r,",");const i=o.Column.int(K,e);i.setTag("friendlyName","First group");const s=o.Column.int(Q,e);s.setTag("friendlyName","Second group");for(let o=0;o<e;o++)t.set(o,this.linkRules[o].code),n.set(o,this.linkRules[o].firstMonomers.toString()),r.set(o,this.linkRules[o].secondMonomers.toString()),i.set(o,this.linkRules[o].firstLinkingGroup),s.set(o,this.linkRules[o].secondLinkingGroup);const a=o.DataFrame.fromColumns([t,n,r,i,s]);return{res:a,addNewRow:e=>{if(null!=e.row&&e.row<a.rowCount&&e.row>=0)t.set(e.row,e.code),n.set(e.row,e.firstMonomers),r.set(e.row,e.secondMonomers),i.set(e.row,e.firstLinkingGroup),s.set(e.row,e.secondLinkingGroup);else{const{code:t,firstMonomers:n,secondMonomers:o,firstLinkingGroup:r,secondLinkingGroup:i}=e;a.rows.addNew([t,n??"",o??"",r??1,i??2])}}}}async getLinkCards(){const e=this.linkRules.length,t=new Array(e),n=(await(0,U.pj)()).getMonomerLib();for(let o=0;o<e;o++)t[o]=new G(this.linkRules[o].firstMonomers,this.linkRules[o].secondMonomers,n,this.linkRules[o].code,this);return t}getSynthesisRulesDf(){const e=this.reactionRules.length,t=o.Column.int(q,e);t.setTag("friendlyName","Code");const n=o.Column.string(W,e);n.setTag("friendlyName","First monomers");const r=o.Column.string(z,e);r.setTag("friendlyName","Second monomers"),n.semType=o.SEMTYPE.MACROMOLECULE,n.temp[".mm.cellRenderer.fontSize"]=16,u.PackageFunctions.applyNotationProviderForCyclized(n,","),r.semType=o.SEMTYPE.MACROMOLECULE,r.temp[".mm.cellRenderer.fontSize"]=16,u.PackageFunctions.applyNotationProviderForCyclized(r,","),r.setTag(o.TAGS.CELL_RENDERER,"Sequence"),n.setTag(o.TAGS.CELL_RENDERER,"Sequence");const i=o.Column.string(Y,e);i.setTag("friendlyName","Name");const s=o.Column.string("firstReactant",e);s.setTag("friendlyName","First reactant");const a=o.Column.string("secondReactant",e);a.setTag("friendlyName","Second reactant");const l=o.Column.string("product",e);l.setTag("friendlyName","Product");for(let o=0;o<e;o++){t.set(o,this.reactionRules[o].code),n.set(o,this.reactionRules[o].firstMonomers.toString()),r.set(o,this.reactionRules[o].secondMonomers.toString()),i.set(o,this.reactionRules[o].name);const e=this.reactionRules[o].reaction.split(">>"),c=e[0].split(".");s.set(o,c[0]),a.set(o,c[1]),l.set(o,e[1])}s.semType=o.SEMTYPE.MOLECULE,a.semType=o.SEMTYPE.MOLECULE,l.semType=o.SEMTYPE.MOLECULE;const c=o.DataFrame.fromColumns([i,s,a,l,t,n,r]);return{df:c,addNewRow:e=>{if(null!=e.rowIndex&&e.rowIndex<c.rowCount&&e.rowIndex>=0)i.set(e.rowIndex,e.resultMonomerName),t.set(e.rowIndex,e.code),n.set(e.rowIndex,e.firstMonomers.join(",")),r.set(e.rowIndex,e.secondMonomers.join(",")),s.set(e.rowIndex,e.firstReactantSmiles),a.set(e.rowIndex,e.secondReactantSmiles),l.set(e.rowIndex,e.productSmiles);else{const{resultMonomerName:t,code:n,firstMonomers:o,secondMonomers:r,firstReactantSmiles:i,secondReactantSmiles:s,productSmiles:a}=e;c.rows.addNew([t,i,s,a,n,o.join(","),r.join(",")])}}}}setLinkRules(e){const t=e.rowCount,n=new Array(t),o=e.columns.byName(q),r=e.columns.byName(W),i=e.columns.byName(z),s=e.columns.byName(K),a=e.columns.byName(Q);for(let e=0;e<t;e++){const t=r.get(e).split(","),l=i.get(e).split(","),c={code:o.get(e),firstMonomers:""!==t[0]?t:[],secondMonomers:""!==l[0]?l:[],firstLinkingGroup:s.get(e),secondLinkingGroup:a.get(e)};n[e]=c}this.linkRules=n}setSynthesisRules(e){const t=e.rowCount,n=new Array(t),o=e.columns.byName(q),r=e.columns.byName(W),i=e.columns.byName(z),s=e.columns.byName(Y),a=e.columns.byName("firstReactant"),l=e.columns.byName("secondReactant"),c=e.columns.byName("product");for(let e=0;e<t;e++){const t=`${a.get(e)}.${l.get(e)}>>${c.get(e)}`,u=r.get(e).split(","),h=i.get(e).split(","),d={code:o.get(e),firstMonomers:""!==u[0]?u:[],secondMonomers:""!==h[0]?h:[],reaction:t,name:s.get(e)};n[e]=d}this.reactionRules=n}}async function ee(e){const t=new o.FileSource(V),n=new Z(null,null,[],[]);for(let o=0;o<e.length;o++){const r=await t.readAsText(e[o].replace(V,"")),i=JSON.parse(r);n.homodimer=i.homodimerCode,n.heterodimer=i.heterodimerCode,n.addLinkRules(i.linkRules),n.addSynthesisRules(i.reactionRules)}return n}function te(e){const t=e.firstMonomers.length*e.secondMonomers.length,n=new Array(t),o=new Array(t);let r=0;for(let t=0;t<e.firstMonomers.length;t++)for(let i=0;i<e.secondMonomers.length;i++)n[r]=e.firstMonomers[t],o[r]=e.secondMonomers[i],r++;return[n,o]}},5174:(e,t,n)=>{"use strict";n.d(t,{A:()=>u,T:()=>h});var o=n(6717),r=n(1296),i=n(9192),s=n(4328),a=n(1991),l=n.n(a),c=n(4971);async function u(e){const t=(await(0,c.pj)()).getMonomerLib(),n=await(0,o.j)(),r={};let i=[],a=[];for(let o=0;o<e.reactionRules.length;o++)try{[i,a]=h(n,t,e.reactionRules[o])}catch(e){i=[],a=[],console.error(e),s.shell.warning(e)}finally{for(let e=0;e<i.length;e++)null!=i[e]&&null!=a[e]&&(r[i[e]]=a[e])}const u={PEPTIDE:r};return t.override(u,"ST-PT-reactions."+l().repeat(1).map((()=>Math.floor(36*Math.random()).toString(36))).take(4).toArray().join(""))}function h(e,t,n){const o=n.reaction,r=n.name,s=n.firstMonomers.length+n.secondMonomers.length+1,a=n.reaction.split(">>"),l=a[0].split("."),c=new Array(s),u=new Array(s),h=new Array(s),f=p(e,o),g=`${l[0]}>>[C:1]C`,y=`${l[1]}>>[C:2]C`,b=p(e,g),v=p(e,y);let C=0;for(let o=0;o<n.firstMonomers.length;o++){const i=t.getMonomer("PEPTIDE",n.firstMonomers[o]);if(i&&i.molfile)try{const t=d(e,i.molfile,b,i.name);h[C]=t,c[C]=`${i.symbol}_${r}`}catch(e){console.error(e)}C++}for(let o=0;o<n.secondMonomers.length;o++){const i=t.getMonomer("PEPTIDE",n.secondMonomers[o]);if(i&&i.molfile)try{const t=d(e,i.molfile,v,i.name);h[C]=t,c[C]=`${i.symbol}_${r}`}catch(e){console.error(e)}C++}let x=null;a[1]=a[1].replace("[C:1]","[1*]").replace("[C:2]","[2*]").replace("[C:3]","[3*]");let w="";try{x=e.get_mol(a[1]),w=x?.get_molblock()}catch(e){const[t,n]=(0,i.AP)(e);throw console.error(`Can not assemble monomer '${r}': ${t}.`),e}finally{x?.delete()}h[C]=w,c[C]=r;for(let e=0;e<s-1;e++)h[e]&&(h[e]=h[e].replace(" 0.0000 0.0000 0.0000 C "," 0.0000 0.0000 0.0000 R# ").replace("M RGP 2","M RGP 3 2 3"));h[s-1]=function(e){const t=e.replace("M RAD","M RGP").replace("M ISO","M RGP").split("\n"),n=t.findIndex((e=>e.startsWith("M RGP"))),o=Number(t[n].substring(9,13)),r=Number(t[n].substring(17,21)),i=Number(t[n].substring(13,17)),s=Number(t[n].substring(21,25));t[n]=t[n].substring(0,13)+` ${i}`+t[n].substring(17,21)+` ${s}`,t[3+o]=t[3+o].substring(0,30)+" R# 0 0 0 0 0 0 0 0 0 0 0 0",t[3+r]=t[3+r].substring(0,30)+" R# 0 0 0 0 0 0 0 0 0 0 0 0";let a="";for(let e=0;e<t.length;e++)a+=t[e]+"\n";return a}(h[s-1]);for(let e=0;e<s;e++){const t=e==s-1;if(!h[e]||!c[e])continue;const n={symbol:c[e],name:c[e],molfile:h[e],author:"",id:0,rgroups:m(t),smiles:"",polymerType:"PEPTIDE",monomerType:"Backbone",createDate:null};n.meta=Object.assign(n.meta??{},{colors:{default:{line:"#2083D5",text:"#2083D5",background:"#F2F2F5"}}}),c[e]=c[e],u[e]=n}return f.delete(),b.delete(),v.delete(),[c,u]}function d(e,t,n,o){let r=null,s=null,a=null,l=null,c="";try{r=new e.MolList,s=e.get_mol(t),r.append(s),a=n.run_reactants(r,1),l=a.get(0).next(),c=l?.get_molblock()}catch(e){const[t,n]=(0,i.AP)(e);throw console.error(`Can not assemble monomer '${o}': ${t}.`),e}finally{r?.delete(),s?.delete(),a?.delete(),l?.delete()}return c}function p(e,t){let n=null;try{if(n=e.get_rxn(t),!n)throw new r.J5(t)}catch(e){n?.delete();const[o,r]=(0,i.AP)(e);throw console.error(`Can not assemble monomer '${t}': ${o}.`),e}return n}function m(e){if(e){const e=new Array(2),t={capGroupSMILES:"[*:1][H]",alternateId:"R1-H",capGroupName:"H",label:"R1"},n={capGroupSMILES:"[*:2][H]",alternateId:"R2-H",capGroupName:"H",label:"R2"};return e[0]=t,e[1]=n,e}return[{capGroupSMILES:"[*:3][H]",alternateId:"R3-H",capGroupName:"H",label:"R3"}]}},3309:(e,t,n)=>{"use strict";n.d(t,{BG:()=>y,HL:()=>A,Ii:()=>C,KS:()=>h,PI:()=>r,Qk:()=>c,XB:()=>f,ah:()=>d,aj:()=>u,j7:()=>l,jp:()=>T,k5:()=>m,u8:()=>o,xD:()=>E,yw:()=>v,z9:()=>b});const o=1e6,r={Zip:"Zip",Cartesian:"Cartesian"},i=String.raw`\[(?:(\d+)\*|\*:(\d+)|\*(\d+)|R(\d+)|R:(\d+))\]`;function s(){return new RegExp(i,"g")}function a(e){for(const t of e)if(void 0!==t)return parseInt(t,10);return null}function l(e){return e.replace(s(),((e,t,n,o,r,i)=>{const s=a([t,n,o,r,i]);return null===s?e:`[*:${s}]`}))}function c(e){const t=new Set;for(const n of e.matchAll(s())){const e=a([n[1],n[2],n[3],n[4],n[5]]);null!==e&&t.add(e)}return[...t].sort(((e,t)=>e-t))}function u(e,t){return e.replace(s(),(()=>`[*:${t}]`))}function h(e,t,n){const o=(e??"").trim();if(""===o)return{smiles:"",originalSmiles:e,rNumbers:[],id:t,error:"Empty SMILES"};const r=l(o),i=c(r);if(0===i.length)return{smiles:r,originalSmiles:e,rNumbers:i,id:t,error:"Core must contain at least one R group"};if(n){const o=p(r,n);if(o)return{smiles:r,originalSmiles:e,rNumbers:i,id:t,error:`Invalid SMILES: ${o}`}}return{smiles:r,originalSmiles:e,rNumbers:i,id:t}}function d(e,t,n,o){const r=(e??"").trim();if(""===r)return{smiles:"",originalSmiles:e,rNumber:t,id:n,error:"Empty SMILES"};const i=l(r),s=c(i);if(0===s.length)return{smiles:i,originalSmiles:e,rNumber:t,id:n,error:"R-group must contain exactly one R label (found none)"};if(s.length>1)return{smiles:i,originalSmiles:e,rNumber:t,id:n,sourceRNumber:s[0],error:`R-group must contain exactly one R label (found ${s.length}: ${s.map((e=>"R"+e)).join(", ")})`};const a=s[0],h=u(i,t);if(o){const r=p(h,o);if(r)return{smiles:h,originalSmiles:e,rNumber:t,id:n,sourceRNumber:a,error:`Invalid SMILES: ${r}`}}return{smiles:h,originalSmiles:e,rNumber:t,id:n,sourceRNumber:a}}function p(e,t){let n=null;try{return n=t.get_mol(e),n&&n.is_valid()?null:"failed to parse"}catch(e){return(e?.message??String(e)).toString().slice(0,120)}finally{n?.delete()}}function m(e,t,n){const o=[],i=[];for(const n of e.rNumbers){const e=t.get(n);e&&0!==e.length?i.push(e.filter((e=>!e.error)).length):o.push(n)}if(o.length>0)return{count:0,uncovered:o};if(i.some((e=>0===e)))return{count:0,uncovered:o};if(n===r.Zip){if(0===i.length)return{count:0,uncovered:o};const e=i[0];return{count:i.every((t=>t===e))?e:-1,uncovered:o}}return{count:i.reduce(((e,t)=>e*t),1),uncovered:o}}function f(e){const t=e.maxResults??o,n=[];let i=0;const s=e.cores.filter((e=>!e.error));0===s.length&&n.push("No valid cores provided.");const a=new Set;for(const e of s)for(const t of e.rNumbers)a.add(t);const l=new Map;for(const t of a){const o=(e.rGroups.get(t)??[]).filter((e=>!e.error)).length;l.set(t,o),0===o&&n.push(`No valid R-group provided for R${t}.`)}if(e.mode===r.Zip){const e=[...l.values()].filter((e=>e>0));e.length>1&&!e.every((t=>t===e[0]))&&n.push(`Zip mode requires every R-group list to have the same number of entries. Got ${[...l.entries()].map((([e,t])=>`R${e}=${t}`)).join(", ")}.`)}for(const o of s){const{count:r,uncovered:s}=m(o,e.rGroups,e.mode);if(s.length>0)n.push(`Core "${o.id}" references uncovered R-number${s.length>1?"s":""}: ${s.map((e=>"R"+e)).join(", ")}.`);else if(!(r<0)&&(i+=r,i>t))break}const c=i>t;return c&&n.push(`Too many combinations (> ${t.toLocaleString()}). Reduce the number of cores or R-groups, or switch to Zip mode.`),{ok:0===n.length,errors:n,predictedCount:i,overCap:c}}function g(e,t){if(0===t.size)return null;const n=b(e),o=new Map;for(const[e,n]of t)o.set(e,b(n));const r=C([n,...o.values()],t.size);if(r.length<t.size)return null;const i=new Map;let s=0;for(const e of t.keys())i.set(e,x(r[s++]));let a=n;for(const[e,t]of i)a=v(a,e,t);const l=[];for(const[e,t]of o)l.push(v(t,e,i.get(e)));return[a,...l].join(".")}function y(e,t,n){const o=g(e,t);if(!o)return null;let r=null;try{return r=n.get_mol(o),r&&r.is_valid()?r.get_smiles():null}catch{return null}finally{r?.delete()}}function b(e){const t=e.match(/^(\[\*:\d+\])([-=#:/\\])?(\[[^\]]+\]|Br|Cl|[BCNOPSFIbcnops])(.*)$/s);if(!t)return e;const[,n,o,r,i]=t;return`${r}(${o??""}${n})${i}`}function v(e,t,n){const o=`[*:${t}]`,r=new RegExp(`\\(\\s*\\[\\*:${t}\\]\\s*\\)`,"g");return(e=e.replace(r,n)).split(o).join(n)}function C(e,t){const n=new Set;for(const t of e){const e=t.replace(/\[[^\]]*\]/g,"");for(const t of e.matchAll(/%(\d{2})/g))n.add(parseInt(t[1],10));for(const t of e){const e=t.charCodeAt(0)-48;e>=0&&e<=9&&n.add(e)}}const o=[];for(let e=1;e<100&&o.length<t;e++)n.has(e)||o.push(e);return o}function x(e){if(e<0||e>99)throw new Error(`Ring digit out of range: ${e}`);return e<=9?`${e}`:`%${e.toString().padStart(2,"0")}`}function*w(e){const t=e.maxResults??o;let n=0;for(const o of e.cores){if(o.error)continue;const i=o.rNumbers,s=[];let a=!1;for(const t of i){const n=(e.rGroups.get(t)??[]).filter((e=>!e.error));if(0===n.length){a=!0;break}s.push(n)}if(!a)if(e.mode===r.Zip){if(0===s.length)continue;const e=s[0].length;if(!s.every((t=>t.length===e)))continue;for(let r=0;r<e;r++){const e=new Map;for(let t=0;t<i.length;t++)e.set(i[t],s[t][r]);if(yield{core:o,assignment:e},++n>=t)return}}else{const e=new Array(s.length).fill(0);for(;;){const r=new Map;for(let t=0;t<i.length;t++)r.set(i[t],s[t][e[t]]);if(yield{core:o,assignment:r},++n>=t)return;let a=e.length-1;for(;a>=0&&(e[a]++,!(e[a]<s[a].length));)e[a]=0,a--;if(a<0)break}}}}function A(e,t){if(!f(e).ok)return null;const n=[];for(const{core:o,assignment:r}of w(e)){const e=new Map;for(const[t,n]of r)e.set(t,n.smiles);const i=y(o.smiles,e,t);if(!i)continue;const s=new Map;for(const[e,t]of r)s.set(e,t.originalSmiles);n.push({smiles:i,coreSmiles:o.originalSmiles,rGroupSmilesByNum:s})}return n}function T(e){if(!f(e).ok)return null;const t=[];for(const{core:n,assignment:o}of w(e)){const e=new Map;for(const[t,n]of o)e.set(t,n.smiles);const r=g(n.smiles,e);if(!r)continue;const i=new Map;for(const[e,t]of o)i.set(e,t.originalSmiles);t.push({smiles:r,coreSmiles:n.originalSmiles,rGroupSmilesByNum:i})}return t}function E(e,t,n=Math.random){const o=[];let r=0;for(const{core:i,assignment:s}of w(e)){const e=new Map;for(const[t,n]of s)e.set(t,n.smiles);const a=g(i.smiles,e);if(!a)continue;const l=new Map;for(const[e,t]of s)l.set(e,t.originalSmiles);const c={smiles:a,coreSmiles:i.originalSmiles,rGroupSmilesByNum:l};if(o.length<t)o.push(c);else{const e=Math.floor(n()*(r+1));e<t&&(o[e]=c)}r++}return o}},3820:(e,t,n)=>{"use strict";n.d(t,{d:()=>r,o:()=>s});var o=n(1296);const r="PEPTIDE1{R.[Aca].T.G.H.F.G.A.A.Y.P.E.[meI]}$$$$";function i(e,t,n,o){const r=new Array(o.length*(n-t+1));for(let i=0;i<o.length;++i){const s=n-t+1;for(let n=0;n<s;++n){const a=t+n,l=o[i],c=r[i*s+n]=e.clone(),u=c.atoms[a].elem;c.atoms[a].elem=l;const h=u?.length>1?`[${u}]`:u,d=l?.length>1?`[${l}]`:l;c.name=`${e.name}-${h}${a+1}${d}`}}return r}function s(e,t,n){const r=new JSDraw2.MolHandler,s=new org.helm.webeditor.Plugin(r);org.helm.webeditor.IO.parseHelm(s,e,new JSDraw2.Point(0,0),void 0);const a=r.m;a.name=t;let l=[];if(n.placeholders)switch(n.type){case o.aK.Single:l=function(e,t){return t.map((t=>i(e,t.position,t.position,t.monomers))).reduce(((e,t)=>e.concat(t)),[])}(r.m,n.placeholders);break;case o.aK.Parallel:l=function(e,t){if(0===t.length)return[];const n=t[0].monomers.length;for(const e of t)if(e.monomers.length!==n)throw new Error("Parallel enumeration requires all positions to have the same number of monomers");const o=new Array(n);for(let r=0;r<n;r++){const n=e.clone(),i=[];for(const e of t){const t=e.position,o=e.monomers[r],s=n.atoms[t].elem;n.atoms[t].elem=o;const a=s?.length>1?`[${s}]`:s,l=o?.length>1?`[${o}]`:o;i.push(`${a}${t+1}${l}`)}n.name=`${e.name}-${i.join("-")}`,o[r]=n}return o}(r.m,n.placeholders);break;case o.aK.Matrix:l=function(e,t){let n=[e];for(const e of t){const t=n.map((t=>i(t,e.position,e.position,e.monomers)));n=t.reduce(((e,t)=>e.concat(t)),[])}return n}(r.m,n.placeholders)}let c=[];n.breadthPlaceholders&&(c=function(e,t){if(0==t.length)return[];let n=[e];for(const e of t){const t=n.map((t=>i(t,e.start,e.end,e.monomers)));n=t.reduce(((e,t)=>e.concat(t)),[])}return n}(r.m,n.breadthPlaceholders)),l=l.concat(c),n.keepOriginal&&(l=[a,...l]);const u=l.map((e=>[org.helm.webeditor.IO.getHelm(e),e.name]));return u}},1296:(e,t,n)=>{"use strict";var o;n.d(t,{J5:()=>r,aK:()=>o}),function(e){e.Single="single",e.Parallel="parallel",e.Matrix="matrix"}(o||(o={})),Error;class r extends Error{constructor(e,t){super(`Invalid reaction '${e}'.`),this.type="InvalidReactionError"}}},6082:e=>{"use strict";e.exports=DG},4328:e=>{"use strict";e.exports=grok},7389:e=>{"use strict";e.exports=ui},1991:e=>{"use strict";e.exports=wu}},t={};function n(o){var r=t[o];if(void 0!==r)return r.exports;var i=t[o]={id:o,loaded:!1,exports:{}};return e[o].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}n.m=e,n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.u=e=>e+".js",n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{var e;n.g.importScripts&&(e=n.g.location+"");var t=n.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var o=t.getElementsByTagName("script");if(o.length)for(var r=o.length-1;r>-1&&(!e||!/^http(s?):/.test(e));)e=o[r--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=e})(),n.b=document.baseURI||self.location.href,n.nc=void 0;var o={};(()=>{"use strict";n.r(o),n.d(o,{_package:()=>we,initAutoTests:()=>Te,test:()=>Ae,tests:()=>h});var e=n(6082);n(9982);const t=DG.DataFrame.fromCsv('countries,fasta,smiles,molregno,LON,Zip Code,Street Address Line 1,ImageUrl,user_id,error_message,xray,flag,magnitude,CS-id,pdb_id,accel_a,time_offset,chart,fit,Questions,empty_number,empty_string\nBelgium,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C(=O)OCCCc1cccnc1)c2cccc(c2)C(=O)c3ccccc3,1480014,36.276729583740234,995042300,14016 ROUTE 31W,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,1,1,1QBS,1,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.497360340644872, 1.7058694986686864, 5.278052678195135, 0.16000320889028383],""points"":[{""x"":0.10000000149011612,""y"":2.374499797821045},{""x"":0.6000000238418579,""y"":2.6242473125457764},{""x"":1.100000023841858,""y"":2.367267608642578},{""x"":1.600000023841858,""y"":2.6723148822784424},{""x"":2.0999999046325684,""y"":2.6537344455718994},{""x"":2.5999999046325684,""y"":2.3651671409606934},{""x"":3.0999999046325684,""y"":2.5654284954071045},{""x"":3.5999999046325684,""y"":2.4160959720611572},{""x"":4.099999904632568,""y"":2.286726713180542},{""x"":4.599999904632568,""y"":2.5100042819976807},{""x"":5.099999904632568,""y"":1.6676985025405884},{""x"":5.599999904632568,""y"":0.680136501789093},{""x"":6.099999904632568,""y"":0.3391543924808502},{""x"":6.599999904632568,""y"":0.09038983285427094},{""x"":7.099999904632568,""y"":0.19802775979042053}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[7.525235855508179, 1.3186911876809984, 5.335672608564294, 0.7860743343958098],""points"":[{""x"":0.10000000149011612,""y"":7.988070487976074},{""x"":0.6000000238418579,""y"":7.018453121185303},{""x"":1.100000023841858,""y"":8.115279197692871},{""x"":1.600000023841858,""y"":7.486658096313477},{""x"":2.0999999046325684,""y"":7.396438121795654},{""x"":2.5999999046325684,""y"":7.477052211761475},{""x"":3.0999999046325684,""y"":6.913095474243164},{""x"":3.5999999046325684,""y"":8.01385498046875},{""x"":4.099999904632568,""y"":6.985900402069092},{""x"":4.599999904632568,""y"":6.970335960388184},{""x"":5.099999904632568,""y"":5.448817253112793},{""x"":5.599999904632568,""y"":2.5534818172454834},{""x"":6.099999904632568,""y"":1.893947958946228},{""x"":6.599999904632568,""y"":0.6340042352676392},{""x"":7.099999904632568,""y"":0.8403874039649963}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,100,abc\nBurundi,MDYKETLLMPKTDFPMRGGLPNKEPQIQEKW,COc1ccc2cc(ccc2c1)C(C)C(=O)Oc3ccc(C)cc3OC,1480015,36.276729583740234,995073444,80 STATE HIGHWAY 310,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,2,2,1ZP8,2,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.431460753103398, 2.1691498799246745, 5.266445597102774, 0.7825762827017926],""points"":[{""x"":0.10000000149011612,""y"":4.751083850860596},{""x"":0.6000000238418579,""y"":4.203000068664551},{""x"":1.100000023841858,""y"":4.415858745574951},{""x"":1.600000023841858,""y"":4.68414306640625},{""x"":2.0999999046325684,""y"":4.198400974273682},{""x"":2.5999999046325684,""y"":4.179222106933594},{""x"":3.0999999046325684,""y"":4.638473987579346},{""x"":3.5999999046325684,""y"":4.708553314208984},{""x"":4.099999904632568,""y"":4.291589260101318},{""x"":4.599999904632568,""y"":4.038082599639893},{""x"":5.099999904632568,""y"":3.4349939823150635},{""x"":5.599999904632568,""y"":1.2194708585739136},{""x"":6.099999904632568,""y"":1.1920831203460693},{""x"":6.599999904632568,""y"":0.5352635979652405},{""x"":7.099999904632568,""y"":0.3346920311450958}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.339458017970126, -1.0734184310171178, 4.746332950550934, 0.2482416857595658],""points"":[{""x"":0.10000000149011612,""y"":0.2139337658882141},{""x"":0.6000000238418579,""y"":0.4269562065601349},{""x"":1.100000023841858,""y"":0.2441573292016983},{""x"":1.600000023841858,""y"":0.146635964512825},{""x"":2.0999999046325684,""y"":0.08818462491035461},{""x"":2.5999999046325684,""y"":0.2560656666755676},{""x"":3.0999999046325684,""y"":0.42434045672416687},{""x"":3.5999999046325684,""y"":0.37111231684684753},{""x"":4.099999904632568,""y"":0.5581737160682678},{""x"":4.599999904632568,""y"":1.183590054512024},{""x"":5.099999904632568,""y"":1.5629843473434448},{""x"":5.599999904632568,""y"":2.3211288452148438},{""x"":6.099999904632568,""y"":2.229961633682251},{""x"":6.599999904632568,""y"":2.2560226917266846},{""x"":7.099999904632568,""y"":2.2142398357391357}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCameroon,MIEVFLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL,COc1ccc2cc(ccc2c1)C(C)C(=O)OCCCc3cccnc3,1480016,36.26095962524414,995153596,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,3,3,2BDJ,3,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.6760652578642325, 0.9046956320756703, 5.651408971856738, 0.07738846012184185],""points"":[{""x"":0.10000000149011612,""y"":4.32425594329834},{""x"":0.6000000238418579,""y"":4.668442249298096},{""x"":1.100000023841858,""y"":4.379785060882568},{""x"":1.600000023841858,""y"":5.0345139503479},{""x"":2.0999999046325684,""y"":4.878653526306152},{""x"":2.5999999046325684,""y"":4.3451313972473145},{""x"":3.0999999046325684,""y"":4.336992263793945},{""x"":3.5999999046325684,""y"":5.037430286407471},{""x"":4.099999904632568,""y"":5.0092692375183105},{""x"":4.599999904632568,""y"":4.151902675628662},{""x"":5.099999904632568,""y"":3.4066951274871826},{""x"":5.599999904632568,""y"":2.3732759952545166},{""x"":6.099999904632568,""y"":1.673728108406067},{""x"":6.599999904632568,""y"":0.48574790358543396},{""x"":7.099999904632568,""y"":0.2783052325248718}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.938395863010111, -1.4658480661392117, 5.462702751996584, 0.3473139023615039],""points"":[{""x"":0.10000000149011612,""y"":0.4941710829734802},{""x"":0.6000000238418579,""y"":0.15323974192142487},{""x"":1.100000023841858,""y"":0.46373432874679565},{""x"":1.600000023841858,""y"":0.3370431363582611},{""x"":2.0999999046325684,""y"":0.5179030299186707},{""x"":2.5999999046325684,""y"":0.27899765968322754},{""x"":3.0999999046325684,""y"":0.22075064480304718},{""x"":3.5999999046325684,""y"":0.5789918899536133},{""x"":4.099999904632568,""y"":0.21169911324977875},{""x"":4.599999904632568,""y"":0.27857646346092224},{""x"":5.099999904632568,""y"":1.0906332731246948},{""x"":5.599999904632568,""y"":1.8520300388336182},{""x"":6.099999904632568,""y"":2.7177059650421143},{""x"":6.599999904632568,""y"":2.8680918216705322},{""x"":7.099999904632568,""y"":3.2413077354431152}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCanada,MMELVLKTIIGPIVVGVVLRIVDKWLNKDK,CC(C(=O)NCCS)c1cccc(c1)C(=O)c2ccccc2,1480017,36.26095962524414,99515,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,4,4,1IAN,4,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[0.8597390975430008, 1.0957625732481946, 5.260537067987958, 0.07974187998177736],""points"":[{""x"":0.10000000149011612,""y"":0.8190152645111084},{""x"":0.6000000238418579,""y"":0.8421689867973328},{""x"":1.100000023841858,""y"":0.8740922212600708},{""x"":1.600000023841858,""y"":0.8924275040626526},{""x"":2.0999999046325684,""y"":0.8249067664146423},{""x"":2.5999999046325684,""y"":0.9327669143676758},{""x"":3.0999999046325684,""y"":0.8522974252700806},{""x"":3.5999999046325684,""y"":0.8174492716789246},{""x"":4.099999904632568,""y"":0.8394647240638733},{""x"":4.599999904632568,""y"":0.7139387726783752},{""x"":5.099999904632568,""y"":0.5561167597770691},{""x"":5.599999904632568,""y"":0.3276226818561554},{""x"":6.099999904632568,""y"":0.12479474395513535},{""x"":6.599999904632568,""y"":0.13006797432899475},{""x"":7.099999904632568,""y"":0.059702079743146896}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.760930219582546, 1.6591793293833013, 4.667155929720851, 0.7858109544121652],""points"":[{""x"":0.10000000149011612,""y"":6.156993389129639},{""x"":0.6000000238418579,""y"":5.236701965332031},{""x"":1.100000023841858,""y"":6.010560512542725},{""x"":1.600000023841858,""y"":5.495512962341309},{""x"":2.0999999046325684,""y"":6.087770462036133},{""x"":2.5999999046325684,""y"":5.79986572265625},{""x"":3.0999999046325684,""y"":5.597546577453613},{""x"":3.5999999046325684,""y"":5.520902156829834},{""x"":4.099999904632568,""y"":5.360654354095459},{""x"":4.599999904632568,""y"":3.5539746284484863},{""x"":5.099999904632568,""y"":1.577236294746399},{""x"":5.599999904632568,""y"":1.0001264810562134},{""x"":6.099999904632568,""y"":0.9305797815322876},{""x"":6.599999904632568,""y"":0.6033638715744019},{""x"":7.099999904632568,""y"":0.4203685522079468}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nColombia,MDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN,FC(F)(F)c1ccc(OC2CCNCC2)cc1,1480029,36.3309440612793,995152050,1 COURT HOUSE SQUARE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,5,5,4UJ1,5,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[6.4995088314153655, 2.4270351004539914, 5.178659535348579, 0.625653346241577],""points"":[{""x"":0.10000000149011612,""y"":6.496231555938721},{""x"":0.6000000238418579,""y"":6.42543363571167},{""x"":1.100000023841858,""y"":7.040063858032227},{""x"":1.600000023841858,""y"":6.1115403175354},{""x"":2.0999999046325684,""y"":6.680728435516357},{""x"":2.5999999046325684,""y"":6.406774520874023},{""x"":3.0999999046325684,""y"":6.611269474029541},{""x"":3.5999999046325684,""y"":5.889094352722168},{""x"":4.099999904632568,""y"":6.75344705581665},{""x"":4.599999904632568,""y"":6.361435890197754},{""x"":5.099999904632568,""y"":4.1666975021362305},{""x"":5.599999904632568,""y"":1.172118902206421},{""x"":6.099999904632568,""y"":0.801048994064331},{""x"":6.599999904632568,""y"":0.4640021026134491},{""x"":7.099999904632568,""y"":0.0010357667924836278}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[1.4734381347446401, 1.1649805188074196, 4.82958608866421, 0.09500545496710007],""points"":[{""x"":0.10000000149011612,""y"":1.5279096364974976},{""x"":0.6000000238418579,""y"":1.3559974431991577},{""x"":1.100000023841858,""y"":1.5246378183364868},{""x"":1.600000023841858,""y"":1.5567657947540283},{""x"":2.0999999046325684,""y"":1.4114240407943726},{""x"":2.5999999046325684,""y"":1.4045010805130005},{""x"":3.0999999046325684,""y"":1.4769829511642456},{""x"":3.5999999046325684,""y"":1.4875500202178955},{""x"":4.099999904632568,""y"":1.2991987466812134},{""x"":4.599999904632568,""y"":0.922961413860321},{""x"":5.099999904632568,""y"":0.6520044803619385},{""x"":5.599999904632568,""y"":0.15350978076457977},{""x"":6.099999904632568,""y"":0.1078903079032898},{""x"":6.599999904632568,""y"":0.17276449501514435},{""x"":7.099999904632568,""y"":0.14066608250141144}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCosta Rica,MKSTKEEIQTIKTLLKDSRTAKYHKRLQIVL,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCCc3ccccc3,1480018,36.3309440612793,995084218,4041 SOUTHWESTERN BLVD,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,6,6,2BPW,6,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.4833641843311227, -1.8945978742090062, 4.671127708092568, 0.24159861311815153],""points"":[{""x"":0.10000000149011612,""y"":0.0969524160027504},{""x"":0.6000000238418579,""y"":0.028483040630817413},{""x"":1.100000023841858,""y"":0.22087176144123077},{""x"":1.600000023841858,""y"":0.0068915546871721745},{""x"":2.0999999046325684,""y"":0.4305879771709442},{""x"":2.5999999046325684,""y"":0.44774115085601807},{""x"":3.0999999046325684,""y"":0.45346319675445557},{""x"":3.5999999046325684,""y"":0.2370593100786209},{""x"":4.099999904632568,""y"":0.4657953977584839},{""x"":4.599999904632568,""y"":1.155200719833374},{""x"":5.099999904632568,""y"":2.2294070720672607},{""x"":5.599999904632568,""y"":2.4311530590057373},{""x"":6.099999904632568,""y"":2.33846116065979},{""x"":6.599999904632568,""y"":2.608201026916504},{""x"":7.099999904632568,""y"":2.8136143684387207}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.224573521642033, 1.4454033924198528, 5.6014197746076535, 0.2823216054197577],""points"":[{""x"":0.10000000149011612,""y"":4.95027494430542},{""x"":0.6000000238418579,""y"":5.1754679679870605},{""x"":1.100000023841858,""y"":5.276752948760986},{""x"":1.600000023841858,""y"":5.589294910430908},{""x"":2.0999999046325684,""y"":5.616994857788086},{""x"":2.5999999046325684,""y"":5.120813846588135},{""x"":3.0999999046325684,""y"":5.340766906738281},{""x"":3.5999999046325684,""y"":4.876471042633057},{""x"":4.099999904632568,""y"":4.94999361038208},{""x"":4.599999904632568,""y"":5.162564754486084},{""x"":5.099999904632568,""y"":4.399557590484619},{""x"":5.599999904632568,""y"":2.7977969646453857},{""x"":6.099999904632568,""y"":1.0229872465133667},{""x"":6.599999904632568,""y"":0.48275601863861084},{""x"":7.099999904632568,""y"":0.10408931970596313}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCuba,MHAILRYFIRRLFYHIFYKIYSLISKKHQSLPSDVRQF,COc1ccc2c(c1)c(CC(=O)N3CCCC3C(=O)Oc4ccc(C)cc4OC)c(C)n2C(=O)c5ccc(Cl)cc5,1480019,36.33115768432617,995081928,1227 US HIGHWAY 11,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,7,7,1QBS,7,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.320838679713925, -1.2421619987316728, 4.831325425225256, 0.3236011098403072],""points"":[{""x"":0.10000000149011612,""y"":0.3727470338344574},{""x"":0.6000000238418579,""y"":0.12365014106035233},{""x"":1.100000023841858,""y"":0.48422467708587646},{""x"":1.600000023841858,""y"":0.2264465093612671},{""x"":2.0999999046325684,""y"":0.16821794211864471},{""x"":2.5999999046325684,""y"":0.3879014551639557},{""x"":3.0999999046325684,""y"":0.5470244884490967},{""x"":3.5999999046325684,""y"":0.3419053554534912},{""x"":4.099999904632568,""y"":0.7655120491981506},{""x"":4.599999904632568,""y"":1.2346516847610474},{""x"":5.099999904632568,""y"":2.453336715698242},{""x"":5.599999904632568,""y"":2.9565491676330566},{""x"":6.099999904632568,""y"":3.335299491882324},{""x"":6.599999904632568,""y"":3.240290880203247},{""x"":7.099999904632568,""y"":3.1107218265533447}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.6401853521511094, 1.26211588875013, 5.399028074402744, 0.5089580830068091],""points"":[{""x"":0.10000000149011612,""y"":3.8585598468780518},{""x"":0.6000000238418579,""y"":3.6077206134796143},{""x"":1.100000023841858,""y"":3.855252265930176},{""x"":1.600000023841858,""y"":3.619039297103882},{""x"":2.0999999046325684,""y"":3.839388370513916},{""x"":2.5999999046325684,""y"":3.335283041000366},{""x"":3.0999999046325684,""y"":3.571141481399536},{""x"":3.5999999046325684,""y"":3.4155046939849854},{""x"":4.099999904632568,""y"":3.7316646575927734},{""x"":4.599999904632568,""y"":3.0680155754089355},{""x"":5.099999904632568,""y"":2.891066551208496},{""x"":5.599999904632568,""y"":1.6022753715515137},{""x"":6.099999904632568,""y"":0.7652576565742493},{""x"":6.599999904632568,""y"":0.6875326037406921},{""x"":7.099999904632568,""y"":0.5828871726989746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nItaly,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO[N+](=O)[O-],1480020,36.33115768432617,99502,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,8,8,1ZP8,8,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.293592105923809, 1.3781586549141835, 5.1025898038676605, 0.03493851245291291],""points"":[{""x"":0.10000000149011612,""y"":2.1287283897399902},{""x"":0.6000000238418579,""y"":2.267972230911255},{""x"":1.100000023841858,""y"":2.398442506790161},{""x"":1.600000023841858,""y"":2.5130622386932373},{""x"":2.0999999046325684,""y"":2.3255116939544678},{""x"":2.5999999046325684,""y"":2.127340793609619},{""x"":3.0999999046325684,""y"":2.47259783744812},{""x"":3.5999999046325684,""y"":2.131181478500366},{""x"":4.099999904632568,""y"":2.090421438217163},{""x"":4.599999904632568,""y"":2.02299165725708},{""x"":5.099999904632568,""y"":1.1105059385299683},{""x"":5.599999904632568,""y"":0.4494485855102539},{""x"":6.099999904632568,""y"":0.1375635862350464},{""x"":6.599999904632568,""y"":0.036351121962070465},{""x"":7.099999904632568,""y"":0.1619771122932434}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.953125499439879, 1.2528620255306528, 5.187637440149802, 0.3110348753260886],""points"":[{""x"":0.10000000149011612,""y"":5.6585283279418945},{""x"":0.6000000238418579,""y"":5.911152362823486},{""x"":1.100000023841858,""y"":5.924920082092285},{""x"":1.600000023841858,""y"":5.8469438552856445},{""x"":2.0999999046325684,""y"":5.929472923278809},{""x"":2.5999999046325684,""y"":6.190037727355957},{""x"":3.0999999046325684,""y"":6.236179828643799},{""x"":3.5999999046325684,""y"":6.141019344329834},{""x"":4.099999904632568,""y"":5.295210838317871},{""x"":4.599999904632568,""y"":5.265801906585693},{""x"":5.099999904632568,""y"":3.3722851276397705},{""x"":5.599999904632568,""y"":1.8299226760864258},{""x"":6.099999904632568,""y"":0.32690900564193726},{""x"":6.599999904632568,""y"":0.6274543404579163},{""x"":7.099999904632568,""y"":0.8441857099533081}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nRwanda,MPNSEPASLLELFNSIATQGELVRSLKAGNASK,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO,1480021,36.33137130737305,995037247,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,9,9,2BDJ,9,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.8209972202654474, 1.3779216716448506, 5.299882228439686, 0.06040645519069608],""points"":[{""x"":0.10000000149011612,""y"":3.7821109294891357},{""x"":0.6000000238418579,""y"":3.542433023452759},{""x"":1.100000023841858,""y"":3.7008674144744873},{""x"":1.600000023841858,""y"":3.717301607131958},{""x"":2.0999999046325684,""y"":4.024452209472656},{""x"":2.5999999046325684,""y"":4.013899326324463},{""x"":3.0999999046325684,""y"":3.945094347000122},{""x"":3.5999999046325684,""y"":3.866621971130371},{""x"":4.099999904632568,""y"":3.7461626529693604},{""x"":4.599999904632568,""y"":3.3454740047454834},{""x"":5.099999904632568,""y"":2.61944317817688},{""x"":5.599999904632568,""y"":0.999405026435852},{""x"":6.099999904632568,""y"":0.46259793639183044},{""x"":6.599999904632568,""y"":0.054134611040353775},{""x"":7.099999904632568,""y"":0.05711187422275543}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.6318079657726035, 1.8495493770000595, 5.391793312471116, 0.17060707587348442],""points"":[{""x"":0.10000000149011612,""y"":5.458079814910889},{""x"":0.6000000238418579,""y"":5.554427146911621},{""x"":1.100000023841858,""y"":5.799983024597168},{""x"":1.600000023841858,""y"":5.364140033721924},{""x"":2.0999999046325684,""y"":5.864485740661621},{""x"":2.5999999046325684,""y"":5.4509806632995605},{""x"":3.0999999046325684,""y"":5.702574729919434},{""x"":3.5999999046325684,""y"":5.7314534187316895},{""x"":4.099999904632568,""y"":5.5123443603515625},{""x"":4.599999904632568,""y"":5.724395751953125},{""x"":5.099999904632568,""y"":4.354506969451904},{""x"":5.599999904632568,""y"":1.7307666540145874},{""x"":6.099999904632568,""y"":0.6305936574935913},{""x"":6.599999904632568,""y"":0.035183437168598175},{""x"":7.099999904632568,""y"":0.7575169205665588}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nSwitzerland,IRVVGRYLIEVWKAAGMDMDKVLFLWSSDEI,CN1CCC(CC1)Oc2ccc(cc2)C(F)(F)F,1480028,36.33137130737305,99504,92-11 179TH PLACE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,9,10,1IAN,10,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[1.1190255865097471, 2.3163895161544437, 5.4968866182279195, 0.2035204047289052],""points"":[{""x"":0.10000000149011612,""y"":1.1057683229446411},{""x"":0.6000000238418579,""y"":1.1019697189331055},{""x"":1.100000023841858,""y"":1.0818607807159424},{""x"":1.600000023841858,""y"":1.062997817993164},{""x"":2.0999999046325684,""y"":1.046447515487671},{""x"":2.5999999046325684,""y"":1.1217249631881714},{""x"":3.0999999046325684,""y"":1.2166996002197266},{""x"":3.5999999046325684,""y"":1.215477705001831},{""x"":4.099999904632568,""y"":1.0581893920898438},{""x"":4.599999904632568,""y"":1.1747995615005493},{""x"":5.099999904632568,""y"":1.0181127786636353},{""x"":5.599999904632568,""y"":0.5344523191452026},{""x"":6.099999904632568,""y"":0.2569526433944702},{""x"":6.599999904632568,""y"":0.1912207305431366},{""x"":7.099999904632568,""y"":0.15060538053512573}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.1038581025805785, 2.0032224204185245, 5.087602825989163, 0.13277988512492753],""points"":[{""x"":0.10000000149011612,""y"":3.0498509407043457},{""x"":0.6000000238418579,""y"":2.805217742919922},{""x"":1.100000023841858,""y"":3.3415253162384033},{""x"":1.600000023841858,""y"":3.0549843311309814},{""x"":2.0999999046325684,""y"":3.250074863433838},{""x"":2.5999999046325684,""y"":3.0432586669921875},{""x"":3.0999999046325684,""y"":3.265852451324463},{""x"":3.5999999046325684,""y"":2.9475724697113037},{""x"":4.099999904632568,""y"":3.1929898262023926},{""x"":4.599999904632568,""y"":2.7460060119628906},{""x"":5.099999904632568,""y"":1.6175861358642578},{""x"":5.599999904632568,""y"":0.3006608486175537},{""x"":6.099999904632568,""y"":0.3444803059101105},{""x"":6.599999904632568,""y"":0.015537971630692482},{""x"":7.099999904632568,""y"":0.5527358055114746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\n,,,,,,,,,,,,,,,,,,,,,');t.columns.add(DG.Column.fromList(DG.TYPE.BYTE_ARRAY,"BinaryImage",Array.from(new Uint8Array(11))));var r=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((o=o.apply(e,t||[])).next())}))};const i=3e4,s=108e5,a=console.log.bind(console),l=console.info.bind(console),c=console.warn.bind(console),u=console.error.bind(console),h={},d="Auto Tests",p="Demo",m="Detectors",f="Core",g={};let y;var b;!function(e){e.notNull=function(e,t){if(null==e)throw new Error(`${null==t?"Value":t} not defined`)}}(b||(b={}));class v{constructor(e,t,n){this.catchUnhandled=!0,this.report=!1,this.returnOnFail=!1,void 0!==e&&(this.catchUnhandled=e),void 0!==t&&(this.report=t),void 0!==n&&(this.returnOnFail=n)}}class C{constructor(e,t,n,o){var s;this.category=e,this.name=t,null!=o||(o={}),null!==(s=o.timeout)&&void 0!==s||(o.timeout=i),this.options=o,this.test=()=>r(this,void 0,void 0,(function*(){return new Promise(((e,t)=>r(this,void 0,void 0,(function*(){var o;let r="";try{DG.Test.isInDebug;let e=yield n();try{r=null!==(o=null==e?void 0:e.toString())&&void 0!==o?o:""}catch(e){r="Can't convert test's result to string",console.error(`Can't convert test's result to string in the ${this.category}:${this.name} test`)}}catch(e){t(e)}e(r)}))))}))}}function x(e,t,n){null==h[y]&&(h[y]={}),null==h[y].tests&&(h[y].tests=[]),h[y].tests.push(new C(y,e,t,n))}function w(e,t=!0,n){if(n=n?`${n}, `:"",e!==t)throw new Error(`${n}Expected "${t}", got "${e}"`)}function A(e,t,n=.001,o){if(e===Number.POSITIVE_INFINITY&&t===Number.POSITIVE_INFINITY||e===Number.NEGATIVE_INFINITY&&t===Number.NEGATIVE_INFINITY||e===Number.NaN&&t===Number.NaN||isNaN(e)&&isNaN(t))return;const r=Math.abs(e-t)<n;if(w(r,!0,`${null!=o?o:""} (tolerance = ${n}; a = ${e}, e = ${t})`),!r)throw new Error(`Expected ${t}, got ${e} (tolerance = ${n})`)}function T(e,t){for(const[n,o]of Object.entries(t)){if(!e.hasOwnProperty(n))throw new Error(`Expected property "${n}" not found`);const t=e[n];if(t instanceof Array&&o instanceof Array)E(t,o);else if(t instanceof Object&&o instanceof Object)T(t,o);else if(Number.isFinite(t)&&Number.isFinite(o))A(t,o);else if(t!=o)throw new Error(`Expected (${o}) for key '${n}', got (${t})`)}}function E(e,t){const n=e.length,o=t.length;if(n!=o)throw new Error(`Arrays are of different length: actual array length is ${n} and expected array length is ${o}`);for(let o=0;o<n;o++)if(e[o]instanceof Array&&t[o]instanceof Array)E(e[o],t[o]);else if(e[o]instanceof Object&&t[o]instanceof Object)T(e[o],t[o]);else if(e[o]!=t[o])throw new Error(`Expected ${t[o]} at position ${o}, got ${e[o]}`)}function S(e,t,n){var o;y=e,t(),h[y]&&(h[y].clear=null===(o=null==n?void 0:n.clear)||void 0===o||o,h[y].timeout=null==n?void 0:n.timeout,h[y].benchmarks=null==n?void 0:n.benchmarks,h[y].stressTests=null==n?void 0:n.stressTests,h[y].owner=null==n?void 0:n.owner)}function N(e){null==h[y]&&(h[y]={}),h[y].before=e}function I(e){null==h[y]&&(h[y]={}),h[y].after=e}function M(e,t){return e.replace(new RegExp(t.name,"gi"),t.nqName)}function P(e,n){var o,a,l,c,u,y,b,v,x,A;return r(this,void 0,void 0,(function*(){const T=e.id;if(g[T])return;const E=n?n.tests:h;if("DevTools"===e.name||n&&"DevTools"===n._package.name)for(const e of window.dartTests){const t=e.name.split(/\s*\|\s*!/g);let n=null!==(o=t.pop())&&void 0!==o?o:e.name,r=t.length?f+": "+t.join(": "):f,s=n.split(" | ");n=s[s.length-1],s.unshift(r),s.pop(),r=s.join(": "),void 0===E[r]&&(E[r]={tests:[],clear:!0}),E[r].tests.push(new C(r,n,e.test,{isAggregated:!1,timeout:null!==(l=null===(a=e.options)||void 0===a?void 0:a.timeout)&&void 0!==l?l:i,skipReason:null===(c=e.options)||void 0===c?void 0:c.skipReason,owner:null===(u=e.options)||void 0===u?void 0:u.owner,benchmark:null!==(b=null===(y=e.options)||void 0===y?void 0:y.benchmark)&&void 0!==b&&b}))}const S=[],N=[],I=[],P=yield grok.dapi.functions.filter(`package.id = "${T}"`).list(),_=new RegExp(/skip:\s*([^,\s]+)|wait:\s*(\d+)|cat:\s*([^,\s]+)|timeout:\s*(\d+)/g);for(const n of P){const o=n.options.test,a=n.options.demoPath;if(o&&Array.isArray(o)&&o.length)for(let e=0;e<o.length;e++){const t=o[e].matchAll(_),a={};Array.from(t).forEach((e=>{e[0].startsWith("skip")?a.skip=e[1]:e[0].startsWith("wait")?a.wait=parseInt(e[2]):e[0].startsWith("cat")?a.cat=e[3]:e[0].startsWith("timeout")&&(a.timeout=parseInt(e[4]))}));const l=new C(null!==(v=a.cat)&&void 0!==v?v:d,1===o.length?n.name:`${n.name} ${e+1}`,(()=>r(this,void 0,void 0,(function*(){const t=yield grok.functions.eval(M(o[e],n));if(a.wait&&(yield R(a.wait)),"boolean"==typeof t&&!t)throw`Failed: ${o[e]}, expected true, got ${t}`}))),{skipReason:a.skip,timeout:DG.Test.isInBenchmark?null!==(x=a.benchmarkTimeout)&&void 0!==x?x:s:null!==(A=a.timeout)&&void 0!==A?A:i});if(a.cat){const e=a.cat;void 0===E[e]&&(E[e]={tests:[],clear:!0}),E[e].tests||(E[e].tests=[]),E[e].tests.push(l)}else S.push(l)}if(a){const e=n.options.demoWait?parseInt(n.options.demoWait):void 0,t=new C(p,n.friendlyName,(()=>r(this,void 0,void 0,(function*(){yield R(300),grok.shell.clearLastError(),yield n.apply(),yield R(e||2e3);const t=yield grok.shell.lastError;if(t)throw new Error(t)}))),{skipReason:n.options.demoSkip});N.push(t)}if(n.hasTag("semTypeDetector")){let o=t;n.options.testData&&(o=yield grok.data.files.openTable(`System:AppData/${e.nqName}/${n.options.testData}`));const i=new C(m,n.friendlyName,(()=>r(this,void 0,void 0,(function*(){const t=[];console.log(`System:AppData/${e.nqName}/${n.options.testData}`);for(const e of o.clone().columns){const o=yield n.apply([e]);t.push(o||e.semType)}const r=t.filter((e=>e));w(r.length,1),n.options.testDataColumnName&&w(r[0],n.options.testDataColumnName)}))),{skipReason:n.options.skipTest});I.push(i)}}g[T]=!0,S.length>0&&(E[d]={tests:S,clear:!0}),N.length>0&&(E[p]={tests:N,clear:!0}),I.length>0&&(E[m]={tests:I,clear:!1})}))}function _(e){return r(this,void 0,void 0,(function*(){return`${e.toString()}\n${e.stack?yield DG.Logger.translateStackTrace(e.stack):""}`}))}function L(e,t,n,o,s,l){var c,h,d,p,m,f,g,y,b,v,C,x,w,A;return r(this,void 0,void 0,(function*(){let r;n.length=0;const T=null!=t&&e.name.toLowerCase()!==t.toLowerCase();let E=(null===(c=e.options)||void 0===c?void 0:c.skipReason)||T,S=T?"skipped":null===(h=e.options)||void 0===h?void 0:h.skipReason;if(DG.Test.isInBenchmark&&!(null===(d=e.options)||void 0===d?void 0:d.benchmark))return void a(`Package testing: Skipped {{${e.category}}} {{${e.name}}} doesnt available in benchmark mode`);E&&!DG.Test.isInBenchmark&&a(`Package testing: Skipped {{${e.category}}} {{${e.name}}}`),E||a(`Package testing: Started {{${e.category}}} {{${e.name}}}`);const N=Date.now(),I=new Date(N).toISOString();try{if(E)r={name:e.name,owner:null!==(m=null===(p=e.options)||void 0===p?void 0:p.owner)&&void 0!==m?m:"",category:e.category,logs:"",date:I,success:!0,result:S,ms:0,skipped:!0,package:null!=s?s:"",flaking:DG.Test.isReproducing};else{let t=null!=o?o:i;DG.Test.isProfiling&&console.profile(`${e.category}: ${e.name}`),r={name:e.name,owner:null!==(g=null===(f=e.options)||void 0===f?void 0:f.owner)&&void 0!==g?g:"",category:e.category,logs:"",date:I,success:!0,result:null!==(y=(yield $(e.test,t)).toString())&&void 0!==y?y:"OK",ms:0,skipped:!1,package:null!=s?s:"",flaking:DG.Test.isReproducing},DG.Test.isProfiling&&(console.profileEnd(`${e.category}: ${e.name}`),grok.shell.info(`Profiling of ${e.category}: ${e.name} finished \n Please ensure that you have opened DevTools (F12) / Performance panel before test starts.`))}}catch(t){u(t),r={name:e.name,owner:null!==(v=null===(b=e.options)||void 0===b?void 0:b.owner)&&void 0!==v?v:"",category:e.category,logs:"",date:I,success:!1,result:yield _(t),ms:0,skipped:!1,package:null!=s?s:"",flaking:!1}}if((null===(C=e.options)||void 0===C?void 0:C.isAggregated)&&r.result.constructor===DG.DataFrame){const e=r.result.col("success");if(e&&(r.success=e.stats.sum===e.length),!l){const e=r.result;e.columns.remove("stack"),e.rows.removeWhere((e=>e.get("success"))),r.result=e}r.result=r.result.toCsv()}if(r.logs=n.join("\n"),r.ms=Date.now()-N,E||a(`Package testing: Finished {{${e.category}}} {{${e.name}}} with {{${r.success?"success":"error"}}} for ${r.ms} ms`),r.success||a(`Package testing: Result for {{${e.category}}} {{${e.name}}}: ${r.result}`),r.category=e.category,r.name=e.name,r.owner=null!==(w=null===(x=e.options)||void 0===x?void 0:x.owner)&&void 0!==w?w:"",!T){let t={success:r.success,result:r.result,ms:r.ms,date:r.date,skipped:r.skipped,category:e.category,name:e.name,logs:r.logs,owner:r.owner,flaking:DG.Test.isReproducing&&r.success,package:r.package};if(r.result.constructor==Object){const e=Object.keys(r.result).reduce(((e,t)=>Object.assign(Object.assign({},e),{["result."+t]:r.result[t]})),{});t=Object.assign(Object.assign({},t),e)}t.result instanceof DG.DataFrame&&(t.result=JSON.stringify(null===(A=t.result)||void 0===A?void 0:A.toJson())||""),yield grok.shell.reportTest("package",t)}return r}))}function O(e){const t=e.slice();return t.sort((()=>Math.random()-.5)),t}function R(e){return r(this,void 0,void 0,(function*(){yield new Promise((t=>setTimeout(t,e)))}))}function $(e,t,n="EXECUTION TIMEOUT"){return r(this,void 0,void 0,(function*(){let o=null;const r=new Promise(((e,r)=>{o=setTimeout((()=>{r(n)}),t)}));try{return yield Promise.race([e(),r])}finally{o&&clearTimeout(o)}}))}DG.DataFrame.fromColumns([DG.Column.fromStrings("col",["val1","val2","val3"])]);var D=n(4328),B=n(6686);class F extends e.Package{async getTranslationHelper(){return await D.functions.call(`${this.name}:getTranslationHelper`)}}function k(e,t,n){return n.createFormatConverter(e,t).convertTo(B.NO.HELM)}function H(e,t,n){return n.createFormatConverter(e,B.NO.HELM).convertTo(t)}const G={Axolabs:{UfAfsCfsGfuacg:"RNA1{[fR](U)p.[fR](A)[sp].[fR](C)[sp].[fR](G)p.[25r](U)p.[25r](A)p.[25r](C)p.[25r](G)}$$$$"},BioSpring:{"A*GC*123456789":"RNA1{r(A)[sp].r(G)p.r(C)[sp].[fR](U)p.[fR](A)p.[fR](C)p.[fR](G)p.[25r](U)p.[25r](A)p.[25r](C)p.[25r](G)p.d([m5C])}$$$$"},Mermade12:{hefglijkLIJKHEFG:"RNA1{[25r](U)[sp].[25r](A)[sp].[25r](C)[sp].[25r](G)[sp].[fR](U)[sp].[fR](A)[sp].[fR](C)[sp].[fR](G)[sp].[fR](U)p.[fR](A)p.[fR](C)p.[fR](G)p.[25r](U)p.[25r](A)p.[25r](C)p.[25r](G)}$$$$"}},U={"RNA1{[fR](U)p.[fR](A)[sp].[fR](C)[sp].[fR](G)p.[25r](U)p.[25r](A)p.[25r](C)p.[25r](G)}$$$$":"UACGUACG","RNA1{r(A)[sp].r(G)p.r(C)[sp].[fR](U)p.[fR](A)p.[fR](C)p.[fR](G)p.[25r](U)p.[25r](A)p.[25r](C)p.[25r](G)p}$$$$":"AGCUACGUACG","RNA1{[25r](U)[sp].[25r](A)[sp].[25r](C)[sp].[25r](G)[sp].[fR](U)[sp].[fR](A)[sp].[fR](C)[sp].[fR](G)[sp].[fR](U)p.[fR](A)p.[fR](C)p.[fR](G)p.[25r](U)p.[25r](A)p.[25r](C)p.[25r](G)}$$$$":"UACGUACGUACGUACG"};S("Formats to HELM",(()=>{let e;N((async()=>{e=await we.getTranslationHelper()}));for(const t of Object.keys(G))for(const[n,o]of Object.entries(G[t]))x(`${t} to HELM`,(async()=>{const r=o;w(k(n,t,e),r)}))})),S("HELM to Formats",(()=>{let e;N((async()=>{e=await we.getTranslationHelper()}));for(const t of Object.keys(G))for(const[n,o]of Object.entries(G[t]))x(`${t} to HELM`,(async()=>{const r=n;w(H(o,t,e),r)}))}));var V=n(3480);S("HELM to Nucleotides",(()=>{let e;N((async()=>{e=await we.getTranslationHelper()})),Object.entries(U).forEach((([t,n],o)=>{x(`Sequence ${o+1} to nucleotides`,(async()=>{const o=n;w((0,V.Hs)(t,e.monomerLibWrapper),o)}))}))}));const j={[B.NO.AXOLABS]:"Afcgacsu",[B.NO.HELM]:"RNA1{[fR](A)p.[25r](C)p.[25r](G)p.[25r](A)p.[25r](C)[sp].[25r](U)}$$$$"};S("Formats support",(()=>{let e;N((async()=>{e=await we.getTranslationHelper()})),Object.entries(j).forEach((([t,n])=>{x(`All formats for ${t}`,(async()=>{const o=function(e,t,n){const o=n.createSequenceValidator(e).getInvalidCodeIndex(t);return(0,V.bD)(e,o,t,n)}(n,t,e),r=Object.keys(o).length;w(!0,Object.keys(G).length+1<=r)}))}))}));var q=n(9192);S("files",(()=>{let t;N((async()=>{t=await we.getTranslationHelper()})),x("list",(async()=>{let n;const o=e.DataFrame.fromColumns([e.Column.string("subTest"),n=e.Column.bool("success"),e.Column.string("format"),e.Column.string("src"),e.Column.string("res"),e.Column.string("tgt"),e.Column.string("error"),e.Column.string("stack")]),r=await we.files.list("tests",!0,".csv");for(const n of r){const r=e.DataFrame.fromCsv(await n.readAsString()),i=r.columns.byIndex(0),s=i.name,a=r.columns.byIndex(1),l=r.rowCount;for(let e=0;e<l;++e){const r=o.rows.addNew();r.subTest=`${n.name}, row: ${e}`;try{const n=i.get(e),o=a.get(e);r.format=s,r.src=n,r.tgt=o,w(r.res=k(n,s,t),o),r.success=!0}catch(e){const[t,n]=(0,q.AP)(e);r.error=t,r.stack=n,r.success=!1}}}0==o.rowCount&&o.rows.addNew(["empty",!0,"",""]);const i=n.toList().findIndex((e=>1!=e));if(-1!=i){const e=o.rows.get(i);throw new Error(`Subtest '${e.subTest}' failed: ${e.error}`)}return o}),{skipReason:"Can not create test in async manner based on files in Shares."})}));var W=n(8312),z=n(2003);class Y{constructor(e,t,n,o,r,i){this.units=e,this.aligned=t,this.alphabet=n,this.alphabetSize=o,this.alphabetIsMultichar=r,this.separator=i}}async function K(t,n){const o=(await t()).getCol(n),r=await D.functions.call("Bio:detectMacromolecule",{col:o});if(r&&(o.semType=r),o.semType===e.SEMTYPE.MACROMOLECULE){const e=`Negative test detected semType='${o.semType}', units='${o.meta.units}'.`;throw new Error(e)}}async function Q(t,n,o,r,i,s,a,l,c=null){const u=(await t()).col(n),h=await D.functions.call("Bio:detectMacromolecule",{col:u});h&&(u.semType=h),w(u.semType,e.SEMTYPE.MACROMOLECULE),w(u.meta.units,r),w(u.getTag(z.gp.aligned),i),w(u.getTag(z.gp.alphabet),s),c&&w(u.getTag(z.gp.separator),c);const d=o.getSeqHandler(u);w(d.getAlphabetSize(),a),w(d.getAlphabetIsMultichar(),l),d.isHelm()||(w(d.aligned,i),w(d.alphabet,s))}S("PolyTool: detectors",(()=>{let t;N((async()=>{t=await(0,W.Q)()}));const n={cyclized1:{csv:"n,seq\n1,R-F-C(1)-T-G-H-F-Y-G-H-F-Y-G-H-F-Y-P-C(1)-meI\n2,C(1)-T-G-H-F-Y-P-C(1)-meI\n3,R-F-C(1)-T-G-H-F-Y-P-C(1)\n4,C(1)-T-G-H-F-H-P-C(1)\n5,R-F-D(2)-T-G-H-F-Y-P-NH2(2)\n6,R-F-aG(4)-T-G-H-F-Y-P-azG(4)-meI",pos:{seq:new Y(z.Hi.CUSTOM,"SEQ",z.YI.UN,13,!0,"-")}}};for(const[o,r]of Object.entries(n))x(`${o}`,(async()=>{const n=async()=>e.DataFrame.fromCsv(r.csv);for(const e of r.neg??[])await K(n,e);for(const[e,o]of Object.entries(r.pos??{}))await Q(n,e,t,o.units,o.aligned,o.alphabet,o.alphabetSize,o.alphabetIsMultichar,o.separator)}),{skipReason:"3156"})}));var J=n(4971);const X="Libraries",Z="Settings",ee="DuplicateMonomerPreferences",te=4e3,ne="nextChunk";let oe=Promise.resolve();async function re(){let e;return oe=oe.then((async()=>{const t=await D.userSettings.getValue(X,Z,!0);e=t?JSON.parse(t):{exclude:[],explicit:[],duplicateMonomerPreferences:{}};const n=await async function(){let e=await D.userSettings.getValue(X,ee,!0)??"";if(!e)return{};for(;e.endsWith(ne);){const t=`${ee}${e.charAt(e.length-9-1)}`,n=await D.userSettings.getValue(X,t,!0)??"";e=e.slice(0,e.length-9-1)+n}return JSON.parse(e)}();e.exclude=e.exclude instanceof Array?e.exclude:[],e.explicit=e.explicit instanceof Array?e.explicit:[],e.duplicateMonomerPreferences=e.duplicateMonomerPreferences instanceof Object?e.duplicateMonomerPreferences:{};for(const t in n){e.duplicateMonomerPreferences[t]=e.duplicateMonomerPreferences[t]??{};for(const o in n[t])for(const r of n[t][o])e.duplicateMonomerPreferences[t][r]=o}})),await oe,e}async function ie(e){oe=oe.then((async()=>{e.duplicateMonomerPreferences=e.duplicateMonomerPreferences??{};const t={};for(const n in e.duplicateMonomerPreferences){t[n]={};for(const o in e.duplicateMonomerPreferences[n]){const r=e.duplicateMonomerPreferences[n][o];t[n][r]=t[n][r]??[],t[n][r].push(o)}}await async function(e){const t=JSON.stringify(e),n=Math.ceil(t.length/te);for(let e=0;e<n;e++){const o=0===e?ee:`${ee}${e}`,r=e<n-1?`${e+1}`:"",i=t.slice(e*te,(e+1)*te),s=r?i+r+ne:i;await D.userSettings.add(X,o,s,!0)}}(t),e.duplicateMonomerPreferences={},await D.userSettings.add(X,Z,JSON.stringify(e),!0)})),await oe}var se=n(6717),ae=n(9124),le=n(4229),ce=n(5174),ue=n(6694);S("PolyTool: Convert",(()=>{let t,n,o,i,s;N((async()=>{o=await(0,se.j)(),t=await(0,ae.b2)(),n=await(0,W.Q)(),i=await(0,J.pj)(),s=await re(),await i.loadMonomerLibForTests()})),I((async()=>{await ie(s),await i.loadMonomerLib(!0)}));const a={"cyclized-C(1)-2-1":{src:{seq:"R-F-C(1)-T-G-H-F-Y-P-C(1)-meI"},tgt:{helm:"PEPTIDE1{R.F.C.T.G.H.F.Y.P.C.[meI]}$PEPTIDE1,PEPTIDE1,3:R3-10:R3$$$V2.0",mol:{atomCount:95,bondCount:100,inchiKey:"LMJUFVBPWWJJPN-AJJYTACESA-N"}}},"cyclized-C(1)-0-1":{src:{seq:"C(1)-T-G-H-F-Y-P-C(1)-meI"},tgt:{helm:"PEPTIDE1{C.T.G.H.F.Y.P.C.[meI]}$PEPTIDE1,PEPTIDE1,1:R3-8:R3$$$V2.0",mol:{atomCount:73,bondCount:77,inchiKey:"KLFRBMUPPMMGJM-HXTBFBBASA-N"}}},"cyclized-C(1)-0-0":{src:{seq:"C(1)-T-G-H-F-Y-P-C(1)"},tgt:{helm:"PEPTIDE1{C.T.G.H.F.Y.P.C}$PEPTIDE1,PEPTIDE1,1:R3-8:R3$$$V2.0",mol:{atomCount:64,bondCount:68,inchiKey:"LOSMDBLEXLWPLB-OFZKBENXSA-N"}}},"cyclized-D(2)-NH2(2)-3-0":{src:{seq:"R-F-D(2)-T-G-H-F-Y-P-NH2(2)"},tgt:{helm:"PEPTIDE1{R.F.D.T.G.H.F.Y.P.[NH2]}$PEPTIDE1,PEPTIDE1,3:R3-10:R2$$$V2.0",mol:{atomCount:81,bondCount:86,inchiKey:"CBMGNYKOZWNVNK-AHGCAHLCSA-N"}}},"cyclized-D(2)-NH2(2)-0-0":{src:{seq:"D(2)-T-G-H-F-Y-P-NH2(2)"},tgt:{helm:"PEPTIDE1{D.T.G.H.F.Y.P.[NH2]}$PEPTIDE1,PEPTIDE1,1:R3-8:R2$$$V2.0",mol:{atomCount:59,bondCount:63,inchiKey:"HGRHAUQBJXFERJ-MUFWPYSASA-N"}}}};for(const[e,n]of Object.entries(a))x(`toHelm-${e}`,(async()=>{const e=await(0,ue.Q4)(["rules_example.json"]);w((0,le.b)([n.src.seq],e,t)[0][0],n.tgt.helm)}));for(const[r,i]of Object.entries(a))x(`toAtomicLevel-${r}`,(async()=>{const r=await(0,ue.Q4)(["rules_example.json"]),[s,a,l]=(0,le.b)([i.src.seq],r,t),c=await(0,ce.A)(r),u=e.Column.fromStrings("helm",s);u.semType=e.SEMTYPE.MACROMOLECULE,u.meta.units=z.Hi.HELM;const h=await n.helmToAtomicLevel(u,!1,!1,c);if(h.warnings&&h.warnings.length>0)throw new Error(h.warnings[0]);w(null!=h.molCol,!0,".molCol is not null");const d=h.molCol.get(0),p=o.get_mol(d);try{T({atomCount:p.get_num_atoms(),bondCount:p.get_num_bonds(),inchiKey:o.get_inchikey_for_inchi(p.get_inchi())},i.tgt.mol)}finally{p.delete()}}));x("ui-col-wo-table",(async()=>{const t=we.name,n=Object.values(a).map((e=>e.src.seq)),o=Object.values(a).map((e=>e.tgt.helm)),r=e.Column.fromStrings("seq",n),i=await D.functions.call(`${t}:polyToolConvert2`,{seqCol:r,generateHelm:!0,chiralityEngine:!0,rules:["rules_example.json"]});E(i.toList(),o),w(i.semType,e.SEMTYPE.MACROMOLECULE),w(i.meta.units,z.Hi.HELM),w(i.dataFrame,null)})),x("ui-col",(async()=>{const t=we.name,n=Object.values(a).map((e=>e.src.seq)),o=Object.values(a).map((e=>e.tgt.helm)),i=e.Column.fromStrings("seq",n),s=e.DataFrame.fromColumns([i]),l=D.shell.addTableView(s),c=await D.functions.call(`${t}:polyToolConvert2`,{seqCol:i,generateHelm:!0,chiralityEngine:!0,rules:["rules_example.json"]});E(c.toList(),o),w(c.semType,e.SEMTYPE.MACROMOLECULE),w(c.meta.units,z.Hi.HELM),w(c.dataFrame.id,s.id),await function(e,t,n,o=0,i="timeout"){return r(this,void 0,void 0,(function*(){return new Promise(((r,s)=>{const a=e.subscribe((e=>{try{t(e),r("OK")}catch(e){s(e)}finally{a.unsubscribe(),clearTimeout(l)}})),l=setTimeout((()=>{a.unsubscribe(),s(i)}),o);n()}))}))}(l.grid.onAfterDrawContent,(()=>{}),(async()=>{l.grid.invalidate()}),15e3),w(c.getTag(e.TAGS.CELL_RENDERER),"helm")}))}));var he=n(1296),de=n(3820);S("PolyTool: Enumerate",(()=>{let e,t,n;N((async()=>{e=await(0,ae.b2)(),t=await(0,J.pj)(),n=await re(),await t.loadMonomerLibForTests()})),I((async()=>{await ie(n),await t.loadMonomerLib(!0)}));const o={single1:{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:he.aK.Single,placeholders:[{position:4,monomers:["K","P","F4COO"]},{position:6,monomers:["Y","T"]}]},tgt:[{seq:"PEPTIDE1{[Ac(1)].F.W.G.K.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5K"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5P"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.[F4COO].L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5[F4COO]"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.P.L.Y.[C(1)].G.[NH2]}$$$$V2.0",name:"-[Tic]7Y"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.P.L.T.[C(1)].G.[NH2]}$$$$V2.0",name:"-[Tic]7T"}]},"single-with-original":{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:he.aK.Single,placeholders:[{position:4,monomers:["K","P","F4COO"]},{position:6,monomers:["Y","T"]}],keepOriginal:!0},tgt:[{seq:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:""},{seq:"PEPTIDE1{[Ac(1)].F.W.G.K.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5K"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5P"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.[F4COO].L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5[F4COO]"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.P.L.Y.[C(1)].G.[NH2]}$$$$V2.0",name:"-[Tic]7Y"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.P.L.T.[C(1)].G.[NH2]}$$$$V2.0",name:"-[Tic]7T"}]},parallel1:{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:he.aK.Parallel,placeholders:[{position:1,monomers:["D","L"]},{position:6,monomers:["Y","T"]}]},tgt:[{seq:"PEPTIDE1{[Ac(1)].D.W.G.P.L.Y.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2D-[Tic]7Y"},{seq:"PEPTIDE1{[Ac(1)].L.W.G.P.L.T.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2L-[Tic]7T"}]},"parallel-three-positions":{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:he.aK.Parallel,placeholders:[{position:1,monomers:["D","L","K"]},{position:4,monomers:["K","P","F4COO"]},{position:6,monomers:["Y","T","A"]}]},tgt:[{seq:"PEPTIDE1{[Ac(1)].D.W.G.K.L.Y.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2D-P5K-[Tic]7Y"},{seq:"PEPTIDE1{[Ac(1)].L.W.G.P.L.T.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2L-P5P-[Tic]7T"},{seq:"PEPTIDE1{[Ac(1)].K.W.G.[F4COO].L.A.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2K-P5[F4COO]-[Tic]7A"}]},"parallel-with-original":{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:he.aK.Parallel,placeholders:[{position:1,monomers:["D","L"]},{position:6,monomers:["Y","T"]}],keepOriginal:!0},tgt:[{seq:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:""},{seq:"PEPTIDE1{[Ac(1)].D.W.G.P.L.Y.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2D-[Tic]7Y"},{seq:"PEPTIDE1{[Ac(1)].L.W.G.P.L.T.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2L-[Tic]7T"}]},"parallel-single-position":{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:he.aK.Parallel,placeholders:[{position:4,monomers:["K","P","F4COO"]}]},tgt:[{seq:"PEPTIDE1{[Ac(1)].F.W.G.K.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5K"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5P"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.[F4COO].L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5[F4COO]"}]},matrix1:{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:he.aK.Matrix,placeholders:[{position:1,monomers:["D","L"]},{position:4,monomers:["K","P","F4COO"]},{position:6,monomers:["Y","T"]}]},tgt:[{seq:"PEPTIDE1{[Ac(1)].D.W.G.K.L.Y.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2D-P5K-[Tic]7Y"},{seq:"PEPTIDE1{[Ac(1)].D.W.G.K.L.T.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2D-P5K-[Tic]7T"},{seq:"PEPTIDE1{[Ac(1)].D.W.G.P.L.Y.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2D-P5P-[Tic]7Y"},{seq:"PEPTIDE1{[Ac(1)].D.W.G.P.L.T.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2D-P5P-[Tic]7T"},{seq:"PEPTIDE1{[Ac(1)].D.W.G.[F4COO].L.Y.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2D-P5[F4COO]-[Tic]7Y"},{seq:"PEPTIDE1{[Ac(1)].D.W.G.[F4COO].L.T.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2D-P5[F4COO]-[Tic]7T"},{seq:"PEPTIDE1{[Ac(1)].L.W.G.K.L.Y.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2L-P5K-[Tic]7Y"},{seq:"PEPTIDE1{[Ac(1)].L.W.G.K.L.T.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2L-P5K-[Tic]7T"},{seq:"PEPTIDE1{[Ac(1)].L.W.G.P.L.Y.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2L-P5P-[Tic]7Y"},{seq:"PEPTIDE1{[Ac(1)].L.W.G.P.L.T.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2L-P5P-[Tic]7T"},{seq:"PEPTIDE1{[Ac(1)].L.W.G.[F4COO].L.Y.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2L-P5[F4COO]-[Tic]7Y"},{seq:"PEPTIDE1{[Ac(1)].L.W.G.[F4COO].L.T.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2L-P5[F4COO]-[Tic]7T"}]}};for(const[e,t]of Object.entries(o))x(`${e}`,(async()=>{E((0,de.o)(t.src,"",t.params),t.tgt.map((e=>[e.seq,e.name])))}))})),S("PolyTool: Enumerate",(()=>{let e,t,n;N((async()=>{e=await(0,ae.b2)(),t=await(0,J.pj)(),n=await re(),await t.loadMonomerLibForTests()})),I((async()=>{await ie(n),await t.loadMonomerLib(!0)}));const o={breadth1:{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:he.aK.Single,breadthPlaceholders:[{start:2,end:4,monomers:["K"]}]},tgt:[{seq:"PEPTIDE1{[Ac(1)].F.K.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-W3K"},{seq:"PEPTIDE1{[Ac(1)].F.W.K.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-G4K"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.K.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5K"}]},"breadth1-with-original":{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:he.aK.Single,breadthPlaceholders:[{start:2,end:4,monomers:["K"]}],keepOriginal:!0},tgt:[{seq:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:""},{seq:"PEPTIDE1{[Ac(1)].F.K.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-W3K"},{seq:"PEPTIDE1{[Ac(1)].F.W.K.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-G4K"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.K.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5K"}]},breadth2:{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:he.aK.Single,breadthPlaceholders:[{start:2,end:4,monomers:["K","Y"]}]},tgt:[{seq:"PEPTIDE1{[Ac(1)].F.K.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-W3K"},{seq:"PEPTIDE1{[Ac(1)].F.W.K.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-G4K"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.K.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5K"},{seq:"PEPTIDE1{[Ac(1)].F.Y.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-W3Y"},{seq:"PEPTIDE1{[Ac(1)].F.W.Y.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-G4Y"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.Y.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5Y"}]},"breadth-double":{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:he.aK.Single,breadthPlaceholders:[{start:2,end:4,monomers:["K"]},{start:2,end:4,monomers:["Y"]}]},tgt:[{seq:"PEPTIDE1{[Ac(1)].F.Y.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-W3K-K3Y"},{seq:"PEPTIDE1{[Ac(1)].F.K.Y.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-W3K-G4Y"},{seq:"PEPTIDE1{[Ac(1)].F.K.G.Y.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-W3K-P5Y"},{seq:"PEPTIDE1{[Ac(1)].F.Y.K.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-G4K-W3Y"},{seq:"PEPTIDE1{[Ac(1)].F.W.Y.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-G4K-K4Y"},{seq:"PEPTIDE1{[Ac(1)].F.W.K.Y.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-G4K-P5Y"},{seq:"PEPTIDE1{[Ac(1)].F.Y.G.K.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5K-W3Y"},{seq:"PEPTIDE1{[Ac(1)].F.W.Y.K.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5K-G4Y"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.Y.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5K-K5Y"}]}};for(const[e,t]of Object.entries(o))x(`${e}`,(async()=>{E((0,de.o)(t.src,"",t.params),t.tgt.map((e=>[e.seq,e.name])))}))}));var pe=n(3309);function me(e,t){const n=t.get_mol(e);try{return w(n.is_valid(),!0,`RDKit rejected SMILES: ${e}`),n.get_smiles()}finally{n.delete()}}S("PolyTool: ChemEnum: R-labels",(()=>{x("extract from every supported form",(async()=>{E((0,pe.Qk)("C[1*]"),[1]),E((0,pe.Qk)("C[*:1]"),[1]),E((0,pe.Qk)("C[*1]"),[1]),E((0,pe.Qk)("C[R1]"),[1]),E((0,pe.Qk)("C[R:1]"),[1])})),x("extract multi-digit numbers",(async()=>{E((0,pe.Qk)("C1CC(C[*:100])(N[*:1])C([*:101])N1[*:2]"),[1,2,100,101]),E((0,pe.Qk)("C[R100]N[R:101]"),[100,101])})),x("normalize all spellings to [*:N]",(async()=>{w((0,pe.j7)("C[1*]"),"C[*:1]"),w((0,pe.j7)("C[*:1]"),"C[*:1]"),w((0,pe.j7)("C[*1]"),"C[*:1]"),w((0,pe.j7)("C[R1]"),"C[*:1]"),w((0,pe.j7)("C[R:1]"),"C[*:1]"),w((0,pe.j7)("C[R100]N[R:101]"),"C[*:100]N[*:101]")})),x("remap the one-and-only R-label to a new slot",(async()=>{w((0,pe.aj)("C[1*]",5),"C[*:5]"),w((0,pe.aj)("C[R:3]CC",1),"C[*:1]CC"),w((0,pe.aj)("[*:7]C",2),"[*:2]C")})),x("deduplicate repeated R numbers",(async()=>{E((0,pe.Qk)("C[*:1]C[*:1]"),[1])})),x("normalize does not touch regular bracket atoms",(async()=>{w((0,pe.j7)("C[NH3+]C[*:1]"),"C[NH3+]C[*:1]"),w((0,pe.j7)("[13C]C[*:2]"),"[13C]C[*:2]")}))})),S("PolyTool: ChemEnum: SMILES surgery",(()=>{x("moveStartRLabelToBranch: bare atom at start",(async()=>{w((0,pe.z9)("[*:1]CC"),"C([*:1])C"),w((0,pe.z9)("[*:1]Cl"),"Cl([*:1])"),w((0,pe.z9)("[*:1][NH3+]C"),"[NH3+]([*:1])C")})),x("moveStartRLabelToBranch: with explicit bond",(async()=>{w((0,pe.z9)("[*:1]=CC"),"C(=[*:1])C"),w((0,pe.z9)("[*:1]#C"),"C(#[*:1])")})),x("moveStartRLabelToBranch: leaves interior unchanged",(async()=>{w((0,pe.z9)("CC[*:1]"),"CC[*:1]"),w((0,pe.z9)("CC([*:1])CC"),"CC([*:1])CC")})),x("substituteRLabelWithRingDigit collapses branch form",(async()=>{w((0,pe.yw)("CC([*:1])CC",1,"9"),"CC9CC"),w((0,pe.yw)("CC([*:2])([*:1])CC",1,"%50"),"CC([*:2])%50CC")})),x("substituteRLabelWithRingDigit handles trailing form",(async()=>{w((0,pe.yw)("CC[*:1]",1,"7"),"CC7"),w((0,pe.yw)("CC=[*:2]",2,"%42"),"CC=%42")})),x("pickFreeRingDigits avoids digits already in use",(async()=>{const e=(0,pe.Ii)(["C1CCCCC1[*:1]","[*:1]C"],2);w(e.includes(1),!1),w(e.length,2)})),x("pickFreeRingDigits ignores digits inside bracket atoms",(async()=>{E((0,pe.Ii)(["C[*:1]","[*:1]C"],1),[1])}))})),S("PolyTool: ChemEnum: validators",(()=>{x("core without any R-label is rejected",(async()=>{w(null!=(0,pe.KS)("CCO","row 1").error,!0)})),x("r-group with zero R-labels is rejected",(async()=>{w(null!=(0,pe.ah)("CC",1,"row 1").error,!0)})),x("r-group with multiple R-labels is rejected",(async()=>{w(null!=(0,pe.ah)("[*:1]CC[*:2]",1,"row 1").error,!0)})),x("r-group with wrong R-number is auto-remapped",(async()=>{const e=(0,pe.ah)("CC[*:3]",1,"row 1");w(null==e.error,!0),w(e.rNumber,1),w(e.sourceRNumber,3),w(e.smiles,"CC[*:1]")}))})),S("PolyTool: ChemEnum: count & validate",(()=>{x("zip length mismatch is flagged",(async()=>{const e=(0,pe.KS)("C[*:1]C[*:2]","c1"),t=(0,pe.XB)({cores:[e],rGroups:new Map([[1,[(0,pe.ah)("C[*:1]",1,"r1-a"),(0,pe.ah)("N[*:1]",1,"r1-b")]],[2,[(0,pe.ah)("O[*:2]",2,"r2-a")]]]),mode:pe.PI.Zip});w(t.ok,!1),w(t.errors.some((e=>e.includes("Zip"))),!0)})),x("cartesian count = product across Rs, summed over cores",(async()=>{const e=(0,pe.KS)("C[*:1]","a"),t=(0,pe.KS)("C[*:1]N[*:2]","b"),n=(0,pe.XB)({cores:[e,t],rGroups:new Map([[1,[(0,pe.ah)("C[*:1]",1,"a"),(0,pe.ah)("N[*:1]",1,"b"),(0,pe.ah)("O[*:1]",1,"c")]],[2,[(0,pe.ah)("C[*:2]",2,"a"),(0,pe.ah)("N[*:2]",2,"b")]]]),mode:pe.PI.Cartesian});w(n.predictedCount,9),w(n.ok,!0)})),x("zip count = N per core, summed",(async()=>{const e=(0,pe.KS)("C[*:1]","a"),t=(0,pe.KS)("C[*:1]N[*:2]","b");w((0,pe.XB)({cores:[e,t],rGroups:new Map([[1,[(0,pe.ah)("C[*:1]",1,"a"),(0,pe.ah)("N[*:1]",1,"b")]],[2,[(0,pe.ah)("O[*:2]",2,"a"),(0,pe.ah)("S[*:2]",2,"b")]]]),mode:pe.PI.Zip}).predictedCount,4)})),x("uncovered R-number is flagged per core",(async()=>{const e=(0,pe.KS)("C[*:1]N[*:7]","c"),t=(0,pe.XB)({cores:[e],rGroups:new Map([[1,[(0,pe.ah)("O[*:1]",1,"a")]]]),mode:pe.PI.Cartesian});w(t.ok,!1),w(t.errors.some((e=>e.includes("R7"))),!0)})),x("hard cap rejects over-limit enumerations",(async()=>{const e=(0,pe.KS)("C[*:1]N[*:2]","c"),t=Array.from({length:1e3},((e,t)=>(0,pe.ah)("C[*:1]",1,`r1-${t}`))),n=Array.from({length:1001},((e,t)=>(0,pe.ah)("O[*:2]",2,`r2-${t}`))),o=(0,pe.XB)({cores:[e],rGroups:new Map([[1,t],[2,n]]),mode:pe.PI.Cartesian,maxResults:1e6});w(o.overCap,!0),w(o.ok,!1)})),x("countForCore: zip with mismatched per-core lengths → -1",(async()=>{const e=(0,pe.KS)("C[*:1]N[*:2]","c"),{count:t}=(0,pe.k5)(e,new Map([[1,[(0,pe.ah)("C[*:1]",1,"a"),(0,pe.ah)("N[*:1]",1,"b")]],[2,[(0,pe.ah)("O[*:2]",2,"a")]]]),pe.PI.Zip);w(t,-1)}))})),S("PolyTool: ChemEnum: assembly",(()=>{let e;N((async()=>{e=await(0,se.j)()})),x("single R-group: joins correctly",(async()=>{const t=(0,pe.BG)("C[*:1]",new Map([[1,"O[*:1]"]]),e);w(null!=t,!0),w(t,me("CO",e))})),x("multi R-group: R1 and R2 both joined",(async()=>{const t=(0,pe.BG)("C[*:1]N[*:2]",new Map([[1,"O[*:1]"],[2,"S[*:2]"]]),e);w(null!=t,!0),w(t,me("OCNS",e))})),x("R-label at SMILES start is handled",(async()=>{const t=(0,pe.BG)("[*:1]CC",new Map([[1,"Br[*:1]"]]),e);w(null!=t,!0),w(t,me("BrCC",e))})),x("core uses existing ring digit 1 — free digit is picked",(async()=>{const t=(0,pe.BG)("C1CCCCC1[*:1]",new Map([[1,"O[*:1]"]]),e);w(null!=t,!0),w(t,me("OC1CCCCC1",e))})),x("multi-digit R numbers (R100, R101)",(async()=>{const t=(0,pe.BG)("C1CC(C[*:100])(N[*:1])C([*:101])N1[*:2]",new Map([[1,"C[*:1]"],[2,"C[*:2]"],[100,"C[*:100]"],[101,"C[*:101]"]]),e);w(null!=t,!0);const n=e.get_mol(t);try{w(n.is_valid(),!0),w(t.includes("[*:"),!1)}finally{n.delete()}}))})),S("PolyTool: ChemEnum: enumerate",(()=>{let e;N((async()=>{e=await(0,se.j)()})),x("cartesian across two cores with different R-sets",(async()=>{const t=(0,pe.KS)("C[*:1]","A"),n=(0,pe.KS)("C[*:1]N[*:2]","B"),o=[(0,pe.ah)("O[*:1]",1,"r1-a"),(0,pe.ah)("S[*:1]",1,"r1-b")],r=[(0,pe.ah)("C[*:2]",2,"r2-a"),(0,pe.ah)("N[*:2]",2,"r2-b"),(0,pe.ah)("F[*:2]",2,"r2-c")],i=(0,pe.HL)({cores:[t,n],rGroups:new Map([[1,o],[2,r]]),mode:pe.PI.Cartesian},e);w(i.length,8);const s=i.filter((e=>"C[*:1]"===e.coreSmiles)),a=i.filter((e=>"C[*:1]N[*:2]"===e.coreSmiles));w(s.length,2),w(a.length,6)})),x("zip across two cores with shared R-list length",(async()=>{const t=(0,pe.KS)("C[*:1]","A"),n=(0,pe.KS)("C[*:1]N[*:2]","B"),o=[(0,pe.ah)("O[*:1]",1,"r1-a"),(0,pe.ah)("S[*:1]",1,"r1-b")],r=[(0,pe.ah)("C[*:2]",2,"r2-a"),(0,pe.ah)("N[*:2]",2,"r2-b")],i=(0,pe.HL)({cores:[t,n],rGroups:new Map([[1,o],[2,r]]),mode:pe.PI.Zip},e);w(i.length,4);const s=i.filter((e=>"C[*:1]N[*:2]"===e.coreSmiles));w(s.length,2),w(s[0].rGroupSmilesByNum.get(1),"O[*:1]"),w(s[0].rGroupSmilesByNum.get(2),"C[*:2]"),w(s[1].rGroupSmilesByNum.get(1),"S[*:1]"),w(s[1].rGroupSmilesByNum.get(2),"N[*:2]")})),x("invalid params return null from enumerate()",(async()=>{const t=(0,pe.KS)("C[*:1]N[*:2]","c");w((0,pe.HL)({cores:[t],rGroups:new Map([[1,[(0,pe.ah)("O[*:1]",1,"x")]]]),mode:pe.PI.Cartesian},e),null)}))})),S("PolyTool: ChemEnum: CSV fixtures",(()=>{let t;async function n(t){const n=await we.files.readAsText(t);return e.DataFrame.fromCsv(n)}N((async()=>{t=await(0,se.j)()})),x("cores file parses and all rows validate",(async()=>{const e=(await n("tests/chem_enum_cores.csv")).col("Core"),o=Array.from({length:e.length},((n,o)=>(0,pe.KS)(e.get(o),`Cores[${o}]`,t)));w(o.length,4),w(o.every((e=>!e.error)),!0,o.map((e=>e.error??"")).filter((e=>e)).join("; "));for(const e of o)w(e.rNumbers.includes(1)&&e.rNumbers.includes(2),!0,`core ${e.id} R-numbers: ${e.rNumbers}`)})),x("r-groups file: columns R1, R2, R3 populate their slots",(async()=>{const e=await n("tests/chem_enum_rgroups.csv"),o=(n,o)=>{const r=e.col(n),i=[];for(let e=0;e<r.length;e++){const s=r.get(e);null!=s&&""!==String(s).trim()&&i.push((0,pe.ah)(String(s),o,`${n}[${e}]`,t))}return i},r=o("R1",1),i=o("R2",2),s=o("R3",3);w(r.length,4),w(i.length,4),w(s.length,1);for(const e of[r,i,s])w(e.every((e=>!e.error)),!0,e.map((e=>e.error??"")).filter((e=>e)).join("; "))})),x("end-to-end cartesian with CSV fixtures produces valid, canonical SMILES",(async()=>{const e=await n("tests/chem_enum_cores.csv"),o=await n("tests/chem_enum_rgroups.csv"),r=e.col("Core"),i=Array.from({length:r.length},((e,n)=>(0,pe.KS)(r.get(n),`Cores[${n}]`,t))),s=new Map;for(const e of["R1","R2","R3"]){const n=parseInt(e.substring(1),10),r=o.col(e),i=[];for(let o=0;o<r.length;o++){const s=r.get(o);null!=s&&""!==String(s).trim()&&i.push((0,pe.ah)(String(s),n,`${e}[${o}]`,t))}s.set(n,i)}const a=(0,pe.HL)({cores:i,rGroups:s,mode:pe.PI.Cartesian},t);w(null!=a&&a.length>0,!0);for(const e of a){w(e.smiles.includes("[*:"),!1,`residual R-label in result: ${e.smiles}`);const n=t.get_mol(e.smiles);try{w(n.is_valid(),!0,`invalid SMILES: ${e.smiles}`)}finally{n.delete()}}}))}));var fe=n(6307),ge=n(2125);S("PolyTool: Chain: parseNotation",(()=>{let e;N((async()=>{e=await(0,ae.b2)()}));const t={cyclized:{src:{seq:"R-F-C(1)-T-G-H-F-Y-P-C(1)-meI"},tgt:{helm:"PEPTIDE1{R.F.[C(1)].T.G.H.F.Y.P.[C(1)].[meI]}$$$$V2.0"}},dimerized1:{src:{seq:"(#3)Succ-{A(CHOL)-F-C(1)-T-G-H-Y-P-C(1)-NH2}"},tgt:{helm:"PEPTIDE1{[(#3)Succ]}|PEPTIDE2{[A(CHOL)].F.[C(1)].T.G.H.Y.P.[C(1)].[NH2]}$PEPTIDE1,PEPTIDE2,1:R1-1:R1$$$V2.0"}},dimerized2:{src:{seq:"($3)Succ-{R-F-C(1)-T-G-H-F-P-C(1)-NH2}($2){A(CHOL)-F-C(1)-T-G-H-F-P-C(1)-NH2}"},tgt:{helm:"PEPTIDE1{[($3)Succ]}|PEPTIDE2{R.F.[C(1)].T.G.H.F.P.[C(1)].[NH2]}|PEPTIDE3{[($2)A(CHOL)].F.[C(1)].T.G.H.F.P.[C(1)].[NH2]}$PEPTIDE1,PEPTIDE2,1:R1-1:R1$$$V2.0"}}};for(const[n,o]of Object.entries(t))x(`${n}`,(async()=>{await(0,ue.Q4)(["rules_example.json"]);const t=await fe.s.fromSeparator(o.src.seq,e),n=t.mol,r=e.createHelmWebEditor();r.editor.setMol(n);const i=r.editor.getHelm(),s=t.getHelm();w(i,o.tgt.helm),w(s,o.tgt.helm)}),"reaction2"==n?{skipReason:"reverse reaction"}:void 0);const n={"0-in-4-4-3":{inIdx:0,spIdx:0,outIdx:0,monomers:[["0","1","2","3"],["4","5","6","7"],["8","9","10"]]},"3-in-4-4-3":{inIdx:3,spIdx:0,outIdx:3,monomers:[["0","1","2","3"],["4","5","6","7"],["8","9","10"]]},"4-in-4-4-3":{inIdx:0,spIdx:1,outIdx:4,monomers:[["0","1","2","3"],["4","5","6","7"],["8","9","10"]]},"7-in-4-4-3":{inIdx:3,spIdx:1,outIdx:7,monomers:[["0","1","2","3"],["4","5","6","7"],["8","9","10"]]},"8-in-4-4-3":{inIdx:0,spIdx:2,outIdx:8,monomers:[["0","1","2","3"],["4","5","6","7"],["8","9","10"]]},"0-in-1-1-6-3":{inIdx:0,spIdx:0,outIdx:0,monomers:[["0"],["1"],["2","3","4","5","6","7"],["8","9","10"]]},"1-in-1-1-6-3":{inIdx:0,spIdx:1,outIdx:1,monomers:[["0"],["1"],["2","3","4","5","6","7"],["8","9","10"]]},"2-in-1-1-6-3":{inIdx:0,spIdx:2,outIdx:2,monomers:[["0"],["1"],["2","3","4","5","6","7"],["8","9","10"]]},"3-in-1-1-6-3":{inIdx:1,spIdx:2,outIdx:3,monomers:[["0"],["1"],["2","3","4","5","6","7"],["8","9","10"]]},"7-in-1-1-6-3":{inIdx:5,spIdx:2,outIdx:7,monomers:[["0"],["1"],["2","3","4","5","6","7"],["8","9","10"]]},"8-in-1-1-6-3":{inIdx:0,spIdx:3,outIdx:8,monomers:[["0"],["1"],["2","3","4","5","6","7"],["8","9","10"]]}};for(const[e,{inIdx:t,spIdx:o,outIdx:r,monomers:i}]of Object.entries(n))x(`innerIdx-${e}`,(async()=>{const[e,n]=(0,ge.M)(r,i);w(e,t),w(n,o)}));for(const[e,{inIdx:t,spIdx:o,outIdx:r,monomers:i}]of Object.entries(n))x(`outerIdx-${e}`,(async()=>{w((0,ge.j)(t,o,i),r)}))})),S("PolyTool: Chain",(()=>{let e;N((async()=>{e=await(0,ae.b2)()}));const t={cyclized:{data:{templateSeq:"R-F-C(1)-T-G-H-F-Y-P-C(1)-meI",templateHelm:"PEPTIDE1{R.F.[C(1)].T.G.H.F.Y.P.[C(1)].[meI]}$$$$V2.0",mmHelm:"PEPTIDE1{R.F.C.T.G.H.F.Y.P.C.[meI]}$PEPTIDE1,PEPTIDE1,3:R3-10:R3$$$V2.0"},tgt:{templateChain:{monomerCount:[11],linkageCount:0},mmChain:{monomerCount:[11],linkageCount:0}}},dimerized1:{data:{templateSeq:"(#3)Succ-{A(CHOL)-F-C(1)-T-G-H-Y-P-C(1)-NH2}",templateHelm:"PEPTIDE1{[(#3)Succ]}|PEPTIDE2{[A(CHOL)].F.[C(1)].T.G.H.Y.P.[C(1)].[NH2]}$PEPTIDE1,PEPTIDE2,1:R1-1:R1$$$V2.0",mmHelm:"PEPTIDE1{[(#3)Succ].[{A(CHOL)].F.C.T.G.H.Y.P.C.[NH2}]}$PEPTIDE1,PEPTIDE1,4:R3-10:R3$$$V2.0"},tgt:{templateChain:{monomerCount:[1,10],linkageCount:1},mmChain:{monomerCount:[11],linkageCount:1}}},dimerized2:{data:{templateSeq:"($3)Succ-{R-F-C(1)-T-G-H-F-P-C(1)-NH2}($3){A(CHOL)-F-C(1)-Y-H-G-D-N-C(1)-meI}",templateHelm:"PEPTIDE1{[($3)Succ]}|PEPTIDE2{R.F.[C(1)].T.G.H.F.P.[C(1)].[NH2]}|PEPTIDE3{[($3)A(CHOL)].F.[C(1)].Y.H.G.D.N.[C(1)].[meI]}$PEPTIDE1,PEPTIDE2,1:R1-1:R1$$$V2.0",mmHelm:"PEPTIDE1{[($3)Succ].[{R].F.C.T.G.H.F.P.C.[NH2}($3){A(CHOL)].F.[C(1)].Y.H.G.D.N.[C(1)].[meI}]}$PEPTIDE1,PEPTIDE1,4:R3-10:R3$$$V2.0"},tgt:{templateChain:{monomerCount:[1,10,10],linkageCount:1},mmChain:{monomerCount:[20],linkageCount:1}}}};for(const[n,{data:o,tgt:r}]of Object.entries(t))x(`fromNotation-${n}`,(async()=>{const t=await(0,ue.Q4)(["rules_example.json"]),n=fe.s.fromSeparator(o.templateSeq,e);n.applyRules(t),n.check(!0),E(n.monomers.map((e=>e.length)),r.mmChain.monomerCount),w(n.linkages.length,r.mmChain.linkageCount),w(n.getHelm(),o.mmHelm)}),{skipReason:"3157"});for(const[n,{data:o,tgt:r}]of Object.entries(t))x(`parseNotation-${n}`,(async()=>{await(0,ue.Q4)(["rules_example.json"]);const t=fe.s.fromSeparator(o.templateSeq,e);t.check(!0),E(t.monomers.map((e=>e.length)),r.templateChain.monomerCount),w(t.linkages.length,r.templateChain.linkageCount),w(t.getHelm(),o.templateHelm),w(t.getNotation(),o.templateSeq)}));for(const[n,{data:o,tgt:r}]of Object.entries(t))x(`parseHelm-${n}`,(async()=>{await(0,ue.Q4)(["rules_example.json"]);const t=fe.s.fromHelm(o.templateHelm,e);t.check(!0),E(t.monomers.map((e=>e.length)),r.templateChain.monomerCount),w(t.linkages.length,r.templateChain.linkageCount),w(t.getHelm(),o.templateHelm),w(t.getNotation(),o.templateSeq)}));for(const[n,{data:o,tgt:r}]of Object.entries(t))x(`applyRules-${n}`,(async()=>{const t=await(0,ue.Q4)(["rules_example.json"]),n=fe.s.fromSeparator(o.templateSeq,e);n.applyRules(t),n.check(!0),E(n.monomers.map((e=>e.length)),r.mmChain.monomerCount),w(n.linkages.length,r.mmChain.linkageCount),w(n.getHelm(),o.mmHelm)}),{skipReason:"applyRules is not implemented"})})),S("toAtomicLevel",(()=>{let t,n,o;N((async()=>{n=await(0,J.pj)(),t=await re(),o=await(0,se.j)(),await n.loadMonomerLibForTests()})),I((async()=>{await ie(t),await n.loadMonomerLib(!0)})),x("override",(async()=>{const t=n.getMonomerLib(),r=await we.files.readAsText("tests/polytool-reaction-lib.json"),i=JSON.parse(r).find((e=>"GGaz"===e.symbol));w(null!=i,!0,"Monomer 'GGaz' not found.");const s={PEPTIDE:{GGaz:i}},a=t.override(s,"test"),l=await(0,W.Q)(),c=e.Column.fromList(e.COLUMN_TYPE.STRING,"helm",["PEPTIDE1{F.P.Y.[GGaz].H.A.A.G.G.A.C}|PEPTIDE2{A.A.A}$PEPTIDE1,PEPTIDE2,4:R4-1:R1|PEPTIDE1,PEPTIDE1,11:R2-4:R3$$$V2.0"]);c.semType=e.SEMTYPE.MACROMOLECULE,c.meta.units=z.Hi.HELM;const u=await l.helmToAtomicLevel(c,!1,!1,a);w(null!=u.molCol,!0,"Result molCol is null");const h=u.molCol.get(0);w(!!h,!0,"Molfile is empty");const d=o.get_mol(h);try{const e=d.get_inchi(),t=o.get_inchikey_for_inchi(e);w(d.get_num_bonds(),103),w(d.get_num_atoms(),98),w(t,"XPQUTLNSNIMERR-WKBTUBAPSA-N")}finally{d.delete()}})),x("getNewMonomer",(async()=>{const e=await(0,se.j)(),t=n.getMonomerLib(),o=(await(0,ue.Q4)(["rules_example.json"])).reactionRules.find((e=>"GGaz"==e.name)),[r,i]=(0,ce.T)(e,t,o);w(r?.[0],"azG_GGaz");const s=e.get_mol(i[0].molfile);try{const t=s.get_inchi();e.get_inchikey_for_inchi(t),w(s.get_num_bonds(),7),w(s.get_num_atoms(),8)}finally{s.delete()}}))}));var ye=n(5613),be=n(5733),ve=n(1536);const Ce="RNA1{m(G)[sp].m(A)[sp].[fl2r](C)p.[fl2r](U)p.r(G)p.r(A)p.r(A)p.r(U)p.r(A)p.r(U)p.r(A)p.r(A)p.r(A)p.r(C)p.r(U)p.r(U)p.m(G)p.m(U)[sp].m(G)[sp].[L3]}|RNA2{[fl2r](C)[sp].m(A)[sp].m(A)p.m(G)p.r(U)p.r(U)p.r(U)p.r(A)p.r(U)p.r(A)p.r(U)p.r(U)p.r(C)p.r(A)p.r(U)p.m(C)p.m(A)[sp].m(G)[sp].r(U)}$$$$",xe="RNA1{[lna](C)[sp].[lna](A)[sp].[lna](G)[sp].d(T)[sp].d(C)[sp].d(A)[sp]}$$$$";S("OligoRenderer: parser",(()=>{x("looksLikeHelm — positive",(async()=>{w((0,ye.yO)(Ce),!0),w((0,ye.yO)("RNA1{R(A)P}"),!0),w((0,ye.yO)("PEPTIDE1{A.C.G}"),!0)})),x("looksLikeHelm — negative",(async()=>{w((0,ye.yO)(""),!1),w((0,ye.yO)("AUCGUACGUAGCUAGCAU"),!1),w((0,ye.yO)("Af Cf Gf Uf"),!1)})),x("parses two-strand duplex",(async()=>{const e=(0,ye.On)(Ce);w(e.sense.type,"RNA"),w(e.sense.monomers.length,20),w(null!==e.antisense,!0),w(e.antisense.monomers.length,19)})),x("parses single-strand",(async()=>{const e=(0,ye.On)(xe);w(e.sense.monomers.length,6),w(e.antisense,null);const t=e.sense.monomers[0];w(t.kind,"nucleotide"),"nucleotide"===t.kind&&(w(t.sugar,"lna"),w(t.base,"C"),w(t.phosphate,"sp"))})),x("single-char unbracketed deoxyribose `d` parses correctly",(async()=>{const e=(0,ye.On)("RNA1{d(T)p.d(C)p.d(G)}$$$$");w(e.sense.monomers.length,3);const t=e.sense.monomers[0];"nucleotide"===t.kind&&(w(t.sugar,"d"),w(t.base,"T"),w(t.phosphate,"p"))})),x("parses bracketed conjugate",(async()=>{const e=(0,ye.On)(Ce),t=e.sense.monomers[e.sense.monomers.length-1];w(t.kind,"conjugate"),"conjugate"===t.kind&&w(t.symbol,"L3")})),x("handles empty / malformed without throwing",(async()=>{const e=(0,ye.On)("");w(e.sense.monomers.length,0),w(e.antisense,null),w((0,ye.On)("not a helm string").sense.monomers.length,0)})),x("passes through unknown sugar/phosphate symbols",(async()=>{const e=(0,ye.On)("RNA1{[xr](A)[zp].[yr](C)p}$$$$").sense.monomers[0];"nucleotide"===e.kind&&(w(e.sugar,"xr"),w(e.phosphate,"zp"))}))})),S("OligoRenderer: modification dictionary",(()=>{x("resolves HELMCore canonical sugars",(async()=>{w((0,ve.xh)("m","A").meta.short,"2'-OMe"),w((0,ve.xh)("fl2r","C").meta.short,"2'-F"),w((0,ve.xh)("lna","G").meta.short,"LNA"),w((0,ve.xh)("moe","A").meta.short,"2'-MOE")})),x("aliases legacy uppercase symbols to canonical",(async()=>{w((0,ve.xh)("mR","A").meta.name,(0,ve.xh)("m","A").meta.name),w((0,ve.xh)("fR","C").meta.name,(0,ve.xh)("fl2r","C").meta.name),w((0,ve.xh)("LR","G").meta.name,(0,ve.xh)("lna","G").meta.name),w((0,ve.xh)("dR","T").meta.name,(0,ve.xh)("d","T").meta.name)})),x("uses base-canonical color for unmodified ribose",(async()=>{const e=(0,ve.xh)("r","A"),t=(0,ve.xh)("r","C");w(e.color!==t.color,!0,`Unmodified A and C must use distinct canonical colors, got ${e.color} for both`)})),x("falls back to hash color for unknown sugar",(async()=>{const e=(0,ve.xh)("zzz","A");w(e.color.startsWith("hsl("),!0),w(e.meta.name,"zzz")})),x("hashColor is deterministic",(async()=>{w((0,ve.e8)("foo"),(0,ve.e8)("foo")),w((0,ve.e8)("foo")!==(0,ve.e8)("bar"),!0)})),x("PS phosphate (canonical and legacy) resolve to same color",(async()=>{w((0,ve.bM)("sp").color,ve.P4.sp.color),w((0,ve.bM)("sP").color,ve.P4.sp.color)})),x("GalNAc / L3 / Chol resolve as conjugates",(async()=>{w((0,ve.rK)("GalNAc").meta.category,"conjugate"),w((0,ve.rK)("L3").meta.category,"conjugate"),w((0,ve.rK)("Chol").meta.color,ve.pt.Chol.color)}))})),S("OligoRenderer: layout",(()=>{x("comfortable cell — chips fit width and height",(async()=>{const e=(0,ye.On)(Ce),t=(0,be.aA)(500,70,e);w(t.textOnlyFallback,!1),w(t.chipW>5,!0,"chip width should be larger than minimum"),w(t.chipW<=17,!0,"chip width should respect max (17)"),w(t.antiY>t.senseY,!0),w(t.senseChips.length>0,!0),w(t.antiChips.length>0,!0)})),x("compact cell — both strands still fit in 28px row",(async()=>{const e=(0,ye.On)(Ce),t=(0,be.aA)(300,28,e);w(t.antiY>0,!0),w(2*t.chipH+t.strandGap<=28,!0,"two strands must fit within 28px row")})),x("very narrow cell triggers text-only fallback",(async()=>{const e=(0,ye.On)(Ce),t=(0,be.aA)(60,30,e);w(t.textOnlyFallback,!0),w(t.senseChips.length,0)})),x("aspect ratio is preserved across sizes",(async()=>{const e=(0,ye.On)(Ce);for(const[t,n]of[[300,50],[500,70],[800,90]]){const o=(0,be.aA)(t,n,e),r=o.chipH/o.chipW;w(Math.abs(r-1.25)<.01,!0,`aspect ratio drifted at ${t}x${n}: got ${r.toFixed(3)}`)}})),x("single-strand layout",(async()=>{const e=(0,ye.On)(xe),t=(0,be.aA)(400,50,e);w(t.antiY,-1),w(t.antiChips.length,0)})),x("antisense reversed by default for pair-alignment",(async()=>{const e=(0,ye.On)(Ce),t=(0,be.aA)(800,70,e);w(t.antiReversed,!0);const n=e.antisense.monomers[e.antisense.monomers.length-1];w(t.antiChips[0].monomer===n,!0)})),x("pairAlign: false leaves antisense in data order",(async()=>{const e=(0,ye.On)(Ce),t=(0,be.aA)(800,70,e,{pairAlign:!1});w(t.antiReversed,!1),w(t.antiChips[0].monomer===e.antisense.monomers[0],!0)})),x("conjugate occupies a wider position; following chip does not overlap",(async()=>{const e=(0,ye.On)("RNA1{m(G)p.m(A)p.m(C)p.[L3]}|RNA2{m(C)p.m(A)p.m(A)p.r(G)}$$$$"),t=(0,be.aA)(600,70,e),n=t.senseChips[3];w(n.monomer.kind,"conjugate"),w(n.w>=t.chipW,!0,"conjugate must be at least chip-wide")}))})),S("OligoRenderer: hit testing",(()=>{x("hits each chip via stored positions",(async()=>{const e=(0,ye.On)(Ce),t=(0,be.aA)(800,70,e),n=t.senseChips[0],o=(0,be.CB)(n.x+n.w/2,t.senseY+t.chipH/2,e,t);w(null!==o,!0),w(o.strand,"sense"),w(o.position,0);const r=e.sense.monomers[0],i="nucleotide"===r.kind&&"sp"===r.phosphate,s=n.x+n.w+.1*t.chipGap,a=(0,be.CB)(s,t.senseY+t.chipH/2,e,t);i?(w(null!==a,!0),w(void 0!==a.linkage,!0)):w(a,null)})),x("antisense hit returns original position despite reversed display",(async()=>{const e=(0,ye.On)(Ce),t=(0,be.aA)(800,70,e),n=t.antiChips[0],o=(0,be.CB)(n.x+n.w/2,t.antiY+t.chipH/2,e,t);w(null!==o,!0),w(o.strand,"antisense"),w(o.position,e.antisense.monomers.length-1,"leftmost AS chip in pair-aligned display = last monomer in data")})),x("hovering between two chips with PS linkage returns the linkage",(async()=>{const e=(0,ye.On)("RNA1{m(G)[sp].m(A)p.m(C)p}$$$$"),t=(0,be.aA)(600,70,e),n=t.senseChips[0],o=t.senseChips[1],r=(n.x+n.w+o.x)/2,i=(0,be.CB)(r,t.senseY+t.chipH/2,e,t);w(null!==i,!0),w(void 0!==i.linkage,!0),w(i.linkage.phosphateSymbol,"sp")}))})),S("OligoRenderer: drawing smoke",(()=>{x("draws without error on offscreen canvas",(async()=>{const e=document.createElement("canvas");e.width=500,e.height=70;const t=e.getContext("2d"),n=(0,ye.On)(Ce);w((0,be.Z4)(t,0,0,500,70,n).textOnlyFallback,!1)})),x("handles unknown modifications without throwing",(async()=>{const e=document.createElement("canvas");e.width=200,e.height=50;const t=e.getContext("2d"),n=(0,ye.On)("RNA1{[xr](A)[zp].[yr](C)p}$$$$");(0,be.Z4)(t,0,0,200,50,n),w(!0,!0)})),x("renders legacy uppercase symbols via alias map",(async()=>{const e=document.createElement("canvas");e.width=400,e.height=50;const t=e.getContext("2d"),n=(0,ye.On)("RNA1{[mR](G)[sP].[mR](A)[sP].[fR](C)P.R(U)P}|RNA2{[mR](C)[sP].R(A)P.R(U)P.R(G)P}$$$$");(0,be.Z4)(t,0,0,400,50,n),w(n.sense.monomers.length,4),w(null!==n.antisense,!0)}))}));const we=new F;async function Ae(t,n,o){const d=await function(e){var t,n,o;return r(this,void 0,void 0,(function*(){const d=(null==e?void 0:e.nodeOptions)?e.nodeOptions.package:grok.functions.getCurrentCall().func.package;if(!d)throw new Error("Can't run tests outside of the package");const p=null===(t=d.packageOwner)||void 0===t?void 0:t.match(/<([^>]*)>/),m=p?p[1]:"";null!=d&&(yield P(d));const f=[];console.log("Running tests..."),console.log(e),null!=e||(e={}),null!==(n=(o=e).testContext)&&void 0!==n||(o.testContext=new v),grok.shell.clearLastError();const g=function(){const e=[];return console.log=(...t)=>{e.push(...t),a(...t)},console.info=(...t)=>{e.push(...t),l(...t)},console.warn=(...t)=>{e.push(...t),c(...t)},console.error=(...t)=>{e.push(...t),u(...t)},e}();yield function(e,t){var n,o,i,s,h,p;return r(this,void 0,void 0,(function*(){try{let l=null!=(null==t?void 0:t.skipToCategory),c=!1;for(const[u,g]of Object.entries(e)){if(null===(n=t.exclude)||void 0===n?void 0:n.some((e=>u.startsWith(e))))continue;if(null!=(null==t?void 0:t.category)&&!u.toLowerCase().startsWith(null==t?void 0:t.category.toLowerCase().trim()))continue;if(l)if(c)l=!1;else{if(null==(null==t?void 0:t.skipToCategory)||u.toLowerCase().trim()!==(null==t?void 0:t.skipToCategory.toLowerCase().trim()))continue;c=!0}const e=null===(o=g.tests)||void 0===o?void 0:o.every((e=>{var n;return(null===(n=e.options)||void 0===n?void 0:n.skipReason)||null!=(null==t?void 0:t.test)&&t.test.toLowerCase()!==e.name.toLowerCase()}));if(!e){const e=(null!==(i=g.tests)&&void 0!==i?i:[]).filter((e=>{var n;return(null===(n=e.options)||void 0===n?void 0:n.skipReason)||null!=(null==t?void 0:t.test)&&t.test.toLowerCase()!==e.name.toLowerCase()})).length;a(`Package testing: Started {{${u}}}${e>0?` skipped {{${e}}}`:""}`),g.beforeStatus=yield y(g.before,u)}let v,C=null!==(s=g.tests)&&void 0!==s?s:[];t.stressTest&&(C=C.filter((e=>{var t;return null===(t=e.options)||void 0===t?void 0:t.stressTest})),C=O(C)),(null!==(p=null===(h=t.tags)||void 0===h?void 0:h.length)&&void 0!==p?p:0)>0&&(C=C.filter((e=>{var n,o;return null===(o=null===(n=e.options)||void 0===n?void 0:n.tags)||void 0===o?void 0:o.some((e=>{var n;return(null!==(n=null==t?void 0:t.tags)&&void 0!==n?n:[]).includes(e)}))}))),g.beforeStatus?(v=Array.from(C.map((e=>({date:(new Date).toISOString(),category:u,name:e.name,success:!1,result:"before() failed",ms:0,skipped:!1,logs:"",owner:m,package:d.name,widgetsDifference:0,flaking:DG.Test.isReproducing})))),v.forEach((e=>r(this,void 0,void 0,(function*(){return yield grok.shell.reportTest("package",e)}))))):v=yield b(g,t,l);const x=v.filter((e=>"skipped"!=e.result));if(e||(g.afterStatus=yield y(g.after,u)),g.afterStatus&&(a(`Package testing: Category after() {{${u}}} failed`),a(`Package testing: Result for {{${u}}} after: ${g.afterStatus}`),x.push({date:(new Date).toISOString(),category:u,name:"after",success:!1,result:g.afterStatus,ms:0,skipped:!1,logs:"",owner:m,package:d.name,widgetsDifference:0,flaking:DG.Test.isReproducing})),g.beforeStatus&&(a(`Package testing: Category before() {{${u}}} failed`),a(`Package testing: Result for {{${u}}} before: ${g.beforeStatus}`),x.push({date:(new Date).toISOString(),category:u,name:"before",success:!1,result:g.beforeStatus,ms:0,skipped:!1,logs:"",owner:m,package:d.name,widgetsDifference:0,flaking:DG.Test.isReproducing})),f.push(...x),t.returnOnFail&&x.some((e=>!e.success&&!e.skipped&&e.name!==t.skipToTest)))break}}finally{console.log=a,console.info=l,console.warn=c,console.error=u}if(t.testContext.catchUnhandled&&!DG.Test.isInBenchmark){yield R(1e3);const e=yield grok.shell.lastError;if(null!=e){const t={logs:"",date:(new Date).toISOString(),category:"Unhandled exceptions",name:"Exception",result:null!=e?e:"",success:!e,ms:0,skipped:!1,owner:null!=m?m:"",package:d.name,widgetsDifference:0};a(`Package testing: Unhandled Exception: ${e}`),f.push(Object.assign(Object.assign({},t),{flaking:DG.Test.isReproducing&&!e})),t.package=d.name,yield grok.shell.reportTest("package",t)}}}))}(h,e);for(let e of f)e.result=e.result.toString().replace(/"/g,"'"),null!=e.logs&&(e.logs=e.logs.toString().replace(/"/g,"'"));return f;function y(e,t){return r(this,void 0,void 0,(function*(){let n;try{void 0!==e&&(yield $((()=>r(this,void 0,void 0,(function*(){yield e()}))),1e5,`before ${t}: timeout error`))}catch(e){n=yield _(e)}return n}))}function b(e,t,n){var o,a,l,c,u,h,p,f,y,b,v,x,w,A,T,E,S,N;return r(this,void 0,void 0,(function*(){let r=null!==(o=e.tests)&&void 0!==o?o:[];const I=[],M=C();if(e.clear){let o=n&&null!=t.skipToTest;for(let n=0;n<r.length;n++){r[n].options&&void 0===(null===(a=r[n].options)||void 0===a?void 0:a.benchmark)&&(r[n].options||(r[n].options={}),r[n].options.benchmark=null!==(l=e.benchmarks)&&void 0!==l&&l);let x=r[n];if(t.test&&t.test.toLowerCase()!==x.name.toLowerCase())continue;if(o){if(null==(null==t?void 0:t.skipToTest)||x.name.toLowerCase().trim()!==(null==t?void 0:t.skipToTest.toLowerCase().trim()))continue;o=!1}(null==x?void 0:x.options)&&(x.options.owner=null!==(p=null!==(h=null!==(u=null===(c=r[n].options)||void 0===c?void 0:c.owner)&&void 0!==u?u:null==e?void 0:e.owner)&&void 0!==h?h:m)&&void 0!==p?p:"");let w=yield L(x,null==t?void 0:t.test,g,DG.Test.isInBenchmark?null!==(y=null===(f=r[n].options)||void 0===f?void 0:f.benchmarkTimeout)&&void 0!==y?y:s:null!==(v=null===(b=r[n].options)||void 0===b?void 0:b.timeout)&&void 0!==v?v:i,d.name,t.verbose);if(w&&(I.push(Object.assign(Object.assign({},w),{widgetsDifference:C()-M})),t.returnOnFail&&t.skipToTest!==x.name&&!w.success&&!w.skipped))return I;t.nodeOptions||(grok.shell.closeAll(),DG.Balloon.closeAll())}}else{let o=n&&null!=t.skipToTest;for(let n=0;n<r.length;n++){let i=r[n];if(t.test&&t.test.toLowerCase()!==i.name.toLowerCase())continue;if(o){null!=(null==t?void 0:t.skipToTest)&&i.name.toLowerCase().trim()===(null==t?void 0:t.skipToTest.toLowerCase().trim())&&(o=!1);continue}(null==i?void 0:i.options)&&(i.options.owner=null!==(T=null!==(A=null!==(w=null===(x=r[n].options)||void 0===x?void 0:x.owner)&&void 0!==w?w:null==e?void 0:e.owner)&&void 0!==A?A:m)&&void 0!==T?T:"");let a=yield L(i,null==t?void 0:t.test,g,DG.Test.isInBenchmark?null!==(S=null===(E=r[n].options)||void 0===E?void 0:E.benchmarkTimeout)&&void 0!==S?S:s:null===(N=r[n].options)||void 0===N?void 0:N.timeout,d.name,t.verbose);if(a&&(I.push(Object.assign(Object.assign({},a),{widgetsDifference:C()-M})),t.returnOnFail&&t.skipToTest!==i.name&&!a.success&&!a.skipped))return I}}return I}))}function C(){var e;if("undefined"!=typeof process)return 0;let t=-1;try{t=DG.Widget.getAll().length}catch(t){console.warn(null!==(e=t.message)&&void 0!==e?e:t)}return t}}))}({category:t,test:n,testContext:o,verbose:!0});return e.DataFrame.fromObjects(d)}async function Te(){await P(we,we.getModule("package-test.js"))}})(),sequencetranslator_test=o})();
3
3
  //# sourceMappingURL=package-test.js.map