@datagrok/bio 2.11.20 → 2.11.22

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/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "name": "Leonid Stolbov",
6
6
  "email": "lstolbov@datagrok.ai"
7
7
  },
8
- "version": "2.11.20",
8
+ "version": "2.11.22",
9
9
  "description": "Bioinformatics support (import/export of sequences, conversion, visualization, analysis). [See more](https://github.com/datagrok-ai/public/blob/master/packages/Bio/README.md) for details.",
10
10
  "repository": {
11
11
  "type": "git",
@@ -34,9 +34,9 @@
34
34
  ],
35
35
  "dependencies": {
36
36
  "@biowasm/aioli": "^3.1.0",
37
- "@datagrok-libraries/bio": "^5.39.14",
37
+ "@datagrok-libraries/bio": "^5.39.16",
38
38
  "@datagrok-libraries/chem-meta": "^1.2.1",
39
- "@datagrok-libraries/ml": "^6.3.67",
39
+ "@datagrok-libraries/ml": "^6.3.68",
40
40
  "@datagrok-libraries/tutorials": "^1.3.11",
41
41
  "@datagrok-libraries/utils": "^4.1.36",
42
42
  "cash-dom": "^8.0.0",
@@ -7,8 +7,10 @@ import {SequenceSearchBaseViewer} from './sequence-search-base-viewer';
7
7
  import {getMonomericMols} from '../calculations/monomerLevelMols';
8
8
  import {updateDivInnerHTML} from '../utils/ui-utils';
9
9
  import {Subject} from 'rxjs';
10
- import {calcMmDistanceMatrix, dmLinearIndex} from './workers/mm-distance-worker-creator';
11
10
  import {UnitsHandler} from '@datagrok-libraries/bio/src/utils/units-handler';
11
+ import {getEncodedSeqSpaceCol} from './sequence-space';
12
+ import {MmDistanceFunctionsNames} from '@datagrok-libraries/ml/src/macromolecule-distance-functions';
13
+ import {DistanceMatrixService, dmLinearIndex} from '@datagrok-libraries/ml/src/distance-matrix';
12
14
 
13
15
  export class SequenceDiversityViewer extends SequenceSearchBaseViewer {
14
16
  diverseColumnLabel: string | null; // Use postfix Label to prevent activating table column selection editor
@@ -58,7 +60,11 @@ export class SequenceDiversityViewer extends SequenceSearchBaseViewer {
58
60
  }
59
61
 
60
62
  private async computeByMM() {
61
- const distanceMatrixData = await calcMmDistanceMatrix(this.moleculeColumn!);
63
+ const encodedSequences =
64
+ (await getEncodedSeqSpaceCol(this.moleculeColumn!, MmDistanceFunctionsNames.LEVENSHTEIN)).seqList;
65
+ const distanceMatrixService = new DistanceMatrixService(true, false);
66
+ const distanceMatrixData = await distanceMatrixService.calc(encodedSequences, MmDistanceFunctionsNames.LEVENSHTEIN);
67
+ distanceMatrixService.terminate();
62
68
  const len = this.moleculeColumn!.length;
63
69
  const linearizeFunc = dmLinearIndex(len);
64
70
  this.renderMolIds = getDiverseSubset(len, Math.min(len, this.limit),
@@ -8,8 +8,10 @@ import {createDifferenceCanvas, createDifferencesWithPositions} from './sequence
8
8
  import {updateDivInnerHTML} from '../utils/ui-utils';
9
9
  import {Subject} from 'rxjs';
10
10
  import {UnitsHandler} from '@datagrok-libraries/bio/src/utils/units-handler';
11
- import {calcMmDistanceMatrix, dmLinearIndex} from './workers/mm-distance-worker-creator';
12
- import {calculateMMDistancesArray} from './workers/mm-distance-array-service';
11
+ import {alignSequencePair} from '@datagrok-libraries/bio/src/utils/macromolecule/alignment';
12
+ import {KnnResult, SparseMatrixService} from '@datagrok-libraries/ml/src/distance-matrix/sparse-matrix-service';
13
+ import {getEncodedSeqSpaceCol} from './sequence-space';
14
+ import {MmDistanceFunctionsNames} from '@datagrok-libraries/ml/src/macromolecule-distance-functions';
13
15
 
14
16
  export class SequenceSimilarityViewer extends SequenceSearchBaseViewer {
15
17
  cutoff: number;
@@ -26,6 +28,8 @@ export class SequenceSimilarityViewer extends SequenceSearchBaseViewer {
26
28
  computeCompleted = new Subject<boolean>();
27
29
  distanceMatrixComputed: boolean = false;
28
30
  mmDistanceMatrix: Float32Array;
31
+ knn?: KnnResult;
32
+ kPrevNeighbors: number = 0;
29
33
 
30
34
  constructor() {
31
35
  super('similarity');
@@ -48,7 +52,7 @@ export class SequenceSimilarityViewer extends SequenceSearchBaseViewer {
48
52
  this.targetMoleculeIdx = this.dataFrame!.currentRowIdx == -1 ? 0 : this.dataFrame!.currentRowIdx;
49
53
  const uh = UnitsHandler.getOrCreate(this.moleculeColumn!);
50
54
 
51
- await (uh.isFasta() ? this.computeByMM() : this.computeByChem());
55
+ await (!uh.isHelm() ? this.computeByMM() : this.computeByChem());
52
56
  const similarColumnName: string = this.similarColumnLabel != null ? this.similarColumnLabel :
53
57
  `similar (${this.moleculeColumnName})`;
54
58
  this.molCol = DG.Column.string(similarColumnName,
@@ -93,29 +97,24 @@ export class SequenceSimilarityViewer extends SequenceSearchBaseViewer {
93
97
  }
94
98
 
95
99
  private async computeByMM() {
96
- let distanceArray = new Float32Array();
97
- if (!this.distanceMatrixComputed && this.preComputeDistanceMatrix) {
98
- this.mmDistanceMatrix = await calcMmDistanceMatrix(this.moleculeColumn!);
99
- this.distanceMatrixComputed = true;
100
- } else if (!this.preComputeDistanceMatrix) {
101
- // use fast distance array calculation if matrix will take too much space
102
- distanceArray = await calculateMMDistancesArray(this.moleculeColumn!, this.targetMoleculeIdx);
103
- }
104
100
  const len = this.moleculeColumn!.length;
105
- const linearizeFunc = dmLinearIndex(len);
106
- // array that keeps track of the indexes and scores together
107
- const indexWScore = Array(len).fill(0)
108
- .map((_, i) => ({
109
- idx: i, score: i === this.targetMoleculeIdx ? 1 :
110
- this.preComputeDistanceMatrix ? 1 - this.mmDistanceMatrix[linearizeFunc(this.targetMoleculeIdx, i)] :
111
- 1 - distanceArray[i]
112
- }));
101
+ const actualLimit = Math.min(this.limit, len - 1);
102
+ if (!this.knn || this.kPrevNeighbors !== actualLimit) {
103
+ const encodedSequences =
104
+ (await getEncodedSeqSpaceCol(this.moleculeColumn!, MmDistanceFunctionsNames.LEVENSHTEIN)).seqList;
105
+
106
+ this.kPrevNeighbors = actualLimit;
107
+ this.knn = await (new SparseMatrixService()
108
+ .getKNN(encodedSequences, MmDistanceFunctionsNames.LEVENSHTEIN, Math.min(this.limit, len - 1)));
109
+ }
110
+ const indexWScore = new Array(actualLimit).fill(0).map((_, i) => ({
111
+ idx: this.knn!.knnIndexes[this.targetMoleculeIdx][i],
112
+ score: 1 - this.knn!.knnDistances[this.targetMoleculeIdx][i],
113
+ }));
113
114
  indexWScore.sort((a, b) => b.score - a.score);
114
- // get the most similar molecules
115
- const actualLimit = Math.min(this.limit, len);
116
- const mostSimilar = indexWScore.slice(0, actualLimit);
117
- this.idxs = DG.Column.int('indexes', actualLimit).init((i) => mostSimilar[i].idx);
118
- this.scores = DG.Column.float('score', actualLimit).init((i) => mostSimilar[i].score);
115
+ indexWScore.unshift({idx: this.targetMoleculeIdx, score: DG.FLOAT_NULL});
116
+ this.idxs = DG.Column.int('indexes', actualLimit + 1).init((i) => indexWScore[i].idx);
117
+ this.scores = DG.Column.float('score', actualLimit + 1).init((i) => indexWScore[i].score);
119
118
  }
120
119
 
121
120
  createPropertyPanel(resDf: DG.DataFrame) {
@@ -127,7 +126,8 @@ export class SequenceSimilarityViewer extends SequenceSearchBaseViewer {
127
126
  const splitter = uh.getSplitter();
128
127
  const subParts1 = splitter(this.moleculeColumn!.get(this.targetMoleculeIdx));
129
128
  const subParts2 = splitter(resDf.get(molColName, resDf.currentRowIdx));
130
- const canvas = createDifferenceCanvas(subParts1, subParts2, uh.units, molDifferences);
129
+ const alignment = alignSequencePair(Array.from(subParts1), Array.from(subParts2));
130
+ const canvas = createDifferenceCanvas(alignment.seq1Splitted, alignment.seq2Splitted, uh.units, molDifferences);
131
131
  propPanel.append(ui.div(canvas, {style: {width: '300px', overflow: 'scroll'}}));
132
132
  if (subParts1.length !== subParts2.length) {
133
133
  propPanel.append(ui.divV([
@@ -48,7 +48,7 @@ async function _testSimilaritySearchViewer() {
48
48
 
49
49
  /* eslint-disable max-len */
50
50
  const str0: string = 'D-Tyr_Et/Tyr_ab-dehydroMe/dV/E/N/D-Orn/D-aThr//Phe_4Me';
51
- const str1: string = 'meI/hHis//Aca/meM/Tyr_ab-dehydroMe/dV/E/N/D-Orn/D-aThr//Phe_4Me';
51
+ const str1: string = 'Thr_PO3H2/Aca/D-Tyr_Et/Tyr_ab-dehydroMe/dV/Chg/N/D-Orn/D-aThr//Phe_4Me';
52
52
  const simStr1: string = 'meI/hHis/Aca/Cys_SEt/T/dK/Thr_PO3H2/Aca/Tyr_PO3H2/D-Chg/dV/Phe_ab-dehydro/N/D-Orn/D-aThr//Phe_4Me';
53
53
  /* eslint-enable max-len */
54
54
 
@@ -57,8 +57,8 @@ async function _testSimilaritySearchViewer() {
57
57
  expect(similaritySearchViewer.scores!.get(0), DG.FLOAT_NULL);
58
58
  expect(similaritySearchViewer.idxs!.get(0), 0);
59
59
  expect(similaritySearchViewer.molCol!.get(0), str0);
60
- expect(similaritySearchViewer.scores!.get(1), 0.4722222089767456);
61
- expect(similaritySearchViewer.idxs!.get(1), 11);
60
+ expect((similaritySearchViewer.scores!.get(1) as number).toFixed(2), '0.73');
61
+ expect(similaritySearchViewer.idxs!.get(1), 4);
62
62
  expect(similaritySearchViewer.molCol!.get(1), str1);
63
63
  moleculesView.dataFrame.currentRowIdx = 1;
64
64
  await awaitCheck(() => similaritySearchViewer.targetMoleculeIdx === 1,
@@ -12,7 +12,7 @@ import {UnitsHandler} from '@datagrok-libraries/bio/src/utils/units-handler';
12
12
  export class MacromoleculeColumnWidget extends DG.Widget {
13
13
  private viewed: boolean = false;
14
14
 
15
- private seqCol: DG.Column<string>;
15
+ private readonly seqCol: DG.Column<string>;
16
16
 
17
17
  private wlViewer: WebLogoViewer;
18
18
 
@@ -44,4 +44,9 @@ export class MacromoleculeColumnWidget extends DG.Widget {
44
44
  this.root.style.width = '100%';
45
45
  }
46
46
  }
47
+
48
+ override detach() {
49
+ this.wlViewer.detach();
50
+ super.detach();
51
+ }
47
52
  }
@@ -2,6 +2,7 @@ import * as grok from 'datagrok-api/grok';
2
2
  import * as ui from 'datagrok-api/ui';
3
3
  import * as DG from 'datagrok-api/dg';
4
4
 
5
+ import $ from 'cash-dom';
5
6
  import wu from 'wu';
6
7
  import {fromEvent, Observable, Subject, Unsubscribable} from 'rxjs';
7
8
 
@@ -558,7 +559,7 @@ export class WebLogoViewer extends DG.JsViewer implements IWebLogoViewer {
558
559
  this.viewSubs.push(
559
560
  fromEvent<WheelEvent>(this.canvas, 'wheel').subscribe(this.canvasOnWheel.bind(this)));
560
561
 
561
- await this.render(WlRenderLevel.Freqs, 'buildView');
562
+ this.render(WlRenderLevel.Freqs, 'buildView');
562
563
  _package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.buildView() end`);
563
564
  }
564
565
 
@@ -589,7 +590,7 @@ export class WebLogoViewer extends DG.JsViewer implements IWebLogoViewer {
589
590
  this.unitsHandler = UnitsHandler.getOrCreate(this.seqCol);
590
591
 
591
592
  this.palette = pickUpPalette(this.seqCol);
592
- this.updatePositions();
593
+ this.render(WlRenderLevel.Freqs, 'updateSeqCol()');
593
594
  this.error = null;
594
595
  } catch (err: any) {
595
596
  this.seqCol = null;
@@ -608,36 +609,6 @@ export class WebLogoViewer extends DG.JsViewer implements IWebLogoViewer {
608
609
  }
609
610
  }
610
611
 
611
- /** Updates {@link positionNames} and calculates {@link startPosition} and {@link endPosition}.
612
- * Calls {@link render}() with {@link WlRenderLevel.Freqs}
613
- */
614
- private updatePositions(): void {
615
- if (!this.seqCol) return;
616
-
617
- const dfFilter = this.getFilter();
618
- const maxLength: number = dfFilter.trueCount === 0 ? this.unitsHandler!.maxLength :
619
- wu.enumerate(this.unitsHandler!.splitted).map(([mList, rowI]) => {
620
- return dfFilter.get(rowI) && !!mList ? mList.length : 0;
621
- }).reduce((max, l) => Math.max(max, l), 0);
622
-
623
- /** positionNames and positionLabel can be set up through the column's tags only */
624
- const positionNamesTxt = this.seqCol.getTag(bioTAGS.positionNames);
625
- const positionLabelsTxt = this.seqCol.getTag(bioTAGS.positionLabels);
626
- this.positionNames = !!positionNamesTxt ? positionNamesTxt.split(positionSeparator).map((v) => v.trim()) :
627
- [...Array(maxLength).keys()].map((jPos) => `${jPos + 1}`)/* fallback if tag is not provided */;
628
- this.positionLabels = !!positionLabelsTxt ? positionLabelsTxt.split(positionSeparator).map((v) => v.trim()) :
629
- undefined;
630
-
631
- this.startPosition = (this.startPositionName && this.positionNames &&
632
- this.positionNames.includes(this.startPositionName)) ?
633
- this.positionNames.indexOf(this.startPositionName) : 0;
634
- this.endPosition = (this.endPositionName && this.positionNames &&
635
- this.positionNames.includes(this.endPositionName)) ?
636
- this.positionNames.indexOf(this.endPositionName) : (maxLength - 1);
637
-
638
- this.render(WlRenderLevel.Freqs, 'updatePositions');
639
- }
640
-
641
612
  private getFilter(): DG.BitSet {
642
613
  let dfFilterRes: DG.BitSet;
643
614
  switch (this.filterSource) {
@@ -851,13 +822,13 @@ export class WebLogoViewer extends DG.JsViewer implements IWebLogoViewer {
851
822
  case PROPS.shrinkEmptyTail:
852
823
  case PROPS.skipEmptyPositions:
853
824
  case PROPS.positionHeight: {
854
- this.updatePositions();
825
+ this.render(WlRenderLevel.Freqs, `onPropertyChanged( ${property.name} )`);
855
826
  break;
856
827
  }
857
828
 
858
829
  case PROPS.valueColumnName:
859
830
  case PROPS.valueAggrType: {
860
- this.render(WlRenderLevel.Freqs, `onPropertyChanged(${property.name})`);
831
+ this.render(WlRenderLevel.Freqs, `onPropertyChanged( ${property.name} )`);
861
832
  break;
862
833
  }
863
834
  // this.positionWidth obtains a new value
@@ -892,7 +863,7 @@ export class WebLogoViewer extends DG.JsViewer implements IWebLogoViewer {
892
863
  }
893
864
 
894
865
  /** Remove all handlers when table is a detach */
895
- public override async detach() {
866
+ public override detach() {
896
867
  const logPrefix = `${this.viewerToLog()}.detach()`;
897
868
  _package.logger.debug(`${logPrefix}, in`);
898
869
 
@@ -984,6 +955,31 @@ export class WebLogoViewer extends DG.JsViewer implements IWebLogoViewer {
984
955
  _package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.render.calculateFreqsInt(), start `);
985
956
  if (!this.host || !this.seqCol || !this.dataFrame) return;
986
957
 
958
+ // region updatePositions
959
+
960
+ const dfFilter = this.getFilter();
961
+ const maxLength: number = dfFilter.trueCount === 0 ? this.unitsHandler!.maxLength :
962
+ wu.enumerate(this.unitsHandler!.splitted).map(([mList, rowI]) => {
963
+ return dfFilter.get(rowI) && !!mList ? mList.length : 0;
964
+ }).reduce((max, l) => Math.max(max, l), 0);
965
+
966
+ /** positionNames and positionLabel can be set up through the column's tags only */
967
+ const positionNamesTxt = this.seqCol.getTag(bioTAGS.positionNames);
968
+ const positionLabelsTxt = this.seqCol.getTag(bioTAGS.positionLabels);
969
+ this.positionNames = !!positionNamesTxt ? positionNamesTxt.split(positionSeparator).map((v) => v.trim()) :
970
+ [...Array(maxLength).keys()].map((jPos) => `${jPos + 1}`)/* fallback if tag is not provided */;
971
+ this.positionLabels = !!positionLabelsTxt ? positionLabelsTxt.split(positionSeparator).map((v) => v.trim()) :
972
+ undefined;
973
+
974
+ this.startPosition = (this.startPositionName && this.positionNames &&
975
+ this.positionNames.includes(this.startPositionName)) ?
976
+ this.positionNames.indexOf(this.startPositionName) : 0;
977
+ this.endPosition = (this.endPositionName && this.positionNames &&
978
+ this.positionNames.includes(this.endPositionName)) ?
979
+ this.positionNames.indexOf(this.endPositionName) : (maxLength - 1);
980
+
981
+ // endregion updatePositions
982
+
987
983
  const length: number = this.startPosition <= this.endPosition ? this.endPosition - this.startPosition + 1 : 0;
988
984
  this.unitsHandler = UnitsHandler.getOrCreate(this.seqCol);
989
985
  const posCount: number = this.startPosition <= this.endPosition ? this.endPosition - this.startPosition + 1 : 0;
@@ -996,7 +992,6 @@ export class WebLogoViewer extends DG.JsViewer implements IWebLogoViewer {
996
992
  }
997
993
 
998
994
  // 2022-05-05 askalkin instructed to show WebLogo based on filter (not selection)
999
- const dfFilter = this.getFilter();
1000
995
  const dfRowCount = this.dataFrame.rowCount;
1001
996
  const splitted = this.unitsHandler.splitted;
1002
997
 
@@ -1136,6 +1131,11 @@ export class WebLogoViewer extends DG.JsViewer implements IWebLogoViewer {
1136
1131
  }
1137
1132
 
1138
1133
  private renderRequestOnDebounce(renderLevel: WlRenderLevel): void {
1134
+ const logPrefix = `${this.viewerToLog()}.renderRequestOnDebounce()`;
1135
+ if ($(this.root).offsetParent().get()[0]?.tagName === 'HTML') {
1136
+ _package.logger.warning(`${logPrefix}, $(this.root).offsetParent() is the 'HTML' tag.`);
1137
+ return;
1138
+ }
1139
1139
  this.requestedRenderLevel = WlRenderLevel.None;
1140
1140
  this.renderInt(renderLevel)
1141
1141
  .catch((err: any) => {
@@ -1176,7 +1176,6 @@ export class WebLogoViewer extends DG.JsViewer implements IWebLogoViewer {
1176
1176
  private dataFrameFilterOnChanged(_value: any): void {
1177
1177
  _package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.dataFrameFilterChanged()`);
1178
1178
  try {
1179
- this.updatePositions();
1180
1179
  if (this.filterSource === FilterSources.Filtered)
1181
1180
  this.render(WlRenderLevel.Freqs, 'dataFrameFilterOnChanged');
1182
1181
  } catch (err: any) {
package/dist/44.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";(self.webpackChunkbio=self.webpackChunkbio||[]).push([[44],{489:(t,e,n)=>{n.d(e,{U:()=>s.U,o:()=>s.o});var s=n(5540)},5540:(t,e,n)=>{n.d(e,{U:()=>s,o:()=>o});var s,r=n(779),i=n(458),h=n(6683);!function(t){t.HAMMING="Hamming",t.LEVENSHTEIN="Levenshtein",t.NEEDLEMANN_WUNSCH="Needlemann-Wunsch",t.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance"}(s||(s={}));const o={[s.HAMMING]:r.j,[s.LEVENSHTEIN]:i.r,[s.NEEDLEMANN_WUNSCH]:h.n,[s.MONOMER_CHEMICAL_DISTANCE]:r.j}},9657:(t,e,n)=>{n.d(e,{Z:()=>s});class s{constructor(t,e=!1){if(this._length=0,this._version=0,this._updateLevel=0,this._selectedCount=0,this._selectedCountVersion=-1,this._selectedIndexesVersion=-1,this._versionedName="",this._versionedNameVersion=-1,this.SHRINK_THRESHOLD=256,"number"==typeof t){const n=t,r=s._createBuffer(n);if(e)for(let t=0;t<r.length;t++)r[t]=-1;this._data=r,this._length=n}else{if(!(t instanceof Uint32Array))throw new Error("Invalid constructor");this._data=t,this._length=e}}getRawData(){return this._data}assureGoez(t,e){if(t<0)throw new Error(`${e} should be greater than zero`)}assureInRange(t,e,n,s){if(t<e||t>n)throw new Error(`Argument ${s} (${t}) out of range (${e}, ${n})`)}copy(t,e,n){for(let s=0;s<n;s++)e[s]=t[s]}copyFrom(t){if(this._length!=t._length)throw new Error(`Lengths differ (${this._length} != ${t._length})`);this.copy(t._data,this._data,this.lengthInInts),this._version++}get length(){return this._length}get buffer(){return this._data}set buffer(t){this._data=t,this._version++}get version(){return this._version}set version(t){this._version=t}incrementVersion(t=!0){this._version++}get lengthInInts(){return Math.floor((this._length+31)/32)}get versionedName(){return this._version==this._versionedNameVersion?this._versionedName:""}set versionedName(t){this._versionedName=t,this._versionedNameVersion=this._version}get self(){return this}setLength(t){if(t<0)throw new Error("should be >= 0");if(t==this._length)return;const e=Math.floor((t+31)/32);if(e>this._data.length||e+this.SHRINK_THRESHOLD<this._data.length){const t=new Uint32Array(e);this.copy(this._data,t,e>this._data.length?this._data.length:e),this._data=t}t>this._length&&(this._length%32>0&&(this._data[this.lengthInInts-1]&=(1<<(this._length%32&31))-1),this._data.fill(0,this.lengthInInts,e)),this._length=t,this._version++}static fromAnd(t,e){if(t._length!=e._length)throw new Error(`Lengths differ (${t._length} != ${e._length})`);const n=new s(t._length);n._length=t._length,n._data=s._createBuffer(n._length),n._version=0;const r=t.lengthInInts;for(let s=0;s<r;s++)n._data[s]=t._data[s]&e._data[s];return n}static _createBuffer(t){return new Uint32Array(Math.floor((t+31)/32))}static fromValues(t){const e=new s(t.length);e._version=0;for(let n=0;n<e._length;n++)t[n]&&(e._data[Math.floor(n/32)]|=1<<(n%32&31));return e}static fromSeq(t,e){const n=new s(t);for(let s=0;s<t;++s)n.setBit(s,e(s));return n._version=0,n}static fromString(t){return s.fromSeq(t.length,(e=>"1"==t.charAt(e)))}static fromUint32Array(t,e){const n=new s(t);return n._data=e,n}static fromBytes(t){const e=t.length,n=new s(8*e);n._data=new Uint32Array(Math.floor((e+3)/4)),n._length=8*e;let r=0,i=0;for(;e-i>=4;)n._data[r++]=255&t[i]|(255&t[i+1])<<8|(255&t[i+2])<<16|(255&t[i+3])<<24,i+=4;return e-i==3&&(n._data[r]=(255&t[i+2])<<16),e-i==2&&(n._data[r]|=(255&t[i+1])<<8),e-i==1&&(n._data[r]|=255&t[i]),n._version=0,n}toString(){return`${this._length} bits, ${this.countBits(!0)} set`}equals(t){if(this==t)return!0;if(null==t)return!1;if(this._length!=t._length)return!1;if(0==this._length)return!0;for(let e=0;e<this._data.length-1;e++)if(this._data[e]!=t._data[e])return!1;for(let e=8*(this._data.length-1);e<this._length;e++)if(this.getBit(e)!=t.getBit(e))return!1;return!0}clone(){const t=new s(0,!1);return t._data=Uint32Array.from(this._data),t._length=this._length,t._version=this._version,t}init(t,e){this.setAll(!1,!1);for(let e=0;e<this._length;e++)t(e)&&(this._data[Math.floor(e/32)]|=1<<(e%32&31));return this.incrementVersion(e),this}invert(t=!0){for(let t=0;t<this._data.length;t++)this._data[t]^=-1;this.incrementVersion(t)}setAll(t,e=!1){const n=t?-1:0,s=this.lengthInInts;for(let t=0;t<s;t++)this._data[t]=n;this.incrementVersion(e)}setIndexes(t,e=!0,n=!0,s=!0){n&&this.setAll(!e,!1);for(const n of t)this.setFast(n,e);this.incrementVersion(s)}everyIndex(t,e=!0){for(const n of t)if(this.getBit(n)!=e)return!1;return!0}anyIndex(t,e=!0){for(const n of t)if(this.getBit(n)==e)return!0;return!1}setWhere(t,e=!0,n=!0,s=!0,r=!0){if(n&&r&&this.setAll(!e,!1),r)for(let n=0;n<this._length;n++)t(n)&&this.setFast(n,e);else for(let n=0;n<this._length;n++)this.setFast(n,t(n)?e:!e);this.incrementVersion(s)}getRange(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const n=[];for(let s=t;s<e;++s)n.push(this.getBit(s));return s.fromValues(n)}getRangeAsList(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const n=[];for(let s=t;s<e;++s)n.push(this.getBit(s));return n}setRange(t,e,n,s=!0){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length-1,"to");const r=Math.min(t,e),i=Math.max(t,e);if(n)for(let t=r;t<=i;t++)this.setTrue(t);else for(let t=r;t<=i;t++)this.setFalse(t);return this.incrementVersion(s),this}setRandom(t,e,n=!0){if(t<0||t>this._length)throw new Error("n must be >= 0 && <= Count");t>this._length/2&&this.setRandom(this._length-t,!e),this.setAll(!e);for(let n=0;n<t;){const t=Math.floor(Math.random()*this._length);this.getBit(t)!=e&&(this.setFast(t,e),n++)}this.incrementVersion(n)}and(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]&=t._data[e];return this.incrementVersion(e),this}andNot(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");const n=this.lengthInInts;for(let e=0;e<n;e++)this._data[e]&=~t._data[e];return this.incrementVersion(e),this}notAnd(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]=~this._data[e]&t._data[e];return this.incrementVersion(e),this}not(t=!0){for(let t=0,e=this.lengthInInts;t<e;t++)this._data[t]=~this._data[t];return this.incrementVersion(t),this}or(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]|=t._data[e];return this.incrementVersion(e),this}xor(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]^=t._data[e];return this.incrementVersion(e),this}insertAt(t,e,n=!1){if(this.assureInRange(t,0,this._length,"pos"),0==e)return;const s=this._length;this.setLength(this._length+e);for(let n=s-1;n>=t;n--)this.setBit(n+e,this.getBit(n));for(let s=t;s<t+e;s++)this.setBit(s,n)}removeAt(t,e=1){if(e<0)throw new Error("n cannot be negative");if(this.assureInRange(t,0,this._length-e,"pos"),this.contains(!0))for(let n=t;n<this._length-e;n++)this.setBit(n,this.getBit(n+e));this.setLength(this._length-e)}removeByMask(t,e=!0){if(this._length!=t.length)throw new Error("length != mask.length");if(t==this)this.setLength(t.countBits(!e)),this.setAll(!e);else{let n=0;for(let s=-1;-1!=(s=t.findNext(s,!e));)this.setFast(n++,this.getBit(s));this._length=n,this._version++}return this}getBit(t){return 0!=(this._data[Math.floor(t/32)]&1<<(31&t))}setBit(t,e,n=!0){this.setFast(t,e),this._version++}setFast(t,e){e?this._data[Math.floor(t/32)]|=1<<(31&t):this._data[Math.floor(t/32)]&=~(1<<(31&t))}setTrue(t){this._data[Math.floor(t/32)]|=1<<(31&t)}setFalse(t){this._data[Math.floor(t/32)]&=~(1<<(31&t))}trueCount(){return this.countBits(!0)}falseCount(){return this.countBits(!1)}countBits(t){if(0==this._length)return 0;if(this._selectedCountVersion!=this._version){this._selectedCount=0;const t=this.lengthInInts;let e=0;for(;e<t-1;e++)for(let t=this._data[e];0!=t;t>>>=8)this._selectedCount+=s._onBitCount[255&t];let n=this._data[e];const r=31&this._length;for(0!=r&&(n&=~(4294967295<<r));0!=n;n>>>=8)this._selectedCount+=s._onBitCount[255&n];this._selectedCountVersion=this._version}return t?this._selectedCount:this._length-this._selectedCount}countWhere(t){let e=0;if(this.trueCount()==this._length)for(let n=0;n<this._length;n++)e+=t(n)?1:0;else for(let n=-1;-1!=(n=this.findNext(n,!0));)e+=t(n)?1:0;return e}andWithCountBits(t,e){if(0==this._length)return 0;let n=0;const r=this.lengthInInts;let i=0;for(;i<r-1;i++)for(let e=this._data[i]&t._data[i];0!=e;e>>>=8)n+=s._onBitCount[255&e];let h=this._data[i]&t._data[i];const o=31&this._length;for(0!=o&&(h&=~(4294967295<<o));0!=h;h>>>=8)n+=s._onBitCount[255&h];return e?n:this._length-n}clear(){this.setLength(0)}contains(t){return this.findNext(-1,t)>=0}get allTrue(){return this.countBits(!0)==this._length}get allFalse(){return this.countBits(!1)==this._length}get anyTrue(){return this.countBits(!0)>0}get anyFalse(){return this.countBits(!1)>0}findNext(t,e=!0){if(this.assureInRange(t,-1,this._length,"index"),t>=this._length-1)return-1;let n=31&(t=t<0?0:t+1);const r=this.lengthInInts;for(let i=Math.floor(t/32);i<r;i++){let r=e?this._data[i]:~this._data[i];if(0!=n)r&=4294967295<<n&4294967295,n=0;else if(!e&&-4294967296==r)continue;for(let e=0;0!=r;e+=8,r>>>=8){const n=s._firstOnBit[255&r];if(n>=0)return(t=n+32*i+e)>=this._length?-1:t}}return-1}findPrev(t,e=!0){if(0==t)return-1;this.assureInRange(t,-1,this._length,"index");let n=1+(t=t<0?this._length-1:t-1)&31;for(let r=Math.floor(t/32);r>=0;r--){let t=e?this._data[r]:~this._data[r];0!=n&&(t&=~(4294967295<<n),n=0);for(let e=24;0!=t;e-=8,t<<=8){const n=s._lastOnBit[t>>>24];if(n>=0)return n+32*r+e}}return-1}}s._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]),s._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]),s._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])},3979:(t,e)=>{e.H$=void 0,e.H$=function(t,e,n){var s=function(t,e,n){if(0===t.length||0===e.length)return 0;if(n&&!n.caseSensitive&&(t=t.toUpperCase(),e=e.toUpperCase()),t===e)return 1;for(var s=0,r=t.length,i=e.length,h=Math.floor(Math.max(r,i)/2)-1,o=new Array(r),a=new Array(i),l=0;l<r;l++)for(var _=Math.max(0,l-h);_<=Math.min(i,l+h+1);_++)if(!o[l]&&!a[_]&&t[l]===e[_]){++s,o[l]=a[_]=!0;break}if(0===s)return 0;var f=0,g=0;for(l=0;l<r;l++)if(o[l]){for(;!a[g];)g++;t.charAt(l)!==e.charAt(g++)&&f++}return(s/r+s/i+(s-(f/=2))/s)/3}(t,e,n),r=0;if(s>.7){for(var i=Math.min(t.length,e.length),h=0;t[h]===e[h]&&h<4&&h<i;)++r,h++;s+=.1*r*(1-s)}return s}}}]);
2
- //# sourceMappingURL=44.js.map