@datagrok/sequence-translator 1.1.5 → 1.2.0
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/CHANGELOG.md +6 -0
- package/dist/package-test.js +1 -1
- package/dist/package-test.js.map +1 -1
- package/dist/package.js +1 -1
- package/dist/package.js.map +1 -1
- package/img/icons/calculator.png +0 -0
- package/img/icons/pattern.png +0 -0
- package/img/icons/structure.png +0 -0
- package/img/icons/toolkit.png +0 -0
- package/img/icons/translator.png +0 -0
- package/package.json +1 -1
- package/src/demo/demo-st-ui.ts +26 -36
- package/src/model/helpers.ts +17 -0
- package/src/model/sequence-to-structure-utils/monomer-code-parser.ts +2 -5
- package/src/model/sequence-to-structure-utils/sdf-tab.ts +1 -1
- package/src/model/sequence-to-structure-utils/sequence-to-molfile.ts +20 -3
- package/src/package.ts +57 -37
- package/src/plugins/const.ts +4 -0
- package/src/plugins/mermade.ts +48 -0
- package/src/view/app-ui.ts +193 -0
- package/src/view/{tabs/axolabs.ts → apps/oligo-pattern.ts} +106 -26
- package/src/view/{tabs/sdf.ts → apps/oligo-structure.ts} +13 -14
- package/src/view/{tabs/main.ts → apps/oligo-translator.ts} +15 -11
- package/src/view/const/ui.ts +14 -0
- package/src/view/style/pattern-app.css +1 -0
- package/src/view/style/structure-app.css +39 -0
- package/src/view/style/translator-app.css +46 -0
- package/src/view/utils/colored-input/colored-text-input.ts +7 -6
- package/src/view/utils/molecule-img.ts +21 -10
- package/src/view/utils/router.ts +71 -0
- package/src/demo/handle-error.ts +0 -12
- package/src/view/const/view.ts +0 -10
- package/src/view/css/axolabs-tab.css +0 -1
- package/src/view/css/main-tab.css +0 -46
- package/src/view/css/sdf-tab.css +0 -39
- package/src/view/view.ts +0 -127
- /package/src/view/const/{main-tab.ts → oligo-translator.ts} +0 -0
- /package/src/view/{css → style}/colored-text-input.css +0 -0
package/dist/package.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var sequencetranslator;(()=>{"use strict";var t={622:(t,e,n)=>{n.d(e,{w:()=>i});class o{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 o=this.isWhitespace(n)?e:e-1;for(let t=0;t<o;t++)n=this.getNextColumnIdx(n);return n}parseAtomTypes(){const t=this.atomCount,e=new Array(t);let n=this.getAtomBlockIdx();for(let o=0;o<t;o++)n=this.shiftIdxToAtomType(n),e[o]=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 o=this.getAtomBlockIdx();for(let i=0;i<this.atomCount;i++){o=this.shiftIdxToXColumn(o);for(const r of[t,e,n])r[i]=this.parseFloatValue(o),o=this.getNextColumnIdx(o);o=this.getNextLineIdx(o)}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 o=new Uint16Array(2);o[0]=this.parseIntValue(e),e=this.getNextColumnIdx(e),o[1]=this.parseIntValue(e),t[n]=o,e=this.getNextLineIdx(e)}return t}parseBondTypes(){const t=this.bondCount,e=new Uint16Array(t);let n=this.getBondBlockIdx();for(let o=0;o<t;o++)n=this.shiftIdxToBondType(n),e[o]=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 i extends o{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 o=0;o<e;o++){if(n=this.shiftIdxToAtomType(n),t(this.fileContent.charCodeAt(n),n))return!0;n=this.getNextLineIdx(n)}return!1}}},577:(t,e,n)=>{n.d(e,{u:()=>i});var o=n(622);class i extends o.w{constructor(t){super(t),this.init(t)}shiftIdxToAtomType(t){return this.shiftIdxToSpecifiedColumn(t,4)}getCountsLineIdx(){return this.fileContent.indexOf("M V30 COUNTS ")}getAtomBlockIdx(){let t=this.fileContent.indexOf("M V30 BEGIN ATOM");return t=this.getNextLineIdx(t),t}shiftIdxToXColumn(t){let e=this.shiftIdxToAtomType(t);return this.isQuote(e)?(e=this.getNextIdenticalChar(e),e=this.getNextColumnIdx(e),e):this.shiftIdxToSpecifiedColumn(t,5)}shiftIdxToBondedAtomsPair(t){return this.shiftIdxToSpecifiedColumn(t,5)}shiftIdxToBondType(t){return this.shiftIdxToSpecifiedColumn(t,4)}getBondBlockIdx(){return this.getNextLineIdx(this.fileContent.indexOf("M V30 BEGIN BOND"))}static validate(t){return-1!==t.indexOf("V3000")&&-1!==t.indexOf("M END")}parseAtomAndBondCounts(){let t=this.fileContent.indexOf("M V30 COUNTS ")+14,e=this.fileContent.indexOf(" ",t+1);const 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))}}}},61:(t,e,n)=>{n.d(e,{gw:()=>i}),n(469),n(976);var o;function i(t){return e=this,n=void 0,i=function*(){yield new Promise((e=>setTimeout(e,t)))},new((o=void 0)||(o=Promise))((function(t,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(s,a)}l((i=i.apply(e,n||[])).next())}));var e,n,o,i}!function(t){t.notNull=function(t,e){if(null==t)throw new Error(`${null==e?"Value":e} not defined`)}}(o||(o={}))},604:(t,e,n)=>{function o(t){var e;return"string"==typeof t||t instanceof String?t:"$thrownJsError"in t?o(t.$thrownJsError):t instanceof Error?null!==(e=t.stack)&&void 0!==e?e:t.message:t.toString()}n.d(e,{O:()=>o})},973:(t,e,n)=>{n.d(e,{Z:()=>a});var o=n(537),i=n.n(o),r=n(645),s=n.n(r)()(i());s.push([t.id,".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.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 Mono', 'Roboto Mono Local', monospace;\n font-size: 12px;\n color: transparent;\n white-space: pre-wrap;\n word-wrap: break-word;\n}\n","",{version:3,sources:["webpack://./src/view/css/colored-text-input.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,0DAA0D;EAC1D,eAAe;EACf,kBAAkB;EAClB,qBAAqB;EACrB,qBAAqB;AACvB",sourcesContent:[".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.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 Mono', 'Roboto Mono Local', monospace;\n font-size: 12px;\n color: transparent;\n white-space: pre-wrap;\n word-wrap: break-word;\n}\n"],sourceRoot:""}]);const a=s},284:(t,e,n)=>{n.d(e,{Z:()=>a});var o=n(537),i=n.n(o),r=n(645),s=n.n(r)()(i());s.push([t.id,"/* Naming convention: class names should begin with st and tab name (main, axo, sdf) to avoid naming collitions */\n.st-main-input-table {\n width: 100%;\n}\n\n.st-main-input-table td:has(textarea) {\n width: 100%;\n padding-right: 20px;\n}\n\n.st-main-input-table td:has(select) {\n min-width: 120px;\n vertical-align: top;\n}\n\n.st-main-output-table {\n margin-top: 20px;\n margin-right: 20px;\n margin-bottom: 10px;\n}\n\n.st-main-output-table table {\n width: 100%;\n table-layout: fixed;\n}\n\n/* .st-main-output-table table tbody tr td { */\n/* max-width: 20%; */\n/* } */\n\n.st-main-output-table td {\n padding-top: 6px;\n padding-bottom: 6px;\n}\n.st-main-output-table tr:nth-child(even) {\n background-color: var(--grey-1);\n}\n\n.st-main-output-table td:nth-child(odd) {\n width: 120px;\n vertical-align: top;\n}\n\n.st-main-output-table td a {\n overflow-wrap: break-word;\n}\n","",{version:3,sources:["webpack://./src/view/css/main-tab.css"],names:[],mappings:"AAAA,iHAAiH;AACjH;EACE,WAAW;AACb;;AAEA;EACE,WAAW;EACX,mBAAmB;AACrB;;AAEA;EACE,gBAAgB;EAChB,mBAAmB;AACrB;;AAEA;EACE,gBAAgB;EAChB,kBAAkB;EAClB,mBAAmB;AACrB;;AAEA;EACE,WAAW;EACX,mBAAmB;AACrB;;AAEA,8CAA8C;AAC9C,sBAAsB;AACtB,MAAM;;AAEN;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 tab name (main, axo, sdf) to avoid naming collitions */\n.st-main-input-table {\n width: 100%;\n}\n\n.st-main-input-table td:has(textarea) {\n width: 100%;\n padding-right: 20px;\n}\n\n.st-main-input-table td:has(select) {\n min-width: 120px;\n vertical-align: top;\n}\n\n.st-main-output-table {\n margin-top: 20px;\n margin-right: 20px;\n margin-bottom: 10px;\n}\n\n.st-main-output-table table {\n width: 100%;\n table-layout: fixed;\n}\n\n/* .st-main-output-table table tbody tr td { */\n/* max-width: 20%; */\n/* } */\n\n.st-main-output-table td {\n padding-top: 6px;\n padding-bottom: 6px;\n}\n.st-main-output-table tr:nth-child(even) {\n background-color: var(--grey-1);\n}\n\n.st-main-output-table td:nth-child(odd) {\n width: 120px;\n vertical-align: top;\n}\n\n.st-main-output-table td a {\n overflow-wrap: break-word;\n}\n"],sourceRoot:""}]);const a=s},865:(t,e,n)=>{n.d(e,{Z:()=>a});var o=n(537),i=n.n(o),r=n(645),s=n.n(r)()(i());s.push([t.id,"/* Naming convention: class names should begin with st and tab name (main, axo, sdf) to avoid naming collitions */\n\n.st-sdf-body {\n padding-right: 20px;\n}\n\n.st-sdf-input-form {\n text-align: right;\n vertical-align: top;\n min-width: 95px;\n}\n\n.st-sdf-direction-choice label {\n min-width: 100px;\n float: right;\n}\n\n.st-sdf-direction-choice div {\n justify-content: right;\n}\n\n.st-sdf-text-input-td { /* Style for td containing textarea */\n width: 100%;\n}\n\n.st-sdf-mol-img {\n margin-right: 30px;\n float: right;\n}\n\n.st-sdf-bool-button-block {\n justify-content: right;\n margin-bottom: 10px;\n}\n\n.st-sdf-bottom {\n flex-direction: row-reverse;\n padding-top: 20px;\n}\n","",{version:3,sources:["webpack://./src/view/css/sdf-tab.css"],names:[],mappings:"AAAA,iHAAiH;;AAEjH;EACE,mBAAmB;AACrB;;AAEA;EACE,iBAAiB;EACjB,mBAAmB;EACnB,eAAe;AACjB;;AAEA;EACE,gBAAgB;EAChB,YAAY;AACd;;AAEA;EACE,sBAAsB;AACxB;;AAEA,wBAAwB,qCAAqC;EAC3D,WAAW;AACb;;AAEA;EACE,kBAAkB;EAClB,YAAY;AACd;;AAEA;EACE,sBAAsB;EACtB,mBAAmB;AACrB;;AAEA;EACE,2BAA2B;EAC3B,iBAAiB;AACnB",sourcesContent:["/* Naming convention: class names should begin with st and tab name (main, axo, sdf) to avoid naming collitions */\n\n.st-sdf-body {\n padding-right: 20px;\n}\n\n.st-sdf-input-form {\n text-align: right;\n vertical-align: top;\n min-width: 95px;\n}\n\n.st-sdf-direction-choice label {\n min-width: 100px;\n float: right;\n}\n\n.st-sdf-direction-choice div {\n justify-content: right;\n}\n\n.st-sdf-text-input-td { /* Style for td containing textarea */\n width: 100%;\n}\n\n.st-sdf-mol-img {\n margin-right: 30px;\n float: right;\n}\n\n.st-sdf-bool-button-block {\n justify-content: right;\n margin-bottom: 10px;\n}\n\n.st-sdf-bottom {\n flex-direction: row-reverse;\n padding-top: 20px;\n}\n"],sourceRoot:""}]);const a=s},645:t=>{t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var n="",o=void 0!==e[5];return e[4]&&(n+="@supports (".concat(e[4],") {")),e[2]&&(n+="@media ".concat(e[2]," {")),o&&(n+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),n+=t(e),o&&(n+="}"),e[2]&&(n+="}"),e[4]&&(n+="}"),n})).join("")},e.i=function(t,n,o,i,r){"string"==typeof t&&(t=[[null,t,void 0]]);var s={};if(o)for(var a=0;a<this.length;a++){var l=this[a][0];null!=l&&(s[l]=!0)}for(var c=0;c<t.length;c++){var u=[].concat(t[c]);o&&s[u[0]]||(void 0!==r&&(void 0===u[5]||(u[1]="@layer".concat(u[5].length>0?" ".concat(u[5]):""," {").concat(u[1],"}")),u[5]=r),n&&(u[2]?(u[1]="@media ".concat(u[2]," {").concat(u[1],"}"),u[2]=n):u[2]=n),i&&(u[4]?(u[1]="@supports (".concat(u[4],") {").concat(u[1],"}"),u[4]=i):u[4]="".concat(i)),e.push(u))}},e}},537:t=>{t.exports=function(t){var e=t[1],n=t[3];if(!n)return e;if("function"==typeof btoa){var o=btoa(unescape(encodeURIComponent(JSON.stringify(n)))),i="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(o),r="/*# ".concat(i," */");return[e].concat([r]).join("\n")}return[e].join("\n")}},803:(t,e)=>{var n;!function(){var o=e||{}||this||window;void 0===(n=function(){return o}.apply(e,[]))||(t.exports=n),o.default=o;var i="http://www.w3.org/2000/xmlns/",r="http://www.w3.org/2000/svg",s=/url\(["']?(.+?)["']?\)/,a={woff2:"font/woff2",woff:"font/woff",otf:"application/x-font-opentype",ttf:"application/x-font-ttf",eot:"application/vnd.ms-fontobject",sfnt:"application/font-sfnt",svg:"image/svg+xml"},l=function(t){return t instanceof HTMLElement||t instanceof SVGElement},c=function(t){if(!l(t))throw new Error("an HTMLElement or SVGElement is required; got "+t)},u=function(t){return new Promise((function(e,n){l(t)?e(t):n(new Error("an HTMLElement or SVGElement is required; got "+t))}))},d=function(t,e,n){var o=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==o||isNaN(parseFloat(o))?0:o},h=function(t){for(var e=window.atob(t.split(",")[1]),n=t.split(",")[0].split(":")[1].split(";")[0],o=new ArrayBuffer(e.length),i=new Uint8Array(o),r=0;r<e.length;r++)i[r]=e.charCodeAt(r);return new Blob([o],{type:n})},p={},f=null,m=function(t,e){var n=e||{},o=n.selectorRemap,i=n.modifyStyle,r=n.modifyCss,l=n.fonts,c=n.excludeUnusedCss,u=r||function(t,e){return(o?o(t):t)+"{"+(i?i(e):e)+"}\n"},d=[],h=void 0===l,m=l||[];return(f||(f=Array.from(document.styleSheets).map((function(t){try{return{rules:t.cssRules,href:t.href}}catch(e){return console.warn("Stylesheet could not be loaded: "+t.href,e),{}}})))).forEach((function(e){var n=e.rules,o=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))d.push(u(e.selectorText,e.style.cssText));else if(h&&e.cssText.match(/^@font-face/)){var n=function(t,e){var n=t.cssText.match(s),o=n&&n[1]||"";if(o&&!o.match(/^data:/)&&"about:blank"!==o){var i,r,l=o.startsWith("../")?e+"/../"+o:o.startsWith("./")?e+"/."+o:o;return{text:t.cssText,format:(i=l,r=Object.keys(a).filter((function(t){return i.indexOf("."+t)>0})).map((function(t){return a[t]})),r?r[0]:(console.error("Unknown font format for "+i+". Fonts may not be working correctly."),"application/octet-stream")),url:l}}}(e,o);n&&m.push(n)}else c||d.push(e.cssText)}))})),function(t){return Promise.all(t.map((function(t){return new Promise((function(e,n){if(p[t.url])return e(p[t.url]);var o=new XMLHttpRequest;o.addEventListener("load",(function(){var n=function(t){for(var e="",n=new Uint8Array(t),o=0;o<n.byteLength;o++)e+=String.fromCharCode(n[o]);return window.btoa(e)}(o.response),i=t.text.replace(s,'url("data:'+t.format+";base64,"+n+'")')+"\n";p[t.url]=i,e(i)})),o.addEventListener("error",(function(n){console.warn("Failed to load font from: "+t.url,n),p[t.url]=null,e(null)})),o.addEventListener("abort",(function(n){console.warn("Aborted loading font from: "+t.url,n),e(null)})),o.open("GET",t.url),o.responseType="arraybuffer",o.send()}))}))).then((function(t){return t.filter((function(t){return t})).join("")}))}(m).then((function(t){return d.join("\n")+t}))},g=function(){if(!navigator.msSaveOrOpenBlob&&!("download"in document.createElement("a")))return{popup:window.open()}};o.prepareSvg=function(t,e,n){c(t);var o=e||{},s=o.left,a=void 0===s?0:s,l=o.top,u=void 0===l?0:l,h=o.width,p=o.height,f=o.scale,g=void 0===f?1:f,A=o.responsive,v=void 0!==A&&A,b=o.excludeCss,C=void 0!==b&&b;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,o){var i=document.createElement("canvas"),r=new Image;r.crossOrigin="anonymous",r.src=n,r.onerror=function(){return o(new Error("Could not load "+n))},r.onload=function(){i.width=r.width,i.height=r.height,i.getContext("2d").drawImage(r,0,0),t.setAttributeNS("http://www.w3.org/1999/xlink","href",i.toDataURL("image/png")),e(!0)}}))):Promise.resolve(null)})))}(t).then((function(){var o=t.cloneNode(!0);o.style.backgroundColor=(e||{}).backgroundColor||t.style.backgroundColor;var s=function(t,e,n,o){if("svg"===t.tagName)return{width:n||d(t,e,"width"),height:o||d(t,e,"height")};if(t.getBBox){var i=t.getBBox(),r=i.x,s=i.y;return{width:r+i.width,height:s+i.height}}}(t,o,h,p),l=s.width,c=s.height;if("svg"!==t.tagName){if(!t.getBBox)return void console.error("Attempted to render non-SVG element",t);null!=o.getAttribute("transform")&&o.setAttribute("transform",o.getAttribute("transform").replace(/translate\(.*?\)/,""));var f=document.createElementNS("http://www.w3.org/2000/svg","svg");f.appendChild(o),o=f}if(o.setAttribute("version","1.1"),o.setAttribute("viewBox",[a,u,l,c].join(" ")),o.getAttribute("xmlns")||o.setAttributeNS(i,"xmlns",r),o.getAttribute("xmlns:xlink")||o.setAttributeNS(i,"xmlns:xlink","http://www.w3.org/1999/xlink"),v?(o.removeAttribute("width"),o.removeAttribute("height"),o.setAttribute("preserveAspectRatio","xMinYMin meet")):(o.setAttribute("width",l*g),o.setAttribute("height",c*g)),Array.from(o.querySelectorAll("foreignObject > *")).forEach((function(t){t.setAttributeNS(i,"xmlns","svg"===t.tagName?r:"http://www.w3.org/1999/xhtml")})),!C)return m(t,e).then((function(t){var e=document.createElement("style");e.setAttribute("type","text/css"),e.innerHTML="<![CDATA[\n"+t+"\n]]>";var i=document.createElement("defs");i.appendChild(e),o.insertBefore(i,o.firstChild);var r=document.createElement("div");r.appendChild(o);var s=r.innerHTML.replace(/NS\d+:href/gi,'xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href');if("function"!=typeof n)return{src:s,width:l,height:c};n(s,l,c)}));var A=document.createElement("div");A.appendChild(o);var b=A.innerHTML;if("function"!=typeof n)return{src:b,width:l,height:c};n(b,l,c)}))},o.svgAsDataUri=function(t,e,n){return c(t),o.prepareSvg(t,e).then((function(t){var e=t.src,o=t.width,i=t.height,r="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 " ">]>'+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(r,o,i),r}))},o.svgAsPngUri=function(t,e,n){c(t);var i=e||{},r=i.encoderType,s=void 0===r?"image/png":r,a=i.encoderOptions,l=void 0===a?.8:a,u=i.canvg,d=function(t){var e=t.src,o=t.width,i=t.height,r=document.createElement("canvas"),a=r.getContext("2d"),c=window.devicePixelRatio||1;r.width=o*c,r.height=i*c,r.style.width=r.width+"px",r.style.height=r.height+"px",a.setTransform(c,0,0,c,0,0),u?u(r,e):a.drawImage(e,0,0);var d=void 0;try{d=r.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(d,r.width,r.height),Promise.resolve(d)};return u?o.prepareSvg(t,e).then(d):o.svgAsDataUri(t,e).then((function(t){return new Promise((function(e,n){var o=new Image;o.onload=function(){return e(d({src:o,width:o.width,height:o.height}))},o.onerror=function(){n("There was an error loading the data URI as an image on the following SVG\n"+window.atob(t.slice(26))+"Open the following link to see browser's diagnosis\n"+t)},o.src=t}))}))},o.download=function(t,e,n){if(navigator.msSaveOrOpenBlob)navigator.msSaveOrOpenBlob(h(e),t);else{var o=document.createElement("a");if("download"in o){o.download=t,o.style.display="none",document.body.appendChild(o);try{var i=h(e),r=URL.createObjectURL(i);o.href=r,o.onclick=function(){return requestAnimationFrame((function(){return URL.revokeObjectURL(r)}))}}catch(t){console.error(t),console.warn("Error while getting object URL. Falling back to string URL."),o.href=e}o.click(),document.body.removeChild(o)}else n&&n.popup&&(n.popup.document.title=t,n.popup.location.replace(e))}},o.saveSvg=function(t,e,n){var i=g();return u(t).then((function(t){return o.svgAsDataUri(t,n||{})})).then((function(t){return o.download(e,t,i)}))},o.saveSvgAsPng=function(t,e,n){var i=g();return u(t).then((function(t){return o.svgAsPngUri(t,n||{})})).then((function(t){return o.download(e,t,i)}))}}()},379:t=>{var e=[];function n(t){for(var n=-1,o=0;o<e.length;o++)if(e[o].identifier===t){n=o;break}return n}function o(t,o){for(var r={},s=[],a=0;a<t.length;a++){var l=t[a],c=o.base?l[0]+o.base:l[0],u=r[c]||0,d="".concat(c," ").concat(u);r[c]=u+1;var h=n(d),p={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==h)e[h].references++,e[h].updater(p);else{var f=i(p,o);o.byIndex=a,e.splice(a,0,{identifier:d,updater:f,references:1})}s.push(d)}return s}function i(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,i){var r=o(t=t||[],i=i||{});return function(t){t=t||[];for(var s=0;s<r.length;s++){var a=n(r[s]);e[a].references--}for(var l=o(t,i),c=0;c<r.length;c++){var u=n(r[c]);0===e[u].references&&(e[u].updater(),e.splice(u,1))}r=l}}},569:t=>{var e={};t.exports=function(t,n){var o=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(!o)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");o.appendChild(n)}},216:t=>{t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},565:(t,e,n)=>{t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},795:t=>{t.exports=function(t){var e=t.insertStyleElement(t);return{update:function(n){!function(t,e,n){var o="";n.supports&&(o+="@supports (".concat(n.supports,") {")),n.media&&(o+="@media ".concat(n.media," {"));var i=void 0!==n.layer;i&&(o+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),o+=n.css,i&&(o+="}"),n.media&&(o+="}"),n.supports&&(o+="}");var r=n.sourceMap;r&&"undefined"!=typeof btoa&&(o+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(r))))," */")),e.styleTagTransform(o,t,e.options)}(e,t,n)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},589:t=>{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))}}},29:(t,e,n)=>{n.d(e,{NI:()=>i,mc:()=>o});const o=["A","G","C","U","T"];var i;!function(t){t.HELM="HELM",t.AXOLABS="Axolabs"}(i||(i={}))},895:(t,e,n)=>{n.d(e,{BX:()=>o,Dv:()=>a,VV:()=>l,Xz:()=>c,a_:()=>i,dz:()=>s,pl:()=>r});const o="System:AppData/SequenceTranslator",i="monomer-lib.json",r="System:AppData/SequenceTranslator",s="axolabs-style.json",a="formats-to-helm.json",l="codes-to-symbols.json",c="linkers.json"},996:(t,e,n)=>{n.d(e,{BF:()=>l,Rv:()=>a,VO:()=>u,al:()=>s,iA:()=>c});var o=n(976),i=n(895);const r=new o.FileSource(i.pl);let s,a,l,c;async function u(){[s,a,l,c].every((t=>void 0!==t))||(s=await d(i.dz),a=await d(i.Dv),l=await d(i.VV),c=await d(i.Xz))}async function d(t){let e;try{e=JSON.parse(await r.readAsText(t))}catch(e){const n=e.hasOwnProperty("message")?e.message:e.toString();throw new Error(`Error loading json from ${t}:`+n)}return e}},800:(t,e,n)=>{n.d(e,{$3:()=>i,DD:()=>o,s8:()=>r});const o={NUCLEOSIDE:"nucleoside",LINKAGE:"phosphateBackbone"},i="p",r="<?>"},112:(t,e,n)=>{n.d(e,{D:()=>l});var o=n(29),i=n(800),r=n(893),s=n(996),a=n(559);function l(t,e,n){const l=Object.keys(s.Rv).concat([o.NI.HELM]);if(!t||-1!==e&&n!==o.NI.HELM)return{};if(!l.includes(n))throw new Error(`${n} format is not supported by SequenceTranslator`);const c=l.filter((t=>t!=n)).sort(((t,e)=>t.localeCompare(e))),u=new r.I(t,n),d=Object.fromEntries(c.map((t=>{let e;try{e=u.convertTo(t)}catch{e=null}return[t,e]})).filter((([t,e])=>e))),h=function(t,e){const n=new RegExp("\\([^()]*\\)","g"),r=t.match(n);if(!r)return null;return r.map((t=>{const n=t.replace(/[\[\]()]/g,"");return o.mc.includes(n)?n:e.getNaturalAnalogBySymbol(n)})).map((t=>t||i.s8)).join("")}(n===o.NI.HELM?t:d[o.NI.HELM],a.A.getInstance());return h&&(d.Nucleotides=h),d}},893:(t,e,n)=>{n.d(e,{I:()=>a});var o=n(29),i=n(800),r=n(996);const s={LEFT:"RNA1{",RIGHT:"}$$$$"};class a{sequence;sourceFormat;constructor(t,e){this.sequence=t,this.sourceFormat=e}convertTo(t){const e=Object.keys(r.Rv);if(this.sourceFormat===o.NI.HELM&&e.includes(t))return u(this.sequence,t);if(e.includes(this.sourceFormat)&&t===o.NI.HELM)return d(this.sequence,this.sourceFormat);if([this.sourceFormat,t].every((t=>e.includes(t))))return u(d(this.sequence,this.sourceFormat),t);throw new Error(`ST: unsupported translation direction ${this.sourceFormat} -> ${t}`)}}function l(t){return t.map((t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"))).map((t=>t.includes("(")||t.includes(")")?t:`(?<!\\([^()]*)${t}(?![^()]*\\))`)).join("|")}function c(t,e){return e.length-t.length}function u(t,e){const n=function(t){const e={};return Object.values(t).forEach((t=>{Object.entries(t).forEach((([t,n])=>{const o=n.replace(/\)p/g,")").replace(/\]p/g,"]");void 0===e[o]?e[o]=[t]:e[o].push(t)}))})),Object.entries(e).forEach((([t,n])=>{const o=n.sort(c);e[t]=o[0]})),e}(r.Rv[e]),o=new RegExp(l(Object.values(s)),"g");let a=t.replace(o,"");const u=Object.keys(n).sort(c),d=new RegExp(l(u)+"|.","g");return a=a.replace(d,(t=>u.includes(t)?n[t]:"p"===t||"."===t?t:"?")).replace(/\?+/g,i.s8).replace(/p\.|\./g,""),a=a.replace(/<empty>/g,""),a=a.replace(/\/\//g,"/"),a}function d(t,e){const n=r.Rv[e],o=Object.assign({},...Object.values(n)),a=Object.keys(o).sort(c),u=new RegExp(l(a)+"|\\([^()]*\\)|.","g"),d=l(Array.from(new Set(Object.values(n[i.DD.LINKAGE]))).sort(c)),h=new RegExp(`${i.$3}.(${d})`,"g");let p=t.replace(u,(t=>a.includes(t)?o[t]+".":"?"));return p=p.replace(/\?+/g,`${i.s8}.`),p=p.slice(0,-1),p[p.length-1]===i.$3&&(p=p.slice(0,-1)),p=p.replace(h,((t,e)=>e)),p=p.replace(/<empty>/g,""),`${s.LEFT+p+s.RIGHT}`}},669:(t,e,n)=>{function o(t){return t.sort(((t,e)=>e.length-t.length))}function i(t,e){const n=document.createElement("a");n.setAttribute("href","data:text/plain;charset=utf-8,"+e),n.setAttribute("download",t),n.click()}n.d(e,{L:()=>i,x:()=>o})},559:(t,e,n)=>{n.d(e,{A:()=>a});var o=n(976),i=n(563),r=n(29),s=n(996);class a{constructor(){const t=i._package.monomerLib;if(null===t)throw new Error("SequenceTranslator: monomer library is null");this.lib=t,this.allMonomers=this.getAllMonomers()}lib;static instance;allMonomers;formatMonomerForViewer(t){const e={};return e.name=t.symbol,e.symbol=t.symbol,e.molfile=t.molfile,this.getAllFormats().forEach((n=>{if(n===r.NI.HELM)return;const o=s.BF[n],i=Object.keys(o).filter((e=>o[e]===t.symbol));e[n]=i.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}static getInstance(){return void 0===a.instance&&(a.instance=new a),a.instance}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(s.BF[t]))}getCodesByFormat(t){return Object.keys(s.BF[t])}getAllFormats(){return Object.keys(s.BF)}getTableForViewer(){const t=this.allMonomers.map((t=>this.formatMonomerForViewer(t)));return o.DataFrame.fromObjects(t)}getCodesToWeightsMap(){const t=new Map;return Object.entries(s.BF).forEach((([e,n])=>{Object.entries(n).forEach((([e,n])=>{const o=this.getMonomer(n).meta?.molecularWeight;t.set(e,o)}))})),t}}},947:(t,e,n)=>{n.d(e,{b:()=>s});var o=n(29),i=n(559),r=n(669);class s{sequence;constructor(t){this.sequence=t,this.libWrapper=i.A.getInstance()}libWrapper;getInvalidCodeIndex(t){if(t===o.NI.HELM)return this.sequence.length;const e=["r","d"],n=(0,r.x)(this.libWrapper.getCodesByFormat(t));let i=0;for(;i<this.sequence.length;){const t=n.find((t=>t===this.sequence.substring(i,i+t.length)));if(!t)break;if(i>1&&o.mc.includes(this.sequence[i])&&e.includes(this.sequence[i-2]))break;if(e.includes(this.sequence[i+1])&&o.mc.includes(this.sequence[i])){i++;break}i+=t.length}return i===this.sequence.length&&(i=-1),i}isValidSequence(t){return-1===this.getInvalidCodeIndex(t)}}},175:(t,e,n)=>{n.d(e,{$:()=>o});const o="p"},837:(t,e,n)=>{function o(t,e=!0){let n="\nDatagrok macromolecule handler\n\n";n+=" 0 0 0 0 0 0 999 V3000\n",n+="M V30 BEGIN CTAB\n";let o="",a="",l="";const c=[];let u=0,d=0,h=0;if(t.antiStrands.length>0)for(let e=0;e<t.antiStrands.length;e++)t.antiStrands[e]=i(t.antiStrands[e]);let p=!1;const f=t.senseStrands.concat(t.antiStrands);let m=0;for(let e=0;e<f.length;e++){f[e]=f[e].replaceAll("(-\nM V30 ","(").replaceAll("-\nM V30 ","").replaceAll(" )",")");const n=r(f[e]),i=s(f[e]);if(e>=t.senseStrands.length?!1===p&&(p=!0,h=0):m=Math.min(m,Math.min(...i.y.filter((t=>t<0)))),p){const t=Math.min(...i.x)-h,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-m}let l=f[e].indexOf("M V30 BEGIN ATOM");l=f[e].indexOf("\n",l);let g=l,A=l;for(let t=0;t<n.natom;t++){g=f[e].indexOf("V30",g)+4,A=f[e].indexOf(" ",g);const n=parseInt(f[e].substring(g,A))+u;f[e]=f[e].slice(0,g)+n+f[e].slice(A),g=f[e].indexOf(" ",g)+1,g=f[e].indexOf(" ",g)+1,A=f[e].indexOf(" ",g);let o=Math.round(1e4*i.x[t])/1e4;f[e]=f[e].slice(0,g)+o+f[e].slice(A),g=f[e].indexOf(" ",g)+1,A=f[e].indexOf(" ",g),o=Math.round(1e4*i.y[t])/1e4,f[e]=f[e].slice(0,g)+o+f[e].slice(A),g=f[e].indexOf("\n",g)+1}const v=f[e].indexOf("M V30 END ATOM");o+=f[e].substring(l+1,v);let b=f[e].indexOf("M V30 BEGIN BOND");b=f[e].indexOf("\n",b),g=b,A=b;for(let t=0;t<n.nbond;t++){g=f[e].indexOf("V30",g)+4,A=f[e].indexOf(" ",g);const t=parseInt(f[e].substring(g,A))+d;f[e]=f[e].slice(0,g)+t+f[e].slice(A),g=f[e].indexOf(" ",g)+1,g=f[e].indexOf(" ",g)+1,A=f[e].indexOf(" ",g);let n=parseInt(f[e].substring(g,A))+u;f[e]=f[e].slice(0,g)+n+f[e].slice(A),g=f[e].indexOf(" ",g)+1,A=Math.min(f[e].indexOf("\n",g),f[e].indexOf(" ",g)),n=parseInt(f[e].substring(g,A))+u,f[e]=f[e].slice(0,g)+n+f[e].slice(A),g=f[e].indexOf("\n",g)+1}const C=f[e].indexOf("M V30 END BOND");a+=f[e].substring(b+1,C);let x=f[e].indexOf("M V30 MDLV30/STEABS ATOMS=(");for(;-1!==x;){x+=28;const t=f[e].indexOf(")",x);f[e].substring(x,t).split(" ").slice(1).forEach((t=>{c.push(parseInt(t)+u)})),x=t,x=f[e].indexOf("M V30 MDLV30/STEABS ATOMS=(",x)}u+=n.natom,d+=n.nbond,h+=Math.max(...i.x)+5}const g=Math.ceil(c.length/4);l+="M V30 MDLV30/STEABS ATOMS=("+c.length+" -\n";for(let t=0;t<g;t++){l+="M V30 ";const e=t+1===g?c.length-4*(g-1):4;for(let n=0;n<e;n++)l+=n+1===e?t===g-1?c[4*t+n]+")\n":c[4*t+n]+" -\n":c[4*t+n]+" "}return n+="M V30 COUNTS "+u+" "+d+" 0 0 0\n",n+="M V30 BEGIN ATOM\n",n+=o,n+="M V30 END ATOM\n",n+="M V30 BEGIN BOND\n",n+=a,n+="M V30 END BOND\n",e&&c.length>0?(n+="M V30 BEGIN COLLECTION\n",n+=l,n+="M V30 END COLLECTION\n"):n=n.replace(/ CFG=\d/g," "),n+="M V30 END CTAB\n",n+="M END",n}function i(t){const e=s(t),n=e.atomIndex.length,o=(Math.max(...e.x)+Math.min(...e.x))/2,i=(Math.max(...e.y)+Math.min(...e.y))/2;for(let t=0;t<n;t++)e.x[t]-=o,e.y[t]-=i;const r=Math.PI,a=Math.cos(r),l=Math.sin(r);for(let t=0;t<n;t++){const n=e.x[t];e.x[t]=n*a-e.y[t]*l,e.y[t]=n*l+e.y[t]*a}const c=Math.max(...e.y);for(let t=0;t<n;t++)e.x[t]+=o,e.y[t]-=c;let u=t.indexOf("M V30 BEGIN ATOM");u=t.indexOf("\n",u);let d=u;for(let o=0;o<n;o++)u=t.indexOf("V30",u)+4,u=t.indexOf(" ",u)+1,u=t.indexOf(" ",u)+1,d=t.indexOf(" ",u)+1,d=t.indexOf(" ",d),u=(t=t.slice(0,u)+e.x[o]+" "+e.y[o]+t.slice(d)).indexOf("\n",u)+1;return t}function r(t){let e=(t=t.replaceAll("\r","")).indexOf("COUNTS")+7,n=t.indexOf(" ",e);const o=parseInt(t.substring(e,n));return e=n+1,n=t.indexOf(" ",e),{natom:o,nbond:parseInt(t.substring(e,n))}}function s(t){const e=r(t);let n=t.indexOf("M V30 BEGIN ATOM");n=t.indexOf("\n",n);let o=n;const i=Array(e.natom),s=Array(e.natom),a=Array(e.natom),l=Array(e.natom);for(let r=0;r<e.natom;r++)n=t.indexOf("V30",n)+4,o=t.indexOf(" ",n),i[r]=parseInt(t.substring(n,o)),n=o+1,o=t.indexOf(" ",n),s[r]=t.substring(n,o),n=o+1,o=t.indexOf(" ",n),a[r]=parseFloat(t.substring(n,o)),n=o+1,o=t.indexOf(" ",n),l[r]=parseFloat(t.substring(n,o)),n=t.indexOf("\n",n)+1;return{atomIndex:i,atomType:s,x:a,y:l}}n.d(e,{$U:()=>s,v5:()=>o})},563:(t,e,n)=>{n.r(e),n.d(e,{_package:()=>ue,demoDesignPattern:()=>ve,demoTranslateSequence:()=>Ae,demoVisualizeDuplex:()=>be,getCodeToWeightsMap:()=>pe,getMolfileFromGcrsSequence:()=>me,initSequenceTranslatorLibData:()=>he,linkStrands:()=>ge,sequenceTranslatorApp:()=>de,translateOligonucleotideSequence:()=>Ce,validateSequence:()=>fe});var o=n(469),i=n(976);const r=ui;var s=n(11);const a=rxjs;var l=n(379),c=n.n(l),u=n(795),d=n.n(u),h=n(569),p=n.n(h),f=n(565),m=n.n(f),g=n(216),A=n.n(g),v=n(589),b=n.n(v),C=n(284),x={};x.styleTagTransform=b(),x.setAttributes=m(),x.insert=p().bind(null,"head"),x.domAPI=d(),x.insertStyleElement=A(),c()(C.Z,x),C.Z&&C.Z.locals&&C.Z.locals;const w=$;var y=n.n(w),E=n(947),I=n(669),O=n(29),S=n(559),T=n(996);class M{sequence;constructor(t){this.sequence=t,this.libWrapper=S.A.getInstance(),this.formats=Object.keys(T.Rv)}libWrapper;formats;getFormat(){if(this.sequence.startsWith("RNA"))return O.NI.HELM;const t=this.getListOfPossibleSynthesizersByFirstMatchedCode();if(0===t.length)return null;const e=new E.b(this.sequence),n=Array(t.length).fill(0);for(let o=0;o<t.length;++o){const i=t[o];n[o]=e.getInvalidCodeIndex(i)}const o=n.some((t=>-1===t))?-1:Math.max(...n);return t[n.indexOf(o)]}getListOfPossibleSynthesizersByFirstMatchedCode(){const t=this.sequence;let e=[];for(const n of this.formats){let o=(0,I.x)(this.libWrapper.getCodesByFormat(n)),i=0;for(let e=0;e<t.length;e++)if(")"===t[e]&&e!==t.length-1){i=e+1;break}o.some((e=>e===t.slice(i,i+e.length)))&&e.push(n)}return e}}function B(t){let e=0;const n=new M(t).getFormat();null!==n&&(e=new E.b(t).getInvalidCodeIndex(n));const o=e<0||""===t,i=r.span([]);y()(i).css("-webkit-text-fill-color","var(--grey-6)");const s=r.span([]);return y()(s).css("-webkit-text-fill-color","red"),o?i.innerHTML=t:(i.innerHTML=t.slice(0,e),s.innerHTML=t.slice(e)),[i,s]}var N=n(973),L={};L.styleTagTransform=b(),L.setAttributes=m(),L.insert=p().bind(null,"head"),L.domAPI=d(),L.insertStyleElement=A(),c()(N.Z,L),N.Z&&N.Z.locals&&N.Z.locals;class D{textInputBase;constructor(t,e,n=!0){this.textInputBase=t,this.textInputBase=t,this.painter=e,y()(this.root).addClass("colored-text-input"),n&&this.textInputBase.onInput((()=>{y()(this.textArea).css("height",0),y()(this.textArea).css("height",this.textArea.scrollHeight+"px")})),this.highlights=r.div([]),this.root.appendChild(this.highlights),this.colorize(),this.textInputBase.onInput((()=>this.colorize()))}highlights;painter;get textArea(){return this.textInputBase.root.getElementsByTagName("textarea").item(0)}get root(){return this.textInputBase.root}colorize(){const t=this.painter(this.textInputBase.value);this.highlights.innerHTML="",t.forEach((t=>this.highlights.appendChild(t)))}}var k=n(175);class P{sequence;invert;codeMap;constructor(t,e=!1,n){this.sequence=t,this.invert=e,this.codeMap=n,this.lib=S.A.getInstance()}lib;parseSequence(){const t=this.parseRawSequence();return this.addLinkers(t)}addLinkers(t){const e=[];return t.forEach(((n,o)=>{const i=this.getSymbolForCode(n);o>0&&function(t){return T.iA.left.includes(t)}(i)&&e.pop(),e.push(i);const r=V(i),s=o===t.length-1,a=o+1<t.length&&V(this.getSymbolForCode(t[o+1]));r||function(t){return T.iA.right.includes(t)}(i)||a||s||e.push(k.$)})),e}getSymbolForCode(t){let e=this.codeMap.get(t);return e??=t,e}parseRawSequence(){const t=this.getAllCodesOfFormat(),e=[];let n=0;for(;n<this.sequence.length;){const o=t.find((t=>t===this.sequence.substring(n,n+t.length)));this.invert?e.unshift(o):e.push(o),n+=o.length}return e}getAllCodesOfFormat(){let t=Array.from(this.codeMap.keys());return(0,I.x)(t)}}function V(t){return T.iA.phosphate.includes(t)}class F{constructor(t,e=!1,n){this.lib=S.A.getInstance();const o=this.lib.getCodeToSymbolMap(n);this.parser=new P(t,e,o)}parser;lib;convert(){const t=this.parser.parseSequence(),e=[];return t.forEach(((t,n)=>{const o=this.getMonomerMolfile(t,n);e.push(o)})),this.getPolymerMolfile(e)}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,o=e.atomIndex.indexOf(1),i=e.atomIndex.indexOf(n),r=(e.x[i]+e.x[o])/2,s=(e.y[i]+e.y[o])/2;for(let t=0;t<n;t++)e.x[t]-=r,e.y[t]-=s;for(let t=0;t<n;t++)e.x[t]=-e.x[t];const a=e.x[o];for(let t=0;t<n;t++)e.x[t]-=a;let l=t.indexOf("M V30 BEGIN ATOM");l=t.indexOf("\n",l);let c=l;for(let o=0;o<n;o++)l=t.indexOf("V30",l)+4,l=t.indexOf(" ",l)+1,l=t.indexOf(" ",l)+1,c=t.indexOf(" ",l)+1,c=t.indexOf(" ",c),l=(t=t.slice(0,l)+e.x[o]+" "+e.y[o]+t.slice(c)).indexOf("\n",l)+1;return t}extractAtomDataV3000(t){const e=this.extractAtomsBondsNumbersV3000(t);let n=t.indexOf("M V30 BEGIN ATOM");n=t.indexOf("\n",n);let o=n;const i=Array(e.natom),r=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,o=t.indexOf(" ",n),i[l]=parseInt(t.substring(n,o)),n=o+1,o=t.indexOf(" ",n),r[l]=t.substring(n,o),n=o+1,o=t.indexOf(" ",n),s[l]=parseFloat(t.substring(n,o)),n=o+1,o=t.indexOf(" ",n),a[l]=parseFloat(t.substring(n,o)),n=t.indexOf("\n",n)+1;return{atomIndex:i,atomType:r,x:s,y:a}}extractAtomsBondsNumbersV3000(t){let e=(t=t.replaceAll("\r","")).indexOf("COUNTS")+7,n=t.indexOf(" ",e);const o=parseInt(t.substring(e,n));return e=n+1,n=t.indexOf(" ",e),{natom:o,nbond:parseInt(t.substring(e,n))}}rotateNucleotidesV3000(t){const e=this.extractAtomDataV3000(t),n=e.atomIndex.length,o=e.atomIndex.indexOf(1),i=e.atomIndex.indexOf(n);n>8&&this.fix5Prime(e,o,i);const r=(e.x[i]+e.x[o])/2,s=(e.y[i]+e.y[o])/2;for(let t=0;t<n;t++)e.x[t]-=r,e.y[t]-=s;let a=0;if(0===e.x[o])a=e.y[o]>e.y[i]?Math.PI/2:3*Math.PI/2;else if(0===e.y[o])a=e.x[o]>e.x[i]?Math.PI:0;else{const t=e.y[o]/e.x[o];a=t>0?e.x[o]>0?Math.PI-Math.atan(t):2*Math.PI-Math.atan(t):e.x[o]>0?-Math.PI-Math.atan(t):Math.atan(t)}const l=Math.cos(a),c=Math.sin(a);for(let t=0;t<n;t++){const n=e.x[t];e.x[t]=n*l-e.y[t]*c,e.y[t]=n*c+e.y[t]*l}const u=e.x[o];for(let t=0;t<n;t++)e.x[t]-=u;let d=t.indexOf("M V30 BEGIN ATOM");d=t.indexOf("\n",d);let h=d;for(let o=0;o<n;o++)d=t.indexOf("V30",d)+4,d=t.indexOf(" ",d)+1,d=t.indexOf(" ",d)+1,h=t.indexOf(" ",d)+1,h=t.indexOf(" ",h),d=(t=t.slice(0,d)+e.x[o]+" "+e.y[o]+t.slice(h)).indexOf("\n",d)+1;return t}linkV3000(t,e=!0){let n="\nDatagrok macromolecule handler\n\n";n+=" 0 0 0 0 0 0 999 V3000\n",n+="M V30 BEGIN CTAB\n";let o="",i="",r="";const s=[];let a=0,l=0,c=0;for(let e=0;e<t.length;e++){const n=t[e].includes("MODIFICATION")&&0===e;let r=0;n&&(r=this.extractAtomDataV3000(t[e]).atomIndex.length),t[e]=t[e].replaceAll("(-\nM V30 ","(").replaceAll("-\nM V30 ","").replaceAll(" )",")");const u=this.extractAtomsBondsNumbersV3000(t[e]),d=this.extractAtomDataV3000(t[e]);let h=t[e].indexOf("M V30 BEGIN ATOM");h=t[e].indexOf("\n",h);let p=h,f=h;for(let o=0;o<u.natom;o++)if(1!==d.atomIndex[o]||0===e){p=t[e].indexOf("V30",p)+4,f=t[e].indexOf(" ",p);let o=0;n?(o=parseInt(t[e].substring(p,f)),1===o?o=r:o===r&&(o=1),o+=a):o=parseInt(t[e].substring(p,f))+a,t[e]=t[e].slice(0,p)+o+t[e].slice(f),p=t[e].indexOf(" ",p)+1,p=t[e].indexOf(" ",p)+1,f=t[e].indexOf(" ",p);const i=c-d.x[0];let s=Math.round(1e4*(parseFloat(t[e].substring(p,f))+i))/1e4;t[e]=t[e].slice(0,p)+s+t[e].slice(f),p=t[e].indexOf(" ",p)+1,f=t[e].indexOf(" ",p),s=Math.round(1e4*parseFloat(t[e].substring(p,f)))/1e4,t[e]=t[e].slice(0,p)+s+t[e].slice(f),p=t[e].indexOf("\n",p)+1}else p=t[e].indexOf("M V30",p)-1,f=t[e].indexOf("\n",p+1),t[e]=t[e].slice(0,p)+t[e].slice(f);const m=t[e].indexOf("M V30 END ATOM");o+=t[e].substring(h+1,m);let g=t[e].indexOf("M V30 BEGIN BOND");g=t[e].indexOf("\n",g),p=g,f=g;for(let o=0;o<u.nbond;o++){p=t[e].indexOf("V30",p)+4,f=t[e].indexOf(" ",p);const o=parseInt(t[e].substring(p,f))+l;t[e]=t[e].slice(0,p)+o+t[e].slice(f),p=t[e].indexOf(" ",p)+1,p=t[e].indexOf(" ",p)+1,f=t[e].indexOf(" ",p);let i=0;n?(i=parseInt(t[e].substring(p,f)),1===i?i=r:i===r&&(i=1),i+=a):i=parseInt(t[e].substring(p,f))+a,t[e]=t[e].slice(0,p)+i+t[e].slice(f),p=t[e].indexOf(" ",p)+1,f=Math.min(t[e].indexOf("\n",p),t[e].indexOf(" ",p)),i=0,n?(i=parseInt(t[e].substring(p,f)),1===i?i=r:i===r&&(i=1),i+=a):i=parseInt(t[e].substring(p,f))+a,t[e]=t[e].slice(0,p)+i+t[e].slice(f),p=t[e].indexOf("\n",p)+1}const A=t[e].indexOf("M V30 END BOND");i+=t[e].substring(g+1,A);let v=t[e].indexOf("M V30 MDLV30/STEABS ATOMS=(");for(;-1!==v;){v+=28;const n=t[e].indexOf(")",v);t[e].substring(v,n).split(" ").slice(1).forEach((t=>{s.push(parseInt(t)+a)})),v=n,v=t[e].indexOf("M V30 MDLV30/STEABS ATOMS=(",v)}a+=u.natom-1,l+=u.nbond,c+=n?Math.max(...d.x):d.x[u.natom-1]-d.x[0]}const u=Math.ceil(s.length/4);r+="M V30 MDLV30/STEABS ATOMS=("+s.length+" -\n";for(let t=0;t<u;t++){r+="M V30 ";const e=t+1===u?s.length-4*(u-1):4;for(let n=0;n<e;n++)r+=n+1===e?t===u-1?s[4*t+n]+")\n":s[4*t+n]+" -\n":s[4*t+n]+" "}return a++,n+="M V30 COUNTS "+a+" "+l+" 0 0 0\n",n+="M V30 BEGIN ATOM\n",n+=o,n+="M V30 END ATOM\n",n+="M V30 BEGIN BOND\n",n+=i,n+="M V30 END BOND\n",e&&s.length>0?(n+="M V30 BEGIN COLLECTION\n",n+=r,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 o=e+1,i=t.x[o],r=t.y[o],s=t.x[n]-i,a=t.y[n]-r,l=t.x[e]-i,c=t.y[e]-r,u=l*Math.cos(2*Math.PI/3)-c*Math.sin(2*Math.PI/3),d=l*Math.sin(2*Math.PI/3)+c*Math.cos(2*Math.PI/3),h=l-s,p=c-a,f=u-s,m=d-a;Math.sqrt(m*m+f*f)>=Math.sqrt(p*p+h*h)&&(t.x[e]=u+i,t.y[e]=d+r)}}var _,H=n(112),q=n(622);!function(t){t.HEADER="V2000",t[t.NUM_OF_HEADER_LINES=3]="NUM_OF_HEADER_LINES",t[t.NUM_OF_COUNTS_DIGITS=3]="NUM_OF_COUNTS_DIGITS",t[t.ATOM_TYPE_COL=4]="ATOM_TYPE_COL",t[t.FIRST_BONDED_ATOM_COL=1]="FIRST_BONDED_ATOM_COL",t[t.BOND_TYPE_COL=3]="BOND_TYPE_COL",t[t.RGP_SHIFT=8]="RGP_SHIFT",t.RGP_LINE="M RGP",t.A_LINE="A ",t.END="M END"}(_||(_={}));class R extends q.w{constructor(t){super(t)}static validate(t){return-1!==t.indexOf(_.HEADER)&&-1!==t.indexOf(_.END)}shiftIdxToAtomType(t){return this.shiftIdxToSpecifiedColumn(t,_.ATOM_TYPE_COL)}getCountsLineIdx(){let t=0;for(let e=0;e<_.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,_.FIRST_BONDED_ATOM_COL)}shiftIdxToBondType(t){return this.shiftIdxToSpecifiedColumn(t,_.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+_.NUM_OF_COUNTS_DIGITS;const n=parseInt(this.fileContent.substring(t,e));return t=e,e+=_.NUM_OF_COUNTS_DIGITS,{atomCount:n,bondCount:parseInt(this.fileContent.substring(t,e))}}}var j=n(577);class U{constructor(){}static getInstance(t){if(R.validate(t))return new R(t);if(j.u.validate(t))return new j.u(t);throw new Error("Malformed molfile")}}var G=n(604);const W=class extends Error{constructor(t){super(t)}};class z{constructor(t){this.molblock=t}_validMolBlock;get molblock(){return this._validMolBlock}set molblock(t){try{this.validateMolBlock(t)}catch(e){e instanceof W&&(t="");const n=(0,G.O)(e);console.error(n)}this._validMolBlock=t}validateMolBlock(t){if(""===t)throw new W("MoleculeImage: invalid molblock")}async drawMolBlockOnCanvas(t){try{await o.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=(0,G.O)(t);console.error(e)}}getMoleculeDimensions(){const t=U.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=r.dialog("Molecule"),e=r.div([],{style:{overflowX:"scroll"}}),n=.7*y()(window).height(),o=this.getMoleculeDimensions(),i=n/o.height,s=n,a=o.width*i,l=r.canvas(a,s);await this.drawMolBlockOnCanvas(l),e.appendChild(l),t.add(e).showModal(!0)}async drawMolecule(t,e,n){t.innerHTML="";const o=r.canvas(e*window.devicePixelRatio,n*window.devicePixelRatio);o.style.width=`${e}px`,o.style.height=`${n}px`,o.style.borderStyle="solid",o.style.borderColor="var(--grey-3)",o.style.borderWidth="thin",this.drawMolBlockOnCanvas(o),y()(o).on("click",(async()=>{await this.zoomIn()})),y()(o).on("mouseover",(()=>y()(o).css("cursor","grab"))),y()(o).on("mouseout",(()=>y()(o).css("cursor","default"))),t.append(o)}}var Y=n(50),X=n(893);class Z{constructor(){const t=Object.keys(T.Rv).concat(O.NI.HELM);this.moleculeImgDiv=r.block([]),this.outputTableDiv=r.div([]),this.formatChoiceInput=r.choiceInput("",O.NI.HELM,t,(async()=>{this.format=this.formatChoiceInput.value,this.updateTable(),await this.updateMolImg()})),this.sequenceInputBase=r.textInput("",s.T_,(()=>{this.onInput.next()})),this.init(),i.debounce(this.onInput,300).subscribe((async()=>{this.init(),this.formatChoiceInput.value=this.format,this.updateTable(),await this.updateMolImg()}))}onInput=new a.Subject;moleculeImgDiv;outputTableDiv;formatChoiceInput;sequenceInputBase;molfile;sequence;format;async getHtmlElement(){const t=new D(this.sequenceInputBase,B),e=r.button("Get SDF",(()=>{this.saveMolfile()}),"Save structure as SDF"),n=r.button("Copy SMILES",(()=>{this.copySmiles()}),"Copy SMILES for the sequence"),o={format:r.div([this.formatChoiceInput]),textInput:t.root},i=r.table([o],(t=>[t.format,t.textInput]));i.classList.add("st-main-input-table");const s=r.block([this.outputTableDiv,e,n]),a=r.box(r.div([i,s,this.moleculeImgDiv],{style:{paddingTop:"20px",paddingLeft:"20px"}}));return this.formatChoiceInput.value=this.format,this.updateTable(),await this.updateMolImg(),a}saveMolfile(){const t=new F(this.sequence,!1,this.formatChoiceInput.value).convert()+"\n$$$$";(0,I.L)(this.sequence+".sdf",encodeURIComponent(t))}copySmiles(){const t=i.chem.convert(this.molfile,i.chem.Notation.MolBlock,i.chem.Notation.Smiles);navigator.clipboard.writeText(t).then((()=>o.shell.info(Y.AU)))}updateTable(){this.outputTableDiv.innerHTML="";const t=this.format?new E.b(this.sequence).getInvalidCodeIndex(this.format):0,e=(0,H.D)(this.sequence,t,this.format),n=[];for(const t of Object.keys(e)){const i="indexOfFirstInvalidChar"in e?r.divH([]):r.link(e[t],(()=>navigator.clipboard.writeText(e[t]).then((()=>o.shell.info(Y.AU)))),Y.wm,"");n.push({format:t,sequence:i})}const i=r.table(n,(t=>[t.format,t.sequence]),["FORMAT","SEQUENCE"]);this.outputTableDiv.append(i),this.outputTableDiv.classList.add("st-main-output-table")}async updateMolImg(){const t=new z(this.molfile);await t.drawMolecule(this.moleculeImgDiv,500,170),y()(this.moleculeImgDiv).find("canvas").css("float","inherit")}init(){this.sequence=this.getFormattedSequence(),this.format=new M(this.sequence).getFormat(),this.molfile=this.getMolfile()}getFormattedSequence(){return this.sequenceInputBase.value.replace(/\s/g,"")}getMolfile(){if(!this.format)return"";if(this.format===O.NI.HELM){const t=new X.I(this.sequence,this.format).convertTo(O.NI.AXOLABS);return new F(t,!1,O.NI.AXOLABS).convert()}return new F(this.sequence,!1,this.format).convert()}}var K=n(865),Q={};Q.styleTagTransform=b(),Q.setAttributes=m(),Q.insert=p().bind(null,"head"),Q.domAPI=d(),Q.insertStyleElement=A(),c()(K.Z,Q),K.Z&&K.Z.locals&&K.Z.locals;var J=n(837);function tt(t,e){if(""===t)return"";const n=new M(t).getFormat();if(!n)return"";let o="";try{o=new F(t,e,n).convert()}catch(t){const e=(0,G.O)(t);console.error(e)}return o}function et(t,e,n,o){const i=[t,e,n].filter((t=>""!==t.strand));if(1===i.length)return tt(i[0].strand,i[0].invert);{const i=tt(t.strand,t.invert),r=[tt(e.strand,e.invert),tt(n.strand,n.invert)].filter((t=>""!==t));return(0,J.v5)({senseStrands:[i],antiStrands:r},o)}}const nt=["ss","as","as2"];class ot{constructor(){this.onInput=new a.Subject,this.onInvalidInput=new a.Subject,this.inputBase=Object.fromEntries(nt.map((t=>[t,r.textInput("","",(()=>{this.onInput.next()}))]))),this.useChiralInput=r.boolInput("Use chiral",!0),this.saveAllStrandsInput=r.boolInput("Save as one entity",!0),r.tooltip.bind(this.saveAllStrandsInput.root,"Save SDF with all strands in one molfile"),this.directionInversion=Object.fromEntries(nt.map((t=>[t,!1]))),this.moleculeImgDiv=r.block([]),y()(this.moleculeImgDiv).addClass("st-sdf-mol-img"),i.debounce(this.onInput,300).subscribe((async()=>{await this.updateMoleculeImg()})),i.debounce(this.onInvalidInput,1e3).subscribe((async()=>{o.shell.warning("Insert Sense strand")}))}onInput;onInvalidInput;useChiralInput;saveAllStrandsInput;inputBase;directionInversion;moleculeImgDiv;async getHtmlDivElement(){const t=this.getTableInput(),e=this.getBoolInputsAndButton();await this.updateMoleculeImg();const n=r.divH([e,this.moleculeImgDiv]);y()(n).addClass("st-sdf-bottom");const o=r.divV([t,n]);return y()(o).addClass("st-sdf-body"),o}getBoolInputsAndButton(){const t=r.buttonsInput([r.bigButton("Save SDF",(()=>{const t=this.getStrandData();!function(t,e,n,i,r){const s=[t.strand,e.strand,n.strand].filter((t=>""!==t));if(0===s.length||1===s.length&&""===t.strand)o.shell.warning("Enter SS and AS/AS2 to save SDF");else{let a;if(r)a=et(t,e,n,i)+"\n$$$$\n";else{const d=tt(t.strand,t.invert),h=tt(e.strand,e.invert),p=tt(n.strand,n.invert);a=d+"\n> <Sequence>\nSense Strand\n$$$$\n",h&&(a+=h+"\n> <Sequence>\nAnti Sense\n$$$$\n"),p&&(a+=p+"\n> <Sequence>\nAnti Sense 2\n$$$$\n")}const l=new Date;function c(t){return t>=10?t.toString():"0"+t.toString()}const u=l.getFullYear()+"-"+c(l.getMonth()+1)+"-"+c(l.getDate())+"_"+c(l.getHours())+"-"+c(l.getMinutes())+"-"+c(l.getSeconds());(0,I.L)(`SequenceTranslator-${u}.sdf`,encodeURIComponent(a))}}(t.ss,t.as,t.as2,this.useChiralInput.value,this.saveAllStrandsInput.value)}))]),e=[this.saveAllStrandsInput.root,this.useChiralInput.root,t],n=r.divV(e);for(const t of e)y()(t).addClass("st-sdf-bool-button-block");return n}getTableInput(){const t=Object.fromEntries(nt.map((t=>[t,new D(this.inputBase[t],B)]))),e=Object.fromEntries(nt.map(((t,e)=>{const n=0===e?"5′ → 3′":"3′ → 5′";return[t,r.choiceInput(`${t.toUpperCase()} direction`,n,["5′ → 3′","3′ → 5′"])]})));nt.forEach(((t,n)=>{e[t].onChanged((()=>{let o="3′ → 5′"===e[t].value;n>0&&(o=!o),this.directionInversion[t]=o,this.onInput.next()}))}));const n=["Sense Strand","Anti Sense","Anti Sense 2"],o=new Map(nt.map(((t,e)=>[t,n[e]]))),i=Object.fromEntries(nt.map((t=>[t,r.label(o.get(t))]))),s=nt.map((n=>({label:i[n],textInput:t[n].root,choiceInput:e[n].root}))),a=r.table(s,(t=>[t.label,t.textInput,t.choiceInput]));y()(a).css("margin-top","10px");for(const t of nt){let n=i[t].parentElement;n.classList.add("st-sdf-input-form"),y()(n).css("padding-top","3px"),n=e[t].root.parentElement,n.classList.add("st-sdf-input-form","st-sdf-direction-choice"),n=this.inputBase[t].root.parentElement,n.classList.add("st-sdf-text-input-td")}return a}getStrandData(){return Object.fromEntries(nt.map(((t,e)=>{let n=this.directionInversion[t];return[t,{strand:this.inputBase[t].value.replace(/\s*/g,""),invert:n}]})))}getMolfile(t,e,n){return""!==t.strand||""===e.strand&&""===n.strand?et(t,e,n,this.useChiralInput.value):(this.onInvalidInput.next(),"")}async updateMoleculeImg(){let t="";try{const e=this.getStrandData();t=this.getMolfile(e.ss,e.as,e.as2)}catch(t){const e=(0,G.O)(t);console.error(e)}const e=new z(t);await e.drawMolecule(this.moleculeImgDiv,650,150),y()(this.moleculeImgDiv).find("canvas").css("float","inherit")}}const it="SequenceTranslator",rt="400px",st="SS",at="AS",lt=[st,at],ct={[st]:"Sense strand",[at]:"Anti sense"},ut="THREE_PRIME",dt="FIVE_PRIME",ht=[ut,dt],pt={[ut]:3,[dt]:5};function ft(t){return"(o)"===t.slice(-3)}function mt(t){let e=0;for(;e<t.length&&ft(t[e]);)e++;return e===t.length-1?0:e}function gt(t,e){const n=document.createElement("canvas").getContext("2d");return n.font=String(e),2*n.measureText(t).width}function At(t,e){return ft(t[e])||!O.mc.includes(t[e])?"":t[e]}function vt(t){const e=T.al[t].color.match(/\d+/g).map((t=>Number(t)));return.299*e[0]+.587*e[1]+.114*e[2]>186?"#33333":"#ffffff"}function bt(t){return T.al[t].color}const Ct={xmlns:"http://www.w3.org/2000/svg",render:function(t,e){const n=document.createElementNS(this.xmlns,"svg");return n.setAttribute("id","mySvg"),n.setAttribute("width",String(t)),n.setAttribute("height",String(e)),n},circle:function(t,e,n,o){const i=document.createElementNS(this.xmlns,"circle");return i.setAttribute("cx",String(t)),i.setAttribute("cy",String(e)),i.setAttribute("r",String(n)),i.setAttribute("fill",o),i},text:function(t,e,n,o,i){const r=document.createElementNS(this.xmlns,"text");return r.setAttribute("x",String(e)),r.setAttribute("y",String(n)),r.setAttribute("font-size",String(o)),r.setAttribute("font-weight","normal"),r.setAttribute("font-family","Arial"),r.setAttribute("fill",i),r.innerHTML=t,r},star:function(t,e,n){const o=document.createElementNS(this.xmlns,"polygon");return o.setAttribute("points",function(t,e){const n=Math.PI/5;let o="";for(let i=0;i<10;i++){const r=i%2==0?6:3;o+=`${t+Math.cos(i*n+60)*r},${e+Math.sin(i*n+60)*r} `}return o}(t,e)),o.setAttribute("fill",n),o}};function xt(t,e){const n=T.al[e].symbols.join("");return n.repeat(Math.floor(t/4))+n.slice(0,t%4)}async function wt(t){return await o.dapi.users.current().then((e=>{const[n,o]=function(t){let e=-1;for(let n=0;n<t.length;n++)if("("===t[n]){e=n;break}return-1===e?["",""]:t.slice(e+9,t.length-1).split(" ").slice(1)}(t);return e.firstName!==n||e.lastName!==o}))}function yt(t){let e=t.length+1;for(let n=0;n<t.length;n++)if("("===t[n]){e=n;break}return t.slice(0,e-1)}function Et(t,e,n,o,i,r){let s=-1,a=t.replace(/[AUGC]/g,(function(o){s++;const i=T.al,r=(Object.keys(i),i.RNA.symbols.indexOf(o));let a=i[e[s].value].symbols[r];return ft(e[s].value)&&(s<t.length/2&&!ft(e[s+1].value)?a=a+o+"f":s>t.length/2&&!ft(e[s-1].value)&&(a=o+"f"+a)),n[s].value?a+"s":a}));return 3===a.slice(0,5).split("mU").length&&(a="(uu)"+a.slice(4)),3===a.slice(a.length-7).split("mU").length&&(a=a.slice(0,a.length-4)+"(uu)"),o.value+(r?"s":"")+a+i.value}const It=15,Ot=30,St=17,Tt="red",Mt="var(--grey-6)",Bt="red",Nt="SS: 5'",Lt="AS: 3'",Dt=Math.max(gt(Nt,St),gt(Lt,St)),kt=Math.max(gt("3'",St),gt("5'",St)),Pt=0+Dt-5,Vt={TITLE:It,SS_INDICES:30,SS_CIRCLES:52.5,SS_TEXTS:60,AS_CIRCLES:97.5,AS_TEXTS:105,AS_INDICES:127.5,comment:t=>t?165:127.5,circlesInLegends:t=>t?142.5:90,textLegend:t=>t?147:Vt.AS_CIRCLES-3,svgHeight:t=>t?165:135};function Ft(t,e,n,o,i,r,s,a,l,c,u,d){function h(t){return Math.round((t+E)*M/(w.length+E)+6)}function p(t,e){return x+(A-t+e+1)*Ot}function f(t,e,n){return n<10||O.mc.includes(t[e])?-5:-10}n=n.reverse(),i=i.reverse();const m=mt(n),g=mt(o),A=Math.max(n.length-m,o.length-g),v=Math.max(m,g),b=Ot*(A+v),C=Math.max(gt(s,St),gt(c,St)),x=Math.max(gt(a,St),gt(l,St)),w=e?[...new Set(n.concat(o))]:[...new Set(n)],y=e?i.concat(r).includes(!0):i.includes(!0),E=y?1:0,I=m*Ot+p(-.5,0),S=g*Ot+p(-.5,0),T=Math.max(I,S)+C+Ot*v,M=Dt+C+b+x+kt+Ot,B=Ct.render(M,Vt.svgHeight(e));B.append(Ct.text(Nt,0,Vt.SS_TEXTS,St,Mt),e?Ct.text(Lt,0,Vt.AS_TEXTS,St,Mt):"",Ct.text("3'",T,Vt.SS_TEXTS,St,Mt),e?Ct.text("5'",T,Vt.AS_TEXTS,St,Mt):"",Ct.text(a,Pt,Vt.SS_TEXTS,St,Bt),e?Ct.text(l,Pt,Vt.AS_TEXTS,St,Bt):"",Ct.text(s,I,Vt.SS_TEXTS,St,Bt),e?Ct.text(c,S,Vt.AS_TEXTS,St,Bt):"",Ct.text(u,0,Vt.comment(e),14,Mt),y?Ct.star(It,Vt.circlesInLegends(e),Tt):"",y?Ct.text("ps linkage",22,Vt.textLegend(e),14,Mt):"");const N=n.filter((t=>!ft(t))).length;let L=N;for(let t=n.length-1;t>-1;t--){const e=p(t,m)+f(n,n.length-t,N-L);ft(n[t])||L--;const o=!ft(n[t])&&d.includes(n[t])?String(N-L):"";B.append(Ct.text(o,e,Vt.SS_INDICES,14,Mt),Ct.circle(p(t,m),Vt.SS_CIRCLES,It,bt(n[t])),Ct.text(At(n,t),e,Vt.SS_TEXTS,St,vt(n[t])),i[t]?Ct.star(p(t,m)+It,Vt.SS_TEXTS+5,Tt):"")}B.append(i[n.length]?Ct.star(p(n.length,m)+It,Vt.SS_TEXTS+5,Tt):"");const D=o.filter((t=>!ft(t))).length;if(e){let t=D;for(let e=o.length-1;e>-1;e--){ft(o[e])||t--;const n=p(e,g)+f(o,e,t+1),i=!ft(o[e])&&d.includes(o[e])?String(t+1):"";B.append(Ct.text(i,n,Vt.AS_INDICES,14,Mt),Ct.circle(p(e,g),Vt.AS_CIRCLES,It,bt(o[e])),Ct.text(At(o,e),p(e,g)+f(o,e,t+1),Vt.AS_TEXTS,St,vt(o[e])),r[e]?Ct.star(p(e,g)+It,Vt.AS_TEXTS+5,Tt):"")}B.append(r[o.length]?Ct.star(p(o.length,g)+It,Vt.AS_TEXTS+5,Tt):"")}const k=`${t} for ${N}${e?`/${D}`:""}mer`;B.append(Ct.text(k,15,Vt.TITLE,St,"black"));for(let t=0;t<w.length;t++)B.append(Ct.circle(h(t),Vt.circlesInLegends(e),6,bt(w[t])),Ct.text(w[t],h(t)+6+4,Vt.textLegend(e),14,Mt));return B}var _t=n(803);class Ht{get htmlDivElement(){function t(e){b[e].innerHTML="",C[e]=C[e].concat(Array(v[e]-x[e].length).fill(A)),x[e]=x[e].concat(Array(v[e]-x[e].length).fill(g));let o=0;for(let i=0;i<w[e].value;i++)C[e][i]=r.boolInput("",C[e][i].value,(()=>{s(),n()})),x[e][i]=r.choiceInput("",x[e][i].value,p,(e=>{m.includes(e)||(m.push(e),H.append(r.divText("",{style:{width:"25px"}}),r.boolInput(e,!0,(t=>{if(t)m.includes(e)||m.push(e);else{const t=m.indexOf(e,0);t>-1&&m.splice(t,1)}s()})).root)),t(at),s(),n()})),y()(x[e][i].root).addClass("st-pattern-choice-input"),ft(x[e][i].value)||o++,b[e].append(r.divH([r.div([r.label(ft(x[e][i].value)?"":String(o))],{style:{width:"20px"}}),r.block75([x[e][i].root]),r.div([C[e][i]])],{style:{alignItems:"center"}}))}function e(){Object.values(w).every((t=>t.value<35))?(lt.forEach((e=>{w[e].value>v[e]&&(v[e]=w[e].value),t(e)})),s(),lt.forEach((t=>{""===S[t].value&&(O[t].value=xt(w[t].value,g.value))})),n()):r.dialog("Sequence length is out of range").add(r.divText("Sequence length should be less than "+35..toString()+" due to UI constrains.")).add(r.divText("Please change sequence length in order to define new pattern.")).show()}function n(){const t=[!0,U.value];lt.forEach(((e,n)=>{t[n]&&(N[e].value=Et(O[e].value,x[e],C[e],B[e][dt],B[e][ut],M[e].value))}))}function s(){k.innerHTML="",k.append(r.span([Ft(yt(G.value),U.value,x[st].slice(0,w[st].value).map((t=>t.value)),x[at].slice(0,w[at].value).map((t=>t.value)),[M[st].value].concat(C[st].slice(0,w[st].value).map((t=>t.value))),[M[at].value].concat(C[at].slice(0,w[at].value).map((t=>t.value))),B[st][ut].value,B[st][dt].value,B[at][ut].value,B[at][dt].value,W.value,m)]))}async function a(t){const e=i.TaskBarProgressIndicator.create("Loading pattern...");await o.dapi.userDataStorage.get(it,!1).then((e=>{const n=JSON.parse(e[t]);g.value=function(t){const e={};let n=t[0],o=1;for(let i=0;i<t.length;i++){const r=t[i];null===e[r]?e[r]=1:e[r]++,e[r]>o&&(n=r,o=e[r])}return n}(n.asBases.concat(n.ssBases)),U.value=n.asBases.length>0,G.value=t;let o=["ssBases","asBases"];lt.forEach(((t,e)=>{x[t]=[];const i=o[e];for(let e=0;e<n[i].length;e++)x[t].push(r.choiceInput("",n[i][e],p))})),o=["ssPtoLinkages","asPtoLinkages"],lt.forEach(((t,e)=>{const i=o[e];M[t].value=n[i][0],C[t]=[];for(let e=1;e<n[i].length;e++)C[t].push(r.boolInput("",n[i][e]))})),o=["ssBases","asBases"],lt.forEach(((t,e)=>{w[t].value=n[o[e]].length}));const i=[["ssThreeModification","ssFiveModification"],["asThreeModification","asFiveModification"]];lt.forEach(((t,e)=>{ht.forEach(((o,r)=>{B[t][o].value=n[i[e][r]]}))})),W.value=n.comment})),e.close()}async function l(){const t=await async function(){return await o.dapi.users.current().then((t=>" (created by "+t.friendlyName+")"))}();return G.value=G.stringValue.includes("(created by ")?yt(G.value)+t:G.stringValue+t,o.dapi.userDataStorage.postValue(it,G.value,JSON.stringify({ssBases:x[st].slice(0,w[st].value).map((t=>t.value)),asBases:x[at].slice(0,w[at].value).map((t=>t.value)),ssPtoLinkages:[M[st].value].concat(C[st].slice(0,w[st].value).map((t=>t.value))),asPtoLinkages:[M[at].value].concat(C[at].slice(0,w[at].value).map((t=>t.value))),ssThreeModification:B[st][ut].value,ssFiveModification:B[st][dt].value,asThreeModification:B[at][ut].value,asFiveModification:B[at][dt].value,comment:W.value}),!1).then((()=>o.shell.info("Pattern '"+G.value+"' was successfully uploaded!")))}async function c(){o.dapi.userDataStorage.get(it,!1).then((async t=>{const e=[],n=[];for(const o of Object.keys(t))await wt(o)?n.push(o):e.push(o);let i=r.choiceInput("Load pattern","",e,(t=>a(t)));const s=(await o.dapi.users.current()).friendlyName,l=r.choiceInput("",s,[s,"Other users"],(t=>{const u=t===s?e:n;i=r.choiceInput("Load pattern","",u,(t=>a(t))),i.root.append(l.input),i.root.append(i.input),i.input.style.maxWidth="100px",i.setTooltip("Apply Existing Pattern"),F.innerHTML="",F.append(i.root),i.root.append(r.div([r.button(r.iconFA("trash-alt",(()=>{})),(async()=>{null===i.value?o.shell.warning("Choose pattern to delete"):await wt(G.value)?o.shell.warning("Cannot delete pattern, created by other user"):await o.dapi.userDataStorage.remove(it,i.value,!1).then((()=>o.shell.info("Pattern '"+i.value+"' deleted"))),await c()}))],"ui-input-options"))}));i.root.append(l.input),i.root.append(i.input),i.input.style.maxWidth="100px",i.setTooltip("Apply Existing Pattern"),F.innerHTML="",F.append(i.root),i.root.append(r.div([r.button(r.iconFA("trash-alt",(()=>{})),(async()=>{null===i.value?o.shell.warning("Choose pattern to delete"):await wt(G.value)?o.shell.warning("Cannot delete pattern, created by other user"):await o.dapi.userDataStorage.remove(it,i.value,!1).then((()=>o.shell.info("Pattern '"+i.value+"' deleted"))),await c()}))],"ui-input-options"))}))}async function u(){await o.dapi.userDataStorage.get(it,!1).then((t=>{if(Object.keys(t).includes(G.value)){const t=r.dialog("Pattern already exists");y()(t.getButton("OK")).hide(),t.add(r.divText("Pattern name '"+G.value+"' already exists.")).add(r.divText("Replace pattern?")).addButton("YES",(async()=>{await o.dapi.userDataStorage.remove(it,G.value,!1).then((()=>l())),t.close()})).show()}else l()})),await c()}function d(t,e){const n=function(t){const e=R.value.getCol(t);let n=!0;for(let t=1;t<e.length;t++)if(e.get(t-1).length!==e.get(t).length&&0!==e.get(t).length){n=!1;break}if(!n){const n=r.dialog("Sequences lengths mismatch");y()(n.getButton("OK")).hide(),n.add(r.divText("The sequence length should match the number of Raw sequences in the input file")).add(r.divText("'ADD COLUMN' to see sequences lengths")).addButton("ADD COLUMN",(()=>{R.value.columns.addNewInt("Sequences lengths in "+t).init((t=>e.get(t).length)),o.shell.info("Column with lengths added to '"+R.value.name+"'"),n.close(),o.shell.v=o.shell.getTableView(R.value.name)})).show()}return e.get(0)!==w[st].value&&r.dialog("Length was updated by value to from imported file").add(r.divText("Latest modifications may not take effect during translation")).onOK((()=>o.shell.info("Lengths changed"))).show(),n}(t),i=R.value.getCol(t).get(0);n&&i.length!==w[e].value&&(w[e].value=R.value.getCol(t).get(0).length),O[e].value=i}function h(t){const e=R.value.getCol(t);if(e.type!==i.TYPE.INT)o.shell.error("Column should contain integers only");else if(e.categories.filter((t=>""!==t)).length<e.toList().filter((t=>""!==t)).length){const t=(n=e.getRawData(),Array.from(new Set(n)).filter((t=>n.indexOf(t)!==n.lastIndexOf(t))));r.dialog("Non-unique IDs").add(r.divText("Press 'OK' to select rows with non-unique values")).onOK((()=>{R.value.selection.init((n=>t.indexOf(e.get(n))>-1)),o.shell.v=o.shell.getTableView(R.value.name),o.shell.info("Rows are selected in table '"+R.value.name+"'")})).show()}var n}const p=Object.keys(T.al),f=p[0],m=[f],g=r.choiceInput("Sequence basis",f,p,(t=>{var e;e=t,lt.forEach((t=>{for(let n=0;n<x[t].length;n++)x[t][n].value=e})),s(),n()})),A=r.boolInput("Fully PTO",!0,(t=>{var e;lt.forEach((e=>{M[e].value=t})),e=t,lt.forEach((t=>{for(let n=0;n<C[t].length;n++)C[t][n].value=e})),s(),n()})),v=Object.fromEntries(lt.map((t=>[t,23]))),b=Object.fromEntries(lt.map((t=>[t,r.div([])]))),C=Object.fromEntries(lt.map((t=>[t,Array(23).fill(r.boolInput("",!0))]))),x=Object.fromEntries(lt.map((t=>[t,Array(23).fill(r.choiceInput("",f,p))]))),w=Object.fromEntries(lt.map((t=>{const n=r.intInput(`${ct[t]} length`,23,(()=>e()));return n.setTooltip(`Length of ${ct[t].toLowerCase()}, including overhangs`),[t,n]}))),E=Object.fromEntries(lt.map((t=>[t,""]))),I=Object.fromEntries(lt.map((t=>[t,r.div([])]))),O=Object.fromEntries(lt.map((t=>[t,r.textInput(`${ct[t]}`,xt(w[t].value,g.value))]))),S=Object.fromEntries(lt.map((t=>{const e=r.choiceInput(`${ct[t]} column`,"",[],(e=>{d(e,t),E[t]=e}));return I[t].append(e.root),[t,e]}))),M=Object.fromEntries(lt.map((t=>{const e=r.boolInput(`First ${t} PTO`,A.value,(()=>s()));return e.setTooltip(`ps linkage before first nucleotide of ${ct[t].toLowerCase()}`),[t,e]}))),B=Object.fromEntries(lt.map((t=>{const e=Object.fromEntries(ht.map((e=>{const o=r.stringInput(`${t} ${pt[e]}' Modification`,"",(()=>{s(),n()}));return o.setTooltip(`Additional ${t} ${pt[e]}' Modification`),[e,o]})));return[t,e]}))),N=Object.fromEntries(lt.map((t=>[t,r.textInput(" ",Et(O[t].value,x[t],C[t],B[t][ut],B[t][dt],M[t].value))]))),L=Object.fromEntries(lt.map((t=>[t,r.panel([r.h1(`${ct[t]}`),r.divH([r.div([r.divText("#")],{style:{width:"20px"}}),r.block75([r.divText("Modification")]),r.div([r.divText("PTO")])]),b[t]],{style:{paddingTop:"12px"}})])));lt.forEach((t=>{O[t].input.style.resize="none",O[t].input.style.minWidth=rt,N[t].input.style.resize="none",N[t].input.style.minWidth=rt,N[t].input.disabled="true";let e=r.div([r.button(r.iconFA("copy",(()=>{})),(()=>{navigator.clipboard.writeText(N[t].value).then((()=>o.shell.info("Sequence was copied to clipboard")))}))],"ui-input-options");e.style.height="inherit",N[t].root.append(e)}));const D=r.div([]),k=r.div([]),P=r.div([],"ui-form ui-form-wide"),V=r.div([]),F=r.div([]),_=r.div([]),H=r.divH([r.boolInput(f,!0,(t=>{if(t)m.includes(f)||m.push(f);else{const t=m.indexOf(f,0);t>-1&&m.splice(t,1)}s(),n()})).root]),q=r.div([w[at].root]),R=r.tableInput("Tables",o.shell.tables[0],o.shell.tables,(t=>{lt.forEach((e=>{S[e]=r.choiceInput(`${e} column`,"",t.columns.names(),(t=>{d(t,e),E[e]=t})),I[e].innerHTML="",I[e].append(S[e].root)}));const e=r.choiceInput("ID column","",t.columns.names(),(t=>{h(t),j=t}));D.innerHTML="",D.append(e.root)}));let j="";const $=r.choiceInput("ID column","",[],(t=>{h(t),j=t}));D.append($.root),c();const U=r.boolInput("Anti sense strand",!0,(t=>{L[at].hidden=!t,I[at].hidden=!t,q.hidden=!t,_.hidden=!t,P.hidden=!t,M[at].root.hidden=!t,s()}));U.setTooltip("Create antisense strand sections on SVG and table to the right");const G=r.textInput("Save as","Pattern name",(()=>s()));G.setTooltip("Name Of New Pattern"),ht.forEach((t=>{_.append(B[at][t].root)}));const W=r.textInput("Comment","",(()=>s())),z=r.bigButton("Save",(()=>{if(""!==G.value)u().then((()=>o.shell.info("Pattern saved")));else{const t=r.stringInput("Enter name","");r.dialog("Pattern Name").add(t.root).onOK((()=>{G.value=t.value,u().then((()=>o.shell.info("Pattern saved")))})).show()}})),Y=r.bigButton("Convert",(()=>{const t=[!0,U.value];if(lt.some(((e,n)=>t[n]&&""===E[e])))o.shell.info("Please select table and columns on which to apply pattern");else if(lt.some((t=>w[t].value!==O[t].value.length))){const t=r.dialog("Length Mismatch");y()(t.getButton("OK")).hide(),t.add(r.divText("Length of sequences in columns doesn't match entered length. Update length value?")).addButton("YES",(()=>{lt.forEach((t=>{w[t].value=R.value.getCol(S[t].value).getString(0).length})),t.close()})).show()}else{""!==j&&function(t,e,n){const i="ID "+n,r=o.shell.table(t).columns;r.contains(i)&&r.remove(i);const s=r.byName(e);r.addNewString(i).init((t=>""===s.getString(t)?"":s.get(t)+"_"+n))}(R.value.name,j,yt(G.value));const t=[!0,U.value];lt.forEach(((e,n)=>{t[n]&&function(t,e,n,i,r,s,a){const l="Axolabs "+e,c=o.shell.table(t).columns;c.contains(l)&&c.remove(l);const u=c.byName(e);c.addNewString(l).init((t=>""===u.getString(t)?"":Et(u.getString(t),n,i,r,s,a)))}(R.value.name,E[e],x[e],C[e],B[e][dt],B[e][ut],M[e].value)})),o.shell.v=o.shell.getTableView(R.value.name),o.shell.info((U.value?"Columns were":"Column was")+" added to table '"+R.value.name+"'"),n()}}));P.append(O[at].root),P.append(N[at].root),e();const X=r.div([r.h1("Conversion preview"),O[st].root,N[st].root,P],"ui-form ui-form-wide"),Z=r.block50([r.h1("Convert options"),R.root,I[st],I[at],D,r.buttonsInput([Y])]);Z.classList.add("ui-form");const K=r.button("Download",(()=>_t.saveSvgAsPng(document.getElementById("mySvg"),G.value,{backgroundColor:"white"}))),Q=r.panel([r.block([k],{style:{overflowX:"scroll"}}),K,H,r.div([r.div([r.divH([r.h1("Pattern options")]),r.divH([r.block([w[st].root,q,g.root,W.root,F,G.root,r.buttonsInput([z])],"ui-form"),r.block([U.root,A.root,M[st].root,M[at].root,B[st][dt].root,B[st][ut].root,_],"ui-form")])],"ui-form"),Z,X],{style:{flexWrap:"wrap"}})]);return r.info([r.divText("\n How to define new pattern:",{style:{"font-weight":"bolder"}}),r.divText("1. Choose table and columns with sense and antisense strands"),r.divText("2. Choose lengths of both strands by editing checkboxes below"),r.divText("3. Choose basis and PTO status for each nucleotide"),r.divText("4. Set additional modifications for sequence edges"),r.divText("5. Press 'Convert Sequences' button"),r.divText("This will add the result column(s) to the right of the table")],"Create and apply Axolabs translation patterns."),r.splitH([r.div([V,Q]),r.box(r.divH([L[st],L[at]]),{style:{maxWidth:"360px"}})])}}async function qt(t){try{const e={overflowX:"scroll"},n=r.div([],{style:e}),i=(0,J.$U)(t),s=.7*y()(window).height(),a=Math.max(...i.x)-Math.min(...i.x),l=Math.max(...i.y)-Math.min(...i.y),c=s/l,u=c*a,d=c*l,h=r.canvas(u*window.devicePixelRatio,d*window.devicePixelRatio);h.style.width=`${u}px`,h.style.height=`${d}px`,await async function(t,e){await o.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),r.dialog("Molecule").add(n).showModal(!0)}catch(t){const e=(0,G.O)(t);console.error(e)}}class Rt{static async view(){const t=S.A.getInstance().getTableForViewer();t.name="Monomer Library";const e=o.shell.addTableView(t);e.grid.props.allowEdit=!1,e.grid.onCellDoubleClick.subscribe((async t=>{const e=t.cell.value;"Molecule"===t.tableColumn?.semType&&await qt(e)}))}}class jt{constructor(){this.view=i.View.create(),this.urlRouter=new Ut(this.view),this.view.box=!0,this.view.name="Sequence Translator";const t=o.shell.windows;t.showProperties=!1,t.showToolbox=!1,t.showHelp=!1;const e=r.iconFA("book",Rt.view,"View monomer library");this.topPanel=[e],this.view.setRibbonPanels([this.topPanel]),this.tabs=new $t(new Z,new Ht,new ot,this.urlRouter)}view;tabs;topPanel;urlRouter;async createLayout(){const t=await this.tabs.getControl(),e=this.urlRouter.tabName;e&&(t.currentPane=t.getPane(e)),this.view.append(t),o.shell.addView(this.view)}}class $t{mainTab;axolabsTab;sdfTab;urlRouter;constructor(t,e,n,o){this.mainTab=t,this.axolabsTab=e,this.sdfTab=n,this.urlRouter=o}control=null;async getControl(){if(this.control)return this.control;const t=r.tabControl({[s.qt]:await this.mainTab.getHtmlElement(),[s.Iy]:this.axolabsTab.htmlDivElement,[s.sv]:await this.sdfTab.getHtmlDivElement()}),e=t.getPane(s.sv);r.tooltip.bind(e.header,"Get atomic-level structure for SS + AS/AS2 and save SDF");const n=t.getPane(s.qt);r.tooltip.bind(n.header,"Translate across formats");const o=t.getPane(s.Iy);return r.tooltip.bind(o.header,"Create modification pattern for SS and AS"),t.onTabChanged.subscribe((()=>{t.currentPane.name!==s.qt?this.urlRouter.searchParams.delete("seq"):this.urlRouter.searchParams.set("seq",this.mainTab.sequence),this.urlRouter.updatePath(t)})),this.control=t,this.control}}class Ut{view;constructor(t){this.view=t,this.pathParts=window.location.pathname.split("/"),this.searchParams=new URLSearchParams(window.location.search)}searchParams;pathParts;get urlParamsString(){return Object.entries(this.searchParams).map((([t,e])=>`${t}=${encodeURIComponent(e)}`)).join("&")}updatePath(t){const e=Object.entries(this.searchParams).map((([t,e])=>`${t}=${encodeURIComponent(e)}`)).join("&");this.view.path=`/apps/SequenceTranslator/${t.currentPane.name}`,e&&(this.view.path+=`/?${e}`)}get tabName(){const t=this.pathParts.findIndex((t=>"SequenceTranslator"===t));return-1===t?"":this.pathParts[t+1]}}var Gt,Wt,zt=n(895);wu;class Yt{constructor(t,e,n){this.name=t,this.alphabet=e,this.cutoff=n}}(Wt=Gt||(Gt={})).FASTA="fasta",Wt.SEPARATOR="separator",Wt.HELM="helm";const Xt=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"])}}};new Yt("PT",Xt.fasta.peptide,.5),new Yt("DNA",Xt.fasta.dna,.55),new Yt("RNA",Xt.fasta.rna,.55);class Zt extends Float32Array{}class Kt{static makePalette(t,e=!1,n=Kt){const o={};return t.forEach((t=>{const n=t[0],i=t[1];n.forEach(((t,n)=>{o[t]=this.colourPalette[i][e?0:n]}))})),new n(o)}constructor(t){this._palette=t}get(t){return this._palette[t]}}Kt.undefinedColor="rgb(100,100,100)",Kt.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 Qt extends Kt{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,Qt)),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,Qt)),this.grokGroups}static get RasMol(){return void 0===this.rasMol&&(this.rasMol=new Qt({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 Qt.aaSynonyms?Qt.aaSynonyms[t]:t;return super.get(e)}}Qt.aaSynonyms={MeNle:"L",MeA:"A",MeG:"G",MeF:"F"};class Jt{static getPalette(t="grok"){switch(t){case"grok":return Qt.GrokGroups;case"lesk":return Qt.Lesk;default:throw new Error(`ChemPalette: scheme \`${t}\` does not exist`)}}static getInnerOuter(t){let e=0,n="",o="";for(const i of t)"("==i?e++:")"==i?e--:e?n+=i:o+=i;return isNaN(parseInt(n))?[o,n]:[o,""]}static getColorAAPivot(t="",e="grok"){const n=this.getPalette(e);let[o,i]=this.getInnerOuter(t);if(o=o.length>6?`${o.slice(0,3)}...`:o,i=i.length>6?`${i.slice(0,3)}...`:i,1==t.length||"("==t[1]){const e=t[0]?.toUpperCase();return e in n?[n.get(e),e,i,1]:[this.undefinedColor,o,i,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,i,2]:[this.undefinedColor,o,i,2]}if(t.substring(0,3)in this.AAFullNames&&(3==t.length||"("==t[3])){const e=this.AAFullNames[t.substring(0,3)];return e in n?[n.get(e),e,i,3]:[this.undefinedColor,o,i,3]}if(t[0]?.toLowerCase()==t[0]&&t.substring(1,3)in this.AAFullNames&&(4==t.length||"("==t[4])){const e=this.AAFullNames[t.substring(1,3)];return e in n?[n.get(e),e,i,4]:[this.undefinedColor,o,i,4]}return[this.undefinedColor,o,i,0]}}Jt.SemType="Aminoacids",Jt.SemTypeMultipleAlignment="AminoacidsMultipleAlignment",Jt.undefinedColor="rgb(100,100,100)",Jt.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"},Jt.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"},Jt.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(*)*"},Jt.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 te{}te.SemType="Nucleotides",te.SemTypeMultipleAlignment="NucleotidesMultipleAlignment",te.Names={A:"Adenine",C:"Cytosine",G:"Guanine",T:"Thymine",U:"Uracil"};class ee{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 ne{}class oe extends ne{static buildPalette(){return[].concat(...Object.values(Kt.colourPalette))}get(t){const e=ee.hashCode(t)%oe.palette.length;return function(t){if(null==t)return"rgb(100,100,100)";const e=i.Color.fromHtml(t),n=i.Color.g(e),o=i.Color.r(e),r=i.Color.b(e),s=Math.sqrt(Math.pow(0-o,2)+Math.pow(0-n,2)+Math.pow(0-r,2));return s>210?`rgb(${o/s*210},${n/s*210},${r/s*210})`:i.Color.toRgb(e)}(oe.palette[e])}}oe.palette=oe.buildPalette();new Uint32Array(65536);var ie,re;function se(t){const e=t instanceof Error?t.message:t.toString(),n=t instanceof Error?t.stack:void 0;o.shell.error(e),ue.logger.error(t.message,void 0,n)}(re=ie||(ie={})).HAMMING="Hamming",re.LEVENSHTEIN="Levenshtein",re.NEEDLEMANN_WUNSCH="Needlemann-Wunsch",ie.HAMMING,ie.LEVENSHTEIN,ie.NEEDLEMANN_WUNSCH,new class{constructor(){this.uhTemp=`units-handler.${i.SEMTYPE.MACROMOLECULE}`}},Gt.FASTA,Gt.SEPARATOR,Gt.HELM;var ae=n(61);async function le(t){let e,n;await(0,T.VO)(),await ue.initMonomerLib();const o=new jt;await o.createLayout(),e=await o.tabs.getControl(),n=e.panes,e.currentPane=n[t]}class ce extends i.Package{_monomerLib;get monomerLib(){if(!this._monomerLib)throw new Error("ST: monomer lib not loaded");return this._monomerLib}async initMonomerLib(){if(void 0!==this._monomerLib)return;const t=i.TaskBarProgressIndicator.create("Initializing Sequence Translator monomer library ...");try{const e=await async function(){const t=i.Func.find({package:"Bio",name:"getMonomerLibHelper"});if(0===t.length)throw new Error('Package "Bio" must be installed for MonomerLibHelper.');return(await t[0].prepare().call()).getOutputParamValue()}();this._monomerLib=await e.readLibrary(zt.BX,zt.a_)}catch(t){const e=t.hasOwnProperty("message")?t.message:t.toString();throw new Error("Loading monomer library: "+e)}finally{t.close()}}}const ue=new ce;async function de(){const t=i.TaskBarProgressIndicator.create("Loading Sequence Translator app ...");try{await he();const e=new jt;await e.createLayout()}catch(t){const e=t.hasOwnProperty("message")?t.message:t.toString();throw o.shell.error("Loading Sequence Translator application error: "+e),t}finally{t.close()}}async function he(){await(0,T.VO)(),await ue.initMonomerLib()}function pe(){const t=S.A.getInstance().getCodesToWeightsMap();return Object.fromEntries(t)}function fe(t){const e=new E.b(t),n=new M(t).getFormat();return null!==n&&e.isValidSequence(n)}function me(t,e){return new F(t,e,"GCRS").convert()}function ge(t){return(0,J.v5)(t,!0)}async function Ae(){await async function(){try{le(0)}catch(t){se(t)}}()}async function ve(){await async function(){try{async function t(t,n,o){await(0,ae.gw)(3e3);const i=document.querySelectorAll(".st-pattern-choice-input > select");e=i.length;const r=i[o(n)];r.value=t;const s=new Event("input");r.dispatchEvent(s)}let e;le(1),["DNA","invAb","Z-New"].forEach((async(e,n)=>{t(e,n,(t=>2*t))})),["2'-O-Methyl","2'-Fluoro","2'-O-MOE"].forEach((async(n,o)=>{t(n,o,(t=>e-2-2*t))}))}catch(n){se(n)}}()}async function be(){await async function(){try{await le(2)}catch(t){se(t)}}()}async function Ce(t,e,n){return await he(),new X.I(t,e).convertTo(n)}},50:(t,e,n)=>{n.d(e,{AU:()=>o,wm:()=>i});const o="Copied",i="Copy sequence"},11:(t,e,n)=>{n.d(e,{Iy:()=>i,T_:()=>s,qt:()=>o,sv:()=>r});const o="SEQUENCE",i="PATTERN",r="SDF",s="Afcgacsu"},976:t=>{t.exports=DG},469:t=>{t.exports=grok}},e={};function n(o){var i=e[o];if(void 0!==i)return i.exports;var r=e[o]={id:o,exports:{}};return t[o](r,r.exports,n),r.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var o in e)n.o(e,o)&&!n.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},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.nc=void 0;var o=n(563);sequencetranslator=o})();
|
|
1
|
+
var sequencetranslator;(()=>{"use strict";var t={622:(t,e,n)=>{n.d(e,{w:()=>r});class o{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 o=this.isWhitespace(n)?e:e-1;for(let t=0;t<o;t++)n=this.getNextColumnIdx(n);return n}parseAtomTypes(){const t=this.atomCount,e=new Array(t);let n=this.getAtomBlockIdx();for(let o=0;o<t;o++)n=this.shiftIdxToAtomType(n),e[o]=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 o=this.getAtomBlockIdx();for(let r=0;r<this.atomCount;r++){o=this.shiftIdxToXColumn(o);for(const i of[t,e,n])i[r]=this.parseFloatValue(o),o=this.getNextColumnIdx(o);o=this.getNextLineIdx(o)}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 o=new Uint16Array(2);o[0]=this.parseIntValue(e),e=this.getNextColumnIdx(e),o[1]=this.parseIntValue(e),t[n]=o,e=this.getNextLineIdx(e)}return t}parseBondTypes(){const t=this.bondCount,e=new Uint16Array(t);let n=this.getBondBlockIdx();for(let o=0;o<t;o++)n=this.shiftIdxToBondType(n),e[o]=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 r extends o{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 o=0;o<e;o++){if(n=this.shiftIdxToAtomType(n),t(this.fileContent.charCodeAt(n),n))return!0;n=this.getNextLineIdx(n)}return!1}}},577:(t,e,n)=>{n.d(e,{u:()=>r});var o=n(622);class r extends o.w{constructor(t){super(t),this.init(t)}shiftIdxToAtomType(t){return this.shiftIdxToSpecifiedColumn(t,4)}getCountsLineIdx(){return this.fileContent.indexOf("M V30 COUNTS ")}getAtomBlockIdx(){let t=this.fileContent.indexOf("M V30 BEGIN ATOM");return t=this.getNextLineIdx(t),t}shiftIdxToXColumn(t){let e=this.shiftIdxToAtomType(t);return this.isQuote(e)?(e=this.getNextIdenticalChar(e),e=this.getNextColumnIdx(e),e):this.shiftIdxToSpecifiedColumn(t,5)}shiftIdxToBondedAtomsPair(t){return this.shiftIdxToSpecifiedColumn(t,5)}shiftIdxToBondType(t){return this.shiftIdxToSpecifiedColumn(t,4)}getBondBlockIdx(){return this.getNextLineIdx(this.fileContent.indexOf("M V30 BEGIN BOND"))}static validate(t){return-1!==t.indexOf("V3000")&&-1!==t.indexOf("M END")}parseAtomAndBondCounts(){let t=this.fileContent.indexOf("M V30 COUNTS ")+14,e=this.fileContent.indexOf(" ",t+1);const 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))}}}},61:(t,e,n)=>{n.d(e,{gw:()=>r}),n(469),n(976);var o;function r(t){return e=this,n=void 0,r=function*(){yield new Promise((e=>setTimeout(e,t)))},new((o=void 0)||(o=Promise))((function(t,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(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(s,a)}l((r=r.apply(e,n||[])).next())}));var e,n,o,r}!function(t){t.notNull=function(t,e){if(null==t)throw new Error(`${null==e?"Value":e} not defined`)}}(o||(o={}))},604:(t,e,n)=>{function o(t){var e;return"string"==typeof t||t instanceof String?t:"$thrownJsError"in t?o(t.$thrownJsError):t instanceof Error?null!==(e=t.stack)&&void 0!==e?e:t.message:t.toString()}n.d(e,{O:()=>o})},490:(t,e,n)=>{n.d(e,{Z:()=>a});var o=n(537),r=n.n(o),i=n(645),s=n.n(i)()(r());s.push([t.id,".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.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 Mono', 'Roboto Mono Local', monospace;\n font-size: 12px;\n color: transparent;\n white-space: pre-wrap;\n word-wrap: break-word;\n}\n","",{version:3,sources:["webpack://./src/view/style/colored-text-input.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,0DAA0D;EAC1D,eAAe;EACf,kBAAkB;EAClB,qBAAqB;EACrB,qBAAqB;AACvB",sourcesContent:[".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.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 Mono', 'Roboto Mono Local', monospace;\n font-size: 12px;\n color: transparent;\n white-space: pre-wrap;\n word-wrap: break-word;\n}\n"],sourceRoot:""}]);const a=s},753:(t,e,n)=>{n.d(e,{Z:()=>a});var o=n(537),r=n.n(o),i=n(645),s=n.n(i)()(r());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-input-form {\n text-align: right;\n vertical-align: top;\n min-width: 95px;\n}\n\n.st-structure-direction-choice label {\n min-width: 100px;\n float: right;\n}\n\n.st-structure-direction-choice div {\n justify-content: right;\n}\n\n.st-structure-text-input-td { /* Style for td containing textarea */\n width: 100%;\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","",{version:3,sources:["webpack://./src/view/style/structure-app.css"],names:[],mappings:"AAAA,gGAAgG;;AAEhG;EACE,mBAAmB;AACrB;;AAEA;EACE,iBAAiB;EACjB,mBAAmB;EACnB,eAAe;AACjB;;AAEA;EACE,gBAAgB;EAChB,YAAY;AACd;;AAEA;EACE,sBAAsB;AACxB;;AAEA,8BAA8B,qCAAqC;EACjE,WAAW;AACb;;AAEA;EACE,kBAAkB;EAClB,YAAY;AACd;;AAEA;EACE,sBAAsB;EACtB,mBAAmB;AACrB;;AAEA;EACE,2BAA2B;EAC3B,iBAAiB;AACnB",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-input-form {\n text-align: right;\n vertical-align: top;\n min-width: 95px;\n}\n\n.st-structure-direction-choice label {\n min-width: 100px;\n float: right;\n}\n\n.st-structure-direction-choice div {\n justify-content: right;\n}\n\n.st-structure-text-input-td { /* Style for td containing textarea */\n width: 100%;\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"],sourceRoot:""}]);const a=s},602:(t,e,n)=>{n.d(e,{Z:()=>a});var o=n(537),r=n.n(o),i=n(645),s=n.n(i)()(r());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}\n\n.st-translator-input-table td:has(textarea) {\n width: 100%;\n padding-right: 20px;\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 table tbody tr td { */\n/* max-width: 20%; */\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/view/style/translator-app.css"],names:[],mappings:"AAAA,gGAAgG;AAChG;EACE,WAAW;AACb;;AAEA;EACE,WAAW;EACX,mBAAmB;AACrB;;AAEA;EACE,gBAAgB;EAChB,mBAAmB;AACrB;;AAEA;EACE,gBAAgB;EAChB,kBAAkB;EAClB,mBAAmB;AACrB;;AAEA;EACE,WAAW;EACX,mBAAmB;AACrB;;AAEA,oDAAoD;AACpD,sBAAsB;AACtB,MAAM;;AAEN;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}\n\n.st-translator-input-table td:has(textarea) {\n width: 100%;\n padding-right: 20px;\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 table tbody tr td { */\n/* max-width: 20%; */\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},645:t=>{t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var n="",o=void 0!==e[5];return e[4]&&(n+="@supports (".concat(e[4],") {")),e[2]&&(n+="@media ".concat(e[2]," {")),o&&(n+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),n+=t(e),o&&(n+="}"),e[2]&&(n+="}"),e[4]&&(n+="}"),n})).join("")},e.i=function(t,n,o,r,i){"string"==typeof t&&(t=[[null,t,void 0]]);var s={};if(o)for(var a=0;a<this.length;a++){var l=this[a][0];null!=l&&(s[l]=!0)}for(var c=0;c<t.length;c++){var u=[].concat(t[c]);o&&s[u[0]]||(void 0!==i&&(void 0===u[5]||(u[1]="@layer".concat(u[5].length>0?" ".concat(u[5]):""," {").concat(u[1],"}")),u[5]=i),n&&(u[2]?(u[1]="@media ".concat(u[2]," {").concat(u[1],"}"),u[2]=n):u[2]=n),r&&(u[4]?(u[1]="@supports (".concat(u[4],") {").concat(u[1],"}"),u[4]=r):u[4]="".concat(r)),e.push(u))}},e}},537:t=>{t.exports=function(t){var e=t[1],n=t[3];if(!n)return e;if("function"==typeof btoa){var o=btoa(unescape(encodeURIComponent(JSON.stringify(n)))),r="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(o),i="/*# ".concat(r," */");return[e].concat([i]).join("\n")}return[e].join("\n")}},803:(t,e)=>{var n;!function(){var o=e||{}||this||window;void 0===(n=function(){return o}.apply(e,[]))||(t.exports=n),o.default=o;var r="http://www.w3.org/2000/xmlns/",i="http://www.w3.org/2000/svg",s=/url\(["']?(.+?)["']?\)/,a={woff2:"font/woff2",woff:"font/woff",otf:"application/x-font-opentype",ttf:"application/x-font-ttf",eot:"application/vnd.ms-fontobject",sfnt:"application/font-sfnt",svg:"image/svg+xml"},l=function(t){return t instanceof HTMLElement||t instanceof SVGElement},c=function(t){if(!l(t))throw new Error("an HTMLElement or SVGElement is required; got "+t)},u=function(t){return new Promise((function(e,n){l(t)?e(t):n(new Error("an HTMLElement or SVGElement is required; got "+t))}))},d=function(t,e,n){var o=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==o||isNaN(parseFloat(o))?0:o},h=function(t){for(var e=window.atob(t.split(",")[1]),n=t.split(",")[0].split(":")[1].split(";")[0],o=new ArrayBuffer(e.length),r=new Uint8Array(o),i=0;i<e.length;i++)r[i]=e.charCodeAt(i);return new Blob([o],{type:n})},p={},f=null,g=function(t,e){var n=e||{},o=n.selectorRemap,r=n.modifyStyle,i=n.modifyCss,l=n.fonts,c=n.excludeUnusedCss,u=i||function(t,e){return(o?o(t):t)+"{"+(r?r(e):e)+"}\n"},d=[],h=void 0===l,g=l||[];return(f||(f=Array.from(document.styleSheets).map((function(t){try{return{rules:t.cssRules,href:t.href}}catch(e){return console.warn("Stylesheet could not be loaded: "+t.href,e),{}}})))).forEach((function(e){var n=e.rules,o=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))d.push(u(e.selectorText,e.style.cssText));else if(h&&e.cssText.match(/^@font-face/)){var n=function(t,e){var n=t.cssText.match(s),o=n&&n[1]||"";if(o&&!o.match(/^data:/)&&"about:blank"!==o){var r,i,l=o.startsWith("../")?e+"/../"+o:o.startsWith("./")?e+"/."+o:o;return{text:t.cssText,format:(r=l,i=Object.keys(a).filter((function(t){return r.indexOf("."+t)>0})).map((function(t){return a[t]})),i?i[0]:(console.error("Unknown font format for "+r+". Fonts may not be working correctly."),"application/octet-stream")),url:l}}}(e,o);n&&g.push(n)}else c||d.push(e.cssText)}))})),function(t){return Promise.all(t.map((function(t){return new Promise((function(e,n){if(p[t.url])return e(p[t.url]);var o=new XMLHttpRequest;o.addEventListener("load",(function(){var n=function(t){for(var e="",n=new Uint8Array(t),o=0;o<n.byteLength;o++)e+=String.fromCharCode(n[o]);return window.btoa(e)}(o.response),r=t.text.replace(s,'url("data:'+t.format+";base64,"+n+'")')+"\n";p[t.url]=r,e(r)})),o.addEventListener("error",(function(n){console.warn("Failed to load font from: "+t.url,n),p[t.url]=null,e(null)})),o.addEventListener("abort",(function(n){console.warn("Aborted loading font from: "+t.url,n),e(null)})),o.open("GET",t.url),o.responseType="arraybuffer",o.send()}))}))).then((function(t){return t.filter((function(t){return t})).join("")}))}(g).then((function(t){return d.join("\n")+t}))},m=function(){if(!navigator.msSaveOrOpenBlob&&!("download"in document.createElement("a")))return{popup:window.open()}};o.prepareSvg=function(t,e,n){c(t);var o=e||{},s=o.left,a=void 0===s?0:s,l=o.top,u=void 0===l?0:l,h=o.width,p=o.height,f=o.scale,m=void 0===f?1:f,A=o.responsive,v=void 0!==A&&A,x=o.excludeCss,b=void 0!==x&&x;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,o){var r=document.createElement("canvas"),i=new Image;i.crossOrigin="anonymous",i.src=n,i.onerror=function(){return o(new Error("Could not load "+n))},i.onload=function(){r.width=i.width,r.height=i.height,r.getContext("2d").drawImage(i,0,0),t.setAttributeNS("http://www.w3.org/1999/xlink","href",r.toDataURL("image/png")),e(!0)}}))):Promise.resolve(null)})))}(t).then((function(){var o=t.cloneNode(!0);o.style.backgroundColor=(e||{}).backgroundColor||t.style.backgroundColor;var s=function(t,e,n,o){if("svg"===t.tagName)return{width:n||d(t,e,"width"),height:o||d(t,e,"height")};if(t.getBBox){var r=t.getBBox(),i=r.x,s=r.y;return{width:i+r.width,height:s+r.height}}}(t,o,h,p),l=s.width,c=s.height;if("svg"!==t.tagName){if(!t.getBBox)return void console.error("Attempted to render non-SVG element",t);null!=o.getAttribute("transform")&&o.setAttribute("transform",o.getAttribute("transform").replace(/translate\(.*?\)/,""));var f=document.createElementNS("http://www.w3.org/2000/svg","svg");f.appendChild(o),o=f}if(o.setAttribute("version","1.1"),o.setAttribute("viewBox",[a,u,l,c].join(" ")),o.getAttribute("xmlns")||o.setAttributeNS(r,"xmlns",i),o.getAttribute("xmlns:xlink")||o.setAttributeNS(r,"xmlns:xlink","http://www.w3.org/1999/xlink"),v?(o.removeAttribute("width"),o.removeAttribute("height"),o.setAttribute("preserveAspectRatio","xMinYMin meet")):(o.setAttribute("width",l*m),o.setAttribute("height",c*m)),Array.from(o.querySelectorAll("foreignObject > *")).forEach((function(t){t.setAttributeNS(r,"xmlns","svg"===t.tagName?i:"http://www.w3.org/1999/xhtml")})),!b)return g(t,e).then((function(t){var e=document.createElement("style");e.setAttribute("type","text/css"),e.innerHTML="<![CDATA[\n"+t+"\n]]>";var r=document.createElement("defs");r.appendChild(e),o.insertBefore(r,o.firstChild);var i=document.createElement("div");i.appendChild(o);var s=i.innerHTML.replace(/NS\d+:href/gi,'xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href');if("function"!=typeof n)return{src:s,width:l,height:c};n(s,l,c)}));var A=document.createElement("div");A.appendChild(o);var x=A.innerHTML;if("function"!=typeof n)return{src:x,width:l,height:c};n(x,l,c)}))},o.svgAsDataUri=function(t,e,n){return c(t),o.prepareSvg(t,e).then((function(t){var e=t.src,o=t.width,r=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 " ">]>'+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,o,r),i}))},o.svgAsPngUri=function(t,e,n){c(t);var r=e||{},i=r.encoderType,s=void 0===i?"image/png":i,a=r.encoderOptions,l=void 0===a?.8:a,u=r.canvg,d=function(t){var e=t.src,o=t.width,r=t.height,i=document.createElement("canvas"),a=i.getContext("2d"),c=window.devicePixelRatio||1;i.width=o*c,i.height=r*c,i.style.width=i.width+"px",i.style.height=i.height+"px",a.setTransform(c,0,0,c,0,0),u?u(i,e):a.drawImage(e,0,0);var d=void 0;try{d=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(d,i.width,i.height),Promise.resolve(d)};return u?o.prepareSvg(t,e).then(d):o.svgAsDataUri(t,e).then((function(t){return new Promise((function(e,n){var o=new Image;o.onload=function(){return e(d({src:o,width:o.width,height:o.height}))},o.onerror=function(){n("There was an error loading the data URI as an image on the following SVG\n"+window.atob(t.slice(26))+"Open the following link to see browser's diagnosis\n"+t)},o.src=t}))}))},o.download=function(t,e,n){if(navigator.msSaveOrOpenBlob)navigator.msSaveOrOpenBlob(h(e),t);else{var o=document.createElement("a");if("download"in o){o.download=t,o.style.display="none",document.body.appendChild(o);try{var r=h(e),i=URL.createObjectURL(r);o.href=i,o.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."),o.href=e}o.click(),document.body.removeChild(o)}else n&&n.popup&&(n.popup.document.title=t,n.popup.location.replace(e))}},o.saveSvg=function(t,e,n){var r=m();return u(t).then((function(t){return o.svgAsDataUri(t,n||{})})).then((function(t){return o.download(e,t,r)}))},o.saveSvgAsPng=function(t,e,n){var r=m();return u(t).then((function(t){return o.svgAsPngUri(t,n||{})})).then((function(t){return o.download(e,t,r)}))}}()},379:t=>{var e=[];function n(t){for(var n=-1,o=0;o<e.length;o++)if(e[o].identifier===t){n=o;break}return n}function o(t,o){for(var i={},s=[],a=0;a<t.length;a++){var l=t[a],c=o.base?l[0]+o.base:l[0],u=i[c]||0,d="".concat(c," ").concat(u);i[c]=u+1;var h=n(d),p={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==h)e[h].references++,e[h].updater(p);else{var f=r(p,o);o.byIndex=a,e.splice(a,0,{identifier:d,updater:f,references:1})}s.push(d)}return s}function r(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,r){var i=o(t=t||[],r=r||{});return function(t){t=t||[];for(var s=0;s<i.length;s++){var a=n(i[s]);e[a].references--}for(var l=o(t,r),c=0;c<i.length;c++){var u=n(i[c]);0===e[u].references&&(e[u].updater(),e.splice(u,1))}i=l}}},569:t=>{var e={};t.exports=function(t,n){var o=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(!o)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");o.appendChild(n)}},216:t=>{t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},565:(t,e,n)=>{t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},795:t=>{t.exports=function(t){var e=t.insertStyleElement(t);return{update:function(n){!function(t,e,n){var o="";n.supports&&(o+="@supports (".concat(n.supports,") {")),n.media&&(o+="@media ".concat(n.media," {"));var r=void 0!==n.layer;r&&(o+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),o+=n.css,r&&(o+="}"),n.media&&(o+="}"),n.supports&&(o+="}");var i=n.sourceMap;i&&"undefined"!=typeof btoa&&(o+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(i))))," */")),e.styleTagTransform(o,t,e.options)}(e,t,n)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},589:t=>{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))}}},29:(t,e,n)=>{n.d(e,{NI:()=>r,mc:()=>o});const o=["A","G","C","U","T"];var r;!function(t){t.HELM="HELM",t.AXOLABS="Axolabs"}(r||(r={}))},895:(t,e,n)=>{n.d(e,{BX:()=>o,Dv:()=>a,VV:()=>l,Xz:()=>c,a_:()=>r,dz:()=>s,pl:()=>i});const o="System:AppData/SequenceTranslator",r="monomer-lib.json",i="System:AppData/SequenceTranslator",s="axolabs-style.json",a="formats-to-helm.json",l="codes-to-symbols.json",c="linkers.json"},996:(t,e,n)=>{n.d(e,{BF:()=>l,Rv:()=>a,VO:()=>u,al:()=>s,iA:()=>c});var o=n(976),r=n(895);const i=new o.FileSource(r.pl);let s,a,l,c;async function u(){[s,a,l,c].every((t=>void 0!==t))||(s=await d(r.dz),a=await d(r.Dv),l=await d(r.VV),c=await d(r.Xz))}async function d(t){let e;try{e=JSON.parse(await i.readAsText(t))}catch(e){const n=e.hasOwnProperty("message")?e.message:e.toString();throw new Error(`Error loading json from ${t}:`+n)}return e}},800:(t,e,n)=>{n.d(e,{$3:()=>r,DD:()=>o,s8:()=>i});const o={NUCLEOSIDE:"nucleoside",LINKAGE:"phosphateBackbone"},r="p",i="<?>"},112:(t,e,n)=>{n.d(e,{D:()=>l});var o=n(29),r=n(800),i=n(893),s=n(996),a=n(559);function l(t,e,n){const l=Object.keys(s.Rv).concat([o.NI.HELM]);if(!t||-1!==e&&n!==o.NI.HELM)return{};if(!l.includes(n))throw new Error(`${n} format is not supported by SequenceTranslator`);const c=l.filter((t=>t!=n)).sort(((t,e)=>t.localeCompare(e))),u=new i.I(t,n),d=Object.fromEntries(c.map((t=>{let e;try{e=u.convertTo(t)}catch{e=null}return[t,e]})).filter((([t,e])=>e))),h=function(t,e){const n=new RegExp("\\([^()]*\\)","g"),i=t.match(n);if(!i)return null;return i.map((t=>{const n=t.replace(/[\[\]()]/g,"");return o.mc.includes(n)?n:e.getNaturalAnalogBySymbol(n)})).map((t=>t||r.s8)).join("")}(n===o.NI.HELM?t:d[o.NI.HELM],a.A.getInstance());return h&&(d.Nucleotides=h),d}},893:(t,e,n)=>{n.d(e,{I:()=>a});var o=n(29),r=n(800),i=n(996);const s={LEFT:"RNA1{",RIGHT:"}$$$$"};class a{sequence;sourceFormat;constructor(t,e){this.sequence=t,this.sourceFormat=e}convertTo(t){const e=Object.keys(i.Rv);if(this.sourceFormat===o.NI.HELM&&e.includes(t))return u(this.sequence,t);if(e.includes(this.sourceFormat)&&t===o.NI.HELM)return d(this.sequence,this.sourceFormat);if([this.sourceFormat,t].every((t=>e.includes(t))))return u(d(this.sequence,this.sourceFormat),t);throw new Error(`ST: unsupported translation direction ${this.sourceFormat} -> ${t}`)}}function l(t){return t.map((t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"))).map((t=>t.includes("(")||t.includes(")")?t:`(?<!\\([^()]*)${t}(?![^()]*\\))`)).join("|")}function c(t,e){return e.length-t.length}function u(t,e){const n=function(t){const e={};return Object.values(t).forEach((t=>{Object.entries(t).forEach((([t,n])=>{const o=n.replace(/\)p/g,")").replace(/\]p/g,"]");void 0===e[o]?e[o]=[t]:e[o].push(t)}))})),Object.entries(e).forEach((([t,n])=>{const o=n.sort(c);e[t]=o[0]})),e}(i.Rv[e]),o=new RegExp(l(Object.values(s)),"g");let a=t.replace(o,"");const u=Object.keys(n).sort(c),d=new RegExp(l(u)+"|.","g");return a=a.replace(d,(t=>u.includes(t)?n[t]:"p"===t||"."===t?t:"?")).replace(/\?+/g,r.s8).replace(/p\.|\./g,""),a=a.replace(/<empty>/g,""),a=a.replace(/\/\//g,"/"),a}function d(t,e){const n=i.Rv[e],o=Object.assign({},...Object.values(n)),a=Object.keys(o).sort(c),u=new RegExp(l(a)+"|\\([^()]*\\)|.","g"),d=l(Array.from(new Set(Object.values(n[r.DD.LINKAGE]))).sort(c)),h=new RegExp(`${r.$3}.(${d})`,"g");let p=t.replace(u,(t=>a.includes(t)?o[t]+".":"?"));return p=p.replace(/\?+/g,`${r.s8}.`),p=p.slice(0,-1),p[p.length-1]===r.$3&&(p=p.slice(0,-1)),p=p.replace(h,((t,e)=>e)),p=p.replace(/<empty>/g,""),`${s.LEFT+p+s.RIGHT}`}},669:(t,e,n)=>{n.d(e,{LR:()=>i,Y3:()=>s,xB:()=>r});var o=n(469);function r(t){return t.sort(((t,e)=>e.length-t.length))}function i(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 s(t,e,n="Oligo app"){try{return await t()}catch(t){const e=t.hasOwnProperty("message")?t.message:t.toString();throw o.shell.error(`${n} error: `+e),t}finally{e&&e()}}},559:(t,e,n)=>{n.d(e,{A:()=>a});var o=n(976),r=n(340),i=n(29),s=n(996);class a{constructor(){const t=r._package.monomerLib;if(null===t)throw new Error("SequenceTranslator: monomer library is null");this.lib=t,this.allMonomers=this.getAllMonomers()}lib;static instance;allMonomers;formatMonomerForViewer(t){const e={};return e.name=t.symbol,e.symbol=t.symbol,e.molfile=t.molfile,this.getAllFormats().forEach((n=>{if(n===i.NI.HELM)return;const o=s.BF[n],r=Object.keys(o).filter((e=>o[e]===t.symbol));e[n]=r.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}static getInstance(){return void 0===a.instance&&(a.instance=new a),a.instance}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(s.BF[t]))}getCodesByFormat(t){return Object.keys(s.BF[t])}getAllFormats(){return Object.keys(s.BF)}getTableForViewer(){const t=this.allMonomers.map((t=>this.formatMonomerForViewer(t)));return o.DataFrame.fromObjects(t)}getCodesToWeightsMap(){const t=new Map;return Object.entries(s.BF).forEach((([e,n])=>{Object.entries(n).forEach((([e,n])=>{const o=this.getMonomer(n).meta?.molecularWeight;t.set(e,o)}))})),t}}},947:(t,e,n)=>{n.d(e,{b:()=>s});var o=n(29),r=n(559),i=n(669);class s{sequence;constructor(t){this.sequence=t,this.libWrapper=r.A.getInstance()}libWrapper;getInvalidCodeIndex(t){if(t===o.NI.HELM)return this.sequence.length;const e=["r","d"],n=(0,i.xB)(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&&o.mc.includes(this.sequence[r])&&e.includes(this.sequence[r-2]))break;if(e.includes(this.sequence[r+1])&&o.mc.includes(this.sequence[r])){r++;break}r+=t.length}return r===this.sequence.length&&(r=-1),r}isValidSequence(t){return-1===this.getInvalidCodeIndex(t)}}},175:(t,e,n)=>{n.d(e,{$:()=>o});const o="p"},837:(t,e,n)=>{function o(t,e=!0){let n="\nDatagrok macromolecule handler\n\n";n+=" 0 0 0 0 0 0 999 V3000\n",n+="M V30 BEGIN CTAB\n";let o="",a="",l="";const c=[];let u=0,d=0,h=0;if(t.antiStrands.length>0)for(let e=0;e<t.antiStrands.length;e++)t.antiStrands[e]=r(t.antiStrands[e]);let p=!1;const f=t.senseStrands.concat(t.antiStrands);let g=0;for(let e=0;e<f.length;e++){f[e]=f[e].replaceAll("(-\nM V30 ","(").replaceAll("-\nM V30 ","").replaceAll(" )",")");const n=i(f[e]),r=s(f[e]);if(e>=t.senseStrands.length?!1===p&&(p=!0,h=0):g=Math.min(g,Math.min(...r.y.filter((t=>t<0)))),p){const t=Math.min(...r.x)-h,e=Math.max(...r.y)+5;for(let e=0;e<r.x.length;e++)r.x[e]-=t;for(let t=0;t<r.y.length;t++)r.y[t]-=e-g}let l=f[e].indexOf("M V30 BEGIN ATOM");l=f[e].indexOf("\n",l);let m=l,A=l;for(let t=0;t<n.natom;t++){m=f[e].indexOf("V30",m)+4,A=f[e].indexOf(" ",m);const n=parseInt(f[e].substring(m,A))+u;f[e]=f[e].slice(0,m)+n+f[e].slice(A),m=f[e].indexOf(" ",m)+1,m=f[e].indexOf(" ",m)+1,A=f[e].indexOf(" ",m);let o=Math.round(1e4*r.x[t])/1e4;f[e]=f[e].slice(0,m)+o+f[e].slice(A),m=f[e].indexOf(" ",m)+1,A=f[e].indexOf(" ",m),o=Math.round(1e4*r.y[t])/1e4,f[e]=f[e].slice(0,m)+o+f[e].slice(A),m=f[e].indexOf("\n",m)+1}const v=f[e].indexOf("M V30 END ATOM");o+=f[e].substring(l+1,v);let x=f[e].indexOf("M V30 BEGIN BOND");x=f[e].indexOf("\n",x),m=x,A=x;for(let t=0;t<n.nbond;t++){m=f[e].indexOf("V30",m)+4,A=f[e].indexOf(" ",m);const t=parseInt(f[e].substring(m,A))+d;f[e]=f[e].slice(0,m)+t+f[e].slice(A),m=f[e].indexOf(" ",m)+1,m=f[e].indexOf(" ",m)+1,A=f[e].indexOf(" ",m);let n=parseInt(f[e].substring(m,A))+u;f[e]=f[e].slice(0,m)+n+f[e].slice(A),m=f[e].indexOf(" ",m)+1,A=Math.min(f[e].indexOf("\n",m),f[e].indexOf(" ",m)),n=parseInt(f[e].substring(m,A))+u,f[e]=f[e].slice(0,m)+n+f[e].slice(A),m=f[e].indexOf("\n",m)+1}const b=f[e].indexOf("M V30 END BOND");a+=f[e].substring(x+1,b);let C=f[e].indexOf("M V30 MDLV30/STEABS ATOMS=(");for(;-1!==C;){C+=28;const t=f[e].indexOf(")",C);f[e].substring(C,t).split(" ").slice(1).forEach((t=>{c.push(parseInt(t)+u)})),C=t,C=f[e].indexOf("M V30 MDLV30/STEABS ATOMS=(",C)}u+=n.natom,d+=n.nbond,h+=Math.max(...r.x)+5}const m=Math.ceil(c.length/4);l+="M V30 MDLV30/STEABS ATOMS=("+c.length+" -\n";for(let t=0;t<m;t++){l+="M V30 ";const e=t+1===m?c.length-4*(m-1):4;for(let n=0;n<e;n++)l+=n+1===e?t===m-1?c[4*t+n]+")\n":c[4*t+n]+" -\n":c[4*t+n]+" "}return n+="M V30 COUNTS "+u+" "+d+" 0 0 0\n",n+="M V30 BEGIN ATOM\n",n+=o,n+="M V30 END ATOM\n",n+="M V30 BEGIN BOND\n",n+=a,n+="M V30 END BOND\n",e&&c.length>0?(n+="M V30 BEGIN COLLECTION\n",n+=l,n+="M V30 END COLLECTION\n"):n=n.replace(/ CFG=\d/g," "),n+="M V30 END CTAB\n",n+="M END",n}function r(t){const e=s(t),n=e.atomIndex.length,o=(Math.max(...e.x)+Math.min(...e.x))/2,r=(Math.max(...e.y)+Math.min(...e.y))/2;for(let t=0;t<n;t++)e.x[t]-=o,e.y[t]-=r;const i=Math.PI,a=Math.cos(i),l=Math.sin(i);for(let t=0;t<n;t++){const n=e.x[t];e.x[t]=n*a-e.y[t]*l,e.y[t]=n*l+e.y[t]*a}const c=Math.max(...e.y);for(let t=0;t<n;t++)e.x[t]+=o,e.y[t]-=c;let u=t.indexOf("M V30 BEGIN ATOM");u=t.indexOf("\n",u);let d=u;for(let o=0;o<n;o++)u=t.indexOf("V30",u)+4,u=t.indexOf(" ",u)+1,u=t.indexOf(" ",u)+1,d=t.indexOf(" ",u)+1,d=t.indexOf(" ",d),u=(t=t.slice(0,u)+e.x[o]+" "+e.y[o]+t.slice(d)).indexOf("\n",u)+1;return t}function i(t){let e=(t=t.replaceAll("\r","")).indexOf("COUNTS")+7,n=t.indexOf(" ",e);const o=parseInt(t.substring(e,n));return e=n+1,n=t.indexOf(" ",e),{natom:o,nbond:parseInt(t.substring(e,n))}}function s(t){const e=i(t);let n=t.indexOf("M V30 BEGIN ATOM");n=t.indexOf("\n",n);let o=n;const r=Array(e.natom),s=Array(e.natom),a=Array(e.natom),l=Array(e.natom);for(let i=0;i<e.natom;i++)n=t.indexOf("V30",n)+4,o=t.indexOf(" ",n),r[i]=parseInt(t.substring(n,o)),n=o+1,o=t.indexOf(" ",n),s[i]=t.substring(n,o),n=o+1,o=t.indexOf(" ",n),a[i]=parseFloat(t.substring(n,o)),n=o+1,o=t.indexOf(" ",n),l[i]=parseFloat(t.substring(n,o)),n=t.indexOf("\n",n)+1;return{atomIndex:r,atomType:s,x:a,y:l}}n.d(e,{$U:()=>s,v5:()=>o})},340:(t,e,n)=>{n.r(e),n.d(e,{_package:()=>pe,demoOligoPattern:()=>Ee,demoOligoStructure:()=>Ie,demoTranslateSequence:()=>Oe,getCodeToWeightsMap:()=>be,getMolfileFromGcrsSequence:()=>we,initSequenceTranslatorLibData:()=>xe,linkStrands:()=>ye,oligoPatternApp:()=>Ae,oligoStructureApp:()=>ve,oligoToolkitApp:()=>ge,oligoTranslatorApp:()=>me,translateOligonucleotideSequence:()=>Se,validateSequence:()=>Ce});var o=n(976),r=n(469);const i=ui,s=rxjs;var a=n(379),l=n.n(a),c=n(795),u=n.n(c),d=n(569),h=n.n(d),p=n(565),f=n.n(p),g=n(216),m=n.n(g),A=n(589),v=n.n(A),x=n(602),b={};b.styleTagTransform=v(),b.setAttributes=f(),b.insert=h().bind(null,"head"),b.domAPI=u(),b.insertStyleElement=m(),l()(x.Z,b),x.Z&&x.Z.locals&&x.Z.locals;var C=n(947),w=n(669),y=n(29),O=n(559),E=n(996);class I{sequence;constructor(t){this.sequence=t,this.libWrapper=O.A.getInstance(),this.formats=Object.keys(E.Rv)}libWrapper;formats;getFormat(){if(this.sequence.startsWith("RNA"))return y.NI.HELM;const t=this.getListOfPossibleSynthesizersByFirstMatchedCode();if(0===t.length)return null;const e=new C.b(this.sequence),n=Array(t.length).fill(0);for(let o=0;o<t.length;++o){const r=t[o];n[o]=e.getInvalidCodeIndex(r)}const o=n.some((t=>-1===t))?-1:Math.max(...n);return t[n.indexOf(o)]}getListOfPossibleSynthesizersByFirstMatchedCode(){const t=this.sequence;let e=[];for(const n of this.formats){let o=(0,w.xB)(this.libWrapper.getCodesByFormat(n)),r=0;for(let e=0;e<t.length;e++)if(")"===t[e]&&e!==t.length-1){r=e+1;break}o.some((e=>e===t.slice(r,r+e.length)))&&e.push(n)}return e}}const S=$;var M=n.n(S);function T(t){let e=0;const n=new I(t).getFormat();null!==n&&(e=new C.b(t).getInvalidCodeIndex(n));const o=e<0||""===t,r=i.span([]);M()(r).css("-webkit-text-fill-color","var(--grey-6)");const s=i.span([]);return M()(s).css("-webkit-text-fill-color","red"),o?r.innerHTML=t:(r.innerHTML=t.slice(0,e),s.innerHTML=t.slice(e)),[r,s]}var B=n(490),N={};N.styleTagTransform=v(),N.setAttributes=f(),N.insert=h().bind(null,"head"),N.domAPI=u(),N.insertStyleElement=m(),l()(B.Z,N),B.Z&&B.Z.locals&&B.Z.locals;class L{textInputBase;painter;constructor(t,e,n=!0){this.textInputBase=t,this.painter=e,M()(this.root).addClass("colored-text-input"),n&&this.textInputBase.onInput((()=>{M()(this.textArea).css("height",0),M()(this.textArea).css("height",this.textArea.scrollHeight+"px")})),this.highlights=i.div([]),this.root.appendChild(this.highlights),this.colorize(),this.textInputBase.onInput((()=>this.colorize()))}highlights;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)))}}var D=n(175);class V{sequence;codeMap;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,o)=>{const r=this.getSymbolForCode(n);o>0&&function(t){return E.iA.left.includes(t)}(r)&&e.pop(),e.push(r);const i=k(r),s=o===t.length-1,a=o+1<t.length&&k(this.getSymbolForCode(t[o+1]));i||function(t){return E.iA.right.includes(t)}(r)||a||s||e.push(D.$)})),e}getSymbolForCode(t){let e=this.codeMap.get(t);return e??=t,e}parseRawSequence(){const t=this.getAllCodesOfFormat(),e=[];let n=0;for(;n<this.sequence.length;){const o=t.find((t=>t===this.sequence.substring(n,n+t.length)));e.push(o),n+=o.length}return e}getAllCodesOfFormat(){let t=Array.from(this.codeMap.keys());return(0,w.xB)(t)}}function k(t){return E.iA.phosphate.includes(t)}class P{invert;constructor(t,e=!1,n){this.invert=e,this.lib=O.A.getInstance();const o=this.lib.getCodeToSymbolMap(n);this.parser=new V(t,o)}parser;lib;convert(){const t=this.parser.parseSequence(),e=[];t.forEach(((t,n)=>{const o=this.getMonomerMolfile(t,n);e.push(o)}));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 o=t.substring(e,n);return o=o.replace(/(CFG=)([13])/g,((t,e,n)=>"1"===n?`${e}3`:"3"===n?`${e}1`:t)),t.substring(0,e)+o+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,o=e.atomIndex.indexOf(1),r=e.atomIndex.indexOf(n),i=(e.x[r]+e.x[o])/2,s=(e.y[r]+e.y[o])/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[o];for(let t=0;t<n;t++)e.x[t]-=a;let l=t.indexOf("M V30 BEGIN ATOM");l=t.indexOf("\n",l);let c=l;for(let o=0;o<n;o++)l=t.indexOf("V30",l)+4,l=t.indexOf(" ",l)+1,l=t.indexOf(" ",l)+1,c=t.indexOf(" ",l)+1,c=t.indexOf(" ",c),l=(t=t.slice(0,l)+e.x[o]+" "+e.y[o]+t.slice(c)).indexOf("\n",l)+1;return t}extractAtomDataV3000(t){const e=this.extractAtomsBondsNumbersV3000(t);let n=t.indexOf("M V30 BEGIN ATOM");n=t.indexOf("\n",n);let o=n;const r=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,o=t.indexOf(" ",n),r[l]=parseInt(t.substring(n,o)),n=o+1,o=t.indexOf(" ",n),i[l]=t.substring(n,o),n=o+1,o=t.indexOf(" ",n),s[l]=parseFloat(t.substring(n,o)),n=o+1,o=t.indexOf(" ",n),a[l]=parseFloat(t.substring(n,o)),n=t.indexOf("\n",n)+1;return{atomIndex:r,atomType:i,x:s,y:a}}extractAtomsBondsNumbersV3000(t){let e=(t=t.replaceAll("\r","")).indexOf("COUNTS")+7,n=t.indexOf(" ",e);const o=parseInt(t.substring(e,n));return e=n+1,n=t.indexOf(" ",e),{natom:o,nbond:parseInt(t.substring(e,n))}}rotateNucleotidesV3000(t){const e=this.extractAtomDataV3000(t),n=e.atomIndex.length,o=e.atomIndex.indexOf(1),r=e.atomIndex.indexOf(n);n>8&&this.fix5Prime(e,o,r);const i=(e.x[r]+e.x[o])/2,s=(e.y[r]+e.y[o])/2;for(let t=0;t<n;t++)e.x[t]-=i,e.y[t]-=s;let a=0;if(0===e.x[o])a=e.y[o]>e.y[r]?Math.PI/2:3*Math.PI/2;else if(0===e.y[o])a=e.x[o]>e.x[r]?Math.PI:0;else{const t=e.y[o]/e.x[o];a=t>0?e.x[o]>0?Math.PI-Math.atan(t):2*Math.PI-Math.atan(t):e.x[o]>0?-Math.PI-Math.atan(t):Math.atan(t)}const l=Math.cos(a),c=Math.sin(a);for(let t=0;t<n;t++){const n=e.x[t];e.x[t]=n*l-e.y[t]*c,e.y[t]=n*c+e.y[t]*l}const u=e.x[o];for(let t=0;t<n;t++)e.x[t]-=u;let d=t.indexOf("M V30 BEGIN ATOM");d=t.indexOf("\n",d);let h=d;for(let o=0;o<n;o++)d=t.indexOf("V30",d)+4,d=t.indexOf(" ",d)+1,d=t.indexOf(" ",d)+1,h=t.indexOf(" ",d)+1,h=t.indexOf(" ",h),d=(t=t.slice(0,d)+e.x[o]+" "+e.y[o]+t.slice(h)).indexOf("\n",d)+1;return t}linkV3000(t,e=!0){let n="\nDatagrok macromolecule handler\n\n";n+=" 0 0 0 0 0 0 999 V3000\n",n+="M V30 BEGIN CTAB\n";let o="",r="",i="";const s=[];let a=0,l=0,c=0;for(let e=0;e<t.length;e++){const n=t[e].includes("MODIFICATION")&&0===e;let i=0;n&&(i=this.extractAtomDataV3000(t[e]).atomIndex.length),t[e]=t[e].replaceAll("(-\nM V30 ","(").replaceAll("-\nM V30 ","").replaceAll(" )",")");const u=this.extractAtomsBondsNumbersV3000(t[e]),d=this.extractAtomDataV3000(t[e]);let h=t[e].indexOf("M V30 BEGIN ATOM");h=t[e].indexOf("\n",h);let p=h,f=h;for(let o=0;o<u.natom;o++)if(1!==d.atomIndex[o]||0===e){p=t[e].indexOf("V30",p)+4,f=t[e].indexOf(" ",p);let o=0;n?(o=parseInt(t[e].substring(p,f)),1===o?o=i:o===i&&(o=1),o+=a):o=parseInt(t[e].substring(p,f))+a,t[e]=t[e].slice(0,p)+o+t[e].slice(f),p=t[e].indexOf(" ",p)+1,p=t[e].indexOf(" ",p)+1,f=t[e].indexOf(" ",p);const r=c-d.x[0];let s=Math.round(1e4*(parseFloat(t[e].substring(p,f))+r))/1e4;t[e]=t[e].slice(0,p)+s+t[e].slice(f),p=t[e].indexOf(" ",p)+1,f=t[e].indexOf(" ",p),s=Math.round(1e4*parseFloat(t[e].substring(p,f)))/1e4,t[e]=t[e].slice(0,p)+s+t[e].slice(f),p=t[e].indexOf("\n",p)+1}else p=t[e].indexOf("M V30",p)-1,f=t[e].indexOf("\n",p+1),t[e]=t[e].slice(0,p)+t[e].slice(f);const g=t[e].indexOf("M V30 END ATOM");o+=t[e].substring(h+1,g);let m=t[e].indexOf("M V30 BEGIN BOND");m=t[e].indexOf("\n",m),p=m,f=m;for(let o=0;o<u.nbond;o++){p=t[e].indexOf("V30",p)+4,f=t[e].indexOf(" ",p);const o=parseInt(t[e].substring(p,f))+l;t[e]=t[e].slice(0,p)+o+t[e].slice(f),p=t[e].indexOf(" ",p)+1,p=t[e].indexOf(" ",p)+1,f=t[e].indexOf(" ",p);let r=0;n?(r=parseInt(t[e].substring(p,f)),1===r?r=i:r===i&&(r=1),r+=a):r=parseInt(t[e].substring(p,f))+a,t[e]=t[e].slice(0,p)+r+t[e].slice(f),p=t[e].indexOf(" ",p)+1,f=Math.min(t[e].indexOf("\n",p),t[e].indexOf(" ",p)),r=0,n?(r=parseInt(t[e].substring(p,f)),1===r?r=i:r===i&&(r=1),r+=a):r=parseInt(t[e].substring(p,f))+a,t[e]=t[e].slice(0,p)+r+t[e].slice(f),p=t[e].indexOf("\n",p)+1}const A=t[e].indexOf("M V30 END BOND");r+=t[e].substring(m+1,A);let v=t[e].indexOf("M V30 MDLV30/STEABS ATOMS=(");for(;-1!==v;){v+=28;const n=t[e].indexOf(")",v);t[e].substring(v,n).split(" ").slice(1).forEach((t=>{s.push(parseInt(t)+a)})),v=n,v=t[e].indexOf("M V30 MDLV30/STEABS ATOMS=(",v)}a+=u.natom-1,l+=u.nbond,c+=n?Math.max(...d.x):d.x[u.natom-1]-d.x[0]}const u=Math.ceil(s.length/4);i+="M V30 MDLV30/STEABS ATOMS=("+s.length+" -\n";for(let t=0;t<u;t++){i+="M V30 ";const e=t+1===u?s.length-4*(u-1):4;for(let n=0;n<e;n++)i+=n+1===e?t===u-1?s[4*t+n]+")\n":s[4*t+n]+" -\n":s[4*t+n]+" "}return a++,n+="M V30 COUNTS "+a+" "+l+" 0 0 0\n",n+="M V30 BEGIN ATOM\n",n+=o,n+="M V30 END ATOM\n",n+="M V30 BEGIN BOND\n",n+=r,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 o=e+1,r=t.x[o],i=t.y[o],s=t.x[n]-r,a=t.y[n]-i,l=t.x[e]-r,c=t.y[e]-i,u=l*Math.cos(2*Math.PI/3)-c*Math.sin(2*Math.PI/3),d=l*Math.sin(2*Math.PI/3)+c*Math.cos(2*Math.PI/3),h=l-s,p=c-a,f=u-s,g=d-a;Math.sqrt(g*g+f*f)>=Math.sqrt(p*p+h*h)&&(t.x[e]=u+r,t.y[e]=d+i)}}var F,_=n(112),H=n(622);!function(t){t.HEADER="V2000",t[t.NUM_OF_HEADER_LINES=3]="NUM_OF_HEADER_LINES",t[t.NUM_OF_COUNTS_DIGITS=3]="NUM_OF_COUNTS_DIGITS",t[t.ATOM_TYPE_COL=4]="ATOM_TYPE_COL",t[t.FIRST_BONDED_ATOM_COL=1]="FIRST_BONDED_ATOM_COL",t[t.BOND_TYPE_COL=3]="BOND_TYPE_COL",t[t.RGP_SHIFT=8]="RGP_SHIFT",t.RGP_LINE="M RGP",t.A_LINE="A ",t.END="M END"}(F||(F={}));class R extends H.w{constructor(t){super(t)}static validate(t){return-1!==t.indexOf(F.HEADER)&&-1!==t.indexOf(F.END)}shiftIdxToAtomType(t){return this.shiftIdxToSpecifiedColumn(t,F.ATOM_TYPE_COL)}getCountsLineIdx(){let t=0;for(let e=0;e<F.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,F.FIRST_BONDED_ATOM_COL)}shiftIdxToBondType(t){return this.shiftIdxToSpecifiedColumn(t,F.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+F.NUM_OF_COUNTS_DIGITS;const n=parseInt(this.fileContent.substring(t,e));return t=e,e+=F.NUM_OF_COUNTS_DIGITS,{atomCount:n,bondCount:parseInt(this.fileContent.substring(t,e))}}}var q=n(577);class j{constructor(){}static getInstance(t){if(R.validate(t))return new R(t);if(q.u.validate(t))return new q.u(t);throw new Error("Malformed molfile")}}var G=n(604);const U=class extends Error{constructor(t){super(t)}};class W{constructor(t){this.molblock=t}_validMolBlock;get molblock(){return this._validMolBlock}set molblock(t){try{this.validateMolBlock(t)}catch(e){e instanceof U&&(t="");const n=(0,G.O)(e);console.error(n)}this._validMolBlock=t}validateMolBlock(t){if(""===t)throw new U("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=(0,G.O)(t);console.error(e)}}getMoleculeDimensions(){const t=j.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=i.dialog({title:"Molecule",showFooter:!1}),e=.7*M()(window).height(),n=this.getMoleculeDimensions(),o=e/n.height,r=e,s=n.width*o,a=i.canvas(s,r);await this.drawMolBlockOnCanvas(a);const l=i.block([a],{style:{overflowX:"scroll"}});t.add(l).showModal(!0),M()(t.root).find(".d4-dialog-contents").removeClass("ui-form"),M()(t.root).find(".d4-dialog-contents").removeClass("ui-panel"),M()(t.root).find(".d4-dialog-contents").addClass("ui-box"),M()(t.root).find(".d4-dialog-contents").css("padding","0")}async drawMolecule(t,e,n){t.innerHTML="";const o=i.canvas(e*window.devicePixelRatio,n*window.devicePixelRatio);o.style.width=`${e}px`,o.style.height=`${n}px`,o.style.cursor="zoom-in",this.drawMolBlockOnCanvas(o),o.addEventListener("click",(async()=>{await this.zoomIn()})),t.append(i.tooltip.bind(o,"Click to zoom"))}}var Y=n(713),z=n(511),X=n(893);class Z{constructor(){const t=Object.keys(E.Rv).concat(y.NI.HELM);this.moleculeImgDiv=i.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=i.div([]),this.formatChoiceInput=i.choiceInput("",y.NI.HELM,t,(async()=>{this.format=this.formatChoiceInput.value,this.updateTable(),await this.updateMolImg()})),this.sequenceInputBase=i.textInput("",z.T,(()=>{this.onInput.next()})),this.init(),o.debounce(this.onInput,300).subscribe((async()=>{this.init(),this.formatChoiceInput.value=this.format,this.updateTable(),await this.updateMolImg()}))}onInput=new s.Subject;moleculeImgDiv;outputTableDiv;formatChoiceInput;sequenceInputBase;molfile;sequence;format;async getHtmlElement(){const t=new L(this.sequenceInputBase,T),e=i.button("Get SDF",(()=>{this.saveMolfile()}),"Save structure as SDF"),n=i.button("Copy SMILES",(()=>{this.copySmiles()}),"Copy SMILES for the sequence"),o={format:i.div([this.formatChoiceInput]),textInput:t.root},r=i.table([o],(t=>[t.format,t.textInput]));r.classList.add("st-translator-input-table");const s=i.block([this.outputTableDiv,e,n]),a=i.box(i.panel([r,s,i.block([i.box(this.moleculeImgDiv)])]));return this.formatChoiceInput.value=this.format,this.updateTable(),await this.updateMolImg(),a}saveMolfile(){const t=new P(this.sequence,!1,this.formatChoiceInput.value).convert()+"\n$$$$";(0,w.LR)(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(Y.AU)))}updateTable(){this.outputTableDiv.innerHTML="";const t=this.format?new C.b(this.sequence).getInvalidCodeIndex(this.format):0,e=(0,_.D)(this.sequence,t,this.format),n=[];for(const t of Object.keys(e)){const o="indexOfFirstInvalidChar"in e?i.divH([]):i.link(e[t],(()=>navigator.clipboard.writeText(e[t]).then((()=>r.shell.info(Y.AU)))),Y.wm,"");n.push({format:t,sequence:o})}const o=i.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 W(this.molfile);await t.drawMolecule(this.moleculeImgDiv,500,170)}init(){this.sequence=this.getFormattedSequence(),this.format=new I(this.sequence).getFormat(),this.molfile=this.getMolfile()}getFormattedSequence(){return this.sequenceInputBase.value.replace(/\s/g,"")}getMolfile(){if(!this.format)return"";if(this.format===y.NI.HELM){const t=new X.I(this.sequence,this.format).convertTo(y.NI.AXOLABS);return new P(t,!1,y.NI.AXOLABS).convert()}return new P(this.sequence,!1,this.format).convert()}}var K=n(753),Q={};Q.styleTagTransform=v(),Q.setAttributes=f(),Q.insert=h().bind(null,"head"),Q.domAPI=u(),Q.insertStyleElement=m(),l()(K.Z,Q),K.Z&&K.Z.locals&&K.Z.locals;var J=n(837);function tt(t,e){if(""===t)return"";const n=new I(t).getFormat();if(!n)return"";let o="";try{o=new P(t,e,n).convert()}catch(t){const e=(0,G.O)(t);console.error(e)}return o}function et(t,e,n,o){const r=[t,e,n].filter((t=>""!==t.strand));if(1===r.length)return tt(r[0].strand,r[0].invert);{const r=tt(t.strand,t.invert),i=[tt(e.strand,e.invert),tt(n.strand,n.invert)].filter((t=>""!==t));return(0,J.v5)({senseStrands:[r],antiStrands:i},o)}}const nt=["ss","as","as2"];class ot{constructor(){this.onInput=new s.Subject,this.onInvalidInput=new s.Subject,this.inputBase=Object.fromEntries(nt.map((t=>[t,i.textInput("","",(()=>{this.onInput.next()}))]))),this.useChiralInput=i.boolInput("Use chiral",!0),this.saveAllStrandsInput=i.boolInput("Save as one entity",!0),i.tooltip.bind(this.saveAllStrandsInput.root,"Save SDF with all strands in one molfile"),this.directionInversion=Object.fromEntries(nt.map((t=>[t,!1]))),this.moleculeImgDiv=i.block([]),M()(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")}))}onInput;onInvalidInput;useChiralInput;saveAllStrandsInput;inputBase;directionInversion;moleculeImgDiv;async getHtmlDivElement(){const t=this.getTableInput(),e=this.getBoolInputsAndButton();await this.updateMoleculeImg();const n=i.divH([e,this.moleculeImgDiv]);M()(n).addClass("st-structure-bottom");const o=i.divV([t,n]);return M()(o).addClass("st-structure-body"),o}getBoolInputsAndButton(){const t=i.buttonsInput([i.bigButton("Save SDF",(()=>{const t=this.getStrandData();!function(t,e,n,o,i){const s=[t.strand,e.strand,n.strand].filter((t=>""!==t));if(0===s.length||1===s.length&&""===t.strand)r.shell.warning("Enter SS and optionally AS/AS2 to save SDF");else{let a;if(i)a=et(t,e,n,o)+"\n$$$$\n";else{const d=tt(t.strand,t.invert),h=tt(e.strand,e.invert),p=tt(n.strand,n.invert);a=d+"\n> <Sequence>\nSense Strand\n$$$$\n",h&&(a+=h+"\n> <Sequence>\nAnti Sense\n$$$$\n"),p&&(a+=p+"\n> <Sequence>\nAnti Sense 2\n$$$$\n")}const l=new Date;function c(t){return t>=10?t.toString():"0"+t.toString()}const u=l.getFullYear()+"-"+c(l.getMonth()+1)+"-"+c(l.getDate())+"_"+c(l.getHours())+"-"+c(l.getMinutes())+"-"+c(l.getSeconds());(0,w.LR)(`SequenceTranslator-${u}.sdf`,encodeURIComponent(a))}}(t.ss,t.as,t.as2,this.useChiralInput.value,this.saveAllStrandsInput.value)}))]),e=[this.saveAllStrandsInput.root,this.useChiralInput.root,t],n=i.divV(e);for(const t of e)M()(t).addClass("st-structure-bool-button-block");return n}getTableInput(){const t=Object.fromEntries(nt.map((t=>[t,new L(this.inputBase[t],T)]))),e=Object.fromEntries(nt.map(((t,e)=>{const n=0===e?"5′ → 3′":"3′ → 5′";return[t,i.choiceInput(`${t.toUpperCase()} direction`,n,["5′ → 3′","3′ → 5′"])]})));nt.forEach(((t,n)=>{e[t].onChanged((()=>{let o="3′ → 5′"===e[t].value;n>0&&(o=!o),this.directionInversion[t]=o,this.onInput.next()}))}));const n=["Sense Strand","Anti Sense","Anti Sense 2"],o=new Map(nt.map(((t,e)=>[t,n[e]]))),r=Object.fromEntries(nt.map((t=>[t,i.label(o.get(t))]))),s=nt.map((n=>({label:r[n],textInput:t[n].root,choiceInput:e[n].root}))),a=i.table(s,(t=>[t.label,t.textInput,t.choiceInput]));M()(a).css("margin-top","10px");for(const t of nt){let n=r[t].parentElement;n.classList.add("st-structure-input-form"),M()(n).css("padding-top","3px"),n=e[t].root.parentElement,n.classList.add("st-structure-input-form","st-structure-direction-choice"),n=this.inputBase[t].root.parentElement,n.classList.add("st-structure-text-input-td")}return a}getStrandData(){return Object.fromEntries(nt.map(((t,e)=>{let n=this.directionInversion[t];return[t,{strand:this.inputBase[t].value.replace(/\s*/g,""),invert:n}]})))}getMolfile(t,e,n){return et(t,e,n,this.useChiralInput.value)}async updateMoleculeImg(){let t="";try{const e=this.getStrandData();t=this.getMolfile(e.ss,e.as,e.as2)}catch(t){const e=(0,G.O)(t);console.error(e)}const e=new W(t);await e.drawMolecule(this.moleculeImgDiv,650,150),M()(this.moleculeImgDiv).find("canvas").css("float","inherit")}}const rt="SequenceTranslator",it="SS",st="AS",at=[it,st],lt={[it]:"Sense strand",[st]:"Anti sense"},ct="THREE_PRIME",ut="FIVE_PRIME",dt=[ct,ut],ht={[ct]:3,[ut]:5};function pt(t){return"(o)"===t.slice(-3)}function ft(t){let e=0;for(;e<t.length&&pt(t[e]);)e++;return e===t.length-1?0:e}function gt(t,e){const n=document.createElement("canvas").getContext("2d");return n.font=String(e),2*n.measureText(t).width}function mt(t,e){return pt(t[e])||!y.mc.includes(t[e])?"":t[e]}function At(t){const e=E.al[t].color.match(/\d+/g).map((t=>Number(t)));return.299*e[0]+.587*e[1]+.114*e[2]>186?"#33333":"#ffffff"}function vt(t){return E.al[t].color}const xt={xmlns:"http://www.w3.org/2000/svg",render:function(t,e){const n=document.createElementNS(this.xmlns,"svg");return n.setAttribute("id","mySvg"),n.setAttribute("width",String(t)),n.setAttribute("height",String(e)),n},circle:function(t,e,n,o){const r=document.createElementNS(this.xmlns,"circle");return r.setAttribute("cx",String(t)),r.setAttribute("cy",String(e)),r.setAttribute("r",String(n)),r.setAttribute("fill",o),r},text:function(t,e,n,o,r){const i=document.createElementNS(this.xmlns,"text");return i.setAttribute("x",String(e)),i.setAttribute("y",String(n)),i.setAttribute("font-size",String(o)),i.setAttribute("font-weight","normal"),i.setAttribute("font-family","Arial"),i.setAttribute("fill",r),i.innerHTML=t,i},star:function(t,e,n){const o=document.createElementNS(this.xmlns,"polygon");return o.setAttribute("points",function(t,e){const n=Math.PI/5;let o="";for(let r=0;r<10;r++){const i=r%2==0?6:3;o+=`${t+Math.cos(r*n+60)*i},${e+Math.sin(r*n+60)*i} `}return o}(t,e)),o.setAttribute("fill",n),o}};function bt(t,e){const n=E.al[e].symbols.join("");return n.repeat(Math.floor(t/4))+n.slice(0,t%4)}async function Ct(t){return await r.dapi.users.current().then((e=>{const[n,o]=function(t){let e=-1;for(let n=0;n<t.length;n++)if("("===t[n]){e=n;break}return-1===e?["",""]:t.slice(e+9,t.length-1).split(" ").slice(1)}(t);return e.firstName!==n||e.lastName!==o}))}function wt(t){let e=t.length+1;for(let n=0;n<t.length;n++)if("("===t[n]){e=n;break}return t.slice(0,e-1)}function yt(t,e,n,o,r,i){let s=-1,a=t.replace(/[AUGC]/g,(function(o){s++;const r=E.al,i=(Object.keys(r),r.RNA.symbols.indexOf(o));let a=r[e[s].value].symbols[i];return pt(e[s].value)&&(s<t.length/2&&!pt(e[s+1].value)?a=a+o+"f":s>t.length/2&&!pt(e[s-1].value)&&(a=o+"f"+a)),n[s].value?a+"s":a}));return 3===a.slice(0,5).split("mU").length&&(a="(uu)"+a.slice(4)),3===a.slice(a.length-7).split("mU").length&&(a=a.slice(0,a.length-4)+"(uu)"),o.value+(i?"s":"")+a+r.value}const Ot=15,Et=30,It=17,St="red",Mt="var(--grey-6)",Tt="red",Bt="SS: 5'",Nt="AS: 3'",Lt=Math.max(gt(Bt,It),gt(Nt,It)),Dt=Math.max(gt("3'",It),gt("5'",It)),Vt=0+Lt-5,kt={TITLE:Ot,SS_INDICES:30,SS_CIRCLES:52.5,SS_TEXTS:60,AS_CIRCLES:97.5,AS_TEXTS:105,AS_INDICES:127.5,comment:t=>t?165:127.5,circlesInLegends:t=>t?142.5:90,textLegend:t=>t?147:kt.AS_CIRCLES-3,svgHeight:t=>t?165:135};function Pt(t,e,n,o,r,i,s,a,l,c,u,d){function h(t){return Math.round((t+E)*T/(w.length+E)+6)}function p(t,e){return C+(A-t+e+1)*Et}function f(t,e,n){return n<10||y.mc.includes(t[e])?-5:-10}n=n.reverse(),r=r.reverse();const g=ft(n),m=ft(o),A=Math.max(n.length-g,o.length-m),v=Math.max(g,m),x=Et*(A+v),b=Math.max(gt(s,It),gt(c,It)),C=Math.max(gt(a,It),gt(l,It)),w=e?[...new Set(n.concat(o))]:[...new Set(n)],O=e?r.concat(i).includes(!0):r.includes(!0),E=O?1:0,I=g*Et+p(-.5,0),S=m*Et+p(-.5,0),M=Math.max(I,S)+b+Et*v,T=Lt+b+x+C+Dt+Et,B=xt.render(T,kt.svgHeight(e));B.append(xt.text(Bt,0,kt.SS_TEXTS,It,Mt),e?xt.text(Nt,0,kt.AS_TEXTS,It,Mt):"",xt.text("3'",M,kt.SS_TEXTS,It,Mt),e?xt.text("5'",M,kt.AS_TEXTS,It,Mt):"",xt.text(a,Vt,kt.SS_TEXTS,It,Tt),e?xt.text(l,Vt,kt.AS_TEXTS,It,Tt):"",xt.text(s,I,kt.SS_TEXTS,It,Tt),e?xt.text(c,S,kt.AS_TEXTS,It,Tt):"",xt.text(u,0,kt.comment(e),14,Mt),O?xt.star(Ot,kt.circlesInLegends(e),St):"",O?xt.text("ps linkage",22,kt.textLegend(e),14,Mt):"");const N=n.filter((t=>!pt(t))).length;let L=N;for(let t=n.length-1;t>-1;t--){const e=p(t,g)+f(n,n.length-t,N-L);pt(n[t])||L--;const o=!pt(n[t])&&d.includes(n[t])?String(N-L):"";B.append(xt.text(o,e,kt.SS_INDICES,14,Mt),xt.circle(p(t,g),kt.SS_CIRCLES,Ot,vt(n[t])),xt.text(mt(n,t),e,kt.SS_TEXTS,It,At(n[t])),r[t]?xt.star(p(t,g)+Ot,kt.SS_TEXTS+5,St):"")}B.append(r[n.length]?xt.star(p(n.length,g)+Ot,kt.SS_TEXTS+5,St):"");const D=o.filter((t=>!pt(t))).length;if(e){let t=D;for(let e=o.length-1;e>-1;e--){pt(o[e])||t--;const n=p(e,m)+f(o,e,t+1),r=!pt(o[e])&&d.includes(o[e])?String(t+1):"";B.append(xt.text(r,n,kt.AS_INDICES,14,Mt),xt.circle(p(e,m),kt.AS_CIRCLES,Ot,vt(o[e])),xt.text(mt(o,e),p(e,m)+f(o,e,t+1),kt.AS_TEXTS,It,At(o[e])),i[e]?xt.star(p(e,m)+Ot,kt.AS_TEXTS+5,St):"")}B.append(i[o.length]?xt.star(p(o.length,m)+Ot,kt.AS_TEXTS+5,St):"")}const V=`${t} for ${N}${e?`/${D}`:""}mer`;B.append(xt.text(V,15,kt.TITLE,It,"black"));for(let t=0;t<w.length;t++)B.append(xt.circle(h(t),kt.circlesInLegends(e),6,vt(w[t])),xt.text(w[t],h(t)+6+4,kt.textLegend(e),14,Mt));return B}var Ft=n(803);class _t{get htmlDivElement(){function t(e){x[e].innerHTML="",b[e]=b[e].concat(Array(v[e]-C[e].length).fill(A)),C[e]=C[e].concat(Array(v[e]-C[e].length).fill(m));let o=0;for(let r=0;r<w[e].value;r++)b[e][r]=i.boolInput("",b[e][r].value,(()=>{s(),n()})),C[e][r]=i.choiceInput("",C[e][r].value,p,(e=>{g.includes(e)||(g.push(e),_.append(i.divText("",{style:{width:"25px"}}),i.boolInput(e,!0,(t=>{if(t)g.includes(e)||g.push(e);else{const t=g.indexOf(e,0);t>-1&&g.splice(t,1)}s()})).root)),t(st),s(),n()})),M()(C[e][r].root).addClass("st-pattern-choice-input"),pt(C[e][r].value)||o++,x[e].append(i.divH([i.div([i.label(pt(C[e][r].value)?"":String(o))],{style:{width:"20px"}}),i.block75([C[e][r].root]),i.div([b[e][r]])],{style:{alignItems:"center"}}))}function e(){Object.values(w).every((t=>t.value<35))?(at.forEach((e=>{w[e].value>v[e]&&(v[e]=w[e].value),t(e)})),s(),at.forEach((t=>{""===S[t].value&&(I[t].value=bt(w[t].value,m.value))})),n()):i.dialog("Out of range").add(i.divText("Sequence length should be less than "+35..toString()+" due to UI constrains.")).onOK((()=>{Object.values(w).every((t=>t.value=34))})).onCancel((()=>{Object.values(w).every((t=>t.value=34))})).showModal(!1)}function n(){const t=[!0,G.value];at.forEach(((e,n)=>{t[n]&&(N[e].value=yt(I[e].value,C[e],b[e],B[e][ut],B[e][ct],T[e].value))}))}function s(){V.innerHTML="",V.append(i.span([Pt(wt($.value),G.value,C[it].slice(0,w[it].value).map((t=>t.value)),C[st].slice(0,w[st].value).map((t=>t.value)),[T[it].value].concat(b[it].slice(0,w[it].value).map((t=>t.value))),[T[st].value].concat(b[st].slice(0,w[st].value).map((t=>t.value))),B[it][ct].value,B[it][ut].value,B[st][ct].value,B[st][ut].value,U.value,g)]))}async function a(t){const e=o.TaskBarProgressIndicator.create("Loading pattern...");await r.dapi.userDataStorage.get(rt,!1).then((e=>{const n=JSON.parse(e[t]);m.value=function(t){const e={};let n=t[0],o=1;for(let r=0;r<t.length;r++){const i=t[r];null===e[i]?e[i]=1:e[i]++,e[i]>o&&(n=i,o=e[i])}return n}(n.asBases.concat(n.ssBases)),G.value=n.asBases.length>0,$.value=t;let o=["ssBases","asBases"];at.forEach(((t,e)=>{C[t]=[];const r=o[e];for(let e=0;e<n[r].length;e++)C[t].push(i.choiceInput("",n[r][e],p))})),o=["ssPtoLinkages","asPtoLinkages"],at.forEach(((t,e)=>{const r=o[e];T[t].value=n[r][0],b[t]=[];for(let e=1;e<n[r].length;e++)b[t].push(i.boolInput("",n[r][e]))})),o=["ssBases","asBases"],at.forEach(((t,e)=>{w[t].value=n[o[e]].length}));const r=[["ssThreeModification","ssFiveModification"],["asThreeModification","asFiveModification"]];at.forEach(((t,e)=>{dt.forEach(((o,i)=>{B[t][o].value=n[r[e][i]]}))})),U.value=n.comment})),e.close()}async function l(){const t=await async function(){return await r.dapi.users.current().then((t=>" (created by "+t.friendlyName+")"))}();return $.value=$.stringValue.includes("(created by ")?wt($.value)+t:$.stringValue+t,r.dapi.userDataStorage.postValue(rt,$.value,JSON.stringify({ssBases:C[it].slice(0,w[it].value).map((t=>t.value)),asBases:C[st].slice(0,w[st].value).map((t=>t.value)),ssPtoLinkages:[T[it].value].concat(b[it].slice(0,w[it].value).map((t=>t.value))),asPtoLinkages:[T[st].value].concat(b[st].slice(0,w[st].value).map((t=>t.value))),ssThreeModification:B[it][ct].value,ssFiveModification:B[it][ut].value,asThreeModification:B[st][ct].value,asFiveModification:B[st][ut].value,comment:U.value}),!1).then((()=>r.shell.info("Pattern '"+$.value+"' was successfully uploaded!")))}async function c(){r.dapi.userDataStorage.get(rt,!1).then((async t=>{const e=[],n=[];for(const o of Object.keys(t))await Ct(o)?n.push(o):e.push(o);let o=i.choiceInput("Load pattern","",e,(t=>a(t)));const s=(await r.dapi.users.current()).friendlyName,l=i.choiceInput("",s,[s,"Other users"],(t=>{const u=t===s?e:n;o=i.choiceInput("Load pattern","",u,(t=>a(t))),o.root.append(l.input),o.root.append(o.input),o.input.style.maxWidth="120px",o.input.style.marginLeft="12px",o.setTooltip("Apply Existing Pattern"),P.innerHTML="",P.append(o.root),o.root.append(i.div([i.button(i.iconFA("trash-alt",(()=>{})),(async()=>{null===o.value?r.shell.warning("Choose pattern to delete"):await Ct($.value)?r.shell.warning("Cannot delete pattern, created by other user"):await r.dapi.userDataStorage.remove(rt,o.value,!1).then((()=>r.shell.info("Pattern '"+o.value+"' deleted"))),await c()}))],"ui-input-options"))}));l.input.style.maxWidth="142px",o.root.append(l.input),o.root.append(o.input),o.input.style.maxWidth="100px",o.setTooltip("Apply Existing Pattern"),P.innerHTML="",P.append(o.root),o.root.append(i.div([i.button(i.iconFA("trash-alt",(()=>{})),(async()=>{null===o.value?r.shell.warning("Choose pattern to delete"):await Ct($.value)?r.shell.warning("Cannot delete pattern, created by other user"):await r.dapi.userDataStorage.remove(rt,o.value,!1).then((()=>r.shell.info("Pattern '"+o.value+"' deleted"))),await c()}))],"ui-input-options"))}))}async function u(){await r.dapi.userDataStorage.get(rt,!1).then((t=>{if(Object.keys(t).includes($.value)){const t=i.dialog("Pattern already exists");M()(t.getButton("OK")).hide(),t.add(i.divText("Pattern name '"+$.value+"' already exists.")).add(i.divText("Replace pattern?")).addButton("YES",(async()=>{await r.dapi.userDataStorage.remove(rt,$.value,!1).then((()=>l())),t.close()})).show()}else l()})),await c()}function d(t,e){const n=function(t){const e=R.value.getCol(t);let n=!0;for(let t=1;t<e.length;t++)if(e.get(t-1).length!==e.get(t).length&&0!==e.get(t).length){n=!1;break}if(!n){const n=i.dialog("Sequences lengths mismatch");M()(n.getButton("OK")).hide(),n.add(i.divText("The sequence length should match the number of Raw sequences in the input file")).add(i.divText("'ADD COLUMN' to see sequences lengths")).addButton("ADD COLUMN",(()=>{R.value.columns.addNewInt("Sequences lengths in "+t).init((t=>e.get(t).length)),r.shell.info("Column with lengths added to '"+R.value.name+"'"),n.close(),r.shell.v=r.shell.getTableView(R.value.name)})).show()}return e.get(0)!==w[it].value&&i.dialog("Length was updated by value to from imported file").add(i.divText("Latest modifications may not take effect during translation")).onOK((()=>r.shell.info("Lengths changed"))).show(),n}(t),o=R.value.getCol(t).get(0);n&&o.length!==w[e].value&&(w[e].value=R.value.getCol(t).get(0).length),I[e].value=o}function h(t){const e=R.value.getCol(t);if(e.type!==o.TYPE.INT)r.shell.error("Column should contain integers only");else if(e.categories.filter((t=>""!==t)).length<e.toList().filter((t=>""!==t)).length){const t=(n=e.getRawData(),Array.from(new Set(n)).filter((t=>n.indexOf(t)!==n.lastIndexOf(t))));i.dialog("Non-unique IDs").add(i.divText("Press 'OK' to select rows with non-unique values")).onOK((()=>{R.value.selection.init((n=>t.indexOf(e.get(n))>-1)),r.shell.v=r.shell.getTableView(R.value.name),r.shell.info("Rows are selected in table '"+R.value.name+"'")})).show()}var n}const p=Object.keys(E.al),f=p[0],g=[f],m=i.choiceInput("Sequence basis",f,p,(t=>{var e;e=t,at.forEach((t=>{for(let n=0;n<C[t].length;n++)C[t][n].value=e})),s(),n()})),A=i.boolInput("Fully PTO",!0,(t=>{var e;at.forEach((e=>{T[e].value=t})),e=t,at.forEach((t=>{for(let n=0;n<b[t].length;n++)b[t][n].value=e})),s(),n()}));A.captionLabel.classList.add("ui-label-right"),A.captionLabel.style.textAlign="left",A.captionLabel.style.maxWidth="100px",A.captionLabel.style.maxWidth="100px",A.captionLabel.style.minWidth="40px",A.captionLabel.style.width="auto";const v=Object.fromEntries(at.map((t=>[t,23]))),x=Object.fromEntries(at.map((t=>[t,i.div([])]))),b=Object.fromEntries(at.map((t=>[t,Array(23).fill(i.boolInput("",!0))]))),C=Object.fromEntries(at.map((t=>[t,Array(23).fill(i.choiceInput("",f,p))]))),w=Object.fromEntries(at.map((t=>{const n=i.intInput(`${lt[t]} length`,23,(()=>e()));return n.setTooltip(`Length of ${lt[t].toLowerCase()}, including overhangs`),[t,n]}))),y=Object.fromEntries(at.map((t=>[t,""]))),O=Object.fromEntries(at.map((t=>[t,i.div([])]))),I=Object.fromEntries(at.map((t=>[t,i.textInput("",bt(w[t].value,m.value))]))),S=Object.fromEntries(at.map((t=>{const e=i.choiceInput(`${lt[t]} column`,"",[],(e=>{d(e,t),y[t]=e}));return O[t].append(e.root),[t,e]}))),T=Object.fromEntries(at.map((t=>{const e=i.boolInput(`First ${t} PTO`,A.value,(()=>s()));return e.setTooltip(`ps linkage before first nucleotide of ${lt[t].toLowerCase()}`),e.captionLabel.classList.add("ui-label-right"),e.captionLabel.style.textAlign="left",e.captionLabel.style.maxWidth="100px",e.captionLabel.style.minWidth="40px",e.captionLabel.style.width="auto",[t,e]}))),B=Object.fromEntries(at.map((t=>{const e=Object.fromEntries(dt.map((e=>{const o=i.stringInput(`${t} ${ht[e]}' Modification`,"",(()=>{s(),n()}));return o.setTooltip(`Additional ${t} ${ht[e]}' Modification`),[e,o]})));return[t,e]}))),N=Object.fromEntries(at.map((t=>{const e=i.textInput("",yt(I[t].value,C[t],b[t],B[t][ct],B[t][ut],T[t].value));return e.input.style.minWidth="none",e.input.style.flexGrow="1",M()(e.root.lastChild).css("height","auto"),[t,e]}))),L=Object.fromEntries(at.map((t=>[t,i.block([i.h1(`${lt[t]}`),i.divH([i.div([i.divText("#")],{style:{width:"20px"}}),i.block75([i.divText("Modification")]),i.div([i.divText("PTO")])]),x[t]],{style:{paddingTop:"12px"}})])));at.forEach((t=>{I[t].input.style.resize="none",N[t].input.style.resize="none",I[t].input.style.minWidth="none",I[t].input.style.flexGrow="1",N[t].input.style.minWidth="none",N[t].input.style.flexGrow="1";let e=i.div([i.button(i.iconFA("copy",(()=>{})),(()=>{navigator.clipboard.writeText(N[t].value).then((()=>r.shell.info("Sequence was copied to clipboard")))}))],"ui-input-options");e.style.height="inherit",N[t].root.append(e)}));const D=i.div([]),V=i.div([]),k=i.div([],"ui-form ui-form-wide"),P=(i.div([]),i.div([])),F=i.form([]),_=i.divH([i.boolInput(f,!0,(t=>{if(t)g.includes(f)||g.push(f);else{const t=g.indexOf(f,0);t>-1&&g.splice(t,1)}s(),n()})).root]),H=i.div([w[st].root]),R=i.tableInput("Tables",r.shell.tables[0],r.shell.tables,(t=>{at.forEach((e=>{S[e]=i.choiceInput(`${e} column`,"",t.columns.names(),(t=>{d(t,e),y[e]=t})),O[e].innerHTML="",O[e].append(S[e].root)}));const e=i.choiceInput("ID column","",t.columns.names(),(t=>{h(t),q=t}));D.innerHTML="",D.append(e.root)}));let q="";const j=i.choiceInput("ID column","",[],(t=>{h(t),q=t}));D.append(j.root),c();const G=i.boolInput("Anti sense strand",!0,(t=>{L[st].hidden=!t,O[st].hidden=!t,H.hidden=!t,F.hidden=!t,k.hidden=!t,T[st].root.hidden=!t,s()}));G.setTooltip("Create antisense strand sections on SVG and table to the right");const $=i.textInput("Save as","Pattern name",(()=>s()));$.setTooltip("Name Of New Pattern"),dt.forEach((t=>{F.append(B[st][t].root)}));const U=i.textInput("Comment","",(()=>s())),W=i.bigButton("Save",(()=>{if(""!==$.value)u().then((()=>r.shell.info("Pattern saved")));else{const t=i.stringInput("Enter name","");i.dialog("Pattern Name").add(t.root).onOK((()=>{$.value=t.value,u().then((()=>r.shell.info("Pattern saved")))})).show()}}));$.addOptions(W);const Y=i.bigButton("Convert",(()=>{const t=[!0,G.value];if(at.some(((e,n)=>t[n]&&""===y[e])))r.shell.info("Please select table and columns on which to apply pattern");else if(at.some((t=>w[t].value!==I[t].value.length))){const t=i.dialog("Length Mismatch");M()(t.getButton("OK")).hide(),t.add(i.divText("Length of sequences in columns doesn't match entered length. Update length value?")).addButton("YES",(()=>{at.forEach((t=>{w[t].value=R.value.getCol(S[t].value).getString(0).length})),t.close()})).show()}else{""!==q&&function(t,e,n){const o="ID "+n,i=r.shell.table(t).columns;i.contains(o)&&i.remove(o);const s=i.byName(e);i.addNewString(o).init((t=>""===s.getString(t)?"":s.get(t)+"_"+n))}(R.value.name,q,wt($.value));const t=[!0,G.value];at.forEach(((e,n)=>{t[n]&&function(t,e,n,o,i,s,a){const l="Axolabs "+e,c=r.shell.table(t).columns;c.contains(l)&&c.remove(l);const u=c.byName(e);c.addNewString(l).init((t=>""===u.getString(t)?"":yt(u.getString(t),n,o,i,s,a)))}(R.value.name,y[e],C[e],b[e],B[e][ut],B[e][ct],T[e].value)})),r.shell.v=r.shell.getTableView(R.value.name),r.shell.info((G.value?"Columns were":"Column was")+" added to table '"+R.value.name+"'"),n()}}));k.append(I[st].root),k.append(N[st].root),e();const z=i.div([i.h1("Conversion preview"),I[it].root,N[it].root,k],"ui-form ui-form-wide"),X=i.block50([i.h1("Convert options"),R.root,O[it],O[st],D,i.buttonsInput([Y])]);X.classList.add("ui-form");const Z=i.link("Download",(()=>Ft.saveSvgAsPng(document.getElementById("mySvg"),$.value,{backgroundColor:"white"})),"Download pattern as PNG image",""),K=i.link("Edit pattern",(()=>{i.dialog("Edit patter").add(i.divV([i.h1("PTO"),i.divH([A.root,T[it].root,T[st].root],{style:{gap:"12px"}})])).add(i.divH([L[it],L[st]],{style:{gap:"24px"}})).onOK((()=>{r.shell.info("Saved")})).show()}),"Edit pattern","");return i.panel([i.block([V],{style:{overflowX:"scroll"}}),Z,_,i.div([i.div([i.divH([i.h1("Pattern options")]),i.divH([i.block([w[it].root,H,m.root,U.root,P,$.root,i.buttonsInput([])],"ui-form"),i.block([G.root,A.root,T[it].root,T[st].root,B[it][ut].root,B[it][ct].root,F],"ui-form")])],"ui-form"),X,z],{style:{flexWrap:"wrap"}})]),i.info([i.divText("\n How to define new pattern:",{style:{"font-weight":"bolder"}}),i.divText("1. Choose table and columns with sense and antisense strands"),i.divText("2. Choose lengths of both strands by editing checkboxes below"),i.divText("3. Choose basis and PTO status for each nucleotide"),i.divText("4. Set additional modifications for sequence edges"),i.divText("5. Press 'Convert Sequences' button"),i.divText("This will add the result column(s) to the right of the table")],"Create and apply Axolabs translation patterns."),w[it].addCaption("Length"),i.splitH([i.box(i.div([i.h1("Pattern"),G.root,w[it],w[st],m.root,U.root,P,$.root,i.h1("Convert"),R.root,S[it],S[st],j.root,i.buttonsInput([Y])],"ui-form"),{style:{maxWidth:"450px"}}),i.panel([V,_,i.divH([Z,K],{style:{gap:"12px",marginTop:"12px"}}),i.divH([i.divV([i.h1("Sense strand"),I[it].root,N[it].root],"ui-block"),i.divV([i.h1("Anti sense"),I[st],N[st]],"ui-block")],{style:{gap:"24px",marginTop:"24px"}}),i.h1("Additional modifications"),i.form([B[it][ut],B[it][ct]]),F],{style:{overflowX:"scroll",padding:"12px 24px"}})],{},!0)}}async function Ht(t){try{const e={overflowX:"scroll"},n=i.div([],{style:e}),o=(0,J.$U)(t),s=.7*M()(window).height(),a=Math.max(...o.x)-Math.min(...o.x),l=Math.max(...o.y)-Math.min(...o.y),c=s/l,u=c*a,d=c*l,h=i.canvas(u*window.devicePixelRatio,d*window.devicePixelRatio);h.style.width=`${u}px`,h.style.height=`${d}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),i.dialog("Molecule").add(n).showModal(!0)}catch(t){const e=(0,G.O)(t);console.error(e)}}class Rt{static async view(){const t=O.A.getInstance().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 Ht(e)}))}}class qt{appName;parentAppName;constructor(t,e){this.appName=t,this.parentAppName=e}async createAppLayout(){const t=o.TaskBarProgressIndicator.create(`Loading ${this.appName}...`);let e=r.shell.v?.root;e&&i.setUpdateIndicator(e,!0),await(0,w.Y3)((async()=>{await this.addView()}),(()=>t.close())),e&&i.setUpdateIndicator(e,!1)}}class jt extends qt{constructor(t){super(t),this.view=o.View.create(),this.setupView()}view;async addView(){await this.initView();const t=this.parentAppName?this.parentAppName+"/"+this.appName:this.appName;this.view.path=`/apps/${pe.name}/${t.replace(/\s/g,"")}/`,r.shell.addView(this.view)}async initView(){const t=await this.getHtml();this.view.append(t)}setupView(){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}}class Gt extends qt{constructor(t){super("Oligo Toolkit"),this.externalViewFactories=t;const e=this.getViewFactories();this.multiView=new o.MultiView({viewFactories:e})}multiView;externalViewFactories;getViewFactories(){function t(t){const e=new t(o.View.create());return e.initView(),()=>e.getView()}let e={TRANSLATOR:t(Wt),PATTERN:t(Yt),STRUCTURE:t(zt)};return this.externalViewFactories&&(e=Object.assign({},e,this.externalViewFactories)),e}getPath(){let t=this.multiView.tabs.currentPane.name;return t=t.charAt(0).toUpperCase()+t.substring(1).toLowerCase(),`/apps/${pe.name}/OligoToolkit/${t}`}setUrl(){this.multiView.path=this.getPath()}async addView(){this.multiView.tabs.onTabChanged.subscribe((()=>this.setUrl())),this.setUrl(),r.shell.addView(this.multiView)}}class $t extends jt{constructor(t,e){super(t),this.layout=e}layout;getHtml(){return Promise.resolve(this.layout)}}class Ut{constructor(){}static getUI(t){switch(t){case"Oligo Translator":return new Wt;case"Oligo Pattern":return new Yt;case"Oligo Structure":return new zt;default:throw new Error(`Unknown app name: ${t}`)}}}class Wt extends jt{constructor(){super("Oligo Translator");const t=i.iconFA("book",Rt.view,"View monomer library");this.topPanel=[t],this.view.setRibbonPanels([this.topPanel]),this.ui=new Z}topPanel;ui;getHtml(){return this.ui.getHtmlElement()}}class Yt extends jt{constructor(){super("Oligo Pattern"),this.ui=new _t}ui;getHtml(){return Promise.resolve(this.ui.htmlDivElement)}}class zt extends jt{constructor(){super("Oligo Structure"),this.ui=new ot}ui;getHtml(){return this.ui.getHtmlDivElement()}}var Xt,Zt,Kt=n(895);wu;class Qt{constructor(t,e,n){this.name=t,this.alphabet=e,this.cutoff=n}}(Zt=Xt||(Xt={})).FASTA="fasta",Zt.SEPARATOR="separator",Zt.HELM="helm";const Jt=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"])}}};new Qt("PT",Jt.fasta.peptide,.5),new Qt("DNA",Jt.fasta.dna,.55),new Qt("RNA",Jt.fasta.rna,.55);class te extends Float32Array{}class ee{static makePalette(t,e=!1,n=ee){const o={};return t.forEach((t=>{const n=t[0],r=t[1];n.forEach(((t,n)=>{o[t]=this.colourPalette[r][e?0:n]}))})),new n(o)}constructor(t){this._palette=t}get(t){return this._palette[t]}}ee.undefinedColor="rgb(100,100,100)",ee.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 ne extends ee{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,ne)),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,ne)),this.grokGroups}static get RasMol(){return void 0===this.rasMol&&(this.rasMol=new ne({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 ne.aaSynonyms?ne.aaSynonyms[t]:t;return super.get(e)}}ne.aaSynonyms={MeNle:"L",MeA:"A",MeG:"G",MeF:"F"};class oe{static getPalette(t="grok"){switch(t){case"grok":return ne.GrokGroups;case"lesk":return ne.Lesk;default:throw new Error(`ChemPalette: scheme \`${t}\` does not exist`)}}static getInnerOuter(t){let e=0,n="",o="";for(const r of t)"("==r?e++:")"==r?e--:e?n+=r:o+=r;return isNaN(parseInt(n))?[o,n]:[o,""]}static getColorAAPivot(t="",e="grok"){const n=this.getPalette(e);let[o,r]=this.getInnerOuter(t);if(o=o.length>6?`${o.slice(0,3)}...`:o,r=r.length>6?`${r.slice(0,3)}...`:r,1==t.length||"("==t[1]){const e=t[0]?.toUpperCase();return e in n?[n.get(e),e,r,1]:[this.undefinedColor,o,r,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,r,2]:[this.undefinedColor,o,r,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,r,3]:[this.undefinedColor,o,r,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,r,4]:[this.undefinedColor,o,r,4]}return[this.undefinedColor,o,r,0]}}oe.SemType="Aminoacids",oe.SemTypeMultipleAlignment="AminoacidsMultipleAlignment",oe.undefinedColor="rgb(100,100,100)",oe.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"},oe.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"},oe.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(*)*"},oe.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 re{}re.SemType="Nucleotides",re.SemTypeMultipleAlignment="NucleotidesMultipleAlignment",re.Names={A:"Adenine",C:"Cytosine",G:"Guanine",T:"Thymine",U:"Uracil"};class ie{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 se{}class ae extends se{static buildPalette(){return[].concat(...Object.values(ee.colourPalette))}get(t){const e=ie.hashCode(t)%ae.palette.length;return function(t){if(null==t)return"rgb(100,100,100)";const e=o.Color.fromHtml(t),n=o.Color.g(e),r=o.Color.r(e),i=o.Color.b(e),s=Math.sqrt(Math.pow(0-r,2)+Math.pow(0-n,2)+Math.pow(0-i,2));return s>210?`rgb(${r/s*210},${n/s*210},${i/s*210})`:o.Color.toRgb(e)}(ae.palette[e])}}ae.palette=ae.buildPalette();new Uint32Array(65536);var le,ce;(ce=le||(le={})).HAMMING="Hamming",ce.LEVENSHTEIN="Levenshtein",ce.NEEDLEMANN_WUNSCH="Needlemann-Wunsch",le.HAMMING,le.LEVENSHTEIN,le.NEEDLEMANN_WUNSCH,new class{constructor(){this.uhTemp=`units-handler.${o.SEMTYPE.MACROMOLECULE}`}},Xt.FASTA,Xt.SEPARATOR,Xt.HELM;var ue=n(61);function de(){const t=i.textInput("","");return{coloredInput:new L(t,T),codes:E.Rv}}class he extends o.Package{_monomerLib;get monomerLib(){if(!this._monomerLib)throw new Error("Monomer lib not loaded");return this._monomerLib}async initMonomerLib(){if(void 0!==this._monomerLib)return;const t=o.TaskBarProgressIndicator.create("Initializing Oligo Toolkit monomer library ...");await(0,w.Y3)((async()=>{const t=await async function(){const t=o.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()}();this._monomerLib=await t.readLibrary(Kt.BX,Kt.a_)}),(()=>t.close()))}}const pe=new he;async function fe(t){await xe();const e=Ut.getUI(t);await e.createAppLayout()}async function ge(){await xe();const t=await async function(){const t={"Mermadesynthesis:merMadeSynthesis":{tabName:"SYNTHESIZE",parameters:de()}},e={};for(const[n,o]of Object.entries(t)){let t;try{t=await r.functions.call(n,o.parameters)}catch(e){console.error(`Plugin ${n} not loaded, error:`,e),t=i.divText("error loading")}const s=new $t(o.tabName,t);s.initView(),e[o.tabName]=()=>s.getView()}return e}();if(!t)throw new Error("External app view factories not loaded");const e=new Gt(t);await e.createAppLayout()}async function me(){await fe("Oligo Translator")}async function Ae(){await fe("Oligo Pattern")}async function ve(){await fe("Oligo Structure")}async function xe(){await(0,E.VO)(),await pe.initMonomerLib()}function be(){const t=O.A.getInstance().getCodesToWeightsMap();return Object.fromEntries(t)}function Ce(t){const e=new C.b(t),n=new I(t).getFormat();return null!==n&&e.isValidSequence(n)}function we(t,e){return new P(t,e,"GCRS").convert()}function ye(t){return(0,J.v5)(t,!0)}async function Oe(){await async function(){await(0,w.Y3)((async()=>me()))}()}async function Ee(){await async function(){await(0,w.Y3)((async()=>{async function t(t,n,o){await(0,ue.gw)(3e3);const r=document.querySelectorAll(".st-pattern-choice-input > select");e=r.length;const i=r[o(n)];i.value=t;const s=new Event("input");i.dispatchEvent(s)}let e;await Ae(),["DNA","invAb","Z-New"].forEach((async(e,n)=>{t(e,n,(t=>2*t))})),["2'-O-Methyl","2'-Fluoro","2'-O-MOE"].forEach((async(n,o)=>{t(n,o,(t=>e-2-2*t))}))}))}()}async function Ie(){await async function(){await(0,w.Y3)((async()=>{await ve(),["Afcgacsu","Afcgacsu","Afcgacsu"].forEach((async(t,e)=>{await async function(t,e){await(0,ue.gw)(500);const n=document.querySelectorAll(".colored-text-input > textarea")[t];n.value=e;const o=new Event("input");n.dispatchEvent(o)}(e,t)}))}))}()}async function Se(t,e,n){return await xe(),new X.I(t,e).convertTo(n)}},713:(t,e,n)=>{n.d(e,{AU:()=>o,wm:()=>r});const o="Copied",r="Copy sequence"},511:(t,e,n)=>{n.d(e,{T:()=>o});const o="Afcgacsu"},976:t=>{t.exports=DG},469:t=>{t.exports=grok}},e={};function n(o){var r=e[o];if(void 0!==r)return r.exports;var i=e[o]={id:o,exports:{}};return t[o](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var o in e)n.o(e,o)&&!n.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},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.nc=void 0;var o=n(340);sequencetranslator=o})();
|
|
2
2
|
//# sourceMappingURL=package.js.map
|