@datagrok/sequence-translator 1.10.3 → 1.10.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/package.js CHANGED
@@ -1,3 +1,3 @@
1
1
  /*! For license information please see package.js.LICENSE.txt */
2
- var sequencetranslator;(()=>{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:()=>u,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,u,c,h){const d=t.length,f=t.dataFrame,p=Math.max(navigator.hardwareConcurrency-2,1),m=new Array(p).fill(null).map((()=>new Worker(new URL(n.p+n.u(455),n.b)))),g=d/p,y=new Array(p),b=c.getSeqHandler(t),v="RNA"==l?a.o.NUCLEOTIDE:a.o.AA,w=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<p;t++){const n=m[t],r=Math.floor(t*g),i=t===p-1?d:Math.floor((t+1)*g);y[t]=new Promise((t=>{n.onmessage=e=>{t(e.data)}})),n.postMessage({seqList:w,monomersDict:e,alphabet:o,polymerType:l,start:r,end:i})}const C=[],A=[];await Promise.all(y).then((t=>{for(const e of t)C.push(...e.molfiles),A.push(...e.warnings)})),setTimeout((()=>{m.forEach((t=>{t.terminate()}))}),0);const x=(0,s.qj)(f,t.name),S=r.Column.fromType(r.COLUMN_TYPE.STRING,x,t.length).init((t=>C[t]?.molfile));return S.semType=r.SEMTYPE.MOLECULE,S.meta.units=r.UNITS.Molecule.MOLBLOCK,S.setTag(".sequence-src-col",t.name),{molCol:S,warnings:A}}function u(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:()=>u});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 u(t,e,n,i){if(0===t.length)return o.vF.createEmpty();const l=p,{atomCount:u,bondCount:h,needsCapping:f}=l(t,e,n,i),g=new Array(u),y=new Array(h);let b,v=null,w=null;"PEPTIDE"===i?b=c:(b=d,v=n===s.YI.DNA?(0,o.xb)(e,r.u.DEOXYRIBOSE):(0,o.xb)(e,r.u.RIBOSE),w=(0,o.xb)(e,r.u.PHOSPHATE));const C={i:0,nodeShift:0,bondShift:0,backbonePositionShift:new Array(2).fill(0),branchPositionShift:new Array(2).fill(0),backboneAttachNode:0,branchAttachNode:0,flipFactor:1},A={sugar:v,phosphate:w,seqLength:t.length,atomCount:u,bondCount:h},x=new o.Cg,S=[];let T,E=0;for(C.i=0;C.i<A.seqLength;++C.i){const n=t[C.i];if(n.symbol===s._S)continue;const r=(0,o.xb)(e,{symbol:n.symbol,polymerType:(0,a.Y)(n.biotype)});T=r.terminalR2Atom;const i=C.nodeShift,l=C.bondShift;b(r,g,y,C,A),r.stereoAtoms?.forEach((t=>S.push(t+E))),E+=r.atoms.x.length;const u=C.nodeShift-i,c=new Array(u);for(let t=0;t<u;++t)c[t]=i+t;const h=C.bondShift-l,d=new Array(h);for(let t=0;t<h;++t)d[t]=l+t;x.set(C.i,{biotype:n.biotype,symbol:n.symbol,atoms:c,bonds:d})}f&&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,C,A,T??r.u.OXYGEN);const _=r.u.V3K_BEGIN_COUNTS_LINE+u+" "+h+r.u.V3K_COUNTS_LINE_ENDING;let I="";return I+=r.u.V3K_HEADER_FIRST_LINE,I+=r.u.V3K_HEADER_SECOND_LINE,I+=r.u.V3K_BEGIN_CTAB_BLOCK,I+=_,I+=r.u.V3K_BEGIN_ATOM_BLOCK,I+=g.join(""),I+=r.u.V3K_END_ATOM_BLOCK,I+=r.u.V3K_BEGIN_BOND_BLOCK,I+=y.join(""),I+=r.u.V3K_END_BOND_BLOCK,S.length>0&&(I+=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`}(S)),I+=r.u.V3K_END_CTAB_BLOCK,I+=r.u.V3K_END,{molfile:I,monomers:x}}function c(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),f(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),f(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 f(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 u=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+u+"\n"}}function p(t,e,n,i){let l=0,u=0,c=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,u+=d.bonds.bondTypes.length,c++}if("PEPTIDE"===i)l+=1,u+=c,c>0&&((d?.meta?.rNodes?.length??0)<2||d?.terminalR2Atom?.toLowerCase()===r.u.HYDROGEN.toLowerCase())&&(h=!1,l-=1,u-=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,u+=(t.length-1)*a.bonds.bondTypes.length,u+=t.length*i.bonds.bondTypes.length,u-=1,u+=3*t.length}return{atomCount:l,bondCount:u,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:()=>p,eM:()=>m});var r=n(4328),o=n(6082),i=n(1991),s=n.n(i),a=n(439),l=n(3561),u=n(9235),c=n(294),h=n(9192),d=n(330),f=n(8123);async function p(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 c=e;const f=i.getSeqHandler(e);let p,g;f.notation!==a.Hi.SEPARATOR&&f.notation!==a.Hi.BILN&&(c=f.convert(a.Hi.SEPARATOR,"."),c.name=e.name);try{g=i.getSeqHandler(c).alphabet,p=(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}(c,i),b=m(y,p,g,n,l),v=c.length,w=await(0,u.R)(c,b,g,p,n,i,l);w.warnings.length>.05*v&&r.shell.warning(`Molfile conversion resulted in ${w.warnings.length} errors`);const C=o.Func.find({name:"convertToV3KViaOCL"})[0];if(C&&w.molCol)try{const t=w.molCol.toList(),e=await C.apply({mols:t});w.molCol.init((n=>e[n]?e[n]:t[n]))}catch(t){console.error(t)}return w}function m(t,e,n,r,o){const i=(0,l.Hb)(r,e,n),s={},u={value:null};if("RNA"===e){const t=n===a.YI.RNA?[f.u.RIBOSE,f.u.PHOSPHATE]:[f.u.DEOXYRIBOSE,f.u.PHOSPHATE];for(const n of t)g(s,n.symbol,i,o,e,u)}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,u),s[e]?.[t]&&(s[e][n]=s[e][t])}else g(s,n,i,o,e,u)}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,c.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),u=(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(f.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(f.u.V2K_A_LINE,r)}for(n=t.indexOf(f.u.V2K_RGP_LINE,0),r=t.indexOf("\n",n);-1!==n;){n+=f.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(f.u.V2K_RGP_LINE,r)}return e}(i),c=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(f.u.V2K_A_LINE,0);-1===e&&(e=t.indexOf(f.u.V2K_RGP_LINE));const n=t.indexOf(f.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(f.u.V3K_BEGIN_COUNTS_LINE)+f.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))}}(c),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(f.u.V3K_BEGIN_ATOM_BLOCK);s=t.indexOf("\n",s);let a=s;for(let l=0;l<e;l++){s=t.indexOf(f.u.V3K_BEGIN_DATA_LINE,s)+f.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}}(c,h.atomCount),p=function(t,e){const n=new Uint32Array(e),r=new Array(e),o=new Map,i=new Map;let s=t.indexOf(f.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(f.u.V3K_BEGIN_DATA_LINE,a)+f.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 u=t.indexOf("\n",s);let c=t.slice(a,u),h=c.indexOf(f.u.V3K_BOND_CONFIG);if(-1!==h){h=c.indexOf("=",h)+1;let t=c.indexOf(" ",h);-1===t&&(t=c.length);const e=parseInt(c.slice(h,t));o.set(l,e);const n=f.u.V3K_BOND_CONFIG+e.toString();c=c.replace(n,"")}c||i.set(l,c)}return{bondTypes:n,atomPairs:r,bondConfiguration:o,kwargs:i}}(c,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],u=e.atomPairs.find((t=>t.includes(s+1))).find((t=>t!==s+1))-1;let c=t.x.reduce(((e,n,r)=>{if(r===s)return e;if(r===u)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===c&&(c=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([u+1,c+1]),e.bondTypes=new Uint32Array([...e.bondTypes,1]),e.kwargs.set(e.atomPairs.length-1,"")),r.set(c+1,o),1===o)n.unshift(t.atomTypes[c]);else{if(2!==o)throw new Error(`Unexpected missing R-group: ${o}`);n.splice(1,0,t.atomTypes[c])}}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,p,a,u),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}(c),v={atoms:d,bonds:p,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;E(t,-r[e],-o[e]);const i=A(r[n],o[n]);x(t.atoms,-i),r[t.meta.rNodes[1]-1]<0&&S(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]===f.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){T(t,!0)}(t),x(t.atoms,-function(t,e){return A(t,e)+Math.PI/2}(t.atoms.x[t.meta.terminalNodes[1]-1],t.atoms.y[t.meta.terminalNodes[1]-1])))}(t,s),function(t,e){const n=t.atoms.x;n[t.meta.rNodes[1]-1]>n[e-1]&&function(t,e,n){const 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===f.u.RIBOSE.symbol||t===f.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;E(t,-n[o],-r[o]);const s=A(n[t.meta.rNodes[2]-1],r[t.meta.rNodes[2]-1]);x(t.atoms,-s),n[t.meta.rNodes[0]-1]>n[t.meta.rNodes[1]-1]&&S(t);const a=A(n[i],r[i]);x(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,E(t,-n[o],-r[o])}(v,o):t===f.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;E(t,-r[e],-o[e]);const i=A(r[n],o[n]);x(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;E(t,-n[o],-r[o]);const s=A(n[i],r[i]),a=e.value;if(!a)throw new Error("The value of sugarBranchToOYAngle is null");x(t.atoms,Math.PI-s+a);const u=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!=u)for(let t=0;t<n.length;++t)n[t]=(0,l.YN)(n[t]/u),r[t]=(0,l.YN)(r[t]/u)}(v,o),function(t,e,n){if("PEPTIDE"===t){b(e,t);const n=w(e,e.meta.rNodes[1]);n?.removedAtom&&(e.terminalR2Atom=n.removedAtom)}else n===f.u.RIBOSE.symbol||n===f.u.DEOXYRIBOSE.symbol?(w(e,e.meta.rNodes[1]),e.meta.rNodes[1]=e.meta.terminalNodes[1],y(e.bonds,e.meta),b(e,t),w(e,e.meta.rNodes[1]),w(e,e.meta.rNodes[0]),w(e,e.meta.rNodes[2])):n===f.u.PHOSPHATE.symbol&&(e.meta.terminalNodes[0]=e.meta.rNodes[0],E(e,-e.atoms.x[e.meta.terminalNodes[0]-1],-e.atoms.y[e.meta.terminalNodes[0]-1]),b(e,t),w(e,e.meta.rNodes[1]))}(r,v,t),function(t){let e=0;for(;e<t.atoms.atomTypes.length;)t.atoms.atomTypes[e]===f.u.HYDROGEN&&(w(t,e+1),--e),++e}(v),function(t){let e=0;for(;e<t.atoms.atomTypes.length;)"oh"===t.atoms.atomTypes[e]?.toLowerCase()&&(t.atoms.atomTypes[e]="O"),"?"===t.atoms.atomTypes[e]&&(t.atoms.atomTypes[e]="H"),++e}(v),function(t){const e=" RGROUPS=(1 1)";for(let n=0;n<(t.atoms.kwargs?.length??0);n++){const 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,c.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 w(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=C(Float32Array,r.x,n,1),r.y=C(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=C(Uint32Array,o.bondTypes,a,1),o.bondConfiguration.has(a)&&o.bondConfiguration.delete(a),o.kwargs.has(a)&&o.kwargs.delete(a),--a):(o.atomPairs[a][0]=t>e?t-1:t,o.atomPairs[a][1]=n>e?n-1:n),++a}let l=Array.from(o.bondConfiguration.keys());return l.forEach((t=>{if(o.bondConfiguration.has(t)&&t>n){const e=o.bondConfiguration.get(t);o.bondConfiguration.delete(t),o.bondConfiguration.set(t-1,e)}})),l=Array.from(o.kwargs.keys()),l.forEach((t=>{if(o.kwargs.has(t)&&t>n){const e=o.kwargs.get(t);o.kwargs.delete(t),o.kwargs.set(t-1,e)}})),s?{removedAtom:s}:void 0}}function C(t,e,n,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 A(t,e){let n;if(0===t)n=e>0?0:Math.PI;else if(0===e)n=t>0?-Math.PI/2:Math.PI/2;else{const r=e/t,o=Math.atan(r);n=t<0?Math.PI/2+o:-Math.PI/2+o}return n}function x(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 S(t){T(t,!1)}function T(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 E(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,YI:()=>o,_S:()=>l,b9:()=>u,gp:()=>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"}(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.a(o.PT,a.fasta.peptide,.5),new s.a(o.DNA,a.fasta.dna,.55),new s.a(o.RNA,a.fasta.rna,.55),""),u={[r.FASTA]:"-",[r.SEPARATOR]:"",[r.HELM]:"*",[r.BILN]:""}},2003:(t,e,n)=>{"use strict";n.d(e,{Hi:()=>r.Hi,YI:()=>r.YI,dh:()=>o.dh,gp:()=>r.gp,zS:()=>o.zS});var r=n(439),o=n(7291)},2738:(t,e,n)=>{"use strict";n.d(e,{a:()=>r});class r{constructor(t,e,n){this.name=t,this.alphabet=e,this.cutoff=n}}},7291:(t,e,n)=>{"use strict";n.d(e,{Mu:()=>y,dh:()=>v,zS:()=>A,qp:()=>w});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 u{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]}}u.SemType="Aminoacids",u.SemTypeMultipleAlignment="AminoacidsMultipleAlignment",u.undefinedColor="rgb(100,100,100)",u.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"},u.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"},u.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(*)*"},u.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 c{}c.SemType="Nucleotides",c.SemTypeMultipleAlignment="NucleotidesMultipleAlignment",c.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 f{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 p{}class m extends p{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=f.hashCode(t)%n;return d(m.palette[i])}}m._pallete=null,m.customMonomerColors={},m.polymerTypes=[];var g=n(8438);n(3599);class y{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 b extends y{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 u=n[2].split("-");if(2!==u.length)continue;const c=u[0].split(":"),h=u[1].split(":");if(2!==c.length||2!==h.length)continue;const d=parseInt(c[0])-1,f=parseInt(h[0])-1;d<0||d>=this.mListSeparated[i].length||f<0||f>=this.mListSeparated[s].length||t.connections.push({seq1Type:a,seq2Type:l,seqIndex1:i,seqIndex2:s,monomerIndex1:d,monomerIndex2:f,rGroup1:parseInt(c[1].substring(1)),rGroup2:parseInt(h[1].substring(1))})}}return t}}function v(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 y(r,s.b9[s.Hi.SEPARATOR])}return new y([],s.b9[s.Hi.SEPARATOR])}}const w=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 b(a,o??"",l,s.b9[s.Hi.HELM])},C=/([^\W_]+)/g;function A(t,e){if(t.length<=e)return t;const n=t.match(C),r=t.length>e||(n?.length??0)>1,o=n?.[0]??" ";return r?o.substring(0,e-1)+"…":o}},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={}))},8070:(t,e,n)=>{"use strict";n.d(e,{cb:()=>a,PE:()=>s}),n(4328);var r=n(6082);n(9982),r.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(r.Column.fromList(r.TYPE.BYTE_ARRAY,"BinaryImage",Array.from(new Uint8Array(11))));var o,i=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())}))};function s(t,e,n,r=0,o="timeout"){return i(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()}))}))}function a(t){return i(this,void 0,void 0,(function*(){yield new Promise((e=>setTimeout(e,t)))}))}console.log.bind(console),console.info.bind(console),console.warn.bind(console),console.error.bind(console),function(t){t.notNull=function(t,e){if(null==t)throw new Error(`${null==e?"Value":e} not defined`)}}(o||(o={})),r.DataFrame.fromColumns([r.Column.fromStrings("col",["val1","val2","val3"])])},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 -webkit-text-fill-color: transparent;\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,oCAAoC;EACpC,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 -webkit-text-fill-color: transparent;\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}\n\n.st-structure-mol-img {\n margin-right: 30px;\n float: right;\n}\n\n.st-structure-bool-button-block {\n justify-content: right;\n margin-bottom: 10px;\n}\n\n.st-structure-bottom {\n flex-direction: row-reverse;\n padding-top: 20px;\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;AACrB;;AAEA;EACE,kBAAkB;EAClB,YAAY;AACd;;AAEA;EACE,sBAAsB;EACtB,mBAAmB;AACrB;;AAEA;EACE,2BAA2B;EAC3B,iBAAiB;AACnB;;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}\n\n.st-structure-mol-img {\n margin-right: 30px;\n float: right;\n}\n\n.st-structure-bool-button-block {\n justify-content: right;\n margin-bottom: 10px;\n}\n\n.st-structure-bottom {\n flex-direction: row-reverse;\n padding-top: 20px;\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 u=0;u<t.length;u++){var c=[].concat(t[u]);r&&s[c[0]]||(void 0!==i&&(void 0===c[5]||(c[1]="@layer".concat(c[5].length>0?" ".concat(c[5]):""," {").concat(c[1],"}")),c[5]=i),n&&(c[2]?(c[1]="@media ".concat(c[2]," {").concat(c[1],"}"),c[2]=n):c[2]=n),o&&(c[4]?(c[1]="@supports (".concat(c[4],") {").concat(c[1],"}"),c[4]=o):c[4]="".concat(o)),e.push(c))}},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,u,c,h,d,f,p,m,g,y,b;i>=64;){for(s=n[0],a=n[1],l=n[2],u=n[3],c=n[4],h=n[5],d=n[6],f=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=((p=t[m-2])>>>17|p<<15)^(p>>>19|p<<13)^p>>>10,b=((p=t[m-15])>>>7|p<<25)^(p>>>18|p<<14)^p>>>3,t[m]=(y+t[m-7]|0)+(b+t[m-16]|0);for(m=0;m<64;m++)y=(((c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7))+(c&h^~c&d)|0)+(f+(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,f=d,d=h,h=c,c=u+y|0,u=l,l=a,a=s,s=y+b|0;n[0]+=s,n[1]+=a,n[2]+=l,n[3]+=u,n[4]+=c,n[5]+=h,n[6]+=d,n[7]+=f,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]),u=s(e,t),c=new o(u),h=new Uint8Array(c.digestLength),d=h.length,f=new Uint8Array(r),p=0;p<r;p++)d===h.length&&(a(h,c,n,i),d=0),f[p]=h[d++];return c.clean(),h.fill(0),i.fill(0),f},t.pbkdf2=function(t,e,n,r){for(var i=new o(t),s=i.digestLength,a=new Uint8Array(4),l=new Uint8Array(s),u=new Uint8Array(s),c=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(u);for(var f=0;f<s;f++)l[f]=u[f];for(f=2;f<=n;f++){i.reset(),i.update(u).finish(u);for(var p=0;p<s;p++)l[p]^=u[p]}for(f=0;f<s&&h*s+f<r;f++)c[h*s+f]=l[f]}for(h=0;h<s;h++)l[h]=u[h]=0;for(h=0;h<4;h++)a[h]=0;return i.clean(),c}}(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,u=128,c=1/0,h=9007199254740991,d=NaN,f=4294967295,p=[["ary",u],["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]",w="[object Function]",C="[object GeneratorFunction]",A="[object Map]",x="[object Number]",S="[object Object]",T="[object Promise]",E="[object RegExp]",_="[object Set]",I="[object String]",N="[object Symbol]",M="[object WeakMap]",O="[object ArrayBuffer]",L="[object DataView]",R="[object Float32Array]",P="[object Float64Array]",B="[object Int8Array]",D="[object Int16Array]",F="[object Int32Array]",k="[object Uint8Array]",H="[object Uint8ClampedArray]",U="[object Uint16Array]",$="[object Uint32Array]",V=/\b__p \+= '';/g,j=/\b(__p \+=) '' \+/g,q=/(__e\(.*?\)|\b__t\)) \+\n'';/g,G=/&(?:amp|lt|gt|quot|#39);/g,z=/[&<>"']/g,W=RegExp(G.source),Y=RegExp(z.source),K=/<%-([\s\S]+?)%>/g,J=/<%([\s\S]+?)%>/g,Q=/<%=([\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,ut=/[()=,{}\[\]\/\s]/,ct=/\\(\\)?/g,ht=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,dt=/\w*$/,ft=/^[-+]0x[0-9a-f]+$/i,pt=/^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=/($^)/,wt=/['\n\r\u2028\u2029\\]/g,Ct="\\ud800-\\udfff",At="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",xt="\\u2700-\\u27bf",St="a-z\\xdf-\\xf6\\xf8-\\xff",Tt="A-Z\\xc0-\\xd6\\xd8-\\xde",Et="\\ufe0e\\ufe0f",_t="\\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",It="["+Ct+"]",Nt="["+_t+"]",Mt="["+At+"]",Ot="\\d+",Lt="["+xt+"]",Rt="["+St+"]",Pt="[^"+Ct+_t+Ot+xt+St+Tt+"]",Bt="\\ud83c[\\udffb-\\udfff]",Dt="[^"+Ct+"]",Ft="(?:\\ud83c[\\udde6-\\uddff]){2}",kt="[\\ud800-\\udbff][\\udc00-\\udfff]",Ht="["+Tt+"]",Ut="\\u200d",$t="(?:"+Rt+"|"+Pt+")",Vt="(?:"+Ht+"|"+Pt+")",jt="(?:['’](?:d|ll|m|re|s|t|ve))?",qt="(?:['’](?:D|LL|M|RE|S|T|VE))?",Gt="(?:"+Mt+"|"+Bt+")?",zt="["+Et+"]?",Wt=zt+Gt+"(?:"+Ut+"(?:"+[Dt,Ft,kt].join("|")+")"+zt+Gt+")*",Yt="(?:"+[Lt,Ft,kt].join("|")+")"+Wt,Kt="(?:"+[Dt+Mt+"?",Mt,Ft,kt,It].join("|")+")",Jt=RegExp("['’]","g"),Qt=RegExp(Mt,"g"),Xt=RegExp(Bt+"(?="+Bt+")|"+Kt+Wt,"g"),Zt=RegExp([Ht+"?"+Rt+"+"+jt+"(?="+[Nt,Ht,"$"].join("|")+")",Vt+"+"+qt+"(?="+[Nt,Ht+$t,"$"].join("|")+")",Ht+"?"+$t+"+"+jt,Ht+"+"+qt,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Ot,Yt].join("|"),"g"),te=RegExp("["+Ut+Ct+At+Et+"]"),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[R]=oe[P]=oe[B]=oe[D]=oe[F]=oe[k]=oe[H]=oe[U]=oe[$]=!0,oe[m]=oe[g]=oe[O]=oe[y]=oe[L]=oe[b]=oe[v]=oe[w]=oe[A]=oe[x]=oe[S]=oe[E]=oe[_]=oe[I]=oe[M]=!1;var ie={};ie[m]=ie[g]=ie[O]=ie[L]=ie[y]=ie[b]=ie[R]=ie[P]=ie[B]=ie[D]=ie[F]=ie[A]=ie[x]=ie[S]=ie[E]=ie[_]=ie[I]=ie[N]=ie[k]=ie[H]=ie[U]=ie[$]=!0,ie[v]=ie[w]=ie[M]=!1;var se={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},ae=parseFloat,le=parseInt,ue="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,ce="object"==typeof self&&self&&self.Object===Object&&self,he=ue||ce||Function("return this")(),de=e&&!e.nodeType&&e,fe=de&&t&&!t.nodeType&&t,pe=fe&&fe.exports===de,me=pe&&ue.process,ge=function(){try{return fe&&fe.require&&fe.require("util").types||me&&me.binding&&me.binding("util")}catch(t){}}(),ye=ge&&ge.isArrayBuffer,be=ge&&ge.isDate,ve=ge&&ge.isMap,we=ge&&ge.isRegExp,Ce=ge&&ge.isSet,Ae=ge&&ge.isTypedArray;function xe(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 Se(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 Te(t,e){for(var n=-1,r=null==t?0:t.length;++n<r&&!1!==e(t[n],n,t););return t}function Ee(t,e){for(var n=null==t?0:t.length;n--&&!1!==e(t[n],n,t););return t}function _e(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 Ie(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 Ne(t,e){return!(null==t||!t.length)&&He(t,e,0)>-1}function Me(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 Oe(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 Re(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 Pe(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 Be(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 De=je("length");function Fe(t,e,n){var r;return n(t,(function(t,n,o){if(e(t,n,o))return r=n,!1})),r}function ke(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 He(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):ke(t,$e,n)}function Ue(t,e,n,r){for(var o=n-1,i=t.length;++o<i;)if(r(t[o],e))return o;return-1}function $e(t){return t!=t}function Ve(t,e){var n=null==t?0:t.length;return n?ze(t,e)/n:d}function je(t){return function(e){return null==e?o:e[t]}}function qe(t){return function(e){return null==t?o:t[e]}}function Ge(t,e,n,r,o){return o(t,(function(t,o,i){n=r?(r=!1,t):e(n,t,o,i)})),n}function ze(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 We(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 Je(t,e){return Oe(e,(function(e){return t[e]}))}function Qe(t,e){return t.has(e)}function Xe(t,e){for(var n=-1,r=t.length;++n<r&&He(e,t[n],0)>-1;);return n}function Ze(t,e){for(var n=t.length;n--&&He(e,t[n],0)>-1;);return n}var tn=qe({À:"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=qe({"&":"&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 un(t){var e=-1,n=Array(t.size);return t.forEach((function(t){n[++e]=[t,t]})),n}function cn(t){return rn(t)?function(t){for(var e=Xt.lastIndex=0;Xt.test(t);)++e;return e}(t):De(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 fn=qe({"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"}),pn=function t(e){var n,r=(e=null==e?he:pn.defaults(he.Object(),e,pn.pick(he,ne))).Array,ot=e.Date,Ct=e.Error,At=e.Function,xt=e.Math,St=e.Object,Tt=e.RegExp,Et=e.String,_t=e.TypeError,It=r.prototype,Nt=At.prototype,Mt=St.prototype,Ot=e["__core-js_shared__"],Lt=Nt.toString,Rt=Mt.hasOwnProperty,Pt=0,Bt=(n=/[^.]+$/.exec(Ot&&Ot.keys&&Ot.keys.IE_PROTO||""))?"Symbol(src)_1."+n:"",Dt=Mt.toString,Ft=Lt.call(St),kt=he._,Ht=Tt("^"+Lt.call(Rt).replace(et,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ut=pe?e.Buffer:o,$t=e.Symbol,Vt=e.Uint8Array,jt=Ut?Ut.allocUnsafe:o,qt=sn(St.getPrototypeOf,St),Gt=St.create,zt=Mt.propertyIsEnumerable,Wt=It.splice,Yt=$t?$t.isConcatSpreadable:o,Kt=$t?$t.iterator:o,Xt=$t?$t.toStringTag:o,te=function(){try{var t=ui(St,"defineProperty");return t({},"",{}),t}catch(t){}}(),se=e.clearTimeout!==he.clearTimeout&&e.clearTimeout,ue=ot&&ot.now!==he.Date.now&&ot.now,ce=e.setTimeout!==he.setTimeout&&e.setTimeout,de=xt.ceil,fe=xt.floor,me=St.getOwnPropertySymbols,ge=Ut?Ut.isBuffer:o,De=e.isFinite,qe=It.join,mn=sn(St.keys,St),gn=xt.max,yn=xt.min,bn=ot.now,vn=e.parseInt,wn=xt.random,Cn=It.reverse,An=ui(e,"DataView"),xn=ui(e,"Map"),Sn=ui(e,"Promise"),Tn=ui(e,"Set"),En=ui(e,"WeakMap"),_n=ui(St,"create"),In=En&&new En,Nn={},Mn=Fi(An),On=Fi(xn),Ln=Fi(Sn),Rn=Fi(Tn),Pn=Fi(En),Bn=$t?$t.prototype:o,Dn=Bn?Bn.valueOf:o,Fn=Bn?Bn.toString:o;function kn(t){if(ta(t)&&!js(t)&&!(t instanceof Vn)){if(t instanceof $n)return t;if(Rt.call(t,"__wrapped__"))return ki(t)}return new $n(t)}var Hn=function(){function t(){}return function(e){if(!Zs(e))return{};if(Gt)return Gt(e);t.prototype=e;var n=new t;return t.prototype=o,n}}();function Un(){}function $n(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__=f,this.__views__=[]}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 Gn(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 zn(t){var e=-1,n=null==t?0:t.length;for(this.__data__=new Gn;++e<n;)this.add(t[e])}function Wn(t){var e=this.__data__=new qn(t);this.size=e.size}function Yn(t,e){var n=js(t),r=!n&&Vs(t),o=!n&&!r&&Ws(t),i=!n&&!r&&!o&&la(t),s=n||r||o||i,a=s?We(t.length,Et):[],l=a.length;for(var u in t)!e&&!Rt.call(t,u)||s&&("length"==u||o&&("offset"==u||"parent"==u)||i&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||gi(u,l))||a.push(u);return a}function Kn(t){var e=t.length;return e?t[Gr(0,e-1)]:o}function Jn(t,e){return Li(_o(t),ir(e,0,t.length))}function Qn(t){return Li(_o(t))}function Xn(t,e,n){(n!==o&&!Hs(t[e],n)||n===o&&!(e in t))&&rr(t,e,n)}function Zn(t,e,n){var r=t[e];Rt.call(t,e)&&Hs(r,n)&&(n!==o||e in t)||rr(t,e,n)}function tr(t,e){for(var n=t.length;n--;)if(Hs(t[n][0],e))return n;return-1}function er(t,e,n,r){return cr(t,(function(t,o,i){e(r,t,n(t),i)})),r}function nr(t,e){return t&&Io(e,Ma(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:Ta(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,u=2&e,c=4&e;if(n&&(a=i?n(t,r,i,s):n(t)),a!==o)return a;if(!Zs(t))return t;var h=js(t);if(h){if(a=function(t){var e=t.length,n=new t.constructor(e);return e&&"string"==typeof t[0]&&Rt.call(t,"index")&&(n.index=t.index,n.input=t.input),n}(t),!l)return _o(t,a)}else{var d=di(t),f=d==w||d==C;if(Ws(t))return Co(t,l);if(d==S||d==m||f&&!i){if(a=u||f?{}:pi(t),!l)return u?function(t,e){return Io(t,hi(t),e)}(t,function(t,e){return t&&Io(e,Oa(e),t)}(a,t)):function(t,e){return Io(t,ci(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 O:return Ao(t);case y:case b:return new o(+t);case L:return function(t,e){var n=e?Ao(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}(t,n);case R:case P:case B:case D:case F:case k:case H:case U:case $:return xo(t,n);case A:return new o;case x:case I:return new o(t);case E:return function(t){var e=new t.constructor(t.source,dt.exec(t));return e.lastIndex=t.lastIndex,e}(t);case _:return new o;case N:return r=t,Dn?St(Dn.call(r)):{}}}(t,d,l)}}s||(s=new Wn);var p=s.get(t);if(p)return p;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:(c?u?ni:ei:u?Oa:Ma)(t);return Te(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=St(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 _t(i);return Ii((function(){t.apply(o,n)}),e)}function ur(t,e,n,r){var o=-1,i=Ne,s=!0,a=t.length,l=[],u=e.length;if(!a)return l;n&&(e=Oe(e,Ke(n))),r?(i=Me,s=!1):e.length>=200&&(i=Qe,s=!1,e=new zn(e));t:for(;++o<a;){var c=t[o],h=null==n?c:n(c);if(c=r||0!==c?c:0,s&&h==h){for(var d=u;d--;)if(e[d]===h)continue t;l.push(c)}else i(e,h,r)||l.push(c)}return l}kn.templateSettings={escape:K,evaluate:J,interpolate:Q,variable:"",imports:{_:kn}},kn.prototype=Un.prototype,kn.prototype.constructor=kn,$n.prototype=Hn(Un.prototype),$n.prototype.constructor=$n,Vn.prototype=Hn(Un.prototype),Vn.prototype.constructor=Vn,jn.prototype.clear=function(){this.__data__=_n?_n(null):{},this.size=0},jn.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},jn.prototype.get=function(t){var e=this.__data__;if(_n){var n=e[t];return n===s?o:n}return Rt.call(e,t)?e[t]:o},jn.prototype.has=function(t){var e=this.__data__;return _n?e[t]!==o:Rt.call(e,t)},jn.prototype.set=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=_n&&e===o?s:e,this},qn.prototype.clear=function(){this.__data__=[],this.size=0},qn.prototype.delete=function(t){var e=this.__data__,n=tr(e,t);return!(n<0||(n==e.length-1?e.pop():Wt.call(e,n,1),--this.size,0))},qn.prototype.get=function(t){var e=this.__data__,n=tr(e,t);return n<0?o:e[n][1]},qn.prototype.has=function(t){return tr(this.__data__,t)>-1},qn.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},Gn.prototype.clear=function(){this.size=0,this.__data__={hash:new jn,map:new(xn||qn),string:new jn}},Gn.prototype.delete=function(t){var e=ai(this,t).delete(t);return this.size-=e?1:0,e},Gn.prototype.get=function(t){return ai(this,t).get(t)},Gn.prototype.has=function(t){return ai(this,t).has(t)},Gn.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},zn.prototype.add=zn.prototype.push=function(t){return this.__data__.set(t,s),this},zn.prototype.has=function(t){return this.__data__.has(t)},Wn.prototype.clear=function(){this.__data__=new qn,this.size=0},Wn.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},Wn.prototype.get=function(t){return this.__data__.get(t)},Wn.prototype.has=function(t){return this.__data__.has(t)},Wn.prototype.set=function(t,e){var n=this.__data__;if(n instanceof qn){var r=n.__data__;if(!xn||r.length<199)return r.push([t,e]),this.size=++n.size,this;n=this.__data__=new Gn(r)}return n.set(t,e),this.size=n.size,this};var cr=Oo(br),hr=Oo(vr,!0);function dr(t,e){var n=!0;return cr(t,(function(t,r,o){return n=!!e(t,r,o)})),n}function fr(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,u=s}return u}function pr(t,e){var n=[];return cr(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,Ma)}function vr(t,e){return t&&yr(t,e,Ma)}function wr(t,e){return Ie(e,(function(e){return Js(t[e])}))}function Cr(t,e){for(var n=0,r=(e=yo(e,t)).length;null!=t&&n<r;)t=t[Di(e[n++])];return n&&n==r?t:o}function Ar(t,e,n){var r=e(t);return js(t)?r:Le(r,n(t))}function xr(t){return null==t?t===o?"[object Undefined]":"[object Null]":Xt&&Xt in St(t)?function(t){var e=Rt.call(t,Xt),n=t[Xt];try{t[Xt]=o;var r=!0}catch(t){}var i=Dt.call(t);return r&&(e?t[Xt]=n:delete t[Xt]),i}(t):function(t){return Dt.call(t)}(t)}function Sr(t,e){return t>e}function Tr(t,e){return null!=t&&Rt.call(t,e)}function Er(t,e){return null!=t&&e in St(t)}function _r(t,e,n){for(var i=n?Me:Ne,s=t[0].length,a=t.length,l=a,u=r(a),c=1/0,h=[];l--;){var d=t[l];l&&e&&(d=Oe(d,Ke(e))),c=yn(d.length,c),u[l]=!n&&(e||s>=120&&d.length>=120)?new zn(l&&d):o}d=t[0];var f=-1,p=u[0];t:for(;++f<s&&h.length<c;){var m=d[f],g=e?e(m):m;if(m=n||0!==m?m:0,!(p?Qe(p,g):i(h,g,n))){for(l=a;--l;){var y=u[l];if(!(y?Qe(y,g):i(t[l],g,n)))continue t}p&&p.push(g),h.push(m)}}return h}function Ir(t,e,n){var r=null==(t=Ti(t,e=yo(e,t)))?t:t[Di(Ki(e))];return null==r?o:xe(r,t,n)}function Nr(t){return ta(t)&&xr(t)==m}function Mr(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=js(t),l=js(e),u=a?g:di(t),c=l?g:di(e),h=(u=u==m?S:u)==S,d=(c=c==m?S:c)==S,f=u==c;if(f&&Ws(t)){if(!Ws(e))return!1;a=!0,h=!1}if(f&&!h)return s||(s=new Wn),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 O:return!(t.byteLength!=e.byteLength||!i(new Vt(t),new Vt(e)));case y:case b:case x:return Hs(+t,+e);case v:return t.name==e.name&&t.message==e.message;case E:case I:return t==e+"";case A:var a=on;case _:var l=1&r;if(a||(a=ln),t.size!=e.size&&!l)return!1;var u=s.get(t);if(u)return u==e;r|=2,s.set(t,e);var c=Zo(a(t),a(e),r,o,i,s);return s.delete(t),c;case N:if(Dn)return Dn.call(t)==Dn.call(e)}return!1}(t,e,u,n,r,i,s);if(!(1&n)){var p=h&&Rt.call(t,"__wrapped__"),w=d&&Rt.call(e,"__wrapped__");if(p||w){var C=p?t.value():t,T=w?e.value():e;return s||(s=new Wn),i(C,T,n,r,s)}}return!!f&&(s||(s=new Wn),function(t,e,n,r,i,s){var a=1&n,l=ei(t),u=l.length;if(u!=ei(e).length&&!a)return!1;for(var c=u;c--;){var h=l[c];if(!(a?h in e:Rt.call(e,h)))return!1}var d=s.get(t),f=s.get(e);if(d&&f)return d==e&&f==t;var p=!0;s.set(t,e),s.set(e,t);for(var m=a;++c<u;){var g=t[h=l[c]],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)){p=!1;break}m||(m="constructor"==h)}if(p&&!m){var v=t.constructor,w=e.constructor;v==w||!("constructor"in t)||!("constructor"in e)||"function"==typeof v&&v instanceof v&&"function"==typeof w&&w instanceof w||(p=!1)}return s.delete(t),s.delete(e),p}(t,e,n,r,i,s))}(t,e,n,r,Mr,i))}function Or(t,e,n,r){var i=n.length,s=i,a=!r;if(null==t)return!s;for(t=St(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 u=(l=n[i])[0],c=t[u],h=l[1];if(a&&l[2]){if(c===o&&!(u in t))return!1}else{var d=new Wn;if(r)var f=r(c,h,u,t,e,d);if(!(f===o?Mr(h,c,3,r,d):f))return!1}}return!0}function Lr(t){return!(!Zs(t)||(e=t,Bt&&Bt in e))&&(Js(t)?Ht:mt).test(Fi(t));var e}function Rr(t){return"function"==typeof t?t:null==t?nl:"object"==typeof t?js(t)?kr(t[0],t[1]):Fr(t):hl(t)}function Pr(t){if(!Ci(t))return mn(t);var e=[];for(var n in St(t))Rt.call(t,n)&&"constructor"!=n&&e.push(n);return e}function Br(t,e){return t<e}function Dr(t,e){var n=-1,o=Gs(t)?r(t.length):[];return cr(t,(function(t,r,i){o[++n]=e(t,r,i)})),o}function Fr(t){var e=li(t);return 1==e.length&&e[0][2]?xi(e[0][0],e[0][1]):function(n){return n===t||Or(n,t,e)}}function kr(t,e){return bi(t)&&Ai(e)?xi(Di(t),e):function(n){var r=Ta(n,t);return r===o&&r===e?Ea(n,t):Mr(e,r,3)}}function Hr(t,e,n,r,i){t!==e&&gr(e,(function(s,a){if(i||(i=new Wn),Zs(s))!function(t,e,n,r,i,s,a){var l=Ei(t,n),u=Ei(e,n),c=a.get(u);if(c)Xn(t,n,c);else{var h=s?s(l,u,n+"",t,e,a):o,d=h===o;if(d){var f=js(u),p=!f&&Ws(u),m=!f&&!p&&la(u);h=u,f||p||m?js(l)?h=l:zs(l)?h=_o(l):p?(d=!1,h=Co(u,!0)):m?(d=!1,h=xo(u,!0)):h=[]:ra(u)||Vs(u)?(h=l,Vs(l)?h=ga(l):Zs(l)&&!Js(l)||(h=pi(u))):d=!1}d&&(a.set(u,h),i(h,u,r,s,a),a.delete(u)),Xn(t,n,h)}}(t,e,a,n,Hr,r,i);else{var l=r?r(Ei(t,a),s,a+"",t,e,i):o;l===o&&(l=s),Xn(t,a,l)}}),Oa)}function Ur(t,e){var n=t.length;if(n)return gi(e+=e<0?n:0,n)?t[e]:o}function $r(t,e,n){e=e.length?Oe(e,(function(t){return js(t)?function(e){return Cr(e,1===t.length?t[0]:t)}:t})):[nl];var r=-1;e=Oe(e,Ke(si()));var o=Dr(t,(function(t,n,o){var i=Oe(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=So(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=Cr(t,s);n(a,s)&&Jr(i,yo(s,t),a)}return i}function jr(t,e,n,r){var o=r?Ue:He,i=-1,s=e.length,a=t;for(t===e&&(e=_o(e)),n&&(a=Oe(t,Ke(n)));++i<s;)for(var l=0,u=e[i],c=n?n(u):u;(l=o(a,c,l,r))>-1;)a!==t&&Wt.call(a,l,1),Wt.call(t,l,1);return t}function qr(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)?Wt.call(t,o,1):lo(t,o)}}return t}function Gr(t,e){return t+fe(wn()*(e-t+1))}function zr(t,e){var n="";if(!t||e<1||e>h)return n;do{e%2&&(n+=t),(e=fe(e/2))&&(t+=t)}while(e);return n}function Wr(t,e){return Ni(Si(t,e,nl),t+"")}function Yr(t){return Kn(Ha(t))}function Kr(t,e){var n=Ha(t);return Li(n,ir(e,0,n.length))}function Jr(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 u=Di(e[i]),c=n;if("__proto__"===u||"constructor"===u||"prototype"===u)return t;if(i!=a){var h=l[u];(c=r?r(h,u,l):o)===o&&(c=Zs(h)?h:gi(e[i+1])?[]:{})}Zn(l,u,c),l=l[u]}return t}var Qr=In?function(t,e){return In.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(Ha(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 cr(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,u=aa(e),c=e===o;i<s;){var h=fe((i+s)/2),d=n(t[h]),f=d!==o,p=null===d,m=d==d,g=aa(d);if(a)var y=r||m;else y=c?m&&(r||f):l?m&&f&&(r||!p):u?m&&f&&!p&&(r||!g):!p&&!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||!Hs(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(js(t))return Oe(t,so)+"";if(aa(t))return Fn?Fn.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function ao(t,e,n){var r=-1,o=Ne,i=t.length,s=!0,a=[],l=a;if(n)s=!1,o=Me;else if(i>=200){var u=e?null:Wo(t);if(u)return ln(u);s=!1,o=Qe,l=new zn}else l=e?[]:a;t:for(;++r<i;){var c=t[r],h=e?e(c):c;if(c=n||0!==c?c:0,s&&h==h){for(var d=l.length;d--;)if(l[d]===h)continue t;e&&l.push(h),a.push(c)}else o(l,h,n)||(l!==a&&l.push(h),a.push(c))}return a}function lo(t,e){return null==(t=Ti(t,e=yo(e,t)))||delete t[Di(Ki(e))]}function uo(t,e,n,r){return Jr(t,e,n(Cr(t,e)),r)}function co(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()),Re(e,(function(t,e){return e.func.apply(e.thisArg,Le([t],e.args))}),n)}function fo(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]=ur(s[i]||a,t[l],e,n));return ao(mr(s,1),e,n)}function po(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 zs(t)?t:[]}function go(t){return"function"==typeof t?t:nl}function yo(t,e){return js(t)?t:bi(t,e)?[t]:Bi(ya(t))}var bo=Wr;function vo(t,e,n){var r=t.length;return n=n===o?r:n,!e&&n>=r?t:to(t,e,n)}var wo=se||function(t){return he.clearTimeout(t)};function Co(t,e){if(e)return t.slice();var n=t.length,r=jt?jt(n):new t.constructor(n);return t.copy(r),r}function Ao(t){var e=new t.constructor(t.byteLength);return new Vt(e).set(new Vt(t)),e}function xo(t,e){var n=e?Ao(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}function So(t,e){if(t!==e){var n=t!==o,r=null===t,i=t==t,s=aa(t),a=e!==o,l=null===e,u=e==e,c=aa(e);if(!l&&!c&&!s&&t>e||s&&a&&u&&!l&&!c||r&&a&&u||!n&&u||!i)return 1;if(!r&&!s&&!c&&t<e||c&&n&&i&&!r&&!s||l&&n&&i||!a&&i||!u)return-1}return 0}function To(t,e,n,o){for(var i=-1,s=t.length,a=n.length,l=-1,u=e.length,c=gn(s-a,0),h=r(u+c),d=!o;++l<u;)h[l]=e[l];for(;++i<a;)(d||i<s)&&(h[n[i]]=t[i]);for(;c--;)h[l++]=t[i++];return h}function Eo(t,e,n,o){for(var i=-1,s=t.length,a=-1,l=n.length,u=-1,c=e.length,h=gn(s-l,0),d=r(h+c),f=!o;++i<h;)d[i]=t[i];for(var p=i;++u<c;)d[p+u]=e[u];for(;++a<l;)(f||i<s)&&(d[p+n[a]]=t[i++]);return d}function _o(t,e){var n=-1,o=t.length;for(e||(e=r(o));++n<o;)e[n]=t[n];return e}function Io(t,e,n,r){var i=!n;n||(n={});for(var s=-1,a=e.length;++s<a;){var l=e[s],u=r?r(n[l],t[l],l,n,t):o;u===o&&(u=t[l]),i?rr(n,l,u):Zn(n,l,u)}return n}function No(t,e){return function(n,r){var o=js(n)?Se:er,i=e?e():{};return o(n,t,si(r,2),i)}}function Mo(t){return Wr((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=St(e);++r<i;){var l=n[r];l&&t(e,l,r,s)}return e}))}function Oo(t,e){return function(n,r){if(null==n)return n;if(!Gs(n))return t(n,r);for(var o=n.length,i=e?o:-1,s=St(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=St(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 Ro(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 Po(t){return function(e){return Re(Ja(Va(e).replace(Jt,"")),t,"")}}function Bo(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=Hn(t.prototype),r=t.apply(n,e);return Zs(r)?r:n}}function Do(t){return function(e,n,r){var i=St(e);if(!Gs(e)){var s=si(n,3);e=Ma(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 Fo(t){return ti((function(e){var n=e.length,r=n,s=$n.prototype.thru;for(t&&e.reverse();r--;){var a=e[r];if("function"!=typeof a)throw new _t(i);if(s&&!l&&"wrapper"==oi(a))var l=new $n([],!0)}for(r=l?r:n;++r<n;){var u=oi(a=e[r]),c="wrapper"==u?ri(a):o;l=c&&vi(c[0])&&424==c[1]&&!c[4].length&&1==c[9]?l[oi(c[0])].apply(l,c[3]):1==a.length&&vi(a)?l[u]():l.thru(a)}return function(){var t=arguments,r=t[0];if(l&&1==t.length&&js(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 ko(t,e,n,i,s,a,l,c,h,d){var f=e&u,p=1&e,m=2&e,g=24&e,y=512&e,b=m?o:Bo(t);return function u(){for(var v=arguments.length,w=r(v),C=v;C--;)w[C]=arguments[C];if(g)var A=ii(u),x=function(t,e){for(var n=t.length,r=0;n--;)t[n]===e&&++r;return r}(w,A);if(i&&(w=To(w,i,s,g)),a&&(w=Eo(w,a,l,g)),v-=x,g&&v<d){var S=an(w,A);return Go(t,e,ko,u.placeholder,n,w,S,c,h,d-v)}var T=p?n:this,E=m?T[t]:t;return v=w.length,c?w=function(t,e){for(var n=t.length,r=yn(e.length,n),i=_o(t);r--;){var s=e[r];t[r]=gi(s,n)?i[s]:o}return t}(w,c):y&&v>1&&w.reverse(),f&&h<v&&(w.length=h),this&&this!==he&&this instanceof u&&(E=b||Bo(E)),E.apply(T,w)}}function Ho(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 Uo(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 $o(t){return ti((function(e){return e=Oe(e,Ke(si())),Wr((function(n){var r=this;return t(e,(function(t){return xe(t,r,n)}))}))}))}function Vo(t,e){var n=(e=e===o?" ":so(e)).length;if(n<2)return n?zr(e,t):e;var r=zr(e,de(t/cn(e)));return rn(e)?vo(hn(r),0,t).join(""):r.slice(0,t)}function jo(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 qo(t){return function(e,n){return"string"==typeof e&&"string"==typeof n||(e=ma(e),n=ma(n)),t(e,n)}}function Go(t,e,n,r,i,s,a,u,c,h){var d=8&e;e|=d?l:64,4&(e&=~(d?64:l))||(e&=-4);var f=[t,e,i,d?s:o,d?a:o,d?o:s,d?o:a,u,c,h],p=n.apply(o,f);return vi(t)&&_i(p,f),p.placeholder=r,Mi(p,t,e)}function zo(t){var e=xt[t];return function(t,n){if(t=ma(t),(n=null==n?0:yn(fa(n),292))&&De(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 Wo=Tn&&1/ln(new Tn([,-0]))[1]==c?function(t){return new Tn(t)}:al;function Yo(t){return function(e){var n=di(e);return n==A?on(e):n==_?un(e):function(t,e){return Oe(e,(function(e){return[e,t[e]]}))}(e,t(e))}}function Ko(t,e,n,s,c,h,d,f){var p=2&e;if(!p&&"function"!=typeof t)throw new _t(i);var m=s?s.length:0;if(m||(e&=-97,s=c=o),d=d===o?d:gn(fa(d),0),f=f===o?f:fa(f),m-=c?c.length:0,64&e){var g=s,y=c;s=c=o}var b=p?o:ri(t),v=[t,e,n,s,c,g,y,h,d,f];if(b&&function(t,e){var n=t[1],r=e[1],o=n|r,i=o<131,s=r==u&&8==n||r==u&&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 c=t[3];t[3]=c?To(c,l,e[4]):l,t[4]=c?an(t[3],a):e[4]}(l=e[5])&&(c=t[5],t[5]=c?Eo(c,l,e[6]):l,t[6]=c?an(t[5],a):e[6]),(l=e[7])&&(t[7]=l),r&u&&(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],c=v[4],!(f=v[9]=v[9]===o?p?0:t.length:gn(v[9]-m,0))&&24&e&&(e&=-25),e&&1!=e)w=8==e||16==e?function(t,e,n){var i=Bo(t);return function s(){for(var a=arguments.length,l=r(a),u=a,c=ii(s);u--;)l[u]=arguments[u];var h=a<3&&l[0]!==c&&l[a-1]!==c?[]:an(l,c);return(a-=h.length)<n?Go(t,e,ko,s.placeholder,o,l,h,o,o,n-a):xe(this&&this!==he&&this instanceof s?i:t,this,l)}}(t,e,f):e!=l&&33!=e||c.length?ko.apply(o,v):function(t,e,n,o){var i=1&e,s=Bo(t);return function e(){for(var a=-1,l=arguments.length,u=-1,c=o.length,h=r(c+l),d=this&&this!==he&&this instanceof e?s:t;++u<c;)h[u]=o[u];for(;l--;)h[u++]=arguments[++a];return xe(d,i?n:this,h)}}(t,e,n,s);else var w=function(t,e,n){var r=1&e,o=Bo(t);return function e(){return(this&&this!==he&&this instanceof e?o:t).apply(r?n:this,arguments)}}(t,e,n);return Mi((b?Qr:_i)(w,v),t,e)}function Jo(t,e,n,r){return t===o||Hs(t,Mt[n])&&!Rt.call(r,n)?e:t}function Qo(t,e,n,r,i,s){return Zs(t)&&Zs(e)&&(s.set(e,t),Hr(t,e,o,Qo,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,u=e.length;if(l!=u&&!(a&&u>l))return!1;var c=s.get(t),h=s.get(e);if(c&&h)return c==e&&h==t;var d=-1,f=!0,p=2&n?new zn: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;f=!1;break}if(p){if(!Be(e,(function(t,e){if(!Qe(p,e)&&(m===t||i(m,t,n,r,s)))return p.push(e)}))){f=!1;break}}else if(m!==g&&!i(m,g,n,r,s)){f=!1;break}}return s.delete(t),s.delete(e),f}function ti(t){return Ni(Si(t,o,qi),t+"")}function ei(t){return Ar(t,Ma,ci)}function ni(t){return Ar(t,Oa,hi)}var ri=In?function(t){return In.get(t)}:al;function oi(t){for(var e=t.name+"",n=Nn[e],r=Rt.call(Nn,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(Rt.call(kn,"placeholder")?kn:t).placeholder}function si(){var t=kn.iteratee||rl;return t=t===rl?Rr: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=Ma(t),n=e.length;n--;){var r=e[n],o=t[r];e[n]=[r,o,Ai(o)]}return e}function ui(t,e){var n=function(t,e){return null==t?o:t[e]}(t,e);return Lr(n)?n:o}var ci=me?function(t){return null==t?[]:(t=St(t),Ie(me(t),(function(e){return zt.call(t,e)})))}:pl,hi=me?function(t){for(var e=[];t;)Le(e,ci(t)),t=qt(t);return e}:pl,di=xr;function fi(t,e,n){for(var r=-1,o=(e=yo(e,t)).length,i=!1;++r<o;){var s=Di(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)&&(js(t)||Vs(t))}function pi(t){return"function"!=typeof t.constructor||Ci(t)?{}:Hn(qt(t))}function mi(t){return js(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?Gs(n)&&gi(e,n.length):"string"==r&&e in n)&&Hs(n[e],t)}function bi(t,e){if(js(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 St(e)}function vi(t){var e=oi(t),n=kn[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]}(An&&di(new An(new ArrayBuffer(1)))!=L||xn&&di(new xn)!=A||Sn&&di(Sn.resolve())!=T||Tn&&di(new Tn)!=_||En&&di(new En)!=M)&&(di=function(t){var e=xr(t),n=e==S?t.constructor:o,r=n?Fi(n):"";if(r)switch(r){case Mn:return L;case On:return A;case Ln:return T;case Rn:return _;case Pn:return M}return e});var wi=Ot?Js:ml;function Ci(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Mt)}function Ai(t){return t==t&&!Zs(t)}function xi(t,e){return function(n){return null!=n&&n[t]===e&&(e!==o||t in St(n))}}function Si(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),xe(t,this,l)}}function Ti(t,e){return e.length<2?t:Cr(t,to(e,0,-1))}function Ei(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var _i=Oi(Qr),Ii=ce||function(t,e){return he.setTimeout(t,e)},Ni=Oi(Xr);function Mi(t,e,n){var r=e+"";return Ni(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 Te(p,(function(n){var r="_."+n[0];e&n[1]&&!Ne(t,r)&&t.push(r)})),t.sort()}(function(t){var e=t.match(st);return e?e[1].split(at):[]}(r),n)))}function Oi(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=Gr(n,i),a=t[s];t[s]=t[n],t[n]=a}return t.length=e,t}var Ri,Pi,Bi=(Ri=Rs((function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(tt,(function(t,n,r,o){e.push(r?o.replace(ct,"$1"):n||t)})),e}),(function(t){return 500===Pi.size&&Pi.clear(),t})),Pi=Ri.cache,Ri);function Di(t){if("string"==typeof t||aa(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function Fi(t){if(null!=t){try{return Lt.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function ki(t){if(t instanceof Vn)return t.clone();var e=new $n(t.__wrapped__,t.__chain__);return e.__actions__=_o(t.__actions__),e.__index__=t.__index__,e.__values__=t.__values__,e}var Hi=Wr((function(t,e){return zs(t)?ur(t,mr(e,1,zs,!0)):[]})),Ui=Wr((function(t,e){var n=Ki(e);return zs(n)&&(n=o),zs(t)?ur(t,mr(e,1,zs,!0),si(n,2)):[]})),$i=Wr((function(t,e){var n=Ki(e);return zs(n)&&(n=o),zs(t)?ur(t,mr(e,1,zs,!0),o,n):[]}));function Vi(t,e,n){var r=null==t?0:t.length;if(!r)return-1;var o=null==n?0:fa(n);return o<0&&(o=gn(r+o,0)),ke(t,si(e,3),o)}function ji(t,e,n){var r=null==t?0:t.length;if(!r)return-1;var i=r-1;return n!==o&&(i=fa(n),i=n<0?gn(r+i,0):yn(i,r-1)),ke(t,si(e,3),i,!0)}function qi(t){return null!=t&&t.length?mr(t,1):[]}function Gi(t){return t&&t.length?t[0]:o}var zi=Wr((function(t){var e=Oe(t,mo);return e.length&&e[0]===t[0]?_r(e):[]})),Wi=Wr((function(t){var e=Ki(t),n=Oe(t,mo);return e===Ki(n)?e=o:n.pop(),n.length&&n[0]===t[0]?_r(n,si(e,2)):[]})),Yi=Wr((function(t){var e=Ki(t),n=Oe(t,mo);return(e="function"==typeof e?e:o)&&n.pop(),n.length&&n[0]===t[0]?_r(n,o,e):[]}));function Ki(t){var e=null==t?0:t.length;return e?t[e-1]:o}var Ji=Wr(Qi);function Qi(t,e){return t&&t.length&&e&&e.length?jr(t,e):t}var Xi=ti((function(t,e){var n=null==t?0:t.length,r=or(t,e);return qr(t,Oe(e,(function(t){return gi(t,n)?+t:t})).sort(So)),r}));function Zi(t){return null==t?t:Cn.call(t)}var ts=Wr((function(t){return ao(mr(t,1,zs,!0))})),es=Wr((function(t){var e=Ki(t);return zs(e)&&(e=o),ao(mr(t,1,zs,!0),si(e,2))})),ns=Wr((function(t){var e=Ki(t);return e="function"==typeof e?e:o,ao(mr(t,1,zs,!0),o,e)}));function rs(t){if(!t||!t.length)return[];var e=0;return t=Ie(t,(function(t){if(zs(t))return e=gn(t.length,e),!0})),We(e,(function(e){return Oe(t,je(e))}))}function os(t,e){if(!t||!t.length)return[];var n=rs(t);return null==e?n:Oe(n,(function(t){return xe(e,o,t)}))}var is=Wr((function(t,e){return zs(t)?ur(t,e):[]})),ss=Wr((function(t){return fo(Ie(t,zs))})),as=Wr((function(t){var e=Ki(t);return zs(e)&&(e=o),fo(Ie(t,zs),si(e,2))})),ls=Wr((function(t){var e=Ki(t);return e="function"==typeof e?e:o,fo(Ie(t,zs),o,e)})),us=Wr(rs),cs=Wr((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=kn(t);return e.__chain__=!0,e}function ds(t,e){return e(t)}var fs=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 $n(r,this.__chain__).thru((function(t){return e&&!t.length&&t.push(o),t}))):this.thru(i)})),ps=No((function(t,e,n){Rt.call(t,n)?++t[n]:rr(t,n,1)})),ms=Do(Vi),gs=Do(ji);function ys(t,e){return(js(t)?Te:cr)(t,si(e,3))}function bs(t,e){return(js(t)?Ee:hr)(t,si(e,3))}var vs=No((function(t,e,n){Rt.call(t,n)?t[n].push(e):rr(t,n,[e])})),ws=Wr((function(t,e,n){var o=-1,i="function"==typeof e,s=Gs(t)?r(t.length):[];return cr(t,(function(t){s[++o]=i?xe(e,t,n):Ir(t,e,n)})),s})),Cs=No((function(t,e,n){rr(t,n,e)}));function As(t,e){return(js(t)?Oe:Dr)(t,si(e,3))}var xs=No((function(t,e,n){t[n?0:1].push(e)}),(function(){return[[],[]]})),Ss=Wr((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]]),$r(t,mr(e,1),[])})),Ts=ue||function(){return he.Date.now()};function Es(t,e,n){return e=n?o:e,e=t&&null==e?t.length:e,Ko(t,u,o,o,o,o,e)}function _s(t,e){var n;if("function"!=typeof e)throw new _t(i);return t=fa(t),function(){return--t>0&&(n=e.apply(this,arguments)),t<=1&&(e=o),n}}var Is=Wr((function(t,e,n){var r=1;if(n.length){var o=an(n,ii(Is));r|=l}return Ko(t,r,e,n,o)})),Ns=Wr((function(t,e,n){var r=3;if(n.length){var o=an(n,ii(Ns));r|=l}return Ko(e,r,t,n,o)}));function Ms(t,e,n){var r,s,a,l,u,c,h=0,d=!1,f=!1,p=!0;if("function"!=typeof t)throw new _t(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-c;return c===o||n>=e||n<0||f&&t-h>=a}function y(){var t=Ts();if(g(t))return b(t);u=Ii(y,function(t){var n=e-(t-c);return f?yn(n,a-(t-h)):n}(t))}function b(t){return u=o,p&&r?m(t):(r=s=o,l)}function v(){var t=Ts(),n=g(t);if(r=arguments,s=this,c=t,n){if(u===o)return function(t){return h=t,u=Ii(y,e),d?m(t):l}(c);if(f)return wo(u),u=Ii(y,e),m(c)}return u===o&&(u=Ii(y,e)),l}return e=ma(e)||0,Zs(n)&&(d=!!n.leading,a=(f="maxWait"in n)?gn(ma(n.maxWait)||0,e):a,p="trailing"in n?!!n.trailing:p),v.cancel=function(){u!==o&&wo(u),h=0,r=c=s=u=o},v.flush=function(){return u===o?l:b(Ts())},v}var Os=Wr((function(t,e){return lr(t,1,e)})),Ls=Wr((function(t,e,n){return lr(t,ma(e)||0,n)}));function Rs(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new _t(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(Rs.Cache||Gn),n}function Ps(t){if("function"!=typeof t)throw new _t(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)}}Rs.Cache=Gn;var Bs=bo((function(t,e){var n=(e=1==e.length&&js(e[0])?Oe(e[0],Ke(si())):Oe(mr(e,1),Ke(si()))).length;return Wr((function(r){for(var o=-1,i=yn(r.length,n);++o<i;)r[o]=e[o].call(this,r[o]);return xe(t,this,r)}))})),Ds=Wr((function(t,e){var n=an(e,ii(Ds));return Ko(t,l,o,e,n)})),Fs=Wr((function(t,e){var n=an(e,ii(Fs));return Ko(t,64,o,e,n)})),ks=ti((function(t,e){return Ko(t,256,o,o,o,e)}));function Hs(t,e){return t===e||t!=t&&e!=e}var Us=qo(Sr),$s=qo((function(t,e){return t>=e})),Vs=Nr(function(){return arguments}())?Nr:function(t){return ta(t)&&Rt.call(t,"callee")&&!zt.call(t,"callee")},js=r.isArray,qs=ye?Ke(ye):function(t){return ta(t)&&xr(t)==O};function Gs(t){return null!=t&&Xs(t.length)&&!Js(t)}function zs(t){return ta(t)&&Gs(t)}var Ws=ge||ml,Ys=be?Ke(be):function(t){return ta(t)&&xr(t)==b};function Ks(t){if(!ta(t))return!1;var e=xr(t);return e==v||"[object DOMException]"==e||"string"==typeof t.message&&"string"==typeof t.name&&!ra(t)}function Js(t){if(!Zs(t))return!1;var e=xr(t);return e==w||e==C||"[object AsyncFunction]"==e||"[object Proxy]"==e}function Qs(t){return"number"==typeof t&&t==fa(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)==A};function na(t){return"number"==typeof t||ta(t)&&xr(t)==x}function ra(t){if(!ta(t)||xr(t)!=S)return!1;var e=qt(t);if(null===e)return!0;var n=Rt.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&Lt.call(n)==Ft}var oa=we?Ke(we):function(t){return ta(t)&&xr(t)==E},ia=Ce?Ke(Ce):function(t){return ta(t)&&di(t)==_};function sa(t){return"string"==typeof t||!js(t)&&ta(t)&&xr(t)==I}function aa(t){return"symbol"==typeof t||ta(t)&&xr(t)==N}var la=Ae?Ke(Ae):function(t){return ta(t)&&Xs(t.length)&&!!oe[xr(t)]},ua=qo(Br),ca=qo((function(t,e){return t<=e}));function ha(t){if(!t)return[];if(Gs(t))return sa(t)?hn(t):_o(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==A?on:e==_?ln:Ha)(t)}function da(t){return t?(t=ma(t))===c||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}function fa(t){var e=da(t),n=e%1;return e==e?n?e-n:e:0}function pa(t){return t?ir(fa(t),0,f):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=pt.test(t);return n||gt.test(t)?le(t.slice(2),n?2:8):ft.test(t)?d:+t}function ga(t){return Io(t,Oa(t))}function ya(t){return null==t?"":so(t)}var ba=Mo((function(t,e){if(Ci(e)||Gs(e))Io(e,Ma(e),t);else for(var n in e)Rt.call(e,n)&&Zn(t,n,e[n])})),va=Mo((function(t,e){Io(e,Oa(e),t)})),wa=Mo((function(t,e,n,r){Io(e,Oa(e),t,r)})),Ca=Mo((function(t,e,n,r){Io(e,Ma(e),t,r)})),Aa=ti(or),xa=Wr((function(t,e){t=St(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=Oa(s),l=-1,u=a.length;++l<u;){var c=a[l],h=t[c];(h===o||Hs(h,Mt[c])&&!Rt.call(t,c))&&(t[c]=s[c])}return t})),Sa=Wr((function(t){return t.push(o,Qo),xe(Ra,o,t)}));function Ta(t,e,n){var r=null==t?o:Cr(t,e);return r===o?n:r}function Ea(t,e){return null!=t&&fi(t,e,Er)}var _a=Ho((function(t,e,n){null!=e&&"function"!=typeof e.toString&&(e=Dt.call(e)),t[e]=n}),Za(nl)),Ia=Ho((function(t,e,n){null!=e&&"function"!=typeof e.toString&&(e=Dt.call(e)),Rt.call(t,e)?t[e].push(n):t[e]=[n]}),si),Na=Wr(Ir);function Ma(t){return Gs(t)?Yn(t):Pr(t)}function Oa(t){return Gs(t)?Yn(t,!0):function(t){if(!Zs(t))return function(t){var e=[];if(null!=t)for(var n in St(t))e.push(n);return e}(t);var e=Ci(t),n=[];for(var r in t)("constructor"!=r||!e&&Rt.call(t,r))&&n.push(r);return n}(t)}var La=Mo((function(t,e,n){Hr(t,e,n)})),Ra=Mo((function(t,e,n,r){Hr(t,e,n,r)})),Pa=ti((function(t,e){var n={};if(null==t)return n;var r=!1;e=Oe(e,(function(e){return e=yo(e,t),r||(r=e.length>1),e})),Io(t,ni(t),n),r&&(n=sr(n,7,Xo));for(var o=e.length;o--;)lo(n,e[o]);return n})),Ba=ti((function(t,e){return null==t?{}:function(t,e){return Vr(t,e,(function(e,n){return Ea(t,n)}))}(t,e)}));function Da(t,e){if(null==t)return{};var n=Oe(ni(t),(function(t){return[t]}));return e=si(e),Vr(t,n,(function(t,n){return e(t,n[0])}))}var Fa=Yo(Ma),ka=Yo(Oa);function Ha(t){return null==t?[]:Je(t,Ma(t))}var Ua=Po((function(t,e,n){return e=e.toLowerCase(),t+(n?$a(e):e)}));function $a(t){return Ka(ya(t).toLowerCase())}function Va(t){return(t=ya(t))&&t.replace(bt,tn).replace(Qt,"")}var ja=Po((function(t,e,n){return t+(n?"-":"")+e.toLowerCase()})),qa=Po((function(t,e,n){return t+(n?" ":"")+e.toLowerCase()})),Ga=Ro("toLowerCase"),za=Po((function(t,e,n){return t+(n?"_":"")+e.toLowerCase()})),Wa=Po((function(t,e,n){return t+(n?" ":"")+Ka(e)})),Ya=Po((function(t,e,n){return t+(n?" ":"")+e.toUpperCase()})),Ka=Ro("toUpperCase");function Ja(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 Qa=Wr((function(t,e){try{return xe(t,o,e)}catch(t){return Ks(t)?t:new Ct(t)}})),Xa=ti((function(t,e){return Te(e,(function(e){e=Di(e),rr(t,e,Is(t[e],t))})),t}));function Za(t){return function(){return t}}var tl=Fo(),el=Fo(!0);function nl(t){return t}function rl(t){return Rr("function"==typeof t?t:sr(t,1))}var ol=Wr((function(t,e){return function(n){return Ir(n,t,e)}})),il=Wr((function(t,e){return function(n){return Ir(t,n,e)}}));function sl(t,e,n){var r=Ma(e),o=wr(e,r);null!=n||Zs(e)&&(o.length||!r.length)||(n=e,e=t,t=this,o=wr(e,Ma(e)));var i=!(Zs(n)&&"chain"in n&&!n.chain),s=Js(t);return Te(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__=_o(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=$o(Oe),ul=$o(_e),cl=$o(Be);function hl(t){return bi(t)?je(Di(t)):function(t){return function(e){return Cr(e,t)}}(t)}var dl=jo(),fl=jo(!0);function pl(){return[]}function ml(){return!1}var gl,yl=Uo((function(t,e){return t+e}),0),bl=zo("ceil"),vl=Uo((function(t,e){return t/e}),1),wl=zo("floor"),Cl=Uo((function(t,e){return t*e}),1),Al=zo("round"),xl=Uo((function(t,e){return t-e}),0);return kn.after=function(t,e){if("function"!=typeof e)throw new _t(i);return t=fa(t),function(){if(--t<1)return e.apply(this,arguments)}},kn.ary=Es,kn.assign=ba,kn.assignIn=va,kn.assignInWith=wa,kn.assignWith=Ca,kn.at=Aa,kn.before=_s,kn.bind=Is,kn.bindAll=Xa,kn.bindKey=Ns,kn.castArray=function(){if(!arguments.length)return[];var t=arguments[0];return js(t)?t:[t]},kn.chain=hs,kn.chunk=function(t,e,n){e=(n?yi(t,e,n):e===o)?1:gn(fa(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},kn.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},kn.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(js(n)?_o(n):[n],mr(e,1))},kn.cond=function(t){var e=null==t?0:t.length,n=si();return t=e?Oe(t,(function(t){if("function"!=typeof t[1])throw new _t(i);return[n(t[0]),t[1]]})):[],Wr((function(n){for(var r=-1;++r<e;){var o=t[r];if(xe(o[0],this,n))return xe(o[1],this,n)}}))},kn.conforms=function(t){return function(t){var e=Ma(t);return function(n){return ar(n,t,e)}}(sr(t,1))},kn.constant=Za,kn.countBy=ps,kn.create=function(t,e){var n=Hn(t);return null==e?n:nr(n,e)},kn.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},kn.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},kn.debounce=Ms,kn.defaults=xa,kn.defaultsDeep=Sa,kn.defer=Os,kn.delay=Ls,kn.difference=Hi,kn.differenceBy=Ui,kn.differenceWith=$i,kn.drop=function(t,e,n){var r=null==t?0:t.length;return r?to(t,(e=n||e===o?1:fa(e))<0?0:e,r):[]},kn.dropRight=function(t,e,n){var r=null==t?0:t.length;return r?to(t,0,(e=r-(e=n||e===o?1:fa(e)))<0?0:e):[]},kn.dropRightWhile=function(t,e){return t&&t.length?co(t,si(e,3),!0,!0):[]},kn.dropWhile=function(t,e){return t&&t.length?co(t,si(e,3),!0):[]},kn.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=fa(n))<0&&(n=-n>i?0:i+n),(r=r===o||r>i?i:fa(r))<0&&(r+=i),r=n>r?0:pa(r);n<r;)t[n++]=e;return t}(t,e,n,r)):[]},kn.filter=function(t,e){return(js(t)?Ie:pr)(t,si(e,3))},kn.flatMap=function(t,e){return mr(As(t,e),1)},kn.flatMapDeep=function(t,e){return mr(As(t,e),c)},kn.flatMapDepth=function(t,e,n){return n=n===o?1:fa(n),mr(As(t,e),n)},kn.flatten=qi,kn.flattenDeep=function(t){return null!=t&&t.length?mr(t,c):[]},kn.flattenDepth=function(t,e){return null!=t&&t.length?mr(t,e=e===o?1:fa(e)):[]},kn.flip=function(t){return Ko(t,512)},kn.flow=tl,kn.flowRight=el,kn.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},kn.functions=function(t){return null==t?[]:wr(t,Ma(t))},kn.functionsIn=function(t){return null==t?[]:wr(t,Oa(t))},kn.groupBy=vs,kn.initial=function(t){return null!=t&&t.length?to(t,0,-1):[]},kn.intersection=zi,kn.intersectionBy=Wi,kn.intersectionWith=Yi,kn.invert=_a,kn.invertBy=Ia,kn.invokeMap=ws,kn.iteratee=rl,kn.keyBy=Cs,kn.keys=Ma,kn.keysIn=Oa,kn.map=As,kn.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},kn.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},kn.matches=function(t){return Fr(sr(t,1))},kn.matchesProperty=function(t,e){return kr(t,sr(e,1))},kn.memoize=Rs,kn.merge=La,kn.mergeWith=Ra,kn.method=ol,kn.methodOf=il,kn.mixin=sl,kn.negate=Ps,kn.nthArg=function(t){return t=fa(t),Wr((function(e){return Ur(e,t)}))},kn.omit=Pa,kn.omitBy=function(t,e){return Da(t,Ps(si(e)))},kn.once=function(t){return _s(2,t)},kn.orderBy=function(t,e,n,r){return null==t?[]:(js(e)||(e=null==e?[]:[e]),js(n=r?o:n)||(n=null==n?[]:[n]),$r(t,e,n))},kn.over=ll,kn.overArgs=Bs,kn.overEvery=ul,kn.overSome=cl,kn.partial=Ds,kn.partialRight=Fs,kn.partition=xs,kn.pick=Ba,kn.pickBy=Da,kn.property=hl,kn.propertyOf=function(t){return function(e){return null==t?o:Cr(t,e)}},kn.pull=Ji,kn.pullAll=Qi,kn.pullAllBy=function(t,e,n){return t&&t.length&&e&&e.length?jr(t,e,si(n,2)):t},kn.pullAllWith=function(t,e,n){return t&&t.length&&e&&e.length?jr(t,e,o,n):t},kn.pullAt=Xi,kn.range=dl,kn.rangeRight=fl,kn.rearg=ks,kn.reject=function(t,e){return(js(t)?Ie:pr)(t,Ps(si(e,3)))},kn.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 qr(t,o),n},kn.rest=function(t,e){if("function"!=typeof t)throw new _t(i);return Wr(t,e=e===o?e:fa(e))},kn.reverse=Zi,kn.sampleSize=function(t,e,n){return e=(n?yi(t,e,n):e===o)?1:fa(e),(js(t)?Jn:Kr)(t,e)},kn.set=function(t,e,n){return null==t?t:Jr(t,e,n)},kn.setWith=function(t,e,n,r){return r="function"==typeof r?r:o,null==t?t:Jr(t,e,n,r)},kn.shuffle=function(t){return(js(t)?Qn:Zr)(t)},kn.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:fa(e),n=n===o?r:fa(n)),to(t,e,n)):[]},kn.sortBy=Ss,kn.sortedUniq=function(t){return t&&t.length?oo(t):[]},kn.sortedUniqBy=function(t,e){return t&&t.length?oo(t,si(e,2)):[]},kn.split=function(t,e,n){return n&&"number"!=typeof n&&yi(t,e,n)&&(e=n=o),(n=n===o?f: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):[]},kn.spread=function(t,e){if("function"!=typeof t)throw new _t(i);return e=null==e?0:gn(fa(e),0),Wr((function(n){var r=n[e],o=vo(n,0,e);return r&&Le(o,r),xe(t,this,o)}))},kn.tail=function(t){var e=null==t?0:t.length;return e?to(t,1,e):[]},kn.take=function(t,e,n){return t&&t.length?to(t,0,(e=n||e===o?1:fa(e))<0?0:e):[]},kn.takeRight=function(t,e,n){var r=null==t?0:t.length;return r?to(t,(e=r-(e=n||e===o?1:fa(e)))<0?0:e,r):[]},kn.takeRightWhile=function(t,e){return t&&t.length?co(t,si(e,3),!1,!0):[]},kn.takeWhile=function(t,e){return t&&t.length?co(t,si(e,3)):[]},kn.tap=function(t,e){return e(t),t},kn.throttle=function(t,e,n){var r=!0,o=!0;if("function"!=typeof t)throw new _t(i);return Zs(n)&&(r="leading"in n?!!n.leading:r,o="trailing"in n?!!n.trailing:o),Ms(t,e,{leading:r,maxWait:e,trailing:o})},kn.thru=ds,kn.toArray=ha,kn.toPairs=Fa,kn.toPairsIn=ka,kn.toPath=function(t){return js(t)?Oe(t,Di):aa(t)?[t]:_o(Bi(ya(t)))},kn.toPlainObject=ga,kn.transform=function(t,e,n){var r=js(t),o=r||Ws(t)||la(t);if(e=si(e,4),null==n){var i=t&&t.constructor;n=o?r?new i:[]:Zs(t)&&Js(i)?Hn(qt(t)):{}}return(o?Te:br)(t,(function(t,r,o){return e(n,t,r,o)})),n},kn.unary=function(t){return Es(t,1)},kn.union=ts,kn.unionBy=es,kn.unionWith=ns,kn.uniq=function(t){return t&&t.length?ao(t):[]},kn.uniqBy=function(t,e){return t&&t.length?ao(t,si(e,2)):[]},kn.uniqWith=function(t,e){return e="function"==typeof e?e:o,t&&t.length?ao(t,o,e):[]},kn.unset=function(t,e){return null==t||lo(t,e)},kn.unzip=rs,kn.unzipWith=os,kn.update=function(t,e,n){return null==t?t:uo(t,e,go(n))},kn.updateWith=function(t,e,n,r){return r="function"==typeof r?r:o,null==t?t:uo(t,e,go(n),r)},kn.values=Ha,kn.valuesIn=function(t){return null==t?[]:Je(t,Oa(t))},kn.without=is,kn.words=Ja,kn.wrap=function(t,e){return Ds(go(e),t)},kn.xor=ss,kn.xorBy=as,kn.xorWith=ls,kn.zip=us,kn.zipObject=function(t,e){return po(t||[],e||[],Zn)},kn.zipObjectDeep=function(t,e){return po(t||[],e||[],Jr)},kn.zipWith=cs,kn.entries=Fa,kn.entriesIn=ka,kn.extend=va,kn.extendWith=wa,sl(kn,kn),kn.add=yl,kn.attempt=Qa,kn.camelCase=Ua,kn.capitalize=$a,kn.ceil=bl,kn.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)},kn.clone=function(t){return sr(t,4)},kn.cloneDeep=function(t){return sr(t,5)},kn.cloneDeepWith=function(t,e){return sr(t,5,e="function"==typeof e?e:o)},kn.cloneWith=function(t,e){return sr(t,4,e="function"==typeof e?e:o)},kn.conformsTo=function(t,e){return null==e||ar(t,e,Ma(e))},kn.deburr=Va,kn.defaultTo=function(t,e){return null==t||t!=t?e:t},kn.divide=vl,kn.endsWith=function(t,e,n){t=ya(t),e=so(e);var r=t.length,i=n=n===o?r:ir(fa(n),0,r);return(n-=e.length)>=0&&t.slice(n,i)==e},kn.eq=Hs,kn.escape=function(t){return(t=ya(t))&&Y.test(t)?t.replace(z,en):t},kn.escapeRegExp=function(t){return(t=ya(t))&&nt.test(t)?t.replace(et,"\\$&"):t},kn.every=function(t,e,n){var r=js(t)?_e:dr;return n&&yi(t,e,n)&&(e=o),r(t,si(e,3))},kn.find=ms,kn.findIndex=Vi,kn.findKey=function(t,e){return Fe(t,si(e,3),br)},kn.findLast=gs,kn.findLastIndex=ji,kn.findLastKey=function(t,e){return Fe(t,si(e,3),vr)},kn.floor=wl,kn.forEach=ys,kn.forEachRight=bs,kn.forIn=function(t,e){return null==t?t:gr(t,si(e,3),Oa)},kn.forInRight=function(t,e){return null==t?t:yr(t,si(e,3),Oa)},kn.forOwn=function(t,e){return t&&br(t,si(e,3))},kn.forOwnRight=function(t,e){return t&&vr(t,si(e,3))},kn.get=Ta,kn.gt=Us,kn.gte=$s,kn.has=function(t,e){return null!=t&&fi(t,e,Tr)},kn.hasIn=Ea,kn.head=Gi,kn.identity=nl,kn.includes=function(t,e,n,r){t=Gs(t)?t:Ha(t),n=n&&!r?fa(n):0;var o=t.length;return n<0&&(n=gn(o+n,0)),sa(t)?n<=o&&t.indexOf(e,n)>-1:!!o&&He(t,e,n)>-1},kn.indexOf=function(t,e,n){var r=null==t?0:t.length;if(!r)return-1;var o=null==n?0:fa(n);return o<0&&(o=gn(r+o,0)),He(t,e,o)},kn.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)},kn.invoke=Na,kn.isArguments=Vs,kn.isArray=js,kn.isArrayBuffer=qs,kn.isArrayLike=Gs,kn.isArrayLikeObject=zs,kn.isBoolean=function(t){return!0===t||!1===t||ta(t)&&xr(t)==y},kn.isBuffer=Ws,kn.isDate=Ys,kn.isElement=function(t){return ta(t)&&1===t.nodeType&&!ra(t)},kn.isEmpty=function(t){if(null==t)return!0;if(Gs(t)&&(js(t)||"string"==typeof t||"function"==typeof t.splice||Ws(t)||la(t)||Vs(t)))return!t.length;var e=di(t);if(e==A||e==_)return!t.size;if(Ci(t))return!Pr(t).length;for(var n in t)if(Rt.call(t,n))return!1;return!0},kn.isEqual=function(t,e){return Mr(t,e)},kn.isEqualWith=function(t,e,n){var r=(n="function"==typeof n?n:o)?n(t,e):o;return r===o?Mr(t,e,o,n):!!r},kn.isError=Ks,kn.isFinite=function(t){return"number"==typeof t&&De(t)},kn.isFunction=Js,kn.isInteger=Qs,kn.isLength=Xs,kn.isMap=ea,kn.isMatch=function(t,e){return t===e||Or(t,e,li(e))},kn.isMatchWith=function(t,e,n){return n="function"==typeof n?n:o,Or(t,e,li(e),n)},kn.isNaN=function(t){return na(t)&&t!=+t},kn.isNative=function(t){if(wi(t))throw new Ct("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");return Lr(t)},kn.isNil=function(t){return null==t},kn.isNull=function(t){return null===t},kn.isNumber=na,kn.isObject=Zs,kn.isObjectLike=ta,kn.isPlainObject=ra,kn.isRegExp=oa,kn.isSafeInteger=function(t){return Qs(t)&&t>=-9007199254740991&&t<=h},kn.isSet=ia,kn.isString=sa,kn.isSymbol=aa,kn.isTypedArray=la,kn.isUndefined=function(t){return t===o},kn.isWeakMap=function(t){return ta(t)&&di(t)==M},kn.isWeakSet=function(t){return ta(t)&&"[object WeakSet]"==xr(t)},kn.join=function(t,e){return null==t?"":qe.call(t,e)},kn.kebabCase=ja,kn.last=Ki,kn.lastIndexOf=function(t,e,n){var r=null==t?0:t.length;if(!r)return-1;var i=r;return n!==o&&(i=(i=fa(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):ke(t,$e,i,!0)},kn.lowerCase=qa,kn.lowerFirst=Ga,kn.lt=ua,kn.lte=ca,kn.max=function(t){return t&&t.length?fr(t,nl,Sr):o},kn.maxBy=function(t,e){return t&&t.length?fr(t,si(e,2),Sr):o},kn.mean=function(t){return Ve(t,nl)},kn.meanBy=function(t,e){return Ve(t,si(e,2))},kn.min=function(t){return t&&t.length?fr(t,nl,Br):o},kn.minBy=function(t,e){return t&&t.length?fr(t,si(e,2),Br):o},kn.stubArray=pl,kn.stubFalse=ml,kn.stubObject=function(){return{}},kn.stubString=function(){return""},kn.stubTrue=function(){return!0},kn.multiply=Cl,kn.nth=function(t,e){return t&&t.length?Ur(t,fa(e)):o},kn.noConflict=function(){return he._===this&&(he._=kt),this},kn.noop=al,kn.now=Ts,kn.pad=function(t,e,n){t=ya(t);var r=(e=fa(e))?cn(t):0;if(!e||r>=e)return t;var o=(e-r)/2;return Vo(fe(o),n)+t+Vo(de(o),n)},kn.padEnd=function(t,e,n){t=ya(t);var r=(e=fa(e))?cn(t):0;return e&&r<e?t+Vo(e-r,n):t},kn.padStart=function(t,e,n){t=ya(t);var r=(e=fa(e))?cn(t):0;return e&&r<e?Vo(e-r,n)+t:t},kn.parseInt=function(t,e,n){return n||null==e?e=0:e&&(e=+e),vn(ya(t).replace(rt,""),e||0)},kn.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=wn();return yn(t+i*(e-t+ae("1e-"+((i+"").length-1))),e)}return Gr(t,e)},kn.reduce=function(t,e,n){var r=js(t)?Re:Ge,o=arguments.length<3;return r(t,si(e,4),n,o,cr)},kn.reduceRight=function(t,e,n){var r=js(t)?Pe:Ge,o=arguments.length<3;return r(t,si(e,4),n,o,hr)},kn.repeat=function(t,e,n){return e=(n?yi(t,e,n):e===o)?1:fa(e),zr(ya(t),e)},kn.replace=function(){var t=arguments,e=ya(t[0]);return t.length<3?e:e.replace(t[1],t[2])},kn.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[Di(e[r])];s===o&&(r=i,s=n),t=Js(s)?s.call(t):s}return t},kn.round=Al,kn.runInContext=t,kn.sample=function(t){return(js(t)?Kn:Yr)(t)},kn.size=function(t){if(null==t)return 0;if(Gs(t))return sa(t)?cn(t):t.length;var e=di(t);return e==A||e==_?t.size:Pr(t).length},kn.snakeCase=za,kn.some=function(t,e,n){var r=js(t)?Be:eo;return n&&yi(t,e,n)&&(e=o),r(t,si(e,3))},kn.sortedIndex=function(t,e){return no(t,e)},kn.sortedIndexBy=function(t,e,n){return ro(t,e,si(n,2))},kn.sortedIndexOf=function(t,e){var n=null==t?0:t.length;if(n){var r=no(t,e);if(r<n&&Hs(t[r],e))return r}return-1},kn.sortedLastIndex=function(t,e){return no(t,e,!0)},kn.sortedLastIndexBy=function(t,e,n){return ro(t,e,si(n,2),!0)},kn.sortedLastIndexOf=function(t,e){if(null!=t&&t.length){var n=no(t,e,!0)-1;if(Hs(t[n],e))return n}return-1},kn.startCase=Wa,kn.startsWith=function(t,e,n){return t=ya(t),n=null==n?0:ir(fa(n),0,t.length),e=so(e),t.slice(n,n+e.length)==e},kn.subtract=xl,kn.sum=function(t){return t&&t.length?ze(t,nl):0},kn.sumBy=function(t,e){return t&&t.length?ze(t,si(e,2)):0},kn.template=function(t,e,n){var r=kn.templateSettings;n&&yi(t,e,n)&&(e=o),t=ya(t),e=wa({},e,r,Jo);var i,s,a=wa({},e.imports,r.imports,Jo),l=Ma(a),u=Je(a,l),c=0,h=e.interpolate||vt,d="__p += '",f=Tt((e.escape||vt).source+"|"+h.source+"|"+(h===Q?ht:vt).source+"|"+(e.evaluate||vt).source+"|$","g"),p="//# sourceURL="+(Rt.call(e,"sourceURL")?(e.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++re+"]")+"\n";t.replace(f,(function(e,n,r,o,a,l){return r||(r=o),d+=t.slice(c,l).replace(wt,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'"),c=l+e.length,e})),d+="';\n";var m=Rt.call(e,"variable")&&e.variable;if(m){if(ut.test(m))throw new Ct("Invalid `variable` option passed into `_.template`")}else d="with (obj) {\n"+d+"\n}\n";d=(s?d.replace(V,""):d).replace(j,"$1").replace(q,"$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=Qa((function(){return At(l,p+"return "+d).apply(o,u)}));if(g.source=d,Ks(g))throw g;return g},kn.times=function(t,e){if((t=fa(t))<1||t>h)return[];var n=f,r=yn(t,f);e=si(e),t-=f;for(var o=We(r,e);++n<t;)e(n);return o},kn.toFinite=da,kn.toInteger=fa,kn.toLength=pa,kn.toLower=function(t){return ya(t).toLowerCase()},kn.toNumber=ma,kn.toSafeInteger=function(t){return t?ir(fa(t),-9007199254740991,h):0===t?t:0},kn.toString=ya,kn.toUpper=function(t){return ya(t).toUpperCase()},kn.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("")},kn.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("")},kn.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("")},kn.truncate=function(t,e){var n=30,r="...";if(Zs(e)){var i="separator"in e?e.separator:i;n="length"in e?fa(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-cn(r);if(l<1)return r;var u=a?vo(a,0,l).join(""):t.slice(0,l);if(i===o)return u+r;if(a&&(l+=u.length-l),oa(i)){if(t.slice(l).search(i)){var c,h=u;for(i.global||(i=Tt(i.source,ya(dt.exec(i))+"g")),i.lastIndex=0;c=i.exec(h);)var d=c.index;u=u.slice(0,d===o?l:d)}}else if(t.indexOf(so(i),l)!=l){var f=u.lastIndexOf(i);f>-1&&(u=u.slice(0,f))}return u+r},kn.unescape=function(t){return(t=ya(t))&&W.test(t)?t.replace(G,fn):t},kn.uniqueId=function(t){var e=++Pt;return ya(t)+e},kn.upperCase=Ya,kn.upperFirst=Ka,kn.each=ys,kn.eachRight=bs,kn.first=Gi,sl(kn,(gl={},br(kn,(function(t,e){Rt.call(kn.prototype,e)||(gl[e]=t)})),gl),{chain:!1}),kn.VERSION="4.17.21",Te(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(t){kn[t].placeholder=kn})),Te(["drop","take"],(function(t,e){Vn.prototype[t]=function(n){n=n===o?1:gn(fa(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,f),type:t+(r.__dir__<0?"Right":"")}),r},Vn.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}})),Te(["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}})),Te(["head","last"],(function(t,e){var n="take"+(e?"Right":"");Vn.prototype[t]=function(){return this[n](1).value()[0]}})),Te(["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=Wr((function(t,e){return"function"==typeof t?new Vn(this):this.map((function(n){return Ir(n,t,e)}))})),Vn.prototype.reject=function(t){return this.filter(Ps(si(t)))},Vn.prototype.slice=function(t,e){t=fa(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=fa(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(f)},br(Vn.prototype,(function(t,e){var n=/^(?:filter|find|map|reject)|While$/.test(e),r=/^(?:head|last)$/.test(e),i=kn[r?"take"+("last"==e?"Right":""):e],s=r||/^find/.test(e);i&&(kn.prototype[e]=function(){var e=this.__wrapped__,a=r?[1]:arguments,l=e instanceof Vn,u=a[0],c=l||js(e),h=function(t){var e=i.apply(kn,Le([t],a));return r&&d?e[0]:e};c&&n&&"function"==typeof u&&1!=u.length&&(l=c=!1);var d=this.__chain__,f=!!this.__actions__.length,p=s&&!d,m=l&&!f;if(!s&&c){e=m?e:new Vn(this);var g=t.apply(e,a);return g.__actions__.push({func:ds,args:[h],thisArg:o}),new $n(g,d)}return p&&m?t.apply(this,a):(g=this.thru(h),p?r?g.value()[0]:g.value():g)})})),Te(["pop","push","shift","sort","splice","unshift"],(function(t){var e=It[t],n=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",r=/^(?:pop|shift)$/.test(t);kn.prototype[t]=function(){var t=arguments;if(r&&!this.__chain__){var o=this.value();return e.apply(js(o)?o:[],t)}return this[n]((function(n){return e.apply(js(n)?n:[],t)}))}})),br(Vn.prototype,(function(t,e){var n=kn[e];if(n){var r=n.name+"";Rt.call(Nn,r)||(Nn[r]=[]),Nn[r].push({name:e,func:n})}})),Nn[ko(o,2).name]=[{name:"wrapper",func:o}],Vn.prototype.clone=function(){var t=new Vn(this.__wrapped__);return t.__actions__=_o(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=_o(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=_o(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=js(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,u=r?a:s-1,c=this.__iteratees__,h=c.length,d=0,f=yn(l,this.__takeCount__);if(!n||!r&&o==l&&f==l)return ho(t,this.__actions__);var p=[];t:for(;l--&&d<f;){for(var m=-1,g=t[u+=e];++m<h;){var y=c[m],b=y.iteratee,v=y.type,w=b(g);if(2==v)g=w;else if(!w){if(1==v)continue t;break t}}p[d++]=g}return p},kn.prototype.at=fs,kn.prototype.chain=function(){return hs(this)},kn.prototype.commit=function(){return new $n(this.value(),this.__chain__)},kn.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__++]}},kn.prototype.plant=function(t){for(var e,n=this;n instanceof Un;){var r=ki(n);r.__index__=0,r.__values__=o,e?i.__wrapped__=r:e=r;var i=r;n=n.__wrapped__}return i.__wrapped__=t,e},kn.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 $n(e,this.__chain__)}return this.thru(Zi)},kn.prototype.toJSON=kn.prototype.valueOf=kn.prototype.value=function(){return ho(this.__wrapped__,this.__actions__)},kn.prototype.first=kn.prototype.head,Kt&&(kn.prototype[Kt]=function(){return this}),kn}();he._=pn,(r=function(){return pn}.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,u,c,h){"use strict";var d=t("crypto");function f(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=f).sha1=function(t){return f(t)},n.keys=function(t){return f(t,{excludeValues:!0,algorithm:"sha1",encoding:"hex"})},n.MD5=function(t){return f(t,{algorithm:"md5",encoding:"hex"})},n.keysMD5=function(t){return f(t,{algorithm:"md5",encoding:"hex",excludeValues:!0})};var p=d.getHashes?d.getHashes().slice():["sha1","md5"],m=(p.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<p.length;++r)p[r].toLowerCase()===n.algorithm.toLowerCase()&&(n.algorithm=p[r]);if(-1===p.indexOf(n.algorithm))throw new Error('Algorithm "'+n.algorithm+'" not supported. supported values: '+p.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,u){!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 u(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=u(t.charAt(n))<<18|u(t.charAt(n+1))<<12|u(t.charAt(n+2))<<6|u(t.charAt(n+3))))>>16),l((65280&r)>>8),l(255&r);return 2==o?l(255&(r=u(t.charAt(n))<<2|u(t.charAt(n+1))>>4)):1==o&&(l((r=u(t.charAt(n))<<10|u(t.charAt(n+1))<<4|u(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,u,c){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=_(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=_(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(I(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 f(t,e,n,r){var o;if(r||(F("boolean"==typeof n,"missing or invalid endian"),F(null!=e,"missing offset"),F(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 p(t,e,n,r){var o;if(r||(F("boolean"==typeof n,"missing or invalid endian"),F(null!=e,"missing offset"),F(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||(F("boolean"==typeof n,"missing or invalid endian"),F(null!=e,"missing offset"),F(e+1<t.length,"Trying to read beyond buffer length")),!(t.length<=e))return 32768&(r=f(t,e,n,!0))?-1*(65535-r+1):r}function g(t,e,n,r){if(r||(F("boolean"==typeof n,"missing or invalid endian"),F(null!=e,"missing offset"),F(e+3<t.length,"Trying to read beyond buffer length")),!(t.length<=e))return 2147483648&(r=p(t,e,n,!0))?-1*(4294967295-r+1):r}function y(t,e,n,r){return r||(F("boolean"==typeof n,"missing or invalid endian"),F(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||(F("boolean"==typeof n,"missing or invalid endian"),F(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||(F(null!=e,"missing value"),F("boolean"==typeof r,"missing or invalid endian"),F(null!=n,"missing offset"),F(n+1<t.length,"trying to write beyond buffer length"),P(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 w(t,e,n,r,o){if(o||(F(null!=e,"missing value"),F("boolean"==typeof r,"missing or invalid endian"),F(null!=n,"missing offset"),F(n+3<t.length,"trying to write beyond buffer length"),P(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 C(t,e,n,r,o){o||(F(null!=e,"missing value"),F("boolean"==typeof r,"missing or invalid endian"),F(null!=n,"missing offset"),F(n+1<t.length,"Trying to write beyond buffer length"),B(e,32767,-32768)),t.length<=n||v(t,0<=e?e:65535+e+1,n,r,o)}function A(t,e,n,r,o){o||(F(null!=e,"missing value"),F("boolean"==typeof r,"missing or invalid endian"),F(null!=n,"missing offset"),F(n+3<t.length,"Trying to write beyond buffer length"),B(e,2147483647,-2147483648)),t.length<=n||w(t,0<=e?e:4294967295+e+1,n,r,o)}function x(t,e,n,r,o){o||(F(null!=e,"missing value"),F("boolean"==typeof r,"missing or invalid endian"),F(null!=n,"missing offset"),F(n+3<t.length,"Trying to write beyond buffer length"),D(e,34028234663852886e22,-34028234663852886e22)),t.length<=n||d.write(t,e,n,r,23,4)}function S(t,e,n,r,o){o||(F(null!=e,"missing value"),F("boolean"==typeof r,"missing or invalid endian"),F(null!=n,"missing offset"),F(n+7<t.length,"Trying to write beyond buffer length"),D(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=M(t).length;break;case"ascii":case"binary":case"raw":n=t.length;break;case"base64":n=O(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(F(I(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):(u=r,r=e,e=n,n=u),e=Number(e)||0;var i,s,a,l,u=this.length-e;switch((!n||u<(n=Number(n)))&&(n=u),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),F((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);F(!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(M(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(O(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+=N(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+=R(o)+String.fromCharCode(t[i]),o=""):o+="%"+t[i].toString(16);return r+R(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){F(n<=r,"sourceEnd < sourceStart"),F(0<=e&&e<t.length,"targetStart out of bounds"),F(0<=n&&n<this.length,"sourceStart out of bounds"),F(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=E(t,n,0),e=E(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||(F(null!=t,"missing offset"),F(t<this.length,"Trying to read beyond buffer length")),!(t>=this.length))return this[t]},o.prototype.readUInt16LE=function(t,e){return f(this,t,!0,e)},o.prototype.readUInt16BE=function(t,e){return f(this,t,!1,e)},o.prototype.readUInt32LE=function(t,e){return p(this,t,!0,e)},o.prototype.readUInt32BE=function(t,e){return p(this,t,!1,e)},o.prototype.readInt8=function(t,e){if(e||(F(null!=t,"missing offset"),F(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||(F(null!=t,"missing value"),F(null!=e,"missing offset"),F(e<this.length,"trying to write beyond buffer length"),P(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){w(this,t,e,!0,n)},o.prototype.writeUInt32BE=function(t,e,n){w(this,t,e,!1,n)},o.prototype.writeInt8=function(t,e,n){n||(F(null!=t,"missing value"),F(null!=e,"missing offset"),F(e<this.length,"Trying to write beyond buffer length"),B(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){C(this,t,e,!0,n)},o.prototype.writeInt16BE=function(t,e,n){C(this,t,e,!1,n)},o.prototype.writeInt32LE=function(t,e,n){A(this,t,e,!0,n)},o.prototype.writeInt32BE=function(t,e,n){A(this,t,e,!1,n)},o.prototype.writeFloatLE=function(t,e,n){x(this,t,e,!0,n)},o.prototype.writeFloatBE=function(t,e,n){x(this,t,e,!1,n)},o.prototype.writeDoubleLE=function(t,e,n){S(this,t,e,!0,n)},o.prototype.writeDoubleBE=function(t,e,n){S(this,t,e,!1,n)},o.prototype.fill=function(t,e,n){if(e=e||0,n=n||this.length,F("number"==typeof(t="string"==typeof(t=t||0)?t.charCodeAt(0):t)&&!isNaN(t),"value is not a number"),F(e<=n,"end < start"),n!==e&&0!==this.length){F(0<=e&&e<this.length,"start out of bounds"),F(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]=N(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 T=o.prototype;function E(t,e,n){return"number"!=typeof t?n:e<=(t=~~t)?e:0<=t||0<=(t+=e)?t:0}function _(t){return(t=~~Math.ceil(+t))<0?0:t}function I(t){return(Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)})(t)}function N(t){return t<16?"0"+t.toString(16):t.toString(16)}function M(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 O(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 R(t){try{return decodeURIComponent(t)}catch(t){return String.fromCharCode(65533)}}function P(t,e){F("number"==typeof t,"cannot write a non-number as a number"),F(0<=t,"specified a negative value for writing an unsigned value"),F(t<=e,"value is larger than maximum value for type"),F(Math.floor(t)===t,"value has a fractional component")}function B(t,e,n){F("number"==typeof t,"cannot write a non-number as a number"),F(t<=e,"value larger than maximum allowed value"),F(n<=t,"value smaller than minimum allowed value"),F(Math.floor(t)===t,"value has a fractional component")}function D(t,e,n){F("number"==typeof t,"cannot write a non-number as a number"),F(t<=e,"value larger than maximum allowed value"),F(n<=t,"value smaller than minimum allowed value")}function F(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=T.get,t.set=T.set,t.write=T.write,t.toString=T.toString,t.toLocaleString=T.toString,t.toJSON=T.toJSON,t.copy=T.copy,t.slice=T.slice,t.readUInt8=T.readUInt8,t.readUInt16LE=T.readUInt16LE,t.readUInt16BE=T.readUInt16BE,t.readUInt32LE=T.readUInt32LE,t.readUInt32BE=T.readUInt32BE,t.readInt8=T.readInt8,t.readInt16LE=T.readInt16LE,t.readInt16BE=T.readInt16BE,t.readInt32LE=T.readInt32LE,t.readInt32BE=T.readInt32BE,t.readFloatLE=T.readFloatLE,t.readFloatBE=T.readFloatBE,t.readDoubleLE=T.readDoubleLE,t.readDoubleBE=T.readDoubleBE,t.writeUInt8=T.writeUInt8,t.writeUInt16LE=T.writeUInt16LE,t.writeUInt16BE=T.writeUInt16BE,t.writeUInt32LE=T.writeUInt32LE,t.writeUInt32BE=T.writeUInt32BE,t.writeInt8=T.writeInt8,t.writeInt16LE=T.writeInt16LE,t.writeInt16BE=T.writeInt16BE,t.writeInt32LE=T.writeInt32LE,t.writeInt32BE=T.writeInt32BE,t.writeFloatLE=T.writeFloatLE,t.writeFloatBE=T.writeFloatBE,t.writeDoubleLE=T.writeDoubleLE,t.writeDoubleBE=T.writeDoubleBE,t.fill=T.fill,t.inspect=T.inspect,t.toArrayBuffer=T.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,u,c){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,u,c){o=t("buffer").Buffer;var h=t("./sha"),d=t("./sha256"),f=t("./rng"),p={sha1:h,sha256:d,md5:t("./md5")},m=64,g=new o(m);function y(t,e){var n=p[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(f(t));try{e.call(this,void 0,new o(f(t)))}catch(t){e(t)}};var v,w=["createCredentials","createCipher","createCipheriv","createDecipher","createDecipheriv","createSign","createVerify","createDiffieHellman","pbkdf2"],C=function(t){n[t]=function(){b("sorry,",t,"is not implemented yet")}};for(v in w)C(w[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,u,c){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,u=o,c=i;n=p(n,r,o,i,t[s+0],7,-680876936),i=p(i,n,r,o,t[s+1],12,-389564586),o=p(o,i,n,r,t[s+2],17,606105819),r=p(r,o,i,n,t[s+3],22,-1044525330),n=p(n,r,o,i,t[s+4],7,-176418897),i=p(i,n,r,o,t[s+5],12,1200080426),o=p(o,i,n,r,t[s+6],17,-1473231341),r=p(r,o,i,n,t[s+7],22,-45705983),n=p(n,r,o,i,t[s+8],7,1770035416),i=p(i,n,r,o,t[s+9],12,-1958414417),o=p(o,i,n,r,t[s+10],17,-42063),r=p(r,o,i,n,t[s+11],22,-1990404162),n=p(n,r,o,i,t[s+12],7,1804603682),i=p(i,n,r,o,t[s+13],12,-40341101),o=p(o,i,n,r,t[s+14],17,-1502002290),n=m(n,r=p(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,u),i=b(i,c)}return Array(n,r,o,i)}function f(t,e,n,r,o,i){return b((e=b(b(e,t),b(r,i)))<<o|e>>>32-o,n)}function p(t,e,n,r,o,i,s){return f(e&n|~e&r,t,e,o,i,s)}function m(t,e,n,r,o,i,s){return f(e&r|n&~r,t,e,o,i,s)}function g(t,e,n,r,o,i,s){return f(e^n^r,t,e,o,i,s)}function y(t,e,n,r,o,i,s){return f(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,u){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,u,c){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,u=271733878,c=-1009589776,h=0;h<t.length;h+=16){for(var d=s,m=a,g=l,y=u,b=c,v=0;v<80;v++){i[v]=v<16?t[h+v]:p(i[v-3]^i[v-8]^i[v-14]^i[v-16],1);var w=f(f(p(s,5),(w=a,r=l,o=u,(n=v)<20?w&r|~w&o:!(n<40)&&n<60?w&r|w&o|r&o:w^r^o)),f(f(c,i[v]),(n=v)<20?1518500249:n<40?1859775393:n<60?-1894007588:-899497514));c=u,u=l,l=p(a,30),a=s,s=w}s=f(s,d),a=f(a,m),l=f(l,g),u=f(u,y),c=f(c,b)}return Array(s,a,l,u,c)}function f(t,e){var n=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(n>>16)<<16|65535&n}function p(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,u,c){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 u=o[0],c=o[1],d=o[2],f=o[3],g=o[4],y=o[5],b=o[6],v=o[7],w=0;w<64;w++)i[w]=w<16?t[w+l]:h(h(h((a=i[w-2],p(a,17)^p(a,19)^m(a,10)),i[w-7]),(a=i[w-15],p(a,7)^p(a,18)^m(a,3))),i[w-16]),n=h(h(h(h(v,p(a=g,6)^p(a,11)^p(a,25)),g&y^~g&b),r[w]),i[w]),s=h(p(s=u,2)^p(s,13)^p(s,22),u&c^u&d^c&d),v=b,b=y,y=g,g=h(f,n),f=d,d=c,c=u,u=h(n,s);o[0]=h(u,o[0]),o[1]=h(c,o[1]),o[2]=h(d,o[2]),o[3]=h(f,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 f=t("./helpers"),p=function(t,e){return t>>>e|t<<32-e},m=function(t,e){return t>>>e};e.exports=function(t){return f.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,u){n.read=function(t,e,n,r,o){var i,s,a=8*o-r-1,l=(1<<a)-1,u=l>>1,c=-7,h=n?o-1:0,d=n?-1:1;for(o=t[e+h],h+=d,i=o&(1<<-c)-1,o>>=-c,c+=a;0<c;i=256*i+t[e+h],h+=d,c-=8);for(s=i&(1<<-c)-1,i>>=-c,c+=r;0<c;s=256*s+t[e+h],h+=d,c-=8);if(0===i)i=1-u;else{if(i===l)return s?NaN:1/0*(o?-1:1);s+=Math.pow(2,r),i-=u}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,u=(1<<l)-1,c=u>>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:i-1,f=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=u):(s=Math.floor(Math.log(e)/Math.LN2),e*(r=Math.pow(2,-s))<1&&(s--,r*=2),2<=(e+=1<=s+c?h/r:h*Math.pow(2,1-c))*r&&(s++,r/=2),u<=s+c?(a=0,s=u):1<=s+c?(a=(e*r-1)*Math.pow(2,o),s+=c):(a=e*Math.pow(2,c-1)*Math.pow(2,o),s=0));8<=o;t[n+d]=255&a,d+=f,a/=256,o-=8);for(s=s<<o|a,l+=o;0<l;t[n+d]=255&s,d+=f,s/=256,l-=8);t[n+d-f]|=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,u){var c,h,d;function f(){}(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?(c=[],window.addEventListener("message",(function(t){var e=t.source;e!==window&&null!==e||"process-tick"!==t.data||(t.stopPropagation(),0<c.length&&c.shift()())}),!0),function(t){c.push(t),window.postMessage("process-tick","*")}):function(t){setTimeout(t,0)}),t.title="browser",t.browser=!0,t.env={},t.argv=[],t.on=f,t.addListener=f,t.once=f,t.off=f,t.removeListener=f,t.removeAllListeners=f,t.emit=f,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},u=function(t){if(!l(t))throw new Error("an HTMLElement or SVGElement is required; got "+t)},c=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})},f={},p=null,m=function(t,e){var n=e||{},r=n.selectorRemap,o=n.modifyStyle,i=n.modifyCss,l=n.fonts,u=n.excludeUnusedCss,c=i||function(t,e){return(r?r(t):t)+"{"+(o?o(e):e)+"}\n"},h=[],d=void 0===l,m=l||[];return(p||(p=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(c(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 u||h.push(e.cssText)}))})),function(t){return Promise.all(t.map((function(t){return new Promise((function(e,n){if(f[t.url])return e(f[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";f[t.url]=o,e(o)})),r.addEventListener("error",(function(n){console.warn("Failed to load font from: "+t.url,n),f[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){u(t);var r=e||{},s=r.left,a=void 0===s?0:s,l=r.top,c=void 0===l?0:l,d=r.width,f=r.height,p=r.scale,g=void 0===p?1:p,y=r.responsive,b=void 0!==y&&y,v=r.excludeCss,w=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,f),l=s.width,u=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 p=document.createElementNS("http://www.w3.org/2000/svg","svg");p.appendChild(r),r=p}if(r.setAttribute("version","1.1"),r.setAttribute("viewBox",[a,c,l,u].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",u*g)),Array.from(r.querySelectorAll("foreignObject > *")).forEach((function(t){t.setAttributeNS(o,"xmlns","svg"===t.tagName?i:"http://www.w3.org/1999/xhtml")})),!w)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:u};n(s,l,u)}));var y=document.createElement("div");y.appendChild(r);var v=y.innerHTML;if("function"!=typeof n)return{src:v,width:l,height:u};n(v,l,u)}))},r.svgAsDataUri=function(t,e,n){return u(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){u(t);var o=e||{},i=o.encoderType,s=void 0===i?"image/png":i,a=o.encoderOptions,l=void 0===a?.8:a,c=o.canvg,h=function(t){var e=t.src,r=t.width,o=t.height,i=document.createElement("canvas"),a=i.getContext("2d"),u=window.devicePixelRatio||1;i.width=r*u,i.height=o*u,i.style.width=i.width+"px",i.style.height=i.height+"px",a.setTransform(u,0,0,u,0,0),c?c(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 c?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 c(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 c(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],u=r.base?l[0]+r.base:l[0],c=i[u]||0,h="".concat(u," ").concat(c);i[u]=c+1;var d=n(h),f={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==d)e[d].references++,e[d].updater(f);else{var p=o(f,r);r.byIndex=a,e.splice(a,0,{identifier:h,updater:p,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),u=0;u<i.length;u++){var c=n(i[u]);0===e[c].references&&(e[c].updater(),e.splice(c,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,OT:()=>u,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),u=Object.fromEntries(s.map((t=>{let e;try{e=l.convertTo(t)}catch{e=null}return[t,e]})).filter((([t,e])=>e))),c=a(n===r.NO.HELM?t:u[r.NO.HELM],o.monomerLibWrapper);return c&&(u.Nucleotides=c),u}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 u(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"},9788:(t,e,n)=>{"use strict";n.r(e),n.d(e,{PackageFunctions:()=>Qr,_package:()=>Kr,applyNotationProviderForCyclized:()=>Gr,createMonomerLibraryForPolyTool:()=>Hr,demoOligoPattern:()=>Mr,demoOligoStructure:()=>Or,demoTranslateSequence:()=>Nr,getCodeToWeightsMap:()=>Tr,getMolfileFromGcrsSequence:()=>_r,getPolyToolCombineDialog:()=>qr,getPolyToolConvertEditor:()=>Pr,getPtChemEnumeratorDialog:()=>jr,getPtHelmEnumeratorDialog:()=>Vr,getTranslationHelper:()=>Sr,init:()=>wr,linkStrands:()=>Ir,oligoPatternApp:()=>Ar,oligoStructureApp:()=>xr,oligoToolkitApp:()=>vr,oligoTranslatorApp:()=>Cr,polyToolColumnChoice:()=>kr,polyToolConvert2:()=>Br,polyToolConvertTopMenu:()=>Rr,polyToolEnumerateChemTopMenu:()=>Fr,polyToolEnumerateHelmTopMenu:()=>Dr,ptEnumeratorChemApp:()=>$r,ptEnumeratorHelmApp:()=>Ur,translateOligonucleotideSequence:()=>Lr,validateSequence:()=>Er});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 u{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 c="System:AppData/SequenceTranslator/monomers-sample",h="pattern-app-data.json",d="formats-to-helm.json",f="codes-to-symbols.json",p="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 w{constructor(t,e,n,r){this.patternAppData=t,this.codesToHelmDict=e,this.codesToSymbolsDict=n,this.monomersWithPhosphate=r}}async function C(t){const e=await Promise.all([h,d,f,p].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 w(e[0],e[1],e[2],e[3])}class A{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 x=n(9537);const S=(t,e)=>e.length-t.length;class T{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(S);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(S)}getTargetFormatHelmCodesRegExp(t){this.validateFormat(t);const e=this.getTargetFormatHelmCodes(t);return new RegExp(E(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=E(Array.from(new Set(Object.values(e[x.ti.LINKAGE]))).sort(S));return new RegExp(`${x.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(S)}getNonHelmFormatRegExp(t){const e=this.getCodesByFormat(t);return new RegExp(E(e)+"|\\([^()]*\\)|.","g")}}function E(t){return t.map((t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"))).map((t=>t.includes("(")||t.includes(")")?t:`(?<!\\([^()]*)${t}(?![^()]*\\))`)).join("|")}const _={LEFT:"RNA1{",RIGHT:"}$$$$"};class I{constructor(t,e,n){this.sequence=t,this.sourceFormat=e,this.th=n,this.formats=new T(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(E(Object.values(_)),"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,x.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,`${x.iL}.`),s=s.slice(0,-1),s[s.length-1]===x.q7&&(s=s.slice(0,-1)),s=s.replace(i,((t,e)=>e)),s=s.replace(/<empty>/g,""),`${_.LEFT+s+_.RIGHT}`}}class N{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 M=n(7389);const O=$;var L=n.n(O);function R(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=M.span([]);L()(i).css("-webkit-text-fill-color","var(--grey-6)");const s=M.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 P 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=>R(t,this),super._logger=new u(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 '${c}'.`),e=c),[this._jsonData,this._monomerLib]=await Promise.all([C(e),B(e)]),this._monomerLibWrapper=new A(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 I(t,e,this)}createFormatDetector(t){return new N(t,this)}}async function B(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 D{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&&M.setUpdateIndicator(e,!0);try{return await this.constructView()}finally{t.close(),e&&M.setUpdateIndicator(e,!1)}}}class F extends D{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/${Kr.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"},U=["3'","5'"],V="OligoToolkit";var j,q,G,z;!function(t){t.IS_ANTISENSE_STRAND_INCLUDED="isAntisenseStrandIncluded",t.NUCLEOTIDE_SEQUENCES="nucleotideSequences",t.PHOSPHOROTHIOATE_LINKAGE_FLAGS="phosphorothioateLinkageFlags",t.STRAND_TERMINUS_MODIFICATIONS="strandTerminusModifications"}(j||(j={})),function(t){t.PATTERN_NAME="patternName",t.PATTERN_COMMENT="patternComment",t.NUCLEOTIDES_WITH_NUMERIC_LABELS="nucleotidesWithNumericLabels"}(q||(q={})),function(t){t.PATTERN_CONFIG="patternConfig",t.AUTHOR_ID="authorID",t.DATE="date"}(G||(G={})),function(t){t.CREATE="create",t.MODIFY="modify"}(z||(z={}));const W=[j.IS_ANTISENSE_STRAND_INCLUDED,j.NUCLEOTIDE_SEQUENCES,j.PHOSPHOROTHIOATE_LINKAGE_FLAGS,j.STRAND_TERMINUS_MODIFICATIONS],Y=(q.PATTERN_NAME,q.PATTERN_COMMENT,q.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 J extends Error{constructor(t){super(t),this.name="PatternNameExistsError"}}class Q 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 Kr.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 J(`Pattern with name ${t} already exists`)}validatePatternUniqueness(t){if(Array.from(this.currentUserPatternNameToHash.values()).concat(Array.from(this.otherUsersPatternNameToHash.values())).includes(t))throw new Q(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[G.PATTERN_CONFIG]}getDefaultPatternRecord(){const t=Y;return t[G.AUTHOR_ID]=this.currentUserId,t}getDefaultPatternConfig(){return Y[G.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{[G.PATTERN_CONFIG]:t,[G.AUTHOR_ID]:await r.dapi.users.current().then((t=>t.id))}}getHash(t){const e=W.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[q.PATTERN_NAME];this.validatePatternNameUniqueness(o);const i=await this.getRecordFromPattern(e),s=(new Date).toISOString();i[G.DATE]={[z.CREATE]:s,[z.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 J||t instanceof Q)throw t;console.error("Error while saving pattern to user storage",t)}}async overwriteExistingPatternInUserStorage(t){const e=t.getPatternConfig(),n=e[q.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[G.DATE]={[z.MODIFY]:a};const l=r.userSettings.getValue(V,o,!1)??"null",u=JSON.parse(l);void 0!==u[G.DATE]&&null!=u[G.DATE][z.CREATE]&&(s[G.DATE][z.CREATE]=u[G.DATE][z.CREATE]);const c=JSON.stringify(s);r.userSettings.add(V,i,c,!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[G.PATTERN_CONFIG];this.currentUserPatternNameToHash.set(t[q.PATTERN_NAME],"")}async extractDataFromRecordToMaps(t,e,n){const o=JSON.parse(e),i=o[G.PATTERN_CONFIG].patternName,s=o[G.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[G.PATTERN_CONFIG][q.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 ut{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||U.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[G.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[G.PATTERN_CONFIG];this._patternName$=new et.BehaviorSubject(e[q.PATTERN_NAME]),this._isAntisenseStrandActive$=new et.BehaviorSubject(e[j.IS_ANTISENSE_STRAND_INCLUDED]),this._nucleotideSequences$=new et.BehaviorSubject(e[j.NUCLEOTIDE_SEQUENCES]),this._phosphorothioateLinkageFlags=new et.BehaviorSubject(e[j.PHOSPHOROTHIOATE_LINKAGE_FLAGS]),this._terminalModifications=new et.BehaviorSubject(e[j.STRAND_TERMINUS_MODIFICATIONS]),this._comment$=new et.BehaviorSubject(e[q.PATTERN_COMMENT]),this._modificationsWithNumericLabels$=new et.BehaviorSubject(e[q.NUCLEOTIDES_WITH_NUMERIC_LABELS]),this._sequenceBase$=new et.BehaviorSubject(ot(e[j.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[q.PATTERN_NAME]),this._isAntisenseStrandActive$.next(t[j.IS_ANTISENSE_STRAND_INCLUDED]),this._nucleotideSequences$.next(t[j.NUCLEOTIDE_SEQUENCES]),this._phosphorothioateLinkageFlags.next(t[j.PHOSPHOROTHIOATE_LINKAGE_FLAGS]),this._terminalModifications.next(t[j.STRAND_TERMINUS_MODIFICATIONS]),this._comment$.next(t[q.PATTERN_COMMENT]),this._modificationsWithNumericLabels$.next(t[q.NUCLEOTIDES_WITH_NUMERIC_LABELS])}setLastLoadedPatternConfig(t){this._lastLoadedPatternConfig.next(lt().cloneDeep(t))}getPatternConfig(){return{[q.PATTERN_NAME]:this.getPatternName(),[j.IS_ANTISENSE_STRAND_INCLUDED]:this.isAntisenseStrandActive(),[j.NUCLEOTIDE_SEQUENCES]:this.getNucleotideSequences(),[j.PHOSPHOROTHIOATE_LINKAGE_FLAGS]:this.getPhosphorothioateLinkageFlags(),[j.STRAND_TERMINUS_MODIFICATIONS]:this.getTerminalModifications(),[q.PATTERN_COMMENT]:this.getComment(),[q.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 ct="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}?${ct}=${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(ct)}setPatternURL(t){null!==t&&""!==t?(this.urlSearchParams.set(ct,t),window.history.pushState({},"",`${window.location.pathname}?${this.urlSearchParams}`)):this.clearPatternURL()}clearPatternURL(){this.urlSearchParams.delete(ct),window.history.pushState({},"",`${window.location.pathname}`)}}var dt=n(5072),ft=n.n(dt),pt=n(7825),mt=n.n(pt),gt=n(7659),yt=n.n(gt),bt=n(5056),vt=n.n(bt),wt=n(540),Ct=n.n(wt),At=n(1113),xt=n.n(At),St=n(9252),Tt={};Tt.styleTagTransform=xt(),Tt.setAttributes=vt(),Tt.insert=yt().bind(null,"head"),Tt.domAPI=mt(),Tt.insertStyleElement=Ct(),ft()(St.A,Tt),St.A&&St.A.locals&&St.A.locals;class Et{constructor(t){this.eventBus=t,this.columnControlsContainer=M.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=M.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=M.input.choice("ID column",{value:t[0],items:t,onValueChanged:t=>this.eventBus.selectIdColumn(t)});return this.eventBus.selectIdColumn(t[0]),e.root}}class _t{constructor(t){this.eventBus=t,this.availableTables=[],this.tableInputContainer=M.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 M.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 It(t,e,n,r){const o=function(t,e,n){const r=new Array(t.length+e.filter((t=>t)).length+U.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],Kr.jsonData);return r})),n,r);return o.join("")}class Nt{constructor(t){this.eventBus=t,this.tableInputManager=new _t(t),this.columnInputManager=new Et(t)}createControls(){const t=M.h1("Bulk convert"),e=this.tableInputManager.getTableInputContainer(),n=this.columnInputManager.getColumnControlsContainer(),r=M.bigButton("Convert",(()=>this.processConvertButtonClick()));return[t,e,n,M.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=>It(r.get(t),i,a,s)))}))}(this.eventBus)}}class Mt{constructor(t,e,n){this.eventBus=t,this.initialPatternConfig=e,this.subscriptions=n}create(){return M.divV([M.h1("PTO"),M.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=M.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),M.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=M.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),M.tooltip.bind(n.captionLabel,`Activate first phosphothioate in ${t}`),n})).filter((t=>void 0!==t))}isFirstPtoActive(t){return this.initialPatternConfig.phosphorothioateLinkageFlags[t][0]}}class Ot{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 M.divH(t,{style:{gap:"24px"}})}constructControlsPanel(t){if(!this.eventBus.isAntisenseStrandActive()&&"AS"===t)return M.div([]);const e=this.constructHeader(),n=this.createControls(t);return M.block([M.h1(`${H[t]}`),e,n],{style:{paddingTop:"12px"}})}constructHeader(){return M.divH([M.div([M.divText("#")],{style:{width:"20px"}}),M.block75([M.divText("Modification")]),M.div([M.divText("PTO")])])}createControls(t){const e=this.createNucleobaseInputs(t),n=this.createLabelDivs(t),r=this.createPTOFlagInputs(t);return M.div(e.map(((t,e)=>M.divH([n[e],M.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=M.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=M.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=>M.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 M.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 Rt{constructor(t,e){this.eventBus=t,this.dataManager=e,this.subscriptions=new Lt}static open(t,e){Rt.isDialogOpen||(Rt.instance||(Rt.instance=new Rt(t,e)),Rt.instance.openDialog())}openDialog(){this.initialPatternConfig=lt().cloneDeep(this.eventBus.getPatternConfig()),Rt.isDialogOpen=!0,this.createDialog().show()}createDialog(){const t=M.divV([]);this.subscriptions.add(this.eventBus.strandsUpdated$.subscribe((()=>this.onStrandsUpdated(t))));const e=M.dialog("Edit strands").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 Mt(this.eventBus,this.initialPatternConfig,this.subscriptions).create(),n=new Ot(this.eventBus,this.dataManager,this.subscriptions).create();L()(t).empty(),L()(t).append(e,n)}resetToInitialState(){this.eventBus.setPatternConfig(this.initialPatternConfig)}}Rt.isDialogOpen=!1;class Pt{constructor(t){this.eventBus=t,this.subscriptions=new Lt}static open(t){Pt.isDialogOpen||(Pt.instance||(Pt.instance=new Pt(t)),Pt.instance.openDialog())}openDialog(){this.initialPatternConfig=lt().cloneDeep(this.eventBus.getPatternConfig()),Pt.isDialogOpen=!0,this.createDialog().show()}createDialog(){const t=M.divV([]);this.subscriptions.add(this.eventBus.strandsUpdated$.subscribe((()=>this.onStrandsUpdated(t))));const e=M.dialog("Edit terminal modifications").add(t).onOK((()=>{})).onCancel((()=>this.resetToInitialState()));return this.subscriptions.add(e.onClose.subscribe((()=>{Pt.isDialogOpen=!1,this.subscriptions.unsubscribeAll()}))),e}onStrandsUpdated(t){const e=new Bt(this.eventBus).create();L()(t).empty(),L()(t).append(e)}resetToInitialState(){this.eventBus.setPatternConfig(this.initialPatternConfig)}}Pt.isDialogOpen=!1;class Bt{constructor(t){this.eventBus=t}create(){const t=k.map((t=>this.constructControlsPanel(t)));return M.divH(t,{style:{gap:"24px"}})}constructControlsPanel(t){if(!this.eventBus.isAntisenseStrandActive()&&"AS"===t)return M.div([]);const e=this.createInputs(t);return M.block([M.h1(`${H[t]}`),e],{style:{paddingTop:"12px"}})}createInputs(t){const e=("SS"===t?[...U].reverse():U).map((e=>this.createInputForTerminus(t,e)));return M.form(e)}createInputForTerminus(t,e){const n=this.eventBus.getTerminalModifications()[t][e],r=M.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 Dt{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[M.h1("Edit"),t,n,r,o,s,i,M.buttonsInput([l,a])]}createEditPatternButton(){const t=M.button("Edit strands",(()=>Rt.open(this.eventBus,this.dataManager)));return M.tooltip.bind(t,"Edit strand modifications and PTOs"),t}createEditTerminalModificationsButton(){const t=M.button("Edit terminals",(()=>Pt.open(this.eventBus)));return M.tooltip.bind(t,"Edit terminal modifications"),L()(t).css("margin-right","20px"),t}createAntisenseStrandToggle(){const t=M.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=M.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=M.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=M.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=M.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 Ft{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[M.h1("Load"),t]}getPatternInputsContainer(){const t=M.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=M.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=M.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=M.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=M.button(M.iconFA("trash-alt"),(()=>{this.eventBus.getPatternName()!==this.dataManager.getDefaultPatternName()?this.showDeletePatternDialog():r.shell.warning("Cannot delete example pattern")}));M.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=M.dialog("Delete pattern"),e=this.eventBus.getPatternName();t.add(M.divText(`Are you sure you want to delete pattern ${e}?`)),t.onOK((()=>this.eventBus.requestPatternDeletion(e))),t.show()}}class kt{constructor(t,e){this.eventBus=t,this.dataManager=e}getLayout(){const t=new Ft(this.eventBus,this.dataManager),e=new Dt(this.eventBus,this.dataManager),n=new Nt(this.eventBus),r=t.createControls(),o=e.createControls(),i=n.createControls(),s=M.div(r);L()(s).css({"padding-bottom":"20px"});const a=M.div([...o,...i],"ui-form"),l=M.div([s,a]);return L()(l).css({padding:"25px"}),M.box(l,{style:{maxWidth:"450px"}})}}var Ht=n(9146);class Ut{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 $t{constructor(){}static getInstance(){return $t.instance||($t.instance=new $t,$t.instance.canvas=document.createElement("canvas")),$t.instance}static getTextDimensions(t,e){const n=$t.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(Kr.jsonData.patternAppData)[0];if(!e)throw new Error(`No format found in '${h}'`);return Kr.jsonData.patternAppData[e][t].color||""}class jt extends Ut{constructor(t,e,n){super(t,e,n);const r=k.filter((t=>e.nucleotideSequences[t].length>0));this.strands=r.map((t=>new qt(this.svgElementFactory,e,n,t))),this.terminalModifications=r.map(((t,r)=>new zt(this.svgElementFactory,e,n,t,this.strands[r]))),this.labels=r.map(((t,r)=>new Gt(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 qt extends Ut{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 Wt(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=$t.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=$t.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 Gt extends Ut{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=$t.getTextDimensions(e,17),r={x:10,y:Wt(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=$t.getTextDimensions(t,17),n={x:65+this.terminalModifications.getContentWidth()+5,y:Wt(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 zt extends Ut{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 $t.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:Wt(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?U:Array.from(U).reverse()).map((t=>this.createTerminalModification(t)))}get svgElements(){return this._svgElements}getContentWidth(){return this.strandSvgWrapper.getContentWidth()+U.map((t=>this.getTerminalModificationTextDimensions(t).width)).reduce(((t,e)=>t+e),0)}getContentHeight(){return this.strandSvgWrapper.getContentHeight()}}function Wt(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 Ut{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 $t.getTextDimensions(this.titleText,17).width}getContentHeight(){return $t.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 Jt extends Ut{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+$t.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 Qt{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 jt(this.svgElementFactory,e,n),n+=this.strands.getContentHeight()+10,this.legend=new Jt(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=M.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 Qt(t).renderPattern()}saveSvgAsPng(){const t=this.eventBus.getPatternName();Ht.saveSvgAsPng(this.svgElement,t,{backgroundColor:"white"})}}class Zt{constructor(t){this.eventBus=t,this.togglesContainer=M.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))),M.divH(t.map((t=>t.root)))}createSingleInput(t){const e=this.eventBus.getModificationsWithNumericLabels().includes(t),n=M.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 M.div([M.h1("Translation example"),this.createTranslationExamples()],{style:{paddingTop:"20px"}})}createTranslationExamples(){const t=M.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(),M.block50([M.h2(H[this.strand]),this.inputExample.root,this.outputExample.root],{style:{paddingRight:"20px"}})):M.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 It(t,e,this.eventBus.getPhosphorothioateLinkageFlags()[this.strand],n)}createTextInputForExamples(){const t=M.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 M.panel([this.svgDisplay,t,e,n],{style:{overflowX:"scroll",padding:"12px 24px"}})}generateDownloadControls(){return M.divH([this.createSavePatternButton(),this.createDownloadPngButton(),this.createShareLinkButton(),this.createInfoButton()],{style:{gap:"12px",marginTop:"12px"}})}createDownloadPngButton(){const t=M.button("Get PNG",(()=>this.eventBus.requestSvgSave()));return M.tooltip.bind(t,"Download pattern as PNG"),t}createInfoButton(){const t=M.button(M.iconFA("info-circle"),(()=>this.openInfoDialog()));return this.eventBus.patternHasUnsavedChanges$.subscribe((e=>{t.disabled=e})),M.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[G.AUTHOR_ID];if(t=(await r.dapi.users.find(i)).friendlyName,e=s[G.PATTERN_CONFIG][q.PATTERN_NAME],void 0!==s[G.DATE]){const t=s[G.DATE][z.CREATE];void 0!==t&&(n=t);const e=s[G.DATE][z.MODIFY];void 0!==e&&(o=e)}}}const s=M.divV([M.divText(`Pattern Name: ${e}`),M.divText(`Author: ${t}`),M.divText(`Created: ${oe(new Date(n))}`),M.divText(`Modified: ${oe(new Date(o))}`)]);r.shell.info(s)}createShareLinkButton(){const t=M.button(M.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})),M.tooltip.bind(t,"Share pattern link"),t}createSavePatternButton(){const t=M.button("Save",(()=>this.processSaveButtonClick()));return this.eventBus.patternHasUnsavedChanges$.subscribe((e=>{t.disabled=!e})),M.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 J?new re(this.eventBus,this.dataManager).show():t instanceof Q?r.shell.warning(M.div([M.divText("Pattern already exists"),M.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=M.dialog(`Pattern "${t}" already exists`);e.add(M.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 ut(t,n);e.subscribeToObservables(r);const o=new kt(r,t).getLayout(),i=new ne(r,t).getLayout();return M.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=xt(),ae.setAttributes=vt(),ae.insert=yt().bind(null,"head"),ae.domAPI=mt(),ae.insertStyleElement=Ct(),ft()(se.A,ae),se.A&&se.A.locals&&se.A.locals;var ue,ce=n(2074),he={};he.styleTagTransform=xt(),he.setAttributes=vt(),he.insert=yt().bind(null,"head"),he.domAPI=mt(),he.insertStyleElement=Ct(),ft()(ce.A,he),ce.A&&ce.A.locals&&ce.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=M.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"}(ue||(ue={}));class fe{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 pe extends fe{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 pe{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(ue.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(ue.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(ue.TYPE)&&-1!==t.indexOf(ue.END)}shiftIdxToAtomType(t){return this.shiftIdxToSpecifiedColumn(t,ue.ATOM_TYPE_COL)}getCountsLineIdx(){let t=0;for(let e=0;e<ue.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,ue.FIRST_BONDED_ATOM_COL)}shiftIdxToBondType(t){return this.shiftIdxToSpecifiedColumn(t,ue.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+ue.NUM_OF_COUNTS_DIGITS;const n=parseInt(this.fileContent.substring(t,e));return t=e,e+=ue.NUM_OF_COUNTS_DIGITS,{atomCount:n,bondCount:parseInt(this.fileContent.substring(t,e))}}}class ge extends pe{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=M.dialog({title:"Molecule",showFooter:!1}),e=.7*L()(window).height(),n=this.getMoleculeDimensions(),r=e/n.height,o=e,i=n.width*r,s=M.canvas(i,o);await this.drawMolBlockOnCanvas(s);const a=M.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=M.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(M.tooltip.bind(r,"Click to zoom"))}}class we extends Error{constructor(t,e){super(t,e)}}class Ce{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 Kr.jsonData.monomersWithPhosphate.left.includes(t)}(o)&&e.pop(),e.push(o);const i=Ae(o),s=r===t.length-1,a=r+1<t.length&&Ae(this.getSymbolForCode(t[r+1]));i||function(t){return Kr.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 we(`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 Ae(t){return Kr.jsonData.monomersWithPhosphate.phosphate.includes(t)}class xe{constructor(t,e=!1,n){this.invert=e,this.lib=Kr.monomerLibWrapper;const r=this.lib.getCodeToSymbolMap(n);this.parser=new Ce(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 u=l;for(let r=0;r<n;r++)l=t.indexOf("V30",l)+4,l=t.indexOf(" ",l)+1,l=t.indexOf(" ",l)+1,u=t.indexOf(" ",l)+1,u=t.indexOf(" ",u),l=(t=t.slice(0,l)+e.x[r]+" "+e.y[r]+t.slice(u)).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),u=Math.sin(a);for(let t=0;t<n;t++){const n=e.x[t];e.x[t]=n*l-e.y[t]*u,e.y[t]=n*u+e.y[t]*l}const c=e.x[r];for(let t=0;t<n;t++)e.x[t]-=c;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,u=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 c=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 f=d,p=d;for(let r=0;r<c.natom;r++)if(1!==h.atomIndex[r]||0===e){f=t[e].indexOf("V30",f)+4,p=t[e].indexOf(" ",f);let r=0;n?(r=parseInt(t[e].substring(f,p)),1===r?r=i:r===i&&(r=1),r+=a):r=parseInt(t[e].substring(f,p))+a,t[e]=t[e].slice(0,f)+r+t[e].slice(p),f=t[e].indexOf(" ",f)+1,f=t[e].indexOf(" ",f)+1,p=t[e].indexOf(" ",f);const o=u-h.x[0];let s=Math.round(1e4*(parseFloat(t[e].substring(f,p))+o))/1e4;t[e]=t[e].slice(0,f)+s+t[e].slice(p),f=t[e].indexOf(" ",f)+1,p=t[e].indexOf(" ",f),s=Math.round(1e4*parseFloat(t[e].substring(f,p)))/1e4,t[e]=t[e].slice(0,f)+s+t[e].slice(p),f=t[e].indexOf("\n",f)+1}else f=t[e].indexOf("M V30",f)-1,p=t[e].indexOf("\n",f+1),t[e]=t[e].slice(0,f)+t[e].slice(p);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),f=g,p=g;for(let r=0;r<c.nbond;r++){f=t[e].indexOf("V30",f)+4,p=t[e].indexOf(" ",f);const r=parseInt(t[e].substring(f,p))+l;t[e]=t[e].slice(0,f)+r+t[e].slice(p),f=t[e].indexOf(" ",f)+1,f=t[e].indexOf(" ",f)+1,p=t[e].indexOf(" ",f);let o=0;n?(o=parseInt(t[e].substring(f,p)),1===o?o=i:o===i&&(o=1),o+=a):o=parseInt(t[e].substring(f,p))+a,t[e]=t[e].slice(0,f)+o+t[e].slice(p),f=t[e].indexOf(" ",f)+1,p=Math.min(t[e].indexOf("\n",f),t[e].indexOf(" ",f)),o=0,n?(o=parseInt(t[e].substring(f,p)),1===o?o=i:o===i&&(o=1),o+=a):o=parseInt(t[e].substring(f,p))+a,t[e]=t[e].slice(0,f)+o+t[e].slice(p),f=t[e].indexOf("\n",f)+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+=c.natom-1,l+=c.nbond,u+=n?Math.max(...h.x):h.x[c.natom-1]-h.x[0]}const c=Math.ceil(s.length/4);i+="M V30 MDLV30/STEABS ATOMS=("+s.length+" -\n";for(let t=0;t<c;t++){i+="M V30 ";const e=t+1===c?s.length-4*(c-1):4;for(let n=0;n<e;n++)i+=n+1===e?t===c-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,u=t.y[e]-i,c=l*Math.cos(2*Math.PI/3)-u*Math.sin(2*Math.PI/3),h=l*Math.sin(2*Math.PI/3)+u*Math.cos(2*Math.PI/3),d=l-s,f=u-a,p=c-s,m=h-a;Math.sqrt(m*m+p*p)>=Math.sqrt(f*f+d*d)&&(t.x[e]=c+o,t.y[e]=h+i)}}function Se(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,u=0;if(t.antiStrands.length>0)for(let e=0;e<t.antiStrands.length;e++)t.antiStrands[e]=Te(t.antiStrands[e]);let c=!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=Ee(h[e]),i=_e(h[e]);if(e>=t.senseStrands.length?!1===c&&(c=!0,u=0):d=Math.min(d,Math.min(...i.y.filter((t=>t<0)))),c){const t=Math.min(...i.x)-u,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 f=h[e].indexOf("M V30 BEGIN ATOM");f=h[e].indexOf("\n",f);let p=f,m=f;for(let t=0;t<n.natom;t++){p=h[e].indexOf("V30",p)+4,m=h[e].indexOf(" ",p);const n=parseInt(h[e].substring(p,m))+a;h[e]=h[e].slice(0,p)+n+h[e].slice(m),p=h[e].indexOf(" ",p)+1,p=h[e].indexOf(" ",p)+1,m=h[e].indexOf(" ",p);let r=Math.round(1e4*i.x[t])/1e4;h[e]=h[e].slice(0,p)+r+h[e].slice(m),p=h[e].indexOf(" ",p)+1,m=h[e].indexOf(" ",p),r=Math.round(1e4*i.y[t])/1e4,h[e]=h[e].slice(0,p)+r+h[e].slice(m),p=h[e].indexOf("\n",p)+1}const g=h[e].indexOf("M V30 END ATOM");r+=h[e].substring(f+1,g);let y=h[e].indexOf("M V30 BEGIN BOND");y=h[e].indexOf("\n",y),p=y,m=y;for(let t=0;t<n.nbond;t++){p=h[e].indexOf("V30",p)+4,m=h[e].indexOf(" ",p);const t=parseInt(h[e].substring(p,m))+l;h[e]=h[e].slice(0,p)+t+h[e].slice(m),p=h[e].indexOf(" ",p)+1,p=h[e].indexOf(" ",p)+1,m=h[e].indexOf(" ",p);let n=parseInt(h[e].substring(p,m))+a;h[e]=h[e].slice(0,p)+n+h[e].slice(m),p=h[e].indexOf(" ",p)+1,m=Math.min(h[e].indexOf("\n",p),h[e].indexOf(" ",p)),n=parseInt(h[e].substring(p,m))+a,h[e]=h[e].slice(0,p)+n+h[e].slice(m),p=h[e].indexOf("\n",p)+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,u+=Math.max(...i.x)+5}const f=Math.ceil(s.length/4);i+="M V30 MDLV30/STEABS ATOMS=("+s.length+" -\n";for(let t=0;t<f;t++){i+="M V30 ";const e=t+1===f?s.length-4*(f-1):4;for(let n=0;n<e;n++)i+=n+1===e?t===f-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 Te(t){const e=_e(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 u=t.indexOf("M V30 BEGIN ATOM");u=t.indexOf("\n",u);let c=u;for(let r=0;r<n;r++)u=t.indexOf("V30",u)+4,u=t.indexOf(" ",u)+1,u=t.indexOf(" ",u)+1,c=t.indexOf(" ",u)+1,c=t.indexOf(" ",c),u=(t=t.slice(0,u)+e.x[r]+" "+e.y[r]+t.slice(c)).indexOf("\n",u)+1;return t}function Ee(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 _e(t){const e=Ee(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 Ie(t,e,n){if(""===t)return"";const r=n.createFormatDetector(t).getFormat();if(!r)return"";let o="";try{o=new xe(t,e,r).convert()}catch(t){const e=le(t);console.error(e)}return o}function Ne(t,e,n,r,o){const i=[t,e,n].filter((t=>""!==t.strand));return 1===i.length?Ie(i[0].strand,i[0].invert,o):Se({senseStrands:[Ie(t.strand,t.invert,o)],antiStrands:[Ie(e.strand,e.invert,o),Ie(n.strand,n.invert,o)].filter((t=>""!==t))},r)}const Me=["ss","as","as2"];class Oe{constructor(){this.th=Kr,this.onInput=new et.Subject,this.onInvalidInput=new et.Subject,this.inputBase=Object.fromEntries(Me.map((t=>{const e=M.input.textArea(t.toUpperCase(),{value:"",onValueChanged:()=>{this.onInput.next(),L()(e.root.getElementsByTagName("div")).css("padding-left","38px")}});return[t,e]}))),this.useChiralInput=M.input.bool("Use chiral",{value:!0}),this.saveAllStrandsInput=M.input.bool("Save as one entity",{value:!0}),M.tooltip.bind(this.saveAllStrandsInput.root,"Save SDF with all strands in one molfile"),this.directionInversion=Object.fromEntries(Me.map((t=>[t,!1]))),this.moleculeImgDiv=M.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=M.divH([n,this.moleculeImgDiv]);L()(r).addClass("st-structure-bottom");const o=M.divV([e,r]);return L()(o).addClass("st-structure-body"),o}getBoolInputsAndButton(){const t=M.buttonsInput([M.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=Ne(t,e,n,o,s)+"\n$$$$\n";else{const h=Ie(t.strand,t.invert,s),d=Ie(e.strand,e.invert,s),f=Ie(n.strand,n.invert,s);l=h+"\n> <Sequence>\nSense Strand\n$$$$\n",d&&(l+=d+"\n> <Sequence>\nAnti Sense\n$$$$\n"),f&&(l+=f+"\n> <Sequence>\nAnti Sense 2\n$$$$\n")}const u=new Date;function c(t){return t>=10?t.toString():"0"+t.toString()}y(`SequenceTranslator-${u.getFullYear()+"-"+c(u.getMonth()+1)+"-"+c(u.getDate())+"_"+c(u.getHours())+"-"+c(u.getMinutes())+"-"+c(u.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=M.divV(e);for(const t of e)L()(t).addClass("st-structure-bool-button-block");return n}getTableInput(t){const e=Object.fromEntries(Me.map((e=>[e,new de(this.inputBase[e],t.highlightInvalidSubsequence)]))),n=Object.fromEntries(Me.map(((t,e)=>{const n=0===e?"5′ → 3′":"3′ → 5′";return[t,M.input.choice(`${t.toUpperCase()} direction`,{value:n,items:["5′ → 3′","3′ → 5′"]})]})));Me.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(Me.map(((t,e)=>[t,r[e]]))),i=(Object.fromEntries(Me.map((t=>[t,M.label(o.get(t))]))),Object.fromEntries(Me.map((t=>{const n=M.icons.delete((()=>{e[t].inputBase.value=""})),r=M.button(n,(()=>{}));return M.tooltip.bind(r,`Clear ${t.toUpperCase()}`),[t,n]})))),s=M.form([],"st-structure-inputs"),a=M.divV([],"st-structure-clear-buttons"),l=M.form([],"st-direction-inputs");for(const t of Me)s.append(this.inputBase[t].root),a.append(i[t]),l.append(n[t].root);return M.divH([s,a,l])}getStrandData(){return Object.fromEntries(Me.map((t=>{const e=this.directionInversion[t];return[t,{strand:this.inputBase[t].value.replace(/\s*/g,""),invert:e}]})))}getMolfile(t,e,n){return Ne(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),L()(this.moleculeImgDiv).find("canvas").css("float","inherit")}}class Le extends F{constructor(t){super("Oligo Structure"),this.th=t,this.layout=new Oe}getContent(){return this.layout.getHtmlDivElement(this.th)}}var Re=n(2003);async function Pe(t){try{const e={overflowX:"scroll"},n=M.div([],{style:e}),o=_e(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,u=l*s,c=l*a,h=M.canvas(u*window.devicePixelRatio,c*window.devicePixelRatio);h.style.width=`${u}px`,h.style.height=`${c}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),M.dialog("Molecule").add(n).showModal(!0)}catch(t){const e=le(t);console.error(e)}}class Be{static async view(){const t=Kr.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 Pe(e)}))}}var De=n(3480),Fe=n(5067),ke=n(5254),He={};He.styleTagTransform=xt(),He.setAttributes=vt(),He.insert=yt().bind(null,"head"),He.domAPI=mt(),He.insertStyleElement=Ct(),ft()(ke.A,He),ke.A&&ke.A.locals&&ke.A.locals;const Ue=["Sequence"];class $e{constructor(t){this.th=t,this.inputFormats=Object.keys(Kr.jsonData.codesToHelmDict).concat(m.NO.HELM),this.seqHelper=Kr.seqHelper,this.onInput=new et.Subject,this.moleculeImgDiv=M.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=M.div([]),this.formatChoiceInput=M.input.choice("",{value:m.NO.HELM,items:this.inputFormats,onValueChanged:async(t,e)=>{this.format=t,this.updateTable(),await this.updateMolImg()}}),L()(this.formatChoiceInput.root.getElementsByTagName("select")[0]).css("width","20%"),this.sequenceInputBase=M.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=Ge.getInstance()}async getHtmlElement(){const t=this.constructSingleSequenceControls(),e=this.constructBulkTranslationControls(),n=M.box(M.panel([t,e,M.block([M.box(this.moleculeImgDiv)])]));return this.formatChoiceInput.value=this.format,this.updateTable(),await this.updateMolImg(),n}constructBulkTranslationControls(){const t=M.h1("Bulk");M.tooltip.bind(t,"Bulk translation from table input");const e=new Ve(this.eventBus).createUIComponents(),n=M.input.choice("Input format",{value:m.NO.AXOLABS,items:this.inputFormats,onValueChanged:t=>this.eventBus.selectInputFormat(t)}),r=M.input.choice("Output format",{value:Fe.qP,items:(0,De.OT)(this.th),onValueChanged:t=>this.eventBus.selectOutputFormat(t)}),o=this.createConvertBulkButton(),i=M.div([...e,n,r,o],"ui-form");return M.block25([t,i])}createConvertBulkButton(){const t=M.bigButton("Convert",(()=>this.processConvertBulkButtonClick()));return M.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,De.C6)(t,e,n,this.th))));if(n===Fe.qP||n===m.NO.HELM){a.semType=o.SEMTYPE.MACROMOLECULE;const t=n==Fe.qP?Re.Hi.FASTA:Re.Hi.HELM;a.meta.units=t;const e=this.seqHelper.getSeqHandler(a);(n==Fe.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=>R(t,this.th))),e=M.button("Get SDF",(()=>{this.saveMolfile()}),"Save structure as SDF"),n=M.button("Copy SMILES",(()=>{this.copySmiles()}),"Copy SMILES for the sequence"),r=M.div([this.formatChoiceInput]),o=M.button(M.icons.delete((()=>{t.inputBase.value=""})),(()=>{}));M.tooltip.bind(o,"Clear input");const i={format:r,textInput:t.root,clearBtn:o},s=M.table([i],(t=>[t.format,t.textInput,t.clearBtn]));s.classList.add("st-translator-input-table");const a=M.block([this.outputTableDiv,e,n]);return M.block75([M.h1("Single sequence"),s,a])}saveMolfile(){const t=new xe(this.sequence,!1,this.formatChoiceInput.value).convert()+"\n$$$$";y(this.sequence+".sdf",encodeURIComponent(t))}copySmiles(){const t=o.chem.convert(this.molfile,o.chem.Notation.MolBlock,o.chem.Notation.Smiles);navigator.clipboard.writeText(t).then((()=>r.shell.info(Fe.n_)))}updateTable(){this.outputTableDiv.innerHTML="";const t=this.format?this.th.createSequenceValidator(this.sequence).getInvalidCodeIndex(this.format):0,e=(0,De.bD)(this.sequence,t,this.format,this.th),n=[];for(const t of Object.keys(e)){const o="indexOfFirstInvalidChar"in e?M.divH([]):M.link(e[t],(()=>navigator.clipboard.writeText(e[t]).then((()=>r.shell.info(Fe.n_)))),Fe.U_,"");n.push({format:t,sequence:o})}const o=M.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 xe(t,!1,m.NO.AXOLABS).convert()}return new xe(this.sequence,!1,this.format).convert()}}class Ve{constructor(t){this.tableInputManager=new je(t),this.columnInputManager=new qe(t)}createUIComponents(){return[this.tableInputManager.getTableInputContainer(),this.columnInputManager.getColumnControlsContainer()]}}class je{constructor(t){this.eventBus=t,this.availableTables=[],this.tableInputContainer=M.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 M.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 qe{constructor(t){this.eventBus=t,this.columnControlsContainer=M.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 Ue.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),M.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 Ge{constructor(){this._tableSelection$=new et.BehaviorSubject(null),this._columnSelection=Object.fromEntries(Ue.map((t=>[t,new et.BehaviorSubject(null)]))),this._inputFormatSelection$=new et.BehaviorSubject(m.NO.AXOLABS),this._outputFormatSelection$=new et.BehaviorSubject(Fe.qP)}static getInstance(){return void 0===Ge._instance&&(Ge._instance=new Ge),Ge._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 ze extends F{constructor(t){super("Oligo Translator"),this.th=t,this.th=Kr,this.layout=new $e(this.th);const e=M.iconFA("book",Be.view,"View monomer library");this.topPanel=[e],this.view.setRibbonPanels([this.topPanel])}getContent(){return this.layout.getHtmlElement()}}class We extends F{constructor(t,e){super(t),this.content=e}getContent(){return Promise.resolve(this.content)}}class Ye extends D{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(ze),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/${Kr.name}/OligoToolkit/${t}`}setUrl(){this.multiView.path=this.getCurrentPanePath()}async constructView(){return this.multiView.tabs.onTabChanged.subscribe((()=>this.setUrl())),this.setUrl(),this.multiView}}var Ke=n(8070);function Je(t){const e=M.input.textArea("",{value:""});return{coloredInput:new de(e,t.highlightInvalidSubsequence),codes:t.jsonData.codesToSymbolsDict}}var Qe=n(9124),Xe=n(9192),Ze=n(8312),tn=n(1991),en=n.n(tn);const nn="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,rn=new Set,on="object"==typeof process&&process?process:{},sn=(t,e,n,r)=>{"function"==typeof on.emitWarning?on.emitWarning(t,e,n,r):console.error(`[${n}] ${e}: ${t}`)};let an=globalThis.AbortController,ln=globalThis.AbortSignal;if(void 0===an){ln=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(t,e){this._onabort.push(e)}},an=class{constructor(){e()}signal=new ln;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"!==on.env?.LRU_CACHE_IGNORE_AC_WARNING;const e=()=>{t&&(t=!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",e))}}Symbol("type");const un=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),cn=t=>un(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?hn:null:null;class hn extends Array{constructor(t){super(t),this.fill(0)}}class dn{heap;length;static#t=!1;static create(t){const e=cn(t);if(!e)return[];dn.#t=!0;const n=new dn(t,e);return dn.#t=!1,n}constructor(t,e){if(!dn.#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 fn{#e;#n;#r;#o;#i;#s;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#a;#l;#u;#c;#h;#d;#f;#p;#m;#g;#y;#b;#v;#w;#C;#A;#x;static unsafeExposeInternals(t){return{starts:t.#v,ttls:t.#w,sizes:t.#b,keyMap:t.#u,keyList:t.#c,valList:t.#h,next:t.#d,prev:t.#f,get head(){return t.#p},get tail(){return t.#m},free:t.#g,isBackgroundFetch:e=>t.#S(e),backgroundFetch:(e,n,r,o)=>t.#T(e,n,r,o),moveToTail:e=>t.#E(e),indexes:e=>t.#_(e),rindexes:e=>t.#I(e),isStale:e=>t.#N(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:u,noDisposeOnSet:c,noUpdateTTL:h,maxSize:d=0,maxEntrySize:f=0,sizeCalculation:p,fetchMethod:m,memoMethod:g,noDeleteOnFetchRejection:y,noDeleteOnStaleGet:b,allowStaleOnFetchRejection:v,allowStaleOnFetchAbort:w,ignoreFetchAbort:C}=t;if(0!==e&&!un(e))throw new TypeError("max option must be a nonnegative integer");const A=e?cn(e):Array;if(!A)throw new Error("invalid max value: "+e);if(this.#e=e,this.#n=d,this.maxEntrySize=f||this.#n,this.sizeCalculation=p,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.#A=!!m,this.#u=new Map,this.#c=new Array(e).fill(void 0),this.#h=new Array(e).fill(void 0),this.#d=new A(e),this.#f=new A(e),this.#p=0,this.#m=0,this.#g=dn.create(e),this.#a=0,this.#l=0,"function"==typeof l&&(this.#r=l),"function"==typeof u?(this.#o=u,this.#y=[]):(this.#o=void 0,this.#y=void 0),this.#C=!!this.#r,this.#x=!!this.#o,this.noDisposeOnSet=!!c,this.noUpdateTTL=!!h,this.noDeleteOnFetchRejection=!!y,this.allowStaleOnFetchRejection=!!v,this.allowStaleOnFetchAbort=!!w,this.ignoreFetchAbort=!!C,0!==this.maxEntrySize){if(0!==this.#n&&!un(this.#n))throw new TypeError("maxSize must be a positive integer if specified");if(!un(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#M()}if(this.allowStale=!!a,this.noDeleteOnStaleGet=!!b,this.updateAgeOnGet=!!i,this.updateAgeOnHas=!!s,this.ttlResolution=un(r)||0===r?r:1,this.ttlAutopurge=!!o,this.ttl=n||0,this.ttl){if(!un(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#O()}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=>!rn.has(t))(t)&&(rn.add(t),sn("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",t,fn))}}getRemainingTTL(t){return this.#u.has(t)?1/0:0}#O(){const t=new hn(this.#e),e=new hn(this.#e);this.#w=t,this.#v=e,this.#L=(n,r,o=nn.now())=>{if(e[n]=0!==r?o:0,t[n]=r,0!==r&&this.ttlAutopurge){const t=setTimeout((()=>{this.#N(n)&&this.#R(this.#c[n],"expire")}),r+1);t.unref&&t.unref()}},this.#P=n=>{e[n]=0!==t[n]?nn.now():0},this.#B=(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=nn.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.#u.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.#N=o=>{const i=e[o],s=t[o];return!!s&&!!i&&(n||r())-i>s}}#P=()=>{};#B=()=>{};#L=()=>{};#N=()=>!1;#M(){const t=new hn(this.#e);this.#l=0,this.#b=t,this.#D=e=>{this.#l-=t[e],t[e]=0},this.#F=(t,e,n,r)=>{if(this.#S(e))return 0;if(!un(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),!un(n))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return n},this.#k=(e,n,r)=>{if(t[e]=n,this.#n){const n=this.#n-t[e];for(;this.#l>n;)this.#H(!0)}this.#l+=t[e],r&&(r.entrySize=n,r.totalCalculatedSize=this.#l)}}#D=t=>{};#k=(t,e,n)=>{};#F=(t,e,n,r)=>{if(n||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#_({allowStale:t=this.allowStale}={}){if(this.#a)for(let e=this.#m;this.#U(e)&&(!t&&this.#N(e)||(yield e),e!==this.#p);)e=this.#f[e]}*#I({allowStale:t=this.allowStale}={}){if(this.#a)for(let e=this.#p;this.#U(e)&&(!t&&this.#N(e)||(yield e),e!==this.#m);)e=this.#d[e]}#U(t){return void 0!==t&&this.#u.get(this.#c[t])===t}*entries(){for(const t of this.#_())void 0===this.#h[t]||void 0===this.#c[t]||this.#S(this.#h[t])||(yield[this.#c[t],this.#h[t]])}*rentries(){for(const t of this.#I())void 0===this.#h[t]||void 0===this.#c[t]||this.#S(this.#h[t])||(yield[this.#c[t],this.#h[t]])}*keys(){for(const t of this.#_()){const e=this.#c[t];void 0===e||this.#S(this.#h[t])||(yield e)}}*rkeys(){for(const t of this.#I()){const e=this.#c[t];void 0===e||this.#S(this.#h[t])||(yield e)}}*values(){for(const t of this.#_())void 0===this.#h[t]||this.#S(this.#h[t])||(yield this.#h[t])}*rvalues(){for(const t of this.#I())void 0===this.#h[t]||this.#S(this.#h[t])||(yield this.#h[t])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,e={}){for(const n of this.#_()){const r=this.#h[n],o=this.#S(r)?r.__staleWhileFetching:r;if(void 0!==o&&t(o,this.#c[n],this))return this.get(this.#c[n],e)}}forEach(t,e=this){for(const n of this.#_()){const r=this.#h[n],o=this.#S(r)?r.__staleWhileFetching:r;void 0!==o&&t.call(e,o,this.#c[n],this)}}rforEach(t,e=this){for(const n of this.#I()){const r=this.#h[n],o=this.#S(r)?r.__staleWhileFetching:r;void 0!==o&&t.call(e,o,this.#c[n],this)}}purgeStale(){let t=!1;for(const e of this.#I({allowStale:!0}))this.#N(e)&&(this.#R(this.#c[e],"expire"),t=!0);return t}info(t){const e=this.#u.get(t);if(void 0===e)return;const n=this.#h[e],r=this.#S(n)?n.__staleWhileFetching:n;if(void 0===r)return;const o={value:r};if(this.#w&&this.#v){const t=this.#w[e],n=this.#v[e];if(t&&n){const e=t-(nn.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.#_({allowStale:!0})){const n=this.#c[e],r=this.#h[e],o=this.#S(r)?r.__staleWhileFetching:r;if(void 0===o||void 0===n)continue;const i={value:o};if(this.#w&&this.#v){i.ttl=this.#w[e];const t=nn.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=nn.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 u=this.#F(t,e,n.size||0,s);if(this.maxEntrySize&&u>this.maxEntrySize)return a&&(a.set="miss",a.maxEntrySizeExceeded=!0),this.#R(t,"set"),this;let c=0===this.#a?void 0:this.#u.get(t);if(void 0===c)c=0===this.#a?this.#m:0!==this.#g.length?this.#g.pop():this.#a===this.#e?this.#H(!1):this.#a,this.#c[c]=t,this.#h[c]=e,this.#u.set(t,c),this.#d[this.#m]=c,this.#f[c]=this.#m,this.#m=c,this.#a++,this.#k(c,u,a),a&&(a.set="add"),l=!1;else{this.#E(c);const n=this.#h[c];if(e!==n){if(this.#A&&this.#S(n)){n.__abortController.abort(new Error("replaced"));const{__staleWhileFetching:e}=n;void 0===e||i||(this.#C&&this.#r?.(e,t,"set"),this.#x&&this.#y?.push([e,t,"set"]))}else i||(this.#C&&this.#r?.(n,t,"set"),this.#x&&this.#y?.push([n,t,"set"]));if(this.#D(c),this.#k(c,u,a),this.#h[c]=e,a){a.set="replace";const t=n&&this.#S(n)?n.__staleWhileFetching:n;void 0!==t&&(a.oldValue=t)}}else a&&(a.set="update")}if(0===r||this.#w||this.#O(),this.#w&&(l||this.#L(c,r,o),a&&this.#B(a,c)),!i&&this.#x&&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.#p];if(this.#H(!0),this.#S(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(void 0!==t)return t}}finally{if(this.#x&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#o?.(...e)}}}#H(t){const e=this.#p,n=this.#c[e],r=this.#h[e];return this.#A&&this.#S(r)?r.__abortController.abort(new Error("evicted")):(this.#C||this.#x)&&(this.#C&&this.#r?.(r,n,"evict"),this.#x&&this.#y?.push([r,n,"evict"])),this.#D(e),t&&(this.#c[e]=void 0,this.#h[e]=void 0,this.#g.push(e)),1===this.#a?(this.#p=this.#m=0,this.#g.length=0):this.#p=this.#d[e],this.#u.delete(n),this.#a--,e}has(t,e={}){const{updateAgeOnHas:n=this.updateAgeOnHas,status:r}=e,o=this.#u.get(t);if(void 0!==o){const t=this.#h[o];if(this.#S(t)&&void 0===t.__staleWhileFetching)return!1;if(!this.#N(o))return n&&this.#P(o),r&&(r.has="hit",this.#B(r,o)),!0;r&&(r.has="stale",this.#B(r,o))}else r&&(r.has="miss");return!1}peek(t,e={}){const{allowStale:n=this.allowStale}=e,r=this.#u.get(t);if(void 0===r||!n&&this.#N(r))return;const o=this.#h[r];return this.#S(o)?o.__staleWhileFetching:o}#T(t,e,n,r){const o=void 0===e?void 0:this.#h[e];if(this.#S(o))return o;const i=new an,{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 u(i.signal.reason);const h=c;return this.#h[e]===c&&(void 0===r?h.__staleWhileFetching?this.#h[e]=h.__staleWhileFetching:this.#R(t,"fetch"):(n.status&&(n.status.fetchUpdated=!0),this.set(t,r,a.options))),r},u=r=>{const{aborted:o}=i.signal,s=o&&n.allowStaleOnFetchAbort,a=s||n.allowStaleOnFetchRejection,l=a||n.noDeleteOnFetchRejection,u=c;if(this.#h[e]===c&&(l&&void 0!==u.__staleWhileFetching?s||(this.#h[e]=u.__staleWhileFetching):this.#R(t,"fetch")),a)return n.status&&void 0!==u.__staleWhileFetching&&(n.status.returnedStale=!0),u.__staleWhileFetching;if(u.__returned===u)throw r};n.status&&(n.status.fetchDispatched=!0);const c=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),u(t)))),h=Object.assign(c,{__abortController:i,__staleWhileFetching:o,__returned:void 0});return void 0===e?(this.set(t,h,{...a.options,status:void 0}),e=this.#u.get(t)):this.#h[e]=h,h}#S(t){if(!this.#A)return!1;const e=t;return!!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof an}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:u=this.noUpdateTTL,noDeleteOnFetchRejection:c=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:h=this.allowStaleOnFetchRejection,ignoreFetchAbort:d=this.ignoreFetchAbort,allowStaleOnFetchAbort:f=this.allowStaleOnFetchAbort,context:p,forceRefresh:m=!1,status:g,signal:y}=e;if(!this.#A)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:u,noDeleteOnFetchRejection:c,allowStaleOnFetchRejection:h,allowStaleOnFetchAbort:f,ignoreFetchAbort:d,status:g,signal:y};let v=this.#u.get(t);if(void 0===v){g&&(g.fetch="miss");const e=this.#T(t,v,b,p);return e.__returned=e}{const e=this.#h[v];if(this.#S(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.#N(v);if(!m&&!o)return g&&(g.fetch="hit"),this.#E(v),r&&this.#P(v),g&&this.#B(g,v),e;const i=this.#T(t,v,b,p),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.#u.get(t);if(void 0!==s){const e=this.#h[s],a=this.#S(e);return i&&this.#B(i,s),this.#N(s)?(i&&(i.get="stale"),a?(i&&n&&void 0!==e.__staleWhileFetching&&(i.returnedStale=!0),n?e.__staleWhileFetching:void 0):(o||this.#R(t,"expire"),i&&n&&(i.returnedStale=!0),n?e:void 0)):(i&&(i.get="hit"),a?e.__staleWhileFetching:(this.#E(s),r&&this.#P(s),e))}i&&(i.get="miss")}#$(t,e){this.#f[e]=t,this.#d[t]=e}#E(t){t!==this.#m&&(t===this.#p?this.#p=this.#d[t]:this.#$(this.#f[t],this.#d[t]),this.#$(this.#m,t),this.#m=t)}delete(t){return this.#R(t,"delete")}#R(t,e){let n=!1;if(0!==this.#a){const r=this.#u.get(t);if(void 0!==r)if(n=!0,1===this.#a)this.#V(e);else{this.#D(r);const n=this.#h[r];if(this.#S(n)?n.__abortController.abort(new Error("deleted")):(this.#C||this.#x)&&(this.#C&&this.#r?.(n,t,e),this.#x&&this.#y?.push([n,t,e])),this.#u.delete(t),this.#c[r]=void 0,this.#h[r]=void 0,r===this.#m)this.#m=this.#f[r];else if(r===this.#p)this.#p=this.#d[r];else{const t=this.#f[r];this.#d[t]=this.#d[r];const e=this.#d[r];this.#f[e]=this.#f[r]}this.#a--,this.#g.push(r)}}if(this.#x&&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.#I({allowStale:!0})){const n=this.#h[e];if(this.#S(n))n.__abortController.abort(new Error("deleted"));else{const r=this.#c[e];this.#C&&this.#r?.(n,r,t),this.#x&&this.#y?.push([n,r,t])}}if(this.#u.clear(),this.#h.fill(void 0),this.#c.fill(void 0),this.#w&&this.#v&&(this.#w.fill(0),this.#v.fill(0)),this.#b&&this.#b.fill(0),this.#p=0,this.#m=0,this.#g.length=0,this.#l=0,this.#a=0,this.#x&&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 mn(t){window.$monomerHover=t}function gn(t,e){let n=t["substruct-providers"];n||(n=t["substruct-providers"]=[]),n.push(e),t["substruct-providers"]=n}var yn=n(6077),bn=n(3561),vn=n(9235);const wn="MonomerHoverLinks";function Cn(t,e){let n=t[wn];n||(n=t[wn]=[]),n.push(e),t[wn]=n}function An(t,e){try{const n=t.tableColumn;if(!n)return;const r=function(t){return t.temp[wn]??[]}(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 xn=n(6717),Sn=n(6694),Tn=n(4229),En=n(5174);function _n(t,e=!0){const[n,o]=(0,Xe.AP)(t);return Kr.logger.error(n,void 0,o),e&&r.shell.error(n),[n,o]}async function In(){return(await(0,l.pj)()).getAvaliableLibraryNames()}const Nn={symbol:"Short Name",name:"Medium Name",smiles:"SMILES"},Mn=[{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"}],On="Get HELM",Ln="Chirality engine",Rn="Highlight monomers",Pn="Poly Tool Conversion",Bn="Poly Tool Enumeration",Dn="Rules used";var Fn=n(5412);async function kn(t){await Kr.initPromise;try{const e=await async function(t){const e=[],n=()=>{for(const t of e)t.unsubscribe()};try{const[i,s]=await Promise.all([In(),(0,Qe.b2)()]),a=t&&t.rowIndex>=0?t.value:"\n\n\n 22 24 0 0 0 0 0 0 0 0999 V2000\n 0.3128 -0.7509 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n 0.3128 0.0740 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -0.4054 -1.1623 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -1.1081 -0.7509 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -0.4054 0.4877 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0\n -1.1081 0.0740 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -1.8175 -1.1623 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n 1.0222 0.4877 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -1.8175 0.4877 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -2.5292 -0.7509 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n 1.0222 1.3127 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n 1.7227 1.7263 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -0.4054 -1.9896 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0\n -2.5292 0.0740 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n 2.4544 1.3127 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n 1.7406 0.0740 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n 1.0222 -1.1623 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0\n 2.4544 0.4877 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -1.8175 -1.9896 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0\n -3.2453 0.4877 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0\n 3.1670 1.7285 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0\n 1.7149 2.5513 0.0000 R# 0 0 0 0 0 0 0 0 0 0 0 0\n 2 1 2 0 0 0 0\n 3 1 1 0 0 0 0\n 4 3 1 0 0 0 0\n 5 2 1 0 0 0 0\n 6 5 1 0 0 0 0\n 7 4 1 0 0 0 0\n 8 2 1 0 0 0 0\n 9 6 1 0 0 0 0\n 10 7 2 0 0 0 0\n 11 8 2 0 0 0 0\n 12 11 1 0 0 0 0\n 13 3 2 0 0 0 0\n 14 9 2 0 0 0 0\n 15 18 1 0 0 0 0\n 16 8 1 0 0 0 0\n 17 1 1 0 0 0 0\n 18 16 2 0 0 0 0\n 19 7 1 0 0 0 0\n 20 14 1 0 0 0 0\n 6 4 2 0 0 0 0\n 15 12 2 0 0 0 0\n 14 10 1 0 0 0 0\n 15 21 1 0 0 0 0\n 12 22 1 0 0 0 0\nM RGP 1 22 1\nM END";let u=await(async()=>o.chem.isMolBlock(a)?a:await r.functions.call("Chem:convertMolNotation",{molecule:a,sourceNotation:t?.column.getTag(o.TAGS.UNITS)??o.chem.Notation.Unknown,targetNotation:o.chem.Notation.MolBlock}))();const c=new o.chem.Sketcher(o.chem.SKETCHER_MODE.EXTERNAL);c.syncCurrentObject=!1,c.onChanged.subscribe((t=>{u=c.getMolFile()})),c.root.classList.add("ui-input-editor"),c.root.style.marginTop="3px",c.setMolFile(u);const h=M.input.choice("Library to use",{value:null,items:i});c.root.setAttribute("style","min-width:250px!important;"),c.root.setAttribute("style","max-width:250px!important;"),h.input.setAttribute("style","min-width:250px!important;");const d=M.div([c.root,h.root]);e.push(r.events.onCurrentCellChanged.subscribe((()=>{const t=r.shell.tv.dataFrame.currentCell;t.column.semType===o.SEMTYPE.MOLECULE&&c.setValue(t.value)})));const f=async()=>{try{const t=c.getMolFile();if(void 0===t||""===t)r.shell.warning("PolyTool: no molecule was provided");else if(t.includes("R#")){const e=await async function(t,e){const n=await async function(t){const e=await(0,l.pj)(),n=await e.readSingleLibraryByName(t);return n?n.getMonomerSymbolsByType("PEPTIDE"):(Kr.logger.error(`Monomer library '${t}' not found.`),[])}(e),o=await async function(t){const e=await(0,l.pj)(),n=await e.readSingleLibraryByName(t);if(!n)return Kr.logger.error(`Monomer library '${t}' not found.`),{};const r=n.getMonomerSymbolsByType("PEPTIDE");return new Array(r.length),n.getMonomerMolsByPolymerType("PEPTIDE")}(e),i=new Array(n.length),s=await r.functions.call("Chem:getRdKitModule"),a=s.get_mol(t),u=a.get_smiles();a.delete();const c=new Array(n.length);for(let t=0;t<n.length;t++){const e=o[n[t]],r=s.get_mol(e);c[t]=r.get_smiles(),r.delete()}for(let t=0;t<n.length;t++){let e=null;try{const n=`${`${u}.${c[t]}`.replaceAll("[1*]C","C([1*])").replaceAll("[1*]c","c([1*])").replaceAll("[1*]O","O([1*])").replaceAll("[1*]N","N([1*])")}`.replaceAll("([1*])","9").replaceAll("[1*]","9");e=s.get_mol(n,JSON.stringify({mappedDummiesAreRGroups:!0}));const r=e.get_v3Kmolblock();i[t]=r}catch(e){i[t]=""}finally{e?.delete()}}return i}(t,h.value),n=o.Column.fromStrings("Enumerated",e),i=o.DataFrame.fromColumns([n]);r.shell.addTableView(i)}else r.shell.warning("PolyTool: no R group was provided")}catch(t){_n(t)}},p=M.dialog(Bn).add(d).onOK((()=>{f().finally((()=>{n()}))})).onCancel((()=>{n()}));return e.push(p.onClose.subscribe((()=>{n()}))),p.history((()=>({mol:c.getMolFile(),screenLibrary:h.value})),(t=>{c.setMolFile(t.mol),h.value=t.screenLibrary})),p}catch(t){throw n(),t}}(t);e.show({resizable:!0})}catch(t){r.shell.warning("To run PolyTool Enumeration, sketch the molecule and specify the R group to vary")}}async function Hn(t,e,n,i,s,a){const l=o.TaskBarProgressIndicator.create("PolyTool converting...");try{const l=(t,e)=>t?t.columns.getUnusedName(e):e,u=await(0,Qe.b2)(),c=t.dataFrame,h=await(0,Sn.Q4)(a),[d,f,p]=(0,Tn.b)(t.toList(),h,u),m=l(c,`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=Re.Hi.HELM,g.setTag(o.TAGS.CELL_RENDERER,"helm"),e&&c&&c.columns.add(g,!0);const y=await(0,xn.j)(),b=await(0,Ze.Q)(),v=await(0,En.A)(h),w=g.temp;w[".mm.cellRenderer.overriddenLibrary"]=v,g.temp=w;const C=await(0,Fn.m)(g,d,f,i,s,n,v,y,b);return C.name=l(c,`molfile(${t.name})`),C.semType=o.SEMTYPE.MOLECULE,c&&(c.columns.add(C,!0),await r.data.detectSemanticTypes(c)),function(t,e,n,r,o,i,s){const a=new fn({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=en().count(0).take(s.length).map((t=>({position:t,symbol:s.getCanonical(t),biotype:a}))).toArray(),u=n.alphabet,c=u==Re.YI.RNA||u==Re.YI.DNA?"RNA":"PEPTIDE",h=(0,yn.eM)([l],c,u,r,i);return(0,bn.gU)(l,h,u,c).monomers}(t,e)),s}const u={targetCol:n,handler:(t,n,o)=>{if(!t||!o.grid||!e.dataFrame)return!0;const i=o.grid,a=t.tableRowIndex,u=t.gridRow,c=i.cell(o.name,u),h=s[u],d=pn();if(!d||d&&(d.dataFrameId!=e.dataFrame?.id||d.gridRowIdx!=u||d.seqColName!=e.name||d.seqPosition!=n?.position)){if(d&&(mn(null),d.gridCell.render()),!n)return mn(null),!0;mn({gridCell:c,dataFrameId:e.dataFrame.id,gridRowIdx:u,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,vn.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)}}),c.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,vn.H)(o.values(),r):void 0}};Cn(t.temp,u),gn(n.temp,u)}(t,g,C,v,b,y,p),[g,C]}finally{l.close()}}var Un=n(6197);class $n extends o.InputBase{constructor(t,e){super(M.input.column(t,e).dart,e?.onValueChanged),this.options=e}setColumnInputTable(t){M.input.setColumnInputTable(this,t,this.options?.filter)}}M.input.column2=function(t,e){return new $n(t,e)};var Vn=n(1296),jn=n(3820);class qn 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=Gn(t.get("Monomers",n));e.push({position:r,monomers:o})}}return e}(this.grid.dataFrame)}constructor(t,e,n){super(),this.name=t,this.subs=[],this.dataFrameSubs=[],this.caption=t??"",this.root.classList.add("ui-input-polytool-pos-grid"),this.root.append(this.gridHost=M.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=M.div(M.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"}}))})),this.updateGridHeight(t??this.grid.dataFrame.rowCount+.7),this.subs.push(M.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 qn(t,n,e)}updateGridHeight(t){const e=this.grid.colHeaderHeight+t*this.grid.props.rowHeight+6+2;this.grid.root.style.height=`${e}px`}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 Gn(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 zn 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)}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=Gn(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.subs=[],this.dataFrameSubs=[],this.caption=t??"",this.root.classList.add("ui-input-polytool-pos-grid"),this.root.append(this.gridHost=M.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=M.div(M.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"}}))})),this.updateGridHeight(t??this.grid.dataFrame.rowCount+.7),this.subs.push(M.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 zn(t,n,e)}updateGridHeight(t){const e=this.grid.colHeaderHeight+t*this.grid.props.rowHeight+6+2;this.grid.root.style.height=`${e}px`}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 Wn=n(6307);async function Yn(t){await Kr.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-en().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 en().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 a=Vn.aK.Single;const u=()=>{for(const t of s)t.unsubscribe();i.placeholders.detach()};try{const c=await(0,l.pj)(),h=c.getMonomerLib(),d=await(0,Ze.Q)(),f=o.DataFrame.fromColumns([]),[p,m]=await Promise.all([In(),(0,Qe.b2)()]),g=m.buildMonomersFuncsFromLib(h),y=t=>{let e,n;if(t&&t.rowIndex>=0&&t?.column.semType==o.SEMTYPE.MACROMOLECULE)e=d.getSeqHandler(t.column).getValue(t.rowIndex),n=e.tags["polytool-data-role"]??"macromolecule";else{const t=o.Column.fromList(o.COLUMN_TYPE.STRING,"seq",[jn.d]);t.semType=o.SEMTYPE.MACROMOLECULE,o.DataFrame.fromColumns([t]),t.meta.units=Re.Hi.HELM,e=d.getSeqHandler(t).getValue(0),n="macromolecule"}return[e,n]};let b,v,[w,C]=y(t),A=null;const x=M.divText("",{style:{marginLeft:"8px",marginTop:"2px"}}),S=M.divText("",{style:{color:"red"}});i={macromolecule:m.createHelmInput("Macromolecule",{editable:!1,editorOptions:{drawOptions:{monomerNumbering:1,getMonomer:(t,e)=>{const n=t;if("ATOM"!==n.T)return g.getMonomer(t,e);try{if(w.isDna()||w.isRna()){const t=w.getSplittedWithSugarsAndPhosphates().getCanonical(n.bio.continuousId-1);return g.getMonomer(n.bio.type,t)}{const t=w.getSplitted().getCanonical(n.bio.continuousId-1);return g.getMonomer(n.bio.type,t)}}catch(n){return g.getMonomer(t,e)}}}}}),placeholders:await qn.create("Placeholders",{showAddNewRowIcon:!0,showRemoveRowIcon:!0,showRowHeader:!1,showCellTooltip:!1}),enumeratorType:M.input.choice("Enumerator type",{value:a,items:Object.values(Vn.aK)}),placeholdersBreadth:await zn.create("Breadth",{showAddNewRowIcon:!0,showRemoveRowIcon:!0,showRowHeader:!1,showCellTooltip:!1}),keepOriginal:M.input.bool("Keep original",{value:!1}),toAtomicLevel:M.input.bool("To atomic level",{value:!1,onValueChanged:(t,e)=>{_()}}),generateHelm:M.input.bool(On,{value:!0}),chiralityEngine:M.input.bool(Ln,{value:!1}),highlightMonomers:M.input.bool(Rn,{value:!1}),rules:{header:M.inlineText([Dn]),form:await(v=new Sn._v(Sn.MU,Sn.yy,".json",{onValueChanged:t=>{b=t}})).getForm()},trivialNameCol:M.input.column2("Trivial name",{table:t?.dataFrame,filter:e=>e.type===o.COLUMN_TYPE.STRING&&e!=t?.column,onValueChanged:()=>{const e=i.trivialNameCol.value;let n=null;t&&e&&(n={value:e.get(t.rowIndex),colName:e.name}),A=n,x.textContent=A?`Original ID: ${A.value}`:""},nullable:!0}),library:M.input.choice("Monomer Library",{items:p,value:p[0],nullable:!0})},i.library.root.style.setProperty("display","none"),i.trivialNameCol.addOptions(x);let T=null;i.placeholders.addValidator((t=>{const e=[];try{if(i.enumeratorType.value===Vn.aK.Library){setTimeout((()=>{I()}),10);const t=i.placeholders.placeholdersValue;if(t.length>1)return"Only one placeholder is allowed for Library mode";if(1===t.length){if(null==t[0].position)return"Position is required for Library mode";if(t[0].position>i.macromolecule.molValue.atoms.length)return`There is no monomer at position ${t[0].position+1}.`}return null}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,Un.Y)(e);for(const e of n.monomers){const n=h.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}`),T=e.length>0?e.join("\n"):null}catch(t){const[e,n]=_n(t,!1);T=e}return setTimeout((()=>{I()}),0),T})),i.library.addValidator((t=>i.enumeratorType.value!==Vn.aK.Library||i.library.value?null:"Monomer Library is required for this enumerator type")),i.library.onChanged.subscribe((()=>{i.enumeratorType.value===Vn.aK.Library&&i.placeholders.setMonomersValue(0,i.library.value??"")})),i.enumeratorType.onChanged.subscribe((t=>{const e=i.enumeratorType.value===Vn.aK.Library;i.library.root.style.setProperty("display",e?"flex":"none");try{if(a!==Vn.aK.Library&&e||a===Vn.aK.Library&&!e){const t=1===i.placeholders.placeholdersValue.length?i.placeholders.placeholdersValue[0].position:null;i.placeholders.clearInput(),i.placeholdersBreadth.clearInput(),e&&null!=t&&i.placeholders.addPosition(t,i.library.value??"")}}catch(t){_n(t,!1)}a=i.enumeratorType.value})),s.push(i.macromolecule.onMouseMove.subscribe((t=>{try{Kr.logger.debug(`${n}, placeholdersInput.onMouseMove()`);const e=t.offsetX,r=t.offsetY,o=i.macromolecule.molValue,s=m.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=M.divText(n.join(", "));i.macromolecule.showTooltip(e,s),t.preventDefault(),t.stopPropagation()}}}catch(t){_n(t,!1)}}))),s.push(i.macromolecule.onClick.subscribe((t=>{try{Kr.logger.debug(`${n}, placeholdersInput.onClick()`);const e=t.offsetX,r=t.offsetY,o=i.macromolecule.molValue,s=m.getHoveredAtom(e,r,o,i.macromolecule.root.clientHeight);if(s){const t=s._parent.atoms.indexOf(s);String(t+1);let e="";i.enumeratorType.value===Vn.aK.Library&&(i.placeholders.clearInput(),e=i.library.value??""),i.placeholders.addPosition(t,e)}}catch(t){_n(t)}}))),s.push(i.placeholders.onChanged.subscribe((()=>{E()}))),s.push(M.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&&([w,C]=y(),O(w,C,t))}))),i.macromolecule.root.style.setProperty("min-width","250px","important");const E=()=>{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.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()},I=()=>{const t=T,e=S;t?(e.innerText=t,e.style.removeProperty("display")):(e.innerText="",e.style.setProperty("display","none"))},N=t=>{t?(i.trivialNameCol.setColumnInputTable(t),i.trivialNameCol.root.style.removeProperty("display")):(i.trivialNameCol.setColumnInputTable(f),i.trivialNameCol.root.style.setProperty("display","none")),e&&e()},O=(t,e,n)=>{i.macromolecule.value=t;const r=n?.dataFrame;N(r)};O(w,C,t),_();const L=async()=>{try{const t=i.macromolecule.stringValue,e=en().enumerate(i.macromolecule.molValue.atoms).filter((([t,e])=>t.highlighted)).map((([t,e])=>e)).toArray();if(i.enumeratorType.value===Vn.aK.Library){if(0===e.length)return void r.shell.warning("PolyTool: position for enumeration was not selected");if(!i.library.value)return void r.shell.warning("PolyTool: No monomer library was selected")}if(void 0===t||""===t)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(`${Bn}: placeholders are empty`);await(0,Qe.b2)();const e=i.placeholders.placeholdersValue;let n=i.enumeratorType.value;if(n===Vn.aK.Library){if(1!==e.length)return void r.shell.warning("Only one placeholder is allowed for Library mode");if(!e[0].monomers||!p.includes(e[0].monomers[0]))return void r.shell.warning("Valid Monomer Library is required for this enumerator type");const t=e[0].monomers[0],o=await c.readSingleLibraryByName(t);if(!o)return void r.shell.warning(`Monomer Library '${t}' was not found`);const i=o.getMonomerSymbolsByType("PEPTIDE");e[0].monomers=i,n=Vn.aK.Single}const s={placeholders:e,type:n,breadthPlaceholders:i.placeholdersBreadth.placeholdersBreadthValue,keepOriginal:i.keepOriginal.value},a=i.toAtomicLevel.value,u=await async function(t,e,n,i,s,a){const u=o.TaskBarProgressIndicator.create("PolyTool enumerating...");try{const u=await(0,l.pj)(),c=await(0,xn.j)(),h=u.getMonomerLib(),d=(0,jn.o)(t,n?.value??"",i);let f;switch(e){case"macromolecule":f=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=Wn.s.fromHelm(n,a);t[e]=r.getNotation()}f=o.Column.fromList(o.COLUMN_TYPE.STRING,"Enumerated",t),f.semType=o.SEMTYPE.MACROMOLECULE,f.setTag("polytool-data-role","template"),Qr.applyNotationProviderForCyclized(f,"-");break}}const p=o.DataFrame.fromColumns([f]);if(await r.data.detectSemanticTypes(p),"template"==e&&Qr.applyNotationProviderForCyclized(f,"-"),s){let t;if("macromolecule"===e){t=f;const e=await a.seqHelper.helmToAtomicLevel(t,s.chiralityEngine,s.highlightMonomers);p.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==Re.YI.RNA||s.alphabet==Re.YI.DNA,l=s.isHelm()&&a,u=!s.isHelm()&&a,c=t=>null==t?null:l?i?t:Math.floor(t/3):u&&i?3*t+1:t,h=i?await r.getHelmToMolfileConverter(n):null,d=new fn({max:100});function f(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=en().count(0).take(t.length).map((e=>({position:e,symbol:t.getCanonical(e),biotype:r}))).toArray(),a=s.alphabet,l=a==Re.YI.RNA||a==Re.YI.DNA?"RNA":"PEPTIDE",u=(0,yn.eM)([i],l,a,n,o);return(0,bn.gU)(i,u,a,l).monomers}}(t,e)),a}const p={targetCol:e,handler:(e,r,o)=>{const i=o.grid,s=e.tableRowIndex,a=e.gridRow,l=i.cell(o.name,a),u=pn();if(!u||u&&(u.dataFrameId!=t.dataFrame.id||u.gridRowIdx!=a||u.seqColName!=t.name||u.seqPosition!=r?.position)){if(u&&(mn(null),u.gridCell.render()),!r)return mn(null),!0;mn({gridCell:l,dataFrameId:t.dataFrame.id,gridRowIdx:a,seqColName:t.name,seqPosition:c(r?.position)??-1,getSubstruct:()=>{if(!r||"*"===r.symbol)return;const e=f(t,s);if(!e)return;const o=e.get(c(r?.position));return o?(0,vn.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=f(t,r);return o?(0,vn.H)(o.values(),n):void 0}};return Cn(t.temp,p),gn(e.temp,p),p}(t,n,h,a.seqHelper,c,!0)}else"template"===e&&(t=(await Hn(f,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]));p.columns.add(t)}return p}finally{u.close()}}(t,C,A,s,!!a&&{generateHelm:i.generateHelm.value,chiralityEngine:i.chiralityEngine.value,highlightMonomers:i.highlightMonomers.value,rules:await v.getActive()},m);r.shell.addTableView(u)}}catch(t){_n(t)}},R=M.dialog({title:Bn,showFooter:!0}).add(i.macromolecule.root).add(M.divH([M.divV([i.placeholders.root,i.enumeratorType.root,i.library.root],{style:{width:"50%"}}),M.divV([i.placeholdersBreadth.root],{style:{width:"50%"}})],{style:{width:"100%"}})).add(M.divH([M.divV([i.trivialNameCol.root,i.keepOriginal.root],{style:{width:"50%"}}),M.divV([M.divH([i.toAtomicLevel.root,i.generateHelm.root]),M.divH([i.chiralityEngine.root,i.highlightMonomers.root]),i.rules.header,i.rules.form],{style:{width:"50%"}})],{style:{width:"100%"}})).add(S).onOK((()=>{L()}));return s.push(R.onClose.subscribe((()=>{u()}))),R.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,trivialNameCol:i.trivialNameCol.stringValue,keepOriginal:i.keepOriginal.value,toAtomicLevel:i.toAtomicLevel.value,generateHelm:i.generateHelm.value,chiralityEngine:i.chiralityEngine.value,highlightMonomers:i.highlightMonomers.value,rules:b,library:i.library.value})),(t=>{i.enumeratorType.value=t.enumeratorType??Vn.aK.Single,i.placeholders.stringValue=t.placeholders,i.placeholdersBreadth.stringValue=t.placeholdersBreadth,i.trivialNameCol.stringValue=t.trivialNameCol,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,v.setActive(t.rules),i.library.value=t.library})),R}catch(t){throw u(),t}}(t,s);let a=!0;M.onSizeChanged(i.root).subscribe((()=>{if(a){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`,a=!1}s()})),s(),Kr.logger.debug("PolyToolEnumerateHelmUI: dialog before show"),i.show({width:Math.max(350,.7*e),resizable:!0}),Kr.logger.debug("PolyToolEnumerateHelmUI: dialog after show")}catch(u){const[c,h]=(0,Xe.AP)(u);Kr.logger.error(c,void 0,h)}}var Kn,Jn=n(3151);class Qn{constructor(t){this.rawLib=t}isValid(){return this.rawLib.every((t=>"object"==typeof t&&Object.values(Nn).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={...Jn.pe};Object.entries(Nn).forEach((([n,r])=>{const o=t[r];e[n]=o}));let n="smiles";const r=t[Nn[n]],o=new Xn(r),i=o.getCappedSmiles();return e[n]=i,n="rgroups",e[n]=Zn.getRGroups(o.getNumberOfRGroups()),n="molfile",e[n]=new tr(o.getSmilesWithRGroups()).getMolfile(),e}}class Xn{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 Zn{constructor(){}static getRGroups(t){return Mn.slice(0,t)}}class tr{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 er{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 Qn(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"}(Kn||(Kn={}));class nr{constructor(t){this.call=t,this.ruleInputs=new Sn._v(Sn.MU,Sn.yy,".json")}async initInputs(){const t=t=>this.call.inputParams[t],e=await this.ruleInputs.getForm();this.inputs={table:(()=>{const e=t(Kn.table);return M.input.table(e.property.caption,{value:e.value})})(),seqCol:(()=>{const e=t(Kn.seqCol);return M.input.column(e.property.caption,{value:e.value,table:e.value.dataFrame})})(),generateHelm:M.input.forProperty(t(Kn.generateHelm).property),chiralityEngine:M.input.forProperty(t(Kn.chiralityEngine).property),rules:{header:M.inlineText([Dn]),form:e}}}static async create(t){const e=new nr(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=M.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)=>{M.dialog({title:Pn}).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")}}class rr{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 or extends rr{constructor(t,e,n){super(),this.gridCol=t,this.tableCol=e,this.logger=n,this.subs=[],this.dirty=!0,this.destroyed=!1,this.viewerId=++or.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(0,Ke.PE)(this._onRendered,(()=>{}),(()=>{this.invalidate()}),t,`${n}, ${e}`),this.errors.length>0){const t=this.errors[0];throw this.errors=[],t}this.logger.debug(`${n}, end`)}}or.viewerCounter=-1;const ir="rgb(100,100,100)",sr="rgb(0,0,0)",ar=s.zS;var lr,ur,cr;!function(t){t.maxMonomerLength=".mm.cellRenderer.maxMonomerLength"}(lr||(lr={})),function(t){t.applyToBackground=".m.cellRenderer.applyToBackground"}(ur||(ur={})),function(t){t.MSA="MSA",t.classic="classic"}(cr||(cr={}));const hr=new class{constructor(){this.color=ir,this.pivot=0,this.left=!1,this.transparencyRate=0,this.separator="",this.last=!1,this.drawStyle=cr.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 dr(t,e,n,r,i,s,a){var l,u,c;const h={...hr,...a};if(h.isMultiLineContext){t.textBaseline="middle",t.textAlign="center";let o=e;null!=h.maxLengthOfMonomer&&(o=ar(o,h.maxLengthOfMonomer));const a=Math.max(.1,1-(h.transparencyRate??0));t.globalAlpha=a;const l=t.measureText(o),u=l.fontBoundingBoxAscent+l.fontBoundingBoxDescent,c=r+(s-u)/2+l.fontBoundingBoxAscent;let d=h.color??ir;return d&&d!==ir||(d=sr),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,c),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),f=h.last?"":h.separator;h.drawStyle===cr.MSA&&(f="");let p=!0,m=!0,g="difference";if(null!=h.gridCell&&null!=h.gridCell.cell.column&&(p=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=ar(d,h.maxLengthOfMonomer));const y=d+f;(l=h.monomerTextSizeMap)[y]??(l[y]=t.measureText(y));let b=h.monomerTextSizeMap[y];(u=h.monomerTextSizeMap)[d]??(u[d]=t.measureText(d));let v=h.monomerTextSizeMap[d].width;const w=s/2-(b.fontBoundingBoxAscent+b.fontBoundingBoxDescent)/2+1;(c=h.monomerTextSizeMap)[f]??(c[f]=t.measureText(f));const C=h.monomerTextSizeMap[f].width;function A(e,i){let a=p?h.color:sr;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===cr.classic&&(t.fillText(d,n+e,r+w),t.fillStyle="#808080",t.fillText(f,n+i,r+w)),h.drawStyle===cr.MSA&&t.fillText(d,n+e,r+w),t.globalAlpha=1}b=b.width,h.drawStyle===cr.MSA&&(v=h.maxWord[h.wordIdx],b=h.maxWord[h.wordIdx]);const x=(h.maxWord[h.wordIdx]??0)-(h.maxWord[0]??0);if(h.left||b>i)return A(x,x+v),n+x+v+C;{const t=(i-b)/2;return A(t,t+v),n+x+t+v}}var fr=n(3599);const pr="rgb(100,100,100)";class mr extends or{get separatorWidth(){return this.props?.fontCharWidth?this.props?.fontCharWidth:5}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.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=[Re.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===Re.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,Xe.AP)(t);this.logger.error(e,void 0,n)}const{lineHeight:s,monomerSpacing:a}=this.calculateFontBasedSpacing(t),l=e-2*this.padding;let u=0;const c=[];if(r.length>0)for(let e=o;e<r.length;e++){const n=r.getOriginal(e),o=this.props.monomerToShort(n,i);c.push({text:o,posIdx:e}),u=Math.max(u,t.measureText(o).width)}if(0===c.length)return{lineLayouts:[],lineHeight:s};const h=u;let d=Math.floor((l+a)/(h+a));d=Math.max(1,d);const f=n-2*this.padding,p=Math.max(0,Math.floor(f/s)),m=[];let g=0;for(let t=0;t<p&&g<c.length;t++){const e=[];for(let t=0;t<d&&g<c.length;t++){const n=c[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,Ze.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,Xe.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 u=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,u+=a,u>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[Re.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 u=this.tableCol,c=this.positionShift;t.save();try{const a=this.seqHelper.getSeqHandler(u);let h=this.monomerLengthLimit;if(lr.maxMonomerLength in u.tags){const t=parseInt(u.getTag(lr.maxMonomerLength));h=!isNaN(t)&&t?t:50}if(".mm.cellRenderer.maxMonomerLength"in u.temp){const t=u.temp[".mm.cellRenderer.maxMonomerLength"],e="number"==typeof t?t:parseInt(t);h=!isNaN(e)&&e?e:50}if("1"===u.temp[".mm.cellRenderer.settingsChanged"]||this.monomerLengthLimit!=h){let t=0;const e=8;t=u.temp[".mm.cellRenderer.gapLength"]??t,this.setMonomerLengthLimit(h),this.setSeparatorWidth(a.isMsa()?e:t),u.temp[".mm.cellRenderer.settingsChanged"]="0",this.dirty=!0}const d=s.cell.rowIndex,f=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 p=u.meta.units,m=u.getTag(Re.gp.aligned),g=u.getTag(Re.gp.separator)??"",y=l?a.getSplitted(d):a.splitter(f);let b=cr.classic;m?.includes("MSA")&&p===Re.Hi.SEPARATOR&&(b=cr.MSA);const v=u.temp["reference-sequence"],w=this.tableCol.temp["current-word"],C=(()=>{const t=(0,a.splitter)(null!=v&&""!==v?v:w??"");return en().count(0).take(t.length).slice(c).map((e=>t.getCanonical(e))).toArray()})(),A=Number.parseInt(u.getTag(Re.gp.selectedPosition)??"-200");if(this.shouldUseMultilineRendering(u)){const l=[],d=this.calculateMultiLineLayoutDynamic(t,r,i,y,c,h);let f=n+this.padding;1===d.lineLayouts.length&&(f=n+(i-d.lineHeight)/2);for(const r of d.lineLayouts){const i=f+r.lineIdx*d.lineHeight;for(const h of r.elements){const f=e+h.x,p=h,m=p.posIdx,g=y.getCanonical(m);let b=pr;const v=this.getMonomerLib();v&&(b=v.getMonomerTextColor(a.defaultBiotype,g));let w=0;if(s.tableRowIndex!==u.dataFrame.currentRowIdx&&C.length>0){const t=m-c;t>=0&&t<C.length&&g===C[t]&&(w=.7)}l.push({lineIdx:r.lineIdx,monomerIdx:m-c,bounds:new o.Rect(h.x,i-n,h.width,d.lineHeight),sequencePosition:m}),dr(t,p.om,f,i,h.width,d.lineHeight,{color:b,isMultiLineContext:!0,transparencyRate:w,selectedPosition:isNaN(A)||A<1?void 0:A,wordIdx:m})}}null!==s.tableRowIndex&&this._cellBounds.set(s.tableRowIndex,l)}else{this._leftThreeDotsPadding=this.shouldRenderShiftedThreeDots(c)?t.measureText("...").width:0;let[,o]=this.getCellMonomerLengths(s.tableRowIndex,r);l||(o=this.getSummedMonomerLengths(this.getCellMonomerLengthsForSeqValue(f,r)));const u=this.props.separatorWidth+1*this.props.fontCharWidth,d=Math.min(y.length,Math.ceil(r/u)+c);for(let l=c;l<d;++l){const u=l<y.length?y.getOriginal(l):a.defaultGapOriginal,d=l<y.length?y.getCanonical(l):a.defaultGapOriginal;let f=pr;this.getMonomerLib()&&(f=this.getMonomerLib().getMonomerTextColor(a.defaultBiotype,d));const p=l===y.length-1,m={color:f,pivot:0,left:!0,transparencyRate:0,separator:(y?.graphInfo?.disjointSeqStarts?.indexOf(l+1)??0)>0?"|":g,last:p,drawStyle:b,maxWord:o,wordIdx:l-c,gridCell:s,referenceSequence:C,maxLengthOfMonomer:h,monomerTextSizeMap:this._monomerLengthMap,logger:this.logger,selectedPosition:isNaN(A)||A<1?void 0:A-c};dr(t,u,e+this.padding+this._leftThreeDotsPadding,n,r,i,m)}if(this.shouldRenderShiftedThreeDots(c)){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};dr(t,"...",e+this.padding,n,r,i,a)}}}catch(t){const[e,n]=(0,Xe.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 u=this.seqHelper.getSeqHandler(this.tableCol),c=u.getSplitted(t.tableRowIndex);if(null!==a&&a>=0&&a+r<c.length){const n=u.alphabet??Re.YI.UN,o={position:a,biotype:n===Re.YI.RNA||n===Re.YI.DNA?fr.o.NUCLEOTIDE:fr.o.AA,symbol:c.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):M.divText("Monomer library is not available")}i.push(s),M.tooltip.show(M.divV(i),e.x+16,e.y+16),An(t,o)}else-1===a?M.tooltip.show(M.divText(`${Math.min(r,c.length)} hidden monomers`),e.x+16,e.y+16):M.tooltip.hide(),An(t,null)}}class gr extends mr{constructor(t,e,n,r){super(t,e,Kr.logger,n,(()=>{const t=r.getSeqHandler(e),{font:n,fontWidth:o}=mr.getFontSettings(e);return{seqHandler:t,font:n,fontCharWidth:o,separatorWidth:11,monomerToShort:Re.zS}}))}onMouseMove(t,e){super.onMouseMove(t,e)}}class yr{get defaultGapOriginal(){return""}constructor(t,e){this.separator=t,this.helmHelper=e,this.separatorSplitter=(0,Re.dh)(this.separator),this.splitter=this._splitter.bind(this)}setUnits(){}_splitter(t){const e=this.separatorSplitter(t);return new br(en().count(0).take(e.length).map((t=>e.getOriginal(t))).toArray(),i.b9[i.Hi.SEPARATOR])}getHelm(t,e){return Wn.s.fromSeparator(t,this.helmHelper).getHelm()}createCellRendererBack(t,e){const n=new gr(t,e,4,this.helmHelper.seqHelper);return n.init().then((()=>{})),n}}class br 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 vr(){return await Qr.oligoToolkitApp()}async function wr(){await Qr.init()}async function Cr(){return await Qr.oligoTranslatorApp()}async function Ar(){return await Qr.oligoPatternApp()}async function xr(){return await Qr.oligoStructureApp()}async function Sr(){return await Qr.getTranslationHelper()}function Tr(){return Qr.getCodeToWeightsMap()}function Er(t){return Qr.validateSequence(t)}function _r(t,e){return Qr.getMolfileFromGcrsSequence(t,e)}function Ir(t){return Qr.linkStrands(t)}async function Nr(){await Qr.demoTranslateSequence()}async function Mr(){await Qr.demoOligoPattern()}async function Or(){await Qr.demoOligoStructure()}async function Lr(t,e,n){return await Qr.translateOligonucleotideSequence(t,e,n)}async function Rr(){await Qr.polyToolConvertTopMenu()}async function Pr(t){return await Qr.getPolyToolConvertEditor(t)}async function Br(t,e,n,r,o){return await Qr.polyToolConvert2(t,e,n,r,o)}async function Dr(){await Qr.polyToolEnumerateHelmTopMenu()}async function Fr(){await Qr.polyToolEnumerateChemTopMenu()}async function kr(t,e){await Qr.polyToolColumnChoice(t,e)}async function Hr(t){await Qr.createMonomerLibraryForPolyTool(t)}async function Ur(){await Qr.ptEnumeratorHelmApp()}async function $r(){await Qr.ptEnumeratorChemApp()}async function Vr(t){await Qr.getPtHelmEnumeratorDialog(t)}async function jr(t){await Qr.getPtChemEnumeratorDialog(t)}async function qr(){await Qr.getPolyToolCombineDialog()}function Gr(t,e){Qr.applyNotationProviderForCyclized(t,e)}var zr=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)},Yr=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 Kr=new P({debug:!0});let Jr=null;class Qr{static async oligoToolkitApp(){await Kr.initLibData();const t=await async function(t){const e={"Mermadesynthesis:merMadeSynthesis":{tabName:"SYNTHESIZE",parameters:Je(t)}},n={};for(const[t,o]of Object.entries(e)){let e;try{e=await r.functions.call(t,o.parameters);const i=new We(o.tabName,e);i.initView(),n[o.tabName]=()=>i.getView()}catch(e){console.warn(`Plugin ${t} not loaded, reason:`,e);continue}}return n}(Kr);if(!t)throw new Error("External app view factories not loaded");const e=new Ye(t,Kr);return await e.getAppView()}static async init(){return null===Jr&&Kr.startInit(Jr=async function(){const[t]=await Promise.all([(0,Qe.b2)()]);Kr.completeInit(t)}()),Jr}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 Kr.initLibData(),Kr}static getCodeToWeightsMap(){const t=Kr.monomerLibWrapper.getCodesToWeightsMap();return Object.fromEntries(t)}static validateSequence(t){const e=Kr.createSequenceValidator(t),n=Kr.createFormatDetector(t).getFormat();return null!==n&&e.isValidSequence(n)}static getMolfileFromGcrsSequence(t,e){return new xe(t,e,"GCRS").convert()}static linkStrands(t){return Se(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(0,Ke.cb)(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 Kr.initLibData(),Kr.createFormatConverter(t,e).convertTo(n)}static async polyToolConvertTopMenu(){await async function(){await Kr.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=>Kr.seqHelper.getSeqHandler(t).notation===Re.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=M.input.column("Column",{table:n.dataFrame,value:n,filter:t=>s.includes(t)}),l=M.input.bool(On,{value:!0});M.tooltip.bind(l.root,"Add HELM column");const u=M.input.bool("Linearize",{value:!0});M.tooltip.bind(u.root,"Make representation linear if possible");const c=M.input.bool(Ln,{value:!0}),h=M.input.bool(Rn,{value:!0});let d;const f=new Sn._v(Sn.MU,Sn.yy,".json",{onValueChanged:t=>{d=t}}),p=M.inlineText([Dn]);M.tooltip.bind(p,"Add or specify rules to use");const m=await f.getForm(),g=M.divV([a,l,u,c,h,p,m]),y=async()=>{try{const t=await f.getActive();await Hn(a.value,l.value,u.value,c.value,h.value,t)}catch(t){_n(t)}},b=M.dialog(Pn).add(g).onOK((()=>{y()}));return t.push(b.onClose.subscribe((()=>{e()}))),b.history((()=>({generateHelm:l.value,chiralityEngine:c.value,rules:d})),(t=>{l.value=t.generateHelm,c.value=t.chiralityEngine,f.setActive(t.rules)})),b}catch(t){throw e(),t}}(),t?.show()}catch(t){const[e,n]=(0,Xe.AP)(t);r.shell.warning("To run PolyTool Conversion, open a dataframe with macromolecules"),Kr.logger.error(e,void 0,n)}}()}static async getPolyToolConvertEditor(t){const e=await nr.create(t);return await e.showDialog()}static async polyToolConvert2(t,e,n,r,o){return(await Hn(e,n,!1,r,!1,o))[0]}static async polyToolEnumerateHelmTopMenu(){await Yn(r.shell.tv?.dataFrame.currentCell)}static async polyToolEnumerateChemTopMenu(){kn()}static async polyToolColumnChoice(t,e){var n;(function(t){t.semType=o.SEMTYPE.MACROMOLECULE,t.setTag("aligned","SEQ"),t.setTag("alphabet",Re.YI.PT)})(n=e),n.meta.units=Re.Hi.SEPARATOR,n.setTag("separator","-"),await r.data.detectSemanticTypes(t)}static async createMonomerLibraryForPolyTool(t){const e=await t.readAsString(),n=new er(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 Yn()}static async ptEnumeratorChemApp(){kn()}static async getPtHelmEnumeratorDialog(t){return Yn(t)}static async getPtChemEnumeratorDialog(t){return kn(t)}static async getPolyToolCombineDialog(){!async function(){const t=[],e=M.divV([]),n=i=>{const s=(()=>{const t=M.divH([]),e=M.input.table("Table",{value:void 0,tooltipText:"Table with sequences"}),n=M.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=M.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=M.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 u=t[i];u?e.insertBefore(s.root,u.root):e.appendChild(s.root),t.splice(i,0,s)};n(0);const i=M.input.string("Separator",{value:"-",tooltipText:"Separator for sequences",nullable:!1});M.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 u=0;const c=l.reduce(((t,e)=>t*e.length),1);if(c>1e7)return void r.shell.error("Too many combinations. Maximum allowed is 10M");const h=new Array(c).fill(null),d=(t,e)=>{if(e===l.length)return void(h[u++]=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 f=o.DataFrame.fromColumns([o.Column.fromStrings("Combined Sequences",h)]);f.name="Combined Sequences",await f.meta.detectSemanticTypes(),await r.data.detectSemanticTypes(f),r.shell.addTableView(f)})).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,t.tags["polytool-data-role"]="template",t.temp[a.notationProvider]=new yr(e,Kr.helmHelper)}}async function Xr(t){await Kr.initLibData();const e=function(t,e){switch(t){case"Oligo Translator":return new ze(e);case"Oligo Pattern":return new ie(e);case"Oligo Structure":return new Le(e);default:throw new Error(`Unknown app name: ${t}`)}}(t,Kr);return await e.getAppView()}zr([r.decorators.app({icon:"img/icons/toolkit.png",browsePath:"Peptides | Oligo Toolkit",name:"Oligo Toolkit"}),Wr("design:type",Function),Wr("design:paramtypes",[]),Wr("design:returntype",Promise)],Qr,"oligoToolkitApp",null),zr([r.decorators.init(),Wr("design:type",Function),Wr("design:paramtypes",[]),Wr("design:returntype",Promise)],Qr,"init",null),zr([r.decorators.app({icon:"img/icons/translator.png",browsePath:"Peptides | Oligo Toolkit",name:"Oligo Translator"}),Wr("design:type",Function),Wr("design:paramtypes",[]),Wr("design:returntype",Promise)],Qr,"oligoTranslatorApp",null),zr([r.decorators.app({icon:"img/icons/pattern.png",browsePath:"Peptides | Oligo Toolkit",name:"Oligo Pattern"}),Wr("design:type",Function),Wr("design:paramtypes",[]),Wr("design:returntype",Promise)],Qr,"oligoPatternApp",null),zr([r.decorators.app({icon:"img/icons/structure.png",browsePath:"Peptides | Oligo Toolkit",name:"Oligo Structure"}),Wr("design:type",Function),Wr("design:paramtypes",[]),Wr("design:returntype",Promise)],Qr,"oligoStructureApp",null),zr([r.decorators.func({outputs:[{type:"object",name:"result"}]}),Wr("design:type",Function),Wr("design:paramtypes",[]),Wr("design:returntype",Promise)],Qr,"getTranslationHelper",null),zr([r.decorators.func({outputs:[{type:"object",name:"result"}]}),Wr("design:type",Function),Wr("design:paramtypes",[]),Wr("design:returntype",Object)],Qr,"getCodeToWeightsMap",null),zr([r.decorators.func(),Wr("design:type",Function),Wr("design:paramtypes",[String]),Wr("design:returntype",Boolean)],Qr,"validateSequence",null),zr([r.decorators.func({name:"validateSequence"}),Wr("design:type",Function),Wr("design:paramtypes",[String,Boolean]),Wr("design:returntype",String)],Qr,"getMolfileFromGcrsSequence",null),zr([r.decorators.func(),Yr(0,r.decorators.param({type:"object"})),Wr("design:type",Function),Wr("design:paramtypes",[Object]),Wr("design:returntype",String)],Qr,"linkStrands",null),zr([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),zr([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),zr([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),zr([r.decorators.func(),Wr("design:type",Function),Wr("design:paramtypes",[String,String,String]),Wr("design:returntype",Promise)],Qr,"translateOligonucleotideSequence",null),zr([r.decorators.func({"top-menu":"Bio | PolyTool | Convert...",name:"polyToolConvert",description:"Perform cyclization of polymers"}),Wr("design:type",Function),Wr("design:paramtypes",[]),Wr("design:returntype",Promise)],Qr,"polyToolConvertTopMenu",null),zr([r.decorators.editor(),Wr("design:type",Function),Wr("design:paramtypes",[o.FuncCall]),Wr("design:returntype",Promise)],Qr,"getPolyToolConvertEditor",null),zr([r.decorators.func({editor:"SequenceTranslator:getPolyToolConvertEditor"}),Yr(1,r.decorators.param({options:{caption:"Sequence"}})),Yr(2,r.decorators.param({options:{initialValue:"true"}})),Yr(3,r.decorators.param({options:{initialValue:"true"}})),Yr(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),zr([r.decorators.func({"top-menu":"Bio | PolyTool | Enumerate HELM...",name:"polyToolEnumerateHelm",description:"Perform cyclization of polymers"}),Wr("design:type",Function),Wr("design:paramtypes",[]),Wr("design:returntype",Promise)],Qr,"polyToolEnumerateHelmTopMenu",null),zr([r.decorators.func({"top-menu":"Bio | PolyTool | Enumerate Chem...",name:"polyToolEnumerateChem",description:"Perform cyclization of polymers"}),Wr("design:type",Function),Wr("design:paramtypes",[]),Wr("design:returntype",Promise)],Qr,"polyToolEnumerateChemTopMenu",null),zr([r.decorators.func(),Yr(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),zr([r.decorators.func(),Wr("design:type",Function),Wr("design:paramtypes",[o.FileInfo]),Wr("design:returntype",Promise)],Qr,"createMonomerLibraryForPolyTool",null),zr([r.decorators.func({meta:{icon:"img/icons/structure.png",browsePath:"Peptides | PolyTool"},tags:["app"],name:"HELM Enumerator"}),Wr("design:type",Function),Wr("design:paramtypes",[]),Wr("design:returntype",Promise)],Qr,"ptEnumeratorHelmApp",null),zr([r.decorators.func({meta:{icon:"img/icons/structure.png",browsePath:"Peptides | PolyTool"},tags:["app"],name:"Chem Enumerator"}),Wr("design:type",Function),Wr("design:paramtypes",[]),Wr("design:returntype",Promise)],Qr,"ptEnumeratorChemApp",null),zr([r.decorators.func({name:"Polytool Helm Enumerator dialog"}),Yr(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),zr([r.decorators.func({name:"Polytool Chem Enumerator dialog"}),Yr(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),zr([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),zr([r.decorators.func({name:"applyNotationProviderForHarmonizedSequence"}),Yr(0,r.decorators.param({type:"column"})),Wr("design:type",Function),Wr("design:paramtypes",[o.Column,String]),Wr("design:returntype",void 0)],Qr,"applyNotationProviderForCyclized",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,u,c,h,d,f){const p=(await f.helmToAtomicLevel(t,l,u,h)).molCol,m=n.filter((t=>t)).length;if(c&&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 u=r.Column.fromStrings("helm",t);u.semType=r.SEMTYPE.MACROMOLECULE,u.meta.units=a.Hi.HELM,u.setTag(r.TAGS.CELL_RENDERER,"helm");const c=(await(0,i.pj)()).getMonomerLib();try{const t=await(0,s.C4)(r.DataFrame.create(0),u,c,f,d);l=0;for(let e=0;e<n.length;e++)n[e]&&(p.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)",""))}(p),p}},6307:(t,e,n)=>{"use strict";n.d(e,{s:()=>f});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,u,c]=[!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,c=h;break}if(l||!n&&t[h]!=o[r]+e)continue;a=!0,c=h;break}if(n)s=!0,l=!0,u=h;else if(t[h]==o[r]+e)s=!0,l=!0,u=h;else{if(t[h]!=i[r]+e)continue;s=!0,l=!!n,u=h}}return[s,a,l,u,c]}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,u,c,h,d]=a(t,o,!1,e,s,l);i&&u&&(c?n.push({firstIdx:h,secondIdx:d,ruleIdx:r}):n.push({firstIdx:d,secondIdx:h,ruleIdx:r}))}else{const[e,i,s,l,u]=a(t,o,!0);if(!e||!i)continue;s?n.push({firstIdx:l,secondIdx:u,ruleIdx:r}):n.push({firstIdx:u,secondIdx:l,ruleIdx:r})}}return n}function u(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,u=t[a].code;e[n[l].firstIdx]=e[n[l].firstIdx].replace(`(${u})`,""),e[n[l].secondIdx]=e[n[l].secondIdx].replace(`(${u})`,""),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 c(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,u=n[a].ruleIdx,c=t[u].code;e[s]=e[s].replace(`(${c})`,"")+`_${t[u].name}`,e[l]=e[l].replace(`(${c})`,"")+`_${t[u].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 f{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 f(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("-"),u=i[0].split(":"),c=i[1].split(":");l.push({fChain:n,sChain:o,fMonomer:(0,r.j)(parseInt(u[0]),n,a),sMonomer:(0,r.j)(parseInt(c[0]),o,a),fR:parseInt(u[1].replace("R","")),sR:parseInt(c[1].replace("R",""))})}return[l,a]}(t);return new f(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),u=i.replace(l,"").replaceAll("{","").replaceAll("}","");n[t]=l+u,n.push(u),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,c,h]=u(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:c[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]=c(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(9788);function s(t,e,n){const s=new Array(t.length),a=new Array(t.length),l=new Array(t.length);for(let u=0;u<t.length;u++)try{if(null==t[u])s[u]="";else{const r=o.s.fromSeparator(t[u],n);r.applyRules(e),a[u]=!(r.monomersUnderRules.length>1||r.linkagesUnderRules.length>0),s[u]=r.getHelm(),l[u]=r.posToPosUnderRules}}catch(t){const[e,n]=(0,r.AP)(t);i._package.logger.error(e,void 0,n),s[u]=""}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:()=>j,yy:()=>q,_v:()=>Q,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 u{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 c=n(9788),h=n(9124),d=n(4229),f=n(439),p=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 w(t){return t.replaceAll(/\[C\:\d\]/g,(t=>`[*:${t[3]}]`))}function C(t,e){const n=e?.firstReactantSmiles?w(e.firstReactantSmiles):"[*:1]C",r=e?.secondReactantSmiles?w(e.secondReactantSmiles):"[*:2]C",s=e?.productSmiles?w(e.productSmiles):"[*:1]CC[*:2]",a=e?.code,l=e?.firstMonomers??[],u=e?.secondMonomers??[],c=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"}),f=i.input.string("Second monomers",{value:u.join(","),nullable:!1,tooltipText:"Comma-separated list of monomers for the second reactant"}),p=i.input.string("Result monomer name",{value:c,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."}),C=()=>{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(C),g.addValidator(C),y.addValidator(C);const A=i.dialog(e?"Edit Reaction Rule":"Add Reaction Rule").add(h).add(p).add(d).add(f).add(m).add(g).add(y);A.addButton("Save",(()=>{const n=C();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:p.value,firstMonomers:d.value.split(",").map((t=>t.trim())).filter((t=>t.length>0)),secondMonomers:f.value.split(",").map((t=>t.trim())).filter((t=>t.length>0)),firstReactantSmiles:r,secondReactantSmiles:i,productSmiles:s,rowIndex:e?.rowIndex}),A.close()})),A.show()}const A="Links",x="Reactions";class S{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 S(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);c._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 c.PackageFunctions.applyNotationProviderForCyclized(s,"-"),s.semType=r.SEMTYPE.MACROMOLECULE,a.semType=r.SEMTYPE.MACROMOLECULE,a.meta.units=f.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 u=await(0,g.j)(),b=await(0,y.Q)();c.PackageFunctions.applyNotationProviderForCyclized(s,"-"),s.tags[r.TAGS.CELL_RENDERER]="Sequence",a.semType=r.SEMTYPE.MACROMOLECULE,a.meta.units=f.Hi.HELM,a.setTag(r.TAGS.CELL_RENDERER,"helm");const v=await(0,p.A)(this.rules),w=a.temp;w[".mm.cellRenderer.overriddenLibrary"]=v,a.temp=w;const C=await(0,m.m)(a,t,o,!0,!1,!1,v,u,b);return C.name="molfile(sequence)",C.semType=r.SEMTYPE.MOLECULE,l.columns.add(C),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;C((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),u=await this.getReactionExamplesGrid(),c=this.createGridDiv("Examples",u);this.substituteReactionGridDataFrame=async()=>{const t=await this.getReactionExamplesGrid();u.dataFrame=t.dataFrame},l.style.width="50%",c.style.width="50%";const h=i.divH([l,c]),d=i.divV([this.homoDimerInput,this.heteroDimerInput]),f=i.tabControl({Links:s,Reactions:h,Dimers:d},!1);i.tooltip.bind(f.getPane(A).header,"Specify rules to link monomers based on HELM notation"),i.tooltip.bind(f.getPane(x).header,"Specify rules to perform reactions within monomers"),i.tooltip.bind(f.getPane("Dimers").header,"Specify symbols for homodimeric and heterodimeric codes"),f.root.style.height="100%",f.root.style.width="100%",f.root.classList.add("rules-manager-form-tab-control"),f.header.style.marginBottom="10px";const p=i.divV([f.root]),m=[i.bigButton("Save",(()=>{this.save()})),i.button("Add rule",(()=>{const t=f.currentPane.name;t==A?this.getAddNewLinkRuleDialog():t==x&&C((t=>this.addSynthRulesFunc(t)))})),i.button("Remove rule",(()=>{const e=f.currentPane.name;if(e==A){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==x){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]),p.style.height="100%",p.style.alignItems="center",f.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(","),u=parseInt(a.value.substring(1)),c=parseInt(l.value.substring(1));this.addLinkRulesFunc({code:o,firstMonomers:i??"",secondMonomers:s??"",firstLinkingGroup:u,secondLinkingGroup:c,row:t?.row}),this.rules.setLinkRules(this.linkRuleDataFrame),this.linkCards=await this.rules.getLinkCards(),this.save()})).show()}}S.instances={};var T=n(5072),E=n.n(T),_=n(7825),I=n.n(_),N=n(7659),M=n.n(N),O=n(5056),L=n.n(O),R=n(540),P=n.n(R),B=n(1113),D=n.n(B),F=n(890),k={};k.styleTagTransform=D(),k.setAttributes=L(),k.insert=M().bind(null,"head"),k.domAPI=I(),k.insertStyleElement=P(),E()(F.A,k),F.A&&F.A.locals&&F.A.locals;var H=n(2003);class U{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 ${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%"}}),u=i.divH([],{style:{overflowX:"auto",width:"100%"}});this.resulting=i.divH([],{style:{overflowX:"auto",width:"100%",minHeight:"150px"}});const c=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([c,l,h,u,this.resulting]);this.cardsFirst=t.map((t=>new U(n.getMonomer("PEPTIDE",t),t))),this.cardsSecond=e.map((t=>new U(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()},u.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=H.Hi.HELM,l.setTag(r.TAGS.CELL_RENDERER,"helm");const u=await(0,g.j)(),c=await(0,y.Q)(),f=await(0,p.A)(this.rules),b=l.temp;l.temp=b;const v=(await(0,m.m)(l,n,s,!0,!1,!1,f,u,c)).get(0),w=v&&o.chem.checkSmiles(v)?o.chem.drawMolecule(v,200,200):o.chem.drawMolecule(v??"",200,200);v&&(w.style.cursor="pointer",w.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(w,"Click to expand"));const C=i.divV([i.h2("Example Result:"),i.h2(t[0])],{style:{width:"200px"}});i.empty(this.resulting),this.resulting.append(i.divH([C,w],{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 j="System:AppData/SequenceTranslator/polytool-rules/",q="Polytool",G="code",z="firstMonomers",W="secondMonomers",Y="name",K="firstLinkingGroup",J="secondLinkingGroup";class Q extends u{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 S.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=Q.ruleDescriptions)[e]??(t[e]=(async()=>{try{const t=JSON.parse(await o.dapi.files.readAsText(`${j}/${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 c._package.logger.error(`Failed to load rule ${e}: ${t?.toString?.()}`),console.error(t),i.divText(`Failed to load rule ${e}`)}})()),await Q.ruleDescriptions[e]})))}}}function X(t,e=30){return t.length<=e?t:`${t.substring(0,e)}...`}Q.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(G,t);e.setTag("friendlyName","Code");const n=r.Column.string(z,t);n.temp[".mm.cellRenderer.fontSize"]=16,n.setTag("friendlyName","First monomers"),n.semType=r.SEMTYPE.MACROMOLECULE,c.PackageFunctions.applyNotationProviderForCyclized(n,",");const o=r.Column.string(W,t);o.setTag("friendlyName","Second monomers"),o.temp[".mm.cellRenderer.fontSize"]=16,o.semType=r.SEMTYPE.MACROMOLECULE,c.PackageFunctions.applyNotationProviderForCyclized(o,",");const i=r.Column.int(K,t);i.setTag("friendlyName","First group");const s=r.Column.int(J,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 $(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(G,t);e.setTag("friendlyName","Code");const n=r.Column.string(z,t);n.setTag("friendlyName","First monomers");const o=r.Column.string(W,t);o.setTag("friendlyName","Second monomers"),n.semType=r.SEMTYPE.MACROMOLECULE,n.temp[".mm.cellRenderer.fontSize"]=16,c.PackageFunctions.applyNotationProviderForCyclized(n,","),o.semType=r.SEMTYPE.MACROMOLECULE,o.temp[".mm.cellRenderer.fontSize"]=16,c.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(">>"),u=t[0].split(".");s.set(r,u[0]),a.set(r,u[1]),l.set(r,t[1])}s.semType=r.SEMTYPE.MOLECULE,a.semType=r.SEMTYPE.MOLECULE,l.semType=r.SEMTYPE.MOLECULE;const u=r.DataFrame.fromColumns([i,s,a,l,e,n,o]);return{df:u,addNewRow:t=>{if(null!=t.rowIndex&&t.rowIndex<u.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;u.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(G),o=t.columns.byName(z),i=t.columns.byName(W),s=t.columns.byName(K),a=t.columns.byName(J);for(let t=0;t<e;t++){const e=o.get(t).split(","),l=i.get(t).split(","),u={code:r.get(t),firstMonomers:""!==e[0]?e:[],secondMonomers:""!==l[0]?l:[],firstLinkingGroup:s.get(t),secondLinkingGroup:a.get(t)};n[t]=u}this.linkRules=n}setSynthesisRules(t){const e=t.rowCount,n=new Array(e),r=t.columns.byName(G),o=t.columns.byName(z),i=t.columns.byName(W),s=t.columns.byName(Y),a=t.columns.byName("firstReactant"),l=t.columns.byName("secondReactant"),u=t.columns.byName("product");for(let t=0;t<e;t++){const e=`${a.get(t)}.${l.get(t)}>>${u.get(t)}`,c=o.get(t).split(","),h=i.get(t).split(","),d={code:r.get(t),firstMonomers:""!==c[0]?c:[],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(j),n=new Z(null,null,[],[]);for(let r=0;r<t.length;r++){const o=await e.readAsText(t[r].replace(j,"")),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:()=>c});var r=n(6717),o=n(1296),i=n(9192),s=n(4328),a=n(1991),l=n.n(a),u=n(4971);async function c(t){const e=(await(0,u.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 c={PEPTIDE:o};return e.override(c,"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("."),u=new Array(s),c=new Array(s),h=new Array(s),m=f(t,r),g=`${l[0]}>>[C:1]C`,y=`${l[1]}>>[C:2]C`,b=f(t,g),v=f(t,y);let w=0;for(let r=0;r<n.firstMonomers.length;r++){const i=e.getMonomer("PEPTIDE",n.firstMonomers[r]);if(i){const e=d(t,i.molfile,b,i.name);h[w]=e,u[w]=`${i.symbol}_${o}`}w++}for(let r=0;r<n.secondMonomers.length;r++){const i=e.getMonomer("PEPTIDE",n.secondMonomers[r]);if(i){const e=d(t,i.molfile,v,i.name);h[w]=e,u[w]=`${i.symbol}_${o}`}w++}let C=null;a[1]=a[1].replace("[C:1]","[1*]").replace("[C:2]","[2*]").replace("[C:3]","[3*]");let A="";try{C=t.get_mol(a[1]),A=C?.get_molblock()}catch(t){const[e,n]=(0,i.AP)(t);throw console.error(`Can not assemble monomer '${o}': ${e}.`),t}finally{C?.delete()}h[w]=A,u[w]=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]||!u[t])continue;const n={symbol:u[t],name:u[t],molfile:h[t],author:"",id:0,rgroups:p(e),smiles:"",polymerType:"PEPTIDE",monomerType:"Backbone",createDate:null};n.meta=Object.assign(n.meta??{},{colors:{default:{line:"#2083D5",text:"#2083D5",background:"#F2F2F5"}}}),u[t]=u[t],c[t]=n}return m.delete(),b.delete(),v.delete(),[u,c]}function d(t,e,n,r){let o=null,s=null,a=null,l=null,u="";try{o=new t.MolList,s=t.get_mol(e),o.append(s),a=n.run_reactants(o,1),l=a.get(0).next(),u=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 u}function f(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 p(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"}]}},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],u=o[i*s+n]=t.clone(),c=u.atoms[a].elem;u.atoms[a].elem=l;const h=c?.length>1?`[${c}]`:c,d=l?.length>1?`[${l}]`:l;u.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.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 u=[];n.breadthPlaceholders&&(u=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(u),n.keepOriginal&&(l=[a,...l]);const c=l.map((t=>[org.helm.webeditor.IO.getHelm(t),t.name]));return c}},1296:(t,e,n)=>{"use strict";var r;n.d(e,{J5:()=>o,aK:()=>r}),function(t){t.Single="single",t.Matrix="matrix",t.Library="library"}(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=n(9788);sequencetranslator=r})();
2
+ var sequencetranslator;(()=>{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:()=>u,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,u,c,h){const d=t.length,f=t.dataFrame,p=Math.max(navigator.hardwareConcurrency-2,1),m=new Array(p).fill(null).map((()=>new Worker(new URL(n.p+n.u(455),n.b)))),g=d/p,y=new Array(p),b=c.getSeqHandler(t),v="RNA"==l?a.o.NUCLEOTIDE:a.o.AA,w=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<p;t++){const n=m[t],r=Math.floor(t*g),i=t===p-1?d:Math.floor((t+1)*g);y[t]=new Promise((t=>{n.onmessage=e=>{t(e.data)}})),n.postMessage({seqList:w,monomersDict:e,alphabet:o,polymerType:l,start:r,end:i})}const C=[],A=[];await Promise.all(y).then((t=>{for(const e of t)C.push(...e.molfiles),A.push(...e.warnings)})),setTimeout((()=>{m.forEach((t=>{t.terminate()}))}),0);const x=(0,s.qj)(f,t.name),S=r.Column.fromType(r.COLUMN_TYPE.STRING,x,t.length).init((t=>C[t]?.molfile));return S.semType=r.SEMTYPE.MOLECULE,S.meta.units=r.UNITS.Molecule.MOLBLOCK,S.setTag(".sequence-src-col",t.name),{molCol:S,warnings:A}}function u(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:()=>u});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 u(t,e,n,i){if(0===t.length)return o.vF.createEmpty();const l=p,{atomCount:u,bondCount:h,needsCapping:f}=l(t,e,n,i),g=new Array(u),y=new Array(h);let b,v=null,w=null;"PEPTIDE"===i?b=c:(b=d,v=n===s.YI.DNA?(0,o.xb)(e,r.u.DEOXYRIBOSE):(0,o.xb)(e,r.u.RIBOSE),w=(0,o.xb)(e,r.u.PHOSPHATE));const C={i:0,nodeShift:0,bondShift:0,backbonePositionShift:new Array(2).fill(0),branchPositionShift:new Array(2).fill(0),backboneAttachNode:0,branchAttachNode:0,flipFactor:1},A={sugar:v,phosphate:w,seqLength:t.length,atomCount:u,bondCount:h},x=new o.Cg,S=[];let T,E=0;for(C.i=0;C.i<A.seqLength;++C.i){const n=t[C.i];if(n.symbol===s._S)continue;const r=(0,o.xb)(e,{symbol:n.symbol,polymerType:(0,a.Y)(n.biotype)});T=r.terminalR2Atom;const i=C.nodeShift,l=C.bondShift;b(r,g,y,C,A),r.stereoAtoms?.forEach((t=>S.push(t+E))),E+=r.atoms.x.length;const u=C.nodeShift-i,c=new Array(u);for(let t=0;t<u;++t)c[t]=i+t;const h=C.bondShift-l,d=new Array(h);for(let t=0;t<h;++t)d[t]=l+t;x.set(C.i,{biotype:n.biotype,symbol:n.symbol,atoms:c,bonds:d})}f&&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,C,A,T??r.u.OXYGEN);const _=r.u.V3K_BEGIN_COUNTS_LINE+u+" "+h+r.u.V3K_COUNTS_LINE_ENDING;let I="";return I+=r.u.V3K_HEADER_FIRST_LINE,I+=r.u.V3K_HEADER_SECOND_LINE,I+=r.u.V3K_BEGIN_CTAB_BLOCK,I+=_,I+=r.u.V3K_BEGIN_ATOM_BLOCK,I+=g.join(""),I+=r.u.V3K_END_ATOM_BLOCK,I+=r.u.V3K_BEGIN_BOND_BLOCK,I+=y.join(""),I+=r.u.V3K_END_BOND_BLOCK,S.length>0&&(I+=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`}(S)),I+=r.u.V3K_END_CTAB_BLOCK,I+=r.u.V3K_END,{molfile:I,monomers:x}}function c(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),f(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),f(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 f(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 u=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+u+"\n"}}function p(t,e,n,i){let l=0,u=0,c=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,u+=d.bonds.bondTypes.length,c++}if("PEPTIDE"===i)l+=1,u+=c,c>0&&((d?.meta?.rNodes?.length??0)<2||d?.terminalR2Atom?.toLowerCase()===r.u.HYDROGEN.toLowerCase())&&(h=!1,l-=1,u-=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,u+=(t.length-1)*a.bonds.bondTypes.length,u+=t.length*i.bonds.bondTypes.length,u-=1,u+=3*t.length}return{atomCount:l,bondCount:u,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:()=>p,eM:()=>m});var r=n(4328),o=n(6082),i=n(1991),s=n.n(i),a=n(439),l=n(3561),u=n(9235),c=n(294),h=n(9192),d=n(330),f=n(8123);async function p(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 c=e;const f=i.getSeqHandler(e);let p,g;f.notation!==a.Hi.SEPARATOR&&f.notation!==a.Hi.BILN&&(c=f.convert(a.Hi.SEPARATOR,"."),c.name=e.name);try{g=i.getSeqHandler(c).alphabet,p=(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}(c,i),b=m(y,p,g,n,l),v=c.length,w=await(0,u.R)(c,b,g,p,n,i,l);w.warnings.length>.05*v&&r.shell.warning(`Molfile conversion resulted in ${w.warnings.length} errors`);const C=o.Func.find({name:"convertToV3KViaOCL"})[0];if(C&&w.molCol)try{const t=w.molCol.toList(),e=await C.apply({mols:t});w.molCol.init((n=>e[n]?e[n]:t[n]))}catch(t){console.error(t)}return w}function m(t,e,n,r,o){const i=(0,l.Hb)(r,e,n),s={},u={value:null};if("RNA"===e){const t=n===a.YI.RNA?[f.u.RIBOSE,f.u.PHOSPHATE]:[f.u.DEOXYRIBOSE,f.u.PHOSPHATE];for(const n of t)g(s,n.symbol,i,o,e,u)}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,u),s[e]?.[t]&&(s[e][n]=s[e][t])}else g(s,n,i,o,e,u)}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,c.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),u=(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(f.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(f.u.V2K_A_LINE,r)}for(n=t.indexOf(f.u.V2K_RGP_LINE,0),r=t.indexOf("\n",n);-1!==n;){n+=f.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(f.u.V2K_RGP_LINE,r)}return e}(i),c=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(f.u.V2K_A_LINE,0);-1===e&&(e=t.indexOf(f.u.V2K_RGP_LINE));const n=t.indexOf(f.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(f.u.V3K_BEGIN_COUNTS_LINE)+f.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))}}(c),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(f.u.V3K_BEGIN_ATOM_BLOCK);s=t.indexOf("\n",s);let a=s;for(let l=0;l<e;l++){s=t.indexOf(f.u.V3K_BEGIN_DATA_LINE,s)+f.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}}(c,h.atomCount),p=function(t,e){const n=new Uint32Array(e),r=new Array(e),o=new Map,i=new Map;let s=t.indexOf(f.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(f.u.V3K_BEGIN_DATA_LINE,a)+f.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 u=t.indexOf("\n",s);let c=t.slice(a,u),h=c.indexOf(f.u.V3K_BOND_CONFIG);if(-1!==h){h=c.indexOf("=",h)+1;let t=c.indexOf(" ",h);-1===t&&(t=c.length);const e=parseInt(c.slice(h,t));o.set(l,e);const n=f.u.V3K_BOND_CONFIG+e.toString();c=c.replace(n,"")}c||i.set(l,c)}return{bondTypes:n,atomPairs:r,bondConfiguration:o,kwargs:i}}(c,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],u=e.atomPairs.find((t=>t.includes(s+1))).find((t=>t!==s+1))-1;let c=t.x.reduce(((e,n,r)=>{if(r===s)return e;if(r===u)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===c&&(c=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([u+1,c+1]),e.bondTypes=new Uint32Array([...e.bondTypes,1]),e.kwargs.set(e.atomPairs.length-1,"")),r.set(c+1,o),1===o)n.unshift(t.atomTypes[c]);else{if(2!==o)throw new Error(`Unexpected missing R-group: ${o}`);n.splice(1,0,t.atomTypes[c])}}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,p,a,u),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}(c),v={atoms:d,bonds:p,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;E(t,-r[e],-o[e]);const i=A(r[n],o[n]);x(t.atoms,-i),r[t.meta.rNodes[1]-1]<0&&S(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]===f.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){T(t,!0)}(t),x(t.atoms,-function(t,e){return A(t,e)+Math.PI/2}(t.atoms.x[t.meta.terminalNodes[1]-1],t.atoms.y[t.meta.terminalNodes[1]-1])))}(t,s),function(t,e){const n=t.atoms.x;n[t.meta.rNodes[1]-1]>n[e-1]&&function(t,e,n){const 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===f.u.RIBOSE.symbol||t===f.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;E(t,-n[o],-r[o]);const s=A(n[t.meta.rNodes[2]-1],r[t.meta.rNodes[2]-1]);x(t.atoms,-s),n[t.meta.rNodes[0]-1]>n[t.meta.rNodes[1]-1]&&S(t);const a=A(n[i],r[i]);x(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,E(t,-n[o],-r[o])}(v,o):t===f.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;E(t,-r[e],-o[e]);const i=A(r[n],o[n]);x(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;E(t,-n[o],-r[o]);const s=A(n[i],r[i]),a=e.value;if(!a)throw new Error("The value of sugarBranchToOYAngle is null");x(t.atoms,Math.PI-s+a);const u=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!=u)for(let t=0;t<n.length;++t)n[t]=(0,l.YN)(n[t]/u),r[t]=(0,l.YN)(r[t]/u)}(v,o),function(t,e,n){if("PEPTIDE"===t){b(e,t);const n=w(e,e.meta.rNodes[1]);n?.removedAtom&&(e.terminalR2Atom=n.removedAtom)}else n===f.u.RIBOSE.symbol||n===f.u.DEOXYRIBOSE.symbol?(w(e,e.meta.rNodes[1]),e.meta.rNodes[1]=e.meta.terminalNodes[1],y(e.bonds,e.meta),b(e,t),w(e,e.meta.rNodes[1]),w(e,e.meta.rNodes[0]),w(e,e.meta.rNodes[2])):n===f.u.PHOSPHATE.symbol&&(e.meta.terminalNodes[0]=e.meta.rNodes[0],E(e,-e.atoms.x[e.meta.terminalNodes[0]-1],-e.atoms.y[e.meta.terminalNodes[0]-1]),b(e,t),w(e,e.meta.rNodes[1]))}(r,v,t),function(t){let e=0;for(;e<t.atoms.atomTypes.length;)t.atoms.atomTypes[e]===f.u.HYDROGEN&&(w(t,e+1),--e),++e}(v),function(t){let e=0;for(;e<t.atoms.atomTypes.length;)"oh"===t.atoms.atomTypes[e]?.toLowerCase()&&(t.atoms.atomTypes[e]="O"),"?"===t.atoms.atomTypes[e]&&(t.atoms.atomTypes[e]="H"),++e}(v),function(t){const e=" RGROUPS=(1 1)";for(let n=0;n<(t.atoms.kwargs?.length??0);n++){const 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,c.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 w(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=C(Float32Array,r.x,n,1),r.y=C(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=C(Uint32Array,o.bondTypes,a,1),o.bondConfiguration.has(a)&&o.bondConfiguration.delete(a),o.kwargs.has(a)&&o.kwargs.delete(a),--a):(o.atomPairs[a][0]=t>e?t-1:t,o.atomPairs[a][1]=n>e?n-1:n),++a}let l=Array.from(o.bondConfiguration.keys());return l.forEach((t=>{if(o.bondConfiguration.has(t)&&t>n){const e=o.bondConfiguration.get(t);o.bondConfiguration.delete(t),o.bondConfiguration.set(t-1,e)}})),l=Array.from(o.kwargs.keys()),l.forEach((t=>{if(o.kwargs.has(t)&&t>n){const e=o.kwargs.get(t);o.kwargs.delete(t),o.kwargs.set(t-1,e)}})),s?{removedAtom:s}:void 0}}function C(t,e,n,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 A(t,e){let n;if(0===t)n=e>0?0:Math.PI;else if(0===e)n=t>0?-Math.PI/2:Math.PI/2;else{const r=e/t,o=Math.atan(r);n=t<0?Math.PI/2+o:-Math.PI/2+o}return n}function x(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 S(t){T(t,!1)}function T(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 E(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,YI:()=>o,_S:()=>l,b9:()=>u,gp:()=>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"}(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.a(o.PT,a.fasta.peptide,.5),new s.a(o.DNA,a.fasta.dna,.55),new s.a(o.RNA,a.fasta.rna,.55),""),u={[r.FASTA]:"-",[r.SEPARATOR]:"",[r.HELM]:"*",[r.BILN]:""}},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,{a:()=>r});class r{constructor(t,e,n){this.name=t,this.alphabet=e,this.cutoff=n}}},7291:(t,e,n)=>{"use strict";n.d(e,{Mu:()=>y,dh:()=>v,zS:()=>A,qp:()=>w});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 u{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]}}u.SemType="Aminoacids",u.SemTypeMultipleAlignment="AminoacidsMultipleAlignment",u.undefinedColor="rgb(100,100,100)",u.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"},u.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"},u.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(*)*"},u.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 c{}c.SemType="Nucleotides",c.SemTypeMultipleAlignment="NucleotidesMultipleAlignment",c.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 f{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 p{}class m extends p{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=f.hashCode(t)%n;return d(m.palette[i])}}m._pallete=null,m.customMonomerColors={},m.polymerTypes=[];var g=n(8438);n(3599);class y{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 b extends y{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 u=n[2].split("-");if(2!==u.length)continue;const c=u[0].split(":"),h=u[1].split(":");if(2!==c.length||2!==h.length)continue;const d=parseInt(c[0])-1,f=parseInt(h[0])-1;d<0||d>=this.mListSeparated[i].length||f<0||f>=this.mListSeparated[s].length||t.connections.push({seq1Type:a,seq2Type:l,seqIndex1:i,seqIndex2:s,monomerIndex1:d,monomerIndex2:f,rGroup1:parseInt(c[1].substring(1)),rGroup2:parseInt(h[1].substring(1))})}}return t}}function v(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 y(r,s.b9[s.Hi.SEPARATOR])}return new y([],s.b9[s.Hi.SEPARATOR])}}const w=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 b(a,o??"",l,s.b9[s.Hi.HELM])},C=/([^\W_]+)/g;function A(t,e){if(t.length<=e)return t;const n=t.match(C),r=t.length>e||(n?.length??0)>1,o=n?.[0]??" ";return r?o.substring(0,e-1)+"…":o}},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={}))},8070:(t,e,n)=>{"use strict";n.d(e,{cb:()=>a,PE:()=>s}),n(4328);var r=n(6082);n(9982),r.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(r.Column.fromList(r.TYPE.BYTE_ARRAY,"BinaryImage",Array.from(new Uint8Array(11))));var o,i=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())}))};function s(t,e,n,r=0,o="timeout"){return i(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()}))}))}function a(t){return i(this,void 0,void 0,(function*(){yield new Promise((e=>setTimeout(e,t)))}))}console.log.bind(console),console.info.bind(console),console.warn.bind(console),console.error.bind(console),function(t){t.notNull=function(t,e){if(null==t)throw new Error(`${null==e?"Value":e} not defined`)}}(o||(o={})),r.DataFrame.fromColumns([r.Column.fromStrings("col",["val1","val2","val3"])])},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 -webkit-text-fill-color: transparent;\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,oCAAoC;EACpC,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 -webkit-text-fill-color: transparent;\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}\n\n.st-structure-mol-img {\n margin-right: 30px;\n float: right;\n}\n\n.st-structure-bool-button-block {\n justify-content: right;\n margin-bottom: 10px;\n}\n\n.st-structure-bottom {\n flex-direction: row-reverse;\n padding-top: 20px;\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;AACrB;;AAEA;EACE,kBAAkB;EAClB,YAAY;AACd;;AAEA;EACE,sBAAsB;EACtB,mBAAmB;AACrB;;AAEA;EACE,2BAA2B;EAC3B,iBAAiB;AACnB;;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}\n\n.st-structure-mol-img {\n margin-right: 30px;\n float: right;\n}\n\n.st-structure-bool-button-block {\n justify-content: right;\n margin-bottom: 10px;\n}\n\n.st-structure-bottom {\n flex-direction: row-reverse;\n padding-top: 20px;\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 u=0;u<t.length;u++){var c=[].concat(t[u]);r&&s[c[0]]||(void 0!==i&&(void 0===c[5]||(c[1]="@layer".concat(c[5].length>0?" ".concat(c[5]):""," {").concat(c[1],"}")),c[5]=i),n&&(c[2]?(c[1]="@media ".concat(c[2]," {").concat(c[1],"}"),c[2]=n):c[2]=n),o&&(c[4]?(c[1]="@supports (".concat(c[4],") {").concat(c[1],"}"),c[4]=o):c[4]="".concat(o)),e.push(c))}},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,u,c,h,d,f,p,m,g,y,b;i>=64;){for(s=n[0],a=n[1],l=n[2],u=n[3],c=n[4],h=n[5],d=n[6],f=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=((p=t[m-2])>>>17|p<<15)^(p>>>19|p<<13)^p>>>10,b=((p=t[m-15])>>>7|p<<25)^(p>>>18|p<<14)^p>>>3,t[m]=(y+t[m-7]|0)+(b+t[m-16]|0);for(m=0;m<64;m++)y=(((c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7))+(c&h^~c&d)|0)+(f+(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,f=d,d=h,h=c,c=u+y|0,u=l,l=a,a=s,s=y+b|0;n[0]+=s,n[1]+=a,n[2]+=l,n[3]+=u,n[4]+=c,n[5]+=h,n[6]+=d,n[7]+=f,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]),u=s(e,t),c=new o(u),h=new Uint8Array(c.digestLength),d=h.length,f=new Uint8Array(r),p=0;p<r;p++)d===h.length&&(a(h,c,n,i),d=0),f[p]=h[d++];return c.clean(),h.fill(0),i.fill(0),f},t.pbkdf2=function(t,e,n,r){for(var i=new o(t),s=i.digestLength,a=new Uint8Array(4),l=new Uint8Array(s),u=new Uint8Array(s),c=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(u);for(var f=0;f<s;f++)l[f]=u[f];for(f=2;f<=n;f++){i.reset(),i.update(u).finish(u);for(var p=0;p<s;p++)l[p]^=u[p]}for(f=0;f<s&&h*s+f<r;f++)c[h*s+f]=l[f]}for(h=0;h<s;h++)l[h]=u[h]=0;for(h=0;h<4;h++)a[h]=0;return i.clean(),c}}(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,u=128,c=1/0,h=9007199254740991,d=NaN,f=4294967295,p=[["ary",u],["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]",w="[object Function]",C="[object GeneratorFunction]",A="[object Map]",x="[object Number]",S="[object Object]",T="[object Promise]",E="[object RegExp]",_="[object Set]",I="[object String]",N="[object Symbol]",M="[object WeakMap]",O="[object ArrayBuffer]",L="[object DataView]",R="[object Float32Array]",P="[object Float64Array]",B="[object Int8Array]",D="[object Int16Array]",F="[object Int32Array]",k="[object Uint8Array]",H="[object Uint8ClampedArray]",U="[object Uint16Array]",$="[object Uint32Array]",V=/\b__p \+= '';/g,q=/\b(__p \+=) '' \+/g,j=/(__e\(.*?\)|\b__t\)) \+\n'';/g,G=/&(?:amp|lt|gt|quot|#39);/g,z=/[&<>"']/g,W=RegExp(G.source),Y=RegExp(z.source),K=/<%-([\s\S]+?)%>/g,J=/<%([\s\S]+?)%>/g,Q=/<%=([\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,ut=/[()=,{}\[\]\/\s]/,ct=/\\(\\)?/g,ht=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,dt=/\w*$/,ft=/^[-+]0x[0-9a-f]+$/i,pt=/^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=/($^)/,wt=/['\n\r\u2028\u2029\\]/g,Ct="\\ud800-\\udfff",At="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",xt="\\u2700-\\u27bf",St="a-z\\xdf-\\xf6\\xf8-\\xff",Tt="A-Z\\xc0-\\xd6\\xd8-\\xde",Et="\\ufe0e\\ufe0f",_t="\\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",It="["+Ct+"]",Nt="["+_t+"]",Mt="["+At+"]",Ot="\\d+",Lt="["+xt+"]",Rt="["+St+"]",Pt="[^"+Ct+_t+Ot+xt+St+Tt+"]",Bt="\\ud83c[\\udffb-\\udfff]",Dt="[^"+Ct+"]",Ft="(?:\\ud83c[\\udde6-\\uddff]){2}",kt="[\\ud800-\\udbff][\\udc00-\\udfff]",Ht="["+Tt+"]",Ut="\\u200d",$t="(?:"+Rt+"|"+Pt+")",Vt="(?:"+Ht+"|"+Pt+")",qt="(?:['’](?:d|ll|m|re|s|t|ve))?",jt="(?:['’](?:D|LL|M|RE|S|T|VE))?",Gt="(?:"+Mt+"|"+Bt+")?",zt="["+Et+"]?",Wt=zt+Gt+"(?:"+Ut+"(?:"+[Dt,Ft,kt].join("|")+")"+zt+Gt+")*",Yt="(?:"+[Lt,Ft,kt].join("|")+")"+Wt,Kt="(?:"+[Dt+Mt+"?",Mt,Ft,kt,It].join("|")+")",Jt=RegExp("['’]","g"),Qt=RegExp(Mt,"g"),Xt=RegExp(Bt+"(?="+Bt+")|"+Kt+Wt,"g"),Zt=RegExp([Ht+"?"+Rt+"+"+qt+"(?="+[Nt,Ht,"$"].join("|")+")",Vt+"+"+jt+"(?="+[Nt,Ht+$t,"$"].join("|")+")",Ht+"?"+$t+"+"+qt,Ht+"+"+jt,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Ot,Yt].join("|"),"g"),te=RegExp("["+Ut+Ct+At+Et+"]"),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[R]=oe[P]=oe[B]=oe[D]=oe[F]=oe[k]=oe[H]=oe[U]=oe[$]=!0,oe[m]=oe[g]=oe[O]=oe[y]=oe[L]=oe[b]=oe[v]=oe[w]=oe[A]=oe[x]=oe[S]=oe[E]=oe[_]=oe[I]=oe[M]=!1;var ie={};ie[m]=ie[g]=ie[O]=ie[L]=ie[y]=ie[b]=ie[R]=ie[P]=ie[B]=ie[D]=ie[F]=ie[A]=ie[x]=ie[S]=ie[E]=ie[_]=ie[I]=ie[N]=ie[k]=ie[H]=ie[U]=ie[$]=!0,ie[v]=ie[w]=ie[M]=!1;var se={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},ae=parseFloat,le=parseInt,ue="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,ce="object"==typeof self&&self&&self.Object===Object&&self,he=ue||ce||Function("return this")(),de=e&&!e.nodeType&&e,fe=de&&t&&!t.nodeType&&t,pe=fe&&fe.exports===de,me=pe&&ue.process,ge=function(){try{return fe&&fe.require&&fe.require("util").types||me&&me.binding&&me.binding("util")}catch(t){}}(),ye=ge&&ge.isArrayBuffer,be=ge&&ge.isDate,ve=ge&&ge.isMap,we=ge&&ge.isRegExp,Ce=ge&&ge.isSet,Ae=ge&&ge.isTypedArray;function xe(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 Se(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 Te(t,e){for(var n=-1,r=null==t?0:t.length;++n<r&&!1!==e(t[n],n,t););return t}function Ee(t,e){for(var n=null==t?0:t.length;n--&&!1!==e(t[n],n,t););return t}function _e(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 Ie(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 Ne(t,e){return!(null==t||!t.length)&&He(t,e,0)>-1}function Me(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 Oe(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 Re(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 Pe(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 Be(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 De=qe("length");function Fe(t,e,n){var r;return n(t,(function(t,n,o){if(e(t,n,o))return r=n,!1})),r}function ke(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 He(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):ke(t,$e,n)}function Ue(t,e,n,r){for(var o=n-1,i=t.length;++o<i;)if(r(t[o],e))return o;return-1}function $e(t){return t!=t}function Ve(t,e){var n=null==t?0:t.length;return n?ze(t,e)/n:d}function qe(t){return function(e){return null==e?o:e[t]}}function je(t){return function(e){return null==t?o:t[e]}}function Ge(t,e,n,r,o){return o(t,(function(t,o,i){n=r?(r=!1,t):e(n,t,o,i)})),n}function ze(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 We(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 Je(t,e){return Oe(e,(function(e){return t[e]}))}function Qe(t,e){return t.has(e)}function Xe(t,e){for(var n=-1,r=t.length;++n<r&&He(e,t[n],0)>-1;);return n}function Ze(t,e){for(var n=t.length;n--&&He(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 un(t){var e=-1,n=Array(t.size);return t.forEach((function(t){n[++e]=[t,t]})),n}function cn(t){return rn(t)?function(t){for(var e=Xt.lastIndex=0;Xt.test(t);)++e;return e}(t):De(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 fn=je({"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"}),pn=function t(e){var n,r=(e=null==e?he:pn.defaults(he.Object(),e,pn.pick(he,ne))).Array,ot=e.Date,Ct=e.Error,At=e.Function,xt=e.Math,St=e.Object,Tt=e.RegExp,Et=e.String,_t=e.TypeError,It=r.prototype,Nt=At.prototype,Mt=St.prototype,Ot=e["__core-js_shared__"],Lt=Nt.toString,Rt=Mt.hasOwnProperty,Pt=0,Bt=(n=/[^.]+$/.exec(Ot&&Ot.keys&&Ot.keys.IE_PROTO||""))?"Symbol(src)_1."+n:"",Dt=Mt.toString,Ft=Lt.call(St),kt=he._,Ht=Tt("^"+Lt.call(Rt).replace(et,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ut=pe?e.Buffer:o,$t=e.Symbol,Vt=e.Uint8Array,qt=Ut?Ut.allocUnsafe:o,jt=sn(St.getPrototypeOf,St),Gt=St.create,zt=Mt.propertyIsEnumerable,Wt=It.splice,Yt=$t?$t.isConcatSpreadable:o,Kt=$t?$t.iterator:o,Xt=$t?$t.toStringTag:o,te=function(){try{var t=ui(St,"defineProperty");return t({},"",{}),t}catch(t){}}(),se=e.clearTimeout!==he.clearTimeout&&e.clearTimeout,ue=ot&&ot.now!==he.Date.now&&ot.now,ce=e.setTimeout!==he.setTimeout&&e.setTimeout,de=xt.ceil,fe=xt.floor,me=St.getOwnPropertySymbols,ge=Ut?Ut.isBuffer:o,De=e.isFinite,je=It.join,mn=sn(St.keys,St),gn=xt.max,yn=xt.min,bn=ot.now,vn=e.parseInt,wn=xt.random,Cn=It.reverse,An=ui(e,"DataView"),xn=ui(e,"Map"),Sn=ui(e,"Promise"),Tn=ui(e,"Set"),En=ui(e,"WeakMap"),_n=ui(St,"create"),In=En&&new En,Nn={},Mn=Fi(An),On=Fi(xn),Ln=Fi(Sn),Rn=Fi(Tn),Pn=Fi(En),Bn=$t?$t.prototype:o,Dn=Bn?Bn.valueOf:o,Fn=Bn?Bn.toString:o;function kn(t){if(ta(t)&&!qs(t)&&!(t instanceof Vn)){if(t instanceof $n)return t;if(Rt.call(t,"__wrapped__"))return ki(t)}return new $n(t)}var Hn=function(){function t(){}return function(e){if(!Zs(e))return{};if(Gt)return Gt(e);t.prototype=e;var n=new t;return t.prototype=o,n}}();function Un(){}function $n(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__=f,this.__views__=[]}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 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 Gn(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 zn(t){var e=-1,n=null==t?0:t.length;for(this.__data__=new Gn;++e<n;)this.add(t[e])}function Wn(t){var e=this.__data__=new jn(t);this.size=e.size}function Yn(t,e){var n=qs(t),r=!n&&Vs(t),o=!n&&!r&&Ws(t),i=!n&&!r&&!o&&la(t),s=n||r||o||i,a=s?We(t.length,Et):[],l=a.length;for(var u in t)!e&&!Rt.call(t,u)||s&&("length"==u||o&&("offset"==u||"parent"==u)||i&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||gi(u,l))||a.push(u);return a}function Kn(t){var e=t.length;return e?t[Gr(0,e-1)]:o}function Jn(t,e){return Li(_o(t),ir(e,0,t.length))}function Qn(t){return Li(_o(t))}function Xn(t,e,n){(n!==o&&!Hs(t[e],n)||n===o&&!(e in t))&&rr(t,e,n)}function Zn(t,e,n){var r=t[e];Rt.call(t,e)&&Hs(r,n)&&(n!==o||e in t)||rr(t,e,n)}function tr(t,e){for(var n=t.length;n--;)if(Hs(t[n][0],e))return n;return-1}function er(t,e,n,r){return cr(t,(function(t,o,i){e(r,t,n(t),i)})),r}function nr(t,e){return t&&Io(e,Ma(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:Ta(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,u=2&e,c=4&e;if(n&&(a=i?n(t,r,i,s):n(t)),a!==o)return a;if(!Zs(t))return t;var h=qs(t);if(h){if(a=function(t){var e=t.length,n=new t.constructor(e);return e&&"string"==typeof t[0]&&Rt.call(t,"index")&&(n.index=t.index,n.input=t.input),n}(t),!l)return _o(t,a)}else{var d=di(t),f=d==w||d==C;if(Ws(t))return Co(t,l);if(d==S||d==m||f&&!i){if(a=u||f?{}:pi(t),!l)return u?function(t,e){return Io(t,hi(t),e)}(t,function(t,e){return t&&Io(e,Oa(e),t)}(a,t)):function(t,e){return Io(t,ci(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 O:return Ao(t);case y:case b:return new o(+t);case L:return function(t,e){var n=e?Ao(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}(t,n);case R:case P:case B:case D:case F:case k:case H:case U:case $:return xo(t,n);case A:return new o;case x:case I:return new o(t);case E:return function(t){var e=new t.constructor(t.source,dt.exec(t));return e.lastIndex=t.lastIndex,e}(t);case _:return new o;case N:return r=t,Dn?St(Dn.call(r)):{}}}(t,d,l)}}s||(s=new Wn);var p=s.get(t);if(p)return p;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:(c?u?ni:ei:u?Oa:Ma)(t);return Te(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=St(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 _t(i);return Ii((function(){t.apply(o,n)}),e)}function ur(t,e,n,r){var o=-1,i=Ne,s=!0,a=t.length,l=[],u=e.length;if(!a)return l;n&&(e=Oe(e,Ke(n))),r?(i=Me,s=!1):e.length>=200&&(i=Qe,s=!1,e=new zn(e));t:for(;++o<a;){var c=t[o],h=null==n?c:n(c);if(c=r||0!==c?c:0,s&&h==h){for(var d=u;d--;)if(e[d]===h)continue t;l.push(c)}else i(e,h,r)||l.push(c)}return l}kn.templateSettings={escape:K,evaluate:J,interpolate:Q,variable:"",imports:{_:kn}},kn.prototype=Un.prototype,kn.prototype.constructor=kn,$n.prototype=Hn(Un.prototype),$n.prototype.constructor=$n,Vn.prototype=Hn(Un.prototype),Vn.prototype.constructor=Vn,qn.prototype.clear=function(){this.__data__=_n?_n(null):{},this.size=0},qn.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},qn.prototype.get=function(t){var e=this.__data__;if(_n){var n=e[t];return n===s?o:n}return Rt.call(e,t)?e[t]:o},qn.prototype.has=function(t){var e=this.__data__;return _n?e[t]!==o:Rt.call(e,t)},qn.prototype.set=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=_n&&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():Wt.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},Gn.prototype.clear=function(){this.size=0,this.__data__={hash:new qn,map:new(xn||jn),string:new qn}},Gn.prototype.delete=function(t){var e=ai(this,t).delete(t);return this.size-=e?1:0,e},Gn.prototype.get=function(t){return ai(this,t).get(t)},Gn.prototype.has=function(t){return ai(this,t).has(t)},Gn.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},zn.prototype.add=zn.prototype.push=function(t){return this.__data__.set(t,s),this},zn.prototype.has=function(t){return this.__data__.has(t)},Wn.prototype.clear=function(){this.__data__=new jn,this.size=0},Wn.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},Wn.prototype.get=function(t){return this.__data__.get(t)},Wn.prototype.has=function(t){return this.__data__.has(t)},Wn.prototype.set=function(t,e){var n=this.__data__;if(n instanceof jn){var r=n.__data__;if(!xn||r.length<199)return r.push([t,e]),this.size=++n.size,this;n=this.__data__=new Gn(r)}return n.set(t,e),this.size=n.size,this};var cr=Oo(br),hr=Oo(vr,!0);function dr(t,e){var n=!0;return cr(t,(function(t,r,o){return n=!!e(t,r,o)})),n}function fr(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,u=s}return u}function pr(t,e){var n=[];return cr(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,Ma)}function vr(t,e){return t&&yr(t,e,Ma)}function wr(t,e){return Ie(e,(function(e){return Js(t[e])}))}function Cr(t,e){for(var n=0,r=(e=yo(e,t)).length;null!=t&&n<r;)t=t[Di(e[n++])];return n&&n==r?t:o}function Ar(t,e,n){var r=e(t);return qs(t)?r:Le(r,n(t))}function xr(t){return null==t?t===o?"[object Undefined]":"[object Null]":Xt&&Xt in St(t)?function(t){var e=Rt.call(t,Xt),n=t[Xt];try{t[Xt]=o;var r=!0}catch(t){}var i=Dt.call(t);return r&&(e?t[Xt]=n:delete t[Xt]),i}(t):function(t){return Dt.call(t)}(t)}function Sr(t,e){return t>e}function Tr(t,e){return null!=t&&Rt.call(t,e)}function Er(t,e){return null!=t&&e in St(t)}function _r(t,e,n){for(var i=n?Me:Ne,s=t[0].length,a=t.length,l=a,u=r(a),c=1/0,h=[];l--;){var d=t[l];l&&e&&(d=Oe(d,Ke(e))),c=yn(d.length,c),u[l]=!n&&(e||s>=120&&d.length>=120)?new zn(l&&d):o}d=t[0];var f=-1,p=u[0];t:for(;++f<s&&h.length<c;){var m=d[f],g=e?e(m):m;if(m=n||0!==m?m:0,!(p?Qe(p,g):i(h,g,n))){for(l=a;--l;){var y=u[l];if(!(y?Qe(y,g):i(t[l],g,n)))continue t}p&&p.push(g),h.push(m)}}return h}function Ir(t,e,n){var r=null==(t=Ti(t,e=yo(e,t)))?t:t[Di(Ki(e))];return null==r?o:xe(r,t,n)}function Nr(t){return ta(t)&&xr(t)==m}function Mr(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=qs(t),l=qs(e),u=a?g:di(t),c=l?g:di(e),h=(u=u==m?S:u)==S,d=(c=c==m?S:c)==S,f=u==c;if(f&&Ws(t)){if(!Ws(e))return!1;a=!0,h=!1}if(f&&!h)return s||(s=new Wn),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 O:return!(t.byteLength!=e.byteLength||!i(new Vt(t),new Vt(e)));case y:case b:case x:return Hs(+t,+e);case v:return t.name==e.name&&t.message==e.message;case E:case I:return t==e+"";case A:var a=on;case _:var l=1&r;if(a||(a=ln),t.size!=e.size&&!l)return!1;var u=s.get(t);if(u)return u==e;r|=2,s.set(t,e);var c=Zo(a(t),a(e),r,o,i,s);return s.delete(t),c;case N:if(Dn)return Dn.call(t)==Dn.call(e)}return!1}(t,e,u,n,r,i,s);if(!(1&n)){var p=h&&Rt.call(t,"__wrapped__"),w=d&&Rt.call(e,"__wrapped__");if(p||w){var C=p?t.value():t,T=w?e.value():e;return s||(s=new Wn),i(C,T,n,r,s)}}return!!f&&(s||(s=new Wn),function(t,e,n,r,i,s){var a=1&n,l=ei(t),u=l.length;if(u!=ei(e).length&&!a)return!1;for(var c=u;c--;){var h=l[c];if(!(a?h in e:Rt.call(e,h)))return!1}var d=s.get(t),f=s.get(e);if(d&&f)return d==e&&f==t;var p=!0;s.set(t,e),s.set(e,t);for(var m=a;++c<u;){var g=t[h=l[c]],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)){p=!1;break}m||(m="constructor"==h)}if(p&&!m){var v=t.constructor,w=e.constructor;v==w||!("constructor"in t)||!("constructor"in e)||"function"==typeof v&&v instanceof v&&"function"==typeof w&&w instanceof w||(p=!1)}return s.delete(t),s.delete(e),p}(t,e,n,r,i,s))}(t,e,n,r,Mr,i))}function Or(t,e,n,r){var i=n.length,s=i,a=!r;if(null==t)return!s;for(t=St(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 u=(l=n[i])[0],c=t[u],h=l[1];if(a&&l[2]){if(c===o&&!(u in t))return!1}else{var d=new Wn;if(r)var f=r(c,h,u,t,e,d);if(!(f===o?Mr(h,c,3,r,d):f))return!1}}return!0}function Lr(t){return!(!Zs(t)||(e=t,Bt&&Bt in e))&&(Js(t)?Ht:mt).test(Fi(t));var e}function Rr(t){return"function"==typeof t?t:null==t?nl:"object"==typeof t?qs(t)?kr(t[0],t[1]):Fr(t):hl(t)}function Pr(t){if(!Ci(t))return mn(t);var e=[];for(var n in St(t))Rt.call(t,n)&&"constructor"!=n&&e.push(n);return e}function Br(t,e){return t<e}function Dr(t,e){var n=-1,o=Gs(t)?r(t.length):[];return cr(t,(function(t,r,i){o[++n]=e(t,r,i)})),o}function Fr(t){var e=li(t);return 1==e.length&&e[0][2]?xi(e[0][0],e[0][1]):function(n){return n===t||Or(n,t,e)}}function kr(t,e){return bi(t)&&Ai(e)?xi(Di(t),e):function(n){var r=Ta(n,t);return r===o&&r===e?Ea(n,t):Mr(e,r,3)}}function Hr(t,e,n,r,i){t!==e&&gr(e,(function(s,a){if(i||(i=new Wn),Zs(s))!function(t,e,n,r,i,s,a){var l=Ei(t,n),u=Ei(e,n),c=a.get(u);if(c)Xn(t,n,c);else{var h=s?s(l,u,n+"",t,e,a):o,d=h===o;if(d){var f=qs(u),p=!f&&Ws(u),m=!f&&!p&&la(u);h=u,f||p||m?qs(l)?h=l:zs(l)?h=_o(l):p?(d=!1,h=Co(u,!0)):m?(d=!1,h=xo(u,!0)):h=[]:ra(u)||Vs(u)?(h=l,Vs(l)?h=ga(l):Zs(l)&&!Js(l)||(h=pi(u))):d=!1}d&&(a.set(u,h),i(h,u,r,s,a),a.delete(u)),Xn(t,n,h)}}(t,e,a,n,Hr,r,i);else{var l=r?r(Ei(t,a),s,a+"",t,e,i):o;l===o&&(l=s),Xn(t,a,l)}}),Oa)}function Ur(t,e){var n=t.length;if(n)return gi(e+=e<0?n:0,n)?t[e]:o}function $r(t,e,n){e=e.length?Oe(e,(function(t){return qs(t)?function(e){return Cr(e,1===t.length?t[0]:t)}:t})):[nl];var r=-1;e=Oe(e,Ke(si()));var o=Dr(t,(function(t,n,o){var i=Oe(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=So(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=Cr(t,s);n(a,s)&&Jr(i,yo(s,t),a)}return i}function qr(t,e,n,r){var o=r?Ue:He,i=-1,s=e.length,a=t;for(t===e&&(e=_o(e)),n&&(a=Oe(t,Ke(n)));++i<s;)for(var l=0,u=e[i],c=n?n(u):u;(l=o(a,c,l,r))>-1;)a!==t&&Wt.call(a,l,1),Wt.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)?Wt.call(t,o,1):lo(t,o)}}return t}function Gr(t,e){return t+fe(wn()*(e-t+1))}function zr(t,e){var n="";if(!t||e<1||e>h)return n;do{e%2&&(n+=t),(e=fe(e/2))&&(t+=t)}while(e);return n}function Wr(t,e){return Ni(Si(t,e,nl),t+"")}function Yr(t){return Kn(Ha(t))}function Kr(t,e){var n=Ha(t);return Li(n,ir(e,0,n.length))}function Jr(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 u=Di(e[i]),c=n;if("__proto__"===u||"constructor"===u||"prototype"===u)return t;if(i!=a){var h=l[u];(c=r?r(h,u,l):o)===o&&(c=Zs(h)?h:gi(e[i+1])?[]:{})}Zn(l,u,c),l=l[u]}return t}var Qr=In?function(t,e){return In.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(Ha(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 cr(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,u=aa(e),c=e===o;i<s;){var h=fe((i+s)/2),d=n(t[h]),f=d!==o,p=null===d,m=d==d,g=aa(d);if(a)var y=r||m;else y=c?m&&(r||f):l?m&&f&&(r||!p):u?m&&f&&!p&&(r||!g):!p&&!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||!Hs(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(qs(t))return Oe(t,so)+"";if(aa(t))return Fn?Fn.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function ao(t,e,n){var r=-1,o=Ne,i=t.length,s=!0,a=[],l=a;if(n)s=!1,o=Me;else if(i>=200){var u=e?null:Wo(t);if(u)return ln(u);s=!1,o=Qe,l=new zn}else l=e?[]:a;t:for(;++r<i;){var c=t[r],h=e?e(c):c;if(c=n||0!==c?c:0,s&&h==h){for(var d=l.length;d--;)if(l[d]===h)continue t;e&&l.push(h),a.push(c)}else o(l,h,n)||(l!==a&&l.push(h),a.push(c))}return a}function lo(t,e){return null==(t=Ti(t,e=yo(e,t)))||delete t[Di(Ki(e))]}function uo(t,e,n,r){return Jr(t,e,n(Cr(t,e)),r)}function co(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()),Re(e,(function(t,e){return e.func.apply(e.thisArg,Le([t],e.args))}),n)}function fo(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]=ur(s[i]||a,t[l],e,n));return ao(mr(s,1),e,n)}function po(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 zs(t)?t:[]}function go(t){return"function"==typeof t?t:nl}function yo(t,e){return qs(t)?t:bi(t,e)?[t]:Bi(ya(t))}var bo=Wr;function vo(t,e,n){var r=t.length;return n=n===o?r:n,!e&&n>=r?t:to(t,e,n)}var wo=se||function(t){return he.clearTimeout(t)};function Co(t,e){if(e)return t.slice();var n=t.length,r=qt?qt(n):new t.constructor(n);return t.copy(r),r}function Ao(t){var e=new t.constructor(t.byteLength);return new Vt(e).set(new Vt(t)),e}function xo(t,e){var n=e?Ao(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}function So(t,e){if(t!==e){var n=t!==o,r=null===t,i=t==t,s=aa(t),a=e!==o,l=null===e,u=e==e,c=aa(e);if(!l&&!c&&!s&&t>e||s&&a&&u&&!l&&!c||r&&a&&u||!n&&u||!i)return 1;if(!r&&!s&&!c&&t<e||c&&n&&i&&!r&&!s||l&&n&&i||!a&&i||!u)return-1}return 0}function To(t,e,n,o){for(var i=-1,s=t.length,a=n.length,l=-1,u=e.length,c=gn(s-a,0),h=r(u+c),d=!o;++l<u;)h[l]=e[l];for(;++i<a;)(d||i<s)&&(h[n[i]]=t[i]);for(;c--;)h[l++]=t[i++];return h}function Eo(t,e,n,o){for(var i=-1,s=t.length,a=-1,l=n.length,u=-1,c=e.length,h=gn(s-l,0),d=r(h+c),f=!o;++i<h;)d[i]=t[i];for(var p=i;++u<c;)d[p+u]=e[u];for(;++a<l;)(f||i<s)&&(d[p+n[a]]=t[i++]);return d}function _o(t,e){var n=-1,o=t.length;for(e||(e=r(o));++n<o;)e[n]=t[n];return e}function Io(t,e,n,r){var i=!n;n||(n={});for(var s=-1,a=e.length;++s<a;){var l=e[s],u=r?r(n[l],t[l],l,n,t):o;u===o&&(u=t[l]),i?rr(n,l,u):Zn(n,l,u)}return n}function No(t,e){return function(n,r){var o=qs(n)?Se:er,i=e?e():{};return o(n,t,si(r,2),i)}}function Mo(t){return Wr((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=St(e);++r<i;){var l=n[r];l&&t(e,l,r,s)}return e}))}function Oo(t,e){return function(n,r){if(null==n)return n;if(!Gs(n))return t(n,r);for(var o=n.length,i=e?o:-1,s=St(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=St(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 Ro(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 Po(t){return function(e){return Re(Ja(Va(e).replace(Jt,"")),t,"")}}function Bo(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=Hn(t.prototype),r=t.apply(n,e);return Zs(r)?r:n}}function Do(t){return function(e,n,r){var i=St(e);if(!Gs(e)){var s=si(n,3);e=Ma(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 Fo(t){return ti((function(e){var n=e.length,r=n,s=$n.prototype.thru;for(t&&e.reverse();r--;){var a=e[r];if("function"!=typeof a)throw new _t(i);if(s&&!l&&"wrapper"==oi(a))var l=new $n([],!0)}for(r=l?r:n;++r<n;){var u=oi(a=e[r]),c="wrapper"==u?ri(a):o;l=c&&vi(c[0])&&424==c[1]&&!c[4].length&&1==c[9]?l[oi(c[0])].apply(l,c[3]):1==a.length&&vi(a)?l[u]():l.thru(a)}return function(){var t=arguments,r=t[0];if(l&&1==t.length&&qs(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 ko(t,e,n,i,s,a,l,c,h,d){var f=e&u,p=1&e,m=2&e,g=24&e,y=512&e,b=m?o:Bo(t);return function u(){for(var v=arguments.length,w=r(v),C=v;C--;)w[C]=arguments[C];if(g)var A=ii(u),x=function(t,e){for(var n=t.length,r=0;n--;)t[n]===e&&++r;return r}(w,A);if(i&&(w=To(w,i,s,g)),a&&(w=Eo(w,a,l,g)),v-=x,g&&v<d){var S=an(w,A);return Go(t,e,ko,u.placeholder,n,w,S,c,h,d-v)}var T=p?n:this,E=m?T[t]:t;return v=w.length,c?w=function(t,e){for(var n=t.length,r=yn(e.length,n),i=_o(t);r--;){var s=e[r];t[r]=gi(s,n)?i[s]:o}return t}(w,c):y&&v>1&&w.reverse(),f&&h<v&&(w.length=h),this&&this!==he&&this instanceof u&&(E=b||Bo(E)),E.apply(T,w)}}function Ho(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 Uo(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 $o(t){return ti((function(e){return e=Oe(e,Ke(si())),Wr((function(n){var r=this;return t(e,(function(t){return xe(t,r,n)}))}))}))}function Vo(t,e){var n=(e=e===o?" ":so(e)).length;if(n<2)return n?zr(e,t):e;var r=zr(e,de(t/cn(e)));return rn(e)?vo(hn(r),0,t).join(""):r.slice(0,t)}function qo(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 Go(t,e,n,r,i,s,a,u,c,h){var d=8&e;e|=d?l:64,4&(e&=~(d?64:l))||(e&=-4);var f=[t,e,i,d?s:o,d?a:o,d?o:s,d?o:a,u,c,h],p=n.apply(o,f);return vi(t)&&_i(p,f),p.placeholder=r,Mi(p,t,e)}function zo(t){var e=xt[t];return function(t,n){if(t=ma(t),(n=null==n?0:yn(fa(n),292))&&De(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 Wo=Tn&&1/ln(new Tn([,-0]))[1]==c?function(t){return new Tn(t)}:al;function Yo(t){return function(e){var n=di(e);return n==A?on(e):n==_?un(e):function(t,e){return Oe(e,(function(e){return[e,t[e]]}))}(e,t(e))}}function Ko(t,e,n,s,c,h,d,f){var p=2&e;if(!p&&"function"!=typeof t)throw new _t(i);var m=s?s.length:0;if(m||(e&=-97,s=c=o),d=d===o?d:gn(fa(d),0),f=f===o?f:fa(f),m-=c?c.length:0,64&e){var g=s,y=c;s=c=o}var b=p?o:ri(t),v=[t,e,n,s,c,g,y,h,d,f];if(b&&function(t,e){var n=t[1],r=e[1],o=n|r,i=o<131,s=r==u&&8==n||r==u&&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 c=t[3];t[3]=c?To(c,l,e[4]):l,t[4]=c?an(t[3],a):e[4]}(l=e[5])&&(c=t[5],t[5]=c?Eo(c,l,e[6]):l,t[6]=c?an(t[5],a):e[6]),(l=e[7])&&(t[7]=l),r&u&&(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],c=v[4],!(f=v[9]=v[9]===o?p?0:t.length:gn(v[9]-m,0))&&24&e&&(e&=-25),e&&1!=e)w=8==e||16==e?function(t,e,n){var i=Bo(t);return function s(){for(var a=arguments.length,l=r(a),u=a,c=ii(s);u--;)l[u]=arguments[u];var h=a<3&&l[0]!==c&&l[a-1]!==c?[]:an(l,c);return(a-=h.length)<n?Go(t,e,ko,s.placeholder,o,l,h,o,o,n-a):xe(this&&this!==he&&this instanceof s?i:t,this,l)}}(t,e,f):e!=l&&33!=e||c.length?ko.apply(o,v):function(t,e,n,o){var i=1&e,s=Bo(t);return function e(){for(var a=-1,l=arguments.length,u=-1,c=o.length,h=r(c+l),d=this&&this!==he&&this instanceof e?s:t;++u<c;)h[u]=o[u];for(;l--;)h[u++]=arguments[++a];return xe(d,i?n:this,h)}}(t,e,n,s);else var w=function(t,e,n){var r=1&e,o=Bo(t);return function e(){return(this&&this!==he&&this instanceof e?o:t).apply(r?n:this,arguments)}}(t,e,n);return Mi((b?Qr:_i)(w,v),t,e)}function Jo(t,e,n,r){return t===o||Hs(t,Mt[n])&&!Rt.call(r,n)?e:t}function Qo(t,e,n,r,i,s){return Zs(t)&&Zs(e)&&(s.set(e,t),Hr(t,e,o,Qo,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,u=e.length;if(l!=u&&!(a&&u>l))return!1;var c=s.get(t),h=s.get(e);if(c&&h)return c==e&&h==t;var d=-1,f=!0,p=2&n?new zn: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;f=!1;break}if(p){if(!Be(e,(function(t,e){if(!Qe(p,e)&&(m===t||i(m,t,n,r,s)))return p.push(e)}))){f=!1;break}}else if(m!==g&&!i(m,g,n,r,s)){f=!1;break}}return s.delete(t),s.delete(e),f}function ti(t){return Ni(Si(t,o,ji),t+"")}function ei(t){return Ar(t,Ma,ci)}function ni(t){return Ar(t,Oa,hi)}var ri=In?function(t){return In.get(t)}:al;function oi(t){for(var e=t.name+"",n=Nn[e],r=Rt.call(Nn,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(Rt.call(kn,"placeholder")?kn:t).placeholder}function si(){var t=kn.iteratee||rl;return t=t===rl?Rr: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=Ma(t),n=e.length;n--;){var r=e[n],o=t[r];e[n]=[r,o,Ai(o)]}return e}function ui(t,e){var n=function(t,e){return null==t?o:t[e]}(t,e);return Lr(n)?n:o}var ci=me?function(t){return null==t?[]:(t=St(t),Ie(me(t),(function(e){return zt.call(t,e)})))}:pl,hi=me?function(t){for(var e=[];t;)Le(e,ci(t)),t=jt(t);return e}:pl,di=xr;function fi(t,e,n){for(var r=-1,o=(e=yo(e,t)).length,i=!1;++r<o;){var s=Di(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)&&(qs(t)||Vs(t))}function pi(t){return"function"!=typeof t.constructor||Ci(t)?{}:Hn(jt(t))}function mi(t){return qs(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?Gs(n)&&gi(e,n.length):"string"==r&&e in n)&&Hs(n[e],t)}function bi(t,e){if(qs(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 St(e)}function vi(t){var e=oi(t),n=kn[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]}(An&&di(new An(new ArrayBuffer(1)))!=L||xn&&di(new xn)!=A||Sn&&di(Sn.resolve())!=T||Tn&&di(new Tn)!=_||En&&di(new En)!=M)&&(di=function(t){var e=xr(t),n=e==S?t.constructor:o,r=n?Fi(n):"";if(r)switch(r){case Mn:return L;case On:return A;case Ln:return T;case Rn:return _;case Pn:return M}return e});var wi=Ot?Js:ml;function Ci(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Mt)}function Ai(t){return t==t&&!Zs(t)}function xi(t,e){return function(n){return null!=n&&n[t]===e&&(e!==o||t in St(n))}}function Si(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),xe(t,this,l)}}function Ti(t,e){return e.length<2?t:Cr(t,to(e,0,-1))}function Ei(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var _i=Oi(Qr),Ii=ce||function(t,e){return he.setTimeout(t,e)},Ni=Oi(Xr);function Mi(t,e,n){var r=e+"";return Ni(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 Te(p,(function(n){var r="_."+n[0];e&n[1]&&!Ne(t,r)&&t.push(r)})),t.sort()}(function(t){var e=t.match(st);return e?e[1].split(at):[]}(r),n)))}function Oi(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=Gr(n,i),a=t[s];t[s]=t[n],t[n]=a}return t.length=e,t}var Ri,Pi,Bi=(Ri=Rs((function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(tt,(function(t,n,r,o){e.push(r?o.replace(ct,"$1"):n||t)})),e}),(function(t){return 500===Pi.size&&Pi.clear(),t})),Pi=Ri.cache,Ri);function Di(t){if("string"==typeof t||aa(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function Fi(t){if(null!=t){try{return Lt.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function ki(t){if(t instanceof Vn)return t.clone();var e=new $n(t.__wrapped__,t.__chain__);return e.__actions__=_o(t.__actions__),e.__index__=t.__index__,e.__values__=t.__values__,e}var Hi=Wr((function(t,e){return zs(t)?ur(t,mr(e,1,zs,!0)):[]})),Ui=Wr((function(t,e){var n=Ki(e);return zs(n)&&(n=o),zs(t)?ur(t,mr(e,1,zs,!0),si(n,2)):[]})),$i=Wr((function(t,e){var n=Ki(e);return zs(n)&&(n=o),zs(t)?ur(t,mr(e,1,zs,!0),o,n):[]}));function Vi(t,e,n){var r=null==t?0:t.length;if(!r)return-1;var o=null==n?0:fa(n);return o<0&&(o=gn(r+o,0)),ke(t,si(e,3),o)}function qi(t,e,n){var r=null==t?0:t.length;if(!r)return-1;var i=r-1;return n!==o&&(i=fa(n),i=n<0?gn(r+i,0):yn(i,r-1)),ke(t,si(e,3),i,!0)}function ji(t){return null!=t&&t.length?mr(t,1):[]}function Gi(t){return t&&t.length?t[0]:o}var zi=Wr((function(t){var e=Oe(t,mo);return e.length&&e[0]===t[0]?_r(e):[]})),Wi=Wr((function(t){var e=Ki(t),n=Oe(t,mo);return e===Ki(n)?e=o:n.pop(),n.length&&n[0]===t[0]?_r(n,si(e,2)):[]})),Yi=Wr((function(t){var e=Ki(t),n=Oe(t,mo);return(e="function"==typeof e?e:o)&&n.pop(),n.length&&n[0]===t[0]?_r(n,o,e):[]}));function Ki(t){var e=null==t?0:t.length;return e?t[e-1]:o}var Ji=Wr(Qi);function Qi(t,e){return t&&t.length&&e&&e.length?qr(t,e):t}var Xi=ti((function(t,e){var n=null==t?0:t.length,r=or(t,e);return jr(t,Oe(e,(function(t){return gi(t,n)?+t:t})).sort(So)),r}));function Zi(t){return null==t?t:Cn.call(t)}var ts=Wr((function(t){return ao(mr(t,1,zs,!0))})),es=Wr((function(t){var e=Ki(t);return zs(e)&&(e=o),ao(mr(t,1,zs,!0),si(e,2))})),ns=Wr((function(t){var e=Ki(t);return e="function"==typeof e?e:o,ao(mr(t,1,zs,!0),o,e)}));function rs(t){if(!t||!t.length)return[];var e=0;return t=Ie(t,(function(t){if(zs(t))return e=gn(t.length,e),!0})),We(e,(function(e){return Oe(t,qe(e))}))}function os(t,e){if(!t||!t.length)return[];var n=rs(t);return null==e?n:Oe(n,(function(t){return xe(e,o,t)}))}var is=Wr((function(t,e){return zs(t)?ur(t,e):[]})),ss=Wr((function(t){return fo(Ie(t,zs))})),as=Wr((function(t){var e=Ki(t);return zs(e)&&(e=o),fo(Ie(t,zs),si(e,2))})),ls=Wr((function(t){var e=Ki(t);return e="function"==typeof e?e:o,fo(Ie(t,zs),o,e)})),us=Wr(rs),cs=Wr((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=kn(t);return e.__chain__=!0,e}function ds(t,e){return e(t)}var fs=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 $n(r,this.__chain__).thru((function(t){return e&&!t.length&&t.push(o),t}))):this.thru(i)})),ps=No((function(t,e,n){Rt.call(t,n)?++t[n]:rr(t,n,1)})),ms=Do(Vi),gs=Do(qi);function ys(t,e){return(qs(t)?Te:cr)(t,si(e,3))}function bs(t,e){return(qs(t)?Ee:hr)(t,si(e,3))}var vs=No((function(t,e,n){Rt.call(t,n)?t[n].push(e):rr(t,n,[e])})),ws=Wr((function(t,e,n){var o=-1,i="function"==typeof e,s=Gs(t)?r(t.length):[];return cr(t,(function(t){s[++o]=i?xe(e,t,n):Ir(t,e,n)})),s})),Cs=No((function(t,e,n){rr(t,n,e)}));function As(t,e){return(qs(t)?Oe:Dr)(t,si(e,3))}var xs=No((function(t,e,n){t[n?0:1].push(e)}),(function(){return[[],[]]})),Ss=Wr((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]]),$r(t,mr(e,1),[])})),Ts=ue||function(){return he.Date.now()};function Es(t,e,n){return e=n?o:e,e=t&&null==e?t.length:e,Ko(t,u,o,o,o,o,e)}function _s(t,e){var n;if("function"!=typeof e)throw new _t(i);return t=fa(t),function(){return--t>0&&(n=e.apply(this,arguments)),t<=1&&(e=o),n}}var Is=Wr((function(t,e,n){var r=1;if(n.length){var o=an(n,ii(Is));r|=l}return Ko(t,r,e,n,o)})),Ns=Wr((function(t,e,n){var r=3;if(n.length){var o=an(n,ii(Ns));r|=l}return Ko(e,r,t,n,o)}));function Ms(t,e,n){var r,s,a,l,u,c,h=0,d=!1,f=!1,p=!0;if("function"!=typeof t)throw new _t(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-c;return c===o||n>=e||n<0||f&&t-h>=a}function y(){var t=Ts();if(g(t))return b(t);u=Ii(y,function(t){var n=e-(t-c);return f?yn(n,a-(t-h)):n}(t))}function b(t){return u=o,p&&r?m(t):(r=s=o,l)}function v(){var t=Ts(),n=g(t);if(r=arguments,s=this,c=t,n){if(u===o)return function(t){return h=t,u=Ii(y,e),d?m(t):l}(c);if(f)return wo(u),u=Ii(y,e),m(c)}return u===o&&(u=Ii(y,e)),l}return e=ma(e)||0,Zs(n)&&(d=!!n.leading,a=(f="maxWait"in n)?gn(ma(n.maxWait)||0,e):a,p="trailing"in n?!!n.trailing:p),v.cancel=function(){u!==o&&wo(u),h=0,r=c=s=u=o},v.flush=function(){return u===o?l:b(Ts())},v}var Os=Wr((function(t,e){return lr(t,1,e)})),Ls=Wr((function(t,e,n){return lr(t,ma(e)||0,n)}));function Rs(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new _t(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(Rs.Cache||Gn),n}function Ps(t){if("function"!=typeof t)throw new _t(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)}}Rs.Cache=Gn;var Bs=bo((function(t,e){var n=(e=1==e.length&&qs(e[0])?Oe(e[0],Ke(si())):Oe(mr(e,1),Ke(si()))).length;return Wr((function(r){for(var o=-1,i=yn(r.length,n);++o<i;)r[o]=e[o].call(this,r[o]);return xe(t,this,r)}))})),Ds=Wr((function(t,e){var n=an(e,ii(Ds));return Ko(t,l,o,e,n)})),Fs=Wr((function(t,e){var n=an(e,ii(Fs));return Ko(t,64,o,e,n)})),ks=ti((function(t,e){return Ko(t,256,o,o,o,e)}));function Hs(t,e){return t===e||t!=t&&e!=e}var Us=jo(Sr),$s=jo((function(t,e){return t>=e})),Vs=Nr(function(){return arguments}())?Nr:function(t){return ta(t)&&Rt.call(t,"callee")&&!zt.call(t,"callee")},qs=r.isArray,js=ye?Ke(ye):function(t){return ta(t)&&xr(t)==O};function Gs(t){return null!=t&&Xs(t.length)&&!Js(t)}function zs(t){return ta(t)&&Gs(t)}var Ws=ge||ml,Ys=be?Ke(be):function(t){return ta(t)&&xr(t)==b};function Ks(t){if(!ta(t))return!1;var e=xr(t);return e==v||"[object DOMException]"==e||"string"==typeof t.message&&"string"==typeof t.name&&!ra(t)}function Js(t){if(!Zs(t))return!1;var e=xr(t);return e==w||e==C||"[object AsyncFunction]"==e||"[object Proxy]"==e}function Qs(t){return"number"==typeof t&&t==fa(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)==A};function na(t){return"number"==typeof t||ta(t)&&xr(t)==x}function ra(t){if(!ta(t)||xr(t)!=S)return!1;var e=jt(t);if(null===e)return!0;var n=Rt.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&Lt.call(n)==Ft}var oa=we?Ke(we):function(t){return ta(t)&&xr(t)==E},ia=Ce?Ke(Ce):function(t){return ta(t)&&di(t)==_};function sa(t){return"string"==typeof t||!qs(t)&&ta(t)&&xr(t)==I}function aa(t){return"symbol"==typeof t||ta(t)&&xr(t)==N}var la=Ae?Ke(Ae):function(t){return ta(t)&&Xs(t.length)&&!!oe[xr(t)]},ua=jo(Br),ca=jo((function(t,e){return t<=e}));function ha(t){if(!t)return[];if(Gs(t))return sa(t)?hn(t):_o(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==A?on:e==_?ln:Ha)(t)}function da(t){return t?(t=ma(t))===c||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}function fa(t){var e=da(t),n=e%1;return e==e?n?e-n:e:0}function pa(t){return t?ir(fa(t),0,f):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=pt.test(t);return n||gt.test(t)?le(t.slice(2),n?2:8):ft.test(t)?d:+t}function ga(t){return Io(t,Oa(t))}function ya(t){return null==t?"":so(t)}var ba=Mo((function(t,e){if(Ci(e)||Gs(e))Io(e,Ma(e),t);else for(var n in e)Rt.call(e,n)&&Zn(t,n,e[n])})),va=Mo((function(t,e){Io(e,Oa(e),t)})),wa=Mo((function(t,e,n,r){Io(e,Oa(e),t,r)})),Ca=Mo((function(t,e,n,r){Io(e,Ma(e),t,r)})),Aa=ti(or),xa=Wr((function(t,e){t=St(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=Oa(s),l=-1,u=a.length;++l<u;){var c=a[l],h=t[c];(h===o||Hs(h,Mt[c])&&!Rt.call(t,c))&&(t[c]=s[c])}return t})),Sa=Wr((function(t){return t.push(o,Qo),xe(Ra,o,t)}));function Ta(t,e,n){var r=null==t?o:Cr(t,e);return r===o?n:r}function Ea(t,e){return null!=t&&fi(t,e,Er)}var _a=Ho((function(t,e,n){null!=e&&"function"!=typeof e.toString&&(e=Dt.call(e)),t[e]=n}),Za(nl)),Ia=Ho((function(t,e,n){null!=e&&"function"!=typeof e.toString&&(e=Dt.call(e)),Rt.call(t,e)?t[e].push(n):t[e]=[n]}),si),Na=Wr(Ir);function Ma(t){return Gs(t)?Yn(t):Pr(t)}function Oa(t){return Gs(t)?Yn(t,!0):function(t){if(!Zs(t))return function(t){var e=[];if(null!=t)for(var n in St(t))e.push(n);return e}(t);var e=Ci(t),n=[];for(var r in t)("constructor"!=r||!e&&Rt.call(t,r))&&n.push(r);return n}(t)}var La=Mo((function(t,e,n){Hr(t,e,n)})),Ra=Mo((function(t,e,n,r){Hr(t,e,n,r)})),Pa=ti((function(t,e){var n={};if(null==t)return n;var r=!1;e=Oe(e,(function(e){return e=yo(e,t),r||(r=e.length>1),e})),Io(t,ni(t),n),r&&(n=sr(n,7,Xo));for(var o=e.length;o--;)lo(n,e[o]);return n})),Ba=ti((function(t,e){return null==t?{}:function(t,e){return Vr(t,e,(function(e,n){return Ea(t,n)}))}(t,e)}));function Da(t,e){if(null==t)return{};var n=Oe(ni(t),(function(t){return[t]}));return e=si(e),Vr(t,n,(function(t,n){return e(t,n[0])}))}var Fa=Yo(Ma),ka=Yo(Oa);function Ha(t){return null==t?[]:Je(t,Ma(t))}var Ua=Po((function(t,e,n){return e=e.toLowerCase(),t+(n?$a(e):e)}));function $a(t){return Ka(ya(t).toLowerCase())}function Va(t){return(t=ya(t))&&t.replace(bt,tn).replace(Qt,"")}var qa=Po((function(t,e,n){return t+(n?"-":"")+e.toLowerCase()})),ja=Po((function(t,e,n){return t+(n?" ":"")+e.toLowerCase()})),Ga=Ro("toLowerCase"),za=Po((function(t,e,n){return t+(n?"_":"")+e.toLowerCase()})),Wa=Po((function(t,e,n){return t+(n?" ":"")+Ka(e)})),Ya=Po((function(t,e,n){return t+(n?" ":"")+e.toUpperCase()})),Ka=Ro("toUpperCase");function Ja(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 Qa=Wr((function(t,e){try{return xe(t,o,e)}catch(t){return Ks(t)?t:new Ct(t)}})),Xa=ti((function(t,e){return Te(e,(function(e){e=Di(e),rr(t,e,Is(t[e],t))})),t}));function Za(t){return function(){return t}}var tl=Fo(),el=Fo(!0);function nl(t){return t}function rl(t){return Rr("function"==typeof t?t:sr(t,1))}var ol=Wr((function(t,e){return function(n){return Ir(n,t,e)}})),il=Wr((function(t,e){return function(n){return Ir(t,n,e)}}));function sl(t,e,n){var r=Ma(e),o=wr(e,r);null!=n||Zs(e)&&(o.length||!r.length)||(n=e,e=t,t=this,o=wr(e,Ma(e)));var i=!(Zs(n)&&"chain"in n&&!n.chain),s=Js(t);return Te(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__=_o(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=$o(Oe),ul=$o(_e),cl=$o(Be);function hl(t){return bi(t)?qe(Di(t)):function(t){return function(e){return Cr(e,t)}}(t)}var dl=qo(),fl=qo(!0);function pl(){return[]}function ml(){return!1}var gl,yl=Uo((function(t,e){return t+e}),0),bl=zo("ceil"),vl=Uo((function(t,e){return t/e}),1),wl=zo("floor"),Cl=Uo((function(t,e){return t*e}),1),Al=zo("round"),xl=Uo((function(t,e){return t-e}),0);return kn.after=function(t,e){if("function"!=typeof e)throw new _t(i);return t=fa(t),function(){if(--t<1)return e.apply(this,arguments)}},kn.ary=Es,kn.assign=ba,kn.assignIn=va,kn.assignInWith=wa,kn.assignWith=Ca,kn.at=Aa,kn.before=_s,kn.bind=Is,kn.bindAll=Xa,kn.bindKey=Ns,kn.castArray=function(){if(!arguments.length)return[];var t=arguments[0];return qs(t)?t:[t]},kn.chain=hs,kn.chunk=function(t,e,n){e=(n?yi(t,e,n):e===o)?1:gn(fa(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},kn.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},kn.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(qs(n)?_o(n):[n],mr(e,1))},kn.cond=function(t){var e=null==t?0:t.length,n=si();return t=e?Oe(t,(function(t){if("function"!=typeof t[1])throw new _t(i);return[n(t[0]),t[1]]})):[],Wr((function(n){for(var r=-1;++r<e;){var o=t[r];if(xe(o[0],this,n))return xe(o[1],this,n)}}))},kn.conforms=function(t){return function(t){var e=Ma(t);return function(n){return ar(n,t,e)}}(sr(t,1))},kn.constant=Za,kn.countBy=ps,kn.create=function(t,e){var n=Hn(t);return null==e?n:nr(n,e)},kn.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},kn.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},kn.debounce=Ms,kn.defaults=xa,kn.defaultsDeep=Sa,kn.defer=Os,kn.delay=Ls,kn.difference=Hi,kn.differenceBy=Ui,kn.differenceWith=$i,kn.drop=function(t,e,n){var r=null==t?0:t.length;return r?to(t,(e=n||e===o?1:fa(e))<0?0:e,r):[]},kn.dropRight=function(t,e,n){var r=null==t?0:t.length;return r?to(t,0,(e=r-(e=n||e===o?1:fa(e)))<0?0:e):[]},kn.dropRightWhile=function(t,e){return t&&t.length?co(t,si(e,3),!0,!0):[]},kn.dropWhile=function(t,e){return t&&t.length?co(t,si(e,3),!0):[]},kn.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=fa(n))<0&&(n=-n>i?0:i+n),(r=r===o||r>i?i:fa(r))<0&&(r+=i),r=n>r?0:pa(r);n<r;)t[n++]=e;return t}(t,e,n,r)):[]},kn.filter=function(t,e){return(qs(t)?Ie:pr)(t,si(e,3))},kn.flatMap=function(t,e){return mr(As(t,e),1)},kn.flatMapDeep=function(t,e){return mr(As(t,e),c)},kn.flatMapDepth=function(t,e,n){return n=n===o?1:fa(n),mr(As(t,e),n)},kn.flatten=ji,kn.flattenDeep=function(t){return null!=t&&t.length?mr(t,c):[]},kn.flattenDepth=function(t,e){return null!=t&&t.length?mr(t,e=e===o?1:fa(e)):[]},kn.flip=function(t){return Ko(t,512)},kn.flow=tl,kn.flowRight=el,kn.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},kn.functions=function(t){return null==t?[]:wr(t,Ma(t))},kn.functionsIn=function(t){return null==t?[]:wr(t,Oa(t))},kn.groupBy=vs,kn.initial=function(t){return null!=t&&t.length?to(t,0,-1):[]},kn.intersection=zi,kn.intersectionBy=Wi,kn.intersectionWith=Yi,kn.invert=_a,kn.invertBy=Ia,kn.invokeMap=ws,kn.iteratee=rl,kn.keyBy=Cs,kn.keys=Ma,kn.keysIn=Oa,kn.map=As,kn.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},kn.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},kn.matches=function(t){return Fr(sr(t,1))},kn.matchesProperty=function(t,e){return kr(t,sr(e,1))},kn.memoize=Rs,kn.merge=La,kn.mergeWith=Ra,kn.method=ol,kn.methodOf=il,kn.mixin=sl,kn.negate=Ps,kn.nthArg=function(t){return t=fa(t),Wr((function(e){return Ur(e,t)}))},kn.omit=Pa,kn.omitBy=function(t,e){return Da(t,Ps(si(e)))},kn.once=function(t){return _s(2,t)},kn.orderBy=function(t,e,n,r){return null==t?[]:(qs(e)||(e=null==e?[]:[e]),qs(n=r?o:n)||(n=null==n?[]:[n]),$r(t,e,n))},kn.over=ll,kn.overArgs=Bs,kn.overEvery=ul,kn.overSome=cl,kn.partial=Ds,kn.partialRight=Fs,kn.partition=xs,kn.pick=Ba,kn.pickBy=Da,kn.property=hl,kn.propertyOf=function(t){return function(e){return null==t?o:Cr(t,e)}},kn.pull=Ji,kn.pullAll=Qi,kn.pullAllBy=function(t,e,n){return t&&t.length&&e&&e.length?qr(t,e,si(n,2)):t},kn.pullAllWith=function(t,e,n){return t&&t.length&&e&&e.length?qr(t,e,o,n):t},kn.pullAt=Xi,kn.range=dl,kn.rangeRight=fl,kn.rearg=ks,kn.reject=function(t,e){return(qs(t)?Ie:pr)(t,Ps(si(e,3)))},kn.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},kn.rest=function(t,e){if("function"!=typeof t)throw new _t(i);return Wr(t,e=e===o?e:fa(e))},kn.reverse=Zi,kn.sampleSize=function(t,e,n){return e=(n?yi(t,e,n):e===o)?1:fa(e),(qs(t)?Jn:Kr)(t,e)},kn.set=function(t,e,n){return null==t?t:Jr(t,e,n)},kn.setWith=function(t,e,n,r){return r="function"==typeof r?r:o,null==t?t:Jr(t,e,n,r)},kn.shuffle=function(t){return(qs(t)?Qn:Zr)(t)},kn.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:fa(e),n=n===o?r:fa(n)),to(t,e,n)):[]},kn.sortBy=Ss,kn.sortedUniq=function(t){return t&&t.length?oo(t):[]},kn.sortedUniqBy=function(t,e){return t&&t.length?oo(t,si(e,2)):[]},kn.split=function(t,e,n){return n&&"number"!=typeof n&&yi(t,e,n)&&(e=n=o),(n=n===o?f: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):[]},kn.spread=function(t,e){if("function"!=typeof t)throw new _t(i);return e=null==e?0:gn(fa(e),0),Wr((function(n){var r=n[e],o=vo(n,0,e);return r&&Le(o,r),xe(t,this,o)}))},kn.tail=function(t){var e=null==t?0:t.length;return e?to(t,1,e):[]},kn.take=function(t,e,n){return t&&t.length?to(t,0,(e=n||e===o?1:fa(e))<0?0:e):[]},kn.takeRight=function(t,e,n){var r=null==t?0:t.length;return r?to(t,(e=r-(e=n||e===o?1:fa(e)))<0?0:e,r):[]},kn.takeRightWhile=function(t,e){return t&&t.length?co(t,si(e,3),!1,!0):[]},kn.takeWhile=function(t,e){return t&&t.length?co(t,si(e,3)):[]},kn.tap=function(t,e){return e(t),t},kn.throttle=function(t,e,n){var r=!0,o=!0;if("function"!=typeof t)throw new _t(i);return Zs(n)&&(r="leading"in n?!!n.leading:r,o="trailing"in n?!!n.trailing:o),Ms(t,e,{leading:r,maxWait:e,trailing:o})},kn.thru=ds,kn.toArray=ha,kn.toPairs=Fa,kn.toPairsIn=ka,kn.toPath=function(t){return qs(t)?Oe(t,Di):aa(t)?[t]:_o(Bi(ya(t)))},kn.toPlainObject=ga,kn.transform=function(t,e,n){var r=qs(t),o=r||Ws(t)||la(t);if(e=si(e,4),null==n){var i=t&&t.constructor;n=o?r?new i:[]:Zs(t)&&Js(i)?Hn(jt(t)):{}}return(o?Te:br)(t,(function(t,r,o){return e(n,t,r,o)})),n},kn.unary=function(t){return Es(t,1)},kn.union=ts,kn.unionBy=es,kn.unionWith=ns,kn.uniq=function(t){return t&&t.length?ao(t):[]},kn.uniqBy=function(t,e){return t&&t.length?ao(t,si(e,2)):[]},kn.uniqWith=function(t,e){return e="function"==typeof e?e:o,t&&t.length?ao(t,o,e):[]},kn.unset=function(t,e){return null==t||lo(t,e)},kn.unzip=rs,kn.unzipWith=os,kn.update=function(t,e,n){return null==t?t:uo(t,e,go(n))},kn.updateWith=function(t,e,n,r){return r="function"==typeof r?r:o,null==t?t:uo(t,e,go(n),r)},kn.values=Ha,kn.valuesIn=function(t){return null==t?[]:Je(t,Oa(t))},kn.without=is,kn.words=Ja,kn.wrap=function(t,e){return Ds(go(e),t)},kn.xor=ss,kn.xorBy=as,kn.xorWith=ls,kn.zip=us,kn.zipObject=function(t,e){return po(t||[],e||[],Zn)},kn.zipObjectDeep=function(t,e){return po(t||[],e||[],Jr)},kn.zipWith=cs,kn.entries=Fa,kn.entriesIn=ka,kn.extend=va,kn.extendWith=wa,sl(kn,kn),kn.add=yl,kn.attempt=Qa,kn.camelCase=Ua,kn.capitalize=$a,kn.ceil=bl,kn.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)},kn.clone=function(t){return sr(t,4)},kn.cloneDeep=function(t){return sr(t,5)},kn.cloneDeepWith=function(t,e){return sr(t,5,e="function"==typeof e?e:o)},kn.cloneWith=function(t,e){return sr(t,4,e="function"==typeof e?e:o)},kn.conformsTo=function(t,e){return null==e||ar(t,e,Ma(e))},kn.deburr=Va,kn.defaultTo=function(t,e){return null==t||t!=t?e:t},kn.divide=vl,kn.endsWith=function(t,e,n){t=ya(t),e=so(e);var r=t.length,i=n=n===o?r:ir(fa(n),0,r);return(n-=e.length)>=0&&t.slice(n,i)==e},kn.eq=Hs,kn.escape=function(t){return(t=ya(t))&&Y.test(t)?t.replace(z,en):t},kn.escapeRegExp=function(t){return(t=ya(t))&&nt.test(t)?t.replace(et,"\\$&"):t},kn.every=function(t,e,n){var r=qs(t)?_e:dr;return n&&yi(t,e,n)&&(e=o),r(t,si(e,3))},kn.find=ms,kn.findIndex=Vi,kn.findKey=function(t,e){return Fe(t,si(e,3),br)},kn.findLast=gs,kn.findLastIndex=qi,kn.findLastKey=function(t,e){return Fe(t,si(e,3),vr)},kn.floor=wl,kn.forEach=ys,kn.forEachRight=bs,kn.forIn=function(t,e){return null==t?t:gr(t,si(e,3),Oa)},kn.forInRight=function(t,e){return null==t?t:yr(t,si(e,3),Oa)},kn.forOwn=function(t,e){return t&&br(t,si(e,3))},kn.forOwnRight=function(t,e){return t&&vr(t,si(e,3))},kn.get=Ta,kn.gt=Us,kn.gte=$s,kn.has=function(t,e){return null!=t&&fi(t,e,Tr)},kn.hasIn=Ea,kn.head=Gi,kn.identity=nl,kn.includes=function(t,e,n,r){t=Gs(t)?t:Ha(t),n=n&&!r?fa(n):0;var o=t.length;return n<0&&(n=gn(o+n,0)),sa(t)?n<=o&&t.indexOf(e,n)>-1:!!o&&He(t,e,n)>-1},kn.indexOf=function(t,e,n){var r=null==t?0:t.length;if(!r)return-1;var o=null==n?0:fa(n);return o<0&&(o=gn(r+o,0)),He(t,e,o)},kn.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)},kn.invoke=Na,kn.isArguments=Vs,kn.isArray=qs,kn.isArrayBuffer=js,kn.isArrayLike=Gs,kn.isArrayLikeObject=zs,kn.isBoolean=function(t){return!0===t||!1===t||ta(t)&&xr(t)==y},kn.isBuffer=Ws,kn.isDate=Ys,kn.isElement=function(t){return ta(t)&&1===t.nodeType&&!ra(t)},kn.isEmpty=function(t){if(null==t)return!0;if(Gs(t)&&(qs(t)||"string"==typeof t||"function"==typeof t.splice||Ws(t)||la(t)||Vs(t)))return!t.length;var e=di(t);if(e==A||e==_)return!t.size;if(Ci(t))return!Pr(t).length;for(var n in t)if(Rt.call(t,n))return!1;return!0},kn.isEqual=function(t,e){return Mr(t,e)},kn.isEqualWith=function(t,e,n){var r=(n="function"==typeof n?n:o)?n(t,e):o;return r===o?Mr(t,e,o,n):!!r},kn.isError=Ks,kn.isFinite=function(t){return"number"==typeof t&&De(t)},kn.isFunction=Js,kn.isInteger=Qs,kn.isLength=Xs,kn.isMap=ea,kn.isMatch=function(t,e){return t===e||Or(t,e,li(e))},kn.isMatchWith=function(t,e,n){return n="function"==typeof n?n:o,Or(t,e,li(e),n)},kn.isNaN=function(t){return na(t)&&t!=+t},kn.isNative=function(t){if(wi(t))throw new Ct("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");return Lr(t)},kn.isNil=function(t){return null==t},kn.isNull=function(t){return null===t},kn.isNumber=na,kn.isObject=Zs,kn.isObjectLike=ta,kn.isPlainObject=ra,kn.isRegExp=oa,kn.isSafeInteger=function(t){return Qs(t)&&t>=-9007199254740991&&t<=h},kn.isSet=ia,kn.isString=sa,kn.isSymbol=aa,kn.isTypedArray=la,kn.isUndefined=function(t){return t===o},kn.isWeakMap=function(t){return ta(t)&&di(t)==M},kn.isWeakSet=function(t){return ta(t)&&"[object WeakSet]"==xr(t)},kn.join=function(t,e){return null==t?"":je.call(t,e)},kn.kebabCase=qa,kn.last=Ki,kn.lastIndexOf=function(t,e,n){var r=null==t?0:t.length;if(!r)return-1;var i=r;return n!==o&&(i=(i=fa(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):ke(t,$e,i,!0)},kn.lowerCase=ja,kn.lowerFirst=Ga,kn.lt=ua,kn.lte=ca,kn.max=function(t){return t&&t.length?fr(t,nl,Sr):o},kn.maxBy=function(t,e){return t&&t.length?fr(t,si(e,2),Sr):o},kn.mean=function(t){return Ve(t,nl)},kn.meanBy=function(t,e){return Ve(t,si(e,2))},kn.min=function(t){return t&&t.length?fr(t,nl,Br):o},kn.minBy=function(t,e){return t&&t.length?fr(t,si(e,2),Br):o},kn.stubArray=pl,kn.stubFalse=ml,kn.stubObject=function(){return{}},kn.stubString=function(){return""},kn.stubTrue=function(){return!0},kn.multiply=Cl,kn.nth=function(t,e){return t&&t.length?Ur(t,fa(e)):o},kn.noConflict=function(){return he._===this&&(he._=kt),this},kn.noop=al,kn.now=Ts,kn.pad=function(t,e,n){t=ya(t);var r=(e=fa(e))?cn(t):0;if(!e||r>=e)return t;var o=(e-r)/2;return Vo(fe(o),n)+t+Vo(de(o),n)},kn.padEnd=function(t,e,n){t=ya(t);var r=(e=fa(e))?cn(t):0;return e&&r<e?t+Vo(e-r,n):t},kn.padStart=function(t,e,n){t=ya(t);var r=(e=fa(e))?cn(t):0;return e&&r<e?Vo(e-r,n)+t:t},kn.parseInt=function(t,e,n){return n||null==e?e=0:e&&(e=+e),vn(ya(t).replace(rt,""),e||0)},kn.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=wn();return yn(t+i*(e-t+ae("1e-"+((i+"").length-1))),e)}return Gr(t,e)},kn.reduce=function(t,e,n){var r=qs(t)?Re:Ge,o=arguments.length<3;return r(t,si(e,4),n,o,cr)},kn.reduceRight=function(t,e,n){var r=qs(t)?Pe:Ge,o=arguments.length<3;return r(t,si(e,4),n,o,hr)},kn.repeat=function(t,e,n){return e=(n?yi(t,e,n):e===o)?1:fa(e),zr(ya(t),e)},kn.replace=function(){var t=arguments,e=ya(t[0]);return t.length<3?e:e.replace(t[1],t[2])},kn.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[Di(e[r])];s===o&&(r=i,s=n),t=Js(s)?s.call(t):s}return t},kn.round=Al,kn.runInContext=t,kn.sample=function(t){return(qs(t)?Kn:Yr)(t)},kn.size=function(t){if(null==t)return 0;if(Gs(t))return sa(t)?cn(t):t.length;var e=di(t);return e==A||e==_?t.size:Pr(t).length},kn.snakeCase=za,kn.some=function(t,e,n){var r=qs(t)?Be:eo;return n&&yi(t,e,n)&&(e=o),r(t,si(e,3))},kn.sortedIndex=function(t,e){return no(t,e)},kn.sortedIndexBy=function(t,e,n){return ro(t,e,si(n,2))},kn.sortedIndexOf=function(t,e){var n=null==t?0:t.length;if(n){var r=no(t,e);if(r<n&&Hs(t[r],e))return r}return-1},kn.sortedLastIndex=function(t,e){return no(t,e,!0)},kn.sortedLastIndexBy=function(t,e,n){return ro(t,e,si(n,2),!0)},kn.sortedLastIndexOf=function(t,e){if(null!=t&&t.length){var n=no(t,e,!0)-1;if(Hs(t[n],e))return n}return-1},kn.startCase=Wa,kn.startsWith=function(t,e,n){return t=ya(t),n=null==n?0:ir(fa(n),0,t.length),e=so(e),t.slice(n,n+e.length)==e},kn.subtract=xl,kn.sum=function(t){return t&&t.length?ze(t,nl):0},kn.sumBy=function(t,e){return t&&t.length?ze(t,si(e,2)):0},kn.template=function(t,e,n){var r=kn.templateSettings;n&&yi(t,e,n)&&(e=o),t=ya(t),e=wa({},e,r,Jo);var i,s,a=wa({},e.imports,r.imports,Jo),l=Ma(a),u=Je(a,l),c=0,h=e.interpolate||vt,d="__p += '",f=Tt((e.escape||vt).source+"|"+h.source+"|"+(h===Q?ht:vt).source+"|"+(e.evaluate||vt).source+"|$","g"),p="//# sourceURL="+(Rt.call(e,"sourceURL")?(e.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++re+"]")+"\n";t.replace(f,(function(e,n,r,o,a,l){return r||(r=o),d+=t.slice(c,l).replace(wt,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'"),c=l+e.length,e})),d+="';\n";var m=Rt.call(e,"variable")&&e.variable;if(m){if(ut.test(m))throw new Ct("Invalid `variable` option passed into `_.template`")}else d="with (obj) {\n"+d+"\n}\n";d=(s?d.replace(V,""):d).replace(q,"$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=Qa((function(){return At(l,p+"return "+d).apply(o,u)}));if(g.source=d,Ks(g))throw g;return g},kn.times=function(t,e){if((t=fa(t))<1||t>h)return[];var n=f,r=yn(t,f);e=si(e),t-=f;for(var o=We(r,e);++n<t;)e(n);return o},kn.toFinite=da,kn.toInteger=fa,kn.toLength=pa,kn.toLower=function(t){return ya(t).toLowerCase()},kn.toNumber=ma,kn.toSafeInteger=function(t){return t?ir(fa(t),-9007199254740991,h):0===t?t:0},kn.toString=ya,kn.toUpper=function(t){return ya(t).toUpperCase()},kn.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("")},kn.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("")},kn.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("")},kn.truncate=function(t,e){var n=30,r="...";if(Zs(e)){var i="separator"in e?e.separator:i;n="length"in e?fa(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-cn(r);if(l<1)return r;var u=a?vo(a,0,l).join(""):t.slice(0,l);if(i===o)return u+r;if(a&&(l+=u.length-l),oa(i)){if(t.slice(l).search(i)){var c,h=u;for(i.global||(i=Tt(i.source,ya(dt.exec(i))+"g")),i.lastIndex=0;c=i.exec(h);)var d=c.index;u=u.slice(0,d===o?l:d)}}else if(t.indexOf(so(i),l)!=l){var f=u.lastIndexOf(i);f>-1&&(u=u.slice(0,f))}return u+r},kn.unescape=function(t){return(t=ya(t))&&W.test(t)?t.replace(G,fn):t},kn.uniqueId=function(t){var e=++Pt;return ya(t)+e},kn.upperCase=Ya,kn.upperFirst=Ka,kn.each=ys,kn.eachRight=bs,kn.first=Gi,sl(kn,(gl={},br(kn,(function(t,e){Rt.call(kn.prototype,e)||(gl[e]=t)})),gl),{chain:!1}),kn.VERSION="4.17.21",Te(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(t){kn[t].placeholder=kn})),Te(["drop","take"],(function(t,e){Vn.prototype[t]=function(n){n=n===o?1:gn(fa(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,f),type:t+(r.__dir__<0?"Right":"")}),r},Vn.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}})),Te(["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}})),Te(["head","last"],(function(t,e){var n="take"+(e?"Right":"");Vn.prototype[t]=function(){return this[n](1).value()[0]}})),Te(["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=Wr((function(t,e){return"function"==typeof t?new Vn(this):this.map((function(n){return Ir(n,t,e)}))})),Vn.prototype.reject=function(t){return this.filter(Ps(si(t)))},Vn.prototype.slice=function(t,e){t=fa(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=fa(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(f)},br(Vn.prototype,(function(t,e){var n=/^(?:filter|find|map|reject)|While$/.test(e),r=/^(?:head|last)$/.test(e),i=kn[r?"take"+("last"==e?"Right":""):e],s=r||/^find/.test(e);i&&(kn.prototype[e]=function(){var e=this.__wrapped__,a=r?[1]:arguments,l=e instanceof Vn,u=a[0],c=l||qs(e),h=function(t){var e=i.apply(kn,Le([t],a));return r&&d?e[0]:e};c&&n&&"function"==typeof u&&1!=u.length&&(l=c=!1);var d=this.__chain__,f=!!this.__actions__.length,p=s&&!d,m=l&&!f;if(!s&&c){e=m?e:new Vn(this);var g=t.apply(e,a);return g.__actions__.push({func:ds,args:[h],thisArg:o}),new $n(g,d)}return p&&m?t.apply(this,a):(g=this.thru(h),p?r?g.value()[0]:g.value():g)})})),Te(["pop","push","shift","sort","splice","unshift"],(function(t){var e=It[t],n=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",r=/^(?:pop|shift)$/.test(t);kn.prototype[t]=function(){var t=arguments;if(r&&!this.__chain__){var o=this.value();return e.apply(qs(o)?o:[],t)}return this[n]((function(n){return e.apply(qs(n)?n:[],t)}))}})),br(Vn.prototype,(function(t,e){var n=kn[e];if(n){var r=n.name+"";Rt.call(Nn,r)||(Nn[r]=[]),Nn[r].push({name:e,func:n})}})),Nn[ko(o,2).name]=[{name:"wrapper",func:o}],Vn.prototype.clone=function(){var t=new Vn(this.__wrapped__);return t.__actions__=_o(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=_o(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=_o(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=qs(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,u=r?a:s-1,c=this.__iteratees__,h=c.length,d=0,f=yn(l,this.__takeCount__);if(!n||!r&&o==l&&f==l)return ho(t,this.__actions__);var p=[];t:for(;l--&&d<f;){for(var m=-1,g=t[u+=e];++m<h;){var y=c[m],b=y.iteratee,v=y.type,w=b(g);if(2==v)g=w;else if(!w){if(1==v)continue t;break t}}p[d++]=g}return p},kn.prototype.at=fs,kn.prototype.chain=function(){return hs(this)},kn.prototype.commit=function(){return new $n(this.value(),this.__chain__)},kn.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__++]}},kn.prototype.plant=function(t){for(var e,n=this;n instanceof Un;){var r=ki(n);r.__index__=0,r.__values__=o,e?i.__wrapped__=r:e=r;var i=r;n=n.__wrapped__}return i.__wrapped__=t,e},kn.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 $n(e,this.__chain__)}return this.thru(Zi)},kn.prototype.toJSON=kn.prototype.valueOf=kn.prototype.value=function(){return ho(this.__wrapped__,this.__actions__)},kn.prototype.first=kn.prototype.head,Kt&&(kn.prototype[Kt]=function(){return this}),kn}();he._=pn,(r=function(){return pn}.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,u,c,h){"use strict";var d=t("crypto");function f(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=f).sha1=function(t){return f(t)},n.keys=function(t){return f(t,{excludeValues:!0,algorithm:"sha1",encoding:"hex"})},n.MD5=function(t){return f(t,{algorithm:"md5",encoding:"hex"})},n.keysMD5=function(t){return f(t,{algorithm:"md5",encoding:"hex",excludeValues:!0})};var p=d.getHashes?d.getHashes().slice():["sha1","md5"],m=(p.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<p.length;++r)p[r].toLowerCase()===n.algorithm.toLowerCase()&&(n.algorithm=p[r]);if(-1===p.indexOf(n.algorithm))throw new Error('Algorithm "'+n.algorithm+'" not supported. supported values: '+p.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,u){!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 u(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=u(t.charAt(n))<<18|u(t.charAt(n+1))<<12|u(t.charAt(n+2))<<6|u(t.charAt(n+3))))>>16),l((65280&r)>>8),l(255&r);return 2==o?l(255&(r=u(t.charAt(n))<<2|u(t.charAt(n+1))>>4)):1==o&&(l((r=u(t.charAt(n))<<10|u(t.charAt(n+1))<<4|u(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,u,c){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=_(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=_(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(I(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 f(t,e,n,r){var o;if(r||(F("boolean"==typeof n,"missing or invalid endian"),F(null!=e,"missing offset"),F(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 p(t,e,n,r){var o;if(r||(F("boolean"==typeof n,"missing or invalid endian"),F(null!=e,"missing offset"),F(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||(F("boolean"==typeof n,"missing or invalid endian"),F(null!=e,"missing offset"),F(e+1<t.length,"Trying to read beyond buffer length")),!(t.length<=e))return 32768&(r=f(t,e,n,!0))?-1*(65535-r+1):r}function g(t,e,n,r){if(r||(F("boolean"==typeof n,"missing or invalid endian"),F(null!=e,"missing offset"),F(e+3<t.length,"Trying to read beyond buffer length")),!(t.length<=e))return 2147483648&(r=p(t,e,n,!0))?-1*(4294967295-r+1):r}function y(t,e,n,r){return r||(F("boolean"==typeof n,"missing or invalid endian"),F(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||(F("boolean"==typeof n,"missing or invalid endian"),F(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||(F(null!=e,"missing value"),F("boolean"==typeof r,"missing or invalid endian"),F(null!=n,"missing offset"),F(n+1<t.length,"trying to write beyond buffer length"),P(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 w(t,e,n,r,o){if(o||(F(null!=e,"missing value"),F("boolean"==typeof r,"missing or invalid endian"),F(null!=n,"missing offset"),F(n+3<t.length,"trying to write beyond buffer length"),P(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 C(t,e,n,r,o){o||(F(null!=e,"missing value"),F("boolean"==typeof r,"missing or invalid endian"),F(null!=n,"missing offset"),F(n+1<t.length,"Trying to write beyond buffer length"),B(e,32767,-32768)),t.length<=n||v(t,0<=e?e:65535+e+1,n,r,o)}function A(t,e,n,r,o){o||(F(null!=e,"missing value"),F("boolean"==typeof r,"missing or invalid endian"),F(null!=n,"missing offset"),F(n+3<t.length,"Trying to write beyond buffer length"),B(e,2147483647,-2147483648)),t.length<=n||w(t,0<=e?e:4294967295+e+1,n,r,o)}function x(t,e,n,r,o){o||(F(null!=e,"missing value"),F("boolean"==typeof r,"missing or invalid endian"),F(null!=n,"missing offset"),F(n+3<t.length,"Trying to write beyond buffer length"),D(e,34028234663852886e22,-34028234663852886e22)),t.length<=n||d.write(t,e,n,r,23,4)}function S(t,e,n,r,o){o||(F(null!=e,"missing value"),F("boolean"==typeof r,"missing or invalid endian"),F(null!=n,"missing offset"),F(n+7<t.length,"Trying to write beyond buffer length"),D(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=M(t).length;break;case"ascii":case"binary":case"raw":n=t.length;break;case"base64":n=O(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(F(I(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):(u=r,r=e,e=n,n=u),e=Number(e)||0;var i,s,a,l,u=this.length-e;switch((!n||u<(n=Number(n)))&&(n=u),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),F((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);F(!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(M(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(O(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+=N(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+=R(o)+String.fromCharCode(t[i]),o=""):o+="%"+t[i].toString(16);return r+R(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){F(n<=r,"sourceEnd < sourceStart"),F(0<=e&&e<t.length,"targetStart out of bounds"),F(0<=n&&n<this.length,"sourceStart out of bounds"),F(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=E(t,n,0),e=E(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||(F(null!=t,"missing offset"),F(t<this.length,"Trying to read beyond buffer length")),!(t>=this.length))return this[t]},o.prototype.readUInt16LE=function(t,e){return f(this,t,!0,e)},o.prototype.readUInt16BE=function(t,e){return f(this,t,!1,e)},o.prototype.readUInt32LE=function(t,e){return p(this,t,!0,e)},o.prototype.readUInt32BE=function(t,e){return p(this,t,!1,e)},o.prototype.readInt8=function(t,e){if(e||(F(null!=t,"missing offset"),F(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||(F(null!=t,"missing value"),F(null!=e,"missing offset"),F(e<this.length,"trying to write beyond buffer length"),P(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){w(this,t,e,!0,n)},o.prototype.writeUInt32BE=function(t,e,n){w(this,t,e,!1,n)},o.prototype.writeInt8=function(t,e,n){n||(F(null!=t,"missing value"),F(null!=e,"missing offset"),F(e<this.length,"Trying to write beyond buffer length"),B(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){C(this,t,e,!0,n)},o.prototype.writeInt16BE=function(t,e,n){C(this,t,e,!1,n)},o.prototype.writeInt32LE=function(t,e,n){A(this,t,e,!0,n)},o.prototype.writeInt32BE=function(t,e,n){A(this,t,e,!1,n)},o.prototype.writeFloatLE=function(t,e,n){x(this,t,e,!0,n)},o.prototype.writeFloatBE=function(t,e,n){x(this,t,e,!1,n)},o.prototype.writeDoubleLE=function(t,e,n){S(this,t,e,!0,n)},o.prototype.writeDoubleBE=function(t,e,n){S(this,t,e,!1,n)},o.prototype.fill=function(t,e,n){if(e=e||0,n=n||this.length,F("number"==typeof(t="string"==typeof(t=t||0)?t.charCodeAt(0):t)&&!isNaN(t),"value is not a number"),F(e<=n,"end < start"),n!==e&&0!==this.length){F(0<=e&&e<this.length,"start out of bounds"),F(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]=N(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 T=o.prototype;function E(t,e,n){return"number"!=typeof t?n:e<=(t=~~t)?e:0<=t||0<=(t+=e)?t:0}function _(t){return(t=~~Math.ceil(+t))<0?0:t}function I(t){return(Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)})(t)}function N(t){return t<16?"0"+t.toString(16):t.toString(16)}function M(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 O(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 R(t){try{return decodeURIComponent(t)}catch(t){return String.fromCharCode(65533)}}function P(t,e){F("number"==typeof t,"cannot write a non-number as a number"),F(0<=t,"specified a negative value for writing an unsigned value"),F(t<=e,"value is larger than maximum value for type"),F(Math.floor(t)===t,"value has a fractional component")}function B(t,e,n){F("number"==typeof t,"cannot write a non-number as a number"),F(t<=e,"value larger than maximum allowed value"),F(n<=t,"value smaller than minimum allowed value"),F(Math.floor(t)===t,"value has a fractional component")}function D(t,e,n){F("number"==typeof t,"cannot write a non-number as a number"),F(t<=e,"value larger than maximum allowed value"),F(n<=t,"value smaller than minimum allowed value")}function F(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=T.get,t.set=T.set,t.write=T.write,t.toString=T.toString,t.toLocaleString=T.toString,t.toJSON=T.toJSON,t.copy=T.copy,t.slice=T.slice,t.readUInt8=T.readUInt8,t.readUInt16LE=T.readUInt16LE,t.readUInt16BE=T.readUInt16BE,t.readUInt32LE=T.readUInt32LE,t.readUInt32BE=T.readUInt32BE,t.readInt8=T.readInt8,t.readInt16LE=T.readInt16LE,t.readInt16BE=T.readInt16BE,t.readInt32LE=T.readInt32LE,t.readInt32BE=T.readInt32BE,t.readFloatLE=T.readFloatLE,t.readFloatBE=T.readFloatBE,t.readDoubleLE=T.readDoubleLE,t.readDoubleBE=T.readDoubleBE,t.writeUInt8=T.writeUInt8,t.writeUInt16LE=T.writeUInt16LE,t.writeUInt16BE=T.writeUInt16BE,t.writeUInt32LE=T.writeUInt32LE,t.writeUInt32BE=T.writeUInt32BE,t.writeInt8=T.writeInt8,t.writeInt16LE=T.writeInt16LE,t.writeInt16BE=T.writeInt16BE,t.writeInt32LE=T.writeInt32LE,t.writeInt32BE=T.writeInt32BE,t.writeFloatLE=T.writeFloatLE,t.writeFloatBE=T.writeFloatBE,t.writeDoubleLE=T.writeDoubleLE,t.writeDoubleBE=T.writeDoubleBE,t.fill=T.fill,t.inspect=T.inspect,t.toArrayBuffer=T.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,u,c){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,u,c){o=t("buffer").Buffer;var h=t("./sha"),d=t("./sha256"),f=t("./rng"),p={sha1:h,sha256:d,md5:t("./md5")},m=64,g=new o(m);function y(t,e){var n=p[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(f(t));try{e.call(this,void 0,new o(f(t)))}catch(t){e(t)}};var v,w=["createCredentials","createCipher","createCipheriv","createDecipher","createDecipheriv","createSign","createVerify","createDiffieHellman","pbkdf2"],C=function(t){n[t]=function(){b("sorry,",t,"is not implemented yet")}};for(v in w)C(w[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,u,c){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,u=o,c=i;n=p(n,r,o,i,t[s+0],7,-680876936),i=p(i,n,r,o,t[s+1],12,-389564586),o=p(o,i,n,r,t[s+2],17,606105819),r=p(r,o,i,n,t[s+3],22,-1044525330),n=p(n,r,o,i,t[s+4],7,-176418897),i=p(i,n,r,o,t[s+5],12,1200080426),o=p(o,i,n,r,t[s+6],17,-1473231341),r=p(r,o,i,n,t[s+7],22,-45705983),n=p(n,r,o,i,t[s+8],7,1770035416),i=p(i,n,r,o,t[s+9],12,-1958414417),o=p(o,i,n,r,t[s+10],17,-42063),r=p(r,o,i,n,t[s+11],22,-1990404162),n=p(n,r,o,i,t[s+12],7,1804603682),i=p(i,n,r,o,t[s+13],12,-40341101),o=p(o,i,n,r,t[s+14],17,-1502002290),n=m(n,r=p(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,u),i=b(i,c)}return Array(n,r,o,i)}function f(t,e,n,r,o,i){return b((e=b(b(e,t),b(r,i)))<<o|e>>>32-o,n)}function p(t,e,n,r,o,i,s){return f(e&n|~e&r,t,e,o,i,s)}function m(t,e,n,r,o,i,s){return f(e&r|n&~r,t,e,o,i,s)}function g(t,e,n,r,o,i,s){return f(e^n^r,t,e,o,i,s)}function y(t,e,n,r,o,i,s){return f(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,u){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,u,c){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,u=271733878,c=-1009589776,h=0;h<t.length;h+=16){for(var d=s,m=a,g=l,y=u,b=c,v=0;v<80;v++){i[v]=v<16?t[h+v]:p(i[v-3]^i[v-8]^i[v-14]^i[v-16],1);var w=f(f(p(s,5),(w=a,r=l,o=u,(n=v)<20?w&r|~w&o:!(n<40)&&n<60?w&r|w&o|r&o:w^r^o)),f(f(c,i[v]),(n=v)<20?1518500249:n<40?1859775393:n<60?-1894007588:-899497514));c=u,u=l,l=p(a,30),a=s,s=w}s=f(s,d),a=f(a,m),l=f(l,g),u=f(u,y),c=f(c,b)}return Array(s,a,l,u,c)}function f(t,e){var n=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(n>>16)<<16|65535&n}function p(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,u,c){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 u=o[0],c=o[1],d=o[2],f=o[3],g=o[4],y=o[5],b=o[6],v=o[7],w=0;w<64;w++)i[w]=w<16?t[w+l]:h(h(h((a=i[w-2],p(a,17)^p(a,19)^m(a,10)),i[w-7]),(a=i[w-15],p(a,7)^p(a,18)^m(a,3))),i[w-16]),n=h(h(h(h(v,p(a=g,6)^p(a,11)^p(a,25)),g&y^~g&b),r[w]),i[w]),s=h(p(s=u,2)^p(s,13)^p(s,22),u&c^u&d^c&d),v=b,b=y,y=g,g=h(f,n),f=d,d=c,c=u,u=h(n,s);o[0]=h(u,o[0]),o[1]=h(c,o[1]),o[2]=h(d,o[2]),o[3]=h(f,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 f=t("./helpers"),p=function(t,e){return t>>>e|t<<32-e},m=function(t,e){return t>>>e};e.exports=function(t){return f.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,u){n.read=function(t,e,n,r,o){var i,s,a=8*o-r-1,l=(1<<a)-1,u=l>>1,c=-7,h=n?o-1:0,d=n?-1:1;for(o=t[e+h],h+=d,i=o&(1<<-c)-1,o>>=-c,c+=a;0<c;i=256*i+t[e+h],h+=d,c-=8);for(s=i&(1<<-c)-1,i>>=-c,c+=r;0<c;s=256*s+t[e+h],h+=d,c-=8);if(0===i)i=1-u;else{if(i===l)return s?NaN:1/0*(o?-1:1);s+=Math.pow(2,r),i-=u}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,u=(1<<l)-1,c=u>>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:i-1,f=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=u):(s=Math.floor(Math.log(e)/Math.LN2),e*(r=Math.pow(2,-s))<1&&(s--,r*=2),2<=(e+=1<=s+c?h/r:h*Math.pow(2,1-c))*r&&(s++,r/=2),u<=s+c?(a=0,s=u):1<=s+c?(a=(e*r-1)*Math.pow(2,o),s+=c):(a=e*Math.pow(2,c-1)*Math.pow(2,o),s=0));8<=o;t[n+d]=255&a,d+=f,a/=256,o-=8);for(s=s<<o|a,l+=o;0<l;t[n+d]=255&s,d+=f,s/=256,l-=8);t[n+d-f]|=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,u){var c,h,d;function f(){}(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?(c=[],window.addEventListener("message",(function(t){var e=t.source;e!==window&&null!==e||"process-tick"!==t.data||(t.stopPropagation(),0<c.length&&c.shift()())}),!0),function(t){c.push(t),window.postMessage("process-tick","*")}):function(t){setTimeout(t,0)}),t.title="browser",t.browser=!0,t.env={},t.argv=[],t.on=f,t.addListener=f,t.once=f,t.off=f,t.removeListener=f,t.removeAllListeners=f,t.emit=f,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},u=function(t){if(!l(t))throw new Error("an HTMLElement or SVGElement is required; got "+t)},c=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})},f={},p=null,m=function(t,e){var n=e||{},r=n.selectorRemap,o=n.modifyStyle,i=n.modifyCss,l=n.fonts,u=n.excludeUnusedCss,c=i||function(t,e){return(r?r(t):t)+"{"+(o?o(e):e)+"}\n"},h=[],d=void 0===l,m=l||[];return(p||(p=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(c(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 u||h.push(e.cssText)}))})),function(t){return Promise.all(t.map((function(t){return new Promise((function(e,n){if(f[t.url])return e(f[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";f[t.url]=o,e(o)})),r.addEventListener("error",(function(n){console.warn("Failed to load font from: "+t.url,n),f[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){u(t);var r=e||{},s=r.left,a=void 0===s?0:s,l=r.top,c=void 0===l?0:l,d=r.width,f=r.height,p=r.scale,g=void 0===p?1:p,y=r.responsive,b=void 0!==y&&y,v=r.excludeCss,w=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,f),l=s.width,u=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 p=document.createElementNS("http://www.w3.org/2000/svg","svg");p.appendChild(r),r=p}if(r.setAttribute("version","1.1"),r.setAttribute("viewBox",[a,c,l,u].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",u*g)),Array.from(r.querySelectorAll("foreignObject > *")).forEach((function(t){t.setAttributeNS(o,"xmlns","svg"===t.tagName?i:"http://www.w3.org/1999/xhtml")})),!w)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:u};n(s,l,u)}));var y=document.createElement("div");y.appendChild(r);var v=y.innerHTML;if("function"!=typeof n)return{src:v,width:l,height:u};n(v,l,u)}))},r.svgAsDataUri=function(t,e,n){return u(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){u(t);var o=e||{},i=o.encoderType,s=void 0===i?"image/png":i,a=o.encoderOptions,l=void 0===a?.8:a,c=o.canvg,h=function(t){var e=t.src,r=t.width,o=t.height,i=document.createElement("canvas"),a=i.getContext("2d"),u=window.devicePixelRatio||1;i.width=r*u,i.height=o*u,i.style.width=i.width+"px",i.style.height=i.height+"px",a.setTransform(u,0,0,u,0,0),c?c(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 c?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 c(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 c(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],u=r.base?l[0]+r.base:l[0],c=i[u]||0,h="".concat(u," ").concat(c);i[u]=c+1;var d=n(h),f={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==d)e[d].references++,e[d].updater(f);else{var p=o(f,r);r.byIndex=a,e.splice(a,0,{identifier:h,updater:p,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),u=0;u<i.length;u++){var c=n(i[u]);0===e[c].references&&(e[c].updater(),e.splice(c,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,OT:()=>u,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),u=Object.fromEntries(s.map((t=>{let e;try{e=l.convertTo(t)}catch{e=null}return[t,e]})).filter((([t,e])=>e))),c=a(n===r.NO.HELM?t:u[r.NO.HELM],o.monomerLibWrapper);return c&&(u.Nucleotides=c),u}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 u(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"},9788:(t,e,n)=>{"use strict";n.r(e),n.d(e,{PackageFunctions:()=>to,_package:()=>Xr,applyNotationProviderForCyclized:()=>Yr,createMonomerLibraryForPolyTool:()=>Ur,demoOligoPattern:()=>Or,demoOligoStructure:()=>Lr,demoTranslateSequence:()=>Mr,enumerateSingleHelmSequence:()=>Gr,enumerateSingleHelmSequenceWithNaturalAAs:()=>zr,getCodeToWeightsMap:()=>Er,getMolfileFromGcrsSequence:()=>Ir,getPolyToolCombineDialog:()=>Wr,getPolyToolConvertEditor:()=>Br,getPtChemEnumeratorDialog:()=>jr,getPtHelmEnumeratorDialog:()=>qr,getTranslationHelper:()=>Tr,init:()=>Cr,linkStrands:()=>Nr,oligoPatternApp:()=>xr,oligoStructureApp:()=>Sr,oligoToolkitApp:()=>wr,oligoTranslatorApp:()=>Ar,polyToolColumnChoice:()=>Hr,polyToolConvert2:()=>Dr,polyToolConvertTopMenu:()=>Pr,polyToolEnumerateChemTopMenu:()=>kr,polyToolEnumerateHelmTopMenu:()=>Fr,ptEnumeratorChemApp:()=>Vr,ptEnumeratorHelmApp:()=>$r,translateOligonucleotideSequence:()=>Rr,validateSequence:()=>_r});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 u{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 c="System:AppData/SequenceTranslator/monomers-sample",h="pattern-app-data.json",d="formats-to-helm.json",f="codes-to-symbols.json",p="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 w{constructor(t,e,n,r){this.patternAppData=t,this.codesToHelmDict=e,this.codesToSymbolsDict=n,this.monomersWithPhosphate=r}}async function C(t){const e=await Promise.all([h,d,f,p].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 w(e[0],e[1],e[2],e[3])}class A{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 x=n(9537);const S=(t,e)=>e.length-t.length;class T{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(S);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(S)}getTargetFormatHelmCodesRegExp(t){this.validateFormat(t);const e=this.getTargetFormatHelmCodes(t);return new RegExp(E(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=E(Array.from(new Set(Object.values(e[x.ti.LINKAGE]))).sort(S));return new RegExp(`${x.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(S)}getNonHelmFormatRegExp(t){const e=this.getCodesByFormat(t);return new RegExp(E(e)+"|\\([^()]*\\)|.","g")}}function E(t){return t.map((t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"))).map((t=>t.includes("(")||t.includes(")")?t:`(?<!\\([^()]*)${t}(?![^()]*\\))`)).join("|")}const _={LEFT:"RNA1{",RIGHT:"}$$$$"};class I{constructor(t,e,n){this.sequence=t,this.sourceFormat=e,this.th=n,this.formats=new T(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(E(Object.values(_)),"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,x.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,`${x.iL}.`),s=s.slice(0,-1),s[s.length-1]===x.q7&&(s=s.slice(0,-1)),s=s.replace(i,((t,e)=>e)),s=s.replace(/<empty>/g,""),`${_.LEFT+s+_.RIGHT}`}}class N{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 M=n(7389);const O=$;var L=n.n(O);function R(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=M.span([]);L()(i).css("-webkit-text-fill-color","var(--grey-6)");const s=M.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 P 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=>R(t,this),super._logger=new u(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 '${c}'.`),e=c),[this._jsonData,this._monomerLib]=await Promise.all([C(e),B(e)]),this._monomerLibWrapper=new A(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 I(t,e,this)}createFormatDetector(t){return new N(t,this)}}async function B(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 D{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&&M.setUpdateIndicator(e,!0);try{return await this.constructView()}finally{t.close(),e&&M.setUpdateIndicator(e,!1)}}}class F extends D{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/${Xr.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"},U=["3'","5'"],V="OligoToolkit";var q,j,G,z;!function(t){t.IS_ANTISENSE_STRAND_INCLUDED="isAntisenseStrandIncluded",t.NUCLEOTIDE_SEQUENCES="nucleotideSequences",t.PHOSPHOROTHIOATE_LINKAGE_FLAGS="phosphorothioateLinkageFlags",t.STRAND_TERMINUS_MODIFICATIONS="strandTerminusModifications"}(q||(q={})),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"}(G||(G={})),function(t){t.CREATE="create",t.MODIFY="modify"}(z||(z={}));const W=[q.IS_ANTISENSE_STRAND_INCLUDED,q.NUCLEOTIDE_SEQUENCES,q.PHOSPHOROTHIOATE_LINKAGE_FLAGS,q.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 J extends Error{constructor(t){super(t),this.name="PatternNameExistsError"}}class Q 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 Xr.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 J(`Pattern with name ${t} already exists`)}validatePatternUniqueness(t){if(Array.from(this.currentUserPatternNameToHash.values()).concat(Array.from(this.otherUsersPatternNameToHash.values())).includes(t))throw new Q(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[G.PATTERN_CONFIG]}getDefaultPatternRecord(){const t=Y;return t[G.AUTHOR_ID]=this.currentUserId,t}getDefaultPatternConfig(){return Y[G.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{[G.PATTERN_CONFIG]:t,[G.AUTHOR_ID]:await r.dapi.users.current().then((t=>t.id))}}getHash(t){const e=W.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[G.DATE]={[z.CREATE]:s,[z.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 J||t instanceof Q)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[G.DATE]={[z.MODIFY]:a};const l=r.userSettings.getValue(V,o,!1)??"null",u=JSON.parse(l);void 0!==u[G.DATE]&&null!=u[G.DATE][z.CREATE]&&(s[G.DATE][z.CREATE]=u[G.DATE][z.CREATE]);const c=JSON.stringify(s);r.userSettings.add(V,i,c,!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[G.PATTERN_CONFIG];this.currentUserPatternNameToHash.set(t[j.PATTERN_NAME],"")}async extractDataFromRecordToMaps(t,e,n){const o=JSON.parse(e),i=o[G.PATTERN_CONFIG].patternName,s=o[G.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[G.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 ut{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||U.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[G.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[G.PATTERN_CONFIG];this._patternName$=new et.BehaviorSubject(e[j.PATTERN_NAME]),this._isAntisenseStrandActive$=new et.BehaviorSubject(e[q.IS_ANTISENSE_STRAND_INCLUDED]),this._nucleotideSequences$=new et.BehaviorSubject(e[q.NUCLEOTIDE_SEQUENCES]),this._phosphorothioateLinkageFlags=new et.BehaviorSubject(e[q.PHOSPHOROTHIOATE_LINKAGE_FLAGS]),this._terminalModifications=new et.BehaviorSubject(e[q.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[q.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[q.IS_ANTISENSE_STRAND_INCLUDED]),this._nucleotideSequences$.next(t[q.NUCLEOTIDE_SEQUENCES]),this._phosphorothioateLinkageFlags.next(t[q.PHOSPHOROTHIOATE_LINKAGE_FLAGS]),this._terminalModifications.next(t[q.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(),[q.IS_ANTISENSE_STRAND_INCLUDED]:this.isAntisenseStrandActive(),[q.NUCLEOTIDE_SEQUENCES]:this.getNucleotideSequences(),[q.PHOSPHOROTHIOATE_LINKAGE_FLAGS]:this.getPhosphorothioateLinkageFlags(),[q.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 ct="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}?${ct}=${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(ct)}setPatternURL(t){null!==t&&""!==t?(this.urlSearchParams.set(ct,t),window.history.pushState({},"",`${window.location.pathname}?${this.urlSearchParams}`)):this.clearPatternURL()}clearPatternURL(){this.urlSearchParams.delete(ct),window.history.pushState({},"",`${window.location.pathname}`)}}var dt=n(5072),ft=n.n(dt),pt=n(7825),mt=n.n(pt),gt=n(7659),yt=n.n(gt),bt=n(5056),vt=n.n(bt),wt=n(540),Ct=n.n(wt),At=n(1113),xt=n.n(At),St=n(9252),Tt={};Tt.styleTagTransform=xt(),Tt.setAttributes=vt(),Tt.insert=yt().bind(null,"head"),Tt.domAPI=mt(),Tt.insertStyleElement=Ct(),ft()(St.A,Tt),St.A&&St.A.locals&&St.A.locals;class Et{constructor(t){this.eventBus=t,this.columnControlsContainer=M.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=M.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=M.input.choice("ID column",{value:t[0],items:t,onValueChanged:t=>this.eventBus.selectIdColumn(t)});return this.eventBus.selectIdColumn(t[0]),e.root}}class _t{constructor(t){this.eventBus=t,this.availableTables=[],this.tableInputContainer=M.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 M.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 It(t,e,n,r){const o=function(t,e,n){const r=new Array(t.length+e.filter((t=>t)).length+U.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],Xr.jsonData);return r})),n,r);return o.join("")}class Nt{constructor(t){this.eventBus=t,this.tableInputManager=new _t(t),this.columnInputManager=new Et(t)}createControls(){const t=M.h1("Bulk convert"),e=this.tableInputManager.getTableInputContainer(),n=this.columnInputManager.getColumnControlsContainer(),r=M.bigButton("Convert",(()=>this.processConvertButtonClick()));return[t,e,n,M.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=>It(r.get(t),i,a,s)))}))}(this.eventBus)}}class Mt{constructor(t,e,n){this.eventBus=t,this.initialPatternConfig=e,this.subscriptions=n}create(){return M.divV([M.h1("PTO"),M.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=M.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),M.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=M.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),M.tooltip.bind(n.captionLabel,`Activate first phosphothioate in ${t}`),n})).filter((t=>void 0!==t))}isFirstPtoActive(t){return this.initialPatternConfig.phosphorothioateLinkageFlags[t][0]}}class Ot{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 M.divH(t,{style:{gap:"24px"}})}constructControlsPanel(t){if(!this.eventBus.isAntisenseStrandActive()&&"AS"===t)return M.div([]);const e=this.constructHeader(),n=this.createControls(t);return M.block([M.h1(`${H[t]}`),e,n],{style:{paddingTop:"12px"}})}constructHeader(){return M.divH([M.div([M.divText("#")],{style:{width:"20px"}}),M.block75([M.divText("Modification")]),M.div([M.divText("PTO")])])}createControls(t){const e=this.createNucleobaseInputs(t),n=this.createLabelDivs(t),r=this.createPTOFlagInputs(t);return M.div(e.map(((t,e)=>M.divH([n[e],M.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=M.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=M.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=>M.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 M.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 Rt{constructor(t,e){this.eventBus=t,this.dataManager=e,this.subscriptions=new Lt}static open(t,e){Rt.isDialogOpen||(Rt.instance||(Rt.instance=new Rt(t,e)),Rt.instance.openDialog())}openDialog(){this.initialPatternConfig=lt().cloneDeep(this.eventBus.getPatternConfig()),Rt.isDialogOpen=!0,this.createDialog().show()}createDialog(){const t=M.divV([]);this.subscriptions.add(this.eventBus.strandsUpdated$.subscribe((()=>this.onStrandsUpdated(t))));const e=M.dialog("Edit strands").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 Mt(this.eventBus,this.initialPatternConfig,this.subscriptions).create(),n=new Ot(this.eventBus,this.dataManager,this.subscriptions).create();L()(t).empty(),L()(t).append(e,n)}resetToInitialState(){this.eventBus.setPatternConfig(this.initialPatternConfig)}}Rt.isDialogOpen=!1;class Pt{constructor(t){this.eventBus=t,this.subscriptions=new Lt}static open(t){Pt.isDialogOpen||(Pt.instance||(Pt.instance=new Pt(t)),Pt.instance.openDialog())}openDialog(){this.initialPatternConfig=lt().cloneDeep(this.eventBus.getPatternConfig()),Pt.isDialogOpen=!0,this.createDialog().show()}createDialog(){const t=M.divV([]);this.subscriptions.add(this.eventBus.strandsUpdated$.subscribe((()=>this.onStrandsUpdated(t))));const e=M.dialog("Edit terminal modifications").add(t).onOK((()=>{})).onCancel((()=>this.resetToInitialState()));return this.subscriptions.add(e.onClose.subscribe((()=>{Pt.isDialogOpen=!1,this.subscriptions.unsubscribeAll()}))),e}onStrandsUpdated(t){const e=new Bt(this.eventBus).create();L()(t).empty(),L()(t).append(e)}resetToInitialState(){this.eventBus.setPatternConfig(this.initialPatternConfig)}}Pt.isDialogOpen=!1;class Bt{constructor(t){this.eventBus=t}create(){const t=k.map((t=>this.constructControlsPanel(t)));return M.divH(t,{style:{gap:"24px"}})}constructControlsPanel(t){if(!this.eventBus.isAntisenseStrandActive()&&"AS"===t)return M.div([]);const e=this.createInputs(t);return M.block([M.h1(`${H[t]}`),e],{style:{paddingTop:"12px"}})}createInputs(t){const e=("SS"===t?[...U].reverse():U).map((e=>this.createInputForTerminus(t,e)));return M.form(e)}createInputForTerminus(t,e){const n=this.eventBus.getTerminalModifications()[t][e],r=M.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 Dt{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[M.h1("Edit"),t,n,r,o,s,i,M.buttonsInput([l,a])]}createEditPatternButton(){const t=M.button("Edit strands",(()=>Rt.open(this.eventBus,this.dataManager)));return M.tooltip.bind(t,"Edit strand modifications and PTOs"),t}createEditTerminalModificationsButton(){const t=M.button("Edit terminals",(()=>Pt.open(this.eventBus)));return M.tooltip.bind(t,"Edit terminal modifications"),L()(t).css("margin-right","20px"),t}createAntisenseStrandToggle(){const t=M.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=M.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=M.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=M.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=M.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 Ft{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[M.h1("Load"),t]}getPatternInputsContainer(){const t=M.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=M.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=M.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=M.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=M.button(M.iconFA("trash-alt"),(()=>{this.eventBus.getPatternName()!==this.dataManager.getDefaultPatternName()?this.showDeletePatternDialog():r.shell.warning("Cannot delete example pattern")}));M.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=M.dialog("Delete pattern"),e=this.eventBus.getPatternName();t.add(M.divText(`Are you sure you want to delete pattern ${e}?`)),t.onOK((()=>this.eventBus.requestPatternDeletion(e))),t.show()}}class kt{constructor(t,e){this.eventBus=t,this.dataManager=e}getLayout(){const t=new Ft(this.eventBus,this.dataManager),e=new Dt(this.eventBus,this.dataManager),n=new Nt(this.eventBus),r=t.createControls(),o=e.createControls(),i=n.createControls(),s=M.div(r);L()(s).css({"padding-bottom":"20px"});const a=M.div([...o,...i],"ui-form"),l=M.div([s,a]);return L()(l).css({padding:"25px"}),M.box(l,{style:{maxWidth:"450px"}})}}var Ht=n(9146);class Ut{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 $t{constructor(){}static getInstance(){return $t.instance||($t.instance=new $t,$t.instance.canvas=document.createElement("canvas")),$t.instance}static getTextDimensions(t,e){const n=$t.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(Xr.jsonData.patternAppData)[0];if(!e)throw new Error(`No format found in '${h}'`);return Xr.jsonData.patternAppData[e][t].color||""}class qt extends Ut{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 zt(this.svgElementFactory,e,n,t,this.strands[r]))),this.labels=r.map(((t,r)=>new Gt(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 Ut{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 Wt(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=$t.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=$t.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 Gt extends Ut{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=$t.getTextDimensions(e,17),r={x:10,y:Wt(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=$t.getTextDimensions(t,17),n={x:65+this.terminalModifications.getContentWidth()+5,y:Wt(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 zt extends Ut{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 $t.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:Wt(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?U:Array.from(U).reverse()).map((t=>this.createTerminalModification(t)))}get svgElements(){return this._svgElements}getContentWidth(){return this.strandSvgWrapper.getContentWidth()+U.map((t=>this.getTerminalModificationTextDimensions(t).width)).reduce(((t,e)=>t+e),0)}getContentHeight(){return this.strandSvgWrapper.getContentHeight()}}function Wt(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 Ut{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 $t.getTextDimensions(this.titleText,17).width}getContentHeight(){return $t.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 Jt extends Ut{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+$t.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 Qt{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 qt(this.svgElementFactory,e,n),n+=this.strands.getContentHeight()+10,this.legend=new Jt(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=M.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 Qt(t).renderPattern()}saveSvgAsPng(){const t=this.eventBus.getPatternName();Ht.saveSvgAsPng(this.svgElement,t,{backgroundColor:"white"})}}class Zt{constructor(t){this.eventBus=t,this.togglesContainer=M.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))),M.divH(t.map((t=>t.root)))}createSingleInput(t){const e=this.eventBus.getModificationsWithNumericLabels().includes(t),n=M.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 M.div([M.h1("Translation example"),this.createTranslationExamples()],{style:{paddingTop:"20px"}})}createTranslationExamples(){const t=M.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(),M.block50([M.h2(H[this.strand]),this.inputExample.root,this.outputExample.root],{style:{paddingRight:"20px"}})):M.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 It(t,e,this.eventBus.getPhosphorothioateLinkageFlags()[this.strand],n)}createTextInputForExamples(){const t=M.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 M.panel([this.svgDisplay,t,e,n],{style:{overflowX:"scroll",padding:"12px 24px"}})}generateDownloadControls(){return M.divH([this.createSavePatternButton(),this.createDownloadPngButton(),this.createShareLinkButton(),this.createInfoButton()],{style:{gap:"12px",marginTop:"12px"}})}createDownloadPngButton(){const t=M.button("Get PNG",(()=>this.eventBus.requestSvgSave()));return M.tooltip.bind(t,"Download pattern as PNG"),t}createInfoButton(){const t=M.button(M.iconFA("info-circle"),(()=>this.openInfoDialog()));return this.eventBus.patternHasUnsavedChanges$.subscribe((e=>{t.disabled=e})),M.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[G.AUTHOR_ID];if(t=(await r.dapi.users.find(i)).friendlyName,e=s[G.PATTERN_CONFIG][j.PATTERN_NAME],void 0!==s[G.DATE]){const t=s[G.DATE][z.CREATE];void 0!==t&&(n=t);const e=s[G.DATE][z.MODIFY];void 0!==e&&(o=e)}}}const s=M.divV([M.divText(`Pattern Name: ${e}`),M.divText(`Author: ${t}`),M.divText(`Created: ${oe(new Date(n))}`),M.divText(`Modified: ${oe(new Date(o))}`)]);r.shell.info(s)}createShareLinkButton(){const t=M.button(M.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})),M.tooltip.bind(t,"Share pattern link"),t}createSavePatternButton(){const t=M.button("Save",(()=>this.processSaveButtonClick()));return this.eventBus.patternHasUnsavedChanges$.subscribe((e=>{t.disabled=!e})),M.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 J?new re(this.eventBus,this.dataManager).show():t instanceof Q?r.shell.warning(M.div([M.divText("Pattern already exists"),M.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=M.dialog(`Pattern "${t}" already exists`);e.add(M.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 ut(t,n);e.subscribeToObservables(r);const o=new kt(r,t).getLayout(),i=new ne(r,t).getLayout();return M.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=xt(),ae.setAttributes=vt(),ae.insert=yt().bind(null,"head"),ae.domAPI=mt(),ae.insertStyleElement=Ct(),ft()(se.A,ae),se.A&&se.A.locals&&se.A.locals;var ue,ce=n(2074),he={};he.styleTagTransform=xt(),he.setAttributes=vt(),he.insert=yt().bind(null,"head"),he.domAPI=mt(),he.insertStyleElement=Ct(),ft()(ce.A,he),ce.A&&ce.A.locals&&ce.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=M.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"}(ue||(ue={}));class fe{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 pe extends fe{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 pe{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(ue.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(ue.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(ue.TYPE)&&-1!==t.indexOf(ue.END)}shiftIdxToAtomType(t){return this.shiftIdxToSpecifiedColumn(t,ue.ATOM_TYPE_COL)}getCountsLineIdx(){let t=0;for(let e=0;e<ue.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,ue.FIRST_BONDED_ATOM_COL)}shiftIdxToBondType(t){return this.shiftIdxToSpecifiedColumn(t,ue.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+ue.NUM_OF_COUNTS_DIGITS;const n=parseInt(this.fileContent.substring(t,e));return t=e,e+=ue.NUM_OF_COUNTS_DIGITS,{atomCount:n,bondCount:parseInt(this.fileContent.substring(t,e))}}}class ge extends pe{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=M.dialog({title:"Molecule",showFooter:!1}),e=.7*L()(window).height(),n=this.getMoleculeDimensions(),r=e/n.height,o=e,i=n.width*r,s=M.canvas(i,o);await this.drawMolBlockOnCanvas(s);const a=M.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=M.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(M.tooltip.bind(r,"Click to zoom"))}}class we extends Error{constructor(t,e){super(t,e)}}class Ce{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 Xr.jsonData.monomersWithPhosphate.left.includes(t)}(o)&&e.pop(),e.push(o);const i=Ae(o),s=r===t.length-1,a=r+1<t.length&&Ae(this.getSymbolForCode(t[r+1]));i||function(t){return Xr.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 we(`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 Ae(t){return Xr.jsonData.monomersWithPhosphate.phosphate.includes(t)}class xe{constructor(t,e=!1,n){this.invert=e,this.lib=Xr.monomerLibWrapper;const r=this.lib.getCodeToSymbolMap(n);this.parser=new Ce(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 u=l;for(let r=0;r<n;r++)l=t.indexOf("V30",l)+4,l=t.indexOf(" ",l)+1,l=t.indexOf(" ",l)+1,u=t.indexOf(" ",l)+1,u=t.indexOf(" ",u),l=(t=t.slice(0,l)+e.x[r]+" "+e.y[r]+t.slice(u)).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),u=Math.sin(a);for(let t=0;t<n;t++){const n=e.x[t];e.x[t]=n*l-e.y[t]*u,e.y[t]=n*u+e.y[t]*l}const c=e.x[r];for(let t=0;t<n;t++)e.x[t]-=c;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,u=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 c=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 f=d,p=d;for(let r=0;r<c.natom;r++)if(1!==h.atomIndex[r]||0===e){f=t[e].indexOf("V30",f)+4,p=t[e].indexOf(" ",f);let r=0;n?(r=parseInt(t[e].substring(f,p)),1===r?r=i:r===i&&(r=1),r+=a):r=parseInt(t[e].substring(f,p))+a,t[e]=t[e].slice(0,f)+r+t[e].slice(p),f=t[e].indexOf(" ",f)+1,f=t[e].indexOf(" ",f)+1,p=t[e].indexOf(" ",f);const o=u-h.x[0];let s=Math.round(1e4*(parseFloat(t[e].substring(f,p))+o))/1e4;t[e]=t[e].slice(0,f)+s+t[e].slice(p),f=t[e].indexOf(" ",f)+1,p=t[e].indexOf(" ",f),s=Math.round(1e4*parseFloat(t[e].substring(f,p)))/1e4,t[e]=t[e].slice(0,f)+s+t[e].slice(p),f=t[e].indexOf("\n",f)+1}else f=t[e].indexOf("M V30",f)-1,p=t[e].indexOf("\n",f+1),t[e]=t[e].slice(0,f)+t[e].slice(p);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),f=g,p=g;for(let r=0;r<c.nbond;r++){f=t[e].indexOf("V30",f)+4,p=t[e].indexOf(" ",f);const r=parseInt(t[e].substring(f,p))+l;t[e]=t[e].slice(0,f)+r+t[e].slice(p),f=t[e].indexOf(" ",f)+1,f=t[e].indexOf(" ",f)+1,p=t[e].indexOf(" ",f);let o=0;n?(o=parseInt(t[e].substring(f,p)),1===o?o=i:o===i&&(o=1),o+=a):o=parseInt(t[e].substring(f,p))+a,t[e]=t[e].slice(0,f)+o+t[e].slice(p),f=t[e].indexOf(" ",f)+1,p=Math.min(t[e].indexOf("\n",f),t[e].indexOf(" ",f)),o=0,n?(o=parseInt(t[e].substring(f,p)),1===o?o=i:o===i&&(o=1),o+=a):o=parseInt(t[e].substring(f,p))+a,t[e]=t[e].slice(0,f)+o+t[e].slice(p),f=t[e].indexOf("\n",f)+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+=c.natom-1,l+=c.nbond,u+=n?Math.max(...h.x):h.x[c.natom-1]-h.x[0]}const c=Math.ceil(s.length/4);i+="M V30 MDLV30/STEABS ATOMS=("+s.length+" -\n";for(let t=0;t<c;t++){i+="M V30 ";const e=t+1===c?s.length-4*(c-1):4;for(let n=0;n<e;n++)i+=n+1===e?t===c-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,u=t.y[e]-i,c=l*Math.cos(2*Math.PI/3)-u*Math.sin(2*Math.PI/3),h=l*Math.sin(2*Math.PI/3)+u*Math.cos(2*Math.PI/3),d=l-s,f=u-a,p=c-s,m=h-a;Math.sqrt(m*m+p*p)>=Math.sqrt(f*f+d*d)&&(t.x[e]=c+o,t.y[e]=h+i)}}function Se(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,u=0;if(t.antiStrands.length>0)for(let e=0;e<t.antiStrands.length;e++)t.antiStrands[e]=Te(t.antiStrands[e]);let c=!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=Ee(h[e]),i=_e(h[e]);if(e>=t.senseStrands.length?!1===c&&(c=!0,u=0):d=Math.min(d,Math.min(...i.y.filter((t=>t<0)))),c){const t=Math.min(...i.x)-u,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 f=h[e].indexOf("M V30 BEGIN ATOM");f=h[e].indexOf("\n",f);let p=f,m=f;for(let t=0;t<n.natom;t++){p=h[e].indexOf("V30",p)+4,m=h[e].indexOf(" ",p);const n=parseInt(h[e].substring(p,m))+a;h[e]=h[e].slice(0,p)+n+h[e].slice(m),p=h[e].indexOf(" ",p)+1,p=h[e].indexOf(" ",p)+1,m=h[e].indexOf(" ",p);let r=Math.round(1e4*i.x[t])/1e4;h[e]=h[e].slice(0,p)+r+h[e].slice(m),p=h[e].indexOf(" ",p)+1,m=h[e].indexOf(" ",p),r=Math.round(1e4*i.y[t])/1e4,h[e]=h[e].slice(0,p)+r+h[e].slice(m),p=h[e].indexOf("\n",p)+1}const g=h[e].indexOf("M V30 END ATOM");r+=h[e].substring(f+1,g);let y=h[e].indexOf("M V30 BEGIN BOND");y=h[e].indexOf("\n",y),p=y,m=y;for(let t=0;t<n.nbond;t++){p=h[e].indexOf("V30",p)+4,m=h[e].indexOf(" ",p);const t=parseInt(h[e].substring(p,m))+l;h[e]=h[e].slice(0,p)+t+h[e].slice(m),p=h[e].indexOf(" ",p)+1,p=h[e].indexOf(" ",p)+1,m=h[e].indexOf(" ",p);let n=parseInt(h[e].substring(p,m))+a;h[e]=h[e].slice(0,p)+n+h[e].slice(m),p=h[e].indexOf(" ",p)+1,m=Math.min(h[e].indexOf("\n",p),h[e].indexOf(" ",p)),n=parseInt(h[e].substring(p,m))+a,h[e]=h[e].slice(0,p)+n+h[e].slice(m),p=h[e].indexOf("\n",p)+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,u+=Math.max(...i.x)+5}const f=Math.ceil(s.length/4);i+="M V30 MDLV30/STEABS ATOMS=("+s.length+" -\n";for(let t=0;t<f;t++){i+="M V30 ";const e=t+1===f?s.length-4*(f-1):4;for(let n=0;n<e;n++)i+=n+1===e?t===f-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 Te(t){const e=_e(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 u=t.indexOf("M V30 BEGIN ATOM");u=t.indexOf("\n",u);let c=u;for(let r=0;r<n;r++)u=t.indexOf("V30",u)+4,u=t.indexOf(" ",u)+1,u=t.indexOf(" ",u)+1,c=t.indexOf(" ",u)+1,c=t.indexOf(" ",c),u=(t=t.slice(0,u)+e.x[r]+" "+e.y[r]+t.slice(c)).indexOf("\n",u)+1;return t}function Ee(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 _e(t){const e=Ee(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 Ie(t,e,n){if(""===t)return"";const r=n.createFormatDetector(t).getFormat();if(!r)return"";let o="";try{o=new xe(t,e,r).convert()}catch(t){const e=le(t);console.error(e)}return o}function Ne(t,e,n,r,o){const i=[t,e,n].filter((t=>""!==t.strand));return 1===i.length?Ie(i[0].strand,i[0].invert,o):Se({senseStrands:[Ie(t.strand,t.invert,o)],antiStrands:[Ie(e.strand,e.invert,o),Ie(n.strand,n.invert,o)].filter((t=>""!==t))},r)}const Me=["ss","as","as2"];class Oe{constructor(){this.th=Xr,this.onInput=new et.Subject,this.onInvalidInput=new et.Subject,this.inputBase=Object.fromEntries(Me.map((t=>{const e=M.input.textArea(t.toUpperCase(),{value:"",onValueChanged:()=>{this.onInput.next(),L()(e.root.getElementsByTagName("div")).css("padding-left","38px")}});return[t,e]}))),this.useChiralInput=M.input.bool("Use chiral",{value:!0}),this.saveAllStrandsInput=M.input.bool("Save as one entity",{value:!0}),M.tooltip.bind(this.saveAllStrandsInput.root,"Save SDF with all strands in one molfile"),this.directionInversion=Object.fromEntries(Me.map((t=>[t,!1]))),this.moleculeImgDiv=M.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=M.divH([n,this.moleculeImgDiv]);L()(r).addClass("st-structure-bottom");const o=M.divV([e,r]);return L()(o).addClass("st-structure-body"),o}getBoolInputsAndButton(){const t=M.buttonsInput([M.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=Ne(t,e,n,o,s)+"\n$$$$\n";else{const h=Ie(t.strand,t.invert,s),d=Ie(e.strand,e.invert,s),f=Ie(n.strand,n.invert,s);l=h+"\n> <Sequence>\nSense Strand\n$$$$\n",d&&(l+=d+"\n> <Sequence>\nAnti Sense\n$$$$\n"),f&&(l+=f+"\n> <Sequence>\nAnti Sense 2\n$$$$\n")}const u=new Date;function c(t){return t>=10?t.toString():"0"+t.toString()}y(`SequenceTranslator-${u.getFullYear()+"-"+c(u.getMonth()+1)+"-"+c(u.getDate())+"_"+c(u.getHours())+"-"+c(u.getMinutes())+"-"+c(u.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=M.divV(e);for(const t of e)L()(t).addClass("st-structure-bool-button-block");return n}getTableInput(t){const e=Object.fromEntries(Me.map((e=>[e,new de(this.inputBase[e],t.highlightInvalidSubsequence)]))),n=Object.fromEntries(Me.map(((t,e)=>{const n=0===e?"5′ → 3′":"3′ → 5′";return[t,M.input.choice(`${t.toUpperCase()} direction`,{value:n,items:["5′ → 3′","3′ → 5′"]})]})));Me.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(Me.map(((t,e)=>[t,r[e]]))),i=(Object.fromEntries(Me.map((t=>[t,M.label(o.get(t))]))),Object.fromEntries(Me.map((t=>{const n=M.icons.delete((()=>{e[t].inputBase.value=""})),r=M.button(n,(()=>{}));return M.tooltip.bind(r,`Clear ${t.toUpperCase()}`),[t,n]})))),s=M.form([],"st-structure-inputs"),a=M.divV([],"st-structure-clear-buttons"),l=M.form([],"st-direction-inputs");for(const t of Me)s.append(this.inputBase[t].root),a.append(i[t]),l.append(n[t].root);return M.divH([s,a,l])}getStrandData(){return Object.fromEntries(Me.map((t=>{const e=this.directionInversion[t];return[t,{strand:this.inputBase[t].value.replace(/\s*/g,""),invert:e}]})))}getMolfile(t,e,n){return Ne(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),L()(this.moleculeImgDiv).find("canvas").css("float","inherit")}}class Le extends F{constructor(t){super("Oligo Structure"),this.th=t,this.layout=new Oe}getContent(){return this.layout.getHtmlDivElement(this.th)}}var Re=n(2003);async function Pe(t){try{const e={overflowX:"scroll"},n=M.div([],{style:e}),o=_e(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,u=l*s,c=l*a,h=M.canvas(u*window.devicePixelRatio,c*window.devicePixelRatio);h.style.width=`${u}px`,h.style.height=`${c}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),M.dialog("Molecule").add(n).showModal(!0)}catch(t){const e=le(t);console.error(e)}}class Be{static async view(){const t=Xr.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 Pe(e)}))}}var De=n(3480),Fe=n(5067),ke=n(5254),He={};He.styleTagTransform=xt(),He.setAttributes=vt(),He.insert=yt().bind(null,"head"),He.domAPI=mt(),He.insertStyleElement=Ct(),ft()(ke.A,He),ke.A&&ke.A.locals&&ke.A.locals;const Ue=["Sequence"];class $e{constructor(t){this.th=t,this.inputFormats=Object.keys(Xr.jsonData.codesToHelmDict).concat(m.NO.HELM),this.seqHelper=Xr.seqHelper,this.onInput=new et.Subject,this.moleculeImgDiv=M.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=M.div([]),this.formatChoiceInput=M.input.choice("",{value:m.NO.HELM,items:this.inputFormats,onValueChanged:async(t,e)=>{this.format=t,this.updateTable(),await this.updateMolImg()}}),L()(this.formatChoiceInput.root.getElementsByTagName("select")[0]).css("width","20%"),this.sequenceInputBase=M.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=Ge.getInstance()}async getHtmlElement(){const t=this.constructSingleSequenceControls(),e=this.constructBulkTranslationControls(),n=M.box(M.panel([t,e,M.block([M.box(this.moleculeImgDiv)])]));return this.formatChoiceInput.value=this.format,this.updateTable(),await this.updateMolImg(),n}constructBulkTranslationControls(){const t=M.h1("Bulk");M.tooltip.bind(t,"Bulk translation from table input");const e=new Ve(this.eventBus).createUIComponents(),n=M.input.choice("Input format",{value:m.NO.AXOLABS,items:this.inputFormats,onValueChanged:t=>this.eventBus.selectInputFormat(t)}),r=M.input.choice("Output format",{value:Fe.qP,items:(0,De.OT)(this.th),onValueChanged:t=>this.eventBus.selectOutputFormat(t)}),o=this.createConvertBulkButton(),i=M.div([...e,n,r,o],"ui-form");return M.block25([t,i])}createConvertBulkButton(){const t=M.bigButton("Convert",(()=>this.processConvertBulkButtonClick()));return M.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,De.C6)(t,e,n,this.th))));if(n===Fe.qP||n===m.NO.HELM){a.semType=o.SEMTYPE.MACROMOLECULE;const t=n==Fe.qP?Re.Hi.FASTA:Re.Hi.HELM;a.meta.units=t;const e=this.seqHelper.getSeqHandler(a);(n==Fe.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=>R(t,this.th))),e=M.button("Get SDF",(()=>{this.saveMolfile()}),"Save structure as SDF"),n=M.button("Copy SMILES",(()=>{this.copySmiles()}),"Copy SMILES for the sequence"),r=M.div([this.formatChoiceInput]),o=M.button(M.icons.delete((()=>{t.inputBase.value=""})),(()=>{}));M.tooltip.bind(o,"Clear input");const i={format:r,textInput:t.root,clearBtn:o},s=M.table([i],(t=>[t.format,t.textInput,t.clearBtn]));s.classList.add("st-translator-input-table");const a=M.block([this.outputTableDiv,e,n]);return M.block75([M.h1("Single sequence"),s,a])}saveMolfile(){const t=new xe(this.sequence,!1,this.formatChoiceInput.value).convert()+"\n$$$$";y(this.sequence+".sdf",encodeURIComponent(t))}copySmiles(){const t=o.chem.convert(this.molfile,o.chem.Notation.MolBlock,o.chem.Notation.Smiles);navigator.clipboard.writeText(t).then((()=>r.shell.info(Fe.n_)))}updateTable(){this.outputTableDiv.innerHTML="";const t=this.format?this.th.createSequenceValidator(this.sequence).getInvalidCodeIndex(this.format):0,e=(0,De.bD)(this.sequence,t,this.format,this.th),n=[];for(const t of Object.keys(e)){const o="indexOfFirstInvalidChar"in e?M.divH([]):M.link(e[t],(()=>navigator.clipboard.writeText(e[t]).then((()=>r.shell.info(Fe.n_)))),Fe.U_,"");n.push({format:t,sequence:o})}const o=M.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 xe(t,!1,m.NO.AXOLABS).convert()}return new xe(this.sequence,!1,this.format).convert()}}class Ve{constructor(t){this.tableInputManager=new qe(t),this.columnInputManager=new je(t)}createUIComponents(){return[this.tableInputManager.getTableInputContainer(),this.columnInputManager.getColumnControlsContainer()]}}class qe{constructor(t){this.eventBus=t,this.availableTables=[],this.tableInputContainer=M.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 M.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=M.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 Ue.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),M.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 Ge{constructor(){this._tableSelection$=new et.BehaviorSubject(null),this._columnSelection=Object.fromEntries(Ue.map((t=>[t,new et.BehaviorSubject(null)]))),this._inputFormatSelection$=new et.BehaviorSubject(m.NO.AXOLABS),this._outputFormatSelection$=new et.BehaviorSubject(Fe.qP)}static getInstance(){return void 0===Ge._instance&&(Ge._instance=new Ge),Ge._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 ze extends F{constructor(t){super("Oligo Translator"),this.th=t,this.th=Xr,this.layout=new $e(this.th);const e=M.iconFA("book",Be.view,"View monomer library");this.topPanel=[e],this.view.setRibbonPanels([this.topPanel])}getContent(){return this.layout.getHtmlElement()}}class We extends F{constructor(t,e){super(t),this.content=e}getContent(){return Promise.resolve(this.content)}}class Ye extends D{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(ze),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/${Xr.name}/OligoToolkit/${t}`}setUrl(){this.multiView.path=this.getCurrentPanePath()}async constructView(){return this.multiView.tabs.onTabChanged.subscribe((()=>this.setUrl())),this.setUrl(),this.multiView}}var Ke=n(8070);function Je(t){const e=M.input.textArea("",{value:""});return{coloredInput:new de(e,t.highlightInvalidSubsequence),codes:t.jsonData.codesToSymbolsDict}}var Qe=n(9124),Xe=n(9192),Ze=n(8312),tn=n(1991),en=n.n(tn);const nn="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,rn=new Set,on="object"==typeof process&&process?process:{},sn=(t,e,n,r)=>{"function"==typeof on.emitWarning?on.emitWarning(t,e,n,r):console.error(`[${n}] ${e}: ${t}`)};let an=globalThis.AbortController,ln=globalThis.AbortSignal;if(void 0===an){ln=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(t,e){this._onabort.push(e)}},an=class{constructor(){e()}signal=new ln;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"!==on.env?.LRU_CACHE_IGNORE_AC_WARNING;const e=()=>{t&&(t=!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",e))}}Symbol("type");const un=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),cn=t=>un(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?hn:null:null;class hn extends Array{constructor(t){super(t),this.fill(0)}}class dn{heap;length;static#t=!1;static create(t){const e=cn(t);if(!e)return[];dn.#t=!0;const n=new dn(t,e);return dn.#t=!1,n}constructor(t,e){if(!dn.#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 fn{#e;#n;#r;#o;#i;#s;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#a;#l;#u;#c;#h;#d;#f;#p;#m;#g;#y;#b;#v;#w;#C;#A;#x;static unsafeExposeInternals(t){return{starts:t.#v,ttls:t.#w,sizes:t.#b,keyMap:t.#u,keyList:t.#c,valList:t.#h,next:t.#d,prev:t.#f,get head(){return t.#p},get tail(){return t.#m},free:t.#g,isBackgroundFetch:e=>t.#S(e),backgroundFetch:(e,n,r,o)=>t.#T(e,n,r,o),moveToTail:e=>t.#E(e),indexes:e=>t.#_(e),rindexes:e=>t.#I(e),isStale:e=>t.#N(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:u,noDisposeOnSet:c,noUpdateTTL:h,maxSize:d=0,maxEntrySize:f=0,sizeCalculation:p,fetchMethod:m,memoMethod:g,noDeleteOnFetchRejection:y,noDeleteOnStaleGet:b,allowStaleOnFetchRejection:v,allowStaleOnFetchAbort:w,ignoreFetchAbort:C}=t;if(0!==e&&!un(e))throw new TypeError("max option must be a nonnegative integer");const A=e?cn(e):Array;if(!A)throw new Error("invalid max value: "+e);if(this.#e=e,this.#n=d,this.maxEntrySize=f||this.#n,this.sizeCalculation=p,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.#A=!!m,this.#u=new Map,this.#c=new Array(e).fill(void 0),this.#h=new Array(e).fill(void 0),this.#d=new A(e),this.#f=new A(e),this.#p=0,this.#m=0,this.#g=dn.create(e),this.#a=0,this.#l=0,"function"==typeof l&&(this.#r=l),"function"==typeof u?(this.#o=u,this.#y=[]):(this.#o=void 0,this.#y=void 0),this.#C=!!this.#r,this.#x=!!this.#o,this.noDisposeOnSet=!!c,this.noUpdateTTL=!!h,this.noDeleteOnFetchRejection=!!y,this.allowStaleOnFetchRejection=!!v,this.allowStaleOnFetchAbort=!!w,this.ignoreFetchAbort=!!C,0!==this.maxEntrySize){if(0!==this.#n&&!un(this.#n))throw new TypeError("maxSize must be a positive integer if specified");if(!un(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#M()}if(this.allowStale=!!a,this.noDeleteOnStaleGet=!!b,this.updateAgeOnGet=!!i,this.updateAgeOnHas=!!s,this.ttlResolution=un(r)||0===r?r:1,this.ttlAutopurge=!!o,this.ttl=n||0,this.ttl){if(!un(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#O()}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=>!rn.has(t))(t)&&(rn.add(t),sn("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",t,fn))}}getRemainingTTL(t){return this.#u.has(t)?1/0:0}#O(){const t=new hn(this.#e),e=new hn(this.#e);this.#w=t,this.#v=e,this.#L=(n,r,o=nn.now())=>{if(e[n]=0!==r?o:0,t[n]=r,0!==r&&this.ttlAutopurge){const t=setTimeout((()=>{this.#N(n)&&this.#R(this.#c[n],"expire")}),r+1);t.unref&&t.unref()}},this.#P=n=>{e[n]=0!==t[n]?nn.now():0},this.#B=(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=nn.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.#u.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.#N=o=>{const i=e[o],s=t[o];return!!s&&!!i&&(n||r())-i>s}}#P=()=>{};#B=()=>{};#L=()=>{};#N=()=>!1;#M(){const t=new hn(this.#e);this.#l=0,this.#b=t,this.#D=e=>{this.#l-=t[e],t[e]=0},this.#F=(t,e,n,r)=>{if(this.#S(e))return 0;if(!un(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),!un(n))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return n},this.#k=(e,n,r)=>{if(t[e]=n,this.#n){const n=this.#n-t[e];for(;this.#l>n;)this.#H(!0)}this.#l+=t[e],r&&(r.entrySize=n,r.totalCalculatedSize=this.#l)}}#D=t=>{};#k=(t,e,n)=>{};#F=(t,e,n,r)=>{if(n||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#_({allowStale:t=this.allowStale}={}){if(this.#a)for(let e=this.#m;this.#U(e)&&(!t&&this.#N(e)||(yield e),e!==this.#p);)e=this.#f[e]}*#I({allowStale:t=this.allowStale}={}){if(this.#a)for(let e=this.#p;this.#U(e)&&(!t&&this.#N(e)||(yield e),e!==this.#m);)e=this.#d[e]}#U(t){return void 0!==t&&this.#u.get(this.#c[t])===t}*entries(){for(const t of this.#_())void 0===this.#h[t]||void 0===this.#c[t]||this.#S(this.#h[t])||(yield[this.#c[t],this.#h[t]])}*rentries(){for(const t of this.#I())void 0===this.#h[t]||void 0===this.#c[t]||this.#S(this.#h[t])||(yield[this.#c[t],this.#h[t]])}*keys(){for(const t of this.#_()){const e=this.#c[t];void 0===e||this.#S(this.#h[t])||(yield e)}}*rkeys(){for(const t of this.#I()){const e=this.#c[t];void 0===e||this.#S(this.#h[t])||(yield e)}}*values(){for(const t of this.#_())void 0===this.#h[t]||this.#S(this.#h[t])||(yield this.#h[t])}*rvalues(){for(const t of this.#I())void 0===this.#h[t]||this.#S(this.#h[t])||(yield this.#h[t])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,e={}){for(const n of this.#_()){const r=this.#h[n],o=this.#S(r)?r.__staleWhileFetching:r;if(void 0!==o&&t(o,this.#c[n],this))return this.get(this.#c[n],e)}}forEach(t,e=this){for(const n of this.#_()){const r=this.#h[n],o=this.#S(r)?r.__staleWhileFetching:r;void 0!==o&&t.call(e,o,this.#c[n],this)}}rforEach(t,e=this){for(const n of this.#I()){const r=this.#h[n],o=this.#S(r)?r.__staleWhileFetching:r;void 0!==o&&t.call(e,o,this.#c[n],this)}}purgeStale(){let t=!1;for(const e of this.#I({allowStale:!0}))this.#N(e)&&(this.#R(this.#c[e],"expire"),t=!0);return t}info(t){const e=this.#u.get(t);if(void 0===e)return;const n=this.#h[e],r=this.#S(n)?n.__staleWhileFetching:n;if(void 0===r)return;const o={value:r};if(this.#w&&this.#v){const t=this.#w[e],n=this.#v[e];if(t&&n){const e=t-(nn.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.#_({allowStale:!0})){const n=this.#c[e],r=this.#h[e],o=this.#S(r)?r.__staleWhileFetching:r;if(void 0===o||void 0===n)continue;const i={value:o};if(this.#w&&this.#v){i.ttl=this.#w[e];const t=nn.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=nn.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 u=this.#F(t,e,n.size||0,s);if(this.maxEntrySize&&u>this.maxEntrySize)return a&&(a.set="miss",a.maxEntrySizeExceeded=!0),this.#R(t,"set"),this;let c=0===this.#a?void 0:this.#u.get(t);if(void 0===c)c=0===this.#a?this.#m:0!==this.#g.length?this.#g.pop():this.#a===this.#e?this.#H(!1):this.#a,this.#c[c]=t,this.#h[c]=e,this.#u.set(t,c),this.#d[this.#m]=c,this.#f[c]=this.#m,this.#m=c,this.#a++,this.#k(c,u,a),a&&(a.set="add"),l=!1;else{this.#E(c);const n=this.#h[c];if(e!==n){if(this.#A&&this.#S(n)){n.__abortController.abort(new Error("replaced"));const{__staleWhileFetching:e}=n;void 0===e||i||(this.#C&&this.#r?.(e,t,"set"),this.#x&&this.#y?.push([e,t,"set"]))}else i||(this.#C&&this.#r?.(n,t,"set"),this.#x&&this.#y?.push([n,t,"set"]));if(this.#D(c),this.#k(c,u,a),this.#h[c]=e,a){a.set="replace";const t=n&&this.#S(n)?n.__staleWhileFetching:n;void 0!==t&&(a.oldValue=t)}}else a&&(a.set="update")}if(0===r||this.#w||this.#O(),this.#w&&(l||this.#L(c,r,o),a&&this.#B(a,c)),!i&&this.#x&&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.#p];if(this.#H(!0),this.#S(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(void 0!==t)return t}}finally{if(this.#x&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#o?.(...e)}}}#H(t){const e=this.#p,n=this.#c[e],r=this.#h[e];return this.#A&&this.#S(r)?r.__abortController.abort(new Error("evicted")):(this.#C||this.#x)&&(this.#C&&this.#r?.(r,n,"evict"),this.#x&&this.#y?.push([r,n,"evict"])),this.#D(e),t&&(this.#c[e]=void 0,this.#h[e]=void 0,this.#g.push(e)),1===this.#a?(this.#p=this.#m=0,this.#g.length=0):this.#p=this.#d[e],this.#u.delete(n),this.#a--,e}has(t,e={}){const{updateAgeOnHas:n=this.updateAgeOnHas,status:r}=e,o=this.#u.get(t);if(void 0!==o){const t=this.#h[o];if(this.#S(t)&&void 0===t.__staleWhileFetching)return!1;if(!this.#N(o))return n&&this.#P(o),r&&(r.has="hit",this.#B(r,o)),!0;r&&(r.has="stale",this.#B(r,o))}else r&&(r.has="miss");return!1}peek(t,e={}){const{allowStale:n=this.allowStale}=e,r=this.#u.get(t);if(void 0===r||!n&&this.#N(r))return;const o=this.#h[r];return this.#S(o)?o.__staleWhileFetching:o}#T(t,e,n,r){const o=void 0===e?void 0:this.#h[e];if(this.#S(o))return o;const i=new an,{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 u(i.signal.reason);const h=c;return this.#h[e]===c&&(void 0===r?h.__staleWhileFetching?this.#h[e]=h.__staleWhileFetching:this.#R(t,"fetch"):(n.status&&(n.status.fetchUpdated=!0),this.set(t,r,a.options))),r},u=r=>{const{aborted:o}=i.signal,s=o&&n.allowStaleOnFetchAbort,a=s||n.allowStaleOnFetchRejection,l=a||n.noDeleteOnFetchRejection,u=c;if(this.#h[e]===c&&(l&&void 0!==u.__staleWhileFetching?s||(this.#h[e]=u.__staleWhileFetching):this.#R(t,"fetch")),a)return n.status&&void 0!==u.__staleWhileFetching&&(n.status.returnedStale=!0),u.__staleWhileFetching;if(u.__returned===u)throw r};n.status&&(n.status.fetchDispatched=!0);const c=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),u(t)))),h=Object.assign(c,{__abortController:i,__staleWhileFetching:o,__returned:void 0});return void 0===e?(this.set(t,h,{...a.options,status:void 0}),e=this.#u.get(t)):this.#h[e]=h,h}#S(t){if(!this.#A)return!1;const e=t;return!!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof an}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:u=this.noUpdateTTL,noDeleteOnFetchRejection:c=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:h=this.allowStaleOnFetchRejection,ignoreFetchAbort:d=this.ignoreFetchAbort,allowStaleOnFetchAbort:f=this.allowStaleOnFetchAbort,context:p,forceRefresh:m=!1,status:g,signal:y}=e;if(!this.#A)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:u,noDeleteOnFetchRejection:c,allowStaleOnFetchRejection:h,allowStaleOnFetchAbort:f,ignoreFetchAbort:d,status:g,signal:y};let v=this.#u.get(t);if(void 0===v){g&&(g.fetch="miss");const e=this.#T(t,v,b,p);return e.__returned=e}{const e=this.#h[v];if(this.#S(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.#N(v);if(!m&&!o)return g&&(g.fetch="hit"),this.#E(v),r&&this.#P(v),g&&this.#B(g,v),e;const i=this.#T(t,v,b,p),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.#u.get(t);if(void 0!==s){const e=this.#h[s],a=this.#S(e);return i&&this.#B(i,s),this.#N(s)?(i&&(i.get="stale"),a?(i&&n&&void 0!==e.__staleWhileFetching&&(i.returnedStale=!0),n?e.__staleWhileFetching:void 0):(o||this.#R(t,"expire"),i&&n&&(i.returnedStale=!0),n?e:void 0)):(i&&(i.get="hit"),a?e.__staleWhileFetching:(this.#E(s),r&&this.#P(s),e))}i&&(i.get="miss")}#$(t,e){this.#f[e]=t,this.#d[t]=e}#E(t){t!==this.#m&&(t===this.#p?this.#p=this.#d[t]:this.#$(this.#f[t],this.#d[t]),this.#$(this.#m,t),this.#m=t)}delete(t){return this.#R(t,"delete")}#R(t,e){let n=!1;if(0!==this.#a){const r=this.#u.get(t);if(void 0!==r)if(n=!0,1===this.#a)this.#V(e);else{this.#D(r);const n=this.#h[r];if(this.#S(n)?n.__abortController.abort(new Error("deleted")):(this.#C||this.#x)&&(this.#C&&this.#r?.(n,t,e),this.#x&&this.#y?.push([n,t,e])),this.#u.delete(t),this.#c[r]=void 0,this.#h[r]=void 0,r===this.#m)this.#m=this.#f[r];else if(r===this.#p)this.#p=this.#d[r];else{const t=this.#f[r];this.#d[t]=this.#d[r];const e=this.#d[r];this.#f[e]=this.#f[r]}this.#a--,this.#g.push(r)}}if(this.#x&&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.#I({allowStale:!0})){const n=this.#h[e];if(this.#S(n))n.__abortController.abort(new Error("deleted"));else{const r=this.#c[e];this.#C&&this.#r?.(n,r,t),this.#x&&this.#y?.push([n,r,t])}}if(this.#u.clear(),this.#h.fill(void 0),this.#c.fill(void 0),this.#w&&this.#v&&(this.#w.fill(0),this.#v.fill(0)),this.#b&&this.#b.fill(0),this.#p=0,this.#m=0,this.#g.length=0,this.#l=0,this.#a=0,this.#x&&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 mn(t){window.$monomerHover=t}function gn(t,e){let n=t["substruct-providers"];n||(n=t["substruct-providers"]=[]),n.push(e),t["substruct-providers"]=n}var yn=n(6077),bn=n(3561),vn=n(9235);const wn="MonomerHoverLinks";function Cn(t,e){let n=t[wn];n||(n=t[wn]=[]),n.push(e),t[wn]=n}function An(t,e){try{const n=t.tableColumn;if(!n)return;const r=function(t){return t.temp[wn]??[]}(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 xn=n(6717),Sn=n(6694),Tn=n(4229),En=n(5174);function _n(t,e=!0){const[n,o]=(0,Xe.AP)(t);return Xr.logger.error(n,void 0,o),e&&r.shell.error(n),[n,o]}async function In(){return(await(0,l.pj)()).getAvaliableLibraryNames()}const Nn={symbol:"Short Name",name:"Medium Name",smiles:"SMILES"},Mn=[{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"}],On="Get HELM",Ln="Chirality engine",Rn="Highlight monomers",Pn="Poly Tool Conversion",Bn="Poly Tool Enumeration",Dn="Rules used";var Fn=n(5412);async function kn(t){await Xr.initPromise;try{const e=await async function(t){const e=[],n=()=>{for(const t of e)t.unsubscribe()};try{const[i,s]=await Promise.all([In(),(0,Qe.b2)()]),a=t&&t.rowIndex>=0?t.value:"\n\n\n 22 24 0 0 0 0 0 0 0 0999 V2000\n 0.3128 -0.7509 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n 0.3128 0.0740 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -0.4054 -1.1623 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -1.1081 -0.7509 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -0.4054 0.4877 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0\n -1.1081 0.0740 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -1.8175 -1.1623 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n 1.0222 0.4877 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -1.8175 0.4877 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -2.5292 -0.7509 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n 1.0222 1.3127 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n 1.7227 1.7263 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -0.4054 -1.9896 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0\n -2.5292 0.0740 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n 2.4544 1.3127 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n 1.7406 0.0740 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n 1.0222 -1.1623 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0\n 2.4544 0.4877 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -1.8175 -1.9896 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0\n -3.2453 0.4877 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0\n 3.1670 1.7285 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0\n 1.7149 2.5513 0.0000 R# 0 0 0 0 0 0 0 0 0 0 0 0\n 2 1 2 0 0 0 0\n 3 1 1 0 0 0 0\n 4 3 1 0 0 0 0\n 5 2 1 0 0 0 0\n 6 5 1 0 0 0 0\n 7 4 1 0 0 0 0\n 8 2 1 0 0 0 0\n 9 6 1 0 0 0 0\n 10 7 2 0 0 0 0\n 11 8 2 0 0 0 0\n 12 11 1 0 0 0 0\n 13 3 2 0 0 0 0\n 14 9 2 0 0 0 0\n 15 18 1 0 0 0 0\n 16 8 1 0 0 0 0\n 17 1 1 0 0 0 0\n 18 16 2 0 0 0 0\n 19 7 1 0 0 0 0\n 20 14 1 0 0 0 0\n 6 4 2 0 0 0 0\n 15 12 2 0 0 0 0\n 14 10 1 0 0 0 0\n 15 21 1 0 0 0 0\n 12 22 1 0 0 0 0\nM RGP 1 22 1\nM END";let u=await(async()=>o.chem.isMolBlock(a)?a:await r.functions.call("Chem:convertMolNotation",{molecule:a,sourceNotation:t?.column.getTag(o.TAGS.UNITS)??o.chem.Notation.Unknown,targetNotation:o.chem.Notation.MolBlock}))();const c=new o.chem.Sketcher(o.chem.SKETCHER_MODE.EXTERNAL);c.syncCurrentObject=!1,c.onChanged.subscribe((t=>{u=c.getMolFile()})),c.root.classList.add("ui-input-editor"),c.root.style.marginTop="3px",c.setMolFile(u);const h=M.input.choice("Library to use",{value:null,items:i});c.root.setAttribute("style","min-width:250px!important;"),c.root.setAttribute("style","max-width:250px!important;"),h.input.setAttribute("style","min-width:250px!important;");const d=M.div([c.root,h.root]);e.push(r.events.onCurrentCellChanged.subscribe((()=>{const t=r.shell.tv.dataFrame.currentCell;t.column.semType===o.SEMTYPE.MOLECULE&&c.setValue(t.value)})));const f=async()=>{try{const t=c.getMolFile();if(void 0===t||""===t)r.shell.warning("PolyTool: no molecule was provided");else if(t.includes("R#")){const e=await async function(t,e){const n=await async function(t){const e=await(0,l.pj)(),n=await e.readSingleLibraryByName(t);return n?n.getMonomerSymbolsByType("PEPTIDE"):(Xr.logger.error(`Monomer library '${t}' not found.`),[])}(e),o=await async function(t){const e=await(0,l.pj)(),n=await e.readSingleLibraryByName(t);if(!n)return Xr.logger.error(`Monomer library '${t}' not found.`),{};const r=n.getMonomerSymbolsByType("PEPTIDE");return new Array(r.length),n.getMonomerMolsByPolymerType("PEPTIDE")}(e),i=new Array(n.length),s=await r.functions.call("Chem:getRdKitModule"),a=s.get_mol(t),u=a.get_smiles();a.delete();const c=new Array(n.length);for(let t=0;t<n.length;t++){const e=o[n[t]],r=s.get_mol(e);c[t]=r.get_smiles(),r.delete()}for(let t=0;t<n.length;t++){let e=null;try{const n=`${`${u}.${c[t]}`.replaceAll("[1*]C","C([1*])").replaceAll("[1*]c","c([1*])").replaceAll("[1*]O","O([1*])").replaceAll("[1*]N","N([1*])")}`.replaceAll("([1*])","9").replaceAll("[1*]","9");e=s.get_mol(n,JSON.stringify({mappedDummiesAreRGroups:!0}));const r=e.get_v3Kmolblock();i[t]=r}catch(e){i[t]=""}finally{e?.delete()}}return i}(t,h.value),n=o.Column.fromStrings("Enumerated",e),i=o.DataFrame.fromColumns([n]);r.shell.addTableView(i)}else r.shell.warning("PolyTool: no R group was provided")}catch(t){_n(t)}},p=M.dialog(Bn).add(d).onOK((()=>{f().finally((()=>{n()}))})).onCancel((()=>{n()}));return e.push(p.onClose.subscribe((()=>{n()}))),p.history((()=>({mol:c.getMolFile(),screenLibrary:h.value})),(t=>{c.setMolFile(t.mol),h.value=t.screenLibrary})),p}catch(t){throw n(),t}}(t);e.show({resizable:!0})}catch(t){r.shell.warning("To run PolyTool Enumeration, sketch the molecule and specify the R group to vary")}}async function Hn(t,e,n,i,s,a){const l=o.TaskBarProgressIndicator.create("PolyTool converting...");try{const l=(t,e)=>t?t.columns.getUnusedName(e):e,u=await(0,Qe.b2)(),c=t.dataFrame,h=await(0,Sn.Q4)(a),[d,f,p]=(0,Tn.b)(t.toList(),h,u),m=l(c,`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=Re.Hi.HELM,g.setTag(o.TAGS.CELL_RENDERER,"helm"),e&&c&&c.columns.add(g,!0);const y=await(0,xn.j)(),b=await(0,Ze.Q)(),v=await(0,En.A)(h),w=g.temp;w[".mm.cellRenderer.overriddenLibrary"]=v,g.temp=w;const C=await(0,Fn.m)(g,d,f,i,s,n,v,y,b);return C.name=l(c,`molfile(${t.name})`),C.semType=o.SEMTYPE.MOLECULE,c&&(c.columns.add(C,!0),await r.data.detectSemanticTypes(c)),function(t,e,n,r,o,i,s){const a=new fn({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=en().count(0).take(s.length).map((t=>({position:t,symbol:s.getCanonical(t),biotype:a}))).toArray(),u=n.alphabet,c=u==Re.YI.RNA||u==Re.YI.DNA?"RNA":"PEPTIDE",h=(0,yn.eM)([l],c,u,r,i);return(0,bn.gU)(l,h,u,c).monomers}(t,e)),s}const u={targetCol:n,handler:(t,n,o)=>{if(!t||!o.grid||!e.dataFrame)return!0;const i=o.grid,a=t.tableRowIndex,u=t.gridRow,c=i.cell(o.name,u),h=s[u],d=pn();if(!d||d&&(d.dataFrameId!=e.dataFrame?.id||d.gridRowIdx!=u||d.seqColName!=e.name||d.seqPosition!=n?.position)){if(d&&(mn(null),d.gridCell.render()),!n)return mn(null),!0;mn({gridCell:c,dataFrameId:e.dataFrame.id,gridRowIdx:u,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,vn.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)}}),c.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,vn.H)(o.values(),r):void 0}};Cn(t.temp,u),gn(n.temp,u)}(t,g,C,v,b,y,p),[g,C]}finally{l.close()}}var Un=n(6197);class $n extends o.InputBase{constructor(t,e){super(M.input.column(t,e).dart,e?.onValueChanged),this.options=e}setColumnInputTable(t){M.input.setColumnInputTable(this,t,this.options?.filter)}}M.input.column2=function(t,e){return new $n(t,e)};var Vn=n(1296),qn=n(3820);class jn 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=Gn(t.get("Monomers",n));e.push({position:r,monomers:o})}}return e}(this.grid.dataFrame)}constructor(t,e,n){super(),this.name=t,this.subs=[],this.dataFrameSubs=[],this.caption=t??"",this.root.classList.add("ui-input-polytool-pos-grid"),this.root.append(this.gridHost=M.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=M.div(M.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"}}))})),this.updateGridHeight(t??this.grid.dataFrame.rowCount+.7),this.subs.push(M.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 jn(t,n,e)}updateGridHeight(t){const e=this.grid.colHeaderHeight+t*this.grid.props.rowHeight+6+2;this.grid.root.style.height=`${e}px`}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 Gn(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 zn 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)}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=Gn(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.subs=[],this.dataFrameSubs=[],this.caption=t??"",this.root.classList.add("ui-input-polytool-pos-grid"),this.root.append(this.gridHost=M.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=M.div(M.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"}}))})),this.updateGridHeight(t??this.grid.dataFrame.rowCount+.7),this.subs.push(M.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 zn(t,n,e)}updateGridHeight(t){const e=this.grid.colHeaderHeight+t*this.grid.props.rowHeight+6+2;this.grid.root.style.height=`${e}px`}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 Wn=n(6307);async function Yn(t){await Xr.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-en().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 en().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 a=Vn.aK.Single;const u=()=>{for(const t of s)t.unsubscribe();i.placeholders.detach()};try{const c=await(0,l.pj)(),h=c.getMonomerLib(),d=await(0,Ze.Q)(),f=o.DataFrame.fromColumns([]),[p,m]=await Promise.all([In(),(0,Qe.b2)()]),g=m.buildMonomersFuncsFromLib(h),y=t=>{let e,n;if(t&&t.rowIndex>=0&&t?.column.semType==o.SEMTYPE.MACROMOLECULE)e=d.getSeqHandler(t.column).getValue(t.rowIndex),n=e.tags["polytool-data-role"]??"macromolecule";else{const t=o.Column.fromList(o.COLUMN_TYPE.STRING,"seq",[qn.d]);t.semType=o.SEMTYPE.MACROMOLECULE,o.DataFrame.fromColumns([t]),t.meta.units=Re.Hi.HELM,e=d.getSeqHandler(t).getValue(0),n="macromolecule"}return[e,n]};let b,v,[w,C]=y(t),A=null;const x=M.divText("",{style:{marginLeft:"8px",marginTop:"2px"}}),S=M.divText("",{style:{color:"red"}});i={macromolecule:m.createHelmInput("Macromolecule",{editable:!1,editorOptions:{drawOptions:{monomerNumbering:1,getMonomer:(t,e)=>{const n=t;if("ATOM"!==n.T)return g.getMonomer(t,e);try{if(w.isDna()||w.isRna()){const t=w.getSplittedWithSugarsAndPhosphates().getCanonical(n.bio.continuousId-1);return g.getMonomer(n.bio.type,t)}{const t=w.getSplitted().getCanonical(n.bio.continuousId-1);return g.getMonomer(n.bio.type,t)}}catch(n){return g.getMonomer(t,e)}}}}}),placeholders:await jn.create("Placeholders",{showAddNewRowIcon:!0,showRemoveRowIcon:!0,showRowHeader:!1,showCellTooltip:!1}),enumeratorType:M.input.choice("Enumerator type",{value:a,items:Object.values(Vn.aK)}),placeholdersBreadth:await zn.create("Breadth",{showAddNewRowIcon:!0,showRemoveRowIcon:!0,showRowHeader:!1,showCellTooltip:!1}),keepOriginal:M.input.bool("Keep original",{value:!1}),toAtomicLevel:M.input.bool("To atomic level",{value:!1,onValueChanged:(t,e)=>{_()}}),generateHelm:M.input.bool(On,{value:!0}),chiralityEngine:M.input.bool(Ln,{value:!1}),highlightMonomers:M.input.bool(Rn,{value:!1}),rules:{header:M.inlineText([Dn]),form:await(v=new Sn._v(Sn.MU,Sn.yy,".json",{onValueChanged:t=>{b=t}})).getForm()},trivialNameCol:M.input.column2("Trivial name",{table:t?.dataFrame,filter:e=>e.type===o.COLUMN_TYPE.STRING&&e!=t?.column,onValueChanged:()=>{const e=i.trivialNameCol.value;let n=null;t&&e&&(n={value:e.get(t.rowIndex),colName:e.name}),A=n,x.textContent=A?`Original ID: ${A.value}`:""},nullable:!0}),library:M.input.choice("Monomer Library",{items:p,value:p[0],nullable:!0})},i.library.root.style.setProperty("display","none"),i.trivialNameCol.addOptions(x);let T=null;i.placeholders.addValidator((t=>{const e=[];try{if(i.enumeratorType.value===Vn.aK.Library){setTimeout((()=>{I()}),10);const t=i.placeholders.placeholdersValue;if(t.length>1)return"Only one placeholder is allowed for Library mode";if(1===t.length){if(null==t[0].position)return"Position is required for Library mode";if(t[0].position>i.macromolecule.molValue.atoms.length)return`There is no monomer at position ${t[0].position+1}.`}return null}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,Un.Y)(e);for(const e of n.monomers){const n=h.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}`),T=e.length>0?e.join("\n"):null}catch(t){const[e,n]=_n(t,!1);T=e}return setTimeout((()=>{I()}),0),T})),i.library.addValidator((t=>i.enumeratorType.value!==Vn.aK.Library||i.library.value?null:"Monomer Library is required for this enumerator type")),i.library.onChanged.subscribe((()=>{i.enumeratorType.value===Vn.aK.Library&&i.placeholders.setMonomersValue(0,i.library.value??"")})),i.enumeratorType.onChanged.subscribe((t=>{const e=i.enumeratorType.value===Vn.aK.Library;i.library.root.style.setProperty("display",e?"flex":"none");try{if(a!==Vn.aK.Library&&e||a===Vn.aK.Library&&!e){const t=1===i.placeholders.placeholdersValue.length?i.placeholders.placeholdersValue[0].position:null;i.placeholders.clearInput(),i.placeholdersBreadth.clearInput(),e&&null!=t&&i.placeholders.addPosition(t,i.library.value??"")}}catch(t){_n(t,!1)}a=i.enumeratorType.value})),s.push(i.macromolecule.onMouseMove.subscribe((t=>{try{Xr.logger.debug(`${n}, placeholdersInput.onMouseMove()`);const e=t.offsetX,r=t.offsetY,o=i.macromolecule.molValue,s=m.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=M.divText(n.join(", "));i.macromolecule.showTooltip(e,s),t.preventDefault(),t.stopPropagation()}}}catch(t){_n(t,!1)}}))),s.push(i.macromolecule.onClick.subscribe((t=>{try{Xr.logger.debug(`${n}, placeholdersInput.onClick()`);const e=t.offsetX,r=t.offsetY,o=i.macromolecule.molValue,s=m.getHoveredAtom(e,r,o,i.macromolecule.root.clientHeight);if(s){const t=s._parent.atoms.indexOf(s);String(t+1);let e="";i.enumeratorType.value===Vn.aK.Library&&(i.placeholders.clearInput(),e=i.library.value??""),i.placeholders.addPosition(t,e)}}catch(t){_n(t)}}))),s.push(i.placeholders.onChanged.subscribe((()=>{E()}))),s.push(M.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&&([w,C]=y(),O(w,C,t))}))),i.macromolecule.root.style.setProperty("min-width","250px","important");const E=()=>{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.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()},I=()=>{const t=T,e=S;t?(e.innerText=t,e.style.removeProperty("display")):(e.innerText="",e.style.setProperty("display","none"))},N=t=>{t?(i.trivialNameCol.setColumnInputTable(t),i.trivialNameCol.root.style.removeProperty("display")):(i.trivialNameCol.setColumnInputTable(f),i.trivialNameCol.root.style.setProperty("display","none")),e&&e()},O=(t,e,n)=>{i.macromolecule.value=t;const r=n?.dataFrame;N(r)};O(w,C,t),_();const L=async()=>{try{const t=i.macromolecule.stringValue,e=en().enumerate(i.macromolecule.molValue.atoms).filter((([t,e])=>t.highlighted)).map((([t,e])=>e)).toArray();if(i.enumeratorType.value===Vn.aK.Library){if(0===e.length)return void r.shell.warning("PolyTool: position for enumeration was not selected");if(!i.library.value)return void r.shell.warning("PolyTool: No monomer library was selected")}if(void 0===t||""===t)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(`${Bn}: placeholders are empty`);await(0,Qe.b2)();const e=i.placeholders.placeholdersValue;let n=i.enumeratorType.value;if(n===Vn.aK.Library){if(1!==e.length)return void r.shell.warning("Only one placeholder is allowed for Library mode");if(!e[0].monomers||!p.includes(e[0].monomers[0]))return void r.shell.warning("Valid Monomer Library is required for this enumerator type");const t=e[0].monomers[0],o=await c.readSingleLibraryByName(t);if(!o)return void r.shell.warning(`Monomer Library '${t}' was not found`);const i=o.getMonomerSymbolsByType("PEPTIDE");e[0].monomers=i,n=Vn.aK.Single}const o={placeholders:e,type:n,breadthPlaceholders:i.placeholdersBreadth.placeholdersBreadthValue,keepOriginal:i.keepOriginal.value},s=i.toAtomicLevel.value,a=await Kn(t,C,A,o,!!s&&{generateHelm:i.generateHelm.value,chiralityEngine:i.chiralityEngine.value,highlightMonomers:i.highlightMonomers.value,rules:await v.getActive()},m);r.shell.addTableView(a)}}catch(t){_n(t)}},R=M.dialog({title:Bn,showFooter:!0}).add(i.macromolecule.root).add(M.divH([M.divV([i.placeholders.root,i.enumeratorType.root,i.library.root],{style:{width:"50%"}}),M.divV([i.placeholdersBreadth.root],{style:{width:"50%"}})],{style:{width:"100%"}})).add(M.divH([M.divV([i.trivialNameCol.root,i.keepOriginal.root],{style:{width:"50%"}}),M.divV([M.divH([i.toAtomicLevel.root,i.generateHelm.root]),M.divH([i.chiralityEngine.root,i.highlightMonomers.root]),i.rules.header,i.rules.form],{style:{width:"50%"}})],{style:{width:"100%"}})).add(S).onOK((()=>{L()}));return s.push(R.onClose.subscribe((()=>{u()}))),R.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,trivialNameCol:i.trivialNameCol.stringValue,keepOriginal:i.keepOriginal.value,toAtomicLevel:i.toAtomicLevel.value,generateHelm:i.generateHelm.value,chiralityEngine:i.chiralityEngine.value,highlightMonomers:i.highlightMonomers.value,rules:b,library:i.library.value})),(t=>{i.enumeratorType.value=t.enumeratorType??Vn.aK.Single,i.placeholders.stringValue=t.placeholders,i.placeholdersBreadth.stringValue=t.placeholdersBreadth,i.trivialNameCol.stringValue=t.trivialNameCol,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,v.setActive(t.rules),i.library.value=t.library})),R}catch(t){throw u(),t}}(t,s);let a=!0;M.onSizeChanged(i.root).subscribe((()=>{if(a){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`,a=!1}s()})),s(),Xr.logger.debug("PolyToolEnumerateHelmUI: dialog before show"),i.show({width:Math.max(350,.7*e),resizable:!0}),Xr.logger.debug("PolyToolEnumerateHelmUI: dialog after show")}catch(u){const[c,h]=(0,Xe.AP)(u);Xr.logger.error(c,void 0,h)}}async function Kn(t,e,n,i,s,a){const u=o.TaskBarProgressIndicator.create("PolyTool enumerating...");try{const u=await(0,l.pj)(),c=await(0,xn.j)(),h=u.getMonomerLib(),d=(0,qn.o)(t,n?.value??"",i);let f;switch(e){case"macromolecule":f=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=Wn.s.fromHelm(n,a);t[e]=r.getNotation()}f=o.Column.fromList(o.COLUMN_TYPE.STRING,"Enumerated",t),f.semType=o.SEMTYPE.MACROMOLECULE,f.setTag("polytool-data-role","template"),to.applyNotationProviderForCyclized(f,"-");break}}const p=o.DataFrame.fromColumns([f]);if(await r.data.detectSemanticTypes(p),"template"==e&&to.applyNotationProviderForCyclized(f,"-"),s){let t;if("macromolecule"===e){t=f;const e=await a.seqHelper.helmToAtomicLevel(t,s.chiralityEngine,s.highlightMonomers);p.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==Re.YI.RNA||s.alphabet==Re.YI.DNA,l=s.isHelm()&&a,u=!s.isHelm()&&a,c=t=>null==t?null:l?i?t:Math.floor(t/3):u&&i?3*t+1:t,h=i?await r.getHelmToMolfileConverter(n):null,d=new fn({max:100});function f(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=en().count(0).take(t.length).map((e=>({position:e,symbol:t.getCanonical(e),biotype:r}))).toArray(),a=s.alphabet,l=a==Re.YI.RNA||a==Re.YI.DNA?"RNA":"PEPTIDE",u=(0,yn.eM)([i],l,a,n,o);return(0,bn.gU)(i,u,a,l).monomers}}(t,e)),a}const p={targetCol:e,handler:(e,r,o)=>{const i=o.grid,s=e.tableRowIndex,a=e.gridRow,l=i.cell(o.name,a),u=pn();if(!u||u&&(u.dataFrameId!=t.dataFrame.id||u.gridRowIdx!=a||u.seqColName!=t.name||u.seqPosition!=r?.position)){if(u&&(mn(null),u.gridCell.render()),!r)return mn(null),!0;mn({gridCell:l,dataFrameId:t.dataFrame.id,gridRowIdx:a,seqColName:t.name,seqPosition:c(r?.position)??-1,getSubstruct:()=>{if(!r||"*"===r.symbol)return;const e=f(t,s);if(!e)return;const o=e.get(c(r?.position));return o?(0,vn.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=f(t,r);return o?(0,vn.H)(o.values(),n):void 0}};return Cn(t.temp,p),gn(e.temp,p),p}(t,n,h,a.seqHelper,c,!0)}else"template"===e&&(t=(await Hn(f,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]));p.columns.add(t)}return p}finally{u.close()}}var Jn,Qn=n(3151);class Xn{constructor(t){this.rawLib=t}isValid(){return this.rawLib.every((t=>"object"==typeof t&&Object.values(Nn).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={...Qn.pe};Object.entries(Nn).forEach((([n,r])=>{const o=t[r];e[n]=o}));let n="smiles";const r=t[Nn[n]],o=new Zn(r),i=o.getCappedSmiles();return e[n]=i,n="rgroups",e[n]=tr.getRGroups(o.getNumberOfRGroups()),n="molfile",e[n]=new er(o.getSmilesWithRGroups()).getMolfile(),e}}class Zn{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 tr{constructor(){}static getRGroups(t){return Mn.slice(0,t)}}class er{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 nr{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 Xn(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"}(Jn||(Jn={}));class rr{constructor(t){this.call=t,this.ruleInputs=new Sn._v(Sn.MU,Sn.yy,".json")}async initInputs(){const t=t=>this.call.inputParams[t],e=await this.ruleInputs.getForm();this.inputs={table:(()=>{const e=t(Jn.table);return M.input.table(e.property.caption,{value:e.value})})(),seqCol:(()=>{const e=t(Jn.seqCol);return M.input.column(e.property.caption,{value:e.value,table:e.value.dataFrame})})(),generateHelm:M.input.forProperty(t(Jn.generateHelm).property),chiralityEngine:M.input.forProperty(t(Jn.chiralityEngine).property),rules:{header:M.inlineText([Dn]),form:e}}}static async create(t){const e=new rr(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=M.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)=>{M.dialog({title:Pn}).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")}}class or{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 ir extends or{constructor(t,e,n){super(),this.gridCol=t,this.tableCol=e,this.logger=n,this.subs=[],this.dirty=!0,this.destroyed=!1,this.viewerId=++ir.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(0,Ke.PE)(this._onRendered,(()=>{}),(()=>{this.invalidate()}),t,`${n}, ${e}`),this.errors.length>0){const t=this.errors[0];throw this.errors=[],t}this.logger.debug(`${n}, end`)}}ir.viewerCounter=-1;const sr="rgb(100,100,100)",ar="rgb(0,0,0)",lr=s.zS;var ur,cr,hr;!function(t){t.maxMonomerLength=".mm.cellRenderer.maxMonomerLength"}(ur||(ur={})),function(t){t.applyToBackground=".m.cellRenderer.applyToBackground"}(cr||(cr={})),function(t){t.MSA="MSA",t.classic="classic"}(hr||(hr={}));const dr=new class{constructor(){this.color=sr,this.pivot=0,this.left=!1,this.transparencyRate=0,this.separator="",this.last=!1,this.drawStyle=hr.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 fr(t,e,n,r,i,s,a){var l,u,c;const h={...dr,...a};if(h.isMultiLineContext){t.textBaseline="middle",t.textAlign="center";let o=e;null!=h.maxLengthOfMonomer&&(o=lr(o,h.maxLengthOfMonomer));const a=Math.max(.1,1-(h.transparencyRate??0));t.globalAlpha=a;const l=t.measureText(o),u=l.fontBoundingBoxAscent+l.fontBoundingBoxDescent,c=r+(s-u)/2+l.fontBoundingBoxAscent;let d=h.color??sr;return d&&d!==sr||(d=ar),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,c),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),f=h.last?"":h.separator;h.drawStyle===hr.MSA&&(f="");let p=!0,m=!0,g="difference";if(null!=h.gridCell&&null!=h.gridCell.cell.column&&(p=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=lr(d,h.maxLengthOfMonomer));const y=d+f;(l=h.monomerTextSizeMap)[y]??(l[y]=t.measureText(y));let b=h.monomerTextSizeMap[y];(u=h.monomerTextSizeMap)[d]??(u[d]=t.measureText(d));let v=h.monomerTextSizeMap[d].width;const w=s/2-(b.fontBoundingBoxAscent+b.fontBoundingBoxDescent)/2+1;(c=h.monomerTextSizeMap)[f]??(c[f]=t.measureText(f));const C=h.monomerTextSizeMap[f].width;function A(e,i){let a=p?h.color:ar;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===hr.classic&&(t.fillText(d,n+e,r+w),t.fillStyle="#808080",t.fillText(f,n+i,r+w)),h.drawStyle===hr.MSA&&t.fillText(d,n+e,r+w),t.globalAlpha=1}b=b.width,h.drawStyle===hr.MSA&&(v=h.maxWord[h.wordIdx],b=h.maxWord[h.wordIdx]);const x=(h.maxWord[h.wordIdx]??0)-(h.maxWord[0]??0);if(h.left||b>i)return A(x,x+v),n+x+v+C;{const t=(i-b)/2;return A(t,t+v),n+x+t+v}}var pr=n(3599);const mr="rgb(100,100,100)";class gr extends ir{get separatorWidth(){return this.props?.fontCharWidth?this.props?.fontCharWidth:5}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.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=[Re.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===Re.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,Xe.AP)(t);this.logger.error(e,void 0,n)}const{lineHeight:s,monomerSpacing:a}=this.calculateFontBasedSpacing(t),l=e-2*this.padding;let u=0;const c=[];if(r.length>0)for(let e=o;e<r.length;e++){const n=r.getOriginal(e),o=this.props.monomerToShort(n,i);c.push({text:o,posIdx:e}),u=Math.max(u,t.measureText(o).width)}if(0===c.length)return{lineLayouts:[],lineHeight:s};const h=u;let d=Math.floor((l+a)/(h+a));d=Math.max(1,d);const f=n-2*this.padding,p=Math.max(0,Math.floor(f/s)),m=[];let g=0;for(let t=0;t<p&&g<c.length;t++){const e=[];for(let t=0;t<d&&g<c.length;t++){const n=c[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,Ze.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,Xe.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 u=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,u+=a,u>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[Re.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 u=this.tableCol,c=this.positionShift;t.save();try{const a=this.seqHelper.getSeqHandler(u);let h=this.monomerLengthLimit;if(ur.maxMonomerLength in u.tags){const t=parseInt(u.getTag(ur.maxMonomerLength));h=!isNaN(t)&&t?t:50}if(".mm.cellRenderer.maxMonomerLength"in u.temp){const t=u.temp[".mm.cellRenderer.maxMonomerLength"],e="number"==typeof t?t:parseInt(t);h=!isNaN(e)&&e?e:50}if("1"===u.temp[".mm.cellRenderer.settingsChanged"]||this.monomerLengthLimit!=h){let t=0;const e=8;t=u.temp[".mm.cellRenderer.gapLength"]??t,this.setMonomerLengthLimit(h),this.setSeparatorWidth(a.isMsa()?e:t),u.temp[".mm.cellRenderer.settingsChanged"]="0",this.dirty=!0}const d=s.cell.rowIndex,f=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 p=u.meta.units,m=u.getTag(Re.gp.aligned),g=u.getTag(Re.gp.separator)??"",y=l?a.getSplitted(d):a.splitter(f);let b=hr.classic;m?.includes("MSA")&&p===Re.Hi.SEPARATOR&&(b=hr.MSA);const v=u.temp["reference-sequence"],w=this.tableCol.temp["current-word"],C=(()=>{const t=(0,a.splitter)(null!=v&&""!==v?v:w??"");return en().count(0).take(t.length).slice(c).map((e=>t.getCanonical(e))).toArray()})(),A=Number.parseInt(u.getTag(Re.gp.selectedPosition)??"-200");if(this.shouldUseMultilineRendering(u)){const l=[],d=this.calculateMultiLineLayoutDynamic(t,r,i,y,c,h);let f=n+this.padding;1===d.lineLayouts.length&&(f=n+(i-d.lineHeight)/2);for(const r of d.lineLayouts){const i=f+r.lineIdx*d.lineHeight;for(const h of r.elements){const f=e+h.x,p=h,m=p.posIdx,g=y.getCanonical(m);let b=mr;const v=this.getMonomerLib();v&&(b=v.getMonomerTextColor(a.defaultBiotype,g));let w=0;if(s.tableRowIndex!==u.dataFrame.currentRowIdx&&C.length>0){const t=m-c;t>=0&&t<C.length&&g===C[t]&&(w=.7)}l.push({lineIdx:r.lineIdx,monomerIdx:m-c,bounds:new o.Rect(h.x,i-n,h.width,d.lineHeight),sequencePosition:m}),fr(t,p.om,f,i,h.width,d.lineHeight,{color:b,isMultiLineContext:!0,transparencyRate:w,selectedPosition:isNaN(A)||A<1?void 0:A,wordIdx:m})}}null!==s.tableRowIndex&&this._cellBounds.set(s.tableRowIndex,l)}else{this._leftThreeDotsPadding=this.shouldRenderShiftedThreeDots(c)?t.measureText("...").width:0;let[,o]=this.getCellMonomerLengths(s.tableRowIndex,r);l||(o=this.getSummedMonomerLengths(this.getCellMonomerLengthsForSeqValue(f,r)));const u=this.props.separatorWidth+1*this.props.fontCharWidth,d=Math.min(y.length,Math.ceil(r/u)+c);for(let l=c;l<d;++l){const u=l<y.length?y.getOriginal(l):a.defaultGapOriginal,d=l<y.length?y.getCanonical(l):a.defaultGapOriginal;let f=mr;this.getMonomerLib()&&(f=this.getMonomerLib().getMonomerTextColor(a.defaultBiotype,d));const p=l===y.length-1,m={color:f,pivot:0,left:!0,transparencyRate:0,separator:(y?.graphInfo?.disjointSeqStarts?.indexOf(l+1)??0)>0?"|":g,last:p,drawStyle:b,maxWord:o,wordIdx:l-c,gridCell:s,referenceSequence:C,maxLengthOfMonomer:h,monomerTextSizeMap:this._monomerLengthMap,logger:this.logger,selectedPosition:isNaN(A)||A<1?void 0:A-c};fr(t,u,e+this.padding+this._leftThreeDotsPadding,n,r,i,m)}if(this.shouldRenderShiftedThreeDots(c)){const a={color:mr,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};fr(t,"...",e+this.padding,n,r,i,a)}}}catch(t){const[e,n]=(0,Xe.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 u=this.seqHelper.getSeqHandler(this.tableCol),c=u.getSplitted(t.tableRowIndex);if(null!==a&&a>=0&&a+r<c.length){const n=u.alphabet??Re.YI.UN,o={position:a,biotype:n===Re.YI.RNA||n===Re.YI.DNA?pr.o.NUCLEOTIDE:pr.o.AA,symbol:c.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):M.divText("Monomer library is not available")}i.push(s),M.tooltip.show(M.divV(i),e.x+16,e.y+16),An(t,o)}else-1===a?M.tooltip.show(M.divText(`${Math.min(r,c.length)} hidden monomers`),e.x+16,e.y+16):M.tooltip.hide(),An(t,null)}}class yr extends gr{constructor(t,e,n,r){super(t,e,Xr.logger,n,(()=>{const t=r.getSeqHandler(e),{font:n,fontWidth:o}=gr.getFontSettings(e);return{seqHandler:t,font:n,fontCharWidth:o,separatorWidth:11,monomerToShort:Re.zS}}))}onMouseMove(t,e){super.onMouseMove(t,e)}}class br{get defaultGapOriginal(){return""}constructor(t,e){this.separator=t,this.helmHelper=e,this.separatorSplitter=(0,Re.dh)(this.separator),this.splitter=this._splitter.bind(this)}setUnits(){}_splitter(t){const e=this.separatorSplitter(t);return new vr(en().count(0).take(e.length).map((t=>e.getOriginal(t))).toArray(),i.b9[i.Hi.SEPARATOR])}getHelm(t,e){return Wn.s.fromSeparator(t,this.helmHelper).getHelm()}createCellRendererBack(t,e){const n=new yr(t,e,4,this.helmHelper.seqHelper);return n.init().then((()=>{})),n}}class vr 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 wr(){return await to.oligoToolkitApp()}async function Cr(){await to.init()}async function Ar(){return await to.oligoTranslatorApp()}async function xr(){return await to.oligoPatternApp()}async function Sr(){return await to.oligoStructureApp()}async function Tr(){return await to.getTranslationHelper()}function Er(){return to.getCodeToWeightsMap()}function _r(t){return to.validateSequence(t)}function Ir(t,e){return to.getMolfileFromGcrsSequence(t,e)}function Nr(t){return to.linkStrands(t)}async function Mr(){await to.demoTranslateSequence()}async function Or(){await to.demoOligoPattern()}async function Lr(){await to.demoOligoStructure()}async function Rr(t,e,n){return await to.translateOligonucleotideSequence(t,e,n)}async function Pr(){await to.polyToolConvertTopMenu()}async function Br(t){return await to.getPolyToolConvertEditor(t)}async function Dr(t,e,n,r,o){return await to.polyToolConvert2(t,e,n,r,o)}async function Fr(){await to.polyToolEnumerateHelmTopMenu()}async function kr(){await to.polyToolEnumerateChemTopMenu()}async function Hr(t,e){await to.polyToolColumnChoice(t,e)}async function Ur(t){await to.createMonomerLibraryForPolyTool(t)}async function $r(){await to.ptEnumeratorHelmApp()}async function Vr(){await to.ptEnumeratorChemApp()}async function qr(t){await to.getPtHelmEnumeratorDialog(t)}async function jr(t){await to.getPtChemEnumeratorDialog(t)}async function Gr(t,e,n,r){return await to.enumerateSingleHelmSequence(t,e,n,r)}async function zr(t,e){return await to.enumerateSingleHelmSequenceWithNaturalAAs(t,e)}async function Wr(){await to.getPolyToolCombineDialog()}function Yr(t,e){to.applyNotationProviderForCyclized(t,e)}var Kr=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},Jr=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},Qr=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 Xr=new P({debug:!0});let Zr=null;class to{static async oligoToolkitApp(){await Xr.initLibData();const t=await async function(t){const e={"Mermadesynthesis:merMadeSynthesis":{tabName:"SYNTHESIZE",parameters:Je(t)}},n={};for(const[t,o]of Object.entries(e)){let e;try{e=await r.functions.call(t,o.parameters);const i=new We(o.tabName,e);i.initView(),n[o.tabName]=()=>i.getView()}catch(e){console.warn(`Plugin ${t} not loaded, reason:`,e);continue}}return n}(Xr);if(!t)throw new Error("External app view factories not loaded");const e=new Ye(t,Xr);return await e.getAppView()}static async init(){return null===Zr&&Xr.startInit(Zr=async function(){const[t]=await Promise.all([(0,Qe.b2)()]);Xr.completeInit(t)}()),Zr}static async oligoTranslatorApp(){return await eo("Oligo Translator")}static async oligoPatternApp(){return await eo("Oligo Pattern")}static async oligoStructureApp(){return await eo("Oligo Structure")}static async getTranslationHelper(){return await Xr.initLibData(),Xr}static getCodeToWeightsMap(){const t=Xr.monomerLibWrapper.getCodesToWeightsMap();return Object.fromEntries(t)}static validateSequence(t){const e=Xr.createSequenceValidator(t),n=Xr.createFormatDetector(t).getFormat();return null!==n&&e.isValidSequence(n)}static getMolfileFromGcrsSequence(t,e){return new xe(t,e,"GCRS").convert()}static linkStrands(t){return Se(t,!0)}static async demoTranslateSequence(){await async function(){await b((async()=>{const t=await to.oligoTranslatorApp();r.shell.addView(t)}))}()}static async demoOligoPattern(){await async function(){await b((async()=>{const t=await to.oligoPatternApp();r.shell.addView(t)}))}()}static async demoOligoStructure(){await async function(){await b((async()=>{const t=await to.oligoStructureApp();r.shell.addView(t),["Afcgacsu","Afcgacsu","Afcgacsu"].forEach((async(t,e)=>{await async function(t,e){await(0,Ke.cb)(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 Xr.initLibData(),Xr.createFormatConverter(t,e).convertTo(n)}static async polyToolConvertTopMenu(){await async function(){await Xr.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=>Xr.seqHelper.getSeqHandler(t).notation===Re.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=M.input.column("Column",{table:n.dataFrame,value:n,filter:t=>s.includes(t)}),l=M.input.bool(On,{value:!0});M.tooltip.bind(l.root,"Add HELM column");const u=M.input.bool("Linearize",{value:!0});M.tooltip.bind(u.root,"Make representation linear if possible");const c=M.input.bool(Ln,{value:!0}),h=M.input.bool(Rn,{value:!0});let d;const f=new Sn._v(Sn.MU,Sn.yy,".json",{onValueChanged:t=>{d=t}}),p=M.inlineText([Dn]);M.tooltip.bind(p,"Add or specify rules to use");const m=await f.getForm(),g=M.divV([a,l,u,c,h,p,m]),y=async()=>{try{const t=await f.getActive();await Hn(a.value,l.value,u.value,c.value,h.value,t)}catch(t){_n(t)}},b=M.dialog(Pn).add(g).onOK((()=>{y()}));return t.push(b.onClose.subscribe((()=>{e()}))),b.history((()=>({generateHelm:l.value,chiralityEngine:c.value,rules:d})),(t=>{l.value=t.generateHelm,c.value=t.chiralityEngine,f.setActive(t.rules)})),b}catch(t){throw e(),t}}(),t?.show()}catch(t){const[e,n]=(0,Xe.AP)(t);r.shell.warning("To run PolyTool Conversion, open a dataframe with macromolecules"),Xr.logger.error(e,void 0,n)}}()}static async getPolyToolConvertEditor(t){const e=await rr.create(t);return await e.showDialog()}static async polyToolConvert2(t,e,n,r,o){return(await Hn(e,n,!1,r,!1,o))[0]}static async polyToolEnumerateHelmTopMenu(){await Yn(r.shell.tv?.dataFrame.currentCell)}static async polyToolEnumerateChemTopMenu(){kn()}static async polyToolColumnChoice(t,e){var n;(function(t){t.semType=o.SEMTYPE.MACROMOLECULE,t.setTag("aligned","SEQ"),t.setTag("alphabet",Re.YI.PT)})(n=e),n.meta.units=Re.Hi.SEPARATOR,n.setTag("separator","-"),await r.data.detectSemanticTypes(t)}static async createMonomerLibraryForPolyTool(t){const e=await t.readAsString(),n=new nr(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 Yn()}static async ptEnumeratorChemApp(){kn()}static async getPtHelmEnumeratorDialog(t){return Yn(t)}static async getPtChemEnumeratorDialog(t){return kn(t)}static async enumerateSingleHelmSequence(t,e,n,r=!1){return await Kn(t,"macromolecule",null,{type:Vn.aK.Single,placeholders:e.map(((t,e)=>({position:t,monomers:n[e]})))},!!r&&{generateHelm:!0,chiralityEngine:!0,highlightMonomers:!1,rules:[]},Xr.helmHelper)}static async enumerateSingleHelmSequenceWithNaturalAAs(t,e=!1){const n=(0,Re.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 to.enumerateSingleHelmSequence(t,r,o,e)}static async getPolyToolCombineDialog(){!async function(){const t=[],e=M.divV([]),n=i=>{const s=(()=>{const t=M.divH([]),e=M.input.table("Table",{value:void 0,tooltipText:"Table with sequences"}),n=M.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=M.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=M.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 u=t[i];u?e.insertBefore(s.root,u.root):e.appendChild(s.root),t.splice(i,0,s)};n(0);const i=M.input.string("Separator",{value:"-",tooltipText:"Separator for sequences",nullable:!1});M.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 u=0;const c=l.reduce(((t,e)=>t*e.length),1);if(c>1e7)return void r.shell.error("Too many combinations. Maximum allowed is 10M");const h=new Array(c).fill(null),d=(t,e)=>{if(e===l.length)return void(h[u++]=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 f=o.DataFrame.fromColumns([o.Column.fromStrings("Combined Sequences",h)]);f.name="Combined Sequences",await f.meta.detectSemanticTypes(),await r.data.detectSemanticTypes(f),r.shell.addTableView(f)})).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,t.tags["polytool-data-role"]="template",t.temp[a.notationProvider]=new br(e,Xr.helmHelper)}}async function eo(t){await Xr.initLibData();const e=function(t,e){switch(t){case"Oligo Translator":return new ze(e);case"Oligo Pattern":return new ie(e);case"Oligo Structure":return new Le(e);default:throw new Error(`Unknown app name: ${t}`)}}(t,Xr);return await e.getAppView()}Kr([r.decorators.app({icon:"img/icons/toolkit.png",browsePath:"Peptides | Oligo Toolkit",name:"Oligo Toolkit"}),Jr("design:type",Function),Jr("design:paramtypes",[]),Jr("design:returntype",Promise)],to,"oligoToolkitApp",null),Kr([r.decorators.init(),Jr("design:type",Function),Jr("design:paramtypes",[]),Jr("design:returntype",Promise)],to,"init",null),Kr([r.decorators.app({icon:"img/icons/translator.png",browsePath:"Peptides | Oligo Toolkit",name:"Oligo Translator"}),Jr("design:type",Function),Jr("design:paramtypes",[]),Jr("design:returntype",Promise)],to,"oligoTranslatorApp",null),Kr([r.decorators.app({icon:"img/icons/pattern.png",browsePath:"Peptides | Oligo Toolkit",name:"Oligo Pattern"}),Jr("design:type",Function),Jr("design:paramtypes",[]),Jr("design:returntype",Promise)],to,"oligoPatternApp",null),Kr([r.decorators.app({icon:"img/icons/structure.png",browsePath:"Peptides | Oligo Toolkit",name:"Oligo Structure"}),Jr("design:type",Function),Jr("design:paramtypes",[]),Jr("design:returntype",Promise)],to,"oligoStructureApp",null),Kr([r.decorators.func({outputs:[{type:"object",name:"result"}]}),Jr("design:type",Function),Jr("design:paramtypes",[]),Jr("design:returntype",Promise)],to,"getTranslationHelper",null),Kr([r.decorators.func({outputs:[{type:"object",name:"result"}]}),Jr("design:type",Function),Jr("design:paramtypes",[]),Jr("design:returntype",Object)],to,"getCodeToWeightsMap",null),Kr([r.decorators.func(),Jr("design:type",Function),Jr("design:paramtypes",[String]),Jr("design:returntype",Boolean)],to,"validateSequence",null),Kr([r.decorators.func({name:"validateSequence"}),Jr("design:type",Function),Jr("design:paramtypes",[String,Boolean]),Jr("design:returntype",String)],to,"getMolfileFromGcrsSequence",null),Kr([r.decorators.func(),Qr(0,r.decorators.param({type:"object"})),Jr("design:type",Function),Jr("design:paramtypes",[Object]),Jr("design:returntype",String)],to,"linkStrands",null),Kr([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"}),Jr("design:type",Function),Jr("design:paramtypes",[]),Jr("design:returntype",Promise)],to,"demoTranslateSequence",null),Kr([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"}),Jr("design:type",Function),Jr("design:paramtypes",[]),Jr("design:returntype",Promise)],to,"demoOligoPattern",null),Kr([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"}),Jr("design:type",Function),Jr("design:paramtypes",[]),Jr("design:returntype",Promise)],to,"demoOligoStructure",null),Kr([r.decorators.func(),Jr("design:type",Function),Jr("design:paramtypes",[String,String,String]),Jr("design:returntype",Promise)],to,"translateOligonucleotideSequence",null),Kr([r.decorators.func({"top-menu":"Bio | PolyTool | Convert...",name:"polyToolConvert",description:"editor for Performing conversion of sequences in custom notation to molfiles"}),Jr("design:type",Function),Jr("design:paramtypes",[]),Jr("design:returntype",Promise)],to,"polyToolConvertTopMenu",null),Kr([r.decorators.editor(),Jr("design:type",Function),Jr("design:paramtypes",[o.FuncCall]),Jr("design:returntype",Promise)],to,"getPolyToolConvertEditor",null),Kr([r.decorators.func({editor:"SequenceTranslator:getPolyToolConvertEditor"}),Qr(1,r.decorators.param({options:{caption:"Sequence"}})),Qr(2,r.decorators.param({options:{initialValue:"true"}})),Qr(3,r.decorators.param({options:{initialValue:"true"}})),Qr(4,r.decorators.param({type:"object"})),Jr("design:type",Function),Jr("design:paramtypes",[o.DataFrame,o.Column,Boolean,Boolean,Array]),Jr("design:returntype",Promise)],to,"polyToolConvert2",null),Kr([r.decorators.func({"top-menu":"Bio | PolyTool | Enumerate HELM...",name:"polyToolEnumerateHelm",description:"Dialog for configuring enumeration of a HELM sequence"}),Jr("design:type",Function),Jr("design:paramtypes",[]),Jr("design:returntype",Promise)],to,"polyToolEnumerateHelmTopMenu",null),Kr([r.decorators.func({"top-menu":"Bio | PolyTool | Enumerate Chem...",name:"polyToolEnumerateChem",description:"Perform enumeration of a molecule using different fragments at specified positions"}),Jr("design:type",Function),Jr("design:paramtypes",[]),Jr("design:returntype",Promise)],to,"polyToolEnumerateChemTopMenu",null),Kr([r.decorators.func(),Qr(0,r.decorators.param({options:{description:"Input data table"}})),Jr("design:type",Function),Jr("design:paramtypes",[o.DataFrame,o.Column]),Jr("design:returntype",Promise)],to,"polyToolColumnChoice",null),Kr([r.decorators.func(),Jr("design:type",Function),Jr("design:paramtypes",[o.FileInfo]),Jr("design:returntype",Promise)],to,"createMonomerLibraryForPolyTool",null),Kr([r.decorators.func({meta:{icon:"img/icons/structure.png",browsePath:"Peptides | PolyTool"},tags:["app"],name:"HELM Enumerator"}),Jr("design:type",Function),Jr("design:paramtypes",[]),Jr("design:returntype",Promise)],to,"ptEnumeratorHelmApp",null),Kr([r.decorators.func({meta:{icon:"img/icons/structure.png",browsePath:"Peptides | PolyTool"},tags:["app"],name:"Chem Enumerator"}),Jr("design:type",Function),Jr("design:paramtypes",[]),Jr("design:returntype",Promise)],to,"ptEnumeratorChemApp",null),Kr([r.decorators.func({name:"Polytool Helm Enumerator dialog"}),Qr(0,r.decorators.param({type:"object",options:{nullable:!0}})),Jr("design:type",Function),Jr("design:paramtypes",[o.Cell]),Jr("design:returntype",Promise)],to,"getPtHelmEnumeratorDialog",null),Kr([r.decorators.func({name:"Polytool Chem Enumerator dialog"}),Qr(0,r.decorators.param({type:"object",options:{nullable:!0}})),Jr("design:type",Function),Jr("design:paramtypes",[o.Cell]),Jr("design:returntype",Promise)],to,"getPtChemEnumeratorDialog",null),Kr([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"}]}),Jr("design:type",Function),Jr("design:paramtypes",[String,Array,Array,Boolean]),Jr("design:returntype",Promise)],to,"enumerateSingleHelmSequence",null),Kr([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"}]}),Jr("design:type",Function),Jr("design:paramtypes",[String,Boolean]),Jr("design:returntype",Promise)],to,"enumerateSingleHelmSequenceWithNaturalAAs",null),Kr([r.decorators.func({name:"Combine Sequences","top-menu":"Bio | PolyTool | Combine Sequences..."}),Jr("design:type",Function),Jr("design:paramtypes",[]),Jr("design:returntype",Promise)],to,"getPolyToolCombineDialog",null),Kr([r.decorators.func({name:"applyNotationProviderForHarmonizedSequence"}),Qr(0,r.decorators.param({type:"column"})),Jr("design:type",Function),Jr("design:paramtypes",[o.Column,String]),Jr("design:returntype",void 0)],to,"applyNotationProviderForCyclized",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,u,c,h,d,f){const p=(await f.helmToAtomicLevel(t,l,u,h)).molCol,m=n.filter((t=>t)).length;if(c&&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 u=r.Column.fromStrings("helm",t);u.semType=r.SEMTYPE.MACROMOLECULE,u.meta.units=a.Hi.HELM,u.setTag(r.TAGS.CELL_RENDERER,"helm");const c=(await(0,i.pj)()).getMonomerLib();try{const t=await(0,s.C4)(r.DataFrame.create(0),u,c,f,d);l=0;for(let e=0;e<n.length;e++)n[e]&&(p.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)",""))}(p),p}},6307:(t,e,n)=>{"use strict";n.d(e,{s:()=>f});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,u,c]=[!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,c=h;break}if(l||!n&&t[h]!=o[r]+e)continue;a=!0,c=h;break}if(n)s=!0,l=!0,u=h;else if(t[h]==o[r]+e)s=!0,l=!0,u=h;else{if(t[h]!=i[r]+e)continue;s=!0,l=!!n,u=h}}return[s,a,l,u,c]}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,u,c,h,d]=a(t,o,!1,e,s,l);i&&u&&(c?n.push({firstIdx:h,secondIdx:d,ruleIdx:r}):n.push({firstIdx:d,secondIdx:h,ruleIdx:r}))}else{const[e,i,s,l,u]=a(t,o,!0);if(!e||!i)continue;s?n.push({firstIdx:l,secondIdx:u,ruleIdx:r}):n.push({firstIdx:u,secondIdx:l,ruleIdx:r})}}return n}function u(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,u=t[a].code;e[n[l].firstIdx]=e[n[l].firstIdx].replace(`(${u})`,""),e[n[l].secondIdx]=e[n[l].secondIdx].replace(`(${u})`,""),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 c(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,u=n[a].ruleIdx,c=t[u].code;e[s]=e[s].replace(`(${c})`,"")+`_${t[u].name}`,e[l]=e[l].replace(`(${c})`,"")+`_${t[u].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 f{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 f(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("-"),u=i[0].split(":"),c=i[1].split(":");l.push({fChain:n,sChain:o,fMonomer:(0,r.j)(parseInt(u[0]),n,a),sMonomer:(0,r.j)(parseInt(c[0]),o,a),fR:parseInt(u[1].replace("R","")),sR:parseInt(c[1].replace("R",""))})}return[l,a]}(t);return new f(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),u=i.replace(l,"").replaceAll("{","").replaceAll("}","");n[t]=l+u,n.push(u),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,c,h]=u(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:c[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]=c(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(9788);function s(t,e,n){const s=new Array(t.length),a=new Array(t.length),l=new Array(t.length);for(let u=0;u<t.length;u++)try{if(null==t[u])s[u]="";else{const r=o.s.fromSeparator(t[u],n);r.applyRules(e),a[u]=!(r.monomersUnderRules.length>1||r.linkagesUnderRules.length>0),s[u]=r.getHelm(),l[u]=r.posToPosUnderRules}}catch(t){const[e,n]=(0,r.AP)(t);i._package.logger.error(e,void 0,n),s[u]=""}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:()=>q,yy:()=>j,_v:()=>Q,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 u{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 c=n(9788),h=n(9124),d=n(4229),f=n(439),p=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 w(t){return t.replaceAll(/\[C\:\d\]/g,(t=>`[*:${t[3]}]`))}function C(t,e){const n=e?.firstReactantSmiles?w(e.firstReactantSmiles):"[*:1]C",r=e?.secondReactantSmiles?w(e.secondReactantSmiles):"[*:2]C",s=e?.productSmiles?w(e.productSmiles):"[*:1]CC[*:2]",a=e?.code,l=e?.firstMonomers??[],u=e?.secondMonomers??[],c=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"}),f=i.input.string("Second monomers",{value:u.join(","),nullable:!1,tooltipText:"Comma-separated list of monomers for the second reactant"}),p=i.input.string("Result monomer name",{value:c,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."}),C=()=>{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(C),g.addValidator(C),y.addValidator(C);const A=i.dialog(e?"Edit Reaction Rule":"Add Reaction Rule").add(h).add(p).add(d).add(f).add(m).add(g).add(y);A.addButton("Save",(()=>{const n=C();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:p.value,firstMonomers:d.value.split(",").map((t=>t.trim())).filter((t=>t.length>0)),secondMonomers:f.value.split(",").map((t=>t.trim())).filter((t=>t.length>0)),firstReactantSmiles:r,secondReactantSmiles:i,productSmiles:s,rowIndex:e?.rowIndex}),A.close()})),A.show()}const A="Links",x="Reactions";class S{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 S(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);c._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 c.PackageFunctions.applyNotationProviderForCyclized(s,"-"),s.semType=r.SEMTYPE.MACROMOLECULE,a.semType=r.SEMTYPE.MACROMOLECULE,a.meta.units=f.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 u=await(0,g.j)(),b=await(0,y.Q)();c.PackageFunctions.applyNotationProviderForCyclized(s,"-"),s.tags[r.TAGS.CELL_RENDERER]="Sequence",a.semType=r.SEMTYPE.MACROMOLECULE,a.meta.units=f.Hi.HELM,a.setTag(r.TAGS.CELL_RENDERER,"helm");const v=await(0,p.A)(this.rules),w=a.temp;w[".mm.cellRenderer.overriddenLibrary"]=v,a.temp=w;const C=await(0,m.m)(a,t,o,!0,!1,!1,v,u,b);return C.name="molfile(sequence)",C.semType=r.SEMTYPE.MOLECULE,l.columns.add(C),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;C((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),u=await this.getReactionExamplesGrid(),c=this.createGridDiv("Examples",u);this.substituteReactionGridDataFrame=async()=>{const t=await this.getReactionExamplesGrid();u.dataFrame=t.dataFrame},l.style.width="50%",c.style.width="50%";const h=i.divH([l,c]),d=i.divV([this.homoDimerInput,this.heteroDimerInput]),f=i.tabControl({Links:s,Reactions:h,Dimers:d},!1);i.tooltip.bind(f.getPane(A).header,"Specify rules to link monomers based on HELM notation"),i.tooltip.bind(f.getPane(x).header,"Specify rules to perform reactions within monomers"),i.tooltip.bind(f.getPane("Dimers").header,"Specify symbols for homodimeric and heterodimeric codes"),f.root.style.height="100%",f.root.style.width="100%",f.root.classList.add("rules-manager-form-tab-control"),f.header.style.marginBottom="10px";const p=i.divV([f.root]),m=[i.bigButton("Save",(()=>{this.save()})),i.button("Add rule",(()=>{const t=f.currentPane.name;t==A?this.getAddNewLinkRuleDialog():t==x&&C((t=>this.addSynthRulesFunc(t)))})),i.button("Remove rule",(()=>{const e=f.currentPane.name;if(e==A){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==x){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]),p.style.height="100%",p.style.alignItems="center",f.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(","),u=parseInt(a.value.substring(1)),c=parseInt(l.value.substring(1));this.addLinkRulesFunc({code:o,firstMonomers:i??"",secondMonomers:s??"",firstLinkingGroup:u,secondLinkingGroup:c,row:t?.row}),this.rules.setLinkRules(this.linkRuleDataFrame),this.linkCards=await this.rules.getLinkCards(),this.save()})).show()}}S.instances={};var T=n(5072),E=n.n(T),_=n(7825),I=n.n(_),N=n(7659),M=n.n(N),O=n(5056),L=n.n(O),R=n(540),P=n.n(R),B=n(1113),D=n.n(B),F=n(890),k={};k.styleTagTransform=D(),k.setAttributes=L(),k.insert=M().bind(null,"head"),k.domAPI=I(),k.insertStyleElement=P(),E()(F.A,k),F.A&&F.A.locals&&F.A.locals;var H=n(2003);class U{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 ${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%"}}),u=i.divH([],{style:{overflowX:"auto",width:"100%"}});this.resulting=i.divH([],{style:{overflowX:"auto",width:"100%",minHeight:"150px"}});const c=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([c,l,h,u,this.resulting]);this.cardsFirst=t.map((t=>new U(n.getMonomer("PEPTIDE",t),t))),this.cardsSecond=e.map((t=>new U(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()},u.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=H.Hi.HELM,l.setTag(r.TAGS.CELL_RENDERER,"helm");const u=await(0,g.j)(),c=await(0,y.Q)(),f=await(0,p.A)(this.rules),b=l.temp;l.temp=b;const v=(await(0,m.m)(l,n,s,!0,!1,!1,f,u,c)).get(0),w=v&&o.chem.checkSmiles(v)?o.chem.drawMolecule(v,200,200):o.chem.drawMolecule(v??"",200,200);v&&(w.style.cursor="pointer",w.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(w,"Click to expand"));const C=i.divV([i.h2("Example Result:"),i.h2(t[0])],{style:{width:"200px"}});i.empty(this.resulting),this.resulting.append(i.divH([C,w],{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 q="System:AppData/SequenceTranslator/polytool-rules/",j="Polytool",G="code",z="firstMonomers",W="secondMonomers",Y="name",K="firstLinkingGroup",J="secondLinkingGroup";class Q extends u{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 S.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=Q.ruleDescriptions)[e]??(t[e]=(async()=>{try{const t=JSON.parse(await o.dapi.files.readAsText(`${q}/${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 c._package.logger.error(`Failed to load rule ${e}: ${t?.toString?.()}`),console.error(t),i.divText(`Failed to load rule ${e}`)}})()),await Q.ruleDescriptions[e]})))}}}function X(t,e=30){return t.length<=e?t:`${t.substring(0,e)}...`}Q.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(G,t);e.setTag("friendlyName","Code");const n=r.Column.string(z,t);n.temp[".mm.cellRenderer.fontSize"]=16,n.setTag("friendlyName","First monomers"),n.semType=r.SEMTYPE.MACROMOLECULE,c.PackageFunctions.applyNotationProviderForCyclized(n,",");const o=r.Column.string(W,t);o.setTag("friendlyName","Second monomers"),o.temp[".mm.cellRenderer.fontSize"]=16,o.semType=r.SEMTYPE.MACROMOLECULE,c.PackageFunctions.applyNotationProviderForCyclized(o,",");const i=r.Column.int(K,t);i.setTag("friendlyName","First group");const s=r.Column.int(J,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 $(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(G,t);e.setTag("friendlyName","Code");const n=r.Column.string(z,t);n.setTag("friendlyName","First monomers");const o=r.Column.string(W,t);o.setTag("friendlyName","Second monomers"),n.semType=r.SEMTYPE.MACROMOLECULE,n.temp[".mm.cellRenderer.fontSize"]=16,c.PackageFunctions.applyNotationProviderForCyclized(n,","),o.semType=r.SEMTYPE.MACROMOLECULE,o.temp[".mm.cellRenderer.fontSize"]=16,c.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(">>"),u=t[0].split(".");s.set(r,u[0]),a.set(r,u[1]),l.set(r,t[1])}s.semType=r.SEMTYPE.MOLECULE,a.semType=r.SEMTYPE.MOLECULE,l.semType=r.SEMTYPE.MOLECULE;const u=r.DataFrame.fromColumns([i,s,a,l,e,n,o]);return{df:u,addNewRow:t=>{if(null!=t.rowIndex&&t.rowIndex<u.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;u.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(G),o=t.columns.byName(z),i=t.columns.byName(W),s=t.columns.byName(K),a=t.columns.byName(J);for(let t=0;t<e;t++){const e=o.get(t).split(","),l=i.get(t).split(","),u={code:r.get(t),firstMonomers:""!==e[0]?e:[],secondMonomers:""!==l[0]?l:[],firstLinkingGroup:s.get(t),secondLinkingGroup:a.get(t)};n[t]=u}this.linkRules=n}setSynthesisRules(t){const e=t.rowCount,n=new Array(e),r=t.columns.byName(G),o=t.columns.byName(z),i=t.columns.byName(W),s=t.columns.byName(Y),a=t.columns.byName("firstReactant"),l=t.columns.byName("secondReactant"),u=t.columns.byName("product");for(let t=0;t<e;t++){const e=`${a.get(t)}.${l.get(t)}>>${u.get(t)}`,c=o.get(t).split(","),h=i.get(t).split(","),d={code:r.get(t),firstMonomers:""!==c[0]?c:[],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(q),n=new Z(null,null,[],[]);for(let r=0;r<t.length;r++){const o=await e.readAsText(t[r].replace(q,"")),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:()=>c});var r=n(6717),o=n(1296),i=n(9192),s=n(4328),a=n(1991),l=n.n(a),u=n(4971);async function c(t){const e=(await(0,u.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 c={PEPTIDE:o};return e.override(c,"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("."),u=new Array(s),c=new Array(s),h=new Array(s),m=f(t,r),g=`${l[0]}>>[C:1]C`,y=`${l[1]}>>[C:2]C`,b=f(t,g),v=f(t,y);let w=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[w]=e,u[w]=`${i.symbol}_${o}`}catch(t){console.error(t)}w++}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[w]=e,u[w]=`${i.symbol}_${o}`}catch(t){console.error(t)}w++}let C=null;a[1]=a[1].replace("[C:1]","[1*]").replace("[C:2]","[2*]").replace("[C:3]","[3*]");let A="";try{C=t.get_mol(a[1]),A=C?.get_molblock()}catch(t){const[e,n]=(0,i.AP)(t);throw console.error(`Can not assemble monomer '${o}': ${e}.`),t}finally{C?.delete()}h[w]=A,u[w]=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]||!u[t])continue;const n={symbol:u[t],name:u[t],molfile:h[t],author:"",id:0,rgroups:p(e),smiles:"",polymerType:"PEPTIDE",monomerType:"Backbone",createDate:null};n.meta=Object.assign(n.meta??{},{colors:{default:{line:"#2083D5",text:"#2083D5",background:"#F2F2F5"}}}),u[t]=u[t],c[t]=n}return m.delete(),b.delete(),v.delete(),[u,c]}function d(t,e,n,r){let o=null,s=null,a=null,l=null,u="";try{o=new t.MolList,s=t.get_mol(e),o.append(s),a=n.run_reactants(o,1),l=a.get(0).next(),u=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 u}function f(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 p(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"}]}},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],u=o[i*s+n]=t.clone(),c=u.atoms[a].elem;u.atoms[a].elem=l;const h=c?.length>1?`[${c}]`:c,d=l?.length>1?`[${l}]`:l;u.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.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 u=[];n.breadthPlaceholders&&(u=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(u),n.keepOriginal&&(l=[a,...l]);const c=l.map((t=>[org.helm.webeditor.IO.getHelm(t),t.name]));return c}},1296:(t,e,n)=>{"use strict";var r;n.d(e,{J5:()=>o,aK:()=>r}),function(t){t.Single="single",t.Matrix="matrix",t.Library="library"}(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=n(9788);sequencetranslator=r})();
3
3
  //# sourceMappingURL=package.js.map