@datagrok/bio 2.25.0 → 2.25.2
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 +14 -0
- package/detectors.js +26 -12
- package/dist/package-test.js +5 -5
- package/dist/package-test.js.map +1 -1
- package/dist/package.js +3 -3
- package/dist/package.js.map +1 -1
- package/package.json +2 -2
- package/scripts/mol-to-helm.py +1279 -0
- package/src/package-api.ts +14 -0
- package/src/package.g.ts +9 -0
- package/src/package.ts +27 -1
- package/src/utils/monomer-lib/library-file-manager/ui.ts +23 -4
- package/src/utils/monomer-lib/monomer-manager/monomer-manager.ts +34 -13
- package/src/utils/seq-helper/seq-handler.ts +15 -6
- package/src/widgets/sequence-scrolling-widget.ts +195 -183
- package/test-console-output-1.log +774 -766
- package/test-record-1.mp4 +0 -0
package/dist/package.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var bio;(()=>{var e={117:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(2586),o=n(5765),r=n(4227),s=n(8660),a={keyword:"properties",type:"object",schemaType:"object",code(e){const{gen:t,schema:n,parentSchema:a,data:l,it:c}=e;"all"===c.opts.removeAdditional&&void 0===a.additionalProperties&&s.default.code(new i.KeywordCxt(c,s.default,"additionalProperties"));const
|
|
1
|
+
var bio;(()=>{var e={117:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(2586),o=n(5765),r=n(4227),s=n(8660),a={keyword:"properties",type:"object",schemaType:"object",code(e){const{gen:t,schema:n,parentSchema:a,data:l,it:c}=e;"all"===c.opts.removeAdditional&&void 0===a.additionalProperties&&s.default.code(new i.KeywordCxt(c,s.default,"additionalProperties"));const u=(0,o.allSchemaProperties)(n);for(const e of u)c.definedProperties.add(e);c.opts.unevaluated&&u.length&&!0!==c.props&&(c.props=r.mergeEvaluated.props(t,(0,r.toHash)(u),c.props));const h=u.filter(e=>!(0,r.alwaysValidSchema)(c,n[e]));if(0===h.length)return;const d=t.name("valid");for(const n of h)p(n)?m(n):(t.if((0,o.propertyInData)(t,l,n,c.opts.ownProperties)),m(n),c.allErrors||t.else().var(d,!0),t.endIf()),e.it.definedProperties.add(n),e.ok(d);function p(e){return c.opts.useDefaults&&!c.compositeRule&&void 0!==n[e].default}function m(t){e.subschema({keyword:"properties",schemaProp:t,dataProp:t},d)}}};t.default=a},208:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.reportTypeError=t.checkDataTypes=t.checkDataType=t.coerceAndCheckDataType=t.getJSONTypes=t.getSchemaTypes=t.DataType=void 0;const i=n(396),o=n(7887),r=n(8708),s=n(9029),a=n(4227);var l;function c(e){const t=Array.isArray(e)?e:e?[e]:[];if(t.every(i.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}!function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"}(l||(t.DataType=l={})),t.getSchemaTypes=function(e){const t=c(e.type);if(t.includes("null")){if(!1===e.nullable)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&void 0!==e.nullable)throw new Error('"nullable" cannot be used without "type"');!0===e.nullable&&t.push("null")}return t},t.getJSONTypes=c,t.coerceAndCheckDataType=function(e,t){const{gen:n,data:i,opts:r}=e,a=function(e,t){return t?e.filter(e=>u.has(e)||"array"===t&&"array"===e):[]}(t,r.coerceTypes),c=t.length>0&&!(0===a.length&&1===t.length&&(0,o.schemaHasRulesForType)(e,t[0]));if(c){const o=d(t,i,r.strictNumbers,l.Wrong);n.if(o,()=>{a.length?function(e,t,n){const{gen:i,data:o,opts:r}=e,a=i.let("dataType",s._`typeof ${o}`),l=i.let("coerced",s._`undefined`);"array"===r.coerceTypes&&i.if(s._`${a} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>i.assign(o,s._`${o}[0]`).assign(a,s._`typeof ${o}`).if(d(t,o,r.strictNumbers),()=>i.assign(l,o))),i.if(s._`${l} !== undefined`);for(const e of n)(u.has(e)||"array"===e&&"array"===r.coerceTypes)&&c(e);function c(e){switch(e){case"string":return void i.elseIf(s._`${a} == "number" || ${a} == "boolean"`).assign(l,s._`"" + ${o}`).elseIf(s._`${o} === null`).assign(l,s._`""`);case"number":return void i.elseIf(s._`${a} == "boolean" || ${o} === null
|
|
2
2
|
|| (${a} == "string" && ${o} && ${o} == +${o})`).assign(l,s._`+${o}`);case"integer":return void i.elseIf(s._`${a} === "boolean" || ${o} === null
|
|
3
3
|
|| (${a} === "string" && ${o} && ${o} == +${o} && !(${o} % 1))`).assign(l,s._`+${o}`);case"boolean":return void i.elseIf(s._`${o} === "false" || ${o} === 0 || ${o} === null`).assign(l,!1).elseIf(s._`${o} === "true" || ${o} === 1`).assign(l,!0);case"null":return i.elseIf(s._`${o} === "" || ${o} === 0 || ${o} === false`),void i.assign(l,null);case"array":i.elseIf(s._`${a} === "string" || ${a} === "number"
|
|
4
|
-
|| ${a} === "boolean" || ${o} === null`).assign(l,s._`[${o}]`)}}i.else(),m(e),i.endIf(),i.if(s._`${l} !== undefined`,()=>{i.assign(o,l),function({gen:e,parentData:t,parentDataProperty:n},i){e.if(s._`${t} !== undefined`,()=>e.assign(s._`${t}[${n}]`,i))}(e,l)})}(e,t,a):m(e)})}return c};const h=new Set(["string","number","integer","boolean","null"]);function u(e,t,n,i=l.Correct){const o=i===l.Correct?s.operators.EQ:s.operators.NEQ;let r;switch(e){case"null":return s._`${t} ${o} null`;case"array":r=s._`Array.isArray(${t})`;break;case"object":r=s._`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":r=a(s._`!(${t} % 1) && !isNaN(${t})`);break;case"number":r=a();break;default:return s._`typeof ${t} ${o} ${e}`}return i===l.Correct?r:(0,s.not)(r);function a(e=s.nil){return(0,s.and)(s._`typeof ${t} == "number"`,e,n?s._`isFinite(${t})`:s.nil)}}function d(e,t,n,i){if(1===e.length)return u(e[0],t,n,i);let o;const r=(0,a.toHash)(e);if(r.array&&r.object){const e=s._`typeof ${t} != "object"`;o=r.null?e:s._`!${t} || ${e}`,delete r.null,delete r.array,delete r.object}else o=s.nil;r.number&&delete r.integer;for(const e in r)o=(0,s.and)(o,u(e,t,n,i));return o}t.checkDataType=u,t.checkDataTypes=d;const p={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>"string"==typeof e?s._`{type: ${e}}`:s._`{type: ${t}}`};function m(e){const t=function(e){const{gen:t,data:n,schema:i}=e,o=(0,a.schemaRefOrVal)(e,i,"type");return{gen:t,keyword:"type",data:n,schema:i.type,schemaCode:o,schemaValue:o,parentSchema:i,params:{},it:e}}(e);(0,r.reportError)(t,p)}t.reportTypeError=m},250:(e,t,n)=>{"use strict";n.d(t,{n5:()=>C,oP:()=>I});var i=n(4328),o=n(7389),r=n(6082),s=n(1757),a=n.n(s),l=n(1991),c=n.n(l),h=n(1858),u=n(2003),d=n(4326);function p(e){var t;return"string"==typeof e||e instanceof String?e:("object"==typeof e||e instanceof Object)&&"$thrownJsError"in e?p(e.$thrownJsError):e instanceof Error?null!==(t=e.stack)&&void 0!==t?t:e.message:e.toString()}var m=n(8070),g=n(7602),f=n(439),y=n(6882);var b=n(2020);function v(e,t,n){return Math.abs(e-t)<=n}var w,C,S=n(6307),A=n(6197);HTMLCanvasElement.prototype.getCursorPosition=function(e,t){const n=this.getBoundingClientRect();return new r.Point((e.clientX-n.left)*t,(e.clientY-n.top)*t)},r.Rect.prototype.contains=function(e,t){return this.left<=e&&e<=this.right&&this.top<=t&&t<=this.bottom};class x{rowCount;value;plotValue;valueList=null;valueIdx=0;bounds;constructor(e=0,t){this.value=this.rowCount=e,this.bounds=t}push(e){this.valueList||(this.valueList=new Array(this.rowCount),this.valueIdx=0),this.valueList[this.valueIdx]=e,++this.valueIdx}aggregate(e){this.value=e(this.valueList)??0,this.valueList=null}}class E{pos;name;_label;get label(){return this._label?this._label:this.name}_freqs;sumRowCount=0;sumPlotValue;sumPlotValueForHeight;constructor(e,t,n,i){this.pos=e,this.name=t,this._freqs=n??{},i?.sumRowCount&&(this.sumRowCount=i.sumRowCount),i?.sumValueForHeight&&(this.sumPlotValue=i.sumValueForHeight),i?.label&&(this._label=i.label)}getMonomers(){return Object.keys(this._freqs)}hasMonomer(e){return e in this._freqs}getFreq(e){let t=this._freqs[e];return t||(t=this._freqs[e]=new x),t}aggregate(e){const t=function(e){return t=>{const n=function(e){let t;const n="agg";return t=e instanceof Float32Array?r.Column.fromFloat32Array(n,e):e instanceof Int32Array?r.Column.fromInt32Array(n,e):r.Column.fromList(r.COLUMN_TYPE.FLOAT,n,e),t}(t);return n.aggregate(e)}}(e);for(const[e,n]of Object.entries(this._freqs))n.aggregate(t)}getMinValue(){return Math.min(...Object.values(this._freqs).map(e=>e.value))}calcPlotValue(e){for(const t of Object.values(this._freqs))t.plotValue=t.value-e}calcHeights(e){this.sumPlotValue=0;for(const e of Object.values(this._freqs))this.sumPlotValue+=e.plotValue;if(this.sumPlotValueForHeight=0,e===d.fH.Entropy){const e=Object.keys(this._freqs).length,t=.01*this.sumPlotValue,n=t/e;for(const e of Object.values(this._freqs)){const i=(e.plotValue+n)/(this.sumPlotValue+t);this.sumPlotValueForHeight+=-i*Math.log2(i)}}else if(e===d.fH.full)for(const[e,t]of Object.entries(this._freqs)){const e=t.plotValue/this.sumPlotValue;this.sumPlotValueForHeight+=e}}calcScreen(e,t,n,i,o,s,a,l,c){const h=i===d.fH.Entropy?n*(o-this.sumPlotValueForHeight)/o:n;let u=c*l+(n-h-1);const p=Object.entries(this._freqs).sort((e,t)=>e[0]!==f._S&&t[0]!==f._S?t[1].value-e[1].value:e[0]===f._S&&t[0]===f._S?0:e[0]===f._S?-1:1);for(const[n,i]of p){const n=h*i.plotValue/this.sumPlotValue;i.bounds=new r.Rect((e-t)*l*s,u,a*l,n),u+=n}}render(e,t,n,i,o,r,s){for(const[a,l]of Object.entries(this._freqs))if(a!==f._S){let c=a;const h=l.bounds,d=h.left;let m=y.S$;if(r)try{m=r.getMonomerTextColor(o,a);const e=r.getMonomer((0,A.Y)(o),a);e&&e.symbol!==a&&(c=e.symbol)}catch(e){p(e)}const g=(0,u.zS)(c,s);e.resetTransform(),e.strokeStyle="lightgray",e.lineWidth=1,e.rect(d,h.top,h.width,h.height),e.fillStyle=m,e.textAlign="left",e.font=t;const f=e.measureText(g);e.setTransform(h.width/f.width,0,0,h.height/i,d,h.top),e.fillText(g,0,-n)}}getMonomerAt(e,t){const n=Object.entries(this._freqs).find(([n,i])=>i.bounds.contains(e,t));return n?n[0]:void 0}buildCompositionTable(e,t){if("-"in this._freqs)throw new Error("Unexpected monomer symbol '-'.");return(0,S.F)(Object.assign({},...Object.entries(this._freqs).map(([e,t])=>({[e]:t.rowCount}))),e,t)}}!function(e){e.STYLE="Style",e.BEHAVIOR="Behavior",e.LAYOUT="Layout",e.DATA="Data"}(w||(w={})),function(e){e.sequenceColumnName="sequenceColumnName",e.valueAggrType="valueAggrType",e.valueColumnName="valueColumnName",e.startPositionName="startPositionName",e.endPositionName="endPositionName",e.skipEmptySequences="skipEmptySequences",e.skipEmptyPositions="skipEmptyPositions",e.shrinkEmptyTail="shrinkEmptyTail",e.backgroundColor="backgroundColor",e.positionHeight="positionHeight",e.positionWidth="positionWidth",e.verticalAlignment="verticalAlignment",e.horizontalAlignment="horizontalAlignment",e.fixWidth="fixWidth",e.fitArea="fitArea",e.minHeight="minHeight",e.maxHeight="maxHeight",e.maxMonomerLetters="maxMonomerLetters",e.showPositionLabels="showPositionLabels",e.positionMarginState="positionMarginState",e.positionMargin="positionMargin",e.filterSource="filterSource"}(C||(C={}));const M=d.Fo;var T;!function(e){e[e.None=0]="None",e[e.Render=1]="Render",e[e.Layout=1]="Layout",e[e.Freqs=2]="Freqs"}(T||(T={}));const _=new class{render=20};class I extends r.JsViewer{static residuesSet="nucleotides";viewed=!1;seqHelper;seqHandler;initialized=!1;monomerLib=null;host;msgHost;canvas;slider;textBaseline;seqCol=null;positions=[];visibleSlider=!1;allowResize=!0;turnOfResizeForOneSetValue=!1;sequenceColumnName;valueAggrType;valueColumnName;skipEmptySequences;skipEmptyPositions;positionWidth;_positionWidth;_positionWidthWithMargin;get positionWidthWithMargin(){return this._positionWidthWithMargin}minHeight;backgroundColor=4294967295;maxHeight;maxMonomerLetters;showPositionLabels;positionMarginState;positionMargin=0;_positionMargin;startPositionName;endPositionName;fixWidth;verticalAlignment;horizontalAlignment;fitArea;shrinkEmptyTail;positionHeight;filterSource;positionNames=[];positionLabels=void 0;startPosition=-1;endPosition=-1;error=null;get Length(){return this.skipEmptyPositions?this.positions.length:this.startPosition<=this.endPosition?this.endPosition-this.startPosition+1:0}get positionMarginValue(){return this.positionMarginState===d.mH.AUTO&&!0===this.seqHandler.getAlphabetIsMultichar()||this.positionMarginState===d.mH.ON?this.positionMargin:0}constructor(){super(),this.seqHelper=b._package.seqHelper,this.textBaseline="top",this.seqHandler=null,this.sequenceColumnName=this.string(C.sequenceColumnName,M.sequenceColumnName,{category:w.DATA,semType:r.SEMTYPE.MACROMOLECULE,description:"Column with sequences"});const e=[r.AGG.KEY,r.AGG.PIVOT,r.AGG.MISSING_VALUE_COUNT,r.AGG.SKEW,r.AGG.KURT,r.AGG.SELECTED_ROWS_COUNT],t=Object.values(r.AGG).filter(t=>!e.includes(t));this.valueColumnName=this.string(C.valueColumnName,M.valueColumnName,{category:w.DATA,columnTypeFilter:"numerical",description:"Column with values used in aggregation for position heights"}),this.valueAggrType=this.string(C.valueAggrType,M.valueAggrType,{category:w.DATA,choices:t,description:"Aggregation method for value column"}),this.startPositionName=this.string(C.startPositionName,M.startPositionName,{category:w.DATA,description:"Position or column name for start position. If column with given name is found, its values will be used as start position. If number is supplied, it will be used as start position of WebLogo."}),this.endPositionName=this.string(C.endPositionName,M.endPositionName,{category:w.DATA,description:"Position or column name for end position. If column with given name is found, its values will be used as end position. If number is supplied, it will be used as end position of WebLogo."}),this.skipEmptySequences=this.bool(C.skipEmptySequences,M.skipEmptySequences,{category:w.DATA,description:"Skip sequences which are empty in all positions"}),this.skipEmptyPositions=this.bool(C.skipEmptyPositions,M.skipEmptyPositions,{category:w.DATA,description:"Skip positions which are empty in all sequences"}),this.shrinkEmptyTail=this.bool(C.shrinkEmptyTail,M.shrinkEmptyTail,{category:w.DATA,description:"Skip empty tail (if found for all sequences within a subset) in WebLogo"}),this.backgroundColor=this.int(C.backgroundColor,M.backgroundColor,{category:w.STYLE,description:"Background color of WebLogo canvas"}),this.positionHeight=this.string(C.positionHeight,M.positionHeight,{category:w.STYLE,choices:Object.values(d.fH),description:"Monomer-Position height mode. Entropy of 100%(full height)"}),this._positionWidth=this.positionWidth=this.float(C.positionWidth,M.positionWidth,{category:w.LAYOUT,editor:"slider",min:4,max:100,description:'Width of position in WebLogo. If "Fit Area" is enabled, width will be calculated to fit horizontal space'}),this.verticalAlignment=this.string(C.verticalAlignment,M.verticalAlignment,{category:w.LAYOUT,choices:Object.values(d.Lp)}),this.horizontalAlignment=this.string(C.horizontalAlignment,M.horizontalAlignment,{category:w.LAYOUT,choices:Object.values(d.P4)}),this.fixWidth=this.bool(C.fixWidth,M.fixWidth,{category:w.LAYOUT,userEditable:!1}),this.fitArea=this.bool(C.fitArea,M.fitArea,{category:w.LAYOUT,description:"Fit WebLogo to the horizontal space. Calculates position width as maximum between provided width value and value needed to fit whole horizontal space."}),this.minHeight=this.int(C.minHeight,M.minHeight,{category:w.LAYOUT,editor:"slider",min:10,max:250,description:"Minimum height of WebLogo"}),this.maxHeight=this.int(C.maxHeight,M.maxHeight,{category:w.LAYOUT,editor:"slider",min:25,max:Math.max(window.innerHeight??0,1e3),nullable:!0,description:"Maximum height of WebLogo"}),this.maxMonomerLetters=this.int(C.maxMonomerLetters,M.maxMonomerLetters,{category:w.LAYOUT,editor:"slider",min:1,max:40,description:"Maximum monomer letters to display before shortening"}),this.showPositionLabels=this.bool(C.showPositionLabels,M.showPositionLabels,{category:w.LAYOUT,description:"Show position labels on top of the weblogo"}),this.positionMarginState=this.string(C.positionMarginState,M.positionMarginState,{category:w.LAYOUT,choices:Object.values(d.mH),description:"Calculate optimal margins between positions or turn it on/off"});let n=0;"auto"===this.positionMarginState&&(n=4),this.positionMargin=this.int(C.positionMargin,n,{category:w.LAYOUT,min:0,max:25,description:"Margin between positions in WebLogo"}),this.filterSource=this.string(C.filterSource,M.filterSource,{category:w.BEHAVIOR,choices:Object.values(d.lT),description:"Data source for weblogo. Selected or filtered rows."}),this.slider=o.rangeSlider(0,100,0,20,!1,{style:"barbell"}),this.canvas=o.canvas(),this.canvas.classList.value="bio-wl-canvas",this.canvas.style.width="100%",b.PackageFunctions.getMonomerLibHelper().then(e=>{this.monomerLib=e.getMonomerLib(),this.render(T.Render,"monomerLib"),this.subs.push(this.monomerLib.onChanged.subscribe(()=>{this.render(T.Render,"monomerLib changed")}))}),this.viewSyncer=new g.g(b._package.logger)}static viewerCounter=-1;viewerId=++I.viewerCounter;toLog(){return`WebLogoViewer<${this.viewerId}>`}setData(){const e=`${this.toLog()}.setData()`;b._package.logger.debug(`${e}, in`),this.viewSyncer.sync(`${e}`,async()=>{if(!this.setDataInProgress){this.setDataInProgress=!0;try{this.viewed&&(this.renderRequestSub.unsubscribe(),await this.destroyView(),this.viewed=!1),this.updateSeqCol(),this.updateEditors(),this.viewed||(await this.buildView(),this.viewed=!0)}finally{this.setDataInProgress=!1}}}),b._package.logger.debug(`${e}, out`)}viewSyncer;setDataInProgress=!1;viewSubs=[];async destroyView(){for(const e of this.viewSubs)e.unsubscribe();this.viewSubs=[];const e=this.dataFrame?"data":"null";b._package.logger.debug(`${this.toLog()}.destroyView( dataFrame = ${e} ) start`),this.host.remove(),this.msgHost=void 0,this.host=void 0,b._package.logger.debug(`${this.toLog()}.destroyView() end`)}async buildView(){const e=this.dataFrame?"data":"null";b._package.logger.debug(`${this.toLog()}.buildView( dataFrame = ${e} ) start`),window.devicePixelRatio,this.viewSubs.push(r.debounce(this.renderRequest,_.render).subscribe(this.renderRequestOnDebounce.bind(this))),this.helpUrl="/help/visualize/viewers/web-logo.md",this.msgHost=o.div("No message",{classes:"bio-wl-msg"}),this.msgHost.style.display="none",this.canvas=o.canvas(),this.canvas.style.width="100%",this.slider.root.style.position="absolute",this.slider.root.style.zIndex="999",this.slider.root.style.display="none",this.slider.root.style.height="0.7em",this.visibleSlider=!1,this.host=o.div([this.msgHost,this.canvas],{classes:"bio-wl-host",style:{display:"flex",flexDirection:"row",flexGrow:"0",flexWrap:"wrap"}}),this.root.append(this.host),this.root.append(this.slider.root),this.error&&(this.msgHost.innerText=this.error.message,o.tooltip.bind(this.msgHost,this.error.stack),this.msgHost.style.setProperty("display",null)),this.dataFrame&&(this.viewSubs.push(this.dataFrame.filter.onChanged.subscribe(this.dataFrameFilterOnChanged.bind(this))),this.viewSubs.push(this.dataFrame.selection.onChanged.subscribe(this.dataFrameSelectionOnChanged.bind(this)))),this.viewSubs.push(o.onSizeChanged(this.root).subscribe(this.rootOnSizeChanged.bind(this))),this.viewSubs.push(this.slider.onValuesChanged.subscribe(this.sliderOnValuesChanged.bind(this))),this.viewSubs.push((0,h.fromEvent)(this.canvas,"mousemove").subscribe(this.canvasOnMouseMove.bind(this))),this.viewSubs.push((0,h.fromEvent)(this.canvas,"mousedown").subscribe(this.canvasOnMouseDown.bind(this))),this.viewSubs.push((0,h.fromEvent)(this.canvas,"wheel").subscribe(this.canvasOnWheel.bind(this))),this.render(T.Freqs,"buildView"),b._package.logger.debug(`${this.toLog()}.buildView() end`)}lastSize={width:-1,height:-1};rootOnSizeChanged(e){const t={width:e.target.clientWidth,height:e.target.clientHeight};this.lastSize.width==t.width&&this.lastSize.height==t.height||(b._package.logger.debug(`${this.toLog()}.rootOnSizeChanged(), ${JSON.stringify(t)}, start `),this.render(T.Layout,"rootOnSizeChanged")),this.lastSize=t}updateEditors(){this.props.getProperty(C.valueColumnName).choices=c()(this.dataFrame.columns.numerical).map(e=>e.name).toArray()}updateSeqCol(){if(this.dataFrame&&(this.seqCol=this.sequenceColumnName?this.dataFrame.col(this.sequenceColumnName):null,null==this.seqCol&&(this.seqCol=(0,u.mn)(this.dataFrame),this.sequenceColumnName=this.seqCol?this.seqCol.name:null),this.seqCol)){try{this.seqHandler=this.seqHelper.getSeqHandler(this.seqCol),this.render(T.Freqs,"updateSeqCol()"),this.error=null}catch(e){throw this.seqCol=null,this.error=e instanceof Error?e:new Error(e.toString()),e}this.seqCol||(this.seqHandler=null,this.positionNames=[],this.positionLabels=[],this.startPosition=-1,this.endPosition=-1)}}getFilter(){let e;switch(this.filterSource){case d.lT.Filtered:e=this.dataFrame.filter;break;case d.lT.Selected:e=0===this.dataFrame.selection.trueCount?this.dataFrame.filter:this.dataFrame.selection}return e}setSliderVisibility(e){e?(this.slider.root.style.display="inherit",this.visibleSlider=!0):(this.slider.root.style.display="none",this.visibleSlider=!1)}calcLayout(e){this.host&&this.canvas&&this.slider&&(this.host.classList.remove("bio-wl-fixWidth","bio-wl-fitArea"),this.canvas.classList.remove("bio-wl-fixWidth","bio-wl-fitArea"),this._positionWidth=this.positionWidth,this._positionMargin=this.positionMargin,this._positionWidthWithMargin=this._positionWidth+this.positionMarginValue,this.fixWidth?this.calcLayoutFixWidth(e):this.calcLayoutNoFitArea(e),this.slider.root.style.width=`${this.host.clientWidth}px`)}calcLayoutFixWidth(e){if(!this.host||!this.canvas||!this.slider)return;this.host.classList.add("bio-wl-fixWidth"),this.canvas.classList.add("bio-wl-fitArea");const t=this._positionWidthWithMargin*this.Length,n=Math.min(Math.max(this.minHeight,this.root.clientHeight),this.maxHeight??this.root.clientHeight);this.host.style.justifyContent=d.P4.LEFT,this.host.style.removeProperty("margin-left"),this.host.style.removeProperty("margin-top"),this.host.style.width=this.canvas.style.width=`${t}px`,this.host.style.height=this.canvas.style.height=`${n}px`,this.host.style.left=this.canvas.style.left="0",this.host.style.top=this.canvas.style.top="0",this.host.style.setProperty("overflow","hidden","important"),this.slider.root.style.display="none",this.slider.setValues(0,Math.max(0,this.Length-1),0,Math.max(0,this.Length-1)),this.canvas.width=t*e,this.canvas.height=n*e}calcLayoutNoFitArea(e){if(!this.host||!this.canvas||!this.slider)return;let t=this._positionWidthWithMargin*this.Length,n=Math.min(this.root.clientWidth,t);this.fitArea&&t<this.root.clientWidth&&(this._positionWidth=Math.floor(this._positionWidth*this.root.clientWidth/t),this._positionWidthWithMargin=this._positionWidth+this.positionMarginValue,t=this._positionWidthWithMargin*this.Length,n=Math.min(this.root.clientWidth,t));const i=Math.min(Math.max(this.minHeight,this.root.clientHeight),this.maxHeight??this.root.clientHeight);this.canvas.style.width=`${n}px`,this.canvas.style.height=`${i}px`,this.host.style.width=`${this.root.clientWidth}px`,this.host.style.height=`${this.root.clientHeight}px`,this.host.style.justifyContent=this.horizontalAlignment,this.host.style.alignContent=this.verticalAlignment===d.Lp.TOP?"start":this.verticalAlignment===d.Lp.MIDDLE?"center":this.verticalAlignment===d.Lp.BOTTOM?"end":"inherit",this.root.clientHeight<this.minHeight&&(this.host.style.alignContent="start",this.host.style.width=`${n+8}px`);const o=t>n;if(this.setSliderVisibility(o),o){this.slider.root.style.removeProperty("display"),this.host.style.justifyContent="left",this.host.style.height=this.root.clientHeight-this.slider.root.offsetHeight+"px",this.canvas.style.height=i-this.slider.root.offsetHeight+"px",this.slider.root.style.top=`${this.host.offsetHeight}px`;let e=Math.min(Math.max(0,this.slider.min),this.Length-.001),t=Math.min(Math.max(0,this.slider.max),this.Length-.001);const n=this.canvas.clientWidth/this._positionWidthWithMargin;t=Math.min(Math.max(e,0)+n,this.Length-.001),e=Math.max(0,Math.min(t,this.Length-.001)-n),this.safeUpdateSlider(0,Math.max(this.Length-.001),e,t)}else this.safeUpdateSlider(0,Math.max(0,this.Length-.001),0,Math.max(0,this.Length-.001));this.canvas.width=n*e,this.canvas.height=i*e}calcLayoutFitArea(e){if(!this.host||!this.canvas||!this.slider)return;const t=this._positionWidth*this.Length,n=Math.min(Math.max(this.minHeight,this.root.clientHeight),this.maxHeight??this.root.clientHeight),i=t>0?(this.root.clientWidth-this.positionMarginValue*this.Length)/t:0,o=this.root.clientHeight/n,r=Math.max(1,Math.min(i,o));this._positionWidth=this.positionWidth*r,this._positionWidthWithMargin=this._positionWidth+this.positionMarginValue;const s=(this._positionWidth+this.positionMarginValue)*this.Length,a=r*n,l=Math.min(this.root.clientWidth,s);this.canvas.style.width=`${l}px`,this.canvas.style.height=`${a}px`,this.host.style.width=`${l}px`,this.host.style.height=`${this.root.clientHeight}px`,this.host.style.justifyContent=this.horizontalAlignment,this.host.style.alignContent=this.verticalAlignment===d.Lp.TOP?"start":this.verticalAlignment===d.Lp.MIDDLE?"center":this.verticalAlignment===d.Lp.BOTTOM?"end":"inherit",this.root.clientHeight<this.minHeight&&(this.host.style.alignContent="start",this.host.style.width=`${l+6}px`),this.host.style.width=`${this.host}px`;const c=s>l;if(this.setSliderVisibility(c),c){this.slider.root.style.removeProperty("display"),this.host.style.justifyContent="left",this.host.style.height=this.root.clientHeight-this.slider.root.offsetHeight+"px",this.slider.root.style.top=`${this.host.offsetHeight}px`;let e=Math.min(Math.max(0,this.slider.min),this.Length-.001),t=Math.min(Math.max(0,this.slider.max),this.Length-.001);const n=this.root.clientWidth/this._positionWidthWithMargin;t=Math.min(Math.max(e,0)+n,this.Length-.001),e=Math.max(0,Math.min(t,this.Length-.001)-n),this.safeUpdateSlider(0,Math.max(0,this.Length-.001),e,t)}else this.safeUpdateSlider(0,Math.max(0,this.Length-.001),0,Math.max(0,this.Length-.001));this.canvas.width=l*e,this.canvas.height=a*e}safeUpdateSlider(e,t,n,i){v(e,this.slider.minRange,.1)&&v(t,this.slider.maxRange,.1)&&v(n,this.slider.min,.1)&&v(i,this.slider.max,.1)||this.slider.setValues(e,t,n,i)}onPropertyChanged(e){switch(super.onPropertyChanged(e),e.name){case C.sequenceColumnName:this.updateSeqCol();break;case C.sequenceColumnName:case C.startPositionName:case C.endPositionName:case C.filterSource:case C.shrinkEmptyTail:case C.skipEmptyPositions:case C.positionHeight:case C.valueColumnName:case C.valueAggrType:this.render(T.Freqs,`onPropertyChanged( ${e.name} )`);break;case C.minHeight:case C.maxHeight:case C.maxMonomerLetters:case C.positionWidth:case C.showPositionLabels:case C.fixWidth:case C.fitArea:case C.horizontalAlignment:case C.verticalAlignment:case C.positionMargin:case C.positionMarginState:this.render(T.Layout,`onPropertyChanged(${e.name})`);break;case C.backgroundColor:this.render(T.Render,`onPropertyChanged(${e.name})`)}}onTableAttached(){b._package.logger.debug(`${this.toLog()}.onTableAttached(), `),super.onTableAttached(),this.setData()}detach(){const e=`${this.toLog()}.detach()`;b._package.logger.debug(`${e}, in`);const t=super.detach.bind(this);this.viewSyncer.sync(`${e}`,async()=>{this.setDataInProgress||(this.viewed&&(await this.destroyView(),this.viewed=!1),t())}),b._package.logger.debug(`${e}, out`)}_onSizeChanged=new h.Subject;get onSizeChanged(){return this._onSizeChanged}_onFreqsCalculated=new h.Subject;get onFreqsCalculated(){return this._onFreqsCalculated}_onLayoutCalculated=new h.Subject;get onLayoutCalculated(){return this._onLayoutCalculated}getMonomer(e,t){const n=e.x,i=Math.floor(e.x/(this._positionWidthWithMargin*t)+Math.floor(this.slider.min)),o=this.positions[i];if(!o)return[null,null,null];const r=o.getMonomerAt(n,e.y);return null==r?[o,null,null]:[o,r,o.getFreq(r)]}_nullSequence(e="X"){return this.skipEmptySequences?"":new Array(this.Length).fill(e).join("")}_removeEmptyPositions(){this.skipEmptyPositions&&(this.positions=c()(this.positions).filter(e=>!e.hasMonomer(f._S)||e.getFreq(f._S).rowCount!==e.sumRowCount).toArray())}requestedRenderLevel=T.Freqs;renderRequest=new h.Subject;renderRequestSub;render(e,t){b._package.logger.debug(`${this.toLog()}.render( recalcLevelVal=${e}, reason='${t}' )`),this.requestedRenderLevel=Math.max(this.requestedRenderLevel,e),this.renderRequest.next(this.requestedRenderLevel)}async renderInt(e){if(b._package.logger.debug(`${this.toLog()}.render.renderInt( renderLevel=${e} ), start `),this.msgHost&&(this.msgHost.style.display="none"),!this.seqCol||!this.dataFrame||null==this.host||null==this.slider)return;const t=window.devicePixelRatio,n=this.showPositionLabels?12:0;if(e>=T.Freqs&&(()=>{if(b._package.logger.debug(`${this.toLog()}.render.calculateFreqsInt(), start `),!this.host||!this.seqCol||!this.dataFrame)return;const e=this.seqCol.getTag(u.gp.positionNames),t=this.seqCol.getTag(u.gp.positionLabels);let n;!e&&this.endPositionName&&/\d+/.test(this.endPositionName)?n=Number(this.endPositionName):e&&this.endPositionName&&(n=e.split(u.z1).indexOf(this.endPositionName),n=-1!==n?n:void 0);const i=this.getFilter(),o=0===i.trueCount?this.seqHandler.maxLength:c().count(0).take(this.seqHandler.length).map(e=>{const t=this.seqHandler.getSplitted(e,n);return i.get(e)&&t?t.length:0}).reduce((e,t)=>Math.max(e,t),0);this.positionNames=e?e.split(u.z1).map(e=>e.trim()):[...Array(o).keys()].map(e=>`${e+1}`),this.positionLabels=t?t.split(u.z1).map(e=>e.trim()):void 0,this.startPosition=this.startPositionName&&this.positionNames&&this.positionNames.includes(this.startPositionName)?this.positionNames.indexOf(this.startPositionName):0,this.endPosition=this.endPositionName&&this.positionNames&&this.positionNames.includes(this.endPositionName)?this.positionNames.indexOf(this.endPositionName):o-1;const s=this.startPosition<=this.endPosition?this.endPosition-this.startPosition+1:0;this.seqHandler=this.seqHelper.getSeqHandler(this.seqCol);const a=this.startPosition<=this.endPosition?this.endPosition-this.startPosition+1:0;this.positions=new Array(a);for(let e=0;e<s;e++){const t=this.positionNames[this.startPosition+e],n=this.positionLabels?this.positionLabels[this.startPosition+e]:void 0;this.positions[e]=new E(this.startPosition+e,t,{},{label:n})}this.dataFrame.rowCount;const l=i.getSelectedIndexes();for(let e=0;e<s;++e){for(const t of l){const n=this.seqHandler.getSplitted(t),i=e+this.startPosition<n.length?n.getCanonical(this.startPosition+e):this.seqHandler.defaultGapOriginal,o=this.seqHandler.defaultGapOriginal===i?f._S:i,r=this.positions[e],s=r.getFreq(o);++r.sumRowCount,s.value=++s.rowCount}if(this.valueAggrType===r.AGG.TOTAL_COUNT)continue;let t=null;try{t=this.dataFrame.getCol(this.valueColumnName),t.matches("numerical")||(t=null)}catch{t=null}if(t){for(const n of l){const i=this.seqHandler.getSplitted(n),o=e+this.startPosition<i.length?i.getCanonical(this.startPosition+e):this.seqHandler.defaultGapOriginal,r=this.seqHandler.defaultGapOriginal===o?f._S:o,s=t.get(n);this.positions[e].getFreq(r).push(s)}this.positions[e].aggregate(this.valueAggrType)}}const h=this.valueAggrType===r.AGG.TOTAL_COUNT?0:Math.min(0,Math.min(...this.positions.map(e=>e.getMinValue())));for(let e=0;e<s;++e)this.positions[e].calcPlotValue(h),this.positions[e].calcHeights(this.positionHeight);this._removeEmptyPositions(),this._onFreqsCalculated.next()})(),this.calcLayout(t),-1===this.startPosition)return;const o=Math.max(Math.floor(this.slider.min),0),s=Math.min(this.positions.length-1,Math.floor(this.slider.max));e>=T.Layout&&((e,t,n,o)=>{b._package.logger.debug(`${this.toLog()}.render.calculateLayoutInt(), start `);const s=this.canvas.height-o*n;let a;if(this.valueAggrType===r.AGG.TOTAL_COUNT){const e=this.seqHandler.getAlphabetSize();this.positionHeight==d.fH.Entropy&&null==e&&i.shell.error("WebLogo: alphabet is undefined."),a=Math.log2(e)}else a=Math.max(...c().count(e).takeWhile(e=>e<=t).map(e=>this.positions[e].sumPlotValueForHeight));for(let i=e;i<=t;++i)i in this.positions?this.positions[i].calcScreen(i,this.slider.min,s,this.positionHeight,a,this._positionWidthWithMargin,this._positionWidth,n,o):b._package.logger.warning(`${this.toLog()}.render.calculateLayoutInt() this.positions.length = ${this.positions.length}, jPos = ${i}`);b._package.logger.debug(`${this.toLog()}.render.calculateLayoutInt(), end `),this._onLayoutCalculated.next()})(o,s,window.devicePixelRatio,n);const a=this.canvas.getContext("2d");if(a){a.save();try{this.Length,a.resetTransform(),a.fillStyle=function(e){const t=r.Color.a(e);return`#${(16777215&e).toString(16).padStart(6,"0")}`+t.toString(16).padStart(2,"0")}(this.backgroundColor),a.fillRect(0,0,this.canvas.width,this.canvas.height),a.textBaseline=this.textBaseline;const e=10*t;a.resetTransform(),a.fillStyle="black",a.textAlign="center",a.font=`${e.toFixed(1)}px Roboto, Roboto Local, sans-serif`,n>0&&this.positions.length>0&&function(e,t,n,i,o,r,s,a){e.save();try{e.textAlign="center";let l=null,c=null;for(let t=Math.floor(s);t<=Math.floor(a);t++){const n=r[t],i=e.measureText(n.name),o=i.actualBoundingBoxDescent-i.actualBoundingBoxAscent;l=null==l?i.width:Math.max(l,i.width),c=null==c?o:Math.max(c,o)}const h=l<i*t-2?1:(i*t-2)/l;for(let l=Math.floor(s);l<=Math.floor(a);l++){const a=r[l],u=(l-s)*n*t+i*t/2,d=(o*t-c)/2;e.setTransform(h,0,0,1,u,d),e.measureText(a.label),e.fillText(a.label,0,0)}}finally{e.restore()}}(a,t,this._positionWidthWithMargin,this._positionWidth,n,this.positions,this.slider.min,this.slider.max);const i="16px Roboto, Roboto Local, sans-serif",l=.25,c=12.2,h=this.seqHandler.defaultBiotype;for(let e=o;e<=s;e++)this.positions[e].render(a,i,l,c,h,this.monomerLib,this.maxMonomerLetters)}finally{a.restore()}b._package.logger.debug(`${this.toLog()}.render.renderInt( recalcLevel=${e} ), end`)}}renderRequestOnDebounce(e){const t=`${this.toLog()}.renderRequestOnDebounce()`;"HTML"!==a()(this.root).offsetParent().get()[0]?.tagName?(this.requestedRenderLevel=T.None,this.viewSyncer.sync(t,async()=>{await this.renderInt(e)})):b._package.logger.warning(`${t}, $(this.root).offsetParent() is the 'HTML' tag.`)}_lastWidth;_lastHeight;sliderOnValuesChanged(e){try{const e={minRange:this.slider.minRange,min:this.slider.min,max:this.slider.max,maxRange:this.slider.maxRange};if(this.canvas&&this.canvas.offsetWidth>0&&(this._positionWidthWithMargin??0)>0){const t=e.max-e.min,n=this.canvas.offsetWidth/t-this.positionMarginValue;v(n,this.positionWidth,.1)?this.render(T.Layout,"sliderOnValuesChanged"):this.getProperty(C.positionWidth)?.set(this,n)}}catch(e){const t=p(e);b._package.logger.error(`${this.toLog()}.sliderOnValuesChanged() error:\n`+t)}}dataFrameFilterOnChanged(e){b._package.logger.debug(`${this.toLog()}.dataFrameFilterChanged()`);try{this.filterSource===d.lT.Filtered&&this.render(T.Freqs,"dataFrameFilterOnChanged")}catch(e){const t=p(e);b._package.logger.error(`${this.toLog()}.dataFrameFilterOnChanged() error:\n`+t)}}dataFrameSelectionOnChanged(e){b._package.logger.debug(`${this.toLog()}.dataFrameSelectionOnChanged()`);try{this.filterSource===d.lT.Selected&&this.render(T.Freqs,"dataFrameSelectionOnChanged")}catch(e){const t=p(e);b._package.logger.error(`${this.toLog()}.dataFrameSelectionOnChanged() error:\n`+t)}}canvasOnMouseMove(e){if(!this.monomerLib||!this.seqHandler)return;const t=window.devicePixelRatio;try{const n=e,i=this.canvas.getCursorPosition(n,t),[s,a]=this.getMonomer(i,t),l=this.showPositionLabels?12*t:0;if(null!==s&&null==a&&0<=i.y&&i.y<=l){const e=[o.divText(`Position ${s.label}`)];if(this.valueAggrType===r.AGG.TOTAL_COUNT){const t=this.seqHandler.defaultBiotype;e.push(s.buildCompositionTable(t,this.monomerLib))}const t=o.divV(e);t.style.maxHeight="80vh",o.tooltip.show(t,n.x+16,n.y+16)}else if(null!==s&&a&&this.dataFrame&&this.seqCol&&this.seqHandler){const e=s.getFreq(a),t=[o.div(`${a}`),o.div(`${e.rowCount} rows`)];this.valueAggrType!==r.AGG.TOTAL_COUNT&&t.push(o.div(`${this.valueAggrType}: ${e.value.toFixed(3)}`));const i=o.divV(t);o.tooltip.show(i,n.x+16,n.y+16)}else o.tooltip.hide()}catch(e){const t=p(e);b._package.logger.error(`${this.toLog()}.canvasOnMouseMove() error:\n`+t)}}canvasOnMouseDown(e){try{const t=e,n=window.devicePixelRatio,[i,o]=this.getMonomer(this.canvas.getCursorPosition(t,n),n);if(null!==i&&null!==o&&this.dataFrame&&this.seqCol&&this.seqHandler){const e=r.BitSet.create(this.dataFrame.selection.length,e=>function(e,t,n,i,o,r){const s=t.getSplitted(i),a=r.pos<s.length?s.getCanonical(r.pos):null;return null!==a&&a===o}(this.dataFrame,this.seqHandler,this.getFilter(),e,o,i));this.dataFrame.selection.init(t=>e.get(t))}}catch(e){const t=p(e);b._package.logger.error(`${this.toLog()}.canvasOnMouseDown() error:\n`+t)}}canvasOnWheel(e){const t=window.devicePixelRatio;try{if(!this.visibleSlider)return;const n=this.canvas.width/(this._positionWidthWithMargin*t),i=e.deltaY/100*Math.max(Math.floor(n/5),1);this.slider.scrollBy(this.slider.min+i)}catch(e){const t=p(e);b._package.logger.error(`${this.toLog()}.canvasOnWheel() error:\n`+t)}}_onRendered=new h.Subject;get onRendered(){return this._onRendered}invalidate(e){const t=`invalidate(${e?` <- ${e} `:""})`,n=`${this.toLog()}.${t}`;this.render(T.None,t),this.viewSyncer.sync(`${n}`,async()=>{this._onRendered.next()})}async awaitRendered(e=5e3){await(0,m.PE)(this.onRendered,()=>{},()=>{this.invalidate()},e);const t=this.viewSyncer.resetErrors();if(t.length>0)throw t[0]}}},294:(e,t,n)=>{"use strict";function i(e,t){return e[t.polymerType]?.[t.symbol]}function o(e,t){return!!e[t.polymerType]?.[t.symbol]}function r(e,t,n){let i=e[t.polymerType];i||(i=e[t.polymerType]={}),i[t.symbol]=n}n.d(t,{Cg:()=>s,LQ:()=>r,bq:()=>o,vF:()=>a,xb:()=>i});class s extends Map{constructor(e){super(e)}}class a{constructor(e,t){this.molfile=e,this.monomers=t}static createEmpty(){return new a("",new s(null))}}},330:(e,t,n)=>{"use strict";n.d(t,{kA:()=>o,pz:()=>s,qj:()=>r,vG:()=>a});var i=n(2003);function o(e,t){return e?e.columns.getUnusedName(t):t}function r(e,t){return o(e,`molfile(${t})`)}function s(e){let t;if(e===i.YI.PT||e===i.YI.UN)t="PEPTIDE";else{if(e!==i.YI.RNA&&e!==i.YI.DNA)throw new Error(`Unexpected alphabet '${e}'.`);t="RNA"}return t}function a(e){const t=7===e.length?/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e):/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?[parseInt(t[1],16)/256,parseInt(t[2],16)/256,parseInt(t[3],16)/256,t.length>4?parseInt(t[4],16)/256:.3]:null}},343:e=>{"use strict";const t=/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu,n=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;function i(e){return"boolean"==typeof e.secure?e.secure:"wss"===String(e.scheme).toLowerCase()}function o(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function r(e){const t="https"===String(e.scheme).toLowerCase();return e.port!==(t?443:80)&&""!==e.port||(e.port=void 0),e.path||(e.path="/"),e}const s={scheme:"http",domainHost:!0,parse:o,serialize:r},a={scheme:"ws",domainHost:!0,parse:function(e){return e.secure=i(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e},serialize:function(e){if(e.port!==(i(e)?443:80)&&""!==e.port||(e.port=void 0),"boolean"==typeof e.secure&&(e.scheme=e.secure?"wss":"ws",e.secure=void 0),e.resourceName){const[t,n]=e.resourceName.split("?");e.path=t&&"/"!==t?t:void 0,e.query=n,e.resourceName=void 0}return e.fragment=void 0,e}},l={http:s,https:{scheme:"https",domainHost:s.domainHost,parse:o,serialize:r},ws:a,wss:{scheme:"wss",domainHost:a.domainHost,parse:a.parse,serialize:a.serialize},urn:{scheme:"urn",parse:function(e,t){if(!e.path)return e.error="URN can not be parsed",e;const i=e.path.match(n);if(i){const n=t.scheme||e.scheme||"urn";e.nid=i[1].toLowerCase(),e.nss=i[2];const o=`${n}:${t.nid||e.nid}`,r=l[o];e.path=void 0,r&&(e=r.parse(e,t))}else e.error=e.error||"URN can not be parsed.";return e},serialize:function(e,t){const n=t.scheme||e.scheme||"urn",i=e.nid.toLowerCase(),o=`${n}:${t.nid||i}`,r=l[o];r&&(e=r.serialize(e,t));const s=e,a=e.nss;return s.path=`${i||t.nid}:${a}`,t.skipEscape=!0,s},skipNormalize:!0},"urn:uuid":{scheme:"urn:uuid",parse:function(e,n){const i=e;return i.uuid=i.nss,i.nss=void 0,n.tolerant||i.uuid&&t.test(i.uuid)||(i.error=i.error||"UUID is not valid."),i},serialize:function(e){const t=e;return t.nss=(e.uuid||"").toLowerCase(),t},skipNormalize:!0}};e.exports=l},392:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o=n(4227),r=n(2023),s={keyword:"unevaluatedProperties",type:"object",schemaType:["boolean","object"],trackErrors:!0,error:{message:"must NOT have unevaluated properties",params:({params:e})=>i._`{unevaluatedProperty: ${e.unevaluatedProperty}}`},code(e){const{gen:t,schema:n,data:s,errsCount:a,it:l}=e;if(!a)throw new Error("ajv implementation error");const{allErrors:c,props:h}=l;function u(r){if(!1===n)return e.setParams({unevaluatedProperty:r}),e.error(),void(c||t.break());if(!(0,o.alwaysValidSchema)(l,n)){const n=t.name("valid");e.subschema({keyword:"unevaluatedProperties",dataProp:r,dataPropType:o.Type.Str},n),c||t.if((0,i.not)(n),()=>t.break())}}h instanceof i.Name?t.if(i._`${h} !== true`,()=>t.forIn("key",s,e=>t.if(function(e,t){return i._`!${e} || !${e}[${t}]`}(h,e),()=>u(e)))):!0!==h&&t.forIn("key",s,e=>void 0===h?u(e):t.if(function(e,t){const n=[];for(const o in e)!0===e[o]&&n.push(i._`${t} !== ${o}`);return(0,i.and)(...n)}(h,e),()=>u(e))),l.props=!0,e.ok(i._`${a} === ${r.default.errors}`)}};t.default=s},396:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getRules=t.isJSONType=void 0;const n=new Set(["string","number","integer","boolean","null","object","array"]);t.isJSONType=function(e){return"string"==typeof e&&n.has(e)},t.getRules=function(){const e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}},422:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(5765),o=n(9029),r={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:{message:({schemaCode:e})=>o.str`must match pattern "${e}"`,params:({schemaCode:e})=>o._`{pattern: ${e}}`},code(e){const{data:t,$data:n,schema:r,schemaCode:s,it:a}=e,l=a.opts.unicodeRegExp?"u":"",c=n?o._`(new RegExp(${s}, ${l}))`:(0,i.usePattern)(e,r);e.fail$data(o._`!${c}.test(${t})`)}};t.default=r},439:(e,t,n)=>{"use strict";n.d(t,{B5:()=>l,Hi:()=>i,Vl:()=>c,YI:()=>o,_S:()=>u,b9:()=>d,gp:()=>r,ot:()=>p,q7:()=>h,qE:()=>r,z1:()=>a});var i,o,r,s=n(2738);!function(e){e.FASTA="fasta",e.SEPARATOR="separator",e.HELM="helm",e.CUSTOM="custom",e.BILN="biln"}(i||(i={})),function(e){e.DNA="DNA",e.RNA="RNA",e.PT="PT",e.UN="UN"}(o||(o={})),function(e){e.aligned="aligned",e.alphabet="alphabet",e.alphabetSize=".alphabetSize",e.alphabetIsMultichar=".alphabetIsMultichar",e.separator="separator",e.isHelmCompatible=".isHelmCompatible",e.positionNames=".positionNames",e.positionLabels=".positionLabels",e.regions=".regions",e.positionShift=".positionShift",e.selectedPosition=".selectedPosition",e.polymerTypeColumnName=".polymerTypeColumnName"}(r||(r={}));const a=", ",l=/(?:\[([A-Za-z0-9_\-,()]+)\])|([A-Za-z\-])/g,c=new class{constructor(){this.fasta={peptide:new Set(["G","L","Y","S","E","Q","D","N","F","A","K","R","H","C","V","P","W","I","M","T"]),dna:new Set(["A","C","G","T"]),rna:new Set(["A","C","G","U"])}}},h=[new s.a(o.PT,c.fasta.peptide,.5),new s.a(o.DNA,c.fasta.dna,.55),new s.a(o.RNA,c.fasta.rna,.55)],u="",d={[i.FASTA]:"-",[i.SEPARATOR]:"",[i.HELM]:"*",[i.BILN]:""},p=" , "},494:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validateTuple=void 0;const i=n(9029),o=n(4227),r=n(5765),s={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){const{schema:t,it:n}=e;if(Array.isArray(t))return a(e,"additionalItems",t);n.items=!0,(0,o.alwaysValidSchema)(n,t)||e.ok((0,r.validateArray)(e))}};function a(e,t,n=e.schema){const{gen:r,parentSchema:s,data:a,keyword:l,it:c}=e;!function(e){const{opts:i,errSchemaPath:r}=c,s=n.length,a=s===e.minItems&&(s===e.maxItems||!1===e[t]);if(i.strictTuples&&!a){const e=`"${l}" is ${s}-tuple, but minItems or maxItems/${t} are not specified or different at path "${r}"`;(0,o.checkStrictMode)(c,e,i.strictTuples)}}(s),c.opts.unevaluated&&n.length&&!0!==c.items&&(c.items=o.mergeEvaluated.items(r,n.length,c.items));const h=r.name("valid"),u=r.const("len",i._`${a}.length`);n.forEach((t,n)=>{(0,o.alwaysValidSchema)(c,t)||(r.if(i._`${u} > ${n}`,()=>e.subschema({keyword:l,schemaProp:n,dataProp:n},h)),e.ok(h))})}t.validateTuple=a,t.default=s},518:e=>{"use strict";e.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/meta/core","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/core":true},"$dynamicAnchor":"meta","title":"Core vocabulary meta-schema","type":["object","boolean"],"properties":{"$id":{"$ref":"#/$defs/uriReferenceString","$comment":"Non-empty fragments not allowed.","pattern":"^[^#]*#?$"},"$schema":{"$ref":"#/$defs/uriString"},"$ref":{"$ref":"#/$defs/uriReferenceString"},"$anchor":{"$ref":"#/$defs/anchorString"},"$dynamicRef":{"$ref":"#/$defs/uriReferenceString"},"$dynamicAnchor":{"$ref":"#/$defs/anchorString"},"$vocabulary":{"type":"object","propertyNames":{"$ref":"#/$defs/uriString"},"additionalProperties":{"type":"boolean"}},"$comment":{"type":"string"},"$defs":{"type":"object","additionalProperties":{"$dynamicRef":"#meta"}}},"$defs":{"anchorString":{"type":"string","pattern":"^[A-Za-z_][-A-Za-z0-9._]*$"},"uriString":{"type":"string","format":"uri"},"uriReferenceString":{"type":"string","format":"uri-reference"}}}')},540:e=>{"use strict";e.exports=function(e){var t=document.createElement("style");return e.setAttributes(t,e.attributes),e.insert(t,e.options),t}},608:(e,t,n)=>{"use strict";n.d(t,{Ap:()=>H,aZ:()=>D,eE:()=>G});var i=n(7389),o=n(6082),r=n(1991),s=n.n(r),a=n(3516),l=n(2003);const c=Symbol("Comlink.proxy"),h=Symbol("Comlink.endpoint"),u=Symbol("Comlink.releaseProxy"),d=Symbol("Comlink.thrown"),p=e=>"object"==typeof e&&null!==e||"function"==typeof e,m=new Map([["proxy",{canHandle:e=>p(e)&&e[c],serialize(e){const{port1:t,port2:n}=new MessageChannel;return g(e,t),[n,[n]]},deserialize:e=>(e.start(),y(e))}],["throw",{canHandle:e=>p(e)&&d in e,serialize({value:e}){let t;return t=e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[t,[]]},deserialize(e){throw e.isError?Object.assign(new Error(e.value.message),e.value):e.value}}]]);function g(e,t=self){t.addEventListener("message",function n(i){if(!i||!i.data)return;const{id:o,type:r,path:s}=Object.assign({path:[]},i.data),a=(i.data.argumentList||[]).map(x);let l;try{const t=s.slice(0,-1).reduce((e,t)=>e[t],e),n=s.reduce((e,t)=>e[t],e);switch(r){case"GET":l=n;break;case"SET":t[s.slice(-1)[0]]=x(i.data.value),l=!0;break;case"APPLY":l=n.apply(t,a);break;case"CONSTRUCT":l=function(e){return Object.assign(e,{[c]:!0})}(new n(...a));break;case"ENDPOINT":{const{port1:t,port2:n}=new MessageChannel;g(e,n),l=function(e,t){return S.set(e,t),e}(t,[t])}break;case"RELEASE":l=void 0;break;default:return}}catch(e){l={value:e,[d]:0}}Promise.resolve(l).catch(e=>({value:e,[d]:0})).then(e=>{const[i,s]=A(e);t.postMessage(Object.assign(Object.assign({},i),{id:o}),s),"RELEASE"===r&&(t.removeEventListener("message",n),f(t))})}),t.start&&t.start()}function f(e){(function(e){return"MessagePort"===e.constructor.name})(e)&&e.close()}function y(e,t){return v(e,[],t)}function b(e){if(e)throw new Error("Proxy has been released and is not useable")}function v(e,t=[],n=function(){}){let i=!1;const o=new Proxy(n,{get(n,r){if(b(i),r===u)return()=>E(e,{type:"RELEASE",path:t.map(e=>e.toString())}).then(()=>{f(e),i=!0});if("then"===r){if(0===t.length)return{then:()=>o};const n=E(e,{type:"GET",path:t.map(e=>e.toString())}).then(x);return n.then.bind(n)}return v(e,[...t,r])},set(n,o,r){b(i);const[s,a]=A(r);return E(e,{type:"SET",path:[...t,o].map(e=>e.toString()),value:s},a).then(x)},apply(n,o,r){b(i);const s=t[t.length-1];if(s===h)return E(e,{type:"ENDPOINT"}).then(x);if("bind"===s)return v(e,t.slice(0,-1));const[a,l]=C(r);return E(e,{type:"APPLY",path:t.map(e=>e.toString()),argumentList:a},l).then(x)},construct(n,o){b(i);const[r,s]=C(o);return E(e,{type:"CONSTRUCT",path:t.map(e=>e.toString()),argumentList:r},s).then(x)}});return o}function w(e){return Array.prototype.concat.apply([],e)}function C(e){const t=e.map(A);return[t.map(e=>e[0]),w(t.map(e=>e[1]))]}const S=new WeakMap;function A(e){for(const[t,n]of m)if(n.canHandle(e)){const[i,o]=n.serialize(e);return[{type:"HANDLER",name:t,value:i},o]}return[{type:"RAW",value:e},S.get(e)||[]]}function x(e){switch(e.type){case"HANDLER":return m.get(e.name).deserialize(e.value);case"RAW":return e.value}}function E(e,t,n){return new Promise(i=>{const o=new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-");e.addEventListener("message",function t(n){!n.data||!n.data.id||n.data.id!==o||(e.removeEventListener("message",t),i(n.data))}),e.start&&e.start(),e.postMessage(Object.assign({id:o},t),n)})}const M="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0ICQ9U3ltYm9sKCJDb21saW5rLnByb3h5IiksQT1TeW1ib2woIkNvbWxpbmsuZW5kcG9pbnQiKSxSPVN5bWJvbCgiQ29tbGluay5yZWxlYXNlUHJveHkiKSx5PVN5bWJvbCgiQ29tbGluay50aHJvd24iKSxfPWU9PnR5cGVvZiBlPT0ib2JqZWN0IiYmZSE9PW51bGx8fHR5cGVvZiBlPT0iZnVuY3Rpb24iLEw9e2NhbkhhbmRsZTplPT5fKGUpJiZlWyRdLHNlcmlhbGl6ZShlKXtjb25zdHtwb3J0MTpyLHBvcnQyOml9PW5ldyBNZXNzYWdlQ2hhbm5lbDtyZXR1cm4gdyhlLHIpLFtpLFtpXV19LGRlc2VyaWFsaXplKGUpe3JldHVybiBlLnN0YXJ0KCksQyhlKX19LE89e2NhbkhhbmRsZTplPT5fKGUpJiZ5IGluIGUsc2VyaWFsaXplKHt2YWx1ZTplfSl7bGV0IHI7cmV0dXJuIGUgaW5zdGFuY2VvZiBFcnJvcj9yPXtpc0Vycm9yOiEwLHZhbHVlOnttZXNzYWdlOmUubWVzc2FnZSxuYW1lOmUubmFtZSxzdGFjazplLnN0YWNrfX06cj17aXNFcnJvcjohMSx2YWx1ZTplfSxbcixbXV19LGRlc2VyaWFsaXplKGUpe3Rocm93IGUuaXNFcnJvcj9PYmplY3QuYXNzaWduKG5ldyBFcnJvcihlLnZhbHVlLm1lc3NhZ2UpLGUudmFsdWUpOmUudmFsdWV9fSxFPW5ldyBNYXAoW1sicHJveHkiLExdLFsidGhyb3ciLE9dXSk7ZnVuY3Rpb24gdyhlLHI9c2VsZil7ci5hZGRFdmVudExpc3RlbmVyKCJtZXNzYWdlIixmdW5jdGlvbiBpKHMpe2lmKCFzfHwhcy5kYXRhKXJldHVybjtjb25zdHtpZDpvLHR5cGU6YSxwYXRoOm59PU9iamVjdC5hc3NpZ24oe3BhdGg6W119LHMuZGF0YSksYz0ocy5kYXRhLmFyZ3VtZW50TGlzdHx8W10pLm1hcChtKTtsZXQgbDt0cnl7Y29uc3QgdT1uLnNsaWNlKDAsLTEpLnJlZHVjZSgoZCxwKT0+ZFtwXSxlKSxmPW4ucmVkdWNlKChkLHApPT5kW3BdLGUpO3N3aXRjaChhKXtjYXNlIkdFVCI6bD1mO2JyZWFrO2Nhc2UiU0VUIjp1W24uc2xpY2UoLTEpWzBdXT1tKHMuZGF0YS52YWx1ZSksbD0hMDticmVhaztjYXNlIkFQUExZIjpsPWYuYXBwbHkodSxjKTticmVhaztjYXNlIkNPTlNUUlVDVCI6e2NvbnN0IGQ9bmV3IGYoLi4uYyk7bD16KGQpfWJyZWFrO2Nhc2UiRU5EUE9JTlQiOntjb25zdHtwb3J0MTpkLHBvcnQyOnB9PW5ldyBNZXNzYWdlQ2hhbm5lbDt3KGUscCksbD1OKGQsW2RdKX1icmVhaztjYXNlIlJFTEVBU0UiOmw9dm9pZCAwO2JyZWFrO2RlZmF1bHQ6cmV0dXJufX1jYXRjaCh1KXtsPXt2YWx1ZTp1LFt5XTowfX1Qcm9taXNlLnJlc29sdmUobCkuY2F0Y2godT0+KHt2YWx1ZTp1LFt5XTowfSkpLnRoZW4odT0+e2NvbnN0W2YsZF09Uyh1KTtyLnBvc3RNZXNzYWdlKE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSxmKSx7aWQ6b30pLGQpLGE9PT0iUkVMRUFTRSImJihyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGkpLE0ocikpfSl9KSxyLnN0YXJ0JiZyLnN0YXJ0KCl9ZnVuY3Rpb24gVChlKXtyZXR1cm4gZS5jb25zdHJ1Y3Rvci5uYW1lPT09Ik1lc3NhZ2VQb3J0In1mdW5jdGlvbiBNKGUpe1QoZSkmJmUuY2xvc2UoKX1mdW5jdGlvbiBDKGUscil7cmV0dXJuIGIoZSxbXSxyKX1mdW5jdGlvbiBoKGUpe2lmKGUpdGhyb3cgbmV3IEVycm9yKCJQcm94eSBoYXMgYmVlbiByZWxlYXNlZCBhbmQgaXMgbm90IHVzZWFibGUiKX1mdW5jdGlvbiBiKGUscj1bXSxpPWZ1bmN0aW9uKCl7fSl7bGV0IHM9ITE7Y29uc3Qgbz1uZXcgUHJveHkoaSx7Z2V0KGEsbil7aWYoaChzKSxuPT09UilyZXR1cm4oKT0+ZyhlLHt0eXBlOiJSRUxFQVNFIixwYXRoOnIubWFwKGM9PmMudG9TdHJpbmcoKSl9KS50aGVuKCgpPT57TShlKSxzPSEwfSk7aWYobj09PSJ0aGVuIil7aWYoci5sZW5ndGg9PT0wKXJldHVybnt0aGVuOigpPT5vfTtjb25zdCBjPWcoZSx7dHlwZToiR0VUIixwYXRoOnIubWFwKGw9PmwudG9TdHJpbmcoKSl9KS50aGVuKG0pO3JldHVybiBjLnRoZW4uYmluZChjKX1yZXR1cm4gYihlLFsuLi5yLG5dKX0sc2V0KGEsbixjKXtoKHMpO2NvbnN0W2wsdV09UyhjKTtyZXR1cm4gZyhlLHt0eXBlOiJTRVQiLHBhdGg6Wy4uLnIsbl0ubWFwKGY9PmYudG9TdHJpbmcoKSksdmFsdWU6bH0sdSkudGhlbihtKX0sYXBwbHkoYSxuLGMpe2gocyk7Y29uc3QgbD1yW3IubGVuZ3RoLTFdO2lmKGw9PT1BKXJldHVybiBnKGUse3R5cGU6IkVORFBPSU5UIn0pLnRoZW4obSk7aWYobD09PSJiaW5kIilyZXR1cm4gYihlLHIuc2xpY2UoMCwtMSkpO2NvbnN0W3UsZl09RihjKTtyZXR1cm4gZyhlLHt0eXBlOiJBUFBMWSIscGF0aDpyLm1hcChkPT5kLnRvU3RyaW5nKCkpLGFyZ3VtZW50TGlzdDp1fSxmKS50aGVuKG0pfSxjb25zdHJ1Y3QoYSxuKXtoKHMpO2NvbnN0W2MsbF09RihuKTtyZXR1cm4gZyhlLHt0eXBlOiJDT05TVFJVQ1QiLHBhdGg6ci5tYXAodT0+dS50b1N0cmluZygpKSxhcmd1bWVudExpc3Q6Y30sbCkudGhlbihtKX19KTtyZXR1cm4gb31mdW5jdGlvbiBEKGUpe3JldHVybiBBcnJheS5wcm90b3R5cGUuY29uY2F0LmFwcGx5KFtdLGUpfWZ1bmN0aW9uIEYoZSl7Y29uc3Qgcj1lLm1hcChTKTtyZXR1cm5bci5tYXAoaT0+aVswXSksRChyLm1hcChpPT5pWzFdKSldfWNvbnN0IFA9bmV3IFdlYWtNYXA7ZnVuY3Rpb24gTihlLHIpe3JldHVybiBQLnNldChlLHIpLGV9ZnVuY3Rpb24geihlKXtyZXR1cm4gT2JqZWN0LmFzc2lnbihlLHtbJF06ITB9KX1mdW5jdGlvbiBTKGUpe2Zvcihjb25zdFtyLGldb2YgRSlpZihpLmNhbkhhbmRsZShlKSl7Y29uc3RbcyxvXT1pLnNlcmlhbGl6ZShlKTtyZXR1cm5be3R5cGU6IkhBTkRMRVIiLG5hbWU6cix2YWx1ZTpzfSxvXX1yZXR1cm5be3R5cGU6IlJBVyIsdmFsdWU6ZX0sUC5nZXQoZSl8fFtdXX1mdW5jdGlvbiBtKGUpe3N3aXRjaChlLnR5cGUpe2Nhc2UiSEFORExFUiI6cmV0dXJuIEUuZ2V0KGUubmFtZSkuZGVzZXJpYWxpemUoZS52YWx1ZSk7Y2FzZSJSQVciOnJldHVybiBlLnZhbHVlfX1mdW5jdGlvbiBnKGUscixpKXtyZXR1cm4gbmV3IFByb21pc2Uocz0+e2NvbnN0IG89VSgpO2UuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsZnVuY3Rpb24gYShuKXshbi5kYXRhfHwhbi5kYXRhLmlkfHxuLmRhdGEuaWQhPT1vfHwoZS5yZW1vdmVFdmVudExpc3RlbmVyKCJtZXNzYWdlIixhKSxzKG4uZGF0YSkpfSksZS5zdGFydCYmZS5zdGFydCgpLGUucG9zdE1lc3NhZ2UoT2JqZWN0LmFzc2lnbih7aWQ6b30sciksaSl9KX1mdW5jdGlvbiBVKCl7cmV0dXJuIG5ldyBBcnJheSg0KS5maWxsKDApLm1hcCgoKT0+TWF0aC5mbG9vcihNYXRoLnJhbmRvbSgpKk51bWJlci5NQVhfU0FGRV9JTlRFR0VSKS50b1N0cmluZygxNikpLmpvaW4oIi0iKX1jb25zdCBXPWFzeW5jKCk9PldlYkFzc2VtYmx5LnZhbGlkYXRlKG5ldyBVaW50OEFycmF5KFswLDk3LDExNSwxMDksMSwwLDAsMCwxLDUsMSw5NiwwLDEsMTIzLDMsMiwxLDAsMTAsMTAsMSw4LDAsNjUsMCwyNTMsMTUsMjUzLDk4LDExXSkpLGs9ImVhZ2VyIix4PSJsYXp5IixqPXtzc3c6WyJzaW1kIl0sbWluaW1hcDI6WyJzaW1kIl19LHQ9e3Rvb2xzOltdLGNvbmZpZzp7fSxmaWxlczpbXSxiYXNlOnt9LGZzOnt9LGFzeW5jIGluaXQoKXtpZih0LnRvb2xzLmxlbmd0aD09PTApdGhyb3ciRXhwZWN0aW5nIGF0IGxlYXN0IDEgdG9vbC4iO2lmKG5ldyBTZXQodC50b29scy5tYXAocj0+YCR7ci50b29sfS8ke3IucHJvZ3JhbXx8ci50b29sfWApKS5zaXplIT09dC50b29scy5sZW5ndGgpdGhyb3ciRm91bmQgZHVwbGljYXRlIHRvb2xzOyBjYW4gb25seSBoYXZlIGVhY2ggdG9vbC9wcm9ncmFtIGNvbWJpbmF0aW9uIGF0IG1vc3Qgb25jZS4iO2lmKHQuYmFzZT10LnRvb2xzLmZpbmQocj0+ci5yZWluaXQhPT0hMCksIXQuYmFzZSl0aHJvdyJDb3VsZCBub3QgZmluZCBhIHRvb2wgd2l0aCBgcmVpbml0OiBmYWxzZWAgdG8gdXNlIGFzIHRoZSBiYXNlIG1vZHVsZS4gVG8gZml4IHRoaXMgaXNzdWUsIGluY2x1ZGUgdGhlIHRvb2wgYGJhc2UvMS4wLjBgIHdoZW4gaW5pdGlhbGl6aW5nIEFpb2xpLiI7cmV0dXJuIHQuYmFzZS5pc0Jhc2VNb2R1bGU9ITAsYXdhaXQgdGhpcy5fc2V0dXAodC5iYXNlKSxhd2FpdCB0aGlzLl9pbml0TW9kdWxlcygpLHQuX2xvZygiUmVhZHkiKSwhMH0sYXN5bmMgX2luaXRNb2R1bGVzKCl7YXdhaXQgUHJvbWlzZS5hbGwodC50b29scy5tYXAodGhpcy5fc2V0dXApKSxhd2FpdCB0aGlzLl9zZXR1cEZTKCl9LG1vdW50KGU9W10pe2NvbnN0IHI9YCR7dC5jb25maWcuZGlyU2hhcmVkfSR7dC5jb25maWcuZGlyRGF0YX1gLGk9YCR7dC5jb25maWcuZGlyU2hhcmVkfSR7dC5jb25maWcuZGlyTW91bnRlZH1gO2xldCBzPVtdLG89W10sYT1bXTshQXJyYXkuaXNBcnJheShlKSYmIShlIGluc3RhbmNlb2YgRmlsZUxpc3QpJiYoZT1bZV0pLHQuX2xvZyhgTW91bnRpbmcgJHtlLmxlbmd0aH0gZmlsZXNgKTtmb3IobGV0IG4gb2YgZSl7aWYobiBpbnN0YW5jZW9mIEZpbGV8fChuPT1udWxsP3ZvaWQgMDpuLmRhdGEpaW5zdGFuY2VvZiBCbG9iJiZuLm5hbWV8fHR5cGVvZihuPT1udWxsP3ZvaWQgMDpuLmRhdGEpPT0ic3RyaW5nIiYmbi5uYW1lKXR5cGVvZihuPT1udWxsP3ZvaWQgMDpuLmRhdGEpPT0ic3RyaW5nIiYmKG4uZGF0YT1uZXcgQmxvYihbbi5kYXRhXSx7dHlwZToidGV4dC9wbGFpbiJ9KSkscy5wdXNoKG4pO2Vsc2UgaWYobi5uYW1lJiZuLnVybClvLnB1c2gobik7ZWxzZSBpZih0eXBlb2Ygbj09InN0cmluZyImJm4uc3RhcnRzV2l0aCgiaHR0cCIpKW49e3VybDpuLG5hbWU6bi5zcGxpdCgiLy8iKS5wb3AoKS5yZXBsYWNlKC9cLy9nLCItIil9LG8ucHVzaChuKTtlbHNlIHRocm93J0Nhbm5vdCBtb3VudCBmaWxlKHMpIHNwZWNpZmllZC4gTXVzdCBiZSBhIEZpbGUsIEJsb2IsIGEgVVJMIHN0cmluZywgb3IgeyBuYW1lOiAiZmlsZS50eHQiLCBkYXRhOiAic3RyaW5nIiB9Lic7YS5wdXNoKG4ubmFtZSl9dHJ5e3QuZnMudW5tb3VudChpKX1jYXRjaHt9Zm9yKGxldCBuIG9mIG8pdC5mcy5jcmVhdGVMYXp5RmlsZShyLG4ubmFtZSxuLnVybCwhMCwhMCk7cmV0dXJuIHQuZmlsZXM9dC5maWxlcy5jb25jYXQocyksdC5iYXNlLm1vZHVsZS5GUy5tb3VudCh0LmJhc2UubW9kdWxlLldPUktFUkZTLHtmaWxlczp0LmZpbGVzLmZpbHRlcihuPT5uIGluc3RhbmNlb2YgRmlsZSksYmxvYnM6dC5maWxlcy5maWx0ZXIobj0+KG49PW51bGw/dm9pZCAwOm4uZGF0YSlpbnN0YW5jZW9mIEJsb2IpfSxpKSxzLm1hcChuPT57Y29uc3QgYz1gJHtpfS8ke24ubmFtZX1gLGw9YCR7cn0vJHtuLm5hbWV9YDt0cnl7dC5mcy51bmxpbmsobCl9Y2F0Y2h7fXQuX2xvZyhgQ3JlYXRpbmcgc3ltbGluazogJHtsfSAtLT4gJHtjfWApLHQuZnMuc3ltbGluayhjLGwpfSksYS5tYXAobj0+YCR7cn0vJHtufWApfSxhc3luYyBleGVjKGUscj1udWxsKXtpZih0Ll9sb2coYEV4ZWN1dGluZyAlYyR7ZX0lYyBhcmdzPSR7cn1gLCJjb2xvcjpkYXJrYmx1ZTsgZm9udC13ZWlnaHQ6Ym9sZCIsIiIpLCFlKXRocm93IkV4cGVjdGluZyBhIGNvbW1hbmQiO2xldCBpPWU7cj09bnVsbCYmKHI9ZS5zcGxpdCgiICIpLGk9ci5zaGlmdCgpKTtjb25zdCBzPXQudG9vbHMuZmluZChhPT57dmFyIGM7bGV0IG49aTtyZXR1cm4oKGM9YT09bnVsbD92b2lkIDA6YS5mZWF0dXJlcyk9PW51bGw/dm9pZCAwOmMuc2ltZCk9PT0hMCYmKG49YCR7bn0tc2ltZGApLGEucHJvZ3JhbT09bn0pO2lmKHM9PW51bGwpdGhyb3dgUHJvZ3JhbSAke2l9IG5vdCBmb3VuZC5gO3Muc3Rkb3V0PSIiLHMuc3RkZXJyPSIiLHMubG9hZGluZz09eCYmKHMubG9hZGluZz1rLGF3YWl0IHRoaXMuX2luaXRNb2R1bGVzKCkpO3RyeXtzLm1vZHVsZS5jYWxsTWFpbihyKX1jYXRjaChhKXtjb25zb2xlLmVycm9yKGEpfXRyeXtzLm1vZHVsZS5GUy5jbG9zZShzLm1vZHVsZS5GUy5zdHJlYW1zWzFdKSxzLm1vZHVsZS5GUy5jbG9zZShzLm1vZHVsZS5GUy5zdHJlYW1zWzJdKX1jYXRjaHt9cy5tb2R1bGUuRlMuc3RyZWFtc1sxXT1zLm1vZHVsZS5GUy5vcGVuKCIvZGV2L3N0ZG91dCIsInciKSxzLm1vZHVsZS5GUy5zdHJlYW1zWzJdPXMubW9kdWxlLkZTLm9wZW4oIi9kZXYvc3RkZXJyIiwidyIpO2xldCBvPXtzdGRvdXQ6cy5zdGRvdXQsc3RkZXJyOnMuc3RkZXJyfTtyZXR1cm4gdC5jb25maWcucHJpbnRJbnRlcmxlYXZlZCYmKG89cy5zdGRvdXQpLHMucmVpbml0PT09ITAmJmF3YWl0IHRoaXMucmVpbml0KHMudG9vbCksb30sY2F0KGUpe3JldHVybiB0Ll9maWxlb3AoImNhdCIsZSl9LGxzKGUpe3JldHVybiB0Ll9maWxlb3AoImxzIixlKX0sZG93bmxvYWQoZSl7cmV0dXJuIHQuX2ZpbGVvcCgiZG93bmxvYWQiLGUpfSxwd2QoKXtyZXR1cm4gdC5mcy5jd2QoKX0sY2QoZSl7Zm9yKGxldCByIG9mIHQudG9vbHMpIXIubW9kdWxlfHxyLm1vZHVsZS5GUy5jaGRpcihlKX0sbWtkaXIoZSl7cmV0dXJuIHQuZnMubWtkaXIoZSksITB9LHJlYWQoe3BhdGg6ZSxsZW5ndGg6cixmbGFnOmk9InIiLG9mZnNldDpzPTAscG9zaXRpb246bz0wfSl7Y29uc3QgYT10LmZzLm9wZW4oZSxpKSxuPW5ldyBVaW50OEFycmF5KHIpO3JldHVybiB0LmZzLnJlYWQoYSxuLHMscixvKSx0LmZzLmNsb3NlKGEpLG59LHdyaXRlKHtwYXRoOmUsYnVmZmVyOnIsZmxhZzppPSJ3KyIsb2Zmc2V0OnM9MCxwb3NpdGlvbjpvPTB9KXtjb25zdCBhPXQuZnMub3BlbihlLGkpO3QuZnMud3JpdGUoYSxyLHMsci5sZW5ndGgsbyksdC5mcy5jbG9zZShhKX0sYXN5bmMgcmVpbml0KGUpe2NvbnN0IHI9dC50b29scy5maW5kKHM9PnMudG9vbD09ZSksaT10LmJhc2UubW9kdWxlLkZTLmN3ZCgpO09iamVjdC5hc3NpZ24ocixyLmNvbmZpZyksci5yZWFkeT0hMSxhd2FpdCB0aGlzLmluaXQoKSxyLmlzQmFzZU1vZHVsZSYmdGhpcy5tb3VudCgpLHRoaXMuY2QoaSl9LF9zdGRpblR4dDoiIixfc3RkaW5QdHI6MCxnZXQgc3RkaW4oKXtyZXR1cm4gdC5fc3RkaW5UeHR9LHNldCBzdGRpbihlPSIiKXt0Ll9sb2coYFNldHRpbmcgc3RkaW4gdG8gJWMke2V9JWNgLCJjb2xvcjpkYXJrYmx1ZSIsIiIpLHQuX3N0ZGluVHh0PWUsdC5fc3RkaW5QdHI9MH0sYXN5bmMgX3NldHVwKGUpe2lmKGUucmVhZHkpcmV0dXJuO2lmKHQuX2xvZyhgU2V0dGluZyB1cCAke2UudG9vbH0gKGJhc2UgPSAke2UuaXNCYXNlTW9kdWxlPT09ITB9KS4uLmApLGUuY29uZmlnPU9iamVjdC5hc3NpZ24oe30sZSksZS51cmxQcmVmaXh8fChlLnVybFByZWZpeD1gJHt0LmNvbmZpZy51cmxDRE59LyR7ZS50b29sfS8ke2UudmVyc2lvbn1gKSxlLnByb2dyYW18fChlLnByb2dyYW09ZS50b29sKSxlLmZlYXR1cmVzfHwoZS5mZWF0dXJlcz17fSwoaltlLnByb2dyYW1dfHxbXSkuaW5jbHVkZXMoInNpbWQiKSYmKGF3YWl0IFcoKT8oZS5wcm9ncmFtKz0iLXNpbWQiLGUuZmVhdHVyZXMuc2ltZD0hMCk6dC5fbG9nKGBXZWJBc3NlbWJseSBTSU1EIGlzIG5vdCBzdXBwb3J0ZWQgaW4gdGhpcyBicm93c2VyOyB3aWxsIGxvYWQgbm9uLVNJTUQgdmVyc2lvbiBvZiAke2UucHJvZ3JhbX0uYCkpKSxlLmlzQmFzZU1vZHVsZSYmKGUubG9hZGluZz1rKSxlLmxvYWRpbmc9PT14KXt0Ll9sb2coYFdpbGwgbGF6eS1sb2FkICR7ZS50b29sfTsgc2tpcHBpbmcgaW5pdGlhbGl6YXRpb24uYCk7cmV0dXJufXNlbGYuaW1wb3J0U2NyaXB0cyhgJHtlLnVybFByZWZpeH0vJHtlLnByb2dyYW19LmpzYCksZS5tb2R1bGU9YXdhaXQgTW9kdWxlKHt0aGlzUHJvZ3JhbTplLnByb2dyYW0sbG9jYXRlRmlsZTooaSxzKT0+YCR7ZS51cmxQcmVmaXh9LyR7aX1gLHN0ZGluOigpPT50Ll9zdGRpblB0cjx0LnN0ZGluLmxlbmd0aD90LnN0ZGluLmNoYXJDb2RlQXQodC5fc3RkaW5QdHIrKyk6KHQuc3RkaW49IiIsbnVsbCkscHJpbnQ6aT0+e3QuY29uZmlnLnByaW50U3RyZWFtP3Bvc3RNZXNzYWdlKHt0eXBlOiJiaW93YXNtIix2YWx1ZTp7c3Rkb3V0Oml9fSk6ZS5zdGRvdXQrPWkrYApgfSxwcmludEVycjppPT57Y29uc3Qgcz10LmNvbmZpZy5wcmludEludGVybGVhdmVkPyJzdGRvdXQiOiJzdGRlcnIiO3QuY29uZmlnLnByaW50U3RyZWFtP3Bvc3RNZXNzYWdlKHt0eXBlOiJiaW93YXNtIix2YWx1ZTp7W3NdOml9fSk6ZVtzXSs9aStgCmB9fSk7Y29uc3Qgcj1lLm1vZHVsZS5GUztlLmlzQmFzZU1vZHVsZT8odC5fbG9nKGBTZXR0aW5nIHVwICR7ZS50b29sfSB3aXRoIGJhc2UgbW9kdWxlIGZpbGVzeXN0ZW0uLi5gKSxyLm1rZGlyKHQuY29uZmlnLmRpclNoYXJlZCw1MTEpLHIubWtkaXIoYCR7dC5jb25maWcuZGlyU2hhcmVkfS8ke3QuY29uZmlnLmRpckRhdGF9YCw1MTEpLHIubWtkaXIoYCR7dC5jb25maWcuZGlyU2hhcmVkfS8ke3QuY29uZmlnLmRpck1vdW50ZWR9YCw1MTEpLHIuY2hkaXIoYCR7dC5jb25maWcuZGlyU2hhcmVkfS8ke3QuY29uZmlnLmRpckRhdGF9YCksdC5mcz1yKToodC5fbG9nKGBTZXR0aW5nIHVwICR7ZS50b29sfSB3aXRoIGZpbGVzeXN0ZW0uLi5gKSxyLm1rZGlyKHQuY29uZmlnLmRpclNoYXJlZCksci5tb3VudChlLm1vZHVsZS5QUk9YWUZTLHtyb290OnQuY29uZmlnLmRpclNoYXJlZCxmczp0LmZzfSx0LmNvbmZpZy5kaXJTaGFyZWQpLHIuY2hkaXIodC5mcy5jd2QoKSkpLGUuc3Rkb3V0PSIiLGUuc3RkZXJyPSIiLGUucmVhZHk9ITB9LGFzeW5jIF9zZXR1cEZTKCl7Y29uc3QgZT10LmZzO2ZvcihsZXQgciBvZiB0LnRvb2xzKXtpZighci5yZWFkeSljb250aW51ZTtjb25zdCBpPXIubW9kdWxlLkZTLHM9YC8ke3IudG9vbH1gLG89YCR7dC5jb25maWcuZGlyU2hhcmVkfSR7c31gOyFpLmFuYWx5emVQYXRoKHMpLmV4aXN0c3x8ZS5hbmFseXplUGF0aChvKS5leGlzdHN8fCh0Ll9sb2coYE1vdW50aW5nICR7c30gb250byAke3QuYmFzZS50b29sfSBmaWxlc3lzdGVtIGF0ICR7b31gKSxlLm1rZGlyKG8pLGUubW91bnQodC5iYXNlLm1vZHVsZS5QUk9YWUZTLHtyb290OnMsZnM6aX0sbykpfX0sX2ZpbGVvcChlLHIpe3QuX2xvZyhgUnVubmluZyAke2V9ICR7cn1gKTtjb25zdCBpPXQuZnMuYW5hbHl6ZVBhdGgocik7aWYoIWkuZXhpc3RzKXJldHVybiB0Ll9sb2coYEZpbGUgJHtyfSBub3QgZm91bmQuYCksITE7c3dpdGNoKGUpe2Nhc2UiY2F0IjpyZXR1cm4gdC5mcy5yZWFkRmlsZShyLHtlbmNvZGluZzoidXRmOCJ9KTtjYXNlImxzIjpyZXR1cm4gdC5mcy5pc0ZpbGUoaS5vYmplY3QubW9kZSk/dC5mcy5zdGF0KHIpOnQuZnMucmVhZGRpcihyKTtjYXNlImRvd25sb2FkIjpjb25zdCBzPW5ldyBCbG9iKFt0aGlzLmNhdChyKV0pO3JldHVybiBVUkwuY3JlYXRlT2JqZWN0VVJMKHMpfXJldHVybiExfSxfbG9nKGUpe2lmKCF0LmNvbmZpZy5kZWJ1ZylyZXR1cm47bGV0IHI9Wy4uLmFyZ3VtZW50c107ci5zaGlmdCgpLGNvbnNvbGUubG9nKGAlY1tXZWJXb3JrZXJdJWMgJHtlfWAsImZvbnQtd2VpZ2h0OmJvbGQiLCIiLC4uLnIpfX07dyh0KX0pKCk7Cg==",T=typeof window<"u"&&window.Blob&&new Blob([atob(M)],{type:"text/javascript;charset=utf-8"});function _(){const e=T&&(window.URL||window.webkitURL).createObjectURL(T);try{return e?new Worker(e):new Worker("data:application/javascript;base64,"+M)}finally{e&&(window.URL||window.webkitURL).revokeObjectURL(e)}}const I={urlCDN:"https://biowasm.com/cdn/v3",urlCDNStg:"https://stg.biowasm.com/cdn/v3",dirShared:"/shared",dirMounted:"/mnt",dirData:"/data",printInterleaved:!0,printStream:!1,callback:null,debug:!1,env:"prd"};class L{constructor(e,t={}){if(null==e)throw"Expecting array of tools as input to Aioli constructor.";return Array.isArray(e)||(e=[e]),t=Object.assign({},I,t),e=e.map(this._parseTool),"stg"===t.env&&(t.urlCDN=t.urlCDNStg),this.tools=e,this.config=t,null!=this.config.callback&&(this.callback=this.config.callback),delete this.config.callback,this.init()}async init(){const e=new _;this.callback&&(e.onmessage=e=>{"biowasm"===e.data.type&&this.callback(e.data.value)});const t=y(e);return t.tools=this.tools,t.config=this.config,await t.init(),t}_parseTool(e){if("string"!=typeof e)return e;const t=e.split("/");if(2!=t.length&&3!=t.length)throw"Expecting '<tool>/<version>' or '<tool>/<program>/<version>'";return{tool:t[0],program:3==t.length?t[1]:t[0],version:t[t.length-1]}}}var N=n(3629);class P{static getAvailableScales(){return Object.entries(this.scales).map(([e,t])=>e)}static getScale(e){return(0,N.vA)(!(void 0===this.scales[e]),`Scale '${e}' was not found.`),this.scales[e]}}P.scales={WimleyWhite:{"-":0,A:.17,C:-.24,D:-.07,E:-.01,F:-1.13,G:.01,H:.17,I:-.31,K:.99,L:-.56,M:-.23,N:.42,P:.45,Q:.58,R:.81,S:.13,T:.14,V:.07,W:-1.85,Y:-.94},categorial:{"-":0,A:1,C:2,D:3,E:4,F:5,G:6,H:7,I:8,K:9,L:10,M:11,N:12,P:13,Q:14,R:15,S:16,T:17,V:18,W:19,Y:20}};class R{constructor(e="categorial"){this.aa2num=P.getScale(e),this.num2aa={},Object.entries(this.aa2num).forEach(([e,t])=>this.num2aa[t]=e)}static _truncateSequence(e){let t=0,n=e.length;const i=["NH2","COOH"];if(e.startsWith(i[0])){const n=i[0].length;(0,N.vA)("-"==e[n],`Wrong sequence format: ${i[0]} without following '-' in '${e}'.`),t=n}if(e.endsWith(i[1])){const t=i[1].length+1;(0,N.vA)("-"==e[n-t],`Wrong sequence format: ${i[1]} without '-' precending in '${e}'.`),n-=t}return e.substring(t,n)}static _dropDefises(e){return e.replace(/(-)([^-]+)/g,"$2")}static clean(e){return R._dropDefises(R._truncateSequence(e))}encode(e){const t=e.length,n=new Array(t).fill(0);for(let i=0;i<t;++i){const t=e[i];(0,N.vA)(t in this.aa2num,`Unknown char '${t}' found in sequence '${e}'`),n[i]=this.encodeLettter(t)}return n}encodeLettter(e){return this.aa2num[e]}decode(e){let t="";for(let n=0;n<e.length;++n){const i=e[n];(0,N.vA)(i in this.num2aa,`Unknown code '${i}' found in vector '${e}'`),t+=this.num2aa[i]}return t}}var $=n(4139);const O="input.fa",k="result.fasta";class H extends Error{element;constructor(e,t){super(e.innerText,t),this.element=e}}function F(e){return e.reduce((e,t,n)=>e+`>sample${n+1}\n${t}\n`,"")}async function G(e,t,n=!1,i="",r=null,s,c,h,u){let d=t.toList();n&&(d=d.map(e=>R.clean(e).replace(/\-/g,"")));const p=t.length;r??=o.Column.string("Clusters",p).init("0"),r.type!=o.COLUMN_TYPE.STRING&&(r=r.convertTo(o.TYPE.STRING)),r.compact();const m=r.categories,g=r.getRawData(),f=new Array(m.length),y=new Array(m.length);if(u){const t=e.selection;if(0===t.length)throw new Error("No selected rows in the table.");for(let e=-1;-1!==(e=t.findNext(e,!0));){const t=g[e];(f[t]??=[]).push(d[e]),(y[t]??=[]).push(e)}}else for(let e=0;e<p;++e){const t=g[e];(f[t]??=[]).push(d[e]),(y[t]??=[]).push(e)}D(y,m);const b=await new L(["base/1.0.0",{tool:"kalign",version:$.b9,reinit:!0}]),v=o.Column.string(i,p);for(let e=0;e<m.length;++e){const t=f[e];if(!t||0===t.length)continue;const n=F(t);await b.fs.writeFile(O,n);const i=`${void 0!==s?` --gpo ${s}`:""}${void 0!==c?` --gpe ${c}`:""}${void 0!==h?` --tgpe ${h}`:""}`,o=await b.exec(`kalign ${O} -f fasta -o ${k}${i}`);console.warn(o);const r=await b.cat(k);if(!r){const e=B(o,1);throw new Error(e)}const l=new a.m(r).sequencesArray,u=y[e];for(let e=0;e<l.length;++e)v.set(u[e],l[e])}const w=t.meta.units,C=t.getTag(l.gp.alphabet);return v.meta.units=w,v.setTag(l.gp.aligned,"SEQ.MSA"),v.setTag(l.gp.alphabet,C),v.semType=o.SEMTYPE.MACROMOLECULE,v}function B(e,t){const n=[],i=/^.+ERROR : (.+)$/gm;let o;for(;null!=(o=i.exec(e))&&(null==t||n.length<t);)n.push(o[1]);return n.join("\n")}function D(e,t){const n=e.map((e,t)=>[e,t]).filter(([e,t])=>1==e.length).map(([e,t])=>t);if(n.length>0){const e=i.div([i.divText(`MSA analysis is not available on single sequence clusters #${n.length}:`),...s()(n).take(3).map(e=>{let o=t[e];return o.length>25&&(o=o.slice(0,25)+"..."),i.divText(`"${o}"${e<n.length-1?", ":"."}`)}).toArray(),...n.length>3?[i.divText("...")]:[]]);throw new H(e)}}},617:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(208),o=n(9029),r=n(4227),s=n(6250),a={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:{message:({params:{i:e,j:t}})=>o.str`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>o._`{i: ${e}, j: ${t}}`},code(e){const{gen:t,data:n,$data:a,schema:l,parentSchema:c,schemaCode:h,it:u}=e;if(!a&&!l)return;const d=t.let("valid"),p=c.items?(0,i.getSchemaTypes)(c.items):[];function m(r,s){const a=t.name("item"),l=(0,i.checkDataTypes)(p,a,u.opts.strictNumbers,i.DataType.Wrong),c=t.const("indices",o._`{}`);t.for(o._`;${r}--;`,()=>{t.let(a,o._`${n}[${r}]`),t.if(l,o._`continue`),p.length>1&&t.if(o._`typeof ${a} == "string"`,o._`${a} += "_"`),t.if(o._`typeof ${c}[${a}] == "number"`,()=>{t.assign(s,o._`${c}[${a}]`),e.error(),t.assign(d,!1).break()}).code(o._`${c}[${a}] = ${r}`)})}function g(i,a){const l=(0,r.useFunc)(t,s.default),c=t.name("outer");t.label(c).for(o._`;${i}--;`,()=>t.for(o._`${a} = ${i}; ${a}--;`,()=>t.if(o._`${l}(${n}[${i}], ${n}[${a}])`,()=>{e.error(),t.assign(d,!1).break(c)})))}e.block$data(d,function(){const i=t.let("i",o._`${n}.length`),r=t.let("j");e.setParams({i,j:r}),t.assign(d,!0),t.if(o._`${i} > 1`,()=>(p.length>0&&!p.some(e=>"object"===e||"array"===e)?m:g)(i,r))},o._`${h} === false`),e.ok(d)}};t.default=a},673:(e,t,n)=>{"use strict";n.d(t,{s:()=>i});const i={true:"1",false:"0"}},684:(e,t,n)=>{"use strict";n.d(t,{C0:()=>r,GP:()=>i,Gi:()=>a,YP:()=>c,_X:()=>s,n3:()=>o,vb:()=>l});const i="dim-red-preprocessing-function",o="supportedSemTypes",r="supportedTypes",s="supportedUnits",a="supportedDistanceFunctions",l="bypassLargeDataWarning",c="show-scatterplot-progress"},857:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var i=n(1354),o=n.n(i),r=n(6314),s=n.n(r)()(o());s.push([e.id,".monomer-manager-root .grok-sketcher {\n min-width: unset !important;\n}\n\n.monomer-manager-root {\n width: 100% !important;\n height: 100% !important;\n}\n\n.monomer-manager-sketcher .ketcher-host {\n height: 100% !important;\n width: unset !important;\n} \n\n.monomer-manager-root > div:first-child {\n flex-basis: 40% !important;\n}\n.monomer-manager-root > div:nth-child(2) {\n flex-basis: 60% !important;\n}\n\n.monomer-manager-root > div:first-child > .ui-form {\n max-width: unset !important;\n}\n\n.monomer-card-info-row {\n width: 100%;\n overflow: hidden;\n text-overflow: ellipsis;\n margin-bottom: 10px;\n}\n\n.monomer-card-info-row > div:nth-child(2) {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.monomer-card-info-row > div:nth-child(1) {\n font-weight: bold;\n margin-right: 5px;\n text-wrap: nowrap;\n}\n\n.duplicate-monomer-symbol-row {\n visibility: visible !important;\n}\n\n.monomer-card-root {\n border: 2px solid var(--grey-2);\n border-radius: 5px;\n padding: 5px;\n margin: 5px;\n overflow: hidden;\n align-items: center;\n cursor: pointer;\n width: 200px;\n height: 300px;\n min-width: 200px;\n min-height: 300px;\n}\n\n.duplicate-monomers-virtual-view {\n width: 100% !important;\n overflow-x: clip;\n overflow-y: auto;\n}\n\n.monomer-manager-form-tab-control input.d4-invalid {\n background: #ff000030;\n}\n\n.monomer-lib-controls-form .ui-input-root {\n flex-wrap: nowrap !important;\n}","",{version:3,sources:["webpack://./css/monomer-manager.css"],names:[],mappings:"AAAA;IACI,2BAA2B;AAC/B;;AAEA;IACI,sBAAsB;IACtB,uBAAuB;AAC3B;;AAEA;IACI,uBAAuB;IACvB,uBAAuB;AAC3B;;AAEA;IACI,0BAA0B;AAC9B;AACA;IACI,0BAA0B;AAC9B;;AAEA;IACI,2BAA2B;AAC/B;;AAEA;IACI,WAAW;IACX,gBAAgB;IAChB,uBAAuB;IACvB,mBAAmB;AACvB;;AAEA;IACI,mBAAmB;IACnB,gBAAgB;IAChB,uBAAuB;AAC3B;;AAEA;IACI,iBAAiB;IACjB,iBAAiB;IACjB,iBAAiB;AACrB;;AAEA;IACI,8BAA8B;AAClC;;AAEA;IACI,+BAA+B;IAC/B,kBAAkB;IAClB,YAAY;IACZ,WAAW;IACX,gBAAgB;IAChB,mBAAmB;IACnB,eAAe;IACf,YAAY;IACZ,aAAa;IACb,gBAAgB;IAChB,iBAAiB;AACrB;;AAEA;IACI,sBAAsB;IACtB,gBAAgB;IAChB,gBAAgB;AACpB;;AAEA;IACI,qBAAqB;AACzB;;AAEA;IACI,4BAA4B;AAChC",sourcesContent:[".monomer-manager-root .grok-sketcher {\n min-width: unset !important;\n}\n\n.monomer-manager-root {\n width: 100% !important;\n height: 100% !important;\n}\n\n.monomer-manager-sketcher .ketcher-host {\n height: 100% !important;\n width: unset !important;\n} \n\n.monomer-manager-root > div:first-child {\n flex-basis: 40% !important;\n}\n.monomer-manager-root > div:nth-child(2) {\n flex-basis: 60% !important;\n}\n\n.monomer-manager-root > div:first-child > .ui-form {\n max-width: unset !important;\n}\n\n.monomer-card-info-row {\n width: 100%;\n overflow: hidden;\n text-overflow: ellipsis;\n margin-bottom: 10px;\n}\n\n.monomer-card-info-row > div:nth-child(2) {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.monomer-card-info-row > div:nth-child(1) {\n font-weight: bold;\n margin-right: 5px;\n text-wrap: nowrap;\n}\n\n.duplicate-monomer-symbol-row {\n visibility: visible !important;\n}\n\n.monomer-card-root {\n border: 2px solid var(--grey-2);\n border-radius: 5px;\n padding: 5px;\n margin: 5px;\n overflow: hidden;\n align-items: center;\n cursor: pointer;\n width: 200px;\n height: 300px;\n min-width: 200px;\n min-height: 300px;\n}\n\n.duplicate-monomers-virtual-view {\n width: 100% !important;\n overflow-x: clip;\n overflow-y: auto;\n}\n\n.monomer-manager-form-tab-control input.d4-invalid {\n background: #ff000030;\n}\n\n.monomer-lib-controls-form .ui-input-root {\n flex-wrap: nowrap !important;\n}"],sourceRoot:""}]);const a=s},934:function(e){e.exports=function(){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,i(e,t)}function n(e){return n=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},n(e)}function i(e,t){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},i(e,t)}function o(e,t,n){return o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}()?Reflect.construct.bind():function(e,t,n){var o=[null];o.push.apply(o,t);var r=new(Function.bind.apply(e,o));return n&&i(r,n.prototype),r},o.apply(null,arguments)}function r(e){var t="function"==typeof Map?new Map:void 0;return r=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,s)}function s(){return o(e,arguments,n(this).constructor)}return s.prototype=Object.create(e.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),i(s,e)},r(e)}function s(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var a=function(){for(var e=arguments[0],t=1,n=arguments.length;t<n;t++)if(arguments[t])for(var i in arguments[t])e[i]=arguments[t][i];return e};function l(e,t,n,i){var o=e._nodes.get(t),r=null;return o?r="mixed"===i?o.out&&o.out[n]||o.undirected&&o.undirected[n]:"directed"===i?o.out&&o.out[n]:o.undirected&&o.undirected[n]:r}function c(t){return"object"===e(t)&&null!==t}function h(e){var t;for(t in e)return!1;return!0}function u(e,t,n){Object.defineProperty(e,t,{enumerable:!1,configurable:!1,writable:!0,value:n})}function d(e,t,n){var i={enumerable:!0,configurable:!0};"function"==typeof n?i.get=n:(i.value=n,i.writable=!1),Object.defineProperty(e,t,i)}function p(e){return!(!c(e)||e.attributes&&!Array.isArray(e.attributes))}"function"==typeof Object.assign&&(a=Object.assign);var m,g={exports:{}},f="object"==typeof Reflect?Reflect:null,y=f&&"function"==typeof f.apply?f.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};m=f&&"function"==typeof f.ownKeys?f.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var b=Number.isNaN||function(e){return e!=e};function v(){v.init.call(this)}g.exports=v,g.exports.once=function(e,t){return new Promise(function(n,i){function o(n){e.removeListener(t,r),i(n)}function r(){"function"==typeof e.removeListener&&e.removeListener("error",o),n([].slice.call(arguments))}I(e,t,r,{once:!0}),"error"!==t&&function(e,t){"function"==typeof e.on&&I(e,"error",t,{once:!0})}(e,o)})},v.EventEmitter=v,v.prototype._events=void 0,v.prototype._eventsCount=0,v.prototype._maxListeners=void 0;var w=10;function C(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function S(e){return void 0===e._maxListeners?v.defaultMaxListeners:e._maxListeners}function A(e,t,n,i){var o,r,s,a;if(C(n),void 0===(r=e._events)?(r=e._events=Object.create(null),e._eventsCount=0):(void 0!==r.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),r=e._events),s=r[t]),void 0===s)s=r[t]=n,++e._eventsCount;else if("function"==typeof s?s=r[t]=i?[n,s]:[s,n]:i?s.unshift(n):s.push(n),(o=S(e))>0&&s.length>o&&!s.warned){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=s.length,a=l,console&&console.warn&&console.warn(a)}return e}function x(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function E(e,t,n){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},o=x.bind(i);return o.listener=n,i.wrapFn=o,o}function M(e,t,n){var i=e._events;if(void 0===i)return[];var o=i[t];return void 0===o?[]:"function"==typeof o?n?[o.listener||o]:[o]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(o):_(o,o.length)}function T(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function _(e,t){for(var n=new Array(t),i=0;i<t;++i)n[i]=e[i];return n}function I(e,t,n,i){if("function"==typeof e.on)i.once?e.once(t,n):e.on(t,n);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,function o(r){i.once&&e.removeEventListener(t,o),n(r)})}}function L(e){if("function"!=typeof e)throw new Error("obliterator/iterator: expecting a function!");this.next=e}Object.defineProperty(v,"defaultMaxListeners",{enumerable:!0,get:function(){return w},set:function(e){if("number"!=typeof e||e<0||b(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");w=e}}),v.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},v.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||b(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},v.prototype.getMaxListeners=function(){return S(this)},v.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var i="error"===e,o=this._events;if(void 0!==o)i=i&&void 0===o.error;else if(!i)return!1;if(i){var r;if(t.length>0&&(r=t[0]),r instanceof Error)throw r;var s=new Error("Unhandled error."+(r?" ("+r.message+")":""));throw s.context=r,s}var a=o[e];if(void 0===a)return!1;if("function"==typeof a)y(a,this,t);else{var l=a.length,c=_(a,l);for(n=0;n<l;++n)y(c[n],this,t)}return!0},v.prototype.addListener=function(e,t){return A(this,e,t,!1)},v.prototype.on=v.prototype.addListener,v.prototype.prependListener=function(e,t){return A(this,e,t,!0)},v.prototype.once=function(e,t){return C(t),this.on(e,E(this,e,t)),this},v.prototype.prependOnceListener=function(e,t){return C(t),this.prependListener(e,E(this,e,t)),this},v.prototype.removeListener=function(e,t){var n,i,o,r,s;if(C(t),void 0===(i=this._events))return this;if(void 0===(n=i[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(o=-1,r=n.length-1;r>=0;r--)if(n[r]===t||n[r].listener===t){s=n[r].listener,o=r;break}if(o<0)return this;0===o?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,o),1===n.length&&(i[e]=n[0]),void 0!==i.removeListener&&this.emit("removeListener",e,s||t)}return this},v.prototype.off=v.prototype.removeListener,v.prototype.removeAllListeners=function(e){var t,n,i;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var o,r=Object.keys(n);for(i=0;i<r.length;++i)"removeListener"!==(o=r[i])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this},v.prototype.listeners=function(e){return M(this,e,!0)},v.prototype.rawListeners=function(e){return M(this,e,!1)},v.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):T.call(e,t)},v.prototype.listenerCount=T,v.prototype.eventNames=function(){return this._eventsCount>0?m(this._events):[]},"undefined"!=typeof Symbol&&(L.prototype[Symbol.iterator]=function(){return this}),L.of=function(){var e=arguments,t=e.length,n=0;return new L(function(){return n>=t?{done:!0}:{done:!1,value:e[n++]}})},L.empty=function(){return new L(function(){return{done:!0}})},L.fromSequence=function(e){var t=0,n=e.length;return new L(function(){return t>=n?{done:!0}:{done:!1,value:e[t++]}})},L.is=function(e){return e instanceof L||"object"==typeof e&&null!==e&&"function"==typeof e.next};var N=L,P={};P.ARRAY_BUFFER_SUPPORT="undefined"!=typeof ArrayBuffer,P.SYMBOL_SUPPORT="undefined"!=typeof Symbol;var R=N,$=P,O=$.ARRAY_BUFFER_SUPPORT,k=$.SYMBOL_SUPPORT,H=function(e){var t=function(e){return"string"==typeof e||Array.isArray(e)||O&&ArrayBuffer.isView(e)?R.fromSequence(e):"object"!=typeof e||null===e?null:k&&"function"==typeof e[Symbol.iterator]?e[Symbol.iterator]():"function"==typeof e.next?e:null}(e);if(!t)throw new Error("obliterator: target is not iterable nor a valid iterator.");return t},F=H,G=function(e,t){for(var n,i=arguments.length>1?t:1/0,o=i!==1/0?new Array(i):[],r=0,s=F(e);;){if(r===i)return o;if((n=s.next()).done)return r!==t&&(o.length=r),o;o[r++]=n.value}},B=function(e){function n(t){var n;return(n=e.call(this)||this).name="GraphError",n.message=t,n}return t(n,e),n}(r(Error)),D=function(e){function n(t){var i;return(i=e.call(this,t)||this).name="InvalidArgumentsGraphError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(s(i),n.prototype.constructor),i}return t(n,e),n}(B),V=function(e){function n(t){var i;return(i=e.call(this,t)||this).name="NotFoundGraphError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(s(i),n.prototype.constructor),i}return t(n,e),n}(B),W=function(e){function n(t){var i;return(i=e.call(this,t)||this).name="UsageGraphError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(s(i),n.prototype.constructor),i}return t(n,e),n}(B);function j(e,t){this.key=e,this.attributes=t,this.clear()}function U(e,t){this.key=e,this.attributes=t,this.clear()}function q(e,t){this.key=e,this.attributes=t,this.clear()}function z(e,t,n,i,o){this.key=t,this.attributes=o,this.undirected=e,this.source=n,this.target=i}function Y(e,t,n,i,o,r,s){var a,l,c,h;if(i=""+i,0===n){if(!(a=e._nodes.get(i)))throw new V("Graph.".concat(t,': could not find the "').concat(i,'" node in the graph.'));c=o,h=r}else if(3===n){if(o=""+o,!(l=e._edges.get(o)))throw new V("Graph.".concat(t,': could not find the "').concat(o,'" edge in the graph.'));var u=l.source.key,d=l.target.key;if(i===u)a=l.target;else{if(i!==d)throw new V("Graph.".concat(t,': the "').concat(i,'" node is not attached to the "').concat(o,'" edge (').concat(u,", ").concat(d,")."));a=l.source}c=r,h=s}else{if(!(l=e._edges.get(i)))throw new V("Graph.".concat(t,': could not find the "').concat(i,'" edge in the graph.'));a=1===n?l.source:l.target,c=o,h=r}return[a,c,h]}j.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}},U.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}},q.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}},z.prototype.attach=function(){var e="out",t="in";this.undirected&&(e=t="undirected");var n=this.source.key,i=this.target.key;this.source[e][i]=this,this.undirected&&n===i||(this.target[t][n]=this)},z.prototype.attachMulti=function(){var e="out",t="in",n=this.source.key,i=this.target.key;this.undirected&&(e=t="undirected");var o=this.source[e],r=o[i];if(void 0===r)return o[i]=this,void(this.undirected&&n===i||(this.target[t][n]=this));r.previous=this,this.next=r,o[i]=this,this.target[t][n]=this},z.prototype.detach=function(){var e=this.source.key,t=this.target.key,n="out",i="in";this.undirected&&(n=i="undirected"),delete this.source[n][t],delete this.target[i][e]},z.prototype.detachMulti=function(){var e=this.source.key,t=this.target.key,n="out",i="in";this.undirected&&(n=i="undirected"),void 0===this.previous?void 0===this.next?(delete this.source[n][t],delete this.target[i][e]):(this.next.previous=void 0,this.source[n][t]=this.next,this.target[i][e]=this.next):(this.previous.next=this.next,void 0!==this.next&&(this.next.previous=this.previous))};var K=[{name:function(e){return"get".concat(e,"Attribute")},attacher:function(e,t,n){e.prototype[t]=function(e,i,o){var r=Y(this,t,n,e,i,o),s=r[0],a=r[1];return s.attributes[a]}}},{name:function(e){return"get".concat(e,"Attributes")},attacher:function(e,t,n){e.prototype[t]=function(e,i){return Y(this,t,n,e,i)[0].attributes}}},{name:function(e){return"has".concat(e,"Attribute")},attacher:function(e,t,n){e.prototype[t]=function(e,i,o){var r=Y(this,t,n,e,i,o),s=r[0],a=r[1];return s.attributes.hasOwnProperty(a)}}},{name:function(e){return"set".concat(e,"Attribute")},attacher:function(e,t,n){e.prototype[t]=function(e,i,o,r){var s=Y(this,t,n,e,i,o,r),a=s[0],l=s[1],c=s[2];return a.attributes[l]=c,this.emit("nodeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:l}),this}}},{name:function(e){return"update".concat(e,"Attribute")},attacher:function(e,t,n){e.prototype[t]=function(e,i,o,r){var s=Y(this,t,n,e,i,o,r),a=s[0],l=s[1],c=s[2];if("function"!=typeof c)throw new D("Graph.".concat(t,": updater should be a function."));var h=a.attributes,u=c(h[l]);return h[l]=u,this.emit("nodeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:l}),this}}},{name:function(e){return"remove".concat(e,"Attribute")},attacher:function(e,t,n){e.prototype[t]=function(e,i,o){var r=Y(this,t,n,e,i,o),s=r[0],a=r[1];return delete s.attributes[a],this.emit("nodeAttributesUpdated",{key:s.key,type:"remove",attributes:s.attributes,name:a}),this}}},{name:function(e){return"replace".concat(e,"Attributes")},attacher:function(e,t,n){e.prototype[t]=function(e,i,o){var r=Y(this,t,n,e,i,o),s=r[0],a=r[1];if(!c(a))throw new D("Graph.".concat(t,": provided attributes are not a plain object."));return s.attributes=a,this.emit("nodeAttributesUpdated",{key:s.key,type:"replace",attributes:s.attributes}),this}}},{name:function(e){return"merge".concat(e,"Attributes")},attacher:function(e,t,n){e.prototype[t]=function(e,i,o){var r=Y(this,t,n,e,i,o),s=r[0],l=r[1];if(!c(l))throw new D("Graph.".concat(t,": provided attributes are not a plain object."));return a(s.attributes,l),this.emit("nodeAttributesUpdated",{key:s.key,type:"merge",attributes:s.attributes,data:l}),this}}},{name:function(e){return"update".concat(e,"Attributes")},attacher:function(e,t,n){e.prototype[t]=function(e,i,o){var r=Y(this,t,n,e,i,o),s=r[0],a=r[1];if("function"!=typeof a)throw new D("Graph.".concat(t,": provided updater is not a function."));return s.attributes=a(s.attributes),this.emit("nodeAttributesUpdated",{key:s.key,type:"update",attributes:s.attributes}),this}}}],Z=[{name:function(e){return"get".concat(e,"Attribute")},attacher:function(e,t,n){e.prototype[t]=function(e,i){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new W("Graph.".concat(t,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var r=""+e,s=""+i;if(i=arguments[2],!(o=l(this,r,s,n)))throw new V("Graph.".concat(t,': could not find an edge for the given path ("').concat(r,'" - "').concat(s,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(t,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(e=""+e,!(o=this._edges.get(e)))throw new V("Graph.".concat(t,': could not find the "').concat(e,'" edge in the graph.'))}return o.attributes[i]}}},{name:function(e){return"get".concat(e,"Attributes")},attacher:function(e,t,n){e.prototype[t]=function(e){var i;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>1){if(this.multi)throw new W("Graph.".concat(t,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var o=""+e,r=""+arguments[1];if(!(i=l(this,o,r,n)))throw new V("Graph.".concat(t,': could not find an edge for the given path ("').concat(o,'" - "').concat(r,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(t,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(e=""+e,!(i=this._edges.get(e)))throw new V("Graph.".concat(t,': could not find the "').concat(e,'" edge in the graph.'))}return i.attributes}}},{name:function(e){return"has".concat(e,"Attribute")},attacher:function(e,t,n){e.prototype[t]=function(e,i){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new W("Graph.".concat(t,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var r=""+e,s=""+i;if(i=arguments[2],!(o=l(this,r,s,n)))throw new V("Graph.".concat(t,': could not find an edge for the given path ("').concat(r,'" - "').concat(s,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(t,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(e=""+e,!(o=this._edges.get(e)))throw new V("Graph.".concat(t,': could not find the "').concat(e,'" edge in the graph.'))}return o.attributes.hasOwnProperty(i)}}},{name:function(e){return"set".concat(e,"Attribute")},attacher:function(e,t,n){e.prototype[t]=function(e,i,o){var r;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>3){if(this.multi)throw new W("Graph.".concat(t,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var s=""+e,a=""+i;if(i=arguments[2],o=arguments[3],!(r=l(this,s,a,n)))throw new V("Graph.".concat(t,': could not find an edge for the given path ("').concat(s,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(t,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(e=""+e,!(r=this._edges.get(e)))throw new V("Graph.".concat(t,': could not find the "').concat(e,'" edge in the graph.'))}return r.attributes[i]=o,this.emit("edgeAttributesUpdated",{key:r.key,type:"set",attributes:r.attributes,name:i}),this}}},{name:function(e){return"update".concat(e,"Attribute")},attacher:function(e,t,n){e.prototype[t]=function(e,i,o){var r;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>3){if(this.multi)throw new W("Graph.".concat(t,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var s=""+e,a=""+i;if(i=arguments[2],o=arguments[3],!(r=l(this,s,a,n)))throw new V("Graph.".concat(t,': could not find an edge for the given path ("').concat(s,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(t,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(e=""+e,!(r=this._edges.get(e)))throw new V("Graph.".concat(t,': could not find the "').concat(e,'" edge in the graph.'))}if("function"!=typeof o)throw new D("Graph.".concat(t,": updater should be a function."));return r.attributes[i]=o(r.attributes[i]),this.emit("edgeAttributesUpdated",{key:r.key,type:"set",attributes:r.attributes,name:i}),this}}},{name:function(e){return"remove".concat(e,"Attribute")},attacher:function(e,t,n){e.prototype[t]=function(e,i){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new W("Graph.".concat(t,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var r=""+e,s=""+i;if(i=arguments[2],!(o=l(this,r,s,n)))throw new V("Graph.".concat(t,': could not find an edge for the given path ("').concat(r,'" - "').concat(s,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(t,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(e=""+e,!(o=this._edges.get(e)))throw new V("Graph.".concat(t,': could not find the "').concat(e,'" edge in the graph.'))}return delete o.attributes[i],this.emit("edgeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:i}),this}}},{name:function(e){return"replace".concat(e,"Attributes")},attacher:function(e,t,n){e.prototype[t]=function(e,i){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new W("Graph.".concat(t,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var r=""+e,s=""+i;if(i=arguments[2],!(o=l(this,r,s,n)))throw new V("Graph.".concat(t,': could not find an edge for the given path ("').concat(r,'" - "').concat(s,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(t,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(e=""+e,!(o=this._edges.get(e)))throw new V("Graph.".concat(t,': could not find the "').concat(e,'" edge in the graph.'))}if(!c(i))throw new D("Graph.".concat(t,": provided attributes are not a plain object."));return o.attributes=i,this.emit("edgeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}},{name:function(e){return"merge".concat(e,"Attributes")},attacher:function(e,t,n){e.prototype[t]=function(e,i){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new W("Graph.".concat(t,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var r=""+e,s=""+i;if(i=arguments[2],!(o=l(this,r,s,n)))throw new V("Graph.".concat(t,': could not find an edge for the given path ("').concat(r,'" - "').concat(s,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(t,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(e=""+e,!(o=this._edges.get(e)))throw new V("Graph.".concat(t,': could not find the "').concat(e,'" edge in the graph.'))}if(!c(i))throw new D("Graph.".concat(t,": provided attributes are not a plain object."));return a(o.attributes,i),this.emit("edgeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:i}),this}}},{name:function(e){return"update".concat(e,"Attributes")},attacher:function(e,t,n){e.prototype[t]=function(e,i){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new W("Graph.".concat(t,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var r=""+e,s=""+i;if(i=arguments[2],!(o=l(this,r,s,n)))throw new V("Graph.".concat(t,': could not find an edge for the given path ("').concat(r,'" - "').concat(s,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(t,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(e=""+e,!(o=this._edges.get(e)))throw new V("Graph.".concat(t,': could not find the "').concat(e,'" edge in the graph.'))}if("function"!=typeof i)throw new D("Graph.".concat(t,": provided updater is not a function."));return o.attributes=i(o.attributes),this.emit("edgeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}}],X=N,J=H,Q=function(){var e=arguments,t=null,n=-1;return new X(function(){for(var i=null;;){if(null===t){if(++n>=e.length)return{done:!0};t=J(e[n])}if(!0!==(i=t.next()).done)break;t=null}return i})},ee=[{name:"edges",type:"mixed"},{name:"inEdges",type:"directed",direction:"in"},{name:"outEdges",type:"directed",direction:"out"},{name:"inboundEdges",type:"mixed",direction:"in"},{name:"outboundEdges",type:"mixed",direction:"out"},{name:"directedEdges",type:"directed"},{name:"undirectedEdges",type:"undirected"}];function te(e,t,n,i){var o=!1;for(var r in t)if(r!==i){var s=t[r];if(o=n(s.key,s.attributes,s.source.key,s.target.key,s.source.attributes,s.target.attributes,s.undirected),e&&o)return s.key}}function ne(e,t,n,i){var o,r,s,a=!1;for(var l in t)if(l!==i){o=t[l];do{if(r=o.source,s=o.target,a=n(o.key,o.attributes,r.key,s.key,r.attributes,s.attributes,o.undirected),e&&a)return o.key;o=o.next}while(void 0!==o)}}function ie(e,t){var n,i=Object.keys(e),o=i.length,r=0;return new N(function(){do{if(n)n=n.next;else{if(r>=o)return{done:!0};var s=i[r++];if(s===t){n=void 0;continue}n=e[s]}}while(!n);return{done:!1,value:{edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected}}})}function oe(e,t,n,i){var o=t[n];if(o){var r=o.source,s=o.target;return i(o.key,o.attributes,r.key,s.key,r.attributes,s.attributes,o.undirected)&&e?o.key:void 0}}function re(e,t,n,i){var o=t[n];if(o){var r=!1;do{if(r=i(o.key,o.attributes,o.source.key,o.target.key,o.source.attributes,o.target.attributes,o.undirected),e&&r)return o.key;o=o.next}while(void 0!==o)}}function se(e,t){var n=e[t];return void 0!==n.next?new N(function(){if(!n)return{done:!0};var e={edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected};return n=n.next,{done:!1,value:e}}):N.of({edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected})}function ae(e,t,n,i){if(0!==t.size)for(var o,r,s="mixed"!==n&&n!==t.type,a="undirected"===n,l=!1,c=t._edges.values();!0!==(o=c.next()).done;)if(r=o.value,!s||r.undirected===a){var h=r,u=h.key,d=h.attributes,p=h.source,m=h.target;if(l=i(u,d,p.key,m.key,p.attributes,m.attributes,r.undirected),e&&l)return u}}function le(e,t,n,i,o,r){var s,a=t?ne:te;if("undirected"!==n){if("out"!==i&&(s=a(e,o.in,r),e&&s))return s;if("in"!==i&&(s=a(e,o.out,r,i?void 0:o.key),e&&s))return s}if("directed"!==n&&(s=a(e,o.undirected,r),e&&s))return s}function ce(e,t,n,i,o,r,s){var a,l=n?re:oe;if("undirected"!==t){if(void 0!==o.in&&"out"!==i&&(a=l(e,o.in,r,s),e&&a))return a;if(void 0!==o.out&&"in"!==i&&(i||o.key!==r)&&(a=l(e,o.out,r,s),e&&a))return a}if("directed"!==t&&void 0!==o.undirected&&(a=l(e,o.undirected,r,s),e&&a))return a}var he=[{name:"neighbors",type:"mixed"},{name:"inNeighbors",type:"directed",direction:"in"},{name:"outNeighbors",type:"directed",direction:"out"},{name:"inboundNeighbors",type:"mixed",direction:"in"},{name:"outboundNeighbors",type:"mixed",direction:"out"},{name:"directedNeighbors",type:"directed"},{name:"undirectedNeighbors",type:"undirected"}];function ue(){this.A=null,this.B=null}function de(e,t,n,i,o){for(var r in i){var s=i[r],a=s.source,l=s.target,c=a===n?l:a;if(!t||!t.has(c.key)){var h=o(c.key,c.attributes);if(e&&h)return c.key}}}function pe(e,t,n,i,o){if("mixed"!==t){if("undirected"===t)return de(e,null,i,i.undirected,o);if("string"==typeof n)return de(e,null,i,i[n],o)}var r,s=new ue;if("undirected"!==t){if("out"!==n){if(r=de(e,null,i,i.in,o),e&&r)return r;s.wrap(i.in)}if("in"!==n){if(r=de(e,s,i,i.out,o),e&&r)return r;s.wrap(i.out)}}if("directed"!==t&&(r=de(e,s,i,i.undirected,o),e&&r))return r}function me(e,t,n){var i=Object.keys(n),o=i.length,r=0;return new N(function(){var s=null;do{if(r>=o)return e&&e.wrap(n),{done:!0};var a=n[i[r++]],l=a.source,c=a.target;s=l===t?c:l,e&&e.has(s.key)&&(s=null)}while(null===s);return{done:!1,value:{neighbor:s.key,attributes:s.attributes}}})}function ge(e,t,n,i,o){for(var r,s,a,l,c,h,u,d=i._nodes.values(),p=i.type;!0!==(r=d.next()).done;){var m=!1;if(s=r.value,"undirected"!==p)for(a in l=s.out){c=l[a];do{if(h=c.target,m=!0,u=o(s.key,h.key,s.attributes,h.attributes,c.key,c.attributes,c.undirected),e&&u)return c;c=c.next}while(c)}if("directed"!==p)for(a in l=s.undirected)if(!(t&&s.key>a)){c=l[a];do{if((h=c.target).key!==a&&(h=c.source),m=!0,u=o(s.key,h.key,s.attributes,h.attributes,c.key,c.attributes,c.undirected),e&&u)return c;c=c.next}while(c)}if(n&&!m&&(u=o(s.key,null,s.attributes,null,null,null,null),e&&u))return null}}function fe(e){if(!c(e))throw new D('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in e))throw new D("Graph.import: serialized node is missing its key.");if("attributes"in e&&(!c(e.attributes)||null===e.attributes))throw new D("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function ye(e){if(!c(e))throw new D('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in e))throw new D("Graph.import: serialized edge is missing its source.");if(!("target"in e))throw new D("Graph.import: serialized edge is missing its target.");if("attributes"in e&&(!c(e.attributes)||null===e.attributes))throw new D("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in e&&"boolean"!=typeof e.undirected)throw new D("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}ue.prototype.wrap=function(e){null===this.A?this.A=e:null===this.B&&(this.B=e)},ue.prototype.has=function(e){return null!==this.A&&e in this.A||null!==this.B&&e in this.B};var be,ve=(be=255&Math.floor(256*Math.random()),function(){return be++}),we=new Set(["directed","undirected","mixed"]),Ce=new Set(["domain","_events","_eventsCount","_maxListeners"]),Se={allowSelfLoops:!0,multi:!1,type:"mixed"};function Ae(e,t,n){var i=new e.NodeDataClass(t,n);return e._nodes.set(t,i),e.emit("nodeAdded",{key:t,attributes:n}),i}function xe(e,t,n,i,o,r,s,a){if(!i&&"undirected"===e.type)throw new W("Graph.".concat(t,": you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead."));if(i&&"directed"===e.type)throw new W("Graph.".concat(t,": you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead."));if(a&&!c(a))throw new D("Graph.".concat(t,': invalid attributes. Expecting an object but got "').concat(a,'"'));if(r=""+r,s=""+s,a=a||{},!e.allowSelfLoops&&r===s)throw new W("Graph.".concat(t,': source & target are the same ("').concat(r,"\"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false."));var l=e._nodes.get(r),h=e._nodes.get(s);if(!l)throw new V("Graph.".concat(t,': source node "').concat(r,'" not found.'));if(!h)throw new V("Graph.".concat(t,': target node "').concat(s,'" not found.'));var u={key:null,undirected:i,source:r,target:s,attributes:a};if(n)o=e._edgeKeyGenerator();else if(o=""+o,e._edges.has(o))throw new W("Graph.".concat(t,': the "').concat(o,'" edge already exists in the graph.'));if(!e.multi&&(i?void 0!==l.undirected[s]:void 0!==l.out[s]))throw new W("Graph.".concat(t,': an edge linking "').concat(r,'" to "').concat(s,"\" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option."));var d=new z(i,o,l,h,a);e._edges.set(o,d);var p=r===s;return i?(l.undirectedDegree++,h.undirectedDegree++,p&&(l.undirectedLoops++,e._undirectedSelfLoopCount++)):(l.outDegree++,h.inDegree++,p&&(l.directedLoops++,e._directedSelfLoopCount++)),e.multi?d.attachMulti():d.attach(),i?e._undirectedSize++:e._directedSize++,u.key=o,e.emit("edgeAdded",u),o}function Ee(e,t,n,i,o,r,s,l,h){if(!i&&"undirected"===e.type)throw new W("Graph.".concat(t,": you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead."));if(i&&"directed"===e.type)throw new W("Graph.".concat(t,": you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead."));if(l)if(h){if("function"!=typeof l)throw new D("Graph.".concat(t,': invalid updater function. Expecting a function but got "').concat(l,'"'))}else if(!c(l))throw new D("Graph.".concat(t,': invalid attributes. Expecting an object but got "').concat(l,'"'));var u;if(r=""+r,s=""+s,h&&(u=l,l=void 0),!e.allowSelfLoops&&r===s)throw new W("Graph.".concat(t,': source & target are the same ("').concat(r,"\"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false."));var d,p,m=e._nodes.get(r),g=e._nodes.get(s);if(!n&&(d=e._edges.get(o))){if(!(d.source.key===r&&d.target.key===s||i&&d.source.key===s&&d.target.key===r))throw new W("Graph.".concat(t,': inconsistency detected when attempting to merge the "').concat(o,'" edge with "').concat(r,'" source & "').concat(s,'" target vs. ("').concat(d.source.key,'", "').concat(d.target.key,'").'));p=d}if(p||e.multi||!m||(p=i?m.undirected[s]:m.out[s]),p){var f=[p.key,!1,!1,!1];if(h?!u:!l)return f;if(h){var y=p.attributes;p.attributes=u(y),e.emit("edgeAttributesUpdated",{type:"replace",key:p.key,attributes:p.attributes})}else a(p.attributes,l),e.emit("edgeAttributesUpdated",{type:"merge",key:p.key,attributes:p.attributes,data:l});return f}l=l||{},h&&u&&(l=u(l));var b={key:null,undirected:i,source:r,target:s,attributes:l};if(n)o=e._edgeKeyGenerator();else if(o=""+o,e._edges.has(o))throw new W("Graph.".concat(t,': the "').concat(o,'" edge already exists in the graph.'));var v=!1,w=!1;m||(m=Ae(e,r,{}),v=!0,r===s&&(g=m,w=!0)),g||(g=Ae(e,s,{}),w=!0),d=new z(i,o,m,g,l),e._edges.set(o,d);var C=r===s;return i?(m.undirectedDegree++,g.undirectedDegree++,C&&(m.undirectedLoops++,e._undirectedSelfLoopCount++)):(m.outDegree++,g.inDegree++,C&&(m.directedLoops++,e._directedSelfLoopCount++)),e.multi?d.attachMulti():d.attach(),i?e._undirectedSize++:e._directedSize++,b.key=o,e.emit("edgeAdded",b),[o,!0,v,w]}function Me(e,t){e._edges.delete(t.key);var n=t.source,i=t.target,o=t.attributes,r=t.undirected,s=n===i;r?(n.undirectedDegree--,i.undirectedDegree--,s&&(n.undirectedLoops--,e._undirectedSelfLoopCount--)):(n.outDegree--,i.inDegree--,s&&(n.directedLoops--,e._directedSelfLoopCount--)),e.multi?t.detachMulti():t.detach(),r?e._undirectedSize--:e._directedSize--,e.emit("edgeDropped",{key:t.key,attributes:o,source:n.key,target:i.key,undirected:r})}var Te=function(n){function i(e){var t;if(t=n.call(this)||this,"boolean"!=typeof(e=a({},Se,e)).multi)throw new D("Graph.constructor: invalid 'multi' option. Expecting a boolean but got \"".concat(e.multi,'".'));if(!we.has(e.type))throw new D('Graph.constructor: invalid \'type\' option. Should be one of "mixed", "directed" or "undirected" but got "'.concat(e.type,'".'));if("boolean"!=typeof e.allowSelfLoops)throw new D("Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got \"".concat(e.allowSelfLoops,'".'));var i="mixed"===e.type?j:"directed"===e.type?U:q;u(s(t),"NodeDataClass",i);var o="geid_"+ve()+"_",r=0;return u(s(t),"_attributes",{}),u(s(t),"_nodes",new Map),u(s(t),"_edges",new Map),u(s(t),"_directedSize",0),u(s(t),"_undirectedSize",0),u(s(t),"_directedSelfLoopCount",0),u(s(t),"_undirectedSelfLoopCount",0),u(s(t),"_edgeKeyGenerator",function(){var e;do{e=o+r++}while(t._edges.has(e));return e}),u(s(t),"_options",e),Ce.forEach(function(e){return u(s(t),e,t[e])}),d(s(t),"order",function(){return t._nodes.size}),d(s(t),"size",function(){return t._edges.size}),d(s(t),"directedSize",function(){return t._directedSize}),d(s(t),"undirectedSize",function(){return t._undirectedSize}),d(s(t),"selfLoopCount",function(){return t._directedSelfLoopCount+t._undirectedSelfLoopCount}),d(s(t),"directedSelfLoopCount",function(){return t._directedSelfLoopCount}),d(s(t),"undirectedSelfLoopCount",function(){return t._undirectedSelfLoopCount}),d(s(t),"multi",t._options.multi),d(s(t),"type",t._options.type),d(s(t),"allowSelfLoops",t._options.allowSelfLoops),d(s(t),"implementation",function(){return"graphology"}),t}t(i,n);var o=i.prototype;return o._resetInstanceCounters=function(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0},o.hasNode=function(e){return this._nodes.has(""+e)},o.hasDirectedEdge=function(e,t){if("undirected"===this.type)return!1;if(1===arguments.length){var n=""+e,i=this._edges.get(n);return!!i&&!i.undirected}if(2===arguments.length){e=""+e,t=""+t;var o=this._nodes.get(e);return!!o&&o.out.hasOwnProperty(t)}throw new D("Graph.hasDirectedEdge: invalid arity (".concat(arguments.length,", instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target."))},o.hasUndirectedEdge=function(e,t){if("directed"===this.type)return!1;if(1===arguments.length){var n=""+e,i=this._edges.get(n);return!!i&&i.undirected}if(2===arguments.length){e=""+e,t=""+t;var o=this._nodes.get(e);return!!o&&o.undirected.hasOwnProperty(t)}throw new D("Graph.hasDirectedEdge: invalid arity (".concat(arguments.length,", instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target."))},o.hasEdge=function(e,t){if(1===arguments.length){var n=""+e;return this._edges.has(n)}if(2===arguments.length){e=""+e,t=""+t;var i=this._nodes.get(e);return!!i&&(void 0!==i.out&&i.out.hasOwnProperty(t)||void 0!==i.undirected&&i.undirected.hasOwnProperty(t))}throw new D("Graph.hasEdge: invalid arity (".concat(arguments.length,", instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target."))},o.directedEdge=function(e,t){if("undirected"!==this.type){if(e=""+e,t=""+t,this.multi)throw new W("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");var n=this._nodes.get(e);if(!n)throw new V('Graph.directedEdge: could not find the "'.concat(e,'" source node in the graph.'));if(!this._nodes.has(t))throw new V('Graph.directedEdge: could not find the "'.concat(t,'" target node in the graph.'));var i=n.out&&n.out[t]||void 0;return i?i.key:void 0}},o.undirectedEdge=function(e,t){if("directed"!==this.type){if(e=""+e,t=""+t,this.multi)throw new W("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");var n=this._nodes.get(e);if(!n)throw new V('Graph.undirectedEdge: could not find the "'.concat(e,'" source node in the graph.'));if(!this._nodes.has(t))throw new V('Graph.undirectedEdge: could not find the "'.concat(t,'" target node in the graph.'));var i=n.undirected&&n.undirected[t]||void 0;return i?i.key:void 0}},o.edge=function(e,t){if(this.multi)throw new W("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");e=""+e,t=""+t;var n=this._nodes.get(e);if(!n)throw new V('Graph.edge: could not find the "'.concat(e,'" source node in the graph.'));if(!this._nodes.has(t))throw new V('Graph.edge: could not find the "'.concat(t,'" target node in the graph.'));var i=n.out&&n.out[t]||n.undirected&&n.undirected[t]||void 0;if(i)return i.key},o.areDirectedNeighbors=function(e,t){e=""+e,t=""+t;var n=this._nodes.get(e);if(!n)throw new V('Graph.areDirectedNeighbors: could not find the "'.concat(e,'" node in the graph.'));return"undirected"!==this.type&&(t in n.in||t in n.out)},o.areOutNeighbors=function(e,t){e=""+e,t=""+t;var n=this._nodes.get(e);if(!n)throw new V('Graph.areOutNeighbors: could not find the "'.concat(e,'" node in the graph.'));return"undirected"!==this.type&&t in n.out},o.areInNeighbors=function(e,t){e=""+e,t=""+t;var n=this._nodes.get(e);if(!n)throw new V('Graph.areInNeighbors: could not find the "'.concat(e,'" node in the graph.'));return"undirected"!==this.type&&t in n.in},o.areUndirectedNeighbors=function(e,t){e=""+e,t=""+t;var n=this._nodes.get(e);if(!n)throw new V('Graph.areUndirectedNeighbors: could not find the "'.concat(e,'" node in the graph.'));return"directed"!==this.type&&t in n.undirected},o.areNeighbors=function(e,t){e=""+e,t=""+t;var n=this._nodes.get(e);if(!n)throw new V('Graph.areNeighbors: could not find the "'.concat(e,'" node in the graph.'));return"undirected"!==this.type&&(t in n.in||t in n.out)||"directed"!==this.type&&t in n.undirected},o.areInboundNeighbors=function(e,t){e=""+e,t=""+t;var n=this._nodes.get(e);if(!n)throw new V('Graph.areInboundNeighbors: could not find the "'.concat(e,'" node in the graph.'));return"undirected"!==this.type&&t in n.in||"directed"!==this.type&&t in n.undirected},o.areOutboundNeighbors=function(e,t){e=""+e,t=""+t;var n=this._nodes.get(e);if(!n)throw new V('Graph.areOutboundNeighbors: could not find the "'.concat(e,'" node in the graph.'));return"undirected"!==this.type&&t in n.out||"directed"!==this.type&&t in n.undirected},o.inDegree=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new V('Graph.inDegree: could not find the "'.concat(e,'" node in the graph.'));return"undirected"===this.type?0:t.inDegree},o.outDegree=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new V('Graph.outDegree: could not find the "'.concat(e,'" node in the graph.'));return"undirected"===this.type?0:t.outDegree},o.directedDegree=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new V('Graph.directedDegree: could not find the "'.concat(e,'" node in the graph.'));return"undirected"===this.type?0:t.inDegree+t.outDegree},o.undirectedDegree=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new V('Graph.undirectedDegree: could not find the "'.concat(e,'" node in the graph.'));return"directed"===this.type?0:t.undirectedDegree},o.inboundDegree=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new V('Graph.inboundDegree: could not find the "'.concat(e,'" node in the graph.'));var n=0;return"directed"!==this.type&&(n+=t.undirectedDegree),"undirected"!==this.type&&(n+=t.inDegree),n},o.outboundDegree=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new V('Graph.outboundDegree: could not find the "'.concat(e,'" node in the graph.'));var n=0;return"directed"!==this.type&&(n+=t.undirectedDegree),"undirected"!==this.type&&(n+=t.outDegree),n},o.degree=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new V('Graph.degree: could not find the "'.concat(e,'" node in the graph.'));var n=0;return"directed"!==this.type&&(n+=t.undirectedDegree),"undirected"!==this.type&&(n+=t.inDegree+t.outDegree),n},o.inDegreeWithoutSelfLoops=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new V('Graph.inDegreeWithoutSelfLoops: could not find the "'.concat(e,'" node in the graph.'));return"undirected"===this.type?0:t.inDegree-t.directedLoops},o.outDegreeWithoutSelfLoops=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new V('Graph.outDegreeWithoutSelfLoops: could not find the "'.concat(e,'" node in the graph.'));return"undirected"===this.type?0:t.outDegree-t.directedLoops},o.directedDegreeWithoutSelfLoops=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new V('Graph.directedDegreeWithoutSelfLoops: could not find the "'.concat(e,'" node in the graph.'));return"undirected"===this.type?0:t.inDegree+t.outDegree-2*t.directedLoops},o.undirectedDegreeWithoutSelfLoops=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new V('Graph.undirectedDegreeWithoutSelfLoops: could not find the "'.concat(e,'" node in the graph.'));return"directed"===this.type?0:t.undirectedDegree-2*t.undirectedLoops},o.inboundDegreeWithoutSelfLoops=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new V('Graph.inboundDegreeWithoutSelfLoops: could not find the "'.concat(e,'" node in the graph.'));var n=0,i=0;return"directed"!==this.type&&(n+=t.undirectedDegree,i+=2*t.undirectedLoops),"undirected"!==this.type&&(n+=t.inDegree,i+=t.directedLoops),n-i},o.outboundDegreeWithoutSelfLoops=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new V('Graph.outboundDegreeWithoutSelfLoops: could not find the "'.concat(e,'" node in the graph.'));var n=0,i=0;return"directed"!==this.type&&(n+=t.undirectedDegree,i+=2*t.undirectedLoops),"undirected"!==this.type&&(n+=t.outDegree,i+=t.directedLoops),n-i},o.degreeWithoutSelfLoops=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new V('Graph.degreeWithoutSelfLoops: could not find the "'.concat(e,'" node in the graph.'));var n=0,i=0;return"directed"!==this.type&&(n+=t.undirectedDegree,i+=2*t.undirectedLoops),"undirected"!==this.type&&(n+=t.inDegree+t.outDegree,i+=2*t.directedLoops),n-i},o.source=function(e){e=""+e;var t=this._edges.get(e);if(!t)throw new V('Graph.source: could not find the "'.concat(e,'" edge in the graph.'));return t.source.key},o.target=function(e){e=""+e;var t=this._edges.get(e);if(!t)throw new V('Graph.target: could not find the "'.concat(e,'" edge in the graph.'));return t.target.key},o.extremities=function(e){e=""+e;var t=this._edges.get(e);if(!t)throw new V('Graph.extremities: could not find the "'.concat(e,'" edge in the graph.'));return[t.source.key,t.target.key]},o.opposite=function(e,t){e=""+e,t=""+t;var n=this._edges.get(t);if(!n)throw new V('Graph.opposite: could not find the "'.concat(t,'" edge in the graph.'));var i=n.source.key,o=n.target.key;if(e===i)return o;if(e===o)return i;throw new V('Graph.opposite: the "'.concat(e,'" node is not attached to the "').concat(t,'" edge (').concat(i,", ").concat(o,")."))},o.hasExtremity=function(e,t){e=""+e,t=""+t;var n=this._edges.get(e);if(!n)throw new V('Graph.hasExtremity: could not find the "'.concat(e,'" edge in the graph.'));return n.source.key===t||n.target.key===t},o.isUndirected=function(e){e=""+e;var t=this._edges.get(e);if(!t)throw new V('Graph.isUndirected: could not find the "'.concat(e,'" edge in the graph.'));return t.undirected},o.isDirected=function(e){e=""+e;var t=this._edges.get(e);if(!t)throw new V('Graph.isDirected: could not find the "'.concat(e,'" edge in the graph.'));return!t.undirected},o.isSelfLoop=function(e){e=""+e;var t=this._edges.get(e);if(!t)throw new V('Graph.isSelfLoop: could not find the "'.concat(e,'" edge in the graph.'));return t.source===t.target},o.addNode=function(e,t){var n=function(e,t,n){if(n&&!c(n))throw new D('Graph.addNode: invalid attributes. Expecting an object but got "'.concat(n,'"'));if(t=""+t,n=n||{},e._nodes.has(t))throw new W('Graph.addNode: the "'.concat(t,'" node already exist in the graph.'));var i=new e.NodeDataClass(t,n);return e._nodes.set(t,i),e.emit("nodeAdded",{key:t,attributes:n}),i}(this,e,t);return n.key},o.mergeNode=function(e,t){if(t&&!c(t))throw new D('Graph.mergeNode: invalid attributes. Expecting an object but got "'.concat(t,'"'));e=""+e,t=t||{};var n=this._nodes.get(e);return n?(t&&(a(n.attributes,t),this.emit("nodeAttributesUpdated",{type:"merge",key:e,attributes:n.attributes,data:t})),[e,!1]):(n=new this.NodeDataClass(e,t),this._nodes.set(e,n),this.emit("nodeAdded",{key:e,attributes:t}),[e,!0])},o.updateNode=function(e,t){if(t&&"function"!=typeof t)throw new D('Graph.updateNode: invalid updater function. Expecting a function but got "'.concat(t,'"'));e=""+e;var n=this._nodes.get(e);if(n){if(t){var i=n.attributes;n.attributes=t(i),this.emit("nodeAttributesUpdated",{type:"replace",key:e,attributes:n.attributes})}return[e,!1]}var o=t?t({}):{};return n=new this.NodeDataClass(e,o),this._nodes.set(e,n),this.emit("nodeAdded",{key:e,attributes:o}),[e,!0]},o.dropNode=function(e){e=""+e;var t,n=this._nodes.get(e);if(!n)throw new V('Graph.dropNode: could not find the "'.concat(e,'" node in the graph.'));if("undirected"!==this.type){for(var i in n.out){t=n.out[i];do{Me(this,t),t=t.next}while(t)}for(var o in n.in){t=n.in[o];do{Me(this,t),t=t.next}while(t)}}if("directed"!==this.type)for(var r in n.undirected){t=n.undirected[r];do{Me(this,t),t=t.next}while(t)}this._nodes.delete(e),this.emit("nodeDropped",{key:e,attributes:n.attributes})},o.dropEdge=function(e){var t;if(arguments.length>1){var n=""+arguments[0],i=""+arguments[1];if(!(t=l(this,n,i,this.type)))throw new V('Graph.dropEdge: could not find the "'.concat(n,'" -> "').concat(i,'" edge in the graph.'))}else if(e=""+e,!(t=this._edges.get(e)))throw new V('Graph.dropEdge: could not find the "'.concat(e,'" edge in the graph.'));return Me(this,t),this},o.dropDirectedEdge=function(e,t){if(arguments.length<2)throw new W("Graph.dropDirectedEdge: it does not make sense to try and drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new W("Graph.dropDirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");var n=l(this,e=""+e,t=""+t,"directed");if(!n)throw new V('Graph.dropDirectedEdge: could not find a "'.concat(e,'" -> "').concat(t,'" edge in the graph.'));return Me(this,n),this},o.dropUndirectedEdge=function(e,t){if(arguments.length<2)throw new W("Graph.dropUndirectedEdge: it does not make sense to drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new W("Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");var n=l(this,e,t,"undirected");if(!n)throw new V('Graph.dropUndirectedEdge: could not find a "'.concat(e,'" -> "').concat(t,'" edge in the graph.'));return Me(this,n),this},o.clear=function(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")},o.clearEdges=function(){for(var e,t=this._nodes.values();!0!==(e=t.next()).done;)e.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")},o.getAttribute=function(e){return this._attributes[e]},o.getAttributes=function(){return this._attributes},o.hasAttribute=function(e){return this._attributes.hasOwnProperty(e)},o.setAttribute=function(e,t){return this._attributes[e]=t,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this},o.updateAttribute=function(e,t){if("function"!=typeof t)throw new D("Graph.updateAttribute: updater should be a function.");var n=this._attributes[e];return this._attributes[e]=t(n),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this},o.removeAttribute=function(e){return delete this._attributes[e],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:e}),this},o.replaceAttributes=function(e){if(!c(e))throw new D("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=e,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this},o.mergeAttributes=function(e){if(!c(e))throw new D("Graph.mergeAttributes: provided attributes are not a plain object.");return a(this._attributes,e),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:e}),this},o.updateAttributes=function(e){if("function"!=typeof e)throw new D("Graph.updateAttributes: provided updater is not a function.");return this._attributes=e(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this},o.updateEachNodeAttributes=function(e,t){if("function"!=typeof e)throw new D("Graph.updateEachNodeAttributes: expecting an updater function.");if(t&&!p(t))throw new D("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");for(var n,i,o=this._nodes.values();!0!==(n=o.next()).done;)(i=n.value).attributes=e(i.key,i.attributes);this.emit("eachNodeAttributesUpdated",{hints:t||null})},o.updateEachEdgeAttributes=function(e,t){if("function"!=typeof e)throw new D("Graph.updateEachEdgeAttributes: expecting an updater function.");if(t&&!p(t))throw new D("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");for(var n,i,o,r,s=this._edges.values();!0!==(n=s.next()).done;)o=(i=n.value).source,r=i.target,i.attributes=e(i.key,i.attributes,o.key,r.key,o.attributes,r.attributes,i.undirected);this.emit("eachEdgeAttributesUpdated",{hints:t||null})},o.forEachAdjacencyEntry=function(e){if("function"!=typeof e)throw new D("Graph.forEachAdjacencyEntry: expecting a callback.");ge(!1,!1,!1,this,e)},o.forEachAdjacencyEntryWithOrphans=function(e){if("function"!=typeof e)throw new D("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");ge(!1,!1,!0,this,e)},o.forEachAssymetricAdjacencyEntry=function(e){if("function"!=typeof e)throw new D("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");ge(!1,!0,!1,this,e)},o.forEachAssymetricAdjacencyEntryWithOrphans=function(e){if("function"!=typeof e)throw new D("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");ge(!1,!0,!0,this,e)},o.nodes=function(){return"function"==typeof Array.from?Array.from(this._nodes.keys()):G(this._nodes.keys(),this._nodes.size)},o.forEachNode=function(e){if("function"!=typeof e)throw new D("Graph.forEachNode: expecting a callback.");for(var t,n,i=this._nodes.values();!0!==(t=i.next()).done;)e((n=t.value).key,n.attributes)},o.findNode=function(e){if("function"!=typeof e)throw new D("Graph.findNode: expecting a callback.");for(var t,n,i=this._nodes.values();!0!==(t=i.next()).done;)if(e((n=t.value).key,n.attributes))return n.key},o.mapNodes=function(e){if("function"!=typeof e)throw new D("Graph.mapNode: expecting a callback.");for(var t,n,i=this._nodes.values(),o=new Array(this.order),r=0;!0!==(t=i.next()).done;)n=t.value,o[r++]=e(n.key,n.attributes);return o},o.someNode=function(e){if("function"!=typeof e)throw new D("Graph.someNode: expecting a callback.");for(var t,n,i=this._nodes.values();!0!==(t=i.next()).done;)if(e((n=t.value).key,n.attributes))return!0;return!1},o.everyNode=function(e){if("function"!=typeof e)throw new D("Graph.everyNode: expecting a callback.");for(var t,n,i=this._nodes.values();!0!==(t=i.next()).done;)if(!e((n=t.value).key,n.attributes))return!1;return!0},o.filterNodes=function(e){if("function"!=typeof e)throw new D("Graph.filterNodes: expecting a callback.");for(var t,n,i=this._nodes.values(),o=[];!0!==(t=i.next()).done;)e((n=t.value).key,n.attributes)&&o.push(n.key);return o},o.reduceNodes=function(e,t){if("function"!=typeof e)throw new D("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new D("Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.");for(var n,i,o=t,r=this._nodes.values();!0!==(n=r.next()).done;)o=e(o,(i=n.value).key,i.attributes);return o},o.nodeEntries=function(){var e=this._nodes.values();return new N(function(){var t=e.next();if(t.done)return t;var n=t.value;return{value:{node:n.key,attributes:n.attributes},done:!1}})},o.export=function(){var e=this,t=new Array(this._nodes.size),n=0;this._nodes.forEach(function(e,i){t[n++]=function(e,t){var n={key:e};return h(t.attributes)||(n.attributes=a({},t.attributes)),n}(i,e)});var i=new Array(this._edges.size);return n=0,this._edges.forEach(function(t,o){i[n++]=function(e,t,n){var i={key:t,source:n.source.key,target:n.target.key};return h(n.attributes)||(i.attributes=a({},n.attributes)),"mixed"===e&&n.undirected&&(i.undirected=!0),i}(e.type,o,t)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:t,edges:i}},o.import=function(e){var t,n,o,r,s,a=this,l=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(e instanceof i)return e.forEachNode(function(e,t){l?a.mergeNode(e,t):a.addNode(e,t)}),e.forEachEdge(function(e,t,n,i,o,r,s){l?s?a.mergeUndirectedEdgeWithKey(e,n,i,t):a.mergeDirectedEdgeWithKey(e,n,i,t):s?a.addUndirectedEdgeWithKey(e,n,i,t):a.addDirectedEdgeWithKey(e,n,i,t)}),this;if(!c(e))throw new D("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(e.attributes){if(!c(e.attributes))throw new D("Graph.import: invalid attributes. Expecting a plain object.");l?this.mergeAttributes(e.attributes):this.replaceAttributes(e.attributes)}if(e.nodes){if(o=e.nodes,!Array.isArray(o))throw new D("Graph.import: invalid nodes. Expecting an array.");for(t=0,n=o.length;t<n;t++){fe(r=o[t]);var h=r,u=h.key,d=h.attributes;l?this.mergeNode(u,d):this.addNode(u,d)}}if(e.edges){var p=!1;if("undirected"===this.type&&(p=!0),o=e.edges,!Array.isArray(o))throw new D("Graph.import: invalid edges. Expecting an array.");for(t=0,n=o.length;t<n;t++){ye(s=o[t]);var m=s,g=m.source,f=m.target,y=m.attributes,b=m.undirected,v=void 0===b?p:b;"key"in s?(l?v?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:v?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey).call(this,s.key,g,f,y):(l?v?this.mergeUndirectedEdge:this.mergeDirectedEdge:v?this.addUndirectedEdge:this.addDirectedEdge).call(this,g,f,y)}}return this},o.nullCopy=function(e){var t=new i(a({},this._options,e));return t.replaceAttributes(a({},this.getAttributes())),t},o.emptyCopy=function(e){var t=this.nullCopy(e);return this._nodes.forEach(function(e,n){var i=a({},e.attributes);e=new t.NodeDataClass(n,i),t._nodes.set(n,e)}),t},o.copy=function(e){if("string"==typeof(e=e||{}).type&&e.type!==this.type&&"mixed"!==e.type)throw new W('Graph.copy: cannot create an incompatible copy from "'.concat(this.type,'" type to "').concat(e.type,'" because this would mean losing information about the current graph.'));if("boolean"==typeof e.multi&&e.multi!==this.multi&&!0!==e.multi)throw new W("Graph.copy: cannot create an incompatible copy by downgrading a multi graph to a simple one because this would mean losing information about the current graph.");if("boolean"==typeof e.allowSelfLoops&&e.allowSelfLoops!==this.allowSelfLoops&&!0!==e.allowSelfLoops)throw new W("Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.");for(var t,n,i=this.emptyCopy(e),o=this._edges.values();!0!==(t=o.next()).done;)xe(i,"copy",!1,(n=t.value).undirected,n.key,n.source.key,n.target.key,a({},n.attributes));return i},o.toJSON=function(){return this.export()},o.toString=function(){return"[object Graph]"},o.inspect=function(){var t=this,n={};this._nodes.forEach(function(e,t){n[t]=e.attributes});var i={},o={};this._edges.forEach(function(e,n){var r,s=e.undirected?"--":"->",a="",l=e.source.key,c=e.target.key;e.undirected&&l>c&&(r=l,l=c,c=r);var h="(".concat(l,")").concat(s,"(").concat(c,")");n.startsWith("geid_")?t.multi&&(void 0===o[h]?o[h]=0:o[h]++,a+="".concat(o[h],". ")):a+="[".concat(n,"]: "),i[a+=h]=e.attributes});var r={};for(var s in this)this.hasOwnProperty(s)&&!Ce.has(s)&&"function"!=typeof this[s]&&"symbol"!==e(s)&&(r[s]=this[s]);return r.attributes=this._attributes,r.nodes=n,r.edges=i,u(r,"constructor",this.constructor),r},i}(g.exports.EventEmitter);"undefined"!=typeof Symbol&&(Te.prototype[Symbol.for("nodejs.util.inspect.custom")]=Te.prototype.inspect),[{name:function(e){return"".concat(e,"Edge")},generateKey:!0},{name:function(e){return"".concat(e,"DirectedEdge")},generateKey:!0,type:"directed"},{name:function(e){return"".concat(e,"UndirectedEdge")},generateKey:!0,type:"undirected"},{name:function(e){return"".concat(e,"EdgeWithKey")}},{name:function(e){return"".concat(e,"DirectedEdgeWithKey")},type:"directed"},{name:function(e){return"".concat(e,"UndirectedEdgeWithKey")},type:"undirected"}].forEach(function(e){["add","merge","update"].forEach(function(t){var n=e.name(t),i="add"===t?xe:Ee;e.generateKey?Te.prototype[n]=function(o,r,s){return i(this,n,!0,"undirected"===(e.type||this.type),null,o,r,s,"update"===t)}:Te.prototype[n]=function(o,r,s,a){return i(this,n,!1,"undirected"===(e.type||this.type),o,r,s,a,"update"===t)}})}),function(e){K.forEach(function(t){var n=t.name,i=t.attacher;i(e,n("Node"),0),i(e,n("Source"),1),i(e,n("Target"),2),i(e,n("Opposite"),3)})}(Te),function(e){Z.forEach(function(t){var n=t.name,i=t.attacher;i(e,n("Edge"),"mixed"),i(e,n("DirectedEdge"),"directed"),i(e,n("UndirectedEdge"),"undirected")})}(Te),function(e){ee.forEach(function(t){!function(e,t){var n=t.name,i=t.type,o=t.direction;e.prototype[n]=function(e,t){if("mixed"!==i&&"mixed"!==this.type&&i!==this.type)return[];if(!arguments.length)return function(e,t){if(0===e.size)return[];if("mixed"===t||t===e.type)return"function"==typeof Array.from?Array.from(e._edges.keys()):G(e._edges.keys(),e._edges.size);for(var n,i,o="undirected"===t?e.undirectedSize:e.directedSize,r=new Array(o),s="undirected"===t,a=e._edges.values(),l=0;!0!==(n=a.next()).done;)(i=n.value).undirected===s&&(r[l++]=i.key);return r}(this,i);if(1===arguments.length){e=""+e;var r=this._nodes.get(e);if(void 0===r)throw new V("Graph.".concat(n,': could not find the "').concat(e,'" node in the graph.'));return function(e,t,n,i){var o=[];return le(!1,e,t,n,i,function(e){o.push(e)}),o}(this.multi,"mixed"===i?this.type:i,o,r)}if(2===arguments.length){e=""+e,t=""+t;var s=this._nodes.get(e);if(!s)throw new V("Graph.".concat(n,': could not find the "').concat(e,'" source node in the graph.'));if(!this._nodes.has(t))throw new V("Graph.".concat(n,': could not find the "').concat(t,'" target node in the graph.'));return function(e,t,n,i,o){var r=[];return ce(!1,e,t,n,i,o,function(e){r.push(e)}),r}(i,this.multi,o,s,t)}throw new D("Graph.".concat(n,": too many arguments (expecting 0, 1 or 2 and got ").concat(arguments.length,")."))}}(e,t),function(e,t){var n=t.name,i=t.type,o=t.direction,r="forEach"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[r]=function(e,t,n){if("mixed"===i||"mixed"===this.type||i===this.type){if(1===arguments.length)return ae(!1,this,i,n=e);if(2===arguments.length){e=""+e,n=t;var s=this._nodes.get(e);if(void 0===s)throw new V("Graph.".concat(r,': could not find the "').concat(e,'" node in the graph.'));return le(!1,this.multi,"mixed"===i?this.type:i,o,s,n)}if(3===arguments.length){e=""+e,t=""+t;var a=this._nodes.get(e);if(!a)throw new V("Graph.".concat(r,': could not find the "').concat(e,'" source node in the graph.'));if(!this._nodes.has(t))throw new V("Graph.".concat(r,': could not find the "').concat(t,'" target node in the graph.'));return ce(!1,i,this.multi,o,a,t,n)}throw new D("Graph.".concat(r,": too many arguments (expecting 1, 2 or 3 and got ").concat(arguments.length,")."))}};var s="map"+n[0].toUpperCase()+n.slice(1);e.prototype[s]=function(){var e,t=Array.prototype.slice.call(arguments),n=t.pop();if(0===t.length){var o=0;"directed"!==i&&(o+=this.undirectedSize),"undirected"!==i&&(o+=this.directedSize),e=new Array(o);var s=0;t.push(function(t,i,o,r,a,l,c){e[s++]=n(t,i,o,r,a,l,c)})}else e=[],t.push(function(t,i,o,r,s,a,l){e.push(n(t,i,o,r,s,a,l))});return this[r].apply(this,t),e};var a="filter"+n[0].toUpperCase()+n.slice(1);e.prototype[a]=function(){var e=Array.prototype.slice.call(arguments),t=e.pop(),n=[];return e.push(function(e,i,o,r,s,a,l){t(e,i,o,r,s,a,l)&&n.push(e)}),this[r].apply(this,e),n};var l="reduce"+n[0].toUpperCase()+n.slice(1);e.prototype[l]=function(){var e,t,n=Array.prototype.slice.call(arguments);if(n.length<2||n.length>4)throw new D("Graph.".concat(l,": invalid number of arguments (expecting 2, 3 or 4 and got ").concat(n.length,")."));if("function"==typeof n[n.length-1]&&"function"!=typeof n[n.length-2])throw new D("Graph.".concat(l,": missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array."));2===n.length?(e=n[0],t=n[1],n=[]):3===n.length?(e=n[1],t=n[2],n=[n[0]]):4===n.length&&(e=n[2],t=n[3],n=[n[0],n[1]]);var i=t;return n.push(function(t,n,o,r,s,a,l){i=e(i,t,n,o,r,s,a,l)}),this[r].apply(this,n),i}}(e,t),function(e,t){var n=t.name,i=t.type,o=t.direction,r="find"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[r]=function(e,t,n){if("mixed"!==i&&"mixed"!==this.type&&i!==this.type)return!1;if(1===arguments.length)return ae(!0,this,i,n=e);if(2===arguments.length){e=""+e,n=t;var s=this._nodes.get(e);if(void 0===s)throw new V("Graph.".concat(r,': could not find the "').concat(e,'" node in the graph.'));return le(!0,this.multi,"mixed"===i?this.type:i,o,s,n)}if(3===arguments.length){e=""+e,t=""+t;var a=this._nodes.get(e);if(!a)throw new V("Graph.".concat(r,': could not find the "').concat(e,'" source node in the graph.'));if(!this._nodes.has(t))throw new V("Graph.".concat(r,': could not find the "').concat(t,'" target node in the graph.'));return ce(!0,i,this.multi,o,a,t,n)}throw new D("Graph.".concat(r,": too many arguments (expecting 1, 2 or 3 and got ").concat(arguments.length,")."))};var s="some"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[s]=function(){var e=Array.prototype.slice.call(arguments),t=e.pop();return e.push(function(e,n,i,o,r,s,a){return t(e,n,i,o,r,s,a)}),!!this[r].apply(this,e)};var a="every"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[a]=function(){var e=Array.prototype.slice.call(arguments),t=e.pop();return e.push(function(e,n,i,o,r,s,a){return!t(e,n,i,o,r,s,a)}),!this[r].apply(this,e)}}(e,t),function(e,t){var n=t.name,i=t.type,o=t.direction,r=n.slice(0,-1)+"Entries";e.prototype[r]=function(e,t){if("mixed"!==i&&"mixed"!==this.type&&i!==this.type)return N.empty();if(!arguments.length)return function(e,t){if(0===e.size)return N.empty();var n="mixed"!==t&&t!==e.type,i="undirected"===t,o=e._edges.values();return new N(function(){for(var e,t;;){if((e=o.next()).done)return e;if(t=e.value,!n||t.undirected===i)break}return{value:{edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected},done:!1}})}(this,i);if(1===arguments.length){e=""+e;var n=this._nodes.get(e);if(!n)throw new V("Graph.".concat(r,': could not find the "').concat(e,'" node in the graph.'));return function(e,t,n){var i=N.empty();return"undirected"!==e&&("out"!==t&&void 0!==n.in&&(i=Q(i,ie(n.in))),"in"!==t&&void 0!==n.out&&(i=Q(i,ie(n.out,t?void 0:n.key)))),"directed"!==e&&void 0!==n.undirected&&(i=Q(i,ie(n.undirected))),i}(i,o,n)}if(2===arguments.length){e=""+e,t=""+t;var s=this._nodes.get(e);if(!s)throw new V("Graph.".concat(r,': could not find the "').concat(e,'" source node in the graph.'));if(!this._nodes.has(t))throw new V("Graph.".concat(r,': could not find the "').concat(t,'" target node in the graph.'));return function(e,t,n,i){var o=N.empty();return"undirected"!==e&&(void 0!==n.in&&"out"!==t&&i in n.in&&(o=Q(o,se(n.in,i))),void 0!==n.out&&"in"!==t&&i in n.out&&(t||n.key!==i)&&(o=Q(o,se(n.out,i)))),"directed"!==e&&void 0!==n.undirected&&i in n.undirected&&(o=Q(o,se(n.undirected,i))),o}(i,o,s,t)}throw new D("Graph.".concat(r,": too many arguments (expecting 0, 1 or 2 and got ").concat(arguments.length,")."))}}(e,t)})}(Te),function(e){he.forEach(function(t){(function(e,t){var n=t.name,i=t.type,o=t.direction;e.prototype[n]=function(e){if("mixed"!==i&&"mixed"!==this.type&&i!==this.type)return[];e=""+e;var t=this._nodes.get(e);if(void 0===t)throw new V("Graph.".concat(n,': could not find the "').concat(e,'" node in the graph.'));return function(e,t,n){if("mixed"!==e){if("undirected"===e)return Object.keys(n.undirected);if("string"==typeof t)return Object.keys(n[t])}var i=[];return pe(!1,e,t,n,function(e){i.push(e)}),i}("mixed"===i?this.type:i,o,t)}})(e,t),function(e,t){var n=t.name,i=t.type,o=t.direction,r="forEach"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[r]=function(e,t){if("mixed"===i||"mixed"===this.type||i===this.type){e=""+e;var n=this._nodes.get(e);if(void 0===n)throw new V("Graph.".concat(r,': could not find the "').concat(e,'" node in the graph.'));pe(!1,"mixed"===i?this.type:i,o,n,t)}};var s="map"+n[0].toUpperCase()+n.slice(1);e.prototype[s]=function(e,t){var n=[];return this[r](e,function(e,i){n.push(t(e,i))}),n};var a="filter"+n[0].toUpperCase()+n.slice(1);e.prototype[a]=function(e,t){var n=[];return this[r](e,function(e,i){t(e,i)&&n.push(e)}),n};var l="reduce"+n[0].toUpperCase()+n.slice(1);e.prototype[l]=function(e,t,n){if(arguments.length<3)throw new D("Graph.".concat(l,": missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array."));var i=n;return this[r](e,function(e,n){i=t(i,e,n)}),i}}(e,t),function(e,t){var n=t.name,i=t.type,o=t.direction,r=n[0].toUpperCase()+n.slice(1,-1),s="find"+r;e.prototype[s]=function(e,t){if("mixed"===i||"mixed"===this.type||i===this.type){e=""+e;var n=this._nodes.get(e);if(void 0===n)throw new V("Graph.".concat(s,': could not find the "').concat(e,'" node in the graph.'));return pe(!0,"mixed"===i?this.type:i,o,n,t)}};var a="some"+r;e.prototype[a]=function(e,t){return!!this[s](e,t)};var l="every"+r;e.prototype[l]=function(e,t){return!this[s](e,function(e,n){return!t(e,n)})}}(e,t),function(e,t){var n=t.name,i=t.type,o=t.direction,r=n.slice(0,-1)+"Entries";e.prototype[r]=function(e){if("mixed"!==i&&"mixed"!==this.type&&i!==this.type)return N.empty();e=""+e;var t=this._nodes.get(e);if(void 0===t)throw new V("Graph.".concat(r,': could not find the "').concat(e,'" node in the graph.'));return function(e,t,n){if("mixed"!==e){if("undirected"===e)return me(null,n,n.undirected);if("string"==typeof t)return me(null,n,n[t])}var i=N.empty(),o=new ue;return"undirected"!==e&&("out"!==t&&(i=Q(i,me(o,n,n.in))),"in"!==t&&(i=Q(i,me(o,n,n.out)))),"directed"!==e&&(i=Q(i,me(o,n,n.undirected))),i}("mixed"===i?this.type:i,o,t)}}(e,t)})}(Te);var _e=function(e){function n(t){var n=a({type:"directed"},t);if("multi"in n&&!1!==n.multi)throw new D("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if("directed"!==n.type)throw new D('DirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return e.call(this,n)||this}return t(n,e),n}(Te),Ie=function(e){function n(t){var n=a({type:"undirected"},t);if("multi"in n&&!1!==n.multi)throw new D("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if("undirected"!==n.type)throw new D('UndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return e.call(this,n)||this}return t(n,e),n}(Te),Le=function(e){function n(t){var n=a({multi:!0},t);if("multi"in n&&!0!==n.multi)throw new D("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");return e.call(this,n)||this}return t(n,e),n}(Te),Ne=function(e){function n(t){var n=a({type:"directed",multi:!0},t);if("multi"in n&&!0!==n.multi)throw new D("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if("directed"!==n.type)throw new D('MultiDirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return e.call(this,n)||this}return t(n,e),n}(Te),Pe=function(e){function n(t){var n=a({type:"undirected",multi:!0},t);if("multi"in n&&!0!==n.multi)throw new D("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if("undirected"!==n.type)throw new D('MultiUndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return e.call(this,n)||this}return t(n,e),n}(Te);function Re(e){e.from=function(t,n){var i=a({},t.options,n),o=new e(i);return o.import(t),o}}return Re(Te),Re(_e),Re(Ie),Re(Le),Re(Ne),Re(Pe),Te.Graph=Te,Te.DirectedGraph=_e,Te.UndirectedGraph=Ie,Te.MultiGraph=Le,Te.MultiDirectedGraph=Ne,Te.MultiUndirectedGraph=Pe,Te.InvalidArgumentsGraphError=D,Te.NotFoundGraphError=V,Te.UsageGraphError=W,Te}()},944:(e,t)=>{"use strict";t.Vb=void 0,t.Vb=function(e,t,n){var i=function(e,t,n){if(0===e.length||0===t.length)return 0;if(n&&!n.caseSensitive&&(e=e.toUpperCase(),t=t.toUpperCase()),e===t)return 1;for(var i=0,o=e.length,r=t.length,s=Math.floor(Math.max(o,r)/2)-1,a=new Array(o),l=new Array(r),c=0;c<o;c++)for(var h=Math.max(0,c-s);h<=Math.min(r,c+s+1);h++)if(!a[c]&&!l[h]&&e[c]===t[h]){++i,a[c]=l[h]=!0;break}if(0===i)return 0;var u=0,d=0;for(c=0;c<o;c++)if(a[c]){for(;!l[d];)d++;e.charAt(c)!==t.charAt(d++)&&u++}return(i/o+i/r+(i-(u/=2))/i)/3}(e,t,n),o=0;if(i>.7){for(var r=Math.min(e.length,t.length),s=0;e[s]===t[s]&&s<4&&s<r;)++o,s++;i+=.1*o*(1-i)}return i}},966:(e,t,n)=>{"use strict";n.d(t,{V:()=>s,l:()=>a});var i=n(4328),o=n(6082),r=n(2020);function s(e,t,n=[],o=[],s=!0){const l=r._package.seqHelper,[c,h]=a(e,t,l,n,o);return s&&!c&&i.shell.warning(h),c}function a(e,t,n,r=[],s=[]){let a=!0,l="";if(e.semType!==o.SEMTYPE.MACROMOLECULE)i.shell.warning(t+" analysis is allowed for Macromolecules semantic type"),a=!1;else{const i=n.getSeqHandler(e),o=i.notation;if(r.length>0&&!r.some(e=>o.toUpperCase()==e.toUpperCase()))l=`${t} + ' analysis is allowed for Macromolecules with notation ${0==r.length?"any notation":`notation${r.length>1?"s":""} ${r.map(e=>`"${e}"`).join(", ")} `}.`,a=!1;else if(!i.isHelm()){const e=i.alphabet;s.length>0&&!s.some(t=>e.toUpperCase()==t.toUpperCase())&&(l=`${t} + ' analysis is allowed for Macromolecules with alphabet ${0==s.length?"any alphabet":`alphabet${s.length>1?"s":""} ${s.map(e=>`"${e}"`).join(", ")}.`}.`,a=!1)}}return[a,l]}},1093:(e,t,n)=>{"use strict";n(7362);class i{}i.SemType="Nucleotides",i.SemTypeMultipleAlignment="NucleotidesMultipleAlignment",i.Names={A:"Adenine",C:"Cytosine",G:"Guanine",T:"Thymine",U:"Uracil"}},1113:e=>{"use strict";e.exports=function(e,t){if(t.styleSheet)t.styleSheet.cssText=e;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(e))}}},1163:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:{message({keyword:e,schemaCode:t}){const n="maxItems"===e?"more":"fewer";return i.str`must NOT have ${n} than ${t} items`},params:({schemaCode:e})=>i._`{limit: ${e}}`},code(e){const{keyword:t,data:n,schemaCode:o}=e,r="maxItems"===t?i.operators.GT:i.operators.LT;e.fail$data(i._`${n}.length ${r} ${o}`)}};t.default=o},1239:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o=n(4227),r={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:{message:({params:e})=>i.str`must match "${e.ifClause}" schema`,params:({params:e})=>i._`{failingKeyword: ${e.ifClause}}`},code(e){const{gen:t,parentSchema:n,it:r}=e;void 0===n.then&&void 0===n.else&&(0,o.checkStrictMode)(r,'"if" without "then" and "else" is ignored');const a=s(r,"then"),l=s(r,"else");if(!a&&!l)return;const c=t.let("valid",!0),h=t.name("_valid");if(function(){const t=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},h);e.mergeEvaluated(t)}(),e.reset(),a&&l){const n=t.let("ifClause");e.setParams({ifClause:n}),t.if(h,u("then",n),u("else",n))}else a?t.if(h,u("then")):t.if((0,i.not)(h),u("else"));function u(n,o){return()=>{const r=e.subschema({keyword:n},h);t.assign(c,h),e.mergeValidEvaluated(r,c),o?t.assign(o,i._`${n}`):e.setParams({ifClause:n})}}e.pass(c,()=>e.error(!0))}};function s(e,t){const n=e.schema[t];return void 0!==n&&!(0,o.alwaysValidSchema)(e,n)}t.default=r},1354:e=>{"use strict";e.exports=function(e){var t=e[1],n=e[3];if(!n)return t;if("function"==typeof btoa){var i=btoa(unescape(encodeURIComponent(JSON.stringify(n)))),o="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(i),r="/*# ".concat(o," */");return[t].concat([r]).join("\n")}return[t].join("\n")}},1520:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.regexpCode=t.getEsmExportName=t.getProperty=t.safeStringify=t.stringify=t.strConcat=t.addCodeArg=t.str=t._=t.nil=t._Code=t.Name=t.IDENTIFIER=t._CodeOrName=void 0;class n{}t._CodeOrName=n,t.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class i extends n{constructor(e){if(super(),!t.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}t.Name=i;class o extends n{constructor(e){super(),this._items="string"==typeof e?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const e=this._items[0];return""===e||'""'===e}get str(){var e;return null!==(e=this._str)&&void 0!==e?e:this._str=this._items.reduce((e,t)=>`${e}${t}`,"")}get names(){var e;return null!==(e=this._names)&&void 0!==e?e:this._names=this._items.reduce((e,t)=>(t instanceof i&&(e[t.str]=(e[t.str]||0)+1),e),{})}}function r(e,...t){const n=[e[0]];let i=0;for(;i<t.length;)l(n,t[i]),n.push(e[++i]);return new o(n)}t._Code=o,t.nil=new o(""),t._=r;const s=new o("+");function a(e,...t){const n=[h(e[0])];let i=0;for(;i<t.length;)n.push(s),l(n,t[i]),n.push(s,h(e[++i]));return function(e){let t=1;for(;t<e.length-1;){if(e[t]===s){const n=c(e[t-1],e[t+1]);if(void 0!==n){e.splice(t-1,3,n);continue}e[t++]="+"}t++}}(n),new o(n)}function l(e,t){var n;t instanceof o?e.push(...t._items):t instanceof i?e.push(t):e.push("number"==typeof(n=t)||"boolean"==typeof n||null===n?n:h(Array.isArray(n)?n.join(","):n))}function c(e,t){if('""'===t)return e;if('""'===e)return t;if("string"==typeof e){if(t instanceof i||'"'!==e[e.length-1])return;return"string"!=typeof t?`${e.slice(0,-1)}${t}"`:'"'===t[0]?e.slice(0,-1)+t.slice(1):void 0}return"string"!=typeof t||'"'!==t[0]||e instanceof i?void 0:`"${e}${t.slice(1)}`}function h(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}t.str=a,t.addCodeArg=l,t.strConcat=function(e,t){return t.emptyStr()?e:e.emptyStr()?t:a`${e}${t}`},t.stringify=function(e){return new o(h(e))},t.safeStringify=h,t.getProperty=function(e){return"string"==typeof e&&t.IDENTIFIER.test(e)?new o(`.${e}`):r`[${e}]`},t.getEsmExportName=function(e){if("string"==typeof e&&t.IDENTIFIER.test(e))return new o(`${e}`);throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)},t.regexpCode=function(e){return new o(e.toString())}},1619:(e,t,n)=>{"use strict";n.d(t,{D:()=>T});var i=n(4328),o=n(6082),r=n(7389),s=n(8070),a=n(2003),l=n(608),c=n(8152),h=n(966),u=n(4139),d=n(5072),p=n.n(d),m=n(7825),g=n.n(m),f=n(7659),y=n.n(f),b=n(5056),v=n.n(b),w=n(540),C=n.n(w),S=n(1113),A=n.n(S),x=n(6369),E={};E.styleTagTransform=A(),E.setAttributes=v(),E.insert=y().bind(null,"head"),E.domAPI=g(),E.insertStyleElement=C(),p()(x.A,E),x.A&&x.A.locals&&x.A.locals;var M=n(2020);async function T(e,t){return new Promise(async(n,a)=>{e.clustersCol??=null,e.pepsea??={},e.pepsea.method??=u.HX.pepsea.method,e.pepsea.gapOpen??=u.HX.pepsea.gapOpen,e.pepsea.gapExtend??=u.HX.pepsea.gapExtend;const h=e.col?.dataFrame??i.shell.t;if(!h){const e="Multiple Sequence Alignment analysis requires a dataset with a macromolecule column.";return void a(new l.Ap(r.divText(e)))}const d=e.col??h.columns.bySemType(o.SEMTYPE.MACROMOLECULE);if(null==d){const e="Multiple Sequence Alignment analysis requires a dataset with a macromolecule column.";return void a(new l.Ap(r.divText(e)))}const p=r.input.choice("Method",{value:e.pepsea.method,items:c.ZY});p.setTooltip("Alignment method");const m=r.input.float("Terminal gap",{value:e?.kalign?.terminalGap});m.setTooltip("Penalty for opening a gap at the beginning or end of the sequence");const g=r.p(`Kalign version: ${u.b9}`,"kalign-version"),f=r.input.float("Gap open",{value:e.pepsea.gapOpen});f.setTooltip("Gap opening penalty at group-to-group alignment");const y=r.input.float("Gap extend",{value:e.pepsea.gapExtend});y.setTooltip("Gap extension penalty to skip the alignment");const b=r.input.bool("Selected Rows Only",{value:!1}),v=r.inputs([f,y,m]),w=r.button("Alignment parameters",()=>{v.hidden=!v.hidden,[f,y,m].forEach(e=>{e.root.style.removeProperty("max-width"),e.captionLabel.style.removeProperty("max-width")})},"Adjust alignment parameters such as penalties for opening and extending gaps");w.classList.add("msa-params-button"),v.hidden=!0,w.prepend(r.icons.settings(()=>null));const C=[p.root.style],S=[m.root.style,g.style];let A,x=d;const E=r.input.column("Sequence",{table:h,value:d,onValueChanged:async e=>{if(!e||e.semType!==o.SEMTYPE.MACROMOLECULE)return L.disabled=!0,await(0,s.cb)(0),void(E.value=x);x=e,L.disabled=!1,A=await I(E.value,h,t,C,S,p,M,f,y,m,b)},filter:e=>e.semType===o.SEMTYPE.MACROMOLECULE});E.setTooltip("Sequences column to use for alignment");const M=r.input.column("Clusters",{table:h,value:e.clustersCol});M.nullable=!0;const T=r.dialog("MSA").add(E).add(M).add(p).add(v).add(w).add(b).add(g).onOK(async()=>{await _(E,h,A,n,a)}),L=T.getButton("OK");if(E.fireChanged(),e.col)return A=await I(e.col,h,t,C,S,p,M,f,y,m,b),void await _(E,h,A,n,a);T.show()})}async function _(e,t,n,r,s){let a=null;const l=o.TaskBarProgressIndicator.create("Analyze for MSA ...");try{if(e.fireChanged(),e.value.semType!==o.SEMTYPE.MACROMOLECULE)throw new Error("Chosen column has to be of Macromolecule semantic type");if(null==n)throw new Error("Invalid column format");if(a=await n(),null==a)return s("PepSeA container has not started");t.columns.add(a),await i.data.detectSemanticTypes(t),r(a)}catch(e){s(e)}finally{l.close()}}async function I(e,t,n,r,s,d,p,m,g,f,y){try{if(e.semType!==o.SEMTYPE.MACROMOLECULE)return;const i=t.columns.getUnusedName(`msa(${e.name})`);if((0,h.l)(e,e.name,n,[a.Hi.FASTA,a.Hi.SEPARATOR],[a.YI.DNA,a.YI.RNA,a.YI.PT])[0]){L(r,s,"kalign"),m.value=null,g.value=null,f.value=null;const o=n.getSeqHandler(e),c=o.isFasta()?e:o.convert(a.Hi.FASTA);return async()=>await(0,l.eE)(t,c,!1,i,p.value,void 0,void 0,void 0,y.value)}if((0,h.l)(e,e.name,n,[a.Hi.HELM],[])[0])return L(r,s,"pepsea"),m.value??=u.HX.pepsea.gapOpen,g.value??=u.HX.pepsea.gapExtend,async()=>(0,c.GD)(t,e,i,d.value,m.value,g.value,p.value,void 0,y.value);if((0,h.l)(e,e.name,n,[a.Hi.SEPARATOR],[a.YI.UN])[0]){const o=n.getSeqHandler(e).convert(a.Hi.HELM);return L(r,s,"pepsea"),m.value??=u.HX.pepsea.gapOpen,g.value??=u.HX.pepsea.gapExtend,async()=>(0,c.GD)(t,o,i,d.value,m.value,g.value,p.value,void 0,y.value)}return m.value=null,g.value=null,f.value=null,void L(r,s,"kalign")}catch(e){const t=e instanceof Error?e.message:e.toString();i.shell.error(t),M._package.logger.error(t)}}function L(e,t,n){if("kalign"===n){for(const t of e)t.display="none";for(const e of t)e.removeProperty("display")}else{for(const e of t)e.display="none";for(const t of e)t.removeProperty("display")}}},1678:e=>{"use strict";e.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/schema","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/core":true,"https://json-schema.org/draft/2020-12/vocab/applicator":true,"https://json-schema.org/draft/2020-12/vocab/unevaluated":true,"https://json-schema.org/draft/2020-12/vocab/validation":true,"https://json-schema.org/draft/2020-12/vocab/meta-data":true,"https://json-schema.org/draft/2020-12/vocab/format-annotation":true,"https://json-schema.org/draft/2020-12/vocab/content":true},"$dynamicAnchor":"meta","title":"Core and Validation specifications meta-schema","allOf":[{"$ref":"meta/core"},{"$ref":"meta/applicator"},{"$ref":"meta/unevaluated"},{"$ref":"meta/validation"},{"$ref":"meta/meta-data"},{"$ref":"meta/format-annotation"},{"$ref":"meta/content"}],"type":["object","boolean"],"$comment":"This meta-schema also defines keywords that have appeared in previous drafts in order to prevent incompatible extensions as they remain in common use.","properties":{"definitions":{"$comment":"\\"definitions\\" has been replaced by \\"$defs\\".","type":"object","additionalProperties":{"$dynamicRef":"#meta"},"deprecated":true,"default":{}},"dependencies":{"$comment":"\\"dependencies\\" has been split and replaced by \\"dependentSchemas\\" and \\"dependentRequired\\" in order to serve their differing semantics.","type":"object","additionalProperties":{"anyOf":[{"$dynamicRef":"#meta"},{"$ref":"meta/validation#/$defs/stringArray"}]},"deprecated":true,"default":{}},"$recursiveAnchor":{"$comment":"\\"$recursiveAnchor\\" has been replaced by \\"$dynamicAnchor\\".","$ref":"meta/core#/$defs/anchorString","deprecated":true},"$recursiveRef":{"$comment":"\\"$recursiveRef\\" has been replaced by \\"$dynamicRef\\".","$ref":"meta/core#/$defs/uriReferenceString","deprecated":true}}}')},1687:(e,t,n)=>{"use strict";n.d(t,{_i:()=>x});var i=n(7389),o=n(6082),r=n(4328),s=n(1991),a=n.n(s),l=n(1858),c=n(2003),h=n(8070),u=n(7602),d=n(4954),p=n(4574),m=n(1757),g=n.n(m),f=n(9124),y=n(9192),b=n(4870),v=n(2020);class w extends p.O{seqHelper;emptyProps=new p.n("",void 0,v._package.logger);helmEditor;_filterPanel=i.div("",{style:{cursor:"pointer"}});logger;static viewerCounter=-1;viewerId=++w.viewerCounter;viewerToLog(){return`HelmBioFilter<${this.viewerId}>`}get type(){return"HelmBioFilter"}constructor(e){super(),this.seqHelper=e,this.logger=v._package.logger}viewSubs=[];async detach(){await super.detach();for(const e of this.viewSubs)e.unsubscribe()}async attach(){this.viewerToLog();try{const e=await(0,f.b2)();let t,n;this.helmEditor=e.createHelmWebEditor(),this.logger.warning("TEST: HelmBioFilter.init().sync() waitForElementInDom waiting..."),await i.tools.waitForElementInDom(this._filterPanel),this.logger.warning("TEST: HelmBioFilter.init().sync() waitForElementInDom ready"),this.updateFilterPanel(),this.viewSubs.push((0,l.fromEvent)(this._filterPanel,"click").subscribe(()=>{t=i.div(),n=e.createWebEditorApp(t,this.props.substructure),i.dialog({showHeader:!1,showFooter:!0}).add(t).onOK(()=>{try{const e=n.canvas.getHelm(!0).replace(/<\/span>/g,"").replace(/<span style='background:#bbf;'>/g,"");this.props=new p.n(e,void 0,v._package.logger)}catch(e){this.logger.error(e)}finally{g()(t).empty(),t=null,n=null}}).onCancel(()=>{g()(t).empty(),t=null,n=null}).show({modal:!0,fullScreen:!0})})),this.viewSubs.push(i.onSizeChanged(this._filterPanel).subscribe(e=>{try{if(n){const e=n.canvas.getHelm(!0).replace(/<\/span>/g,"").replace(/<span style='background:#bbf;'>/g,"");this.updateFilterPanel(e)}}catch(e){const[t,n]=(0,y.AP)(e);this.logger.error(t,void 0,n)}}))}catch(e){const[t,n]=(0,y.AP)(e),o=this._filterPanel;o.innerText="error",o.classList.add("d4-error"),i.tooltip.bind(o,t)}}applyProps(){this.helmEditor&&this.updateFilterPanel(this.props.substructure)}get filterPanel(){return this._filterPanel}updateFilterPanel(e){if(!this.helmEditor)throw new Error("helmEditor is not created, the filter is not in dom yet");const t=this._filterPanel.parentElement.clientWidth<100?100:this._filterPanel.parentElement.clientWidth,n=t/2;if(e)(0,b.Ku)(this._filterPanel,this.helmEditor.host),this.helmEditor.editor.setHelm(e),this.helmEditor.resizeEditor(t,n);else{const e=i.divText("Click to edit","helm-substructure-filter");(0,b.Ku)(this._filterPanel,e)}}async substructureSearch(e){const t=`${this.viewerToLog()}.substructureSearch( column = <${e.name}> )`;v._package.logger.debug(`${t}, start`);try{return await(0,h.cb)(10),await(0,d.if)(this.props.substructure,e,this.seqHelper)}finally{v._package.logger.debug(`${t}, end`)}}}const C="bio-substructure-filter";class S{props;filterId;dataFrameId;columnName;bitset;constructor(e,t,n,i,o){this.props=e,this.filterId=t,this.dataFrameId=n,this.columnName=i,this.bitset=o}}class A extends p.n{separator;constructor(e,t,n){super(e,!1,n),this.separator=t,this.readOnly=!0}}class x extends o.Filter{seqHelper;logger;bioFilter=null;bitset=null;loader;notation=void 0;filterSyncer;get calculating(){return"initial"==this.loader.style.display}set calculating(e){this.loader.style.display=e?"initial":"none"}get filterSummary(){return this.bioFilter.filterSummary}get isFiltering(){return super.isFiltering&&(this.bioFilter?.isFiltering??!1)}get isReadyToApplyFilter(){return!this.calculating&&null!=this.bitset}get debounceTime(){if(null==this.column)return 1e3;const e=this.column.length;return e<500?0:e>1e4?1e3:Math.floor((e-500)/9500*1e3)}constructor(e,t){super(),this.seqHelper=e,this.logger=t,this.root=i.divV([]),this.loader=i.loader(),this.calculating=!1,this.filterSyncer=new u.g(this.logger)}static filterCounter=-1;filterId=++x.filterCounter;filterToLog(){return`BioSubstructureFilter<${this.filterId}>`}viewSubs=[];attach(e){const t=super.attach.bind(this),n=`${this.filterToLog()}.attach()`;this.filterSyncer.sync(n,async()=>{t(e),this.column||(this.columnName?this.column=this.dataFrame.getCol(this.columnName):this.column=e.columns.bySemType(o.SEMTYPE.MACROMOLECULE)),this.seqHelper.getSeqHandler(this.column),this.columnName??=this.column?.name,this.notation??=this.column?.meta.units,this.bioFilter=this.notation===c.Hi.FASTA?new E:this.notation===c.Hi.SEPARATOR?new M(this.column.getTag(c.gp.separator)):new w(this.seqHelper),this.root.appendChild(this.bioFilter.filterPanel),this.root.appendChild(this.loader),await this.bioFilter.attach(),this.viewSubs.push(o.debounce(this.bioFilter.onChanged,this.debounceTime).subscribe(this.bioFilterOnChangedDebounced.bind(this))),this.viewSubs.push(r.events.onResetFilterRequest.subscribe(this.grokEventsOnResetFilterRequest.bind(this))),this.viewSubs.push(r.events.onCustomEvent(C).subscribe(this.filterOnSync.bind(this)))})}detach(){const e=super.detach.bind(this),t=`${this.filterToLog()}.detach()`;this.filterSyncer.sync(t,async()=>{for(const e of this.viewSubs)e.unsubscribe();this.viewSubs=[],e(),this.bioFilter&&this.bioFilter.detach(),this.bioFilter=null})}filterOnSync(e){e.filterId!==this.filterId&&e.dataFrameId===this.dataFrame.id&&e.columnName===this.columnName&&(this.bioFilter.props=e.props)}applyFilter(){const e=`${this.filterToLog()}.applyFilter()`;this.logger.debug(`${e}, IN`),this.bitset&&!this.isDetached&&this.dataFrame?.filter.and(this.bitset)}saveState(){const e=`${this.filterToLog()}.saveState()`,t=super.saveState();return this.logger.debug(`${e}, super.state = ${JSON.stringify(t)}`),t.props=this.bioFilter.saveProps(),t}applyState(e){const t=`${this.filterToLog()}.applyState()`;super.applyState(e),this.filterSyncer.sync(t,async()=>{e.props&&this.bioFilter&&(this.bioFilter.props=o.toJs(e.props??{}))})}fireFilterSync(){const e=`${this.filterToLog()}.fireFilterSync()`;this.logger.debug(`${e}, bioFilter = ${this.bioFilter?this.bioFilter.constructor.name:"null"}`+(this.bioFilter?`, props = ${JSON.stringify(this.bioFilter.saveProps())}`:"")),r.events.fireCustomEvent(C,new S(this.bioFilter.props,this.filterId,this.dataFrame.id,this.columnName,this.bitset))}bioFilterOnChangedDebounced(){if(!this.dataFrame)return;const e=`${this.filterToLog()}.bioFilterOnChangedDebounced()`;if(this.logger.debug(`${e}, start, isFiltering = ${this.isFiltering}, props = ${JSON.stringify(this.bioFilter.saveProps())}`),!this.isFiltering)return this.bitset=null,void this.dataFrame.rows.requestFilter();a()(this.dataFrame.rows.filters).has(`${this.columnName}: ${this.filterSummary}`)||this.filterSyncer.sync(e,async()=>{this.calculating=!0;try{this.logger.debug(`${e}, before substructureSearch`),this.bitset=await(this.bioFilter?.substructureSearch(this.column)),this.logger.debug(`${e}, after substructureSearch`),this.calculating=!1,this.fireFilterSync(),this.dataFrame?.rows.requestFilter()}finally{this.calculating=!1,this.logger.debug(`${e}, end`)}})}grokEventsOnResetFilterRequest(){const e=`${this.filterToLog()}.grokEventsOnResetFilterRequest()`;this.logger.debug(`${e}`),this.bioFilter?.resetFilter()}_onRendered=new l.Subject;get onRendered(){return this._onRendered}invalidate(e){const t=`${this.filterToLog()}.invalidate(${e?` <- ${e} `:""})`;this.filterSyncer.sync(t,async()=>{this._onRendered.next()})}async awaitRendered(e=1e4){const t=`awaitRendered( ${e} )`,n=`${this.filterToLog()}.${t}`;await(0,h.cb)(10),await(0,h.PE)(this.onRendered,()=>{this.logger.debug(`${n}, _onRendered event caught`)},()=>{this.invalidate(t)},e,`${n} timeout`);const i=this.filterSyncer.resetErrors();if(i.length>0)throw i[0]}}class E extends p.O{emptyProps=new p.n("",void 0,v._package.logger);substructureInput;get type(){return"FastaBioFilter"}constructor(){super(),this.substructureInput=i.input.string("",{value:"",onValueChanged:e=>{window.setTimeout(()=>{this.props=new p.n(e,void 0,v._package.logger),this._propsChanging||this.onChanged.next()},0)},placeholder:"Substructure"})}applyProps(){this.substructureInput.value!==this.props.substructure&&(this.substructureInput.value=this.props.substructure)}get filterPanel(){return this.substructureInput.root}get isFiltering(){return""!==this.substructureInput.value}async substructureSearch(e){return(0,d.nI)(this.props.substructure,e)}async attach(){}async detach(){await super.detach()}}class M extends p.O{emptyProps=new A("",void 0,v._package.logger);substructureInput;separatorInput;colSeparator="";get type(){return"SeparatorBioFilter"}constructor(e){super(),this.substructureInput=i.input.string("",{value:"",onValueChanged:e=>{this.props=new A(e,this.props.separator,v._package.logger),setTimeout(()=>{this._propsChanging||this.onChanged.next()})},placeholder:"Substructure"}),this.separatorInput=i.input.string("",{value:this.colSeparator=e,onValueChanged:e=>{const t=e||"";this.props=new A(this.props.substructure,t,v._package.logger),setTimeout(()=>{this._propsChanging||this.onChanged.next()})},placeholder:"Separator"})}applyProps(){this.substructureInput.value!==this.props.substructure&&(this.substructureInput.value=this.props.substructure);const e=this.props.separator??this.colSeparator;this.separatorInput.value!==e&&(this.separatorInput.value=e)}get filterSummary(){return this.props.separator?this.props.separator:this.colSeparator,`${this.props.substructure}, {sep}`}get isFiltering(){return""!==this.props.substructure}resetFilter(){this.props=new A("",void 0,v._package.logger)}get filterPanel(){return i.divV([this.substructureInput.root,this.separatorInput.root])}get substructure(){return this.separatorInput.value&&this.separatorInput.value!==this.colSeparator?this.substructureInput.value.replaceAll(this.separatorInput.value,this.colSeparator):this.substructureInput.value}set substructure(e){this.substructureInput.value=e}async substructureSearch(e){return(0,d.nI)(this.substructure,e,this.colSeparator)}async attach(){}async detach(){await super.detach()}}},1736:e=>{e.exports=function(e){return null!==e&&"object"==typeof e&&"function"==typeof e.addUndirectedEdgeWithKey&&"function"==typeof e.dropNode&&"boolean"==typeof e.multi}},1757:e=>{"use strict";e.exports=$},1782:(e,t)=>{t.assign=function(e){e=e||{};var t,n,i,o=Array.prototype.slice.call(arguments).slice(1);for(t=0,i=o.length;t<i;t++)if(o[t])for(n in o[t])e[n]=o[t][n];return e},t.validateSettings=function(e){return"linLogMode"in e&&"boolean"!=typeof e.linLogMode?{message:"the `linLogMode` setting should be a boolean."}:"outboundAttractionDistribution"in e&&"boolean"!=typeof e.outboundAttractionDistribution?{message:"the `outboundAttractionDistribution` setting should be a boolean."}:"adjustSizes"in e&&"boolean"!=typeof e.adjustSizes?{message:"the `adjustSizes` setting should be a boolean."}:"edgeWeightInfluence"in e&&"number"!=typeof e.edgeWeightInfluence?{message:"the `edgeWeightInfluence` setting should be a number."}:!("scalingRatio"in e)||"number"==typeof e.scalingRatio&&e.scalingRatio>=0?"strongGravityMode"in e&&"boolean"!=typeof e.strongGravityMode?{message:"the `strongGravityMode` setting should be a boolean."}:!("gravity"in e)||"number"==typeof e.gravity&&e.gravity>=0?"slowDown"in e&&!("number"==typeof e.slowDown||e.slowDown>=0)?{message:"the `slowDown` setting should be a number >= 0."}:"barnesHutOptimize"in e&&"boolean"!=typeof e.barnesHutOptimize?{message:"the `barnesHutOptimize` setting should be a boolean."}:!("barnesHutTheta"in e)||"number"==typeof e.barnesHutTheta&&e.barnesHutTheta>=0?null:{message:"the `barnesHutTheta` setting should be a number >= 0."}:{message:"the `gravity` setting should be a number >= 0."}:{message:"the `scalingRatio` setting should be a number >= 0."}},t.graphToByteArrays=function(e,t){var n,i=e.order,o=e.size,r={},s=new Float32Array(10*i),a=new Float32Array(3*o);return n=0,e.forEachNode(function(e,t){r[e]=n,s[n]=t.x,s[n+1]=t.y,s[n+2]=0,s[n+3]=0,s[n+4]=0,s[n+5]=0,s[n+6]=1,s[n+7]=1,s[n+8]=t.size||1,s[n+9]=t.fixed?1:0,n+=10}),n=0,e.forEachEdge(function(e,i,o,l,c,h,u){var d=r[o],p=r[l],m=t(e,i,o,l,c,h,u);s[d+6]+=m,s[p+6]+=m,a[n]=d,a[n+1]=p,a[n+2]=m,n+=3}),{nodes:s,edges:a}},t.assignLayoutChanges=function(e,t,n){var i=0;e.updateEachNodeAttributes(function(e,o){return o.x=t[i],o.y=t[i+1],i+=10,n?n(e,o):o})},t.readGraphPositions=function(e,t){var n=0;e.forEachNode(function(e,i){t[n]=i.x,t[n+1]=i.y,n+=10})},t.collectLayoutChanges=function(e,t,n){for(var i=e.nodes(),o={},r=0,s=0,a=t.length;r<a;r+=10){if(n){var l=Object.assign({},e.getNodeAttributes(i[s]));l.x=t[r],l.y=t[r+1],l=n(i[s],l),o[i[s]]={x:l.x,y:l.y}}else o[i[s]]={x:t[r],y:t[r+1]};s++}return o},t.createWorker=function(e){var t=window.URL||window.webkitURL,n=e.toString(),i=t.createObjectURL(new Blob(["("+n+").call(this);"],{type:"text/javascript"})),o=new Worker(i);return t.revokeObjectURL(i),o}},1846:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(3025),o={keyword:"dependentRequired",type:"object",schemaType:"object",error:i.error,code:e=>(0,i.validatePropertyDeps)(e)};t.default=o},1858:e=>{"use strict";e.exports=rxjs},1913:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(3282),o=n(9029),r=n(1520),s=n(2586),a=n(8708),l=n(2023),c="errorMessage",h=new i.Name("emUsed"),u={required:"missingProperty",dependencies:"property",dependentRequired:"property"},d=/\$\{[^}]+\}/,p=/\$\{([^}]+)\}/g,m=/^""\s*\+\s*|\s*\+\s*""$/g;const g=(e,t={})=>{if(!e.opts.allErrors)throw new Error("ajv-errors: Ajv option allErrors must be true");if(e.opts.jsPropertySyntax)throw new Error("ajv-errors: ajv option jsPropertySyntax is not supported");return e.addKeyword(function(e){return{keyword:c,schemaType:["string","object"],post:!0,code(t){const{gen:n,data:g,schema:f,schemaValue:y,it:b}=t;if(!1===b.createErrors)return;const v=f,w=o.strConcat(l.default.instancePath,b.errorPath);function C(e,t){return o.and(i._`${e}.keyword !== ${c}`,i._`!${e}.${h}`,i._`${e}.instancePath === ${w}`,i._`${e}.keyword in ${t}`,i._`${e}.schemaPath.indexOf(${b.errSchemaPath}) === 0`,i._`/^\\/[^\\/]*$/.test(${e}.schemaPath.slice(${b.errSchemaPath.length}))`)}function S(e,t){const i=[];for(const n in e){const e=t[n];d.test(e)&&i.push([n,x(e)])}return n.object(...i)}function A(e){return d.test(e)?new r._Code(r.safeStringify(e).replace(p,(e,t)=>`" + JSON.stringify(${s.getData(t,b)}) + "`).replace(m,"")):i.stringify(e)}function x(e){return i._`function(){return ${A(e)}}`}n.if(i._`${l.default.errors} > 0`,()=>{if("object"==typeof v){const[r,s]=function(e){let t,n;for(const i in e){if("properties"===i||"items"===i)continue;const o=e[i];if("object"==typeof o){t||(t={});const e=t[i]={};for(const t in o)e[t]=[]}else n||(n={}),n[i]=[]}return[t,n]}(v);s&&function(o){const r=n.const("emErrors",i.stringify(o)),s=n.const("templates",S(o,f));n.forOf("err",l.default.vErrors,e=>n.if(C(e,r),()=>n.code(i._`${r}[${e}.keyword].push(${e})`).assign(i._`${e}.${h}`,!0)));const{singleError:c}=e;if(c){const e=n.let("message",i._`""`),o=n.let("paramsErrors",i._`[]`);u(t=>{n.if(e,()=>n.code(i._`${e} += ${"string"==typeof c?c:";"}`)),n.code(i._`${e} += ${d(t)}`),n.assign(o,i._`${o}.concat(${r}[${t}])`)}),a.reportError(t,{message:e,params:i._`{errors: ${o}}`})}else u(e=>a.reportError(t,{message:d(e),params:i._`{errors: ${r}[${e}]}`}));function u(e){n.forIn("key",r,t=>n.if(i._`${r}[${t}].length`,()=>e(t)))}function d(e){return i._`${e} in ${s} ? ${s}[${e}]() : ${y}[${e}]`}}(s),r&&function(e){const o=n.const("emErrors",i.stringify(e)),r=[];for(const t in e)r.push([t,S(e[t],f[t])]);const s=n.const("templates",n.object(...r)),c=n.scopeValue("obj",{ref:u,code:i.stringify(u)}),d=n.let("emPropParams"),p=n.let("emParamsErrors");n.forOf("err",l.default.vErrors,e=>n.if(C(e,o),()=>{n.assign(d,i._`${c}[${e}.keyword]`),n.assign(p,i._`${o}[${e}.keyword][${e}.params[${d}]]`),n.if(p,()=>n.code(i._`${p}.push(${e})`).assign(i._`${e}.${h}`,!0))})),n.forIn("key",o,e=>n.forIn("keyProp",i._`${o}[${e}]`,r=>{n.assign(p,i._`${o}[${e}][${r}]`),n.if(i._`${p}.length`,()=>{const o=n.const("tmpl",i._`${s}[${e}] && ${s}[${e}][${r}]`);a.reportError(t,{message:i._`${o} ? ${o}() : ${y}[${e}][${r}]`,params:i._`{errors: ${p}}`})})}))}(r),function(e){const{props:r,items:s}=e;if(!r&&!s)return;const u=i._`typeof ${g} == "object"`,d=i._`Array.isArray(${g})`,p=n.let("emErrors");let m,b;const v=n.let("templates");function C(e,t){n.assign(p,i.stringify(e)),n.assign(v,S(e,t))}r&&s?(m=n.let("emChildKwd"),n.if(u),n.if(d,()=>{C(s,f.items),n.assign(m,i.str`items`)},()=>{C(r,f.properties),n.assign(m,i.str`properties`)}),b=i._`[${m}]`):s?(n.if(d),C(s,f.items),b=i._`.items`):r&&(n.if(o.and(u,o.not(d))),C(r,f.properties),b=i._`.properties`),n.forOf("err",l.default.vErrors,e=>function(e,t,r){n.if(o.and(i._`${e}.keyword !== ${c}`,i._`!${e}.${h}`,i._`${e}.instancePath.indexOf(${w}) === 0`),()=>{const o=n.scopeValue("pattern",{ref:/^\/([^/]*)(?:\/|$)/,code:i._`new RegExp("^\\\/([^/]*)(?:\\\/|$)")`}),s=n.const("emMatches",i._`${o}.exec(${e}.instancePath.slice(${w}.length))`),a=n.const("emChild",i._`${s} && ${s}[1].replace(/~1/g, "/").replace(/~0/g, "~")`);n.if(i._`${a} !== undefined && ${a} in ${t}`,()=>r(a))})}(e,p,t=>n.code(i._`${p}[${t}].push(${e})`).assign(i._`${e}.${h}`,!0))),n.forIn("key",p,e=>n.if(i._`${p}[${e}].length`,()=>{a.reportError(t,{message:i._`${e} in ${v} ? ${v}[${e}]() : ${y}${b}[${e}]`,params:i._`{errors: ${p}[${e}]}`}),n.assign(i._`${l.default.vErrors}[${l.default.errors}-1].instancePath`,i._`${w} + "/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`)})),n.endIf()}(function({properties:e,items:t}){const n={};if(e){n.props={};for(const t in e)n.props[t]=[]}if(t){n.items={};for(let e=0;e<t.length;e++)n.items[e]=[]}return n}(v))}const r="string"==typeof v?v:v._;r&&function(e){const r=n.const("emErrs",i._`[]`);n.forOf("err",l.default.vErrors,e=>n.if(function(e){return o.and(i._`${e}.keyword !== ${c}`,i._`!${e}.${h}`,o.or(i._`${e}.instancePath === ${w}`,o.and(i._`${e}.instancePath.indexOf(${w}) === 0`,i._`${e}.instancePath[${w}.length] === "/"`)),i._`${e}.schemaPath.indexOf(${b.errSchemaPath}) === 0`,i._`${e}.schemaPath[${b.errSchemaPath}.length] === "/"`)}(e),()=>n.code(i._`${r}.push(${e})`).assign(i._`${e}.${h}`,!0))),n.if(i._`${r}.length`,()=>a.reportError(t,{message:A(e),params:i._`{errors: ${r}}`}))}(r),e.keepErrors||function(){const e=n.const("emErrs",i._`[]`);n.forOf("err",l.default.vErrors,t=>n.if(i._`!${t}.${h}`,()=>n.code(i._`${e}.push(${t})`))),n.assign(l.default.vErrors,e).assign(l.default.errors,i._`${e}.length`)}()})},metaSchema:{anyOf:[{type:"string"},{type:"object",properties:{properties:{$ref:"#/$defs/stringMap"},items:{$ref:"#/$defs/stringList"},required:{$ref:"#/$defs/stringOrMap"},dependencies:{$ref:"#/$defs/stringOrMap"}},additionalProperties:{type:"string"}}],$defs:{stringMap:{type:"object",additionalProperties:{type:"string"}},stringOrMap:{anyOf:[{type:"string"},{$ref:"#/$defs/stringMap"}]},stringList:{type:"array",items:{type:"string"}}}}}}(t))};t.default=g,e.exports=g,e.exports.default=g},1991:e=>{"use strict";e.exports=wu},2003:(e,t,n)=>{"use strict";n.d(t,{Hi:()=>i.Hi,J9:()=>o.J9,Qf:()=>o.Qf,YI:()=>i.YI,dh:()=>o.dh,gp:()=>i.gp,mn:()=>o.mn,q7:()=>i.q7,qp:()=>o.qp,z1:()=>i.z1,zS:()=>o.zS});var i=n(439),o=n(7278)},2017:e=>{"use strict";e.exports=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){if(t.constructor!==n.constructor)return!1;var i,o,r;if(Array.isArray(t)){if((i=t.length)!=n.length)return!1;for(o=i;0!==o--;)if(!e(t[o],n[o]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if((i=(r=Object.keys(t)).length)!==Object.keys(n).length)return!1;for(o=i;0!==o--;)if(!Object.prototype.hasOwnProperty.call(n,r[o]))return!1;for(o=i;0!==o--;){var s=r[o];if(!e(t[s],n[s]))return!1}return!0}return t!=t&&n!=n}},2020:(e,t,n)=>{"use strict";n.r(t),n.d(t,{GetRegionEditor:()=>So,PackageFunctions:()=>Wr,SeqActivityCliffsEditor:()=>Eo,SeqPaletteCustom:()=>jr,SequenceSpaceEditor:()=>xo,SplitToMonomersEditor:()=>Ao,SubsequenceSearchTopMenu:()=>cr,_package:()=>Dr,activityCliffs:()=>Go,addCopyMenu:()=>Tr,alignSequences:()=>Yo,bilnSequenceCellRenderer:()=>Io,bioSubstructureFilter:()=>br,bioSubstructureFilterTest:()=>vr,compositionAnalysis:()=>Ko,compositionAnalysisWidget:()=>Po,convertColumnAction:()=>Qo,convertDialog:()=>Jo,customSequenceCellRenderer:()=>Mo,demoBioActivityCliffs:()=>Lr,demoBioAtomicLevel:()=>Nr,demoBioSequenceSpace:()=>Ir,demoBioSimilarityDiversity:()=>_r,detectMacromoleculeProbe:()=>Or,diversitySearchTopMenu:()=>ar,diversitySearchViewer:()=>sr,fastaSequenceCellRenderer:()=>To,getBioLib:()=>bo,getHelmMonomers:()=>ir,getMolFromHelm:()=>Hr,getMonomerLibHelper:()=>po,getRegion:()=>Ho,getRegionApp:()=>Sr,getRegionHelmApp:()=>Ar,getRegionPanel:()=>wo,getRegionTopMenu:()=>Fo,getSeqHandler:()=>vo,getSeqHelper:()=>kr,helmPreprocessingFunction:()=>Do,importBam:()=>Xo,importFasta:()=>Zo,initBio:()=>mo,libraryPanel:()=>Co,longSeqTableFasta:()=>Er,longSeqTableHelm:()=>Mr,longSeqTableSeparator:()=>xr,macroMolColumnPropertyPanel:()=>No,macromoleculeDifferenceCellRenderer:()=>Ro,macromoleculePreprocessingFunction:()=>Bo,manageLibrariesView:()=>pr,manageMonomerLibraries:()=>dr,manageMonomerLibrariesView:()=>gr,manageMonomerLibrariesViewTreeBrowser:()=>fr,manageMonomersView:()=>mr,matchWithMonomerLibrary:()=>yo,monomerCellRenderer:()=>er,multipleSequenceAlignmentDialog:()=>zo,refineNotationProviderForBiln:()=>Lo,saveAsFasta:()=>yr,sdfToJsonLib:()=>Pr,searchSubsequenceEditor:()=>lr,separatorSequenceCellRenderer:()=>_o,seq2atomic:()=>Rr,seqIdentity:()=>$r,sequence3dStructureWidget:()=>qo,sequenceAlignment:()=>$o,sequenceIdentityScoring:()=>hr,sequenceSimilarityScoring:()=>ur,sequenceSpaceTopMenu:()=>Vo,sequenceTooltip:()=>go,similaritySearchTopMenu:()=>rr,similaritySearchViewer:()=>or,splitToMonomersTopMenu:()=>nr,standardiseMonomerLibrary:()=>fo,test1:()=>Ur,testDetectMacromolecule:()=>tr,toAtomicLevel:()=>Wo,toAtomicLevelAction:()=>jo,toAtomicLevelPanel:()=>Uo,vdRegionsViewer:()=>ko,webLogoAggApp:()=>Cr,webLogoLargeApp:()=>wr,webLogoViewer:()=>Oo});var i,o,r=n(4328),s=n(7389),a=n(6082),l=n(684),c=n(9039);(o=i||(i={})).EUCLIDEAN="EUCLIDEAN",o.MANHATTAN="MANHATTAN";var h=n(1858),u=n(5072),d=n.n(u),p=n(7825),m=n.n(p),g=n(7659),f=n.n(g),y=n(5056),b=n.n(y),v=n(540),w=n.n(v),C=n(1113),S=n.n(C),A=n(7939),x={};x.styleTagTransform=S(),x.setAttributes=b(),x.insert=f().bind(null,"head"),x.domAPI=m(),x.insertStyleElement=w(),d()(A.A,x),A.A&&A.A.locals&&A.A.locals;var E=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function s(e){try{l(i.next(e))}catch(e){r(e)}}function a(e){try{l(i.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((i=i.apply(e,t||[])).next())})};let M=null,T=null;function _(e,t){return e&&""!=e?e:t}n(2780);class I{constructor(){this.learningRate={uiName:"Learninig Rate",value:1,tooltip:"The initial learning rate for the embedding optimization"},this.nEpochs={uiName:"Epochs",value:0,tooltip:"The number of epochs to optimize embeddings via SGD. Computed automatically if set to 0"},this.nNeighbors={uiName:"Neighbors",value:15,tooltip:"The number of nearest neighbors to construct the fuzzy manifold"},this.spread={uiName:"Spread",value:1,tooltip:"The effective scale of embedded points, used with min distance to control \n the clumped/dispersed nature of the embedding"},this.minDist={uiName:"Min Distance",value:.1,tooltip:"The effective minimum distance between embedded points, \n used with spread to control the clumped/dispersed nature of the embedding"},this.randomSeed={uiName:"Random Seed",value:null,tooltip:"Random seed",type:"string"},this.useWebGPU={uiName:"Use WebGPU",value:!1,tooltip:"Use WebGPU for Distance and UMAP computations",type:"boolean",disableTooltip:"WebGPU is not available"},function(){return E(this,void 0,void 0,function*(){if(!navigator.gpu)return console.error("WebGPU is not supported in this browser"),null;if(!M&&(M=yield navigator.gpu.requestAdapter(),null==M))return null;let e=null;return"info"in M&&(e=M.info),e?_(e.description,_(e.vendor,"No GPU description available")):"No GPU description available"})}().then(e=>{e?(this.useWebGPU.tooltip+=` (${e})`,this.useWebGPU.value=!0):(this.useWebGPU.value=!1,this.useWebGPU.disable=!0)})}}class L{constructor(){this.epsilon={uiName:"Epsilon",value:10,tooltip:"Epsilon is learning rate"},this.perplexity={uiName:"Perplexity",value:30,tooltip:"Roughly how many neighbors each point influences"}}}Promise.resolve(),n(934),n(8903);const N="MCL";var P=n(1991),R=n.n(P);a.SEMTYPE.MOLECULE,a.SEMTYPE.MACROMOLECULE;class ${constructor(){this.epsilon={uiName:"Epsilon",value:.01,tooltip:"Minimum distance between cluster points",min:0,max:2,step:.005},this.minPts={uiName:"Minimum points",value:4,tooltip:"Minimum number of points in cluster",min:1,max:1e3,step:1}}}class O{get algorithmOptions(){const e=this.methodsParams[this.methodInput.value],t={};return Object.keys(e).forEach(n=>{null!=e[n].value&&(t[n]=e[n].value)}),t}get dbScanOptions(){return{dbScanEpsilon:this.dbScanParams.epsilon.value??.01,dbScanMinPts:this.dbScanParams.minPts.value??4}}constructor(e={}){this.editorSettings={},this.plotEmbeddingsInput=s.input.bool("Plot embeddings",{value:!0}),this.clusterEmbeddingsInput=s.input.bool("Cluster embeddings",{value:!0}),this.preprocessingFunctionInputRoot=null,this.methods=[c.c.UMAP,c.c.T_SNE],this.columnFunctionsMap={},this.supportedFunctions={},this.availableMetrics=[],this.methodSettingsDiv=s.inputs([]),this.dbScanSettingsDiv=s.inputs([]),this.preprocessingFuncSettingsDiv=s.inputs([]),this.preprocessingFunctionSettings={},this.methodsParams={[c.c.UMAP]:new I,[c.c.T_SNE]:new L},this.dbScanParams=new $,this.editorSettings=e,this.editorSettings.enableMCL&&this.methods.push(N),a.Func.find({tags:[l.GP]}).forEach(e=>{const t=e.options.get(l.n3)??"",n=e.friendlyName??e.name,i=e.options.get(l.C0)??"",o=e.options.get(l._X)??"",r=e.options.get(l.Gi)??"";this.editorSettings.semtype&&!t.includes(this.editorSettings.semtype)||this.editorSettings.type&&!i.includes(this.editorSettings.type)||this.editorSettings.units&&!o.includes(this.editorSettings.units)||(this.supportedFunctions[n]={func:e,semTypes:t?t.split(","):[],types:i?i.split(","):[],units:o?o.split(","):[],distanceFunctions:r?r.split(","):[]})}),this.tableInput=s.input.table("Table",{value:r.shell.tv.dataFrame,items:r.shell.tables,onValueChanged:()=>{this.onTableInputChanged()}}),this.onTableInputChanged(),this.regenerateColInput(),this.onColumnInputChanged();let t=!1,n=!1;this.methodInput=s.input.choice("Method",{value:c.c.UMAP,items:this.methods,onValueChanged:e=>{t&&this.createAlgorithmSettingsDiv(this.methodSettingsDiv,this.methodsParams[e])}}),this.methodSettingsIcon=s.icons.settings(()=>{t=!t,t?this.createAlgorithmSettingsDiv(this.methodSettingsDiv,this.methodsParams[this.methodInput.value]):s.empty(this.methodSettingsDiv)},"Modify methods parameters"),this.dbScanSettingsIcon=s.icons.settings(()=>{n=!n,n?this.createAlgorithmSettingsDiv(this.dbScanSettingsDiv,this.dbScanParams):s.empty(this.dbScanSettingsDiv)},"Modify clustering parameters"),this.clusterEmbeddingsInput.classList.add("ml-dim-reduction-settings-input"),this.clusterEmbeddingsInput.root.prepend(this.dbScanSettingsIcon),this.methodInput.root.classList.add("ml-dim-reduction-settings-input"),this.methodInput.root.prepend(this.methodSettingsIcon),this.methodSettingsDiv=s.inputs([]);const i=this.columnFunctionsMap[this.colInput.value.name];this.preprocessingFunctionInput=s.input.choice("Encoding function",{value:i[0],items:i,onValueChanged:()=>{this.onPreprocessingFunctionChanged()}});let o=!1;this.preprocessingFunctionInputRoot||(this.preprocessingFunctionInputRoot=this.preprocessingFunctionInput.root,o=!0),o||(s.empty(this.preprocessingFunctionInputRoot),Array.from(this.preprocessingFunctionInput.root.children).forEach(e=>this.preprocessingFunctionInputRoot.append(e))),this.preprocessingFunctionInputRoot.classList.add("ml-dim-reduction-settings-input");let h=!1;this.preprocessingFuncSettingsIcon=s.icons.settings(async()=>{h?s.empty(this.preprocessingFuncSettingsDiv):await this.createPreprocessingFuncParamsDiv(this.preprocessingFuncSettingsDiv,this.supportedFunctions[this.preprocessingFunctionInput.value].func),h=!h},"Modify encoding function parameters"),this.preprocessingFunctionInputRoot.prepend(this.preprocessingFuncSettingsIcon),this.similarityMetricInput=s.input.choice("Similarity",{value:"",items:[]}),this.similarityMetricInput.nullable=!1,this.similarityMetricInputRoot||(this.similarityMetricInputRoot=this.similarityMetricInput.root),this.onPreprocessingFunctionChanged()}getColInput(){const e=this.tableInput.value?.columns.toList().find(e=>!!this.columnFunctionsMap[e.name])??null,t=s.input.column("Column",{table:this.tableInput.value,value:e,nullable:!1,onValueChanged:()=>this.onColumnInputChanged(),filter:e=>!!this.columnFunctionsMap[e.name]});return this.colInputRoot||(this.colInputRoot=t.root),t}regenerateColInput(){let e=!1;this.colInputRoot&&(e=!0,s.empty(this.colInputRoot)),this.colInput=this.getColInput(),e&&Array.from(this.colInput.root.children).forEach(e=>this.colInputRoot.append(e)),this.onColumnInputChanged()}onTableInputChanged(){const e=this.tableInput.value;if(!e)return;const t=()=>{this.columnFunctionsMap={},e.columns.toList().forEach(e=>{Object.keys(this.supportedFunctions).forEach(t=>{const n=this.supportedFunctions[t].semTypes,i=this.supportedFunctions[t].types,o=this.supportedFunctions[t].units,r=!n.length||e.semType&&n.includes(e.semType),s=!i.length||i.includes(e.type),a=!o.length||e.meta.units&&o.includes(e.meta.units);r&&s&&a&&(this.columnFunctionsMap[e.name]||(this.columnFunctionsMap[e.name]=[]),this.columnFunctionsMap[e.name].push(t))})}),this.regenerateColInput()};t(),R()(e.columns).some(e=>!!e.getTag(a.Tags.SemanticDetectionDuration))||e.meta.detectSemanticTypes().then(()=>{t()})}onColumnInputChanged(){const e=this.colInput.value;if(!e)return;const t=this.columnFunctionsMap[e.name];this.preprocessingFunctionInput=s.input.choice("Preprocessing function",{value:t[0],items:t,onValueChanged:()=>{this.onPreprocessingFunctionChanged()}});let n=!1;this.preprocessingFunctionInputRoot||(this.preprocessingFunctionInputRoot=this.preprocessingFunctionInput.root,n=!0),n||(s.empty(this.preprocessingFunctionInputRoot),Array.from(this.preprocessingFunctionInput.root.children).forEach(e=>this.preprocessingFunctionInputRoot.append(e))),this.onPreprocessingFunctionChanged()}onPreprocessingFunctionChanged(){s.empty(this.preprocessingFuncSettingsDiv),this.preprocessingFunctionSettings={};const e=this.preprocessingFunctionInput.value,t=this.supportedFunctions[e].distanceFunctions;this.availableMetrics=[...t],this.similarityMetricInput=s.input.choice("Similarity",{value:this.availableMetrics[0],items:this.availableMetrics}),this.similarityMetricInput.nullable=!1,this.similarityMetricInputRoot||(this.similarityMetricInputRoot=this.similarityMetricInput.root),s.empty(this.similarityMetricInputRoot),Array.from(this.similarityMetricInput.root.children).forEach(e=>this.similarityMetricInputRoot.append(e)),this.preprocessingFuncSettingsIcon&&(this.supportedFunctions[e].func.inputs.length<3?this.preprocessingFuncSettingsIcon.style.display="none":this.preprocessingFuncSettingsIcon.style.display="flex")}createAlgorithmSettingsDiv(e,t){return s.empty(e),Object.keys(t).forEach(n=>{const i=t[n],o="string"===i.type?s.input.string(i.uiName,{value:i.value??"",onValueChanged:e=>{i.value=e}}):"boolean"===i.type?s.input.bool(i.uiName,{value:i.value??!1,onValueChanged:e=>{i.value=e}}):s.input.float(i.uiName,{value:i.value,onValueChanged:e=>{i.value=e}});e.append(o.root),i.disable?(o.enabled=!1,s.tooltip.bind(o.input??o.root,i.disableTooltip??"")):s.tooltip.bind(o.input??o.root,i.tooltip)}),e}async createPreprocessingFuncParamsDiv(e,t){if(s.empty(e),t.inputs.length<3)return s.div();const n=t.prepare(),i=await n.buildEditor(s.div());for(let o=2;o<t.inputs.length;o++){const r=t.inputs[o];(this.preprocessingFunctionSettings[r.name]||n.inputParams[t.inputs[o].name].value||r.defaultValue)&&(this.preprocessingFunctionSettings[r.name]=this.preprocessingFunctionSettings[r.name]??n.inputParams[r.name].value??r.defaultValue);const s=i.find(e=>e.property.name===r.name);s&&(null!==this.preprocessingFunctionSettings[r.name]&&void 0!==this.preprocessingFunctionSettings[r.name]&&(s.value=this.preprocessingFunctionSettings[r.name]),s.onChanged.subscribe(e=>{this.preprocessingFunctionSettings[r.name]=e}),e.append(s.root))}return e}getEditor(){return s.div([this.tableInput,this.colInputRoot,this.preprocessingFunctionInputRoot,this.preprocessingFuncSettingsDiv,this.methodInput,this.methodSettingsDiv,this.similarityMetricInputRoot,this.plotEmbeddingsInput,this.clusterEmbeddingsInput,this.dbScanSettingsDiv],{style:{minWidth:"420px"},classes:"ui-form dim-reduction-dialog-form"})}getParams(){return{table:this.tableInput.value,col:this.colInput.value,methodName:this.methodInput.value,preprocessingFunction:this.supportedFunctions[this.preprocessingFunctionInput.value].func,similarityMetric:this.similarityMetricInput.value,plotEmbeddings:this.plotEmbeddingsInput.value,clusterEmbeddings:this.clusterEmbeddingsInput.value,options:{...this.algorithmOptions,...this.dbScanOptions,preprocessingFuncArgs:this.preprocessingFunctionSettings??{}}}}getInput(){return{table:this.tableInput.value.name,col:this.colInput.value.name,methodName:this.methodInput.value,preprocessingFunction:this.preprocessingFunctionInput.value,similarityMetric:this.similarityMetricInput.value,plotEmbeddings:this.plotEmbeddingsInput.value,clusterEmbeddings:this.clusterEmbeddingsInput.value,options:{...this.algorithmOptions,...this.dbScanOptions,preprocessingFuncArgs:this.preprocessingFunctionSettings??{}}}}getStringInput(){return JSON.stringify(this.getInput())}async applyStringInput(e){try{const t=JSON.parse(e);await this.applyInput(t)}catch(e){r.shell.error("Error applying input from history"),console.error(e)}}async applyInput(e){try{const t=this.tableInput.value?.col(e.col);if(!t)throw new Error("Column not found");this.colInput.value=t,this.preprocessingFunctionInput.value=e.preprocessingFunction,this.similarityMetricInput.value=e.similarityMetric,this.plotEmbeddingsInput.value=e.plotEmbeddings,this.clusterEmbeddingsInput.value=e.clusterEmbeddings;const n=this.methodsParams[this.methodInput.value];Object.keys(n).forEach(t=>{null!=e.options[t]&&(this.methodsParams[e.methodName][t].value=e.options[t])}),this.methodInput.value=e.methodName,this.preprocessingFunctionSettings=e.options.preprocessingFuncArgs,await this.createPreprocessingFuncParamsDiv(this.preprocessingFuncSettingsDiv,this.supportedFunctions[this.preprocessingFunctionInput.value].func)}catch(e){r.shell.error("Error applying input from history"),console.error(e)}}}var k=n(9713),H=n(6295);const F=e=>null==e;function G(e,t,n,i){if(n>e[e.length-1])return;const o=e.findIndex(e=>n<e);e.pop(),e.splice(o,0,n),t.pop(),t.splice(o,0,i)}class B{constructor(e=!0,t=!0){const i=navigator.hardwareConcurrency;this._workerCount=e?Math.max(i-2,1):1,this._workers=new Array(this._workerCount).fill(null).map(()=>new Worker(new URL(n.p+n.u(793),n.b))),this._terminateOnComplete=t}async calc(e,t,n=!0,o){return await this.calcMulti([e],[t],n,[o??{}],[1],i.MANHATTAN)}async calcMulti(e,t,n=!0,o=[{}],r=[1],s=i.MANHATTAN){if(e.length<1)throw new Error("values must contain at least one array");if(t.length!==e.length||o.length!==e.length||r.length!==e.length)throw new Error("values, fnNames, weights and opts must have the same length");return new Promise(async(i,a)=>{try{const a=e[0].length,l=new Array(this._workerCount),c=a*(a-1)/2;this._workerCount=Math.min(this._workerCount,c);const h=c/this._workerCount,u=new Float32Array(c);let d=0,p=1,m=0,g=Number.MIN_VALUE;for(let n=0;n<this._workerCount;n++){const i=Math.floor(n*h),f=n===this._workerCount-1?c:Math.floor((n+1)*h),y=d,b=p;n!==this._workerCount-1&&(d=a-2-Math.floor(Math.sqrt(-8*f+4*a*(a-1)-7)/2-.5),p=f-a*d+Math.floor((d+1)*(d+2)/2)),this._workers[n].postMessage({values:e,fnNames:t,startRow:y,startCol:b,chunckSize:f-i,opts:o,weights:r,aggregationMethod:s}),l[n]=new Promise((e,t)=>{this._workers[n].onmessage=({data:{error:o,distanceMatrixData:r,min:s,max:a}})=>{this._terminateOnComplete&&setTimeout(()=>this._workers[n].terminate()),o?t(o):(u.set(r,i),s<m&&(m=s),a>g&&(g=a),e())}})}await Promise.all(l),n&&u.forEach((e,t)=>{u[t]=(e-m)/(g-m)}),i(u)}catch(e){a(e)}})}terminate(){this._workers.forEach(e=>e.terminate())}}class D{constructor(){this._workerCount=Math.max(navigator.hardwareConcurrency-2,1)}static pruneSparseMatrix(e,t=1e6){const n=200,i=new Uint32Array(n),o=e.distance.length,r=e.distance;for(let e=0;e<o;e++)i[Math.floor(r[e]*n)]++;let s=0,a=0;for(let e=0;e<n&&(s+=i[e],a=e,!(s>=t));e++);const l=new Uint32Array(s),c=new Uint32Array(s),h=new Float32Array(s),u=e.i,d=e.j;let p=0;const m=(a+1)/n;for(let e=0;e<o;e++)r[e]<m&&(l[p]=u[e],c[p]=d[e],h[p]=r[e],p++);return{i:l,j:c,distance:h}}async calcMultiColumn(e,t,o,r=[{}],s=[1],a=i.EUCLIDEAN){const l=e[0].length*(e[0].length-1)/2,c=Math.floor(l/this._workerCount),h=e[0].length>2e4?await this.getMinimalThreshold(e,t,r,s,a):0;o<h&&(console.log(`using threshold ${h}`),o=h),r.forEach((e,t)=>r[t].threshold=o);const u=new Array(this._workerCount),d=new Array(this._workerCount).fill(null).map(()=>new Worker(new URL(n.p+n.u(111),n.b)));for(let n=0;n<this._workerCount;n++)u[n]=new Promise((i,h)=>{const u=n*c,p=n===this._workerCount-1?l:(n+1)*c;p<=u&&i({i:new Int32Array(0),j:new Int32Array(0),distance:new Float32Array(0),idx:n}),d[n].postMessage({values:e,startIdx:u,endIdx:p,threshold:o,fnNames:t,opts:r,weights:s,aggregationMethod:a}),d[n].onmessage=({data:{error:e,i:t,j:o,distance:r}})=>{e?(d[n].terminate(),h(e)):(d[n].terminate(),i({i:t,j:o,distance:r,idx:n}))}});const p=await Promise.all(u),m=p.reduce((e,t)=>e+t.i.length,0),g=new Int32Array(m),f=new Int32Array(m),y=new Float32Array(m);let b=0;for(const e of p)g.set(e.i,b),f.set(e.j,b),y.set(e.distance,b),b+=e.i.length;return{i:g,j:f,distance:y}}async calc(e,t,n,i={}){return await this.calcMultiColumn([e],[t],n,[i],[1])}async getKNN(e,t,n=15,i={}){return await this.multiColumnKNN([e],[t],n,[i],[1])}async getThresholdKNN(e,t,n=.8,i={}){return await this.multiColumnThresholdKnn([e],[t],n,[i],[1])}async multiColumnThresholdKnn(e,t,o=.8,r,s,a=i.EUCLIDEAN){if(e.length!==t.length||e.length!==r.length||e.length!==s.length)throw new Error("values, distance functions, options and weights arrays should have the same length");if(e.some(t=>t.length!==e[0].length))throw new Error("all values arrays should have the same length");const l=e[0].length*(e[0].length-1)/2,c=Math.floor(l/this._workerCount),h=new Array(this._workerCount),u=new Array(this._workerCount).fill(null).map(()=>new Worker(new URL(n.p+n.u(603),n.b)));for(let n=0;n<this._workerCount;n++)h[n]=new Promise((i,h)=>{const d=n*c,p=n===this._workerCount-1?l:(n+1)*c;p<=d&&i({knnDistances:new Array(0),knnIndexes:new Array(0)}),u[n].postMessage({values:e,startIdx:d,endIdx:p,fnNames:t,opts:r,threshold:o,weights:s,aggregationMethod:a}),u[n].onmessage=({data:{error:e,knnDistances:t,knnIndexes:o}})=>{e?(u[n].terminate(),h(e)):(u[n].terminate(),i({knnDistances:t,knnIndexes:o}))}});const d=await Promise.all(h),p=new Int32Array(e[0].length);for(const t of d)for(let n=0;n<e[0].length;++n)p[n]+=t.knnIndexes[n]?.length??0;const m={knnDistances:new Array(e[0].length).fill(null).map((e,t)=>new Array(p[t])),knnIndexes:new Array(e[0].length).fill(null).map((e,t)=>new Array(p[t]))};for(const t of d)for(let n=0;n<e[0].length;++n)for(let e=0;e<(t.knnDistances[n]?.length??0);++e)m.knnDistances[n][p[n]-1]=t.knnDistances[n][e],m.knnIndexes[n][p[n]-1]=t.knnIndexes[n][e],p[n]-=1;return m}async multiColumnSingleValueKNN(e,t,o,r=15,s,a,l=i.EUCLIDEAN){if(e.length!==o.length||e.length!==s.length||e.length!==a.length)throw new Error("values, distance functions, options and weights arrays should have the same length");if(e.some(t=>t.length!==e[0].length))throw new Error("all values arrays should have the same length");const c=new Array(this._workerCount).fill(null).map(()=>new Worker(new URL(n.p+n.u(810),n.b))),h=new Array(this._workerCount),u=e[0].length,d=e.map(e=>e[t]),p=Math.ceil(u/this._workerCount);for(let t=0;t<this._workerCount;t++)h[t]=new Promise((n,i)=>{const h=t*p,m=t===this._workerCount-1?u:(t+1)*p;m<=h&&n({knnDistances:new Array(0),knnIndexes:new Array(0)}),c[t].postMessage({values:e.map(e=>e.slice(h,m)),target:d,fnNames:o,opts:s,nNeighbours:r,weights:a,aggregationMethod:l,startIdx:h}),c[t].onmessage=({data:{error:e,knnDistances:o,knnIndexes:r}})=>{e?(c[t].terminate(),i(e)):(c[t].terminate(),n({knnDistances:o,knnIndexes:r}))}});const m=await Promise.all(h),g={knnDistances:new Array(r).fill(99999),knnIndexes:new Array(r).fill(-1)};for(const e of m)for(let t=0;t<(e.knnDistances?.length??0);++t)G(g.knnDistances,g.knnIndexes,e.knnDistances[t],e.knnIndexes[t]);return g}async multiColumnKNN(e,t,o=15,r,s,a=i.EUCLIDEAN){if(e.length!==t.length||e.length!==r.length||e.length!==s.length)throw new Error("values, distance functions, options and weights arrays should have the same length");if(e.some(t=>t.length!==e[0].length))throw new Error("all values arrays should have the same length");const l=e[0].length*(e[0].length-1)/2,c=Math.floor(l/this._workerCount),h=new Array(this._workerCount),u=new Array(this._workerCount).fill(null).map(()=>new Worker(new URL(n.p+n.u(950),n.b)));for(let n=0;n<this._workerCount;n++)h[n]=new Promise((i,h)=>{const d=n*c,p=n===this._workerCount-1?l:(n+1)*c;p<=d&&i({knnDistances:new Array(0),knnIndexes:new Array(0)}),u[n].postMessage({values:e,startIdx:d,endIdx:p,fnNames:t,opts:r,nNeighbours:o,weights:s,aggregationMethod:a}),u[n].onmessage=({data:{error:e,knnDistances:t,knnIndexes:o}})=>{e?(u[n].terminate(),h(e)):(u[n].terminate(),i({knnDistances:t,knnIndexes:o}))}});const d=await Promise.all(h),p={knnDistances:new Array(e[0].length).fill(null).map(()=>new Array(o).fill(99999)),knnIndexes:new Array(e[0].length).fill(null).map(()=>new Array(o).fill(-1))};for(const t of d)for(let n=0;n<e[0].length;++n)for(let e=0;e<(t.knnDistances[n]?.length??0);++e)G(p.knnDistances[n],p.knnIndexes[n],t.knnDistances[n][e],t.knnIndexes[n][e]);return p}async getSampleDistances(e,t,o=[],r,s=i.EUCLIDEAN){const a=new Array(this._workerCount).fill(null).map(()=>new Worker(new URL(n.p+n.u(778),n.b)));try{const n=e[0].length*(e[0].length-1)/2,i=Math.floor(n/this._workerCount),l=1e6,c=Math.max(Math.min(n/1e3,l),Math.min(n,l)),h=Math.floor(c/this._workerCount),u=new Array(this._workerCount);for(let l=0;l<this._workerCount;l++)u[l]=new Promise((c,u)=>{const d=l*i,p=l===this._workerCount-1?n:(l+1)*i;a[l].postMessage({values:e,startIdx:d,endIdx:p,sampleLength:h,fnNames:t,opts:o,weights:r,aggregationMethod:s}),a[l].onmessage=({data:{error:e,distance:t}})=>{a[l].terminate(),e?u(e):c({distance:t})}});const d=await Promise.all(u),p=d.reduce((e,t)=>e+t.distance.length,0),m=new Float32Array(p);let g=0;for(const e of d)m.set(e.distance,g),g+=e.distance.length;return m.sort(),m}catch(e){return a?.forEach(e=>e?.terminate()),console.error(e),new Float32Array(1).fill(.5)}}async getMinimalThreshold(e,t,n=[],o,r=i.EUCLIDEAN){try{const i=e.length*(e.length-1)/2,s=await this.getSampleDistances(e,t,n,o,r);return 1-s[Math.floor(7e7/i*s.length)]}catch(e){return console.error(e),.5}}static calcSync(e,t,n,i){const o=[],r=[],s=[];let a=0,l=0,c=0;const h=e.length*(e.length-1)/2;for(;a<h;){const t=F(e[l])||F(e[c])?1:n(e[l],e[c]);1-t>=i&&(o.push(l),r.push(c),s.push(t)),a++,c++,c===e.length&&(l++,c=l+1)}return{i:new Int32Array(o),j:new Int32Array(r),distance:new Float32Array(s)}}}var V,W,j=n(8774);(W=V||(V={})).none="none",W.bold="bold",W.dashed="dashed";class U{get currentLineId(){return this._currentLineIdx}set currentLineId(e){e!==this._currentLineIdx&&(this._currentLineIdx=e,this.sp.render(this.ctx))}set linesToRender(e){this.updateLines(e),this.sp.render(this.ctx)}set linesVisibility(e){this.visibility=e,this.sp.render(this.ctx)}constructor(e,t,n,i,o=V.none){var r;this._currentLineIdx=-1,this.lineClicked=new h.Subject,this.lineHover=new h.Subject,this.mouseOverLineId=-1,this.arrowWidth=15,this.sp=e,this.xAxisCol=this.sp.dataFrame.columns.byName(t),this.yAxisCol=this.sp.dataFrame.columns.byName(n),this.canvas=this.sp.getInfo().canvas,this.ctx=this.canvas.getContext("2d"),this.currentLineStyle=o,this.updateLines(i),this.visibility=null!==(r=i.visibility)&&void 0!==r?r:new j.A(this.lines.from.length),i.visibility||this.visibility.setAll(!0,!1),i.arrowSize&&(this.arrowWidth=i.arrowSize),this.canvas.onmousedown=e=>{var t;(null===(t=this.lines)||void 0===t?void 0:t.skipMouseOverDetection)&&(this.mouseOverLineId=this.checkCoordsOnLine(e.offsetX,e.offsetY)),-1!==this.mouseOverLineId&&this.lineClicked.next({x:e.clientX,y:e.clientY,id:this.mouseOverLineId,event:e})},this.canvas.onmousemove=e=>{var t;this.mouseOverLineId=(null===(t=this.lines)||void 0===t?void 0:t.skipMouseOverDetection)?-1:this.checkCoordsOnLine(e.offsetX,e.offsetY),-1!==this.mouseOverLineId&&this.lineHover.next({x:e.clientX,y:e.clientY,id:this.mouseOverLineId,event:e})},e.onEvent("d4-before-draw-scene").subscribe(e=>{this.renderLines()})}updateLines(e){this.lines=e,this.multipleLinesCounts=new Uint8Array(this.lines.from.length),e.skipMultiLineCalculation?this.multipleLinesCounts.fill(0):this.createMultiLinesIndices()}renderLines(){var e,t,n,i,o,r,s,a,l,c,h,u,d,p,m,g,f;const y=this.lines.colors||this.lines.widths||this.lines.opacities||this.lines.drawArrowsArr;y||(this.ctx.lineWidth=null!==(e=this.lines.width)&&void 0!==e?e:1,this.ctx.strokeStyle=`rgba(${null!==(t=this.lines.color)&&void 0!==t?t:"0,128,0"},${null!==(n=this.lines.opacity)&&void 0!==n?n:1})`);const b=this.sp.dataFrame.filter,v=Math.pow(null!==(i=this.lines.shortLineThreshold)&&void 0!==i?i:5,2);for(let e=0;e<this.lines.from.length;e++)if(b.get(this.lines.from[e])&&b.get(this.lines.to[e])&&this.visibility.getBit(e)){let t=0;const n=this.sp.getMarkerSize(this.lines.from[e])/2,i=this.sp.getMarkerSize(this.lines.to[e])/2,b=this.sp.pointToScreen(this.lines.from[e]);let w=null==b?void 0:b.x,C=null==b?void 0:b.y;const S=this.sp.pointToScreen(this.lines.to[e]);let A=null==S?void 0:S.x,x=null==S?void 0:S.y;const E=Math.min(this.sp.viewBox.width,this.sp.viewBox.height);if(this.ctx.beginPath(),w&&C&&A&&x&&Math.hypot(A-w,x-C)/E>.01){if(y){const t=(null===(o=this.lines.colors)||void 0===o?void 0:o[e])?null===(r=this.lines.colors)||void 0===r?void 0:r[e]:null!==(s=this.lines.color)&&void 0!==s?s:"0,128,0",n=(null===(a=this.lines.opacities)||void 0===a?void 0:a[e])?null===(l=this.lines.opacities)||void 0===l?void 0:l[e]:null!==(c=this.lines.opacity)&&void 0!==c?c:1;this.ctx.strokeStyle=`rgba(${t},${n})`,this.ctx.lineWidth=(null===(h=this.lines.widths)||void 0===h?void 0:h[e])?null===(u=this.lines.widths)||void 0===u?void 0:u[e]:null!==(d=this.lines.width)&&void 0!==d?d:1}e===this._currentLineIdx&&this.toggleCurrentLineStyle(!0);const b=this.multipleLinesCounts[e];let S=null;if(b){t=this.getLineLength(w,C,A,x);const o=this.getPointOnDistance(w,C,A,x,i,t),r=this.getPointOnDistance(A,x,w,C,n,t);w=o.x,C=o.y,A=r.x,x=r.y,S=this.lines.from[e]>this.lines.to[e]?this.findControlPoint(b,w,C,A,x,e):this.findControlPoint(b,A,x,w,C,e),this.ctx.moveTo(w,C),this.ctx.quadraticCurveTo(S.x,S.y,A,x)}else(!this.lines.skipShortLines||Math.pow(A-w,2)+Math.pow(x-C,2)>v)&&(this.ctx.moveTo(w,C),this.ctx.lineTo(A,x));if((null!==(p=this.lines.drawArrows)&&void 0!==p?p:null===(m=this.lines.drawArrowsArr)||void 0===m?void 0:m.getBit(e))&&(t||(t=this.getLineLength(w,C,A,x)),t>this.arrowWidth)){const e=b?null:this.getPointOnDistance(w,C,A,x,i,t),n=b?S.x:w,o=b?S.y:C;this.canvasArrow(this.ctx,null!==(g=null==e?void 0:e.x)&&void 0!==g?g:w,null!==(f=null==e?void 0:e.y)&&void 0!==f?f:C,n,o)}this.ctx.stroke(),this.ctx.closePath(),e===this._currentLineIdx&&this.toggleCurrentLineStyle(!1)}}this.fillLeftBottomRect()}toggleCurrentLineStyle(e){switch(this.currentLineStyle){case V.bold:e?this.ctx.lineWidth+=2:this.ctx.lineWidth-=2;break;case V.dashed:e?this.ctx.setLineDash([5,5]):this.ctx.setLineDash([]);break;default:return}}fillLeftBottomRect(){const e=new Path2D;e.rect(this.sp.yAxisBox.minX,this.sp.yAxisBox.maxY,this.sp.yAxisBox.width,this.sp.xAxisBox.height),this.ctx.fillStyle="white",this.ctx.beginPath(),this.ctx.fill(e),this.ctx.closePath()}createMultiLinesIndices(){const e={};for(let t=0;t<this.lines.from.length;t++){let n=0,i=0;this.lines.from[t]<this.lines.to[t]?(n=this.lines.from[t],i=this.lines.to[t]):(n=this.lines.to[t],i=this.lines.from[t]),e[`${n}|${i}`]?(1===e[`${n}|${i}`].length&&(this.multipleLinesCounts[e[`${n}|${i}`][0]]=1,e[`${n}|${i}`].push(1)),this.multipleLinesCounts[t]=++e[`${n}|${i}`][1]):e[`${n}|${i}`]=[t]}}checkCoordsOnLine(e,t){let n=-1,i=null,o=null;const r=this.sp.dataFrame.filter;for(let s=0;s<this.lines.from.length;s++)if(r.get(this.lines.from[s])&&r.get(this.lines.to[s])&&this.visibility.getBit(s)){const r=this.sp.getMarkerSize(this.lines.from[s])/2,a=this.sp.getMarkerSize(this.lines.to[s])/2,l=this.sp.worldToScreen(this.xAxisCol.get(this.lines.from[s]),this.yAxisCol.get(this.lines.from[s])),c=this.sp.worldToScreen(this.xAxisCol.get(this.lines.to[s]),this.yAxisCol.get(this.lines.to[s]));if(this.multipleLinesCounts[s]){const n=this.getLineLength(l.x,l.y,c.x,c.y),i=this.getPointOnDistance(l.x,l.y,c.x,c.y,a,n),h=this.getPointOnDistance(c.x,c.y,null==l?void 0:l.x,null==l?void 0:l.y,r,n),u=this.lines.from[s]>this.lines.to[s]?this.findControlPoint(this.multipleLinesCounts[s],i.x,i.y,h.x,h.y,s):this.findControlPoint(this.multipleLinesCounts[s],h.x,h.y,i.x,i.y,s);o=this.calculateDistToCurveLine(s,e,t,i,h,u)}else o=this.calculateDistToStraightLine(e,t,l,c);(!i&&null!==o&&o<5||i&&null!==o&&o<i)&&(i=o,n=s)}return n}calculateDistToStraightLine(e,t,n,i){const o=Math.min(n.x,i.x),r=Math.max(n.x,i.x),s=Math.min(n.y,i.y),a=Math.max(n.y,i.y);return e>=o-2&&e<=r+2&&t>=s-2&&t<=a+2?this.distToStraightLineSegment(e,t,n,i):null}distToStraightLineSegment(e,t,n,i){const o=(e,t,n,i)=>Math.pow(e-n,2)+Math.pow(t-i,2),r=o(n.x,n.y,i.x,i.y);if(0==r)return o(e,t,n.x,n.y);let s=((e-n.x)*(i.x-n.x)+(t-n.y)*(i.y-n.y))/r;return s=Math.max(0,Math.min(1,s)),o(e,t,n.x+s*(i.x-n.x),n.y+s*(i.y-n.y))}calculateDistToCurveLine(e,t,n,i,o,r){const s=Math.min(i.x,o.x,r.x),a=Math.max(i.x,o.x,r.x),l=Math.min(i.y,o.y,r.y),c=Math.max(i.y,o.y,r.y);if(t>=s-2&&t<=a+2&&n>=l-2&&n<=c+2){const e=a-s,h=c-l;return this.calculateDistToCurveInRect(t,n,i,r,o,e,h)}return null}calculateDistToCurveInRect(e,t,n,i,o,r,s){const a=Math.floor((r+s)/3),l=1/a,c=new Uint32Array(a),h=new Uint32Array(a),u=new Uint32Array(a);let d=null;const p=new j.A(a);for(let r=0;r<c.length;r++){const s=r*l,a=Math.pow(1-s,2)*n.x+2*s*(1-s)*i.x+Math.pow(s,2)*o.x,p=Math.pow(1-s,2)*n.y+2*s*(1-s)*i.y+Math.pow(s,2)*o.y,m=Math.abs(e-a),g=Math.abs(t-p),f=m+g;(!d||d>f)&&(d=f),u[r]=Math.max(m,g),c[r]=a,h[r]=p}for(let e=0;e<c.length;e++)u[e]<d&&p.setBit(e,!0,!1);let m=null;for(let n=-1;-1!==(n=p.findNext(n));){const i=Math.hypot(c[n]-e,h[n]-t);(!m||m>i)&&(m=i)}return m}getLineLength(e,t,n,i){return Math.sqrt(Math.pow(n-e,2)+Math.pow(i-t,2))}getPointOnDistance(e,t,n,i,o,r){const s=n-o*((n-e)/r),l=i-o*((i-t)/r);return new a.Point(s,l)}findControlPoint(e,t,n,i,o,r){const s=t+(i-t)/2,l=n+(o-n)/2;let c=s-t,h=l-n;const u=Math.sqrt(c*c+h*h);c/=u,h/=u;const d=50*Math.ceil(e/2);return e%2==0?new a.Point(s+d/2*h,l-d/2*c):new a.Point(s-d/2*h,l+d/2*c)}canvasArrow(e,t,n,i,o){const r=Math.atan2(i-t,o-n)+Math.PI;e.moveTo(t-this.arrowWidth*Math.sin(r-Math.PI/10),n-this.arrowWidth*Math.cos(r-Math.PI/10)),e.lineTo(t,n),e.lineTo(t-this.arrowWidth*Math.sin(r+Math.PI/10),n-this.arrowWidth*Math.cos(r+Math.PI/10))}}const q="dimensionality-reducer-terminate-event";var z,Y,K=n(3629);async function Z(e,t,i,o,s,a,l){let c=await async function(e,t,i,o,s,a,l){if(!a.distanceFnArgs)throw new Error("options.distanceFnArgs must be defined");if(e.length!==t.length||e.length!==a.distanceFnArgs.length||e.length!==o.length)throw new Error("data, metrics and options and weights must have the same length");return new Promise(function(c,h){const u=new Worker(new URL(n.p+n.u(234),n.b));u.postMessage({columnsData:e,distanceMetrics:t,method:i,options:a,weights:o,aggregationMethod:s});const d=r.events.onCustomEvent(q).subscribe(()=>{try{u?.terminate()}finally{d.unsubscribe()}});u.onmessage=({data:{error:e,embedding:t,epochNum:n,epochsLength:i}})=>{F(n)||F(i)?(d.unsubscribe(),e?h(e):c(t),setTimeout(()=>u.terminate(),100)):l&&l(n,i,t)}})}(e,i,t,o,s,a,l);return c=c.map(e=>(0,K.S8)(e)),c}(Y=z||(z={})).EUCLIDEAN="EUCLIDEAN",Y.MANHATTAN="MANHATTAN";const X={[z.EUCLIDEAN]:function(e){return`\n var sum = 0.0;\n for (var i = 0u; i < ${e}; i = i + 1u) {\n sum = sum + distances[i] * distances[i] * computeInfo.weights[i] * computeInfo.weights[i];\n }\n return sqrt(sum);\n `},[z.MANHATTAN]:function(e){return`\n var sum = 0.0;\n for (var i = 0u; i < ${e}; i = i + 1u) {\n sum = sum + abs(distances[i]) * computeInfo.weights[i];\n }\n return sum;\n `}};var J,Q;(Q=J||(J={})).HAMMING="Hamming",Q.EUCLIDEAN="Euclidean",Q.VECTOR_COSINE="Vector Cosine",Q.MANHATTAN="Manhattan",Q.TANIMOTO="Tanimoto",Q.LEVENSTEIN="Levenshtein",Q.NEEDLEMAN_WUNSCH="Needlemann-Wunsch",Q.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance",Q.SOKAL="Sokal",Q.COSINE="Cosine",Q.ASYMMETRIC="Asymmetric",Q.Difference="Difference",Q.OneHot="One-Hot";const ee={[J.HAMMING]:function(e,t){return`\n let aLength: u32 = computeInfo.entrySizes[${t}][aIndex];\n let bLength: u32 = computeInfo.entrySizes[${t}][bIndex];\n let maxLength: u32 = max(aLength, bLength);\n let minLength: u32 = min(aLength, bLength);\n let sizeDiff: u32 = maxLength - minLength;\n \n let maxIntDistance = ceil(maxDistance * f32(maxLength)) - f32(sizeDiff);\n\n var diff: f32 = 0.0;\n for (var i = 0u; i < ${e}; i = i + 1u) {\n diff = diff + f32(a[i] != b[i]);\n if (diff > maxIntDistance) {\n return 1.0;\n }\n }\n diff += f32(sizeDiff);\n return diff / ${e};\n `},[J.EUCLIDEAN]:function(e,t){return`\n var dist: f32 = 0.0;\n for (var i = 0u; i < ${e}; i = i + 1u) {\n dist = dist + f32(a[i] - b[i]) * f32(a[i] - b[i]);\n }\n return sqrt(dist);\n `},[J.MANHATTAN]:function(e,t){return`\n var dist: f32 = 0.0;\n for (var i = 0u; i < ${e}; i = i + 1u) {\n dist = dist + abs(f32(a[i] - b[i]));\n }\n return dist;\n `},[J.VECTOR_COSINE]:function(e,t){return`\n var dist: f32 = 0.0;\n var productSum: f32 = 0.0;\n var aSquareSum: f32 = 0.0;\n var bSquareSum: f32 = 0.0;\n for (var i = 0u; i < ${e}; i = i + 1u) {\n productSum = productSum + f32(a[i] * b[i]);\n aSquareSum = aSquareSum + f32(a[i] * a[i]);\n bSquareSum = bSquareSum + f32(b[i] * b[i]);\n }\n var sim = productSum / (sqrt(aSquareSum) * sqrt(bSquareSum));\n return (1.0 - sim) / 2.0;\n `},[J.TANIMOTO]:function(e,t){return`\n var onBitsa: u32 = 0u;\n var onBitsb: u32 = 0u;\n for (var i = 0u; i < ${e}u; i = i + 1u) {\n onBitsa = onBitsa + countOneBits(a[i]);\n onBitsb = onBitsb + countOneBits(b[i]);\n }\n\n if (onBitsa == 0u && onBitsb == 0u) {\n return 0.0;\n }\n\n let totalOnBits = onBitsa + onBitsb;\n var commonBits: u32 = 0u;\n for (var i = 0u; i < ${e}u; i = i + 1u) {\n commonBits = commonBits + countOneBits(a[i] & b[i]);\n }\n\n return 1.0 - f32(commonBits) / f32(totalOnBits - commonBits);\n `},[J.LEVENSTEIN]:function(e,t){return`\n let aLength: u32 = computeInfo.entrySizes[${t}][aIndex];\n let bLength: u32 = computeInfo.entrySizes[${t}][bIndex];\n let maxLength: u32 = max(aLength, bLength);\n let minLength: u32 = min(aLength, bLength);\n\n let maxIntDistance = ceil(maxDistance * f32(maxLength));\n\n // we will store two arrays as matrix and swap the working indices per pass.\n // this way we can reduce memory usage per computation to just O(aLength)\n // the grid will have aLength + 1 columns and bLength + 1 rows\n // this will be guaranteed by iteration, but the array sizes must be known at compile time, so we will use a fixed size of maxArraySize\n var dynamicPassMat: array<array<f32, ${e+1}u>, 2>; // initialize to 0\n \n var prevIndex: u32 = 0;\n var curIndex: u32 = 1; // we will swap these indices per pass\n\n // initialize the first row\n for (var i = 0u; i <= aLength; i = i + 1u) {\n dynamicPassMat[prevIndex][i] = f32(i);\n }\n\n // iterate over the rows\n for (var i = 1u; i <= bLength; i = i + 1u) {\n dynamicPassMat[curIndex][0] = f32(i);\n var minEntry: f32 = f32(maxLength);\n let prevRow = &dynamicPassMat[prevIndex];\n let curRow = &dynamicPassMat[curIndex];\n let bMon = u32(b[i - 1]);\n for (var j = 1u; j <= aLength; j = j + 1u) {\n var cost: f32 = f32(a[j - 1] != bMon);\n var res: f32 = min(\n min(\n (*prevRow)[j] + 1.0, // deletion\n (*curRow)[j - 1] + 1.0, // insertion\n ),\n (*prevRow)[j - 1] + cost // substitution\n );\n (*curRow)[j] = res;\n if (res < minEntry) {\n minEntry = res;\n }\n }\n // swap the indices\n let temp: u32 = prevIndex;\n prevIndex = curIndex;\n curIndex = temp;\n if (minEntry > maxIntDistance) {\n return 1.0;\n }\n }\n\n return dynamicPassMat[prevIndex][aLength] / f32(maxLength);\n `},[J.NEEDLEMAN_WUNSCH]:function(e,t){return`\n let aLength: u32 = computeInfo.entrySizes[${t}][aIndex];\n let bLength: u32 = computeInfo.entrySizes[${t}][bIndex];\n let maxLength: u32 = max(aLength, bLength);\n let minLength: u32 = min(aLength, bLength);\n \n let maxIntDistance = ceil(maxDistance * f32(maxLength));\n // we will store two arrays as matrix and swap the working indices per pass.\n // this way we can reduce memory usage per computation to just O(aLength)\n // the grid will have aLength + 1 columns and bLength + 1 rows\n // this will be guaranteed by iteration, but the array sizes must be known at compile time, so we will use a fixed size of maxArraySize\n var dynamicPassMat: array<array<f32, ${e+1}u>, 2>; // initialize to 0\n \n // we need to keep track of which operation led to the current cell\n // i.e. whether we came from the left, top or diagonal to assign gap open/gap extend penalty\n var verticalGaps: array<u32, ${e+1}u>;\n var horizontalGaps: array<u32, ${e+1}u>;\n\n let gapOpenPenalty: f32 = suppInfo.gapOpenPenalty${t};\n let gapExtensionPenalty: f32 = suppInfo.gapExtensionPenalty${t};\n var prevIndex: u32 = 0;\n var curIndex: u32 = 1; // we will swap these indices per pass\n // initialize the first row\n for (var i = 0u; i <= aLength; i = i + 1u) {\n dynamicPassMat[prevIndex][i] = gapExtensionPenalty + f32(i - 1) * gapExtensionPenalty; // accounting for the fact that left and right gaps are less costly\n dynamicPassMat[curIndex][i] = 0.0;\n }\n dynamicPassMat[0][0] = 0.0;\n\n let simMatrix = &suppInfo.similarityMatrix${t}; // using pointers make things faster\n // iterate over the rows\n for (var i = 1u; i <= bLength; i = i + 1u) {\n let prevRow = &dynamicPassMat[prevIndex];\n let curRow = &dynamicPassMat[curIndex];\n (*curRow)[0] = gapExtensionPenalty + f32(i - 1) * gapExtensionPenalty;\n var minEntry: f32 = f32(maxLength);\n let monB = u32(b[i - 1]);\n for (var j = 1u; j <= aLength; j = j + 1u) {\n let monA = u32(a[j - 1]);\n \n let cost: f32 = (*prevRow)[j - 1] + 1f - (*simMatrix)[monA][monB];\n var top = (*prevRow)[j]; // deletion\n if (verticalGaps[j] > 0 || i == 1 || i == bLength) {\n top = top + gapExtensionPenalty;\n } else {\n top = top + gapOpenPenalty;\n }\n var left = (*curRow)[j - 1]; // insertion\n if (horizontalGaps[j - 1] > 0 || j == 1 || j == aLength) {\n left = left + gapExtensionPenalty;\n } else {\n left = left + gapOpenPenalty;\n }\n var res: f32 = min(\n min(\n top, // deletion\n left, // insertion\n ),\n cost // substitution\n );\n (*curRow)[j] = res;\n if (res < minEntry) {\n minEntry = res;\n }\n // update the horizontal and vertical gaps\n if (res == cost) {\n verticalGaps[j] = 0;\n horizontalGaps[j] = 0;\n } else if (res == left) {\n verticalGaps[j] = 0;\n horizontalGaps[j] = 1;\n } else {\n verticalGaps[j] = 1;\n horizontalGaps[j] = 0;\n }\n }\n // swap the indices\n let temp: u32 = prevIndex;\n prevIndex = curIndex;\n curIndex = temp;\n if (minEntry > maxIntDistance) {\n return 1.0;\n }\n }\n return dynamicPassMat[prevIndex][aLength] / f32(minLength);\n\n `},[J.MONOMER_CHEMICAL_DISTANCE]:function(e,t){return`\n let aLength: u32 = computeInfo.entrySizes[${t}][aIndex];\n let bLength: u32 = computeInfo.entrySizes[${t}][bIndex];\n let maxLength: u32 = max(aLength, bLength);\n let minLength: u32 = min(aLength, bLength);\n let sizeDiff: u32 = maxLength - minLength;\n \n let maxIntDistance = ceil(maxDistance * f32(maxLength)) - f32(sizeDiff);\n\n let simMatrix = &(suppInfo.similarityMatrix${t}); // using pointers make things faster\n var diff: f32 = 0.0;\n for (var i = 0u; i < ${e}; i = i + 1u) {\n diff = diff + 1.0 - (*simMatrix)[u32(a[i])][u32(b[i])];\n if (diff > maxIntDistance) {\n return 1.0;\n }\n }\n diff += f32(sizeDiff);\n return diff / ${e};\n `},[J.SOKAL]:function(e,t){return`\n var onBitsa: u32 = 0u;\n var onBitsb: u32 = 0u;\n for (var i = 0u; i < ${e}u; i = i + 1u) {\n onBitsa = onBitsa + countOneBits(a[i]);\n onBitsb = onBitsb + countOneBits(b[i]);\n }\n let total = onBitsa + onBitsb;\n if (total == 0u) {\n return 1.0;\n }\n var commonBits: u32 = 0u;\n for (var i = 0u; i < ${e}u; i = i + 1u) {\n commonBits = commonBits + countOneBits(a[i] & b[i]);\n }\n return 1.0 - f32(commonBits) / f32(total * 2 - commonBits * 3);\n `},[J.COSINE]:function(e,t){return`\n var onBitsa: u32 = 0u;\n var onBitsb: u32 = 0u;\n for (var i = 0u; i < ${e}u; i = i + 1u) {\n onBitsa = onBitsa + countOneBits(a[i]);\n onBitsb = onBitsb + countOneBits(b[i]);\n }\n let total = onBitsa * onBitsb; // p.s. here total is taken by multiplying\n if (total == 0u) {\n return 1.0;\n }\n var commonBits: u32 = 0u;\n for (var i = 0u; i < ${e}u; i = i + 1u) {\n commonBits = commonBits + countOneBits(a[i] & b[i]);\n }\n return 1.0 - f32(commonBits) / sqrt(f32(total));\n `},[J.ASYMMETRIC]:function(e,t){return`\n var onBitsa: u32 = 0u;\n var onBitsb: u32 = 0u;\n for (var i = 0u; i < ${e}u; i = i + 1u) {\n onBitsa = onBitsa + countOneBits(a[i]);\n onBitsb = onBitsb + countOneBits(b[i]);\n }\n let min = min(onBitsa, onBitsb);\n if (min == 0u) {\n return 1.0;\n }\n var commonBits: u32 = 0u;\n for (var i = 0u; i < ${e}u; i = i + 1u) {\n commonBits = commonBits + countOneBits(a[i] & b[i]);\n }\n return 1.0 - f32(commonBits) / f32(min);\n `},[J.Difference]:function(e,t){return`\n let range = suppInfo.range${t};\n return f32(abs(f32(a[0]) - f32(b[0])) / range);\n `},[J.OneHot]:function(e,t){return`\n let aLength: u32 = computeInfo.entrySizes[${t}][aIndex];\n let bLength: u32 = computeInfo.entrySizes[${t}][bIndex];\n if (aLength != bLength) {\n return 1.0;\n }\n for (var i = 0u; i < aLength; i = i + 1u) {\n if(a[i] != b[i]) {\n return 1.0;\n }\n }\n return 0.0;\n `}},te={[J.HAMMING]:e=>Math.ceil(e/30),[J.EUCLIDEAN]:e=>Math.ceil(e/30),[J.MANHATTAN]:e=>Math.ceil(e/30),[J.TANIMOTO]:e=>Math.ceil(e/30),[J.SOKAL]:e=>Math.ceil(e/30),[J.COSINE]:e=>Math.ceil(e/30),[J.ASYMMETRIC]:e=>Math.ceil(e/30),[J.LEVENSTEIN]:e=>Math.ceil(e*e/60),[J.NEEDLEMAN_WUNSCH]:e=>Math.ceil(e*e/60),[J.MONOMER_CHEMICAL_DISTANCE]:e=>Math.ceil(e/25),[J.Difference]:e=>1,[J.OneHot]:e=>Math.ceil(e/40),[J.VECTOR_COSINE]:e=>Math.ceil(e/30)},ne={STRING:new Set([J.HAMMING,J.LEVENSTEIN,J.NEEDLEMAN_WUNSCH,J.MONOMER_CHEMICAL_DISTANCE,J.OneHot]),UINT32ARRAY:new Set([J.HAMMING,J.EUCLIDEAN,J.MANHATTAN,J.MONOMER_CHEMICAL_DISTANCE,J.LEVENSTEIN,J.NEEDLEMAN_WUNSCH,J.TANIMOTO,J.COSINE,J.VECTOR_COSINE,J.SOKAL,J.ASYMMETRIC,J.OneHot,J.Difference]),INT32ARRAY:new Set([J.EUCLIDEAN,J.MANHATTAN,J.OneHot,J.Difference,J.VECTOR_COSINE]),FLOAT32ARRAY:new Set([J.EUCLIDEAN,J.MANHATTAN,J.Difference,J.VECTOR_COSINE]),NUMBER:new Set([J.EUCLIDEAN,J.MANHATTAN,J.Difference]),BITARRAY:new Set([J.TANIMOTO,J.COSINE,J.SOKAL,J.ASYMMETRIC])};function ie(e,t=.8,n,i,o,r){return function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function s(e){try{l(i.next(e))}catch(e){r(e)}}function a(e){try{l(i.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((i=i.apply(e,t||[])).next())})}(this,void 0,void 0,function*(){const s=yield function(){return E(this,void 0,void 0,function*(){if(!navigator.gpu)return console.error("WebGPU is not supported in this browser"),null;if(!M&&(M=yield navigator.gpu.requestAdapter({powerPreference:"high-performance"}),null==M))return null;let e=!1;if(T&&(T.lost.then(()=>{e=!0}),yield new Promise(e=>setTimeout(e,10))),!T||e){const e=1e9,t=M.limits,n=t.maxBufferSize,i=t.maxStorageBufferBindingSize;try{return T=yield M.requestDevice({requiredLimits:{maxBufferSize:Math.min(n,e),maxStorageBufferBindingSize:Math.min(i,e)}}),T}catch(e){return console.error("Failed to create device with required limits",e),T=yield M.requestDevice(),T}}return T})}();if(!s)return null;const a=Object.values(J);if(n.some(e=>!a.includes(e)))throw new Error("Invalid distance metrics provided: "+n.join(", "));if(!Object.values(z).includes(i))throw new Error("Invalid aggregation function provided: "+i);const l=1-t;if(r.length!==e.length||r.length!==n.length||r.length!==o.length)throw new Error("Options, weigths and distance functions must be provided for each column");if(e.some(t=>t.length!==e[0].length))throw new Error("All entry lists must be the same length");const c=e.length,h=e[0].length,u=e.map((e,t)=>function(e,t=J.HAMMING,n,i={gapOpenPenalty:1,gapExtensionPenalty:.6}){var o,r;let s=null;const a=e.some(e=>"string"==typeof e)?(s="STRING",e.map(e=>new Uint32Array(e.split("").map(e=>e.charCodeAt(0))))):e.some(e=>"number"==typeof e)?(s="NUMBER",e.map(e=>new Float32Array([e]))):"object"==typeof e[0]&&e.some(e=>"_data"in e&&"_length"in e)?(s="BITARRAY",e.map(e=>e._data)):e.some(e=>e instanceof Float32Array)?(s="FLOAT32ARRAY",e):e.some(e=>e instanceof Uint32Array)?(s="UINT32ARRAY",e):e.some(e=>e instanceof Int32Array)?(s="INT32ARRAY",e):void 0;if(!a||!s)throw new Error("Invalid entry type, could not determine entry type from input list");const l=a[0]instanceof Int32Array?"INT32ARRAY":a[0]instanceof Float32Array?"FLOAT32ARRAY":"UINT32ARRAY",c=new Uint32Array(a.map(e=>e.length));if(!ne[s]||!ne[s].has(t))throw new Error(`Distance metric '${t}' not supported for entry type '${s}'`);const h=c.reduce((e,t)=>Math.max(e,t),0),u=te[t](h),d="INT32ARRAY"===l?Int32Array:"FLOAT32ARRAY"===l?Float32Array:Uint32Array,p=new d(a.length*h);a.forEach((e,t)=>{p.set(e,t*h)});let m="",g=0,f="FLOAT32ARRAY",y=null;if(t===J.NEEDLEMAN_WUNSCH||t===J.MONOMER_CHEMICAL_DISTANCE){let e=i.scoringMatrix&&i.alphabetIndexes?Object.keys(i.alphabetIndexes).reduce((e,t)=>Math.max(e,t.charCodeAt(0)),0):-1;if(!i.alphabetIndexes||!i.scoringMatrix){for(let t=0;t<p.length;t++)p[t]>e&&(e=p[t]);i.scoringMatrix=new Array(e+1).fill(null).map(()=>new Array(e+1).fill(0)),i.alphabetIndexes={};for(let e=0;e<i.scoringMatrix.length;e++)i.scoringMatrix[e][e]=1,i.alphabetIndexes[String.fromCharCode(e)]=e}const t=(e+1)*(e+1),s=new Array(e+1).fill(null).map(()=>new Float32Array(e+1));for(let t=0;t<e+1;t++)s[t][t]=1;const a=i.alphabetIndexes;for(const e of Object.keys(a))for(const t of Object.keys(a))e!==t&&(s[e.charCodeAt(0)][t.charCodeAt(0)]=i.scoringMatrix[a[e]][a[t]]);g=2+t,f="FLOAT32ARRAY",y=new Float32Array(g),y[0]=null!==(o=i.gapOpenPenalty)&&void 0!==o?o:1,y[1]=null!==(r=i.gapExtensionPenalty)&&void 0!==r?r:.6;let l=2;for(let e=0;e<s.length;e++)y.set(s[e],l),l+=s[e].length;m=`\n gapOpenPenalty${n}: f32,\n gapExtensionPenalty${n}: f32,\n similarityMatrix${n}: array<array<f32, ${e+1}>, ${e+1}>`}else if(t===J.Difference){if(!i.range||"number"!=typeof i.range||i.range<=0){const e=p.reduce((e,t)=>Math.min(e,t),p[0]),t=p.reduce((e,t)=>Math.max(e,t),p[0]);i.range=t-e}i.range<=0&&(i.range=1),g=1,f="FLOAT32ARRAY",y=new Float32Array([i.range]),m=`\n range${n}: f32`}const b=p instanceof Int32Array?"i32":p instanceof Float32Array?"f32":"u32",v=`data${n}: array<array<${b}, ${h}>, ${a.length}>`;return{flatSourceArray:p,sourceArraySize:p.length,maxEntryLen:h,arraySizes:c,complexity:u,suppInfoBuffer:y,suppInfoSize:g,suppInfoType:f,suppInfoStructWgsl:m,entryType:s,dataTypeWGSL:b,dataStructWgsl:v,EncodedArrayConstructor:d}}(e,n[t],t,r[t]));if(0===c)throw new Error("No columns provided. Please provide at least one column of data.");1===c&&(i=z.MANHATTAN);let d=u.map(e=>e.suppInfoStructWgsl).filter(e=>!!e&&""!=e).join(",\n"),p=!1;d&&""!=d.trim()||(p=!0,d="\ndummy: f32\n");const m=u.map(e=>e.dataStructWgsl).filter(e=>!!e&&""!=e).join(",\n"),g=new Uint32Array(c*h);u.forEach((e,t)=>{g.set(e.arraySizes,t*h)});const f=1e4,y=100,b=u.reduce((e,t)=>e+t.complexity,0),v=Math.ceil(6e3/b),w=Math.ceil(Math.sqrt(Math.ceil(100))),C=10*w,S=h*(h-1)/2,A=Math.ceil(S/f),x=s.createShaderModule({label:"Sparse matrix compute shader",code:`\n // each thread will perform 100 iterations at one time, comparing 100 pairs of entries.\n // in total, each thread will perform at most ${A} comparisons.\n // first is the result struct, containing is, js, and distances. each array with length of 100,\n // and also integer for how many pairs were found to be below threshold.\n struct SparseResult {\n i: array<array<u32, 100>, 10000>,\n j: array<array<u32, 100>, 10000>,\n distances: array<array<f32, 100>, 10000>,\n found: array<u32, 10000>,\n done: array<u32, 10000>\n }\n // struct for the data\n struct ComputeInfo {\n // start at cols and rows, and end at cols and rows for each thread, these will be calculated on cpu and passed to gpu.\n startAtCols: array<u32, 10000>,\n startAtRows: array<u32, 10000>,\n endAtCols: array<u32, 10000>,\n endAtRows: array<u32, 10000>,\n\n // the ACTUALLY sizes of each entry\n entrySizes: array<array<u32, ${h}>, ${c}>,\n // the weights for each entry\n weights: array<f32, ${c}>,\n // the data for each entry\n ${m} // an example of the dataWgsl would be:\n //data0: array<array<u32,20>,100>,\n //data1: array<array<u32,20>,100>\n }\n\n // struct for the supplementary information\n struct SuppInfo {\n // struct containing all the supplementary info, like scoring matrix, alphabet indexes, range, etc.\n ${d}\n };\n\n @group(0) @binding(0) var<storage, read_write> computeInfo: ComputeInfo;\n @group(0) @binding(1) var<storage, read_write> suppInfo: SuppInfo;\n @group(0) @binding(2) var<storage, read_write> results: SparseResult;\n @compute @workgroup_size(10, 10) fn calcSparseMatrix(\n @builtin(global_invocation_id) id: vec3<u32>\n ) {\n ${p?"let otherDummy = suppInfo.dummy * 2;":""} // just to make sure that the suppInfo is not optimized out\n let threadCol = id.x;\n let threadRow = id.y;\n let linearIndex = threadRow * ${C} + threadCol;\n if (linearIndex >= 10000) {\n return; // if we are out of bounds, return\n } \n var startAtCol: u32 = computeInfo.startAtCols[linearIndex];\n var startAtRow: u32 = computeInfo.startAtRows[linearIndex];\n let endAtCol: u32 = min(computeInfo.endAtCols[linearIndex], ${h}u);\n let endAtRow: u32 = min(computeInfo.endAtRows[linearIndex], ${h}u);\n let is = &results.i[linearIndex];\n let js = &results.j[linearIndex];\n let distances = &results.distances[linearIndex];\n results.found[linearIndex] = 0; // initialize the found counter\n var found: u32 = 0;\n if (results.done[linearIndex] > 0) {\n return; // if we are done, return\n }\n for (var i = 0; i < ${v}; i++) {\n if (startAtCol >= endAtCol && startAtRow >= endAtRow) {\n results.done[linearIndex] = 1;\n break;\n }\n if (found >= 100) {\n break;\n }\n let dist = combinedDistance(startAtCol, startAtRow);\n if (dist <= ${l}) {\n (*is)[found] = startAtCol;\n (*js)[found] = startAtRow;\n (*distances)[found] = dist;\n found = found + 1;\n }\n startAtCol = startAtCol + 1;\n if (startAtCol >= ${h}u) {\n startAtRow += 1;\n startAtCol = startAtRow + 1;\n }\n }\n results.found[linearIndex] = found;\n // update the startAtCols and startAtRows\n computeInfo.startAtCols[linearIndex] = startAtCol;\n computeInfo.startAtRows[linearIndex] = startAtRow;\n\n }\n\n // this will generate the distance script for each distance metric and then combine them into one\n ${oe(n,u.map(e=>e.maxEntryLen),l,i)}\n\n\n `}),_=s.createComputePipeline({label:"sparse matrix compute pipeline",layout:"auto",compute:{module:x,entryPoint:"calcSparseMatrix"}}),I=new Uint32Array(f),L=new Uint32Array(f),N=new Uint32Array(f),P=new Uint32Array(f),R=Math.floor(S/f);let $=0,O=1;console.time("GPUthreadStarts");for(let e=0;e<f;e++){const t=9999===e?S-1:(e+1)*R,n=h-2-Math.floor(Math.sqrt(-8*t+4*h*(h-1)-7)/2-.5),i=t-h*n+Math.floor((n+1)*(n+2)/2);I[e]=O,L[e]=$,N[e]=i,P[e]=n,$=n,O=i}console.timeEnd("GPUthreadStarts");const k=4e4+h*c+c+u.reduce((e,t)=>e+t.sourceArraySize,0),H=u.reduce((e,t)=>e+t.suppInfoSize,0),F=1e6,G=k*Uint32Array.BYTES_PER_ELEMENT;let B=G;const D=15&G;0!==D&&(B+=16-D);const V=s.createBuffer({label:"compute info buffer",size:B,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST,mappedAtCreation:!0}),W=V.getMappedRange();let j=0;new Uint32Array(W,j,f).set(I),j+=f*Uint32Array.BYTES_PER_ELEMENT,new Uint32Array(W,j,f).set(L),j+=f*Uint32Array.BYTES_PER_ELEMENT,new Uint32Array(W,j,f).set(N),j+=f*Uint32Array.BYTES_PER_ELEMENT,new Uint32Array(W,j,f).set(P),j+=f*Uint32Array.BYTES_PER_ELEMENT,new Uint32Array(W,j,g.length).set(g),j+=g.length*Uint32Array.BYTES_PER_ELEMENT,new Float32Array(W,j,c).set(o),j+=c*Float32Array.BYTES_PER_ELEMENT;for(const e of u){const t=e.EncodedArrayConstructor,n=e.sourceArraySize;new t(W,j,n).set(e.flatSourceArray),j+=n*t.BYTES_PER_ELEMENT}V.unmap();const U=H*Uint32Array.BYTES_PER_ELEMENT;let q=U;const Y=15&U;0!==Y&&(q+=16-Y),q=Math.max(q,16);const K=s.createBuffer({label:"supp info buffer",size:q,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST,mappedAtCreation:!0}),Z=K.getMappedRange();let X=0;for(const e of u)e.suppInfoBuffer&&e.suppInfoBuffer.byteLength>0&&e.suppInfoSize>0&&(new("UINT32ARRAY"===e.suppInfoType?Uint32Array:Float32Array)(Z,X,e.suppInfoBuffer.length).set(e.suppInfoBuffer),X+=e.suppInfoBuffer.byteLength);0===X&&new Uint32Array(Z,0,4).set([1,1,1,1]),K.unmap();const Q=302e4*Uint32Array.BYTES_PER_ELEMENT;let ee=Q;const ie=15&Q;0!==ie&&(ee+=16-ie);const re=s.createBuffer({label:"results buffer",size:ee,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_SRC}),se=s.createBindGroup({label:"bindGroup for sparse matrix buffer",layout:_.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:V}},{binding:1,resource:{buffer:K}},{binding:2,resource:{buffer:re}}]}),ae=s.createBuffer({label:"results out buffer",size:re.size,usage:GPUBufferUsage.MAP_READ|GPUBufferUsage.COPY_DST}),le=[],ce=[],he=[];let ue=!1;for(;!ue;){const e=s.createCommandEncoder({label:"distance encoder"}),t=e.beginComputePass({label:"distance compute pass"});t.setPipeline(_),t.setBindGroup(0,se),t.dispatchWorkgroups(w,w),t.end(),e.copyBufferToBuffer(re,0,ae,0,ae.size);const n=e.finish();s.queue.submit([n]),yield s.queue.onSubmittedWorkDone(),yield ae.mapAsync(GPUMapMode.READ);const i=ae.getMappedRange();let o=0;const r=new Uint32Array(i,o,F);o+=F*Uint32Array.BYTES_PER_ELEMENT;const a=new Uint32Array(i,o,F);o+=F*Uint32Array.BYTES_PER_ELEMENT;const l=new Float32Array(i,o,F);o+=F*Float32Array.BYTES_PER_ELEMENT;const c=new Uint32Array(i,o,f);o+=f*Uint32Array.BYTES_PER_ELEMENT,ue=new Uint32Array(i,o,f).every(e=>1===e);const h=c.reduce((e,t)=>e+t,0),u=new Uint32Array(h),d=new Uint32Array(h),p=new Float32Array(h);let m=0;for(let e=0;e<c.length;e++){const t=c[e];0!==t&&(u.set(r.subarray(e*y,e*y+t),m),d.set(a.subarray(e*y,e*y+t),m),p.set(l.subarray(e*y,e*y+t),m),m+=t)}le.push(u),ce.push(d),he.push(p),ae.unmap()}const de=le.reduce((e,t)=>e+t.length,0),pe=new Uint32Array(de),me=new Uint32Array(de),ge=new Float32Array(de);let fe=0;for(let e=0;e<le.length;e++)pe.set(le[e],fe),me.set(ce[e],fe),ge.set(he[e],fe),fe+=le[e].length;return V.destroy(),K.destroy(),re.destroy(),ae.destroy(),{i:pe,j:me,distance:ge}})}function oe(e,t,n,i){return e.map((e,i)=>`\n fn distanceScript${i}(aIndex: u32, bIndex: u32) -> f32 {\n let a = computeInfo.data${i}[aIndex];\n let b = computeInfo.data${i}[bIndex];\n let maxDistance: f32 = ${n};\n ${ee[e](t[i],i)}\n }\n `).join("\n")+"\n"+`\n fn combinedDistance(aIndex: u32, bIndex: u32) -> f32 {\n var distances: array<f32, ${e.length}>;\n ${e.map((e,t)=>`distances[${t}] = distanceScript${t}(aIndex, bIndex);`).join("\n")}\n ${X[i](e.length)}\n }\n \n `}let re=0;const se="cliffsDf",ae=new h.Subject,le="SALI",ce="line index",he=["From","To"],ue="filterCliffs";async function de(e,t,i,o,l,c,h,u,d,p,m,g,f,y,b,v,w){re++;const C=c/100;let S,A=!1;const x=g.inputs,E=await g.apply({[x[0].name]:t,[x[1].name]:h,...d.preprocessingFuncArgs??{}});let M=[];if(u===N){const t=await function(e,t,i,o,r,s,a=10,l=!1,c=2){const h=new Worker(new URL(n.p+n.u(980),n.b));let u;return h.postMessage({data:e,threshold:t,weights:i,aggregationMethod:o,distanceFns:r,distanceFnArgs:s,maxIterations:a,useWebGPU:l,inflate:c}),{promise:new Promise((e,t)=>{u=e,h.onmessage=t=>{setTimeout(()=>h.terminate(),100),e(t.data.res)},h.onerror=e=>{setTimeout(()=>h.terminate(),100),t(e)}}),terminate:()=>{try{u(null),h.terminate()}catch(e){console.error(e)}}}}([E.entries],c,[1],"MANHATTAN",[h],[E.options??{}],d?.maxIterations??5,d.useWebGPU??!1).promise;e.columns.addNewInt(e.columns.getUnusedName("MCL Cluster")).init(e=>t.clusters[e]),M=[t.embedX,t.embedY]}else M=await Z([E.entries],u,[h],[1],"MANHATTAN",{...d,distanceFnArgs:[E.options??{}]});if(M.length!==i.length)throw new Error("Number of axes names should be equal to number of embedding dimensions");for(let t=0;t<M.length;++t)e.columns.addNewFloat(i[t]).init(e=>M[t][e]);let T=null;if(d.useWebGPU)try{T=await ie([E.entries],C,[h],z.MANHATTAN,[1],[E.options??{}])}catch(e){console.error(e)}T||(d.useWebGPU&&console.error("WebGPU sparse matrix calculation failed, falling back to CPU implementation"),T=await(new D).calc(E.entries,h,C,E.options));const _=await async function(e,t){const n=e.distance.map((n,i)=>{const o=Math.abs(t.get(e.i[i])-t.get(e.j[i]));return 0!=n?o/n:1/0}),i=e.distance.map(e=>1-e),o=e.i,r=e.j,s=a.BitSet.create(t.length);return e.distance.forEach((t,n)=>{s.set(e.i[n],!0),s.set(e.j[n],!0)}),{simVals:i,saliVals:n,n1:o,n2:r,cliffsBitSet:s}}(T,l),I=function(e,t,n,i,o,r,s){const l=new Array(e).fill(0);for(let e=0;e!=i.length;++e)n[e]!=1/0&&(s.get(i[e])>s.get(o[e])?l[i[e]]+=n[e]:l[o[e]]+=n[e]);return a.Column.fromList("double",t,l)}(t.length,`sali_${i[0].substring(i[0].lastIndexOf("_"))}`,_.saliVals,_.n1,_.n2,0,l);e.columns.add(I);const L=_.cliffsBitSet,P=function(e){const t=e.filter(e=>e!==1/0),n=t.reduce((e,t)=>Math.min(e,t),Number.MAX_VALUE);return{max:t.reduce((e,t)=>Math.max(e,t),n),min:n}}(_.saliVals),$=.8/(P.max-P.min),O=r.shell.tv?.dataFrame===e?r.shell.tv:r.shell.getTableView(e.name),H=O.addViewer(a.VIEWER.SCATTER_PLOT,{xColumnName:i[0],yColumnName:i[1],size:I.name,color:l.name,showXSelector:!1,showYSelector:!1,showSizeSelector:!1,showColorSelector:!1,markerMinSize:5,markerMaxSize:25,title:o}),F=function(e,t,n,i,o,r,s,l){const c={from:new Uint32Array(t.n1.length),to:new Uint32Array(t.n1.length),opacities:new Float32Array(t.n1.length),colors:new Array(t.n1.length),widths:new Float32Array(t.n1.length)};for(let n=0;n<t.n1.length;n++)c.from[n]=t.n1[n],c.to[n]=t.n2[n],c.opacities[n]=t.saliVals[n]===1/0?1:.2+(t.saliVals[n]-s.min)*l,c.colors[n]=e.selection.get(c.from[n])&&e.selection.get(c.to[n])?"255,255,0":"0,128,0",c.widths[n]=1;const h=a.DataFrame.create(c.from.length);return he.forEach((e,t)=>{h.columns.addNewString(e).init(e=>n.get(0===t?c.from[e]:c.to[e])),function(e,t){Object.keys(t).forEach(n=>{e.tags[n]=t[n]})}(h.col(e),r),h.col(e).semType=o}),h.columns.addNewFloat("Δ activity").init(e=>Math.abs(i.get(c.from[e])-i.get(c.to[e]))),h.columns.addNewInt(ce).init(e=>e),h.columns.addNewFloat(le).init(e=>t.saliVals[e]),h.columns.addNewFloat("Similarity").init(e=>t.simVals[e]),h.name=`${se}${re}`,{lines:c,linesDf:h}}(e,_,t,l,p,m,P,$);F.lines.skipMultiLineCalculation=!0,F.linesDf.col(le).setTag("description","Structure−Activity Landscape Index (activity difference divided by 1 minus similarity)");const G=new U(H,i[0],i[1],F.lines,V.none),B=b?b(F.linesDf,he).sort([le],[!1]):F.linesDf.plot.grid().sort([le],[!1]);B.col(ce)&&(B.col(ce).visible=!1),e.temp[".cliffsDfGrid"]=B;const W=s.button(`${F.linesDf.rowCount} cliffs`,()=>{const e=R()(O.viewers).some(e=>e.dataFrame.name===`${se}${re}`);w&&!e&&O.addViewer(B),O.dockManager.dock(B,"down",null,"Activity cliffs",v??.2)});W.classList.add("scatter_plot_link","cliffs_grid");const j=s.input.toggle("Show only cliffs",{value:!1,onValueChanged:t=>{t?(H.dataFrame.setTag(ue,i[0]),e.filter.and(L),ae.next(i[0])):(H.dataFrame.setTag(ue,""),e.filter.setAll(!0),ae.next(""))}});H.root.prepend(s.divH([W,j.root],"cliffs_div")),ae.subscribe(e=>{j.enabled=""===e||e===i[0]}),e.onRowsFiltering.subscribe(()=>{j.value&&e.filter.and(_.cliffsBitSet)});const q=r.events.onViewerClosed.subscribe(e=>{e.args.viewer===H&&(O.dockManager.close(B.root),q.unsubscribe(),O.subs=O.subs.filter(e=>e!==q))});return O.subs.push(q),F.linesDf.onCurrentCellChanged.subscribe(()=>{for(let e=0;e<F.linesDf.rowCount;e++)F.lines.widths[e]=e===F.linesDf.currentRowIdx?3:1;G.linesToRender=F.lines;const n=F.linesDf.currentCol&&F.linesDf.currentCol.name===he[1]?F.lines.to:F.lines.from,o=-1!==F.linesDf.currentRowIdx?F.linesDf.currentRowIdx:null;if(H.dataFrame.currentRowIdx=o?n[o]:-1,null!==o){const n=F.linesDf.currentRowIdx;G.currentLineId=n;const{zoomLeft:a,zoomRight:c,zoomTop:h,zoomBottom:u}=function(e,t,n,i,o,r){const s=Math.abs(n-o),a=Math.abs(i-r),l=e/s,c=t/a,h=Math.min(l,c),u=e/h*5,d=t/h*5,p=(n<o?n:o)+s/2-u/2,m=(i>r?i:r)-a/2+d/2;return{zoomLeft:p,zoomRight:p+u,zoomTop:m,zoomBottom:m-d}}(H.viewport.width,H.viewport.height,H.dataFrame.get(i[0],F.lines.from[n]),H.dataFrame.get(i[1],F.lines.from[n]),H.dataFrame.get(i[0],F.lines.to[n]),H.dataFrame.get(i[1],F.lines.to[n]));H.zoom(a,h,c,u),j.value?e.filter.and(L):!0===j.enabled&&e.filter.setAll(!0),setTimeout(()=>{!function(e,t,n,i,o,a,l,c,h){const u=t.getPane("Cliff Details");s.empty(u.root);const d=h({points:[n,i],lineId:o,df:e,seqCol:a,activityCol:l,sali:c});u.root.append(d),setTimeout(()=>{r.shell.o=t.root},500)}(e,S,F.lines.from[o],F.lines.to[o],o,t,l,F.linesDf.get(le,o),y);const n=H.dataFrame.getSortedOrder(O.grid.sortByColumns,O.grid.sortTypes);O.grid.scrollToCell(t.name,n.indexOf(H.dataFrame.currentRowIdx))},1e3)}}),F.linesDf.onSelectionChanged.subscribe(t=>{setTimeout(()=>(()=>{const t=a.BitSet.create(e.rowCount);for(let e=0;e<F.linesDf.rowCount;e++){const n=F.linesDf.selection.get(e);n&&(t.set(F.lines.from[e],!0),t.set(F.lines.to[e],!0)),F.lines.colors[e]=n?"255,255,0":"0,128,0"}e.selection.copyFrom(t),G.linesToRender=F.lines})(),100)}),e.onSelectionChanged.subscribe(t=>{!1===e.selection.anyTrue&&"number"==typeof t&&(A?A=!1:(e=>{e.selection.setAll(!1);for(let e=0;e<F.lines.colors.length;e++)F.lines.colors[e]="0,128,0";G.linesToRender=F.lines})(B.dataFrame))}),G.lineClicked.subscribe(t=>{if(A=!0,G.currentLineId=t.id,-1!==t.id){const n=F.linesDf.selection.clone();setTimeout(()=>{t.event.ctrlKey?(n.set(t.id,!n.get(t.id)),F.linesDf.selection.copyFrom(n)):(F.linesDf.currentRowIdx!==t.id&&(F.linesDf.currentRowIdx=t.id,e.currentRowIdx=F.lines.from[t.id]),F.linesDf.selection.copyFrom(n));const i=F.linesDf.getSortedOrder(B.sortByColumns,B.sortTypes);B.scrollToCell(he[0],i.indexOf(t.id))},500)}}),G.lineHover.pipe((0,k.debounceTime)(500)).subscribe(n=>{-1!==n.id&&-1===e.mouseOverRowIdx&&s.tooltip.show(f({lineId:n.id,points:[F.lines.from[n.id],F.lines.to[n.id]],df:e,seqCol:t,activityCol:l}),n.x,n.y)}),H.addProperty("similarityLimit","double",C),S=function(){const e=s.accordion(),t=s.element("i");return t.className="grok-icon svg-icon svg-view-layout",e.addTitle(s.span([t,s.label("Activity cliffs")])),e.addPane("Cliff Details",()=>s.divText("Cliff has not been selected"),!0),r.shell.o=e.root,e}(),H}var pe=n(6863),me=n(2003),ge=n(3516),fe=n(3151);function ye(e,t){const n=e=>o[e]??null,i=e=>{const t=s.columns.addNewString((e+1).toString());return o.push(t),t},o=[],r=e.length,s=a.DataFrame.create(r),l=t.getSeqHandler(e);for(let e=0;e<r;++e){const t=l.getSplitted(e);for(let o=0;o<t.length;++o){const r=t.getCanonical(o);(n(o)||i(o)).set(e,r,!1)}}return s}var be,ve=n(439),we=n(4971);async function Ce(e){const t=(await(0,we.pj)()).getMonomerLib(),n=[],i={},o=e.map(e=>t.getMonomer("PEPTIDE",e)?.smiles??""),s=a.Column.fromStrings("smiles",o);for(let t=0;t<o.length;++t){i[e[t]]=t;const a=o[t],l=""===a?new Array(o.length).fill(0):(await r.chem.getSimilarities(s,a)).getRawData();l[t]=1,n[t]=Array.from(l)}return{scoringMatrix:n,alphabetIndexes:i}}!function(e){e.IDENTITY="identity",e.SIMILARITY="similarity"}(be||(be={}));var Se=n(9192);class Ae{constructor(){this.maxIterations={uiName:"Max iterations",value:0,tooltip:"Maximum iterations for MCL process.Default is \n 0 which will construct the clusters with plain sparse matrix. Values greater than 0 will \n perform MCL with the given number of iterations and will result in trans-cluster activity cliff lines."},this.useWebGPU={uiName:"Use WebGPU",value:!1,tooltip:"Use WebGPU for MCL calculation. (Experimental)",type:"boolean"}}}class xe extends O{constructor(e={}){super({...e,enableMCL:!0});const t=Array.from(this.tableInput.value.columns.numericalNoDateTime);this.activitiesInput=s.input.column("Activities",{table:this.tableInput.value,value:t.length?t[0]:null,filter:e=>t.includes(e)}),this.activitiesInputRoot=this.activitiesInput.root,this.similarityInput=s.input.int("Similarity cutoff",{value:80}),this.methodsParams[N]=new Ae}onTableInputChanged(){if(super.onTableInputChanged(),this.activitiesInputRoot){s.empty(this.activitiesInputRoot);const e=Array.from(this.tableInput.value.columns.numerical);this.activitiesInput=s.input.column("Activities",{table:this.tableInput.value,value:e.length?e[0]:null,filter:t=>e.includes(t)}),Array.from(this.activitiesInput.root.children).forEach(e=>this.activitiesInputRoot.append(e))}}getEditor(){return s.div([this.tableInput,this.colInputRoot,this.preprocessingFunctionInputRoot,this.preprocessingFuncSettingsDiv,this.activitiesInputRoot,this.similarityMetricInputRoot,this.methodInput,this.methodSettingsDiv,this.similarityMetricInputRoot,this.similarityInput],{style:{minWidth:"320px"},classes:"ui-form dim-reduction-dialog-form"})}getParams(){return{...super.getParams(),activities:this.activitiesInput.value,similarityThreshold:this.similarityInput.value}}getInput(){return{...super.getInput(),activityCol:this.activitiesInput.value.name,simThreshold:this.similarityInput.value}}async applyInput(e){super.applyInput(e),this.activitiesInput.value=this.tableInput.value.col(e.activityCol),this.similarityInput.value=e.simThreshold}}var Ee,Me,Te;function _e(e){const t=["Embed_X","Embed_Y"],n=e.columns.names().filter(e=>e.includes(t[0])).length+1;return t.map(e=>`${e}_${n}`)}function Ie(e,t){return`${t} (${e.length>4?`${e.length} columns`:e.map(e=>e.name).join(", ")})`}async function Le(e,t,i,o,c,h,u,d=!0,p=!1,m={preprocessingFuncArgs:[]},g={},f=null,y={},b){const v={showXAxis:!1,showYAxis:!1,showXSelector:!1,showYSelector:!1};if(t.length!==o.length||t.length!==h.length||t.length!==c.length||t.length!==m.preprocessingFuncArgs.length)throw new Error("columns, metrics and preprocessing functions, weights and function argumentsmust have the same length");const w=d?g.tableView??r.shell.tableView(e.name)??r.shell.addTableView(e):null,C=async()=>{const C=a.TaskBarProgressIndicator.create(`Initializing ${g.scatterPlotName??"dimensionality reduction"} ...`);let S;try{const A=_e(e);function x(n,o,r){let c=null,h=null;e.columns.names().includes(A[0])?(c=e.columns.byName(A[0]),h=e.columns.byName(A[1])):(c=e.columns.add(a.Column.float(A[0],e.rowCount)),h=e.columns.add(a.Column.float(A[1],e.rowCount)),d&&!S&&(S=w.scatterPlot({...v,x:A[0],y:A[1],title:g.scatterPlotName??Ie(t,i)}))),g[l.YP]&&(S?.root&&s.setUpdateIndicator(S.root,!1),c.init(e=>r[0]?r[0][e]:void 0),h.init(e=>r[1]?r[1][e]:void 0));const u=n/o*100;C.update(u,`Running ${g.scatterPlotName??"dimensionality reduction"}... ${u.toFixed(0)}%`)}async function E(){e.columns.add(a.Column.float(A[0],e.rowCount)),e.columns.add(a.Column.float(A[1],e.rowCount));let n=null;d&&(S=w.scatterPlot({...v,x:A[0],y:A[1],title:g.scatterPlotName??Ie(t,i)}),s.setUpdateIndicator(S.root,!0));const p=r.events.onViewerClosed.subscribe(e=>{const t=e.args.viewer;t?.getOptions()?.look?.title&&S?.getOptions()?.look?.title&&t?.getOptions()?.look?.title===S?.getOptions()?.look?.title&&(r.events.fireCustomEvent(q,{}),p.unsubscribe(),n?.(),C.close())}),f=new Promise(async(r,s)=>{try{n=r;const s=[];let a=o,d=c,p=u;if(b&&t.every(e=>e.isNumerical)){const n=t.map(e=>e.toList()),i=new Array(e.rowCount).fill(0).map((e,n)=>new Float32Array(t.length));for(let o=0;o<t.length;++o)for(let t=0;t<e.rowCount;++t)i[t][o]=n[o][t];m.distanceFnArgs=[{}],s.push({entries:i,options:{}}),a=[b],d=[1],p="MANHATTAN"}else for(let e=0;e<h.length;++e){const n=h[e];if(m.distanceFnArgs||(m.distanceFnArgs=[]),n){const i=n.inputs[0].name,r=n.inputs[1].name,{entries:a,options:l}=await n.apply({[i]:t[e],[r]:o[e],...m.preprocessingFuncArgs[e]??{}});s.push({entries:a,options:l}),m.distanceFnArgs.push(l)}else{const n=t[e].toList(),i={};s.push({entries:n,options:i}),m.distanceFnArgs.push(i)}}r(await Z(s.map(e=>e.entries),i,a,d,u,m,g[l.vb]?void 0:x))}catch(e){s(e)}}),y=await f;return C.close(),p.unsubscribe(),y}const M=await E();if(p&&M){const T=a.TaskBarProgressIndicator.create("Clustering embeddings ...");try{const _=await function(e,t,i,o){return function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function s(e){try{l(i.next(e))}catch(e){r(e)}}function a(e){try{l(i.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((i=i.apply(e,t||[])).next())})}(this,void 0,void 0,function*(){return new Promise(function(r,s){const a=new Worker(new URL(n.p+n.u(682),n.b));a.postMessage({embedX:e,embedY:t,minPts:o,epsilon:i}),a.onmessage=({data:{error:e,clusters:t}})=>{a.terminate(),e?s(e):r(t)}})})}(M[0],M[1],m.dbScanEpsilon??.01,m.dbScanMinPts??4),I=e.columns.getUnusedName("Cluster (DBSCAN)");e.columns.addNewString(I).init(e=>_[e].toString()),S&&(S.props.colorColumnName=I)}catch(L){r.shell.error("Clustering embeddings failed"),console.error(L)}finally{T.close()}}if(M){const N=e.columns.byName(A[0]),P=e.columns.byName(A[1]);if(N.init(e=>M[0][e]),P.init(e=>M[1][e]),f)try{const R=f.inputs[0].name,$=f.inputs[1].name;await f.prepare({[R]:N,[$]:P,...y}).call(!0)}catch(O){r.shell.error("Post-processing failed"),console.error(O)}if(S)return s.setUpdateIndicator(S.root,!1),S.helpUrl="/help/compute/sequence-space",S}}catch(k){r.shell.error("Dimensionality reduction failed"),console.error(k),C.close(),S&&s.setUpdateIndicator(S.root,!1)}};return new Promise(async(t,n)=>{try{if(g.fastRowCount&&e.rowCount>g.fastRowCount&&!g[l.vb])s.dialog().add(s.divText("Analysis might take several minutes. Do you want to continue?")).onOK(async()=>{try{const e=await C();t(e)}catch(e){n(e)}}).onCancel(()=>t(void 0)).show();else{const e=await C();t(e)}}catch(e){n(e)}})}n(5540),function(e){e.ADD="ADD",e.SUB="SUB",e.MULT="MULT"}(Ee||(Ee={})),function(e){e.SQUARE="SQUARE",e.INVERSE="INVERSE",e.TRANSPOSE="TRANSPOSE",e.NORM="NORM",e.COLUMN_NORM="COLUMN_NORM"}(Me||(Me={})),function(e){e.SCALARMULT="SCALARMULT",e.SCALARADD="SCALARADD",e.SCALARPOW="SCALARPOW"}(Te||(Te={})),Object.prototype.toString;var Ne=n(6873),Pe=n(4356),Re=n(6717),$e=n(4025),Oe=n(4870),ke=n(3856),He=n(6882),Fe=n(7278),Ge=n(5553),Be=n(6642),De=n(3599),Ve=n(673),We=n(8312);class je extends Be.sD{monomerLib=null;seqHelper=null;constructor(e,t){super(e,t,Dr.logger),(0,we.pj)().then(e=>{this.monomerLib=e.getMonomerLib(),this.dirty=!0,this.gridCol?.grid?.invalidate(),this.subs.push(this.monomerLib.onChanged.subscribe(()=>{this.dirty=!0,this.gridCol?.grid?.invalidate()}))}),(0,We.Q)().then(e=>{this.seqHelper=e,this.dirty=!0,this.gridCol?.grid?.invalidate()})}}var Ue=n(4139);const qe=me.zS;function ze(e){const t=!R().enumerate(e).some(([t,n])=>t.length>1&&0!=n&&n!=e.length-1),n=[],i=t?"":" ";for(const[t,o]of R().enumerate(e)){let r=t;o<e.length&&(r+=`${t?"":"-"}${i}`),n.push(r)}return[n,t]}class Ye extends a.GridCellRenderer{seqHelper;get name(){return"sequence"}get cellType(){return"sequence"}get defaultHeight(){return 30}get defaultWidth(){return 230}hasMouseOver=!1;constructor(){super(),this.seqHelper=Dr.seqHelper}getRendererBack(e){const[t,n,i]=(0,Be.BG)(e);if(i.rendererBack)return i.rendererBack;let o=null;return this.seqHelper&&(o=this.seqHelper.getSeqHandler(n).getRendererBack(t,n)),o}onClick(e,t){e.cell.column.temp["current-word"]=e.cell.value,e.grid.invalidate();const n=this.getRendererBack(e);n?.onClick(e,t)}onMouseEnter(e,t){const n=this.getRendererBack(e);n?.onMouseEnter(e,t),this.hasMouseOver=!0}onMouseMove(e,t){const n=this.getRendererBack(e);n?.onMouseMove(e,t)}onMouseLeave(e,t){if((0,Ge.WN)(e,null),e?.grid){const t=e.grid.onEvent("d4-grid-show-tooltip").subscribe(e=>{t.unsubscribe(),this.hasMouseOver&&e.preventDefault()})}this.hasMouseOver=!1}onDoubleClick(e,t){const n=this.getRendererBack(e);n?.onDoubleClick(e,t)}onKeyDown(e,t){const n=this.getRendererBack(e);n?.onKeyDown(e,t)}onKeyPress(e,t){const n=this.getRendererBack(e);n?.onKeyPress(e,t)}renderInt(e,t,n,i,o,r,s){const[a,l,c]=(0,Be.BG)(r);if(!l)return;const h=l.temp,u=this.seqHelper.getSeqHandler(l);let d=(Dr.properties?Dr.properties.maxMonomerLength:4)??50;if(ke.gp.maxMonomerLength in l.tags){const e=parseInt(l.getTag(ke.gp.maxMonomerLength));d=!isNaN(e)&&e?e:50}if(".mm.cellRenderer.maxMonomerLength"in h){const e=h[".mm.cellRenderer.maxMonomerLength"];d=!isNaN(e)&&e?e:50}let p=c.rendererBack;p||(p=c.rendererBack=new He.Jy(a,l,Dr.logger,d,()=>{const{font:e,fontWidth:t}=He.Jy.getFontSettings(l);return{font:e,fontCharWidth:t,separatorWidth:u.isMsa()?8:0,monomerToShort:qe}}),l.temp[".mm.cellRenderer.settingsChanged"],Ve.s.true,p.init().then(()=>{})),p.render(e,t,n,i,o,r,s)}render(e,t,n,i,o,r,s){const a=this.getRendererBack(r);a?a?.render(e,t,n,i,o,r,s):this.renderInt(e,t,n,i,o,r,s)}}class Ke extends je{constructor(e,t){super(e,t)}render(e,t,n,i,o,r,s){const a=window.devicePixelRatio,l=r.grid,c=r.cell.value??"",h=this.tableCol.tags[me.gp.separator],u=this.tableCol.meta.units;i=(0,He.U0)(l,e,t,i,a);const[d,p]=c.split("#"),m=this.tableCol.temp[$e.j.notationProvider]?.separatorSplitter??(0,Fe.Iv)(u,h),g=m(d),f=m(p),y=R().count(0).take(g.length).map(e=>g.getCanonical(e)).toArray(),b=R().count(0).take(f.length).map(e=>f.getCanonical(e)).toArray(),v=this.tableCol.getTag(me.gp.alphabet);Xe(e,t,n,i,o,y,b,v===me.YI.RNA||v===me.YI.DNA?De.o.NUCLEOTIDE:De.o.AA,this.monomerLib,void 0,void 0)}async awaitRendered(e=1e4,t=`${e} timeout`){return Promise.resolve()}static getOrCreate(e){const[t,n,i]=(0,Be.BG)(e);let o=i.rendererBack;return o||(o=i.rendererBack=new Ke(t,n)),o}}class Ze extends a.GridCellRenderer{get name(){return"MacromoleculeDifferenceCR"}get cellType(){return Ue.uF.MACROMOLECULE_DIFFERENCE}get defaultHeight(){return 30}get defaultWidth(){return 230}render(e,t,n,i,o,r,s){Ke.getOrCreate(r).render(e,t,n,i,o,r,s)}}function Xe(e,t,n,i,o,r,s,a,l,c,h){if(r.length!==s.length){const e=function(e,t){let n=0,i=0;const o=e.length>t.length?e:t,r=e.length>t.length?t:e;for(let e=0;e<r.length;e++)o[e]===r[e]&&n++;const s=o.length-r.length;for(let e=o.length-1;e>s;e--)o[e]===r[e-s]&&i++;const a=new Array(Math.abs(e.length-t.length)).fill(ve.b9[me.Hi.FASTA]);function l(e){return n>i?e.concat(a):a.concat(e)}return e.length>t.length?t=l(R()(t).toArray()):e=l(R()(e).toArray()),{subParts1:e,subParts2:t}}(r,s);r=e.subParts1,s=e.subParts2}const u=e.measureText(ze(r).join("")),d=e.measureText(ze(s).join("")),p=Math.max(u.width,d.width);c&&(i=p+4*r.length,e.canvas.width=p+4*r.length);let m=Math.max(t,t+(i-(p+4*r.length))/2)+5;const g=Math.max(n,n+(o-28)/2);e.save();try{e.beginPath(),e.rect(t,n,c?p+4*r.length:i,o),e.clip(),e.font="12px monospace",e.textBaseline="top";const u=7;for(let t=0;t<r.length;t++){const n=r[t],c=s[t];let d=He.S$;if(l&&(d=l.getMonomerTextColor(a,n)),n!=c){let r=He.S$;l&&(r=l.getMonomerTextColor(a,c));const s=(0,ke.oZ)(e,n,m,g-u,i,o,{color:d,pivot:0,left:!0}),p=(0,ke.oZ)(e,c,m,g+u,i,o,{color:r,pivot:0,left:!0});m=Math.max(p,s),h&&(h[t]=Je(n,c,d,r,g,u,o))}else m=(0,ke.oZ)(e,n,m,g,i,o,{color:d,pivot:0,left:!0,transparencyRate:.5});m+=4}}finally{e.restore()}}function Je(e,t,n,i,o,r,s){const a=document.createElement("canvas"),l=a.getContext("2d");l.font="12px monospace";const c=l.measureText(ze([e]).join("")).width,h=l.measureText(ze([t]).join("")).width,u=Math.max(c,h);return a.height=s,a.width=u+4,l.font="12px monospace",l.textBaseline="top",(0,ke.oZ)(l,e,0,o-r,u,s,{color:n,pivot:0,left:!0}),(0,ke.oZ)(l,t,0,o+r,u,s,{color:i,pivot:0,left:!0}),a}var Qe,et=n(8070),tt=n(4326);!function(e){e.Unknown="unknown",e.FR="framework",e.CDR="cdr"}(Qe||(Qe={}));const nt=new class{constructor(){this.regionTypes=[Qe.CDR],this.chains=["Heavy","Light"],this.skipEmptyPositions=!1,this.fitWidth=!1,this.positionWidth=16,this.positionHeight=tt.fH.Entropy,this.filterSource=tt.Fo.filterSource}};var it=n(7602),ot=n(250);const rt=Qe;var st,at;!function(e){e.STYLE="Style",e.BEHAVIOR="Behavior",e.LAYOUT="Layout",e.DATA="Data"}(st||(st={})),function(e){e.skipEmptyPositions="skipEmptyPositions",e.regionTypes="regionTypes",e.chains="chains",e.fitWidth="fitWidth",e.positionWidth="positionWidth",e.positionHeight="positionHeight",e.filterSource="filterSource"}(at||(at={}));const lt=nt;class ct extends a.JsViewer{viewed=!1;regionsFg=null;regionsRoot=null;isOpened=!1;panelNode=null;regions=[];regionTypes;chains;skipEmptyPositions;fitWidth;positionWidth;positionHeight;filterSource;constructor(){super(),this.skipEmptyPositions=this.bool(at.skipEmptyPositions,lt.skipEmptyPositions,{category:st.DATA}),this.regionTypes=this.stringList(at.regionTypes,lt.regionTypes,{category:st.DATA,choices:Object.values(rt).filter(e=>e!=rt.Unknown)}),this.chains=this.stringList(at.chains,lt.chains,{category:st.DATA,choices:["Heavy","Light"]}),this.fitWidth=this.bool(at.fitWidth,lt.fitWidth,{category:st.LAYOUT}),this.positionWidth=this.float(at.positionWidth,lt.positionWidth,{category:st.LAYOUT,editor:"slider",min:0,max:64,description:"Internal WebLogo viewers property width of position."}),this.positionHeight=this.string(at.positionHeight,lt.positionHeight,{category:st.LAYOUT,choices:Object.keys(tt.fH)}),this.filterSource=this.string(at.filterSource,lt.filterSource,{category:st.BEHAVIOR,choices:Object.values(tt.lT)}),this.viewSyncer=new it.g(Dr.logger)}static viewerCounter=-1;viewerId=++ct.viewerCounter;viewerToLog(){return`VdRegionsViewer<${this.viewerId}>`}async init(){this.subs.push((0,h.fromEvent)(this.root,"mousemove").subscribe(this.rootOnMouseMove.bind(this)))}detach(){const e=`${this.viewerToLog()}.detach()`,t=super.detach.bind(this);this.viewSyncer.sync(`${e}`,async()=>{this.setDataInProgress||(this.viewed&&(await this.destroyView("detach"),this.viewed=!1),t())})}onTableAttached(){super.onTableAttached(),this.setData(this.regions)}onPropertyChanged(e){if(super.onPropertyChanged(e),e){switch(e.name){case at.regionTypes:case at.chains:this.setData(this.regions)}switch(e.name){case at.skipEmptyPositions:for(let e=0;e<this.logos.length;++e)for(const t of this.chains)this.logos[e][t].setOptions({[ot.n5.skipEmptyPositions]:this.skipEmptyPositions});this.calcSize();break;case at.fitWidth:case at.positionWidth:this.calcSize();break;case at.positionHeight:for(let e=0;e<this.logos.length;++e)for(const t of this.chains)this.logos[e][t].setOptions({[ot.n5.positionHeight]:this.positionHeight});this.calcSize();break;case at.filterSource:this.filterSourceInput.value=this.filterSource;break;default:this.setData(this.regions)}}else console.warn("Bio: VdRegionsViewer.onPropertyChanged() property is null")}setData(e){const t=`${this.viewerToLog()}.setData()`;Dr.logger.debug(`${t}, in, regions.length = ${e.length}`),this.viewSyncer.sync(`${t}`,async()=>{if(!this.setDataInProgress){this.setDataInProgress=!0;try{this.viewed&&(await this.destroyView("setData"),this.viewed=!1),this.regions=e,this.viewed||(await this.buildView("setData"),this.viewed=!0)}finally{this.setDataInProgress=!1}}})}viewSyncer;setDataInProgress=!1;host=null;filterSourceInput;mainLayout=null;logos=[];viewSubs=[];async destroyView(e){Dr.logger.debug(`Bio: VdRegionsViewer.destroyView( mainLayout = ${this.mainLayout?"value":"none"} ), purpose = '${e}', this.regions.length = ${this.regions.length}`),this.filterSourceInput&&s.empty(this.filterSourceInput.root),null!=this.mainLayout&&(this.mainLayout.remove(),this.host.remove(),this.host=null,this.mainLayout=null);for(const e of this.viewSubs)e.unsubscribe()}async buildView(e){Dr.logger.debug(`Bio: VdRegionsViewer.buildView() begin, purpose = '${e}', this.regions.length = ${this.regions.length}`);const t=this.regions.filter(e=>this.regionTypes.includes(e.type)),n=Array.from(new Set(t.map(e=>e.order))).sort(),i=[];for(let e=0;e<n.length;e++)for(const o of this.chains){const r=t.find(t=>t.order==n[e]&&t.chain==o);i.push((async()=>{const t=await this.dataFrame.plot.fromType("WebLogo",{sequenceColumnName:r.sequenceColumnName,startPositionName:r.positionStartName,endPositionName:r.positionEndName,fixWidth:!0,skipEmptyPositions:this.skipEmptyPositions,positionWidth:this.positionWidth,positionHeight:this.positionHeight,filterSource:this.filterSource});return t.onSizeChanged.subscribe(()=>{this.calcSize()}),[e,o,t]})())}const o=await Promise.all(i);this.logos=new Array(n.length);for(let e=0;e<n.length;++e)this.logos[e]={};for(const[e,t,n]of o)this.logos[e][t]=n,this.viewSubs.push(n.onFreqsCalculated.subscribe(()=>{this.calcSize()}));this.mainLayout=s.table(this.chains,e=>[...n.length>0?[s.div(e,{style:{transform:"rotate(-90deg)",font:"12px Roboto, Roboto Local, sans-serif",textAlign:"center",width:"16px",marginTop:"24px",marginLeft:"6px"}})]:[],...[...Array(n.length).keys()].map(t=>{const n=this.logos[t][e];return n.root.style.height="100%",s.div([n.root],{style:{marginTop:"4px",marginBottom:"4px"}})})],["",...[...Array(n.length).keys()].map(e=>t.find(t=>t.order==n[e]&&t.chain==this.chains[0]).name||"Name")]),this.mainLayout.className="mlb-vd-regions-viewer-table2",this.filterSourceInput=s.input.choice("Data source",{value:this.filterSource,items:Object.values(tt.lT),onValueChanged:this.filterSourceInputOnValueChanged.bind(this)}),this.filterSourceInput.root.style.position="absolute",this.filterSourceInput.root.style.right="9px",this.filterSourceInput.root.style.top="-4px",Math.ceil(255*Math.random()).toString(16),this.host=s.div([this.mainLayout,this.filterSourceInput.root],{}),this.root.appendChild(this.host),this.root.style.overflowX="auto",this.calcSize(),this.viewSubs.push(s.onSizeChanged(this.root).subscribe(this.rootOnSizeChanged.bind(this))),Dr.logger.debug("Bio: VdRegionsViewer.buildView() end")}calcSizeRequested=!1;calcSize(){Dr.logger.debug("Bio: VdRegionsViewer.calcSize(), start");const e=()=>{if(!this.host)return;const e=(this.root.clientHeight-54)/this.chains.length;let t=0;for(let n=0;n<this.logos.length;n++){for(const t of this.chains)this.logos[n][t].root.style.height=`${e}px`;t+=Math.max(...this.chains.map(e=>this.logos[n][e].Length))}if(this.fitWidth){if(this.logos.length>0&&t>0){const e=22,n=13,i=9,o=(this.root.clientWidth-e-(this.logos.length-1)*i-n)/t;for(let e=0;e<this.logos.length;e++)for(const t of this.chains){const n=this.logos[e][t];n.setOptions({[ot.n5.positionWidth]:o-n.positionMarginValue}),n.root.style.width=o*n.Length+"px"}}this.host.style.setProperty("overflow","hidden","important")}else{for(let e=0;e<this.logos.length;e++)for(const t of this.chains)this.logos[e][t].setOptions({[ot.n5.positionWidth]:this.positionWidth});this.host.style.removeProperty("overflow")}0===this.positionWidth?this.host.style.setProperty("overflow-x","hidden","important"):this.host.style.removeProperty("overflow-x")};this.calcSizeRequested||(this.calcSizeRequested=!0,window.setTimeout(()=>{e(),this.calcSizeRequested=!1},0))}rootOnSizeChanged(e){this.calcSize()}rootOnMouseMove(e){}filterSourceInputOnValueChanged(){const e=`${this.viewerToLog()}.filterSourceInputOnValueChanged()`,t=this.filterSourceInput.value;this.viewSyncer.sync(`${e}`,async()=>{if(this.filterSource!==t){this.props.getProperty(at.filterSource).set(this,t);for(let e=0;e<this.logos.length;e++)for(let t=0;t<this.chains.length;t++){const n=this.chains[t];this.logos[e][n].setOptions({[ot.n5.filterSource]:this.filterSource})}}})}_onRendered=new h.Subject;get onRendered(){return this._onRendered}invalidate(e){const t=`${this.viewerToLog()}.invalidate(${e?` <- ${e} `:""})`;this.viewSyncer.sync(`${t}`,async()=>{this._onRendered.next()})}async awaitRendered(e=5e3){await(0,et.PE)(this.onRendered,()=>{},()=>{this.invalidate()},e);const t=this.viewSyncer.resetErrors();if(t.length>0)throw t[0]}}class ht{value;parentI;parentJ;constructor(){this.value=0,this.parentI=0,this.parentJ=0}}class ut{seq1;seq2;score;constructor(e,t,n){this.seq1=e,this.seq2=t,this.score=n}}class dt{seq1="";seq2="";gap=1;len1=0;len2=0;step=1;alignGrid=[];scores=[];dpGrid=[];connections={};BLOSUM45=[[5,-2,-1,-2,-1,-1,-1,0,-2,-1,-1,-1,-1,-2,-1,1,0,-2,-2,0,-1,-1,0,-5],[-2,7,0,-1,-3,1,0,-2,0,-3,-2,3,-1,-2,-2,-1,-1,-2,-1,-2,-1,0,-1,-5],[-1,0,6,2,-2,0,0,0,1,-2,-3,0,-2,-2,-2,1,0,-4,-2,-3,4,0,-1,-5],[-2,-1,2,7,-3,0,2,-1,0,-4,-3,0,-3,-4,-1,0,-1,-4,-2,-3,5,1,-1,-5],[-1,-3,-2,-3,12,-3,-3,-3,-3,-3,-2,-3,-2,-2,-4,-1,-1,-5,-3,-1,-2,-3,-2,-5],[-1,1,0,0,-3,6,2,-2,1,-2,-2,1,0,-4,-1,0,-1,-2,-1,-3,0,4,-1,-5],[-1,0,0,2,-3,2,6,-2,0,-3,-2,1,-2,-3,0,0,-1,-3,-2,-3,1,4,-1,-5],[0,-2,0,-1,-3,-2,-2,7,-2,-4,-3,-2,-2,-3,-2,0,-2,-2,-3,-3,-1,-2,-1,-5],[-2,0,1,0,-3,1,0,-2,10,-3,-2,-1,0,-2,-2,-1,-2,-3,2,-3,0,0,-1,-5],[-1,-3,-2,-4,-3,-2,-3,-4,-3,5,2,-3,2,0,-2,-2,-1,-2,0,3,-3,-3,-1,-5],[-1,-2,-3,-3,-2,-2,-2,-3,-2,2,5,-3,2,1,-3,-3,-1,-2,0,1,-3,-2,-1,-5],[-1,3,0,0,-3,1,1,-2,-1,-3,-3,5,-1,-3,-1,-1,-1,-2,-1,-2,0,1,-1,-5],[-1,-1,-2,-3,-2,0,-2,-2,0,2,2,-1,6,0,-2,-2,-1,-2,0,1,-2,-1,-1,-5],[-2,-2,-2,-4,-2,-4,-3,-3,-2,0,1,-3,0,8,-3,-2,-1,1,3,0,-3,-3,-1,-5],[-1,-2,-2,-1,-4,-1,0,-2,-2,-2,-3,-1,-2,-3,9,-1,-1,-3,-3,-3,-2,-1,-1,-5],[1,-1,1,0,-1,0,0,0,-1,-2,-3,-1,-2,-2,-1,4,2,-4,-2,-1,0,0,0,-5],[0,-1,0,-1,-1,-1,-1,-2,-2,-1,-1,-1,-1,-1,-1,2,5,-3,-1,0,0,-1,0,-5],[-2,-2,-4,-4,-5,-2,-3,-2,-3,-2,-2,-2,-2,1,-3,-4,-3,15,3,-3,-4,-2,-2,-5],[-2,-1,-2,-2,-3,-1,-2,-3,2,0,0,-1,0,3,-3,-2,-1,3,8,-1,-2,-2,-1,-5],[0,-2,-3,-3,-1,-3,-3,-3,-3,3,1,-2,1,0,-3,-1,0,-3,-1,5,-3,-3,-1,-5],[-1,-1,4,5,-2,0,1,-1,0,-3,-3,0,-2,-3,-2,0,0,-4,-2,-3,4,2,-1,-5],[-1,0,0,1,-3,4,4,-2,0,-3,-2,1,-1,-3,-1,0,-1,-2,-2,-3,2,4,-1,-5],[0,-1,-1,-1,-2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,0,-2,-1,-1,-1,-1,-1,-5],[-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,1]];BLOSUM50=[[5,-2,-1,-2,-1,-1,-1,0,-2,-1,-2,-1,-1,-3,-1,1,0,-3,-2,0,-2,-1,-1,-5],[-2,7,-1,-2,-4,1,0,-3,0,-4,-3,3,-2,-3,-3,-1,-1,-3,-1,-3,-1,0,-1,-5],[-1,-1,7,2,-2,0,0,0,1,-3,-4,0,-2,-4,-2,1,0,-4,-2,-3,4,0,-1,-5],[-2,-2,2,8,-4,0,2,-1,-1,-4,-4,-1,-4,-5,-1,0,-1,-5,-3,-4,5,1,-1,-5],[-1,-4,-2,-4,13,-3,-3,-3,-3,-2,-2,-3,-2,-2,-4,-1,-1,-5,-3,-1,-3,-3,-2,-5],[-1,1,0,0,-3,7,2,-2,1,-3,-2,2,0,-4,-1,0,-1,-1,-1,-3,0,4,-1,-5],[-1,0,0,2,-3,2,6,-3,0,-4,-3,1,-2,-3,-1,-1,-1,-3,-2,-3,1,5,-1,-5],[0,-3,0,-1,-3,-2,-3,8,-2,-4,-4,-2,-3,-4,-2,0,-2,-3,-3,-4,-1,-2,-2,-5],[-2,0,1,-1,-3,1,0,-2,10,-4,-3,0,-1,-1,-2,-1,-2,-3,2,-4,0,0,-1,-5],[-1,-4,-3,-4,-2,-3,-4,-4,-4,5,2,-3,2,0,-3,-3,-1,-3,-1,4,-4,-3,-1,-5],[-2,-3,-4,-4,-2,-2,-3,-4,-3,2,5,-3,3,1,-4,-3,-1,-2,-1,1,-4,-3,-1,-5],[-1,3,0,-1,-3,2,1,-2,0,-3,-3,6,-2,-4,-1,0,-1,-3,-2,-3,0,1,-1,-5],[-1,-2,-2,-4,-2,0,-2,-3,-1,2,3,-2,7,0,-3,-2,-1,-1,0,1,-3,-1,-1,-5],[-3,-3,-4,-5,-2,-4,-3,-4,-1,0,1,-4,0,8,-4,-3,-2,1,4,-1,-4,-4,-2,-5],[-1,-3,-2,-1,-4,-1,-1,-2,-2,-3,-4,-1,-3,-4,10,-1,-1,-4,-3,-3,-2,-1,-2,-5],[1,-1,1,0,-1,0,-1,0,-1,-3,-3,0,-2,-3,-1,5,2,-4,-2,-2,0,0,-1,-5],[0,-1,0,-1,-1,-1,-1,-2,-2,-1,-1,-1,-1,-2,-1,2,5,-3,-2,0,0,-1,0,-5],[-3,-3,-4,-5,-5,-1,-3,-3,-3,-3,-2,-3,-1,1,-4,-4,-3,15,2,-3,-5,-2,-3,-5],[-2,-1,-2,-3,-3,-1,-2,-3,2,-1,-1,-2,0,4,-3,-2,-2,2,8,-1,-3,-2,-1,-5],[0,-3,-3,-4,-1,-3,-3,-4,-4,4,1,-3,1,-1,-3,-2,0,-3,-1,5,-4,-3,-1,-5],[-2,-1,4,5,-3,0,1,-1,0,-4,-4,0,-3,-4,-2,0,0,-5,-3,-4,5,2,-1,-5],[-1,0,0,1,-3,4,5,-2,0,-3,-3,1,-1,-4,-1,0,-1,-2,-2,-3,2,5,-1,-5],[-1,-1,-1,-1,-2,-1,-1,-2,-1,-1,-1,-1,-1,-2,-2,-1,0,-3,-1,-1,-1,-1,-1,-5],[-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,1]];BLOSUM62=[[4,-1,-2,-2,0,-1,-1,0,-2,-1,-1,-1,-1,-2,-1,1,0,-3,-2,0,-2,-1,0,-4],[-1,5,0,-2,-3,1,0,-2,0,-3,-2,2,-1,-3,-2,-1,-1,-3,-2,-3,-1,0,-1,-4],[-2,0,6,1,-3,0,0,0,1,-3,-3,0,-2,-3,-2,1,0,-4,-2,-3,3,0,-1,-4],[-2,-2,1,6,-3,0,2,-1,-1,-3,-4,-1,-3,-3,-1,0,-1,-4,-3,-3,4,1,-1,-4],[0,-3,-3,-3,9,-3,-4,-3,-3,-1,-1,-3,-1,-2,-3,-1,-1,-2,-2,-1,-3,-3,-2,-4],[-1,1,0,0,-3,5,2,-2,0,-3,-2,1,0,-3,-1,0,-1,-2,-1,-2,0,3,-1,-4],[-1,0,0,2,-4,2,5,-2,0,-3,-3,1,-2,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-2,0,-1,-3,-2,-2,6,-2,-4,-4,-2,-3,-3,-2,0,-2,-2,-3,-3,-1,-2,-1,-4],[-2,0,1,-1,-3,0,0,-2,8,-3,-3,-1,-2,-1,-2,-1,-2,-2,2,-3,0,0,-1,-4],[-1,-3,-3,-3,-1,-3,-3,-4,-3,4,2,-3,1,0,-3,-2,-1,-3,-1,3,-3,-3,-1,-4],[-1,-2,-3,-4,-1,-2,-3,-4,-3,2,4,-2,2,0,-3,-2,-1,-2,-1,1,-4,-3,-1,-4],[-1,2,0,-1,-3,1,1,-2,-1,-3,-2,5,-1,-3,-1,0,-1,-3,-2,-2,0,1,-1,-4],[-1,-1,-2,-3,-1,0,-2,-3,-2,1,2,-1,5,0,-2,-1,-1,-1,-1,1,-3,-1,-1,-4],[-2,-3,-3,-3,-2,-3,-3,-3,-1,0,0,-3,0,6,-4,-2,-2,1,3,-1,-3,-3,-1,-4],[-1,-2,-2,-1,-3,-1,-1,-2,-2,-3,-3,-1,-2,-4,7,-1,-1,-4,-3,-2,-2,-1,-2,-4],[1,-1,1,0,-1,0,0,0,-1,-2,-2,0,-1,-2,-1,4,1,-3,-2,-2,0,0,0,-4],[0,-1,0,-1,-1,-1,-1,-2,-2,-1,-1,-1,-1,-2,-1,1,5,-2,-2,0,-1,-1,0,-4],[-3,-3,-4,-4,-2,-2,-3,-2,-2,-3,-2,-3,-1,1,-4,-3,-2,11,2,-3,-4,-3,-2,-4],[-2,-2,-2,-3,-2,-1,-2,-3,2,-1,-1,-2,-1,3,-3,-2,-2,2,7,-1,-3,-2,-1,-4],[0,-3,-3,-3,-1,-2,-2,-3,-3,3,1,-2,1,-1,-2,-2,0,-3,-1,4,-3,-2,-1,-4],[-2,-1,3,4,-3,0,1,-1,0,-3,-4,0,-3,-3,-2,0,-1,-4,-3,-3,4,1,-1,-4],[-1,0,0,1,-3,3,4,-2,0,-3,-3,1,-1,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-1,-1,-1,-2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-2,0,0,-2,-1,-1,-1,-1,-1,-4],[-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,1]];BLOSUM80=[[7,-3,-3,-3,-1,-2,-2,0,-3,-3,-3,-1,-2,-4,-1,2,0,-5,-4,-1,-3,-2,-1,-8],[-3,9,-1,-3,-6,1,-1,-4,0,-5,-4,3,-3,-5,-3,-2,-2,-5,-4,-4,-2,0,-2,-8],[-3,-1,9,2,-5,0,-1,-1,1,-6,-6,0,-4,-6,-4,1,0,-7,-4,-5,5,-1,-2,-8],[-3,-3,2,10,-7,-1,2,-3,-2,-7,-7,-2,-6,-6,-3,-1,-2,-8,-6,-6,6,1,-3,-8],[-1,-6,-5,-7,13,-5,-7,-6,-7,-2,-3,-6,-3,-4,-6,-2,-2,-5,-5,-2,-6,-7,-4,-8],[-2,1,0,-1,-5,9,3,-4,1,-5,-4,2,-1,-5,-3,-1,-1,-4,-3,-4,-1,5,-2,-8],[-2,-1,-1,2,-7,3,8,-4,0,-6,-6,1,-4,-6,-2,-1,-2,-6,-5,-4,1,6,-2,-8],[0,-4,-1,-3,-6,-4,-4,9,-4,-7,-7,-3,-5,-6,-5,-1,-3,-6,-6,-6,-2,-4,-3,-8],[-3,0,1,-2,-7,1,0,-4,12,-6,-5,-1,-4,-2,-4,-2,-3,-4,3,-5,-1,0,-2,-8],[-3,-5,-6,-7,-2,-5,-6,-7,-6,7,2,-5,2,-1,-5,-4,-2,-5,-3,4,-6,-6,-2,-8],[-3,-4,-6,-7,-3,-4,-6,-7,-5,2,6,-4,3,0,-5,-4,-3,-4,-2,1,-7,-5,-2,-8],[-1,3,0,-2,-6,2,1,-3,-1,-5,-4,8,-3,-5,-2,-1,-1,-6,-4,-4,-1,1,-2,-8],[-2,-3,-4,-6,-3,-1,-4,-5,-4,2,3,-3,9,0,-4,-3,-1,-3,-3,1,-5,-3,-2,-8],[-4,-5,-6,-6,-4,-5,-6,-6,-2,-1,0,-5,0,10,-6,-4,-4,0,4,-2,-6,-6,-3,-8],[-1,-3,-4,-3,-6,-3,-2,-5,-4,-5,-5,-2,-4,-6,12,-2,-3,-7,-6,-4,-4,-2,-3,-8],[2,-2,1,-1,-2,-1,-1,-1,-2,-4,-4,-1,-3,-4,-2,7,2,-6,-3,-3,0,-1,-1,-8],[0,-2,0,-2,-2,-1,-2,-3,-3,-2,-3,-1,-1,-4,-3,2,8,-5,-3,0,-1,-2,-1,-8],[-5,-5,-7,-8,-5,-4,-6,-6,-4,-5,-4,-6,-3,0,-7,-6,-5,16,3,-5,-8,-5,-5,-8],[-4,-4,-4,-6,-5,-3,-5,-6,3,-3,-2,-4,-3,4,-6,-3,-3,3,11,-3,-5,-4,-3,-8],[-1,-4,-5,-6,-2,-4,-4,-6,-5,4,1,-4,1,-2,-4,-3,0,-5,-3,7,-6,-4,-2,-8],[-3,-2,5,6,-6,-1,1,-2,-1,-6,-7,-1,-5,-6,-4,0,-1,-8,-5,-6,6,0,-3,-8],[-2,0,-1,1,-7,5,6,-4,0,-6,-5,1,-3,-6,-2,-1,-2,-5,-4,-4,0,6,-1,-8],[-1,-2,-2,-3,-4,-2,-2,-3,-2,-2,-2,-2,-2,-3,-3,-1,-1,-5,-3,-2,-3,-1,-2,-8],[-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,1]];BLOSUM90=[[5,-2,-2,-3,-1,-1,-1,0,-2,-2,-2,-1,-2,-3,-1,1,0,-4,-3,-1,-2,-1,-1,-6],[-2,6,-1,-3,-5,1,-1,-3,0,-4,-3,2,-2,-4,-3,-1,-2,-4,-3,-3,-2,0,-2,-6],[-2,-1,7,1,-4,0,-1,-1,0,-4,-4,0,-3,-4,-3,0,0,-5,-3,-4,4,-1,-2,-6],[-3,-3,1,7,-5,-1,1,-2,-2,-5,-5,-1,-4,-5,-3,-1,-2,-6,-4,-5,4,0,-2,-6],[-1,-5,-4,-5,9,-4,-6,-4,-5,-2,-2,-4,-2,-3,-4,-2,-2,-4,-4,-2,-4,-5,-3,-6],[-1,1,0,-1,-4,7,2,-3,1,-4,-3,1,0,-4,-2,-1,-1,-3,-3,-3,-1,4,-1,-6],[-1,-1,-1,1,-6,2,6,-3,-1,-4,-4,0,-3,-5,-2,-1,-1,-5,-4,-3,0,4,-2,-6],[0,-3,-1,-2,-4,-3,-3,6,-3,-5,-5,-2,-4,-5,-3,-1,-3,-4,-5,-5,-2,-3,-2,-6],[-2,0,0,-2,-5,1,-1,-3,8,-4,-4,-1,-3,-2,-3,-2,-2,-3,1,-4,-1,0,-2,-6],[-2,-4,-4,-5,-2,-4,-4,-5,-4,5,1,-4,1,-1,-4,-3,-1,-4,-2,3,-5,-4,-2,-6],[-2,-3,-4,-5,-2,-3,-4,-5,-4,1,5,-3,2,0,-4,-3,-2,-3,-2,0,-5,-4,-2,-6],[-1,2,0,-1,-4,1,0,-2,-1,-4,-3,6,-2,-4,-2,-1,-1,-5,-3,-3,-1,1,-1,-6],[-2,-2,-3,-4,-2,0,-3,-4,-3,1,2,-2,7,-1,-3,-2,-1,-2,-2,0,-4,-2,-1,-6],[-3,-4,-4,-5,-3,-4,-5,-5,-2,-1,0,-4,-1,7,-4,-3,-3,0,3,-2,-4,-4,-2,-6],[-1,-3,-3,-3,-4,-2,-2,-3,-3,-4,-4,-2,-3,-4,8,-2,-2,-5,-4,-3,-3,-2,-2,-6],[1,-1,0,-1,-2,-1,-1,-1,-2,-3,-3,-1,-2,-3,-2,5,1,-4,-3,-2,0,-1,-1,-6],[0,-2,0,-2,-2,-1,-1,-3,-2,-1,-2,-1,-1,-3,-2,1,6,-4,-2,-1,-1,-1,-1,-6],[-4,-4,-5,-6,-4,-3,-5,-4,-3,-4,-3,-5,-2,0,-5,-4,-4,11,2,-3,-6,-4,-3,-6],[-3,-3,-3,-4,-4,-3,-4,-5,1,-2,-2,-3,-2,3,-4,-3,-2,2,8,-3,-4,-3,-2,-6],[-1,-3,-4,-5,-2,-3,-3,-5,-4,3,0,-3,0,-2,-3,-2,-1,-3,-3,5,-4,-3,-2,-6],[-2,-2,4,4,-4,-1,0,-2,-1,-5,-5,-1,-4,-4,-3,0,-1,-6,-4,-4,4,0,-2,-6],[-1,0,-1,0,-5,4,4,-3,0,-4,-4,1,-2,-4,-2,-1,-1,-4,-3,-3,0,4,-1,-6],[-1,-2,-2,-2,-3,-1,-2,-2,-2,-2,-2,-1,-1,-2,-2,-1,-1,-3,-2,-2,-2,-1,-2,-6],[-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,1]];NUCLEOTIDES=[[1,-1,-1,-1],[-1,1,-1,-1],[-1,-1,1,-1],[-1,-1,-1,1]];PAM30=[[6,-7,-4,-3,-6,-4,-2,-2,-7,-5,-6,-7,-5,-8,-2,0,-1,-13,-8,-2,-3,-3,-3,-17],[-7,8,-6,-10,-8,-2,-9,-9,-2,-5,-8,0,-4,-9,-4,-3,-6,-2,-10,-8,-7,-4,-6,-17],[-4,-6,8,2,-11,-3,-2,-3,0,-5,-7,-1,-9,-9,-6,0,-2,-8,-4,-8,6,-3,-3,-17],[-3,-10,2,8,-14,-2,2,-3,-4,-7,-12,-4,-11,-15,-8,-4,-5,-15,-11,-8,6,1,-5,-17],[-6,-8,-11,-14,10,-14,-14,-9,-7,-6,-15,-14,-13,-13,-8,-3,-8,-15,-4,-6,-12,-14,-9,-17],[-4,-2,-3,-2,-14,8,1,-7,1,-8,-5,-3,-4,-13,-3,-5,-5,-13,-12,-7,-3,6,-5,-17],[-2,-9,-2,2,-14,1,8,-4,-5,-5,-9,-4,-7,-14,-5,-4,-6,-17,-8,-6,1,6,-5,-17],[-2,-9,-3,-3,-9,-7,-4,6,-9,-11,-10,-7,-8,-9,-6,-2,-6,-15,-14,-5,-3,-5,-5,-17],[-7,-2,0,-4,-7,1,-5,-9,9,-9,-6,-6,-10,-6,-4,-6,-7,-7,-3,-6,-1,-1,-5,-17],[-5,-5,-5,-7,-6,-8,-5,-11,-9,8,-1,-6,-1,-2,-8,-7,-2,-14,-6,2,-6,-6,-5,-17],[-6,-8,-7,-12,-15,-5,-9,-10,-6,-1,7,-8,1,-3,-7,-8,-7,-6,-7,-2,-9,-7,-6,-17],[-7,0,-1,-4,-14,-3,-4,-7,-6,-6,-8,7,-2,-14,-6,-4,-3,-12,-9,-9,-2,-4,-5,-17],[-5,-4,-9,-11,-13,-4,-7,-8,-10,-1,1,-2,11,-4,-8,-5,-4,-13,-11,-1,-10,-5,-5,-17],[-8,-9,-9,-15,-13,-13,-14,-9,-6,-2,-3,-14,-4,9,-10,-6,-9,-4,2,-8,-10,-13,-8,-17],[-2,-4,-6,-8,-8,-3,-5,-6,-4,-8,-7,-6,-8,-10,8,-2,-4,-14,-13,-6,-7,-4,-5,-17],[0,-3,0,-4,-3,-5,-4,-2,-6,-7,-8,-4,-5,-6,-2,6,0,-5,-7,-6,-1,-5,-3,-17],[-1,-6,-2,-5,-8,-5,-6,-6,-7,-2,-7,-3,-4,-9,-4,0,7,-13,-6,-3,-3,-6,-4,-17],[-13,-2,-8,-15,-15,-13,-17,-15,-7,-14,-6,-12,-13,-4,-14,-5,-13,13,-5,-15,-10,-14,-11,-17],[-8,-10,-4,-11,-4,-12,-8,-14,-3,-6,-7,-9,-11,2,-13,-7,-6,-5,10,-7,-6,-9,-7,-17],[-2,-8,-8,-8,-6,-7,-6,-5,-6,2,-2,-9,-1,-8,-6,-6,-3,-15,-7,7,-8,-6,-5,-17],[-3,-7,6,6,-12,-3,1,-3,-1,-6,-9,-2,-10,-10,-7,-1,-3,-10,-6,-8,6,0,-5,-17],[-3,-4,-3,1,-14,6,6,-5,-1,-6,-7,-4,-5,-13,-4,-5,-6,-14,-9,-6,0,6,-5,-17],[-3,-6,-3,-5,-9,-5,-5,-5,-5,-5,-6,-5,-5,-8,-5,-3,-4,-11,-7,-5,-5,-5,-5,-17],[-17,-17,-17,-17,-17,-17,-17,-17,-17,-17,-17,-17,-17,-17,-17,-17,-17,-17,-17,-17,-17,-17,-17,1]];PAM70=[[5,-4,-2,-1,-4,-2,-1,0,-4,-2,-4,-4,-3,-6,0,1,1,-9,-5,-1,-1,-1,-2,-11],[-4,8,-3,-6,-5,0,-5,-6,0,-3,-6,2,-2,-7,-2,-1,-4,0,-7,-5,-4,-2,-3,-11],[-2,-3,6,3,-7,-1,0,-1,1,-3,-5,0,-5,-6,-3,1,0,-6,-3,-5,5,-1,-2,-11],[-1,-6,3,6,-9,0,3,-1,-1,-5,-8,-2,-7,-10,-4,-1,-2,-10,-7,-5,5,2,-3,-11],[-4,-5,-7,-9,9,-9,-9,-6,-5,-4,-10,-9,-9,-8,-5,-1,-5,-11,-2,-4,-8,-9,-6,-11],[-2,0,-1,0,-9,7,2,-4,2,-5,-3,-1,-2,-9,-1,-3,-3,-8,-8,-4,-1,5,-2,-11],[-1,-5,0,3,-9,2,6,-2,-2,-4,-6,-2,-4,-9,-3,-2,-3,-11,-6,-4,2,5,-3,-11],[0,-6,-1,-1,-6,-4,-2,6,-6,-6,-7,-5,-6,-7,-3,0,-3,-10,-9,-3,-1,-3,-3,-11],[-4,0,1,-1,-5,2,-2,-6,8,-6,-4,-3,-6,-4,-2,-3,-4,-5,-1,-4,0,1,-3,-11],[-2,-3,-3,-5,-4,-5,-4,-6,-6,7,1,-4,1,0,-5,-4,-1,-9,-4,3,-4,-4,-3,-11],[-4,-6,-5,-8,-10,-3,-6,-7,-4,1,6,-5,2,-1,-5,-6,-4,-4,-4,0,-6,-4,-4,-11],[-4,2,0,-2,-9,-1,-2,-5,-3,-4,-5,6,0,-9,-4,-2,-1,-7,-7,-6,-1,-2,-3,-11],[-3,-2,-5,-7,-9,-2,-4,-6,-6,1,2,0,10,-2,-5,-3,-2,-8,-7,0,-6,-3,-3,-11],[-6,-7,-6,-10,-8,-9,-9,-7,-4,0,-1,-9,-2,8,-7,-4,-6,-2,4,-5,-7,-9,-5,-11],[0,-2,-3,-4,-5,-1,-3,-3,-2,-5,-5,-4,-5,-7,7,0,-2,-9,-9,-3,-4,-2,-3,-11],[1,-1,1,-1,-1,-3,-2,0,-3,-4,-6,-2,-3,-4,0,5,2,-3,-5,-3,0,-2,-1,-11],[1,-4,0,-2,-5,-3,-3,-3,-4,-1,-4,-1,-2,-6,-2,2,6,-8,-4,-1,-1,-3,-2,-11],[-9,0,-6,-10,-11,-8,-11,-10,-5,-9,-4,-7,-8,-2,-9,-3,-8,13,-3,-10,-7,-10,-7,-11],[-5,-7,-3,-7,-2,-8,-6,-9,-1,-4,-4,-7,-7,4,-9,-5,-4,-3,9,-5,-4,-7,-5,-11],[-1,-5,-5,-5,-4,-4,-4,-3,-4,3,0,-6,0,-5,-3,-3,-1,-10,-5,6,-5,-4,-2,-11],[-1,-4,5,5,-8,-1,2,-1,0,-4,-6,-1,-6,-7,-4,0,-1,-7,-4,-5,5,1,-2,-11],[-1,-2,-1,2,-9,5,5,-3,1,-4,-4,-2,-3,-9,-2,-2,-3,-10,-7,-4,1,5,-3,-11],[-2,-3,-2,-3,-6,-2,-3,-3,-3,-3,-4,-3,-3,-5,-3,-1,-2,-7,-5,-2,-2,-3,-3,-11],[-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,1]];PAM250=[[2,-2,0,0,-2,0,0,1,-1,-1,-2,-1,-1,-3,1,1,1,-6,-3,0,0,0,0,-8],[-2,6,0,-1,-4,1,-1,-3,2,-2,-3,3,0,-4,0,0,-1,2,-4,-2,-1,0,-1,-8],[0,0,2,2,-4,1,1,0,2,-2,-3,1,-2,-3,0,1,0,-4,-2,-2,2,1,0,-8],[0,-1,2,4,-5,2,3,1,1,-2,-4,0,-3,-6,-1,0,0,-7,-4,-2,3,3,-1,-8],[-2,-4,-4,-5,12,-5,-5,-3,-3,-2,-6,-5,-5,-4,-3,0,-2,-8,0,-2,-4,-5,-3,-8],[0,1,1,2,-5,4,2,-1,3,-2,-2,1,-1,-5,0,-1,-1,-5,-4,-2,1,3,-1,-8],[0,-1,1,3,-5,2,4,0,1,-2,-3,0,-2,-5,-1,0,0,-7,-4,-2,3,3,-1,-8],[1,-3,0,1,-3,-1,0,5,-2,-3,-4,-2,-3,-5,0,1,0,-7,-5,-1,0,0,-1,-8],[-1,2,2,1,-3,3,1,-2,6,-2,-2,0,-2,-2,0,-1,-1,-3,0,-2,1,2,-1,-8],[-1,-2,-2,-2,-2,-2,-2,-3,-2,5,2,-2,2,1,-2,-1,0,-5,-1,4,-2,-2,-1,-8],[-2,-3,-3,-4,-6,-2,-3,-4,-2,2,6,-3,4,2,-3,-3,-2,-2,-1,2,-3,-3,-1,-8],[-1,3,1,0,-5,1,0,-2,0,-2,-3,5,0,-5,-1,0,0,-3,-4,-2,1,0,-1,-8],[-1,0,-2,-3,-5,-1,-2,-3,-2,2,4,0,6,0,-2,-2,-1,-4,-2,2,-2,-2,-1,-8],[-3,-4,-3,-6,-4,-5,-5,-5,-2,1,2,-5,0,9,-5,-3,-3,0,7,-1,-4,-5,-2,-8],[1,0,0,-1,-3,0,-1,0,0,-2,-3,-1,-2,-5,6,1,0,-6,-5,-1,-1,0,-1,-8],[1,0,1,0,0,-1,0,1,-1,-1,-3,0,-2,-3,1,2,1,-2,-3,-1,0,0,0,-8],[1,-1,0,0,-2,-1,0,0,-1,0,-2,0,-1,-3,0,1,3,-5,-3,0,0,-1,0,-8],[-6,2,-4,-7,-8,-5,-7,-7,-3,-5,-2,-3,-4,0,-6,-2,-5,17,0,-6,-5,-6,-4,-8],[-3,-4,-2,-4,0,-4,-4,-5,0,-1,-1,-4,-2,7,-5,-3,-3,0,10,-2,-3,-4,-2,-8],[0,-2,-2,-2,-2,-2,-2,-1,-2,4,2,-2,2,-1,-1,-1,0,-6,-2,4,-2,-2,-1,-8],[0,-1,2,3,-4,1,3,0,1,-2,-3,1,-2,-4,-1,0,0,-5,-3,-2,3,2,-1,-8],[0,0,1,3,-5,3,3,0,2,-2,-3,0,-2,-5,0,0,-1,-6,-4,-2,2,3,-1,-8],[0,-1,0,-1,-3,-1,-1,-1,-1,-1,-1,-1,-1,-2,-1,0,0,-4,-2,-1,-1,-1,-1,-8],[-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,1]];SCHNEIDER=[[11.6,-2.7,9.7,-1.7,-2.7,-6.4,-3.9,-5.6,5.1,-5,3.6,-4.2,-6.3,-13,-7.1,-11.5,.4,-6,-1.9,-5.3,-8.5,-11.2,-8.9,-10.8,2.1,0,1.4,.2,-10.2,-13.5,-13,-12.5,-2.6,-8.5,-5,-8.1,-6.3,-9.9,-7.5,-9,-7.1,-10.2,-8.2,-9.2,-8.2,-12.5,-11.1,-11.4,-50,-14.8,-50,-13.8,-7.3,-10.1,-8.4,-9.1,-50,-13,-13.5,-12.4,-10.7,-18.1,-11.8,-17.2],[-2.7,13,-3.3,10.9,-3.5,-.4,-3.3,-1.8,-5.4,4.6,-5.5,3,-10.2,-7.9,-9.9,-9.6,-5,.5,-5.5,-1,-10.3,-8.1,-9.4,-9.6,-8.1,-5,-7.3,-6.3,-13.4,-11.3,-14.4,-12.9,-6.3,.8,-6.4,-1.1,-7.4,-5,-6.2,-6.5,-5.6,-1.6,-4.7,-3,-10.8,-8.7,-11.9,-10,-50,-6.2,-50,-7.5,-6.3,-4.3,-6.2,-5.4,-50,-7,-16.3,-8.2,-13.2,-12.3,-13.1,-13.3],[9.7,-3.3,11.6,-2.8,-4.5,-6.7,-3.1,-6.9,3.3,-5.5,4.8,-5.1,-8.9,-13.2,-5.7,-12.6,-1.5,-6.1,-.6,-6.1,-10,-11.8,-8.6,-11.9,1.2,.5,2.2,.1,-11.8,-14,-11.9,-13.4,-4.9,-9.1,-3.4,-8.9,-8,-10,-7.2,-10,-9.1,-10.2,-7.1,-9.9,-10.1,-13,-10.6,-12.7,-50,-14.9,-50,-14.4,-8.9,-10.8,-8.9,-10.4,-50,-13.1,-11.8,-13,-12.4,-19.4,-11.5,-17.8],[-1.7,10.9,-2.8,12.9,-2.7,-2.2,-2.8,.2,-4.8,2.9,-5.2,5.2,-9.1,-9.5,-9,-7,-4,-1,-5,1,-9,-8.8,-8.9,-7.7,-7,-6.8,-7.1,-4.3,-12.4,-12.9,-13.9,-10,-4.9,-.7,-5.6,1.4,-6,-6.5,-6.2,-4.8,-5.1,-3.2,-5,-1.2,-9.8,-9.9,-11.3,-8.2,-50,-7.6,-50,-5.1,-5.5,-5.8,-5.9,-4.2,-50,-8.3,-15.5,-5.9,-11.6,-14.2,-12,-11.6],[-2.7,-3.5,-4.5,-2.7,11.7,9,10.6,9.6,-3.2,-.7,-5.1,-.4,.7,-4.6,-.4,-3.6,-4.8,-8.9,-6.5,-7.8,-1.4,-4.1,-2.9,-3.3,-8,-9.1,-8,-8.2,-6,-9.3,-7.7,-8.5,-6.4,-10.1,-7.5,-8.6,2.8,-.7,.9,.1,-5.9,-7.3,-6.5,-6.5,-.4,-3.9,-2.6,-3.1,-50,-14.6,-50,-12.6,2.9,.1,1.8,1,-50,-9.2,-13.6,-7.7,-4.8,-12.2,-6.2,-11],[-6.4,-.4,-6.7,-2.2,9,12.3,9.8,9.6,-7.1,2.4,-7.2,.3,-2.9,-1.2,-3,-3.3,-7.6,-6.7,-8.1,-7.9,-4.9,-1.9,-4.5,-3.8,-9.5,-7.8,-9.3,-8.9,-9.4,-7.1,-9,-9,-9.4,-7.5,-9.3,-9.2,-.7,2.6,.2,-.1,-8,-4.6,-7.7,-6.1,-3.6,-1,-4.1,-3.1,-50,-11.6,-50,-11.6,.2,2.3,.4,.5,-50,-6.5,-15.3,-7.8,-8.4,-9.5,-8.3,-11.1],[-3.9,-3.3,-3.1,-2.8,10.6,9.8,12.2,9.8,-4.9,.1,-3.6,-.2,-1.7,-4.1,.9,-3.5,-5.9,-8.9,-5.6,-8.5,-3.9,-3.9,-2.2,-4.5,-7.3,-7.5,-6.4,-8.5,-7.1,-8.2,-6.7,-7.8,-7.9,-9.1,-7.1,-9.4,.9,-.2,2.5,-.3,-6.9,-6.5,-5.5,-6.8,-1.7,-3.4,-1.7,-2.8,-50,-13,-50,-11.5,1.5,.7,2.7,.6,-50,-8.9,-12.1,-7.4,-6.1,-11.5,-5.4,-10.4],[-5.6,-1.8,-6.9,.2,9.6,9.6,9.8,11.6,-6.6,.9,-7.2,2.5,-2.3,-3.4,-2.3,-.6,-6.5,-8.2,-8,-6.3,-3.7,-3.5,-3.9,-1.6,-9.9,-8.9,-9.6,-7,-8.6,-8.9,-8.8,-6.8,-8.6,-8.2,-8.8,-6.8,.3,.1,.2,2.4,-7.4,-6.2,-6.9,-4.4,-2.9,-2.9,-3.5,-.9,-50,-12.2,-50,-10.1,1.2,.6,1.2,2.4,-50,-7.6,-16.1,-5.8,-7.2,-10.8,-7.4,-9],[5.1,-5.4,3.3,-4.8,-3.2,-7.1,-4.9,-6.6,13.3,-2.8,11.2,-1.9,-5.7,-12.5,-7.2,-11.6,-.7,-4.8,-3.1,-4.3,-10,-11.6,-8.8,-11.7,10.5,7.7,9.1,8.5,-9.8,-12.7,-11.7,-11.8,-6.3,-11.4,-8.8,-11,-7.5,-10.3,-8.3,-9.9,-1.9,-6.7,-4.1,-6.4,-7.9,-12.5,-11.4,-11.7,-50,-14,-50,-13.2,-8.5,-10.4,-9.1,-9.6,-50,-9.8,-7.7,-8.8,-10.3,-17.9,-11.8,-16],[-5,4.6,-5.5,2.9,-.7,2.4,.1,.9,-2.8,12.8,-2.6,11,-8.4,-6.3,-8.3,-7.7,-6.1,-2.9,-6.5,-4.2,-8.5,-5.9,-7.5,-7.7,-5.5,-2.4,-5.5,-4.1,-12.9,-10.3,-12.7,-11.3,-7.4,-3.1,-7.4,-4.9,-4.4,-1.8,-3.5,-3.5,-1.6,3,-.8,.9,-8.4,-6.3,-9.6,-7.3,-50,-9,-50,-9.7,-2.3,-.2,-1.2,-1.5,-50,-.7,-13.3,-2,-11.8,-11.9,-12.3,-12.7],[3.6,-5.5,4.8,-5.2,-5.1,-7.2,-3.6,-7.2,11.2,-2.6,13.4,-2.1,-7.7,-12.5,-5.3,-11.9,-2.2,-4.4,-1.9,-4.8,-10.2,-11.5,-8.1,-12,9.3,8.2,10,8,-10.8,-11.9,-10.7,-12.4,-8.2,-11.8,-6.9,-11.5,-8.4,-9.9,-7.1,-10.6,-4.7,-6.8,-1.2,-7,-9.8,-11.6,-9.6,-12.1,-50,-14.1,-50,-12.7,-10,-10.8,-8.8,-10.5,-50,-9.2,-4.2,-9.3,-11,-18.2,-11.1,-16.1],[-4.2,3,-5.1,5.2,-.4,.3,-.2,2.5,-1.9,11,-2.1,13.2,-7.6,-8.5,-8,-5.3,-5.6,-4.5,-6.8,-2.4,-7.8,-7.9,-7.9,-6.2,-5.7,-5.1,-5.4,-2.1,-12.4,-12.3,-13.1,-10.1,-6.6,-4.4,-6.9,-2.6,-3.6,-3.8,-3.7,-2,-1.4,.8,-.9,3,-8.2,-8.1,-9.2,-5.8,-50,-10.1,-50,-7.4,-1.7,-2,-1.5,-.5,-50,-2.1,-12.6,-.4,-11.6,-13.9,-11.4,-11.1],[-6.3,-10.2,-8.9,-9.1,.7,-2.9,-1.7,-2.3,-5.7,-8.4,-7.7,-7.6,13.2,9.6,3.5,9.7,-8.7,-12.4,-10.7,-10.7,-7.8,-10.2,-8.8,-9.6,-9.5,-11.9,-10.9,-10.5,2.3,-.4,-.2,-.3,-9.7,-15.5,-11.4,-13.7,-3,-6.4,-4.1,-5.4,-9.6,-11.9,-10.5,-11.8,6.2,3.3,3.7,3.6,-50,-13.6,-50,-11.9,-5.6,-8.8,-7.2,-8.9,-50,-12.4,-14.1,-11.6,2.8,-6.4,.5,-5.2],[-13,-7.9,-13.2,-9.5,-4.6,-1.2,-4.1,-3.4,-12.5,-6.3,-12.5,-8.5,9.6,12.7,.2,10.5,-12.4,-11.6,-13.2,-12,-12.4,-10.1,-11.6,-12,-15.1,-13.1,-14.3,-13.4,-1.4,1.4,-1.6,-.5,-14.9,-14.3,-15.2,-16.8,-7.7,-4.7,-6.3,-6.6,-14.6,-10.8,-12.8,-13,2.3,6,2.5,3.6,-50,-11.2,-50,-11.9,-10.5,-9.2,-10.5,-10.5,-50,-10.3,-16.2,-11.3,-1.7,-3.7,-2.5,-5.4],[-7.1,-9.9,-5.7,-9,-.4,-3,.9,-2.3,-7.2,-8.3,-5.3,-8,3.5,.2,14.3,1,-7.3,-11.2,-6.9,-9.7,-8.5,-10.2,-7.7,-9.8,-10,-10.4,-8.4,-10.2,1,-.6,1.7,-.5,-11.1,-14.8,-9.7,-14.5,-3.7,-5.8,-3.1,-5.6,-10.4,-11.5,-8.2,-11.1,.6,-1.6,1.6,-1.1,-50,-12.4,-50,-11.5,-5.5,-8,-4.9,-7.2,-50,-12.4,-10.3,-11.6,.7,-6.8,2.4,-6],[-11.5,-9.6,-12.6,-7,-3.6,-3.3,-3.5,-.6,-11.6,-7.7,-11.9,-5.3,9.7,10.5,1,12.6,-12,-12.2,-12.5,-9.7,-11.1,-11.2,-11.9,-9.4,-12.9,-14.3,-14,-11.9,-1,-.4,-1.6,1.2,-13.9,-15.4,-13.7,-12.6,-6.2,-6.7,-6.3,-4.4,-13,-12.2,-13,-10.4,2.9,3.8,2.5,5.8,-50,-12.5,-50,-10.2,-9.6,-9.7,-9.6,-8.3,-50,-11.6,-15.4,-9.4,-1.1,-5.4,-1.6,-3.3],[.4,-5,-1.5,-4,-4.8,-7.6,-5.9,-6.5,-.7,-6.1,-2.2,-5.6,-8.7,-12.4,-7.3,-12,12.8,2.3,10.2,3,0,-3.4,-.7,-3.2,2.5,-.8,.9,.2,-3,-7.2,-5.7,-6.1,-.2,-6.6,-1.8,-6,-5.3,-8.2,-5.7,-7.6,-6.7,-9.6,-7.5,-9.3,-7.1,-10.5,-9.6,-9.4,-50,-8.1,-50,-7.2,-4.3,-6.8,-5.7,-6.3,-50,-9.5,-9.6,-8.9,-6.2,-12.8,-6.8,-11.8],[-6,.5,-6.1,-1,-8.9,-6.7,-8.9,-8.2,-4.8,-2.9,-4.4,-4.5,-12.4,-11.6,-11.2,-12.2,2.3,14.6,1.9,12.9,-5.5,-2.6,-4.1,-4.7,-1.2,3,-1.1,1.6,-8,-4.7,-8.7,-6,-8.2,-4.7,-7.8,-6.7,-10,-8.3,-8.9,-9.9,-10.8,-7.1,-10,-9.2,-11.6,-10.1,-12.3,-11.9,-50,2.2,-50,.9,-7.9,-5.9,-7.4,-6.9,-50,-4.6,-11.6,-5.6,-9.7,-5.9,-9.9,-7.3],[-1.9,-5.5,-.6,-5,-6.5,-8.1,-5.6,-8,-3.1,-6.5,-1.9,-6.8,-10.7,-13.2,-6.9,-12.5,10.2,1.9,11.9,2.1,-2.3,-4.1,-.5,-4.6,-.1,-.9,2.4,-.8,-5.1,-6.9,-4.8,-6.7,-2.3,-7.1,-.8,-7.2,-7.2,-8,-5.6,-8.5,-9.4,-9.7,-7.2,-9.8,-9.2,-11.1,-9.5,-10.7,-50,-8.7,-50,-8.6,-6.1,-7.5,-5.5,-7.7,-50,-10.4,-7.7,-10,-7.3,-13.6,-6.4,-13.3],[-5.3,-1,-6.1,1,-7.8,-7.9,-8.5,-6.3,-4.3,-4.2,-4.8,-2.4,-10.7,-12,-9.7,-9.7,3,12.9,2.1,14.7,-4.9,-3.8,-4,-2.4,-1,.8,-1.3,3.4,-7.6,-5.7,-8.1,-3.5,-6.8,-5.8,-7.2,-4.2,-8.9,-10.2,-8.4,-8.2,-9.9,-8.4,-9.7,-6.4,-11.1,-11.1,-11.8,-10,-50,.4,-50,2.6,-7.2,-7,-7.4,-5.1,-50,-5.7,-9.8,-3.2,-8.4,-7.4,-8.9,-5.9],[-8.5,-10.3,-10,-9,-1.4,-4.9,-3.9,-3.7,-10,-8.5,-10.2,-7.8,-7.8,-12.4,-8.5,-11.1,0,-5.5,-2.3,-4.9,12.6,10,11.1,10.5,-6,-8.3,-6.9,-7.5,-2.2,-7.4,-5.3,-5.9,-8.9,-12.5,-9.4,-11.6,-.7,-3.9,-2.3,-3,-9.1,-9.8,-9.2,-9.5,-5.6,-9,-8,-8.5,-50,-15.3,-50,-14.1,2.3,-1.4,.3,-.5,-50,-13.6,-14.3,-11.5,-5.3,-13.7,-6.1,-12.7],[-11.2,-8.1,-11.8,-8.8,-4.1,-1.9,-3.9,-3.5,-11.6,-5.9,-11.5,-7.9,-10.2,-10.1,-10.2,-11.2,-3.4,-2.6,-4.1,-3.8,10,13.1,10.7,10.6,-8.1,-5.2,-8,-6.7,-6.1,-3.7,-7.5,-5.6,-11.1,-10.3,-10.6,-11.9,-3.2,-1,-2.2,-2.8,-10.5,-8.1,-9.4,-9.5,-8.3,-6.9,-9.4,-8.8,-50,-11.3,-50,-12.8,-.6,2.2,-.3,.1,-50,-10.1,-17.5,-11.1,-8.6,-9.9,-8.6,-11.9],[-8.9,-9.4,-8.6,-8.9,-2.9,-4.5,-2.2,-3.9,-8.8,-7.5,-8.1,-7.9,-8.8,-11.6,-7.7,-11.9,-.7,-4.1,-.5,-4,11.1,10.7,13.2,10.4,-5.7,-5.8,-3.5,-6.1,-3.6,-6.5,-3.3,-5.5,-9.4,-11,-8.7,-11.2,-1.8,-2.7,.7,-3,-9.1,-8.2,-7.3,-9.4,-7.2,-8.2,-7.2,-8.2,-50,-13.2,-50,-13.3,.5,-.9,1.8,-.6,-50,-11.4,-11.1,-10.5,-6.1,-12.9,-5,-11.9],[-10.8,-9.6,-11.9,-7.7,-3.3,-3.8,-4.5,-1.6,-11.7,-7.7,-12,-6.2,-9.6,-12,-9.8,-9.4,-3.2,-4.7,-4.6,-2.4,10.5,10.6,10.4,12.6,-8.2,-7.9,-9,-4.7,-6.1,-6,-7.5,-2.9,-10.9,-12.2,-11.2,-10.9,-2.4,-2.9,-2.7,-.9,-10.4,-9.7,-10.2,-8,-8.4,-9.1,-9.3,-6.5,-50,-13.3,-50,-11,-0,-.4,-.4,2.3,-50,-10.9,-17.2,-8.3,-8.3,-12.7,-7.8,-9.3],[2.1,-8.1,1.2,-7,-8,-9.5,-7.3,-9.9,10.5,-5.5,9.3,-5.7,-9.5,-15.1,-10,-12.9,2.5,-1.2,-.1,-1,-6,-8.1,-5.7,-8.2,13.8,11.3,11.8,12.1,-6,-9.1,-9,-9.5,-8.9,-13.4,-10,-13.1,-9.9,-11.7,-9.8,-12.8,-5.9,-9.4,-6.5,-8.1,-10.7,-14,-13.3,-13.9,-50,-11.9,-50,-9.7,-8.9,-10.8,-9,-11.1,-50,-6.5,-5.3,-6.3,-10.5,-16.2,-10.4,-15.2],[0,-5,.5,-6.8,-9.1,-7.8,-7.5,-8.9,7.7,-2.4,8.2,-5.1,-11.9,-13.1,-10.4,-14.3,-.8,3,-.9,.8,-8.3,-5.2,-5.8,-7.9,11.3,15,11.2,12.8,-9.7,-5.3,-9.2,-7.8,-11.7,-10.6,-10.1,-12.2,-11.7,-8.8,-8.9,-11.8,-9.3,-5,-8,-8.2,-13.6,-11.4,-12.8,-13,-50,-7.2,-50,-8.4,-11,-7.7,-8.7,-10.2,-50,-1.5,-7.1,-4.9,-11.2,-11.6,-11.6,-15],[1.4,-7.3,2.2,-7.1,-8,-9.3,-6.4,-9.6,9.1,-5.5,10,-5.4,-10.9,-14.3,-8.4,-14,.9,-1.1,2.4,-1.3,-6.9,-8,-3.5,-9,11.8,11.2,13.4,11.4,-7.3,-8.8,-6.5,-8.5,-10,-12.5,-7.8,-12.5,-9.6,-11,-7.1,-10.7,-7.9,-8,-4.3,-9.4,-11.4,-12.3,-10.9,-12.9,-50,-11.8,-50,-11.2,-9.4,-9.8,-7.3,-10.5,-50,-6.2,-2.2,-6.7,-9.8,-15.2,-8.5,-14.9],[.2,-6.3,.1,-4.3,-8.2,-8.9,-8.5,-7,8.5,-4.1,8,-2.1,-10.5,-13.4,-10.2,-11.9,.2,1.6,-.8,3.4,-7.5,-6.7,-6.1,-4.7,12.1,12.8,11.4,14.7,-8.7,-7.4,-9.4,-5.3,-9.9,-11.8,-10.5,-10.3,-9.9,-10.1,-9.3,-9.3,-8.1,-7.2,-8,-5.2,-12,-12.1,-12.6,-10.9,-50,-7.9,-50,-5.3,-9.3,-8.8,-8.9,-7,-50,-3.6,-7.1,-1.2,-10.2,-12.7,-9.9,-11],[-10.2,-13.4,-11.8,-12.4,-6,-9.4,-7.1,-8.6,-9.8,-12.9,-10.8,-12.4,2.3,-1.4,1,-1,-3,-8,-5.1,-7.6,-2.2,-6.1,-3.6,-6.1,-6,-9.7,-7.3,-8.7,11.2,7.9,8.9,8.1,-12.1,-17.4,-13.2,-16.8,-6.3,-9.5,-7.5,-8.8,-12.7,-15.2,-13.1,-14.2,0,-3.1,-1.8,-3.1,-50,-10.7,-50,-9.3,-4.6,-8.9,-5.9,-8.3,-50,-12.8,-9.6,-10.6,9.5,-3.2,8.2,-2.8],[-13.5,-11.3,-14,-12.9,-9.3,-7.1,-8.2,-8.9,-12.7,-10.3,-11.9,-12.3,-.4,1.4,-.6,-.4,-7.2,-4.7,-6.9,-5.7,-7.4,-3.7,-6.5,-6,-9.1,-5.3,-8.8,-7.4,7.9,11.9,7.8,9.3,-15.2,-15.1,-14.6,-17.2,-9.7,-7.3,-8.2,-9.2,-15,-12.8,-14.1,-14.9,-2.8,.2,-2.9,-2.3,-50,-7.4,-50,-8.7,-9.4,-7.3,-9.4,-9.4,-50,-8,-11.9,-9.7,6.5,.5,6.4,-1.8],[-13,-14.4,-11.9,-13.9,-7.7,-9,-6.7,-8.8,-11.7,-12.7,-10.7,-13.1,-.2,-1.6,1.7,-1.6,-5.7,-8.7,-4.8,-8.1,-5.3,-7.5,-3.3,-7.5,-9,-9.2,-6.5,-9.4,8.9,7.8,10.1,7.8,-14.3,-17.7,-13,-17.8,-8,-9.4,-6.2,-9.2,-15.1,-14.9,-12.2,-14.9,-1.8,-3.2,-.8,-3.2,-50,-10.8,-50,-9.9,-7.3,-9.6,-6.4,-9.4,-50,-12.3,-8.7,-11.3,7.6,-3.3,8.7,-2.9],[-12.5,-12.9,-13.4,-10,-8.5,-9,-7.8,-6.8,-11.8,-11.3,-12.4,-10.1,-.3,-.5,-.5,1.2,-6.1,-6,-6.7,-3.5,-5.9,-5.6,-5.5,-2.9,-9.5,-7.8,-8.5,-5.3,8.1,9.3,7.8,11.8,-14.4,-15.7,-14.5,-14.6,-8.4,-8.7,-7.9,-7.1,-14.3,-13.8,-13.8,-12.3,-2.4,-2.2,-2.9,-.2,-50,-8.9,-50,-7.1,-8.1,-9.1,-8.7,-6.6,-50,-9.7,-11.4,-8,6.8,-1.8,6.9,.4],[-2.6,-6.3,-4.9,-4.9,-6.4,-9.4,-7.9,-8.6,-6.3,-7.4,-8.2,-6.6,-9.7,-14.9,-11.1,-13.9,-.2,-8.2,-2.3,-6.8,-8.9,-11.1,-9.4,-10.9,-8.9,-11.7,-10,-9.9,-12.1,-15.2,-14.3,-14.4,11.1,2.9,9.2,3.5,-3,-7,-4.3,-6.2,-2.2,-6.6,-3.7,-5.7,-6,-10.4,-8.6,-9.5,-50,-15.5,-50,-13.9,-7.8,-10.5,-8.7,-9.6,-50,-16.5,-17.1,-14.8,-12.1,-18.9,-12.4,-17.4],[-8.5,.8,-9.1,-.7,-10.1,-7.5,-9.1,-8.2,-11.4,-3.1,-11.8,-4.4,-15.5,-14.3,-14.8,-15.4,-6.6,-4.7,-7.1,-5.8,-12.5,-10.3,-11,-12.2,-13.4,-10.6,-12.5,-11.8,-17.4,-15.1,-17.7,-15.7,2.9,12.5,3.1,10.3,-7.7,-5.2,-6.2,-7.3,-5.4,-1.7,-5.4,-3.7,-11.6,-9.1,-13,-10.8,-50,-10.3,-50,-11.2,-9.8,-8.3,-9.1,-9.7,-50,-12.7,-20.6,-13.1,-16,-16.6,-17,-18.4],[-5,-6.4,-3.4,-5.6,-7.5,-9.3,-7.1,-8.8,-8.8,-7.4,-6.9,-6.9,-11.4,-15.2,-9.7,-13.7,-1.8,-7.8,-.8,-7.2,-9.4,-10.6,-8.7,-11.2,-10,-10.1,-7.8,-10.5,-13.2,-14.6,-13,-14.5,9.2,3.1,10.8,3,-4.5,-6.7,-2.7,-6.7,-5,-6.8,-2.5,-6.7,-7.5,-10.4,-7.4,-10.2,-50,-15.5,-50,-14.2,-8.9,-10.2,-8.5,-10,-50,-15.6,-15.3,-15.5,-13,-18.8,-12.6,-18.3],[-8.1,-1.1,-8.9,1.4,-8.6,-9.2,-9.4,-6.8,-11,-4.9,-11.5,-2.6,-13.7,-16.8,-14.5,-12.6,-6,-6.7,-7.2,-4.2,-11.6,-11.9,-11.2,-10.9,-13.1,-12.2,-12.5,-10.3,-16.8,-17.2,-17.8,-14.6,3.5,10.3,3,12.4,-6.9,-7.5,-6.8,-4.9,-5.4,-4.2,-5.4,-1.3,-10.8,-11.5,-12.4,-8.2,-50,-12.5,-50,-8.9,-9.2,-10,-9.4,-7.9,-50,-14.3,-19.9,-11.4,-16.2,-19.2,-15.8,-15.9],[-6.3,-7.4,-8,-6,2.8,-.7,.9,.3,-7.5,-4.4,-8.4,-3.6,-3,-7.7,-3.7,-6.2,-5.3,-10,-7.2,-8.9,-.7,-3.2,-1.8,-2.4,-9.9,-11.7,-9.6,-9.9,-6.3,-9.7,-8,-8.4,-3,-7.7,-4.5,-6.9,11.3,8.2,9.4,9.1,-1,-3.3,-1.8,-2.4,1.5,-2.1,-.4,-1.1,-50,-14.5,-50,-12.9,2.8,-0,1.4,.7,-50,-8.7,-14.1,-7.5,-5.2,-12.5,-6.5,-10.7],[-9.9,-5,-10,-6.5,-.7,2.6,-.2,.1,-10.3,-1.8,-9.9,-3.8,-6.4,-4.7,-5.8,-6.7,-8.2,-8.3,-8,-10.2,-3.9,-1,-2.7,-2.9,-11.7,-8.8,-11,-10.1,-9.5,-7.3,-9.4,-8.7,-7,-5.2,-6.7,-7.5,8.2,11.6,8.8,9.1,-3.7,-.9,-3.1,-3,-2,1.2,-2.3,-1.3,-50,-12.1,-50,-12.6,.1,2.5,.7,.6,-50,-6,-14.8,-7.5,-8.6,-9.4,-8.5,-11.2],[-7.5,-6.2,-7.2,-6.2,.9,.2,2.5,.2,-8.3,-3.5,-7.1,-3.7,-4.1,-6.3,-3.1,-6.3,-5.7,-8.9,-5.6,-8.4,-2.3,-2.2,.7,-2.7,-9.8,-8.9,-7.1,-9.3,-7.5,-8.2,-6.2,-7.9,-4.3,-6.2,-2.7,-6.8,9.4,8.8,12.1,8.8,-2.1,-2,.1,-2.4,0,-1.1,1.3,-.8,-50,-11.9,-50,-12.6,1.2,.7,3.5,.8,-50,-7.1,-12.4,-7.1,-7.1,-10.6,-5,-10.6],[-9,-6.5,-10,-4.8,.1,-.1,-.3,2.4,-9.9,-3.5,-10.6,-2,-5.4,-6.6,-5.6,-4.4,-7.6,-9.9,-8.5,-8.2,-3,-2.8,-3,-.9,-12.8,-11.8,-10.7,-9.3,-8.8,-9.2,-9.2,-7.1,-6.2,-7.3,-6.7,-4.9,9.1,9.1,8.8,11.2,-3.1,-3,-3.3,-1,-1.1,-1.4,-2,1.2,-50,-12.8,-50,-10.9,.8,.5,.7,2.3,-50,-7.5,-16.5,-5.9,-7.8,-11.1,-7.8,-9],[-7.1,-5.6,-9.1,-5.1,-5.9,-8,-6.9,-7.4,-1.9,-1.6,-4.7,-1.4,-9.6,-14.6,-10.4,-13,-6.7,-10.8,-9.4,-9.9,-9.1,-10.5,-9.1,-10.4,-5.9,-9.3,-7.9,-8.1,-12.7,-15,-15.1,-14.3,-2.2,-5.4,-5,-5.4,-1,-3.7,-2.1,-3.1,12.8,9.6,11.1,10.1,-4.8,-9.4,-8.1,-8.6,-50,-18.3,-50,-15.4,-5.9,-7.5,-6.6,-7.1,-50,-9.5,-11.7,-8.4,-12.5,-17.3,-13.2,-15.4],[-10.2,-1.6,-10.2,-3.2,-7.3,-4.6,-6.5,-6.2,-6.7,3,-6.8,.8,-11.9,-10.8,-11.5,-12.2,-9.6,-7.1,-9.7,-8.4,-9.8,-8.1,-8.2,-9.7,-9.4,-5,-8,-7.2,-15.2,-12.8,-14.9,-13.8,-6.6,-1.7,-6.8,-4.2,-3.3,-.9,-2,-3,9.6,12.8,9.7,10.5,-8.5,-5.6,-9.3,-7.8,-50,-12.7,-50,-13.8,-6.8,-5.1,-5.3,-6.5,-50,-4.1,-12.8,-5.8,-14.4,-14.1,-13.6,-14.8],[-8.2,-4.7,-7.1,-5,-6.5,-7.7,-5.5,-6.9,-4.1,-.8,-1.2,-.9,-10.5,-12.8,-8.2,-13,-7.5,-10,-7.2,-9.7,-9.2,-9.4,-7.3,-10.2,-6.5,-8,-4.3,-8,-13.1,-14.1,-12.2,-13.8,-3.7,-5.4,-2.5,-5.4,-1.8,-3.1,.1,-3.3,11.1,9.7,12.9,9.8,-5.5,-8.1,-5.4,-7.8,-50,-16.4,-50,-14.8,-5.9,-7.1,-4.7,-7.2,-50,-8.4,-6.4,-8.1,-12.1,-16.2,-10.3,-15.8],[-9.2,-3,-9.9,-1.2,-6.5,-6.1,-6.8,-4.4,-6.4,.9,-7,3,-11.8,-13,-11.1,-10.4,-9.3,-9.2,-9.8,-6.4,-9.5,-9.5,-9.4,-8,-8.1,-8.2,-9.4,-5.2,-14.2,-14.9,-14.9,-12.3,-5.7,-3.7,-6.7,-1.3,-2.4,-3,-2.4,-1,10.1,10.5,9.8,13.1,-7.2,-8,-8.4,-5,-50,-14.7,-50,-11.4,-6.3,-6.7,-5.8,-5,-50,-6.1,-13.4,-3.6,-13,-16,-13.7,-13.3],[-8.2,-10.8,-10.1,-9.8,-.4,-3.6,-1.7,-2.9,-7.9,-8.4,-9.8,-8.2,6.2,2.3,.6,2.9,-7.1,-11.6,-9.2,-11.1,-5.6,-8.3,-7.2,-8.4,-10.7,-13.6,-11.4,-12,0,-2.8,-1.8,-2.4,-6,-11.6,-7.5,-10.8,1.5,-2,0,-1.1,-4.8,-8.5,-5.5,-7.2,11.9,8.6,10,9,-50,-14.2,-50,-12.8,-4.1,-7.4,-5.7,-6.5,-50,-11,-14.3,-9.9,1.4,-7.9,-.7,-6.8],[-12.5,-8.7,-13,-9.9,-3.9,-1,-3.4,-2.9,-12.5,-6.3,-11.6,-8.1,3.3,6,-1.6,3.8,-10.5,-10.1,-11.1,-11.1,-9,-6.9,-8.2,-9.1,-14,-11.4,-12.3,-12.1,-3.1,.2,-3.2,-2.2,-10.4,-9.1,-10.4,-11.5,-2.1,1.2,-1.1,-1.4,-9.4,-5.6,-8.1,-8,8.6,12.4,8.6,9.5,-50,-10.4,-50,-11.6,-7.2,-5.7,-7.5,-7.4,-50,-8.6,-15.7,-9.7,-3,-3.7,-3.2,-5.9],[-11.1,-11.9,-10.6,-11.3,-2.6,-4.1,-1.7,-3.5,-11.4,-9.6,-9.6,-9.2,3.7,2.5,1.6,2.5,-9.6,-12.3,-9.5,-11.8,-8,-9.4,-7.2,-9.3,-13.3,-12.8,-10.9,-12.6,-1.8,-2.9,-.8,-2.9,-8.6,-13,-7.4,-12.4,-.4,-2.3,1.3,-2,-8.1,-9.3,-5.4,-8.4,10,8.6,11.4,8.9,-50,-13.7,-50,-13.2,-6.1,-8.1,-5.5,-7.5,-50,-11.3,-12.7,-10.1,-1.6,-7.8,-.3,-7.2],[-11.4,-10,-12.7,-8.2,-3.1,-3.1,-2.8,-.9,-11.7,-7.3,-12.1,-5.8,3.6,3.6,-1.1,5.8,-9.4,-11.9,-10.7,-10,-8.5,-8.8,-8.2,-6.5,-13.9,-13,-12.9,-10.9,-3.1,-2.3,-3.2,-.2,-9.5,-10.8,-10.2,-8.2,-1.1,-1.3,-.8,1.2,-8.6,-7.8,-7.8,-5,9,9.5,8.9,12,-50,-13,-50,-10.3,-6.2,-7,-7.1,-5.4,-50,-9.3,-14,-8.2,-2.4,-6.3,-2.4,-3.9],[-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,33.3,-50,30.6,-50,-50,-50,-50,-50,29.2,-50,-50,-50,-50,-50,-50,-50],[-14.8,-6.2,-14.9,-7.6,-14.6,-11.6,-13,-12.2,-14,-9,-14.1,-10.1,-13.6,-11.2,-12.4,-12.5,-8.1,2.2,-8.7,.4,-15.3,-11.3,-13.2,-13.3,-11.9,-7.2,-11.8,-7.9,-10.7,-7.4,-10.8,-8.9,-15.5,-10.3,-15.5,-12.5,-14.5,-12.1,-11.9,-12.8,-18.3,-12.7,-16.4,-14.7,-14.2,-10.4,-13.7,-13,-50,15.1,-50,13.3,-9.9,-5.8,-8.9,-7.6,-50,-1.5,-7.8,-3,-8.1,3.6,-9.4,2],[-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,30.6,-50,35.2,-50,-50,-50,-50,-50,28.5,-50,-50,-50,-50,-50,-50,-50],[-13.8,-7.5,-14.4,-5.1,-12.6,-11.6,-11.5,-10.1,-13.2,-9.7,-12.7,-7.4,-11.9,-11.9,-11.5,-10.2,-7.2,.9,-8.6,2.6,-14.1,-12.8,-13.3,-11,-9.7,-8.4,-11.2,-5.3,-9.3,-8.7,-9.9,-7.1,-13.9,-11.2,-14.2,-8.9,-12.9,-12.6,-12.6,-10.9,-15.4,-13.8,-14.8,-11.4,-12.8,-11.6,-13.2,-10.3,-50,13.3,-50,15.2,-8.6,-7,-8.4,-4.8,-50,-3,-7.1,-.1,-7.3,2.3,-8.7,3.9],[-7.3,-6.3,-8.9,-5.5,2.9,.2,1.5,1.2,-8.5,-2.3,-10,-1.7,-5.6,-10.5,-5.5,-9.6,-4.3,-7.9,-6.1,-7.2,2.3,-.6,.5,-0,-8.9,-11,-9.4,-9.3,-4.6,-9.4,-7.3,-8.1,-7.8,-9.8,-8.9,-9.2,2.8,.1,1.2,.8,-5.9,-6.8,-5.9,-6.3,-4.1,-7.2,-6.1,-6.2,-50,-9.9,-50,-8.6,12.5,9.4,11,9.8,-50,-4.8,-8.7,-3.5,-0,-8.6,-2.1,-7],[-10.1,-4.3,-10.8,-5.8,.1,2.3,.7,.6,-10.4,-.2,-10.8,-2,-8.8,-9.2,-8,-9.7,-6.8,-5.9,-7.5,-7,-1.4,2.2,-.9,-.4,-10.8,-7.7,-9.8,-8.8,-8.9,-7.3,-9.6,-9.1,-10.5,-8.3,-10.2,-10,-0,2.5,.7,.5,-7.5,-5.1,-7.1,-6.7,-7.4,-5.7,-8.1,-7,-50,-5.8,-50,-7,9.4,12.7,10.1,10,-50,-1.5,-11.3,-3.3,-5.4,-4.2,-5.6,-6.8],[-8.4,-6.2,-8.9,-5.9,1.8,.4,2.7,1.2,-9.1,-1.2,-8.8,-1.5,-7.2,-10.5,-4.9,-9.6,-5.7,-7.4,-5.5,-7.4,.3,-.3,1.8,-.4,-9,-8.7,-7.3,-8.9,-5.9,-9.4,-6.4,-8.7,-8.7,-9.1,-8.5,-9.4,1.4,.7,3.5,.7,-6.6,-5.3,-4.7,-5.8,-5.7,-7.5,-5.5,-7.1,-50,-8.9,-50,-8.4,11,10.1,13.2,10.2,-50,-4.2,-6.1,-3.6,-3.5,-8.4,-1.2,-6.8],[-9.1,-5.4,-10.4,-4.2,1,.5,.6,2.4,-9.6,-1.5,-10.5,-.5,-8.9,-10.5,-7.2,-8.3,-6.3,-6.9,-7.7,-5.1,-.5,.1,-.6,2.3,-11.1,-10.2,-10.5,-7,-8.3,-9.4,-9.4,-6.6,-9.6,-9.7,-10,-7.9,.7,.6,.8,2.3,-7.1,-6.5,-7.2,-5,-6.5,-7.4,-7.5,-5.4,-50,-7.6,-50,-4.8,9.8,10,10.2,12.1,-50,-3.1,-11.4,-.7,-4.6,-6.6,-4.9,-3.9],[-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,29.2,-50,28.5,-50,-50,-50,-50,-50,33.3,-50,-50,-50,-50,-50,-50,-50],[-13,-7,-13.1,-8.3,-9.2,-6.5,-8.9,-7.6,-9.8,-.7,-9.2,-2.1,-12.4,-10.3,-12.4,-11.6,-9.5,-4.6,-10.4,-5.7,-13.6,-10.1,-11.4,-10.9,-6.5,-1.5,-6.2,-3.6,-12.8,-8,-12.3,-9.7,-16.5,-12.7,-15.6,-14.3,-8.7,-6,-7.1,-7.5,-9.5,-4.1,-8.4,-6.1,-11,-8.6,-11.3,-9.3,-50,-1.5,-50,-3,-4.8,-1.5,-4.2,-3.1,-50,16.4,-5.1,14.2,-10.1,-4.3,-10,-5.4],[-13.5,-16.3,-11.8,-15.5,-13.6,-15.3,-12.1,-16.1,-7.7,-13.3,-4.2,-12.6,-14.1,-16.2,-10.3,-15.4,-9.6,-11.6,-7.7,-9.8,-14.3,-17.5,-11.1,-17.2,-5.3,-7.1,-2.2,-7.1,-9.6,-11.9,-8.7,-11.4,-17.1,-20.6,-15.3,-19.9,-14.1,-14.8,-12.4,-16.5,-11.7,-12.8,-6.4,-13.4,-14.3,-15.7,-12.7,-14,-50,-7.8,-50,-7.1,-8.7,-11.3,-6.1,-11.4,-50,-5.1,18.6,-4.8,-8.6,-8.1,-4.5,-7.3],[-12.4,-8.2,-13,-5.9,-7.7,-7.8,-7.4,-5.8,-8.8,-2,-9.3,-.4,-11.6,-11.3,-11.6,-9.4,-8.9,-5.6,-10,-3.2,-11.5,-11.1,-10.5,-8.3,-6.3,-4.9,-6.7,-1.2,-10.6,-9.7,-11.3,-8,-14.8,-13.1,-15.5,-11.4,-7.5,-7.5,-7.1,-5.9,-8.4,-5.8,-8.1,-3.6,-9.9,-9.7,-10.1,-8.2,-50,-3,-50,-.1,-3.5,-3.3,-3.6,-.7,-50,14.2,-4.8,16.4,-8.9,-5.8,-8.9,-3.4],[-10.7,-13.2,-12.4,-11.6,-4.8,-8.4,-6.1,-7.2,-10.3,-11.8,-11,-11.6,2.8,-1.7,.7,-1.1,-6.2,-9.7,-7.3,-8.4,-5.3,-8.6,-6.1,-8.3,-10.5,-11.2,-9.8,-10.2,9.5,6.5,7.6,6.8,-12.1,-16,-13,-16.2,-5.2,-8.6,-7.1,-7.8,-12.5,-14.4,-12.1,-13,1.4,-3,-1.6,-2.4,-50,-8.1,-50,-7.3,-0,-5.4,-3.5,-4.6,-50,-10.1,-8.6,-8.9,13.2,-.9,9.7,-.3],[-18.1,-12.3,-19.4,-14.2,-12.2,-9.5,-11.5,-10.8,-17.9,-11.9,-18.2,-13.9,-6.4,-3.7,-6.8,-5.4,-12.8,-5.9,-13.6,-7.4,-13.7,-9.9,-12.9,-12.7,-16.2,-11.6,-15.2,-12.7,-3.2,.5,-3.3,-1.8,-18.9,-16.6,-18.8,-19.2,-12.5,-9.4,-10.6,-11.1,-17.3,-14.1,-16.2,-16,-7.9,-3.7,-7.8,-6.3,-50,3.6,-50,2.3,-8.6,-4.2,-8.4,-6.6,-50,-4.3,-8.1,-5.8,-.9,14.2,-1.8,11.6],[-11.8,-13.1,-11.5,-12,-6.2,-8.3,-5.4,-7.4,-11.8,-12.3,-11.1,-11.4,.5,-2.5,2.4,-1.6,-6.8,-9.9,-6.4,-8.9,-6.1,-8.6,-5,-7.8,-10.4,-11.6,-8.5,-9.9,8.2,6.4,8.7,6.9,-12.4,-17,-12.6,-15.8,-6.5,-8.5,-5,-7.8,-13.2,-13.6,-10.3,-13.7,-.7,-3.2,-.3,-2.4,-50,-9.4,-50,-8.7,-2.1,-5.6,-1.2,-4.9,-50,-10,-4.5,-8.9,9.7,-1.8,11.3,-.9],[-17.2,-13.3,-17.8,-11.6,-11,-11.1,-10.4,-9,-16,-12.7,-16.1,-11.1,-5.2,-5.4,-6,-3.3,-11.8,-7.3,-13.3,-5.9,-12.7,-11.9,-11.9,-9.3,-15.2,-15,-14.9,-11,-2.8,-1.8,-2.9,.4,-17.4,-18.4,-18.3,-15.9,-10.7,-11.2,-10.6,-9,-15.4,-14.8,-15.8,-13.3,-6.8,-5.9,-7.2,-3.9,-50,2,-50,3.9,-7,-6.8,-6.8,-3.9,-50,-5.4,-7.3,-3.4,-.3,11.6,-.9,14.1]];TRANS=[[5,0,0,4],[0,5,4,0],[0,4,5,0],[4,0,0,5]];CONBLO={A:0,R:1,N:2,D:3,C:4,Q:5,E:6,G:7,H:8,I:9,L:10,K:11,M:12,F:13,P:14,S:15,T:16,W:17,Y:18,V:19,B:20,Z:21,X:22,"*":23};CONNUCL={A:0,T:1,C:2,G:3};CONSCHN={AAA:0,AAC:1,AAG:2,AAT:3,ACA:4,ACC:5,ACG:6,ACT:7,AGA:8,AGC:9,AGG:10,AGT:11,ATA:12,ATC:13,ATG:14,ATT:15,CAA:16,CAC:17,CAG:18,CAT:19,CCA:20,CCC:21,CCG:22,CCT:23,CGA:24,CGC:25,CGG:26,CGT:27,CTA:28,CTC:29,CTG:30,CTT:31,GAA:32,GAC:33,GAG:34,GAT:35,GCA:36,GCC:37,GCG:38,GCT:39,GGA:40,GGC:41,GGG:42,GGT:43,GTA:44,GTC:45,GTG:46,GTT:47,TAA:48,TAC:49,TAG:50,TAT:51,TCA:52,TCC:53,TCG:54,TCT:55,TGA:56,TGC:57,TGG:58,TGT:59,TTA:60,TTC:61,TTG:62,TTT:63};fillNeedleman(){for(let e=0;e<=this.len1;e++)this.dpGrid[e][0].value=-e*this.gap,this.dpGrid[e][0].parentI=e-1,this.dpGrid[e][0].parentJ=0;for(let e=1;e<=this.len2;e++)this.dpGrid[0][e].value=-e*this.gap,this.dpGrid[0][e].parentI=0,this.dpGrid[0][e].parentJ=e-1}fillOne(e,t){this.dpGrid[e][t].value=Math.max(this.dpGrid[e-1][t-1].value+this.scores[e-1][t-1],Math.max(this.dpGrid[e-1][t].value-this.gap,this.dpGrid[e][t-1].value-this.gap)),this.dpGrid[e][t].value==this.dpGrid[e-1][t-1].value+this.scores[e-1][t-1]?(this.dpGrid[e][t].parentI=e-1,this.dpGrid[e][t].parentJ=t-1):this.dpGrid[e][t].value==this.dpGrid[e-1][t].value-this.gap?(this.dpGrid[e][t].parentI=e-1,this.dpGrid[e][t].parentJ=t):(this.dpGrid[e][t].parentI=e,this.dpGrid[e][t].parentJ=t-1)}gridFromName(e){switch(e){case"BLOSUM45":this.alignGrid=this.BLOSUM45,this.connections=this.CONBLO,this.step=1;break;case"BLOSUM50":this.alignGrid=this.BLOSUM50,this.connections=this.CONBLO,this.step=1;break;case"BLOSUM62":this.alignGrid=this.BLOSUM62,this.connections=this.CONBLO,this.step=1;break;case"BLOSUM80":this.alignGrid=this.BLOSUM80,this.connections=this.CONBLO,this.step=1;break;case"BLOSUM90":this.alignGrid=this.BLOSUM90,this.connections=this.CONBLO,this.step=1;break;case"PAM30":this.alignGrid=this.PAM30,this.connections=this.CONBLO,this.step=1;break;case"PAM70":this.alignGrid=this.PAM70,this.connections=this.CONBLO,this.step=1;break;case"PAM250":this.alignGrid=this.PAM250,this.connections=this.CONBLO,this.step=1;break;case"NUCLEOTIDES":this.alignGrid=this.NUCLEOTIDES,this.connections=this.CONNUCL,this.step=1;break;case"TRANS":this.alignGrid=this.TRANS,this.connections=this.CONNUCL,this.step=1;break;case"SCHNEIDER":this.alignGrid=this.SCHNEIDER,this.connections=this.CONSCHN,this.step=3}this.fillScores()}constructResult(e,t){let n="",i="",o="";const r=this.dpGrid[e][t].value;for(let e=0;e<this.step;e++)o+="|";for(;e>0||t>0;){this.dpGrid[e][t].parentI==e?(n=o+n,i=this.seq2.substr((t-1)*this.step,this.step)+i):this.dpGrid[e][t].parentJ==t?(i=o+i,n=this.seq1.substr((e-1)*this.step,this.step)+n):(n=e-1>=0?this.seq1.substr((e-1)*this.step,this.step)+n:o+n,i=t-1>=0?this.seq2.substr((t-1)*this.step,this.step)+i:o+i);const r=e;e=this.dpGrid[e][t].parentI,t=this.dpGrid[r][t].parentJ}return new ut(n,i,r)}fillScores(){this.scores=[];for(let e=0;e<this.len1;e++){this.scores.push([]);for(let t=0;t<this.len2;t++)this.scores[e].push(this.alignGrid[this.connections[this.seq1.substr(e*this.step,this.step)]][this.connections[this.seq2.substr(t*this.step,this.step)]])}}typeRec(){if(/[ATGC]*/.test(this.seq1)&&/[ATGC]*/.test(this.seq2))return"NUCLEOTIDES";if(/[ARNDCQEGHILKMFPSTWYVBZX*]*/.test(this.seq1)&&/[ARNDCQEGHILKMFPSTWYVBZX*]*/.test(this.seq2))return"BLOSUM62";throw Error("Can't recognize sequence type")}needlemanWunsch(){this.dpGrid=[];for(let e=0;e<this.len1+1;e++){const e=[];for(let t=0;t<this.len2+1;t++)e.push(new ht);this.dpGrid.push(e)}this.fillNeedleman();for(let e=1;e<=this.len1;e++)for(let t=1;t<=this.len2;t++)this.fillOne(e,t);return this.constructResult(this.len1,this.len2)}smithWaterman(){this.dpGrid=[];for(let e=0;e<this.len1+1;e++){const e=[];for(let t=0;t<this.len2+1;t++)e.push(new ht);this.dpGrid.push(e)}let e=0,t=0,n=0;for(let i=1;i<=this.len1;i++)for(let o=1;o<=this.len2;o++)this.fillOne(i,o),this.dpGrid[i][o].value<=0?(this.dpGrid[i][o].value=0,this.dpGrid[i][o].parentI=0,this.dpGrid[i][o].parentJ=0):0==this.dpGrid[this.dpGrid[i][o].parentI][this.dpGrid[i][o].parentJ].value&&(this.dpGrid[i][o].parentI=0,this.dpGrid[i][o].parentJ=0),this.dpGrid[i][o].value>e&&(e=this.dpGrid[i][o].value,t=i,n=o);return this.constructResult(t,n)}setSequences(e,t){this.seq1=e,this.seq2=t,this.len1=this.seq1.length/this.step,this.len2=this.seq2.length/this.step,this.fillScores()}setGap(e){this.gap=e}setMethod(e=""){"AUTO"==e&&(e=this.typeRec()),this.gridFromName(e)}constructor(e,t,n,i=""){this.setMethod(i),this.setSequences(e,t),this.setGap(n)}}async function pt(e,t,n="Morgan",i=1,o=.6){const r=e.length,s=Dr.seqHelper.getSeqHandler(e),l=Array(r);let c=1;const h=new Map,u=e.categories,d=e.getRawData();for(let t=0;t<r;t++){if(null==u[d[t]]||e.isNone(t)){l[t]=null;continue}l[t]="";const n=s.getSplitted(t);for(let e=0;e<n.length;e++){const i=n.getCanonical(e);h.has(i)||(h.set(i,String.fromCharCode(c)),c++),l[t]+=h.get(i)}}let p={};if(t===pe.Z.MONOMER_CHEMICAL_DISTANCE||t===pe.Z.NEEDLEMANN_WUNSCH){const e=Array.from(h.keys()),r=await async function(e,t="Morgan"){const n=(await(0,we.pj)()).getMonomerLib(),i=new Array(e.length).fill(0).map(()=>new Array(e.length).fill(0)),o={},r=e.map(e=>n.getMonomer("PEPTIDE",e)?.molfile||n.getMonomer("PEPTIDE",e)?.smiles||""),s=a.Func.find({package:"Chem",name:"getFingerprints"})[0];if(!s)return console.warn('Function "Chem:getFingerprints" is not found in chem package. falling back to Morgan fingerprints'),await Ce(e);const l=a.Column.fromStrings("smiles",r),c=(a.DataFrame.fromColumns([l]),(await s.apply({col:l,fingerprintType:t}))?.entries);if(!c)return console.warn(`${t} Fingerprints could not be calculated for monomers from chem package.\n falling back to Morgan fingerprints`),await Ce(e);for(let t=0;t<c.length;++t)if(i[t][t]=1,o[e[t]]=t,c[t])for(let e=t+1;e<c.length;++e)c[e]&&(i[t][e]=i[e][t]=(0,H.$1)(c[t],c[e]));return{scoringMatrix:i,alphabetIndexes:o}}(e,n),s={};Object.entries(r.alphabetIndexes).forEach(([e,t])=>{s[h.get(e)]=t});const c=l.reduce((e,t)=>Math.max(e,t?.length||0),0);p={scoringMatrix:r.scoringMatrix,alphabetIndexes:s,maxLength:c},t===pe.Z.NEEDLEMANN_WUNSCH&&(p.gapOpen=i,p.gapExtend=o)}return{seqList:l,options:p}}var mt=n(4954);function gt(e){const t=s.divH([],{style:{gap:"10px"}}),n=s.divV([s.divText(e.seqCol.name),s.divText(e.activityCol.name)]);return n.style.fontWeight="bold",n.style.display="flex",n.style.justifyContent="space-between",t.append(n),e.points.forEach(n=>{const i=s.divText(e.activityCol.get(n).toFixed(2));i.style.display="flex",i.style.justifyContent="left",i.style.paddingLeft="30px",t.append(s.divV([s.divText(e.seqCol.get(n)),i]))}),t}function ft(e){const t=s.div();t.append(s.divText(e.seqCol.name,{style:{fontWeight:"bold"}}));const n=new Array(2);e.points.forEach((t,i)=>{n[i]=e.activityCol.get(t)});const i={},o=Dr.seqHelper.getSeqHandler(e.seqCol),r=o.defaultBiotype,a=bt(o.getSplitted(e.points[0]),o.getSplitted(e.points[1]),r,i);return t.append(s.div(a,{style:{width:"300px",overflow:"scroll"}})),t.append(vt(i)),t.append(yt("Activity delta",Math.abs(n[0]-n[1]))),t.append(yt("Cliff",e.sali)),t}function yt(e,t){return s.divH([s.divText(`${e}: `,{style:{fontWeight:"bold",paddingRight:"5px"}}),s.divText(t.toFixed(2))],{style:{paddingTop:"10px"}})}function bt(e,t,n,i){const o=document.createElement("canvas"),r=o.getContext("2d");o.height=30;const s=Dr.monomerLib;return Xe(r,0,0,0,30,R().count(0).take(e.length).map(t=>e.getCanonical(t)).toArray(),R().count(0).take(t.length).map(e=>t.getCanonical(e)).toArray(),n,s,!0,i),o}function vt(e){const t=s.div();if(Object.keys(e).length>0){const n=s.divV([]);n.append(s.divH([s.divText("Pos",{style:{fontWeight:"bold",width:"30px",borderBottom:"1px solid"}}),s.divText("Difference",{style:{fontWeight:"bold",borderBottom:"1px solid"}})]));for(const t of Object.keys(e))e[t].style.borderBottom="1px solid lightgray",n.append(s.divH([s.divText((parseInt(t)+1).toString(),{style:{width:"30px",borderBottom:"1px solid lightgray"}}),e[t]]));t.append(n)}return t}function wt(e,t){const n=a.Column.string("seq_diff",e.rowCount).init(n=>`${e.get(t[0],n)}#${e.get(t[1],n)}`);n.semType="MacromoleculeDifference",n.meta.units=e.col(t[0]).meta.units,n.setTag(me.gp.separator,e.col(t[0]).getTag(me.gp.separator)),e.columns.add(n);const i=e.plot.grid();return i.col(t[0]).visible=!1,i.col(t[1]).visible=!1,i}class Ct extends a.JsViewer{constructor(e,t){super(),this.name="",this.semType="",this.initialized=!1,this.gridSelect=!1,this.maxLimit=100,this.recomputeOnCurrentRowChange=!0,this.skipRecomputingProperies=[],this.debounceTimer=null,this.computeRequested=!1,this.renderPromise=Promise.resolve(),this.limit=this.int("limit",10,{min:1,max:this.maxLimit}),this.targetColumnName=this.string("targetColumnName",null,{...t?{semType:t}:{},nullable:!1}),this.name=e,this.semType=t}init(){this.initialized=!0}detach(){this.subs.forEach(e=>e.unsubscribe())}async onTableAttached(){if(this.init(),this.dataFrame){this.subs.push(a.debounce(this.dataFrame.onRowsRemoved,50).subscribe(e=>this.render(!0)));const e="diversity"!==this.name;this.subs.push(a.debounce(this.dataFrame.onCurrentRowChanged,50).subscribe(t=>{this.gridSelect||this.render(e)})),this.subs.push(a.debounce(this.dataFrame.selection.onChanged,50).subscribe(e=>this.render(!1))),this.subs.push(a.debounce(s.onSizeChanged(this.root),50).subscribe(e=>this.render(!1))),this.targetColumnName??(this.targetColumnName=this.dataFrame.columns.bySemType(this.semType).name),this.targetColumn=this.dataFrame.col(this.targetColumnName),this.getProperty("limit").fromOptions({min:1,max:this.maxLimit})}this.render()}onPropertyChanged(e){if(super.onPropertyChanged(e),this.initialized){if("targetColumnName"===e.name){const t=this.dataFrame.col(e.get(this));t.semType===this.semType&&(this.targetColumn=t)}this.debouncedRender()}}debouncedRender(e=!0){this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>{this.render(e),this.debounceTimer=null},100)}render(e=!0){this.renderPromise=this.renderPromise.then(async()=>{this.computeRequested=this.computeRequested||e,await this.renderInt(e)})}async renderInt(e){}beforeRender(){return!(!this.initialized||!this.targetColumnName||this.dataFrame&&this.targetColumnName&&this.dataFrame.col(this.targetColumnName).semType!==this.semType&&(r.shell.error(`${this.targetColumnName} is not ${this.semType} type`),1))}}class St extends Ct{distanceMetric;fingerprint;gapOpen;gapExtend;metricsProperties=["distanceMetric","fingerprint","gapOpen","gapExtend"];fingerprintChoices=["Morgan","RDKit","Pattern","AtomPair","MACCS","TopologicalTorsion"];distanceFunctionChoices=[pe.Z.NEEDLEMANN_WUNSCH,pe.Z.HAMMING,pe.Z.LEVENSHTEIN,pe.Z.MONOMER_CHEMICAL_DISTANCE];tags=[a.TAGS.UNITS,me.gp.aligned,me.gp.separator,me.gp.alphabet,"cell.renderer"];preComputeDistanceMatrix=!1;requiresSampling=!1;constructor(e,t){super(e,t),this.distanceMetric=this.string("distanceMetric",pe.Z.HAMMING,{choices:this.distanceFunctionChoices}),this.fingerprint=this.string("fingerprint",this.fingerprintChoices[0],{choices:this.fingerprintChoices}),this.gapOpen=this.float("gapOpen",1),this.gapExtend=this.float("gapExtend",.6)}async onTableAttached(){if(super.onTableAttached(),this.dataFrame){const e=this.dataFrame.rowCount;this.preComputeDistanceMatrix=e<=1e4,this.requiresSampling=e>1e4}}needsGapPenalties(){return this.distanceMetric===pe.Z.NEEDLEMANN_WUNSCH}needsFingerprint(){return this.distanceMetric===pe.Z.MONOMER_CHEMICAL_DISTANCE||this.distanceMetric===pe.Z.NEEDLEMANN_WUNSCH}}const At={gapPenalty:1,matchScore:1,gapSymbol:ve.b9[ve.Hi.FASTA],localAlignment:!1};class xt extends St{seqHelper;cutoff;hotSearch;similarColumnLabel;sketchedMolecule="";curIdx=0;molCol=null;idxs=null;scores=null;gridSelect=!1;targetMoleculeIdx=0;computeCompleted=new h.Subject;distanceMatrixComputed=!1;mmDistanceMatrix;knn;kPrevNeighbors=0;demo;analysisGrid;subInited=!1;lastDistanceMetric="";lastFingerprint="";lastGapOpen=0;lastGapExtend=0;constructor(e,t){super("similarity",a.SEMTYPE.MACROMOLECULE),this.seqHelper=e,this.cutoff=this.float("cutoff",.01,{min:0,max:1}),this.hotSearch=this.bool("hotSearch",!0),this.similarColumnLabel=this.string("similarColumnLabel",null),this.demo=t}init(){this.hotSearch=!0,this.initialized=!0}async renderInt(e){if(this.beforeRender()&&this.targetColumn){this.curIdx=-1==this.dataFrame.currentRowIdx?0:this.dataFrame.currentRowIdx;const t=this.lastDistanceMetric!==this.distanceMetric||this.lastFingerprint!==this.fingerprint||this.lastGapOpen!==this.gapOpen||this.lastGapExtend!==this.gapExtend;if(e&&!this.gridSelect||t){this.targetMoleculeIdx=(this.dataFrame.currentRowIdx??-1)<0?0:this.dataFrame.currentRowIdx,await this.computeByMM();const e=null!=this.similarColumnLabel?this.similarColumnLabel:`similar (${this.targetColumn})`;this.molCol=a.Column.string(e,this.idxs.length).init(e=>this.targetColumn?.get(this.idxs?.get(e))),this.molCol.semType=a.SEMTYPE.MACROMOLECULE,this.tags.forEach(e=>this.molCol.setTag(e,this.targetColumn.getTag(e)));const t=a.DataFrame.fromColumns([this.idxs,this.molCol,this.scores]);await t.meta.detectSemanticTypes(),await r.data.detectSemanticTypes(t),this.molCol.temp["reference-sequence"]=this.targetColumn.get(this.targetMoleculeIdx),this.molCol.temp[".mm.cellRenderer.maxMonomerLength"]=4;let n=null;t.onCurrentRowChanged.subscribe(e=>{n&&clearTimeout(n),(t.currentRowIdx??-1)<0||(this.dataFrame.currentRowIdx=t.col("indexes").get(t.currentRowIdx),n=setTimeout(()=>{this.createPropertyPanel(t)},300),this.gridSelect=!0)}),this.analysisGrid?(this.analysisGrid.dataFrame=t,this.analysisGrid.invalidate()):(this.analysisGrid=t.plot.grid(),(0,Oe.Ku)(this.root,this.analysisGrid.root)),this.analysisGrid.col("indexes").visible=!1,(0,Oe.Kd)(this.analysisGrid,this.molCol.name,450,30,!0);const i=this.idxs?.getRawData().findIndex(e=>e==this.targetMoleculeIdx);this.analysisGrid.cell("score",i).cell.value=null;const o=r.shell.tv;this.subInited||(o.grid.root.addEventListener("click",e=>{this.gridSelect=!1}),this.subInited=!0),this.computeCompleted.next(!0)}}}async computeByMM(){const e=this.targetColumn.length,t=Math.min(this.limit,e-1);if(!this.knn||this.kPrevNeighbors!==t||this.lastDistanceMetric!==this.distanceMetric||this.lastFingerprint!==this.fingerprint||this.lastGapOpen!==this.gapOpen||this.lastGapExtend!==this.gapExtend){const e=this.distanceMetric,n=await pt(this.targetColumn,e,this.fingerprint,this.gapOpen,this.gapExtend),i=n.seqList,o=n.options;this.lastDistanceMetric=this.distanceMetric,this.lastFingerprint=this.fingerprint,this.lastGapOpen=this.gapOpen,this.lastGapExtend=this.gapExtend,this.kPrevNeighbors=t,this.knn=await(new D).getKNN(i,e,t,o)}const n=new Array(t).fill(0).map((e,t)=>({idx:this.knn.knnIndexes[this.targetMoleculeIdx][t],score:1-this.knn.knnDistances[this.targetMoleculeIdx][t]}));n.sort((e,t)=>t.score-e.score),n.unshift({idx:this.targetMoleculeIdx,score:a.FLOAT_NULL}),this.idxs=a.Column.int("indexes",t+1).init(e=>n[e].idx),this.scores=a.Column.float("score",t+1).init(e=>n[e].score)}createPropertyPanel(e){const t=s.div(),n={},i=this.molCol?.name,o=e.col(i),a=this.seqHelper.getSeqHandler(this.targetColumn),l=this.seqHelper.getSeqHandler(o),c=a.getSplitted(this.targetMoleculeIdx),h=l.getSplitted(e.currentRowIdx),u=function(e,t,n={}){const i={...At,...n};function o(e,t){return e===t?i.matchScore:-i.matchScore}const r=e.length,s=t.length,a=Array(r+1).fill(0).map(()=>Array(s+1).fill(0));let l=-9999,c=[1,1];for(let n=1;n<r+1;n++)for(let r=1;r<s+1;r++)a[n][r]=Math.max(0,a[n-1][r-1]+o(e.getCanonical(n-1),t.getCanonical(r-1)),a[n-1][r]-i.gapPenalty,a[n][r-1]-i.gapPenalty),a[n][r]>=l&&(l=a[n][r],c=[n,r]);let h=i.localAlignment?c[0]:r,u=i.localAlignment?c[1]:s,d=new Array(0),p=new Array(0);for(;h>0&&u>0;){const n=Math.max(a[h-1][u-1],a[h-1][u],a[h][u-1]);a[h][u]==a[h-1][u-1]+i.matchScore&&n==a[h-1][u-1]?(d.push(e.getCanonical(h-1)),p.push(t.getCanonical(u-1)),h-=1,u-=1):a[h][u]==a[h-1][u]-i.gapPenalty?(p.push(i.gapSymbol),d.push(e.getCanonical(h-1)),h-=1):a[h][u]==a[h][u-1]-i.gapPenalty?(d.push(i.gapSymbol),p.push(t.getCanonical(u-1)),u-=1):(d.push(e.getCanonical(h-1)),p.push(t.getCanonical(u-1)),h-=1,u-=1)}d=[...R().count(0).take(h).map(t=>e.getCanonical(t)),...d.reverse(),...i.localAlignment?R().count(c[0]).take(r).map(t=>e.getCanonical(t)):[]],p=[...R().count(0).take(u).map(e=>t.getCanonical(e)),...p.reverse(),...i.localAlignment?R().count(c[1]).take(s).map(e=>t.getCanonical(e)):[]];const m=h,g=u;return m>g?p=[...new Array(m-g).fill(i.gapSymbol.valueOf()),...p]:d=[...new Array(g-m).fill(i.gapSymbol.valueOf()),...d],p.length>d.length?d.push(...new Array(p.length-d.length).fill(i.gapSymbol.valueOf())):p.push(...new Array(d.length-p.length).fill(i.gapSymbol.valueOf())),{seq1:d.join(""),seq2:p.join(""),seq1Splitted:new Fe.Mu(d,i.gapSymbol),seq2Splitted:new Fe.Mu(p,i.gapSymbol)}}(c,h),d=bt(u.seq1Splitted,u.seq2Splitted,l.defaultBiotype,n);t.append(s.div(d,{style:{width:"300px",overflow:"scroll"}})),c.length!==h.length&&t.append(s.divV([s.divText("Different sequence length:",{style:{fontWeight:"bold"}}),s.divText(`target: ${c.length} monomers`),s.divText(`selected: ${h.length} monomers`)],{style:{paddingBottom:"10px"}})),t.append(vt(n));const p=s.accordion(),m=s.element("i");m.className="grok-icon svg-icon svg-view-layout",p.addTitle(s.span([m,s.label("Similarity search")])),p.addPane("Differences",()=>t,!0),r.shell.o=p.root}}class Et extends St{seqHelper;diverseColumnLabel;renderMolIds=null;columnNames=[];computeCompleted=new h.Subject;sampledIndices=null;constructor(e){super("diversity",a.SEMTYPE.MACROMOLECULE),this.seqHelper=e,this.diverseColumnLabel=this.string("diverseColumnLabel",null)}async renderInt(e){if(this.beforeRender()&&this.dataFrame&&e&&this.targetColumn){await this.computeByMM();const e=null!=this.diverseColumnLabel?this.diverseColumnLabel:`diverse (${this.targetColumnName})`,t=a.Column.string(e,this.renderMolIds.length).init(e=>this.targetColumn?.get(this.renderMolIds[e]));t.semType=a.SEMTYPE.MACROMOLECULE,this.tags.forEach(e=>t.setTag(e,this.targetColumn.getTag(e)));const n=a.DataFrame.fromColumns([t]);t.temp[".mm.cellRenderer.maxMonomerLength"]=4,n.onCurrentRowChanged.subscribe(e=>{this.dataFrame.currentRowIdx=this.renderMolIds[n.currentRowIdx]});const i=n.plot.grid();(0,Oe.Kd)(i,t.name,450,30),(0,Oe.Ku)(this.root,i.root),this.computeCompleted.next(!0)}}async computeByMM(){const e=this.targetColumn.length;let t;this.requiresSampling&&e>1e4?(t=this.createRandomSample(e,1e4),this.sampledIndices=t):(t=Array.from({length:e},(e,t)=>t),this.sampledIndices=null);const n=this.distanceMetric,i=await pt(this.targetColumn,n,this.fingerprint,this.gapOpen,this.gapExtend),o=i.seqList,r=i.options,s=t.map(e=>o[e]),a=new B(!0,!1),l=await a.calc(s,n,!0,r);a.terminate();const c=t.length,h=(d=c,(e,t)=>d*e+t-Math.floor((e+2)*(e+1)/2)),u=function(e,t){function n(e,t){let n=null,i=null;for(const o of e){const e=t(o);(null==i||e>i)&&(n=o,i=e)}return n}const i=[(r=e-1,Math.floor(function(e){return Math.random()*e}(r)))],o=new Set;var r;for(let t=0;t<e;++t)i.includes(t)||o.add(t);for(;i.length<t;){const e=n(o.values(),e=>Math.min.apply(Math,i.map(function(t,n){return l[h(e,t)]})));null!=e&&(i.push(e),o.delete(e))}return i}(c,Math.min(c,this.limit));var d;this.renderMolIds=u.map(e=>t[e])}createRandomSample(e,t){const n=[];for(let t=0;t<e;t++)this.targetColumn.isNone(t)||n.push(t);if(n.length<=t)return n;for(let e=n.length-1;e>0;e--){const t=Math.floor(Math.random()*(e+1)),i=n[e];n[e]=n[t],n[t]=i}return n.slice(0,t)}}var Mt,Tt=n(5433),_t=n(3890),It=n(1687);!function(e){e.TYPE="V2000",e[e.NUM_OF_HEADER_LINES=3]="NUM_OF_HEADER_LINES",e[e.NUM_OF_COUNTS_DIGITS=3]="NUM_OF_COUNTS_DIGITS",e[e.ATOM_TYPE_COL=4]="ATOM_TYPE_COL",e[e.FIRST_BONDED_ATOM_COL=1]="FIRST_BONDED_ATOM_COL",e[e.BOND_TYPE_COL=3]="BOND_TYPE_COL",e[e.RGP_SHIFT=8]="RGP_SHIFT",e[e.MAX_ATOM_COUNT=999]="MAX_ATOM_COUNT",e.RGP_LINE_START="M RGP",e.ATOM_ALIAS_LINE_START="A ",e.END="M END"}(Mt||(Mt={}));class Lt{constructor(e){this.init(e)}init(e){this.fileContent=e.replace(/\r/g,""),this._atomCount=void 0,this._atomTypes=void 0,this._bondCount=void 0,this._bondTypes=void 0,this.xyzAtomCoordinates=void 0,this._pairsOfBondedAtoms=void 0}get atomCount(){return void 0===this._atomCount&&this.setAtomAndBondCounts(),this._atomCount}get bondCount(){return void 0===this._bondCount&&this.setAtomAndBondCounts(),this._bondCount}get x(){var e;return null!==(e=this.xyzAtomCoordinates)&&void 0!==e||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.x}get y(){var e;return null!==(e=this.xyzAtomCoordinates)&&void 0!==e||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.y}get z(){var e;return null!==(e=this.xyzAtomCoordinates)&&void 0!==e||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.z}get atomTypes(){var e;return null!==(e=this._atomTypes)&&void 0!==e||(this._atomTypes=this.parseAtomTypes()),this._atomTypes}get pairsOfBondedAtoms(){var e;return null!==(e=this._pairsOfBondedAtoms)&&void 0!==e||(this._pairsOfBondedAtoms=this.parseBondedAtomPairs()),this._pairsOfBondedAtoms}get bondTypes(){var e;return null!==(e=this._bondTypes)&&void 0!==e||(this._bondTypes=this.parseBondTypes()),this._bondTypes}setAtomAndBondCounts(){const{atomCount:e,bondCount:t}=this.parseAtomAndBondCounts();this._atomCount=e,this._bondCount=t}getNextColumnIdx(e){for(;!this.isWhitespace(e);)++e;for(;this.isWhitespace(e);)++e;return e}shiftIdxToSpecifiedColumn(e,t){let n=e;const i=this.isWhitespace(n)?t:t-1;for(let e=0;e<i;e++)n=this.getNextColumnIdx(n);return n}parseAtomTypes(){const e=this.atomCount,t=new Array(e);let n=this.getAtomBlockIdx();for(let i=0;i<e;i++)n=this.shiftIdxToAtomType(n),t[i]=this.parseAtomType(n),n=this.getNextLineIdx(n);return t}parseAtomCoordinates(){const e=new Float32Array(this.atomCount),t=new Float32Array(this.atomCount),n=new Float32Array(this.atomCount);let i=this.getAtomBlockIdx();for(let o=0;o<this.atomCount;o++){i=this.shiftIdxToXColumn(i);for(const r of[e,t,n])r[o]=this.parseFloatValue(i),i=this.getNextColumnIdx(i);i=this.getNextLineIdx(i)}return{x:e,y:t,z:n}}parseBondedAtomPairs(){const e=new Array(this.bondCount);let t=this.getBondBlockIdx();for(let n=0;n<this.bondCount;n++){t=this.shiftIdxToBondedAtomsPair(t);const i=new Uint16Array(2);i[0]=this.parseIntValue(t),t=this.getNextColumnIdx(t),i[1]=this.parseIntValue(t),e[n]=i,t=this.getNextLineIdx(t)}return e}parseBondTypes(){const e=this.bondCount,t=new Uint16Array(e);let n=this.getBondBlockIdx();for(let i=0;i<e;i++)n=this.shiftIdxToBondType(n),t[i]=this.parseIntValue(n),n=this.getNextLineIdx(n);return t}isWhitespace(e){const t=this.fileContent[e];return" "===t||"\t"===t}getNextLineIdx(e){return"\n"!==this.fileContent[e]?this.fileContent.indexOf("\n",e)+1:e+1}parseFloatValue(e){return this.parseNumericValue(parseFloat,e)}parseIntValue(e){return this.parseNumericValue(parseInt,e)}parseNumericValue(e,t){let n=t+1;for(;!this.isWhitespace(n);)++n;return e(this.fileContent.substring(t,n))}}class Nt extends Lt{constructor(e){super(e),this.init(e)}init(e){super.init(e)}parseAtomType(e){let t=e,n=t;return this.isQuote(t)?(n=this.getNextIdenticalChar(t),t++):n=this.fileContent.indexOf(" ",n),this.fileContent.substring(t,n)}isQuote(e){const t=this.fileContent[e].charCodeAt(0);return 39===t||34===t}getNextIdenticalChar(e){const t=this.fileContent[e];return t?this.fileContent.indexOf(t,e+1):-1}isQuery(){return this.isQueryOrFragment((e,t)=>{return 39===e||34===e||76===e&&!((n=this.fileContent.charCodeAt(t+1))>64&&n<91||n>96&&n<123);var n})}isFragment(){return this.isQueryOrFragment(e=>82===e||42===e)}isQueryOrFragment(e){const t=this.atomCount;let n=this.getAtomBlockIdx();for(let i=0;i<t;i++){if(n=this.shiftIdxToAtomType(n),e(this.fileContent.charCodeAt(n),n))return!0;n=this.getNextLineIdx(n)}return!1}}class Pt extends Nt{constructor(e){super(e)}getAtomLines(){const e=this.getAtomBlockIdx(),t=this.getBondBlockIdx();return this.fileContent.substring(e,t).split("\n").slice(0,this.atomCount)}getBondLines(){const e=this.getBondBlockIdx();return this.fileContent.substring(e).split("\n").slice(0,this.bondCount)}getRGroupIdToAtomicIdxMap(){const e=new Map,t=this.fileContent.split("\n");t.filter(e=>e.startsWith(Mt.RGP_LINE_START)).forEach(t=>{const n=this.getAtomIdxToRgpIdxList(t);for(const[t,i]of n){if(e.has(t))throw new Error(`R group ${t} is already in the map`);e.set(t,i)}});const n=t.map((e,t)=>{if(e.startsWith(Mt.ATOM_ALIAS_LINE_START))return t}).filter(e=>void 0!==e),i=n.map(e=>t[e]),o=n.map(e=>t[e+1]);i.forEach((t,n)=>{const i=parseInt(t.split(/\s+/)[1])-1,r=parseInt(o[n].substring(1));if(e.has(r))throw new Error(`R group ${r} is already in the map`);e.set(r,i)});const r=this.getRGroupAtomicIndices().filter(t=>!Array.from(e.values()).includes(t));if(0!==r.length)throw new Error(`Unaccounted R group indices: ${r}`);return e}getAtomIdxToRgpIdxList(e){const t=e.split(/\s+/).filter(e=>e).slice(3).map(e=>parseInt(e)),n=new Array(t.length/2);for(let e=0;e<t.length;e+=2)n[e/2]=[t[e+1],t[e]-1];return n}getRGroupAtomicIndices(){return this.atomTypes.map((e,t)=>{if(e.includes("R#"))return t}).filter(e=>void 0!==e)}static isValidMolfile(e){return-1!==e.indexOf(Mt.TYPE)&&-1!==e.indexOf(Mt.END)}shiftIdxToAtomType(e){return this.shiftIdxToSpecifiedColumn(e,Mt.ATOM_TYPE_COL)}getCountsLineIdx(){let e=0;for(let t=0;t<Mt.NUM_OF_HEADER_LINES;++t)e=this.getNextLineIdx(e);return e}getAtomBlockIdx(){let e=this.getCountsLineIdx();return e=this.getNextLineIdx(e),e}shiftIdxToXColumn(e){return this.getNextColumnIdx(e)}shiftIdxToBondedAtomsPair(e){return this.shiftIdxToSpecifiedColumn(e,Mt.FIRST_BONDED_ATOM_COL)}shiftIdxToBondType(e){return this.shiftIdxToSpecifiedColumn(e,Mt.BOND_TYPE_COL)}getBondBlockIdx(){let e=this.getAtomBlockIdx();for(let t=0;t<this.atomCount;t++)e=this.getNextLineIdx(e);return e}parseAtomAndBondCounts(){let e=this.getCountsLineIdx(),t=e+Mt.NUM_OF_COUNTS_DIGITS;const n=parseInt(this.fileContent.substring(e,t));return e=t,t+=Mt.NUM_OF_COUNTS_DIGITS,{atomCount:n,bondCount:parseInt(this.fileContent.substring(e,t))}}}class Rt extends Nt{constructor(e){super(e),this.init(e)}getAtomLines(){const e=this.getAtomBlockIdx(),t=this.getBondBlockIdx();return this.fileContent.substring(e,t).split("\n").slice(0,this.atomCount)}getBondLines(){const e=this.getBondBlockIdx();return this.fileContent.substring(e).split("\n").slice(0,this.bondCount)}getRGroupIdToAtomicIdxMap(){const e=new Map;return this.getAtomLines().forEach((t,n)=>{const i=t.match(/RGROUPS=\(([\d\s]+)\)/);if(i){const t=i[1].split(/\s+/).map(e=>parseInt(e));if(t.length>2)throw new Error(`R group data ${t} has more than 2 elements`);const o=t[1];if(e.has(o))throw new Error(`R group ${o} is already in the map`);e.set(o,n)}}),e}shiftIdxToAtomType(e){return this.shiftIdxToSpecifiedColumn(e,4)}getCountsLineIdx(){return this.fileContent.indexOf("M V30 COUNTS ")}getAtomBlockIdx(){let e=this.fileContent.indexOf("M V30 BEGIN ATOM");return e=this.getNextLineIdx(e),e}shiftIdxToXColumn(e){let t=this.shiftIdxToAtomType(e);return this.isQuote(t)?(t=this.getNextIdenticalChar(t),t=this.getNextColumnIdx(t),t):this.shiftIdxToSpecifiedColumn(e,5)}shiftIdxToBondedAtomsPair(e){return this.shiftIdxToSpecifiedColumn(e,5)}shiftIdxToBondType(e){return this.shiftIdxToSpecifiedColumn(e,4)}getBondBlockIdx(){return this.getNextLineIdx(this.fileContent.indexOf("M V30 BEGIN BOND"))}static isValidMolfile(e){return-1!==e.indexOf("V3000")&&-1!==e.indexOf("M END")}parseAtomAndBondCounts(){let e=this.fileContent.indexOf("M V30 COUNTS ")+14,t=this.fileContent.indexOf(" ",e+1);const n=parseInt(this.fileContent.substring(e,t));return e=t+1,t=this.fileContent.indexOf(" ",e+1),{atomCount:n,bondCount:parseInt(this.fileContent.substring(e,t))}}}class $t{constructor(){}static getInstance(e){if($t.isMolfileV2K(e))return new Pt(e);if($t.isMolfileV3K(e))return new Rt(e);throw new Error("Malformed molfile")}static isMolfileV2K(e){return Pt.isValidMolfile(e)}static isMolfileV3K(e){return Rt.isValidMolfile(e)}}var Ot=n(6197),kt=n(9124),Ht=n(3527);class Ft{biotype;id;n;m;type;mt;smiles;get issmiles(){return!!this.smiles}at={R1:"H",R2:"H",R3:"H",R4:"H",R5:"H",R6:"H",R7:"H",R8:"H",R9:"H"};get rs(){return Object.keys(this.at).length}constructor(e,t,n="missing",i=void 0,o=void 0,r=void 0,s){if(this.biotype=e,this.id=t,this.n=n,this.m=i,this.type=o,this.mt=r,this.smiles=s,!this.id)throw new Error("Invalid arg undefined [id].")}static objCounter=-1;objId=++Ft.objCounter;className="WebEditorMonomerDummy";toLog(){return`Helm: ${this.className}<${this.objId}>`}}class Gt extends Ft{backgroundcolor="#808080";linecolor="#000000";textcolor="#000000";constructor(e,t,n,i,o){super(e,t,i,void 0,void 0,void 0,n),this.at={},o.forEach(e=>{this.at[e]="H"})}}class Bt extends Ft{backgroundcolor="#FFFFFF";linecolor="#808080";textcolor="#808080";constructor(e){super(e,"*","gap")}}class Dt extends Ft{backgroundcolor="#808080";linecolor="#000000";textcolor="#000000";constructor(e,t){super(e,t,"ambiguous")}}class Vt extends Ft{backgroundcolor="#FF4444";linecolor="#800000";textcolor="#FFFFFF";constructor(e,t,n){super(e,t,"missing"),n&&(this.backgroundcolor="#C0C0C0",this.linecolor="#404040",this.textcolor="#404040")}}class Wt extends Ft{backgroundcolor="#FFFF44";linecolor="#800000";textcolor="#000000";constructor(e,t){super(e,t,"broken")}}class jt{id;m;n;na;type;mt;at;smiles;get rs(){return Object.keys(this.at).length}get issmiles(){return!!this.smiles}linecolor;backgroundcolor;textcolor;constructor(e,t,n,i,o,r,s,a){this.id=e,this.m=t,this.n=n,this.na=i,this.type=o,this.mt=r,this.at=s,this.smiles=a}static fromMonomer(e,t,n){let i={};const o=t.symbol,r=t.smiles;if(t.rgroups.length>0)t.rgroups.forEach(e=>{i[e.label]=e.capGroupName});else{if(!r){if(t.lib)return new Wt(e,o);throw new Error("Unexpected missing monomer without .lib")}i=n.getRS(r)}const s=new jt(t.symbol,t.molfile,t.name,t.naturalAnalog,t.polymerType,t.monomerType,i),a=n.getMonomerColors(e,t.symbol);return a&&(s.textcolor=a?.textcolor,s.linecolor=a?.linecolor,s.backgroundcolor=a?.backgroundcolor),s}}const Ut={[De.o.BASE]:{A:"#20E040",G:"#040404",T:"#FF8080",C:"#2060FF",U:"#FF8080"},[De.o.NUCLEOTIDE]:{A:"#20E040",G:"#040404",T:"#FF8080",C:"#2060FF",U:"#FF8080"},[De.o.LINKER]:{P:"#9aa5e1",p:"#9aa5e1"},[De.o.SUGAR]:{R:"#7a85c1",r:"#7a85c1"},[De.o.AA]:{A:"rgb(44,160,44)",R:"rgb(23,190,207)",N:"rgb(235,137,70)",D:"rgb(31,119,180)",C:"rgb(188,189,34)",E:"rgb(31, 120, 150)",Q:"rgb(205, 111, 71)",G:"rgb(214,39,40)",H:"rgb(158,218,229)",I:"rgb(23,103,57)",L:"rgb(30,110,96)",K:"rgb(108, 218, 229)",M:"rgb(60,131,95)",F:"rgb(24,110,79)",P:"rgb(255,152,150)",S:"rgb(255,187,120)",T:"rgb(245,167,100)",W:"rgb(182, 223, 138)",Y:"rgb(152,223,138)",V:"rgb(74,160,74)"},[De.o.CHEM]:{R:"#eeeeee"},[De.o.BLOB]:{B:"#999999",G:"#e2e2e2"}};class qt{constructor(e,t=[],n={}){this.onItemChanged=new h.Subject,this.onAddingItemChanged=new h.Subject,this.onItemAdded=new h.Subject,this.onItemRemoved=new h.Subject,this.options={removeButtonTooltip:"Remove item",addButtonTooltip:"Add item",allowAdd:!0,allowRemove:!0},this.addingItemInputs={},this.properties=e,this.options=Object.assign(Object.assign({},this.options),n),this._root=s.divV([],{style:{display:"grid",gridTemplateColumns:`repeat(${this.properties.length}, 1fr)`,alignItems:"center",gap:"12px"},classes:"ui-items-grid"}),this._items=t,this.render()}get root(){return this._root}get items(){return this._items}set items(e){this._items=e,this.render()}addItem(e,t=!0){this._items.push(e),this.render(),t&&this.onItemAdded.next(e)}removeItem(e,t=!0){-1!==this._items.indexOf(e)&&(this._items.splice(this._items.indexOf(e),1),this.render(),t&&this.onItemRemoved.next(e))}removeAtIndex(e,t=!0){if(e<0||e>=this._items.length)return;const n=this._items.splice(e,1);this.render(),t&&this.onItemRemoved.next(n[0])}removeAllItems(){this._items=[],this.render()}render(){var e,t,n,i,o;if(s.empty(this._root),!this.options.horizontalInputNames)for(const n of this.properties){let i=null!==(e=n.caption)&&void 0!==e?e:n.name;(null===(t=this.options.customLabels)||void 0===t?void 0:t[n.name])&&(i=this.options.customLabels[n.name]);const o=s.divText(i);o.style.fontWeight="bold",this._root.appendChild(o)}for(const e of this._items){const t=this.getItemDiv(e);for(const e of t)this._root.appendChild(e)}if(this.options.allowAdd){const e=this.getItemDiv(null!==(o=null===(i=(n=this.options).newItemFunction)||void 0===i?void 0:i.call(n))&&void 0!==o?o:void 0,!0);for(const t of e)this._root.appendChild(t)}}get addingItem(){const e={};return Object.keys(this.addingItemInputs).forEach(t=>{e[t]=this.addingItemInputs[t].value}),e}getItemDiv(e={},t){var n,i;const o=[],r={};let l=null;for(const c of this.properties){void 0===e[c.name]&&(e[c.name]=null);const h=(null===(n=this.options.customInputs)||void 0===n?void 0:n[c.name])?this.options.customInputs[c.name](e):s.input.forProperty(c,e),u=null===(i=this.options.validators)||void 0===i?void 0:i[c.name];u&&h.addValidator(u),o.push(this.options.horizontalInputNames?h.root:this.hideLabel(h.root)),c.propertyType!==a.TYPE.BOOL&&"color"!==c.name.toLowerCase()&&h.input&&(h.input.style.width="100%"),r[c.name]=h,h.onChanged.subscribe(()=>{e[c.name]=h.value,t?this.onAddingItemChanged.next({item:e,fieldName:c.name}):this.onItemChanged.next({item:e,fieldName:c.name})}),h.root.style.alignItems="center",l=h}let c=null;if(t)this.addingItemInputs=r,c=s.icons.add(()=>{const e=this.options.newItemFunction?this.options.newItemFunction():{};Object.keys(r).forEach(t=>{e[t]=r[t].value}),this._items.push(e),this.onItemAdded.next(e),this.render()},this.options.addButtonTooltip);else{if(!this.options.allowRemove)return o;c=s.icons.delete(()=>{this._items.splice(this._items.indexOf(e),1),this.onItemRemoved.next(e),this.render()},this.options.removeButtonTooltip)}return l&&l.addOptions?l.addOptions(c):null==l||l.root.appendChild(c),c.style.color="#2083d5",o}hideLabel(e){return e.getElementsByTagName("label")[0]&&e.removeChild(e.getElementsByTagName("label")[0]),e}hasErrors(){return this._root.querySelectorAll(".d4-invalid").length>0}}const zt={A:new j.A(new Uint32Array([2,0,0,0,16,0,0,0,134217728,0,0,0,32,0,33554432,0,0,0,0,0,1024,0,0,0,262144,128,0,0,0,0,0,0,0,2,0,0,524288,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1048576,0,536870912,0,0,0,0]),2048),C:new j.A(new Uint32Array([2,0,65536,0,0,0,0,32,0,0,2,0,32,0,0,0,0,0,0,0,1024,0,0,0,262144,128,0,0,0,0,0,0,0,65536,0,0,524288,0,0,0,0,0,0,0,524288,524288,0,0,0,0,0,0,0,0,0,0,0,34603008,0,536870912,64,0,0,0]),2048),D:new j.A(new Uint32Array([2,0,65600,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,1024,0,0,0,262400,128,0,0,0,0,0,0,0,0,0,2097152,524288,0,0,0,1024,0,0,0,524288,0,0,0,0,0,0,0,0,0,512,0,0,34603008,0,536870912,0,0,0,0]),2048),E:new j.A(new Uint32Array([2,0,65536,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,1024,0,0,8,262144,128,0,0,16,134217728,0,0,0,0,0,0,524288,0,0,0,128,0,0,0,524288,0,0,0,268435456,0,0,0,0,0,512,2147483648,0,34603008,0,536870912,0,0,0,0]),2048),F:new j.A(new Uint32Array([2,0,98304,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,1024,0,0,0,262144,128,33554432,0,0,0,0,33554432,0,1024,1,0,524288,32768,32,0,0,0,0,16,524288,0,0,0,0,0,0,0,0,0,71303168,0,0,34603008,131072,536870912,0,0,0,0]),2048),G:new j.A(new Uint32Array([134217728,0,65536,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,1024,0,0,0,0,128,0,0,0,0,2097216,0,0,0,0,0,524288,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,512,0,0,0,0,536870912,0,0,0,0]),2048),H:new j.A(new Uint32Array([2,0,1073840128,0,0,0,0,0,0,0,0,67108864,32,0,0,0,0,0,0,0,1024,0,512,0,262144,192,0,268435456,0,0,8200,0,0,0,67108864,0,524296,0,32,0,0,0,0,16,524288,0,0,2147483648,0,0,8,0,0,0,0,0,0,34603008,131072,536870920,4194304,0,0,0]),2048),I:new j.A(new Uint32Array([2,0,65536,0,0,0,0,0,150994944,64,0,0,32,0,0,0,0,0,0,0,1024,0,8388608,0,327680,128,0,0,0,0,0,0,0,2,0,524288,524288,0,0,0,0,0,0,0,0,0,0,0,256,0,0,0,0,8388608,0,33554432,0,1048576,0,536870912,0,0,0,0]),2048),K:new j.A(new Uint32Array([2,0,65536,0,0,0,0,0,0,0,0,0,268435488,0,0,0,0,0,0,0,1024,0,0,8,262144,128,0,0,0,0,2097152,0,0,67108864,0,0,524288,0,0,0,8,0,0,0,524288,0,0,8192,0,0,0,0,0,0,0,2147483648,0,34668544,0,545259520,0,0,0,0]),2048),L:new j.A(new Uint32Array([2,0,65536,0,0,0,0,0,134217728,0,0,0,32,512,0,0,0,0,0,0,1024,256,0,8388608,262400,128,0,0,0,0,0,0,0,2,0,0,524288,0,0,0,0,0,0,0,524288,0,0,0,0,0,0,0,0,0,0,0,0,42991616,0,536870912,0,0,0,0]),2048),M:new j.A(new Uint32Array([2050,0,65536,1048576,0,0,0,0,0,0,0,0,1056,0,0,0,0,0,0,0,1024,0,0,8,262144,128,0,0,0,0,0,536870912,0,2,0,0,1074266112,0,0,0,0,0,0,0,524288,0,0,0,4194304,0,0,0,0,0,0,2147483648,0,34603008,0,536870912,4194304,0,0,0]),2048),N:new j.A(new Uint32Array([2,0,65536,0,4096,0,0,0,0,0,0,16777216,32,0,0,0,0,0,0,0,1024,0,0,0,262400,128,0,0,0,0,0,0,0,0,0,0,524288,0,0,0,1024,0,0,0,524288,0,0,0,0,0,0,0,0,0,0,0,0,34603008,0,536871936,67108864,0,0,0]),2048),P:new j.A(new Uint32Array([0,0,1024,0,0,0,0,0,0,131072,0,1024,32,0,0,0,0,512,0,0,1024,0,0,64,0,128,0,0,1073741824,0,0,138412032,16,0,67108864,0,0,0,0,0,0,8192,0,0,8388608,0,0,8,0,0,0,0,0,0,256,0,0,0,0,553648128,0,0,0,0]),2048),Q:new j.A(new Uint32Array([2,0,65536,0,4096,0,0,0,0,0,0,0,32,0,0,0,0,2,0,0,1024,0,0,8,262144,128,0,0,16,0,0,0,0,0,0,0,524288,0,0,0,0,0,0,0,524288,0,0,0,268435456,0,0,0,0,0,16777216,2147483648,0,34603008,0,536871936,0,0,0,0]),2048),R:new j.A(new Uint32Array([2,0,65536,0,4096,0,32,0,0,0,0,0,268435488,0,0,0,0,0,0,32768,134218752,0,16,8,262144,128,0,1073741824,0,0,8388608,0,0,0,65536,0,524289,0,0,0,0,0,0,0,524288,2048,0,0,0,0,0,0,0,0,0,2147483648,0,34603008,1048576,545259520,0,0,0,0]),2048),S:new j.A(new Uint32Array([2,0,65536,0,0,0,1073741824,0,0,0,0,0,32,0,0,4,0,0,0,0,1024,0,0,0,262144,128,0,0,0,0,0,0,0,0,0,0,524288,0,0,1048576,0,0,0,0,524288,0,0,0,0,0,0,0,0,0,8388608,0,0,34603008,0,536870912,0,0,0,0]),2048),T:new j.A(new Uint32Array([2,0,0,0,0,0,0,8,134217728,0,0,67108864,32,0,0,0,0,0,0,0,1024,0,8388608,0,262144,128,0,0,0,0,0,0,0,2,0,524288,524288,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,536870912,0,0,0,0,1048576,67108864,536870912,0,0,0,0]),2048),V:new j.A(new Uint32Array([2,0,0,0,0,0,0,0,134217728,0,0,0,32,0,0,0,0,0,0,0,1024,0,8388608,0,262144,128,0,0,0,0,0,1073741824,128,2,0,524288,524288,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8192,0,1048576,0,536870912,0,0,0,0]),2048),W:new j.A(new Uint32Array([2,0,98304,8388608,0,0,0,0,0,0,256,4096,32,0,0,0,0,0,0,0,1024,0,0,0,262144,192,0,0,0,0,0,0,0,0,67108865,0,524288,32768,32,0,0,0,8224,16,524288,0,0,0,0,32,128,0,2097152,0,4194304,8388608,0,34603008,8519680,536870912,131072,262144,0,0]),2048),Y:new j.A(new Uint32Array([2,0,98304,0,0,0,0,0,0,4194304,0,0,32,0,0,0,0,0,0,0,1024,0,0,512,262144,128,33554432,0,0,0,0,33554432,0,0,0,0,524288,0,32,0,0,2,0,16,524288,0,0,0,0,0,4,0,0,0,71303168,262144,0,34603008,131072,536870912,0,0,0,0]),2048)},Yt={RNA:{A:new j.A(new Uint32Array([0,0,0,0,0,0,0,0,0,1024,0,67108864,0,0,0,512,0,0,0,8388608,0,0,512,0,0,64,4,0,0,0,4,0,0,0,67108864,0,524289,0,0,0,0,0,0,16,0,659456,0,256,0,16,0,0,0,268435456,0,0,262144,0,131072,0,0,0,8388608,0]),2048),C:new j.A(new Uint32Array([0,1073741824,0,0,0,0,0,2147483648,4,67108864,0,67108864,0,256,0,0,0,0,0,0,1024,0,128,0,0,64,0,0,0,0,0,0,0,0,67108864,0,524289,0,65536,0,0,0,0,16,0,131072,0,4,0,0,0,0,0,0,4194304,0,0,2147483648,131072,0,4096,0,0,0]),2048),G:new j.A(new Uint32Array([0,0,0,0,1024,0,0,0,0,67109888,16384,67108864,0,0,0,0,0,0,0,33562624,1024,33554432,512,16384,0,64,4,0,0,33554432,0,0,0,0,67108864,0,524289,0,0,0,0,0,0,16,0,135168,0,268435456,0,0,0,0,0,268435456,131072,0,0,2147483648,131072,0,0,0,8388608,0]),2048),T:new j.A(new Uint32Array([8388608,0,0,0,0,0,0,0,0,67108864,0,0,0,4,0,0,0,0,0,0,1024,0,0,16384,0,64,0,0,0,0,0,0,0,2,67108864,0,0,0,0,0,0,0,0,40976,0,0,0,0,0,0,0,0,0,67108864,131072,524288,0,0,8519680,0,1,33554432,1048576,0]),2048),U:new j.A(new Uint32Array([0,0,131072,1073741824,0,0,0,0,0,67108864,0,0,0,0,0,0,0,0,0,0,1024,0,128,0,0,64,0,0,0,0,0,0,0,32768,67108864,0,0,0,0,0,0,0,0,16,0,0,0,4,0,0,2048,0,0,0,4341760,0,0,0,131072,0,0,33554432,1048576,0]),2048)},PEPTIDE:zt};async function Kt(e,t,n=0){if(!Object.keys(Yt).includes(t))return null;const i=await async function(e){const t=a.Func.find({package:"Chem",name:"getMorganFingerprint"})?.[0];if(!t)return null;try{const n=(await t.apply({molString:e}))?.getBuffer().buffer;if(n)return new j.A(new Uint32Array(n),2048)}catch(e){return null}}(e);if(!i)return null;if(!Yt[t])return null;const o=Yt[t];let r=0,s=null;for(const[e,t]of Object.entries(o)){const o=(0,H.$1)(i,t);o>r&&o>=n&&(r=o,s=e)}return s}var Zt,Xt=n(857),Jt={};Jt.styleTagTransform=S(),Jt.setAttributes=b(),Jt.insert=f().bind(null,"head"),Jt.domAPI=m(),Jt.insertStyleElement=w(),d()(Xt.A,Jt),Xt.A&&Xt.A.locals&&Xt.A.locals,function(e){e.MONOMER="Monomer",e.SYMBOL="Symbol",e.NAME="Name",e.R_GROUPS="~R-Groups",e.MONOMER_TYPE="Monomer Type",e.POLYMER_TYPE="Polymer Type",e.NATURAL_ANALOG="Natural Analog",e.AUTHOR="Author",e.CREATE_DATE="Create Date",e.ID="ID",e.META="Meta",e.SOURCE="Source"}(Zt||(Zt={}));const Qt={[Zt.MONOMER]:a.COLUMN_TYPE.STRING,[Zt.SYMBOL]:a.COLUMN_TYPE.STRING,[Zt.NAME]:a.COLUMN_TYPE.STRING,[Zt.R_GROUPS]:a.COLUMN_TYPE.STRING,[Zt.MONOMER_TYPE]:a.COLUMN_TYPE.STRING,[Zt.POLYMER_TYPE]:a.COLUMN_TYPE.STRING,[Zt.NATURAL_ANALOG]:a.COLUMN_TYPE.STRING,[Zt.AUTHOR]:a.COLUMN_TYPE.STRING,[Zt.CREATE_DATE]:a.COLUMN_TYPE.DATE_TIME,[Zt.ID]:a.COLUMN_TYPE.INT,[Zt.META]:a.COLUMN_TYPE.STRING,[Zt.SOURCE]:a.COLUMN_TYPE.STRING};async function en(e){const t=await tn(e);if(e.length!==t.rowCount)throw new Error(`Monomers length ${e.length} does not match dataframe row count ${t.rowCount}`);return await Promise.all(new Array(e.length).fill(null).map(async(e,n)=>dn(t.rows.get(n))))}async function tn(e){try{const t=a.DataFrame.create(e.length),n=new Set;for(const t of e)t.rgroups.forEach(e=>{e.label&&n.add(e.label)});const i=Array.from(n);i.sort();for(const[e,n]of Object.entries(Qt))if(t.columns.addNew(e,n),e===Zt.R_GROUPS)for(const e of i)t.columns.addNew(e,a.COLUMN_TYPE.STRING);t.col(Zt.SYMBOL).semType="Monomer",t.col(Zt.SYMBOL).setTag(ke.Mn.applyToBackground,"true"),t.col(Zt.SYMBOL).setTag(ve.qE.polymerTypeColumnName,Zt.POLYMER_TYPE);const o=a.TaskBarProgressIndicator.create("Creating Monomers DataFrame...");for(let n=0;n<e.length;n++){n%20==0&&o.update((n+1)/e.length*100,"Creating Monomers DataFrame...");const r=()=>{let o=cn(e[n].rgroups,e[n].smiles,e[n].molfile);o=on(o),e[n].rgroups=an(e[n].rgroups);const r=i.map(t=>{const i=e[n].rgroups.find(e=>e.label===t);return i?sn(i,"capGroupSmiles"):""});let s=null;if(e[n].createDate)try{s=Date.parse(e[n].createDate)}catch(t){console.error(`Error parsing date ${e[n].createDate}`)}t.rows.setValues(n,[o,e[n].symbol,e[n].name,JSON.stringify(e[n].rgroups??[]),...r,e[n].monomerType,e[n].polymerType,e[n].naturalAnalog,e[n].author,s,e[n].id,JSON.stringify(e[n].meta??{}),e[n].lib?.source??""],!1);try{s&&t.col(Zt.CREATE_DATE)?.set(n,s,!1)}catch(t){console.error(`Error setting date ${e[n].createDate}`,t)}};await new Promise(e=>{const t=()=>{try{r(),e()}catch(t){console.error("Error in doFill",t),e()}};n%20==0?setTimeout(()=>{t()}):t()})}return o.close(),t.col(Zt.MONOMER).semType=a.SEMTYPE.MOLECULE,i.forEach(e=>{t.col(e).semType=a.SEMTYPE.MOLECULE}),t}catch(e){throw r.shell.error("Error creating monomers dataframe"),console.error(e),e}}class nn{monomerLibManamger;adjustTable(){this.tv?.dataFrame&&(r.data.detectSemanticTypes(this.tv.dataFrame),this.tv.dataFrame.meta.detectSemanticTypes()),setTimeout(()=>{this.tv?.grid&&(this.tv.grid.props.allowEdit=!1,this.tv.grid.col(Zt.NAME).width=100,this.tv.grid.col(Zt.SYMBOL).width=70)},200)}static VIEW_NAME="Manage Monomers";_newMonomer=fe.pe;_newMonomerForm;monomerLib;tv=null;libInput;static instance;activeMonomerLib=null;constructor(e){this.monomerLibManamger=e,this.monomerLib=e.getBioLib(),this._newMonomerForm=new ln(e,()=>this.activeMonomerLib,async e=>{const t=await this.getMonomersDf(this.libInput.value);this.tv?.dataFrame&&(this.tv.dataFrame=t,this.adjustTable(),null!=e&&setTimeout(()=>{const n=t.col(Zt.SYMBOL).toList().indexOf(e);-1!==n&&(this.tv?.grid.scrollToCell(t.columns.byIndex(0),n),t.currentRow=t.rows.get(n))},500))},()=>this.tv?.dataFrame)}static async getInstance(){if(!this.instance){const e=await Hn.getInstance();await e.awaitLoaded(),this.instance=new nn(e)}return this.instance}static async getNewInstance(){const e=await Hn.getInstance();return await e.awaitLoaded(),new nn(e)}async createNewMonomerLib(e,t,n){this.tv?.grid&&s.setUpdateIndicator(this.tv.grid.root,!0);try{const i=(await this.monomerLibManamger.getProviders()).find(t=>t.name===e);if(!i)throw new Error(`Provider ${e} not found`);const o=n.map(e=>({...e,lib:void 0,wem:void 0}));await i.addOrUpdateLibrary(t,o),await this.monomerLibManamger.loadMonomerLib(!1),r.shell.v=await this.getViewRoot(t)}catch(e){r.shell.error("Error creating library"),console.error(e)}finally{this.tv?.grid&&s.setUpdateIndicator(this.tv.grid.root,!1)}}async createNewLibDialog(e){const t=await this.monomerLibManamger.getAvaliableLibraryNames(),n=s.input.string("Library Name",{placeholder:"Enter library name",nullable:!1,onValueChanged:()=>{const e=i(n.value);l.getButton("Create")?.classList?.toggle("d4-disabled",!!e)}});function i(e){return e&&e.trim()?t.includes(e)||t.includes(e+".json")?"Library with this name already exists":null:"Library name cannot be empty"}n.addValidator(i);const o=(await this.monomerLibManamger.getProviders()).map(e=>e.name),a=s.input.choice("Storage",{items:o,value:o[0],nullable:!1,tooltipText:"Select storage provider for the new library"});1===o.length&&(a.readOnly=!0);const l=s.dialog("Create New Library").add(a).add(n).addButton("Create",async()=>{const t=i(n.value);if(t)r.shell.warning(t);else if(a.value){try{await this.createNewMonomerLib(a.value,n.value,e??[])}catch(e){r.shell.error("Error creating library"),console.error(e)}l.close()}else r.shell.warning("Please select storage provider")}).show();l.getButton("Create")?.classList?.toggle("d4-disabled",!0)}get newMonomer(){return this._newMonomer}getNewMonomerForm(){return this._newMonomerForm}_contextMenuSub=null;async getMonomersTableView(e,t=!0){const n=await this.getMonomersDf(e);return this.tv=a.TableView.create(n,t),this.adjustTable(),this._contextMenuSub?.unsubscribe(),this._contextMenuSub=r.events.onContextMenu.subscribe(({args:e})=>{if(!e||!e.menu||!e.context||e.context.type!==a.VIEWER.GRID||!e.context.tableView||e.context.tableView.id!==(this.tv.id??"")||!e.item||!e.item.isTableCell||(e.item.tableRowIndex??-1)<0)return;const t=e.item.tableRowIndex;e.menu.item("Edit Monomer",async()=>{await this.editMonomer(this.tv.dataFrame.rows.get(t))}),e.menu.item("Fix all monomers",()=>{this.fixAllMonomers()}),this.tv.dataFrame.selection.trueCount>0?(e.menu.item("Remove Selected Monomers",async()=>{const e=await Promise.all(Array.from(this.tv.dataFrame.selection.getSelectedIndexes()).map(e=>dn(this.tv.dataFrame.rows.get(e))));this._newMonomerForm.removeMonomers(e,this.libInput.value)}),e.menu.item("Selection To New Library",async()=>{const e=await Promise.all(Array.from(this.tv.dataFrame.selection.getSelectedIndexes()).map(e=>dn(this.tv.dataFrame.rows.get(e))));this.createNewLibDialog(e)})):e.menu.item("Remove Monomer",async()=>{const e=await dn(this.tv.dataFrame.rows.get(t));this._newMonomerForm.removeMonomers([e],this.libInput.value)})}),this.tv.grid&&(this.tv.grid.props.allowEdit=!1),this.tv}static closeAllMonomerManagers(){Array.from(r.shell.tableViews??[]).filter(e=>e.name===nn.VIEW_NAME).forEach(e=>e.close())}findActiveManagerView(){if(!this.tv)return null;const e=Array.from(r.shell.tableViews??[]).find(e=>e.id===this.tv.id);return e?r.shell.v=e:nn.closeAllMonomerManagers(),e??null}_skipLibInputOnchange=!1;async getViewRoot(e,t=!0){const n=await this.monomerLibManamger.getAvaliableLibraryNames();if(this._newMonomerForm.molSketcher.resize(),t&&(this.tv=this.findActiveManagerView())&&(e??this.libInput.value)){try{this._skipLibInputOnchange=!0,this.libInput&&(this.libInput.items=n),e&&(this.libInput.value=e)}catch(e){r.shell.error("Error updating library list"),console.error(e)}finally{this._skipLibInputOnchange=!1}const t=await this.getMonomersDf(e);return this.tv.dataFrame=t,this.adjustTable(),this.tv}e??=n[0],this.tv=await this.getMonomersTableView(e,t);let i=this.tv.getRibbonPanels();i.forEach((e,t)=>{i[t]=e.filter(e=>0!==e.getElementsByClassName("grok-icon-filter").length)}),i=i.filter(e=>e.length>0);const o=s.icons.add(()=>{this._newMonomerForm.setEmptyMonomer()},"Add New Monomer"),l=s.iconFA("wand-magic",()=>{this.fixAllMonomers()},"Fix all monomers"),c=s.icons.edit(async()=>{(this.tv?.dataFrame?.currentRowIdx??-1)<0||await this.editMonomer(this.tv.dataFrame.rows.get(this.tv.dataFrame.currentRowIdx))},"Edit Monomer"),h=s.icons.delete(async()=>{const e=this.tv?.dataFrame?.currentRowIdx??-1,t=Array.from(this.tv?.dataFrame?.selection?.getSelectedIndexes()??[]);if(e<0&&0===t.length)return;if(t.length>0){const e=await Promise.all(t.map(e=>dn(this.tv.dataFrame.rows.get(e))));return void await this._newMonomerForm.removeMonomers(e,this.libInput.value)}const n=await dn(this.tv.dataFrame.rows.get(e));await this._newMonomerForm.removeMonomers([n],this.libInput.value)});s.tooltip.bind(h,()=>(this.tv?.dataFrame?.selection?.trueCount??0)>0?"Delete selected monomers":"Delete monomer");const u=s.iconFA("arrow-to-bottom",async()=>{const e=this.libInput.value;if(!e)return r.shell.error("No library selected");let t=null;try{const n=await(0,we.pY)(await this.monomerLibManamger.getProviders(),e);if(!n)throw new Error(`Library ${e} not found in any provider`);t=await n.getLibraryAsString(e)}catch(t){return r.shell.error(`Error reading library ${e}`),console.error(t)}if(!t)return r.shell.error(`Library ${e} is empty`);a.Utils.download(e,t,"text/plain")},"Download Monomer Library");i.push([o,c,l,h,u]),this.tv.setRibbonPanels(i),this.tv.name=nn.VIEW_NAME,this.libInput=s.input.choice("Monomer Library",{value:e,items:n,nullable:!1,onValueChanged:async()=>{try{if(this._skipLibInputOnchange)return;const e=await this.getMonomersDf(this.libInput.value);this.tv.dataFrame=e,this.adjustTable()}catch(e){console.error(e)}}}),this.libInput.addOptions(s.icons.add(()=>{this.createNewLibDialog()},"Create new monomer library..."));const d=this._newMonomerForm.form;return d.prepend(this.libInput.root),s.tools.waitForElementInDom(this.tv.root).then(()=>{this.tv.dockManager.dock(d,a.DOCK_TYPE.LEFT,null,void 0,.4)}),this.tv}async editMonomer(e){return this._newMonomer=await dn(e),this._newMonomerForm.setMonomer(this._newMonomer),this._newMonomer}async getMonomersDf(e){this.tv?.grid&&s.setUpdateIndicator(this.tv.grid.root,!0);try{let t=null;const n=await this.monomerLibManamger.getProviders();if(0===n.length)throw new Error("No monomer library providers available");if(e){if(t=await(0,we.pY)(n,e),!t)throw new Error(`Library ${e} not found in any provider`)}else t=n[0],e=(await t.listLibraries())[0];if(this.activeMonomerLib=await this.monomerLibManamger.readSingleLibrary(t.name,e),!this.activeMonomerLib)return r.shell.error(`Library ${e} not found`),a.DataFrame.create();const i=this.activeMonomerLib.getPolymerTypes().flatMap(e=>this.activeMonomerLib.getMonomerSymbolsByType(e).map(t=>this.activeMonomerLib.getMonomer(e,t)));return await tn(i)}catch(e){throw r.shell.error("Error creating monomers dataframe"),console.error(e),e}finally{this.tv?.grid&&s.setUpdateIndicator(this.tv.grid.root,!1)}}async fixAllMonomers(){s.dialog("Fix All Monomers").add(s.divText("This action will fix all monomers in the library, standardize their smiles, molblocks and r-groups, assign correct natural analogs and save the library.")).add(s.divText("Do you wish to continue?")).onOK(async()=>{const e=this.tv?.dataFrame,t=this.libInput.value;if(e&&t){this.tv?.grid&&s.setUpdateIndicator(this.tv.grid.root,!0);try{const n=await(0,we.pY)(await this.monomerLibManamger.getProviders(),t);if(!n)throw new Error(`Library ${t} not found in any provider`);const i=(await Promise.all(new Array(e.rowCount).fill(0).map((t,n)=>dn(e.rows.get(n))))).map(e=>({...e,lib:void 0,wem:void 0}));await n.addOrUpdateLibrary(t,i),await this.monomerLibManamger.loadMonomerLib(!0),r.shell.v=await this.getViewRoot(t)}catch(e){r.shell.error("Error saving library"),console.error(e)}finally{this.tv?.grid&&s.setUpdateIndicator(this.tv.grid.root,!1)}}else r.shell.error("No monomer library loaded")}).show()}resetCurrentRowFollowing(){this._newMonomerForm.molChanged=!1}}function on(e){let t=e.replaceAll(/\[R[1-9]\]/g,e=>`[*:${e[2]}]`);return t=t.replaceAll(/\[\d\*\]/g,e=>`[*:${e[1]}]`),t.replaceAll(/\[\d\*\:\d\]/g,e=>`[*:${e[1]}]`)}const rn=["alternateId","capGroupName","capGroupSMILES","label"];function sn(e,t){const n=Object.keys(e).find(e=>e.toLowerCase()===t.toLowerCase());if(n)return e[n]}function an(e){return e.map(e=>{const t=function(e,t){const n={};return e.forEach(e=>{const i=Object.keys(t).find(t=>t.toLowerCase()===e.toLowerCase());i&&(n[e]=t[i])}),n}(rn,e),n=sn(t,"capGroupSMILES"),i=sn(t,"alternateId"),o=sn(t,"capGroupName"),r=sn(t,"label")??"R1";if(n&&i&&o||r.length<2)return t;if(i&&-1!==i.indexOf(`${r}-`)){const e=i.replace(`${r}-`,"");o||(t.capGroupName=e),n||(t.capGroupSMILES=`[*:${r.substring(1)}][${e}]`)}else o&&(n||(t.capGroupSMILES=`[*:${r.substring(1)}][${o}]`),i||(t.alternateId=`${r}-${o}`));return t}).sort((e,t)=>e.label?.localeCompare(t.label??"")??0)}class ln{monomerLibManager;getMonomerLib;refreshTable;getMonomersDataFrame;molSketcher;monomerTypeInput;polymerTypeInput;monomerSymbolInput;monomerNameInput;monomerIdInput;monomerNaturalAnalogInput;rgroupsGrid;metaGrid;colors;colorsEditor;saveButton;rgroupsGridRoot;_molChanged=!1;get molChanged(){return this._molChanged}set molChanged(e){this._molChanged=e}saveValidationResult=null;triggerMolChange=!0;inputsTabControl;constructor(e,t,n,i){this.monomerLibManager=e,this.getMonomerLib=t,this.refreshTable=n,this.getMonomersDataFrame=i,this.colors={line:"#000000",background:"#000000",text:"#000000"},this.colorsEditor=new pn(this.colors),this.molSketcher=new a.chem.Sketcher,this.molSketcher.root.classList.add("monomer-manager-sketcher"),this.polymerTypeInput=s.input.choice("Polymer Type",{value:"PEPTIDE",items:["PEPTIDE","RNA","CHEM","BLOB","G"],onValueChanged:()=>this.onMonomerInputChanged(),nullable:!1}),this.monomerTypeInput=s.input.choice("Monomer Type",{value:"Backbone",items:["Backbone","Branch","Terminal"],onValueChanged:()=>this.onMonomerInputChanged(),nullable:!1}),this.monomerSymbolInput=s.input.string("Monomer Symbol",{nullable:!1,onValueChanged:()=>this.onMonomerInputChanged()}),this.monomerNameInput=s.input.string("Monomer Name",{nullable:!1,onValueChanged:()=>this.onMonomerInputChanged()}),this.monomerNameInput.nullable=!1,this.monomerIdInput=s.input.int("Monomer ID",{nullable:!0,value:0,onValueChanged:()=>this.onMonomerInputChanged()}),this.monomerNaturalAnalogInput=s.input.string("Natural Analog",{nullable:!0,onValueChanged:()=>this.onMonomerInputChanged()}),this.saveButton=s.bigButton("Save",async()=>{const e=this.validateInputs();e?r.shell.warning(e):await this.saveMonomer()}),this.molSketcher.subs.push(this.molSketcher.onChanged.subscribe(async()=>{if(this.triggerMolChange){try{this.rgroupsGridRoot.style.display="none";const e=this.inputsTabControl.panes.find(e=>"r-groups"===e.name?.toLowerCase());e&&e.header.style.removeProperty("background-color");let t=this.molSketcher.getSmiles();if(!t)return this.rgroupsGrid.items=[],this.rgroupsGrid.render(),this.saveValidationResult="Monomer molecule is required",void this.invalidateSaveButton();t=cn([],t);const n=this.findRgroupsInSmiles(t);if(0===n.length)return this.rgroupsGrid.items=[],this.rgroupsGrid.render(),this.saveValidationResult="At least one R-group is required",e&&e.header.style.setProperty("background-color","#ff000030"),void this.invalidateSaveButton();if(new Set(n.map(e=>e[0])).size!==n.length)return this.saveValidationResult="Duplicate R-groups are not allowed",this.rgroupsGridRoot.style.display="flex",e&&e.header.style.setProperty("background-color","#ff000030"),void this.invalidateSaveButton();const i=n.map(e=>Number.parseInt(e[0].match(/[1-9]/g)[0])).map(e=>this.rgroupsGrid.items.find(t=>t.label===`R${e}`)??{capGroupSMILES:`[*:${e}][H]`,alternateId:`R${e}-H`,capGroupName:"H",label:`R${e}`});this.rgroupsGrid.items=i.sort((e,t)=>e.label?.localeCompare(t.label??"")??0),this.rgroupsGrid.render(),this.rgroupsGridRoot.style.display="flex";const o=await Kt(un(t,i),this.polymerTypeInput.value??"");o&&(this.monomerNaturalAnalogInput.value=o)}catch(e){console.error(e)}this.onMonomerInputChanged(),this._molChanged=!0}else this.triggerMolChange=!0}));const o=[a.Property.js("capGroupSMILES",a.TYPE.STRING,{caption:"R-group SMILES",nullable:!1}),a.Property.js("alternateId",a.TYPE.STRING,{caption:"Alternate ID",nullable:!1}),a.Property.js("capGroupName",a.TYPE.STRING,{caption:"R-group name",nullable:!1}),a.Property.js("label",a.TYPE.STRING,{fieldName:"R-group Label",nullable:!1,userEditable:!1})];this.rgroupsGrid=new qt(o,[],{allowAdd:!1,allowRemove:!1,validators:{capGroupSMILES:e=>e?r.chem.checkSmiles(e)?null:"Invalid SMILES":"Cap group smiles is required",alternateId:e=>e?null:"Alternate ID is required",capGroupName:e=>e?null:"Cap group name is required",label:e=>e?null:"R-group label is required"},customLabels:{capGroupSMILES:"R-group SMILES",alternateId:"Alternate ID",capGroupName:"Cap Group Name",label:"Label"}}),this.rgroupsGrid.onItemChanged.subscribe(()=>this.onMonomerInputChanged()),this.rgroupsGridRoot=s.divV([this.rgroupsGrid.root]),this.rgroupsGridRoot.style.display="none";const l=[a.Property.js("Property",a.TYPE.STRING,{caption:"Property",nullable:!0}),a.Property.js("Value",a.TYPE.STRING,{caption:"Value",nullable:!0})];this.metaGrid=new qt(l,[]),this.onMonomerInputChanged();const c=s.divV([this.polymerTypeInput,this.monomerTypeInput,this.monomerSymbolInput,this.monomerNameInput,this.monomerIdInput,this.monomerNaturalAnalogInput]);this.inputsTabControl=s.tabControl({Monomer:c,"R-groups":this.rgroupsGridRoot,Meta:s.divV([this.metaGrid.root]),Colors:this.colorsEditor.form},!1)}invalidateSaveButton(){this.saveValidationResult?this.saveButton.classList.add("d4-disabled"):this.saveButton.classList.remove("d4-disabled")}onMonomerInputChanged(){setTimeout(()=>{this.saveValidationResult=this.validateInputs(),this.invalidateSaveButton();const e=this.polymerTypeInput.value&&this.polymerTypeInput.value&&!!this.getMonomerLib()?.getMonomer(this.polymerTypeInput.value,this.monomerSymbolInput.value);this.saveButton.textContent=e?"Save Monomer":"Add Monomer"},200)}setEmptyMonomer(){this.triggerMolChange=!1,this.molSketcher.setSmiles(""),this.monomerSymbolInput.value="",this.monomerNameInput.value="",this.monomerIdInput.value=null,this.monomerNaturalAnalogInput.value=null,this.rgroupsGrid.items=[],this.metaGrid.items=[],this.rgroupsGrid.render(),this.metaGrid.render(),this.rgroupsGridRoot.style.display="none",this.onMonomerInputChanged(),this.colorsEditor.colors={line:"#000000",background:"#000000",text:"#000000"}}setMonomer(e){this.triggerMolChange=!1,this.molSketcher.setSmiles(e.smiles),this.polymerTypeInput.value=e.polymerType,this.monomerTypeInput.value=e.monomerType,this.monomerSymbolInput.value=e.symbol,this.monomerNameInput.value=e.name,this.monomerIdInput.value=e.id,this.monomerNaturalAnalogInput.value=e.naturalAnalog??null,this.rgroupsGrid.items=an(e.rgroups),this.metaGrid.items=Object.entries(e.meta??{}).filter(([e,t])=>"colors"!==e?.toLowerCase()).map(([e,t])=>({Property:e,Value:t})),this.rgroupsGrid.render(),this.metaGrid.render(),this.rgroupsGridRoot.style.display="flex",this.onMonomerInputChanged(),!e.naturalAnalog&&e.polymerType&&Kt(un(e.smiles,this.rgroupsGrid.items),e.polymerType).then(e=>{e&&(this.monomerNaturalAnalogInput.value=e)});const t=e.meta?.colors??"";let n={};try{n=t?JSON.parse(t)?.default:{}}catch(e){console.error(e)}this.colorsEditor.colors={line:n.line??"#000000",background:n.background??"#000000",text:n.text??"#000000"}}validateInputs(){const e=this.inputsTabControl.panes.find(e=>"r-groups"===e.name?.toLowerCase());if(e&&e.header.style.removeProperty("background-color"),!this.molSketcher.getSmiles())return"Monomer Molecule field is required";for(const e of[this.polymerTypeInput,this.monomerTypeInput,this.monomerSymbolInput,this.monomerNameInput])if(null==e.value||""===e.value)return`${e.caption} field is required`;let t=null;if(this.rgroupsGrid.items.length<1&&(t="At least one R-group is required"),!t)e:for(const e of this.rgroupsGrid.items)for(const[n,i]of Object.entries(e))if(!i){t=`R-group ${n} field is required for ${e.label}`;break e}return!t&&this.rgroupsGrid.hasErrors()&&(t="R-group fields contain errors"),t?(e&&e.header.style.setProperty("background-color","#ff000030"),t):null}findRgroupsInSmiles(e){return[...Array.from(e.matchAll(/\[[1-9]\*\]/g)),...Array.from(e.matchAll(/\[\*\:[1-9]\]/g))]}get form(){this.inputsTabControl.root.classList.add("monomer-manager-form-tab-control"),this.inputsTabControl.header.style.marginBottom="10px";const e=s.buttonsInput([this.saveButton]);return s.tooltip.bind(e,()=>this.saveValidationResult??"Save monomer to library"),s.divV([this.molSketcher.root,this.inputsTabControl.root,e],{classes:"ui-form",style:{paddingLeft:"10px",overflow:"scroll",maxWidth:"unset"}})}get fieldInputs(){return{molecule:this.molSketcher,polymerType:this.polymerTypeInput,monomerType:this.monomerTypeInput,symbol:this.monomerSymbolInput,name:this.monomerNameInput,id:this.monomerIdInput,naturalAnalog:this.monomerNaturalAnalogInput}}get metaInputs(){return[]}get rgroupInputs(){return[]}getMonomerInfoTable(e){const t=cn(e.rgroups,e.smiles,e.molfile),n=r.chem.drawMolecule(t,150,150),i=s.tableFromMap({name:e.name,author:e.author,createDate:e.createDate});return s.divH([n,i],{style:{alignItems:"center"}})}async removeMonomers(e,t,n=!0){const i=await(0,we.pY)(await this.monomerLibManager.getProviders(),t);if(!i)return void r.shell.error(`Library ${t} not found in any provider`);const o=s.divV(e.map(e=>this.getMonomerInfoTable(e)),{style:{maxHeight:"500px",overflow:"scroll"}}),a=e.length>1,l=a?`Are you sure you want to remove monomers ${e.map(e=>e.symbol).join(", ")} from ${t} library?`:`Are you sure you want to remove monomer with symbol ${e[0].symbol} from ${t} library?`,c=s.dialog("Remove Monomer"+(a?"s":"")).add(s.h1(l)).add(o).addButton("Remove",async()=>{await i.deleteMonomersFromLibrary(t,e),await this.monomerLibManager.loadMonomerLib(!0),await this.refreshTable(),n&&r.shell.info(`Monomer${a?"s":""} ${e.map(e=>e.symbol).join(", ")} ${a?"were":"was"} successfully removed from ${t} library`),c.close()}).show()}async addMonomerToLib(e,t){const n=this.getMonomersDataFrame();if(!n)return void r.shell.error("No monomer library loaded");const i=n?.col(Zt.POLYMER_TYPE)?.toList()??[],o=n?.col(Zt.SYMBOL)?.toList()??[],a=n?.col(Zt.MONOMER)?.toList()??[];if(i.length!==o.length||i.length!==a.length)return void r.shell.error("Monomer library data frame is corrupted");const l=i.findIndex((t,n)=>t===e.polymerType&&o[n]===e.symbol),c=a.findIndex(t=>t===e.smiles),h=async()=>{try{const n=await(0,we.pY)(await this.monomerLibManager.getProviders(),t);if(!n)return void r.shell.error(`Library ${t} not found in any provider`);await n.updateOrAddMonomersInLibrary(t,[{...e,lib:void 0,wem:void 0}]),await this.monomerLibManager.loadMonomerLib(!0),await this.refreshTable(e.symbol),this._molChanged=!1,r.shell.info(`Monomer ${e.symbol} was successfully saved in library ${t}`)}catch(e){r.shell.error("Error saving monomer"),console.error(e)}this.onMonomerInputChanged()};let u=null,d="";if(l>=0)u=this.getMonomerInfoTable(await dn(n.row(l))),d=`Monomer with symbol '${e.symbol}' already exists in library ${t}.\nAre you sure you want to overwrite it?`;else if((c??-1)>=0){const e=await dn(this.getMonomersDataFrame().rows.get(c));u=this.getMonomerInfoTable(e),d=`Monomer with the same structure already exists in library ${t} with different symbol (${e.symbol}).\nAre you sure you want to duplicate it?`}if(u){const e=s.dialog("Save Monomer").add(s.divText(d)).add(u).addButton("Save",()=>{e.close(),h()}).show()}else await h()}async saveMonomer(){let e=this.molSketcher.getSmiles();if(!e||!r.chem.checkSmiles(e))return void r.shell.warning("Invalid SMILES");e=cn([],e);let t=r.chem.convert(e,a.chem.Notation.Smiles,a.chem.Notation.MolBlock);t=hn(t);const n={};this.metaGrid.items.filter(e=>!!e.Property&&!!e.Value).forEach(e=>{n[e.Property]=e.Value});const i=this.metaGrid.addingItem;i&&i.Property&&i.Value&&(n[i.Property]=i.Value),"#000000"===this.colorsEditor.colors.line&&"#000000"===this.colorsEditor.colors.background&&"#000000"===this.colorsEditor.colors.text||(n.colors={default:this.colorsEditor.colors});const o={symbol:this.monomerSymbolInput.value,name:this.monomerNameInput.value,molfile:t,smiles:e,polymerType:this.polymerTypeInput.value,monomerType:this.monomerTypeInput.value,naturalAnalog:this.monomerNaturalAnalogInput.value?this.monomerNaturalAnalogInput.value:void 0,id:this.monomerIdInput.value??0,rgroups:this.rgroupsGrid.items,author:a.User.current().friendlyName,createDate:(new Date).toISOString(),meta:n},s=this.getMonomerLib()?.source;s?await this.addMonomerToLib(o,s):r.shell.warning("Monomer library source is not specified")}}function cn(e,t,n){const i=!t||!r.chem.checkSmiles(t);if(i&&!n)throw new Error("Both SMILES and MOL block are empty or malformed");let o=i?r.chem.convert(n,a.chem.Notation.Unknown,a.chem.Notation.Smiles):t;return o=function(e,t){let n=e;return t.forEach(e=>{const t=e.label[1]??"1",i=new RegExp(`\\[\\${e.capGroupName}:${t}\\]`,"g");n=n.replace(i,`[*:${t}]`)}),n=n.replaceAll(/\[\d[A-Z]{1,2}\]/g,e=>`[*:${e[1]}]`),n}(o,e),o=on(o),i?o:r.chem.convert(o,a.chem.Notation.Unknown,a.chem.Notation.Smiles)}function hn(e){const t=e.split("\n"),n=t.findIndex(e=>e.startsWith("M")&&e.includes("ISO"));if(-1!==n){const e=t[n].indexOf("ISO");t[n]=t[n].substring(0,e)+"RGP"+t[n].substring(e+3)}const i=t.findIndex(e=>e.includes("V2000"));if(-1===i)return console.error("Mol start line not found"),e;const o=Number.parseInt(t[i].trim().split(" ")[0].slice(0,3).trim()),r={};for(let e=i+1;e<i+1+o;e++){const n=t[e].indexOf("R ");if(-1===n)continue;"#"!==t[e][n+1]&&(t[e]=t[e].replace("R ","R#"));const o=t[e].trim().split(" ").map(e=>e.trim()).filter(Boolean);if(r[e-i]=1,o.length<14)continue;const s=Number.parseInt(o[13]);Number.isNaN(s)||(r[e-i]=s)}const s=Object.keys(r);if(-1===t.findIndex(e=>e.startsWith("M")&&e.includes("RGP"))){const e=`M RGP${s.length.toString().padStart(3," ")}${Object.entries(r).map(([e,t])=>`${e.toString().padStart(4," ")}${t.toString().padStart(4," ")}`).join("")}`,n=t.findIndex(e=>e.startsWith("M")&&e.includes("END"));t.splice(n,0,e)}return s.filter(e=>!!Number.parseInt(e)).map(e=>Number.parseInt(e)+i).forEach(e=>{const n=t[e].split(" "),i=n.findIndex(e=>"R#"===e);if(-1!==i){for(let e=i+1;e<n.length;e++)n[e]&&1==n[e].length&&(Number.parseInt(n[e])??0)>0&&(n[e]="0");t[e]=n.join(" ")}}),t.join("\n")}function un(e,t){let n=e;return t.forEach(e=>{const t=e.label[1]??"1",i=sn(e,"capGroupName");n=n.replace(`[*:${t}]`,`[${i}]`)}),n}async function dn(e){let t;try{t=JSON.parse(e.get(Zt.META)??"{}");for(const e in t)"object"==typeof t[e]&&(t[e]=JSON.stringify(t[e])),("string"!=typeof t[e]||t[e]!==a.INT_NULL.toString()&&t[e]!==a.FLOAT_NULL.toString())&&("number"!=typeof t[e]||t[e]!==a.INT_NULL&&t[e]!==a.FLOAT_NULL)||(t[e]=null)}catch(e){console.error(e)}const n=e.get(Zt.MONOMER);if(!n)throw new Error("Monomer SMILES is empty");let i="";try{i=r.chem.convert(n,a.chem.Notation.Smiles,a.chem.Notation.MolBlock),i=hn(i)}catch(e){r.shell.error(`Error converting SMILES to molfile, \n ${n}`),console.error(e)}let o=e.get(Zt.NATURAL_ANALOG);const s=e.get(Zt.POLYMER_TYPE);let l=[];try{if(l=JSON.parse(e.get(Zt.R_GROUPS)??"[]"),!o&&s){const e=await Kt(un(n,l),s);e&&(o=e)}}catch(e){l??=[]}return{symbol:e.get(Zt.SYMBOL),name:e.get(Zt.NAME),molfile:i,smiles:n,polymerType:s,monomerType:e.get(Zt.MONOMER_TYPE),naturalAnalog:o,id:e.get(Zt.ID),rgroups:l,meta:t,author:e.get(Zt.AUTHOR),createDate:e.get(Zt.CREATE_DATE)}}class pn{_colors;_colorInputs;constructor(e){this._colors=e,this._colorInputs={line:s.input.color("Line",{value:e.line,onValueChanged:e=>this._colors.line=e}),background:s.input.color("Background",{value:e.background,onValueChanged:e=>this._colors.background=e}),text:s.input.color("Text",{value:e.text,onValueChanged:e=>this._colors.text=e})}}get colors(){return this._colors}set colors(e){const t={line:a.Color.toHtml(a.Color.fromHtml(e.line??"#000000")),background:a.Color.toHtml(a.Color.fromHtml(e.background??"#000000")),text:a.Color.toHtml(a.Color.fromHtml(e.text??"#000000"))};this._colors=t;for(const e in this._colorInputs)this._colorInputs[e].value=t[e]}get colorsMetaFormat(){return{colors:{default:this._colors}}}get form(){return s.form(Object.values(this._colorInputs))}}const mn=/.*\|\$.*R.*\$\|/,gn=/\[R(\d+)\]/,fn=/\[R(\d+)\]/g,yn=/\[\*:(\d+)\]/g;function bn(e,t){const n=Array.from(e.matchAll(fn)).map(e=>e[1]),i={name:"Explicit SMILES Monomer",smiles:e,polymerType:t??"CHEM",molfile:"",rgroups:n.map(e=>({label:`R${e}`,capGroupName:"H",capGroupSmiles:`[*:${e}][H]`,alternateId:`R${e}-H`})),author:"Datagrok auto-generated",id:0,createDate:null,monomerType:"Backbone"};try{let t=e;i.rgroups.forEach(e=>{const n=e.label.substring(1);t=t.replace(`[R${n}]`,`[*:${n}]`)});const n=hn(r.chem.convert(t,r.chem.Notation.Smiles,r.chem.Notation.MolBlock));i.molfile=n,i.smiles=t}catch(t){Dr.logger.error(`getMonomerFromRSmiles: cannot convert SMILES to Molfile: ${e}\n${t}`)}return i}const vn=/[\w()]+/,wn=RegExp(String.raw`\(${vn}(,${vn})+\)`),Cn=e=>{const t=s.canvas(250,250);return r.chem.canvasMol(0,0,250,250,t,e),t},Sn=new Ht.Mi([255,255,255]),An=new Ht.Mi([0,0,0]),xn=.7*(0,K.wQ)(Sn);class En{_monomers;source;_isEmpty;get isEmpty(){return this._isEmpty}_onChanged=new h.Subject;get onChanged(){return this._onChanged}constructor(e,t){this._monomers=e,this.source=t,this._isEmpty=!this._monomers||0===Object.keys(this._monomers).length||Object.entries(this._monomers).every(([e,t])=>0===Object.keys(t).length);for(const[e,t]of Object.entries(this._monomers))for(const[e,n]of Object.entries(t))n.lib=this}getMonomerSymbolsByType(e){const t=Object.keys(this._monomers[e]);return this._smilesMonomerCache[e]&&t.push(...Object.keys(this._smilesMonomerCache[e])),t}_smilesMonomerCache={};addMissingMonomer(e,t){let n=this._monomers[e];n||(n=this._monomers[e]={});let i=t;t==ve._S||t===ve.b9[ve.Hi.HELM]?i="Gap":("PEPTIDE"===e&&"X"===t||"RNA"===e&&"N"===t)&&(i="Any");const o=function(e,t){try{if(mn.test(e)){const n=e.split("|$"),i=n[0].trim(),o=n[1],r=Array.from(o.matchAll(/R(\d+)/g)),s=Array.from(i.matchAll(/(\*)/g));if(r.length!==s.length)return null;let a=i.replaceAll(/\[\*\]/g,"*");const l=r.map(e=>e[1]);for(let e=0;e<l.length;e++){const t=l[e];a=a.replace("*",`[R${t}]`)}return bn(a,t)}let n=e;const i=Array.from(e.matchAll(yn));for(const e of i){const t=e[0],i=e[1];n=n.replace(t,`[R${i}]`)}if(gn.test(n))return bn(n,t)}catch(t){Dr.logger.error(`smiles2Monomer: cannot parse SMILES: ${e}\n${t}`)}return null}(t,e);if(o){this._smilesMonomerCache[e]=this._smilesMonomerCache[e]??{};const i=this._smilesMonomerCache[e],r=Object.keys(i).length+1;i[t]=`#${e[0]}${r}`;const s={...o,symbol:i[t]},a=new Gt((0,Fe.MD)(e),s.symbol,t,`SMILES Monomer ${s.symbol}`,s.rgroups.map(e=>e.label));return s.wem=a,n[s.symbol]=s,s}return n[t]={symbol:t,name:i,molfile:"",author:"MISSING",id:-1,rgroups:R().count(1).take(9).map(e=>({capGroupSmiles:"",alternateId:"",capGroupName:"",label:`R${e.toString()}`})).toArray(),smiles:"",polymerType:e,monomerType:void 0,createDate:null}}getMonomer(e,t){let n=t;"RNA"==e&&"R"==n&&(n="r"),"RNA"==e&&"P"==n&&(n="p");let i=null;if(e){this._smilesMonomerCache[e]?.[n]&&(n=this._smilesMonomerCache[e][n]);const t=this._monomers[e];i=t?.[n]??null}else{Dr.logger.warning(`Bio: MonomerLib.getMonomer() symbol '${t}', polymerType not specified.`);for(const[e,t]of Object.entries(this._monomers))if(i=t[n],i)break}return i}getWebEditorMonomer(e,t){const[n,i]=(0,kt.fA)(e,t),o=(0,Ot.Y)(n);let r=this.getMonomer(o,i);if(r&&n==De.o.LINKER&&2!=r.rgroups.length)return null;if(r&&n==De.o.SUGAR&&3!=r.rgroups.length)return null;r||(r=this.addMissingMonomer(o,i));let s=r.wem??null;return s||(i===ve._S||"*"==i?s=r.wem=new Bt(n):n===De.o.NUCLEOTIDE&&"N"===i||n===De.o.AA&&"X"===i||(De.o.CHEM,0)||wn.test(i)?s=r.wem=new Dt(n,i):r.lib||(s=r.wem=new Vt(n,i,this.isEmpty)),s||(s=r.wem=jt.fromMonomer(n,r,this))),s}getTooltip(e,t){const n=(0,Ot.Y)(e),i=s.div([],{classes:"ui-form ui-tooltip"}),o=this.getWebEditorMonomer(e,t),r=this.getMonomer(n,t);if(r){const e=r.symbol,[t,n,a]=(r.name,o?[o.textcolor,o.backgroundcolor,o.linecolor]:["#202020","#A0A0A0","#202020"]);let l;if(i.append(s.divH([s.div([e],{style:{textWrap:"nowrap",marginLeft:"4px",marginRight:"4px",color:t,backgroundColor:n,borderColor:a,borderWidth:"1px",borderStyle:"solid",borderRadius:"2px",padding:"3px",minWidth:"24px",textAlign:"center"}}),s.div([r.name],{style:{padding:"4px"}})],{style:{display:"flex",flexDirection:"row",justifyContent:"left"}})),l=r.molfile?Cn(r.molfile):r.smiles?s.divV([Cn(r.smiles),s.divText("from smiles",{style:{fontSize:"smaller"}})]):s.divText("No structure",{style:{margin:"6px"}}),i.append(s.div(l,{style:{display:"flex",flexDirection:"row",justifyContent:"center",margin:"6px"}})),r.symbol!=ve._S){let e=r.lib?.source;e?(e.endsWith(".json")&&(e=e.substring(0,e.length-5)),e=e.replace(/_/g," ").replace(/-/g," ").replace(/([a-z])([a-z])([A-Z])/g,"$1$2 $3"),i.append(s.divText(e))):i.append(s.divText("Missed in libraries"))}}else i.append(s.divV([s.divText(`Monomer '${t}' of type '${n}' not found.`),s.divText("Open the Context Panel, then expand Manage Libraries")]));return i}getMonomerTextColor(e,t){const n=this.getMonomerColors(e,t),i=e=>{const t=/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/.exec(e);if(t)return[parseInt(t[1]),parseInt(t[2]),parseInt(t[3])];const n=a.Color.fromHtml(e);return[a.Color.r(n),a.Color.g(n),a.Color.b(n)]},o=i(n.textcolor),r=new Ht.Mi([...o.map(e=>e+1)]),s=(0,K.KE)(r,Sn)/((0,K.wQ)(r)*(0,K.wQ)(Sn)),l=i(n.backgroundcolor),c=new Ht.Mi([...l.map(e=>e+.01)]);let h;h=(0,K.KE)(c,Sn)/((0,K.wQ)(c)*(0,K.wQ)(Sn))<s?l:o;let u=new Ht.Mi(h);const d=(0,K.wQ)(u);return d>xn&&(u=(0,K.dC)(An,u,xn/d)),`rgb(${u[0]}, ${u[1]}, ${u[2]})`}getMonomerColors(e,t){const n="default";let i=n;const o=(0,Ot.Y)(e),r=this.getMonomer(o,t);let s;if(r){if(r.meta&&r.meta.colors){if("string"==typeof r.meta.colors)try{r.meta.colors=JSON.parse(r.meta.colors)}catch(e){Dr.logger.error(`Bio: MonomerLib.getMonomerColors() failed to parse monomer.meta.colors: ${e}`)}const e=r.meta.colors;e&&"string"!=typeof e&&!(n in e)&&(i="default"),e&&"string"!=typeof e&&i in e&&(s=e[i])}if(!s){const t=Ut[e],n=t?.[r.symbol];n&&(s={textColor:a.Color.toHtml(a.Color.getContrastColor(a.Color.fromHtml(n))),lineColor:"#202020",backgroundColor:n})}const t=r.naturalAnalog;if(!s&&t&&t!==r.symbol)return this.getMonomerColors(e,t)}return s||(s={textColor:"#202020",lineColor:"#202020",backgroundColor:"#A0A0A0"}),{textcolor:s.text??s.textColor,linecolor:s.line??s.lineColor,backgroundcolor:s.background??s.backgroundColor}}getRS(e){const t=e.match(/(?<=\[)[^\][]*(?=])/gm),n={};let i,o="";if(t)for(let e=0;e<t.length;e++)if(null!=t[e]&&/\d/.test(t[e])){i=t[e][t[e].length-1],t[e]=t[e].replace(/[0-9]/g,"");for(let n=0;n<t[e].length;n++)":"!=t[e][n]&&(o+=t[e][n]);n["R"+i]=o,o=""}return n}}var Mn=n(5488),Tn={};Tn.styleTagTransform=S(),Tn.setAttributes=b(),Tn.insert=f().bind(null,"head"),Tn.domAPI=m(),Tn.insertStyleElement=w(),d()(Mn.A,Tn),Mn.A&&Mn.A.locals&&Mn.A.locals;class _n extends En{error;_duplicateMonomers={};get duplicateMonomers(){return this._duplicateMonomers}_duplicatesHandled=!0;get duplicatesHandled(){return this._duplicatesHandled}duplicatesNotified=!1;constructor(e,t,n=void 0){super(e,t),this.error=n}toJSON(){const e=[];for(const t of Object.values(this._monomers))for(const n of Object.values(t))e.push({...n,lib:void 0,wem:void 0});return e}_monomerSets=null;getMonomerSet(e){const t=(0,Ot.Y)(e);if(this._monomerSets||(this._monomerSets={}),!(e in this._monomerSets))for(const[e,n]of Object.entries(this._monomers[t]));return this._monomerSets[e]}getPolymerTypes(){return Object.keys(this._monomers)}getMonomerMolsByPolymerType(e){const t={};return Object.keys(this._monomers[e]??{}).forEach(n=>{t[n]=this._monomers[e][n].molfile}),t}getMonomerSymbolsByRGroup(e,t,n){let i=this.getMonomerSymbolsByType(t).map(e=>this.getMonomer(t,e));return i=i.filter(e=>null!==e),0===i.length?[]:(i=i.filter(t=>{if(!t?.rgroups)return!1;let n=t?.rgroups.length>=e;var i;return i=$t.getInstance(t.molfile).atomTypes,i.map((e,t)=>"R#"===e?t:-1).filter(e=>-1!==e),n&&=!0,n}),i.map(e=>e?.symbol))}_updateLibInt(e){const t=e.getPolymerTypes(),n=this.getPolymerTypes();t.forEach(t=>{n.includes(t)||(this._monomers[t]={}),e.getMonomerSymbolsByType(t).forEach(n=>{this._monomers[t][n]&&(this._duplicateMonomers[t]??={},this._duplicateMonomers[t][n]??=[this._monomers[t][n]],this._duplicateMonomers[t][n].push(e.getMonomer(t,n))),this._monomers[t][n]=e.getMonomer(t,n)})}),this._isEmpty=this.isEmpty&&e.isEmpty}async updateLibs(e,t=!1){t&&(this._monomers={},this._isEmpty=!0),this._duplicateMonomers={};for(const t of e)t.error||this._updateLibInt(t);if(Object.entries(this.duplicateMonomers).length>0){const e=await(0,Pe.ub)();this.assignDuplicatePreferences(e)}else this._duplicatesHandled=!0;this._onChanged.next()}assignDuplicatePreferences(e){let t=!0;for(const n in this.duplicateMonomers)for(const i in this.duplicateMonomers[n])if(e.duplicateMonomerPreferences?.[n]?.[i]){const o=e.duplicateMonomerPreferences[n][i],r=this.duplicateMonomers[n][i].find(e=>e.lib?.source===o);r?this._monomers[n][i]=r:t=!1}else t=!1;return this._duplicatesHandled=t,t}clear(){this._monomers={},this._onChanged.next()}getSummaryObj(){const e={},t=this.getPolymerTypes();for(const n of t)e[n]=this.getMonomerSymbolsByType(n).length;return e}getSummaryDf(){const e=this.getPolymerTypes(),t=new Array(e.length);for(const[n,i]of R().enumerate(e))t[i]=this.getMonomerSymbolsByType(n).length;return a.DataFrame.fromColumns([a.Column.fromStrings("polymerType",e),a.Column.fromList(a.COLUMN_TYPE.INT,"count",t)])}getSummary(){const e=this.getPolymerTypes();return 0==e.length?"empty":e.map(e=>`${e} ${this.getMonomerSymbolsByType(e).length}`).join("\n")}static overrideCounter=0;override(e,t){return new In(e,`override: ${++_n.overrideCounter}, ${t}`,this)}}class In extends En{data;base;constructor(e,t,n){super(e,t),this.data=e,this.base=n}get onChanged(){return this.base.onChanged}getMonomerSymbolsByType(e){const t=this.base.getMonomerSymbolsByType(e);for(const n of Object.keys(this.data[e]??{}))t.includes(n)||t.push(n);return t}addMissingMonomer(e,t){return this.base.addMissingMonomer(e,t)}getMonomer(e,t){const n=this.data[e]?.[t];return n??this.base.getMonomer(e,t)}}var Ln=n(8604),Nn=n(7433),Pn=n.n(Nn),Rn=n(1913),$n=n.n(Rn);class On{helmMonomerSchema;validateMonomerSchema;constructor(e){this.helmMonomerSchema=e;const t=new(Pn())({allErrors:!0,strictTuples:!1,allowUnionTypes:!0});$n()(t),this.validateMonomerSchema=t.compile(this.helmMonomerSchema)}validateFile(e,t){const n=this.parseJson(e,t);return null!=n&&(Array.isArray(n)?this.validateJsonContent(n,t):(console.warn(`Bio: Monomer Library File Validator file '${t}': Invalid JSON format: The file must contain an array of monomers.`),!1))}parseJson(e,t){try{return JSON.parse(e)}catch(e){return console.error(`Bio: Monomer Library File Validator file '${t}': Invalid JSON format:`,e),null}}validateJsonContent(e,t){let n=!0;const i=new Set;for(const o of e){const e=o.symbol??o.id??o.name??"#N/A";if(n=this.validateMonomerSchema(o),!n){console.warn(`Bio: Monomer Library File Validator file ${t}, monomer '${e}' violating JSON schema:`,o,"\nError reason: ",JSON.stringify(this.validateMonomerSchema.errors??{}),`\nThere may be other errors in ${t} since the validation is stopped after the first error.`," Please, verify that the monomer library file satisfies the JSON schema");break}const r=`${o.polymerType??""}-${e}`;i.has(r)&&console.warn(`Bio: Monomer Library File Validator file ${t}, monomer '${e}' is duplicated.`,"Please, verify that the monomer library file does not contain duplicated monomer symbols."),i.add(r)}return n}}class kn{fileValidator;libHelper;logger;get LIB_PATH(){return"System:AppData/Bio/monomer-libraries/"}get SETS_PATH(){return"System:AppData/Bio/monomer-sets/"}static HELM_JSON_SCHEMA_PATH="System:AppData/Bio/tests/libraries/HELMmonomerSchema.json";static _instance=null;filesPromise=Promise.resolve();name=we.ic;_onChanged=new h.Subject;get onChanged(){return this._onChanged}constructor(e,t,n){this.fileValidator=e,this.libHelper=t,this.logger=n}static async getInstance(e,t){if(null==this._instance){const n=await r.dapi.files.readAsText(kn.HELM_JSON_SCHEMA_PATH),i=JSON.parse(n),o=new On(i);kn._instance=new kn(o,e,t),kn._instance.refreshLists()}return kn._instance}toLog(){return"MonomerLibFileManager"}async validateAgainstHELM(e,t){if(!this.isValidHELMLibrary(e,t))throw new Error(`File ${t} does not satisfy HELM standard`)}isValidHELMLibrary(e,t){return this.fileValidator.validateFile(e,t)}async refreshLists(){await Promise.all([this.updateValidLibList(),this.updateValidSetList()])}async addOrUpdateLibraryString(e,t){e=e.endsWith(".json")?e:`${e}.json`;try{await this.validateAgainstHELM(t,e),await r.dapi.files.writeAsText(this.LIB_PATH+`${e}`,t),await this.updateValidLibList(),await r.dapi.files.exists(this.LIB_PATH+`${e}`)?r.shell.info(`Added ${e} HELM library`):r.shell.error(`Failed to add ${e} library`)}catch(t){this.logger.error(t),r.shell.error(`Failed to add ${e} library`)}}async addOrUpdateLibrary(e,t){const n=JSON.stringify([...t.map(e=>({...e,wem:void 0,lib:void 0}))],null,2);await this.addOrUpdateLibraryString(e,n)}get loadPromise(){return this.filesPromise}async listLibraries(){return this.validLibList}async listSets(){return this.validSetList}async loadLibraries(e,t=!1){let n=[];e=e.map(e=>e.endsWith(".json")?e:`${e}.json`);const i=t?e:e.map(e=>this.LIB_PATH+e),o=[];for(let e=0;e<i.length;e++){const t={};try{const o=await r.dapi.files.readAsText(i[e]);n=JSON.parse(o),n.forEach(e=>{const n=e.polymerType,i=e.symbol;t[n]||(t[n]={}),t[n][i]=e})}catch(t){this.logger.error(`Failed to load monomer library file: ${i[e]}`),this.logger.error(t);continue}finally{o.push(t)}}return o}async loadSets(e){const t=[],n=this.libHelper.getMonomerLib();for(const i of e){const e=i.endsWith(".json")?i:`${i}.json`,o=this.SETS_PATH+e;try{const e=await r.dapi.files.readAsText(o),i=JSON.parse(e),s=i.description,a=Object.entries(i.placeholders).map(([e,t])=>{const i=e,o=t.polymerType,r=t.monomerType,s=t.set;return new we.lH(n,i,o,r,s)});t.push(new we.YS(s,a))}catch(e){this.logger.error(`Failed to load monomer set file: ${o}`),this.logger.error(e);continue}}return t}async deleteLibrary(e){const t=e.endsWith(".json")?e:`${e}.json`;await r.dapi.files.delete(this.LIB_PATH+t),await this.updateValidLibList()}async deleteSet(e){const t=e.endsWith(".json")?e:`${e}.json`;await r.dapi.files.delete(this.SETS_PATH+t),await this.updateValidSetList()}async addOrUpdateSetString(e,t){const n=e.endsWith(".json")?e:`${e}.json`;await r.dapi.files.writeAsText(this.SETS_PATH+n,t),await this.updateValidSetList()}async addOrUpdateSet(e,t){const n=JSON.stringify(t,null,2);await this.addOrUpdateSetString(e,n)}async deleteMonomersFromLibrary(e,t){const n=e.endsWith(".json")?e:`${e}.json`,i=this.LIB_PATH+n,o=await r.dapi.files.readAsText(i);let s=JSON.parse(o);s=s.filter(e=>!t.some(t=>e.polymerType===t.polymerType&&e.symbol===t.symbol));const a=JSON.stringify(s,null,2);await r.dapi.files.writeAsText(i,a),await this.updateValidLibList()}validLibList=[];libListHasChanged(e){const t=this.validLibList;return e.length!==t.length||e.some((e,n)=>e!==t[n])}validSetList=[];setListHasChanged(e){const t=this.validSetList;return e.length!==t.length||e.some((e,n)=>e!==t[n])}async getLibraryAsString(e){const t=e.endsWith(".json")?e:`${e}.json`;return r.dapi.files.readAsText(this.LIB_PATH+t)}async getSingleLibrary(e){return(await this.loadLibraries([e]))?.[0]}async getSingleLibraryWithFullPath(e){return(await this.loadLibraries([e],!0))?.[0]}async updateOrAddMonomersInLibrary(e,t){const n=e.endsWith(".json")?e:`${e}.json`,i=this.LIB_PATH+n,o=await r.dapi.files.readAsText(i),s=JSON.parse(o);for(const e of t){const t=s.findIndex(t=>t.polymerType===e.polymerType&&t.symbol===e.symbol);-1!==t?s[t]={...e,lib:void 0,wem:void 0}:s.push({...e,lib:void 0,wem:void 0})}const a=JSON.stringify(s,null,2);await r.dapi.files.writeAsText(i,a),await this.updateValidLibList()}async updateValidLibList(){const e=`${this.toLog()}.updateValidLibList()`;return this.logger.debug(`${e}, start`),this.filesPromise=this.filesPromise.then(async()=>{this.logger.debug(`${e}, IN`);const t=[],n=await this.getLibFileListAtLocation();if(!this.libListHasChanged(n))return void this.logger.debug(`${e}, end, not changed`);for(const e of n){if(!e.endsWith(".json")){t.push(e);continue}const n=await r.dapi.files.readAsText(this.LIB_PATH+`${e}`);this.isValidHELMLibrary(n,e)||t.push(e)}const i=n.filter(e=>!t.includes(e));if(this.libListHasChanged(i)&&(this.validLibList=i,await this.libHelper.loadMonomerLib(!0)),i.some(e=>!e.endsWith(".json"))&&this.logger.warning(`Wrong validation: ${i}`),t.length>0){const e=`Invalid monomer library files in ${this.LIB_PATH}, consider fixing or removing them: ${t.join(", ")}`;this.logger.warning(e)}this.logger.debug(`${e}, OUT`),this._onChanged.next()}),this.logger.debug(`${e}, end`),this.filesPromise}async updateValidSetList(){const e=`${this.toLog()}.updateValidSetList()`;return this.logger.debug(`${e}, start`),this.filesPromise=this.filesPromise.then(async()=>{this.logger.debug(`${e}, IN`);const t=[],n=await this.getSetFileListAtLocation();if(!this.setListHasChanged(n))return void this.logger.debug(`${e}, end, not changed`);for(const e of n)e.endsWith(".json")||t.push(e);const i=n.filter(e=>!t.includes(e));this.setListHasChanged(i)&&(this.validSetList=i,this.libHelper.loadMonomerSets(!0)),this.logger.debug(`${e}, OUT`),this._onChanged.next()}),this.logger.debug(`${e}, end`),this.filesPromise}async getLibFileListAtLocation(){const e=`${this.toLog()}.getLibFileListAtLocation()`;this.logger.debug(`${e}, start`);const t=await r.dapi.files.list(this.LIB_PATH).then(e=>e.filter(e=>e.isFile).map(e=>e.fullPath)),n=[];return n.push(...t),n.map(e=>e.substring(this.LIB_PATH.length))}async getSetFileListAtLocation(){const e=`${this.toLog()}.getSetFileListAtLocation()`;this.logger.debug(`${e}, start`);const t=await r.dapi.files.list(this.SETS_PATH).then(e=>e.map(e=>e.fullPath)),n=[];return n.push(...t),n.map(e=>e.substring(this.SETS_PATH.length))}}class Hn{logger;_monomerLib=new _n({},"MAIN");_monomerSets=new we.YS("MAIN",[]);_initialLoadCompleted=!1;get initialLoadCompleted(){return this._initialLoadCompleted}_providersDataChanged=new h.Subject;get providersDataChanged(){return this._providersDataChanged}_fileUploadRequested=new h.Subject;get fileUploadRequested(){return this._fileUploadRequested}requestFileUpload(){this._fileUploadRequested.next()}_selectionChanged=new h.Subject;get librarySelectionChanged(){return this._selectionChanged}notifyLibrarySelectionChanged(){this._selectionChanged.next()}async getAvaliableLibraryNames(e=!1){const t=await this.getProviders(),n=[];for(const i of t){e&&await i.refreshLists();const t=await i.listLibraries();n.push(...t)}return n}async refreshValidLibraryLists(){const e=await this.getProviders();await Promise.all(e.map(async e=>e.refreshLists()))}async getAvailableLibrariesPerProvider(){const e=await this.getProviders(),t=new Map;for(const n of e){const e=await n.listLibraries();t.set(n.name,e)}return t}async awaitLoaded(e=1/0){return e=e===1/0?6e4:e,await Promise.race([(async()=>{const e=await this.getProviders();return await Promise.all(e.map(async e=>e.loadPromise)),await this.loadLibrariesPromise,!0})(),(async()=>(await(0,et.cb)(e),!1))()]).then(t=>{if(!t)throw new Error(`Loading monomer libraries timeout ${e} ms.`)})}_monomerLibProviders=null;async getProviders(){if(null==this._monomerLibProviders){const e=a.Func.find({tags:["monomer-lib-provider"]});this._monomerLibProviders=await Promise.all(e.map(async e=>await e.apply({}))),this._monomerLibProviders.push(await kn.getInstance(this,Dr.logger)),a.debounce((0,h.merge)(...this._monomerLibProviders.map(e=>e.onChanged)),200).subscribe(()=>{this._providersDataChanged.next()})}return this._monomerLibProviders}constructor(e){this.logger=e}static objCounter=-1;objId=(()=>{if(++Hn.objCounter>0)throw new Error("MonomerLibManager MUST be a singleton.");return Hn.objCounter})();toLog(){return`MonomerLibManager<${this.objId}>`}getMonomerLib(){return this._monomerLib}getBioLib(){return this.getMonomerLib()}getMonomerSets(){return this._monomerSets}get duplicateMonomers(){return this._monomerLib.duplicateMonomers}get duplicatesHandled(){return this._monomerLib.duplicatesHandled}assignDuplicatePreferances(e){this._monomerLib.assignDuplicatePreferences(e)}loadLibrariesPromise=Promise.resolve();async loadMonomerLib(e=!1){const t=`${this.toLog()}.loadMonomerLib()`;return this.logger.debug(`${t}, start`),this.loadLibrariesPromise=this.loadLibrariesPromise.then(async()=>{this.logger.debug(`${t}, IN`);const n=a.TaskBarProgressIndicator.create("Loading monomers ...");try{const t=await(0,Pe.ub)(),i=await this.getProviders(),o=await Promise.all(i.map(async e=>e.listLibraries()));o.forEach((e,n)=>{o[n]=e.filter(e=>{const n=!t.exclude.includes(e),i=0===(t.explicit?.length??0)||t.explicit.includes(e);return n&&i})});let s=0;const a=[];for(let e=0;e<i.length;e++){const t=i[e],l=o[e];try{const e=await t.loadLibraries(l);for(let t=0;t<e.length;t++)a.push(new _n(e[t],l[t]))}catch(e){r.shell.warning(`Loading monomer libraries from provider '${t.name}' failed: `),this.logger.error(`Loading monomer libraries from provider '${t.name}' failed: ${e instanceof Error?e.message:e.toString()}`)}n.update(Math.round(100*++s/i.length),`Loading monomers ${s}/${i.length}`)}this._monomerLib.updateLibs(a,e),this._initialLoadCompleted=!0}catch(e){const t=`Loading monomer libraries error: ${e instanceof Error?e.message:e.toString()}`;r.shell.warning(t);const n=e instanceof Error?e.stack:void 0;this.logger.error(t,void 0,n)}finally{n.close(),this.logger.debug(`${t}, OUT`)}}),this.logger.debug(`${t}, end`),this.loadLibrariesPromise}async loadLibraries(e){return this.loadMonomerLib(e)}loadSetsPromise=Promise.resolve();async loadMonomerSets(e=!1){const t=`${this.toLog()}.loadMonomerSets()`;return this.logger.debug(`${t}, start`),this.loadSetsPromise=this.loadSetsPromise.then(async()=>{this.logger.debug(`${t}, IN`);const e=a.TaskBarProgressIndicator.create("Loading monomer sets ...");try{const t=await this.getProviders(),n=await Promise.all(t.map(async e=>e.listSets())),i=[];let o=0;for(let s=0;s<t.length;s++){const a=t[s],l=n[s];try{const e=await a.loadSets(l);for(let t=0;t<e.length;t++)i.push(e[t])}catch(e){r.shell.warning(`Loading monomer sets from provider '${a.name}' failed: `),this.logger.error(`Loading monomer sets from provider '${a.name}' failed: ${e instanceof Error?e.message:e.toString()}`)}e.update(Math.round(100*++o/t.length),`Loading monomer sets ${o}/${t.length}`)}this._monomerSets.updateSets(i)}catch(e){const t=`Loading monomer sets error: ${e instanceof Error?e.message:e.toString()}`;r.shell.warning(t);const n=e instanceof Error?e.stack:void 0;this.logger.error(t,void 0,n)}finally{e.close(),this.logger.debug(`${t}, OUT`)}}),this.logger.debug(`${t}, end`),this.loadSetsPromise}async loadMonomerLibForTests(){await(0,Pe.Eu)(Ln.G),await this.awaitLoaded(1e4),await this.loadMonomerLib(!0)}async readSingleLibrary(e,t){const n=(await this.getProviders()).find(t=>t.name===e);if(!n)return this.logger.error(`Provider '${e}' not found.`),null;try{const i=await n.loadLibraries([t]);return 0===i.length?(this.logger.error(`Library '${t}' not found in provider '${e}'.`),null):new _n(i[0],t)}catch(e){return this.logger.error(`Loading monomer library '${t}' from provider '${n.name}' failed: ${e instanceof Error?e.message:e.toString()}`),null}}async readLibraryFromFilePath(e){const t=(await this.getProviders()).find(e=>e.name===we.ic);if(!t)throw new Error(`Provider '${we.ic}' not found.`);const n=await t.getSingleLibraryWithFullPath(e);if(!n)throw new Error(`Library at path '${e}' not found.`);return new _n(n,e)}async readSingleLibraryByName(e){const t=await this.getProviders(),n=await(0,we.pY)(t,e);return n?this.readSingleLibrary(n.name,e):(this.logger.error(`No provider found for library '${e}'.`),null)}async readSingleSet(e,t){const n=(await this.getProviders()).find(t=>t.name===e);if(!n)return this.logger.error(`Provider '${e}' not found.`),null;try{const i=await n.loadSets([t]);return 0===i.length?(this.logger.error(`Set '${t}' not found in provider '${e}'.`),null):i[0]}catch(e){return this.logger.error(`Loading monomer set '${t}' from provider '${n.name}' failed: ${e instanceof Error?e.message:e.toString()}`),null}}static async getInstance(){let e=window.$monomerLibHelperPromise;return null==e&&(e=window.$monomerLibHelperPromise=(async()=>new Hn(Dr.logger))()),e}}var Fn=n(1757),Gn=n.n(Fn);class Bn{monomer;root=s.divV([],{classes:"monomer-card-root"});_selected=!1;get selected(){return this._selected}set selected(e){this._selected=e,this.root.style.border=e?"2px solid var(--green-2)":"2px solid var(--grey-2)"}constructor(e){this.monomer=e}render(){s.empty(this.root);const e=this.monomer.smiles&&r.chem.checkSmiles(this.monomer.smiles)?r.chem.drawMolecule(this.monomer.smiles,200,200):r.chem.drawMolecule(this.monomer.molfile??"",200,200);this.root.appendChild(e);const t=s.divH([s.divText("Monomer Name: "),s.divText(this.monomer.name)],{classes:"monomer-card-info-row"});if(this.root.appendChild(t),s.tooltip.bind(t,this.monomer.name),this.monomer.lib?.source){const e=s.divH([s.divText("Source: "),s.divText(this.monomer.lib.source)],{classes:"monomer-card-info-row"});this.root.appendChild(e),s.tooltip.bind(e,this.monomer.lib.source)}const n=s.divH([s.divText("Polymer Type: "),s.divText(this.monomer.polymerType)],{classes:"monomer-card-info-row"});this.root.appendChild(n),s.tooltip.bind(n,this.monomer.polymerType),s.tooltip.bind(this.root,"Select Monomer")}}class Dn{monomerSymbol;monomers;root=s.divH([],{style:{alignItems:"center",width:"100%",overflow:"hidden",visibility:"visible"},classes:"duplicate-monomer-symbol-row"});monomerCards;constructor(e,t,n,i){this.monomerSymbol=e,this.monomers=t,this.monomerCards=t.map(e=>new Bn(e));const o=s.divH([],{style:{overflowX:"auto",width:"100%"}}),r=s.h1(e,{style:{lineHeight:"2em",fontSize:"1.5em",marginRight:"20px",width:"100px",overflow:"hidden",textOverflow:"elipsis"}});s.tooltip.bind(r,e),this.root.appendChild(r),this.root.appendChild(o),this.monomerCards.forEach(e=>{e.root.onclick=()=>{this.monomerCards.forEach(e=>e.selected=!1),e.selected=!0,i(e.monomer)},n&&e.monomer===n&&(e.selected=!0),o.appendChild(e.root)})}render(){this.monomerCards.forEach(e=>e.render())}}class Vn{monomerCardRows=[];saveSettingsPromise=Promise.resolve();searchInput;_root;monomers;settings;filteredMonomerRows=[];static _instance;vv;static async getInstance(){return Vn._instance||(Vn._instance=new Vn,await Vn._instance.refresh(),(await Hn.getInstance()).getMonomerLib().onChanged.subscribe(async()=>await Vn._instance.refresh())),Vn._instance.refresh(),Vn._instance}async refresh(){this.settings=await(0,Pe.ub)();const e=await Hn.getInstance();await e.awaitLoaded(),this.monomers=e.duplicateMonomers,this.monomerCardRows=[];for(const t in this.monomers)for(const n in this.monomers[t]){const i=this.settings.duplicateMonomerPreferences?.[t]?.[n]??null,o=i?this.monomers[t][n].find(e=>e.lib?.source===i)??null:null;this.monomerCardRows.push(new Dn(n,this.monomers[t][n],o,async i=>{this.saveSettingsPromise=this.saveSettingsPromise.then(async()=>{i.lib?.source&&(this.settings.duplicateMonomerPreferences=this.settings.duplicateMonomerPreferences??{},this.settings.duplicateMonomerPreferences[t]=this.settings.duplicateMonomerPreferences[t]??{},this.settings.duplicateMonomerPreferences[t][n]=i.lib.source,await(0,Pe.Eu)(this.settings),e.assignDuplicatePreferances(this.settings),r.shell.info(`Monomer '${i.name}' from source '${i.lib.source}' selected for symbol '${n}'.`))})}))}const t=s.divText("Set Default");if(t.addEventListener("click",async()=>{if(0===Object.keys(this.monomers??{}).length)return void r.shell.info("No Duplicate Monomers found");const t=new Set;for(const e in this.monomers)for(const n in this.monomers[e])for(const i of this.monomers[e][n])i.lib?.source&&t.add(i.lib.source);if(0===t.size)return void r.shell.info("No Duplicate Monomers found");const n=Array.from(t),i=s.input.choice("Default Library",{items:n,nullable:!0});s.dialog("Set Default Monomer Source for Duplicates").add(i).onOK(async()=>{if(i.value){for(const e in this.monomers)for(const t in this.monomers[e]){const n=this.monomers[e][t];n?.some(e=>e.lib?.source===i.value)&&(this.settings.duplicateMonomerPreferences=this.settings.duplicateMonomerPreferences??{},this.settings.duplicateMonomerPreferences[e]=this.settings.duplicateMonomerPreferences[e]??{},this.settings.duplicateMonomerPreferences[e][t]=i.value)}await(0,Pe.Eu)(this.settings),e.assignDuplicatePreferances(this.settings),r.shell.info(`Default Monomer Source for Duplicates set to '${i.value}'.`),setTimeout(()=>this.refresh(),100)}else r.shell.info("No library selected")}).show()}),this.filteredMonomerRows=this.monomerCardRows,this.vv)this.vv.setData(this.filteredMonomerRows.length,e=>(this.filteredMonomerRows[e].render(),this.filteredMonomerRows[e].root));else{this.vv=s.virtualView(this.monomerCardRows.length,e=>(this.monomerCardRows[e].render(),this.monomerCardRows[e].root)),this.vv.root.classList.add("duplicate-monomers-virtual-view"),this.searchInput=s.input.string("Search",{placeholder:"Monomer Symbol",value:"",onValueChanged:()=>e(this.searchInput.value)}),this.searchInput.root.style.justifyContent="center",this.searchInput.addOptions(t),this.searchInput.input.style.width="200px",this._root=s.divV([s.h1("Manage Duplicate Monomer Symbols",{style:{textAlign:"center"}}),this.searchInput.root,s.divV([this.vv.root],{style:{overflowY:"auto",height:"100%"}})],{style:{height:"100%"}});const e=e=>{this.filteredMonomerRows=this.monomerCardRows.filter(t=>t.monomerSymbol.toLowerCase().includes(e.toLowerCase())),this.vv.setData(this.filteredMonomerRows.length,e=>(this.filteredMonomerRows[e].render(),this.filteredMonomerRows[e].root))}}}constructor(){}get root(){return this._root}}var Wn=n(3017),jn={};async function Un(){await Zn.showDialog()}async function qn(e=!0){return await Xn.showView(e)}jn.styleTagTransform=S(),jn.setAttributes=b(),jn.insert=f().bind(null,"head"),jn.domAPI=m(),jn.insertStyleElement=w(),d()(Wn.A,jn),Wn.A&&Wn.A.locals&&Wn.A.locals;class zn{_widget;get widget(){return this._widget}constructor(){}static instancePromise;libHelper;static async getInstance(){return null==zn.instancePromise&&(zn.instancePromise=(async()=>{const e=new zn,t=await(0,we.pj)();return e.libHelper=t,e._widget=await e.createWidget(),e})()),zn.instancePromise}static async reloadWidget(){const e=await zn.getInstance();e._widget=await e.createWidget()}async createWidget(){const e=await this.getWidgetContent();return(await(0,we.pj)()).fileUploadRequested.subscribe(()=>this.promptToAddLibraryFiles()),new a.Widget(e)}async getWidgetContent(){const e=await Yn.createControlsForm();return Gn()(e).addClass("monomer-lib-controls-form"),setTimeout(()=>{e&&Gn()(e)&&Gn()(e).removeClass("ui-form-condensed")},200),s.divV([e])}async promptToAddLibraryFiles(){a.Utils.openFile({accept:".json",open:async e=>{const t=async t=>{const n=await e.text(),i=e.name,o=a.TaskBarProgressIndicator.create(`Adding ${i} as a monomer library`);try{await t.addOrUpdateLibraryString(i,n)}catch(e){r.shell.error(`File ${i} is not a valid monomer library, verify it is aligned to HELM JSON schema.`)}finally{o.close()}},n=await this.libHelper.getProviders();if(0===n.length)return void r.shell.error("No monomer library providers available to add the library.");if(1===n.length)return void await t(n[0]);const i=s.dialog("Select storage for new monomer library"),o=s.input.choice("Storage",{items:n.map(e=>e.name),value:n[0].name,nullable:!1,tooltipText:"Storage provider for new monomer library"});i.add(o).onOK(async()=>{const e=n.find(e=>e.name===o.value);await t(e)})}})}}class Yn{libHelper;userLibSettings;constructor(e,t){this.libHelper=e,this.userLibSettings=t,this.libHelper.providersDataChanged.subscribe(async()=>{await this.updateControlsForm()})}toLog(){return"LibraryControlsManager<#>"}static async createControlsForm(){Dr.logger.debug("LibraryControlsForm.createControlsForm(), start");const e=await(0,Pe.ub)(),t=await(0,we.pj)();return new Yn(t,e)._createControlsForm()}async _createControlsForm(){const e=await this.createLibraryControls(),t=s.wideForm(e,void 0);return Gn()(t).addClass("monomer-lib-controls-form"),t}async updateControlsForm(){const e=await this._createControlsForm();Gn()(".monomer-lib-controls-form").replaceWith(e)}async createLibraryControls(){return(await this.libHelper.getAvaliableLibraryNames()).map(e=>this.createLibInput(e))}createLibInput(e){const t=`${this.toLog()}.createLibInput()`;Dr.logger.debug(`${t}, libFileName = '${e}', start`);const n=!this.userLibSettings.exclude.includes(e),i=s.input.bool(e,{value:n,onValueChanged:()=>{Kn(i.value,e)}});s.tooltip.bind(i.root,`Include monomers from ${e}`);const o=s.iconFA("trash-alt",()=>this.promptForLibraryDeletion(e)),a=s.icons.edit(async()=>{r.shell.v=await(await nn.getInstance()).getViewRoot(e)},"Edit monomer library");return s.tooltip.bind(o,`Delete ${e}`),i.addOptions(a),i.addOptions(o),Dr.logger.debug(`${t}, libFileName = '${e}', end`),i}promptForLibraryDeletion(e){s.dialog("Warning").add(s.divText(`Are you sure you want to delete library "${e}"?`)).onOK(async()=>{try{const t=a.TaskBarProgressIndicator.create(`Deleting ${e} library`);await Kn(!1,e);const n=await(0,we.pY)(await this.libHelper.getProviders(),e);if(!n)throw new Error(`Cannot find provider for library ${e}`);await n.deleteLibrary(e),t.close()}catch(t){console.error(t),r.shell.error(`Failed to delete ${e} library`)}}).showModal(!1)}}async function Kn(e,t){const n=await(0,Pe.ub)();!function(e,t,n){t?e.exclude=e.exclude.filter(e=>e!==n):e.exclude.includes(n)||e.exclude.push(n)}(n,e,t),await(0,Pe.Eu)(n);const i=await(0,we.pj)();await i.loadMonomerLib(!0),r.shell.info("Monomer library user settings saved"),i.notifyLibrarySelectionChanged()}class Zn{constructor(){}static _instance;dialog;closeDialogSubject$=new h.Subject;static async showDialog(){Zn._instance||(Zn._instance=new Zn,Zn._instance.closeDialogSubject$.subscribe(()=>{Zn._instance.dialog=void 0})),Zn._instance.dialog||(Zn._instance.dialog=await Zn._instance.getDialog()),Zn._instance.dialog.show()}async getDialog(){const e=(await zn.getInstance()).widget,t=await(0,we.pj)(),n=s.dialog({title:"Manage monomer libraries",helpUrl:"/help/datagrok/solutions/domains/bio/bio.md#manage-monomer-libraries"});Gn()(n.root).css("width","350px"),n.clear(),n.addButton("Add",()=>t.requestFileUpload(),void 0,"Upload new HELM monomer library"),n.add(e);const i=n.onClose.subscribe(()=>{this.closeDialogSubject$.next(),i.unsubscribe()});return n}}class Xn{constructor(){}static _instance;static viewName="Manage Monomer Libraries";_view;_duplicateManager;libManager;async getView(e=!0){const t=(await zn.getInstance()).widget,n=s.bigButton("Add",()=>this.libManager.requestFileUpload(),"Upload new HELM monomer library"),i=s.bigButton("Merge",()=>{this.mergeSelectedLibs()},"Merge selected libraries into one"),o=s.splitH([s.divV([t.root,s.buttonsInput([n,i])],{classes:"ui-form"}),this._duplicateManager.root],{style:{width:"100%",height:"100%"}},!0);if(this._view)try{this._view.subs.forEach(e=>e.unsubscribe()),this._view.detach(),this._view.close()}catch(e){}return this._view=a.View.fromRoot(o),this._view.name=Xn.viewName,e&&r.shell.addView(this._view),s.tools.waitForElementInDom(o).then(()=>{setTimeout(()=>{const e=Array.from(o.children).filter(e=>e.classList.contains("ui-box"));if(2!==e.length)return;const[t,n]=e,i=t.getBoundingClientRect().width+n.getBoundingClientRect().width,r=.3*i;t.style.width=`${r}px`;const s=i-r;n.style.width=`${s}px`},100),this._view.subs.push(r.events.onCurrentViewChanged.subscribe(()=>{try{const e=Xn._instance;e&&e._view&&r.shell.v&&"id"in r.shell.v&&r.shell.v.id===e._view.id&&e._duplicateManager?.refresh()}catch(e){console.error(e)}}))}),this._view}static async showView(e=!0){return Xn._instance||(Xn._instance=new Xn),Xn._instance._duplicateManager||(Xn._instance._duplicateManager=await Vn.getInstance()),Xn._instance.libManager||(Xn._instance.libManager=await Hn.getInstance()),e&&Xn._instance._view&&Array.from(r.shell.views).find(e=>e.id&&e.id===Xn._instance._view.id)?(r.shell.v=Xn._instance._view,await Xn._instance._duplicateManager.refresh(),Xn._instance._view):(Xn.closeExistingViews(),Xn._instance.getView(e))}static closeExistingViews(){Array.from(r.shell.views).filter(e=>e.name===Xn.viewName).forEach(e=>e.close())}async mergeSelectedLibs(){const e="Library with this name already exists",t=await Hn.getInstance();if(await t.awaitLoaded(),!t.duplicatesHandled)return void r.shell.warning("Selected libraries contain repeating symbols with different monomers.\n Please choose the correct monomer for each symbol using duplicate monomomer manager.");const n=t.getBioLib().toJSON(),i=s.dialog("Merge selected libraries"),o=s.input.string("Library Name",{placeholder:"Enter new library name",nullable:!1,onValueChanged:()=>{const t=c(o.value);i.getButton("Download")?.classList?.toggle("d4-disabled",!!t&&t!==e),i.getButton("Save")?.classList?.toggle("d4-disabled",!!t)}}),l=await this.libManager.getAvaliableLibraryNames();function c(t){return t&&t.trim()?l.includes(t)||l.includes(t+".json")?e:null:"Library name cannot be empty"}o.addValidator(c);const h=await this.libManager.getProviders();if(0===h.length)return void r.shell.error("No monomer library providers available to save the merged library.");const u=s.input.choice("Storage",{items:h.map(e=>e.name),value:h[0].name,nullable:!1,tooltipText:"Storage provider for saving new monomer library"});i.add(u).add(o).add(s.divText(`Total monomers: ${n.length}`)).addButton("Download",()=>{a.Utils.download((()=>{let e=o.value.trim();return e||(e="New"),e.toLowerCase().endsWith(".json")||(e+=".json"),e})(),JSON.stringify(n))}).addButton("Save",async()=>{if(!o.value||!o.value.trim()||!u.value)return u.validate(),void o.validate();i.close();const e=o.value,t=JSON.stringify(n);this._view&&s.setUpdateIndicator(this._view.root,!0);try{const n=h.find(e=>e.name===u.value);await n.addOrUpdateLibraryString(e,t);const i=await(0,Pe.ub)();i.exclude=l,await(0,Pe.Eu)(i),await this.libManager.loadMonomerLib(!0),await zn.reloadWidget()}catch(t){r.shell.error(`Failed to save library ${e}. see console for details.`),console.error(t)}finally{this._view&&s.setUpdateIndicator(this._view.root,!1)}}).show(),i.getButton("Download")?.classList?.add("d4-disabled"),i.getButton("Save")?.classList?.add("d4-disabled")}}var Jn,Qn=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function s(e){try{l(i.next(e))}catch(e){r(e)}}function a(e){try{l(i.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((i=i.apply(e,t||[])).next())})};class ei{_setBreadcrumbsInViewName(){var e,t;const n=["Home","Demo",...(null!==(e=this._path)&&void 0!==e?e:"").split("/")],i=s.breadcrumbs(n);if(i.onPathClick.subscribe(e=>Qn(this,void 0,void 0,function*(){const t=e[e.length-1];if(t===i.path[i.path.length-1])return;const n=r.shell.browsePanel.mainTree.getOrCreateGroup("Apps").getOrCreateGroup("Demo");n.currentItem="Demo"===t?n:n.items.find(e=>e.text===t)})),r.shell.v){if(0!==i.path.length&&"Home"===i.path[0]){const e=s.iconFA("home",()=>{r.shell.v.close(),r.shell.v=a.View.createByType(a.VIEW_TYPE.HOME)});e.classList.add("demo-breadcrumbs-home-element"),i.root.firstElementChild.replaceWith(e)}const e=null===(t=r.shell.v.ribbonMenu.root.parentElement)||void 0===t?void 0:t.getElementsByClassName("d4-ribbon-name")[0];e&&(e.textContent="",e.appendChild(i.root))}}constructor(e,t,n=!1,i){var o,r;this.name="",this.description="",this._isAutomatic=!1,this._autoStartFirstStep=!1,this._currentStep=0,this._isStopped=!1,this._isCancelled=!1,this._isStepProcessed=!1,this._root=s.div([],{id:"demo-script",classes:"tutorials-root tutorials-track demo-app-script"}),this._steps=[],this._mainHeader=s.panel([],"tutorials-main-header"),this._header=s.h2(""),this._headerDiv=s.divH([],"tutorials-root-header"),this._stopStartBtn=s.button(s.iconFA("pause"),()=>Qn(this,void 0,void 0,function*(){return yield this._changeStopState()}),"Play / pause"),this._restartBtn=s.button(s.iconFA("redo"),()=>Qn(this,void 0,void 0,function*(){return yield this._restartScript()}),"Restart"),this._nextStepBtn=s.button(s.iconFA("play"),()=>Qn(this,void 0,void 0,function*(){this._isStepProcessed||(yield this._nextStep())}),"Next step"),this._activity=s.panel([],"tutorials-root-description"),this._progressDiv=s.divV([],"tutorials-root-progress"),this._progress=s.element("progress"),this._progressSteps=s.divText(""),this._closeBtn=s.button(s.iconFA("chevron-left"),()=>this._closeDock(),"Back to demo"),this.DEMO_PATH="apps/Tutorials/Demo",this.name=e,this.description=t,this._isAutomatic=n,this._autoStartFirstStep=null!==(o=null==i?void 0:i.autoStartFirstStep)&&void 0!==o&&o,this._path=null!==(r=null==i?void 0:i.path)&&void 0!==r?r:"",this._progress.max=0,this._progress.value=1,ei.currentObject=this}get steps(){return this._steps}get stepNumber(){return this._steps.length}_addHeader(){this._createHeaderDiv(),this._createProgressDiv(),this._mainHeader.append(this._headerDiv,this._progressDiv)}_createHeaderDiv(){this._header.innerText=this.name,this._headerDiv.append(this._closeBtn),this._headerDiv.append(this._header),this._nextStepBtn.firstChild.className="grok-icon fas fa-play",this._headerDiv.append(this._isAutomatic?this._stopStartBtn:this._nextStepBtn)}_createProgressDiv(){this._progress.max=this.stepNumber,this._progressDiv.append(this._progress),this._progressSteps=s.divText(`Step: ${this._progress.value} of ${this.stepNumber}`),this._progressDiv.append(this._progressSteps)}_addDescription(){var e;this._activity.append(s.div(this.description,"tutorials-root-description"));for(let t=0;t<this.stepNumber;t++){let n=s.iconFA("clock");this._isAutomatic||0===t&&(n=s.iconFA("play",()=>this._nextStep(),"Next step"),n.className="grok-icon fas fa-play");const i=s.div(this._steps[t].name,"grok-tutorial-entry-instruction"),o=s.div(null===(e=this._steps[t].options)||void 0===e?void 0:e.description,"grok-tutorial-step-description hidden"),r=s.divH([n,i],"grok-tutorial-entry");this._activity.append(r,o)}}_initRoot(){r.shell.windows.showContextPanel=!0,r.shell.windows.showHelp=!1,this._node=r.shell.dockManager.dock(this._root,a.DOCK_TYPE.FILL,r.shell.dockManager.findNode(r.shell.browsePanel.root),this.name),this._node.container.containerElement.classList.add("tutorials-demo-script-container"),this._addHeader(),this._root.append(this._mainHeader),this._addDescription(),this._root.append(this._activity)}_setViewParams(){var e;r.shell.v&&(r.shell.v.name=this.name,r.shell.v.path=`${this.DEMO_PATH}/${(null!==(e=this._path)&&void 0!==e?e:"").replaceAll(" ","-")}`,this._setBreadcrumbsInViewName())}_nextStep(){return Qn(this,void 0,void 0,function*(){var e,t;this._isStepProcessed=!0,this._isAutomatic||(this._nextStepBtn.classList.add("disabled"),this._nextStepBtn.firstChild.classList.add("fa-disabled"));const n=this._activity.getElementsByClassName("grok-tutorial-entry")[this._currentStep],i=this._activity.getElementsByClassName("grok-icon")[this._currentStep],o=this._activity.getElementsByClassName("grok-tutorial-step-description")[this._currentStep];i.className="grok-icon far fa-spinner-third fa-spin",o.classList.remove("hidden"),o.classList.add("visible");const l=n,c=(null===(e=this._steps[this._currentStep].options)||void 0===e?void 0:e.delay)?null===(t=this._steps[this._currentStep].options)||void 0===t?void 0:t.delay:2e3;try{this._setViewParams(),yield this._steps[this._currentStep].func(),this._setViewParams()}catch(e){console.error(e)}this._scrollTo(this._root,l.offsetTop-this._mainHeader.offsetHeight),this._isAutomatic&&(yield this._countdown(n,i,c),yield(0,et.cb)(c));const h=s.iconFA("check");if(i.replaceWith(h),h.className="grok-icon far fa-check",this._progress.value++,this._progressSteps.innerText=`Step: ${this._progress.value} of ${this.stepNumber}`,this._currentStep++,this._isStepProcessed=!1,this._currentStep!==this.stepNumber){if(!this._isAutomatic){const e=this._activity.getElementsByClassName("grok-icon")[this._currentStep],t=s.iconFA("play",()=>this._nextStep(),"Next step");t.className="grok-icon fas fa-play",e.replaceWith(t),this._nextStepBtn.classList.remove("disabled"),this._nextStepBtn.firstChild.classList.remove("fa-disabled")}r.shell.v instanceof a.TableView&&(yield r.data.detectSemanticTypes(r.shell.tv.dataFrame))}else this._isAutomatic?this._stopStartBtn.replaceWith(this._restartBtn):this._nextStepBtn.replaceWith(this._restartBtn)})}_startScript(){return Qn(this,void 0,void 0,function*(){for(let e=this._currentStep;e<this.stepNumber&&!this._isStopped&&!this._isCancelled;e++)yield this._nextStep()})}_scrollTo(e,t){e.focus(),e.scrollTop=t}_countdown(e,t,n){return Qn(this,void 0,void 0,function*(){const i=s.div([],"demo-script-countdown");t.classList.add("hidden");let o=n/1e3;const r=this._createSVGIndicator(o);i.append(r),e.prepend(i);const a=setInterval(()=>{o--,0===o&&(clearInterval(a),i.remove(),t.classList.remove("hidden"),t.classList.add("visible"))},1e3)})}_createSVGIndicator(e){const t=document.createElementNS("http://www.w3.org/2000/svg","svg"),n=document.createElementNS("http://www.w3.org/2000/svg","circle");return n.setAttributeNS(null,"cx","7"),n.setAttributeNS(null,"cy","7"),n.setAttributeNS(null,"r","6"),n.setAttributeNS(null,"style",`animation: countdown ${e}s linear infinite forwards`),t.append(n),t}_changeStopState(){return Qn(this,void 0,void 0,function*(){const e=this._stopStartBtn.getElementsByClassName("grok-icon");e[0].className="grok-icon fas fa-play",this._isStopped=!this._isStopped,this._isStopped||(e[0].className="grok-icon fal fa-pause",this._isStepProcessed||(yield this._startScript()))})}_restartScript(){return Qn(this,void 0,void 0,function*(){r.shell.dockManager.close(this._node),this._clearRoot(),this._setInitParams(),yield this.start()})}_clearRoot(){this._root=s.div([],{id:"demo-script",classes:"tutorials-root tutorials-track demo-app-script"}),this._mainHeader=s.panel([],"tutorials-main-header"),this._header=s.h2(""),this._headerDiv=s.divH([],"tutorials-root-header"),this._activity=s.panel([],"tutorials-root-description"),this._progressDiv=s.divV([],"tutorials-root-progress"),this._progress=s.element("progress"),this._progressSteps=s.divText(""),this._progress.max=0,this._progress.value=1}_setInitParams(){this._currentStep=0,this._isStopped=!1,this._isCancelled=!1,this._stopStartBtn.getElementsByClassName("grok-icon")[0].className="grok-icon fal fa-pause",this._nextStepBtn.classList.remove("disabled")}_closeDock(){r.shell.dockManager.close(this._node),this.cancelScript()}cancelScript(){this._isCancelled=!0,ei.currentObject=null}step(e,t,n){return this._steps[this.steps.length]={name:e,func:t,options:n},this}start(){return Qn(this,void 0,void 0,function*(){this._initRoot(),r.shell.v.name===this.name&&(r.shell.v.close(),this._node=r.shell.dockManager.dock(this._root,a.DOCK_TYPE.FILL,r.shell.dockManager.findNode(r.shell.browsePanel.root),this.name)),this._isAutomatic?yield this._startScript():this._autoStartFirstStep&&(yield this._nextStep())})}}ei.currentObject=null,function(e){e.X="Embed_X",e.Y="Embed_Y"}(Jn||(Jn={}));var ti=n(966),ni=n(608),ii=n(1619);class oi{urlParams;funcName;options;df;view;constructor(e,t,n={}){this.urlParams=e,this.funcName=t,this.options=n}async init(e){this.df=e,await this.buildView()}async buildView(){const e=R()(this.urlParams.entries()).map(([e,t])=>`${e}=${encodeURIComponent(t)}`).toArray().join("&");this.view=r.shell.addTableView(this.df),this.view.path=this.view.basePath=`func/${Dr.name}.${this.funcName}?${e}`;const t={...this.options,sequenceColumnName:"sequence"};for(const[e,n]of this.urlParams.entries())switch(e){case ot.n5.fixWidth:case ot.n5.fitArea:t[e]=(e=>["1","on","true"].includes(e.toLowerCase()))(n);break;default:t[e]=n}const n=await this.view.dataFrame.plot.fromType("WebLogo",t);this.view.dockManager.dock(n,a.DOCK_TYPE.DOWN,null,"WebLogo",.35)}}class ri{tableInput;seqColInput;funcParamsDiv;get funcParams(){return{table:this.tableInput.value,sequence:this.seqColInput.value}}get paramsUI(){return this.funcParamsDiv}constructor(){this.tableInput=s.input.table("Table",{value:r.shell.tv.dataFrame,onValueChanged:()=>{this.onTableInputChanged()}});const e=this.tableInput.value.columns.bySemType(a.SEMTYPE.MACROMOLECULE);this.seqColInput=s.input.column("Sequence",{table:this.tableInput.value,value:e,filter:e=>e.semType===a.SEMTYPE.MACROMOLECULE}),this.funcParamsDiv=s.inputs([this.tableInput,this.seqColInput],{style:{minWidth:"320px"}})}onTableInputChanged(){this.seqColInput=s.input.column("Sequence",{table:this.tableInput.value,value:this.tableInput.value.columns.bySemType(a.SEMTYPE.MACROMOLECULE)})}}var si=n(6869);new class{tooltipHandlerTemp="tooltip-handler.Monomer"};const ai="-";class li extends je{constructor(e,t){super(e,t)}render(e,t,n,i,o,r,s){e.save(),e.beginPath(),e.rect(t,n,i,o),e.clip();try{if(!r.isTableCell)return;const s=r.cell?.column&&r.cell.column?.dart&&"true"===r.cell.column.getTag(ke.Mn.applyToBackground);e.font="12px monospace",e.textBaseline="middle",e.textAlign="left";let a=r.cell.value;a&&a!==ve._S||(a=ai);const l=a.split(ve.ot).map(e=>e&&e!==ve._S?e.trim():ai),c=l.map(e=>(0,me.zS)(e,Math.max(2,Math.floor(.15*i/l.length)))),h=c.map(t=>e.measureText(t).width),u=h.reduce((e,t)=>e+t,0);let d=t+(i-u)/2;const p=this.tableCol.getTag(ve.gp.alphabet),m=p===me.YI.RNA||p===me.YI.DNA?si.o.NUCLEOTIDE:si.o.AA;for(let a=0;a<c.length;a++){const u=l[a],p=this.getHelmType(r,m);let g=He.S$,f="rgb(255, 255, 255)";if(this.monomerLib)if(s){const e=this.monomerLib.getMonomerColors(p,u);g=e?.textcolor??g,f=e?.backgroundcolor??f}else g=this.monomerLib.getMonomerTextColor(p,u);s&&1==l.length&&(e.fillStyle=f,e.fillRect(t,n,i,o)),e.fillStyle=g,e.fillText(c[a],d,n+o/2,i),d+=h[a]}}finally{e.restore()}}onMouseMove(e,t){if(e.grid.dart!=this.gridCol?.grid.dart||e.gridColumn.dart!=this.gridCol?.dart||!e.tableColumn||!e.isTableCell)return!1;const n=e.tableColumn.getTag(ve.gp.alphabet),i=e.cell.value,o=e.grid.canvas.getBoundingClientRect(),r=e.bounds.right+o.left-4,a=e.bounds.bottom+o.top-4;if(!i||i==ve._S||i==ai)return s.tooltip.show(s.divText("gap"),r,a),!0;if(!this.monomerLib)return s.tooltip.show(s.divText("Monomer library is not available."),r,a),!0;const l=n===me.YI.RNA||n===me.YI.DNA?si.o.NUCLEOTIDE:si.o.AA,c=i.split(ve.ot).map(t=>{if(!t||t===ve._S||t===ai)return s.divText("gap");const n=this.getHelmType(e,l);return this.monomerLib.getTooltip(n,t)}),h=s.divH(c,{style:{alignItems:"top"}}),u=Array.from(h.querySelectorAll("canvas"));if(u.length>2){const e=Math.floor(550/u.length);u.forEach(t=>{t.style.setProperty("max-width",`${e}px`,"important"),t.style.setProperty("max-height",`${e}px`,"important")})}return s.tooltip.show(h,r,a),!0}getHelmType(e,t){let n=t;if((e.tableRowIndex??-1)>-1&&e.tableColumn?.getTag(ve.qE.polymerTypeColumnName)){const t=e.tableColumn.getTag(ve.qE.polymerTypeColumnName),i=e.tableColumn.dataFrame?.col(t);if(i){const t=i.get(e.tableRowIndex);t&&["BLOB","CHEM","G","PEPTIDE","RNA"].includes(t)&&(n=(0,Fe.MD)(t))}}return n}async awaitRendered(e=1e4,t=`${e} timeout`){return Promise.resolve()}static getOrCreate(e){const[t,n,i]=(0,Be.BG)(e);let o=i.rendererBack;return o||(o=i.rendererBack=new li(t,n)),o}}class ci extends a.GridCellRenderer{get name(){return Ue.uF.MONOMER}get cellType(){return Ue.uF.MONOMER}get defaultHeight(){return 15}get defaultWidth(){return 40}render(e,t,n,i,o,r,s){li.getOrCreate(r).render(e,t,n,i,o,r,s)}onMouseMove(e,t){li.getOrCreate(e).onMouseMove(e,t),t.preventDefault()}}class hi{constructor(e,t,n=""){this.target=e,this.debugEnabled=t,this.prefix=n}error(e,t,n){return this.target.error(this.prefix+e,t,n)}warning(e,t){return this.target.warning(this.prefix+e,t)}info(e,t){return this.target.info(this.prefix+e,t)}debug(e,t){if(this.debugEnabled)return this.target.debug(this.prefix+e,t)}}class ui extends Map{_onPropertyChanged=new h.Subject;get onPropertyChanged(){return this._onPropertyChanged}get fontSize(){const e=super.get("FontSize");return e&&!isNaN(e)?Number.parseInt(e):12}set fontSize(e){super.set("FontSize",e),this._onPropertyChanged.next("FontSize")}get maxMonomerLength(){const e=super.get("MaxMonomerLength");return"long"===e?null:parseInt(e)}set maxMonomerLength(e){const t=null==e?"long":e.toString();super.set("MaxMonomerLength",t),this._onPropertyChanged.next("MaxMonomerLength")}get tooltipWebLogo(){return super.get("TooltipWebLogo")}set tooltipWebLogo(e){super.set("TooltipWebLogo",e),this._onPropertyChanged.next("TooltipWebLogo")}get defaultSeparator(){return super.get("DefaultSeparator")}set defaultSeparator(e){if(1!==e.length)throw new Error("The separator must be of length one.");super.set("DefaultSeparator",e),this._onPropertyChanged.next("DefaultSeparator")}constructor(e){super(Object.entries(e))}}class di extends a.Package{_properties;_seqHelper;get seqHelper(){if(!this._seqHelper)throw new Error("Package Bio .seqHelper is not initialized.");return this._seqHelper}_monomerLib;get monomerLib(){if(!this._monomerLib)throw new Error("Package Bio .monomerLib is not initialized.");return this._monomerLib}_monomerSets;get monomerSets(){if(!this._monomerSets)throw new Error("Package Bio .monomerSets is not initialized.");return this._monomerSets}_rdKitModule;get rdKitModule(){if(!this._rdKitModule)throw new Error("Package Bio .rdKitModule is not initialized.");return this._rdKitModule}get properties(){return this._properties}set properties(e){this._properties=e}_initialized=!1;get initialized(){return this._initialized}constructor(e={debug:!1}){super(),super._logger=new hi(super.logger,e.debug)}completeInit(e,t,n,i){this._seqHelper=e,this._monomerLib=t,this._monomerSets=n,this._rdKitModule=i,this._initialized=!0}handleErrorUI(e){const[t,n]=(0,Se.AP)(e);r.shell.error(t),this.logger.error(t,void 0,n)}}var pi=n(6307),mi=n(5999),gi={};gi.styleTagTransform=S(),gi.setAttributes=b(),gi.insert=f().bind(null,"head"),gi.domAPI=m(),gi.insertStyleElement=w(),d()(mi.A,gi),mi.A&&mi.A.locals&&mi.A.locals;class fi extends a.Widget{seqCol;seqHelper;get type(){return"MacromoleculeColumnWidget"}viewed=!1;wlViewer=null;constructor(e,t){super(s.divV([])),this.seqCol=e,this.seqHelper=t}async init(){const e=this.seqHelper.getSeqHandler(this.seqCol),t=Dr.properties.tooltipWebLogo,n=this.seqCol.getTag(tt.gp.tooltipWebLogo);!1===t||["false","off","disable","disabled"].includes(n)||(this.wlViewer=await this.seqCol.dataFrame.plot.fromType("WebLogo",{sequenceColumnName:this.seqCol.name,backgroundColor:0,positionHeight:"Entropy",positionWidth:e.getAlphabetIsMultichar()?24:16,fixWidth:!0,fitArea:!1,positionNames:"",endPositionName:"50"}),this.wlViewer.root.style.height="50px",this.root.appendChild(this.wlViewer.root),this.root.style.width="100%")}detach(){this.wlViewer&&(this.wlViewer.detach(),this.wlViewer=null),super.detach()}}function yi(e,t,n,i){const o=Dr.seqHelper.getSeqHandler(e);let r=null,s=null;for(let e=0;e<o.posList.length;++e)o.posList[e]==t&&(r=e),o.posList[e]==n&&(s=e);if(null==r&&null!==t)throw new Error(`Start position ${t} not found.`);if(null==s&&null!==n)throw new Error(`End position ${n} not found.`);if(o.posList.length<s)throw new Error(`End position ${s} exceeds positions length`);const a=i||`${e.name}: (${t??""}-${n??""})`;return o.getRegion(r,s,a)}const bi={df:a.DataFrame.fromCsv("seq,value\nATCCGTCGT,0.5\nTGTTCGTCA,0.4\nATGGTCGTA,0.7\nATCCGTGCA,0.1"),colName:"seq",positionNames:["1","1A","1C","2","4","4A","4B","5","6"].join(me.z1),regions:[{name:"first region",start:"1",end:"2"},{name:"second region",start:"1C",end:"4"},{name:"overlapping second",start:"1C",end:"4A"},{name:"whole sequence",start:"1",end:"6"},{name:"bad start",start:"0",end:"6"},{name:"bad end",start:"1",end:"4C"},{name:"bad start & end",start:"0",end:"4C"}]};class vi{urlParams;funcName;view;data;constructor(e,t){this.urlParams=e,this.funcName=t}async init(e){this.data=e??bi;const t=this.data.df.getCol(this.data.colName);this.data.positionNames&&t.setTag(me.gp.positionNames,this.data.positionNames),this.data.regions&&t.setTag(me.gp.regions,JSON.stringify(this.data.regions)),await this.buildView()}async buildView(){await r.data.detectSemanticTypes(this.data.df),this.view=r.shell.addTableView(this.data.df),this.view.path=this.view.basePath=`func/${Dr.name}.${this.funcName}`;const e=await this.view.dataFrame.plot.fromType("WebLogo",{sequenceColumnName:this.data.colName});this.view.dockManager.dock(e,a.DOCK_TYPE.DOWN,null,"WebLogo",.35)}}class wi{call;seqHelper;inputs=new class{table;sequence;region;start;end;name};constructor(e,t){this.call=e,this.seqHelper=t;const n=e=>this.call.inputParams[e].property.description;this.inputs.table=s.input.table("Table",{value:this.call.inputParams.table.value??r.shell.tv.dataFrame});const i=this.call.inputParams.sequence.value??this.inputs.table.value.columns.bySemType(a.SEMTYPE.MACROMOLECULE);this.inputs.sequence=s.input.column("Sequence",{table:r.shell.tv.dataFrame,value:i,onValueChanged:this.sequenceInputChanged.bind(this),filter:e=>e.semType===a.SEMTYPE.MACROMOLECULE}),this.inputs.start=s.input.choice("Start",{onValueChanged:this.startInputChanged.bind(this)}),this.inputs.end=s.input.choice("End",{onValueChanged:this.endInputChanged.bind(this)}),this.inputs.region=s.input.choice("Region",{value:null,items:[],onValueChanged:this.regionInputChanged.bind(this)}),this.inputs.name=s.input.string("Column name",{value:this.getDefaultName(),onValueChanged:this.nameInputChanged.bind(this),clearIcon:!0}),this.inputs.name.onInput.subscribe(()=>this.nameInputInput.bind(this));for(const e in this.call.inputParams)s.tooltip.bind(this.inputs[e].captionLabel,n(e));this.sequenceInputChanged()}sequenceInputChanged(){const e=this.inputs.sequence.value;e&&this.seqHelper.getSeqHandler(e),this.updateRegionItems(),this.updateStartEndInputItems(),this.updateRegion(!0),this.updateNameInput()}fixRegion=!1;regionInputChanged(){this.fixRegion=!0;try{const e=this.inputs.region.stringValue,t=e?JSON.parse(e):null;if(null!==t)this.inputs.start.value=t?.start,this.inputs.end.value=t?.end;else{const e=this.seqHelper.getSeqHandler(this.inputs.sequence.value);this.inputs.start.value=e.posList[0],this.inputs.end.value=e.posList[e.posList.length-1]}}finally{this.fixRegion=!1}}startInputChanged(){this.updateRegion(!1),this.updateNameInput()}endInputChanged(){this.updateRegion(!1),this.updateNameInput()}nameInputChanged(){this.defaultNameUpdating||(this.defaultName=!1)}nameInputInput(){this.inputs.name.value||(this.defaultName=!0,this.inputs.name.input.focus())}updateStartEndInputItems(){const e=this.inputs.sequence.value,t=e?this.seqHelper.getSeqHandler(e):null,n=this.inputs.start.input,i=this.inputs.end.input;for(let e=n.options.length-1;e>=0;--e)n.options.remove(e);for(let e=i.options.length-1;e>=0;--e)i.options.remove(e);for(const e of t?.posList??[]){const t=document.createElement("option"),o=document.createElement("option");t.text=o.text=e,t.value=o.value=e,n.options.add(t),i.options.add(o)}n.value=t?.posList[0]??"",i.value=t?.posList[t?.posList.length-1]??""}updateRegionItems(){const e=this.inputs.sequence.value,t=e?e.getTag(me.gp.regions):null,n=t?JSON.parse(t):null,i=this.inputs.region.input;for(let e=i.options.length-1;e>=0;--e)i.options.remove(e);const o=document.createElement("option");if(o.text="",o.value=JSON.stringify(null),i.options.add(o),null!=n){this.inputs.region.root.style.removeProperty("display");for(const e of n){const t=document.createElement("option");t.text=`${e.name}: ${e.start}-${e.end}`,t.value=JSON.stringify(e),i.options.add(t)}}else this.inputs.region.root.style.display="none"}updateRegion(e){const t=this.inputs.start.stringValue??"",n=this.inputs.end.stringValue??"";if(!this.fixRegion){const e=this.inputs.region.input;e.selectedIndex=-1;for(let i=e.options.length-1;i>=0;--i){const o=e.options[i],r=JSON.parse(o.value);r&&t===r.start&&n===r.end&&(e.selectedIndex=i)}}}defaultName=!0;defaultNameUpdating=!1;updateNameInput(){this.defaultNameUpdating=!0;try{this.defaultName&&(this.inputs.name.value=this.getDefaultName())}finally{this.defaultNameUpdating=!1}}getDefaultName(){const e=this.inputs.region.stringValue,t=e?JSON.parse(e):null,n=this.inputs.sequence.value,i=this.inputs.start.stringValue??"",o=this.inputs.end.stringValue??"";return null!=t?`${n.name}(${t.name}): ${t.start}-${t.end}`:`${n?.name}: (${i}-${o})`}getParams(){return{table:this.inputs.table.value,sequence:this.inputs.sequence.value,start:this.getStart(),end:this.getEnd(),name:this.getName()}}getStart(){return this.inputs.start.stringValue}getEnd(){return this.inputs.end.stringValue}getName(){const e=this.inputs.name.stringValue;return""==e?null:e}dialog(){const e=s.inputs(Object.values(this.inputs),{style:{minWidth:"320px"}});s.dialog({title:"Get Region"}).add(e).onOK(()=>{(async()=>{const e=this.getParams();await this.call.func.prepare(e).call(!0)})().catch(e=>{Dr.handleErrorUI(e)})}).show()}widget(){const e=s.inputs(Object.entries(this.inputs).filter(([e,t])=>!["table","sequence"].includes(e)).map(([e,t])=>t)),t=s.button("Get Region",()=>{(async()=>{const e=this.getParams();await this.call.func.prepare(e).call(!0)})().catch(e=>{Dr.handleErrorUI(e)})});return a.Widget.fromRoot(s.divV([e,s.div(t)]))}}var Ci=n(8754);async function Si(e,t,n,i,o){const s=await async function(e,t,n,i,o){const s=ye(t,o),l=o.getSeqHandler(t).getNewColumnFromList("ref",[n]),c=o.getSeqHandler(l).getSplitted(0),h=i===be.IDENTITY?function(e,t){const n=t.columns.length,i=new Array(n),o=new Array(n),r=new Array(n);for(let s=0;s<n;++s){const n=t.columns.byIndex(s);i[s]=n.getRawData(),o[s]=n.categories.indexOf("");const a=s<e.length?e.getOriginal(s):ve._S;r[s]=n.categories.indexOf(a)}const s=a.Column.float("Identity",t.rowCount),l=s.getRawData();for(let n=0;n<t.rowCount;++n){l[n]=0;for(let t=0;t<e.length;++t)(i[t]?i[t][n]:0)===r[t]&&++l[n];l[n]/=e.length}return s}(c,s):i===be.SIMILARITY?await async function(e,t,n){const i=t.columns.toList(),o=await async function(e,t,n){e instanceof a.Column&&(e=ye(e,n).columns.toList());const i=(await(0,we.pj)()).getMonomerLib(),o=new Array(e.length),s=e[0].length,l=new Float32Array(s);for(let n=0;n<e.length;++n){const c=n<t.length?t.getCanonical(n):ve._S,h=i.getMonomer("PEPTIDE",c)?.smiles??"",u=e[n],d=u.getRawData(),p=u.categories,m=p.indexOf("");if(o[n]={categories:p,data:d,emptyIndex:m},void 0===c)continue;const g=a.Column.fromStrings("smiles",p.map(e=>i.getMonomer("PEPTIDE",e)?.smiles??"")),f=(a.DataFrame.fromColumns([g]),await r.chem.getSimilarities(g,h)),y=f?f.getRawData():null;for(let e=0;e<s;++e){const t=d[e];c!==ve._S&&t!==m?l[e]+=y[t]:c===ve._S&&t===m&&(l[e]+=1)}}for(let n=0;n<l.length;++n){let i=l[n]/t.length;for(let r=0;r<e.length;++r){const e=o[r];if(r>=t.length&&e.data[n]!==e.emptyIndex||e.data[n]===e.emptyIndex&&r<t.length){i=a.FLOAT_NULL;break}}l[n]=i}return a.Column.fromFloat32Array("Similarity",l)}(i,e,n);return o}(c,s,o):null;if(null===h)throw new Error(`In bio library: Unknown sequence scoring method: ${i}`);return h.name=e.columns.getUnusedName(h.name),e.columns.add(h),h}(e,t,n,i,o);for(let e=0;e<s.length;e++)t.isNone(e)&&s.set(e,null,!1);return s}var Ai=n(294),xi=n(330);const Ei=OCL;var Mi=n(2582);class Ti{monomerSymbol;constructor(e){this.monomerSymbol=e}atoms;bonds;rGroups;get atomCount(){return this.atoms.count}get bondCount(){return this.bonds.count}shiftR1GroupToOrigin(){const e=this.rGroups.getAtomicIdx(1);if(null==e)return;const{x:t,y:n}=this.atoms.atomCoordinates[e];this.atoms.shift({x:-t,y:-n})}alignR2AlongX(){const e=this.rGroups.getAtomicIdx(2);if(null==e)throw new Error(`Cannot find R2 group for monomer ${this.monomerSymbol}`);const t=this.atoms.atomCoordinates[e],n=t.y/t.x,i=Math.atan(n);if(isNaN(i))throw new Error(`Cannot calculate angle for R2 group for monomer ${this.monomerSymbol}`);this.rotateCoordinates(-i)}shiftMonomerToDefaultPosition(){this.shiftR1GroupToOrigin(),null!==this.rGroups.getAtomicIdx(2)&&this.alignR2AlongX()}deleteBondLineWithSpecifiedRGroup(e){this.rGroups.deleteBondLineWithSpecifiedRGroup(e)}shiftCoordinates(e){this.atoms.shift(e)}rotateCoordinates(e){this.atoms.rotate(e)}getBondLines(){return this.bonds.getBondLines()}getAtomLines(){return this.atoms.atomLines}removeRGroups(e){this.rGroups.removeRGroups(e)}replaceRGroupWithAttachmentAtom(e,t){this.rGroups.replaceRGroupWithAttachmentAtom(e,t)}getAttachmentAtomByRGroupId(e){return this.rGroups.getAttachmentAtomIdByRGroupId(e)}shiftBonds(e){this.bonds.shift(e)}capRGroups(e){this.rGroups.capRGroups(e)}}var _i=n(6956);class Ii{atoms;bonds;constructor(e,t,n){this.atoms=t,this.bonds=n,this.rGroupIdToAtomicIndexMap=e.getRGroupIdToAtomicIdxMap()}rGroupIdToAtomicIndexMap;rGroupBondPositionMap=new Map;getAtomicIdx(e){const t=this.rGroupIdToAtomicIndexMap.get(e);return null==t?null:t}removeRGroupsFromAtomBlock(e){e.forEach(e=>{if(null==this.rGroupIdToAtomicIndexMap.get(e))throw new Error(`Cannot find atomic index for R group ${e}`)});const t=Array.from(this.rGroupIdToAtomicIndexMap.entries()).filter(([t,n])=>e.includes(t)).map(([e,t])=>t);this.atoms.deleteAtoms(t)}removeRGroups(e){this.removeRGroupsFromAtomBlock(e),e.forEach(e=>{const t=this.replaceRGroupInBondsByDummy(e);this.rGroupBondPositionMap.set(e,t)})}replaceRGroupInBondsByDummy(e){const t=this.rGroupIdToAtomicIndexMap.get(e);if(this.rGroupBondPositionMap.has(e))throw new Error(`R group ${e} is already handled`);const n=this.bonds.getPositionsInBonds(t+1);if(0===n.length)throw new Error(`Cannot find position for R group ${e}`);if(n.length>1)throw new Error(`More than one position for R group ${e}`);const i=n[0];return this.bonds.replacePositionsInBondsByDummy([i]),this.bonds.removeAtomIdFromBonds(t+1),this.removeRGroupFromAtomicIdxMap(e,t),i}removeRGroupFromAtomicIdxMap(e,t){this.rGroupIdToAtomicIndexMap.delete(e);for(const[e,n]of this.rGroupIdToAtomicIndexMap)n>t&&this.rGroupIdToAtomicIndexMap.set(e,n-1)}deleteBondLineWithSpecifiedRGroup(e){const t=this.rGroupBondPositionMap.get(e);if(!t)throw new Error(`Cannot find position for R group ${e}`);const{bondLineIdx:n}=t;this.bonds.deleteBondLines([n]),this.rGroupBondPositionMap.delete(e),this.rGroupIdToAtomicIndexMap.delete(e),this.rGroupBondPositionMap.forEach(e=>{e.bondLineIdx>n&&(e.bondLineIdx-=1)})}replaceRGroupWithAttachmentAtom(e,t){const n=this.rGroupBondPositionMap.get(e);if(!n)throw new Error(`Cannot find position for R group ${e}`);const{bondLineIdx:i,nodeIdx:o}=n;this.bonds.bondedAtoms[i][o]=t}getAttachmentAtomIdByRGroupId(e){const t=this.rGroupBondPositionMap.get(e);if(!t)throw new Error(`Cannot find position for R group ${e}`);const{bondLineIdx:n,nodeIdx:i}=t;return this.bonds.bondedAtoms[n][(i+1)%2]}capRGroups(e){this.rGroupIdToAtomicIndexMap.forEach((t,n)=>{const i=e[n-1];i===_i.m?(this.removeRGroups([n]),this.deleteBondLineWithSpecifiedRGroup(n)):this.atoms.replaceRGroupSymbolByElement(t,i)})}}class Li{coordinates=[];rawAtomLines=[];get count(){return this.coordinates.length}get atomCoordinates(){return this.coordinates}replaceRGroupSymbolByElement(e,t){this.rawAtomLines[e]=this.rawAtomLines[e].replace("R#",t)}deleteAtoms(e){this.coordinates=this.coordinates.filter((t,n)=>!e.includes(n)),this.rawAtomLines=this.rawAtomLines.filter((t,n)=>!e.includes(n))}shift(e){this.coordinates=this.coordinates.map(t=>{const n=t.x+e.x,i=t.y+e.y;if(isNaN(n)||isNaN(i))throw new Error(`Cannot shift coordinates by ${e.x}, ${e.y}`);return{x:n,y:i}})}rotate(e){this.coordinates=this.coordinates.map(t=>{const n=t.x,i=t.y,o=n*Math.cos(e)-i*Math.sin(e),r=n*Math.sin(e)+i*Math.cos(e);if(isNaN(o)||isNaN(r))throw new Error(`Cannot rotate coordinates by ${e}`);return{x:o,y:r}})}}class Ni extends Li{constructor(e){super(),this.rawAtomLines=e.getAtomLines(),this.coordinates=this.rawAtomLines.map(e=>({x:parseFloat(e.substring(0,10)),y:parseFloat(e.substring(10,20))}))}get atomLines(){return this.rawAtomLines.map((e,t)=>{const n=this.coordinates[t];return`${n.x.toFixed(4).padStart(10," ")}${n.y.toFixed(4).padStart(10," ")}${e.substring(20)}`})}}class Pi{bondedAtomPairs=[];rawBondLines=[];get count(){return this.bondedAtomPairs.length}get bondedAtoms(){return this.bondedAtomPairs}deleteBondLines(e){this.rawBondLines=this.rawBondLines.filter((t,n)=>!e.includes(n)),this.bondedAtomPairs=this.bondedAtomPairs.filter((t,n)=>!e.includes(n))}getPositionsInBonds(e){const t=[];return this.bondedAtomPairs.forEach((n,i)=>{n.forEach((n,o)=>{n===e&&t.push({bondLineIdx:i,nodeIdx:o})})}),t}replacePositionsInBondsByDummy(e,t){null==t&&(t=-1),e.forEach(e=>{const{bondLineIdx:n,nodeIdx:i}=e;this.bondedAtomPairs[n][i]=t})}removeAtomIdFromBonds(e){this.bondedAtomPairs=this.bondedAtomPairs.map(t=>t.map(t=>t>e?t-1:t))}shift(e){this.bondedAtomPairs=this.bondedAtomPairs.map(t=>t.map(t=>t+e))}}class Ri extends Pi{constructor(e){super(),this.rawBondLines=e.getBondLines(),this.bondedAtomPairs=this.rawBondLines.map(e=>[parseInt(e.substring(0,3)),parseInt(e.substring(3,6))])}getBondLines(){return this.bondedAtomPairs.map((e,t)=>{if(e.some(e=>-1===e))throw new Error(`Bonded pair ${e} contains -1`);return`${e[0].toString().padStart(3," ")}${e[1].toString().padStart(3," ")}${this.rawBondLines[t].substring(6)}`})}}class $i extends Ti{constructor(e,t){super(t);const n=$t.getInstance(e);this.atoms=new Ni(n),this.bonds=new Ri(n),this.rGroups=new Ii(n,this.atoms,this.bonds),this.shiftMonomerToDefaultPosition()}}class Oi extends Li{molfileHandler;constructor(e){super(),this.molfileHandler=e,this.rawAtomLines=e.getAtomLines(),this.coordinates=this.getCoordinates()}getCoordinates(){const e=this.molfileHandler.x,t=this.molfileHandler.y;return Array.from(e).map((e,n)=>({x:e,y:t[n]}))}get atomLines(){const e=/^(M V30 [^-]*)(-?\d+\.\d+)( )(-?\d+\.\d+)( -?\d+\.\d+.*)$/,t=/\sRGROUPS=\(\d+(\s+\d+)*\)/;return this.rawAtomLines.map((n,i)=>{const o=this.coordinates[i],r=o.x.toFixed(4)+"00",s=o.y.toFixed(4)+"00";return n.replace(e,(e,t,n,i,o,a)=>t+r+i+s+a).replace(t,"")})}replaceRGroupSymbolByElement(e,t){super.replaceRGroupSymbolByElement(e,t);const n=this.rawAtomLines[e].substring(3).split(" ");n.length>7&&(this.rawAtomLines[e]=`M ${n.slice(0,7).join(" ")}`)}}class ki extends Pi{molfileHandler;constructor(e){super(),this.molfileHandler=e,this.rawBondLines=e.getBondLines(),this.bondedAtomPairs=this.getBondedAtomPairs()}getBondedAtomPairs(){return this.molfileHandler.pairsOfBondedAtoms.map(e=>[e[0],e[1]])}getBondLines(){const e=/^(M\s+V30\s+\d+\s+\d+\s+)(\d+)(\s+)(\d+)(.*)$/;return this.bondedAtomPairs.map((t,n)=>{if(t.some(e=>-1===e))throw new Error(`Bonded pair ${t} contains -1`);return this.rawBondLines[n].replace(e,(e,n,i,o,r,s)=>`${n}${t[0]}${o}${t[1]}${s}`)})}}class Hi extends Ti{constructor(e,t){super(t);const n=$t.getInstance(e);this.atoms=new Oi(n),this.bonds=new ki(n),this.rGroups=new Ii(n,this.atoms,this.bonds),this.shiftMonomerToDefaultPosition()}}class Fi{static getInstance(e,t){if($t.isMolfileV2K(e))return new $i(e,t);if($t.isMolfileV3K(e))return new Hi(e,t);throw new Error("Unsupported molfile version")}}class Gi{monomerSymbol;monomerIdx;helm;monomerLib;molfileWrapper;capGroupElements=[];static molfileV2KToV3KCache=new Map;constructor(e,t,n,i,o,r){this.monomerSymbol=e,this.monomerIdx=t,this.helm=n,this.monomerLib=r;const s=this.getLibraryMonomerObject();let a=s.molfile;$t.isMolfileV2K(a)&&(a=this.convertMolfileToV3KFormat(a,e,o)),this.molfileWrapper=Fi.getInstance(a,e),this.capGroupElements=this.getCapGroupElements(s),this.removeRGroups(n.bondedRGroupsMap[t]),this.capRemainingRGroups(),this.shiftCoordinates(i)}get atomCount(){return this.molfileWrapper.atomCount}get bondCount(){return this.molfileWrapper.bondCount}convertMolfileToV3KFormat(e,t,n){if(Gi.molfileV2KToV3KCache.has(e))return Gi.molfileV2KToV3KCache.get(e);let i=null;try{if(i=n.get_mol(e,JSON.stringify({mergeQueryHs:!0})),i){const t=i.get_v3Kmolblock();return Gi.molfileV2KToV3KCache.set(e,t),t}throw new Error(`Cannot convert ${t} to molV3000`)}finally{i?.delete()}}getLibraryMonomerObject(){const e=this.helm.getPolymerTypeByMonomerIdx(this.monomerIdx),t=this.monomerLib.getMonomer(e,this.monomerSymbol);if(!t)throw new Error(`Monomer ${this.monomerSymbol} is not found in the library`);return t}getCapGroupElements(e){return e.rgroups.map(e=>(e.capGroupSmiles||e.capGroupSMILES).replace(/(\[|\]|\*|:|\d)/g,""))}shiftCoordinates(e){this.molfileWrapper.shiftCoordinates(e)}getAtomLines(){return this.molfileWrapper.getAtomLines()}getBondLines(){return this.molfileWrapper.getBondLines()}removeRGroups(e){this.molfileWrapper.removeRGroups(e)}capRemainingRGroups(){this.molfileWrapper.capRGroups(this.capGroupElements)}replaceRGroupWithAttachmentAtom(e,t){this.molfileWrapper.replaceRGroupWithAttachmentAtom(e,t)}getAttachmentAtomByRGroupId(e){return this.molfileWrapper.getAttachmentAtomByRGroupId(e)}deleteBondLineWithSpecifiedRGroup(e){this.molfileWrapper.deleteBondLineWithSpecifiedRGroup(e)}shiftBonds(e){this.molfileWrapper.shiftBonds(e)}}class Bi{rdKitModule;monomerLib;constructor(e,t,n){this.rdKitModule=t,this.monomerLib=n,this.helm=new Mi.f(e)}monomerWrappers=[];helm;addMonomer(e,t,n){if(e===ve.b9[me.Hi.HELM])return;const i=this.monomerWrappers.length,o=new Gi(e,i,this.helm,n,this.rdKitModule,this.monomerLib);this.monomerWrappers.push(o)}getAtomNumberShifts(){const e=[];let t=0;return this.monomerWrappers.forEach(n=>{e.push(t),t+=n.getAtomLines().length}),e}restoreBondsBetweenMonomers(){this.helm.bondData.forEach(e=>{const t=e.map(e=>e.monomerIdx),n=e.map(e=>e.rGroupId),i=t.map(e=>this.monomerWrappers[e]),o=i[1].getAttachmentAtomByRGroupId(n[1]);i[0].replaceRGroupWithAttachmentAtom(n[0],o),i[1].deleteBondLineWithSpecifiedRGroup(n[1])})}compileToMolfile(){const e=[],t=[],n=this.getAtomNumberShifts();this.monomerWrappers.forEach((e,t)=>{e.shiftBonds(n[t])}),this.restoreBondsBetweenMonomers();const i=new Ai.Cg;for(const[n,o]of R().enumerate(this.monomerWrappers)){const r=e.length,s=t.length;e.push(...n.getAtomLines()),t.push(...n.getBondLines());const a="RNA"==this.helm.getPolymerTypeByMonomerIdx(o)?De.o.NUCLEOTIDE:De.o.AA;i.set(o,{biotype:a,symbol:n.monomerSymbol,atoms:R().count(r).take(n.atomCount).toArray(),bonds:R().count(s).take(n.bondCount).toArray()})}const o=e.length,r=t.length;return{molfile:[this.getV3KHeader(o,r),this.getV3KAtomBlock(e),this.getV3KBondBlock(t),"M V30 END CTAB\nM END"].join("\n"),monomers:i}}getV3KHeader(e,t){return`\n Datagrok\n\n 0 0 0 0 0 0 0 0 0 0999 V3000\nM V30 BEGIN CTAB\nM V30 COUNTS ${e} ${t} 0 0 1`}getV3KAtomBlock(e){const t=/^(M V30 )(\d+)( .*)$/;return["M V30 BEGIN ATOM",...e.map((e,n)=>{const i=n+1;return e.replace(t,(e,t,n,o)=>t+i+o)}),"M V30 END ATOM"].join("\n")}getV3KBondBlock(e){const t=/^(M V30 )(\d+)( .*)$/;return["M V30 BEGIN BOND",...e.map((e,n)=>{const i=n+1;return e.replace(t,(e,t,n,o)=>t+i+o)}),"M V30 END BOND"].join("\n")}}class Di{constructor(e){this.molfileHandler=$t.getInstance(e)}molfileHandler;get monomerSymbols(){return this.molfileHandler.atomTypes}getMonomerShifts(e){return{x:this.molfileHandler.x[e],y:this.molfileHandler.y[e]}}}class Vi{helmHelper;rdKitModule;monomerLib;constructor(e,t,n){this.helmHelper=e,this.rdKitModule=t,this.monomerLib=n}convertToSmiles(e){const t=e.dataFrame,n=this.getSmilesList(e),i=`smiles(${e.name})`,o=t?t.columns.getUnusedName(i):i;return a.Column.fromStrings(o,n.map(e=>null==e?"":e))}getSmilesList(e){return this.convertToMolfileV3KColumn(e).toList().map(e=>a.chem.convert(e,a.chem.Notation.MolBlock,a.chem.Notation.Smiles))}molV3KtoMolV3KOCL(e){try{if(!e)return"";return Ei.Molecule.fromMolfile(e).toMolfileV3().replace("STERAC1","STEABS")}catch(e){const[t,n]=(0,Se.AP)(e);return Dr.logger.error(t,void 0,n),""}}getMolV3000ViaOCL(e,t){const n=e.map(e=>{if(null==e)return"";const t=e.get_v3Kmolblock();return e.delete(),t}),i=new Array(n.length),o=a.TaskBarProgressIndicator.create("Handling chirality...");for(let e=0;e<n.length;e++){i[e]=this.molV3KtoMolV3KOCL(n[e]);const t=e/n.length*100;o.update(t,`${t?.toFixed(2)}% of molecules completed`)}return o.close(),a.Column.fromStrings(t,i)}convertToRdKitBeautifiedMolfileColumn(e,t,n,i){const o=e.dataFrame,r=this.convertToMolfileV3KColumn(e).toList().map(e=>{if(""===e)return null;const t=n.get_mol(e);return t?(t.set_new_coords(),t.normalize_depiction(1),t.straighten_depiction(!0),t):null}),s=`molfile(${e.name})`,l=o?o.columns.getUnusedName(s):s;return t?this.getMolV3000ViaOCL(r,l):a.Column.fromStrings(l,r.map(e=>{if(null==e)return"";const t=e.get_v3Kmolblock();return e.delete(),t}))}convertToMolfileV3KColumn(e){const t=e.dataFrame,n=this.convertToMolfileV3K(e.toList()).map(e=>e.molfile),i=(0,xi.kA)(t,`molfileV3K(${e.name})`);return a.Column.fromList("string",i,n)}convertToMolfileV3K(e){const t=new Array(e.length);for(let n=0;n<e.length;++n){const i=e[n];if(!i){t[n]=Ai.vF.createEmpty();continue}let o;try{o=this.getPolymerMolfile(i)}catch(e){const[t,n]=(0,Se.AP)(e);Dr.logger.error(t,void 0,n),o=Ai.vF.createEmpty()}t[n]=o}return t}getPolymerGraphColumn(e){const t=e.toList(),n=this.helmHelper.getMolfiles(t);return a.Column.fromStrings("mols",n)}getPolymerMolfile(e){const t=this.helmHelper.removeGaps(e),n=t.resHelm,i=new Map;for(const[e,n]of t.monomerMap?.entries()??[])i.set(n,e);const o=this.helmHelper.getMolfiles([n])[0],r=new Di(o),s=new Bi(n,this.rdKitModule,this.monomerLib);r.monomerSymbols.forEach((e,t)=>{const n=r.getMonomerShifts(t);s.addMonomer(e,t,n)});const a=s.compileToMolfile(),l=new Ai.Cg;for(const[e,t]of a.monomers.entries()){const n=i.get(e);l.set(n,t)}return new Ai.vF(a.molfile,l)}}var Wi=n(2738);class ji{seqHelper;_column;_units;_notation;_defaultGapOriginal;_notationProvider=null;_tempReadForNotProvider=!1;get notationProvider(){return this._tempReadForNotProvider||(this._tempReadForNotProvider=!0,this._notationProvider=this._notationProvider??this._column.temp[$e.j.notationProvider]??null),this._notationProvider}set notationProvider(e){this._notationProvider=e}_splitter=null;_refinerPromise=Promise.resolve();get refinerPromise(){return this._refinerPromise}constructor(e,t){if(this.seqHelper=t,e.type!==a.TYPE.STRING)throw new Error(`Unexpected column type '${e.type}', must be '${a.TYPE.STRING}'.`);this._column=e;const n=this._column.meta.units;if(!n)throw new Error("Units are not specified in column");this._units=n,this._notation=this.getNotation(),(this.isCustom()||this.isBiln())&&(this.notationProvider=this.column.temp[$e.j.notationProvider]??null);const i=this.isFasta()?ve.b9[me.Hi.FASTA]:this.isSeparator()?ve.b9[me.Hi.SEPARATOR]:this.isHelm()?ve.b9[me.Hi.HELM]:this.isCustom()||this.isBiln()?this.notationProvider?.defaultGapOriginal??ve.b9[me.Hi.SEPARATOR]:void 0;if(null==i)throw new Error(`Unexpected defaultGapOriginal for notation '${this.notation}'`);if(this._defaultGapOriginal=i,!this.column.tags.has(me.gp.aligned)||!this.column.tags.has(me.gp.alphabet)||!this.column.tags.has(me.gp.alphabetIsMultichar)&&!this.isHelm()&&this.alphabet===me.YI.UN)if(this.isFasta())this.seqHelper.setUnitsToFastaColumn(this);else if(this.isSeparator()){const t=e.getTag(me.gp.separator);this.seqHelper.setUnitsToSeparatorColumn(this,t)}else if(this.isHelm())this.seqHelper.setUnitsToHelmColumn(this);else{if(!this.isCustom()&&!this.isBiln())throw new Error(`Unexpected units '${this.column.meta.units}'.`);this.notationProvider?.setUnits(this)}if(!this.column.tags.has(me.gp.alphabetIsMultichar))if(this.isHelm())this.column.setTag(me.gp.alphabetIsMultichar,"true");else if(["UN"].includes(this.alphabet))throw new Error(`For column '${this.column.name}' of alphabet '${this.alphabet}' tag '${me.gp.alphabetIsMultichar}' is mandatory.`);this.columnVersion=this.column.version,!this.isSeparator()||(this.isCustom()||this.isBiln())&&this.notationProvider||e.temp.seqHandlerRefined||(this._refinerPromise=this.refineSeparatorNotation(),e.temp.seqHandlerRefined=!0)}async refineSeparatorNotation(){const e=((e,t,n)=>{const i={};let o=!0,r=null;for(const t of e){const e=t?n(t):[];if(null==r?r=e.length:e.length!==r&&(o=!1),e.length>=3)for(const t of e)t in i||(i[t]=0),i[t]+=1}return{freq:i,sameLength:o}})([...new Set((this.column.length<100?R().count(0).take(Math.min(100,this.column.length)).map(e=>this.column.get(e)):this.column.categories.slice(0,100)).map(e=>e?e.substring(0,500):"").filter(e=>0!==e.length))],0,e=>e.split(this.separator));let t=!1;const n=a.Func.find({tags:["notationRefiner"]});for(const i of n)try{const n=i.prepare({col:this.column,stats:e,separator:this.separator}),o=(await n.call()).getOutputParamValue();t||=o}catch(e){console.error(e)}t&&(this._tempReadForNotProvider=!1,delete this.column.temp[$e.j.seqHandler],this.column.fireValuesChanged())}static setTags(e){const t=e.column.meta.units;if([me.Hi.FASTA,me.Hi.SEPARATOR].includes(t)){if(!e.column.getTag(me.gp.alphabet)&&0===Object.keys(e.stats.freq).length)throw new Error("Alphabet is empty and not annotated.");let t=e.column.getTag(me.gp.aligned);null==t&&(t=e.stats.sameLength?"SEQ.MSA":"SEQ",e.column.setTag(me.gp.aligned,t));let n=e.column.getTag(me.gp.alphabet);if(null==n&&(n=(0,Fe.pc)(e.stats.freq,me.q7),e.column.setTag(me.gp.alphabet,n)),n===me.YI.UN){const t=Object.keys(e.stats.freq).length,n=Object.keys(e.stats.freq).some(e=>e.length>1);e.column.setTag(me.gp.alphabetSize,t.toString()),e.column.setTag(me.gp.alphabetIsMultichar,n?"true":"false")}}else if(t===me.Hi.HELM){let t=e.column.getTag(me.gp.alphabet);if(null==t){const n=me.q7.map(e=>new Wi.a(e.name,e.alphabet,.9));t=(0,Fe.p0)(e.stats.freq,n,e.defaultGapOriginal),e.column.setTag(me.gp.alphabet,t)}}}get column(){return this._column}get length(){return this._column.length}get units(){return this._units}get notation(){return this._notation}get defaultGapOriginal(){return this._defaultGapOriginal}get separator(){const e=this.column.getTag(me.gp.separator)??void 0;if(this.notation===me.Hi.SEPARATOR&&null==e)throw new Error(`Separator is mandatory for column '${this.column.name}' of notation '${this.notation}'.`);return e}get aligned(){const e=this.column.getTag(me.gp.aligned);if(!e&&(this.isFasta()||this.isSeparator()))throw new Error("Tag aligned not set");return e}get alphabet(){const e=this.column.getTag(me.gp.alphabet);if(!e&&(this.isFasta()||this.isSeparator()))throw new Error("Tag alphabet not set");return e}get defaultBiotype(){return this.alphabet===me.YI.RNA||this.alphabet===me.YI.DNA?De.o.NUCLEOTIDE:De.o.AA}get helmCompatible(){return this.column.getTag(me.gp.isHelmCompatible)}getAlphabetSize(){if(this.notation==me.Hi.HELM||this.alphabet==me.YI.UN){const e=this.column.getTag(me.gp.alphabetSize);let t;if(e)t=parseInt(e);else{const e=this.stats;t=Object.keys(e.freq).length}return t}switch(this.alphabet){case me.YI.PT:return 20;case me.YI.DNA:case me.YI.RNA:return 4;case"NT":return console.warn("Unexpected alphabet 'NT'."),4;default:throw new Error(`Unexpected alphabet '${this.alphabet}'.`)}}getAlphabetIsMultichar(){return this.notation===me.Hi.HELM||this.alphabet===me.YI.UN&&"true"===this.column.getTag(me.gp.alphabetIsMultichar)}cached=!0;_splitted=null;columnVersion=null;getSplitted(e,t){if(this.cached&&void 0===t){this.column.version===this.columnVersion&&null!=this._splitted||(this.columnVersion=this.column.version,this._splitted=new Array(this.column.length));let t=this._splitted[e]?this._splitted[e].deref():void 0;if(!t){const n=this.column.get(e);t=this.splitter(n),this._splitted[e]=new WeakRef(t)}return t}{const n=this.column.get(e);return this.getSplitter(t)(n)}}getMonomerAtPosition(e,t,n){if(this.isCanonicalAlphabet&&this.isFasta()&&!this.getAlphabetIsMultichar()){const i=(this.column.get(e)??"")[t];return n?i===ve.b9[me.Hi.FASTA]?ve._S:i??ve._S:i??""}const i=this.getSplitted(e);return t<0||t>=i.length?this.defaultGapOriginal:n?i.getCanonical(t):i.getOriginal(t)}getMonomersAtPosition(e,t){const n=this.column.length,i=new Array(n).fill(ve._S);if(this.isCanonicalAlphabet&&this.isFasta()&&!this.getAlphabetIsMultichar()){const o=this.column.categories,r=this.column.getRawData();for(let s=0;s<n;s++){const n=o[r[s]]??"";if(e<n.length){const o=n[e];i[s]=t?o===ve.b9[me.Hi.FASTA]?ve._S:o??ve._S:o??""}}}else for(let o=0;o<n;o++){const n=this.getSplitted(o);e>=0&&e<n.length&&(i[o]=t?n.getCanonical(e):n.getOriginal(e))}return i}getValue(e,t){return this.column.get(e),new $e.C(e,this)}getHelm(e){let t;const n=this.column.get(e);return t=this.notation===me.Hi.HELM?n:this.notation===me.Hi.CUSTOM||this.notation===me.Hi.BILN?this.notationProvider.getHelm(n,{}):this.getConverter(me.Hi.HELM)(n),t}_stats=null;get isCanonicalAlphabet(){const e=this.alphabet;return e===me.YI.DNA||e===me.YI.RNA||e===me.YI.PT}get stats(){if(null==this._stats){const e={};let t=!0,n=null;const i=this.column.length;for(let o=0;o<i;++o){const i=this.getSplitted(o);null==n?n=i.length:i.length!==n&&(t=!1);for(let t=0;t<i.length;++t){const n=i.getCanonical(t);n in e||(e[n]=0),e[n]+=1}}this._stats={freq:e,sameLength:t}}return this._stats}_maxLength=null;get maxLength(){return null==this._maxLength&&(this._maxLength=0===this.column.length?0:R().count(0).take(this.column.length).map(e=>this.getSplitted(e).length).reduce((e,t)=>e>t?e:t,0)),this._maxLength}_posList=null;get posList(){if(null==this._posList){const e=this.column.getTag(me.gp.positionNames);this._posList=e?e.split(me.z1).map(e=>e.trim()):R().count(1).take(this.maxLength).map(e=>e.toString()).toArray()}return this._posList}isFasta(){return this.notation===me.Hi.FASTA}isSeparator(){return this.notation===me.Hi.SEPARATOR||!!this.separator}isFastaOrSeparator(){return this.isFasta()||this.isSeparator()}isHelm(){return this.notation===me.Hi.HELM}isCustom(){return this.notation===me.Hi.CUSTOM}isBiln(){return this.notation===me.Hi.BILN}isRna(){return this.alphabet===me.YI.RNA}isDna(){return this.alphabet===me.YI.DNA}isPeptide(){return this.alphabet===me.YI.PT}isMsa(){return!!this.aligned&&this.aligned.toUpperCase().includes("MSA")}isHelmCompatible(){return"true"===this.helmCompatible}isGap(e){return!e||e===this._defaultGapOriginal}getNotation(){if(this.units.toLowerCase().startsWith(me.Hi.FASTA))return me.Hi.FASTA;if(this.units.toLowerCase().startsWith(me.Hi.SEPARATOR))return me.Hi.SEPARATOR;if(this.units.toLowerCase().startsWith(me.Hi.HELM))return me.Hi.HELM;if(this.units.toLowerCase().startsWith(me.Hi.CUSTOM))return me.Hi.CUSTOM;if(this.units.toLowerCase().startsWith(me.Hi.BILN))return me.Hi.BILN;throw new Error(`Column '${this.column.name}' has unexpected notation '${this.units}'.`)}getHelmWrappers(){return[this.isDna()||this.isRna()||this.isHelmCompatible()?"RNA1{":"PEPTIDE1{",this.isDna()?"d(":this.isRna()?"r(":"",this.isDna()||this.isRna()?")p":"","}$$$$"]}getNewColumn(e,t,n,i){const o=this.column,r=e.toLowerCase()+"("+o.name+")",s=n??o.dataFrame?.columns.getUnusedName(r)??r,l=a.Column.fromList("string",s,i??new Array(this.column.length).fill(""));if(l.semType=a.SEMTYPE.MACROMOLECULE,l.meta.units=e,e===me.Hi.SEPARATOR){if(!t)throw new Error(`Notation '${me.Hi.SEPARATOR}' requires separator value.`);l.setTag(me.gp.separator,t)}l.setTag(a.TAGS.CELL_RENDERER,e===me.Hi.HELM?"helm":"sequence");const c=o.getTag(me.gp.aligned);c&&l.setTag(me.gp.aligned,c);let h=o.getTag(me.gp.alphabet);h||this.notation!==me.Hi.HELM||e===me.Hi.HELM||(h=me.YI.UN),null!=h&&l.setTag(me.gp.alphabet,h);let u=o.getTag(me.gp.alphabetSize);null!=h&&u&&l.setTag(me.gp.alphabetSize,u);const d=o.getTag(me.gp.alphabetIsMultichar);return null!=h&&void 0!==d&&l.setTag(me.gp.alphabetIsMultichar,d),e==me.Hi.HELM&&(u=this.getAlphabetSize().toString(),l.setTag(me.gp.alphabetSize,u)),e===me.Hi.BILN&&(l.setTag(me.gp.separator,"-"),l.meta.units=me.Hi.SEPARATOR),l}getNewColumnFromList(e,t){return this.getNewColumn(this.notation,this.separator,e,t)}static unitsStringIsValid(e){return e=e.toLowerCase(),[me.Hi.FASTA,me.Hi.SEPARATOR,me.Hi.HELM].some(t=>e.startsWith(t.toLowerCase()))}static getNewColumnFromParams(e,t,n){if(!ji.unitsStringIsValid(n))throw new Error("Invalid format of 'units' parameter");const i=a.Column.fromList("string",t,new Array(e).fill(""));return i.semType=a.SEMTYPE.MACROMOLECULE,i.meta.units=n,i}get splitter(){return null==this._splitter&&(this._splitter=this.getSplitter()),this._splitter}getSplitter(e){let t=null;if(t=this.notationProvider?this.notationProvider.splitter:null,t)return t;if(this.units.toLowerCase().startsWith(me.Hi.FASTA))return null===this.column.getTag(me.gp.alphabet)||this.getAlphabetIsMultichar()?me.J9:Fe.tm;if(this.units.toLowerCase().startsWith(me.Hi.SEPARATOR))return(0,me.dh)(this.separator,e);if(this.units.toLowerCase().startsWith(me.Hi.HELM))return me.qp;throw new Error(`Unexpected units ${this.units} .`)}split(e){return this.splitter(e)}getDistanceFunctionName(){if(!this.isFasta())throw new Error("Only FASTA notation is supported");if(this.isMsa())return pe.Z.HAMMING;switch(this.alphabet){case me.YI.DNA:case me.YI.RNA:case me.YI.PT:}return pe.Z.LEVENSHTEIN}getDistanceFunction(){return pe.V[this.getDistanceFunctionName()]()}async checkHelmCompatibility(){if(this.column.tags.has(me.gp.isHelmCompatible))return"true"===this.column.getTag(me.gp.isHelmCompatible);const e=(await(0,we.pj)()).getMonomerLib().getMonomerSymbolsByType("PEPTIDE"),t=new Set(e),n=((0,me.dh)(this.separator),new Set),i=this.column.length,o=this.column.getRawData();for(let e=0;e<i;++e){const i=o[e];if(!(i in n)){n.add(i);const o=this.getSplitted(e);for(let e=0;e<o.length;++e){const n=o.getCanonical(e);if(!t.has(n))return this.column.setTag(me.gp.isHelmCompatible,"false"),!1}}}return this.column.setTag(me.gp.isHelmCompatible,"true"),!0}toFasta(e){return e===me.Hi.FASTA}toSeparator(e){return e===me.Hi.SEPARATOR}toHelm(e){return e===me.Hi.HELM}convertHelmToFastaSeparator(e,t,n,i){i||(i=this.toFasta(t)?ve.b9[me.Hi.FASTA]:ve.b9[me.Hi.SEPARATOR]),n||(n=this.toFasta(t)?"":this.separator);const o=e.startsWith("RNA"),r=(0,me.qp)(e),s=[];for(let e=0;e<r.length;++e){let n=r.getOriginal(e);if(o&&(n=n.replace(fe.EK,"$1")),n===ve.b9[me.Hi.HELM])s.push(i);else if(this.toFasta(t)&&n.length>1){const e="["+n+"]";s.push(e)}else s.push(n)}return s.join(n)}convert(e,t){const n=this.getJoiner({notation:e,separator:t}),i=this.getNewColumn(e,t);return i.init(e=>{const t=this.getSplitted(e);return n(t)}),i}getRegion(e,t,n){const i=this.getNewColumn(this.notation,this.separator);i.name=n;const o=e??0,r=t??this.maxLength-1,s=this.getJoiner(),a=r-o+1,l=ve.b9[this.notation];i.init(e=>{const t=this.getSplitted(e),n=new Array(a);for(let e=0;e<a;++e){const i=o+e;n[e]=i<t.length?t.getOriginal(i):l}return s(new Fe.Mu(n,l))});const c=e=>{const t=e.split(",").map(e=>e.trim()),n=new Array(a);for(let e=0;e<a;++e){const i=o+e;n[e]=i<t.length?t[i]:"?"}return n.join(me.z1)},h=this.column.getTag(me.gp.positionNames);h&&i.setTag(me.gp.positionNames,c(h));const u=this.column.getTag(me.gp.positionLabels);return u&&i.setTag(me.gp.positionLabels,c(u)),i}_joiner=void 0;get joiner(){return this._joiner||(this._joiner=this.getJoiner()),this._joiner}getJoiner(e){const t=e?e.notation:this.notation,n=e?e.separator:this.separator;let i;const o=this;switch(t){case me.Hi.FASTA:i=function(e){return o.joinToFasta(e,o.isHelm())};break;case me.Hi.SEPARATOR:if(!n)throw new Error(`Separator is mandatory for notation '${t}'.`);i=function(e){return Ui(e,n,o.isHelm())};break;case me.Hi.HELM:{const e=o.alphabet===me.YI.DNA||o.alphabet===me.YI.RNA,t=o.getHelmWrappers();i=function(n){return qi(n,t,e)};break}case me.Hi.BILN:i=function(e){return zi(e)};break;default:throw new Error(`Unexpected notation '${t}'.`)}return i}getConverter(e,t=void 0){if(e===me.Hi.SEPARATOR&&!t)throw new Error(`Target separator is not specified for target units '${me.Hi.SEPARATOR}'.`);const n=this;if(e===me.Hi.FASTA)return function(e){return n.convertToFasta(e)};if(e===me.Hi.HELM)return function(e){return n.convertToHelm(e)};if(e===me.Hi.SEPARATOR)return function(e){return n.convertToSeparator(e,t)};if(e===me.Hi.BILN)return function(e){return n.convertToBiln(e)};throw new Error("Unexpected target units '"+e+"'.")}static forColumn(e,t){let n=e.temp[$e.j.seqHandler];return n&&n.columnVersion===e.version||(n=e.temp[$e.j.seqHandler]=new ji(e,t)),n}joinToFasta(e,t){const n=new Array(e.length);for(let i=0;i<e.length;++i){const o=e.getOriginal(i);let r=e.getOriginal(i);t&&(r=r.replace(fe.EK,"$1")),o===ve._S?r=ve.b9[me.Hi.FASTA]:o===fe.q7?r="":r.length>1&&(r="["+r+"]"),n[i]=r}return n.join("")}convertToFasta(e){const t=this.splitter,n=this.isHelm()?this.splitterAsHelmNucl(e):t(e);return this.joinToFasta(n,this.isHelm())}convertToSeparator(e,t){return Ui(this.isHelm()?this.splitterAsHelmNucl(e):this.splitter(e),t,this.isHelm())}convertToHelm(e){if(this.notation==me.Hi.HELM)return e;const t=this.getHelmWrappers(),n=this.isDna()||this.isRna();return qi(this.splitter(e),t,n)}convertToBiln(e){return this.notation==me.Hi.BILN?e:zi(this.splitter(e))}splitterAsHelmNucl(e){const t=this.splitter(e),n=new Array(t.length),i=e.startsWith("DNA"),o=e.startsWith("RNA");for(let e=0;e<t.length;++e){let r=t.getOriginal(e);(i||o)&&(r=r.replace(fe.EK,"$1"),r=r===fe.q7?null:r),n[e]=r||null}return new Fe.Mu(n.filter(e=>!!e),ve.b9[me.Hi.HELM])}getRendererBack(e,t){const n=this.column.temp;let i=n.rendererBack;return i||(i=n.rendererBack=this.notationProvider?.createCellRendererBack(e,t)),i}}function Ui(e,t,n){const i=new Array(e.length);for(let t=0;t<e.length;++t){const o=e.getCanonical(t);let r=e.getOriginal(t);n&&(r=r.replace(fe.EK,"$1")),o===ve._S?r=ve.b9[me.Hi.SEPARATOR]:o===fe.q7&&(r=""),i[t]=r}return i.join(t)}function qi(e,t,n){if(e.graphInfo&&(e.graphInfo.connections?.length??0)>0){const i=n?"RNA":"PEPTIDE",o="$$$",r=e.graphInfo.disjointSeqStarts,s=t[1],a=t[2],l=[];for(let t=0;t<r.length;t++){const o=r[t],c=t+1<r.length?r[t+1]:e.length,h=new Array(c-o);for(let t=o;t<c;++t){const i=e.getCanonical(t);let r=i;i===ve._S?r=ve.b9[me.Hi.HELM]:(n&&(r=r.replace(fe.EK,"$1")),r=1===r.length?`${s}${r}${a}`:`${s}[${r}]${a}`),h[t-o]=r}l.push(`${i}${t+1}{${h.join(".")}}`)}return`${l.join("|")}$${e.graphInfo.connections.map(e=>`${i}${e.seqIndex1+1},${i}${e.seqIndex2+1},${e.monomerIndex1+1}:R${e.rGroup1}-${e.monomerIndex2+1}:R${e.rGroup2}`).join("|")}${o}V2.0`}{const[i,o,r,s]=t,a=new Array(e.length);for(let t=0;t<e.length;++t){const i=e.getCanonical(t);let s=i;i===ve._S?s=ve.b9[me.Hi.HELM]:(n&&(s=s.replace(fe.EK,"$1")),s=1===s.length?`${o}${s}${r}`:`${o}[${s}]${r}`),a[t]=s}return`${i}${a.join(".")}${s}`}}function zi(e){if(e.graphInfo&&(e.graphInfo.connections?.length??0)>0){const t=e.graphInfo.disjointSeqStarts,n=new Array(e.length);for(let t=0;t<e.length;++t)n[t]=e.getCanonical(t),n[t]?.includes("-")&&(n[t]=`[${n[t]}]`);for(let i=0;i<e.graphInfo.connections.length;i++){const o=e.graphInfo.connections[i],r=`${i+1}`,s=o.seqIndex1,a=o.seqIndex2,l=t[s]+o.monomerIndex1,c=t[a]+o.monomerIndex2,h=`${n[l]}(${r},${o.rGroup1})`,u=`${n[c]}(${r},${o.rGroup2})`;n[l]=h,n[c]=u}return t.map((i,o)=>{const r=o+1<t.length?t[o+1]:e.length;return n.slice(i,r).join("-")}).join(".")}{const t=new Array(e.length);for(let n=0;n<e.length;++n)t[n]=e.getCanonical(n),t[n]?.includes("-")&&(t[n]=`[${t[n]}]`);return t.join("-")}}class Yi{libHelper;rdKitModule;constructor(e,t){this.libHelper=e,this.rdKitModule=t}getSeqHandler(e){return ji.forColumn(e,this)}getSeqMonomers(e){const t=this.getSeqHandler(e);return Object.keys(t.stats.freq)}async getHelmToMolfileConverter(e){const t=await(0,kt.b2)();return new Vi(t,this.rdKitModule,e)}helmToAtomicLevelSingle(e,t,n,i=!0){if(!e)return Ai.vF.createEmpty();const o=t.convertToMolfileV3K([e])[0];if(!o||!o.molfile)return Ai.vF.createEmpty();let r=null;try{let e=o.molfile;if(i){if(r=this.rdKitModule.get_mol(e),!r)return Ai.vF.createEmpty();r.set_new_coords(),r.normalize_depiction(1),r.straighten_depiction(!0),e=r.get_v3Kmolblock()}return n&&(e=t.molV3KtoMolV3KOCL(e)),new Ai.vF(e,o.monomers)}catch(e){const[t,n]=(0,Se.AP)(e);return Dr.logger.error(t,void 0,n),Ai.vF.createEmpty()}finally{r?.delete()}}async helmToAtomicLevel(e,t,n,i){const o=i??this.libHelper.getMonomerLib(),s=e.dataFrame,l=(0,xi.qj)(s,e.name),c=await this.getHelmToMolfileConverter(o),h=e.toList(),u=new Array(e.length),d=a.Func.find({package:"Chem",name:"beautifyMols"})[0],p=a.Func.find({package:"Chem",name:"convertToV3KViaOCL"})[0];for(let n=0;n<e.length;n++)u[n]=this.helmToAtomicLevelSingle(h[n],c,t&&!p,!d).molfile;if(d){const t=await d.apply({mols:u});if(t&&Array.isArray(t)&&t.length===e.length)for(let n=0;n<e.length;n++)t[n]&&(u[n]=t[n])}if(t&&p){const t=await p.apply({mols:u});if(t&&Array.isArray(t)&&t.length===e.length)for(let n=0;n<e.length;n++)t[n]&&(u[n]=t[n]);else r.shell.warning("OCL function returned an unexpected result")}const m=a.Column.fromStrings(l,u);return m.semType=a.SEMTYPE.MOLECULE,m.meta.units=a.UNITS.Molecule.MOLBLOCK,m.setTag(".sequence-src-col",e.name),{molCol:m,warnings:[]}}setUnitsToFastaColumn(e){if(e.column.semType!==a.SEMTYPE.MACROMOLECULE||e.column.meta.units!==me.Hi.FASTA)throw new Error(`The column of notation '${me.Hi.FASTA}' must be '${a.SEMTYPE.MACROMOLECULE}'.`);e.column.meta.units=me.Hi.FASTA,ji.setTags(e)}setUnitsToSeparatorColumn(e,t){if(e.column.semType!==a.SEMTYPE.MACROMOLECULE)throw new Error(`The column of notation '${me.Hi.SEPARATOR}' must be '${a.SEMTYPE.MACROMOLECULE}'.`);if(!t)throw new Error(`The column of notation '${me.Hi.SEPARATOR}' must have the separator tag.`);e.column.meta.units=me.Hi.SEPARATOR,e.column.setTag(me.gp.separator,t),ji.setTags(e)}setUnitsToHelmColumn(e){if(e.column.semType!==a.SEMTYPE.MACROMOLECULE)throw new Error(`The column of notation '${me.Hi.HELM}' must be '${a.SEMTYPE.MACROMOLECULE}'`);e.column.meta.units=me.Hi.HELM,ji.setTags(e)}}async function Ki(e){let t="";try{if(!e||!e.value)return t="No sequence provided",{errorText:t,mol:""};if(!(e.cell&&e.cell.dart&&e.cell.dataFrame&&e.cell.column))return t="Atomic level conversion requeires a sequence column",{errorText:t,mol:""};if(![me.Hi.FASTA,me.Hi.SEPARATOR,me.Hi.HELM,me.Hi.BILN].includes(e.cell.column.meta.units?.toLowerCase()??""))return t="Unsupported sequence notation. please use Bio | Polytool | Convert",{errorText:t,mol:""};const n=(await Wr.getSeqHelper()).getSeqHandler(e.cell.column);if(!n)return t="No sequence handler found",{errorText:t,mol:""};if((n.getSplitted(e.cell.rowIndex,60)?.length??100)>50)return t="Maximum number of monomers is 50",{errorText:t,mol:""};const i=a.Column.fromStrings("singleVal",[e.value]),o=a.DataFrame.fromColumns([i]);Object.entries(e.cell.column.tags).forEach(([e,t])=>{i.setTag(e,t)}),e.cell.column.temp[$e.j.notationProvider]&&(i.temp[$e.j.notationProvider]=e.cell.column.temp[$e.j.notationProvider]);const r=n.getSplitted(e.cell.rowIndex),s=(r.graphInfo?.connections?.length??0)>0,l=n.isHelm()&&new Set(r.graphInfo?.polymerTypes??[]).size>1;if(await Wr.toAtomicLevel(o,i,s||l,!1),o.columns.length<2)return t="No structure generated",{errorText:t,mol:""};const c=o.columns.byIndex(1).get(0);return c?{errorText:"",mol:c}:(t="No structure generated",{errorText:t,mol:""})}catch(e){Dr.logger.error(e)}return t="No Structure generated",{errorText:t,mol:""}}const Zi="#333333",Xi="rgba(60, 177, 115, 0.1)",Ji="rgba(240, 240, 240, 0.5)",Qi="rgba(100, 100, 100, 0.3)";class eo{constructor(e=io.DEFAULT_TRACK_HEIGHT,t=io.MIN_TRACK_HEIGHT,n=""){this.ctx=null,this.visible=!0,this.title="",this.tooltipEnabled=!1,this.tooltipContent=null,this.height=e,this.defaultHeight=e,this.minHeight=t,this.title=n}init(e){this.ctx=e}getMonomerAt(e,t,n){return null}enableTooltip(e){this.tooltipEnabled=e}setTooltipContentGenerator(e){this.tooltipContent=e}getTooltipContent(e,t){if(!this.tooltipEnabled||!this.tooltipContent)return null;const n=this.getPositionData(e)??new Map;return this.tooltipContent(e,t,n)}getPositionData(e){return null}setVisible(e){this.visible=e}getHeight(){return this.visible?this.height:0}getDefaultHeight(){return this.defaultHeight}getMinHeight(){return this.minHeight}setHeight(e){this.height=Math.max(this.minHeight,e)}resetHeight(){this.height=this.defaultHeight}isVisible(){return this.visible}setTitle(e){this.title=e}getTitle(){return this.title}}class to extends eo{constructor(e=new Map,t=io.DEFAULT_TRACK_HEIGHT,n="",i="WebLogo"){super(t,io.DEFAULT_TRACK_HEIGHT,i),this.data=new Map,this.monomerLib=null,this.biotype="HELM_AA",this.hoveredPosition=-1,this.hoveredMonomer=null,this.data=e,this.visible=e.size>0}setHovered(e,t){this.hoveredPosition=e,this.hoveredMonomer=t}getPositionData(e){return this.data.get(e)||null}setupDefaultTooltip(){this.enableTooltip(!0),this.setTooltipContentGenerator((e,t,n)=>this.createTooltipContent(e,t,n))}createFrequencyTable(e){let t;switch(this.biotype){case"HELM_BASE":case"HELM_SUGAR":case"HELM_NUCLETIDE":t=De.o.NUCLEOTIDE;break;default:t=De.o.AA}const n=Array.from(e.values()).reduce((e,t)=>e+t,0),i={};for(const[t,o]of e.entries())i[t]=Math.max(1,Math.round(o/n*100));const o=(0,pi.F)(i,t,this.monomerLib);return o.style.fontSize="11px",o.style.marginTop="4px",o}createTooltipContent(e,t,n){const i=[];if(i.push(s.divText(`Position: ${e+1}`,{style:{fontWeight:"bold",marginBottom:"6px",fontSize:"13px"}})),t&&(i.push(s.divText(`Monomer: ${t}`,{style:{marginBottom:"6px",fontSize:"13px"}})),n.has(t)&&i.push(s.divText(`${(100*n.get(t)).toFixed(2)}%`,{style:{marginBottom:"6px",fontSize:"13px"}}))),n&&n.size>0){const e=this.createFrequencyTable(n);i.push(e)}else i.push(s.divText("No data available",{style:{fontStyle:"italic",color:"#666"}}));const o=s.divV(i);return o.style.maxHeight="80vh",o}setMonomerLib(e){this.monomerLib=e}setBiotype(e){this.biotype=e}getMonomerAt(e,t,n){if(!this.ctx||!this.visible||0===this.data.size)return null;const i=this.data.get(n);if(!i||0===i.size)return null;const o=t,r=Array.from(i.entries()).sort((e,t)=>t[1]-e[1]),s=r.reduce((e,[t,n])=>e+n,0),a=this.height;let l=0;for(const[e,t]of r){const n=t*a/s;if(o>=l&&o<l+n)return e;l+=n}return null}updateData(e){this.data=e,this.visible=e.size>0}draw(e,t,n,i,o,r,s,a){if(!this.ctx||!this.visible||0===this.data.size)return;const l=Math.floor(n/r),c=i-4,h=t+2;for(let u=0;u<l;u++)this.drawWebLogoColumn(u,e,t,n,i,o,r,s,a,h,c)}drawWebLogoColumn(e,t,n,i,o,r,s,a,l,c,h){const u=r+e-1;if(u<0||u>=a)return;const d=this.data.get(u);if(!d||0===d.size)return;const p=t+e*s,m=s-2;r+e===l&&(this.ctx.fillStyle=Xi,this.ctx.fillRect(p,n,s,o)),this.ctx.fillStyle=Ji,this.ctx.fillRect(p+1,c,m,h),this.drawLettersInColumn(u,p,m,c,h,d),this.drawColumnBorder(p,c,m,h)}drawLettersInColumn(e,t,n,i,o,r){const s=Array.from(r.entries()).sort((e,t)=>t[1]-e[1]),a=s.reduce((e,[t,n])=>e+n,0),l=Math.min(1,o/(a*o));let c=i;const h=i+o;for(const[i,r]of s){const s=r*o*l,a=Math.max(4,Math.floor(s));if(a<4)continue;const u=e===this.hoveredPosition&&i===this.hoveredMonomer,d=Math.min(a,h-c);if(d<4)break;this.drawLetter(i,t+1,c,n,d,u),c+=d}}drawColumnBorder(e,t,n,i){this.ctx.strokeStyle=Qi,this.ctx.lineWidth=1,this.ctx.strokeRect(e+1,t,n,i)}drawLetter(e,t,n,i,o,r=!1){if(!this.ctx)return;const s=this.getMonomerBackgroundColor(e),a=this.getMonomerTextColor(e);this.ctx.fillStyle=s,this.ctx.fillRect(t,n,i,o),r&&(this.ctx.shadowColor="rgba(255, 255, 255, 0.8)",this.ctx.shadowBlur=8,this.ctx.strokeStyle="white",this.ctx.lineWidth=2,this.ctx.strokeRect(t,n,i,o),this.ctx.shadowBlur=0),this.drawLetterSeparators(t,n,i,o),this.drawLetterText(e,t,n,i,o,a)}drawLetterSeparators(e,t,n,i){this.ctx.strokeStyle="rgba(255, 255, 255, 0.4)",this.ctx.lineWidth=1,t+i<t+this.ctx.canvas.height&&(this.ctx.beginPath(),this.ctx.moveTo(e,t+i),this.ctx.lineTo(e+n,t+i),this.ctx.stroke())}drawLetterText(e,t,n,i,o,r){const s=Math.min(.8*o,.8*i);s>=7&&(this.ctx.fillStyle=r,this.ctx.font=`bold ${s}px Roboto, Roboto Local`,this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillText(e,t+i/2,n+o/2))}getMonomerBackgroundColor(e){if(this.monomerLib)try{const t=this.monomerLib.getMonomerColors(this.biotype,e);if(t&&t.backgroundcolor)return t.backgroundcolor}catch(e){console.warn("Error getting background color from monomerLib:",e)}return"#CCCCCC"}getMonomerTextColor(e){const t=this.getMonomerBackgroundColor(e);try{const e=a.Color.fromHtml(t),n=a.Color.getContrastColor(e);return a.Color.toHtml(n)}catch(e){return console.warn("Error calculating contrast color:",e),"#000000"}}}class no extends eo{constructor(e,t=io.DEFAULT_TRACK_HEIGHT,n="default",i="Conservation"){super(t,io.MIN_TRACK_HEIGHT,i),this.data=e,this.colorScheme=n,this.visible=e.length>0}updateData(e){this.data=e,this.visible=e.length>0}draw(e,t,n,i,o,r,s,a){if(!this.ctx||!this.visible||0===this.data.length)return;const l=Math.floor(n/r);for(let n=0;n<l;n++){const l=o+n;if(l>s)break;const c=e+n*r,h=r,u=c+h/2;l-1<this.data.length&&(this.drawConservationBar(l-1,c,h,u,t,i),l===a&&(this.ctx.fillStyle=Xi,this.ctx.fillRect(c,t,h,i)))}}drawConservationBar(e,t,n,i,o,r){if(!this.ctx)return;const s=this.data[e];this.ctx.fillStyle=Ji,this.ctx.fillRect(t+2,o,n-4,r);let a="#3CB173";if("default"===this.colorScheme)s<.5?a="#E74C3C":s<.75&&(a="#F39C12");else if("rainbow"===this.colorScheme)a=s<.2?"#E74C3C":s<.4?"#FF7F00":s<.6?"#FFFF00":s<.8?"#00FF00":"#0000FF";else if("heatmap"===this.colorScheme){const e=Math.round(255*s);a=`rgb(255, ${e}, ${e})`}const l=s*r;this.ctx.fillStyle=a,this.ctx.fillRect(t+2,o+r-l,n-4,l),this.ctx.strokeStyle=Qi,this.ctx.lineWidth=1,this.ctx.strokeRect(t+2,o,n-4,r),n>20&&(this.ctx.fillStyle=Zi,this.ctx.font="9px monospace",this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillText(`${Math.round(100*s)}%`,i,o+r/2))}}const io={TITLE_HEIGHT:16,TRACK_GAP:4,DOTTED_CELL_HEIGHT:30,SLIDER_HEIGHT:8,TOP_PADDING:5,DEFAULT_TRACK_HEIGHT:45,MIN_TRACK_HEIGHT:35},oo={BASE:io.DOTTED_CELL_HEIGHT+io.SLIDER_HEIGHT,WITH_TITLE:function(){return this.BASE+io.TITLE_HEIGHT+io.TRACK_GAP},WITH_WEBLOGO:function(){return this.WITH_TITLE()+io.DEFAULT_TRACK_HEIGHT+io.TRACK_GAP},WITH_BOTH:function(){return this.WITH_WEBLOGO()+io.DEFAULT_TRACK_HEIGHT+io.TRACK_GAP}};class ro{constructor(e,t){this.gridColumn=t,this.canvas=null,this.ctx=null,this.tracks=new Map,this.currentHoverPosition=-1,this.currentHoverTrack=null,this.currentHoverMonomer=null,this.previousHoverPosition=-1,this.previousHoverTrack=null,this.previousHoverMonomer=null,this.dataFrame=null,this.seqHandler=null,this.seqColumn=null,this.onSelectionCallback=null,this.trackButtons=[],this.userSelectedTracks=null,this.config={x:e.x||0,y:e.y||0,width:e.width||0,height:e.height||0,windowStartPosition:e.windowStartPosition||1,positionWidth:e.positionWidth||15,totalPositions:e.totalPositions||5e3,headerHeight:e.headerHeight||oo.BASE,sliderHeight:e.sliderHeight||io.SLIDER_HEIGHT,currentPosition:e.currentPosition||1,cellBackground:void 0===e.cellBackground||e.cellBackground,sliderColor:e.sliderColor||"rgba(220, 220, 220, 0.4)",onPositionChange:e.onPositionChange||((e,t)=>{}),onHeaderHeightChange:e.onHeaderHeightChange||(()=>{}),...e},this.eventElement=s.div(),this.eventElement.style.position="absolute",this.config.canvas.parentElement?.appendChild(this.eventElement),this.state={isDragging:!1,dragStartX:0},this.setupEventListeners(),this.init()}determineVisibleTracks(){const e=this.config.headerHeight,t=this.getTrack("weblogo"),n=this.getTrack("conservation");if(this.tracks.forEach(e=>{e.setVisible(!1),e.setHeight(io.DEFAULT_TRACK_HEIGHT)}),!(e<oo.WITH_TITLE()||e<oo.WITH_WEBLOGO()))if(e<oo.WITH_BOTH()){if(t){t.setVisible(!0);const n=e-oo.WITH_WEBLOGO();t.setHeight(io.DEFAULT_TRACK_HEIGHT+n)}}else{if(t&&t.setVisible(!0),n&&n.setVisible(!0),t&&e>oo.WITH_BOTH()){const n=e-oo.WITH_BOTH();t.setHeight(io.DEFAULT_TRACK_HEIGHT+n)}this.userSelectedTracks&&(this.tracks.forEach((e,t)=>{this.userSelectedTracks[t]||e.setVisible(!1)}),e<oo.WITH_WEBLOGO()&&t&&t.setVisible(!1),e<oo.WITH_BOTH()&&n&&n.setVisible(!1))}}drawTrackButtons(){if(!this.ctx||this.config.width<280)return;this.trackButtons=[];const e=this.getTrack("conservation"),t=this.getTrack("weblogo"),n=e?.isVisible()??!1,i=t?.isVisible()??!1;let o=this.config.width-16;const r=this.config.headerHeight>=oo.WITH_TITLE()?(io.TITLE_HEIGHT-14)/2:2;n&&i||(!n&&e&&(o-=70,this.drawTrackButton("conservation","Conservation",o,r,70,14),o-=4),!i&&t&&(o-=70,this.drawTrackButton("weblogo","WebLogo",o,r,70,14)))}drawTrackButton(e,t,n,i,o,r,s=!1){this.ctx&&(this.trackButtons.push({id:e,label:t,x:n,y:i,width:o,height:r}),this.ctx.fillStyle=s?"rgba(100, 150, 200, 0.8)":"rgba(240, 240, 240, 0.8)",this.ctx.fillRect(n,i,o,r),this.ctx.strokeStyle=s?"rgba(70, 120, 170, 0.8)":"rgba(180, 180, 180, 0.8)",this.ctx.lineWidth=1,this.ctx.strokeRect(n,i,o,r),this.ctx.fillStyle=s?"#ffffff":"#666666",this.ctx.font="9px Roboto, Roboto Local",this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillText(t,n+o/2,i+r/2))}handleTrackButtonClick(e,t){for(const n of this.trackButtons)if(e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height)return this.snapToTrackHeight(n.id),!0;return!1}isInsideColumnHeaderArea(e,t){return t<(this.config.headerHeight>=oo.WITH_TITLE()?io.TITLE_HEIGHT:0)}snapToTrackHeight(e){let t;if("weblogo"===e)t=oo.WITH_WEBLOGO();else{if("conservation"!==e)return;t=oo.WITH_BOTH()}this.userSelectedTracks||(this.userSelectedTracks={},this.tracks.forEach((e,t)=>{this.userSelectedTracks[t]=!1})),"conservation"===e?(this.userSelectedTracks.weblogo=!0,this.userSelectedTracks.conservation=!0):"weblogo"===e&&(this.userSelectedTracks.weblogo=!0),this.config.onHeaderHeightChange&&this.config.onHeaderHeightChange(t),window.requestAnimationFrame(()=>this.redraw())}resetToAutoMode(){this.userSelectedTracks=null;const e=this.tracks.size>0?oo.WITH_BOTH():oo.BASE;this.config.onHeaderHeightChange&&this.config.onHeaderHeightChange(e),window.requestAnimationFrame(()=>this.redraw())}drawColumnTitle(e,t,n,i){this.ctx&&i&&this.config.headerHeight>=oo.WITH_TITLE()&&(this.ctx.fillStyle="rgba(255, 255, 255, 0.95)",this.ctx.fillRect(e,t,n,io.TITLE_HEIGHT),this.ctx.fillStyle=Zi,this.ctx.font="bold 13px Roboto, Roboto Local",this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillText(i,e+n/2,t+io.TITLE_HEIGHT/2))}clearHoverStates(){(-1!==this.previousHoverPosition||null!==this.previousHoverTrack||null!==this.previousHoverMonomer)&&(this.previousHoverPosition=-1,this.previousHoverTrack=null,this.previousHoverMonomer=null,this.tracks.forEach(e=>{e instanceof to&&e.setHovered(-1,null)}),window.requestAnimationFrame(()=>this.redraw()))}redraw(){this.draw(this.config.x,this.config.y,this.config.width,this.config.height,this.config.currentPosition,this.config.windowStartPosition,{preventDefault:()=>{}},this.seqColumn?.name)}setSelectionData(e,t,n,i){this.dataFrame=e,this.seqColumn=t,this.seqHandler=n,this.onSelectionCallback=i||null}setupTooltipHandling(){this.eventElement.addEventListener("mousemove",this.handleTooltipMouseMove.bind(this)),this.eventElement.addEventListener("mouseleave",this.handleTooltipMouseLeave.bind(this))}handleTooltipMouseMove(e){if(!this.isValid)return;const{x:t,y:n}=this.getCoords(e),i=this.config.positionWidth,o=Math.floor(t/i),r=this.config.windowStartPosition+o-1;if(r<0||r>=this.config.totalPositions)return this.hideTooltip(),void this.clearHoverStates();const a=this.config.headerHeight>=oo.WITH_TITLE()?io.TITLE_HEIGHT:0,l=this.config.headerHeight-io.SLIDER_HEIGHT-io.DOTTED_CELL_HEIGHT,c=l-io.TRACK_GAP;if(n>=l||n<a)return this.hideTooltip(),void this.clearHoverStates();let h=null,u=0;const d=[],p=this.getTrack("weblogo");p&&p.isVisible()&&d.push({id:"weblogo",track:p});const m=this.getTrack("conservation");m&&m.isVisible()&&d.push({id:"conservation",track:m});let g=c;for(const{id:e,track:t}of d){const i=g-t.getHeight();if(n>=i&&n<g){h=e,u=n-i;break}g=i-io.TRACK_GAP}let f=null;if(h){const e=this.tracks.get(h);e&&(f=e.getMonomerAt(t,u,r))}if((this.previousHoverPosition!==r||this.previousHoverTrack!==h||this.previousHoverMonomer!==f)&&(this.previousHoverPosition=r,this.previousHoverTrack=h,this.previousHoverMonomer=f,h)){const e=this.tracks.get(h);e instanceof to&&(e.setHovered(r,f),window.requestAnimationFrame(()=>this.redraw()))}if((r!==this.currentHoverPosition||h!==this.currentHoverTrack||f!==this.currentHoverMonomer)&&(this.currentHoverPosition=r,this.currentHoverTrack=h,this.currentHoverMonomer=f,h)){const t=this.tracks.get(h);if(t){const n=t.getTooltipContent(r,f);if(n)return void s.tooltip.show(n,e.clientX+16,e.clientY+16)}}h&&f||(this.hideTooltip(),this.clearHoverStates())}handleTooltipMouseLeave(){this.hideTooltip(),this.clearHoverStates(),window.requestAnimationFrame(()=>this.draw(this.config.x,this.config.y,this.config.width,this.config.height,this.config.currentPosition,this.config.windowStartPosition,{preventDefault:()=>{}},this.seqColumn?.name))}hideTooltip(){this.currentHoverPosition=-1,this.currentHoverTrack=null,s.tooltip.hide()}draw(e,t,n,i,o,r,s,a){if(Object.assign(this.config,{x:e,y:t,width:n,height:i,currentPosition:o,windowStartPosition:r}),!this.isValid)return void(this.eventElement.style.display="none");this.ctx.save(),this.ctx.clearRect(e,t,n,i),this.ctx.translate(e,t),this.ctx.rect(0,0,n,i),this.ctx.clip(),this.determineVisibleTracks();const l=this.config.headerHeight>=oo.WITH_TITLE();l&&io.TITLE_HEIGHT,a&&l&&this.drawColumnTitle(0,0,n,a);const c=i-io.SLIDER_HEIGHT,h=c-io.DOTTED_CELL_HEIGHT,u=h-io.TRACK_GAP,d=[],p=[],m=this.getTrack("weblogo");m&&m.isVisible()&&p.push({id:"weblogo",track:m});const g=this.getTrack("conservation");g&&g.isVisible()&&p.push({id:"conservation",track:g});let f=u;for(const{track:e}of p){const t=e.getHeight(),i=f-t;e.draw(0,i,n,t,this.config.windowStartPosition,this.config.positionWidth,this.config.totalPositions,this.config.currentPosition),d.unshift({y:i,height:t}),f=i-io.TRACK_GAP}if(this.drawDottedCells(0,h,n,io.DOTTED_CELL_HEIGHT,c),d.push({y:h,height:io.DOTTED_CELL_HEIGHT}),this.config.currentPosition>=1&&this.config.currentPosition<=this.config.totalPositions){const e=this.config.positionWidth,t=this.config.currentPosition-this.config.windowStartPosition;if(t>=0&&t<Math.floor(n/e)){const n=t*e+e/2;for(let e=0;e<d.length-1;e++){const t=d[e],i=d[e+1];this.ctx.strokeStyle="rgba(60, 177, 115, 0.4)",this.ctx.lineWidth=1,this.ctx.beginPath(),this.ctx.moveTo(n,t.y+t.height),this.ctx.lineTo(n,i.y),this.ctx.stroke()}}}this.drawTrackButtons(),this.ctx.restore(),s.preventDefault(),this.setupEventElement()}drawDottedCells(e,t,n,i,o){if(!this.ctx)return;const r=this.config.totalPositions,s=this.config.positionWidth,a=this.config.currentPosition,l=this.config.windowStartPosition,c=Math.floor(n/s),h=t+io.TOP_PADDING;this.drawSlider(e,o,n);for(let n=0;n<c;n++){const c=l+n;if(c>r)break;const u=e+n*s,d=s,p=u+d/2;this.config.cellBackground&&(this.ctx.fillStyle=n%2==0?"rgba(248, 248, 248, 0.3)":"rgba(242, 242, 242, 0.2)",this.ctx.fillRect(u,t,d,i),this.ctx.strokeStyle="rgba(220, 220, 220, 0.7)",this.ctx.beginPath(),this.ctx.moveTo(u,t),this.ctx.lineTo(u,o),this.ctx.stroke()),this.ctx.fillStyle="#999999",this.ctx.beginPath(),this.ctx.arc(p,h+5,1,0,2*Math.PI),this.ctx.fill(),(c===a||(1===c||c%10==0)&&Math.abs(c-a)>1)&&(this.ctx.fillStyle=Zi,this.ctx.font="12px monospace",this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillText(c.toString(),p,h+15)),c===a&&(this.ctx.fillStyle="rgba(60, 177, 115, 0.2)",this.ctx.fillRect(u,t,d,i))}}drawSlider(e,t,n){if(!this.ctx)return;this.ctx.fillStyle=this.config.sliderColor,this.ctx.fillRect(e,t,n,io.SLIDER_HEIGHT);const i=Math.floor(n/this.config.positionWidth),o=this.config.windowStartPosition,r=this.config.totalPositions-i,s=this.sliderWidth,a=r<=0?0:(o-1)/r*(n-s),l=r<=0?n:s;if(this.ctx.fillStyle="rgba(150, 150, 150, 0.5)",this.ctx.fillRect(e+a,t,l,io.SLIDER_HEIGHT),this.config.currentPosition>=1&&this.config.currentPosition<=this.config.totalPositions){const i=(this.config.currentPosition-1)/(this.config.totalPositions-1),o=Math.round(i*n);this.ctx.fillStyle="#3CB173",this.ctx.fillRect(e+o-1,t-2,3,io.SLIDER_HEIGHT+4)}}setupEventElement(){this.eventElement.style.display="block",this.eventElement.style.left=`${this.config.x}px`,this.eventElement.style.top=`${this.config.y}px`,this.eventElement.style.width=`${this.config.width}px`,this.eventElement.style.height=`${this.config.height}px`}getCoords(e){const t=this.canvas.getBoundingClientRect();return{x:e.clientX-t.left-this.config.x,y:e.clientY-t.top-this.config.y}}isInHeaderArea(e){const{x:t,y:n}=this.getCoords(e);return t>=0&&t<=this.config.width&&n>=0&&n<=this.config.headerHeight}get positionWidth(){return this.config.positionWidth}set positionWidth(e){this.config.positionWidth=e}isInSliderArea(e){const{y:t}=this.getCoords(e),n=this.config.headerHeight-io.SLIDER_HEIGHT;return t>n&&t<n+io.SLIDER_HEIGHT}get sliderWidth(){const e=this.config.width/this.config.totalPositions*(this.config.width/this.config.positionWidth);return Math.max(e,20)}isInSliderDraggableArea(e){const{x:t,y:n}=this.getCoords(e),i=this.config.headerHeight-io.SLIDER_HEIGHT,o=Math.floor(this.config.width/this.config.positionWidth),r=this.config.windowStartPosition,s=this.config.totalPositions-o,a=s<=0?0:(r-1)/s*(this.config.width-this.sliderWidth);return n>i&&n<i+io.SLIDER_HEIGHT&&t>=a&&t<a+this.sliderWidth}setupEventListeners(){this.eventElement.addEventListener("mousemove",e=>{this.isValid&&(this.isInSliderDraggableArea(e)?this.eventElement.style.cursor="grab":this.isInSliderArea(e)||this.isInHeaderArea(e)?this.eventElement.style.cursor="pointer":this.eventElement.style.cursor="default")}),this.eventElement.addEventListener("mousedown",this.handleMouseDown.bind(this)),this.eventElement.addEventListener("mousemove",this.handleMouseMove.bind(this)),this.eventElement.addEventListener("mouseup",this.handleMouseUp.bind(this)),this.eventElement.addEventListener("mouseleave",this.handleMouseUp.bind(this)),this.eventElement.addEventListener("click",this.handleSelectionClick.bind(this)),this.eventElement.addEventListener("click",this.handleClick.bind(this)),this.eventElement.addEventListener("wheel",this.handleMouseWheel.bind(this)),window.addEventListener("keydown",this.handleKeyDown.bind(this))}handleSelectionClick(e){if(!(this.isValid&&this.dataFrame&&this.seqColumn&&this.seqHandler))return;const{x:t,y:n}=this.getCoords(e);if(this.handleTrackButtonClick(t,n))return;if(this.isInsideColumnHeaderArea(t,n))return;const i=this.config.positionWidth,o=Math.floor(t/i),r=this.config.windowStartPosition+o-1;if(r<0||r>=this.config.totalPositions)return;const s=this.config.headerHeight>=oo.WITH_TITLE()?io.TITLE_HEIGHT:0,a=this.config.headerHeight-io.SLIDER_HEIGHT-io.DOTTED_CELL_HEIGHT,l=a-io.TRACK_GAP;if(n>=a||n<s)return;let c=null,h=0;const u=[],d=this.getTrack("weblogo");d&&d.isVisible()&&u.push({id:"weblogo",track:d});const p=this.getTrack("conservation");p&&p.isVisible()&&u.push({id:"conservation",track:p});let m=l;for(const{id:e,track:t}of u){const i=m-t.getHeight();if(n>=i&&n<m){c=e,h=n-i;break}m=i-io.TRACK_GAP}if(c){const n=this.tracks.get(c);if(n){const i=n.getMonomerAt(t,h,r);if(i){if(this.onSelectionCallback)return void this.onSelectionCallback(r,i);this.selectRowsWithMonomerAtPosition(r,i),e.stopPropagation(),e.stopImmediatePropagation()}}}}selectRowsWithMonomerAtPosition(e,t){if(this.dataFrame&&this.seqHandler)try{const n=this.dataFrame.selection,i=this.seqHandler.getMonomersAtPosition(e,!0);n.init(e=>i[e]===t)}catch(e){console.error("Error selecting rows:",e)}}init(){if(this.canvas=this.config.canvas,!this.canvas)return void console.error("Canvas not found");const e=this.canvas.getContext("2d");e?(this.ctx=e,this.tracks.forEach(t=>t.init(e))):console.error("Failed to get 2D context from canvas")}addTrack(e,t){this.ctx&&t.init(this.ctx),this.tracks.set(e,t)}removeTrack(e){this.tracks.delete(e)}getTrack(e){return this.tracks.get(e)}updateTrack(e,t){const n=this.getTrack(e);n&&t(n)}get isValid(){const e=this.gridColumn,t=e?.grid,n=t?.horzScroll?.min||0,i=t?.horzScroll?.max||1e7;return!!this.canvas&&!!this.ctx&&this.config.height>=oo.WITH_TITLE()&&t&&(so(e.left??0,n,i)||so(e.right??1/0,n,i))}handleMouseDown(e){if(!this.isValid)return;const{x:t}=this.getCoords(e);this.isInSliderDraggableArea(e)&&(this.state.isDragging=!0,this.state.dragStartX=t,this.handleSliderDrag(t),e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation())}handleMouseWheel(e){if(this.isValid&&this.isInHeaderArea(e)){e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation();const t=e.shiftKey?Math.sign(e.deltaY):Math.sign(e.deltaX||e.deltaY),n=e.shiftKey?3:1,i=this.config.windowStartPosition+t*n,o=Math.floor(this.config.width/this.config.positionWidth),r=this.config.totalPositions-o+1;this.config.windowStartPosition=Math.max(1,Math.min(r,i)),"function"==typeof this.config.onPositionChange&&this.config.onPositionChange(this.config.currentPosition,this.getWindowRange())}}handleMouseMove(e){if(!this.state.isDragging||!this.isValid)return;const t=this.canvas.getBoundingClientRect(),n=e.clientX-t.left-this.config.x;this.handleSliderDrag(n),e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation()}handleKeyDown(e){if(this.isValid&&!(this.config.currentPosition<1)&&document.activeElement?.contains(this.eventElement)&&"block"===this.eventElement.style.display){if("ArrowLeft"===e.key||"ArrowRight"===e.key){e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation();const t="ArrowLeft"===e.key?-1:1,n=Math.min(Math.max(this.config.currentPosition+t,1),this.config.totalPositions);if(n===this.config.currentPosition)return;this.config.currentPosition=n;const i=Math.floor(this.config.width/this.config.positionWidth),o=this.config.windowStartPosition;(n<o||n>o+i-1)&&(this.config.windowStartPosition=t<0?n:Math.max(1,n-i+1))}else{if("Escape"!==e.key)return;this.config.currentPosition=-2,e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation()}"function"==typeof this.config.onPositionChange&&this.config.onPositionChange(this.config.currentPosition,this.getWindowRange())}}handleMouseUp(){this.state.isDragging=!1}handleSliderDrag(e){if(!this.isValid)return;const t=this.sliderWidth,n=this.config.width-t,i=Math.max(0,Math.min(this.config.width,e)),o=Math.floor(this.config.width/this.config.positionWidth),r=Math.floor(this.config.width/this.config.positionWidth),s=this.config.totalPositions-r,a=Math.max(0,i-t/2)/n*s;this.config.windowStartPosition=Math.max(1,Math.min(a,this.config.totalPositions-o+1)),"function"==typeof this.config.onPositionChange&&this.config.onPositionChange(this.config.currentPosition,this.getWindowRange())}get headerHeight(){return this.config.headerHeight}set headerHeight(e){this.config.headerHeight=e}handleClick(e){if(!this.isValid)return;e.clientX,this.canvas.getBoundingClientRect().left,e.clientY,this.canvas.getBoundingClientRect().top;const{x:t,y:n}=this.getCoords(e);if(this.handleTrackButtonClick(t,n))return e.preventDefault(),void e.stopPropagation();if(!this.isInsideColumnHeaderArea(t,n)&&n<this.config.headerHeight-io.SLIDER_HEIGHT&&n>=0){const e=this.config.positionWidth,n=Math.round(t/e-.5),i=this.config.windowStartPosition+n;i>=1&&i<=this.config.totalPositions&&(this.config.currentPosition=i,"function"==typeof this.config.onPositionChange&&this.config.onPositionChange(this.config.currentPosition,this.getWindowRange()))}}getWindowRange(){return{start:this.config.windowStartPosition,end:Math.min(this.config.totalPositions,this.config.windowStartPosition+Math.floor(this.config.width/this.config.positionWidth))}}updateConfig(e){Object.assign(this.config,e),this.config.currentPosition=Math.min(this.config.currentPosition,this.config.totalPositions),"function"==typeof this.config.onPositionChange&&this.config.onPositionChange(this.config.currentPosition,this.getWindowRange())}getCurrentPosition(){return this.config.currentPosition}setCurrentPosition(e){this.config.currentPosition=Math.max(1,Math.min(this.config.totalPositions,e)),"function"==typeof this.config.onPositionChange&&this.config.onPositionChange(this.config.currentPosition,this.getWindowRange())}getHeightThresholds(){return{BASE:oo.BASE,WITH_TITLE:oo.WITH_TITLE(),WITH_WEBLOGO:oo.WITH_WEBLOGO(),WITH_BOTH:oo.WITH_BOTH()}}}function so(e,t,n){return e>=t&&e<=n}class ao{static conservationCache=new a.LruCache(100);static webLogoCache=new a.LruCache(100);static lastInvalidationTime=0;static CHUNK_SIZE=50;static clearAllCaches(){ao.conservationCache=new a.LruCache(100),ao.webLogoCache=new a.LruCache(100),ao.lastInvalidationTime=Date.now()}static getLastInvalidationTime(){return ao.lastInvalidationTime}static getChunkCacheKey(e,t,n){const i=e.dataFrame;return`${i.id}_${e.name}_f${i.filter.version}_${t}_${n}`}static getConservationChunk(e,t,n,i){return ao.conservationCache.getOrCreate(i,()=>{const o=ao.getWebLogoChunk(e,t,n,i),r=new Array(n-t).fill(0);for(let i=t;i<n;i++){const n=o.get(i);if(!n||0===n.size)continue;let s=0,a=0;const l=e.defaultGapOriginal;for(const[e,t]of n.entries())e&&e!==l&&(s+=t,t>a&&(a=t));r[i-t]=s>0?a/s:0}return r})}static getWebLogoChunk(e,t,n,i){return ao.webLogoCache.getOrCreate(i,()=>{const i=e.column.dataFrame,o=new Map,r=i.filter.trueCount;if(r<=1)return o;for(let e=t;e<n;e++)o.set(e,new Map);const s=i.filter,a=1/r;for(let i=-1;-1!==(i=s.findNext(i,!0));){const r=e.getSplitted(i).getOriginalRegion(t,n);if(0!==r.length)for(let e=0;e<r.length;e++){const n=r[e],i=o.get(t+e);i.set(n,(i.get(n)||0)+a)}}return o})}static getConservationForViewport(e,t,n,i){const o=new Array(i).fill(0),r=Math.floor(t/ao.CHUNK_SIZE)*ao.CHUNK_SIZE,s=Math.ceil(n/ao.CHUNK_SIZE)*ao.CHUNK_SIZE;for(let t=r;t<s;t+=ao.CHUNK_SIZE){const n=Math.min(t+ao.CHUNK_SIZE,i),r=ao.getChunkCacheKey(e.column,t,n),s=ao.getConservationChunk(e,t,n,r);for(let e=0;e<s.length&&t+e<i;e++)o[t+e]=s[e]}return o}static getWebLogoForViewport(e,t,n,i){const o=new Map,r=Math.floor(t/ao.CHUNK_SIZE)*ao.CHUNK_SIZE,s=Math.ceil(n/ao.CHUNK_SIZE)*ao.CHUNK_SIZE;for(let t=r;t<s;t+=ao.CHUNK_SIZE){const n=Math.min(t+ao.CHUNK_SIZE,i),r=ao.getChunkCacheKey(e.column,t,n),s=ao.getWebLogoChunk(e,t,n,r);for(const[e,t]of s.entries())e<i&&o.set(e,t)}return o}}class lo extends to{seqHandler;maxLength;lastViewportStart=-1;lastViewportEnd=-1;lastInvalidationTime=0;forceNextUpdate=!1;constructor(e,t,n=45,i="WebLogo"){super(new Map,n,"",i),this.seqHandler=e,this.maxLength=t,this.visible=e.column.dataFrame.filter.trueCount>1}forceUpdate(){this.forceNextUpdate=!0}resetViewportTracking(){this.lastViewportStart=-1,this.lastViewportEnd=-1}updateForViewport(e,t){const n=ao.getLastInvalidationTime(),i=n>this.lastInvalidationTime;if(!(Math.abs(this.lastViewportStart-e)>=10||Math.abs(this.lastViewportEnd-t)>=10||i||this.forceNextUpdate))return;this.forceNextUpdate=!1,this.lastViewportStart=e,this.lastViewportEnd=t,this.lastInvalidationTime=n;const o=Math.max(0,e-20),r=Math.min(this.maxLength,t+20),s=ao.getWebLogoForViewport(this.seqHandler,o,r,this.maxLength);this.updateData(s)}draw(e,t,n,i,o,r,s,a){const l=Math.ceil(n/r)+2,c=Math.min(o+l,s);this.updateForViewport(o-1,c-1),super.draw(e,t,n,i,o,r,s,a)}}class co extends no{seqHandler;maxLength;lastViewportStart=-1;lastViewportEnd=-1;lastInvalidationTime=0;forceNextUpdate=!1;constructor(e,t,n=45,i="default",o="Conservation"){super([],n,i,o),this.seqHandler=e,this.maxLength=t,this.visible=e.column.dataFrame.filter.trueCount>1}forceUpdate(){this.forceNextUpdate=!0}resetViewportTracking(){this.lastViewportStart=-1,this.lastViewportEnd=-1}updateForViewport(e,t){const n=ao.getLastInvalidationTime(),i=n>this.lastInvalidationTime;if(!(Math.abs(this.lastViewportStart-e)>=10||Math.abs(this.lastViewportEnd-t)>=10||i||this.forceNextUpdate))return;this.forceNextUpdate=!1,this.lastViewportStart=e,this.lastViewportEnd=t,this.lastInvalidationTime=n;const o=Math.max(0,e-20),r=Math.min(this.maxLength,t+20),s=ao.getConservationForViewport(this.seqHandler,o,r,this.maxLength);this.updateData(s)}draw(e,t,n,i,o,r,s,a){const l=Math.ceil(n/r)+2,c=Math.min(o+l,s);this.updateForViewport(o-1,c-1),super.draw(e,t,n,i,o,r,s,a)}}class ho{separator;seqHelper;seqCol;splitter;get defaultGapOriginal(){return""}constructor(e,t,n){this.separator=e,this.seqHelper=t,this.seqCol=n,this.splitter=Fe.bR.bind(this)}setUnits(){}getHelm(e,t){const n=this.splitter(e);return this.seqHelper.getSeqHandler(this.seqCol).getJoiner({notation:ve.Hi.HELM})(n)}createCellRendererBack(e,t){const n=Dr.properties.maxMonomerLength||4,i=new uo(e,t,n,this.seqHelper);return i.init().then(()=>{}),i}}class uo extends He.Jy{constructor(e,t,n,i){super(e,t,Dr.logger,n,()=>{const e=i.getSeqHandler(t),{font:n,fontWidth:o}=He.Jy.getFontSettings(t);return{seqHandler:e,font:n,fontCharWidth:o,separatorWidth:0,monomerToShort:Fe.zS}})}}async function po(){return await Wr.getMonomerLibHelper()}async function mo(){await Wr.initBio()}function go(e){return Wr.sequenceTooltip(e)}async function fo(e){return await Wr.standardiseMonomerLibrary(e)}async function yo(e,t,n){await Wr.matchWithMonomerLibrary(e,t,n)}function bo(){return Wr.getBioLib()}function vo(e){return Wr.getSeqHandler(e)}function wo(e){return Wr.getRegionPanel(e)}async function Co(e){return await Wr.libraryPanel(e)}function So(e){Wr.GetRegionEditor(e)}function Ao(e){Wr.SplitToMonomersEditor(e)}function xo(e){Wr.SequenceSpaceEditor(e)}function Eo(e){Wr.SeqActivityCliffsEditor(e)}function Mo(){return Wr.customSequenceCellRenderer()}function To(){return Wr.fastaSequenceCellRenderer()}function _o(){return Wr.separatorSequenceCellRenderer()}function Io(){return Wr.bilnSequenceCellRenderer()}function Lo(e,t,n){return Wr.refineNotationProviderForBiln(e,t,n)}function No(e){return Wr.macroMolColumnPropertyPanel(e)}function Po(e){return Wr.compositionAnalysisWidget(e)}function Ro(){return Wr.macromoleculeDifferenceCellRenderer()}function $o(e,t,n,i,o){return Wr.sequenceAlignment(e,t,n,i,o)}function Oo(){return Wr.webLogoViewer()}function ko(){return Wr.vdRegionsViewer()}function Ho(e,t,n,i){return Wr.getRegion(e,t,n,i)}async function Fo(e,t,n,i,o){await Wr.getRegionTopMenu(e,t,n,i,o)}async function Go(e,t,n,i,o,r,s,a,l){return await Wr.activityCliffs(e,t,n,i,o,r,s,a,l)}async function Bo(e,t,n,i,o){return await Wr.macromoleculePreprocessingFunction(e,t,n,i,o)}async function Do(e,t){return await Wr.helmPreprocessingFunction(e,t)}async function Vo(e,t,n,i,o,r,s,a,l){return await Wr.sequenceSpaceTopMenu(e,t,n,i,o,r,s,a,l)}async function Wo(e,t,n,i){await Wr.toAtomicLevel(e,t,n,i)}async function jo(e){await Wr.toAtomicLevelAction(e)}async function Uo(e){return await Wr.toAtomicLevelPanel(e)}async function qo(e){return await Wr.sequence3dStructureWidget(e)}function zo(){Wr.multipleSequenceAlignmentDialog()}async function Yo(e,t,n){return await Wr.alignSequences(e,t,n)}async function Ko(){return await Wr.compositionAnalysis()}function Zo(e){return Wr.importFasta(e)}function Xo(e){return Wr.importBam(e)}function Jo(){Wr.convertDialog()}function Qo(e){Wr.convertColumnAction(e)}function er(){return Wr.monomerCellRenderer()}async function tr(e){return await Wr.testDetectMacromolecule(e)}async function nr(e,t){return await Wr.splitToMonomersTopMenu(e,t)}function ir(e){return Wr.getHelmMonomers(e)}function or(){return Wr.similaritySearchViewer()}function rr(){return Wr.similaritySearchTopMenu()}function sr(){return Wr.diversitySearchViewer()}function ar(){return Wr.diversitySearchTopMenu()}function lr(e){Wr.searchSubsequenceEditor(e)}function cr(e){Wr.SubsequenceSearchTopMenu(e)}async function hr(e,t,n){return await Wr.sequenceIdentityScoring(e,t,n)}async function ur(e,t,n){return await Wr.sequenceSimilarityScoring(e,t,n)}async function dr(){await Wr.manageMonomerLibraries()}async function pr(){await Wr.manageLibrariesView()}async function mr(){await Wr.manageMonomersView()}async function gr(){return await Wr.manageMonomerLibrariesView()}async function fr(e){await Wr.manageMonomerLibrariesViewTreeBrowser(e)}function yr(){Wr.saveAsFasta()}function br(){return Wr.bioSubstructureFilter()}function vr(){return Wr.bioSubstructureFilterTest()}async function wr(){await Wr.webLogoLargeApp()}async function Cr(){await Wr.webLogoAggApp()}async function Sr(){await Wr.getRegionApp()}async function Ar(){await Wr.getRegionHelmApp()}function xr(){Wr.longSeqTableSeparator()}function Er(){Wr.longSeqTableFasta()}function Mr(){Wr.longSeqTableHelm()}function Tr(e,t){Wr.addCopyMenu(e,t)}async function _r(){await Wr.demoBioSimilarityDiversity()}async function Ir(){await Wr.demoBioSequenceSpace()}async function Lr(){await Wr.demoBioActivityCliffs()}async function Nr(){await Wr.demoBioAtomicLevel()}async function Pr(e){await Wr.sdfToJsonLib(e)}async function Rr(e,t){return await Wr.seq2atomic(e,t)}async function $r(e,t){return await Wr.seqIdentity(e,t)}async function Or(e,t,n){await Wr.detectMacromoleculeProbe(e,t,n)}async function kr(){return await Wr.getSeqHelper()}async function Hr(e,t,n){return await Wr.getMolFromHelm(e,t,n)}var Fr=function(e,t,n,i){var o,r=arguments.length,s=r<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,i);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(r<3?o(s):r>3?o(t,n,s):o(t,n))||s);return r>3&&s&&Object.defineProperty(t,n,s),s},Gr=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Br=function(e,t){return function(n,i){t(n,i,e)}};const Dr=new di;let Vr=null;r.decorators||(r.decorators={}),["func","init","param","panel","editor","demo","app","appTreeBrowser","fileHandler","fileExporter","model","viewer","filter","cellRenderer","autostart","dashboard","folderViewer","semTypeDetector","packageSettingsEditor","functionAnalysis","converter","fileViewer","model","treeBrowser","polyfill"].forEach(e=>{r.decorators[e]||(r.decorators[e]=function(e){return function(e,t,n){}})});class Wr{static async getMonomerLibHelper(){return await Hn.getInstance()}static async initBio(){null==Vr&&(Vr=async function(){const e="Bio: _package.initBio()";Dr.logger.debug(`${e}, start`);const t=window.performance.now(),n=await(0,Re.j)(),i=await Dr.getProperties(),o=new ui(i);Dr.properties=o;const s=await Hn.getInstance(),l=await(0,Pe.ub)();l.explicit&&(l.explicit=[],await(0,Pe.Eu)(l)),await s.awaitLoaded(1/0),s.initialLoadCompleted||await s.loadMonomerLib(),s.loadMonomerSets();const c=s.getMonomerLib(),u=s.getMonomerSets(),d=window.performance.now();Dr.logger.debug(`${e}, loading ET: ${d-t} ms`);const p=new Yi(s,n);Dr.completeInit(p,c,u,n),Dr.logger.debug(`${e}, end`),function(){const e=e=>{setTimeout(()=>{if(e.isDetached)return;const t=e.dataFrame;if(!t)return;const n=t.columns.bySemTypeAll(a.SEMTYPE.MACROMOLECULE);for(const i of n){let n=null;try{n=Dr.seqHelper.getSeqHandler(i)}catch(e){continue}if(!n)continue;if(n.isHelm()||n.alphabet===me.YI.UN)continue;const o=e.col(i.name);if(!o)continue;let s=!!e.tableView&&Array.from(e.tableView.viewers).some(e=>"Sequence Position Statistics"===e.type);if(n.isMsa()){const l=(e,t)=>Number.isNaN(e)?t:e,c=()=>l(Math.max(Number.parseInt(i.getTag(me.gp.positionShift)??"0"),0),0)+1,u=()=>l(Number.parseInt(i.getTag(me.gp.selectedPosition)??"-2"),-2),d=()=>He.Jy.getFontSettings(i).fontWidth;let p=0,m=0;const g=i.categories;for(let e=0;e<g.length;e++){const t=g[e];t&&t.length>m&&(m=t.length,p=e)}const f=g[p],y=n.splitter(f),b=y?y.length:30,v={WITH_TITLE:58,WITH_WEBLOGO:107,WITH_BOTH:156};let w;w=i.length>1e5||b<50?v.WITH_TITLE:i.length>5e4?v.WITH_WEBLOGO:v.WITH_BOTH;let C=null,S=null;const A=a.debounce(h.merge(t.onFilterChanged,t.onDataChanged.pipe((0,k.filter)(e=>e?.args?.column===i))),100).subscribe(()=>{ao.clearAllCaches(),C&&(C.resetViewportTracking(),C.forceUpdate()),S&&(S.resetViewportTracking(),S.forceUpdate()),setTimeout(()=>{e.isDetached||e.invalidate()},50)});e.sub(A);const x=r=>{const l=[],h=new co(n,b,45,"default","Conservation");S=h,l.push({id:"conservation",track:h,priority:1});const p=new lo(n,b,45,"WebLogo");C=p,r&&(p.setMonomerLib(r),p.setBiotype(n.defaultBiotype||"HELM_AA")),p.setupDefaultTooltip(),l.push({id:"weblogo",track:p,priority:2});const m=new ro({canvas:e.overlay,headerHeight:w,totalPositions:b+1,onPositionChange:(t,n)=>{setTimeout(()=>{const o=c(),r=u();if(o!==n.start&&i.setTag(me.gp.positionShift,(n.start-1).toString()),r!==t&&(i.setTag(me.gp.selectedPosition,t.toString()),t>=0&&!s&&e.tableView&&R()(e.dataFrame?.columns.numerical).find(e=>!0))){s=!0;const t=e.tableView.addViewer("Sequence Position Statistics",{sequenceColumnName:i.name});e.tableView.dockManager.dock(t,a.DOCK_TYPE.DOWN,null,"Sequence Position Statistics",.4)}})},onHeaderHeightChange:t=>{e.isDetached||t<v.WITH_TITLE||setTimeout(()=>e.props.colHeaderHeight=t)}},o);m.setupTooltipHandling(),l.forEach(({id:e,track:t})=>{m.addTrack(e,t)}),m.setSelectionData(t,i,n),b>50&&(e.props.colHeaderHeight=w,setTimeout(()=>{e.isDetached||(o.width=400)},300)),e.sub(e.onCellRender.subscribe(e=>{const t=e.cell;if(!t||!t.isColHeader||t?.gridColumn?.name!==o?.name)return;const n=e.bounds;if(!n)return;m.headerHeight=n.height;const r=d();m.positionWidth=r+8;const s=c();m.draw(n.x,n.y,n.width,n.height,u(),s,e,i.name)}))};(0,we.pj)().then(e=>{const t=e.getMonomerLib();x(t)}).catch(e=>{r.shell.warning("Failed to initialize monomer library"),console.error("Failed to initialize monomer library:",e)})}}},1e3)},t=(r.events.onViewerAdded.subscribe(t=>{if(!(t.args&&t.args.viewer instanceof a.Grid))return;const n=t.args.viewer;e(n)}),r.shell.tableViews);for(const n of t){const t=n?.grid;t&&e(t)}}()}()),await Vr}static sequenceTooltip(e){const t=new fi(e,Dr.seqHelper);return t.init().then(()=>{}).catch(e=>{const t=e instanceof Error?e.message:e.toString();r.shell.error(t)}),t}static async standardiseMonomerLibrary(e){return await async function(e){const t=JSON.parse(e);if(!t||!Array.isArray(t)||0===t.length)throw new Error("Invalid library format, expected an array of monomers");const n=(await en(t)).map(e=>({...e,lib:void 0,wem:void 0}));return JSON.stringify(n,null,2)}(e)}static async matchWithMonomerLibrary(e,t,n="PEPTIDE"){const i=await async function(e,t,n,i="PEPTIDE"){const o=a.Func.find({package:"Chem",name:"convertMoleculeNotation"})[0];if(!o)throw new Error("Function convertMoleculeNotation not found, please install Chem package");const r=n.getMonomerSymbolsByType(i).map(e=>n.getMonomer(i,e)).filter(e=>e&&(e.smiles||e.molfile)),s=(await en(r)).map((e,t)=>({sym:e.symbol,smiles:un(e.smiles??"",e.rgroups??[]),original:e.smiles,source:r[t]?.lib?.source})).filter(e=>!!e?.smiles&&!e.smiles.includes("[*:")),l=a.Column.fromList(a.COLUMN_TYPE.STRING,"MonomerSmiles",s.map(e=>e.smiles));l.semType=a.SEMTYPE.MOLECULE;const c=await o.apply({molecule:l,targetNotation:a.chem.Notation.Smiles});if(!c||c.length!==l.length)throw new Error("Error canonicalizing monomer smiles");c.toList().forEach((e,t)=>s[t].smiles=e);const h=e.col(t),u=await o.apply({molecule:h,targetNotation:a.chem.Notation.Smiles});if(!u||u.length!==h.length)throw new Error("Error canonicalizing molecules");const d=u.toList(),p=e.clone(),m=p.columns.addNewString(p.columns.getUnusedName("Matched monomer smiles"));m.semType=a.SEMTYPE.MOLECULE;const g=p.columns.addNewString(p.columns.getUnusedName("Matched monomer symbol"));g.semType="Monomer";const f=p.columns.addNewString(p.columns.getUnusedName("Matched monomer source"));p.columns.setOrder([t,g.name,m.name,f.name]);for(let e=0;e<d.length;e++){const t=d[e];if(t)for(let n=0;n<s.length;n++)if(s[n].smiles===t){m.set(e,s[n].original,!1),g.set(e,s[n].sym,!1),f.set(e,s[n].source??"",!1);break}}return p}(e,t.name,Dr.monomerLib,n);r.shell.addTableView(i)}static getBioLib(){return Dr.monomerLib}static getSeqHandler(e){return Dr.seqHelper.getSeqHandler(e)}static getRegionPanel(e){const t="getRegionTopMenu",n=a.Func.find({package:Dr.name,name:t});if(1!==n.length)throw new Error(`Package '${Dr.name}' func '${t}' not found`);const i=n[0].prepare({table:e.dataFrame,sequence:e});return new wi(i,Dr.seqHelper).widget()}static async libraryPanel(e){return async function(){const e=s.label("Manage monomer libraries");return Gn()(e).addClass("d4-link-action"),e.onclick=async()=>await Un(),new a.Widget(e)}()}static GetRegionEditor(e){try{new wi(e,Dr.seqHelper).dialog()}catch(e){const t=e instanceof Error?e.message:e.toString(),n=e instanceof Error?e.stack:void 0;r.shell.error(`Get region editor error: ${t}`),Dr.logger.error(t,void 0,n)}}static SplitToMonomersEditor(e){const t=new ri;s.dialog({title:"Split to Monomers"}).add(t.paramsUI).onOK(async()=>e.func.prepare(t.funcParams).call(!0)).show()}static SequenceSpaceEditor(e){const t=new O({semtype:a.SEMTYPE.MACROMOLECULE}),n=s.dialog({title:"Sequence Space"}).add(t.getEditor()).onOK(async()=>{const n=t.getParams();return e.func.prepare({molecules:n.col,table:n.table,methodName:n.methodName,similarityMetric:n.similarityMetric,plotEmbeddings:n.plotEmbeddings,options:n.options,preprocessingFunction:n.preprocessingFunction,clusterEmbeddings:n.clusterEmbeddings}).call()});n.history(()=>({editorSettings:t.getStringInput()}),e=>t.applyStringInput(e.editorSettings)),n.show()}static SeqActivityCliffsEditor(e){const t=new xe({semtype:a.SEMTYPE.MACROMOLECULE}),n=s.dialog({title:"Activity Cliffs"}).add(t.getEditor()).onOK(async()=>{const n=t.getParams();return e.func.prepare({table:n.table,molecules:n.col,activities:n.activities,similarity:n.similarityThreshold,methodName:n.methodName,similarityMetric:n.similarityMetric,preprocessingFunction:n.preprocessingFunction,options:n.options}).call()});n.history(()=>({editorSettings:t.getStringInput()}),e=>t.applyStringInput(e.editorSettings)),n.show()}static customSequenceCellRenderer(){return new Ye}static fastaSequenceCellRenderer(){return new Ye}static separatorSequenceCellRenderer(){return new Ye}static bilnSequenceCellRenderer(){return new Ye}static refineNotationProviderForBiln(e,t,n){return"-"===n&&(!(!Object.keys(t.freq).some(e=>e.match(/^.+\(\d{1,2},\d{1,2}\)$/))&&!Object.keys(t.freq).some(e=>e.includes("[")||e.includes("]")))&&(e.setTag("aligned","SEQ"),e.setTag("alphabet","UN"),e.setTag(".alphabetIsMultichar","true"),e.meta.units=me.Hi.BILN,e.temp[$e.j.notationProvider]=new ho(n,Dr.seqHelper,e),!0))}static macroMolColumnPropertyPanel(e){return function(e){const t=Array.from(e.dataFrame.columns).filter(e=>e.semType===a.SEMTYPE.MOLECULE).map(e=>e.name);new Set(t).delete(e.name);let n=Dr.properties?Dr.properties.maxMonomerLength:4;if(ke.gp.maxMonomerLength in e.tags){const t=parseInt(e.getTag(ke.gp.maxMonomerLength));n=isNaN(t)?n:t}if(".mm.cellRenderer.maxMonomerLength"in e.temp){const t=parseInt(e.temp[".mm.cellRenderer.maxMonomerLength"]);n=isNaN(t)?n:t}const i=s.input.int("Max Monomer Length",{value:n,nullable:!0,min:1,max:50,step:1,onValueChanged:t=>{if(0==t)setTimeout(()=>{i.value=null},0);else{const n=t??"",i=null==n?"":n.toString();e.temp[".mm.cellRenderer.maxMonomerLength"]=i,e.temp[".mm.cellRenderer.settingsChanged"]=Ve.s.true,e.dataFrame.fireValuesChanged()}},tooltipText:"The max length of monomer symbol displayed without shortening, empty to no limit"});let o=Dr.properties?Dr.properties.fontSize:12;".mm.cellRenderer.fontSize"in e.temp&&e.temp[".mm.cellRenderer.fontSize"]&&!isNaN(e.temp[".mm.cellRenderer.fontSize"])&&(o=e.temp[".mm.cellRenderer.fontSize"]);const r=s.input.int("Font Size",{value:o,nullable:!0,min:1,max:50,step:1,onValueChanged:t=>{if(t&&t>0){const n=t??12;e.temp[".mm.cellRenderer.fontSize"]=n,e.temp[".mm.cellRenderer.settingsChanged"]=Ve.s.true,e.dataFrame.fireValuesChanged()}},tooltipText:"The font size of monomer symbol in sequence renderer"}),l=s.input.int("Monomer Margin",{value:e.temp[".mm.cellRenderer.gapLength"]??0,onValueChanged:t=>{e.temp[".mm.cellRenderer.gapLength"]=t,e.temp[".mm.cellRenderer.settingsChanged"]=Ve.s.true,e.dataFrame.fireValuesChanged()},tooltipText:"The size of margin between monomers (in pixels)"}),c=s.input.bool("Color Code",{value:null==e?.temp["color-code"]||e.temp["color-code"],onValueChanged:t=>{e.temp["color-code"]=t,e.dataFrame.fireValuesChanged()},tooltipText:"Color code"}),h=s.input.string("Reference Sequence",{value:null!=e?.temp["reference-sequence"]?e?.temp["reference-sequence"]:"",nullable:!0,onValueChanged:t=>{e.temp["reference-sequence"]=t,e.dataFrame.fireValuesChanged()},tooltipText:"Reference sequence is not empty, then the sequence will be render \nas a difference from the reference sequence"}),u=s.input.bool("Compare with current",{value:null==e?.temp["compare-with-current"]||e.temp["compare-with-current"],onValueChanged:t=>{e.temp["compare-with-current"]=t,e.dataFrame.fireValuesChanged()},tooltipText:'When on, all sequences get rendered in the "diff" mode'});let d=null;e.meta.units!==me.Hi.HELM&&(d=s.input.bool("Multiline Rendering",{value:"true"===e.getTag("renderMultiline"),onValueChanged:t=>{e.tags.renderMultiline=t?"true":"false",e.dataFrame.fireValuesChanged()},tooltipText:"Render sequences across multiple lines when they exceed cell width"}));const p=[r,i,l,h,c,u];d&&p.push(d);const m=s.inputs(p);return new a.Widget(m)}(e)}static compositionAnalysisWidget(e){return function(e,t,n){const i=s.div();i.classList.add("macromolecule-cell-comp-analysis-host");const o=e.cell.column.tags[me.gp.alphabet],r=o===me.YI.DNA||o===me.YI.RNA?De.o.NUCLEOTIDE:De.o.AA,l={},c=n.getSeqHandler(e.cell.column),h=e.cell.rowIndex,u=c.getSplitted(h),d={};R().count(0).take(u.length).filter(e=>!u.isGap(e)).forEach(e=>{let t=u.getCanonical(e);r===De.o.NUCLEOTIDE&&c.isHelm()&&"("===t[1]&&")"===t[t.length-2]&&(t=t.substring(2,t.length-2));const n=l[t]||0;if(l[t]=n+1,!d[t]&&u.graphInfo?.polymerTypes){const n=u.graphInfo.polymerTypes[e];d[t]=(0,Fe.MD)(n)}});const p=(0,pi.F)(l,r,t,Object.keys(d).length?d:void 0);return Array.from(p.rows).forEach(e=>{const t=e.getElementsByClassName("macromolecule-cell-comp-analysis-bar")[0].style.backgroundColor;e.cells[0].style.color=t}),i.appendChild(p),new a.Widget(i)}(e,Dr.monomerLib,Dr.seqHelper)}static macromoleculeDifferenceCellRenderer(){return new Ze}static sequenceAlignment(e,t,n,i,o){const r=new dt(i,o,n,t);return"Local alignment"==e?r.smithWaterman():r.needlemanWunsch()}static webLogoViewer(){return new ot.oP}static vdRegionsViewer(){return new ct}static getRegion(e,t,n,i){return yi(e,t??null,n??null,i??null)}static async getRegionTopMenu(e,t,n,i,o){const s=yi(t,n??null,i??null,o??null);t.dataFrame.columns.add(s),await r.data.detectSemanticTypes(t.dataFrame)}static async activityCliffs(e,t,n,i,o,h,u,d,p){if(e.name!==r.shell.tv.dataFrame.name)return void r.shell.error(`Table ${e.name} is not a current table view`);if(!(0,ti.V)(t,"Activity Cliffs"))return;const m=_e(e),g={units:t.meta.units,aligned:t.getTag(me.gp.aligned),separator:t.getTag(me.gp.separator),alphabet:t.getTag(me.gp.alphabet)},f=h,y=t,b=async()=>await de(e,y,m,"Activity cliffs",n,i,f,o,{...d??{}},a.SEMTYPE.MACROMOLECULE,g,u,gt,ft,wt,void 0,p),v=o===c.c.UMAP?2e5:2e4,w=o===c.c.UMAP?5e3:2e3;if(e.rowCount>v)return void r.shell.warning(`Too many rows, maximum for sequence activity cliffs is ${v}`);const C=a.TaskBarProgressIndicator.create("Running sequence activity cliffs ..."),S=await new Promise((t,n)=>{e.rowCount>w&&!d?.[l.vb]?s.dialog().add(s.divText("Activity cliffs analysis might take several minutes.\n Do you want to continue?")).onOK(async()=>{b().then(e=>t(e)).catch(e=>n(e))}).onCancel(()=>{t(void 0)}).show():b().then(e=>t(e)).catch(e=>n(e))}).catch(e=>{const[t,n]=(0,Se.AP)(e);throw Dr.logger.error(t,void 0,n),e}).finally(()=>{C.close()});return S?.props?.xColumnName&&S?.props?.yColumnName&&e.col(S.props.xColumnName)&&e.col(S.props.yColumnName)&&(e.col(S.props.xColumnName).set(0,e.col(S.props.xColumnName).get(0)),e.col(S.props.yColumnName).set(0,e.col(S.props.yColumnName).get(0))),S}static async macromoleculePreprocessingFunction(e,t,n=1,i=.6,o="Morgan"){if(e.semType!==a.SEMTYPE.MACROMOLECULE)return{entries:e.toList(),options:{}};const{seqList:r,options:s}=await pt(e,t,o,n,i);return{entries:r,options:s}}static async helmPreprocessingFunction(e,t){e.version!==e.temp["last-invalidated-version"]&&await(0,mt.BQ)(e,Dr.seqHelper,!1);const n=e.temp["monomeric-mols"],i=await r.functions.call("Chem:getMorganFingerprints",{molColumn:n}),o=new Array(i.length).fill(null);for(let e=0;e<i.length;e++){if(i.isNone(e)||!i.get(e))continue;const t=i.get(e);o[e]=j.A.fromUint32Array(t.length,new Uint32Array(t.getBuffer().buffer))}return{entries:o,options:{}}}static async sequenceSpaceTopMenu(e,t,n,i,o,s,c,h,u){if(e.name!==r.shell.tv.dataFrame.name)return void r.shell.error(`Table ${e.name} is not a current table view`);const d=r.shell.tv.dataFrame==e?r.shell.tv:void 0;return(0,ti.V)(t,"Sequence Space")?(s||(s=a.Func.find({name:"macromoleculePreprocessingFunction",package:"Bio"})[0]),c??={},await Le(e,[t],n,[i],[1],[s],"MANHATTAN",o,h??!1,{...c,preprocessingFuncArgs:[c.preprocessingFuncArgs??{}]},{fastRowCount:1e4,scatterPlotName:"Sequence space",bypassLargeDataWarning:c?.[l.vb],tableView:d})):void 0}static async toAtomicLevel(e,t,n,i=!1){const o=a.TaskBarProgressIndicator.create("Converting to atomic level ...");try{await Vr;const o=t.temp[".mm.cellRenderer.overriddenLibrary"]??Dr.monomerLib,r=Dr.seqHelper,s=Dr.rdKitModule;await(0,Ci.V)(e,t,n,i,o,r,s)}finally{o.close()}}static async toAtomicLevelAction(e){if(!e?.dataFrame)throw new Error("Sequence column is not found or its data frame is not empty");const t=a.Func.find({name:"toAtomicLevel",package:"Bio"})[0];if(!t)throw new Error("To Atomic level Function not found");t.prepare({table:e.dataFrame,seqCol:e}).edit()}static async toAtomicLevelPanel(e){return async function(e){const t=await Ki(e);if(t.errorText||!t.mol)return a.Widget.fromRoot(s.divText(t.errorText??"No structure generated"));try{const e=a.SemanticValue.fromValueType(t.mol,a.SEMTYPE.MOLECULE),n=s.panels.infoPanel(e);let i=null;n&&(i=a.Widget.fromRoot(n.root));const o=r.chem.drawMolecule(t.mol,300,300,!1);return o.style.cursor="pointer",s.tooltip.bind(o,"Click to expand"),o.onclick=()=>{const e=window.innerWidth-200,n=window.innerHeight-200,i=r.chem.drawMolecule(t.mol,e,n,!1);s.dialog({title:"Molecule"}).add(i).showModal(!0)},i&&i.root.prepend(o),i??a.Widget.fromRoot(o)}catch(e){Dr.logger.error(e)}return a.Widget.fromRoot(s.divText("No structure generated"))}(e)}static async sequence3dStructureWidget(e){return async function(e){const t=a.TaskBarProgressIndicator.create("Creating 3D view");let n,i="";try{await(a.Func.find({name:"getPdbHelper"})[0]?.apply({}));try{const o=await Ki(e);if(o.errorText||!o.mol)return n=s.divText(o.errorText??"No structure generated"),t.close(),new a.Widget(n);const l=o.mol;i=await r.functions.call("Bio:Embed",{molecule:l});const c=Ei.Molecule.fromMolfile(i);c?i=c.toMolfile():console.warn("Failed to convert molv3 to molv2")}catch(e){console.warn(e)}try{i=i.replaceAll("\\n","\n");const e=new Blob([i],{type:"text/plain"}),t=s.div([],{classes:"d4-ngl-viewer",id:"ngl-3d-host"});t.style.setProperty("height","100%","important");const o=new NGL.Stage(t,{backgroundColor:"white"});o.loadFile(e,{ext:"sdf"}).then(function(e){o.setSize(300,300),e.addRepresentation("ball+stick"),e.autoView()}),n=s.div([t],{style:{aspectRatio:"1"}})}catch(e){n=s.divText("Couldn't get 3D structure")}}catch(e){n=s.divText("Couldn't get 3D structure")}return t.close(),new a.Widget(n)}(e)}static multipleSequenceAlignmentDialog(){(0,ii.D)({},Dr.seqHelper).catch(e=>{const[t,n]=(0,Se.AP)(e);if(e instanceof ni.Ap)return r.shell.warning(e.element),void Dr.logger.warning(t);r.shell.error(t),Dr.logger.error(t,void 0,n)})}static async alignSequences(e=null,t=null,n){return(0,ii.D)({col:e,clustersCol:t,...n},Dr.seqHelper)}static async compositionAnalysis(){const e=r.shell.tv,t=e.dataFrame.columns.toList().filter(e=>e.semType==a.SEMTYPE.MACROMOLECULE&&(Dr.seqHelper.getSeqHandler(e),!0)),n=async t=>{if(!(0,ti.V)(t,"Composition"))return;const n=e.addViewer("WebLogo",{sequenceColumnName:t.name});r.shell.tv.dockManager.dock(n,a.DOCK_TYPE.DOWN,null,"Composition analysis",.25)};let i=null;if(0!=t.length){if(t.length>1){const e=t.map(e=>e.name),i=t.find(e=>Dr.seqHelper.getSeqHandler(e).isMsa()),o=s.input.choice("Column",{value:i?i.name:e[0],items:e});s.dialog({title:"Composition Analysis",helpUrl:"https://datagrok.ai/help/datagrok/solutions/domains/bio/#sequence-composition"}).add(s.div([o])).onOK(async()=>{const e=t.find(e=>e.name==o.value)??null;e&&await n(e)}).show()}else i=t[0];i&&await n(i)}else r.shell.error("Current table does not contain sequences")}static importFasta(e){return new ge.m(e).importFasta()}static importBam(e){return console.log(e),[]}static convertDialog(){const e=(0,Oe.me)()[0];(0,Tt.C)(e,Dr.seqHelper)}static convertColumnAction(e){(0,Tt.C)(e,Dr.seqHelper)}static monomerCellRenderer(){return new ci}static async testDetectMacromolecule(e){const t=a.TaskBarProgressIndicator.create("Test detectMacromolecule..."),n=(await r.dapi.files.list(e,!0,"")).filter(e=>e.fileName.endsWith(".csv"));let i=0;const o=[];for(const s of n)try{const t=await r.dapi.files.readAsText(e+s.fullPath),n=a.DataFrame.fromCsv(t);for(const e of n.columns)await r.functions.call("Bio:detectMacromolecule",{col:e})===a.SEMTYPE.MACROMOLECULE&&o.push({file:s.path,result:"detected",column:e.name,message:`units: ${e.meta.units}`})}catch(e){o.push({file:s.path,result:"error",column:null,message:e instanceof Error?e.message:e.toString()})}finally{i+=1,t.update(100*i/n.length,`Test ${s.fileName}`)}r.shell.info("Test Demo:Files for detectMacromolecule finished."),t.close();const s=a.DataFrame.fromObjects(o);return s.name=`datasets_detectMacromolecule_${e}`,s}static async splitToMonomersTopMenu(e,t){return await async function(e,t){if(await(0,et.cb)(10),!(0,ti.V)(t,"Sequence space"))return e;const n=ye(t,Dr.seqHelper);n.name="splitToMonomers";const i=t.dataFrame;for(const e of n.columns)e.semType=Ue.uF.MONOMER,e.setTag(ve.gp.alphabet,t.getTag(ve.gp.alphabet));const o=/(\d+)(?: \((\d+)\))?/,s=e=>{o.lastIndex=0;const t=e.match(o);return t?`${t[1]} (${parseInt(t[2]??"0")+1})`:e};for(let e=0;e<n.columns.length;e++){const o=n.columns.byIndex(e);o.semType=Ue.uF.MONOMER,o.setTag(ve.gp.alphabet,t.getTag(ve.gp.alphabet));const r=100;let a=0;for(;i.columns.byName(o.name)&&a<r;)o.name=s(o.name),a++;i.columns.add(o)}await r.data.detectSemanticTypes(i);for(let e=0;e<n.columns.length;e++){const t=n.columns.byIndex(e);t.setTag(a.TAGS.CELL_RENDERER,"Monomer"),t.setTag(".use-as-filter","false")}return i}(e,t)}static getHelmMonomers(e){return Dr.seqHelper.getSeqMonomers(e)}static similaritySearchViewer(){return new xt(Dr.seqHelper)}static similaritySearchTopMenu(){const e=r.shell.v,t=e.addViewer("Sequence Similarity Search");e.dockManager.dock(t,"down")}static diversitySearchViewer(){return new Et(Dr.seqHelper)}static diversitySearchTopMenu(){const e=r.shell.v,t=e.addViewer("Sequence Diversity Search");e.dockManager.dock(t,"down")}static searchSubsequenceEditor(e){const t=(0,Oe.me)();1===t.length?e.func.prepare({macromolecules:t[0]}).call(!0):new mt.a7(t,Dr.seqHelper)}static SubsequenceSearchTopMenu(e){r.shell.tv.getFiltersGroup({createDefaultFilters:!1}).updateOrAdd({type:"Bio:bioSubstructureFilter",column:e.name,columnName:e.name}),r.shell.tv.grid.scrollToCell(e,0)}static async sequenceIdentityScoring(e,t,n){const i=Dr.seqHelper;return Si(e,t,n,be.IDENTITY,i)}static async sequenceSimilarityScoring(e,t,n){const i=Dr.seqHelper;return Si(e,t,n,be.SIMILARITY,i)}static async manageMonomerLibraries(){Un()}static async manageLibrariesView(){await qn()}static async manageMonomersView(){const e=await nn.getInstance();await e.getViewRoot()}static async manageMonomerLibrariesView(){return await qn(!1)}static async manageMonomerLibrariesViewTreeBrowser(e){(await(await Hn.getInstance()).getAvaliableLibraryNames()).forEach(t=>{const n=t.endsWith(".json")?t.substring(0,t.length-5):t;e.item(n).onSelected.subscribe(async()=>{const e=await nn.getInstance();await e.getViewRoot(t,!0),e.resetCurrentRowFollowing()})})}static saveAsFasta(){(0,_t.TE)()}static bioSubstructureFilter(){return new It._i(Dr.seqHelper,Dr.logger)}static bioSubstructureFilterTest(){return new It._i(Dr.seqHelper,Dr.logger)}static async webLogoLargeApp(){const e=a.TaskBarProgressIndicator.create("WebLogo");try{const e=new URLSearchParams(window.location.search),t=new oi(e,"webLogoLargeApp"),n=await Dr.files.readCsv("data/sample_PT_100000x5.csv");await r.data.detectSemanticTypes(n),await t.init(n)}finally{e.close()}}static async webLogoAggApp(){const e=a.TaskBarProgressIndicator.create("WebLogo ...");try{const e=new URLSearchParams(window.location.search),t=new oi(e,"webLogoAggApp"),n=await Dr.files.readCsv("samples/FASTA_PT_activity.csv");await r.data.detectSemanticTypes(n),await t.init(n)}finally{e.close()}}static async getRegionApp(){const e=a.TaskBarProgressIndicator.create("getRegion ...");try{const e=new URLSearchParams(window.location.search),t=new vi(e,"getRegionApp");await t.init()}finally{e.close()}}static async getRegionHelmApp(){const e=a.TaskBarProgressIndicator.create("getRegion ...");try{const e=new URLSearchParams(window.location.search),t=await Dr.files.readCsv("samples/HELM_empty_vals.csv"),n=new vi(e,"getRegionHelmApp");await n.init({df:t,colName:"HELM"})}finally{e.close()}}static longSeqTableSeparator(){const e=a.DataFrame.fromColumns((0,Ne.dW)());r.shell.addTableView(e)}static longSeqTableFasta(){const e=a.DataFrame.fromColumns([(0,Ne.Hx)(Dr.seqHelper,me.Hi.FASTA)]);r.shell.addTableView(e)}static longSeqTableHelm(){const e=a.DataFrame.fromColumns([(0,Ne.Hx)(Dr.seqHelper,me.Hi.HELM)]);r.shell.addTableView(e)}static addCopyMenu(e,t){!function(e,t,n){const i=Object.values(me.Hi).filter(e=>e!==me.Hi.CUSTOM);t.group("Copy").items(i,t=>{const i=e.column,o=e.rowIndex,s=n.getSeqHandler(i),a=t===me.Hi.SEPARATOR?Dr.properties.defaultSeparator??"-":void 0,l=s.getJoiner({notation:t,separator:a})(s.getSplitted(o));navigator.clipboard?(navigator.clipboard.writeText(l),r.shell.info(`Value of notation '${t}' copied to clipboard`)):r.shell.warning("The clipboard functionality requires a secure origin — either HTTPS or localhost")})}(e,t,Dr.seqHelper)}static async demoBioSimilarityDiversity(){await async function(){const e=await Dr.files.readCsv("samples/peptides-non-natural.csv");e.name="Similarity and Diversity Demo",e.col("activity").setTag("format","3 significant digits"),e.col("sequence").temp[".mm.cellRenderer.maxMonomerLength"]=4;const t=r.shell.addTableView(e);await e.meta.detectSemanticTypes(),await r.data.detectSemanticTypes(e);const n=t.addViewer("Sequence Similarity Search",{limit:20}),i=t.dockManager.dock(n,a.DOCK_TYPE.RIGHT,null,"Similarity search",.45);(0,Oe.Kd)(t.grid,"sequence",500,30);const o=t.addViewer("Sequence Diversity Search",{limit:20});t.dockManager.dock(o,a.DOCK_TYPE.DOWN,i,"Diversity search",.4),r.functions.call("Dendrogram:HierarchicalClustering",{df:r.shell.t,colNameList:["sequence"],distance:"euclidian",linkage:"complete"})}()}static async demoBioSequenceSpace(){await async function(){const e=await r.functions.eval("Bio:SeqSpaceDemo"),t=await r.dapi.projects.find(e.id);await t.open(),r.shell.windows.help.showHelp("/help/datagrok/solutions/domains/bio/bio.md#sequence-space")}()}static async demoBioActivityCliffs(){await async function(){const e=await Dr.files.readCsv("tests/helm_cyclic_cliffs.csv");e.name="Activity Cliffs Demo",await r.data.detectSemanticTypes(e),await e.meta.detectSemanticTypes();const t=r.shell.addTableView(e);s.setUpdateIndicator(t.root,!0);try{const n=a.Func.find({name:"macromoleculePreprocessingFunction",package:"Bio"})[0],i=await Wr.activityCliffs(e,e.getCol("Sequence"),e.getCol("Activity"),96,c.c.UMAP,pe.Z.MONOMER_CHEMICAL_DISTANCE,n,{},!0);t.dockManager.dock(i,a.DOCK_TYPE.RIGHT,null,"Activity Cliffs",.65),await a.delay(100),Gn()(i.root).find("button.scatter_plot_link,cliffs_grid").get()[0].click(),await a.delay(100),t.grid.props.rowHeight=180,t.grid.col("sequence")&&(t.grid.col("sequence").width=300),t.grid.col("structure")&&(t.grid.col("structure").width=300);const o=Array.from(t.viewers).find(e=>e!==t.grid&&e.type===a.VIEWER.GRID);o&&(o.props.rowHeight=40,o.col("seq_diff").width=600,t.dockManager.dock(o,a.DOCK_TYPE.DOWN,null,"Cliffs",.35),t.dockManager.dock(i,a.DOCK_TYPE.RIGHT,null,"Activity Cliffs",.55))}catch(e){!function(e){const t=e instanceof Error?e.message:e.toString(),n=e instanceof Error?e.stack:void 0;r.shell.error(t),Dr.logger.error(e.message,void 0,n)}(e)}finally{s.setUpdateIndicator(t.root,!1)}r.shell.windows.help.showHelp("/help/datagrok/solutions/domains/bio/bio.md#activity-cliffs")}()}static async demoBioAtomicLevel(){await async function(){const e=await Dr.files.readCsv("samples/HELM_BI_CYCLIC.csv");e.name="To Atomic Level",await e.meta.detectSemanticTypes(),await r.data.detectSemanticTypes(e);const t=r.shell.addTableView(e),n=e.col("HELM");await Wr.toAtomicLevel(e,n,!0,!1),(0,Oe.Kd)(t.grid,"molfile(HELM)",500,300,!0),(0,Oe.Kd)(t.grid,"HELM",500,void 0,!0),r.shell.info("Hover over monomers in HELM column to highlight them in molecular structure.",{timeout:10}),r.shell.windows.help.showHelp("/help/datagrok/solutions/domains/bio/bio.md#convert-to-atomic-level")}()}static async sdfToJsonLib(e){const t=function(e){const t=[];for(let n=0;n<e.rowCount;n++){const i={};Object.keys(fe.Ec).forEach(t=>{if("symbol"===t){const o=e.get(fe.Ec[t],n);i[t]="."===o?e.get(fe.yw,n):o}else if("rgroups"===t){const o=e.get(fe.Ec[t],n).split("\n"),r=[];o.forEach(e=>{const t={},n=e.substring(e.lastIndexOf("]")+1),i=e.match(/\[R(\d+)\]/)[1];t.capGroupSmiles="H"===n?`[*:${i}][H]`:`O[*:${i}]`,t.alternateId="H"===n?`R${i}-H`:`R${i}-OH`,t.capGroupName="H"===n?"H":"OH",t.label=`R${i}`,r.push(t)}),i[t]=r}else fe.Ec[t]&&(i[t]=e.get(fe.Ec[t],n))}),i.author??(i.author=""),i.id??(i.id=0),i.smiles??(i.smiles=""),i.monomerType??(i.monomerType="Backbone"),i.createDate??(i.createDate=null),t.push(i)}return t}(e),n=JSON.stringify(t);a.Utils.download(`${e.name}.json`,n)}static async seq2atomic(e,t){if(!e.trim())return"";try{const n=a.Column.fromList(a.COLUMN_TYPE.STRING,"helm",[e]),i=a.DataFrame.fromColumns([n]),o=await r.functions.call("Bio:detectMacromolecule",{col:n});o&&(n.semType=o);const s=(await Wr.getMonomerLibHelper()).getMonomerLib(),l=Dr.seqHelper,c=await(0,Re.j)(),h=(await(0,Ci.V)(i,n,t,!1,s,l,c))?.molCol?.get(0);return h??void 0}catch(e){const[t,n]=(0,Se.AP)(e);throw Dr.logger.error(t,void 0,n),e}}static async seqIdentity(e,t){if(!e.trim())return null;try{const n=a.Column.fromList(a.COLUMN_TYPE.STRING,"seq",[e]),i=a.DataFrame.fromColumns([n]);if(!await r.functions.call("Bio:detectMacromolecule",{col:n}))throw new Error("Macromolecule required");return(await Si(i,n,t,be.IDENTITY,Dr.seqHelper)).get(0)}catch(e){const[t,n]=(0,Se.AP)(e);throw Dr.logger.error(t,void 0,n),e}}static async detectMacromoleculeProbe(e,t="",n=100){const i=await e.readAsString();await async function(e,t,n){const i=a.TaskBarProgressIndicator.create("detectMacromolecule probe ...");try{let o=0;const s=await r.functions.call("Bio:detectMacromoleculeEnableStore");let l=0;for(let c=0;c<n;++c){const h=a.DataFrame.fromCsv(e),u=t?h.getCol(t):h.columns.byIndex(0);await r.functions.call("Bio:detectMacromolecule",{col:u})!==a.SEMTYPE.MACROMOLECULE&&(++l,console.warn(`Reject reason: ${s.last.rejectReason}`));const d=c/n;d-o>=.1&&(o=d,i.update(100*d,`detectMacromolecule probe ${l}/${c}/${n} ...`),await(0,et.cb)(0))}l>0?r.shell.warning(`detectMacromolecule failed ${l} / ${n}`):r.shell.info(`detectMacromolecule success ${n}`)}finally{i.close()}}(i,t,n)}static async getSeqHelper(){return await Wr.initBio(),Dr.seqHelper}static async getMolFromHelm(e,t,n=!0){return async function(e,t,n=!0,i){const o=Dr.seqHelper,r=(await o.getHelmToMolfileConverter(i)).convertToRdKitBeautifiedMolfileColumn(t,n,Dr.rdKitModule,i);return r.semType=a.SEMTYPE.MOLECULE,r}(0,t,n,Dr.monomerLib)}}Fr([r.decorators.func({description:"Returns an instance of the monomer library helper",outputs:[{type:"object",name:"result"}]}),Gr("design:type",Function),Gr("design:paramtypes",[]),Gr("design:returntype",Promise)],Wr,"getMonomerLibHelper",null),Fr([r.decorators.init({}),Gr("design:type",Function),Gr("design:paramtypes",[]),Gr("design:returntype",Promise)],Wr,"initBio",null),Fr([r.decorators.func({tags:["tooltip"]}),Br(0,r.decorators.param({options:{semType:"Macromolecule"}})),Gr("design:type",Function),Gr("design:paramtypes",[a.Column]),Gr("design:returntype",a.Widget)],Wr,"sequenceTooltip",null),Fr([r.decorators.func({}),Gr("design:type",Function),Gr("design:paramtypes",[String]),Gr("design:returntype",Promise)],Wr,"standardiseMonomerLibrary",null),Fr([r.decorators.func({"top-menu":"Bio | Manage | Match with Monomer Library...",description:"Matches molecules in a column with monomers from the selected library(s)"}),Br(1,r.decorators.param({type:"column",options:{semType:"Molecule"}})),Br(2,r.decorators.param({type:"string",options:{choices:["PEPTIDE","RNA","CHEM"],initialValue:"PEPTIDE",caption:"Polymer Type"}})),Gr("design:type",Function),Gr("design:paramtypes",[a.DataFrame,a.Column,String]),Gr("design:returntype",Promise)],Wr,"matchWithMonomerLibrary",null),Fr([r.decorators.func({outputs:[{type:"object",name:"monomerLib"}]}),Gr("design:type",Function),Gr("design:paramtypes",[]),Gr("design:returntype",Object)],Wr,"getBioLib",null),Fr([r.decorators.func({outputs:[{type:"object",name:"result"}]}),Br(0,r.decorators.param({type:"column",options:{semType:"Macromolecule"}})),Gr("design:type",Function),Gr("design:paramtypes",[a.Column]),Gr("design:returntype",Object)],Wr,"getSeqHandler",null),Fr([r.decorators.panel({name:"Bioinformatics | Get Region",description:"Creates a new column with sequences of the region between start and end"}),Br(0,r.decorators.param({type:"column",options:{semType:"Macromolecule"}})),Gr("design:type",Function),Gr("design:paramtypes",[a.Column]),Gr("design:returntype",a.Widget)],Wr,"getRegionPanel",null),Fr([r.decorators.panel({name:"Bioinformatics | Manage Monomer Libraries",tags:["exclude-actions-panel"]}),Br(0,r.decorators.param({name:"seqColumn",options:{semType:"Macromolecule"}})),Gr("design:type",Function),Gr("design:paramtypes",[a.Column]),Gr("design:returntype",Promise)],Wr,"libraryPanel",null),Fr([r.decorators.editor({}),Gr("design:type",Function),Gr("design:paramtypes",[a.FuncCall]),Gr("design:returntype",void 0)],Wr,"GetRegionEditor",null),Fr([r.decorators.editor({}),Gr("design:type",Function),Gr("design:paramtypes",[a.FuncCall]),Gr("design:returntype",void 0)],Wr,"SplitToMonomersEditor",null),Fr([r.decorators.editor({}),Gr("design:type",Function),Gr("design:paramtypes",[a.FuncCall]),Gr("design:returntype",void 0)],Wr,"SequenceSpaceEditor",null),Fr([r.decorators.editor({}),Gr("design:type",Function),Gr("design:paramtypes",[a.FuncCall]),Gr("design:returntype",void 0)],Wr,"SeqActivityCliffsEditor",null),Fr([r.decorators.func({name:"customSequenceCellRenderer",tags:["cellRenderer"],meta:{cellType:"sequence",columnTags:"quality=Macromolecule, units=custom"},outputs:[{type:"grid_cell_renderer",name:"result"}]}),Gr("design:type",Function),Gr("design:paramtypes",[]),Gr("design:returntype",a.GridCellRenderer)],Wr,"customSequenceCellRenderer",null),Fr([r.decorators.func({name:"fastaSequenceCellRenderer",tags:["cellRenderer"],meta:{cellType:"sequence",columnTags:"quality=Macromolecule, units=fasta"},outputs:[{type:"grid_cell_renderer",name:"result"}]}),Gr("design:type",Function),Gr("design:paramtypes",[]),Gr("design:returntype",Ye)],Wr,"fastaSequenceCellRenderer",null),Fr([r.decorators.func({name:"separatorSequenceCellRenderer",tags:["cellRenderer"],meta:{cellType:"sequence",columnTags:"quality=Macromolecule, units=separator"},outputs:[{type:"grid_cell_renderer",name:"result"}]}),Gr("design:type",Function),Gr("design:paramtypes",[]),Gr("design:returntype",Ye)],Wr,"separatorSequenceCellRenderer",null),Fr([r.decorators.func({name:"bilnSequenceCellRenderer",tags:["cellRenderer"],meta:{cellType:"sequence",columnTags:"quality=Macromolecule, units=biln"},outputs:[{type:"grid_cell_renderer",name:"result"}]}),Gr("design:type",Function),Gr("design:paramtypes",[]),Gr("design:returntype",Ye)],Wr,"bilnSequenceCellRenderer",null),Fr([r.decorators.func({name:"refineNotationProviderForBiln",tags:["notationRefiner"],outputs:[{type:"bool",name:"result"}]}),Br(0,r.decorators.param({type:"column"})),Br(1,r.decorators.param({type:"object"})),Br(2,r.decorators.param({type:"string",options:{nullable:!0,optional:!0}})),Gr("design:type",Function),Gr("design:paramtypes",[a.Column,Object,Object]),Gr("design:returntype",Boolean)],Wr,"refineNotationProviderForBiln",null),Fr([r.decorators.panel({name:"Bioinformatics | Sequence Renderer"}),Br(0,r.decorators.param({options:{semType:"Macromolecule"}})),Gr("design:type",Function),Gr("design:paramtypes",[a.Column]),Gr("design:returntype",a.Widget)],Wr,"macroMolColumnPropertyPanel",null),Fr([r.decorators.panel({name:"Composition analysis",tags:["bio","widgets"]}),Br(0,r.decorators.param({options:{semType:"Macromolecule"}})),Gr("design:type",Function),Gr("design:paramtypes",[a.SemanticValue]),Gr("design:returntype",a.Widget)],Wr,"compositionAnalysisWidget",null),Fr([r.decorators.func({name:"MacromoleculeDifferenceCellRenderer",tags:["cellRenderer"],meta:{cellType:"MacromoleculeDifference",columnTags:"quality=MacromoleculeDifference"},outputs:[{type:"grid_cell_renderer",name:"result"}]}),Gr("design:type",Function),Gr("design:paramtypes",[]),Gr("design:returntype",Ze)],Wr,"macromoleculeDifferenceCellRenderer",null),Fr([r.decorators.func({outputs:[{type:"object",name:"result"}]}),Br(0,r.decorators.param({options:{choices:["Local alignment","Global alignment"]}})),Br(1,r.decorators.param({options:{choices:["AUTO","NUCLEOTIDES","BLOSUM45","BLOSUM50","BLOSUM62","BLOSUM80","BLOSUM90","PAM30","PAM70","PAM250","SCHNEIDER","TRANS"]}})),Gr("design:type",Function),Gr("design:paramtypes",[String,String,Number,String,String]),Gr("design:returntype",void 0)],Wr,"sequenceAlignment",null),Fr([r.decorators.panel({name:"WebLogo",description:"WebLogo",tags:["viewer"],meta:{icon:"files/icons/weblogo-viewer.svg"},outputs:[{type:"viewer",name:"result"}]}),Gr("design:type",Function),Gr("design:paramtypes",[]),Gr("design:returntype",void 0)],Wr,"webLogoViewer",null),Fr([r.decorators.panel({name:"VdRegions",description:"V-Domain regions viewer",tags:["viewer"],meta:{icon:"files/icons/vdregions-viewer.svg"},outputs:[{type:"viewer",name:"result"}]}),Gr("design:type",Function),Gr("design:paramtypes",[]),Gr("design:returntype",void 0)],Wr,"vdRegionsViewer",null),Fr([r.decorators.func({name:"getRegion",description:"Gets a new column with sequences of the region between start and end"}),Br(0,r.decorators.param({type:"column"})),Br(1,r.decorators.param({type:"string",options:{optional:!0}})),Br(2,r.decorators.param({type:"string",options:{optional:!0}})),Br(3,r.decorators.param({type:"string",options:{optional:!0,description:"Name of the column to be created"}})),Gr("design:type",Function),Gr("design:paramtypes",[a.Column,Object,Object,Object]),Gr("design:returntype",a.Column)],Wr,"getRegion",null),Fr([r.decorators.func({name:"Get Region Top Menu",description:"Get sequences for a region specified from a Macromolecule","top-menu":"Bio | Calculate | Get Region...",editor:"Bio:GetRegionEditor"}),Br(0,r.decorators.param({options:{description:"Input data table"}})),Br(1,r.decorators.param({options:{semType:"Macromolecule",description:"Sequence column"}})),Br(2,r.decorators.param({type:"string",options:{optional:!0,description:"Region start position name"}})),Br(3,r.decorators.param({type:"string",options:{optional:!0,description:"Region end position name"}})),Br(4,r.decorators.param({type:"string",options:{optional:!0,description:"Region column name"}})),Gr("design:type",Function),Gr("design:paramtypes",[a.DataFrame,a.Column,Object,Object,Object]),Gr("design:returntype",Promise)],Wr,"getRegionTopMenu",null),Fr([r.decorators.func({name:"Sequence Activity Cliffs",description:"Detects pairs of molecules with similar structure and significant difference in any given property","top-menu":"Bio | Analyze | Activity Cliffs...",editor:"Bio:SeqActivityCliffsEditor",outputs:[]}),Br(0,r.decorators.param({options:{description:"Input data table"}})),Br(1,r.decorators.param({type:"string",options:{semType:"Macromolecule",description:"Input data table"}})),Br(3,r.decorators.param({options:{initialValue:"80",description:"Similarity cutoff"}})),Br(4,r.decorators.param({type:"string",options:{choices:["UMAP","t-SNE"]}})),Br(5,r.decorators.param({type:"string",options:{choices:["Hamming","Levenshtein","Monomer chemical distance"]}})),Br(6,r.decorators.param({type:"func"})),Br(7,r.decorators.param({type:"object",options:{optional:!0}})),Br(8,r.decorators.param({options:{optional:!0}})),Gr("design:type",Function),Gr("design:paramtypes",[a.DataFrame,a.Column,a.Column,Number,String,String,a.Func,Object,Boolean]),Gr("design:returntype",Promise)],Wr,"activityCliffs",null),Fr([r.decorators.func({name:"Encode Sequences",tags:["dim-red-preprocessing-function"],meta:{supportedSemTypes:"Macromolecule",supportedTypes:"string",supportedDistanceFunctions:"Hamming,Levenshtein,Monomer chemical distance,Needlemann-Wunsch"},outputs:[{type:"object",name:"result"}]}),Br(0,r.decorators.param({options:{semType:"Macromolecule"}})),Br(1,r.decorators.param({type:"string"})),Br(2,r.decorators.param({options:{initialValue:"1",caption:"Gap open penalty",optional:!0}})),Br(3,r.decorators.param({options:{initialValue:"0.6",caption:"Gap extension penalty",optional:!0}})),Br(4,r.decorators.param({options:{caption:"Fingerprint type",initialValue:"Morgan",choices:["Morgan","RDKit","Pattern","AtomPair","MACCS","TopologicalTorsion"],optional:!0}})),Gr("design:type",Function),Gr("design:paramtypes",[a.Column,String,Number,Number,String]),Gr("design:returntype",Promise)],Wr,"macromoleculePreprocessingFunction",null),Fr([r.decorators.func({name:"Helm Fingerprints",meta:{supportedSemTypes:"Macromolecule",supportedTypes:"string",supportedUnits:"helm",supportedDistanceFunctions:"Tanimoto,Asymmetric,Cosine,Sokal"},outputs:[{type:"object",name:"result"}]}),Br(0,r.decorators.param({type:"column",options:{semType:"Macromolecule"}})),Br(1,r.decorators.param({type:"string"})),Gr("design:type",Function),Gr("design:paramtypes",[a.Column,String]),Gr("design:returntype",Promise)],Wr,"helmPreprocessingFunction",null),Fr([r.decorators.func({name:"Sequence Space",description:"Creates 2D sequence space with projected sequences by pairwise distance","top-menu":"Bio | Analyze | Sequence Space...",editor:"Bio:SequenceSpaceEditor",outputs:[]}),Br(1,r.decorators.param({options:{semType:"Macromolecule"}})),Br(2,r.decorators.param({type:"string",options:{choices:["UMAP","t-SNE"]}})),Br(3,r.decorators.param({type:"string",options:{choices:["Hamming","Levenshtein","Monomer chemical distance"]}})),Br(4,r.decorators.param({options:{initialValue:"true"}})),Br(5,r.decorators.param({type:"func",options:{optional:!0}})),Br(6,r.decorators.param({type:"object",options:{optional:!0}})),Br(7,r.decorators.param({options:{optional:!0,initialValue:"true"}})),Br(8,r.decorators.param({options:{optional:!0}})),Gr("design:type",Function),Gr("design:paramtypes",[a.DataFrame,a.Column,String,String,Boolean,a.Func,Object,Boolean,Boolean]),Gr("design:returntype",Promise)],Wr,"sequenceSpaceTopMenu",null),Fr([r.decorators.func({name:"To Atomic Level",description:"Converts sequences to molblocks","top-menu":"Bio | Transform | To Atomic Level..."}),Br(0,r.decorators.param({options:{description:"Input data table"}})),Br(1,r.decorators.param({options:{semType:"Macromolecule",caption:"Sequence"}})),Br(2,r.decorators.param({options:{initialValue:"false",caption:"Non-linear",description:"Slower mode for cycling/branching HELM structures"}})),Br(3,r.decorators.param({options:{initialValue:"false",caption:"Highlight monomers",description:"Highlight monomers' substructures of the molecule"}})),Gr("design:type",Function),Gr("design:paramtypes",[a.DataFrame,a.Column,Boolean,Boolean]),Gr("design:returntype",Promise)],Wr,"toAtomicLevel",null),Fr([r.decorators.func({name:"To Atomic Level...",meta:{action:"to atomic level"}}),Br(0,r.decorators.param({options:{semType:"Macromolecule"}})),Gr("design:type",Function),Gr("design:paramtypes",[a.Column]),Gr("design:returntype",Promise)],Wr,"toAtomicLevelAction",null),Fr([r.decorators.panel({name:"Molecular Structure",tags:["bio","widgets"]}),Br(0,r.decorators.param({name:"sequence",type:"semantic_value",options:{semType:"Macromolecule"}})),Gr("design:type",Function),Gr("design:paramtypes",[a.SemanticValue]),Gr("design:returntype",Promise)],Wr,"toAtomicLevelPanel",null),Fr([r.decorators.panel({name:"Molecular 3D Structure",tags:["bio","widgets"]}),Br(0,r.decorators.param({type:"semantic_value",options:{semType:"Macromolecule"}})),Gr("design:type",Function),Gr("design:paramtypes",[a.SemanticValue]),Gr("design:returntype",Promise)],Wr,"sequence3dStructureWidget",null),Fr([r.decorators.panel({name:"MSA",description:"Performs multiple sequence alignment",tags:["bio"],"top-menu":"Bio | Analyze | MSA..."}),Gr("design:type",Function),Gr("design:paramtypes",[]),Gr("design:returntype",void 0)],Wr,"multipleSequenceAlignmentDialog",null),Fr([r.decorators.func({name:"Multiple Sequence Alignment",description:"Multiple sequence alignment",tags:["bio"]}),Br(0,r.decorators.param({type:"column",options:{semType:"Macromolecule"}})),Br(1,r.decorators.param({type:"column"})),Br(2,r.decorators.param({type:"object",options:{optional:!0}})),Gr("design:type",Function),Gr("design:paramtypes",[Object,Object,Object]),Gr("design:returntype",Promise)],Wr,"alignSequences",null),Fr([r.decorators.func({name:"Composition Analysis",description:"Visualizes sequence composition on a WebLogo plot","top-menu":"Bio | Analyze | Composition",meta:{icon:"files/icons/composition-analysis.svg"},outputs:[{name:"result",type:"viewer"}]}),Gr("design:type",Function),Gr("design:paramtypes",[]),Gr("design:returntype",Promise)],Wr,"compositionAnalysis",null),Fr([r.decorators.fileHandler({name:"importFasta",description:"Opens FASTA file",ext:"fasta, fna, ffn, faa, frn, fa, fst"}),Gr("design:type",Function),Gr("design:paramtypes",[String]),Gr("design:returntype",Array)],Wr,"importFasta",null),Fr([r.decorators.fileHandler({name:"importBam",description:"Opens Bam file",ext:"bam, bai"}),Gr("design:type",Function),Gr("design:paramtypes",[String]),Gr("design:returntype",Array)],Wr,"importBam",null),Fr([r.decorators.func({name:"convertDialog","top-menu":"Bio | Transform | Convert Sequence Notation..."}),Gr("design:type",Function),Gr("design:paramtypes",[]),Gr("design:returntype",void 0)],Wr,"convertDialog",null),Fr([r.decorators.func({name:"Convert Notation...",meta:{action:"Convert Notation..."}}),Br(0,r.decorators.param({options:{semType:"Macromolecule"}})),Gr("design:type",Function),Gr("design:paramtypes",[a.Column]),Gr("design:returntype",void 0)],Wr,"convertColumnAction",null),Fr([r.decorators.func({name:"monomerCellRenderer",tags:["cellRenderer"],meta:{cellType:"Monomer",columnTags:"quality=Monomer"},outputs:[{type:"grid_cell_renderer",name:"result"}]}),Gr("design:type",Function),Gr("design:paramtypes",[]),Gr("design:returntype",ci)],Wr,"monomerCellRenderer",null),Fr([r.decorators.func({name:"testDetectMacromolecule"}),Br(0,r.decorators.param({options:{choices:["Demo:Files/","System:AppData/"]}})),Gr("design:type",Function),Gr("design:paramtypes",[String]),Gr("design:returntype",Promise)],Wr,"testDetectMacromolecule",null),Fr([r.decorators.func({name:"Split to Monomers","top-menu":"Bio | Transform | Split to Monomers...",editor:"Bio:SplitToMonomersEditor"}),Br(1,r.decorators.param({options:{semType:"Macromolecule"}})),Gr("design:type",Function),Gr("design:paramtypes",[a.DataFrame,a.Column]),Gr("design:returntype",Promise)],Wr,"splitToMonomersTopMenu",null),Fr([r.decorators.func({name:"Bio: getHelmMonomers",outputs:[{name:"result",type:"object"}]}),Br(0,r.decorators.param({type:"column",options:{semType:"Macromolecule"}})),Gr("design:type",Function),Gr("design:paramtypes",[a.Column]),Gr("design:returntype",Array)],Wr,"getHelmMonomers",null),Fr([r.decorators.func({name:"Sequence Similarity Search",tags:["viewer"],meta:{icon:"files/icons/sequence-similarity-viewer.svg"},outputs:[{name:"result",type:"viewer"}]}),Gr("design:type",Function),Gr("design:paramtypes",[]),Gr("design:returntype",xt)],Wr,"similaritySearchViewer",null),Fr([r.decorators.func({name:"similaritySearch",description:"Finds similar sequences","top-menu":"Bio | Search | Similarity Search",outputs:[{name:"result",type:"viewer"}]}),Gr("design:type",Function),Gr("design:paramtypes",[]),Gr("design:returntype",void 0)],Wr,"similaritySearchTopMenu",null),Fr([r.decorators.func({name:"Sequence Diversity Search",tags:["viewer"],meta:{icon:"files/icons/sequence-diversity-viewer.svg"},outputs:[{name:"result",type:"viewer"}]}),Gr("design:type",Function),Gr("design:paramtypes",[]),Gr("design:returntype",Et)],Wr,"diversitySearchViewer",null),Fr([r.decorators.func({name:"diversitySearch",description:"Finds the most diverse sequences","top-menu":"Bio | Search | Diversity Search",outputs:[{name:"result",type:"viewer"}]}),Gr("design:type",Function),Gr("design:paramtypes",[]),Gr("design:returntype",void 0)],Wr,"diversitySearchTopMenu",null),Fr([r.decorators.editor({name:"SearchSubsequenceEditor"}),Gr("design:type",Function),Gr("design:paramtypes",[a.FuncCall]),Gr("design:returntype",void 0)],Wr,"searchSubsequenceEditor",null),Fr([r.decorators.func({name:"Subsequence Search","top-menu":"Bio | Search | Subsequence Search ...",editor:"Bio:SearchSubsequenceEditor"}),Gr("design:type",Function),Gr("design:paramtypes",[a.Column]),Gr("design:returntype",void 0)],Wr,"SubsequenceSearchTopMenu",null),Fr([r.decorators.func({name:"Identity",description:"Adds a column with fraction of matching monomers","top-menu":"Bio | Calculate | Identity..."}),Br(0,r.decorators.param({options:{description:"Table containing Macromolecule column"}})),Br(1,r.decorators.param({options:{semType:"Macromolecule",description:"Sequences to score"}})),Br(2,r.decorators.param({options:{description:"Sequence,matching column format"}})),Gr("design:type",Function),Gr("design:paramtypes",[a.DataFrame,a.Column,String]),Gr("design:returntype",Promise)],Wr,"sequenceIdentityScoring",null),Fr([r.decorators.func({name:"Similarity",description:"Adds a column with similarity scores, calculated as sum of monomer fingerprint similarities","top-menu":"Bio | Calculate | Similarity..."}),Br(0,r.decorators.param({options:{description:"Table containing Macromolecule column"}})),Br(1,r.decorators.param({options:{semType:"Macromolecule",description:"Sequences to score"}})),Br(2,r.decorators.param({options:{description:"Sequence,matching column format"}})),Gr("design:type",Function),Gr("design:paramtypes",[a.DataFrame,a.Column,String]),Gr("design:returntype",Promise)],Wr,"sequenceSimilarityScoring",null),Fr([r.decorators.func({name:"Manage Monomer Libraries",description:"Manage HELM monomer libraries"}),Gr("design:type",Function),Gr("design:paramtypes",[]),Gr("design:returntype",Promise)],Wr,"manageMonomerLibraries",null),Fr([r.decorators.func({name:"Manage Monomer Libraries View","top-menu":"Bio | Manage | Monomer Libraries"}),Gr("design:type",Function),Gr("design:paramtypes",[]),Gr("design:returntype",Promise)],Wr,"manageLibrariesView",null),Fr([r.decorators.func({name:"manageMonomersView",description:"Edit and create monomers","top-menu":"Bio | Manage | Monomers"}),Gr("design:type",Function),Gr("design:paramtypes",[]),Gr("design:returntype",Promise)],Wr,"manageMonomersView",null),Fr([r.decorators.app({name:"Manage Monomer Libraries",browsePath:"Peptides",icon:"files/icons/monomers.png"}),Gr("design:type",Function),Gr("design:paramtypes",[]),Gr("design:returntype",Promise)],Wr,"manageMonomerLibrariesView",null),Fr([r.decorators.func({name:"Monomer Manager Tree Browser",meta:{role:"appTreeBrowser"}}),Gr("design:type",Function),Gr("design:paramtypes",[a.TreeViewGroup]),Gr("design:returntype",Promise)],Wr,"manageMonomerLibrariesViewTreeBrowser",null),Fr([r.decorators.fileExporter({description:"As FASTA..."}),Gr("design:type",Function),Gr("design:paramtypes",[]),Gr("design:returntype",void 0)],Wr,"saveAsFasta",null),Fr([r.decorators.func({name:"Bio Substructure Filter",description:"Substructure filter for macromolecules",tags:["filter"],meta:{semType:"Macromolecule"},outputs:[{type:"filter",name:"result"}]}),Gr("design:type",Function),Gr("design:paramtypes",[]),Gr("design:returntype",It._i)],Wr,"bioSubstructureFilter",null),Fr([r.decorators.func({name:"Bio Substructure Filter Test",description:"Substructure filter for Helm package tests",outputs:[{name:"result",type:"object"}]}),Gr("design:type",Function),Gr("design:paramtypes",[]),Gr("design:returntype",It._i)],Wr,"bioSubstructureFilterTest",null),Fr([r.decorators.func(),Gr("design:type",Function),Gr("design:paramtypes",[]),Gr("design:returntype",Promise)],Wr,"webLogoLargeApp",null),Fr([r.decorators.func(),Gr("design:type",Function),Gr("design:paramtypes",[]),Gr("design:returntype",Promise)],Wr,"webLogoAggApp",null),Fr([r.decorators.func(),Gr("design:type",Function),Gr("design:paramtypes",[]),Gr("design:returntype",Promise)],Wr,"getRegionApp",null),Fr([r.decorators.func(),Gr("design:type",Function),Gr("design:paramtypes",[]),Gr("design:returntype",Promise)],Wr,"getRegionHelmApp",null),Fr([r.decorators.func(),Gr("design:type",Function),Gr("design:paramtypes",[]),Gr("design:returntype",void 0)],Wr,"longSeqTableSeparator",null),Fr([r.decorators.func(),Gr("design:type",Function),Gr("design:paramtypes",[]),Gr("design:returntype",void 0)],Wr,"longSeqTableFasta",null),Fr([r.decorators.func(),Gr("design:type",Function),Gr("design:paramtypes",[]),Gr("design:returntype",void 0)],Wr,"longSeqTableHelm",null),Fr([r.decorators.func(),Br(0,r.decorators.param({type:"object"})),Br(1,r.decorators.param({type:"object"})),Gr("design:type",Function),Gr("design:paramtypes",[a.Cell,a.Menu]),Gr("design:returntype",void 0)],Wr,"addCopyMenu",null),Fr([r.decorators.demo({description:"Sequence similarity tracking and evaluation dataset diversity",demoPath:"Bioinformatics | Similarity, Diversity",path:"/apps/Tutorials/Demo/Bioinformatics/Similarity,%20Diversity"}),Gr("design:type",Function),Gr("design:paramtypes",[]),Gr("design:returntype",Promise)],Wr,"demoBioSimilarityDiversity",null),Fr([r.decorators.demo({description:"Exploring sequence space of Macromolecules, comparison with hierarchical clustering results",demoPath:"Bioinformatics | Sequence Space",path:"/apps/Tutorials/Demo/Bioinformatics/Sequence%20Space",meta:{isDemoDashboard:"true"}}),Gr("design:type",Function),Gr("design:paramtypes",[]),Gr("design:returntype",Promise)],Wr,"demoBioSequenceSpace",null),Fr([r.decorators.demo({description:"Activity Cliffs analysis on Macromolecules data",demoPath:"Bioinformatics | Activity Cliffs",path:"/apps/Tutorials/Demo/Bioinformatics/Activity%20Cliffs"}),Gr("design:type",Function),Gr("design:paramtypes",[]),Gr("design:returntype",Promise)],Wr,"demoBioActivityCliffs",null),Fr([r.decorators.demo({description:"Atomic level structure of Macromolecules",demoPath:"Bioinformatics | Atomic Level",path:"/apps/Tutorials/Demo/Bioinformatics/Atomic%20Level"}),Gr("design:type",Function),Gr("design:paramtypes",[]),Gr("design:returntype",Promise)],Wr,"demoBioAtomicLevel",null),Fr([r.decorators.func({name:"SDF to JSON Library"}),Gr("design:type",Function),Gr("design:paramtypes",[a.DataFrame]),Gr("design:returntype",Promise)],Wr,"sdfToJsonLib",null),Fr([r.decorators.func({friendlyName:"seq2atomic",description:"Converts a `Macromolecule` sequence to its atomic level `Molecule` representation",outputs:[{name:"molfile",type:"string",options:{semType:"Molecule"}}]}),Br(0,r.decorators.param({options:{semType:"Macromolecule"}})),Gr("design:type",Function),Gr("design:paramtypes",[String,Boolean]),Gr("design:returntype",Promise)],Wr,"seq2atomic",null),Fr([r.decorators.func({name:"seqIdentity",friendlyName:"seqIdentity",description:"Gets identity to a reference sequence"}),Br(0,r.decorators.param({options:{semType:"Macromolecule"}})),Br(1,r.decorators.param({options:{semType:"Macromolecule"}})),Gr("design:type",Function),Gr("design:paramtypes",[String,String]),Gr("design:returntype",Promise)],Wr,"seqIdentity",null),Fr([r.decorators.func(),Br(2,r.decorators.param({options:{initialValue:"100"}})),Gr("design:type",Function),Gr("design:paramtypes",[a.FileInfo,String,Number]),Gr("design:returntype",Promise)],Wr,"detectMacromoleculeProbe",null),Fr([r.decorators.func({outputs:[{type:"object",name:"result"}]}),Gr("design:type",Function),Gr("design:paramtypes",[]),Gr("design:returntype",Promise)],Wr,"getSeqHelper",null),Fr([r.decorators.func(),Br(1,r.decorators.param({type:"column"})),Br(2,r.decorators.param({options:{initialValue:"true"}})),Gr("design:type",Function),Gr("design:paramtypes",[a.DataFrame,a.Column,Boolean]),Gr("design:returntype",Promise)],Wr,"getMolFromHelm",null);class jr{_palette;constructor(e){this._palette=e}get(e){return this._palette[e]}}function Ur(){return Dr.logger.debug("Bio:test1() function"),{value:"value1"}}},2023:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o={data:new i.Name("data"),valCxt:new i.Name("valCxt"),instancePath:new i.Name("instancePath"),parentData:new i.Name("parentData"),parentDataProperty:new i.Name("parentDataProperty"),rootData:new i.Name("rootData"),dynamicAnchors:new i.Name("dynamicAnchors"),vErrors:new i.Name("vErrors"),errors:new i.Name("errors"),this:new i.Name("this"),self:new i.Name("self"),scope:new i.Name("scope"),json:new i.Name("json"),jsonPos:new i.Name("jsonPos"),jsonLen:new i.Name("jsonLen"),jsonPart:new i.Name("jsonPart")};t.default=o},2079:e=>{"use strict";e.exports=JSON.parse('{"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://json-schema.org/draft-07/schema#","title":"Core schema meta-schema","definitions":{"schemaArray":{"type":"array","minItems":1,"items":{"$ref":"#"}},"nonNegativeInteger":{"type":"integer","minimum":0},"nonNegativeIntegerDefault0":{"allOf":[{"$ref":"#/definitions/nonNegativeInteger"},{"default":0}]},"simpleTypes":{"enum":["array","boolean","integer","null","number","object","string"]},"stringArray":{"type":"array","items":{"type":"string"},"uniqueItems":true,"default":[]}},"type":["object","boolean"],"properties":{"$id":{"type":"string","format":"uri-reference"},"$schema":{"type":"string","format":"uri"},"$ref":{"type":"string","format":"uri-reference"},"$comment":{"type":"string"},"title":{"type":"string"},"description":{"type":"string"},"default":true,"readOnly":{"type":"boolean","default":false},"examples":{"type":"array","items":true},"multipleOf":{"type":"number","exclusiveMinimum":0},"maximum":{"type":"number"},"exclusiveMaximum":{"type":"number"},"minimum":{"type":"number"},"exclusiveMinimum":{"type":"number"},"maxLength":{"$ref":"#/definitions/nonNegativeInteger"},"minLength":{"$ref":"#/definitions/nonNegativeIntegerDefault0"},"pattern":{"type":"string","format":"regex"},"additionalItems":{"$ref":"#"},"items":{"anyOf":[{"$ref":"#"},{"$ref":"#/definitions/schemaArray"}],"default":true},"maxItems":{"$ref":"#/definitions/nonNegativeInteger"},"minItems":{"$ref":"#/definitions/nonNegativeIntegerDefault0"},"uniqueItems":{"type":"boolean","default":false},"contains":{"$ref":"#"},"maxProperties":{"$ref":"#/definitions/nonNegativeInteger"},"minProperties":{"$ref":"#/definitions/nonNegativeIntegerDefault0"},"required":{"$ref":"#/definitions/stringArray"},"additionalProperties":{"$ref":"#"},"definitions":{"type":"object","additionalProperties":{"$ref":"#"},"default":{}},"properties":{"type":"object","additionalProperties":{"$ref":"#"},"default":{}},"patternProperties":{"type":"object","additionalProperties":{"$ref":"#"},"propertyNames":{"format":"regex"},"default":{}},"dependencies":{"type":"object","additionalProperties":{"anyOf":[{"$ref":"#"},{"$ref":"#/definitions/stringArray"}]}},"propertyNames":{"$ref":"#"},"const":true,"enum":{"type":"array","items":true,"minItems":1,"uniqueItems":true},"type":{"anyOf":[{"$ref":"#/definitions/simpleTypes"},{"type":"array","items":{"$ref":"#/definitions/simpleTypes"},"minItems":1,"uniqueItems":true}]},"format":{"type":"string"},"contentMediaType":{"type":"string"},"contentEncoding":{"type":"string"},"if":{"$ref":"#"},"then":{"$ref":"#"},"else":{"$ref":"#"},"allOf":{"$ref":"#/definitions/schemaArray"},"anyOf":{"$ref":"#/definitions/schemaArray"},"oneOf":{"$ref":"#/definitions/schemaArray"},"not":{"$ref":"#"}},"default":true}')},2094:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o=n(4227),r={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:{message:"property name must be valid",params:({params:e})=>i._`{propertyName: ${e.propertyName}}`},code(e){const{gen:t,schema:n,data:r,it:s}=e;if((0,o.alwaysValidSchema)(s,n))return;const a=t.name("valid");t.forIn("key",r,n=>{e.setParams({propertyName:n}),e.subschema({keyword:"propertyNames",data:n,dataTypes:["string"],propertyName:n,compositeRule:!0},a),t.if((0,i.not)(a),()=>{e.error(!0),s.allErrors||t.break()})}),e.ok(a)}};t.default=r},2128:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(3463),o=n(3693),r=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",i.default,o.default];t.default=r},2476:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dynamicAnchor=void 0;const i=n(9029),o=n(2023),r=n(3835),s=n(3693),a={keyword:"$dynamicAnchor",schemaType:"string",code:e=>l(e,e.schema)};function l(e,t){const{gen:n,it:a}=e;a.schemaEnv.root.dynamicAnchors[t]=!0;const l=i._`${o.default.dynamicAnchors}${(0,i.getProperty)(t)}`,c="#"===a.errSchemaPath?a.validateName:function(e){const{schemaEnv:t,schema:n,self:i}=e.it,{root:o,baseId:a,localRefs:l,meta:c}=t.root,{schemaId:h}=i.opts,u=new r.SchemaEnv({schema:n,schemaId:h,root:o,baseId:a,localRefs:l,meta:c});return r.compileSchema.call(i,u),(0,s.getValidate)(e,u)}(e);n.if(i._`!${l}`,()=>n.assign(l,c))}t.dynamicAnchor=l,t.default=a},2561:e=>{var t=10;e.exports=function(e,n,i){var o,r,s,a,l,c,h,u,d,p,m,g,f,y,b,v,w,C,S,A,x,E,M,T=n.length,_=i.length,I=e.adjustSizes,L=e.barnesHutTheta*e.barnesHutTheta,N=[];for(s=0;s<T;s+=t)n[s+4]=n[s+2],n[s+5]=n[s+3],n[s+2]=0,n[s+3]=0;if(e.outboundAttractionDistribution){for(m=0,s=0;s<T;s+=t)m+=n[s+6];m/=T/t}if(e.barnesHutOptimize){var P,R,$,O=1/0,k=-1/0,H=1/0,F=-1/0;for(s=0;s<T;s+=t)O=Math.min(O,n[s+0]),k=Math.max(k,n[s+0]),H=Math.min(H,n[s+1]),F=Math.max(F,n[s+1]);var G=k-O,B=F-H;for(G>B?F=(H-=(G-B)/2)+G:k=(O-=(B-G)/2)+B,N[0]=-1,N[1]=(O+k)/2,N[2]=(H+F)/2,N[3]=Math.max(k-O,F-H),N[4]=-1,N[5]=-1,N[6]=0,N[7]=0,N[8]=0,o=1,s=0;s<T;s+=t)for(r=0,$=3;;){if(!(N[r+5]>=0)){if(N[r+0]<0){N[r+0]=s;break}if(N[r+5]=9*o,u=N[r+3]/2,N[(d=N[r+5])+0]=-1,N[d+1]=N[r+1]-u,N[d+2]=N[r+2]-u,N[d+3]=u,N[d+4]=d+9,N[d+5]=-1,N[d+6]=0,N[d+7]=0,N[d+8]=0,N[(d+=9)+0]=-1,N[d+1]=N[r+1]-u,N[d+2]=N[r+2]+u,N[d+3]=u,N[d+4]=d+9,N[d+5]=-1,N[d+6]=0,N[d+7]=0,N[d+8]=0,N[(d+=9)+0]=-1,N[d+1]=N[r+1]+u,N[d+2]=N[r+2]-u,N[d+3]=u,N[d+4]=d+9,N[d+5]=-1,N[d+6]=0,N[d+7]=0,N[d+8]=0,N[(d+=9)+0]=-1,N[d+1]=N[r+1]+u,N[d+2]=N[r+2]+u,N[d+3]=u,N[d+4]=N[r+4],N[d+5]=-1,N[d+6]=0,N[d+7]=0,N[d+8]=0,o+=4,P=n[N[r+0]+0]<N[r+1]?n[N[r+0]+1]<N[r+2]?N[r+5]:N[r+5]+9:n[N[r+0]+1]<N[r+2]?N[r+5]+18:N[r+5]+27,N[r+6]=n[N[r+0]+6],N[r+7]=n[N[r+0]+0],N[r+8]=n[N[r+0]+1],N[P+0]=N[r+0],N[r+0]=-1,P===(R=n[s+0]<N[r+1]?n[s+1]<N[r+2]?N[r+5]:N[r+5]+9:n[s+1]<N[r+2]?N[r+5]+18:N[r+5]+27)){if($--){r=P;continue}$=3;break}N[R+0]=s;break}P=n[s+0]<N[r+1]?n[s+1]<N[r+2]?N[r+5]:N[r+5]+9:n[s+1]<N[r+2]?N[r+5]+18:N[r+5]+27,N[r+7]=(N[r+7]*N[r+6]+n[s+0]*n[s+6])/(N[r+6]+n[s+6]),N[r+8]=(N[r+8]*N[r+6]+n[s+1]*n[s+6])/(N[r+6]+n[s+6]),N[r+6]+=n[s+6],r=P}}if(e.barnesHutOptimize){for(g=e.scalingRatio,s=0;s<T;s+=t)for(r=0;;)if(N[r+5]>=0){if(v=Math.pow(n[s+0]-N[r+7],2)+Math.pow(n[s+1]-N[r+8],2),4*(p=N[r+3])*p/v<L){if(f=n[s+0]-N[r+7],y=n[s+1]-N[r+8],!0===I?v>0?(w=g*n[s+6]*N[r+6]/v,n[s+2]+=f*w,n[s+3]+=y*w):v<0&&(w=-g*n[s+6]*N[r+6]/Math.sqrt(v),n[s+2]+=f*w,n[s+3]+=y*w):v>0&&(w=g*n[s+6]*N[r+6]/v,n[s+2]+=f*w,n[s+3]+=y*w),(r=N[r+4])<0)break;continue}r=N[r+5]}else if((c=N[r+0])>=0&&c!==s&&(v=(f=n[s+0]-n[c+0])*f+(y=n[s+1]-n[c+1])*y,!0===I?v>0?(w=g*n[s+6]*n[c+6]/v,n[s+2]+=f*w,n[s+3]+=y*w):v<0&&(w=-g*n[s+6]*n[c+6]/Math.sqrt(v),n[s+2]+=f*w,n[s+3]+=y*w):v>0&&(w=g*n[s+6]*n[c+6]/v,n[s+2]+=f*w,n[s+3]+=y*w)),(r=N[r+4])<0)break}else for(g=e.scalingRatio,a=0;a<T;a+=t)for(l=0;l<a;l+=t)f=n[a+0]-n[l+0],y=n[a+1]-n[l+1],!0===I?(v=Math.sqrt(f*f+y*y)-n[a+8]-n[l+8])>0?(w=g*n[a+6]*n[l+6]/v/v,n[a+2]+=f*w,n[a+3]+=y*w,n[l+2]-=f*w,n[l+3]-=y*w):v<0&&(w=100*g*n[a+6]*n[l+6],n[a+2]+=f*w,n[a+3]+=y*w,n[l+2]-=f*w,n[l+3]-=y*w):(v=Math.sqrt(f*f+y*y))>0&&(w=g*n[a+6]*n[l+6]/v/v,n[a+2]+=f*w,n[a+3]+=y*w,n[l+2]-=f*w,n[l+3]-=y*w);for(d=e.gravity/e.scalingRatio,g=e.scalingRatio,s=0;s<T;s+=t)w=0,f=n[s+0],y=n[s+1],v=Math.sqrt(Math.pow(f,2)+Math.pow(y,2)),e.strongGravityMode?v>0&&(w=g*n[s+6]*d):v>0&&(w=g*n[s+6]*d/v),n[s+2]-=f*w,n[s+3]-=y*w;for(g=1*(e.outboundAttractionDistribution?m:1),h=0;h<_;h+=3)a=i[h+0],l=i[h+1],u=i[h+2],b=Math.pow(u,e.edgeWeightInfluence),f=n[a+0]-n[l+0],y=n[a+1]-n[l+1],!0===I?(v=Math.sqrt(f*f+y*y)-n[a+8]-n[l+8],e.linLogMode?e.outboundAttractionDistribution?v>0&&(w=-g*b*Math.log(1+v)/v/n[a+6]):v>0&&(w=-g*b*Math.log(1+v)/v):e.outboundAttractionDistribution?v>0&&(w=-g*b/n[a+6]):v>0&&(w=-g*b)):(v=Math.sqrt(Math.pow(f,2)+Math.pow(y,2)),e.linLogMode?e.outboundAttractionDistribution?v>0&&(w=-g*b*Math.log(1+v)/v/n[a+6]):v>0&&(w=-g*b*Math.log(1+v)/v):e.outboundAttractionDistribution?(v=1,w=-g*b/n[a+6]):(v=1,w=-g*b)),v>0&&(n[a+2]+=f*w,n[a+3]+=y*w,n[l+2]-=f*w,n[l+3]-=y*w);if(!0===I)for(s=0;s<T;s+=t)1!==n[s+9]&&((C=Math.sqrt(Math.pow(n[s+2],2)+Math.pow(n[s+3],2)))>10&&(n[s+2]=10*n[s+2]/C,n[s+3]=10*n[s+3]/C),S=n[s+6]*Math.sqrt((n[s+4]-n[s+2])*(n[s+4]-n[s+2])+(n[s+5]-n[s+3])*(n[s+5]-n[s+3])),A=Math.sqrt((n[s+4]+n[s+2])*(n[s+4]+n[s+2])+(n[s+5]+n[s+3])*(n[s+5]+n[s+3]))/2,x=.1*Math.log(1+A)/(1+Math.sqrt(S)),E=n[s+0]+n[s+2]*(x/e.slowDown),n[s+0]=E,M=n[s+1]+n[s+3]*(x/e.slowDown),n[s+1]=M);else for(s=0;s<T;s+=t)1!==n[s+9]&&(S=n[s+6]*Math.sqrt((n[s+4]-n[s+2])*(n[s+4]-n[s+2])+(n[s+5]-n[s+3])*(n[s+5]-n[s+3])),A=Math.sqrt((n[s+4]+n[s+2])*(n[s+4]+n[s+2])+(n[s+5]+n[s+3])*(n[s+5]+n[s+3]))/2,x=n[s+7]*Math.log(1+A)/(1+Math.sqrt(S)),n[s+7]=Math.min(1,Math.sqrt(x*(Math.pow(n[s+2],2)+Math.pow(n[s+3],2))/(1+Math.sqrt(S)))),E=n[s+0]+n[s+2]*(x/e.slowDown),n[s+0]=E,M=n[s+1]+n[s+3]*(x/e.slowDown),n[s+1]=M);return{}}},2582:(e,t,n)=>{"use strict";n.d(t,{f:()=>a});var i=n(6956);class o{constructor(e){const t=e.split(i.x).filter(e=>e);t.forEach(e=>this.validateConnectionItem(e)),this.connectionItems=t}connectionItems;validateConnectionItem(e){const t="(PEPTIDE|RNA|CHEM|BLOB)",n=new RegExp(`${t}[0-9]+,${t}[0-9]+,[0-9]+:R[0-9]+-[0-9]+:R[0-9]+`,"g");if(!e.match(n))throw new Error(`Cannot parse connection item from ${e}`)}getConnectionData(){const e=[];return this.connectionItems.forEach(t=>{const n=[],i=t.split(",");i[2].split("-").forEach((e,t)=>{const o=i[t],r=e.split(":"),s={monomerIdx:parseInt(r[0])-1,rGroupId:parseInt(r[1].slice(1))};n.push({polymerId:o,bond:s})}),e.push(n)}),e}}var r=n(8438);class s{simplePolymer;isNucleotideSequence=!1;constructor(e){this.simplePolymer=e,this.polymerType=this.getPolymerType(),this.isNucleotideSequence="RNA"===this.polymerType,this.idx=this.getIdx();const{monomers:t,monomerTypes:n}=this.getMonomerSymbolsAndTypes();this.monomers=t,this.monomerTypes=n}polymerType;monomers;idx;monomerTypes;get id(){return this.polymerType+this.idx.toString()}getPolymerType(){const e=new RegExp("(PEPTIDE|RNA|CHEM|BLOB)[0-9]+{"),t=this.simplePolymer.match(e);if(!t)throw new Error(`Unsupported polymer type in ${this.simplePolymer}`);return t[1]}getIdx(){const e=new RegExp(`${this.polymerType}([0-9]+){`),t=this.simplePolymer.match(e);if(!t)throw new Error(`Cannot parse simple polymer id from ${this.simplePolymer}`);return parseInt(t[1])}getMonomerSymbolsAndTypes(){const e=new RegExp(`${this.polymerType}${this.idx}{|}`,"g"),t=this.simplePolymer.replace(e,"").split("."),n=[],i=[];return t.forEach(e=>{if(this.isNucleotideSequence){const t=e.split(/\(|\)/).filter(e=>!!e).map(e=>(0,r.D)(e));n.push(...t),t.forEach((e,t)=>i.push(t%3==1?"Branch":"Backbone"))}else n.push((0,r.D)(e)),i.push("Backbone")}),{monomers:n,monomerTypes:i}}getBondData(){const e=[],t=this.monomerTypes.map((e,t)=>{if("Backbone"===e)return t}).filter(e=>void 0!==e),n=this.monomerTypes.map((e,t)=>{if("Branch"===e)return t}).filter(e=>void 0!==e);for(let n=0;n<t.length-1;n++){const i=t[n],o=t[n+1];e.push([{monomerIdx:i,rGroupId:2},{monomerIdx:o,rGroupId:1}])}for(let t=0;t<n.length;t++){const i=n[t],o=i-1;e.push([{monomerIdx:o,rGroupId:3},{monomerIdx:i,rGroupId:1}])}return e}}class a{helmString;constructor(e){this.helmString=e;const t=e.indexOf("}$"),n=e.substring(0,t+1),i=e.indexOf("$",t+2),r=e.substring(t+2,i),a=n.split("}|");for(let e=0;e<a.length-1;e++)a[e]=a[e]+"}";this.simplePolymers=a.map(e=>new s(e)),this.connectionList=new o(r),this.bondData=this.getBondData(),this.bondedRGroupsMap=this.getBondedRGroupsMap()}bondData;simplePolymers;connectionList;bondedRGroupsMap;getBondedRGroupsMap(){const e=this.simplePolymers.map(e=>e.monomers.length).reduce((e,t)=>e+t,0),t=Array.from({length:e},()=>[]);return this.bondData.forEach(e=>{e.forEach(e=>{const n=e.monomerIdx,i=e.rGroupId;t[n].push(i)})}),t}toString(){return this.helmString}getPolymerTypeByMonomerIdx(e){return this.getSimplePolymerByMonomerIdx(e).polymerType}getSimplePolymerByMonomerIdx(e){const t=this.getMonomerIdxShifts(),n=Object.values(t).sort((e,t)=>t-e).find(t=>e>=t);if(null==n)throw new Error(`Cannot find simple polymer for monomer ${e}`);const i=Object.keys(t).find(e=>t[e]===n);return this.simplePolymers.find(e=>e.id===i)}shiftBondMonomerIds(e,t){t.forEach(t=>{t.forEach(t=>{t.monomerIdx+=e})})}getMonomerIdxShifts(){const e={};let t=0;return this.simplePolymers.forEach(n=>{e[n.id]=t,t+=n.monomers.length}),e}getBondData(){const e=this.getMonomerIdxShifts(),t=[];return this.simplePolymers.forEach(n=>{const i=n.getBondData(),o=e[n.id];this.shiftBondMonomerIds(o,i),t.push(...i)}),this.connectionList.getConnectionData().forEach(n=>{const i=[];n.forEach(t=>{const n=e[t.polymerId],o=t.bond;o.monomerIdx+=n,i.push(o)}),t.push(i)}),t}}},2586:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getData=t.KeywordCxt=t.validateFunctionCode=void 0;const i=n(8727),o=n(208),r=n(7887),s=n(208),a=n(7870),l=n(3673),c=n(4495),h=n(9029),u=n(2023),d=n(6939),p=n(4227),m=n(8708);function g({gen:e,validateName:t,schema:n,schemaEnv:i,opts:o},r){o.code.es5?e.func(t,h._`${u.default.data}, ${u.default.valCxt}`,i.$async,()=>{e.code(h._`"use strict"; ${f(n,o)}`),function(e,t){e.if(u.default.valCxt,()=>{e.var(u.default.instancePath,h._`${u.default.valCxt}.${u.default.instancePath}`),e.var(u.default.parentData,h._`${u.default.valCxt}.${u.default.parentData}`),e.var(u.default.parentDataProperty,h._`${u.default.valCxt}.${u.default.parentDataProperty}`),e.var(u.default.rootData,h._`${u.default.valCxt}.${u.default.rootData}`),t.dynamicRef&&e.var(u.default.dynamicAnchors,h._`${u.default.valCxt}.${u.default.dynamicAnchors}`)},()=>{e.var(u.default.instancePath,h._`""`),e.var(u.default.parentData,h._`undefined`),e.var(u.default.parentDataProperty,h._`undefined`),e.var(u.default.rootData,u.default.data),t.dynamicRef&&e.var(u.default.dynamicAnchors,h._`{}`)})}(e,o),e.code(r)}):e.func(t,h._`${u.default.data}, ${function(e){return h._`{${u.default.instancePath}="", ${u.default.parentData}, ${u.default.parentDataProperty}, ${u.default.rootData}=${u.default.data}${e.dynamicRef?h._`, ${u.default.dynamicAnchors}={}`:h.nil}}={}`}(o)}`,i.$async,()=>e.code(f(n,o)).code(r))}function f(e,t){const n="object"==typeof e&&e[t.schemaId];return n&&(t.code.source||t.code.process)?h._`/*# sourceURL=${n} */`:h.nil}function y({schema:e,self:t}){if("boolean"==typeof e)return!e;for(const n in e)if(t.RULES.all[n])return!0;return!1}function b(e){return"boolean"!=typeof e.schema}function v(e){(0,p.checkUnknownRules)(e),function(e){const{schema:t,errSchemaPath:n,opts:i,self:o}=e;t.$ref&&i.ignoreKeywordsWithRef&&(0,p.schemaHasRulesButRef)(t,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${n}"`)}(e)}function w(e,t){if(e.opts.jtd)return S(e,[],!1,t);const n=(0,o.getSchemaTypes)(e.schema);S(e,n,!(0,o.coerceAndCheckDataType)(e,n),t)}function C({gen:e,schemaEnv:t,schema:n,errSchemaPath:i,opts:o}){const r=n.$comment;if(!0===o.$comment)e.code(h._`${u.default.self}.logger.log(${r})`);else if("function"==typeof o.$comment){const n=h.str`${i}/$comment`,o=e.scopeValue("root",{ref:t.root});e.code(h._`${u.default.self}.opts.$comment(${r}, ${n}, ${o}.schema)`)}}function S(e,t,n,i){const{gen:o,schema:a,data:l,allErrors:c,opts:d,self:m}=e,{RULES:g}=m;function f(p){(0,r.shouldUseGroup)(a,p)&&(p.type?(o.if((0,s.checkDataType)(p.type,l,d.strictNumbers)),A(e,p),1===t.length&&t[0]===p.type&&n&&(o.else(),(0,s.reportTypeError)(e)),o.endIf()):A(e,p),c||o.if(h._`${u.default.errors} === ${i||0}`))}!a.$ref||!d.ignoreKeywordsWithRef&&(0,p.schemaHasRulesButRef)(a,g)?(d.jtd||function(e,t){!e.schemaEnv.meta&&e.opts.strictTypes&&(function(e,t){t.length&&(e.dataTypes.length?(t.forEach(t=>{x(e.dataTypes,t)||E(e,`type "${t}" not allowed by context "${e.dataTypes.join(",")}"`)}),function(e,t){const n=[];for(const i of e.dataTypes)x(t,i)?n.push(i):t.includes("integer")&&"number"===i&&n.push("integer");e.dataTypes=n}(e,t)):e.dataTypes=t)}(e,t),e.opts.allowUnionTypes||function(e,t){t.length>1&&(2!==t.length||!t.includes("null"))&&E(e,"use allowUnionTypes to allow union type keyword")}(e,t),function(e,t){const n=e.self.RULES.all;for(const i in n){const o=n[i];if("object"==typeof o&&(0,r.shouldUseRule)(e.schema,o)){const{type:n}=o.definition;n.length&&!n.some(e=>{return i=e,(n=t).includes(i)||"number"===i&&n.includes("integer");var n,i})&&E(e,`missing type "${n.join(",")}" for keyword "${i}"`)}}}(e,e.dataTypes))}(e,t),o.block(()=>{for(const e of g.rules)f(e);f(g.post)})):o.block(()=>T(e,"$ref",g.all.$ref.definition))}function A(e,t){const{gen:n,schema:i,opts:{useDefaults:o}}=e;o&&(0,a.assignDefaults)(e,t.type),n.block(()=>{for(const n of t.rules)(0,r.shouldUseRule)(i,n)&&T(e,n.keyword,n.definition,t.type)})}function x(e,t){return e.includes(t)||"integer"===t&&e.includes("number")}function E(e,t){t+=` at "${e.schemaEnv.baseId+e.errSchemaPath}" (strictTypes)`,(0,p.checkStrictMode)(e,t,e.opts.strictTypes)}t.validateFunctionCode=function(e){b(e)&&(v(e),y(e))?function(e){const{schema:t,opts:n,gen:i}=e;g(e,()=>{n.$comment&&t.$comment&&C(e),function(e){const{schema:t,opts:n}=e;void 0!==t.default&&n.useDefaults&&n.strictSchema&&(0,p.checkStrictMode)(e,"default is ignored in the schema root")}(e),i.let(u.default.vErrors,null),i.let(u.default.errors,0),n.unevaluated&&function(e){const{gen:t,validateName:n}=e;e.evaluated=t.const("evaluated",h._`${n}.evaluated`),t.if(h._`${e.evaluated}.dynamicProps`,()=>t.assign(h._`${e.evaluated}.props`,h._`undefined`)),t.if(h._`${e.evaluated}.dynamicItems`,()=>t.assign(h._`${e.evaluated}.items`,h._`undefined`))}(e),w(e),function(e){const{gen:t,schemaEnv:n,validateName:i,ValidationError:o,opts:r}=e;n.$async?t.if(h._`${u.default.errors} === 0`,()=>t.return(u.default.data),()=>t.throw(h._`new ${o}(${u.default.vErrors})`)):(t.assign(h._`${i}.errors`,u.default.vErrors),r.unevaluated&&function({gen:e,evaluated:t,props:n,items:i}){n instanceof h.Name&&e.assign(h._`${t}.props`,n),i instanceof h.Name&&e.assign(h._`${t}.items`,i)}(e),t.return(h._`${u.default.errors} === 0`))}(e)})}(e):g(e,()=>(0,i.topBoolOrEmptySchema)(e))};class M{constructor(e,t,n){if((0,l.validateKeywordUsage)(e,t,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=t.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,p.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=t.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=t,this.$data)this.schemaCode=e.gen.const("vSchema",L(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,l.validSchemaType)(this.schema,t.schemaType,t.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(t.schemaType)}`);("code"in t?t.trackErrors:!1!==t.errors)&&(this.errsCount=e.gen.const("_errs",u.default.errors))}result(e,t,n){this.failResult((0,h.not)(e),t,n)}failResult(e,t,n){this.gen.if(e),n?n():this.error(),t?(this.gen.else(),t(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,t){this.failResult((0,h.not)(e),void 0,t)}fail(e){if(void 0===e)return this.error(),void(this.allErrors||this.gen.if(!1));this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);const{schemaCode:t}=this;this.fail(h._`${t} !== undefined && (${(0,h.or)(this.invalid$data(),e)})`)}error(e,t,n){if(t)return this.setParams(t),this._error(e,n),void this.setParams({});this._error(e,n)}_error(e,t){(e?m.reportExtraError:m.reportError)(this,this.def.error,t)}$dataError(){(0,m.reportError)(this,this.def.$dataError||m.keyword$DataError)}reset(){if(void 0===this.errsCount)throw new Error('add "trackErrors" to keyword definition');(0,m.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,t){t?Object.assign(this.params,e):this.params=e}block$data(e,t,n=h.nil){this.gen.block(()=>{this.check$data(e,n),t()})}check$data(e=h.nil,t=h.nil){if(!this.$data)return;const{gen:n,schemaCode:i,schemaType:o,def:r}=this;n.if((0,h.or)(h._`${i} === undefined`,t)),e!==h.nil&&n.assign(e,!0),(o.length||r.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==h.nil&&n.assign(e,!1)),n.else()}invalid$data(){const{gen:e,schemaCode:t,schemaType:n,def:i,it:o}=this;return(0,h.or)(function(){if(n.length){if(!(t instanceof h.Name))throw new Error("ajv implementation error");const e=Array.isArray(n)?n:[n];return h._`${(0,s.checkDataTypes)(e,t,o.opts.strictNumbers,s.DataType.Wrong)}`}return h.nil}(),function(){if(i.validateSchema){const n=e.scopeValue("validate$data",{ref:i.validateSchema});return h._`!${n}(${t})`}return h.nil}())}subschema(e,t){const n=(0,c.getSubschema)(this.it,e);(0,c.extendSubschemaData)(n,this.it,e),(0,c.extendSubschemaMode)(n,e);const o={...this.it,...n,items:void 0,props:void 0};return function(e,t){b(e)&&(v(e),y(e))?function(e,t){const{schema:n,gen:i,opts:o}=e;o.$comment&&n.$comment&&C(e),function(e){const t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,d.resolveUrl)(e.opts.uriResolver,e.baseId,t))}(e),function(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}(e);const r=i.const("_errs",u.default.errors);w(e,r),i.var(t,h._`${r} === ${u.default.errors}`)}(e,t):(0,i.boolOrEmptySchema)(e,t)}(o,t),o}mergeEvaluated(e,t){const{it:n,gen:i}=this;n.opts.unevaluated&&(!0!==n.props&&void 0!==e.props&&(n.props=p.mergeEvaluated.props(i,e.props,n.props,t)),!0!==n.items&&void 0!==e.items&&(n.items=p.mergeEvaluated.items(i,e.items,n.items,t)))}mergeValidEvaluated(e,t){const{it:n,gen:i}=this;if(n.opts.unevaluated&&(!0!==n.props||!0!==n.items))return i.if(t,()=>this.mergeEvaluated(e,h.Name)),!0}}function T(e,t,n,i){const o=new M(e,n,t);"code"in n?n.code(o,i):o.$data&&n.validate?(0,l.funcKeywordCode)(o,n):"macro"in n?(0,l.macroKeywordCode)(o,n):(n.compile||n.validate)&&(0,l.funcKeywordCode)(o,n)}t.KeywordCxt=M;const _=/^\/(?:[^~]|~0|~1)*$/,I=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function L(e,{dataLevel:t,dataNames:n,dataPathArr:i}){let o,r;if(""===e)return u.default.rootData;if("/"===e[0]){if(!_.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);o=e,r=u.default.rootData}else{const s=I.exec(e);if(!s)throw new Error(`Invalid JSON-pointer: ${e}`);const a=+s[1];if(o=s[2],"#"===o){if(a>=t)throw new Error(l("property/index",a));return i[t-a]}if(a>t)throw new Error(l("data",a));if(r=n[t-a],!o)return r}let s=r;const a=o.split("/");for(const e of a)e&&(r=h._`${r}${(0,h.getProperty)((0,p.unescapeJsonPointer)(e))}`,s=h._`${s} && ${r}`);return s;function l(e,n){return`Cannot access ${e} ${n} levels up, current level is ${t}`}}t.getData=L},2626:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(4227),o={keyword:["maxContains","minContains"],type:"array",schemaType:"number",code({keyword:e,parentSchema:t,it:n}){void 0===t.contains&&(0,i.checkStrictMode)(n,`"${e}" without "contains" is ignored`)}};t.default=o},2661:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o=n(4227),r={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:{message:({params:{min:e,max:t}})=>void 0===t?i.str`must contain at least ${e} valid item(s)`:i.str`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>void 0===t?i._`{minContains: ${e}}`:i._`{minContains: ${e}, maxContains: ${t}}`},code(e){const{gen:t,schema:n,parentSchema:r,data:s,it:a}=e;let l,c;const{minContains:h,maxContains:u}=r;a.opts.next?(l=void 0===h?1:h,c=u):l=1;const d=t.const("len",i._`${s}.length`);if(e.setParams({min:l,max:c}),void 0===c&&0===l)return void(0,o.checkStrictMode)(a,'"minContains" == 0 without "maxContains": "contains" keyword ignored');if(void 0!==c&&l>c)return(0,o.checkStrictMode)(a,'"minContains" > "maxContains" is always invalid'),void e.fail();if((0,o.alwaysValidSchema)(a,n)){let t=i._`${d} >= ${l}`;return void 0!==c&&(t=i._`${t} && ${d} <= ${c}`),void e.pass(t)}a.items=!0;const p=t.name("valid");function m(){const e=t.name("_valid"),n=t.let("count",0);g(e,()=>t.if(e,()=>function(e){t.code(i._`${e}++`),void 0===c?t.if(i._`${e} >= ${l}`,()=>t.assign(p,!0).break()):(t.if(i._`${e} > ${c}`,()=>t.assign(p,!1).break()),1===l?t.assign(p,!0):t.if(i._`${e} >= ${l}`,()=>t.assign(p,!0)))}(n)))}function g(n,i){t.forRange("i",0,d,t=>{e.subschema({keyword:"contains",dataProp:t,dataPropType:o.Type.Num,compositeRule:!0},n),i()})}void 0===c&&1===l?g(p,()=>t.if(p,()=>t.break())):0===l?(t.let(p,!0),void 0!==c&&t.if(i._`${s}.length > 0`,m)):(t.let(p,!1),m()),e.result(p,()=>e.reset())}};t.default=r},2721:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(2476),o=n(4227),r={keyword:"$recursiveAnchor",schemaType:"boolean",code(e){e.schema?(0,i.dynamicAnchor)(e,""):(0,o.checkStrictMode)(e.it,"$recursiveAnchor: false is ignored")}};t.default=r},2738:(e,t,n)=>{"use strict";n.d(t,{X:()=>o,a:()=>i});class i{constructor(e,t,n){this.name=e,this.alphabet=t,this.cutoff=n}}class o extends i{constructor(e,t,n){super(e.name,e.alphabet,e.cutoff),this.freq=t,this.similarity=n}}},2780:(e,t,n)=>{"use strict";n(8498),n(9336)},2787:(e,t,n)=>{"use strict";n.d(t,{I:()=>o});const i=new Uint32Array(65536),o=(e,t)=>{if(e.length<t.length){const n=t;t=e,e=n}return 0===t.length?e.length:e.length<=32?((e,t)=>{const n=e.length,o=t.length,r=1<<n-1;let s=-1,a=0,l=n,c=n;for(;c--;)i[e.charCodeAt(c)]|=1<<c;for(c=0;c<o;c++){let e=i[t.charCodeAt(c)];const n=e|a;e|=(e&s)+s^s,a|=~(e|s),s&=e,a&r&&l++,s&r&&l--,a=a<<1|1,s=s<<1|~(n|a),a&=n}for(c=n;c--;)i[e.charCodeAt(c)]=0;return l})(e,t):((e,t)=>{const n=t.length,o=e.length,r=[],s=[],a=Math.ceil(n/32),l=Math.ceil(o/32);for(let e=0;e<a;e++)s[e]=-1,r[e]=0;let c=0;for(;c<l-1;c++){let a=0,l=-1;const h=32*c,u=Math.min(32,o)+h;for(let t=h;t<u;t++)i[e.charCodeAt(t)]|=1<<t;for(let e=0;e<n;e++){const n=i[t.charCodeAt(e)],o=s[e/32|0]>>>e&1,c=r[e/32|0]>>>e&1,h=n|a,u=((n|c)&l)+l^l|n|c;let d=a|~(u|l),p=l&u;d>>>31^o&&(s[e/32|0]^=1<<e),p>>>31^c&&(r[e/32|0]^=1<<e),d=d<<1|o,p=p<<1|c,l=p|~(h|d),a=d&h}for(let t=h;t<u;t++)i[e.charCodeAt(t)]=0}let h=0,u=-1;const d=32*c,p=Math.min(32,o-d)+d;for(let t=d;t<p;t++)i[e.charCodeAt(t)]|=1<<t;let m=o;for(let e=0;e<n;e++){const n=i[t.charCodeAt(e)],a=s[e/32|0]>>>e&1,l=r[e/32|0]>>>e&1,c=n|h,d=((n|l)&u)+u^u|n|l;let p=h|~(d|u),g=u&d;m+=p>>>o-1&1,m-=g>>>o-1&1,p>>>31^a&&(s[e/32|0]^=1<<e),g>>>31^l&&(r[e/32|0]^=1<<e),p=p<<1|a,g=g<<1|l,u=g|~(c|p),h=p&c}for(let t=d;t<p;t++)i[e.charCodeAt(t)]=0;return m})(e,t)}},3017:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var i=n(1354),o=n.n(i),r=n(6314),s=n.n(r)()(o());s.push([e.id,".monomer-lib-controls-form {\n margin-left: auto;\n margin-right: auto;\n display: flex;\n flex-direction: column;\n align-items: center;\n min-width: 220px;\n width: 100%;\n\n}\n","",{version:3,sources:["webpack://./src/utils/monomer-lib/library-file-manager/style.css"],names:[],mappings:"AAAA;EACE,iBAAiB;EACjB,kBAAkB;EAClB,aAAa;EACb,sBAAsB;EACtB,mBAAmB;EACnB,gBAAgB;EAChB,WAAW;;AAEb",sourcesContent:[".monomer-lib-controls-form {\n margin-left: auto;\n margin-right: auto;\n display: flex;\n flex-direction: column;\n align-items: center;\n min-width: 220px;\n width: 100%;\n\n}\n"],sourceRoot:""}]);const a=s},3025:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validateSchemaDeps=t.validatePropertyDeps=t.error=void 0;const i=n(9029),o=n(4227),r=n(5765);t.error={message:({params:{property:e,depsCount:t,deps:n}})=>{const o=1===t?"property":"properties";return i.str`must have ${o} ${n} when property ${e} is present`},params:({params:{property:e,depsCount:t,deps:n,missingProperty:o}})=>i._`{property: ${e},
|
|
4
|
+
|| ${a} === "boolean" || ${o} === null`).assign(l,s._`[${o}]`)}}i.else(),m(e),i.endIf(),i.if(s._`${l} !== undefined`,()=>{i.assign(o,l),function({gen:e,parentData:t,parentDataProperty:n},i){e.if(s._`${t} !== undefined`,()=>e.assign(s._`${t}[${n}]`,i))}(e,l)})}(e,t,a):m(e)})}return c};const u=new Set(["string","number","integer","boolean","null"]);function h(e,t,n,i=l.Correct){const o=i===l.Correct?s.operators.EQ:s.operators.NEQ;let r;switch(e){case"null":return s._`${t} ${o} null`;case"array":r=s._`Array.isArray(${t})`;break;case"object":r=s._`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":r=a(s._`!(${t} % 1) && !isNaN(${t})`);break;case"number":r=a();break;default:return s._`typeof ${t} ${o} ${e}`}return i===l.Correct?r:(0,s.not)(r);function a(e=s.nil){return(0,s.and)(s._`typeof ${t} == "number"`,e,n?s._`isFinite(${t})`:s.nil)}}function d(e,t,n,i){if(1===e.length)return h(e[0],t,n,i);let o;const r=(0,a.toHash)(e);if(r.array&&r.object){const e=s._`typeof ${t} != "object"`;o=r.null?e:s._`!${t} || ${e}`,delete r.null,delete r.array,delete r.object}else o=s.nil;r.number&&delete r.integer;for(const e in r)o=(0,s.and)(o,h(e,t,n,i));return o}t.checkDataType=h,t.checkDataTypes=d;const p={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>"string"==typeof e?s._`{type: ${e}}`:s._`{type: ${t}}`};function m(e){const t=function(e){const{gen:t,data:n,schema:i}=e,o=(0,a.schemaRefOrVal)(e,i,"type");return{gen:t,keyword:"type",data:n,schema:i.type,schemaCode:o,schemaValue:o,parentSchema:i,params:{},it:e}}(e);(0,r.reportError)(t,p)}t.reportTypeError=m},250:(e,t,n)=>{"use strict";n.d(t,{n5:()=>C,oP:()=>I});var i=n(4328),o=n(7389),r=n(6082),s=n(1757),a=n.n(s),l=n(1991),c=n.n(l),u=n(1858),h=n(2003),d=n(4326);function p(e){var t;return"string"==typeof e||e instanceof String?e:("object"==typeof e||e instanceof Object)&&"$thrownJsError"in e?p(e.$thrownJsError):e instanceof Error?null!==(t=e.stack)&&void 0!==t?t:e.message:e.toString()}var m=n(8070),f=n(7602),g=n(439),y=n(6882);var b=n(2447);function v(e,t,n){return Math.abs(e-t)<=n}var w,C,S=n(6307),A=n(6197);HTMLCanvasElement.prototype.getCursorPosition=function(e,t){const n=this.getBoundingClientRect();return new r.Point((e.clientX-n.left)*t,(e.clientY-n.top)*t)},r.Rect.prototype.contains=function(e,t){return this.left<=e&&e<=this.right&&this.top<=t&&t<=this.bottom};class x{rowCount;value;plotValue;valueList=null;valueIdx=0;bounds;constructor(e=0,t){this.value=this.rowCount=e,this.bounds=t}push(e){this.valueList||(this.valueList=new Array(this.rowCount),this.valueIdx=0),this.valueList[this.valueIdx]=e,++this.valueIdx}aggregate(e){this.value=e(this.valueList)??0,this.valueList=null}}class M{pos;name;_label;get label(){return this._label?this._label:this.name}_freqs;sumRowCount=0;sumPlotValue;sumPlotValueForHeight;constructor(e,t,n,i){this.pos=e,this.name=t,this._freqs=n??{},i?.sumRowCount&&(this.sumRowCount=i.sumRowCount),i?.sumValueForHeight&&(this.sumPlotValue=i.sumValueForHeight),i?.label&&(this._label=i.label)}getMonomers(){return Object.keys(this._freqs)}hasMonomer(e){return e in this._freqs}getFreq(e){let t=this._freqs[e];return t||(t=this._freqs[e]=new x),t}aggregate(e){const t=function(e){return t=>{const n=function(e){let t;const n="agg";return t=e instanceof Float32Array?r.Column.fromFloat32Array(n,e):e instanceof Int32Array?r.Column.fromInt32Array(n,e):r.Column.fromList(r.COLUMN_TYPE.FLOAT,n,e),t}(t);return n.aggregate(e)}}(e);for(const[e,n]of Object.entries(this._freqs))n.aggregate(t)}getMinValue(){return Math.min(...Object.values(this._freqs).map(e=>e.value))}calcPlotValue(e){for(const t of Object.values(this._freqs))t.plotValue=t.value-e}calcHeights(e){this.sumPlotValue=0;for(const e of Object.values(this._freqs))this.sumPlotValue+=e.plotValue;if(this.sumPlotValueForHeight=0,e===d.fH.Entropy){const e=Object.keys(this._freqs).length,t=.01*this.sumPlotValue,n=t/e;for(const e of Object.values(this._freqs)){const i=(e.plotValue+n)/(this.sumPlotValue+t);this.sumPlotValueForHeight+=-i*Math.log2(i)}}else if(e===d.fH.full)for(const[e,t]of Object.entries(this._freqs)){const e=t.plotValue/this.sumPlotValue;this.sumPlotValueForHeight+=e}}calcScreen(e,t,n,i,o,s,a,l,c){const u=i===d.fH.Entropy?n*(o-this.sumPlotValueForHeight)/o:n;let h=c*l+(n-u-1);const p=Object.entries(this._freqs).sort((e,t)=>e[0]!==g._S&&t[0]!==g._S?t[1].value-e[1].value:e[0]===g._S&&t[0]===g._S?0:e[0]===g._S?-1:1);for(const[n,i]of p){const n=u*i.plotValue/this.sumPlotValue;i.bounds=new r.Rect((e-t)*l*s,h,a*l,n),h+=n}}render(e,t,n,i,o,r,s){for(const[a,l]of Object.entries(this._freqs))if(a!==g._S){let c=a;const u=l.bounds,d=u.left;let m=y.S$;if(r)try{m=r.getMonomerTextColor(o,a);const e=r.getMonomer((0,A.Y)(o),a);e&&e.symbol!==a&&(c=e.symbol)}catch(e){p(e)}const f=(0,h.zS)(c,s);e.resetTransform(),e.strokeStyle="lightgray",e.lineWidth=1,e.rect(d,u.top,u.width,u.height),e.fillStyle=m,e.textAlign="left",e.font=t;const g=e.measureText(f);e.setTransform(u.width/g.width,0,0,u.height/i,d,u.top),e.fillText(f,0,-n)}}getMonomerAt(e,t){const n=Object.entries(this._freqs).find(([n,i])=>i.bounds.contains(e,t));return n?n[0]:void 0}buildCompositionTable(e,t){if("-"in this._freqs)throw new Error("Unexpected monomer symbol '-'.");return(0,S.F)(Object.assign({},...Object.entries(this._freqs).map(([e,t])=>({[e]:t.rowCount}))),e,t)}}!function(e){e.STYLE="Style",e.BEHAVIOR="Behavior",e.LAYOUT="Layout",e.DATA="Data"}(w||(w={})),function(e){e.sequenceColumnName="sequenceColumnName",e.valueAggrType="valueAggrType",e.valueColumnName="valueColumnName",e.startPositionName="startPositionName",e.endPositionName="endPositionName",e.skipEmptySequences="skipEmptySequences",e.skipEmptyPositions="skipEmptyPositions",e.shrinkEmptyTail="shrinkEmptyTail",e.backgroundColor="backgroundColor",e.positionHeight="positionHeight",e.positionWidth="positionWidth",e.verticalAlignment="verticalAlignment",e.horizontalAlignment="horizontalAlignment",e.fixWidth="fixWidth",e.fitArea="fitArea",e.minHeight="minHeight",e.maxHeight="maxHeight",e.maxMonomerLetters="maxMonomerLetters",e.showPositionLabels="showPositionLabels",e.positionMarginState="positionMarginState",e.positionMargin="positionMargin",e.filterSource="filterSource"}(C||(C={}));const T=d.Fo;var E;!function(e){e[e.None=0]="None",e[e.Render=1]="Render",e[e.Layout=1]="Layout",e[e.Freqs=2]="Freqs"}(E||(E={}));const _=new class{render=20};class I extends r.JsViewer{static residuesSet="nucleotides";viewed=!1;seqHelper;seqHandler;initialized=!1;monomerLib=null;host;msgHost;canvas;slider;textBaseline;seqCol=null;positions=[];visibleSlider=!1;allowResize=!0;turnOfResizeForOneSetValue=!1;sequenceColumnName;valueAggrType;valueColumnName;skipEmptySequences;skipEmptyPositions;positionWidth;_positionWidth;_positionWidthWithMargin;get positionWidthWithMargin(){return this._positionWidthWithMargin}minHeight;backgroundColor=4294967295;maxHeight;maxMonomerLetters;showPositionLabels;positionMarginState;positionMargin=0;_positionMargin;startPositionName;endPositionName;fixWidth;verticalAlignment;horizontalAlignment;fitArea;shrinkEmptyTail;positionHeight;filterSource;positionNames=[];positionLabels=void 0;startPosition=-1;endPosition=-1;error=null;get Length(){return this.skipEmptyPositions?this.positions.length:this.startPosition<=this.endPosition?this.endPosition-this.startPosition+1:0}get positionMarginValue(){return this.positionMarginState===d.mH.AUTO&&!0===this.seqHandler.getAlphabetIsMultichar()||this.positionMarginState===d.mH.ON?this.positionMargin:0}constructor(){super(),this.seqHelper=b._package.seqHelper,this.textBaseline="top",this.seqHandler=null,this.sequenceColumnName=this.string(C.sequenceColumnName,T.sequenceColumnName,{category:w.DATA,semType:r.SEMTYPE.MACROMOLECULE,description:"Column with sequences"});const e=[r.AGG.KEY,r.AGG.PIVOT,r.AGG.MISSING_VALUE_COUNT,r.AGG.SKEW,r.AGG.KURT,r.AGG.SELECTED_ROWS_COUNT],t=Object.values(r.AGG).filter(t=>!e.includes(t));this.valueColumnName=this.string(C.valueColumnName,T.valueColumnName,{category:w.DATA,columnTypeFilter:"numerical",description:"Column with values used in aggregation for position heights"}),this.valueAggrType=this.string(C.valueAggrType,T.valueAggrType,{category:w.DATA,choices:t,description:"Aggregation method for value column"}),this.startPositionName=this.string(C.startPositionName,T.startPositionName,{category:w.DATA,description:"Position or column name for start position. If column with given name is found, its values will be used as start position. If number is supplied, it will be used as start position of WebLogo."}),this.endPositionName=this.string(C.endPositionName,T.endPositionName,{category:w.DATA,description:"Position or column name for end position. If column with given name is found, its values will be used as end position. If number is supplied, it will be used as end position of WebLogo."}),this.skipEmptySequences=this.bool(C.skipEmptySequences,T.skipEmptySequences,{category:w.DATA,description:"Skip sequences which are empty in all positions"}),this.skipEmptyPositions=this.bool(C.skipEmptyPositions,T.skipEmptyPositions,{category:w.DATA,description:"Skip positions which are empty in all sequences"}),this.shrinkEmptyTail=this.bool(C.shrinkEmptyTail,T.shrinkEmptyTail,{category:w.DATA,description:"Skip empty tail (if found for all sequences within a subset) in WebLogo"}),this.backgroundColor=this.int(C.backgroundColor,T.backgroundColor,{category:w.STYLE,description:"Background color of WebLogo canvas"}),this.positionHeight=this.string(C.positionHeight,T.positionHeight,{category:w.STYLE,choices:Object.values(d.fH),description:"Monomer-Position height mode. Entropy of 100%(full height)"}),this._positionWidth=this.positionWidth=this.float(C.positionWidth,T.positionWidth,{category:w.LAYOUT,editor:"slider",min:4,max:100,description:'Width of position in WebLogo. If "Fit Area" is enabled, width will be calculated to fit horizontal space'}),this.verticalAlignment=this.string(C.verticalAlignment,T.verticalAlignment,{category:w.LAYOUT,choices:Object.values(d.Lp)}),this.horizontalAlignment=this.string(C.horizontalAlignment,T.horizontalAlignment,{category:w.LAYOUT,choices:Object.values(d.P4)}),this.fixWidth=this.bool(C.fixWidth,T.fixWidth,{category:w.LAYOUT,userEditable:!1}),this.fitArea=this.bool(C.fitArea,T.fitArea,{category:w.LAYOUT,description:"Fit WebLogo to the horizontal space. Calculates position width as maximum between provided width value and value needed to fit whole horizontal space."}),this.minHeight=this.int(C.minHeight,T.minHeight,{category:w.LAYOUT,editor:"slider",min:10,max:250,description:"Minimum height of WebLogo"}),this.maxHeight=this.int(C.maxHeight,T.maxHeight,{category:w.LAYOUT,editor:"slider",min:25,max:Math.max(window.innerHeight??0,1e3),nullable:!0,description:"Maximum height of WebLogo"}),this.maxMonomerLetters=this.int(C.maxMonomerLetters,T.maxMonomerLetters,{category:w.LAYOUT,editor:"slider",min:1,max:40,description:"Maximum monomer letters to display before shortening"}),this.showPositionLabels=this.bool(C.showPositionLabels,T.showPositionLabels,{category:w.LAYOUT,description:"Show position labels on top of the weblogo"}),this.positionMarginState=this.string(C.positionMarginState,T.positionMarginState,{category:w.LAYOUT,choices:Object.values(d.mH),description:"Calculate optimal margins between positions or turn it on/off"});let n=0;"auto"===this.positionMarginState&&(n=4),this.positionMargin=this.int(C.positionMargin,n,{category:w.LAYOUT,min:0,max:25,description:"Margin between positions in WebLogo"}),this.filterSource=this.string(C.filterSource,T.filterSource,{category:w.BEHAVIOR,choices:Object.values(d.lT),description:"Data source for weblogo. Selected or filtered rows."}),this.slider=o.rangeSlider(0,100,0,20,!1,{style:"barbell"}),this.canvas=o.canvas(),this.canvas.classList.value="bio-wl-canvas",this.canvas.style.width="100%",b.PackageFunctions.getMonomerLibHelper().then(e=>{this.monomerLib=e.getMonomerLib(),this.render(E.Render,"monomerLib"),this.subs.push(this.monomerLib.onChanged.subscribe(()=>{this.render(E.Render,"monomerLib changed")}))}),this.viewSyncer=new f.g(b._package.logger)}static viewerCounter=-1;viewerId=++I.viewerCounter;toLog(){return`WebLogoViewer<${this.viewerId}>`}setData(){const e=`${this.toLog()}.setData()`;b._package.logger.debug(`${e}, in`),this.viewSyncer.sync(`${e}`,async()=>{if(!this.setDataInProgress){this.setDataInProgress=!0;try{this.viewed&&(this.renderRequestSub.unsubscribe(),await this.destroyView(),this.viewed=!1),this.updateSeqCol(),this.updateEditors(),this.viewed||(await this.buildView(),this.viewed=!0)}finally{this.setDataInProgress=!1}}}),b._package.logger.debug(`${e}, out`)}viewSyncer;setDataInProgress=!1;viewSubs=[];async destroyView(){for(const e of this.viewSubs)e.unsubscribe();this.viewSubs=[];const e=this.dataFrame?"data":"null";b._package.logger.debug(`${this.toLog()}.destroyView( dataFrame = ${e} ) start`),this.host.remove(),this.msgHost=void 0,this.host=void 0,b._package.logger.debug(`${this.toLog()}.destroyView() end`)}async buildView(){const e=this.dataFrame?"data":"null";b._package.logger.debug(`${this.toLog()}.buildView( dataFrame = ${e} ) start`),window.devicePixelRatio,this.viewSubs.push(r.debounce(this.renderRequest,_.render).subscribe(this.renderRequestOnDebounce.bind(this))),this.helpUrl="/help/visualize/viewers/web-logo.md",this.msgHost=o.div("No message",{classes:"bio-wl-msg"}),this.msgHost.style.display="none",this.canvas=o.canvas(),this.canvas.style.width="100%",this.slider.root.style.position="absolute",this.slider.root.style.zIndex="999",this.slider.root.style.display="none",this.slider.root.style.height="0.7em",this.visibleSlider=!1,this.host=o.div([this.msgHost,this.canvas],{classes:"bio-wl-host",style:{display:"flex",flexDirection:"row",flexGrow:"0",flexWrap:"wrap"}}),this.root.append(this.host),this.root.append(this.slider.root),this.error&&(this.msgHost.innerText=this.error.message,o.tooltip.bind(this.msgHost,this.error.stack),this.msgHost.style.setProperty("display",null)),this.dataFrame&&(this.viewSubs.push(this.dataFrame.filter.onChanged.subscribe(this.dataFrameFilterOnChanged.bind(this))),this.viewSubs.push(this.dataFrame.selection.onChanged.subscribe(this.dataFrameSelectionOnChanged.bind(this)))),this.viewSubs.push(o.onSizeChanged(this.root).subscribe(this.rootOnSizeChanged.bind(this))),this.viewSubs.push(this.slider.onValuesChanged.subscribe(this.sliderOnValuesChanged.bind(this))),this.viewSubs.push((0,u.fromEvent)(this.canvas,"mousemove").subscribe(this.canvasOnMouseMove.bind(this))),this.viewSubs.push((0,u.fromEvent)(this.canvas,"mousedown").subscribe(this.canvasOnMouseDown.bind(this))),this.viewSubs.push((0,u.fromEvent)(this.canvas,"wheel").subscribe(this.canvasOnWheel.bind(this))),this.render(E.Freqs,"buildView"),b._package.logger.debug(`${this.toLog()}.buildView() end`)}lastSize={width:-1,height:-1};rootOnSizeChanged(e){const t={width:e.target.clientWidth,height:e.target.clientHeight};this.lastSize.width==t.width&&this.lastSize.height==t.height||(b._package.logger.debug(`${this.toLog()}.rootOnSizeChanged(), ${JSON.stringify(t)}, start `),this.render(E.Layout,"rootOnSizeChanged")),this.lastSize=t}updateEditors(){this.props.getProperty(C.valueColumnName).choices=c()(this.dataFrame.columns.numerical).map(e=>e.name).toArray()}updateSeqCol(){if(this.dataFrame&&(this.seqCol=this.sequenceColumnName?this.dataFrame.col(this.sequenceColumnName):null,null==this.seqCol&&(this.seqCol=(0,h.mn)(this.dataFrame),this.sequenceColumnName=this.seqCol?this.seqCol.name:null),this.seqCol)){try{this.seqHandler=this.seqHelper.getSeqHandler(this.seqCol),this.render(E.Freqs,"updateSeqCol()"),this.error=null}catch(e){throw this.seqCol=null,this.error=e instanceof Error?e:new Error(e.toString()),e}this.seqCol||(this.seqHandler=null,this.positionNames=[],this.positionLabels=[],this.startPosition=-1,this.endPosition=-1)}}getFilter(){let e;switch(this.filterSource){case d.lT.Filtered:e=this.dataFrame.filter;break;case d.lT.Selected:e=0===this.dataFrame.selection.trueCount?this.dataFrame.filter:this.dataFrame.selection}return e}setSliderVisibility(e){e?(this.slider.root.style.display="inherit",this.visibleSlider=!0):(this.slider.root.style.display="none",this.visibleSlider=!1)}calcLayout(e){this.host&&this.canvas&&this.slider&&(this.host.classList.remove("bio-wl-fixWidth","bio-wl-fitArea"),this.canvas.classList.remove("bio-wl-fixWidth","bio-wl-fitArea"),this._positionWidth=this.positionWidth,this._positionMargin=this.positionMargin,this._positionWidthWithMargin=this._positionWidth+this.positionMarginValue,this.fixWidth?this.calcLayoutFixWidth(e):this.calcLayoutNoFitArea(e),this.slider.root.style.width=`${this.host.clientWidth}px`)}calcLayoutFixWidth(e){if(!this.host||!this.canvas||!this.slider)return;this.host.classList.add("bio-wl-fixWidth"),this.canvas.classList.add("bio-wl-fitArea");const t=this._positionWidthWithMargin*this.Length,n=Math.min(Math.max(this.minHeight,this.root.clientHeight),this.maxHeight??this.root.clientHeight);this.host.style.justifyContent=d.P4.LEFT,this.host.style.removeProperty("margin-left"),this.host.style.removeProperty("margin-top"),this.host.style.width=this.canvas.style.width=`${t}px`,this.host.style.height=this.canvas.style.height=`${n}px`,this.host.style.left=this.canvas.style.left="0",this.host.style.top=this.canvas.style.top="0",this.host.style.setProperty("overflow","hidden","important"),this.slider.root.style.display="none",this.slider.setValues(0,Math.max(0,this.Length-1),0,Math.max(0,this.Length-1)),this.canvas.width=t*e,this.canvas.height=n*e}calcLayoutNoFitArea(e){if(!this.host||!this.canvas||!this.slider)return;let t=this._positionWidthWithMargin*this.Length,n=Math.min(this.root.clientWidth,t);this.fitArea&&t<this.root.clientWidth&&(this._positionWidth=Math.floor(this._positionWidth*this.root.clientWidth/t),this._positionWidthWithMargin=this._positionWidth+this.positionMarginValue,t=this._positionWidthWithMargin*this.Length,n=Math.min(this.root.clientWidth,t));const i=Math.min(Math.max(this.minHeight,this.root.clientHeight),this.maxHeight??this.root.clientHeight);this.canvas.style.width=`${n}px`,this.canvas.style.height=`${i}px`,this.host.style.width=`${this.root.clientWidth}px`,this.host.style.height=`${this.root.clientHeight}px`,this.host.style.justifyContent=this.horizontalAlignment,this.host.style.alignContent=this.verticalAlignment===d.Lp.TOP?"start":this.verticalAlignment===d.Lp.MIDDLE?"center":this.verticalAlignment===d.Lp.BOTTOM?"end":"inherit",this.root.clientHeight<this.minHeight&&(this.host.style.alignContent="start",this.host.style.width=`${n+8}px`);const o=t>n;if(this.setSliderVisibility(o),o){this.slider.root.style.removeProperty("display"),this.host.style.justifyContent="left",this.host.style.height=this.root.clientHeight-this.slider.root.offsetHeight+"px",this.canvas.style.height=i-this.slider.root.offsetHeight+"px",this.slider.root.style.top=`${this.host.offsetHeight}px`;let e=Math.min(Math.max(0,this.slider.min),this.Length-.001),t=Math.min(Math.max(0,this.slider.max),this.Length-.001);const n=this.canvas.clientWidth/this._positionWidthWithMargin;t=Math.min(Math.max(e,0)+n,this.Length-.001),e=Math.max(0,Math.min(t,this.Length-.001)-n),this.safeUpdateSlider(0,Math.max(this.Length-.001),e,t)}else this.safeUpdateSlider(0,Math.max(0,this.Length-.001),0,Math.max(0,this.Length-.001));this.canvas.width=n*e,this.canvas.height=i*e}calcLayoutFitArea(e){if(!this.host||!this.canvas||!this.slider)return;const t=this._positionWidth*this.Length,n=Math.min(Math.max(this.minHeight,this.root.clientHeight),this.maxHeight??this.root.clientHeight),i=t>0?(this.root.clientWidth-this.positionMarginValue*this.Length)/t:0,o=this.root.clientHeight/n,r=Math.max(1,Math.min(i,o));this._positionWidth=this.positionWidth*r,this._positionWidthWithMargin=this._positionWidth+this.positionMarginValue;const s=(this._positionWidth+this.positionMarginValue)*this.Length,a=r*n,l=Math.min(this.root.clientWidth,s);this.canvas.style.width=`${l}px`,this.canvas.style.height=`${a}px`,this.host.style.width=`${l}px`,this.host.style.height=`${this.root.clientHeight}px`,this.host.style.justifyContent=this.horizontalAlignment,this.host.style.alignContent=this.verticalAlignment===d.Lp.TOP?"start":this.verticalAlignment===d.Lp.MIDDLE?"center":this.verticalAlignment===d.Lp.BOTTOM?"end":"inherit",this.root.clientHeight<this.minHeight&&(this.host.style.alignContent="start",this.host.style.width=`${l+6}px`),this.host.style.width=`${this.host}px`;const c=s>l;if(this.setSliderVisibility(c),c){this.slider.root.style.removeProperty("display"),this.host.style.justifyContent="left",this.host.style.height=this.root.clientHeight-this.slider.root.offsetHeight+"px",this.slider.root.style.top=`${this.host.offsetHeight}px`;let e=Math.min(Math.max(0,this.slider.min),this.Length-.001),t=Math.min(Math.max(0,this.slider.max),this.Length-.001);const n=this.root.clientWidth/this._positionWidthWithMargin;t=Math.min(Math.max(e,0)+n,this.Length-.001),e=Math.max(0,Math.min(t,this.Length-.001)-n),this.safeUpdateSlider(0,Math.max(0,this.Length-.001),e,t)}else this.safeUpdateSlider(0,Math.max(0,this.Length-.001),0,Math.max(0,this.Length-.001));this.canvas.width=l*e,this.canvas.height=a*e}safeUpdateSlider(e,t,n,i){v(e,this.slider.minRange,.1)&&v(t,this.slider.maxRange,.1)&&v(n,this.slider.min,.1)&&v(i,this.slider.max,.1)||this.slider.setValues(e,t,n,i)}onPropertyChanged(e){switch(super.onPropertyChanged(e),e.name){case C.sequenceColumnName:this.updateSeqCol();break;case C.sequenceColumnName:case C.startPositionName:case C.endPositionName:case C.filterSource:case C.shrinkEmptyTail:case C.skipEmptyPositions:case C.positionHeight:case C.valueColumnName:case C.valueAggrType:this.render(E.Freqs,`onPropertyChanged( ${e.name} )`);break;case C.minHeight:case C.maxHeight:case C.maxMonomerLetters:case C.positionWidth:case C.showPositionLabels:case C.fixWidth:case C.fitArea:case C.horizontalAlignment:case C.verticalAlignment:case C.positionMargin:case C.positionMarginState:this.render(E.Layout,`onPropertyChanged(${e.name})`);break;case C.backgroundColor:this.render(E.Render,`onPropertyChanged(${e.name})`)}}onTableAttached(){b._package.logger.debug(`${this.toLog()}.onTableAttached(), `),super.onTableAttached(),this.setData()}detach(){const e=`${this.toLog()}.detach()`;b._package.logger.debug(`${e}, in`);const t=super.detach.bind(this);this.viewSyncer.sync(`${e}`,async()=>{this.setDataInProgress||(this.viewed&&(await this.destroyView(),this.viewed=!1),t())}),b._package.logger.debug(`${e}, out`)}_onSizeChanged=new u.Subject;get onSizeChanged(){return this._onSizeChanged}_onFreqsCalculated=new u.Subject;get onFreqsCalculated(){return this._onFreqsCalculated}_onLayoutCalculated=new u.Subject;get onLayoutCalculated(){return this._onLayoutCalculated}getMonomer(e,t){const n=e.x,i=Math.floor(e.x/(this._positionWidthWithMargin*t)+Math.floor(this.slider.min)),o=this.positions[i];if(!o)return[null,null,null];const r=o.getMonomerAt(n,e.y);return null==r?[o,null,null]:[o,r,o.getFreq(r)]}_nullSequence(e="X"){return this.skipEmptySequences?"":new Array(this.Length).fill(e).join("")}_removeEmptyPositions(){this.skipEmptyPositions&&(this.positions=c()(this.positions).filter(e=>!e.hasMonomer(g._S)||e.getFreq(g._S).rowCount!==e.sumRowCount).toArray())}requestedRenderLevel=E.Freqs;renderRequest=new u.Subject;renderRequestSub;render(e,t){b._package.logger.debug(`${this.toLog()}.render( recalcLevelVal=${e}, reason='${t}' )`),this.requestedRenderLevel=Math.max(this.requestedRenderLevel,e),this.renderRequest.next(this.requestedRenderLevel)}async renderInt(e){if(b._package.logger.debug(`${this.toLog()}.render.renderInt( renderLevel=${e} ), start `),this.msgHost&&(this.msgHost.style.display="none"),!this.seqCol||!this.dataFrame||null==this.host||null==this.slider)return;const t=window.devicePixelRatio,n=this.showPositionLabels?12:0;if(e>=E.Freqs&&(()=>{if(b._package.logger.debug(`${this.toLog()}.render.calculateFreqsInt(), start `),!this.host||!this.seqCol||!this.dataFrame)return;const e=this.seqCol.getTag(h.gp.positionNames),t=this.seqCol.getTag(h.gp.positionLabels);let n;!e&&this.endPositionName&&/\d+/.test(this.endPositionName)?n=Number(this.endPositionName):e&&this.endPositionName&&(n=e.split(h.z1).indexOf(this.endPositionName),n=-1!==n?n:void 0);const i=this.getFilter(),o=0===i.trueCount?this.seqHandler.maxLength:c().count(0).take(this.seqHandler.length).map(e=>{const t=this.seqHandler.getSplitted(e,n);return i.get(e)&&t?t.length:0}).reduce((e,t)=>Math.max(e,t),0);this.positionNames=e?e.split(h.z1).map(e=>e.trim()):[...Array(o).keys()].map(e=>`${e+1}`),this.positionLabels=t?t.split(h.z1).map(e=>e.trim()):void 0,this.startPosition=this.startPositionName&&this.positionNames&&this.positionNames.includes(this.startPositionName)?this.positionNames.indexOf(this.startPositionName):0,this.endPosition=this.endPositionName&&this.positionNames&&this.positionNames.includes(this.endPositionName)?this.positionNames.indexOf(this.endPositionName):o-1;const s=this.startPosition<=this.endPosition?this.endPosition-this.startPosition+1:0;this.seqHandler=this.seqHelper.getSeqHandler(this.seqCol);const a=this.startPosition<=this.endPosition?this.endPosition-this.startPosition+1:0;this.positions=new Array(a);for(let e=0;e<s;e++){const t=this.positionNames[this.startPosition+e],n=this.positionLabels?this.positionLabels[this.startPosition+e]:void 0;this.positions[e]=new M(this.startPosition+e,t,{},{label:n})}this.dataFrame.rowCount;const l=i.getSelectedIndexes();for(let e=0;e<s;++e){for(const t of l){const n=this.seqHandler.getSplitted(t),i=e+this.startPosition<n.length?n.getCanonical(this.startPosition+e):this.seqHandler.defaultGapOriginal,o=this.seqHandler.defaultGapOriginal===i?g._S:i,r=this.positions[e],s=r.getFreq(o);++r.sumRowCount,s.value=++s.rowCount}if(this.valueAggrType===r.AGG.TOTAL_COUNT)continue;let t=null;try{t=this.dataFrame.getCol(this.valueColumnName),t.matches("numerical")||(t=null)}catch{t=null}if(t){for(const n of l){const i=this.seqHandler.getSplitted(n),o=e+this.startPosition<i.length?i.getCanonical(this.startPosition+e):this.seqHandler.defaultGapOriginal,r=this.seqHandler.defaultGapOriginal===o?g._S:o,s=t.get(n);this.positions[e].getFreq(r).push(s)}this.positions[e].aggregate(this.valueAggrType)}}const u=this.valueAggrType===r.AGG.TOTAL_COUNT?0:Math.min(0,Math.min(...this.positions.map(e=>e.getMinValue())));for(let e=0;e<s;++e)this.positions[e].calcPlotValue(u),this.positions[e].calcHeights(this.positionHeight);this._removeEmptyPositions(),this._onFreqsCalculated.next()})(),this.calcLayout(t),-1===this.startPosition)return;const o=Math.max(Math.floor(this.slider.min),0),s=Math.min(this.positions.length-1,Math.floor(this.slider.max));e>=E.Layout&&((e,t,n,o)=>{b._package.logger.debug(`${this.toLog()}.render.calculateLayoutInt(), start `);const s=this.canvas.height-o*n;let a;if(this.valueAggrType===r.AGG.TOTAL_COUNT){const e=this.seqHandler.getAlphabetSize();this.positionHeight==d.fH.Entropy&&null==e&&i.shell.error("WebLogo: alphabet is undefined."),a=Math.log2(e)}else a=Math.max(...c().count(e).takeWhile(e=>e<=t).map(e=>this.positions[e].sumPlotValueForHeight));for(let i=e;i<=t;++i)i in this.positions?this.positions[i].calcScreen(i,this.slider.min,s,this.positionHeight,a,this._positionWidthWithMargin,this._positionWidth,n,o):b._package.logger.warning(`${this.toLog()}.render.calculateLayoutInt() this.positions.length = ${this.positions.length}, jPos = ${i}`);b._package.logger.debug(`${this.toLog()}.render.calculateLayoutInt(), end `),this._onLayoutCalculated.next()})(o,s,window.devicePixelRatio,n);const a=this.canvas.getContext("2d");if(a){a.save();try{this.Length,a.resetTransform(),a.fillStyle=function(e){const t=r.Color.a(e);return`#${(16777215&e).toString(16).padStart(6,"0")}`+t.toString(16).padStart(2,"0")}(this.backgroundColor),a.fillRect(0,0,this.canvas.width,this.canvas.height),a.textBaseline=this.textBaseline;const e=10*t;a.resetTransform(),a.fillStyle="black",a.textAlign="center",a.font=`${e.toFixed(1)}px Roboto, Roboto Local, sans-serif`,n>0&&this.positions.length>0&&function(e,t,n,i,o,r,s,a){e.save();try{e.textAlign="center";let l=null,c=null;for(let t=Math.floor(s);t<=Math.floor(a);t++){const n=r[t],i=e.measureText(n.name),o=i.actualBoundingBoxDescent-i.actualBoundingBoxAscent;l=null==l?i.width:Math.max(l,i.width),c=null==c?o:Math.max(c,o)}const u=l<i*t-2?1:(i*t-2)/l;for(let l=Math.floor(s);l<=Math.floor(a);l++){const a=r[l],h=(l-s)*n*t+i*t/2,d=(o*t-c)/2;e.setTransform(u,0,0,1,h,d),e.measureText(a.label),e.fillText(a.label,0,0)}}finally{e.restore()}}(a,t,this._positionWidthWithMargin,this._positionWidth,n,this.positions,this.slider.min,this.slider.max);const i="16px Roboto, Roboto Local, sans-serif",l=.25,c=12.2,u=this.seqHandler.defaultBiotype;for(let e=o;e<=s;e++)this.positions[e].render(a,i,l,c,u,this.monomerLib,this.maxMonomerLetters)}finally{a.restore()}b._package.logger.debug(`${this.toLog()}.render.renderInt( recalcLevel=${e} ), end`)}}renderRequestOnDebounce(e){const t=`${this.toLog()}.renderRequestOnDebounce()`;"HTML"!==a()(this.root).offsetParent().get()[0]?.tagName?(this.requestedRenderLevel=E.None,this.viewSyncer.sync(t,async()=>{await this.renderInt(e)})):b._package.logger.warning(`${t}, $(this.root).offsetParent() is the 'HTML' tag.`)}_lastWidth;_lastHeight;sliderOnValuesChanged(e){try{const e={minRange:this.slider.minRange,min:this.slider.min,max:this.slider.max,maxRange:this.slider.maxRange};if(this.canvas&&this.canvas.offsetWidth>0&&(this._positionWidthWithMargin??0)>0){const t=e.max-e.min,n=this.canvas.offsetWidth/t-this.positionMarginValue;v(n,this.positionWidth,.1)?this.render(E.Layout,"sliderOnValuesChanged"):this.getProperty(C.positionWidth)?.set(this,n)}}catch(e){const t=p(e);b._package.logger.error(`${this.toLog()}.sliderOnValuesChanged() error:\n`+t)}}dataFrameFilterOnChanged(e){b._package.logger.debug(`${this.toLog()}.dataFrameFilterChanged()`);try{this.filterSource===d.lT.Filtered&&this.render(E.Freqs,"dataFrameFilterOnChanged")}catch(e){const t=p(e);b._package.logger.error(`${this.toLog()}.dataFrameFilterOnChanged() error:\n`+t)}}dataFrameSelectionOnChanged(e){b._package.logger.debug(`${this.toLog()}.dataFrameSelectionOnChanged()`);try{this.filterSource===d.lT.Selected&&this.render(E.Freqs,"dataFrameSelectionOnChanged")}catch(e){const t=p(e);b._package.logger.error(`${this.toLog()}.dataFrameSelectionOnChanged() error:\n`+t)}}canvasOnMouseMove(e){if(!this.monomerLib||!this.seqHandler)return;const t=window.devicePixelRatio;try{const n=e,i=this.canvas.getCursorPosition(n,t),[s,a]=this.getMonomer(i,t),l=this.showPositionLabels?12*t:0;if(null!==s&&null==a&&0<=i.y&&i.y<=l){const e=[o.divText(`Position ${s.label}`)];if(this.valueAggrType===r.AGG.TOTAL_COUNT){const t=this.seqHandler.defaultBiotype;e.push(s.buildCompositionTable(t,this.monomerLib))}const t=o.divV(e);t.style.maxHeight="80vh",o.tooltip.show(t,n.x+16,n.y+16)}else if(null!==s&&a&&this.dataFrame&&this.seqCol&&this.seqHandler){const e=s.getFreq(a),t=[o.div(`${a}`),o.div(`${e.rowCount} rows`)];this.valueAggrType!==r.AGG.TOTAL_COUNT&&t.push(o.div(`${this.valueAggrType}: ${e.value.toFixed(3)}`));const i=o.divV(t);o.tooltip.show(i,n.x+16,n.y+16)}else o.tooltip.hide()}catch(e){const t=p(e);b._package.logger.error(`${this.toLog()}.canvasOnMouseMove() error:\n`+t)}}canvasOnMouseDown(e){try{const t=e,n=window.devicePixelRatio,[i,o]=this.getMonomer(this.canvas.getCursorPosition(t,n),n);if(null!==i&&null!==o&&this.dataFrame&&this.seqCol&&this.seqHandler){const e=r.BitSet.create(this.dataFrame.selection.length,e=>function(e,t,n,i,o,r){const s=t.getSplitted(i),a=r.pos<s.length?s.getCanonical(r.pos):null;return null!==a&&a===o}(this.dataFrame,this.seqHandler,this.getFilter(),e,o,i));this.dataFrame.selection.init(t=>e.get(t))}}catch(e){const t=p(e);b._package.logger.error(`${this.toLog()}.canvasOnMouseDown() error:\n`+t)}}canvasOnWheel(e){const t=window.devicePixelRatio;try{if(!this.visibleSlider)return;const n=this.canvas.width/(this._positionWidthWithMargin*t),i=e.deltaY/100*Math.max(Math.floor(n/5),1);this.slider.scrollBy(this.slider.min+i)}catch(e){const t=p(e);b._package.logger.error(`${this.toLog()}.canvasOnWheel() error:\n`+t)}}_onRendered=new u.Subject;get onRendered(){return this._onRendered}invalidate(e){const t=`invalidate(${e?` <- ${e} `:""})`,n=`${this.toLog()}.${t}`;this.render(E.None,t),this.viewSyncer.sync(`${n}`,async()=>{this._onRendered.next()})}async awaitRendered(e=5e3){await(0,m.PE)(this.onRendered,()=>{},()=>{this.invalidate()},e);const t=this.viewSyncer.resetErrors();if(t.length>0)throw t[0]}}},294:(e,t,n)=>{"use strict";function i(e,t){return e[t.polymerType]?.[t.symbol]}function o(e,t){return!!e[t.polymerType]?.[t.symbol]}function r(e,t,n){let i=e[t.polymerType];i||(i=e[t.polymerType]={}),i[t.symbol]=n}n.d(t,{Cg:()=>s,LQ:()=>r,bq:()=>o,vF:()=>a,xb:()=>i});class s extends Map{constructor(e){super(e)}}class a{constructor(e,t){this.molfile=e,this.monomers=t}static createEmpty(){return new a("",new s(null))}}},330:(e,t,n)=>{"use strict";n.d(t,{kA:()=>o,pz:()=>s,qj:()=>r,vG:()=>a});var i=n(2003);function o(e,t){return e?e.columns.getUnusedName(t):t}function r(e,t){return o(e,`molfile(${t})`)}function s(e){let t;if(e===i.YI.PT||e===i.YI.UN)t="PEPTIDE";else{if(e!==i.YI.RNA&&e!==i.YI.DNA)throw new Error(`Unexpected alphabet '${e}'.`);t="RNA"}return t}function a(e){const t=7===e.length?/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e):/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?[parseInt(t[1],16)/256,parseInt(t[2],16)/256,parseInt(t[3],16)/256,t.length>4?parseInt(t[4],16)/256:.3]:null}},343:e=>{"use strict";const t=/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu,n=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;function i(e){return"boolean"==typeof e.secure?e.secure:"wss"===String(e.scheme).toLowerCase()}function o(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function r(e){const t="https"===String(e.scheme).toLowerCase();return e.port!==(t?443:80)&&""!==e.port||(e.port=void 0),e.path||(e.path="/"),e}const s={scheme:"http",domainHost:!0,parse:o,serialize:r},a={scheme:"ws",domainHost:!0,parse:function(e){return e.secure=i(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e},serialize:function(e){if(e.port!==(i(e)?443:80)&&""!==e.port||(e.port=void 0),"boolean"==typeof e.secure&&(e.scheme=e.secure?"wss":"ws",e.secure=void 0),e.resourceName){const[t,n]=e.resourceName.split("?");e.path=t&&"/"!==t?t:void 0,e.query=n,e.resourceName=void 0}return e.fragment=void 0,e}},l={http:s,https:{scheme:"https",domainHost:s.domainHost,parse:o,serialize:r},ws:a,wss:{scheme:"wss",domainHost:a.domainHost,parse:a.parse,serialize:a.serialize},urn:{scheme:"urn",parse:function(e,t){if(!e.path)return e.error="URN can not be parsed",e;const i=e.path.match(n);if(i){const n=t.scheme||e.scheme||"urn";e.nid=i[1].toLowerCase(),e.nss=i[2];const o=`${n}:${t.nid||e.nid}`,r=l[o];e.path=void 0,r&&(e=r.parse(e,t))}else e.error=e.error||"URN can not be parsed.";return e},serialize:function(e,t){const n=t.scheme||e.scheme||"urn",i=e.nid.toLowerCase(),o=`${n}:${t.nid||i}`,r=l[o];r&&(e=r.serialize(e,t));const s=e,a=e.nss;return s.path=`${i||t.nid}:${a}`,t.skipEscape=!0,s},skipNormalize:!0},"urn:uuid":{scheme:"urn:uuid",parse:function(e,n){const i=e;return i.uuid=i.nss,i.nss=void 0,n.tolerant||i.uuid&&t.test(i.uuid)||(i.error=i.error||"UUID is not valid."),i},serialize:function(e){const t=e;return t.nss=(e.uuid||"").toLowerCase(),t},skipNormalize:!0}};e.exports=l},392:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o=n(4227),r=n(2023),s={keyword:"unevaluatedProperties",type:"object",schemaType:["boolean","object"],trackErrors:!0,error:{message:"must NOT have unevaluated properties",params:({params:e})=>i._`{unevaluatedProperty: ${e.unevaluatedProperty}}`},code(e){const{gen:t,schema:n,data:s,errsCount:a,it:l}=e;if(!a)throw new Error("ajv implementation error");const{allErrors:c,props:u}=l;function h(r){if(!1===n)return e.setParams({unevaluatedProperty:r}),e.error(),void(c||t.break());if(!(0,o.alwaysValidSchema)(l,n)){const n=t.name("valid");e.subschema({keyword:"unevaluatedProperties",dataProp:r,dataPropType:o.Type.Str},n),c||t.if((0,i.not)(n),()=>t.break())}}u instanceof i.Name?t.if(i._`${u} !== true`,()=>t.forIn("key",s,e=>t.if(function(e,t){return i._`!${e} || !${e}[${t}]`}(u,e),()=>h(e)))):!0!==u&&t.forIn("key",s,e=>void 0===u?h(e):t.if(function(e,t){const n=[];for(const o in e)!0===e[o]&&n.push(i._`${t} !== ${o}`);return(0,i.and)(...n)}(u,e),()=>h(e))),l.props=!0,e.ok(i._`${a} === ${r.default.errors}`)}};t.default=s},396:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getRules=t.isJSONType=void 0;const n=new Set(["string","number","integer","boolean","null","object","array"]);t.isJSONType=function(e){return"string"==typeof e&&n.has(e)},t.getRules=function(){const e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}},422:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(5765),o=n(9029),r={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:{message:({schemaCode:e})=>o.str`must match pattern "${e}"`,params:({schemaCode:e})=>o._`{pattern: ${e}}`},code(e){const{data:t,$data:n,schema:r,schemaCode:s,it:a}=e,l=a.opts.unicodeRegExp?"u":"",c=n?o._`(new RegExp(${s}, ${l}))`:(0,i.usePattern)(e,r);e.fail$data(o._`!${c}.test(${t})`)}};t.default=r},439:(e,t,n)=>{"use strict";n.d(t,{B5:()=>l,Hi:()=>i,Vl:()=>c,YI:()=>o,_S:()=>h,b9:()=>d,gp:()=>r,ot:()=>p,q7:()=>u,qE:()=>r,z1:()=>a});var i,o,r,s=n(2738);!function(e){e.FASTA="fasta",e.SEPARATOR="separator",e.HELM="helm",e.CUSTOM="custom",e.BILN="biln"}(i||(i={})),function(e){e.DNA="DNA",e.RNA="RNA",e.PT="PT",e.UN="UN"}(o||(o={})),function(e){e.aligned="aligned",e.alphabet="alphabet",e.alphabetSize=".alphabetSize",e.alphabetIsMultichar=".alphabetIsMultichar",e.separator="separator",e.isHelmCompatible=".isHelmCompatible",e.positionNames=".positionNames",e.positionLabels=".positionLabels",e.regions=".regions",e.positionShift=".positionShift",e.selectedPosition=".selectedPosition",e.polymerTypeColumnName=".polymerTypeColumnName"}(r||(r={}));const a=", ",l=/(?:\[([A-Za-z0-9_\-,()]+)\])|([A-Za-z\-])/g,c=new class{constructor(){this.fasta={peptide:new Set(["G","L","Y","S","E","Q","D","N","F","A","K","R","H","C","V","P","W","I","M","T"]),dna:new Set(["A","C","G","T"]),rna:new Set(["A","C","G","U"])}}},u=[new s.a(o.PT,c.fasta.peptide,.5),new s.a(o.DNA,c.fasta.dna,.55),new s.a(o.RNA,c.fasta.rna,.55)],h="",d={[i.FASTA]:"-",[i.SEPARATOR]:"",[i.HELM]:"*",[i.BILN]:""},p=" , "},494:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validateTuple=void 0;const i=n(9029),o=n(4227),r=n(5765),s={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){const{schema:t,it:n}=e;if(Array.isArray(t))return a(e,"additionalItems",t);n.items=!0,(0,o.alwaysValidSchema)(n,t)||e.ok((0,r.validateArray)(e))}};function a(e,t,n=e.schema){const{gen:r,parentSchema:s,data:a,keyword:l,it:c}=e;!function(e){const{opts:i,errSchemaPath:r}=c,s=n.length,a=s===e.minItems&&(s===e.maxItems||!1===e[t]);if(i.strictTuples&&!a){const e=`"${l}" is ${s}-tuple, but minItems or maxItems/${t} are not specified or different at path "${r}"`;(0,o.checkStrictMode)(c,e,i.strictTuples)}}(s),c.opts.unevaluated&&n.length&&!0!==c.items&&(c.items=o.mergeEvaluated.items(r,n.length,c.items));const u=r.name("valid"),h=r.const("len",i._`${a}.length`);n.forEach((t,n)=>{(0,o.alwaysValidSchema)(c,t)||(r.if(i._`${h} > ${n}`,()=>e.subschema({keyword:l,schemaProp:n,dataProp:n},u)),e.ok(u))})}t.validateTuple=a,t.default=s},518:e=>{"use strict";e.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/meta/core","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/core":true},"$dynamicAnchor":"meta","title":"Core vocabulary meta-schema","type":["object","boolean"],"properties":{"$id":{"$ref":"#/$defs/uriReferenceString","$comment":"Non-empty fragments not allowed.","pattern":"^[^#]*#?$"},"$schema":{"$ref":"#/$defs/uriString"},"$ref":{"$ref":"#/$defs/uriReferenceString"},"$anchor":{"$ref":"#/$defs/anchorString"},"$dynamicRef":{"$ref":"#/$defs/uriReferenceString"},"$dynamicAnchor":{"$ref":"#/$defs/anchorString"},"$vocabulary":{"type":"object","propertyNames":{"$ref":"#/$defs/uriString"},"additionalProperties":{"type":"boolean"}},"$comment":{"type":"string"},"$defs":{"type":"object","additionalProperties":{"$dynamicRef":"#meta"}}},"$defs":{"anchorString":{"type":"string","pattern":"^[A-Za-z_][-A-Za-z0-9._]*$"},"uriString":{"type":"string","format":"uri"},"uriReferenceString":{"type":"string","format":"uri-reference"}}}')},540:e=>{"use strict";e.exports=function(e){var t=document.createElement("style");return e.setAttributes(t,e.attributes),e.insert(t,e.options),t}},608:(e,t,n)=>{"use strict";n.d(t,{Ap:()=>H,aZ:()=>D,eE:()=>F});var i=n(7389),o=n(6082),r=n(1991),s=n.n(r),a=n(3516),l=n(2003);const c=Symbol("Comlink.proxy"),u=Symbol("Comlink.endpoint"),h=Symbol("Comlink.releaseProxy"),d=Symbol("Comlink.thrown"),p=e=>"object"==typeof e&&null!==e||"function"==typeof e,m=new Map([["proxy",{canHandle:e=>p(e)&&e[c],serialize(e){const{port1:t,port2:n}=new MessageChannel;return f(e,t),[n,[n]]},deserialize:e=>(e.start(),y(e))}],["throw",{canHandle:e=>p(e)&&d in e,serialize({value:e}){let t;return t=e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[t,[]]},deserialize(e){throw e.isError?Object.assign(new Error(e.value.message),e.value):e.value}}]]);function f(e,t=self){t.addEventListener("message",function n(i){if(!i||!i.data)return;const{id:o,type:r,path:s}=Object.assign({path:[]},i.data),a=(i.data.argumentList||[]).map(x);let l;try{const t=s.slice(0,-1).reduce((e,t)=>e[t],e),n=s.reduce((e,t)=>e[t],e);switch(r){case"GET":l=n;break;case"SET":t[s.slice(-1)[0]]=x(i.data.value),l=!0;break;case"APPLY":l=n.apply(t,a);break;case"CONSTRUCT":l=function(e){return Object.assign(e,{[c]:!0})}(new n(...a));break;case"ENDPOINT":{const{port1:t,port2:n}=new MessageChannel;f(e,n),l=function(e,t){return S.set(e,t),e}(t,[t])}break;case"RELEASE":l=void 0;break;default:return}}catch(e){l={value:e,[d]:0}}Promise.resolve(l).catch(e=>({value:e,[d]:0})).then(e=>{const[i,s]=A(e);t.postMessage(Object.assign(Object.assign({},i),{id:o}),s),"RELEASE"===r&&(t.removeEventListener("message",n),g(t))})}),t.start&&t.start()}function g(e){(function(e){return"MessagePort"===e.constructor.name})(e)&&e.close()}function y(e,t){return v(e,[],t)}function b(e){if(e)throw new Error("Proxy has been released and is not useable")}function v(e,t=[],n=function(){}){let i=!1;const o=new Proxy(n,{get(n,r){if(b(i),r===h)return()=>M(e,{type:"RELEASE",path:t.map(e=>e.toString())}).then(()=>{g(e),i=!0});if("then"===r){if(0===t.length)return{then:()=>o};const n=M(e,{type:"GET",path:t.map(e=>e.toString())}).then(x);return n.then.bind(n)}return v(e,[...t,r])},set(n,o,r){b(i);const[s,a]=A(r);return M(e,{type:"SET",path:[...t,o].map(e=>e.toString()),value:s},a).then(x)},apply(n,o,r){b(i);const s=t[t.length-1];if(s===u)return M(e,{type:"ENDPOINT"}).then(x);if("bind"===s)return v(e,t.slice(0,-1));const[a,l]=C(r);return M(e,{type:"APPLY",path:t.map(e=>e.toString()),argumentList:a},l).then(x)},construct(n,o){b(i);const[r,s]=C(o);return M(e,{type:"CONSTRUCT",path:t.map(e=>e.toString()),argumentList:r},s).then(x)}});return o}function w(e){return Array.prototype.concat.apply([],e)}function C(e){const t=e.map(A);return[t.map(e=>e[0]),w(t.map(e=>e[1]))]}const S=new WeakMap;function A(e){for(const[t,n]of m)if(n.canHandle(e)){const[i,o]=n.serialize(e);return[{type:"HANDLER",name:t,value:i},o]}return[{type:"RAW",value:e},S.get(e)||[]]}function x(e){switch(e.type){case"HANDLER":return m.get(e.name).deserialize(e.value);case"RAW":return e.value}}function M(e,t,n){return new Promise(i=>{const o=new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-");e.addEventListener("message",function t(n){!n.data||!n.data.id||n.data.id!==o||(e.removeEventListener("message",t),i(n.data))}),e.start&&e.start(),e.postMessage(Object.assign({id:o},t),n)})}const T="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0ICQ9U3ltYm9sKCJDb21saW5rLnByb3h5IiksQT1TeW1ib2woIkNvbWxpbmsuZW5kcG9pbnQiKSxSPVN5bWJvbCgiQ29tbGluay5yZWxlYXNlUHJveHkiKSx5PVN5bWJvbCgiQ29tbGluay50aHJvd24iKSxfPWU9PnR5cGVvZiBlPT0ib2JqZWN0IiYmZSE9PW51bGx8fHR5cGVvZiBlPT0iZnVuY3Rpb24iLEw9e2NhbkhhbmRsZTplPT5fKGUpJiZlWyRdLHNlcmlhbGl6ZShlKXtjb25zdHtwb3J0MTpyLHBvcnQyOml9PW5ldyBNZXNzYWdlQ2hhbm5lbDtyZXR1cm4gdyhlLHIpLFtpLFtpXV19LGRlc2VyaWFsaXplKGUpe3JldHVybiBlLnN0YXJ0KCksQyhlKX19LE89e2NhbkhhbmRsZTplPT5fKGUpJiZ5IGluIGUsc2VyaWFsaXplKHt2YWx1ZTplfSl7bGV0IHI7cmV0dXJuIGUgaW5zdGFuY2VvZiBFcnJvcj9yPXtpc0Vycm9yOiEwLHZhbHVlOnttZXNzYWdlOmUubWVzc2FnZSxuYW1lOmUubmFtZSxzdGFjazplLnN0YWNrfX06cj17aXNFcnJvcjohMSx2YWx1ZTplfSxbcixbXV19LGRlc2VyaWFsaXplKGUpe3Rocm93IGUuaXNFcnJvcj9PYmplY3QuYXNzaWduKG5ldyBFcnJvcihlLnZhbHVlLm1lc3NhZ2UpLGUudmFsdWUpOmUudmFsdWV9fSxFPW5ldyBNYXAoW1sicHJveHkiLExdLFsidGhyb3ciLE9dXSk7ZnVuY3Rpb24gdyhlLHI9c2VsZil7ci5hZGRFdmVudExpc3RlbmVyKCJtZXNzYWdlIixmdW5jdGlvbiBpKHMpe2lmKCFzfHwhcy5kYXRhKXJldHVybjtjb25zdHtpZDpvLHR5cGU6YSxwYXRoOm59PU9iamVjdC5hc3NpZ24oe3BhdGg6W119LHMuZGF0YSksYz0ocy5kYXRhLmFyZ3VtZW50TGlzdHx8W10pLm1hcChtKTtsZXQgbDt0cnl7Y29uc3QgdT1uLnNsaWNlKDAsLTEpLnJlZHVjZSgoZCxwKT0+ZFtwXSxlKSxmPW4ucmVkdWNlKChkLHApPT5kW3BdLGUpO3N3aXRjaChhKXtjYXNlIkdFVCI6bD1mO2JyZWFrO2Nhc2UiU0VUIjp1W24uc2xpY2UoLTEpWzBdXT1tKHMuZGF0YS52YWx1ZSksbD0hMDticmVhaztjYXNlIkFQUExZIjpsPWYuYXBwbHkodSxjKTticmVhaztjYXNlIkNPTlNUUlVDVCI6e2NvbnN0IGQ9bmV3IGYoLi4uYyk7bD16KGQpfWJyZWFrO2Nhc2UiRU5EUE9JTlQiOntjb25zdHtwb3J0MTpkLHBvcnQyOnB9PW5ldyBNZXNzYWdlQ2hhbm5lbDt3KGUscCksbD1OKGQsW2RdKX1icmVhaztjYXNlIlJFTEVBU0UiOmw9dm9pZCAwO2JyZWFrO2RlZmF1bHQ6cmV0dXJufX1jYXRjaCh1KXtsPXt2YWx1ZTp1LFt5XTowfX1Qcm9taXNlLnJlc29sdmUobCkuY2F0Y2godT0+KHt2YWx1ZTp1LFt5XTowfSkpLnRoZW4odT0+e2NvbnN0W2YsZF09Uyh1KTtyLnBvc3RNZXNzYWdlKE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSxmKSx7aWQ6b30pLGQpLGE9PT0iUkVMRUFTRSImJihyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGkpLE0ocikpfSl9KSxyLnN0YXJ0JiZyLnN0YXJ0KCl9ZnVuY3Rpb24gVChlKXtyZXR1cm4gZS5jb25zdHJ1Y3Rvci5uYW1lPT09Ik1lc3NhZ2VQb3J0In1mdW5jdGlvbiBNKGUpe1QoZSkmJmUuY2xvc2UoKX1mdW5jdGlvbiBDKGUscil7cmV0dXJuIGIoZSxbXSxyKX1mdW5jdGlvbiBoKGUpe2lmKGUpdGhyb3cgbmV3IEVycm9yKCJQcm94eSBoYXMgYmVlbiByZWxlYXNlZCBhbmQgaXMgbm90IHVzZWFibGUiKX1mdW5jdGlvbiBiKGUscj1bXSxpPWZ1bmN0aW9uKCl7fSl7bGV0IHM9ITE7Y29uc3Qgbz1uZXcgUHJveHkoaSx7Z2V0KGEsbil7aWYoaChzKSxuPT09UilyZXR1cm4oKT0+ZyhlLHt0eXBlOiJSRUxFQVNFIixwYXRoOnIubWFwKGM9PmMudG9TdHJpbmcoKSl9KS50aGVuKCgpPT57TShlKSxzPSEwfSk7aWYobj09PSJ0aGVuIil7aWYoci5sZW5ndGg9PT0wKXJldHVybnt0aGVuOigpPT5vfTtjb25zdCBjPWcoZSx7dHlwZToiR0VUIixwYXRoOnIubWFwKGw9PmwudG9TdHJpbmcoKSl9KS50aGVuKG0pO3JldHVybiBjLnRoZW4uYmluZChjKX1yZXR1cm4gYihlLFsuLi5yLG5dKX0sc2V0KGEsbixjKXtoKHMpO2NvbnN0W2wsdV09UyhjKTtyZXR1cm4gZyhlLHt0eXBlOiJTRVQiLHBhdGg6Wy4uLnIsbl0ubWFwKGY9PmYudG9TdHJpbmcoKSksdmFsdWU6bH0sdSkudGhlbihtKX0sYXBwbHkoYSxuLGMpe2gocyk7Y29uc3QgbD1yW3IubGVuZ3RoLTFdO2lmKGw9PT1BKXJldHVybiBnKGUse3R5cGU6IkVORFBPSU5UIn0pLnRoZW4obSk7aWYobD09PSJiaW5kIilyZXR1cm4gYihlLHIuc2xpY2UoMCwtMSkpO2NvbnN0W3UsZl09RihjKTtyZXR1cm4gZyhlLHt0eXBlOiJBUFBMWSIscGF0aDpyLm1hcChkPT5kLnRvU3RyaW5nKCkpLGFyZ3VtZW50TGlzdDp1fSxmKS50aGVuKG0pfSxjb25zdHJ1Y3QoYSxuKXtoKHMpO2NvbnN0W2MsbF09RihuKTtyZXR1cm4gZyhlLHt0eXBlOiJDT05TVFJVQ1QiLHBhdGg6ci5tYXAodT0+dS50b1N0cmluZygpKSxhcmd1bWVudExpc3Q6Y30sbCkudGhlbihtKX19KTtyZXR1cm4gb31mdW5jdGlvbiBEKGUpe3JldHVybiBBcnJheS5wcm90b3R5cGUuY29uY2F0LmFwcGx5KFtdLGUpfWZ1bmN0aW9uIEYoZSl7Y29uc3Qgcj1lLm1hcChTKTtyZXR1cm5bci5tYXAoaT0+aVswXSksRChyLm1hcChpPT5pWzFdKSldfWNvbnN0IFA9bmV3IFdlYWtNYXA7ZnVuY3Rpb24gTihlLHIpe3JldHVybiBQLnNldChlLHIpLGV9ZnVuY3Rpb24geihlKXtyZXR1cm4gT2JqZWN0LmFzc2lnbihlLHtbJF06ITB9KX1mdW5jdGlvbiBTKGUpe2Zvcihjb25zdFtyLGldb2YgRSlpZihpLmNhbkhhbmRsZShlKSl7Y29uc3RbcyxvXT1pLnNlcmlhbGl6ZShlKTtyZXR1cm5be3R5cGU6IkhBTkRMRVIiLG5hbWU6cix2YWx1ZTpzfSxvXX1yZXR1cm5be3R5cGU6IlJBVyIsdmFsdWU6ZX0sUC5nZXQoZSl8fFtdXX1mdW5jdGlvbiBtKGUpe3N3aXRjaChlLnR5cGUpe2Nhc2UiSEFORExFUiI6cmV0dXJuIEUuZ2V0KGUubmFtZSkuZGVzZXJpYWxpemUoZS52YWx1ZSk7Y2FzZSJSQVciOnJldHVybiBlLnZhbHVlfX1mdW5jdGlvbiBnKGUscixpKXtyZXR1cm4gbmV3IFByb21pc2Uocz0+e2NvbnN0IG89VSgpO2UuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsZnVuY3Rpb24gYShuKXshbi5kYXRhfHwhbi5kYXRhLmlkfHxuLmRhdGEuaWQhPT1vfHwoZS5yZW1vdmVFdmVudExpc3RlbmVyKCJtZXNzYWdlIixhKSxzKG4uZGF0YSkpfSksZS5zdGFydCYmZS5zdGFydCgpLGUucG9zdE1lc3NhZ2UoT2JqZWN0LmFzc2lnbih7aWQ6b30sciksaSl9KX1mdW5jdGlvbiBVKCl7cmV0dXJuIG5ldyBBcnJheSg0KS5maWxsKDApLm1hcCgoKT0+TWF0aC5mbG9vcihNYXRoLnJhbmRvbSgpKk51bWJlci5NQVhfU0FGRV9JTlRFR0VSKS50b1N0cmluZygxNikpLmpvaW4oIi0iKX1jb25zdCBXPWFzeW5jKCk9PldlYkFzc2VtYmx5LnZhbGlkYXRlKG5ldyBVaW50OEFycmF5KFswLDk3LDExNSwxMDksMSwwLDAsMCwxLDUsMSw5NiwwLDEsMTIzLDMsMiwxLDAsMTAsMTAsMSw4LDAsNjUsMCwyNTMsMTUsMjUzLDk4LDExXSkpLGs9ImVhZ2VyIix4PSJsYXp5IixqPXtzc3c6WyJzaW1kIl0sbWluaW1hcDI6WyJzaW1kIl19LHQ9e3Rvb2xzOltdLGNvbmZpZzp7fSxmaWxlczpbXSxiYXNlOnt9LGZzOnt9LGFzeW5jIGluaXQoKXtpZih0LnRvb2xzLmxlbmd0aD09PTApdGhyb3ciRXhwZWN0aW5nIGF0IGxlYXN0IDEgdG9vbC4iO2lmKG5ldyBTZXQodC50b29scy5tYXAocj0+YCR7ci50b29sfS8ke3IucHJvZ3JhbXx8ci50b29sfWApKS5zaXplIT09dC50b29scy5sZW5ndGgpdGhyb3ciRm91bmQgZHVwbGljYXRlIHRvb2xzOyBjYW4gb25seSBoYXZlIGVhY2ggdG9vbC9wcm9ncmFtIGNvbWJpbmF0aW9uIGF0IG1vc3Qgb25jZS4iO2lmKHQuYmFzZT10LnRvb2xzLmZpbmQocj0+ci5yZWluaXQhPT0hMCksIXQuYmFzZSl0aHJvdyJDb3VsZCBub3QgZmluZCBhIHRvb2wgd2l0aCBgcmVpbml0OiBmYWxzZWAgdG8gdXNlIGFzIHRoZSBiYXNlIG1vZHVsZS4gVG8gZml4IHRoaXMgaXNzdWUsIGluY2x1ZGUgdGhlIHRvb2wgYGJhc2UvMS4wLjBgIHdoZW4gaW5pdGlhbGl6aW5nIEFpb2xpLiI7cmV0dXJuIHQuYmFzZS5pc0Jhc2VNb2R1bGU9ITAsYXdhaXQgdGhpcy5fc2V0dXAodC5iYXNlKSxhd2FpdCB0aGlzLl9pbml0TW9kdWxlcygpLHQuX2xvZygiUmVhZHkiKSwhMH0sYXN5bmMgX2luaXRNb2R1bGVzKCl7YXdhaXQgUHJvbWlzZS5hbGwodC50b29scy5tYXAodGhpcy5fc2V0dXApKSxhd2FpdCB0aGlzLl9zZXR1cEZTKCl9LG1vdW50KGU9W10pe2NvbnN0IHI9YCR7dC5jb25maWcuZGlyU2hhcmVkfSR7dC5jb25maWcuZGlyRGF0YX1gLGk9YCR7dC5jb25maWcuZGlyU2hhcmVkfSR7dC5jb25maWcuZGlyTW91bnRlZH1gO2xldCBzPVtdLG89W10sYT1bXTshQXJyYXkuaXNBcnJheShlKSYmIShlIGluc3RhbmNlb2YgRmlsZUxpc3QpJiYoZT1bZV0pLHQuX2xvZyhgTW91bnRpbmcgJHtlLmxlbmd0aH0gZmlsZXNgKTtmb3IobGV0IG4gb2YgZSl7aWYobiBpbnN0YW5jZW9mIEZpbGV8fChuPT1udWxsP3ZvaWQgMDpuLmRhdGEpaW5zdGFuY2VvZiBCbG9iJiZuLm5hbWV8fHR5cGVvZihuPT1udWxsP3ZvaWQgMDpuLmRhdGEpPT0ic3RyaW5nIiYmbi5uYW1lKXR5cGVvZihuPT1udWxsP3ZvaWQgMDpuLmRhdGEpPT0ic3RyaW5nIiYmKG4uZGF0YT1uZXcgQmxvYihbbi5kYXRhXSx7dHlwZToidGV4dC9wbGFpbiJ9KSkscy5wdXNoKG4pO2Vsc2UgaWYobi5uYW1lJiZuLnVybClvLnB1c2gobik7ZWxzZSBpZih0eXBlb2Ygbj09InN0cmluZyImJm4uc3RhcnRzV2l0aCgiaHR0cCIpKW49e3VybDpuLG5hbWU6bi5zcGxpdCgiLy8iKS5wb3AoKS5yZXBsYWNlKC9cLy9nLCItIil9LG8ucHVzaChuKTtlbHNlIHRocm93J0Nhbm5vdCBtb3VudCBmaWxlKHMpIHNwZWNpZmllZC4gTXVzdCBiZSBhIEZpbGUsIEJsb2IsIGEgVVJMIHN0cmluZywgb3IgeyBuYW1lOiAiZmlsZS50eHQiLCBkYXRhOiAic3RyaW5nIiB9Lic7YS5wdXNoKG4ubmFtZSl9dHJ5e3QuZnMudW5tb3VudChpKX1jYXRjaHt9Zm9yKGxldCBuIG9mIG8pdC5mcy5jcmVhdGVMYXp5RmlsZShyLG4ubmFtZSxuLnVybCwhMCwhMCk7cmV0dXJuIHQuZmlsZXM9dC5maWxlcy5jb25jYXQocyksdC5iYXNlLm1vZHVsZS5GUy5tb3VudCh0LmJhc2UubW9kdWxlLldPUktFUkZTLHtmaWxlczp0LmZpbGVzLmZpbHRlcihuPT5uIGluc3RhbmNlb2YgRmlsZSksYmxvYnM6dC5maWxlcy5maWx0ZXIobj0+KG49PW51bGw/dm9pZCAwOm4uZGF0YSlpbnN0YW5jZW9mIEJsb2IpfSxpKSxzLm1hcChuPT57Y29uc3QgYz1gJHtpfS8ke24ubmFtZX1gLGw9YCR7cn0vJHtuLm5hbWV9YDt0cnl7dC5mcy51bmxpbmsobCl9Y2F0Y2h7fXQuX2xvZyhgQ3JlYXRpbmcgc3ltbGluazogJHtsfSAtLT4gJHtjfWApLHQuZnMuc3ltbGluayhjLGwpfSksYS5tYXAobj0+YCR7cn0vJHtufWApfSxhc3luYyBleGVjKGUscj1udWxsKXtpZih0Ll9sb2coYEV4ZWN1dGluZyAlYyR7ZX0lYyBhcmdzPSR7cn1gLCJjb2xvcjpkYXJrYmx1ZTsgZm9udC13ZWlnaHQ6Ym9sZCIsIiIpLCFlKXRocm93IkV4cGVjdGluZyBhIGNvbW1hbmQiO2xldCBpPWU7cj09bnVsbCYmKHI9ZS5zcGxpdCgiICIpLGk9ci5zaGlmdCgpKTtjb25zdCBzPXQudG9vbHMuZmluZChhPT57dmFyIGM7bGV0IG49aTtyZXR1cm4oKGM9YT09bnVsbD92b2lkIDA6YS5mZWF0dXJlcyk9PW51bGw/dm9pZCAwOmMuc2ltZCk9PT0hMCYmKG49YCR7bn0tc2ltZGApLGEucHJvZ3JhbT09bn0pO2lmKHM9PW51bGwpdGhyb3dgUHJvZ3JhbSAke2l9IG5vdCBmb3VuZC5gO3Muc3Rkb3V0PSIiLHMuc3RkZXJyPSIiLHMubG9hZGluZz09eCYmKHMubG9hZGluZz1rLGF3YWl0IHRoaXMuX2luaXRNb2R1bGVzKCkpO3RyeXtzLm1vZHVsZS5jYWxsTWFpbihyKX1jYXRjaChhKXtjb25zb2xlLmVycm9yKGEpfXRyeXtzLm1vZHVsZS5GUy5jbG9zZShzLm1vZHVsZS5GUy5zdHJlYW1zWzFdKSxzLm1vZHVsZS5GUy5jbG9zZShzLm1vZHVsZS5GUy5zdHJlYW1zWzJdKX1jYXRjaHt9cy5tb2R1bGUuRlMuc3RyZWFtc1sxXT1zLm1vZHVsZS5GUy5vcGVuKCIvZGV2L3N0ZG91dCIsInciKSxzLm1vZHVsZS5GUy5zdHJlYW1zWzJdPXMubW9kdWxlLkZTLm9wZW4oIi9kZXYvc3RkZXJyIiwidyIpO2xldCBvPXtzdGRvdXQ6cy5zdGRvdXQsc3RkZXJyOnMuc3RkZXJyfTtyZXR1cm4gdC5jb25maWcucHJpbnRJbnRlcmxlYXZlZCYmKG89cy5zdGRvdXQpLHMucmVpbml0PT09ITAmJmF3YWl0IHRoaXMucmVpbml0KHMudG9vbCksb30sY2F0KGUpe3JldHVybiB0Ll9maWxlb3AoImNhdCIsZSl9LGxzKGUpe3JldHVybiB0Ll9maWxlb3AoImxzIixlKX0sZG93bmxvYWQoZSl7cmV0dXJuIHQuX2ZpbGVvcCgiZG93bmxvYWQiLGUpfSxwd2QoKXtyZXR1cm4gdC5mcy5jd2QoKX0sY2QoZSl7Zm9yKGxldCByIG9mIHQudG9vbHMpIXIubW9kdWxlfHxyLm1vZHVsZS5GUy5jaGRpcihlKX0sbWtkaXIoZSl7cmV0dXJuIHQuZnMubWtkaXIoZSksITB9LHJlYWQoe3BhdGg6ZSxsZW5ndGg6cixmbGFnOmk9InIiLG9mZnNldDpzPTAscG9zaXRpb246bz0wfSl7Y29uc3QgYT10LmZzLm9wZW4oZSxpKSxuPW5ldyBVaW50OEFycmF5KHIpO3JldHVybiB0LmZzLnJlYWQoYSxuLHMscixvKSx0LmZzLmNsb3NlKGEpLG59LHdyaXRlKHtwYXRoOmUsYnVmZmVyOnIsZmxhZzppPSJ3KyIsb2Zmc2V0OnM9MCxwb3NpdGlvbjpvPTB9KXtjb25zdCBhPXQuZnMub3BlbihlLGkpO3QuZnMud3JpdGUoYSxyLHMsci5sZW5ndGgsbyksdC5mcy5jbG9zZShhKX0sYXN5bmMgcmVpbml0KGUpe2NvbnN0IHI9dC50b29scy5maW5kKHM9PnMudG9vbD09ZSksaT10LmJhc2UubW9kdWxlLkZTLmN3ZCgpO09iamVjdC5hc3NpZ24ocixyLmNvbmZpZyksci5yZWFkeT0hMSxhd2FpdCB0aGlzLmluaXQoKSxyLmlzQmFzZU1vZHVsZSYmdGhpcy5tb3VudCgpLHRoaXMuY2QoaSl9LF9zdGRpblR4dDoiIixfc3RkaW5QdHI6MCxnZXQgc3RkaW4oKXtyZXR1cm4gdC5fc3RkaW5UeHR9LHNldCBzdGRpbihlPSIiKXt0Ll9sb2coYFNldHRpbmcgc3RkaW4gdG8gJWMke2V9JWNgLCJjb2xvcjpkYXJrYmx1ZSIsIiIpLHQuX3N0ZGluVHh0PWUsdC5fc3RkaW5QdHI9MH0sYXN5bmMgX3NldHVwKGUpe2lmKGUucmVhZHkpcmV0dXJuO2lmKHQuX2xvZyhgU2V0dGluZyB1cCAke2UudG9vbH0gKGJhc2UgPSAke2UuaXNCYXNlTW9kdWxlPT09ITB9KS4uLmApLGUuY29uZmlnPU9iamVjdC5hc3NpZ24oe30sZSksZS51cmxQcmVmaXh8fChlLnVybFByZWZpeD1gJHt0LmNvbmZpZy51cmxDRE59LyR7ZS50b29sfS8ke2UudmVyc2lvbn1gKSxlLnByb2dyYW18fChlLnByb2dyYW09ZS50b29sKSxlLmZlYXR1cmVzfHwoZS5mZWF0dXJlcz17fSwoaltlLnByb2dyYW1dfHxbXSkuaW5jbHVkZXMoInNpbWQiKSYmKGF3YWl0IFcoKT8oZS5wcm9ncmFtKz0iLXNpbWQiLGUuZmVhdHVyZXMuc2ltZD0hMCk6dC5fbG9nKGBXZWJBc3NlbWJseSBTSU1EIGlzIG5vdCBzdXBwb3J0ZWQgaW4gdGhpcyBicm93c2VyOyB3aWxsIGxvYWQgbm9uLVNJTUQgdmVyc2lvbiBvZiAke2UucHJvZ3JhbX0uYCkpKSxlLmlzQmFzZU1vZHVsZSYmKGUubG9hZGluZz1rKSxlLmxvYWRpbmc9PT14KXt0Ll9sb2coYFdpbGwgbGF6eS1sb2FkICR7ZS50b29sfTsgc2tpcHBpbmcgaW5pdGlhbGl6YXRpb24uYCk7cmV0dXJufXNlbGYuaW1wb3J0U2NyaXB0cyhgJHtlLnVybFByZWZpeH0vJHtlLnByb2dyYW19LmpzYCksZS5tb2R1bGU9YXdhaXQgTW9kdWxlKHt0aGlzUHJvZ3JhbTplLnByb2dyYW0sbG9jYXRlRmlsZTooaSxzKT0+YCR7ZS51cmxQcmVmaXh9LyR7aX1gLHN0ZGluOigpPT50Ll9zdGRpblB0cjx0LnN0ZGluLmxlbmd0aD90LnN0ZGluLmNoYXJDb2RlQXQodC5fc3RkaW5QdHIrKyk6KHQuc3RkaW49IiIsbnVsbCkscHJpbnQ6aT0+e3QuY29uZmlnLnByaW50U3RyZWFtP3Bvc3RNZXNzYWdlKHt0eXBlOiJiaW93YXNtIix2YWx1ZTp7c3Rkb3V0Oml9fSk6ZS5zdGRvdXQrPWkrYApgfSxwcmludEVycjppPT57Y29uc3Qgcz10LmNvbmZpZy5wcmludEludGVybGVhdmVkPyJzdGRvdXQiOiJzdGRlcnIiO3QuY29uZmlnLnByaW50U3RyZWFtP3Bvc3RNZXNzYWdlKHt0eXBlOiJiaW93YXNtIix2YWx1ZTp7W3NdOml9fSk6ZVtzXSs9aStgCmB9fSk7Y29uc3Qgcj1lLm1vZHVsZS5GUztlLmlzQmFzZU1vZHVsZT8odC5fbG9nKGBTZXR0aW5nIHVwICR7ZS50b29sfSB3aXRoIGJhc2UgbW9kdWxlIGZpbGVzeXN0ZW0uLi5gKSxyLm1rZGlyKHQuY29uZmlnLmRpclNoYXJlZCw1MTEpLHIubWtkaXIoYCR7dC5jb25maWcuZGlyU2hhcmVkfS8ke3QuY29uZmlnLmRpckRhdGF9YCw1MTEpLHIubWtkaXIoYCR7dC5jb25maWcuZGlyU2hhcmVkfS8ke3QuY29uZmlnLmRpck1vdW50ZWR9YCw1MTEpLHIuY2hkaXIoYCR7dC5jb25maWcuZGlyU2hhcmVkfS8ke3QuY29uZmlnLmRpckRhdGF9YCksdC5mcz1yKToodC5fbG9nKGBTZXR0aW5nIHVwICR7ZS50b29sfSB3aXRoIGZpbGVzeXN0ZW0uLi5gKSxyLm1rZGlyKHQuY29uZmlnLmRpclNoYXJlZCksci5tb3VudChlLm1vZHVsZS5QUk9YWUZTLHtyb290OnQuY29uZmlnLmRpclNoYXJlZCxmczp0LmZzfSx0LmNvbmZpZy5kaXJTaGFyZWQpLHIuY2hkaXIodC5mcy5jd2QoKSkpLGUuc3Rkb3V0PSIiLGUuc3RkZXJyPSIiLGUucmVhZHk9ITB9LGFzeW5jIF9zZXR1cEZTKCl7Y29uc3QgZT10LmZzO2ZvcihsZXQgciBvZiB0LnRvb2xzKXtpZighci5yZWFkeSljb250aW51ZTtjb25zdCBpPXIubW9kdWxlLkZTLHM9YC8ke3IudG9vbH1gLG89YCR7dC5jb25maWcuZGlyU2hhcmVkfSR7c31gOyFpLmFuYWx5emVQYXRoKHMpLmV4aXN0c3x8ZS5hbmFseXplUGF0aChvKS5leGlzdHN8fCh0Ll9sb2coYE1vdW50aW5nICR7c30gb250byAke3QuYmFzZS50b29sfSBmaWxlc3lzdGVtIGF0ICR7b31gKSxlLm1rZGlyKG8pLGUubW91bnQodC5iYXNlLm1vZHVsZS5QUk9YWUZTLHtyb290OnMsZnM6aX0sbykpfX0sX2ZpbGVvcChlLHIpe3QuX2xvZyhgUnVubmluZyAke2V9ICR7cn1gKTtjb25zdCBpPXQuZnMuYW5hbHl6ZVBhdGgocik7aWYoIWkuZXhpc3RzKXJldHVybiB0Ll9sb2coYEZpbGUgJHtyfSBub3QgZm91bmQuYCksITE7c3dpdGNoKGUpe2Nhc2UiY2F0IjpyZXR1cm4gdC5mcy5yZWFkRmlsZShyLHtlbmNvZGluZzoidXRmOCJ9KTtjYXNlImxzIjpyZXR1cm4gdC5mcy5pc0ZpbGUoaS5vYmplY3QubW9kZSk/dC5mcy5zdGF0KHIpOnQuZnMucmVhZGRpcihyKTtjYXNlImRvd25sb2FkIjpjb25zdCBzPW5ldyBCbG9iKFt0aGlzLmNhdChyKV0pO3JldHVybiBVUkwuY3JlYXRlT2JqZWN0VVJMKHMpfXJldHVybiExfSxfbG9nKGUpe2lmKCF0LmNvbmZpZy5kZWJ1ZylyZXR1cm47bGV0IHI9Wy4uLmFyZ3VtZW50c107ci5zaGlmdCgpLGNvbnNvbGUubG9nKGAlY1tXZWJXb3JrZXJdJWMgJHtlfWAsImZvbnQtd2VpZ2h0OmJvbGQiLCIiLC4uLnIpfX07dyh0KX0pKCk7Cg==",E=typeof window<"u"&&window.Blob&&new Blob([atob(T)],{type:"text/javascript;charset=utf-8"});function _(){const e=E&&(window.URL||window.webkitURL).createObjectURL(E);try{return e?new Worker(e):new Worker("data:application/javascript;base64,"+T)}finally{e&&(window.URL||window.webkitURL).revokeObjectURL(e)}}const I={urlCDN:"https://biowasm.com/cdn/v3",urlCDNStg:"https://stg.biowasm.com/cdn/v3",dirShared:"/shared",dirMounted:"/mnt",dirData:"/data",printInterleaved:!0,printStream:!1,callback:null,debug:!1,env:"prd"};class L{constructor(e,t={}){if(null==e)throw"Expecting array of tools as input to Aioli constructor.";return Array.isArray(e)||(e=[e]),t=Object.assign({},I,t),e=e.map(this._parseTool),"stg"===t.env&&(t.urlCDN=t.urlCDNStg),this.tools=e,this.config=t,null!=this.config.callback&&(this.callback=this.config.callback),delete this.config.callback,this.init()}async init(){const e=new _;this.callback&&(e.onmessage=e=>{"biowasm"===e.data.type&&this.callback(e.data.value)});const t=y(e);return t.tools=this.tools,t.config=this.config,await t.init(),t}_parseTool(e){if("string"!=typeof e)return e;const t=e.split("/");if(2!=t.length&&3!=t.length)throw"Expecting '<tool>/<version>' or '<tool>/<program>/<version>'";return{tool:t[0],program:3==t.length?t[1]:t[0],version:t[t.length-1]}}}var N=n(3629);class P{static getAvailableScales(){return Object.entries(this.scales).map(([e,t])=>e)}static getScale(e){return(0,N.vA)(!(void 0===this.scales[e]),`Scale '${e}' was not found.`),this.scales[e]}}P.scales={WimleyWhite:{"-":0,A:.17,C:-.24,D:-.07,E:-.01,F:-1.13,G:.01,H:.17,I:-.31,K:.99,L:-.56,M:-.23,N:.42,P:.45,Q:.58,R:.81,S:.13,T:.14,V:.07,W:-1.85,Y:-.94},categorial:{"-":0,A:1,C:2,D:3,E:4,F:5,G:6,H:7,I:8,K:9,L:10,M:11,N:12,P:13,Q:14,R:15,S:16,T:17,V:18,W:19,Y:20}};class R{constructor(e="categorial"){this.aa2num=P.getScale(e),this.num2aa={},Object.entries(this.aa2num).forEach(([e,t])=>this.num2aa[t]=e)}static _truncateSequence(e){let t=0,n=e.length;const i=["NH2","COOH"];if(e.startsWith(i[0])){const n=i[0].length;(0,N.vA)("-"==e[n],`Wrong sequence format: ${i[0]} without following '-' in '${e}'.`),t=n}if(e.endsWith(i[1])){const t=i[1].length+1;(0,N.vA)("-"==e[n-t],`Wrong sequence format: ${i[1]} without '-' precending in '${e}'.`),n-=t}return e.substring(t,n)}static _dropDefises(e){return e.replace(/(-)([^-]+)/g,"$2")}static clean(e){return R._dropDefises(R._truncateSequence(e))}encode(e){const t=e.length,n=new Array(t).fill(0);for(let i=0;i<t;++i){const t=e[i];(0,N.vA)(t in this.aa2num,`Unknown char '${t}' found in sequence '${e}'`),n[i]=this.encodeLettter(t)}return n}encodeLettter(e){return this.aa2num[e]}decode(e){let t="";for(let n=0;n<e.length;++n){const i=e[n];(0,N.vA)(i in this.num2aa,`Unknown code '${i}' found in vector '${e}'`),t+=this.num2aa[i]}return t}}var $=n(4139);const O="input.fa",k="result.fasta";class H extends Error{element;constructor(e,t){super(e.innerText,t),this.element=e}}function B(e){return e.reduce((e,t,n)=>e+`>sample${n+1}\n${t}\n`,"")}async function F(e,t,n=!1,i="",r=null,s,c,u,h){let d=t.toList();n&&(d=d.map(e=>R.clean(e).replace(/\-/g,"")));const p=t.length;r??=o.Column.string("Clusters",p).init("0"),r.type!=o.COLUMN_TYPE.STRING&&(r=r.convertTo(o.TYPE.STRING)),r.compact();const m=r.categories,f=r.getRawData(),g=new Array(m.length),y=new Array(m.length);if(h){const t=e.selection;if(0===t.length)throw new Error("No selected rows in the table.");for(let e=-1;-1!==(e=t.findNext(e,!0));){const t=f[e];(g[t]??=[]).push(d[e]),(y[t]??=[]).push(e)}}else for(let e=0;e<p;++e){const t=f[e];(g[t]??=[]).push(d[e]),(y[t]??=[]).push(e)}D(y,m);const b=await new L(["base/1.0.0",{tool:"kalign",version:$.b9,reinit:!0}]),v=o.Column.string(i,p);for(let e=0;e<m.length;++e){const t=g[e];if(!t||0===t.length)continue;const n=B(t);await b.fs.writeFile(O,n);const i=`${void 0!==s?` --gpo ${s}`:""}${void 0!==c?` --gpe ${c}`:""}${void 0!==u?` --tgpe ${u}`:""}`,o=await b.exec(`kalign ${O} -f fasta -o ${k}${i}`);console.warn(o);const r=await b.cat(k);if(!r){const e=G(o,1);throw new Error(e)}const l=new a.m(r).sequencesArray,h=y[e];for(let e=0;e<l.length;++e)v.set(h[e],l[e])}const w=t.meta.units,C=t.getTag(l.gp.alphabet);return v.meta.units=w,v.setTag(l.gp.aligned,"SEQ.MSA"),v.setTag(l.gp.alphabet,C),v.semType=o.SEMTYPE.MACROMOLECULE,v}function G(e,t){const n=[],i=/^.+ERROR : (.+)$/gm;let o;for(;null!=(o=i.exec(e))&&(null==t||n.length<t);)n.push(o[1]);return n.join("\n")}function D(e,t){const n=e.map((e,t)=>[e,t]).filter(([e,t])=>1==e.length).map(([e,t])=>t);if(n.length>0){const e=i.div([i.divText(`MSA analysis is not available on single sequence clusters #${n.length}:`),...s()(n).take(3).map(e=>{let o=t[e];return o.length>25&&(o=o.slice(0,25)+"..."),i.divText(`"${o}"${e<n.length-1?", ":"."}`)}).toArray(),...n.length>3?[i.divText("...")]:[]]);throw new H(e)}}},617:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(208),o=n(9029),r=n(4227),s=n(6250),a={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:{message:({params:{i:e,j:t}})=>o.str`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>o._`{i: ${e}, j: ${t}}`},code(e){const{gen:t,data:n,$data:a,schema:l,parentSchema:c,schemaCode:u,it:h}=e;if(!a&&!l)return;const d=t.let("valid"),p=c.items?(0,i.getSchemaTypes)(c.items):[];function m(r,s){const a=t.name("item"),l=(0,i.checkDataTypes)(p,a,h.opts.strictNumbers,i.DataType.Wrong),c=t.const("indices",o._`{}`);t.for(o._`;${r}--;`,()=>{t.let(a,o._`${n}[${r}]`),t.if(l,o._`continue`),p.length>1&&t.if(o._`typeof ${a} == "string"`,o._`${a} += "_"`),t.if(o._`typeof ${c}[${a}] == "number"`,()=>{t.assign(s,o._`${c}[${a}]`),e.error(),t.assign(d,!1).break()}).code(o._`${c}[${a}] = ${r}`)})}function f(i,a){const l=(0,r.useFunc)(t,s.default),c=t.name("outer");t.label(c).for(o._`;${i}--;`,()=>t.for(o._`${a} = ${i}; ${a}--;`,()=>t.if(o._`${l}(${n}[${i}], ${n}[${a}])`,()=>{e.error(),t.assign(d,!1).break(c)})))}e.block$data(d,function(){const i=t.let("i",o._`${n}.length`),r=t.let("j");e.setParams({i,j:r}),t.assign(d,!0),t.if(o._`${i} > 1`,()=>(p.length>0&&!p.some(e=>"object"===e||"array"===e)?m:f)(i,r))},o._`${u} === false`),e.ok(d)}};t.default=a},673:(e,t,n)=>{"use strict";n.d(t,{s:()=>i});const i={true:"1",false:"0"}},684:(e,t,n)=>{"use strict";n.d(t,{C0:()=>r,GP:()=>i,Gi:()=>a,YP:()=>c,_X:()=>s,n3:()=>o,vb:()=>l});const i="dim-red-preprocessing-function",o="supportedSemTypes",r="supportedTypes",s="supportedUnits",a="supportedDistanceFunctions",l="bypassLargeDataWarning",c="show-scatterplot-progress"},857:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var i=n(1354),o=n.n(i),r=n(6314),s=n.n(r)()(o());s.push([e.id,".monomer-manager-root .grok-sketcher {\n min-width: unset !important;\n}\n\n.monomer-manager-root {\n width: 100% !important;\n height: 100% !important;\n}\n\n.monomer-manager-sketcher .ketcher-host {\n height: 100% !important;\n width: unset !important;\n} \n\n.monomer-manager-root > div:first-child {\n flex-basis: 40% !important;\n}\n.monomer-manager-root > div:nth-child(2) {\n flex-basis: 60% !important;\n}\n\n.monomer-manager-root > div:first-child > .ui-form {\n max-width: unset !important;\n}\n\n.monomer-card-info-row {\n width: 100%;\n overflow: hidden;\n text-overflow: ellipsis;\n margin-bottom: 10px;\n}\n\n.monomer-card-info-row > div:nth-child(2) {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.monomer-card-info-row > div:nth-child(1) {\n font-weight: bold;\n margin-right: 5px;\n text-wrap: nowrap;\n}\n\n.duplicate-monomer-symbol-row {\n visibility: visible !important;\n}\n\n.monomer-card-root {\n border: 2px solid var(--grey-2);\n border-radius: 5px;\n padding: 5px;\n margin: 5px;\n overflow: hidden;\n align-items: center;\n cursor: pointer;\n width: 200px;\n height: 300px;\n min-width: 200px;\n min-height: 300px;\n}\n\n.duplicate-monomers-virtual-view {\n width: 100% !important;\n overflow-x: clip;\n overflow-y: auto;\n}\n\n.monomer-manager-form-tab-control input.d4-invalid {\n background: #ff000030;\n}\n\n.monomer-lib-controls-form .ui-input-root {\n flex-wrap: nowrap !important;\n}","",{version:3,sources:["webpack://./css/monomer-manager.css"],names:[],mappings:"AAAA;IACI,2BAA2B;AAC/B;;AAEA;IACI,sBAAsB;IACtB,uBAAuB;AAC3B;;AAEA;IACI,uBAAuB;IACvB,uBAAuB;AAC3B;;AAEA;IACI,0BAA0B;AAC9B;AACA;IACI,0BAA0B;AAC9B;;AAEA;IACI,2BAA2B;AAC/B;;AAEA;IACI,WAAW;IACX,gBAAgB;IAChB,uBAAuB;IACvB,mBAAmB;AACvB;;AAEA;IACI,mBAAmB;IACnB,gBAAgB;IAChB,uBAAuB;AAC3B;;AAEA;IACI,iBAAiB;IACjB,iBAAiB;IACjB,iBAAiB;AACrB;;AAEA;IACI,8BAA8B;AAClC;;AAEA;IACI,+BAA+B;IAC/B,kBAAkB;IAClB,YAAY;IACZ,WAAW;IACX,gBAAgB;IAChB,mBAAmB;IACnB,eAAe;IACf,YAAY;IACZ,aAAa;IACb,gBAAgB;IAChB,iBAAiB;AACrB;;AAEA;IACI,sBAAsB;IACtB,gBAAgB;IAChB,gBAAgB;AACpB;;AAEA;IACI,qBAAqB;AACzB;;AAEA;IACI,4BAA4B;AAChC",sourcesContent:[".monomer-manager-root .grok-sketcher {\n min-width: unset !important;\n}\n\n.monomer-manager-root {\n width: 100% !important;\n height: 100% !important;\n}\n\n.monomer-manager-sketcher .ketcher-host {\n height: 100% !important;\n width: unset !important;\n} \n\n.monomer-manager-root > div:first-child {\n flex-basis: 40% !important;\n}\n.monomer-manager-root > div:nth-child(2) {\n flex-basis: 60% !important;\n}\n\n.monomer-manager-root > div:first-child > .ui-form {\n max-width: unset !important;\n}\n\n.monomer-card-info-row {\n width: 100%;\n overflow: hidden;\n text-overflow: ellipsis;\n margin-bottom: 10px;\n}\n\n.monomer-card-info-row > div:nth-child(2) {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.monomer-card-info-row > div:nth-child(1) {\n font-weight: bold;\n margin-right: 5px;\n text-wrap: nowrap;\n}\n\n.duplicate-monomer-symbol-row {\n visibility: visible !important;\n}\n\n.monomer-card-root {\n border: 2px solid var(--grey-2);\n border-radius: 5px;\n padding: 5px;\n margin: 5px;\n overflow: hidden;\n align-items: center;\n cursor: pointer;\n width: 200px;\n height: 300px;\n min-width: 200px;\n min-height: 300px;\n}\n\n.duplicate-monomers-virtual-view {\n width: 100% !important;\n overflow-x: clip;\n overflow-y: auto;\n}\n\n.monomer-manager-form-tab-control input.d4-invalid {\n background: #ff000030;\n}\n\n.monomer-lib-controls-form .ui-input-root {\n flex-wrap: nowrap !important;\n}"],sourceRoot:""}]);const a=s},934:function(e){e.exports=function(){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,i(e,t)}function n(e){return n=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},n(e)}function i(e,t){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},i(e,t)}function o(e,t,n){return o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}()?Reflect.construct.bind():function(e,t,n){var o=[null];o.push.apply(o,t);var r=new(Function.bind.apply(e,o));return n&&i(r,n.prototype),r},o.apply(null,arguments)}function r(e){var t="function"==typeof Map?new Map:void 0;return r=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,s)}function s(){return o(e,arguments,n(this).constructor)}return s.prototype=Object.create(e.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),i(s,e)},r(e)}function s(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var a=function(){for(var e=arguments[0],t=1,n=arguments.length;t<n;t++)if(arguments[t])for(var i in arguments[t])e[i]=arguments[t][i];return e};function l(e,t,n,i){var o=e._nodes.get(t),r=null;return o?r="mixed"===i?o.out&&o.out[n]||o.undirected&&o.undirected[n]:"directed"===i?o.out&&o.out[n]:o.undirected&&o.undirected[n]:r}function c(t){return"object"===e(t)&&null!==t}function u(e){var t;for(t in e)return!1;return!0}function h(e,t,n){Object.defineProperty(e,t,{enumerable:!1,configurable:!1,writable:!0,value:n})}function d(e,t,n){var i={enumerable:!0,configurable:!0};"function"==typeof n?i.get=n:(i.value=n,i.writable=!1),Object.defineProperty(e,t,i)}function p(e){return!(!c(e)||e.attributes&&!Array.isArray(e.attributes))}"function"==typeof Object.assign&&(a=Object.assign);var m,f={exports:{}},g="object"==typeof Reflect?Reflect:null,y=g&&"function"==typeof g.apply?g.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};m=g&&"function"==typeof g.ownKeys?g.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var b=Number.isNaN||function(e){return e!=e};function v(){v.init.call(this)}f.exports=v,f.exports.once=function(e,t){return new Promise(function(n,i){function o(n){e.removeListener(t,r),i(n)}function r(){"function"==typeof e.removeListener&&e.removeListener("error",o),n([].slice.call(arguments))}I(e,t,r,{once:!0}),"error"!==t&&function(e,t){"function"==typeof e.on&&I(e,"error",t,{once:!0})}(e,o)})},v.EventEmitter=v,v.prototype._events=void 0,v.prototype._eventsCount=0,v.prototype._maxListeners=void 0;var w=10;function C(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function S(e){return void 0===e._maxListeners?v.defaultMaxListeners:e._maxListeners}function A(e,t,n,i){var o,r,s,a;if(C(n),void 0===(r=e._events)?(r=e._events=Object.create(null),e._eventsCount=0):(void 0!==r.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),r=e._events),s=r[t]),void 0===s)s=r[t]=n,++e._eventsCount;else if("function"==typeof s?s=r[t]=i?[n,s]:[s,n]:i?s.unshift(n):s.push(n),(o=S(e))>0&&s.length>o&&!s.warned){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=s.length,a=l,console&&console.warn&&console.warn(a)}return e}function x(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function M(e,t,n){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},o=x.bind(i);return o.listener=n,i.wrapFn=o,o}function T(e,t,n){var i=e._events;if(void 0===i)return[];var o=i[t];return void 0===o?[]:"function"==typeof o?n?[o.listener||o]:[o]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(o):_(o,o.length)}function E(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function _(e,t){for(var n=new Array(t),i=0;i<t;++i)n[i]=e[i];return n}function I(e,t,n,i){if("function"==typeof e.on)i.once?e.once(t,n):e.on(t,n);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,function o(r){i.once&&e.removeEventListener(t,o),n(r)})}}function L(e){if("function"!=typeof e)throw new Error("obliterator/iterator: expecting a function!");this.next=e}Object.defineProperty(v,"defaultMaxListeners",{enumerable:!0,get:function(){return w},set:function(e){if("number"!=typeof e||e<0||b(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");w=e}}),v.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},v.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||b(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},v.prototype.getMaxListeners=function(){return S(this)},v.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var i="error"===e,o=this._events;if(void 0!==o)i=i&&void 0===o.error;else if(!i)return!1;if(i){var r;if(t.length>0&&(r=t[0]),r instanceof Error)throw r;var s=new Error("Unhandled error."+(r?" ("+r.message+")":""));throw s.context=r,s}var a=o[e];if(void 0===a)return!1;if("function"==typeof a)y(a,this,t);else{var l=a.length,c=_(a,l);for(n=0;n<l;++n)y(c[n],this,t)}return!0},v.prototype.addListener=function(e,t){return A(this,e,t,!1)},v.prototype.on=v.prototype.addListener,v.prototype.prependListener=function(e,t){return A(this,e,t,!0)},v.prototype.once=function(e,t){return C(t),this.on(e,M(this,e,t)),this},v.prototype.prependOnceListener=function(e,t){return C(t),this.prependListener(e,M(this,e,t)),this},v.prototype.removeListener=function(e,t){var n,i,o,r,s;if(C(t),void 0===(i=this._events))return this;if(void 0===(n=i[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(o=-1,r=n.length-1;r>=0;r--)if(n[r]===t||n[r].listener===t){s=n[r].listener,o=r;break}if(o<0)return this;0===o?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,o),1===n.length&&(i[e]=n[0]),void 0!==i.removeListener&&this.emit("removeListener",e,s||t)}return this},v.prototype.off=v.prototype.removeListener,v.prototype.removeAllListeners=function(e){var t,n,i;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var o,r=Object.keys(n);for(i=0;i<r.length;++i)"removeListener"!==(o=r[i])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this},v.prototype.listeners=function(e){return T(this,e,!0)},v.prototype.rawListeners=function(e){return T(this,e,!1)},v.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):E.call(e,t)},v.prototype.listenerCount=E,v.prototype.eventNames=function(){return this._eventsCount>0?m(this._events):[]},"undefined"!=typeof Symbol&&(L.prototype[Symbol.iterator]=function(){return this}),L.of=function(){var e=arguments,t=e.length,n=0;return new L(function(){return n>=t?{done:!0}:{done:!1,value:e[n++]}})},L.empty=function(){return new L(function(){return{done:!0}})},L.fromSequence=function(e){var t=0,n=e.length;return new L(function(){return t>=n?{done:!0}:{done:!1,value:e[t++]}})},L.is=function(e){return e instanceof L||"object"==typeof e&&null!==e&&"function"==typeof e.next};var N=L,P={};P.ARRAY_BUFFER_SUPPORT="undefined"!=typeof ArrayBuffer,P.SYMBOL_SUPPORT="undefined"!=typeof Symbol;var R=N,$=P,O=$.ARRAY_BUFFER_SUPPORT,k=$.SYMBOL_SUPPORT,H=function(e){var t=function(e){return"string"==typeof e||Array.isArray(e)||O&&ArrayBuffer.isView(e)?R.fromSequence(e):"object"!=typeof e||null===e?null:k&&"function"==typeof e[Symbol.iterator]?e[Symbol.iterator]():"function"==typeof e.next?e:null}(e);if(!t)throw new Error("obliterator: target is not iterable nor a valid iterator.");return t},B=H,F=function(e,t){for(var n,i=arguments.length>1?t:1/0,o=i!==1/0?new Array(i):[],r=0,s=B(e);;){if(r===i)return o;if((n=s.next()).done)return r!==t&&(o.length=r),o;o[r++]=n.value}},G=function(e){function n(t){var n;return(n=e.call(this)||this).name="GraphError",n.message=t,n}return t(n,e),n}(r(Error)),D=function(e){function n(t){var i;return(i=e.call(this,t)||this).name="InvalidArgumentsGraphError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(s(i),n.prototype.constructor),i}return t(n,e),n}(G),V=function(e){function n(t){var i;return(i=e.call(this,t)||this).name="NotFoundGraphError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(s(i),n.prototype.constructor),i}return t(n,e),n}(G),W=function(e){function n(t){var i;return(i=e.call(this,t)||this).name="UsageGraphError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(s(i),n.prototype.constructor),i}return t(n,e),n}(G);function j(e,t){this.key=e,this.attributes=t,this.clear()}function U(e,t){this.key=e,this.attributes=t,this.clear()}function q(e,t){this.key=e,this.attributes=t,this.clear()}function z(e,t,n,i,o){this.key=t,this.attributes=o,this.undirected=e,this.source=n,this.target=i}function Y(e,t,n,i,o,r,s){var a,l,c,u;if(i=""+i,0===n){if(!(a=e._nodes.get(i)))throw new V("Graph.".concat(t,': could not find the "').concat(i,'" node in the graph.'));c=o,u=r}else if(3===n){if(o=""+o,!(l=e._edges.get(o)))throw new V("Graph.".concat(t,': could not find the "').concat(o,'" edge in the graph.'));var h=l.source.key,d=l.target.key;if(i===h)a=l.target;else{if(i!==d)throw new V("Graph.".concat(t,': the "').concat(i,'" node is not attached to the "').concat(o,'" edge (').concat(h,", ").concat(d,")."));a=l.source}c=r,u=s}else{if(!(l=e._edges.get(i)))throw new V("Graph.".concat(t,': could not find the "').concat(i,'" edge in the graph.'));a=1===n?l.source:l.target,c=o,u=r}return[a,c,u]}j.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}},U.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}},q.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}},z.prototype.attach=function(){var e="out",t="in";this.undirected&&(e=t="undirected");var n=this.source.key,i=this.target.key;this.source[e][i]=this,this.undirected&&n===i||(this.target[t][n]=this)},z.prototype.attachMulti=function(){var e="out",t="in",n=this.source.key,i=this.target.key;this.undirected&&(e=t="undirected");var o=this.source[e],r=o[i];if(void 0===r)return o[i]=this,void(this.undirected&&n===i||(this.target[t][n]=this));r.previous=this,this.next=r,o[i]=this,this.target[t][n]=this},z.prototype.detach=function(){var e=this.source.key,t=this.target.key,n="out",i="in";this.undirected&&(n=i="undirected"),delete this.source[n][t],delete this.target[i][e]},z.prototype.detachMulti=function(){var e=this.source.key,t=this.target.key,n="out",i="in";this.undirected&&(n=i="undirected"),void 0===this.previous?void 0===this.next?(delete this.source[n][t],delete this.target[i][e]):(this.next.previous=void 0,this.source[n][t]=this.next,this.target[i][e]=this.next):(this.previous.next=this.next,void 0!==this.next&&(this.next.previous=this.previous))};var K=[{name:function(e){return"get".concat(e,"Attribute")},attacher:function(e,t,n){e.prototype[t]=function(e,i,o){var r=Y(this,t,n,e,i,o),s=r[0],a=r[1];return s.attributes[a]}}},{name:function(e){return"get".concat(e,"Attributes")},attacher:function(e,t,n){e.prototype[t]=function(e,i){return Y(this,t,n,e,i)[0].attributes}}},{name:function(e){return"has".concat(e,"Attribute")},attacher:function(e,t,n){e.prototype[t]=function(e,i,o){var r=Y(this,t,n,e,i,o),s=r[0],a=r[1];return s.attributes.hasOwnProperty(a)}}},{name:function(e){return"set".concat(e,"Attribute")},attacher:function(e,t,n){e.prototype[t]=function(e,i,o,r){var s=Y(this,t,n,e,i,o,r),a=s[0],l=s[1],c=s[2];return a.attributes[l]=c,this.emit("nodeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:l}),this}}},{name:function(e){return"update".concat(e,"Attribute")},attacher:function(e,t,n){e.prototype[t]=function(e,i,o,r){var s=Y(this,t,n,e,i,o,r),a=s[0],l=s[1],c=s[2];if("function"!=typeof c)throw new D("Graph.".concat(t,": updater should be a function."));var u=a.attributes,h=c(u[l]);return u[l]=h,this.emit("nodeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:l}),this}}},{name:function(e){return"remove".concat(e,"Attribute")},attacher:function(e,t,n){e.prototype[t]=function(e,i,o){var r=Y(this,t,n,e,i,o),s=r[0],a=r[1];return delete s.attributes[a],this.emit("nodeAttributesUpdated",{key:s.key,type:"remove",attributes:s.attributes,name:a}),this}}},{name:function(e){return"replace".concat(e,"Attributes")},attacher:function(e,t,n){e.prototype[t]=function(e,i,o){var r=Y(this,t,n,e,i,o),s=r[0],a=r[1];if(!c(a))throw new D("Graph.".concat(t,": provided attributes are not a plain object."));return s.attributes=a,this.emit("nodeAttributesUpdated",{key:s.key,type:"replace",attributes:s.attributes}),this}}},{name:function(e){return"merge".concat(e,"Attributes")},attacher:function(e,t,n){e.prototype[t]=function(e,i,o){var r=Y(this,t,n,e,i,o),s=r[0],l=r[1];if(!c(l))throw new D("Graph.".concat(t,": provided attributes are not a plain object."));return a(s.attributes,l),this.emit("nodeAttributesUpdated",{key:s.key,type:"merge",attributes:s.attributes,data:l}),this}}},{name:function(e){return"update".concat(e,"Attributes")},attacher:function(e,t,n){e.prototype[t]=function(e,i,o){var r=Y(this,t,n,e,i,o),s=r[0],a=r[1];if("function"!=typeof a)throw new D("Graph.".concat(t,": provided updater is not a function."));return s.attributes=a(s.attributes),this.emit("nodeAttributesUpdated",{key:s.key,type:"update",attributes:s.attributes}),this}}}],Z=[{name:function(e){return"get".concat(e,"Attribute")},attacher:function(e,t,n){e.prototype[t]=function(e,i){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new W("Graph.".concat(t,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var r=""+e,s=""+i;if(i=arguments[2],!(o=l(this,r,s,n)))throw new V("Graph.".concat(t,': could not find an edge for the given path ("').concat(r,'" - "').concat(s,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(t,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(e=""+e,!(o=this._edges.get(e)))throw new V("Graph.".concat(t,': could not find the "').concat(e,'" edge in the graph.'))}return o.attributes[i]}}},{name:function(e){return"get".concat(e,"Attributes")},attacher:function(e,t,n){e.prototype[t]=function(e){var i;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>1){if(this.multi)throw new W("Graph.".concat(t,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var o=""+e,r=""+arguments[1];if(!(i=l(this,o,r,n)))throw new V("Graph.".concat(t,': could not find an edge for the given path ("').concat(o,'" - "').concat(r,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(t,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(e=""+e,!(i=this._edges.get(e)))throw new V("Graph.".concat(t,': could not find the "').concat(e,'" edge in the graph.'))}return i.attributes}}},{name:function(e){return"has".concat(e,"Attribute")},attacher:function(e,t,n){e.prototype[t]=function(e,i){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new W("Graph.".concat(t,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var r=""+e,s=""+i;if(i=arguments[2],!(o=l(this,r,s,n)))throw new V("Graph.".concat(t,': could not find an edge for the given path ("').concat(r,'" - "').concat(s,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(t,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(e=""+e,!(o=this._edges.get(e)))throw new V("Graph.".concat(t,': could not find the "').concat(e,'" edge in the graph.'))}return o.attributes.hasOwnProperty(i)}}},{name:function(e){return"set".concat(e,"Attribute")},attacher:function(e,t,n){e.prototype[t]=function(e,i,o){var r;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>3){if(this.multi)throw new W("Graph.".concat(t,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var s=""+e,a=""+i;if(i=arguments[2],o=arguments[3],!(r=l(this,s,a,n)))throw new V("Graph.".concat(t,': could not find an edge for the given path ("').concat(s,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(t,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(e=""+e,!(r=this._edges.get(e)))throw new V("Graph.".concat(t,': could not find the "').concat(e,'" edge in the graph.'))}return r.attributes[i]=o,this.emit("edgeAttributesUpdated",{key:r.key,type:"set",attributes:r.attributes,name:i}),this}}},{name:function(e){return"update".concat(e,"Attribute")},attacher:function(e,t,n){e.prototype[t]=function(e,i,o){var r;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>3){if(this.multi)throw new W("Graph.".concat(t,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var s=""+e,a=""+i;if(i=arguments[2],o=arguments[3],!(r=l(this,s,a,n)))throw new V("Graph.".concat(t,': could not find an edge for the given path ("').concat(s,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(t,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(e=""+e,!(r=this._edges.get(e)))throw new V("Graph.".concat(t,': could not find the "').concat(e,'" edge in the graph.'))}if("function"!=typeof o)throw new D("Graph.".concat(t,": updater should be a function."));return r.attributes[i]=o(r.attributes[i]),this.emit("edgeAttributesUpdated",{key:r.key,type:"set",attributes:r.attributes,name:i}),this}}},{name:function(e){return"remove".concat(e,"Attribute")},attacher:function(e,t,n){e.prototype[t]=function(e,i){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new W("Graph.".concat(t,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var r=""+e,s=""+i;if(i=arguments[2],!(o=l(this,r,s,n)))throw new V("Graph.".concat(t,': could not find an edge for the given path ("').concat(r,'" - "').concat(s,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(t,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(e=""+e,!(o=this._edges.get(e)))throw new V("Graph.".concat(t,': could not find the "').concat(e,'" edge in the graph.'))}return delete o.attributes[i],this.emit("edgeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:i}),this}}},{name:function(e){return"replace".concat(e,"Attributes")},attacher:function(e,t,n){e.prototype[t]=function(e,i){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new W("Graph.".concat(t,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var r=""+e,s=""+i;if(i=arguments[2],!(o=l(this,r,s,n)))throw new V("Graph.".concat(t,': could not find an edge for the given path ("').concat(r,'" - "').concat(s,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(t,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(e=""+e,!(o=this._edges.get(e)))throw new V("Graph.".concat(t,': could not find the "').concat(e,'" edge in the graph.'))}if(!c(i))throw new D("Graph.".concat(t,": provided attributes are not a plain object."));return o.attributes=i,this.emit("edgeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}},{name:function(e){return"merge".concat(e,"Attributes")},attacher:function(e,t,n){e.prototype[t]=function(e,i){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new W("Graph.".concat(t,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var r=""+e,s=""+i;if(i=arguments[2],!(o=l(this,r,s,n)))throw new V("Graph.".concat(t,': could not find an edge for the given path ("').concat(r,'" - "').concat(s,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(t,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(e=""+e,!(o=this._edges.get(e)))throw new V("Graph.".concat(t,': could not find the "').concat(e,'" edge in the graph.'))}if(!c(i))throw new D("Graph.".concat(t,": provided attributes are not a plain object."));return a(o.attributes,i),this.emit("edgeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:i}),this}}},{name:function(e){return"update".concat(e,"Attributes")},attacher:function(e,t,n){e.prototype[t]=function(e,i){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new W("Graph.".concat(t,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var r=""+e,s=""+i;if(i=arguments[2],!(o=l(this,r,s,n)))throw new V("Graph.".concat(t,': could not find an edge for the given path ("').concat(r,'" - "').concat(s,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(t,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(e=""+e,!(o=this._edges.get(e)))throw new V("Graph.".concat(t,': could not find the "').concat(e,'" edge in the graph.'))}if("function"!=typeof i)throw new D("Graph.".concat(t,": provided updater is not a function."));return o.attributes=i(o.attributes),this.emit("edgeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}}],X=N,J=H,Q=function(){var e=arguments,t=null,n=-1;return new X(function(){for(var i=null;;){if(null===t){if(++n>=e.length)return{done:!0};t=J(e[n])}if(!0!==(i=t.next()).done)break;t=null}return i})},ee=[{name:"edges",type:"mixed"},{name:"inEdges",type:"directed",direction:"in"},{name:"outEdges",type:"directed",direction:"out"},{name:"inboundEdges",type:"mixed",direction:"in"},{name:"outboundEdges",type:"mixed",direction:"out"},{name:"directedEdges",type:"directed"},{name:"undirectedEdges",type:"undirected"}];function te(e,t,n,i){var o=!1;for(var r in t)if(r!==i){var s=t[r];if(o=n(s.key,s.attributes,s.source.key,s.target.key,s.source.attributes,s.target.attributes,s.undirected),e&&o)return s.key}}function ne(e,t,n,i){var o,r,s,a=!1;for(var l in t)if(l!==i){o=t[l];do{if(r=o.source,s=o.target,a=n(o.key,o.attributes,r.key,s.key,r.attributes,s.attributes,o.undirected),e&&a)return o.key;o=o.next}while(void 0!==o)}}function ie(e,t){var n,i=Object.keys(e),o=i.length,r=0;return new N(function(){do{if(n)n=n.next;else{if(r>=o)return{done:!0};var s=i[r++];if(s===t){n=void 0;continue}n=e[s]}}while(!n);return{done:!1,value:{edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected}}})}function oe(e,t,n,i){var o=t[n];if(o){var r=o.source,s=o.target;return i(o.key,o.attributes,r.key,s.key,r.attributes,s.attributes,o.undirected)&&e?o.key:void 0}}function re(e,t,n,i){var o=t[n];if(o){var r=!1;do{if(r=i(o.key,o.attributes,o.source.key,o.target.key,o.source.attributes,o.target.attributes,o.undirected),e&&r)return o.key;o=o.next}while(void 0!==o)}}function se(e,t){var n=e[t];return void 0!==n.next?new N(function(){if(!n)return{done:!0};var e={edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected};return n=n.next,{done:!1,value:e}}):N.of({edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected})}function ae(e,t,n,i){if(0!==t.size)for(var o,r,s="mixed"!==n&&n!==t.type,a="undirected"===n,l=!1,c=t._edges.values();!0!==(o=c.next()).done;)if(r=o.value,!s||r.undirected===a){var u=r,h=u.key,d=u.attributes,p=u.source,m=u.target;if(l=i(h,d,p.key,m.key,p.attributes,m.attributes,r.undirected),e&&l)return h}}function le(e,t,n,i,o,r){var s,a=t?ne:te;if("undirected"!==n){if("out"!==i&&(s=a(e,o.in,r),e&&s))return s;if("in"!==i&&(s=a(e,o.out,r,i?void 0:o.key),e&&s))return s}if("directed"!==n&&(s=a(e,o.undirected,r),e&&s))return s}function ce(e,t,n,i,o,r,s){var a,l=n?re:oe;if("undirected"!==t){if(void 0!==o.in&&"out"!==i&&(a=l(e,o.in,r,s),e&&a))return a;if(void 0!==o.out&&"in"!==i&&(i||o.key!==r)&&(a=l(e,o.out,r,s),e&&a))return a}if("directed"!==t&&void 0!==o.undirected&&(a=l(e,o.undirected,r,s),e&&a))return a}var ue=[{name:"neighbors",type:"mixed"},{name:"inNeighbors",type:"directed",direction:"in"},{name:"outNeighbors",type:"directed",direction:"out"},{name:"inboundNeighbors",type:"mixed",direction:"in"},{name:"outboundNeighbors",type:"mixed",direction:"out"},{name:"directedNeighbors",type:"directed"},{name:"undirectedNeighbors",type:"undirected"}];function he(){this.A=null,this.B=null}function de(e,t,n,i,o){for(var r in i){var s=i[r],a=s.source,l=s.target,c=a===n?l:a;if(!t||!t.has(c.key)){var u=o(c.key,c.attributes);if(e&&u)return c.key}}}function pe(e,t,n,i,o){if("mixed"!==t){if("undirected"===t)return de(e,null,i,i.undirected,o);if("string"==typeof n)return de(e,null,i,i[n],o)}var r,s=new he;if("undirected"!==t){if("out"!==n){if(r=de(e,null,i,i.in,o),e&&r)return r;s.wrap(i.in)}if("in"!==n){if(r=de(e,s,i,i.out,o),e&&r)return r;s.wrap(i.out)}}if("directed"!==t&&(r=de(e,s,i,i.undirected,o),e&&r))return r}function me(e,t,n){var i=Object.keys(n),o=i.length,r=0;return new N(function(){var s=null;do{if(r>=o)return e&&e.wrap(n),{done:!0};var a=n[i[r++]],l=a.source,c=a.target;s=l===t?c:l,e&&e.has(s.key)&&(s=null)}while(null===s);return{done:!1,value:{neighbor:s.key,attributes:s.attributes}}})}function fe(e,t,n,i,o){for(var r,s,a,l,c,u,h,d=i._nodes.values(),p=i.type;!0!==(r=d.next()).done;){var m=!1;if(s=r.value,"undirected"!==p)for(a in l=s.out){c=l[a];do{if(u=c.target,m=!0,h=o(s.key,u.key,s.attributes,u.attributes,c.key,c.attributes,c.undirected),e&&h)return c;c=c.next}while(c)}if("directed"!==p)for(a in l=s.undirected)if(!(t&&s.key>a)){c=l[a];do{if((u=c.target).key!==a&&(u=c.source),m=!0,h=o(s.key,u.key,s.attributes,u.attributes,c.key,c.attributes,c.undirected),e&&h)return c;c=c.next}while(c)}if(n&&!m&&(h=o(s.key,null,s.attributes,null,null,null,null),e&&h))return null}}function ge(e){if(!c(e))throw new D('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in e))throw new D("Graph.import: serialized node is missing its key.");if("attributes"in e&&(!c(e.attributes)||null===e.attributes))throw new D("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function ye(e){if(!c(e))throw new D('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in e))throw new D("Graph.import: serialized edge is missing its source.");if(!("target"in e))throw new D("Graph.import: serialized edge is missing its target.");if("attributes"in e&&(!c(e.attributes)||null===e.attributes))throw new D("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in e&&"boolean"!=typeof e.undirected)throw new D("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}he.prototype.wrap=function(e){null===this.A?this.A=e:null===this.B&&(this.B=e)},he.prototype.has=function(e){return null!==this.A&&e in this.A||null!==this.B&&e in this.B};var be,ve=(be=255&Math.floor(256*Math.random()),function(){return be++}),we=new Set(["directed","undirected","mixed"]),Ce=new Set(["domain","_events","_eventsCount","_maxListeners"]),Se={allowSelfLoops:!0,multi:!1,type:"mixed"};function Ae(e,t,n){var i=new e.NodeDataClass(t,n);return e._nodes.set(t,i),e.emit("nodeAdded",{key:t,attributes:n}),i}function xe(e,t,n,i,o,r,s,a){if(!i&&"undirected"===e.type)throw new W("Graph.".concat(t,": you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead."));if(i&&"directed"===e.type)throw new W("Graph.".concat(t,": you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead."));if(a&&!c(a))throw new D("Graph.".concat(t,': invalid attributes. Expecting an object but got "').concat(a,'"'));if(r=""+r,s=""+s,a=a||{},!e.allowSelfLoops&&r===s)throw new W("Graph.".concat(t,': source & target are the same ("').concat(r,"\"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false."));var l=e._nodes.get(r),u=e._nodes.get(s);if(!l)throw new V("Graph.".concat(t,': source node "').concat(r,'" not found.'));if(!u)throw new V("Graph.".concat(t,': target node "').concat(s,'" not found.'));var h={key:null,undirected:i,source:r,target:s,attributes:a};if(n)o=e._edgeKeyGenerator();else if(o=""+o,e._edges.has(o))throw new W("Graph.".concat(t,': the "').concat(o,'" edge already exists in the graph.'));if(!e.multi&&(i?void 0!==l.undirected[s]:void 0!==l.out[s]))throw new W("Graph.".concat(t,': an edge linking "').concat(r,'" to "').concat(s,"\" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option."));var d=new z(i,o,l,u,a);e._edges.set(o,d);var p=r===s;return i?(l.undirectedDegree++,u.undirectedDegree++,p&&(l.undirectedLoops++,e._undirectedSelfLoopCount++)):(l.outDegree++,u.inDegree++,p&&(l.directedLoops++,e._directedSelfLoopCount++)),e.multi?d.attachMulti():d.attach(),i?e._undirectedSize++:e._directedSize++,h.key=o,e.emit("edgeAdded",h),o}function Me(e,t,n,i,o,r,s,l,u){if(!i&&"undirected"===e.type)throw new W("Graph.".concat(t,": you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead."));if(i&&"directed"===e.type)throw new W("Graph.".concat(t,": you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead."));if(l)if(u){if("function"!=typeof l)throw new D("Graph.".concat(t,': invalid updater function. Expecting a function but got "').concat(l,'"'))}else if(!c(l))throw new D("Graph.".concat(t,': invalid attributes. Expecting an object but got "').concat(l,'"'));var h;if(r=""+r,s=""+s,u&&(h=l,l=void 0),!e.allowSelfLoops&&r===s)throw new W("Graph.".concat(t,': source & target are the same ("').concat(r,"\"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false."));var d,p,m=e._nodes.get(r),f=e._nodes.get(s);if(!n&&(d=e._edges.get(o))){if(!(d.source.key===r&&d.target.key===s||i&&d.source.key===s&&d.target.key===r))throw new W("Graph.".concat(t,': inconsistency detected when attempting to merge the "').concat(o,'" edge with "').concat(r,'" source & "').concat(s,'" target vs. ("').concat(d.source.key,'", "').concat(d.target.key,'").'));p=d}if(p||e.multi||!m||(p=i?m.undirected[s]:m.out[s]),p){var g=[p.key,!1,!1,!1];if(u?!h:!l)return g;if(u){var y=p.attributes;p.attributes=h(y),e.emit("edgeAttributesUpdated",{type:"replace",key:p.key,attributes:p.attributes})}else a(p.attributes,l),e.emit("edgeAttributesUpdated",{type:"merge",key:p.key,attributes:p.attributes,data:l});return g}l=l||{},u&&h&&(l=h(l));var b={key:null,undirected:i,source:r,target:s,attributes:l};if(n)o=e._edgeKeyGenerator();else if(o=""+o,e._edges.has(o))throw new W("Graph.".concat(t,': the "').concat(o,'" edge already exists in the graph.'));var v=!1,w=!1;m||(m=Ae(e,r,{}),v=!0,r===s&&(f=m,w=!0)),f||(f=Ae(e,s,{}),w=!0),d=new z(i,o,m,f,l),e._edges.set(o,d);var C=r===s;return i?(m.undirectedDegree++,f.undirectedDegree++,C&&(m.undirectedLoops++,e._undirectedSelfLoopCount++)):(m.outDegree++,f.inDegree++,C&&(m.directedLoops++,e._directedSelfLoopCount++)),e.multi?d.attachMulti():d.attach(),i?e._undirectedSize++:e._directedSize++,b.key=o,e.emit("edgeAdded",b),[o,!0,v,w]}function Te(e,t){e._edges.delete(t.key);var n=t.source,i=t.target,o=t.attributes,r=t.undirected,s=n===i;r?(n.undirectedDegree--,i.undirectedDegree--,s&&(n.undirectedLoops--,e._undirectedSelfLoopCount--)):(n.outDegree--,i.inDegree--,s&&(n.directedLoops--,e._directedSelfLoopCount--)),e.multi?t.detachMulti():t.detach(),r?e._undirectedSize--:e._directedSize--,e.emit("edgeDropped",{key:t.key,attributes:o,source:n.key,target:i.key,undirected:r})}var Ee=function(n){function i(e){var t;if(t=n.call(this)||this,"boolean"!=typeof(e=a({},Se,e)).multi)throw new D("Graph.constructor: invalid 'multi' option. Expecting a boolean but got \"".concat(e.multi,'".'));if(!we.has(e.type))throw new D('Graph.constructor: invalid \'type\' option. Should be one of "mixed", "directed" or "undirected" but got "'.concat(e.type,'".'));if("boolean"!=typeof e.allowSelfLoops)throw new D("Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got \"".concat(e.allowSelfLoops,'".'));var i="mixed"===e.type?j:"directed"===e.type?U:q;h(s(t),"NodeDataClass",i);var o="geid_"+ve()+"_",r=0;return h(s(t),"_attributes",{}),h(s(t),"_nodes",new Map),h(s(t),"_edges",new Map),h(s(t),"_directedSize",0),h(s(t),"_undirectedSize",0),h(s(t),"_directedSelfLoopCount",0),h(s(t),"_undirectedSelfLoopCount",0),h(s(t),"_edgeKeyGenerator",function(){var e;do{e=o+r++}while(t._edges.has(e));return e}),h(s(t),"_options",e),Ce.forEach(function(e){return h(s(t),e,t[e])}),d(s(t),"order",function(){return t._nodes.size}),d(s(t),"size",function(){return t._edges.size}),d(s(t),"directedSize",function(){return t._directedSize}),d(s(t),"undirectedSize",function(){return t._undirectedSize}),d(s(t),"selfLoopCount",function(){return t._directedSelfLoopCount+t._undirectedSelfLoopCount}),d(s(t),"directedSelfLoopCount",function(){return t._directedSelfLoopCount}),d(s(t),"undirectedSelfLoopCount",function(){return t._undirectedSelfLoopCount}),d(s(t),"multi",t._options.multi),d(s(t),"type",t._options.type),d(s(t),"allowSelfLoops",t._options.allowSelfLoops),d(s(t),"implementation",function(){return"graphology"}),t}t(i,n);var o=i.prototype;return o._resetInstanceCounters=function(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0},o.hasNode=function(e){return this._nodes.has(""+e)},o.hasDirectedEdge=function(e,t){if("undirected"===this.type)return!1;if(1===arguments.length){var n=""+e,i=this._edges.get(n);return!!i&&!i.undirected}if(2===arguments.length){e=""+e,t=""+t;var o=this._nodes.get(e);return!!o&&o.out.hasOwnProperty(t)}throw new D("Graph.hasDirectedEdge: invalid arity (".concat(arguments.length,", instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target."))},o.hasUndirectedEdge=function(e,t){if("directed"===this.type)return!1;if(1===arguments.length){var n=""+e,i=this._edges.get(n);return!!i&&i.undirected}if(2===arguments.length){e=""+e,t=""+t;var o=this._nodes.get(e);return!!o&&o.undirected.hasOwnProperty(t)}throw new D("Graph.hasDirectedEdge: invalid arity (".concat(arguments.length,", instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target."))},o.hasEdge=function(e,t){if(1===arguments.length){var n=""+e;return this._edges.has(n)}if(2===arguments.length){e=""+e,t=""+t;var i=this._nodes.get(e);return!!i&&(void 0!==i.out&&i.out.hasOwnProperty(t)||void 0!==i.undirected&&i.undirected.hasOwnProperty(t))}throw new D("Graph.hasEdge: invalid arity (".concat(arguments.length,", instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target."))},o.directedEdge=function(e,t){if("undirected"!==this.type){if(e=""+e,t=""+t,this.multi)throw new W("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");var n=this._nodes.get(e);if(!n)throw new V('Graph.directedEdge: could not find the "'.concat(e,'" source node in the graph.'));if(!this._nodes.has(t))throw new V('Graph.directedEdge: could not find the "'.concat(t,'" target node in the graph.'));var i=n.out&&n.out[t]||void 0;return i?i.key:void 0}},o.undirectedEdge=function(e,t){if("directed"!==this.type){if(e=""+e,t=""+t,this.multi)throw new W("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");var n=this._nodes.get(e);if(!n)throw new V('Graph.undirectedEdge: could not find the "'.concat(e,'" source node in the graph.'));if(!this._nodes.has(t))throw new V('Graph.undirectedEdge: could not find the "'.concat(t,'" target node in the graph.'));var i=n.undirected&&n.undirected[t]||void 0;return i?i.key:void 0}},o.edge=function(e,t){if(this.multi)throw new W("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");e=""+e,t=""+t;var n=this._nodes.get(e);if(!n)throw new V('Graph.edge: could not find the "'.concat(e,'" source node in the graph.'));if(!this._nodes.has(t))throw new V('Graph.edge: could not find the "'.concat(t,'" target node in the graph.'));var i=n.out&&n.out[t]||n.undirected&&n.undirected[t]||void 0;if(i)return i.key},o.areDirectedNeighbors=function(e,t){e=""+e,t=""+t;var n=this._nodes.get(e);if(!n)throw new V('Graph.areDirectedNeighbors: could not find the "'.concat(e,'" node in the graph.'));return"undirected"!==this.type&&(t in n.in||t in n.out)},o.areOutNeighbors=function(e,t){e=""+e,t=""+t;var n=this._nodes.get(e);if(!n)throw new V('Graph.areOutNeighbors: could not find the "'.concat(e,'" node in the graph.'));return"undirected"!==this.type&&t in n.out},o.areInNeighbors=function(e,t){e=""+e,t=""+t;var n=this._nodes.get(e);if(!n)throw new V('Graph.areInNeighbors: could not find the "'.concat(e,'" node in the graph.'));return"undirected"!==this.type&&t in n.in},o.areUndirectedNeighbors=function(e,t){e=""+e,t=""+t;var n=this._nodes.get(e);if(!n)throw new V('Graph.areUndirectedNeighbors: could not find the "'.concat(e,'" node in the graph.'));return"directed"!==this.type&&t in n.undirected},o.areNeighbors=function(e,t){e=""+e,t=""+t;var n=this._nodes.get(e);if(!n)throw new V('Graph.areNeighbors: could not find the "'.concat(e,'" node in the graph.'));return"undirected"!==this.type&&(t in n.in||t in n.out)||"directed"!==this.type&&t in n.undirected},o.areInboundNeighbors=function(e,t){e=""+e,t=""+t;var n=this._nodes.get(e);if(!n)throw new V('Graph.areInboundNeighbors: could not find the "'.concat(e,'" node in the graph.'));return"undirected"!==this.type&&t in n.in||"directed"!==this.type&&t in n.undirected},o.areOutboundNeighbors=function(e,t){e=""+e,t=""+t;var n=this._nodes.get(e);if(!n)throw new V('Graph.areOutboundNeighbors: could not find the "'.concat(e,'" node in the graph.'));return"undirected"!==this.type&&t in n.out||"directed"!==this.type&&t in n.undirected},o.inDegree=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new V('Graph.inDegree: could not find the "'.concat(e,'" node in the graph.'));return"undirected"===this.type?0:t.inDegree},o.outDegree=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new V('Graph.outDegree: could not find the "'.concat(e,'" node in the graph.'));return"undirected"===this.type?0:t.outDegree},o.directedDegree=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new V('Graph.directedDegree: could not find the "'.concat(e,'" node in the graph.'));return"undirected"===this.type?0:t.inDegree+t.outDegree},o.undirectedDegree=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new V('Graph.undirectedDegree: could not find the "'.concat(e,'" node in the graph.'));return"directed"===this.type?0:t.undirectedDegree},o.inboundDegree=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new V('Graph.inboundDegree: could not find the "'.concat(e,'" node in the graph.'));var n=0;return"directed"!==this.type&&(n+=t.undirectedDegree),"undirected"!==this.type&&(n+=t.inDegree),n},o.outboundDegree=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new V('Graph.outboundDegree: could not find the "'.concat(e,'" node in the graph.'));var n=0;return"directed"!==this.type&&(n+=t.undirectedDegree),"undirected"!==this.type&&(n+=t.outDegree),n},o.degree=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new V('Graph.degree: could not find the "'.concat(e,'" node in the graph.'));var n=0;return"directed"!==this.type&&(n+=t.undirectedDegree),"undirected"!==this.type&&(n+=t.inDegree+t.outDegree),n},o.inDegreeWithoutSelfLoops=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new V('Graph.inDegreeWithoutSelfLoops: could not find the "'.concat(e,'" node in the graph.'));return"undirected"===this.type?0:t.inDegree-t.directedLoops},o.outDegreeWithoutSelfLoops=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new V('Graph.outDegreeWithoutSelfLoops: could not find the "'.concat(e,'" node in the graph.'));return"undirected"===this.type?0:t.outDegree-t.directedLoops},o.directedDegreeWithoutSelfLoops=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new V('Graph.directedDegreeWithoutSelfLoops: could not find the "'.concat(e,'" node in the graph.'));return"undirected"===this.type?0:t.inDegree+t.outDegree-2*t.directedLoops},o.undirectedDegreeWithoutSelfLoops=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new V('Graph.undirectedDegreeWithoutSelfLoops: could not find the "'.concat(e,'" node in the graph.'));return"directed"===this.type?0:t.undirectedDegree-2*t.undirectedLoops},o.inboundDegreeWithoutSelfLoops=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new V('Graph.inboundDegreeWithoutSelfLoops: could not find the "'.concat(e,'" node in the graph.'));var n=0,i=0;return"directed"!==this.type&&(n+=t.undirectedDegree,i+=2*t.undirectedLoops),"undirected"!==this.type&&(n+=t.inDegree,i+=t.directedLoops),n-i},o.outboundDegreeWithoutSelfLoops=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new V('Graph.outboundDegreeWithoutSelfLoops: could not find the "'.concat(e,'" node in the graph.'));var n=0,i=0;return"directed"!==this.type&&(n+=t.undirectedDegree,i+=2*t.undirectedLoops),"undirected"!==this.type&&(n+=t.outDegree,i+=t.directedLoops),n-i},o.degreeWithoutSelfLoops=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new V('Graph.degreeWithoutSelfLoops: could not find the "'.concat(e,'" node in the graph.'));var n=0,i=0;return"directed"!==this.type&&(n+=t.undirectedDegree,i+=2*t.undirectedLoops),"undirected"!==this.type&&(n+=t.inDegree+t.outDegree,i+=2*t.directedLoops),n-i},o.source=function(e){e=""+e;var t=this._edges.get(e);if(!t)throw new V('Graph.source: could not find the "'.concat(e,'" edge in the graph.'));return t.source.key},o.target=function(e){e=""+e;var t=this._edges.get(e);if(!t)throw new V('Graph.target: could not find the "'.concat(e,'" edge in the graph.'));return t.target.key},o.extremities=function(e){e=""+e;var t=this._edges.get(e);if(!t)throw new V('Graph.extremities: could not find the "'.concat(e,'" edge in the graph.'));return[t.source.key,t.target.key]},o.opposite=function(e,t){e=""+e,t=""+t;var n=this._edges.get(t);if(!n)throw new V('Graph.opposite: could not find the "'.concat(t,'" edge in the graph.'));var i=n.source.key,o=n.target.key;if(e===i)return o;if(e===o)return i;throw new V('Graph.opposite: the "'.concat(e,'" node is not attached to the "').concat(t,'" edge (').concat(i,", ").concat(o,")."))},o.hasExtremity=function(e,t){e=""+e,t=""+t;var n=this._edges.get(e);if(!n)throw new V('Graph.hasExtremity: could not find the "'.concat(e,'" edge in the graph.'));return n.source.key===t||n.target.key===t},o.isUndirected=function(e){e=""+e;var t=this._edges.get(e);if(!t)throw new V('Graph.isUndirected: could not find the "'.concat(e,'" edge in the graph.'));return t.undirected},o.isDirected=function(e){e=""+e;var t=this._edges.get(e);if(!t)throw new V('Graph.isDirected: could not find the "'.concat(e,'" edge in the graph.'));return!t.undirected},o.isSelfLoop=function(e){e=""+e;var t=this._edges.get(e);if(!t)throw new V('Graph.isSelfLoop: could not find the "'.concat(e,'" edge in the graph.'));return t.source===t.target},o.addNode=function(e,t){var n=function(e,t,n){if(n&&!c(n))throw new D('Graph.addNode: invalid attributes. Expecting an object but got "'.concat(n,'"'));if(t=""+t,n=n||{},e._nodes.has(t))throw new W('Graph.addNode: the "'.concat(t,'" node already exist in the graph.'));var i=new e.NodeDataClass(t,n);return e._nodes.set(t,i),e.emit("nodeAdded",{key:t,attributes:n}),i}(this,e,t);return n.key},o.mergeNode=function(e,t){if(t&&!c(t))throw new D('Graph.mergeNode: invalid attributes. Expecting an object but got "'.concat(t,'"'));e=""+e,t=t||{};var n=this._nodes.get(e);return n?(t&&(a(n.attributes,t),this.emit("nodeAttributesUpdated",{type:"merge",key:e,attributes:n.attributes,data:t})),[e,!1]):(n=new this.NodeDataClass(e,t),this._nodes.set(e,n),this.emit("nodeAdded",{key:e,attributes:t}),[e,!0])},o.updateNode=function(e,t){if(t&&"function"!=typeof t)throw new D('Graph.updateNode: invalid updater function. Expecting a function but got "'.concat(t,'"'));e=""+e;var n=this._nodes.get(e);if(n){if(t){var i=n.attributes;n.attributes=t(i),this.emit("nodeAttributesUpdated",{type:"replace",key:e,attributes:n.attributes})}return[e,!1]}var o=t?t({}):{};return n=new this.NodeDataClass(e,o),this._nodes.set(e,n),this.emit("nodeAdded",{key:e,attributes:o}),[e,!0]},o.dropNode=function(e){e=""+e;var t,n=this._nodes.get(e);if(!n)throw new V('Graph.dropNode: could not find the "'.concat(e,'" node in the graph.'));if("undirected"!==this.type){for(var i in n.out){t=n.out[i];do{Te(this,t),t=t.next}while(t)}for(var o in n.in){t=n.in[o];do{Te(this,t),t=t.next}while(t)}}if("directed"!==this.type)for(var r in n.undirected){t=n.undirected[r];do{Te(this,t),t=t.next}while(t)}this._nodes.delete(e),this.emit("nodeDropped",{key:e,attributes:n.attributes})},o.dropEdge=function(e){var t;if(arguments.length>1){var n=""+arguments[0],i=""+arguments[1];if(!(t=l(this,n,i,this.type)))throw new V('Graph.dropEdge: could not find the "'.concat(n,'" -> "').concat(i,'" edge in the graph.'))}else if(e=""+e,!(t=this._edges.get(e)))throw new V('Graph.dropEdge: could not find the "'.concat(e,'" edge in the graph.'));return Te(this,t),this},o.dropDirectedEdge=function(e,t){if(arguments.length<2)throw new W("Graph.dropDirectedEdge: it does not make sense to try and drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new W("Graph.dropDirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");var n=l(this,e=""+e,t=""+t,"directed");if(!n)throw new V('Graph.dropDirectedEdge: could not find a "'.concat(e,'" -> "').concat(t,'" edge in the graph.'));return Te(this,n),this},o.dropUndirectedEdge=function(e,t){if(arguments.length<2)throw new W("Graph.dropUndirectedEdge: it does not make sense to drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new W("Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");var n=l(this,e,t,"undirected");if(!n)throw new V('Graph.dropUndirectedEdge: could not find a "'.concat(e,'" -> "').concat(t,'" edge in the graph.'));return Te(this,n),this},o.clear=function(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")},o.clearEdges=function(){for(var e,t=this._nodes.values();!0!==(e=t.next()).done;)e.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")},o.getAttribute=function(e){return this._attributes[e]},o.getAttributes=function(){return this._attributes},o.hasAttribute=function(e){return this._attributes.hasOwnProperty(e)},o.setAttribute=function(e,t){return this._attributes[e]=t,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this},o.updateAttribute=function(e,t){if("function"!=typeof t)throw new D("Graph.updateAttribute: updater should be a function.");var n=this._attributes[e];return this._attributes[e]=t(n),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this},o.removeAttribute=function(e){return delete this._attributes[e],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:e}),this},o.replaceAttributes=function(e){if(!c(e))throw new D("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=e,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this},o.mergeAttributes=function(e){if(!c(e))throw new D("Graph.mergeAttributes: provided attributes are not a plain object.");return a(this._attributes,e),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:e}),this},o.updateAttributes=function(e){if("function"!=typeof e)throw new D("Graph.updateAttributes: provided updater is not a function.");return this._attributes=e(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this},o.updateEachNodeAttributes=function(e,t){if("function"!=typeof e)throw new D("Graph.updateEachNodeAttributes: expecting an updater function.");if(t&&!p(t))throw new D("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");for(var n,i,o=this._nodes.values();!0!==(n=o.next()).done;)(i=n.value).attributes=e(i.key,i.attributes);this.emit("eachNodeAttributesUpdated",{hints:t||null})},o.updateEachEdgeAttributes=function(e,t){if("function"!=typeof e)throw new D("Graph.updateEachEdgeAttributes: expecting an updater function.");if(t&&!p(t))throw new D("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");for(var n,i,o,r,s=this._edges.values();!0!==(n=s.next()).done;)o=(i=n.value).source,r=i.target,i.attributes=e(i.key,i.attributes,o.key,r.key,o.attributes,r.attributes,i.undirected);this.emit("eachEdgeAttributesUpdated",{hints:t||null})},o.forEachAdjacencyEntry=function(e){if("function"!=typeof e)throw new D("Graph.forEachAdjacencyEntry: expecting a callback.");fe(!1,!1,!1,this,e)},o.forEachAdjacencyEntryWithOrphans=function(e){if("function"!=typeof e)throw new D("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");fe(!1,!1,!0,this,e)},o.forEachAssymetricAdjacencyEntry=function(e){if("function"!=typeof e)throw new D("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");fe(!1,!0,!1,this,e)},o.forEachAssymetricAdjacencyEntryWithOrphans=function(e){if("function"!=typeof e)throw new D("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");fe(!1,!0,!0,this,e)},o.nodes=function(){return"function"==typeof Array.from?Array.from(this._nodes.keys()):F(this._nodes.keys(),this._nodes.size)},o.forEachNode=function(e){if("function"!=typeof e)throw new D("Graph.forEachNode: expecting a callback.");for(var t,n,i=this._nodes.values();!0!==(t=i.next()).done;)e((n=t.value).key,n.attributes)},o.findNode=function(e){if("function"!=typeof e)throw new D("Graph.findNode: expecting a callback.");for(var t,n,i=this._nodes.values();!0!==(t=i.next()).done;)if(e((n=t.value).key,n.attributes))return n.key},o.mapNodes=function(e){if("function"!=typeof e)throw new D("Graph.mapNode: expecting a callback.");for(var t,n,i=this._nodes.values(),o=new Array(this.order),r=0;!0!==(t=i.next()).done;)n=t.value,o[r++]=e(n.key,n.attributes);return o},o.someNode=function(e){if("function"!=typeof e)throw new D("Graph.someNode: expecting a callback.");for(var t,n,i=this._nodes.values();!0!==(t=i.next()).done;)if(e((n=t.value).key,n.attributes))return!0;return!1},o.everyNode=function(e){if("function"!=typeof e)throw new D("Graph.everyNode: expecting a callback.");for(var t,n,i=this._nodes.values();!0!==(t=i.next()).done;)if(!e((n=t.value).key,n.attributes))return!1;return!0},o.filterNodes=function(e){if("function"!=typeof e)throw new D("Graph.filterNodes: expecting a callback.");for(var t,n,i=this._nodes.values(),o=[];!0!==(t=i.next()).done;)e((n=t.value).key,n.attributes)&&o.push(n.key);return o},o.reduceNodes=function(e,t){if("function"!=typeof e)throw new D("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new D("Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.");for(var n,i,o=t,r=this._nodes.values();!0!==(n=r.next()).done;)o=e(o,(i=n.value).key,i.attributes);return o},o.nodeEntries=function(){var e=this._nodes.values();return new N(function(){var t=e.next();if(t.done)return t;var n=t.value;return{value:{node:n.key,attributes:n.attributes},done:!1}})},o.export=function(){var e=this,t=new Array(this._nodes.size),n=0;this._nodes.forEach(function(e,i){t[n++]=function(e,t){var n={key:e};return u(t.attributes)||(n.attributes=a({},t.attributes)),n}(i,e)});var i=new Array(this._edges.size);return n=0,this._edges.forEach(function(t,o){i[n++]=function(e,t,n){var i={key:t,source:n.source.key,target:n.target.key};return u(n.attributes)||(i.attributes=a({},n.attributes)),"mixed"===e&&n.undirected&&(i.undirected=!0),i}(e.type,o,t)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:t,edges:i}},o.import=function(e){var t,n,o,r,s,a=this,l=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(e instanceof i)return e.forEachNode(function(e,t){l?a.mergeNode(e,t):a.addNode(e,t)}),e.forEachEdge(function(e,t,n,i,o,r,s){l?s?a.mergeUndirectedEdgeWithKey(e,n,i,t):a.mergeDirectedEdgeWithKey(e,n,i,t):s?a.addUndirectedEdgeWithKey(e,n,i,t):a.addDirectedEdgeWithKey(e,n,i,t)}),this;if(!c(e))throw new D("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(e.attributes){if(!c(e.attributes))throw new D("Graph.import: invalid attributes. Expecting a plain object.");l?this.mergeAttributes(e.attributes):this.replaceAttributes(e.attributes)}if(e.nodes){if(o=e.nodes,!Array.isArray(o))throw new D("Graph.import: invalid nodes. Expecting an array.");for(t=0,n=o.length;t<n;t++){ge(r=o[t]);var u=r,h=u.key,d=u.attributes;l?this.mergeNode(h,d):this.addNode(h,d)}}if(e.edges){var p=!1;if("undirected"===this.type&&(p=!0),o=e.edges,!Array.isArray(o))throw new D("Graph.import: invalid edges. Expecting an array.");for(t=0,n=o.length;t<n;t++){ye(s=o[t]);var m=s,f=m.source,g=m.target,y=m.attributes,b=m.undirected,v=void 0===b?p:b;"key"in s?(l?v?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:v?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey).call(this,s.key,f,g,y):(l?v?this.mergeUndirectedEdge:this.mergeDirectedEdge:v?this.addUndirectedEdge:this.addDirectedEdge).call(this,f,g,y)}}return this},o.nullCopy=function(e){var t=new i(a({},this._options,e));return t.replaceAttributes(a({},this.getAttributes())),t},o.emptyCopy=function(e){var t=this.nullCopy(e);return this._nodes.forEach(function(e,n){var i=a({},e.attributes);e=new t.NodeDataClass(n,i),t._nodes.set(n,e)}),t},o.copy=function(e){if("string"==typeof(e=e||{}).type&&e.type!==this.type&&"mixed"!==e.type)throw new W('Graph.copy: cannot create an incompatible copy from "'.concat(this.type,'" type to "').concat(e.type,'" because this would mean losing information about the current graph.'));if("boolean"==typeof e.multi&&e.multi!==this.multi&&!0!==e.multi)throw new W("Graph.copy: cannot create an incompatible copy by downgrading a multi graph to a simple one because this would mean losing information about the current graph.");if("boolean"==typeof e.allowSelfLoops&&e.allowSelfLoops!==this.allowSelfLoops&&!0!==e.allowSelfLoops)throw new W("Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.");for(var t,n,i=this.emptyCopy(e),o=this._edges.values();!0!==(t=o.next()).done;)xe(i,"copy",!1,(n=t.value).undirected,n.key,n.source.key,n.target.key,a({},n.attributes));return i},o.toJSON=function(){return this.export()},o.toString=function(){return"[object Graph]"},o.inspect=function(){var t=this,n={};this._nodes.forEach(function(e,t){n[t]=e.attributes});var i={},o={};this._edges.forEach(function(e,n){var r,s=e.undirected?"--":"->",a="",l=e.source.key,c=e.target.key;e.undirected&&l>c&&(r=l,l=c,c=r);var u="(".concat(l,")").concat(s,"(").concat(c,")");n.startsWith("geid_")?t.multi&&(void 0===o[u]?o[u]=0:o[u]++,a+="".concat(o[u],". ")):a+="[".concat(n,"]: "),i[a+=u]=e.attributes});var r={};for(var s in this)this.hasOwnProperty(s)&&!Ce.has(s)&&"function"!=typeof this[s]&&"symbol"!==e(s)&&(r[s]=this[s]);return r.attributes=this._attributes,r.nodes=n,r.edges=i,h(r,"constructor",this.constructor),r},i}(f.exports.EventEmitter);"undefined"!=typeof Symbol&&(Ee.prototype[Symbol.for("nodejs.util.inspect.custom")]=Ee.prototype.inspect),[{name:function(e){return"".concat(e,"Edge")},generateKey:!0},{name:function(e){return"".concat(e,"DirectedEdge")},generateKey:!0,type:"directed"},{name:function(e){return"".concat(e,"UndirectedEdge")},generateKey:!0,type:"undirected"},{name:function(e){return"".concat(e,"EdgeWithKey")}},{name:function(e){return"".concat(e,"DirectedEdgeWithKey")},type:"directed"},{name:function(e){return"".concat(e,"UndirectedEdgeWithKey")},type:"undirected"}].forEach(function(e){["add","merge","update"].forEach(function(t){var n=e.name(t),i="add"===t?xe:Me;e.generateKey?Ee.prototype[n]=function(o,r,s){return i(this,n,!0,"undirected"===(e.type||this.type),null,o,r,s,"update"===t)}:Ee.prototype[n]=function(o,r,s,a){return i(this,n,!1,"undirected"===(e.type||this.type),o,r,s,a,"update"===t)}})}),function(e){K.forEach(function(t){var n=t.name,i=t.attacher;i(e,n("Node"),0),i(e,n("Source"),1),i(e,n("Target"),2),i(e,n("Opposite"),3)})}(Ee),function(e){Z.forEach(function(t){var n=t.name,i=t.attacher;i(e,n("Edge"),"mixed"),i(e,n("DirectedEdge"),"directed"),i(e,n("UndirectedEdge"),"undirected")})}(Ee),function(e){ee.forEach(function(t){!function(e,t){var n=t.name,i=t.type,o=t.direction;e.prototype[n]=function(e,t){if("mixed"!==i&&"mixed"!==this.type&&i!==this.type)return[];if(!arguments.length)return function(e,t){if(0===e.size)return[];if("mixed"===t||t===e.type)return"function"==typeof Array.from?Array.from(e._edges.keys()):F(e._edges.keys(),e._edges.size);for(var n,i,o="undirected"===t?e.undirectedSize:e.directedSize,r=new Array(o),s="undirected"===t,a=e._edges.values(),l=0;!0!==(n=a.next()).done;)(i=n.value).undirected===s&&(r[l++]=i.key);return r}(this,i);if(1===arguments.length){e=""+e;var r=this._nodes.get(e);if(void 0===r)throw new V("Graph.".concat(n,': could not find the "').concat(e,'" node in the graph.'));return function(e,t,n,i){var o=[];return le(!1,e,t,n,i,function(e){o.push(e)}),o}(this.multi,"mixed"===i?this.type:i,o,r)}if(2===arguments.length){e=""+e,t=""+t;var s=this._nodes.get(e);if(!s)throw new V("Graph.".concat(n,': could not find the "').concat(e,'" source node in the graph.'));if(!this._nodes.has(t))throw new V("Graph.".concat(n,': could not find the "').concat(t,'" target node in the graph.'));return function(e,t,n,i,o){var r=[];return ce(!1,e,t,n,i,o,function(e){r.push(e)}),r}(i,this.multi,o,s,t)}throw new D("Graph.".concat(n,": too many arguments (expecting 0, 1 or 2 and got ").concat(arguments.length,")."))}}(e,t),function(e,t){var n=t.name,i=t.type,o=t.direction,r="forEach"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[r]=function(e,t,n){if("mixed"===i||"mixed"===this.type||i===this.type){if(1===arguments.length)return ae(!1,this,i,n=e);if(2===arguments.length){e=""+e,n=t;var s=this._nodes.get(e);if(void 0===s)throw new V("Graph.".concat(r,': could not find the "').concat(e,'" node in the graph.'));return le(!1,this.multi,"mixed"===i?this.type:i,o,s,n)}if(3===arguments.length){e=""+e,t=""+t;var a=this._nodes.get(e);if(!a)throw new V("Graph.".concat(r,': could not find the "').concat(e,'" source node in the graph.'));if(!this._nodes.has(t))throw new V("Graph.".concat(r,': could not find the "').concat(t,'" target node in the graph.'));return ce(!1,i,this.multi,o,a,t,n)}throw new D("Graph.".concat(r,": too many arguments (expecting 1, 2 or 3 and got ").concat(arguments.length,")."))}};var s="map"+n[0].toUpperCase()+n.slice(1);e.prototype[s]=function(){var e,t=Array.prototype.slice.call(arguments),n=t.pop();if(0===t.length){var o=0;"directed"!==i&&(o+=this.undirectedSize),"undirected"!==i&&(o+=this.directedSize),e=new Array(o);var s=0;t.push(function(t,i,o,r,a,l,c){e[s++]=n(t,i,o,r,a,l,c)})}else e=[],t.push(function(t,i,o,r,s,a,l){e.push(n(t,i,o,r,s,a,l))});return this[r].apply(this,t),e};var a="filter"+n[0].toUpperCase()+n.slice(1);e.prototype[a]=function(){var e=Array.prototype.slice.call(arguments),t=e.pop(),n=[];return e.push(function(e,i,o,r,s,a,l){t(e,i,o,r,s,a,l)&&n.push(e)}),this[r].apply(this,e),n};var l="reduce"+n[0].toUpperCase()+n.slice(1);e.prototype[l]=function(){var e,t,n=Array.prototype.slice.call(arguments);if(n.length<2||n.length>4)throw new D("Graph.".concat(l,": invalid number of arguments (expecting 2, 3 or 4 and got ").concat(n.length,")."));if("function"==typeof n[n.length-1]&&"function"!=typeof n[n.length-2])throw new D("Graph.".concat(l,": missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array."));2===n.length?(e=n[0],t=n[1],n=[]):3===n.length?(e=n[1],t=n[2],n=[n[0]]):4===n.length&&(e=n[2],t=n[3],n=[n[0],n[1]]);var i=t;return n.push(function(t,n,o,r,s,a,l){i=e(i,t,n,o,r,s,a,l)}),this[r].apply(this,n),i}}(e,t),function(e,t){var n=t.name,i=t.type,o=t.direction,r="find"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[r]=function(e,t,n){if("mixed"!==i&&"mixed"!==this.type&&i!==this.type)return!1;if(1===arguments.length)return ae(!0,this,i,n=e);if(2===arguments.length){e=""+e,n=t;var s=this._nodes.get(e);if(void 0===s)throw new V("Graph.".concat(r,': could not find the "').concat(e,'" node in the graph.'));return le(!0,this.multi,"mixed"===i?this.type:i,o,s,n)}if(3===arguments.length){e=""+e,t=""+t;var a=this._nodes.get(e);if(!a)throw new V("Graph.".concat(r,': could not find the "').concat(e,'" source node in the graph.'));if(!this._nodes.has(t))throw new V("Graph.".concat(r,': could not find the "').concat(t,'" target node in the graph.'));return ce(!0,i,this.multi,o,a,t,n)}throw new D("Graph.".concat(r,": too many arguments (expecting 1, 2 or 3 and got ").concat(arguments.length,")."))};var s="some"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[s]=function(){var e=Array.prototype.slice.call(arguments),t=e.pop();return e.push(function(e,n,i,o,r,s,a){return t(e,n,i,o,r,s,a)}),!!this[r].apply(this,e)};var a="every"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[a]=function(){var e=Array.prototype.slice.call(arguments),t=e.pop();return e.push(function(e,n,i,o,r,s,a){return!t(e,n,i,o,r,s,a)}),!this[r].apply(this,e)}}(e,t),function(e,t){var n=t.name,i=t.type,o=t.direction,r=n.slice(0,-1)+"Entries";e.prototype[r]=function(e,t){if("mixed"!==i&&"mixed"!==this.type&&i!==this.type)return N.empty();if(!arguments.length)return function(e,t){if(0===e.size)return N.empty();var n="mixed"!==t&&t!==e.type,i="undirected"===t,o=e._edges.values();return new N(function(){for(var e,t;;){if((e=o.next()).done)return e;if(t=e.value,!n||t.undirected===i)break}return{value:{edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected},done:!1}})}(this,i);if(1===arguments.length){e=""+e;var n=this._nodes.get(e);if(!n)throw new V("Graph.".concat(r,': could not find the "').concat(e,'" node in the graph.'));return function(e,t,n){var i=N.empty();return"undirected"!==e&&("out"!==t&&void 0!==n.in&&(i=Q(i,ie(n.in))),"in"!==t&&void 0!==n.out&&(i=Q(i,ie(n.out,t?void 0:n.key)))),"directed"!==e&&void 0!==n.undirected&&(i=Q(i,ie(n.undirected))),i}(i,o,n)}if(2===arguments.length){e=""+e,t=""+t;var s=this._nodes.get(e);if(!s)throw new V("Graph.".concat(r,': could not find the "').concat(e,'" source node in the graph.'));if(!this._nodes.has(t))throw new V("Graph.".concat(r,': could not find the "').concat(t,'" target node in the graph.'));return function(e,t,n,i){var o=N.empty();return"undirected"!==e&&(void 0!==n.in&&"out"!==t&&i in n.in&&(o=Q(o,se(n.in,i))),void 0!==n.out&&"in"!==t&&i in n.out&&(t||n.key!==i)&&(o=Q(o,se(n.out,i)))),"directed"!==e&&void 0!==n.undirected&&i in n.undirected&&(o=Q(o,se(n.undirected,i))),o}(i,o,s,t)}throw new D("Graph.".concat(r,": too many arguments (expecting 0, 1 or 2 and got ").concat(arguments.length,")."))}}(e,t)})}(Ee),function(e){ue.forEach(function(t){(function(e,t){var n=t.name,i=t.type,o=t.direction;e.prototype[n]=function(e){if("mixed"!==i&&"mixed"!==this.type&&i!==this.type)return[];e=""+e;var t=this._nodes.get(e);if(void 0===t)throw new V("Graph.".concat(n,': could not find the "').concat(e,'" node in the graph.'));return function(e,t,n){if("mixed"!==e){if("undirected"===e)return Object.keys(n.undirected);if("string"==typeof t)return Object.keys(n[t])}var i=[];return pe(!1,e,t,n,function(e){i.push(e)}),i}("mixed"===i?this.type:i,o,t)}})(e,t),function(e,t){var n=t.name,i=t.type,o=t.direction,r="forEach"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[r]=function(e,t){if("mixed"===i||"mixed"===this.type||i===this.type){e=""+e;var n=this._nodes.get(e);if(void 0===n)throw new V("Graph.".concat(r,': could not find the "').concat(e,'" node in the graph.'));pe(!1,"mixed"===i?this.type:i,o,n,t)}};var s="map"+n[0].toUpperCase()+n.slice(1);e.prototype[s]=function(e,t){var n=[];return this[r](e,function(e,i){n.push(t(e,i))}),n};var a="filter"+n[0].toUpperCase()+n.slice(1);e.prototype[a]=function(e,t){var n=[];return this[r](e,function(e,i){t(e,i)&&n.push(e)}),n};var l="reduce"+n[0].toUpperCase()+n.slice(1);e.prototype[l]=function(e,t,n){if(arguments.length<3)throw new D("Graph.".concat(l,": missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array."));var i=n;return this[r](e,function(e,n){i=t(i,e,n)}),i}}(e,t),function(e,t){var n=t.name,i=t.type,o=t.direction,r=n[0].toUpperCase()+n.slice(1,-1),s="find"+r;e.prototype[s]=function(e,t){if("mixed"===i||"mixed"===this.type||i===this.type){e=""+e;var n=this._nodes.get(e);if(void 0===n)throw new V("Graph.".concat(s,': could not find the "').concat(e,'" node in the graph.'));return pe(!0,"mixed"===i?this.type:i,o,n,t)}};var a="some"+r;e.prototype[a]=function(e,t){return!!this[s](e,t)};var l="every"+r;e.prototype[l]=function(e,t){return!this[s](e,function(e,n){return!t(e,n)})}}(e,t),function(e,t){var n=t.name,i=t.type,o=t.direction,r=n.slice(0,-1)+"Entries";e.prototype[r]=function(e){if("mixed"!==i&&"mixed"!==this.type&&i!==this.type)return N.empty();e=""+e;var t=this._nodes.get(e);if(void 0===t)throw new V("Graph.".concat(r,': could not find the "').concat(e,'" node in the graph.'));return function(e,t,n){if("mixed"!==e){if("undirected"===e)return me(null,n,n.undirected);if("string"==typeof t)return me(null,n,n[t])}var i=N.empty(),o=new he;return"undirected"!==e&&("out"!==t&&(i=Q(i,me(o,n,n.in))),"in"!==t&&(i=Q(i,me(o,n,n.out)))),"directed"!==e&&(i=Q(i,me(o,n,n.undirected))),i}("mixed"===i?this.type:i,o,t)}}(e,t)})}(Ee);var _e=function(e){function n(t){var n=a({type:"directed"},t);if("multi"in n&&!1!==n.multi)throw new D("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if("directed"!==n.type)throw new D('DirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return e.call(this,n)||this}return t(n,e),n}(Ee),Ie=function(e){function n(t){var n=a({type:"undirected"},t);if("multi"in n&&!1!==n.multi)throw new D("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if("undirected"!==n.type)throw new D('UndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return e.call(this,n)||this}return t(n,e),n}(Ee),Le=function(e){function n(t){var n=a({multi:!0},t);if("multi"in n&&!0!==n.multi)throw new D("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");return e.call(this,n)||this}return t(n,e),n}(Ee),Ne=function(e){function n(t){var n=a({type:"directed",multi:!0},t);if("multi"in n&&!0!==n.multi)throw new D("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if("directed"!==n.type)throw new D('MultiDirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return e.call(this,n)||this}return t(n,e),n}(Ee),Pe=function(e){function n(t){var n=a({type:"undirected",multi:!0},t);if("multi"in n&&!0!==n.multi)throw new D("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if("undirected"!==n.type)throw new D('MultiUndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return e.call(this,n)||this}return t(n,e),n}(Ee);function Re(e){e.from=function(t,n){var i=a({},t.options,n),o=new e(i);return o.import(t),o}}return Re(Ee),Re(_e),Re(Ie),Re(Le),Re(Ne),Re(Pe),Ee.Graph=Ee,Ee.DirectedGraph=_e,Ee.UndirectedGraph=Ie,Ee.MultiGraph=Le,Ee.MultiDirectedGraph=Ne,Ee.MultiUndirectedGraph=Pe,Ee.InvalidArgumentsGraphError=D,Ee.NotFoundGraphError=V,Ee.UsageGraphError=W,Ee}()},944:(e,t)=>{"use strict";t.Vb=void 0,t.Vb=function(e,t,n){var i=function(e,t,n){if(0===e.length||0===t.length)return 0;if(n&&!n.caseSensitive&&(e=e.toUpperCase(),t=t.toUpperCase()),e===t)return 1;for(var i=0,o=e.length,r=t.length,s=Math.floor(Math.max(o,r)/2)-1,a=new Array(o),l=new Array(r),c=0;c<o;c++)for(var u=Math.max(0,c-s);u<=Math.min(r,c+s+1);u++)if(!a[c]&&!l[u]&&e[c]===t[u]){++i,a[c]=l[u]=!0;break}if(0===i)return 0;var h=0,d=0;for(c=0;c<o;c++)if(a[c]){for(;!l[d];)d++;e.charAt(c)!==t.charAt(d++)&&h++}return(i/o+i/r+(i-(h/=2))/i)/3}(e,t,n),o=0;if(i>.7){for(var r=Math.min(e.length,t.length),s=0;e[s]===t[s]&&s<4&&s<r;)++o,s++;i+=.1*o*(1-i)}return i}},966:(e,t,n)=>{"use strict";n.d(t,{V:()=>s,l:()=>a});var i=n(4328),o=n(6082),r=n(2447);function s(e,t,n=[],o=[],s=!0){const l=r._package.seqHelper,[c,u]=a(e,t,l,n,o);return s&&!c&&i.shell.warning(u),c}function a(e,t,n,r=[],s=[]){let a=!0,l="";if(e.semType!==o.SEMTYPE.MACROMOLECULE)i.shell.warning(t+" analysis is allowed for Macromolecules semantic type"),a=!1;else{const i=n.getSeqHandler(e),o=i.notation;if(r.length>0&&!r.some(e=>o.toUpperCase()==e.toUpperCase()))l=`${t} + ' analysis is allowed for Macromolecules with notation ${0==r.length?"any notation":`notation${r.length>1?"s":""} ${r.map(e=>`"${e}"`).join(", ")} `}.`,a=!1;else if(!i.isHelm()){const e=i.alphabet;s.length>0&&!s.some(t=>e.toUpperCase()==t.toUpperCase())&&(l=`${t} + ' analysis is allowed for Macromolecules with alphabet ${0==s.length?"any alphabet":`alphabet${s.length>1?"s":""} ${s.map(e=>`"${e}"`).join(", ")}.`}.`,a=!1)}}return[a,l]}},1093:(e,t,n)=>{"use strict";n(7362);class i{}i.SemType="Nucleotides",i.SemTypeMultipleAlignment="NucleotidesMultipleAlignment",i.Names={A:"Adenine",C:"Cytosine",G:"Guanine",T:"Thymine",U:"Uracil"}},1113:e=>{"use strict";e.exports=function(e,t){if(t.styleSheet)t.styleSheet.cssText=e;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(e))}}},1163:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:{message({keyword:e,schemaCode:t}){const n="maxItems"===e?"more":"fewer";return i.str`must NOT have ${n} than ${t} items`},params:({schemaCode:e})=>i._`{limit: ${e}}`},code(e){const{keyword:t,data:n,schemaCode:o}=e,r="maxItems"===t?i.operators.GT:i.operators.LT;e.fail$data(i._`${n}.length ${r} ${o}`)}};t.default=o},1239:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o=n(4227),r={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:{message:({params:e})=>i.str`must match "${e.ifClause}" schema`,params:({params:e})=>i._`{failingKeyword: ${e.ifClause}}`},code(e){const{gen:t,parentSchema:n,it:r}=e;void 0===n.then&&void 0===n.else&&(0,o.checkStrictMode)(r,'"if" without "then" and "else" is ignored');const a=s(r,"then"),l=s(r,"else");if(!a&&!l)return;const c=t.let("valid",!0),u=t.name("_valid");if(function(){const t=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},u);e.mergeEvaluated(t)}(),e.reset(),a&&l){const n=t.let("ifClause");e.setParams({ifClause:n}),t.if(u,h("then",n),h("else",n))}else a?t.if(u,h("then")):t.if((0,i.not)(u),h("else"));function h(n,o){return()=>{const r=e.subschema({keyword:n},u);t.assign(c,u),e.mergeValidEvaluated(r,c),o?t.assign(o,i._`${n}`):e.setParams({ifClause:n})}}e.pass(c,()=>e.error(!0))}};function s(e,t){const n=e.schema[t];return void 0!==n&&!(0,o.alwaysValidSchema)(e,n)}t.default=r},1354:e=>{"use strict";e.exports=function(e){var t=e[1],n=e[3];if(!n)return t;if("function"==typeof btoa){var i=btoa(unescape(encodeURIComponent(JSON.stringify(n)))),o="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(i),r="/*# ".concat(o," */");return[t].concat([r]).join("\n")}return[t].join("\n")}},1520:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.regexpCode=t.getEsmExportName=t.getProperty=t.safeStringify=t.stringify=t.strConcat=t.addCodeArg=t.str=t._=t.nil=t._Code=t.Name=t.IDENTIFIER=t._CodeOrName=void 0;class n{}t._CodeOrName=n,t.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class i extends n{constructor(e){if(super(),!t.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}t.Name=i;class o extends n{constructor(e){super(),this._items="string"==typeof e?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const e=this._items[0];return""===e||'""'===e}get str(){var e;return null!==(e=this._str)&&void 0!==e?e:this._str=this._items.reduce((e,t)=>`${e}${t}`,"")}get names(){var e;return null!==(e=this._names)&&void 0!==e?e:this._names=this._items.reduce((e,t)=>(t instanceof i&&(e[t.str]=(e[t.str]||0)+1),e),{})}}function r(e,...t){const n=[e[0]];let i=0;for(;i<t.length;)l(n,t[i]),n.push(e[++i]);return new o(n)}t._Code=o,t.nil=new o(""),t._=r;const s=new o("+");function a(e,...t){const n=[u(e[0])];let i=0;for(;i<t.length;)n.push(s),l(n,t[i]),n.push(s,u(e[++i]));return function(e){let t=1;for(;t<e.length-1;){if(e[t]===s){const n=c(e[t-1],e[t+1]);if(void 0!==n){e.splice(t-1,3,n);continue}e[t++]="+"}t++}}(n),new o(n)}function l(e,t){var n;t instanceof o?e.push(...t._items):t instanceof i?e.push(t):e.push("number"==typeof(n=t)||"boolean"==typeof n||null===n?n:u(Array.isArray(n)?n.join(","):n))}function c(e,t){if('""'===t)return e;if('""'===e)return t;if("string"==typeof e){if(t instanceof i||'"'!==e[e.length-1])return;return"string"!=typeof t?`${e.slice(0,-1)}${t}"`:'"'===t[0]?e.slice(0,-1)+t.slice(1):void 0}return"string"!=typeof t||'"'!==t[0]||e instanceof i?void 0:`"${e}${t.slice(1)}`}function u(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}t.str=a,t.addCodeArg=l,t.strConcat=function(e,t){return t.emptyStr()?e:e.emptyStr()?t:a`${e}${t}`},t.stringify=function(e){return new o(u(e))},t.safeStringify=u,t.getProperty=function(e){return"string"==typeof e&&t.IDENTIFIER.test(e)?new o(`.${e}`):r`[${e}]`},t.getEsmExportName=function(e){if("string"==typeof e&&t.IDENTIFIER.test(e))return new o(`${e}`);throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)},t.regexpCode=function(e){return new o(e.toString())}},1619:(e,t,n)=>{"use strict";n.d(t,{D:()=>E});var i=n(4328),o=n(6082),r=n(7389),s=n(8070),a=n(2003),l=n(608),c=n(8152),u=n(966),h=n(4139),d=n(5072),p=n.n(d),m=n(7825),f=n.n(m),g=n(7659),y=n.n(g),b=n(5056),v=n.n(b),w=n(540),C=n.n(w),S=n(1113),A=n.n(S),x=n(6369),M={};M.styleTagTransform=A(),M.setAttributes=v(),M.insert=y().bind(null,"head"),M.domAPI=f(),M.insertStyleElement=C(),p()(x.A,M),x.A&&x.A.locals&&x.A.locals;var T=n(2447);async function E(e,t){return new Promise(async(n,a)=>{e.clustersCol??=null,e.pepsea??={},e.pepsea.method??=h.HX.pepsea.method,e.pepsea.gapOpen??=h.HX.pepsea.gapOpen,e.pepsea.gapExtend??=h.HX.pepsea.gapExtend;const u=e.col?.dataFrame??i.shell.t;if(!u){const e="Multiple Sequence Alignment analysis requires a dataset with a macromolecule column.";return void a(new l.Ap(r.divText(e)))}const d=e.col??u.columns.bySemType(o.SEMTYPE.MACROMOLECULE);if(null==d){const e="Multiple Sequence Alignment analysis requires a dataset with a macromolecule column.";return void a(new l.Ap(r.divText(e)))}const p=r.input.choice("Method",{value:e.pepsea.method,items:c.ZY});p.setTooltip("Alignment method");const m=r.input.float("Terminal gap",{value:e?.kalign?.terminalGap});m.setTooltip("Penalty for opening a gap at the beginning or end of the sequence");const f=r.p(`Kalign version: ${h.b9}`,"kalign-version"),g=r.input.float("Gap open",{value:e.pepsea.gapOpen});g.setTooltip("Gap opening penalty at group-to-group alignment");const y=r.input.float("Gap extend",{value:e.pepsea.gapExtend});y.setTooltip("Gap extension penalty to skip the alignment");const b=r.input.bool("Selected Rows Only",{value:!1}),v=r.inputs([g,y,m]),w=r.button("Alignment parameters",()=>{v.hidden=!v.hidden,[g,y,m].forEach(e=>{e.root.style.removeProperty("max-width"),e.captionLabel.style.removeProperty("max-width")})},"Adjust alignment parameters such as penalties for opening and extending gaps");w.classList.add("msa-params-button"),v.hidden=!0,w.prepend(r.icons.settings(()=>null));const C=[p.root.style],S=[m.root.style,f.style];let A,x=d;const M=r.input.column("Sequence",{table:u,value:d,onValueChanged:async e=>{if(!e||e.semType!==o.SEMTYPE.MACROMOLECULE)return L.disabled=!0,await(0,s.cb)(0),void(M.value=x);x=e,L.disabled=!1,A=await I(M.value,u,t,C,S,p,T,g,y,m,b)},filter:e=>e.semType===o.SEMTYPE.MACROMOLECULE});M.setTooltip("Sequences column to use for alignment");const T=r.input.column("Clusters",{table:u,value:e.clustersCol});T.nullable=!0;const E=r.dialog("MSA").add(M).add(T).add(p).add(v).add(w).add(b).add(f).onOK(async()=>{await _(M,u,A,n,a)}),L=E.getButton("OK");if(M.fireChanged(),e.col)return A=await I(e.col,u,t,C,S,p,T,g,y,m,b),void await _(M,u,A,n,a);E.show()})}async function _(e,t,n,r,s){let a=null;const l=o.TaskBarProgressIndicator.create("Analyze for MSA ...");try{if(e.fireChanged(),e.value.semType!==o.SEMTYPE.MACROMOLECULE)throw new Error("Chosen column has to be of Macromolecule semantic type");if(null==n)throw new Error("Invalid column format");if(a=await n(),null==a)return s("PepSeA container has not started");t.columns.add(a),await i.data.detectSemanticTypes(t),r(a)}catch(e){s(e)}finally{l.close()}}async function I(e,t,n,r,s,d,p,m,f,g,y){try{if(e.semType!==o.SEMTYPE.MACROMOLECULE)return;const i=t.columns.getUnusedName(`msa(${e.name})`);if((0,u.l)(e,e.name,n,[a.Hi.FASTA,a.Hi.SEPARATOR],[a.YI.DNA,a.YI.RNA,a.YI.PT])[0]){L(r,s,"kalign"),m.value=null,f.value=null,g.value=null;const o=n.getSeqHandler(e),c=o.isFasta()?e:o.convert(a.Hi.FASTA);return async()=>await(0,l.eE)(t,c,!1,i,p.value,void 0,void 0,void 0,y.value)}if((0,u.l)(e,e.name,n,[a.Hi.HELM],[])[0])return L(r,s,"pepsea"),m.value??=h.HX.pepsea.gapOpen,f.value??=h.HX.pepsea.gapExtend,async()=>(0,c.GD)(t,e,i,d.value,m.value,f.value,p.value,void 0,y.value);if((0,u.l)(e,e.name,n,[a.Hi.SEPARATOR],[a.YI.UN])[0]){const o=n.getSeqHandler(e).convert(a.Hi.HELM);return L(r,s,"pepsea"),m.value??=h.HX.pepsea.gapOpen,f.value??=h.HX.pepsea.gapExtend,async()=>(0,c.GD)(t,o,i,d.value,m.value,f.value,p.value,void 0,y.value)}return m.value=null,f.value=null,g.value=null,void L(r,s,"kalign")}catch(e){const t=e instanceof Error?e.message:e.toString();i.shell.error(t),T._package.logger.error(t)}}function L(e,t,n){if("kalign"===n){for(const t of e)t.display="none";for(const e of t)e.removeProperty("display")}else{for(const e of t)e.display="none";for(const t of e)t.removeProperty("display")}}},1678:e=>{"use strict";e.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/schema","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/core":true,"https://json-schema.org/draft/2020-12/vocab/applicator":true,"https://json-schema.org/draft/2020-12/vocab/unevaluated":true,"https://json-schema.org/draft/2020-12/vocab/validation":true,"https://json-schema.org/draft/2020-12/vocab/meta-data":true,"https://json-schema.org/draft/2020-12/vocab/format-annotation":true,"https://json-schema.org/draft/2020-12/vocab/content":true},"$dynamicAnchor":"meta","title":"Core and Validation specifications meta-schema","allOf":[{"$ref":"meta/core"},{"$ref":"meta/applicator"},{"$ref":"meta/unevaluated"},{"$ref":"meta/validation"},{"$ref":"meta/meta-data"},{"$ref":"meta/format-annotation"},{"$ref":"meta/content"}],"type":["object","boolean"],"$comment":"This meta-schema also defines keywords that have appeared in previous drafts in order to prevent incompatible extensions as they remain in common use.","properties":{"definitions":{"$comment":"\\"definitions\\" has been replaced by \\"$defs\\".","type":"object","additionalProperties":{"$dynamicRef":"#meta"},"deprecated":true,"default":{}},"dependencies":{"$comment":"\\"dependencies\\" has been split and replaced by \\"dependentSchemas\\" and \\"dependentRequired\\" in order to serve their differing semantics.","type":"object","additionalProperties":{"anyOf":[{"$dynamicRef":"#meta"},{"$ref":"meta/validation#/$defs/stringArray"}]},"deprecated":true,"default":{}},"$recursiveAnchor":{"$comment":"\\"$recursiveAnchor\\" has been replaced by \\"$dynamicAnchor\\".","$ref":"meta/core#/$defs/anchorString","deprecated":true},"$recursiveRef":{"$comment":"\\"$recursiveRef\\" has been replaced by \\"$dynamicRef\\".","$ref":"meta/core#/$defs/uriReferenceString","deprecated":true}}}')},1687:(e,t,n)=>{"use strict";n.d(t,{_i:()=>x});var i=n(7389),o=n(6082),r=n(4328),s=n(1991),a=n.n(s),l=n(1858),c=n(2003),u=n(8070),h=n(7602),d=n(4954),p=n(4574),m=n(1757),f=n.n(m),g=n(9124),y=n(9192),b=n(4870),v=n(2447);class w extends p.O{seqHelper;emptyProps=new p.n("",void 0,v._package.logger);helmEditor;_filterPanel=i.div("",{style:{cursor:"pointer"}});logger;static viewerCounter=-1;viewerId=++w.viewerCounter;viewerToLog(){return`HelmBioFilter<${this.viewerId}>`}get type(){return"HelmBioFilter"}constructor(e){super(),this.seqHelper=e,this.logger=v._package.logger}viewSubs=[];async detach(){await super.detach();for(const e of this.viewSubs)e.unsubscribe()}async attach(){this.viewerToLog();try{const e=await(0,g.b2)();let t,n;this.helmEditor=e.createHelmWebEditor(),this.logger.warning("TEST: HelmBioFilter.init().sync() waitForElementInDom waiting..."),await i.tools.waitForElementInDom(this._filterPanel),this.logger.warning("TEST: HelmBioFilter.init().sync() waitForElementInDom ready"),this.updateFilterPanel(),this.viewSubs.push((0,l.fromEvent)(this._filterPanel,"click").subscribe(()=>{t=i.div(),n=e.createWebEditorApp(t,this.props.substructure),i.dialog({showHeader:!1,showFooter:!0}).add(t).onOK(()=>{try{const e=n.canvas.getHelm(!0).replace(/<\/span>/g,"").replace(/<span style='background:#bbf;'>/g,"");this.props=new p.n(e,void 0,v._package.logger)}catch(e){this.logger.error(e)}finally{f()(t).empty(),t=null,n=null}}).onCancel(()=>{f()(t).empty(),t=null,n=null}).show({modal:!0,fullScreen:!0})})),this.viewSubs.push(i.onSizeChanged(this._filterPanel).subscribe(e=>{try{if(n){const e=n.canvas.getHelm(!0).replace(/<\/span>/g,"").replace(/<span style='background:#bbf;'>/g,"");this.updateFilterPanel(e)}}catch(e){const[t,n]=(0,y.AP)(e);this.logger.error(t,void 0,n)}}))}catch(e){const[t,n]=(0,y.AP)(e),o=this._filterPanel;o.innerText="error",o.classList.add("d4-error"),i.tooltip.bind(o,t)}}applyProps(){this.helmEditor&&this.updateFilterPanel(this.props.substructure)}get filterPanel(){return this._filterPanel}updateFilterPanel(e){if(!this.helmEditor)throw new Error("helmEditor is not created, the filter is not in dom yet");const t=this._filterPanel.parentElement.clientWidth<100?100:this._filterPanel.parentElement.clientWidth,n=t/2;if(e)(0,b.Ku)(this._filterPanel,this.helmEditor.host),this.helmEditor.editor.setHelm(e),this.helmEditor.resizeEditor(t,n);else{const e=i.divText("Click to edit","helm-substructure-filter");(0,b.Ku)(this._filterPanel,e)}}async substructureSearch(e){const t=`${this.viewerToLog()}.substructureSearch( column = <${e.name}> )`;v._package.logger.debug(`${t}, start`);try{return await(0,u.cb)(10),await(0,d.if)(this.props.substructure,e,this.seqHelper)}finally{v._package.logger.debug(`${t}, end`)}}}const C="bio-substructure-filter";class S{props;filterId;dataFrameId;columnName;bitset;constructor(e,t,n,i,o){this.props=e,this.filterId=t,this.dataFrameId=n,this.columnName=i,this.bitset=o}}class A extends p.n{separator;constructor(e,t,n){super(e,!1,n),this.separator=t,this.readOnly=!0}}class x extends o.Filter{seqHelper;logger;bioFilter=null;bitset=null;loader;notation=void 0;filterSyncer;get calculating(){return"initial"==this.loader.style.display}set calculating(e){this.loader.style.display=e?"initial":"none"}get filterSummary(){return this.bioFilter.filterSummary}get isFiltering(){return super.isFiltering&&(this.bioFilter?.isFiltering??!1)}get isReadyToApplyFilter(){return!this.calculating&&null!=this.bitset}get debounceTime(){if(null==this.column)return 1e3;const e=this.column.length;return e<500?0:e>1e4?1e3:Math.floor((e-500)/9500*1e3)}constructor(e,t){super(),this.seqHelper=e,this.logger=t,this.root=i.divV([]),this.loader=i.loader(),this.calculating=!1,this.filterSyncer=new h.g(this.logger)}static filterCounter=-1;filterId=++x.filterCounter;filterToLog(){return`BioSubstructureFilter<${this.filterId}>`}viewSubs=[];attach(e){const t=super.attach.bind(this),n=`${this.filterToLog()}.attach()`;this.filterSyncer.sync(n,async()=>{t(e),this.column||(this.columnName?this.column=this.dataFrame.getCol(this.columnName):this.column=e.columns.bySemType(o.SEMTYPE.MACROMOLECULE)),this.seqHelper.getSeqHandler(this.column),this.columnName??=this.column?.name,this.notation??=this.column?.meta.units,this.bioFilter=this.notation===c.Hi.FASTA?new M:this.notation===c.Hi.SEPARATOR?new T(this.column.getTag(c.gp.separator)):new w(this.seqHelper),this.root.appendChild(this.bioFilter.filterPanel),this.root.appendChild(this.loader),await this.bioFilter.attach(),this.viewSubs.push(o.debounce(this.bioFilter.onChanged,this.debounceTime).subscribe(this.bioFilterOnChangedDebounced.bind(this))),this.viewSubs.push(r.events.onResetFilterRequest.subscribe(this.grokEventsOnResetFilterRequest.bind(this))),this.viewSubs.push(r.events.onCustomEvent(C).subscribe(this.filterOnSync.bind(this)))})}detach(){const e=super.detach.bind(this),t=`${this.filterToLog()}.detach()`;this.filterSyncer.sync(t,async()=>{for(const e of this.viewSubs)e.unsubscribe();this.viewSubs=[],e(),this.bioFilter&&this.bioFilter.detach(),this.bioFilter=null})}filterOnSync(e){e.filterId!==this.filterId&&e.dataFrameId===this.dataFrame.id&&e.columnName===this.columnName&&(this.bioFilter.props=e.props)}applyFilter(){const e=`${this.filterToLog()}.applyFilter()`;this.logger.debug(`${e}, IN`),this.bitset&&!this.isDetached&&this.dataFrame?.filter.and(this.bitset)}saveState(){const e=`${this.filterToLog()}.saveState()`,t=super.saveState();return this.logger.debug(`${e}, super.state = ${JSON.stringify(t)}`),t.props=this.bioFilter.saveProps(),t}applyState(e){const t=`${this.filterToLog()}.applyState()`;super.applyState(e),this.filterSyncer.sync(t,async()=>{e.props&&this.bioFilter&&(this.bioFilter.props=o.toJs(e.props??{}))})}fireFilterSync(){const e=`${this.filterToLog()}.fireFilterSync()`;this.logger.debug(`${e}, bioFilter = ${this.bioFilter?this.bioFilter.constructor.name:"null"}`+(this.bioFilter?`, props = ${JSON.stringify(this.bioFilter.saveProps())}`:"")),r.events.fireCustomEvent(C,new S(this.bioFilter.props,this.filterId,this.dataFrame.id,this.columnName,this.bitset))}bioFilterOnChangedDebounced(){if(!this.dataFrame)return;const e=`${this.filterToLog()}.bioFilterOnChangedDebounced()`;if(this.logger.debug(`${e}, start, isFiltering = ${this.isFiltering}, props = ${JSON.stringify(this.bioFilter.saveProps())}`),!this.isFiltering)return this.bitset=null,void this.dataFrame.rows.requestFilter();a()(this.dataFrame.rows.filters).has(`${this.columnName}: ${this.filterSummary}`)||this.filterSyncer.sync(e,async()=>{this.calculating=!0;try{this.logger.debug(`${e}, before substructureSearch`),this.bitset=await(this.bioFilter?.substructureSearch(this.column)),this.logger.debug(`${e}, after substructureSearch`),this.calculating=!1,this.fireFilterSync(),this.dataFrame?.rows.requestFilter()}finally{this.calculating=!1,this.logger.debug(`${e}, end`)}})}grokEventsOnResetFilterRequest(){const e=`${this.filterToLog()}.grokEventsOnResetFilterRequest()`;this.logger.debug(`${e}`),this.bioFilter?.resetFilter()}_onRendered=new l.Subject;get onRendered(){return this._onRendered}invalidate(e){const t=`${this.filterToLog()}.invalidate(${e?` <- ${e} `:""})`;this.filterSyncer.sync(t,async()=>{this._onRendered.next()})}async awaitRendered(e=1e4){const t=`awaitRendered( ${e} )`,n=`${this.filterToLog()}.${t}`;await(0,u.cb)(10),await(0,u.PE)(this.onRendered,()=>{this.logger.debug(`${n}, _onRendered event caught`)},()=>{this.invalidate(t)},e,`${n} timeout`);const i=this.filterSyncer.resetErrors();if(i.length>0)throw i[0]}}class M extends p.O{emptyProps=new p.n("",void 0,v._package.logger);substructureInput;get type(){return"FastaBioFilter"}constructor(){super(),this.substructureInput=i.input.string("",{value:"",onValueChanged:e=>{window.setTimeout(()=>{this.props=new p.n(e,void 0,v._package.logger),this._propsChanging||this.onChanged.next()},0)},placeholder:"Substructure"})}applyProps(){this.substructureInput.value!==this.props.substructure&&(this.substructureInput.value=this.props.substructure)}get filterPanel(){return this.substructureInput.root}get isFiltering(){return""!==this.substructureInput.value}async substructureSearch(e){return(0,d.nI)(this.props.substructure,e)}async attach(){}async detach(){await super.detach()}}class T extends p.O{emptyProps=new A("",void 0,v._package.logger);substructureInput;separatorInput;colSeparator="";get type(){return"SeparatorBioFilter"}constructor(e){super(),this.substructureInput=i.input.string("",{value:"",onValueChanged:e=>{this.props=new A(e,this.props.separator,v._package.logger),setTimeout(()=>{this._propsChanging||this.onChanged.next()})},placeholder:"Substructure"}),this.separatorInput=i.input.string("",{value:this.colSeparator=e,onValueChanged:e=>{const t=e||"";this.props=new A(this.props.substructure,t,v._package.logger),setTimeout(()=>{this._propsChanging||this.onChanged.next()})},placeholder:"Separator"})}applyProps(){this.substructureInput.value!==this.props.substructure&&(this.substructureInput.value=this.props.substructure);const e=this.props.separator??this.colSeparator;this.separatorInput.value!==e&&(this.separatorInput.value=e)}get filterSummary(){return this.props.separator?this.props.separator:this.colSeparator,`${this.props.substructure}, {sep}`}get isFiltering(){return""!==this.props.substructure}resetFilter(){this.props=new A("",void 0,v._package.logger)}get filterPanel(){return i.divV([this.substructureInput.root,this.separatorInput.root])}get substructure(){return this.separatorInput.value&&this.separatorInput.value!==this.colSeparator?this.substructureInput.value.replaceAll(this.separatorInput.value,this.colSeparator):this.substructureInput.value}set substructure(e){this.substructureInput.value=e}async substructureSearch(e){return(0,d.nI)(this.substructure,e,this.colSeparator)}async attach(){}async detach(){await super.detach()}}},1736:e=>{e.exports=function(e){return null!==e&&"object"==typeof e&&"function"==typeof e.addUndirectedEdgeWithKey&&"function"==typeof e.dropNode&&"boolean"==typeof e.multi}},1757:e=>{"use strict";e.exports=$},1782:(e,t)=>{t.assign=function(e){e=e||{};var t,n,i,o=Array.prototype.slice.call(arguments).slice(1);for(t=0,i=o.length;t<i;t++)if(o[t])for(n in o[t])e[n]=o[t][n];return e},t.validateSettings=function(e){return"linLogMode"in e&&"boolean"!=typeof e.linLogMode?{message:"the `linLogMode` setting should be a boolean."}:"outboundAttractionDistribution"in e&&"boolean"!=typeof e.outboundAttractionDistribution?{message:"the `outboundAttractionDistribution` setting should be a boolean."}:"adjustSizes"in e&&"boolean"!=typeof e.adjustSizes?{message:"the `adjustSizes` setting should be a boolean."}:"edgeWeightInfluence"in e&&"number"!=typeof e.edgeWeightInfluence?{message:"the `edgeWeightInfluence` setting should be a number."}:!("scalingRatio"in e)||"number"==typeof e.scalingRatio&&e.scalingRatio>=0?"strongGravityMode"in e&&"boolean"!=typeof e.strongGravityMode?{message:"the `strongGravityMode` setting should be a boolean."}:!("gravity"in e)||"number"==typeof e.gravity&&e.gravity>=0?"slowDown"in e&&!("number"==typeof e.slowDown||e.slowDown>=0)?{message:"the `slowDown` setting should be a number >= 0."}:"barnesHutOptimize"in e&&"boolean"!=typeof e.barnesHutOptimize?{message:"the `barnesHutOptimize` setting should be a boolean."}:!("barnesHutTheta"in e)||"number"==typeof e.barnesHutTheta&&e.barnesHutTheta>=0?null:{message:"the `barnesHutTheta` setting should be a number >= 0."}:{message:"the `gravity` setting should be a number >= 0."}:{message:"the `scalingRatio` setting should be a number >= 0."}},t.graphToByteArrays=function(e,t){var n,i=e.order,o=e.size,r={},s=new Float32Array(10*i),a=new Float32Array(3*o);return n=0,e.forEachNode(function(e,t){r[e]=n,s[n]=t.x,s[n+1]=t.y,s[n+2]=0,s[n+3]=0,s[n+4]=0,s[n+5]=0,s[n+6]=1,s[n+7]=1,s[n+8]=t.size||1,s[n+9]=t.fixed?1:0,n+=10}),n=0,e.forEachEdge(function(e,i,o,l,c,u,h){var d=r[o],p=r[l],m=t(e,i,o,l,c,u,h);s[d+6]+=m,s[p+6]+=m,a[n]=d,a[n+1]=p,a[n+2]=m,n+=3}),{nodes:s,edges:a}},t.assignLayoutChanges=function(e,t,n){var i=0;e.updateEachNodeAttributes(function(e,o){return o.x=t[i],o.y=t[i+1],i+=10,n?n(e,o):o})},t.readGraphPositions=function(e,t){var n=0;e.forEachNode(function(e,i){t[n]=i.x,t[n+1]=i.y,n+=10})},t.collectLayoutChanges=function(e,t,n){for(var i=e.nodes(),o={},r=0,s=0,a=t.length;r<a;r+=10){if(n){var l=Object.assign({},e.getNodeAttributes(i[s]));l.x=t[r],l.y=t[r+1],l=n(i[s],l),o[i[s]]={x:l.x,y:l.y}}else o[i[s]]={x:t[r],y:t[r+1]};s++}return o},t.createWorker=function(e){var t=window.URL||window.webkitURL,n=e.toString(),i=t.createObjectURL(new Blob(["("+n+").call(this);"],{type:"text/javascript"})),o=new Worker(i);return t.revokeObjectURL(i),o}},1846:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(3025),o={keyword:"dependentRequired",type:"object",schemaType:"object",error:i.error,code:e=>(0,i.validatePropertyDeps)(e)};t.default=o},1858:e=>{"use strict";e.exports=rxjs},1913:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(3282),o=n(9029),r=n(1520),s=n(2586),a=n(8708),l=n(2023),c="errorMessage",u=new i.Name("emUsed"),h={required:"missingProperty",dependencies:"property",dependentRequired:"property"},d=/\$\{[^}]+\}/,p=/\$\{([^}]+)\}/g,m=/^""\s*\+\s*|\s*\+\s*""$/g;const f=(e,t={})=>{if(!e.opts.allErrors)throw new Error("ajv-errors: Ajv option allErrors must be true");if(e.opts.jsPropertySyntax)throw new Error("ajv-errors: ajv option jsPropertySyntax is not supported");return e.addKeyword(function(e){return{keyword:c,schemaType:["string","object"],post:!0,code(t){const{gen:n,data:f,schema:g,schemaValue:y,it:b}=t;if(!1===b.createErrors)return;const v=g,w=o.strConcat(l.default.instancePath,b.errorPath);function C(e,t){return o.and(i._`${e}.keyword !== ${c}`,i._`!${e}.${u}`,i._`${e}.instancePath === ${w}`,i._`${e}.keyword in ${t}`,i._`${e}.schemaPath.indexOf(${b.errSchemaPath}) === 0`,i._`/^\\/[^\\/]*$/.test(${e}.schemaPath.slice(${b.errSchemaPath.length}))`)}function S(e,t){const i=[];for(const n in e){const e=t[n];d.test(e)&&i.push([n,x(e)])}return n.object(...i)}function A(e){return d.test(e)?new r._Code(r.safeStringify(e).replace(p,(e,t)=>`" + JSON.stringify(${s.getData(t,b)}) + "`).replace(m,"")):i.stringify(e)}function x(e){return i._`function(){return ${A(e)}}`}n.if(i._`${l.default.errors} > 0`,()=>{if("object"==typeof v){const[r,s]=function(e){let t,n;for(const i in e){if("properties"===i||"items"===i)continue;const o=e[i];if("object"==typeof o){t||(t={});const e=t[i]={};for(const t in o)e[t]=[]}else n||(n={}),n[i]=[]}return[t,n]}(v);s&&function(o){const r=n.const("emErrors",i.stringify(o)),s=n.const("templates",S(o,g));n.forOf("err",l.default.vErrors,e=>n.if(C(e,r),()=>n.code(i._`${r}[${e}.keyword].push(${e})`).assign(i._`${e}.${u}`,!0)));const{singleError:c}=e;if(c){const e=n.let("message",i._`""`),o=n.let("paramsErrors",i._`[]`);h(t=>{n.if(e,()=>n.code(i._`${e} += ${"string"==typeof c?c:";"}`)),n.code(i._`${e} += ${d(t)}`),n.assign(o,i._`${o}.concat(${r}[${t}])`)}),a.reportError(t,{message:e,params:i._`{errors: ${o}}`})}else h(e=>a.reportError(t,{message:d(e),params:i._`{errors: ${r}[${e}]}`}));function h(e){n.forIn("key",r,t=>n.if(i._`${r}[${t}].length`,()=>e(t)))}function d(e){return i._`${e} in ${s} ? ${s}[${e}]() : ${y}[${e}]`}}(s),r&&function(e){const o=n.const("emErrors",i.stringify(e)),r=[];for(const t in e)r.push([t,S(e[t],g[t])]);const s=n.const("templates",n.object(...r)),c=n.scopeValue("obj",{ref:h,code:i.stringify(h)}),d=n.let("emPropParams"),p=n.let("emParamsErrors");n.forOf("err",l.default.vErrors,e=>n.if(C(e,o),()=>{n.assign(d,i._`${c}[${e}.keyword]`),n.assign(p,i._`${o}[${e}.keyword][${e}.params[${d}]]`),n.if(p,()=>n.code(i._`${p}.push(${e})`).assign(i._`${e}.${u}`,!0))})),n.forIn("key",o,e=>n.forIn("keyProp",i._`${o}[${e}]`,r=>{n.assign(p,i._`${o}[${e}][${r}]`),n.if(i._`${p}.length`,()=>{const o=n.const("tmpl",i._`${s}[${e}] && ${s}[${e}][${r}]`);a.reportError(t,{message:i._`${o} ? ${o}() : ${y}[${e}][${r}]`,params:i._`{errors: ${p}}`})})}))}(r),function(e){const{props:r,items:s}=e;if(!r&&!s)return;const h=i._`typeof ${f} == "object"`,d=i._`Array.isArray(${f})`,p=n.let("emErrors");let m,b;const v=n.let("templates");function C(e,t){n.assign(p,i.stringify(e)),n.assign(v,S(e,t))}r&&s?(m=n.let("emChildKwd"),n.if(h),n.if(d,()=>{C(s,g.items),n.assign(m,i.str`items`)},()=>{C(r,g.properties),n.assign(m,i.str`properties`)}),b=i._`[${m}]`):s?(n.if(d),C(s,g.items),b=i._`.items`):r&&(n.if(o.and(h,o.not(d))),C(r,g.properties),b=i._`.properties`),n.forOf("err",l.default.vErrors,e=>function(e,t,r){n.if(o.and(i._`${e}.keyword !== ${c}`,i._`!${e}.${u}`,i._`${e}.instancePath.indexOf(${w}) === 0`),()=>{const o=n.scopeValue("pattern",{ref:/^\/([^/]*)(?:\/|$)/,code:i._`new RegExp("^\\\/([^/]*)(?:\\\/|$)")`}),s=n.const("emMatches",i._`${o}.exec(${e}.instancePath.slice(${w}.length))`),a=n.const("emChild",i._`${s} && ${s}[1].replace(/~1/g, "/").replace(/~0/g, "~")`);n.if(i._`${a} !== undefined && ${a} in ${t}`,()=>r(a))})}(e,p,t=>n.code(i._`${p}[${t}].push(${e})`).assign(i._`${e}.${u}`,!0))),n.forIn("key",p,e=>n.if(i._`${p}[${e}].length`,()=>{a.reportError(t,{message:i._`${e} in ${v} ? ${v}[${e}]() : ${y}${b}[${e}]`,params:i._`{errors: ${p}[${e}]}`}),n.assign(i._`${l.default.vErrors}[${l.default.errors}-1].instancePath`,i._`${w} + "/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`)})),n.endIf()}(function({properties:e,items:t}){const n={};if(e){n.props={};for(const t in e)n.props[t]=[]}if(t){n.items={};for(let e=0;e<t.length;e++)n.items[e]=[]}return n}(v))}const r="string"==typeof v?v:v._;r&&function(e){const r=n.const("emErrs",i._`[]`);n.forOf("err",l.default.vErrors,e=>n.if(function(e){return o.and(i._`${e}.keyword !== ${c}`,i._`!${e}.${u}`,o.or(i._`${e}.instancePath === ${w}`,o.and(i._`${e}.instancePath.indexOf(${w}) === 0`,i._`${e}.instancePath[${w}.length] === "/"`)),i._`${e}.schemaPath.indexOf(${b.errSchemaPath}) === 0`,i._`${e}.schemaPath[${b.errSchemaPath}.length] === "/"`)}(e),()=>n.code(i._`${r}.push(${e})`).assign(i._`${e}.${u}`,!0))),n.if(i._`${r}.length`,()=>a.reportError(t,{message:A(e),params:i._`{errors: ${r}}`}))}(r),e.keepErrors||function(){const e=n.const("emErrs",i._`[]`);n.forOf("err",l.default.vErrors,t=>n.if(i._`!${t}.${u}`,()=>n.code(i._`${e}.push(${t})`))),n.assign(l.default.vErrors,e).assign(l.default.errors,i._`${e}.length`)}()})},metaSchema:{anyOf:[{type:"string"},{type:"object",properties:{properties:{$ref:"#/$defs/stringMap"},items:{$ref:"#/$defs/stringList"},required:{$ref:"#/$defs/stringOrMap"},dependencies:{$ref:"#/$defs/stringOrMap"}},additionalProperties:{type:"string"}}],$defs:{stringMap:{type:"object",additionalProperties:{type:"string"}},stringOrMap:{anyOf:[{type:"string"},{$ref:"#/$defs/stringMap"}]},stringList:{type:"array",items:{type:"string"}}}}}}(t))};t.default=f,e.exports=f,e.exports.default=f},1991:e=>{"use strict";e.exports=wu},2003:(e,t,n)=>{"use strict";n.d(t,{Hi:()=>i.Hi,J9:()=>o.J9,Qf:()=>o.Qf,YI:()=>i.YI,dh:()=>o.dh,gp:()=>i.gp,mn:()=>o.mn,q7:()=>i.q7,qp:()=>o.qp,z1:()=>i.z1,zS:()=>o.zS});var i=n(439),o=n(7278)},2017:e=>{"use strict";e.exports=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){if(t.constructor!==n.constructor)return!1;var i,o,r;if(Array.isArray(t)){if((i=t.length)!=n.length)return!1;for(o=i;0!==o--;)if(!e(t[o],n[o]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if((i=(r=Object.keys(t)).length)!==Object.keys(n).length)return!1;for(o=i;0!==o--;)if(!Object.prototype.hasOwnProperty.call(n,r[o]))return!1;for(o=i;0!==o--;){var s=r[o];if(!e(t[s],n[s]))return!1}return!0}return t!=t&&n!=n}},2023:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o={data:new i.Name("data"),valCxt:new i.Name("valCxt"),instancePath:new i.Name("instancePath"),parentData:new i.Name("parentData"),parentDataProperty:new i.Name("parentDataProperty"),rootData:new i.Name("rootData"),dynamicAnchors:new i.Name("dynamicAnchors"),vErrors:new i.Name("vErrors"),errors:new i.Name("errors"),this:new i.Name("this"),self:new i.Name("self"),scope:new i.Name("scope"),json:new i.Name("json"),jsonPos:new i.Name("jsonPos"),jsonLen:new i.Name("jsonLen"),jsonPart:new i.Name("jsonPart")};t.default=o},2079:e=>{"use strict";e.exports=JSON.parse('{"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://json-schema.org/draft-07/schema#","title":"Core schema meta-schema","definitions":{"schemaArray":{"type":"array","minItems":1,"items":{"$ref":"#"}},"nonNegativeInteger":{"type":"integer","minimum":0},"nonNegativeIntegerDefault0":{"allOf":[{"$ref":"#/definitions/nonNegativeInteger"},{"default":0}]},"simpleTypes":{"enum":["array","boolean","integer","null","number","object","string"]},"stringArray":{"type":"array","items":{"type":"string"},"uniqueItems":true,"default":[]}},"type":["object","boolean"],"properties":{"$id":{"type":"string","format":"uri-reference"},"$schema":{"type":"string","format":"uri"},"$ref":{"type":"string","format":"uri-reference"},"$comment":{"type":"string"},"title":{"type":"string"},"description":{"type":"string"},"default":true,"readOnly":{"type":"boolean","default":false},"examples":{"type":"array","items":true},"multipleOf":{"type":"number","exclusiveMinimum":0},"maximum":{"type":"number"},"exclusiveMaximum":{"type":"number"},"minimum":{"type":"number"},"exclusiveMinimum":{"type":"number"},"maxLength":{"$ref":"#/definitions/nonNegativeInteger"},"minLength":{"$ref":"#/definitions/nonNegativeIntegerDefault0"},"pattern":{"type":"string","format":"regex"},"additionalItems":{"$ref":"#"},"items":{"anyOf":[{"$ref":"#"},{"$ref":"#/definitions/schemaArray"}],"default":true},"maxItems":{"$ref":"#/definitions/nonNegativeInteger"},"minItems":{"$ref":"#/definitions/nonNegativeIntegerDefault0"},"uniqueItems":{"type":"boolean","default":false},"contains":{"$ref":"#"},"maxProperties":{"$ref":"#/definitions/nonNegativeInteger"},"minProperties":{"$ref":"#/definitions/nonNegativeIntegerDefault0"},"required":{"$ref":"#/definitions/stringArray"},"additionalProperties":{"$ref":"#"},"definitions":{"type":"object","additionalProperties":{"$ref":"#"},"default":{}},"properties":{"type":"object","additionalProperties":{"$ref":"#"},"default":{}},"patternProperties":{"type":"object","additionalProperties":{"$ref":"#"},"propertyNames":{"format":"regex"},"default":{}},"dependencies":{"type":"object","additionalProperties":{"anyOf":[{"$ref":"#"},{"$ref":"#/definitions/stringArray"}]}},"propertyNames":{"$ref":"#"},"const":true,"enum":{"type":"array","items":true,"minItems":1,"uniqueItems":true},"type":{"anyOf":[{"$ref":"#/definitions/simpleTypes"},{"type":"array","items":{"$ref":"#/definitions/simpleTypes"},"minItems":1,"uniqueItems":true}]},"format":{"type":"string"},"contentMediaType":{"type":"string"},"contentEncoding":{"type":"string"},"if":{"$ref":"#"},"then":{"$ref":"#"},"else":{"$ref":"#"},"allOf":{"$ref":"#/definitions/schemaArray"},"anyOf":{"$ref":"#/definitions/schemaArray"},"oneOf":{"$ref":"#/definitions/schemaArray"},"not":{"$ref":"#"}},"default":true}')},2094:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o=n(4227),r={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:{message:"property name must be valid",params:({params:e})=>i._`{propertyName: ${e.propertyName}}`},code(e){const{gen:t,schema:n,data:r,it:s}=e;if((0,o.alwaysValidSchema)(s,n))return;const a=t.name("valid");t.forIn("key",r,n=>{e.setParams({propertyName:n}),e.subschema({keyword:"propertyNames",data:n,dataTypes:["string"],propertyName:n,compositeRule:!0},a),t.if((0,i.not)(a),()=>{e.error(!0),s.allErrors||t.break()})}),e.ok(a)}};t.default=r},2128:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(3463),o=n(3693),r=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",i.default,o.default];t.default=r},2447:(e,t,n)=>{"use strict";n.r(t),n.d(t,{GetRegionEditor:()=>To,PackageFunctions:()=>Yr,SeqActivityCliffsEditor:()=>Io,SeqPaletteCustom:()=>Kr,SequenceSpaceEditor:()=>_o,SplitToMonomersEditor:()=>Eo,SubsequenceSearchTopMenu:()=>mr,_package:()=>qr,activityCliffs:()=>Wo,addCopyMenu:()=>Pr,alignSequences:()=>Qo,bilnSequenceCellRenderer:()=>Ro,bioSubstructureFilter:()=>Ar,bioSubstructureFilterTest:()=>xr,compositionAnalysis:()=>er,compositionAnalysisWidget:()=>ko,convertColumnAction:()=>or,convertDialog:()=>ir,customSequenceCellRenderer:()=>Lo,demoBioActivityCliffs:()=>Or,demoBioAtomicLevel:()=>kr,demoBioSequenceSpace:()=>$r,demoBioSimilarityDiversity:()=>Rr,detectMacromoleculeProbe:()=>Gr,diversitySearchTopMenu:()=>dr,diversitySearchViewer:()=>hr,fastaSequenceCellRenderer:()=>No,getBioLib:()=>So,getHelmMonomers:()=>lr,getMolFromHelm:()=>Vr,getMonomerLibHelper:()=>yo,getRegion:()=>Do,getRegionApp:()=>Er,getRegionHelmApp:()=>_r,getRegionPanel:()=>xo,getRegionTopMenu:()=>Vo,getSeqHandler:()=>Ao,getSeqHelper:()=>Dr,helmPreprocessingFunction:()=>Uo,importBam:()=>nr,importFasta:()=>tr,initBio:()=>bo,libraryPanel:()=>Mo,longSeqTableFasta:()=>Lr,longSeqTableHelm:()=>Nr,longSeqTableSeparator:()=>Ir,macroMolColumnPropertyPanel:()=>Oo,macromoleculeDifferenceCellRenderer:()=>Ho,macromoleculePreprocessingFunction:()=>jo,manageLibrariesView:()=>br,manageMonomerLibraries:()=>yr,manageMonomerLibrariesView:()=>wr,manageMonomerLibrariesViewTreeBrowser:()=>Cr,manageMonomersView:()=>vr,matchWithMonomerLibrary:()=>Co,moleculesToHelmTopMenu:()=>zo,monomerCellRenderer:()=>rr,multipleSequenceAlignmentDialog:()=>Jo,refineNotationProviderForBiln:()=>$o,saveAsFasta:()=>Sr,sdfToJsonLib:()=>Hr,searchSubsequenceEditor:()=>pr,separatorSequenceCellRenderer:()=>Po,seq2atomic:()=>Br,seqIdentity:()=>Fr,sequence3dStructureWidget:()=>Xo,sequenceAlignment:()=>Bo,sequenceIdentityScoring:()=>fr,sequenceSimilarityScoring:()=>gr,sequenceSpaceTopMenu:()=>qo,sequenceTooltip:()=>vo,similaritySearchTopMenu:()=>ur,similaritySearchViewer:()=>cr,splitToMonomersTopMenu:()=>ar,standardiseMonomerLibrary:()=>wo,test1:()=>Zr,testDetectMacromolecule:()=>sr,toAtomicLevel:()=>Yo,toAtomicLevelAction:()=>Ko,toAtomicLevelPanel:()=>Zo,vdRegionsViewer:()=>Go,webLogoAggApp:()=>Tr,webLogoLargeApp:()=>Mr,webLogoViewer:()=>Fo});var i,o,r=n(4328),s=n(7389),a=n(6082),l=n(684),c=n(9039);(o=i||(i={})).EUCLIDEAN="EUCLIDEAN",o.MANHATTAN="MANHATTAN";var u=n(1858),h=n(5072),d=n.n(h),p=n(7825),m=n.n(p),f=n(7659),g=n.n(f),y=n(5056),b=n.n(y),v=n(540),w=n.n(v),C=n(1113),S=n.n(C),A=n(7939),x={};x.styleTagTransform=S(),x.setAttributes=b(),x.insert=g().bind(null,"head"),x.domAPI=m(),x.insertStyleElement=w(),d()(A.A,x),A.A&&A.A.locals&&A.A.locals;var M=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function s(e){try{l(i.next(e))}catch(e){r(e)}}function a(e){try{l(i.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((i=i.apply(e,t||[])).next())})};let T=null,E=null;function _(e,t){return e&&""!=e?e:t}n(2780);class I{constructor(){this.learningRate={uiName:"Learninig Rate",value:1,tooltip:"The initial learning rate for the embedding optimization"},this.nEpochs={uiName:"Epochs",value:0,tooltip:"The number of epochs to optimize embeddings via SGD. Computed automatically if set to 0"},this.nNeighbors={uiName:"Neighbors",value:15,tooltip:"The number of nearest neighbors to construct the fuzzy manifold"},this.spread={uiName:"Spread",value:1,tooltip:"The effective scale of embedded points, used with min distance to control \n the clumped/dispersed nature of the embedding"},this.minDist={uiName:"Min Distance",value:.1,tooltip:"The effective minimum distance between embedded points, \n used with spread to control the clumped/dispersed nature of the embedding"},this.randomSeed={uiName:"Random Seed",value:null,tooltip:"Random seed",type:"string"},this.useWebGPU={uiName:"Use WebGPU",value:!1,tooltip:"Use WebGPU for Distance and UMAP computations",type:"boolean",disableTooltip:"WebGPU is not available"},function(){return M(this,void 0,void 0,function*(){if(!navigator.gpu)return console.error("WebGPU is not supported in this browser"),null;if(!T&&(T=yield navigator.gpu.requestAdapter(),null==T))return null;let e=null;return"info"in T&&(e=T.info),e?_(e.description,_(e.vendor,"No GPU description available")):"No GPU description available"})}().then(e=>{e?(this.useWebGPU.tooltip+=` (${e})`,this.useWebGPU.value=!0):(this.useWebGPU.value=!1,this.useWebGPU.disable=!0)})}}class L{constructor(){this.epsilon={uiName:"Epsilon",value:10,tooltip:"Epsilon is learning rate"},this.perplexity={uiName:"Perplexity",value:30,tooltip:"Roughly how many neighbors each point influences"}}}Promise.resolve(),n(934),n(8903);const N="MCL";var P=n(1991),R=n.n(P);a.SEMTYPE.MOLECULE,a.SEMTYPE.MACROMOLECULE;class ${constructor(){this.epsilon={uiName:"Epsilon",value:.01,tooltip:"Minimum distance between cluster points",min:0,max:2,step:.005},this.minPts={uiName:"Minimum points",value:4,tooltip:"Minimum number of points in cluster",min:1,max:1e3,step:1}}}class O{get algorithmOptions(){const e=this.methodsParams[this.methodInput.value],t={};return Object.keys(e).forEach(n=>{null!=e[n].value&&(t[n]=e[n].value)}),t}get dbScanOptions(){return{dbScanEpsilon:this.dbScanParams.epsilon.value??.01,dbScanMinPts:this.dbScanParams.minPts.value??4}}constructor(e={}){this.editorSettings={},this.plotEmbeddingsInput=s.input.bool("Plot embeddings",{value:!0}),this.clusterEmbeddingsInput=s.input.bool("Cluster embeddings",{value:!0}),this.preprocessingFunctionInputRoot=null,this.methods=[c.c.UMAP,c.c.T_SNE],this.columnFunctionsMap={},this.supportedFunctions={},this.availableMetrics=[],this.methodSettingsDiv=s.inputs([]),this.dbScanSettingsDiv=s.inputs([]),this.preprocessingFuncSettingsDiv=s.inputs([]),this.preprocessingFunctionSettings={},this.methodsParams={[c.c.UMAP]:new I,[c.c.T_SNE]:new L},this.dbScanParams=new $,this.editorSettings=e,this.editorSettings.enableMCL&&this.methods.push(N),a.Func.find({tags:[l.GP]}).forEach(e=>{const t=e.options.get(l.n3)??"",n=e.friendlyName??e.name,i=e.options.get(l.C0)??"",o=e.options.get(l._X)??"",r=e.options.get(l.Gi)??"";this.editorSettings.semtype&&!t.includes(this.editorSettings.semtype)||this.editorSettings.type&&!i.includes(this.editorSettings.type)||this.editorSettings.units&&!o.includes(this.editorSettings.units)||(this.supportedFunctions[n]={func:e,semTypes:t?t.split(","):[],types:i?i.split(","):[],units:o?o.split(","):[],distanceFunctions:r?r.split(","):[]})}),this.tableInput=s.input.table("Table",{value:r.shell.tv.dataFrame,items:r.shell.tables,onValueChanged:()=>{this.onTableInputChanged()}}),this.onTableInputChanged(),this.regenerateColInput(),this.onColumnInputChanged();let t=!1,n=!1;this.methodInput=s.input.choice("Method",{value:c.c.UMAP,items:this.methods,onValueChanged:e=>{t&&this.createAlgorithmSettingsDiv(this.methodSettingsDiv,this.methodsParams[e])}}),this.methodSettingsIcon=s.icons.settings(()=>{t=!t,t?this.createAlgorithmSettingsDiv(this.methodSettingsDiv,this.methodsParams[this.methodInput.value]):s.empty(this.methodSettingsDiv)},"Modify methods parameters"),this.dbScanSettingsIcon=s.icons.settings(()=>{n=!n,n?this.createAlgorithmSettingsDiv(this.dbScanSettingsDiv,this.dbScanParams):s.empty(this.dbScanSettingsDiv)},"Modify clustering parameters"),this.clusterEmbeddingsInput.classList.add("ml-dim-reduction-settings-input"),this.clusterEmbeddingsInput.root.prepend(this.dbScanSettingsIcon),this.methodInput.root.classList.add("ml-dim-reduction-settings-input"),this.methodInput.root.prepend(this.methodSettingsIcon),this.methodSettingsDiv=s.inputs([]);const i=this.columnFunctionsMap[this.colInput.value.name];this.preprocessingFunctionInput=s.input.choice("Encoding function",{value:i[0],items:i,onValueChanged:()=>{this.onPreprocessingFunctionChanged()}});let o=!1;this.preprocessingFunctionInputRoot||(this.preprocessingFunctionInputRoot=this.preprocessingFunctionInput.root,o=!0),o||(s.empty(this.preprocessingFunctionInputRoot),Array.from(this.preprocessingFunctionInput.root.children).forEach(e=>this.preprocessingFunctionInputRoot.append(e))),this.preprocessingFunctionInputRoot.classList.add("ml-dim-reduction-settings-input");let u=!1;this.preprocessingFuncSettingsIcon=s.icons.settings(async()=>{u?s.empty(this.preprocessingFuncSettingsDiv):await this.createPreprocessingFuncParamsDiv(this.preprocessingFuncSettingsDiv,this.supportedFunctions[this.preprocessingFunctionInput.value].func),u=!u},"Modify encoding function parameters"),this.preprocessingFunctionInputRoot.prepend(this.preprocessingFuncSettingsIcon),this.similarityMetricInput=s.input.choice("Similarity",{value:"",items:[]}),this.similarityMetricInput.nullable=!1,this.similarityMetricInputRoot||(this.similarityMetricInputRoot=this.similarityMetricInput.root),this.onPreprocessingFunctionChanged()}getColInput(){const e=this.tableInput.value?.columns.toList().find(e=>!!this.columnFunctionsMap[e.name])??null,t=s.input.column("Column",{table:this.tableInput.value,value:e,nullable:!1,onValueChanged:()=>this.onColumnInputChanged(),filter:e=>!!this.columnFunctionsMap[e.name]});return this.colInputRoot||(this.colInputRoot=t.root),t}regenerateColInput(){let e=!1;this.colInputRoot&&(e=!0,s.empty(this.colInputRoot)),this.colInput=this.getColInput(),e&&Array.from(this.colInput.root.children).forEach(e=>this.colInputRoot.append(e)),this.onColumnInputChanged()}onTableInputChanged(){const e=this.tableInput.value;if(!e)return;const t=()=>{this.columnFunctionsMap={},e.columns.toList().forEach(e=>{Object.keys(this.supportedFunctions).forEach(t=>{const n=this.supportedFunctions[t].semTypes,i=this.supportedFunctions[t].types,o=this.supportedFunctions[t].units,r=!n.length||e.semType&&n.includes(e.semType),s=!i.length||i.includes(e.type),a=!o.length||e.meta.units&&o.includes(e.meta.units);r&&s&&a&&(this.columnFunctionsMap[e.name]||(this.columnFunctionsMap[e.name]=[]),this.columnFunctionsMap[e.name].push(t))})}),this.regenerateColInput()};t(),R()(e.columns).some(e=>!!e.getTag(a.Tags.SemanticDetectionDuration))||e.meta.detectSemanticTypes().then(()=>{t()})}onColumnInputChanged(){const e=this.colInput.value;if(!e)return;const t=this.columnFunctionsMap[e.name];this.preprocessingFunctionInput=s.input.choice("Preprocessing function",{value:t[0],items:t,onValueChanged:()=>{this.onPreprocessingFunctionChanged()}});let n=!1;this.preprocessingFunctionInputRoot||(this.preprocessingFunctionInputRoot=this.preprocessingFunctionInput.root,n=!0),n||(s.empty(this.preprocessingFunctionInputRoot),Array.from(this.preprocessingFunctionInput.root.children).forEach(e=>this.preprocessingFunctionInputRoot.append(e))),this.onPreprocessingFunctionChanged()}onPreprocessingFunctionChanged(){s.empty(this.preprocessingFuncSettingsDiv),this.preprocessingFunctionSettings={};const e=this.preprocessingFunctionInput.value,t=this.supportedFunctions[e].distanceFunctions;this.availableMetrics=[...t],this.similarityMetricInput=s.input.choice("Similarity",{value:this.availableMetrics[0],items:this.availableMetrics}),this.similarityMetricInput.nullable=!1,this.similarityMetricInputRoot||(this.similarityMetricInputRoot=this.similarityMetricInput.root),s.empty(this.similarityMetricInputRoot),Array.from(this.similarityMetricInput.root.children).forEach(e=>this.similarityMetricInputRoot.append(e)),this.preprocessingFuncSettingsIcon&&(this.supportedFunctions[e].func.inputs.length<3?this.preprocessingFuncSettingsIcon.style.display="none":this.preprocessingFuncSettingsIcon.style.display="flex")}createAlgorithmSettingsDiv(e,t){return s.empty(e),Object.keys(t).forEach(n=>{const i=t[n],o="string"===i.type?s.input.string(i.uiName,{value:i.value??"",onValueChanged:e=>{i.value=e}}):"boolean"===i.type?s.input.bool(i.uiName,{value:i.value??!1,onValueChanged:e=>{i.value=e}}):s.input.float(i.uiName,{value:i.value,onValueChanged:e=>{i.value=e}});e.append(o.root),i.disable?(o.enabled=!1,s.tooltip.bind(o.input??o.root,i.disableTooltip??"")):s.tooltip.bind(o.input??o.root,i.tooltip)}),e}async createPreprocessingFuncParamsDiv(e,t){if(s.empty(e),t.inputs.length<3)return s.div();const n=t.prepare(),i=await n.buildEditor(s.div());for(let o=2;o<t.inputs.length;o++){const r=t.inputs[o];(this.preprocessingFunctionSettings[r.name]||n.inputParams[t.inputs[o].name].value||r.defaultValue)&&(this.preprocessingFunctionSettings[r.name]=this.preprocessingFunctionSettings[r.name]??n.inputParams[r.name].value??r.defaultValue);const s=i.find(e=>e.property.name===r.name);s&&(null!==this.preprocessingFunctionSettings[r.name]&&void 0!==this.preprocessingFunctionSettings[r.name]&&(s.value=this.preprocessingFunctionSettings[r.name]),s.onChanged.subscribe(e=>{this.preprocessingFunctionSettings[r.name]=e}),e.append(s.root))}return e}getEditor(){return s.div([this.tableInput,this.colInputRoot,this.preprocessingFunctionInputRoot,this.preprocessingFuncSettingsDiv,this.methodInput,this.methodSettingsDiv,this.similarityMetricInputRoot,this.plotEmbeddingsInput,this.clusterEmbeddingsInput,this.dbScanSettingsDiv],{style:{minWidth:"420px"},classes:"ui-form dim-reduction-dialog-form"})}getParams(){return{table:this.tableInput.value,col:this.colInput.value,methodName:this.methodInput.value,preprocessingFunction:this.supportedFunctions[this.preprocessingFunctionInput.value].func,similarityMetric:this.similarityMetricInput.value,plotEmbeddings:this.plotEmbeddingsInput.value,clusterEmbeddings:this.clusterEmbeddingsInput.value,options:{...this.algorithmOptions,...this.dbScanOptions,preprocessingFuncArgs:this.preprocessingFunctionSettings??{}}}}getInput(){return{table:this.tableInput.value.name,col:this.colInput.value.name,methodName:this.methodInput.value,preprocessingFunction:this.preprocessingFunctionInput.value,similarityMetric:this.similarityMetricInput.value,plotEmbeddings:this.plotEmbeddingsInput.value,clusterEmbeddings:this.clusterEmbeddingsInput.value,options:{...this.algorithmOptions,...this.dbScanOptions,preprocessingFuncArgs:this.preprocessingFunctionSettings??{}}}}getStringInput(){return JSON.stringify(this.getInput())}async applyStringInput(e){try{const t=JSON.parse(e);await this.applyInput(t)}catch(e){r.shell.error("Error applying input from history"),console.error(e)}}async applyInput(e){try{const t=this.tableInput.value?.col(e.col);if(!t)throw new Error("Column not found");this.colInput.value=t,this.preprocessingFunctionInput.value=e.preprocessingFunction,this.similarityMetricInput.value=e.similarityMetric,this.plotEmbeddingsInput.value=e.plotEmbeddings,this.clusterEmbeddingsInput.value=e.clusterEmbeddings;const n=this.methodsParams[this.methodInput.value];Object.keys(n).forEach(t=>{null!=e.options[t]&&(this.methodsParams[e.methodName][t].value=e.options[t])}),this.methodInput.value=e.methodName,this.preprocessingFunctionSettings=e.options.preprocessingFuncArgs,await this.createPreprocessingFuncParamsDiv(this.preprocessingFuncSettingsDiv,this.supportedFunctions[this.preprocessingFunctionInput.value].func)}catch(e){r.shell.error("Error applying input from history"),console.error(e)}}}var k=n(9713),H=n(6295);const B=e=>null==e;function F(e,t,n,i){if(n>e[e.length-1])return;const o=e.findIndex(e=>n<e);e.pop(),e.splice(o,0,n),t.pop(),t.splice(o,0,i)}class G{constructor(e=!0,t=!0){const i=navigator.hardwareConcurrency;this._workerCount=e?Math.max(i-2,1):1,this._workers=new Array(this._workerCount).fill(null).map(()=>new Worker(new URL(n.p+n.u(793),n.b))),this._terminateOnComplete=t}async calc(e,t,n=!0,o){return await this.calcMulti([e],[t],n,[o??{}],[1],i.MANHATTAN)}async calcMulti(e,t,n=!0,o=[{}],r=[1],s=i.MANHATTAN){if(e.length<1)throw new Error("values must contain at least one array");if(t.length!==e.length||o.length!==e.length||r.length!==e.length)throw new Error("values, fnNames, weights and opts must have the same length");return new Promise(async(i,a)=>{try{const a=e[0].length,l=new Array(this._workerCount),c=a*(a-1)/2;this._workerCount=Math.min(this._workerCount,c);const u=c/this._workerCount,h=new Float32Array(c);let d=0,p=1,m=0,f=Number.MIN_VALUE;for(let n=0;n<this._workerCount;n++){const i=Math.floor(n*u),g=n===this._workerCount-1?c:Math.floor((n+1)*u),y=d,b=p;n!==this._workerCount-1&&(d=a-2-Math.floor(Math.sqrt(-8*g+4*a*(a-1)-7)/2-.5),p=g-a*d+Math.floor((d+1)*(d+2)/2)),this._workers[n].postMessage({values:e,fnNames:t,startRow:y,startCol:b,chunckSize:g-i,opts:o,weights:r,aggregationMethod:s}),l[n]=new Promise((e,t)=>{this._workers[n].onmessage=({data:{error:o,distanceMatrixData:r,min:s,max:a}})=>{this._terminateOnComplete&&setTimeout(()=>this._workers[n].terminate()),o?t(o):(h.set(r,i),s<m&&(m=s),a>f&&(f=a),e())}})}await Promise.all(l),n&&h.forEach((e,t)=>{h[t]=(e-m)/(f-m)}),i(h)}catch(e){a(e)}})}terminate(){this._workers.forEach(e=>e.terminate())}}class D{constructor(){this._workerCount=Math.max(navigator.hardwareConcurrency-2,1)}static pruneSparseMatrix(e,t=1e6){const n=200,i=new Uint32Array(n),o=e.distance.length,r=e.distance;for(let e=0;e<o;e++)i[Math.floor(r[e]*n)]++;let s=0,a=0;for(let e=0;e<n&&(s+=i[e],a=e,!(s>=t));e++);const l=new Uint32Array(s),c=new Uint32Array(s),u=new Float32Array(s),h=e.i,d=e.j;let p=0;const m=(a+1)/n;for(let e=0;e<o;e++)r[e]<m&&(l[p]=h[e],c[p]=d[e],u[p]=r[e],p++);return{i:l,j:c,distance:u}}async calcMultiColumn(e,t,o,r=[{}],s=[1],a=i.EUCLIDEAN){const l=e[0].length*(e[0].length-1)/2,c=Math.floor(l/this._workerCount),u=e[0].length>2e4?await this.getMinimalThreshold(e,t,r,s,a):0;o<u&&(console.log(`using threshold ${u}`),o=u),r.forEach((e,t)=>r[t].threshold=o);const h=new Array(this._workerCount),d=new Array(this._workerCount).fill(null).map(()=>new Worker(new URL(n.p+n.u(111),n.b)));for(let n=0;n<this._workerCount;n++)h[n]=new Promise((i,u)=>{const h=n*c,p=n===this._workerCount-1?l:(n+1)*c;p<=h&&i({i:new Int32Array(0),j:new Int32Array(0),distance:new Float32Array(0),idx:n}),d[n].postMessage({values:e,startIdx:h,endIdx:p,threshold:o,fnNames:t,opts:r,weights:s,aggregationMethod:a}),d[n].onmessage=({data:{error:e,i:t,j:o,distance:r}})=>{e?(d[n].terminate(),u(e)):(d[n].terminate(),i({i:t,j:o,distance:r,idx:n}))}});const p=await Promise.all(h),m=p.reduce((e,t)=>e+t.i.length,0),f=new Int32Array(m),g=new Int32Array(m),y=new Float32Array(m);let b=0;for(const e of p)f.set(e.i,b),g.set(e.j,b),y.set(e.distance,b),b+=e.i.length;return{i:f,j:g,distance:y}}async calc(e,t,n,i={}){return await this.calcMultiColumn([e],[t],n,[i],[1])}async getKNN(e,t,n=15,i={}){return await this.multiColumnKNN([e],[t],n,[i],[1])}async getThresholdKNN(e,t,n=.8,i={}){return await this.multiColumnThresholdKnn([e],[t],n,[i],[1])}async multiColumnThresholdKnn(e,t,o=.8,r,s,a=i.EUCLIDEAN){if(e.length!==t.length||e.length!==r.length||e.length!==s.length)throw new Error("values, distance functions, options and weights arrays should have the same length");if(e.some(t=>t.length!==e[0].length))throw new Error("all values arrays should have the same length");const l=e[0].length*(e[0].length-1)/2,c=Math.floor(l/this._workerCount),u=new Array(this._workerCount),h=new Array(this._workerCount).fill(null).map(()=>new Worker(new URL(n.p+n.u(603),n.b)));for(let n=0;n<this._workerCount;n++)u[n]=new Promise((i,u)=>{const d=n*c,p=n===this._workerCount-1?l:(n+1)*c;p<=d&&i({knnDistances:new Array(0),knnIndexes:new Array(0)}),h[n].postMessage({values:e,startIdx:d,endIdx:p,fnNames:t,opts:r,threshold:o,weights:s,aggregationMethod:a}),h[n].onmessage=({data:{error:e,knnDistances:t,knnIndexes:o}})=>{e?(h[n].terminate(),u(e)):(h[n].terminate(),i({knnDistances:t,knnIndexes:o}))}});const d=await Promise.all(u),p=new Int32Array(e[0].length);for(const t of d)for(let n=0;n<e[0].length;++n)p[n]+=t.knnIndexes[n]?.length??0;const m={knnDistances:new Array(e[0].length).fill(null).map((e,t)=>new Array(p[t])),knnIndexes:new Array(e[0].length).fill(null).map((e,t)=>new Array(p[t]))};for(const t of d)for(let n=0;n<e[0].length;++n)for(let e=0;e<(t.knnDistances[n]?.length??0);++e)m.knnDistances[n][p[n]-1]=t.knnDistances[n][e],m.knnIndexes[n][p[n]-1]=t.knnIndexes[n][e],p[n]-=1;return m}async multiColumnSingleValueKNN(e,t,o,r=15,s,a,l=i.EUCLIDEAN){if(e.length!==o.length||e.length!==s.length||e.length!==a.length)throw new Error("values, distance functions, options and weights arrays should have the same length");if(e.some(t=>t.length!==e[0].length))throw new Error("all values arrays should have the same length");const c=new Array(this._workerCount).fill(null).map(()=>new Worker(new URL(n.p+n.u(810),n.b))),u=new Array(this._workerCount),h=e[0].length,d=e.map(e=>e[t]),p=Math.ceil(h/this._workerCount);for(let t=0;t<this._workerCount;t++)u[t]=new Promise((n,i)=>{const u=t*p,m=t===this._workerCount-1?h:(t+1)*p;m<=u&&n({knnDistances:new Array(0),knnIndexes:new Array(0)}),c[t].postMessage({values:e.map(e=>e.slice(u,m)),target:d,fnNames:o,opts:s,nNeighbours:r,weights:a,aggregationMethod:l,startIdx:u}),c[t].onmessage=({data:{error:e,knnDistances:o,knnIndexes:r}})=>{e?(c[t].terminate(),i(e)):(c[t].terminate(),n({knnDistances:o,knnIndexes:r}))}});const m=await Promise.all(u),f={knnDistances:new Array(r).fill(99999),knnIndexes:new Array(r).fill(-1)};for(const e of m)for(let t=0;t<(e.knnDistances?.length??0);++t)F(f.knnDistances,f.knnIndexes,e.knnDistances[t],e.knnIndexes[t]);return f}async multiColumnKNN(e,t,o=15,r,s,a=i.EUCLIDEAN){if(e.length!==t.length||e.length!==r.length||e.length!==s.length)throw new Error("values, distance functions, options and weights arrays should have the same length");if(e.some(t=>t.length!==e[0].length))throw new Error("all values arrays should have the same length");const l=e[0].length*(e[0].length-1)/2,c=Math.floor(l/this._workerCount),u=new Array(this._workerCount),h=new Array(this._workerCount).fill(null).map(()=>new Worker(new URL(n.p+n.u(950),n.b)));for(let n=0;n<this._workerCount;n++)u[n]=new Promise((i,u)=>{const d=n*c,p=n===this._workerCount-1?l:(n+1)*c;p<=d&&i({knnDistances:new Array(0),knnIndexes:new Array(0)}),h[n].postMessage({values:e,startIdx:d,endIdx:p,fnNames:t,opts:r,nNeighbours:o,weights:s,aggregationMethod:a}),h[n].onmessage=({data:{error:e,knnDistances:t,knnIndexes:o}})=>{e?(h[n].terminate(),u(e)):(h[n].terminate(),i({knnDistances:t,knnIndexes:o}))}});const d=await Promise.all(u),p={knnDistances:new Array(e[0].length).fill(null).map(()=>new Array(o).fill(99999)),knnIndexes:new Array(e[0].length).fill(null).map(()=>new Array(o).fill(-1))};for(const t of d)for(let n=0;n<e[0].length;++n)for(let e=0;e<(t.knnDistances[n]?.length??0);++e)F(p.knnDistances[n],p.knnIndexes[n],t.knnDistances[n][e],t.knnIndexes[n][e]);return p}async getSampleDistances(e,t,o=[],r,s=i.EUCLIDEAN){const a=new Array(this._workerCount).fill(null).map(()=>new Worker(new URL(n.p+n.u(778),n.b)));try{const n=e[0].length*(e[0].length-1)/2,i=Math.floor(n/this._workerCount),l=1e6,c=Math.max(Math.min(n/1e3,l),Math.min(n,l)),u=Math.floor(c/this._workerCount),h=new Array(this._workerCount);for(let l=0;l<this._workerCount;l++)h[l]=new Promise((c,h)=>{const d=l*i,p=l===this._workerCount-1?n:(l+1)*i;a[l].postMessage({values:e,startIdx:d,endIdx:p,sampleLength:u,fnNames:t,opts:o,weights:r,aggregationMethod:s}),a[l].onmessage=({data:{error:e,distance:t}})=>{a[l].terminate(),e?h(e):c({distance:t})}});const d=await Promise.all(h),p=d.reduce((e,t)=>e+t.distance.length,0),m=new Float32Array(p);let f=0;for(const e of d)m.set(e.distance,f),f+=e.distance.length;return m.sort(),m}catch(e){return a?.forEach(e=>e?.terminate()),console.error(e),new Float32Array(1).fill(.5)}}async getMinimalThreshold(e,t,n=[],o,r=i.EUCLIDEAN){try{const i=e.length*(e.length-1)/2,s=await this.getSampleDistances(e,t,n,o,r);return 1-s[Math.floor(7e7/i*s.length)]}catch(e){return console.error(e),.5}}static calcSync(e,t,n,i){const o=[],r=[],s=[];let a=0,l=0,c=0;const u=e.length*(e.length-1)/2;for(;a<u;){const t=B(e[l])||B(e[c])?1:n(e[l],e[c]);1-t>=i&&(o.push(l),r.push(c),s.push(t)),a++,c++,c===e.length&&(l++,c=l+1)}return{i:new Int32Array(o),j:new Int32Array(r),distance:new Float32Array(s)}}}var V,W,j=n(8774);(W=V||(V={})).none="none",W.bold="bold",W.dashed="dashed";class U{get currentLineId(){return this._currentLineIdx}set currentLineId(e){e!==this._currentLineIdx&&(this._currentLineIdx=e,this.sp.render(this.ctx))}set linesToRender(e){this.updateLines(e),this.sp.render(this.ctx)}set linesVisibility(e){this.visibility=e,this.sp.render(this.ctx)}constructor(e,t,n,i,o=V.none){var r;this._currentLineIdx=-1,this.lineClicked=new u.Subject,this.lineHover=new u.Subject,this.mouseOverLineId=-1,this.arrowWidth=15,this.sp=e,this.xAxisCol=this.sp.dataFrame.columns.byName(t),this.yAxisCol=this.sp.dataFrame.columns.byName(n),this.canvas=this.sp.getInfo().canvas,this.ctx=this.canvas.getContext("2d"),this.currentLineStyle=o,this.updateLines(i),this.visibility=null!==(r=i.visibility)&&void 0!==r?r:new j.A(this.lines.from.length),i.visibility||this.visibility.setAll(!0,!1),i.arrowSize&&(this.arrowWidth=i.arrowSize),this.canvas.onmousedown=e=>{var t;(null===(t=this.lines)||void 0===t?void 0:t.skipMouseOverDetection)&&(this.mouseOverLineId=this.checkCoordsOnLine(e.offsetX,e.offsetY)),-1!==this.mouseOverLineId&&this.lineClicked.next({x:e.clientX,y:e.clientY,id:this.mouseOverLineId,event:e})},this.canvas.onmousemove=e=>{var t;this.mouseOverLineId=(null===(t=this.lines)||void 0===t?void 0:t.skipMouseOverDetection)?-1:this.checkCoordsOnLine(e.offsetX,e.offsetY),-1!==this.mouseOverLineId&&this.lineHover.next({x:e.clientX,y:e.clientY,id:this.mouseOverLineId,event:e})},e.onEvent("d4-before-draw-scene").subscribe(e=>{this.renderLines()})}updateLines(e){this.lines=e,this.multipleLinesCounts=new Uint8Array(this.lines.from.length),e.skipMultiLineCalculation?this.multipleLinesCounts.fill(0):this.createMultiLinesIndices()}renderLines(){var e,t,n,i,o,r,s,a,l,c,u,h,d,p,m,f,g;const y=this.lines.colors||this.lines.widths||this.lines.opacities||this.lines.drawArrowsArr;y||(this.ctx.lineWidth=null!==(e=this.lines.width)&&void 0!==e?e:1,this.ctx.strokeStyle=`rgba(${null!==(t=this.lines.color)&&void 0!==t?t:"0,128,0"},${null!==(n=this.lines.opacity)&&void 0!==n?n:1})`);const b=this.sp.dataFrame.filter,v=Math.pow(null!==(i=this.lines.shortLineThreshold)&&void 0!==i?i:5,2);for(let e=0;e<this.lines.from.length;e++)if(b.get(this.lines.from[e])&&b.get(this.lines.to[e])&&this.visibility.getBit(e)){let t=0;const n=this.sp.getMarkerSize(this.lines.from[e])/2,i=this.sp.getMarkerSize(this.lines.to[e])/2,b=this.sp.pointToScreen(this.lines.from[e]);let w=null==b?void 0:b.x,C=null==b?void 0:b.y;const S=this.sp.pointToScreen(this.lines.to[e]);let A=null==S?void 0:S.x,x=null==S?void 0:S.y;const M=Math.min(this.sp.viewBox.width,this.sp.viewBox.height);if(this.ctx.beginPath(),w&&C&&A&&x&&Math.hypot(A-w,x-C)/M>.01){if(y){const t=(null===(o=this.lines.colors)||void 0===o?void 0:o[e])?null===(r=this.lines.colors)||void 0===r?void 0:r[e]:null!==(s=this.lines.color)&&void 0!==s?s:"0,128,0",n=(null===(a=this.lines.opacities)||void 0===a?void 0:a[e])?null===(l=this.lines.opacities)||void 0===l?void 0:l[e]:null!==(c=this.lines.opacity)&&void 0!==c?c:1;this.ctx.strokeStyle=`rgba(${t},${n})`,this.ctx.lineWidth=(null===(u=this.lines.widths)||void 0===u?void 0:u[e])?null===(h=this.lines.widths)||void 0===h?void 0:h[e]:null!==(d=this.lines.width)&&void 0!==d?d:1}e===this._currentLineIdx&&this.toggleCurrentLineStyle(!0);const b=this.multipleLinesCounts[e];let S=null;if(b){t=this.getLineLength(w,C,A,x);const o=this.getPointOnDistance(w,C,A,x,i,t),r=this.getPointOnDistance(A,x,w,C,n,t);w=o.x,C=o.y,A=r.x,x=r.y,S=this.lines.from[e]>this.lines.to[e]?this.findControlPoint(b,w,C,A,x,e):this.findControlPoint(b,A,x,w,C,e),this.ctx.moveTo(w,C),this.ctx.quadraticCurveTo(S.x,S.y,A,x)}else(!this.lines.skipShortLines||Math.pow(A-w,2)+Math.pow(x-C,2)>v)&&(this.ctx.moveTo(w,C),this.ctx.lineTo(A,x));if((null!==(p=this.lines.drawArrows)&&void 0!==p?p:null===(m=this.lines.drawArrowsArr)||void 0===m?void 0:m.getBit(e))&&(t||(t=this.getLineLength(w,C,A,x)),t>this.arrowWidth)){const e=b?null:this.getPointOnDistance(w,C,A,x,i,t),n=b?S.x:w,o=b?S.y:C;this.canvasArrow(this.ctx,null!==(f=null==e?void 0:e.x)&&void 0!==f?f:w,null!==(g=null==e?void 0:e.y)&&void 0!==g?g:C,n,o)}this.ctx.stroke(),this.ctx.closePath(),e===this._currentLineIdx&&this.toggleCurrentLineStyle(!1)}}this.fillLeftBottomRect()}toggleCurrentLineStyle(e){switch(this.currentLineStyle){case V.bold:e?this.ctx.lineWidth+=2:this.ctx.lineWidth-=2;break;case V.dashed:e?this.ctx.setLineDash([5,5]):this.ctx.setLineDash([]);break;default:return}}fillLeftBottomRect(){const e=new Path2D;e.rect(this.sp.yAxisBox.minX,this.sp.yAxisBox.maxY,this.sp.yAxisBox.width,this.sp.xAxisBox.height),this.ctx.fillStyle="white",this.ctx.beginPath(),this.ctx.fill(e),this.ctx.closePath()}createMultiLinesIndices(){const e={};for(let t=0;t<this.lines.from.length;t++){let n=0,i=0;this.lines.from[t]<this.lines.to[t]?(n=this.lines.from[t],i=this.lines.to[t]):(n=this.lines.to[t],i=this.lines.from[t]),e[`${n}|${i}`]?(1===e[`${n}|${i}`].length&&(this.multipleLinesCounts[e[`${n}|${i}`][0]]=1,e[`${n}|${i}`].push(1)),this.multipleLinesCounts[t]=++e[`${n}|${i}`][1]):e[`${n}|${i}`]=[t]}}checkCoordsOnLine(e,t){let n=-1,i=null,o=null;const r=this.sp.dataFrame.filter;for(let s=0;s<this.lines.from.length;s++)if(r.get(this.lines.from[s])&&r.get(this.lines.to[s])&&this.visibility.getBit(s)){const r=this.sp.getMarkerSize(this.lines.from[s])/2,a=this.sp.getMarkerSize(this.lines.to[s])/2,l=this.sp.worldToScreen(this.xAxisCol.get(this.lines.from[s]),this.yAxisCol.get(this.lines.from[s])),c=this.sp.worldToScreen(this.xAxisCol.get(this.lines.to[s]),this.yAxisCol.get(this.lines.to[s]));if(this.multipleLinesCounts[s]){const n=this.getLineLength(l.x,l.y,c.x,c.y),i=this.getPointOnDistance(l.x,l.y,c.x,c.y,a,n),u=this.getPointOnDistance(c.x,c.y,null==l?void 0:l.x,null==l?void 0:l.y,r,n),h=this.lines.from[s]>this.lines.to[s]?this.findControlPoint(this.multipleLinesCounts[s],i.x,i.y,u.x,u.y,s):this.findControlPoint(this.multipleLinesCounts[s],u.x,u.y,i.x,i.y,s);o=this.calculateDistToCurveLine(s,e,t,i,u,h)}else o=this.calculateDistToStraightLine(e,t,l,c);(!i&&null!==o&&o<5||i&&null!==o&&o<i)&&(i=o,n=s)}return n}calculateDistToStraightLine(e,t,n,i){const o=Math.min(n.x,i.x),r=Math.max(n.x,i.x),s=Math.min(n.y,i.y),a=Math.max(n.y,i.y);return e>=o-2&&e<=r+2&&t>=s-2&&t<=a+2?this.distToStraightLineSegment(e,t,n,i):null}distToStraightLineSegment(e,t,n,i){const o=(e,t,n,i)=>Math.pow(e-n,2)+Math.pow(t-i,2),r=o(n.x,n.y,i.x,i.y);if(0==r)return o(e,t,n.x,n.y);let s=((e-n.x)*(i.x-n.x)+(t-n.y)*(i.y-n.y))/r;return s=Math.max(0,Math.min(1,s)),o(e,t,n.x+s*(i.x-n.x),n.y+s*(i.y-n.y))}calculateDistToCurveLine(e,t,n,i,o,r){const s=Math.min(i.x,o.x,r.x),a=Math.max(i.x,o.x,r.x),l=Math.min(i.y,o.y,r.y),c=Math.max(i.y,o.y,r.y);if(t>=s-2&&t<=a+2&&n>=l-2&&n<=c+2){const e=a-s,u=c-l;return this.calculateDistToCurveInRect(t,n,i,r,o,e,u)}return null}calculateDistToCurveInRect(e,t,n,i,o,r,s){const a=Math.floor((r+s)/3),l=1/a,c=new Uint32Array(a),u=new Uint32Array(a),h=new Uint32Array(a);let d=null;const p=new j.A(a);for(let r=0;r<c.length;r++){const s=r*l,a=Math.pow(1-s,2)*n.x+2*s*(1-s)*i.x+Math.pow(s,2)*o.x,p=Math.pow(1-s,2)*n.y+2*s*(1-s)*i.y+Math.pow(s,2)*o.y,m=Math.abs(e-a),f=Math.abs(t-p),g=m+f;(!d||d>g)&&(d=g),h[r]=Math.max(m,f),c[r]=a,u[r]=p}for(let e=0;e<c.length;e++)h[e]<d&&p.setBit(e,!0,!1);let m=null;for(let n=-1;-1!==(n=p.findNext(n));){const i=Math.hypot(c[n]-e,u[n]-t);(!m||m>i)&&(m=i)}return m}getLineLength(e,t,n,i){return Math.sqrt(Math.pow(n-e,2)+Math.pow(i-t,2))}getPointOnDistance(e,t,n,i,o,r){const s=n-o*((n-e)/r),l=i-o*((i-t)/r);return new a.Point(s,l)}findControlPoint(e,t,n,i,o,r){const s=t+(i-t)/2,l=n+(o-n)/2;let c=s-t,u=l-n;const h=Math.sqrt(c*c+u*u);c/=h,u/=h;const d=50*Math.ceil(e/2);return e%2==0?new a.Point(s+d/2*u,l-d/2*c):new a.Point(s-d/2*u,l+d/2*c)}canvasArrow(e,t,n,i,o){const r=Math.atan2(i-t,o-n)+Math.PI;e.moveTo(t-this.arrowWidth*Math.sin(r-Math.PI/10),n-this.arrowWidth*Math.cos(r-Math.PI/10)),e.lineTo(t,n),e.lineTo(t-this.arrowWidth*Math.sin(r+Math.PI/10),n-this.arrowWidth*Math.cos(r+Math.PI/10))}}const q="dimensionality-reducer-terminate-event";var z,Y,K=n(3629);async function Z(e,t,i,o,s,a,l){let c=await async function(e,t,i,o,s,a,l){if(!a.distanceFnArgs)throw new Error("options.distanceFnArgs must be defined");if(e.length!==t.length||e.length!==a.distanceFnArgs.length||e.length!==o.length)throw new Error("data, metrics and options and weights must have the same length");return new Promise(function(c,u){const h=new Worker(new URL(n.p+n.u(234),n.b));h.postMessage({columnsData:e,distanceMetrics:t,method:i,options:a,weights:o,aggregationMethod:s});const d=r.events.onCustomEvent(q).subscribe(()=>{try{h?.terminate()}finally{d.unsubscribe()}});h.onmessage=({data:{error:e,embedding:t,epochNum:n,epochsLength:i}})=>{B(n)||B(i)?(d.unsubscribe(),e?u(e):c(t),setTimeout(()=>h.terminate(),100)):l&&l(n,i,t)}})}(e,i,t,o,s,a,l);return c=c.map(e=>(0,K.S8)(e)),c}(Y=z||(z={})).EUCLIDEAN="EUCLIDEAN",Y.MANHATTAN="MANHATTAN";const X={[z.EUCLIDEAN]:function(e){return`\n var sum = 0.0;\n for (var i = 0u; i < ${e}; i = i + 1u) {\n sum = sum + distances[i] * distances[i] * computeInfo.weights[i] * computeInfo.weights[i];\n }\n return sqrt(sum);\n `},[z.MANHATTAN]:function(e){return`\n var sum = 0.0;\n for (var i = 0u; i < ${e}; i = i + 1u) {\n sum = sum + abs(distances[i]) * computeInfo.weights[i];\n }\n return sum;\n `}};var J,Q;(Q=J||(J={})).HAMMING="Hamming",Q.EUCLIDEAN="Euclidean",Q.VECTOR_COSINE="Vector Cosine",Q.MANHATTAN="Manhattan",Q.TANIMOTO="Tanimoto",Q.LEVENSTEIN="Levenshtein",Q.NEEDLEMAN_WUNSCH="Needlemann-Wunsch",Q.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance",Q.SOKAL="Sokal",Q.COSINE="Cosine",Q.ASYMMETRIC="Asymmetric",Q.Difference="Difference",Q.OneHot="One-Hot";const ee={[J.HAMMING]:function(e,t){return`\n let aLength: u32 = computeInfo.entrySizes[${t}][aIndex];\n let bLength: u32 = computeInfo.entrySizes[${t}][bIndex];\n let maxLength: u32 = max(aLength, bLength);\n let minLength: u32 = min(aLength, bLength);\n let sizeDiff: u32 = maxLength - minLength;\n \n let maxIntDistance = ceil(maxDistance * f32(maxLength)) - f32(sizeDiff);\n\n var diff: f32 = 0.0;\n for (var i = 0u; i < ${e}; i = i + 1u) {\n diff = diff + f32(a[i] != b[i]);\n if (diff > maxIntDistance) {\n return 1.0;\n }\n }\n diff += f32(sizeDiff);\n return diff / ${e};\n `},[J.EUCLIDEAN]:function(e,t){return`\n var dist: f32 = 0.0;\n for (var i = 0u; i < ${e}; i = i + 1u) {\n dist = dist + f32(a[i] - b[i]) * f32(a[i] - b[i]);\n }\n return sqrt(dist);\n `},[J.MANHATTAN]:function(e,t){return`\n var dist: f32 = 0.0;\n for (var i = 0u; i < ${e}; i = i + 1u) {\n dist = dist + abs(f32(a[i] - b[i]));\n }\n return dist;\n `},[J.VECTOR_COSINE]:function(e,t){return`\n var dist: f32 = 0.0;\n var productSum: f32 = 0.0;\n var aSquareSum: f32 = 0.0;\n var bSquareSum: f32 = 0.0;\n for (var i = 0u; i < ${e}; i = i + 1u) {\n productSum = productSum + f32(a[i] * b[i]);\n aSquareSum = aSquareSum + f32(a[i] * a[i]);\n bSquareSum = bSquareSum + f32(b[i] * b[i]);\n }\n var sim = productSum / (sqrt(aSquareSum) * sqrt(bSquareSum));\n return (1.0 - sim) / 2.0;\n `},[J.TANIMOTO]:function(e,t){return`\n var onBitsa: u32 = 0u;\n var onBitsb: u32 = 0u;\n for (var i = 0u; i < ${e}u; i = i + 1u) {\n onBitsa = onBitsa + countOneBits(a[i]);\n onBitsb = onBitsb + countOneBits(b[i]);\n }\n\n if (onBitsa == 0u && onBitsb == 0u) {\n return 0.0;\n }\n\n let totalOnBits = onBitsa + onBitsb;\n var commonBits: u32 = 0u;\n for (var i = 0u; i < ${e}u; i = i + 1u) {\n commonBits = commonBits + countOneBits(a[i] & b[i]);\n }\n\n return 1.0 - f32(commonBits) / f32(totalOnBits - commonBits);\n `},[J.LEVENSTEIN]:function(e,t){return`\n let aLength: u32 = computeInfo.entrySizes[${t}][aIndex];\n let bLength: u32 = computeInfo.entrySizes[${t}][bIndex];\n let maxLength: u32 = max(aLength, bLength);\n let minLength: u32 = min(aLength, bLength);\n\n let maxIntDistance = ceil(maxDistance * f32(maxLength));\n\n // we will store two arrays as matrix and swap the working indices per pass.\n // this way we can reduce memory usage per computation to just O(aLength)\n // the grid will have aLength + 1 columns and bLength + 1 rows\n // this will be guaranteed by iteration, but the array sizes must be known at compile time, so we will use a fixed size of maxArraySize\n var dynamicPassMat: array<array<f32, ${e+1}u>, 2>; // initialize to 0\n \n var prevIndex: u32 = 0;\n var curIndex: u32 = 1; // we will swap these indices per pass\n\n // initialize the first row\n for (var i = 0u; i <= aLength; i = i + 1u) {\n dynamicPassMat[prevIndex][i] = f32(i);\n }\n\n // iterate over the rows\n for (var i = 1u; i <= bLength; i = i + 1u) {\n dynamicPassMat[curIndex][0] = f32(i);\n var minEntry: f32 = f32(maxLength);\n let prevRow = &dynamicPassMat[prevIndex];\n let curRow = &dynamicPassMat[curIndex];\n let bMon = u32(b[i - 1]);\n for (var j = 1u; j <= aLength; j = j + 1u) {\n var cost: f32 = f32(a[j - 1] != bMon);\n var res: f32 = min(\n min(\n (*prevRow)[j] + 1.0, // deletion\n (*curRow)[j - 1] + 1.0, // insertion\n ),\n (*prevRow)[j - 1] + cost // substitution\n );\n (*curRow)[j] = res;\n if (res < minEntry) {\n minEntry = res;\n }\n }\n // swap the indices\n let temp: u32 = prevIndex;\n prevIndex = curIndex;\n curIndex = temp;\n if (minEntry > maxIntDistance) {\n return 1.0;\n }\n }\n\n return dynamicPassMat[prevIndex][aLength] / f32(maxLength);\n `},[J.NEEDLEMAN_WUNSCH]:function(e,t){return`\n let aLength: u32 = computeInfo.entrySizes[${t}][aIndex];\n let bLength: u32 = computeInfo.entrySizes[${t}][bIndex];\n let maxLength: u32 = max(aLength, bLength);\n let minLength: u32 = min(aLength, bLength);\n \n let maxIntDistance = ceil(maxDistance * f32(maxLength));\n // we will store two arrays as matrix and swap the working indices per pass.\n // this way we can reduce memory usage per computation to just O(aLength)\n // the grid will have aLength + 1 columns and bLength + 1 rows\n // this will be guaranteed by iteration, but the array sizes must be known at compile time, so we will use a fixed size of maxArraySize\n var dynamicPassMat: array<array<f32, ${e+1}u>, 2>; // initialize to 0\n \n // we need to keep track of which operation led to the current cell\n // i.e. whether we came from the left, top or diagonal to assign gap open/gap extend penalty\n var verticalGaps: array<u32, ${e+1}u>;\n var horizontalGaps: array<u32, ${e+1}u>;\n\n let gapOpenPenalty: f32 = suppInfo.gapOpenPenalty${t};\n let gapExtensionPenalty: f32 = suppInfo.gapExtensionPenalty${t};\n var prevIndex: u32 = 0;\n var curIndex: u32 = 1; // we will swap these indices per pass\n // initialize the first row\n for (var i = 0u; i <= aLength; i = i + 1u) {\n dynamicPassMat[prevIndex][i] = gapExtensionPenalty + f32(i - 1) * gapExtensionPenalty; // accounting for the fact that left and right gaps are less costly\n dynamicPassMat[curIndex][i] = 0.0;\n }\n dynamicPassMat[0][0] = 0.0;\n\n let simMatrix = &suppInfo.similarityMatrix${t}; // using pointers make things faster\n // iterate over the rows\n for (var i = 1u; i <= bLength; i = i + 1u) {\n let prevRow = &dynamicPassMat[prevIndex];\n let curRow = &dynamicPassMat[curIndex];\n (*curRow)[0] = gapExtensionPenalty + f32(i - 1) * gapExtensionPenalty;\n var minEntry: f32 = f32(maxLength);\n let monB = u32(b[i - 1]);\n for (var j = 1u; j <= aLength; j = j + 1u) {\n let monA = u32(a[j - 1]);\n \n let cost: f32 = (*prevRow)[j - 1] + 1f - (*simMatrix)[monA][monB];\n var top = (*prevRow)[j]; // deletion\n if (verticalGaps[j] > 0 || i == 1 || i == bLength) {\n top = top + gapExtensionPenalty;\n } else {\n top = top + gapOpenPenalty;\n }\n var left = (*curRow)[j - 1]; // insertion\n if (horizontalGaps[j - 1] > 0 || j == 1 || j == aLength) {\n left = left + gapExtensionPenalty;\n } else {\n left = left + gapOpenPenalty;\n }\n var res: f32 = min(\n min(\n top, // deletion\n left, // insertion\n ),\n cost // substitution\n );\n (*curRow)[j] = res;\n if (res < minEntry) {\n minEntry = res;\n }\n // update the horizontal and vertical gaps\n if (res == cost) {\n verticalGaps[j] = 0;\n horizontalGaps[j] = 0;\n } else if (res == left) {\n verticalGaps[j] = 0;\n horizontalGaps[j] = 1;\n } else {\n verticalGaps[j] = 1;\n horizontalGaps[j] = 0;\n }\n }\n // swap the indices\n let temp: u32 = prevIndex;\n prevIndex = curIndex;\n curIndex = temp;\n if (minEntry > maxIntDistance) {\n return 1.0;\n }\n }\n return dynamicPassMat[prevIndex][aLength] / f32(minLength);\n\n `},[J.MONOMER_CHEMICAL_DISTANCE]:function(e,t){return`\n let aLength: u32 = computeInfo.entrySizes[${t}][aIndex];\n let bLength: u32 = computeInfo.entrySizes[${t}][bIndex];\n let maxLength: u32 = max(aLength, bLength);\n let minLength: u32 = min(aLength, bLength);\n let sizeDiff: u32 = maxLength - minLength;\n \n let maxIntDistance = ceil(maxDistance * f32(maxLength)) - f32(sizeDiff);\n\n let simMatrix = &(suppInfo.similarityMatrix${t}); // using pointers make things faster\n var diff: f32 = 0.0;\n for (var i = 0u; i < ${e}; i = i + 1u) {\n diff = diff + 1.0 - (*simMatrix)[u32(a[i])][u32(b[i])];\n if (diff > maxIntDistance) {\n return 1.0;\n }\n }\n diff += f32(sizeDiff);\n return diff / ${e};\n `},[J.SOKAL]:function(e,t){return`\n var onBitsa: u32 = 0u;\n var onBitsb: u32 = 0u;\n for (var i = 0u; i < ${e}u; i = i + 1u) {\n onBitsa = onBitsa + countOneBits(a[i]);\n onBitsb = onBitsb + countOneBits(b[i]);\n }\n let total = onBitsa + onBitsb;\n if (total == 0u) {\n return 1.0;\n }\n var commonBits: u32 = 0u;\n for (var i = 0u; i < ${e}u; i = i + 1u) {\n commonBits = commonBits + countOneBits(a[i] & b[i]);\n }\n return 1.0 - f32(commonBits) / f32(total * 2 - commonBits * 3);\n `},[J.COSINE]:function(e,t){return`\n var onBitsa: u32 = 0u;\n var onBitsb: u32 = 0u;\n for (var i = 0u; i < ${e}u; i = i + 1u) {\n onBitsa = onBitsa + countOneBits(a[i]);\n onBitsb = onBitsb + countOneBits(b[i]);\n }\n let total = onBitsa * onBitsb; // p.s. here total is taken by multiplying\n if (total == 0u) {\n return 1.0;\n }\n var commonBits: u32 = 0u;\n for (var i = 0u; i < ${e}u; i = i + 1u) {\n commonBits = commonBits + countOneBits(a[i] & b[i]);\n }\n return 1.0 - f32(commonBits) / sqrt(f32(total));\n `},[J.ASYMMETRIC]:function(e,t){return`\n var onBitsa: u32 = 0u;\n var onBitsb: u32 = 0u;\n for (var i = 0u; i < ${e}u; i = i + 1u) {\n onBitsa = onBitsa + countOneBits(a[i]);\n onBitsb = onBitsb + countOneBits(b[i]);\n }\n let min = min(onBitsa, onBitsb);\n if (min == 0u) {\n return 1.0;\n }\n var commonBits: u32 = 0u;\n for (var i = 0u; i < ${e}u; i = i + 1u) {\n commonBits = commonBits + countOneBits(a[i] & b[i]);\n }\n return 1.0 - f32(commonBits) / f32(min);\n `},[J.Difference]:function(e,t){return`\n let range = suppInfo.range${t};\n return f32(abs(f32(a[0]) - f32(b[0])) / range);\n `},[J.OneHot]:function(e,t){return`\n let aLength: u32 = computeInfo.entrySizes[${t}][aIndex];\n let bLength: u32 = computeInfo.entrySizes[${t}][bIndex];\n if (aLength != bLength) {\n return 1.0;\n }\n for (var i = 0u; i < aLength; i = i + 1u) {\n if(a[i] != b[i]) {\n return 1.0;\n }\n }\n return 0.0;\n `}},te={[J.HAMMING]:e=>Math.ceil(e/30),[J.EUCLIDEAN]:e=>Math.ceil(e/30),[J.MANHATTAN]:e=>Math.ceil(e/30),[J.TANIMOTO]:e=>Math.ceil(e/30),[J.SOKAL]:e=>Math.ceil(e/30),[J.COSINE]:e=>Math.ceil(e/30),[J.ASYMMETRIC]:e=>Math.ceil(e/30),[J.LEVENSTEIN]:e=>Math.ceil(e*e/60),[J.NEEDLEMAN_WUNSCH]:e=>Math.ceil(e*e/60),[J.MONOMER_CHEMICAL_DISTANCE]:e=>Math.ceil(e/25),[J.Difference]:e=>1,[J.OneHot]:e=>Math.ceil(e/40),[J.VECTOR_COSINE]:e=>Math.ceil(e/30)},ne={STRING:new Set([J.HAMMING,J.LEVENSTEIN,J.NEEDLEMAN_WUNSCH,J.MONOMER_CHEMICAL_DISTANCE,J.OneHot]),UINT32ARRAY:new Set([J.HAMMING,J.EUCLIDEAN,J.MANHATTAN,J.MONOMER_CHEMICAL_DISTANCE,J.LEVENSTEIN,J.NEEDLEMAN_WUNSCH,J.TANIMOTO,J.COSINE,J.VECTOR_COSINE,J.SOKAL,J.ASYMMETRIC,J.OneHot,J.Difference]),INT32ARRAY:new Set([J.EUCLIDEAN,J.MANHATTAN,J.OneHot,J.Difference,J.VECTOR_COSINE]),FLOAT32ARRAY:new Set([J.EUCLIDEAN,J.MANHATTAN,J.Difference,J.VECTOR_COSINE]),NUMBER:new Set([J.EUCLIDEAN,J.MANHATTAN,J.Difference]),BITARRAY:new Set([J.TANIMOTO,J.COSINE,J.SOKAL,J.ASYMMETRIC])};function ie(e,t=.8,n,i,o,r){return function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function s(e){try{l(i.next(e))}catch(e){r(e)}}function a(e){try{l(i.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((i=i.apply(e,t||[])).next())})}(this,void 0,void 0,function*(){const s=yield function(){return M(this,void 0,void 0,function*(){if(!navigator.gpu)return console.error("WebGPU is not supported in this browser"),null;if(!T&&(T=yield navigator.gpu.requestAdapter({powerPreference:"high-performance"}),null==T))return null;let e=!1;if(E&&(E.lost.then(()=>{e=!0}),yield new Promise(e=>setTimeout(e,10))),!E||e){const e=1e9,t=T.limits,n=t.maxBufferSize,i=t.maxStorageBufferBindingSize;try{return E=yield T.requestDevice({requiredLimits:{maxBufferSize:Math.min(n,e),maxStorageBufferBindingSize:Math.min(i,e)}}),E}catch(e){return console.error("Failed to create device with required limits",e),E=yield T.requestDevice(),E}}return E})}();if(!s)return null;const a=Object.values(J);if(n.some(e=>!a.includes(e)))throw new Error("Invalid distance metrics provided: "+n.join(", "));if(!Object.values(z).includes(i))throw new Error("Invalid aggregation function provided: "+i);const l=1-t;if(r.length!==e.length||r.length!==n.length||r.length!==o.length)throw new Error("Options, weigths and distance functions must be provided for each column");if(e.some(t=>t.length!==e[0].length))throw new Error("All entry lists must be the same length");const c=e.length,u=e[0].length,h=e.map((e,t)=>function(e,t=J.HAMMING,n,i={gapOpenPenalty:1,gapExtensionPenalty:.6}){var o,r;let s=null;const a=e.some(e=>"string"==typeof e)?(s="STRING",e.map(e=>new Uint32Array(e.split("").map(e=>e.charCodeAt(0))))):e.some(e=>"number"==typeof e)?(s="NUMBER",e.map(e=>new Float32Array([e]))):"object"==typeof e[0]&&e.some(e=>"_data"in e&&"_length"in e)?(s="BITARRAY",e.map(e=>e._data)):e.some(e=>e instanceof Float32Array)?(s="FLOAT32ARRAY",e):e.some(e=>e instanceof Uint32Array)?(s="UINT32ARRAY",e):e.some(e=>e instanceof Int32Array)?(s="INT32ARRAY",e):void 0;if(!a||!s)throw new Error("Invalid entry type, could not determine entry type from input list");const l=a[0]instanceof Int32Array?"INT32ARRAY":a[0]instanceof Float32Array?"FLOAT32ARRAY":"UINT32ARRAY",c=new Uint32Array(a.map(e=>e.length));if(!ne[s]||!ne[s].has(t))throw new Error(`Distance metric '${t}' not supported for entry type '${s}'`);const u=c.reduce((e,t)=>Math.max(e,t),0),h=te[t](u),d="INT32ARRAY"===l?Int32Array:"FLOAT32ARRAY"===l?Float32Array:Uint32Array,p=new d(a.length*u);a.forEach((e,t)=>{p.set(e,t*u)});let m="",f=0,g="FLOAT32ARRAY",y=null;if(t===J.NEEDLEMAN_WUNSCH||t===J.MONOMER_CHEMICAL_DISTANCE){let e=i.scoringMatrix&&i.alphabetIndexes?Object.keys(i.alphabetIndexes).reduce((e,t)=>Math.max(e,t.charCodeAt(0)),0):-1;if(!i.alphabetIndexes||!i.scoringMatrix){for(let t=0;t<p.length;t++)p[t]>e&&(e=p[t]);i.scoringMatrix=new Array(e+1).fill(null).map(()=>new Array(e+1).fill(0)),i.alphabetIndexes={};for(let e=0;e<i.scoringMatrix.length;e++)i.scoringMatrix[e][e]=1,i.alphabetIndexes[String.fromCharCode(e)]=e}const t=(e+1)*(e+1),s=new Array(e+1).fill(null).map(()=>new Float32Array(e+1));for(let t=0;t<e+1;t++)s[t][t]=1;const a=i.alphabetIndexes;for(const e of Object.keys(a))for(const t of Object.keys(a))e!==t&&(s[e.charCodeAt(0)][t.charCodeAt(0)]=i.scoringMatrix[a[e]][a[t]]);f=2+t,g="FLOAT32ARRAY",y=new Float32Array(f),y[0]=null!==(o=i.gapOpenPenalty)&&void 0!==o?o:1,y[1]=null!==(r=i.gapExtensionPenalty)&&void 0!==r?r:.6;let l=2;for(let e=0;e<s.length;e++)y.set(s[e],l),l+=s[e].length;m=`\n gapOpenPenalty${n}: f32,\n gapExtensionPenalty${n}: f32,\n similarityMatrix${n}: array<array<f32, ${e+1}>, ${e+1}>`}else if(t===J.Difference){if(!i.range||"number"!=typeof i.range||i.range<=0){const e=p.reduce((e,t)=>Math.min(e,t),p[0]),t=p.reduce((e,t)=>Math.max(e,t),p[0]);i.range=t-e}i.range<=0&&(i.range=1),f=1,g="FLOAT32ARRAY",y=new Float32Array([i.range]),m=`\n range${n}: f32`}const b=p instanceof Int32Array?"i32":p instanceof Float32Array?"f32":"u32",v=`data${n}: array<array<${b}, ${u}>, ${a.length}>`;return{flatSourceArray:p,sourceArraySize:p.length,maxEntryLen:u,arraySizes:c,complexity:h,suppInfoBuffer:y,suppInfoSize:f,suppInfoType:g,suppInfoStructWgsl:m,entryType:s,dataTypeWGSL:b,dataStructWgsl:v,EncodedArrayConstructor:d}}(e,n[t],t,r[t]));if(0===c)throw new Error("No columns provided. Please provide at least one column of data.");1===c&&(i=z.MANHATTAN);let d=h.map(e=>e.suppInfoStructWgsl).filter(e=>!!e&&""!=e).join(",\n"),p=!1;d&&""!=d.trim()||(p=!0,d="\ndummy: f32\n");const m=h.map(e=>e.dataStructWgsl).filter(e=>!!e&&""!=e).join(",\n"),f=new Uint32Array(c*u);h.forEach((e,t)=>{f.set(e.arraySizes,t*u)});const g=1e4,y=100,b=h.reduce((e,t)=>e+t.complexity,0),v=Math.ceil(6e3/b),w=Math.ceil(Math.sqrt(Math.ceil(100))),C=10*w,S=u*(u-1)/2,A=Math.ceil(S/g),x=s.createShaderModule({label:"Sparse matrix compute shader",code:`\n // each thread will perform 100 iterations at one time, comparing 100 pairs of entries.\n // in total, each thread will perform at most ${A} comparisons.\n // first is the result struct, containing is, js, and distances. each array with length of 100,\n // and also integer for how many pairs were found to be below threshold.\n struct SparseResult {\n i: array<array<u32, 100>, 10000>,\n j: array<array<u32, 100>, 10000>,\n distances: array<array<f32, 100>, 10000>,\n found: array<u32, 10000>,\n done: array<u32, 10000>\n }\n // struct for the data\n struct ComputeInfo {\n // start at cols and rows, and end at cols and rows for each thread, these will be calculated on cpu and passed to gpu.\n startAtCols: array<u32, 10000>,\n startAtRows: array<u32, 10000>,\n endAtCols: array<u32, 10000>,\n endAtRows: array<u32, 10000>,\n\n // the ACTUALLY sizes of each entry\n entrySizes: array<array<u32, ${u}>, ${c}>,\n // the weights for each entry\n weights: array<f32, ${c}>,\n // the data for each entry\n ${m} // an example of the dataWgsl would be:\n //data0: array<array<u32,20>,100>,\n //data1: array<array<u32,20>,100>\n }\n\n // struct for the supplementary information\n struct SuppInfo {\n // struct containing all the supplementary info, like scoring matrix, alphabet indexes, range, etc.\n ${d}\n };\n\n @group(0) @binding(0) var<storage, read_write> computeInfo: ComputeInfo;\n @group(0) @binding(1) var<storage, read_write> suppInfo: SuppInfo;\n @group(0) @binding(2) var<storage, read_write> results: SparseResult;\n @compute @workgroup_size(10, 10) fn calcSparseMatrix(\n @builtin(global_invocation_id) id: vec3<u32>\n ) {\n ${p?"let otherDummy = suppInfo.dummy * 2;":""} // just to make sure that the suppInfo is not optimized out\n let threadCol = id.x;\n let threadRow = id.y;\n let linearIndex = threadRow * ${C} + threadCol;\n if (linearIndex >= 10000) {\n return; // if we are out of bounds, return\n } \n var startAtCol: u32 = computeInfo.startAtCols[linearIndex];\n var startAtRow: u32 = computeInfo.startAtRows[linearIndex];\n let endAtCol: u32 = min(computeInfo.endAtCols[linearIndex], ${u}u);\n let endAtRow: u32 = min(computeInfo.endAtRows[linearIndex], ${u}u);\n let is = &results.i[linearIndex];\n let js = &results.j[linearIndex];\n let distances = &results.distances[linearIndex];\n results.found[linearIndex] = 0; // initialize the found counter\n var found: u32 = 0;\n if (results.done[linearIndex] > 0) {\n return; // if we are done, return\n }\n for (var i = 0; i < ${v}; i++) {\n if (startAtCol >= endAtCol && startAtRow >= endAtRow) {\n results.done[linearIndex] = 1;\n break;\n }\n if (found >= 100) {\n break;\n }\n let dist = combinedDistance(startAtCol, startAtRow);\n if (dist <= ${l}) {\n (*is)[found] = startAtCol;\n (*js)[found] = startAtRow;\n (*distances)[found] = dist;\n found = found + 1;\n }\n startAtCol = startAtCol + 1;\n if (startAtCol >= ${u}u) {\n startAtRow += 1;\n startAtCol = startAtRow + 1;\n }\n }\n results.found[linearIndex] = found;\n // update the startAtCols and startAtRows\n computeInfo.startAtCols[linearIndex] = startAtCol;\n computeInfo.startAtRows[linearIndex] = startAtRow;\n\n }\n\n // this will generate the distance script for each distance metric and then combine them into one\n ${oe(n,h.map(e=>e.maxEntryLen),l,i)}\n\n\n `}),_=s.createComputePipeline({label:"sparse matrix compute pipeline",layout:"auto",compute:{module:x,entryPoint:"calcSparseMatrix"}}),I=new Uint32Array(g),L=new Uint32Array(g),N=new Uint32Array(g),P=new Uint32Array(g),R=Math.floor(S/g);let $=0,O=1;console.time("GPUthreadStarts");for(let e=0;e<g;e++){const t=9999===e?S-1:(e+1)*R,n=u-2-Math.floor(Math.sqrt(-8*t+4*u*(u-1)-7)/2-.5),i=t-u*n+Math.floor((n+1)*(n+2)/2);I[e]=O,L[e]=$,N[e]=i,P[e]=n,$=n,O=i}console.timeEnd("GPUthreadStarts");const k=4e4+u*c+c+h.reduce((e,t)=>e+t.sourceArraySize,0),H=h.reduce((e,t)=>e+t.suppInfoSize,0),B=1e6,F=k*Uint32Array.BYTES_PER_ELEMENT;let G=F;const D=15&F;0!==D&&(G+=16-D);const V=s.createBuffer({label:"compute info buffer",size:G,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST,mappedAtCreation:!0}),W=V.getMappedRange();let j=0;new Uint32Array(W,j,g).set(I),j+=g*Uint32Array.BYTES_PER_ELEMENT,new Uint32Array(W,j,g).set(L),j+=g*Uint32Array.BYTES_PER_ELEMENT,new Uint32Array(W,j,g).set(N),j+=g*Uint32Array.BYTES_PER_ELEMENT,new Uint32Array(W,j,g).set(P),j+=g*Uint32Array.BYTES_PER_ELEMENT,new Uint32Array(W,j,f.length).set(f),j+=f.length*Uint32Array.BYTES_PER_ELEMENT,new Float32Array(W,j,c).set(o),j+=c*Float32Array.BYTES_PER_ELEMENT;for(const e of h){const t=e.EncodedArrayConstructor,n=e.sourceArraySize;new t(W,j,n).set(e.flatSourceArray),j+=n*t.BYTES_PER_ELEMENT}V.unmap();const U=H*Uint32Array.BYTES_PER_ELEMENT;let q=U;const Y=15&U;0!==Y&&(q+=16-Y),q=Math.max(q,16);const K=s.createBuffer({label:"supp info buffer",size:q,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST,mappedAtCreation:!0}),Z=K.getMappedRange();let X=0;for(const e of h)e.suppInfoBuffer&&e.suppInfoBuffer.byteLength>0&&e.suppInfoSize>0&&(new("UINT32ARRAY"===e.suppInfoType?Uint32Array:Float32Array)(Z,X,e.suppInfoBuffer.length).set(e.suppInfoBuffer),X+=e.suppInfoBuffer.byteLength);0===X&&new Uint32Array(Z,0,4).set([1,1,1,1]),K.unmap();const Q=302e4*Uint32Array.BYTES_PER_ELEMENT;let ee=Q;const ie=15&Q;0!==ie&&(ee+=16-ie);const re=s.createBuffer({label:"results buffer",size:ee,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_SRC}),se=s.createBindGroup({label:"bindGroup for sparse matrix buffer",layout:_.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:V}},{binding:1,resource:{buffer:K}},{binding:2,resource:{buffer:re}}]}),ae=s.createBuffer({label:"results out buffer",size:re.size,usage:GPUBufferUsage.MAP_READ|GPUBufferUsage.COPY_DST}),le=[],ce=[],ue=[];let he=!1;for(;!he;){const e=s.createCommandEncoder({label:"distance encoder"}),t=e.beginComputePass({label:"distance compute pass"});t.setPipeline(_),t.setBindGroup(0,se),t.dispatchWorkgroups(w,w),t.end(),e.copyBufferToBuffer(re,0,ae,0,ae.size);const n=e.finish();s.queue.submit([n]),yield s.queue.onSubmittedWorkDone(),yield ae.mapAsync(GPUMapMode.READ);const i=ae.getMappedRange();let o=0;const r=new Uint32Array(i,o,B);o+=B*Uint32Array.BYTES_PER_ELEMENT;const a=new Uint32Array(i,o,B);o+=B*Uint32Array.BYTES_PER_ELEMENT;const l=new Float32Array(i,o,B);o+=B*Float32Array.BYTES_PER_ELEMENT;const c=new Uint32Array(i,o,g);o+=g*Uint32Array.BYTES_PER_ELEMENT,he=new Uint32Array(i,o,g).every(e=>1===e);const u=c.reduce((e,t)=>e+t,0),h=new Uint32Array(u),d=new Uint32Array(u),p=new Float32Array(u);let m=0;for(let e=0;e<c.length;e++){const t=c[e];0!==t&&(h.set(r.subarray(e*y,e*y+t),m),d.set(a.subarray(e*y,e*y+t),m),p.set(l.subarray(e*y,e*y+t),m),m+=t)}le.push(h),ce.push(d),ue.push(p),ae.unmap()}const de=le.reduce((e,t)=>e+t.length,0),pe=new Uint32Array(de),me=new Uint32Array(de),fe=new Float32Array(de);let ge=0;for(let e=0;e<le.length;e++)pe.set(le[e],ge),me.set(ce[e],ge),fe.set(ue[e],ge),ge+=le[e].length;return V.destroy(),K.destroy(),re.destroy(),ae.destroy(),{i:pe,j:me,distance:fe}})}function oe(e,t,n,i){return e.map((e,i)=>`\n fn distanceScript${i}(aIndex: u32, bIndex: u32) -> f32 {\n let a = computeInfo.data${i}[aIndex];\n let b = computeInfo.data${i}[bIndex];\n let maxDistance: f32 = ${n};\n ${ee[e](t[i],i)}\n }\n `).join("\n")+"\n"+`\n fn combinedDistance(aIndex: u32, bIndex: u32) -> f32 {\n var distances: array<f32, ${e.length}>;\n ${e.map((e,t)=>`distances[${t}] = distanceScript${t}(aIndex, bIndex);`).join("\n")}\n ${X[i](e.length)}\n }\n \n `}let re=0;const se="cliffsDf",ae=new u.Subject,le="SALI",ce="line index",ue=["From","To"],he="filterCliffs";async function de(e,t,i,o,l,c,u,h,d,p,m,f,g,y,b,v,w){re++;const C=c/100;let S,A=!1;const x=f.inputs,M=await f.apply({[x[0].name]:t,[x[1].name]:u,...d.preprocessingFuncArgs??{}});let T=[];if(h===N){const t=await function(e,t,i,o,r,s,a=10,l=!1,c=2){const u=new Worker(new URL(n.p+n.u(980),n.b));let h;return u.postMessage({data:e,threshold:t,weights:i,aggregationMethod:o,distanceFns:r,distanceFnArgs:s,maxIterations:a,useWebGPU:l,inflate:c}),{promise:new Promise((e,t)=>{h=e,u.onmessage=t=>{setTimeout(()=>u.terminate(),100),e(t.data.res)},u.onerror=e=>{setTimeout(()=>u.terminate(),100),t(e)}}),terminate:()=>{try{h(null),u.terminate()}catch(e){console.error(e)}}}}([M.entries],c,[1],"MANHATTAN",[u],[M.options??{}],d?.maxIterations??5,d.useWebGPU??!1).promise;e.columns.addNewInt(e.columns.getUnusedName("MCL Cluster")).init(e=>t.clusters[e]),T=[t.embedX,t.embedY]}else T=await Z([M.entries],h,[u],[1],"MANHATTAN",{...d,distanceFnArgs:[M.options??{}]});if(T.length!==i.length)throw new Error("Number of axes names should be equal to number of embedding dimensions");for(let t=0;t<T.length;++t)e.columns.addNewFloat(i[t]).init(e=>T[t][e]);let E=null;if(d.useWebGPU)try{E=await ie([M.entries],C,[u],z.MANHATTAN,[1],[M.options??{}])}catch(e){console.error(e)}E||(d.useWebGPU&&console.error("WebGPU sparse matrix calculation failed, falling back to CPU implementation"),E=await(new D).calc(M.entries,u,C,M.options));const _=await async function(e,t){const n=e.distance.map((n,i)=>{const o=Math.abs(t.get(e.i[i])-t.get(e.j[i]));return 0!=n?o/n:1/0}),i=e.distance.map(e=>1-e),o=e.i,r=e.j,s=a.BitSet.create(t.length);return e.distance.forEach((t,n)=>{s.set(e.i[n],!0),s.set(e.j[n],!0)}),{simVals:i,saliVals:n,n1:o,n2:r,cliffsBitSet:s}}(E,l),I=function(e,t,n,i,o,r,s){const l=new Array(e).fill(0);for(let e=0;e!=i.length;++e)n[e]!=1/0&&(s.get(i[e])>s.get(o[e])?l[i[e]]+=n[e]:l[o[e]]+=n[e]);return a.Column.fromList("double",t,l)}(t.length,`sali_${i[0].substring(i[0].lastIndexOf("_"))}`,_.saliVals,_.n1,_.n2,0,l);e.columns.add(I);const L=_.cliffsBitSet,P=function(e){const t=e.filter(e=>e!==1/0),n=t.reduce((e,t)=>Math.min(e,t),Number.MAX_VALUE);return{max:t.reduce((e,t)=>Math.max(e,t),n),min:n}}(_.saliVals),$=.8/(P.max-P.min),O=r.shell.tv?.dataFrame===e?r.shell.tv:r.shell.getTableView(e.name),H=O.addViewer(a.VIEWER.SCATTER_PLOT,{xColumnName:i[0],yColumnName:i[1],size:I.name,color:l.name,showXSelector:!1,showYSelector:!1,showSizeSelector:!1,showColorSelector:!1,markerMinSize:5,markerMaxSize:25,title:o}),B=function(e,t,n,i,o,r,s,l){const c={from:new Uint32Array(t.n1.length),to:new Uint32Array(t.n1.length),opacities:new Float32Array(t.n1.length),colors:new Array(t.n1.length),widths:new Float32Array(t.n1.length)};for(let n=0;n<t.n1.length;n++)c.from[n]=t.n1[n],c.to[n]=t.n2[n],c.opacities[n]=t.saliVals[n]===1/0?1:.2+(t.saliVals[n]-s.min)*l,c.colors[n]=e.selection.get(c.from[n])&&e.selection.get(c.to[n])?"255,255,0":"0,128,0",c.widths[n]=1;const u=a.DataFrame.create(c.from.length);return ue.forEach((e,t)=>{u.columns.addNewString(e).init(e=>n.get(0===t?c.from[e]:c.to[e])),function(e,t){Object.keys(t).forEach(n=>{e.tags[n]=t[n]})}(u.col(e),r),u.col(e).semType=o}),u.columns.addNewFloat("Δ activity").init(e=>Math.abs(i.get(c.from[e])-i.get(c.to[e]))),u.columns.addNewInt(ce).init(e=>e),u.columns.addNewFloat(le).init(e=>t.saliVals[e]),u.columns.addNewFloat("Similarity").init(e=>t.simVals[e]),u.name=`${se}${re}`,{lines:c,linesDf:u}}(e,_,t,l,p,m,P,$);B.lines.skipMultiLineCalculation=!0,B.linesDf.col(le).setTag("description","Structure−Activity Landscape Index (activity difference divided by 1 minus similarity)");const F=new U(H,i[0],i[1],B.lines,V.none),G=b?b(B.linesDf,ue).sort([le],[!1]):B.linesDf.plot.grid().sort([le],[!1]);G.col(ce)&&(G.col(ce).visible=!1),e.temp[".cliffsDfGrid"]=G;const W=s.button(`${B.linesDf.rowCount} cliffs`,()=>{const e=R()(O.viewers).some(e=>e.dataFrame.name===`${se}${re}`);w&&!e&&O.addViewer(G),O.dockManager.dock(G,"down",null,"Activity cliffs",v??.2)});W.classList.add("scatter_plot_link","cliffs_grid");const j=s.input.toggle("Show only cliffs",{value:!1,onValueChanged:t=>{t?(H.dataFrame.setTag(he,i[0]),e.filter.and(L),ae.next(i[0])):(H.dataFrame.setTag(he,""),e.filter.setAll(!0),ae.next(""))}});H.root.prepend(s.divH([W,j.root],"cliffs_div")),ae.subscribe(e=>{j.enabled=""===e||e===i[0]}),e.onRowsFiltering.subscribe(()=>{j.value&&e.filter.and(_.cliffsBitSet)});const q=r.events.onViewerClosed.subscribe(e=>{e.args.viewer===H&&(O.dockManager.close(G.root),q.unsubscribe(),O.subs=O.subs.filter(e=>e!==q))});return O.subs.push(q),B.linesDf.onCurrentCellChanged.subscribe(()=>{for(let e=0;e<B.linesDf.rowCount;e++)B.lines.widths[e]=e===B.linesDf.currentRowIdx?3:1;F.linesToRender=B.lines;const n=B.linesDf.currentCol&&B.linesDf.currentCol.name===ue[1]?B.lines.to:B.lines.from,o=-1!==B.linesDf.currentRowIdx?B.linesDf.currentRowIdx:null;if(H.dataFrame.currentRowIdx=o?n[o]:-1,null!==o){const n=B.linesDf.currentRowIdx;F.currentLineId=n;const{zoomLeft:a,zoomRight:c,zoomTop:u,zoomBottom:h}=function(e,t,n,i,o,r){const s=Math.abs(n-o),a=Math.abs(i-r),l=e/s,c=t/a,u=Math.min(l,c),h=e/u*5,d=t/u*5,p=(n<o?n:o)+s/2-h/2,m=(i>r?i:r)-a/2+d/2;return{zoomLeft:p,zoomRight:p+h,zoomTop:m,zoomBottom:m-d}}(H.viewport.width,H.viewport.height,H.dataFrame.get(i[0],B.lines.from[n]),H.dataFrame.get(i[1],B.lines.from[n]),H.dataFrame.get(i[0],B.lines.to[n]),H.dataFrame.get(i[1],B.lines.to[n]));H.zoom(a,u,c,h),j.value?e.filter.and(L):!0===j.enabled&&e.filter.setAll(!0),setTimeout(()=>{!function(e,t,n,i,o,a,l,c,u){const h=t.getPane("Cliff Details");s.empty(h.root);const d=u({points:[n,i],lineId:o,df:e,seqCol:a,activityCol:l,sali:c});h.root.append(d),setTimeout(()=>{r.shell.o=t.root},500)}(e,S,B.lines.from[o],B.lines.to[o],o,t,l,B.linesDf.get(le,o),y);const n=H.dataFrame.getSortedOrder(O.grid.sortByColumns,O.grid.sortTypes);O.grid.scrollToCell(t.name,n.indexOf(H.dataFrame.currentRowIdx))},1e3)}}),B.linesDf.onSelectionChanged.subscribe(t=>{setTimeout(()=>(()=>{const t=a.BitSet.create(e.rowCount);for(let e=0;e<B.linesDf.rowCount;e++){const n=B.linesDf.selection.get(e);n&&(t.set(B.lines.from[e],!0),t.set(B.lines.to[e],!0)),B.lines.colors[e]=n?"255,255,0":"0,128,0"}e.selection.copyFrom(t),F.linesToRender=B.lines})(),100)}),e.onSelectionChanged.subscribe(t=>{!1===e.selection.anyTrue&&"number"==typeof t&&(A?A=!1:(e=>{e.selection.setAll(!1);for(let e=0;e<B.lines.colors.length;e++)B.lines.colors[e]="0,128,0";F.linesToRender=B.lines})(G.dataFrame))}),F.lineClicked.subscribe(t=>{if(A=!0,F.currentLineId=t.id,-1!==t.id){const n=B.linesDf.selection.clone();setTimeout(()=>{t.event.ctrlKey?(n.set(t.id,!n.get(t.id)),B.linesDf.selection.copyFrom(n)):(B.linesDf.currentRowIdx!==t.id&&(B.linesDf.currentRowIdx=t.id,e.currentRowIdx=B.lines.from[t.id]),B.linesDf.selection.copyFrom(n));const i=B.linesDf.getSortedOrder(G.sortByColumns,G.sortTypes);G.scrollToCell(ue[0],i.indexOf(t.id))},500)}}),F.lineHover.pipe((0,k.debounceTime)(500)).subscribe(n=>{-1!==n.id&&-1===e.mouseOverRowIdx&&s.tooltip.show(g({lineId:n.id,points:[B.lines.from[n.id],B.lines.to[n.id]],df:e,seqCol:t,activityCol:l}),n.x,n.y)}),H.addProperty("similarityLimit","double",C),S=function(){const e=s.accordion(),t=s.element("i");return t.className="grok-icon svg-icon svg-view-layout",e.addTitle(s.span([t,s.label("Activity cliffs")])),e.addPane("Cliff Details",()=>s.divText("Cliff has not been selected"),!0),r.shell.o=e.root,e}(),H}var pe=n(6863),me=n(2003),fe=n(3516),ge=n(3151);function ye(e,t){const n=e=>o[e]??null,i=e=>{const t=s.columns.addNewString((e+1).toString());return o.push(t),t},o=[],r=e.length,s=a.DataFrame.create(r),l=t.getSeqHandler(e);for(let e=0;e<r;++e){const t=l.getSplitted(e);for(let o=0;o<t.length;++o){const r=t.getCanonical(o);(n(o)||i(o)).set(e,r,!1)}}return s}var be,ve=n(439),we=n(4971);async function Ce(e){const t=(await(0,we.pj)()).getMonomerLib(),n=[],i={},o=e.map(e=>t.getMonomer("PEPTIDE",e)?.smiles??""),s=a.Column.fromStrings("smiles",o);for(let t=0;t<o.length;++t){i[e[t]]=t;const a=o[t],l=""===a?new Array(o.length).fill(0):(await r.chem.getSimilarities(s,a)).getRawData();l[t]=1,n[t]=Array.from(l)}return{scoringMatrix:n,alphabetIndexes:i}}!function(e){e.IDENTITY="identity",e.SIMILARITY="similarity"}(be||(be={}));var Se=n(9192);class Ae{constructor(){this.maxIterations={uiName:"Max iterations",value:0,tooltip:"Maximum iterations for MCL process.Default is \n 0 which will construct the clusters with plain sparse matrix. Values greater than 0 will \n perform MCL with the given number of iterations and will result in trans-cluster activity cliff lines."},this.useWebGPU={uiName:"Use WebGPU",value:!1,tooltip:"Use WebGPU for MCL calculation. (Experimental)",type:"boolean"}}}class xe extends O{constructor(e={}){super({...e,enableMCL:!0});const t=Array.from(this.tableInput.value.columns.numericalNoDateTime);this.activitiesInput=s.input.column("Activities",{table:this.tableInput.value,value:t.length?t[0]:null,filter:e=>t.includes(e)}),this.activitiesInputRoot=this.activitiesInput.root,this.similarityInput=s.input.int("Similarity cutoff",{value:80}),this.methodsParams[N]=new Ae}onTableInputChanged(){if(super.onTableInputChanged(),this.activitiesInputRoot){s.empty(this.activitiesInputRoot);const e=Array.from(this.tableInput.value.columns.numerical);this.activitiesInput=s.input.column("Activities",{table:this.tableInput.value,value:e.length?e[0]:null,filter:t=>e.includes(t)}),Array.from(this.activitiesInput.root.children).forEach(e=>this.activitiesInputRoot.append(e))}}getEditor(){return s.div([this.tableInput,this.colInputRoot,this.preprocessingFunctionInputRoot,this.preprocessingFuncSettingsDiv,this.activitiesInputRoot,this.similarityMetricInputRoot,this.methodInput,this.methodSettingsDiv,this.similarityMetricInputRoot,this.similarityInput],{style:{minWidth:"320px"},classes:"ui-form dim-reduction-dialog-form"})}getParams(){return{...super.getParams(),activities:this.activitiesInput.value,similarityThreshold:this.similarityInput.value}}getInput(){return{...super.getInput(),activityCol:this.activitiesInput.value.name,simThreshold:this.similarityInput.value}}async applyInput(e){super.applyInput(e),this.activitiesInput.value=this.tableInput.value.col(e.activityCol),this.similarityInput.value=e.simThreshold}}var Me,Te,Ee;function _e(e){const t=["Embed_X","Embed_Y"],n=e.columns.names().filter(e=>e.includes(t[0])).length+1;return t.map(e=>`${e}_${n}`)}function Ie(e,t){return`${t} (${e.length>4?`${e.length} columns`:e.map(e=>e.name).join(", ")})`}async function Le(e,t,i,o,c,u,h,d=!0,p=!1,m={preprocessingFuncArgs:[]},f={},g=null,y={},b){const v={showXAxis:!1,showYAxis:!1,showXSelector:!1,showYSelector:!1};if(t.length!==o.length||t.length!==u.length||t.length!==c.length||t.length!==m.preprocessingFuncArgs.length)throw new Error("columns, metrics and preprocessing functions, weights and function argumentsmust have the same length");const w=d?f.tableView??r.shell.tableView(e.name)??r.shell.addTableView(e):null,C=async()=>{const C=a.TaskBarProgressIndicator.create(`Initializing ${f.scatterPlotName??"dimensionality reduction"} ...`);let S;try{const A=_e(e);function x(n,o,r){let c=null,u=null;e.columns.names().includes(A[0])?(c=e.columns.byName(A[0]),u=e.columns.byName(A[1])):(c=e.columns.add(a.Column.float(A[0],e.rowCount)),u=e.columns.add(a.Column.float(A[1],e.rowCount)),d&&!S&&(S=w.scatterPlot({...v,x:A[0],y:A[1],title:f.scatterPlotName??Ie(t,i)}))),f[l.YP]&&(S?.root&&s.setUpdateIndicator(S.root,!1),c.init(e=>r[0]?r[0][e]:void 0),u.init(e=>r[1]?r[1][e]:void 0));const h=n/o*100;C.update(h,`Running ${f.scatterPlotName??"dimensionality reduction"}... ${h.toFixed(0)}%`)}async function M(){e.columns.add(a.Column.float(A[0],e.rowCount)),e.columns.add(a.Column.float(A[1],e.rowCount));let n=null;d&&(S=w.scatterPlot({...v,x:A[0],y:A[1],title:f.scatterPlotName??Ie(t,i)}),s.setUpdateIndicator(S.root,!0));const p=r.events.onViewerClosed.subscribe(e=>{const t=e.args.viewer;t?.getOptions()?.look?.title&&S?.getOptions()?.look?.title&&t?.getOptions()?.look?.title===S?.getOptions()?.look?.title&&(r.events.fireCustomEvent(q,{}),p.unsubscribe(),n?.(),C.close())}),g=new Promise(async(r,s)=>{try{n=r;const s=[];let a=o,d=c,p=h;if(b&&t.every(e=>e.isNumerical)){const n=t.map(e=>e.toList()),i=new Array(e.rowCount).fill(0).map((e,n)=>new Float32Array(t.length));for(let o=0;o<t.length;++o)for(let t=0;t<e.rowCount;++t)i[t][o]=n[o][t];m.distanceFnArgs=[{}],s.push({entries:i,options:{}}),a=[b],d=[1],p="MANHATTAN"}else for(let e=0;e<u.length;++e){const n=u[e];if(m.distanceFnArgs||(m.distanceFnArgs=[]),n){const i=n.inputs[0].name,r=n.inputs[1].name,{entries:a,options:l}=await n.apply({[i]:t[e],[r]:o[e],...m.preprocessingFuncArgs[e]??{}});s.push({entries:a,options:l}),m.distanceFnArgs.push(l)}else{const n=t[e].toList(),i={};s.push({entries:n,options:i}),m.distanceFnArgs.push(i)}}r(await Z(s.map(e=>e.entries),i,a,d,h,m,f[l.vb]?void 0:x))}catch(e){s(e)}}),y=await g;return C.close(),p.unsubscribe(),y}const T=await M();if(p&&T){const E=a.TaskBarProgressIndicator.create("Clustering embeddings ...");try{const _=await function(e,t,i,o){return function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function s(e){try{l(i.next(e))}catch(e){r(e)}}function a(e){try{l(i.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((i=i.apply(e,t||[])).next())})}(this,void 0,void 0,function*(){return new Promise(function(r,s){const a=new Worker(new URL(n.p+n.u(682),n.b));a.postMessage({embedX:e,embedY:t,minPts:o,epsilon:i}),a.onmessage=({data:{error:e,clusters:t}})=>{a.terminate(),e?s(e):r(t)}})})}(T[0],T[1],m.dbScanEpsilon??.01,m.dbScanMinPts??4),I=e.columns.getUnusedName("Cluster (DBSCAN)");e.columns.addNewString(I).init(e=>_[e].toString()),S&&(S.props.colorColumnName=I)}catch(L){r.shell.error("Clustering embeddings failed"),console.error(L)}finally{E.close()}}if(T){const N=e.columns.byName(A[0]),P=e.columns.byName(A[1]);if(N.init(e=>T[0][e]),P.init(e=>T[1][e]),g)try{const R=g.inputs[0].name,$=g.inputs[1].name;await g.prepare({[R]:N,[$]:P,...y}).call(!0)}catch(O){r.shell.error("Post-processing failed"),console.error(O)}if(S)return s.setUpdateIndicator(S.root,!1),S.helpUrl="/help/compute/sequence-space",S}}catch(k){r.shell.error("Dimensionality reduction failed"),console.error(k),C.close(),S&&s.setUpdateIndicator(S.root,!1)}};return new Promise(async(t,n)=>{try{if(f.fastRowCount&&e.rowCount>f.fastRowCount&&!f[l.vb])s.dialog().add(s.divText("Analysis might take several minutes. Do you want to continue?")).onOK(async()=>{try{const e=await C();t(e)}catch(e){n(e)}}).onCancel(()=>t(void 0)).show();else{const e=await C();t(e)}}catch(e){n(e)}})}n(5540),function(e){e.ADD="ADD",e.SUB="SUB",e.MULT="MULT"}(Me||(Me={})),function(e){e.SQUARE="SQUARE",e.INVERSE="INVERSE",e.TRANSPOSE="TRANSPOSE",e.NORM="NORM",e.COLUMN_NORM="COLUMN_NORM"}(Te||(Te={})),function(e){e.SCALARMULT="SCALARMULT",e.SCALARADD="SCALARADD",e.SCALARPOW="SCALARPOW"}(Ee||(Ee={})),Object.prototype.toString;var Ne=n(6873),Pe=n(4356),Re=n(6717),$e=n(4025),Oe=n(4870),ke=n(3856),He=n(6882),Be=n(7278),Fe=n(5553),Ge=n(6642),De=n(3599),Ve=n(673),We=n(8312);class je extends Ge.sD{monomerLib=null;seqHelper=null;constructor(e,t){super(e,t,qr.logger),(0,we.pj)().then(e=>{this.monomerLib=e.getMonomerLib(),this.dirty=!0,this.gridCol?.grid?.invalidate(),this.subs.push(this.monomerLib.onChanged.subscribe(()=>{this.dirty=!0,this.gridCol?.grid?.invalidate()}))}),(0,We.Q)().then(e=>{this.seqHelper=e,this.dirty=!0,this.gridCol?.grid?.invalidate()})}}var Ue=n(4139);const qe=me.zS;function ze(e){const t=!R().enumerate(e).some(([t,n])=>t.length>1&&0!=n&&n!=e.length-1),n=[],i=t?"":" ";for(const[t,o]of R().enumerate(e)){let r=t;o<e.length&&(r+=`${t?"":"-"}${i}`),n.push(r)}return[n,t]}class Ye extends a.GridCellRenderer{seqHelper;get name(){return"sequence"}get cellType(){return"sequence"}get defaultHeight(){return 30}get defaultWidth(){return 230}hasMouseOver=!1;constructor(){super(),this.seqHelper=qr.seqHelper}getRendererBack(e){const[t,n,i]=(0,Ge.BG)(e);if(i.rendererBack)return i.rendererBack;let o=null;return this.seqHelper&&(o=this.seqHelper.getSeqHandler(n).getRendererBack(t,n)),o}onClick(e,t){e.cell.column.temp["current-word"]=e.cell.value,e.grid.invalidate();const n=this.getRendererBack(e);n?.onClick(e,t)}onMouseEnter(e,t){const n=this.getRendererBack(e);n?.onMouseEnter(e,t),this.hasMouseOver=!0}onMouseMove(e,t){const n=this.getRendererBack(e);n?.onMouseMove(e,t)}onMouseLeave(e,t){if((0,Fe.WN)(e,null),e?.grid){const t=e.grid.onEvent("d4-grid-show-tooltip").subscribe(e=>{t.unsubscribe(),this.hasMouseOver&&e.preventDefault()})}this.hasMouseOver=!1}onDoubleClick(e,t){const n=this.getRendererBack(e);n?.onDoubleClick(e,t)}onKeyDown(e,t){const n=this.getRendererBack(e);n?.onKeyDown(e,t)}onKeyPress(e,t){const n=this.getRendererBack(e);n?.onKeyPress(e,t)}renderInt(e,t,n,i,o,r,s){const[a,l,c]=(0,Ge.BG)(r);if(!l)return;const u=l.temp,h=this.seqHelper.getSeqHandler(l);let d=(qr.properties?qr.properties.maxMonomerLength:4)??50;if(ke.gp.maxMonomerLength in l.tags){const e=parseInt(l.getTag(ke.gp.maxMonomerLength));d=!isNaN(e)&&e?e:50}if(".mm.cellRenderer.maxMonomerLength"in u){const e=u[".mm.cellRenderer.maxMonomerLength"];d=!isNaN(e)&&e?e:50}let p=c.rendererBack;p||(p=c.rendererBack=new He.Jy(a,l,qr.logger,d,()=>{const{font:e,fontWidth:t}=He.Jy.getFontSettings(l);return{font:e,fontCharWidth:t,separatorWidth:h.isMsa()?8:0,monomerToShort:qe}}),l.temp[".mm.cellRenderer.settingsChanged"],Ve.s.true,p.init().then(()=>{})),p.render(e,t,n,i,o,r,s)}render(e,t,n,i,o,r,s){const a=this.getRendererBack(r);a?a?.render(e,t,n,i,o,r,s):this.renderInt(e,t,n,i,o,r,s)}}class Ke extends je{constructor(e,t){super(e,t)}render(e,t,n,i,o,r,s){const a=window.devicePixelRatio,l=r.grid,c=r.cell.value??"",u=this.tableCol.tags[me.gp.separator],h=this.tableCol.meta.units;i=(0,He.U0)(l,e,t,i,a);const[d,p]=c.split("#"),m=this.tableCol.temp[$e.j.notationProvider]?.separatorSplitter??(0,Be.Iv)(h,u),f=m(d),g=m(p),y=R().count(0).take(f.length).map(e=>f.getCanonical(e)).toArray(),b=R().count(0).take(g.length).map(e=>g.getCanonical(e)).toArray(),v=this.tableCol.getTag(me.gp.alphabet);Xe(e,t,n,i,o,y,b,v===me.YI.RNA||v===me.YI.DNA?De.o.NUCLEOTIDE:De.o.AA,this.monomerLib,void 0,void 0)}async awaitRendered(e=1e4,t=`${e} timeout`){return Promise.resolve()}static getOrCreate(e){const[t,n,i]=(0,Ge.BG)(e);let o=i.rendererBack;return o||(o=i.rendererBack=new Ke(t,n)),o}}class Ze extends a.GridCellRenderer{get name(){return"MacromoleculeDifferenceCR"}get cellType(){return Ue.uF.MACROMOLECULE_DIFFERENCE}get defaultHeight(){return 30}get defaultWidth(){return 230}render(e,t,n,i,o,r,s){Ke.getOrCreate(r).render(e,t,n,i,o,r,s)}}function Xe(e,t,n,i,o,r,s,a,l,c,u){if(r.length!==s.length){const e=function(e,t){let n=0,i=0;const o=e.length>t.length?e:t,r=e.length>t.length?t:e;for(let e=0;e<r.length;e++)o[e]===r[e]&&n++;const s=o.length-r.length;for(let e=o.length-1;e>s;e--)o[e]===r[e-s]&&i++;const a=new Array(Math.abs(e.length-t.length)).fill(ve.b9[me.Hi.FASTA]);function l(e){return n>i?e.concat(a):a.concat(e)}return e.length>t.length?t=l(R()(t).toArray()):e=l(R()(e).toArray()),{subParts1:e,subParts2:t}}(r,s);r=e.subParts1,s=e.subParts2}const h=e.measureText(ze(r).join("")),d=e.measureText(ze(s).join("")),p=Math.max(h.width,d.width);c&&(i=p+4*r.length,e.canvas.width=p+4*r.length);let m=Math.max(t,t+(i-(p+4*r.length))/2)+5;const f=Math.max(n,n+(o-28)/2);e.save();try{e.beginPath(),e.rect(t,n,c?p+4*r.length:i,o),e.clip(),e.font="12px monospace",e.textBaseline="top";const h=7;for(let t=0;t<r.length;t++){const n=r[t],c=s[t];let d=He.S$;if(l&&(d=l.getMonomerTextColor(a,n)),n!=c){let r=He.S$;l&&(r=l.getMonomerTextColor(a,c));const s=(0,ke.oZ)(e,n,m,f-h,i,o,{color:d,pivot:0,left:!0}),p=(0,ke.oZ)(e,c,m,f+h,i,o,{color:r,pivot:0,left:!0});m=Math.max(p,s),u&&(u[t]=Je(n,c,d,r,f,h,o))}else m=(0,ke.oZ)(e,n,m,f,i,o,{color:d,pivot:0,left:!0,transparencyRate:.5});m+=4}}finally{e.restore()}}function Je(e,t,n,i,o,r,s){const a=document.createElement("canvas"),l=a.getContext("2d");l.font="12px monospace";const c=l.measureText(ze([e]).join("")).width,u=l.measureText(ze([t]).join("")).width,h=Math.max(c,u);return a.height=s,a.width=h+4,l.font="12px monospace",l.textBaseline="top",(0,ke.oZ)(l,e,0,o-r,h,s,{color:n,pivot:0,left:!0}),(0,ke.oZ)(l,t,0,o+r,h,s,{color:i,pivot:0,left:!0}),a}var Qe,et=n(8070),tt=n(4326);!function(e){e.Unknown="unknown",e.FR="framework",e.CDR="cdr"}(Qe||(Qe={}));const nt=new class{constructor(){this.regionTypes=[Qe.CDR],this.chains=["Heavy","Light"],this.skipEmptyPositions=!1,this.fitWidth=!1,this.positionWidth=16,this.positionHeight=tt.fH.Entropy,this.filterSource=tt.Fo.filterSource}};var it=n(7602),ot=n(250);const rt=Qe;var st,at;!function(e){e.STYLE="Style",e.BEHAVIOR="Behavior",e.LAYOUT="Layout",e.DATA="Data"}(st||(st={})),function(e){e.skipEmptyPositions="skipEmptyPositions",e.regionTypes="regionTypes",e.chains="chains",e.fitWidth="fitWidth",e.positionWidth="positionWidth",e.positionHeight="positionHeight",e.filterSource="filterSource"}(at||(at={}));const lt=nt;class ct extends a.JsViewer{viewed=!1;regionsFg=null;regionsRoot=null;isOpened=!1;panelNode=null;regions=[];regionTypes;chains;skipEmptyPositions;fitWidth;positionWidth;positionHeight;filterSource;constructor(){super(),this.skipEmptyPositions=this.bool(at.skipEmptyPositions,lt.skipEmptyPositions,{category:st.DATA}),this.regionTypes=this.stringList(at.regionTypes,lt.regionTypes,{category:st.DATA,choices:Object.values(rt).filter(e=>e!=rt.Unknown)}),this.chains=this.stringList(at.chains,lt.chains,{category:st.DATA,choices:["Heavy","Light"]}),this.fitWidth=this.bool(at.fitWidth,lt.fitWidth,{category:st.LAYOUT}),this.positionWidth=this.float(at.positionWidth,lt.positionWidth,{category:st.LAYOUT,editor:"slider",min:0,max:64,description:"Internal WebLogo viewers property width of position."}),this.positionHeight=this.string(at.positionHeight,lt.positionHeight,{category:st.LAYOUT,choices:Object.keys(tt.fH)}),this.filterSource=this.string(at.filterSource,lt.filterSource,{category:st.BEHAVIOR,choices:Object.values(tt.lT)}),this.viewSyncer=new it.g(qr.logger)}static viewerCounter=-1;viewerId=++ct.viewerCounter;viewerToLog(){return`VdRegionsViewer<${this.viewerId}>`}async init(){this.subs.push((0,u.fromEvent)(this.root,"mousemove").subscribe(this.rootOnMouseMove.bind(this)))}detach(){const e=`${this.viewerToLog()}.detach()`,t=super.detach.bind(this);this.viewSyncer.sync(`${e}`,async()=>{this.setDataInProgress||(this.viewed&&(await this.destroyView("detach"),this.viewed=!1),t())})}onTableAttached(){super.onTableAttached(),this.setData(this.regions)}onPropertyChanged(e){if(super.onPropertyChanged(e),e){switch(e.name){case at.regionTypes:case at.chains:this.setData(this.regions)}switch(e.name){case at.skipEmptyPositions:for(let e=0;e<this.logos.length;++e)for(const t of this.chains)this.logos[e][t].setOptions({[ot.n5.skipEmptyPositions]:this.skipEmptyPositions});this.calcSize();break;case at.fitWidth:case at.positionWidth:this.calcSize();break;case at.positionHeight:for(let e=0;e<this.logos.length;++e)for(const t of this.chains)this.logos[e][t].setOptions({[ot.n5.positionHeight]:this.positionHeight});this.calcSize();break;case at.filterSource:this.filterSourceInput.value=this.filterSource;break;default:this.setData(this.regions)}}else console.warn("Bio: VdRegionsViewer.onPropertyChanged() property is null")}setData(e){const t=`${this.viewerToLog()}.setData()`;qr.logger.debug(`${t}, in, regions.length = ${e.length}`),this.viewSyncer.sync(`${t}`,async()=>{if(!this.setDataInProgress){this.setDataInProgress=!0;try{this.viewed&&(await this.destroyView("setData"),this.viewed=!1),this.regions=e,this.viewed||(await this.buildView("setData"),this.viewed=!0)}finally{this.setDataInProgress=!1}}})}viewSyncer;setDataInProgress=!1;host=null;filterSourceInput;mainLayout=null;logos=[];viewSubs=[];async destroyView(e){qr.logger.debug(`Bio: VdRegionsViewer.destroyView( mainLayout = ${this.mainLayout?"value":"none"} ), purpose = '${e}', this.regions.length = ${this.regions.length}`),this.filterSourceInput&&s.empty(this.filterSourceInput.root),null!=this.mainLayout&&(this.mainLayout.remove(),this.host.remove(),this.host=null,this.mainLayout=null);for(const e of this.viewSubs)e.unsubscribe()}async buildView(e){qr.logger.debug(`Bio: VdRegionsViewer.buildView() begin, purpose = '${e}', this.regions.length = ${this.regions.length}`);const t=this.regions.filter(e=>this.regionTypes.includes(e.type)),n=Array.from(new Set(t.map(e=>e.order))).sort(),i=[];for(let e=0;e<n.length;e++)for(const o of this.chains){const r=t.find(t=>t.order==n[e]&&t.chain==o);i.push((async()=>{const t=await this.dataFrame.plot.fromType("WebLogo",{sequenceColumnName:r.sequenceColumnName,startPositionName:r.positionStartName,endPositionName:r.positionEndName,fixWidth:!0,skipEmptyPositions:this.skipEmptyPositions,positionWidth:this.positionWidth,positionHeight:this.positionHeight,filterSource:this.filterSource});return t.onSizeChanged.subscribe(()=>{this.calcSize()}),[e,o,t]})())}const o=await Promise.all(i);this.logos=new Array(n.length);for(let e=0;e<n.length;++e)this.logos[e]={};for(const[e,t,n]of o)this.logos[e][t]=n,this.viewSubs.push(n.onFreqsCalculated.subscribe(()=>{this.calcSize()}));this.mainLayout=s.table(this.chains,e=>[...n.length>0?[s.div(e,{style:{transform:"rotate(-90deg)",font:"12px Roboto, Roboto Local, sans-serif",textAlign:"center",width:"16px",marginTop:"24px",marginLeft:"6px"}})]:[],...[...Array(n.length).keys()].map(t=>{const n=this.logos[t][e];return n.root.style.height="100%",s.div([n.root],{style:{marginTop:"4px",marginBottom:"4px"}})})],["",...[...Array(n.length).keys()].map(e=>t.find(t=>t.order==n[e]&&t.chain==this.chains[0]).name||"Name")]),this.mainLayout.className="mlb-vd-regions-viewer-table2",this.filterSourceInput=s.input.choice("Data source",{value:this.filterSource,items:Object.values(tt.lT),onValueChanged:this.filterSourceInputOnValueChanged.bind(this)}),this.filterSourceInput.root.style.position="absolute",this.filterSourceInput.root.style.right="9px",this.filterSourceInput.root.style.top="-4px",Math.ceil(255*Math.random()).toString(16),this.host=s.div([this.mainLayout,this.filterSourceInput.root],{}),this.root.appendChild(this.host),this.root.style.overflowX="auto",this.calcSize(),this.viewSubs.push(s.onSizeChanged(this.root).subscribe(this.rootOnSizeChanged.bind(this))),qr.logger.debug("Bio: VdRegionsViewer.buildView() end")}calcSizeRequested=!1;calcSize(){qr.logger.debug("Bio: VdRegionsViewer.calcSize(), start");const e=()=>{if(!this.host)return;const e=(this.root.clientHeight-54)/this.chains.length;let t=0;for(let n=0;n<this.logos.length;n++){for(const t of this.chains)this.logos[n][t].root.style.height=`${e}px`;t+=Math.max(...this.chains.map(e=>this.logos[n][e].Length))}if(this.fitWidth){if(this.logos.length>0&&t>0){const e=22,n=13,i=9,o=(this.root.clientWidth-e-(this.logos.length-1)*i-n)/t;for(let e=0;e<this.logos.length;e++)for(const t of this.chains){const n=this.logos[e][t];n.setOptions({[ot.n5.positionWidth]:o-n.positionMarginValue}),n.root.style.width=o*n.Length+"px"}}this.host.style.setProperty("overflow","hidden","important")}else{for(let e=0;e<this.logos.length;e++)for(const t of this.chains)this.logos[e][t].setOptions({[ot.n5.positionWidth]:this.positionWidth});this.host.style.removeProperty("overflow")}0===this.positionWidth?this.host.style.setProperty("overflow-x","hidden","important"):this.host.style.removeProperty("overflow-x")};this.calcSizeRequested||(this.calcSizeRequested=!0,window.setTimeout(()=>{e(),this.calcSizeRequested=!1},0))}rootOnSizeChanged(e){this.calcSize()}rootOnMouseMove(e){}filterSourceInputOnValueChanged(){const e=`${this.viewerToLog()}.filterSourceInputOnValueChanged()`,t=this.filterSourceInput.value;this.viewSyncer.sync(`${e}`,async()=>{if(this.filterSource!==t){this.props.getProperty(at.filterSource).set(this,t);for(let e=0;e<this.logos.length;e++)for(let t=0;t<this.chains.length;t++){const n=this.chains[t];this.logos[e][n].setOptions({[ot.n5.filterSource]:this.filterSource})}}})}_onRendered=new u.Subject;get onRendered(){return this._onRendered}invalidate(e){const t=`${this.viewerToLog()}.invalidate(${e?` <- ${e} `:""})`;this.viewSyncer.sync(`${t}`,async()=>{this._onRendered.next()})}async awaitRendered(e=5e3){await(0,et.PE)(this.onRendered,()=>{},()=>{this.invalidate()},e);const t=this.viewSyncer.resetErrors();if(t.length>0)throw t[0]}}class ut{value;parentI;parentJ;constructor(){this.value=0,this.parentI=0,this.parentJ=0}}class ht{seq1;seq2;score;constructor(e,t,n){this.seq1=e,this.seq2=t,this.score=n}}class dt{seq1="";seq2="";gap=1;len1=0;len2=0;step=1;alignGrid=[];scores=[];dpGrid=[];connections={};BLOSUM45=[[5,-2,-1,-2,-1,-1,-1,0,-2,-1,-1,-1,-1,-2,-1,1,0,-2,-2,0,-1,-1,0,-5],[-2,7,0,-1,-3,1,0,-2,0,-3,-2,3,-1,-2,-2,-1,-1,-2,-1,-2,-1,0,-1,-5],[-1,0,6,2,-2,0,0,0,1,-2,-3,0,-2,-2,-2,1,0,-4,-2,-3,4,0,-1,-5],[-2,-1,2,7,-3,0,2,-1,0,-4,-3,0,-3,-4,-1,0,-1,-4,-2,-3,5,1,-1,-5],[-1,-3,-2,-3,12,-3,-3,-3,-3,-3,-2,-3,-2,-2,-4,-1,-1,-5,-3,-1,-2,-3,-2,-5],[-1,1,0,0,-3,6,2,-2,1,-2,-2,1,0,-4,-1,0,-1,-2,-1,-3,0,4,-1,-5],[-1,0,0,2,-3,2,6,-2,0,-3,-2,1,-2,-3,0,0,-1,-3,-2,-3,1,4,-1,-5],[0,-2,0,-1,-3,-2,-2,7,-2,-4,-3,-2,-2,-3,-2,0,-2,-2,-3,-3,-1,-2,-1,-5],[-2,0,1,0,-3,1,0,-2,10,-3,-2,-1,0,-2,-2,-1,-2,-3,2,-3,0,0,-1,-5],[-1,-3,-2,-4,-3,-2,-3,-4,-3,5,2,-3,2,0,-2,-2,-1,-2,0,3,-3,-3,-1,-5],[-1,-2,-3,-3,-2,-2,-2,-3,-2,2,5,-3,2,1,-3,-3,-1,-2,0,1,-3,-2,-1,-5],[-1,3,0,0,-3,1,1,-2,-1,-3,-3,5,-1,-3,-1,-1,-1,-2,-1,-2,0,1,-1,-5],[-1,-1,-2,-3,-2,0,-2,-2,0,2,2,-1,6,0,-2,-2,-1,-2,0,1,-2,-1,-1,-5],[-2,-2,-2,-4,-2,-4,-3,-3,-2,0,1,-3,0,8,-3,-2,-1,1,3,0,-3,-3,-1,-5],[-1,-2,-2,-1,-4,-1,0,-2,-2,-2,-3,-1,-2,-3,9,-1,-1,-3,-3,-3,-2,-1,-1,-5],[1,-1,1,0,-1,0,0,0,-1,-2,-3,-1,-2,-2,-1,4,2,-4,-2,-1,0,0,0,-5],[0,-1,0,-1,-1,-1,-1,-2,-2,-1,-1,-1,-1,-1,-1,2,5,-3,-1,0,0,-1,0,-5],[-2,-2,-4,-4,-5,-2,-3,-2,-3,-2,-2,-2,-2,1,-3,-4,-3,15,3,-3,-4,-2,-2,-5],[-2,-1,-2,-2,-3,-1,-2,-3,2,0,0,-1,0,3,-3,-2,-1,3,8,-1,-2,-2,-1,-5],[0,-2,-3,-3,-1,-3,-3,-3,-3,3,1,-2,1,0,-3,-1,0,-3,-1,5,-3,-3,-1,-5],[-1,-1,4,5,-2,0,1,-1,0,-3,-3,0,-2,-3,-2,0,0,-4,-2,-3,4,2,-1,-5],[-1,0,0,1,-3,4,4,-2,0,-3,-2,1,-1,-3,-1,0,-1,-2,-2,-3,2,4,-1,-5],[0,-1,-1,-1,-2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,0,-2,-1,-1,-1,-1,-1,-5],[-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,1]];BLOSUM50=[[5,-2,-1,-2,-1,-1,-1,0,-2,-1,-2,-1,-1,-3,-1,1,0,-3,-2,0,-2,-1,-1,-5],[-2,7,-1,-2,-4,1,0,-3,0,-4,-3,3,-2,-3,-3,-1,-1,-3,-1,-3,-1,0,-1,-5],[-1,-1,7,2,-2,0,0,0,1,-3,-4,0,-2,-4,-2,1,0,-4,-2,-3,4,0,-1,-5],[-2,-2,2,8,-4,0,2,-1,-1,-4,-4,-1,-4,-5,-1,0,-1,-5,-3,-4,5,1,-1,-5],[-1,-4,-2,-4,13,-3,-3,-3,-3,-2,-2,-3,-2,-2,-4,-1,-1,-5,-3,-1,-3,-3,-2,-5],[-1,1,0,0,-3,7,2,-2,1,-3,-2,2,0,-4,-1,0,-1,-1,-1,-3,0,4,-1,-5],[-1,0,0,2,-3,2,6,-3,0,-4,-3,1,-2,-3,-1,-1,-1,-3,-2,-3,1,5,-1,-5],[0,-3,0,-1,-3,-2,-3,8,-2,-4,-4,-2,-3,-4,-2,0,-2,-3,-3,-4,-1,-2,-2,-5],[-2,0,1,-1,-3,1,0,-2,10,-4,-3,0,-1,-1,-2,-1,-2,-3,2,-4,0,0,-1,-5],[-1,-4,-3,-4,-2,-3,-4,-4,-4,5,2,-3,2,0,-3,-3,-1,-3,-1,4,-4,-3,-1,-5],[-2,-3,-4,-4,-2,-2,-3,-4,-3,2,5,-3,3,1,-4,-3,-1,-2,-1,1,-4,-3,-1,-5],[-1,3,0,-1,-3,2,1,-2,0,-3,-3,6,-2,-4,-1,0,-1,-3,-2,-3,0,1,-1,-5],[-1,-2,-2,-4,-2,0,-2,-3,-1,2,3,-2,7,0,-3,-2,-1,-1,0,1,-3,-1,-1,-5],[-3,-3,-4,-5,-2,-4,-3,-4,-1,0,1,-4,0,8,-4,-3,-2,1,4,-1,-4,-4,-2,-5],[-1,-3,-2,-1,-4,-1,-1,-2,-2,-3,-4,-1,-3,-4,10,-1,-1,-4,-3,-3,-2,-1,-2,-5],[1,-1,1,0,-1,0,-1,0,-1,-3,-3,0,-2,-3,-1,5,2,-4,-2,-2,0,0,-1,-5],[0,-1,0,-1,-1,-1,-1,-2,-2,-1,-1,-1,-1,-2,-1,2,5,-3,-2,0,0,-1,0,-5],[-3,-3,-4,-5,-5,-1,-3,-3,-3,-3,-2,-3,-1,1,-4,-4,-3,15,2,-3,-5,-2,-3,-5],[-2,-1,-2,-3,-3,-1,-2,-3,2,-1,-1,-2,0,4,-3,-2,-2,2,8,-1,-3,-2,-1,-5],[0,-3,-3,-4,-1,-3,-3,-4,-4,4,1,-3,1,-1,-3,-2,0,-3,-1,5,-4,-3,-1,-5],[-2,-1,4,5,-3,0,1,-1,0,-4,-4,0,-3,-4,-2,0,0,-5,-3,-4,5,2,-1,-5],[-1,0,0,1,-3,4,5,-2,0,-3,-3,1,-1,-4,-1,0,-1,-2,-2,-3,2,5,-1,-5],[-1,-1,-1,-1,-2,-1,-1,-2,-1,-1,-1,-1,-1,-2,-2,-1,0,-3,-1,-1,-1,-1,-1,-5],[-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,1]];BLOSUM62=[[4,-1,-2,-2,0,-1,-1,0,-2,-1,-1,-1,-1,-2,-1,1,0,-3,-2,0,-2,-1,0,-4],[-1,5,0,-2,-3,1,0,-2,0,-3,-2,2,-1,-3,-2,-1,-1,-3,-2,-3,-1,0,-1,-4],[-2,0,6,1,-3,0,0,0,1,-3,-3,0,-2,-3,-2,1,0,-4,-2,-3,3,0,-1,-4],[-2,-2,1,6,-3,0,2,-1,-1,-3,-4,-1,-3,-3,-1,0,-1,-4,-3,-3,4,1,-1,-4],[0,-3,-3,-3,9,-3,-4,-3,-3,-1,-1,-3,-1,-2,-3,-1,-1,-2,-2,-1,-3,-3,-2,-4],[-1,1,0,0,-3,5,2,-2,0,-3,-2,1,0,-3,-1,0,-1,-2,-1,-2,0,3,-1,-4],[-1,0,0,2,-4,2,5,-2,0,-3,-3,1,-2,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-2,0,-1,-3,-2,-2,6,-2,-4,-4,-2,-3,-3,-2,0,-2,-2,-3,-3,-1,-2,-1,-4],[-2,0,1,-1,-3,0,0,-2,8,-3,-3,-1,-2,-1,-2,-1,-2,-2,2,-3,0,0,-1,-4],[-1,-3,-3,-3,-1,-3,-3,-4,-3,4,2,-3,1,0,-3,-2,-1,-3,-1,3,-3,-3,-1,-4],[-1,-2,-3,-4,-1,-2,-3,-4,-3,2,4,-2,2,0,-3,-2,-1,-2,-1,1,-4,-3,-1,-4],[-1,2,0,-1,-3,1,1,-2,-1,-3,-2,5,-1,-3,-1,0,-1,-3,-2,-2,0,1,-1,-4],[-1,-1,-2,-3,-1,0,-2,-3,-2,1,2,-1,5,0,-2,-1,-1,-1,-1,1,-3,-1,-1,-4],[-2,-3,-3,-3,-2,-3,-3,-3,-1,0,0,-3,0,6,-4,-2,-2,1,3,-1,-3,-3,-1,-4],[-1,-2,-2,-1,-3,-1,-1,-2,-2,-3,-3,-1,-2,-4,7,-1,-1,-4,-3,-2,-2,-1,-2,-4],[1,-1,1,0,-1,0,0,0,-1,-2,-2,0,-1,-2,-1,4,1,-3,-2,-2,0,0,0,-4],[0,-1,0,-1,-1,-1,-1,-2,-2,-1,-1,-1,-1,-2,-1,1,5,-2,-2,0,-1,-1,0,-4],[-3,-3,-4,-4,-2,-2,-3,-2,-2,-3,-2,-3,-1,1,-4,-3,-2,11,2,-3,-4,-3,-2,-4],[-2,-2,-2,-3,-2,-1,-2,-3,2,-1,-1,-2,-1,3,-3,-2,-2,2,7,-1,-3,-2,-1,-4],[0,-3,-3,-3,-1,-2,-2,-3,-3,3,1,-2,1,-1,-2,-2,0,-3,-1,4,-3,-2,-1,-4],[-2,-1,3,4,-3,0,1,-1,0,-3,-4,0,-3,-3,-2,0,-1,-4,-3,-3,4,1,-1,-4],[-1,0,0,1,-3,3,4,-2,0,-3,-3,1,-1,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-1,-1,-1,-2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-2,0,0,-2,-1,-1,-1,-1,-1,-4],[-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,1]];BLOSUM80=[[7,-3,-3,-3,-1,-2,-2,0,-3,-3,-3,-1,-2,-4,-1,2,0,-5,-4,-1,-3,-2,-1,-8],[-3,9,-1,-3,-6,1,-1,-4,0,-5,-4,3,-3,-5,-3,-2,-2,-5,-4,-4,-2,0,-2,-8],[-3,-1,9,2,-5,0,-1,-1,1,-6,-6,0,-4,-6,-4,1,0,-7,-4,-5,5,-1,-2,-8],[-3,-3,2,10,-7,-1,2,-3,-2,-7,-7,-2,-6,-6,-3,-1,-2,-8,-6,-6,6,1,-3,-8],[-1,-6,-5,-7,13,-5,-7,-6,-7,-2,-3,-6,-3,-4,-6,-2,-2,-5,-5,-2,-6,-7,-4,-8],[-2,1,0,-1,-5,9,3,-4,1,-5,-4,2,-1,-5,-3,-1,-1,-4,-3,-4,-1,5,-2,-8],[-2,-1,-1,2,-7,3,8,-4,0,-6,-6,1,-4,-6,-2,-1,-2,-6,-5,-4,1,6,-2,-8],[0,-4,-1,-3,-6,-4,-4,9,-4,-7,-7,-3,-5,-6,-5,-1,-3,-6,-6,-6,-2,-4,-3,-8],[-3,0,1,-2,-7,1,0,-4,12,-6,-5,-1,-4,-2,-4,-2,-3,-4,3,-5,-1,0,-2,-8],[-3,-5,-6,-7,-2,-5,-6,-7,-6,7,2,-5,2,-1,-5,-4,-2,-5,-3,4,-6,-6,-2,-8],[-3,-4,-6,-7,-3,-4,-6,-7,-5,2,6,-4,3,0,-5,-4,-3,-4,-2,1,-7,-5,-2,-8],[-1,3,0,-2,-6,2,1,-3,-1,-5,-4,8,-3,-5,-2,-1,-1,-6,-4,-4,-1,1,-2,-8],[-2,-3,-4,-6,-3,-1,-4,-5,-4,2,3,-3,9,0,-4,-3,-1,-3,-3,1,-5,-3,-2,-8],[-4,-5,-6,-6,-4,-5,-6,-6,-2,-1,0,-5,0,10,-6,-4,-4,0,4,-2,-6,-6,-3,-8],[-1,-3,-4,-3,-6,-3,-2,-5,-4,-5,-5,-2,-4,-6,12,-2,-3,-7,-6,-4,-4,-2,-3,-8],[2,-2,1,-1,-2,-1,-1,-1,-2,-4,-4,-1,-3,-4,-2,7,2,-6,-3,-3,0,-1,-1,-8],[0,-2,0,-2,-2,-1,-2,-3,-3,-2,-3,-1,-1,-4,-3,2,8,-5,-3,0,-1,-2,-1,-8],[-5,-5,-7,-8,-5,-4,-6,-6,-4,-5,-4,-6,-3,0,-7,-6,-5,16,3,-5,-8,-5,-5,-8],[-4,-4,-4,-6,-5,-3,-5,-6,3,-3,-2,-4,-3,4,-6,-3,-3,3,11,-3,-5,-4,-3,-8],[-1,-4,-5,-6,-2,-4,-4,-6,-5,4,1,-4,1,-2,-4,-3,0,-5,-3,7,-6,-4,-2,-8],[-3,-2,5,6,-6,-1,1,-2,-1,-6,-7,-1,-5,-6,-4,0,-1,-8,-5,-6,6,0,-3,-8],[-2,0,-1,1,-7,5,6,-4,0,-6,-5,1,-3,-6,-2,-1,-2,-5,-4,-4,0,6,-1,-8],[-1,-2,-2,-3,-4,-2,-2,-3,-2,-2,-2,-2,-2,-3,-3,-1,-1,-5,-3,-2,-3,-1,-2,-8],[-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,1]];BLOSUM90=[[5,-2,-2,-3,-1,-1,-1,0,-2,-2,-2,-1,-2,-3,-1,1,0,-4,-3,-1,-2,-1,-1,-6],[-2,6,-1,-3,-5,1,-1,-3,0,-4,-3,2,-2,-4,-3,-1,-2,-4,-3,-3,-2,0,-2,-6],[-2,-1,7,1,-4,0,-1,-1,0,-4,-4,0,-3,-4,-3,0,0,-5,-3,-4,4,-1,-2,-6],[-3,-3,1,7,-5,-1,1,-2,-2,-5,-5,-1,-4,-5,-3,-1,-2,-6,-4,-5,4,0,-2,-6],[-1,-5,-4,-5,9,-4,-6,-4,-5,-2,-2,-4,-2,-3,-4,-2,-2,-4,-4,-2,-4,-5,-3,-6],[-1,1,0,-1,-4,7,2,-3,1,-4,-3,1,0,-4,-2,-1,-1,-3,-3,-3,-1,4,-1,-6],[-1,-1,-1,1,-6,2,6,-3,-1,-4,-4,0,-3,-5,-2,-1,-1,-5,-4,-3,0,4,-2,-6],[0,-3,-1,-2,-4,-3,-3,6,-3,-5,-5,-2,-4,-5,-3,-1,-3,-4,-5,-5,-2,-3,-2,-6],[-2,0,0,-2,-5,1,-1,-3,8,-4,-4,-1,-3,-2,-3,-2,-2,-3,1,-4,-1,0,-2,-6],[-2,-4,-4,-5,-2,-4,-4,-5,-4,5,1,-4,1,-1,-4,-3,-1,-4,-2,3,-5,-4,-2,-6],[-2,-3,-4,-5,-2,-3,-4,-5,-4,1,5,-3,2,0,-4,-3,-2,-3,-2,0,-5,-4,-2,-6],[-1,2,0,-1,-4,1,0,-2,-1,-4,-3,6,-2,-4,-2,-1,-1,-5,-3,-3,-1,1,-1,-6],[-2,-2,-3,-4,-2,0,-3,-4,-3,1,2,-2,7,-1,-3,-2,-1,-2,-2,0,-4,-2,-1,-6],[-3,-4,-4,-5,-3,-4,-5,-5,-2,-1,0,-4,-1,7,-4,-3,-3,0,3,-2,-4,-4,-2,-6],[-1,-3,-3,-3,-4,-2,-2,-3,-3,-4,-4,-2,-3,-4,8,-2,-2,-5,-4,-3,-3,-2,-2,-6],[1,-1,0,-1,-2,-1,-1,-1,-2,-3,-3,-1,-2,-3,-2,5,1,-4,-3,-2,0,-1,-1,-6],[0,-2,0,-2,-2,-1,-1,-3,-2,-1,-2,-1,-1,-3,-2,1,6,-4,-2,-1,-1,-1,-1,-6],[-4,-4,-5,-6,-4,-3,-5,-4,-3,-4,-3,-5,-2,0,-5,-4,-4,11,2,-3,-6,-4,-3,-6],[-3,-3,-3,-4,-4,-3,-4,-5,1,-2,-2,-3,-2,3,-4,-3,-2,2,8,-3,-4,-3,-2,-6],[-1,-3,-4,-5,-2,-3,-3,-5,-4,3,0,-3,0,-2,-3,-2,-1,-3,-3,5,-4,-3,-2,-6],[-2,-2,4,4,-4,-1,0,-2,-1,-5,-5,-1,-4,-4,-3,0,-1,-6,-4,-4,4,0,-2,-6],[-1,0,-1,0,-5,4,4,-3,0,-4,-4,1,-2,-4,-2,-1,-1,-4,-3,-3,0,4,-1,-6],[-1,-2,-2,-2,-3,-1,-2,-2,-2,-2,-2,-1,-1,-2,-2,-1,-1,-3,-2,-2,-2,-1,-2,-6],[-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,1]];NUCLEOTIDES=[[1,-1,-1,-1],[-1,1,-1,-1],[-1,-1,1,-1],[-1,-1,-1,1]];PAM30=[[6,-7,-4,-3,-6,-4,-2,-2,-7,-5,-6,-7,-5,-8,-2,0,-1,-13,-8,-2,-3,-3,-3,-17],[-7,8,-6,-10,-8,-2,-9,-9,-2,-5,-8,0,-4,-9,-4,-3,-6,-2,-10,-8,-7,-4,-6,-17],[-4,-6,8,2,-11,-3,-2,-3,0,-5,-7,-1,-9,-9,-6,0,-2,-8,-4,-8,6,-3,-3,-17],[-3,-10,2,8,-14,-2,2,-3,-4,-7,-12,-4,-11,-15,-8,-4,-5,-15,-11,-8,6,1,-5,-17],[-6,-8,-11,-14,10,-14,-14,-9,-7,-6,-15,-14,-13,-13,-8,-3,-8,-15,-4,-6,-12,-14,-9,-17],[-4,-2,-3,-2,-14,8,1,-7,1,-8,-5,-3,-4,-13,-3,-5,-5,-13,-12,-7,-3,6,-5,-17],[-2,-9,-2,2,-14,1,8,-4,-5,-5,-9,-4,-7,-14,-5,-4,-6,-17,-8,-6,1,6,-5,-17],[-2,-9,-3,-3,-9,-7,-4,6,-9,-11,-10,-7,-8,-9,-6,-2,-6,-15,-14,-5,-3,-5,-5,-17],[-7,-2,0,-4,-7,1,-5,-9,9,-9,-6,-6,-10,-6,-4,-6,-7,-7,-3,-6,-1,-1,-5,-17],[-5,-5,-5,-7,-6,-8,-5,-11,-9,8,-1,-6,-1,-2,-8,-7,-2,-14,-6,2,-6,-6,-5,-17],[-6,-8,-7,-12,-15,-5,-9,-10,-6,-1,7,-8,1,-3,-7,-8,-7,-6,-7,-2,-9,-7,-6,-17],[-7,0,-1,-4,-14,-3,-4,-7,-6,-6,-8,7,-2,-14,-6,-4,-3,-12,-9,-9,-2,-4,-5,-17],[-5,-4,-9,-11,-13,-4,-7,-8,-10,-1,1,-2,11,-4,-8,-5,-4,-13,-11,-1,-10,-5,-5,-17],[-8,-9,-9,-15,-13,-13,-14,-9,-6,-2,-3,-14,-4,9,-10,-6,-9,-4,2,-8,-10,-13,-8,-17],[-2,-4,-6,-8,-8,-3,-5,-6,-4,-8,-7,-6,-8,-10,8,-2,-4,-14,-13,-6,-7,-4,-5,-17],[0,-3,0,-4,-3,-5,-4,-2,-6,-7,-8,-4,-5,-6,-2,6,0,-5,-7,-6,-1,-5,-3,-17],[-1,-6,-2,-5,-8,-5,-6,-6,-7,-2,-7,-3,-4,-9,-4,0,7,-13,-6,-3,-3,-6,-4,-17],[-13,-2,-8,-15,-15,-13,-17,-15,-7,-14,-6,-12,-13,-4,-14,-5,-13,13,-5,-15,-10,-14,-11,-17],[-8,-10,-4,-11,-4,-12,-8,-14,-3,-6,-7,-9,-11,2,-13,-7,-6,-5,10,-7,-6,-9,-7,-17],[-2,-8,-8,-8,-6,-7,-6,-5,-6,2,-2,-9,-1,-8,-6,-6,-3,-15,-7,7,-8,-6,-5,-17],[-3,-7,6,6,-12,-3,1,-3,-1,-6,-9,-2,-10,-10,-7,-1,-3,-10,-6,-8,6,0,-5,-17],[-3,-4,-3,1,-14,6,6,-5,-1,-6,-7,-4,-5,-13,-4,-5,-6,-14,-9,-6,0,6,-5,-17],[-3,-6,-3,-5,-9,-5,-5,-5,-5,-5,-6,-5,-5,-8,-5,-3,-4,-11,-7,-5,-5,-5,-5,-17],[-17,-17,-17,-17,-17,-17,-17,-17,-17,-17,-17,-17,-17,-17,-17,-17,-17,-17,-17,-17,-17,-17,-17,1]];PAM70=[[5,-4,-2,-1,-4,-2,-1,0,-4,-2,-4,-4,-3,-6,0,1,1,-9,-5,-1,-1,-1,-2,-11],[-4,8,-3,-6,-5,0,-5,-6,0,-3,-6,2,-2,-7,-2,-1,-4,0,-7,-5,-4,-2,-3,-11],[-2,-3,6,3,-7,-1,0,-1,1,-3,-5,0,-5,-6,-3,1,0,-6,-3,-5,5,-1,-2,-11],[-1,-6,3,6,-9,0,3,-1,-1,-5,-8,-2,-7,-10,-4,-1,-2,-10,-7,-5,5,2,-3,-11],[-4,-5,-7,-9,9,-9,-9,-6,-5,-4,-10,-9,-9,-8,-5,-1,-5,-11,-2,-4,-8,-9,-6,-11],[-2,0,-1,0,-9,7,2,-4,2,-5,-3,-1,-2,-9,-1,-3,-3,-8,-8,-4,-1,5,-2,-11],[-1,-5,0,3,-9,2,6,-2,-2,-4,-6,-2,-4,-9,-3,-2,-3,-11,-6,-4,2,5,-3,-11],[0,-6,-1,-1,-6,-4,-2,6,-6,-6,-7,-5,-6,-7,-3,0,-3,-10,-9,-3,-1,-3,-3,-11],[-4,0,1,-1,-5,2,-2,-6,8,-6,-4,-3,-6,-4,-2,-3,-4,-5,-1,-4,0,1,-3,-11],[-2,-3,-3,-5,-4,-5,-4,-6,-6,7,1,-4,1,0,-5,-4,-1,-9,-4,3,-4,-4,-3,-11],[-4,-6,-5,-8,-10,-3,-6,-7,-4,1,6,-5,2,-1,-5,-6,-4,-4,-4,0,-6,-4,-4,-11],[-4,2,0,-2,-9,-1,-2,-5,-3,-4,-5,6,0,-9,-4,-2,-1,-7,-7,-6,-1,-2,-3,-11],[-3,-2,-5,-7,-9,-2,-4,-6,-6,1,2,0,10,-2,-5,-3,-2,-8,-7,0,-6,-3,-3,-11],[-6,-7,-6,-10,-8,-9,-9,-7,-4,0,-1,-9,-2,8,-7,-4,-6,-2,4,-5,-7,-9,-5,-11],[0,-2,-3,-4,-5,-1,-3,-3,-2,-5,-5,-4,-5,-7,7,0,-2,-9,-9,-3,-4,-2,-3,-11],[1,-1,1,-1,-1,-3,-2,0,-3,-4,-6,-2,-3,-4,0,5,2,-3,-5,-3,0,-2,-1,-11],[1,-4,0,-2,-5,-3,-3,-3,-4,-1,-4,-1,-2,-6,-2,2,6,-8,-4,-1,-1,-3,-2,-11],[-9,0,-6,-10,-11,-8,-11,-10,-5,-9,-4,-7,-8,-2,-9,-3,-8,13,-3,-10,-7,-10,-7,-11],[-5,-7,-3,-7,-2,-8,-6,-9,-1,-4,-4,-7,-7,4,-9,-5,-4,-3,9,-5,-4,-7,-5,-11],[-1,-5,-5,-5,-4,-4,-4,-3,-4,3,0,-6,0,-5,-3,-3,-1,-10,-5,6,-5,-4,-2,-11],[-1,-4,5,5,-8,-1,2,-1,0,-4,-6,-1,-6,-7,-4,0,-1,-7,-4,-5,5,1,-2,-11],[-1,-2,-1,2,-9,5,5,-3,1,-4,-4,-2,-3,-9,-2,-2,-3,-10,-7,-4,1,5,-3,-11],[-2,-3,-2,-3,-6,-2,-3,-3,-3,-3,-4,-3,-3,-5,-3,-1,-2,-7,-5,-2,-2,-3,-3,-11],[-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,1]];PAM250=[[2,-2,0,0,-2,0,0,1,-1,-1,-2,-1,-1,-3,1,1,1,-6,-3,0,0,0,0,-8],[-2,6,0,-1,-4,1,-1,-3,2,-2,-3,3,0,-4,0,0,-1,2,-4,-2,-1,0,-1,-8],[0,0,2,2,-4,1,1,0,2,-2,-3,1,-2,-3,0,1,0,-4,-2,-2,2,1,0,-8],[0,-1,2,4,-5,2,3,1,1,-2,-4,0,-3,-6,-1,0,0,-7,-4,-2,3,3,-1,-8],[-2,-4,-4,-5,12,-5,-5,-3,-3,-2,-6,-5,-5,-4,-3,0,-2,-8,0,-2,-4,-5,-3,-8],[0,1,1,2,-5,4,2,-1,3,-2,-2,1,-1,-5,0,-1,-1,-5,-4,-2,1,3,-1,-8],[0,-1,1,3,-5,2,4,0,1,-2,-3,0,-2,-5,-1,0,0,-7,-4,-2,3,3,-1,-8],[1,-3,0,1,-3,-1,0,5,-2,-3,-4,-2,-3,-5,0,1,0,-7,-5,-1,0,0,-1,-8],[-1,2,2,1,-3,3,1,-2,6,-2,-2,0,-2,-2,0,-1,-1,-3,0,-2,1,2,-1,-8],[-1,-2,-2,-2,-2,-2,-2,-3,-2,5,2,-2,2,1,-2,-1,0,-5,-1,4,-2,-2,-1,-8],[-2,-3,-3,-4,-6,-2,-3,-4,-2,2,6,-3,4,2,-3,-3,-2,-2,-1,2,-3,-3,-1,-8],[-1,3,1,0,-5,1,0,-2,0,-2,-3,5,0,-5,-1,0,0,-3,-4,-2,1,0,-1,-8],[-1,0,-2,-3,-5,-1,-2,-3,-2,2,4,0,6,0,-2,-2,-1,-4,-2,2,-2,-2,-1,-8],[-3,-4,-3,-6,-4,-5,-5,-5,-2,1,2,-5,0,9,-5,-3,-3,0,7,-1,-4,-5,-2,-8],[1,0,0,-1,-3,0,-1,0,0,-2,-3,-1,-2,-5,6,1,0,-6,-5,-1,-1,0,-1,-8],[1,0,1,0,0,-1,0,1,-1,-1,-3,0,-2,-3,1,2,1,-2,-3,-1,0,0,0,-8],[1,-1,0,0,-2,-1,0,0,-1,0,-2,0,-1,-3,0,1,3,-5,-3,0,0,-1,0,-8],[-6,2,-4,-7,-8,-5,-7,-7,-3,-5,-2,-3,-4,0,-6,-2,-5,17,0,-6,-5,-6,-4,-8],[-3,-4,-2,-4,0,-4,-4,-5,0,-1,-1,-4,-2,7,-5,-3,-3,0,10,-2,-3,-4,-2,-8],[0,-2,-2,-2,-2,-2,-2,-1,-2,4,2,-2,2,-1,-1,-1,0,-6,-2,4,-2,-2,-1,-8],[0,-1,2,3,-4,1,3,0,1,-2,-3,1,-2,-4,-1,0,0,-5,-3,-2,3,2,-1,-8],[0,0,1,3,-5,3,3,0,2,-2,-3,0,-2,-5,0,0,-1,-6,-4,-2,2,3,-1,-8],[0,-1,0,-1,-3,-1,-1,-1,-1,-1,-1,-1,-1,-2,-1,0,0,-4,-2,-1,-1,-1,-1,-8],[-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,1]];SCHNEIDER=[[11.6,-2.7,9.7,-1.7,-2.7,-6.4,-3.9,-5.6,5.1,-5,3.6,-4.2,-6.3,-13,-7.1,-11.5,.4,-6,-1.9,-5.3,-8.5,-11.2,-8.9,-10.8,2.1,0,1.4,.2,-10.2,-13.5,-13,-12.5,-2.6,-8.5,-5,-8.1,-6.3,-9.9,-7.5,-9,-7.1,-10.2,-8.2,-9.2,-8.2,-12.5,-11.1,-11.4,-50,-14.8,-50,-13.8,-7.3,-10.1,-8.4,-9.1,-50,-13,-13.5,-12.4,-10.7,-18.1,-11.8,-17.2],[-2.7,13,-3.3,10.9,-3.5,-.4,-3.3,-1.8,-5.4,4.6,-5.5,3,-10.2,-7.9,-9.9,-9.6,-5,.5,-5.5,-1,-10.3,-8.1,-9.4,-9.6,-8.1,-5,-7.3,-6.3,-13.4,-11.3,-14.4,-12.9,-6.3,.8,-6.4,-1.1,-7.4,-5,-6.2,-6.5,-5.6,-1.6,-4.7,-3,-10.8,-8.7,-11.9,-10,-50,-6.2,-50,-7.5,-6.3,-4.3,-6.2,-5.4,-50,-7,-16.3,-8.2,-13.2,-12.3,-13.1,-13.3],[9.7,-3.3,11.6,-2.8,-4.5,-6.7,-3.1,-6.9,3.3,-5.5,4.8,-5.1,-8.9,-13.2,-5.7,-12.6,-1.5,-6.1,-.6,-6.1,-10,-11.8,-8.6,-11.9,1.2,.5,2.2,.1,-11.8,-14,-11.9,-13.4,-4.9,-9.1,-3.4,-8.9,-8,-10,-7.2,-10,-9.1,-10.2,-7.1,-9.9,-10.1,-13,-10.6,-12.7,-50,-14.9,-50,-14.4,-8.9,-10.8,-8.9,-10.4,-50,-13.1,-11.8,-13,-12.4,-19.4,-11.5,-17.8],[-1.7,10.9,-2.8,12.9,-2.7,-2.2,-2.8,.2,-4.8,2.9,-5.2,5.2,-9.1,-9.5,-9,-7,-4,-1,-5,1,-9,-8.8,-8.9,-7.7,-7,-6.8,-7.1,-4.3,-12.4,-12.9,-13.9,-10,-4.9,-.7,-5.6,1.4,-6,-6.5,-6.2,-4.8,-5.1,-3.2,-5,-1.2,-9.8,-9.9,-11.3,-8.2,-50,-7.6,-50,-5.1,-5.5,-5.8,-5.9,-4.2,-50,-8.3,-15.5,-5.9,-11.6,-14.2,-12,-11.6],[-2.7,-3.5,-4.5,-2.7,11.7,9,10.6,9.6,-3.2,-.7,-5.1,-.4,.7,-4.6,-.4,-3.6,-4.8,-8.9,-6.5,-7.8,-1.4,-4.1,-2.9,-3.3,-8,-9.1,-8,-8.2,-6,-9.3,-7.7,-8.5,-6.4,-10.1,-7.5,-8.6,2.8,-.7,.9,.1,-5.9,-7.3,-6.5,-6.5,-.4,-3.9,-2.6,-3.1,-50,-14.6,-50,-12.6,2.9,.1,1.8,1,-50,-9.2,-13.6,-7.7,-4.8,-12.2,-6.2,-11],[-6.4,-.4,-6.7,-2.2,9,12.3,9.8,9.6,-7.1,2.4,-7.2,.3,-2.9,-1.2,-3,-3.3,-7.6,-6.7,-8.1,-7.9,-4.9,-1.9,-4.5,-3.8,-9.5,-7.8,-9.3,-8.9,-9.4,-7.1,-9,-9,-9.4,-7.5,-9.3,-9.2,-.7,2.6,.2,-.1,-8,-4.6,-7.7,-6.1,-3.6,-1,-4.1,-3.1,-50,-11.6,-50,-11.6,.2,2.3,.4,.5,-50,-6.5,-15.3,-7.8,-8.4,-9.5,-8.3,-11.1],[-3.9,-3.3,-3.1,-2.8,10.6,9.8,12.2,9.8,-4.9,.1,-3.6,-.2,-1.7,-4.1,.9,-3.5,-5.9,-8.9,-5.6,-8.5,-3.9,-3.9,-2.2,-4.5,-7.3,-7.5,-6.4,-8.5,-7.1,-8.2,-6.7,-7.8,-7.9,-9.1,-7.1,-9.4,.9,-.2,2.5,-.3,-6.9,-6.5,-5.5,-6.8,-1.7,-3.4,-1.7,-2.8,-50,-13,-50,-11.5,1.5,.7,2.7,.6,-50,-8.9,-12.1,-7.4,-6.1,-11.5,-5.4,-10.4],[-5.6,-1.8,-6.9,.2,9.6,9.6,9.8,11.6,-6.6,.9,-7.2,2.5,-2.3,-3.4,-2.3,-.6,-6.5,-8.2,-8,-6.3,-3.7,-3.5,-3.9,-1.6,-9.9,-8.9,-9.6,-7,-8.6,-8.9,-8.8,-6.8,-8.6,-8.2,-8.8,-6.8,.3,.1,.2,2.4,-7.4,-6.2,-6.9,-4.4,-2.9,-2.9,-3.5,-.9,-50,-12.2,-50,-10.1,1.2,.6,1.2,2.4,-50,-7.6,-16.1,-5.8,-7.2,-10.8,-7.4,-9],[5.1,-5.4,3.3,-4.8,-3.2,-7.1,-4.9,-6.6,13.3,-2.8,11.2,-1.9,-5.7,-12.5,-7.2,-11.6,-.7,-4.8,-3.1,-4.3,-10,-11.6,-8.8,-11.7,10.5,7.7,9.1,8.5,-9.8,-12.7,-11.7,-11.8,-6.3,-11.4,-8.8,-11,-7.5,-10.3,-8.3,-9.9,-1.9,-6.7,-4.1,-6.4,-7.9,-12.5,-11.4,-11.7,-50,-14,-50,-13.2,-8.5,-10.4,-9.1,-9.6,-50,-9.8,-7.7,-8.8,-10.3,-17.9,-11.8,-16],[-5,4.6,-5.5,2.9,-.7,2.4,.1,.9,-2.8,12.8,-2.6,11,-8.4,-6.3,-8.3,-7.7,-6.1,-2.9,-6.5,-4.2,-8.5,-5.9,-7.5,-7.7,-5.5,-2.4,-5.5,-4.1,-12.9,-10.3,-12.7,-11.3,-7.4,-3.1,-7.4,-4.9,-4.4,-1.8,-3.5,-3.5,-1.6,3,-.8,.9,-8.4,-6.3,-9.6,-7.3,-50,-9,-50,-9.7,-2.3,-.2,-1.2,-1.5,-50,-.7,-13.3,-2,-11.8,-11.9,-12.3,-12.7],[3.6,-5.5,4.8,-5.2,-5.1,-7.2,-3.6,-7.2,11.2,-2.6,13.4,-2.1,-7.7,-12.5,-5.3,-11.9,-2.2,-4.4,-1.9,-4.8,-10.2,-11.5,-8.1,-12,9.3,8.2,10,8,-10.8,-11.9,-10.7,-12.4,-8.2,-11.8,-6.9,-11.5,-8.4,-9.9,-7.1,-10.6,-4.7,-6.8,-1.2,-7,-9.8,-11.6,-9.6,-12.1,-50,-14.1,-50,-12.7,-10,-10.8,-8.8,-10.5,-50,-9.2,-4.2,-9.3,-11,-18.2,-11.1,-16.1],[-4.2,3,-5.1,5.2,-.4,.3,-.2,2.5,-1.9,11,-2.1,13.2,-7.6,-8.5,-8,-5.3,-5.6,-4.5,-6.8,-2.4,-7.8,-7.9,-7.9,-6.2,-5.7,-5.1,-5.4,-2.1,-12.4,-12.3,-13.1,-10.1,-6.6,-4.4,-6.9,-2.6,-3.6,-3.8,-3.7,-2,-1.4,.8,-.9,3,-8.2,-8.1,-9.2,-5.8,-50,-10.1,-50,-7.4,-1.7,-2,-1.5,-.5,-50,-2.1,-12.6,-.4,-11.6,-13.9,-11.4,-11.1],[-6.3,-10.2,-8.9,-9.1,.7,-2.9,-1.7,-2.3,-5.7,-8.4,-7.7,-7.6,13.2,9.6,3.5,9.7,-8.7,-12.4,-10.7,-10.7,-7.8,-10.2,-8.8,-9.6,-9.5,-11.9,-10.9,-10.5,2.3,-.4,-.2,-.3,-9.7,-15.5,-11.4,-13.7,-3,-6.4,-4.1,-5.4,-9.6,-11.9,-10.5,-11.8,6.2,3.3,3.7,3.6,-50,-13.6,-50,-11.9,-5.6,-8.8,-7.2,-8.9,-50,-12.4,-14.1,-11.6,2.8,-6.4,.5,-5.2],[-13,-7.9,-13.2,-9.5,-4.6,-1.2,-4.1,-3.4,-12.5,-6.3,-12.5,-8.5,9.6,12.7,.2,10.5,-12.4,-11.6,-13.2,-12,-12.4,-10.1,-11.6,-12,-15.1,-13.1,-14.3,-13.4,-1.4,1.4,-1.6,-.5,-14.9,-14.3,-15.2,-16.8,-7.7,-4.7,-6.3,-6.6,-14.6,-10.8,-12.8,-13,2.3,6,2.5,3.6,-50,-11.2,-50,-11.9,-10.5,-9.2,-10.5,-10.5,-50,-10.3,-16.2,-11.3,-1.7,-3.7,-2.5,-5.4],[-7.1,-9.9,-5.7,-9,-.4,-3,.9,-2.3,-7.2,-8.3,-5.3,-8,3.5,.2,14.3,1,-7.3,-11.2,-6.9,-9.7,-8.5,-10.2,-7.7,-9.8,-10,-10.4,-8.4,-10.2,1,-.6,1.7,-.5,-11.1,-14.8,-9.7,-14.5,-3.7,-5.8,-3.1,-5.6,-10.4,-11.5,-8.2,-11.1,.6,-1.6,1.6,-1.1,-50,-12.4,-50,-11.5,-5.5,-8,-4.9,-7.2,-50,-12.4,-10.3,-11.6,.7,-6.8,2.4,-6],[-11.5,-9.6,-12.6,-7,-3.6,-3.3,-3.5,-.6,-11.6,-7.7,-11.9,-5.3,9.7,10.5,1,12.6,-12,-12.2,-12.5,-9.7,-11.1,-11.2,-11.9,-9.4,-12.9,-14.3,-14,-11.9,-1,-.4,-1.6,1.2,-13.9,-15.4,-13.7,-12.6,-6.2,-6.7,-6.3,-4.4,-13,-12.2,-13,-10.4,2.9,3.8,2.5,5.8,-50,-12.5,-50,-10.2,-9.6,-9.7,-9.6,-8.3,-50,-11.6,-15.4,-9.4,-1.1,-5.4,-1.6,-3.3],[.4,-5,-1.5,-4,-4.8,-7.6,-5.9,-6.5,-.7,-6.1,-2.2,-5.6,-8.7,-12.4,-7.3,-12,12.8,2.3,10.2,3,0,-3.4,-.7,-3.2,2.5,-.8,.9,.2,-3,-7.2,-5.7,-6.1,-.2,-6.6,-1.8,-6,-5.3,-8.2,-5.7,-7.6,-6.7,-9.6,-7.5,-9.3,-7.1,-10.5,-9.6,-9.4,-50,-8.1,-50,-7.2,-4.3,-6.8,-5.7,-6.3,-50,-9.5,-9.6,-8.9,-6.2,-12.8,-6.8,-11.8],[-6,.5,-6.1,-1,-8.9,-6.7,-8.9,-8.2,-4.8,-2.9,-4.4,-4.5,-12.4,-11.6,-11.2,-12.2,2.3,14.6,1.9,12.9,-5.5,-2.6,-4.1,-4.7,-1.2,3,-1.1,1.6,-8,-4.7,-8.7,-6,-8.2,-4.7,-7.8,-6.7,-10,-8.3,-8.9,-9.9,-10.8,-7.1,-10,-9.2,-11.6,-10.1,-12.3,-11.9,-50,2.2,-50,.9,-7.9,-5.9,-7.4,-6.9,-50,-4.6,-11.6,-5.6,-9.7,-5.9,-9.9,-7.3],[-1.9,-5.5,-.6,-5,-6.5,-8.1,-5.6,-8,-3.1,-6.5,-1.9,-6.8,-10.7,-13.2,-6.9,-12.5,10.2,1.9,11.9,2.1,-2.3,-4.1,-.5,-4.6,-.1,-.9,2.4,-.8,-5.1,-6.9,-4.8,-6.7,-2.3,-7.1,-.8,-7.2,-7.2,-8,-5.6,-8.5,-9.4,-9.7,-7.2,-9.8,-9.2,-11.1,-9.5,-10.7,-50,-8.7,-50,-8.6,-6.1,-7.5,-5.5,-7.7,-50,-10.4,-7.7,-10,-7.3,-13.6,-6.4,-13.3],[-5.3,-1,-6.1,1,-7.8,-7.9,-8.5,-6.3,-4.3,-4.2,-4.8,-2.4,-10.7,-12,-9.7,-9.7,3,12.9,2.1,14.7,-4.9,-3.8,-4,-2.4,-1,.8,-1.3,3.4,-7.6,-5.7,-8.1,-3.5,-6.8,-5.8,-7.2,-4.2,-8.9,-10.2,-8.4,-8.2,-9.9,-8.4,-9.7,-6.4,-11.1,-11.1,-11.8,-10,-50,.4,-50,2.6,-7.2,-7,-7.4,-5.1,-50,-5.7,-9.8,-3.2,-8.4,-7.4,-8.9,-5.9],[-8.5,-10.3,-10,-9,-1.4,-4.9,-3.9,-3.7,-10,-8.5,-10.2,-7.8,-7.8,-12.4,-8.5,-11.1,0,-5.5,-2.3,-4.9,12.6,10,11.1,10.5,-6,-8.3,-6.9,-7.5,-2.2,-7.4,-5.3,-5.9,-8.9,-12.5,-9.4,-11.6,-.7,-3.9,-2.3,-3,-9.1,-9.8,-9.2,-9.5,-5.6,-9,-8,-8.5,-50,-15.3,-50,-14.1,2.3,-1.4,.3,-.5,-50,-13.6,-14.3,-11.5,-5.3,-13.7,-6.1,-12.7],[-11.2,-8.1,-11.8,-8.8,-4.1,-1.9,-3.9,-3.5,-11.6,-5.9,-11.5,-7.9,-10.2,-10.1,-10.2,-11.2,-3.4,-2.6,-4.1,-3.8,10,13.1,10.7,10.6,-8.1,-5.2,-8,-6.7,-6.1,-3.7,-7.5,-5.6,-11.1,-10.3,-10.6,-11.9,-3.2,-1,-2.2,-2.8,-10.5,-8.1,-9.4,-9.5,-8.3,-6.9,-9.4,-8.8,-50,-11.3,-50,-12.8,-.6,2.2,-.3,.1,-50,-10.1,-17.5,-11.1,-8.6,-9.9,-8.6,-11.9],[-8.9,-9.4,-8.6,-8.9,-2.9,-4.5,-2.2,-3.9,-8.8,-7.5,-8.1,-7.9,-8.8,-11.6,-7.7,-11.9,-.7,-4.1,-.5,-4,11.1,10.7,13.2,10.4,-5.7,-5.8,-3.5,-6.1,-3.6,-6.5,-3.3,-5.5,-9.4,-11,-8.7,-11.2,-1.8,-2.7,.7,-3,-9.1,-8.2,-7.3,-9.4,-7.2,-8.2,-7.2,-8.2,-50,-13.2,-50,-13.3,.5,-.9,1.8,-.6,-50,-11.4,-11.1,-10.5,-6.1,-12.9,-5,-11.9],[-10.8,-9.6,-11.9,-7.7,-3.3,-3.8,-4.5,-1.6,-11.7,-7.7,-12,-6.2,-9.6,-12,-9.8,-9.4,-3.2,-4.7,-4.6,-2.4,10.5,10.6,10.4,12.6,-8.2,-7.9,-9,-4.7,-6.1,-6,-7.5,-2.9,-10.9,-12.2,-11.2,-10.9,-2.4,-2.9,-2.7,-.9,-10.4,-9.7,-10.2,-8,-8.4,-9.1,-9.3,-6.5,-50,-13.3,-50,-11,-0,-.4,-.4,2.3,-50,-10.9,-17.2,-8.3,-8.3,-12.7,-7.8,-9.3],[2.1,-8.1,1.2,-7,-8,-9.5,-7.3,-9.9,10.5,-5.5,9.3,-5.7,-9.5,-15.1,-10,-12.9,2.5,-1.2,-.1,-1,-6,-8.1,-5.7,-8.2,13.8,11.3,11.8,12.1,-6,-9.1,-9,-9.5,-8.9,-13.4,-10,-13.1,-9.9,-11.7,-9.8,-12.8,-5.9,-9.4,-6.5,-8.1,-10.7,-14,-13.3,-13.9,-50,-11.9,-50,-9.7,-8.9,-10.8,-9,-11.1,-50,-6.5,-5.3,-6.3,-10.5,-16.2,-10.4,-15.2],[0,-5,.5,-6.8,-9.1,-7.8,-7.5,-8.9,7.7,-2.4,8.2,-5.1,-11.9,-13.1,-10.4,-14.3,-.8,3,-.9,.8,-8.3,-5.2,-5.8,-7.9,11.3,15,11.2,12.8,-9.7,-5.3,-9.2,-7.8,-11.7,-10.6,-10.1,-12.2,-11.7,-8.8,-8.9,-11.8,-9.3,-5,-8,-8.2,-13.6,-11.4,-12.8,-13,-50,-7.2,-50,-8.4,-11,-7.7,-8.7,-10.2,-50,-1.5,-7.1,-4.9,-11.2,-11.6,-11.6,-15],[1.4,-7.3,2.2,-7.1,-8,-9.3,-6.4,-9.6,9.1,-5.5,10,-5.4,-10.9,-14.3,-8.4,-14,.9,-1.1,2.4,-1.3,-6.9,-8,-3.5,-9,11.8,11.2,13.4,11.4,-7.3,-8.8,-6.5,-8.5,-10,-12.5,-7.8,-12.5,-9.6,-11,-7.1,-10.7,-7.9,-8,-4.3,-9.4,-11.4,-12.3,-10.9,-12.9,-50,-11.8,-50,-11.2,-9.4,-9.8,-7.3,-10.5,-50,-6.2,-2.2,-6.7,-9.8,-15.2,-8.5,-14.9],[.2,-6.3,.1,-4.3,-8.2,-8.9,-8.5,-7,8.5,-4.1,8,-2.1,-10.5,-13.4,-10.2,-11.9,.2,1.6,-.8,3.4,-7.5,-6.7,-6.1,-4.7,12.1,12.8,11.4,14.7,-8.7,-7.4,-9.4,-5.3,-9.9,-11.8,-10.5,-10.3,-9.9,-10.1,-9.3,-9.3,-8.1,-7.2,-8,-5.2,-12,-12.1,-12.6,-10.9,-50,-7.9,-50,-5.3,-9.3,-8.8,-8.9,-7,-50,-3.6,-7.1,-1.2,-10.2,-12.7,-9.9,-11],[-10.2,-13.4,-11.8,-12.4,-6,-9.4,-7.1,-8.6,-9.8,-12.9,-10.8,-12.4,2.3,-1.4,1,-1,-3,-8,-5.1,-7.6,-2.2,-6.1,-3.6,-6.1,-6,-9.7,-7.3,-8.7,11.2,7.9,8.9,8.1,-12.1,-17.4,-13.2,-16.8,-6.3,-9.5,-7.5,-8.8,-12.7,-15.2,-13.1,-14.2,0,-3.1,-1.8,-3.1,-50,-10.7,-50,-9.3,-4.6,-8.9,-5.9,-8.3,-50,-12.8,-9.6,-10.6,9.5,-3.2,8.2,-2.8],[-13.5,-11.3,-14,-12.9,-9.3,-7.1,-8.2,-8.9,-12.7,-10.3,-11.9,-12.3,-.4,1.4,-.6,-.4,-7.2,-4.7,-6.9,-5.7,-7.4,-3.7,-6.5,-6,-9.1,-5.3,-8.8,-7.4,7.9,11.9,7.8,9.3,-15.2,-15.1,-14.6,-17.2,-9.7,-7.3,-8.2,-9.2,-15,-12.8,-14.1,-14.9,-2.8,.2,-2.9,-2.3,-50,-7.4,-50,-8.7,-9.4,-7.3,-9.4,-9.4,-50,-8,-11.9,-9.7,6.5,.5,6.4,-1.8],[-13,-14.4,-11.9,-13.9,-7.7,-9,-6.7,-8.8,-11.7,-12.7,-10.7,-13.1,-.2,-1.6,1.7,-1.6,-5.7,-8.7,-4.8,-8.1,-5.3,-7.5,-3.3,-7.5,-9,-9.2,-6.5,-9.4,8.9,7.8,10.1,7.8,-14.3,-17.7,-13,-17.8,-8,-9.4,-6.2,-9.2,-15.1,-14.9,-12.2,-14.9,-1.8,-3.2,-.8,-3.2,-50,-10.8,-50,-9.9,-7.3,-9.6,-6.4,-9.4,-50,-12.3,-8.7,-11.3,7.6,-3.3,8.7,-2.9],[-12.5,-12.9,-13.4,-10,-8.5,-9,-7.8,-6.8,-11.8,-11.3,-12.4,-10.1,-.3,-.5,-.5,1.2,-6.1,-6,-6.7,-3.5,-5.9,-5.6,-5.5,-2.9,-9.5,-7.8,-8.5,-5.3,8.1,9.3,7.8,11.8,-14.4,-15.7,-14.5,-14.6,-8.4,-8.7,-7.9,-7.1,-14.3,-13.8,-13.8,-12.3,-2.4,-2.2,-2.9,-.2,-50,-8.9,-50,-7.1,-8.1,-9.1,-8.7,-6.6,-50,-9.7,-11.4,-8,6.8,-1.8,6.9,.4],[-2.6,-6.3,-4.9,-4.9,-6.4,-9.4,-7.9,-8.6,-6.3,-7.4,-8.2,-6.6,-9.7,-14.9,-11.1,-13.9,-.2,-8.2,-2.3,-6.8,-8.9,-11.1,-9.4,-10.9,-8.9,-11.7,-10,-9.9,-12.1,-15.2,-14.3,-14.4,11.1,2.9,9.2,3.5,-3,-7,-4.3,-6.2,-2.2,-6.6,-3.7,-5.7,-6,-10.4,-8.6,-9.5,-50,-15.5,-50,-13.9,-7.8,-10.5,-8.7,-9.6,-50,-16.5,-17.1,-14.8,-12.1,-18.9,-12.4,-17.4],[-8.5,.8,-9.1,-.7,-10.1,-7.5,-9.1,-8.2,-11.4,-3.1,-11.8,-4.4,-15.5,-14.3,-14.8,-15.4,-6.6,-4.7,-7.1,-5.8,-12.5,-10.3,-11,-12.2,-13.4,-10.6,-12.5,-11.8,-17.4,-15.1,-17.7,-15.7,2.9,12.5,3.1,10.3,-7.7,-5.2,-6.2,-7.3,-5.4,-1.7,-5.4,-3.7,-11.6,-9.1,-13,-10.8,-50,-10.3,-50,-11.2,-9.8,-8.3,-9.1,-9.7,-50,-12.7,-20.6,-13.1,-16,-16.6,-17,-18.4],[-5,-6.4,-3.4,-5.6,-7.5,-9.3,-7.1,-8.8,-8.8,-7.4,-6.9,-6.9,-11.4,-15.2,-9.7,-13.7,-1.8,-7.8,-.8,-7.2,-9.4,-10.6,-8.7,-11.2,-10,-10.1,-7.8,-10.5,-13.2,-14.6,-13,-14.5,9.2,3.1,10.8,3,-4.5,-6.7,-2.7,-6.7,-5,-6.8,-2.5,-6.7,-7.5,-10.4,-7.4,-10.2,-50,-15.5,-50,-14.2,-8.9,-10.2,-8.5,-10,-50,-15.6,-15.3,-15.5,-13,-18.8,-12.6,-18.3],[-8.1,-1.1,-8.9,1.4,-8.6,-9.2,-9.4,-6.8,-11,-4.9,-11.5,-2.6,-13.7,-16.8,-14.5,-12.6,-6,-6.7,-7.2,-4.2,-11.6,-11.9,-11.2,-10.9,-13.1,-12.2,-12.5,-10.3,-16.8,-17.2,-17.8,-14.6,3.5,10.3,3,12.4,-6.9,-7.5,-6.8,-4.9,-5.4,-4.2,-5.4,-1.3,-10.8,-11.5,-12.4,-8.2,-50,-12.5,-50,-8.9,-9.2,-10,-9.4,-7.9,-50,-14.3,-19.9,-11.4,-16.2,-19.2,-15.8,-15.9],[-6.3,-7.4,-8,-6,2.8,-.7,.9,.3,-7.5,-4.4,-8.4,-3.6,-3,-7.7,-3.7,-6.2,-5.3,-10,-7.2,-8.9,-.7,-3.2,-1.8,-2.4,-9.9,-11.7,-9.6,-9.9,-6.3,-9.7,-8,-8.4,-3,-7.7,-4.5,-6.9,11.3,8.2,9.4,9.1,-1,-3.3,-1.8,-2.4,1.5,-2.1,-.4,-1.1,-50,-14.5,-50,-12.9,2.8,-0,1.4,.7,-50,-8.7,-14.1,-7.5,-5.2,-12.5,-6.5,-10.7],[-9.9,-5,-10,-6.5,-.7,2.6,-.2,.1,-10.3,-1.8,-9.9,-3.8,-6.4,-4.7,-5.8,-6.7,-8.2,-8.3,-8,-10.2,-3.9,-1,-2.7,-2.9,-11.7,-8.8,-11,-10.1,-9.5,-7.3,-9.4,-8.7,-7,-5.2,-6.7,-7.5,8.2,11.6,8.8,9.1,-3.7,-.9,-3.1,-3,-2,1.2,-2.3,-1.3,-50,-12.1,-50,-12.6,.1,2.5,.7,.6,-50,-6,-14.8,-7.5,-8.6,-9.4,-8.5,-11.2],[-7.5,-6.2,-7.2,-6.2,.9,.2,2.5,.2,-8.3,-3.5,-7.1,-3.7,-4.1,-6.3,-3.1,-6.3,-5.7,-8.9,-5.6,-8.4,-2.3,-2.2,.7,-2.7,-9.8,-8.9,-7.1,-9.3,-7.5,-8.2,-6.2,-7.9,-4.3,-6.2,-2.7,-6.8,9.4,8.8,12.1,8.8,-2.1,-2,.1,-2.4,0,-1.1,1.3,-.8,-50,-11.9,-50,-12.6,1.2,.7,3.5,.8,-50,-7.1,-12.4,-7.1,-7.1,-10.6,-5,-10.6],[-9,-6.5,-10,-4.8,.1,-.1,-.3,2.4,-9.9,-3.5,-10.6,-2,-5.4,-6.6,-5.6,-4.4,-7.6,-9.9,-8.5,-8.2,-3,-2.8,-3,-.9,-12.8,-11.8,-10.7,-9.3,-8.8,-9.2,-9.2,-7.1,-6.2,-7.3,-6.7,-4.9,9.1,9.1,8.8,11.2,-3.1,-3,-3.3,-1,-1.1,-1.4,-2,1.2,-50,-12.8,-50,-10.9,.8,.5,.7,2.3,-50,-7.5,-16.5,-5.9,-7.8,-11.1,-7.8,-9],[-7.1,-5.6,-9.1,-5.1,-5.9,-8,-6.9,-7.4,-1.9,-1.6,-4.7,-1.4,-9.6,-14.6,-10.4,-13,-6.7,-10.8,-9.4,-9.9,-9.1,-10.5,-9.1,-10.4,-5.9,-9.3,-7.9,-8.1,-12.7,-15,-15.1,-14.3,-2.2,-5.4,-5,-5.4,-1,-3.7,-2.1,-3.1,12.8,9.6,11.1,10.1,-4.8,-9.4,-8.1,-8.6,-50,-18.3,-50,-15.4,-5.9,-7.5,-6.6,-7.1,-50,-9.5,-11.7,-8.4,-12.5,-17.3,-13.2,-15.4],[-10.2,-1.6,-10.2,-3.2,-7.3,-4.6,-6.5,-6.2,-6.7,3,-6.8,.8,-11.9,-10.8,-11.5,-12.2,-9.6,-7.1,-9.7,-8.4,-9.8,-8.1,-8.2,-9.7,-9.4,-5,-8,-7.2,-15.2,-12.8,-14.9,-13.8,-6.6,-1.7,-6.8,-4.2,-3.3,-.9,-2,-3,9.6,12.8,9.7,10.5,-8.5,-5.6,-9.3,-7.8,-50,-12.7,-50,-13.8,-6.8,-5.1,-5.3,-6.5,-50,-4.1,-12.8,-5.8,-14.4,-14.1,-13.6,-14.8],[-8.2,-4.7,-7.1,-5,-6.5,-7.7,-5.5,-6.9,-4.1,-.8,-1.2,-.9,-10.5,-12.8,-8.2,-13,-7.5,-10,-7.2,-9.7,-9.2,-9.4,-7.3,-10.2,-6.5,-8,-4.3,-8,-13.1,-14.1,-12.2,-13.8,-3.7,-5.4,-2.5,-5.4,-1.8,-3.1,.1,-3.3,11.1,9.7,12.9,9.8,-5.5,-8.1,-5.4,-7.8,-50,-16.4,-50,-14.8,-5.9,-7.1,-4.7,-7.2,-50,-8.4,-6.4,-8.1,-12.1,-16.2,-10.3,-15.8],[-9.2,-3,-9.9,-1.2,-6.5,-6.1,-6.8,-4.4,-6.4,.9,-7,3,-11.8,-13,-11.1,-10.4,-9.3,-9.2,-9.8,-6.4,-9.5,-9.5,-9.4,-8,-8.1,-8.2,-9.4,-5.2,-14.2,-14.9,-14.9,-12.3,-5.7,-3.7,-6.7,-1.3,-2.4,-3,-2.4,-1,10.1,10.5,9.8,13.1,-7.2,-8,-8.4,-5,-50,-14.7,-50,-11.4,-6.3,-6.7,-5.8,-5,-50,-6.1,-13.4,-3.6,-13,-16,-13.7,-13.3],[-8.2,-10.8,-10.1,-9.8,-.4,-3.6,-1.7,-2.9,-7.9,-8.4,-9.8,-8.2,6.2,2.3,.6,2.9,-7.1,-11.6,-9.2,-11.1,-5.6,-8.3,-7.2,-8.4,-10.7,-13.6,-11.4,-12,0,-2.8,-1.8,-2.4,-6,-11.6,-7.5,-10.8,1.5,-2,0,-1.1,-4.8,-8.5,-5.5,-7.2,11.9,8.6,10,9,-50,-14.2,-50,-12.8,-4.1,-7.4,-5.7,-6.5,-50,-11,-14.3,-9.9,1.4,-7.9,-.7,-6.8],[-12.5,-8.7,-13,-9.9,-3.9,-1,-3.4,-2.9,-12.5,-6.3,-11.6,-8.1,3.3,6,-1.6,3.8,-10.5,-10.1,-11.1,-11.1,-9,-6.9,-8.2,-9.1,-14,-11.4,-12.3,-12.1,-3.1,.2,-3.2,-2.2,-10.4,-9.1,-10.4,-11.5,-2.1,1.2,-1.1,-1.4,-9.4,-5.6,-8.1,-8,8.6,12.4,8.6,9.5,-50,-10.4,-50,-11.6,-7.2,-5.7,-7.5,-7.4,-50,-8.6,-15.7,-9.7,-3,-3.7,-3.2,-5.9],[-11.1,-11.9,-10.6,-11.3,-2.6,-4.1,-1.7,-3.5,-11.4,-9.6,-9.6,-9.2,3.7,2.5,1.6,2.5,-9.6,-12.3,-9.5,-11.8,-8,-9.4,-7.2,-9.3,-13.3,-12.8,-10.9,-12.6,-1.8,-2.9,-.8,-2.9,-8.6,-13,-7.4,-12.4,-.4,-2.3,1.3,-2,-8.1,-9.3,-5.4,-8.4,10,8.6,11.4,8.9,-50,-13.7,-50,-13.2,-6.1,-8.1,-5.5,-7.5,-50,-11.3,-12.7,-10.1,-1.6,-7.8,-.3,-7.2],[-11.4,-10,-12.7,-8.2,-3.1,-3.1,-2.8,-.9,-11.7,-7.3,-12.1,-5.8,3.6,3.6,-1.1,5.8,-9.4,-11.9,-10.7,-10,-8.5,-8.8,-8.2,-6.5,-13.9,-13,-12.9,-10.9,-3.1,-2.3,-3.2,-.2,-9.5,-10.8,-10.2,-8.2,-1.1,-1.3,-.8,1.2,-8.6,-7.8,-7.8,-5,9,9.5,8.9,12,-50,-13,-50,-10.3,-6.2,-7,-7.1,-5.4,-50,-9.3,-14,-8.2,-2.4,-6.3,-2.4,-3.9],[-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,33.3,-50,30.6,-50,-50,-50,-50,-50,29.2,-50,-50,-50,-50,-50,-50,-50],[-14.8,-6.2,-14.9,-7.6,-14.6,-11.6,-13,-12.2,-14,-9,-14.1,-10.1,-13.6,-11.2,-12.4,-12.5,-8.1,2.2,-8.7,.4,-15.3,-11.3,-13.2,-13.3,-11.9,-7.2,-11.8,-7.9,-10.7,-7.4,-10.8,-8.9,-15.5,-10.3,-15.5,-12.5,-14.5,-12.1,-11.9,-12.8,-18.3,-12.7,-16.4,-14.7,-14.2,-10.4,-13.7,-13,-50,15.1,-50,13.3,-9.9,-5.8,-8.9,-7.6,-50,-1.5,-7.8,-3,-8.1,3.6,-9.4,2],[-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,30.6,-50,35.2,-50,-50,-50,-50,-50,28.5,-50,-50,-50,-50,-50,-50,-50],[-13.8,-7.5,-14.4,-5.1,-12.6,-11.6,-11.5,-10.1,-13.2,-9.7,-12.7,-7.4,-11.9,-11.9,-11.5,-10.2,-7.2,.9,-8.6,2.6,-14.1,-12.8,-13.3,-11,-9.7,-8.4,-11.2,-5.3,-9.3,-8.7,-9.9,-7.1,-13.9,-11.2,-14.2,-8.9,-12.9,-12.6,-12.6,-10.9,-15.4,-13.8,-14.8,-11.4,-12.8,-11.6,-13.2,-10.3,-50,13.3,-50,15.2,-8.6,-7,-8.4,-4.8,-50,-3,-7.1,-.1,-7.3,2.3,-8.7,3.9],[-7.3,-6.3,-8.9,-5.5,2.9,.2,1.5,1.2,-8.5,-2.3,-10,-1.7,-5.6,-10.5,-5.5,-9.6,-4.3,-7.9,-6.1,-7.2,2.3,-.6,.5,-0,-8.9,-11,-9.4,-9.3,-4.6,-9.4,-7.3,-8.1,-7.8,-9.8,-8.9,-9.2,2.8,.1,1.2,.8,-5.9,-6.8,-5.9,-6.3,-4.1,-7.2,-6.1,-6.2,-50,-9.9,-50,-8.6,12.5,9.4,11,9.8,-50,-4.8,-8.7,-3.5,-0,-8.6,-2.1,-7],[-10.1,-4.3,-10.8,-5.8,.1,2.3,.7,.6,-10.4,-.2,-10.8,-2,-8.8,-9.2,-8,-9.7,-6.8,-5.9,-7.5,-7,-1.4,2.2,-.9,-.4,-10.8,-7.7,-9.8,-8.8,-8.9,-7.3,-9.6,-9.1,-10.5,-8.3,-10.2,-10,-0,2.5,.7,.5,-7.5,-5.1,-7.1,-6.7,-7.4,-5.7,-8.1,-7,-50,-5.8,-50,-7,9.4,12.7,10.1,10,-50,-1.5,-11.3,-3.3,-5.4,-4.2,-5.6,-6.8],[-8.4,-6.2,-8.9,-5.9,1.8,.4,2.7,1.2,-9.1,-1.2,-8.8,-1.5,-7.2,-10.5,-4.9,-9.6,-5.7,-7.4,-5.5,-7.4,.3,-.3,1.8,-.4,-9,-8.7,-7.3,-8.9,-5.9,-9.4,-6.4,-8.7,-8.7,-9.1,-8.5,-9.4,1.4,.7,3.5,.7,-6.6,-5.3,-4.7,-5.8,-5.7,-7.5,-5.5,-7.1,-50,-8.9,-50,-8.4,11,10.1,13.2,10.2,-50,-4.2,-6.1,-3.6,-3.5,-8.4,-1.2,-6.8],[-9.1,-5.4,-10.4,-4.2,1,.5,.6,2.4,-9.6,-1.5,-10.5,-.5,-8.9,-10.5,-7.2,-8.3,-6.3,-6.9,-7.7,-5.1,-.5,.1,-.6,2.3,-11.1,-10.2,-10.5,-7,-8.3,-9.4,-9.4,-6.6,-9.6,-9.7,-10,-7.9,.7,.6,.8,2.3,-7.1,-6.5,-7.2,-5,-6.5,-7.4,-7.5,-5.4,-50,-7.6,-50,-4.8,9.8,10,10.2,12.1,-50,-3.1,-11.4,-.7,-4.6,-6.6,-4.9,-3.9],[-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,29.2,-50,28.5,-50,-50,-50,-50,-50,33.3,-50,-50,-50,-50,-50,-50,-50],[-13,-7,-13.1,-8.3,-9.2,-6.5,-8.9,-7.6,-9.8,-.7,-9.2,-2.1,-12.4,-10.3,-12.4,-11.6,-9.5,-4.6,-10.4,-5.7,-13.6,-10.1,-11.4,-10.9,-6.5,-1.5,-6.2,-3.6,-12.8,-8,-12.3,-9.7,-16.5,-12.7,-15.6,-14.3,-8.7,-6,-7.1,-7.5,-9.5,-4.1,-8.4,-6.1,-11,-8.6,-11.3,-9.3,-50,-1.5,-50,-3,-4.8,-1.5,-4.2,-3.1,-50,16.4,-5.1,14.2,-10.1,-4.3,-10,-5.4],[-13.5,-16.3,-11.8,-15.5,-13.6,-15.3,-12.1,-16.1,-7.7,-13.3,-4.2,-12.6,-14.1,-16.2,-10.3,-15.4,-9.6,-11.6,-7.7,-9.8,-14.3,-17.5,-11.1,-17.2,-5.3,-7.1,-2.2,-7.1,-9.6,-11.9,-8.7,-11.4,-17.1,-20.6,-15.3,-19.9,-14.1,-14.8,-12.4,-16.5,-11.7,-12.8,-6.4,-13.4,-14.3,-15.7,-12.7,-14,-50,-7.8,-50,-7.1,-8.7,-11.3,-6.1,-11.4,-50,-5.1,18.6,-4.8,-8.6,-8.1,-4.5,-7.3],[-12.4,-8.2,-13,-5.9,-7.7,-7.8,-7.4,-5.8,-8.8,-2,-9.3,-.4,-11.6,-11.3,-11.6,-9.4,-8.9,-5.6,-10,-3.2,-11.5,-11.1,-10.5,-8.3,-6.3,-4.9,-6.7,-1.2,-10.6,-9.7,-11.3,-8,-14.8,-13.1,-15.5,-11.4,-7.5,-7.5,-7.1,-5.9,-8.4,-5.8,-8.1,-3.6,-9.9,-9.7,-10.1,-8.2,-50,-3,-50,-.1,-3.5,-3.3,-3.6,-.7,-50,14.2,-4.8,16.4,-8.9,-5.8,-8.9,-3.4],[-10.7,-13.2,-12.4,-11.6,-4.8,-8.4,-6.1,-7.2,-10.3,-11.8,-11,-11.6,2.8,-1.7,.7,-1.1,-6.2,-9.7,-7.3,-8.4,-5.3,-8.6,-6.1,-8.3,-10.5,-11.2,-9.8,-10.2,9.5,6.5,7.6,6.8,-12.1,-16,-13,-16.2,-5.2,-8.6,-7.1,-7.8,-12.5,-14.4,-12.1,-13,1.4,-3,-1.6,-2.4,-50,-8.1,-50,-7.3,-0,-5.4,-3.5,-4.6,-50,-10.1,-8.6,-8.9,13.2,-.9,9.7,-.3],[-18.1,-12.3,-19.4,-14.2,-12.2,-9.5,-11.5,-10.8,-17.9,-11.9,-18.2,-13.9,-6.4,-3.7,-6.8,-5.4,-12.8,-5.9,-13.6,-7.4,-13.7,-9.9,-12.9,-12.7,-16.2,-11.6,-15.2,-12.7,-3.2,.5,-3.3,-1.8,-18.9,-16.6,-18.8,-19.2,-12.5,-9.4,-10.6,-11.1,-17.3,-14.1,-16.2,-16,-7.9,-3.7,-7.8,-6.3,-50,3.6,-50,2.3,-8.6,-4.2,-8.4,-6.6,-50,-4.3,-8.1,-5.8,-.9,14.2,-1.8,11.6],[-11.8,-13.1,-11.5,-12,-6.2,-8.3,-5.4,-7.4,-11.8,-12.3,-11.1,-11.4,.5,-2.5,2.4,-1.6,-6.8,-9.9,-6.4,-8.9,-6.1,-8.6,-5,-7.8,-10.4,-11.6,-8.5,-9.9,8.2,6.4,8.7,6.9,-12.4,-17,-12.6,-15.8,-6.5,-8.5,-5,-7.8,-13.2,-13.6,-10.3,-13.7,-.7,-3.2,-.3,-2.4,-50,-9.4,-50,-8.7,-2.1,-5.6,-1.2,-4.9,-50,-10,-4.5,-8.9,9.7,-1.8,11.3,-.9],[-17.2,-13.3,-17.8,-11.6,-11,-11.1,-10.4,-9,-16,-12.7,-16.1,-11.1,-5.2,-5.4,-6,-3.3,-11.8,-7.3,-13.3,-5.9,-12.7,-11.9,-11.9,-9.3,-15.2,-15,-14.9,-11,-2.8,-1.8,-2.9,.4,-17.4,-18.4,-18.3,-15.9,-10.7,-11.2,-10.6,-9,-15.4,-14.8,-15.8,-13.3,-6.8,-5.9,-7.2,-3.9,-50,2,-50,3.9,-7,-6.8,-6.8,-3.9,-50,-5.4,-7.3,-3.4,-.3,11.6,-.9,14.1]];TRANS=[[5,0,0,4],[0,5,4,0],[0,4,5,0],[4,0,0,5]];CONBLO={A:0,R:1,N:2,D:3,C:4,Q:5,E:6,G:7,H:8,I:9,L:10,K:11,M:12,F:13,P:14,S:15,T:16,W:17,Y:18,V:19,B:20,Z:21,X:22,"*":23};CONNUCL={A:0,T:1,C:2,G:3};CONSCHN={AAA:0,AAC:1,AAG:2,AAT:3,ACA:4,ACC:5,ACG:6,ACT:7,AGA:8,AGC:9,AGG:10,AGT:11,ATA:12,ATC:13,ATG:14,ATT:15,CAA:16,CAC:17,CAG:18,CAT:19,CCA:20,CCC:21,CCG:22,CCT:23,CGA:24,CGC:25,CGG:26,CGT:27,CTA:28,CTC:29,CTG:30,CTT:31,GAA:32,GAC:33,GAG:34,GAT:35,GCA:36,GCC:37,GCG:38,GCT:39,GGA:40,GGC:41,GGG:42,GGT:43,GTA:44,GTC:45,GTG:46,GTT:47,TAA:48,TAC:49,TAG:50,TAT:51,TCA:52,TCC:53,TCG:54,TCT:55,TGA:56,TGC:57,TGG:58,TGT:59,TTA:60,TTC:61,TTG:62,TTT:63};fillNeedleman(){for(let e=0;e<=this.len1;e++)this.dpGrid[e][0].value=-e*this.gap,this.dpGrid[e][0].parentI=e-1,this.dpGrid[e][0].parentJ=0;for(let e=1;e<=this.len2;e++)this.dpGrid[0][e].value=-e*this.gap,this.dpGrid[0][e].parentI=0,this.dpGrid[0][e].parentJ=e-1}fillOne(e,t){this.dpGrid[e][t].value=Math.max(this.dpGrid[e-1][t-1].value+this.scores[e-1][t-1],Math.max(this.dpGrid[e-1][t].value-this.gap,this.dpGrid[e][t-1].value-this.gap)),this.dpGrid[e][t].value==this.dpGrid[e-1][t-1].value+this.scores[e-1][t-1]?(this.dpGrid[e][t].parentI=e-1,this.dpGrid[e][t].parentJ=t-1):this.dpGrid[e][t].value==this.dpGrid[e-1][t].value-this.gap?(this.dpGrid[e][t].parentI=e-1,this.dpGrid[e][t].parentJ=t):(this.dpGrid[e][t].parentI=e,this.dpGrid[e][t].parentJ=t-1)}gridFromName(e){switch(e){case"BLOSUM45":this.alignGrid=this.BLOSUM45,this.connections=this.CONBLO,this.step=1;break;case"BLOSUM50":this.alignGrid=this.BLOSUM50,this.connections=this.CONBLO,this.step=1;break;case"BLOSUM62":this.alignGrid=this.BLOSUM62,this.connections=this.CONBLO,this.step=1;break;case"BLOSUM80":this.alignGrid=this.BLOSUM80,this.connections=this.CONBLO,this.step=1;break;case"BLOSUM90":this.alignGrid=this.BLOSUM90,this.connections=this.CONBLO,this.step=1;break;case"PAM30":this.alignGrid=this.PAM30,this.connections=this.CONBLO,this.step=1;break;case"PAM70":this.alignGrid=this.PAM70,this.connections=this.CONBLO,this.step=1;break;case"PAM250":this.alignGrid=this.PAM250,this.connections=this.CONBLO,this.step=1;break;case"NUCLEOTIDES":this.alignGrid=this.NUCLEOTIDES,this.connections=this.CONNUCL,this.step=1;break;case"TRANS":this.alignGrid=this.TRANS,this.connections=this.CONNUCL,this.step=1;break;case"SCHNEIDER":this.alignGrid=this.SCHNEIDER,this.connections=this.CONSCHN,this.step=3}this.fillScores()}constructResult(e,t){let n="",i="",o="";const r=this.dpGrid[e][t].value;for(let e=0;e<this.step;e++)o+="|";for(;e>0||t>0;){this.dpGrid[e][t].parentI==e?(n=o+n,i=this.seq2.substr((t-1)*this.step,this.step)+i):this.dpGrid[e][t].parentJ==t?(i=o+i,n=this.seq1.substr((e-1)*this.step,this.step)+n):(n=e-1>=0?this.seq1.substr((e-1)*this.step,this.step)+n:o+n,i=t-1>=0?this.seq2.substr((t-1)*this.step,this.step)+i:o+i);const r=e;e=this.dpGrid[e][t].parentI,t=this.dpGrid[r][t].parentJ}return new ht(n,i,r)}fillScores(){this.scores=[];for(let e=0;e<this.len1;e++){this.scores.push([]);for(let t=0;t<this.len2;t++)this.scores[e].push(this.alignGrid[this.connections[this.seq1.substr(e*this.step,this.step)]][this.connections[this.seq2.substr(t*this.step,this.step)]])}}typeRec(){if(/[ATGC]*/.test(this.seq1)&&/[ATGC]*/.test(this.seq2))return"NUCLEOTIDES";if(/[ARNDCQEGHILKMFPSTWYVBZX*]*/.test(this.seq1)&&/[ARNDCQEGHILKMFPSTWYVBZX*]*/.test(this.seq2))return"BLOSUM62";throw Error("Can't recognize sequence type")}needlemanWunsch(){this.dpGrid=[];for(let e=0;e<this.len1+1;e++){const e=[];for(let t=0;t<this.len2+1;t++)e.push(new ut);this.dpGrid.push(e)}this.fillNeedleman();for(let e=1;e<=this.len1;e++)for(let t=1;t<=this.len2;t++)this.fillOne(e,t);return this.constructResult(this.len1,this.len2)}smithWaterman(){this.dpGrid=[];for(let e=0;e<this.len1+1;e++){const e=[];for(let t=0;t<this.len2+1;t++)e.push(new ut);this.dpGrid.push(e)}let e=0,t=0,n=0;for(let i=1;i<=this.len1;i++)for(let o=1;o<=this.len2;o++)this.fillOne(i,o),this.dpGrid[i][o].value<=0?(this.dpGrid[i][o].value=0,this.dpGrid[i][o].parentI=0,this.dpGrid[i][o].parentJ=0):0==this.dpGrid[this.dpGrid[i][o].parentI][this.dpGrid[i][o].parentJ].value&&(this.dpGrid[i][o].parentI=0,this.dpGrid[i][o].parentJ=0),this.dpGrid[i][o].value>e&&(e=this.dpGrid[i][o].value,t=i,n=o);return this.constructResult(t,n)}setSequences(e,t){this.seq1=e,this.seq2=t,this.len1=this.seq1.length/this.step,this.len2=this.seq2.length/this.step,this.fillScores()}setGap(e){this.gap=e}setMethod(e=""){"AUTO"==e&&(e=this.typeRec()),this.gridFromName(e)}constructor(e,t,n,i=""){this.setMethod(i),this.setSequences(e,t),this.setGap(n)}}async function pt(e,t,n="Morgan",i=1,o=.6){const r=e.length,s=qr.seqHelper.getSeqHandler(e),l=Array(r);let c=1;const u=new Map,h=e.categories,d=e.getRawData();for(let t=0;t<r;t++){if(null==h[d[t]]||e.isNone(t)){l[t]=null;continue}l[t]="";const n=s.getSplitted(t);for(let e=0;e<n.length;e++){const i=n.getCanonical(e);u.has(i)||(u.set(i,String.fromCharCode(c)),c++),l[t]+=u.get(i)}}let p={};if(t===pe.Z.MONOMER_CHEMICAL_DISTANCE||t===pe.Z.NEEDLEMANN_WUNSCH){const e=Array.from(u.keys()),r=await async function(e,t="Morgan"){const n=(await(0,we.pj)()).getMonomerLib(),i=new Array(e.length).fill(0).map(()=>new Array(e.length).fill(0)),o={},r=e.map(e=>n.getMonomer("PEPTIDE",e)?.molfile||n.getMonomer("PEPTIDE",e)?.smiles||""),s=a.Func.find({package:"Chem",name:"getFingerprints"})[0];if(!s)return console.warn('Function "Chem:getFingerprints" is not found in chem package. falling back to Morgan fingerprints'),await Ce(e);const l=a.Column.fromStrings("smiles",r),c=(a.DataFrame.fromColumns([l]),(await s.apply({col:l,fingerprintType:t}))?.entries);if(!c)return console.warn(`${t} Fingerprints could not be calculated for monomers from chem package.\n falling back to Morgan fingerprints`),await Ce(e);for(let t=0;t<c.length;++t)if(i[t][t]=1,o[e[t]]=t,c[t])for(let e=t+1;e<c.length;++e)c[e]&&(i[t][e]=i[e][t]=(0,H.$1)(c[t],c[e]));return{scoringMatrix:i,alphabetIndexes:o}}(e,n),s={};Object.entries(r.alphabetIndexes).forEach(([e,t])=>{s[u.get(e)]=t});const c=l.reduce((e,t)=>Math.max(e,t?.length||0),0);p={scoringMatrix:r.scoringMatrix,alphabetIndexes:s,maxLength:c},t===pe.Z.NEEDLEMANN_WUNSCH&&(p.gapOpen=i,p.gapExtend=o)}return{seqList:l,options:p}}var mt=n(4954);function ft(e){const t=s.divH([],{style:{gap:"10px"}}),n=s.divV([s.divText(e.seqCol.name),s.divText(e.activityCol.name)]);return n.style.fontWeight="bold",n.style.display="flex",n.style.justifyContent="space-between",t.append(n),e.points.forEach(n=>{const i=s.divText(e.activityCol.get(n).toFixed(2));i.style.display="flex",i.style.justifyContent="left",i.style.paddingLeft="30px",t.append(s.divV([s.divText(e.seqCol.get(n)),i]))}),t}function gt(e){const t=s.div();t.append(s.divText(e.seqCol.name,{style:{fontWeight:"bold"}}));const n=new Array(2);e.points.forEach((t,i)=>{n[i]=e.activityCol.get(t)});const i={},o=qr.seqHelper.getSeqHandler(e.seqCol),r=o.defaultBiotype,a=bt(o.getSplitted(e.points[0]),o.getSplitted(e.points[1]),r,i);return t.append(s.div(a,{style:{width:"300px",overflow:"scroll"}})),t.append(vt(i)),t.append(yt("Activity delta",Math.abs(n[0]-n[1]))),t.append(yt("Cliff",e.sali)),t}function yt(e,t){return s.divH([s.divText(`${e}: `,{style:{fontWeight:"bold",paddingRight:"5px"}}),s.divText(t.toFixed(2))],{style:{paddingTop:"10px"}})}function bt(e,t,n,i){const o=document.createElement("canvas"),r=o.getContext("2d");o.height=30;const s=qr.monomerLib;return Xe(r,0,0,0,30,R().count(0).take(e.length).map(t=>e.getCanonical(t)).toArray(),R().count(0).take(t.length).map(e=>t.getCanonical(e)).toArray(),n,s,!0,i),o}function vt(e){const t=s.div();if(Object.keys(e).length>0){const n=s.divV([]);n.append(s.divH([s.divText("Pos",{style:{fontWeight:"bold",width:"30px",borderBottom:"1px solid"}}),s.divText("Difference",{style:{fontWeight:"bold",borderBottom:"1px solid"}})]));for(const t of Object.keys(e))e[t].style.borderBottom="1px solid lightgray",n.append(s.divH([s.divText((parseInt(t)+1).toString(),{style:{width:"30px",borderBottom:"1px solid lightgray"}}),e[t]]));t.append(n)}return t}function wt(e,t){const n=a.Column.string("seq_diff",e.rowCount).init(n=>`${e.get(t[0],n)}#${e.get(t[1],n)}`);n.semType="MacromoleculeDifference",n.meta.units=e.col(t[0]).meta.units,n.setTag(me.gp.separator,e.col(t[0]).getTag(me.gp.separator)),e.columns.add(n);const i=e.plot.grid();return i.col(t[0]).visible=!1,i.col(t[1]).visible=!1,i}class Ct extends a.JsViewer{constructor(e,t){super(),this.name="",this.semType="",this.initialized=!1,this.gridSelect=!1,this.maxLimit=100,this.recomputeOnCurrentRowChange=!0,this.skipRecomputingProperies=[],this.debounceTimer=null,this.computeRequested=!1,this.renderPromise=Promise.resolve(),this.limit=this.int("limit",10,{min:1,max:this.maxLimit}),this.targetColumnName=this.string("targetColumnName",null,{...t?{semType:t}:{},nullable:!1}),this.name=e,this.semType=t}init(){this.initialized=!0}detach(){this.subs.forEach(e=>e.unsubscribe())}async onTableAttached(){if(this.init(),this.dataFrame){this.subs.push(a.debounce(this.dataFrame.onRowsRemoved,50).subscribe(e=>this.render(!0)));const e="diversity"!==this.name;this.subs.push(a.debounce(this.dataFrame.onCurrentRowChanged,50).subscribe(t=>{this.gridSelect||this.render(e)})),this.subs.push(a.debounce(this.dataFrame.selection.onChanged,50).subscribe(e=>this.render(!1))),this.subs.push(a.debounce(s.onSizeChanged(this.root),50).subscribe(e=>this.render(!1))),this.targetColumnName??(this.targetColumnName=this.dataFrame.columns.bySemType(this.semType).name),this.targetColumn=this.dataFrame.col(this.targetColumnName),this.getProperty("limit").fromOptions({min:1,max:this.maxLimit})}this.render()}onPropertyChanged(e){if(super.onPropertyChanged(e),this.initialized){if("targetColumnName"===e.name){const t=this.dataFrame.col(e.get(this));t.semType===this.semType&&(this.targetColumn=t)}this.debouncedRender()}}debouncedRender(e=!0){this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>{this.render(e),this.debounceTimer=null},100)}render(e=!0){this.renderPromise=this.renderPromise.then(async()=>{this.computeRequested=this.computeRequested||e,await this.renderInt(e)})}async renderInt(e){}beforeRender(){return!(!this.initialized||!this.targetColumnName||this.dataFrame&&this.targetColumnName&&this.dataFrame.col(this.targetColumnName).semType!==this.semType&&(r.shell.error(`${this.targetColumnName} is not ${this.semType} type`),1))}}class St extends Ct{distanceMetric;fingerprint;gapOpen;gapExtend;metricsProperties=["distanceMetric","fingerprint","gapOpen","gapExtend"];fingerprintChoices=["Morgan","RDKit","Pattern","AtomPair","MACCS","TopologicalTorsion"];distanceFunctionChoices=[pe.Z.NEEDLEMANN_WUNSCH,pe.Z.HAMMING,pe.Z.LEVENSHTEIN,pe.Z.MONOMER_CHEMICAL_DISTANCE];tags=[a.TAGS.UNITS,me.gp.aligned,me.gp.separator,me.gp.alphabet,"cell.renderer"];preComputeDistanceMatrix=!1;requiresSampling=!1;constructor(e,t){super(e,t),this.distanceMetric=this.string("distanceMetric",pe.Z.HAMMING,{choices:this.distanceFunctionChoices}),this.fingerprint=this.string("fingerprint",this.fingerprintChoices[0],{choices:this.fingerprintChoices}),this.gapOpen=this.float("gapOpen",1),this.gapExtend=this.float("gapExtend",.6)}async onTableAttached(){if(super.onTableAttached(),this.dataFrame){const e=this.dataFrame.rowCount;this.preComputeDistanceMatrix=e<=1e4,this.requiresSampling=e>1e4}}needsGapPenalties(){return this.distanceMetric===pe.Z.NEEDLEMANN_WUNSCH}needsFingerprint(){return this.distanceMetric===pe.Z.MONOMER_CHEMICAL_DISTANCE||this.distanceMetric===pe.Z.NEEDLEMANN_WUNSCH}}const At={gapPenalty:1,matchScore:1,gapSymbol:ve.b9[ve.Hi.FASTA],localAlignment:!1};class xt extends St{seqHelper;cutoff;hotSearch;similarColumnLabel;sketchedMolecule="";curIdx=0;molCol=null;idxs=null;scores=null;gridSelect=!1;targetMoleculeIdx=0;computeCompleted=new u.Subject;distanceMatrixComputed=!1;mmDistanceMatrix;knn;kPrevNeighbors=0;demo;analysisGrid;subInited=!1;lastDistanceMetric="";lastFingerprint="";lastGapOpen=0;lastGapExtend=0;constructor(e,t){super("similarity",a.SEMTYPE.MACROMOLECULE),this.seqHelper=e,this.cutoff=this.float("cutoff",.01,{min:0,max:1}),this.hotSearch=this.bool("hotSearch",!0),this.similarColumnLabel=this.string("similarColumnLabel",null),this.demo=t}init(){this.hotSearch=!0,this.initialized=!0}async renderInt(e){if(this.beforeRender()&&this.targetColumn){this.curIdx=-1==this.dataFrame.currentRowIdx?0:this.dataFrame.currentRowIdx;const t=this.lastDistanceMetric!==this.distanceMetric||this.lastFingerprint!==this.fingerprint||this.lastGapOpen!==this.gapOpen||this.lastGapExtend!==this.gapExtend;if(e&&!this.gridSelect||t){this.targetMoleculeIdx=(this.dataFrame.currentRowIdx??-1)<0?0:this.dataFrame.currentRowIdx,await this.computeByMM();const e=null!=this.similarColumnLabel?this.similarColumnLabel:`similar (${this.targetColumn})`;this.molCol=a.Column.string(e,this.idxs.length).init(e=>this.targetColumn?.get(this.idxs?.get(e))),this.molCol.semType=a.SEMTYPE.MACROMOLECULE,this.tags.forEach(e=>this.molCol.setTag(e,this.targetColumn.getTag(e)));const t=a.DataFrame.fromColumns([this.idxs,this.molCol,this.scores]);await t.meta.detectSemanticTypes(),await r.data.detectSemanticTypes(t),this.molCol.temp["reference-sequence"]=this.targetColumn.get(this.targetMoleculeIdx),this.molCol.temp[".mm.cellRenderer.maxMonomerLength"]=4;let n=null;t.onCurrentRowChanged.subscribe(e=>{n&&clearTimeout(n),(t.currentRowIdx??-1)<0||(this.dataFrame.currentRowIdx=t.col("indexes").get(t.currentRowIdx),n=setTimeout(()=>{this.createPropertyPanel(t)},300),this.gridSelect=!0)}),this.analysisGrid?(this.analysisGrid.dataFrame=t,this.analysisGrid.invalidate()):(this.analysisGrid=t.plot.grid(),(0,Oe.Ku)(this.root,this.analysisGrid.root)),this.analysisGrid.col("indexes").visible=!1,(0,Oe.Kd)(this.analysisGrid,this.molCol.name,450,30,!0);const i=this.idxs?.getRawData().findIndex(e=>e==this.targetMoleculeIdx);this.analysisGrid.cell("score",i).cell.value=null;const o=r.shell.tv;this.subInited||(o.grid.root.addEventListener("click",e=>{this.gridSelect=!1}),this.subInited=!0),this.computeCompleted.next(!0)}}}async computeByMM(){const e=this.targetColumn.length,t=Math.min(this.limit,e-1);if(!this.knn||this.kPrevNeighbors!==t||this.lastDistanceMetric!==this.distanceMetric||this.lastFingerprint!==this.fingerprint||this.lastGapOpen!==this.gapOpen||this.lastGapExtend!==this.gapExtend){const e=this.distanceMetric,n=await pt(this.targetColumn,e,this.fingerprint,this.gapOpen,this.gapExtend),i=n.seqList,o=n.options;this.lastDistanceMetric=this.distanceMetric,this.lastFingerprint=this.fingerprint,this.lastGapOpen=this.gapOpen,this.lastGapExtend=this.gapExtend,this.kPrevNeighbors=t,this.knn=await(new D).getKNN(i,e,t,o)}const n=new Array(t).fill(0).map((e,t)=>({idx:this.knn.knnIndexes[this.targetMoleculeIdx][t],score:1-this.knn.knnDistances[this.targetMoleculeIdx][t]}));n.sort((e,t)=>t.score-e.score),n.unshift({idx:this.targetMoleculeIdx,score:a.FLOAT_NULL}),this.idxs=a.Column.int("indexes",t+1).init(e=>n[e].idx),this.scores=a.Column.float("score",t+1).init(e=>n[e].score)}createPropertyPanel(e){const t=s.div(),n={},i=this.molCol?.name,o=e.col(i),a=this.seqHelper.getSeqHandler(this.targetColumn),l=this.seqHelper.getSeqHandler(o),c=a.getSplitted(this.targetMoleculeIdx),u=l.getSplitted(e.currentRowIdx),h=function(e,t,n={}){const i={...At,...n};function o(e,t){return e===t?i.matchScore:-i.matchScore}const r=e.length,s=t.length,a=Array(r+1).fill(0).map(()=>Array(s+1).fill(0));let l=-9999,c=[1,1];for(let n=1;n<r+1;n++)for(let r=1;r<s+1;r++)a[n][r]=Math.max(0,a[n-1][r-1]+o(e.getCanonical(n-1),t.getCanonical(r-1)),a[n-1][r]-i.gapPenalty,a[n][r-1]-i.gapPenalty),a[n][r]>=l&&(l=a[n][r],c=[n,r]);let u=i.localAlignment?c[0]:r,h=i.localAlignment?c[1]:s,d=new Array(0),p=new Array(0);for(;u>0&&h>0;){const n=Math.max(a[u-1][h-1],a[u-1][h],a[u][h-1]);a[u][h]==a[u-1][h-1]+i.matchScore&&n==a[u-1][h-1]?(d.push(e.getCanonical(u-1)),p.push(t.getCanonical(h-1)),u-=1,h-=1):a[u][h]==a[u-1][h]-i.gapPenalty?(p.push(i.gapSymbol),d.push(e.getCanonical(u-1)),u-=1):a[u][h]==a[u][h-1]-i.gapPenalty?(d.push(i.gapSymbol),p.push(t.getCanonical(h-1)),h-=1):(d.push(e.getCanonical(u-1)),p.push(t.getCanonical(h-1)),u-=1,h-=1)}d=[...R().count(0).take(u).map(t=>e.getCanonical(t)),...d.reverse(),...i.localAlignment?R().count(c[0]).take(r).map(t=>e.getCanonical(t)):[]],p=[...R().count(0).take(h).map(e=>t.getCanonical(e)),...p.reverse(),...i.localAlignment?R().count(c[1]).take(s).map(e=>t.getCanonical(e)):[]];const m=u,f=h;return m>f?p=[...new Array(m-f).fill(i.gapSymbol.valueOf()),...p]:d=[...new Array(f-m).fill(i.gapSymbol.valueOf()),...d],p.length>d.length?d.push(...new Array(p.length-d.length).fill(i.gapSymbol.valueOf())):p.push(...new Array(d.length-p.length).fill(i.gapSymbol.valueOf())),{seq1:d.join(""),seq2:p.join(""),seq1Splitted:new Be.Mu(d,i.gapSymbol),seq2Splitted:new Be.Mu(p,i.gapSymbol)}}(c,u),d=bt(h.seq1Splitted,h.seq2Splitted,l.defaultBiotype,n);t.append(s.div(d,{style:{width:"300px",overflow:"scroll"}})),c.length!==u.length&&t.append(s.divV([s.divText("Different sequence length:",{style:{fontWeight:"bold"}}),s.divText(`target: ${c.length} monomers`),s.divText(`selected: ${u.length} monomers`)],{style:{paddingBottom:"10px"}})),t.append(vt(n));const p=s.accordion(),m=s.element("i");m.className="grok-icon svg-icon svg-view-layout",p.addTitle(s.span([m,s.label("Similarity search")])),p.addPane("Differences",()=>t,!0),r.shell.o=p.root}}class Mt extends St{seqHelper;diverseColumnLabel;renderMolIds=null;columnNames=[];computeCompleted=new u.Subject;sampledIndices=null;constructor(e){super("diversity",a.SEMTYPE.MACROMOLECULE),this.seqHelper=e,this.diverseColumnLabel=this.string("diverseColumnLabel",null)}async renderInt(e){if(this.beforeRender()&&this.dataFrame&&e&&this.targetColumn){await this.computeByMM();const e=null!=this.diverseColumnLabel?this.diverseColumnLabel:`diverse (${this.targetColumnName})`,t=a.Column.string(e,this.renderMolIds.length).init(e=>this.targetColumn?.get(this.renderMolIds[e]));t.semType=a.SEMTYPE.MACROMOLECULE,this.tags.forEach(e=>t.setTag(e,this.targetColumn.getTag(e)));const n=a.DataFrame.fromColumns([t]);t.temp[".mm.cellRenderer.maxMonomerLength"]=4,n.onCurrentRowChanged.subscribe(e=>{this.dataFrame.currentRowIdx=this.renderMolIds[n.currentRowIdx]});const i=n.plot.grid();(0,Oe.Kd)(i,t.name,450,30),(0,Oe.Ku)(this.root,i.root),this.computeCompleted.next(!0)}}async computeByMM(){const e=this.targetColumn.length;let t;this.requiresSampling&&e>1e4?(t=this.createRandomSample(e,1e4),this.sampledIndices=t):(t=Array.from({length:e},(e,t)=>t),this.sampledIndices=null);const n=this.distanceMetric,i=await pt(this.targetColumn,n,this.fingerprint,this.gapOpen,this.gapExtend),o=i.seqList,r=i.options,s=t.map(e=>o[e]),a=new G(!0,!1),l=await a.calc(s,n,!0,r);a.terminate();const c=t.length,u=(d=c,(e,t)=>d*e+t-Math.floor((e+2)*(e+1)/2)),h=function(e,t){function n(e,t){let n=null,i=null;for(const o of e){const e=t(o);(null==i||e>i)&&(n=o,i=e)}return n}const i=[(r=e-1,Math.floor(function(e){return Math.random()*e}(r)))],o=new Set;var r;for(let t=0;t<e;++t)i.includes(t)||o.add(t);for(;i.length<t;){const e=n(o.values(),e=>Math.min.apply(Math,i.map(function(t,n){return l[u(e,t)]})));null!=e&&(i.push(e),o.delete(e))}return i}(c,Math.min(c,this.limit));var d;this.renderMolIds=h.map(e=>t[e])}createRandomSample(e,t){const n=[];for(let t=0;t<e;t++)this.targetColumn.isNone(t)||n.push(t);if(n.length<=t)return n;for(let e=n.length-1;e>0;e--){const t=Math.floor(Math.random()*(e+1)),i=n[e];n[e]=n[t],n[t]=i}return n.slice(0,t)}}var Tt,Et=n(5433),_t=n(3890),It=n(1687);!function(e){e.TYPE="V2000",e[e.NUM_OF_HEADER_LINES=3]="NUM_OF_HEADER_LINES",e[e.NUM_OF_COUNTS_DIGITS=3]="NUM_OF_COUNTS_DIGITS",e[e.ATOM_TYPE_COL=4]="ATOM_TYPE_COL",e[e.FIRST_BONDED_ATOM_COL=1]="FIRST_BONDED_ATOM_COL",e[e.BOND_TYPE_COL=3]="BOND_TYPE_COL",e[e.RGP_SHIFT=8]="RGP_SHIFT",e[e.MAX_ATOM_COUNT=999]="MAX_ATOM_COUNT",e.RGP_LINE_START="M RGP",e.ATOM_ALIAS_LINE_START="A ",e.END="M END"}(Tt||(Tt={}));class Lt{constructor(e){this.init(e)}init(e){this.fileContent=e.replace(/\r/g,""),this._atomCount=void 0,this._atomTypes=void 0,this._bondCount=void 0,this._bondTypes=void 0,this.xyzAtomCoordinates=void 0,this._pairsOfBondedAtoms=void 0}get atomCount(){return void 0===this._atomCount&&this.setAtomAndBondCounts(),this._atomCount}get bondCount(){return void 0===this._bondCount&&this.setAtomAndBondCounts(),this._bondCount}get x(){var e;return null!==(e=this.xyzAtomCoordinates)&&void 0!==e||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.x}get y(){var e;return null!==(e=this.xyzAtomCoordinates)&&void 0!==e||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.y}get z(){var e;return null!==(e=this.xyzAtomCoordinates)&&void 0!==e||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.z}get atomTypes(){var e;return null!==(e=this._atomTypes)&&void 0!==e||(this._atomTypes=this.parseAtomTypes()),this._atomTypes}get pairsOfBondedAtoms(){var e;return null!==(e=this._pairsOfBondedAtoms)&&void 0!==e||(this._pairsOfBondedAtoms=this.parseBondedAtomPairs()),this._pairsOfBondedAtoms}get bondTypes(){var e;return null!==(e=this._bondTypes)&&void 0!==e||(this._bondTypes=this.parseBondTypes()),this._bondTypes}setAtomAndBondCounts(){const{atomCount:e,bondCount:t}=this.parseAtomAndBondCounts();this._atomCount=e,this._bondCount=t}getNextColumnIdx(e){for(;!this.isWhitespace(e);)++e;for(;this.isWhitespace(e);)++e;return e}shiftIdxToSpecifiedColumn(e,t){let n=e;const i=this.isWhitespace(n)?t:t-1;for(let e=0;e<i;e++)n=this.getNextColumnIdx(n);return n}parseAtomTypes(){const e=this.atomCount,t=new Array(e);let n=this.getAtomBlockIdx();for(let i=0;i<e;i++)n=this.shiftIdxToAtomType(n),t[i]=this.parseAtomType(n),n=this.getNextLineIdx(n);return t}parseAtomCoordinates(){const e=new Float32Array(this.atomCount),t=new Float32Array(this.atomCount),n=new Float32Array(this.atomCount);let i=this.getAtomBlockIdx();for(let o=0;o<this.atomCount;o++){i=this.shiftIdxToXColumn(i);for(const r of[e,t,n])r[o]=this.parseFloatValue(i),i=this.getNextColumnIdx(i);i=this.getNextLineIdx(i)}return{x:e,y:t,z:n}}parseBondedAtomPairs(){const e=new Array(this.bondCount);let t=this.getBondBlockIdx();for(let n=0;n<this.bondCount;n++){t=this.shiftIdxToBondedAtomsPair(t);const i=new Uint16Array(2);i[0]=this.parseIntValue(t),t=this.getNextColumnIdx(t),i[1]=this.parseIntValue(t),e[n]=i,t=this.getNextLineIdx(t)}return e}parseBondTypes(){const e=this.bondCount,t=new Uint16Array(e);let n=this.getBondBlockIdx();for(let i=0;i<e;i++)n=this.shiftIdxToBondType(n),t[i]=this.parseIntValue(n),n=this.getNextLineIdx(n);return t}isWhitespace(e){const t=this.fileContent[e];return" "===t||"\t"===t}getNextLineIdx(e){return"\n"!==this.fileContent[e]?this.fileContent.indexOf("\n",e)+1:e+1}parseFloatValue(e){return this.parseNumericValue(parseFloat,e)}parseIntValue(e){return this.parseNumericValue(parseInt,e)}parseNumericValue(e,t){let n=t+1;for(;!this.isWhitespace(n);)++n;return e(this.fileContent.substring(t,n))}}class Nt extends Lt{constructor(e){super(e),this.init(e)}init(e){super.init(e)}parseAtomType(e){let t=e,n=t;return this.isQuote(t)?(n=this.getNextIdenticalChar(t),t++):n=this.fileContent.indexOf(" ",n),this.fileContent.substring(t,n)}isQuote(e){const t=this.fileContent[e].charCodeAt(0);return 39===t||34===t}getNextIdenticalChar(e){const t=this.fileContent[e];return t?this.fileContent.indexOf(t,e+1):-1}isQuery(){return this.isQueryOrFragment((e,t)=>{return 39===e||34===e||76===e&&!((n=this.fileContent.charCodeAt(t+1))>64&&n<91||n>96&&n<123);var n})}isFragment(){return this.isQueryOrFragment(e=>82===e||42===e)}isQueryOrFragment(e){const t=this.atomCount;let n=this.getAtomBlockIdx();for(let i=0;i<t;i++){if(n=this.shiftIdxToAtomType(n),e(this.fileContent.charCodeAt(n),n))return!0;n=this.getNextLineIdx(n)}return!1}}class Pt extends Nt{constructor(e){super(e)}getAtomLines(){const e=this.getAtomBlockIdx(),t=this.getBondBlockIdx();return this.fileContent.substring(e,t).split("\n").slice(0,this.atomCount)}getBondLines(){const e=this.getBondBlockIdx();return this.fileContent.substring(e).split("\n").slice(0,this.bondCount)}getRGroupIdToAtomicIdxMap(){const e=new Map,t=this.fileContent.split("\n");t.filter(e=>e.startsWith(Tt.RGP_LINE_START)).forEach(t=>{const n=this.getAtomIdxToRgpIdxList(t);for(const[t,i]of n){if(e.has(t))throw new Error(`R group ${t} is already in the map`);e.set(t,i)}});const n=t.map((e,t)=>{if(e.startsWith(Tt.ATOM_ALIAS_LINE_START))return t}).filter(e=>void 0!==e),i=n.map(e=>t[e]),o=n.map(e=>t[e+1]);i.forEach((t,n)=>{const i=parseInt(t.split(/\s+/)[1])-1,r=parseInt(o[n].substring(1));if(e.has(r))throw new Error(`R group ${r} is already in the map`);e.set(r,i)});const r=this.getRGroupAtomicIndices().filter(t=>!Array.from(e.values()).includes(t));if(0!==r.length)throw new Error(`Unaccounted R group indices: ${r}`);return e}getAtomIdxToRgpIdxList(e){const t=e.split(/\s+/).filter(e=>e).slice(3).map(e=>parseInt(e)),n=new Array(t.length/2);for(let e=0;e<t.length;e+=2)n[e/2]=[t[e+1],t[e]-1];return n}getRGroupAtomicIndices(){return this.atomTypes.map((e,t)=>{if(e.includes("R#"))return t}).filter(e=>void 0!==e)}static isValidMolfile(e){return-1!==e.indexOf(Tt.TYPE)&&-1!==e.indexOf(Tt.END)}shiftIdxToAtomType(e){return this.shiftIdxToSpecifiedColumn(e,Tt.ATOM_TYPE_COL)}getCountsLineIdx(){let e=0;for(let t=0;t<Tt.NUM_OF_HEADER_LINES;++t)e=this.getNextLineIdx(e);return e}getAtomBlockIdx(){let e=this.getCountsLineIdx();return e=this.getNextLineIdx(e),e}shiftIdxToXColumn(e){return this.getNextColumnIdx(e)}shiftIdxToBondedAtomsPair(e){return this.shiftIdxToSpecifiedColumn(e,Tt.FIRST_BONDED_ATOM_COL)}shiftIdxToBondType(e){return this.shiftIdxToSpecifiedColumn(e,Tt.BOND_TYPE_COL)}getBondBlockIdx(){let e=this.getAtomBlockIdx();for(let t=0;t<this.atomCount;t++)e=this.getNextLineIdx(e);return e}parseAtomAndBondCounts(){let e=this.getCountsLineIdx(),t=e+Tt.NUM_OF_COUNTS_DIGITS;const n=parseInt(this.fileContent.substring(e,t));return e=t,t+=Tt.NUM_OF_COUNTS_DIGITS,{atomCount:n,bondCount:parseInt(this.fileContent.substring(e,t))}}}class Rt extends Nt{constructor(e){super(e),this.init(e)}getAtomLines(){const e=this.getAtomBlockIdx(),t=this.getBondBlockIdx();return this.fileContent.substring(e,t).split("\n").slice(0,this.atomCount)}getBondLines(){const e=this.getBondBlockIdx();return this.fileContent.substring(e).split("\n").slice(0,this.bondCount)}getRGroupIdToAtomicIdxMap(){const e=new Map;return this.getAtomLines().forEach((t,n)=>{const i=t.match(/RGROUPS=\(([\d\s]+)\)/);if(i){const t=i[1].split(/\s+/).map(e=>parseInt(e));if(t.length>2)throw new Error(`R group data ${t} has more than 2 elements`);const o=t[1];if(e.has(o))throw new Error(`R group ${o} is already in the map`);e.set(o,n)}}),e}shiftIdxToAtomType(e){return this.shiftIdxToSpecifiedColumn(e,4)}getCountsLineIdx(){return this.fileContent.indexOf("M V30 COUNTS ")}getAtomBlockIdx(){let e=this.fileContent.indexOf("M V30 BEGIN ATOM");return e=this.getNextLineIdx(e),e}shiftIdxToXColumn(e){let t=this.shiftIdxToAtomType(e);return this.isQuote(t)?(t=this.getNextIdenticalChar(t),t=this.getNextColumnIdx(t),t):this.shiftIdxToSpecifiedColumn(e,5)}shiftIdxToBondedAtomsPair(e){return this.shiftIdxToSpecifiedColumn(e,5)}shiftIdxToBondType(e){return this.shiftIdxToSpecifiedColumn(e,4)}getBondBlockIdx(){return this.getNextLineIdx(this.fileContent.indexOf("M V30 BEGIN BOND"))}static isValidMolfile(e){return-1!==e.indexOf("V3000")&&-1!==e.indexOf("M END")}parseAtomAndBondCounts(){let e=this.fileContent.indexOf("M V30 COUNTS ")+14,t=this.fileContent.indexOf(" ",e+1);const n=parseInt(this.fileContent.substring(e,t));return e=t+1,t=this.fileContent.indexOf(" ",e+1),{atomCount:n,bondCount:parseInt(this.fileContent.substring(e,t))}}}class $t{constructor(){}static getInstance(e){if($t.isMolfileV2K(e))return new Pt(e);if($t.isMolfileV3K(e))return new Rt(e);throw new Error("Malformed molfile")}static isMolfileV2K(e){return Pt.isValidMolfile(e)}static isMolfileV3K(e){return Rt.isValidMolfile(e)}}var Ot=n(6197),kt=n(9124),Ht=n(3527);class Bt{biotype;id;n;m;type;mt;smiles;get issmiles(){return!!this.smiles}at={R1:"H",R2:"H",R3:"H",R4:"H",R5:"H",R6:"H",R7:"H",R8:"H",R9:"H"};get rs(){return Object.keys(this.at).length}constructor(e,t,n="missing",i=void 0,o=void 0,r=void 0,s){if(this.biotype=e,this.id=t,this.n=n,this.m=i,this.type=o,this.mt=r,this.smiles=s,!this.id)throw new Error("Invalid arg undefined [id].")}static objCounter=-1;objId=++Bt.objCounter;className="WebEditorMonomerDummy";toLog(){return`Helm: ${this.className}<${this.objId}>`}}class Ft extends Bt{backgroundcolor="#808080";linecolor="#000000";textcolor="#000000";constructor(e,t,n,i,o){super(e,t,i,void 0,void 0,void 0,n),this.at={},o.forEach(e=>{this.at[e]="H"})}}class Gt extends Bt{backgroundcolor="#FFFFFF";linecolor="#808080";textcolor="#808080";constructor(e){super(e,"*","gap")}}class Dt extends Bt{backgroundcolor="#808080";linecolor="#000000";textcolor="#000000";constructor(e,t){super(e,t,"ambiguous")}}class Vt extends Bt{backgroundcolor="#FF4444";linecolor="#800000";textcolor="#FFFFFF";constructor(e,t,n){super(e,t,"missing"),n&&(this.backgroundcolor="#C0C0C0",this.linecolor="#404040",this.textcolor="#404040")}}class Wt extends Bt{backgroundcolor="#FFFF44";linecolor="#800000";textcolor="#000000";constructor(e,t){super(e,t,"broken")}}class jt{id;m;n;na;type;mt;at;smiles;get rs(){return Object.keys(this.at).length}get issmiles(){return!!this.smiles}linecolor;backgroundcolor;textcolor;constructor(e,t,n,i,o,r,s,a){this.id=e,this.m=t,this.n=n,this.na=i,this.type=o,this.mt=r,this.at=s,this.smiles=a}static fromMonomer(e,t,n){let i={};const o=t.symbol,r=t.smiles;if(t.rgroups.length>0)t.rgroups.forEach(e=>{i[e.label]=e.capGroupName});else{if(!r){if(t.lib)return new Wt(e,o);throw new Error("Unexpected missing monomer without .lib")}i=n.getRS(r)}const s=new jt(t.symbol,t.molfile,t.name,t.naturalAnalog,t.polymerType,t.monomerType,i),a=n.getMonomerColors(e,t.symbol);return a&&(s.textcolor=a?.textcolor,s.linecolor=a?.linecolor,s.backgroundcolor=a?.backgroundcolor),s}}const Ut={[De.o.BASE]:{A:"#20E040",G:"#040404",T:"#FF8080",C:"#2060FF",U:"#FF8080"},[De.o.NUCLEOTIDE]:{A:"#20E040",G:"#040404",T:"#FF8080",C:"#2060FF",U:"#FF8080"},[De.o.LINKER]:{P:"#9aa5e1",p:"#9aa5e1"},[De.o.SUGAR]:{R:"#7a85c1",r:"#7a85c1"},[De.o.AA]:{A:"rgb(44,160,44)",R:"rgb(23,190,207)",N:"rgb(235,137,70)",D:"rgb(31,119,180)",C:"rgb(188,189,34)",E:"rgb(31, 120, 150)",Q:"rgb(205, 111, 71)",G:"rgb(214,39,40)",H:"rgb(158,218,229)",I:"rgb(23,103,57)",L:"rgb(30,110,96)",K:"rgb(108, 218, 229)",M:"rgb(60,131,95)",F:"rgb(24,110,79)",P:"rgb(255,152,150)",S:"rgb(255,187,120)",T:"rgb(245,167,100)",W:"rgb(182, 223, 138)",Y:"rgb(152,223,138)",V:"rgb(74,160,74)"},[De.o.CHEM]:{R:"#eeeeee"},[De.o.BLOB]:{B:"#999999",G:"#e2e2e2"}};class qt{constructor(e,t=[],n={}){this.onItemChanged=new u.Subject,this.onAddingItemChanged=new u.Subject,this.onItemAdded=new u.Subject,this.onItemRemoved=new u.Subject,this.options={removeButtonTooltip:"Remove item",addButtonTooltip:"Add item",allowAdd:!0,allowRemove:!0},this.addingItemInputs={},this.properties=e,this.options=Object.assign(Object.assign({},this.options),n),this._root=s.divV([],{style:{display:"grid",gridTemplateColumns:`repeat(${this.properties.length}, 1fr)`,alignItems:"center",gap:"12px"},classes:"ui-items-grid"}),this._items=t,this.render()}get root(){return this._root}get items(){return this._items}set items(e){this._items=e,this.render()}addItem(e,t=!0){this._items.push(e),this.render(),t&&this.onItemAdded.next(e)}removeItem(e,t=!0){-1!==this._items.indexOf(e)&&(this._items.splice(this._items.indexOf(e),1),this.render(),t&&this.onItemRemoved.next(e))}removeAtIndex(e,t=!0){if(e<0||e>=this._items.length)return;const n=this._items.splice(e,1);this.render(),t&&this.onItemRemoved.next(n[0])}removeAllItems(){this._items=[],this.render()}render(){var e,t,n,i,o;if(s.empty(this._root),!this.options.horizontalInputNames)for(const n of this.properties){let i=null!==(e=n.caption)&&void 0!==e?e:n.name;(null===(t=this.options.customLabels)||void 0===t?void 0:t[n.name])&&(i=this.options.customLabels[n.name]);const o=s.divText(i);o.style.fontWeight="bold",this._root.appendChild(o)}for(const e of this._items){const t=this.getItemDiv(e);for(const e of t)this._root.appendChild(e)}if(this.options.allowAdd){const e=this.getItemDiv(null!==(o=null===(i=(n=this.options).newItemFunction)||void 0===i?void 0:i.call(n))&&void 0!==o?o:void 0,!0);for(const t of e)this._root.appendChild(t)}}get addingItem(){const e={};return Object.keys(this.addingItemInputs).forEach(t=>{e[t]=this.addingItemInputs[t].value}),e}getItemDiv(e={},t){var n,i;const o=[],r={};let l=null;for(const c of this.properties){void 0===e[c.name]&&(e[c.name]=null);const u=(null===(n=this.options.customInputs)||void 0===n?void 0:n[c.name])?this.options.customInputs[c.name](e):s.input.forProperty(c,e),h=null===(i=this.options.validators)||void 0===i?void 0:i[c.name];h&&u.addValidator(h),o.push(this.options.horizontalInputNames?u.root:this.hideLabel(u.root)),c.propertyType!==a.TYPE.BOOL&&"color"!==c.name.toLowerCase()&&u.input&&(u.input.style.width="100%"),r[c.name]=u,u.onChanged.subscribe(()=>{e[c.name]=u.value,t?this.onAddingItemChanged.next({item:e,fieldName:c.name}):this.onItemChanged.next({item:e,fieldName:c.name})}),u.root.style.alignItems="center",l=u}let c=null;if(t)this.addingItemInputs=r,c=s.icons.add(()=>{const e=this.options.newItemFunction?this.options.newItemFunction():{};Object.keys(r).forEach(t=>{e[t]=r[t].value}),this._items.push(e),this.onItemAdded.next(e),this.render()},this.options.addButtonTooltip);else{if(!this.options.allowRemove)return o;c=s.icons.delete(()=>{this._items.splice(this._items.indexOf(e),1),this.onItemRemoved.next(e),this.render()},this.options.removeButtonTooltip)}return l&&l.addOptions?l.addOptions(c):null==l||l.root.appendChild(c),c.style.color="#2083d5",o}hideLabel(e){return e.getElementsByTagName("label")[0]&&e.removeChild(e.getElementsByTagName("label")[0]),e}hasErrors(){return this._root.querySelectorAll(".d4-invalid").length>0}}const zt={A:new j.A(new Uint32Array([2,0,0,0,16,0,0,0,134217728,0,0,0,32,0,33554432,0,0,0,0,0,1024,0,0,0,262144,128,0,0,0,0,0,0,0,2,0,0,524288,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1048576,0,536870912,0,0,0,0]),2048),C:new j.A(new Uint32Array([2,0,65536,0,0,0,0,32,0,0,2,0,32,0,0,0,0,0,0,0,1024,0,0,0,262144,128,0,0,0,0,0,0,0,65536,0,0,524288,0,0,0,0,0,0,0,524288,524288,0,0,0,0,0,0,0,0,0,0,0,34603008,0,536870912,64,0,0,0]),2048),D:new j.A(new Uint32Array([2,0,65600,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,1024,0,0,0,262400,128,0,0,0,0,0,0,0,0,0,2097152,524288,0,0,0,1024,0,0,0,524288,0,0,0,0,0,0,0,0,0,512,0,0,34603008,0,536870912,0,0,0,0]),2048),E:new j.A(new Uint32Array([2,0,65536,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,1024,0,0,8,262144,128,0,0,16,134217728,0,0,0,0,0,0,524288,0,0,0,128,0,0,0,524288,0,0,0,268435456,0,0,0,0,0,512,2147483648,0,34603008,0,536870912,0,0,0,0]),2048),F:new j.A(new Uint32Array([2,0,98304,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,1024,0,0,0,262144,128,33554432,0,0,0,0,33554432,0,1024,1,0,524288,32768,32,0,0,0,0,16,524288,0,0,0,0,0,0,0,0,0,71303168,0,0,34603008,131072,536870912,0,0,0,0]),2048),G:new j.A(new Uint32Array([134217728,0,65536,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,1024,0,0,0,0,128,0,0,0,0,2097216,0,0,0,0,0,524288,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,512,0,0,0,0,536870912,0,0,0,0]),2048),H:new j.A(new Uint32Array([2,0,1073840128,0,0,0,0,0,0,0,0,67108864,32,0,0,0,0,0,0,0,1024,0,512,0,262144,192,0,268435456,0,0,8200,0,0,0,67108864,0,524296,0,32,0,0,0,0,16,524288,0,0,2147483648,0,0,8,0,0,0,0,0,0,34603008,131072,536870920,4194304,0,0,0]),2048),I:new j.A(new Uint32Array([2,0,65536,0,0,0,0,0,150994944,64,0,0,32,0,0,0,0,0,0,0,1024,0,8388608,0,327680,128,0,0,0,0,0,0,0,2,0,524288,524288,0,0,0,0,0,0,0,0,0,0,0,256,0,0,0,0,8388608,0,33554432,0,1048576,0,536870912,0,0,0,0]),2048),K:new j.A(new Uint32Array([2,0,65536,0,0,0,0,0,0,0,0,0,268435488,0,0,0,0,0,0,0,1024,0,0,8,262144,128,0,0,0,0,2097152,0,0,67108864,0,0,524288,0,0,0,8,0,0,0,524288,0,0,8192,0,0,0,0,0,0,0,2147483648,0,34668544,0,545259520,0,0,0,0]),2048),L:new j.A(new Uint32Array([2,0,65536,0,0,0,0,0,134217728,0,0,0,32,512,0,0,0,0,0,0,1024,256,0,8388608,262400,128,0,0,0,0,0,0,0,2,0,0,524288,0,0,0,0,0,0,0,524288,0,0,0,0,0,0,0,0,0,0,0,0,42991616,0,536870912,0,0,0,0]),2048),M:new j.A(new Uint32Array([2050,0,65536,1048576,0,0,0,0,0,0,0,0,1056,0,0,0,0,0,0,0,1024,0,0,8,262144,128,0,0,0,0,0,536870912,0,2,0,0,1074266112,0,0,0,0,0,0,0,524288,0,0,0,4194304,0,0,0,0,0,0,2147483648,0,34603008,0,536870912,4194304,0,0,0]),2048),N:new j.A(new Uint32Array([2,0,65536,0,4096,0,0,0,0,0,0,16777216,32,0,0,0,0,0,0,0,1024,0,0,0,262400,128,0,0,0,0,0,0,0,0,0,0,524288,0,0,0,1024,0,0,0,524288,0,0,0,0,0,0,0,0,0,0,0,0,34603008,0,536871936,67108864,0,0,0]),2048),P:new j.A(new Uint32Array([0,0,1024,0,0,0,0,0,0,131072,0,1024,32,0,0,0,0,512,0,0,1024,0,0,64,0,128,0,0,1073741824,0,0,138412032,16,0,67108864,0,0,0,0,0,0,8192,0,0,8388608,0,0,8,0,0,0,0,0,0,256,0,0,0,0,553648128,0,0,0,0]),2048),Q:new j.A(new Uint32Array([2,0,65536,0,4096,0,0,0,0,0,0,0,32,0,0,0,0,2,0,0,1024,0,0,8,262144,128,0,0,16,0,0,0,0,0,0,0,524288,0,0,0,0,0,0,0,524288,0,0,0,268435456,0,0,0,0,0,16777216,2147483648,0,34603008,0,536871936,0,0,0,0]),2048),R:new j.A(new Uint32Array([2,0,65536,0,4096,0,32,0,0,0,0,0,268435488,0,0,0,0,0,0,32768,134218752,0,16,8,262144,128,0,1073741824,0,0,8388608,0,0,0,65536,0,524289,0,0,0,0,0,0,0,524288,2048,0,0,0,0,0,0,0,0,0,2147483648,0,34603008,1048576,545259520,0,0,0,0]),2048),S:new j.A(new Uint32Array([2,0,65536,0,0,0,1073741824,0,0,0,0,0,32,0,0,4,0,0,0,0,1024,0,0,0,262144,128,0,0,0,0,0,0,0,0,0,0,524288,0,0,1048576,0,0,0,0,524288,0,0,0,0,0,0,0,0,0,8388608,0,0,34603008,0,536870912,0,0,0,0]),2048),T:new j.A(new Uint32Array([2,0,0,0,0,0,0,8,134217728,0,0,67108864,32,0,0,0,0,0,0,0,1024,0,8388608,0,262144,128,0,0,0,0,0,0,0,2,0,524288,524288,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,536870912,0,0,0,0,1048576,67108864,536870912,0,0,0,0]),2048),V:new j.A(new Uint32Array([2,0,0,0,0,0,0,0,134217728,0,0,0,32,0,0,0,0,0,0,0,1024,0,8388608,0,262144,128,0,0,0,0,0,1073741824,128,2,0,524288,524288,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8192,0,1048576,0,536870912,0,0,0,0]),2048),W:new j.A(new Uint32Array([2,0,98304,8388608,0,0,0,0,0,0,256,4096,32,0,0,0,0,0,0,0,1024,0,0,0,262144,192,0,0,0,0,0,0,0,0,67108865,0,524288,32768,32,0,0,0,8224,16,524288,0,0,0,0,32,128,0,2097152,0,4194304,8388608,0,34603008,8519680,536870912,131072,262144,0,0]),2048),Y:new j.A(new Uint32Array([2,0,98304,0,0,0,0,0,0,4194304,0,0,32,0,0,0,0,0,0,0,1024,0,0,512,262144,128,33554432,0,0,0,0,33554432,0,0,0,0,524288,0,32,0,0,2,0,16,524288,0,0,0,0,0,4,0,0,0,71303168,262144,0,34603008,131072,536870912,0,0,0,0]),2048)},Yt={RNA:{A:new j.A(new Uint32Array([0,0,0,0,0,0,0,0,0,1024,0,67108864,0,0,0,512,0,0,0,8388608,0,0,512,0,0,64,4,0,0,0,4,0,0,0,67108864,0,524289,0,0,0,0,0,0,16,0,659456,0,256,0,16,0,0,0,268435456,0,0,262144,0,131072,0,0,0,8388608,0]),2048),C:new j.A(new Uint32Array([0,1073741824,0,0,0,0,0,2147483648,4,67108864,0,67108864,0,256,0,0,0,0,0,0,1024,0,128,0,0,64,0,0,0,0,0,0,0,0,67108864,0,524289,0,65536,0,0,0,0,16,0,131072,0,4,0,0,0,0,0,0,4194304,0,0,2147483648,131072,0,4096,0,0,0]),2048),G:new j.A(new Uint32Array([0,0,0,0,1024,0,0,0,0,67109888,16384,67108864,0,0,0,0,0,0,0,33562624,1024,33554432,512,16384,0,64,4,0,0,33554432,0,0,0,0,67108864,0,524289,0,0,0,0,0,0,16,0,135168,0,268435456,0,0,0,0,0,268435456,131072,0,0,2147483648,131072,0,0,0,8388608,0]),2048),T:new j.A(new Uint32Array([8388608,0,0,0,0,0,0,0,0,67108864,0,0,0,4,0,0,0,0,0,0,1024,0,0,16384,0,64,0,0,0,0,0,0,0,2,67108864,0,0,0,0,0,0,0,0,40976,0,0,0,0,0,0,0,0,0,67108864,131072,524288,0,0,8519680,0,1,33554432,1048576,0]),2048),U:new j.A(new Uint32Array([0,0,131072,1073741824,0,0,0,0,0,67108864,0,0,0,0,0,0,0,0,0,0,1024,0,128,0,0,64,0,0,0,0,0,0,0,32768,67108864,0,0,0,0,0,0,0,0,16,0,0,0,4,0,0,2048,0,0,0,4341760,0,0,0,131072,0,0,33554432,1048576,0]),2048)},PEPTIDE:zt};async function Kt(e,t,n=0){if(!Object.keys(Yt).includes(t))return null;const i=await async function(e){const t=a.Func.find({package:"Chem",name:"getMorganFingerprint"})?.[0];if(!t)return null;try{const n=(await t.apply({molString:e}))?.getBuffer().buffer;if(n)return new j.A(new Uint32Array(n),2048)}catch(e){return null}}(e);if(!i)return null;if(!Yt[t])return null;const o=Yt[t];let r=0,s=null;for(const[e,t]of Object.entries(o)){const o=(0,H.$1)(i,t);o>r&&o>=n&&(r=o,s=e)}return s}var Zt,Xt=n(857),Jt={};Jt.styleTagTransform=S(),Jt.setAttributes=b(),Jt.insert=g().bind(null,"head"),Jt.domAPI=m(),Jt.insertStyleElement=w(),d()(Xt.A,Jt),Xt.A&&Xt.A.locals&&Xt.A.locals,function(e){e.MONOMER="Monomer",e.SYMBOL="Symbol",e.NAME="Name",e.R_GROUPS="~R-Groups",e.MONOMER_TYPE="Monomer Type",e.POLYMER_TYPE="Polymer Type",e.NATURAL_ANALOG="Natural Analog",e.AUTHOR="Author",e.CREATE_DATE="Create Date",e.ID="ID",e.META="Meta",e.SOURCE="Source"}(Zt||(Zt={}));const Qt={[Zt.MONOMER]:a.COLUMN_TYPE.STRING,[Zt.SYMBOL]:a.COLUMN_TYPE.STRING,[Zt.NAME]:a.COLUMN_TYPE.STRING,[Zt.R_GROUPS]:a.COLUMN_TYPE.STRING,[Zt.MONOMER_TYPE]:a.COLUMN_TYPE.STRING,[Zt.POLYMER_TYPE]:a.COLUMN_TYPE.STRING,[Zt.NATURAL_ANALOG]:a.COLUMN_TYPE.STRING,[Zt.AUTHOR]:a.COLUMN_TYPE.STRING,[Zt.CREATE_DATE]:a.COLUMN_TYPE.DATE_TIME,[Zt.ID]:a.COLUMN_TYPE.INT,[Zt.META]:a.COLUMN_TYPE.STRING,[Zt.SOURCE]:a.COLUMN_TYPE.STRING};async function en(e){const t=await tn(e);if(e.length!==t.rowCount)throw new Error(`Monomers length ${e.length} does not match dataframe row count ${t.rowCount}`);return await Promise.all(new Array(e.length).fill(null).map(async(e,n)=>dn(t.rows.get(n))))}async function tn(e){try{const t=a.DataFrame.create(e.length),n=new Set;for(const t of e)t.rgroups.forEach(e=>{e.label&&n.add(e.label)});const i=Array.from(n);i.sort();for(const[e,n]of Object.entries(Qt))if(t.columns.addNew(e,n),e===Zt.R_GROUPS)for(const e of i)t.columns.addNew(e,a.COLUMN_TYPE.STRING);t.col(Zt.SYMBOL).semType="Monomer",t.col(Zt.SYMBOL).setTag(ke.Mn.applyToBackground,"true"),t.col(Zt.SYMBOL).setTag(ve.qE.polymerTypeColumnName,Zt.POLYMER_TYPE);const o=a.TaskBarProgressIndicator.create("Creating Monomers DataFrame...");for(let n=0;n<e.length;n++){n%20==0&&o.update((n+1)/e.length*100,"Creating Monomers DataFrame...");const r=()=>{let o=cn(e[n].rgroups,e[n].smiles,e[n].molfile);o=on(o),e[n].rgroups=an(e[n].rgroups);const r=i.map(t=>{const i=e[n].rgroups.find(e=>e.label===t);return i?sn(i,"capGroupSmiles"):""});let s=null;if(e[n].createDate)try{s=Date.parse(e[n].createDate)}catch(t){console.error(`Error parsing date ${e[n].createDate}`)}t.rows.setValues(n,[o,e[n].symbol,e[n].name,JSON.stringify(e[n].rgroups??[]),...r,e[n].monomerType,e[n].polymerType,e[n].naturalAnalog,e[n].author,s,e[n].id,JSON.stringify(e[n].meta??{}),e[n].lib?.source??""],!1);try{s&&t.col(Zt.CREATE_DATE)?.set(n,s,!1)}catch(t){console.error(`Error setting date ${e[n].createDate}`,t)}};await new Promise(e=>{const t=()=>{try{r(),e()}catch(t){console.error("Error in doFill",t),e()}};n%20==0?setTimeout(()=>{t()}):t()})}return o.close(),t.col(Zt.MONOMER).semType=a.SEMTYPE.MOLECULE,i.forEach(e=>{t.col(e).semType=a.SEMTYPE.MOLECULE}),t}catch(e){throw r.shell.error("Error creating monomers dataframe"),console.error(e),e}}class nn{monomerLibManamger;adjustTable(){this.tv?.dataFrame&&(r.data.detectSemanticTypes(this.tv.dataFrame),this.tv.dataFrame.meta.detectSemanticTypes()),setTimeout(()=>{this.tv?.grid&&(this.tv.grid.props.allowEdit=!1,this.tv.grid.col(Zt.NAME).width=100,this.tv.grid.col(Zt.SYMBOL).width=70)},200)}static VIEW_NAME="Manage Monomers";_newMonomer=ge.pe;_newMonomerForm;monomerLib;tv=null;libInput;static instance;activeMonomerLib=null;constructor(e){this.monomerLibManamger=e,this.monomerLib=e.getBioLib(),this._newMonomerForm=new ln(e,()=>this.activeMonomerLib,async e=>{const t=await this.getMonomersDf(this.libInput.value);this.tv?.dataFrame&&(this.tv.dataFrame=t,this.adjustTable(),null!=e&&setTimeout(()=>{const n=t.col(Zt.SYMBOL).toList().indexOf(e);-1!==n&&(this.tv?.grid.scrollToCell(t.columns.byIndex(0),n),t.currentRow=t.rows.get(n))},500))},()=>this.tv?.dataFrame)}static async getInstance(){if(!this.instance){const e=await Hn.getInstance();await e.awaitLoaded(),this.instance=new nn(e)}return this.instance}static async getNewInstance(){const e=await Hn.getInstance();return await e.awaitLoaded(),new nn(e)}async createNewMonomerLib(e,t,n){this.tv?.grid&&s.setUpdateIndicator(this.tv.grid.root,!0);try{const i=(await this.monomerLibManamger.getProviders()).find(t=>t.name===e);if(!i)throw new Error(`Provider ${e} not found`);const o=n.map(e=>({...e,lib:void 0,wem:void 0}));await i.addOrUpdateLibrary(t,o),await this.monomerLibManamger.loadMonomerLib(!1),r.shell.v=await this.getViewRoot(t)}catch(e){r.shell.error("Error creating library"),console.error(e)}finally{this.tv?.grid&&s.setUpdateIndicator(this.tv.grid.root,!1)}}async createNewLibDialog(e){const t=await this.monomerLibManamger.getAvaliableLibraryNames(),n=s.input.string("Library Name",{placeholder:"Enter library name",nullable:!1,onValueChanged:()=>{const e=i(n.value);l.getButton("Create")?.classList?.toggle("d4-disabled",!!e)}});function i(e){return e&&e.trim()?t.includes(e)||t.includes(e+".json")?"Library with this name already exists":null:"Library name cannot be empty"}n.addValidator(i);const o=(await this.monomerLibManamger.getProviders()).map(e=>e.name),a=s.input.choice("Storage",{items:o,value:o[0],nullable:!1,tooltipText:"Select storage provider for the new library"});1===o.length&&(a.readOnly=!0);const l=s.dialog("Create New Library").add(a).add(n).addButton("Create",async()=>{const t=i(n.value);if(t)r.shell.warning(t);else if(a.value){try{await this.createNewMonomerLib(a.value,n.value,e??[])}catch(e){r.shell.error("Error creating library"),console.error(e)}l.close()}else r.shell.warning("Please select storage provider")}).show();l.getButton("Create")?.classList?.toggle("d4-disabled",!0)}get newMonomer(){return this._newMonomer}getNewMonomerForm(){return this._newMonomerForm}_contextMenuSub=null;async getMonomersTableView(e,t=!0){const n=await this.getMonomersDf(e);return this.tv=a.TableView.create(n,t),this.adjustTable(),this._contextMenuSub?.unsubscribe(),this._contextMenuSub=r.events.onContextMenu.subscribe(({args:e})=>{if(!e||!e.menu||!e.context||e.context.type!==a.VIEWER.GRID||!e.context.tableView||e.context.tableView.id!==(this.tv.id??"")||!e.item||!e.item.isTableCell||(e.item.tableRowIndex??-1)<0)return;const t=e.item.tableRowIndex;e.menu.item("Edit Monomer",async()=>{await this.editMonomer(this.tv.dataFrame.rows.get(t))}),e.menu.item("Fix all monomers",()=>{this.fixAllMonomers()}),this.tv.dataFrame.selection.trueCount>0?(e.menu.item("Remove Selected Monomers",async()=>{const e=await Promise.all(Array.from(this.tv.dataFrame.selection.getSelectedIndexes()).map(e=>dn(this.tv.dataFrame.rows.get(e))));this._newMonomerForm.removeMonomers(e,this.libInput.value)}),e.menu.item("Selection To New Library",async()=>{const e=await Promise.all(Array.from(this.tv.dataFrame.selection.getSelectedIndexes()).map(e=>dn(this.tv.dataFrame.rows.get(e))));this.createNewLibDialog(e)})):e.menu.item("Remove Monomer",async()=>{const e=await dn(this.tv.dataFrame.rows.get(t));this._newMonomerForm.removeMonomers([e],this.libInput.value)})}),this.tv.grid&&(this.tv.grid.props.allowEdit=!1),this.tv}static closeAllMonomerManagers(){Array.from(r.shell.tableViews??[]).filter(e=>e.name===nn.VIEW_NAME).forEach(e=>e.close())}findActiveManagerView(){if(!this.tv)return null;const e=Array.from(r.shell.tableViews??[]).find(e=>e.id===this.tv.id);return e?r.shell.v=e:nn.closeAllMonomerManagers(),e??null}_skipLibInputOnchange=!1;async getViewRoot(e,t=!0){const n=await this.monomerLibManamger.getAvaliableLibraryNames();if(this._newMonomerForm.molSketcher.resize(),t&&(this.tv=this.findActiveManagerView())&&(e??this.libInput.value)){try{this._skipLibInputOnchange=!0,this.libInput&&(this.libInput.items=n),e&&(this.libInput.value=e)}catch(e){r.shell.error("Error updating library list"),console.error(e)}finally{this._skipLibInputOnchange=!1}const t=await this.getMonomersDf(e);return this.tv.dataFrame=t,this.adjustTable(),this.tv}e??=n[0],this.tv=await this.getMonomersTableView(e,t);let i=this.tv.getRibbonPanels();i.forEach((e,t)=>{i[t]=e.filter(e=>0!==e.getElementsByClassName("grok-icon-filter").length)}),i=i.filter(e=>e.length>0);const o=s.icons.add(()=>{this._newMonomerForm.setEmptyMonomer()},"Add New Monomer"),l=s.iconFA("wand-magic",()=>{this.fixAllMonomers()},"Fix all monomers"),c=s.icons.edit(async()=>{(this.tv?.dataFrame?.currentRowIdx??-1)<0||await this.editMonomer(this.tv.dataFrame.rows.get(this.tv.dataFrame.currentRowIdx))},"Edit Monomer"),u=s.icons.delete(async()=>{const e=this.tv?.dataFrame?.currentRowIdx??-1,t=Array.from(this.tv?.dataFrame?.selection?.getSelectedIndexes()??[]);if(e<0&&0===t.length)return;if(t.length>0){const e=await Promise.all(t.map(e=>dn(this.tv.dataFrame.rows.get(e))));return void await this._newMonomerForm.removeMonomers(e,this.libInput.value)}const n=await dn(this.tv.dataFrame.rows.get(e));await this._newMonomerForm.removeMonomers([n],this.libInput.value)});s.tooltip.bind(u,()=>(this.tv?.dataFrame?.selection?.trueCount??0)>0?"Delete selected monomers":"Delete monomer");const h=s.iconFA("arrow-to-bottom",async()=>{const e=this.libInput.value;if(!e)return r.shell.error("No library selected");let t=null;try{const n=await(0,we.pY)(await this.monomerLibManamger.getProviders(),e);if(!n)throw new Error(`Library ${e} not found in any provider`);t=await n.getLibraryAsString(e)}catch(t){return r.shell.error(`Error reading library ${e}`),console.error(t)}if(!t)return r.shell.error(`Library ${e} is empty`);a.Utils.download(e,t,"text/plain")},"Download Monomer Library");i.push([o,c,l,u,h]),this.tv.setRibbonPanels(i),this.tv.name=nn.VIEW_NAME,this.libInput=s.input.choice("Monomer Library",{value:e,items:n,nullable:!1,onValueChanged:async()=>{try{if(this._skipLibInputOnchange)return;const e=await this.getMonomersDf(this.libInput.value);this.tv.dataFrame=e,this.adjustTable()}catch(e){console.error(e)}}}),this.libInput.addOptions(s.icons.add(()=>{this.createNewLibDialog()},"Create new monomer library..."));const d=this._newMonomerForm.form;return d.prepend(this.libInput.root),s.tools.waitForElementInDom(this.tv.root).then(()=>{this.tv.dockManager.dock(d,a.DOCK_TYPE.LEFT,null,void 0,.4)}),this.tv}async editMonomer(e){return this._newMonomer=await dn(e),this._newMonomerForm.setMonomer(this._newMonomer),this._newMonomer}async getMonomersDf(e){this.tv?.grid&&s.setUpdateIndicator(this.tv.grid.root,!0);try{let t=null;const n=await this.monomerLibManamger.getProviders();if(0===n.length)throw new Error("No monomer library providers available");if(e){if(t=await(0,we.pY)(n,e),!t)throw new Error(`Library ${e} not found in any provider`)}else t=n[0],e=(await t.listLibraries())[0];if(this.activeMonomerLib=await this.monomerLibManamger.readSingleLibrary(t.name,e),!this.activeMonomerLib)return r.shell.error(`Library ${e} not found`),a.DataFrame.create();const i=this.activeMonomerLib.getPolymerTypes().flatMap(e=>this.activeMonomerLib.getMonomerSymbolsByType(e).map(t=>this.activeMonomerLib.getMonomer(e,t)));return await tn(i)}catch(e){throw r.shell.error("Error creating monomers dataframe"),console.error(e),e}finally{this.tv?.grid&&s.setUpdateIndicator(this.tv.grid.root,!1)}}async fixAllMonomers(){s.dialog("Fix All Monomers").add(s.divText("This action will fix all monomers in the library, standardize their smiles, molblocks and r-groups, assign correct natural analogs and save the library.")).add(s.divText("Do you wish to continue?")).onOK(async()=>{const e=this.tv?.dataFrame,t=this.libInput.value;if(e&&t){this.tv?.grid&&s.setUpdateIndicator(this.tv.grid.root,!0);try{const n=await(0,we.pY)(await this.monomerLibManamger.getProviders(),t);if(!n)throw new Error(`Library ${t} not found in any provider`);const i=(await Promise.all(new Array(e.rowCount).fill(0).map((t,n)=>dn(e.rows.get(n))))).map(e=>({...e,lib:void 0,wem:void 0}));await n.addOrUpdateLibrary(t,i),await this.monomerLibManamger.loadMonomerLib(!0),r.shell.v=await this.getViewRoot(t)}catch(e){r.shell.error("Error saving library"),console.error(e)}finally{this.tv?.grid&&s.setUpdateIndicator(this.tv.grid.root,!1)}}else r.shell.error("No monomer library loaded")}).show()}resetCurrentRowFollowing(){this._newMonomerForm.molChanged=!1}}function on(e){let t=e.replaceAll(/\[R[1-9]\]/g,e=>`[*:${e[2]}]`);return t=t.replaceAll(/\[\d\*\]/g,e=>`[*:${e[1]}]`),t.replaceAll(/\[\d\*\:\d\]/g,e=>`[*:${e[1]}]`)}const rn=["alternateId","capGroupName","capGroupSMILES","label"];function sn(e,t){const n=Object.keys(e).find(e=>e.toLowerCase()===t.toLowerCase());if(n)return e[n]}function an(e){return e.map(e=>{const t=function(e,t){const n={};return e.forEach(e=>{const i=Object.keys(t).find(t=>t.toLowerCase()===e.toLowerCase());i&&(n[e]=t[i])}),n}(rn,e),n=sn(t,"capGroupSMILES"),i=sn(t,"alternateId"),o=sn(t,"capGroupName"),r=sn(t,"label")??"R1";if(n&&i&&o||r.length<2)return t;if(i&&-1!==i.indexOf(`${r}-`)){const e=i.replace(`${r}-`,"");o||(t.capGroupName=e),n||(t.capGroupSMILES=`[*:${r.substring(1)}][${e}]`)}else o&&(n||(t.capGroupSMILES=`[*:${r.substring(1)}][${o}]`),i||(t.alternateId=`${r}-${o}`));return t}).sort((e,t)=>e.label?.localeCompare(t.label??"")??0)}class ln{monomerLibManager;getMonomerLib;refreshTable;getMonomersDataFrame;molSketcher;monomerTypeInput;polymerTypeInput;monomerSymbolInput;monomerNameInput;monomerIdInput;monomerNaturalAnalogInput;rgroupsGrid;metaGrid;colors;colorsEditor;saveButton;rgroupsGridRoot;_molChanged=!1;get molChanged(){return this._molChanged}set molChanged(e){this._molChanged=e}saveValidationResult=null;triggerMolChange=!0;inputsTabControl;constructor(e,t,n,i){this.monomerLibManager=e,this.getMonomerLib=t,this.refreshTable=n,this.getMonomersDataFrame=i,this.colors={line:"#000000",background:"#000000",text:"#000000"},this.colorsEditor=new pn(this.colors),this.molSketcher=new a.chem.Sketcher,this.molSketcher.root.classList.add("monomer-manager-sketcher"),this.polymerTypeInput=s.input.choice("Polymer Type",{value:"PEPTIDE",items:["PEPTIDE","RNA","CHEM","BLOB","G"],onValueChanged:()=>this.onMonomerInputChanged(),nullable:!1}),this.monomerTypeInput=s.input.choice("Monomer Type",{value:"Backbone",items:["Backbone","Branch","Terminal"],onValueChanged:()=>this.onMonomerInputChanged(),nullable:!1}),this.monomerSymbolInput=s.input.string("Monomer Symbol",{nullable:!1,onValueChanged:()=>this.onMonomerInputChanged()}),this.monomerNameInput=s.input.string("Monomer Name",{nullable:!1,onValueChanged:()=>this.onMonomerInputChanged()}),this.monomerNameInput.nullable=!1,this.monomerIdInput=s.input.int("Monomer ID",{nullable:!0,value:0,onValueChanged:()=>this.onMonomerInputChanged()}),this.monomerNaturalAnalogInput=s.input.string("Natural Analog",{nullable:!0,onValueChanged:()=>this.onMonomerInputChanged()}),this.saveButton=s.bigButton("Save",async()=>{const e=this.validateInputs();e?r.shell.warning(e):await this.saveMonomer()}),this.molSketcher.subs.push(this.molSketcher.onChanged.subscribe(async()=>{if(this.triggerMolChange){try{this.rgroupsGridRoot.style.display="none";const e=this.inputsTabControl.panes.find(e=>"r-groups"===e.name?.toLowerCase());e&&e.header.style.removeProperty("background-color");let t=this.molSketcher.getSmiles();if(!t)return this.rgroupsGrid.items=[],this.rgroupsGrid.render(),this.saveValidationResult="Monomer molecule is required",void this.invalidateSaveButton();t=cn([],t);const n=this.findRgroupsInSmiles(t);if(0===n.length)return this.rgroupsGrid.items=[],this.rgroupsGrid.render(),this.saveValidationResult="At least one R-group is required",e&&e.header.style.setProperty("background-color","#ff000030"),void this.invalidateSaveButton();if(new Set(n.map(e=>e[0])).size!==n.length)return this.saveValidationResult="Duplicate R-groups are not allowed",this.rgroupsGridRoot.style.display="flex",e&&e.header.style.setProperty("background-color","#ff000030"),void this.invalidateSaveButton();const i=n.map(e=>Number.parseInt(e[0].match(/[1-9]/g)[0])).map(e=>this.rgroupsGrid.items.find(t=>t.label===`R${e}`)??{capGroupSMILES:`[*:${e}][H]`,alternateId:`R${e}-H`,capGroupName:"H",label:`R${e}`});this.rgroupsGrid.items=i.sort((e,t)=>e.label?.localeCompare(t.label??"")??0),this.rgroupsGrid.render(),this.rgroupsGridRoot.style.display="flex";const o=await Kt(hn(t,i),this.polymerTypeInput.value??"");o&&(this.monomerNaturalAnalogInput.value=o)}catch(e){console.error(e)}this.onMonomerInputChanged(),this._molChanged=!0}else this.triggerMolChange=!0}));const o=[a.Property.js("capGroupSMILES",a.TYPE.STRING,{caption:"R-group SMILES",nullable:!1}),a.Property.js("alternateId",a.TYPE.STRING,{caption:"Alternate ID",nullable:!1}),a.Property.js("capGroupName",a.TYPE.STRING,{caption:"R-group name",nullable:!1}),a.Property.js("label",a.TYPE.STRING,{fieldName:"R-group Label",nullable:!1,userEditable:!1})];this.rgroupsGrid=new qt(o,[],{allowAdd:!1,allowRemove:!1,validators:{capGroupSMILES:e=>e?r.chem.checkSmiles(e)?null:"Invalid SMILES":"Cap group smiles is required",alternateId:e=>e?null:"Alternate ID is required",capGroupName:e=>e?null:"Cap group name is required",label:e=>e?null:"R-group label is required"},customLabels:{capGroupSMILES:"R-group SMILES",alternateId:"Alternate ID",capGroupName:"Cap Group Name",label:"Label"}}),this.rgroupsGrid.onItemChanged.subscribe(()=>this.onMonomerInputChanged()),this.rgroupsGridRoot=s.divV([this.rgroupsGrid.root]),this.rgroupsGridRoot.style.display="none";const l=[a.Property.js("Property",a.TYPE.STRING,{caption:"Property",nullable:!0}),a.Property.js("Value",a.TYPE.STRING,{caption:"Value",nullable:!0})];this.metaGrid=new qt(l,[]),this.onMonomerInputChanged();const c=s.divV([this.polymerTypeInput,this.monomerTypeInput,this.monomerSymbolInput,this.monomerNameInput,this.monomerIdInput,this.monomerNaturalAnalogInput]);this.inputsTabControl=s.tabControl({Monomer:c,"R-groups":this.rgroupsGridRoot,Meta:s.divV([this.metaGrid.root]),Colors:this.colorsEditor.form},!1)}invalidateSaveButton(){this.saveValidationResult?this.saveButton.classList.add("d4-disabled"):this.saveButton.classList.remove("d4-disabled")}onMonomerInputChanged(){setTimeout(()=>{this.saveValidationResult=this.validateInputs(),this.invalidateSaveButton();const e=this.polymerTypeInput.value&&this.polymerTypeInput.value&&!!this.getMonomerLib()?.getMonomer(this.polymerTypeInput.value,this.monomerSymbolInput.value);this.saveButton.textContent=e?"Save Monomer":"Add Monomer"},200)}setEmptyMonomer(){this.triggerMolChange=!1,this.molSketcher.setSmiles(""),this.monomerSymbolInput.value="",this.monomerNameInput.value="",this.monomerIdInput.value=null,this.monomerNaturalAnalogInput.value=null,this.rgroupsGrid.items=[],this.metaGrid.items=[],this.rgroupsGrid.render(),this.metaGrid.render(),this.rgroupsGridRoot.style.display="none",this.onMonomerInputChanged(),this.colorsEditor.colors={line:"#000000",background:"#000000",text:"#000000"}}setMonomer(e){this.triggerMolChange=!1,this.molSketcher.setSmiles(e.smiles),this.polymerTypeInput.value=e.polymerType,this.monomerTypeInput.value=e.monomerType,this.monomerSymbolInput.value=e.symbol,this.monomerNameInput.value=e.name,this.monomerIdInput.value=e.id,this.monomerNaturalAnalogInput.value=e.naturalAnalog??null,this.rgroupsGrid.items=an(e.rgroups),this.metaGrid.items=Object.entries(e.meta??{}).filter(([e,t])=>"colors"!==e?.toLowerCase()).map(([e,t])=>({Property:e,Value:t})),this.rgroupsGrid.render(),this.metaGrid.render(),this.rgroupsGridRoot.style.display="flex",this.onMonomerInputChanged(),!e.naturalAnalog&&e.polymerType&&Kt(hn(e.smiles,this.rgroupsGrid.items),e.polymerType).then(e=>{e&&(this.monomerNaturalAnalogInput.value=e)});const t=e.meta?.colors??"";let n={};try{n=t?JSON.parse(t)?.default:{}}catch(e){console.error(e)}this.colorsEditor.colors={line:n.line??"#000000",background:n.background??"#000000",text:n.text??"#000000"}}validateInputs(){const e=this.inputsTabControl.panes.find(e=>"r-groups"===e.name?.toLowerCase());if(e&&e.header.style.removeProperty("background-color"),!this.molSketcher.getSmiles())return"Monomer Molecule field is required";for(const e of[this.polymerTypeInput,this.monomerTypeInput,this.monomerSymbolInput,this.monomerNameInput])if(null==e.value||""===e.value)return`${e.caption} field is required`;let t=null;if(this.rgroupsGrid.items.length<1&&(t="At least one R-group is required"),!t)e:for(const e of this.rgroupsGrid.items)for(const[n,i]of Object.entries(e))if(!i){t=`R-group ${n} field is required for ${e.label}`;break e}return!t&&this.rgroupsGrid.hasErrors()&&(t="R-group fields contain errors"),t?(e&&e.header.style.setProperty("background-color","#ff000030"),t):null}findRgroupsInSmiles(e){return[...Array.from(e.matchAll(/\[[1-9]\*\]/g)),...Array.from(e.matchAll(/\[\*\:[1-9]\]/g))]}get form(){this.inputsTabControl.root.classList.add("monomer-manager-form-tab-control"),this.inputsTabControl.header.style.marginBottom="10px";const e=s.buttonsInput([this.saveButton]);return s.tooltip.bind(e,()=>this.saveValidationResult??"Save monomer to library"),s.divV([this.molSketcher.root,this.inputsTabControl.root,e],{classes:"ui-form",style:{paddingLeft:"10px",overflow:"scroll",maxWidth:"unset"}})}get fieldInputs(){return{molecule:this.molSketcher,polymerType:this.polymerTypeInput,monomerType:this.monomerTypeInput,symbol:this.monomerSymbolInput,name:this.monomerNameInput,id:this.monomerIdInput,naturalAnalog:this.monomerNaturalAnalogInput}}get metaInputs(){return[]}get rgroupInputs(){return[]}getMonomerInfoTable(e){const t=cn(e.rgroups,e.smiles,e.molfile),n=r.chem.drawMolecule(t,150,150),i=s.tableFromMap({name:e.name,author:e.author,createDate:e.createDate});return s.divH([n,i],{style:{alignItems:"center"}})}async removeMonomers(e,t,n=!0){const i=await(0,we.pY)(await this.monomerLibManager.getProviders(),t);if(!i)return void r.shell.error(`Library ${t} not found in any provider`);const o=s.divV(e.map(e=>this.getMonomerInfoTable(e)),{style:{maxHeight:"500px",overflow:"scroll"}}),a=e.length>1,l=a?`Are you sure you want to remove monomers ${e.map(e=>e.symbol).join(", ")} from ${t} library?`:`Are you sure you want to remove monomer with symbol ${e[0].symbol} from ${t} library?`,c=s.dialog("Remove Monomer"+(a?"s":"")).add(s.h1(l)).add(o).addButton("Remove",async()=>{await i.deleteMonomersFromLibrary(t,e),await this.monomerLibManager.loadMonomerLib(!0),await this.refreshTable(),n&&r.shell.info(`Monomer${a?"s":""} ${e.map(e=>e.symbol).join(", ")} ${a?"were":"was"} successfully removed from ${t} library`),c.close()}).show()}async addMonomerToLib(e,t){const n=this.getMonomersDataFrame();if(!n)return void r.shell.error("No monomer library loaded");const i=n?.col(Zt.POLYMER_TYPE)?.toList()??[],o=n?.col(Zt.SYMBOL)?.toList()??[],a=n?.col(Zt.MONOMER)?.toList()??[];if(i.length!==o.length||i.length!==a.length)return void r.shell.error("Monomer library data frame is corrupted");const l=i.findIndex((t,n)=>t===e.polymerType&&o[n]===e.symbol),c=a.findIndex(t=>t===e.smiles),u=async()=>{try{const n=await(0,we.pY)(await this.monomerLibManager.getProviders(),t);if(!n)return void r.shell.error(`Library ${t} not found in any provider`);await n.updateOrAddMonomersInLibrary(t,[{...e,lib:void 0,wem:void 0}]),await this.monomerLibManager.loadMonomerLib(!0),await this.refreshTable(e.symbol),this._molChanged=!1,r.shell.info(`Monomer ${e.symbol} was successfully saved in library ${t}`)}catch(e){r.shell.error("Error saving monomer"),console.error(e)}this.onMonomerInputChanged()};let h=null,d="";if(l>=0)h=this.getMonomerInfoTable(await dn(n.row(l))),d=`Monomer with symbol '${e.symbol}' already exists in library ${t}.\nAre you sure you want to overwrite it?`;else if((c??-1)>=0){const e=await dn(this.getMonomersDataFrame().rows.get(c));h=this.getMonomerInfoTable(e),d=`Monomer with the same structure already exists in library ${t} with different symbol (${e.symbol}).\nAre you sure you want to duplicate it?`}if(h){const e=s.dialog("Save Monomer").add(s.divText(d)).add(h).addButton("Save",()=>{e.close(),u()}).show()}else await u()}async saveMonomer(){let e=this.molSketcher.getSmiles();if(!e||!r.chem.checkSmiles(e))return void r.shell.warning("Invalid SMILES");e=cn([],e);let t=r.chem.convert(e,a.chem.Notation.Smiles,a.chem.Notation.MolBlock);t=un(t);const n={};this.metaGrid.items.filter(e=>!!e.Property&&!!e.Value).forEach(e=>{n[e.Property]=e.Value});const i=this.metaGrid.addingItem;i&&i.Property&&i.Value&&(n[i.Property]=i.Value),"#000000"===this.colorsEditor.colors.line&&"#000000"===this.colorsEditor.colors.background&&"#000000"===this.colorsEditor.colors.text||(n.colors={default:this.colorsEditor.colors});const o={symbol:this.monomerSymbolInput.value,name:this.monomerNameInput.value,molfile:t,smiles:e,polymerType:this.polymerTypeInput.value,monomerType:this.monomerTypeInput.value,naturalAnalog:this.monomerNaturalAnalogInput.value?this.monomerNaturalAnalogInput.value:void 0,id:this.monomerIdInput.value??0,rgroups:this.rgroupsGrid.items,author:a.User.current().friendlyName,createDate:(new Date).toISOString(),meta:n},s=this.getMonomerLib()?.source;s?await this.addMonomerToLib(o,s):r.shell.warning("Monomer library source is not specified")}}function cn(e,t,n){const i=!t||!r.chem.checkSmiles(t);if(i&&!n)throw new Error("Both SMILES and MOL block are empty or malformed");let o=i?r.chem.convert(n,a.chem.Notation.Unknown,a.chem.Notation.Smiles):t;return o=function(e,t){let n=e;return t.forEach(e=>{const t=e.label[1]??"1",i=new RegExp(`\\[\\${e.capGroupName}:${t}\\]`,"g");n=n.replace(i,`[*:${t}]`)}),n=n.replaceAll(/\[\d[A-Z]{1,2}\]/g,e=>`[*:${e[1]}]`),n}(o,e),o=on(o),i?o:r.chem.convert(o,a.chem.Notation.Unknown,a.chem.Notation.Smiles)}function un(e){const t=e.split("\n"),n=t.findIndex(e=>e.startsWith("M")&&e.includes("ISO"));if(-1!==n){const e=t[n].indexOf("ISO");t[n]=t[n].substring(0,e)+"RGP"+t[n].substring(e+3)}const i=t.findIndex(e=>e.includes("V2000"));if(-1===i)return console.error("Mol start line not found"),e;const o=Number.parseInt(t[i].trim().split(" ")[0].slice(0,3).trim()),r={};for(let e=i+1;e<i+1+o;e++){const n=t[e].indexOf("R ");if(-1===n)continue;"#"!==t[e][n+1]&&(t[e]=t[e].replace("R ","R#"));const o=t[e].trim().split(" ").map(e=>e.trim()).filter(Boolean);if(r[e-i]=1,o.length<14)continue;const s=Number.parseInt(o[13]);Number.isNaN(s)||(r[e-i]=s)}const s=Object.keys(r);if(-1===t.findIndex(e=>e.startsWith("M")&&e.includes("RGP"))){const e=`M RGP${s.length.toString().padStart(3," ")}${Object.entries(r).map(([e,t])=>`${e.toString().padStart(4," ")}${t.toString().padStart(4," ")}`).join("")}`,n=t.findIndex(e=>e.startsWith("M")&&e.includes("END"));t.splice(n,0,e)}return s.filter(e=>!!Number.parseInt(e)).map(e=>Number.parseInt(e)+i).forEach(e=>{const n=t[e].split(" "),i=n.findIndex(e=>"R#"===e);if(-1!==i){for(let e=i+1;e<n.length;e++)n[e]&&1==n[e].length&&(Number.parseInt(n[e])??0)>0&&(n[e]="0");t[e]=n.join(" ")}}),t.join("\n")}function hn(e,t){let n=e;return t.forEach(e=>{const t=e.label[1]??"1",i=sn(e,"capGroupName");n=n.replace(`[*:${t}]`,`[${i}]`)}),n}async function dn(e){let t;try{t=JSON.parse(e.get(Zt.META)??"{}");for(const e in t)"object"==typeof t[e]&&(t[e]=JSON.stringify(t[e])),("string"!=typeof t[e]||t[e]!==a.INT_NULL.toString()&&t[e]!==a.FLOAT_NULL.toString())&&("number"!=typeof t[e]||t[e]!==a.INT_NULL&&t[e]!==a.FLOAT_NULL)||(t[e]=null)}catch(e){console.error(e)}const n=e.get(Zt.MONOMER);if(!n)throw new Error("Monomer SMILES is empty");let i="";try{i=r.chem.convert(n,a.chem.Notation.Smiles,a.chem.Notation.MolBlock),i=un(i)}catch(e){r.shell.error(`Error converting SMILES to molfile, \n ${n}`),console.error(e)}let o=e.get(Zt.NATURAL_ANALOG);const s=e.get(Zt.POLYMER_TYPE);let l=[];try{if(l=JSON.parse(e.get(Zt.R_GROUPS)??"[]"),!o&&s){const e=await Kt(hn(n,l),s);e&&(o=e)}}catch(e){l??=[]}return{symbol:e.get(Zt.SYMBOL),name:e.get(Zt.NAME),molfile:i,smiles:n,polymerType:s,monomerType:e.get(Zt.MONOMER_TYPE),naturalAnalog:o,id:e.get(Zt.ID),rgroups:l,meta:t,author:e.get(Zt.AUTHOR),createDate:e.get(Zt.CREATE_DATE)}}class pn{_colors;_colorInputs;constructor(e){this._colors=e,this._colorInputs={line:s.input.color("Line",{value:e.line,onValueChanged:e=>this._colors.line=e}),background:s.input.color("Background",{value:e.background,onValueChanged:e=>this._colors.background=e}),text:s.input.color("Text",{value:e.text,onValueChanged:e=>this._colors.text=e})}}get colors(){return this._colors}set colors(e){const t={line:a.Color.toHtml(a.Color.fromHtml(e.line??"#000000")),background:a.Color.toHtml(a.Color.fromHtml(e.background??"#000000")),text:a.Color.toHtml(a.Color.fromHtml(e.text??"#000000"))};this._colors=t;for(const e in this._colorInputs)this._colorInputs[e].value=t[e]}get colorsMetaFormat(){return{colors:{default:this._colors}}}get form(){return s.form(Object.values(this._colorInputs))}}const mn=/.*\|\$.*R.*\$\|/,fn=/\[R(\d+)\]/,gn=/\[R(\d+)\]/g,yn=/\[\*:(\d+)\]/g;function bn(e,t){const n=Array.from(e.matchAll(gn)).map(e=>e[1]),i={name:"Explicit SMILES Monomer",smiles:e,polymerType:t??"CHEM",molfile:"",rgroups:n.map(e=>({label:`R${e}`,capGroupName:"H",capGroupSmiles:`[*:${e}][H]`,alternateId:`R${e}-H`})),author:"Datagrok auto-generated",id:0,createDate:null,monomerType:"Backbone"};try{let t=e;i.rgroups.forEach(e=>{const n=e.label.substring(1);t=t.replace(`[R${n}]`,`[*:${n}]`)});const n=un(r.chem.convert(t,r.chem.Notation.Smiles,r.chem.Notation.MolBlock));i.molfile=n,i.smiles=t}catch(t){qr.logger.error(`getMonomerFromRSmiles: cannot convert SMILES to Molfile: ${e}\n${t}`)}return i}const vn=/[\w()]+/,wn=RegExp(String.raw`\(${vn}(,${vn})+\)`),Cn=e=>{const t=s.canvas(250,250);return r.chem.canvasMol(0,0,250,250,t,e),t},Sn=new Ht.Mi([255,255,255]),An=new Ht.Mi([0,0,0]),xn=.7*(0,K.wQ)(Sn);class Mn{_monomers;source;_isEmpty;get isEmpty(){return this._isEmpty}_onChanged=new u.Subject;get onChanged(){return this._onChanged}constructor(e,t){this._monomers=e,this.source=t,this._isEmpty=!this._monomers||0===Object.keys(this._monomers).length||Object.entries(this._monomers).every(([e,t])=>0===Object.keys(t).length);for(const[e,t]of Object.entries(this._monomers))for(const[e,n]of Object.entries(t))n.lib=this}getMonomerSymbolsByType(e){const t=Object.keys(this._monomers[e]);return this._smilesMonomerCache[e]&&t.push(...Object.keys(this._smilesMonomerCache[e])),t}_smilesMonomerCache={};addMissingMonomer(e,t){let n=this._monomers[e];n||(n=this._monomers[e]={});let i=t;t==ve._S||t===ve.b9[ve.Hi.HELM]?i="Gap":("PEPTIDE"===e&&"X"===t||"RNA"===e&&"N"===t)&&(i="Any");const o=function(e,t){try{if(mn.test(e)){const n=e.split("|$"),i=n[0].trim(),o=n[1],r=Array.from(o.matchAll(/R(\d+)/g)),s=Array.from(i.matchAll(/(\*)/g));if(r.length!==s.length)return null;let a=i.replaceAll(/\[\*\]/g,"*");const l=r.map(e=>e[1]);for(let e=0;e<l.length;e++){const t=l[e];a=a.replace("*",`[R${t}]`)}return bn(a,t)}let n=e;const i=Array.from(e.matchAll(yn));for(const e of i){const t=e[0],i=e[1];n=n.replace(t,`[R${i}]`)}if(fn.test(n))return bn(n,t)}catch(t){qr.logger.error(`smiles2Monomer: cannot parse SMILES: ${e}\n${t}`)}return null}(t,e);if(o){this._smilesMonomerCache[e]=this._smilesMonomerCache[e]??{};const i=this._smilesMonomerCache[e],r=Object.keys(i).length+1;i[t]=`#${e[0]}${r}`;const s={...o,symbol:i[t]},a=new Ft((0,Be.MD)(e),s.symbol,t,`SMILES Monomer ${s.symbol}`,s.rgroups.map(e=>e.label));return s.wem=a,n[s.symbol]=s,s}return n[t]={symbol:t,name:i,molfile:"",author:"MISSING",id:-1,rgroups:R().count(1).take(9).map(e=>({capGroupSmiles:"",alternateId:"",capGroupName:"",label:`R${e.toString()}`})).toArray(),smiles:"",polymerType:e,monomerType:void 0,createDate:null}}getMonomer(e,t){let n=t;"RNA"==e&&"R"==n&&(n="r"),"RNA"==e&&"P"==n&&(n="p");let i=null;if(e){this._smilesMonomerCache[e]?.[n]&&(n=this._smilesMonomerCache[e][n]);const t=this._monomers[e];i=t?.[n]??null}else{qr.logger.warning(`Bio: MonomerLib.getMonomer() symbol '${t}', polymerType not specified.`);for(const[e,t]of Object.entries(this._monomers))if(i=t[n],i)break}return i}getWebEditorMonomer(e,t){const[n,i]=(0,kt.fA)(e,t),o=(0,Ot.Y)(n);let r=this.getMonomer(o,i);if(r&&n==De.o.LINKER&&2!=r.rgroups.length)return null;if(r&&n==De.o.SUGAR&&3!=r.rgroups.length)return null;r||(r=this.addMissingMonomer(o,i));let s=r.wem??null;return s||(i===ve._S||"*"==i?s=r.wem=new Gt(n):n===De.o.NUCLEOTIDE&&"N"===i||n===De.o.AA&&"X"===i||(De.o.CHEM,0)||wn.test(i)?s=r.wem=new Dt(n,i):r.lib||(s=r.wem=new Vt(n,i,this.isEmpty)),s||(s=r.wem=jt.fromMonomer(n,r,this))),s}getTooltip(e,t){const n=(0,Ot.Y)(e),i=s.div([],{classes:"ui-form ui-tooltip"}),o=this.getWebEditorMonomer(e,t),r=this.getMonomer(n,t);if(r){const e=r.symbol,[t,n,a]=(r.name,o?[o.textcolor,o.backgroundcolor,o.linecolor]:["#202020","#A0A0A0","#202020"]);let l;if(i.append(s.divH([s.div([e],{style:{textWrap:"nowrap",marginLeft:"4px",marginRight:"4px",color:t,backgroundColor:n,borderColor:a,borderWidth:"1px",borderStyle:"solid",borderRadius:"2px",padding:"3px",minWidth:"24px",textAlign:"center"}}),s.div([r.name],{style:{padding:"4px"}})],{style:{display:"flex",flexDirection:"row",justifyContent:"left"}})),l=r.molfile?Cn(r.molfile):r.smiles?s.divV([Cn(r.smiles),s.divText("from smiles",{style:{fontSize:"smaller"}})]):s.divText("No structure",{style:{margin:"6px"}}),i.append(s.div(l,{style:{display:"flex",flexDirection:"row",justifyContent:"center",margin:"6px"}})),r.symbol!=ve._S){let e=r.lib?.source;e?(e.endsWith(".json")&&(e=e.substring(0,e.length-5)),e=e.replace(/_/g," ").replace(/-/g," ").replace(/([a-z])([a-z])([A-Z])/g,"$1$2 $3"),i.append(s.divText(e))):i.append(s.divText("Missed in libraries"))}}else i.append(s.divV([s.divText(`Monomer '${t}' of type '${n}' not found.`),s.divText("Open the Context Panel, then expand Manage Libraries")]));return i}getMonomerTextColor(e,t){const n=this.getMonomerColors(e,t),i=e=>{const t=/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/.exec(e);if(t)return[parseInt(t[1]),parseInt(t[2]),parseInt(t[3])];const n=a.Color.fromHtml(e);return[a.Color.r(n),a.Color.g(n),a.Color.b(n)]},o=i(n.textcolor),r=new Ht.Mi([...o.map(e=>e+1)]),s=(0,K.KE)(r,Sn)/((0,K.wQ)(r)*(0,K.wQ)(Sn)),l=i(n.backgroundcolor),c=new Ht.Mi([...l.map(e=>e+.01)]);let u;u=(0,K.KE)(c,Sn)/((0,K.wQ)(c)*(0,K.wQ)(Sn))<s?l:o;let h=new Ht.Mi(u);const d=(0,K.wQ)(h);return d>xn&&(h=(0,K.dC)(An,h,xn/d)),`rgb(${h[0]}, ${h[1]}, ${h[2]})`}getMonomerColors(e,t){const n="default";let i=n;const o=(0,Ot.Y)(e),r=this.getMonomer(o,t);let s;if(r){if(r.meta&&r.meta.colors){if("string"==typeof r.meta.colors)try{r.meta.colors=JSON.parse(r.meta.colors)}catch(e){qr.logger.error(`Bio: MonomerLib.getMonomerColors() failed to parse monomer.meta.colors: ${e}`)}const e=r.meta.colors;e&&"string"!=typeof e&&!(n in e)&&(i="default"),e&&"string"!=typeof e&&i in e&&(s=e[i])}if(!s){const t=Ut[e],n=t?.[r.symbol];n&&(s={textColor:a.Color.toHtml(a.Color.getContrastColor(a.Color.fromHtml(n))),lineColor:"#202020",backgroundColor:n})}const t=r.naturalAnalog;if(!s&&t&&t!==r.symbol)return this.getMonomerColors(e,t)}return s||(s={textColor:"#202020",lineColor:"#202020",backgroundColor:"#A0A0A0"}),{textcolor:s.text??s.textColor,linecolor:s.line??s.lineColor,backgroundcolor:s.background??s.backgroundColor}}getRS(e){const t=e.match(/(?<=\[)[^\][]*(?=])/gm),n={};let i,o="";if(t)for(let e=0;e<t.length;e++)if(null!=t[e]&&/\d/.test(t[e])){i=t[e][t[e].length-1],t[e]=t[e].replace(/[0-9]/g,"");for(let n=0;n<t[e].length;n++)":"!=t[e][n]&&(o+=t[e][n]);n["R"+i]=o,o=""}return n}}var Tn=n(5488),En={};En.styleTagTransform=S(),En.setAttributes=b(),En.insert=g().bind(null,"head"),En.domAPI=m(),En.insertStyleElement=w(),d()(Tn.A,En),Tn.A&&Tn.A.locals&&Tn.A.locals;class _n extends Mn{error;_duplicateMonomers={};get duplicateMonomers(){return this._duplicateMonomers}_duplicatesHandled=!0;get duplicatesHandled(){return this._duplicatesHandled}duplicatesNotified=!1;constructor(e,t,n=void 0){super(e,t),this.error=n}toJSON(){const e=[];for(const t of Object.values(this._monomers))for(const n of Object.values(t))e.push({...n,lib:void 0,wem:void 0});return e}_monomerSets=null;getMonomerSet(e){const t=(0,Ot.Y)(e);if(this._monomerSets||(this._monomerSets={}),!(e in this._monomerSets))for(const[e,n]of Object.entries(this._monomers[t]));return this._monomerSets[e]}getPolymerTypes(){return Object.keys(this._monomers)}getMonomerMolsByPolymerType(e){const t={};return Object.keys(this._monomers[e]??{}).forEach(n=>{t[n]=this._monomers[e][n].molfile}),t}getMonomerSymbolsByRGroup(e,t,n){let i=this.getMonomerSymbolsByType(t).map(e=>this.getMonomer(t,e));return i=i.filter(e=>null!==e),0===i.length?[]:(i=i.filter(t=>{if(!t?.rgroups)return!1;let n=t?.rgroups.length>=e;var i;return i=$t.getInstance(t.molfile).atomTypes,i.map((e,t)=>"R#"===e?t:-1).filter(e=>-1!==e),n&&=!0,n}),i.map(e=>e?.symbol))}_updateLibInt(e){const t=e.getPolymerTypes(),n=this.getPolymerTypes();t.forEach(t=>{n.includes(t)||(this._monomers[t]={}),e.getMonomerSymbolsByType(t).forEach(n=>{this._monomers[t][n]&&(this._duplicateMonomers[t]??={},this._duplicateMonomers[t][n]??=[this._monomers[t][n]],this._duplicateMonomers[t][n].push(e.getMonomer(t,n))),this._monomers[t][n]=e.getMonomer(t,n)})}),this._isEmpty=this.isEmpty&&e.isEmpty}async updateLibs(e,t=!1){t&&(this._monomers={},this._isEmpty=!0),this._duplicateMonomers={};for(const t of e)t.error||this._updateLibInt(t);if(Object.entries(this.duplicateMonomers).length>0){const e=await(0,Pe.u)();this.assignDuplicatePreferences(e)}else this._duplicatesHandled=!0;this._onChanged.next()}assignDuplicatePreferences(e){let t=!0;for(const n in this.duplicateMonomers)for(const i in this.duplicateMonomers[n])if(e.duplicateMonomerPreferences?.[n]?.[i]){const o=e.duplicateMonomerPreferences[n][i],r=this.duplicateMonomers[n][i].find(e=>e.lib?.source===o);r?this._monomers[n][i]=r:t=!1}else t=!1;return this._duplicatesHandled=t,t}clear(){this._monomers={},this._onChanged.next()}getSummaryObj(){const e={},t=this.getPolymerTypes();for(const n of t)e[n]=this.getMonomerSymbolsByType(n).length;return e}getSummaryDf(){const e=this.getPolymerTypes(),t=new Array(e.length);for(const[n,i]of R().enumerate(e))t[i]=this.getMonomerSymbolsByType(n).length;return a.DataFrame.fromColumns([a.Column.fromStrings("polymerType",e),a.Column.fromList(a.COLUMN_TYPE.INT,"count",t)])}getSummary(){const e=this.getPolymerTypes();return 0==e.length?"empty":e.map(e=>`${e} ${this.getMonomerSymbolsByType(e).length}`).join("\n")}static overrideCounter=0;override(e,t){return new In(e,`override: ${++_n.overrideCounter}, ${t}`,this)}}class In extends Mn{data;base;constructor(e,t,n){super(e,t),this.data=e,this.base=n}get onChanged(){return this.base.onChanged}getMonomerSymbolsByType(e){const t=this.base.getMonomerSymbolsByType(e);for(const n of Object.keys(this.data[e]??{}))t.includes(n)||t.push(n);return t}addMissingMonomer(e,t){return this.base.addMissingMonomer(e,t)}getMonomer(e,t){const n=this.data[e]?.[t];return n??this.base.getMonomer(e,t)}}var Ln=n(8604),Nn=n(7433),Pn=n.n(Nn),Rn=n(1913),$n=n.n(Rn);class On{helmMonomerSchema;validateMonomerSchema;constructor(e){this.helmMonomerSchema=e;const t=new(Pn())({allErrors:!0,strictTuples:!1,allowUnionTypes:!0});$n()(t),this.validateMonomerSchema=t.compile(this.helmMonomerSchema)}validateFile(e,t){const n=this.parseJson(e,t);return null!=n&&(Array.isArray(n)?this.validateJsonContent(n,t):(console.warn(`Bio: Monomer Library File Validator file '${t}': Invalid JSON format: The file must contain an array of monomers.`),!1))}parseJson(e,t){try{return JSON.parse(e)}catch(e){return console.error(`Bio: Monomer Library File Validator file '${t}': Invalid JSON format:`,e),null}}validateJsonContent(e,t){let n=!0;const i=new Set;for(const o of e){const e=o.symbol??o.id??o.name??"#N/A";if(n=this.validateMonomerSchema(o),!n){console.warn(`Bio: Monomer Library File Validator file ${t}, monomer '${e}' violating JSON schema:`,o,"\nError reason: ",JSON.stringify(this.validateMonomerSchema.errors??{}),`\nThere may be other errors in ${t} since the validation is stopped after the first error.`," Please, verify that the monomer library file satisfies the JSON schema");break}const r=`${o.polymerType??""}-${e}`;i.has(r)&&console.warn(`Bio: Monomer Library File Validator file ${t}, monomer '${e}' is duplicated.`,"Please, verify that the monomer library file does not contain duplicated monomer symbols."),i.add(r)}return n}}class kn{fileValidator;libHelper;logger;get LIB_PATH(){return"System:AppData/Bio/monomer-libraries/"}get SETS_PATH(){return"System:AppData/Bio/monomer-sets/"}static HELM_JSON_SCHEMA_PATH="System:AppData/Bio/tests/libraries/HELMmonomerSchema.json";static _instance=null;filesPromise=Promise.resolve();name=we.ic;_onChanged=new u.Subject;get onChanged(){return this._onChanged}constructor(e,t,n){this.fileValidator=e,this.libHelper=t,this.logger=n}static async getInstance(e,t){if(null==this._instance){const n=await r.dapi.files.readAsText(kn.HELM_JSON_SCHEMA_PATH),i=JSON.parse(n),o=new On(i);kn._instance=new kn(o,e,t),kn._instance.refreshLists()}return kn._instance}toLog(){return"MonomerLibFileManager"}async validateAgainstHELM(e,t){if(!this.isValidHELMLibrary(e,t))throw new Error(`File ${t} does not satisfy HELM standard`)}isValidHELMLibrary(e,t){return this.fileValidator.validateFile(e,t)}async refreshLists(){await Promise.all([this.updateValidLibList(),this.updateValidSetList()])}async addOrUpdateLibraryString(e,t){e=e.endsWith(".json")?e:`${e}.json`;try{await this.validateAgainstHELM(t,e),await r.dapi.files.writeAsText(this.LIB_PATH+`${e}`,t),await this.updateValidLibList(),await r.dapi.files.exists(this.LIB_PATH+`${e}`)?r.shell.info(`Added ${e} HELM library`):r.shell.error(`Failed to add ${e} library`)}catch(t){this.logger.error(t),r.shell.error(`Failed to add ${e} library`)}}async addOrUpdateLibrary(e,t){const n=JSON.stringify([...t.map(e=>({...e,wem:void 0,lib:void 0}))],null,2);await this.addOrUpdateLibraryString(e,n)}get loadPromise(){return this.filesPromise}async listLibraries(){return this.validLibList}async listSets(){return this.validSetList}async loadLibraries(e,t=!1){let n=[];e=e.map(e=>e.endsWith(".json")?e:`${e}.json`);const i=t?e:e.map(e=>this.LIB_PATH+e),o=[];for(let e=0;e<i.length;e++){const t={};try{const o=await r.dapi.files.readAsText(i[e]);n=JSON.parse(o),n.forEach(e=>{const n=e.polymerType,i=e.symbol;t[n]||(t[n]={}),t[n][i]=e})}catch(t){this.logger.error(`Failed to load monomer library file: ${i[e]}`),this.logger.error(t);continue}finally{o.push(t)}}return o}async loadSets(e){const t=[],n=this.libHelper.getMonomerLib();for(const i of e){const e=i.endsWith(".json")?i:`${i}.json`,o=this.SETS_PATH+e;try{const e=await r.dapi.files.readAsText(o),i=JSON.parse(e),s=i.description,a=Object.entries(i.placeholders).map(([e,t])=>{const i=e,o=t.polymerType,r=t.monomerType,s=t.set;return new we.lH(n,i,o,r,s)});t.push(new we.YS(s,a))}catch(e){this.logger.error(`Failed to load monomer set file: ${o}`),this.logger.error(e);continue}}return t}async deleteLibrary(e){const t=e.endsWith(".json")?e:`${e}.json`;await r.dapi.files.delete(this.LIB_PATH+t),await this.updateValidLibList()}async deleteSet(e){const t=e.endsWith(".json")?e:`${e}.json`;await r.dapi.files.delete(this.SETS_PATH+t),await this.updateValidSetList()}async addOrUpdateSetString(e,t){const n=e.endsWith(".json")?e:`${e}.json`;await r.dapi.files.writeAsText(this.SETS_PATH+n,t),await this.updateValidSetList()}async addOrUpdateSet(e,t){const n=JSON.stringify(t,null,2);await this.addOrUpdateSetString(e,n)}async deleteMonomersFromLibrary(e,t){const n=e.endsWith(".json")?e:`${e}.json`,i=this.LIB_PATH+n,o=await r.dapi.files.readAsText(i);let s=JSON.parse(o);s=s.filter(e=>!t.some(t=>e.polymerType===t.polymerType&&e.symbol===t.symbol));const a=JSON.stringify(s,null,2);await r.dapi.files.writeAsText(i,a),await this.updateValidLibList()}validLibList=[];libListHasChanged(e){const t=this.validLibList;return e.length!==t.length||e.some((e,n)=>e!==t[n])}validSetList=[];setListHasChanged(e){const t=this.validSetList;return e.length!==t.length||e.some((e,n)=>e!==t[n])}async getLibraryAsString(e){const t=e.endsWith(".json")?e:`${e}.json`;return r.dapi.files.readAsText(this.LIB_PATH+t)}async getSingleLibrary(e){return(await this.loadLibraries([e]))?.[0]}async getSingleLibraryWithFullPath(e){return(await this.loadLibraries([e],!0))?.[0]}async updateOrAddMonomersInLibrary(e,t){const n=e.endsWith(".json")?e:`${e}.json`,i=this.LIB_PATH+n,o=await r.dapi.files.readAsText(i),s=JSON.parse(o);for(const e of t){const t=s.findIndex(t=>t.polymerType===e.polymerType&&t.symbol===e.symbol);-1!==t?s[t]={...e,lib:void 0,wem:void 0}:s.push({...e,lib:void 0,wem:void 0})}const a=JSON.stringify(s,null,2);await r.dapi.files.writeAsText(i,a),await this.updateValidLibList()}async updateValidLibList(){const e=`${this.toLog()}.updateValidLibList()`;return this.logger.debug(`${e}, start`),this.filesPromise=this.filesPromise.then(async()=>{this.logger.debug(`${e}, IN`);const t=[],n=await this.getLibFileListAtLocation();if(!this.libListHasChanged(n))return void this.logger.debug(`${e}, end, not changed`);for(const e of n){if(!e.endsWith(".json")){t.push(e);continue}const n=await r.dapi.files.readAsText(this.LIB_PATH+`${e}`);this.isValidHELMLibrary(n,e)||t.push(e)}const i=n.filter(e=>!t.includes(e));if(this.libListHasChanged(i)&&(this.validLibList=i,await this.libHelper.loadMonomerLib(!0)),i.some(e=>!e.endsWith(".json"))&&this.logger.warning(`Wrong validation: ${i}`),t.length>0){const e=`Invalid monomer library files in ${this.LIB_PATH}, consider fixing or removing them: ${t.join(", ")}`;this.logger.warning(e)}this.logger.debug(`${e}, OUT`),this._onChanged.next()}),this.logger.debug(`${e}, end`),this.filesPromise}async updateValidSetList(){const e=`${this.toLog()}.updateValidSetList()`;return this.logger.debug(`${e}, start`),this.filesPromise=this.filesPromise.then(async()=>{this.logger.debug(`${e}, IN`);const t=[],n=await this.getSetFileListAtLocation();if(!this.setListHasChanged(n))return void this.logger.debug(`${e}, end, not changed`);for(const e of n)e.endsWith(".json")||t.push(e);const i=n.filter(e=>!t.includes(e));this.setListHasChanged(i)&&(this.validSetList=i,this.libHelper.loadMonomerSets(!0)),this.logger.debug(`${e}, OUT`),this._onChanged.next()}),this.logger.debug(`${e}, end`),this.filesPromise}async getLibFileListAtLocation(){const e=`${this.toLog()}.getLibFileListAtLocation()`;this.logger.debug(`${e}, start`);const t=await r.dapi.files.list(this.LIB_PATH).then(e=>e.filter(e=>e.isFile).map(e=>e.fullPath)),n=[];return n.push(...t),n.map(e=>e.substring(this.LIB_PATH.length))}async getSetFileListAtLocation(){const e=`${this.toLog()}.getSetFileListAtLocation()`;this.logger.debug(`${e}, start`);const t=await r.dapi.files.list(this.SETS_PATH).then(e=>e.map(e=>e.fullPath)),n=[];return n.push(...t),n.map(e=>e.substring(this.SETS_PATH.length))}}class Hn{logger;_monomerLib=new _n({},"MAIN");_monomerSets=new we.YS("MAIN",[]);_initialLoadCompleted=!1;get initialLoadCompleted(){return this._initialLoadCompleted}_providersDataChanged=new u.Subject;get providersDataChanged(){return this._providersDataChanged}_fileUploadRequested=new u.Subject;get fileUploadRequested(){return this._fileUploadRequested}requestFileUpload(){this._fileUploadRequested.next()}_selectionChanged=new u.Subject;get librarySelectionChanged(){return this._selectionChanged}notifyLibrarySelectionChanged(){this._selectionChanged.next()}async getAvaliableLibraryNames(e=!1){const t=await this.getProviders(),n=[];for(const i of t){e&&await i.refreshLists();const t=await i.listLibraries();n.push(...t)}return n}async refreshValidLibraryLists(){const e=await this.getProviders();await Promise.all(e.map(async e=>e.refreshLists()))}async getAvailableLibrariesPerProvider(){const e=await this.getProviders(),t=new Map;for(const n of e){const e=await n.listLibraries();t.set(n.name,e)}return t}async awaitLoaded(e=1/0){return e=e===1/0?6e4:e,await Promise.race([(async()=>{const e=await this.getProviders();return await Promise.all(e.map(async e=>e.loadPromise)),await this.loadLibrariesPromise,!0})(),(async()=>(await(0,et.cb)(e),!1))()]).then(t=>{if(!t)throw new Error(`Loading monomer libraries timeout ${e} ms.`)})}_monomerLibProviders=null;async getProviders(){if(null==this._monomerLibProviders){const e=a.Func.find({tags:["monomer-lib-provider"]});this._monomerLibProviders=await Promise.all(e.map(async e=>await e.apply({}))),this._monomerLibProviders.push(await kn.getInstance(this,qr.logger)),a.debounce((0,u.merge)(...this._monomerLibProviders.map(e=>e.onChanged)),200).subscribe(()=>{this._providersDataChanged.next()})}return this._monomerLibProviders}constructor(e){this.logger=e}static objCounter=-1;objId=(()=>{if(++Hn.objCounter>0)throw new Error("MonomerLibManager MUST be a singleton.");return Hn.objCounter})();toLog(){return`MonomerLibManager<${this.objId}>`}getMonomerLib(){return this._monomerLib}getBioLib(){return this.getMonomerLib()}getMonomerSets(){return this._monomerSets}get duplicateMonomers(){return this._monomerLib.duplicateMonomers}get duplicatesHandled(){return this._monomerLib.duplicatesHandled}assignDuplicatePreferances(e){this._monomerLib.assignDuplicatePreferences(e)}loadLibrariesPromise=Promise.resolve();async loadMonomerLib(e=!1){const t=`${this.toLog()}.loadMonomerLib()`;return this.logger.debug(`${t}, start`),this.loadLibrariesPromise=this.loadLibrariesPromise.then(async()=>{this.logger.debug(`${t}, IN`);const n=a.TaskBarProgressIndicator.create("Loading monomers ...");try{const t=await(0,Pe.u)(),i=await this.getProviders(),o=await Promise.all(i.map(async e=>e.listLibraries()));o.forEach((e,n)=>{o[n]=e.filter(e=>{const n=!t.exclude.includes(e),i=0===(t.explicit?.length??0)||t.explicit.includes(e);return n&&i})});let s=0;const a=[];for(let e=0;e<i.length;e++){const t=i[e],l=o[e];try{const e=await t.loadLibraries(l);for(let t=0;t<e.length;t++)a.push(new _n(e[t],l[t]))}catch(e){r.shell.warning(`Loading monomer libraries from provider '${t.name}' failed: `),this.logger.error(`Loading monomer libraries from provider '${t.name}' failed: ${e instanceof Error?e.message:e.toString()}`)}n.update(Math.round(100*++s/i.length),`Loading monomers ${s}/${i.length}`)}this._monomerLib.updateLibs(a,e),this._initialLoadCompleted=!0}catch(e){const t=`Loading monomer libraries error: ${e instanceof Error?e.message:e.toString()}`;r.shell.warning(t);const n=e instanceof Error?e.stack:void 0;this.logger.error(t,void 0,n)}finally{n.close(),this.logger.debug(`${t}, OUT`)}}),this.logger.debug(`${t}, end`),this.loadLibrariesPromise}async loadLibraries(e){return this.loadMonomerLib(e)}loadSetsPromise=Promise.resolve();async loadMonomerSets(e=!1){const t=`${this.toLog()}.loadMonomerSets()`;return this.logger.debug(`${t}, start`),this.loadSetsPromise=this.loadSetsPromise.then(async()=>{this.logger.debug(`${t}, IN`);const e=a.TaskBarProgressIndicator.create("Loading monomer sets ...");try{const t=await this.getProviders(),n=await Promise.all(t.map(async e=>e.listSets())),i=[];let o=0;for(let s=0;s<t.length;s++){const a=t[s],l=n[s];try{const e=await a.loadSets(l);for(let t=0;t<e.length;t++)i.push(e[t])}catch(e){r.shell.warning(`Loading monomer sets from provider '${a.name}' failed: `),this.logger.error(`Loading monomer sets from provider '${a.name}' failed: ${e instanceof Error?e.message:e.toString()}`)}e.update(Math.round(100*++o/t.length),`Loading monomer sets ${o}/${t.length}`)}this._monomerSets.updateSets(i)}catch(e){const t=`Loading monomer sets error: ${e instanceof Error?e.message:e.toString()}`;r.shell.warning(t);const n=e instanceof Error?e.stack:void 0;this.logger.error(t,void 0,n)}finally{e.close(),this.logger.debug(`${t}, OUT`)}}),this.logger.debug(`${t}, end`),this.loadSetsPromise}async loadMonomerLibForTests(){await(0,Pe.E)(Ln.G),await this.awaitLoaded(1e4),await this.loadMonomerLib(!0)}async readSingleLibrary(e,t){const n=(await this.getProviders()).find(t=>t.name===e);if(!n)return this.logger.error(`Provider '${e}' not found.`),null;try{const i=await n.loadLibraries([t]);return 0===i.length?(this.logger.error(`Library '${t}' not found in provider '${e}'.`),null):new _n(i[0],t)}catch(e){return this.logger.error(`Loading monomer library '${t}' from provider '${n.name}' failed: ${e instanceof Error?e.message:e.toString()}`),null}}async readLibraryFromFilePath(e){const t=(await this.getProviders()).find(e=>e.name===we.ic);if(!t)throw new Error(`Provider '${we.ic}' not found.`);const n=await t.getSingleLibraryWithFullPath(e);if(!n)throw new Error(`Library at path '${e}' not found.`);return new _n(n,e)}async readSingleLibraryByName(e){const t=await this.getProviders(),n=await(0,we.pY)(t,e);return n?this.readSingleLibrary(n.name,e):(this.logger.error(`No provider found for library '${e}'.`),null)}async readSingleSet(e,t){const n=(await this.getProviders()).find(t=>t.name===e);if(!n)return this.logger.error(`Provider '${e}' not found.`),null;try{const i=await n.loadSets([t]);return 0===i.length?(this.logger.error(`Set '${t}' not found in provider '${e}'.`),null):i[0]}catch(e){return this.logger.error(`Loading monomer set '${t}' from provider '${n.name}' failed: ${e instanceof Error?e.message:e.toString()}`),null}}static async getInstance(){let e=window.$monomerLibHelperPromise;return null==e&&(e=window.$monomerLibHelperPromise=(async()=>new Hn(qr.logger))()),e}}var Bn=n(1757),Fn=n.n(Bn);class Gn{monomer;root=s.divV([],{classes:"monomer-card-root"});_selected=!1;get selected(){return this._selected}set selected(e){this._selected=e,this.root.style.border=e?"2px solid var(--green-2)":"2px solid var(--grey-2)"}constructor(e){this.monomer=e}render(){s.empty(this.root);const e=this.monomer.smiles&&r.chem.checkSmiles(this.monomer.smiles)?r.chem.drawMolecule(this.monomer.smiles,200,200):r.chem.drawMolecule(this.monomer.molfile??"",200,200);this.root.appendChild(e);const t=s.divH([s.divText("Monomer Name: "),s.divText(this.monomer.name)],{classes:"monomer-card-info-row"});if(this.root.appendChild(t),s.tooltip.bind(t,this.monomer.name),this.monomer.lib?.source){const e=s.divH([s.divText("Source: "),s.divText(this.monomer.lib.source)],{classes:"monomer-card-info-row"});this.root.appendChild(e),s.tooltip.bind(e,this.monomer.lib.source)}const n=s.divH([s.divText("Polymer Type: "),s.divText(this.monomer.polymerType)],{classes:"monomer-card-info-row"});this.root.appendChild(n),s.tooltip.bind(n,this.monomer.polymerType),s.tooltip.bind(this.root,"Select Monomer")}}class Dn{monomerSymbol;monomers;root=s.divH([],{style:{alignItems:"center",width:"100%",overflow:"hidden",visibility:"visible"},classes:"duplicate-monomer-symbol-row"});monomerCards;constructor(e,t,n,i){this.monomerSymbol=e,this.monomers=t,this.monomerCards=t.map(e=>new Gn(e));const o=s.divH([],{style:{overflowX:"auto",width:"100%"}}),r=s.h1(e,{style:{lineHeight:"2em",fontSize:"1.5em",marginRight:"20px",width:"100px",overflow:"hidden",textOverflow:"elipsis"}});s.tooltip.bind(r,e),this.root.appendChild(r),this.root.appendChild(o),this.monomerCards.forEach(e=>{e.root.onclick=()=>{this.monomerCards.forEach(e=>e.selected=!1),e.selected=!0,i(e.monomer)},n&&e.monomer===n&&(e.selected=!0),o.appendChild(e.root)})}render(){this.monomerCards.forEach(e=>e.render())}}class Vn{monomerCardRows=[];saveSettingsPromise=Promise.resolve();searchInput;_root;monomers;settings;filteredMonomerRows=[];static _instance;vv;static async getInstance(){return Vn._instance||(Vn._instance=new Vn,await Vn._instance.refresh(),(await Hn.getInstance()).getMonomerLib().onChanged.subscribe(async()=>await Vn._instance.refresh())),Vn._instance.refresh(),Vn._instance}async refresh(){this.settings=await(0,Pe.u)();const e=await Hn.getInstance();await e.awaitLoaded(),this.monomers=e.duplicateMonomers,this.monomerCardRows=[];for(const t in this.monomers)for(const n in this.monomers[t]){const i=this.settings.duplicateMonomerPreferences?.[t]?.[n]??null,o=i?this.monomers[t][n].find(e=>e.lib?.source===i)??null:null;this.monomerCardRows.push(new Dn(n,this.monomers[t][n],o,async i=>{this.saveSettingsPromise=this.saveSettingsPromise.then(async()=>{i.lib?.source&&(this.settings.duplicateMonomerPreferences=this.settings.duplicateMonomerPreferences??{},this.settings.duplicateMonomerPreferences[t]=this.settings.duplicateMonomerPreferences[t]??{},this.settings.duplicateMonomerPreferences[t][n]=i.lib.source,await(0,Pe.E)(this.settings),e.assignDuplicatePreferances(this.settings),r.shell.info(`Monomer '${i.name}' from source '${i.lib.source}' selected for symbol '${n}'.`))})}))}const t=s.divText("Set Default");if(t.addEventListener("click",async()=>{if(0===Object.keys(this.monomers??{}).length)return void r.shell.info("No Duplicate Monomers found");const t=new Set;for(const e in this.monomers)for(const n in this.monomers[e])for(const i of this.monomers[e][n])i.lib?.source&&t.add(i.lib.source);if(0===t.size)return void r.shell.info("No Duplicate Monomers found");const n=Array.from(t),i=s.input.choice("Default Library",{items:n,nullable:!0});s.dialog("Set Default Monomer Source for Duplicates").add(i).onOK(async()=>{if(i.value){for(const e in this.monomers)for(const t in this.monomers[e]){const n=this.monomers[e][t];n?.some(e=>e.lib?.source===i.value)&&(this.settings.duplicateMonomerPreferences=this.settings.duplicateMonomerPreferences??{},this.settings.duplicateMonomerPreferences[e]=this.settings.duplicateMonomerPreferences[e]??{},this.settings.duplicateMonomerPreferences[e][t]=i.value)}await(0,Pe.E)(this.settings),e.assignDuplicatePreferances(this.settings),r.shell.info(`Default Monomer Source for Duplicates set to '${i.value}'.`),setTimeout(()=>this.refresh(),100)}else r.shell.info("No library selected")}).show()}),this.filteredMonomerRows=this.monomerCardRows,this.vv)this.vv.setData(this.filteredMonomerRows.length,e=>(this.filteredMonomerRows[e].render(),this.filteredMonomerRows[e].root));else{this.vv=s.virtualView(this.monomerCardRows.length,e=>(this.monomerCardRows[e].render(),this.monomerCardRows[e].root)),this.vv.root.classList.add("duplicate-monomers-virtual-view"),this.searchInput=s.input.string("Search",{placeholder:"Monomer Symbol",value:"",onValueChanged:()=>e(this.searchInput.value)}),this.searchInput.root.style.justifyContent="center",this.searchInput.addOptions(t),this.searchInput.input.style.width="200px",this._root=s.divV([s.h1("Manage Duplicate Monomer Symbols",{style:{textAlign:"center"}}),this.searchInput.root,s.divV([this.vv.root],{style:{overflowY:"auto",height:"100%"}})],{style:{height:"100%"}});const e=e=>{this.filteredMonomerRows=this.monomerCardRows.filter(t=>t.monomerSymbol.toLowerCase().includes(e.toLowerCase())),this.vv.setData(this.filteredMonomerRows.length,e=>(this.filteredMonomerRows[e].render(),this.filteredMonomerRows[e].root))}}}constructor(){}get root(){return this._root}}var Wn=n(3017),jn={};async function Un(){await Zn.showDialog()}async function qn(e=!0){return await Xn.showView(e)}jn.styleTagTransform=S(),jn.setAttributes=b(),jn.insert=g().bind(null,"head"),jn.domAPI=m(),jn.insertStyleElement=w(),d()(Wn.A,jn),Wn.A&&Wn.A.locals&&Wn.A.locals;class zn{_widget;get widget(){return this._widget}constructor(){}static instancePromise;libHelper;static async getInstance(){return null==zn.instancePromise&&(zn.instancePromise=(async()=>{const e=new zn,t=await(0,we.pj)();return e.libHelper=t,e._widget=await e.createWidget(),e})()),zn.instancePromise}static async reloadWidget(){const e=await zn.getInstance();e._widget=await e.createWidget()}_fileUploadSubscription=null;async createWidget(){const e=await this.getWidgetContent(),t=await(0,we.pj)();return this._fileUploadSubscription?.unsubscribe(),this._fileUploadSubscription=t.fileUploadRequested.subscribe(()=>this.promptToAddLibraryFiles()),new a.Widget(e)}async getWidgetContent(){const e=await Yn.createControlsForm();return Fn()(e).addClass("monomer-lib-controls-form"),setTimeout(()=>{e&&Fn()(e)&&Fn()(e).removeClass("ui-form-condensed")},200),s.divV([e])}async promptToAddLibraryFiles(){a.Utils.openFile({accept:".json",open:async e=>{const t=async t=>{const n=e.name;if((await t.listLibraries()).includes(n)&&!await new Promise(e=>{s.dialog("Confirm Library Update").add(s.divText(`Library '${n}' already exists. Do you want to overwrite it?`)).onOK(()=>e(!0)).onCancel(()=>e(!1)).show()}))return;const i=await e.text(),o=a.TaskBarProgressIndicator.create(`Adding ${n} as a monomer library`);try{await t.addOrUpdateLibraryString(n,i)}catch(e){r.shell.error(`File ${n} is not a valid monomer library, verify it is aligned to HELM JSON schema.`),console.error(e)}finally{o.close()}},n=await this.libHelper.getProviders();if(0===n.length)return void r.shell.error("No monomer library providers available to add the library.");if(1===n.length)return void await t(n[0]);const i=s.dialog("Select storage for new monomer library"),o=s.input.choice("Storage",{items:n.map(e=>e.name),value:n[0].name,nullable:!1,tooltipText:"Storage provider for new monomer library"});i.add(o).onOK(async()=>{const e=n.find(e=>e.name===o.value);await t(e)}).show()}})}}class Yn{libHelper;userLibSettings;constructor(e,t){this.libHelper=e,this.userLibSettings=t,this.libHelper.providersDataChanged.subscribe(async()=>{await this.updateControlsForm()})}toLog(){return"LibraryControlsManager<#>"}static async createControlsForm(){qr.logger.debug("LibraryControlsForm.createControlsForm(), start");const e=await(0,Pe.u)(),t=await(0,we.pj)();return new Yn(t,e)._createControlsForm()}async _createControlsForm(){const e=await this.createLibraryControls(),t=s.wideForm(e,void 0);return Fn()(t).addClass("monomer-lib-controls-form"),t}async updateControlsForm(){const e=await this._createControlsForm();Fn()(".monomer-lib-controls-form").replaceWith(e)}async createLibraryControls(){return(await this.libHelper.getAvaliableLibraryNames()).map(e=>this.createLibInput(e))}createLibInput(e){const t=`${this.toLog()}.createLibInput()`;qr.logger.debug(`${t}, libFileName = '${e}', start`);const n=!this.userLibSettings.exclude.includes(e),i=s.input.bool(e,{value:n,onValueChanged:()=>{Kn(i.value,e)}});s.tooltip.bind(i.root,`Include monomers from ${e}`);const o=s.iconFA("trash-alt",()=>this.promptForLibraryDeletion(e)),a=s.icons.edit(async()=>{r.shell.v=await(await nn.getInstance()).getViewRoot(e)},"Edit monomer library");return s.tooltip.bind(o,`Delete ${e}`),i.addOptions(a),i.addOptions(o),qr.logger.debug(`${t}, libFileName = '${e}', end`),i}promptForLibraryDeletion(e){s.dialog("Warning").add(s.divText(`Are you sure you want to delete library "${e}"?`)).onOK(async()=>{try{const t=a.TaskBarProgressIndicator.create(`Deleting ${e} library`);await Kn(!1,e);const n=await(0,we.pY)(await this.libHelper.getProviders(),e);if(!n)throw new Error(`Cannot find provider for library ${e}`);await n.deleteLibrary(e),t.close()}catch(t){console.error(t),r.shell.error(`Failed to delete ${e} library`)}}).showModal(!1)}}async function Kn(e,t){const n=await(0,Pe.u)();!function(e,t,n){t?e.exclude=e.exclude.filter(e=>e!==n):e.exclude.includes(n)||e.exclude.push(n)}(n,e,t),await(0,Pe.E)(n);const i=await(0,we.pj)();await i.loadMonomerLib(!0),r.shell.info("Monomer library user settings saved"),i.notifyLibrarySelectionChanged()}class Zn{constructor(){}static _instance;dialog;closeDialogSubject$=new u.Subject;static async showDialog(){Zn._instance||(Zn._instance=new Zn,Zn._instance.closeDialogSubject$.subscribe(()=>{Zn._instance.dialog=void 0})),Zn._instance.dialog||(Zn._instance.dialog=await Zn._instance.getDialog()),Zn._instance.dialog.show()}async getDialog(){const e=(await zn.getInstance()).widget,t=await(0,we.pj)(),n=s.dialog({title:"Manage monomer libraries",helpUrl:"/help/datagrok/solutions/domains/bio/bio.md#manage-monomer-libraries"});Fn()(n.root).css("width","350px"),n.clear(),n.addButton("Add",()=>t.requestFileUpload(),void 0,"Upload new HELM monomer library"),n.add(e);const i=n.onClose.subscribe(()=>{this.closeDialogSubject$.next(),i.unsubscribe()});return n}}class Xn{constructor(){}static _instance;static viewName="Manage Monomer Libraries";_view;_duplicateManager;libManager;async getView(e=!0){const t=(await zn.getInstance()).widget,n=s.bigButton("Add",()=>this.libManager.requestFileUpload(),"Upload new HELM monomer library"),i=s.bigButton("Merge",()=>{this.mergeSelectedLibs()},"Merge selected libraries into one"),o=s.splitH([s.divV([t.root,s.buttonsInput([n,i])],{classes:"ui-form"}),this._duplicateManager.root],{style:{width:"100%",height:"100%"}},!0);if(this._view)try{this._view.subs.forEach(e=>e.unsubscribe()),this._view.detach(),this._view.close()}catch(e){}return this._view=a.View.fromRoot(o),this._view.name=Xn.viewName,e&&r.shell.addView(this._view),s.tools.waitForElementInDom(o).then(()=>{setTimeout(()=>{const e=Array.from(o.children).filter(e=>e.classList.contains("ui-box"));if(2!==e.length)return;const[t,n]=e,i=t.getBoundingClientRect().width+n.getBoundingClientRect().width,r=.3*i;t.style.width=`${r}px`;const s=i-r;n.style.width=`${s}px`},100),this._view.subs.push(r.events.onCurrentViewChanged.subscribe(()=>{try{const e=Xn._instance;e&&e._view&&r.shell.v&&"id"in r.shell.v&&r.shell.v.id===e._view.id&&e._duplicateManager?.refresh()}catch(e){console.error(e)}}))}),this._view}static async showView(e=!0){return Xn._instance||(Xn._instance=new Xn),Xn._instance._duplicateManager||(Xn._instance._duplicateManager=await Vn.getInstance()),Xn._instance.libManager||(Xn._instance.libManager=await Hn.getInstance()),e&&Xn._instance._view&&Array.from(r.shell.views).find(e=>e.id&&e.id===Xn._instance._view.id)?(r.shell.v=Xn._instance._view,await Xn._instance._duplicateManager.refresh(),Xn._instance._view):(Xn.closeExistingViews(),Xn._instance.getView(e))}static closeExistingViews(){Array.from(r.shell.views).filter(e=>e.name===Xn.viewName).forEach(e=>e.close())}async mergeSelectedLibs(){const e="Library with this name already exists",t=await Hn.getInstance();if(await t.awaitLoaded(),!t.duplicatesHandled)return void r.shell.warning("Selected libraries contain repeating symbols with different monomers.\n Please choose the correct monomer for each symbol using duplicate monomomer manager.");const n=t.getBioLib().toJSON(),i=s.dialog("Merge selected libraries"),o=s.input.string("Library Name",{placeholder:"Enter new library name",nullable:!1,onValueChanged:()=>{const t=c(o.value);i.getButton("Download")?.classList?.toggle("d4-disabled",!!t&&t!==e),i.getButton("Save")?.classList?.toggle("d4-disabled",!!t)}}),l=await this.libManager.getAvaliableLibraryNames();function c(t){return t&&t.trim()?l.includes(t)||l.includes(t+".json")?e:null:"Library name cannot be empty"}o.addValidator(c);const u=await this.libManager.getProviders();if(0===u.length)return void r.shell.error("No monomer library providers available to save the merged library.");const h=s.input.choice("Storage",{items:u.map(e=>e.name),value:u[0].name,nullable:!1,tooltipText:"Storage provider for saving new monomer library"});i.add(h).add(o).add(s.divText(`Total monomers: ${n.length}`)).addButton("Download",()=>{a.Utils.download((()=>{let e=o.value.trim();return e||(e="New"),e.toLowerCase().endsWith(".json")||(e+=".json"),e})(),JSON.stringify(n))}).addButton("Save",async()=>{if(!o.value||!o.value.trim()||!h.value)return h.validate(),void o.validate();i.close();const e=o.value,t=JSON.stringify(n);this._view&&s.setUpdateIndicator(this._view.root,!0);try{const n=u.find(e=>e.name===h.value);await n.addOrUpdateLibraryString(e,t);const i=await(0,Pe.u)();i.exclude=l,await(0,Pe.E)(i),await this.libManager.loadMonomerLib(!0),await zn.reloadWidget()}catch(t){r.shell.error(`Failed to save library ${e}. see console for details.`),console.error(t)}finally{this._view&&s.setUpdateIndicator(this._view.root,!1)}}).show(),i.getButton("Download")?.classList?.add("d4-disabled"),i.getButton("Save")?.classList?.add("d4-disabled")}}var Jn,Qn=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function s(e){try{l(i.next(e))}catch(e){r(e)}}function a(e){try{l(i.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((i=i.apply(e,t||[])).next())})};class ei{_setBreadcrumbsInViewName(){var e,t;const n=["Home","Demo",...(null!==(e=this._path)&&void 0!==e?e:"").split("/")],i=s.breadcrumbs(n);if(i.onPathClick.subscribe(e=>Qn(this,void 0,void 0,function*(){const t=e[e.length-1];if(t===i.path[i.path.length-1])return;const n=r.shell.browsePanel.mainTree.getOrCreateGroup("Apps").getOrCreateGroup("Demo");n.currentItem="Demo"===t?n:n.items.find(e=>e.text===t)})),r.shell.v){if(0!==i.path.length&&"Home"===i.path[0]){const e=s.iconFA("home",()=>{r.shell.v.close(),r.shell.v=a.View.createByType(a.VIEW_TYPE.HOME)});e.classList.add("demo-breadcrumbs-home-element"),i.root.firstElementChild.replaceWith(e)}const e=null===(t=r.shell.v.ribbonMenu.root.parentElement)||void 0===t?void 0:t.getElementsByClassName("d4-ribbon-name")[0];e&&(e.textContent="",e.appendChild(i.root))}}constructor(e,t,n=!1,i){var o,r;this.name="",this.description="",this._isAutomatic=!1,this._autoStartFirstStep=!1,this._currentStep=0,this._isStopped=!1,this._isCancelled=!1,this._isStepProcessed=!1,this._root=s.div([],{id:"demo-script",classes:"tutorials-root tutorials-track demo-app-script"}),this._steps=[],this._mainHeader=s.panel([],"tutorials-main-header"),this._header=s.h2(""),this._headerDiv=s.divH([],"tutorials-root-header"),this._stopStartBtn=s.button(s.iconFA("pause"),()=>Qn(this,void 0,void 0,function*(){return yield this._changeStopState()}),"Play / pause"),this._restartBtn=s.button(s.iconFA("redo"),()=>Qn(this,void 0,void 0,function*(){return yield this._restartScript()}),"Restart"),this._nextStepBtn=s.button(s.iconFA("play"),()=>Qn(this,void 0,void 0,function*(){this._isStepProcessed||(yield this._nextStep())}),"Next step"),this._activity=s.panel([],"tutorials-root-description"),this._progressDiv=s.divV([],"tutorials-root-progress"),this._progress=s.element("progress"),this._progressSteps=s.divText(""),this._closeBtn=s.button(s.iconFA("chevron-left"),()=>this._closeDock(),"Back to demo"),this.DEMO_PATH="apps/Tutorials/Demo",this.name=e,this.description=t,this._isAutomatic=n,this._autoStartFirstStep=null!==(o=null==i?void 0:i.autoStartFirstStep)&&void 0!==o&&o,this._path=null!==(r=null==i?void 0:i.path)&&void 0!==r?r:"",this._progress.max=0,this._progress.value=1,ei.currentObject=this}get steps(){return this._steps}get stepNumber(){return this._steps.length}_addHeader(){this._createHeaderDiv(),this._createProgressDiv(),this._mainHeader.append(this._headerDiv,this._progressDiv)}_createHeaderDiv(){this._header.innerText=this.name,this._headerDiv.append(this._closeBtn),this._headerDiv.append(this._header),this._nextStepBtn.firstChild.className="grok-icon fas fa-play",this._headerDiv.append(this._isAutomatic?this._stopStartBtn:this._nextStepBtn)}_createProgressDiv(){this._progress.max=this.stepNumber,this._progressDiv.append(this._progress),this._progressSteps=s.divText(`Step: ${this._progress.value} of ${this.stepNumber}`),this._progressDiv.append(this._progressSteps)}_addDescription(){var e;this._activity.append(s.div(this.description,"tutorials-root-description"));for(let t=0;t<this.stepNumber;t++){let n=s.iconFA("clock");this._isAutomatic||0===t&&(n=s.iconFA("play",()=>this._nextStep(),"Next step"),n.className="grok-icon fas fa-play");const i=s.div(this._steps[t].name,"grok-tutorial-entry-instruction"),o=s.div(null===(e=this._steps[t].options)||void 0===e?void 0:e.description,"grok-tutorial-step-description hidden"),r=s.divH([n,i],"grok-tutorial-entry");this._activity.append(r,o)}}_initRoot(){r.shell.windows.showContextPanel=!0,r.shell.windows.showHelp=!1,this._node=r.shell.dockManager.dock(this._root,a.DOCK_TYPE.FILL,r.shell.dockManager.findNode(r.shell.browsePanel.root),this.name),this._node.container.containerElement.classList.add("tutorials-demo-script-container"),this._addHeader(),this._root.append(this._mainHeader),this._addDescription(),this._root.append(this._activity)}_setViewParams(){var e;r.shell.v&&(r.shell.v.name=this.name,r.shell.v.path=`${this.DEMO_PATH}/${(null!==(e=this._path)&&void 0!==e?e:"").replaceAll(" ","-")}`,this._setBreadcrumbsInViewName())}_nextStep(){return Qn(this,void 0,void 0,function*(){var e,t;this._isStepProcessed=!0,this._isAutomatic||(this._nextStepBtn.classList.add("disabled"),this._nextStepBtn.firstChild.classList.add("fa-disabled"));const n=this._activity.getElementsByClassName("grok-tutorial-entry")[this._currentStep],i=this._activity.getElementsByClassName("grok-icon")[this._currentStep],o=this._activity.getElementsByClassName("grok-tutorial-step-description")[this._currentStep];i.className="grok-icon far fa-spinner-third fa-spin",o.classList.remove("hidden"),o.classList.add("visible");const l=n,c=(null===(e=this._steps[this._currentStep].options)||void 0===e?void 0:e.delay)?null===(t=this._steps[this._currentStep].options)||void 0===t?void 0:t.delay:2e3;try{this._setViewParams(),yield this._steps[this._currentStep].func(),this._setViewParams()}catch(e){console.error(e)}this._scrollTo(this._root,l.offsetTop-this._mainHeader.offsetHeight),this._isAutomatic&&(yield this._countdown(n,i,c),yield(0,et.cb)(c));const u=s.iconFA("check");if(i.replaceWith(u),u.className="grok-icon far fa-check",this._progress.value++,this._progressSteps.innerText=`Step: ${this._progress.value} of ${this.stepNumber}`,this._currentStep++,this._isStepProcessed=!1,this._currentStep!==this.stepNumber){if(!this._isAutomatic){const e=this._activity.getElementsByClassName("grok-icon")[this._currentStep],t=s.iconFA("play",()=>this._nextStep(),"Next step");t.className="grok-icon fas fa-play",e.replaceWith(t),this._nextStepBtn.classList.remove("disabled"),this._nextStepBtn.firstChild.classList.remove("fa-disabled")}r.shell.v instanceof a.TableView&&(yield r.data.detectSemanticTypes(r.shell.tv.dataFrame))}else this._isAutomatic?this._stopStartBtn.replaceWith(this._restartBtn):this._nextStepBtn.replaceWith(this._restartBtn)})}_startScript(){return Qn(this,void 0,void 0,function*(){for(let e=this._currentStep;e<this.stepNumber&&!this._isStopped&&!this._isCancelled;e++)yield this._nextStep()})}_scrollTo(e,t){e.focus(),e.scrollTop=t}_countdown(e,t,n){return Qn(this,void 0,void 0,function*(){const i=s.div([],"demo-script-countdown");t.classList.add("hidden");let o=n/1e3;const r=this._createSVGIndicator(o);i.append(r),e.prepend(i);const a=setInterval(()=>{o--,0===o&&(clearInterval(a),i.remove(),t.classList.remove("hidden"),t.classList.add("visible"))},1e3)})}_createSVGIndicator(e){const t=document.createElementNS("http://www.w3.org/2000/svg","svg"),n=document.createElementNS("http://www.w3.org/2000/svg","circle");return n.setAttributeNS(null,"cx","7"),n.setAttributeNS(null,"cy","7"),n.setAttributeNS(null,"r","6"),n.setAttributeNS(null,"style",`animation: countdown ${e}s linear infinite forwards`),t.append(n),t}_changeStopState(){return Qn(this,void 0,void 0,function*(){const e=this._stopStartBtn.getElementsByClassName("grok-icon");e[0].className="grok-icon fas fa-play",this._isStopped=!this._isStopped,this._isStopped||(e[0].className="grok-icon fal fa-pause",this._isStepProcessed||(yield this._startScript()))})}_restartScript(){return Qn(this,void 0,void 0,function*(){r.shell.dockManager.close(this._node),this._clearRoot(),this._setInitParams(),yield this.start()})}_clearRoot(){this._root=s.div([],{id:"demo-script",classes:"tutorials-root tutorials-track demo-app-script"}),this._mainHeader=s.panel([],"tutorials-main-header"),this._header=s.h2(""),this._headerDiv=s.divH([],"tutorials-root-header"),this._activity=s.panel([],"tutorials-root-description"),this._progressDiv=s.divV([],"tutorials-root-progress"),this._progress=s.element("progress"),this._progressSteps=s.divText(""),this._progress.max=0,this._progress.value=1}_setInitParams(){this._currentStep=0,this._isStopped=!1,this._isCancelled=!1,this._stopStartBtn.getElementsByClassName("grok-icon")[0].className="grok-icon fal fa-pause",this._nextStepBtn.classList.remove("disabled")}_closeDock(){r.shell.dockManager.close(this._node),this.cancelScript()}cancelScript(){this._isCancelled=!0,ei.currentObject=null}step(e,t,n){return this._steps[this.steps.length]={name:e,func:t,options:n},this}start(){return Qn(this,void 0,void 0,function*(){this._initRoot(),r.shell.v.name===this.name&&(r.shell.v.close(),this._node=r.shell.dockManager.dock(this._root,a.DOCK_TYPE.FILL,r.shell.dockManager.findNode(r.shell.browsePanel.root),this.name)),this._isAutomatic?yield this._startScript():this._autoStartFirstStep&&(yield this._nextStep())})}}ei.currentObject=null,function(e){e.X="Embed_X",e.Y="Embed_Y"}(Jn||(Jn={}));var ti=n(966),ni=n(608),ii=n(1619);class oi{urlParams;funcName;options;df;view;constructor(e,t,n={}){this.urlParams=e,this.funcName=t,this.options=n}async init(e){this.df=e,await this.buildView()}async buildView(){const e=R()(this.urlParams.entries()).map(([e,t])=>`${e}=${encodeURIComponent(t)}`).toArray().join("&");this.view=r.shell.addTableView(this.df),this.view.path=this.view.basePath=`func/${qr.name}.${this.funcName}?${e}`;const t={...this.options,sequenceColumnName:"sequence"};for(const[e,n]of this.urlParams.entries())switch(e){case ot.n5.fixWidth:case ot.n5.fitArea:t[e]=(e=>["1","on","true"].includes(e.toLowerCase()))(n);break;default:t[e]=n}const n=await this.view.dataFrame.plot.fromType("WebLogo",t);this.view.dockManager.dock(n,a.DOCK_TYPE.DOWN,null,"WebLogo",.35)}}class ri{tableInput;seqColInput;funcParamsDiv;get funcParams(){return{table:this.tableInput.value,sequence:this.seqColInput.value}}get paramsUI(){return this.funcParamsDiv}constructor(){this.tableInput=s.input.table("Table",{value:r.shell.tv.dataFrame,onValueChanged:()=>{this.onTableInputChanged()}});const e=this.tableInput.value.columns.bySemType(a.SEMTYPE.MACROMOLECULE);this.seqColInput=s.input.column("Sequence",{table:this.tableInput.value,value:e,filter:e=>e.semType===a.SEMTYPE.MACROMOLECULE}),this.funcParamsDiv=s.inputs([this.tableInput,this.seqColInput],{style:{minWidth:"320px"}})}onTableInputChanged(){this.seqColInput=s.input.column("Sequence",{table:this.tableInput.value,value:this.tableInput.value.columns.bySemType(a.SEMTYPE.MACROMOLECULE)})}}var si=n(6869);new class{tooltipHandlerTemp="tooltip-handler.Monomer"};const ai="-";class li extends je{constructor(e,t){super(e,t)}render(e,t,n,i,o,r,s){e.save(),e.beginPath(),e.rect(t,n,i,o),e.clip();try{if(!r.isTableCell)return;const s=r.cell?.column&&r.cell.column?.dart&&"true"===r.cell.column.getTag(ke.Mn.applyToBackground);e.font="12px monospace",e.textBaseline="middle",e.textAlign="left";let a=r.cell.value;a&&a!==ve._S||(a=ai);const l=a.split(ve.ot).map(e=>e&&e!==ve._S?e.trim():ai),c=l.map(e=>(0,me.zS)(e,Math.max(2,Math.floor(.15*i/l.length)))),u=c.map(t=>e.measureText(t).width),h=u.reduce((e,t)=>e+t,0);let d=t+(i-h)/2;const p=this.tableCol.getTag(ve.gp.alphabet),m=p===me.YI.RNA||p===me.YI.DNA?si.o.NUCLEOTIDE:si.o.AA;for(let a=0;a<c.length;a++){const h=l[a],p=this.getHelmType(r,m);let f=He.S$,g="rgb(255, 255, 255)";if(this.monomerLib)if(s){const e=this.monomerLib.getMonomerColors(p,h);f=e?.textcolor??f,g=e?.backgroundcolor??g}else f=this.monomerLib.getMonomerTextColor(p,h);s&&1==l.length&&(e.fillStyle=g,e.fillRect(t,n,i,o)),e.fillStyle=f,e.fillText(c[a],d,n+o/2,i),d+=u[a]}}finally{e.restore()}}onMouseMove(e,t){if(e.grid.dart!=this.gridCol?.grid.dart||e.gridColumn.dart!=this.gridCol?.dart||!e.tableColumn||!e.isTableCell)return!1;const n=e.tableColumn.getTag(ve.gp.alphabet),i=e.cell.value,o=e.grid.canvas.getBoundingClientRect(),r=e.bounds.right+o.left-4,a=e.bounds.bottom+o.top-4;if(!i||i==ve._S||i==ai)return s.tooltip.show(s.divText("gap"),r,a),!0;if(!this.monomerLib)return s.tooltip.show(s.divText("Monomer library is not available."),r,a),!0;const l=n===me.YI.RNA||n===me.YI.DNA?si.o.NUCLEOTIDE:si.o.AA,c=i.split(ve.ot).map(t=>{if(!t||t===ve._S||t===ai)return s.divText("gap");const n=this.getHelmType(e,l);return this.monomerLib.getTooltip(n,t)}),u=s.divH(c,{style:{alignItems:"top"}}),h=Array.from(u.querySelectorAll("canvas"));if(h.length>2){const e=Math.floor(550/h.length);h.forEach(t=>{t.style.setProperty("max-width",`${e}px`,"important"),t.style.setProperty("max-height",`${e}px`,"important")})}return s.tooltip.show(u,r,a),!0}getHelmType(e,t){let n=t;if((e.tableRowIndex??-1)>-1&&e.tableColumn?.getTag(ve.qE.polymerTypeColumnName)){const t=e.tableColumn.getTag(ve.qE.polymerTypeColumnName),i=e.tableColumn.dataFrame?.col(t);if(i){const t=i.get(e.tableRowIndex);t&&["BLOB","CHEM","G","PEPTIDE","RNA"].includes(t)&&(n=(0,Be.MD)(t))}}return n}async awaitRendered(e=1e4,t=`${e} timeout`){return Promise.resolve()}static getOrCreate(e){const[t,n,i]=(0,Ge.BG)(e);let o=i.rendererBack;return o||(o=i.rendererBack=new li(t,n)),o}}class ci extends a.GridCellRenderer{get name(){return Ue.uF.MONOMER}get cellType(){return Ue.uF.MONOMER}get defaultHeight(){return 15}get defaultWidth(){return 40}render(e,t,n,i,o,r,s){li.getOrCreate(r).render(e,t,n,i,o,r,s)}onMouseMove(e,t){li.getOrCreate(e).onMouseMove(e,t),t.preventDefault()}}class ui{constructor(e,t,n=""){this.target=e,this.debugEnabled=t,this.prefix=n}error(e,t,n){return this.target.error(this.prefix+e,t,n)}warning(e,t){return this.target.warning(this.prefix+e,t)}info(e,t){return this.target.info(this.prefix+e,t)}debug(e,t){if(this.debugEnabled)return this.target.debug(this.prefix+e,t)}}class hi extends Map{_onPropertyChanged=new u.Subject;get onPropertyChanged(){return this._onPropertyChanged}get fontSize(){const e=super.get("FontSize");return e&&!isNaN(e)?Number.parseInt(e):12}set fontSize(e){super.set("FontSize",e),this._onPropertyChanged.next("FontSize")}get maxMonomerLength(){const e=super.get("MaxMonomerLength");return"long"===e?null:parseInt(e)}set maxMonomerLength(e){const t=null==e?"long":e.toString();super.set("MaxMonomerLength",t),this._onPropertyChanged.next("MaxMonomerLength")}get tooltipWebLogo(){return super.get("TooltipWebLogo")}set tooltipWebLogo(e){super.set("TooltipWebLogo",e),this._onPropertyChanged.next("TooltipWebLogo")}get defaultSeparator(){return super.get("DefaultSeparator")}set defaultSeparator(e){if(1!==e.length)throw new Error("The separator must be of length one.");super.set("DefaultSeparator",e),this._onPropertyChanged.next("DefaultSeparator")}constructor(e){super(Object.entries(e))}}class di extends a.Package{_properties;_seqHelper;get seqHelper(){if(!this._seqHelper)throw new Error("Package Bio .seqHelper is not initialized.");return this._seqHelper}_monomerLib;get monomerLib(){if(!this._monomerLib)throw new Error("Package Bio .monomerLib is not initialized.");return this._monomerLib}_monomerSets;get monomerSets(){if(!this._monomerSets)throw new Error("Package Bio .monomerSets is not initialized.");return this._monomerSets}_rdKitModule;get rdKitModule(){if(!this._rdKitModule)throw new Error("Package Bio .rdKitModule is not initialized.");return this._rdKitModule}get properties(){return this._properties}set properties(e){this._properties=e}_initialized=!1;get initialized(){return this._initialized}constructor(e={debug:!1}){super(),super._logger=new ui(super.logger,e.debug)}completeInit(e,t,n,i){this._seqHelper=e,this._monomerLib=t,this._monomerSets=n,this._rdKitModule=i,this._initialized=!0}handleErrorUI(e){const[t,n]=(0,Se.AP)(e);r.shell.error(t),this.logger.error(t,void 0,n)}}var pi=n(6307),mi=n(5999),fi={};fi.styleTagTransform=S(),fi.setAttributes=b(),fi.insert=g().bind(null,"head"),fi.domAPI=m(),fi.insertStyleElement=w(),d()(mi.A,fi),mi.A&&mi.A.locals&&mi.A.locals;class gi extends a.Widget{seqCol;seqHelper;get type(){return"MacromoleculeColumnWidget"}viewed=!1;wlViewer=null;constructor(e,t){super(s.divV([])),this.seqCol=e,this.seqHelper=t}async init(){const e=this.seqHelper.getSeqHandler(this.seqCol),t=qr.properties.tooltipWebLogo,n=this.seqCol.getTag(tt.gp.tooltipWebLogo);!1===t||["false","off","disable","disabled"].includes(n)||(this.wlViewer=await this.seqCol.dataFrame.plot.fromType("WebLogo",{sequenceColumnName:this.seqCol.name,backgroundColor:0,positionHeight:"Entropy",positionWidth:e.getAlphabetIsMultichar()?24:16,fixWidth:!0,fitArea:!1,positionNames:"",endPositionName:"50"}),this.wlViewer.root.style.height="50px",this.root.appendChild(this.wlViewer.root),this.root.style.width="100%")}detach(){this.wlViewer&&(this.wlViewer.detach(),this.wlViewer=null),super.detach()}}function yi(e,t,n,i){const o=qr.seqHelper.getSeqHandler(e);let r=null,s=null;for(let e=0;e<o.posList.length;++e)o.posList[e]==t&&(r=e),o.posList[e]==n&&(s=e);if(null==r&&null!==t)throw new Error(`Start position ${t} not found.`);if(null==s&&null!==n)throw new Error(`End position ${n} not found.`);if(o.posList.length<s)throw new Error(`End position ${s} exceeds positions length`);const a=i||`${e.name}: (${t??""}-${n??""})`;return o.getRegion(r,s,a)}const bi={df:a.DataFrame.fromCsv("seq,value\nATCCGTCGT,0.5\nTGTTCGTCA,0.4\nATGGTCGTA,0.7\nATCCGTGCA,0.1"),colName:"seq",positionNames:["1","1A","1C","2","4","4A","4B","5","6"].join(me.z1),regions:[{name:"first region",start:"1",end:"2"},{name:"second region",start:"1C",end:"4"},{name:"overlapping second",start:"1C",end:"4A"},{name:"whole sequence",start:"1",end:"6"},{name:"bad start",start:"0",end:"6"},{name:"bad end",start:"1",end:"4C"},{name:"bad start & end",start:"0",end:"4C"}]};class vi{urlParams;funcName;view;data;constructor(e,t){this.urlParams=e,this.funcName=t}async init(e){this.data=e??bi;const t=this.data.df.getCol(this.data.colName);this.data.positionNames&&t.setTag(me.gp.positionNames,this.data.positionNames),this.data.regions&&t.setTag(me.gp.regions,JSON.stringify(this.data.regions)),await this.buildView()}async buildView(){await r.data.detectSemanticTypes(this.data.df),this.view=r.shell.addTableView(this.data.df),this.view.path=this.view.basePath=`func/${qr.name}.${this.funcName}`;const e=await this.view.dataFrame.plot.fromType("WebLogo",{sequenceColumnName:this.data.colName});this.view.dockManager.dock(e,a.DOCK_TYPE.DOWN,null,"WebLogo",.35)}}class wi{call;seqHelper;inputs=new class{table;sequence;region;start;end;name};constructor(e,t){this.call=e,this.seqHelper=t;const n=e=>this.call.inputParams[e].property.description;this.inputs.table=s.input.table("Table",{value:this.call.inputParams.table.value??r.shell.tv.dataFrame});const i=this.call.inputParams.sequence.value??this.inputs.table.value.columns.bySemType(a.SEMTYPE.MACROMOLECULE);this.inputs.sequence=s.input.column("Sequence",{table:r.shell.tv.dataFrame,value:i,onValueChanged:this.sequenceInputChanged.bind(this),filter:e=>e.semType===a.SEMTYPE.MACROMOLECULE}),this.inputs.start=s.input.choice("Start",{onValueChanged:this.startInputChanged.bind(this)}),this.inputs.end=s.input.choice("End",{onValueChanged:this.endInputChanged.bind(this)}),this.inputs.region=s.input.choice("Region",{value:null,items:[],onValueChanged:this.regionInputChanged.bind(this)}),this.inputs.name=s.input.string("Column name",{value:this.getDefaultName(),onValueChanged:this.nameInputChanged.bind(this),clearIcon:!0}),this.inputs.name.onInput.subscribe(()=>this.nameInputInput.bind(this));for(const e in this.call.inputParams)s.tooltip.bind(this.inputs[e].captionLabel,n(e));this.sequenceInputChanged()}sequenceInputChanged(){const e=this.inputs.sequence.value;e&&this.seqHelper.getSeqHandler(e),this.updateRegionItems(),this.updateStartEndInputItems(),this.updateRegion(!0),this.updateNameInput()}fixRegion=!1;regionInputChanged(){this.fixRegion=!0;try{const e=this.inputs.region.stringValue,t=e?JSON.parse(e):null;if(null!==t)this.inputs.start.value=t?.start,this.inputs.end.value=t?.end;else{const e=this.seqHelper.getSeqHandler(this.inputs.sequence.value);this.inputs.start.value=e.posList[0],this.inputs.end.value=e.posList[e.posList.length-1]}}finally{this.fixRegion=!1}}startInputChanged(){this.updateRegion(!1),this.updateNameInput()}endInputChanged(){this.updateRegion(!1),this.updateNameInput()}nameInputChanged(){this.defaultNameUpdating||(this.defaultName=!1)}nameInputInput(){this.inputs.name.value||(this.defaultName=!0,this.inputs.name.input.focus())}updateStartEndInputItems(){const e=this.inputs.sequence.value,t=e?this.seqHelper.getSeqHandler(e):null,n=this.inputs.start.input,i=this.inputs.end.input;for(let e=n.options.length-1;e>=0;--e)n.options.remove(e);for(let e=i.options.length-1;e>=0;--e)i.options.remove(e);for(const e of t?.posList??[]){const t=document.createElement("option"),o=document.createElement("option");t.text=o.text=e,t.value=o.value=e,n.options.add(t),i.options.add(o)}n.value=t?.posList[0]??"",i.value=t?.posList[t?.posList.length-1]??""}updateRegionItems(){const e=this.inputs.sequence.value,t=e?e.getTag(me.gp.regions):null,n=t?JSON.parse(t):null,i=this.inputs.region.input;for(let e=i.options.length-1;e>=0;--e)i.options.remove(e);const o=document.createElement("option");if(o.text="",o.value=JSON.stringify(null),i.options.add(o),null!=n){this.inputs.region.root.style.removeProperty("display");for(const e of n){const t=document.createElement("option");t.text=`${e.name}: ${e.start}-${e.end}`,t.value=JSON.stringify(e),i.options.add(t)}}else this.inputs.region.root.style.display="none"}updateRegion(e){const t=this.inputs.start.stringValue??"",n=this.inputs.end.stringValue??"";if(!this.fixRegion){const e=this.inputs.region.input;e.selectedIndex=-1;for(let i=e.options.length-1;i>=0;--i){const o=e.options[i],r=JSON.parse(o.value);r&&t===r.start&&n===r.end&&(e.selectedIndex=i)}}}defaultName=!0;defaultNameUpdating=!1;updateNameInput(){this.defaultNameUpdating=!0;try{this.defaultName&&(this.inputs.name.value=this.getDefaultName())}finally{this.defaultNameUpdating=!1}}getDefaultName(){const e=this.inputs.region.stringValue,t=e?JSON.parse(e):null,n=this.inputs.sequence.value,i=this.inputs.start.stringValue??"",o=this.inputs.end.stringValue??"";return null!=t?`${n.name}(${t.name}): ${t.start}-${t.end}`:`${n?.name}: (${i}-${o})`}getParams(){return{table:this.inputs.table.value,sequence:this.inputs.sequence.value,start:this.getStart(),end:this.getEnd(),name:this.getName()}}getStart(){return this.inputs.start.stringValue}getEnd(){return this.inputs.end.stringValue}getName(){const e=this.inputs.name.stringValue;return""==e?null:e}dialog(){const e=s.inputs(Object.values(this.inputs),{style:{minWidth:"320px"}});s.dialog({title:"Get Region"}).add(e).onOK(()=>{(async()=>{const e=this.getParams();await this.call.func.prepare(e).call(!0)})().catch(e=>{qr.handleErrorUI(e)})}).show()}widget(){const e=s.inputs(Object.entries(this.inputs).filter(([e,t])=>!["table","sequence"].includes(e)).map(([e,t])=>t)),t=s.button("Get Region",()=>{(async()=>{const e=this.getParams();await this.call.func.prepare(e).call(!0)})().catch(e=>{qr.handleErrorUI(e)})});return a.Widget.fromRoot(s.divV([e,s.div(t)]))}}var Ci=n(8754);async function Si(e,t,n,i,o){const s=await async function(e,t,n,i,o){const s=ye(t,o),l=o.getSeqHandler(t).getNewColumnFromList("ref",[n]),c=o.getSeqHandler(l).getSplitted(0),u=i===be.IDENTITY?function(e,t){const n=t.columns.length,i=new Array(n),o=new Array(n),r=new Array(n);for(let s=0;s<n;++s){const n=t.columns.byIndex(s);i[s]=n.getRawData(),o[s]=n.categories.indexOf("");const a=s<e.length?e.getOriginal(s):ve._S;r[s]=n.categories.indexOf(a)}const s=a.Column.float("Identity",t.rowCount),l=s.getRawData();for(let n=0;n<t.rowCount;++n){l[n]=0;for(let t=0;t<e.length;++t)(i[t]?i[t][n]:0)===r[t]&&++l[n];l[n]/=e.length}return s}(c,s):i===be.SIMILARITY?await async function(e,t,n){const i=t.columns.toList(),o=await async function(e,t,n){e instanceof a.Column&&(e=ye(e,n).columns.toList());const i=(await(0,we.pj)()).getMonomerLib(),o=new Array(e.length),s=e[0].length,l=new Float32Array(s);for(let n=0;n<e.length;++n){const c=n<t.length?t.getCanonical(n):ve._S,u=i.getMonomer("PEPTIDE",c)?.smiles??"",h=e[n],d=h.getRawData(),p=h.categories,m=p.indexOf("");if(o[n]={categories:p,data:d,emptyIndex:m},void 0===c)continue;const f=a.Column.fromStrings("smiles",p.map(e=>i.getMonomer("PEPTIDE",e)?.smiles??"")),g=(a.DataFrame.fromColumns([f]),await r.chem.getSimilarities(f,u)),y=g?g.getRawData():null;for(let e=0;e<s;++e){const t=d[e];c!==ve._S&&t!==m?l[e]+=y[t]:c===ve._S&&t===m&&(l[e]+=1)}}for(let n=0;n<l.length;++n){let i=l[n]/t.length;for(let r=0;r<e.length;++r){const e=o[r];if(r>=t.length&&e.data[n]!==e.emptyIndex||e.data[n]===e.emptyIndex&&r<t.length){i=a.FLOAT_NULL;break}}l[n]=i}return a.Column.fromFloat32Array("Similarity",l)}(i,e,n);return o}(c,s,o):null;if(null===u)throw new Error(`In bio library: Unknown sequence scoring method: ${i}`);return u.name=e.columns.getUnusedName(u.name),e.columns.add(u),u}(e,t,n,i,o);for(let e=0;e<s.length;e++)t.isNone(e)&&s.set(e,null,!1);return s}var Ai=n(294),xi=n(330);const Mi=OCL;var Ti=n(2582);class Ei{monomerSymbol;constructor(e){this.monomerSymbol=e}atoms;bonds;rGroups;get atomCount(){return this.atoms.count}get bondCount(){return this.bonds.count}shiftR1GroupToOrigin(){const e=this.rGroups.getAtomicIdx(1);if(null==e)return;const{x:t,y:n}=this.atoms.atomCoordinates[e];this.atoms.shift({x:-t,y:-n})}alignR2AlongX(){const e=this.rGroups.getAtomicIdx(2);if(null==e)throw new Error(`Cannot find R2 group for monomer ${this.monomerSymbol}`);const t=this.atoms.atomCoordinates[e],n=t.y/t.x,i=Math.atan(n);if(isNaN(i))throw new Error(`Cannot calculate angle for R2 group for monomer ${this.monomerSymbol}`);this.rotateCoordinates(-i)}shiftMonomerToDefaultPosition(){this.shiftR1GroupToOrigin(),null!==this.rGroups.getAtomicIdx(2)&&this.alignR2AlongX()}deleteBondLineWithSpecifiedRGroup(e){this.rGroups.deleteBondLineWithSpecifiedRGroup(e)}shiftCoordinates(e){this.atoms.shift(e)}rotateCoordinates(e){this.atoms.rotate(e)}getBondLines(){return this.bonds.getBondLines()}getAtomLines(){return this.atoms.atomLines}removeRGroups(e){this.rGroups.removeRGroups(e)}replaceRGroupWithAttachmentAtom(e,t){this.rGroups.replaceRGroupWithAttachmentAtom(e,t)}getAttachmentAtomByRGroupId(e){return this.rGroups.getAttachmentAtomIdByRGroupId(e)}shiftBonds(e){this.bonds.shift(e)}capRGroups(e){this.rGroups.capRGroups(e)}}var _i=n(6956);class Ii{atoms;bonds;constructor(e,t,n){this.atoms=t,this.bonds=n,this.rGroupIdToAtomicIndexMap=e.getRGroupIdToAtomicIdxMap()}rGroupIdToAtomicIndexMap;rGroupBondPositionMap=new Map;getAtomicIdx(e){const t=this.rGroupIdToAtomicIndexMap.get(e);return null==t?null:t}removeRGroupsFromAtomBlock(e){e.forEach(e=>{if(null==this.rGroupIdToAtomicIndexMap.get(e))throw new Error(`Cannot find atomic index for R group ${e}`)});const t=Array.from(this.rGroupIdToAtomicIndexMap.entries()).filter(([t,n])=>e.includes(t)).map(([e,t])=>t);this.atoms.deleteAtoms(t)}removeRGroups(e){this.removeRGroupsFromAtomBlock(e),e.forEach(e=>{const t=this.replaceRGroupInBondsByDummy(e);this.rGroupBondPositionMap.set(e,t)})}replaceRGroupInBondsByDummy(e){const t=this.rGroupIdToAtomicIndexMap.get(e);if(this.rGroupBondPositionMap.has(e))throw new Error(`R group ${e} is already handled`);const n=this.bonds.getPositionsInBonds(t+1);if(0===n.length)throw new Error(`Cannot find position for R group ${e}`);if(n.length>1)throw new Error(`More than one position for R group ${e}`);const i=n[0];return this.bonds.replacePositionsInBondsByDummy([i]),this.bonds.removeAtomIdFromBonds(t+1),this.removeRGroupFromAtomicIdxMap(e,t),i}removeRGroupFromAtomicIdxMap(e,t){this.rGroupIdToAtomicIndexMap.delete(e);for(const[e,n]of this.rGroupIdToAtomicIndexMap)n>t&&this.rGroupIdToAtomicIndexMap.set(e,n-1)}deleteBondLineWithSpecifiedRGroup(e){const t=this.rGroupBondPositionMap.get(e);if(!t)throw new Error(`Cannot find position for R group ${e}`);const{bondLineIdx:n}=t;this.bonds.deleteBondLines([n]),this.rGroupBondPositionMap.delete(e),this.rGroupIdToAtomicIndexMap.delete(e),this.rGroupBondPositionMap.forEach(e=>{e.bondLineIdx>n&&(e.bondLineIdx-=1)})}replaceRGroupWithAttachmentAtom(e,t){const n=this.rGroupBondPositionMap.get(e);if(!n)throw new Error(`Cannot find position for R group ${e}`);const{bondLineIdx:i,nodeIdx:o}=n;this.bonds.bondedAtoms[i][o]=t}getAttachmentAtomIdByRGroupId(e){const t=this.rGroupBondPositionMap.get(e);if(!t)throw new Error(`Cannot find position for R group ${e}`);const{bondLineIdx:n,nodeIdx:i}=t;return this.bonds.bondedAtoms[n][(i+1)%2]}capRGroups(e){this.rGroupIdToAtomicIndexMap.forEach((t,n)=>{const i=e[n-1];i===_i.m?(this.removeRGroups([n]),this.deleteBondLineWithSpecifiedRGroup(n)):this.atoms.replaceRGroupSymbolByElement(t,i)})}}class Li{coordinates=[];rawAtomLines=[];get count(){return this.coordinates.length}get atomCoordinates(){return this.coordinates}replaceRGroupSymbolByElement(e,t){this.rawAtomLines[e]=this.rawAtomLines[e].replace("R#",t)}deleteAtoms(e){this.coordinates=this.coordinates.filter((t,n)=>!e.includes(n)),this.rawAtomLines=this.rawAtomLines.filter((t,n)=>!e.includes(n))}shift(e){this.coordinates=this.coordinates.map(t=>{const n=t.x+e.x,i=t.y+e.y;if(isNaN(n)||isNaN(i))throw new Error(`Cannot shift coordinates by ${e.x}, ${e.y}`);return{x:n,y:i}})}rotate(e){this.coordinates=this.coordinates.map(t=>{const n=t.x,i=t.y,o=n*Math.cos(e)-i*Math.sin(e),r=n*Math.sin(e)+i*Math.cos(e);if(isNaN(o)||isNaN(r))throw new Error(`Cannot rotate coordinates by ${e}`);return{x:o,y:r}})}}class Ni extends Li{constructor(e){super(),this.rawAtomLines=e.getAtomLines(),this.coordinates=this.rawAtomLines.map(e=>({x:parseFloat(e.substring(0,10)),y:parseFloat(e.substring(10,20))}))}get atomLines(){return this.rawAtomLines.map((e,t)=>{const n=this.coordinates[t];return`${n.x.toFixed(4).padStart(10," ")}${n.y.toFixed(4).padStart(10," ")}${e.substring(20)}`})}}class Pi{bondedAtomPairs=[];rawBondLines=[];get count(){return this.bondedAtomPairs.length}get bondedAtoms(){return this.bondedAtomPairs}deleteBondLines(e){this.rawBondLines=this.rawBondLines.filter((t,n)=>!e.includes(n)),this.bondedAtomPairs=this.bondedAtomPairs.filter((t,n)=>!e.includes(n))}getPositionsInBonds(e){const t=[];return this.bondedAtomPairs.forEach((n,i)=>{n.forEach((n,o)=>{n===e&&t.push({bondLineIdx:i,nodeIdx:o})})}),t}replacePositionsInBondsByDummy(e,t){null==t&&(t=-1),e.forEach(e=>{const{bondLineIdx:n,nodeIdx:i}=e;this.bondedAtomPairs[n][i]=t})}removeAtomIdFromBonds(e){this.bondedAtomPairs=this.bondedAtomPairs.map(t=>t.map(t=>t>e?t-1:t))}shift(e){this.bondedAtomPairs=this.bondedAtomPairs.map(t=>t.map(t=>t+e))}}class Ri extends Pi{constructor(e){super(),this.rawBondLines=e.getBondLines(),this.bondedAtomPairs=this.rawBondLines.map(e=>[parseInt(e.substring(0,3)),parseInt(e.substring(3,6))])}getBondLines(){return this.bondedAtomPairs.map((e,t)=>{if(e.some(e=>-1===e))throw new Error(`Bonded pair ${e} contains -1`);return`${e[0].toString().padStart(3," ")}${e[1].toString().padStart(3," ")}${this.rawBondLines[t].substring(6)}`})}}class $i extends Ei{constructor(e,t){super(t);const n=$t.getInstance(e);this.atoms=new Ni(n),this.bonds=new Ri(n),this.rGroups=new Ii(n,this.atoms,this.bonds),this.shiftMonomerToDefaultPosition()}}class Oi extends Li{molfileHandler;constructor(e){super(),this.molfileHandler=e,this.rawAtomLines=e.getAtomLines(),this.coordinates=this.getCoordinates()}getCoordinates(){const e=this.molfileHandler.x,t=this.molfileHandler.y;return Array.from(e).map((e,n)=>({x:e,y:t[n]}))}get atomLines(){const e=/^(M V30 [^-]*)(-?\d+\.\d+)( )(-?\d+\.\d+)( -?\d+\.\d+.*)$/,t=/\sRGROUPS=\(\d+(\s+\d+)*\)/;return this.rawAtomLines.map((n,i)=>{const o=this.coordinates[i],r=o.x.toFixed(4)+"00",s=o.y.toFixed(4)+"00";return n.replace(e,(e,t,n,i,o,a)=>t+r+i+s+a).replace(t,"")})}replaceRGroupSymbolByElement(e,t){super.replaceRGroupSymbolByElement(e,t);const n=this.rawAtomLines[e].substring(3).split(" ");n.length>7&&(this.rawAtomLines[e]=`M ${n.slice(0,7).join(" ")}`)}}class ki extends Pi{molfileHandler;constructor(e){super(),this.molfileHandler=e,this.rawBondLines=e.getBondLines(),this.bondedAtomPairs=this.getBondedAtomPairs()}getBondedAtomPairs(){return this.molfileHandler.pairsOfBondedAtoms.map(e=>[e[0],e[1]])}getBondLines(){const e=/^(M\s+V30\s+\d+\s+\d+\s+)(\d+)(\s+)(\d+)(.*)$/;return this.bondedAtomPairs.map((t,n)=>{if(t.some(e=>-1===e))throw new Error(`Bonded pair ${t} contains -1`);return this.rawBondLines[n].replace(e,(e,n,i,o,r,s)=>`${n}${t[0]}${o}${t[1]}${s}`)})}}class Hi extends Ei{constructor(e,t){super(t);const n=$t.getInstance(e);this.atoms=new Oi(n),this.bonds=new ki(n),this.rGroups=new Ii(n,this.atoms,this.bonds),this.shiftMonomerToDefaultPosition()}}class Bi{static getInstance(e,t){if($t.isMolfileV2K(e))return new $i(e,t);if($t.isMolfileV3K(e))return new Hi(e,t);throw new Error("Unsupported molfile version")}}class Fi{monomerSymbol;monomerIdx;helm;monomerLib;molfileWrapper;capGroupElements=[];static molfileV2KToV3KCache=new Map;constructor(e,t,n,i,o,r){this.monomerSymbol=e,this.monomerIdx=t,this.helm=n,this.monomerLib=r;const s=this.getLibraryMonomerObject();let a=s.molfile;$t.isMolfileV2K(a)&&(a=this.convertMolfileToV3KFormat(a,e,o)),this.molfileWrapper=Bi.getInstance(a,e),this.capGroupElements=this.getCapGroupElements(s),this.removeRGroups(n.bondedRGroupsMap[t]),this.capRemainingRGroups(),this.shiftCoordinates(i)}get atomCount(){return this.molfileWrapper.atomCount}get bondCount(){return this.molfileWrapper.bondCount}convertMolfileToV3KFormat(e,t,n){if(Fi.molfileV2KToV3KCache.has(e))return Fi.molfileV2KToV3KCache.get(e);let i=null;try{if(i=n.get_mol(e,JSON.stringify({mergeQueryHs:!0})),i){const t=i.get_v3Kmolblock();return Fi.molfileV2KToV3KCache.set(e,t),t}throw new Error(`Cannot convert ${t} to molV3000`)}finally{i?.delete()}}getLibraryMonomerObject(){const e=this.helm.getPolymerTypeByMonomerIdx(this.monomerIdx),t=this.monomerLib.getMonomer(e,this.monomerSymbol);if(!t)throw new Error(`Monomer ${this.monomerSymbol} is not found in the library`);return t}getCapGroupElements(e){return e.rgroups.map(e=>(e.capGroupSmiles||e.capGroupSMILES).replace(/(\[|\]|\*|:|\d)/g,""))}shiftCoordinates(e){this.molfileWrapper.shiftCoordinates(e)}getAtomLines(){return this.molfileWrapper.getAtomLines()}getBondLines(){return this.molfileWrapper.getBondLines()}removeRGroups(e){this.molfileWrapper.removeRGroups(e)}capRemainingRGroups(){this.molfileWrapper.capRGroups(this.capGroupElements)}replaceRGroupWithAttachmentAtom(e,t){this.molfileWrapper.replaceRGroupWithAttachmentAtom(e,t)}getAttachmentAtomByRGroupId(e){return this.molfileWrapper.getAttachmentAtomByRGroupId(e)}deleteBondLineWithSpecifiedRGroup(e){this.molfileWrapper.deleteBondLineWithSpecifiedRGroup(e)}shiftBonds(e){this.molfileWrapper.shiftBonds(e)}}class Gi{rdKitModule;monomerLib;constructor(e,t,n){this.rdKitModule=t,this.monomerLib=n,this.helm=new Ti.f(e)}monomerWrappers=[];helm;addMonomer(e,t,n){if(e===ve.b9[me.Hi.HELM])return;const i=this.monomerWrappers.length,o=new Fi(e,i,this.helm,n,this.rdKitModule,this.monomerLib);this.monomerWrappers.push(o)}getAtomNumberShifts(){const e=[];let t=0;return this.monomerWrappers.forEach(n=>{e.push(t),t+=n.getAtomLines().length}),e}restoreBondsBetweenMonomers(){this.helm.bondData.forEach(e=>{const t=e.map(e=>e.monomerIdx),n=e.map(e=>e.rGroupId),i=t.map(e=>this.monomerWrappers[e]),o=i[1].getAttachmentAtomByRGroupId(n[1]);i[0].replaceRGroupWithAttachmentAtom(n[0],o),i[1].deleteBondLineWithSpecifiedRGroup(n[1])})}compileToMolfile(){const e=[],t=[],n=this.getAtomNumberShifts();this.monomerWrappers.forEach((e,t)=>{e.shiftBonds(n[t])}),this.restoreBondsBetweenMonomers();const i=new Ai.Cg;for(const[n,o]of R().enumerate(this.monomerWrappers)){const r=e.length,s=t.length;e.push(...n.getAtomLines()),t.push(...n.getBondLines());const a="RNA"==this.helm.getPolymerTypeByMonomerIdx(o)?De.o.NUCLEOTIDE:De.o.AA;i.set(o,{biotype:a,symbol:n.monomerSymbol,atoms:R().count(r).take(n.atomCount).toArray(),bonds:R().count(s).take(n.bondCount).toArray()})}const o=e.length,r=t.length;return{molfile:[this.getV3KHeader(o,r),this.getV3KAtomBlock(e),this.getV3KBondBlock(t),"M V30 END CTAB\nM END"].join("\n"),monomers:i}}getV3KHeader(e,t){return`\n Datagrok\n\n 0 0 0 0 0 0 0 0 0 0999 V3000\nM V30 BEGIN CTAB\nM V30 COUNTS ${e} ${t} 0 0 1`}getV3KAtomBlock(e){const t=/^(M V30 )(\d+)( .*)$/;return["M V30 BEGIN ATOM",...e.map((e,n)=>{const i=n+1;return e.replace(t,(e,t,n,o)=>t+i+o)}),"M V30 END ATOM"].join("\n")}getV3KBondBlock(e){const t=/^(M V30 )(\d+)( .*)$/;return["M V30 BEGIN BOND",...e.map((e,n)=>{const i=n+1;return e.replace(t,(e,t,n,o)=>t+i+o)}),"M V30 END BOND"].join("\n")}}class Di{constructor(e){this.molfileHandler=$t.getInstance(e)}molfileHandler;get monomerSymbols(){return this.molfileHandler.atomTypes}getMonomerShifts(e){return{x:this.molfileHandler.x[e],y:this.molfileHandler.y[e]}}}class Vi{helmHelper;rdKitModule;monomerLib;constructor(e,t,n){this.helmHelper=e,this.rdKitModule=t,this.monomerLib=n}convertToSmiles(e){const t=e.dataFrame,n=this.getSmilesList(e),i=`smiles(${e.name})`,o=t?t.columns.getUnusedName(i):i;return a.Column.fromStrings(o,n.map(e=>null==e?"":e))}getSmilesList(e){return this.convertToMolfileV3KColumn(e).toList().map(e=>a.chem.convert(e,a.chem.Notation.MolBlock,a.chem.Notation.Smiles))}molV3KtoMolV3KOCL(e){try{if(!e)return"";return Mi.Molecule.fromMolfile(e).toMolfileV3().replace("STERAC1","STEABS")}catch(e){const[t,n]=(0,Se.AP)(e);return qr.logger.error(t,void 0,n),""}}getMolV3000ViaOCL(e,t){const n=e.map(e=>{if(null==e)return"";const t=e.get_v3Kmolblock();return e.delete(),t}),i=new Array(n.length),o=a.TaskBarProgressIndicator.create("Handling chirality...");for(let e=0;e<n.length;e++){i[e]=this.molV3KtoMolV3KOCL(n[e]);const t=e/n.length*100;o.update(t,`${t?.toFixed(2)}% of molecules completed`)}return o.close(),a.Column.fromStrings(t,i)}convertToRdKitBeautifiedMolfileColumn(e,t,n,i){const o=e.dataFrame,r=this.convertToMolfileV3KColumn(e).toList().map(e=>{if(""===e)return null;const t=n.get_mol(e);return t?(t.set_new_coords(),t.normalize_depiction(1),t.straighten_depiction(!0),t):null}),s=`molfile(${e.name})`,l=o?o.columns.getUnusedName(s):s;return t?this.getMolV3000ViaOCL(r,l):a.Column.fromStrings(l,r.map(e=>{if(null==e)return"";const t=e.get_v3Kmolblock();return e.delete(),t}))}convertToMolfileV3KColumn(e){const t=e.dataFrame,n=this.convertToMolfileV3K(e.toList()).map(e=>e.molfile),i=(0,xi.kA)(t,`molfileV3K(${e.name})`);return a.Column.fromList("string",i,n)}convertToMolfileV3K(e){const t=new Array(e.length);for(let n=0;n<e.length;++n){const i=e[n];if(!i){t[n]=Ai.vF.createEmpty();continue}let o;try{o=this.getPolymerMolfile(i)}catch(e){const[t,n]=(0,Se.AP)(e);qr.logger.error(t,void 0,n),o=Ai.vF.createEmpty()}t[n]=o}return t}getPolymerGraphColumn(e){const t=e.toList(),n=this.helmHelper.getMolfiles(t);return a.Column.fromStrings("mols",n)}getPolymerMolfile(e){const t=this.helmHelper.removeGaps(e),n=t.resHelm,i=new Map;for(const[e,n]of t.monomerMap?.entries()??[])i.set(n,e);const o=this.helmHelper.getMolfiles([n])[0],r=new Di(o),s=new Gi(n,this.rdKitModule,this.monomerLib);r.monomerSymbols.forEach((e,t)=>{const n=r.getMonomerShifts(t);s.addMonomer(e,t,n)});const a=s.compileToMolfile(),l=new Ai.Cg;for(const[e,t]of a.monomers.entries()){const n=i.get(e);l.set(n,t)}return new Ai.vF(a.molfile,l)}}var Wi=n(2738);class ji{seqHelper;_column;_units;_notation;_defaultGapOriginal;_notationProvider=null;_tempReadForNotProvider=!1;get notationProvider(){return this._tempReadForNotProvider||(this._tempReadForNotProvider=!0,this._notationProvider=this._notationProvider??this._column.temp[$e.j.notationProvider]??null),this._notationProvider}set notationProvider(e){this._notationProvider=e}_splitter=null;_refinerPromise=Promise.resolve();get refinerPromise(){return this._refinerPromise}constructor(e,t){if(this.seqHelper=t,e.type!==a.TYPE.STRING)throw new Error(`Unexpected column type '${e.type}', must be '${a.TYPE.STRING}'.`);this._column=e;const n=this._column.meta.units;if(!n)throw new Error("Units are not specified in column");this._units=n,this._notation=this.getNotation(),(this.isCustom()||this.isBiln())&&(this.notationProvider=this.column.temp[$e.j.notationProvider]??null);const i=this.isFasta()?ve.b9[me.Hi.FASTA]:this.isSeparator()?ve.b9[me.Hi.SEPARATOR]:this.isHelm()?ve.b9[me.Hi.HELM]:this.isCustom()||this.isBiln()?this.notationProvider?.defaultGapOriginal??ve.b9[me.Hi.SEPARATOR]:void 0;if(null==i)throw new Error(`Unexpected defaultGapOriginal for notation '${this.notation}'`);if(this._defaultGapOriginal=i,!this.column.tags.has(me.gp.aligned)||!this.column.tags.has(me.gp.alphabet)||!this.column.tags.has(me.gp.alphabetIsMultichar)&&!this.isHelm()&&this.alphabet===me.YI.UN)if(this.isFasta())this.seqHelper.setUnitsToFastaColumn(this);else if(this.isSeparator()){const t=e.getTag(me.gp.separator);this.seqHelper.setUnitsToSeparatorColumn(this,t)}else if(this.isHelm())this.seqHelper.setUnitsToHelmColumn(this);else{if(!this.isCustom()&&!this.isBiln())throw new Error(`Unexpected units '${this.column.meta.units}'.`);this.notationProvider?.setUnits(this)}if(!this.column.tags.has(me.gp.alphabetIsMultichar))if(this.isHelm())this.column.setTag(me.gp.alphabetIsMultichar,"true");else if(["UN"].includes(this.alphabet))throw new Error(`For column '${this.column.name}' of alphabet '${this.alphabet}' tag '${me.gp.alphabetIsMultichar}' is mandatory.`);this.columnVersion=this.column.version,!this.isSeparator()||(this.isCustom()||this.isBiln())&&this.notationProvider||e.temp.seqHandlerRefined||(this._refinerPromise=this.refineSeparatorNotation(),e.temp.seqHandlerRefined=!0)}async refineSeparatorNotation(){const e=((e,t,n)=>{const i={};let o=!0,r=null;for(const t of e){const e=t?n(t):[];if(null==r?r=e.length:e.length!==r&&(o=!1),e.length>=3)for(const t of e)t in i||(i[t]=0),i[t]+=1}return{freq:i,sameLength:o}})([...new Set((this.column.length<100?R().count(0).take(Math.min(100,this.column.length)).map(e=>this.column.get(e)):this.column.categories.slice(0,100)).map(e=>e?e.substring(0,500):"").filter(e=>0!==e.length))],0,e=>e.split(this.separator));let t=!1;const n=a.Func.find({tags:["notationRefiner"]});for(const i of n)try{const n=i.prepare({col:this.column,stats:e,separator:this.separator}),o=(await n.call()).getOutputParamValue();t||=o}catch(e){console.error(e)}t&&(this._tempReadForNotProvider=!1,delete this.column.temp[$e.j.seqHandler],this.column.fireValuesChanged())}static setTags(e){const t=e.column.meta.units;if([me.Hi.FASTA,me.Hi.SEPARATOR].includes(t)){if(!e.column.getTag(me.gp.alphabet)&&0===Object.keys(e.stats.freq).length)throw new Error("Alphabet is empty and not annotated.");let t=e.column.getTag(me.gp.aligned);null==t&&(t=e.stats.sameLength?"SEQ.MSA":"SEQ",e.column.setTag(me.gp.aligned,t));let n=e.column.getTag(me.gp.alphabet);if(null==n&&(n=(0,Be.pc)(e.stats.freq,me.q7),e.column.setTag(me.gp.alphabet,n)),n===me.YI.UN){const t=Object.keys(e.stats.freq).length,n=Object.keys(e.stats.freq).some(e=>e.length>1);e.column.setTag(me.gp.alphabetSize,t.toString()),e.column.setTag(me.gp.alphabetIsMultichar,n?"true":"false")}}else if(t===me.Hi.HELM){let t=e.column.getTag(me.gp.alphabet);if(null==t){const n=me.q7.map(e=>new Wi.a(e.name,e.alphabet,.9));t=(0,Be.p0)(e.stats.freq,n,e.defaultGapOriginal),e.column.setTag(me.gp.alphabet,t)}}}get column(){return this._column}get length(){return this._column.length}get units(){return this._units}get notation(){return this._notation}get defaultGapOriginal(){return this._defaultGapOriginal}get separator(){const e=this.column.getTag(me.gp.separator)??void 0;if(this.notation===me.Hi.SEPARATOR&&null==e)throw new Error(`Separator is mandatory for column '${this.column.name}' of notation '${this.notation}'.`);return e}get aligned(){const e=this.column.getTag(me.gp.aligned);if(!e&&(this.isFasta()||this.isSeparator()))throw new Error("Tag aligned not set");return e}get alphabet(){const e=this.column.getTag(me.gp.alphabet);if(!e&&(this.isFasta()||this.isSeparator()))throw new Error("Tag alphabet not set");return e}get defaultBiotype(){return this.alphabet===me.YI.RNA||this.alphabet===me.YI.DNA?De.o.NUCLEOTIDE:De.o.AA}get helmCompatible(){return this.column.getTag(me.gp.isHelmCompatible)}getAlphabetSize(){if(this.notation==me.Hi.HELM||this.alphabet==me.YI.UN){const e=this.column.getTag(me.gp.alphabetSize);let t;if(e)t=parseInt(e);else{const e=this.stats;t=Object.keys(e.freq).length}return t}switch(this.alphabet){case me.YI.PT:return 20;case me.YI.DNA:case me.YI.RNA:return 4;case"NT":return console.warn("Unexpected alphabet 'NT'."),4;default:throw new Error(`Unexpected alphabet '${this.alphabet}'.`)}}getAlphabetIsMultichar(){return this.notation===me.Hi.HELM||this.alphabet===me.YI.UN&&"true"===this.column.getTag(me.gp.alphabetIsMultichar)}cached=!0;_splitted=null;columnVersion=null;getSplitted(e,t){if(this.cached&&void 0===t){this.column.version===this.columnVersion&&null!=this._splitted||(this.columnVersion=this.column.version,this._splitted=new Array(this.column.length));let t=this._splitted[e]?this._splitted[e].deref():void 0;if(!t){const n=this.column.get(e);t=this.splitter(n),this._splitted[e]=new WeakRef(t)}return t}{const n=this.column.get(e);return this.getSplitter(t)(n)}}getMonomerAtPosition(e,t,n){if(this.isCanonicalAlphabet&&this.isFasta()&&!this.getAlphabetIsMultichar()){const i=(this.column.get(e)??"")[t];return n?i===ve.b9[me.Hi.FASTA]?ve._S:i??ve._S:i??""}const i=this.getSplitted(e);return t<0||t>=i.length?this.defaultGapOriginal:n?i.getCanonical(t):i.getOriginal(t)}getMonomersAtPosition(e,t){const n=this.column.length,i=new Array(n).fill(ve._S);if(this.isCanonicalAlphabet&&this.isFasta()&&!this.getAlphabetIsMultichar()){const o=this.column.categories,r=this.column.getRawData();for(let s=0;s<n;s++){const n=o[r[s]]??"";if(e<n.length){const o=n[e];i[s]=t?o===ve.b9[me.Hi.FASTA]?ve._S:o??ve._S:o??""}}}else for(let o=0;o<n;o++){const n=this.getSplitted(o);e>=0&&e<n.length&&(i[o]=t?n.getCanonical(e):n.getOriginal(e))}return i}getValue(e,t){return this.column.get(e),new $e.C(e,this)}getHelm(e){let t;const n=this.column.get(e);return t=this.notation===me.Hi.HELM?n:this.notation===me.Hi.CUSTOM||this.notation===me.Hi.BILN?this.notationProvider.getHelm(n,{}):this.getConverter(me.Hi.HELM)(n),t}_stats=null;get isCanonicalAlphabet(){const e=this.alphabet;return e===me.YI.DNA||e===me.YI.RNA||e===me.YI.PT}get stats(){if(null==this._stats){const e={};let t=!0,n=null;const i=this.column.length;for(let o=0;o<i;++o){const i=this.getSplitted(o);null==n?n=i.length:i.length!==n&&(t=!1);for(let t=0;t<i.length;++t){const n=i.getCanonical(t);n in e||(e[n]=0),e[n]+=1}}this._stats={freq:e,sameLength:t}}return this._stats}_maxLength=null;get maxLength(){return null==this._maxLength&&(this._maxLength=0===this.column.length?0:R().count(0).take(this.column.length).map(e=>this.getSplitted(e).length).reduce((e,t)=>e>t?e:t,0)),this._maxLength}_posList=null;get posList(){if(null==this._posList){const e=this.column.getTag(me.gp.positionNames);this._posList=e?e.split(me.z1).map(e=>e.trim()):R().count(1).take(this.maxLength).map(e=>e.toString()).toArray()}return this._posList}isFasta(){return this.notation===me.Hi.FASTA}isSeparator(){return this.notation===me.Hi.SEPARATOR||!!this.separator}isFastaOrSeparator(){return this.isFasta()||this.isSeparator()}isHelm(){return this.notation===me.Hi.HELM}isCustom(){return this.notation===me.Hi.CUSTOM}isBiln(){return this.notation===me.Hi.BILN}isRna(){return this.alphabet===me.YI.RNA}isDna(){return this.alphabet===me.YI.DNA}isPeptide(){return this.alphabet===me.YI.PT}isMsa(){return!!this.aligned&&this.aligned.toUpperCase().includes("MSA")}isHelmCompatible(){return"true"===this.helmCompatible}isGap(e){return!e||e===this._defaultGapOriginal}getNotation(){if(this.units.toLowerCase().startsWith(me.Hi.FASTA))return me.Hi.FASTA;if(this.units.toLowerCase().startsWith(me.Hi.SEPARATOR))return me.Hi.SEPARATOR;if(this.units.toLowerCase().startsWith(me.Hi.HELM))return me.Hi.HELM;if(this.units.toLowerCase().startsWith(me.Hi.CUSTOM))return me.Hi.CUSTOM;if(this.units.toLowerCase().startsWith(me.Hi.BILN))return me.Hi.BILN;throw new Error(`Column '${this.column.name}' has unexpected notation '${this.units}'.`)}getHelmWrappers(){return[this.isDna()||this.isRna()||this.isHelmCompatible()?"RNA1{":"PEPTIDE1{",this.isDna()?"d(":this.isRna()?"r(":"",this.isDna()||this.isRna()?")p":"","}$$$$"]}getNewColumn(e,t,n,i){const o=this.column,r=e.toLowerCase()+"("+o.name+")",s=n??o.dataFrame?.columns.getUnusedName(r)??r,l=a.Column.fromList("string",s,i??new Array(this.column.length).fill(""));if(l.semType=a.SEMTYPE.MACROMOLECULE,l.meta.units=e,e===me.Hi.SEPARATOR){if(!t)throw new Error(`Notation '${me.Hi.SEPARATOR}' requires separator value.`);l.setTag(me.gp.separator,t)}l.setTag(a.TAGS.CELL_RENDERER,e===me.Hi.HELM?"helm":"sequence");const c=o.getTag(me.gp.aligned);c&&l.setTag(me.gp.aligned,c);let u=o.getTag(me.gp.alphabet);u||this.notation!==me.Hi.HELM||e===me.Hi.HELM||(u=me.YI.UN),null!=u&&l.setTag(me.gp.alphabet,u);let h=o.getTag(me.gp.alphabetSize);null!=u&&h&&l.setTag(me.gp.alphabetSize,h);const d=o.getTag(me.gp.alphabetIsMultichar);return null!=u&&void 0!==d&&l.setTag(me.gp.alphabetIsMultichar,d),e==me.Hi.HELM&&(h=this.getAlphabetSize().toString(),l.setTag(me.gp.alphabetSize,h)),e===me.Hi.BILN&&(l.setTag(me.gp.separator,"-"),l.meta.units=me.Hi.SEPARATOR),l}getNewColumnFromList(e,t){return this.getNewColumn(this.notation,this.separator,e,t)}static unitsStringIsValid(e){return e=e.toLowerCase(),[me.Hi.FASTA,me.Hi.SEPARATOR,me.Hi.HELM].some(t=>e.startsWith(t.toLowerCase()))}static getNewColumnFromParams(e,t,n){if(!ji.unitsStringIsValid(n))throw new Error("Invalid format of 'units' parameter");const i=a.Column.fromList("string",t,new Array(e).fill(""));return i.semType=a.SEMTYPE.MACROMOLECULE,i.meta.units=n,i}get splitter(){return null==this._splitter&&(this._splitter=this.getSplitter()),this._splitter}getSplitter(e){let t=null;if(t=this.notationProvider?this.notationProvider.splitter:null,t)return t;if(this.units.toLowerCase().startsWith(me.Hi.FASTA))return null===this.column.getTag(me.gp.alphabet)||this.getAlphabetIsMultichar()?me.J9:Be.tm;if(this.units.toLowerCase().startsWith(me.Hi.SEPARATOR))return(0,me.dh)(this.separator,e);if(this.units.toLowerCase().startsWith(me.Hi.HELM))return me.qp;throw new Error(`Unexpected units ${this.units} .`)}split(e){return this.splitter(e)}getDistanceFunctionName(){if(!this.isFasta())throw new Error("Only FASTA notation is supported");if(this.isMsa())return pe.Z.HAMMING;switch(this.alphabet){case me.YI.DNA:case me.YI.RNA:case me.YI.PT:}return pe.Z.LEVENSHTEIN}getDistanceFunction(){return pe.V[this.getDistanceFunctionName()]()}async checkHelmCompatibility(){if(this.column.tags.has(me.gp.isHelmCompatible))return"true"===this.column.getTag(me.gp.isHelmCompatible);const e=(await(0,we.pj)()).getMonomerLib().getMonomerSymbolsByType("PEPTIDE"),t=new Set(e),n=((0,me.dh)(this.separator),new Set),i=this.column.length,o=this.column.getRawData();for(let e=0;e<i;++e){const i=o[e];if(!(i in n)){n.add(i);const o=this.getSplitted(e);for(let e=0;e<o.length;++e){const n=o.getCanonical(e);if(!t.has(n))return this.column.setTag(me.gp.isHelmCompatible,"false"),!1}}}return this.column.setTag(me.gp.isHelmCompatible,"true"),!0}toFasta(e){return e===me.Hi.FASTA}toSeparator(e){return e===me.Hi.SEPARATOR}toHelm(e){return e===me.Hi.HELM}convertHelmToFastaSeparator(e,t,n,i){i||(i=this.toFasta(t)?ve.b9[me.Hi.FASTA]:ve.b9[me.Hi.SEPARATOR]),n||(n=this.toFasta(t)?"":this.separator);const o=e.startsWith("RNA"),r=(0,me.qp)(e),s=[];for(let e=0;e<r.length;++e){let n=r.getOriginal(e);if(o&&(n=n.replace(ge.EK,"$1")),n===ve.b9[me.Hi.HELM])s.push(i);else if(this.toFasta(t)&&n.length>1){const e="["+n+"]";s.push(e)}else s.push(n)}return s.join(n)}convert(e,t){const n=this.getJoiner({notation:e,separator:t}),i=this.getNewColumn(e,t);return i.init(e=>{const t=this.getSplitted(e);return n(t)}),i}getRegion(e,t,n){const i=this.getNewColumn(this.notation,this.separator);i.name=n;const o=e??0,r=t??this.maxLength-1,s=this.getJoiner(),a=r-o+1,l=ve.b9[this.notation];i.init(e=>{const t=this.getSplitted(e),n=new Array(a);for(let e=0;e<a;++e){const i=o+e;n[e]=i<t.length?t.getOriginal(i):l}return s(new Be.Mu(n,l))});const c=e=>{const t=e.split(",").map(e=>e.trim()),n=new Array(a);for(let e=0;e<a;++e){const i=o+e;n[e]=i<t.length?t[i]:"?"}return n.join(me.z1)},u=this.column.getTag(me.gp.positionNames);u&&i.setTag(me.gp.positionNames,c(u));const h=this.column.getTag(me.gp.positionLabels);return h&&i.setTag(me.gp.positionLabels,c(h)),i}_joiner=void 0;get joiner(){return this._joiner||(this._joiner=this.getJoiner()),this._joiner}getJoiner(e){const t=e?e.notation:this.notation,n=e?e.separator:this.separator;let i;const o=this;switch(t){case me.Hi.FASTA:i=function(e){return o.joinToFasta(e,o.isHelm())};break;case me.Hi.SEPARATOR:if(!n)throw new Error(`Separator is mandatory for notation '${t}'.`);i=function(e){return Ui(e,n,o.isHelm())};break;case me.Hi.HELM:{const e=o.alphabet===me.YI.DNA||o.alphabet===me.YI.RNA,t=o.getHelmWrappers();i=function(n){return qi(n,t,e)};break}case me.Hi.BILN:i=function(e){return zi(e)};break;default:throw new Error(`Unexpected notation '${t}'.`)}return i}getConverter(e,t=void 0){if(e===me.Hi.SEPARATOR&&!t)throw new Error(`Target separator is not specified for target units '${me.Hi.SEPARATOR}'.`);const n=this;if(e===me.Hi.FASTA)return function(e){return n.convertToFasta(e)};if(e===me.Hi.HELM)return function(e){return n.convertToHelm(e)};if(e===me.Hi.SEPARATOR)return function(e){return n.convertToSeparator(e,t)};if(e===me.Hi.BILN)return function(e){return n.convertToBiln(e)};throw new Error("Unexpected target units '"+e+"'.")}static forColumn(e,t){let n=e.temp[$e.j.seqHandler];return n&&n.columnVersion===e.version||(n=e.temp[$e.j.seqHandler]=new ji(e,t)),n}joinToFasta(e,t){const n=new Array(e.length);for(let i=0;i<e.length;++i){const o=e.getOriginal(i);let r=e.getOriginal(i);t&&(r=r.replace(ge.EK,"$1")),o===ve._S?r=ve.b9[me.Hi.FASTA]:o===ge.q7?r="":r.length>1&&(r="["+r+"]"),n[i]=r}return n.join("")}convertToFasta(e){const t=this.splitter,n=this.isHelm()?this.splitterAsHelmNucl(e):t(e);return this.joinToFasta(n,this.isHelm())}convertToSeparator(e,t){return Ui(this.isHelm()?this.splitterAsHelmNucl(e):this.splitter(e),t,this.isHelm())}convertToHelm(e){if(this.notation==me.Hi.HELM)return e;const t=this.getHelmWrappers(),n=this.isDna()||this.isRna();return qi(this.splitter(e),t,n)}convertToBiln(e){return this.notation==me.Hi.BILN?e:zi(this.splitter(e))}splitterAsHelmNucl(e){const t=this.splitter(e),n=new Array(t.length),i=e.startsWith("DNA"),o=e.startsWith("RNA");for(let e=0;e<t.length;++e){let r=t.getOriginal(e);(i||o)&&(r=r.replace(ge.EK,"$1"),r=r===ge.q7?null:r),n[e]=r||null}return new Be.Mu(n.filter(e=>!!e),ve.b9[me.Hi.HELM])}getRendererBack(e,t){const n=this.column.temp;let i=n.rendererBack;return i||(i=n.rendererBack=this.notationProvider?.createCellRendererBack(e,t)),i}}function Ui(e,t,n){const i=new Array(e.length);for(let t=0;t<e.length;++t){const o=e.getCanonical(t);let r=e.getOriginal(t);n&&(r=r.replace(ge.EK,"$1")),o===ve._S?r=ve.b9[me.Hi.SEPARATOR]:o===ge.q7&&(r=""),i[t]=r}return i.join(t)}function qi(e,t,n){if(e.graphInfo&&(e.graphInfo.connections?.length??0)>0){const i=n?"RNA":"PEPTIDE",o="$$$",r=e.graphInfo.disjointSeqStarts,s=t[1],a=t[2],l=[];for(let t=0;t<r.length;t++){const o=r[t],c=t+1<r.length?r[t+1]:e.length,u=new Array(c-o);for(let t=o;t<c;++t){const i=e.getCanonical(t);let r=i;i===ve._S?r=ve.b9[me.Hi.HELM]:(n&&(r=r.replace(ge.EK,"$1")),r=1===r.length?`${s}${r}${a}`:`${s}[${r}]${a}`),u[t-o]=r}l.push(`${i}${t+1}{${u.join(".")}}`)}return`${l.join("|")}$${e.graphInfo.connections.map(e=>`${i}${e.seqIndex1+1},${i}${e.seqIndex2+1},${e.monomerIndex1+1}:R${e.rGroup1}-${e.monomerIndex2+1}:R${e.rGroup2}`).join("|")}${o}V2.0`}{const[i,o,r,s]=t,a=new Array(e.length);for(let t=0;t<e.length;++t){const i=e.getCanonical(t);let s=i;i===ve._S?s=ve.b9[me.Hi.HELM]:(n&&(s=s.replace(ge.EK,"$1")),s=1===s.length?`${o}${s}${r}`:`${o}[${s}]${r}`),a[t]=s}return`${i}${a.join(".")}${s}`}}function zi(e){const t=e=>e&&(e.includes("-")||e.includes("*")||e.includes("[R"));if(e.graphInfo&&(e.graphInfo.connections?.length??0)>0){const n=e.graphInfo.disjointSeqStarts,i=new Array(e.length);for(let n=0;n<e.length;++n){const o=e.getCanonical(n);t(o)?i[n]=`[${o}]`:i[n]=o}for(let t=0;t<e.graphInfo.connections.length;t++){const o=e.graphInfo.connections[t],r=`${t+1}`,s=o.seqIndex1,a=o.seqIndex2,l=n[s]+o.monomerIndex1,c=n[a]+o.monomerIndex2,u=`${i[l]}(${r},${o.rGroup1})`,h=`${i[c]}(${r},${o.rGroup2})`;i[l]=u,i[c]=h}return n.map((t,o)=>{const r=o+1<n.length?n[o+1]:e.length;return i.slice(t,r).join("-")}).join(".")}{const n=new Array(e.length);for(let i=0;i<e.length;++i){const o=e.getCanonical(i);t(o)?n[i]=`[${o}]`:n[i]=o}return n.join("-")}}class Yi{libHelper;rdKitModule;constructor(e,t){this.libHelper=e,this.rdKitModule=t}getSeqHandler(e){return ji.forColumn(e,this)}getSeqMonomers(e){const t=this.getSeqHandler(e);return Object.keys(t.stats.freq)}async getHelmToMolfileConverter(e){const t=await(0,kt.b2)();return new Vi(t,this.rdKitModule,e)}helmToAtomicLevelSingle(e,t,n,i=!0){if(!e)return Ai.vF.createEmpty();const o=t.convertToMolfileV3K([e])[0];if(!o||!o.molfile)return Ai.vF.createEmpty();let r=null;try{let e=o.molfile;if(i){if(r=this.rdKitModule.get_mol(e),!r)return Ai.vF.createEmpty();r.set_new_coords(),r.normalize_depiction(1),r.straighten_depiction(!0),e=r.get_v3Kmolblock()}return n&&(e=t.molV3KtoMolV3KOCL(e)),new Ai.vF(e,o.monomers)}catch(e){const[t,n]=(0,Se.AP)(e);return qr.logger.error(t,void 0,n),Ai.vF.createEmpty()}finally{r?.delete()}}async helmToAtomicLevel(e,t,n,i){const o=i??this.libHelper.getMonomerLib(),s=e.dataFrame,l=(0,xi.qj)(s,e.name),c=await this.getHelmToMolfileConverter(o),u=e.toList(),h=new Array(e.length),d=a.Func.find({package:"Chem",name:"beautifyMols"})[0],p=a.Func.find({package:"Chem",name:"convertToV3KViaOCL"})[0];for(let n=0;n<e.length;n++)h[n]=this.helmToAtomicLevelSingle(u[n],c,t&&!p,!d).molfile;if(d){const t=await d.apply({mols:h});if(t&&Array.isArray(t)&&t.length===e.length)for(let n=0;n<e.length;n++)t[n]&&(h[n]=t[n])}if(t&&p){const t=await p.apply({mols:h});if(t&&Array.isArray(t)&&t.length===e.length)for(let n=0;n<e.length;n++)t[n]&&(h[n]=t[n]);else r.shell.warning("OCL function returned an unexpected result")}const m=a.Column.fromStrings(l,h);return m.semType=a.SEMTYPE.MOLECULE,m.meta.units=a.UNITS.Molecule.MOLBLOCK,m.setTag(".sequence-src-col",e.name),{molCol:m,warnings:[]}}setUnitsToFastaColumn(e){if(e.column.semType!==a.SEMTYPE.MACROMOLECULE||e.column.meta.units!==me.Hi.FASTA)throw new Error(`The column of notation '${me.Hi.FASTA}' must be '${a.SEMTYPE.MACROMOLECULE}'.`);e.column.meta.units=me.Hi.FASTA,ji.setTags(e)}setUnitsToSeparatorColumn(e,t){if(e.column.semType!==a.SEMTYPE.MACROMOLECULE)throw new Error(`The column of notation '${me.Hi.SEPARATOR}' must be '${a.SEMTYPE.MACROMOLECULE}'.`);if(!t)throw new Error(`The column of notation '${me.Hi.SEPARATOR}' must have the separator tag.`);e.column.meta.units=me.Hi.SEPARATOR,e.column.setTag(me.gp.separator,t),ji.setTags(e)}setUnitsToHelmColumn(e){if(e.column.semType!==a.SEMTYPE.MACROMOLECULE)throw new Error(`The column of notation '${me.Hi.HELM}' must be '${a.SEMTYPE.MACROMOLECULE}'`);e.column.meta.units=me.Hi.HELM,ji.setTags(e)}}async function Ki(e){let t="";try{if(!e||!e.value)return t="No sequence provided",{errorText:t,mol:""};if(!(e.cell&&e.cell.dart&&e.cell.dataFrame&&e.cell.column))return t="Atomic level conversion requeires a sequence column",{errorText:t,mol:""};if(![me.Hi.FASTA,me.Hi.SEPARATOR,me.Hi.HELM,me.Hi.BILN].includes(e.cell.column.meta.units?.toLowerCase()??""))return t="Unsupported sequence notation. please use Bio | Polytool | Convert",{errorText:t,mol:""};const n=(await Yr.getSeqHelper()).getSeqHandler(e.cell.column);if(!n)return t="No sequence handler found",{errorText:t,mol:""};if((n.getSplitted(e.cell.rowIndex,60)?.length??100)>50)return t="Maximum number of monomers is 50",{errorText:t,mol:""};const i=a.Column.fromStrings("singleVal",[e.value]),o=a.DataFrame.fromColumns([i]);Object.entries(e.cell.column.tags).forEach(([e,t])=>{i.setTag(e,t)}),e.cell.column.temp[$e.j.notationProvider]&&(i.temp[$e.j.notationProvider]=e.cell.column.temp[$e.j.notationProvider]);const r=n.getSplitted(e.cell.rowIndex),s=(r.graphInfo?.connections?.length??0)>0,l=n.isHelm()&&new Set(r.graphInfo?.polymerTypes??[]).size>1;if(await Yr.toAtomicLevel(o,i,s||l,!1),o.columns.length<2)return t="No structure generated",{errorText:t,mol:""};const c=o.columns.byIndex(1).get(0);return c?{errorText:"",mol:c}:(t="No structure generated",{errorText:t,mol:""})}catch(e){qr.logger.error(e)}return t="No Structure generated",{errorText:t,mol:""}}const Zi="#333333",Xi="rgba(60, 177, 115, 0.1)",Ji="rgba(240, 240, 240, 0.5)",Qi="rgba(100, 100, 100, 0.3)";class eo{constructor(e=io.DEFAULT_TRACK_HEIGHT,t=io.MIN_TRACK_HEIGHT,n=""){this.ctx=null,this.visible=!0,this.title="",this.tooltipEnabled=!1,this.tooltipContent=null,this.height=e,this.defaultHeight=e,this.minHeight=t,this.title=n}init(e){this.ctx=e}getMonomerAt(e,t,n){return null}enableTooltip(e){this.tooltipEnabled=e}setTooltipContentGenerator(e){this.tooltipContent=e}getTooltipContent(e,t){if(!this.tooltipEnabled||!this.tooltipContent)return null;const n=this.getPositionData(e)??new Map;return this.tooltipContent(e,t,n)}getPositionData(e){return null}setVisible(e){this.visible=e}getHeight(){return this.visible?this.height:0}getDefaultHeight(){return this.defaultHeight}getMinHeight(){return this.minHeight}setHeight(e){this.height=Math.max(this.minHeight,e)}resetHeight(){this.height=this.defaultHeight}isVisible(){return this.visible}setTitle(e){this.title=e}getTitle(){return this.title}}class to extends eo{constructor(e=new Map,t=io.DEFAULT_TRACK_HEIGHT,n="",i="WebLogo"){super(t,io.DEFAULT_TRACK_HEIGHT,i),this.data=new Map,this.monomerLib=null,this.biotype="HELM_AA",this.hoveredPosition=-1,this.hoveredMonomer=null,this.data=e,this.visible=e.size>0}setHovered(e,t){this.hoveredPosition=e,this.hoveredMonomer=t}getPositionData(e){return this.data.get(e)||null}setupDefaultTooltip(){this.enableTooltip(!0),this.setTooltipContentGenerator((e,t,n)=>this.createTooltipContent(e,t,n))}createFrequencyTable(e){let t;switch(this.biotype){case"HELM_BASE":case"HELM_SUGAR":case"HELM_NUCLETIDE":t=De.o.NUCLEOTIDE;break;default:t=De.o.AA}const n=Array.from(e.values()).reduce((e,t)=>e+t,0),i={};for(const[t,o]of e.entries())i[t]=Math.max(1,Math.round(o/n*100));const o=(0,pi.F)(i,t,this.monomerLib);return o.style.fontSize="11px",o.style.marginTop="4px",o}createTooltipContent(e,t,n){const i=[];if(i.push(s.divText(`Position: ${e+1}`,{style:{fontWeight:"bold",marginBottom:"6px",fontSize:"13px"}})),t&&(i.push(s.divText(`Monomer: ${t}`,{style:{marginBottom:"6px",fontSize:"13px"}})),n.has(t)&&i.push(s.divText(`${(100*n.get(t)).toFixed(2)}%`,{style:{marginBottom:"6px",fontSize:"13px"}}))),n&&n.size>0){const e=this.createFrequencyTable(n);i.push(e)}else i.push(s.divText("No data available",{style:{fontStyle:"italic",color:"#666"}}));const o=s.divV(i);return o.style.maxHeight="80vh",o}setMonomerLib(e){this.monomerLib=e}setBiotype(e){this.biotype=e}getMonomerAt(e,t,n){if(!this.ctx||!this.visible||0===this.data.size)return null;const i=this.data.get(n);if(!i||0===i.size)return null;const o=t,r=Array.from(i.entries()).sort((e,t)=>t[1]-e[1]),s=r.reduce((e,[t,n])=>e+n,0),a=this.height;let l=0;for(const[e,t]of r){const n=t*a/s;if(o>=l&&o<l+n)return e;l+=n}return null}updateData(e){this.data=e,this.visible=e.size>0}draw(e,t,n,i,o,r,s,a){if(!this.ctx||!this.visible||0===this.data.size)return;const l=Math.floor(n/r),c=i-4,u=t+2;for(let h=0;h<l;h++)this.drawWebLogoColumn(h,e,t,n,i,o,r,s,a,u,c)}drawWebLogoColumn(e,t,n,i,o,r,s,a,l,c,u){const h=r+e-1;if(h<0||h>=a)return;const d=this.data.get(h);if(!d||0===d.size)return;const p=t+e*s,m=s-2;r+e===l&&(this.ctx.fillStyle=Xi,this.ctx.fillRect(p,n,s,o)),this.ctx.fillStyle=Ji,this.ctx.fillRect(p+1,c,m,u),this.drawLettersInColumn(h,p,m,c,u,d),this.drawColumnBorder(p,c,m,u)}drawLettersInColumn(e,t,n,i,o,r){const s=Array.from(r.entries()).sort((e,t)=>t[1]-e[1]),a=s.reduce((e,[t,n])=>e+n,0),l=Math.min(1,o/(a*o));let c=i;const u=i+o;for(const[i,r]of s){const s=r*o*l,a=Math.max(4,Math.floor(s));if(a<4)continue;const h=e===this.hoveredPosition&&i===this.hoveredMonomer,d=Math.min(a,u-c);if(d<4)break;this.drawLetter(i,t+1,c,n,d,h),c+=d}}drawColumnBorder(e,t,n,i){this.ctx.strokeStyle=Qi,this.ctx.lineWidth=1,this.ctx.strokeRect(e+1,t,n,i)}drawLetter(e,t,n,i,o,r=!1){if(!this.ctx)return;const s=this.getMonomerBackgroundColor(e),a=this.getMonomerTextColor(e);this.ctx.fillStyle=s,this.ctx.fillRect(t,n,i,o),r&&(this.ctx.shadowColor="rgba(255, 255, 255, 0.8)",this.ctx.shadowBlur=8,this.ctx.strokeStyle="white",this.ctx.lineWidth=2,this.ctx.strokeRect(t,n,i,o),this.ctx.shadowBlur=0),this.drawLetterSeparators(t,n,i,o),this.drawLetterText(e,t,n,i,o,a)}drawLetterSeparators(e,t,n,i){this.ctx.strokeStyle="rgba(255, 255, 255, 0.4)",this.ctx.lineWidth=1,t+i<t+this.ctx.canvas.height&&(this.ctx.beginPath(),this.ctx.moveTo(e,t+i),this.ctx.lineTo(e+n,t+i),this.ctx.stroke())}drawLetterText(e,t,n,i,o,r){const s=Math.min(.8*o,.8*i);s>=7&&(this.ctx.fillStyle=r,this.ctx.font=`bold ${s}px Roboto, Roboto Local`,this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillText(e,t+i/2,n+o/2))}getMonomerBackgroundColor(e){if(this.monomerLib)try{const t=this.monomerLib.getMonomerColors(this.biotype,e);if(t&&t.backgroundcolor)return t.backgroundcolor}catch(e){console.warn("Error getting background color from monomerLib:",e)}return"#CCCCCC"}getMonomerTextColor(e){const t=this.getMonomerBackgroundColor(e);try{const e=a.Color.fromHtml(t),n=a.Color.getContrastColor(e);return a.Color.toHtml(n)}catch(e){return console.warn("Error calculating contrast color:",e),"#000000"}}}class no extends eo{constructor(e,t=io.DEFAULT_TRACK_HEIGHT,n="default",i="Conservation"){super(t,io.MIN_TRACK_HEIGHT,i),this.data=e,this.colorScheme=n,this.visible=e.length>0}updateData(e){this.data=e,this.visible=e.length>0}draw(e,t,n,i,o,r,s,a){if(!this.ctx||!this.visible||0===this.data.length)return;const l=Math.floor(n/r);for(let n=0;n<l;n++){const l=o+n;if(l>s)break;const c=e+n*r,u=r,h=c+u/2;l-1<this.data.length&&(this.drawConservationBar(l-1,c,u,h,t,i),l===a&&(this.ctx.fillStyle=Xi,this.ctx.fillRect(c,t,u,i)))}}drawConservationBar(e,t,n,i,o,r){if(!this.ctx)return;const s=this.data[e];this.ctx.fillStyle=Ji,this.ctx.fillRect(t+2,o,n-4,r);let a="#3CB173";if("default"===this.colorScheme)s<.5?a="#E74C3C":s<.75&&(a="#F39C12");else if("rainbow"===this.colorScheme)a=s<.2?"#E74C3C":s<.4?"#FF7F00":s<.6?"#FFFF00":s<.8?"#00FF00":"#0000FF";else if("heatmap"===this.colorScheme){const e=Math.round(255*s);a=`rgb(255, ${e}, ${e})`}const l=s*r;this.ctx.fillStyle=a,this.ctx.fillRect(t+2,o+r-l,n-4,l),this.ctx.strokeStyle=Qi,this.ctx.lineWidth=1,this.ctx.strokeRect(t+2,o,n-4,r),n>20&&(this.ctx.fillStyle=Zi,this.ctx.font="9px monospace",this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillText(`${Math.round(100*s)}%`,i,o+r/2))}}const io={TITLE_HEIGHT:16,TRACK_GAP:4,DOTTED_CELL_HEIGHT:30,SLIDER_HEIGHT:8,TOP_PADDING:5,DEFAULT_TRACK_HEIGHT:45,MIN_TRACK_HEIGHT:35},oo={BASE:io.DOTTED_CELL_HEIGHT+io.SLIDER_HEIGHT,WITH_TITLE:function(){return this.BASE+io.TITLE_HEIGHT+io.TRACK_GAP},WITH_WEBLOGO:function(){return this.WITH_TITLE()+io.DEFAULT_TRACK_HEIGHT+io.TRACK_GAP},WITH_BOTH:function(){return this.WITH_WEBLOGO()+io.DEFAULT_TRACK_HEIGHT+io.TRACK_GAP}};class ro{constructor(e,t){this.gridColumn=t,this.canvas=null,this.ctx=null,this.tracks=new Map,this.currentHoverPosition=-1,this.currentHoverTrack=null,this.currentHoverMonomer=null,this.previousHoverPosition=-1,this.previousHoverTrack=null,this.previousHoverMonomer=null,this.dataFrame=null,this.seqHandler=null,this.seqColumn=null,this.onSelectionCallback=null,this.trackButtons=[],this.userSelectedTracks=null,this.config={x:e.x||0,y:e.y||0,width:e.width||0,height:e.height||0,windowStartPosition:e.windowStartPosition||1,positionWidth:e.positionWidth||15,totalPositions:e.totalPositions||5e3,headerHeight:e.headerHeight||oo.BASE,sliderHeight:e.sliderHeight||io.SLIDER_HEIGHT,currentPosition:e.currentPosition||1,cellBackground:void 0===e.cellBackground||e.cellBackground,sliderColor:e.sliderColor||"rgba(220, 220, 220, 0.4)",onPositionChange:e.onPositionChange||((e,t)=>{}),onHeaderHeightChange:e.onHeaderHeightChange||(()=>{}),...e},this.eventElement=s.div(),this.eventElement.style.position="absolute",this.config.canvas.parentElement?.appendChild(this.eventElement),this.state={isDragging:!1,dragStartX:0},this.setupEventListeners(),this.init()}determineVisibleTracks(){const e=this.config.headerHeight,t=this.getTrack("weblogo"),n=this.getTrack("conservation");if(this.tracks.forEach(e=>{e.setVisible(!1),e.setHeight(io.DEFAULT_TRACK_HEIGHT)}),!(e<oo.WITH_TITLE()||e<oo.WITH_WEBLOGO()))if(e<oo.WITH_BOTH()){if(t){t.setVisible(!0);const n=e-oo.WITH_WEBLOGO();t.setHeight(io.DEFAULT_TRACK_HEIGHT+n)}}else{if(t&&t.setVisible(!0),n&&n.setVisible(!0),t&&e>oo.WITH_BOTH()){const n=e-oo.WITH_BOTH();t.setHeight(io.DEFAULT_TRACK_HEIGHT+n)}this.userSelectedTracks&&(this.tracks.forEach((e,t)=>{this.userSelectedTracks[t]||e.setVisible(!1)}),e<oo.WITH_WEBLOGO()&&t&&t.setVisible(!1),e<oo.WITH_BOTH()&&n&&n.setVisible(!1))}}drawTrackButtons(){if(!this.ctx||this.config.width<280)return;this.trackButtons=[];const e=this.getTrack("conservation"),t=this.getTrack("weblogo"),n=e?.isVisible()??!1,i=t?.isVisible()??!1;let o=this.config.width-16;const r=this.config.headerHeight>=oo.WITH_TITLE()?(io.TITLE_HEIGHT-14)/2:2;n&&i||(!n&&e&&(o-=70,this.drawTrackButton("conservation","Conservation",o,r,70,14),o-=4),!i&&t&&(o-=70,this.drawTrackButton("weblogo","WebLogo",o,r,70,14)))}drawTrackButton(e,t,n,i,o,r,s=!1){this.ctx&&(this.trackButtons.push({id:e,label:t,x:n,y:i,width:o,height:r}),this.ctx.fillStyle=s?"rgba(100, 150, 200, 0.8)":"rgba(240, 240, 240, 0.8)",this.ctx.fillRect(n,i,o,r),this.ctx.strokeStyle=s?"rgba(70, 120, 170, 0.8)":"rgba(180, 180, 180, 0.8)",this.ctx.lineWidth=1,this.ctx.strokeRect(n,i,o,r),this.ctx.fillStyle=s?"#ffffff":"#666666",this.ctx.font="9px Roboto, Roboto Local",this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillText(t,n+o/2,i+r/2))}handleTrackButtonClick(e,t){for(const n of this.trackButtons)if(e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height)return this.snapToTrackHeight(n.id),!0;return!1}isInsideColumnHeaderArea(e,t){return t<(this.config.headerHeight>=oo.WITH_TITLE()?io.TITLE_HEIGHT:0)}snapToTrackHeight(e){let t;if("weblogo"===e)t=oo.WITH_WEBLOGO();else{if("conservation"!==e)return;t=oo.WITH_BOTH()}this.userSelectedTracks||(this.userSelectedTracks={},this.tracks.forEach((e,t)=>{this.userSelectedTracks[t]=!1})),"conservation"===e?(this.userSelectedTracks.weblogo=!0,this.userSelectedTracks.conservation=!0):"weblogo"===e&&(this.userSelectedTracks.weblogo=!0),this.config.onHeaderHeightChange&&this.config.onHeaderHeightChange(t),window.requestAnimationFrame(()=>this.redraw())}resetToAutoMode(){this.userSelectedTracks=null;const e=this.tracks.size>0?oo.WITH_BOTH():oo.BASE;this.config.onHeaderHeightChange&&this.config.onHeaderHeightChange(e),window.requestAnimationFrame(()=>this.redraw())}drawColumnTitle(e,t,n,i){this.ctx&&i&&this.config.headerHeight>=oo.WITH_TITLE()&&(this.ctx.fillStyle="rgba(255, 255, 255, 0.95)",this.ctx.fillRect(e,t,n,io.TITLE_HEIGHT),this.ctx.fillStyle=Zi,this.ctx.font="bold 13px Roboto, Roboto Local",this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillText(i,e+n/2,t+io.TITLE_HEIGHT/2))}clearHoverStates(){(-1!==this.previousHoverPosition||null!==this.previousHoverTrack||null!==this.previousHoverMonomer)&&(this.previousHoverPosition=-1,this.previousHoverTrack=null,this.previousHoverMonomer=null,this.tracks.forEach(e=>{e instanceof to&&e.setHovered(-1,null)}),window.requestAnimationFrame(()=>this.redraw()))}redraw(){this.draw(this.config.x,this.config.y,this.config.width,this.config.height,this.config.currentPosition,this.config.windowStartPosition,{preventDefault:()=>{}},this.seqColumn?.name)}setSelectionData(e,t,n,i){this.dataFrame=e,this.seqColumn=t,this.seqHandler=n,this.onSelectionCallback=i||null}setupTooltipHandling(){this.eventElement.addEventListener("mousemove",this.handleTooltipMouseMove.bind(this)),this.eventElement.addEventListener("mouseleave",this.handleTooltipMouseLeave.bind(this))}handleTooltipMouseMove(e){if(!this.isValid)return;const{x:t,y:n}=this.getCoords(e),i=this.config.positionWidth,o=Math.floor(t/i),r=this.config.windowStartPosition+o-1;if(r<0||r>=this.config.totalPositions)return this.hideTooltip(),void this.clearHoverStates();const a=this.config.headerHeight>=oo.WITH_TITLE()?io.TITLE_HEIGHT:0,l=this.config.headerHeight-io.SLIDER_HEIGHT-io.DOTTED_CELL_HEIGHT,c=l-io.TRACK_GAP;if(n>=l||n<a)return this.hideTooltip(),void this.clearHoverStates();let u=null,h=0;const d=[],p=this.getTrack("weblogo");p&&p.isVisible()&&d.push({id:"weblogo",track:p});const m=this.getTrack("conservation");m&&m.isVisible()&&d.push({id:"conservation",track:m});let f=c;for(const{id:e,track:t}of d){const i=f-t.getHeight();if(n>=i&&n<f){u=e,h=n-i;break}f=i-io.TRACK_GAP}let g=null;if(u){const e=this.tracks.get(u);e&&(g=e.getMonomerAt(t,h,r))}if((this.previousHoverPosition!==r||this.previousHoverTrack!==u||this.previousHoverMonomer!==g)&&(this.previousHoverPosition=r,this.previousHoverTrack=u,this.previousHoverMonomer=g,u)){const e=this.tracks.get(u);e instanceof to&&(e.setHovered(r,g),window.requestAnimationFrame(()=>this.redraw()))}if((r!==this.currentHoverPosition||u!==this.currentHoverTrack||g!==this.currentHoverMonomer)&&(this.currentHoverPosition=r,this.currentHoverTrack=u,this.currentHoverMonomer=g,u)){const t=this.tracks.get(u);if(t){const n=t.getTooltipContent(r,g);if(n)return void s.tooltip.show(n,e.clientX+16,e.clientY+16)}}u&&g||(this.hideTooltip(),this.clearHoverStates())}handleTooltipMouseLeave(){this.hideTooltip(),this.clearHoverStates(),window.requestAnimationFrame(()=>this.draw(this.config.x,this.config.y,this.config.width,this.config.height,this.config.currentPosition,this.config.windowStartPosition,{preventDefault:()=>{}},this.seqColumn?.name))}hideTooltip(){this.currentHoverPosition=-1,this.currentHoverTrack=null,s.tooltip.hide()}draw(e,t,n,i,o,r,s,a){if(Object.assign(this.config,{x:e,y:t,width:n,height:i,currentPosition:o,windowStartPosition:r}),!this.isValid)return void(this.eventElement.style.display="none");this.ctx.save(),this.ctx.clearRect(e,t,n,i),this.ctx.translate(e,t),this.ctx.rect(0,0,n,i),this.ctx.clip(),this.determineVisibleTracks();const l=this.config.headerHeight>=oo.WITH_TITLE();l&&io.TITLE_HEIGHT,a&&l&&this.drawColumnTitle(0,0,n,a);const c=i-io.SLIDER_HEIGHT,u=c-io.DOTTED_CELL_HEIGHT,h=u-io.TRACK_GAP,d=[],p=[],m=this.getTrack("weblogo");m&&m.isVisible()&&p.push({id:"weblogo",track:m});const f=this.getTrack("conservation");f&&f.isVisible()&&p.push({id:"conservation",track:f});let g=h;for(const{track:e}of p){const t=e.getHeight(),i=g-t;e.draw(0,i,n,t,this.config.windowStartPosition,this.config.positionWidth,this.config.totalPositions,this.config.currentPosition),d.unshift({y:i,height:t}),g=i-io.TRACK_GAP}if(this.drawDottedCells(0,u,n,io.DOTTED_CELL_HEIGHT,c),d.push({y:u,height:io.DOTTED_CELL_HEIGHT}),this.config.currentPosition>=1&&this.config.currentPosition<=this.config.totalPositions){const e=this.config.positionWidth,t=this.config.currentPosition-this.config.windowStartPosition;if(t>=0&&t<Math.floor(n/e)){const n=t*e+e/2;for(let e=0;e<d.length-1;e++){const t=d[e],i=d[e+1];this.ctx.strokeStyle="rgba(60, 177, 115, 0.4)",this.ctx.lineWidth=1,this.ctx.beginPath(),this.ctx.moveTo(n,t.y+t.height),this.ctx.lineTo(n,i.y),this.ctx.stroke()}}}this.drawTrackButtons(),this.ctx.restore(),s.preventDefault(),this.setupEventElement()}drawDottedCells(e,t,n,i,o){if(!this.ctx)return;const r=this.config.totalPositions,s=this.config.positionWidth,a=this.config.currentPosition,l=this.config.windowStartPosition,c=Math.floor(n/s),u=t+io.TOP_PADDING;this.drawSlider(e,o,n);for(let n=0;n<c;n++){const c=l+n;if(c>r)break;const h=e+n*s,d=s,p=h+d/2;this.config.cellBackground&&(this.ctx.fillStyle=n%2==0?"rgba(248, 248, 248, 0.3)":"rgba(242, 242, 242, 0.2)",this.ctx.fillRect(h,t,d,i),this.ctx.strokeStyle="rgba(220, 220, 220, 0.7)",this.ctx.beginPath(),this.ctx.moveTo(h,t),this.ctx.lineTo(h,o),this.ctx.stroke()),this.ctx.fillStyle="#999999",this.ctx.beginPath(),this.ctx.arc(p,u+5,1,0,2*Math.PI),this.ctx.fill(),(c===a||(1===c||c%10==0)&&Math.abs(c-a)>1)&&(this.ctx.fillStyle=Zi,this.ctx.font="12px monospace",this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillText(c.toString(),p,u+15)),c===a&&(this.ctx.fillStyle="rgba(60, 177, 115, 0.2)",this.ctx.fillRect(h,t,d,i))}}drawSlider(e,t,n){if(!this.ctx)return;this.ctx.fillStyle=this.config.sliderColor,this.ctx.fillRect(e,t,n,io.SLIDER_HEIGHT);const i=Math.floor(n/this.config.positionWidth),o=this.config.windowStartPosition,r=this.config.totalPositions-i,s=this.sliderWidth,a=r<=0?0:(o-1)/r*(n-s),l=r<=0?n:s;if(this.ctx.fillStyle="rgba(150, 150, 150, 0.5)",this.ctx.fillRect(e+a,t,l,io.SLIDER_HEIGHT),this.config.currentPosition>=1&&this.config.currentPosition<=this.config.totalPositions){const i=(this.config.currentPosition-1)/(this.config.totalPositions-1),o=Math.round(i*n);this.ctx.fillStyle="#3CB173",this.ctx.fillRect(e+o-1,t-2,3,io.SLIDER_HEIGHT+4)}}setupEventElement(){this.eventElement.style.display="block",this.eventElement.style.left=`${this.config.x}px`,this.eventElement.style.top=`${this.config.y}px`,this.eventElement.style.width=`${this.config.width}px`,this.eventElement.style.height=`${this.config.height}px`}getCoords(e){const t=this.canvas.getBoundingClientRect();return{x:e.clientX-t.left-this.config.x,y:e.clientY-t.top-this.config.y}}isInHeaderArea(e){const{x:t,y:n}=this.getCoords(e);return t>=0&&t<=this.config.width&&n>=0&&n<=this.config.headerHeight}get positionWidth(){return this.config.positionWidth}set positionWidth(e){this.config.positionWidth=e}isInSliderArea(e){const{y:t}=this.getCoords(e),n=this.config.headerHeight-io.SLIDER_HEIGHT;return t>n&&t<n+io.SLIDER_HEIGHT}get sliderWidth(){const e=this.config.width/this.config.totalPositions*(this.config.width/this.config.positionWidth);return Math.max(e,20)}isInSliderDraggableArea(e){const{x:t,y:n}=this.getCoords(e),i=this.config.headerHeight-io.SLIDER_HEIGHT,o=Math.floor(this.config.width/this.config.positionWidth),r=this.config.windowStartPosition,s=this.config.totalPositions-o,a=s<=0?0:(r-1)/s*(this.config.width-this.sliderWidth);return n>i&&n<i+io.SLIDER_HEIGHT&&t>=a&&t<a+this.sliderWidth}setupEventListeners(){this.eventElement.addEventListener("mousemove",e=>{this.isValid&&(this.isInSliderDraggableArea(e)?this.eventElement.style.cursor="grab":this.isInSliderArea(e)||this.isInHeaderArea(e)?this.eventElement.style.cursor="pointer":this.eventElement.style.cursor="default")}),this.eventElement.addEventListener("mousedown",this.handleMouseDown.bind(this)),this.eventElement.addEventListener("mousemove",this.handleMouseMove.bind(this)),this.eventElement.addEventListener("mouseup",this.handleMouseUp.bind(this)),this.eventElement.addEventListener("mouseleave",this.handleMouseUp.bind(this)),this.eventElement.addEventListener("click",this.handleSelectionClick.bind(this)),this.eventElement.addEventListener("click",this.handleClick.bind(this)),this.eventElement.addEventListener("wheel",this.handleMouseWheel.bind(this)),window.addEventListener("keydown",this.handleKeyDown.bind(this))}handleSelectionClick(e){if(!(this.isValid&&this.dataFrame&&this.seqColumn&&this.seqHandler))return;const{x:t,y:n}=this.getCoords(e);if(this.handleTrackButtonClick(t,n))return;if(this.isInsideColumnHeaderArea(t,n))return;const i=this.config.positionWidth,o=Math.floor(t/i),r=this.config.windowStartPosition+o-1;if(r<0||r>=this.config.totalPositions)return;const s=this.config.headerHeight>=oo.WITH_TITLE()?io.TITLE_HEIGHT:0,a=this.config.headerHeight-io.SLIDER_HEIGHT-io.DOTTED_CELL_HEIGHT,l=a-io.TRACK_GAP;if(n>=a||n<s)return;let c=null,u=0;const h=[],d=this.getTrack("weblogo");d&&d.isVisible()&&h.push({id:"weblogo",track:d});const p=this.getTrack("conservation");p&&p.isVisible()&&h.push({id:"conservation",track:p});let m=l;for(const{id:e,track:t}of h){const i=m-t.getHeight();if(n>=i&&n<m){c=e,u=n-i;break}m=i-io.TRACK_GAP}if(c){const n=this.tracks.get(c);if(n){const i=n.getMonomerAt(t,u,r);if(i){if(this.onSelectionCallback)return void this.onSelectionCallback(r,i);this.selectRowsWithMonomerAtPosition(r,i),e.stopPropagation(),e.stopImmediatePropagation()}}}}selectRowsWithMonomerAtPosition(e,t){if(this.dataFrame&&this.seqHandler)try{const n=this.dataFrame.selection,i=this.seqHandler.getMonomersAtPosition(e,!0);n.init(e=>i[e]===t)}catch(e){console.error("Error selecting rows:",e)}}init(){if(this.canvas=this.config.canvas,!this.canvas)return void console.error("Canvas not found");const e=this.canvas.getContext("2d");e?(this.ctx=e,this.tracks.forEach(t=>t.init(e))):console.error("Failed to get 2D context from canvas")}addTrack(e,t){this.ctx&&t.init(this.ctx),this.tracks.set(e,t)}removeTrack(e){this.tracks.delete(e)}getTrack(e){return this.tracks.get(e)}updateTrack(e,t){const n=this.getTrack(e);n&&t(n)}get isValid(){const e=this.gridColumn,t=e?.grid,n=t?.horzScroll?.min||0,i=t?.horzScroll?.max||1e7;return!!this.canvas&&!!this.ctx&&this.config.height>=oo.WITH_TITLE()&&t&&(so(e.left??0,n,i)||so(e.right??1/0,n,i))}handleMouseDown(e){if(!this.isValid)return;const{x:t}=this.getCoords(e);this.isInSliderDraggableArea(e)&&(this.state.isDragging=!0,this.state.dragStartX=t,this.handleSliderDrag(t),e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation())}handleMouseWheel(e){if(this.isValid&&this.isInHeaderArea(e)){e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation();const t=e.shiftKey?Math.sign(e.deltaY):Math.sign(e.deltaX||e.deltaY),n=e.shiftKey?3:1,i=this.config.windowStartPosition+t*n,o=Math.floor(this.config.width/this.config.positionWidth),r=this.config.totalPositions-o+1;this.config.windowStartPosition=Math.max(1,Math.min(r,i)),"function"==typeof this.config.onPositionChange&&this.config.onPositionChange(this.config.currentPosition,this.getWindowRange())}}handleMouseMove(e){if(!this.state.isDragging||!this.isValid)return;const t=this.canvas.getBoundingClientRect(),n=e.clientX-t.left-this.config.x;this.handleSliderDrag(n),e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation()}handleKeyDown(e){if(this.isValid&&!(this.config.currentPosition<1)&&document.activeElement?.contains(this.eventElement)&&"block"===this.eventElement.style.display){if("ArrowLeft"===e.key||"ArrowRight"===e.key){e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation();const t="ArrowLeft"===e.key?-1:1,n=Math.min(Math.max(this.config.currentPosition+t,1),this.config.totalPositions);if(n===this.config.currentPosition)return;this.config.currentPosition=n;const i=Math.floor(this.config.width/this.config.positionWidth),o=this.config.windowStartPosition;(n<o||n>o+i-1)&&(this.config.windowStartPosition=t<0?n:Math.max(1,n-i+1))}else{if("Escape"!==e.key)return;this.config.currentPosition=-2,e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation()}"function"==typeof this.config.onPositionChange&&this.config.onPositionChange(this.config.currentPosition,this.getWindowRange())}}handleMouseUp(){this.state.isDragging=!1}handleSliderDrag(e){if(!this.isValid)return;const t=this.sliderWidth,n=this.config.width-t,i=Math.max(0,Math.min(this.config.width,e)),o=Math.floor(this.config.width/this.config.positionWidth),r=Math.floor(this.config.width/this.config.positionWidth),s=this.config.totalPositions-r,a=Math.max(0,i-t/2)/n*s;this.config.windowStartPosition=Math.max(1,Math.min(a,this.config.totalPositions-o+1)),"function"==typeof this.config.onPositionChange&&this.config.onPositionChange(this.config.currentPosition,this.getWindowRange())}get headerHeight(){return this.config.headerHeight}set headerHeight(e){this.config.headerHeight=e}handleClick(e){if(!this.isValid)return;e.clientX,this.canvas.getBoundingClientRect().left,e.clientY,this.canvas.getBoundingClientRect().top;const{x:t,y:n}=this.getCoords(e);if(this.handleTrackButtonClick(t,n))return e.preventDefault(),void e.stopPropagation();if(!this.isInsideColumnHeaderArea(t,n)&&n<this.config.headerHeight-io.SLIDER_HEIGHT&&n>=0){const e=this.config.positionWidth,n=Math.round(t/e-.5),i=this.config.windowStartPosition+n;i>=1&&i<=this.config.totalPositions&&(this.config.currentPosition=i,"function"==typeof this.config.onPositionChange&&this.config.onPositionChange(this.config.currentPosition,this.getWindowRange()))}}getWindowRange(){return{start:this.config.windowStartPosition,end:Math.min(this.config.totalPositions,this.config.windowStartPosition+Math.floor(this.config.width/this.config.positionWidth))}}updateConfig(e){Object.assign(this.config,e),this.config.currentPosition=Math.min(this.config.currentPosition,this.config.totalPositions),"function"==typeof this.config.onPositionChange&&this.config.onPositionChange(this.config.currentPosition,this.getWindowRange())}getCurrentPosition(){return this.config.currentPosition}setCurrentPosition(e){this.config.currentPosition=Math.max(1,Math.min(this.config.totalPositions,e)),"function"==typeof this.config.onPositionChange&&this.config.onPositionChange(this.config.currentPosition,this.getWindowRange())}getHeightThresholds(){return{BASE:oo.BASE,WITH_TITLE:oo.WITH_TITLE(),WITH_WEBLOGO:oo.WITH_WEBLOGO(),WITH_BOTH:oo.WITH_BOTH()}}}function so(e,t,n){return e>=t&&e<=n}class ao{static conservationCache=new a.LruCache(100);static webLogoCache=new a.LruCache(100);static lastInvalidationTime=0;static CHUNK_SIZE=50;static clearAllCaches(){ao.conservationCache=new a.LruCache(100),ao.webLogoCache=new a.LruCache(100),ao.lastInvalidationTime=Date.now()}static getLastInvalidationTime(){return ao.lastInvalidationTime}static getChunkCacheKey(e,t,n){const i=e.dataFrame;return`${i.id}_${e.name}_f${i.filter.version}_${t}_${n}`}static getConservationChunk(e,t,n,i){return ao.conservationCache.getOrCreate(i,()=>{const o=ao.getWebLogoChunk(e,t,n,i),r=new Array(n-t).fill(0);for(let i=t;i<n;i++){const n=o.get(i);if(!n||0===n.size)continue;let s=0,a=0;const l=e.defaultGapOriginal;for(const[e,t]of n.entries())e&&e!==l&&(s+=t,t>a&&(a=t));r[i-t]=s>0?a/s:0}return r})}static getWebLogoChunk(e,t,n,i){return ao.webLogoCache.getOrCreate(i,()=>{const i=e.column.dataFrame,o=new Map,r=i.filter.trueCount;if(r<=1)return o;for(let e=t;e<n;e++)o.set(e,new Map);const s=i.filter,a=1/r;for(let i=-1;-1!==(i=s.findNext(i,!0));){const r=e.getSplitted(i).getOriginalRegion(t,n);if(0!==r.length)for(let e=0;e<r.length;e++){const n=r[e],i=o.get(t+e);i.set(n,(i.get(n)||0)+a)}}return o})}static getConservationForViewport(e,t,n,i){const o=new Array(i).fill(0),r=Math.floor(t/ao.CHUNK_SIZE)*ao.CHUNK_SIZE,s=Math.ceil(n/ao.CHUNK_SIZE)*ao.CHUNK_SIZE;for(let t=r;t<s;t+=ao.CHUNK_SIZE){const n=Math.min(t+ao.CHUNK_SIZE,i),r=ao.getChunkCacheKey(e.column,t,n),s=ao.getConservationChunk(e,t,n,r);for(let e=0;e<s.length&&t+e<i;e++)o[t+e]=s[e]}return o}static getWebLogoForViewport(e,t,n,i){const o=new Map,r=Math.floor(t/ao.CHUNK_SIZE)*ao.CHUNK_SIZE,s=Math.ceil(n/ao.CHUNK_SIZE)*ao.CHUNK_SIZE;for(let t=r;t<s;t+=ao.CHUNK_SIZE){const n=Math.min(t+ao.CHUNK_SIZE,i),r=ao.getChunkCacheKey(e.column,t,n),s=ao.getWebLogoChunk(e,t,n,r);for(const[e,t]of s.entries())e<i&&o.set(e,t)}return o}}class lo extends to{seqHandler;maxLength;lastViewportStart=-1;lastViewportEnd=-1;lastInvalidationTime=0;forceNextUpdate=!1;constructor(e,t,n=45,i="WebLogo"){super(new Map,n,"",i),this.seqHandler=e,this.maxLength=t,this.visible=e.column.dataFrame.filter.trueCount>1}forceUpdate(){this.forceNextUpdate=!0}resetViewportTracking(){this.lastViewportStart=-1,this.lastViewportEnd=-1}updateForViewport(e,t){const n=ao.getLastInvalidationTime(),i=n>this.lastInvalidationTime;if(!(Math.abs(this.lastViewportStart-e)>=10||Math.abs(this.lastViewportEnd-t)>=10||i||this.forceNextUpdate))return;this.forceNextUpdate=!1,this.lastViewportStart=e,this.lastViewportEnd=t,this.lastInvalidationTime=n;const o=Math.max(0,e-20),r=Math.min(this.maxLength,t+20),s=ao.getWebLogoForViewport(this.seqHandler,o,r,this.maxLength);this.updateData(s)}draw(e,t,n,i,o,r,s,a){const l=Math.ceil(n/r)+2,c=Math.min(o+l,s);this.updateForViewport(o-1,c-1),super.draw(e,t,n,i,o,r,s,a)}}class co extends no{seqHandler;maxLength;lastViewportStart=-1;lastViewportEnd=-1;lastInvalidationTime=0;forceNextUpdate=!1;constructor(e,t,n=45,i="default",o="Conservation"){super([],n,i,o),this.seqHandler=e,this.maxLength=t,this.visible=e.column.dataFrame.filter.trueCount>1}forceUpdate(){this.forceNextUpdate=!0}resetViewportTracking(){this.lastViewportStart=-1,this.lastViewportEnd=-1}updateForViewport(e,t){const n=ao.getLastInvalidationTime(),i=n>this.lastInvalidationTime;if(!(Math.abs(this.lastViewportStart-e)>=10||Math.abs(this.lastViewportEnd-t)>=10||i||this.forceNextUpdate))return;this.forceNextUpdate=!1,this.lastViewportStart=e,this.lastViewportEnd=t,this.lastInvalidationTime=n;const o=Math.max(0,e-20),r=Math.min(this.maxLength,t+20),s=ao.getConservationForViewport(this.seqHandler,o,r,this.maxLength);this.updateData(s)}draw(e,t,n,i,o,r,s,a){const l=Math.ceil(n/r)+2,c=Math.min(o+l,s);this.updateForViewport(o-1,c-1),super.draw(e,t,n,i,o,r,s,a)}}const uo="__msa-scroller-initialized",ho="__msa-scroller-subscription";class po{separator;seqHelper;seqCol;splitter;get defaultGapOriginal(){return""}constructor(e,t,n){this.separator=e,this.seqHelper=t,this.seqCol=n,this.splitter=Be.bR.bind(this)}setUnits(){}getHelm(e,t){const n=this.splitter(e);return this.seqHelper.getSeqHandler(this.seqCol).getJoiner({notation:ve.Hi.HELM})(n)}createCellRendererBack(e,t){const n=qr.properties.maxMonomerLength||4,i=new mo(e,t,n,this.seqHelper);return i.init().then(()=>{}),i}}class mo extends He.Jy{constructor(e,t,n,i){super(e,t,qr.logger,n,()=>{const e=i.getSeqHandler(t),{font:n,fontWidth:o}=He.Jy.getFontSettings(t);return{seqHandler:e,font:n,fontCharWidth:o,separatorWidth:0,monomerToShort:Be.zS}})}}var fo,go;async function yo(){return await Yr.getMonomerLibHelper()}async function bo(){await Yr.initBio()}function vo(e){return Yr.sequenceTooltip(e)}async function wo(e){return await Yr.standardiseMonomerLibrary(e)}async function Co(e,t,n){await Yr.matchWithMonomerLibrary(e,t,n)}function So(){return Yr.getBioLib()}function Ao(e){return Yr.getSeqHandler(e)}function xo(e){return Yr.getRegionPanel(e)}async function Mo(e){return await Yr.libraryPanel(e)}function To(e){Yr.GetRegionEditor(e)}function Eo(e){Yr.SplitToMonomersEditor(e)}function _o(e){Yr.SequenceSpaceEditor(e)}function Io(e){Yr.SeqActivityCliffsEditor(e)}function Lo(){return Yr.customSequenceCellRenderer()}function No(){return Yr.fastaSequenceCellRenderer()}function Po(){return Yr.separatorSequenceCellRenderer()}function Ro(){return Yr.bilnSequenceCellRenderer()}function $o(e,t,n){return Yr.refineNotationProviderForBiln(e,t,n)}function Oo(e){return Yr.macroMolColumnPropertyPanel(e)}function ko(e){return Yr.compositionAnalysisWidget(e)}function Ho(){return Yr.macromoleculeDifferenceCellRenderer()}function Bo(e,t,n,i,o){return Yr.sequenceAlignment(e,t,n,i,o)}function Fo(){return Yr.webLogoViewer()}function Go(){return Yr.vdRegionsViewer()}function Do(e,t,n,i){return Yr.getRegion(e,t,n,i)}async function Vo(e,t,n,i,o){await Yr.getRegionTopMenu(e,t,n,i,o)}async function Wo(e,t,n,i,o,r,s,a,l){return await Yr.activityCliffs(e,t,n,i,o,r,s,a,l)}async function jo(e,t,n,i,o){return await Yr.macromoleculePreprocessingFunction(e,t,n,i,o)}async function Uo(e,t){return await Yr.helmPreprocessingFunction(e,t)}async function qo(e,t,n,i,o,r,s,a,l){return await Yr.sequenceSpaceTopMenu(e,t,n,i,o,r,s,a,l)}async function zo(e,t){await Yr.moleculesToHelmTopMenu(e,t)}async function Yo(e,t,n,i){await Yr.toAtomicLevel(e,t,n,i)}async function Ko(e){await Yr.toAtomicLevelAction(e)}async function Zo(e){return await Yr.toAtomicLevelPanel(e)}async function Xo(e){return await Yr.sequence3dStructureWidget(e)}function Jo(){Yr.multipleSequenceAlignmentDialog()}async function Qo(e,t,n){return await Yr.alignSequences(e,t,n)}async function er(){return await Yr.compositionAnalysis()}function tr(e){return Yr.importFasta(e)}function nr(e){return Yr.importBam(e)}function ir(){Yr.convertDialog()}function or(e){Yr.convertColumnAction(e)}function rr(){return Yr.monomerCellRenderer()}async function sr(e){return await Yr.testDetectMacromolecule(e)}async function ar(e,t){return await Yr.splitToMonomersTopMenu(e,t)}function lr(e){return Yr.getHelmMonomers(e)}function cr(){return Yr.similaritySearchViewer()}function ur(){return Yr.similaritySearchTopMenu()}function hr(){return Yr.diversitySearchViewer()}function dr(){return Yr.diversitySearchTopMenu()}function pr(e){Yr.searchSubsequenceEditor(e)}function mr(e){Yr.SubsequenceSearchTopMenu(e)}async function fr(e,t,n){return await Yr.sequenceIdentityScoring(e,t,n)}async function gr(e,t,n){return await Yr.sequenceSimilarityScoring(e,t,n)}async function yr(){await Yr.manageMonomerLibraries()}async function br(){await Yr.manageLibrariesView()}async function vr(){await Yr.manageMonomersView()}async function wr(){return await Yr.manageMonomerLibrariesView()}async function Cr(e){await Yr.manageMonomerLibrariesViewTreeBrowser(e)}function Sr(){Yr.saveAsFasta()}function Ar(){return Yr.bioSubstructureFilter()}function xr(){return Yr.bioSubstructureFilterTest()}async function Mr(){await Yr.webLogoLargeApp()}async function Tr(){await Yr.webLogoAggApp()}async function Er(){await Yr.getRegionApp()}async function _r(){await Yr.getRegionHelmApp()}function Ir(){Yr.longSeqTableSeparator()}function Lr(){Yr.longSeqTableFasta()}function Nr(){Yr.longSeqTableHelm()}function Pr(e,t){Yr.addCopyMenu(e,t)}async function Rr(){await Yr.demoBioSimilarityDiversity()}async function $r(){await Yr.demoBioSequenceSpace()}async function Or(){await Yr.demoBioActivityCliffs()}async function kr(){await Yr.demoBioAtomicLevel()}async function Hr(e){await Yr.sdfToJsonLib(e)}async function Br(e,t){return await Yr.seq2atomic(e,t)}async function Fr(e,t){return await Yr.seqIdentity(e,t)}async function Gr(e,t,n){await Yr.detectMacromoleculeProbe(e,t,n)}async function Dr(){return await Yr.getSeqHelper()}async function Vr(e,t,n){return await Yr.getMolFromHelm(e,t,n)}!function(e){e.embed=async function(e){return await r.functions.call("Bio:Embed",{molecule:e})},e.molToHelmConverterPy=async function(e,t,n){return await r.functions.call("Bio:MolToHelmConverterPy",{moleculesDataframe:e,moleculesColumn:t,libraryJSON:n})},e.sequenceGenerator=async function(e,t,n,i,o,s,a,l,c,u,h,d,p,m,f,g,y){return await r.functions.call("Bio:SequenceGenerator",{clusters:e,num_sequences:t,alphabet_key:n,motif_length:i,max_variants_position:o,random_length:s,dispersion:a,activity_range:l,cliff_probability:c,cliff_strength:u,cliff_strength_dispersion:h,assay_noise_levels:d,assay_scales:p,disable_negatives:m,fasta_separator:f,helm_library_file:g,helm_connection_mode:y})}}(fo||(fo={})),function(e){e.test1=async function(){return await r.functions.call("Bio:Test1",{})},e.getMonomerLibHelper=async function(){return await r.functions.call("Bio:GetMonomerLibHelper",{})},e.initBio=async function(){return await r.functions.call("Bio:InitBio",{})},e.sequenceTooltip=async function(e){return await r.functions.call("Bio:SequenceTooltip",{col:e})},e.standardiseMonomerLibrary=async function(e){return await r.functions.call("Bio:StandardiseMonomerLibrary",{library:e})},e.matchWithMonomerLibrary=async function(e,t,n){return await r.functions.call("Bio:MatchWithMonomerLibrary",{table:e,molecules:t,polymerType:n})},e.getBioLib=async function(){return await r.functions.call("Bio:GetBioLib",{})},e.getSeqHandler=async function(e){return await r.functions.call("Bio:GetSeqHandler",{sequence:e})},e.getRegionPanel=async function(e){return await r.functions.call("Bio:GetRegionPanel",{seqCol:e})},e.libraryPanel=async function(e){return await r.functions.call("Bio:LibraryPanel",{seqColumn:e})},e.getRegionEditor=async function(e){return await r.functions.call("Bio:GetRegionEditor",{call:e})},e.splitToMonomersEditor=async function(e){return await r.functions.call("Bio:SplitToMonomersEditor",{call:e})},e.sequenceSpaceEditor=async function(e){return await r.functions.call("Bio:SequenceSpaceEditor",{call:e})},e.seqActivityCliffsEditor=async function(e){return await r.functions.call("Bio:SeqActivityCliffsEditor",{call:e})},e.customSequenceCellRenderer=async function(){return await r.functions.call("Bio:CustomSequenceCellRenderer",{})},e.fastaSequenceCellRenderer=async function(){return await r.functions.call("Bio:FastaSequenceCellRenderer",{})},e.separatorSequenceCellRenderer=async function(){return await r.functions.call("Bio:SeparatorSequenceCellRenderer",{})},e.bilnSequenceCellRenderer=async function(){return await r.functions.call("Bio:BilnSequenceCellRenderer",{})},e.refineNotationProviderForBiln=async function(e,t,n){return await r.functions.call("Bio:RefineNotationProviderForBiln",{col:e,stats:t,separator:n})},e.macroMolColumnPropertyPanel=async function(e){return await r.functions.call("Bio:MacroMolColumnPropertyPanel",{molColumn:e})},e.compositionAnalysisWidget=async function(e){return await r.functions.call("Bio:CompositionAnalysisWidget",{sequence:e})},e.macromoleculeDifferenceCellRenderer=async function(){return await r.functions.call("Bio:MacromoleculeDifferenceCellRenderer",{})},e.sequenceAlignment=async function(e,t,n,i,o){return await r.functions.call("Bio:SequenceAlignment",{alignType:e,alignTable:t,gap:n,seq1:i,seq2:o})},e.webLogoViewer=async function(){return await r.functions.call("Bio:WebLogoViewer",{})},e.vdRegionsViewer=async function(){return await r.functions.call("Bio:VdRegionsViewer",{})},e.getRegion=async function(e,t,n,i){return await r.functions.call("Bio:GetRegion",{sequence:e,start:t,end:n,name:i})},e.getRegionTopMenu=async function(e,t,n,i,o){return await r.functions.call("Bio:GetRegionTopMenu",{table:e,sequence:t,start:n,end:i,name:o})},e.activityCliffs=async function(e,t,n,i,o,s,a,l,c){return await r.functions.call("Bio:ActivityCliffs",{table:e,molecules:t,activities:n,similarity:i,methodName:o,similarityMetric:s,preprocessingFunction:a,options:l,demo:c})},e.macromoleculePreprocessingFunction=async function(e,t,n,i,o){return await r.functions.call("Bio:MacromoleculePreprocessingFunction",{col:e,metric:t,gapOpen:n,gapExtend:i,fingerprintType:o})},e.helmPreprocessingFunction=async function(e,t){return await r.functions.call("Bio:HelmPreprocessingFunction",{col:e,_metric:t})},e.sequenceSpaceTopMenu=async function(e,t,n,i,o,s,a,l,c){return await r.functions.call("Bio:SequenceSpaceTopMenu",{table:e,molecules:t,methodName:n,similarityMetric:i,plotEmbeddings:o,preprocessingFunction:s,options:a,clusterEmbeddings:l,isDemo:c})},e.moleculesToHelmTopMenu=async function(e,t){return await r.functions.call("Bio:MoleculesToHelmTopMenu",{table:e,molecules:t})},e.toAtomicLevel=async function(e,t,n,i){return await r.functions.call("Bio:ToAtomicLevel",{table:e,seqCol:t,nonlinear:n,highlight:i})},e.toAtomicLevelAction=async function(e){return await r.functions.call("Bio:ToAtomicLevelAction",{seqCol:e})},e.toAtomicLevelPanel=async function(e){return await r.functions.call("Bio:ToAtomicLevelPanel",{sequence:e})},e.sequence3dStructureWidget=async function(e){return await r.functions.call("Bio:Sequence3dStructureWidget",{sequence:e})},e.multipleSequenceAlignmentDialog=async function(){return await r.functions.call("Bio:MultipleSequenceAlignmentDialog",{})},e.alignSequences=async function(e,t,n){return await r.functions.call("Bio:AlignSequences",{sequenceCol:e,clustersCol:t,options:n})},e.compositionAnalysis=async function(){return await r.functions.call("Bio:CompositionAnalysis",{})},e.importFasta=async function(e){return await r.functions.call("Bio:ImportFasta",{fileContent:e})},e.importBam=async function(e){return await r.functions.call("Bio:ImportBam",{fileContent:e})},e.convertDialog=async function(){return await r.functions.call("Bio:ConvertDialog",{})},e.convertColumnAction=async function(e){return await r.functions.call("Bio:ConvertColumnAction",{col:e})},e.monomerCellRenderer=async function(){return await r.functions.call("Bio:MonomerCellRenderer",{})},e.testDetectMacromolecule=async function(e){return await r.functions.call("Bio:TestDetectMacromolecule",{path:e})},e.splitToMonomersTopMenu=async function(e,t){return await r.functions.call("Bio:SplitToMonomersTopMenu",{table:e,sequence:t})},e.getHelmMonomers=async function(e){return await r.functions.call("Bio:GetHelmMonomers",{sequence:e})},e.similaritySearchViewer=async function(){return await r.functions.call("Bio:SimilaritySearchViewer",{})},e.similaritySearchTopMenu=async function(){return await r.functions.call("Bio:SimilaritySearchTopMenu",{})},e.diversitySearchViewer=async function(){return await r.functions.call("Bio:DiversitySearchViewer",{})},e.diversitySearchTopMenu=async function(){return await r.functions.call("Bio:DiversitySearchTopMenu",{})},e.searchSubsequenceEditor=async function(e){return await r.functions.call("Bio:SearchSubsequenceEditor",{call:e})},e.subsequenceSearchTopMenu=async function(e){return await r.functions.call("Bio:SubsequenceSearchTopMenu",{macromolecules:e})},e.sequenceIdentityScoring=async function(e,t,n){return await r.functions.call("Bio:SequenceIdentityScoring",{table:e,macromolecule:t,reference:n})},e.sequenceSimilarityScoring=async function(e,t,n){return await r.functions.call("Bio:SequenceSimilarityScoring",{table:e,macromolecule:t,reference:n})},e.manageMonomerLibraries=async function(){return await r.functions.call("Bio:ManageMonomerLibraries",{})},e.manageLibrariesView=async function(){return await r.functions.call("Bio:ManageLibrariesView",{})},e.manageMonomersView=async function(){return await r.functions.call("Bio:ManageMonomersView",{})},e.manageMonomerLibrariesView=async function(){return await r.functions.call("Bio:ManageMonomerLibrariesView",{})},e.manageMonomerLibrariesViewTreeBrowser=async function(e){return await r.functions.call("Bio:ManageMonomerLibrariesViewTreeBrowser",{treeNode:e})},e.saveAsFasta=async function(){return await r.functions.call("Bio:SaveAsFasta",{})},e.bioSubstructureFilter=async function(){return await r.functions.call("Bio:BioSubstructureFilter",{})},e.bioSubstructureFilterTest=async function(){return await r.functions.call("Bio:BioSubstructureFilterTest",{})},e.webLogoLargeApp=async function(){return await r.functions.call("Bio:WebLogoLargeApp",{})},e.webLogoAggApp=async function(){return await r.functions.call("Bio:WebLogoAggApp",{})},e.getRegionApp=async function(){return await r.functions.call("Bio:GetRegionApp",{})},e.getRegionHelmApp=async function(){return await r.functions.call("Bio:GetRegionHelmApp",{})},e.longSeqTableSeparator=async function(){return await r.functions.call("Bio:LongSeqTableSeparator",{})},e.longSeqTableFasta=async function(){return await r.functions.call("Bio:LongSeqTableFasta",{})},e.longSeqTableHelm=async function(){return await r.functions.call("Bio:LongSeqTableHelm",{})},e.addCopyMenu=async function(e,t){return await r.functions.call("Bio:AddCopyMenu",{cell:e,menu:t})},e.demoBioSimilarityDiversity=async function(){return await r.functions.call("Bio:DemoBioSimilarityDiversity",{})},e.demoBioSequenceSpace=async function(){return await r.functions.call("Bio:DemoBioSequenceSpace",{})},e.demoBioActivityCliffs=async function(){return await r.functions.call("Bio:DemoBioActivityCliffs",{})},e.demoBioAtomicLevel=async function(){return await r.functions.call("Bio:DemoBioAtomicLevel",{})},e.sdfToJsonLib=async function(e){return await r.functions.call("Bio:SdfToJsonLib",{table:e})},e.seq2atomic=async function(e,t){return await r.functions.call("Bio:Seq2atomic",{seq:e,nonlinear:t})},e.seqIdentity=async function(e,t){return await r.functions.call("Bio:SeqIdentity",{seq:e,ref:t})},e.detectMacromoleculeProbe=async function(e,t,n){return await r.functions.call("Bio:DetectMacromoleculeProbe",{file:e,colName:t,probeCount:n})},e.getSeqHelper=async function(){return await r.functions.call("Bio:GetSeqHelper",{})},e.getMolFromHelm=async function(e,t,n){return await r.functions.call("Bio:GetMolFromHelm",{df:e,helmCol:t,chiralityEngine:n})}}(go||(go={}));var Wr=function(e,t,n,i){var o,r=arguments.length,s=r<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,i);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(r<3?o(s):r>3?o(t,n,s):o(t,n))||s);return r>3&&s&&Object.defineProperty(t,n,s),s},jr=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Ur=function(e,t){return function(n,i){t(n,i,e)}};const qr=new di;let zr=null;r.decorators||(r.decorators={}),["func","init","param","panel","editor","demo","app","appTreeBrowser","fileHandler","fileExporter","model","viewer","filter","cellRenderer","autostart","dashboard","folderViewer","semTypeDetector","packageSettingsEditor","functionAnalysis","converter","fileViewer","model","treeBrowser","polyfill"].forEach(e=>{r.decorators[e]||(r.decorators[e]=function(e){return function(e,t,n){}})});class Yr{static async getMonomerLibHelper(){return await Hn.getInstance()}static async initBio(){null==zr&&(zr=async function(){const e="Bio: _package.initBio()";qr.logger.debug(`${e}, start`);const t=window.performance.now(),n=await(0,Re.j)(),i=await qr.getProperties(),o=new hi(i);qr.properties=o;const s=await Hn.getInstance(),l=await(0,Pe.u)();l.explicit&&(l.explicit=[],await(0,Pe.E)(l)),await s.awaitLoaded(1/0),s.initialLoadCompleted||await s.loadMonomerLib(),s.loadMonomerSets();const c=s.getMonomerLib(),h=s.getMonomerSets(),d=window.performance.now();qr.logger.debug(`${e}, loading ET: ${d-t} ms`);const p=new Yi(s,n);qr.completeInit(p,c,h,n),qr.logger.debug(`${e}, end`),function(){const e=t=>{setTimeout(()=>{if(t.isDetached)return;const n=t.dataFrame;if(!n)return;const i=n.columns.bySemTypeAll(a.SEMTYPE.MACROMOLECULE);t.temp[ho]?.unsubscribe(),t.temp[ho]=a.debounce(u.merge(n.onColumnsAdded,n.onSemanticTypeDetected),200).subscribe(()=>e(t)),t.sub(t.temp[ho]);for(const e of i){const i=t.col(e.name);if(!i)continue;if(i.temp[uo])continue;i.temp[uo]=!0;let o=null;try{o=qr.seqHelper.getSeqHandler(e)}catch(t){console.warn(`Failed to get SeqHandler for column ${e.name}`);continue}if(!o)continue;if(o.isHelm()||o.alphabet===me.YI.UN)continue;let s=!!t.tableView&&Array.from(t.tableView.viewers).some(e=>"Sequence Position Statistics"===e.type);const l=(e,t)=>Number.isNaN(e)||null==e?t:e,c=()=>l(Math.max(Number.parseInt(e.getTag(me.gp.positionShift)??"0"),0),0)+1,h=()=>l(Number.parseInt(e.getTag(me.gp.selectedPosition)??"-2"),-2),d=()=>He.Jy.getFontSettings(e).fontWidth;let p=0,m=0;const f=e.categories;for(let e=0;e<f.length;e++){const t=f[e];t&&t.length>m&&(m=t.length,p=e)}const g=f[p],y=o.splitter(g),b=y?y.length:30,v={WITH_TITLE:58,WITH_WEBLOGO:107,WITH_BOTH:156};let w;w=e.length>1e5||b<50?v.WITH_TITLE:e.length>5e4?v.WITH_WEBLOGO:v.WITH_BOTH;let C=null,S=null;const A=a.debounce(u.merge(n.onFilterChanged,n.onDataChanged.pipe((0,k.filter)(t=>t?.args?.column===e))),100).subscribe(()=>{ao.clearAllCaches(),C&&(C.resetViewportTracking(),C.forceUpdate()),S&&(S.resetViewportTracking(),S.forceUpdate()),setTimeout(()=>{t.isDetached||t.invalidate()},50)});t.sub(A);const x=r=>{const l=[],u=new co(o,b,45,"default","Conservation");S=u,l.push({id:"conservation",track:u,priority:1});const p=new lo(o,b,45,"WebLogo");C=p,r&&(p.setMonomerLib(r),p.setBiotype(o.defaultBiotype||"HELM_AA")),p.setupDefaultTooltip(),l.push({id:"weblogo",track:p,priority:2});const m=new ro({canvas:t.overlay,headerHeight:w,totalPositions:b+1,onPositionChange:(n,i)=>{setTimeout(()=>{const o=c(),r=h();if(o!==i.start&&e.setTag(me.gp.positionShift,(i.start-1).toString()),r!==n&&(e.setTag(me.gp.selectedPosition,n.toString()),n>=0&&!s&&t.tableView&&R()(t.dataFrame?.columns.numerical).find(e=>!0))){s=!0;const n=t.tableView.addViewer("Sequence Position Statistics",{sequenceColumnName:e.name});t.tableView.dockManager.dock(n,a.DOCK_TYPE.DOWN,null,"Sequence Position Statistics",.4)}})},onHeaderHeightChange:e=>{t.isDetached||e<v.WITH_TITLE||setTimeout(()=>t.props.colHeaderHeight=e)}},i);m.setupTooltipHandling(),l.forEach(({id:e,track:t})=>{m.addTrack(e,t)}),m.setSelectionData(n,e,o),b>50&&(t.props.colHeaderHeight=w,setTimeout(()=>{t.isDetached||(i.width=400)},300)),t.sub(t.onCellRender.subscribe(t=>{const n=t.cell;if(!n||!n.isColHeader||n?.gridColumn?.name!==i?.name)return;const o=t.bounds;if(!o)return;m.headerHeight=o.height;const r=d();m.positionWidth=r+8;const s=c();m.draw(o.x,o.y,o.width,o.height,h(),s,t,e.name)}))};(0,we.pj)().then(e=>{const t=e.getMonomerLib();x(t)}).catch(e=>{r.shell.warning("Failed to initialize monomer library"),console.error("Failed to initialize monomer library:",e)})}},1e3)},t=(r.events.onViewerAdded.subscribe(t=>{if(!(t.args&&t.args.viewer instanceof a.Grid))return;const n=t.args.viewer;e(n)}),r.shell.tableViews);for(const n of t){const t=n?.grid;t&&e(t)}}()}()),await zr}static sequenceTooltip(e){const t=new gi(e,qr.seqHelper);return t.init().then(()=>{}).catch(e=>{const t=e instanceof Error?e.message:e.toString();r.shell.error(t)}),t}static async standardiseMonomerLibrary(e){return await async function(e){const t=JSON.parse(e);if(!t||!Array.isArray(t)||0===t.length)throw new Error("Invalid library format, expected an array of monomers");const n=(await en(t)).map(e=>({...e,lib:void 0,wem:void 0}));return JSON.stringify(n,null,2)}(e)}static async matchWithMonomerLibrary(e,t,n="PEPTIDE"){const i=await async function(e,t,n,i="PEPTIDE"){const o=n.duplicateMonomers?.[i]??{},r=a.Func.find({package:"Chem",name:"convertMoleculeNotation"})[0];if(!r)throw new Error("Function convertMoleculeNotation not found, please install Chem package");const s=n.getMonomerSymbolsByType(i).map(e=>n.getMonomer(i,e)).filter(e=>e&&(e.smiles||e.molfile)),l=await en(s),c=l.filter(e=>!!e.smiles).reduce((e,t)=>(e[t.smiles]={symbol:t.symbol,smiles:t.smiles,original:t.smiles,source:t.lib?.source},e),{}),u=l.map((e,t)=>({symbol:e.symbol,smiles:hn(e.smiles??"",e.rgroups??[]),original:e.smiles,source:s[t]?.lib?.source})).filter(e=>!!e?.smiles&&!e.smiles.includes("[*:")),h=a.Column.fromList(a.COLUMN_TYPE.STRING,"MonomerSmiles",u.map(e=>e.smiles));h.semType=a.SEMTYPE.MOLECULE;const d=await r.apply({molecule:h,targetNotation:a.chem.Notation.Smiles});if(!d||d.length!==h.length)throw new Error("Error canonicalizing monomer smiles");d.toList().forEach((e,t)=>u[t].smiles=e);const p=u.reduce((e,t)=>(e[t.smiles]=t,e),{}),m=e.col(t).toList().map(e=>{if(!e)return e;try{const t=e.includes("\n");return cn([],t?void 0:e,t?e:void 0)}catch(t){return e}}),f=a.Column.fromList(a.COLUMN_TYPE.STRING,"MoleculesOriginalCorrected",m);f.semType=a.SEMTYPE.MOLECULE,a.DataFrame.fromColumns([f]);const g=await r.apply({molecule:f,targetNotation:a.chem.Notation.Smiles});if(!g||g.length!==f.length)throw new Error("Error canonicalizing molecules");const y=g.toList(),b=e.clone(),v=b.columns.addNewString(b.columns.getUnusedName("Matched monomer smiles"));v.semType=a.SEMTYPE.MOLECULE;const w=b.columns.addNewString(b.columns.getUnusedName("Matched monomer symbol"));w.semType="Monomer";const C=b.columns.addNewString(b.columns.getUnusedName("Matched monomer source"));b.columns.setOrder([t,w.name,v.name,C.name]);for(let e=0;e<y.length;e++){const t=y[e];if(!t)continue;const n=p[t]??c[t];if(n){const t=n.symbol,i=(o[t]?.length??0)>0?o[t].map(e=>e?.lib?.source).filter(e=>!!e).join(", "):n.source??"",r=n.original??n.smiles;v.set(e,r,!1),w.set(e,t,!1),C.set(e,i,!1)}}return b}(e,t.name,qr.monomerLib,n);r.shell.addTableView(i)}static getBioLib(){return qr.monomerLib}static getSeqHandler(e){return qr.seqHelper.getSeqHandler(e)}static getRegionPanel(e){const t="getRegionTopMenu",n=a.Func.find({package:qr.name,name:t});if(1!==n.length)throw new Error(`Package '${qr.name}' func '${t}' not found`);const i=n[0].prepare({table:e.dataFrame,sequence:e});return new wi(i,qr.seqHelper).widget()}static async libraryPanel(e){return async function(){const e=s.label("Manage monomer libraries");return Fn()(e).addClass("d4-link-action"),e.onclick=async()=>await Un(),new a.Widget(e)}()}static GetRegionEditor(e){try{new wi(e,qr.seqHelper).dialog()}catch(e){const t=e instanceof Error?e.message:e.toString(),n=e instanceof Error?e.stack:void 0;r.shell.error(`Get region editor error: ${t}`),qr.logger.error(t,void 0,n)}}static SplitToMonomersEditor(e){const t=new ri;s.dialog({title:"Split to Monomers"}).add(t.paramsUI).onOK(async()=>e.func.prepare(t.funcParams).call(!0)).show()}static SequenceSpaceEditor(e){const t=new O({semtype:a.SEMTYPE.MACROMOLECULE}),n=s.dialog({title:"Sequence Space"}).add(t.getEditor()).onOK(async()=>{const n=t.getParams();return e.func.prepare({molecules:n.col,table:n.table,methodName:n.methodName,similarityMetric:n.similarityMetric,plotEmbeddings:n.plotEmbeddings,options:n.options,preprocessingFunction:n.preprocessingFunction,clusterEmbeddings:n.clusterEmbeddings}).call()});n.history(()=>({editorSettings:t.getStringInput()}),e=>t.applyStringInput(e.editorSettings)),n.show()}static SeqActivityCliffsEditor(e){const t=new xe({semtype:a.SEMTYPE.MACROMOLECULE}),n=s.dialog({title:"Activity Cliffs"}).add(t.getEditor()).onOK(async()=>{const n=t.getParams();return e.func.prepare({table:n.table,molecules:n.col,activities:n.activities,similarity:n.similarityThreshold,methodName:n.methodName,similarityMetric:n.similarityMetric,preprocessingFunction:n.preprocessingFunction,options:n.options}).call()});n.history(()=>({editorSettings:t.getStringInput()}),e=>t.applyStringInput(e.editorSettings)),n.show()}static customSequenceCellRenderer(){return new Ye}static fastaSequenceCellRenderer(){return new Ye}static separatorSequenceCellRenderer(){return new Ye}static bilnSequenceCellRenderer(){return new Ye}static refineNotationProviderForBiln(e,t,n){return"-"===n&&(!(!Object.keys(t.freq).some(e=>e.match(/^.+\(\d{1,2},\d{1,2}\)$/))&&!Object.keys(t.freq).some(e=>e.includes("[")||e.includes("]")))&&(e.setTag("aligned","SEQ"),e.setTag("alphabet","UN"),e.setTag(".alphabetIsMultichar","true"),e.meta.units=me.Hi.BILN,e.temp[$e.j.notationProvider]=new po(n,qr.seqHelper,e),!0))}static macroMolColumnPropertyPanel(e){return function(e){const t=Array.from(e.dataFrame.columns).filter(e=>e.semType===a.SEMTYPE.MOLECULE).map(e=>e.name);new Set(t).delete(e.name);let n=qr.properties?qr.properties.maxMonomerLength:4;if(ke.gp.maxMonomerLength in e.tags){const t=parseInt(e.getTag(ke.gp.maxMonomerLength));n=isNaN(t)?n:t}if(".mm.cellRenderer.maxMonomerLength"in e.temp){const t=parseInt(e.temp[".mm.cellRenderer.maxMonomerLength"]);n=isNaN(t)?n:t}const i=s.input.int("Max Monomer Length",{value:n,nullable:!0,min:1,max:50,step:1,onValueChanged:t=>{if(0==t)setTimeout(()=>{i.value=null},0);else{const n=t??"",i=null==n?"":n.toString();e.temp[".mm.cellRenderer.maxMonomerLength"]=i,e.temp[".mm.cellRenderer.settingsChanged"]=Ve.s.true,e.dataFrame.fireValuesChanged()}},tooltipText:"The max length of monomer symbol displayed without shortening, empty to no limit"});let o=qr.properties?qr.properties.fontSize:12;".mm.cellRenderer.fontSize"in e.temp&&e.temp[".mm.cellRenderer.fontSize"]&&!isNaN(e.temp[".mm.cellRenderer.fontSize"])&&(o=e.temp[".mm.cellRenderer.fontSize"]);const r=s.input.int("Font Size",{value:o,nullable:!0,min:1,max:50,step:1,onValueChanged:t=>{if(t&&t>0){const n=t??12;e.temp[".mm.cellRenderer.fontSize"]=n,e.temp[".mm.cellRenderer.settingsChanged"]=Ve.s.true,e.dataFrame.fireValuesChanged()}},tooltipText:"The font size of monomer symbol in sequence renderer"}),l=s.input.int("Monomer Margin",{value:e.temp[".mm.cellRenderer.gapLength"]??0,onValueChanged:t=>{e.temp[".mm.cellRenderer.gapLength"]=t,e.temp[".mm.cellRenderer.settingsChanged"]=Ve.s.true,e.dataFrame.fireValuesChanged()},tooltipText:"The size of margin between monomers (in pixels)"}),c=s.input.bool("Color Code",{value:null==e?.temp["color-code"]||e.temp["color-code"],onValueChanged:t=>{e.temp["color-code"]=t,e.dataFrame.fireValuesChanged()},tooltipText:"Color code"}),u=s.input.string("Reference Sequence",{value:null!=e?.temp["reference-sequence"]?e?.temp["reference-sequence"]:"",nullable:!0,onValueChanged:t=>{e.temp["reference-sequence"]=t,e.dataFrame.fireValuesChanged()},tooltipText:"Reference sequence is not empty, then the sequence will be render \nas a difference from the reference sequence"}),h=s.input.bool("Compare with current",{value:null==e?.temp["compare-with-current"]||e.temp["compare-with-current"],onValueChanged:t=>{e.temp["compare-with-current"]=t,e.dataFrame.fireValuesChanged()},tooltipText:'When on, all sequences get rendered in the "diff" mode'});let d=null;e.meta.units!==me.Hi.HELM&&(d=s.input.bool("Multiline Rendering",{value:"true"===e.getTag("renderMultiline"),onValueChanged:t=>{e.tags.renderMultiline=t?"true":"false",e.dataFrame.fireValuesChanged()},tooltipText:"Render sequences across multiple lines when they exceed cell width"}));const p=[r,i,l,u,c,h];d&&p.push(d);const m=s.inputs(p);return new a.Widget(m)}(e)}static compositionAnalysisWidget(e){return function(e,t,n){const i=s.div();i.classList.add("macromolecule-cell-comp-analysis-host");const o=e.cell.column.tags[me.gp.alphabet],r=o===me.YI.DNA||o===me.YI.RNA?De.o.NUCLEOTIDE:De.o.AA,l={},c=n.getSeqHandler(e.cell.column),u=e.cell.rowIndex,h=c.getSplitted(u),d={};R().count(0).take(h.length).filter(e=>!h.isGap(e)).forEach(e=>{let t=h.getCanonical(e);r===De.o.NUCLEOTIDE&&c.isHelm()&&"("===t[1]&&")"===t[t.length-2]&&(t=t.substring(2,t.length-2));const n=l[t]||0;if(l[t]=n+1,!d[t]&&h.graphInfo?.polymerTypes){const n=h.graphInfo.polymerTypes[e];d[t]=(0,Be.MD)(n)}});const p=(0,pi.F)(l,r,t,Object.keys(d).length?d:void 0);return Array.from(p.rows).forEach(e=>{const t=e.getElementsByClassName("macromolecule-cell-comp-analysis-bar")[0].style.backgroundColor;e.cells[0].style.color=t}),i.appendChild(p),new a.Widget(i)}(e,qr.monomerLib,qr.seqHelper)}static macromoleculeDifferenceCellRenderer(){return new Ze}static sequenceAlignment(e,t,n,i,o){const r=new dt(i,o,n,t);return"Local alignment"==e?r.smithWaterman():r.needlemanWunsch()}static webLogoViewer(){return new ot.oP}static vdRegionsViewer(){return new ct}static getRegion(e,t,n,i){return yi(e,t??null,n??null,i??null)}static async getRegionTopMenu(e,t,n,i,o){const s=yi(t,n??null,i??null,o??null);t.dataFrame.columns.add(s),await r.data.detectSemanticTypes(t.dataFrame)}static async activityCliffs(e,t,n,i,o,u,h,d,p){if(e.name!==r.shell.tv.dataFrame.name)return void r.shell.error(`Table ${e.name} is not a current table view`);if(!(0,ti.V)(t,"Activity Cliffs"))return;const m=_e(e),f={units:t.meta.units,aligned:t.getTag(me.gp.aligned),separator:t.getTag(me.gp.separator),alphabet:t.getTag(me.gp.alphabet)},g=u,y=t,b=async()=>await de(e,y,m,"Activity cliffs",n,i,g,o,{...d??{}},a.SEMTYPE.MACROMOLECULE,f,h,ft,gt,wt,void 0,p),v=o===c.c.UMAP?2e5:2e4,w=o===c.c.UMAP?5e3:2e3;if(e.rowCount>v)return void r.shell.warning(`Too many rows, maximum for sequence activity cliffs is ${v}`);const C=a.TaskBarProgressIndicator.create("Running sequence activity cliffs ..."),S=await new Promise((t,n)=>{e.rowCount>w&&!d?.[l.vb]?s.dialog().add(s.divText("Activity cliffs analysis might take several minutes.\n Do you want to continue?")).onOK(async()=>{b().then(e=>t(e)).catch(e=>n(e))}).onCancel(()=>{t(void 0)}).show():b().then(e=>t(e)).catch(e=>n(e))}).catch(e=>{const[t,n]=(0,Se.AP)(e);throw qr.logger.error(t,void 0,n),e}).finally(()=>{C.close()});return S?.props?.xColumnName&&S?.props?.yColumnName&&e.col(S.props.xColumnName)&&e.col(S.props.yColumnName)&&(e.col(S.props.xColumnName).set(0,e.col(S.props.xColumnName).get(0)),e.col(S.props.yColumnName).set(0,e.col(S.props.yColumnName).get(0))),S}static async macromoleculePreprocessingFunction(e,t,n=1,i=.6,o="Morgan"){if(e.semType!==a.SEMTYPE.MACROMOLECULE)return{entries:e.toList(),options:{}};const{seqList:r,options:s}=await pt(e,t,o,n,i);return{entries:r,options:s}}static async helmPreprocessingFunction(e,t){e.version!==e.temp["last-invalidated-version"]&&await(0,mt.BQ)(e,qr.seqHelper,!1);const n=e.temp["monomeric-mols"],i=await r.functions.call("Chem:getMorganFingerprints",{molColumn:n}),o=new Array(i.length).fill(null);for(let e=0;e<i.length;e++){if(i.isNone(e)||!i.get(e))continue;const t=i.get(e);o[e]=j.A.fromUint32Array(t.length,new Uint32Array(t.getBuffer().buffer))}return{entries:o,options:{}}}static async sequenceSpaceTopMenu(e,t,n,i,o,s,c,u,h){if(e.name!==r.shell.tv.dataFrame.name)return void r.shell.error(`Table ${e.name} is not a current table view`);const d=r.shell.tv.dataFrame==e?r.shell.tv:void 0;return(0,ti.V)(t,"Sequence Space")?(s||(s=a.Func.find({name:"macromoleculePreprocessingFunction",package:"Bio"})[0]),c??={},await Le(e,[t],n,[i],[1],[s],"MANHATTAN",o,u??!1,{...c,preprocessingFuncArgs:[c.preprocessingFuncArgs??{}]},{fastRowCount:1e4,scatterPlotName:"Sequence space",bypassLargeDataWarning:c?.[l.vb],tableView:d})):void 0}static async moleculesToHelmTopMenu(e,t){const n=qr.monomerLib,i=JSON.stringify(n.toJSON());await fo.molToHelmConverterPy(e,t,i);const o=e.columns.toList().find(e=>e.name.toLowerCase().includes("regenerated sequence")&&e.semType!==a.SEMTYPE.MACROMOLECULE);o&&(o.meta.units=me.Hi.HELM,o.semType=a.SEMTYPE.MACROMOLECULE,o.setTag("cell.renderer","helm"))}static async toAtomicLevel(e,t,n,i=!1){const o=a.TaskBarProgressIndicator.create("Converting to atomic level ...");try{await zr;const o=t.temp[".mm.cellRenderer.overriddenLibrary"]??qr.monomerLib,r=qr.seqHelper,s=qr.rdKitModule;await(0,Ci.V)(e,t,n,i,o,r,s)}finally{o.close()}}static async toAtomicLevelAction(e){if(!e?.dataFrame)throw new Error("Sequence column is not found or its data frame is not empty");const t=a.Func.find({name:"toAtomicLevel",package:"Bio"})[0];if(!t)throw new Error("To Atomic level Function not found");t.prepare({table:e.dataFrame,seqCol:e}).edit()}static async toAtomicLevelPanel(e){return async function(e){const t=await Ki(e);if(t.errorText||!t.mol)return a.Widget.fromRoot(s.divText(t.errorText??"No structure generated"));try{const e=a.SemanticValue.fromValueType(t.mol,a.SEMTYPE.MOLECULE),n=s.panels.infoPanel(e);let i=null;n&&(i=a.Widget.fromRoot(n.root));const o=r.chem.drawMolecule(t.mol,300,300,!1);return o.style.cursor="pointer",s.tooltip.bind(o,"Click to expand"),o.onclick=()=>{const e=window.innerWidth-200,n=window.innerHeight-200,i=r.chem.drawMolecule(t.mol,e,n,!1);s.dialog({title:"Molecule"}).add(i).showModal(!0)},i&&i.root.prepend(o),i??a.Widget.fromRoot(o)}catch(e){qr.logger.error(e)}return a.Widget.fromRoot(s.divText("No structure generated"))}(e)}static async sequence3dStructureWidget(e){return async function(e){const t=a.TaskBarProgressIndicator.create("Creating 3D view");let n,i="";try{await(a.Func.find({name:"getPdbHelper"})[0]?.apply({}));try{const o=await Ki(e);if(o.errorText||!o.mol)return n=s.divText(o.errorText??"No structure generated"),t.close(),new a.Widget(n);const l=o.mol;i=await r.functions.call("Bio:Embed",{molecule:l});const c=Mi.Molecule.fromMolfile(i);c?i=c.toMolfile():console.warn("Failed to convert molv3 to molv2")}catch(e){console.warn(e)}try{i=i.replaceAll("\\n","\n");const e=new Blob([i],{type:"text/plain"}),t=s.div([],{classes:"d4-ngl-viewer",id:"ngl-3d-host"});t.style.setProperty("height","100%","important");const o=new NGL.Stage(t,{backgroundColor:"white"});o.loadFile(e,{ext:"sdf"}).then(function(e){o.setSize(300,300),e.addRepresentation("ball+stick"),e.autoView()}),n=s.div([t],{style:{aspectRatio:"1"}})}catch(e){n=s.divText("Couldn't get 3D structure")}}catch(e){n=s.divText("Couldn't get 3D structure")}return t.close(),new a.Widget(n)}(e)}static multipleSequenceAlignmentDialog(){(0,ii.D)({},qr.seqHelper).catch(e=>{const[t,n]=(0,Se.AP)(e);if(e instanceof ni.Ap)return r.shell.warning(e.element),void qr.logger.warning(t);r.shell.error(t),qr.logger.error(t,void 0,n)})}static async alignSequences(e=null,t=null,n){return(0,ii.D)({col:e,clustersCol:t,...n},qr.seqHelper)}static async compositionAnalysis(){const e=r.shell.tv,t=e.dataFrame.columns.toList().filter(e=>e.semType==a.SEMTYPE.MACROMOLECULE&&(qr.seqHelper.getSeqHandler(e),!0)),n=async t=>{if(!(0,ti.V)(t,"Composition"))return;const n=e.addViewer("WebLogo",{sequenceColumnName:t.name});r.shell.tv.dockManager.dock(n,a.DOCK_TYPE.DOWN,null,"Composition analysis",.25)};let i=null;if(0!=t.length){if(t.length>1){const e=t.map(e=>e.name),i=t.find(e=>qr.seqHelper.getSeqHandler(e).isMsa()),o=s.input.choice("Column",{value:i?i.name:e[0],items:e});s.dialog({title:"Composition Analysis",helpUrl:"https://datagrok.ai/help/datagrok/solutions/domains/bio/#sequence-composition"}).add(s.div([o])).onOK(async()=>{const e=t.find(e=>e.name==o.value)??null;e&&await n(e)}).show()}else i=t[0];i&&await n(i)}else r.shell.error("Current table does not contain sequences")}static importFasta(e){return new fe.m(e).importFasta()}static importBam(e){return console.log(e),[]}static convertDialog(){const e=(0,Oe.me)()[0];(0,Et.C)(e,qr.seqHelper)}static convertColumnAction(e){(0,Et.C)(e,qr.seqHelper)}static monomerCellRenderer(){return new ci}static async testDetectMacromolecule(e){const t=a.TaskBarProgressIndicator.create("Test detectMacromolecule..."),n=(await r.dapi.files.list(e,!0,"")).filter(e=>e.fileName.endsWith(".csv"));let i=0;const o=[];for(const s of n)try{const t=await r.dapi.files.readAsText(e+s.fullPath),n=a.DataFrame.fromCsv(t);for(const e of n.columns)await r.functions.call("Bio:detectMacromolecule",{col:e})===a.SEMTYPE.MACROMOLECULE&&o.push({file:s.path,result:"detected",column:e.name,message:`units: ${e.meta.units}`})}catch(e){o.push({file:s.path,result:"error",column:null,message:e instanceof Error?e.message:e.toString()})}finally{i+=1,t.update(100*i/n.length,`Test ${s.fileName}`)}r.shell.info("Test Demo:Files for detectMacromolecule finished."),t.close();const s=a.DataFrame.fromObjects(o);return s.name=`datasets_detectMacromolecule_${e}`,s}static async splitToMonomersTopMenu(e,t){return await async function(e,t){if(await(0,et.cb)(10),!(0,ti.V)(t,"Sequence space"))return e;const n=ye(t,qr.seqHelper);n.name="splitToMonomers";const i=t.dataFrame;for(const e of n.columns)e.semType=Ue.uF.MONOMER,e.setTag(ve.gp.alphabet,t.getTag(ve.gp.alphabet));const o=/(\d+)(?: \((\d+)\))?/,s=e=>{o.lastIndex=0;const t=e.match(o);return t?`${t[1]} (${parseInt(t[2]??"0")+1})`:e};for(let e=0;e<n.columns.length;e++){const o=n.columns.byIndex(e);o.semType=Ue.uF.MONOMER,o.setTag(ve.gp.alphabet,t.getTag(ve.gp.alphabet));const r=100;let a=0;for(;i.columns.byName(o.name)&&a<r;)o.name=s(o.name),a++;i.columns.add(o)}await r.data.detectSemanticTypes(i);for(let e=0;e<n.columns.length;e++){const t=n.columns.byIndex(e);t.setTag(a.TAGS.CELL_RENDERER,"Monomer"),t.setTag(".use-as-filter","false")}return i}(e,t)}static getHelmMonomers(e){return qr.seqHelper.getSeqMonomers(e)}static similaritySearchViewer(){return new xt(qr.seqHelper)}static similaritySearchTopMenu(){const e=r.shell.v,t=e.addViewer("Sequence Similarity Search");e.dockManager.dock(t,"down")}static diversitySearchViewer(){return new Mt(qr.seqHelper)}static diversitySearchTopMenu(){const e=r.shell.v,t=e.addViewer("Sequence Diversity Search");e.dockManager.dock(t,"down")}static searchSubsequenceEditor(e){const t=(0,Oe.me)();1===t.length?e.func.prepare({macromolecules:t[0]}).call(!0):new mt.a7(t,qr.seqHelper)}static SubsequenceSearchTopMenu(e){r.shell.tv.getFiltersGroup({createDefaultFilters:!1}).updateOrAdd({type:"Bio:bioSubstructureFilter",column:e.name,columnName:e.name}),r.shell.tv.grid.scrollToCell(e,0)}static async sequenceIdentityScoring(e,t,n){const i=qr.seqHelper;return Si(e,t,n,be.IDENTITY,i)}static async sequenceSimilarityScoring(e,t,n){const i=qr.seqHelper;return Si(e,t,n,be.SIMILARITY,i)}static async manageMonomerLibraries(){Un()}static async manageLibrariesView(){await qn()}static async manageMonomersView(){const e=await nn.getInstance();await e.getViewRoot()}static async manageMonomerLibrariesView(){return await qn(!1)}static async manageMonomerLibrariesViewTreeBrowser(e){(await(await Hn.getInstance()).getAvaliableLibraryNames()).forEach(t=>{const n=t.endsWith(".json")?t.substring(0,t.length-5):t;e.item(n).onSelected.subscribe(async()=>{const e=await nn.getInstance();await e.getViewRoot(t,!0),e.resetCurrentRowFollowing()})})}static saveAsFasta(){(0,_t.TE)()}static bioSubstructureFilter(){return new It._i(qr.seqHelper,qr.logger)}static bioSubstructureFilterTest(){return new It._i(qr.seqHelper,qr.logger)}static async webLogoLargeApp(){const e=a.TaskBarProgressIndicator.create("WebLogo");try{const e=new URLSearchParams(window.location.search),t=new oi(e,"webLogoLargeApp"),n=await qr.files.readCsv("data/sample_PT_100000x5.csv");await r.data.detectSemanticTypes(n),await t.init(n)}finally{e.close()}}static async webLogoAggApp(){const e=a.TaskBarProgressIndicator.create("WebLogo ...");try{const e=new URLSearchParams(window.location.search),t=new oi(e,"webLogoAggApp"),n=await qr.files.readCsv("samples/FASTA_PT_activity.csv");await r.data.detectSemanticTypes(n),await t.init(n)}finally{e.close()}}static async getRegionApp(){const e=a.TaskBarProgressIndicator.create("getRegion ...");try{const e=new URLSearchParams(window.location.search),t=new vi(e,"getRegionApp");await t.init()}finally{e.close()}}static async getRegionHelmApp(){const e=a.TaskBarProgressIndicator.create("getRegion ...");try{const e=new URLSearchParams(window.location.search),t=await qr.files.readCsv("samples/HELM_empty_vals.csv"),n=new vi(e,"getRegionHelmApp");await n.init({df:t,colName:"HELM"})}finally{e.close()}}static longSeqTableSeparator(){const e=a.DataFrame.fromColumns((0,Ne.dW)());r.shell.addTableView(e)}static longSeqTableFasta(){const e=a.DataFrame.fromColumns([(0,Ne.Hx)(qr.seqHelper,me.Hi.FASTA)]);r.shell.addTableView(e)}static longSeqTableHelm(){const e=a.DataFrame.fromColumns([(0,Ne.Hx)(qr.seqHelper,me.Hi.HELM)]);r.shell.addTableView(e)}static addCopyMenu(e,t){!function(e,t,n){const i=Object.values(me.Hi).filter(e=>e!==me.Hi.CUSTOM);t.group("Copy").items(i,t=>{const i=e.column,o=e.rowIndex,s=n.getSeqHandler(i),a=t===me.Hi.SEPARATOR?qr.properties.defaultSeparator??"-":void 0,l=s.getJoiner({notation:t,separator:a})(s.getSplitted(o));navigator.clipboard?(navigator.clipboard.writeText(l),r.shell.info(`Value of notation '${t}' copied to clipboard`)):r.shell.warning("The clipboard functionality requires a secure origin — either HTTPS or localhost")})}(e,t,qr.seqHelper)}static async demoBioSimilarityDiversity(){await async function(){const e=await qr.files.readCsv("samples/peptides-non-natural.csv");e.name="Similarity and Diversity Demo",e.col("activity").setTag("format","3 significant digits"),e.col("sequence").temp[".mm.cellRenderer.maxMonomerLength"]=4;const t=r.shell.addTableView(e);await e.meta.detectSemanticTypes(),await r.data.detectSemanticTypes(e);const n=t.addViewer("Sequence Similarity Search",{limit:20}),i=t.dockManager.dock(n,a.DOCK_TYPE.RIGHT,null,"Similarity search",.45);(0,Oe.Kd)(t.grid,"sequence",500,30);const o=t.addViewer("Sequence Diversity Search",{limit:20});t.dockManager.dock(o,a.DOCK_TYPE.DOWN,i,"Diversity search",.4),r.functions.call("Dendrogram:HierarchicalClustering",{df:r.shell.t,colNameList:["sequence"],distance:"euclidian",linkage:"complete"})}()}static async demoBioSequenceSpace(){await async function(){const e=await r.functions.eval("Bio:SeqSpaceDemo"),t=await r.dapi.projects.find(e.id);await t.open(),r.shell.windows.help.showHelp("/help/datagrok/solutions/domains/bio/bio.md#sequence-space")}()}static async demoBioActivityCliffs(){await async function(){const e=await qr.files.readCsv("tests/helm_cyclic_cliffs.csv");e.name="Activity Cliffs Demo",await r.data.detectSemanticTypes(e),await e.meta.detectSemanticTypes();const t=r.shell.addTableView(e);s.setUpdateIndicator(t.root,!0);try{const n=a.Func.find({name:"macromoleculePreprocessingFunction",package:"Bio"})[0],i=await Yr.activityCliffs(e,e.getCol("Sequence"),e.getCol("Activity"),96,c.c.UMAP,pe.Z.MONOMER_CHEMICAL_DISTANCE,n,{},!0);t.dockManager.dock(i,a.DOCK_TYPE.RIGHT,null,"Activity Cliffs",.65),await a.delay(100),Fn()(i.root).find("button.scatter_plot_link,cliffs_grid").get()[0].click(),await a.delay(100),t.grid.props.rowHeight=180,t.grid.col("sequence")&&(t.grid.col("sequence").width=300),t.grid.col("structure")&&(t.grid.col("structure").width=300);const o=Array.from(t.viewers).find(e=>e!==t.grid&&e.type===a.VIEWER.GRID);o&&(o.props.rowHeight=40,o.col("seq_diff").width=600,t.dockManager.dock(o,a.DOCK_TYPE.DOWN,null,"Cliffs",.35),t.dockManager.dock(i,a.DOCK_TYPE.RIGHT,null,"Activity Cliffs",.55))}catch(e){!function(e){const t=e instanceof Error?e.message:e.toString(),n=e instanceof Error?e.stack:void 0;r.shell.error(t),qr.logger.error(e.message,void 0,n)}(e)}finally{s.setUpdateIndicator(t.root,!1)}r.shell.windows.help.showHelp("/help/datagrok/solutions/domains/bio/bio.md#activity-cliffs")}()}static async demoBioAtomicLevel(){await async function(){const e=await qr.files.readCsv("samples/HELM_BI_CYCLIC.csv");e.name="To Atomic Level",await e.meta.detectSemanticTypes(),await r.data.detectSemanticTypes(e);const t=r.shell.addTableView(e),n=e.col("HELM");await Yr.toAtomicLevel(e,n,!0,!1),(0,Oe.Kd)(t.grid,"molfile(HELM)",500,300,!0),(0,Oe.Kd)(t.grid,"HELM",500,void 0,!0),r.shell.info("Hover over monomers in HELM column to highlight them in molecular structure.",{timeout:10}),r.shell.windows.help.showHelp("/help/datagrok/solutions/domains/bio/bio.md#convert-to-atomic-level")}()}static async sdfToJsonLib(e){const t=function(e){const t=[];for(let n=0;n<e.rowCount;n++){const i={};Object.keys(ge.Ec).forEach(t=>{if("symbol"===t){const o=e.get(ge.Ec[t],n);i[t]="."===o?e.get(ge.yw,n):o}else if("rgroups"===t){const o=e.get(ge.Ec[t],n).split("\n"),r=[];o.forEach(e=>{const t={},n=e.substring(e.lastIndexOf("]")+1),i=e.match(/\[R(\d+)\]/)[1];t.capGroupSmiles="H"===n?`[*:${i}][H]`:`O[*:${i}]`,t.alternateId="H"===n?`R${i}-H`:`R${i}-OH`,t.capGroupName="H"===n?"H":"OH",t.label=`R${i}`,r.push(t)}),i[t]=r}else ge.Ec[t]&&(i[t]=e.get(ge.Ec[t],n))}),i.author??(i.author=""),i.id??(i.id=0),i.smiles??(i.smiles=""),i.monomerType??(i.monomerType="Backbone"),i.createDate??(i.createDate=null),t.push(i)}return t}(e),n=JSON.stringify(t);a.Utils.download(`${e.name}.json`,n)}static async seq2atomic(e,t){if(!e.trim())return"";try{const n=a.Column.fromList(a.COLUMN_TYPE.STRING,"helm",[e]),i=a.DataFrame.fromColumns([n]),o=await r.functions.call("Bio:detectMacromolecule",{col:n});o&&(n.semType=o);const s=(await Yr.getMonomerLibHelper()).getMonomerLib(),l=qr.seqHelper,c=await(0,Re.j)(),u=(await(0,Ci.V)(i,n,t,!1,s,l,c))?.molCol?.get(0);return u??void 0}catch(e){const[t,n]=(0,Se.AP)(e);throw qr.logger.error(t,void 0,n),e}}static async seqIdentity(e,t){if(!e.trim())return null;try{const n=a.Column.fromList(a.COLUMN_TYPE.STRING,"seq",[e]),i=a.DataFrame.fromColumns([n]);if(!await r.functions.call("Bio:detectMacromolecule",{col:n}))throw new Error("Macromolecule required");return(await Si(i,n,t,be.IDENTITY,qr.seqHelper)).get(0)}catch(e){const[t,n]=(0,Se.AP)(e);throw qr.logger.error(t,void 0,n),e}}static async detectMacromoleculeProbe(e,t="",n=100){const i=await e.readAsString();await async function(e,t,n){const i=a.TaskBarProgressIndicator.create("detectMacromolecule probe ...");try{let o=0;const s=await r.functions.call("Bio:detectMacromoleculeEnableStore");let l=0;for(let c=0;c<n;++c){const u=a.DataFrame.fromCsv(e),h=t?u.getCol(t):u.columns.byIndex(0);await r.functions.call("Bio:detectMacromolecule",{col:h})!==a.SEMTYPE.MACROMOLECULE&&(++l,console.warn(`Reject reason: ${s.last.rejectReason}`));const d=c/n;d-o>=.1&&(o=d,i.update(100*d,`detectMacromolecule probe ${l}/${c}/${n} ...`),await(0,et.cb)(0))}l>0?r.shell.warning(`detectMacromolecule failed ${l} / ${n}`):r.shell.info(`detectMacromolecule success ${n}`)}finally{i.close()}}(i,t,n)}static async getSeqHelper(){return await Yr.initBio(),qr.seqHelper}static async getMolFromHelm(e,t,n=!0){return async function(e,t,n=!0,i){const o=qr.seqHelper,r=(await o.getHelmToMolfileConverter(i)).convertToRdKitBeautifiedMolfileColumn(t,n,qr.rdKitModule,i);return r.semType=a.SEMTYPE.MOLECULE,r}(0,t,n,qr.monomerLib)}}Wr([r.decorators.func({description:"Returns an instance of the monomer library helper",outputs:[{type:"object",name:"result"}]}),jr("design:type",Function),jr("design:paramtypes",[]),jr("design:returntype",Promise)],Yr,"getMonomerLibHelper",null),Wr([r.decorators.init({}),jr("design:type",Function),jr("design:paramtypes",[]),jr("design:returntype",Promise)],Yr,"initBio",null),Wr([r.decorators.func({tags:["tooltip"]}),Ur(0,r.decorators.param({options:{semType:"Macromolecule"}})),jr("design:type",Function),jr("design:paramtypes",[a.Column]),jr("design:returntype",a.Widget)],Yr,"sequenceTooltip",null),Wr([r.decorators.func({}),jr("design:type",Function),jr("design:paramtypes",[String]),jr("design:returntype",Promise)],Yr,"standardiseMonomerLibrary",null),Wr([r.decorators.func({"top-menu":"Bio | Manage | Match with Monomer Library...",description:"Matches molecules in a column with monomers from the selected library(s)"}),Ur(1,r.decorators.param({type:"column",options:{semType:"Molecule"}})),Ur(2,r.decorators.param({type:"string",options:{choices:["PEPTIDE","RNA","CHEM"],initialValue:"PEPTIDE",caption:"Polymer Type"}})),jr("design:type",Function),jr("design:paramtypes",[a.DataFrame,a.Column,String]),jr("design:returntype",Promise)],Yr,"matchWithMonomerLibrary",null),Wr([r.decorators.func({outputs:[{type:"object",name:"monomerLib"}]}),jr("design:type",Function),jr("design:paramtypes",[]),jr("design:returntype",Object)],Yr,"getBioLib",null),Wr([r.decorators.func({outputs:[{type:"object",name:"result"}]}),Ur(0,r.decorators.param({type:"column",options:{semType:"Macromolecule"}})),jr("design:type",Function),jr("design:paramtypes",[a.Column]),jr("design:returntype",Object)],Yr,"getSeqHandler",null),Wr([r.decorators.panel({name:"Bioinformatics | Get Region",description:"Creates a new column with sequences of the region between start and end"}),Ur(0,r.decorators.param({type:"column",options:{semType:"Macromolecule"}})),jr("design:type",Function),jr("design:paramtypes",[a.Column]),jr("design:returntype",a.Widget)],Yr,"getRegionPanel",null),Wr([r.decorators.panel({name:"Bioinformatics | Manage Monomer Libraries",tags:["exclude-actions-panel"]}),Ur(0,r.decorators.param({name:"seqColumn",options:{semType:"Macromolecule"}})),jr("design:type",Function),jr("design:paramtypes",[a.Column]),jr("design:returntype",Promise)],Yr,"libraryPanel",null),Wr([r.decorators.editor({}),jr("design:type",Function),jr("design:paramtypes",[a.FuncCall]),jr("design:returntype",void 0)],Yr,"GetRegionEditor",null),Wr([r.decorators.editor({}),jr("design:type",Function),jr("design:paramtypes",[a.FuncCall]),jr("design:returntype",void 0)],Yr,"SplitToMonomersEditor",null),Wr([r.decorators.editor({}),jr("design:type",Function),jr("design:paramtypes",[a.FuncCall]),jr("design:returntype",void 0)],Yr,"SequenceSpaceEditor",null),Wr([r.decorators.editor({}),jr("design:type",Function),jr("design:paramtypes",[a.FuncCall]),jr("design:returntype",void 0)],Yr,"SeqActivityCliffsEditor",null),Wr([r.decorators.func({name:"customSequenceCellRenderer",tags:["cellRenderer"],meta:{cellType:"sequence",columnTags:"quality=Macromolecule, units=custom"},outputs:[{type:"grid_cell_renderer",name:"result"}]}),jr("design:type",Function),jr("design:paramtypes",[]),jr("design:returntype",a.GridCellRenderer)],Yr,"customSequenceCellRenderer",null),Wr([r.decorators.func({name:"fastaSequenceCellRenderer",tags:["cellRenderer"],meta:{cellType:"sequence",columnTags:"quality=Macromolecule, units=fasta"},outputs:[{type:"grid_cell_renderer",name:"result"}]}),jr("design:type",Function),jr("design:paramtypes",[]),jr("design:returntype",Ye)],Yr,"fastaSequenceCellRenderer",null),Wr([r.decorators.func({name:"separatorSequenceCellRenderer",tags:["cellRenderer"],meta:{cellType:"sequence",columnTags:"quality=Macromolecule, units=separator"},outputs:[{type:"grid_cell_renderer",name:"result"}]}),jr("design:type",Function),jr("design:paramtypes",[]),jr("design:returntype",Ye)],Yr,"separatorSequenceCellRenderer",null),Wr([r.decorators.func({name:"bilnSequenceCellRenderer",tags:["cellRenderer"],meta:{cellType:"sequence",columnTags:"quality=Macromolecule, units=biln"},outputs:[{type:"grid_cell_renderer",name:"result"}]}),jr("design:type",Function),jr("design:paramtypes",[]),jr("design:returntype",Ye)],Yr,"bilnSequenceCellRenderer",null),Wr([r.decorators.func({name:"refineNotationProviderForBiln",tags:["notationRefiner"],outputs:[{type:"bool",name:"result"}]}),Ur(0,r.decorators.param({type:"column"})),Ur(1,r.decorators.param({type:"object"})),Ur(2,r.decorators.param({type:"string",options:{nullable:!0,optional:!0}})),jr("design:type",Function),jr("design:paramtypes",[a.Column,Object,Object]),jr("design:returntype",Boolean)],Yr,"refineNotationProviderForBiln",null),Wr([r.decorators.panel({name:"Bioinformatics | Sequence Renderer"}),Ur(0,r.decorators.param({options:{semType:"Macromolecule"}})),jr("design:type",Function),jr("design:paramtypes",[a.Column]),jr("design:returntype",a.Widget)],Yr,"macroMolColumnPropertyPanel",null),Wr([r.decorators.panel({name:"Composition analysis",tags:["bio","widgets"]}),Ur(0,r.decorators.param({options:{semType:"Macromolecule"}})),jr("design:type",Function),jr("design:paramtypes",[a.SemanticValue]),jr("design:returntype",a.Widget)],Yr,"compositionAnalysisWidget",null),Wr([r.decorators.func({name:"MacromoleculeDifferenceCellRenderer",tags:["cellRenderer"],meta:{cellType:"MacromoleculeDifference",columnTags:"quality=MacromoleculeDifference"},outputs:[{type:"grid_cell_renderer",name:"result"}]}),jr("design:type",Function),jr("design:paramtypes",[]),jr("design:returntype",Ze)],Yr,"macromoleculeDifferenceCellRenderer",null),Wr([r.decorators.func({outputs:[{type:"object",name:"result"}]}),Ur(0,r.decorators.param({options:{choices:["Local alignment","Global alignment"]}})),Ur(1,r.decorators.param({options:{choices:["AUTO","NUCLEOTIDES","BLOSUM45","BLOSUM50","BLOSUM62","BLOSUM80","BLOSUM90","PAM30","PAM70","PAM250","SCHNEIDER","TRANS"]}})),jr("design:type",Function),jr("design:paramtypes",[String,String,Number,String,String]),jr("design:returntype",void 0)],Yr,"sequenceAlignment",null),Wr([r.decorators.panel({name:"WebLogo",description:"WebLogo",tags:["viewer"],meta:{icon:"files/icons/weblogo-viewer.svg"},outputs:[{type:"viewer",name:"result"}]}),jr("design:type",Function),jr("design:paramtypes",[]),jr("design:returntype",void 0)],Yr,"webLogoViewer",null),Wr([r.decorators.panel({name:"VdRegions",description:"V-Domain regions viewer",tags:["viewer"],meta:{icon:"files/icons/vdregions-viewer.svg"},outputs:[{type:"viewer",name:"result"}]}),jr("design:type",Function),jr("design:paramtypes",[]),jr("design:returntype",void 0)],Yr,"vdRegionsViewer",null),Wr([r.decorators.func({name:"getRegion",description:"Gets a new column with sequences of the region between start and end"}),Ur(0,r.decorators.param({type:"column"})),Ur(1,r.decorators.param({type:"string",options:{optional:!0}})),Ur(2,r.decorators.param({type:"string",options:{optional:!0}})),Ur(3,r.decorators.param({type:"string",options:{optional:!0,description:"Name of the column to be created"}})),jr("design:type",Function),jr("design:paramtypes",[a.Column,Object,Object,Object]),jr("design:returntype",a.Column)],Yr,"getRegion",null),Wr([r.decorators.func({name:"Get Region Top Menu",description:"Get sequences for a region specified from a Macromolecule","top-menu":"Bio | Calculate | Get Region...",editor:"Bio:GetRegionEditor"}),Ur(0,r.decorators.param({options:{description:"Input data table"}})),Ur(1,r.decorators.param({options:{semType:"Macromolecule",description:"Sequence column"}})),Ur(2,r.decorators.param({type:"string",options:{optional:!0,description:"Region start position name"}})),Ur(3,r.decorators.param({type:"string",options:{optional:!0,description:"Region end position name"}})),Ur(4,r.decorators.param({type:"string",options:{optional:!0,description:"Region column name"}})),jr("design:type",Function),jr("design:paramtypes",[a.DataFrame,a.Column,Object,Object,Object]),jr("design:returntype",Promise)],Yr,"getRegionTopMenu",null),Wr([r.decorators.func({name:"Sequence Activity Cliffs",description:"Detects pairs of molecules with similar structure and significant difference in any given property","top-menu":"Bio | Analyze | Activity Cliffs...",editor:"Bio:SeqActivityCliffsEditor",outputs:[]}),Ur(0,r.decorators.param({options:{description:"Input data table"}})),Ur(1,r.decorators.param({type:"string",options:{semType:"Macromolecule",description:"Input data table"}})),Ur(3,r.decorators.param({options:{initialValue:"80",description:"Similarity cutoff"}})),Ur(4,r.decorators.param({type:"string",options:{choices:["UMAP","t-SNE"]}})),Ur(5,r.decorators.param({type:"string",options:{choices:["Hamming","Levenshtein","Monomer chemical distance"]}})),Ur(6,r.decorators.param({type:"func"})),Ur(7,r.decorators.param({type:"object",options:{optional:!0}})),Ur(8,r.decorators.param({options:{optional:!0}})),jr("design:type",Function),jr("design:paramtypes",[a.DataFrame,a.Column,a.Column,Number,String,String,a.Func,Object,Boolean]),jr("design:returntype",Promise)],Yr,"activityCliffs",null),Wr([r.decorators.func({name:"Encode Sequences",tags:["dim-red-preprocessing-function"],meta:{supportedSemTypes:"Macromolecule",supportedTypes:"string",supportedDistanceFunctions:"Hamming,Levenshtein,Monomer chemical distance,Needlemann-Wunsch"},outputs:[{type:"object",name:"result"}]}),Ur(0,r.decorators.param({options:{semType:"Macromolecule"}})),Ur(1,r.decorators.param({type:"string"})),Ur(2,r.decorators.param({options:{initialValue:"1",caption:"Gap open penalty",optional:!0}})),Ur(3,r.decorators.param({options:{initialValue:"0.6",caption:"Gap extension penalty",optional:!0}})),Ur(4,r.decorators.param({options:{caption:"Fingerprint type",initialValue:"Morgan",choices:["Morgan","RDKit","Pattern","AtomPair","MACCS","TopologicalTorsion"],optional:!0}})),jr("design:type",Function),jr("design:paramtypes",[a.Column,String,Number,Number,String]),jr("design:returntype",Promise)],Yr,"macromoleculePreprocessingFunction",null),Wr([r.decorators.func({name:"Helm Fingerprints",meta:{supportedSemTypes:"Macromolecule",supportedTypes:"string",supportedUnits:"helm",supportedDistanceFunctions:"Tanimoto,Asymmetric,Cosine,Sokal"},outputs:[{type:"object",name:"result"}]}),Ur(0,r.decorators.param({type:"column",options:{semType:"Macromolecule"}})),Ur(1,r.decorators.param({type:"string"})),jr("design:type",Function),jr("design:paramtypes",[a.Column,String]),jr("design:returntype",Promise)],Yr,"helmPreprocessingFunction",null),Wr([r.decorators.func({name:"Sequence Space",description:"Creates 2D sequence space with projected sequences by pairwise distance","top-menu":"Bio | Analyze | Sequence Space...",editor:"Bio:SequenceSpaceEditor",outputs:[]}),Ur(1,r.decorators.param({options:{semType:"Macromolecule"}})),Ur(2,r.decorators.param({type:"string",options:{choices:["UMAP","t-SNE"]}})),Ur(3,r.decorators.param({type:"string",options:{choices:["Hamming","Levenshtein","Monomer chemical distance"]}})),Ur(4,r.decorators.param({options:{initialValue:"true"}})),Ur(5,r.decorators.param({type:"func",options:{optional:!0}})),Ur(6,r.decorators.param({type:"object",options:{optional:!0}})),Ur(7,r.decorators.param({options:{optional:!0,initialValue:"true"}})),Ur(8,r.decorators.param({options:{optional:!0}})),jr("design:type",Function),jr("design:paramtypes",[a.DataFrame,a.Column,String,String,Boolean,a.Func,Object,Boolean,Boolean]),jr("design:returntype",Promise)],Yr,"sequenceSpaceTopMenu",null),Wr([r.decorators.func({name:"Molecules to HELM","top-menu":"Bio | Transform | Molecules to HELM...",description:"Converts Peptide molecules to HELM notation by matching with monomer library"}),Ur(0,r.decorators.param({name:"table",options:{description:"Input data table"}})),Ur(1,r.decorators.param({name:"molecules",options:{semType:"Molecule",description:"Molecule column"}})),jr("design:type",Function),jr("design:paramtypes",[a.DataFrame,a.Column]),jr("design:returntype",Promise)],Yr,"moleculesToHelmTopMenu",null),Wr([r.decorators.func({name:"To Atomic Level",description:"Converts sequences to molblocks","top-menu":"Bio | Transform | To Atomic Level..."}),Ur(0,r.decorators.param({options:{description:"Input data table"}})),Ur(1,r.decorators.param({options:{semType:"Macromolecule",caption:"Sequence"}})),Ur(2,r.decorators.param({options:{initialValue:"false",caption:"Non-linear",description:"Slower mode for cycling/branching HELM structures"}})),Ur(3,r.decorators.param({options:{initialValue:"false",caption:"Highlight monomers",description:"Highlight monomers' substructures of the molecule"}})),jr("design:type",Function),jr("design:paramtypes",[a.DataFrame,a.Column,Boolean,Boolean]),jr("design:returntype",Promise)],Yr,"toAtomicLevel",null),Wr([r.decorators.func({name:"To Atomic Level...",meta:{action:"to atomic level"}}),Ur(0,r.decorators.param({options:{semType:"Macromolecule"}})),jr("design:type",Function),jr("design:paramtypes",[a.Column]),jr("design:returntype",Promise)],Yr,"toAtomicLevelAction",null),Wr([r.decorators.panel({name:"Molecular Structure",tags:["bio","widgets"]}),Ur(0,r.decorators.param({name:"sequence",type:"semantic_value",options:{semType:"Macromolecule"}})),jr("design:type",Function),jr("design:paramtypes",[a.SemanticValue]),jr("design:returntype",Promise)],Yr,"toAtomicLevelPanel",null),Wr([r.decorators.panel({name:"Molecular 3D Structure",tags:["bio","widgets"]}),Ur(0,r.decorators.param({type:"semantic_value",options:{semType:"Macromolecule"}})),jr("design:type",Function),jr("design:paramtypes",[a.SemanticValue]),jr("design:returntype",Promise)],Yr,"sequence3dStructureWidget",null),Wr([r.decorators.panel({name:"MSA",description:"Performs multiple sequence alignment",tags:["bio"],"top-menu":"Bio | Analyze | MSA..."}),jr("design:type",Function),jr("design:paramtypes",[]),jr("design:returntype",void 0)],Yr,"multipleSequenceAlignmentDialog",null),Wr([r.decorators.func({name:"Multiple Sequence Alignment",description:"Multiple sequence alignment",tags:["bio"]}),Ur(0,r.decorators.param({type:"column",options:{semType:"Macromolecule"}})),Ur(1,r.decorators.param({type:"column"})),Ur(2,r.decorators.param({type:"object",options:{optional:!0}})),jr("design:type",Function),jr("design:paramtypes",[Object,Object,Object]),jr("design:returntype",Promise)],Yr,"alignSequences",null),Wr([r.decorators.func({name:"Composition Analysis",description:"Visualizes sequence composition on a WebLogo plot","top-menu":"Bio | Analyze | Composition",meta:{icon:"files/icons/composition-analysis.svg"},outputs:[{name:"result",type:"viewer"}]}),jr("design:type",Function),jr("design:paramtypes",[]),jr("design:returntype",Promise)],Yr,"compositionAnalysis",null),Wr([r.decorators.fileHandler({name:"importFasta",description:"Opens FASTA file",ext:"fasta, fna, ffn, faa, frn, fa, fst"}),jr("design:type",Function),jr("design:paramtypes",[String]),jr("design:returntype",Array)],Yr,"importFasta",null),Wr([r.decorators.fileHandler({name:"importBam",description:"Opens Bam file",ext:"bam, bai"}),jr("design:type",Function),jr("design:paramtypes",[String]),jr("design:returntype",Array)],Yr,"importBam",null),Wr([r.decorators.func({name:"convertDialog","top-menu":"Bio | Transform | Convert Sequence Notation..."}),jr("design:type",Function),jr("design:paramtypes",[]),jr("design:returntype",void 0)],Yr,"convertDialog",null),Wr([r.decorators.func({name:"Convert Notation...",meta:{action:"Convert Notation..."}}),Ur(0,r.decorators.param({options:{semType:"Macromolecule"}})),jr("design:type",Function),jr("design:paramtypes",[a.Column]),jr("design:returntype",void 0)],Yr,"convertColumnAction",null),Wr([r.decorators.func({name:"monomerCellRenderer",tags:["cellRenderer"],meta:{cellType:"Monomer",columnTags:"quality=Monomer"},outputs:[{type:"grid_cell_renderer",name:"result"}]}),jr("design:type",Function),jr("design:paramtypes",[]),jr("design:returntype",ci)],Yr,"monomerCellRenderer",null),Wr([r.decorators.func({name:"testDetectMacromolecule"}),Ur(0,r.decorators.param({options:{choices:["Demo:Files/","System:AppData/"]}})),jr("design:type",Function),jr("design:paramtypes",[String]),jr("design:returntype",Promise)],Yr,"testDetectMacromolecule",null),Wr([r.decorators.func({name:"Split to Monomers","top-menu":"Bio | Transform | Split to Monomers...",editor:"Bio:SplitToMonomersEditor"}),Ur(1,r.decorators.param({options:{semType:"Macromolecule"}})),jr("design:type",Function),jr("design:paramtypes",[a.DataFrame,a.Column]),jr("design:returntype",Promise)],Yr,"splitToMonomersTopMenu",null),Wr([r.decorators.func({name:"Bio: getHelmMonomers",outputs:[{name:"result",type:"object"}]}),Ur(0,r.decorators.param({type:"column",options:{semType:"Macromolecule"}})),jr("design:type",Function),jr("design:paramtypes",[a.Column]),jr("design:returntype",Array)],Yr,"getHelmMonomers",null),Wr([r.decorators.func({name:"Sequence Similarity Search",tags:["viewer"],meta:{icon:"files/icons/sequence-similarity-viewer.svg"},outputs:[{name:"result",type:"viewer"}]}),jr("design:type",Function),jr("design:paramtypes",[]),jr("design:returntype",xt)],Yr,"similaritySearchViewer",null),Wr([r.decorators.func({name:"similaritySearch",description:"Finds similar sequences","top-menu":"Bio | Search | Similarity Search",outputs:[{name:"result",type:"viewer"}]}),jr("design:type",Function),jr("design:paramtypes",[]),jr("design:returntype",void 0)],Yr,"similaritySearchTopMenu",null),Wr([r.decorators.func({name:"Sequence Diversity Search",tags:["viewer"],meta:{icon:"files/icons/sequence-diversity-viewer.svg"},outputs:[{name:"result",type:"viewer"}]}),jr("design:type",Function),jr("design:paramtypes",[]),jr("design:returntype",Mt)],Yr,"diversitySearchViewer",null),Wr([r.decorators.func({name:"diversitySearch",description:"Finds the most diverse sequences","top-menu":"Bio | Search | Diversity Search",outputs:[{name:"result",type:"viewer"}]}),jr("design:type",Function),jr("design:paramtypes",[]),jr("design:returntype",void 0)],Yr,"diversitySearchTopMenu",null),Wr([r.decorators.editor({name:"SearchSubsequenceEditor"}),jr("design:type",Function),jr("design:paramtypes",[a.FuncCall]),jr("design:returntype",void 0)],Yr,"searchSubsequenceEditor",null),Wr([r.decorators.func({name:"Subsequence Search","top-menu":"Bio | Search | Subsequence Search ...",editor:"Bio:SearchSubsequenceEditor"}),jr("design:type",Function),jr("design:paramtypes",[a.Column]),jr("design:returntype",void 0)],Yr,"SubsequenceSearchTopMenu",null),Wr([r.decorators.func({name:"Identity",description:"Adds a column with fraction of matching monomers","top-menu":"Bio | Calculate | Identity..."}),Ur(0,r.decorators.param({options:{description:"Table containing Macromolecule column"}})),Ur(1,r.decorators.param({options:{semType:"Macromolecule",description:"Sequences to score"}})),Ur(2,r.decorators.param({options:{description:"Sequence,matching column format"}})),jr("design:type",Function),jr("design:paramtypes",[a.DataFrame,a.Column,String]),jr("design:returntype",Promise)],Yr,"sequenceIdentityScoring",null),Wr([r.decorators.func({name:"Similarity",description:"Adds a column with similarity scores, calculated as sum of monomer fingerprint similarities","top-menu":"Bio | Calculate | Similarity..."}),Ur(0,r.decorators.param({options:{description:"Table containing Macromolecule column"}})),Ur(1,r.decorators.param({options:{semType:"Macromolecule",description:"Sequences to score"}})),Ur(2,r.decorators.param({options:{description:"Sequence,matching column format"}})),jr("design:type",Function),jr("design:paramtypes",[a.DataFrame,a.Column,String]),jr("design:returntype",Promise)],Yr,"sequenceSimilarityScoring",null),Wr([r.decorators.func({name:"Manage Monomer Libraries",description:"Manage HELM monomer libraries"}),jr("design:type",Function),jr("design:paramtypes",[]),jr("design:returntype",Promise)],Yr,"manageMonomerLibraries",null),Wr([r.decorators.func({name:"Manage Monomer Libraries View","top-menu":"Bio | Manage | Monomer Libraries"}),jr("design:type",Function),jr("design:paramtypes",[]),jr("design:returntype",Promise)],Yr,"manageLibrariesView",null),Wr([r.decorators.func({name:"manageMonomersView",description:"Edit and create monomers","top-menu":"Bio | Manage | Monomers"}),jr("design:type",Function),jr("design:paramtypes",[]),jr("design:returntype",Promise)],Yr,"manageMonomersView",null),Wr([r.decorators.app({name:"Manage Monomer Libraries",browsePath:"Peptides",icon:"files/icons/monomers.png"}),jr("design:type",Function),jr("design:paramtypes",[]),jr("design:returntype",Promise)],Yr,"manageMonomerLibrariesView",null),Wr([r.decorators.func({name:"Monomer Manager Tree Browser",meta:{role:"appTreeBrowser"}}),jr("design:type",Function),jr("design:paramtypes",[a.TreeViewGroup]),jr("design:returntype",Promise)],Yr,"manageMonomerLibrariesViewTreeBrowser",null),Wr([r.decorators.fileExporter({description:"As FASTA..."}),jr("design:type",Function),jr("design:paramtypes",[]),jr("design:returntype",void 0)],Yr,"saveAsFasta",null),Wr([r.decorators.func({name:"Bio Substructure Filter",description:"Substructure filter for macromolecules",tags:["filter"],meta:{semType:"Macromolecule"},outputs:[{type:"filter",name:"result"}]}),jr("design:type",Function),jr("design:paramtypes",[]),jr("design:returntype",It._i)],Yr,"bioSubstructureFilter",null),Wr([r.decorators.func({name:"Bio Substructure Filter Test",description:"Substructure filter for Helm package tests",outputs:[{name:"result",type:"object"}]}),jr("design:type",Function),jr("design:paramtypes",[]),jr("design:returntype",It._i)],Yr,"bioSubstructureFilterTest",null),Wr([r.decorators.func(),jr("design:type",Function),jr("design:paramtypes",[]),jr("design:returntype",Promise)],Yr,"webLogoLargeApp",null),Wr([r.decorators.func(),jr("design:type",Function),jr("design:paramtypes",[]),jr("design:returntype",Promise)],Yr,"webLogoAggApp",null),Wr([r.decorators.func(),jr("design:type",Function),jr("design:paramtypes",[]),jr("design:returntype",Promise)],Yr,"getRegionApp",null),Wr([r.decorators.func(),jr("design:type",Function),jr("design:paramtypes",[]),jr("design:returntype",Promise)],Yr,"getRegionHelmApp",null),Wr([r.decorators.func(),jr("design:type",Function),jr("design:paramtypes",[]),jr("design:returntype",void 0)],Yr,"longSeqTableSeparator",null),Wr([r.decorators.func(),jr("design:type",Function),jr("design:paramtypes",[]),jr("design:returntype",void 0)],Yr,"longSeqTableFasta",null),Wr([r.decorators.func(),jr("design:type",Function),jr("design:paramtypes",[]),jr("design:returntype",void 0)],Yr,"longSeqTableHelm",null),Wr([r.decorators.func(),Ur(0,r.decorators.param({type:"object"})),Ur(1,r.decorators.param({type:"object"})),jr("design:type",Function),jr("design:paramtypes",[a.Cell,a.Menu]),jr("design:returntype",void 0)],Yr,"addCopyMenu",null),Wr([r.decorators.demo({description:"Sequence similarity tracking and evaluation dataset diversity",demoPath:"Bioinformatics | Similarity, Diversity",path:"/apps/Tutorials/Demo/Bioinformatics/Similarity,%20Diversity"}),jr("design:type",Function),jr("design:paramtypes",[]),jr("design:returntype",Promise)],Yr,"demoBioSimilarityDiversity",null),Wr([r.decorators.demo({description:"Exploring sequence space of Macromolecules, comparison with hierarchical clustering results",demoPath:"Bioinformatics | Sequence Space",path:"/apps/Tutorials/Demo/Bioinformatics/Sequence%20Space",meta:{isDemoDashboard:"true"}}),jr("design:type",Function),jr("design:paramtypes",[]),jr("design:returntype",Promise)],Yr,"demoBioSequenceSpace",null),Wr([r.decorators.demo({description:"Activity Cliffs analysis on Macromolecules data",demoPath:"Bioinformatics | Activity Cliffs",path:"/apps/Tutorials/Demo/Bioinformatics/Activity%20Cliffs"}),jr("design:type",Function),jr("design:paramtypes",[]),jr("design:returntype",Promise)],Yr,"demoBioActivityCliffs",null),Wr([r.decorators.demo({description:"Atomic level structure of Macromolecules",demoPath:"Bioinformatics | Atomic Level",path:"/apps/Tutorials/Demo/Bioinformatics/Atomic%20Level"}),jr("design:type",Function),jr("design:paramtypes",[]),jr("design:returntype",Promise)],Yr,"demoBioAtomicLevel",null),Wr([r.decorators.func({name:"SDF to JSON Library"}),jr("design:type",Function),jr("design:paramtypes",[a.DataFrame]),jr("design:returntype",Promise)],Yr,"sdfToJsonLib",null),Wr([r.decorators.func({friendlyName:"seq2atomic",description:"Converts a `Macromolecule` sequence to its atomic level `Molecule` representation",outputs:[{name:"molfile",type:"string",options:{semType:"Molecule"}}]}),Ur(0,r.decorators.param({options:{semType:"Macromolecule"}})),jr("design:type",Function),jr("design:paramtypes",[String,Boolean]),jr("design:returntype",Promise)],Yr,"seq2atomic",null),Wr([r.decorators.func({name:"seqIdentity",friendlyName:"seqIdentity",description:"Gets identity to a reference sequence"}),Ur(0,r.decorators.param({options:{semType:"Macromolecule"}})),Ur(1,r.decorators.param({options:{semType:"Macromolecule"}})),jr("design:type",Function),jr("design:paramtypes",[String,String]),jr("design:returntype",Promise)],Yr,"seqIdentity",null),Wr([r.decorators.func(),Ur(2,r.decorators.param({options:{initialValue:"100"}})),jr("design:type",Function),jr("design:paramtypes",[a.FileInfo,String,Number]),jr("design:returntype",Promise)],Yr,"detectMacromoleculeProbe",null),Wr([r.decorators.func({outputs:[{type:"object",name:"result"}]}),jr("design:type",Function),jr("design:paramtypes",[]),jr("design:returntype",Promise)],Yr,"getSeqHelper",null),Wr([r.decorators.func(),Ur(1,r.decorators.param({type:"column"})),Ur(2,r.decorators.param({options:{initialValue:"true"}})),jr("design:type",Function),jr("design:paramtypes",[a.DataFrame,a.Column,Boolean]),jr("design:returntype",Promise)],Yr,"getMolFromHelm",null);class Kr{_palette;constructor(e){this._palette=e}get(e){return this._palette[e]}}function Zr(){return qr.logger.debug("Bio:test1() function"),{value:"value1"}}},2476:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dynamicAnchor=void 0;const i=n(9029),o=n(2023),r=n(3835),s=n(3693),a={keyword:"$dynamicAnchor",schemaType:"string",code:e=>l(e,e.schema)};function l(e,t){const{gen:n,it:a}=e;a.schemaEnv.root.dynamicAnchors[t]=!0;const l=i._`${o.default.dynamicAnchors}${(0,i.getProperty)(t)}`,c="#"===a.errSchemaPath?a.validateName:function(e){const{schemaEnv:t,schema:n,self:i}=e.it,{root:o,baseId:a,localRefs:l,meta:c}=t.root,{schemaId:u}=i.opts,h=new r.SchemaEnv({schema:n,schemaId:u,root:o,baseId:a,localRefs:l,meta:c});return r.compileSchema.call(i,h),(0,s.getValidate)(e,h)}(e);n.if(i._`!${l}`,()=>n.assign(l,c))}t.dynamicAnchor=l,t.default=a},2561:e=>{var t=10;e.exports=function(e,n,i){var o,r,s,a,l,c,u,h,d,p,m,f,g,y,b,v,w,C,S,A,x,M,T,E=n.length,_=i.length,I=e.adjustSizes,L=e.barnesHutTheta*e.barnesHutTheta,N=[];for(s=0;s<E;s+=t)n[s+4]=n[s+2],n[s+5]=n[s+3],n[s+2]=0,n[s+3]=0;if(e.outboundAttractionDistribution){for(m=0,s=0;s<E;s+=t)m+=n[s+6];m/=E/t}if(e.barnesHutOptimize){var P,R,$,O=1/0,k=-1/0,H=1/0,B=-1/0;for(s=0;s<E;s+=t)O=Math.min(O,n[s+0]),k=Math.max(k,n[s+0]),H=Math.min(H,n[s+1]),B=Math.max(B,n[s+1]);var F=k-O,G=B-H;for(F>G?B=(H-=(F-G)/2)+F:k=(O-=(G-F)/2)+G,N[0]=-1,N[1]=(O+k)/2,N[2]=(H+B)/2,N[3]=Math.max(k-O,B-H),N[4]=-1,N[5]=-1,N[6]=0,N[7]=0,N[8]=0,o=1,s=0;s<E;s+=t)for(r=0,$=3;;){if(!(N[r+5]>=0)){if(N[r+0]<0){N[r+0]=s;break}if(N[r+5]=9*o,h=N[r+3]/2,N[(d=N[r+5])+0]=-1,N[d+1]=N[r+1]-h,N[d+2]=N[r+2]-h,N[d+3]=h,N[d+4]=d+9,N[d+5]=-1,N[d+6]=0,N[d+7]=0,N[d+8]=0,N[(d+=9)+0]=-1,N[d+1]=N[r+1]-h,N[d+2]=N[r+2]+h,N[d+3]=h,N[d+4]=d+9,N[d+5]=-1,N[d+6]=0,N[d+7]=0,N[d+8]=0,N[(d+=9)+0]=-1,N[d+1]=N[r+1]+h,N[d+2]=N[r+2]-h,N[d+3]=h,N[d+4]=d+9,N[d+5]=-1,N[d+6]=0,N[d+7]=0,N[d+8]=0,N[(d+=9)+0]=-1,N[d+1]=N[r+1]+h,N[d+2]=N[r+2]+h,N[d+3]=h,N[d+4]=N[r+4],N[d+5]=-1,N[d+6]=0,N[d+7]=0,N[d+8]=0,o+=4,P=n[N[r+0]+0]<N[r+1]?n[N[r+0]+1]<N[r+2]?N[r+5]:N[r+5]+9:n[N[r+0]+1]<N[r+2]?N[r+5]+18:N[r+5]+27,N[r+6]=n[N[r+0]+6],N[r+7]=n[N[r+0]+0],N[r+8]=n[N[r+0]+1],N[P+0]=N[r+0],N[r+0]=-1,P===(R=n[s+0]<N[r+1]?n[s+1]<N[r+2]?N[r+5]:N[r+5]+9:n[s+1]<N[r+2]?N[r+5]+18:N[r+5]+27)){if($--){r=P;continue}$=3;break}N[R+0]=s;break}P=n[s+0]<N[r+1]?n[s+1]<N[r+2]?N[r+5]:N[r+5]+9:n[s+1]<N[r+2]?N[r+5]+18:N[r+5]+27,N[r+7]=(N[r+7]*N[r+6]+n[s+0]*n[s+6])/(N[r+6]+n[s+6]),N[r+8]=(N[r+8]*N[r+6]+n[s+1]*n[s+6])/(N[r+6]+n[s+6]),N[r+6]+=n[s+6],r=P}}if(e.barnesHutOptimize){for(f=e.scalingRatio,s=0;s<E;s+=t)for(r=0;;)if(N[r+5]>=0){if(v=Math.pow(n[s+0]-N[r+7],2)+Math.pow(n[s+1]-N[r+8],2),4*(p=N[r+3])*p/v<L){if(g=n[s+0]-N[r+7],y=n[s+1]-N[r+8],!0===I?v>0?(w=f*n[s+6]*N[r+6]/v,n[s+2]+=g*w,n[s+3]+=y*w):v<0&&(w=-f*n[s+6]*N[r+6]/Math.sqrt(v),n[s+2]+=g*w,n[s+3]+=y*w):v>0&&(w=f*n[s+6]*N[r+6]/v,n[s+2]+=g*w,n[s+3]+=y*w),(r=N[r+4])<0)break;continue}r=N[r+5]}else if((c=N[r+0])>=0&&c!==s&&(v=(g=n[s+0]-n[c+0])*g+(y=n[s+1]-n[c+1])*y,!0===I?v>0?(w=f*n[s+6]*n[c+6]/v,n[s+2]+=g*w,n[s+3]+=y*w):v<0&&(w=-f*n[s+6]*n[c+6]/Math.sqrt(v),n[s+2]+=g*w,n[s+3]+=y*w):v>0&&(w=f*n[s+6]*n[c+6]/v,n[s+2]+=g*w,n[s+3]+=y*w)),(r=N[r+4])<0)break}else for(f=e.scalingRatio,a=0;a<E;a+=t)for(l=0;l<a;l+=t)g=n[a+0]-n[l+0],y=n[a+1]-n[l+1],!0===I?(v=Math.sqrt(g*g+y*y)-n[a+8]-n[l+8])>0?(w=f*n[a+6]*n[l+6]/v/v,n[a+2]+=g*w,n[a+3]+=y*w,n[l+2]-=g*w,n[l+3]-=y*w):v<0&&(w=100*f*n[a+6]*n[l+6],n[a+2]+=g*w,n[a+3]+=y*w,n[l+2]-=g*w,n[l+3]-=y*w):(v=Math.sqrt(g*g+y*y))>0&&(w=f*n[a+6]*n[l+6]/v/v,n[a+2]+=g*w,n[a+3]+=y*w,n[l+2]-=g*w,n[l+3]-=y*w);for(d=e.gravity/e.scalingRatio,f=e.scalingRatio,s=0;s<E;s+=t)w=0,g=n[s+0],y=n[s+1],v=Math.sqrt(Math.pow(g,2)+Math.pow(y,2)),e.strongGravityMode?v>0&&(w=f*n[s+6]*d):v>0&&(w=f*n[s+6]*d/v),n[s+2]-=g*w,n[s+3]-=y*w;for(f=1*(e.outboundAttractionDistribution?m:1),u=0;u<_;u+=3)a=i[u+0],l=i[u+1],h=i[u+2],b=Math.pow(h,e.edgeWeightInfluence),g=n[a+0]-n[l+0],y=n[a+1]-n[l+1],!0===I?(v=Math.sqrt(g*g+y*y)-n[a+8]-n[l+8],e.linLogMode?e.outboundAttractionDistribution?v>0&&(w=-f*b*Math.log(1+v)/v/n[a+6]):v>0&&(w=-f*b*Math.log(1+v)/v):e.outboundAttractionDistribution?v>0&&(w=-f*b/n[a+6]):v>0&&(w=-f*b)):(v=Math.sqrt(Math.pow(g,2)+Math.pow(y,2)),e.linLogMode?e.outboundAttractionDistribution?v>0&&(w=-f*b*Math.log(1+v)/v/n[a+6]):v>0&&(w=-f*b*Math.log(1+v)/v):e.outboundAttractionDistribution?(v=1,w=-f*b/n[a+6]):(v=1,w=-f*b)),v>0&&(n[a+2]+=g*w,n[a+3]+=y*w,n[l+2]-=g*w,n[l+3]-=y*w);if(!0===I)for(s=0;s<E;s+=t)1!==n[s+9]&&((C=Math.sqrt(Math.pow(n[s+2],2)+Math.pow(n[s+3],2)))>10&&(n[s+2]=10*n[s+2]/C,n[s+3]=10*n[s+3]/C),S=n[s+6]*Math.sqrt((n[s+4]-n[s+2])*(n[s+4]-n[s+2])+(n[s+5]-n[s+3])*(n[s+5]-n[s+3])),A=Math.sqrt((n[s+4]+n[s+2])*(n[s+4]+n[s+2])+(n[s+5]+n[s+3])*(n[s+5]+n[s+3]))/2,x=.1*Math.log(1+A)/(1+Math.sqrt(S)),M=n[s+0]+n[s+2]*(x/e.slowDown),n[s+0]=M,T=n[s+1]+n[s+3]*(x/e.slowDown),n[s+1]=T);else for(s=0;s<E;s+=t)1!==n[s+9]&&(S=n[s+6]*Math.sqrt((n[s+4]-n[s+2])*(n[s+4]-n[s+2])+(n[s+5]-n[s+3])*(n[s+5]-n[s+3])),A=Math.sqrt((n[s+4]+n[s+2])*(n[s+4]+n[s+2])+(n[s+5]+n[s+3])*(n[s+5]+n[s+3]))/2,x=n[s+7]*Math.log(1+A)/(1+Math.sqrt(S)),n[s+7]=Math.min(1,Math.sqrt(x*(Math.pow(n[s+2],2)+Math.pow(n[s+3],2))/(1+Math.sqrt(S)))),M=n[s+0]+n[s+2]*(x/e.slowDown),n[s+0]=M,T=n[s+1]+n[s+3]*(x/e.slowDown),n[s+1]=T);return{}}},2582:(e,t,n)=>{"use strict";n.d(t,{f:()=>a});var i=n(6956);class o{constructor(e){const t=e.split(i.x).filter(e=>e);t.forEach(e=>this.validateConnectionItem(e)),this.connectionItems=t}connectionItems;validateConnectionItem(e){const t="(PEPTIDE|RNA|CHEM|BLOB)",n=new RegExp(`${t}[0-9]+,${t}[0-9]+,[0-9]+:R[0-9]+-[0-9]+:R[0-9]+`,"g");if(!e.match(n))throw new Error(`Cannot parse connection item from ${e}`)}getConnectionData(){const e=[];return this.connectionItems.forEach(t=>{const n=[],i=t.split(",");i[2].split("-").forEach((e,t)=>{const o=i[t],r=e.split(":"),s={monomerIdx:parseInt(r[0])-1,rGroupId:parseInt(r[1].slice(1))};n.push({polymerId:o,bond:s})}),e.push(n)}),e}}var r=n(8438);class s{simplePolymer;isNucleotideSequence=!1;constructor(e){this.simplePolymer=e,this.polymerType=this.getPolymerType(),this.isNucleotideSequence="RNA"===this.polymerType,this.idx=this.getIdx();const{monomers:t,monomerTypes:n}=this.getMonomerSymbolsAndTypes();this.monomers=t,this.monomerTypes=n}polymerType;monomers;idx;monomerTypes;get id(){return this.polymerType+this.idx.toString()}getPolymerType(){const e=new RegExp("(PEPTIDE|RNA|CHEM|BLOB)[0-9]+{"),t=this.simplePolymer.match(e);if(!t)throw new Error(`Unsupported polymer type in ${this.simplePolymer}`);return t[1]}getIdx(){const e=new RegExp(`${this.polymerType}([0-9]+){`),t=this.simplePolymer.match(e);if(!t)throw new Error(`Cannot parse simple polymer id from ${this.simplePolymer}`);return parseInt(t[1])}getMonomerSymbolsAndTypes(){const e=new RegExp(`${this.polymerType}${this.idx}{|}`,"g"),t=this.simplePolymer.replace(e,"").split("."),n=[],i=[];return t.forEach(e=>{if(this.isNucleotideSequence){const t=e.split(/\(|\)/).filter(e=>!!e).map(e=>(0,r.D)(e));n.push(...t),t.forEach((e,t)=>i.push(t%3==1?"Branch":"Backbone"))}else n.push((0,r.D)(e)),i.push("Backbone")}),{monomers:n,monomerTypes:i}}getBondData(){const e=[],t=this.monomerTypes.map((e,t)=>{if("Backbone"===e)return t}).filter(e=>void 0!==e),n=this.monomerTypes.map((e,t)=>{if("Branch"===e)return t}).filter(e=>void 0!==e);for(let n=0;n<t.length-1;n++){const i=t[n],o=t[n+1];e.push([{monomerIdx:i,rGroupId:2},{monomerIdx:o,rGroupId:1}])}for(let t=0;t<n.length;t++){const i=n[t],o=i-1;e.push([{monomerIdx:o,rGroupId:3},{monomerIdx:i,rGroupId:1}])}return e}}class a{helmString;constructor(e){this.helmString=e;const t=e.indexOf("}$"),n=e.substring(0,t+1),i=e.indexOf("$",t+2),r=e.substring(t+2,i),a=n.split("}|");for(let e=0;e<a.length-1;e++)a[e]=a[e]+"}";this.simplePolymers=a.map(e=>new s(e)),this.connectionList=new o(r),this.bondData=this.getBondData(),this.bondedRGroupsMap=this.getBondedRGroupsMap()}bondData;simplePolymers;connectionList;bondedRGroupsMap;getBondedRGroupsMap(){const e=this.simplePolymers.map(e=>e.monomers.length).reduce((e,t)=>e+t,0),t=Array.from({length:e},()=>[]);return this.bondData.forEach(e=>{e.forEach(e=>{const n=e.monomerIdx,i=e.rGroupId;t[n].push(i)})}),t}toString(){return this.helmString}getPolymerTypeByMonomerIdx(e){return this.getSimplePolymerByMonomerIdx(e).polymerType}getSimplePolymerByMonomerIdx(e){const t=this.getMonomerIdxShifts(),n=Object.values(t).sort((e,t)=>t-e).find(t=>e>=t);if(null==n)throw new Error(`Cannot find simple polymer for monomer ${e}`);const i=Object.keys(t).find(e=>t[e]===n);return this.simplePolymers.find(e=>e.id===i)}shiftBondMonomerIds(e,t){t.forEach(t=>{t.forEach(t=>{t.monomerIdx+=e})})}getMonomerIdxShifts(){const e={};let t=0;return this.simplePolymers.forEach(n=>{e[n.id]=t,t+=n.monomers.length}),e}getBondData(){const e=this.getMonomerIdxShifts(),t=[];return this.simplePolymers.forEach(n=>{const i=n.getBondData(),o=e[n.id];this.shiftBondMonomerIds(o,i),t.push(...i)}),this.connectionList.getConnectionData().forEach(n=>{const i=[];n.forEach(t=>{const n=e[t.polymerId],o=t.bond;o.monomerIdx+=n,i.push(o)}),t.push(i)}),t}}},2586:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getData=t.KeywordCxt=t.validateFunctionCode=void 0;const i=n(8727),o=n(208),r=n(7887),s=n(208),a=n(7870),l=n(3673),c=n(4495),u=n(9029),h=n(2023),d=n(6939),p=n(4227),m=n(8708);function f({gen:e,validateName:t,schema:n,schemaEnv:i,opts:o},r){o.code.es5?e.func(t,u._`${h.default.data}, ${h.default.valCxt}`,i.$async,()=>{e.code(u._`"use strict"; ${g(n,o)}`),function(e,t){e.if(h.default.valCxt,()=>{e.var(h.default.instancePath,u._`${h.default.valCxt}.${h.default.instancePath}`),e.var(h.default.parentData,u._`${h.default.valCxt}.${h.default.parentData}`),e.var(h.default.parentDataProperty,u._`${h.default.valCxt}.${h.default.parentDataProperty}`),e.var(h.default.rootData,u._`${h.default.valCxt}.${h.default.rootData}`),t.dynamicRef&&e.var(h.default.dynamicAnchors,u._`${h.default.valCxt}.${h.default.dynamicAnchors}`)},()=>{e.var(h.default.instancePath,u._`""`),e.var(h.default.parentData,u._`undefined`),e.var(h.default.parentDataProperty,u._`undefined`),e.var(h.default.rootData,h.default.data),t.dynamicRef&&e.var(h.default.dynamicAnchors,u._`{}`)})}(e,o),e.code(r)}):e.func(t,u._`${h.default.data}, ${function(e){return u._`{${h.default.instancePath}="", ${h.default.parentData}, ${h.default.parentDataProperty}, ${h.default.rootData}=${h.default.data}${e.dynamicRef?u._`, ${h.default.dynamicAnchors}={}`:u.nil}}={}`}(o)}`,i.$async,()=>e.code(g(n,o)).code(r))}function g(e,t){const n="object"==typeof e&&e[t.schemaId];return n&&(t.code.source||t.code.process)?u._`/*# sourceURL=${n} */`:u.nil}function y({schema:e,self:t}){if("boolean"==typeof e)return!e;for(const n in e)if(t.RULES.all[n])return!0;return!1}function b(e){return"boolean"!=typeof e.schema}function v(e){(0,p.checkUnknownRules)(e),function(e){const{schema:t,errSchemaPath:n,opts:i,self:o}=e;t.$ref&&i.ignoreKeywordsWithRef&&(0,p.schemaHasRulesButRef)(t,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${n}"`)}(e)}function w(e,t){if(e.opts.jtd)return S(e,[],!1,t);const n=(0,o.getSchemaTypes)(e.schema);S(e,n,!(0,o.coerceAndCheckDataType)(e,n),t)}function C({gen:e,schemaEnv:t,schema:n,errSchemaPath:i,opts:o}){const r=n.$comment;if(!0===o.$comment)e.code(u._`${h.default.self}.logger.log(${r})`);else if("function"==typeof o.$comment){const n=u.str`${i}/$comment`,o=e.scopeValue("root",{ref:t.root});e.code(u._`${h.default.self}.opts.$comment(${r}, ${n}, ${o}.schema)`)}}function S(e,t,n,i){const{gen:o,schema:a,data:l,allErrors:c,opts:d,self:m}=e,{RULES:f}=m;function g(p){(0,r.shouldUseGroup)(a,p)&&(p.type?(o.if((0,s.checkDataType)(p.type,l,d.strictNumbers)),A(e,p),1===t.length&&t[0]===p.type&&n&&(o.else(),(0,s.reportTypeError)(e)),o.endIf()):A(e,p),c||o.if(u._`${h.default.errors} === ${i||0}`))}!a.$ref||!d.ignoreKeywordsWithRef&&(0,p.schemaHasRulesButRef)(a,f)?(d.jtd||function(e,t){!e.schemaEnv.meta&&e.opts.strictTypes&&(function(e,t){t.length&&(e.dataTypes.length?(t.forEach(t=>{x(e.dataTypes,t)||M(e,`type "${t}" not allowed by context "${e.dataTypes.join(",")}"`)}),function(e,t){const n=[];for(const i of e.dataTypes)x(t,i)?n.push(i):t.includes("integer")&&"number"===i&&n.push("integer");e.dataTypes=n}(e,t)):e.dataTypes=t)}(e,t),e.opts.allowUnionTypes||function(e,t){t.length>1&&(2!==t.length||!t.includes("null"))&&M(e,"use allowUnionTypes to allow union type keyword")}(e,t),function(e,t){const n=e.self.RULES.all;for(const i in n){const o=n[i];if("object"==typeof o&&(0,r.shouldUseRule)(e.schema,o)){const{type:n}=o.definition;n.length&&!n.some(e=>{return i=e,(n=t).includes(i)||"number"===i&&n.includes("integer");var n,i})&&M(e,`missing type "${n.join(",")}" for keyword "${i}"`)}}}(e,e.dataTypes))}(e,t),o.block(()=>{for(const e of f.rules)g(e);g(f.post)})):o.block(()=>E(e,"$ref",f.all.$ref.definition))}function A(e,t){const{gen:n,schema:i,opts:{useDefaults:o}}=e;o&&(0,a.assignDefaults)(e,t.type),n.block(()=>{for(const n of t.rules)(0,r.shouldUseRule)(i,n)&&E(e,n.keyword,n.definition,t.type)})}function x(e,t){return e.includes(t)||"integer"===t&&e.includes("number")}function M(e,t){t+=` at "${e.schemaEnv.baseId+e.errSchemaPath}" (strictTypes)`,(0,p.checkStrictMode)(e,t,e.opts.strictTypes)}t.validateFunctionCode=function(e){b(e)&&(v(e),y(e))?function(e){const{schema:t,opts:n,gen:i}=e;f(e,()=>{n.$comment&&t.$comment&&C(e),function(e){const{schema:t,opts:n}=e;void 0!==t.default&&n.useDefaults&&n.strictSchema&&(0,p.checkStrictMode)(e,"default is ignored in the schema root")}(e),i.let(h.default.vErrors,null),i.let(h.default.errors,0),n.unevaluated&&function(e){const{gen:t,validateName:n}=e;e.evaluated=t.const("evaluated",u._`${n}.evaluated`),t.if(u._`${e.evaluated}.dynamicProps`,()=>t.assign(u._`${e.evaluated}.props`,u._`undefined`)),t.if(u._`${e.evaluated}.dynamicItems`,()=>t.assign(u._`${e.evaluated}.items`,u._`undefined`))}(e),w(e),function(e){const{gen:t,schemaEnv:n,validateName:i,ValidationError:o,opts:r}=e;n.$async?t.if(u._`${h.default.errors} === 0`,()=>t.return(h.default.data),()=>t.throw(u._`new ${o}(${h.default.vErrors})`)):(t.assign(u._`${i}.errors`,h.default.vErrors),r.unevaluated&&function({gen:e,evaluated:t,props:n,items:i}){n instanceof u.Name&&e.assign(u._`${t}.props`,n),i instanceof u.Name&&e.assign(u._`${t}.items`,i)}(e),t.return(u._`${h.default.errors} === 0`))}(e)})}(e):f(e,()=>(0,i.topBoolOrEmptySchema)(e))};class T{constructor(e,t,n){if((0,l.validateKeywordUsage)(e,t,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=t.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,p.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=t.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=t,this.$data)this.schemaCode=e.gen.const("vSchema",L(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,l.validSchemaType)(this.schema,t.schemaType,t.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(t.schemaType)}`);("code"in t?t.trackErrors:!1!==t.errors)&&(this.errsCount=e.gen.const("_errs",h.default.errors))}result(e,t,n){this.failResult((0,u.not)(e),t,n)}failResult(e,t,n){this.gen.if(e),n?n():this.error(),t?(this.gen.else(),t(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,t){this.failResult((0,u.not)(e),void 0,t)}fail(e){if(void 0===e)return this.error(),void(this.allErrors||this.gen.if(!1));this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);const{schemaCode:t}=this;this.fail(u._`${t} !== undefined && (${(0,u.or)(this.invalid$data(),e)})`)}error(e,t,n){if(t)return this.setParams(t),this._error(e,n),void this.setParams({});this._error(e,n)}_error(e,t){(e?m.reportExtraError:m.reportError)(this,this.def.error,t)}$dataError(){(0,m.reportError)(this,this.def.$dataError||m.keyword$DataError)}reset(){if(void 0===this.errsCount)throw new Error('add "trackErrors" to keyword definition');(0,m.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,t){t?Object.assign(this.params,e):this.params=e}block$data(e,t,n=u.nil){this.gen.block(()=>{this.check$data(e,n),t()})}check$data(e=u.nil,t=u.nil){if(!this.$data)return;const{gen:n,schemaCode:i,schemaType:o,def:r}=this;n.if((0,u.or)(u._`${i} === undefined`,t)),e!==u.nil&&n.assign(e,!0),(o.length||r.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==u.nil&&n.assign(e,!1)),n.else()}invalid$data(){const{gen:e,schemaCode:t,schemaType:n,def:i,it:o}=this;return(0,u.or)(function(){if(n.length){if(!(t instanceof u.Name))throw new Error("ajv implementation error");const e=Array.isArray(n)?n:[n];return u._`${(0,s.checkDataTypes)(e,t,o.opts.strictNumbers,s.DataType.Wrong)}`}return u.nil}(),function(){if(i.validateSchema){const n=e.scopeValue("validate$data",{ref:i.validateSchema});return u._`!${n}(${t})`}return u.nil}())}subschema(e,t){const n=(0,c.getSubschema)(this.it,e);(0,c.extendSubschemaData)(n,this.it,e),(0,c.extendSubschemaMode)(n,e);const o={...this.it,...n,items:void 0,props:void 0};return function(e,t){b(e)&&(v(e),y(e))?function(e,t){const{schema:n,gen:i,opts:o}=e;o.$comment&&n.$comment&&C(e),function(e){const t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,d.resolveUrl)(e.opts.uriResolver,e.baseId,t))}(e),function(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}(e);const r=i.const("_errs",h.default.errors);w(e,r),i.var(t,u._`${r} === ${h.default.errors}`)}(e,t):(0,i.boolOrEmptySchema)(e,t)}(o,t),o}mergeEvaluated(e,t){const{it:n,gen:i}=this;n.opts.unevaluated&&(!0!==n.props&&void 0!==e.props&&(n.props=p.mergeEvaluated.props(i,e.props,n.props,t)),!0!==n.items&&void 0!==e.items&&(n.items=p.mergeEvaluated.items(i,e.items,n.items,t)))}mergeValidEvaluated(e,t){const{it:n,gen:i}=this;if(n.opts.unevaluated&&(!0!==n.props||!0!==n.items))return i.if(t,()=>this.mergeEvaluated(e,u.Name)),!0}}function E(e,t,n,i){const o=new T(e,n,t);"code"in n?n.code(o,i):o.$data&&n.validate?(0,l.funcKeywordCode)(o,n):"macro"in n?(0,l.macroKeywordCode)(o,n):(n.compile||n.validate)&&(0,l.funcKeywordCode)(o,n)}t.KeywordCxt=T;const _=/^\/(?:[^~]|~0|~1)*$/,I=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function L(e,{dataLevel:t,dataNames:n,dataPathArr:i}){let o,r;if(""===e)return h.default.rootData;if("/"===e[0]){if(!_.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);o=e,r=h.default.rootData}else{const s=I.exec(e);if(!s)throw new Error(`Invalid JSON-pointer: ${e}`);const a=+s[1];if(o=s[2],"#"===o){if(a>=t)throw new Error(l("property/index",a));return i[t-a]}if(a>t)throw new Error(l("data",a));if(r=n[t-a],!o)return r}let s=r;const a=o.split("/");for(const e of a)e&&(r=u._`${r}${(0,u.getProperty)((0,p.unescapeJsonPointer)(e))}`,s=u._`${s} && ${r}`);return s;function l(e,n){return`Cannot access ${e} ${n} levels up, current level is ${t}`}}t.getData=L},2626:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(4227),o={keyword:["maxContains","minContains"],type:"array",schemaType:"number",code({keyword:e,parentSchema:t,it:n}){void 0===t.contains&&(0,i.checkStrictMode)(n,`"${e}" without "contains" is ignored`)}};t.default=o},2661:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o=n(4227),r={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:{message:({params:{min:e,max:t}})=>void 0===t?i.str`must contain at least ${e} valid item(s)`:i.str`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>void 0===t?i._`{minContains: ${e}}`:i._`{minContains: ${e}, maxContains: ${t}}`},code(e){const{gen:t,schema:n,parentSchema:r,data:s,it:a}=e;let l,c;const{minContains:u,maxContains:h}=r;a.opts.next?(l=void 0===u?1:u,c=h):l=1;const d=t.const("len",i._`${s}.length`);if(e.setParams({min:l,max:c}),void 0===c&&0===l)return void(0,o.checkStrictMode)(a,'"minContains" == 0 without "maxContains": "contains" keyword ignored');if(void 0!==c&&l>c)return(0,o.checkStrictMode)(a,'"minContains" > "maxContains" is always invalid'),void e.fail();if((0,o.alwaysValidSchema)(a,n)){let t=i._`${d} >= ${l}`;return void 0!==c&&(t=i._`${t} && ${d} <= ${c}`),void e.pass(t)}a.items=!0;const p=t.name("valid");function m(){const e=t.name("_valid"),n=t.let("count",0);f(e,()=>t.if(e,()=>function(e){t.code(i._`${e}++`),void 0===c?t.if(i._`${e} >= ${l}`,()=>t.assign(p,!0).break()):(t.if(i._`${e} > ${c}`,()=>t.assign(p,!1).break()),1===l?t.assign(p,!0):t.if(i._`${e} >= ${l}`,()=>t.assign(p,!0)))}(n)))}function f(n,i){t.forRange("i",0,d,t=>{e.subschema({keyword:"contains",dataProp:t,dataPropType:o.Type.Num,compositeRule:!0},n),i()})}void 0===c&&1===l?f(p,()=>t.if(p,()=>t.break())):0===l?(t.let(p,!0),void 0!==c&&t.if(i._`${s}.length > 0`,m)):(t.let(p,!1),m()),e.result(p,()=>e.reset())}};t.default=r},2721:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(2476),o=n(4227),r={keyword:"$recursiveAnchor",schemaType:"boolean",code(e){e.schema?(0,i.dynamicAnchor)(e,""):(0,o.checkStrictMode)(e.it,"$recursiveAnchor: false is ignored")}};t.default=r},2738:(e,t,n)=>{"use strict";n.d(t,{X:()=>o,a:()=>i});class i{constructor(e,t,n){this.name=e,this.alphabet=t,this.cutoff=n}}class o extends i{constructor(e,t,n){super(e.name,e.alphabet,e.cutoff),this.freq=t,this.similarity=n}}},2780:(e,t,n)=>{"use strict";n(8498),n(9336)},2787:(e,t,n)=>{"use strict";n.d(t,{I:()=>o});const i=new Uint32Array(65536),o=(e,t)=>{if(e.length<t.length){const n=t;t=e,e=n}return 0===t.length?e.length:e.length<=32?((e,t)=>{const n=e.length,o=t.length,r=1<<n-1;let s=-1,a=0,l=n,c=n;for(;c--;)i[e.charCodeAt(c)]|=1<<c;for(c=0;c<o;c++){let e=i[t.charCodeAt(c)];const n=e|a;e|=(e&s)+s^s,a|=~(e|s),s&=e,a&r&&l++,s&r&&l--,a=a<<1|1,s=s<<1|~(n|a),a&=n}for(c=n;c--;)i[e.charCodeAt(c)]=0;return l})(e,t):((e,t)=>{const n=t.length,o=e.length,r=[],s=[],a=Math.ceil(n/32),l=Math.ceil(o/32);for(let e=0;e<a;e++)s[e]=-1,r[e]=0;let c=0;for(;c<l-1;c++){let a=0,l=-1;const u=32*c,h=Math.min(32,o)+u;for(let t=u;t<h;t++)i[e.charCodeAt(t)]|=1<<t;for(let e=0;e<n;e++){const n=i[t.charCodeAt(e)],o=s[e/32|0]>>>e&1,c=r[e/32|0]>>>e&1,u=n|a,h=((n|c)&l)+l^l|n|c;let d=a|~(h|l),p=l&h;d>>>31^o&&(s[e/32|0]^=1<<e),p>>>31^c&&(r[e/32|0]^=1<<e),d=d<<1|o,p=p<<1|c,l=p|~(u|d),a=d&u}for(let t=u;t<h;t++)i[e.charCodeAt(t)]=0}let u=0,h=-1;const d=32*c,p=Math.min(32,o-d)+d;for(let t=d;t<p;t++)i[e.charCodeAt(t)]|=1<<t;let m=o;for(let e=0;e<n;e++){const n=i[t.charCodeAt(e)],a=s[e/32|0]>>>e&1,l=r[e/32|0]>>>e&1,c=n|u,d=((n|l)&h)+h^h|n|l;let p=u|~(d|h),f=h&d;m+=p>>>o-1&1,m-=f>>>o-1&1,p>>>31^a&&(s[e/32|0]^=1<<e),f>>>31^l&&(r[e/32|0]^=1<<e),p=p<<1|a,f=f<<1|l,h=f|~(c|p),u=p&c}for(let t=d;t<p;t++)i[e.charCodeAt(t)]=0;return m})(e,t)}},3017:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var i=n(1354),o=n.n(i),r=n(6314),s=n.n(r)()(o());s.push([e.id,".monomer-lib-controls-form {\n margin-left: auto;\n margin-right: auto;\n display: flex;\n flex-direction: column;\n align-items: center;\n min-width: 220px;\n width: 100%;\n\n}\n","",{version:3,sources:["webpack://./src/utils/monomer-lib/library-file-manager/style.css"],names:[],mappings:"AAAA;EACE,iBAAiB;EACjB,kBAAkB;EAClB,aAAa;EACb,sBAAsB;EACtB,mBAAmB;EACnB,gBAAgB;EAChB,WAAW;;AAEb",sourcesContent:[".monomer-lib-controls-form {\n margin-left: auto;\n margin-right: auto;\n display: flex;\n flex-direction: column;\n align-items: center;\n min-width: 220px;\n width: 100%;\n\n}\n"],sourceRoot:""}]);const a=s},3025:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validateSchemaDeps=t.validatePropertyDeps=t.error=void 0;const i=n(9029),o=n(4227),r=n(5765);t.error={message:({params:{property:e,depsCount:t,deps:n}})=>{const o=1===t?"property":"properties";return i.str`must have ${o} ${n} when property ${e} is present`},params:({params:{property:e,depsCount:t,deps:n,missingProperty:o}})=>i._`{property: ${e},
|
|
5
5
|
missingProperty: ${o},
|
|
6
6
|
depsCount: ${t},
|
|
7
|
-
deps: ${n}}`};const s={keyword:"dependencies",type:"object",schemaType:"object",error:t.error,code(e){const[t,n]=function({schema:e}){const t={},n={};for(const i in e)"__proto__"!==i&&((Array.isArray(e[i])?t:n)[i]=e[i]);return[t,n]}(e);a(e,t),l(e,n)}};function a(e,t=e.schema){const{gen:n,data:o,it:s}=e;if(0===Object.keys(t).length)return;const a=n.let("missing");for(const l in t){const c=t[l];if(0===c.length)continue;const h=(0,r.propertyInData)(n,o,l,s.opts.ownProperties);e.setParams({property:l,depsCount:c.length,deps:c.join(", ")}),s.allErrors?n.if(h,()=>{for(const t of c)(0,r.checkReportMissingProp)(e,t)}):(n.if(i._`${h} && (${(0,r.checkMissingProp)(e,c,a)})`),(0,r.reportMissingProp)(e,a),n.else())}}function l(e,t=e.schema){const{gen:n,data:i,keyword:s,it:a}=e,l=n.name("valid");for(const c in t)(0,o.alwaysValidSchema)(a,t[c])||(n.if((0,r.propertyInData)(n,i,c,a.opts.ownProperties),()=>{const t=e.subschema({keyword:s,schemaProp:c},l);e.mergeValidEvaluated(t,l)},()=>n.var(l,!0)),e.ok(l))}t.validatePropertyDeps=a,t.validateSchemaDeps=l,t.default=s},3151:(e,t,n)=>{"use strict";n.d(t,{EK:()=>l,Ec:()=>r,f6:()=>i,pe:()=>s,q7:()=>a,yw:()=>o});const i=["symbol","molfile","rgroups","name"],o="MonomerName",r={monomerType:null,smiles:null,name:"Name",author:null,molfile:"molecule",naturalAnalog:"MonomerNaturalAnalogCode",rgroups:"MonomerCaps",createDate:null,id:null,polymerType:"MonomerType",symbol:"MonomerName"},s={monomerType:"Backbone",smiles:"",name:"",author:"Datagrok",molfile:"",naturalAnalog:"",rgroups:[],createDate:null,id:0,polymerType:"PEPTIDE",symbol:""},a="p",l=new RegExp(`[rd]\\((\\w)\\)${a}?`,"g")},3252:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dynamicRef=void 0;const i=n(9029),o=n(2023),r=n(3693),s={keyword:"$dynamicRef",schemaType:"string",code:e=>a(e,e.schema)};function a(e,t){const{gen:n,keyword:s,it:a}=e;if("#"!==t[0])throw new Error(`"${s}" only supports hash fragment reference`);const l=t.slice(1);if(a.allErrors)c();else{const t=n.let("valid",!1);c(t),e.ok(t)}function c(e){if(a.schemaEnv.root.dynamicAnchors[l]){const t=n.let("_v",i._`${o.default.dynamicAnchors}${(0,i.getProperty)(l)}`);n.if(t,h(t,e),h(a.validateName,e))}else h(a.validateName,e)()}function h(t,i){return i?()=>n.block(()=>{(0,r.callRef)(e,t),n.let(i,!0)}):()=>(0,r.callRef)(e,t)}}t.dynamicRef=a,t.default=s},3265:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(392),o=n(3445),r=[i.default,o.default];t.default=r},3282:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MissingRefError=t.ValidationError=t.CodeGen=t.Name=t.nil=t.stringify=t.str=t._=t.KeywordCxt=t.Ajv=void 0;const i=n(4042),o=n(6144),r=n(6653),s=n(2079),a=["/properties"],l="http://json-schema.org/draft-07/schema";class c extends i.default{_addVocabularies(){super._addVocabularies(),o.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(r.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const e=this.opts.$data?this.$dataMetaSchema(s,a):s;this.addMetaSchema(e,l,!1),this.refs["http://json-schema.org/schema"]=l}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(l)?l:void 0)}}t.Ajv=c,e.exports=t=c,e.exports.Ajv=c,Object.defineProperty(t,"__esModule",{value:!0}),t.default=c;var h=n(2586);Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return h.KeywordCxt}});var u=n(9029);Object.defineProperty(t,"_",{enumerable:!0,get:function(){return u._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return u.str}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return u.stringify}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return u.nil}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return u.Name}}),Object.defineProperty(t,"CodeGen",{enumerable:!0,get:function(){return u.CodeGen}});var d=n(3558);Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return d.default}});var p=n(4551);Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return p.default}})},3439:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:{message:({schemaCode:e})=>i.str`must be multiple of ${e}`,params:({schemaCode:e})=>i._`{multipleOf: ${e}}`},code(e){const{gen:t,data:n,schemaCode:o,it:r}=e,s=r.opts.multipleOfPrecision,a=t.let("res"),l=s?i._`Math.abs(Math.round(${a}) - ${a}) > 1e-${s}`:i._`${a} !== parseInt(${a})`;e.fail$data(i._`(${o} === 0 || (${a} = ${n}/${o}, ${l}))`)}};t.default=o},3445:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o=n(4227),r={keyword:"unevaluatedItems",type:"array",schemaType:["boolean","object"],error:{message:({params:{len:e}})=>i.str`must NOT have more than ${e} items`,params:({params:{len:e}})=>i._`{limit: ${e}}`},code(e){const{gen:t,schema:n,data:r,it:s}=e,a=s.items||0;if(!0===a)return;const l=t.const("len",i._`${r}.length`);if(!1===n)e.setParams({len:a}),e.fail(i._`${l} > ${a}`);else if("object"==typeof n&&!(0,o.alwaysValidSchema)(s,n)){const n=t.var("valid",i._`${l} <= ${a}`);t.if((0,i.not)(n),()=>function(n,r){t.forRange("i",r,l,r=>{e.subschema({keyword:"unevaluatedItems",dataProp:r,dataPropType:o.Type.Num},n),s.allErrors||t.if((0,i.not)(n),()=>t.break())})}(n,a)),e.ok(n)}s.items=!0}};t.default=r},3463:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};t.default=n},3516:(e,t,n)=>{"use strict";n.d(t,{m:()=>r});var i=n(6082),o=n(439);class r{get descriptionsArray(){return this._descriptionsArray}get sequencesArray(){return this._sequencesArray}parseMacromolecule(e,t){return this._fileContent.slice(e,t).split(/\s/).join("")}parseColumns(){const e=/^>(.*)$/gm;let t,n=0;for(;t=e.exec(this._fileContent);){const i=this._fileContent.substring(t.index+1,e.lastIndex);this._descriptionsArray.push(i),0!==n&&this._sequencesArray.push(this.parseMacromolecule(n,t.index)),n=e.lastIndex+1}this._sequencesArray.push(this.parseMacromolecule(n,-1))}importFasta(){const e=i.Column.fromStrings("description",this.descriptionsArray),t=i.Column.fromStrings("sequence",this.sequencesArray);return t.semType=i.SEMTYPE.MACROMOLECULE,t.meta.units=o.Hi.FASTA,[i.DataFrame.fromColumns([e,t])]}constructor(e){this._descriptionsArray=[],this._sequencesArray=[],this._fileContent=e,this.parseColumns()}}},3527:(e,t,n)=>{"use strict";n.d(t,{Mi:()=>i});class i extends Float32Array{}},3558:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});class n extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}}t.default=n},3561:(e,t,n)=>{"use strict";n.d(t,{Hb:()=>l,YN:()=>g,gU:()=>c});var i=n(8123),o=n(294),r=n(3151),s=n(439),a=n(6197);function l(e,t,n){const o=new Map;for(const a of e.getMonomerSymbolsByType(t)){const l=e.getMonomer(t,a);if("RNA"===t&&("Branch"===l.monomerType||n===s.YI.DNA&&l.symbol===i.u.DEOXYRIBOSE.symbol||n===s.YI.RNA&&l.symbol===i.u.RIBOSE.symbol||l.symbol===i.u.PHOSPHATE.symbol)||"PEPTIDE"===t&&"Branch"!==l.monomerType){const e={};r.f6.forEach(t=>{e[t]=l[t]}),o.set(a,e)}}return o}function c(e,t,n,r){if(0===e.length)return o.vF.createEmpty();const l=m,{atomCount:c,bondCount:u,needsCapping:p}=l(e,t,n,r),f=new Array(c),y=new Array(u);let b,v=null,w=null;"PEPTIDE"===r?b=h:(b=d,v=n===s.YI.DNA?(0,o.xb)(t,i.u.DEOXYRIBOSE):(0,o.xb)(t,i.u.RIBOSE),w=(0,o.xb)(t,i.u.PHOSPHATE));const C={i:0,nodeShift:0,bondShift:0,backbonePositionShift:new Array(2).fill(0),branchPositionShift:new Array(2).fill(0),backboneAttachNode:0,branchAttachNode:0,flipFactor:1},S={sugar:v,phosphate:w,seqLength:e.length,atomCount:c,bondCount:u},A=new o.Cg,x=[];let E,M=0;for(C.i=0;C.i<S.seqLength;++C.i){const n=e[C.i];if(n.symbol===s._S)continue;const i=(0,o.xb)(t,{symbol:n.symbol,polymerType:(0,a.Y)(n.biotype)});E=i.terminalR2Atom;const r=C.nodeShift,l=C.bondShift;b(i,f,y,C,S),i.stereoAtoms?.forEach(e=>x.push(e+M)),M+=i.atoms.x.length;const c=C.nodeShift-r,h=new Array(c);for(let e=0;e<c;++e)h[e]=r+e;const u=C.bondShift-l,d=new Array(u);for(let e=0;e<u;++e)d[e]=l+e;A.set(C.i,{biotype:n.biotype,symbol:n.symbol,atoms:h,bonds:d})}p&&function(e,t,n,o,r=i.u.OXYGEN){const s=n.nodeShift+1;e[o.atomCount]=i.u.V3K_BEGIN_DATA_LINE+s+" "+(r??i.u.OXYGEN)+" "+g(n.backbonePositionShift[0])+" "+n.flipFactor*g(n.backbonePositionShift[1])+" 0.000000 0\n";const a=n.backboneAttachNode,l=s;t[o.bondCount]=i.u.V3K_BEGIN_DATA_LINE+n.bondShift+" 1 "+a+" "+l+"\n"}(f,y,C,S,E??i.u.OXYGEN);const T=i.u.V3K_BEGIN_COUNTS_LINE+c+" "+u+i.u.V3K_COUNTS_LINE_ENDING;let _="";return _+=i.u.V3K_HEADER_FIRST_LINE,_+=i.u.V3K_HEADER_SECOND_LINE,_+=i.u.V3K_BEGIN_CTAB_BLOCK,_+=T,_+=i.u.V3K_BEGIN_ATOM_BLOCK,_+=f.join(""),_+=i.u.V3K_END_ATOM_BLOCK,_+=i.u.V3K_BEGIN_BOND_BLOCK,_+=y.join(""),_+=i.u.V3K_END_BOND_BLOCK,x.length>0&&(_+=function(e){const t=[];let n=`M V30 MDLV30/STEABS ATOMS=(${e.length}`;for(let i=0;i<e.length;i++){const o=`${n} ${e[i]}`;o.length>76?(t.push(`${n} -\n`),n=`M V30 ${e[i]}`):n=o,i===e.length-1&&t.push(`${n})\n`)}return`M V30 BEGIN COLLECTION\n${t.join("")}M V30 END COLLECTION\n`}(x)),_+=i.u.V3K_END_CTAB_BLOCK,_+=i.u.V3K_END,{molfile:_,monomers:A}}function h(e,t,n,i){i.flipFactor=(-1)**(i.i%2),u(e,t,n,i)}function u(e,t,n,o){!function(e,t,n){for(let o=0;o<e.atoms.atomTypes.length;++o){const r=n.nodeShift+o+1;t[n.nodeShift+o]=i.u.V3K_BEGIN_DATA_LINE+r+" "+e.atoms.atomTypes[o]+" "+g(n.backbonePositionShift[0]+e.atoms.x[o])+" "+g(n.backbonePositionShift[1]+n.flipFactor*e.atoms.y[o])+" "+e.atoms.kwargs[o]}}(e,t,o),p(e,n,o),function(e,t,n){if(0!==n.backboneAttachNode){const o=n.bondShift,r=n.backboneAttachNode,s=e.meta.terminalNodes[0]+n.nodeShift;t[n.bondShift-1]=i.u.V3K_BEGIN_DATA_LINE+o+" 1 "+r+" "+s+"\n"}}(e,n,o),null!==e.meta.branchShift&&e.meta.terminalNodes.length>2&&function(e,t){t.branchAttachNode=t.nodeShift+e.meta.terminalNodes[2];for(let n=0;n<2;++n)t.branchPositionShift[n]=t.backbonePositionShift[n]+e.meta.branchShift[n]}(e,o),function(e,t){t.backboneAttachNode=t.nodeShift+e.meta.terminalNodes[1],t.bondShift+=e.bonds.atomPairs.length+1,t.nodeShift+=e.atoms.atomTypes.length,t.backbonePositionShift[0]+=e.meta.backboneShift?.[0]??0,t.backbonePositionShift[1]+=t.flipFactor*(e.meta.backboneShift?.[1]??0)}(e,o)}function d(e,t,n,o,r){if(0===o.i)u(r.sugar,t,n,o);else for(const e of[r.phosphate,r.sugar])u(e,t,n,o);!function(e,t,n,o){(function(e,t,n){for(let o=0;o<e.atoms.atomTypes.length;++o){const r=n.nodeShift+o+1;t[n.nodeShift+o]=i.u.V3K_BEGIN_DATA_LINE+r+" "+e.atoms.atomTypes[o]+" "+g(n.branchPositionShift[0]+e.atoms.x[o])+" "+g(n.branchPositionShift[1]+n.flipFactor*e.atoms.y[o])+" "+e.atoms.kwargs[o]}})(e,t,o),p(e,n,o),function(e,t,n){const o=n.bondShift,r=n.branchAttachNode,s=e.meta.terminalNodes[0]+n.nodeShift;t[o-1]=i.u.V3K_BEGIN_DATA_LINE+o+" 1 "+r+" "+s+"\n"}(e,n,o);const r=o.bondShift,s=o.branchAttachNode,a=e.meta.terminalNodes[0]+o.nodeShift;n[r-1]=i.u.V3K_BEGIN_DATA_LINE+r+" 1 "+s+" "+a+"\n",o.bondShift+=e.bonds.atomPairs.length+1,o.nodeShift+=e.atoms.atomTypes.length}(e,t,n,o)}function p(e,t,n){for(let o=0;o<e.bonds.atomPairs.length;++o){const r=n.bondShift+o+1,s=e.bonds.atomPairs[o][0]+n.nodeShift,a=e.bonds.atomPairs[o][1]+n.nodeShift;let l="";if(e.bonds.bondConfiguration.has(o)){let t=e.bonds.bondConfiguration.get(o);n.flipFactor<0&&(t=1===t?3:1),l=" CFG="+t}const c=e.bonds.kwargs.has(o)?" "+e.bonds.kwargs.get(o):"";t[n.bondShift+o]=i.u.V3K_BEGIN_DATA_LINE+r+" "+e.bonds.bondTypes[o]+" "+s+" "+a+l+c+"\n"}}function m(e,t,n,r){let l=0,c=0,h=0,u=!0,d=null;for(const n of e)if(n.symbol!==s._S){if("*"==n.symbol)throw new Error("Gap canonical symbol is '', not '*");d=(0,o.xb)(t,{symbol:n.symbol,polymerType:(0,a.Y)(n.biotype)}),l+=d.atoms.x.length,c+=d.bonds.bondTypes.length,h++}if("PEPTIDE"===r)l+=1,c+=h,h>0&&((d?.meta?.rNodes?.length??0)<2||d?.terminalR2Atom?.toLowerCase()===i.u.HYDROGEN.toLowerCase())&&(u=!1,l-=1,c-=1);else{const r=n===s.YI.DNA?(0,o.xb)(t,i.u.DEOXYRIBOSE):(0,o.xb)(t,i.u.RIBOSE),a=(0,o.xb)(t,i.u.PHOSPHATE);l+=(e.length-1)*a.atoms.x.length,l+=e.length*r.atoms.x.length,l+=1,c+=(e.length-1)*a.bonds.bondTypes.length,c+=e.length*r.bonds.bondTypes.length,c-=1,c+=3*e.length}return{atomCount:l,bondCount:c,needsCapping:u}}function g(e){return Math.round(i.u.PRECISION_FACTOR*e)/i.u.PRECISION_FACTOR}},3599:(e,t,n)=>{"use strict";n.d(t,{o:()=>i.o});var i=n(6869)},3629:(e,t,n)=>{"use strict";n.d(t,{KE:()=>a,S8:()=>l,dC:()=>r,vA:()=>o,wQ:()=>s});var i=n(3527);function o(e=!1,t="Assertion error."){if(!e)throw new Error(t)}function r(e,t,n=1){const r=e.length;o(r==t.length,"Vector lengths do not match.");const s=new i.Mi(r);for(let i=0;i<e.length;++i)s[i]=e[i]+n*t[i];return s}function s(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n]*e[n];return Math.sqrt(t)}function a(e,t){if(e.length!=t.length)throw new Error("The dimensionality of the vectors must match");let n=0;for(let i=0;i<e.length;i++)n+=e[i]*t[i];return n}function l(e){const t=e.length;let n=0,i=0;for(let o=0;o<t;++o)n+=e[o],i+=Math.pow(e[o],2);const o=n/t,r=1/Math.sqrt(i/t-Math.pow(o,2));for(let n=0;n<t;++n)e[n]=(e[n]-o)*r;return e}},3673:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validateKeywordUsage=t.validSchemaType=t.funcKeywordCode=t.macroKeywordCode=void 0;const i=n(9029),o=n(2023),r=n(5765),s=n(8708);function a(e){const{gen:t,data:n,it:o}=e;t.if(o.parentData,()=>t.assign(n,i._`${o.parentData}[${o.parentDataProperty}]`))}function l(e,t,n){if(void 0===n)throw new Error(`keyword "${t}" failed to compile`);return e.scopeValue("keyword","function"==typeof n?{ref:n}:{ref:n,code:(0,i.stringify)(n)})}t.macroKeywordCode=function(e,t){const{gen:n,keyword:o,schema:r,parentSchema:s,it:a}=e,c=t.macro.call(a.self,r,s,a),h=l(n,o,c);!1!==a.opts.validateSchema&&a.self.validateSchema(c,!0);const u=n.name("valid");e.subschema({schema:c,schemaPath:i.nil,errSchemaPath:`${a.errSchemaPath}/${o}`,topSchemaRef:h,compositeRule:!0},u),e.pass(u,()=>e.error(!0))},t.funcKeywordCode=function(e,t){var n;const{gen:c,keyword:h,schema:u,parentSchema:d,$data:p,it:m}=e;!function({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}(m,t);const g=!p&&t.compile?t.compile.call(m.self,u,d,m):t.validate,f=l(c,h,g),y=c.let("valid");function b(n=(t.async?i._`await `:i.nil)){const s=m.opts.passContext?o.default.this:o.default.self,a=!("compile"in t&&!p||!1===t.schema);c.assign(y,i._`${n}${(0,r.callValidateCode)(e,f,s,a)}`,t.modifying)}function v(e){var n;c.if((0,i.not)(null!==(n=t.valid)&&void 0!==n?n:y),e)}e.block$data(y,function(){if(!1===t.errors)b(),t.modifying&&a(e),v(()=>e.error());else{const n=t.async?function(){const e=c.let("ruleErrs",null);return c.try(()=>b(i._`await `),t=>c.assign(y,!1).if(i._`${t} instanceof ${m.ValidationError}`,()=>c.assign(e,i._`${t}.errors`),()=>c.throw(t))),e}():function(){const e=i._`${f}.errors`;return c.assign(e,null),b(i.nil),e}();t.modifying&&a(e),v(()=>function(e,t){const{gen:n}=e;n.if(i._`Array.isArray(${t})`,()=>{n.assign(o.default.vErrors,i._`${o.default.vErrors} === null ? ${t} : ${o.default.vErrors}.concat(${t})`).assign(o.default.errors,i._`${o.default.vErrors}.length`),(0,s.extendErrors)(e)},()=>e.error())}(e,n))}}),e.ok(null!==(n=t.valid)&&void 0!==n?n:y)},t.validSchemaType=function(e,t,n=!1){return!t.length||t.some(t=>"array"===t?Array.isArray(e):"object"===t?e&&"object"==typeof e&&!Array.isArray(e):typeof e==t||n&&void 0===e)},t.validateKeywordUsage=function({schema:e,opts:t,self:n,errSchemaPath:i},o,r){if(Array.isArray(o.keyword)?!o.keyword.includes(r):o.keyword!==r)throw new Error("ajv implementation error");const s=o.dependencies;if(null==s?void 0:s.some(t=>!Object.prototype.hasOwnProperty.call(e,t)))throw new Error(`parent schema must have dependencies of ${r}: ${s.join(",")}`);if(o.validateSchema&&!o.validateSchema(e[r])){const e=`keyword "${r}" value is invalid at path "${i}": `+n.errorsText(o.validateSchema.errors);if("log"!==t.validateSchema)throw new Error(e);n.logger.error(e)}}},3693:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.callRef=t.getValidate=void 0;const i=n(4551),o=n(5765),r=n(9029),s=n(2023),a=n(3835),l=n(4227),c={keyword:"$ref",schemaType:"string",code(e){const{gen:t,schema:n,it:o}=e,{baseId:s,schemaEnv:l,validateName:c,opts:d,self:p}=o,{root:m}=l;if(("#"===n||"#/"===n)&&s===m.baseId)return function(){if(l===m)return u(e,c,l,l.$async);const n=t.scopeValue("root",{ref:m});return u(e,r._`${n}.validate`,m,m.$async)}();const g=a.resolveRef.call(p,m,s,n);if(void 0===g)throw new i.default(o.opts.uriResolver,s,n);return g instanceof a.SchemaEnv?function(t){const n=h(e,t);u(e,n,t,t.$async)}(g):function(i){const o=t.scopeValue("schema",!0===d.code.source?{ref:i,code:(0,r.stringify)(i)}:{ref:i}),s=t.name("valid"),a=e.subschema({schema:i,dataTypes:[],schemaPath:r.nil,topSchemaRef:o,errSchemaPath:n},s);e.mergeEvaluated(a),e.ok(s)}(g)}};function h(e,t){const{gen:n}=e;return t.validate?n.scopeValue("validate",{ref:t.validate}):r._`${n.scopeValue("wrapper",{ref:t})}.validate`}function u(e,t,n,i){const{gen:a,it:c}=e,{allErrors:h,schemaEnv:u,opts:d}=c,p=d.passContext?s.default.this:r.nil;function m(e){const t=r._`${e}.errors`;a.assign(s.default.vErrors,r._`${s.default.vErrors} === null ? ${t} : ${s.default.vErrors}.concat(${t})`),a.assign(s.default.errors,r._`${s.default.vErrors}.length`)}function g(e){var t;if(!c.opts.unevaluated)return;const i=null===(t=null==n?void 0:n.validate)||void 0===t?void 0:t.evaluated;if(!0!==c.props)if(i&&!i.dynamicProps)void 0!==i.props&&(c.props=l.mergeEvaluated.props(a,i.props,c.props));else{const t=a.var("props",r._`${e}.evaluated.props`);c.props=l.mergeEvaluated.props(a,t,c.props,r.Name)}if(!0!==c.items)if(i&&!i.dynamicItems)void 0!==i.items&&(c.items=l.mergeEvaluated.items(a,i.items,c.items));else{const t=a.var("items",r._`${e}.evaluated.items`);c.items=l.mergeEvaluated.items(a,t,c.items,r.Name)}}i?function(){if(!u.$async)throw new Error("async schema referenced by sync schema");const n=a.let("valid");a.try(()=>{a.code(r._`await ${(0,o.callValidateCode)(e,t,p)}`),g(t),h||a.assign(n,!0)},e=>{a.if(r._`!(${e} instanceof ${c.ValidationError})`,()=>a.throw(e)),m(e),h||a.assign(n,!1)}),e.ok(n)}():e.result((0,o.callValidateCode)(e,t,p),()=>g(t),()=>m(t))}t.getValidate=h,t.callRef=u,t.default=c},3799:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(3252),o={keyword:"$recursiveRef",schemaType:"string",code:e=>(0,i.dynamicRef)(e,e.schema)};t.default=o},3835:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.resolveSchema=t.getCompilingSchema=t.resolveRef=t.compileSchema=t.SchemaEnv=void 0;const i=n(9029),o=n(3558),r=n(2023),s=n(6939),a=n(4227),l=n(2586);class c{constructor(e){var t;let n;this.refs={},this.dynamicAnchors={},"object"==typeof e.schema&&(n=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=null!==(t=e.baseId)&&void 0!==t?t:(0,s.normalizeId)(null==n?void 0:n[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=null==n?void 0:n.$async,this.refs={}}}function h(e){const t=d.call(this,e);if(t)return t;const n=(0,s.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:a,lines:c}=this.opts.code,{ownProperties:h}=this.opts,u=new i.CodeGen(this.scope,{es5:a,lines:c,ownProperties:h});let p;e.$async&&(p=u.scopeValue("Error",{ref:o.default,code:i._`require("ajv/dist/runtime/validation_error").default`}));const m=u.scopeName("validate");e.validateName=m;const g={gen:u,allErrors:this.opts.allErrors,data:r.default.data,parentData:r.default.parentData,parentDataProperty:r.default.parentDataProperty,dataNames:[r.default.data],dataPathArr:[i.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:u.scopeValue("schema",!0===this.opts.code.source?{ref:e.schema,code:(0,i.stringify)(e.schema)}:{ref:e.schema}),validateName:m,ValidationError:p,schema:e.schema,schemaEnv:e,rootId:n,baseId:e.baseId||n,schemaPath:i.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:i._`""`,opts:this.opts,self:this};let f;try{this._compilations.add(e),(0,l.validateFunctionCode)(g),u.optimize(this.opts.code.optimize);const t=u.toString();f=`${u.scopeRefs(r.default.scope)}return ${t}`,this.opts.code.process&&(f=this.opts.code.process(f,e));const n=new Function(`${r.default.self}`,`${r.default.scope}`,f)(this,this.scope.get());if(this.scope.value(m,{ref:n}),n.errors=null,n.schema=e.schema,n.schemaEnv=e,e.$async&&(n.$async=!0),!0===this.opts.code.source&&(n.source={validateName:m,validateCode:t,scopeValues:u._values}),this.opts.unevaluated){const{props:e,items:t}=g;n.evaluated={props:e instanceof i.Name?void 0:e,items:t instanceof i.Name?void 0:t,dynamicProps:e instanceof i.Name,dynamicItems:t instanceof i.Name},n.source&&(n.source.evaluated=(0,i.stringify)(n.evaluated))}return e.validate=n,e}catch(t){throw delete e.validate,delete e.validateName,f&&this.logger.error("Error compiling schema, function code:",f),t}finally{this._compilations.delete(e)}}function u(e){return(0,s.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:h.call(this,e)}function d(e){for(const t of this._compilations)if(p(t,e))return t}function p(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function m(e,t){let n;for(;"string"==typeof(n=this.refs[t]);)t=n;return n||this.schemas[t]||g.call(this,e,t)}function g(e,t){const n=this.opts.uriResolver.parse(t),i=(0,s._getFullPath)(this.opts.uriResolver,n);let o=(0,s.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&i===o)return y.call(this,n,e);const r=(0,s.normalizeId)(i),a=this.refs[r]||this.schemas[r];if("string"==typeof a){const t=g.call(this,e,a);if("object"!=typeof(null==t?void 0:t.schema))return;return y.call(this,n,t)}if("object"==typeof(null==a?void 0:a.schema)){if(a.validate||h.call(this,a),r===(0,s.normalizeId)(t)){const{schema:t}=a,{schemaId:n}=this.opts,i=t[n];return i&&(o=(0,s.resolveUrl)(this.opts.uriResolver,o,i)),new c({schema:t,schemaId:n,root:e,baseId:o})}return y.call(this,n,a)}}t.SchemaEnv=c,t.compileSchema=h,t.resolveRef=function(e,t,n){var i;n=(0,s.resolveUrl)(this.opts.uriResolver,t,n);const o=e.refs[n];if(o)return o;let r=m.call(this,e,n);if(void 0===r){const o=null===(i=e.localRefs)||void 0===i?void 0:i[n],{schemaId:s}=this.opts;o&&(r=new c({schema:o,schemaId:s,root:e,baseId:t}))}return void 0!==r?e.refs[n]=u.call(this,r):void 0},t.getCompilingSchema=d,t.resolveSchema=g;const f=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function y(e,{baseId:t,schema:n,root:i}){var o;if("/"!==(null===(o=e.fragment)||void 0===o?void 0:o[0]))return;for(const i of e.fragment.slice(1).split("/")){if("boolean"==typeof n)return;const e=n[(0,a.unescapeFragment)(i)];if(void 0===e)return;const o="object"==typeof(n=e)&&n[this.opts.schemaId];!f.has(i)&&o&&(t=(0,s.resolveUrl)(this.opts.uriResolver,t,o))}let r;if("boolean"!=typeof n&&n.$ref&&!(0,a.schemaHasRulesButRef)(n,this.RULES)){const e=(0,s.resolveUrl)(this.opts.uriResolver,t,n.$ref);r=g.call(this,i,e)}const{schemaId:l}=this.opts;return r=r||new c({schema:n,schemaId:l,root:i,baseId:t}),r.schema!==r.root.schema?r:void 0}},3837:e=>{"use strict";e.exports=JSON.parse('{"$id":"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#","description":"Meta-schema for $data reference (JSON AnySchema extension proposal)","type":"object","required":["$data"],"properties":{"$data":{"type":"string","anyOf":[{"format":"relative-json-pointer"},{"format":"json-pointer"}]}},"additionalProperties":false}')},3853:(e,t)=>{"use strict";function n(e){const t=e.length;let n,i=0,o=0;for(;o<t;)i++,n=e.charCodeAt(o++),n>=55296&&n<=56319&&o<t&&(n=e.charCodeAt(o),56320==(64512&n)&&o++);return i}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n,n.code='require("ajv/dist/runtime/ucs2length").default'},3856:(e,t,n)=>{"use strict";n.d(t,{Mn:()=>h,gp:()=>c,oZ:()=>p,yg:()=>u});var i=n(6082),o=n(7278);const r="rgb(100,100,100)",s="#808080",a="rgb(0,0,0)",l=o.zS;var c,h,u;!function(e){e.maxMonomerLength=".mm.cellRenderer.maxMonomerLength"}(c||(c={})),function(e){e.applyToBackground=".m.cellRenderer.applyToBackground"}(h||(h={})),function(e){e.MSA="MSA",e.classic="classic"}(u||(u={}));const d=new class{constructor(){this.color=r,this.pivot=0,this.left=!1,this.transparencyRate=0,this.separator="",this.last=!1,this.drawStyle=u.classic,this.maxWord=[],this.wordIdx=0,this.gridCell=null,this.referenceSequence=null,this.maxLengthOfMonomer=null,this.monomerTextSizeMap={},this.logger=void 0,this.selectedPosition=void 0,this.isMultiLineContext=!1,this.lineNumber=0}};function p(e,t,n,o,c,h,p){var m,g,f;const y={...d,...p};if(y.isMultiLineContext){e.textBaseline="middle",e.textAlign="center";let i=t;null!=y.maxLengthOfMonomer&&(i=l(i,y.maxLengthOfMonomer));const s=Math.max(.1,1-(y.transparencyRate??0));e.globalAlpha=s;const u=e.measureText(i),d=u.fontBoundingBoxAscent+u.fontBoundingBoxDescent,p=o+(h-d)/2+u.fontBoundingBoxAscent;let m=y.color??r;return m&&m!==r||(m=a),e.fillStyle=m,y.selectedPosition===y.wordIdx+1&&(e.save(),e.fillStyle="rgba(60, 177, 115, 0.2)",e.fillRect(n,o,c,h),e.restore(),e.fillStyle=m),e.fillText(i,n+c/2,p),e.globalAlpha=1,e.textBaseline="top",e.textAlign="start",n+c}p.logger?.debug("Bio: printLeftOrCentered(), start"),e.textAlign="start";let b=t.substring(0),v=y.last?"":y.separator;y.drawStyle===u.MSA&&(v="");let w=!0,C=!0,S="difference";if(null!=y.gridCell&&null!=y.gridCell.cell.column&&(w=y.gridCell.cell.column.temp["color-code"]??!0,C=y.gridCell.cell.column.temp["compare-with-current"]??!0,S=y.gridCell.cell.column.temp["highlight-difference"]??"difference"),y.referenceSequence){const e=y.referenceSequence[y.wordIdx];C&&y.referenceSequence.length>0&&"difference"===S&&(y.transparencyRate=b==e?.7:y.transparencyRate),C&&y.referenceSequence.length>0&&"equal"===S&&(y.transparencyRate=b!=e?.7:y.transparencyRate)}null!=y.maxLengthOfMonomer&&(b=l(b,y.maxLengthOfMonomer));const A=b+v;(m=y.monomerTextSizeMap)[A]??(m[A]=e.measureText(A));let x=y.monomerTextSizeMap[A];(g=y.monomerTextSizeMap)[b]??(g[b]=e.measureText(b));let E=y.monomerTextSizeMap[b].width;const M=h/2-(x.fontBoundingBoxAscent+x.fontBoundingBoxDescent)/2+1;(f=y.monomerTextSizeMap)[v]??(f[v]=e.measureText(v));const T=y.monomerTextSizeMap[v].width;function _(t,r){let l=w?y.color:a;y.selectedPosition===y.wordIdx+1&&(e.fillStyle="rgba(60, 177, 115, 0.2)",e.fillRect(n+t-4,o-5,y.monomerTextSizeMap[b].width+8,h+10),l=i.Color.toHtml(i.Color.setAlpha(i.Color.fromHtml(l),255))),e.fillStyle=l,e.globalAlpha=1-y.transparencyRate,y.drawStyle===u.classic&&(e.fillText(b,n+t,o+M),e.fillStyle=s,e.fillText(v,n+r,o+M)),y.drawStyle===u.MSA&&e.fillText(b,n+t,o+M),e.globalAlpha=1}x=x.width,y.drawStyle===u.MSA&&(E=y.maxWord[y.wordIdx],x=y.maxWord[y.wordIdx]);const I=(y.maxWord[y.wordIdx]??0)-(y.maxWord[0]??0);if(y.left||x>c)return _(I,I+E),n+I+E+T;{const e=(c-x)/2;return _(e,e+E),n+I+e+E}}},3890:(e,t,n)=>{"use strict";n.d(t,{TE:()=>h});var i=n(6082),o=n(7389),r=n(4328),s=n(1991),a=n.n(s),l=n(2020);const c=60;function h(){const e=r.shell.tv.grid,t=e.dataFrame,n=a().count(0).take(t.columns.length).map(e=>t.columns.byIndex(e)).filter(e=>e.semType!==i.SEMTYPE.MACROMOLECULE).toArray().find(e=>-1!==e.name.toLowerCase().indexOf("id")),s=n?[n]:[],h=o.input.columns("Seq id columns",{table:t,value:s,filter:e=>e.semType!==i.SEMTYPE.MACROMOLECULE}),d=a().count(0).take(t.columns.length).map(e=>t.columns.byIndex(e)).filter(e=>!(!e||e.semType!==i.SEMTYPE.MACROMOLECULE)&&l._package.seqHelper.getSeqHandler(e).isFasta()).toArray(),p=d.length>0?d[0]:null,m=o.input.column("Seq column",{table:t,value:p,filter:e=>!(!e||e.semType!==i.SEMTYPE.MACROMOLECULE)&&l._package.seqHelper.getSeqHandler(e).isFasta()}),g=o.input.int("FASTA line width",{value:c});o.dialog({title:"Save as FASTA"}).add(o.inputs([h,m,g])).onOK(()=>{const t=h.value??[],n=m.value??null,i=g.value??c;n||r.shell.warning("Seq column is mandatory to save as FASTA.");const o=function(e,t,n=c,i="\n"){const o=[];for(let r=0;r<t.length;r++){const s=e.map(e=>e.get(r).toString()).join("|"),a=u(t.getSplitted(r),n);o.push(`>${s}${i}`);for(const e of a)o.push(`${e}${i}`)}return"".concat(...o)}(t,l._package.seqHelper.getSeqHandler(n),i),s=document.createElement("a");s.setAttribute("href",`data:text/plain;charset=utf-8,${encodeURIComponent(o)}`),s.setAttribute("download",`${e.dataFrame.name}.fasta`),s.click()}).show()}function u(e,t=c){let n=0;const i=e.length,o=[];for(;n<i;){const i=a().count(n).take(Math.min(e.length-n,t)).map(t=>e.getOriginal(t)).toArray(),r=i.map(e=>e.length>1?`[${e}]`:e).reduce((e,t)=>e+t,"");o.push(r),n+=i.length}return o}},3966:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o=n(4227),r=n(5765),s=n(5457),a={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:{message:({params:{len:e}})=>i.str`must NOT have more than ${e} items`,params:({params:{len:e}})=>i._`{limit: ${e}}`},code(e){const{schema:t,parentSchema:n,it:i}=e,{prefixItems:a}=n;i.items=!0,(0,o.alwaysValidSchema)(i,t)||(a?(0,s.validateAdditionalItems)(e,a):e.ok((0,r.validateArray)(e)))}};t.default=a},4003:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(5765),o=n(9029),r=n(4227),s={keyword:"required",type:"object",schemaType:"array",$data:!0,error:{message:({params:{missingProperty:e}})=>o.str`must have required property '${e}'`,params:({params:{missingProperty:e}})=>o._`{missingProperty: ${e}}`},code(e){const{gen:t,schema:n,schemaCode:s,data:a,$data:l,it:c}=e,{opts:h}=c;if(!l&&0===n.length)return;const u=n.length>=h.loopRequired;if(c.allErrors?function(){if(u||l)e.block$data(o.nil,d);else for(const t of n)(0,i.checkReportMissingProp)(e,t)}():function(){const r=t.let("missing");if(u||l){const n=t.let("valid",!0);e.block$data(n,()=>function(n,r){e.setParams({missingProperty:n}),t.forOf(n,s,()=>{t.assign(r,(0,i.propertyInData)(t,a,n,h.ownProperties)),t.if((0,o.not)(r),()=>{e.error(),t.break()})},o.nil)}(r,n)),e.ok(n)}else t.if((0,i.checkMissingProp)(e,n,r)),(0,i.reportMissingProp)(e,r),t.else()}(),h.strictRequired){const t=e.parentSchema.properties,{definedProperties:i}=e.it;for(const e of n)if(void 0===(null==t?void 0:t[e])&&!i.has(e)){const t=`required property "${e}" is not defined at "${c.schemaEnv.baseId+c.errSchemaPath}" (strictRequired)`;(0,r.checkStrictMode)(c,t,c.opts.strictRequired)}}function d(){t.forOf("prop",s,n=>{e.setParams({missingProperty:n}),t.if((0,i.noPropertyInData)(t,a,n,h.ownProperties),()=>e.error())})}}};t.default=s},4025:(e,t,n)=>{"use strict";n.d(t,{C:()=>a,j:()=>s});var i=n(6082),o=n(439),r=n(7278);const s=new class{constructor(){this.seqHandler="seq-handler",this.notationProvider="seq-handler.notation-provider"}};class a extends i.SemanticValue{get value(){return this.seqHandler.column.get(this.rowIdx)}set value(e){this.seqHandler.column.set(this.rowIdx,e)}get helm(){return this.seqHandler.getHelm(this.rowIdx)}isDna(){return this.seqHandler.alphabet===o.YI.DNA}isRna(){return this.seqHandler.alphabet===o.YI.RNA}isNaturalPeptide(){return this.seqHandler.alphabet===o.YI.PT}isHelm(){return this.seqHandler.isHelm()}constructor(e,t){if(null==t.column.dataFrame)throw new Error("Attribute .dataFrame is required for SeqValueBase from cell");const n=t.column.dataFrame.cell(e,t.column.name);super(i.SemanticValue.fromTableCell(n).dart),this.rowIdx=e,this.seqHandler=t}getSplitted(){return this.seqHandler.getSplitted(this.rowIdx)}getSplittedWithSugarsAndPhosphates(){if(!this.isDna()&&!this.isRna())return this.getSplitted();const e=(0,r.qp)(this.helm),t=[],n=/\(|\)/;for(let i=0;i<e.length;i++){const o=e.getOriginal(i),r=o.split(n).filter(e=>!!e);3===r.length?(t.push(r[0]),t.push(r[1]),t.push(r[2])):t.push(o)}return new r.Mu(t,this.seqHandler.defaultGapOriginal)}}},4042:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CodeGen=t.Name=t.nil=t.stringify=t.str=t._=t.KeywordCxt=void 0;var i=n(2586);Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return i.KeywordCxt}});var o=n(9029);Object.defineProperty(t,"_",{enumerable:!0,get:function(){return o._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return o.str}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return o.stringify}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return o.nil}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return o.Name}}),Object.defineProperty(t,"CodeGen",{enumerable:!0,get:function(){return o.CodeGen}});const r=n(3558),s=n(4551),a=n(396),l=n(3835),c=n(9029),h=n(6939),u=n(208),d=n(4227),p=n(3837),m=n(5944),g=(e,t)=>new RegExp(e,t);g.code="new RegExp";const f=["removeAdditional","useDefaults","coerceTypes"],y=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),b={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},v={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'};function w(e){var t,n,i,o,r,s,a,l,c,h,u,d,p,f,y,b,v,w,C,S,A,x,E,M,T;const _=e.strict,I=null===(t=e.code)||void 0===t?void 0:t.optimize,L=!0===I||void 0===I?1:I||0,N=null!==(i=null===(n=e.code)||void 0===n?void 0:n.regExp)&&void 0!==i?i:g,P=null!==(o=e.uriResolver)&&void 0!==o?o:m.default;return{strictSchema:null===(s=null!==(r=e.strictSchema)&&void 0!==r?r:_)||void 0===s||s,strictNumbers:null===(l=null!==(a=e.strictNumbers)&&void 0!==a?a:_)||void 0===l||l,strictTypes:null!==(h=null!==(c=e.strictTypes)&&void 0!==c?c:_)&&void 0!==h?h:"log",strictTuples:null!==(d=null!==(u=e.strictTuples)&&void 0!==u?u:_)&&void 0!==d?d:"log",strictRequired:null!==(f=null!==(p=e.strictRequired)&&void 0!==p?p:_)&&void 0!==f&&f,code:e.code?{...e.code,optimize:L,regExp:N}:{optimize:L,regExp:N},loopRequired:null!==(y=e.loopRequired)&&void 0!==y?y:200,loopEnum:null!==(b=e.loopEnum)&&void 0!==b?b:200,meta:null===(v=e.meta)||void 0===v||v,messages:null===(w=e.messages)||void 0===w||w,inlineRefs:null===(C=e.inlineRefs)||void 0===C||C,schemaId:null!==(S=e.schemaId)&&void 0!==S?S:"$id",addUsedSchema:null===(A=e.addUsedSchema)||void 0===A||A,validateSchema:null===(x=e.validateSchema)||void 0===x||x,validateFormats:null===(E=e.validateFormats)||void 0===E||E,unicodeRegExp:null===(M=e.unicodeRegExp)||void 0===M||M,int32range:null===(T=e.int32range)||void 0===T||T,uriResolver:P}}class C{constructor(e={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...w(e)};const{es5:t,lines:n}=this.opts.code;this.scope=new c.ValueScope({scope:{},prefixes:y,es5:t,lines:n}),this.logger=function(e){if(!1===e)return _;if(void 0===e)return console;if(e.log&&e.warn&&e.error)return e;throw new Error("logger must implement log, warn and error methods")}(e.logger);const i=e.validateFormats;e.validateFormats=!1,this.RULES=(0,a.getRules)(),S.call(this,b,e,"NOT SUPPORTED"),S.call(this,v,e,"DEPRECATED","warn"),this._metaOpts=T.call(this),e.formats&&E.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&M.call(this,e.keywords),"object"==typeof e.meta&&this.addMetaSchema(e.meta),x.call(this),e.validateFormats=i}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:e,meta:t,schemaId:n}=this.opts;let i=p;"id"===n&&(i={...p},i.id=i.$id,delete i.$id),t&&e&&this.addMetaSchema(i,i[n],!1)}defaultMeta(){const{meta:e,schemaId:t}=this.opts;return this.opts.defaultMeta="object"==typeof e?e[t]||e:void 0}validate(e,t){let n;if("string"==typeof e){if(n=this.getSchema(e),!n)throw new Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);const i=n(t);return"$async"in n||(this.errors=n.errors),i}compile(e,t){const n=this._addSchema(e,t);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,t){if("function"!=typeof this.opts.loadSchema)throw new Error("options.loadSchema should be a function");const{loadSchema:n}=this.opts;return i.call(this,e,t);async function i(e,t){await o.call(this,e.$schema);const n=this._addSchema(e,t);return n.validate||r.call(this,n)}async function o(e){e&&!this.getSchema(e)&&await i.call(this,{$ref:e},!0)}async function r(e){try{return this._compileSchemaEnv(e)}catch(t){if(!(t instanceof s.default))throw t;return a.call(this,t),await l.call(this,t.missingSchema),r.call(this,e)}}function a({missingSchema:e,missingRef:t}){if(this.refs[e])throw new Error(`AnySchema ${e} is loaded but ${t} cannot be resolved`)}async function l(e){const n=await c.call(this,e);this.refs[e]||await o.call(this,n.$schema),this.refs[e]||this.addSchema(n,e,t)}async function c(e){const t=this._loading[e];if(t)return t;try{return await(this._loading[e]=n(e))}finally{delete this._loading[e]}}}addSchema(e,t,n,i=this.opts.validateSchema){if(Array.isArray(e)){for(const t of e)this.addSchema(t,void 0,n,i);return this}let o;if("object"==typeof e){const{schemaId:t}=this.opts;if(o=e[t],void 0!==o&&"string"!=typeof o)throw new Error(`schema ${t} must be string`)}return t=(0,h.normalizeId)(t||o),this._checkUnique(t),this.schemas[t]=this._addSchema(e,n,t,i,!0),this}addMetaSchema(e,t,n=this.opts.validateSchema){return this.addSchema(e,t,!0,n),this}validateSchema(e,t){if("boolean"==typeof e)return!0;let n;if(n=e.$schema,void 0!==n&&"string"!=typeof n)throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,!0;const i=this.validate(n,e);if(!i&&t){const e="schema is invalid: "+this.errorsText();if("log"!==this.opts.validateSchema)throw new Error(e);this.logger.error(e)}return i}getSchema(e){let t;for(;"string"==typeof(t=A.call(this,e));)e=t;if(void 0===t){const{schemaId:n}=this.opts,i=new l.SchemaEnv({schema:{},schemaId:n});if(t=l.resolveSchema.call(this,i,e),!t)return;this.refs[e]=t}return t.validate||this._compileSchemaEnv(t)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{const t=A.call(this,e);return"object"==typeof t&&this._cache.delete(t.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{const t=e;this._cache.delete(t);let n=e[this.opts.schemaId];return n&&(n=(0,h.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(const t of e)this.addKeyword(t);return this}addKeyword(e,t){let n;if("string"==typeof e)n=e,"object"==typeof t&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),t.keyword=n);else{if("object"!=typeof e||void 0!==t)throw new Error("invalid addKeywords parameters");if(n=(t=e).keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}if(L.call(this,n,t),!t)return(0,d.eachItem)(n,e=>N.call(this,e)),this;R.call(this,t);const i={...t,type:(0,u.getJSONTypes)(t.type),schemaType:(0,u.getJSONTypes)(t.schemaType)};return(0,d.eachItem)(n,0===i.type.length?e=>N.call(this,e,i):e=>i.type.forEach(t=>N.call(this,e,i,t))),this}getKeyword(e){const t=this.RULES.all[e];return"object"==typeof t?t.definition:!!t}removeKeyword(e){const{RULES:t}=this;delete t.keywords[e],delete t.all[e];for(const n of t.rules){const t=n.rules.findIndex(t=>t.keyword===e);t>=0&&n.rules.splice(t,1)}return this}addFormat(e,t){return"string"==typeof t&&(t=new RegExp(t)),this.formats[e]=t,this}errorsText(e=this.errors,{separator:t=", ",dataVar:n="data"}={}){return e&&0!==e.length?e.map(e=>`${n}${e.instancePath} ${e.message}`).reduce((e,n)=>e+t+n):"No errors"}$dataMetaSchema(e,t){const n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(const i of t){const t=i.split("/").slice(1);let o=e;for(const e of t)o=o[e];for(const e in n){const t=n[e];if("object"!=typeof t)continue;const{$data:i}=t.definition,r=o[e];i&&r&&(o[e]=O(r))}}return e}_removeAllSchemas(e,t){for(const n in e){const i=e[n];t&&!t.test(n)||("string"==typeof i?delete e[n]:i&&!i.meta&&(this._cache.delete(i.schema),delete e[n]))}}_addSchema(e,t,n,i=this.opts.validateSchema,o=this.opts.addUsedSchema){let r;const{schemaId:s}=this.opts;if("object"==typeof e)r=e[s];else{if(this.opts.jtd)throw new Error("schema must be object");if("boolean"!=typeof e)throw new Error("schema must be object or boolean")}let a=this._cache.get(e);if(void 0!==a)return a;n=(0,h.normalizeId)(r||n);const c=h.getSchemaRefs.call(this,e,n);return a=new l.SchemaEnv({schema:e,schemaId:s,meta:t,baseId:n,localRefs:c}),this._cache.set(a.schema,a),o&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=a),i&&this.validateSchema(e,!0),a}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):l.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){const t=this.opts;this.opts=this._metaOpts;try{l.compileSchema.call(this,e)}finally{this.opts=t}}}function S(e,t,n,i="error"){for(const o in e){const r=o;r in t&&this.logger[i](`${n}: option ${o}. ${e[r]}`)}}function A(e){return e=(0,h.normalizeId)(e),this.schemas[e]||this.refs[e]}function x(){const e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(const t in e)this.addSchema(e[t],t)}function E(){for(const e in this.opts.formats){const t=this.opts.formats[e];t&&this.addFormat(e,t)}}function M(e){if(Array.isArray(e))this.addVocabulary(e);else{this.logger.warn("keywords option as map is deprecated, pass array");for(const t in e){const n=e[t];n.keyword||(n.keyword=t),this.addKeyword(n)}}}function T(){const e={...this.opts};for(const t of f)delete e[t];return e}C.ValidationError=r.default,C.MissingRefError=s.default,t.default=C;const _={log(){},warn(){},error(){}},I=/^[a-z_$][a-z0-9_$:-]*$/i;function L(e,t){const{RULES:n}=this;if((0,d.eachItem)(e,e=>{if(n.keywords[e])throw new Error(`Keyword ${e} is already defined`);if(!I.test(e))throw new Error(`Keyword ${e} has invalid name`)}),t&&t.$data&&!("code"in t)&&!("validate"in t))throw new Error('$data keyword must have "code" or "validate" function')}function N(e,t,n){var i;const o=null==t?void 0:t.post;if(n&&o)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:r}=this;let s=o?r.post:r.rules.find(({type:e})=>e===n);if(s||(s={type:n,rules:[]},r.rules.push(s)),r.keywords[e]=!0,!t)return;const a={keyword:e,definition:{...t,type:(0,u.getJSONTypes)(t.type),schemaType:(0,u.getJSONTypes)(t.schemaType)}};t.before?P.call(this,s,a,t.before):s.rules.push(a),r.all[e]=a,null===(i=t.implements)||void 0===i||i.forEach(e=>this.addKeyword(e))}function P(e,t,n){const i=e.rules.findIndex(e=>e.keyword===n);i>=0?e.rules.splice(i,0,t):(e.rules.push(t),this.logger.warn(`rule ${n} is not defined`))}function R(e){let{metaSchema:t}=e;void 0!==t&&(e.$data&&this.opts.$data&&(t=O(t)),e.validateSchema=this.compile(t,!0))}const $={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function O(e){return{anyOf:[e,$]}}},4139:(e,t,n)=>{"use strict";n.d(t,{HX:()=>h,J:()=>a,b9:()=>c,uF:()=>r});var i,o,r,s,a,l=n(8152);!function(e){e.SPLIT_COL="~split",e.ACTIVITY="~activity",e.ACTIVITY_SCALED="activity_scaled",e.ALIGNED_SEQUENCE="~aligned_sequence",e.AMINO_ACID_RESIDUE="AAR",e.POSITION="Pos",e.P_VALUE="pValue",e.MEAN_DIFFERENCE="Mean difference"}(i||(i={})),function(e){e.AAR="AAR",e.POSITION="Pos",e.SELECTION="selection"}(o||(o={})),function(e){e.MONOMER="Monomer",e.MACROMOLECULE_DIFFERENCE="MacromoleculeDifference",e.ACTIVITY="activity",e.ACTIVITY_SCALED="activityScaled"}(r||(r={})),function(e){e.CELL_CHANGING="isCellChanging"}(s||(s={})),function(e){e.SEPARATOR="."}(a||(a={}));const c="3.3.1",h={pepsea:{gapOpen:1.53,gapExtend:0,method:l.ZY[0]},kalign:{gapOpen:-1,gapExtend:-1,terminalGap:-1}}},4152:(e,t,n)=>{"use strict";var i=n(6082),o=n(7362),r=n(4971);function s(e,t=!0){if(null==e)return"rgb(100,100,100)";const n=i.Color.fromHtml(e);if(t){const e=i.Color.g(n),t=i.Color.r(n),o=i.Color.b(n),r=Math.sqrt(Math.pow(0-t,2)+Math.pow(0-e,2)+Math.pow(0-o,2));if(r>210)return`rgb(${t/r*210},${e/r*210},${o/r*210})`}return i.Color.toRgb(n)}class a{static hashCode(e){let t=0;if(0===e.length)return t;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t}}class l{}class c extends l{static get palette(){return c._pallete||(c._pallete=c.buildPalette()),c._pallete}static buildPalette(){return(0,r.pj)().then(e=>{e.awaitLoaded(1/0).then(()=>{const t=e.getMonomerLib();t.onChanged.subscribe(()=>{c.customMonomerColors={},c.polymerTypes=t.getPolymerTypes();for(const e of this.polymerTypes){const n=t.getMonomerSymbolsByType(e);for(const i of n){const n=t.getMonomer(e,i);n?.meta?.colors?.default?.background&&(this.customMonomerColors[i]||(this.customMonomerColors[i]={}),this.customMonomerColors[i][e]=s(n.meta.colors.default.background))}}})})}),[].concat(...Object.values(o.e.colourPalette))}get(e,t){const n=c.palette.length,i=c.customMonomerColors[e],o=t??"PEPTIDE";if(i&&i[o])return i[o];const r=a.hashCode(e)%n;return s(c.palette[r])}}c._pallete=null,c.customMonomerColors={},c.polymerTypes=[]},4227:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.checkStrictMode=t.getErrorPath=t.Type=t.useFunc=t.setEvaluated=t.evaluatedPropsToName=t.mergeEvaluated=t.eachItem=t.unescapeJsonPointer=t.escapeJsonPointer=t.escapeFragment=t.unescapeFragment=t.schemaRefOrVal=t.schemaHasRulesButRef=t.schemaHasRules=t.checkUnknownRules=t.alwaysValidSchema=t.toHash=void 0;const i=n(9029),o=n(1520);function r(e,t=e.schema){const{opts:n,self:i}=e;if(!n.strictSchema)return;if("boolean"==typeof t)return;const o=i.RULES.keywords;for(const n in t)o[n]||m(e,`unknown keyword: "${n}"`)}function s(e,t){if("boolean"==typeof e)return!e;for(const n in e)if(t[n])return!0;return!1}function a(e){return"number"==typeof e?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}function l(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function c({mergeNames:e,mergeToName:t,mergeValues:n,resultToName:o}){return(r,s,a,l)=>{const c=void 0===a?s:a instanceof i.Name?(s instanceof i.Name?e(r,s,a):t(r,s,a),a):s instanceof i.Name?(t(r,a,s),s):n(s,a);return l!==i.Name||c instanceof i.Name?c:o(r,c)}}function h(e,t){if(!0===t)return e.var("props",!0);const n=e.var("props",i._`{}`);return void 0!==t&&u(e,n,t),n}function u(e,t,n){Object.keys(n).forEach(n=>e.assign(i._`${t}${(0,i.getProperty)(n)}`,!0))}t.toHash=function(e){const t={};for(const n of e)t[n]=!0;return t},t.alwaysValidSchema=function(e,t){return"boolean"==typeof t?t:0===Object.keys(t).length||(r(e,t),!s(t,e.self.RULES.all))},t.checkUnknownRules=r,t.schemaHasRules=s,t.schemaHasRulesButRef=function(e,t){if("boolean"==typeof e)return!e;for(const n in e)if("$ref"!==n&&t.all[n])return!0;return!1},t.schemaRefOrVal=function({topSchemaRef:e,schemaPath:t},n,o,r){if(!r){if("number"==typeof n||"boolean"==typeof n)return n;if("string"==typeof n)return i._`${n}`}return i._`${e}${t}${(0,i.getProperty)(o)}`},t.unescapeFragment=function(e){return l(decodeURIComponent(e))},t.escapeFragment=function(e){return encodeURIComponent(a(e))},t.escapeJsonPointer=a,t.unescapeJsonPointer=l,t.eachItem=function(e,t){if(Array.isArray(e))for(const n of e)t(n);else t(e)},t.mergeEvaluated={props:c({mergeNames:(e,t,n)=>e.if(i._`${n} !== true && ${t} !== undefined`,()=>{e.if(i._`${t} === true`,()=>e.assign(n,!0),()=>e.assign(n,i._`${n} || {}`).code(i._`Object.assign(${n}, ${t})`))}),mergeToName:(e,t,n)=>e.if(i._`${n} !== true`,()=>{!0===t?e.assign(n,!0):(e.assign(n,i._`${n} || {}`),u(e,n,t))}),mergeValues:(e,t)=>!0===e||{...e,...t},resultToName:h}),items:c({mergeNames:(e,t,n)=>e.if(i._`${n} !== true && ${t} !== undefined`,()=>e.assign(n,i._`${t} === true ? true : ${n} > ${t} ? ${n} : ${t}`)),mergeToName:(e,t,n)=>e.if(i._`${n} !== true`,()=>e.assign(n,!0===t||i._`${n} > ${t} ? ${n} : ${t}`)),mergeValues:(e,t)=>!0===e||Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})},t.evaluatedPropsToName=h,t.setEvaluated=u;const d={};var p;function m(e,t,n=e.opts.strictSchema){if(n){if(t=`strict mode: ${t}`,!0===n)throw new Error(t);e.self.logger.warn(t)}}t.useFunc=function(e,t){return e.scopeValue("func",{ref:t,code:d[t.code]||(d[t.code]=new o._Code(t.code))})},function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"}(p||(t.Type=p={})),t.getErrorPath=function(e,t,n){if(e instanceof i.Name){const o=t===p.Num;return n?o?i._`"[" + ${e} + "]"`:i._`"['" + ${e} + "']"`:o?i._`"/" + ${e}`:i._`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return n?(0,i.getProperty)(e).toString():"/"+a(e)},t.checkStrictMode=m},4326:(e,t,n)=>{"use strict";n.d(t,{Fo:()=>h,Lp:()=>r,P4:()=>s,fH:()=>o,gp:()=>i,lT:()=>l,mH:()=>a});var i,o,r,s,a,l,c=n(6082);!function(e){e.tooltipWebLogo=".tooltipWebLogo"}(i||(i={})),function(e){e.Entropy="Entropy",e.full="100%"}(o||(o={})),function(e){e.TOP="top",e.MIDDLE="middle",e.BOTTOM="bottom"}(r||(r={})),function(e){e.LEFT="left",e.CENTER="center",e.RIGHT="right"}(s||(s={})),function(e){e.AUTO="auto",e.ON="on",e.OFF="off"}(a||(a={})),function(e){e.Filtered="Filtered",e.Selected="Selected"}(l||(l={}));const h=new class{constructor(){this.sequenceColumnName=null,this.valueAggrType=c.AGG.TOTAL_COUNT,this.valueColumnName="Activity",this.startPositionName=null,this.endPositionName=null,this.skipEmptySequences=!0,this.skipEmptyPositions=!1,this.shrinkEmptyTail=!0,this.backgroundColor=4294967295,this.positionHeight=o.Entropy,this.positionWidth=20,this.verticalAlignment=r.MIDDLE,this.horizontalAlignment=s.CENTER,this.fixWidth=!1,this.fitArea=!0,this.minHeight=25,this.maxHeight=300,this.maxMonomerLetters=5,this.showPositionLabels=!0,this.positionMarginState=a.AUTO,this.positionMargin=0,this.filterSource=l.Filtered}}},4328:e=>{"use strict";e.exports=grok},4356:(e,t,n)=>{"use strict";n.d(t,{Eu:()=>a,ub:()=>s});var i=n(4328);const o="Libraries";let r=Promise.resolve();async function s(){let e;return r=r.then(async()=>{const t=i.userSettings.getValue(o,"Settings",!0);e=t?JSON.parse(t):{exclude:[],explicit:[],duplicateMonomerPreferences:{}},e.exclude=e.exclude instanceof Array?e.exclude:[],e.explicit=e.explicit instanceof Array?e.explicit:[],e.duplicateMonomerPreferences=e.duplicateMonomerPreferences instanceof Object?e.duplicateMonomerPreferences:{},console.debug(`Bio: getUserLibSettings()\n${JSON.stringify(e,void 0,2)}`)}),await r,e}async function a(e){r=r.then(async()=>{console.debug(`Bio: setUserLibSettings()\n${JSON.stringify(e,void 0,2)}`),i.userSettings.add(o,"Settings",JSON.stringify(e),!0)}),await r}},4426:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(4227),o={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:n}){void 0===t.if&&(0,i.checkStrictMode)(n,`"${e}" without "if" is ignored`)}};t.default=o},4486:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:{message({keyword:e,schemaCode:t}){const n="maxProperties"===e?"more":"fewer";return i.str`must NOT have ${n} than ${t} properties`},params:({schemaCode:e})=>i._`{limit: ${e}}`},code(e){const{keyword:t,data:n,schemaCode:o}=e,r="maxProperties"===t?i.operators.GT:i.operators.LT;e.fail$data(i._`Object.keys(${n}).length ${r} ${o}`)}};t.default=o},4495:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extendSubschemaMode=t.extendSubschemaData=t.getSubschema=void 0;const i=n(9029),o=n(4227);t.getSubschema=function(e,{keyword:t,schemaProp:n,schema:r,schemaPath:s,errSchemaPath:a,topSchemaRef:l}){if(void 0!==t&&void 0!==r)throw new Error('both "keyword" and "schema" passed, only one allowed');if(void 0!==t){const r=e.schema[t];return void 0===n?{schema:r,schemaPath:i._`${e.schemaPath}${(0,i.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:r[n],schemaPath:i._`${e.schemaPath}${(0,i.getProperty)(t)}${(0,i.getProperty)(n)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,o.escapeFragment)(n)}`}}if(void 0!==r){if(void 0===s||void 0===a||void 0===l)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:r,schemaPath:s,topSchemaRef:l,errSchemaPath:a}}throw new Error('either "keyword" or "schema" must be passed')},t.extendSubschemaData=function(e,t,{dataProp:n,dataPropType:r,data:s,dataTypes:a,propertyName:l}){if(void 0!==s&&void 0!==n)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:c}=t;if(void 0!==n){const{errorPath:s,dataPathArr:a,opts:l}=t;h(c.let("data",i._`${t.data}${(0,i.getProperty)(n)}`,!0)),e.errorPath=i.str`${s}${(0,o.getErrorPath)(n,r,l.jsPropertySyntax)}`,e.parentDataProperty=i._`${n}`,e.dataPathArr=[...a,e.parentDataProperty]}function h(n){e.data=n,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,n]}void 0!==s&&(h(s instanceof i.Name?s:c.let("data",s,!0)),void 0!==l&&(e.propertyName=l)),a&&(e.dataTypes=a)},t.extendSubschemaMode=function(e,{jtdDiscriminator:t,jtdMetadata:n,compositeRule:i,createErrors:o,allErrors:r}){void 0!==i&&(e.compositeRule=i),void 0!==o&&(e.createErrors=o),void 0!==r&&(e.allErrors=r),e.jtdDiscriminator=t,e.jtdMetadata=n}},4551:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(6939);class o extends Error{constructor(e,t,n,o){super(o||`can't resolve reference ${n} from id ${t}`),this.missingRef=(0,i.resolveUrl)(e,t,n),this.missingSchema=(0,i.normalizeId)((0,i.getFullPath)(e,this.missingRef))}}t.default=o},4574:(e,t,n)=>{"use strict";n.d(t,{O:()=>r,n:()=>o});var i=n(1858);class o{constructor(e,t=!0,n){return this.substructure=e,this.readOnly=t,this.logger=n,new Proxy(this,{set:(e,t,n)=>{if(this.logger?.debug(`BioFilterProps.set ${t.toString()}( '${n}' )`),this.readOnly)throw new Error("Properties are immutable.");return e[t]=n,!0}})}}class r{constructor(){this.onChanged=new i.Subject,this._props=null,this._propsChanging=!1}get props(){return this._props||(this._props=this.emptyProps),this._props}set props(e){this._propsChanging=!0;try{this._props=e,this.applyProps(),this.onChanged.next()}finally{this._propsChanging=!1}}saveProps(){const e={};for(const[t,n]of Object.entries(this.props))"_onChanged"!==t&&"logger"!==t&&(e[t]=this.props[t]);return e}async detach(){}get filterSummary(){return this.props.substructure}get isFiltering(){return""!==this.props.substructure}resetFilter(){this.props=this.emptyProps,this.onChanged.next()}}},4588:e=>{"use strict";e.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/meta/format-annotation","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/format-annotation":true},"$dynamicAnchor":"meta","title":"Format vocabulary meta-schema for annotation results","type":["object","boolean"],"properties":{"format":{"type":"string"}}}')},4737:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:{message:({schemaCode:e})=>i.str`must match format "${e}"`,params:({schemaCode:e})=>i._`{format: ${e}}`},code(e,t){const{gen:n,data:o,$data:r,schema:s,schemaCode:a,it:l}=e,{opts:c,errSchemaPath:h,schemaEnv:u,self:d}=l;c.validateFormats&&(r?function(){const r=n.scopeValue("formats",{ref:d.formats,code:c.code.formats}),s=n.const("fDef",i._`${r}[${a}]`),l=n.let("fType"),h=n.let("format");n.if(i._`typeof ${s} == "object" && !(${s} instanceof RegExp)`,()=>n.assign(l,i._`${s}.type || "string"`).assign(h,i._`${s}.validate`),()=>n.assign(l,i._`"string"`).assign(h,s)),e.fail$data((0,i.or)(!1===c.strictSchema?i.nil:i._`${a} && !${h}`,function(){const e=u.$async?i._`(${s}.async ? await ${h}(${o}) : ${h}(${o}))`:i._`${h}(${o})`,n=i._`(typeof ${h} == "function" ? ${e} : ${h}.test(${o}))`;return i._`${h} && ${h} !== true && ${l} === ${t} && !${n}`}()))}():function(){const r=d.formats[s];if(!r)return void function(){if(!1!==c.strictSchema)throw new Error(e());function e(){return`unknown format "${s}" ignored in schema at path "${h}"`}d.logger.warn(e())}();if(!0===r)return;const[a,l,p]=function(e){const t=e instanceof RegExp?(0,i.regexpCode)(e):c.code.formats?i._`${c.code.formats}${(0,i.getProperty)(s)}`:void 0,o=n.scopeValue("formats",{key:s,ref:e,code:t});return"object"!=typeof e||e instanceof RegExp?["string",e,o]:[e.type||"string",e.validate,i._`${o}.validate`]}(r);a===t&&e.pass(function(){if("object"==typeof r&&!(r instanceof RegExp)&&r.async){if(!u.$async)throw new Error("async format in sync schema");return i._`await ${p}(${o})`}return"function"==typeof l?i._`${p}(${o})`:i._`${p}.test(${o})`}())}())}};t.default=o},4834:(e,t,n)=>{"use strict";const{HEX:i}=n(4914),o=/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u;function r(e){if(c(e,".")<3)return{host:e,isIPV4:!1};const t=e.match(o)||[],[n]=t;return n?{host:l(n,"."),isIPV4:!0}:{host:e,isIPV4:!1}}function s(e,t=!1){let n="",o=!0;for(const t of e){if(void 0===i[t])return;"0"!==t&&!0===o&&(o=!1),o||(n+=t)}return t&&0===n.length&&(n="0"),n}function a(e){if(c(e,":")<2)return{host:e,isIPV6:!1};const t=function(e){let t=0;const n={error:!1,address:"",zone:""},i=[],o=[];let r=!1,a=!1,l=!1;function c(){if(o.length){if(!1===r){const e=s(o);if(void 0===e)return n.error=!0,!1;i.push(e)}o.length=0}return!0}for(let s=0;s<e.length;s++){const h=e[s];if("["!==h&&"]"!==h)if(":"!==h)if("%"===h){if(!c())break;r=!0}else o.push(h);else{if(!0===a&&(l=!0),!c())break;if(t++,i.push(":"),t>7){n.error=!0;break}s-1>=0&&":"===e[s-1]&&(a=!0)}}return o.length&&(r?n.zone=o.join(""):l?i.push(o.join("")):i.push(s(o))),n.address=i.join(""),n}(e);if(t.error)return{host:e,isIPV6:!1};{let e=t.address,n=t.address;return t.zone&&(e+="%"+t.zone,n+="%25"+t.zone),{host:e,escapedHost:n,isIPV6:!0}}}function l(e,t){let n="",i=!0;const o=e.length;for(let r=0;r<o;r++){const s=e[r];"0"===s&&i?(r+1<=o&&e[r+1]===t||r+1===o)&&(n+=s,i=!1):(i=s===t,n+=s)}return n}function c(e,t){let n=0;for(let i=0;i<e.length;i++)e[i]===t&&n++;return n}const h=/^\.\.?\//u,u=/^\/\.(?:\/|$)/u,d=/^\/\.\.(?:\/|$)/u,p=/^\/?(?:.|\n)*?(?=\/|$)/u;e.exports={recomposeAuthority:function(e){const t=[];if(void 0!==e.userinfo&&(t.push(e.userinfo),t.push("@")),void 0!==e.host){let n=unescape(e.host);const i=r(n);if(i.isIPV4)n=i.host;else{const t=a(i.host);n=!0===t.isIPV6?`[${t.escapedHost}]`:e.host}t.push(n)}return"number"!=typeof e.port&&"string"!=typeof e.port||(t.push(":"),t.push(String(e.port))),t.length?t.join(""):void 0},normalizeComponentEncoding:function(e,t){const n=!0!==t?escape:unescape;return void 0!==e.scheme&&(e.scheme=n(e.scheme)),void 0!==e.userinfo&&(e.userinfo=n(e.userinfo)),void 0!==e.host&&(e.host=n(e.host)),void 0!==e.path&&(e.path=n(e.path)),void 0!==e.query&&(e.query=n(e.query)),void 0!==e.fragment&&(e.fragment=n(e.fragment)),e},removeDotSegments:function(e){const t=[];for(;e.length;)if(e.match(h))e=e.replace(h,"");else if(e.match(u))e=e.replace(u,"/");else if(e.match(d))e=e.replace(d,"/"),t.pop();else if("."===e||".."===e)e="";else{const n=e.match(p);if(!n)throw new Error("Unexpected dot segment condition");{const i=n[0];e=e.slice(i.length),t.push(i)}}return t.join("")},normalizeIPv4:r,normalizeIPv6:a,stringArrayToHexStripped:s}},4845:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(3025),o={keyword:"dependentSchemas",type:"object",schemaType:"object",code:e=>(0,i.validateSchemaDeps)(e)};t.default=o},4870:(e,t,n)=>{"use strict";n.d(t,{Kd:()=>a,Ku:()=>s,me:()=>r});var i=n(4328),o=n(6082);function r(){const e=i.shell.t.columns.bySemTypeAll(o.SEMTYPE.MACROMOLECULE);return null==e?(i.shell.error("Current table does not contain macromolecules"),[]):e}function s(e,t){e.innerHTML="",e.append(t)}function a(e,t,n,i,o){const r=()=>{const o=e.col(t);o&&(o.width=n),i&&(e.props.rowHeight=i)};if(o)return void r();const s=e.onAfterDrawOverlay.subscribe(()=>{s.unsubscribe(),setTimeout(()=>{r()})})}},4914:e=>{"use strict";e.exports={HEX:{0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15}}},4954:(e,t,n)=>{"use strict";n.d(t,{a7:()=>m,if:()=>f,BQ:()=>y,nI:()=>g});var i=n(4328),o=n(7389),r=n(6082),s=n(8070),a=n(2003),l=n(439);const c=31;async function h(e,t,n=!1,o){const s=t.getSeqHandler(e);let a;o??=new Map;const l=s.isHelm()?t.getSeqMonomers(e):Object.keys(s.stats.freq).filter(e=>""!==e);for(let e=0;e<l.length;e++)o.has(l[e])||o.set(l[e],`${o.size+1}`);if(s.isHelm())a=await i.functions.call("HELM:getMolFiles",{col:e}),a=function(e,t,n=!1){const i=new Array(e.length);for(let o=0;o<e.length;o++){let r=0,s=0,a="\n Datagrok macromolecule handler\n\n 0 0 0 0 0 0 999 V3000\nM V30 BEGIN CTAB\n";const l=e.get(o);r=l.indexOf("\n",r)+1,r=l.indexOf("\n",r)+1,r=l.indexOf("\n",r)+1;const h=parseInt(l.substring(r,r+3)),u=parseInt(l.substring(r+3,r+6));a+=`M V30 COUNTS ${h} ${u} 0 0 0\n`,a+="M V30 BEGIN ATOM\n";for(let e=0;e<h;e++){r=l.indexOf("\n",r)+1+c,s=l.indexOf(" ",r);const i=l.substring(r,s);a+=n?`M V30 ${e+1} R${t.get(i)} 0.000 0.000 0 0\n`:`M V30 ${e+1} At 0.000 0.000 0 0 MASS=${t.get(i)}\n`}a+="M V30 END ATOM\n",a+="M V30 BEGIN BOND\n";for(let e=0;e<u;e++){r=l.indexOf("\n",r)+1;const t=parseInt(l.substring(r,r+3).trim()),n=parseInt(l.substring(r+3,r+6).trim());a+=`M V30 ${e+1} ${parseInt(l.substring(r+6,r+9).trim())} ${t} ${n}\n`}a+="M V30 END BOND\n",a+="M V30 END CTAB\n",a+="M END",i[o]=a}return i}(a,o,n);else{a=new Array(e.length);for(let t=0;t<e.length;t++){const e=u(s.getSplitted(t),o,n);a[t]=e}}return r.Column.fromStrings("monomericMols",a)}function u(e,t,n=!1){let i="\n Datagrok macromolecule handler\n\n 0 0 0 0 0 0 999 V3000\nM V30 BEGIN CTAB\n";i+=`M V30 COUNTS ${e.length} ${e.length?e.length-1:0} 0 0 0\n`,i+="M V30 BEGIN ATOM\n";for(let o=0;o<e.length;o++){const r=e.getCanonical(o);r!==l._S&&(i+=n?`M V30 ${o+1} R${t.get(r)} 0.000 0.000 0 0\n`:`M V30 ${o+1} At 0.000 0.000 0 0 MASS=${t.get(r)}\n`)}i+="M V30 END ATOM\n",i+="M V30 BEGIN BOND\n";for(let t=0;t<e.length-1;t++)i+=`M V30 ${t+1} 1 ${t+1} ${t+2}\n`;return i+="M V30 END BOND\n",i+="M V30 END CTAB\n",i+="M END",i}var d=n(4870);const p="substr_helm";class m{seqHelper;units;separator;inputsDiv;substructureInput;separatorInput;editHelmLink;columnsInput;grid;col;dialog;constructor(e,t){this.seqHelper=t,this.col=e[0],this.createUI()}editHelmLinkAction(){(0,d.Ku)(this.inputsDiv,this.grid.root),o.tools.waitForElementInDom(this.grid.root).then(()=>{setTimeout(()=>{this.grid.cell(p,0).element.children[0].dispatchEvent(new KeyboardEvent("keydown",{key:"Enter"}))},100)})}updateInputs(){const e=this.units===a.Hi.HELM?o.divV([this.columnsInput,this.editHelmLink]):this.units===a.Hi.SEPARATOR?o.inputs([this.columnsInput,this.substructureInput,this.separatorInput]):o.inputs([this.columnsInput,this.substructureInput]);(0,d.Ku)(this.inputsDiv,e)}updateNotationDiv(){this.units=this.col.meta.units,this.separator=this.col.getTag(a.gp.separator);const e=this.dialog.root.getElementsByClassName("notation-text")[0];e&&(e.textContent=`Notation: ${this.units}`)}createUI(){const e=i.shell.tv.dataFrame;this.columnsInput=o.input.column("Column",{table:e,value:this.col,onValueChanged:e=>{this.col=e,this.updateNotationDiv(),this.updateInputs()},filter:e=>e.semType===r.SEMTYPE.MACROMOLECULE}),this.substructureInput=o.input.string("Substructure",{value:""}),this.editHelmLink=o.link("Edit helm",()=>this.editHelmLinkAction(),void 0,{style:{position:"relative",left:"95px"}});const t=r.DataFrame.create(1);t.columns.addNewString(p).init(e=>""),t.col(p).semType=this.col.semType,t.col(p).meta.units=a.Hi.HELM,this.grid=t.plot.grid(),this.separatorInput=o.input.string("Separator",{value:this.separator}),this.inputsDiv=o.div(),this.units=this.col.meta.units,this.separator=this.col.getTag(a.gp.separator),this.updateInputs(),this.dialog=o.dialog("Substructure Search").add(o.divV([o.divText(`Notation: ${this.units}`,"notation-text"),this.inputsDiv])).onOK(async()=>{let e,n=this.units===a.Hi.HELM?t.get(p,0):this.substructureInput.value;this.units===a.Hi.SEPARATOR&&this.separatorInput.value!==this.separator&&this.separatorInput.value&&(n=n.replaceAll(this.separatorInput.value,this.separator)),e=this.units===a.Hi.HELM?await f(n,this.col,this.seqHelper):g(n,this.col),this.col.dataFrame.filter.and(e)}).show()}}function g(e,t,n){const i=n?function(e,t){const n=`${t}`.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),i=e.charAt(0)===t,o=e.charAt(e.length-1)===t,r=e.replace(new RegExp(`^${n}|${n}$`,"g"),"");return i?o?`${n}${r}${n}`:`${n}${r}${n}|${n}${r}$`:o?`^${r}${n}|${n}${r}${n}`:`^${r}${n}|${n}${r}${n}|${n}${r}$`}(e,n):e,o=r.BitSet.create(t.length);for(let n=0;n<t.length;n++){const r=t.get(n);(r.match(i)||r===e)&&o.set(n,!0,!1)}return o}async function f(e,t,n){t.version!==t.temp["last-invalidated-version"]&&await y(t,n,!0);const o=r.Column.string("helm",1).init(t=>e);o.semType=r.SEMTYPE.MACROMOLECULE,o.meta.units=a.Hi.HELM;const s=await h(o,n,!0,t.temp["monomers-dict"]);return(await i.functions.call("Chem:searchSubstructure",{molStringsColumn:t.temp["monomeric-mols"],molString:s.get(0),molBlockFailover:""})).get(0)}async function y(e,t,n){const i=r.TaskBarProgressIndicator.create(`Invalidating molfiles for ${e.name}`);try{await(0,s.cb)(10);const i=new Map,o=await h(e,t,n,i);e.temp["monomeric-mols"]=o,e.temp["monomers-dict"]=i,e.temp["last-invalidated-version"]=e.version}finally{i.close()}}},4971:(e,t,n)=>{"use strict";n.d(t,{YS:()=>c,ic:()=>r,lH:()=>l,pY:()=>s,pj:()=>a});var i=n(6082),o=n(9192);const r="Files";async function s(e,t){for(const n of e){const e=await n.listLibraries();if(e.includes(t)||e.includes(`${t}.json`))return n}return null}async function a(){const e=i.Func.find({package:"Bio",name:"getMonomerLibHelper"});if(0===e.length)throw new Error('Package "Bio" must be installed for MonomerLibHelper.');return(await e[0].prepare().call()).getOutputParamValue()}class l{constructor(e,t,n,i,r){this.monomerLib=e,this.symbol=t,this.polymerType=n,this.monomerType=i,this.monomerLinks=r,this.error=null;try{this.monomers=this.monomerLinks.map(e=>{const n=this.monomerLib.getMonomer(this.polymerType,e.symbol);if(!n)throw new Error("Monomer not found: ");if(n.lib?.source!=e.source)throw new Error(`Monomer '${t}' found in different library.`);return n})}catch(e){const[t,n]=(0,o.AP)(e);this.error=t,this.monomers=[]}}}class c{constructor(e,t,n=void 0,i=void 0){this.description=e,this.placeholders=t,this.source=n,this.error=i}updateSets(e,t=!1){t&&(this.placeholders=[]);for(const t of e)t.error||this._updateSetInt(t)}_updateSetInt(e){for(const t of e.placeholders)this.placeholders.push(t)}}},5056:(e,t,n)=>{"use strict";e.exports=function(e){var t=n.nc;t&&e.setAttribute("nonce",t)}},5072:e=>{"use strict";var t=[];function n(e){for(var n=-1,i=0;i<t.length;i++)if(t[i].identifier===e){n=i;break}return n}function i(e,i){for(var r={},s=[],a=0;a<e.length;a++){var l=e[a],c=i.base?l[0]+i.base:l[0],h=r[c]||0,u="".concat(c," ").concat(h);r[c]=h+1;var d=n(u),p={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==d)t[d].references++,t[d].updater(p);else{var m=o(p,i);i.byIndex=a,t.splice(a,0,{identifier:u,updater:m,references:1})}s.push(u)}return s}function o(e,t){var n=t.domAPI(t);return n.update(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap&&t.supports===e.supports&&t.layer===e.layer)return;n.update(e=t)}else n.remove()}}e.exports=function(e,o){var r=i(e=e||[],o=o||{});return function(e){e=e||[];for(var s=0;s<r.length;s++){var a=n(r[s]);t[a].references--}for(var l=i(e,o),c=0;c<r.length;c++){var h=n(r[c]);0===t[h].references&&(t[h].updater(),t.splice(h,1))}r=l}}},5333:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(5765),o=n(9029),r=n(4227),s=n(4227),a={keyword:"patternProperties",type:"object",schemaType:"object",code(e){const{gen:t,schema:n,data:a,parentSchema:l,it:c}=e,{opts:h}=c,u=(0,i.allSchemaProperties)(n),d=u.filter(e=>(0,r.alwaysValidSchema)(c,n[e]));if(0===u.length||d.length===u.length&&(!c.opts.unevaluated||!0===c.props))return;const p=h.strictSchema&&!h.allowMatchingProperties&&l.properties,m=t.name("valid");!0===c.props||c.props instanceof o.Name||(c.props=(0,s.evaluatedPropsToName)(t,c.props));const{props:g}=c;function f(e){for(const t in p)new RegExp(e).test(t)&&(0,r.checkStrictMode)(c,`property ${t} matches pattern ${e} (use allowMatchingProperties)`)}function y(n){t.forIn("key",a,r=>{t.if(o._`${(0,i.usePattern)(e,n)}.test(${r})`,()=>{const i=d.includes(n);i||e.subschema({keyword:"patternProperties",schemaProp:n,dataProp:r,dataPropType:s.Type.Str},m),c.opts.unevaluated&&!0!==g?t.assign(o._`${g}[${r}]`,!0):i||c.allErrors||t.if((0,o.not)(m),()=>t.break())})})}!function(){for(const e of u)p&&f(e),c.allErrors?y(e):(t.var(m,!0),y(e),t.if(m))}()}};t.default=a},5354:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(494),o={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,i.validateTuple)(e,"items")};t.default=o},5413:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(1846),o=n(4845),r=n(2626),s=[i.default,o.default,r.default];t.default=s},5433:(e,t,n)=>{"use strict";n.d(t,{C:()=>u});var i=n(6082),o=n(7389),r=n(4328),s=n(1757),a=n.n(s),l=n(2003);let c=null,h=[];function u(e,t){let n=e??r.shell.t.columns.bySemType("Macromolecule");if(!n)throw new Error("No column with Macromolecule semantic type found");let s=t.getSeqHandler(n),u=s.notation;const d=o.divText("Current notation: "+u,{style:{"text-align":"center","font-weight":"bold","font-size":"14px",padding:"5px"}}),p=[l.Hi.FASTA,l.Hi.SEPARATOR,l.Hi.HELM,l.Hi.BILN],m=o.input.column("Column",{table:r.shell.t,value:n,filter:e=>e.semType===i.SEMTYPE.MACROMOLECULE,nullable:!1,onValueChanged:e=>(n=e,s=t.getSeqHandler(n),u=s.notation,u===l.Hi.HELM&&(y.value="/"),d.textContent="Current notation: "+u,f=p.filter(e=>e!==u),v=o.input.choice("Convert to",{value:f[0],items:f,onValueChanged:b}),b(),c?.clear(),void c?.add(o.div([d,m.root,v.root,y.root])))}),g=["-",".","/"];let f=p.filter(e=>e!==u);const y=o.input.choice("Separator",{value:g[0],items:g}),b=()=>{v.value!==l.Hi.SEPARATOR?a()(y.root).hide():a()(y.root).show()};let v=o.input.choice("Convert to",{value:f[0],items:f,onValueChanged:b});b(),v.onChanged.subscribe(()=>{b()}),null==c&&(c=o.dialog("Convert Sequence Notation").add(o.div([d,m.root,v.root,y.root])).onOK(async()=>{const e=v.value,i=e===l.Hi.SEPARATOR?y.value:void 0;await async function(e,t,n,i){const o=t.getSeqHandler(e).convert(n,i);e.dataFrame.columns.add(o);const s=await r.functions.call("Bio:detectMacromolecule",{col:o});return s&&(o.semType=s),await r.data.detectSemanticTypes(e.dataFrame),o}(n,t,e,i)}).show({x:350,y:100}),h.push(c.onClose.subscribe(e=>{h.forEach(e=>{e.unsubscribe()}),h=[],c=null})))}},5457:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validateAdditionalItems=void 0;const i=n(9029),o=n(4227),r={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:{message:({params:{len:e}})=>i.str`must NOT have more than ${e} items`,params:({params:{len:e}})=>i._`{limit: ${e}}`},code(e){const{parentSchema:t,it:n}=e,{items:i}=t;Array.isArray(i)?s(e,i):(0,o.checkStrictMode)(n,'"additionalItems" is ignored when "items" is not an array of schemas')}};function s(e,t){const{gen:n,schema:r,data:s,keyword:a,it:l}=e;l.items=!0;const c=n.const("len",i._`${s}.length`);if(!1===r)e.setParams({len:t.length}),e.pass(i._`${c} <= ${t.length}`);else if("object"==typeof r&&!(0,o.alwaysValidSchema)(l,r)){const r=n.var("valid",i._`${c} <= ${t.length}`);n.if((0,i.not)(r),()=>function(r){n.forRange("i",t.length,c,t=>{e.subschema({keyword:a,dataProp:t,dataPropType:o.Type.Num},r),l.allErrors||n.if((0,i.not)(r),()=>n.break())})}(r)),e.ok(r)}}t.validateAdditionalItems=s,t.default=r},5488:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var i=n(1354),o=n.n(i),r=n(6314),s=n.n(r)()(o());s.push([e.id,"\n.ui-form.ui-tooltip .ui-input-root > label.ui-input-label:not(:empty) {\n /* min-width: 30px; /* Breaks right margin /**/\n}\n\n.ui-form.ui-tooltip .ui-input-root > div.ui-input-text:not(:empty) {\n margin-top: 6px;\n}","",{version:3,sources:["webpack://./css/cell-renderer.css"],names:[],mappings:";AACA;IACI,8CAA8C;AAClD;;AAEA;IACI,eAAe;AACnB",sourcesContent:["\n.ui-form.ui-tooltip .ui-input-root > label.ui-input-label:not(:empty) {\n /* min-width: 30px; /* Breaks right margin /**/\n}\n\n.ui-form.ui-tooltip .ui-input-root > div.ui-input-text:not(:empty) {\n margin-top: 6px;\n}"],sourceRoot:""}]);const a=s},5520:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(2476),o=n(3252),r=n(2721),s=n(3799),a=[i.default,o.default,r.default,s.default];t.default=a},5540:(e,t,n)=>{"use strict";e=n.hmd(e);var i,o=(i="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0,function(e={}){var t,n,o=void 0!==e?e:{};o.ready=new Promise(function(e,i){t=e,n=i});var r,s=Object.assign({},o),a="object"==typeof window,l="function"==typeof importScripts,c=("object"==typeof process&&"object"==typeof process.versions&&process.versions.node,"");(a||l)&&(l?c=self.location.href:"undefined"!=typeof document&&document.currentScript&&(c=document.currentScript.src),i&&(c=i),c=0!==c.indexOf("blob:")?c.substr(0,c.replace(/[?#].*/,"").lastIndexOf("/")+1):"",l&&(r=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)})),o.print||console.log.bind(console);var h,u,d=o.printErr||console.warn.bind(console);Object.assign(o,s),s=null,o.arguments&&o.arguments,o.thisProgram&&o.thisProgram,o.quit&&o.quit,o.wasmBinary&&(h=o.wasmBinary),o.noExitRuntime,"object"!=typeof WebAssembly&&_("no native wasm support detected");var p,m,g,f=!1;function y(){var e=u.buffer;o.HEAP8=p=new Int8Array(e),o.HEAP16=new Int16Array(e),o.HEAP32=new Int32Array(e),o.HEAPU8=m=new Uint8Array(e),o.HEAPU16=new Uint16Array(e),o.HEAPU32=g=new Uint32Array(e),o.HEAPF32=new Float32Array(e),o.HEAPF64=new Float64Array(e)}var b=[],v=[],w=[];function C(e){b.unshift(e)}function S(e){w.unshift(e)}var A,x,E=0,M=null,T=null;function _(e){o.onAbort&&o.onAbort(e),d(e="Aborted("+e+")"),f=!0,e+=". Build with -sASSERTIONS for more info.";var t=new WebAssembly.RuntimeError(e);throw n(t),t}function I(e){return e.startsWith("data:application/octet-stream;base64,")}function L(e){try{if(e==A&&h)return new Uint8Array(h);if(r)return r(e);throw"both async and sync fetching of the wasm failed"}catch(e){_(e)}}function N(e,t,n){return function(e){return h||!a&&!l||"function"!=typeof fetch?Promise.resolve().then(function(){return L(e)}):fetch(e,{credentials:"same-origin"}).then(function(t){if(!t.ok)throw"failed to load wasm binary file at '"+e+"'";return t.arrayBuffer()}).catch(function(){return L(e)})}(e).then(function(e){return WebAssembly.instantiate(e,t)}).then(function(e){return e}).then(n,function(e){d("failed to asynchronously prepare wasm: "+e),_(e)})}function P(e){for(;e.length>0;)e.shift()(o)}function R(e){this.excPtr=e,this.ptr=e-24,this.set_type=function(e){g[this.ptr+4>>2]=e},this.get_type=function(){return g[this.ptr+4>>2]},this.set_destructor=function(e){g[this.ptr+8>>2]=e},this.get_destructor=function(){return g[this.ptr+8>>2]},this.set_caught=function(e){e=e?1:0,p[this.ptr+12|0]=e},this.get_caught=function(){return 0!=p[this.ptr+12|0]},this.set_rethrown=function(e){e=e?1:0,p[this.ptr+13|0]=e},this.get_rethrown=function(){return 0!=p[this.ptr+13|0]},this.init=function(e,t){this.set_adjusted_ptr(0),this.set_type(e),this.set_destructor(t)},this.set_adjusted_ptr=function(e){g[this.ptr+16>>2]=e},this.get_adjusted_ptr=function(){return g[this.ptr+16>>2]},this.get_exception_ptr=function(){if(W(this.get_type()))return g[this.excPtr>>2];var e=this.get_adjusted_ptr();return 0!==e?e:this.excPtr}}function $(e){var t=u.buffer;try{return u.grow(e-t.byteLength+65535>>>16),y(),1}catch(e){}}function O(e){return o["_"+e]}I(A="wasmDbscan.wasm")||(x=A,A=o.locateFile?o.locateFile(x,c):c+x);var k="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function H(e,t,n,i,o){var r={string:e=>{var t=0;return null!=e&&0!==e&&(t=function(e){var t=function(e){for(var t=0,n=0;n<e.length;++n){var i=e.charCodeAt(n);i<=127?t++:i<=2047?t+=2:i>=55296&&i<=57343?(t+=4,++n):t+=3}return t}(e)+1,n=V(t);return function(e,t,n){!function(e,t,n,i){if(!(i>0))return 0;for(var o=n+i-1,r=0;r<e.length;++r){var s=e.charCodeAt(r);if(s>=55296&&s<=57343&&(s=65536+((1023&s)<<10)|1023&e.charCodeAt(++r)),s<=127){if(n>=o)break;t[n++]=s}else if(s<=2047){if(n+1>=o)break;t[n++]=192|s>>6,t[n++]=128|63&s}else if(s<=65535){if(n+2>=o)break;t[n++]=224|s>>12,t[n++]=128|s>>6&63,t[n++]=128|63&s}else{if(n+3>=o)break;t[n++]=240|s>>18,t[n++]=128|s>>12&63,t[n++]=128|s>>6&63,t[n++]=128|63&s}}t[n]=0}(e,m,t,n)}(e,n,t),n}(e)),t},array:e=>{var t,n,i=V(e.length);return t=e,n=i,p.set(t,n),i}},s=O(e),a=[],l=0;if(i)for(var c=0;c<i.length;c++){var h=r[n[c]];h?(0===l&&(l=B()),a[c]=h(i[c])):a[c]=i[c]}var u=s.apply(null,a);return function(e){return 0!==l&&D(l),function(e){return"string"===t?(n=e)?function(e,t,n){for(var i=t+n,o=t;e[o]&&!(o>=i);)++o;if(o-t>16&&e.buffer&&k)return k.decode(e.subarray(t,o));for(var r="";t<o;){var s=e[t++];if(128&s){var a=63&e[t++];if(192!=(224&s)){var l=63&e[t++];if((s=224==(240&s)?(15&s)<<12|a<<6|l:(7&s)<<18|a<<12|l<<6|63&e[t++])<65536)r+=String.fromCharCode(s);else{var c=s-65536;r+=String.fromCharCode(55296|c>>10,56320|1023&c)}}else r+=String.fromCharCode((31&s)<<6|a)}else r+=String.fromCharCode(s)}return r}(m,n,i):"":"boolean"===t?Boolean(e):e;var n,i}(e)}(u)}var F,G={__cxa_throw:function(e,t,n){throw new R(e).init(t,n),e},abort:function(){_("")},emscripten_memcpy_big:function(e,t,n){m.copyWithin(e,t,t+n)},emscripten_resize_heap:function(e){var t=m.length,n=2147483648;if((e>>>=0)>n)return!1;let i=(e,t)=>e+(t-e%t)%t;for(var o=1;o<=4;o*=2){var r=t*(1+.2/o);if(r=Math.min(r,e+100663296),$(Math.min(n,i(Math.max(e,r),65536))))return!0}return!1}},B=(function(){var e,t,i,r,s={env:G,wasi_snapshot_preview1:G};function a(e,t){var n,i=e.exports;return o.asm=i,u=o.asm.memory,y(),o.asm.__indirect_function_table,n=o.asm.__wasm_call_ctors,v.unshift(n),function(){if(E--,o.monitorRunDependencies&&o.monitorRunDependencies(E),0==E&&(null!==M&&(clearInterval(M),M=null),T)){var e=T;T=null,e()}}(),i}if(E++,o.monitorRunDependencies&&o.monitorRunDependencies(E),o.instantiateWasm)try{return o.instantiateWasm(s,a)}catch(e){d("Module.instantiateWasm callback failed with error: "+e),n(e)}(e=h,t=A,i=s,r=function(e){a(e.instance)},e||"function"!=typeof WebAssembly.instantiateStreaming||I(t)||"function"!=typeof fetch?N(t,i,r):fetch(t,{credentials:"same-origin"}).then(function(e){return WebAssembly.instantiateStreaming(e,i).then(r,function(e){return d("wasm streaming compile failed: "+e),d("falling back to ArrayBuffer instantiation"),N(t,i,r)})})).catch(n)}(),o._dbscan=function(){return(o._dbscan=o.asm.dbscan).apply(null,arguments)},o._malloc=function(){return(o._malloc=o.asm.malloc).apply(null,arguments)},o._free=function(){return(o._free=o.asm.free).apply(null,arguments)},function(){return(B=o.asm.stackSave).apply(null,arguments)}),D=function(){return(D=o.asm.stackRestore).apply(null,arguments)},V=function(){return(V=o.asm.stackAlloc).apply(null,arguments)},W=function(){return(W=o.asm.__cxa_is_pointer_type).apply(null,arguments)};function j(){function e(){F||(F=!0,o.calledRun=!0,f||(P(v),t(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),function(){if(o.postRun)for("function"==typeof o.postRun&&(o.postRun=[o.postRun]);o.postRun.length;)S(o.postRun.shift());P(w)}()))}E>0||(function(){if(o.preRun)for("function"==typeof o.preRun&&(o.preRun=[o.preRun]);o.preRun.length;)C(o.preRun.shift());P(b)}(),E>0||(o.setStatus?(o.setStatus("Running..."),setTimeout(function(){setTimeout(function(){o.setStatus("")},1),e()},1)):e()))}if(o.ccall=H,o.cwrap=function(e,t,n,i){var o=!n||n.every(e=>"number"===e||"boolean"===e);return"string"!==t&&o&&!i?O(e):function(){return H(e,t,n,arguments)}},T=function e(){F||j(),F||(T=e)},o.preInit)for("function"==typeof o.preInit&&(o.preInit=[o.preInit]);o.preInit.length>0;)o.preInit.pop()();return j(),e.ready});"object"==typeof exports?e.exports=o:"function"==typeof define&&n.amdO?define([],function(){return o}):"object"==typeof exports&&(exports.exportCppDbscanLib=o)},5553:(e,t,n)=>{"use strict";n.d(t,{Qc:()=>S,WN:()=>A});var i=n(1991),o=n.n(i);const r="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,s=new Set,a="object"==typeof process&&process?process:{},l=(e,t,n,i)=>{"function"==typeof a.emitWarning?a.emitWarning(e,t,n,i):console.error(`[${n}] ${t}: ${e}`)};let c=globalThis.AbortController,h=globalThis.AbortSignal;if(void 0===c){h=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(e,t){this._onabort.push(t)}},c=class{constructor(){t()}signal=new h;abort(e){if(!this.signal.aborted){this.signal.reason=e,this.signal.aborted=!0;for(const t of this.signal._onabort)t(e);this.signal.onabort?.(e)}}};let e="1"!==a.env?.LRU_CACHE_IGNORE_AC_WARNING;const t=()=>{e&&(e=!1,l("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",t))}}Symbol("type");const u=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),d=e=>u(e)?e<=Math.pow(2,8)?Uint8Array:e<=Math.pow(2,16)?Uint16Array:e<=Math.pow(2,32)?Uint32Array:e<=Number.MAX_SAFE_INTEGER?p:null:null;class p extends Array{constructor(e){super(e),this.fill(0)}}class m{heap;length;static#e=!1;static create(e){const t=d(e);if(!t)return[];m.#e=!0;const n=new m(e,t);return m.#e=!1,n}constructor(e,t){if(!m.#e)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}}class g{#t;#n;#i;#o;#r;#s;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#a;#l;#c;#h;#u;#d;#p;#m;#g;#f;#y;#b;#v;#w;#C;#S;#A;static unsafeExposeInternals(e){return{starts:e.#v,ttls:e.#w,sizes:e.#b,keyMap:e.#c,keyList:e.#h,valList:e.#u,next:e.#d,prev:e.#p,get head(){return e.#m},get tail(){return e.#g},free:e.#f,isBackgroundFetch:t=>e.#x(t),backgroundFetch:(t,n,i,o)=>e.#E(t,n,i,o),moveToTail:t=>e.#M(t),indexes:t=>e.#T(t),rindexes:t=>e.#_(t),isStale:t=>e.#I(t)}}get max(){return this.#t}get maxSize(){return this.#n}get calculatedSize(){return this.#l}get size(){return this.#a}get fetchMethod(){return this.#r}get memoMethod(){return this.#s}get dispose(){return this.#i}get disposeAfter(){return this.#o}constructor(e){const{max:t=0,ttl:n,ttlResolution:i=1,ttlAutopurge:o,updateAgeOnGet:r,updateAgeOnHas:a,allowStale:c,dispose:h,disposeAfter:p,noDisposeOnSet:f,noUpdateTTL:y,maxSize:b=0,maxEntrySize:v=0,sizeCalculation:w,fetchMethod:C,memoMethod:S,noDeleteOnFetchRejection:A,noDeleteOnStaleGet:x,allowStaleOnFetchRejection:E,allowStaleOnFetchAbort:M,ignoreFetchAbort:T}=e;if(0!==t&&!u(t))throw new TypeError("max option must be a nonnegative integer");const _=t?d(t):Array;if(!_)throw new Error("invalid max value: "+t);if(this.#t=t,this.#n=b,this.maxEntrySize=v||this.#n,this.sizeCalculation=w,this.sizeCalculation){if(!this.#n&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if("function"!=typeof this.sizeCalculation)throw new TypeError("sizeCalculation set to non-function")}if(void 0!==S&&"function"!=typeof S)throw new TypeError("memoMethod must be a function if defined");if(this.#s=S,void 0!==C&&"function"!=typeof C)throw new TypeError("fetchMethod must be a function if specified");if(this.#r=C,this.#S=!!C,this.#c=new Map,this.#h=new Array(t).fill(void 0),this.#u=new Array(t).fill(void 0),this.#d=new _(t),this.#p=new _(t),this.#m=0,this.#g=0,this.#f=m.create(t),this.#a=0,this.#l=0,"function"==typeof h&&(this.#i=h),"function"==typeof p?(this.#o=p,this.#y=[]):(this.#o=void 0,this.#y=void 0),this.#C=!!this.#i,this.#A=!!this.#o,this.noDisposeOnSet=!!f,this.noUpdateTTL=!!y,this.noDeleteOnFetchRejection=!!A,this.allowStaleOnFetchRejection=!!E,this.allowStaleOnFetchAbort=!!M,this.ignoreFetchAbort=!!T,0!==this.maxEntrySize){if(0!==this.#n&&!u(this.#n))throw new TypeError("maxSize must be a positive integer if specified");if(!u(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#L()}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!x,this.updateAgeOnGet=!!r,this.updateAgeOnHas=!!a,this.ttlResolution=u(i)||0===i?i:1,this.ttlAutopurge=!!o,this.ttl=n||0,this.ttl){if(!u(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#N()}if(0===this.#t&&0===this.ttl&&0===this.#n)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#t&&!this.#n){const e="LRU_CACHE_UNBOUNDED";(e=>!s.has(e))(e)&&(s.add(e),l("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",e,g))}}getRemainingTTL(e){return this.#c.has(e)?1/0:0}#N(){const e=new p(this.#t),t=new p(this.#t);this.#w=e,this.#v=t,this.#P=(n,i,o=r.now())=>{if(t[n]=0!==i?o:0,e[n]=i,0!==i&&this.ttlAutopurge){const e=setTimeout(()=>{this.#I(n)&&this.#R(this.#h[n],"expire")},i+1);e.unref&&e.unref()}},this.#$=n=>{t[n]=0!==e[n]?r.now():0},this.#O=(o,r)=>{if(e[r]){const s=e[r],a=t[r];if(!s||!a)return;o.ttl=s,o.start=a,o.now=n||i();const l=o.now-a;o.remainingTTL=s-l}};let n=0;const i=()=>{const e=r.now();if(this.ttlResolution>0){n=e;const t=setTimeout(()=>n=0,this.ttlResolution);t.unref&&t.unref()}return e};this.getRemainingTTL=o=>{const r=this.#c.get(o);if(void 0===r)return 0;const s=e[r],a=t[r];return s&&a?s-((n||i())-a):1/0},this.#I=o=>{const r=t[o],s=e[o];return!!s&&!!r&&(n||i())-r>s}}#$=()=>{};#O=()=>{};#P=()=>{};#I=()=>!1;#L(){const e=new p(this.#t);this.#l=0,this.#b=e,this.#k=t=>{this.#l-=e[t],e[t]=0},this.#H=(e,t,n,i)=>{if(this.#x(t))return 0;if(!u(n)){if(!i)throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");if("function"!=typeof i)throw new TypeError("sizeCalculation must be a function");if(n=i(t,e),!u(n))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return n},this.#F=(t,n,i)=>{if(e[t]=n,this.#n){const n=this.#n-e[t];for(;this.#l>n;)this.#G(!0)}this.#l+=e[t],i&&(i.entrySize=n,i.totalCalculatedSize=this.#l)}}#k=e=>{};#F=(e,t,n)=>{};#H=(e,t,n,i)=>{if(n||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#T({allowStale:e=this.allowStale}={}){if(this.#a)for(let t=this.#g;this.#B(t)&&(!e&&this.#I(t)||(yield t),t!==this.#m);)t=this.#p[t]}*#_({allowStale:e=this.allowStale}={}){if(this.#a)for(let t=this.#m;this.#B(t)&&(!e&&this.#I(t)||(yield t),t!==this.#g);)t=this.#d[t]}#B(e){return void 0!==e&&this.#c.get(this.#h[e])===e}*entries(){for(const e of this.#T())void 0===this.#u[e]||void 0===this.#h[e]||this.#x(this.#u[e])||(yield[this.#h[e],this.#u[e]])}*rentries(){for(const e of this.#_())void 0===this.#u[e]||void 0===this.#h[e]||this.#x(this.#u[e])||(yield[this.#h[e],this.#u[e]])}*keys(){for(const e of this.#T()){const t=this.#h[e];void 0===t||this.#x(this.#u[e])||(yield t)}}*rkeys(){for(const e of this.#_()){const t=this.#h[e];void 0===t||this.#x(this.#u[e])||(yield t)}}*values(){for(const e of this.#T())void 0===this.#u[e]||this.#x(this.#u[e])||(yield this.#u[e])}*rvalues(){for(const e of this.#_())void 0===this.#u[e]||this.#x(this.#u[e])||(yield this.#u[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,t={}){for(const n of this.#T()){const i=this.#u[n],o=this.#x(i)?i.__staleWhileFetching:i;if(void 0!==o&&e(o,this.#h[n],this))return this.get(this.#h[n],t)}}forEach(e,t=this){for(const n of this.#T()){const i=this.#u[n],o=this.#x(i)?i.__staleWhileFetching:i;void 0!==o&&e.call(t,o,this.#h[n],this)}}rforEach(e,t=this){for(const n of this.#_()){const i=this.#u[n],o=this.#x(i)?i.__staleWhileFetching:i;void 0!==o&&e.call(t,o,this.#h[n],this)}}purgeStale(){let e=!1;for(const t of this.#_({allowStale:!0}))this.#I(t)&&(this.#R(this.#h[t],"expire"),e=!0);return e}info(e){const t=this.#c.get(e);if(void 0===t)return;const n=this.#u[t],i=this.#x(n)?n.__staleWhileFetching:n;if(void 0===i)return;const o={value:i};if(this.#w&&this.#v){const e=this.#w[t],n=this.#v[t];if(e&&n){const t=e-(r.now()-n);o.ttl=t,o.start=Date.now()}}return this.#b&&(o.size=this.#b[t]),o}dump(){const e=[];for(const t of this.#T({allowStale:!0})){const n=this.#h[t],i=this.#u[t],o=this.#x(i)?i.__staleWhileFetching:i;if(void 0===o||void 0===n)continue;const s={value:o};if(this.#w&&this.#v){s.ttl=this.#w[t];const e=r.now()-this.#v[t];s.start=Math.floor(Date.now()-e)}this.#b&&(s.size=this.#b[t]),e.unshift([n,s])}return e}load(e){this.clear();for(const[t,n]of e){if(n.start){const e=Date.now()-n.start;n.start=r.now()-e}this.set(t,n.value,n)}}set(e,t,n={}){if(void 0===t)return this.delete(e),this;const{ttl:i=this.ttl,start:o,noDisposeOnSet:r=this.noDisposeOnSet,sizeCalculation:s=this.sizeCalculation,status:a}=n;let{noUpdateTTL:l=this.noUpdateTTL}=n;const c=this.#H(e,t,n.size||0,s);if(this.maxEntrySize&&c>this.maxEntrySize)return a&&(a.set="miss",a.maxEntrySizeExceeded=!0),this.#R(e,"set"),this;let h=0===this.#a?void 0:this.#c.get(e);if(void 0===h)h=0===this.#a?this.#g:0!==this.#f.length?this.#f.pop():this.#a===this.#t?this.#G(!1):this.#a,this.#h[h]=e,this.#u[h]=t,this.#c.set(e,h),this.#d[this.#g]=h,this.#p[h]=this.#g,this.#g=h,this.#a++,this.#F(h,c,a),a&&(a.set="add"),l=!1;else{this.#M(h);const n=this.#u[h];if(t!==n){if(this.#S&&this.#x(n)){n.__abortController.abort(new Error("replaced"));const{__staleWhileFetching:t}=n;void 0===t||r||(this.#C&&this.#i?.(t,e,"set"),this.#A&&this.#y?.push([t,e,"set"]))}else r||(this.#C&&this.#i?.(n,e,"set"),this.#A&&this.#y?.push([n,e,"set"]));if(this.#k(h),this.#F(h,c,a),this.#u[h]=t,a){a.set="replace";const e=n&&this.#x(n)?n.__staleWhileFetching:n;void 0!==e&&(a.oldValue=e)}}else a&&(a.set="update")}if(0===i||this.#w||this.#N(),this.#w&&(l||this.#P(h,i,o),a&&this.#O(a,h)),!r&&this.#A&&this.#y){const e=this.#y;let t;for(;t=e?.shift();)this.#o?.(...t)}return this}pop(){try{for(;this.#a;){const e=this.#u[this.#m];if(this.#G(!0),this.#x(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(void 0!==e)return e}}finally{if(this.#A&&this.#y){const e=this.#y;let t;for(;t=e?.shift();)this.#o?.(...t)}}}#G(e){const t=this.#m,n=this.#h[t],i=this.#u[t];return this.#S&&this.#x(i)?i.__abortController.abort(new Error("evicted")):(this.#C||this.#A)&&(this.#C&&this.#i?.(i,n,"evict"),this.#A&&this.#y?.push([i,n,"evict"])),this.#k(t),e&&(this.#h[t]=void 0,this.#u[t]=void 0,this.#f.push(t)),1===this.#a?(this.#m=this.#g=0,this.#f.length=0):this.#m=this.#d[t],this.#c.delete(n),this.#a--,t}has(e,t={}){const{updateAgeOnHas:n=this.updateAgeOnHas,status:i}=t,o=this.#c.get(e);if(void 0!==o){const e=this.#u[o];if(this.#x(e)&&void 0===e.__staleWhileFetching)return!1;if(!this.#I(o))return n&&this.#$(o),i&&(i.has="hit",this.#O(i,o)),!0;i&&(i.has="stale",this.#O(i,o))}else i&&(i.has="miss");return!1}peek(e,t={}){const{allowStale:n=this.allowStale}=t,i=this.#c.get(e);if(void 0===i||!n&&this.#I(i))return;const o=this.#u[i];return this.#x(o)?o.__staleWhileFetching:o}#E(e,t,n,i){const o=void 0===t?void 0:this.#u[t];if(this.#x(o))return o;const r=new c,{signal:s}=n;s?.addEventListener("abort",()=>r.abort(s.reason),{signal:r.signal});const a={signal:r.signal,options:n,context:i},l=(i,o=!1)=>{const{aborted:s}=r.signal,l=n.ignoreFetchAbort&&void 0!==i;if(n.status&&(s&&!o?(n.status.fetchAborted=!0,n.status.fetchError=r.signal.reason,l&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),s&&!l&&!o)return h(r.signal.reason);const c=u;return this.#u[t]===u&&(void 0===i?c.__staleWhileFetching?this.#u[t]=c.__staleWhileFetching:this.#R(e,"fetch"):(n.status&&(n.status.fetchUpdated=!0),this.set(e,i,a.options))),i},h=i=>{const{aborted:o}=r.signal,s=o&&n.allowStaleOnFetchAbort,a=s||n.allowStaleOnFetchRejection,l=a||n.noDeleteOnFetchRejection,c=u;if(this.#u[t]===u&&(l&&void 0!==c.__staleWhileFetching?s||(this.#u[t]=c.__staleWhileFetching):this.#R(e,"fetch")),a)return n.status&&void 0!==c.__staleWhileFetching&&(n.status.returnedStale=!0),c.__staleWhileFetching;if(c.__returned===c)throw i};n.status&&(n.status.fetchDispatched=!0);const u=new Promise((t,i)=>{const s=this.#r?.(e,o,a);s&&s instanceof Promise&&s.then(e=>t(void 0===e?void 0:e),i),r.signal.addEventListener("abort",()=>{n.ignoreFetchAbort&&!n.allowStaleOnFetchAbort||(t(void 0),n.allowStaleOnFetchAbort&&(t=e=>l(e,!0)))})}).then(l,e=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=e),h(e))),d=Object.assign(u,{__abortController:r,__staleWhileFetching:o,__returned:void 0});return void 0===t?(this.set(e,d,{...a.options,status:void 0}),t=this.#c.get(e)):this.#u[t]=d,d}#x(e){if(!this.#S)return!1;const t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof c}async fetch(e,t={}){const{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:r=this.ttl,noDisposeOnSet:s=this.noDisposeOnSet,size:a=0,sizeCalculation:l=this.sizeCalculation,noUpdateTTL:c=this.noUpdateTTL,noDeleteOnFetchRejection:h=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:u=this.allowStaleOnFetchRejection,ignoreFetchAbort:d=this.ignoreFetchAbort,allowStaleOnFetchAbort:p=this.allowStaleOnFetchAbort,context:m,forceRefresh:g=!1,status:f,signal:y}=t;if(!this.#S)return f&&(f.fetch="get"),this.get(e,{allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:o,status:f});const b={allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:o,ttl:r,noDisposeOnSet:s,size:a,sizeCalculation:l,noUpdateTTL:c,noDeleteOnFetchRejection:h,allowStaleOnFetchRejection:u,allowStaleOnFetchAbort:p,ignoreFetchAbort:d,status:f,signal:y};let v=this.#c.get(e);if(void 0===v){f&&(f.fetch="miss");const t=this.#E(e,v,b,m);return t.__returned=t}{const t=this.#u[v];if(this.#x(t)){const e=n&&void 0!==t.__staleWhileFetching;return f&&(f.fetch="inflight",e&&(f.returnedStale=!0)),e?t.__staleWhileFetching:t.__returned=t}const o=this.#I(v);if(!g&&!o)return f&&(f.fetch="hit"),this.#M(v),i&&this.#$(v),f&&this.#O(f,v),t;const r=this.#E(e,v,b,m),s=void 0!==r.__staleWhileFetching&&n;return f&&(f.fetch=o?"stale":"refresh",s&&o&&(f.returnedStale=!0)),s?r.__staleWhileFetching:r.__returned=r}}async forceFetch(e,t={}){const n=await this.fetch(e,t);if(void 0===n)throw new Error("fetch() returned undefined");return n}memo(e,t={}){const n=this.#s;if(!n)throw new Error("no memoMethod provided to constructor");const{context:i,forceRefresh:o,...r}=t,s=this.get(e,r);if(!o&&void 0!==s)return s;const a=n(e,s,{options:r,context:i});return this.set(e,a,r),a}get(e,t={}){const{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:r}=t,s=this.#c.get(e);if(void 0!==s){const t=this.#u[s],a=this.#x(t);return r&&this.#O(r,s),this.#I(s)?(r&&(r.get="stale"),a?(r&&n&&void 0!==t.__staleWhileFetching&&(r.returnedStale=!0),n?t.__staleWhileFetching:void 0):(o||this.#R(e,"expire"),r&&n&&(r.returnedStale=!0),n?t:void 0)):(r&&(r.get="hit"),a?t.__staleWhileFetching:(this.#M(s),i&&this.#$(s),t))}r&&(r.get="miss")}#D(e,t){this.#p[t]=e,this.#d[e]=t}#M(e){e!==this.#g&&(e===this.#m?this.#m=this.#d[e]:this.#D(this.#p[e],this.#d[e]),this.#D(this.#g,e),this.#g=e)}delete(e){return this.#R(e,"delete")}#R(e,t){let n=!1;if(0!==this.#a){const i=this.#c.get(e);if(void 0!==i)if(n=!0,1===this.#a)this.#V(t);else{this.#k(i);const n=this.#u[i];if(this.#x(n)?n.__abortController.abort(new Error("deleted")):(this.#C||this.#A)&&(this.#C&&this.#i?.(n,e,t),this.#A&&this.#y?.push([n,e,t])),this.#c.delete(e),this.#h[i]=void 0,this.#u[i]=void 0,i===this.#g)this.#g=this.#p[i];else if(i===this.#m)this.#m=this.#d[i];else{const e=this.#p[i];this.#d[e]=this.#d[i];const t=this.#d[i];this.#p[t]=this.#p[i]}this.#a--,this.#f.push(i)}}if(this.#A&&this.#y?.length){const e=this.#y;let t;for(;t=e?.shift();)this.#o?.(...t)}return n}clear(){return this.#V("delete")}#V(e){for(const t of this.#_({allowStale:!0})){const n=this.#u[t];if(this.#x(n))n.__abortController.abort(new Error("deleted"));else{const i=this.#h[t];this.#C&&this.#i?.(n,i,e),this.#A&&this.#y?.push([n,i,e])}}if(this.#c.clear(),this.#u.fill(void 0),this.#h.fill(void 0),this.#w&&this.#v&&(this.#w.fill(0),this.#v.fill(0)),this.#b&&this.#b.fill(0),this.#m=0,this.#g=0,this.#f.length=0,this.#l=0,this.#a=0,this.#A&&this.#y){const e=this.#y;let t;for(;t=e?.shift();)this.#o?.(...t)}}}function f(e){window.$monomerHover=e}var y=n(2003),b=n(6077),v=n(3561),w=n(9235);const C="MonomerHoverLinks";async function S(e,t,n,i,r,s=!1){const a=i.getSeqHandler(e),l=a.alphabet==y.YI.RNA||a.alphabet==y.YI.DNA,c=a.isHelm()&&l,h=!a.isHelm()&&l,u=e=>null==e?null:c?s?e:Math.floor(e/3):h&&s?3*e+1:e,d=s?await i.getHelmToMolfileConverter(n):null,p=new g({max:100});function m(e,t){const a=e.get(t);if(null==a)return null;let l=p.get(a);return l||p.set(a,l=function(e,t){const a=i.getSeqHandler(e);if(s){const e=a.getHelm(t);return i.helmToAtomicLevelSingle(e,d,!1,!1).monomers}{const e=a.getSplitted(t),i=a.defaultBiotype,s=o().count(0).take(e.length).map(t=>({position:t,symbol:e.getCanonical(t),biotype:i})).toArray(),l=a.alphabet,c=l==y.YI.RNA||l==y.YI.DNA?"RNA":"PEPTIDE",h=(0,b.eM)([s],c,l,n,r);return(0,v.gU)(s,h,l,c).monomers}}(e,t)),l}const S={targetCol:t,handler:(t,i,o)=>{const r=o.grid,s=t.tableRowIndex,a=t.gridRow,l=r.cell(o.name,a),c=null!==(h=window.$monomerHover)&&void 0!==h?h:null;var h;if(!c||c&&(c.dataFrameId!=e.dataFrame.id||c.gridRowIdx!=a||c.seqColName!=e.name||c.seqPosition!=i?.position)){if(c&&(f(null),c.gridCell.render()),!i)return f(null),!0;f({gridCell:l,dataFrameId:e.dataFrame.id,gridRowIdx:a,seqColName:e.name,seqPosition:u(i?.position)??-1,getSubstruct:()=>{if(!i||"*"===i.symbol)return;const t=m(e,s);if(!t)return;const o=t.get(u(i?.position));return o?(0,w.H)([o],n):{atoms:[],bonds:[],highlightAtomColors:[],highlightBondColors:[]}}}),l.render()}return!0},getSubstruct:i=>{if("true"!=t.getTag(".sequence-src-highlight-monomers"))return;if(null==i)return;if(!e.get(i))return;const o=m(e,i);return o?(0,w.H)(o.values(),n):void 0}};return function(e,t){let n=e[C];n||(n=e[C]=[]),n.push(t),e[C]=n}(e.temp,S),function(e,t){let n=e["substruct-providers"];n||(n=e["substruct-providers"]=[]),n.push(t),e["substruct-providers"]=n}(t.temp,S),S}function A(e,t){try{const n=e.tableColumn;if(!n)return;const i=function(e){return e.temp[C]??[]}(n);for(let n=i.length-1;n>=0;--n){const o=i[n],r=e.grid.col(o.targetCol.name);if(r&&!o.handler(e,t,r))break}}catch(e){console.error(e)}}},5707:e=>{"use strict";e.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/meta/meta-data","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/meta-data":true},"$dynamicAnchor":"meta","title":"Meta-data vocabulary meta-schema","type":["object","boolean"],"properties":{"title":{"type":"string"},"description":{"type":"string"},"default":true,"deprecated":{"type":"boolean","default":false},"readOnly":{"type":"boolean","default":false},"writeOnly":{"type":"boolean","default":false},"examples":{"type":"array","items":true}}}')},5765:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validateUnion=t.validateArray=t.usePattern=t.callValidateCode=t.schemaProperties=t.allSchemaProperties=t.noPropertyInData=t.propertyInData=t.isOwnProperty=t.hasPropFunc=t.reportMissingProp=t.checkMissingProp=t.checkReportMissingProp=void 0;const i=n(9029),o=n(4227),r=n(2023),s=n(4227);function a(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:i._`Object.prototype.hasOwnProperty`})}function l(e,t,n){return i._`${a(e)}.call(${t}, ${n})`}function c(e,t,n,o){const r=i._`${t}${(0,i.getProperty)(n)} === undefined`;return o?(0,i.or)(r,(0,i.not)(l(e,t,n))):r}function h(e){return e?Object.keys(e).filter(e=>"__proto__"!==e):[]}t.checkReportMissingProp=function(e,t){const{gen:n,data:o,it:r}=e;n.if(c(n,o,t,r.opts.ownProperties),()=>{e.setParams({missingProperty:i._`${t}`},!0),e.error()})},t.checkMissingProp=function({gen:e,data:t,it:{opts:n}},o,r){return(0,i.or)(...o.map(o=>(0,i.and)(c(e,t,o,n.ownProperties),i._`${r} = ${o}`)))},t.reportMissingProp=function(e,t){e.setParams({missingProperty:t},!0),e.error()},t.hasPropFunc=a,t.isOwnProperty=l,t.propertyInData=function(e,t,n,o){const r=i._`${t}${(0,i.getProperty)(n)} !== undefined`;return o?i._`${r} && ${l(e,t,n)}`:r},t.noPropertyInData=c,t.allSchemaProperties=h,t.schemaProperties=function(e,t){return h(t).filter(n=>!(0,o.alwaysValidSchema)(e,t[n]))},t.callValidateCode=function({schemaCode:e,data:t,it:{gen:n,topSchemaRef:o,schemaPath:s,errorPath:a},it:l},c,h,u){const d=u?i._`${e}, ${t}, ${o}${s}`:t,p=[[r.default.instancePath,(0,i.strConcat)(r.default.instancePath,a)],[r.default.parentData,l.parentData],[r.default.parentDataProperty,l.parentDataProperty],[r.default.rootData,r.default.rootData]];l.opts.dynamicRef&&p.push([r.default.dynamicAnchors,r.default.dynamicAnchors]);const m=i._`${d}, ${n.object(...p)}`;return h!==i.nil?i._`${c}.call(${h}, ${m})`:i._`${c}(${m})`};const u=i._`new RegExp`;t.usePattern=function({gen:e,it:{opts:t}},n){const o=t.unicodeRegExp?"u":"",{regExp:r}=t.code,a=r(n,o);return e.scopeValue("pattern",{key:a.toString(),ref:a,code:i._`${"new RegExp"===r.code?u:(0,s.useFunc)(e,r)}(${n}, ${o})`})},t.validateArray=function(e){const{gen:t,data:n,keyword:r,it:s}=e,a=t.name("valid");if(s.allErrors){const e=t.let("valid",!0);return l(()=>t.assign(e,!1)),e}return t.var(a,!0),l(()=>t.break()),a;function l(s){const l=t.const("len",i._`${n}.length`);t.forRange("i",0,l,n=>{e.subschema({keyword:r,dataProp:n,dataPropType:o.Type.Num},a),t.if((0,i.not)(a),s)})}},t.validateUnion=function(e){const{gen:t,schema:n,keyword:r,it:s}=e;if(!Array.isArray(n))throw new Error("ajv implementation error");if(n.some(e=>(0,o.alwaysValidSchema)(s,e))&&!s.opts.unevaluated)return;const a=t.let("valid",!1),l=t.name("_valid");t.block(()=>n.forEach((n,o)=>{const s=e.subschema({keyword:r,schemaProp:o,compositeRule:!0},l);t.assign(a,i._`${a} || ${l}`),e.mergeValidEvaluated(s,l)||t.if((0,i.not)(a))})),e.result(a,()=>e.reset(),()=>e.error(!0))}},5844:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(4227),o={keyword:"allOf",schemaType:"array",code(e){const{gen:t,schema:n,it:o}=e;if(!Array.isArray(n))throw new Error("ajv implementation error");const r=t.name("valid");n.forEach((t,n)=>{if((0,i.alwaysValidSchema)(o,t))return;const s=e.subschema({keyword:"allOf",schemaProp:n},r);e.ok(r),e.mergeEvaluated(s)})}};t.default=o},5882:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o=i.operators,r={maximum:{okStr:"<=",ok:o.LTE,fail:o.GT},minimum:{okStr:">=",ok:o.GTE,fail:o.LT},exclusiveMaximum:{okStr:"<",ok:o.LT,fail:o.GTE},exclusiveMinimum:{okStr:">",ok:o.GT,fail:o.LTE}},s={message:({keyword:e,schemaCode:t})=>i.str`must be ${r[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>i._`{comparison: ${r[e].okStr}, limit: ${t}}`},a={keyword:Object.keys(r),type:"number",schemaType:"number",$data:!0,error:s,code(e){const{keyword:t,data:n,schemaCode:o}=e;e.fail$data(i._`${n} ${r[t].fail} ${o} || isNaN(${n})`)}};t.default=a},5944:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(8343);i.code='require("ajv/dist/runtime/uri").default',t.default=i},5999:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var i=n(1354),o=n.n(i),r=n(6314),s=n.n(r)()(o());s.push([e.id,".macromolecule-cell-comp-analysis-host{\n max-height: 250px;\n overflow-y: scroll;\n}\n\n.macromolecule-cell-comp-analysis-bar{\n height: inherit;\n display: block;\n margin-top: 1.5px;\n margin-bottom: 1.5px;\n margin-right: 3px;\n}\n\n.macromolecule-cell-comp-analysis-value{\n display: flex;\n}","",{version:3,sources:["webpack://./css/composition-analysis.css"],names:[],mappings:"AAAA;IACI,iBAAiB;IACjB,kBAAkB;AACtB;;AAEA;IACI,eAAe;IACf,cAAc;IACd,iBAAiB;IACjB,oBAAoB;IACpB,iBAAiB;AACrB;;AAEA;IACI,aAAa;AACjB",sourcesContent:[".macromolecule-cell-comp-analysis-host{\n max-height: 250px;\n overflow-y: scroll;\n}\n\n.macromolecule-cell-comp-analysis-bar{\n height: inherit;\n display: block;\n margin-top: 1.5px;\n margin-bottom: 1.5px;\n margin-right: 3px;\n}\n\n.macromolecule-cell-comp-analysis-value{\n display: flex;\n}"],sourceRoot:""}]);const a=s},6077:(e,t,n)=>{"use strict";n.d(t,{C4:()=>m,eM:()=>g});var i=n(4328),o=n(6082),r=n(1991),s=n.n(r),a=n(439),l=n(3561),c=n(9235),h=n(294),u=n(9192),d=n(330),p=n(8123);async function m(e,t,n,r,l){if(t.semType!==o.SEMTYPE.MACROMOLECULE)return{molCol:null,warnings:[`Only the ${o.SEMTYPE.MACROMOLECULE} columns can be converted to atomic level, the chosen column has semType '${t.semType}'`]};let h=t;const p=r.getSeqHandler(t);let m,f;p.notation!==a.Hi.SEPARATOR&&p.notation!==a.Hi.BILN&&(h=p.convert(a.Hi.SEPARATOR,"."),h.name=t.name);try{f=r.getSeqHandler(h).alphabet,m=(0,d.pz)(f)}catch(e){const[t,n]=(0,u.AP)(e);return{molCol:null,warnings:[t]}}const y=function(e,t){const n=e.length,o=new Array(n),r=t.getSeqHandler(e);let a=!1;const l=r.defaultBiotype;for(let e=0;e<n;++e){const t=r.getSplitted(e);a||(a=0===t.length),o[e]=s().count(0).take(t.length).filter(e=>!t.isGap(e)).map(e=>({position:e,biotype:l,symbol:t.getCanonical(e)})).toArray()}return a&&i.shell.warning(`Some values in the "${e.name}" column are empty`),o}(h,r),b=g(y,m,f,n,l),v=h.length,w=await(0,c.R)(h,b,f,m,n,r,l);w.warnings.length>.05*v&&i.shell.warning(`Molfile conversion resulted in ${w.warnings.length} errors`);const C=o.Func.find({name:"convertToV3KViaOCL"})[0];if(C&&w.molCol)try{const e=w.molCol.toList(),t=await C.apply({mols:e});w.molCol.init(n=>t[n]?t[n]:e[n])}catch(e){console.error(e)}return w}function g(e,t,n,i,o){const r=(0,l.Hb)(i,t,n),s={},c={value:null};if("RNA"===t){const e=n===a.YI.RNA?[p.u.RIBOSE,p.u.PHOSPHATE]:[p.u.DEOXYRIBOSE,p.u.PHOSPHATE];for(const n of e)f(s,n.symbol,r,o,t,c)}for(let n=0;n<e.length;++n){const i=e[n];for(const e of i){const n=e.symbol;if(""!==n)try{if("RNA"===t&&3===n.split(/\(|\)/).filter(e=>!!e).length){const e=n.split(/\(|\)/)[1];f(s,e,r,o,t,c),s[t]?.[e]&&(s[t][n]=s[t][e])}else f(s,n,r,o,t,c)}catch(e){const t=e instanceof Error?e.message:e.toString(),i=e instanceof Error?e.stack:void 0;throw console.error(`bio lib: getMonomersDictFromLib() sym='${n}', error:\n${t}\n${i}`),new Error(`Can't get monomer '${n}' from library: ${t}`)}}}return s}function f(e,t,n,i,o,r){const s={polymerType:o,symbol:t};if(!(0,h.bq)(e,s)){const a=function(e,t,n,i,o){if(t.has(e)){const s=t.get(e),a=function(e){const t=[];for(const n of e){let e=n.capGroupSmiles;e||(e=n.capGroupSMILES),e=e.replace(/(\[|\]|\*|:|\d)/g,"").replace("OH","O").replace("Oh","O"),t.push(e)}return t}(s.rgroups),c=(r=s.molfile).includes("V3000")?function(e){const t=new Map,n=/M V30 (\d+) R#.+RGROUPS=\((\d+) (\d+)\).*/gm;let i;for(;null!==(i=n.exec(e));)i.index===n.lastIndex&&n.lastIndex++,t.set(parseInt(i[1]),parseInt(i[3]));return t}(r):function(e){const t=new Map;let n=e.indexOf(p.u.V2K_A_LINE,0),i=n;for(;-1!==n;){i=e.indexOf("\n",n);const o=parseInt(e.substring(n,i).replace(/^A\s+/,""));n=e.indexOf("R",i),i=e.indexOf("\n",n);const r=parseInt(e.substring(n,i).replace(/^R/,""));t.set(o,r),n=e.indexOf(p.u.V2K_A_LINE,i)}for(n=e.indexOf(p.u.V2K_RGP_LINE,0),i=e.indexOf("\n",n);-1!==n;){n+=p.u.V2K_RGP_SHIFT,i=e.indexOf("\n",n);const o=e.substring(n,i).replaceAll(/\s+/g," ").split(" ").map(e=>parseInt(e)).slice(1);for(let e=0;e<o.length;e+=2){if(t.has(o[e])&&t.get(o[e])!==o[e+1])throw new Error(`r-group index ${o[e]} has already been added with a different value`);t.set(o[e],o[e+1])}n=e.indexOf(p.u.V2K_RGP_LINE,i)}return t}(r),h=s.molfile.includes("V3000")?s.molfile:function(e,t){const n=t.get_mol(function(e){return e.split("\n").map(e=>{const t=e.indexOf(" R# "),n=e.indexOf(" R ");if(-1===t&&-1===n)return e;const i=-1!==t?t:n,o=e.split("");for(let e=i+5;e<o.length;e++)" "!==o[e]&&(o[e]="0");return o.join("")}).join("\n")}(e)),i=n.get_v3Kmolblock();return n.delete(),i}(function(e){let t=e.indexOf(p.u.V2K_A_LINE,0);-1===t&&(t=e.indexOf(p.u.V2K_RGP_LINE));const n=e.indexOf(p.u.V3K_END,t);return e.substring(0,t)+e.substring(n)}(s.molfile),n),u=function(e){let t=(e=e.replaceAll("\r","")).indexOf(p.u.V3K_BEGIN_COUNTS_LINE)+p.u.V3K_COUNTS_SHIFT,n=e.indexOf(" ",t+1);const i=parseInt(e.substring(t,n));return t=n+1,n=e.indexOf(" ",t+1),{atomCount:i,bondCount:parseInt(e.substring(t,n))}}(h),d=function(e,t){const n=new Array(t),i=new Float32Array(t),o=new Float32Array(t),r=new Array(t);let s=e.indexOf(p.u.V3K_BEGIN_ATOM_BLOCK);s=e.indexOf("\n",s);let a=s;for(let l=0;l<t;l++){s=e.indexOf(p.u.V3K_BEGIN_DATA_LINE,s)+p.u.V3K_IDX_SHIFT,a=e.indexOf(" ",s),s=a+1,a=e.indexOf(" ",s),n[l]=e.substring(s,a);const t=new Array(2);for(let n=0;n<2;++n)s=a+1,a=e.indexOf(" ",s),t[n]=parseFloat(e.substring(s,a));i[l]=t[0],o[l]=t[1],s=a,a=e.indexOf("\n",s)+1,r[l]=e.slice(s,a),s=a}return{atomTypes:n,x:i,y:o,kwargs:r}}(h,u.atomCount),m=function(e,t){const n=new Uint32Array(t),i=new Array(t),o=new Map,r=new Map;let s=e.indexOf(p.u.V3K_BEGIN_BOND_BLOCK);s=e.indexOf("\n",s);let a=s;for(let l=0;l<t;++l){const t=new Array(3);s=e.indexOf(p.u.V3K_BEGIN_DATA_LINE,a)+p.u.V3K_IDX_SHIFT,a=e.indexOf(" ",s);for(let n=0;n<3;++n)s=a+1,a=Math.min(e.indexOf("\n",s),e.indexOf(" ",s)),t[n]=parseInt(e.slice(s,a));n[l]=t[0],i[l]=t.slice(1);const c=e.indexOf("\n",s);let h=e.slice(a,c),u=h.indexOf(p.u.V3K_BOND_CONFIG);if(-1!==u){u=h.indexOf("=",u)+1;let e=h.indexOf(" ",u);-1===e&&(e=h.length);const t=parseInt(h.slice(u,e));o.set(l,t);const n=p.u.V3K_BOND_CONFIG+t.toString();h=h.replace(n,"")}h||r.set(l,h)}return{bondTypes:n,atomPairs:i,bondConfiguration:o,kwargs:r}}(h,u.bondCount),g=function(e,t,n,i){const o={backboneShift:null,branchShift:null,terminalNodes:[],rNodes:[]};if(n&&i&&[1,2].some(e=>!Array.from(i.values()).find(t=>t==e))){const o=[1,2].find(e=>!Array.from(i.values()).find(t=>t==e)),r=[1,2].find(e=>Array.from(i.values()).find(t=>t==e)),s=Array.from(i.keys()).find(e=>i.get(e)===r)-1,a=e.x[s],l=e.y[s],c=t.atomPairs.find(e=>e.includes(s+1)).find(e=>e!==s+1)-1;let h=e.x.reduce((t,n,i)=>{if(i===s)return t;if(i===c)return t;const o=e.y[i];return Math.sqrt((n-a)**2+(o-l)**2)>Math.sqrt((e.x[t]-a)**2+(e.y[t]-l)**2)?i:t},-1);if(-1===h&&(h=e.x.length,e.x=new Float32Array([...e.x,-a]),e.y=new Float32Array([...e.y,-l]),e.atomTypes=[...e.atomTypes,"H"],e.kwargs=[...e.kwargs,""],t.atomPairs.push([c+1,h+1]),t.bondTypes=new Uint32Array([...t.bondTypes,1]),t.kwargs.set(t.atomPairs.length-1,"")),i.set(h+1,o),1===o)n.unshift(e.atomTypes[h]);else{if(2!==o)throw new Error(`Unexpected missing R-group: ${o}`);n.splice(1,0,e.atomTypes[h])}}return function(e,t,n){for(const[i,o]of n)e.atomTypes[i-1]=t[o-1]}(e,n,i),function(e,t){t.rNodes=Array.from(e.keys());for(let n=0;n<t.rNodes.length;n++)for(const i of[1,2])if(e.get(t.rNodes[n])===i){const e=t.rNodes[i-1];t.rNodes[i-1]=t.rNodes[n],t.rNodes[n]=e}}(i,o),y(t,o),o}(d,m,a,c),f=function(e){let t=[],n=e.indexOf("M V30 MDLV30/STEABS ATOMS=(");for(;-1!==n;){n+=28;const i=e.indexOf(")",n);t=t.concat(e.substring(n,i).split(" ").slice(1).map(e=>parseInt(e))),n=i,n=e.indexOf("M V30 MDLV30/STEABS ATOMS=(",n)}return t}(h),v={atoms:d,bonds:m,meta:g,stereoAtoms:f};return"PEPTIDE"===i?function(e){const t=e.meta.terminalNodes[0]-1,n=e.meta.rNodes[0]-1,i=e.atoms.x,o=e.atoms.y;M(e,-i[t],-o[t]);const r=S(i[n],o[n]);A(e.atoms,-r),i[e.meta.rNodes[1]-1]<0&&x(e);const s=function(e){const t=function(e){const t=new Map;for(const n of e.bonds.atomPairs)for(let e=0;e<2;e++){const i=n[e],o=n[(e+1)%2];t.has(i)?t.get(i)?.push(o):t.set(i,new Array(1).fill(o))}return t}(e);let n=0;const i=e.atoms.atomTypes.length;let o=0;if(e.meta.terminalNodes.length<2)return null;for(;0===n;){const r=t.get(e.meta.terminalNodes[1])[o];if(e.atoms.atomTypes[r-1]===p.u.OXYGEN&&r!==e.meta.rNodes[1]&&(n=r),o++,o>i)return null}return n}(e);null!=s&&(function(e,t){e.atoms.y[e.meta.rNodes[1]-1]<0&&e.atoms.y[t-1]<0&&(function(e){E(e,!0)}(e),A(e.atoms,-function(e,t){return S(e,t)+Math.PI/2}(e.atoms.x[e.meta.terminalNodes[1]-1],e.atoms.y[e.meta.terminalNodes[1]-1])))}(e,s),function(e,t){const n=e.atoms.x;n[e.meta.rNodes[1]-1]>n[t-1]&&function(e,t,n){const i=t-1,o=n-1,r=e.atoms.x,s=e.atoms.y,a=r[i],l=s[i];r[i]=r[o],s[i]=s[o],r[o]=a,s[o]=l}(e,t,e.meta.rNodes[1])}(e,s))}(v):e===p.u.RIBOSE.symbol||e===p.u.DEOXYRIBOSE.symbol?function(e,t){const n=e.atoms.x,i=e.atoms.y;let o=e.meta.terminalNodes[0]-1;const r=e.meta.rNodes[1]-1;M(e,-n[o],-i[o]);const s=S(n[e.meta.rNodes[2]-1],i[e.meta.rNodes[2]-1]);A(e.atoms,-s),n[e.meta.rNodes[0]-1]>n[e.meta.rNodes[1]-1]&&x(e);const a=S(n[r],i[r]);A(e.atoms,3*Math.PI/2-a),t.value=function(e){const t=e.atoms.x,n=e.atoms.y,i=e.meta.rNodes[2]-1,o=e.meta.terminalNodes[2]-1,r=t[i]-t[o],s=n[i]-n[o];return Math.atan2(r,s)}(e),o=e.meta.terminalNodes[0]-1,M(e,-n[o],-i[o])}(v,o):e===p.u.PHOSPHATE.symbol?function(e){const t=e.meta.rNodes[1]-1,n=e.meta.rNodes[0]-1,i=e.atoms.x,o=e.atoms.y;M(e,-i[t],-o[t]);const r=S(i[n],o[n]);A(e.atoms,Math.PI/2-r)}(v):function(e,t){const n=e.atoms.x,i=e.atoms.y,o=e.meta.terminalNodes[0]-1,r=e.meta.rNodes[0]-1;M(e,-n[o],-i[o]);const s=S(n[r],i[r]),a=t.value;if(!a)throw new Error("The value of sugarBranchToOYAngle is null");A(e.atoms,Math.PI-s+a);const c=function(e,t){return(0,l.YN)(Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2))}({x:n[e.meta.rNodes[0]-1],y:i[e.meta.rNodes[0]-1]},{x:n[e.meta.terminalNodes[0]-1],y:i[e.meta.terminalNodes[0]-1]});if(1!=c)for(let e=0;e<n.length;++e)n[e]=(0,l.YN)(n[e]/c),i[e]=(0,l.YN)(i[e]/c)}(v,o),function(e,t,n){if("PEPTIDE"===e){b(t,e);const n=w(t,t.meta.rNodes[1]);n?.removedAtom&&(t.terminalR2Atom=n.removedAtom)}else n===p.u.RIBOSE.symbol||n===p.u.DEOXYRIBOSE.symbol?(w(t,t.meta.rNodes[1]),t.meta.rNodes[1]=t.meta.terminalNodes[1],y(t.bonds,t.meta),b(t,e),w(t,t.meta.rNodes[1]),w(t,t.meta.rNodes[0]),w(t,t.meta.rNodes[2])):n===p.u.PHOSPHATE.symbol&&(t.meta.terminalNodes[0]=t.meta.rNodes[0],M(t,-t.atoms.x[t.meta.terminalNodes[0]-1],-t.atoms.y[t.meta.terminalNodes[0]-1]),b(t,e),w(t,t.meta.rNodes[1]))}(i,v,e),function(e){let t=0;for(;t<e.atoms.atomTypes.length;)e.atoms.atomTypes[t]===p.u.HYDROGEN&&(w(e,t+1),--t),++t}(v),function(e){let t=0;for(;t<e.atoms.atomTypes.length;)"oh"===e.atoms.atomTypes[t]?.toLowerCase()&&(e.atoms.atomTypes[t]="O"),"?"===e.atoms.atomTypes[t]&&(e.atoms.atomTypes[t]="H"),++t}(v),function(e){const t=" RGROUPS=(1 1)";for(let n=0;n<(e.atoms.kwargs?.length??0);n++){const i=e.atoms.kwargs[n];i&&i.includes(t)&&(e.atoms.kwargs[n]=i.replace(t,""))}}(v),v}var r;return null}(t,n,i,o,r);if(!a)throw new Error(`Monomer with symbol '${t}' is absent the monomer library`);(0,h.LQ)(e,s,a)}}function y(e,t){const n=t.rNodes;t.terminalNodes=new Array(n.length).fill(0);const i=t.terminalNodes,o=e.atomPairs;let r=0,s=0;for(;r<o.length&&s<i.length;){for(let e=0;e<i.length;++e)for(let t=0;t<2;++t)o[r][t]===n[e]&&(i[e]=o[r][(t+1)%2],n.length,++s);++r}}function b(e,t){e.meta.rNodes.length>1&&(e.meta.backboneShift=v(e,e.meta.rNodes[1]-1,e.meta.terminalNodes[0]-1)),"RNA"===t&&e.meta.rNodes.length>2&&(e.meta.branchShift=v(e,e.meta.rNodes[2]-1,e.meta.terminalNodes[0]-1))}function v(e,t,n){return[(0,l.YN)(e.atoms.x[t]-e.atoms.x[n]),(0,l.YN)(e.atoms.y[t]-e.atoms.y[n])]}function w(e,t){if(void 0!==t){const n=t-1,i=e.atoms,o=e.bonds,r=e.meta,s=i.atomTypes.splice(n,1)[0];i.x=C(Float32Array,i.x,n,1),i.y=C(Float32Array,i.y,n,1),i.kwargs.splice(n,1);for(let e=0;e<r.terminalNodes.length;++e)r.terminalNodes[e]>t?--r.terminalNodes[e]:r.terminalNodes[e]===t&&(r.terminalNodes[e]=-1);for(let e=0;e<r.rNodes.length;++e)r.rNodes[e]>t?--r.rNodes[e]:r.rNodes[e]===t&&(r.rNodes[e]=-1);let a=0;for(;a<o.atomPairs.length;){const e=o.atomPairs[a][0],n=o.atomPairs[a][1];e===t||n===t?(o.atomPairs.splice(a,1),o.bondTypes=C(Uint32Array,o.bondTypes,a,1),o.bondConfiguration.has(a)&&o.bondConfiguration.delete(a),o.kwargs.has(a)&&o.kwargs.delete(a),--a):(o.atomPairs[a][0]=e>t?e-1:e,o.atomPairs[a][1]=n>t?n-1:n),++a}let l=Array.from(o.bondConfiguration.keys());return l.forEach(e=>{if(o.bondConfiguration.has(e)&&e>n){const t=o.bondConfiguration.get(e);o.bondConfiguration.delete(e),o.bondConfiguration.set(e-1,t)}}),l=Array.from(o.kwargs.keys()),l.forEach(e=>{if(o.kwargs.has(e)&&e>n){const t=o.kwargs.get(e);o.kwargs.delete(e),o.kwargs.set(e-1,t)}}),s?{removedAtom:s}:void 0}}function C(e,t,n,i){const o=new e(t.length-i);let r=0,s=0;for(;r<t.length;)r===n&&(r+=i),o[s]=t[r],++s,++r;return o}function S(e,t){let n;if(0===e)n=t>0?0:Math.PI;else if(0===t)n=e>0?-Math.PI/2:Math.PI/2;else{const i=t/e,o=Math.atan(i);n=e<0?Math.PI/2+o:-Math.PI/2+o}return n}function A(e,t){if(0!==t){const n=e.x,i=e.y,o=Math.cos(t),r=Math.sin(t);for(let e=0;e<n.length;++e){const t=n[e];n[e]=(0,l.YN)(t*o-i[e]*r),i[e]=(0,l.YN)(t*r+i[e]*o)}}}function x(e){E(e,!1)}function E(e,t){if(t){const t=e.atoms.y;for(let e=0;e<t.length;e++)t[e]=-t[e]}else{const t=e.atoms.x;for(let e=0;e<t.length;e++)t[e]=-t[e]}const n=e.bonds.bondConfiguration;for(const[e,t]of n){const i=1===t?3:1;n.set(e,i)}}function M(e,t,n){const i=e.atoms.x,o=e.atoms.y;for(let e=0;e<i.length;++e)i[e]=(0,l.YN)(i[e]+t),void 0!==n&&(o[e]=(0,l.YN)(o[e]+n))}},6082:e=>{"use strict";e.exports=DG},6105:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(2128),o=n(7060),r=n(6378),s=n(5520),a=n(5413),l=n(3265),c=n(7532),h=n(9857),u=[s.default,i.default,o.default,(0,r.default)(!0),c.default,h.metadataVocabulary,h.contentVocabulary,a.default,l.default];t.default=u},6144:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(2128),o=n(7060),r=n(6378),s=n(7532),a=n(9857),l=[i.default,o.default,(0,r.default)(),s.default,a.metadataVocabulary,a.contentVocabulary];t.default=l},6163:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o=n(4227),r={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:{message:"must match exactly one schema in oneOf",params:({params:e})=>i._`{passingSchemas: ${e.passing}}`},code(e){const{gen:t,schema:n,parentSchema:r,it:s}=e;if(!Array.isArray(n))throw new Error("ajv implementation error");if(s.opts.discriminator&&r.discriminator)return;const a=n,l=t.let("valid",!1),c=t.let("passing",null),h=t.name("_valid");e.setParams({passing:c}),t.block(function(){a.forEach((n,r)=>{let a;(0,o.alwaysValidSchema)(s,n)?t.var(h,!0):a=e.subschema({keyword:"oneOf",schemaProp:r,compositeRule:!0},h),r>0&&t.if(i._`${h} && ${l}`).assign(l,!1).assign(c,i._`[${c}, ${r}]`).else(),t.if(h,()=>{t.assign(l,!0),t.assign(c,r),a&&e.mergeEvaluated(a,i.Name)})})}),e.result(l,()=>e.reset(),()=>e.error(!0))}};t.default=r},6197:(e,t,n)=>{"use strict";n.d(t,{Y:()=>o});var i=n(3599);function o(e){let t;switch(e){case i.o.BASE:case i.o.SUGAR:case i.o.LINKER:case i.o.NUCLEOTIDE:case"nucleotide":t="RNA";break;case i.o.AA:t="PEPTIDE";break;case i.o.CHEM:t="CHEM";break;case i.o.BLOB:t="BLOB";break;default:t="PEPTIDE",console.warn(`Unexpected HelmType '${e}'`)}return t}},6250:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(2017);i.code='require("ajv/dist/runtime/equal").default',t.default=i},6295:(e,t,n)=>{"use strict";n.d(t,{$1:()=>s,Hf:()=>h,Hr:()=>E,Ii:()=>f,Qj:()=>m,T6:()=>x,TK:()=>S,be:()=>g,gt:()=>v,ij:()=>w,jL:()=>c,lO:()=>p,lP:()=>b,rR:()=>y,tO:()=>a,v_:()=>l,w_:()=>u,yK:()=>C,zn:()=>d});var i=n(8774),o=n(8498),r=n(6863);function s(e,t){const n=e.trueCount()+t.trueCount();if(0==n)return 1;const i=e.andWithCountBits(t,!0);return i/(n-i)}function a(e,t){return 1-s(e,t)}function l(e,t){return A(s(new i.A(e,32*e.length),new i.A(t,32*t.length)))}function c(e,t){let n=0;for(let i=0;i<e.length;i++)n+=Math.pow(e[i]-t[i],2);return Math.sqrt(n)}function h(e,t){let n=0;for(let i=0;i<e.length;i++)n+=Math.abs(e[i]-t[i]);return n}function u(e,t){let n=0,i=0,o=0;for(let r=0;r<e.length;r++)n+=e[r]*t[r],i+=e[r]*e[r],o+=t[r]*t[r];return(1-n/(Math.sqrt(i)*Math.sqrt(o)))/2}function d(e,t){return 1-function(e,t){const n=e.trueCount()+t.trueCount();return 0==n?0:2*e.andWithCountBits(t,!0)/n}(e,t)}function p(e,t){return 1-function(e,t){const n=e.trueCount()*t.trueCount();return 0==n?0:e.andWithCountBits(t,!0)/Math.sqrt(n)}(e,t)}function m(e,t){return Math.sqrt(e.trueCount()+t.trueCount()-2*e.andWithCountBits(t,!0))}function g(e,t){return e.trueCount()+t.trueCount()-2*e.andWithCountBits(t,!0)}function f(e,t){return 1-function(e,t){const n=e.trueCount()+t.trueCount(),i=e.andWithCountBits(t,!0);return i/(2*n-3*i)}(e,t)}function y(e,t){return A(function(e,t){const n=e.trueCount()+t.trueCount(),i=e.trueCount()*t.trueCount();return 0==i?0:e.andWithCountBits(t,!0)*n/(2*i)}(e,t))}function b(e,t){return A(function(e,t){const n=e.trueCount()+t.trueCount(),i=e.trueCount()*t.trueCount();return 0==i?0:(e.andWithCountBits(t,!0)*n-i)/i}(e,t))}function v(e,t){return 1-function(e,t){const n=Math.min(e.trueCount(),t.trueCount());return 0==n?0:e.andWithCountBits(t,!0)/n}(e,t)}function w(e,t){return A(function(e,t){const n=Math.max(e.trueCount(),t.trueCount());return 0==n?0:e.andWithCountBits(t,!0)/n}(e,t))}function C(e,t){return A(function(e,t){return 0==e.length?0:e.andWithCountBits(t,!0)/e.length}(e,t))}function S(e,t){return A(function(e,t){const n=e.andWithCountBits(t,!0),i=e.countBits(!0)+t.countBits(!0),o=e.length,r=o-i+n;return n==o||r==o?1:n/i+r/(2*o-i)}(e,t))}function A(e){return e<=0?3402823e32:1/e-1}function x(e){if(e&&null!=e.range&&e.range>0){const t=e.range;return(e,n)=>Math.abs(e-n)/t}return(e,t)=>Math.abs(e-t)}function E(e){const t=function(e){const t=e?.mostCommon??new Set;return(e,n)=>{const i=e.length,o=n.length;let r=0,s=0,a=0;for(;s<i&&a<o;)e[s]===n[a]?(t?.has(e[s])||++r,++s,++a):e[s]<n[a]?++s:++a;return r}}(e);return(e,n)=>0===n.length||0===e.length?1e4:Math.min(e.length,n.length)/(t(e,n)+1e-4)}o.aT.Tanimoto,o.aT.Dice,o.aT.Asymmetric,o.aT.BraunBlanquet,o.aT.Cosine,o.aT.Kulczynski,o.aT.McConnaughey,o.aT.RogotGoldberg,o.aT.Russel,o.aT.Sokal,o.aT.Hamming,o.aT.Euclidean,o.aT.Tanimoto,o.aT.Dice,o.aT.Asymmetric,o.aT.BraunBlanquet,o.aT.Cosine,o.aT.Kulczynski,o.aT.McConnaughey,o.aT.RogotGoldberg,o.aT.Russel,o.aT.Sokal,o.aT.Hamming,o.aT.Euclidean,o.aT.Tanimoto,o.aT.Dice,o.aT.Cosine,o.aT.Tanimoto,o.aT.Asymmetric,o.aT.Cosine,o.aT.Sokal,r.Z.HAMMING,r.Z.LEVENSHTEIN,r.Z.MONOMER_CHEMICAL_DISTANCE,r.Z.NEEDLEMANN_WUNSCH},6307:(e,t,n)=>{"use strict";n.d(t,{F:()=>a});var i=n(7389),o=n(6082),r=n(439),s=n(6197);function a(e,t,n,a){let l=0,c=null;for(const t of Object.values(e))l+=t,c=null===c?t:Math.max(c,t);const h=c/l,u=Object.assign({},...Array.from(Object.entries(e)).sort((e,t)=>t[1]-e[1]).map(([e,c])=>{const u=c/l;let d;const p=a&&a[e]||t;try{const t=n.getMonomerColors(p,e);d=t?.backgroundcolor||"#CCCCCC"}catch(t){console.warn(`Failed to get colors for monomer ${e}:`,t),d="#CCCCCC"}const m=i.div("",{classes:"macromolecule-cell-comp-analysis-bar"});m.style.width=50*u/h+"px",m.style.backgroundColor=d,r._S===e&&(m.style.borderWidth="1px",m.style.borderStyle="solid",m.style.borderColor=o.Color.toHtml(o.Color.lightGray));let g=e;if(e!==r._S){const t=n.getMonomer((0,s.Y)(p),e);t&&t.symbol!==e&&(g=t.symbol)}else g="-";const f=i.div(`${(100*u).toFixed(2)}%`),y=i.div([m,f],{classes:"macromolecule-cell-comp-analysis-value"});return{[g]:y}})),d=i.tableFromMap(u);return Array.from(d.rows).forEach(e=>{const t=e.getElementsByClassName("macromolecule-cell-comp-analysis-bar")[0].style.backgroundColor;e.cells[0].style.color=t}),d}},6314:e=>{"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map(function(t){var n="",i=void 0!==t[5];return t[4]&&(n+="@supports (".concat(t[4],") {")),t[2]&&(n+="@media ".concat(t[2]," {")),i&&(n+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),n+=e(t),i&&(n+="}"),t[2]&&(n+="}"),t[4]&&(n+="}"),n}).join("")},t.i=function(e,n,i,o,r){"string"==typeof e&&(e=[[null,e,void 0]]);var s={};if(i)for(var a=0;a<this.length;a++){var l=this[a][0];null!=l&&(s[l]=!0)}for(var c=0;c<e.length;c++){var h=[].concat(e[c]);i&&s[h[0]]||(void 0!==r&&(void 0===h[5]||(h[1]="@layer".concat(h[5].length>0?" ".concat(h[5]):""," {").concat(h[1],"}")),h[5]=r),n&&(h[2]?(h[1]="@media ".concat(h[2]," {").concat(h[1],"}"),h[2]=n):h[2]=n),o&&(h[4]?(h[1]="@supports (".concat(h[4],") {").concat(h[1],"}"),h[4]=o):h[4]="".concat(o)),t.push(h))}},t}},6369:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var i=n(1354),o=n.n(i),r=n(6314),s=n.n(r)()(o());s.push([e.id,".kalign-version {\n margin-bottom: 0;\n text-align: end;\n font-size: 12px;\n opacity: 0.8;\n}\nbutton.msa-params-button.ui-btn {\n justify-content: end;\n}","",{version:3,sources:["webpack://./css/msa.css"],names:[],mappings:"AAAA;IACI,gBAAgB;IAChB,eAAe;IACf,eAAe;IACf,YAAY;AAChB;AACA;IACI,oBAAoB;AACxB",sourcesContent:[".kalign-version {\n margin-bottom: 0;\n text-align: end;\n font-size: 12px;\n opacity: 0.8;\n}\nbutton.msa-params-button.ui-btn {\n justify-content: end;\n}"],sourceRoot:""}]);const a=s},6378:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(5457),o=n(5354),r=n(494),s=n(3966),a=n(2661),l=n(3025),c=n(2094),h=n(8660),u=n(117),d=n(5333),p=n(7923),m=n(6505),g=n(6163),f=n(5844),y=n(1239),b=n(4426);t.default=function(e=!1){const t=[p.default,m.default,g.default,f.default,y.default,b.default,c.default,h.default,l.default,u.default,d.default];return e?t.push(o.default,s.default):t.push(i.default,r.default),t.push(a.default),t}},6505:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:n(5765).validateUnion,error:{message:"must match a schema in anyOf"}};t.default=i},6642:(e,t,n)=>{"use strict";n.d(t,{BG:()=>s,sD:()=>l});var i=n(4328),o=n(1858),r=n(8070);function s(e){let t=null,n=null;try{n=e.dart?e.gridColumn:null,t=n?n.temp:null}catch{[n,t]=[null,null]}const i=e.cell.column;if(t=t??(i?i.temp:null),!t)throw new Error("Grid cell renderer back store (GridColumn or Column) not found.");return[n,i,t]}class a{onKeyDown(e,t){}onKeyPress(e,t){}onMouseEnter(e,t){}onMouseLeave(e,t){}onMouseDown(e,t){}onMouseUp(e,t){}onMouseMove(e,t){}onClick(e,t){}onDoubleClick(e,t){}}class l extends a{constructor(e,t,n){super(),this.gridCol=e,this.tableCol=t,this.logger=n,this.subs=[],this.dirty=!0,this.destroyed=!1,this.viewerId=++l.viewerCounter,this.errors=[],this._onRendered=new o.Subject,this.tableCol&&this.tableCol.dataFrame&&(this.subs.push(this.tableCol.dataFrame.onDataChanged.subscribe(()=>{this.dirty=!0})),this.subs.push(this.tableCol.dataFrame.onColumnsRemoved.subscribe(e=>{try{this.destroyed||!this.tableCol||this.tableCol.dataFrame||this.destroy()}catch(e){this.logger.error(e)}}))),this.tableCol&&this.subs.push(i.events.onTableRemoved.subscribe(e=>{try{const t=e.args.dataFrame;this.tableCol?.dataFrame.id!==t.id||this.destroyed||this.destroy()}catch(e){this.logger.error(e)}})),this.gridCol&&this.subs.push(i.events.onViewRemoving.subscribe(e=>{try{const t=e.args.view;this.gridCol?.dart&&this.gridCol.grid&&this.gridCol?.grid?.dart&&this.gridCol?.grid?.view?.id===t.id&&!this.destroyed&&this.destroy()}catch(e){this.logger.error(e)}}))}toLog(){return`${this.constructor.name}<${this.viewerId}>`}destroy(){for(const e of this.subs)e.unsubscribe();this.destroyed=!0}invalidateGrid(){this.gridCol&&this.gridCol.dart&&this.gridCol.grid?.invalidate()}reset(){this.dirty=!1}get onRendered(){return this._onRendered}invalidate(e){this.invalidateGrid()}async awaitRendered(e=1e4,t=`${e} timeout`){const n=`${this.toLog()}.awaitRendered()`;if(this.logger.debug(`${n}, start, testEvent before`),await(0,r.PE)(this._onRendered,()=>{},()=>{this.invalidate()},e,`${n}, ${t}`),this.errors.length>0){const e=this.errors[0];throw this.errors=[],e}this.logger.debug(`${n}, end`)}}l.viewerCounter=-1},6653:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o=n(7652),r=n(3835),s=n(4551),a=n(4227),l={keyword:"discriminator",type:"object",schemaType:"object",error:{message:({params:{discrError:e,tagName:t}})=>e===o.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:n}})=>i._`{error: ${e}, tag: ${n}, tagValue: ${t}}`},code(e){const{gen:t,data:n,schema:l,parentSchema:c,it:h}=e,{oneOf:u}=c;if(!h.opts.discriminator)throw new Error("discriminator: requires discriminator option");const d=l.propertyName;if("string"!=typeof d)throw new Error("discriminator: requires propertyName");if(l.mapping)throw new Error("discriminator: mapping is not supported");if(!u)throw new Error("discriminator: requires oneOf keyword");const p=t.let("valid",!1),m=t.const("tag",i._`${n}${(0,i.getProperty)(d)}`);function g(n){const o=t.name("valid"),r=e.subschema({keyword:"oneOf",schemaProp:n},o);return e.mergeEvaluated(r,i.Name),o}t.if(i._`typeof ${m} == "string"`,()=>function(){const n=function(){var e;const t={},n=o(c);let i=!0;for(let t=0;t<u.length;t++){let c=u[t];if((null==c?void 0:c.$ref)&&!(0,a.schemaHasRulesButRef)(c,h.self.RULES)){const e=c.$ref;if(c=r.resolveRef.call(h.self,h.schemaEnv.root,h.baseId,e),c instanceof r.SchemaEnv&&(c=c.schema),void 0===c)throw new s.default(h.opts.uriResolver,h.baseId,e)}const p=null===(e=null==c?void 0:c.properties)||void 0===e?void 0:e[d];if("object"!=typeof p)throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${d}"`);i=i&&(n||o(c)),l(p,t)}if(!i)throw new Error(`discriminator: "${d}" must be required`);return t;function o({required:e}){return Array.isArray(e)&&e.includes(d)}function l(e,t){if(e.const)p(e.const,t);else{if(!e.enum)throw new Error(`discriminator: "properties/${d}" must have "const" or "enum"`);for(const n of e.enum)p(n,t)}}function p(e,n){if("string"!=typeof e||e in t)throw new Error(`discriminator: "${d}" values must be unique strings`);t[e]=n}}();t.if(!1);for(const e in n)t.elseIf(i._`${m} === ${e}`),t.assign(p,g(n[e]));t.else(),e.error(!1,{discrError:o.DiscrError.Mapping,tag:m,tagName:d}),t.endIf()}(),()=>e.error(!1,{discrError:o.DiscrError.Tag,tag:m,tagName:d})),e.ok(p)}};t.default=l},6717:(e,t,n)=>{"use strict";n.d(t,{j:()=>o});var i=n(6082);async function o(){const e=i.Func.find({package:"Chem",name:"getRdKitModule"});if(0===e.length)throw new Error('Package "Chem" must be installed for getRdKitModule.');return(await e[0].prepare().call()).getOutputParamValue()}},6863:(e,t,n)=>{"use strict";function i(e={}){const t=function(){if(!e||!e.scoringMatrix||!e.alphabetIndexes)return(e,t)=>e===t?0:1;if(e.scoringMatrix.length!==Object.keys(e.alphabetIndexes).length)throw new Error("Scoring matrix and alphabet indexes should have the same length");const t=e.alphabetIndexes,n=e.scoringMatrix,i=Math.min(...Object.keys(t).map(e=>e.charCodeAt(0)))+1,o=new Float32Array((n.length+i)*(n.length+i));return Object.entries(t).forEach(([e,i])=>{const r=n[i];Object.entries(t).forEach(([t,i])=>{o[e.charCodeAt(0)*n.length+t.charCodeAt(0)]=r[i]})}),(e,t)=>1-o[e.charCodeAt(0)*n.length+t.charCodeAt(0)]}(),n=e?.threshold??0;return(e,i)=>{let o=0;const r=e.length,s=i.length,a=Math.ceil(Math.max(r,s)*(1-n));r!==s&&(o=Math.abs(r-s));let l=0;for(let n=0;n<Math.min(r,s);n++)if(e[n]!==i[n]&&(l+=t(e[n],i[n]),l>a))return 1;return l+=o,l/=Math.max(r,s),l}}n.d(t,{Z:()=>s,V:()=>a});var o=n(2787);const r={gapOpen:1,gapExtend:.6,scoringMatrix:[[4,-1,-2,-2,0,-1,-1,0,-2,-1,-1,-1,-1,-2,-1,1,0,-3,-2,0,-2,-1,0,-4],[-1,5,0,-2,-3,1,0,-2,0,-3,-2,2,-1,-3,-2,-1,-1,-3,-2,-3,-1,0,-1,-4],[-2,0,6,1,-3,0,0,0,1,-3,-3,0,-2,-3,-2,1,0,-4,-2,-3,3,0,-1,-4],[-2,-2,1,6,-3,0,2,-1,-1,-3,-4,-1,-3,-3,-1,0,-1,-4,-3,-3,4,1,-1,-4],[0,-3,-3,-3,9,-3,-4,-3,-3,-1,-1,-3,-1,-2,-3,-1,-1,-2,-2,-1,-3,-3,-2,-4],[-1,1,0,0,-3,5,2,-2,0,-3,-2,1,0,-3,-1,0,-1,-2,-1,-2,0,3,-1,-4],[-1,0,0,2,-4,2,5,-2,0,-3,-3,1,-2,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-2,0,-1,-3,-2,-2,6,-2,-4,-4,-2,-3,-3,-2,0,-2,-2,-3,-3,-1,-2,-1,-4],[-2,0,1,-1,-3,0,0,-2,8,-3,-3,-1,-2,-1,-2,-1,-2,-2,2,-3,0,0,-1,-4],[-1,-3,-3,-3,-1,-3,-3,-4,-3,4,2,-3,1,0,-3,-2,-1,-3,-1,3,-3,-3,-1,-4],[-1,-2,-3,-4,-1,-2,-3,-4,-3,2,4,-2,2,0,-3,-2,-1,-2,-1,1,-4,-3,-1,-4],[-1,2,0,-1,-3,1,1,-2,-1,-3,-2,5,-1,-3,-1,0,-1,-3,-2,-2,0,1,-1,-4],[-1,-1,-2,-3,-1,0,-2,-3,-2,1,2,-1,5,0,-2,-1,-1,-1,-1,1,-3,-1,-1,-4],[-2,-3,-3,-3,-2,-3,-3,-3,-1,0,0,-3,0,6,-4,-2,-2,1,3,-1,-3,-3,-1,-4],[-1,-2,-2,-1,-3,-1,-1,-2,-2,-3,-3,-1,-2,-4,7,-1,-1,-4,-3,-2,-2,-1,-2,-4],[1,-1,1,0,-1,0,0,0,-1,-2,-2,0,-1,-2,-1,4,1,-3,-2,-2,0,0,0,-4],[0,-1,0,-1,-1,-1,-1,-2,-2,-1,-1,-1,-1,-2,-1,1,5,-2,-2,0,-1,-1,0,-4],[-3,-3,-4,-4,-2,-2,-3,-2,-2,-3,-2,-3,-1,1,-4,-3,-2,11,2,-3,-4,-3,-2,-4],[-2,-2,-2,-3,-2,-1,-2,-3,2,-1,-1,-2,-1,3,-3,-2,-2,2,7,-1,-3,-2,-1,-4],[0,-3,-3,-3,-1,-2,-2,-3,-3,3,1,-2,1,-1,-2,-2,0,-3,-1,4,-3,-2,-1,-4],[-2,-1,3,4,-3,0,1,-1,0,-3,-4,0,-3,-3,-2,0,-1,-4,-3,-3,4,1,-1,-4],[-1,0,0,1,-3,3,4,-2,0,-3,-3,1,-1,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-1,-1,-1,-2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-2,0,0,-2,-1,-1,-1,-1,-1,-4],[-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,1]],alphabetIndexes:{A:0,R:1,N:2,D:3,C:4,Q:5,E:6,G:7,H:8,I:9,L:10,K:11,M:12,F:13,P:14,S:15,T:16,W:17,Y:18,V:19,B:20,Z:21,X:22,"*":23}};var s;!function(e){e.HAMMING="Hamming",e.LEVENSHTEIN="Levenshtein",e.NEEDLEMANN_WUNSCH="Needlemann-Wunsch",e.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance"}(s||(s={}));const a={[s.HAMMING]:i,[s.LEVENSHTEIN]:function(){return(e,t)=>(0,o.I)(e,t)/Math.max(e.length,t.length)},[s.NEEDLEMANN_WUNSCH]:function(e){const t=new Uint16Array(65536),{gapOpen:n,gapExtend:i,scoringMatrix:o,alphabetIndexes:s}={...r,...e};Object.entries(s).forEach(([e,n])=>t[e.charCodeAt(0)]=n);const a=[new Float32Array(1e4),new Float32Array(1e4)];return(e,r)=>{const s=new Array(e.length+1).fill(!1),l=new Array(e.length+1).fill(!1);let c=0,h=1;for(let t=1;t<e.length+1;t++)a[0][t]=-i-(t-1)*i,a[1][t]=0;a[0][0]=0;for(let u=1;u<r.length+1;u++){a[h][0]=-i-(u-1)*i;for(let d=1;d<e.length+1;d++){const p=a[c][d-1]+o[t[e.charCodeAt(d-1)]][t[r.charCodeAt(u-1)]],m=a[c][d]-(s[d]||1===u||u===r.length?i:n),g=a[h][d-1]-(l[d-1]||1===d||d===e.length?i:n);a[h][d]=Math.max(p,g,m),a[h][d]===p?(s[d]=!1,l[d]=!1):a[h][d]===g?(s[d]=!1,l[d]=!0):(s[d]=!0,l[d]=!1)}c=h,h=(h+1)%2}const u=Math.min(e.length,r.length);return(u-a[c][e.length])/u}},[s.MONOMER_CHEMICAL_DISTANCE]:i}},6869:(e,t,n)=>{"use strict";var i;n.d(t,{o:()=>i}),function(e){e.BASE="HELM_BASE",e.SUGAR="HELM_SUGAR",e.LINKER="HELM_LINKER",e.AA="HELM_AA",e.CHEM="HELM_CHEM",e.BLOB="HELM_BLOB",e.NUCLEOTIDE="HELM_NUCLETIDE"}(i||(i={}))},6873:(e,t,n)=>{"use strict";n.d(t,{Hx:()=>h,dW:()=>c});var i=n(6082),o=n(1991),r=n.n(o),s=n(2003),a=n(7278),l=n(439);function c(e=1e4){const t="meI/hHis/Aca/N//dE/Thr_PO3H2/Aca/D-Tyr_Et/Tyr_ab-dehydroMe".repeat(Math.ceil(e/10)).slice(0,-1),n=i.Column.fromList(i.COLUMN_TYPE.STRING,"MSA",new Array(100).fill(t));n.semType=i.SEMTYPE.MACROMOLECULE,n.meta.units=s.Hi.SEPARATOR,n.setTag(s.gp.separator,"/"),n.setTag(s.gp.alphabet,s.YI.UN),n.setTag(s.gp.alphabetIsMultichar,"true");const o=[];return o.push(n),o.push(i.Column.fromList(i.COLUMN_TYPE.FLOAT,"Activity",new Array(100).fill(7.30751))),o}function h(e,t=s.Hi.SEPARATOR,n=s.YI.PT,o=(t===s.Hi.SEPARATOR?"-":void 0),c=void 0,h="seq",u=100,d=10**6){const p=n===s.YI.UN?c?.getMonomerSymbolsByType("PEPTIDE")??[]:Array.from((0,s.Qf)(n)),m=p.length,g=i.Column.fromType(i.COLUMN_TYPE.STRING,h,u);g.semType=i.SEMTYPE.MACROMOLECULE,g.meta.units=t,g.setTag(s.gp.alphabet,n),t==s.Hi.SEPARATOR&&g.setTag(s.gp.separator,o);const f=e.getSeqHandler(g);for(let e=0;e<u;e++){const n=r().count(0).take(d).map(e=>p[Math.floor(Math.random()*m)]).toArray(),i=f.joiner(new a.Mu(n,l.b9[t]));g.set(e,i)}return g}},6882:(e,t,n)=>{"use strict";n.d(t,{Jy:()=>b,S$:()=>y,U0:()=>v});var i=n(7389),o=n(6082),r=n(1991),s=n.n(r),a=n(8312),l=n(2003),c=n(6642),h=n(4971),u=n(9192),d=n(3856),p=n(673),m=n(3599),g=n(5553),f=n(9713);const y="rgb(100,100,100)";class b extends c.sD{get separatorWidth(){return this.props?.fontCharWidth?this.props?.fontCharWidth:5}constructor(e,t,n,i,r){if(super(e,t,n),this.monomerLengthLimit=i,this.propsProvider=r,this.colWidth=0,this._monomerLengthList=null,this._processedMaxVisibleSeqLength=0,this._monomerLengthMap={},this._monomerStructureMap={},this._ellipsisBounds=void 0,this._totalLinesNeeded=0,this._lineHeight=20,this._cellBounds=new Map,this.sysMonomerLib=null,this.padding=5,this._leftThreeDotsPadding=0,this.props=this.propsProvider(),this._processedRows=o.BitSet.create(this.tableCol.length),this.gridCol&&this.subs.push(this.gridCol.grid.onAfterDrawContent.subscribe(()=>{this._onRendered.next()})),this.tableCol&&this.gridCol){this.subs.push(this.tableCol.dataFrame.onCurrentRowChanged.subscribe(()=>{-1===this.tableCol.dataFrame.currentRowIdx&&(this.tableCol.temp["reference-sequence"]=null,this.tableCol.temp["current-word"]=null,this.invalidateGrid())}));const e=[l.gp.positionShift,"renderMultiline"];this.subs.push(o.debounce(this.tableCol.dataFrame.onMetadataChanged.pipe(f.filter(t=>t.args.source===this.tableCol&&e.includes(t.args.key))),200).subscribe(e=>{this.reset()})),this.subs.push(o.debounce(this.tableCol.dataFrame.onMetadataChanged.pipe(f.filter(e=>e.args.source===this.tableCol&&e.args.key===l.gp.positionShift)),200).subscribe(e=>{this.reset()}))}}calculateFontBasedSpacing(e){const t=e.measureText("M");let n=12;if(this.tableCol?.temp[".mm.cellRenderer.fontSize"]){const e=this.tableCol.temp[".mm.cellRenderer.fontSize"];"number"!=typeof e||isNaN(e)||(n=Math.max(e,1))}return{lineHeight:Math.max(1.4*n,t.fontBoundingBoxAscent+t.fontBoundingBoxDescent+4),monomerSpacing:Math.max(2,.2*this.props.fontCharWidth)}}shouldUseMultilineRendering(e){return"true"===e.getTag("renderMultiline")}calculateMultiLineLayoutDynamic(e,t,n,i,o,r){if(this.dirty)try{this.reset()}catch(e){const[t,n]=(0,u.AP)(e);this.logger.error(t,void 0,n)}const{lineHeight:s,monomerSpacing:a}=this.calculateFontBasedSpacing(e),l=t-2*this.padding;let c=0;const h=[];if(i.length>0)for(let t=o;t<i.length;t++){const n=i.getOriginal(t),o=this.props.monomerToShort(n,r);h.push({text:o,posIdx:t}),c=Math.max(c,e.measureText(o).width)}if(0===h.length)return{lineLayouts:[],lineHeight:s};const d=c;let p=Math.floor((l+a)/(d+a));p=Math.max(1,p);const m=n-2*this.padding,g=Math.max(0,Math.floor(m/s)),f=[];let y=0;for(let e=0;e<g&&y<h.length;e++){const t=[];for(let e=0;e<p&&y<h.length;e++){const n=h[y],i=this.padding+e*(d+a);t.push({posIdx:n.posIdx,x:i,width:d,om:n.text,isSeparator:!1}),y++}f.push({lineIdx:e,elements:t})}return{lineLayouts:f,lineHeight:s}}async init(){await Promise.all([(async()=>{this.seqHelper=await(0,a.Q)(),this.invalidateGrid()})(),(async()=>{const e=await(0,h.pj)();this.sysMonomerLib=e.getMonomerLib()})()]),this.subs.push(this.sysMonomerLib.onChanged.subscribe(()=>{this.reset()})),this.reset()}static getFontSettings(e){let t=12;return e&&e.temp[".mm.cellRenderer.fontSize"]&&"number"==typeof e.temp[".mm.cellRenderer.fontSize"]&&!isNaN(e.temp[".mm.cellRenderer.fontSize"])&&(t=Math.max(e.temp[".mm.cellRenderer.fontSize"],1)),{font:`${t}px monospace`,fontWidth:.6*t}}toLog(){return`MonomerPlacer<${this.viewerId}>`}getMonomerLib(){return this.tableCol.temp[".mm.cellRenderer.overriddenLibrary"]??this.sysMonomerLib}reset(){this.propsProvider&&(this.props=this.propsProvider()),this._processedRows=o.BitSet.create(this.tableCol.length),this._monomerLengthList=null,this._monomerLengthMap={},this._monomerStructureMap={},this._cellBounds.clear(),super.reset(),this.invalidateGrid()}invalidateGrid(){this.gridCol&&this.gridCol.dart&&this.gridCol.grid?.invalidate()}getCellMonomerLengths(e,t){const n=this.seqHelper.getSeqHandler(this.tableCol);if(this.colWidth<t&&(this.colWidth=t,this.dirty=!0),this.dirty)try{this.reset()}catch(e){const[t,n]=(0,u.AP)(e);this.logger.error(t,void 0,n)}const i=n.isMsa()?this.getCellMonomerLengthsForSeqMsa():this.getCellMonomerLengthsForSeq(e);return[i,this.getSummedMonomerLengths(i)]}getSummedMonomerLengths(e){const t=new Array(e.length+1);t[0]=this.padding;for(let n=1;n<t.length;n++)t[n]=t[n-1]+e[n-1];let n=t[0];for(let e=1;e<t.length;e++)t[e]?n=t[e]:t[e]=n;return t}getCellMonomerLengthsForSeqValue(e,t){const n=this.seqHelper.getSeqHandler(this.tableCol),i=this.props.separatorWidth+1*this.props.fontCharWidth,o=this.positionShift,r=Math.ceil(t/i)+o,s=n.splitter(e),a=Math.min(r,s.length),l=new Array(a-o);let c=0;for(let e=o;e<a;++e){const i=s.getOriginal(e),r=this.props.monomerToShort(i,this.monomerLengthLimit),a=(n.isSeparator()?this.separatorWidth:this.props.separatorWidth)+r.length*this.props.fontCharWidth;if(l[e-o]=a,c+=a,c>t)break}return l}getCellMonomerLengthsForSeq(e){this.toLog(),null===this._monomerLengthList&&(this._monomerLengthList=new Array(this.tableCol.length).fill(null));const t=this.positionShift,n=this.seqHelper.getSeqHandler(this.tableCol),i=this.props.separatorWidth+1*this.props.fontCharWidth,o=Math.ceil(this.colWidth/i)+t,r=n.getSplitted(e),s=Math.min(o,r.length);let a=this._monomerLengthList[e];if(null===a||a.length!=s-t){a=this._monomerLengthList[e]=new Array(r.length);let i=0;for(let e=t;e<s;++e){const o=r.getOriginal(e),s=this.props.monomerToShort(o,this.monomerLengthLimit),l=(n.isSeparator()?this.separatorWidth:this.props.separatorWidth)+s.length*this.props.fontCharWidth;if(a[e-t]=l,i+=l,i>this.colWidth)break}}return a}getCellMonomerLengthsForSeqMsa(){var e;this.toLog(),null===this._monomerLengthList&&(this._monomerLengthList=new Array(1).fill(null)),(e=this._monomerLengthList)[0]??(e[0]=new Array(0));const t=this._monomerLengthList[0],{startIdx:n,endIdx:i}=(()=>{try{const e=this.gridCol&&this.gridCol.dart?this.gridCol.grid:null;return e&&e.dart?{startIdx:Math.max(Math.floor((e?.vertScroll.min??0)-10),0),endIdx:Math.min(Math.ceil((e?.vertScroll.max??0)+10),this.tableCol.length)}:{startIdx:0,endIdx:Math.min(this.tableCol.length,10)}}catch(e){return{startIdx:0,endIdx:Math.min(this.tableCol.length,10)}}})(),o=this.props.separatorWidth+1*this.props.fontCharWidth,r=this.positionShift,s=Math.ceil(this.colWidth/o)+r;for(let e=n;e<i;e++){if(this._processedRows.get(e)&&s<=this._processedMaxVisibleSeqLength)continue;const n=this.seqHelper.getSeqHandler(this.tableCol).getSplitted(e,s),i=Math.min(s,n.length);i-r>t.length&&t.push(...new Array(i-r-t.length).fill(o));let a=0;for(let e=r;e<i;++e){const i=n.getOriginal(e),o=this.props.monomerToShort(i,this.monomerLengthLimit),s=this.props.separatorWidth+o.length*this.props.fontCharWidth;if(t[e-r]=Math.max(t[e-r]??0,s),a+=s,a>=this.colWidth)break}this._processedMaxVisibleSeqLength=Math.max(this._processedMaxVisibleSeqLength,s),this._processedRows.set(e,!0)}return t}getPosition(e,t,n,i){const[o,r]=this.getCellMonomerLengths(e,n);return 0===this.seqHelper.getSeqHandler(this.tableCol).getSplitted(e).length?null:function(e,t,n){if((n??0)>0&&t<(e[0]??0)+n)return-1;t-=n??0;let i,o=100,r=0,s=e.length-1;for(;r<=s;){if(i=Math.floor((s+r)/2),e[i]<=t&&t<e[i+1])return i;if(t<e[i]?s=i-1:r=i+1,--o<=0)throw new Error(`Get position for pointer x = ${t} searching has not converged on ${JSON.stringify(e)}. `)}return null}(r,t,i)}setMonomerLengthLimit(e){this.monomerLengthLimit!=e&&(this.monomerLengthLimit=e,this.dirty=!0)}setSeparatorWidth(e){this.separatorWidth!=e&&(this.props.separatorWidth=e,this.dirty=!0)}get positionShift(){const e=Number.parseInt(this.tableCol?.tags[l.gp.positionShift]??"0")??0;return isNaN(e)?0:Math.max(e,0)}render(e,t,n,i,r,a,c){const h=a.grid?.dart&&a.grid?.canvas===e.canvas;if(!this.seqHelper)return;const m=this.tableCol,g=this.positionShift;e.save();try{const c=this.seqHelper.getSeqHandler(m);let u=this.monomerLengthLimit;if(d.gp.maxMonomerLength in m.tags){const e=parseInt(m.getTag(d.gp.maxMonomerLength));u=!isNaN(e)&&e?e:50}if(".mm.cellRenderer.maxMonomerLength"in m.temp){const e=m.temp[".mm.cellRenderer.maxMonomerLength"],t="number"==typeof e?e:parseInt(e);u=!isNaN(t)&&t?t:50}if(m.temp[".mm.cellRenderer.settingsChanged"]===p.s.true||this.monomerLengthLimit!=u){let e=0;const t=8;e=m.temp[".mm.cellRenderer.gapLength"]??e,this.setMonomerLengthLimit(u),this.setSeparatorWidth(c.isMsa()?t:e),m.temp[".mm.cellRenderer.settingsChanged"]=p.s.false,this.dirty=!0}const f=a.cell.rowIndex,b=a.cell.value;h&&(i=v(a.grid,e,t,i,window.devicePixelRatio)),e.beginPath(),e.rect(t,n,i,r),e.clip(),e.font=this.props?.font??"12px monospace",e.textBaseline="top";const w=m.meta.units,C=m.getTag(l.gp.aligned),S=m.getTag(l.gp.separator)??"",A=h?c.getSplitted(f):c.splitter(b);let x=d.yg.classic;C?.includes("MSA")&&w===l.Hi.SEPARATOR&&(x=d.yg.MSA);const E=m.temp["reference-sequence"],M=this.tableCol.temp["current-word"],T=(()=>{const e=(0,c.splitter)(null!=E&&""!==E?E:M??"");return s().count(0).take(e.length).slice(g).map(t=>e.getCanonical(t)).toArray()})(),_=Number.parseInt(m.getTag(l.gp.selectedPosition)??"-200");if(this.shouldUseMultilineRendering(m)){const s=[],l=this.calculateMultiLineLayoutDynamic(e,i,r,A,g,u);let h=n+this.padding;1===l.lineLayouts.length&&(h=n+(r-l.lineHeight)/2);for(const i of l.lineLayouts){const r=h+i.lineIdx*l.lineHeight;for(const h of i.elements){const u=t+h.x,p=h,f=p.posIdx,b=A.getCanonical(f);let v=y;const w=this.getMonomerLib();w&&(v=w.getMonomerTextColor(c.defaultBiotype,b));let C=0;if(a.tableRowIndex!==m.dataFrame.currentRowIdx&&T.length>0){const e=f-g;e>=0&&e<T.length&&b===T[e]&&(C=.7)}s.push({lineIdx:i.lineIdx,monomerIdx:f-g,bounds:new o.Rect(h.x,r-n,h.width,l.lineHeight),sequencePosition:f}),(0,d.oZ)(e,p.om,u,r,h.width,l.lineHeight,{color:v,isMultiLineContext:!0,transparencyRate:C,selectedPosition:isNaN(_)||_<1?void 0:_,wordIdx:f})}}null!==a.tableRowIndex&&this._cellBounds.set(a.tableRowIndex,s)}else{this._leftThreeDotsPadding=this.shouldRenderShiftedThreeDots(g)?e.measureText("...").width:0;let[,o]=this.getCellMonomerLengths(a.tableRowIndex,i);h||(o=this.getSummedMonomerLengths(this.getCellMonomerLengthsForSeqValue(b,i)));const s=this.props.separatorWidth+1*this.props.fontCharWidth,l=Math.min(A.length,Math.ceil(i/s)+g);for(let s=g;s<l;++s){const l=s<A.length?A.getOriginal(s):c.defaultGapOriginal,h=s<A.length?A.getCanonical(s):c.defaultGapOriginal;let p=y;this.getMonomerLib()&&(p=this.getMonomerLib().getMonomerTextColor(c.defaultBiotype,h));const m=s===A.length-1,f={color:p,pivot:0,left:!0,transparencyRate:0,separator:(A?.graphInfo?.disjointSeqStarts?.indexOf(s+1)??0)>0?"|":S,last:m,drawStyle:x,maxWord:o,wordIdx:s-g,gridCell:a,referenceSequence:T,maxLengthOfMonomer:u,monomerTextSizeMap:this._monomerLengthMap,logger:this.logger,selectedPosition:isNaN(_)||_<1?void 0:_-g};(0,d.oZ)(e,l,t+this.padding+this._leftThreeDotsPadding,n,i,r,f)}if(this.shouldRenderShiftedThreeDots(g)){const s={color:y,pivot:0,left:!0,transparencyRate:0,separator:S,last:!1,drawStyle:x,maxWord:o,wordIdx:0,gridCell:a,maxLengthOfMonomer:u,monomerTextSizeMap:this._monomerLengthMap,logger:this.logger};(0,d.oZ)(e,"...",t+this.padding,n,i,r,s)}}}catch(e){const[t,n]=(0,u.AP)(e);this.logger.error(t,void 0,n),this.errors.push(e)}finally{e.restore()}}shouldRenderShiftedThreeDots(e){return e>0&&(!this.gridCol||!this.gridCol.dart||!this.gridCol.grid||!this.gridCol.grid.dart||(this.gridCol.grid.props.colHeaderHeight??0)<=50)}onMouseMove(e,t){const n=`${this.toLog()}.onMouseMove()`;if(!this.seqHelper||null==e.tableRowIndex)return;const o=this.positionShift,r=e.bounds,s=t.offsetX-e.gridColumn.left+(e.gridColumn.left-r.x),a=t.offsetY-r.y;this.gridCol?.grid?.canvas&&(this.gridCol.grid.canvas.style.cursor="default");let c=null;const h=this._cellBounds.get(e.tableRowIndex);if(h){for(const e of h)if(e.bounds.contains(s,a)){c=e.monomerIdx;break}}else{const t=this.shouldRenderShiftedThreeDots(o)&&(this._leftThreeDotsPadding??0)>0?this._leftThreeDotsPadding:0;c=this.getPosition(e.tableRowIndex,s,r.width,t)}this.logger.debug(`${n}, argsX: ${s}, argsY: ${a}, left: ${c}`);const u=this.seqHelper.getSeqHandler(this.tableCol),d=u.getSplitted(e.tableRowIndex);if(null!==c&&c>=0&&c+o<d.length){const n=u.alphabet??l.YI.UN,r={position:c,biotype:n===l.YI.RNA||n===l.YI.DNA?m.o.NUCLEOTIDE:m.o.AA,symbol:d.getCanonical(c+o)},s=[];let a=this._monomerStructureMap[r.symbol];if(!a){const e=this.getMonomerLib();a=this._monomerStructureMap[r.symbol]=e?e.getTooltip(r.biotype,r.symbol):i.divText("Monomer library is not available")}s.push(a),i.tooltip.show(i.divV(s),t.x+16,t.y+16),(0,g.WN)(e,r)}else-1===c?i.tooltip.show(i.divText(`${Math.min(o,d.length)} hidden monomers`),t.x+16,t.y+16):i.tooltip.hide(),(0,g.WN)(e,null)}}function v(e,t,n,i,o){return e?Math.max(Math.min(e.canvas.width/o-n,i)):Math.max(t.canvas.width/o-n,0)}},6939:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getSchemaRefs=t.resolveUrl=t.normalizeId=t._getFullPath=t.getFullPath=t.inlineRef=void 0;const i=n(4227),o=n(2017),r=n(7106),s=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);t.inlineRef=function(e,t=!0){return"boolean"==typeof e||(!0===t?!l(e):!!t&&c(e)<=t)};const a=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function l(e){for(const t in e){if(a.has(t))return!0;const n=e[t];if(Array.isArray(n)&&n.some(l))return!0;if("object"==typeof n&&l(n))return!0}return!1}function c(e){let t=0;for(const n in e){if("$ref"===n)return 1/0;if(t++,!s.has(n)&&("object"==typeof e[n]&&(0,i.eachItem)(e[n],e=>t+=c(e)),t===1/0))return 1/0}return t}function h(e,t="",n){!1!==n&&(t=p(t));const i=e.parse(t);return u(e,i)}function u(e,t){return e.serialize(t).split("#")[0]+"#"}t.getFullPath=h,t._getFullPath=u;const d=/#\/?$/;function p(e){return e?e.replace(d,""):""}t.normalizeId=p,t.resolveUrl=function(e,t,n){return n=p(n),e.resolve(t,n)};const m=/^[a-z_][-a-z0-9._]*$/i;t.getSchemaRefs=function(e,t){if("boolean"==typeof e)return{};const{schemaId:n,uriResolver:i}=this.opts,s=p(e[n]||t),a={"":s},l=h(i,s,!1),c={},u=new Set;return r(e,{allKeys:!0},(e,t,i,o)=>{if(void 0===o)return;const r=l+t;let s=a[o];function h(t){const n=this.opts.uriResolver.resolve;if(t=p(s?n(s,t):t),u.has(t))throw g(t);u.add(t);let i=this.refs[t];return"string"==typeof i&&(i=this.refs[i]),"object"==typeof i?d(e,i.schema,t):t!==p(r)&&("#"===t[0]?(d(e,c[t],t),c[t]=e):this.refs[t]=r),t}function f(e){if("string"==typeof e){if(!m.test(e))throw new Error(`invalid anchor "${e}"`);h.call(this,`#${e}`)}}"string"==typeof e[n]&&(s=h.call(this,e[n])),f.call(this,e.$anchor),f.call(this,e.$dynamicAnchor),a[t]=s}),c;function d(e,t,n){if(void 0!==t&&!o(e,t))throw g(n)}function g(e){return new Error(`reference "${e}" resolves to more than one schema`)}}},6956:(e,t,n)=>{"use strict";n.d(t,{m:()=>o,x:()=>i});const i="|",o="H"},7060:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(5882),o=n(3439),r=n(7307),s=n(422),a=n(4486),l=n(4003),c=n(1163),h=n(617),u=n(7935),d=n(8643),p=[i.default,o.default,r.default,s.default,a.default,l.default,c.default,h.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},u.default,d.default];t.default=p},7082:e=>{"use strict";e.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/meta/validation","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/validation":true},"$dynamicAnchor":"meta","title":"Validation vocabulary meta-schema","type":["object","boolean"],"properties":{"type":{"anyOf":[{"$ref":"#/$defs/simpleTypes"},{"type":"array","items":{"$ref":"#/$defs/simpleTypes"},"minItems":1,"uniqueItems":true}]},"const":true,"enum":{"type":"array","items":true},"multipleOf":{"type":"number","exclusiveMinimum":0},"maximum":{"type":"number"},"exclusiveMaximum":{"type":"number"},"minimum":{"type":"number"},"exclusiveMinimum":{"type":"number"},"maxLength":{"$ref":"#/$defs/nonNegativeInteger"},"minLength":{"$ref":"#/$defs/nonNegativeIntegerDefault0"},"pattern":{"type":"string","format":"regex"},"maxItems":{"$ref":"#/$defs/nonNegativeInteger"},"minItems":{"$ref":"#/$defs/nonNegativeIntegerDefault0"},"uniqueItems":{"type":"boolean","default":false},"maxContains":{"$ref":"#/$defs/nonNegativeInteger"},"minContains":{"$ref":"#/$defs/nonNegativeInteger","default":1},"maxProperties":{"$ref":"#/$defs/nonNegativeInteger"},"minProperties":{"$ref":"#/$defs/nonNegativeIntegerDefault0"},"required":{"$ref":"#/$defs/stringArray"},"dependentRequired":{"type":"object","additionalProperties":{"$ref":"#/$defs/stringArray"}}},"$defs":{"nonNegativeInteger":{"type":"integer","minimum":0},"nonNegativeIntegerDefault0":{"$ref":"#/$defs/nonNegativeInteger","default":0},"simpleTypes":{"enum":["array","boolean","integer","null","number","object","string"]},"stringArray":{"type":"array","items":{"type":"string"},"uniqueItems":true,"default":[]}}}')},7106:e=>{"use strict";var t=e.exports=function(e,t,i){"function"==typeof t&&(i=t,t={}),n(t,"function"==typeof(i=t.cb||i)?i:i.pre||function(){},i.post||function(){},e,"",e)};function n(e,o,r,s,a,l,c,h,u,d){if(s&&"object"==typeof s&&!Array.isArray(s)){for(var p in o(s,a,l,c,h,u,d),s){var m=s[p];if(Array.isArray(m)){if(p in t.arrayKeywords)for(var g=0;g<m.length;g++)n(e,o,r,m[g],a+"/"+p+"/"+g,l,a,p,s,g)}else if(p in t.propsKeywords){if(m&&"object"==typeof m)for(var f in m)n(e,o,r,m[f],a+"/"+p+"/"+i(f),l,a,p,s,f)}else(p in t.keywords||e.allKeys&&!(p in t.skipKeywords))&&n(e,o,r,m,a+"/"+p,l,a,p,s)}r(s,a,l,c,h,u,d)}}function i(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}t.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0},t.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},t.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},t.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0}},7216:e=>{"use strict";e.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/meta/applicator","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/applicator":true},"$dynamicAnchor":"meta","title":"Applicator vocabulary meta-schema","type":["object","boolean"],"properties":{"prefixItems":{"$ref":"#/$defs/schemaArray"},"items":{"$dynamicRef":"#meta"},"contains":{"$dynamicRef":"#meta"},"additionalProperties":{"$dynamicRef":"#meta"},"properties":{"type":"object","additionalProperties":{"$dynamicRef":"#meta"},"default":{}},"patternProperties":{"type":"object","additionalProperties":{"$dynamicRef":"#meta"},"propertyNames":{"format":"regex"},"default":{}},"dependentSchemas":{"type":"object","additionalProperties":{"$dynamicRef":"#meta"},"default":{}},"propertyNames":{"$dynamicRef":"#meta"},"if":{"$dynamicRef":"#meta"},"then":{"$dynamicRef":"#meta"},"else":{"$dynamicRef":"#meta"},"allOf":{"$ref":"#/$defs/schemaArray"},"anyOf":{"$ref":"#/$defs/schemaArray"},"oneOf":{"$ref":"#/$defs/schemaArray"},"not":{"$dynamicRef":"#meta"}},"$defs":{"schemaArray":{"type":"array","minItems":1,"items":{"$dynamicRef":"#meta"}}}}')},7278:(e,t,n)=>{"use strict";n.d(t,{Iv:()=>C,J9:()=>f,MD:()=>_,Mu:()=>d,Qf:()=>x,bR:()=>w,dh:()=>b,mn:()=>T,p0:()=>M,pc:()=>E,qp:()=>v,tm:()=>y,zS:()=>A});var i=n(6082),o=n(1991),r=n.n(o),s=n(3527),a=n(3629),l=n(2738),c=n(439),h=(n(8924),n(1093),n(4152),n(8438)),u=n(3599);class d{get length(){return this.mList.length}get graphInfo(){}isGap(e){return this.getOriginal(e)===this.gapOriginalMonomer}getCanonical(e){if(this.length<=e)throw new Error("Index out of bounds");const t=this.mList[e];return t!==this.gapOriginalMonomer?t:c._S}getOriginal(e){if(this.length<=e)throw new Error("Index out of bounds");return this.mList[e]}getCanonicalRegion(e,t){const n=Math.min(Math.max(0,e),this.length),i=Math.max(Math.min(this.length,t),0)-n,o=this.gapOriginalMonomer;return new Array(i).fill(null).map((e,t)=>{const i=this.mList[t+n];return i===o?c._S:i})}getOriginalRegion(e,t){const n=Math.min(Math.max(0,e),this.length),i=Math.max(Math.min(this.length,t),0);return new Array(i-n).fill(null).map((e,t)=>this.mList[t+n])}get gapOriginal(){return this.gapOriginalMonomer}constructor(e,t){this.mList=e,this.gapOriginalMonomer=t}}class p extends d{constructor(e,t,n,i){super(e.flat(),i),this.mListSeparated=e,this.connections=t,this._graphInfo=void 0,this.polymerTypes=e.map((e,t)=>new Array(e.length).fill(n[t])).flat()}get graphInfo(){return this._graphInfo??(this._graphInfo=this.parseConnections()),this._graphInfo}parseConnections(){const e={connections:[],disjointSeqStarts:[],polymerTypes:this.polymerTypes};if((this.connections?.length??0)>0){let t=0;for(let n=0;n<this.mListSeparated.length;++n)e.disjointSeqStarts.push(t),t+=this.mListSeparated[n].length;const n=(this.connections??"").split("|").filter(e=>(e?.length??0)>0),i=/^(PEPTIDE|RNA|BLOB|CHEM)\d{1,2}$/,o=/^\d{1,2}:R\d{1}-\d{1,2}:R\d{1}$/;for(const t of n){const n=t.split(",");if(3!==n.length||!o.test(n[2])||!i.test(n[0])||!i.test(n[1]))continue;const r=parseInt(n[0].replace(/^(PEPTIDE|RNA|BLOB|CHEM)/,""))-1,s=parseInt(n[1].replace(/^(PEPTIDE|RNA|BLOB|CHEM)/,""))-1,a=n[0].replace(/\d{1,2}$/,""),l=n[1].replace(/\d{1,2}$/,"");if(r<0||r>=this.mListSeparated.length||s<0||s>=this.mListSeparated.length)continue;const c=n[2].split("-");if(2!==c.length)continue;const h=c[0].split(":"),u=c[1].split(":");if(2!==h.length||2!==u.length)continue;const d=parseInt(h[0])-1,p=parseInt(u[0])-1;d<0||d>=this.mListSeparated[r].length||p<0||p>=this.mListSeparated[s].length||e.connections.push({seq1Type:a,seq2Type:l,seqIndex1:r,seqIndex2:s,monomerIndex1:d,monomerIndex2:p,rGroup1:parseInt(h[1].substring(1)),rGroup2:parseInt(u[1].substring(1))})}}return e}}class m extends p{getCanonical(e){if(this.isGap(e))return c._S;let t=this.getOriginal(e);const n=/\(\d{1,2},\d{1,2}\)$/;for(;n.test(t);)t=t.replace(n,"");return t}getOriginal(e){return super.getOriginal(e).replace(/^\[(.*)\]/,"$1")}constructor(e,t){super(e,"",e.map(()=>"PEPTIDE"),t)}parseConnections(){const e={connections:[],disjointSeqStarts:[]},t={};let n=0;for(let i=0;i<this.mListSeparated.length;i++){const o=this.mListSeparated[i];e.disjointSeqStarts.push(n),n+=o.length;for(let n=0;n<o.length;n++){const r=/\(\d{1,2},\d{1,2}\)$/;let s=o[n];for(;r.test(s);){const o=/\(\d{1,2},\d{1,2}\)$/.exec(s)?.[0];if(s=s.replace(r,""),null!=o){const r=o.substring(1,o.length-1).split(",").map(e=>parseInt(e,10));if(2!==r.length||r.some(e=>null==e||Number.isNaN(e)))continue;const s=r[0].toString(),a=r[1];if(s in t){const o=t[s];e.connections.push({seq1Type:"PEPTIDE",seq2Type:"PEPTIDE",seqIndex1:o.seqIndex,seqIndex2:i,monomerIndex1:o.monomerIndex,monomerIndex2:n,rGroup1:o.rGroup,rGroup2:a}),delete t[s]}else t[s]={seqIndex:i,monomerIndex:n,rGroup:a}}}}}return e}}class g{get length(){return this.seqS.length}isGap(e){return this.getOriginal(e)===c.b9[c.Hi.FASTA]}getCanonical(e){if(this.length<=e)throw new Error("Index out of bounds");return this.isGap(e)?c._S:this.seqS[e]}getOriginal(e){if(this.length<=e)throw new Error("Index out of bounds");return this.seqS[e]}getCanonicalRegion(e,t){const n=Math.max(0,e),i=Math.min(this.length,t)-n,o=c.b9[c.Hi.FASTA];return new Array(i).fill(null).map((e,t)=>{const i=this.seqS[t+n];return i===o?c._S:i})}getOriginalRegion(e,t){const n=Math.max(0,e),i=Math.min(this.length,t);return this.seqS.slice(n,i)}get gapOriginal(){return c.b9[c.Hi.FASTA]}constructor(e){this.seqS=e}}const f=e=>{const t=r()(e.toString().matchAll(c.B5)).map(e=>e[2]??e[1]).toArray();return new d(t,c.b9[c.Hi.FASTA])},y=e=>e?new g(e):new d([],c.b9[c.Hi.FASTA]);function b(e,t=void 0){return n=>{if(n){let i;const o=new RegExp(`(?<=^|\\${e})("-"|'-'|[^\\${e}]*)(?=\\${e}|$)`,"g");return null!=t?(o.lastIndex=0,i=r()(n.matchAll(o)).take(t).map(e=>e[0]).toArray()):i=n.replaceAll('"-"',"").replaceAll("'-'","").split(e,t),new d(i,c.b9[c.Hi.SEPARATOR])}return new d([],c.b9[c.Hi.SEPARATOR])}}const v=e=>{const t=e.indexOf("}$"),n=e.substring(0,t+1),i=e.indexOf("$",t+2),o=e.substring(t+2,i),r=n.split("}|");for(let e=0;e<r.length-1;e++)r[e]=r[e]+"}";const s=r.map(e=>(e.match(/(?<=\{).+(?=})/)?.[0]?.split(".")??[]).map(e=>(0,h.D)(e))),a=r.map(e=>e.replace(/\d{1,2}\{.+\}/,""));return new p(s,o??"",a,c.b9[c.Hi.HELM])};function w(e){const t=e.split(".").map(e=>e.replaceAll('"-"',"").replaceAll("'-'","")),n="___TEMP___";for(let e=0;e<t.length;e++){const i=/\[([^\]]+)\]/g;let o,r=t[e];for(;null!==(o=i.exec(t[e]));){const e=o[1],t=e.replaceAll("-",n);r=r.replace(e,t)}t[e]=r}const i=t.map(e=>e.split("-").map(e=>e.replaceAll(n,"-")));return new m(i,c.b9[c.Hi.SEPARATOR])}function C(e,t,n=void 0){if(e.toLowerCase().startsWith(c.Hi.FASTA))return f;if(e.toLowerCase().startsWith(c.Hi.SEPARATOR))return b(t,n);if(e.toLowerCase().startsWith(c.Hi.HELM))return v;if(e.toLowerCase().startsWith(c.Hi.BILN))return w;throw new Error(`Unexpected units ${e} .`)}const S=/([^\W_]+)/g;function A(e,t){if(e.length<=t)return e;const n=e.match(S),i=e.length>t||(n?.length??0)>1,o=n?.[0]??" ";return i?o.substring(0,t-1)+"…":o}function x(e){switch(e){case c.YI.DNA:return c.Vl.fasta.dna;case c.YI.RNA:return c.Vl.fasta.rna;case c.YI.PT:return c.Vl.fasta.peptide;default:throw new Error(`Unsupported alphabet '${e}'.`)}}function E(e,t,n="-"){const i=t.map(t=>{const i=function(e,t,n="-"){const i=new Set([...new Set(Object.keys(e)),...t]);i.delete(n);const o=[],r=[];for(const n of i)o.push(n in e?e[n]:0),r.push(t.has(n)?1:0);const l=new s.Mi(o),c=new s.Mi(r);return(0,a.KE)(l,c)/((0,a.wQ)(l)*(0,a.wQ)(c))}(e,t.alphabet,n);return new l.X(t,e,i)});let o;const r=Math.max(...i.map(e=>e.similarity>e.cutoff?e.similarity:-1));return o=r>0?i.find(e=>e.similarity===r).name:c.YI.UN,o}function M(e,t,n="-"){const i=Object.keys(e),o=/\(|\)/;return E(i.filter(e=>3===e.split(o).filter(e=>!!e).length).length>.8*i.length?Object.entries(e).reduce((e,[t,n])=>{const i=t.split(o)[1];return i&&(e[i]=n),e},{}):e,t,n)}function T(e){const t=e.columns.bySemTypeAll(i.SEMTYPE.MACROMOLECULE);let n=t.find(e=>{const t=e.meta.units;return!!t&&-1!==t.indexOf("MSA")})??null;return!n&&t.length>0&&(n=t[0]),n}function _(e){switch(e){case"PEPTIDE":default:return u.o.AA;case"RNA":return u.o.NUCLEOTIDE;case"CHEM":return u.o.CHEM;case"BLOB":return u.o.BLOB}}},7307:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o=n(4227),r=n(3853),s={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:{message({keyword:e,schemaCode:t}){const n="maxLength"===e?"more":"fewer";return i.str`must NOT have ${n} than ${t} characters`},params:({schemaCode:e})=>i._`{limit: ${e}}`},code(e){const{keyword:t,data:n,schemaCode:s,it:a}=e,l="maxLength"===t?i.operators.GT:i.operators.LT,c=!1===a.opts.unicode?i._`${n}.length`:i._`${(0,o.useFunc)(e.gen,r.default)}(${n})`;e.fail$data(i._`${c} ${l} ${s}`)}};t.default=s},7362:(e,t,n)=>{"use strict";n.d(t,{e:()=>i});class i{static makePalette(e,t=!1,n=i){const o={};return e.forEach(e=>{const n=e[0],i=e[1];n.forEach((e,n)=>{o[e]=this.colourPalette[i][t?0:n]})}),new n(o)}constructor(e){this._palette=e}get(e,t){return this._palette[e]}}i.undefinedColor="rgb(100,100,100)",i.colourPalette={orange:["rgb(255,187,120)","rgb(245,167,100)","rgb(235,137,70)","rgb(205, 111, 71)"],all_green:["rgb(44,160,44)","rgb(74,160,74)","rgb(23,103,57)","rgb(30,110,96)","rgb(60,131,95)","rgb(24,110,79)","rgb(152,223,138)","rgb(182, 223, 138)","rgb(152, 193, 138)"],all_blue:["rgb(31,119,180)","rgb(23,190,207)","rgb(122, 102, 189)","rgb(158,218,229)","rgb(141, 124, 217)","rgb(31, 120, 150)"],magenta:["rgb(162,106,192)","rgb(197,165,224)","rgb(208,113,218)"],red:["rgb(214,39,40)","rgb(255,152,150)"],st_blue:["rgb(23,190,207)","rgb(158,218,229)","rgb(31,119,180)"],dark_blue:["rgb(31,119,180)","rgb(31, 120, 150)"],light_blue:["rgb(23,190,207)","rgb(158,218,229)","rgb(108, 218, 229)","rgb(23,190,227)"],lilac_blue:["rgb(124,102,211)","rgb(149,134,217)","rgb(97, 81, 150)"],dark_green:["rgb(23,103,57)","rgb(30,110,96)","rgb(60,131,95)","rgb(24,110,79)"],green:["rgb(44,160,44)","rgb(74,160,74)"],light_green:["rgb(152,223,138)","rgb(182, 223, 138)","rgb(152, 193, 138)"],st_green:["rgb(44,160,44)","rgb(152,223,138)","rgb(39, 174, 96)","rgb(74,160,74)"],pink:["rgb(247,182,210)"],brown:["rgb(140,86,75)","rgb(102, 62, 54)"],gray:["rgb(127,127,127)","rgb(199,199,199)","rgb(196,156,148)","rgb(222, 222, 180)"],yellow:["rgb(188,189,34)"],white:["rgb(230,230,230)"]}},7389:e=>{"use strict";e.exports=ui},7433:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MissingRefError=t.ValidationError=t.CodeGen=t.Name=t.nil=t.stringify=t.str=t._=t.KeywordCxt=t.Ajv2020=void 0;const i=n(4042),o=n(6105),r=n(6653),s=n(9572),a="https://json-schema.org/draft/2020-12/schema";class l extends i.default{constructor(e={}){super({...e,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){super._addVocabularies(),o.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(r.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();const{$data:e,meta:t}=this.opts;t&&(s.default.call(this,e),this.refs["http://json-schema.org/schema"]=a)}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(a)?a:void 0)}}t.Ajv2020=l,e.exports=t=l,e.exports.Ajv2020=l,Object.defineProperty(t,"__esModule",{value:!0}),t.default=l;var c=n(2586);Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return c.KeywordCxt}});var h=n(9029);Object.defineProperty(t,"_",{enumerable:!0,get:function(){return h._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return h.str}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return h.stringify}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return h.nil}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return h.Name}}),Object.defineProperty(t,"CodeGen",{enumerable:!0,get:function(){return h.CodeGen}});var u=n(3558);Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return u.default}});var d=n(4551);Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return d.default}})},7532:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=[n(4737).default];t.default=i},7602:(e,t,n)=>{"use strict";n.d(t,{g:()=>r});var i,o=n(9192);!function(e){e[e.error=0]="error",e[e.warning=1]="warning",e[e.info=2]="info",e[e.debug=3]="debug"}(i||(i={}));class r{constructor(e){this.logger=e,this.promise=Promise.resolve(),this.errors=[],this.syncCounter=0}sync(e,t){const n=++this.syncCounter;this.logger.debug(`${e}, SYNC syncId = ${n}, IN `),this.promise=this.promise.then(async()=>{this.logger.debug(`${e}, SYNC syncId = ${n}, START `),await t(),this.logger.debug(`${e}, SYNC syncId = ${n}, END `)}).catch(t=>{const[i,r]=(0,o.AP)(t);this.logger.error(`${e}, SYNC syncId = ${n}, ERROR:\n${i}`,void 0,r),this.errors.push(t)})}resetErrors(){const e=this.errors;return this.errors=[],e}}},7652:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.DiscrError=void 0,function(e){e.Tag="tag",e.Mapping="mapping"}(n||(t.DiscrError=n={}))},7659:e=>{"use strict";var t={};e.exports=function(e,n){var i=function(e){if(void 0===t[e]){var n=document.querySelector(e);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(e){n=null}t[e]=n}return t[e]}(e);if(!i)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");i.appendChild(n)}},7825:e=>{"use strict";e.exports=function(e){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var t=e.insertStyleElement(e);return{update:function(n){!function(e,t,n){var i="";n.supports&&(i+="@supports (".concat(n.supports,") {")),n.media&&(i+="@media ".concat(n.media," {"));var o=void 0!==n.layer;o&&(i+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),i+=n.css,o&&(i+="}"),n.media&&(i+="}"),n.supports&&(i+="}");var r=n.sourceMap;r&&"undefined"!=typeof btoa&&(i+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(r))))," */")),t.styleTagTransform(i,e,t.options)}(t,e,n)},remove:function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(t)}}}},7845:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ValueScope=t.ValueScopeName=t.Scope=t.varKinds=t.UsedValueState=void 0;const i=n(1520);class o extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}}var r;!function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"}(r||(t.UsedValueState=r={})),t.varKinds={const:new i.Name("const"),let:new i.Name("let"),var:new i.Name("var")};class s{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof i.Name?e:this.name(e)}name(e){return new i.Name(this._newName(e))}_newName(e){return`${e}${(this._names[e]||this._nameGroup(e)).index++}`}_nameGroup(e){var t,n;if((null===(n=null===(t=this._parent)||void 0===t?void 0:t._prefixes)||void 0===n?void 0:n.has(e))||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}}t.Scope=s;class a extends i.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:t,itemIndex:n}){this.value=e,this.scopePath=i._`.${new i.Name(t)}[${n}]`}}t.ValueScopeName=a;const l=i._`\n`;t.ValueScope=class extends s{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?l:i.nil}}get(){return this._scope}name(e){return new a(e,this._newName(e))}value(e,t){var n;if(void 0===t.ref)throw new Error("CodeGen: ref must be passed in value");const i=this.toName(e),{prefix:o}=i,r=null!==(n=t.key)&&void 0!==n?n:t.ref;let s=this._values[o];if(s){const e=s.get(r);if(e)return e}else s=this._values[o]=new Map;s.set(r,i);const a=this._scope[o]||(this._scope[o]=[]),l=a.length;return a[l]=t.ref,i.setValue(t,{property:o,itemIndex:l}),i}getValue(e,t){const n=this._values[e];if(n)return n.get(t)}scopeRefs(e,t=this._values){return this._reduceValues(t,t=>{if(void 0===t.scopePath)throw new Error(`CodeGen: name "${t}" has no value`);return i._`${e}${t.scopePath}`})}scopeCode(e=this._values,t,n){return this._reduceValues(e,e=>{if(void 0===e.value)throw new Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,n)}_reduceValues(e,n,s={},a){let l=i.nil;for(const c in e){const h=e[c];if(!h)continue;const u=s[c]=s[c]||new Map;h.forEach(e=>{if(u.has(e))return;u.set(e,r.Started);let s=n(e);if(s){const n=this.opts.es5?t.varKinds.var:t.varKinds.const;l=i._`${l}${n} ${e} = ${s};${this.opts._n}`}else{if(!(s=null==a?void 0:a(e)))throw new o(e);l=i._`${l}${s}${this.opts._n}`}u.set(e,r.Completed)})}return l}}},7870:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.assignDefaults=void 0;const i=n(9029),o=n(4227);function r(e,t,n){const{gen:r,compositeRule:s,data:a,opts:l}=e;if(void 0===n)return;const c=i._`${a}${(0,i.getProperty)(t)}`;if(s)return void(0,o.checkStrictMode)(e,`default is ignored for: ${c}`);let h=i._`${c} === undefined`;"empty"===l.useDefaults&&(h=i._`${h} || ${c} === null || ${c} === ""`),r.if(h,i._`${c} = ${(0,i.stringify)(n)}`)}t.assignDefaults=function(e,t){const{properties:n,items:i}=e.schema;if("object"===t&&n)for(const t in n)r(e,t,n[t].default);else"array"===t&&Array.isArray(i)&&i.forEach((t,n)=>r(e,n,t.default))}},7887:(e,t)=>{"use strict";function n(e,t){return t.rules.some(t=>i(e,t))}function i(e,t){var n;return void 0!==e[t.keyword]||(null===(n=t.definition.implements)||void 0===n?void 0:n.some(t=>void 0!==e[t]))}Object.defineProperty(t,"__esModule",{value:!0}),t.shouldUseRule=t.shouldUseGroup=t.schemaHasRulesForType=void 0,t.schemaHasRulesForType=function({schema:e,self:t},i){const o=t.RULES.types[i];return o&&!0!==o&&n(e,o)},t.shouldUseGroup=n,t.shouldUseRule=i},7923:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(4227),o={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){const{gen:t,schema:n,it:o}=e;if((0,i.alwaysValidSchema)(o,n))return void e.fail();const r=t.name("valid");e.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},r),e.failResult(r,()=>e.reset(),()=>e.error())},error:{message:"must NOT be valid"}};t.default=o},7935:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o=n(4227),r=n(6250),s={keyword:"const",$data:!0,error:{message:"must be equal to constant",params:({schemaCode:e})=>i._`{allowedValue: ${e}}`},code(e){const{gen:t,data:n,$data:s,schemaCode:a,schema:l}=e;s||l&&"object"==typeof l?e.fail$data(i._`!${(0,o.useFunc)(t,r.default)}(${n}, ${a})`):e.fail(i._`${l} !== ${n}`)}};t.default=s},7939:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var i=n(1354),o=n.n(i),r=n(6314),s=n.n(r)()(o());s.push([e.id,".scatter_plot_link {\n right: 10px;\n}\n\n.cliffs_div {\n flex-grow: initial!important;\n justify-content: flex-end;\n flex-wrap: wrap;\n}\n\n.cliffs_grid {\n margin: 0!important;\n}\n\n.ml-dim-reduction-settings-input i.grok-icon.grok-font-icon-settings {\n font-size: 18px;\n position: absolute;\n height: 28px;\n}\n\n.ml-dim-reduction-settings-input i.grok-icon.grok-font-icon-settings:not(.ml-dim-reduction-column-editor-input-root i) {\n left: -20px;\n}\n.dlg-dimensionality-reduction.ui-form, .dlg-markov-clustering.ui-form, .dlg-markov-clustering.ui-form .ui-form, .dlg-dimensionality-reduction.ui-form .ui-form {\n max-width: unset;\n}\n\n.ml-dim-reduction-column-editor-input-root label {\n display: none !important;\n}\n\n.dim-reduction-dialog-form > .ui-input-root, .dim-reduction-dialog-form > div > .ui-input-root {\n margin-left: 10px;\n}\n\n.ml-dim-reduction-column-editor-input-root input, .ml-dim-reduction-column-editor-input-root select {\n margin-left: 20px !important;\n}\n\nh3.ml-dim-reduction-column-editor-input-root {\n margin: 0 !important;\n}\n\n.ml-dim-reduction-column-editor-root, .ml-dim-reduction-column-editor-header-root {\n display: flex;\n flex-direction: row;\n align-items: center;\n margin-bottom: 10px !important;\n width: 700px !important;\n}\n\n.ml-dim-reduction-column-editor-column-title {\n text-overflow: ellipsis;\n overflow: hidden;\n}\n\n.ml-dim-reduction-column-editor-header-root > h1:not(:first-child) {\n margin-left: 20px !important;\n}\n\n.ml-dim-reduction-column-editor-table-root .header > td:not(:first-child) {\n padding-left: 32px;\n}","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/ml/css/styles.css"],names:[],mappings:"AAAA;IACI,WAAW;AACf;;AAEA;IACI,4BAA4B;IAC5B,yBAAyB;IACzB,eAAe;AACnB;;AAEA;GACG,mBAAmB;AACtB;;AAEA;IACI,eAAe;IACf,kBAAkB;IAClB,YAAY;AAChB;;AAEA;IACI,WAAW;AACf;AACA;IACI,gBAAgB;AACpB;;AAEA;IACI,wBAAwB;AAC5B;;AAEA;IACI,iBAAiB;AACrB;;AAEA;IACI,4BAA4B;AAChC;;AAEA;IACI,oBAAoB;AACxB;;AAEA;IACI,aAAa;IACb,mBAAmB;IACnB,mBAAmB;IACnB,8BAA8B;IAC9B,uBAAuB;AAC3B;;AAEA;IACI,uBAAuB;IACvB,gBAAgB;AACpB;;AAEA;IACI,4BAA4B;AAChC;;AAEA;IACI,kBAAkB;AACtB",sourcesContent:[".scatter_plot_link {\n right: 10px;\n}\n\n.cliffs_div {\n flex-grow: initial!important;\n justify-content: flex-end;\n flex-wrap: wrap;\n}\n\n.cliffs_grid {\n margin: 0!important;\n}\n\n.ml-dim-reduction-settings-input i.grok-icon.grok-font-icon-settings {\n font-size: 18px;\n position: absolute;\n height: 28px;\n}\n\n.ml-dim-reduction-settings-input i.grok-icon.grok-font-icon-settings:not(.ml-dim-reduction-column-editor-input-root i) {\n left: -20px;\n}\n.dlg-dimensionality-reduction.ui-form, .dlg-markov-clustering.ui-form, .dlg-markov-clustering.ui-form .ui-form, .dlg-dimensionality-reduction.ui-form .ui-form {\n max-width: unset;\n}\n\n.ml-dim-reduction-column-editor-input-root label {\n display: none !important;\n}\n\n.dim-reduction-dialog-form > .ui-input-root, .dim-reduction-dialog-form > div > .ui-input-root {\n margin-left: 10px;\n}\n\n.ml-dim-reduction-column-editor-input-root input, .ml-dim-reduction-column-editor-input-root select {\n margin-left: 20px !important;\n}\n\nh3.ml-dim-reduction-column-editor-input-root {\n margin: 0 !important;\n}\n\n.ml-dim-reduction-column-editor-root, .ml-dim-reduction-column-editor-header-root {\n display: flex;\n flex-direction: row;\n align-items: center;\n margin-bottom: 10px !important;\n width: 700px !important;\n}\n\n.ml-dim-reduction-column-editor-column-title {\n text-overflow: ellipsis;\n overflow: hidden;\n}\n\n.ml-dim-reduction-column-editor-header-root > h1:not(:first-child) {\n margin-left: 20px !important;\n}\n\n.ml-dim-reduction-column-editor-table-root .header > td:not(:first-child) {\n padding-left: 32px;\n}"],sourceRoot:""}]);const a=s},8070:(e,t,n)=>{"use strict";n.d(t,{cb:()=>a,PE:()=>s}),n(4328);var i=n(6082);n(9982),i.DataFrame.fromCsv('countries,fasta,smiles,molregno,LON,Zip Code,Street Address Line 1,ImageUrl,user_id,error_message,xray,flag,magnitude,CS-id,pdb_id,accel_a,time_offset,chart,fit,Questions,empty_number,empty_string\nBelgium,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C(=O)OCCCc1cccnc1)c2cccc(c2)C(=O)c3ccccc3,1480014,36.276729583740234,995042300,14016 ROUTE 31W,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,1,1,1QBS,1,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.497360340644872, 1.7058694986686864, 5.278052678195135, 0.16000320889028383],""points"":[{""x"":0.10000000149011612,""y"":2.374499797821045},{""x"":0.6000000238418579,""y"":2.6242473125457764},{""x"":1.100000023841858,""y"":2.367267608642578},{""x"":1.600000023841858,""y"":2.6723148822784424},{""x"":2.0999999046325684,""y"":2.6537344455718994},{""x"":2.5999999046325684,""y"":2.3651671409606934},{""x"":3.0999999046325684,""y"":2.5654284954071045},{""x"":3.5999999046325684,""y"":2.4160959720611572},{""x"":4.099999904632568,""y"":2.286726713180542},{""x"":4.599999904632568,""y"":2.5100042819976807},{""x"":5.099999904632568,""y"":1.6676985025405884},{""x"":5.599999904632568,""y"":0.680136501789093},{""x"":6.099999904632568,""y"":0.3391543924808502},{""x"":6.599999904632568,""y"":0.09038983285427094},{""x"":7.099999904632568,""y"":0.19802775979042053}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[7.525235855508179, 1.3186911876809984, 5.335672608564294, 0.7860743343958098],""points"":[{""x"":0.10000000149011612,""y"":7.988070487976074},{""x"":0.6000000238418579,""y"":7.018453121185303},{""x"":1.100000023841858,""y"":8.115279197692871},{""x"":1.600000023841858,""y"":7.486658096313477},{""x"":2.0999999046325684,""y"":7.396438121795654},{""x"":2.5999999046325684,""y"":7.477052211761475},{""x"":3.0999999046325684,""y"":6.913095474243164},{""x"":3.5999999046325684,""y"":8.01385498046875},{""x"":4.099999904632568,""y"":6.985900402069092},{""x"":4.599999904632568,""y"":6.970335960388184},{""x"":5.099999904632568,""y"":5.448817253112793},{""x"":5.599999904632568,""y"":2.5534818172454834},{""x"":6.099999904632568,""y"":1.893947958946228},{""x"":6.599999904632568,""y"":0.6340042352676392},{""x"":7.099999904632568,""y"":0.8403874039649963}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,100,abc\nBurundi,MDYKETLLMPKTDFPMRGGLPNKEPQIQEKW,COc1ccc2cc(ccc2c1)C(C)C(=O)Oc3ccc(C)cc3OC,1480015,36.276729583740234,995073444,80 STATE HIGHWAY 310,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,2,2,1ZP8,2,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.431460753103398, 2.1691498799246745, 5.266445597102774, 0.7825762827017926],""points"":[{""x"":0.10000000149011612,""y"":4.751083850860596},{""x"":0.6000000238418579,""y"":4.203000068664551},{""x"":1.100000023841858,""y"":4.415858745574951},{""x"":1.600000023841858,""y"":4.68414306640625},{""x"":2.0999999046325684,""y"":4.198400974273682},{""x"":2.5999999046325684,""y"":4.179222106933594},{""x"":3.0999999046325684,""y"":4.638473987579346},{""x"":3.5999999046325684,""y"":4.708553314208984},{""x"":4.099999904632568,""y"":4.291589260101318},{""x"":4.599999904632568,""y"":4.038082599639893},{""x"":5.099999904632568,""y"":3.4349939823150635},{""x"":5.599999904632568,""y"":1.2194708585739136},{""x"":6.099999904632568,""y"":1.1920831203460693},{""x"":6.599999904632568,""y"":0.5352635979652405},{""x"":7.099999904632568,""y"":0.3346920311450958}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.339458017970126, -1.0734184310171178, 4.746332950550934, 0.2482416857595658],""points"":[{""x"":0.10000000149011612,""y"":0.2139337658882141},{""x"":0.6000000238418579,""y"":0.4269562065601349},{""x"":1.100000023841858,""y"":0.2441573292016983},{""x"":1.600000023841858,""y"":0.146635964512825},{""x"":2.0999999046325684,""y"":0.08818462491035461},{""x"":2.5999999046325684,""y"":0.2560656666755676},{""x"":3.0999999046325684,""y"":0.42434045672416687},{""x"":3.5999999046325684,""y"":0.37111231684684753},{""x"":4.099999904632568,""y"":0.5581737160682678},{""x"":4.599999904632568,""y"":1.183590054512024},{""x"":5.099999904632568,""y"":1.5629843473434448},{""x"":5.599999904632568,""y"":2.3211288452148438},{""x"":6.099999904632568,""y"":2.229961633682251},{""x"":6.599999904632568,""y"":2.2560226917266846},{""x"":7.099999904632568,""y"":2.2142398357391357}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCameroon,MIEVFLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL,COc1ccc2cc(ccc2c1)C(C)C(=O)OCCCc3cccnc3,1480016,36.26095962524414,995153596,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,3,3,2BDJ,3,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.6760652578642325, 0.9046956320756703, 5.651408971856738, 0.07738846012184185],""points"":[{""x"":0.10000000149011612,""y"":4.32425594329834},{""x"":0.6000000238418579,""y"":4.668442249298096},{""x"":1.100000023841858,""y"":4.379785060882568},{""x"":1.600000023841858,""y"":5.0345139503479},{""x"":2.0999999046325684,""y"":4.878653526306152},{""x"":2.5999999046325684,""y"":4.3451313972473145},{""x"":3.0999999046325684,""y"":4.336992263793945},{""x"":3.5999999046325684,""y"":5.037430286407471},{""x"":4.099999904632568,""y"":5.0092692375183105},{""x"":4.599999904632568,""y"":4.151902675628662},{""x"":5.099999904632568,""y"":3.4066951274871826},{""x"":5.599999904632568,""y"":2.3732759952545166},{""x"":6.099999904632568,""y"":1.673728108406067},{""x"":6.599999904632568,""y"":0.48574790358543396},{""x"":7.099999904632568,""y"":0.2783052325248718}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.938395863010111, -1.4658480661392117, 5.462702751996584, 0.3473139023615039],""points"":[{""x"":0.10000000149011612,""y"":0.4941710829734802},{""x"":0.6000000238418579,""y"":0.15323974192142487},{""x"":1.100000023841858,""y"":0.46373432874679565},{""x"":1.600000023841858,""y"":0.3370431363582611},{""x"":2.0999999046325684,""y"":0.5179030299186707},{""x"":2.5999999046325684,""y"":0.27899765968322754},{""x"":3.0999999046325684,""y"":0.22075064480304718},{""x"":3.5999999046325684,""y"":0.5789918899536133},{""x"":4.099999904632568,""y"":0.21169911324977875},{""x"":4.599999904632568,""y"":0.27857646346092224},{""x"":5.099999904632568,""y"":1.0906332731246948},{""x"":5.599999904632568,""y"":1.8520300388336182},{""x"":6.099999904632568,""y"":2.7177059650421143},{""x"":6.599999904632568,""y"":2.8680918216705322},{""x"":7.099999904632568,""y"":3.2413077354431152}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCanada,MMELVLKTIIGPIVVGVVLRIVDKWLNKDK,CC(C(=O)NCCS)c1cccc(c1)C(=O)c2ccccc2,1480017,36.26095962524414,99515,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,4,4,1IAN,4,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[0.8597390975430008, 1.0957625732481946, 5.260537067987958, 0.07974187998177736],""points"":[{""x"":0.10000000149011612,""y"":0.8190152645111084},{""x"":0.6000000238418579,""y"":0.8421689867973328},{""x"":1.100000023841858,""y"":0.8740922212600708},{""x"":1.600000023841858,""y"":0.8924275040626526},{""x"":2.0999999046325684,""y"":0.8249067664146423},{""x"":2.5999999046325684,""y"":0.9327669143676758},{""x"":3.0999999046325684,""y"":0.8522974252700806},{""x"":3.5999999046325684,""y"":0.8174492716789246},{""x"":4.099999904632568,""y"":0.8394647240638733},{""x"":4.599999904632568,""y"":0.7139387726783752},{""x"":5.099999904632568,""y"":0.5561167597770691},{""x"":5.599999904632568,""y"":0.3276226818561554},{""x"":6.099999904632568,""y"":0.12479474395513535},{""x"":6.599999904632568,""y"":0.13006797432899475},{""x"":7.099999904632568,""y"":0.059702079743146896}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.760930219582546, 1.6591793293833013, 4.667155929720851, 0.7858109544121652],""points"":[{""x"":0.10000000149011612,""y"":6.156993389129639},{""x"":0.6000000238418579,""y"":5.236701965332031},{""x"":1.100000023841858,""y"":6.010560512542725},{""x"":1.600000023841858,""y"":5.495512962341309},{""x"":2.0999999046325684,""y"":6.087770462036133},{""x"":2.5999999046325684,""y"":5.79986572265625},{""x"":3.0999999046325684,""y"":5.597546577453613},{""x"":3.5999999046325684,""y"":5.520902156829834},{""x"":4.099999904632568,""y"":5.360654354095459},{""x"":4.599999904632568,""y"":3.5539746284484863},{""x"":5.099999904632568,""y"":1.577236294746399},{""x"":5.599999904632568,""y"":1.0001264810562134},{""x"":6.099999904632568,""y"":0.9305797815322876},{""x"":6.599999904632568,""y"":0.6033638715744019},{""x"":7.099999904632568,""y"":0.4203685522079468}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nColombia,MDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN,FC(F)(F)c1ccc(OC2CCNCC2)cc1,1480029,36.3309440612793,995152050,1 COURT HOUSE SQUARE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,5,5,4UJ1,5,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[6.4995088314153655, 2.4270351004539914, 5.178659535348579, 0.625653346241577],""points"":[{""x"":0.10000000149011612,""y"":6.496231555938721},{""x"":0.6000000238418579,""y"":6.42543363571167},{""x"":1.100000023841858,""y"":7.040063858032227},{""x"":1.600000023841858,""y"":6.1115403175354},{""x"":2.0999999046325684,""y"":6.680728435516357},{""x"":2.5999999046325684,""y"":6.406774520874023},{""x"":3.0999999046325684,""y"":6.611269474029541},{""x"":3.5999999046325684,""y"":5.889094352722168},{""x"":4.099999904632568,""y"":6.75344705581665},{""x"":4.599999904632568,""y"":6.361435890197754},{""x"":5.099999904632568,""y"":4.1666975021362305},{""x"":5.599999904632568,""y"":1.172118902206421},{""x"":6.099999904632568,""y"":0.801048994064331},{""x"":6.599999904632568,""y"":0.4640021026134491},{""x"":7.099999904632568,""y"":0.0010357667924836278}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[1.4734381347446401, 1.1649805188074196, 4.82958608866421, 0.09500545496710007],""points"":[{""x"":0.10000000149011612,""y"":1.5279096364974976},{""x"":0.6000000238418579,""y"":1.3559974431991577},{""x"":1.100000023841858,""y"":1.5246378183364868},{""x"":1.600000023841858,""y"":1.5567657947540283},{""x"":2.0999999046325684,""y"":1.4114240407943726},{""x"":2.5999999046325684,""y"":1.4045010805130005},{""x"":3.0999999046325684,""y"":1.4769829511642456},{""x"":3.5999999046325684,""y"":1.4875500202178955},{""x"":4.099999904632568,""y"":1.2991987466812134},{""x"":4.599999904632568,""y"":0.922961413860321},{""x"":5.099999904632568,""y"":0.6520044803619385},{""x"":5.599999904632568,""y"":0.15350978076457977},{""x"":6.099999904632568,""y"":0.1078903079032898},{""x"":6.599999904632568,""y"":0.17276449501514435},{""x"":7.099999904632568,""y"":0.14066608250141144}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCosta Rica,MKSTKEEIQTIKTLLKDSRTAKYHKRLQIVL,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCCc3ccccc3,1480018,36.3309440612793,995084218,4041 SOUTHWESTERN BLVD,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,6,6,2BPW,6,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.4833641843311227, -1.8945978742090062, 4.671127708092568, 0.24159861311815153],""points"":[{""x"":0.10000000149011612,""y"":0.0969524160027504},{""x"":0.6000000238418579,""y"":0.028483040630817413},{""x"":1.100000023841858,""y"":0.22087176144123077},{""x"":1.600000023841858,""y"":0.0068915546871721745},{""x"":2.0999999046325684,""y"":0.4305879771709442},{""x"":2.5999999046325684,""y"":0.44774115085601807},{""x"":3.0999999046325684,""y"":0.45346319675445557},{""x"":3.5999999046325684,""y"":0.2370593100786209},{""x"":4.099999904632568,""y"":0.4657953977584839},{""x"":4.599999904632568,""y"":1.155200719833374},{""x"":5.099999904632568,""y"":2.2294070720672607},{""x"":5.599999904632568,""y"":2.4311530590057373},{""x"":6.099999904632568,""y"":2.33846116065979},{""x"":6.599999904632568,""y"":2.608201026916504},{""x"":7.099999904632568,""y"":2.8136143684387207}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.224573521642033, 1.4454033924198528, 5.6014197746076535, 0.2823216054197577],""points"":[{""x"":0.10000000149011612,""y"":4.95027494430542},{""x"":0.6000000238418579,""y"":5.1754679679870605},{""x"":1.100000023841858,""y"":5.276752948760986},{""x"":1.600000023841858,""y"":5.589294910430908},{""x"":2.0999999046325684,""y"":5.616994857788086},{""x"":2.5999999046325684,""y"":5.120813846588135},{""x"":3.0999999046325684,""y"":5.340766906738281},{""x"":3.5999999046325684,""y"":4.876471042633057},{""x"":4.099999904632568,""y"":4.94999361038208},{""x"":4.599999904632568,""y"":5.162564754486084},{""x"":5.099999904632568,""y"":4.399557590484619},{""x"":5.599999904632568,""y"":2.7977969646453857},{""x"":6.099999904632568,""y"":1.0229872465133667},{""x"":6.599999904632568,""y"":0.48275601863861084},{""x"":7.099999904632568,""y"":0.10408931970596313}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCuba,MHAILRYFIRRLFYHIFYKIYSLISKKHQSLPSDVRQF,COc1ccc2c(c1)c(CC(=O)N3CCCC3C(=O)Oc4ccc(C)cc4OC)c(C)n2C(=O)c5ccc(Cl)cc5,1480019,36.33115768432617,995081928,1227 US HIGHWAY 11,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,7,7,1QBS,7,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.320838679713925, -1.2421619987316728, 4.831325425225256, 0.3236011098403072],""points"":[{""x"":0.10000000149011612,""y"":0.3727470338344574},{""x"":0.6000000238418579,""y"":0.12365014106035233},{""x"":1.100000023841858,""y"":0.48422467708587646},{""x"":1.600000023841858,""y"":0.2264465093612671},{""x"":2.0999999046325684,""y"":0.16821794211864471},{""x"":2.5999999046325684,""y"":0.3879014551639557},{""x"":3.0999999046325684,""y"":0.5470244884490967},{""x"":3.5999999046325684,""y"":0.3419053554534912},{""x"":4.099999904632568,""y"":0.7655120491981506},{""x"":4.599999904632568,""y"":1.2346516847610474},{""x"":5.099999904632568,""y"":2.453336715698242},{""x"":5.599999904632568,""y"":2.9565491676330566},{""x"":6.099999904632568,""y"":3.335299491882324},{""x"":6.599999904632568,""y"":3.240290880203247},{""x"":7.099999904632568,""y"":3.1107218265533447}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.6401853521511094, 1.26211588875013, 5.399028074402744, 0.5089580830068091],""points"":[{""x"":0.10000000149011612,""y"":3.8585598468780518},{""x"":0.6000000238418579,""y"":3.6077206134796143},{""x"":1.100000023841858,""y"":3.855252265930176},{""x"":1.600000023841858,""y"":3.619039297103882},{""x"":2.0999999046325684,""y"":3.839388370513916},{""x"":2.5999999046325684,""y"":3.335283041000366},{""x"":3.0999999046325684,""y"":3.571141481399536},{""x"":3.5999999046325684,""y"":3.4155046939849854},{""x"":4.099999904632568,""y"":3.7316646575927734},{""x"":4.599999904632568,""y"":3.0680155754089355},{""x"":5.099999904632568,""y"":2.891066551208496},{""x"":5.599999904632568,""y"":1.6022753715515137},{""x"":6.099999904632568,""y"":0.7652576565742493},{""x"":6.599999904632568,""y"":0.6875326037406921},{""x"":7.099999904632568,""y"":0.5828871726989746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nItaly,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO[N+](=O)[O-],1480020,36.33115768432617,99502,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,8,8,1ZP8,8,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.293592105923809, 1.3781586549141835, 5.1025898038676605, 0.03493851245291291],""points"":[{""x"":0.10000000149011612,""y"":2.1287283897399902},{""x"":0.6000000238418579,""y"":2.267972230911255},{""x"":1.100000023841858,""y"":2.398442506790161},{""x"":1.600000023841858,""y"":2.5130622386932373},{""x"":2.0999999046325684,""y"":2.3255116939544678},{""x"":2.5999999046325684,""y"":2.127340793609619},{""x"":3.0999999046325684,""y"":2.47259783744812},{""x"":3.5999999046325684,""y"":2.131181478500366},{""x"":4.099999904632568,""y"":2.090421438217163},{""x"":4.599999904632568,""y"":2.02299165725708},{""x"":5.099999904632568,""y"":1.1105059385299683},{""x"":5.599999904632568,""y"":0.4494485855102539},{""x"":6.099999904632568,""y"":0.1375635862350464},{""x"":6.599999904632568,""y"":0.036351121962070465},{""x"":7.099999904632568,""y"":0.1619771122932434}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.953125499439879, 1.2528620255306528, 5.187637440149802, 0.3110348753260886],""points"":[{""x"":0.10000000149011612,""y"":5.6585283279418945},{""x"":0.6000000238418579,""y"":5.911152362823486},{""x"":1.100000023841858,""y"":5.924920082092285},{""x"":1.600000023841858,""y"":5.8469438552856445},{""x"":2.0999999046325684,""y"":5.929472923278809},{""x"":2.5999999046325684,""y"":6.190037727355957},{""x"":3.0999999046325684,""y"":6.236179828643799},{""x"":3.5999999046325684,""y"":6.141019344329834},{""x"":4.099999904632568,""y"":5.295210838317871},{""x"":4.599999904632568,""y"":5.265801906585693},{""x"":5.099999904632568,""y"":3.3722851276397705},{""x"":5.599999904632568,""y"":1.8299226760864258},{""x"":6.099999904632568,""y"":0.32690900564193726},{""x"":6.599999904632568,""y"":0.6274543404579163},{""x"":7.099999904632568,""y"":0.8441857099533081}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nRwanda,MPNSEPASLLELFNSIATQGELVRSLKAGNASK,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO,1480021,36.33137130737305,995037247,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,9,9,2BDJ,9,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.8209972202654474, 1.3779216716448506, 5.299882228439686, 0.06040645519069608],""points"":[{""x"":0.10000000149011612,""y"":3.7821109294891357},{""x"":0.6000000238418579,""y"":3.542433023452759},{""x"":1.100000023841858,""y"":3.7008674144744873},{""x"":1.600000023841858,""y"":3.717301607131958},{""x"":2.0999999046325684,""y"":4.024452209472656},{""x"":2.5999999046325684,""y"":4.013899326324463},{""x"":3.0999999046325684,""y"":3.945094347000122},{""x"":3.5999999046325684,""y"":3.866621971130371},{""x"":4.099999904632568,""y"":3.7461626529693604},{""x"":4.599999904632568,""y"":3.3454740047454834},{""x"":5.099999904632568,""y"":2.61944317817688},{""x"":5.599999904632568,""y"":0.999405026435852},{""x"":6.099999904632568,""y"":0.46259793639183044},{""x"":6.599999904632568,""y"":0.054134611040353775},{""x"":7.099999904632568,""y"":0.05711187422275543}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.6318079657726035, 1.8495493770000595, 5.391793312471116, 0.17060707587348442],""points"":[{""x"":0.10000000149011612,""y"":5.458079814910889},{""x"":0.6000000238418579,""y"":5.554427146911621},{""x"":1.100000023841858,""y"":5.799983024597168},{""x"":1.600000023841858,""y"":5.364140033721924},{""x"":2.0999999046325684,""y"":5.864485740661621},{""x"":2.5999999046325684,""y"":5.4509806632995605},{""x"":3.0999999046325684,""y"":5.702574729919434},{""x"":3.5999999046325684,""y"":5.7314534187316895},{""x"":4.099999904632568,""y"":5.5123443603515625},{""x"":4.599999904632568,""y"":5.724395751953125},{""x"":5.099999904632568,""y"":4.354506969451904},{""x"":5.599999904632568,""y"":1.7307666540145874},{""x"":6.099999904632568,""y"":0.6305936574935913},{""x"":6.599999904632568,""y"":0.035183437168598175},{""x"":7.099999904632568,""y"":0.7575169205665588}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nSwitzerland,IRVVGRYLIEVWKAAGMDMDKVLFLWSSDEI,CN1CCC(CC1)Oc2ccc(cc2)C(F)(F)F,1480028,36.33137130737305,99504,92-11 179TH PLACE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,9,10,1IAN,10,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[1.1190255865097471, 2.3163895161544437, 5.4968866182279195, 0.2035204047289052],""points"":[{""x"":0.10000000149011612,""y"":1.1057683229446411},{""x"":0.6000000238418579,""y"":1.1019697189331055},{""x"":1.100000023841858,""y"":1.0818607807159424},{""x"":1.600000023841858,""y"":1.062997817993164},{""x"":2.0999999046325684,""y"":1.046447515487671},{""x"":2.5999999046325684,""y"":1.1217249631881714},{""x"":3.0999999046325684,""y"":1.2166996002197266},{""x"":3.5999999046325684,""y"":1.215477705001831},{""x"":4.099999904632568,""y"":1.0581893920898438},{""x"":4.599999904632568,""y"":1.1747995615005493},{""x"":5.099999904632568,""y"":1.0181127786636353},{""x"":5.599999904632568,""y"":0.5344523191452026},{""x"":6.099999904632568,""y"":0.2569526433944702},{""x"":6.599999904632568,""y"":0.1912207305431366},{""x"":7.099999904632568,""y"":0.15060538053512573}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.1038581025805785, 2.0032224204185245, 5.087602825989163, 0.13277988512492753],""points"":[{""x"":0.10000000149011612,""y"":3.0498509407043457},{""x"":0.6000000238418579,""y"":2.805217742919922},{""x"":1.100000023841858,""y"":3.3415253162384033},{""x"":1.600000023841858,""y"":3.0549843311309814},{""x"":2.0999999046325684,""y"":3.250074863433838},{""x"":2.5999999046325684,""y"":3.0432586669921875},{""x"":3.0999999046325684,""y"":3.265852451324463},{""x"":3.5999999046325684,""y"":2.9475724697113037},{""x"":4.099999904632568,""y"":3.1929898262023926},{""x"":4.599999904632568,""y"":2.7460060119628906},{""x"":5.099999904632568,""y"":1.6175861358642578},{""x"":5.599999904632568,""y"":0.3006608486175537},{""x"":6.099999904632568,""y"":0.3444803059101105},{""x"":6.599999904632568,""y"":0.015537971630692482},{""x"":7.099999904632568,""y"":0.5527358055114746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\n,,,,,,,,,,,,,,,,,,,,,').columns.add(i.Column.fromList(i.TYPE.BYTE_ARRAY,"BinaryImage",Array.from(new Uint8Array(11))));var o,r=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function s(e){try{l(i.next(e))}catch(e){r(e)}}function a(e){try{l(i.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((i=i.apply(e,t||[])).next())})};function s(e,t,n,i=0,o="timeout"){return r(this,void 0,void 0,function*(){return new Promise((r,s)=>{const a=e.subscribe(e=>{try{t(e),r("OK")}catch(e){s(e)}finally{a.unsubscribe(),clearTimeout(l)}}),l=setTimeout(()=>{a.unsubscribe(),s(o)},i);n()})})}function a(e){return r(this,void 0,void 0,function*(){yield new Promise(t=>setTimeout(t,e))})}console.log.bind(console),console.info.bind(console),console.warn.bind(console),console.error.bind(console),function(e){e.notNull=function(e,t){if(null==e)throw new Error(`${null==t?"Value":t} not defined`)}}(o||(o={})),i.DataFrame.fromColumns([i.Column.fromStrings("col",["val1","val2","val3"])])},8123:(e,t,n)=>{"use strict";n.d(t,{u:()=>i});const i={V2K_RGP_SHIFT:8,V2K_RGP_LINE:"M RGP",V2K_A_LINE:"A ",V3K_COUNTS_SHIFT:14,V3K_IDX_SHIFT:7,V3K_HEADER_FIRST_LINE:"\nDatagrok macromolecule handler\n\n",V3K_HEADER_SECOND_LINE:" 0 0 0 0 0 0 999 V3000\n",V3K_BEGIN_CTAB_BLOCK:"M V30 BEGIN CTAB\n",V3K_END_CTAB_BLOCK:"M V30 END CTAB\n",V3K_BEGIN_COUNTS_LINE:"M V30 COUNTS ",V3K_COUNTS_LINE_ENDING:" 0 0 0\n",V3K_BEGIN_ATOM_BLOCK:"M V30 BEGIN ATOM\n",V3K_END_ATOM_BLOCK:"M V30 END ATOM\n",V3K_BEGIN_BOND_BLOCK:"M V30 BEGIN BOND\n",V3K_END_BOND_BLOCK:"M V30 END BOND\n",V3K_BOND_CONFIG:" CFG=",V3K_BEGIN_DATA_LINE:"M V30 ",V3K_END:"M END",PRECISION_FACTOR:1e4,DEOXYRIBOSE:{polymerType:"RNA",symbol:"d"},RIBOSE:{polymerType:"RNA",symbol:"r"},PHOSPHATE:{polymerType:"RNA",symbol:"p"},OXYGEN:"O",HYDROGEN:"H"}},8152:(e,t,n)=>{"use strict";n.d(t,{GD:()=>d,ZY:()=>h});var i=n(4328),o=n(6082),r=n(2003),s=n(608),a=n(4139),l=n(2020);const c=new class{dcName="bio";async getDockerContainer(){return await i.dapi.docker.dockerContainers.filter(this.dcName).first()}},h=["mafft --auto","mafft","linsi","ginsi","einsi","fftns","fftnsi","nwns","nwnsi"],u=["AlignedSeq","AlignedSubpeptide","HELM","ID","PolymerID"];async function d(e,t,n,i="ginsi",l=1.53,h=0,d=null,m,g=!1){const f=await c.getDockerContainer(),y=t.length;d??=o.Column.int("Clusters",y).init(0),d.type!=o.COLUMN_TYPE.STRING&&(d=d.convertTo(o.TYPE.STRING));const b=d.categories,v=d.getRawData(),w=new Array(b.length),C=new Array(b.length);if(g){const n=e.selection;for(let e=-1;-1!==(e=n.findNext(e,!0));){const n=v[e];if(!b[n])continue;const i=n,o=t.get(e);o&&((w[i]??=[]).push({ID:e.toString(),HELM:o}),(C[n]??=[]).push(e))}}else for(let e=0;e<y;++e){const n=v[e];if(!b[n])continue;const i=n,o=t.get(e);o&&((w[i]??=[]).push({ID:e.toString(),HELM:o}),(C[n]??=[]).push(e))}(0,s.aZ)(C,b);const S=new Array(y).fill(null);for(const e of w){if(!e||0===e.length)continue;const t=(await p(f.id,e,i,l,h,m)).Alignment;for(const e of t)S[parseInt(e.ID)]=Object.entries(e).filter(e=>!u.includes(e[0])).map(e=>"-"!==e[1]?e[1]:"").join(a.J.SEPARATOR)}const A=o.Column.fromStrings(n,S);return A.meta.units=r.Hi.SEPARATOR,A.setTag(r.gp.separator,a.J.SEPARATOR),A.setTag(r.gp.aligned,"SEQ.MSA"),A.setTag(r.gp.alphabet,r.YI.UN),A.setTag(r.gp.alphabetIsMultichar,"true"),A.semType=o.SEMTYPE.MACROMOLECULE,A}async function p(e,t,n,o,r,s){const a={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(t)},c=`/align?method=${n}&gap_open=${o}&gap_extend=${r}`,h=window.performance.now(),u=await i.dapi.docker.dockerContainers.fetchProxy(e,c,a),d=window.performance.now();l._package.logger.debug(`Bio: requestAlignedObjects() dockerContainers.fetchProxy(), ET: ${d-h} ms`);const p="application/json"===u.headers.get("content-type");if(!u.ok&&p){const e=await u.json(),t=e["pepsea-error"];if(t)throw new Error(`PepSeA error: ${t}`);const n=e["datagrok-error"];if(n)throw new Error(`Datagrok error: ${n}`);throw new Error(u.statusText)}if(!u.ok&&!p){const e=await u.text();throw new Error(`Error: ${e}`)}if(!p){const e=await u.text();throw new Error(`Error: PepSeA expected JSON response, got '${e}'.`)}const m=await u.json();if("pepsea-stderr"in m){const e=m["pepsea-stderr"];s?.warning(e)}return m}},8153:(e,t)=>{function n(e){return"number"!=typeof e||isNaN(e)?1:e}t.Fd=function(e){return function(e,t){var n={},i=function(e){return void 0===e?t:e};"function"==typeof t&&(i=t);var o=function(t){return i(t[e])},r=function(){return i(void 0)};return"string"==typeof e?(n.fromAttributes=o,n.fromGraph=function(e,t){return o(e.getEdgeAttributes(t))},n.fromEntry=function(e,t){return o(t)},n.fromPartialEntry=n.fromEntry,n.fromMinimalEntry=n.fromEntry):"function"==typeof e?(n.fromAttributes=function(){throw new Error("graphology-utils/getters/createEdgeValueGetter: irrelevant usage.")},n.fromGraph=function(t,n){var o=t.extremities(n);return i(e(n,t.getEdgeAttributes(n),o[0],o[1],t.getNodeAttributes(o[0]),t.getNodeAttributes(o[1]),t.isUndirected(n)))},n.fromEntry=function(t,n,o,r,s,a,l){return i(e(t,n,o,r,s,a,l))},n.fromPartialEntry=function(t,n,o,r){return i(e(t,n,o,r))},n.fromMinimalEntry=function(t,n){return i(e(t,n))}):(n.fromAttributes=r,n.fromGraph=r,n.fromEntry=r,n.fromMinimalEntry=r),n}(e,n)}},8226:e=>{"use strict";e.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/meta/content","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/content":true},"$dynamicAnchor":"meta","title":"Content vocabulary meta-schema","type":["object","boolean"],"properties":{"contentEncoding":{"type":"string"},"contentMediaType":{"type":"string"},"contentSchema":{"$dynamicRef":"#meta"}}}')},8312:(e,t,n)=>{"use strict";n.d(t,{Q:()=>o});var i=n(6082);async function o(){const e=i.Func.find({package:"Bio",name:"getSeqHelper"});if(0===e.length)throw new Error("Package 'Bio' must be installed for SeqHelper.");return(await e[0].prepare().call()).getOutputParamValue()}},8343:(e,t,n)=>{"use strict";const{normalizeIPv6:i,normalizeIPv4:o,removeDotSegments:r,recomposeAuthority:s,normalizeComponentEncoding:a}=n(4834),l=n(343);function c(e,t,n,i){const o={};return i||(e=p(h(e,n),n),t=p(h(t,n),n)),!(n=n||{}).tolerant&&t.scheme?(o.scheme=t.scheme,o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=r(t.path||""),o.query=t.query):(void 0!==t.userinfo||void 0!==t.host||void 0!==t.port?(o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=r(t.path||""),o.query=t.query):(t.path?("/"===t.path.charAt(0)?o.path=r(t.path):(void 0===e.userinfo&&void 0===e.host&&void 0===e.port||e.path?e.path?o.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+t.path:o.path=t.path:o.path="/"+t.path,o.path=r(o.path)),o.query=t.query):(o.path=e.path,void 0!==t.query?o.query=t.query:o.query=e.query),o.userinfo=e.userinfo,o.host=e.host,o.port=e.port),o.scheme=e.scheme),o.fragment=t.fragment,o}function h(e,t){const n={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:""},i=Object.assign({},t),o=[],a=l[(i.scheme||n.scheme||"").toLowerCase()];a&&a.serialize&&a.serialize(n,i),void 0!==n.path&&(i.skipEscape?n.path=unescape(n.path):(n.path=escape(n.path),void 0!==n.scheme&&(n.path=n.path.split("%3A").join(":")))),"suffix"!==i.reference&&n.scheme&&o.push(n.scheme,":");const c=s(n);if(void 0!==c&&("suffix"!==i.reference&&o.push("//"),o.push(c),n.path&&"/"!==n.path.charAt(0)&&o.push("/")),void 0!==n.path){let e=n.path;i.absolutePath||a&&a.absolutePath||(e=r(e)),void 0===c&&(e=e.replace(/^\/\//u,"/%2F")),o.push(e)}return void 0!==n.query&&o.push("?",n.query),void 0!==n.fragment&&o.push("#",n.fragment),o.join("")}const u=Array.from({length:127},(e,t)=>/[^!"$&'()*+,\-.;=_`a-z{}~]/u.test(String.fromCharCode(t))),d=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function p(e,t){const n=Object.assign({},t),r={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},s=-1!==e.indexOf("%");let a=!1;"suffix"===n.reference&&(e=(n.scheme?n.scheme+":":"")+"//"+e);const c=e.match(d);if(c){if(r.scheme=c[1],r.userinfo=c[3],r.host=c[4],r.port=parseInt(c[5],10),r.path=c[6]||"",r.query=c[7],r.fragment=c[8],isNaN(r.port)&&(r.port=c[5]),r.host){const e=o(r.host);if(!1===e.isIPV4){const t=i(e.host);r.host=t.host.toLowerCase(),a=t.isIPV6}else r.host=e.host,a=!0}void 0!==r.scheme||void 0!==r.userinfo||void 0!==r.host||void 0!==r.port||void 0!==r.query||r.path?void 0===r.scheme?r.reference="relative":void 0===r.fragment?r.reference="absolute":r.reference="uri":r.reference="same-document",n.reference&&"suffix"!==n.reference&&n.reference!==r.reference&&(r.error=r.error||"URI is not a "+n.reference+" reference.");const e=l[(n.scheme||r.scheme||"").toLowerCase()];if(!(n.unicodeSupport||e&&e.unicodeSupport)&&r.host&&(n.domainHost||e&&e.domainHost)&&!1===a&&function(e){let t=0;for(let n=0,i=e.length;n<i;++n)if(t=e.charCodeAt(n),t>126||u[t])return!0;return!1}(r.host))try{r.host=URL.domainToASCII(r.host.toLowerCase())}catch(e){r.error=r.error||"Host's domain name can not be converted to ASCII: "+e}(!e||e&&!e.skipNormalize)&&(s&&void 0!==r.scheme&&(r.scheme=unescape(r.scheme)),s&&void 0!==r.host&&(r.host=unescape(r.host)),r.path&&(r.path=escape(unescape(r.path))),r.fragment&&(r.fragment=encodeURI(decodeURIComponent(r.fragment)))),e&&e.parse&&e.parse(r,n)}else r.error=r.error||"URI can not be parsed.";return r}const m={SCHEMES:l,normalize:function(e,t){return"string"==typeof e?e=h(p(e,t),t):"object"==typeof e&&(e=p(h(e,t),t)),e},resolve:function(e,t,n){const i=Object.assign({scheme:"null"},n);return h(c(p(e,i),p(t,i),i,!0),{...i,skipEscape:!0})},resolveComponents:c,equal:function(e,t,n){return"string"==typeof e?(e=unescape(e),e=h(a(p(e,n),!0),{...n,skipEscape:!0})):"object"==typeof e&&(e=h(a(e,!0),{...n,skipEscape:!0})),"string"==typeof t?(t=unescape(t),t=h(a(p(t,n),!0),{...n,skipEscape:!0})):"object"==typeof t&&(t=h(a(t,!0),{...n,skipEscape:!0})),e.toLowerCase()===t.toLowerCase()},serialize:h,parse:p};e.exports=m,e.exports.default=m,e.exports.fastUri=m},8438:(e,t,n)=>{"use strict";function i(e){return e.startsWith("[")&&e.endsWith("]")?e.slice(1,-1):e}n.d(t,{D:()=>i})},8498:(e,t,n)=>{"use strict";var i,o,r,s,a,l,c;n.d(t,{EG:()=>a,Pn:()=>o,RR:()=>l,Wn:()=>c,aT:()=>r,m6:()=>s,xL:()=>i}),function(e){e.Levenshtein="Levenshtein",e.JaroWinkler="Jaro-Winkler",e.Manhattan="Manhattan String",e.Onehot="One-Hot"}(i||(i={})),function(e){e.Euclidean="Euclidean",e.Manhattan="Manhattan",e.Cosine="Vector Cosine"}(o||(o={})),function(e){e.Tanimoto="Tanimoto",e.Dice="Dice",e.Asymmetric="Asymmetric",e.BraunBlanquet="Braun-Blanquet",e.Cosine="Cosine",e.Kulczynski="Kulczynski",e.McConnaughey="Mc-Connaughey",e.RogotGoldberg="Rogot-Goldberg",e.Russel="Russel",e.Sokal="Sokal",e.Hamming="Hamming",e.Euclidean="Euclidean BitArray"}(r||(r={})),function(e){e.TanimotoIntArray="TanimotoIntArray"}(s||(s={})),function(e){e.Vector="Vector",e.String="String",e.BitArray="BitArray",e.MacroMolecule="MacroMolecule",e.Number="Number",e.IntArray="IntArray",e.NumberArray="NumberArray"}(a||(a={})),function(e){e.Difference="Difference"}(l||(l={})),function(e){e.CommonItems="Common Items"}(c||(c={}))},8604:(e,t,n)=>{"use strict";n.d(t,{G:()=>i});const i={explicit:["HELMCoreLibrary.json","polytool-lib.json"],exclude:[],duplicateMonomerPreferences:{}}},8643:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o=n(4227),r=n(6250),s={keyword:"enum",schemaType:"array",$data:!0,error:{message:"must be equal to one of the allowed values",params:({schemaCode:e})=>i._`{allowedValues: ${e}}`},code(e){const{gen:t,data:n,$data:s,schema:a,schemaCode:l,it:c}=e;if(!s&&0===a.length)throw new Error("enum must have non-empty array");const h=a.length>=c.opts.loopEnum;let u;const d=()=>null!=u?u:u=(0,o.useFunc)(t,r.default);let p;if(h||s)p=t.let("valid"),e.block$data(p,function(){t.assign(p,!1),t.forOf("v",l,e=>t.if(i._`${d()}(${n}, ${e})`,()=>t.assign(p,!0).break()))});else{if(!Array.isArray(a))throw new Error("ajv implementation error");const e=t.const("vSchema",l);p=(0,i.or)(...a.map((t,o)=>function(e,t){const o=a[t];return"object"==typeof o&&null!==o?i._`${d()}(${n}, ${e}[${t}])`:i._`${n} === ${o}`}(e,o)))}e.pass(p)}};t.default=s},8660:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(5765),o=n(9029),r=n(2023),s=n(4227),a={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:{message:"must NOT have additional properties",params:({params:e})=>o._`{additionalProperty: ${e.additionalProperty}}`},code(e){const{gen:t,schema:n,parentSchema:a,data:l,errsCount:c,it:h}=e;if(!c)throw new Error("ajv implementation error");const{allErrors:u,opts:d}=h;if(h.props=!0,"all"!==d.removeAdditional&&(0,s.alwaysValidSchema)(h,n))return;const p=(0,i.allSchemaProperties)(a.properties),m=(0,i.allSchemaProperties)(a.patternProperties);function g(e){t.code(o._`delete ${l}[${e}]`)}function f(i){if("all"===d.removeAdditional||d.removeAdditional&&!1===n)g(i);else{if(!1===n)return e.setParams({additionalProperty:i}),e.error(),void(u||t.break());if("object"==typeof n&&!(0,s.alwaysValidSchema)(h,n)){const n=t.name("valid");"failing"===d.removeAdditional?(y(i,n,!1),t.if((0,o.not)(n),()=>{e.reset(),g(i)})):(y(i,n),u||t.if((0,o.not)(n),()=>t.break()))}}}function y(t,n,i){const o={keyword:"additionalProperties",dataProp:t,dataPropType:s.Type.Str};!1===i&&Object.assign(o,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(o,n)}t.forIn("key",l,n=>{p.length||m.length?t.if(function(n){let r;if(p.length>8){const e=(0,s.schemaRefOrVal)(h,a.properties,"properties");r=(0,i.isOwnProperty)(t,e,n)}else r=p.length?(0,o.or)(...p.map(e=>o._`${n} === ${e}`)):o.nil;return m.length&&(r=(0,o.or)(r,...m.map(t=>o._`${(0,i.usePattern)(e,t)}.test(${n})`))),(0,o.not)(r)}(n),()=>f(n)):f(n)}),e.ok(o._`${c} === ${r.default.errors}`)}};t.default=a},8708:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extendErrors=t.resetErrorsCount=t.reportExtraError=t.reportError=t.keyword$DataError=t.keywordError=void 0;const i=n(9029),o=n(4227),r=n(2023);function s(e,t){const n=e.const("err",t);e.if(i._`${r.default.vErrors} === null`,()=>e.assign(r.default.vErrors,i._`[${n}]`),i._`${r.default.vErrors}.push(${n})`),e.code(i._`${r.default.errors}++`)}function a(e,t){const{gen:n,validateName:o,schemaEnv:r}=e;r.$async?n.throw(i._`new ${e.ValidationError}(${t})`):(n.assign(i._`${o}.errors`,t),n.return(!1))}t.keywordError={message:({keyword:e})=>i.str`must pass "${e}" keyword validation`},t.keyword$DataError={message:({keyword:e,schemaType:t})=>t?i.str`"${e}" keyword must be ${t} ($data)`:i.str`"${e}" keyword is invalid ($data)`},t.reportError=function(e,n=t.keywordError,o,r){const{it:l}=e,{gen:h,compositeRule:u,allErrors:d}=l,p=c(e,n,o);(null!=r?r:u||d)?s(h,p):a(l,i._`[${p}]`)},t.reportExtraError=function(e,n=t.keywordError,i){const{it:o}=e,{gen:l,compositeRule:h,allErrors:u}=o;s(l,c(e,n,i)),h||u||a(o,r.default.vErrors)},t.resetErrorsCount=function(e,t){e.assign(r.default.errors,t),e.if(i._`${r.default.vErrors} !== null`,()=>e.if(t,()=>e.assign(i._`${r.default.vErrors}.length`,t),()=>e.assign(r.default.vErrors,null)))},t.extendErrors=function({gen:e,keyword:t,schemaValue:n,data:o,errsCount:s,it:a}){if(void 0===s)throw new Error("ajv implementation error");const l=e.name("err");e.forRange("i",s,r.default.errors,s=>{e.const(l,i._`${r.default.vErrors}[${s}]`),e.if(i._`${l}.instancePath === undefined`,()=>e.assign(i._`${l}.instancePath`,(0,i.strConcat)(r.default.instancePath,a.errorPath))),e.assign(i._`${l}.schemaPath`,i.str`${a.errSchemaPath}/${t}`),a.opts.verbose&&(e.assign(i._`${l}.schema`,n),e.assign(i._`${l}.data`,o))})};const l={keyword:new i.Name("keyword"),schemaPath:new i.Name("schemaPath"),params:new i.Name("params"),propertyName:new i.Name("propertyName"),message:new i.Name("message"),schema:new i.Name("schema"),parentSchema:new i.Name("parentSchema")};function c(e,t,n){const{createErrors:o}=e.it;return!1===o?i._`{}`:function(e,t,n={}){const{gen:o,it:s}=e,a=[h(s,n),u(e,n)];return function(e,{params:t,message:n},o){const{keyword:s,data:a,schemaValue:c,it:h}=e,{opts:u,propertyName:d,topSchemaRef:p,schemaPath:m}=h;o.push([l.keyword,s],[l.params,"function"==typeof t?t(e):t||i._`{}`]),u.messages&&o.push([l.message,"function"==typeof n?n(e):n]),u.verbose&&o.push([l.schema,c],[l.parentSchema,i._`${p}${m}`],[r.default.data,a]),d&&o.push([l.propertyName,d])}(e,t,a),o.object(...a)}(e,t,n)}function h({errorPath:e},{instancePath:t}){const n=t?i.str`${e}${(0,o.getErrorPath)(t,o.Type.Str)}`:e;return[r.default.instancePath,(0,i.strConcat)(r.default.instancePath,n)]}function u({keyword:e,it:{errSchemaPath:t}},{schemaPath:n,parentSchema:r}){let s=r?t:i.str`${t}/${e}`;return n&&(s=i.str`${s}${(0,o.getErrorPath)(n,o.Type.Str)}`),[l.schemaPath,s]}},8727:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.boolOrEmptySchema=t.topBoolOrEmptySchema=void 0;const i=n(8708),o=n(9029),r=n(2023),s={message:"boolean schema is false"};function a(e,t){const{gen:n,data:o}=e,r={gen:n,keyword:"false schema",data:o,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,i.reportError)(r,s,void 0,t)}t.topBoolOrEmptySchema=function(e){const{gen:t,schema:n,validateName:i}=e;!1===n?a(e,!1):"object"==typeof n&&!0===n.$async?t.return(r.default.data):(t.assign(o._`${i}.errors`,null),t.return(!0))},t.boolOrEmptySchema=function(e,t){const{gen:n,schema:i}=e;!1===i?(n.var(t,!1),a(e)):n.var(t,!0)}},8754:(e,t,n)=>{"use strict";n.d(t,{V:()=>h});var i=n(4328),o=n(6077),r=n(2003),s=n(8312),a=n(5553),l=n(966),c=n(330);async function h(e,t,n,h,u,d,p){let m;if(n){const n=await(0,s.Q)(),i=n.getSeqHandler(t);let o,a;i.isHelm()?o=t:(a=t.name,t.name=`__${a}`,o=i.convert(r.Hi.HELM),o.name=a,e.columns.add(o,!1));try{m=await n.helmToAtomicLevel(o,!0,!0,u)}finally{o!==t&&(e.columns.remove(o.name),t.name=a)}}else{if(!(0,l.l)(t,"To Atomic Level",d)[0])return{molCol:null,warnings:["Column is not suitable"]};m=await(0,o.C4)(e,t,u,d,p)}if(m.molCol){const o=(0,c.qj)(e,t.name);m.molCol.name=o,e.columns.add(m.molCol,!0),await(0,a.Qc)(t,m.molCol,u,d,p,n),m.molCol.setTag(".sequence-src-highlight-monomers",String(h)),await i.data.detectSemanticTypes(e)}return m}},8774:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});class i{constructor(e,t=!1){if(this._length=0,this._version=0,this._updateLevel=0,this._selectedCount=0,this._selectedCountVersion=-1,this._selectedIndexesVersion=-1,this._versionedName="",this._versionedNameVersion=-1,this.SHRINK_THRESHOLD=256,"number"==typeof e){const n=e,o=i._createBuffer(n);if(t)for(let e=0;e<o.length;e++)o[e]=-1;this._data=o,this._length=n}else{if(!(e instanceof Uint32Array))throw new Error("Invalid constructor");this._data=e,this._length=t}}getRawData(){return this._data}assureGoez(e,t){if(e<0)throw new Error(`${t} should be greater than zero`)}assureInRange(e,t,n,i){if(e<t||e>n)throw new Error(`Argument ${i} (${e}) out of range (${t}, ${n})`)}copy(e,t,n){for(let i=0;i<n;i++)t[i]=e[i]}copyFrom(e){if(this._length!=e._length)throw new Error(`Lengths differ (${this._length} != ${e._length})`);this.copy(e._data,this._data,this.lengthInInts),this._version++}get length(){return this._length}get buffer(){return this._data}set buffer(e){this._data=e,this._version++}get version(){return this._version}set version(e){this._version=e}incrementVersion(e=!0){this._version++}get lengthInInts(){return Math.floor((this._length+31)/32)}get versionedName(){return this._version==this._versionedNameVersion?this._versionedName:""}set versionedName(e){this._versionedName=e,this._versionedNameVersion=this._version}get self(){return this}setLength(e){if(e<0)throw new Error("should be >= 0");if(e==this._length)return;const t=Math.floor((e+31)/32);if(t>this._data.length||t+this.SHRINK_THRESHOLD<this._data.length){const e=new Uint32Array(t);this.copy(this._data,e,t>this._data.length?this._data.length:t),this._data=e}e>this._length&&(this._length%32>0&&(this._data[this.lengthInInts-1]&=(1<<(this._length%32&31))-1),this._data.fill(0,this.lengthInInts,t)),this._length=e,this._version++}static fromAnd(e,t){if(e._length!=t._length)throw new Error(`Lengths differ (${e._length} != ${t._length})`);const n=new i(e._length);n._length=e._length,n._data=i._createBuffer(n._length),n._version=0;const o=e.lengthInInts;for(let i=0;i<o;i++)n._data[i]=e._data[i]&t._data[i];return n}static _createBuffer(e){return new Uint32Array(Math.floor((e+31)/32))}static fromValues(e){const t=new i(e.length);t._version=0;for(let n=0;n<t._length;n++)e[n]&&(t._data[Math.floor(n/32)]|=1<<(n%32&31));return t}static fromSeq(e,t){const n=new i(e);for(let i=0;i<e;++i)n.setBit(i,t(i));return n._version=0,n}static fromString(e){return i.fromSeq(e.length,t=>"1"==e.charAt(t))}static fromUint32Array(e,t){const n=new i(e);return n._data=t,n}static fromBytes(e){const t=e.length,n=new i(8*t);n._data=new Uint32Array(Math.floor((t+3)/4)),n._length=8*t;let o=0,r=0;for(;t-r>=4;)n._data[o++]=255&e[r]|(255&e[r+1])<<8|(255&e[r+2])<<16|(255&e[r+3])<<24,r+=4;return t-r==3&&(n._data[o]=(255&e[r+2])<<16),t-r==2&&(n._data[o]|=(255&e[r+1])<<8),t-r==1&&(n._data[o]|=255&e[r]),n._version=0,n}toString(){return`${this._length} bits, ${this.countBits(!0)} set`}equals(e){if(this==e)return!0;if(null==e)return!1;if(this._length!=e._length)return!1;if(0==this._length)return!0;for(let t=0;t<this._data.length-1;t++)if(this._data[t]!=e._data[t])return!1;for(let t=8*(this._data.length-1);t<this._length;t++)if(this.getBit(t)!=e.getBit(t))return!1;return!0}clone(){const e=new i(0,!1);return e._data=Uint32Array.from(this._data),e._length=this._length,e._version=this._version,e}init(e,t){this.setAll(!1,!1);for(let t=0;t<this._length;t++)e(t)&&(this._data[Math.floor(t/32)]|=1<<(t%32&31));return this.incrementVersion(t),this}invert(e=!0){for(let e=0;e<this._data.length;e++)this._data[e]^=-1;this.incrementVersion(e)}setAll(e,t=!1){const n=e?-1:0,i=this.lengthInInts;for(let e=0;e<i;e++)this._data[e]=n;this.incrementVersion(t)}setIndexes(e,t=!0,n=!0,i=!0){n&&this.setAll(!t,!1);for(const n of e)this.setFast(n,t);this.incrementVersion(i)}everyIndex(e,t=!0){for(const n of e)if(this.getBit(n)!=t)return!1;return!0}anyIndex(e,t=!0){for(const n of e)if(this.getBit(n)==t)return!0;return!1}setWhere(e,t=!0,n=!0,i=!0,o=!0){if(n&&o&&this.setAll(!t,!1),o)for(let n=0;n<this._length;n++)e(n)&&this.setFast(n,t);else for(let n=0;n<this._length;n++)this.setFast(n,e(n)?t:!t);this.incrementVersion(i)}getRange(e,t){this.assureInRange(e,0,this._length-1,"from"),this.assureInRange(t,0,this._length,"to");const n=[];for(let i=e;i<t;++i)n.push(this.getBit(i));return i.fromValues(n)}getRangeAsList(e,t){this.assureInRange(e,0,this._length-1,"from"),this.assureInRange(t,0,this._length,"to");const n=[];for(let i=e;i<t;++i)n.push(this.getBit(i));return n}setRange(e,t,n,i=!0){this.assureInRange(e,0,this._length-1,"from"),this.assureInRange(t,0,this._length-1,"to");const o=Math.min(e,t),r=Math.max(e,t);if(n)for(let e=o;e<=r;e++)this.setTrue(e);else for(let e=o;e<=r;e++)this.setFalse(e);return this.incrementVersion(i),this}setRandom(e,t,n=!0){if(e<0||e>this._length)throw new Error("n must be >= 0 && <= Count");e>this._length/2&&this.setRandom(this._length-e,!t),this.setAll(!t);for(let n=0;n<e;){const e=Math.floor(Math.random()*this._length);this.getBit(e)!=t&&(this.setFast(e,t),n++)}this.incrementVersion(n)}and(e,t=!0){if(this._length!=e._length)throw new Error("Array lengths differ.");for(let t=0,n=this.lengthInInts;t<n;t++)this._data[t]&=e._data[t];return this.incrementVersion(t),this}andNot(e,t=!0){if(this._length!=e._length)throw new Error("Array lengths differ.");const n=this.lengthInInts;for(let t=0;t<n;t++)this._data[t]&=~e._data[t];return this.incrementVersion(t),this}notAnd(e,t=!0){if(this._length!=e._length)throw new Error("Array lengths differ.");for(let t=0,n=this.lengthInInts;t<n;t++)this._data[t]=~this._data[t]&e._data[t];return this.incrementVersion(t),this}not(e=!0){for(let e=0,t=this.lengthInInts;e<t;e++)this._data[e]=~this._data[e];return this.incrementVersion(e),this}or(e,t=!0){if(this._length!=e._length)throw new Error("Array lengths differ.");for(let t=0,n=this.lengthInInts;t<n;t++)this._data[t]|=e._data[t];return this.incrementVersion(t),this}xor(e,t=!0){if(this._length!=e._length)throw new Error("Array lengths differ.");for(let t=0,n=this.lengthInInts;t<n;t++)this._data[t]^=e._data[t];return this.incrementVersion(t),this}insertAt(e,t,n=!1){if(this.assureInRange(e,0,this._length,"pos"),0==t)return;const i=this._length;this.setLength(this._length+t);for(let n=i-1;n>=e;n--)this.setBit(n+t,this.getBit(n));for(let i=e;i<e+t;i++)this.setBit(i,n)}removeAt(e,t=1){if(t<0)throw new Error("n cannot be negative");if(this.assureInRange(e,0,this._length-t,"pos"),this.contains(!0))for(let n=e;n<this._length-t;n++)this.setBit(n,this.getBit(n+t));this.setLength(this._length-t)}removeByMask(e,t=!0){if(this._length!=e.length)throw new Error("length != mask.length");if(e==this)this.setLength(e.countBits(!t)),this.setAll(!t);else{let n=0;for(let i=-1;-1!=(i=e.findNext(i,!t));)this.setFast(n++,this.getBit(i));this._length=n,this._version++}return this}getBit(e){return!!(this._data[Math.floor(e/32)]&1<<(31&e))}setBit(e,t,n=!0){this.setFast(e,t),this._version++}setFast(e,t){t?this._data[Math.floor(e/32)]|=1<<(31&e):this._data[Math.floor(e/32)]&=~(1<<(31&e))}setTrue(e){this._data[Math.floor(e/32)]|=1<<(31&e)}setFalse(e){this._data[Math.floor(e/32)]&=~(1<<(31&e))}trueCount(){return this.countBits(!0)}falseCount(){return this.countBits(!1)}countBits(e){if(0==this._length)return 0;if(this._selectedCountVersion!=this._version){this._selectedCount=0;const e=this.lengthInInts;let t=0;for(;t<e-1;t++)for(let e=this._data[t];0!=e;e>>>=8)this._selectedCount+=i._onBitCount[255&e];let n=this._data[t];const o=31&this._length;for(0!=o&&(n&=~(4294967295<<o));0!=n;n>>>=8)this._selectedCount+=i._onBitCount[255&n];this._selectedCountVersion=this._version}return e?this._selectedCount:this._length-this._selectedCount}countWhere(e){let t=0;if(this.trueCount()==this._length)for(let n=0;n<this._length;n++)t+=e(n)?1:0;else for(let n=-1;-1!=(n=this.findNext(n,!0));)t+=e(n)?1:0;return t}andWithCountBits(e,t){if(0==this._length)return 0;let n=0;const o=this.lengthInInts;let r=0;for(;r<o-1;r++)for(let t=this._data[r]&e._data[r];0!=t;t>>>=8)n+=i._onBitCount[255&t];let s=this._data[r]&e._data[r];const a=31&this._length;for(0!=a&&(s&=~(4294967295<<a));0!=s;s>>>=8)n+=i._onBitCount[255&s];return t?n:this._length-n}clear(){this.setLength(0)}contains(e){return this.findNext(-1,e)>=0}get allTrue(){return this.countBits(!0)==this._length}get allFalse(){return this.countBits(!1)==this._length}get anyTrue(){return this.countBits(!0)>0}get anyFalse(){return this.countBits(!1)>0}findNext(e,t=!0){if(this.assureInRange(e,-1,this._length,"index"),e>=this._length-1)return-1;let n=31&(e=e<0?0:e+1);const o=this.lengthInInts;for(let r=Math.floor(e/32);r<o;r++){let o=t?this._data[r]:~this._data[r];if(0!=n)o&=4294967295<<n&4294967295,n=0;else if(!t&&-4294967296==o)continue;for(let t=0;0!=o;t+=8,o>>>=8){const n=i._firstOnBit[255&o];if(n>=0)return(e=n+32*r+t)>=this._length?-1:e}}return-1}findPrev(e,t=!0){if(0==e)return-1;this.assureInRange(e,-1,this._length,"index");let n=1+(e=e<0?this._length-1:e-1)&31;for(let o=Math.floor(e/32);o>=0;o--){let e=t?this._data[o]:~this._data[o];0!=n&&(e&=~(4294967295<<n),n=0);for(let t=24;0!=e;t-=8,e<<=8){const n=i._lastOnBit[e>>>24];if(n>=0)return n+32*o+t}}return-1}}i._onBitCount=Int8Array.from([0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8]),i._firstOnBit=Int8Array.from([-1,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,7,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0]),i._lastOnBit=Int8Array.from([-1,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7])},8903:(e,t,n)=>{var i=n(1736),o=n(8153).Fd,r=n(2561),s=n(1782),a=n(9937);function l(e,t,n){if(!i(t))throw new Error("graphology-layout-forceatlas2: the given graph is not a valid graphology instance.");"number"==typeof n&&(n={iterations:n});var l=n.iterations;if("number"!=typeof l)throw new Error("graphology-layout-forceatlas2: invalid number of iterations.");if(l<=0)throw new Error("graphology-layout-forceatlas2: you should provide a positive number of iterations.");var c=o("getEdgeWeight"in n?n.getEdgeWeight:"weight").fromEntry,h="function"==typeof n.outputReducer?n.outputReducer:null,u=s.assign({},a,n.settings),d=s.validateSettings(u);if(d)throw new Error("graphology-layout-forceatlas2: "+d.message);var p,m=s.graphToByteArrays(t,c);for(p=0;p<l;p++)r(u,m.nodes,m.edges);if(!e)return s.collectLayoutChanges(t,m.nodes);s.assignLayoutChanges(t,m.nodes,h)}var c=l.bind(null,!1);c.assign=l.bind(null,!0),c.inferSettings=function(e){var t="number"==typeof e?e:e.order;return{barnesHutOptimize:t>2e3,strongGravityMode:!0,gravity:.05,scalingRatio:10,slowDown:1+Math.log(t)}},e.exports=c},8924:(e,t,n)=>{"use strict";var i=n(7362);class o extends i.e{static get Lesk(){return void 0===this.lesk&&(this.lesk=this.makePalette([[["G","A","S","T"],"orange"],[["C","V","I","L","P","F","Y","M","W"],"all_green"],[["N","Q","H"],"magenta"],[["D","E"],"red"],[["K","R"],"all_blue"]],!1,o)),this.lesk}static get GrokGroups(){return void 0===this.grokGroups&&(this.grokGroups=this.makePalette([[["C","U"],"yellow"],[["G","P"],"red"],[["A","V","I","L","M","F","Y","W"],"all_green"],[["R","H","K"],"light_blue"],[["D","E"],"dark_blue"],[["S","T","N","Q"],"orange"]],!1,o)),this.grokGroups}static get RasMol(){return void 0===this.rasMol&&(this.rasMol=new o({D:"#E60A0A",E:"#E60A0A",C:"#E6E600",M:"#E6E600",K:"#145AFF",R:"#145AFF",S:"#FA9600",T:"#FA9600",F:"#3232AA",Y:"#3232AA",N:"#00DCDC",Q:"#00DCDC",G:"#EBEBEB",L:"#0F820F",V:"#0F820F",I:"#0F820F",A:"#C8C8C8",W:"#B45AB4",H:"#8282D2",P:"#DC9682",others:"#BEA06E"})),this.rasMol}get(e){const t=e in o.aaSynonyms?o.aaSynonyms[e]:e;return super.get(t)}}o.aaSynonyms={MeNle:"L",MeA:"A",MeG:"G",MeF:"F"};class r{static getPalette(e="grok"){switch(e){case"grok":return o.GrokGroups;case"lesk":return o.Lesk;default:throw new Error(`ChemPalette: scheme \`${e}\` does not exist`)}}static getInnerOuter(e){let t=0,n="",i="";for(const o of e)"("==o?t++:")"==o?t--:t?n+=o:i+=o;return isNaN(parseInt(n))?[i,n]:[i,""]}static getColorAAPivot(e="",t="grok"){const n=this.getPalette(t);let[i,o]=this.getInnerOuter(e);if(i=i.length>6?`${i.slice(0,3)}...`:i,o=o.length>6?`${o.slice(0,3)}...`:o,1==e.length||"("==e[1]){const t=e[0]?.toUpperCase();return t in n?[n.get(t),t,o,1]:[this.undefinedColor,i,o,1]}if("d"==e[0]&&e[1]in n&&(2==e.length||"("==e[2])){const t=e[1]?.toUpperCase();return t in n?[n.get(t),t,o,2]:[this.undefinedColor,i,o,2]}if(e.substring(0,3)in this.AAFullNames&&(3==e.length||"("==e[3])){const t=this.AAFullNames[e.substring(0,3)];return t in n?[n.get(t),t,o,3]:[this.undefinedColor,i,o,3]}if(e[0]?.toLowerCase()==e[0]&&e.substring(1,3)in this.AAFullNames&&(4==e.length||"("==e[4])){const t=this.AAFullNames[e.substring(1,3)];return t in n?[n.get(t),t,o,4]:[this.undefinedColor,i,o,4]}return[this.undefinedColor,i,o,0]}}r.SemType="Aminoacids",r.SemTypeMultipleAlignment="AminoacidsMultipleAlignment",r.undefinedColor="rgb(100,100,100)",r.Names={G:"Glycine",L:"Leucine",Y:"Tyrosine",S:"Serine",E:"Glutamic acid",Q:"Glutamine",D:"Aspartic acid",N:"Asparagine",F:"Phenylalanine",A:"Alanine",K:"Lysine",R:"Arginine",H:"Histidine",C:"Cysteine",V:"Valine",P:"Proline",W:"Tryptophan",I:"Isoleucine",M:"Methionine",T:"Threonine"},r.AASmiles={G:"NCC(=O)O",L:"N[C@H](CC(C)C)C(=O)O",Y:"NC(CC1=CC=C(O)C=C1)C(=O)O",S:"NC(CO)C(=O)O",E:"N[C@@H](CCC(O)=O)C(=O)O",Q:"N[C@@H](CCC(N)=O)C(=O)O",D:"N[C@@H](CC(O)=O)C(=O)O",N:"N[C@@H](CC(N)=O)C(=O)O",F:"NC(CC1=CC=CC=C1)C(=O)O",A:"N[C@H](C)C(=O)O",K:"NC(CCCCN)C(=O)O",R:"N[C@H](CCCNC(=N)C)C(=O)O",H:"NC(CC1=CN=C[N]1)C(=O)O",C:"N[C@@H](CS)C(=O)O",V:"NC(C(C)C)C(=O)O",P:"N(CCC1)C1C(=O)O",W:"N[C@@H](Cc1c2ccccc2n([H])c1)C(=O)O",I:"N[C@H]([C@H](C)CC)C(=O)O",M:"NC(CCSC)C(=O)O",T:"NC(C(O)C)C(=O)O"},r.AASmilesTruncated={G:"*C*",L:"CC(C)C[C@H](*)*",Y:"C1=CC(=CC=C1CC(*)*)O",S:"OCC(*)C*",E:"*[C@@H](CCC(O)=O)*",Q:"*N[C@@H](CCC(N)=O)*",D:"*[C@@H](CC(O)=O)*",N:"*[C@@H](CC(N)=O)*",F:"C1=CC=C(C=C1)CC(*)*",A:"C[C@H](*)*",K:"C(CCN)CC(*)*",R:"*[C@H](CCCNC(=N)C)*",H:"C1=C(NC=N1)CC(*)*",C:"C([C@@H](*)*)S",V:"CC(C)C(*)*",P:"C1CCN(*)C1*",W:"*[C@@H](Cc1c2ccccc2n([H])c1)*",I:"CC[C@H](C)[C@H](*)*",M:"CSCCC(*)*",T:"CC(O)C(*)*"},r.AAFullNames={Ala:"A",Arg:"R",Asn:"N",Asp:"D",Cys:"C",Gln:"Q",Glu:"E",Gly:"G",His:"H",Ile:"I",Leu:"L",Lys:"K",Met:"M",Phe:"F",Pro:"P",Ser:"S",Thr:"T",Trp:"W",Tyr:"Y",Val:"V"}},9029:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.or=t.and=t.not=t.CodeGen=t.operators=t.varKinds=t.ValueScopeName=t.ValueScope=t.Scope=t.Name=t.regexpCode=t.stringify=t.getProperty=t.nil=t.strConcat=t.str=t._=void 0;const i=n(1520),o=n(7845);var r=n(1520);Object.defineProperty(t,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(t,"strConcat",{enumerable:!0,get:function(){return r.strConcat}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(t,"getProperty",{enumerable:!0,get:function(){return r.getProperty}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(t,"regexpCode",{enumerable:!0,get:function(){return r.regexpCode}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return r.Name}});var s=n(7845);Object.defineProperty(t,"Scope",{enumerable:!0,get:function(){return s.Scope}}),Object.defineProperty(t,"ValueScope",{enumerable:!0,get:function(){return s.ValueScope}}),Object.defineProperty(t,"ValueScopeName",{enumerable:!0,get:function(){return s.ValueScopeName}}),Object.defineProperty(t,"varKinds",{enumerable:!0,get:function(){return s.varKinds}}),t.operators={GT:new i._Code(">"),GTE:new i._Code(">="),LT:new i._Code("<"),LTE:new i._Code("<="),EQ:new i._Code("==="),NEQ:new i._Code("!=="),NOT:new i._Code("!"),OR:new i._Code("||"),AND:new i._Code("&&"),ADD:new i._Code("+")};class a{optimizeNodes(){return this}optimizeNames(e,t){return this}}class l extends a{constructor(e,t,n){super(),this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){const n=e?o.varKinds.var:this.varKind,i=void 0===this.rhs?"":` = ${this.rhs}`;return`${n} ${this.name}${i};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&(this.rhs=N(this.rhs,e,t)),this}get names(){return this.rhs instanceof i._CodeOrName?this.rhs.names:{}}}class c extends a{constructor(e,t,n){super(),this.lhs=e,this.rhs=t,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,t){if(!(this.lhs instanceof i.Name)||e[this.lhs.str]||this.sideEffects)return this.rhs=N(this.rhs,e,t),this}get names(){return L(this.lhs instanceof i.Name?{}:{...this.lhs.names},this.rhs)}}class h extends c{constructor(e,t,n,i){super(e,n,i),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}}class u extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}}class d extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}}class p extends a{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}}class m extends a{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=N(this.code,e,t),this}get names(){return this.code instanceof i._CodeOrName?this.code.names:{}}}class g extends a{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,n)=>t+n.render(e),"")}optimizeNodes(){const{nodes:e}=this;let t=e.length;for(;t--;){const n=e[t].optimizeNodes();Array.isArray(n)?e.splice(t,1,...n):n?e[t]=n:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){const{nodes:n}=this;let i=n.length;for(;i--;){const o=n[i];o.optimizeNames(e,t)||(P(e,o.names),n.splice(i,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>I(e,t.names),{})}}class f extends g{render(e){return"{"+e._n+super.render(e)+"}"+e._n}}class y extends g{}class b extends f{}b.kind="else";class v extends f{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+="else "+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();const e=this.condition;if(!0===e)return this.nodes;let t=this.else;if(t){const e=t.optimizeNodes();t=this.else=Array.isArray(e)?new b(e):e}return t?!1===e?t instanceof v?t:t.nodes:this.nodes.length?this:new v(R(e),t instanceof v?[t]:t.nodes):!1!==e&&this.nodes.length?this:void 0}optimizeNames(e,t){var n;if(this.else=null===(n=this.else)||void 0===n?void 0:n.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=N(this.condition,e,t),this}get names(){const e=super.names;return L(e,this.condition),this.else&&I(e,this.else.names),e}}v.kind="if";class w extends f{}w.kind="for";class C extends w{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=N(this.iteration,e,t),this}get names(){return I(super.names,this.iteration.names)}}class S extends w{constructor(e,t,n,i){super(),this.varKind=e,this.name=t,this.from=n,this.to=i}render(e){const t=e.es5?o.varKinds.var:this.varKind,{name:n,from:i,to:r}=this;return`for(${t} ${n}=${i}; ${n}<${r}; ${n}++)`+super.render(e)}get names(){const e=L(super.names,this.from);return L(e,this.to)}}class A extends w{constructor(e,t,n,i){super(),this.loop=e,this.varKind=t,this.name=n,this.iterable=i}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=N(this.iterable,e,t),this}get names(){return I(super.names,this.iterable.names)}}class x extends f{constructor(e,t,n){super(),this.name=e,this.args=t,this.async=n}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}}x.kind="func";class E extends g{render(e){return"return "+super.render(e)}}E.kind="return";class M extends f{render(e){let t="try"+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),null===(e=this.catch)||void 0===e||e.optimizeNodes(),null===(t=this.finally)||void 0===t||t.optimizeNodes(),this}optimizeNames(e,t){var n,i;return super.optimizeNames(e,t),null===(n=this.catch)||void 0===n||n.optimizeNames(e,t),null===(i=this.finally)||void 0===i||i.optimizeNames(e,t),this}get names(){const e=super.names;return this.catch&&I(e,this.catch.names),this.finally&&I(e,this.finally.names),e}}class T extends f{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}}T.kind="catch";class _ extends f{render(e){return"finally"+super.render(e)}}function I(e,t){for(const n in t)e[n]=(e[n]||0)+(t[n]||0);return e}function L(e,t){return t instanceof i._CodeOrName?I(e,t.names):e}function N(e,t,n){return e instanceof i.Name?r(e):(o=e)instanceof i._Code&&o._items.some(e=>e instanceof i.Name&&1===t[e.str]&&void 0!==n[e.str])?new i._Code(e._items.reduce((e,t)=>(t instanceof i.Name&&(t=r(t)),t instanceof i._Code?e.push(...t._items):e.push(t),e),[])):e;var o;function r(e){const i=n[e.str];return void 0===i||1!==t[e.str]?e:(delete t[e.str],i)}}function P(e,t){for(const n in t)e[n]=(e[n]||0)-(t[n]||0)}function R(e){return"boolean"==typeof e||"number"==typeof e||null===e?!e:i._`!${H(e)}`}_.kind="finally",t.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?"\n":""},this._extScope=e,this._scope=new o.Scope({parent:e}),this._nodes=[new y]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){const n=this._extScope.value(e,t);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,n,i){const o=this._scope.toName(t);return void 0!==n&&i&&(this._constants[o.str]=n),this._leafNode(new l(e,o,n)),o}const(e,t,n){return this._def(o.varKinds.const,e,t,n)}let(e,t,n){return this._def(o.varKinds.let,e,t,n)}var(e,t,n){return this._def(o.varKinds.var,e,t,n)}assign(e,t,n){return this._leafNode(new c(e,t,n))}add(e,n){return this._leafNode(new h(e,t.operators.ADD,n))}code(e){return"function"==typeof e?e():e!==i.nil&&this._leafNode(new m(e)),this}object(...e){const t=["{"];for(const[n,o]of e)t.length>1&&t.push(","),t.push(n),(n!==o||this.opts.es5)&&(t.push(":"),(0,i.addCodeArg)(t,o));return t.push("}"),new i._Code(t)}if(e,t,n){if(this._blockNode(new v(e)),t&&n)this.code(t).else().code(n).endIf();else if(t)this.code(t).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new v(e))}else(){return this._elseNode(new b)}endIf(){return this._endBlockNode(v,b)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new C(e),t)}forRange(e,t,n,i,r=(this.opts.es5?o.varKinds.var:o.varKinds.let)){const s=this._scope.toName(e);return this._for(new S(r,s,t,n),()=>i(s))}forOf(e,t,n,r=o.varKinds.const){const s=this._scope.toName(e);if(this.opts.es5){const e=t instanceof i.Name?t:this.var("_arr",t);return this.forRange("_i",0,i._`${e}.length`,t=>{this.var(s,i._`${e}[${t}]`),n(s)})}return this._for(new A("of",r,s,t),()=>n(s))}forIn(e,t,n,r=(this.opts.es5?o.varKinds.var:o.varKinds.const)){if(this.opts.ownProperties)return this.forOf(e,i._`Object.keys(${t})`,n);const s=this._scope.toName(e);return this._for(new A("in",r,s,t),()=>n(s))}endFor(){return this._endBlockNode(w)}label(e){return this._leafNode(new u(e))}break(e){return this._leafNode(new d(e))}return(e){const t=new E;if(this._blockNode(t),this.code(e),1!==t.nodes.length)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(E)}try(e,t,n){if(!t&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');const i=new M;if(this._blockNode(i),this.code(e),t){const e=this.name("e");this._currNode=i.catch=new T(e),t(e)}return n&&(this._currNode=i.finally=new _,this.code(n)),this._endBlockNode(T,_)}throw(e){return this._leafNode(new p(e))}block(e,t){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(t),this}endBlock(e){const t=this._blockStarts.pop();if(void 0===t)throw new Error("CodeGen: not in self-balancing block");const n=this._nodes.length-t;if(n<0||void 0!==e&&n!==e)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=t,this}func(e,t=i.nil,n,o){return this._blockNode(new x(e,t,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(x)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,t){const n=this._currNode;if(n instanceof e||t&&n instanceof t)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){const t=this._currNode;if(!(t instanceof v))throw new Error('CodeGen: "else" without "if"');return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){const e=this._nodes;return e[e.length-1]}set _currNode(e){const t=this._nodes;t[t.length-1]=e}},t.not=R;const $=k(t.operators.AND);t.and=function(...e){return e.reduce($)};const O=k(t.operators.OR);function k(e){return(t,n)=>t===i.nil?n:n===i.nil?t:i._`${H(t)} ${e} ${H(n)}`}function H(e){return e instanceof i.Name?e:i._`(${e})`}t.or=function(...e){return e.reduce(O)}},9039:(e,t,n)=>{"use strict";var i;n.d(t,{c:()=>i}),function(e){e.UMAP="UMAP",e.T_SNE="t-SNE"}(i||(i={}))},9124:(e,t,n)=>{"use strict";n.d(t,{b2:()=>r,fA:()=>s});var i=n(7389),o=n(6082);async function r(){const e="Helm",t=o.Func.find({package:e,name:"getHelmHelper"});if(0===t.length)throw new Error(`Package '${e}' must be installed for HelmHelper.`);return(await t[0].prepare().call()).getOutputParamValue()}function s(e,t){if(!e)throw new Error("Argument 'a' of type Atom or HelmType is mandatory.");let n,i;const o=e;return"ATOM"===o.T?(n=o.biotype(),i=o.elem):(n=e,i=t),[n,i]}o.JsInputBase,Error,i.input.helmAsync=async function(e,t){return(await r()).createHelmInput(e,t)}},9192:(e,t,n)=>{"use strict";function i(e){return"string"==typeof e||e instanceof String?e:"StateError"===e.constructor.name?e.message:"StateError"===e.constructor.name&&"$thrownJsError"in e?i(e.$thrownJsError):e instanceof Error?e.message:e.toString()}function o(e){return e instanceof Error?e.stack:"StateError"===e.constructor.name&&"$thrownJsError"in e?o(e.$thrownJsError):void 0}function r(e){return[i(e),o(e)]}n.d(t,{AP:()=>r})},9235:(e,t,n)=>{"use strict";n.d(t,{H:()=>c,R:()=>l});var i=n(6082),o=n(1991),r=n.n(o),s=n(330),a=n(3599);async function l(e,t,o,l,c,h,u){const d=e.length,p=e.dataFrame,m=Math.max(navigator.hardwareConcurrency-2,1),g=new Array(m).fill(null).map(()=>new Worker(new URL(n.p+n.u(455),n.b))),f=d/m,y=new Array(m),b=h.getSeqHandler(e),v="RNA"==l?a.o.NUCLEOTIDE:a.o.AA,w=r().count(0).take(e.length).map(e=>{const t=b.getSplitted(e);return r().count(0).take(t.length).map(e=>({position:e,symbol:t.getCanonical(e),biotype:v})).toArray()}).toArray();for(let e=0;e<m;e++){const n=g[e],i=Math.floor(e*f),r=e===m-1?d:Math.floor((e+1)*f);y[e]=new Promise(e=>{n.onmessage=t=>{e(t.data)}}),n.postMessage({seqList:w,monomersDict:t,alphabet:o,polymerType:l,start:i,end:r})}const C=[],S=[];await Promise.all(y).then(e=>{for(const t of e)C.push(...t.molfiles),S.push(...t.warnings)}),setTimeout(()=>{g.forEach(e=>{e.terminate()})},0);const A=(0,s.qj)(p,e.name),x=i.Column.fromType(i.COLUMN_TYPE.STRING,A,e.length).init(e=>C[e]?.molfile);return x.semType=i.SEMTYPE.MOLECULE,x.meta.units=i.UNITS.Molecule.MOLBLOCK,x.setTag(".sequence-src-col",e.name),{molCol:x,warnings:S}}function c(e,t){const n={},o={};for(const r of e){const e=t.getWebEditorMonomer(r.biotype,r.symbol).backgroundcolor,a=(0,s.vG)(e??i.Color.toRgb(i.Color.mouseOverRows))??[1,0,0,.7];for(const e of r.atoms)n[e]=a;for(const e of r.bonds)o[e]=a}return{atoms:Object.keys(n).map(e=>parseInt(e)),bonds:Object.keys(o).map(e=>parseInt(e)),highlightAtomColors:n,highlightBondColors:o}}},9336:(e,t,n)=>{"use strict";var i=n(2787),o=n(944),r=n(6295),s=n(6863),a=n(8498);const l={[a.Pn.Euclidean]:r.jL,[a.Pn.Manhattan]:r.Hf,[a.Pn.Cosine]:r.w_},c={[a.xL.Levenshtein]:i.I,[a.xL.JaroWinkler]:o.Vb,[a.xL.Manhattan]:function(e,t){if(e.length!==t.length)return 1;{let n=0;for(let i=1;i<e.length;i++)n+=e[i]==t[i]?0:1;return n/e.length}},[a.xL.Onehot]:function(e,t){return e===t?0:1}},h={[a.aT.Tanimoto]:r.tO,[a.aT.Dice]:r.zn,[a.aT.Asymmetric]:r.gt,[a.aT.BraunBlanquet]:r.ij,[a.aT.Cosine]:r.lO,[a.aT.Kulczynski]:r.rR,[a.aT.McConnaughey]:r.lP,[a.aT.RogotGoldberg]:r.TK,[a.aT.Russel]:r.yK,[a.aT.Sokal]:r.Ii,[a.aT.Hamming]:r.be,[a.aT.Euclidean]:r.Qj},u={[a.m6.TanimotoIntArray]:r.v_},d={[a.RR.Difference]:r.T6},p={[a.Wn.CommonItems]:r.Hr},m={[a.EG.Vector]:{[a.Pn.Euclidean]:l[a.Pn.Euclidean],[a.Pn.Manhattan]:l[a.Pn.Manhattan],[a.Pn.Cosine]:l[a.Pn.Cosine]},[a.EG.String]:{[a.xL.Levenshtein]:c[a.xL.Levenshtein],[a.xL.JaroWinkler]:c[a.xL.JaroWinkler],[a.xL.Manhattan]:c[a.xL.Manhattan],[a.xL.Onehot]:c[a.xL.Onehot]},[a.EG.BitArray]:{[a.aT.Tanimoto]:h[a.aT.Tanimoto],[a.aT.Dice]:h[a.aT.Dice],[a.aT.Asymmetric]:h[a.aT.Asymmetric],[a.aT.BraunBlanquet]:h[a.aT.BraunBlanquet],[a.aT.Cosine]:h[a.aT.Cosine],[a.aT.Kulczynski]:h[a.aT.Kulczynski],[a.aT.McConnaughey]:h[a.aT.McConnaughey],[a.aT.RogotGoldberg]:h[a.aT.RogotGoldberg],[a.aT.Russel]:h[a.aT.Russel],[a.aT.Sokal]:h[a.aT.Sokal]},[a.EG.MacroMolecule]:{[s.Z.HAMMING]:s.V[s.Z.HAMMING],[s.Z.LEVENSHTEIN]:s.V[s.Z.LEVENSHTEIN],[s.Z.NEEDLEMANN_WUNSCH]:s.V[s.Z.NEEDLEMANN_WUNSCH],[s.Z.MONOMER_CHEMICAL_DISTANCE]:s.V[s.Z.MONOMER_CHEMICAL_DISTANCE]},[a.EG.Number]:{[a.RR.Difference]:d[a.RR.Difference]},[a.EG.IntArray]:{[a.m6.TanimotoIntArray]:u[a.m6.TanimotoIntArray]},[a.EG.NumberArray]:{[a.Wn.CommonItems]:p[a.Wn.CommonItems]}};Object.keys(m).reduce((e,t)=>{for(const n of Object.keys(m[t]))e[n]=t;return e},{})},9547:e=>{"use strict";e.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/meta/unevaluated","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/unevaluated":true},"$dynamicAnchor":"meta","title":"Unevaluated applicator vocabulary meta-schema","type":["object","boolean"],"properties":{"unevaluatedItems":{"$dynamicRef":"#meta"},"unevaluatedProperties":{"$dynamicRef":"#meta"}}}')},9572:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(1678),o=n(7216),r=n(9547),s=n(8226),a=n(518),l=n(4588),c=n(5707),h=n(7082),u=["/properties"];t.default=function(e){return[i,o,r,s,a,t(this,l),c,t(this,h)].forEach(e=>this.addMetaSchema(e,void 0,!1)),this;function t(t,n){return e?t.$dataMetaSchema(n,u):n}}},9713:e=>{"use strict";e.exports=rxjs.operators},9857:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.contentVocabulary=t.metadataVocabulary=void 0,t.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"],t.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]},9937:e=>{e.exports={linLogMode:!1,outboundAttractionDistribution:!1,adjustSizes:!1,edgeWeightInfluence:1,scalingRatio:1,strongGravityMode:!1,gravity:1,slowDown:1,barnesHutOptimize:!1,barnesHutTheta:.5}},9982:function(e,t,n){var i;!function(){var t={};!function(e){"use strict";e.__esModule=!0,e.digestLength=32,e.blockSize=64;var t=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function n(e,n,i,o,r){for(var s,a,l,c,h,u,d,p,m,g,f,y,b;r>=64;){for(s=n[0],a=n[1],l=n[2],c=n[3],h=n[4],u=n[5],d=n[6],p=n[7],g=0;g<16;g++)f=o+4*g,e[g]=(255&i[f])<<24|(255&i[f+1])<<16|(255&i[f+2])<<8|255&i[f+3];for(g=16;g<64;g++)y=((m=e[g-2])>>>17|m<<15)^(m>>>19|m<<13)^m>>>10,b=((m=e[g-15])>>>7|m<<25)^(m>>>18|m<<14)^m>>>3,e[g]=(y+e[g-7]|0)+(b+e[g-16]|0);for(g=0;g<64;g++)y=(((h>>>6|h<<26)^(h>>>11|h<<21)^(h>>>25|h<<7))+(h&u^~h&d)|0)+(p+(t[g]+e[g]|0)|0)|0,b=((s>>>2|s<<30)^(s>>>13|s<<19)^(s>>>22|s<<10))+(s&a^s&l^a&l)|0,p=d,d=u,u=h,h=c+y|0,c=l,l=a,a=s,s=y+b|0;n[0]+=s,n[1]+=a,n[2]+=l,n[3]+=c,n[4]+=h,n[5]+=u,n[6]+=d,n[7]+=p,o+=64,r-=64}return o}var i=function(){function t(){this.digestLength=e.digestLength,this.blockSize=e.blockSize,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this.reset()}return t.prototype.reset=function(){return this.state[0]=1779033703,this.state[1]=3144134277,this.state[2]=1013904242,this.state[3]=2773480762,this.state[4]=1359893119,this.state[5]=2600822924,this.state[6]=528734635,this.state[7]=1541459225,this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this},t.prototype.clean=function(){for(var e=0;e<this.buffer.length;e++)this.buffer[e]=0;for(e=0;e<this.temp.length;e++)this.temp[e]=0;this.reset()},t.prototype.update=function(e,t){if(void 0===t&&(t=e.length),this.finished)throw new Error("SHA256: can't update because hash was finished.");var i=0;if(this.bytesHashed+=t,this.bufferLength>0){for(;this.bufferLength<64&&t>0;)this.buffer[this.bufferLength++]=e[i++],t--;64===this.bufferLength&&(n(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(t>=64&&(i=n(this.temp,this.state,e,i,t),t%=64);t>0;)this.buffer[this.bufferLength++]=e[i++],t--;return this},t.prototype.finish=function(e){if(!this.finished){var t=this.bytesHashed,i=this.bufferLength,o=t/536870912|0,r=t<<3,s=t%64<56?64:128;this.buffer[i]=128;for(var a=i+1;a<s-8;a++)this.buffer[a]=0;this.buffer[s-8]=o>>>24&255,this.buffer[s-7]=o>>>16&255,this.buffer[s-6]=o>>>8&255,this.buffer[s-5]=o>>>0&255,this.buffer[s-4]=r>>>24&255,this.buffer[s-3]=r>>>16&255,this.buffer[s-2]=r>>>8&255,this.buffer[s-1]=r>>>0&255,n(this.temp,this.state,this.buffer,0,s),this.finished=!0}for(a=0;a<8;a++)e[4*a+0]=this.state[a]>>>24&255,e[4*a+1]=this.state[a]>>>16&255,e[4*a+2]=this.state[a]>>>8&255,e[4*a+3]=this.state[a]>>>0&255;return this},t.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},t.prototype._saveState=function(e){for(var t=0;t<this.state.length;t++)e[t]=this.state[t]},t.prototype._restoreState=function(e,t){for(var n=0;n<this.state.length;n++)this.state[n]=e[n];this.bytesHashed=t,this.finished=!1,this.bufferLength=0},t}();e.Hash=i;var o=function(){function e(e){this.inner=new i,this.outer=new i,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var t=new Uint8Array(this.blockSize);if(e.length>this.blockSize)(new i).update(e).finish(t).clean();else for(var n=0;n<e.length;n++)t[n]=e[n];for(n=0;n<t.length;n++)t[n]^=54;for(this.inner.update(t),n=0;n<t.length;n++)t[n]^=106;for(this.outer.update(t),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate),n=0;n<t.length;n++)t[n]=0}return e.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},e.prototype.clean=function(){for(var e=0;e<this.istate.length;e++)this.ostate[e]=this.istate[e]=0;this.inner.clean(),this.outer.clean()},e.prototype.update=function(e){return this.inner.update(e),this},e.prototype.finish=function(e){return this.outer.finished?this.outer.finish(e):(this.inner.finish(e),this.outer.update(e,this.digestLength).finish(e)),this},e.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},e}();function r(e){var t=(new i).update(e),n=t.digest();return t.clean(),n}function s(e,t){var n=new o(e).update(t),i=n.digest();return n.clean(),i}function a(e,t,n,i){var o=i[0];if(0===o)throw new Error("hkdf: cannot expand more");t.reset(),o>1&&t.update(e),n&&t.update(n),t.update(i),t.finish(e),i[0]++}e.HMAC=o,e.hash=r,e.default=r,e.hmac=s;var l=new Uint8Array(e.digestLength);e.hkdf=function(e,t,n,i){void 0===t&&(t=l),void 0===i&&(i=32);for(var r=new Uint8Array([1]),c=s(t,e),h=new o(c),u=new Uint8Array(h.digestLength),d=u.length,p=new Uint8Array(i),m=0;m<i;m++)d===u.length&&(a(u,h,n,r),d=0),p[m]=u[d++];return h.clean(),u.fill(0),r.fill(0),p},e.pbkdf2=function(e,t,n,i){for(var r=new o(e),s=r.digestLength,a=new Uint8Array(4),l=new Uint8Array(s),c=new Uint8Array(s),h=new Uint8Array(i),u=0;u*s<i;u++){var d=u+1;a[0]=d>>>24&255,a[1]=d>>>16&255,a[2]=d>>>8&255,a[3]=d>>>0&255,r.reset(),r.update(t),r.update(a),r.finish(c);for(var p=0;p<s;p++)l[p]=c[p];for(p=2;p<=n;p++){r.reset(),r.update(c).finish(c);for(var m=0;m<s;m++)l[m]^=c[m]}for(p=0;p<s&&u*s+p<i;p++)h[u*s+p]=l[p]}for(u=0;u<s;u++)l[u]=c[u]=0;for(u=0;u<4;u++)a[u]=0;return r.clean(),h}}(t);var o=t.default;for(var r in t)o[r]=t[r];"object"==typeof e.exports?e.exports=o:void 0===(i=function(){return o}.call(t,n,t,e))||(e.exports=i)}()}},t={};function n(i){var o=t[i];if(void 0!==o)return o.exports;var r=t[i]={id:i,loaded:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.loaded=!0,r.exports}n.m=e,n.amdO={},n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.u=e=>e+".js",n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.hmd=e=>((e=Object.create(e)).children||(e.children=[]),Object.defineProperty(e,"exports",{enumerable:!0,set:()=>{throw new Error("ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: "+e.id)}}),e),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;n.g.importScripts&&(e=n.g.location+"");var t=n.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var i=t.getElementsByTagName("script");if(i.length)for(var o=i.length-1;o>-1&&(!e||!/^http(s?):/.test(e));)e=i[o--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=e})(),n.b=document.baseURI||self.location.href,n.nc=void 0;var i=n(2020);bio=i})();
|
|
7
|
+
deps: ${n}}`};const s={keyword:"dependencies",type:"object",schemaType:"object",error:t.error,code(e){const[t,n]=function({schema:e}){const t={},n={};for(const i in e)"__proto__"!==i&&((Array.isArray(e[i])?t:n)[i]=e[i]);return[t,n]}(e);a(e,t),l(e,n)}};function a(e,t=e.schema){const{gen:n,data:o,it:s}=e;if(0===Object.keys(t).length)return;const a=n.let("missing");for(const l in t){const c=t[l];if(0===c.length)continue;const u=(0,r.propertyInData)(n,o,l,s.opts.ownProperties);e.setParams({property:l,depsCount:c.length,deps:c.join(", ")}),s.allErrors?n.if(u,()=>{for(const t of c)(0,r.checkReportMissingProp)(e,t)}):(n.if(i._`${u} && (${(0,r.checkMissingProp)(e,c,a)})`),(0,r.reportMissingProp)(e,a),n.else())}}function l(e,t=e.schema){const{gen:n,data:i,keyword:s,it:a}=e,l=n.name("valid");for(const c in t)(0,o.alwaysValidSchema)(a,t[c])||(n.if((0,r.propertyInData)(n,i,c,a.opts.ownProperties),()=>{const t=e.subschema({keyword:s,schemaProp:c},l);e.mergeValidEvaluated(t,l)},()=>n.var(l,!0)),e.ok(l))}t.validatePropertyDeps=a,t.validateSchemaDeps=l,t.default=s},3151:(e,t,n)=>{"use strict";n.d(t,{EK:()=>l,Ec:()=>r,f6:()=>i,pe:()=>s,q7:()=>a,yw:()=>o});const i=["symbol","molfile","rgroups","name"],o="MonomerName",r={monomerType:null,smiles:null,name:"Name",author:null,molfile:"molecule",naturalAnalog:"MonomerNaturalAnalogCode",rgroups:"MonomerCaps",createDate:null,id:null,polymerType:"MonomerType",symbol:"MonomerName"},s={monomerType:"Backbone",smiles:"",name:"",author:"Datagrok",molfile:"",naturalAnalog:"",rgroups:[],createDate:null,id:0,polymerType:"PEPTIDE",symbol:""},a="p",l=new RegExp(`[rd]\\((\\w)\\)${a}?`,"g")},3252:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dynamicRef=void 0;const i=n(9029),o=n(2023),r=n(3693),s={keyword:"$dynamicRef",schemaType:"string",code:e=>a(e,e.schema)};function a(e,t){const{gen:n,keyword:s,it:a}=e;if("#"!==t[0])throw new Error(`"${s}" only supports hash fragment reference`);const l=t.slice(1);if(a.allErrors)c();else{const t=n.let("valid",!1);c(t),e.ok(t)}function c(e){if(a.schemaEnv.root.dynamicAnchors[l]){const t=n.let("_v",i._`${o.default.dynamicAnchors}${(0,i.getProperty)(l)}`);n.if(t,u(t,e),u(a.validateName,e))}else u(a.validateName,e)()}function u(t,i){return i?()=>n.block(()=>{(0,r.callRef)(e,t),n.let(i,!0)}):()=>(0,r.callRef)(e,t)}}t.dynamicRef=a,t.default=s},3265:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(392),o=n(3445),r=[i.default,o.default];t.default=r},3282:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MissingRefError=t.ValidationError=t.CodeGen=t.Name=t.nil=t.stringify=t.str=t._=t.KeywordCxt=t.Ajv=void 0;const i=n(4042),o=n(6144),r=n(6653),s=n(2079),a=["/properties"],l="http://json-schema.org/draft-07/schema";class c extends i.default{_addVocabularies(){super._addVocabularies(),o.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(r.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const e=this.opts.$data?this.$dataMetaSchema(s,a):s;this.addMetaSchema(e,l,!1),this.refs["http://json-schema.org/schema"]=l}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(l)?l:void 0)}}t.Ajv=c,e.exports=t=c,e.exports.Ajv=c,Object.defineProperty(t,"__esModule",{value:!0}),t.default=c;var u=n(2586);Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return u.KeywordCxt}});var h=n(9029);Object.defineProperty(t,"_",{enumerable:!0,get:function(){return h._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return h.str}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return h.stringify}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return h.nil}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return h.Name}}),Object.defineProperty(t,"CodeGen",{enumerable:!0,get:function(){return h.CodeGen}});var d=n(3558);Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return d.default}});var p=n(4551);Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return p.default}})},3439:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:{message:({schemaCode:e})=>i.str`must be multiple of ${e}`,params:({schemaCode:e})=>i._`{multipleOf: ${e}}`},code(e){const{gen:t,data:n,schemaCode:o,it:r}=e,s=r.opts.multipleOfPrecision,a=t.let("res"),l=s?i._`Math.abs(Math.round(${a}) - ${a}) > 1e-${s}`:i._`${a} !== parseInt(${a})`;e.fail$data(i._`(${o} === 0 || (${a} = ${n}/${o}, ${l}))`)}};t.default=o},3445:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o=n(4227),r={keyword:"unevaluatedItems",type:"array",schemaType:["boolean","object"],error:{message:({params:{len:e}})=>i.str`must NOT have more than ${e} items`,params:({params:{len:e}})=>i._`{limit: ${e}}`},code(e){const{gen:t,schema:n,data:r,it:s}=e,a=s.items||0;if(!0===a)return;const l=t.const("len",i._`${r}.length`);if(!1===n)e.setParams({len:a}),e.fail(i._`${l} > ${a}`);else if("object"==typeof n&&!(0,o.alwaysValidSchema)(s,n)){const n=t.var("valid",i._`${l} <= ${a}`);t.if((0,i.not)(n),()=>function(n,r){t.forRange("i",r,l,r=>{e.subschema({keyword:"unevaluatedItems",dataProp:r,dataPropType:o.Type.Num},n),s.allErrors||t.if((0,i.not)(n),()=>t.break())})}(n,a)),e.ok(n)}s.items=!0}};t.default=r},3463:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};t.default=n},3516:(e,t,n)=>{"use strict";n.d(t,{m:()=>r});var i=n(6082),o=n(439);class r{get descriptionsArray(){return this._descriptionsArray}get sequencesArray(){return this._sequencesArray}parseMacromolecule(e,t){return this._fileContent.slice(e,t).split(/\s/).join("")}parseColumns(){const e=/^>(.*)$/gm;let t,n=0;for(;t=e.exec(this._fileContent);){const i=this._fileContent.substring(t.index+1,e.lastIndex);this._descriptionsArray.push(i),0!==n&&this._sequencesArray.push(this.parseMacromolecule(n,t.index)),n=e.lastIndex+1}this._sequencesArray.push(this.parseMacromolecule(n,-1))}importFasta(){const e=i.Column.fromStrings("description",this.descriptionsArray),t=i.Column.fromStrings("sequence",this.sequencesArray);return t.semType=i.SEMTYPE.MACROMOLECULE,t.meta.units=o.Hi.FASTA,[i.DataFrame.fromColumns([e,t])]}constructor(e){this._descriptionsArray=[],this._sequencesArray=[],this._fileContent=e,this.parseColumns()}}},3527:(e,t,n)=>{"use strict";n.d(t,{Mi:()=>i});class i extends Float32Array{}},3558:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});class n extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}}t.default=n},3561:(e,t,n)=>{"use strict";n.d(t,{Hb:()=>l,YN:()=>f,gU:()=>c});var i=n(8123),o=n(294),r=n(3151),s=n(439),a=n(6197);function l(e,t,n){const o=new Map;for(const a of e.getMonomerSymbolsByType(t)){const l=e.getMonomer(t,a);if("RNA"===t&&("Branch"===l.monomerType||n===s.YI.DNA&&l.symbol===i.u.DEOXYRIBOSE.symbol||n===s.YI.RNA&&l.symbol===i.u.RIBOSE.symbol||l.symbol===i.u.PHOSPHATE.symbol)||"PEPTIDE"===t&&"Branch"!==l.monomerType){const e={};r.f6.forEach(t=>{e[t]=l[t]}),o.set(a,e)}}return o}function c(e,t,n,r){if(0===e.length)return o.vF.createEmpty();const l=m,{atomCount:c,bondCount:h,needsCapping:p}=l(e,t,n,r),g=new Array(c),y=new Array(h);let b,v=null,w=null;"PEPTIDE"===r?b=u:(b=d,v=n===s.YI.DNA?(0,o.xb)(t,i.u.DEOXYRIBOSE):(0,o.xb)(t,i.u.RIBOSE),w=(0,o.xb)(t,i.u.PHOSPHATE));const C={i:0,nodeShift:0,bondShift:0,backbonePositionShift:new Array(2).fill(0),branchPositionShift:new Array(2).fill(0),backboneAttachNode:0,branchAttachNode:0,flipFactor:1},S={sugar:v,phosphate:w,seqLength:e.length,atomCount:c,bondCount:h},A=new o.Cg,x=[];let M,T=0;for(C.i=0;C.i<S.seqLength;++C.i){const n=e[C.i];if(n.symbol===s._S)continue;const i=(0,o.xb)(t,{symbol:n.symbol,polymerType:(0,a.Y)(n.biotype)});M=i.terminalR2Atom;const r=C.nodeShift,l=C.bondShift;b(i,g,y,C,S),i.stereoAtoms?.forEach(e=>x.push(e+T)),T+=i.atoms.x.length;const c=C.nodeShift-r,u=new Array(c);for(let e=0;e<c;++e)u[e]=r+e;const h=C.bondShift-l,d=new Array(h);for(let e=0;e<h;++e)d[e]=l+e;A.set(C.i,{biotype:n.biotype,symbol:n.symbol,atoms:u,bonds:d})}p&&function(e,t,n,o,r=i.u.OXYGEN){const s=n.nodeShift+1;e[o.atomCount]=i.u.V3K_BEGIN_DATA_LINE+s+" "+(r??i.u.OXYGEN)+" "+f(n.backbonePositionShift[0])+" "+n.flipFactor*f(n.backbonePositionShift[1])+" 0.000000 0\n";const a=n.backboneAttachNode,l=s;t[o.bondCount]=i.u.V3K_BEGIN_DATA_LINE+n.bondShift+" 1 "+a+" "+l+"\n"}(g,y,C,S,M??i.u.OXYGEN);const E=i.u.V3K_BEGIN_COUNTS_LINE+c+" "+h+i.u.V3K_COUNTS_LINE_ENDING;let _="";return _+=i.u.V3K_HEADER_FIRST_LINE,_+=i.u.V3K_HEADER_SECOND_LINE,_+=i.u.V3K_BEGIN_CTAB_BLOCK,_+=E,_+=i.u.V3K_BEGIN_ATOM_BLOCK,_+=g.join(""),_+=i.u.V3K_END_ATOM_BLOCK,_+=i.u.V3K_BEGIN_BOND_BLOCK,_+=y.join(""),_+=i.u.V3K_END_BOND_BLOCK,x.length>0&&(_+=function(e){const t=[];let n=`M V30 MDLV30/STEABS ATOMS=(${e.length}`;for(let i=0;i<e.length;i++){const o=`${n} ${e[i]}`;o.length>76?(t.push(`${n} -\n`),n=`M V30 ${e[i]}`):n=o,i===e.length-1&&t.push(`${n})\n`)}return`M V30 BEGIN COLLECTION\n${t.join("")}M V30 END COLLECTION\n`}(x)),_+=i.u.V3K_END_CTAB_BLOCK,_+=i.u.V3K_END,{molfile:_,monomers:A}}function u(e,t,n,i){i.flipFactor=(-1)**(i.i%2),h(e,t,n,i)}function h(e,t,n,o){!function(e,t,n){for(let o=0;o<e.atoms.atomTypes.length;++o){const r=n.nodeShift+o+1;t[n.nodeShift+o]=i.u.V3K_BEGIN_DATA_LINE+r+" "+e.atoms.atomTypes[o]+" "+f(n.backbonePositionShift[0]+e.atoms.x[o])+" "+f(n.backbonePositionShift[1]+n.flipFactor*e.atoms.y[o])+" "+e.atoms.kwargs[o]}}(e,t,o),p(e,n,o),function(e,t,n){if(0!==n.backboneAttachNode){const o=n.bondShift,r=n.backboneAttachNode,s=e.meta.terminalNodes[0]+n.nodeShift;t[n.bondShift-1]=i.u.V3K_BEGIN_DATA_LINE+o+" 1 "+r+" "+s+"\n"}}(e,n,o),null!==e.meta.branchShift&&e.meta.terminalNodes.length>2&&function(e,t){t.branchAttachNode=t.nodeShift+e.meta.terminalNodes[2];for(let n=0;n<2;++n)t.branchPositionShift[n]=t.backbonePositionShift[n]+e.meta.branchShift[n]}(e,o),function(e,t){t.backboneAttachNode=t.nodeShift+e.meta.terminalNodes[1],t.bondShift+=e.bonds.atomPairs.length+1,t.nodeShift+=e.atoms.atomTypes.length,t.backbonePositionShift[0]+=e.meta.backboneShift?.[0]??0,t.backbonePositionShift[1]+=t.flipFactor*(e.meta.backboneShift?.[1]??0)}(e,o)}function d(e,t,n,o,r){if(0===o.i)h(r.sugar,t,n,o);else for(const e of[r.phosphate,r.sugar])h(e,t,n,o);!function(e,t,n,o){(function(e,t,n){for(let o=0;o<e.atoms.atomTypes.length;++o){const r=n.nodeShift+o+1;t[n.nodeShift+o]=i.u.V3K_BEGIN_DATA_LINE+r+" "+e.atoms.atomTypes[o]+" "+f(n.branchPositionShift[0]+e.atoms.x[o])+" "+f(n.branchPositionShift[1]+n.flipFactor*e.atoms.y[o])+" "+e.atoms.kwargs[o]}})(e,t,o),p(e,n,o),function(e,t,n){const o=n.bondShift,r=n.branchAttachNode,s=e.meta.terminalNodes[0]+n.nodeShift;t[o-1]=i.u.V3K_BEGIN_DATA_LINE+o+" 1 "+r+" "+s+"\n"}(e,n,o);const r=o.bondShift,s=o.branchAttachNode,a=e.meta.terminalNodes[0]+o.nodeShift;n[r-1]=i.u.V3K_BEGIN_DATA_LINE+r+" 1 "+s+" "+a+"\n",o.bondShift+=e.bonds.atomPairs.length+1,o.nodeShift+=e.atoms.atomTypes.length}(e,t,n,o)}function p(e,t,n){for(let o=0;o<e.bonds.atomPairs.length;++o){const r=n.bondShift+o+1,s=e.bonds.atomPairs[o][0]+n.nodeShift,a=e.bonds.atomPairs[o][1]+n.nodeShift;let l="";if(e.bonds.bondConfiguration.has(o)){let t=e.bonds.bondConfiguration.get(o);n.flipFactor<0&&(t=1===t?3:1),l=" CFG="+t}const c=e.bonds.kwargs.has(o)?" "+e.bonds.kwargs.get(o):"";t[n.bondShift+o]=i.u.V3K_BEGIN_DATA_LINE+r+" "+e.bonds.bondTypes[o]+" "+s+" "+a+l+c+"\n"}}function m(e,t,n,r){let l=0,c=0,u=0,h=!0,d=null;for(const n of e)if(n.symbol!==s._S){if("*"==n.symbol)throw new Error("Gap canonical symbol is '', not '*");d=(0,o.xb)(t,{symbol:n.symbol,polymerType:(0,a.Y)(n.biotype)}),l+=d.atoms.x.length,c+=d.bonds.bondTypes.length,u++}if("PEPTIDE"===r)l+=1,c+=u,u>0&&((d?.meta?.rNodes?.length??0)<2||d?.terminalR2Atom?.toLowerCase()===i.u.HYDROGEN.toLowerCase())&&(h=!1,l-=1,c-=1);else{const r=n===s.YI.DNA?(0,o.xb)(t,i.u.DEOXYRIBOSE):(0,o.xb)(t,i.u.RIBOSE),a=(0,o.xb)(t,i.u.PHOSPHATE);l+=(e.length-1)*a.atoms.x.length,l+=e.length*r.atoms.x.length,l+=1,c+=(e.length-1)*a.bonds.bondTypes.length,c+=e.length*r.bonds.bondTypes.length,c-=1,c+=3*e.length}return{atomCount:l,bondCount:c,needsCapping:h}}function f(e){return Math.round(i.u.PRECISION_FACTOR*e)/i.u.PRECISION_FACTOR}},3599:(e,t,n)=>{"use strict";n.d(t,{o:()=>i.o});var i=n(6869)},3629:(e,t,n)=>{"use strict";n.d(t,{KE:()=>a,S8:()=>l,dC:()=>r,vA:()=>o,wQ:()=>s});var i=n(3527);function o(e=!1,t="Assertion error."){if(!e)throw new Error(t)}function r(e,t,n=1){const r=e.length;o(r==t.length,"Vector lengths do not match.");const s=new i.Mi(r);for(let i=0;i<e.length;++i)s[i]=e[i]+n*t[i];return s}function s(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n]*e[n];return Math.sqrt(t)}function a(e,t){if(e.length!=t.length)throw new Error("The dimensionality of the vectors must match");let n=0;for(let i=0;i<e.length;i++)n+=e[i]*t[i];return n}function l(e){const t=e.length;let n=0,i=0;for(let o=0;o<t;++o)n+=e[o],i+=Math.pow(e[o],2);const o=n/t,r=1/Math.sqrt(i/t-Math.pow(o,2));for(let n=0;n<t;++n)e[n]=(e[n]-o)*r;return e}},3673:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validateKeywordUsage=t.validSchemaType=t.funcKeywordCode=t.macroKeywordCode=void 0;const i=n(9029),o=n(2023),r=n(5765),s=n(8708);function a(e){const{gen:t,data:n,it:o}=e;t.if(o.parentData,()=>t.assign(n,i._`${o.parentData}[${o.parentDataProperty}]`))}function l(e,t,n){if(void 0===n)throw new Error(`keyword "${t}" failed to compile`);return e.scopeValue("keyword","function"==typeof n?{ref:n}:{ref:n,code:(0,i.stringify)(n)})}t.macroKeywordCode=function(e,t){const{gen:n,keyword:o,schema:r,parentSchema:s,it:a}=e,c=t.macro.call(a.self,r,s,a),u=l(n,o,c);!1!==a.opts.validateSchema&&a.self.validateSchema(c,!0);const h=n.name("valid");e.subschema({schema:c,schemaPath:i.nil,errSchemaPath:`${a.errSchemaPath}/${o}`,topSchemaRef:u,compositeRule:!0},h),e.pass(h,()=>e.error(!0))},t.funcKeywordCode=function(e,t){var n;const{gen:c,keyword:u,schema:h,parentSchema:d,$data:p,it:m}=e;!function({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}(m,t);const f=!p&&t.compile?t.compile.call(m.self,h,d,m):t.validate,g=l(c,u,f),y=c.let("valid");function b(n=(t.async?i._`await `:i.nil)){const s=m.opts.passContext?o.default.this:o.default.self,a=!("compile"in t&&!p||!1===t.schema);c.assign(y,i._`${n}${(0,r.callValidateCode)(e,g,s,a)}`,t.modifying)}function v(e){var n;c.if((0,i.not)(null!==(n=t.valid)&&void 0!==n?n:y),e)}e.block$data(y,function(){if(!1===t.errors)b(),t.modifying&&a(e),v(()=>e.error());else{const n=t.async?function(){const e=c.let("ruleErrs",null);return c.try(()=>b(i._`await `),t=>c.assign(y,!1).if(i._`${t} instanceof ${m.ValidationError}`,()=>c.assign(e,i._`${t}.errors`),()=>c.throw(t))),e}():function(){const e=i._`${g}.errors`;return c.assign(e,null),b(i.nil),e}();t.modifying&&a(e),v(()=>function(e,t){const{gen:n}=e;n.if(i._`Array.isArray(${t})`,()=>{n.assign(o.default.vErrors,i._`${o.default.vErrors} === null ? ${t} : ${o.default.vErrors}.concat(${t})`).assign(o.default.errors,i._`${o.default.vErrors}.length`),(0,s.extendErrors)(e)},()=>e.error())}(e,n))}}),e.ok(null!==(n=t.valid)&&void 0!==n?n:y)},t.validSchemaType=function(e,t,n=!1){return!t.length||t.some(t=>"array"===t?Array.isArray(e):"object"===t?e&&"object"==typeof e&&!Array.isArray(e):typeof e==t||n&&void 0===e)},t.validateKeywordUsage=function({schema:e,opts:t,self:n,errSchemaPath:i},o,r){if(Array.isArray(o.keyword)?!o.keyword.includes(r):o.keyword!==r)throw new Error("ajv implementation error");const s=o.dependencies;if(null==s?void 0:s.some(t=>!Object.prototype.hasOwnProperty.call(e,t)))throw new Error(`parent schema must have dependencies of ${r}: ${s.join(",")}`);if(o.validateSchema&&!o.validateSchema(e[r])){const e=`keyword "${r}" value is invalid at path "${i}": `+n.errorsText(o.validateSchema.errors);if("log"!==t.validateSchema)throw new Error(e);n.logger.error(e)}}},3693:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.callRef=t.getValidate=void 0;const i=n(4551),o=n(5765),r=n(9029),s=n(2023),a=n(3835),l=n(4227),c={keyword:"$ref",schemaType:"string",code(e){const{gen:t,schema:n,it:o}=e,{baseId:s,schemaEnv:l,validateName:c,opts:d,self:p}=o,{root:m}=l;if(("#"===n||"#/"===n)&&s===m.baseId)return function(){if(l===m)return h(e,c,l,l.$async);const n=t.scopeValue("root",{ref:m});return h(e,r._`${n}.validate`,m,m.$async)}();const f=a.resolveRef.call(p,m,s,n);if(void 0===f)throw new i.default(o.opts.uriResolver,s,n);return f instanceof a.SchemaEnv?function(t){const n=u(e,t);h(e,n,t,t.$async)}(f):function(i){const o=t.scopeValue("schema",!0===d.code.source?{ref:i,code:(0,r.stringify)(i)}:{ref:i}),s=t.name("valid"),a=e.subschema({schema:i,dataTypes:[],schemaPath:r.nil,topSchemaRef:o,errSchemaPath:n},s);e.mergeEvaluated(a),e.ok(s)}(f)}};function u(e,t){const{gen:n}=e;return t.validate?n.scopeValue("validate",{ref:t.validate}):r._`${n.scopeValue("wrapper",{ref:t})}.validate`}function h(e,t,n,i){const{gen:a,it:c}=e,{allErrors:u,schemaEnv:h,opts:d}=c,p=d.passContext?s.default.this:r.nil;function m(e){const t=r._`${e}.errors`;a.assign(s.default.vErrors,r._`${s.default.vErrors} === null ? ${t} : ${s.default.vErrors}.concat(${t})`),a.assign(s.default.errors,r._`${s.default.vErrors}.length`)}function f(e){var t;if(!c.opts.unevaluated)return;const i=null===(t=null==n?void 0:n.validate)||void 0===t?void 0:t.evaluated;if(!0!==c.props)if(i&&!i.dynamicProps)void 0!==i.props&&(c.props=l.mergeEvaluated.props(a,i.props,c.props));else{const t=a.var("props",r._`${e}.evaluated.props`);c.props=l.mergeEvaluated.props(a,t,c.props,r.Name)}if(!0!==c.items)if(i&&!i.dynamicItems)void 0!==i.items&&(c.items=l.mergeEvaluated.items(a,i.items,c.items));else{const t=a.var("items",r._`${e}.evaluated.items`);c.items=l.mergeEvaluated.items(a,t,c.items,r.Name)}}i?function(){if(!h.$async)throw new Error("async schema referenced by sync schema");const n=a.let("valid");a.try(()=>{a.code(r._`await ${(0,o.callValidateCode)(e,t,p)}`),f(t),u||a.assign(n,!0)},e=>{a.if(r._`!(${e} instanceof ${c.ValidationError})`,()=>a.throw(e)),m(e),u||a.assign(n,!1)}),e.ok(n)}():e.result((0,o.callValidateCode)(e,t,p),()=>f(t),()=>m(t))}t.getValidate=u,t.callRef=h,t.default=c},3799:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(3252),o={keyword:"$recursiveRef",schemaType:"string",code:e=>(0,i.dynamicRef)(e,e.schema)};t.default=o},3835:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.resolveSchema=t.getCompilingSchema=t.resolveRef=t.compileSchema=t.SchemaEnv=void 0;const i=n(9029),o=n(3558),r=n(2023),s=n(6939),a=n(4227),l=n(2586);class c{constructor(e){var t;let n;this.refs={},this.dynamicAnchors={},"object"==typeof e.schema&&(n=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=null!==(t=e.baseId)&&void 0!==t?t:(0,s.normalizeId)(null==n?void 0:n[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=null==n?void 0:n.$async,this.refs={}}}function u(e){const t=d.call(this,e);if(t)return t;const n=(0,s.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:a,lines:c}=this.opts.code,{ownProperties:u}=this.opts,h=new i.CodeGen(this.scope,{es5:a,lines:c,ownProperties:u});let p;e.$async&&(p=h.scopeValue("Error",{ref:o.default,code:i._`require("ajv/dist/runtime/validation_error").default`}));const m=h.scopeName("validate");e.validateName=m;const f={gen:h,allErrors:this.opts.allErrors,data:r.default.data,parentData:r.default.parentData,parentDataProperty:r.default.parentDataProperty,dataNames:[r.default.data],dataPathArr:[i.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:h.scopeValue("schema",!0===this.opts.code.source?{ref:e.schema,code:(0,i.stringify)(e.schema)}:{ref:e.schema}),validateName:m,ValidationError:p,schema:e.schema,schemaEnv:e,rootId:n,baseId:e.baseId||n,schemaPath:i.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:i._`""`,opts:this.opts,self:this};let g;try{this._compilations.add(e),(0,l.validateFunctionCode)(f),h.optimize(this.opts.code.optimize);const t=h.toString();g=`${h.scopeRefs(r.default.scope)}return ${t}`,this.opts.code.process&&(g=this.opts.code.process(g,e));const n=new Function(`${r.default.self}`,`${r.default.scope}`,g)(this,this.scope.get());if(this.scope.value(m,{ref:n}),n.errors=null,n.schema=e.schema,n.schemaEnv=e,e.$async&&(n.$async=!0),!0===this.opts.code.source&&(n.source={validateName:m,validateCode:t,scopeValues:h._values}),this.opts.unevaluated){const{props:e,items:t}=f;n.evaluated={props:e instanceof i.Name?void 0:e,items:t instanceof i.Name?void 0:t,dynamicProps:e instanceof i.Name,dynamicItems:t instanceof i.Name},n.source&&(n.source.evaluated=(0,i.stringify)(n.evaluated))}return e.validate=n,e}catch(t){throw delete e.validate,delete e.validateName,g&&this.logger.error("Error compiling schema, function code:",g),t}finally{this._compilations.delete(e)}}function h(e){return(0,s.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:u.call(this,e)}function d(e){for(const t of this._compilations)if(p(t,e))return t}function p(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function m(e,t){let n;for(;"string"==typeof(n=this.refs[t]);)t=n;return n||this.schemas[t]||f.call(this,e,t)}function f(e,t){const n=this.opts.uriResolver.parse(t),i=(0,s._getFullPath)(this.opts.uriResolver,n);let o=(0,s.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&i===o)return y.call(this,n,e);const r=(0,s.normalizeId)(i),a=this.refs[r]||this.schemas[r];if("string"==typeof a){const t=f.call(this,e,a);if("object"!=typeof(null==t?void 0:t.schema))return;return y.call(this,n,t)}if("object"==typeof(null==a?void 0:a.schema)){if(a.validate||u.call(this,a),r===(0,s.normalizeId)(t)){const{schema:t}=a,{schemaId:n}=this.opts,i=t[n];return i&&(o=(0,s.resolveUrl)(this.opts.uriResolver,o,i)),new c({schema:t,schemaId:n,root:e,baseId:o})}return y.call(this,n,a)}}t.SchemaEnv=c,t.compileSchema=u,t.resolveRef=function(e,t,n){var i;n=(0,s.resolveUrl)(this.opts.uriResolver,t,n);const o=e.refs[n];if(o)return o;let r=m.call(this,e,n);if(void 0===r){const o=null===(i=e.localRefs)||void 0===i?void 0:i[n],{schemaId:s}=this.opts;o&&(r=new c({schema:o,schemaId:s,root:e,baseId:t}))}return void 0!==r?e.refs[n]=h.call(this,r):void 0},t.getCompilingSchema=d,t.resolveSchema=f;const g=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function y(e,{baseId:t,schema:n,root:i}){var o;if("/"!==(null===(o=e.fragment)||void 0===o?void 0:o[0]))return;for(const i of e.fragment.slice(1).split("/")){if("boolean"==typeof n)return;const e=n[(0,a.unescapeFragment)(i)];if(void 0===e)return;const o="object"==typeof(n=e)&&n[this.opts.schemaId];!g.has(i)&&o&&(t=(0,s.resolveUrl)(this.opts.uriResolver,t,o))}let r;if("boolean"!=typeof n&&n.$ref&&!(0,a.schemaHasRulesButRef)(n,this.RULES)){const e=(0,s.resolveUrl)(this.opts.uriResolver,t,n.$ref);r=f.call(this,i,e)}const{schemaId:l}=this.opts;return r=r||new c({schema:n,schemaId:l,root:i,baseId:t}),r.schema!==r.root.schema?r:void 0}},3837:e=>{"use strict";e.exports=JSON.parse('{"$id":"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#","description":"Meta-schema for $data reference (JSON AnySchema extension proposal)","type":"object","required":["$data"],"properties":{"$data":{"type":"string","anyOf":[{"format":"relative-json-pointer"},{"format":"json-pointer"}]}},"additionalProperties":false}')},3853:(e,t)=>{"use strict";function n(e){const t=e.length;let n,i=0,o=0;for(;o<t;)i++,n=e.charCodeAt(o++),n>=55296&&n<=56319&&o<t&&(n=e.charCodeAt(o),56320==(64512&n)&&o++);return i}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n,n.code='require("ajv/dist/runtime/ucs2length").default'},3856:(e,t,n)=>{"use strict";n.d(t,{Mn:()=>u,gp:()=>c,oZ:()=>p,yg:()=>h});var i=n(6082),o=n(7278);const r="rgb(100,100,100)",s="#808080",a="rgb(0,0,0)",l=o.zS;var c,u,h;!function(e){e.maxMonomerLength=".mm.cellRenderer.maxMonomerLength"}(c||(c={})),function(e){e.applyToBackground=".m.cellRenderer.applyToBackground"}(u||(u={})),function(e){e.MSA="MSA",e.classic="classic"}(h||(h={}));const d=new class{constructor(){this.color=r,this.pivot=0,this.left=!1,this.transparencyRate=0,this.separator="",this.last=!1,this.drawStyle=h.classic,this.maxWord=[],this.wordIdx=0,this.gridCell=null,this.referenceSequence=null,this.maxLengthOfMonomer=null,this.monomerTextSizeMap={},this.logger=void 0,this.selectedPosition=void 0,this.isMultiLineContext=!1,this.lineNumber=0}};function p(e,t,n,o,c,u,p){var m,f,g;const y={...d,...p};if(y.isMultiLineContext){e.textBaseline="middle",e.textAlign="center";let i=t;null!=y.maxLengthOfMonomer&&(i=l(i,y.maxLengthOfMonomer));const s=Math.max(.1,1-(y.transparencyRate??0));e.globalAlpha=s;const h=e.measureText(i),d=h.fontBoundingBoxAscent+h.fontBoundingBoxDescent,p=o+(u-d)/2+h.fontBoundingBoxAscent;let m=y.color??r;return m&&m!==r||(m=a),e.fillStyle=m,y.selectedPosition===y.wordIdx+1&&(e.save(),e.fillStyle="rgba(60, 177, 115, 0.2)",e.fillRect(n,o,c,u),e.restore(),e.fillStyle=m),e.fillText(i,n+c/2,p),e.globalAlpha=1,e.textBaseline="top",e.textAlign="start",n+c}p.logger?.debug("Bio: printLeftOrCentered(), start"),e.textAlign="start";let b=t.substring(0),v=y.last?"":y.separator;y.drawStyle===h.MSA&&(v="");let w=!0,C=!0,S="difference";if(null!=y.gridCell&&null!=y.gridCell.cell.column&&(w=y.gridCell.cell.column.temp["color-code"]??!0,C=y.gridCell.cell.column.temp["compare-with-current"]??!0,S=y.gridCell.cell.column.temp["highlight-difference"]??"difference"),y.referenceSequence){const e=y.referenceSequence[y.wordIdx];C&&y.referenceSequence.length>0&&"difference"===S&&(y.transparencyRate=b==e?.7:y.transparencyRate),C&&y.referenceSequence.length>0&&"equal"===S&&(y.transparencyRate=b!=e?.7:y.transparencyRate)}null!=y.maxLengthOfMonomer&&(b=l(b,y.maxLengthOfMonomer));const A=b+v;(m=y.monomerTextSizeMap)[A]??(m[A]=e.measureText(A));let x=y.monomerTextSizeMap[A];(f=y.monomerTextSizeMap)[b]??(f[b]=e.measureText(b));let M=y.monomerTextSizeMap[b].width;const T=u/2-(x.fontBoundingBoxAscent+x.fontBoundingBoxDescent)/2+1;(g=y.monomerTextSizeMap)[v]??(g[v]=e.measureText(v));const E=y.monomerTextSizeMap[v].width;function _(t,r){let l=w?y.color:a;y.selectedPosition===y.wordIdx+1&&(e.fillStyle="rgba(60, 177, 115, 0.2)",e.fillRect(n+t-4,o-5,y.monomerTextSizeMap[b].width+8,u+10),l=i.Color.toHtml(i.Color.setAlpha(i.Color.fromHtml(l),255))),e.fillStyle=l,e.globalAlpha=1-y.transparencyRate,y.drawStyle===h.classic&&(e.fillText(b,n+t,o+T),e.fillStyle=s,e.fillText(v,n+r,o+T)),y.drawStyle===h.MSA&&e.fillText(b,n+t,o+T),e.globalAlpha=1}x=x.width,y.drawStyle===h.MSA&&(M=y.maxWord[y.wordIdx],x=y.maxWord[y.wordIdx]);const I=(y.maxWord[y.wordIdx]??0)-(y.maxWord[0]??0);if(y.left||x>c)return _(I,I+M),n+I+M+E;{const e=(c-x)/2;return _(e,e+M),n+I+e+M}}},3890:(e,t,n)=>{"use strict";n.d(t,{TE:()=>u});var i=n(6082),o=n(7389),r=n(4328),s=n(1991),a=n.n(s),l=n(2447);const c=60;function u(){const e=r.shell.tv.grid,t=e.dataFrame,n=a().count(0).take(t.columns.length).map(e=>t.columns.byIndex(e)).filter(e=>e.semType!==i.SEMTYPE.MACROMOLECULE).toArray().find(e=>-1!==e.name.toLowerCase().indexOf("id")),s=n?[n]:[],u=o.input.columns("Seq id columns",{table:t,value:s,filter:e=>e.semType!==i.SEMTYPE.MACROMOLECULE}),d=a().count(0).take(t.columns.length).map(e=>t.columns.byIndex(e)).filter(e=>!(!e||e.semType!==i.SEMTYPE.MACROMOLECULE)&&l._package.seqHelper.getSeqHandler(e).isFasta()).toArray(),p=d.length>0?d[0]:null,m=o.input.column("Seq column",{table:t,value:p,filter:e=>!(!e||e.semType!==i.SEMTYPE.MACROMOLECULE)&&l._package.seqHelper.getSeqHandler(e).isFasta()}),f=o.input.int("FASTA line width",{value:c});o.dialog({title:"Save as FASTA"}).add(o.inputs([u,m,f])).onOK(()=>{const t=u.value??[],n=m.value??null,i=f.value??c;n||r.shell.warning("Seq column is mandatory to save as FASTA.");const o=function(e,t,n=c,i="\n"){const o=[];for(let r=0;r<t.length;r++){const s=e.map(e=>e.get(r).toString()).join("|"),a=h(t.getSplitted(r),n);o.push(`>${s}${i}`);for(const e of a)o.push(`${e}${i}`)}return"".concat(...o)}(t,l._package.seqHelper.getSeqHandler(n),i),s=document.createElement("a");s.setAttribute("href",`data:text/plain;charset=utf-8,${encodeURIComponent(o)}`),s.setAttribute("download",`${e.dataFrame.name}.fasta`),s.click()}).show()}function h(e,t=c){let n=0;const i=e.length,o=[];for(;n<i;){const i=a().count(n).take(Math.min(e.length-n,t)).map(t=>e.getOriginal(t)).toArray(),r=i.map(e=>e.length>1?`[${e}]`:e).reduce((e,t)=>e+t,"");o.push(r),n+=i.length}return o}},3966:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o=n(4227),r=n(5765),s=n(5457),a={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:{message:({params:{len:e}})=>i.str`must NOT have more than ${e} items`,params:({params:{len:e}})=>i._`{limit: ${e}}`},code(e){const{schema:t,parentSchema:n,it:i}=e,{prefixItems:a}=n;i.items=!0,(0,o.alwaysValidSchema)(i,t)||(a?(0,s.validateAdditionalItems)(e,a):e.ok((0,r.validateArray)(e)))}};t.default=a},4003:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(5765),o=n(9029),r=n(4227),s={keyword:"required",type:"object",schemaType:"array",$data:!0,error:{message:({params:{missingProperty:e}})=>o.str`must have required property '${e}'`,params:({params:{missingProperty:e}})=>o._`{missingProperty: ${e}}`},code(e){const{gen:t,schema:n,schemaCode:s,data:a,$data:l,it:c}=e,{opts:u}=c;if(!l&&0===n.length)return;const h=n.length>=u.loopRequired;if(c.allErrors?function(){if(h||l)e.block$data(o.nil,d);else for(const t of n)(0,i.checkReportMissingProp)(e,t)}():function(){const r=t.let("missing");if(h||l){const n=t.let("valid",!0);e.block$data(n,()=>function(n,r){e.setParams({missingProperty:n}),t.forOf(n,s,()=>{t.assign(r,(0,i.propertyInData)(t,a,n,u.ownProperties)),t.if((0,o.not)(r),()=>{e.error(),t.break()})},o.nil)}(r,n)),e.ok(n)}else t.if((0,i.checkMissingProp)(e,n,r)),(0,i.reportMissingProp)(e,r),t.else()}(),u.strictRequired){const t=e.parentSchema.properties,{definedProperties:i}=e.it;for(const e of n)if(void 0===(null==t?void 0:t[e])&&!i.has(e)){const t=`required property "${e}" is not defined at "${c.schemaEnv.baseId+c.errSchemaPath}" (strictRequired)`;(0,r.checkStrictMode)(c,t,c.opts.strictRequired)}}function d(){t.forOf("prop",s,n=>{e.setParams({missingProperty:n}),t.if((0,i.noPropertyInData)(t,a,n,u.ownProperties),()=>e.error())})}}};t.default=s},4025:(e,t,n)=>{"use strict";n.d(t,{C:()=>a,j:()=>s});var i=n(6082),o=n(439),r=n(7278);const s=new class{constructor(){this.seqHandler="seq-handler",this.notationProvider="seq-handler.notation-provider"}};class a extends i.SemanticValue{get value(){return this.seqHandler.column.get(this.rowIdx)}set value(e){this.seqHandler.column.set(this.rowIdx,e)}get helm(){return this.seqHandler.getHelm(this.rowIdx)}isDna(){return this.seqHandler.alphabet===o.YI.DNA}isRna(){return this.seqHandler.alphabet===o.YI.RNA}isNaturalPeptide(){return this.seqHandler.alphabet===o.YI.PT}isHelm(){return this.seqHandler.isHelm()}constructor(e,t){if(null==t.column.dataFrame)throw new Error("Attribute .dataFrame is required for SeqValueBase from cell");const n=t.column.dataFrame.cell(e,t.column.name);super(i.SemanticValue.fromTableCell(n).dart),this.rowIdx=e,this.seqHandler=t}getSplitted(){return this.seqHandler.getSplitted(this.rowIdx)}getSplittedWithSugarsAndPhosphates(){if(!this.isDna()&&!this.isRna())return this.getSplitted();const e=(0,r.qp)(this.helm),t=[],n=/\(|\)/;for(let i=0;i<e.length;i++){const o=e.getOriginal(i),r=o.split(n).filter(e=>!!e);3===r.length?(t.push(r[0]),t.push(r[1]),t.push(r[2])):t.push(o)}return new r.Mu(t,this.seqHandler.defaultGapOriginal)}}},4042:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CodeGen=t.Name=t.nil=t.stringify=t.str=t._=t.KeywordCxt=void 0;var i=n(2586);Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return i.KeywordCxt}});var o=n(9029);Object.defineProperty(t,"_",{enumerable:!0,get:function(){return o._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return o.str}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return o.stringify}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return o.nil}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return o.Name}}),Object.defineProperty(t,"CodeGen",{enumerable:!0,get:function(){return o.CodeGen}});const r=n(3558),s=n(4551),a=n(396),l=n(3835),c=n(9029),u=n(6939),h=n(208),d=n(4227),p=n(3837),m=n(5944),f=(e,t)=>new RegExp(e,t);f.code="new RegExp";const g=["removeAdditional","useDefaults","coerceTypes"],y=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),b={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},v={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'};function w(e){var t,n,i,o,r,s,a,l,c,u,h,d,p,g,y,b,v,w,C,S,A,x,M,T,E;const _=e.strict,I=null===(t=e.code)||void 0===t?void 0:t.optimize,L=!0===I||void 0===I?1:I||0,N=null!==(i=null===(n=e.code)||void 0===n?void 0:n.regExp)&&void 0!==i?i:f,P=null!==(o=e.uriResolver)&&void 0!==o?o:m.default;return{strictSchema:null===(s=null!==(r=e.strictSchema)&&void 0!==r?r:_)||void 0===s||s,strictNumbers:null===(l=null!==(a=e.strictNumbers)&&void 0!==a?a:_)||void 0===l||l,strictTypes:null!==(u=null!==(c=e.strictTypes)&&void 0!==c?c:_)&&void 0!==u?u:"log",strictTuples:null!==(d=null!==(h=e.strictTuples)&&void 0!==h?h:_)&&void 0!==d?d:"log",strictRequired:null!==(g=null!==(p=e.strictRequired)&&void 0!==p?p:_)&&void 0!==g&&g,code:e.code?{...e.code,optimize:L,regExp:N}:{optimize:L,regExp:N},loopRequired:null!==(y=e.loopRequired)&&void 0!==y?y:200,loopEnum:null!==(b=e.loopEnum)&&void 0!==b?b:200,meta:null===(v=e.meta)||void 0===v||v,messages:null===(w=e.messages)||void 0===w||w,inlineRefs:null===(C=e.inlineRefs)||void 0===C||C,schemaId:null!==(S=e.schemaId)&&void 0!==S?S:"$id",addUsedSchema:null===(A=e.addUsedSchema)||void 0===A||A,validateSchema:null===(x=e.validateSchema)||void 0===x||x,validateFormats:null===(M=e.validateFormats)||void 0===M||M,unicodeRegExp:null===(T=e.unicodeRegExp)||void 0===T||T,int32range:null===(E=e.int32range)||void 0===E||E,uriResolver:P}}class C{constructor(e={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...w(e)};const{es5:t,lines:n}=this.opts.code;this.scope=new c.ValueScope({scope:{},prefixes:y,es5:t,lines:n}),this.logger=function(e){if(!1===e)return _;if(void 0===e)return console;if(e.log&&e.warn&&e.error)return e;throw new Error("logger must implement log, warn and error methods")}(e.logger);const i=e.validateFormats;e.validateFormats=!1,this.RULES=(0,a.getRules)(),S.call(this,b,e,"NOT SUPPORTED"),S.call(this,v,e,"DEPRECATED","warn"),this._metaOpts=E.call(this),e.formats&&M.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&T.call(this,e.keywords),"object"==typeof e.meta&&this.addMetaSchema(e.meta),x.call(this),e.validateFormats=i}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:e,meta:t,schemaId:n}=this.opts;let i=p;"id"===n&&(i={...p},i.id=i.$id,delete i.$id),t&&e&&this.addMetaSchema(i,i[n],!1)}defaultMeta(){const{meta:e,schemaId:t}=this.opts;return this.opts.defaultMeta="object"==typeof e?e[t]||e:void 0}validate(e,t){let n;if("string"==typeof e){if(n=this.getSchema(e),!n)throw new Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);const i=n(t);return"$async"in n||(this.errors=n.errors),i}compile(e,t){const n=this._addSchema(e,t);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,t){if("function"!=typeof this.opts.loadSchema)throw new Error("options.loadSchema should be a function");const{loadSchema:n}=this.opts;return i.call(this,e,t);async function i(e,t){await o.call(this,e.$schema);const n=this._addSchema(e,t);return n.validate||r.call(this,n)}async function o(e){e&&!this.getSchema(e)&&await i.call(this,{$ref:e},!0)}async function r(e){try{return this._compileSchemaEnv(e)}catch(t){if(!(t instanceof s.default))throw t;return a.call(this,t),await l.call(this,t.missingSchema),r.call(this,e)}}function a({missingSchema:e,missingRef:t}){if(this.refs[e])throw new Error(`AnySchema ${e} is loaded but ${t} cannot be resolved`)}async function l(e){const n=await c.call(this,e);this.refs[e]||await o.call(this,n.$schema),this.refs[e]||this.addSchema(n,e,t)}async function c(e){const t=this._loading[e];if(t)return t;try{return await(this._loading[e]=n(e))}finally{delete this._loading[e]}}}addSchema(e,t,n,i=this.opts.validateSchema){if(Array.isArray(e)){for(const t of e)this.addSchema(t,void 0,n,i);return this}let o;if("object"==typeof e){const{schemaId:t}=this.opts;if(o=e[t],void 0!==o&&"string"!=typeof o)throw new Error(`schema ${t} must be string`)}return t=(0,u.normalizeId)(t||o),this._checkUnique(t),this.schemas[t]=this._addSchema(e,n,t,i,!0),this}addMetaSchema(e,t,n=this.opts.validateSchema){return this.addSchema(e,t,!0,n),this}validateSchema(e,t){if("boolean"==typeof e)return!0;let n;if(n=e.$schema,void 0!==n&&"string"!=typeof n)throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,!0;const i=this.validate(n,e);if(!i&&t){const e="schema is invalid: "+this.errorsText();if("log"!==this.opts.validateSchema)throw new Error(e);this.logger.error(e)}return i}getSchema(e){let t;for(;"string"==typeof(t=A.call(this,e));)e=t;if(void 0===t){const{schemaId:n}=this.opts,i=new l.SchemaEnv({schema:{},schemaId:n});if(t=l.resolveSchema.call(this,i,e),!t)return;this.refs[e]=t}return t.validate||this._compileSchemaEnv(t)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{const t=A.call(this,e);return"object"==typeof t&&this._cache.delete(t.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{const t=e;this._cache.delete(t);let n=e[this.opts.schemaId];return n&&(n=(0,u.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(const t of e)this.addKeyword(t);return this}addKeyword(e,t){let n;if("string"==typeof e)n=e,"object"==typeof t&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),t.keyword=n);else{if("object"!=typeof e||void 0!==t)throw new Error("invalid addKeywords parameters");if(n=(t=e).keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}if(L.call(this,n,t),!t)return(0,d.eachItem)(n,e=>N.call(this,e)),this;R.call(this,t);const i={...t,type:(0,h.getJSONTypes)(t.type),schemaType:(0,h.getJSONTypes)(t.schemaType)};return(0,d.eachItem)(n,0===i.type.length?e=>N.call(this,e,i):e=>i.type.forEach(t=>N.call(this,e,i,t))),this}getKeyword(e){const t=this.RULES.all[e];return"object"==typeof t?t.definition:!!t}removeKeyword(e){const{RULES:t}=this;delete t.keywords[e],delete t.all[e];for(const n of t.rules){const t=n.rules.findIndex(t=>t.keyword===e);t>=0&&n.rules.splice(t,1)}return this}addFormat(e,t){return"string"==typeof t&&(t=new RegExp(t)),this.formats[e]=t,this}errorsText(e=this.errors,{separator:t=", ",dataVar:n="data"}={}){return e&&0!==e.length?e.map(e=>`${n}${e.instancePath} ${e.message}`).reduce((e,n)=>e+t+n):"No errors"}$dataMetaSchema(e,t){const n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(const i of t){const t=i.split("/").slice(1);let o=e;for(const e of t)o=o[e];for(const e in n){const t=n[e];if("object"!=typeof t)continue;const{$data:i}=t.definition,r=o[e];i&&r&&(o[e]=O(r))}}return e}_removeAllSchemas(e,t){for(const n in e){const i=e[n];t&&!t.test(n)||("string"==typeof i?delete e[n]:i&&!i.meta&&(this._cache.delete(i.schema),delete e[n]))}}_addSchema(e,t,n,i=this.opts.validateSchema,o=this.opts.addUsedSchema){let r;const{schemaId:s}=this.opts;if("object"==typeof e)r=e[s];else{if(this.opts.jtd)throw new Error("schema must be object");if("boolean"!=typeof e)throw new Error("schema must be object or boolean")}let a=this._cache.get(e);if(void 0!==a)return a;n=(0,u.normalizeId)(r||n);const c=u.getSchemaRefs.call(this,e,n);return a=new l.SchemaEnv({schema:e,schemaId:s,meta:t,baseId:n,localRefs:c}),this._cache.set(a.schema,a),o&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=a),i&&this.validateSchema(e,!0),a}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):l.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){const t=this.opts;this.opts=this._metaOpts;try{l.compileSchema.call(this,e)}finally{this.opts=t}}}function S(e,t,n,i="error"){for(const o in e){const r=o;r in t&&this.logger[i](`${n}: option ${o}. ${e[r]}`)}}function A(e){return e=(0,u.normalizeId)(e),this.schemas[e]||this.refs[e]}function x(){const e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(const t in e)this.addSchema(e[t],t)}function M(){for(const e in this.opts.formats){const t=this.opts.formats[e];t&&this.addFormat(e,t)}}function T(e){if(Array.isArray(e))this.addVocabulary(e);else{this.logger.warn("keywords option as map is deprecated, pass array");for(const t in e){const n=e[t];n.keyword||(n.keyword=t),this.addKeyword(n)}}}function E(){const e={...this.opts};for(const t of g)delete e[t];return e}C.ValidationError=r.default,C.MissingRefError=s.default,t.default=C;const _={log(){},warn(){},error(){}},I=/^[a-z_$][a-z0-9_$:-]*$/i;function L(e,t){const{RULES:n}=this;if((0,d.eachItem)(e,e=>{if(n.keywords[e])throw new Error(`Keyword ${e} is already defined`);if(!I.test(e))throw new Error(`Keyword ${e} has invalid name`)}),t&&t.$data&&!("code"in t)&&!("validate"in t))throw new Error('$data keyword must have "code" or "validate" function')}function N(e,t,n){var i;const o=null==t?void 0:t.post;if(n&&o)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:r}=this;let s=o?r.post:r.rules.find(({type:e})=>e===n);if(s||(s={type:n,rules:[]},r.rules.push(s)),r.keywords[e]=!0,!t)return;const a={keyword:e,definition:{...t,type:(0,h.getJSONTypes)(t.type),schemaType:(0,h.getJSONTypes)(t.schemaType)}};t.before?P.call(this,s,a,t.before):s.rules.push(a),r.all[e]=a,null===(i=t.implements)||void 0===i||i.forEach(e=>this.addKeyword(e))}function P(e,t,n){const i=e.rules.findIndex(e=>e.keyword===n);i>=0?e.rules.splice(i,0,t):(e.rules.push(t),this.logger.warn(`rule ${n} is not defined`))}function R(e){let{metaSchema:t}=e;void 0!==t&&(e.$data&&this.opts.$data&&(t=O(t)),e.validateSchema=this.compile(t,!0))}const $={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function O(e){return{anyOf:[e,$]}}},4139:(e,t,n)=>{"use strict";n.d(t,{HX:()=>u,J:()=>a,b9:()=>c,uF:()=>r});var i,o,r,s,a,l=n(8152);!function(e){e.SPLIT_COL="~split",e.ACTIVITY="~activity",e.ACTIVITY_SCALED="activity_scaled",e.ALIGNED_SEQUENCE="~aligned_sequence",e.AMINO_ACID_RESIDUE="AAR",e.POSITION="Pos",e.P_VALUE="pValue",e.MEAN_DIFFERENCE="Mean difference"}(i||(i={})),function(e){e.AAR="AAR",e.POSITION="Pos",e.SELECTION="selection"}(o||(o={})),function(e){e.MONOMER="Monomer",e.MACROMOLECULE_DIFFERENCE="MacromoleculeDifference",e.ACTIVITY="activity",e.ACTIVITY_SCALED="activityScaled"}(r||(r={})),function(e){e.CELL_CHANGING="isCellChanging"}(s||(s={})),function(e){e.SEPARATOR="."}(a||(a={}));const c="3.3.1",u={pepsea:{gapOpen:1.53,gapExtend:0,method:l.ZY[0]},kalign:{gapOpen:-1,gapExtend:-1,terminalGap:-1}}},4152:(e,t,n)=>{"use strict";var i=n(6082),o=n(7362),r=n(4971);function s(e,t=!0){if(null==e)return"rgb(100,100,100)";const n=i.Color.fromHtml(e);if(t){const e=i.Color.g(n),t=i.Color.r(n),o=i.Color.b(n),r=Math.sqrt(Math.pow(0-t,2)+Math.pow(0-e,2)+Math.pow(0-o,2));if(r>210)return`rgb(${t/r*210},${e/r*210},${o/r*210})`}return i.Color.toRgb(n)}class a{static hashCode(e){let t=0;if(0===e.length)return t;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t}}class l{}class c extends l{static get palette(){return c._pallete||(c._pallete=c.buildPalette()),c._pallete}static buildPalette(){return(0,r.pj)().then(e=>{e.awaitLoaded(1/0).then(()=>{const t=e.getMonomerLib();t.onChanged.subscribe(()=>{c.customMonomerColors={},c.polymerTypes=t.getPolymerTypes();for(const e of this.polymerTypes){const n=t.getMonomerSymbolsByType(e);for(const i of n){const n=t.getMonomer(e,i);n?.meta?.colors?.default?.background&&(this.customMonomerColors[i]||(this.customMonomerColors[i]={}),this.customMonomerColors[i][e]=s(n.meta.colors.default.background))}}})})}),[].concat(...Object.values(o.e.colourPalette))}get(e,t){const n=c.palette.length,i=c.customMonomerColors[e],o=t??"PEPTIDE";if(i&&i[o])return i[o];const r=a.hashCode(e)%n;return s(c.palette[r])}}c._pallete=null,c.customMonomerColors={},c.polymerTypes=[]},4227:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.checkStrictMode=t.getErrorPath=t.Type=t.useFunc=t.setEvaluated=t.evaluatedPropsToName=t.mergeEvaluated=t.eachItem=t.unescapeJsonPointer=t.escapeJsonPointer=t.escapeFragment=t.unescapeFragment=t.schemaRefOrVal=t.schemaHasRulesButRef=t.schemaHasRules=t.checkUnknownRules=t.alwaysValidSchema=t.toHash=void 0;const i=n(9029),o=n(1520);function r(e,t=e.schema){const{opts:n,self:i}=e;if(!n.strictSchema)return;if("boolean"==typeof t)return;const o=i.RULES.keywords;for(const n in t)o[n]||m(e,`unknown keyword: "${n}"`)}function s(e,t){if("boolean"==typeof e)return!e;for(const n in e)if(t[n])return!0;return!1}function a(e){return"number"==typeof e?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}function l(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function c({mergeNames:e,mergeToName:t,mergeValues:n,resultToName:o}){return(r,s,a,l)=>{const c=void 0===a?s:a instanceof i.Name?(s instanceof i.Name?e(r,s,a):t(r,s,a),a):s instanceof i.Name?(t(r,a,s),s):n(s,a);return l!==i.Name||c instanceof i.Name?c:o(r,c)}}function u(e,t){if(!0===t)return e.var("props",!0);const n=e.var("props",i._`{}`);return void 0!==t&&h(e,n,t),n}function h(e,t,n){Object.keys(n).forEach(n=>e.assign(i._`${t}${(0,i.getProperty)(n)}`,!0))}t.toHash=function(e){const t={};for(const n of e)t[n]=!0;return t},t.alwaysValidSchema=function(e,t){return"boolean"==typeof t?t:0===Object.keys(t).length||(r(e,t),!s(t,e.self.RULES.all))},t.checkUnknownRules=r,t.schemaHasRules=s,t.schemaHasRulesButRef=function(e,t){if("boolean"==typeof e)return!e;for(const n in e)if("$ref"!==n&&t.all[n])return!0;return!1},t.schemaRefOrVal=function({topSchemaRef:e,schemaPath:t},n,o,r){if(!r){if("number"==typeof n||"boolean"==typeof n)return n;if("string"==typeof n)return i._`${n}`}return i._`${e}${t}${(0,i.getProperty)(o)}`},t.unescapeFragment=function(e){return l(decodeURIComponent(e))},t.escapeFragment=function(e){return encodeURIComponent(a(e))},t.escapeJsonPointer=a,t.unescapeJsonPointer=l,t.eachItem=function(e,t){if(Array.isArray(e))for(const n of e)t(n);else t(e)},t.mergeEvaluated={props:c({mergeNames:(e,t,n)=>e.if(i._`${n} !== true && ${t} !== undefined`,()=>{e.if(i._`${t} === true`,()=>e.assign(n,!0),()=>e.assign(n,i._`${n} || {}`).code(i._`Object.assign(${n}, ${t})`))}),mergeToName:(e,t,n)=>e.if(i._`${n} !== true`,()=>{!0===t?e.assign(n,!0):(e.assign(n,i._`${n} || {}`),h(e,n,t))}),mergeValues:(e,t)=>!0===e||{...e,...t},resultToName:u}),items:c({mergeNames:(e,t,n)=>e.if(i._`${n} !== true && ${t} !== undefined`,()=>e.assign(n,i._`${t} === true ? true : ${n} > ${t} ? ${n} : ${t}`)),mergeToName:(e,t,n)=>e.if(i._`${n} !== true`,()=>e.assign(n,!0===t||i._`${n} > ${t} ? ${n} : ${t}`)),mergeValues:(e,t)=>!0===e||Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})},t.evaluatedPropsToName=u,t.setEvaluated=h;const d={};var p;function m(e,t,n=e.opts.strictSchema){if(n){if(t=`strict mode: ${t}`,!0===n)throw new Error(t);e.self.logger.warn(t)}}t.useFunc=function(e,t){return e.scopeValue("func",{ref:t,code:d[t.code]||(d[t.code]=new o._Code(t.code))})},function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"}(p||(t.Type=p={})),t.getErrorPath=function(e,t,n){if(e instanceof i.Name){const o=t===p.Num;return n?o?i._`"[" + ${e} + "]"`:i._`"['" + ${e} + "']"`:o?i._`"/" + ${e}`:i._`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return n?(0,i.getProperty)(e).toString():"/"+a(e)},t.checkStrictMode=m},4326:(e,t,n)=>{"use strict";n.d(t,{Fo:()=>u,Lp:()=>r,P4:()=>s,fH:()=>o,gp:()=>i,lT:()=>l,mH:()=>a});var i,o,r,s,a,l,c=n(6082);!function(e){e.tooltipWebLogo=".tooltipWebLogo"}(i||(i={})),function(e){e.Entropy="Entropy",e.full="100%"}(o||(o={})),function(e){e.TOP="top",e.MIDDLE="middle",e.BOTTOM="bottom"}(r||(r={})),function(e){e.LEFT="left",e.CENTER="center",e.RIGHT="right"}(s||(s={})),function(e){e.AUTO="auto",e.ON="on",e.OFF="off"}(a||(a={})),function(e){e.Filtered="Filtered",e.Selected="Selected"}(l||(l={}));const u=new class{constructor(){this.sequenceColumnName=null,this.valueAggrType=c.AGG.TOTAL_COUNT,this.valueColumnName="Activity",this.startPositionName=null,this.endPositionName=null,this.skipEmptySequences=!0,this.skipEmptyPositions=!1,this.shrinkEmptyTail=!0,this.backgroundColor=4294967295,this.positionHeight=o.Entropy,this.positionWidth=20,this.verticalAlignment=r.MIDDLE,this.horizontalAlignment=s.CENTER,this.fixWidth=!1,this.fitArea=!0,this.minHeight=25,this.maxHeight=300,this.maxMonomerLetters=5,this.showPositionLabels=!0,this.positionMarginState=a.AUTO,this.positionMargin=0,this.filterSource=l.Filtered}}},4328:e=>{"use strict";e.exports=grok},4356:(e,t,n)=>{"use strict";n.d(t,{E:()=>h,u:()=>u});var i=n(4328);const o="Libraries",r="Settings",s="DuplicateMonomerPreferences",a=4e3,l="nextChunk";let c=Promise.resolve();async function u(){let e;return c=c.then(async()=>{const t=await i.userSettings.getValue(o,r,!0);e=t?JSON.parse(t):{exclude:[],explicit:[],duplicateMonomerPreferences:{}};const n=await async function(){let e=await i.userSettings.getValue(o,s,!0)??"";if(!e)return{};for(;e.endsWith(l);){const t=`${s}${e.charAt(e.length-l.length-1)}`,n=await i.userSettings.getValue(o,t,!0)??"";e=e.slice(0,e.length-l.length-1)+n}return JSON.parse(e)}();e.exclude=e.exclude instanceof Array?e.exclude:[],e.explicit=e.explicit instanceof Array?e.explicit:[],e.duplicateMonomerPreferences=e.duplicateMonomerPreferences instanceof Object?e.duplicateMonomerPreferences:{};for(const t in n){e.duplicateMonomerPreferences[t]=e.duplicateMonomerPreferences[t]??{};for(const i in n[t])for(const o of n[t][i])e.duplicateMonomerPreferences[t][o]=i}console.debug(`Bio: getUserLibSettings()\n${JSON.stringify(e,void 0,2)}`)}),await c,e}async function h(e){c=c.then(async()=>{e.duplicateMonomerPreferences=e.duplicateMonomerPreferences??{},console.debug(`Bio: setUserLibSettings()\n${JSON.stringify(e,void 0,2)}`);const t={};for(const n in e.duplicateMonomerPreferences){t[n]={};for(const i in e.duplicateMonomerPreferences[n]){const o=e.duplicateMonomerPreferences[n][i];t[n][o]=t[n][o]??[],t[n][o].push(i)}}await async function(e){const t=JSON.stringify(e),n=Math.ceil(t.length/a);for(let e=0;e<n;e++){const r=0===e?s:`${s}${e}`,c=e<n-1?`${e+1}`:"",u=t.slice(e*a,(e+1)*a),h=c?u+c+l:u;await i.userSettings.add(o,r,h,!0)}}(t),e.duplicateMonomerPreferences={},await i.userSettings.add(o,r,JSON.stringify(e),!0)}),await c}},4426:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(4227),o={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:n}){void 0===t.if&&(0,i.checkStrictMode)(n,`"${e}" without "if" is ignored`)}};t.default=o},4486:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:{message({keyword:e,schemaCode:t}){const n="maxProperties"===e?"more":"fewer";return i.str`must NOT have ${n} than ${t} properties`},params:({schemaCode:e})=>i._`{limit: ${e}}`},code(e){const{keyword:t,data:n,schemaCode:o}=e,r="maxProperties"===t?i.operators.GT:i.operators.LT;e.fail$data(i._`Object.keys(${n}).length ${r} ${o}`)}};t.default=o},4495:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extendSubschemaMode=t.extendSubschemaData=t.getSubschema=void 0;const i=n(9029),o=n(4227);t.getSubschema=function(e,{keyword:t,schemaProp:n,schema:r,schemaPath:s,errSchemaPath:a,topSchemaRef:l}){if(void 0!==t&&void 0!==r)throw new Error('both "keyword" and "schema" passed, only one allowed');if(void 0!==t){const r=e.schema[t];return void 0===n?{schema:r,schemaPath:i._`${e.schemaPath}${(0,i.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:r[n],schemaPath:i._`${e.schemaPath}${(0,i.getProperty)(t)}${(0,i.getProperty)(n)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,o.escapeFragment)(n)}`}}if(void 0!==r){if(void 0===s||void 0===a||void 0===l)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:r,schemaPath:s,topSchemaRef:l,errSchemaPath:a}}throw new Error('either "keyword" or "schema" must be passed')},t.extendSubschemaData=function(e,t,{dataProp:n,dataPropType:r,data:s,dataTypes:a,propertyName:l}){if(void 0!==s&&void 0!==n)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:c}=t;if(void 0!==n){const{errorPath:s,dataPathArr:a,opts:l}=t;u(c.let("data",i._`${t.data}${(0,i.getProperty)(n)}`,!0)),e.errorPath=i.str`${s}${(0,o.getErrorPath)(n,r,l.jsPropertySyntax)}`,e.parentDataProperty=i._`${n}`,e.dataPathArr=[...a,e.parentDataProperty]}function u(n){e.data=n,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,n]}void 0!==s&&(u(s instanceof i.Name?s:c.let("data",s,!0)),void 0!==l&&(e.propertyName=l)),a&&(e.dataTypes=a)},t.extendSubschemaMode=function(e,{jtdDiscriminator:t,jtdMetadata:n,compositeRule:i,createErrors:o,allErrors:r}){void 0!==i&&(e.compositeRule=i),void 0!==o&&(e.createErrors=o),void 0!==r&&(e.allErrors=r),e.jtdDiscriminator=t,e.jtdMetadata=n}},4551:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(6939);class o extends Error{constructor(e,t,n,o){super(o||`can't resolve reference ${n} from id ${t}`),this.missingRef=(0,i.resolveUrl)(e,t,n),this.missingSchema=(0,i.normalizeId)((0,i.getFullPath)(e,this.missingRef))}}t.default=o},4574:(e,t,n)=>{"use strict";n.d(t,{O:()=>r,n:()=>o});var i=n(1858);class o{constructor(e,t=!0,n){return this.substructure=e,this.readOnly=t,this.logger=n,new Proxy(this,{set:(e,t,n)=>{if(this.logger?.debug(`BioFilterProps.set ${t.toString()}( '${n}' )`),this.readOnly)throw new Error("Properties are immutable.");return e[t]=n,!0}})}}class r{constructor(){this.onChanged=new i.Subject,this._props=null,this._propsChanging=!1}get props(){return this._props||(this._props=this.emptyProps),this._props}set props(e){this._propsChanging=!0;try{this._props=e,this.applyProps(),this.onChanged.next()}finally{this._propsChanging=!1}}saveProps(){const e={};for(const[t,n]of Object.entries(this.props))"_onChanged"!==t&&"logger"!==t&&(e[t]=this.props[t]);return e}async detach(){}get filterSummary(){return this.props.substructure}get isFiltering(){return""!==this.props.substructure}resetFilter(){this.props=this.emptyProps,this.onChanged.next()}}},4588:e=>{"use strict";e.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/meta/format-annotation","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/format-annotation":true},"$dynamicAnchor":"meta","title":"Format vocabulary meta-schema for annotation results","type":["object","boolean"],"properties":{"format":{"type":"string"}}}')},4737:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:{message:({schemaCode:e})=>i.str`must match format "${e}"`,params:({schemaCode:e})=>i._`{format: ${e}}`},code(e,t){const{gen:n,data:o,$data:r,schema:s,schemaCode:a,it:l}=e,{opts:c,errSchemaPath:u,schemaEnv:h,self:d}=l;c.validateFormats&&(r?function(){const r=n.scopeValue("formats",{ref:d.formats,code:c.code.formats}),s=n.const("fDef",i._`${r}[${a}]`),l=n.let("fType"),u=n.let("format");n.if(i._`typeof ${s} == "object" && !(${s} instanceof RegExp)`,()=>n.assign(l,i._`${s}.type || "string"`).assign(u,i._`${s}.validate`),()=>n.assign(l,i._`"string"`).assign(u,s)),e.fail$data((0,i.or)(!1===c.strictSchema?i.nil:i._`${a} && !${u}`,function(){const e=h.$async?i._`(${s}.async ? await ${u}(${o}) : ${u}(${o}))`:i._`${u}(${o})`,n=i._`(typeof ${u} == "function" ? ${e} : ${u}.test(${o}))`;return i._`${u} && ${u} !== true && ${l} === ${t} && !${n}`}()))}():function(){const r=d.formats[s];if(!r)return void function(){if(!1!==c.strictSchema)throw new Error(e());function e(){return`unknown format "${s}" ignored in schema at path "${u}"`}d.logger.warn(e())}();if(!0===r)return;const[a,l,p]=function(e){const t=e instanceof RegExp?(0,i.regexpCode)(e):c.code.formats?i._`${c.code.formats}${(0,i.getProperty)(s)}`:void 0,o=n.scopeValue("formats",{key:s,ref:e,code:t});return"object"!=typeof e||e instanceof RegExp?["string",e,o]:[e.type||"string",e.validate,i._`${o}.validate`]}(r);a===t&&e.pass(function(){if("object"==typeof r&&!(r instanceof RegExp)&&r.async){if(!h.$async)throw new Error("async format in sync schema");return i._`await ${p}(${o})`}return"function"==typeof l?i._`${p}(${o})`:i._`${p}.test(${o})`}())}())}};t.default=o},4834:(e,t,n)=>{"use strict";const{HEX:i}=n(4914),o=/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u;function r(e){if(c(e,".")<3)return{host:e,isIPV4:!1};const t=e.match(o)||[],[n]=t;return n?{host:l(n,"."),isIPV4:!0}:{host:e,isIPV4:!1}}function s(e,t=!1){let n="",o=!0;for(const t of e){if(void 0===i[t])return;"0"!==t&&!0===o&&(o=!1),o||(n+=t)}return t&&0===n.length&&(n="0"),n}function a(e){if(c(e,":")<2)return{host:e,isIPV6:!1};const t=function(e){let t=0;const n={error:!1,address:"",zone:""},i=[],o=[];let r=!1,a=!1,l=!1;function c(){if(o.length){if(!1===r){const e=s(o);if(void 0===e)return n.error=!0,!1;i.push(e)}o.length=0}return!0}for(let s=0;s<e.length;s++){const u=e[s];if("["!==u&&"]"!==u)if(":"!==u)if("%"===u){if(!c())break;r=!0}else o.push(u);else{if(!0===a&&(l=!0),!c())break;if(t++,i.push(":"),t>7){n.error=!0;break}s-1>=0&&":"===e[s-1]&&(a=!0)}}return o.length&&(r?n.zone=o.join(""):l?i.push(o.join("")):i.push(s(o))),n.address=i.join(""),n}(e);if(t.error)return{host:e,isIPV6:!1};{let e=t.address,n=t.address;return t.zone&&(e+="%"+t.zone,n+="%25"+t.zone),{host:e,escapedHost:n,isIPV6:!0}}}function l(e,t){let n="",i=!0;const o=e.length;for(let r=0;r<o;r++){const s=e[r];"0"===s&&i?(r+1<=o&&e[r+1]===t||r+1===o)&&(n+=s,i=!1):(i=s===t,n+=s)}return n}function c(e,t){let n=0;for(let i=0;i<e.length;i++)e[i]===t&&n++;return n}const u=/^\.\.?\//u,h=/^\/\.(?:\/|$)/u,d=/^\/\.\.(?:\/|$)/u,p=/^\/?(?:.|\n)*?(?=\/|$)/u;e.exports={recomposeAuthority:function(e){const t=[];if(void 0!==e.userinfo&&(t.push(e.userinfo),t.push("@")),void 0!==e.host){let n=unescape(e.host);const i=r(n);if(i.isIPV4)n=i.host;else{const t=a(i.host);n=!0===t.isIPV6?`[${t.escapedHost}]`:e.host}t.push(n)}return"number"!=typeof e.port&&"string"!=typeof e.port||(t.push(":"),t.push(String(e.port))),t.length?t.join(""):void 0},normalizeComponentEncoding:function(e,t){const n=!0!==t?escape:unescape;return void 0!==e.scheme&&(e.scheme=n(e.scheme)),void 0!==e.userinfo&&(e.userinfo=n(e.userinfo)),void 0!==e.host&&(e.host=n(e.host)),void 0!==e.path&&(e.path=n(e.path)),void 0!==e.query&&(e.query=n(e.query)),void 0!==e.fragment&&(e.fragment=n(e.fragment)),e},removeDotSegments:function(e){const t=[];for(;e.length;)if(e.match(u))e=e.replace(u,"");else if(e.match(h))e=e.replace(h,"/");else if(e.match(d))e=e.replace(d,"/"),t.pop();else if("."===e||".."===e)e="";else{const n=e.match(p);if(!n)throw new Error("Unexpected dot segment condition");{const i=n[0];e=e.slice(i.length),t.push(i)}}return t.join("")},normalizeIPv4:r,normalizeIPv6:a,stringArrayToHexStripped:s}},4845:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(3025),o={keyword:"dependentSchemas",type:"object",schemaType:"object",code:e=>(0,i.validateSchemaDeps)(e)};t.default=o},4870:(e,t,n)=>{"use strict";n.d(t,{Kd:()=>a,Ku:()=>s,me:()=>r});var i=n(4328),o=n(6082);function r(){const e=i.shell.t.columns.bySemTypeAll(o.SEMTYPE.MACROMOLECULE);return null==e?(i.shell.error("Current table does not contain macromolecules"),[]):e}function s(e,t){e.innerHTML="",e.append(t)}function a(e,t,n,i,o){const r=()=>{const o=e.col(t);o&&(o.width=n),i&&(e.props.rowHeight=i)};if(o)return void r();const s=e.onAfterDrawOverlay.subscribe(()=>{s.unsubscribe(),setTimeout(()=>{r()})})}},4914:e=>{"use strict";e.exports={HEX:{0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15}}},4954:(e,t,n)=>{"use strict";n.d(t,{a7:()=>m,if:()=>g,BQ:()=>y,nI:()=>f});var i=n(4328),o=n(7389),r=n(6082),s=n(8070),a=n(2003),l=n(439);const c=31;async function u(e,t,n=!1,o){const s=t.getSeqHandler(e);let a;o??=new Map;const l=s.isHelm()?t.getSeqMonomers(e):Object.keys(s.stats.freq).filter(e=>""!==e);for(let e=0;e<l.length;e++)o.has(l[e])||o.set(l[e],`${o.size+1}`);if(s.isHelm())a=await i.functions.call("HELM:getMolFiles",{col:e}),a=function(e,t,n=!1){const i=new Array(e.length);for(let o=0;o<e.length;o++){let r=0,s=0,a="\n Datagrok macromolecule handler\n\n 0 0 0 0 0 0 999 V3000\nM V30 BEGIN CTAB\n";const l=e.get(o);r=l.indexOf("\n",r)+1,r=l.indexOf("\n",r)+1,r=l.indexOf("\n",r)+1;const u=parseInt(l.substring(r,r+3)),h=parseInt(l.substring(r+3,r+6));a+=`M V30 COUNTS ${u} ${h} 0 0 0\n`,a+="M V30 BEGIN ATOM\n";for(let e=0;e<u;e++){r=l.indexOf("\n",r)+1+c,s=l.indexOf(" ",r);const i=l.substring(r,s);a+=n?`M V30 ${e+1} R${t.get(i)} 0.000 0.000 0 0\n`:`M V30 ${e+1} At 0.000 0.000 0 0 MASS=${t.get(i)}\n`}a+="M V30 END ATOM\n",a+="M V30 BEGIN BOND\n";for(let e=0;e<h;e++){r=l.indexOf("\n",r)+1;const t=parseInt(l.substring(r,r+3).trim()),n=parseInt(l.substring(r+3,r+6).trim());a+=`M V30 ${e+1} ${parseInt(l.substring(r+6,r+9).trim())} ${t} ${n}\n`}a+="M V30 END BOND\n",a+="M V30 END CTAB\n",a+="M END",i[o]=a}return i}(a,o,n);else{a=new Array(e.length);for(let t=0;t<e.length;t++){const e=h(s.getSplitted(t),o,n);a[t]=e}}return r.Column.fromStrings("monomericMols",a)}function h(e,t,n=!1){let i="\n Datagrok macromolecule handler\n\n 0 0 0 0 0 0 999 V3000\nM V30 BEGIN CTAB\n";i+=`M V30 COUNTS ${e.length} ${e.length?e.length-1:0} 0 0 0\n`,i+="M V30 BEGIN ATOM\n";for(let o=0;o<e.length;o++){const r=e.getCanonical(o);r!==l._S&&(i+=n?`M V30 ${o+1} R${t.get(r)} 0.000 0.000 0 0\n`:`M V30 ${o+1} At 0.000 0.000 0 0 MASS=${t.get(r)}\n`)}i+="M V30 END ATOM\n",i+="M V30 BEGIN BOND\n";for(let t=0;t<e.length-1;t++)i+=`M V30 ${t+1} 1 ${t+1} ${t+2}\n`;return i+="M V30 END BOND\n",i+="M V30 END CTAB\n",i+="M END",i}var d=n(4870);const p="substr_helm";class m{seqHelper;units;separator;inputsDiv;substructureInput;separatorInput;editHelmLink;columnsInput;grid;col;dialog;constructor(e,t){this.seqHelper=t,this.col=e[0],this.createUI()}editHelmLinkAction(){(0,d.Ku)(this.inputsDiv,this.grid.root),o.tools.waitForElementInDom(this.grid.root).then(()=>{setTimeout(()=>{this.grid.cell(p,0).element.children[0].dispatchEvent(new KeyboardEvent("keydown",{key:"Enter"}))},100)})}updateInputs(){const e=this.units===a.Hi.HELM?o.divV([this.columnsInput,this.editHelmLink]):this.units===a.Hi.SEPARATOR?o.inputs([this.columnsInput,this.substructureInput,this.separatorInput]):o.inputs([this.columnsInput,this.substructureInput]);(0,d.Ku)(this.inputsDiv,e)}updateNotationDiv(){this.units=this.col.meta.units,this.separator=this.col.getTag(a.gp.separator);const e=this.dialog.root.getElementsByClassName("notation-text")[0];e&&(e.textContent=`Notation: ${this.units}`)}createUI(){const e=i.shell.tv.dataFrame;this.columnsInput=o.input.column("Column",{table:e,value:this.col,onValueChanged:e=>{this.col=e,this.updateNotationDiv(),this.updateInputs()},filter:e=>e.semType===r.SEMTYPE.MACROMOLECULE}),this.substructureInput=o.input.string("Substructure",{value:""}),this.editHelmLink=o.link("Edit helm",()=>this.editHelmLinkAction(),void 0,{style:{position:"relative",left:"95px"}});const t=r.DataFrame.create(1);t.columns.addNewString(p).init(e=>""),t.col(p).semType=this.col.semType,t.col(p).meta.units=a.Hi.HELM,this.grid=t.plot.grid(),this.separatorInput=o.input.string("Separator",{value:this.separator}),this.inputsDiv=o.div(),this.units=this.col.meta.units,this.separator=this.col.getTag(a.gp.separator),this.updateInputs(),this.dialog=o.dialog("Substructure Search").add(o.divV([o.divText(`Notation: ${this.units}`,"notation-text"),this.inputsDiv])).onOK(async()=>{let e,n=this.units===a.Hi.HELM?t.get(p,0):this.substructureInput.value;this.units===a.Hi.SEPARATOR&&this.separatorInput.value!==this.separator&&this.separatorInput.value&&(n=n.replaceAll(this.separatorInput.value,this.separator)),e=this.units===a.Hi.HELM?await g(n,this.col,this.seqHelper):f(n,this.col),this.col.dataFrame.filter.and(e)}).show()}}function f(e,t,n){const i=n?function(e,t){const n=`${t}`.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),i=e.charAt(0)===t,o=e.charAt(e.length-1)===t,r=e.replace(new RegExp(`^${n}|${n}$`,"g"),"");return i?o?`${n}${r}${n}`:`${n}${r}${n}|${n}${r}$`:o?`^${r}${n}|${n}${r}${n}`:`^${r}${n}|${n}${r}${n}|${n}${r}$`}(e,n):e,o=r.BitSet.create(t.length);for(let n=0;n<t.length;n++){const r=t.get(n);(r.match(i)||r===e)&&o.set(n,!0,!1)}return o}async function g(e,t,n){t.version!==t.temp["last-invalidated-version"]&&await y(t,n,!0);const o=r.Column.string("helm",1).init(t=>e);o.semType=r.SEMTYPE.MACROMOLECULE,o.meta.units=a.Hi.HELM;const s=await u(o,n,!0,t.temp["monomers-dict"]);return(await i.functions.call("Chem:searchSubstructure",{molStringsColumn:t.temp["monomeric-mols"],molString:s.get(0),molBlockFailover:""})).get(0)}async function y(e,t,n){const i=r.TaskBarProgressIndicator.create(`Invalidating molfiles for ${e.name}`);try{await(0,s.cb)(10);const i=new Map,o=await u(e,t,n,i);e.temp["monomeric-mols"]=o,e.temp["monomers-dict"]=i,e.temp["last-invalidated-version"]=e.version}finally{i.close()}}},4971:(e,t,n)=>{"use strict";n.d(t,{YS:()=>c,ic:()=>r,lH:()=>l,pY:()=>s,pj:()=>a});var i=n(6082),o=n(9192);const r="Files";async function s(e,t){for(const n of e){const e=await n.listLibraries();if(e.includes(t)||e.includes(`${t}.json`))return n}return null}async function a(){const e=i.Func.find({package:"Bio",name:"getMonomerLibHelper"});if(0===e.length)throw new Error('Package "Bio" must be installed for MonomerLibHelper.');return(await e[0].prepare().call()).getOutputParamValue()}class l{constructor(e,t,n,i,r){this.monomerLib=e,this.symbol=t,this.polymerType=n,this.monomerType=i,this.monomerLinks=r,this.error=null;try{this.monomers=this.monomerLinks.map(e=>{const n=this.monomerLib.getMonomer(this.polymerType,e.symbol);if(!n)throw new Error("Monomer not found: ");if(n.lib?.source!=e.source)throw new Error(`Monomer '${t}' found in different library.`);return n})}catch(e){const[t,n]=(0,o.AP)(e);this.error=t,this.monomers=[]}}}class c{constructor(e,t,n=void 0,i=void 0){this.description=e,this.placeholders=t,this.source=n,this.error=i}updateSets(e,t=!1){t&&(this.placeholders=[]);for(const t of e)t.error||this._updateSetInt(t)}_updateSetInt(e){for(const t of e.placeholders)this.placeholders.push(t)}}},5056:(e,t,n)=>{"use strict";e.exports=function(e){var t=n.nc;t&&e.setAttribute("nonce",t)}},5072:e=>{"use strict";var t=[];function n(e){for(var n=-1,i=0;i<t.length;i++)if(t[i].identifier===e){n=i;break}return n}function i(e,i){for(var r={},s=[],a=0;a<e.length;a++){var l=e[a],c=i.base?l[0]+i.base:l[0],u=r[c]||0,h="".concat(c," ").concat(u);r[c]=u+1;var d=n(h),p={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==d)t[d].references++,t[d].updater(p);else{var m=o(p,i);i.byIndex=a,t.splice(a,0,{identifier:h,updater:m,references:1})}s.push(h)}return s}function o(e,t){var n=t.domAPI(t);return n.update(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap&&t.supports===e.supports&&t.layer===e.layer)return;n.update(e=t)}else n.remove()}}e.exports=function(e,o){var r=i(e=e||[],o=o||{});return function(e){e=e||[];for(var s=0;s<r.length;s++){var a=n(r[s]);t[a].references--}for(var l=i(e,o),c=0;c<r.length;c++){var u=n(r[c]);0===t[u].references&&(t[u].updater(),t.splice(u,1))}r=l}}},5333:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(5765),o=n(9029),r=n(4227),s=n(4227),a={keyword:"patternProperties",type:"object",schemaType:"object",code(e){const{gen:t,schema:n,data:a,parentSchema:l,it:c}=e,{opts:u}=c,h=(0,i.allSchemaProperties)(n),d=h.filter(e=>(0,r.alwaysValidSchema)(c,n[e]));if(0===h.length||d.length===h.length&&(!c.opts.unevaluated||!0===c.props))return;const p=u.strictSchema&&!u.allowMatchingProperties&&l.properties,m=t.name("valid");!0===c.props||c.props instanceof o.Name||(c.props=(0,s.evaluatedPropsToName)(t,c.props));const{props:f}=c;function g(e){for(const t in p)new RegExp(e).test(t)&&(0,r.checkStrictMode)(c,`property ${t} matches pattern ${e} (use allowMatchingProperties)`)}function y(n){t.forIn("key",a,r=>{t.if(o._`${(0,i.usePattern)(e,n)}.test(${r})`,()=>{const i=d.includes(n);i||e.subschema({keyword:"patternProperties",schemaProp:n,dataProp:r,dataPropType:s.Type.Str},m),c.opts.unevaluated&&!0!==f?t.assign(o._`${f}[${r}]`,!0):i||c.allErrors||t.if((0,o.not)(m),()=>t.break())})})}!function(){for(const e of h)p&&g(e),c.allErrors?y(e):(t.var(m,!0),y(e),t.if(m))}()}};t.default=a},5354:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(494),o={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,i.validateTuple)(e,"items")};t.default=o},5413:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(1846),o=n(4845),r=n(2626),s=[i.default,o.default,r.default];t.default=s},5433:(e,t,n)=>{"use strict";n.d(t,{C:()=>h});var i=n(6082),o=n(7389),r=n(4328),s=n(1757),a=n.n(s),l=n(2003);let c=null,u=[];function h(e,t){let n=e??r.shell.t.columns.bySemType("Macromolecule");if(!n)throw new Error("No column with Macromolecule semantic type found");let s=t.getSeqHandler(n),h=s.notation;const d=o.divText("Current notation: "+h,{style:{"text-align":"center","font-weight":"bold","font-size":"14px",padding:"5px"}}),p=[l.Hi.FASTA,l.Hi.SEPARATOR,l.Hi.HELM,l.Hi.BILN],m=o.input.column("Column",{table:r.shell.t,value:n,filter:e=>e.semType===i.SEMTYPE.MACROMOLECULE,nullable:!1,onValueChanged:e=>(n=e,s=t.getSeqHandler(n),h=s.notation,h===l.Hi.HELM&&(y.value="/"),d.textContent="Current notation: "+h,g=p.filter(e=>e!==h),v=o.input.choice("Convert to",{value:g[0],items:g,onValueChanged:b}),b(),c?.clear(),void c?.add(o.div([d,m.root,v.root,y.root])))}),f=["-",".","/"];let g=p.filter(e=>e!==h);const y=o.input.choice("Separator",{value:f[0],items:f}),b=()=>{v.value!==l.Hi.SEPARATOR?a()(y.root).hide():a()(y.root).show()};let v=o.input.choice("Convert to",{value:g[0],items:g,onValueChanged:b});b(),v.onChanged.subscribe(()=>{b()}),null==c&&(c=o.dialog("Convert Sequence Notation").add(o.div([d,m.root,v.root,y.root])).onOK(async()=>{const e=v.value,i=e===l.Hi.SEPARATOR?y.value:void 0;await async function(e,t,n,i){const o=t.getSeqHandler(e).convert(n,i);e.dataFrame.columns.add(o);const s=await r.functions.call("Bio:detectMacromolecule",{col:o});return s&&(o.semType=s),await r.data.detectSemanticTypes(e.dataFrame),o}(n,t,e,i)}).show({x:350,y:100}),u.push(c.onClose.subscribe(e=>{u.forEach(e=>{e.unsubscribe()}),u=[],c=null})))}},5457:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validateAdditionalItems=void 0;const i=n(9029),o=n(4227),r={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:{message:({params:{len:e}})=>i.str`must NOT have more than ${e} items`,params:({params:{len:e}})=>i._`{limit: ${e}}`},code(e){const{parentSchema:t,it:n}=e,{items:i}=t;Array.isArray(i)?s(e,i):(0,o.checkStrictMode)(n,'"additionalItems" is ignored when "items" is not an array of schemas')}};function s(e,t){const{gen:n,schema:r,data:s,keyword:a,it:l}=e;l.items=!0;const c=n.const("len",i._`${s}.length`);if(!1===r)e.setParams({len:t.length}),e.pass(i._`${c} <= ${t.length}`);else if("object"==typeof r&&!(0,o.alwaysValidSchema)(l,r)){const r=n.var("valid",i._`${c} <= ${t.length}`);n.if((0,i.not)(r),()=>function(r){n.forRange("i",t.length,c,t=>{e.subschema({keyword:a,dataProp:t,dataPropType:o.Type.Num},r),l.allErrors||n.if((0,i.not)(r),()=>n.break())})}(r)),e.ok(r)}}t.validateAdditionalItems=s,t.default=r},5488:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var i=n(1354),o=n.n(i),r=n(6314),s=n.n(r)()(o());s.push([e.id,"\n.ui-form.ui-tooltip .ui-input-root > label.ui-input-label:not(:empty) {\n /* min-width: 30px; /* Breaks right margin /**/\n}\n\n.ui-form.ui-tooltip .ui-input-root > div.ui-input-text:not(:empty) {\n margin-top: 6px;\n}","",{version:3,sources:["webpack://./css/cell-renderer.css"],names:[],mappings:";AACA;IACI,8CAA8C;AAClD;;AAEA;IACI,eAAe;AACnB",sourcesContent:["\n.ui-form.ui-tooltip .ui-input-root > label.ui-input-label:not(:empty) {\n /* min-width: 30px; /* Breaks right margin /**/\n}\n\n.ui-form.ui-tooltip .ui-input-root > div.ui-input-text:not(:empty) {\n margin-top: 6px;\n}"],sourceRoot:""}]);const a=s},5520:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(2476),o=n(3252),r=n(2721),s=n(3799),a=[i.default,o.default,r.default,s.default];t.default=a},5540:(e,t,n)=>{"use strict";e=n.hmd(e);var i,o=(i="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0,function(e={}){var t,n,o=void 0!==e?e:{};o.ready=new Promise(function(e,i){t=e,n=i});var r,s=Object.assign({},o),a="object"==typeof window,l="function"==typeof importScripts,c=("object"==typeof process&&"object"==typeof process.versions&&process.versions.node,"");(a||l)&&(l?c=self.location.href:"undefined"!=typeof document&&document.currentScript&&(c=document.currentScript.src),i&&(c=i),c=0!==c.indexOf("blob:")?c.substr(0,c.replace(/[?#].*/,"").lastIndexOf("/")+1):"",l&&(r=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)})),o.print||console.log.bind(console);var u,h,d=o.printErr||console.warn.bind(console);Object.assign(o,s),s=null,o.arguments&&o.arguments,o.thisProgram&&o.thisProgram,o.quit&&o.quit,o.wasmBinary&&(u=o.wasmBinary),o.noExitRuntime,"object"!=typeof WebAssembly&&_("no native wasm support detected");var p,m,f,g=!1;function y(){var e=h.buffer;o.HEAP8=p=new Int8Array(e),o.HEAP16=new Int16Array(e),o.HEAP32=new Int32Array(e),o.HEAPU8=m=new Uint8Array(e),o.HEAPU16=new Uint16Array(e),o.HEAPU32=f=new Uint32Array(e),o.HEAPF32=new Float32Array(e),o.HEAPF64=new Float64Array(e)}var b=[],v=[],w=[];function C(e){b.unshift(e)}function S(e){w.unshift(e)}var A,x,M=0,T=null,E=null;function _(e){o.onAbort&&o.onAbort(e),d(e="Aborted("+e+")"),g=!0,e+=". Build with -sASSERTIONS for more info.";var t=new WebAssembly.RuntimeError(e);throw n(t),t}function I(e){return e.startsWith("data:application/octet-stream;base64,")}function L(e){try{if(e==A&&u)return new Uint8Array(u);if(r)return r(e);throw"both async and sync fetching of the wasm failed"}catch(e){_(e)}}function N(e,t,n){return function(e){return u||!a&&!l||"function"!=typeof fetch?Promise.resolve().then(function(){return L(e)}):fetch(e,{credentials:"same-origin"}).then(function(t){if(!t.ok)throw"failed to load wasm binary file at '"+e+"'";return t.arrayBuffer()}).catch(function(){return L(e)})}(e).then(function(e){return WebAssembly.instantiate(e,t)}).then(function(e){return e}).then(n,function(e){d("failed to asynchronously prepare wasm: "+e),_(e)})}function P(e){for(;e.length>0;)e.shift()(o)}function R(e){this.excPtr=e,this.ptr=e-24,this.set_type=function(e){f[this.ptr+4>>2]=e},this.get_type=function(){return f[this.ptr+4>>2]},this.set_destructor=function(e){f[this.ptr+8>>2]=e},this.get_destructor=function(){return f[this.ptr+8>>2]},this.set_caught=function(e){e=e?1:0,p[this.ptr+12|0]=e},this.get_caught=function(){return 0!=p[this.ptr+12|0]},this.set_rethrown=function(e){e=e?1:0,p[this.ptr+13|0]=e},this.get_rethrown=function(){return 0!=p[this.ptr+13|0]},this.init=function(e,t){this.set_adjusted_ptr(0),this.set_type(e),this.set_destructor(t)},this.set_adjusted_ptr=function(e){f[this.ptr+16>>2]=e},this.get_adjusted_ptr=function(){return f[this.ptr+16>>2]},this.get_exception_ptr=function(){if(W(this.get_type()))return f[this.excPtr>>2];var e=this.get_adjusted_ptr();return 0!==e?e:this.excPtr}}function $(e){var t=h.buffer;try{return h.grow(e-t.byteLength+65535>>>16),y(),1}catch(e){}}function O(e){return o["_"+e]}I(A="wasmDbscan.wasm")||(x=A,A=o.locateFile?o.locateFile(x,c):c+x);var k="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function H(e,t,n,i,o){var r={string:e=>{var t=0;return null!=e&&0!==e&&(t=function(e){var t=function(e){for(var t=0,n=0;n<e.length;++n){var i=e.charCodeAt(n);i<=127?t++:i<=2047?t+=2:i>=55296&&i<=57343?(t+=4,++n):t+=3}return t}(e)+1,n=V(t);return function(e,t,n){!function(e,t,n,i){if(!(i>0))return 0;for(var o=n+i-1,r=0;r<e.length;++r){var s=e.charCodeAt(r);if(s>=55296&&s<=57343&&(s=65536+((1023&s)<<10)|1023&e.charCodeAt(++r)),s<=127){if(n>=o)break;t[n++]=s}else if(s<=2047){if(n+1>=o)break;t[n++]=192|s>>6,t[n++]=128|63&s}else if(s<=65535){if(n+2>=o)break;t[n++]=224|s>>12,t[n++]=128|s>>6&63,t[n++]=128|63&s}else{if(n+3>=o)break;t[n++]=240|s>>18,t[n++]=128|s>>12&63,t[n++]=128|s>>6&63,t[n++]=128|63&s}}t[n]=0}(e,m,t,n)}(e,n,t),n}(e)),t},array:e=>{var t,n,i=V(e.length);return t=e,n=i,p.set(t,n),i}},s=O(e),a=[],l=0;if(i)for(var c=0;c<i.length;c++){var u=r[n[c]];u?(0===l&&(l=G()),a[c]=u(i[c])):a[c]=i[c]}var h=s.apply(null,a);return function(e){return 0!==l&&D(l),function(e){return"string"===t?(n=e)?function(e,t,n){for(var i=t+n,o=t;e[o]&&!(o>=i);)++o;if(o-t>16&&e.buffer&&k)return k.decode(e.subarray(t,o));for(var r="";t<o;){var s=e[t++];if(128&s){var a=63&e[t++];if(192!=(224&s)){var l=63&e[t++];if((s=224==(240&s)?(15&s)<<12|a<<6|l:(7&s)<<18|a<<12|l<<6|63&e[t++])<65536)r+=String.fromCharCode(s);else{var c=s-65536;r+=String.fromCharCode(55296|c>>10,56320|1023&c)}}else r+=String.fromCharCode((31&s)<<6|a)}else r+=String.fromCharCode(s)}return r}(m,n,i):"":"boolean"===t?Boolean(e):e;var n,i}(e)}(h)}var B,F={__cxa_throw:function(e,t,n){throw new R(e).init(t,n),e},abort:function(){_("")},emscripten_memcpy_big:function(e,t,n){m.copyWithin(e,t,t+n)},emscripten_resize_heap:function(e){var t=m.length,n=2147483648;if((e>>>=0)>n)return!1;let i=(e,t)=>e+(t-e%t)%t;for(var o=1;o<=4;o*=2){var r=t*(1+.2/o);if(r=Math.min(r,e+100663296),$(Math.min(n,i(Math.max(e,r),65536))))return!0}return!1}},G=(function(){var e,t,i,r,s={env:F,wasi_snapshot_preview1:F};function a(e,t){var n,i=e.exports;return o.asm=i,h=o.asm.memory,y(),o.asm.__indirect_function_table,n=o.asm.__wasm_call_ctors,v.unshift(n),function(){if(M--,o.monitorRunDependencies&&o.monitorRunDependencies(M),0==M&&(null!==T&&(clearInterval(T),T=null),E)){var e=E;E=null,e()}}(),i}if(M++,o.monitorRunDependencies&&o.monitorRunDependencies(M),o.instantiateWasm)try{return o.instantiateWasm(s,a)}catch(e){d("Module.instantiateWasm callback failed with error: "+e),n(e)}(e=u,t=A,i=s,r=function(e){a(e.instance)},e||"function"!=typeof WebAssembly.instantiateStreaming||I(t)||"function"!=typeof fetch?N(t,i,r):fetch(t,{credentials:"same-origin"}).then(function(e){return WebAssembly.instantiateStreaming(e,i).then(r,function(e){return d("wasm streaming compile failed: "+e),d("falling back to ArrayBuffer instantiation"),N(t,i,r)})})).catch(n)}(),o._dbscan=function(){return(o._dbscan=o.asm.dbscan).apply(null,arguments)},o._malloc=function(){return(o._malloc=o.asm.malloc).apply(null,arguments)},o._free=function(){return(o._free=o.asm.free).apply(null,arguments)},function(){return(G=o.asm.stackSave).apply(null,arguments)}),D=function(){return(D=o.asm.stackRestore).apply(null,arguments)},V=function(){return(V=o.asm.stackAlloc).apply(null,arguments)},W=function(){return(W=o.asm.__cxa_is_pointer_type).apply(null,arguments)};function j(){function e(){B||(B=!0,o.calledRun=!0,g||(P(v),t(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),function(){if(o.postRun)for("function"==typeof o.postRun&&(o.postRun=[o.postRun]);o.postRun.length;)S(o.postRun.shift());P(w)}()))}M>0||(function(){if(o.preRun)for("function"==typeof o.preRun&&(o.preRun=[o.preRun]);o.preRun.length;)C(o.preRun.shift());P(b)}(),M>0||(o.setStatus?(o.setStatus("Running..."),setTimeout(function(){setTimeout(function(){o.setStatus("")},1),e()},1)):e()))}if(o.ccall=H,o.cwrap=function(e,t,n,i){var o=!n||n.every(e=>"number"===e||"boolean"===e);return"string"!==t&&o&&!i?O(e):function(){return H(e,t,n,arguments)}},E=function e(){B||j(),B||(E=e)},o.preInit)for("function"==typeof o.preInit&&(o.preInit=[o.preInit]);o.preInit.length>0;)o.preInit.pop()();return j(),e.ready});"object"==typeof exports?e.exports=o:"function"==typeof define&&n.amdO?define([],function(){return o}):"object"==typeof exports&&(exports.exportCppDbscanLib=o)},5553:(e,t,n)=>{"use strict";n.d(t,{Qc:()=>S,WN:()=>A});var i=n(1991),o=n.n(i);const r="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,s=new Set,a="object"==typeof process&&process?process:{},l=(e,t,n,i)=>{"function"==typeof a.emitWarning?a.emitWarning(e,t,n,i):console.error(`[${n}] ${t}: ${e}`)};let c=globalThis.AbortController,u=globalThis.AbortSignal;if(void 0===c){u=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(e,t){this._onabort.push(t)}},c=class{constructor(){t()}signal=new u;abort(e){if(!this.signal.aborted){this.signal.reason=e,this.signal.aborted=!0;for(const t of this.signal._onabort)t(e);this.signal.onabort?.(e)}}};let e="1"!==a.env?.LRU_CACHE_IGNORE_AC_WARNING;const t=()=>{e&&(e=!1,l("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",t))}}Symbol("type");const h=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),d=e=>h(e)?e<=Math.pow(2,8)?Uint8Array:e<=Math.pow(2,16)?Uint16Array:e<=Math.pow(2,32)?Uint32Array:e<=Number.MAX_SAFE_INTEGER?p:null:null;class p extends Array{constructor(e){super(e),this.fill(0)}}class m{heap;length;static#e=!1;static create(e){const t=d(e);if(!t)return[];m.#e=!0;const n=new m(e,t);return m.#e=!1,n}constructor(e,t){if(!m.#e)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}}class f{#t;#n;#i;#o;#r;#s;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#a;#l;#c;#u;#h;#d;#p;#m;#f;#g;#y;#b;#v;#w;#C;#S;#A;static unsafeExposeInternals(e){return{starts:e.#v,ttls:e.#w,sizes:e.#b,keyMap:e.#c,keyList:e.#u,valList:e.#h,next:e.#d,prev:e.#p,get head(){return e.#m},get tail(){return e.#f},free:e.#g,isBackgroundFetch:t=>e.#x(t),backgroundFetch:(t,n,i,o)=>e.#M(t,n,i,o),moveToTail:t=>e.#T(t),indexes:t=>e.#E(t),rindexes:t=>e.#_(t),isStale:t=>e.#I(t)}}get max(){return this.#t}get maxSize(){return this.#n}get calculatedSize(){return this.#l}get size(){return this.#a}get fetchMethod(){return this.#r}get memoMethod(){return this.#s}get dispose(){return this.#i}get disposeAfter(){return this.#o}constructor(e){const{max:t=0,ttl:n,ttlResolution:i=1,ttlAutopurge:o,updateAgeOnGet:r,updateAgeOnHas:a,allowStale:c,dispose:u,disposeAfter:p,noDisposeOnSet:g,noUpdateTTL:y,maxSize:b=0,maxEntrySize:v=0,sizeCalculation:w,fetchMethod:C,memoMethod:S,noDeleteOnFetchRejection:A,noDeleteOnStaleGet:x,allowStaleOnFetchRejection:M,allowStaleOnFetchAbort:T,ignoreFetchAbort:E}=e;if(0!==t&&!h(t))throw new TypeError("max option must be a nonnegative integer");const _=t?d(t):Array;if(!_)throw new Error("invalid max value: "+t);if(this.#t=t,this.#n=b,this.maxEntrySize=v||this.#n,this.sizeCalculation=w,this.sizeCalculation){if(!this.#n&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if("function"!=typeof this.sizeCalculation)throw new TypeError("sizeCalculation set to non-function")}if(void 0!==S&&"function"!=typeof S)throw new TypeError("memoMethod must be a function if defined");if(this.#s=S,void 0!==C&&"function"!=typeof C)throw new TypeError("fetchMethod must be a function if specified");if(this.#r=C,this.#S=!!C,this.#c=new Map,this.#u=new Array(t).fill(void 0),this.#h=new Array(t).fill(void 0),this.#d=new _(t),this.#p=new _(t),this.#m=0,this.#f=0,this.#g=m.create(t),this.#a=0,this.#l=0,"function"==typeof u&&(this.#i=u),"function"==typeof p?(this.#o=p,this.#y=[]):(this.#o=void 0,this.#y=void 0),this.#C=!!this.#i,this.#A=!!this.#o,this.noDisposeOnSet=!!g,this.noUpdateTTL=!!y,this.noDeleteOnFetchRejection=!!A,this.allowStaleOnFetchRejection=!!M,this.allowStaleOnFetchAbort=!!T,this.ignoreFetchAbort=!!E,0!==this.maxEntrySize){if(0!==this.#n&&!h(this.#n))throw new TypeError("maxSize must be a positive integer if specified");if(!h(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#L()}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!x,this.updateAgeOnGet=!!r,this.updateAgeOnHas=!!a,this.ttlResolution=h(i)||0===i?i:1,this.ttlAutopurge=!!o,this.ttl=n||0,this.ttl){if(!h(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#N()}if(0===this.#t&&0===this.ttl&&0===this.#n)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#t&&!this.#n){const e="LRU_CACHE_UNBOUNDED";(e=>!s.has(e))(e)&&(s.add(e),l("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",e,f))}}getRemainingTTL(e){return this.#c.has(e)?1/0:0}#N(){const e=new p(this.#t),t=new p(this.#t);this.#w=e,this.#v=t,this.#P=(n,i,o=r.now())=>{if(t[n]=0!==i?o:0,e[n]=i,0!==i&&this.ttlAutopurge){const e=setTimeout(()=>{this.#I(n)&&this.#R(this.#u[n],"expire")},i+1);e.unref&&e.unref()}},this.#$=n=>{t[n]=0!==e[n]?r.now():0},this.#O=(o,r)=>{if(e[r]){const s=e[r],a=t[r];if(!s||!a)return;o.ttl=s,o.start=a,o.now=n||i();const l=o.now-a;o.remainingTTL=s-l}};let n=0;const i=()=>{const e=r.now();if(this.ttlResolution>0){n=e;const t=setTimeout(()=>n=0,this.ttlResolution);t.unref&&t.unref()}return e};this.getRemainingTTL=o=>{const r=this.#c.get(o);if(void 0===r)return 0;const s=e[r],a=t[r];return s&&a?s-((n||i())-a):1/0},this.#I=o=>{const r=t[o],s=e[o];return!!s&&!!r&&(n||i())-r>s}}#$=()=>{};#O=()=>{};#P=()=>{};#I=()=>!1;#L(){const e=new p(this.#t);this.#l=0,this.#b=e,this.#k=t=>{this.#l-=e[t],e[t]=0},this.#H=(e,t,n,i)=>{if(this.#x(t))return 0;if(!h(n)){if(!i)throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");if("function"!=typeof i)throw new TypeError("sizeCalculation must be a function");if(n=i(t,e),!h(n))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return n},this.#B=(t,n,i)=>{if(e[t]=n,this.#n){const n=this.#n-e[t];for(;this.#l>n;)this.#F(!0)}this.#l+=e[t],i&&(i.entrySize=n,i.totalCalculatedSize=this.#l)}}#k=e=>{};#B=(e,t,n)=>{};#H=(e,t,n,i)=>{if(n||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#E({allowStale:e=this.allowStale}={}){if(this.#a)for(let t=this.#f;this.#G(t)&&(!e&&this.#I(t)||(yield t),t!==this.#m);)t=this.#p[t]}*#_({allowStale:e=this.allowStale}={}){if(this.#a)for(let t=this.#m;this.#G(t)&&(!e&&this.#I(t)||(yield t),t!==this.#f);)t=this.#d[t]}#G(e){return void 0!==e&&this.#c.get(this.#u[e])===e}*entries(){for(const e of this.#E())void 0===this.#h[e]||void 0===this.#u[e]||this.#x(this.#h[e])||(yield[this.#u[e],this.#h[e]])}*rentries(){for(const e of this.#_())void 0===this.#h[e]||void 0===this.#u[e]||this.#x(this.#h[e])||(yield[this.#u[e],this.#h[e]])}*keys(){for(const e of this.#E()){const t=this.#u[e];void 0===t||this.#x(this.#h[e])||(yield t)}}*rkeys(){for(const e of this.#_()){const t=this.#u[e];void 0===t||this.#x(this.#h[e])||(yield t)}}*values(){for(const e of this.#E())void 0===this.#h[e]||this.#x(this.#h[e])||(yield this.#h[e])}*rvalues(){for(const e of this.#_())void 0===this.#h[e]||this.#x(this.#h[e])||(yield this.#h[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,t={}){for(const n of this.#E()){const i=this.#h[n],o=this.#x(i)?i.__staleWhileFetching:i;if(void 0!==o&&e(o,this.#u[n],this))return this.get(this.#u[n],t)}}forEach(e,t=this){for(const n of this.#E()){const i=this.#h[n],o=this.#x(i)?i.__staleWhileFetching:i;void 0!==o&&e.call(t,o,this.#u[n],this)}}rforEach(e,t=this){for(const n of this.#_()){const i=this.#h[n],o=this.#x(i)?i.__staleWhileFetching:i;void 0!==o&&e.call(t,o,this.#u[n],this)}}purgeStale(){let e=!1;for(const t of this.#_({allowStale:!0}))this.#I(t)&&(this.#R(this.#u[t],"expire"),e=!0);return e}info(e){const t=this.#c.get(e);if(void 0===t)return;const n=this.#h[t],i=this.#x(n)?n.__staleWhileFetching:n;if(void 0===i)return;const o={value:i};if(this.#w&&this.#v){const e=this.#w[t],n=this.#v[t];if(e&&n){const t=e-(r.now()-n);o.ttl=t,o.start=Date.now()}}return this.#b&&(o.size=this.#b[t]),o}dump(){const e=[];for(const t of this.#E({allowStale:!0})){const n=this.#u[t],i=this.#h[t],o=this.#x(i)?i.__staleWhileFetching:i;if(void 0===o||void 0===n)continue;const s={value:o};if(this.#w&&this.#v){s.ttl=this.#w[t];const e=r.now()-this.#v[t];s.start=Math.floor(Date.now()-e)}this.#b&&(s.size=this.#b[t]),e.unshift([n,s])}return e}load(e){this.clear();for(const[t,n]of e){if(n.start){const e=Date.now()-n.start;n.start=r.now()-e}this.set(t,n.value,n)}}set(e,t,n={}){if(void 0===t)return this.delete(e),this;const{ttl:i=this.ttl,start:o,noDisposeOnSet:r=this.noDisposeOnSet,sizeCalculation:s=this.sizeCalculation,status:a}=n;let{noUpdateTTL:l=this.noUpdateTTL}=n;const c=this.#H(e,t,n.size||0,s);if(this.maxEntrySize&&c>this.maxEntrySize)return a&&(a.set="miss",a.maxEntrySizeExceeded=!0),this.#R(e,"set"),this;let u=0===this.#a?void 0:this.#c.get(e);if(void 0===u)u=0===this.#a?this.#f:0!==this.#g.length?this.#g.pop():this.#a===this.#t?this.#F(!1):this.#a,this.#u[u]=e,this.#h[u]=t,this.#c.set(e,u),this.#d[this.#f]=u,this.#p[u]=this.#f,this.#f=u,this.#a++,this.#B(u,c,a),a&&(a.set="add"),l=!1;else{this.#T(u);const n=this.#h[u];if(t!==n){if(this.#S&&this.#x(n)){n.__abortController.abort(new Error("replaced"));const{__staleWhileFetching:t}=n;void 0===t||r||(this.#C&&this.#i?.(t,e,"set"),this.#A&&this.#y?.push([t,e,"set"]))}else r||(this.#C&&this.#i?.(n,e,"set"),this.#A&&this.#y?.push([n,e,"set"]));if(this.#k(u),this.#B(u,c,a),this.#h[u]=t,a){a.set="replace";const e=n&&this.#x(n)?n.__staleWhileFetching:n;void 0!==e&&(a.oldValue=e)}}else a&&(a.set="update")}if(0===i||this.#w||this.#N(),this.#w&&(l||this.#P(u,i,o),a&&this.#O(a,u)),!r&&this.#A&&this.#y){const e=this.#y;let t;for(;t=e?.shift();)this.#o?.(...t)}return this}pop(){try{for(;this.#a;){const e=this.#h[this.#m];if(this.#F(!0),this.#x(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(void 0!==e)return e}}finally{if(this.#A&&this.#y){const e=this.#y;let t;for(;t=e?.shift();)this.#o?.(...t)}}}#F(e){const t=this.#m,n=this.#u[t],i=this.#h[t];return this.#S&&this.#x(i)?i.__abortController.abort(new Error("evicted")):(this.#C||this.#A)&&(this.#C&&this.#i?.(i,n,"evict"),this.#A&&this.#y?.push([i,n,"evict"])),this.#k(t),e&&(this.#u[t]=void 0,this.#h[t]=void 0,this.#g.push(t)),1===this.#a?(this.#m=this.#f=0,this.#g.length=0):this.#m=this.#d[t],this.#c.delete(n),this.#a--,t}has(e,t={}){const{updateAgeOnHas:n=this.updateAgeOnHas,status:i}=t,o=this.#c.get(e);if(void 0!==o){const e=this.#h[o];if(this.#x(e)&&void 0===e.__staleWhileFetching)return!1;if(!this.#I(o))return n&&this.#$(o),i&&(i.has="hit",this.#O(i,o)),!0;i&&(i.has="stale",this.#O(i,o))}else i&&(i.has="miss");return!1}peek(e,t={}){const{allowStale:n=this.allowStale}=t,i=this.#c.get(e);if(void 0===i||!n&&this.#I(i))return;const o=this.#h[i];return this.#x(o)?o.__staleWhileFetching:o}#M(e,t,n,i){const o=void 0===t?void 0:this.#h[t];if(this.#x(o))return o;const r=new c,{signal:s}=n;s?.addEventListener("abort",()=>r.abort(s.reason),{signal:r.signal});const a={signal:r.signal,options:n,context:i},l=(i,o=!1)=>{const{aborted:s}=r.signal,l=n.ignoreFetchAbort&&void 0!==i;if(n.status&&(s&&!o?(n.status.fetchAborted=!0,n.status.fetchError=r.signal.reason,l&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),s&&!l&&!o)return u(r.signal.reason);const c=h;return this.#h[t]===h&&(void 0===i?c.__staleWhileFetching?this.#h[t]=c.__staleWhileFetching:this.#R(e,"fetch"):(n.status&&(n.status.fetchUpdated=!0),this.set(e,i,a.options))),i},u=i=>{const{aborted:o}=r.signal,s=o&&n.allowStaleOnFetchAbort,a=s||n.allowStaleOnFetchRejection,l=a||n.noDeleteOnFetchRejection,c=h;if(this.#h[t]===h&&(l&&void 0!==c.__staleWhileFetching?s||(this.#h[t]=c.__staleWhileFetching):this.#R(e,"fetch")),a)return n.status&&void 0!==c.__staleWhileFetching&&(n.status.returnedStale=!0),c.__staleWhileFetching;if(c.__returned===c)throw i};n.status&&(n.status.fetchDispatched=!0);const h=new Promise((t,i)=>{const s=this.#r?.(e,o,a);s&&s instanceof Promise&&s.then(e=>t(void 0===e?void 0:e),i),r.signal.addEventListener("abort",()=>{n.ignoreFetchAbort&&!n.allowStaleOnFetchAbort||(t(void 0),n.allowStaleOnFetchAbort&&(t=e=>l(e,!0)))})}).then(l,e=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=e),u(e))),d=Object.assign(h,{__abortController:r,__staleWhileFetching:o,__returned:void 0});return void 0===t?(this.set(e,d,{...a.options,status:void 0}),t=this.#c.get(e)):this.#h[t]=d,d}#x(e){if(!this.#S)return!1;const t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof c}async fetch(e,t={}){const{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:r=this.ttl,noDisposeOnSet:s=this.noDisposeOnSet,size:a=0,sizeCalculation:l=this.sizeCalculation,noUpdateTTL:c=this.noUpdateTTL,noDeleteOnFetchRejection:u=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:h=this.allowStaleOnFetchRejection,ignoreFetchAbort:d=this.ignoreFetchAbort,allowStaleOnFetchAbort:p=this.allowStaleOnFetchAbort,context:m,forceRefresh:f=!1,status:g,signal:y}=t;if(!this.#S)return g&&(g.fetch="get"),this.get(e,{allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:o,status:g});const b={allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:o,ttl:r,noDisposeOnSet:s,size:a,sizeCalculation:l,noUpdateTTL:c,noDeleteOnFetchRejection:u,allowStaleOnFetchRejection:h,allowStaleOnFetchAbort:p,ignoreFetchAbort:d,status:g,signal:y};let v=this.#c.get(e);if(void 0===v){g&&(g.fetch="miss");const t=this.#M(e,v,b,m);return t.__returned=t}{const t=this.#h[v];if(this.#x(t)){const e=n&&void 0!==t.__staleWhileFetching;return g&&(g.fetch="inflight",e&&(g.returnedStale=!0)),e?t.__staleWhileFetching:t.__returned=t}const o=this.#I(v);if(!f&&!o)return g&&(g.fetch="hit"),this.#T(v),i&&this.#$(v),g&&this.#O(g,v),t;const r=this.#M(e,v,b,m),s=void 0!==r.__staleWhileFetching&&n;return g&&(g.fetch=o?"stale":"refresh",s&&o&&(g.returnedStale=!0)),s?r.__staleWhileFetching:r.__returned=r}}async forceFetch(e,t={}){const n=await this.fetch(e,t);if(void 0===n)throw new Error("fetch() returned undefined");return n}memo(e,t={}){const n=this.#s;if(!n)throw new Error("no memoMethod provided to constructor");const{context:i,forceRefresh:o,...r}=t,s=this.get(e,r);if(!o&&void 0!==s)return s;const a=n(e,s,{options:r,context:i});return this.set(e,a,r),a}get(e,t={}){const{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:r}=t,s=this.#c.get(e);if(void 0!==s){const t=this.#h[s],a=this.#x(t);return r&&this.#O(r,s),this.#I(s)?(r&&(r.get="stale"),a?(r&&n&&void 0!==t.__staleWhileFetching&&(r.returnedStale=!0),n?t.__staleWhileFetching:void 0):(o||this.#R(e,"expire"),r&&n&&(r.returnedStale=!0),n?t:void 0)):(r&&(r.get="hit"),a?t.__staleWhileFetching:(this.#T(s),i&&this.#$(s),t))}r&&(r.get="miss")}#D(e,t){this.#p[t]=e,this.#d[e]=t}#T(e){e!==this.#f&&(e===this.#m?this.#m=this.#d[e]:this.#D(this.#p[e],this.#d[e]),this.#D(this.#f,e),this.#f=e)}delete(e){return this.#R(e,"delete")}#R(e,t){let n=!1;if(0!==this.#a){const i=this.#c.get(e);if(void 0!==i)if(n=!0,1===this.#a)this.#V(t);else{this.#k(i);const n=this.#h[i];if(this.#x(n)?n.__abortController.abort(new Error("deleted")):(this.#C||this.#A)&&(this.#C&&this.#i?.(n,e,t),this.#A&&this.#y?.push([n,e,t])),this.#c.delete(e),this.#u[i]=void 0,this.#h[i]=void 0,i===this.#f)this.#f=this.#p[i];else if(i===this.#m)this.#m=this.#d[i];else{const e=this.#p[i];this.#d[e]=this.#d[i];const t=this.#d[i];this.#p[t]=this.#p[i]}this.#a--,this.#g.push(i)}}if(this.#A&&this.#y?.length){const e=this.#y;let t;for(;t=e?.shift();)this.#o?.(...t)}return n}clear(){return this.#V("delete")}#V(e){for(const t of this.#_({allowStale:!0})){const n=this.#h[t];if(this.#x(n))n.__abortController.abort(new Error("deleted"));else{const i=this.#u[t];this.#C&&this.#i?.(n,i,e),this.#A&&this.#y?.push([n,i,e])}}if(this.#c.clear(),this.#h.fill(void 0),this.#u.fill(void 0),this.#w&&this.#v&&(this.#w.fill(0),this.#v.fill(0)),this.#b&&this.#b.fill(0),this.#m=0,this.#f=0,this.#g.length=0,this.#l=0,this.#a=0,this.#A&&this.#y){const e=this.#y;let t;for(;t=e?.shift();)this.#o?.(...t)}}}function g(e){window.$monomerHover=e}var y=n(2003),b=n(6077),v=n(3561),w=n(9235);const C="MonomerHoverLinks";async function S(e,t,n,i,r,s=!1){const a=i.getSeqHandler(e),l=a.alphabet==y.YI.RNA||a.alphabet==y.YI.DNA,c=a.isHelm()&&l,u=!a.isHelm()&&l,h=e=>null==e?null:c?s?e:Math.floor(e/3):u&&s?3*e+1:e,d=s?await i.getHelmToMolfileConverter(n):null,p=new f({max:100});function m(e,t){const a=e.get(t);if(null==a)return null;let l=p.get(a);return l||p.set(a,l=function(e,t){const a=i.getSeqHandler(e);if(s){const e=a.getHelm(t);return i.helmToAtomicLevelSingle(e,d,!1,!1).monomers}{const e=a.getSplitted(t),i=a.defaultBiotype,s=o().count(0).take(e.length).map(t=>({position:t,symbol:e.getCanonical(t),biotype:i})).toArray(),l=a.alphabet,c=l==y.YI.RNA||l==y.YI.DNA?"RNA":"PEPTIDE",u=(0,b.eM)([s],c,l,n,r);return(0,v.gU)(s,u,l,c).monomers}}(e,t)),l}const S={targetCol:t,handler:(t,i,o)=>{const r=o.grid,s=t.tableRowIndex,a=t.gridRow,l=r.cell(o.name,a),c=null!==(u=window.$monomerHover)&&void 0!==u?u:null;var u;if(!c||c&&(c.dataFrameId!=e.dataFrame.id||c.gridRowIdx!=a||c.seqColName!=e.name||c.seqPosition!=i?.position)){if(c&&(g(null),c.gridCell.render()),!i)return g(null),!0;g({gridCell:l,dataFrameId:e.dataFrame.id,gridRowIdx:a,seqColName:e.name,seqPosition:h(i?.position)??-1,getSubstruct:()=>{if(!i||"*"===i.symbol)return;const t=m(e,s);if(!t)return;const o=t.get(h(i?.position));return o?(0,w.H)([o],n):{atoms:[],bonds:[],highlightAtomColors:[],highlightBondColors:[]}}}),l.render()}return!0},getSubstruct:i=>{if("true"!=t.getTag(".sequence-src-highlight-monomers"))return;if(null==i)return;if(!e.get(i))return;const o=m(e,i);return o?(0,w.H)(o.values(),n):void 0}};return function(e,t){let n=e[C];n||(n=e[C]=[]),n.push(t),e[C]=n}(e.temp,S),function(e,t){let n=e["substruct-providers"];n||(n=e["substruct-providers"]=[]),n.push(t),e["substruct-providers"]=n}(t.temp,S),S}function A(e,t){try{const n=e.tableColumn;if(!n)return;const i=function(e){return e.temp[C]??[]}(n);for(let n=i.length-1;n>=0;--n){const o=i[n],r=e.grid.col(o.targetCol.name);if(r&&!o.handler(e,t,r))break}}catch(e){console.error(e)}}},5707:e=>{"use strict";e.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/meta/meta-data","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/meta-data":true},"$dynamicAnchor":"meta","title":"Meta-data vocabulary meta-schema","type":["object","boolean"],"properties":{"title":{"type":"string"},"description":{"type":"string"},"default":true,"deprecated":{"type":"boolean","default":false},"readOnly":{"type":"boolean","default":false},"writeOnly":{"type":"boolean","default":false},"examples":{"type":"array","items":true}}}')},5765:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validateUnion=t.validateArray=t.usePattern=t.callValidateCode=t.schemaProperties=t.allSchemaProperties=t.noPropertyInData=t.propertyInData=t.isOwnProperty=t.hasPropFunc=t.reportMissingProp=t.checkMissingProp=t.checkReportMissingProp=void 0;const i=n(9029),o=n(4227),r=n(2023),s=n(4227);function a(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:i._`Object.prototype.hasOwnProperty`})}function l(e,t,n){return i._`${a(e)}.call(${t}, ${n})`}function c(e,t,n,o){const r=i._`${t}${(0,i.getProperty)(n)} === undefined`;return o?(0,i.or)(r,(0,i.not)(l(e,t,n))):r}function u(e){return e?Object.keys(e).filter(e=>"__proto__"!==e):[]}t.checkReportMissingProp=function(e,t){const{gen:n,data:o,it:r}=e;n.if(c(n,o,t,r.opts.ownProperties),()=>{e.setParams({missingProperty:i._`${t}`},!0),e.error()})},t.checkMissingProp=function({gen:e,data:t,it:{opts:n}},o,r){return(0,i.or)(...o.map(o=>(0,i.and)(c(e,t,o,n.ownProperties),i._`${r} = ${o}`)))},t.reportMissingProp=function(e,t){e.setParams({missingProperty:t},!0),e.error()},t.hasPropFunc=a,t.isOwnProperty=l,t.propertyInData=function(e,t,n,o){const r=i._`${t}${(0,i.getProperty)(n)} !== undefined`;return o?i._`${r} && ${l(e,t,n)}`:r},t.noPropertyInData=c,t.allSchemaProperties=u,t.schemaProperties=function(e,t){return u(t).filter(n=>!(0,o.alwaysValidSchema)(e,t[n]))},t.callValidateCode=function({schemaCode:e,data:t,it:{gen:n,topSchemaRef:o,schemaPath:s,errorPath:a},it:l},c,u,h){const d=h?i._`${e}, ${t}, ${o}${s}`:t,p=[[r.default.instancePath,(0,i.strConcat)(r.default.instancePath,a)],[r.default.parentData,l.parentData],[r.default.parentDataProperty,l.parentDataProperty],[r.default.rootData,r.default.rootData]];l.opts.dynamicRef&&p.push([r.default.dynamicAnchors,r.default.dynamicAnchors]);const m=i._`${d}, ${n.object(...p)}`;return u!==i.nil?i._`${c}.call(${u}, ${m})`:i._`${c}(${m})`};const h=i._`new RegExp`;t.usePattern=function({gen:e,it:{opts:t}},n){const o=t.unicodeRegExp?"u":"",{regExp:r}=t.code,a=r(n,o);return e.scopeValue("pattern",{key:a.toString(),ref:a,code:i._`${"new RegExp"===r.code?h:(0,s.useFunc)(e,r)}(${n}, ${o})`})},t.validateArray=function(e){const{gen:t,data:n,keyword:r,it:s}=e,a=t.name("valid");if(s.allErrors){const e=t.let("valid",!0);return l(()=>t.assign(e,!1)),e}return t.var(a,!0),l(()=>t.break()),a;function l(s){const l=t.const("len",i._`${n}.length`);t.forRange("i",0,l,n=>{e.subschema({keyword:r,dataProp:n,dataPropType:o.Type.Num},a),t.if((0,i.not)(a),s)})}},t.validateUnion=function(e){const{gen:t,schema:n,keyword:r,it:s}=e;if(!Array.isArray(n))throw new Error("ajv implementation error");if(n.some(e=>(0,o.alwaysValidSchema)(s,e))&&!s.opts.unevaluated)return;const a=t.let("valid",!1),l=t.name("_valid");t.block(()=>n.forEach((n,o)=>{const s=e.subschema({keyword:r,schemaProp:o,compositeRule:!0},l);t.assign(a,i._`${a} || ${l}`),e.mergeValidEvaluated(s,l)||t.if((0,i.not)(a))})),e.result(a,()=>e.reset(),()=>e.error(!0))}},5844:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(4227),o={keyword:"allOf",schemaType:"array",code(e){const{gen:t,schema:n,it:o}=e;if(!Array.isArray(n))throw new Error("ajv implementation error");const r=t.name("valid");n.forEach((t,n)=>{if((0,i.alwaysValidSchema)(o,t))return;const s=e.subschema({keyword:"allOf",schemaProp:n},r);e.ok(r),e.mergeEvaluated(s)})}};t.default=o},5882:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o=i.operators,r={maximum:{okStr:"<=",ok:o.LTE,fail:o.GT},minimum:{okStr:">=",ok:o.GTE,fail:o.LT},exclusiveMaximum:{okStr:"<",ok:o.LT,fail:o.GTE},exclusiveMinimum:{okStr:">",ok:o.GT,fail:o.LTE}},s={message:({keyword:e,schemaCode:t})=>i.str`must be ${r[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>i._`{comparison: ${r[e].okStr}, limit: ${t}}`},a={keyword:Object.keys(r),type:"number",schemaType:"number",$data:!0,error:s,code(e){const{keyword:t,data:n,schemaCode:o}=e;e.fail$data(i._`${n} ${r[t].fail} ${o} || isNaN(${n})`)}};t.default=a},5944:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(8343);i.code='require("ajv/dist/runtime/uri").default',t.default=i},5999:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var i=n(1354),o=n.n(i),r=n(6314),s=n.n(r)()(o());s.push([e.id,".macromolecule-cell-comp-analysis-host{\n max-height: 250px;\n overflow-y: scroll;\n}\n\n.macromolecule-cell-comp-analysis-bar{\n height: inherit;\n display: block;\n margin-top: 1.5px;\n margin-bottom: 1.5px;\n margin-right: 3px;\n}\n\n.macromolecule-cell-comp-analysis-value{\n display: flex;\n}","",{version:3,sources:["webpack://./css/composition-analysis.css"],names:[],mappings:"AAAA;IACI,iBAAiB;IACjB,kBAAkB;AACtB;;AAEA;IACI,eAAe;IACf,cAAc;IACd,iBAAiB;IACjB,oBAAoB;IACpB,iBAAiB;AACrB;;AAEA;IACI,aAAa;AACjB",sourcesContent:[".macromolecule-cell-comp-analysis-host{\n max-height: 250px;\n overflow-y: scroll;\n}\n\n.macromolecule-cell-comp-analysis-bar{\n height: inherit;\n display: block;\n margin-top: 1.5px;\n margin-bottom: 1.5px;\n margin-right: 3px;\n}\n\n.macromolecule-cell-comp-analysis-value{\n display: flex;\n}"],sourceRoot:""}]);const a=s},6077:(e,t,n)=>{"use strict";n.d(t,{C4:()=>m,eM:()=>f});var i=n(4328),o=n(6082),r=n(1991),s=n.n(r),a=n(439),l=n(3561),c=n(9235),u=n(294),h=n(9192),d=n(330),p=n(8123);async function m(e,t,n,r,l){if(t.semType!==o.SEMTYPE.MACROMOLECULE)return{molCol:null,warnings:[`Only the ${o.SEMTYPE.MACROMOLECULE} columns can be converted to atomic level, the chosen column has semType '${t.semType}'`]};let u=t;const p=r.getSeqHandler(t);let m,g;p.notation!==a.Hi.SEPARATOR&&p.notation!==a.Hi.BILN&&(u=p.convert(a.Hi.SEPARATOR,"."),u.name=t.name);try{g=r.getSeqHandler(u).alphabet,m=(0,d.pz)(g)}catch(e){const[t,n]=(0,h.AP)(e);return{molCol:null,warnings:[t]}}const y=function(e,t){const n=e.length,o=new Array(n),r=t.getSeqHandler(e);let a=!1;const l=r.defaultBiotype;for(let e=0;e<n;++e){const t=r.getSplitted(e);a||(a=0===t.length),o[e]=s().count(0).take(t.length).filter(e=>!t.isGap(e)).map(e=>({position:e,biotype:l,symbol:t.getCanonical(e)})).toArray()}return a&&i.shell.warning(`Some values in the "${e.name}" column are empty`),o}(u,r),b=f(y,m,g,n,l),v=u.length,w=await(0,c.R)(u,b,g,m,n,r,l);w.warnings.length>.05*v&&i.shell.warning(`Molfile conversion resulted in ${w.warnings.length} errors`);const C=o.Func.find({name:"convertToV3KViaOCL"})[0];if(C&&w.molCol)try{const e=w.molCol.toList(),t=await C.apply({mols:e});w.molCol.init(n=>t[n]?t[n]:e[n])}catch(e){console.error(e)}return w}function f(e,t,n,i,o){const r=(0,l.Hb)(i,t,n),s={},c={value:null};if("RNA"===t){const e=n===a.YI.RNA?[p.u.RIBOSE,p.u.PHOSPHATE]:[p.u.DEOXYRIBOSE,p.u.PHOSPHATE];for(const n of e)g(s,n.symbol,r,o,t,c)}for(let n=0;n<e.length;++n){const i=e[n];for(const e of i){const n=e.symbol;if(""!==n)try{if("RNA"===t&&3===n.split(/\(|\)/).filter(e=>!!e).length){const e=n.split(/\(|\)/)[1];g(s,e,r,o,t,c),s[t]?.[e]&&(s[t][n]=s[t][e])}else g(s,n,r,o,t,c)}catch(e){const t=e instanceof Error?e.message:e.toString(),i=e instanceof Error?e.stack:void 0;throw console.error(`bio lib: getMonomersDictFromLib() sym='${n}', error:\n${t}\n${i}`),new Error(`Can't get monomer '${n}' from library: ${t}`)}}}return s}function g(e,t,n,i,o,r){const s={polymerType:o,symbol:t};if(!(0,u.bq)(e,s)){const a=function(e,t,n,i,o){if(t.has(e)){const s=t.get(e),a=function(e){const t=[];for(const n of e){let e=n.capGroupSmiles;e||(e=n.capGroupSMILES),e=e.replace(/(\[|\]|\*|:|\d)/g,"").replace("OH","O").replace("Oh","O"),t.push(e)}return t}(s.rgroups),c=(r=s.molfile).includes("V3000")?function(e){const t=new Map,n=/M V30 (\d+) R#.+RGROUPS=\((\d+) (\d+)\).*/gm;let i;for(;null!==(i=n.exec(e));)i.index===n.lastIndex&&n.lastIndex++,t.set(parseInt(i[1]),parseInt(i[3]));return t}(r):function(e){const t=new Map;let n=e.indexOf(p.u.V2K_A_LINE,0),i=n;for(;-1!==n;){i=e.indexOf("\n",n);const o=parseInt(e.substring(n,i).replace(/^A\s+/,""));n=e.indexOf("R",i),i=e.indexOf("\n",n);const r=parseInt(e.substring(n,i).replace(/^R/,""));t.set(o,r),n=e.indexOf(p.u.V2K_A_LINE,i)}for(n=e.indexOf(p.u.V2K_RGP_LINE,0),i=e.indexOf("\n",n);-1!==n;){n+=p.u.V2K_RGP_SHIFT,i=e.indexOf("\n",n);const o=e.substring(n,i).replaceAll(/\s+/g," ").split(" ").map(e=>parseInt(e)).slice(1);for(let e=0;e<o.length;e+=2){if(t.has(o[e])&&t.get(o[e])!==o[e+1])throw new Error(`r-group index ${o[e]} has already been added with a different value`);t.set(o[e],o[e+1])}n=e.indexOf(p.u.V2K_RGP_LINE,i)}return t}(r),u=s.molfile.includes("V3000")?s.molfile:function(e,t){const n=t.get_mol(function(e){return e.split("\n").map(e=>{const t=e.indexOf(" R# "),n=e.indexOf(" R ");if(-1===t&&-1===n)return e;const i=-1!==t?t:n,o=e.split("");for(let e=i+5;e<o.length;e++)" "!==o[e]&&(o[e]="0");return o.join("")}).join("\n")}(e)),i=n.get_v3Kmolblock();return n.delete(),i}(function(e){let t=e.indexOf(p.u.V2K_A_LINE,0);-1===t&&(t=e.indexOf(p.u.V2K_RGP_LINE));const n=e.indexOf(p.u.V3K_END,t);return e.substring(0,t)+e.substring(n)}(s.molfile),n),h=function(e){let t=(e=e.replaceAll("\r","")).indexOf(p.u.V3K_BEGIN_COUNTS_LINE)+p.u.V3K_COUNTS_SHIFT,n=e.indexOf(" ",t+1);const i=parseInt(e.substring(t,n));return t=n+1,n=e.indexOf(" ",t+1),{atomCount:i,bondCount:parseInt(e.substring(t,n))}}(u),d=function(e,t){const n=new Array(t),i=new Float32Array(t),o=new Float32Array(t),r=new Array(t);let s=e.indexOf(p.u.V3K_BEGIN_ATOM_BLOCK);s=e.indexOf("\n",s);let a=s;for(let l=0;l<t;l++){s=e.indexOf(p.u.V3K_BEGIN_DATA_LINE,s)+p.u.V3K_IDX_SHIFT,a=e.indexOf(" ",s),s=a+1,a=e.indexOf(" ",s),n[l]=e.substring(s,a);const t=new Array(2);for(let n=0;n<2;++n)s=a+1,a=e.indexOf(" ",s),t[n]=parseFloat(e.substring(s,a));i[l]=t[0],o[l]=t[1],s=a,a=e.indexOf("\n",s)+1,r[l]=e.slice(s,a),s=a}return{atomTypes:n,x:i,y:o,kwargs:r}}(u,h.atomCount),m=function(e,t){const n=new Uint32Array(t),i=new Array(t),o=new Map,r=new Map;let s=e.indexOf(p.u.V3K_BEGIN_BOND_BLOCK);s=e.indexOf("\n",s);let a=s;for(let l=0;l<t;++l){const t=new Array(3);s=e.indexOf(p.u.V3K_BEGIN_DATA_LINE,a)+p.u.V3K_IDX_SHIFT,a=e.indexOf(" ",s);for(let n=0;n<3;++n)s=a+1,a=Math.min(e.indexOf("\n",s),e.indexOf(" ",s)),t[n]=parseInt(e.slice(s,a));n[l]=t[0],i[l]=t.slice(1);const c=e.indexOf("\n",s);let u=e.slice(a,c),h=u.indexOf(p.u.V3K_BOND_CONFIG);if(-1!==h){h=u.indexOf("=",h)+1;let e=u.indexOf(" ",h);-1===e&&(e=u.length);const t=parseInt(u.slice(h,e));o.set(l,t);const n=p.u.V3K_BOND_CONFIG+t.toString();u=u.replace(n,"")}u||r.set(l,u)}return{bondTypes:n,atomPairs:i,bondConfiguration:o,kwargs:r}}(u,h.bondCount),f=function(e,t,n,i){const o={backboneShift:null,branchShift:null,terminalNodes:[],rNodes:[]};if(n&&i&&[1,2].some(e=>!Array.from(i.values()).find(t=>t==e))){const o=[1,2].find(e=>!Array.from(i.values()).find(t=>t==e)),r=[1,2].find(e=>Array.from(i.values()).find(t=>t==e)),s=Array.from(i.keys()).find(e=>i.get(e)===r)-1,a=e.x[s],l=e.y[s],c=t.atomPairs.find(e=>e.includes(s+1)).find(e=>e!==s+1)-1;let u=e.x.reduce((t,n,i)=>{if(i===s)return t;if(i===c)return t;const o=e.y[i];return Math.sqrt((n-a)**2+(o-l)**2)>Math.sqrt((e.x[t]-a)**2+(e.y[t]-l)**2)?i:t},-1);if(-1===u&&(u=e.x.length,e.x=new Float32Array([...e.x,-a]),e.y=new Float32Array([...e.y,-l]),e.atomTypes=[...e.atomTypes,"H"],e.kwargs=[...e.kwargs,""],t.atomPairs.push([c+1,u+1]),t.bondTypes=new Uint32Array([...t.bondTypes,1]),t.kwargs.set(t.atomPairs.length-1,"")),i.set(u+1,o),1===o)n.unshift(e.atomTypes[u]);else{if(2!==o)throw new Error(`Unexpected missing R-group: ${o}`);n.splice(1,0,e.atomTypes[u])}}return function(e,t,n){for(const[i,o]of n)e.atomTypes[i-1]=t[o-1]}(e,n,i),function(e,t){t.rNodes=Array.from(e.keys());for(let n=0;n<t.rNodes.length;n++)for(const i of[1,2])if(e.get(t.rNodes[n])===i){const e=t.rNodes[i-1];t.rNodes[i-1]=t.rNodes[n],t.rNodes[n]=e}}(i,o),y(t,o),o}(d,m,a,c),g=function(e){let t=[],n=e.indexOf("M V30 MDLV30/STEABS ATOMS=(");for(;-1!==n;){n+=28;const i=e.indexOf(")",n);t=t.concat(e.substring(n,i).split(" ").slice(1).map(e=>parseInt(e))),n=i,n=e.indexOf("M V30 MDLV30/STEABS ATOMS=(",n)}return t}(u),v={atoms:d,bonds:m,meta:f,stereoAtoms:g};return"PEPTIDE"===i?function(e){const t=e.meta.terminalNodes[0]-1,n=e.meta.rNodes[0]-1,i=e.atoms.x,o=e.atoms.y;T(e,-i[t],-o[t]);const r=S(i[n],o[n]);A(e.atoms,-r),i[e.meta.rNodes[1]-1]<0&&x(e);const s=function(e){const t=function(e){const t=new Map;for(const n of e.bonds.atomPairs)for(let e=0;e<2;e++){const i=n[e],o=n[(e+1)%2];t.has(i)?t.get(i)?.push(o):t.set(i,new Array(1).fill(o))}return t}(e);let n=0;const i=e.atoms.atomTypes.length;let o=0;if(e.meta.terminalNodes.length<2)return null;for(;0===n;){const r=t.get(e.meta.terminalNodes[1])[o];if(e.atoms.atomTypes[r-1]===p.u.OXYGEN&&r!==e.meta.rNodes[1]&&(n=r),o++,o>i)return null}return n}(e);null!=s&&(function(e,t){e.atoms.y[e.meta.rNodes[1]-1]<0&&e.atoms.y[t-1]<0&&(function(e){M(e,!0)}(e),A(e.atoms,-function(e,t){return S(e,t)+Math.PI/2}(e.atoms.x[e.meta.terminalNodes[1]-1],e.atoms.y[e.meta.terminalNodes[1]-1])))}(e,s),function(e,t){const n=e.atoms.x;n[e.meta.rNodes[1]-1]>n[t-1]&&function(e,t,n){const i=t-1,o=n-1,r=e.atoms.x,s=e.atoms.y,a=r[i],l=s[i];r[i]=r[o],s[i]=s[o],r[o]=a,s[o]=l}(e,t,e.meta.rNodes[1])}(e,s))}(v):e===p.u.RIBOSE.symbol||e===p.u.DEOXYRIBOSE.symbol?function(e,t){const n=e.atoms.x,i=e.atoms.y;let o=e.meta.terminalNodes[0]-1;const r=e.meta.rNodes[1]-1;T(e,-n[o],-i[o]);const s=S(n[e.meta.rNodes[2]-1],i[e.meta.rNodes[2]-1]);A(e.atoms,-s),n[e.meta.rNodes[0]-1]>n[e.meta.rNodes[1]-1]&&x(e);const a=S(n[r],i[r]);A(e.atoms,3*Math.PI/2-a),t.value=function(e){const t=e.atoms.x,n=e.atoms.y,i=e.meta.rNodes[2]-1,o=e.meta.terminalNodes[2]-1,r=t[i]-t[o],s=n[i]-n[o];return Math.atan2(r,s)}(e),o=e.meta.terminalNodes[0]-1,T(e,-n[o],-i[o])}(v,o):e===p.u.PHOSPHATE.symbol?function(e){const t=e.meta.rNodes[1]-1,n=e.meta.rNodes[0]-1,i=e.atoms.x,o=e.atoms.y;T(e,-i[t],-o[t]);const r=S(i[n],o[n]);A(e.atoms,Math.PI/2-r)}(v):function(e,t){const n=e.atoms.x,i=e.atoms.y,o=e.meta.terminalNodes[0]-1,r=e.meta.rNodes[0]-1;T(e,-n[o],-i[o]);const s=S(n[r],i[r]),a=t.value;if(!a)throw new Error("The value of sugarBranchToOYAngle is null");A(e.atoms,Math.PI-s+a);const c=function(e,t){return(0,l.YN)(Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2))}({x:n[e.meta.rNodes[0]-1],y:i[e.meta.rNodes[0]-1]},{x:n[e.meta.terminalNodes[0]-1],y:i[e.meta.terminalNodes[0]-1]});if(1!=c)for(let e=0;e<n.length;++e)n[e]=(0,l.YN)(n[e]/c),i[e]=(0,l.YN)(i[e]/c)}(v,o),function(e,t,n){if("PEPTIDE"===e){b(t,e);const n=w(t,t.meta.rNodes[1]);n?.removedAtom&&(t.terminalR2Atom=n.removedAtom)}else n===p.u.RIBOSE.symbol||n===p.u.DEOXYRIBOSE.symbol?(w(t,t.meta.rNodes[1]),t.meta.rNodes[1]=t.meta.terminalNodes[1],y(t.bonds,t.meta),b(t,e),w(t,t.meta.rNodes[1]),w(t,t.meta.rNodes[0]),w(t,t.meta.rNodes[2])):n===p.u.PHOSPHATE.symbol&&(t.meta.terminalNodes[0]=t.meta.rNodes[0],T(t,-t.atoms.x[t.meta.terminalNodes[0]-1],-t.atoms.y[t.meta.terminalNodes[0]-1]),b(t,e),w(t,t.meta.rNodes[1]))}(i,v,e),function(e){let t=0;for(;t<e.atoms.atomTypes.length;)e.atoms.atomTypes[t]===p.u.HYDROGEN&&(w(e,t+1),--t),++t}(v),function(e){let t=0;for(;t<e.atoms.atomTypes.length;)"oh"===e.atoms.atomTypes[t]?.toLowerCase()&&(e.atoms.atomTypes[t]="O"),"?"===e.atoms.atomTypes[t]&&(e.atoms.atomTypes[t]="H"),++t}(v),function(e){const t=" RGROUPS=(1 1)";for(let n=0;n<(e.atoms.kwargs?.length??0);n++){const i=e.atoms.kwargs[n];i&&i.includes(t)&&(e.atoms.kwargs[n]=i.replace(t,""))}}(v),v}var r;return null}(t,n,i,o,r);if(!a)throw new Error(`Monomer with symbol '${t}' is absent the monomer library`);(0,u.LQ)(e,s,a)}}function y(e,t){const n=t.rNodes;t.terminalNodes=new Array(n.length).fill(0);const i=t.terminalNodes,o=e.atomPairs;let r=0,s=0;for(;r<o.length&&s<i.length;){for(let e=0;e<i.length;++e)for(let t=0;t<2;++t)o[r][t]===n[e]&&(i[e]=o[r][(t+1)%2],n.length,++s);++r}}function b(e,t){e.meta.rNodes.length>1&&(e.meta.backboneShift=v(e,e.meta.rNodes[1]-1,e.meta.terminalNodes[0]-1)),"RNA"===t&&e.meta.rNodes.length>2&&(e.meta.branchShift=v(e,e.meta.rNodes[2]-1,e.meta.terminalNodes[0]-1))}function v(e,t,n){return[(0,l.YN)(e.atoms.x[t]-e.atoms.x[n]),(0,l.YN)(e.atoms.y[t]-e.atoms.y[n])]}function w(e,t){if(void 0!==t){const n=t-1,i=e.atoms,o=e.bonds,r=e.meta,s=i.atomTypes.splice(n,1)[0];i.x=C(Float32Array,i.x,n,1),i.y=C(Float32Array,i.y,n,1),i.kwargs.splice(n,1);for(let e=0;e<r.terminalNodes.length;++e)r.terminalNodes[e]>t?--r.terminalNodes[e]:r.terminalNodes[e]===t&&(r.terminalNodes[e]=-1);for(let e=0;e<r.rNodes.length;++e)r.rNodes[e]>t?--r.rNodes[e]:r.rNodes[e]===t&&(r.rNodes[e]=-1);let a=0;for(;a<o.atomPairs.length;){const e=o.atomPairs[a][0],n=o.atomPairs[a][1];e===t||n===t?(o.atomPairs.splice(a,1),o.bondTypes=C(Uint32Array,o.bondTypes,a,1),o.bondConfiguration.has(a)&&o.bondConfiguration.delete(a),o.kwargs.has(a)&&o.kwargs.delete(a),--a):(o.atomPairs[a][0]=e>t?e-1:e,o.atomPairs[a][1]=n>t?n-1:n),++a}let l=Array.from(o.bondConfiguration.keys());return l.forEach(e=>{if(o.bondConfiguration.has(e)&&e>n){const t=o.bondConfiguration.get(e);o.bondConfiguration.delete(e),o.bondConfiguration.set(e-1,t)}}),l=Array.from(o.kwargs.keys()),l.forEach(e=>{if(o.kwargs.has(e)&&e>n){const t=o.kwargs.get(e);o.kwargs.delete(e),o.kwargs.set(e-1,t)}}),s?{removedAtom:s}:void 0}}function C(e,t,n,i){const o=new e(t.length-i);let r=0,s=0;for(;r<t.length;)r===n&&(r+=i),o[s]=t[r],++s,++r;return o}function S(e,t){let n;if(0===e)n=t>0?0:Math.PI;else if(0===t)n=e>0?-Math.PI/2:Math.PI/2;else{const i=t/e,o=Math.atan(i);n=e<0?Math.PI/2+o:-Math.PI/2+o}return n}function A(e,t){if(0!==t){const n=e.x,i=e.y,o=Math.cos(t),r=Math.sin(t);for(let e=0;e<n.length;++e){const t=n[e];n[e]=(0,l.YN)(t*o-i[e]*r),i[e]=(0,l.YN)(t*r+i[e]*o)}}}function x(e){M(e,!1)}function M(e,t){if(t){const t=e.atoms.y;for(let e=0;e<t.length;e++)t[e]=-t[e]}else{const t=e.atoms.x;for(let e=0;e<t.length;e++)t[e]=-t[e]}const n=e.bonds.bondConfiguration;for(const[e,t]of n){const i=1===t?3:1;n.set(e,i)}}function T(e,t,n){const i=e.atoms.x,o=e.atoms.y;for(let e=0;e<i.length;++e)i[e]=(0,l.YN)(i[e]+t),void 0!==n&&(o[e]=(0,l.YN)(o[e]+n))}},6082:e=>{"use strict";e.exports=DG},6105:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(2128),o=n(7060),r=n(6378),s=n(5520),a=n(5413),l=n(3265),c=n(7532),u=n(9857),h=[s.default,i.default,o.default,(0,r.default)(!0),c.default,u.metadataVocabulary,u.contentVocabulary,a.default,l.default];t.default=h},6144:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(2128),o=n(7060),r=n(6378),s=n(7532),a=n(9857),l=[i.default,o.default,(0,r.default)(),s.default,a.metadataVocabulary,a.contentVocabulary];t.default=l},6163:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o=n(4227),r={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:{message:"must match exactly one schema in oneOf",params:({params:e})=>i._`{passingSchemas: ${e.passing}}`},code(e){const{gen:t,schema:n,parentSchema:r,it:s}=e;if(!Array.isArray(n))throw new Error("ajv implementation error");if(s.opts.discriminator&&r.discriminator)return;const a=n,l=t.let("valid",!1),c=t.let("passing",null),u=t.name("_valid");e.setParams({passing:c}),t.block(function(){a.forEach((n,r)=>{let a;(0,o.alwaysValidSchema)(s,n)?t.var(u,!0):a=e.subschema({keyword:"oneOf",schemaProp:r,compositeRule:!0},u),r>0&&t.if(i._`${u} && ${l}`).assign(l,!1).assign(c,i._`[${c}, ${r}]`).else(),t.if(u,()=>{t.assign(l,!0),t.assign(c,r),a&&e.mergeEvaluated(a,i.Name)})})}),e.result(l,()=>e.reset(),()=>e.error(!0))}};t.default=r},6197:(e,t,n)=>{"use strict";n.d(t,{Y:()=>o});var i=n(3599);function o(e){let t;switch(e){case i.o.BASE:case i.o.SUGAR:case i.o.LINKER:case i.o.NUCLEOTIDE:case"nucleotide":t="RNA";break;case i.o.AA:t="PEPTIDE";break;case i.o.CHEM:t="CHEM";break;case i.o.BLOB:t="BLOB";break;default:t="PEPTIDE",console.warn(`Unexpected HelmType '${e}'`)}return t}},6250:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(2017);i.code='require("ajv/dist/runtime/equal").default',t.default=i},6295:(e,t,n)=>{"use strict";n.d(t,{$1:()=>s,Hf:()=>u,Hr:()=>M,Ii:()=>g,Qj:()=>m,T6:()=>x,TK:()=>S,be:()=>f,gt:()=>v,ij:()=>w,jL:()=>c,lO:()=>p,lP:()=>b,rR:()=>y,tO:()=>a,v_:()=>l,w_:()=>h,yK:()=>C,zn:()=>d});var i=n(8774),o=n(8498),r=n(6863);function s(e,t){const n=e.trueCount()+t.trueCount();if(0==n)return 1;const i=e.andWithCountBits(t,!0);return i/(n-i)}function a(e,t){return 1-s(e,t)}function l(e,t){return A(s(new i.A(e,32*e.length),new i.A(t,32*t.length)))}function c(e,t){let n=0;for(let i=0;i<e.length;i++)n+=Math.pow(e[i]-t[i],2);return Math.sqrt(n)}function u(e,t){let n=0;for(let i=0;i<e.length;i++)n+=Math.abs(e[i]-t[i]);return n}function h(e,t){let n=0,i=0,o=0;for(let r=0;r<e.length;r++)n+=e[r]*t[r],i+=e[r]*e[r],o+=t[r]*t[r];return(1-n/(Math.sqrt(i)*Math.sqrt(o)))/2}function d(e,t){return 1-function(e,t){const n=e.trueCount()+t.trueCount();return 0==n?0:2*e.andWithCountBits(t,!0)/n}(e,t)}function p(e,t){return 1-function(e,t){const n=e.trueCount()*t.trueCount();return 0==n?0:e.andWithCountBits(t,!0)/Math.sqrt(n)}(e,t)}function m(e,t){return Math.sqrt(e.trueCount()+t.trueCount()-2*e.andWithCountBits(t,!0))}function f(e,t){return e.trueCount()+t.trueCount()-2*e.andWithCountBits(t,!0)}function g(e,t){return 1-function(e,t){const n=e.trueCount()+t.trueCount(),i=e.andWithCountBits(t,!0);return i/(2*n-3*i)}(e,t)}function y(e,t){return A(function(e,t){const n=e.trueCount()+t.trueCount(),i=e.trueCount()*t.trueCount();return 0==i?0:e.andWithCountBits(t,!0)*n/(2*i)}(e,t))}function b(e,t){return A(function(e,t){const n=e.trueCount()+t.trueCount(),i=e.trueCount()*t.trueCount();return 0==i?0:(e.andWithCountBits(t,!0)*n-i)/i}(e,t))}function v(e,t){return 1-function(e,t){const n=Math.min(e.trueCount(),t.trueCount());return 0==n?0:e.andWithCountBits(t,!0)/n}(e,t)}function w(e,t){return A(function(e,t){const n=Math.max(e.trueCount(),t.trueCount());return 0==n?0:e.andWithCountBits(t,!0)/n}(e,t))}function C(e,t){return A(function(e,t){return 0==e.length?0:e.andWithCountBits(t,!0)/e.length}(e,t))}function S(e,t){return A(function(e,t){const n=e.andWithCountBits(t,!0),i=e.countBits(!0)+t.countBits(!0),o=e.length,r=o-i+n;return n==o||r==o?1:n/i+r/(2*o-i)}(e,t))}function A(e){return e<=0?3402823e32:1/e-1}function x(e){if(e&&null!=e.range&&e.range>0){const t=e.range;return(e,n)=>Math.abs(e-n)/t}return(e,t)=>Math.abs(e-t)}function M(e){const t=function(e){const t=e?.mostCommon??new Set;return(e,n)=>{const i=e.length,o=n.length;let r=0,s=0,a=0;for(;s<i&&a<o;)e[s]===n[a]?(t?.has(e[s])||++r,++s,++a):e[s]<n[a]?++s:++a;return r}}(e);return(e,n)=>0===n.length||0===e.length?1e4:Math.min(e.length,n.length)/(t(e,n)+1e-4)}o.aT.Tanimoto,o.aT.Dice,o.aT.Asymmetric,o.aT.BraunBlanquet,o.aT.Cosine,o.aT.Kulczynski,o.aT.McConnaughey,o.aT.RogotGoldberg,o.aT.Russel,o.aT.Sokal,o.aT.Hamming,o.aT.Euclidean,o.aT.Tanimoto,o.aT.Dice,o.aT.Asymmetric,o.aT.BraunBlanquet,o.aT.Cosine,o.aT.Kulczynski,o.aT.McConnaughey,o.aT.RogotGoldberg,o.aT.Russel,o.aT.Sokal,o.aT.Hamming,o.aT.Euclidean,o.aT.Tanimoto,o.aT.Dice,o.aT.Cosine,o.aT.Tanimoto,o.aT.Asymmetric,o.aT.Cosine,o.aT.Sokal,r.Z.HAMMING,r.Z.LEVENSHTEIN,r.Z.MONOMER_CHEMICAL_DISTANCE,r.Z.NEEDLEMANN_WUNSCH},6307:(e,t,n)=>{"use strict";n.d(t,{F:()=>a});var i=n(7389),o=n(6082),r=n(439),s=n(6197);function a(e,t,n,a){let l=0,c=null;for(const t of Object.values(e))l+=t,c=null===c?t:Math.max(c,t);const u=c/l,h=Object.assign({},...Array.from(Object.entries(e)).sort((e,t)=>t[1]-e[1]).map(([e,c])=>{const h=c/l;let d;const p=a&&a[e]||t;try{const t=n.getMonomerColors(p,e);d=t?.backgroundcolor||"#CCCCCC"}catch(t){console.warn(`Failed to get colors for monomer ${e}:`,t),d="#CCCCCC"}const m=i.div("",{classes:"macromolecule-cell-comp-analysis-bar"});m.style.width=50*h/u+"px",m.style.backgroundColor=d,r._S===e&&(m.style.borderWidth="1px",m.style.borderStyle="solid",m.style.borderColor=o.Color.toHtml(o.Color.lightGray));let f=e;if(e!==r._S){const t=n.getMonomer((0,s.Y)(p),e);t&&t.symbol!==e&&(f=t.symbol)}else f="-";const g=i.div(`${(100*h).toFixed(2)}%`),y=i.div([m,g],{classes:"macromolecule-cell-comp-analysis-value"});return{[f]:y}})),d=i.tableFromMap(h);return Array.from(d.rows).forEach(e=>{const t=e.getElementsByClassName("macromolecule-cell-comp-analysis-bar")[0].style.backgroundColor;e.cells[0].style.color=t}),d}},6314:e=>{"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map(function(t){var n="",i=void 0!==t[5];return t[4]&&(n+="@supports (".concat(t[4],") {")),t[2]&&(n+="@media ".concat(t[2]," {")),i&&(n+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),n+=e(t),i&&(n+="}"),t[2]&&(n+="}"),t[4]&&(n+="}"),n}).join("")},t.i=function(e,n,i,o,r){"string"==typeof e&&(e=[[null,e,void 0]]);var s={};if(i)for(var a=0;a<this.length;a++){var l=this[a][0];null!=l&&(s[l]=!0)}for(var c=0;c<e.length;c++){var u=[].concat(e[c]);i&&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),o&&(u[4]?(u[1]="@supports (".concat(u[4],") {").concat(u[1],"}"),u[4]=o):u[4]="".concat(o)),t.push(u))}},t}},6369:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var i=n(1354),o=n.n(i),r=n(6314),s=n.n(r)()(o());s.push([e.id,".kalign-version {\n margin-bottom: 0;\n text-align: end;\n font-size: 12px;\n opacity: 0.8;\n}\nbutton.msa-params-button.ui-btn {\n justify-content: end;\n}","",{version:3,sources:["webpack://./css/msa.css"],names:[],mappings:"AAAA;IACI,gBAAgB;IAChB,eAAe;IACf,eAAe;IACf,YAAY;AAChB;AACA;IACI,oBAAoB;AACxB",sourcesContent:[".kalign-version {\n margin-bottom: 0;\n text-align: end;\n font-size: 12px;\n opacity: 0.8;\n}\nbutton.msa-params-button.ui-btn {\n justify-content: end;\n}"],sourceRoot:""}]);const a=s},6378:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(5457),o=n(5354),r=n(494),s=n(3966),a=n(2661),l=n(3025),c=n(2094),u=n(8660),h=n(117),d=n(5333),p=n(7923),m=n(6505),f=n(6163),g=n(5844),y=n(1239),b=n(4426);t.default=function(e=!1){const t=[p.default,m.default,f.default,g.default,y.default,b.default,c.default,u.default,l.default,h.default,d.default];return e?t.push(o.default,s.default):t.push(i.default,r.default),t.push(a.default),t}},6505:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:n(5765).validateUnion,error:{message:"must match a schema in anyOf"}};t.default=i},6642:(e,t,n)=>{"use strict";n.d(t,{BG:()=>s,sD:()=>l});var i=n(4328),o=n(1858),r=n(8070);function s(e){let t=null,n=null;try{n=e.dart?e.gridColumn:null,t=n?n.temp:null}catch{[n,t]=[null,null]}const i=e.cell.column;if(t=t??(i?i.temp:null),!t)throw new Error("Grid cell renderer back store (GridColumn or Column) not found.");return[n,i,t]}class a{onKeyDown(e,t){}onKeyPress(e,t){}onMouseEnter(e,t){}onMouseLeave(e,t){}onMouseDown(e,t){}onMouseUp(e,t){}onMouseMove(e,t){}onClick(e,t){}onDoubleClick(e,t){}}class l extends a{constructor(e,t,n){super(),this.gridCol=e,this.tableCol=t,this.logger=n,this.subs=[],this.dirty=!0,this.destroyed=!1,this.viewerId=++l.viewerCounter,this.errors=[],this._onRendered=new o.Subject,this.tableCol&&this.tableCol.dataFrame&&(this.subs.push(this.tableCol.dataFrame.onDataChanged.subscribe(()=>{this.dirty=!0})),this.subs.push(this.tableCol.dataFrame.onColumnsRemoved.subscribe(e=>{try{this.destroyed||!this.tableCol||this.tableCol.dataFrame||this.destroy()}catch(e){this.logger.error(e)}}))),this.tableCol&&this.subs.push(i.events.onTableRemoved.subscribe(e=>{try{const t=e.args.dataFrame;this.tableCol?.dataFrame.id!==t.id||this.destroyed||this.destroy()}catch(e){this.logger.error(e)}})),this.gridCol&&this.subs.push(i.events.onViewRemoving.subscribe(e=>{try{const t=e.args.view;this.gridCol?.dart&&this.gridCol.grid&&this.gridCol?.grid?.dart&&this.gridCol?.grid?.view?.id===t.id&&!this.destroyed&&this.destroy()}catch(e){this.logger.error(e)}}))}toLog(){return`${this.constructor.name}<${this.viewerId}>`}destroy(){for(const e of this.subs)e.unsubscribe();this.destroyed=!0}invalidateGrid(){this.gridCol&&this.gridCol.dart&&this.gridCol.grid?.invalidate()}reset(){this.dirty=!1}get onRendered(){return this._onRendered}invalidate(e){this.invalidateGrid()}async awaitRendered(e=1e4,t=`${e} timeout`){const n=`${this.toLog()}.awaitRendered()`;if(this.logger.debug(`${n}, start, testEvent before`),await(0,r.PE)(this._onRendered,()=>{},()=>{this.invalidate()},e,`${n}, ${t}`),this.errors.length>0){const e=this.errors[0];throw this.errors=[],e}this.logger.debug(`${n}, end`)}}l.viewerCounter=-1},6653:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o=n(7652),r=n(3835),s=n(4551),a=n(4227),l={keyword:"discriminator",type:"object",schemaType:"object",error:{message:({params:{discrError:e,tagName:t}})=>e===o.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:n}})=>i._`{error: ${e}, tag: ${n}, tagValue: ${t}}`},code(e){const{gen:t,data:n,schema:l,parentSchema:c,it:u}=e,{oneOf:h}=c;if(!u.opts.discriminator)throw new Error("discriminator: requires discriminator option");const d=l.propertyName;if("string"!=typeof d)throw new Error("discriminator: requires propertyName");if(l.mapping)throw new Error("discriminator: mapping is not supported");if(!h)throw new Error("discriminator: requires oneOf keyword");const p=t.let("valid",!1),m=t.const("tag",i._`${n}${(0,i.getProperty)(d)}`);function f(n){const o=t.name("valid"),r=e.subschema({keyword:"oneOf",schemaProp:n},o);return e.mergeEvaluated(r,i.Name),o}t.if(i._`typeof ${m} == "string"`,()=>function(){const n=function(){var e;const t={},n=o(c);let i=!0;for(let t=0;t<h.length;t++){let c=h[t];if((null==c?void 0:c.$ref)&&!(0,a.schemaHasRulesButRef)(c,u.self.RULES)){const e=c.$ref;if(c=r.resolveRef.call(u.self,u.schemaEnv.root,u.baseId,e),c instanceof r.SchemaEnv&&(c=c.schema),void 0===c)throw new s.default(u.opts.uriResolver,u.baseId,e)}const p=null===(e=null==c?void 0:c.properties)||void 0===e?void 0:e[d];if("object"!=typeof p)throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${d}"`);i=i&&(n||o(c)),l(p,t)}if(!i)throw new Error(`discriminator: "${d}" must be required`);return t;function o({required:e}){return Array.isArray(e)&&e.includes(d)}function l(e,t){if(e.const)p(e.const,t);else{if(!e.enum)throw new Error(`discriminator: "properties/${d}" must have "const" or "enum"`);for(const n of e.enum)p(n,t)}}function p(e,n){if("string"!=typeof e||e in t)throw new Error(`discriminator: "${d}" values must be unique strings`);t[e]=n}}();t.if(!1);for(const e in n)t.elseIf(i._`${m} === ${e}`),t.assign(p,f(n[e]));t.else(),e.error(!1,{discrError:o.DiscrError.Mapping,tag:m,tagName:d}),t.endIf()}(),()=>e.error(!1,{discrError:o.DiscrError.Tag,tag:m,tagName:d})),e.ok(p)}};t.default=l},6717:(e,t,n)=>{"use strict";n.d(t,{j:()=>o});var i=n(6082);async function o(){const e=i.Func.find({package:"Chem",name:"getRdKitModule"});if(0===e.length)throw new Error('Package "Chem" must be installed for getRdKitModule.');return(await e[0].prepare().call()).getOutputParamValue()}},6863:(e,t,n)=>{"use strict";function i(e={}){const t=function(){if(!e||!e.scoringMatrix||!e.alphabetIndexes)return(e,t)=>e===t?0:1;if(e.scoringMatrix.length!==Object.keys(e.alphabetIndexes).length)throw new Error("Scoring matrix and alphabet indexes should have the same length");const t=e.alphabetIndexes,n=e.scoringMatrix,i=Math.min(...Object.keys(t).map(e=>e.charCodeAt(0)))+1,o=new Float32Array((n.length+i)*(n.length+i));return Object.entries(t).forEach(([e,i])=>{const r=n[i];Object.entries(t).forEach(([t,i])=>{o[e.charCodeAt(0)*n.length+t.charCodeAt(0)]=r[i]})}),(e,t)=>1-o[e.charCodeAt(0)*n.length+t.charCodeAt(0)]}(),n=e?.threshold??0;return(e,i)=>{let o=0;const r=e.length,s=i.length,a=Math.ceil(Math.max(r,s)*(1-n));r!==s&&(o=Math.abs(r-s));let l=0;for(let n=0;n<Math.min(r,s);n++)if(e[n]!==i[n]&&(l+=t(e[n],i[n]),l>a))return 1;return l+=o,l/=Math.max(r,s),l}}n.d(t,{Z:()=>s,V:()=>a});var o=n(2787);const r={gapOpen:1,gapExtend:.6,scoringMatrix:[[4,-1,-2,-2,0,-1,-1,0,-2,-1,-1,-1,-1,-2,-1,1,0,-3,-2,0,-2,-1,0,-4],[-1,5,0,-2,-3,1,0,-2,0,-3,-2,2,-1,-3,-2,-1,-1,-3,-2,-3,-1,0,-1,-4],[-2,0,6,1,-3,0,0,0,1,-3,-3,0,-2,-3,-2,1,0,-4,-2,-3,3,0,-1,-4],[-2,-2,1,6,-3,0,2,-1,-1,-3,-4,-1,-3,-3,-1,0,-1,-4,-3,-3,4,1,-1,-4],[0,-3,-3,-3,9,-3,-4,-3,-3,-1,-1,-3,-1,-2,-3,-1,-1,-2,-2,-1,-3,-3,-2,-4],[-1,1,0,0,-3,5,2,-2,0,-3,-2,1,0,-3,-1,0,-1,-2,-1,-2,0,3,-1,-4],[-1,0,0,2,-4,2,5,-2,0,-3,-3,1,-2,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-2,0,-1,-3,-2,-2,6,-2,-4,-4,-2,-3,-3,-2,0,-2,-2,-3,-3,-1,-2,-1,-4],[-2,0,1,-1,-3,0,0,-2,8,-3,-3,-1,-2,-1,-2,-1,-2,-2,2,-3,0,0,-1,-4],[-1,-3,-3,-3,-1,-3,-3,-4,-3,4,2,-3,1,0,-3,-2,-1,-3,-1,3,-3,-3,-1,-4],[-1,-2,-3,-4,-1,-2,-3,-4,-3,2,4,-2,2,0,-3,-2,-1,-2,-1,1,-4,-3,-1,-4],[-1,2,0,-1,-3,1,1,-2,-1,-3,-2,5,-1,-3,-1,0,-1,-3,-2,-2,0,1,-1,-4],[-1,-1,-2,-3,-1,0,-2,-3,-2,1,2,-1,5,0,-2,-1,-1,-1,-1,1,-3,-1,-1,-4],[-2,-3,-3,-3,-2,-3,-3,-3,-1,0,0,-3,0,6,-4,-2,-2,1,3,-1,-3,-3,-1,-4],[-1,-2,-2,-1,-3,-1,-1,-2,-2,-3,-3,-1,-2,-4,7,-1,-1,-4,-3,-2,-2,-1,-2,-4],[1,-1,1,0,-1,0,0,0,-1,-2,-2,0,-1,-2,-1,4,1,-3,-2,-2,0,0,0,-4],[0,-1,0,-1,-1,-1,-1,-2,-2,-1,-1,-1,-1,-2,-1,1,5,-2,-2,0,-1,-1,0,-4],[-3,-3,-4,-4,-2,-2,-3,-2,-2,-3,-2,-3,-1,1,-4,-3,-2,11,2,-3,-4,-3,-2,-4],[-2,-2,-2,-3,-2,-1,-2,-3,2,-1,-1,-2,-1,3,-3,-2,-2,2,7,-1,-3,-2,-1,-4],[0,-3,-3,-3,-1,-2,-2,-3,-3,3,1,-2,1,-1,-2,-2,0,-3,-1,4,-3,-2,-1,-4],[-2,-1,3,4,-3,0,1,-1,0,-3,-4,0,-3,-3,-2,0,-1,-4,-3,-3,4,1,-1,-4],[-1,0,0,1,-3,3,4,-2,0,-3,-3,1,-1,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-1,-1,-1,-2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-2,0,0,-2,-1,-1,-1,-1,-1,-4],[-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,1]],alphabetIndexes:{A:0,R:1,N:2,D:3,C:4,Q:5,E:6,G:7,H:8,I:9,L:10,K:11,M:12,F:13,P:14,S:15,T:16,W:17,Y:18,V:19,B:20,Z:21,X:22,"*":23}};var s;!function(e){e.HAMMING="Hamming",e.LEVENSHTEIN="Levenshtein",e.NEEDLEMANN_WUNSCH="Needlemann-Wunsch",e.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance"}(s||(s={}));const a={[s.HAMMING]:i,[s.LEVENSHTEIN]:function(){return(e,t)=>(0,o.I)(e,t)/Math.max(e.length,t.length)},[s.NEEDLEMANN_WUNSCH]:function(e){const t=new Uint16Array(65536),{gapOpen:n,gapExtend:i,scoringMatrix:o,alphabetIndexes:s}={...r,...e};Object.entries(s).forEach(([e,n])=>t[e.charCodeAt(0)]=n);const a=[new Float32Array(1e4),new Float32Array(1e4)];return(e,r)=>{const s=new Array(e.length+1).fill(!1),l=new Array(e.length+1).fill(!1);let c=0,u=1;for(let t=1;t<e.length+1;t++)a[0][t]=-i-(t-1)*i,a[1][t]=0;a[0][0]=0;for(let h=1;h<r.length+1;h++){a[u][0]=-i-(h-1)*i;for(let d=1;d<e.length+1;d++){const p=a[c][d-1]+o[t[e.charCodeAt(d-1)]][t[r.charCodeAt(h-1)]],m=a[c][d]-(s[d]||1===h||h===r.length?i:n),f=a[u][d-1]-(l[d-1]||1===d||d===e.length?i:n);a[u][d]=Math.max(p,f,m),a[u][d]===p?(s[d]=!1,l[d]=!1):a[u][d]===f?(s[d]=!1,l[d]=!0):(s[d]=!0,l[d]=!1)}c=u,u=(u+1)%2}const h=Math.min(e.length,r.length);return(h-a[c][e.length])/h}},[s.MONOMER_CHEMICAL_DISTANCE]:i}},6869:(e,t,n)=>{"use strict";var i;n.d(t,{o:()=>i}),function(e){e.BASE="HELM_BASE",e.SUGAR="HELM_SUGAR",e.LINKER="HELM_LINKER",e.AA="HELM_AA",e.CHEM="HELM_CHEM",e.BLOB="HELM_BLOB",e.NUCLEOTIDE="HELM_NUCLETIDE"}(i||(i={}))},6873:(e,t,n)=>{"use strict";n.d(t,{Hx:()=>u,dW:()=>c});var i=n(6082),o=n(1991),r=n.n(o),s=n(2003),a=n(7278),l=n(439);function c(e=1e4){const t="meI/hHis/Aca/N//dE/Thr_PO3H2/Aca/D-Tyr_Et/Tyr_ab-dehydroMe".repeat(Math.ceil(e/10)).slice(0,-1),n=i.Column.fromList(i.COLUMN_TYPE.STRING,"MSA",new Array(100).fill(t));n.semType=i.SEMTYPE.MACROMOLECULE,n.meta.units=s.Hi.SEPARATOR,n.setTag(s.gp.separator,"/"),n.setTag(s.gp.alphabet,s.YI.UN),n.setTag(s.gp.alphabetIsMultichar,"true");const o=[];return o.push(n),o.push(i.Column.fromList(i.COLUMN_TYPE.FLOAT,"Activity",new Array(100).fill(7.30751))),o}function u(e,t=s.Hi.SEPARATOR,n=s.YI.PT,o=(t===s.Hi.SEPARATOR?"-":void 0),c=void 0,u="seq",h=100,d=10**6){const p=n===s.YI.UN?c?.getMonomerSymbolsByType("PEPTIDE")??[]:Array.from((0,s.Qf)(n)),m=p.length,f=i.Column.fromType(i.COLUMN_TYPE.STRING,u,h);f.semType=i.SEMTYPE.MACROMOLECULE,f.meta.units=t,f.setTag(s.gp.alphabet,n),t==s.Hi.SEPARATOR&&f.setTag(s.gp.separator,o);const g=e.getSeqHandler(f);for(let e=0;e<h;e++){const n=r().count(0).take(d).map(e=>p[Math.floor(Math.random()*m)]).toArray(),i=g.joiner(new a.Mu(n,l.b9[t]));f.set(e,i)}return f}},6882:(e,t,n)=>{"use strict";n.d(t,{Jy:()=>b,S$:()=>y,U0:()=>v});var i=n(7389),o=n(6082),r=n(1991),s=n.n(r),a=n(8312),l=n(2003),c=n(6642),u=n(4971),h=n(9192),d=n(3856),p=n(673),m=n(3599),f=n(5553),g=n(9713);const y="rgb(100,100,100)";class b extends c.sD{get separatorWidth(){return this.props?.fontCharWidth?this.props?.fontCharWidth:5}constructor(e,t,n,i,r){if(super(e,t,n),this.monomerLengthLimit=i,this.propsProvider=r,this.colWidth=0,this._monomerLengthList=null,this._processedMaxVisibleSeqLength=0,this._monomerLengthMap={},this._monomerStructureMap={},this._ellipsisBounds=void 0,this._totalLinesNeeded=0,this._lineHeight=20,this._cellBounds=new Map,this.sysMonomerLib=null,this.padding=5,this._leftThreeDotsPadding=0,this.props=this.propsProvider(),this._processedRows=o.BitSet.create(this.tableCol.length),this.gridCol&&this.subs.push(this.gridCol.grid.onAfterDrawContent.subscribe(()=>{this._onRendered.next()})),this.tableCol&&this.gridCol){this.subs.push(this.tableCol.dataFrame.onCurrentRowChanged.subscribe(()=>{-1===this.tableCol.dataFrame.currentRowIdx&&(this.tableCol.temp["reference-sequence"]=null,this.tableCol.temp["current-word"]=null,this.invalidateGrid())}));const e=[l.gp.positionShift,"renderMultiline"];this.subs.push(o.debounce(this.tableCol.dataFrame.onMetadataChanged.pipe(g.filter(t=>t.args.source===this.tableCol&&e.includes(t.args.key))),200).subscribe(e=>{this.reset()})),this.subs.push(o.debounce(this.tableCol.dataFrame.onMetadataChanged.pipe(g.filter(e=>e.args.source===this.tableCol&&e.args.key===l.gp.positionShift)),200).subscribe(e=>{this.reset()}))}}calculateFontBasedSpacing(e){const t=e.measureText("M");let n=12;if(this.tableCol?.temp[".mm.cellRenderer.fontSize"]){const e=this.tableCol.temp[".mm.cellRenderer.fontSize"];"number"!=typeof e||isNaN(e)||(n=Math.max(e,1))}return{lineHeight:Math.max(1.4*n,t.fontBoundingBoxAscent+t.fontBoundingBoxDescent+4),monomerSpacing:Math.max(2,.2*this.props.fontCharWidth)}}shouldUseMultilineRendering(e){return"true"===e.getTag("renderMultiline")}calculateMultiLineLayoutDynamic(e,t,n,i,o,r){if(this.dirty)try{this.reset()}catch(e){const[t,n]=(0,h.AP)(e);this.logger.error(t,void 0,n)}const{lineHeight:s,monomerSpacing:a}=this.calculateFontBasedSpacing(e),l=t-2*this.padding;let c=0;const u=[];if(i.length>0)for(let t=o;t<i.length;t++){const n=i.getOriginal(t),o=this.props.monomerToShort(n,r);u.push({text:o,posIdx:t}),c=Math.max(c,e.measureText(o).width)}if(0===u.length)return{lineLayouts:[],lineHeight:s};const d=c;let p=Math.floor((l+a)/(d+a));p=Math.max(1,p);const m=n-2*this.padding,f=Math.max(0,Math.floor(m/s)),g=[];let y=0;for(let e=0;e<f&&y<u.length;e++){const t=[];for(let e=0;e<p&&y<u.length;e++){const n=u[y],i=this.padding+e*(d+a);t.push({posIdx:n.posIdx,x:i,width:d,om:n.text,isSeparator:!1}),y++}g.push({lineIdx:e,elements:t})}return{lineLayouts:g,lineHeight:s}}async init(){await Promise.all([(async()=>{this.seqHelper=await(0,a.Q)(),this.invalidateGrid()})(),(async()=>{const e=await(0,u.pj)();this.sysMonomerLib=e.getMonomerLib()})()]),this.subs.push(this.sysMonomerLib.onChanged.subscribe(()=>{this.reset()})),this.reset()}static getFontSettings(e){let t=12;return e&&e.temp[".mm.cellRenderer.fontSize"]&&"number"==typeof e.temp[".mm.cellRenderer.fontSize"]&&!isNaN(e.temp[".mm.cellRenderer.fontSize"])&&(t=Math.max(e.temp[".mm.cellRenderer.fontSize"],1)),{font:`${t}px monospace`,fontWidth:.6*t}}toLog(){return`MonomerPlacer<${this.viewerId}>`}getMonomerLib(){return this.tableCol.temp[".mm.cellRenderer.overriddenLibrary"]??this.sysMonomerLib}reset(){this.propsProvider&&(this.props=this.propsProvider()),this._processedRows=o.BitSet.create(this.tableCol.length),this._monomerLengthList=null,this._monomerLengthMap={},this._monomerStructureMap={},this._cellBounds.clear(),super.reset(),this.invalidateGrid()}invalidateGrid(){this.gridCol&&this.gridCol.dart&&this.gridCol.grid?.invalidate()}getCellMonomerLengths(e,t){const n=this.seqHelper.getSeqHandler(this.tableCol);if(this.colWidth<t&&(this.colWidth=t,this.dirty=!0),this.dirty)try{this.reset()}catch(e){const[t,n]=(0,h.AP)(e);this.logger.error(t,void 0,n)}const i=n.isMsa()?this.getCellMonomerLengthsForSeqMsa():this.getCellMonomerLengthsForSeq(e);return[i,this.getSummedMonomerLengths(i)]}getSummedMonomerLengths(e){const t=new Array(e.length+1);t[0]=this.padding;for(let n=1;n<t.length;n++)t[n]=t[n-1]+e[n-1];let n=t[0];for(let e=1;e<t.length;e++)t[e]?n=t[e]:t[e]=n;return t}getCellMonomerLengthsForSeqValue(e,t){const n=this.seqHelper.getSeqHandler(this.tableCol),i=this.props.separatorWidth+1*this.props.fontCharWidth,o=this.positionShift,r=Math.ceil(t/i)+o,s=n.splitter(e),a=Math.min(r,s.length),l=new Array(a-o);let c=0;for(let e=o;e<a;++e){const i=s.getOriginal(e),r=this.props.monomerToShort(i,this.monomerLengthLimit),a=(n.isSeparator()?this.separatorWidth:this.props.separatorWidth)+r.length*this.props.fontCharWidth;if(l[e-o]=a,c+=a,c>t)break}return l}getCellMonomerLengthsForSeq(e){this.toLog(),null===this._monomerLengthList&&(this._monomerLengthList=new Array(this.tableCol.length).fill(null));const t=this.positionShift,n=this.seqHelper.getSeqHandler(this.tableCol),i=this.props.separatorWidth+1*this.props.fontCharWidth,o=Math.ceil(this.colWidth/i)+t,r=n.getSplitted(e),s=Math.min(o,r.length);let a=this._monomerLengthList[e];if(null===a||a.length!=s-t){a=this._monomerLengthList[e]=new Array(r.length);let i=0;for(let e=t;e<s;++e){const o=r.getOriginal(e),s=this.props.monomerToShort(o,this.monomerLengthLimit),l=(n.isSeparator()?this.separatorWidth:this.props.separatorWidth)+s.length*this.props.fontCharWidth;if(a[e-t]=l,i+=l,i>this.colWidth)break}}return a}getCellMonomerLengthsForSeqMsa(){var e;this.toLog(),null===this._monomerLengthList&&(this._monomerLengthList=new Array(1).fill(null)),(e=this._monomerLengthList)[0]??(e[0]=new Array(0));const t=this._monomerLengthList[0],{startIdx:n,endIdx:i}=(()=>{try{const e=this.gridCol&&this.gridCol.dart?this.gridCol.grid:null;return e&&e.dart?{startIdx:Math.max(Math.floor((e?.vertScroll.min??0)-10),0),endIdx:Math.min(Math.ceil((e?.vertScroll.max??0)+10),this.tableCol.length)}:{startIdx:0,endIdx:Math.min(this.tableCol.length,10)}}catch(e){return{startIdx:0,endIdx:Math.min(this.tableCol.length,10)}}})(),o=this.props.separatorWidth+1*this.props.fontCharWidth,r=this.positionShift,s=Math.ceil(this.colWidth/o)+r;for(let e=n;e<i;e++){if(this._processedRows.get(e)&&s<=this._processedMaxVisibleSeqLength)continue;const n=this.seqHelper.getSeqHandler(this.tableCol).getSplitted(e,s),i=Math.min(s,n.length);i-r>t.length&&t.push(...new Array(i-r-t.length).fill(o));let a=0;for(let e=r;e<i;++e){const i=n.getOriginal(e),o=this.props.monomerToShort(i,this.monomerLengthLimit),s=this.props.separatorWidth+o.length*this.props.fontCharWidth;if(t[e-r]=Math.max(t[e-r]??0,s),a+=s,a>=this.colWidth)break}this._processedMaxVisibleSeqLength=Math.max(this._processedMaxVisibleSeqLength,s),this._processedRows.set(e,!0)}return t}getPosition(e,t,n,i){const[o,r]=this.getCellMonomerLengths(e,n);return 0===this.seqHelper.getSeqHandler(this.tableCol).getSplitted(e).length?null:function(e,t,n){if((n??0)>0&&t<(e[0]??0)+n)return-1;t-=n??0;let i,o=100,r=0,s=e.length-1;for(;r<=s;){if(i=Math.floor((s+r)/2),e[i]<=t&&t<e[i+1])return i;if(t<e[i]?s=i-1:r=i+1,--o<=0)throw new Error(`Get position for pointer x = ${t} searching has not converged on ${JSON.stringify(e)}. `)}return null}(r,t,i)}setMonomerLengthLimit(e){this.monomerLengthLimit!=e&&(this.monomerLengthLimit=e,this.dirty=!0)}setSeparatorWidth(e){this.separatorWidth!=e&&(this.props.separatorWidth=e,this.dirty=!0)}get positionShift(){const e=Number.parseInt(this.tableCol?.tags[l.gp.positionShift]??"0")??0;return isNaN(e)?0:Math.max(e,0)}render(e,t,n,i,r,a,c){const u=a.grid?.dart&&a.grid?.canvas===e.canvas;if(!this.seqHelper)return;const m=this.tableCol,f=this.positionShift;e.save();try{const c=this.seqHelper.getSeqHandler(m);let h=this.monomerLengthLimit;if(d.gp.maxMonomerLength in m.tags){const e=parseInt(m.getTag(d.gp.maxMonomerLength));h=!isNaN(e)&&e?e:50}if(".mm.cellRenderer.maxMonomerLength"in m.temp){const e=m.temp[".mm.cellRenderer.maxMonomerLength"],t="number"==typeof e?e:parseInt(e);h=!isNaN(t)&&t?t:50}if(m.temp[".mm.cellRenderer.settingsChanged"]===p.s.true||this.monomerLengthLimit!=h){let e=0;const t=8;e=m.temp[".mm.cellRenderer.gapLength"]??e,this.setMonomerLengthLimit(h),this.setSeparatorWidth(c.isMsa()?t:e),m.temp[".mm.cellRenderer.settingsChanged"]=p.s.false,this.dirty=!0}const g=a.cell.rowIndex,b=a.cell.value;u&&(i=v(a.grid,e,t,i,window.devicePixelRatio)),e.beginPath(),e.rect(t,n,i,r),e.clip(),e.font=this.props?.font??"12px monospace",e.textBaseline="top";const w=m.meta.units,C=m.getTag(l.gp.aligned),S=m.getTag(l.gp.separator)??"",A=u?c.getSplitted(g):c.splitter(b);let x=d.yg.classic;C?.includes("MSA")&&w===l.Hi.SEPARATOR&&(x=d.yg.MSA);const M=m.temp["reference-sequence"],T=this.tableCol.temp["current-word"],E=(()=>{const e=(0,c.splitter)(null!=M&&""!==M?M:T??"");return s().count(0).take(e.length).slice(f).map(t=>e.getCanonical(t)).toArray()})(),_=Number.parseInt(m.getTag(l.gp.selectedPosition)??"-200");if(this.shouldUseMultilineRendering(m)){const s=[],l=this.calculateMultiLineLayoutDynamic(e,i,r,A,f,h);let u=n+this.padding;1===l.lineLayouts.length&&(u=n+(r-l.lineHeight)/2);for(const i of l.lineLayouts){const r=u+i.lineIdx*l.lineHeight;for(const u of i.elements){const h=t+u.x,p=u,g=p.posIdx,b=A.getCanonical(g);let v=y;const w=this.getMonomerLib();w&&(v=w.getMonomerTextColor(c.defaultBiotype,b));let C=0;if(a.tableRowIndex!==m.dataFrame.currentRowIdx&&E.length>0){const e=g-f;e>=0&&e<E.length&&b===E[e]&&(C=.7)}s.push({lineIdx:i.lineIdx,monomerIdx:g-f,bounds:new o.Rect(u.x,r-n,u.width,l.lineHeight),sequencePosition:g}),(0,d.oZ)(e,p.om,h,r,u.width,l.lineHeight,{color:v,isMultiLineContext:!0,transparencyRate:C,selectedPosition:isNaN(_)||_<1?void 0:_,wordIdx:g})}}null!==a.tableRowIndex&&this._cellBounds.set(a.tableRowIndex,s)}else{this._leftThreeDotsPadding=this.shouldRenderShiftedThreeDots(f)?e.measureText("...").width:0;let[,o]=this.getCellMonomerLengths(a.tableRowIndex,i);u||(o=this.getSummedMonomerLengths(this.getCellMonomerLengthsForSeqValue(b,i)));const s=this.props.separatorWidth+1*this.props.fontCharWidth,l=Math.min(A.length,Math.ceil(i/s)+f);for(let s=f;s<l;++s){const l=s<A.length?A.getOriginal(s):c.defaultGapOriginal,u=s<A.length?A.getCanonical(s):c.defaultGapOriginal;let p=y;this.getMonomerLib()&&(p=this.getMonomerLib().getMonomerTextColor(c.defaultBiotype,u));const m=s===A.length-1,g={color:p,pivot:0,left:!0,transparencyRate:0,separator:(A?.graphInfo?.disjointSeqStarts?.indexOf(s+1)??0)>0?"|":S,last:m,drawStyle:x,maxWord:o,wordIdx:s-f,gridCell:a,referenceSequence:E,maxLengthOfMonomer:h,monomerTextSizeMap:this._monomerLengthMap,logger:this.logger,selectedPosition:isNaN(_)||_<1?void 0:_-f};(0,d.oZ)(e,l,t+this.padding+this._leftThreeDotsPadding,n,i,r,g)}if(this.shouldRenderShiftedThreeDots(f)){const s={color:y,pivot:0,left:!0,transparencyRate:0,separator:S,last:!1,drawStyle:x,maxWord:o,wordIdx:0,gridCell:a,maxLengthOfMonomer:h,monomerTextSizeMap:this._monomerLengthMap,logger:this.logger};(0,d.oZ)(e,"...",t+this.padding,n,i,r,s)}}}catch(e){const[t,n]=(0,h.AP)(e);this.logger.error(t,void 0,n),this.errors.push(e)}finally{e.restore()}}shouldRenderShiftedThreeDots(e){return e>0&&(!this.gridCol||!this.gridCol.dart||!this.gridCol.grid||!this.gridCol.grid.dart||(this.gridCol.grid.props.colHeaderHeight??0)<=50)}onMouseMove(e,t){const n=`${this.toLog()}.onMouseMove()`;if(!this.seqHelper||null==e.tableRowIndex)return;const o=this.positionShift,r=e.bounds,s=t.offsetX-e.gridColumn.left+(e.gridColumn.left-r.x),a=t.offsetY-r.y;this.gridCol?.grid?.canvas&&(this.gridCol.grid.canvas.style.cursor="default");let c=null;const u=this._cellBounds.get(e.tableRowIndex);if(u){for(const e of u)if(e.bounds.contains(s,a)){c=e.monomerIdx;break}}else{const t=this.shouldRenderShiftedThreeDots(o)&&(this._leftThreeDotsPadding??0)>0?this._leftThreeDotsPadding:0;c=this.getPosition(e.tableRowIndex,s,r.width,t)}this.logger.debug(`${n}, argsX: ${s}, argsY: ${a}, left: ${c}`);const h=this.seqHelper.getSeqHandler(this.tableCol),d=h.getSplitted(e.tableRowIndex);if(null!==c&&c>=0&&c+o<d.length){const n=h.alphabet??l.YI.UN,r={position:c,biotype:n===l.YI.RNA||n===l.YI.DNA?m.o.NUCLEOTIDE:m.o.AA,symbol:d.getCanonical(c+o)},s=[];let a=this._monomerStructureMap[r.symbol];if(!a){const e=this.getMonomerLib();a=this._monomerStructureMap[r.symbol]=e?e.getTooltip(r.biotype,r.symbol):i.divText("Monomer library is not available")}s.push(a),i.tooltip.show(i.divV(s),t.x+16,t.y+16),(0,f.WN)(e,r)}else-1===c?i.tooltip.show(i.divText(`${Math.min(o,d.length)} hidden monomers`),t.x+16,t.y+16):i.tooltip.hide(),(0,f.WN)(e,null)}}function v(e,t,n,i,o){return e?Math.max(Math.min(e.canvas.width/o-n,i)):Math.max(t.canvas.width/o-n,0)}},6939:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getSchemaRefs=t.resolveUrl=t.normalizeId=t._getFullPath=t.getFullPath=t.inlineRef=void 0;const i=n(4227),o=n(2017),r=n(7106),s=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);t.inlineRef=function(e,t=!0){return"boolean"==typeof e||(!0===t?!l(e):!!t&&c(e)<=t)};const a=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function l(e){for(const t in e){if(a.has(t))return!0;const n=e[t];if(Array.isArray(n)&&n.some(l))return!0;if("object"==typeof n&&l(n))return!0}return!1}function c(e){let t=0;for(const n in e){if("$ref"===n)return 1/0;if(t++,!s.has(n)&&("object"==typeof e[n]&&(0,i.eachItem)(e[n],e=>t+=c(e)),t===1/0))return 1/0}return t}function u(e,t="",n){!1!==n&&(t=p(t));const i=e.parse(t);return h(e,i)}function h(e,t){return e.serialize(t).split("#")[0]+"#"}t.getFullPath=u,t._getFullPath=h;const d=/#\/?$/;function p(e){return e?e.replace(d,""):""}t.normalizeId=p,t.resolveUrl=function(e,t,n){return n=p(n),e.resolve(t,n)};const m=/^[a-z_][-a-z0-9._]*$/i;t.getSchemaRefs=function(e,t){if("boolean"==typeof e)return{};const{schemaId:n,uriResolver:i}=this.opts,s=p(e[n]||t),a={"":s},l=u(i,s,!1),c={},h=new Set;return r(e,{allKeys:!0},(e,t,i,o)=>{if(void 0===o)return;const r=l+t;let s=a[o];function u(t){const n=this.opts.uriResolver.resolve;if(t=p(s?n(s,t):t),h.has(t))throw f(t);h.add(t);let i=this.refs[t];return"string"==typeof i&&(i=this.refs[i]),"object"==typeof i?d(e,i.schema,t):t!==p(r)&&("#"===t[0]?(d(e,c[t],t),c[t]=e):this.refs[t]=r),t}function g(e){if("string"==typeof e){if(!m.test(e))throw new Error(`invalid anchor "${e}"`);u.call(this,`#${e}`)}}"string"==typeof e[n]&&(s=u.call(this,e[n])),g.call(this,e.$anchor),g.call(this,e.$dynamicAnchor),a[t]=s}),c;function d(e,t,n){if(void 0!==t&&!o(e,t))throw f(n)}function f(e){return new Error(`reference "${e}" resolves to more than one schema`)}}},6956:(e,t,n)=>{"use strict";n.d(t,{m:()=>o,x:()=>i});const i="|",o="H"},7060:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(5882),o=n(3439),r=n(7307),s=n(422),a=n(4486),l=n(4003),c=n(1163),u=n(617),h=n(7935),d=n(8643),p=[i.default,o.default,r.default,s.default,a.default,l.default,c.default,u.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},h.default,d.default];t.default=p},7082:e=>{"use strict";e.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/meta/validation","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/validation":true},"$dynamicAnchor":"meta","title":"Validation vocabulary meta-schema","type":["object","boolean"],"properties":{"type":{"anyOf":[{"$ref":"#/$defs/simpleTypes"},{"type":"array","items":{"$ref":"#/$defs/simpleTypes"},"minItems":1,"uniqueItems":true}]},"const":true,"enum":{"type":"array","items":true},"multipleOf":{"type":"number","exclusiveMinimum":0},"maximum":{"type":"number"},"exclusiveMaximum":{"type":"number"},"minimum":{"type":"number"},"exclusiveMinimum":{"type":"number"},"maxLength":{"$ref":"#/$defs/nonNegativeInteger"},"minLength":{"$ref":"#/$defs/nonNegativeIntegerDefault0"},"pattern":{"type":"string","format":"regex"},"maxItems":{"$ref":"#/$defs/nonNegativeInteger"},"minItems":{"$ref":"#/$defs/nonNegativeIntegerDefault0"},"uniqueItems":{"type":"boolean","default":false},"maxContains":{"$ref":"#/$defs/nonNegativeInteger"},"minContains":{"$ref":"#/$defs/nonNegativeInteger","default":1},"maxProperties":{"$ref":"#/$defs/nonNegativeInteger"},"minProperties":{"$ref":"#/$defs/nonNegativeIntegerDefault0"},"required":{"$ref":"#/$defs/stringArray"},"dependentRequired":{"type":"object","additionalProperties":{"$ref":"#/$defs/stringArray"}}},"$defs":{"nonNegativeInteger":{"type":"integer","minimum":0},"nonNegativeIntegerDefault0":{"$ref":"#/$defs/nonNegativeInteger","default":0},"simpleTypes":{"enum":["array","boolean","integer","null","number","object","string"]},"stringArray":{"type":"array","items":{"type":"string"},"uniqueItems":true,"default":[]}}}')},7106:e=>{"use strict";var t=e.exports=function(e,t,i){"function"==typeof t&&(i=t,t={}),n(t,"function"==typeof(i=t.cb||i)?i:i.pre||function(){},i.post||function(){},e,"",e)};function n(e,o,r,s,a,l,c,u,h,d){if(s&&"object"==typeof s&&!Array.isArray(s)){for(var p in o(s,a,l,c,u,h,d),s){var m=s[p];if(Array.isArray(m)){if(p in t.arrayKeywords)for(var f=0;f<m.length;f++)n(e,o,r,m[f],a+"/"+p+"/"+f,l,a,p,s,f)}else if(p in t.propsKeywords){if(m&&"object"==typeof m)for(var g in m)n(e,o,r,m[g],a+"/"+p+"/"+i(g),l,a,p,s,g)}else(p in t.keywords||e.allKeys&&!(p in t.skipKeywords))&&n(e,o,r,m,a+"/"+p,l,a,p,s)}r(s,a,l,c,u,h,d)}}function i(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}t.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0},t.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},t.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},t.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0}},7216:e=>{"use strict";e.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/meta/applicator","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/applicator":true},"$dynamicAnchor":"meta","title":"Applicator vocabulary meta-schema","type":["object","boolean"],"properties":{"prefixItems":{"$ref":"#/$defs/schemaArray"},"items":{"$dynamicRef":"#meta"},"contains":{"$dynamicRef":"#meta"},"additionalProperties":{"$dynamicRef":"#meta"},"properties":{"type":"object","additionalProperties":{"$dynamicRef":"#meta"},"default":{}},"patternProperties":{"type":"object","additionalProperties":{"$dynamicRef":"#meta"},"propertyNames":{"format":"regex"},"default":{}},"dependentSchemas":{"type":"object","additionalProperties":{"$dynamicRef":"#meta"},"default":{}},"propertyNames":{"$dynamicRef":"#meta"},"if":{"$dynamicRef":"#meta"},"then":{"$dynamicRef":"#meta"},"else":{"$dynamicRef":"#meta"},"allOf":{"$ref":"#/$defs/schemaArray"},"anyOf":{"$ref":"#/$defs/schemaArray"},"oneOf":{"$ref":"#/$defs/schemaArray"},"not":{"$dynamicRef":"#meta"}},"$defs":{"schemaArray":{"type":"array","minItems":1,"items":{"$dynamicRef":"#meta"}}}}')},7278:(e,t,n)=>{"use strict";n.d(t,{Iv:()=>C,J9:()=>g,MD:()=>_,Mu:()=>d,Qf:()=>x,bR:()=>w,dh:()=>b,mn:()=>E,p0:()=>T,pc:()=>M,qp:()=>v,tm:()=>y,zS:()=>A});var i=n(6082),o=n(1991),r=n.n(o),s=n(3527),a=n(3629),l=n(2738),c=n(439),u=(n(8924),n(1093),n(4152),n(8438)),h=n(3599);class d{get length(){return this.mList.length}get graphInfo(){}isGap(e){return this.getOriginal(e)===this.gapOriginalMonomer}getCanonical(e){if(this.length<=e)throw new Error("Index out of bounds");const t=this.mList[e];return t!==this.gapOriginalMonomer?t:c._S}getOriginal(e){if(this.length<=e)throw new Error("Index out of bounds");return this.mList[e]}getCanonicalRegion(e,t){const n=Math.min(Math.max(0,e),this.length),i=Math.max(Math.min(this.length,t),0)-n,o=this.gapOriginalMonomer;return new Array(i).fill(null).map((e,t)=>{const i=this.mList[t+n];return i===o?c._S:i})}getOriginalRegion(e,t){const n=Math.min(Math.max(0,e),this.length),i=Math.max(Math.min(this.length,t),0);return new Array(i-n).fill(null).map((e,t)=>this.mList[t+n])}get gapOriginal(){return this.gapOriginalMonomer}constructor(e,t){this.mList=e,this.gapOriginalMonomer=t}}class p extends d{constructor(e,t,n,i){super(e.flat(),i),this.mListSeparated=e,this.connections=t,this._graphInfo=void 0,this.polymerTypes=e.map((e,t)=>new Array(e.length).fill(n[t])).flat()}get graphInfo(){return this._graphInfo??(this._graphInfo=this.parseConnections()),this._graphInfo}parseConnections(){const e={connections:[],disjointSeqStarts:[],polymerTypes:this.polymerTypes};if((this.connections?.length??0)>0){let t=0;for(let n=0;n<this.mListSeparated.length;++n)e.disjointSeqStarts.push(t),t+=this.mListSeparated[n].length;const n=(this.connections??"").split("|").filter(e=>(e?.length??0)>0),i=/^(PEPTIDE|RNA|BLOB|CHEM)\d{1,2}$/,o=/^\d{1,2}:R\d{1}-\d{1,2}:R\d{1}$/;for(const t of n){const n=t.split(",");if(3!==n.length||!o.test(n[2])||!i.test(n[0])||!i.test(n[1]))continue;const r=parseInt(n[0].replace(/^(PEPTIDE|RNA|BLOB|CHEM)/,""))-1,s=parseInt(n[1].replace(/^(PEPTIDE|RNA|BLOB|CHEM)/,""))-1,a=n[0].replace(/\d{1,2}$/,""),l=n[1].replace(/\d{1,2}$/,"");if(r<0||r>=this.mListSeparated.length||s<0||s>=this.mListSeparated.length)continue;const c=n[2].split("-");if(2!==c.length)continue;const u=c[0].split(":"),h=c[1].split(":");if(2!==u.length||2!==h.length)continue;const d=parseInt(u[0])-1,p=parseInt(h[0])-1;d<0||d>=this.mListSeparated[r].length||p<0||p>=this.mListSeparated[s].length||e.connections.push({seq1Type:a,seq2Type:l,seqIndex1:r,seqIndex2:s,monomerIndex1:d,monomerIndex2:p,rGroup1:parseInt(u[1].substring(1)),rGroup2:parseInt(h[1].substring(1))})}}return e}}class m extends p{getCanonical(e){if(this.isGap(e))return c._S;let t=this.getOriginal(e);const n=/\(\d{1,2},\d{1,2}\)$/;for(;n.test(t);)t=t.replace(n,"");return t}getOriginal(e){return super.getOriginal(e).replace(/^\[(.*)\]/,"$1")}constructor(e,t){super(e,"",e.map(()=>"PEPTIDE"),t)}parseConnections(){const e={connections:[],disjointSeqStarts:[]},t={};let n=0;for(let i=0;i<this.mListSeparated.length;i++){const o=this.mListSeparated[i];e.disjointSeqStarts.push(n),n+=o.length;for(let n=0;n<o.length;n++){const r=/\(\d{1,2},\d{1,2}\)$/;let s=o[n];for(;r.test(s);){const o=/\(\d{1,2},\d{1,2}\)$/.exec(s)?.[0];if(s=s.replace(r,""),null!=o){const r=o.substring(1,o.length-1).split(",").map(e=>parseInt(e,10));if(2!==r.length||r.some(e=>null==e||Number.isNaN(e)))continue;const s=r[0].toString(),a=r[1];if(s in t){const o=t[s];e.connections.push({seq1Type:"PEPTIDE",seq2Type:"PEPTIDE",seqIndex1:o.seqIndex,seqIndex2:i,monomerIndex1:o.monomerIndex,monomerIndex2:n,rGroup1:o.rGroup,rGroup2:a}),delete t[s]}else t[s]={seqIndex:i,monomerIndex:n,rGroup:a}}}}}return e}}class f{get length(){return this.seqS.length}isGap(e){return this.getOriginal(e)===c.b9[c.Hi.FASTA]}getCanonical(e){if(this.length<=e)throw new Error("Index out of bounds");return this.isGap(e)?c._S:this.seqS[e]}getOriginal(e){if(this.length<=e)throw new Error("Index out of bounds");return this.seqS[e]}getCanonicalRegion(e,t){const n=Math.max(0,e),i=Math.min(this.length,t)-n,o=c.b9[c.Hi.FASTA];return new Array(i).fill(null).map((e,t)=>{const i=this.seqS[t+n];return i===o?c._S:i})}getOriginalRegion(e,t){const n=Math.max(0,e),i=Math.min(this.length,t);return this.seqS.slice(n,i)}get gapOriginal(){return c.b9[c.Hi.FASTA]}constructor(e){this.seqS=e}}const g=e=>{const t=r()(e.toString().matchAll(c.B5)).map(e=>e[2]??e[1]).toArray();return new d(t,c.b9[c.Hi.FASTA])},y=e=>e?new f(e):new d([],c.b9[c.Hi.FASTA]);function b(e,t=void 0){return n=>{if(n){let i;const o=new RegExp(`(?<=^|\\${e})("-"|'-'|[^\\${e}]*)(?=\\${e}|$)`,"g");return null!=t?(o.lastIndex=0,i=r()(n.matchAll(o)).take(t).map(e=>e[0]).toArray()):i=n.replaceAll('"-"',"").replaceAll("'-'","").split(e,t),new d(i,c.b9[c.Hi.SEPARATOR])}return new d([],c.b9[c.Hi.SEPARATOR])}}const v=e=>{const t=e.indexOf("}$"),n=e.substring(0,t+1),i=e.indexOf("$",t+2),o=e.substring(t+2,i),r=n.split("}|");for(let e=0;e<r.length-1;e++)r[e]=r[e]+"}";const s=r.map(e=>(e.match(/(?<=\{).+(?=})/)?.[0]?.split(".")??[]).map(e=>(0,u.D)(e))),a=r.map(e=>e.replace(/\d{1,2}\{.+\}/,""));return new p(s,o??"",a,c.b9[c.Hi.HELM])};function w(e){const t=e.split(".").map(e=>e.replaceAll('"-"',"").replaceAll("'-'","")),n="___TEMP___";for(let e=0;e<t.length;e++){const i=/\[([^\]]+)\]/g;let o,r=t[e];for(;null!==(o=i.exec(t[e]));){const e=o[1],t=e.replaceAll("-",n);r=r.replace(e,t)}t[e]=r}const i=t.map(e=>e.split("-").map(e=>e.replaceAll(n,"-")));return new m(i,c.b9[c.Hi.SEPARATOR])}function C(e,t,n=void 0){if(e.toLowerCase().startsWith(c.Hi.FASTA))return g;if(e.toLowerCase().startsWith(c.Hi.SEPARATOR))return b(t,n);if(e.toLowerCase().startsWith(c.Hi.HELM))return v;if(e.toLowerCase().startsWith(c.Hi.BILN))return w;throw new Error(`Unexpected units ${e} .`)}const S=/([^\W_]+)/g;function A(e,t){if(e.length<=t)return e;const n=e.match(S),i=e.length>t||(n?.length??0)>1,o=n?.[0]??" ";return i?o.substring(0,t-1)+"…":o}function x(e){switch(e){case c.YI.DNA:return c.Vl.fasta.dna;case c.YI.RNA:return c.Vl.fasta.rna;case c.YI.PT:return c.Vl.fasta.peptide;default:throw new Error(`Unsupported alphabet '${e}'.`)}}function M(e,t,n="-"){const i=t.map(t=>{const i=function(e,t,n="-"){const i=new Set([...new Set(Object.keys(e)),...t]);i.delete(n);const o=[],r=[];for(const n of i)o.push(n in e?e[n]:0),r.push(t.has(n)?1:0);const l=new s.Mi(o),c=new s.Mi(r);return(0,a.KE)(l,c)/((0,a.wQ)(l)*(0,a.wQ)(c))}(e,t.alphabet,n);return new l.X(t,e,i)});let o;const r=Math.max(...i.map(e=>e.similarity>e.cutoff?e.similarity:-1));return o=r>0?i.find(e=>e.similarity===r).name:c.YI.UN,o}function T(e,t,n="-"){const i=Object.keys(e),o=/\(|\)/;return M(i.filter(e=>3===e.split(o).filter(e=>!!e).length).length>.8*i.length?Object.entries(e).reduce((e,[t,n])=>{const i=t.split(o)[1];return i&&(e[i]=n),e},{}):e,t,n)}function E(e){const t=e.columns.bySemTypeAll(i.SEMTYPE.MACROMOLECULE);let n=t.find(e=>{const t=e.meta.units;return!!t&&-1!==t.indexOf("MSA")})??null;return!n&&t.length>0&&(n=t[0]),n}function _(e){switch(e){case"PEPTIDE":default:return h.o.AA;case"RNA":return h.o.NUCLEOTIDE;case"CHEM":return h.o.CHEM;case"BLOB":return h.o.BLOB}}},7307:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o=n(4227),r=n(3853),s={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:{message({keyword:e,schemaCode:t}){const n="maxLength"===e?"more":"fewer";return i.str`must NOT have ${n} than ${t} characters`},params:({schemaCode:e})=>i._`{limit: ${e}}`},code(e){const{keyword:t,data:n,schemaCode:s,it:a}=e,l="maxLength"===t?i.operators.GT:i.operators.LT,c=!1===a.opts.unicode?i._`${n}.length`:i._`${(0,o.useFunc)(e.gen,r.default)}(${n})`;e.fail$data(i._`${c} ${l} ${s}`)}};t.default=s},7362:(e,t,n)=>{"use strict";n.d(t,{e:()=>i});class i{static makePalette(e,t=!1,n=i){const o={};return e.forEach(e=>{const n=e[0],i=e[1];n.forEach((e,n)=>{o[e]=this.colourPalette[i][t?0:n]})}),new n(o)}constructor(e){this._palette=e}get(e,t){return this._palette[e]}}i.undefinedColor="rgb(100,100,100)",i.colourPalette={orange:["rgb(255,187,120)","rgb(245,167,100)","rgb(235,137,70)","rgb(205, 111, 71)"],all_green:["rgb(44,160,44)","rgb(74,160,74)","rgb(23,103,57)","rgb(30,110,96)","rgb(60,131,95)","rgb(24,110,79)","rgb(152,223,138)","rgb(182, 223, 138)","rgb(152, 193, 138)"],all_blue:["rgb(31,119,180)","rgb(23,190,207)","rgb(122, 102, 189)","rgb(158,218,229)","rgb(141, 124, 217)","rgb(31, 120, 150)"],magenta:["rgb(162,106,192)","rgb(197,165,224)","rgb(208,113,218)"],red:["rgb(214,39,40)","rgb(255,152,150)"],st_blue:["rgb(23,190,207)","rgb(158,218,229)","rgb(31,119,180)"],dark_blue:["rgb(31,119,180)","rgb(31, 120, 150)"],light_blue:["rgb(23,190,207)","rgb(158,218,229)","rgb(108, 218, 229)","rgb(23,190,227)"],lilac_blue:["rgb(124,102,211)","rgb(149,134,217)","rgb(97, 81, 150)"],dark_green:["rgb(23,103,57)","rgb(30,110,96)","rgb(60,131,95)","rgb(24,110,79)"],green:["rgb(44,160,44)","rgb(74,160,74)"],light_green:["rgb(152,223,138)","rgb(182, 223, 138)","rgb(152, 193, 138)"],st_green:["rgb(44,160,44)","rgb(152,223,138)","rgb(39, 174, 96)","rgb(74,160,74)"],pink:["rgb(247,182,210)"],brown:["rgb(140,86,75)","rgb(102, 62, 54)"],gray:["rgb(127,127,127)","rgb(199,199,199)","rgb(196,156,148)","rgb(222, 222, 180)"],yellow:["rgb(188,189,34)"],white:["rgb(230,230,230)"]}},7389:e=>{"use strict";e.exports=ui},7433:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MissingRefError=t.ValidationError=t.CodeGen=t.Name=t.nil=t.stringify=t.str=t._=t.KeywordCxt=t.Ajv2020=void 0;const i=n(4042),o=n(6105),r=n(6653),s=n(9572),a="https://json-schema.org/draft/2020-12/schema";class l extends i.default{constructor(e={}){super({...e,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){super._addVocabularies(),o.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(r.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();const{$data:e,meta:t}=this.opts;t&&(s.default.call(this,e),this.refs["http://json-schema.org/schema"]=a)}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(a)?a:void 0)}}t.Ajv2020=l,e.exports=t=l,e.exports.Ajv2020=l,Object.defineProperty(t,"__esModule",{value:!0}),t.default=l;var c=n(2586);Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return c.KeywordCxt}});var u=n(9029);Object.defineProperty(t,"_",{enumerable:!0,get:function(){return u._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return u.str}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return u.stringify}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return u.nil}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return u.Name}}),Object.defineProperty(t,"CodeGen",{enumerable:!0,get:function(){return u.CodeGen}});var h=n(3558);Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return h.default}});var d=n(4551);Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return d.default}})},7532:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=[n(4737).default];t.default=i},7602:(e,t,n)=>{"use strict";n.d(t,{g:()=>r});var i,o=n(9192);!function(e){e[e.error=0]="error",e[e.warning=1]="warning",e[e.info=2]="info",e[e.debug=3]="debug"}(i||(i={}));class r{constructor(e){this.logger=e,this.promise=Promise.resolve(),this.errors=[],this.syncCounter=0}sync(e,t){const n=++this.syncCounter;this.logger.debug(`${e}, SYNC syncId = ${n}, IN `),this.promise=this.promise.then(async()=>{this.logger.debug(`${e}, SYNC syncId = ${n}, START `),await t(),this.logger.debug(`${e}, SYNC syncId = ${n}, END `)}).catch(t=>{const[i,r]=(0,o.AP)(t);this.logger.error(`${e}, SYNC syncId = ${n}, ERROR:\n${i}`,void 0,r),this.errors.push(t)})}resetErrors(){const e=this.errors;return this.errors=[],e}}},7652:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.DiscrError=void 0,function(e){e.Tag="tag",e.Mapping="mapping"}(n||(t.DiscrError=n={}))},7659:e=>{"use strict";var t={};e.exports=function(e,n){var i=function(e){if(void 0===t[e]){var n=document.querySelector(e);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(e){n=null}t[e]=n}return t[e]}(e);if(!i)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");i.appendChild(n)}},7825:e=>{"use strict";e.exports=function(e){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var t=e.insertStyleElement(e);return{update:function(n){!function(e,t,n){var i="";n.supports&&(i+="@supports (".concat(n.supports,") {")),n.media&&(i+="@media ".concat(n.media," {"));var o=void 0!==n.layer;o&&(i+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),i+=n.css,o&&(i+="}"),n.media&&(i+="}"),n.supports&&(i+="}");var r=n.sourceMap;r&&"undefined"!=typeof btoa&&(i+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(r))))," */")),t.styleTagTransform(i,e,t.options)}(t,e,n)},remove:function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(t)}}}},7845:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ValueScope=t.ValueScopeName=t.Scope=t.varKinds=t.UsedValueState=void 0;const i=n(1520);class o extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}}var r;!function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"}(r||(t.UsedValueState=r={})),t.varKinds={const:new i.Name("const"),let:new i.Name("let"),var:new i.Name("var")};class s{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof i.Name?e:this.name(e)}name(e){return new i.Name(this._newName(e))}_newName(e){return`${e}${(this._names[e]||this._nameGroup(e)).index++}`}_nameGroup(e){var t,n;if((null===(n=null===(t=this._parent)||void 0===t?void 0:t._prefixes)||void 0===n?void 0:n.has(e))||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}}t.Scope=s;class a extends i.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:t,itemIndex:n}){this.value=e,this.scopePath=i._`.${new i.Name(t)}[${n}]`}}t.ValueScopeName=a;const l=i._`\n`;t.ValueScope=class extends s{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?l:i.nil}}get(){return this._scope}name(e){return new a(e,this._newName(e))}value(e,t){var n;if(void 0===t.ref)throw new Error("CodeGen: ref must be passed in value");const i=this.toName(e),{prefix:o}=i,r=null!==(n=t.key)&&void 0!==n?n:t.ref;let s=this._values[o];if(s){const e=s.get(r);if(e)return e}else s=this._values[o]=new Map;s.set(r,i);const a=this._scope[o]||(this._scope[o]=[]),l=a.length;return a[l]=t.ref,i.setValue(t,{property:o,itemIndex:l}),i}getValue(e,t){const n=this._values[e];if(n)return n.get(t)}scopeRefs(e,t=this._values){return this._reduceValues(t,t=>{if(void 0===t.scopePath)throw new Error(`CodeGen: name "${t}" has no value`);return i._`${e}${t.scopePath}`})}scopeCode(e=this._values,t,n){return this._reduceValues(e,e=>{if(void 0===e.value)throw new Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,n)}_reduceValues(e,n,s={},a){let l=i.nil;for(const c in e){const u=e[c];if(!u)continue;const h=s[c]=s[c]||new Map;u.forEach(e=>{if(h.has(e))return;h.set(e,r.Started);let s=n(e);if(s){const n=this.opts.es5?t.varKinds.var:t.varKinds.const;l=i._`${l}${n} ${e} = ${s};${this.opts._n}`}else{if(!(s=null==a?void 0:a(e)))throw new o(e);l=i._`${l}${s}${this.opts._n}`}h.set(e,r.Completed)})}return l}}},7870:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.assignDefaults=void 0;const i=n(9029),o=n(4227);function r(e,t,n){const{gen:r,compositeRule:s,data:a,opts:l}=e;if(void 0===n)return;const c=i._`${a}${(0,i.getProperty)(t)}`;if(s)return void(0,o.checkStrictMode)(e,`default is ignored for: ${c}`);let u=i._`${c} === undefined`;"empty"===l.useDefaults&&(u=i._`${u} || ${c} === null || ${c} === ""`),r.if(u,i._`${c} = ${(0,i.stringify)(n)}`)}t.assignDefaults=function(e,t){const{properties:n,items:i}=e.schema;if("object"===t&&n)for(const t in n)r(e,t,n[t].default);else"array"===t&&Array.isArray(i)&&i.forEach((t,n)=>r(e,n,t.default))}},7887:(e,t)=>{"use strict";function n(e,t){return t.rules.some(t=>i(e,t))}function i(e,t){var n;return void 0!==e[t.keyword]||(null===(n=t.definition.implements)||void 0===n?void 0:n.some(t=>void 0!==e[t]))}Object.defineProperty(t,"__esModule",{value:!0}),t.shouldUseRule=t.shouldUseGroup=t.schemaHasRulesForType=void 0,t.schemaHasRulesForType=function({schema:e,self:t},i){const o=t.RULES.types[i];return o&&!0!==o&&n(e,o)},t.shouldUseGroup=n,t.shouldUseRule=i},7923:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(4227),o={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){const{gen:t,schema:n,it:o}=e;if((0,i.alwaysValidSchema)(o,n))return void e.fail();const r=t.name("valid");e.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},r),e.failResult(r,()=>e.reset(),()=>e.error())},error:{message:"must NOT be valid"}};t.default=o},7935:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o=n(4227),r=n(6250),s={keyword:"const",$data:!0,error:{message:"must be equal to constant",params:({schemaCode:e})=>i._`{allowedValue: ${e}}`},code(e){const{gen:t,data:n,$data:s,schemaCode:a,schema:l}=e;s||l&&"object"==typeof l?e.fail$data(i._`!${(0,o.useFunc)(t,r.default)}(${n}, ${a})`):e.fail(i._`${l} !== ${n}`)}};t.default=s},7939:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var i=n(1354),o=n.n(i),r=n(6314),s=n.n(r)()(o());s.push([e.id,".scatter_plot_link {\n right: 10px;\n}\n\n.cliffs_div {\n flex-grow: initial!important;\n justify-content: flex-end;\n flex-wrap: wrap;\n}\n\n.cliffs_grid {\n margin: 0!important;\n}\n\n.ml-dim-reduction-settings-input i.grok-icon.grok-font-icon-settings {\n font-size: 18px;\n position: absolute;\n height: 28px;\n}\n\n.ml-dim-reduction-settings-input i.grok-icon.grok-font-icon-settings:not(.ml-dim-reduction-column-editor-input-root i) {\n left: -20px;\n}\n.dlg-dimensionality-reduction.ui-form, .dlg-markov-clustering.ui-form, .dlg-markov-clustering.ui-form .ui-form, .dlg-dimensionality-reduction.ui-form .ui-form {\n max-width: unset;\n}\n\n.ml-dim-reduction-column-editor-input-root label {\n display: none !important;\n}\n\n.dim-reduction-dialog-form > .ui-input-root, .dim-reduction-dialog-form > div > .ui-input-root {\n margin-left: 10px;\n}\n\n.ml-dim-reduction-column-editor-input-root input, .ml-dim-reduction-column-editor-input-root select {\n margin-left: 20px !important;\n}\n\nh3.ml-dim-reduction-column-editor-input-root {\n margin: 0 !important;\n}\n\n.ml-dim-reduction-column-editor-root, .ml-dim-reduction-column-editor-header-root {\n display: flex;\n flex-direction: row;\n align-items: center;\n margin-bottom: 10px !important;\n width: 700px !important;\n}\n\n.ml-dim-reduction-column-editor-column-title {\n text-overflow: ellipsis;\n overflow: hidden;\n}\n\n.ml-dim-reduction-column-editor-header-root > h1:not(:first-child) {\n margin-left: 20px !important;\n}\n\n.ml-dim-reduction-column-editor-table-root .header > td:not(:first-child) {\n padding-left: 32px;\n}","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/ml/css/styles.css"],names:[],mappings:"AAAA;IACI,WAAW;AACf;;AAEA;IACI,4BAA4B;IAC5B,yBAAyB;IACzB,eAAe;AACnB;;AAEA;GACG,mBAAmB;AACtB;;AAEA;IACI,eAAe;IACf,kBAAkB;IAClB,YAAY;AAChB;;AAEA;IACI,WAAW;AACf;AACA;IACI,gBAAgB;AACpB;;AAEA;IACI,wBAAwB;AAC5B;;AAEA;IACI,iBAAiB;AACrB;;AAEA;IACI,4BAA4B;AAChC;;AAEA;IACI,oBAAoB;AACxB;;AAEA;IACI,aAAa;IACb,mBAAmB;IACnB,mBAAmB;IACnB,8BAA8B;IAC9B,uBAAuB;AAC3B;;AAEA;IACI,uBAAuB;IACvB,gBAAgB;AACpB;;AAEA;IACI,4BAA4B;AAChC;;AAEA;IACI,kBAAkB;AACtB",sourcesContent:[".scatter_plot_link {\n right: 10px;\n}\n\n.cliffs_div {\n flex-grow: initial!important;\n justify-content: flex-end;\n flex-wrap: wrap;\n}\n\n.cliffs_grid {\n margin: 0!important;\n}\n\n.ml-dim-reduction-settings-input i.grok-icon.grok-font-icon-settings {\n font-size: 18px;\n position: absolute;\n height: 28px;\n}\n\n.ml-dim-reduction-settings-input i.grok-icon.grok-font-icon-settings:not(.ml-dim-reduction-column-editor-input-root i) {\n left: -20px;\n}\n.dlg-dimensionality-reduction.ui-form, .dlg-markov-clustering.ui-form, .dlg-markov-clustering.ui-form .ui-form, .dlg-dimensionality-reduction.ui-form .ui-form {\n max-width: unset;\n}\n\n.ml-dim-reduction-column-editor-input-root label {\n display: none !important;\n}\n\n.dim-reduction-dialog-form > .ui-input-root, .dim-reduction-dialog-form > div > .ui-input-root {\n margin-left: 10px;\n}\n\n.ml-dim-reduction-column-editor-input-root input, .ml-dim-reduction-column-editor-input-root select {\n margin-left: 20px !important;\n}\n\nh3.ml-dim-reduction-column-editor-input-root {\n margin: 0 !important;\n}\n\n.ml-dim-reduction-column-editor-root, .ml-dim-reduction-column-editor-header-root {\n display: flex;\n flex-direction: row;\n align-items: center;\n margin-bottom: 10px !important;\n width: 700px !important;\n}\n\n.ml-dim-reduction-column-editor-column-title {\n text-overflow: ellipsis;\n overflow: hidden;\n}\n\n.ml-dim-reduction-column-editor-header-root > h1:not(:first-child) {\n margin-left: 20px !important;\n}\n\n.ml-dim-reduction-column-editor-table-root .header > td:not(:first-child) {\n padding-left: 32px;\n}"],sourceRoot:""}]);const a=s},8070:(e,t,n)=>{"use strict";n.d(t,{cb:()=>a,PE:()=>s}),n(4328);var i=n(6082);n(9982),i.DataFrame.fromCsv('countries,fasta,smiles,molregno,LON,Zip Code,Street Address Line 1,ImageUrl,user_id,error_message,xray,flag,magnitude,CS-id,pdb_id,accel_a,time_offset,chart,fit,Questions,empty_number,empty_string\nBelgium,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C(=O)OCCCc1cccnc1)c2cccc(c2)C(=O)c3ccccc3,1480014,36.276729583740234,995042300,14016 ROUTE 31W,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,1,1,1QBS,1,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.497360340644872, 1.7058694986686864, 5.278052678195135, 0.16000320889028383],""points"":[{""x"":0.10000000149011612,""y"":2.374499797821045},{""x"":0.6000000238418579,""y"":2.6242473125457764},{""x"":1.100000023841858,""y"":2.367267608642578},{""x"":1.600000023841858,""y"":2.6723148822784424},{""x"":2.0999999046325684,""y"":2.6537344455718994},{""x"":2.5999999046325684,""y"":2.3651671409606934},{""x"":3.0999999046325684,""y"":2.5654284954071045},{""x"":3.5999999046325684,""y"":2.4160959720611572},{""x"":4.099999904632568,""y"":2.286726713180542},{""x"":4.599999904632568,""y"":2.5100042819976807},{""x"":5.099999904632568,""y"":1.6676985025405884},{""x"":5.599999904632568,""y"":0.680136501789093},{""x"":6.099999904632568,""y"":0.3391543924808502},{""x"":6.599999904632568,""y"":0.09038983285427094},{""x"":7.099999904632568,""y"":0.19802775979042053}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[7.525235855508179, 1.3186911876809984, 5.335672608564294, 0.7860743343958098],""points"":[{""x"":0.10000000149011612,""y"":7.988070487976074},{""x"":0.6000000238418579,""y"":7.018453121185303},{""x"":1.100000023841858,""y"":8.115279197692871},{""x"":1.600000023841858,""y"":7.486658096313477},{""x"":2.0999999046325684,""y"":7.396438121795654},{""x"":2.5999999046325684,""y"":7.477052211761475},{""x"":3.0999999046325684,""y"":6.913095474243164},{""x"":3.5999999046325684,""y"":8.01385498046875},{""x"":4.099999904632568,""y"":6.985900402069092},{""x"":4.599999904632568,""y"":6.970335960388184},{""x"":5.099999904632568,""y"":5.448817253112793},{""x"":5.599999904632568,""y"":2.5534818172454834},{""x"":6.099999904632568,""y"":1.893947958946228},{""x"":6.599999904632568,""y"":0.6340042352676392},{""x"":7.099999904632568,""y"":0.8403874039649963}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,100,abc\nBurundi,MDYKETLLMPKTDFPMRGGLPNKEPQIQEKW,COc1ccc2cc(ccc2c1)C(C)C(=O)Oc3ccc(C)cc3OC,1480015,36.276729583740234,995073444,80 STATE HIGHWAY 310,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,2,2,1ZP8,2,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.431460753103398, 2.1691498799246745, 5.266445597102774, 0.7825762827017926],""points"":[{""x"":0.10000000149011612,""y"":4.751083850860596},{""x"":0.6000000238418579,""y"":4.203000068664551},{""x"":1.100000023841858,""y"":4.415858745574951},{""x"":1.600000023841858,""y"":4.68414306640625},{""x"":2.0999999046325684,""y"":4.198400974273682},{""x"":2.5999999046325684,""y"":4.179222106933594},{""x"":3.0999999046325684,""y"":4.638473987579346},{""x"":3.5999999046325684,""y"":4.708553314208984},{""x"":4.099999904632568,""y"":4.291589260101318},{""x"":4.599999904632568,""y"":4.038082599639893},{""x"":5.099999904632568,""y"":3.4349939823150635},{""x"":5.599999904632568,""y"":1.2194708585739136},{""x"":6.099999904632568,""y"":1.1920831203460693},{""x"":6.599999904632568,""y"":0.5352635979652405},{""x"":7.099999904632568,""y"":0.3346920311450958}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.339458017970126, -1.0734184310171178, 4.746332950550934, 0.2482416857595658],""points"":[{""x"":0.10000000149011612,""y"":0.2139337658882141},{""x"":0.6000000238418579,""y"":0.4269562065601349},{""x"":1.100000023841858,""y"":0.2441573292016983},{""x"":1.600000023841858,""y"":0.146635964512825},{""x"":2.0999999046325684,""y"":0.08818462491035461},{""x"":2.5999999046325684,""y"":0.2560656666755676},{""x"":3.0999999046325684,""y"":0.42434045672416687},{""x"":3.5999999046325684,""y"":0.37111231684684753},{""x"":4.099999904632568,""y"":0.5581737160682678},{""x"":4.599999904632568,""y"":1.183590054512024},{""x"":5.099999904632568,""y"":1.5629843473434448},{""x"":5.599999904632568,""y"":2.3211288452148438},{""x"":6.099999904632568,""y"":2.229961633682251},{""x"":6.599999904632568,""y"":2.2560226917266846},{""x"":7.099999904632568,""y"":2.2142398357391357}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCameroon,MIEVFLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL,COc1ccc2cc(ccc2c1)C(C)C(=O)OCCCc3cccnc3,1480016,36.26095962524414,995153596,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,3,3,2BDJ,3,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.6760652578642325, 0.9046956320756703, 5.651408971856738, 0.07738846012184185],""points"":[{""x"":0.10000000149011612,""y"":4.32425594329834},{""x"":0.6000000238418579,""y"":4.668442249298096},{""x"":1.100000023841858,""y"":4.379785060882568},{""x"":1.600000023841858,""y"":5.0345139503479},{""x"":2.0999999046325684,""y"":4.878653526306152},{""x"":2.5999999046325684,""y"":4.3451313972473145},{""x"":3.0999999046325684,""y"":4.336992263793945},{""x"":3.5999999046325684,""y"":5.037430286407471},{""x"":4.099999904632568,""y"":5.0092692375183105},{""x"":4.599999904632568,""y"":4.151902675628662},{""x"":5.099999904632568,""y"":3.4066951274871826},{""x"":5.599999904632568,""y"":2.3732759952545166},{""x"":6.099999904632568,""y"":1.673728108406067},{""x"":6.599999904632568,""y"":0.48574790358543396},{""x"":7.099999904632568,""y"":0.2783052325248718}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.938395863010111, -1.4658480661392117, 5.462702751996584, 0.3473139023615039],""points"":[{""x"":0.10000000149011612,""y"":0.4941710829734802},{""x"":0.6000000238418579,""y"":0.15323974192142487},{""x"":1.100000023841858,""y"":0.46373432874679565},{""x"":1.600000023841858,""y"":0.3370431363582611},{""x"":2.0999999046325684,""y"":0.5179030299186707},{""x"":2.5999999046325684,""y"":0.27899765968322754},{""x"":3.0999999046325684,""y"":0.22075064480304718},{""x"":3.5999999046325684,""y"":0.5789918899536133},{""x"":4.099999904632568,""y"":0.21169911324977875},{""x"":4.599999904632568,""y"":0.27857646346092224},{""x"":5.099999904632568,""y"":1.0906332731246948},{""x"":5.599999904632568,""y"":1.8520300388336182},{""x"":6.099999904632568,""y"":2.7177059650421143},{""x"":6.599999904632568,""y"":2.8680918216705322},{""x"":7.099999904632568,""y"":3.2413077354431152}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCanada,MMELVLKTIIGPIVVGVVLRIVDKWLNKDK,CC(C(=O)NCCS)c1cccc(c1)C(=O)c2ccccc2,1480017,36.26095962524414,99515,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,4,4,1IAN,4,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[0.8597390975430008, 1.0957625732481946, 5.260537067987958, 0.07974187998177736],""points"":[{""x"":0.10000000149011612,""y"":0.8190152645111084},{""x"":0.6000000238418579,""y"":0.8421689867973328},{""x"":1.100000023841858,""y"":0.8740922212600708},{""x"":1.600000023841858,""y"":0.8924275040626526},{""x"":2.0999999046325684,""y"":0.8249067664146423},{""x"":2.5999999046325684,""y"":0.9327669143676758},{""x"":3.0999999046325684,""y"":0.8522974252700806},{""x"":3.5999999046325684,""y"":0.8174492716789246},{""x"":4.099999904632568,""y"":0.8394647240638733},{""x"":4.599999904632568,""y"":0.7139387726783752},{""x"":5.099999904632568,""y"":0.5561167597770691},{""x"":5.599999904632568,""y"":0.3276226818561554},{""x"":6.099999904632568,""y"":0.12479474395513535},{""x"":6.599999904632568,""y"":0.13006797432899475},{""x"":7.099999904632568,""y"":0.059702079743146896}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.760930219582546, 1.6591793293833013, 4.667155929720851, 0.7858109544121652],""points"":[{""x"":0.10000000149011612,""y"":6.156993389129639},{""x"":0.6000000238418579,""y"":5.236701965332031},{""x"":1.100000023841858,""y"":6.010560512542725},{""x"":1.600000023841858,""y"":5.495512962341309},{""x"":2.0999999046325684,""y"":6.087770462036133},{""x"":2.5999999046325684,""y"":5.79986572265625},{""x"":3.0999999046325684,""y"":5.597546577453613},{""x"":3.5999999046325684,""y"":5.520902156829834},{""x"":4.099999904632568,""y"":5.360654354095459},{""x"":4.599999904632568,""y"":3.5539746284484863},{""x"":5.099999904632568,""y"":1.577236294746399},{""x"":5.599999904632568,""y"":1.0001264810562134},{""x"":6.099999904632568,""y"":0.9305797815322876},{""x"":6.599999904632568,""y"":0.6033638715744019},{""x"":7.099999904632568,""y"":0.4203685522079468}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nColombia,MDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN,FC(F)(F)c1ccc(OC2CCNCC2)cc1,1480029,36.3309440612793,995152050,1 COURT HOUSE SQUARE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,5,5,4UJ1,5,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[6.4995088314153655, 2.4270351004539914, 5.178659535348579, 0.625653346241577],""points"":[{""x"":0.10000000149011612,""y"":6.496231555938721},{""x"":0.6000000238418579,""y"":6.42543363571167},{""x"":1.100000023841858,""y"":7.040063858032227},{""x"":1.600000023841858,""y"":6.1115403175354},{""x"":2.0999999046325684,""y"":6.680728435516357},{""x"":2.5999999046325684,""y"":6.406774520874023},{""x"":3.0999999046325684,""y"":6.611269474029541},{""x"":3.5999999046325684,""y"":5.889094352722168},{""x"":4.099999904632568,""y"":6.75344705581665},{""x"":4.599999904632568,""y"":6.361435890197754},{""x"":5.099999904632568,""y"":4.1666975021362305},{""x"":5.599999904632568,""y"":1.172118902206421},{""x"":6.099999904632568,""y"":0.801048994064331},{""x"":6.599999904632568,""y"":0.4640021026134491},{""x"":7.099999904632568,""y"":0.0010357667924836278}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[1.4734381347446401, 1.1649805188074196, 4.82958608866421, 0.09500545496710007],""points"":[{""x"":0.10000000149011612,""y"":1.5279096364974976},{""x"":0.6000000238418579,""y"":1.3559974431991577},{""x"":1.100000023841858,""y"":1.5246378183364868},{""x"":1.600000023841858,""y"":1.5567657947540283},{""x"":2.0999999046325684,""y"":1.4114240407943726},{""x"":2.5999999046325684,""y"":1.4045010805130005},{""x"":3.0999999046325684,""y"":1.4769829511642456},{""x"":3.5999999046325684,""y"":1.4875500202178955},{""x"":4.099999904632568,""y"":1.2991987466812134},{""x"":4.599999904632568,""y"":0.922961413860321},{""x"":5.099999904632568,""y"":0.6520044803619385},{""x"":5.599999904632568,""y"":0.15350978076457977},{""x"":6.099999904632568,""y"":0.1078903079032898},{""x"":6.599999904632568,""y"":0.17276449501514435},{""x"":7.099999904632568,""y"":0.14066608250141144}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCosta Rica,MKSTKEEIQTIKTLLKDSRTAKYHKRLQIVL,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCCc3ccccc3,1480018,36.3309440612793,995084218,4041 SOUTHWESTERN BLVD,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,6,6,2BPW,6,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.4833641843311227, -1.8945978742090062, 4.671127708092568, 0.24159861311815153],""points"":[{""x"":0.10000000149011612,""y"":0.0969524160027504},{""x"":0.6000000238418579,""y"":0.028483040630817413},{""x"":1.100000023841858,""y"":0.22087176144123077},{""x"":1.600000023841858,""y"":0.0068915546871721745},{""x"":2.0999999046325684,""y"":0.4305879771709442},{""x"":2.5999999046325684,""y"":0.44774115085601807},{""x"":3.0999999046325684,""y"":0.45346319675445557},{""x"":3.5999999046325684,""y"":0.2370593100786209},{""x"":4.099999904632568,""y"":0.4657953977584839},{""x"":4.599999904632568,""y"":1.155200719833374},{""x"":5.099999904632568,""y"":2.2294070720672607},{""x"":5.599999904632568,""y"":2.4311530590057373},{""x"":6.099999904632568,""y"":2.33846116065979},{""x"":6.599999904632568,""y"":2.608201026916504},{""x"":7.099999904632568,""y"":2.8136143684387207}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.224573521642033, 1.4454033924198528, 5.6014197746076535, 0.2823216054197577],""points"":[{""x"":0.10000000149011612,""y"":4.95027494430542},{""x"":0.6000000238418579,""y"":5.1754679679870605},{""x"":1.100000023841858,""y"":5.276752948760986},{""x"":1.600000023841858,""y"":5.589294910430908},{""x"":2.0999999046325684,""y"":5.616994857788086},{""x"":2.5999999046325684,""y"":5.120813846588135},{""x"":3.0999999046325684,""y"":5.340766906738281},{""x"":3.5999999046325684,""y"":4.876471042633057},{""x"":4.099999904632568,""y"":4.94999361038208},{""x"":4.599999904632568,""y"":5.162564754486084},{""x"":5.099999904632568,""y"":4.399557590484619},{""x"":5.599999904632568,""y"":2.7977969646453857},{""x"":6.099999904632568,""y"":1.0229872465133667},{""x"":6.599999904632568,""y"":0.48275601863861084},{""x"":7.099999904632568,""y"":0.10408931970596313}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCuba,MHAILRYFIRRLFYHIFYKIYSLISKKHQSLPSDVRQF,COc1ccc2c(c1)c(CC(=O)N3CCCC3C(=O)Oc4ccc(C)cc4OC)c(C)n2C(=O)c5ccc(Cl)cc5,1480019,36.33115768432617,995081928,1227 US HIGHWAY 11,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,7,7,1QBS,7,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.320838679713925, -1.2421619987316728, 4.831325425225256, 0.3236011098403072],""points"":[{""x"":0.10000000149011612,""y"":0.3727470338344574},{""x"":0.6000000238418579,""y"":0.12365014106035233},{""x"":1.100000023841858,""y"":0.48422467708587646},{""x"":1.600000023841858,""y"":0.2264465093612671},{""x"":2.0999999046325684,""y"":0.16821794211864471},{""x"":2.5999999046325684,""y"":0.3879014551639557},{""x"":3.0999999046325684,""y"":0.5470244884490967},{""x"":3.5999999046325684,""y"":0.3419053554534912},{""x"":4.099999904632568,""y"":0.7655120491981506},{""x"":4.599999904632568,""y"":1.2346516847610474},{""x"":5.099999904632568,""y"":2.453336715698242},{""x"":5.599999904632568,""y"":2.9565491676330566},{""x"":6.099999904632568,""y"":3.335299491882324},{""x"":6.599999904632568,""y"":3.240290880203247},{""x"":7.099999904632568,""y"":3.1107218265533447}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.6401853521511094, 1.26211588875013, 5.399028074402744, 0.5089580830068091],""points"":[{""x"":0.10000000149011612,""y"":3.8585598468780518},{""x"":0.6000000238418579,""y"":3.6077206134796143},{""x"":1.100000023841858,""y"":3.855252265930176},{""x"":1.600000023841858,""y"":3.619039297103882},{""x"":2.0999999046325684,""y"":3.839388370513916},{""x"":2.5999999046325684,""y"":3.335283041000366},{""x"":3.0999999046325684,""y"":3.571141481399536},{""x"":3.5999999046325684,""y"":3.4155046939849854},{""x"":4.099999904632568,""y"":3.7316646575927734},{""x"":4.599999904632568,""y"":3.0680155754089355},{""x"":5.099999904632568,""y"":2.891066551208496},{""x"":5.599999904632568,""y"":1.6022753715515137},{""x"":6.099999904632568,""y"":0.7652576565742493},{""x"":6.599999904632568,""y"":0.6875326037406921},{""x"":7.099999904632568,""y"":0.5828871726989746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nItaly,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO[N+](=O)[O-],1480020,36.33115768432617,99502,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,8,8,1ZP8,8,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.293592105923809, 1.3781586549141835, 5.1025898038676605, 0.03493851245291291],""points"":[{""x"":0.10000000149011612,""y"":2.1287283897399902},{""x"":0.6000000238418579,""y"":2.267972230911255},{""x"":1.100000023841858,""y"":2.398442506790161},{""x"":1.600000023841858,""y"":2.5130622386932373},{""x"":2.0999999046325684,""y"":2.3255116939544678},{""x"":2.5999999046325684,""y"":2.127340793609619},{""x"":3.0999999046325684,""y"":2.47259783744812},{""x"":3.5999999046325684,""y"":2.131181478500366},{""x"":4.099999904632568,""y"":2.090421438217163},{""x"":4.599999904632568,""y"":2.02299165725708},{""x"":5.099999904632568,""y"":1.1105059385299683},{""x"":5.599999904632568,""y"":0.4494485855102539},{""x"":6.099999904632568,""y"":0.1375635862350464},{""x"":6.599999904632568,""y"":0.036351121962070465},{""x"":7.099999904632568,""y"":0.1619771122932434}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.953125499439879, 1.2528620255306528, 5.187637440149802, 0.3110348753260886],""points"":[{""x"":0.10000000149011612,""y"":5.6585283279418945},{""x"":0.6000000238418579,""y"":5.911152362823486},{""x"":1.100000023841858,""y"":5.924920082092285},{""x"":1.600000023841858,""y"":5.8469438552856445},{""x"":2.0999999046325684,""y"":5.929472923278809},{""x"":2.5999999046325684,""y"":6.190037727355957},{""x"":3.0999999046325684,""y"":6.236179828643799},{""x"":3.5999999046325684,""y"":6.141019344329834},{""x"":4.099999904632568,""y"":5.295210838317871},{""x"":4.599999904632568,""y"":5.265801906585693},{""x"":5.099999904632568,""y"":3.3722851276397705},{""x"":5.599999904632568,""y"":1.8299226760864258},{""x"":6.099999904632568,""y"":0.32690900564193726},{""x"":6.599999904632568,""y"":0.6274543404579163},{""x"":7.099999904632568,""y"":0.8441857099533081}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nRwanda,MPNSEPASLLELFNSIATQGELVRSLKAGNASK,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO,1480021,36.33137130737305,995037247,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,9,9,2BDJ,9,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.8209972202654474, 1.3779216716448506, 5.299882228439686, 0.06040645519069608],""points"":[{""x"":0.10000000149011612,""y"":3.7821109294891357},{""x"":0.6000000238418579,""y"":3.542433023452759},{""x"":1.100000023841858,""y"":3.7008674144744873},{""x"":1.600000023841858,""y"":3.717301607131958},{""x"":2.0999999046325684,""y"":4.024452209472656},{""x"":2.5999999046325684,""y"":4.013899326324463},{""x"":3.0999999046325684,""y"":3.945094347000122},{""x"":3.5999999046325684,""y"":3.866621971130371},{""x"":4.099999904632568,""y"":3.7461626529693604},{""x"":4.599999904632568,""y"":3.3454740047454834},{""x"":5.099999904632568,""y"":2.61944317817688},{""x"":5.599999904632568,""y"":0.999405026435852},{""x"":6.099999904632568,""y"":0.46259793639183044},{""x"":6.599999904632568,""y"":0.054134611040353775},{""x"":7.099999904632568,""y"":0.05711187422275543}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.6318079657726035, 1.8495493770000595, 5.391793312471116, 0.17060707587348442],""points"":[{""x"":0.10000000149011612,""y"":5.458079814910889},{""x"":0.6000000238418579,""y"":5.554427146911621},{""x"":1.100000023841858,""y"":5.799983024597168},{""x"":1.600000023841858,""y"":5.364140033721924},{""x"":2.0999999046325684,""y"":5.864485740661621},{""x"":2.5999999046325684,""y"":5.4509806632995605},{""x"":3.0999999046325684,""y"":5.702574729919434},{""x"":3.5999999046325684,""y"":5.7314534187316895},{""x"":4.099999904632568,""y"":5.5123443603515625},{""x"":4.599999904632568,""y"":5.724395751953125},{""x"":5.099999904632568,""y"":4.354506969451904},{""x"":5.599999904632568,""y"":1.7307666540145874},{""x"":6.099999904632568,""y"":0.6305936574935913},{""x"":6.599999904632568,""y"":0.035183437168598175},{""x"":7.099999904632568,""y"":0.7575169205665588}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nSwitzerland,IRVVGRYLIEVWKAAGMDMDKVLFLWSSDEI,CN1CCC(CC1)Oc2ccc(cc2)C(F)(F)F,1480028,36.33137130737305,99504,92-11 179TH PLACE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,9,10,1IAN,10,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[1.1190255865097471, 2.3163895161544437, 5.4968866182279195, 0.2035204047289052],""points"":[{""x"":0.10000000149011612,""y"":1.1057683229446411},{""x"":0.6000000238418579,""y"":1.1019697189331055},{""x"":1.100000023841858,""y"":1.0818607807159424},{""x"":1.600000023841858,""y"":1.062997817993164},{""x"":2.0999999046325684,""y"":1.046447515487671},{""x"":2.5999999046325684,""y"":1.1217249631881714},{""x"":3.0999999046325684,""y"":1.2166996002197266},{""x"":3.5999999046325684,""y"":1.215477705001831},{""x"":4.099999904632568,""y"":1.0581893920898438},{""x"":4.599999904632568,""y"":1.1747995615005493},{""x"":5.099999904632568,""y"":1.0181127786636353},{""x"":5.599999904632568,""y"":0.5344523191452026},{""x"":6.099999904632568,""y"":0.2569526433944702},{""x"":6.599999904632568,""y"":0.1912207305431366},{""x"":7.099999904632568,""y"":0.15060538053512573}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.1038581025805785, 2.0032224204185245, 5.087602825989163, 0.13277988512492753],""points"":[{""x"":0.10000000149011612,""y"":3.0498509407043457},{""x"":0.6000000238418579,""y"":2.805217742919922},{""x"":1.100000023841858,""y"":3.3415253162384033},{""x"":1.600000023841858,""y"":3.0549843311309814},{""x"":2.0999999046325684,""y"":3.250074863433838},{""x"":2.5999999046325684,""y"":3.0432586669921875},{""x"":3.0999999046325684,""y"":3.265852451324463},{""x"":3.5999999046325684,""y"":2.9475724697113037},{""x"":4.099999904632568,""y"":3.1929898262023926},{""x"":4.599999904632568,""y"":2.7460060119628906},{""x"":5.099999904632568,""y"":1.6175861358642578},{""x"":5.599999904632568,""y"":0.3006608486175537},{""x"":6.099999904632568,""y"":0.3444803059101105},{""x"":6.599999904632568,""y"":0.015537971630692482},{""x"":7.099999904632568,""y"":0.5527358055114746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\n,,,,,,,,,,,,,,,,,,,,,').columns.add(i.Column.fromList(i.TYPE.BYTE_ARRAY,"BinaryImage",Array.from(new Uint8Array(11))));var o,r=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function s(e){try{l(i.next(e))}catch(e){r(e)}}function a(e){try{l(i.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((i=i.apply(e,t||[])).next())})};function s(e,t,n,i=0,o="timeout"){return r(this,void 0,void 0,function*(){return new Promise((r,s)=>{const a=e.subscribe(e=>{try{t(e),r("OK")}catch(e){s(e)}finally{a.unsubscribe(),clearTimeout(l)}}),l=setTimeout(()=>{a.unsubscribe(),s(o)},i);n()})})}function a(e){return r(this,void 0,void 0,function*(){yield new Promise(t=>setTimeout(t,e))})}console.log.bind(console),console.info.bind(console),console.warn.bind(console),console.error.bind(console),function(e){e.notNull=function(e,t){if(null==e)throw new Error(`${null==t?"Value":t} not defined`)}}(o||(o={})),i.DataFrame.fromColumns([i.Column.fromStrings("col",["val1","val2","val3"])])},8123:(e,t,n)=>{"use strict";n.d(t,{u:()=>i});const i={V2K_RGP_SHIFT:8,V2K_RGP_LINE:"M RGP",V2K_A_LINE:"A ",V3K_COUNTS_SHIFT:14,V3K_IDX_SHIFT:7,V3K_HEADER_FIRST_LINE:"\nDatagrok macromolecule handler\n\n",V3K_HEADER_SECOND_LINE:" 0 0 0 0 0 0 999 V3000\n",V3K_BEGIN_CTAB_BLOCK:"M V30 BEGIN CTAB\n",V3K_END_CTAB_BLOCK:"M V30 END CTAB\n",V3K_BEGIN_COUNTS_LINE:"M V30 COUNTS ",V3K_COUNTS_LINE_ENDING:" 0 0 0\n",V3K_BEGIN_ATOM_BLOCK:"M V30 BEGIN ATOM\n",V3K_END_ATOM_BLOCK:"M V30 END ATOM\n",V3K_BEGIN_BOND_BLOCK:"M V30 BEGIN BOND\n",V3K_END_BOND_BLOCK:"M V30 END BOND\n",V3K_BOND_CONFIG:" CFG=",V3K_BEGIN_DATA_LINE:"M V30 ",V3K_END:"M END",PRECISION_FACTOR:1e4,DEOXYRIBOSE:{polymerType:"RNA",symbol:"d"},RIBOSE:{polymerType:"RNA",symbol:"r"},PHOSPHATE:{polymerType:"RNA",symbol:"p"},OXYGEN:"O",HYDROGEN:"H"}},8152:(e,t,n)=>{"use strict";n.d(t,{GD:()=>d,ZY:()=>u});var i=n(4328),o=n(6082),r=n(2003),s=n(608),a=n(4139),l=n(2447);const c=new class{dcName="bio";async getDockerContainer(){return await i.dapi.docker.dockerContainers.filter(this.dcName).first()}},u=["mafft --auto","mafft","linsi","ginsi","einsi","fftns","fftnsi","nwns","nwnsi"],h=["AlignedSeq","AlignedSubpeptide","HELM","ID","PolymerID"];async function d(e,t,n,i="ginsi",l=1.53,u=0,d=null,m,f=!1){const g=await c.getDockerContainer(),y=t.length;d??=o.Column.int("Clusters",y).init(0),d.type!=o.COLUMN_TYPE.STRING&&(d=d.convertTo(o.TYPE.STRING));const b=d.categories,v=d.getRawData(),w=new Array(b.length),C=new Array(b.length);if(f){const n=e.selection;for(let e=-1;-1!==(e=n.findNext(e,!0));){const n=v[e];if(!b[n])continue;const i=n,o=t.get(e);o&&((w[i]??=[]).push({ID:e.toString(),HELM:o}),(C[n]??=[]).push(e))}}else for(let e=0;e<y;++e){const n=v[e];if(!b[n])continue;const i=n,o=t.get(e);o&&((w[i]??=[]).push({ID:e.toString(),HELM:o}),(C[n]??=[]).push(e))}(0,s.aZ)(C,b);const S=new Array(y).fill(null);for(const e of w){if(!e||0===e.length)continue;const t=(await p(g.id,e,i,l,u,m)).Alignment;for(const e of t)S[parseInt(e.ID)]=Object.entries(e).filter(e=>!h.includes(e[0])).map(e=>"-"!==e[1]?e[1]:"").join(a.J.SEPARATOR)}const A=o.Column.fromStrings(n,S);return A.meta.units=r.Hi.SEPARATOR,A.setTag(r.gp.separator,a.J.SEPARATOR),A.setTag(r.gp.aligned,"SEQ.MSA"),A.setTag(r.gp.alphabet,r.YI.UN),A.setTag(r.gp.alphabetIsMultichar,"true"),A.semType=o.SEMTYPE.MACROMOLECULE,A}async function p(e,t,n,o,r,s){const a={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(t)},c=`/align?method=${n}&gap_open=${o}&gap_extend=${r}`,u=window.performance.now(),h=await i.dapi.docker.dockerContainers.fetchProxy(e,c,a),d=window.performance.now();l._package.logger.debug(`Bio: requestAlignedObjects() dockerContainers.fetchProxy(), ET: ${d-u} ms`);const p="application/json"===h.headers.get("content-type");if(!h.ok&&p){const e=await h.json(),t=e["pepsea-error"];if(t)throw new Error(`PepSeA error: ${t}`);const n=e["datagrok-error"];if(n)throw new Error(`Datagrok error: ${n}`);throw new Error(h.statusText)}if(!h.ok&&!p){const e=await h.text();throw new Error(`Error: ${e}`)}if(!p){const e=await h.text();throw new Error(`Error: PepSeA expected JSON response, got '${e}'.`)}const m=await h.json();if("pepsea-stderr"in m){const e=m["pepsea-stderr"];s?.warning(e)}return m}},8153:(e,t)=>{function n(e){return"number"!=typeof e||isNaN(e)?1:e}t.Fd=function(e){return function(e,t){var n={},i=function(e){return void 0===e?t:e};"function"==typeof t&&(i=t);var o=function(t){return i(t[e])},r=function(){return i(void 0)};return"string"==typeof e?(n.fromAttributes=o,n.fromGraph=function(e,t){return o(e.getEdgeAttributes(t))},n.fromEntry=function(e,t){return o(t)},n.fromPartialEntry=n.fromEntry,n.fromMinimalEntry=n.fromEntry):"function"==typeof e?(n.fromAttributes=function(){throw new Error("graphology-utils/getters/createEdgeValueGetter: irrelevant usage.")},n.fromGraph=function(t,n){var o=t.extremities(n);return i(e(n,t.getEdgeAttributes(n),o[0],o[1],t.getNodeAttributes(o[0]),t.getNodeAttributes(o[1]),t.isUndirected(n)))},n.fromEntry=function(t,n,o,r,s,a,l){return i(e(t,n,o,r,s,a,l))},n.fromPartialEntry=function(t,n,o,r){return i(e(t,n,o,r))},n.fromMinimalEntry=function(t,n){return i(e(t,n))}):(n.fromAttributes=r,n.fromGraph=r,n.fromEntry=r,n.fromMinimalEntry=r),n}(e,n)}},8226:e=>{"use strict";e.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/meta/content","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/content":true},"$dynamicAnchor":"meta","title":"Content vocabulary meta-schema","type":["object","boolean"],"properties":{"contentEncoding":{"type":"string"},"contentMediaType":{"type":"string"},"contentSchema":{"$dynamicRef":"#meta"}}}')},8312:(e,t,n)=>{"use strict";n.d(t,{Q:()=>o});var i=n(6082);async function o(){const e=i.Func.find({package:"Bio",name:"getSeqHelper"});if(0===e.length)throw new Error("Package 'Bio' must be installed for SeqHelper.");return(await e[0].prepare().call()).getOutputParamValue()}},8343:(e,t,n)=>{"use strict";const{normalizeIPv6:i,normalizeIPv4:o,removeDotSegments:r,recomposeAuthority:s,normalizeComponentEncoding:a}=n(4834),l=n(343);function c(e,t,n,i){const o={};return i||(e=p(u(e,n),n),t=p(u(t,n),n)),!(n=n||{}).tolerant&&t.scheme?(o.scheme=t.scheme,o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=r(t.path||""),o.query=t.query):(void 0!==t.userinfo||void 0!==t.host||void 0!==t.port?(o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=r(t.path||""),o.query=t.query):(t.path?("/"===t.path.charAt(0)?o.path=r(t.path):(void 0===e.userinfo&&void 0===e.host&&void 0===e.port||e.path?e.path?o.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+t.path:o.path=t.path:o.path="/"+t.path,o.path=r(o.path)),o.query=t.query):(o.path=e.path,void 0!==t.query?o.query=t.query:o.query=e.query),o.userinfo=e.userinfo,o.host=e.host,o.port=e.port),o.scheme=e.scheme),o.fragment=t.fragment,o}function u(e,t){const n={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:""},i=Object.assign({},t),o=[],a=l[(i.scheme||n.scheme||"").toLowerCase()];a&&a.serialize&&a.serialize(n,i),void 0!==n.path&&(i.skipEscape?n.path=unescape(n.path):(n.path=escape(n.path),void 0!==n.scheme&&(n.path=n.path.split("%3A").join(":")))),"suffix"!==i.reference&&n.scheme&&o.push(n.scheme,":");const c=s(n);if(void 0!==c&&("suffix"!==i.reference&&o.push("//"),o.push(c),n.path&&"/"!==n.path.charAt(0)&&o.push("/")),void 0!==n.path){let e=n.path;i.absolutePath||a&&a.absolutePath||(e=r(e)),void 0===c&&(e=e.replace(/^\/\//u,"/%2F")),o.push(e)}return void 0!==n.query&&o.push("?",n.query),void 0!==n.fragment&&o.push("#",n.fragment),o.join("")}const h=Array.from({length:127},(e,t)=>/[^!"$&'()*+,\-.;=_`a-z{}~]/u.test(String.fromCharCode(t))),d=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function p(e,t){const n=Object.assign({},t),r={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},s=-1!==e.indexOf("%");let a=!1;"suffix"===n.reference&&(e=(n.scheme?n.scheme+":":"")+"//"+e);const c=e.match(d);if(c){if(r.scheme=c[1],r.userinfo=c[3],r.host=c[4],r.port=parseInt(c[5],10),r.path=c[6]||"",r.query=c[7],r.fragment=c[8],isNaN(r.port)&&(r.port=c[5]),r.host){const e=o(r.host);if(!1===e.isIPV4){const t=i(e.host);r.host=t.host.toLowerCase(),a=t.isIPV6}else r.host=e.host,a=!0}void 0!==r.scheme||void 0!==r.userinfo||void 0!==r.host||void 0!==r.port||void 0!==r.query||r.path?void 0===r.scheme?r.reference="relative":void 0===r.fragment?r.reference="absolute":r.reference="uri":r.reference="same-document",n.reference&&"suffix"!==n.reference&&n.reference!==r.reference&&(r.error=r.error||"URI is not a "+n.reference+" reference.");const e=l[(n.scheme||r.scheme||"").toLowerCase()];if(!(n.unicodeSupport||e&&e.unicodeSupport)&&r.host&&(n.domainHost||e&&e.domainHost)&&!1===a&&function(e){let t=0;for(let n=0,i=e.length;n<i;++n)if(t=e.charCodeAt(n),t>126||h[t])return!0;return!1}(r.host))try{r.host=URL.domainToASCII(r.host.toLowerCase())}catch(e){r.error=r.error||"Host's domain name can not be converted to ASCII: "+e}(!e||e&&!e.skipNormalize)&&(s&&void 0!==r.scheme&&(r.scheme=unescape(r.scheme)),s&&void 0!==r.host&&(r.host=unescape(r.host)),r.path&&(r.path=escape(unescape(r.path))),r.fragment&&(r.fragment=encodeURI(decodeURIComponent(r.fragment)))),e&&e.parse&&e.parse(r,n)}else r.error=r.error||"URI can not be parsed.";return r}const m={SCHEMES:l,normalize:function(e,t){return"string"==typeof e?e=u(p(e,t),t):"object"==typeof e&&(e=p(u(e,t),t)),e},resolve:function(e,t,n){const i=Object.assign({scheme:"null"},n);return u(c(p(e,i),p(t,i),i,!0),{...i,skipEscape:!0})},resolveComponents:c,equal:function(e,t,n){return"string"==typeof e?(e=unescape(e),e=u(a(p(e,n),!0),{...n,skipEscape:!0})):"object"==typeof e&&(e=u(a(e,!0),{...n,skipEscape:!0})),"string"==typeof t?(t=unescape(t),t=u(a(p(t,n),!0),{...n,skipEscape:!0})):"object"==typeof t&&(t=u(a(t,!0),{...n,skipEscape:!0})),e.toLowerCase()===t.toLowerCase()},serialize:u,parse:p};e.exports=m,e.exports.default=m,e.exports.fastUri=m},8438:(e,t,n)=>{"use strict";function i(e){return e.startsWith("[")&&e.endsWith("]")?e.slice(1,-1):e}n.d(t,{D:()=>i})},8498:(e,t,n)=>{"use strict";var i,o,r,s,a,l,c;n.d(t,{EG:()=>a,Pn:()=>o,RR:()=>l,Wn:()=>c,aT:()=>r,m6:()=>s,xL:()=>i}),function(e){e.Levenshtein="Levenshtein",e.JaroWinkler="Jaro-Winkler",e.Manhattan="Manhattan String",e.Onehot="One-Hot"}(i||(i={})),function(e){e.Euclidean="Euclidean",e.Manhattan="Manhattan",e.Cosine="Vector Cosine"}(o||(o={})),function(e){e.Tanimoto="Tanimoto",e.Dice="Dice",e.Asymmetric="Asymmetric",e.BraunBlanquet="Braun-Blanquet",e.Cosine="Cosine",e.Kulczynski="Kulczynski",e.McConnaughey="Mc-Connaughey",e.RogotGoldberg="Rogot-Goldberg",e.Russel="Russel",e.Sokal="Sokal",e.Hamming="Hamming",e.Euclidean="Euclidean BitArray"}(r||(r={})),function(e){e.TanimotoIntArray="TanimotoIntArray"}(s||(s={})),function(e){e.Vector="Vector",e.String="String",e.BitArray="BitArray",e.MacroMolecule="MacroMolecule",e.Number="Number",e.IntArray="IntArray",e.NumberArray="NumberArray"}(a||(a={})),function(e){e.Difference="Difference"}(l||(l={})),function(e){e.CommonItems="Common Items"}(c||(c={}))},8604:(e,t,n)=>{"use strict";n.d(t,{G:()=>i});const i={explicit:["HELMCoreLibrary.json","polytool-lib.json"],exclude:[],duplicateMonomerPreferences:{}}},8643:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9029),o=n(4227),r=n(6250),s={keyword:"enum",schemaType:"array",$data:!0,error:{message:"must be equal to one of the allowed values",params:({schemaCode:e})=>i._`{allowedValues: ${e}}`},code(e){const{gen:t,data:n,$data:s,schema:a,schemaCode:l,it:c}=e;if(!s&&0===a.length)throw new Error("enum must have non-empty array");const u=a.length>=c.opts.loopEnum;let h;const d=()=>null!=h?h:h=(0,o.useFunc)(t,r.default);let p;if(u||s)p=t.let("valid"),e.block$data(p,function(){t.assign(p,!1),t.forOf("v",l,e=>t.if(i._`${d()}(${n}, ${e})`,()=>t.assign(p,!0).break()))});else{if(!Array.isArray(a))throw new Error("ajv implementation error");const e=t.const("vSchema",l);p=(0,i.or)(...a.map((t,o)=>function(e,t){const o=a[t];return"object"==typeof o&&null!==o?i._`${d()}(${n}, ${e}[${t}])`:i._`${n} === ${o}`}(e,o)))}e.pass(p)}};t.default=s},8660:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(5765),o=n(9029),r=n(2023),s=n(4227),a={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:{message:"must NOT have additional properties",params:({params:e})=>o._`{additionalProperty: ${e.additionalProperty}}`},code(e){const{gen:t,schema:n,parentSchema:a,data:l,errsCount:c,it:u}=e;if(!c)throw new Error("ajv implementation error");const{allErrors:h,opts:d}=u;if(u.props=!0,"all"!==d.removeAdditional&&(0,s.alwaysValidSchema)(u,n))return;const p=(0,i.allSchemaProperties)(a.properties),m=(0,i.allSchemaProperties)(a.patternProperties);function f(e){t.code(o._`delete ${l}[${e}]`)}function g(i){if("all"===d.removeAdditional||d.removeAdditional&&!1===n)f(i);else{if(!1===n)return e.setParams({additionalProperty:i}),e.error(),void(h||t.break());if("object"==typeof n&&!(0,s.alwaysValidSchema)(u,n)){const n=t.name("valid");"failing"===d.removeAdditional?(y(i,n,!1),t.if((0,o.not)(n),()=>{e.reset(),f(i)})):(y(i,n),h||t.if((0,o.not)(n),()=>t.break()))}}}function y(t,n,i){const o={keyword:"additionalProperties",dataProp:t,dataPropType:s.Type.Str};!1===i&&Object.assign(o,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(o,n)}t.forIn("key",l,n=>{p.length||m.length?t.if(function(n){let r;if(p.length>8){const e=(0,s.schemaRefOrVal)(u,a.properties,"properties");r=(0,i.isOwnProperty)(t,e,n)}else r=p.length?(0,o.or)(...p.map(e=>o._`${n} === ${e}`)):o.nil;return m.length&&(r=(0,o.or)(r,...m.map(t=>o._`${(0,i.usePattern)(e,t)}.test(${n})`))),(0,o.not)(r)}(n),()=>g(n)):g(n)}),e.ok(o._`${c} === ${r.default.errors}`)}};t.default=a},8708:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extendErrors=t.resetErrorsCount=t.reportExtraError=t.reportError=t.keyword$DataError=t.keywordError=void 0;const i=n(9029),o=n(4227),r=n(2023);function s(e,t){const n=e.const("err",t);e.if(i._`${r.default.vErrors} === null`,()=>e.assign(r.default.vErrors,i._`[${n}]`),i._`${r.default.vErrors}.push(${n})`),e.code(i._`${r.default.errors}++`)}function a(e,t){const{gen:n,validateName:o,schemaEnv:r}=e;r.$async?n.throw(i._`new ${e.ValidationError}(${t})`):(n.assign(i._`${o}.errors`,t),n.return(!1))}t.keywordError={message:({keyword:e})=>i.str`must pass "${e}" keyword validation`},t.keyword$DataError={message:({keyword:e,schemaType:t})=>t?i.str`"${e}" keyword must be ${t} ($data)`:i.str`"${e}" keyword is invalid ($data)`},t.reportError=function(e,n=t.keywordError,o,r){const{it:l}=e,{gen:u,compositeRule:h,allErrors:d}=l,p=c(e,n,o);(null!=r?r:h||d)?s(u,p):a(l,i._`[${p}]`)},t.reportExtraError=function(e,n=t.keywordError,i){const{it:o}=e,{gen:l,compositeRule:u,allErrors:h}=o;s(l,c(e,n,i)),u||h||a(o,r.default.vErrors)},t.resetErrorsCount=function(e,t){e.assign(r.default.errors,t),e.if(i._`${r.default.vErrors} !== null`,()=>e.if(t,()=>e.assign(i._`${r.default.vErrors}.length`,t),()=>e.assign(r.default.vErrors,null)))},t.extendErrors=function({gen:e,keyword:t,schemaValue:n,data:o,errsCount:s,it:a}){if(void 0===s)throw new Error("ajv implementation error");const l=e.name("err");e.forRange("i",s,r.default.errors,s=>{e.const(l,i._`${r.default.vErrors}[${s}]`),e.if(i._`${l}.instancePath === undefined`,()=>e.assign(i._`${l}.instancePath`,(0,i.strConcat)(r.default.instancePath,a.errorPath))),e.assign(i._`${l}.schemaPath`,i.str`${a.errSchemaPath}/${t}`),a.opts.verbose&&(e.assign(i._`${l}.schema`,n),e.assign(i._`${l}.data`,o))})};const l={keyword:new i.Name("keyword"),schemaPath:new i.Name("schemaPath"),params:new i.Name("params"),propertyName:new i.Name("propertyName"),message:new i.Name("message"),schema:new i.Name("schema"),parentSchema:new i.Name("parentSchema")};function c(e,t,n){const{createErrors:o}=e.it;return!1===o?i._`{}`:function(e,t,n={}){const{gen:o,it:s}=e,a=[u(s,n),h(e,n)];return function(e,{params:t,message:n},o){const{keyword:s,data:a,schemaValue:c,it:u}=e,{opts:h,propertyName:d,topSchemaRef:p,schemaPath:m}=u;o.push([l.keyword,s],[l.params,"function"==typeof t?t(e):t||i._`{}`]),h.messages&&o.push([l.message,"function"==typeof n?n(e):n]),h.verbose&&o.push([l.schema,c],[l.parentSchema,i._`${p}${m}`],[r.default.data,a]),d&&o.push([l.propertyName,d])}(e,t,a),o.object(...a)}(e,t,n)}function u({errorPath:e},{instancePath:t}){const n=t?i.str`${e}${(0,o.getErrorPath)(t,o.Type.Str)}`:e;return[r.default.instancePath,(0,i.strConcat)(r.default.instancePath,n)]}function h({keyword:e,it:{errSchemaPath:t}},{schemaPath:n,parentSchema:r}){let s=r?t:i.str`${t}/${e}`;return n&&(s=i.str`${s}${(0,o.getErrorPath)(n,o.Type.Str)}`),[l.schemaPath,s]}},8727:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.boolOrEmptySchema=t.topBoolOrEmptySchema=void 0;const i=n(8708),o=n(9029),r=n(2023),s={message:"boolean schema is false"};function a(e,t){const{gen:n,data:o}=e,r={gen:n,keyword:"false schema",data:o,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,i.reportError)(r,s,void 0,t)}t.topBoolOrEmptySchema=function(e){const{gen:t,schema:n,validateName:i}=e;!1===n?a(e,!1):"object"==typeof n&&!0===n.$async?t.return(r.default.data):(t.assign(o._`${i}.errors`,null),t.return(!0))},t.boolOrEmptySchema=function(e,t){const{gen:n,schema:i}=e;!1===i?(n.var(t,!1),a(e)):n.var(t,!0)}},8754:(e,t,n)=>{"use strict";n.d(t,{V:()=>u});var i=n(4328),o=n(6077),r=n(2003),s=n(8312),a=n(5553),l=n(966),c=n(330);async function u(e,t,n,u,h,d,p){let m;if(n){const n=await(0,s.Q)(),i=n.getSeqHandler(t);let o,a;i.isHelm()?o=t:(a=t.name,t.name=`__${a}`,o=i.convert(r.Hi.HELM),o.name=a,e.columns.add(o,!1));try{m=await n.helmToAtomicLevel(o,!0,!0,h)}finally{o!==t&&(e.columns.remove(o.name),t.name=a)}}else{if(!(0,l.l)(t,"To Atomic Level",d)[0])return{molCol:null,warnings:["Column is not suitable"]};m=await(0,o.C4)(e,t,h,d,p)}if(m.molCol){const o=(0,c.qj)(e,t.name);m.molCol.name=o,e.columns.add(m.molCol,!0),await(0,a.Qc)(t,m.molCol,h,d,p,n),m.molCol.setTag(".sequence-src-highlight-monomers",String(u)),await i.data.detectSemanticTypes(e)}return m}},8774:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});class i{constructor(e,t=!1){if(this._length=0,this._version=0,this._updateLevel=0,this._selectedCount=0,this._selectedCountVersion=-1,this._selectedIndexesVersion=-1,this._versionedName="",this._versionedNameVersion=-1,this.SHRINK_THRESHOLD=256,"number"==typeof e){const n=e,o=i._createBuffer(n);if(t)for(let e=0;e<o.length;e++)o[e]=-1;this._data=o,this._length=n}else{if(!(e instanceof Uint32Array))throw new Error("Invalid constructor");this._data=e,this._length=t}}getRawData(){return this._data}assureGoez(e,t){if(e<0)throw new Error(`${t} should be greater than zero`)}assureInRange(e,t,n,i){if(e<t||e>n)throw new Error(`Argument ${i} (${e}) out of range (${t}, ${n})`)}copy(e,t,n){for(let i=0;i<n;i++)t[i]=e[i]}copyFrom(e){if(this._length!=e._length)throw new Error(`Lengths differ (${this._length} != ${e._length})`);this.copy(e._data,this._data,this.lengthInInts),this._version++}get length(){return this._length}get buffer(){return this._data}set buffer(e){this._data=e,this._version++}get version(){return this._version}set version(e){this._version=e}incrementVersion(e=!0){this._version++}get lengthInInts(){return Math.floor((this._length+31)/32)}get versionedName(){return this._version==this._versionedNameVersion?this._versionedName:""}set versionedName(e){this._versionedName=e,this._versionedNameVersion=this._version}get self(){return this}setLength(e){if(e<0)throw new Error("should be >= 0");if(e==this._length)return;const t=Math.floor((e+31)/32);if(t>this._data.length||t+this.SHRINK_THRESHOLD<this._data.length){const e=new Uint32Array(t);this.copy(this._data,e,t>this._data.length?this._data.length:t),this._data=e}e>this._length&&(this._length%32>0&&(this._data[this.lengthInInts-1]&=(1<<(this._length%32&31))-1),this._data.fill(0,this.lengthInInts,t)),this._length=e,this._version++}static fromAnd(e,t){if(e._length!=t._length)throw new Error(`Lengths differ (${e._length} != ${t._length})`);const n=new i(e._length);n._length=e._length,n._data=i._createBuffer(n._length),n._version=0;const o=e.lengthInInts;for(let i=0;i<o;i++)n._data[i]=e._data[i]&t._data[i];return n}static _createBuffer(e){return new Uint32Array(Math.floor((e+31)/32))}static fromValues(e){const t=new i(e.length);t._version=0;for(let n=0;n<t._length;n++)e[n]&&(t._data[Math.floor(n/32)]|=1<<(n%32&31));return t}static fromSeq(e,t){const n=new i(e);for(let i=0;i<e;++i)n.setBit(i,t(i));return n._version=0,n}static fromString(e){return i.fromSeq(e.length,t=>"1"==e.charAt(t))}static fromUint32Array(e,t){const n=new i(e);return n._data=t,n}static fromBytes(e){const t=e.length,n=new i(8*t);n._data=new Uint32Array(Math.floor((t+3)/4)),n._length=8*t;let o=0,r=0;for(;t-r>=4;)n._data[o++]=255&e[r]|(255&e[r+1])<<8|(255&e[r+2])<<16|(255&e[r+3])<<24,r+=4;return t-r==3&&(n._data[o]=(255&e[r+2])<<16),t-r==2&&(n._data[o]|=(255&e[r+1])<<8),t-r==1&&(n._data[o]|=255&e[r]),n._version=0,n}toString(){return`${this._length} bits, ${this.countBits(!0)} set`}equals(e){if(this==e)return!0;if(null==e)return!1;if(this._length!=e._length)return!1;if(0==this._length)return!0;for(let t=0;t<this._data.length-1;t++)if(this._data[t]!=e._data[t])return!1;for(let t=8*(this._data.length-1);t<this._length;t++)if(this.getBit(t)!=e.getBit(t))return!1;return!0}clone(){const e=new i(0,!1);return e._data=Uint32Array.from(this._data),e._length=this._length,e._version=this._version,e}init(e,t){this.setAll(!1,!1);for(let t=0;t<this._length;t++)e(t)&&(this._data[Math.floor(t/32)]|=1<<(t%32&31));return this.incrementVersion(t),this}invert(e=!0){for(let e=0;e<this._data.length;e++)this._data[e]^=-1;this.incrementVersion(e)}setAll(e,t=!1){const n=e?-1:0,i=this.lengthInInts;for(let e=0;e<i;e++)this._data[e]=n;this.incrementVersion(t)}setIndexes(e,t=!0,n=!0,i=!0){n&&this.setAll(!t,!1);for(const n of e)this.setFast(n,t);this.incrementVersion(i)}everyIndex(e,t=!0){for(const n of e)if(this.getBit(n)!=t)return!1;return!0}anyIndex(e,t=!0){for(const n of e)if(this.getBit(n)==t)return!0;return!1}setWhere(e,t=!0,n=!0,i=!0,o=!0){if(n&&o&&this.setAll(!t,!1),o)for(let n=0;n<this._length;n++)e(n)&&this.setFast(n,t);else for(let n=0;n<this._length;n++)this.setFast(n,e(n)?t:!t);this.incrementVersion(i)}getRange(e,t){this.assureInRange(e,0,this._length-1,"from"),this.assureInRange(t,0,this._length,"to");const n=[];for(let i=e;i<t;++i)n.push(this.getBit(i));return i.fromValues(n)}getRangeAsList(e,t){this.assureInRange(e,0,this._length-1,"from"),this.assureInRange(t,0,this._length,"to");const n=[];for(let i=e;i<t;++i)n.push(this.getBit(i));return n}setRange(e,t,n,i=!0){this.assureInRange(e,0,this._length-1,"from"),this.assureInRange(t,0,this._length-1,"to");const o=Math.min(e,t),r=Math.max(e,t);if(n)for(let e=o;e<=r;e++)this.setTrue(e);else for(let e=o;e<=r;e++)this.setFalse(e);return this.incrementVersion(i),this}setRandom(e,t,n=!0){if(e<0||e>this._length)throw new Error("n must be >= 0 && <= Count");e>this._length/2&&this.setRandom(this._length-e,!t),this.setAll(!t);for(let n=0;n<e;){const e=Math.floor(Math.random()*this._length);this.getBit(e)!=t&&(this.setFast(e,t),n++)}this.incrementVersion(n)}and(e,t=!0){if(this._length!=e._length)throw new Error("Array lengths differ.");for(let t=0,n=this.lengthInInts;t<n;t++)this._data[t]&=e._data[t];return this.incrementVersion(t),this}andNot(e,t=!0){if(this._length!=e._length)throw new Error("Array lengths differ.");const n=this.lengthInInts;for(let t=0;t<n;t++)this._data[t]&=~e._data[t];return this.incrementVersion(t),this}notAnd(e,t=!0){if(this._length!=e._length)throw new Error("Array lengths differ.");for(let t=0,n=this.lengthInInts;t<n;t++)this._data[t]=~this._data[t]&e._data[t];return this.incrementVersion(t),this}not(e=!0){for(let e=0,t=this.lengthInInts;e<t;e++)this._data[e]=~this._data[e];return this.incrementVersion(e),this}or(e,t=!0){if(this._length!=e._length)throw new Error("Array lengths differ.");for(let t=0,n=this.lengthInInts;t<n;t++)this._data[t]|=e._data[t];return this.incrementVersion(t),this}xor(e,t=!0){if(this._length!=e._length)throw new Error("Array lengths differ.");for(let t=0,n=this.lengthInInts;t<n;t++)this._data[t]^=e._data[t];return this.incrementVersion(t),this}insertAt(e,t,n=!1){if(this.assureInRange(e,0,this._length,"pos"),0==t)return;const i=this._length;this.setLength(this._length+t);for(let n=i-1;n>=e;n--)this.setBit(n+t,this.getBit(n));for(let i=e;i<e+t;i++)this.setBit(i,n)}removeAt(e,t=1){if(t<0)throw new Error("n cannot be negative");if(this.assureInRange(e,0,this._length-t,"pos"),this.contains(!0))for(let n=e;n<this._length-t;n++)this.setBit(n,this.getBit(n+t));this.setLength(this._length-t)}removeByMask(e,t=!0){if(this._length!=e.length)throw new Error("length != mask.length");if(e==this)this.setLength(e.countBits(!t)),this.setAll(!t);else{let n=0;for(let i=-1;-1!=(i=e.findNext(i,!t));)this.setFast(n++,this.getBit(i));this._length=n,this._version++}return this}getBit(e){return!!(this._data[Math.floor(e/32)]&1<<(31&e))}setBit(e,t,n=!0){this.setFast(e,t),this._version++}setFast(e,t){t?this._data[Math.floor(e/32)]|=1<<(31&e):this._data[Math.floor(e/32)]&=~(1<<(31&e))}setTrue(e){this._data[Math.floor(e/32)]|=1<<(31&e)}setFalse(e){this._data[Math.floor(e/32)]&=~(1<<(31&e))}trueCount(){return this.countBits(!0)}falseCount(){return this.countBits(!1)}countBits(e){if(0==this._length)return 0;if(this._selectedCountVersion!=this._version){this._selectedCount=0;const e=this.lengthInInts;let t=0;for(;t<e-1;t++)for(let e=this._data[t];0!=e;e>>>=8)this._selectedCount+=i._onBitCount[255&e];let n=this._data[t];const o=31&this._length;for(0!=o&&(n&=~(4294967295<<o));0!=n;n>>>=8)this._selectedCount+=i._onBitCount[255&n];this._selectedCountVersion=this._version}return e?this._selectedCount:this._length-this._selectedCount}countWhere(e){let t=0;if(this.trueCount()==this._length)for(let n=0;n<this._length;n++)t+=e(n)?1:0;else for(let n=-1;-1!=(n=this.findNext(n,!0));)t+=e(n)?1:0;return t}andWithCountBits(e,t){if(0==this._length)return 0;let n=0;const o=this.lengthInInts;let r=0;for(;r<o-1;r++)for(let t=this._data[r]&e._data[r];0!=t;t>>>=8)n+=i._onBitCount[255&t];let s=this._data[r]&e._data[r];const a=31&this._length;for(0!=a&&(s&=~(4294967295<<a));0!=s;s>>>=8)n+=i._onBitCount[255&s];return t?n:this._length-n}clear(){this.setLength(0)}contains(e){return this.findNext(-1,e)>=0}get allTrue(){return this.countBits(!0)==this._length}get allFalse(){return this.countBits(!1)==this._length}get anyTrue(){return this.countBits(!0)>0}get anyFalse(){return this.countBits(!1)>0}findNext(e,t=!0){if(this.assureInRange(e,-1,this._length,"index"),e>=this._length-1)return-1;let n=31&(e=e<0?0:e+1);const o=this.lengthInInts;for(let r=Math.floor(e/32);r<o;r++){let o=t?this._data[r]:~this._data[r];if(0!=n)o&=4294967295<<n&4294967295,n=0;else if(!t&&-4294967296==o)continue;for(let t=0;0!=o;t+=8,o>>>=8){const n=i._firstOnBit[255&o];if(n>=0)return(e=n+32*r+t)>=this._length?-1:e}}return-1}findPrev(e,t=!0){if(0==e)return-1;this.assureInRange(e,-1,this._length,"index");let n=1+(e=e<0?this._length-1:e-1)&31;for(let o=Math.floor(e/32);o>=0;o--){let e=t?this._data[o]:~this._data[o];0!=n&&(e&=~(4294967295<<n),n=0);for(let t=24;0!=e;t-=8,e<<=8){const n=i._lastOnBit[e>>>24];if(n>=0)return n+32*o+t}}return-1}}i._onBitCount=Int8Array.from([0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8]),i._firstOnBit=Int8Array.from([-1,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,7,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0]),i._lastOnBit=Int8Array.from([-1,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7])},8903:(e,t,n)=>{var i=n(1736),o=n(8153).Fd,r=n(2561),s=n(1782),a=n(9937);function l(e,t,n){if(!i(t))throw new Error("graphology-layout-forceatlas2: the given graph is not a valid graphology instance.");"number"==typeof n&&(n={iterations:n});var l=n.iterations;if("number"!=typeof l)throw new Error("graphology-layout-forceatlas2: invalid number of iterations.");if(l<=0)throw new Error("graphology-layout-forceatlas2: you should provide a positive number of iterations.");var c=o("getEdgeWeight"in n?n.getEdgeWeight:"weight").fromEntry,u="function"==typeof n.outputReducer?n.outputReducer:null,h=s.assign({},a,n.settings),d=s.validateSettings(h);if(d)throw new Error("graphology-layout-forceatlas2: "+d.message);var p,m=s.graphToByteArrays(t,c);for(p=0;p<l;p++)r(h,m.nodes,m.edges);if(!e)return s.collectLayoutChanges(t,m.nodes);s.assignLayoutChanges(t,m.nodes,u)}var c=l.bind(null,!1);c.assign=l.bind(null,!0),c.inferSettings=function(e){var t="number"==typeof e?e:e.order;return{barnesHutOptimize:t>2e3,strongGravityMode:!0,gravity:.05,scalingRatio:10,slowDown:1+Math.log(t)}},e.exports=c},8924:(e,t,n)=>{"use strict";var i=n(7362);class o extends i.e{static get Lesk(){return void 0===this.lesk&&(this.lesk=this.makePalette([[["G","A","S","T"],"orange"],[["C","V","I","L","P","F","Y","M","W"],"all_green"],[["N","Q","H"],"magenta"],[["D","E"],"red"],[["K","R"],"all_blue"]],!1,o)),this.lesk}static get GrokGroups(){return void 0===this.grokGroups&&(this.grokGroups=this.makePalette([[["C","U"],"yellow"],[["G","P"],"red"],[["A","V","I","L","M","F","Y","W"],"all_green"],[["R","H","K"],"light_blue"],[["D","E"],"dark_blue"],[["S","T","N","Q"],"orange"]],!1,o)),this.grokGroups}static get RasMol(){return void 0===this.rasMol&&(this.rasMol=new o({D:"#E60A0A",E:"#E60A0A",C:"#E6E600",M:"#E6E600",K:"#145AFF",R:"#145AFF",S:"#FA9600",T:"#FA9600",F:"#3232AA",Y:"#3232AA",N:"#00DCDC",Q:"#00DCDC",G:"#EBEBEB",L:"#0F820F",V:"#0F820F",I:"#0F820F",A:"#C8C8C8",W:"#B45AB4",H:"#8282D2",P:"#DC9682",others:"#BEA06E"})),this.rasMol}get(e){const t=e in o.aaSynonyms?o.aaSynonyms[e]:e;return super.get(t)}}o.aaSynonyms={MeNle:"L",MeA:"A",MeG:"G",MeF:"F"};class r{static getPalette(e="grok"){switch(e){case"grok":return o.GrokGroups;case"lesk":return o.Lesk;default:throw new Error(`ChemPalette: scheme \`${e}\` does not exist`)}}static getInnerOuter(e){let t=0,n="",i="";for(const o of e)"("==o?t++:")"==o?t--:t?n+=o:i+=o;return isNaN(parseInt(n))?[i,n]:[i,""]}static getColorAAPivot(e="",t="grok"){const n=this.getPalette(t);let[i,o]=this.getInnerOuter(e);if(i=i.length>6?`${i.slice(0,3)}...`:i,o=o.length>6?`${o.slice(0,3)}...`:o,1==e.length||"("==e[1]){const t=e[0]?.toUpperCase();return t in n?[n.get(t),t,o,1]:[this.undefinedColor,i,o,1]}if("d"==e[0]&&e[1]in n&&(2==e.length||"("==e[2])){const t=e[1]?.toUpperCase();return t in n?[n.get(t),t,o,2]:[this.undefinedColor,i,o,2]}if(e.substring(0,3)in this.AAFullNames&&(3==e.length||"("==e[3])){const t=this.AAFullNames[e.substring(0,3)];return t in n?[n.get(t),t,o,3]:[this.undefinedColor,i,o,3]}if(e[0]?.toLowerCase()==e[0]&&e.substring(1,3)in this.AAFullNames&&(4==e.length||"("==e[4])){const t=this.AAFullNames[e.substring(1,3)];return t in n?[n.get(t),t,o,4]:[this.undefinedColor,i,o,4]}return[this.undefinedColor,i,o,0]}}r.SemType="Aminoacids",r.SemTypeMultipleAlignment="AminoacidsMultipleAlignment",r.undefinedColor="rgb(100,100,100)",r.Names={G:"Glycine",L:"Leucine",Y:"Tyrosine",S:"Serine",E:"Glutamic acid",Q:"Glutamine",D:"Aspartic acid",N:"Asparagine",F:"Phenylalanine",A:"Alanine",K:"Lysine",R:"Arginine",H:"Histidine",C:"Cysteine",V:"Valine",P:"Proline",W:"Tryptophan",I:"Isoleucine",M:"Methionine",T:"Threonine"},r.AASmiles={G:"NCC(=O)O",L:"N[C@H](CC(C)C)C(=O)O",Y:"NC(CC1=CC=C(O)C=C1)C(=O)O",S:"NC(CO)C(=O)O",E:"N[C@@H](CCC(O)=O)C(=O)O",Q:"N[C@@H](CCC(N)=O)C(=O)O",D:"N[C@@H](CC(O)=O)C(=O)O",N:"N[C@@H](CC(N)=O)C(=O)O",F:"NC(CC1=CC=CC=C1)C(=O)O",A:"N[C@H](C)C(=O)O",K:"NC(CCCCN)C(=O)O",R:"N[C@H](CCCNC(=N)C)C(=O)O",H:"NC(CC1=CN=C[N]1)C(=O)O",C:"N[C@@H](CS)C(=O)O",V:"NC(C(C)C)C(=O)O",P:"N(CCC1)C1C(=O)O",W:"N[C@@H](Cc1c2ccccc2n([H])c1)C(=O)O",I:"N[C@H]([C@H](C)CC)C(=O)O",M:"NC(CCSC)C(=O)O",T:"NC(C(O)C)C(=O)O"},r.AASmilesTruncated={G:"*C*",L:"CC(C)C[C@H](*)*",Y:"C1=CC(=CC=C1CC(*)*)O",S:"OCC(*)C*",E:"*[C@@H](CCC(O)=O)*",Q:"*N[C@@H](CCC(N)=O)*",D:"*[C@@H](CC(O)=O)*",N:"*[C@@H](CC(N)=O)*",F:"C1=CC=C(C=C1)CC(*)*",A:"C[C@H](*)*",K:"C(CCN)CC(*)*",R:"*[C@H](CCCNC(=N)C)*",H:"C1=C(NC=N1)CC(*)*",C:"C([C@@H](*)*)S",V:"CC(C)C(*)*",P:"C1CCN(*)C1*",W:"*[C@@H](Cc1c2ccccc2n([H])c1)*",I:"CC[C@H](C)[C@H](*)*",M:"CSCCC(*)*",T:"CC(O)C(*)*"},r.AAFullNames={Ala:"A",Arg:"R",Asn:"N",Asp:"D",Cys:"C",Gln:"Q",Glu:"E",Gly:"G",His:"H",Ile:"I",Leu:"L",Lys:"K",Met:"M",Phe:"F",Pro:"P",Ser:"S",Thr:"T",Trp:"W",Tyr:"Y",Val:"V"}},9029:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.or=t.and=t.not=t.CodeGen=t.operators=t.varKinds=t.ValueScopeName=t.ValueScope=t.Scope=t.Name=t.regexpCode=t.stringify=t.getProperty=t.nil=t.strConcat=t.str=t._=void 0;const i=n(1520),o=n(7845);var r=n(1520);Object.defineProperty(t,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(t,"strConcat",{enumerable:!0,get:function(){return r.strConcat}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(t,"getProperty",{enumerable:!0,get:function(){return r.getProperty}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(t,"regexpCode",{enumerable:!0,get:function(){return r.regexpCode}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return r.Name}});var s=n(7845);Object.defineProperty(t,"Scope",{enumerable:!0,get:function(){return s.Scope}}),Object.defineProperty(t,"ValueScope",{enumerable:!0,get:function(){return s.ValueScope}}),Object.defineProperty(t,"ValueScopeName",{enumerable:!0,get:function(){return s.ValueScopeName}}),Object.defineProperty(t,"varKinds",{enumerable:!0,get:function(){return s.varKinds}}),t.operators={GT:new i._Code(">"),GTE:new i._Code(">="),LT:new i._Code("<"),LTE:new i._Code("<="),EQ:new i._Code("==="),NEQ:new i._Code("!=="),NOT:new i._Code("!"),OR:new i._Code("||"),AND:new i._Code("&&"),ADD:new i._Code("+")};class a{optimizeNodes(){return this}optimizeNames(e,t){return this}}class l extends a{constructor(e,t,n){super(),this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){const n=e?o.varKinds.var:this.varKind,i=void 0===this.rhs?"":` = ${this.rhs}`;return`${n} ${this.name}${i};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&(this.rhs=N(this.rhs,e,t)),this}get names(){return this.rhs instanceof i._CodeOrName?this.rhs.names:{}}}class c extends a{constructor(e,t,n){super(),this.lhs=e,this.rhs=t,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,t){if(!(this.lhs instanceof i.Name)||e[this.lhs.str]||this.sideEffects)return this.rhs=N(this.rhs,e,t),this}get names(){return L(this.lhs instanceof i.Name?{}:{...this.lhs.names},this.rhs)}}class u extends c{constructor(e,t,n,i){super(e,n,i),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}}class h extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}}class d extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}}class p extends a{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}}class m extends a{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=N(this.code,e,t),this}get names(){return this.code instanceof i._CodeOrName?this.code.names:{}}}class f extends a{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,n)=>t+n.render(e),"")}optimizeNodes(){const{nodes:e}=this;let t=e.length;for(;t--;){const n=e[t].optimizeNodes();Array.isArray(n)?e.splice(t,1,...n):n?e[t]=n:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){const{nodes:n}=this;let i=n.length;for(;i--;){const o=n[i];o.optimizeNames(e,t)||(P(e,o.names),n.splice(i,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>I(e,t.names),{})}}class g extends f{render(e){return"{"+e._n+super.render(e)+"}"+e._n}}class y extends f{}class b extends g{}b.kind="else";class v extends g{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+="else "+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();const e=this.condition;if(!0===e)return this.nodes;let t=this.else;if(t){const e=t.optimizeNodes();t=this.else=Array.isArray(e)?new b(e):e}return t?!1===e?t instanceof v?t:t.nodes:this.nodes.length?this:new v(R(e),t instanceof v?[t]:t.nodes):!1!==e&&this.nodes.length?this:void 0}optimizeNames(e,t){var n;if(this.else=null===(n=this.else)||void 0===n?void 0:n.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=N(this.condition,e,t),this}get names(){const e=super.names;return L(e,this.condition),this.else&&I(e,this.else.names),e}}v.kind="if";class w extends g{}w.kind="for";class C extends w{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=N(this.iteration,e,t),this}get names(){return I(super.names,this.iteration.names)}}class S extends w{constructor(e,t,n,i){super(),this.varKind=e,this.name=t,this.from=n,this.to=i}render(e){const t=e.es5?o.varKinds.var:this.varKind,{name:n,from:i,to:r}=this;return`for(${t} ${n}=${i}; ${n}<${r}; ${n}++)`+super.render(e)}get names(){const e=L(super.names,this.from);return L(e,this.to)}}class A extends w{constructor(e,t,n,i){super(),this.loop=e,this.varKind=t,this.name=n,this.iterable=i}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=N(this.iterable,e,t),this}get names(){return I(super.names,this.iterable.names)}}class x extends g{constructor(e,t,n){super(),this.name=e,this.args=t,this.async=n}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}}x.kind="func";class M extends f{render(e){return"return "+super.render(e)}}M.kind="return";class T extends g{render(e){let t="try"+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),null===(e=this.catch)||void 0===e||e.optimizeNodes(),null===(t=this.finally)||void 0===t||t.optimizeNodes(),this}optimizeNames(e,t){var n,i;return super.optimizeNames(e,t),null===(n=this.catch)||void 0===n||n.optimizeNames(e,t),null===(i=this.finally)||void 0===i||i.optimizeNames(e,t),this}get names(){const e=super.names;return this.catch&&I(e,this.catch.names),this.finally&&I(e,this.finally.names),e}}class E extends g{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}}E.kind="catch";class _ extends g{render(e){return"finally"+super.render(e)}}function I(e,t){for(const n in t)e[n]=(e[n]||0)+(t[n]||0);return e}function L(e,t){return t instanceof i._CodeOrName?I(e,t.names):e}function N(e,t,n){return e instanceof i.Name?r(e):(o=e)instanceof i._Code&&o._items.some(e=>e instanceof i.Name&&1===t[e.str]&&void 0!==n[e.str])?new i._Code(e._items.reduce((e,t)=>(t instanceof i.Name&&(t=r(t)),t instanceof i._Code?e.push(...t._items):e.push(t),e),[])):e;var o;function r(e){const i=n[e.str];return void 0===i||1!==t[e.str]?e:(delete t[e.str],i)}}function P(e,t){for(const n in t)e[n]=(e[n]||0)-(t[n]||0)}function R(e){return"boolean"==typeof e||"number"==typeof e||null===e?!e:i._`!${H(e)}`}_.kind="finally",t.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?"\n":""},this._extScope=e,this._scope=new o.Scope({parent:e}),this._nodes=[new y]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){const n=this._extScope.value(e,t);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,n,i){const o=this._scope.toName(t);return void 0!==n&&i&&(this._constants[o.str]=n),this._leafNode(new l(e,o,n)),o}const(e,t,n){return this._def(o.varKinds.const,e,t,n)}let(e,t,n){return this._def(o.varKinds.let,e,t,n)}var(e,t,n){return this._def(o.varKinds.var,e,t,n)}assign(e,t,n){return this._leafNode(new c(e,t,n))}add(e,n){return this._leafNode(new u(e,t.operators.ADD,n))}code(e){return"function"==typeof e?e():e!==i.nil&&this._leafNode(new m(e)),this}object(...e){const t=["{"];for(const[n,o]of e)t.length>1&&t.push(","),t.push(n),(n!==o||this.opts.es5)&&(t.push(":"),(0,i.addCodeArg)(t,o));return t.push("}"),new i._Code(t)}if(e,t,n){if(this._blockNode(new v(e)),t&&n)this.code(t).else().code(n).endIf();else if(t)this.code(t).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new v(e))}else(){return this._elseNode(new b)}endIf(){return this._endBlockNode(v,b)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new C(e),t)}forRange(e,t,n,i,r=(this.opts.es5?o.varKinds.var:o.varKinds.let)){const s=this._scope.toName(e);return this._for(new S(r,s,t,n),()=>i(s))}forOf(e,t,n,r=o.varKinds.const){const s=this._scope.toName(e);if(this.opts.es5){const e=t instanceof i.Name?t:this.var("_arr",t);return this.forRange("_i",0,i._`${e}.length`,t=>{this.var(s,i._`${e}[${t}]`),n(s)})}return this._for(new A("of",r,s,t),()=>n(s))}forIn(e,t,n,r=(this.opts.es5?o.varKinds.var:o.varKinds.const)){if(this.opts.ownProperties)return this.forOf(e,i._`Object.keys(${t})`,n);const s=this._scope.toName(e);return this._for(new A("in",r,s,t),()=>n(s))}endFor(){return this._endBlockNode(w)}label(e){return this._leafNode(new h(e))}break(e){return this._leafNode(new d(e))}return(e){const t=new M;if(this._blockNode(t),this.code(e),1!==t.nodes.length)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(M)}try(e,t,n){if(!t&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');const i=new T;if(this._blockNode(i),this.code(e),t){const e=this.name("e");this._currNode=i.catch=new E(e),t(e)}return n&&(this._currNode=i.finally=new _,this.code(n)),this._endBlockNode(E,_)}throw(e){return this._leafNode(new p(e))}block(e,t){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(t),this}endBlock(e){const t=this._blockStarts.pop();if(void 0===t)throw new Error("CodeGen: not in self-balancing block");const n=this._nodes.length-t;if(n<0||void 0!==e&&n!==e)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=t,this}func(e,t=i.nil,n,o){return this._blockNode(new x(e,t,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(x)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,t){const n=this._currNode;if(n instanceof e||t&&n instanceof t)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){const t=this._currNode;if(!(t instanceof v))throw new Error('CodeGen: "else" without "if"');return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){const e=this._nodes;return e[e.length-1]}set _currNode(e){const t=this._nodes;t[t.length-1]=e}},t.not=R;const $=k(t.operators.AND);t.and=function(...e){return e.reduce($)};const O=k(t.operators.OR);function k(e){return(t,n)=>t===i.nil?n:n===i.nil?t:i._`${H(t)} ${e} ${H(n)}`}function H(e){return e instanceof i.Name?e:i._`(${e})`}t.or=function(...e){return e.reduce(O)}},9039:(e,t,n)=>{"use strict";var i;n.d(t,{c:()=>i}),function(e){e.UMAP="UMAP",e.T_SNE="t-SNE"}(i||(i={}))},9124:(e,t,n)=>{"use strict";n.d(t,{b2:()=>r,fA:()=>s});var i=n(7389),o=n(6082);async function r(){const e="Helm",t=o.Func.find({package:e,name:"getHelmHelper"});if(0===t.length)throw new Error(`Package '${e}' must be installed for HelmHelper.`);return(await t[0].prepare().call()).getOutputParamValue()}function s(e,t){if(!e)throw new Error("Argument 'a' of type Atom or HelmType is mandatory.");let n,i;const o=e;return"ATOM"===o.T?(n=o.biotype(),i=o.elem):(n=e,i=t),[n,i]}o.JsInputBase,Error,i.input.helmAsync=async function(e,t){return(await r()).createHelmInput(e,t)}},9192:(e,t,n)=>{"use strict";function i(e){return"string"==typeof e||e instanceof String?e:"StateError"===e.constructor.name?e.message:"StateError"===e.constructor.name&&"$thrownJsError"in e?i(e.$thrownJsError):e instanceof Error?e.message:e.toString()}function o(e){return e instanceof Error?e.stack:"StateError"===e.constructor.name&&"$thrownJsError"in e?o(e.$thrownJsError):void 0}function r(e){return[i(e),o(e)]}n.d(t,{AP:()=>r})},9235:(e,t,n)=>{"use strict";n.d(t,{H:()=>c,R:()=>l});var i=n(6082),o=n(1991),r=n.n(o),s=n(330),a=n(3599);async function l(e,t,o,l,c,u,h){const d=e.length,p=e.dataFrame,m=Math.max(navigator.hardwareConcurrency-2,1),f=new Array(m).fill(null).map(()=>new Worker(new URL(n.p+n.u(455),n.b))),g=d/m,y=new Array(m),b=u.getSeqHandler(e),v="RNA"==l?a.o.NUCLEOTIDE:a.o.AA,w=r().count(0).take(e.length).map(e=>{const t=b.getSplitted(e);return r().count(0).take(t.length).map(e=>({position:e,symbol:t.getCanonical(e),biotype:v})).toArray()}).toArray();for(let e=0;e<m;e++){const n=f[e],i=Math.floor(e*g),r=e===m-1?d:Math.floor((e+1)*g);y[e]=new Promise(e=>{n.onmessage=t=>{e(t.data)}}),n.postMessage({seqList:w,monomersDict:t,alphabet:o,polymerType:l,start:i,end:r})}const C=[],S=[];await Promise.all(y).then(e=>{for(const t of e)C.push(...t.molfiles),S.push(...t.warnings)}),setTimeout(()=>{f.forEach(e=>{e.terminate()})},0);const A=(0,s.qj)(p,e.name),x=i.Column.fromType(i.COLUMN_TYPE.STRING,A,e.length).init(e=>C[e]?.molfile);return x.semType=i.SEMTYPE.MOLECULE,x.meta.units=i.UNITS.Molecule.MOLBLOCK,x.setTag(".sequence-src-col",e.name),{molCol:x,warnings:S}}function c(e,t){const n={},o={};for(const r of e){const e=t.getWebEditorMonomer(r.biotype,r.symbol).backgroundcolor,a=(0,s.vG)(e??i.Color.toRgb(i.Color.mouseOverRows))??[1,0,0,.7];for(const e of r.atoms)n[e]=a;for(const e of r.bonds)o[e]=a}return{atoms:Object.keys(n).map(e=>parseInt(e)),bonds:Object.keys(o).map(e=>parseInt(e)),highlightAtomColors:n,highlightBondColors:o}}},9336:(e,t,n)=>{"use strict";var i=n(2787),o=n(944),r=n(6295),s=n(6863),a=n(8498);const l={[a.Pn.Euclidean]:r.jL,[a.Pn.Manhattan]:r.Hf,[a.Pn.Cosine]:r.w_},c={[a.xL.Levenshtein]:i.I,[a.xL.JaroWinkler]:o.Vb,[a.xL.Manhattan]:function(e,t){if(e.length!==t.length)return 1;{let n=0;for(let i=1;i<e.length;i++)n+=e[i]==t[i]?0:1;return n/e.length}},[a.xL.Onehot]:function(e,t){return e===t?0:1}},u={[a.aT.Tanimoto]:r.tO,[a.aT.Dice]:r.zn,[a.aT.Asymmetric]:r.gt,[a.aT.BraunBlanquet]:r.ij,[a.aT.Cosine]:r.lO,[a.aT.Kulczynski]:r.rR,[a.aT.McConnaughey]:r.lP,[a.aT.RogotGoldberg]:r.TK,[a.aT.Russel]:r.yK,[a.aT.Sokal]:r.Ii,[a.aT.Hamming]:r.be,[a.aT.Euclidean]:r.Qj},h={[a.m6.TanimotoIntArray]:r.v_},d={[a.RR.Difference]:r.T6},p={[a.Wn.CommonItems]:r.Hr},m={[a.EG.Vector]:{[a.Pn.Euclidean]:l[a.Pn.Euclidean],[a.Pn.Manhattan]:l[a.Pn.Manhattan],[a.Pn.Cosine]:l[a.Pn.Cosine]},[a.EG.String]:{[a.xL.Levenshtein]:c[a.xL.Levenshtein],[a.xL.JaroWinkler]:c[a.xL.JaroWinkler],[a.xL.Manhattan]:c[a.xL.Manhattan],[a.xL.Onehot]:c[a.xL.Onehot]},[a.EG.BitArray]:{[a.aT.Tanimoto]:u[a.aT.Tanimoto],[a.aT.Dice]:u[a.aT.Dice],[a.aT.Asymmetric]:u[a.aT.Asymmetric],[a.aT.BraunBlanquet]:u[a.aT.BraunBlanquet],[a.aT.Cosine]:u[a.aT.Cosine],[a.aT.Kulczynski]:u[a.aT.Kulczynski],[a.aT.McConnaughey]:u[a.aT.McConnaughey],[a.aT.RogotGoldberg]:u[a.aT.RogotGoldberg],[a.aT.Russel]:u[a.aT.Russel],[a.aT.Sokal]:u[a.aT.Sokal]},[a.EG.MacroMolecule]:{[s.Z.HAMMING]:s.V[s.Z.HAMMING],[s.Z.LEVENSHTEIN]:s.V[s.Z.LEVENSHTEIN],[s.Z.NEEDLEMANN_WUNSCH]:s.V[s.Z.NEEDLEMANN_WUNSCH],[s.Z.MONOMER_CHEMICAL_DISTANCE]:s.V[s.Z.MONOMER_CHEMICAL_DISTANCE]},[a.EG.Number]:{[a.RR.Difference]:d[a.RR.Difference]},[a.EG.IntArray]:{[a.m6.TanimotoIntArray]:h[a.m6.TanimotoIntArray]},[a.EG.NumberArray]:{[a.Wn.CommonItems]:p[a.Wn.CommonItems]}};Object.keys(m).reduce((e,t)=>{for(const n of Object.keys(m[t]))e[n]=t;return e},{})},9547:e=>{"use strict";e.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/meta/unevaluated","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/unevaluated":true},"$dynamicAnchor":"meta","title":"Unevaluated applicator vocabulary meta-schema","type":["object","boolean"],"properties":{"unevaluatedItems":{"$dynamicRef":"#meta"},"unevaluatedProperties":{"$dynamicRef":"#meta"}}}')},9572:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(1678),o=n(7216),r=n(9547),s=n(8226),a=n(518),l=n(4588),c=n(5707),u=n(7082),h=["/properties"];t.default=function(e){return[i,o,r,s,a,t(this,l),c,t(this,u)].forEach(e=>this.addMetaSchema(e,void 0,!1)),this;function t(t,n){return e?t.$dataMetaSchema(n,h):n}}},9713:e=>{"use strict";e.exports=rxjs.operators},9857:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.contentVocabulary=t.metadataVocabulary=void 0,t.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"],t.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]},9937:e=>{e.exports={linLogMode:!1,outboundAttractionDistribution:!1,adjustSizes:!1,edgeWeightInfluence:1,scalingRatio:1,strongGravityMode:!1,gravity:1,slowDown:1,barnesHutOptimize:!1,barnesHutTheta:.5}},9982:function(e,t,n){var i;!function(){var t={};!function(e){"use strict";e.__esModule=!0,e.digestLength=32,e.blockSize=64;var t=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function n(e,n,i,o,r){for(var s,a,l,c,u,h,d,p,m,f,g,y,b;r>=64;){for(s=n[0],a=n[1],l=n[2],c=n[3],u=n[4],h=n[5],d=n[6],p=n[7],f=0;f<16;f++)g=o+4*f,e[f]=(255&i[g])<<24|(255&i[g+1])<<16|(255&i[g+2])<<8|255&i[g+3];for(f=16;f<64;f++)y=((m=e[f-2])>>>17|m<<15)^(m>>>19|m<<13)^m>>>10,b=((m=e[f-15])>>>7|m<<25)^(m>>>18|m<<14)^m>>>3,e[f]=(y+e[f-7]|0)+(b+e[f-16]|0);for(f=0;f<64;f++)y=(((u>>>6|u<<26)^(u>>>11|u<<21)^(u>>>25|u<<7))+(u&h^~u&d)|0)+(p+(t[f]+e[f]|0)|0)|0,b=((s>>>2|s<<30)^(s>>>13|s<<19)^(s>>>22|s<<10))+(s&a^s&l^a&l)|0,p=d,d=h,h=u,u=c+y|0,c=l,l=a,a=s,s=y+b|0;n[0]+=s,n[1]+=a,n[2]+=l,n[3]+=c,n[4]+=u,n[5]+=h,n[6]+=d,n[7]+=p,o+=64,r-=64}return o}var i=function(){function t(){this.digestLength=e.digestLength,this.blockSize=e.blockSize,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this.reset()}return t.prototype.reset=function(){return this.state[0]=1779033703,this.state[1]=3144134277,this.state[2]=1013904242,this.state[3]=2773480762,this.state[4]=1359893119,this.state[5]=2600822924,this.state[6]=528734635,this.state[7]=1541459225,this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this},t.prototype.clean=function(){for(var e=0;e<this.buffer.length;e++)this.buffer[e]=0;for(e=0;e<this.temp.length;e++)this.temp[e]=0;this.reset()},t.prototype.update=function(e,t){if(void 0===t&&(t=e.length),this.finished)throw new Error("SHA256: can't update because hash was finished.");var i=0;if(this.bytesHashed+=t,this.bufferLength>0){for(;this.bufferLength<64&&t>0;)this.buffer[this.bufferLength++]=e[i++],t--;64===this.bufferLength&&(n(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(t>=64&&(i=n(this.temp,this.state,e,i,t),t%=64);t>0;)this.buffer[this.bufferLength++]=e[i++],t--;return this},t.prototype.finish=function(e){if(!this.finished){var t=this.bytesHashed,i=this.bufferLength,o=t/536870912|0,r=t<<3,s=t%64<56?64:128;this.buffer[i]=128;for(var a=i+1;a<s-8;a++)this.buffer[a]=0;this.buffer[s-8]=o>>>24&255,this.buffer[s-7]=o>>>16&255,this.buffer[s-6]=o>>>8&255,this.buffer[s-5]=o>>>0&255,this.buffer[s-4]=r>>>24&255,this.buffer[s-3]=r>>>16&255,this.buffer[s-2]=r>>>8&255,this.buffer[s-1]=r>>>0&255,n(this.temp,this.state,this.buffer,0,s),this.finished=!0}for(a=0;a<8;a++)e[4*a+0]=this.state[a]>>>24&255,e[4*a+1]=this.state[a]>>>16&255,e[4*a+2]=this.state[a]>>>8&255,e[4*a+3]=this.state[a]>>>0&255;return this},t.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},t.prototype._saveState=function(e){for(var t=0;t<this.state.length;t++)e[t]=this.state[t]},t.prototype._restoreState=function(e,t){for(var n=0;n<this.state.length;n++)this.state[n]=e[n];this.bytesHashed=t,this.finished=!1,this.bufferLength=0},t}();e.Hash=i;var o=function(){function e(e){this.inner=new i,this.outer=new i,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var t=new Uint8Array(this.blockSize);if(e.length>this.blockSize)(new i).update(e).finish(t).clean();else for(var n=0;n<e.length;n++)t[n]=e[n];for(n=0;n<t.length;n++)t[n]^=54;for(this.inner.update(t),n=0;n<t.length;n++)t[n]^=106;for(this.outer.update(t),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate),n=0;n<t.length;n++)t[n]=0}return e.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},e.prototype.clean=function(){for(var e=0;e<this.istate.length;e++)this.ostate[e]=this.istate[e]=0;this.inner.clean(),this.outer.clean()},e.prototype.update=function(e){return this.inner.update(e),this},e.prototype.finish=function(e){return this.outer.finished?this.outer.finish(e):(this.inner.finish(e),this.outer.update(e,this.digestLength).finish(e)),this},e.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},e}();function r(e){var t=(new i).update(e),n=t.digest();return t.clean(),n}function s(e,t){var n=new o(e).update(t),i=n.digest();return n.clean(),i}function a(e,t,n,i){var o=i[0];if(0===o)throw new Error("hkdf: cannot expand more");t.reset(),o>1&&t.update(e),n&&t.update(n),t.update(i),t.finish(e),i[0]++}e.HMAC=o,e.hash=r,e.default=r,e.hmac=s;var l=new Uint8Array(e.digestLength);e.hkdf=function(e,t,n,i){void 0===t&&(t=l),void 0===i&&(i=32);for(var r=new Uint8Array([1]),c=s(t,e),u=new o(c),h=new Uint8Array(u.digestLength),d=h.length,p=new Uint8Array(i),m=0;m<i;m++)d===h.length&&(a(h,u,n,r),d=0),p[m]=h[d++];return u.clean(),h.fill(0),r.fill(0),p},e.pbkdf2=function(e,t,n,i){for(var r=new o(e),s=r.digestLength,a=new Uint8Array(4),l=new Uint8Array(s),c=new Uint8Array(s),u=new Uint8Array(i),h=0;h*s<i;h++){var d=h+1;a[0]=d>>>24&255,a[1]=d>>>16&255,a[2]=d>>>8&255,a[3]=d>>>0&255,r.reset(),r.update(t),r.update(a),r.finish(c);for(var p=0;p<s;p++)l[p]=c[p];for(p=2;p<=n;p++){r.reset(),r.update(c).finish(c);for(var m=0;m<s;m++)l[m]^=c[m]}for(p=0;p<s&&h*s+p<i;p++)u[h*s+p]=l[p]}for(h=0;h<s;h++)l[h]=c[h]=0;for(h=0;h<4;h++)a[h]=0;return r.clean(),u}}(t);var o=t.default;for(var r in t)o[r]=t[r];"object"==typeof e.exports?e.exports=o:void 0===(i=function(){return o}.call(t,n,t,e))||(e.exports=i)}()}},t={};function n(i){var o=t[i];if(void 0!==o)return o.exports;var r=t[i]={id:i,loaded:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.loaded=!0,r.exports}n.m=e,n.amdO={},n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.u=e=>e+".js",n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.hmd=e=>((e=Object.create(e)).children||(e.children=[]),Object.defineProperty(e,"exports",{enumerable:!0,set:()=>{throw new Error("ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: "+e.id)}}),e),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;n.g.importScripts&&(e=n.g.location+"");var t=n.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var i=t.getElementsByTagName("script");if(i.length)for(var o=i.length-1;o>-1&&(!e||!/^http(s?):/.test(e));)e=i[o--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=e})(),n.b=document.baseURI||self.location.href,n.nc=void 0;var i=n(2447);bio=i})();
|
|
8
8
|
//# sourceMappingURL=package.js.map
|