jbrowse-plugin-graphgenomeviewer 7.1.11 → 7.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/GbzBaseSyntenyAdapter-NB6WBBZH.js +2 -0
- package/dist/chunks/GbzBaseSyntenyAdapter-NB6WBBZH.js.map +7 -0
- package/dist/chunks/WalkTabixSyntenyAdapter-WBHOZLAN.js +2 -0
- package/dist/chunks/WalkTabixSyntenyAdapter-WBHOZLAN.js.map +7 -0
- package/dist/chunks/chunk-JLGPQO5L.js +4 -0
- package/dist/chunks/{chunk-U4U5ZOCH.js.map → chunk-JLGPQO5L.js.map} +4 -4
- package/dist/chunks/{chunk-OBQFV4NL.js → chunk-LXCMWL7B.js} +2 -2
- package/dist/chunks/chunk-M2D7NUOY.js +2 -0
- package/dist/chunks/{chunk-T4HOC6O3.js.map → chunk-M2D7NUOY.js.map} +4 -4
- package/dist/jbrowse-plugin-graphgenomeviewer.esm.js +3 -3
- package/dist/jbrowse-plugin-graphgenomeviewer.esm.js.map +2 -2
- package/package.json +1 -1
- package/src/GbzBaseSyntenyAdapter/GbzBaseSyntenyAdapter.test.ts +2 -4
- package/src/GbzBaseSyntenyAdapter/GbzBaseSyntenyAdapter.ts +9 -8
- package/src/RgfaTabixAdapter/test_data/walks3_lanepairs.GRCh38.walks.bed.gz +0 -0
- package/src/RgfaTabixAdapter/test_data/walks3_lanepairs.GRCh38.walks.bed.gz.tbi +0 -0
- package/src/WalkTabixSyntenyAdapter/WalkTabixSyntenyAdapter.test.ts +128 -3
- package/src/WalkTabixSyntenyAdapter/WalkTabixSyntenyAdapter.ts +4 -10
- package/src/WalkTabixSyntenyAdapter/walkLanes.ts +60 -0
- package/src/synteny/clipFeatureToRegion.test.ts +23 -0
- package/src/synteny/clipFeatureToRegion.ts +4 -1
- package/src/synteny/laneZoomNotice.test.ts +55 -0
- package/src/synteny/laneZoomNotice.ts +34 -0
- package/src/version.ts +1 -1
- package/dist/chunks/GbzBaseSyntenyAdapter-2MA3I6BM.js +0 -2
- package/dist/chunks/GbzBaseSyntenyAdapter-2MA3I6BM.js.map +0 -7
- package/dist/chunks/WalkTabixSyntenyAdapter-AIC3W7FL.js +0 -2
- package/dist/chunks/WalkTabixSyntenyAdapter-AIC3W7FL.js.map +0 -7
- package/dist/chunks/chunk-PJ43KEV6.js +0 -2
- package/dist/chunks/chunk-PJ43KEV6.js.map +0 -7
- package/dist/chunks/chunk-T4HOC6O3.js +0 -2
- package/dist/chunks/chunk-U4U5ZOCH.js +0 -4
- /package/dist/chunks/{chunk-OBQFV4NL.js.map → chunk-LXCMWL7B.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../node_modules/.pnpm/@jbrowse+cigar-utils@5.0.0-beta.11/node_modules/@jbrowse/cigar-utils/esm/coarseCigar.js", "../../node_modules/.pnpm/@jbrowse+cigar-utils@5.0.0-beta.11/node_modules/@jbrowse/cigar-utils/esm/csOps.js", "../../node_modules/.pnpm/@jbrowse+cigar-utils@5.0.0-beta.11/node_modules/@jbrowse/cigar-utils/esm/cigarToMismatches2.js", "../../node_modules/.pnpm/@jbrowse+cigar-utils@5.0.0-beta.11/node_modules/@jbrowse/cigar-utils/esm/mdToMismatches2.js", "../../node_modules/.pnpm/@jbrowse+cigar-utils@5.0.0-beta.11/node_modules/@jbrowse/cigar-utils/esm/mismatchParser.js", "../../src/synteny/SyntenyFeature.ts", "../../node_modules/.pnpm/tslib@2.8.1/node_modules/tslib/tslib.es6.mjs", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/util/isFunction.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/util/createErrorClass.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/util/UnsubscriptionError.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/util/arrRemove.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/Subscription.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/config.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/scheduler/timeoutProvider.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/util/reportUnhandledError.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/util/noop.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/NotificationFactories.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/util/errorContext.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/Subscriber.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/symbol/observable.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/util/identity.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/util/pipe.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/Observable.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/util/lift.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/operators/OperatorSubscriber.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/util/isArrayLike.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/util/isPromise.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/util/isInteropObservable.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/util/isAsyncIterable.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/util/throwUnobservableError.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/symbol/iterator.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/util/isIterable.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/util/isReadableStreamLike.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/observable/innerFrom.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/util/executeSchedule.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/operators/observeOn.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/operators/subscribeOn.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/scheduled/scheduleObservable.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/scheduled/schedulePromise.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/scheduled/scheduleArray.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/scheduled/scheduleIterable.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/scheduled/scheduleAsyncIterable.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/scheduled/scheduleReadableStreamLike.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/scheduled/scheduled.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/observable/from.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/operators/map.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/operators/mergeInternals.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/operators/mergeMap.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/operators/scanInternals.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/operators/reduce.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/operators/toArray.ts", "../../node_modules/.pnpm/@jbrowse+synteny-core@5.0.0-beta.11_@emotion+react@11.14.0_@types+react@19.3.0_react@19_6b83ce7782285603d64e48e3d7c0913c/node_modules/@jbrowse/synteny-core/esm/clipSyntenyFeature.js", "../../node_modules/.pnpm/@jbrowse+synteny-core@5.0.0-beta.11_@emotion+react@11.14.0_@types+react@19.3.0_react@19_6b83ce7782285603d64e48e3d7c0913c/node_modules/@jbrowse/synteny-core/esm/featureAlignmentOps.js", "../../src/synteny/clipFeatureToRegion.ts", "../../src/synteny/ComparativeAdapterBase.ts", "../../src/synteny/lanePairs.ts", "../../src/synteny/matchFeature.ts"],
|
|
4
|
-
"sourcesContent": ["import { CIGAR_D, CIGAR_I, CIGAR_M, CIGAR_N, CIGAR_RUN, } from './cigarConstants.js';\n/**\n * #api\n * Fold a CIGAR into a coarse CIGAR whose straight lines stay within `gap` of\n * the alignment's own path. An indel longer than half the gap keeps its letter\n * and length (D/N/I); a shorter one is absorbed into the match run around it,\n * and a run whose two axes advanced by different amounts is written\n * `<own>:<mate>M`, a square run `<n>M`. `=`/`X` count as M. `ownLen`/`mateLen`\n * are the totals each axis consumed, for the caller to check against the row's\n * coordinate columns.\n *\n * The bound: a run is closed before a folded indel would push its running\n * skew (own minus mate) past half the gap, and no folded indel is longer than\n * that, so inside a run the skew never exceeds half the gap and the line\n * between the run's corners is never more than the gap off the path. That is\n * what lets a reader interpolate within a run, and it costs a new run only\n * where the two genomes' small indels are lopsided.\n */\nexport function coarsenCigar(cigar, gap) {\n const skewBound = gap / 2;\n let ops = '';\n let ownLen = 0;\n let mateLen = 0;\n let gapCount = 0;\n let opCount = 0;\n let runOwn = 0;\n let runMate = 0;\n // a run with nothing on one side is the indel it amounts to, and is written\n // as one, so a reader never meets a zero-sided run\n const flushRun = () => {\n if (runOwn > 0 || runMate > 0) {\n ops +=\n runOwn === runMate\n ? `${runOwn}M`\n : runOwn === 0\n ? `${runMate}I`\n : runMate === 0\n ? `${runOwn}D`\n : `${runOwn}:${runMate}M`;\n opCount++;\n runOwn = 0;\n runMate = 0;\n }\n };\n const keep = (len, op) => {\n flushRun();\n ops += `${len}${op}`;\n gapCount++;\n opCount++;\n };\n const fold = (own, mate) => {\n if (Math.abs(runOwn + own - runMate - mate) > skewBound) {\n flushRun();\n }\n runOwn += own;\n runMate += mate;\n };\n let len = 0;\n for (let i = 0, l = cigar.length; i < l; i++) {\n const code = cigar.charCodeAt(i);\n if (code >= 48 && code <= 57) {\n len = len * 10 + code - 48;\n }\n else {\n const op = cigar[i];\n if (op === 'M' || op === '=' || op === 'X') {\n runOwn += len;\n runMate += len;\n ownLen += len;\n mateLen += len;\n }\n else if (op === 'D' || op === 'N') {\n ownLen += len;\n if (len > skewBound) {\n keep(len, op);\n }\n else {\n fold(len, 0);\n }\n }\n else if (op === 'I') {\n mateLen += len;\n if (len > skewBound) {\n keep(len, op);\n }\n else {\n fold(0, len);\n }\n }\n len = 0;\n }\n }\n flushRun();\n return { ops, ownLen, mateLen, gapCount, opCount };\n}\nfunction parseCoarseOps(s) {\n const out = [];\n let len = 0;\n let ownBeforeColon;\n for (let i = 0, l = s.length; i < l; i++) {\n const code = s.charCodeAt(i);\n if (code >= 48 && code <= 57) {\n len = len * 10 + code - 48;\n }\n else if (code === 58) {\n ownBeforeColon = len;\n len = 0;\n }\n else {\n // the alphabet is M I D N plus the run; a reader also takes =/X as M and\n // steps over clips and padding, which a writer never emits\n const op = s[i];\n if (op === 'M' || op === '=' || op === 'X') {\n out.push({\n own: ownBeforeColon === undefined ? len : ownBeforeColon,\n mate: len,\n op: 'M',\n });\n }\n else if (op === 'I') {\n out.push({ own: 0, mate: len, op });\n }\n else if (op === 'D' || op === 'N') {\n out.push({ own: len, mate: 0, op });\n }\n ownBeforeColon = undefined;\n len = 0;\n }\n }\n return out;\n}\nfunction serializeCoarseOps(ops) {\n let s = '';\n for (const { own, mate, op } of ops) {\n s +=\n op === 'M'\n ? own === mate\n ? `${own}M`\n : `${own}:${mate}M`\n : `${op === 'I' ? mate : own}${op}`;\n }\n return s;\n}\n// N keeps its axis as well as its letter, matching `swapIndelCigar`, which\n// swaps only D<->I\nfunction swapAxes({ own, mate, op }) {\n return op === 'N'\n ? { own, mate, op }\n : {\n own: mate,\n mate: own,\n op: op === 'D' ? 'I' : op === 'I' ? 'D' : op,\n };\n}\n/**\n * #api\n * The coarse CIGAR seen from the other axis on the plus strand: the two lengths\n * of every run trade places and D<->I swap, op order untouched. The twin of\n * `swapIndelCigar`.\n */\nexport function swapCoarseCigar(s) {\n return serializeCoarseOps(parseCoarseOps(s).map(swapAxes));\n}\n/**\n * #api\n * The coarse CIGAR seen from the other axis on the minus strand: swapped as\n * `swapCoarseCigar` does, and in reverse op order. The twin of `flipCigar`.\n */\nexport function flipCoarseCigar(s) {\n return serializeCoarseOps(parseCoarseOps(s).map(swapAxes).reverse());\n}\n/**\n * #api\n * The coarse CIGAR as a plain CIGAR over the row's own axis, for a walk that\n * places mismatches by reference position: a run keeps only its own length, a\n * run with no own length is the insertion it amounts to, and one with no mate\n * length the deletion. Kept indels are exact, so they land where the fine\n * tier's would.\n */\nexport function coarseCigarOwnAxis(s) {\n let out = '';\n for (const { own, mate, op } of parseCoarseOps(s)) {\n out +=\n op === 'M'\n ? own === 0\n ? `${mate}I`\n : mate === 0\n ? `${own}D`\n : `${own}M`\n : `${op === 'I' ? mate : own}${op}`;\n }\n return out;\n}\n// The packed form keeps 28 bits of length, so a longer op is written as several\n// words that sum to it. A run is split with both axes in proportion.\nconst MAX_PACKED_LEN = 2 ** 28 - 1;\nfunction pushPacked(out, len, code) {\n for (let rest = len; rest > 0; rest -= MAX_PACKED_LEN) {\n out.push(((Math.min(rest, MAX_PACKED_LEN) << 4) | code) >>> 0);\n }\n}\nfunction pushRun(out, own, mate) {\n if (own === mate) {\n pushPacked(out, own, CIGAR_M);\n }\n else {\n const chunks = Math.ceil(Math.max(own, mate) / MAX_PACKED_LEN);\n for (let i = 0; i < chunks; i++) {\n const o = Math.floor((own * (i + 1)) / chunks) - Math.floor((own * i) / chunks);\n const m = Math.floor((mate * (i + 1)) / chunks) - Math.floor((mate * i) / chunks);\n out.push(((o << 4) | CIGAR_RUN) >>> 0, ((m << 4) | CIGAR_RUN) >>> 0);\n }\n }\n}\n/**\n * #api\n * Parse a coarse CIGAR into the packed `(len << 4) | op` form\n * `visitCigarRenderedSegments` walks. A square run packs as one `CIGAR_M`\n * word; an unequal run as a `CIGAR_RUN` word pair, own axis first.\n */\nexport function parseCoarseCigar(s) {\n const out = [];\n for (const { own, mate, op } of parseCoarseOps(s)) {\n if (op === 'M') {\n pushRun(out, own, mate);\n }\n else if (op === 'I') {\n pushPacked(out, mate, CIGAR_I);\n }\n else {\n pushPacked(out, own, op === 'N' ? CIGAR_N : CIGAR_D);\n }\n }\n return Uint32Array.from(out);\n}\n", "import { DELETION_TYPE, INSERTION_TYPE, MISMATCH_TYPE, SKIP_TYPE, } from './mismatchCallback.js';\nfunction isDigit(code) {\n return code >= 48 && code <= 57;\n}\nfunction isBaseChar(ch) {\n return ch !== undefined && /[A-Za-z]/.test(ch);\n}\nfunction scanBases(cs, start) {\n let i = start;\n while (i < cs.length && isBaseChar(cs[i])) {\n i++;\n }\n return i;\n}\nfunction scanDigits(cs, start) {\n let i = start;\n let value = 0;\n while (i < cs.length && isDigit(cs.charCodeAt(i))) {\n value = value * 10 + (cs.charCodeAt(i) - 48);\n i++;\n }\n return { value, next: i };\n}\n/**\n * Walk a minimap2 `cs` difference string\n * (https://github.com/lh3/minimap2#cs), calling `callback` once per operation.\n *\n * Short form is `:N` match run, `*ab` substitution (ref base a, query base b),\n * `+seq` insertion, `-seq` deletion; long form adds `=SEQ` match runs; `~ab12cd`\n * is a 12 bp intron between the given splice motifs. A character belonging to\n * none of those is skipped, so a truncated or extended string still walks to the\n * end rather than throwing.\n *\n * `refLen`/`queryLen` are the bases the operation consumes on each sequence, and\n * `[seqStart, seqEnd)` bounds its operand *within `cs`* \u2014 the bases for `=`/`+`/\n * `-`, the two substituted bases for `*`, the digits for `:`, the whole motif\n * for `~`. Offsets rather than a substring because the mismatch walk runs per\n * feature per frame, and only two of six ops ever need the text.\n *\n * **One walker, because four disagreed.** This replaces a copy in each of\n * `csToCigar`, `flipCs`, `forEachCsMismatch` and the (now removed) `visitCsOps`,\n * and every one of the divergences was silent: two of them dropped `~` and then\n * mis-scanned the rest of the string, one ignored `=SEQ` entirely and so never\n * advanced the reference across a long-form match run, and the three that\n * scanned `+`/`-` operands disagreed on where one ends.\n */\nexport function forEachCsOp(cs, callback) {\n let i = 0;\n while (i < cs.length) {\n const c = cs[i];\n if (c === ':') {\n const { value, next } = scanDigits(cs, i + 1);\n callback(':', value, value, i + 1, next);\n i = next;\n }\n else if (c === '=') {\n const next = scanBases(cs, i + 1);\n const len = next - i - 1;\n callback('=', len, len, i + 1, next);\n i = next;\n }\n else if (c === '*') {\n callback('*', 1, 1, i + 1, Math.min(i + 3, cs.length));\n i += 3;\n }\n else if (c === '+' || c === '-') {\n const next = scanBases(cs, i + 1);\n const len = next - i - 1;\n callback(c, c === '-' ? len : 0, c === '+' ? len : 0, i + 1, next);\n i = next;\n }\n else if (c === '~') {\n // the length sits between two 2-base splice motifs\n const { value, next } = scanDigits(cs, i + 3);\n const end = Math.min(next + 2, cs.length);\n callback('~', value, 0, i + 1, end);\n i = end;\n }\n else {\n i++;\n }\n }\n}\n/**\n * Rewrite a cs string from the target perspective to the query perspective (for\n * a synteny view anchored on the query assembly): `*ab` -> `*ba`, `+seq` ->\n * `-seq`, `-seq` -> `+seq`, match runs unchanged.\n *\n * Undefined when the string states something the query perspective cannot: an\n * intron is a gap in the *reference*, and flipped it becomes a gap in the query\n * with no sequence to write for it, which cs has no way to express. Callers fall\n * back to the CIGAR there, the same as they already do for reverse-strand\n * alignments (which additionally need a reverse-complement).\n */\nexport function flipCs(cs) {\n // The one op with no query-perspective form, and cs writes it nowhere else \u2014\n // operands are base letters. Answered before the walk so the rewrite below is\n // total.\n if (cs.includes('~')) {\n return undefined;\n }\n let result = '';\n forEachCsOp(cs, (op, refLen, _queryLen, seqStart, seqEnd) => {\n if (op === ':') {\n result += `:${refLen}`;\n }\n else if (op === '=') {\n result += `=${cs.slice(seqStart, seqEnd)}`;\n }\n else if (op === '*') {\n result += `*${cs[seqStart + 1] ?? ''}${cs[seqStart] ?? ''}`;\n }\n else {\n result += `${op === '+' ? '-' : '+'}${cs.slice(seqStart, seqEnd)}`;\n }\n });\n return result;\n}\n/**\n * Walk a cs string and drive a {@link MismatchCallback} (the contract BAM/CRAM\n * features use), emitting per-base substitutions with their real query base plus\n * insertions, deletions and introns. Offsets are relative to the reference\n * (feature) start; `windowStart`/`windowEnd` (also reference-relative) clip the\n * output.\n */\nexport function forEachCsMismatch(cs, callback, windowStart, windowEnd) {\n const lo = windowStart ?? Number.NEGATIVE_INFINITY;\n const hi = windowEnd ?? Number.POSITIVE_INFINITY;\n let ref = 0;\n forEachCsOp(cs, (op, refLen, queryLen, seqStart, seqEnd) => {\n if (op === '*') {\n if (ref >= lo && ref < hi) {\n callback(MISMATCH_TYPE, ref, 1, cs[seqStart + 1] ?? '', -1, 0, 0);\n }\n }\n else if (op === '+') {\n if (ref >= lo && ref <= hi) {\n const seq = cs.slice(seqStart, seqEnd);\n callback(INSERTION_TYPE, ref, queryLen, seq, -1, 0, queryLen);\n }\n }\n else if (op === '-' || op === '~') {\n if (ref < hi && ref + refLen > lo) {\n // an intron is a reference gap the read skips rather than deletes, and\n // the two draw differently\n const type = op === '-' ? DELETION_TYPE : SKIP_TYPE;\n callback(type, ref, refLen, '', -1, 0, 0);\n }\n }\n ref += refLen;\n });\n}\n", "import { CIGAR_D, CIGAR_EQ, CIGAR_H, CIGAR_I, CIGAR_M, CIGAR_N, CIGAR_S, CIGAR_X, } from './cigarConstants.js';\n// Handles packed NUMERIC_CIGAR format from @gmod/bam\n// Format: Uint32Array where each value is (length << 4) | opIndex\n// opIndex is 0-8: M=0, I=1, D=2, N=3, S=4, H=5, P=6, ==7, X=8\nexport function cigarToMismatches2(ops, seq, ref, qual) {\n let roffset = 0;\n let soffset = 0;\n const mismatches = [];\n const hasRefAndSeq = ref && seq;\n for (let i = 0, l = ops.length; i < l; i++) {\n const packed = ops[i];\n const len = packed >>> 4;\n const op = packed & 0xf;\n if (op === CIGAR_M || op === CIGAR_EQ) {\n if (hasRefAndSeq) {\n for (let j = 0; j < len; j++) {\n if ((seq.charCodeAt(soffset + j) | 0x20) !==\n (ref.charCodeAt(roffset + j) | 0x20)) {\n mismatches.push({\n start: roffset + j,\n type: 'mismatch',\n base: seq[soffset + j],\n altbase: ref[roffset + j],\n length: 1,\n });\n }\n }\n }\n soffset += len;\n roffset += len;\n }\n else if (op === CIGAR_I) {\n mismatches.push({\n start: roffset,\n type: 'insertion',\n insertlen: len,\n insertedBases: seq?.slice(soffset, soffset + len),\n length: 0,\n });\n soffset += len;\n }\n else if (op === CIGAR_D) {\n mismatches.push({\n start: roffset,\n type: 'deletion',\n length: len,\n });\n roffset += len;\n }\n else if (op === CIGAR_N) {\n mismatches.push({\n start: roffset,\n type: 'skip',\n length: len,\n });\n roffset += len;\n }\n else if (op === CIGAR_X) {\n for (let j = 0; j < len; j++) {\n mismatches.push({\n start: roffset + j,\n type: 'mismatch',\n base: seq?.[soffset + j] || 'X',\n qual: qual?.[soffset + j],\n length: 1,\n });\n }\n soffset += len;\n roffset += len;\n }\n else if (op === CIGAR_H) {\n mismatches.push({\n start: roffset,\n type: 'hardclip',\n cliplen: len,\n length: 1,\n });\n }\n else if (op === CIGAR_S) {\n mismatches.push({\n start: roffset,\n type: 'softclip',\n cliplen: len,\n length: 1,\n });\n soffset += len;\n }\n }\n return mismatches;\n}\n", "import { CIGAR_D, CIGAR_H, CIGAR_I, CIGAR_N, CIGAR_P, CIGAR_S, } from './cigarConstants.js';\n// Handles packed NUMERIC_CIGAR format from @gmod/bam\n// Format: Uint32Array where each value is (length << 4) | opIndex\n// opIndex is 0-8: M=0, I=1, D=2, N=3, S=4, H=5, P=6, ==7, X=8\nexport function mdToMismatches2(mdstring, ops, cigarMismatches, seq, qual) {\n if (!ops) {\n return [];\n }\n const mismatchRecords = [];\n const opsLength = ops.length;\n const seqLength = seq.length;\n const hasQual = qual !== undefined;\n // only check for skips if cigarMismatches has any\n const cigarLength = cigarMismatches.length;\n let hasSkips = false;\n for (let k = 0; k < cigarLength; k++) {\n if (cigarMismatches[k].type === 'skip') {\n hasSkips = true;\n break;\n }\n }\n let currStart = 0;\n let lastCigar = 0;\n let lastTemplateOffset = 0;\n let lastRefOffset = 0;\n let lastSkipPos = 0;\n // parse the MD string manually for better performance\n let i = 0;\n const len = mdstring.length;\n while (i < len) {\n const char = mdstring.charCodeAt(i);\n if (char >= 48 && char <= 57) {\n // digit (0-9)\n let num = 0;\n while (i < len) {\n const c = mdstring.charCodeAt(i);\n if (c >= 48 && c <= 57) {\n num = num * 10 + (c - 48);\n i++;\n }\n else {\n break;\n }\n }\n currStart += num;\n }\n else if (char === 94) {\n // '^' - deletion\n i++;\n while (i < len && mdstring.charCodeAt(i) >= 65) {\n // skip deleted bases (A-Z, a-z)\n i++;\n currStart++;\n }\n }\n else if (char >= 65) {\n // letter (mismatch)\n const letter = mdstring[i];\n i++;\n // handle skips in cigar\n if (hasSkips && cigarLength > 0) {\n for (let k = lastSkipPos; k < cigarLength; k++) {\n const mismatch = cigarMismatches[k];\n if (mismatch.type === 'skip' && currStart >= mismatch.start) {\n currStart += mismatch.length;\n lastSkipPos = k + 1;\n }\n }\n }\n // find position in read that corresponds to currStart\n let templateOffset = lastTemplateOffset;\n let refOffset = lastRefOffset;\n // Packed format: each element is (length << 4) | opIndex\n for (let j = lastCigar; j < opsLength && refOffset <= currStart; j++, lastCigar = j) {\n const packed = ops[j];\n const len = packed >>> 4;\n const op = packed & 0xf;\n if (op === CIGAR_S || op === CIGAR_I) {\n templateOffset += len;\n }\n else if (op === CIGAR_D || op === CIGAR_P || op === CIGAR_N) {\n refOffset += len;\n }\n else if (op !== CIGAR_H) {\n templateOffset += len;\n refOffset += len;\n }\n }\n lastTemplateOffset = templateOffset;\n lastRefOffset = refOffset;\n const s = templateOffset - (refOffset - currStart);\n const base = s < seqLength ? seq[s] : 'X';\n mismatchRecords.push({\n start: currStart,\n base,\n qual: hasQual ? qual[s] : undefined,\n altbase: letter,\n length: 1,\n type: 'mismatch',\n });\n currStart++;\n }\n else {\n i++;\n }\n }\n return mismatchRecords;\n}\n", "import { CIGAR_D, CIGAR_H, CIGAR_I, CIGAR_N, CIGAR_S, } from './cigarConstants.js';\nimport { cigarToMismatches2 } from './cigarToMismatches2.js';\nimport { mdToMismatches2 } from './mdToMismatches2.js';\n// CIGAR operation char codes to indices (from BAM spec)\nconst CIGAR_CODE_TO_INDEX = {\n 77: 0, // M\n 73: 1, // I\n 68: 2, // D\n 78: 3, // N\n 83: 4, // S\n 72: 5, // H\n 80: 6, // P\n 61: 7, // =\n 88: 8, // X\n};\n/**\n * #api\n * Parses a CIGAR string to an alternating `[length, op, ...]` string array.\n */\nexport function parseCigar(s = '') {\n let currLen = '';\n const ret = [];\n for (let i = 0, l = s.length; i < l; i++) {\n const c = s[i];\n if (c >= '0' && c <= '9') {\n currLen = currLen + c;\n }\n else {\n ret.push(currLen, c);\n currLen = '';\n }\n }\n return ret;\n}\n/**\n * #api\n * Parses a CIGAR string to a packed number array where each value is\n * `(length << 4) | opIndex`.\n */\nexport function parseCigar2(s = '') {\n let currLen = 0;\n const ret = [];\n for (let i = 0, l = s.length; i < l; i++) {\n const code = s.charCodeAt(i);\n if (code >= 48 && code <= 57) {\n currLen = currLen * 10 + (code - 48);\n }\n else {\n const opIndex = CIGAR_CODE_TO_INDEX[code];\n ret.push((currLen << 4) | opIndex);\n currLen = 0;\n }\n }\n return ret;\n}\n/**\n * #api\n * Same encoding as `parseCigar2` but writes into a packed `Uint32Array` \u2014\n * matches the NUMERIC_CIGAR format that BAM/CRAM adapters emit, so consumers can\n * use a single typed-array code path.\n */\nexport function parseCigar2Typed(s = '') {\n let opCount = 0;\n for (let i = 0, l = s.length; i < l; i++) {\n const code = s.charCodeAt(i);\n if (code < 48 || code > 57) {\n opCount++;\n }\n }\n const out = new Uint32Array(opCount);\n let currLen = 0;\n let j = 0;\n for (let i = 0, l = s.length; i < l; i++) {\n const code = s.charCodeAt(i);\n if (code >= 48 && code <= 57) {\n currLen = currLen * 10 + (code - 48);\n }\n else {\n out[j++] = (currLen << 4) | CIGAR_CODE_TO_INDEX[code];\n currLen = 0;\n }\n }\n return out;\n}\n/**\n * #api\n * Computes the list of mismatches (SNVs, indels, clips, skips) for a read from\n * its CIGAR, optional MD tag, sequence, reference, and quality.\n */\nexport function getMismatches(cigar, md, seq, ref, qual) {\n const ops = parseCigar2(cigar);\n const mismatches = cigar ? cigarToMismatches2(ops, seq, ref, qual) : [];\n if (md && seq) {\n return mismatches.concat(mdToMismatches2(md, ops, mismatches, seq, qual));\n }\n return mismatches;\n}\n// All three lengths in one pass over already-parsed ops: callers that want more\n// than one (featurizeSA wants all three) would otherwise re-scan and re-allocate\n// the op array per length.\nfunction cigarLengths(ops) {\n let lengthOnRef = 0;\n let length = 0;\n let lengthSansClipping = 0;\n for (let i = 0, l = ops.length; i < l; i++) {\n const op = ops[i];\n const opIdx = op & 0xf;\n const len = op >>> 4;\n const clipping = opIdx === CIGAR_H || opIdx === CIGAR_S;\n const refOnly = opIdx === CIGAR_D || opIdx === CIGAR_N;\n if (!clipping && opIdx !== CIGAR_I) {\n lengthOnRef += len;\n }\n if (!refOnly) {\n length += len;\n }\n if (!clipping && !refOnly) {\n lengthSansClipping += len;\n }\n }\n return { lengthOnRef, length, lengthSansClipping };\n}\n/**\n * #api\n * Length the read spans on the reference (sum of M/=/X/D/N ops).\n */\nexport function getLengthOnRef(cigar) {\n return cigarLengths(parseCigar2(cigar)).lengthOnRef;\n}\n/**\n * #api\n * Length of the read sequence (sum of all ops except D/N).\n */\nexport function getLength(cigar) {\n return cigarLengths(parseCigar2(cigar)).length;\n}\nexport function getLengthSansClipping(cigar) {\n return cigarLengths(parseCigar2(cigar)).lengthSansClipping;\n}\n// clip at the end of the CIGAR string = start of a reverse-strand read,\n// clip at the start of the CIGAR string = start of a forward-strand read\nexport function getClip(cigar, strand) {\n if (!cigar) {\n return 0;\n }\n if (strand === -1) {\n const last = cigar.length - 1;\n const op = cigar[last];\n if (op === 'S' || op === 'H') {\n let i = last;\n while (i > 0 && cigar[i - 1] >= '0' && cigar[i - 1] <= '9') {\n i--;\n }\n return +cigar.slice(i, last);\n }\n return 0;\n }\n else {\n let i = 0;\n while (cigar[i] >= '0' && cigar[i] <= '9') {\n i++;\n }\n const op = cigar[i];\n return (op === 'S' || op === 'H') && i > 0 ? +cigar.slice(0, i) : 0;\n }\n}\n// numeric analog of getClip: reads the start-clip length straight off a packed\n// NUMERIC_CIGAR (each entry = (length << 4) | opIndex) without serializing to a\n// CIGAR string. Reverse-strand reads clip at the CIGAR tail, forward at the head.\nexport function clipLengthAtStartOfReadNumeric(cigar, strand) {\n const len = cigar.length;\n if (len === 0) {\n return 0;\n }\n const packed = strand === -1 ? cigar[len - 1] : cigar[0];\n const op = packed & 0xf;\n return op === CIGAR_S || op === CIGAR_H ? packed >>> 4 : 0;\n}\n// produces a list of \"feature-like\" object from parsing supplementary\n// alignments in the SA tag\n//\n// @param normalize - used specifically in the linear-read-vs-ref context, it\n// flips features around relative to the original feature. other contexts of\n// usage can keep this false\nexport function featurizeSA(SA, id, strand, readName, normalize) {\n return SA === undefined\n ? []\n : featurizeSAEntries(splitSA(SA), id, strand, readName, normalize);\n}\n/**\n * #api\n * The `;`-separated alignment records of an SA tag, empties dropped \u2014 the input\n * `featurizeSAEntries` expects.\n */\nexport function splitSA(SA) {\n return SA.split(';').filter(aln => !!aln);\n}\n/**\n * #api\n * featurizeSA over pre-split entries (see splitSA). Lets a caller filter the\n * entries first \u2014 e.g. deduplicating the records repeated across a split read's\n * segments \u2014 without paying to split and rejoin the tag around the filter.\n */\nexport function featurizeSAEntries(entries, id, strand, readName, normalize) {\n const strandNum = strand ?? 1;\n return entries.map((aln, index) => {\n const ret = aln.split(',');\n const saRef = ret[0];\n const saStart = ret[1];\n const saStrand = ret[2];\n const saCigar = ret[3];\n const saOps = parseCigar2(saCigar);\n const { lengthOnRef: saLengthOnRef, length: saLength, lengthSansClipping: saLengthSansClipping, } = cigarLengths(saOps);\n const saStrandNormalized = saStrand === '-' ? -1 : 1;\n const effectiveStrand = normalize\n ? strandNum === saStrandNormalized\n ? 1\n : -1\n : saStrandNormalized;\n const saClipPos = clipLengthAtStartOfReadNumeric(saOps, effectiveStrand);\n const saRealStart = +saStart - 1;\n return {\n refName: saRef,\n start: saRealStart,\n end: saRealStart + saLengthOnRef,\n seqLength: saLength,\n clipLengthAtStartOfRead: saClipPos,\n CIGAR: saCigar,\n strand: effectiveStrand,\n uniqueId: `${id}_SA${index}`,\n mate: {\n start: saClipPos,\n end: saClipPos + saLengthSansClipping,\n refName: readName,\n },\n };\n });\n}\n", "import {\n DELETION_TYPE,\n INSERTION_TYPE,\n MISMATCH_TYPE,\n SKIP_TYPE,\n coarseCigarOwnAxis,\n forEachCsMismatch,\n getMismatches,\n} from '@jbrowse/cigar-utils'\nimport { SimpleFeature } from '@jbrowse/core/util'\n\nimport type { MismatchCallback, MismatchWindow } from '@jbrowse/cigar-utils'\nimport type { Feature } from '@jbrowse/core/util'\n\n// Implementing forEachMismatch lets synteny features flow through the alignments\n// GPU/Canvas2D mismatch pipeline (LGVSyntenyDisplay reuses it), rendering\n// per-base SNPs and indels. Prefer the cs tag (real query bases); fall back to\n// the CIGAR (positions only, no base identity for X ops).\nexport default class SyntenyFeature extends SimpleFeature {\n get(name: 'mismatches'): ReturnType<typeof getMismatches>\n get(name: 'refName'): string\n get(name: 'name' | 'type' | 'id' | 'source'): string | undefined\n get(name: 'start' | 'end' | 'clipLengthAtStartOfRead'): number\n get(name: 'phase'): 0 | 1 | 2 | undefined\n get(name: 'strand'): -1 | 0 | 1 | undefined\n get(name: 'score'): number | undefined\n get(name: 'subfeatures'): Feature[] | undefined\n get(name: string): unknown\n get(name: string): unknown {\n if (name === 'mismatches') {\n return getMismatches(this.walkableCigar)\n } else if (name === 'clipLengthAtStartOfRead') {\n return this.clipLengthAtStartOfRead\n } else if (name === 'name') {\n return super.get('name') ?? this.mate?.refName\n } else {\n return super.get(name)\n }\n }\n\n private get mate() {\n return super.get('mate') as { refName?: string; start?: number } | undefined\n }\n\n // The CIGAR, or on the coarse tier its fold read along this row's own axis,\n // so a kept indel places itself where the fine tier's would; the runs' mate\n // lengths mean nothing to a reference-anchored mismatch walk.\n private get walkableCigar() {\n const cigar = super.get('CIGAR')\n const coarse = super.get('coarseCigar')\n return typeof cigar === 'string'\n ? cigar\n : typeof coarse === 'string'\n ? coarseCigarOwnAxis(coarse)\n : undefined\n }\n\n // The block's offset along the other sequence, i.e. what a soft clip is to a\n // read: the position the alignments chain builder sorts a name's blocks by,\n // so a contig's blocks chain in contig order rather than fetch order. A PAF\n // CIGAR carries no clip of its own.\n get clipLengthAtStartOfRead() {\n return this.mate?.start ?? 0\n }\n\n forEachMismatch(callback: MismatchCallback, opts?: MismatchWindow) {\n const start = this.get('start')\n const ws = opts?.start === undefined ? undefined : opts.start - start\n const we = opts?.end === undefined ? undefined : opts.end - start\n const cs = this.get('cs') as string | undefined\n if (cs) {\n forEachCsMismatch(cs, callback, ws, we)\n } else {\n const lo = ws ?? Number.NEGATIVE_INFINITY\n const hi = we ?? Number.POSITIVE_INFINITY\n for (const m of getMismatches(this.walkableCigar)) {\n // Deletions and skips are spans, so one that starts left of the window\n // but reaches into it still draws \u2014 the overlap test the cs path and\n // BAM's forEachMismatchNumeric both apply. Clipping them on start\n // alone made a deletion larger than the viewport vanish exactly when\n // zoomed into it.\n const visible =\n m.type === 'deletion' || m.type === 'skip'\n ? m.start < hi && m.start + m.length > lo\n : m.start >= lo && m.start <= hi\n if (visible) {\n if (m.type === 'mismatch') {\n callback(\n MISMATCH_TYPE,\n m.start,\n m.length,\n m.base,\n m.qual ?? -1,\n 0,\n 0,\n )\n } else if (m.type === 'insertion') {\n callback(\n INSERTION_TYPE,\n m.start,\n m.length,\n m.insertedBases ?? '',\n -1,\n 0,\n m.insertlen,\n )\n } else if (m.type === 'deletion') {\n callback(DELETION_TYPE, m.start, m.length, '', -1, 0, 0)\n } else if (m.type === 'skip') {\n callback(SKIP_TYPE, m.start, m.length, '', -1, 0, 0)\n }\n }\n }\n }\n }\n}\n", "/******************************************************************************\nCopyright (c) Microsoft Corporation.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\n/* global Reflect, Promise, SuppressedError, Symbol, Iterator */\n\nvar extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n};\n\nexport function __extends(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n}\n\nexport var __assign = function() {\n __assign = Object.assign || function __assign(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\n }\n return t;\n }\n return __assign.apply(this, arguments);\n}\n\nexport function __rest(s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n}\n\nexport function __decorate(decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n}\n\nexport function __param(paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n}\n\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\n var _, done = false;\n for (var i = decorators.length - 1; i >= 0; i--) {\n var context = {};\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\n if (kind === \"accessor\") {\n if (result === void 0) continue;\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\n if (_ = accept(result.get)) descriptor.get = _;\n if (_ = accept(result.set)) descriptor.set = _;\n if (_ = accept(result.init)) initializers.unshift(_);\n }\n else if (_ = accept(result)) {\n if (kind === \"field\") initializers.unshift(_);\n else descriptor[key] = _;\n }\n }\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\n done = true;\n};\n\nexport function __runInitializers(thisArg, initializers, value) {\n var useValue = arguments.length > 2;\n for (var i = 0; i < initializers.length; i++) {\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\n }\n return useValue ? value : void 0;\n};\n\nexport function __propKey(x) {\n return typeof x === \"symbol\" ? x : \"\".concat(x);\n};\n\nexport function __setFunctionName(f, name, prefix) {\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\n};\n\nexport function __metadata(metadataKey, metadataValue) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\n}\n\nexport function __awaiter(thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n}\n\nexport function __generator(thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === \"function\" ? Iterator : Object).prototype);\n return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n}\n\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n});\n\nexport function __exportStar(m, o) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\n}\n\nexport function __values(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n}\n\nexport function __read(o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n}\n\n/** @deprecated */\nexport function __spread() {\n for (var ar = [], i = 0; i < arguments.length; i++)\n ar = ar.concat(__read(arguments[i]));\n return ar;\n}\n\n/** @deprecated */\nexport function __spreadArrays() {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n}\n\nexport function __spreadArray(to, from, pack) {\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n if (ar || !(i in from)) {\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n ar[i] = from[i];\n }\n }\n return to.concat(ar || Array.prototype.slice.call(from));\n}\n\nexport function __await(v) {\n return this instanceof __await ? (this.v = v, this) : new __await(v);\n}\n\nexport function __asyncGenerator(thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = Object.create((typeof AsyncIterator === \"function\" ? AsyncIterator : Object).prototype), verb(\"next\"), verb(\"throw\"), verb(\"return\", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;\n function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }\n function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n}\n\nexport function __asyncDelegator(o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\n}\n\nexport function __asyncValues(o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n}\n\nexport function __makeTemplateObject(cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n};\n\nvar __setModuleDefault = Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n};\n\nvar ownKeys = function(o) {\n ownKeys = Object.getOwnPropertyNames || function (o) {\n var ar = [];\n for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;\n return ar;\n };\n return ownKeys(o);\n};\n\nexport function __importStar(mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== \"default\") __createBinding(result, mod, k[i]);\n __setModuleDefault(result, mod);\n return result;\n}\n\nexport function __importDefault(mod) {\n return (mod && mod.__esModule) ? mod : { default: mod };\n}\n\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n}\n\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\n}\n\nexport function __classPrivateFieldIn(state, receiver) {\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\n}\n\nexport function __addDisposableResource(env, value, async) {\n if (value !== null && value !== void 0) {\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\n var dispose, inner;\n if (async) {\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\n dispose = value[Symbol.asyncDispose];\n }\n if (dispose === void 0) {\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\n dispose = value[Symbol.dispose];\n if (async) inner = dispose;\n }\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\n if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };\n env.stack.push({ value: value, dispose: dispose, async: async });\n }\n else if (async) {\n env.stack.push({ async: true });\n }\n return value;\n}\n\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\n var e = new Error(message);\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\n};\n\nexport function __disposeResources(env) {\n function fail(e) {\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\n env.hasError = true;\n }\n var r, s = 0;\n function next() {\n while (r = env.stack.pop()) {\n try {\n if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);\n if (r.dispose) {\n var result = r.dispose.call(r.value);\n if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\n }\n else s |= 1;\n }\n catch (e) {\n fail(e);\n }\n }\n if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();\n if (env.hasError) throw env.error;\n }\n return next();\n}\n\nexport function __rewriteRelativeImportExtension(path, preserveJsx) {\n if (typeof path === \"string\" && /^\\.\\.?\\//.test(path)) {\n return path.replace(/\\.(tsx)$|((?:\\.d)?)((?:\\.[^./]+?)?)\\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {\n return tsx ? preserveJsx ? \".jsx\" : \".js\" : d && (!ext || !cm) ? m : (d + ext + \".\" + cm.toLowerCase() + \"js\");\n });\n }\n return path;\n}\n\nexport default {\n __extends,\n __assign,\n __rest,\n __decorate,\n __param,\n __esDecorate,\n __runInitializers,\n __propKey,\n __setFunctionName,\n __metadata,\n __awaiter,\n __generator,\n __createBinding,\n __exportStar,\n __values,\n __read,\n __spread,\n __spreadArrays,\n __spreadArray,\n __await,\n __asyncGenerator,\n __asyncDelegator,\n __asyncValues,\n __makeTemplateObject,\n __importStar,\n __importDefault,\n __classPrivateFieldGet,\n __classPrivateFieldSet,\n __classPrivateFieldIn,\n __addDisposableResource,\n __disposeResources,\n __rewriteRelativeImportExtension,\n};\n", "/**\n * Returns true if the object is a function.\n * @param value The value to check\n */\nexport function isFunction(value: any): value is (...args: any[]) => any {\n return typeof value === 'function';\n}\n", "/**\n * Used to create Error subclasses until the community moves away from ES5.\n *\n * This is because compiling from TypeScript down to ES5 has issues with subclassing Errors\n * as well as other built-in types: https://github.com/Microsoft/TypeScript/issues/12123\n *\n * @param createImpl A factory function to create the actual constructor implementation. The returned\n * function should be a named function that calls `_super` internally.\n */\nexport function createErrorClass<T>(createImpl: (_super: any) => any): T {\n const _super = (instance: any) => {\n Error.call(instance);\n instance.stack = new Error().stack;\n };\n\n const ctorFunc = createImpl(_super);\n ctorFunc.prototype = Object.create(Error.prototype);\n ctorFunc.prototype.constructor = ctorFunc;\n return ctorFunc;\n}\n", "import { createErrorClass } from './createErrorClass';\n\nexport interface UnsubscriptionError extends Error {\n readonly errors: any[];\n}\n\nexport interface UnsubscriptionErrorCtor {\n /**\n * @deprecated Internal implementation detail. Do not construct error instances.\n * Cannot be tagged as internal: https://github.com/ReactiveX/rxjs/issues/6269\n */\n new (errors: any[]): UnsubscriptionError;\n}\n\n/**\n * An error thrown when one or more errors have occurred during the\n * `unsubscribe` of a {@link Subscription}.\n */\nexport const UnsubscriptionError: UnsubscriptionErrorCtor = createErrorClass(\n (_super) =>\n function UnsubscriptionErrorImpl(this: any, errors: (Error | string)[]) {\n _super(this);\n this.message = errors\n ? `${errors.length} errors occurred during unsubscription:\n${errors.map((err, i) => `${i + 1}) ${err.toString()}`).join('\\n ')}`\n : '';\n this.name = 'UnsubscriptionError';\n this.errors = errors;\n }\n);\n", "/**\n * Removes an item from an array, mutating it.\n * @param arr The array to remove the item from\n * @param item The item to remove\n */\nexport function arrRemove<T>(arr: T[] | undefined | null, item: T) {\n if (arr) {\n const index = arr.indexOf(item);\n 0 <= index && arr.splice(index, 1);\n }\n}\n", "import { isFunction } from './util/isFunction';\nimport { UnsubscriptionError } from './util/UnsubscriptionError';\nimport { SubscriptionLike, TeardownLogic, Unsubscribable } from './types';\nimport { arrRemove } from './util/arrRemove';\n\n/**\n * Represents a disposable resource, such as the execution of an Observable. A\n * Subscription has one important method, `unsubscribe`, that takes no argument\n * and just disposes the resource held by the subscription.\n *\n * Additionally, subscriptions may be grouped together through the `add()`\n * method, which will attach a child Subscription to the current Subscription.\n * When a Subscription is unsubscribed, all its children (and its grandchildren)\n * will be unsubscribed as well.\n */\nexport class Subscription implements SubscriptionLike {\n public static EMPTY = (() => {\n const empty = new Subscription();\n empty.closed = true;\n return empty;\n })();\n\n /**\n * A flag to indicate whether this Subscription has already been unsubscribed.\n */\n public closed = false;\n\n private _parentage: Subscription[] | Subscription | null = null;\n\n /**\n * The list of registered finalizers to execute upon unsubscription. Adding and removing from this\n * list occurs in the {@link #add} and {@link #remove} methods.\n */\n private _finalizers: Exclude<TeardownLogic, void>[] | null = null;\n\n /**\n * @param initialTeardown A function executed first as part of the finalization\n * process that is kicked off when {@link #unsubscribe} is called.\n */\n constructor(private initialTeardown?: () => void) {}\n\n /**\n * Disposes the resources held by the subscription. May, for instance, cancel\n * an ongoing Observable execution or cancel any other type of work that\n * started when the Subscription was created.\n */\n unsubscribe(): void {\n let errors: any[] | undefined;\n\n if (!this.closed) {\n this.closed = true;\n\n // Remove this from it's parents.\n const { _parentage } = this;\n if (_parentage) {\n this._parentage = null;\n if (Array.isArray(_parentage)) {\n for (const parent of _parentage) {\n parent.remove(this);\n }\n } else {\n _parentage.remove(this);\n }\n }\n\n const { initialTeardown: initialFinalizer } = this;\n if (isFunction(initialFinalizer)) {\n try {\n initialFinalizer();\n } catch (e) {\n errors = e instanceof UnsubscriptionError ? e.errors : [e];\n }\n }\n\n const { _finalizers } = this;\n if (_finalizers) {\n this._finalizers = null;\n for (const finalizer of _finalizers) {\n try {\n execFinalizer(finalizer);\n } catch (err) {\n errors = errors ?? [];\n if (err instanceof UnsubscriptionError) {\n errors = [...errors, ...err.errors];\n } else {\n errors.push(err);\n }\n }\n }\n }\n\n if (errors) {\n throw new UnsubscriptionError(errors);\n }\n }\n }\n\n /**\n * Adds a finalizer to this subscription, so that finalization will be unsubscribed/called\n * when this subscription is unsubscribed. If this subscription is already {@link #closed},\n * because it has already been unsubscribed, then whatever finalizer is passed to it\n * will automatically be executed (unless the finalizer itself is also a closed subscription).\n *\n * Closed Subscriptions cannot be added as finalizers to any subscription. Adding a closed\n * subscription to a any subscription will result in no operation. (A noop).\n *\n * Adding a subscription to itself, or adding `null` or `undefined` will not perform any\n * operation at all. (A noop).\n *\n * `Subscription` instances that are added to this instance will automatically remove themselves\n * if they are unsubscribed. Functions and {@link Unsubscribable} objects that you wish to remove\n * will need to be removed manually with {@link #remove}\n *\n * @param teardown The finalization logic to add to this subscription.\n */\n add(teardown: TeardownLogic): void {\n // Only add the finalizer if it's not undefined\n // and don't add a subscription to itself.\n if (teardown && teardown !== this) {\n if (this.closed) {\n // If this subscription is already closed,\n // execute whatever finalizer is handed to it automatically.\n execFinalizer(teardown);\n } else {\n if (teardown instanceof Subscription) {\n // We don't add closed subscriptions, and we don't add the same subscription\n // twice. Subscription unsubscribe is idempotent.\n if (teardown.closed || teardown._hasParent(this)) {\n return;\n }\n teardown._addParent(this);\n }\n (this._finalizers = this._finalizers ?? []).push(teardown);\n }\n }\n }\n\n /**\n * Checks to see if a this subscription already has a particular parent.\n * This will signal that this subscription has already been added to the parent in question.\n * @param parent the parent to check for\n */\n private _hasParent(parent: Subscription) {\n const { _parentage } = this;\n return _parentage === parent || (Array.isArray(_parentage) && _parentage.includes(parent));\n }\n\n /**\n * Adds a parent to this subscription so it can be removed from the parent if it\n * unsubscribes on it's own.\n *\n * NOTE: THIS ASSUMES THAT {@link _hasParent} HAS ALREADY BEEN CHECKED.\n * @param parent The parent subscription to add\n */\n private _addParent(parent: Subscription) {\n const { _parentage } = this;\n this._parentage = Array.isArray(_parentage) ? (_parentage.push(parent), _parentage) : _parentage ? [_parentage, parent] : parent;\n }\n\n /**\n * Called on a child when it is removed via {@link #remove}.\n * @param parent The parent to remove\n */\n private _removeParent(parent: Subscription) {\n const { _parentage } = this;\n if (_parentage === parent) {\n this._parentage = null;\n } else if (Array.isArray(_parentage)) {\n arrRemove(_parentage, parent);\n }\n }\n\n /**\n * Removes a finalizer from this subscription that was previously added with the {@link #add} method.\n *\n * Note that `Subscription` instances, when unsubscribed, will automatically remove themselves\n * from every other `Subscription` they have been added to. This means that using the `remove` method\n * is not a common thing and should be used thoughtfully.\n *\n * If you add the same finalizer instance of a function or an unsubscribable object to a `Subscription` instance\n * more than once, you will need to call `remove` the same number of times to remove all instances.\n *\n * All finalizer instances are removed to free up memory upon unsubscription.\n *\n * @param teardown The finalizer to remove from this subscription\n */\n remove(teardown: Exclude<TeardownLogic, void>): void {\n const { _finalizers } = this;\n _finalizers && arrRemove(_finalizers, teardown);\n\n if (teardown instanceof Subscription) {\n teardown._removeParent(this);\n }\n }\n}\n\nexport const EMPTY_SUBSCRIPTION = Subscription.EMPTY;\n\nexport function isSubscription(value: any): value is Subscription {\n return (\n value instanceof Subscription ||\n (value && 'closed' in value && isFunction(value.remove) && isFunction(value.add) && isFunction(value.unsubscribe))\n );\n}\n\nfunction execFinalizer(finalizer: Unsubscribable | (() => void)) {\n if (isFunction(finalizer)) {\n finalizer();\n } else {\n finalizer.unsubscribe();\n }\n}\n", "import { Subscriber } from './Subscriber';\nimport { ObservableNotification } from './types';\n\n/**\n * The {@link GlobalConfig} object for RxJS. It is used to configure things\n * like how to react on unhandled errors.\n */\nexport const config: GlobalConfig = {\n onUnhandledError: null,\n onStoppedNotification: null,\n Promise: undefined,\n useDeprecatedSynchronousErrorHandling: false,\n useDeprecatedNextContext: false,\n};\n\n/**\n * The global configuration object for RxJS, used to configure things\n * like how to react on unhandled errors. Accessible via {@link config}\n * object.\n */\nexport interface GlobalConfig {\n /**\n * A registration point for unhandled errors from RxJS. These are errors that\n * cannot were not handled by consuming code in the usual subscription path. For\n * example, if you have this configured, and you subscribe to an observable without\n * providing an error handler, errors from that subscription will end up here. This\n * will _always_ be called asynchronously on another job in the runtime. This is because\n * we do not want errors thrown in this user-configured handler to interfere with the\n * behavior of the library.\n */\n onUnhandledError: ((err: any) => void) | null;\n\n /**\n * A registration point for notifications that cannot be sent to subscribers because they\n * have completed, errored or have been explicitly unsubscribed. By default, next, complete\n * and error notifications sent to stopped subscribers are noops. However, sometimes callers\n * might want a different behavior. For example, with sources that attempt to report errors\n * to stopped subscribers, a caller can configure RxJS to throw an unhandled error instead.\n * This will _always_ be called asynchronously on another job in the runtime. This is because\n * we do not want errors thrown in this user-configured handler to interfere with the\n * behavior of the library.\n */\n onStoppedNotification: ((notification: ObservableNotification<any>, subscriber: Subscriber<any>) => void) | null;\n\n /**\n * The promise constructor used by default for {@link Observable#toPromise toPromise} and {@link Observable#forEach forEach}\n * methods.\n *\n * @deprecated As of version 8, RxJS will no longer support this sort of injection of a\n * Promise constructor. If you need a Promise implementation other than native promises,\n * please polyfill/patch Promise as you see appropriate. Will be removed in v8.\n */\n Promise?: PromiseConstructorLike;\n\n /**\n * If true, turns on synchronous error rethrowing, which is a deprecated behavior\n * in v6 and higher. This behavior enables bad patterns like wrapping a subscribe\n * call in a try/catch block. It also enables producer interference, a nasty bug\n * where a multicast can be broken for all observers by a downstream consumer with\n * an unhandled error. DO NOT USE THIS FLAG UNLESS IT'S NEEDED TO BUY TIME\n * FOR MIGRATION REASONS.\n *\n * @deprecated As of version 8, RxJS will no longer support synchronous throwing\n * of unhandled errors. All errors will be thrown on a separate call stack to prevent bad\n * behaviors described above. Will be removed in v8.\n */\n useDeprecatedSynchronousErrorHandling: boolean;\n\n /**\n * If true, enables an as-of-yet undocumented feature from v5: The ability to access\n * `unsubscribe()` via `this` context in `next` functions created in observers passed\n * to `subscribe`.\n *\n * This is being removed because the performance was severely problematic, and it could also cause\n * issues when types other than POJOs are passed to subscribe as subscribers, as they will likely have\n * their `this` context overwritten.\n *\n * @deprecated As of version 8, RxJS will no longer support altering the\n * context of next functions provided as part of an observer to Subscribe. Instead,\n * you will have access to a subscription or a signal or token that will allow you to do things like\n * unsubscribe and test closed status. Will be removed in v8.\n */\n useDeprecatedNextContext: boolean;\n}\n", "import type { TimerHandle } from './timerHandle';\ntype SetTimeoutFunction = (handler: () => void, timeout?: number, ...args: any[]) => TimerHandle;\ntype ClearTimeoutFunction = (handle: TimerHandle) => void;\n\ninterface TimeoutProvider {\n setTimeout: SetTimeoutFunction;\n clearTimeout: ClearTimeoutFunction;\n delegate:\n | {\n setTimeout: SetTimeoutFunction;\n clearTimeout: ClearTimeoutFunction;\n }\n | undefined;\n}\n\nexport const timeoutProvider: TimeoutProvider = {\n // When accessing the delegate, use the variable rather than `this` so that\n // the functions can be called without being bound to the provider.\n setTimeout(handler: () => void, timeout?: number, ...args) {\n const { delegate } = timeoutProvider;\n if (delegate?.setTimeout) {\n return delegate.setTimeout(handler, timeout, ...args);\n }\n return setTimeout(handler, timeout, ...args);\n },\n clearTimeout(handle) {\n const { delegate } = timeoutProvider;\n return (delegate?.clearTimeout || clearTimeout)(handle as any);\n },\n delegate: undefined,\n};\n", "import { config } from '../config';\nimport { timeoutProvider } from '../scheduler/timeoutProvider';\n\n/**\n * Handles an error on another job either with the user-configured {@link onUnhandledError},\n * or by throwing it on that new job so it can be picked up by `window.onerror`, `process.on('error')`, etc.\n *\n * This should be called whenever there is an error that is out-of-band with the subscription\n * or when an error hits a terminal boundary of the subscription and no error handler was provided.\n *\n * @param err the error to report\n */\nexport function reportUnhandledError(err: any) {\n timeoutProvider.setTimeout(() => {\n const { onUnhandledError } = config;\n if (onUnhandledError) {\n // Execute the user-configured error handler.\n onUnhandledError(err);\n } else {\n // Throw so it is picked up by the runtime's uncaught error mechanism.\n throw err;\n }\n });\n}\n", "/* tslint:disable:no-empty */\nexport function noop() { }\n", "import { CompleteNotification, NextNotification, ErrorNotification } from './types';\n\n/**\n * A completion object optimized for memory use and created to be the\n * same \"shape\" as other notifications in v8.\n * @internal\n */\nexport const COMPLETE_NOTIFICATION = (() => createNotification('C', undefined, undefined) as CompleteNotification)();\n\n/**\n * Internal use only. Creates an optimized error notification that is the same \"shape\"\n * as other notifications.\n * @internal\n */\nexport function errorNotification(error: any): ErrorNotification {\n return createNotification('E', undefined, error) as any;\n}\n\n/**\n * Internal use only. Creates an optimized next notification that is the same \"shape\"\n * as other notifications.\n * @internal\n */\nexport function nextNotification<T>(value: T) {\n return createNotification('N', value, undefined) as NextNotification<T>;\n}\n\n/**\n * Ensures that all notifications created internally have the same \"shape\" in v8.\n *\n * TODO: This is only exported to support a crazy legacy test in `groupBy`.\n * @internal\n */\nexport function createNotification(kind: 'N' | 'E' | 'C', value: any, error: any) {\n return {\n kind,\n value,\n error,\n };\n}\n", "import { config } from '../config';\n\nlet context: { errorThrown: boolean; error: any } | null = null;\n\n/**\n * Handles dealing with errors for super-gross mode. Creates a context, in which\n * any synchronously thrown errors will be passed to {@link captureError}. Which\n * will record the error such that it will be rethrown after the call back is complete.\n * TODO: Remove in v8\n * @param cb An immediately executed function.\n */\nexport function errorContext(cb: () => void) {\n if (config.useDeprecatedSynchronousErrorHandling) {\n const isRoot = !context;\n if (isRoot) {\n context = { errorThrown: false, error: null };\n }\n cb();\n if (isRoot) {\n const { errorThrown, error } = context!;\n context = null;\n if (errorThrown) {\n throw error;\n }\n }\n } else {\n // This is the general non-deprecated path for everyone that\n // isn't crazy enough to use super-gross mode (useDeprecatedSynchronousErrorHandling)\n cb();\n }\n}\n\n/**\n * Captures errors only in super-gross mode.\n * @param err the error to capture\n */\nexport function captureError(err: any) {\n if (config.useDeprecatedSynchronousErrorHandling && context) {\n context.errorThrown = true;\n context.error = err;\n }\n}\n", "import { isFunction } from './util/isFunction';\nimport { Observer, ObservableNotification } from './types';\nimport { isSubscription, Subscription } from './Subscription';\nimport { config } from './config';\nimport { reportUnhandledError } from './util/reportUnhandledError';\nimport { noop } from './util/noop';\nimport { nextNotification, errorNotification, COMPLETE_NOTIFICATION } from './NotificationFactories';\nimport { timeoutProvider } from './scheduler/timeoutProvider';\nimport { captureError } from './util/errorContext';\n\n/**\n * Implements the {@link Observer} interface and extends the\n * {@link Subscription} class. While the {@link Observer} is the public API for\n * consuming the values of an {@link Observable}, all Observers get converted to\n * a Subscriber, in order to provide Subscription-like capabilities such as\n * `unsubscribe`. Subscriber is a common type in RxJS, and crucial for\n * implementing operators, but it is rarely used as a public API.\n */\nexport class Subscriber<T> extends Subscription implements Observer<T> {\n /**\n * A static factory for a Subscriber, given a (potentially partial) definition\n * of an Observer.\n * @param next The `next` callback of an Observer.\n * @param error The `error` callback of an\n * Observer.\n * @param complete The `complete` callback of an\n * Observer.\n * @return A Subscriber wrapping the (partially defined)\n * Observer represented by the given arguments.\n * @deprecated Do not use. Will be removed in v8. There is no replacement for this\n * method, and there is no reason to be creating instances of `Subscriber` directly.\n * If you have a specific use case, please file an issue.\n */\n static create<T>(next?: (x?: T) => void, error?: (e?: any) => void, complete?: () => void): Subscriber<T> {\n return new SafeSubscriber(next, error, complete);\n }\n\n /** @deprecated Internal implementation detail, do not use directly. Will be made internal in v8. */\n protected isStopped: boolean = false;\n /** @deprecated Internal implementation detail, do not use directly. Will be made internal in v8. */\n protected destination: Subscriber<any> | Observer<any>; // this `any` is the escape hatch to erase extra type param (e.g. R)\n\n /**\n * @deprecated Internal implementation detail, do not use directly. Will be made internal in v8.\n * There is no reason to directly create an instance of Subscriber. This type is exported for typings reasons.\n */\n constructor(destination?: Subscriber<any> | Observer<any>) {\n super();\n if (destination) {\n this.destination = destination;\n // Automatically chain subscriptions together here.\n // if destination is a Subscription, then it is a Subscriber.\n if (isSubscription(destination)) {\n destination.add(this);\n }\n } else {\n this.destination = EMPTY_OBSERVER;\n }\n }\n\n /**\n * The {@link Observer} callback to receive notifications of type `next` from\n * the Observable, with a value. The Observable may call this method 0 or more\n * times.\n * @param value The `next` value.\n */\n next(value: T): void {\n if (this.isStopped) {\n handleStoppedNotification(nextNotification(value), this);\n } else {\n this._next(value!);\n }\n }\n\n /**\n * The {@link Observer} callback to receive notifications of type `error` from\n * the Observable, with an attached `Error`. Notifies the Observer that\n * the Observable has experienced an error condition.\n * @param err The `error` exception.\n */\n error(err?: any): void {\n if (this.isStopped) {\n handleStoppedNotification(errorNotification(err), this);\n } else {\n this.isStopped = true;\n this._error(err);\n }\n }\n\n /**\n * The {@link Observer} callback to receive a valueless notification of type\n * `complete` from the Observable. Notifies the Observer that the Observable\n * has finished sending push-based notifications.\n */\n complete(): void {\n if (this.isStopped) {\n handleStoppedNotification(COMPLETE_NOTIFICATION, this);\n } else {\n this.isStopped = true;\n this._complete();\n }\n }\n\n unsubscribe(): void {\n if (!this.closed) {\n this.isStopped = true;\n super.unsubscribe();\n this.destination = null!;\n }\n }\n\n protected _next(value: T): void {\n this.destination.next(value);\n }\n\n protected _error(err: any): void {\n try {\n this.destination.error(err);\n } finally {\n this.unsubscribe();\n }\n }\n\n protected _complete(): void {\n try {\n this.destination.complete();\n } finally {\n this.unsubscribe();\n }\n }\n}\n\n/**\n * This bind is captured here because we want to be able to have\n * compatibility with monoid libraries that tend to use a method named\n * `bind`. In particular, a library called Monio requires this.\n */\nconst _bind = Function.prototype.bind;\n\nfunction bind<Fn extends (...args: any[]) => any>(fn: Fn, thisArg: any): Fn {\n return _bind.call(fn, thisArg);\n}\n\n/**\n * Internal optimization only, DO NOT EXPOSE.\n * @internal\n */\nclass ConsumerObserver<T> implements Observer<T> {\n constructor(private partialObserver: Partial<Observer<T>>) {}\n\n next(value: T): void {\n const { partialObserver } = this;\n if (partialObserver.next) {\n try {\n partialObserver.next(value);\n } catch (error) {\n handleUnhandledError(error);\n }\n }\n }\n\n error(err: any): void {\n const { partialObserver } = this;\n if (partialObserver.error) {\n try {\n partialObserver.error(err);\n } catch (error) {\n handleUnhandledError(error);\n }\n } else {\n handleUnhandledError(err);\n }\n }\n\n complete(): void {\n const { partialObserver } = this;\n if (partialObserver.complete) {\n try {\n partialObserver.complete();\n } catch (error) {\n handleUnhandledError(error);\n }\n }\n }\n}\n\nexport class SafeSubscriber<T> extends Subscriber<T> {\n constructor(\n observerOrNext?: Partial<Observer<T>> | ((value: T) => void) | null,\n error?: ((e?: any) => void) | null,\n complete?: (() => void) | null\n ) {\n super();\n\n let partialObserver: Partial<Observer<T>>;\n if (isFunction(observerOrNext) || !observerOrNext) {\n // The first argument is a function, not an observer. The next\n // two arguments *could* be observers, or they could be empty.\n partialObserver = {\n next: (observerOrNext ?? undefined) as ((value: T) => void) | undefined,\n error: error ?? undefined,\n complete: complete ?? undefined,\n };\n } else {\n // The first argument is a partial observer.\n let context: any;\n if (this && config.useDeprecatedNextContext) {\n // This is a deprecated path that made `this.unsubscribe()` available in\n // next handler functions passed to subscribe. This only exists behind a flag\n // now, as it is *very* slow.\n context = Object.create(observerOrNext);\n context.unsubscribe = () => this.unsubscribe();\n partialObserver = {\n next: observerOrNext.next && bind(observerOrNext.next, context),\n error: observerOrNext.error && bind(observerOrNext.error, context),\n complete: observerOrNext.complete && bind(observerOrNext.complete, context),\n };\n } else {\n // The \"normal\" path. Just use the partial observer directly.\n partialObserver = observerOrNext;\n }\n }\n\n // Wrap the partial observer to ensure it's a full observer, and\n // make sure proper error handling is accounted for.\n this.destination = new ConsumerObserver(partialObserver);\n }\n}\n\nfunction handleUnhandledError(error: any) {\n if (config.useDeprecatedSynchronousErrorHandling) {\n captureError(error);\n } else {\n // Ideal path, we report this as an unhandled error,\n // which is thrown on a new call stack.\n reportUnhandledError(error);\n }\n}\n\n/**\n * An error handler used when no error handler was supplied\n * to the SafeSubscriber -- meaning no error handler was supplied\n * do the `subscribe` call on our observable.\n * @param err The error to handle\n */\nfunction defaultErrorHandler(err: any) {\n throw err;\n}\n\n/**\n * A handler for notifications that cannot be sent to a stopped subscriber.\n * @param notification The notification being sent.\n * @param subscriber The stopped subscriber.\n */\nfunction handleStoppedNotification(notification: ObservableNotification<any>, subscriber: Subscriber<any>) {\n const { onStoppedNotification } = config;\n onStoppedNotification && timeoutProvider.setTimeout(() => onStoppedNotification(notification, subscriber));\n}\n\n/**\n * The observer used as a stub for subscriptions where the user did not\n * pass any arguments to `subscribe`. Comes with the default error handling\n * behavior.\n */\nexport const EMPTY_OBSERVER: Readonly<Observer<any>> & { closed: true } = {\n closed: true,\n next: noop,\n error: defaultErrorHandler,\n complete: noop,\n};\n", "/**\n * Symbol.observable or a string \"@@observable\". Used for interop\n *\n * @deprecated We will no longer be exporting this symbol in upcoming versions of RxJS.\n * Instead polyfill and use Symbol.observable directly *or* use https://www.npmjs.com/package/symbol-observable\n */\nexport const observable: string | symbol = (() => (typeof Symbol === 'function' && Symbol.observable) || '@@observable')();\n", "/**\n * This function takes one parameter and just returns it. Simply put,\n * this is like `<T>(x: T): T => x`.\n *\n * ## Examples\n *\n * This is useful in some cases when using things like `mergeMap`\n *\n * ```ts\n * import { interval, take, map, range, mergeMap, identity } from 'rxjs';\n *\n * const source$ = interval(1000).pipe(take(5));\n *\n * const result$ = source$.pipe(\n * map(i => range(i)),\n * mergeMap(identity) // same as mergeMap(x => x)\n * );\n *\n * result$.subscribe({\n * next: console.log\n * });\n * ```\n *\n * Or when you want to selectively apply an operator\n *\n * ```ts\n * import { interval, take, identity } from 'rxjs';\n *\n * const shouldLimit = () => Math.random() < 0.5;\n *\n * const source$ = interval(1000);\n *\n * const result$ = source$.pipe(shouldLimit() ? take(5) : identity);\n *\n * result$.subscribe({\n * next: console.log\n * });\n * ```\n *\n * @param x Any value that is returned by this function\n * @returns The value passed as the first parameter to this function\n */\nexport function identity<T>(x: T): T {\n return x;\n}\n", "import { identity } from './identity';\nimport { UnaryFunction } from '../types';\n\nexport function pipe(): typeof identity;\nexport function pipe<T, A>(fn1: UnaryFunction<T, A>): UnaryFunction<T, A>;\nexport function pipe<T, A, B>(fn1: UnaryFunction<T, A>, fn2: UnaryFunction<A, B>): UnaryFunction<T, B>;\nexport function pipe<T, A, B, C>(fn1: UnaryFunction<T, A>, fn2: UnaryFunction<A, B>, fn3: UnaryFunction<B, C>): UnaryFunction<T, C>;\nexport function pipe<T, A, B, C, D>(\n fn1: UnaryFunction<T, A>,\n fn2: UnaryFunction<A, B>,\n fn3: UnaryFunction<B, C>,\n fn4: UnaryFunction<C, D>\n): UnaryFunction<T, D>;\nexport function pipe<T, A, B, C, D, E>(\n fn1: UnaryFunction<T, A>,\n fn2: UnaryFunction<A, B>,\n fn3: UnaryFunction<B, C>,\n fn4: UnaryFunction<C, D>,\n fn5: UnaryFunction<D, E>\n): UnaryFunction<T, E>;\nexport function pipe<T, A, B, C, D, E, F>(\n fn1: UnaryFunction<T, A>,\n fn2: UnaryFunction<A, B>,\n fn3: UnaryFunction<B, C>,\n fn4: UnaryFunction<C, D>,\n fn5: UnaryFunction<D, E>,\n fn6: UnaryFunction<E, F>\n): UnaryFunction<T, F>;\nexport function pipe<T, A, B, C, D, E, F, G>(\n fn1: UnaryFunction<T, A>,\n fn2: UnaryFunction<A, B>,\n fn3: UnaryFunction<B, C>,\n fn4: UnaryFunction<C, D>,\n fn5: UnaryFunction<D, E>,\n fn6: UnaryFunction<E, F>,\n fn7: UnaryFunction<F, G>\n): UnaryFunction<T, G>;\nexport function pipe<T, A, B, C, D, E, F, G, H>(\n fn1: UnaryFunction<T, A>,\n fn2: UnaryFunction<A, B>,\n fn3: UnaryFunction<B, C>,\n fn4: UnaryFunction<C, D>,\n fn5: UnaryFunction<D, E>,\n fn6: UnaryFunction<E, F>,\n fn7: UnaryFunction<F, G>,\n fn8: UnaryFunction<G, H>\n): UnaryFunction<T, H>;\nexport function pipe<T, A, B, C, D, E, F, G, H, I>(\n fn1: UnaryFunction<T, A>,\n fn2: UnaryFunction<A, B>,\n fn3: UnaryFunction<B, C>,\n fn4: UnaryFunction<C, D>,\n fn5: UnaryFunction<D, E>,\n fn6: UnaryFunction<E, F>,\n fn7: UnaryFunction<F, G>,\n fn8: UnaryFunction<G, H>,\n fn9: UnaryFunction<H, I>\n): UnaryFunction<T, I>;\nexport function pipe<T, A, B, C, D, E, F, G, H, I>(\n fn1: UnaryFunction<T, A>,\n fn2: UnaryFunction<A, B>,\n fn3: UnaryFunction<B, C>,\n fn4: UnaryFunction<C, D>,\n fn5: UnaryFunction<D, E>,\n fn6: UnaryFunction<E, F>,\n fn7: UnaryFunction<F, G>,\n fn8: UnaryFunction<G, H>,\n fn9: UnaryFunction<H, I>,\n ...fns: UnaryFunction<any, any>[]\n): UnaryFunction<T, unknown>;\n\n/**\n * pipe() can be called on one or more functions, each of which can take one argument (\"UnaryFunction\")\n * and uses it to return a value.\n * It returns a function that takes one argument, passes it to the first UnaryFunction, and then\n * passes the result to the next one, passes that result to the next one, and so on. \n */\nexport function pipe(...fns: Array<UnaryFunction<any, any>>): UnaryFunction<any, any> {\n return pipeFromArray(fns);\n}\n\n/** @internal */\nexport function pipeFromArray<T, R>(fns: Array<UnaryFunction<T, R>>): UnaryFunction<T, R> {\n if (fns.length === 0) {\n return identity as UnaryFunction<any, any>;\n }\n\n if (fns.length === 1) {\n return fns[0];\n }\n\n return function piped(input: T): R {\n return fns.reduce((prev: any, fn: UnaryFunction<T, R>) => fn(prev), input as any);\n };\n}\n", "import { Operator } from './Operator';\nimport { SafeSubscriber, Subscriber } from './Subscriber';\nimport { isSubscription, Subscription } from './Subscription';\nimport { TeardownLogic, OperatorFunction, Subscribable, Observer } from './types';\nimport { observable as Symbol_observable } from './symbol/observable';\nimport { pipeFromArray } from './util/pipe';\nimport { config } from './config';\nimport { isFunction } from './util/isFunction';\nimport { errorContext } from './util/errorContext';\n\n/**\n * A representation of any set of values over any amount of time. This is the most basic building block\n * of RxJS.\n */\nexport class Observable<T> implements Subscribable<T> {\n /**\n * @deprecated Internal implementation detail, do not use directly. Will be made internal in v8.\n */\n source: Observable<any> | undefined;\n\n /**\n * @deprecated Internal implementation detail, do not use directly. Will be made internal in v8.\n */\n operator: Operator<any, T> | undefined;\n\n /**\n * @param subscribe The function that is called when the Observable is\n * initially subscribed to. This function is given a Subscriber, to which new values\n * can be `next`ed, or an `error` method can be called to raise an error, or\n * `complete` can be called to notify of a successful completion.\n */\n constructor(subscribe?: (this: Observable<T>, subscriber: Subscriber<T>) => TeardownLogic) {\n if (subscribe) {\n this._subscribe = subscribe;\n }\n }\n\n // HACK: Since TypeScript inherits static properties too, we have to\n // fight against TypeScript here so Subject can have a different static create signature\n /**\n * Creates a new Observable by calling the Observable constructor\n * @param subscribe the subscriber function to be passed to the Observable constructor\n * @return A new observable.\n * @deprecated Use `new Observable()` instead. Will be removed in v8.\n */\n static create: (...args: any[]) => any = <T>(subscribe?: (subscriber: Subscriber<T>) => TeardownLogic) => {\n return new Observable<T>(subscribe);\n };\n\n /**\n * Creates a new Observable, with this Observable instance as the source, and the passed\n * operator defined as the new observable's operator.\n * @param operator the operator defining the operation to take on the observable\n * @return A new observable with the Operator applied.\n * @deprecated Internal implementation detail, do not use directly. Will be made internal in v8.\n * If you have implemented an operator using `lift`, it is recommended that you create an\n * operator by simply returning `new Observable()` directly. See \"Creating new operators from\n * scratch\" section here: https://rxjs.dev/guide/operators\n */\n lift<R>(operator?: Operator<T, R>): Observable<R> {\n const observable = new Observable<R>();\n observable.source = this;\n observable.operator = operator;\n return observable;\n }\n\n subscribe(observerOrNext?: Partial<Observer<T>> | ((value: T) => void)): Subscription;\n /** @deprecated Instead of passing separate callback arguments, use an observer argument. Signatures taking separate callback arguments will be removed in v8. Details: https://rxjs.dev/deprecations/subscribe-arguments */\n subscribe(next?: ((value: T) => void) | null, error?: ((error: any) => void) | null, complete?: (() => void) | null): Subscription;\n /**\n * Invokes an execution of an Observable and registers Observer handlers for notifications it will emit.\n *\n * <span class=\"informal\">Use it when you have all these Observables, but still nothing is happening.</span>\n *\n * `subscribe` is not a regular operator, but a method that calls Observable's internal `subscribe` function. It\n * might be for example a function that you passed to Observable's constructor, but most of the time it is\n * a library implementation, which defines what will be emitted by an Observable, and when it be will emitted. This means\n * that calling `subscribe` is actually the moment when Observable starts its work, not when it is created, as it is often\n * the thought.\n *\n * Apart from starting the execution of an Observable, this method allows you to listen for values\n * that an Observable emits, as well as for when it completes or errors. You can achieve this in two\n * of the following ways.\n *\n * The first way is creating an object that implements {@link Observer} interface. It should have methods\n * defined by that interface, but note that it should be just a regular JavaScript object, which you can create\n * yourself in any way you want (ES6 class, classic function constructor, object literal etc.). In particular, do\n * not attempt to use any RxJS implementation details to create Observers - you don't need them. Remember also\n * that your object does not have to implement all methods. If you find yourself creating a method that doesn't\n * do anything, you can simply omit it. Note however, if the `error` method is not provided and an error happens,\n * it will be thrown asynchronously. Errors thrown asynchronously cannot be caught using `try`/`catch`. Instead,\n * use the {@link onUnhandledError} configuration option or use a runtime handler (like `window.onerror` or\n * `process.on('error)`) to be notified of unhandled errors. Because of this, it's recommended that you provide\n * an `error` method to avoid missing thrown errors.\n *\n * The second way is to give up on Observer object altogether and simply provide callback functions in place of its methods.\n * This means you can provide three functions as arguments to `subscribe`, where the first function is equivalent\n * of a `next` method, the second of an `error` method and the third of a `complete` method. Just as in case of an Observer,\n * if you do not need to listen for something, you can omit a function by passing `undefined` or `null`,\n * since `subscribe` recognizes these functions by where they were placed in function call. When it comes\n * to the `error` function, as with an Observer, if not provided, errors emitted by an Observable will be thrown asynchronously.\n *\n * You can, however, subscribe with no parameters at all. This may be the case where you're not interested in terminal events\n * and you also handled emissions internally by using operators (e.g. using `tap`).\n *\n * Whichever style of calling `subscribe` you use, in both cases it returns a Subscription object.\n * This object allows you to call `unsubscribe` on it, which in turn will stop the work that an Observable does and will clean\n * up all resources that an Observable used. Note that cancelling a subscription will not call `complete` callback\n * provided to `subscribe` function, which is reserved for a regular completion signal that comes from an Observable.\n *\n * Remember that callbacks provided to `subscribe` are not guaranteed to be called asynchronously.\n * It is an Observable itself that decides when these functions will be called. For example {@link of}\n * by default emits all its values synchronously. Always check documentation for how given Observable\n * will behave when subscribed and if its default behavior can be modified with a `scheduler`.\n *\n * #### Examples\n *\n * Subscribe with an {@link guide/observer Observer}\n *\n * ```ts\n * import { of } from 'rxjs';\n *\n * const sumObserver = {\n * sum: 0,\n * next(value) {\n * console.log('Adding: ' + value);\n * this.sum = this.sum + value;\n * },\n * error() {\n * // We actually could just remove this method,\n * // since we do not really care about errors right now.\n * },\n * complete() {\n * console.log('Sum equals: ' + this.sum);\n * }\n * };\n *\n * of(1, 2, 3) // Synchronously emits 1, 2, 3 and then completes.\n * .subscribe(sumObserver);\n *\n * // Logs:\n * // 'Adding: 1'\n * // 'Adding: 2'\n * // 'Adding: 3'\n * // 'Sum equals: 6'\n * ```\n *\n * Subscribe with functions ({@link deprecations/subscribe-arguments deprecated})\n *\n * ```ts\n * import { of } from 'rxjs'\n *\n * let sum = 0;\n *\n * of(1, 2, 3).subscribe(\n * value => {\n * console.log('Adding: ' + value);\n * sum = sum + value;\n * },\n * undefined,\n * () => console.log('Sum equals: ' + sum)\n * );\n *\n * // Logs:\n * // 'Adding: 1'\n * // 'Adding: 2'\n * // 'Adding: 3'\n * // 'Sum equals: 6'\n * ```\n *\n * Cancel a subscription\n *\n * ```ts\n * import { interval } from 'rxjs';\n *\n * const subscription = interval(1000).subscribe({\n * next(num) {\n * console.log(num)\n * },\n * complete() {\n * // Will not be called, even when cancelling subscription.\n * console.log('completed!');\n * }\n * });\n *\n * setTimeout(() => {\n * subscription.unsubscribe();\n * console.log('unsubscribed!');\n * }, 2500);\n *\n * // Logs:\n * // 0 after 1s\n * // 1 after 2s\n * // 'unsubscribed!' after 2.5s\n * ```\n *\n * @param observerOrNext Either an {@link Observer} with some or all callback methods,\n * or the `next` handler that is called for each value emitted from the subscribed Observable.\n * @param error A handler for a terminal event resulting from an error. If no error handler is provided,\n * the error will be thrown asynchronously as unhandled.\n * @param complete A handler for a terminal event resulting from successful completion.\n * @return A subscription reference to the registered handlers.\n */\n subscribe(\n observerOrNext?: Partial<Observer<T>> | ((value: T) => void) | null,\n error?: ((error: any) => void) | null,\n complete?: (() => void) | null\n ): Subscription {\n const subscriber = isSubscriber(observerOrNext) ? observerOrNext : new SafeSubscriber(observerOrNext, error, complete);\n\n errorContext(() => {\n const { operator, source } = this;\n subscriber.add(\n operator\n ? // We're dealing with a subscription in the\n // operator chain to one of our lifted operators.\n operator.call(subscriber, source)\n : source\n ? // If `source` has a value, but `operator` does not, something that\n // had intimate knowledge of our API, like our `Subject`, must have\n // set it. We're going to just call `_subscribe` directly.\n this._subscribe(subscriber)\n : // In all other cases, we're likely wrapping a user-provided initializer\n // function, so we need to catch errors and handle them appropriately.\n this._trySubscribe(subscriber)\n );\n });\n\n return subscriber;\n }\n\n /** @internal */\n protected _trySubscribe(sink: Subscriber<T>): TeardownLogic {\n try {\n return this._subscribe(sink);\n } catch (err) {\n // We don't need to return anything in this case,\n // because it's just going to try to `add()` to a subscription\n // above.\n sink.error(err);\n }\n }\n\n /**\n * Used as a NON-CANCELLABLE means of subscribing to an observable, for use with\n * APIs that expect promises, like `async/await`. You cannot unsubscribe from this.\n *\n * **WARNING**: Only use this with observables you *know* will complete. If the source\n * observable does not complete, you will end up with a promise that is hung up, and\n * potentially all of the state of an async function hanging out in memory. To avoid\n * this situation, look into adding something like {@link timeout}, {@link take},\n * {@link takeWhile}, or {@link takeUntil} amongst others.\n *\n * #### Example\n *\n * ```ts\n * import { interval, take } from 'rxjs';\n *\n * const source$ = interval(1000).pipe(take(4));\n *\n * async function getTotal() {\n * let total = 0;\n *\n * await source$.forEach(value => {\n * total += value;\n * console.log('observable -> ' + value);\n * });\n *\n * return total;\n * }\n *\n * getTotal().then(\n * total => console.log('Total: ' + total)\n * );\n *\n * // Expected:\n * // 'observable -> 0'\n * // 'observable -> 1'\n * // 'observable -> 2'\n * // 'observable -> 3'\n * // 'Total: 6'\n * ```\n *\n * @param next A handler for each value emitted by the observable.\n * @return A promise that either resolves on observable completion or\n * rejects with the handled error.\n */\n forEach(next: (value: T) => void): Promise<void>;\n\n /**\n * @param next a handler for each value emitted by the observable\n * @param promiseCtor a constructor function used to instantiate the Promise\n * @return a promise that either resolves on observable completion or\n * rejects with the handled error\n * @deprecated Passing a Promise constructor will no longer be available\n * in upcoming versions of RxJS. This is because it adds weight to the library, for very\n * little benefit. If you need this functionality, it is recommended that you either\n * polyfill Promise, or you create an adapter to convert the returned native promise\n * to whatever promise implementation you wanted. Will be removed in v8.\n */\n forEach(next: (value: T) => void, promiseCtor: PromiseConstructorLike): Promise<void>;\n\n forEach(next: (value: T) => void, promiseCtor?: PromiseConstructorLike): Promise<void> {\n promiseCtor = getPromiseCtor(promiseCtor);\n\n return new promiseCtor<void>((resolve, reject) => {\n const subscriber = new SafeSubscriber<T>({\n next: (value) => {\n try {\n next(value);\n } catch (err) {\n reject(err);\n subscriber.unsubscribe();\n }\n },\n error: reject,\n complete: resolve,\n });\n this.subscribe(subscriber);\n }) as Promise<void>;\n }\n\n /** @internal */\n protected _subscribe(subscriber: Subscriber<any>): TeardownLogic {\n return this.source?.subscribe(subscriber);\n }\n\n /**\n * An interop point defined by the es7-observable spec https://github.com/zenparsing/es-observable\n * @return This instance of the observable.\n */\n [Symbol_observable]() {\n return this;\n }\n\n /* tslint:disable:max-line-length */\n pipe(): Observable<T>;\n pipe<A>(op1: OperatorFunction<T, A>): Observable<A>;\n pipe<A, B>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>): Observable<B>;\n pipe<A, B, C>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>): Observable<C>;\n pipe<A, B, C, D>(\n op1: OperatorFunction<T, A>,\n op2: OperatorFunction<A, B>,\n op3: OperatorFunction<B, C>,\n op4: OperatorFunction<C, D>\n ): Observable<D>;\n pipe<A, B, C, D, E>(\n op1: OperatorFunction<T, A>,\n op2: OperatorFunction<A, B>,\n op3: OperatorFunction<B, C>,\n op4: OperatorFunction<C, D>,\n op5: OperatorFunction<D, E>\n ): Observable<E>;\n pipe<A, B, C, D, E, F>(\n op1: OperatorFunction<T, A>,\n op2: OperatorFunction<A, B>,\n op3: OperatorFunction<B, C>,\n op4: OperatorFunction<C, D>,\n op5: OperatorFunction<D, E>,\n op6: OperatorFunction<E, F>\n ): Observable<F>;\n pipe<A, B, C, D, E, F, G>(\n op1: OperatorFunction<T, A>,\n op2: OperatorFunction<A, B>,\n op3: OperatorFunction<B, C>,\n op4: OperatorFunction<C, D>,\n op5: OperatorFunction<D, E>,\n op6: OperatorFunction<E, F>,\n op7: OperatorFunction<F, G>\n ): Observable<G>;\n pipe<A, B, C, D, E, F, G, H>(\n op1: OperatorFunction<T, A>,\n op2: OperatorFunction<A, B>,\n op3: OperatorFunction<B, C>,\n op4: OperatorFunction<C, D>,\n op5: OperatorFunction<D, E>,\n op6: OperatorFunction<E, F>,\n op7: OperatorFunction<F, G>,\n op8: OperatorFunction<G, H>\n ): Observable<H>;\n pipe<A, B, C, D, E, F, G, H, I>(\n op1: OperatorFunction<T, A>,\n op2: OperatorFunction<A, B>,\n op3: OperatorFunction<B, C>,\n op4: OperatorFunction<C, D>,\n op5: OperatorFunction<D, E>,\n op6: OperatorFunction<E, F>,\n op7: OperatorFunction<F, G>,\n op8: OperatorFunction<G, H>,\n op9: OperatorFunction<H, I>\n ): Observable<I>;\n pipe<A, B, C, D, E, F, G, H, I>(\n op1: OperatorFunction<T, A>,\n op2: OperatorFunction<A, B>,\n op3: OperatorFunction<B, C>,\n op4: OperatorFunction<C, D>,\n op5: OperatorFunction<D, E>,\n op6: OperatorFunction<E, F>,\n op7: OperatorFunction<F, G>,\n op8: OperatorFunction<G, H>,\n op9: OperatorFunction<H, I>,\n ...operations: OperatorFunction<any, any>[]\n ): Observable<unknown>;\n /* tslint:enable:max-line-length */\n\n /**\n * Used to stitch together functional operators into a chain.\n *\n * ## Example\n *\n * ```ts\n * import { interval, filter, map, scan } from 'rxjs';\n *\n * interval(1000)\n * .pipe(\n * filter(x => x % 2 === 0),\n * map(x => x + x),\n * scan((acc, x) => acc + x)\n * )\n * .subscribe(x => console.log(x));\n * ```\n *\n * @return The Observable result of all the operators having been called\n * in the order they were passed in.\n */\n pipe(...operations: OperatorFunction<any, any>[]): Observable<any> {\n return pipeFromArray(operations)(this);\n }\n\n /* tslint:disable:max-line-length */\n /** @deprecated Replaced with {@link firstValueFrom} and {@link lastValueFrom}. Will be removed in v8. Details: https://rxjs.dev/deprecations/to-promise */\n toPromise(): Promise<T | undefined>;\n /** @deprecated Replaced with {@link firstValueFrom} and {@link lastValueFrom}. Will be removed in v8. Details: https://rxjs.dev/deprecations/to-promise */\n toPromise(PromiseCtor: typeof Promise): Promise<T | undefined>;\n /** @deprecated Replaced with {@link firstValueFrom} and {@link lastValueFrom}. Will be removed in v8. Details: https://rxjs.dev/deprecations/to-promise */\n toPromise(PromiseCtor: PromiseConstructorLike): Promise<T | undefined>;\n /* tslint:enable:max-line-length */\n\n /**\n * Subscribe to this Observable and get a Promise resolving on\n * `complete` with the last emission (if any).\n *\n * **WARNING**: Only use this with observables you *know* will complete. If the source\n * observable does not complete, you will end up with a promise that is hung up, and\n * potentially all of the state of an async function hanging out in memory. To avoid\n * this situation, look into adding something like {@link timeout}, {@link take},\n * {@link takeWhile}, or {@link takeUntil} amongst others.\n *\n * @param [promiseCtor] a constructor function used to instantiate\n * the Promise\n * @return A Promise that resolves with the last value emit, or\n * rejects on an error. If there were no emissions, Promise\n * resolves with undefined.\n * @deprecated Replaced with {@link firstValueFrom} and {@link lastValueFrom}. Will be removed in v8. Details: https://rxjs.dev/deprecations/to-promise\n */\n toPromise(promiseCtor?: PromiseConstructorLike): Promise<T | undefined> {\n promiseCtor = getPromiseCtor(promiseCtor);\n\n return new promiseCtor((resolve, reject) => {\n let value: T | undefined;\n this.subscribe(\n (x: T) => (value = x),\n (err: any) => reject(err),\n () => resolve(value)\n );\n }) as Promise<T | undefined>;\n }\n}\n\n/**\n * Decides between a passed promise constructor from consuming code,\n * A default configured promise constructor, and the native promise\n * constructor and returns it. If nothing can be found, it will throw\n * an error.\n * @param promiseCtor The optional promise constructor to passed by consuming code\n */\nfunction getPromiseCtor(promiseCtor: PromiseConstructorLike | undefined) {\n return promiseCtor ?? config.Promise ?? Promise;\n}\n\nfunction isObserver<T>(value: any): value is Observer<T> {\n return value && isFunction(value.next) && isFunction(value.error) && isFunction(value.complete);\n}\n\nfunction isSubscriber<T>(value: any): value is Subscriber<T> {\n return (value && value instanceof Subscriber) || (isObserver(value) && isSubscription(value));\n}\n", "import { Observable } from '../Observable';\nimport { Subscriber } from '../Subscriber';\nimport { OperatorFunction } from '../types';\nimport { isFunction } from './isFunction';\n\n/**\n * Used to determine if an object is an Observable with a lift function.\n */\nexport function hasLift(source: any): source is { lift: InstanceType<typeof Observable>['lift'] } {\n return isFunction(source?.lift);\n}\n\n/**\n * Creates an `OperatorFunction`. Used to define operators throughout the library in a concise way.\n * @param init The logic to connect the liftedSource to the subscriber at the moment of subscription.\n */\nexport function operate<T, R>(\n init: (liftedSource: Observable<T>, subscriber: Subscriber<R>) => (() => void) | void\n): OperatorFunction<T, R> {\n return (source: Observable<T>) => {\n if (hasLift(source)) {\n return source.lift(function (this: Subscriber<R>, liftedSource: Observable<T>) {\n try {\n return init(liftedSource, this);\n } catch (err) {\n this.error(err);\n }\n });\n }\n throw new TypeError('Unable to lift unknown Observable type');\n };\n}\n", "import { Subscriber } from '../Subscriber';\n\n/**\n * Creates an instance of an `OperatorSubscriber`.\n * @param destination The downstream subscriber.\n * @param onNext Handles next values, only called if this subscriber is not stopped or closed. Any\n * error that occurs in this function is caught and sent to the `error` method of this subscriber.\n * @param onError Handles errors from the subscription, any errors that occur in this handler are caught\n * and send to the `destination` error handler.\n * @param onComplete Handles completion notification from the subscription. Any errors that occur in\n * this handler are sent to the `destination` error handler.\n * @param onFinalize Additional teardown logic here. This will only be called on teardown if the\n * subscriber itself is not already closed. This is called after all other teardown logic is executed.\n */\nexport function createOperatorSubscriber<T>(\n destination: Subscriber<any>,\n onNext?: (value: T) => void,\n onComplete?: () => void,\n onError?: (err: any) => void,\n onFinalize?: () => void\n): Subscriber<T> {\n return new OperatorSubscriber(destination, onNext, onComplete, onError, onFinalize);\n}\n\n/**\n * A generic helper for allowing operators to be created with a Subscriber and\n * use closures to capture necessary state from the operator function itself.\n */\nexport class OperatorSubscriber<T> extends Subscriber<T> {\n /**\n * Creates an instance of an `OperatorSubscriber`.\n * @param destination The downstream subscriber.\n * @param onNext Handles next values, only called if this subscriber is not stopped or closed. Any\n * error that occurs in this function is caught and sent to the `error` method of this subscriber.\n * @param onError Handles errors from the subscription, any errors that occur in this handler are caught\n * and send to the `destination` error handler.\n * @param onComplete Handles completion notification from the subscription. Any errors that occur in\n * this handler are sent to the `destination` error handler.\n * @param onFinalize Additional finalization logic here. This will only be called on finalization if the\n * subscriber itself is not already closed. This is called after all other finalization logic is executed.\n * @param shouldUnsubscribe An optional check to see if an unsubscribe call should truly unsubscribe.\n * NOTE: This currently **ONLY** exists to support the strange behavior of {@link groupBy}, where unsubscription\n * to the resulting observable does not actually disconnect from the source if there are active subscriptions\n * to any grouped observable. (DO NOT EXPOSE OR USE EXTERNALLY!!!)\n */\n constructor(\n destination: Subscriber<any>,\n onNext?: (value: T) => void,\n onComplete?: () => void,\n onError?: (err: any) => void,\n private onFinalize?: () => void,\n private shouldUnsubscribe?: () => boolean\n ) {\n // It's important - for performance reasons - that all of this class's\n // members are initialized and that they are always initialized in the same\n // order. This will ensure that all OperatorSubscriber instances have the\n // same hidden class in V8. This, in turn, will help keep the number of\n // hidden classes involved in property accesses within the base class as\n // low as possible. If the number of hidden classes involved exceeds four,\n // the property accesses will become megamorphic and performance penalties\n // will be incurred - i.e. inline caches won't be used.\n //\n // The reasons for ensuring all instances have the same hidden class are\n // further discussed in this blog post from Benedikt Meurer:\n // https://benediktmeurer.de/2018/03/23/impact-of-polymorphism-on-component-based-frameworks-like-react/\n super(destination);\n this._next = onNext\n ? function (this: OperatorSubscriber<T>, value: T) {\n try {\n onNext(value);\n } catch (err) {\n destination.error(err);\n }\n }\n : super._next;\n this._error = onError\n ? function (this: OperatorSubscriber<T>, err: any) {\n try {\n onError(err);\n } catch (err) {\n // Send any errors that occur down stream.\n destination.error(err);\n } finally {\n // Ensure finalization.\n this.unsubscribe();\n }\n }\n : super._error;\n this._complete = onComplete\n ? function (this: OperatorSubscriber<T>) {\n try {\n onComplete();\n } catch (err) {\n // Send any errors that occur down stream.\n destination.error(err);\n } finally {\n // Ensure finalization.\n this.unsubscribe();\n }\n }\n : super._complete;\n }\n\n unsubscribe() {\n if (!this.shouldUnsubscribe || this.shouldUnsubscribe()) {\n const { closed } = this;\n super.unsubscribe();\n // Execute additional teardown if we have any and we didn't already do so.\n !closed && this.onFinalize?.();\n }\n }\n}\n", "export const isArrayLike = (<T>(x: any): x is ArrayLike<T> => x && typeof x.length === 'number' && typeof x !== 'function');", "import { isFunction } from \"./isFunction\";\n\n/**\n * Tests to see if the object is \"thennable\".\n * @param value the object to test\n */\nexport function isPromise(value: any): value is PromiseLike<any> {\n return isFunction(value?.then);\n}\n", "import { InteropObservable } from '../types';\nimport { observable as Symbol_observable } from '../symbol/observable';\nimport { isFunction } from './isFunction';\n\n/** Identifies an input as being Observable (but not necessary an Rx Observable) */\nexport function isInteropObservable(input: any): input is InteropObservable<any> {\n return isFunction(input[Symbol_observable]);\n}\n", "import { isFunction } from './isFunction';\n\nexport function isAsyncIterable<T>(obj: any): obj is AsyncIterable<T> {\n return Symbol.asyncIterator && isFunction(obj?.[Symbol.asyncIterator]);\n}\n", "/**\n * Creates the TypeError to throw if an invalid object is passed to `from` or `scheduled`.\n * @param input The object that was passed.\n */\nexport function createInvalidObservableTypeError(input: any) {\n // TODO: We should create error codes that can be looked up, so this can be less verbose.\n return new TypeError(\n `You provided ${\n input !== null && typeof input === 'object' ? 'an invalid object' : `'${input}'`\n } where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.`\n );\n}\n", "export function getSymbolIterator(): symbol {\n if (typeof Symbol !== 'function' || !Symbol.iterator) {\n return '@@iterator' as any;\n }\n\n return Symbol.iterator;\n}\n\nexport const iterator = getSymbolIterator();\n", "import { iterator as Symbol_iterator } from '../symbol/iterator';\nimport { isFunction } from './isFunction';\n\n/** Identifies an input as being an Iterable */\nexport function isIterable(input: any): input is Iterable<any> {\n return isFunction(input?.[Symbol_iterator]);\n}\n", "import { ReadableStreamLike } from '../types';\nimport { isFunction } from './isFunction';\n\nexport async function* readableStreamLikeToAsyncGenerator<T>(readableStream: ReadableStreamLike<T>): AsyncGenerator<T> {\n const reader = readableStream.getReader();\n try {\n while (true) {\n const { value, done } = await reader.read();\n if (done) {\n return;\n }\n yield value!;\n }\n } finally {\n reader.releaseLock();\n }\n}\n\nexport function isReadableStreamLike<T>(obj: any): obj is ReadableStreamLike<T> {\n // We don't want to use instanceof checks because they would return\n // false for instances from another Realm, like an <iframe>.\n return isFunction(obj?.getReader);\n}\n", "import { isArrayLike } from '../util/isArrayLike';\nimport { isPromise } from '../util/isPromise';\nimport { Observable } from '../Observable';\nimport { ObservableInput, ObservedValueOf, ReadableStreamLike } from '../types';\nimport { isInteropObservable } from '../util/isInteropObservable';\nimport { isAsyncIterable } from '../util/isAsyncIterable';\nimport { createInvalidObservableTypeError } from '../util/throwUnobservableError';\nimport { isIterable } from '../util/isIterable';\nimport { isReadableStreamLike, readableStreamLikeToAsyncGenerator } from '../util/isReadableStreamLike';\nimport { Subscriber } from '../Subscriber';\nimport { isFunction } from '../util/isFunction';\nimport { reportUnhandledError } from '../util/reportUnhandledError';\nimport { observable as Symbol_observable } from '../symbol/observable';\n\nexport function innerFrom<O extends ObservableInput<any>>(input: O): Observable<ObservedValueOf<O>>;\nexport function innerFrom<T>(input: ObservableInput<T>): Observable<T> {\n if (input instanceof Observable) {\n return input;\n }\n if (input != null) {\n if (isInteropObservable(input)) {\n return fromInteropObservable(input);\n }\n if (isArrayLike(input)) {\n return fromArrayLike(input);\n }\n if (isPromise(input)) {\n return fromPromise(input);\n }\n if (isAsyncIterable(input)) {\n return fromAsyncIterable(input);\n }\n if (isIterable(input)) {\n return fromIterable(input);\n }\n if (isReadableStreamLike(input)) {\n return fromReadableStreamLike(input);\n }\n }\n\n throw createInvalidObservableTypeError(input);\n}\n\n/**\n * Creates an RxJS Observable from an object that implements `Symbol.observable`.\n * @param obj An object that properly implements `Symbol.observable`.\n */\nexport function fromInteropObservable<T>(obj: any) {\n return new Observable((subscriber: Subscriber<T>) => {\n const obs = obj[Symbol_observable]();\n if (isFunction(obs.subscribe)) {\n return obs.subscribe(subscriber);\n }\n // Should be caught by observable subscribe function error handling.\n throw new TypeError('Provided object does not correctly implement Symbol.observable');\n });\n}\n\n/**\n * Synchronously emits the values of an array like and completes.\n * This is exported because there are creation functions and operators that need to\n * make direct use of the same logic, and there's no reason to make them run through\n * `from` conditionals because we *know* they're dealing with an array.\n * @param array The array to emit values from\n */\nexport function fromArrayLike<T>(array: ArrayLike<T>) {\n return new Observable((subscriber: Subscriber<T>) => {\n // Loop over the array and emit each value. Note two things here:\n // 1. We're making sure that the subscriber is not closed on each loop.\n // This is so we don't continue looping over a very large array after\n // something like a `take`, `takeWhile`, or other synchronous unsubscription\n // has already unsubscribed.\n // 2. In this form, reentrant code can alter that array we're looping over.\n // This is a known issue, but considered an edge case. The alternative would\n // be to copy the array before executing the loop, but this has\n // performance implications.\n for (let i = 0; i < array.length && !subscriber.closed; i++) {\n subscriber.next(array[i]);\n }\n subscriber.complete();\n });\n}\n\nexport function fromPromise<T>(promise: PromiseLike<T>) {\n return new Observable((subscriber: Subscriber<T>) => {\n promise\n .then(\n (value) => {\n if (!subscriber.closed) {\n subscriber.next(value);\n subscriber.complete();\n }\n },\n (err: any) => subscriber.error(err)\n )\n .then(null, reportUnhandledError);\n });\n}\n\nexport function fromIterable<T>(iterable: Iterable<T>) {\n return new Observable((subscriber: Subscriber<T>) => {\n for (const value of iterable) {\n subscriber.next(value);\n if (subscriber.closed) {\n return;\n }\n }\n subscriber.complete();\n });\n}\n\nexport function fromAsyncIterable<T>(asyncIterable: AsyncIterable<T>) {\n return new Observable((subscriber: Subscriber<T>) => {\n process(asyncIterable, subscriber).catch((err) => subscriber.error(err));\n });\n}\n\nexport function fromReadableStreamLike<T>(readableStream: ReadableStreamLike<T>) {\n return fromAsyncIterable(readableStreamLikeToAsyncGenerator(readableStream));\n}\n\nasync function process<T>(asyncIterable: AsyncIterable<T>, subscriber: Subscriber<T>) {\n for await (const value of asyncIterable) {\n subscriber.next(value);\n // A side-effect may have closed our subscriber,\n // check before the next iteration.\n if (subscriber.closed) {\n return;\n }\n }\n subscriber.complete();\n}\n", "import { Subscription } from '../Subscription';\nimport { SchedulerAction, SchedulerLike } from '../types';\n\nexport function executeSchedule(\n parentSubscription: Subscription,\n scheduler: SchedulerLike,\n work: () => void,\n delay: number,\n repeat: true\n): void;\nexport function executeSchedule(\n parentSubscription: Subscription,\n scheduler: SchedulerLike,\n work: () => void,\n delay?: number,\n repeat?: false\n): Subscription;\n\nexport function executeSchedule(\n parentSubscription: Subscription,\n scheduler: SchedulerLike,\n work: () => void,\n delay = 0,\n repeat = false\n): Subscription | void {\n const scheduleSubscription = scheduler.schedule(function (this: SchedulerAction<any>) {\n work();\n if (repeat) {\n parentSubscription.add(this.schedule(null, delay));\n } else {\n this.unsubscribe();\n }\n }, delay);\n\n parentSubscription.add(scheduleSubscription);\n\n if (!repeat) {\n // Because user-land scheduler implementations are unlikely to properly reuse\n // Actions for repeat scheduling, we can't trust that the returned subscription\n // will control repeat subscription scenarios. So we're trying to avoid using them\n // incorrectly within this library.\n return scheduleSubscription;\n }\n}\n", "/** @prettier */\nimport { MonoTypeOperatorFunction, SchedulerLike } from '../types';\nimport { executeSchedule } from '../util/executeSchedule';\nimport { operate } from '../util/lift';\nimport { createOperatorSubscriber } from './OperatorSubscriber';\n\n/**\n * Re-emits all notifications from source Observable with specified scheduler.\n *\n * <span class=\"informal\">Ensure a specific scheduler is used, from outside of an Observable.</span>\n *\n * `observeOn` is an operator that accepts a scheduler as a first parameter, which will be used to reschedule\n * notifications emitted by the source Observable. It might be useful, if you do not have control over\n * internal scheduler of a given Observable, but want to control when its values are emitted nevertheless.\n *\n * Returned Observable emits the same notifications (nexted values, complete and error events) as the source Observable,\n * but rescheduled with provided scheduler. Note that this doesn't mean that source Observables internal\n * scheduler will be replaced in any way. Original scheduler still will be used, but when the source Observable emits\n * notification, it will be immediately scheduled again - this time with scheduler passed to `observeOn`.\n * An anti-pattern would be calling `observeOn` on Observable that emits lots of values synchronously, to split\n * that emissions into asynchronous chunks. For this to happen, scheduler would have to be passed into the source\n * Observable directly (usually into the operator that creates it). `observeOn` simply delays notifications a\n * little bit more, to ensure that they are emitted at expected moments.\n *\n * As a matter of fact, `observeOn` accepts second parameter, which specifies in milliseconds with what delay notifications\n * will be emitted. The main difference between {@link delay} operator and `observeOn` is that `observeOn`\n * will delay all notifications - including error notifications - while `delay` will pass through error\n * from source Observable immediately when it is emitted. In general it is highly recommended to use `delay` operator\n * for any kind of delaying of values in the stream, while using `observeOn` to specify which scheduler should be used\n * for notification emissions in general.\n *\n * ## Example\n *\n * Ensure values in subscribe are called just before browser repaint\n *\n * ```ts\n * import { interval, observeOn, animationFrameScheduler } from 'rxjs';\n *\n * const someDiv = document.createElement('div');\n * someDiv.style.cssText = 'width: 200px;background: #09c';\n * document.body.appendChild(someDiv);\n * const intervals = interval(10); // Intervals are scheduled\n * // with async scheduler by default...\n * intervals.pipe(\n * observeOn(animationFrameScheduler) // ...but we will observe on animationFrame\n * ) // scheduler to ensure smooth animation.\n * .subscribe(val => {\n * someDiv.style.height = val + 'px';\n * });\n * ```\n *\n * @see {@link delay}\n *\n * @param scheduler Scheduler that will be used to reschedule notifications from source Observable.\n * @param delay Number of milliseconds that states with what delay every notification should be rescheduled.\n * @return A function that returns an Observable that emits the same\n * notifications as the source Observable, but with provided scheduler.\n */\nexport function observeOn<T>(scheduler: SchedulerLike, delay = 0): MonoTypeOperatorFunction<T> {\n return operate((source, subscriber) => {\n source.subscribe(\n createOperatorSubscriber(\n subscriber,\n (value) => executeSchedule(subscriber, scheduler, () => subscriber.next(value), delay),\n () => executeSchedule(subscriber, scheduler, () => subscriber.complete(), delay),\n (err) => executeSchedule(subscriber, scheduler, () => subscriber.error(err), delay)\n )\n );\n });\n}\n", "import { MonoTypeOperatorFunction, SchedulerLike } from '../types';\nimport { operate } from '../util/lift';\n\n/**\n * Asynchronously subscribes Observers to this Observable on the specified {@link SchedulerLike}.\n *\n * With `subscribeOn` you can decide what type of scheduler a specific Observable will be using when it is subscribed to.\n *\n * Schedulers control the speed and order of emissions to observers from an Observable stream.\n *\n * \n *\n * ## Example\n *\n * Given the following code:\n *\n * ```ts\n * import { of, merge } from 'rxjs';\n *\n * const a = of(1, 2, 3);\n * const b = of(4, 5, 6);\n *\n * merge(a, b).subscribe(console.log);\n *\n * // Outputs\n * // 1\n * // 2\n * // 3\n * // 4\n * // 5\n * // 6\n * ```\n *\n * Both Observable `a` and `b` will emit their values directly and synchronously once they are subscribed to.\n *\n * If we instead use the `subscribeOn` operator declaring that we want to use the {@link asyncScheduler} for values emitted by Observable `a`:\n *\n * ```ts\n * import { of, subscribeOn, asyncScheduler, merge } from 'rxjs';\n *\n * const a = of(1, 2, 3).pipe(subscribeOn(asyncScheduler));\n * const b = of(4, 5, 6);\n *\n * merge(a, b).subscribe(console.log);\n *\n * // Outputs\n * // 4\n * // 5\n * // 6\n * // 1\n * // 2\n * // 3\n * ```\n *\n * The reason for this is that Observable `b` emits its values directly and synchronously like before\n * but the emissions from `a` are scheduled on the event loop because we are now using the {@link asyncScheduler} for that specific Observable.\n *\n * @param scheduler The {@link SchedulerLike} to perform subscription actions on.\n * @param delay A delay to pass to the scheduler to delay subscriptions\n * @return A function that returns an Observable modified so that its\n * subscriptions happen on the specified {@link SchedulerLike}.\n */\nexport function subscribeOn<T>(scheduler: SchedulerLike, delay: number = 0): MonoTypeOperatorFunction<T> {\n return operate((source, subscriber) => {\n subscriber.add(scheduler.schedule(() => source.subscribe(subscriber), delay));\n });\n}\n", "import { innerFrom } from '../observable/innerFrom';\nimport { observeOn } from '../operators/observeOn';\nimport { subscribeOn } from '../operators/subscribeOn';\nimport { InteropObservable, SchedulerLike } from '../types';\n\nexport function scheduleObservable<T>(input: InteropObservable<T>, scheduler: SchedulerLike) {\n return innerFrom(input).pipe(subscribeOn(scheduler), observeOn(scheduler));\n}\n", "import { innerFrom } from '../observable/innerFrom';\nimport { observeOn } from '../operators/observeOn';\nimport { subscribeOn } from '../operators/subscribeOn';\nimport { SchedulerLike } from '../types';\n\nexport function schedulePromise<T>(input: PromiseLike<T>, scheduler: SchedulerLike) {\n return innerFrom(input).pipe(subscribeOn(scheduler), observeOn(scheduler));\n}\n", "import { Observable } from '../Observable';\nimport { SchedulerLike } from '../types';\n\nexport function scheduleArray<T>(input: ArrayLike<T>, scheduler: SchedulerLike) {\n return new Observable<T>((subscriber) => {\n // The current array index.\n let i = 0;\n // Start iterating over the array like on a schedule.\n return scheduler.schedule(function () {\n if (i === input.length) {\n // If we have hit the end of the array like in the\n // previous job, we can complete.\n subscriber.complete();\n } else {\n // Otherwise let's next the value at the current index,\n // then increment our index.\n subscriber.next(input[i++]);\n // If the last emission didn't cause us to close the subscriber\n // (via take or some side effect), reschedule the job and we'll\n // make another pass.\n if (!subscriber.closed) {\n this.schedule();\n }\n }\n });\n });\n}\n", "import { Observable } from '../Observable';\nimport { SchedulerLike } from '../types';\nimport { iterator as Symbol_iterator } from '../symbol/iterator';\nimport { isFunction } from '../util/isFunction';\nimport { executeSchedule } from '../util/executeSchedule';\n\n/**\n * Used in {@link scheduled} to create an observable from an Iterable.\n * @param input The iterable to create an observable from\n * @param scheduler The scheduler to use\n */\nexport function scheduleIterable<T>(input: Iterable<T>, scheduler: SchedulerLike) {\n return new Observable<T>((subscriber) => {\n let iterator: Iterator<T, T>;\n\n // Schedule the initial creation of the iterator from\n // the iterable. This is so the code in the iterable is\n // not called until the scheduled job fires.\n executeSchedule(subscriber, scheduler, () => {\n // Create the iterator.\n iterator = (input as any)[Symbol_iterator]();\n\n executeSchedule(\n subscriber,\n scheduler,\n () => {\n let value: T;\n let done: boolean | undefined;\n try {\n // Pull the value out of the iterator\n ({ value, done } = iterator.next());\n } catch (err) {\n // We got an error while pulling from the iterator\n subscriber.error(err);\n return;\n }\n\n if (done) {\n // If it is \"done\" we just complete. This mimics the\n // behavior of JavaScript's `for..of` consumption of\n // iterables, which will not emit the value from an iterator\n // result of `{ done: true: value: 'here' }`.\n subscriber.complete();\n } else {\n // The iterable is not done, emit the value.\n subscriber.next(value);\n }\n },\n 0,\n true\n );\n });\n\n // During finalization, if we see this iterator has a `return` method,\n // then we know it is a Generator, and not just an Iterator. So we call\n // the `return()` function. This will ensure that any `finally { }` blocks\n // inside of the generator we can hit will be hit properly.\n return () => isFunction(iterator?.return) && iterator.return();\n });\n}\n", "import { SchedulerLike } from '../types';\nimport { Observable } from '../Observable';\nimport { executeSchedule } from '../util/executeSchedule';\n\nexport function scheduleAsyncIterable<T>(input: AsyncIterable<T>, scheduler: SchedulerLike) {\n if (!input) {\n throw new Error('Iterable cannot be null');\n }\n return new Observable<T>((subscriber) => {\n executeSchedule(subscriber, scheduler, () => {\n const iterator = input[Symbol.asyncIterator]();\n executeSchedule(\n subscriber,\n scheduler,\n () => {\n iterator.next().then((result) => {\n if (result.done) {\n // This will remove the subscriptions from\n // the parent subscription.\n subscriber.complete();\n } else {\n subscriber.next(result.value);\n }\n });\n },\n 0,\n true\n );\n });\n });\n}\n", "import { SchedulerLike, ReadableStreamLike } from '../types';\nimport { Observable } from '../Observable';\nimport { scheduleAsyncIterable } from './scheduleAsyncIterable';\nimport { readableStreamLikeToAsyncGenerator } from '../util/isReadableStreamLike';\n\nexport function scheduleReadableStreamLike<T>(input: ReadableStreamLike<T>, scheduler: SchedulerLike): Observable<T> {\n return scheduleAsyncIterable(readableStreamLikeToAsyncGenerator(input), scheduler);\n}\n", "import { scheduleObservable } from './scheduleObservable';\nimport { schedulePromise } from './schedulePromise';\nimport { scheduleArray } from './scheduleArray';\nimport { scheduleIterable } from './scheduleIterable';\nimport { scheduleAsyncIterable } from './scheduleAsyncIterable';\nimport { isInteropObservable } from '../util/isInteropObservable';\nimport { isPromise } from '../util/isPromise';\nimport { isArrayLike } from '../util/isArrayLike';\nimport { isIterable } from '../util/isIterable';\nimport { ObservableInput, SchedulerLike } from '../types';\nimport { Observable } from '../Observable';\nimport { isAsyncIterable } from '../util/isAsyncIterable';\nimport { createInvalidObservableTypeError } from '../util/throwUnobservableError';\nimport { isReadableStreamLike } from '../util/isReadableStreamLike';\nimport { scheduleReadableStreamLike } from './scheduleReadableStreamLike';\n\n/**\n * Converts from a common {@link ObservableInput} type to an observable where subscription and emissions\n * are scheduled on the provided scheduler.\n *\n * @see {@link from}\n * @see {@link of}\n *\n * @param input The observable, array, promise, iterable, etc you would like to schedule\n * @param scheduler The scheduler to use to schedule the subscription and emissions from\n * the returned observable.\n */\nexport function scheduled<T>(input: ObservableInput<T>, scheduler: SchedulerLike): Observable<T> {\n if (input != null) {\n if (isInteropObservable(input)) {\n return scheduleObservable(input, scheduler);\n }\n if (isArrayLike(input)) {\n return scheduleArray(input, scheduler);\n }\n if (isPromise(input)) {\n return schedulePromise(input, scheduler);\n }\n if (isAsyncIterable(input)) {\n return scheduleAsyncIterable(input, scheduler);\n }\n if (isIterable(input)) {\n return scheduleIterable(input, scheduler);\n }\n if (isReadableStreamLike(input)) {\n return scheduleReadableStreamLike(input, scheduler);\n }\n }\n throw createInvalidObservableTypeError(input);\n}\n", "import { Observable } from '../Observable';\nimport { ObservableInput, SchedulerLike, ObservedValueOf } from '../types';\nimport { scheduled } from '../scheduled/scheduled';\nimport { innerFrom } from './innerFrom';\n\nexport function from<O extends ObservableInput<any>>(input: O): Observable<ObservedValueOf<O>>;\n/** @deprecated The `scheduler` parameter will be removed in v8. Use `scheduled`. Details: https://rxjs.dev/deprecations/scheduler-argument */\nexport function from<O extends ObservableInput<any>>(input: O, scheduler: SchedulerLike | undefined): Observable<ObservedValueOf<O>>;\n\n/**\n * Creates an Observable from an Array, an array-like object, a Promise, an iterable object, or an Observable-like object.\n *\n * <span class=\"informal\">Converts almost anything to an Observable.</span>\n *\n * \n *\n * `from` converts various other objects and data types into Observables. It also converts a Promise, an array-like, or an\n * <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#iterable\" target=\"_blank\">iterable</a>\n * object into an Observable that emits the items in that promise, array, or iterable. A String, in this context, is treated\n * as an array of characters. Observable-like objects (contains a function named with the ES2015 Symbol for Observable) can also be\n * converted through this operator.\n *\n * ## Examples\n *\n * Converts an array to an Observable\n *\n * ```ts\n * import { from } from 'rxjs';\n *\n * const array = [10, 20, 30];\n * const result = from(array);\n *\n * result.subscribe(x => console.log(x));\n *\n * // Logs:\n * // 10\n * // 20\n * // 30\n * ```\n *\n * Convert an infinite iterable (from a generator) to an Observable\n *\n * ```ts\n * import { from, take } from 'rxjs';\n *\n * function* generateDoubles(seed) {\n * let i = seed;\n * while (true) {\n * yield i;\n * i = 2 * i; // double it\n * }\n * }\n *\n * const iterator = generateDoubles(3);\n * const result = from(iterator).pipe(take(10));\n *\n * result.subscribe(x => console.log(x));\n *\n * // Logs:\n * // 3\n * // 6\n * // 12\n * // 24\n * // 48\n * // 96\n * // 192\n * // 384\n * // 768\n * // 1536\n * ```\n *\n * With `asyncScheduler`\n *\n * ```ts\n * import { from, asyncScheduler } from 'rxjs';\n *\n * console.log('start');\n *\n * const array = [10, 20, 30];\n * const result = from(array, asyncScheduler);\n *\n * result.subscribe(x => console.log(x));\n *\n * console.log('end');\n *\n * // Logs:\n * // 'start'\n * // 'end'\n * // 10\n * // 20\n * // 30\n * ```\n *\n * @see {@link fromEvent}\n * @see {@link fromEventPattern}\n *\n * @param input A subscription object, a Promise, an Observable-like,\n * an Array, an iterable, or an array-like object to be converted.\n * @param scheduler An optional {@link SchedulerLike} on which to schedule the emission of values.\n * @return An Observable converted from {@link ObservableInput}.\n */\nexport function from<T>(input: ObservableInput<T>, scheduler?: SchedulerLike): Observable<T> {\n return scheduler ? scheduled(input, scheduler) : innerFrom(input);\n}\n", "import { OperatorFunction } from '../types';\nimport { operate } from '../util/lift';\nimport { createOperatorSubscriber } from './OperatorSubscriber';\n\nexport function map<T, R>(project: (value: T, index: number) => R): OperatorFunction<T, R>;\n/** @deprecated Use a closure instead of a `thisArg`. Signatures accepting a `thisArg` will be removed in v8. */\nexport function map<T, R, A>(project: (this: A, value: T, index: number) => R, thisArg: A): OperatorFunction<T, R>;\n\n/**\n * Applies a given `project` function to each value emitted by the source\n * Observable, and emits the resulting values as an Observable.\n *\n * <span class=\"informal\">Like [Array.prototype.map()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map),\n * it passes each source value through a transformation function to get\n * corresponding output values.</span>\n *\n * \n *\n * Similar to the well known `Array.prototype.map` function, this operator\n * applies a projection to each value and emits that projection in the output\n * Observable.\n *\n * ## Example\n *\n * Map every click to the `clientX` position of that click\n *\n * ```ts\n * import { fromEvent, map } from 'rxjs';\n *\n * const clicks = fromEvent<PointerEvent>(document, 'click');\n * const positions = clicks.pipe(map(ev => ev.clientX));\n *\n * positions.subscribe(x => console.log(x));\n * ```\n *\n * @see {@link mapTo}\n * @see {@link pluck}\n *\n * @param project The function to apply to each `value` emitted by the source\n * Observable. The `index` parameter is the number `i` for the i-th emission\n * that has happened since the subscription, starting from the number `0`.\n * @param thisArg An optional argument to define what `this` is in the\n * `project` function.\n * @return A function that returns an Observable that emits the values from the\n * source Observable transformed by the given `project` function.\n */\nexport function map<T, R>(project: (value: T, index: number) => R, thisArg?: any): OperatorFunction<T, R> {\n return operate((source, subscriber) => {\n // The index of the value from the source. Used with projection.\n let index = 0;\n // Subscribe to the source, all errors and completions are sent along\n // to the consumer.\n source.subscribe(\n createOperatorSubscriber(subscriber, (value: T) => {\n // Call the projection function with the appropriate this context,\n // and send the resulting value to the consumer.\n subscriber.next(project.call(thisArg, value, index++));\n })\n );\n });\n}\n", "import { Observable } from '../Observable';\nimport { innerFrom } from '../observable/innerFrom';\nimport { Subscriber } from '../Subscriber';\nimport { ObservableInput, SchedulerLike } from '../types';\nimport { executeSchedule } from '../util/executeSchedule';\nimport { createOperatorSubscriber } from './OperatorSubscriber';\n\n/**\n * A process embodying the general \"merge\" strategy. This is used in\n * `mergeMap` and `mergeScan` because the logic is otherwise nearly identical.\n * @param source The original source observable\n * @param subscriber The consumer subscriber\n * @param project The projection function to get our inner sources\n * @param concurrent The number of concurrent inner subscriptions\n * @param onBeforeNext Additional logic to apply before nexting to our consumer\n * @param expand If `true` this will perform an \"expand\" strategy, which differs only\n * in that it recurses, and the inner subscription must be schedule-able.\n * @param innerSubScheduler A scheduler to use to schedule inner subscriptions,\n * this is to support the expand strategy, mostly, and should be deprecated\n */\nexport function mergeInternals<T, R>(\n source: Observable<T>,\n subscriber: Subscriber<R>,\n project: (value: T, index: number) => ObservableInput<R>,\n concurrent: number,\n onBeforeNext?: (innerValue: R) => void,\n expand?: boolean,\n innerSubScheduler?: SchedulerLike,\n additionalFinalizer?: () => void\n) {\n // Buffered values, in the event of going over our concurrency limit\n const buffer: T[] = [];\n // The number of active inner subscriptions.\n let active = 0;\n // An index to pass to our accumulator function\n let index = 0;\n // Whether or not the outer source has completed.\n let isComplete = false;\n\n /**\n * Checks to see if we can complete our result or not.\n */\n const checkComplete = () => {\n // If the outer has completed, and nothing is left in the buffer,\n // and we don't have any active inner subscriptions, then we can\n // Emit the state and complete.\n if (isComplete && !buffer.length && !active) {\n subscriber.complete();\n }\n };\n\n // If we're under our concurrency limit, just start the inner subscription, otherwise buffer and wait.\n const outerNext = (value: T) => (active < concurrent ? doInnerSub(value) : buffer.push(value));\n\n const doInnerSub = (value: T) => {\n // If we're expanding, we need to emit the outer values and the inner values\n // as the inners will \"become outers\" in a way as they are recursively fed\n // back to the projection mechanism.\n expand && subscriber.next(value as any);\n\n // Increment the number of active subscriptions so we can track it\n // against our concurrency limit later.\n active++;\n\n // A flag used to show that the inner observable completed.\n // This is checked during finalization to see if we should\n // move to the next item in the buffer, if there is on.\n let innerComplete = false;\n\n // Start our inner subscription.\n innerFrom(project(value, index++)).subscribe(\n createOperatorSubscriber(\n subscriber,\n (innerValue) => {\n // `mergeScan` has additional handling here. For example\n // taking the inner value and updating state.\n onBeforeNext?.(innerValue);\n\n if (expand) {\n // If we're expanding, then just recurse back to our outer\n // handler. It will emit the value first thing.\n outerNext(innerValue as any);\n } else {\n // Otherwise, emit the inner value.\n subscriber.next(innerValue);\n }\n },\n () => {\n // Flag that we have completed, so we know to check the buffer\n // during finalization.\n innerComplete = true;\n },\n // Errors are passed to the destination.\n undefined,\n () => {\n // During finalization, if the inner completed (it wasn't errored or\n // cancelled), then we want to try the next item in the buffer if\n // there is one.\n if (innerComplete) {\n // We have to wrap this in a try/catch because it happens during\n // finalization, possibly asynchronously, and we want to pass\n // any errors that happen (like in a projection function) to\n // the outer Subscriber.\n try {\n // INNER SOURCE COMPLETE\n // Decrement the active count to ensure that the next time\n // we try to call `doInnerSub`, the number is accurate.\n active--;\n // If we have more values in the buffer, try to process those\n // Note that this call will increment `active` ahead of the\n // next conditional, if there were any more inner subscriptions\n // to start.\n while (buffer.length && active < concurrent) {\n const bufferedValue = buffer.shift()!;\n // Particularly for `expand`, we need to check to see if a scheduler was provided\n // for when we want to start our inner subscription. Otherwise, we just start\n // are next inner subscription.\n if (innerSubScheduler) {\n executeSchedule(subscriber, innerSubScheduler, () => doInnerSub(bufferedValue));\n } else {\n doInnerSub(bufferedValue);\n }\n }\n // Check to see if we can complete, and complete if so.\n checkComplete();\n } catch (err) {\n subscriber.error(err);\n }\n }\n }\n )\n );\n };\n\n // Subscribe to our source observable.\n source.subscribe(\n createOperatorSubscriber(subscriber, outerNext, () => {\n // Outer completed, make a note of it, and check to see if we can complete everything.\n isComplete = true;\n checkComplete();\n })\n );\n\n // Additional finalization (for when the destination is torn down).\n // Other finalization is added implicitly via subscription above.\n return () => {\n additionalFinalizer?.();\n };\n}\n", "import { ObservableInput, OperatorFunction, ObservedValueOf } from '../types';\nimport { map } from './map';\nimport { innerFrom } from '../observable/innerFrom';\nimport { operate } from '../util/lift';\nimport { mergeInternals } from './mergeInternals';\nimport { isFunction } from '../util/isFunction';\n\n/* tslint:disable:max-line-length */\nexport function mergeMap<T, O extends ObservableInput<any>>(\n project: (value: T, index: number) => O,\n concurrent?: number\n): OperatorFunction<T, ObservedValueOf<O>>;\n/** @deprecated The `resultSelector` parameter will be removed in v8. Use an inner `map` instead. Details: https://rxjs.dev/deprecations/resultSelector */\nexport function mergeMap<T, O extends ObservableInput<any>>(\n project: (value: T, index: number) => O,\n resultSelector: undefined,\n concurrent?: number\n): OperatorFunction<T, ObservedValueOf<O>>;\n/** @deprecated The `resultSelector` parameter will be removed in v8. Use an inner `map` instead. Details: https://rxjs.dev/deprecations/resultSelector */\nexport function mergeMap<T, R, O extends ObservableInput<any>>(\n project: (value: T, index: number) => O,\n resultSelector: (outerValue: T, innerValue: ObservedValueOf<O>, outerIndex: number, innerIndex: number) => R,\n concurrent?: number\n): OperatorFunction<T, R>;\n/* tslint:enable:max-line-length */\n\n/**\n * Projects each source value to an Observable which is merged in the output\n * Observable.\n *\n * <span class=\"informal\">Maps each value to an Observable, then flattens all of\n * these inner Observables using {@link mergeAll}.</span>\n *\n * \n *\n * Returns an Observable that emits items based on applying a function that you\n * supply to each item emitted by the source Observable, where that function\n * returns an Observable, and then merging those resulting Observables and\n * emitting the results of this merger.\n *\n * ## Example\n *\n * Map and flatten each letter to an Observable ticking every 1 second\n *\n * ```ts\n * import { of, mergeMap, interval, map } from 'rxjs';\n *\n * const letters = of('a', 'b', 'c');\n * const result = letters.pipe(\n * mergeMap(x => interval(1000).pipe(map(i => x + i)))\n * );\n *\n * result.subscribe(x => console.log(x));\n *\n * // Results in the following:\n * // a0\n * // b0\n * // c0\n * // a1\n * // b1\n * // c1\n * // continues to list a, b, c every second with respective ascending integers\n * ```\n *\n * @see {@link concatMap}\n * @see {@link exhaustMap}\n * @see {@link merge}\n * @see {@link mergeAll}\n * @see {@link mergeMapTo}\n * @see {@link mergeScan}\n * @see {@link switchMap}\n *\n * @param project A function that, when applied to an item emitted by the source\n * Observable, returns an Observable.\n * @param concurrent Maximum number of `ObservableInput`s being subscribed to concurrently.\n * @return A function that returns an Observable that emits the result of\n * applying the projection function (and the optional deprecated\n * `resultSelector`) to each item emitted by the source Observable and merging\n * the results of the Observables obtained from this transformation.\n */\nexport function mergeMap<T, R, O extends ObservableInput<any>>(\n project: (value: T, index: number) => O,\n resultSelector?: ((outerValue: T, innerValue: ObservedValueOf<O>, outerIndex: number, innerIndex: number) => R) | number,\n concurrent: number = Infinity\n): OperatorFunction<T, ObservedValueOf<O> | R> {\n if (isFunction(resultSelector)) {\n // DEPRECATED PATH\n return mergeMap((a, i) => map((b: any, ii: number) => resultSelector(a, b, i, ii))(innerFrom(project(a, i))), concurrent);\n } else if (typeof resultSelector === 'number') {\n concurrent = resultSelector;\n }\n\n return operate((source, subscriber) => mergeInternals(source, subscriber, project, concurrent));\n}\n", "import { Observable } from '../Observable';\nimport { Subscriber } from '../Subscriber';\nimport { createOperatorSubscriber } from './OperatorSubscriber';\n\n/**\n * A basic scan operation. This is used for `scan` and `reduce`.\n * @param accumulator The accumulator to use\n * @param seed The seed value for the state to accumulate\n * @param hasSeed Whether or not a seed was provided\n * @param emitOnNext Whether or not to emit the state on next\n * @param emitBeforeComplete Whether or not to emit the before completion\n */\n\nexport function scanInternals<V, A, S>(\n accumulator: (acc: V | A | S, value: V, index: number) => A,\n seed: S,\n hasSeed: boolean,\n emitOnNext: boolean,\n emitBeforeComplete?: undefined | true\n) {\n return (source: Observable<V>, subscriber: Subscriber<any>) => {\n // Whether or not we have state yet. This will only be\n // false before the first value arrives if we didn't get\n // a seed value.\n let hasState = hasSeed;\n // The state that we're tracking, starting with the seed,\n // if there is one, and then updated by the return value\n // from the accumulator on each emission.\n let state: any = seed;\n // An index to pass to the accumulator function.\n let index = 0;\n\n // Subscribe to our source. All errors and completions are passed through.\n source.subscribe(\n createOperatorSubscriber(\n subscriber,\n (value) => {\n // Always increment the index.\n const i = index++;\n // Set the state\n state = hasState\n ? // We already have state, so we can get the new state from the accumulator\n accumulator(state, value, i)\n : // We didn't have state yet, a seed value was not provided, so\n\n // we set the state to the first value, and mark that we have state now\n ((hasState = true), value);\n\n // Maybe send it to the consumer.\n emitOnNext && subscriber.next(state);\n },\n // If an onComplete was given, call it, otherwise\n // just pass through the complete notification to the consumer.\n emitBeforeComplete &&\n (() => {\n hasState && subscriber.next(state);\n subscriber.complete();\n })\n )\n );\n };\n}\n", "import { scanInternals } from './scanInternals';\nimport { OperatorFunction } from '../types';\nimport { operate } from '../util/lift';\n\nexport function reduce<V, A = V>(accumulator: (acc: A | V, value: V, index: number) => A): OperatorFunction<V, V | A>;\nexport function reduce<V, A>(accumulator: (acc: A, value: V, index: number) => A, seed: A): OperatorFunction<V, A>;\nexport function reduce<V, A, S = A>(accumulator: (acc: A | S, value: V, index: number) => A, seed: S): OperatorFunction<V, A>;\n\n/**\n * Applies an accumulator function over the source Observable, and returns the\n * accumulated result when the source completes, given an optional seed value.\n *\n * <span class=\"informal\">Combines together all values emitted on the source,\n * using an accumulator function that knows how to join a new source value into\n * the accumulation from the past.</span>\n *\n * \n *\n * Like\n * [Array.prototype.reduce()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce),\n * `reduce` applies an `accumulator` function against an accumulation and each\n * value of the source Observable (from the past) to reduce it to a single\n * value, emitted on the output Observable. Note that `reduce` will only emit\n * one value, only when the source Observable completes. It is equivalent to\n * applying operator {@link scan} followed by operator {@link last}.\n *\n * Returns an Observable that applies a specified `accumulator` function to each\n * item emitted by the source Observable. If a `seed` value is specified, then\n * that value will be used as the initial value for the accumulator. If no seed\n * value is specified, the first item of the source is used as the seed.\n *\n * ## Example\n *\n * Count the number of click events that happened in 5 seconds\n *\n * ```ts\n * import { fromEvent, takeUntil, interval, map, reduce } from 'rxjs';\n *\n * const clicksInFiveSeconds = fromEvent(document, 'click')\n * .pipe(takeUntil(interval(5000)));\n *\n * const ones = clicksInFiveSeconds.pipe(map(() => 1));\n * const seed = 0;\n * const count = ones.pipe(reduce((acc, one) => acc + one, seed));\n *\n * count.subscribe(x => console.log(x));\n * ```\n *\n * @see {@link count}\n * @see {@link expand}\n * @see {@link mergeScan}\n * @see {@link scan}\n *\n * @param accumulator The accumulator function called on each source value.\n * @param seed The initial accumulation value.\n * @return A function that returns an Observable that emits a single value that\n * is the result of accumulating the values emitted by the source Observable.\n */\nexport function reduce<V, A>(accumulator: (acc: V | A, value: V, index: number) => A, seed?: any): OperatorFunction<V, V | A> {\n return operate(scanInternals(accumulator, seed, arguments.length >= 2, false, true));\n}\n", "import { reduce } from './reduce';\nimport { OperatorFunction } from '../types';\nimport { operate } from '../util/lift';\n\nconst arrReducer = (arr: any[], value: any) => (arr.push(value), arr);\n\n/**\n * Collects all source emissions and emits them as an array when the source completes.\n *\n * <span class=\"informal\">Get all values inside an array when the source completes</span>\n *\n * \n *\n * `toArray` will wait until the source Observable completes before emitting\n * the array containing all emissions. When the source Observable errors no\n * array will be emitted.\n *\n * ## Example\n *\n * ```ts\n * import { interval, take, toArray } from 'rxjs';\n *\n * const source = interval(1000);\n * const example = source.pipe(\n * take(10),\n * toArray()\n * );\n *\n * example.subscribe(value => console.log(value));\n *\n * // output: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n * ```\n *\n * @return A function that returns an Observable that emits an array of items\n * emitted by the source Observable when source completes.\n */\nexport function toArray<T>(): OperatorFunction<T, T[]> {\n // Because arrays are mutable, and we're mutating the array in this\n // reducer process, we have to encapsulate the creation of the initial\n // array within this `operate` function.\n return operate((source, subscriber) => {\n reduce(arrReducer, [] as T[])(source).subscribe(subscriber);\n });\n}\n", "import { CIGAR_D, CIGAR_EQ, CIGAR_I, CIGAR_M, CIGAR_N, CIGAR_RUN, CIGAR_X, parseCigar2Typed, parseCoarseCigar, } from '@jbrowse/cigar-utils';\n// Per-perspective PIF/PAF CIGAR consumption, matching buildSyntenyGeometry's\n// walk: bp1 (query / v1 side) advances on M/=/X and D/N; bp2 (target / v2 side)\n// advances on M/=/X and I. The D<->I asymmetry is the pre-swap the PIF t-line\n// carries, so a clip produced here stays consistent when it feeds back through\n// the same convention.\n//\n// Spelled as ENUMERATED op sets, so H/S/P advance NEITHER axis. That is the\n// convention every other walk in the tree uses \u2014 `visitCigarRenderedSegments`\n// (the walk this clip's own output is re-walked by, which has no branch for them\n// at all) and `findPosInCigar`, whose header says so explicitly. Written as\n// `op !== CIGAR_I` / `op !== CIGAR_D && op !== CIGAR_N` these advanced BOTH axes\n// on a clip, which stays invisible only because a PAF/PIF CIGAR carries none. A\n// BAM-sourced one does: \"Linear read vs ref\" hands the read's raw CIGAR through\n// verbatim while putting the mate in read coordinates that already EXCLUDE the\n// clip (`buildReadVsRefFeatures`, `clipLengthAtStartOfRead`). So a leading\n// `100S` walked the re-anchored block 100bp along both axes past where the block\n// says it starts, and since `clipLargeBlockToWindow` fires once a block exceeds\n// 4x the window \u2014 ~1bp/px on a 20kb read segment, an ordinary inspection zoom \u2014\n// every CIGAR tile and marker on it landed 100bp short of the ribbon it sits in,\n// which in transparent-indels mode is a hole at the trailing end.\n//\n// Bitmasks in `((1 << op) & MASK)` form, the idiom `CIGAR_INDEL_MASK` already\n// carries in this directory (buildSyntenyGeometry's `cigarSegmentKind`), so\n// membership is one test rather than a chain of five. Built from the op\n// constants rather than written as literals: the point of the fix is that the\n// SET is the thing to read, and `0b110001101` hides it. Deliberately local \u2014\n// `visitCigarRenderedSegments` is the authority here and it branches per op to\n// decide WHICH axis, so a mask does not fit it, and a shared one it could not\n// use would just be a second statement of the same convention.\nconst V1_OPS = (1 << CIGAR_M) |\n (1 << CIGAR_EQ) |\n (1 << CIGAR_X) |\n (1 << CIGAR_D) |\n (1 << CIGAR_N);\nconst V2_OPS = (1 << CIGAR_M) | (1 << CIGAR_EQ) | (1 << CIGAR_X) | (1 << CIGAR_I);\nconst MATCH_OPS = (1 << CIGAR_M) | (1 << CIGAR_EQ) | (1 << CIGAR_X);\nfunction consumesQuery(op) {\n return ((1 << op) & V1_OPS) !== 0;\n}\nfunction consumesTarget(op) {\n return ((1 << op) & V2_OPS) !== 0;\n}\nfunction isMatchOp(op) {\n return ((1 << op) & MATCH_OPS) !== 0;\n}\n// Trim a synteny feature + its CIGAR to a query-space window\n// [winStart, winEnd], returning the re-anchored coords + trimmed CIGAR, or\n// undefined if the block doesn't overlap the window.\n//\n// **`winStart`/`winEnd` MUST be integer bp**, and both callers snap them \u2014\n// outward in `clipLargeBlockToWindow` (a viewport bound), inward in\n// `executeSyntenyFeaturesAndPositions`' trim path (a region-containment bound).\n// A fractional window breaks the output two ways at once: the boundary ops are\n// trimmed to it and then packed through `(cHi - cLo) << 4`, whose ToInt32\n// TRUNCATES the length (a 0.6bp remnant becomes a zero-length op), while\n// `start`/`end` come back carrying the fraction in full. The block's declared\n// span then exceeds what its own CIGAR walks, and since the base trapezoid is\n// drawn from the corners while the tiles are walked from the ops, the\n// difference shows in transparent-indels mode as unpainted ribbon at the\n// trailing end. Not asserted here \u2014 this runs per feature over a whole-genome\n// PAF \u2014 so it is the callers' invariant to keep.\n//\n// A single alignment block can span far beyond the viewport \u2014 a whole UCSC\n// liftOver chain is one ~20 Mb feature. Its base ribbon is drawn as one *linear*\n// trapezoid across that span, which cannot follow megabases of indels, so at\n// high zoom the ribbon lands off-screen and nothing renders. Re-anchoring the\n// block to just its visible slice (accurate coords + a short CIGAR) restores it.\n//\n// Walk direction MUST match buildSyntenyGeometry, which walks the query (v1)\n// axis forward in GENOMIC order for BOTH strands and flips only the target (v2)\n// axis. So the query walk here is always start->end; only the target counts\n// down for a - strand block, entering at mateEnd. Within a match op the target\n// maps to the query as target(q) = bp2 + (q - bp1) * revTarget, using the op's\n// walk-entry positions. (buildSyntenyGeometry re-derives its rev1 from the cumBp\n// order of the endpoints, so a reversed display region walks the same file-order\n// CIGAR the other way in cumBp space \u2014 still forward in genomic query bp, so\n// this reassembly stays valid.)\n//\n// Walking the query backward for - strand (as an earlier version did) mirrors\n// every indel's query position within the window: the trimmed CIGAR is\n// reassembled in file order and re-walked forward by buildSyntenyGeometry, so a\n// deletion lands at its mirror-image position (wrong side of the ribbon).\nexport function clipSyntenyFeature(cigar, start, mateStart, mateEnd, strand, winStart, winEnd) {\n const revTarget = strand === -1 ? -1 : 1;\n let bp1 = start;\n let bp2 = strand === -1 ? mateEnd : mateStart;\n const out = [];\n let qLo = Infinity;\n let qHi = -Infinity;\n let tLo = Infinity;\n let tHi = -Infinity;\n const extendTarget = (a, b) => {\n tLo = Math.min(tLo, a, b);\n tHi = Math.max(tHi, a, b);\n };\n for (let k = 0; k < cigar.length; k++) {\n const packed = cigar[k];\n const len = packed >>> 4;\n const op = packed & 0xf;\n // a CIGAR_RUN pair advances the query by its first word and the target by\n // its second, mapping the two in proportion along the run\n const isRun = op === CIGAR_RUN;\n const qAdv = isRun || consumesQuery(op) ? len : 0;\n const tAdv = isRun ? cigar[++k] >>> 4 : consumesTarget(op) ? len : 0;\n const bp1Next = bp1 + qAdv;\n const bp2Next = bp2 + tAdv * revTarget;\n const opQLo = bp1;\n const opQHi = bp1Next;\n if (opQHi >= winStart && opQLo <= winEnd) {\n if (qAdv > 0) {\n // Query-consuming op (match, run or D/N): trim to the window in query\n // space.\n const cLo = Math.max(opQLo, winStart);\n const cHi = Math.min(opQHi, winEnd);\n if (cHi > cLo) {\n qLo = Math.min(qLo, cLo);\n qHi = Math.max(qHi, cHi);\n if (isRun) {\n const ratio = tAdv / len;\n const keptOwn = cHi - cLo;\n const keptMate = Math.round(keptOwn * ratio);\n const tEntry = Math.round(bp2 + (cLo - bp1) * ratio * revTarget);\n out.push((keptOwn << 4) | CIGAR_RUN, (keptMate << 4) | CIGAR_RUN);\n extendTarget(tEntry, tEntry + keptMate * revTarget);\n }\n else {\n out.push(((cHi - cLo) << 4) | op);\n if (isMatchOp(op)) {\n // matches map target 1:1: target(q) = bp2 + (q - bp1) * revTarget\n extendTarget(bp2 + (cLo - bp1) * revTarget, bp2 + (cHi - bp1) * revTarget);\n }\n else {\n // D/N consume no target, so it stays a point at bp2\n extendTarget(bp2, bp2);\n }\n }\n }\n }\n else if (tAdv > 0) {\n // I (or a run with no query span): target-consuming gap at a single\n // query position; keep it whole\n if (isRun) {\n out.push(packed, cigar[k]);\n }\n else {\n out.push(packed);\n }\n qLo = Math.min(qLo, bp1);\n qHi = Math.max(qHi, bp1);\n extendTarget(bp2, bp2Next);\n }\n // An op consuming NEITHER axis (H/S/P) is dropped rather than falling into\n // the arm above. It carries no coordinate on either axis, so keeping it\n // would extend qLo/qHi to a position the alignment does not occupy \u2014 and\n // on a hard clip sitting exactly at winEnd, with the preceding match\n // trimmed to nothing, that arm is the ONLY thing that collects, so the\n // clip alone would come back as a zero-width block. The walk this output\n // feeds (visitCigarRenderedSegments) has no branch for these ops either.\n }\n bp1 = bp1Next;\n bp2 = bp2Next;\n // Query ascends monotonically, so every later op has opQLo >= bp1 > winEnd\n // and cannot overlap the window \u2014 whether or not anything has been collected\n // yet. This used to also require `out.length`, which disabled the break for\n // the one input that walks longest: a block lying entirely to the RIGHT of\n // the window never collects an op, so it read every op of a multi-megabyte\n // chain to conclude what the first op already said.\n if (bp1 > winEnd) {\n break;\n }\n }\n if (out.length === 0) {\n return undefined;\n }\n return {\n start: qLo,\n end: qHi,\n mateStart: tLo,\n mateEnd: tHi,\n cigar: Uint32Array.from(out),\n };\n}\nfunction isGapOp(op) {\n return op === CIGAR_I || op === CIGAR_D || op === CIGAR_N;\n}\n/**\n * The gap-free runs of a block: the block cut at every insertion or deletion\n * of `gapBp` or more, each run re-anchored on both axes with its own ops, in\n * the shape {@link clipSyntenyFeature} answers with so a run can then be\n * clipped to a window like any block. Cut BEFORE the clip rather than after\n * it, because a clip trims a gap straddling the window edge to the part\n * inside, and a 25 kb deletion 9 kb of which is in view is still a gap. The\n * walk is the clip's own \u2014 query forward, target down for a - strand block\n * from `mateEnd` \u2014 and a run's `mateStart`/`mateEnd` are its target extent\n * in ascending order. A run is only what aligned: one holding no match or\n * coarse-run op (a stretch that is deletions alone) is dropped, and a gap at\n * either edge of the block leaves no empty run behind it.\n *\n * Wanted by a display that draws a clipped record as one straight placement\n * and has no CIGAR left to consult: a chain carrying a 25 kb indel inside the\n * window drew as one ribbon, and what it draws now is one placement per run.\n * The coarse tier keeps every indel longer than half its bound as its own op,\n * so a `gapBp` at that bound splits the same way on either tier.\n */\nexport function splitSyntenyFeatureAtGaps(cigar, start, mateStart, mateEnd, strand, gapBp) {\n const revTarget = strand === -1 ? -1 : 1;\n const runs = [];\n let bp1 = start;\n let bp2 = strand === -1 ? mateEnd : mateStart;\n let run;\n let aligned = false;\n const close = () => {\n if (run !== undefined && aligned && run.qHi > run.qLo) {\n runs.push({\n start: run.qLo,\n end: run.qHi,\n mateStart: run.tLo,\n mateEnd: run.tHi,\n cigar: Uint32Array.from(run.ops),\n });\n }\n run = undefined;\n aligned = false;\n };\n for (let k = 0; k < cigar.length; k++) {\n const packed = cigar[k];\n const len = packed >>> 4;\n const op = packed & 0xf;\n const isRun = op === CIGAR_RUN;\n const second = isRun ? cigar[++k] : undefined;\n const qAdv = isRun || consumesQuery(op) ? len : 0;\n const tAdv = second !== undefined ? second >>> 4 : consumesTarget(op) ? len : 0;\n const bp2Next = bp2 + tAdv * revTarget;\n if (isGapOp(op) && len >= gapBp) {\n close();\n }\n else if (qAdv > 0 || tAdv > 0) {\n if (run === undefined) {\n run = { qLo: bp1, qHi: bp1, tLo: bp2, tHi: bp2, ops: [] };\n }\n run.qHi = bp1 + qAdv;\n run.tLo = Math.min(run.tLo, bp2, bp2Next);\n run.tHi = Math.max(run.tHi, bp2, bp2Next);\n run.ops.push(packed);\n if (second !== undefined) {\n run.ops.push(second);\n }\n aligned = aligned || isRun || isMatchOp(op);\n }\n bp1 += qAdv;\n bp2 = bp2Next;\n }\n close();\n return runs;\n}\n// Worker glue over clipSyntenyFeature: gate on size + resolve the v1 region the\n// fetch window is over, convert the window to that region's local bp, parse\n// the CIGAR (or the coarse tier's fold of it) and clip. Returns undefined\n// (leave the block untouched) unless it is a block with an alignment string\n// more than `spanRatio`x the window on a clippable region. The clip\n// itself is region-orientation-agnostic (it walks genomic query bp forward), and\n// buildSyntenyGeometry re-derives its rev1 from the cumBp order of the clipped\n// endpoints \u2014 so a reversed v1 region only changes the cumBp->local-bp window\n// mapping below, not the clip or the downstream projection.\nexport function clipLargeBlockToWindow({ v1Index, refName, start, end, mateStart, mateEnd, strand, cigar, coarseCigar, winCumLo, winCumHi, windowSpan, spanRatio, }) {\n if ((!cigar && !coarseCigar) || end - start <= spanRatio * windowSpan) {\n return undefined;\n }\n // Re-anchor to the region this refName's fetch window falls in. A refName\n // can be displayed at several loci at once \u2014 e.g. a dispersed gene duplication\n // shows the same contig in multiple regions \u2014 so pick the region whose cumBp\n // span overlaps the window most (for the common single-region case, just that\n // region; no overlap = the block is off-screen, leave it untouched). Assumes\n // the same-refName regions are genomically DISJOINT (which the duplication\n // case is): the downstream projection re-resolves the clipped coords with\n // findRegionEntry, which picks the region their span overlaps MOST \u2014 the same\n // region we clipped to only when the genomic ranges don't overlap. Overlapping\n // copies of one locus would need a region index threaded through.\n const entries = v1Index.entries.get(refName) ?? [];\n let r0;\n let bestOverlap = 0;\n for (const e of entries) {\n const regLo = e.bpBefore;\n const regHi = e.bpBefore + (e.region.end - e.region.start);\n const overlap = Math.min(winCumHi, regHi) - Math.max(winCumLo, regLo);\n if (overlap > bestOverlap) {\n bestOverlap = overlap;\n r0 = e;\n }\n }\n if (!r0) {\n return undefined;\n }\n // Snap the window to integer bp (widen outward). winCumLo/Hi come off a\n // fetch window snapped to a pixel-derived grid, so they can carry a sub-bp\n // fraction. The\n // window is only a coarse \"which ops to include\" bound, but the clip trims\n // the boundary match op to start exactly at winStart \u2014 a fractional winStart\n // makes the whole re-anchored block's coords fractional (the op lengths stay\n // integer), rigidly shifting every tile/indel off the true integer-bp grid by\n // that fraction. At several px/bp that reads as indels landing mid-basepair,\n // misaligned vs the exact-bp LGVSyntenyDisplay. Flooring/ceiling keeps the\n // clipped block on the alignment's integer grid; the <1bp widening is well\n // inside the pan buffer.\n //\n // Invert bpToCumBp for this region's orientation. Forward: local =\n // cumBp - bpBefore + start (monotonic up). Reversed: local =\n // end - (cumBp - bpBefore) (monotonic down), so the low/high cumBp bounds map\n // to the high/low local bp \u2014 winStart takes winCumHi and winEnd winCumLo.\n //\n // Clamped to the region, because the cumBp window spans every displayed\n // region and this maps it through one of them: on a multi-region view the\n // window is wider than the region it is being expressed in, so an unclamped\n // winStart lands outside and the re-anchored block keeps an endpoint the\n // projection cannot place.\n const { region, bpBefore } = r0;\n const clampToRegion = (bp) => Math.min(Math.max(bp, region.start), region.end);\n const winStart = clampToRegion(region.reversed\n ? Math.floor(region.end - (winCumHi - bpBefore))\n : Math.floor(winCumLo - bpBefore + region.start));\n const winEnd = clampToRegion(region.reversed\n ? Math.ceil(region.end - (winCumLo - bpBefore))\n : Math.ceil(winCumHi - bpBefore + region.start));\n // A block that doesn't reach the window keeps no op \u2014 every op the walk below\n // retains has to overlap [winStart, winEnd], and the walk only ever moves\n // forward from `start` \u2014 so answer that here, before parsing a multi-megabyte\n // CIGAR string, which is exactly the size of block that reaches this function\n // at all. The window is the fetch window, so a fetched block reaches it\n // unless the same refName is displayed at several loci and the block belongs\n // to another of them.\n if (end < winStart || start > winEnd) {\n return undefined;\n }\n const ops = cigar\n ? parseCigar2Typed(cigar)\n : coarseCigar\n ? parseCoarseCigar(coarseCigar)\n : undefined;\n return ops\n ? clipSyntenyFeature(ops, start, mateStart, mateEnd, strand, winStart, winEnd)\n : undefined;\n}\n", "import { parseCigar2Typed, parseCoarseCigar } from '@jbrowse/cigar-utils';\nexport function getCigar(feature) {\n const cigar = feature.get('CIGAR');\n return typeof cigar === 'string' ? cigar : undefined;\n}\nexport function getCoarseCigar(feature) {\n const coarse = feature.get('coarseCigar');\n return typeof coarse === 'string' ? coarse : undefined;\n}\nexport function hasAlignmentString(feature) {\n return (getCigar(feature) !== undefined || getCoarseCigar(feature) !== undefined);\n}\n// the per-base CIGAR when the record carries one, else the coarse tier's fold\nexport function getAlignmentOps(feature) {\n const cigar = getCigar(feature);\n const coarse = cigar === undefined ? getCoarseCigar(feature) : undefined;\n return cigar !== undefined\n ? parseCigar2Typed(cigar)\n : coarse !== undefined\n ? parseCoarseCigar(coarse)\n : undefined;\n}\n", "import {\n clipSyntenyFeature,\n getAlignmentOps,\n splitSyntenyFeatureAtGaps,\n} from '@jbrowse/synteny-core'\n\nimport SyntenyFeature from './SyntenyFeature.ts'\n\nimport type { Feature, SimpleFeatureSerialized } from '@jbrowse/core/util'\n\ninterface Interval {\n start: number\n end: number\n}\n\ninterface ClippedIntervals extends Interval {\n mateStart: number\n mateEnd: number\n cigar?: Uint32Array\n}\n\nconst ALIGNMENT_STRING_FIELDS = ['CIGAR', 'cs', 'coarseCigar', 'cg', 'cr']\n\ntype SerializedMate = NonNullable<SimpleFeatureSerialized['mate']>\n\nfunction isMate(mate: unknown): mate is SerializedMate {\n return (\n typeof mate === 'object' &&\n mate !== null &&\n 'refName' in mate &&\n 'start' in mate &&\n 'end' in mate &&\n typeof mate.refName === 'string' &&\n typeof mate.start === 'number' &&\n typeof mate.end === 'number'\n )\n}\n\nfunction mateOf(feature: Feature) {\n const mate: unknown = feature.get('mate')\n return isMate(mate) ? mate : undefined\n}\n\n// A record with no alignment string maps its two intervals onto each other in\n// proportion, the way the synteny launch interpolates across such a block; a\n// reverse-strand record runs its mate from the far end.\nfunction interpolateClip(\n own: Interval,\n mate: Interval,\n strand: number,\n window: Interval,\n): ClippedIntervals | undefined {\n const lo = Math.max(own.start, window.start)\n const hi = Math.min(own.end, window.end)\n const ratio = (mate.end - mate.start) / Math.max(own.end - own.start, 1)\n const mateAt = (q: number) =>\n strand === -1\n ? mate.end - (q - own.start) * ratio\n : mate.start + (q - own.start) * ratio\n const a = Math.round(mateAt(lo))\n const b = Math.round(mateAt(hi))\n return hi > lo\n ? { start: lo, end: hi, mateStart: Math.min(a, b), mateEnd: Math.max(a, b) }\n : undefined\n}\n\n// A record inside the window is its own clip, and skips parsing its alignment\n// string, unless the runs or the ops are wanted, which only the string knows.\nfunction clipIntervals(\n feature: Feature,\n mate: Interval,\n window: Interval,\n splitAtGapBp: number | undefined,\n keepAlignment: boolean,\n): ClippedIntervals[] {\n const own = { start: feature.get('start'), end: feature.get('end') }\n const strand = feature.get('strand') === -1 ? -1 : 1\n const inside = own.start >= window.start && own.end <= window.end\n const ops =\n inside && splitAtGapBp === undefined && !keepAlignment\n ? undefined\n : getAlignmentOps(feature)\n if (ops === undefined) {\n const clipped = inside\n ? { ...own, mateStart: mate.start, mateEnd: mate.end }\n : interpolateClip(own, mate, strand, window)\n return clipped === undefined ? [] : [clipped]\n } else {\n const runs =\n splitAtGapBp === undefined\n ? [{ ...own, mateStart: mate.start, mateEnd: mate.end, cigar: ops }]\n : splitSyntenyFeatureAtGaps(\n ops,\n own.start,\n mate.start,\n mate.end,\n strand,\n splitAtGapBp,\n )\n return runs.flatMap(run => {\n const clipped = clipSyntenyFeature(\n run.cigar,\n run.start,\n run.mateStart,\n run.mateEnd,\n strand,\n window.start,\n window.end,\n )\n return clipped === undefined ? [] : [clipped]\n })\n }\n}\n\nfunction clippedFeature(\n feature: Feature,\n mate: SerializedMate,\n clipped: ClippedIntervals,\n window: Interval,\n run: string,\n keepAlignment: boolean,\n) {\n const suffix = `:${window.start}-${window.end}${run}`\n const source = feature.toJSON()\n const data: SimpleFeatureSerialized = {\n ...source,\n uniqueId: `${feature.id()}${suffix}`,\n start: clipped.start,\n end: clipped.end,\n mate: { ...mate, start: clipped.mateStart, end: clipped.mateEnd },\n }\n if (source.syntenyId !== undefined) {\n data.syntenyId = `${String(source.syntenyId)}${suffix}`\n }\n for (const field of ALIGNMENT_STRING_FIELDS) {\n delete data[field]\n }\n if (keepAlignment && clipped.cigar) {\n data.alignmentOps = clipped.cigar\n }\n return new SyntenyFeature(data)\n}\n\n/**\n * The pieces of one pairwise record inside `window`, on both axes: none when\n * the record misses the window, one otherwise, and with `splitAtGapBp` one per\n * gap-free run of its alignment, numbered after the window suffix so each run\n * is its own feature and its own `syntenyId` group. A piece keeps every field\n * of the record except the alignment strings; `keepAlignment` hands back its\n * own stretch of them as packed ops in `alignmentOps`. A feature with no\n * `mate` is not a pairwise record and passes through whole.\n *\n * A copy of `@jbrowse/plugin-comparative-adapters`' own, which a runtime plugin\n * cannot import: the worker serves that package as a stub too.\n */\nexport function clipFeatureToRegion(\n feature: Feature,\n window: Interval,\n splitAtGapBp?: number,\n keepAlignment = false,\n): Feature[] {\n const mate = mateOf(feature)\n if (mate === undefined) {\n return [feature]\n } else {\n const pieces = clipIntervals(\n feature,\n mate,\n window,\n splitAtGapBp,\n keepAlignment,\n )\n return pieces.map((piece, i) =>\n clippedFeature(\n feature,\n mate,\n piece,\n window,\n pieces.length > 1 ? `/${i}` : '',\n keepAlignment,\n ),\n )\n }\n}\n", "import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter'\nimport { createStatusFanOut } from '@jbrowse/core/util'\nimport { from } from 'rxjs'\nimport { map, mergeMap, toArray } from 'rxjs/operators'\n\nimport { clipFeatureToRegion } from './clipFeatureToRegion.ts'\n\nimport type { AnyConfigurationModel } from '@jbrowse/core/configuration'\nimport type { Feature } from '@jbrowse/core/util'\nimport type { AugmentedRegion as Region } from '@jbrowse/core/util/types'\nimport type { ComparativeOptions } from '@jbrowse/synteny-core'\n\n/**\n * What every adapter in this plugin answers the same way.\n *\n * `hasDataForRefName` is true unconditionally because deciding it properly is a\n * `getFeatures`, and it has to be true, or BaseFeatureDataAdapter filters the\n * track out and `getFeatures` is never called at all. The two feature\n * adapters, RgfaTabixAdapter and MinigraphBubbleAdapter, answer it the same\n * way on their own.\n *\n * Only the answers that do not depend on config live here. Anything reading a\n * slot stays in the concrete adapter, for the reason `getAssemblyNamesFromConf`\n * documents: a base generic over the config cannot prove a slot name to\n * `getConf`, so hoisting a read costs the typing that makes it worth having.\n */\nexport abstract class ComparativeAdapterBase<\n CONF extends AnyConfigurationModel = AnyConfigurationModel,\n> extends BaseFeatureDataAdapter<CONF> {\n public static capabilities = ['getFeatures', 'getRefNames']\n\n /**\n * Whether a record's two intervals are the aligned extents of one alignment,\n * which `clipToRegion` may cut at a region edge on both axes, or two genes,\n * whose extents are the genes and stay whole however the region falls.\n */\n protected readonly recordsAreAlignments: boolean = true\n\n async hasDataForRefName() {\n return true\n }\n\n /**\n * `clipToRegion`, `splitAtGapBp` and `keepAlignment` are honoured here and\n * nowhere below: `getFeatures` never sees them. A record on another assembly\n * than the region's, such as a lane pair read inside an anchor window, is in\n * no coordinates the region states, so it is split at its gaps and clipped\n * to its own extent.\n *\n * Emission is in region order, not arrival order, as core's base does: the\n * multi-way display's lane sort tie-breaks on first appearance in this list,\n * and its weights tie exactly, so arrival order would decide the stack.\n */\n getFeaturesInMultipleRegions(\n regions: Region[],\n opts: ComparativeOptions = {},\n ) {\n const { clipToRegion, splitAtGapBp, keepAlignment, ...rest } = opts\n const clip = clipToRegion && this.recordsAreAlignments\n const slot = createStatusFanOut(rest.statusCallback)\n return from(regions).pipe(\n mergeMap((region, index) =>\n this.getFeatures(region, { ...rest, statusCallback: slot() }).pipe(\n mergeMap((feature): Feature[] =>\n clip\n ? clipFeatureToRegion(\n feature,\n feature.get('assemblyName') === region.assemblyName\n ? region\n : { start: feature.get('start'), end: feature.get('end') },\n splitAtGapBp,\n keepAlignment,\n )\n : [feature],\n ),\n toArray(),\n map(features => ({ index, features })),\n ),\n ),\n toArray(),\n mergeMap(chunks =>\n chunks\n .sort((a, b) => a.index - b.index)\n .flatMap(chunk => chunk.features),\n ),\n )\n }\n}\n", "import { panSNSample } from '@jbrowse/bandage-core/pansn'\n\nimport type { ComparativeOptions } from '@jbrowse/synteny-core'\n\n/**\n * Two lanes aligned to each other inside an anchor window: records on the\n * query lane's contigs, with the target lane's walk as the mate\n */\nexport interface LanePair {\n queryAssemblyName: string\n targetAssemblyName: string\n}\n\n/**\n * `haplotypes` narrows a fetch to the lanes listed: PanSN prefixes at sample\n * (`HG002`) or haplotype (`HG002#1`) depth, or assembly names the config maps\n * to one; undefined is every haplotype.\n *\n * `queryAssemblyName` with `targetAssemblyName`, on a window of the anchor,\n * asks for that pair of lanes aligned to each other inside the window.\n */\nexport interface LaneFeatureOptions extends ComparativeOptions {\n haplotypes?: string[]\n queryAssemblyName?: string\n lanePairs?: LanePair[]\n}\n\nexport class PairTargetError extends Error {\n override name = 'PairTargetError'\n\n constructor(queryAssemblyName: string) {\n super(\n `a pair query names both lanes: queryAssemblyName ${queryAssemblyName} came without a targetAssemblyName`,\n )\n }\n}\n\n// The pairs a fetch asks for: its batch, else its one pair, else none\nexport function requestedPairs(opts: LaneFeatureOptions): LanePair[] {\n const { lanePairs, queryAssemblyName, targetAssemblyName } = opts\n if (lanePairs?.length) {\n return lanePairs\n } else if (queryAssemblyName === undefined) {\n return []\n } else if (targetAssemblyName === undefined) {\n throw new PairTargetError(queryAssemblyName)\n } else {\n return [{ queryAssemblyName, targetAssemblyName }]\n }\n}\n\n// The status a fetch of lane pairs shows while it reads\nexport function lanePairsStatus(pairs: LanePair[]) {\n const [first] = pairs\n return pairs.length === 1 && first\n ? `Reading ${first.queryAssemblyName} against ${first.targetAssemblyName}`\n : `Reading ${pairs.length} lane pairs`\n}\n\n/**\n * The lane a haplotype draws on: the JBrowse assembly the config maps to its\n * `sample#haplotype` prefix, else to its sample, else the prefix itself. The\n * fallback stays at haplotype depth, unlike the multi-genome PAF adapters',\n * because a diploid sample's two walks are two lanes.\n */\nexport function laneAssemblyName(\n asmByPrefix: Record<string, string>,\n prefix: string,\n) {\n return asmByPrefix[prefix] ?? asmByPrefix[panSNSample(prefix)] ?? prefix\n}\n", "import SyntenyFeature from './SyntenyFeature.ts'\n\nexport interface MatchSide {\n name: string\n assemblyName: string\n refName: string\n start: number\n end: number\n}\n\n/**\n * One record of a walk aligned to another, on the target walk's contig with\n * the query walk as its mate and the CIGAR read along the target, a `D` being\n * target bases the query lacks. Each side's walk name and extent make the id.\n */\nexport function matchFeature({\n target,\n query,\n strand,\n cigar,\n matches,\n columns,\n}: {\n target: MatchSide\n query: MatchSide\n strand: string\n cigar: string\n matches: number\n columns: number\n}) {\n const id = `${target.name}:${target.start}-${target.end}|${query.name}:${query.start}-${query.end}`\n return new SyntenyFeature({\n uniqueId: id,\n assemblyName: target.assemblyName,\n refName: target.refName,\n start: target.start,\n end: target.end,\n type: 'match',\n strand: strand === '-' ? -1 : 1,\n CIGAR: cigar,\n syntenyId: id,\n identity: matches / Math.max(columns, 1),\n numMatches: matches,\n blockLen: columns,\n mate: {\n refName: query.refName,\n start: query.start,\n end: query.end,\n assemblyName: query.assemblyName,\n },\n })\n}\n"],
|
|
5
|
-
"mappings": "mIA+FA,SAASA,GAAeC,EAAG,CACvB,IAAMC,EAAM,CAAC,EACTC,EAAM,EACNC,EACJ,QAASC,EAAI,EAAGC,EAAIL,EAAE,OAAQI,EAAIC,EAAGD,IAAK,CACtC,IAAME,EAAON,EAAE,WAAWI,CAAC,EAC3B,GAAIE,GAAQ,IAAMA,GAAQ,GACtBJ,EAAMA,EAAM,GAAKI,EAAO,WAEnBA,IAAS,GACdH,EAAiBD,EACjBA,EAAM,MAEL,CAGD,IAAMK,EAAKP,EAAEI,CAAC,EACVG,IAAO,KAAOA,IAAO,KAAOA,IAAO,IACnCN,EAAI,KAAK,CACL,IAAKE,IAAmB,OAAYD,EAAMC,EAC1C,KAAMD,EACN,GAAI,GACR,CAAC,EAEIK,IAAO,IACZN,EAAI,KAAK,CAAE,IAAK,EAAG,KAAMC,EAAK,GAAAK,CAAG,CAAC,GAE7BA,IAAO,KAAOA,IAAO,MAC1BN,EAAI,KAAK,CAAE,IAAKC,EAAK,KAAM,EAAG,GAAAK,CAAG,CAAC,EAEtCJ,EAAiB,OACjBD,EAAM,CACV,CACJ,CACA,OAAOD,CACX,CAiDO,SAASO,GAAmBC,EAAG,CAClC,IAAIC,EAAM,GACV,OAAW,CAAE,IAAAC,EAAK,KAAAC,EAAM,GA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,OAAQE,IAAW,IAAM,GAAK,EAC9B,MAAOC,EACP,UAAWG,EACX,SAAUF,EAAU,KAAK,IAAIC,EAAS,CAAC,EACvC,WAAYD,EACZ,SAAUC,EACV,KAAM,CACJ,QAASJ,EAAM,QACf,MAAOA,EAAM,MACb,IAAKA,EAAM,IACX,aAAcA,EAAM,YACtB,CACF,CAAC,CACH",
|
|
6
|
-
"names": ["parseCoarseOps", "s", "out", "len", "ownBeforeColon", "i", "l", "code", "op", "coarseCigarOwnAxis", "s", "out", "own", "mate", "op", "parseCoarseOps", "MAX_PACKED_LEN", "pushPacked", "len", "code", "rest", "pushRun", "chunks", "i", "o", "m", "parseCoarseCigar", "isDigit", "code", "isBaseChar", "ch", "scanBases", "cs", "start", "i", "scanDigits", "value", "forEachCsOp", "callback", "c", "next", "len", "end", "forEachCsMismatch", "cs", "callback", "windowStart", "windowEnd", "lo", "hi", "ref", "forEachCsOp", "op", "refLen", "queryLen", "seqStart", "seqEnd", "seq", "cigarToMismatches2", "ops", "seq", "ref", "qual", "roffset", "soffset", "mismatches", "hasRefAndSeq", "i", "l", "packed", "len", "op", "j", "mdToMismatches2", "mdstring", "ops", "cigarMismatches", "seq", "qual", "mismatchRecords", "opsLength", "seqLength", "hasQual", "cigarLength", "hasSkips", "k", "currStart", "lastCigar", "lastTemplateOffset", "lastRefOffset", "lastSkipPos", "i", "len", "char", "num", "c", "letter", "mismatch", "templateOffset", "refOffset", "j", "packed", "op", "s", "base", "CIGAR_CODE_TO_INDEX", "parseCigar2", "s", "currLen", "ret", "i", "l", "code", "opIndex", "CIGAR_CODE_TO_INDEX", "parseCigar2Typed", "opCount", "out", "j", "getMismatches", "cigar", "md", "seq", "ref", "qual", "ops", "mismatches", "cigarToMismatches2", "mdToMismatches2", "SyntenyFeature", "SimpleFeature", "name", "getMismatches", "cigar", "coarse", "coarseCigarOwnAxis", "callback", "opts", "start", "ws", "we", "cs", "forEachCsMismatch", "lo", "hi", "m", "extendStatics", "d", "b", "p", "__extends", "__", "__awaiter", "thisArg", "_arguments", "P", "generator", "adopt", "value", "resolve", "reject", "fulfilled", "step", "e", "rejected", "result", "__generator", "body", "_", "t", "f", "y", "g", "verb", "n", "v", "op", "__values", "o", "s", "m", "i", "__read", "n", "r", "ar", "e", "error", "__spreadArray", "to", "from", "pack", "i", "l", "ar", "__await", "v", "__asyncGenerator", "thisArg", "_arguments", "generator", "g", "q", "verb", "awaitReturn", "f", "reject", "n", "a", "b", "resume", "step", "e", "settle", "r", "fulfill", "value", "__asyncValues", "o", "m", "i", "__values", "verb", "n", "v", "resolve", "reject", "settle", "d", "isFunction", "value", "createErrorClass", "createImpl", "_super", "instance", "ctorFunc", "UnsubscriptionError", "createErrorClass", "_super", "errors", "err", "i", "arrRemove", "arr", "item", "index", "Subscription", "initialTeardown", "errors", "_parentage", "_parentage_1", "__values", "_parentage_1_1", "parent_1", "initialFinalizer", "isFunction", "e", "UnsubscriptionError", "_finalizers", "_finalizers_1", "_finalizers_1_1", "finalizer", "execFinalizer", "err", "__spreadArray", "__read", "teardown", "_a", "parent", "arrRemove", "empty", "EMPTY_SUBSCRIPTION", "Subscription", "isSubscription", "value", "isFunction", "execFinalizer", "finalizer", "config", "timeoutProvider", "handler", "timeout", "args", "_i", "delegate", "__spreadArray", "__read", "handle", "reportUnhandledError", "err", "timeoutProvider", "onUnhandledError", "config", "noop", "COMPLETE_NOTIFICATION", "createNotification", "errorNotification", "error", "nextNotification", "value", "kind", "context", "errorContext", "cb", "config", "isRoot", "_a", "errorThrown", "error", "captureError", "err", "Subscriber", "_super", "__extends", "destination", "_this", "isSubscription", "EMPTY_OBSERVER", "next", "error", "complete", "SafeSubscriber", "value", "handleStoppedNotification", "nextNotification", "err", "errorNotification", "COMPLETE_NOTIFICATION", "Subscription", "_bind", "bind", "fn", "thisArg", "ConsumerObserver", "partialObserver", "value", "error", "handleUnhandledError", "err", "SafeSubscriber", "_super", "__extends", "observerOrNext", "complete", "_this", "isFunction", "context_1", "config", "Subscriber", "handleUnhandledError", "error", "config", "captureError", "reportUnhandledError", "defaultErrorHandler", "err", "handleStoppedNotification", "notification", "subscriber", "onStoppedNotification", "timeoutProvider", "EMPTY_OBSERVER", "noop", "observable", "identity", "x", "pipeFromArray", "fns", "identity", "input", "prev", "fn", "Observable", "subscribe", "operator", "observable", "observerOrNext", "error", "complete", "_this", "subscriber", "isSubscriber", "SafeSubscriber", "errorContext", "_a", "source", "sink", "err", "next", "promiseCtor", "getPromiseCtor", "resolve", "reject", "value", "operations", "_i", "pipeFromArray", "x", "getPromiseCtor", "promiseCtor", "_a", "config", "isObserver", "value", "isFunction", "isSubscriber", "Subscriber", "isSubscription", "hasLift", "source", "isFunction", "operate", "init", "liftedSource", "err", "createOperatorSubscriber", "destination", "onNext", "onComplete", "onError", "onFinalize", "OperatorSubscriber", "_super", "__extends", "shouldUnsubscribe", "_this", "value", "err", "closed_1", "_a", "Subscriber", "isArrayLike", "x", "isPromise", "value", "isFunction", "isInteropObservable", "input", "isFunction", "observable", "isAsyncIterable", "obj", "isFunction", "createInvalidObservableTypeError", "input", "getSymbolIterator", "iterator", "isIterable", "input", "isFunction", "iterator", "readableStreamLikeToAsyncGenerator", "readableStream", "reader", "__await", "_a", "_b", "value", "done", "isReadableStreamLike", "obj", "isFunction", "innerFrom", "input", "Observable", "isInteropObservable", "fromInteropObservable", "isArrayLike", "fromArrayLike", "isPromise", "fromPromise", "isAsyncIterable", "fromAsyncIterable", "isIterable", "fromIterable", "isReadableStreamLike", "fromReadableStreamLike", "createInvalidObservableTypeError", "obj", "subscriber", "obs", "observable", "isFunction", "array", "i", "promise", "value", "err", "reportUnhandledError", "iterable", "iterable_1", "__values", "iterable_1_1", "asyncIterable", "process", "readableStream", "readableStreamLikeToAsyncGenerator", "asyncIterable_1", "__asyncValues", "asyncIterable_1_1", "executeSchedule", "parentSubscription", "scheduler", "work", "delay", "repeat", "scheduleSubscription", "observeOn", "scheduler", "delay", "operate", "source", "subscriber", "createOperatorSubscriber", "value", "executeSchedule", "err", "subscribeOn", "scheduler", "delay", "operate", "source", "subscriber", "scheduleObservable", "input", "scheduler", "innerFrom", "subscribeOn", "observeOn", "schedulePromise", "input", "scheduler", "innerFrom", "subscribeOn", "observeOn", "scheduleArray", "input", "scheduler", "Observable", "subscriber", "i", "scheduleIterable", "input", "scheduler", "Observable", "subscriber", "iterator", "executeSchedule", "value", "done", "_a", "err", "isFunction", "scheduleAsyncIterable", "input", "scheduler", "Observable", "subscriber", "executeSchedule", "iterator", "result", "scheduleReadableStreamLike", "input", "scheduler", "scheduleAsyncIterable", "readableStreamLikeToAsyncGenerator", "scheduled", "input", "scheduler", "isInteropObservable", "scheduleObservable", "isArrayLike", "scheduleArray", "isPromise", "schedulePromise", "isAsyncIterable", "scheduleAsyncIterable", "isIterable", "scheduleIterable", "isReadableStreamLike", "scheduleReadableStreamLike", "createInvalidObservableTypeError", "from", "input", "scheduler", "scheduled", "innerFrom", "map", "project", "thisArg", "operate", "source", "subscriber", "index", "createOperatorSubscriber", "value", "mergeInternals", "source", "subscriber", "project", "concurrent", "onBeforeNext", "expand", "innerSubScheduler", "additionalFinalizer", "buffer", "active", "index", "isComplete", "checkComplete", "outerNext", "value", "doInnerSub", "innerComplete", "innerFrom", "createOperatorSubscriber", "innerValue", "bufferedValue", "executeSchedule", "err", "mergeMap", "project", "resultSelector", "concurrent", "isFunction", "a", "i", "map", "b", "ii", "innerFrom", "operate", "source", "subscriber", "mergeInternals", "scanInternals", "accumulator", "seed", "hasSeed", "emitOnNext", "emitBeforeComplete", "source", "subscriber", "hasState", "state", "index", "createOperatorSubscriber", "value", "i", "reduce", "accumulator", "seed", "operate", "scanInternals", "arrReducer", "arr", "value", "toArray", "operate", "source", "subscriber", "reduce", "V1_OPS", "V2_OPS", "MATCH_OPS", "consumesQuery", "op", "consumesTarget", "isMatchOp", "clipSyntenyFeature", "cigar", "start", "mateStart", "mateEnd", "strand", "winStart", "winEnd", "revTarget", "bp1", "bp2", "out", "qLo", "qHi", "tLo", "tHi", "extendTarget", "a", "b", "k", "packed", "len", "isRun", "qAdv", "tAdv", "bp1Next", "bp2Next", "opQLo", "opQHi", "cLo", "cHi", "ratio", "keptOwn", "keptMate", "tEntry", "isGapOp", "splitSyntenyFeatureAtGaps", "gapBp", "runs", "run", "aligned", "close", "second", "getCigar", "feature", "cigar", "getCoarseCigar", "coarse", "getAlignmentOps", "feature", "cigar", "getCigar", "coarse", "getCoarseCigar", "parseCigar2Typed", "parseCoarseCigar", "ALIGNMENT_STRING_FIELDS", "isMate", "mate", "mateOf", "feature", "interpolateClip", "own", "strand", "window", "lo", "hi", "ratio", "mateAt", "q", "a", "b", "clipIntervals", "splitAtGapBp", "keepAlignment", "inside", "ops", "getAlignmentOps", "clipped", "splitSyntenyFeatureAtGaps", "run", "clipSyntenyFeature", "clippedFeature", "suffix", "source", "data", "field", "SyntenyFeature", "clipFeatureToRegion", "pieces", "piece", "i", "ComparativeAdapterBase", "BaseFeatureDataAdapter", "regions", "opts", "clipToRegion", "splitAtGapBp", "keepAlignment", "rest", "clip", "slot", "createStatusFanOut", "from", "mergeMap", "region", "index", "feature", "clipFeatureToRegion", "toArray", "map", "features", "chunks", "a", "b", "chunk", "PairTargetError", "queryAssemblyName", "requestedPairs", "opts", "lanePairs", "targetAssemblyName", "lanePairsStatus", "pairs", "first", "laneAssemblyName", "asmByPrefix", "prefix", "panSNSample", "matchFeature", "target", "query", "strand", "cigar", "matches", "columns", "id", "SyntenyFeature"]
|
|
3
|
+
"sources": ["../../node_modules/.pnpm/@jbrowse+cigar-utils@5.0.0-beta.11/node_modules/@jbrowse/cigar-utils/esm/coarseCigar.js", "../../node_modules/.pnpm/@jbrowse+cigar-utils@5.0.0-beta.11/node_modules/@jbrowse/cigar-utils/esm/csOps.js", "../../node_modules/.pnpm/@jbrowse+cigar-utils@5.0.0-beta.11/node_modules/@jbrowse/cigar-utils/esm/cigarToMismatches2.js", "../../node_modules/.pnpm/@jbrowse+cigar-utils@5.0.0-beta.11/node_modules/@jbrowse/cigar-utils/esm/mdToMismatches2.js", "../../node_modules/.pnpm/@jbrowse+cigar-utils@5.0.0-beta.11/node_modules/@jbrowse/cigar-utils/esm/mismatchParser.js", "../../src/synteny/SyntenyFeature.ts", "../../node_modules/.pnpm/tslib@2.8.1/node_modules/tslib/tslib.es6.mjs", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/util/isFunction.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/util/createErrorClass.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/util/UnsubscriptionError.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/util/arrRemove.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/Subscription.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/config.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/scheduler/timeoutProvider.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/util/reportUnhandledError.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/util/noop.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/NotificationFactories.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/util/errorContext.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/Subscriber.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/symbol/observable.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/util/identity.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/util/pipe.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/Observable.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/util/lift.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/operators/OperatorSubscriber.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/util/isArrayLike.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/util/isPromise.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/util/isInteropObservable.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/util/isAsyncIterable.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/util/throwUnobservableError.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/symbol/iterator.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/util/isIterable.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/util/isReadableStreamLike.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/observable/innerFrom.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/util/executeSchedule.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/operators/observeOn.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/operators/subscribeOn.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/scheduled/scheduleObservable.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/scheduled/schedulePromise.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/scheduled/scheduleArray.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/scheduled/scheduleIterable.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/scheduled/scheduleAsyncIterable.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/scheduled/scheduleReadableStreamLike.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/scheduled/scheduled.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/observable/from.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/operators/map.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/operators/mergeInternals.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/operators/mergeMap.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/operators/scanInternals.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/operators/reduce.ts", "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/src/internal/operators/toArray.ts", "../../node_modules/.pnpm/@jbrowse+synteny-core@5.0.0-beta.11_@emotion+react@11.14.0_@types+react@19.3.0_react@19_6b83ce7782285603d64e48e3d7c0913c/node_modules/@jbrowse/synteny-core/esm/clipSyntenyFeature.js", "../../node_modules/.pnpm/@jbrowse+synteny-core@5.0.0-beta.11_@emotion+react@11.14.0_@types+react@19.3.0_react@19_6b83ce7782285603d64e48e3d7c0913c/node_modules/@jbrowse/synteny-core/esm/featureAlignmentOps.js", "../../src/synteny/clipFeatureToRegion.ts", "../../src/synteny/ComparativeAdapterBase.ts", "../../src/synteny/lanePairs.ts", "../../src/synteny/laneZoomNotice.ts", "../../src/synteny/matchFeature.ts"],
|
|
4
|
+
"sourcesContent": ["import { CIGAR_D, CIGAR_I, CIGAR_M, CIGAR_N, CIGAR_RUN, } from './cigarConstants.js';\n/**\n * #api\n * Fold a CIGAR into a coarse CIGAR whose straight lines stay within `gap` of\n * the alignment's own path. An indel longer than half the gap keeps its letter\n * and length (D/N/I); a shorter one is absorbed into the match run around it,\n * and a run whose two axes advanced by different amounts is written\n * `<own>:<mate>M`, a square run `<n>M`. `=`/`X` count as M. `ownLen`/`mateLen`\n * are the totals each axis consumed, for the caller to check against the row's\n * coordinate columns.\n *\n * The bound: a run is closed before a folded indel would push its running\n * skew (own minus mate) past half the gap, and no folded indel is longer than\n * that, so inside a run the skew never exceeds half the gap and the line\n * between the run's corners is never more than the gap off the path. That is\n * what lets a reader interpolate within a run, and it costs a new run only\n * where the two genomes' small indels are lopsided.\n */\nexport function coarsenCigar(cigar, gap) {\n const skewBound = gap / 2;\n let ops = '';\n let ownLen = 0;\n let mateLen = 0;\n let gapCount = 0;\n let opCount = 0;\n let runOwn = 0;\n let runMate = 0;\n // a run with nothing on one side is the indel it amounts to, and is written\n // as one, so a reader never meets a zero-sided run\n const flushRun = () => {\n if (runOwn > 0 || runMate > 0) {\n ops +=\n runOwn === runMate\n ? `${runOwn}M`\n : runOwn === 0\n ? `${runMate}I`\n : runMate === 0\n ? `${runOwn}D`\n : `${runOwn}:${runMate}M`;\n opCount++;\n runOwn = 0;\n runMate = 0;\n }\n };\n const keep = (len, op) => {\n flushRun();\n ops += `${len}${op}`;\n gapCount++;\n opCount++;\n };\n const fold = (own, mate) => {\n if (Math.abs(runOwn + own - runMate - mate) > skewBound) {\n flushRun();\n }\n runOwn += own;\n runMate += mate;\n };\n let len = 0;\n for (let i = 0, l = cigar.length; i < l; i++) {\n const code = cigar.charCodeAt(i);\n if (code >= 48 && code <= 57) {\n len = len * 10 + code - 48;\n }\n else {\n const op = cigar[i];\n if (op === 'M' || op === '=' || op === 'X') {\n runOwn += len;\n runMate += len;\n ownLen += len;\n mateLen += len;\n }\n else if (op === 'D' || op === 'N') {\n ownLen += len;\n if (len > skewBound) {\n keep(len, op);\n }\n else {\n fold(len, 0);\n }\n }\n else if (op === 'I') {\n mateLen += len;\n if (len > skewBound) {\n keep(len, op);\n }\n else {\n fold(0, len);\n }\n }\n len = 0;\n }\n }\n flushRun();\n return { ops, ownLen, mateLen, gapCount, opCount };\n}\nfunction parseCoarseOps(s) {\n const out = [];\n let len = 0;\n let ownBeforeColon;\n for (let i = 0, l = s.length; i < l; i++) {\n const code = s.charCodeAt(i);\n if (code >= 48 && code <= 57) {\n len = len * 10 + code - 48;\n }\n else if (code === 58) {\n ownBeforeColon = len;\n len = 0;\n }\n else {\n // the alphabet is M I D N plus the run; a reader also takes =/X as M and\n // steps over clips and padding, which a writer never emits\n const op = s[i];\n if (op === 'M' || op === '=' || op === 'X') {\n out.push({\n own: ownBeforeColon === undefined ? len : ownBeforeColon,\n mate: len,\n op: 'M',\n });\n }\n else if (op === 'I') {\n out.push({ own: 0, mate: len, op });\n }\n else if (op === 'D' || op === 'N') {\n out.push({ own: len, mate: 0, op });\n }\n ownBeforeColon = undefined;\n len = 0;\n }\n }\n return out;\n}\nfunction serializeCoarseOps(ops) {\n let s = '';\n for (const { own, mate, op } of ops) {\n s +=\n op === 'M'\n ? own === mate\n ? `${own}M`\n : `${own}:${mate}M`\n : `${op === 'I' ? mate : own}${op}`;\n }\n return s;\n}\n// N keeps its axis as well as its letter, matching `swapIndelCigar`, which\n// swaps only D<->I\nfunction swapAxes({ own, mate, op }) {\n return op === 'N'\n ? { own, mate, op }\n : {\n own: mate,\n mate: own,\n op: op === 'D' ? 'I' : op === 'I' ? 'D' : op,\n };\n}\n/**\n * #api\n * The coarse CIGAR seen from the other axis on the plus strand: the two lengths\n * of every run trade places and D<->I swap, op order untouched. The twin of\n * `swapIndelCigar`.\n */\nexport function swapCoarseCigar(s) {\n return serializeCoarseOps(parseCoarseOps(s).map(swapAxes));\n}\n/**\n * #api\n * The coarse CIGAR seen from the other axis on the minus strand: swapped as\n * `swapCoarseCigar` does, and in reverse op order. The twin of `flipCigar`.\n */\nexport function flipCoarseCigar(s) {\n return serializeCoarseOps(parseCoarseOps(s).map(swapAxes).reverse());\n}\n/**\n * #api\n * The coarse CIGAR as a plain CIGAR over the row's own axis, for a walk that\n * places mismatches by reference position: a run keeps only its own length, a\n * run with no own length is the insertion it amounts to, and one with no mate\n * length the deletion. Kept indels are exact, so they land where the fine\n * tier's would.\n */\nexport function coarseCigarOwnAxis(s) {\n let out = '';\n for (const { own, mate, op } of parseCoarseOps(s)) {\n out +=\n op === 'M'\n ? own === 0\n ? `${mate}I`\n : mate === 0\n ? `${own}D`\n : `${own}M`\n : `${op === 'I' ? mate : own}${op}`;\n }\n return out;\n}\n// The packed form keeps 28 bits of length, so a longer op is written as several\n// words that sum to it. A run is split with both axes in proportion.\nconst MAX_PACKED_LEN = 2 ** 28 - 1;\nfunction pushPacked(out, len, code) {\n for (let rest = len; rest > 0; rest -= MAX_PACKED_LEN) {\n out.push(((Math.min(rest, MAX_PACKED_LEN) << 4) | code) >>> 0);\n }\n}\nfunction pushRun(out, own, mate) {\n if (own === mate) {\n pushPacked(out, own, CIGAR_M);\n }\n else {\n const chunks = Math.ceil(Math.max(own, mate) / MAX_PACKED_LEN);\n for (let i = 0; i < chunks; i++) {\n const o = Math.floor((own * (i + 1)) / chunks) - Math.floor((own * i) / chunks);\n const m = Math.floor((mate * (i + 1)) / chunks) - Math.floor((mate * i) / chunks);\n out.push(((o << 4) | CIGAR_RUN) >>> 0, ((m << 4) | CIGAR_RUN) >>> 0);\n }\n }\n}\n/**\n * #api\n * Parse a coarse CIGAR into the packed `(len << 4) | op` form\n * `visitCigarRenderedSegments` walks. A square run packs as one `CIGAR_M`\n * word; an unequal run as a `CIGAR_RUN` word pair, own axis first.\n */\nexport function parseCoarseCigar(s) {\n const out = [];\n for (const { own, mate, op } of parseCoarseOps(s)) {\n if (op === 'M') {\n pushRun(out, own, mate);\n }\n else if (op === 'I') {\n pushPacked(out, mate, CIGAR_I);\n }\n else {\n pushPacked(out, own, op === 'N' ? CIGAR_N : CIGAR_D);\n }\n }\n return Uint32Array.from(out);\n}\n", "import { DELETION_TYPE, INSERTION_TYPE, MISMATCH_TYPE, SKIP_TYPE, } from './mismatchCallback.js';\nfunction isDigit(code) {\n return code >= 48 && code <= 57;\n}\nfunction isBaseChar(ch) {\n return ch !== undefined && /[A-Za-z]/.test(ch);\n}\nfunction scanBases(cs, start) {\n let i = start;\n while (i < cs.length && isBaseChar(cs[i])) {\n i++;\n }\n return i;\n}\nfunction scanDigits(cs, start) {\n let i = start;\n let value = 0;\n while (i < cs.length && isDigit(cs.charCodeAt(i))) {\n value = value * 10 + (cs.charCodeAt(i) - 48);\n i++;\n }\n return { value, next: i };\n}\n/**\n * Walk a minimap2 `cs` difference string\n * (https://github.com/lh3/minimap2#cs), calling `callback` once per operation.\n *\n * Short form is `:N` match run, `*ab` substitution (ref base a, query base b),\n * `+seq` insertion, `-seq` deletion; long form adds `=SEQ` match runs; `~ab12cd`\n * is a 12 bp intron between the given splice motifs. A character belonging to\n * none of those is skipped, so a truncated or extended string still walks to the\n * end rather than throwing.\n *\n * `refLen`/`queryLen` are the bases the operation consumes on each sequence, and\n * `[seqStart, seqEnd)` bounds its operand *within `cs`* \u2014 the bases for `=`/`+`/\n * `-`, the two substituted bases for `*`, the digits for `:`, the whole motif\n * for `~`. Offsets rather than a substring because the mismatch walk runs per\n * feature per frame, and only two of six ops ever need the text.\n *\n * **One walker, because four disagreed.** This replaces a copy in each of\n * `csToCigar`, `flipCs`, `forEachCsMismatch` and the (now removed) `visitCsOps`,\n * and every one of the divergences was silent: two of them dropped `~` and then\n * mis-scanned the rest of the string, one ignored `=SEQ` entirely and so never\n * advanced the reference across a long-form match run, and the three that\n * scanned `+`/`-` operands disagreed on where one ends.\n */\nexport function forEachCsOp(cs, callback) {\n let i = 0;\n while (i < cs.length) {\n const c = cs[i];\n if (c === ':') {\n const { value, next } = scanDigits(cs, i + 1);\n callback(':', value, value, i + 1, next);\n i = next;\n }\n else if (c === '=') {\n const next = scanBases(cs, i + 1);\n const len = next - i - 1;\n callback('=', len, len, i + 1, next);\n i = next;\n }\n else if (c === '*') {\n callback('*', 1, 1, i + 1, Math.min(i + 3, cs.length));\n i += 3;\n }\n else if (c === '+' || c === '-') {\n const next = scanBases(cs, i + 1);\n const len = next - i - 1;\n callback(c, c === '-' ? len : 0, c === '+' ? len : 0, i + 1, next);\n i = next;\n }\n else if (c === '~') {\n // the length sits between two 2-base splice motifs\n const { value, next } = scanDigits(cs, i + 3);\n const end = Math.min(next + 2, cs.length);\n callback('~', value, 0, i + 1, end);\n i = end;\n }\n else {\n i++;\n }\n }\n}\n/**\n * Rewrite a cs string from the target perspective to the query perspective (for\n * a synteny view anchored on the query assembly): `*ab` -> `*ba`, `+seq` ->\n * `-seq`, `-seq` -> `+seq`, match runs unchanged.\n *\n * Undefined when the string states something the query perspective cannot: an\n * intron is a gap in the *reference*, and flipped it becomes a gap in the query\n * with no sequence to write for it, which cs has no way to express. Callers fall\n * back to the CIGAR there, the same as they already do for reverse-strand\n * alignments (which additionally need a reverse-complement).\n */\nexport function flipCs(cs) {\n // The one op with no query-perspective form, and cs writes it nowhere else \u2014\n // operands are base letters. Answered before the walk so the rewrite below is\n // total.\n if (cs.includes('~')) {\n return undefined;\n }\n let result = '';\n forEachCsOp(cs, (op, refLen, _queryLen, seqStart, seqEnd) => {\n if (op === ':') {\n result += `:${refLen}`;\n }\n else if (op === '=') {\n result += `=${cs.slice(seqStart, seqEnd)}`;\n }\n else if (op === '*') {\n result += `*${cs[seqStart + 1] ?? ''}${cs[seqStart] ?? ''}`;\n }\n else {\n result += `${op === '+' ? '-' : '+'}${cs.slice(seqStart, seqEnd)}`;\n }\n });\n return result;\n}\n/**\n * Walk a cs string and drive a {@link MismatchCallback} (the contract BAM/CRAM\n * features use), emitting per-base substitutions with their real query base plus\n * insertions, deletions and introns. Offsets are relative to the reference\n * (feature) start; `windowStart`/`windowEnd` (also reference-relative) clip the\n * output.\n */\nexport function forEachCsMismatch(cs, callback, windowStart, windowEnd) {\n const lo = windowStart ?? Number.NEGATIVE_INFINITY;\n const hi = windowEnd ?? Number.POSITIVE_INFINITY;\n let ref = 0;\n forEachCsOp(cs, (op, refLen, queryLen, seqStart, seqEnd) => {\n if (op === '*') {\n if (ref >= lo && ref < hi) {\n callback(MISMATCH_TYPE, ref, 1, cs[seqStart + 1] ?? '', -1, 0, 0);\n }\n }\n else if (op === '+') {\n if (ref >= lo && ref <= hi) {\n const seq = cs.slice(seqStart, seqEnd);\n callback(INSERTION_TYPE, ref, queryLen, seq, -1, 0, queryLen);\n }\n }\n else if (op === '-' || op === '~') {\n if (ref < hi && ref + refLen > lo) {\n // an intron is a reference gap the read skips rather than deletes, and\n // the two draw differently\n const type = op === '-' ? DELETION_TYPE : SKIP_TYPE;\n callback(type, ref, refLen, '', -1, 0, 0);\n }\n }\n ref += refLen;\n });\n}\n", "import { CIGAR_D, CIGAR_EQ, CIGAR_H, CIGAR_I, CIGAR_M, CIGAR_N, CIGAR_S, CIGAR_X, } from './cigarConstants.js';\n// Handles packed NUMERIC_CIGAR format from @gmod/bam\n// Format: Uint32Array where each value is (length << 4) | opIndex\n// opIndex is 0-8: M=0, I=1, D=2, N=3, S=4, H=5, P=6, ==7, X=8\nexport function cigarToMismatches2(ops, seq, ref, qual) {\n let roffset = 0;\n let soffset = 0;\n const mismatches = [];\n const hasRefAndSeq = ref && seq;\n for (let i = 0, l = ops.length; i < l; i++) {\n const packed = ops[i];\n const len = packed >>> 4;\n const op = packed & 0xf;\n if (op === CIGAR_M || op === CIGAR_EQ) {\n if (hasRefAndSeq) {\n for (let j = 0; j < len; j++) {\n if ((seq.charCodeAt(soffset + j) | 0x20) !==\n (ref.charCodeAt(roffset + j) | 0x20)) {\n mismatches.push({\n start: roffset + j,\n type: 'mismatch',\n base: seq[soffset + j],\n altbase: ref[roffset + j],\n length: 1,\n });\n }\n }\n }\n soffset += len;\n roffset += len;\n }\n else if (op === CIGAR_I) {\n mismatches.push({\n start: roffset,\n type: 'insertion',\n insertlen: len,\n insertedBases: seq?.slice(soffset, soffset + len),\n length: 0,\n });\n soffset += len;\n }\n else if (op === CIGAR_D) {\n mismatches.push({\n start: roffset,\n type: 'deletion',\n length: len,\n });\n roffset += len;\n }\n else if (op === CIGAR_N) {\n mismatches.push({\n start: roffset,\n type: 'skip',\n length: len,\n });\n roffset += len;\n }\n else if (op === CIGAR_X) {\n for (let j = 0; j < len; j++) {\n mismatches.push({\n start: roffset + j,\n type: 'mismatch',\n base: seq?.[soffset + j] || 'X',\n qual: qual?.[soffset + j],\n length: 1,\n });\n }\n soffset += len;\n roffset += len;\n }\n else if (op === CIGAR_H) {\n mismatches.push({\n start: roffset,\n type: 'hardclip',\n cliplen: len,\n length: 1,\n });\n }\n else if (op === CIGAR_S) {\n mismatches.push({\n start: roffset,\n type: 'softclip',\n cliplen: len,\n length: 1,\n });\n soffset += len;\n }\n }\n return mismatches;\n}\n", "import { CIGAR_D, CIGAR_H, CIGAR_I, CIGAR_N, CIGAR_P, CIGAR_S, } from './cigarConstants.js';\n// Handles packed NUMERIC_CIGAR format from @gmod/bam\n// Format: Uint32Array where each value is (length << 4) | opIndex\n// opIndex is 0-8: M=0, I=1, D=2, N=3, S=4, H=5, P=6, ==7, X=8\nexport function mdToMismatches2(mdstring, ops, cigarMismatches, seq, qual) {\n if (!ops) {\n return [];\n }\n const mismatchRecords = [];\n const opsLength = ops.length;\n const seqLength = seq.length;\n const hasQual = qual !== undefined;\n // only check for skips if cigarMismatches has any\n const cigarLength = cigarMismatches.length;\n let hasSkips = false;\n for (let k = 0; k < cigarLength; k++) {\n if (cigarMismatches[k].type === 'skip') {\n hasSkips = true;\n break;\n }\n }\n let currStart = 0;\n let lastCigar = 0;\n let lastTemplateOffset = 0;\n let lastRefOffset = 0;\n let lastSkipPos = 0;\n // parse the MD string manually for better performance\n let i = 0;\n const len = mdstring.length;\n while (i < len) {\n const char = mdstring.charCodeAt(i);\n if (char >= 48 && char <= 57) {\n // digit (0-9)\n let num = 0;\n while (i < len) {\n const c = mdstring.charCodeAt(i);\n if (c >= 48 && c <= 57) {\n num = num * 10 + (c - 48);\n i++;\n }\n else {\n break;\n }\n }\n currStart += num;\n }\n else if (char === 94) {\n // '^' - deletion\n i++;\n while (i < len && mdstring.charCodeAt(i) >= 65) {\n // skip deleted bases (A-Z, a-z)\n i++;\n currStart++;\n }\n }\n else if (char >= 65) {\n // letter (mismatch)\n const letter = mdstring[i];\n i++;\n // handle skips in cigar\n if (hasSkips && cigarLength > 0) {\n for (let k = lastSkipPos; k < cigarLength; k++) {\n const mismatch = cigarMismatches[k];\n if (mismatch.type === 'skip' && currStart >= mismatch.start) {\n currStart += mismatch.length;\n lastSkipPos = k + 1;\n }\n }\n }\n // find position in read that corresponds to currStart\n let templateOffset = lastTemplateOffset;\n let refOffset = lastRefOffset;\n // Packed format: each element is (length << 4) | opIndex\n for (let j = lastCigar; j < opsLength && refOffset <= currStart; j++, lastCigar = j) {\n const packed = ops[j];\n const len = packed >>> 4;\n const op = packed & 0xf;\n if (op === CIGAR_S || op === CIGAR_I) {\n templateOffset += len;\n }\n else if (op === CIGAR_D || op === CIGAR_P || op === CIGAR_N) {\n refOffset += len;\n }\n else if (op !== CIGAR_H) {\n templateOffset += len;\n refOffset += len;\n }\n }\n lastTemplateOffset = templateOffset;\n lastRefOffset = refOffset;\n const s = templateOffset - (refOffset - currStart);\n const base = s < seqLength ? seq[s] : 'X';\n mismatchRecords.push({\n start: currStart,\n base,\n qual: hasQual ? qual[s] : undefined,\n altbase: letter,\n length: 1,\n type: 'mismatch',\n });\n currStart++;\n }\n else {\n i++;\n }\n }\n return mismatchRecords;\n}\n", "import { CIGAR_D, CIGAR_H, CIGAR_I, CIGAR_N, CIGAR_S, } from './cigarConstants.js';\nimport { cigarToMismatches2 } from './cigarToMismatches2.js';\nimport { mdToMismatches2 } from './mdToMismatches2.js';\n// CIGAR operation char codes to indices (from BAM spec)\nconst CIGAR_CODE_TO_INDEX = {\n 77: 0, // M\n 73: 1, // I\n 68: 2, // D\n 78: 3, // N\n 83: 4, // S\n 72: 5, // H\n 80: 6, // P\n 61: 7, // =\n 88: 8, // X\n};\n/**\n * #api\n * Parses a CIGAR string to an alternating `[length, op, ...]` string array.\n */\nexport function parseCigar(s = '') {\n let currLen = '';\n const ret = [];\n for (let i = 0, l = s.length; i < l; i++) {\n const c = s[i];\n if (c >= '0' && c <= '9') {\n currLen = currLen + c;\n }\n else {\n ret.push(currLen, c);\n currLen = '';\n }\n }\n return ret;\n}\n/**\n * #api\n * Parses a CIGAR string to a packed number array where each value is\n * `(length << 4) | opIndex`.\n */\nexport function parseCigar2(s = '') {\n let currLen = 0;\n const ret = [];\n for (let i = 0, l = s.length; i < l; i++) {\n const code = s.charCodeAt(i);\n if (code >= 48 && code <= 57) {\n currLen = currLen * 10 + (code - 48);\n }\n else {\n const opIndex = CIGAR_CODE_TO_INDEX[code];\n ret.push((currLen << 4) | opIndex);\n currLen = 0;\n }\n }\n return ret;\n}\n/**\n * #api\n * Same encoding as `parseCigar2` but writes into a packed `Uint32Array` \u2014\n * matches the NUMERIC_CIGAR format that BAM/CRAM adapters emit, so consumers can\n * use a single typed-array code path.\n */\nexport function parseCigar2Typed(s = '') {\n let opCount = 0;\n for (let i = 0, l = s.length; i < l; i++) {\n const code = s.charCodeAt(i);\n if (code < 48 || code > 57) {\n opCount++;\n }\n }\n const out = new Uint32Array(opCount);\n let currLen = 0;\n let j = 0;\n for (let i = 0, l = s.length; i < l; i++) {\n const code = s.charCodeAt(i);\n if (code >= 48 && code <= 57) {\n currLen = currLen * 10 + (code - 48);\n }\n else {\n out[j++] = (currLen << 4) | CIGAR_CODE_TO_INDEX[code];\n currLen = 0;\n }\n }\n return out;\n}\n/**\n * #api\n * Computes the list of mismatches (SNVs, indels, clips, skips) for a read from\n * its CIGAR, optional MD tag, sequence, reference, and quality.\n */\nexport function getMismatches(cigar, md, seq, ref, qual) {\n const ops = parseCigar2(cigar);\n const mismatches = cigar ? cigarToMismatches2(ops, seq, ref, qual) : [];\n if (md && seq) {\n return mismatches.concat(mdToMismatches2(md, ops, mismatches, seq, qual));\n }\n return mismatches;\n}\n// All three lengths in one pass over already-parsed ops: callers that want more\n// than one (featurizeSA wants all three) would otherwise re-scan and re-allocate\n// the op array per length.\nfunction cigarLengths(ops) {\n let lengthOnRef = 0;\n let length = 0;\n let lengthSansClipping = 0;\n for (let i = 0, l = ops.length; i < l; i++) {\n const op = ops[i];\n const opIdx = op & 0xf;\n const len = op >>> 4;\n const clipping = opIdx === CIGAR_H || opIdx === CIGAR_S;\n const refOnly = opIdx === CIGAR_D || opIdx === CIGAR_N;\n if (!clipping && opIdx !== CIGAR_I) {\n lengthOnRef += len;\n }\n if (!refOnly) {\n length += len;\n }\n if (!clipping && !refOnly) {\n lengthSansClipping += len;\n }\n }\n return { lengthOnRef, length, lengthSansClipping };\n}\n/**\n * #api\n * Length the read spans on the reference (sum of M/=/X/D/N ops).\n */\nexport function getLengthOnRef(cigar) {\n return cigarLengths(parseCigar2(cigar)).lengthOnRef;\n}\n/**\n * #api\n * Length of the read sequence (sum of all ops except D/N).\n */\nexport function getLength(cigar) {\n return cigarLengths(parseCigar2(cigar)).length;\n}\nexport function getLengthSansClipping(cigar) {\n return cigarLengths(parseCigar2(cigar)).lengthSansClipping;\n}\n// clip at the end of the CIGAR string = start of a reverse-strand read,\n// clip at the start of the CIGAR string = start of a forward-strand read\nexport function getClip(cigar, strand) {\n if (!cigar) {\n return 0;\n }\n if (strand === -1) {\n const last = cigar.length - 1;\n const op = cigar[last];\n if (op === 'S' || op === 'H') {\n let i = last;\n while (i > 0 && cigar[i - 1] >= '0' && cigar[i - 1] <= '9') {\n i--;\n }\n return +cigar.slice(i, last);\n }\n return 0;\n }\n else {\n let i = 0;\n while (cigar[i] >= '0' && cigar[i] <= '9') {\n i++;\n }\n const op = cigar[i];\n return (op === 'S' || op === 'H') && i > 0 ? +cigar.slice(0, i) : 0;\n }\n}\n// numeric analog of getClip: reads the start-clip length straight off a packed\n// NUMERIC_CIGAR (each entry = (length << 4) | opIndex) without serializing to a\n// CIGAR string. Reverse-strand reads clip at the CIGAR tail, forward at the head.\nexport function clipLengthAtStartOfReadNumeric(cigar, strand) {\n const len = cigar.length;\n if (len === 0) {\n return 0;\n }\n const packed = strand === -1 ? cigar[len - 1] : cigar[0];\n const op = packed & 0xf;\n return op === CIGAR_S || op === CIGAR_H ? packed >>> 4 : 0;\n}\n// produces a list of \"feature-like\" object from parsing supplementary\n// alignments in the SA tag\n//\n// @param normalize - used specifically in the linear-read-vs-ref context, it\n// flips features around relative to the original feature. other contexts of\n// usage can keep this false\nexport function featurizeSA(SA, id, strand, readName, normalize) {\n return SA === undefined\n ? []\n : featurizeSAEntries(splitSA(SA), id, strand, readName, normalize);\n}\n/**\n * #api\n * The `;`-separated alignment records of an SA tag, empties dropped \u2014 the input\n * `featurizeSAEntries` expects.\n */\nexport function splitSA(SA) {\n return SA.split(';').filter(aln => !!aln);\n}\n/**\n * #api\n * featurizeSA over pre-split entries (see splitSA). Lets a caller filter the\n * entries first \u2014 e.g. deduplicating the records repeated across a split read's\n * segments \u2014 without paying to split and rejoin the tag around the filter.\n */\nexport function featurizeSAEntries(entries, id, strand, readName, normalize) {\n const strandNum = strand ?? 1;\n return entries.map((aln, index) => {\n const ret = aln.split(',');\n const saRef = ret[0];\n const saStart = ret[1];\n const saStrand = ret[2];\n const saCigar = ret[3];\n const saOps = parseCigar2(saCigar);\n const { lengthOnRef: saLengthOnRef, length: saLength, lengthSansClipping: saLengthSansClipping, } = cigarLengths(saOps);\n const saStrandNormalized = saStrand === '-' ? -1 : 1;\n const effectiveStrand = normalize\n ? strandNum === saStrandNormalized\n ? 1\n : -1\n : saStrandNormalized;\n const saClipPos = clipLengthAtStartOfReadNumeric(saOps, effectiveStrand);\n const saRealStart = +saStart - 1;\n return {\n refName: saRef,\n start: saRealStart,\n end: saRealStart + saLengthOnRef,\n seqLength: saLength,\n clipLengthAtStartOfRead: saClipPos,\n CIGAR: saCigar,\n strand: effectiveStrand,\n uniqueId: `${id}_SA${index}`,\n mate: {\n start: saClipPos,\n end: saClipPos + saLengthSansClipping,\n refName: readName,\n },\n };\n });\n}\n", "import {\n DELETION_TYPE,\n INSERTION_TYPE,\n MISMATCH_TYPE,\n SKIP_TYPE,\n coarseCigarOwnAxis,\n forEachCsMismatch,\n getMismatches,\n} from '@jbrowse/cigar-utils'\nimport { SimpleFeature } from '@jbrowse/core/util'\n\nimport type { MismatchCallback, MismatchWindow } from '@jbrowse/cigar-utils'\nimport type { Feature } from '@jbrowse/core/util'\n\n// Implementing forEachMismatch lets synteny features flow through the alignments\n// GPU/Canvas2D mismatch pipeline (LGVSyntenyDisplay reuses it), rendering\n// per-base SNPs and indels. Prefer the cs tag (real query bases); fall back to\n// the CIGAR (positions only, no base identity for X ops).\nexport default class SyntenyFeature extends SimpleFeature {\n get(name: 'mismatches'): ReturnType<typeof getMismatches>\n get(name: 'refName'): string\n get(name: 'name' | 'type' | 'id' | 'source'): string | undefined\n get(name: 'start' | 'end' | 'clipLengthAtStartOfRead'): number\n get(name: 'phase'): 0 | 1 | 2 | undefined\n get(name: 'strand'): -1 | 0 | 1 | undefined\n get(name: 'score'): number | undefined\n get(name: 'subfeatures'): Feature[] | undefined\n get(name: string): unknown\n get(name: string): unknown {\n if (name === 'mismatches') {\n return getMismatches(this.walkableCigar)\n } else if (name === 'clipLengthAtStartOfRead') {\n return this.clipLengthAtStartOfRead\n } else if (name === 'name') {\n return super.get('name') ?? this.mate?.refName\n } else {\n return super.get(name)\n }\n }\n\n private get mate() {\n return super.get('mate') as { refName?: string; start?: number } | undefined\n }\n\n // The CIGAR, or on the coarse tier its fold read along this row's own axis,\n // so a kept indel places itself where the fine tier's would; the runs' mate\n // lengths mean nothing to a reference-anchored mismatch walk.\n private get walkableCigar() {\n const cigar = super.get('CIGAR')\n const coarse = super.get('coarseCigar')\n return typeof cigar === 'string'\n ? cigar\n : typeof coarse === 'string'\n ? coarseCigarOwnAxis(coarse)\n : undefined\n }\n\n // The block's offset along the other sequence, i.e. what a soft clip is to a\n // read: the position the alignments chain builder sorts a name's blocks by,\n // so a contig's blocks chain in contig order rather than fetch order. A PAF\n // CIGAR carries no clip of its own.\n get clipLengthAtStartOfRead() {\n return this.mate?.start ?? 0\n }\n\n forEachMismatch(callback: MismatchCallback, opts?: MismatchWindow) {\n const start = this.get('start')\n const ws = opts?.start === undefined ? undefined : opts.start - start\n const we = opts?.end === undefined ? undefined : opts.end - start\n const cs = this.get('cs') as string | undefined\n if (cs) {\n forEachCsMismatch(cs, callback, ws, we)\n } else {\n const lo = ws ?? Number.NEGATIVE_INFINITY\n const hi = we ?? Number.POSITIVE_INFINITY\n for (const m of getMismatches(this.walkableCigar)) {\n // Deletions and skips are spans, so one that starts left of the window\n // but reaches into it still draws \u2014 the overlap test the cs path and\n // BAM's forEachMismatchNumeric both apply. Clipping them on start\n // alone made a deletion larger than the viewport vanish exactly when\n // zoomed into it.\n const visible =\n m.type === 'deletion' || m.type === 'skip'\n ? m.start < hi && m.start + m.length > lo\n : m.start >= lo && m.start <= hi\n if (visible) {\n if (m.type === 'mismatch') {\n callback(\n MISMATCH_TYPE,\n m.start,\n m.length,\n m.base,\n m.qual ?? -1,\n 0,\n 0,\n )\n } else if (m.type === 'insertion') {\n callback(\n INSERTION_TYPE,\n m.start,\n m.length,\n m.insertedBases ?? '',\n -1,\n 0,\n m.insertlen,\n )\n } else if (m.type === 'deletion') {\n callback(DELETION_TYPE, m.start, m.length, '', -1, 0, 0)\n } else if (m.type === 'skip') {\n callback(SKIP_TYPE, m.start, m.length, '', -1, 0, 0)\n }\n }\n }\n }\n }\n}\n", "/******************************************************************************\nCopyright (c) Microsoft Corporation.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\n/* global Reflect, Promise, SuppressedError, Symbol, Iterator */\n\nvar extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n};\n\nexport function __extends(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n}\n\nexport var __assign = function() {\n __assign = Object.assign || function __assign(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\n }\n return t;\n }\n return __assign.apply(this, arguments);\n}\n\nexport function __rest(s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n}\n\nexport function __decorate(decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n}\n\nexport function __param(paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n}\n\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\n var _, done = false;\n for (var i = decorators.length - 1; i >= 0; i--) {\n var context = {};\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\n if (kind === \"accessor\") {\n if (result === void 0) continue;\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\n if (_ = accept(result.get)) descriptor.get = _;\n if (_ = accept(result.set)) descriptor.set = _;\n if (_ = accept(result.init)) initializers.unshift(_);\n }\n else if (_ = accept(result)) {\n if (kind === \"field\") initializers.unshift(_);\n else descriptor[key] = _;\n }\n }\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\n done = true;\n};\n\nexport function __runInitializers(thisArg, initializers, value) {\n var useValue = arguments.length > 2;\n for (var i = 0; i < initializers.length; i++) {\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\n }\n return useValue ? value : void 0;\n};\n\nexport function __propKey(x) {\n return typeof x === \"symbol\" ? x : \"\".concat(x);\n};\n\nexport function __setFunctionName(f, name, prefix) {\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\n};\n\nexport function __metadata(metadataKey, metadataValue) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\n}\n\nexport function __awaiter(thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n}\n\nexport function __generator(thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === \"function\" ? Iterator : Object).prototype);\n return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n}\n\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n});\n\nexport function __exportStar(m, o) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\n}\n\nexport function __values(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n}\n\nexport function __read(o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n}\n\n/** @deprecated */\nexport function __spread() {\n for (var ar = [], i = 0; i < arguments.length; i++)\n ar = ar.concat(__read(arguments[i]));\n return ar;\n}\n\n/** @deprecated */\nexport function __spreadArrays() {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n}\n\nexport function __spreadArray(to, from, pack) {\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n if (ar || !(i in from)) {\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n ar[i] = from[i];\n }\n }\n return to.concat(ar || Array.prototype.slice.call(from));\n}\n\nexport function __await(v) {\n return this instanceof __await ? (this.v = v, this) : new __await(v);\n}\n\nexport function __asyncGenerator(thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = Object.create((typeof AsyncIterator === \"function\" ? AsyncIterator : Object).prototype), verb(\"next\"), verb(\"throw\"), verb(\"return\", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;\n function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }\n function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n}\n\nexport function __asyncDelegator(o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\n}\n\nexport function __asyncValues(o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n}\n\nexport function __makeTemplateObject(cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n};\n\nvar __setModuleDefault = Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n};\n\nvar ownKeys = function(o) {\n ownKeys = Object.getOwnPropertyNames || function (o) {\n var ar = [];\n for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;\n return ar;\n };\n return ownKeys(o);\n};\n\nexport function __importStar(mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== \"default\") __createBinding(result, mod, k[i]);\n __setModuleDefault(result, mod);\n return result;\n}\n\nexport function __importDefault(mod) {\n return (mod && mod.__esModule) ? mod : { default: mod };\n}\n\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n}\n\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\n}\n\nexport function __classPrivateFieldIn(state, receiver) {\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\n}\n\nexport function __addDisposableResource(env, value, async) {\n if (value !== null && value !== void 0) {\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\n var dispose, inner;\n if (async) {\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\n dispose = value[Symbol.asyncDispose];\n }\n if (dispose === void 0) {\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\n dispose = value[Symbol.dispose];\n if (async) inner = dispose;\n }\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\n if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };\n env.stack.push({ value: value, dispose: dispose, async: async });\n }\n else if (async) {\n env.stack.push({ async: true });\n }\n return value;\n}\n\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\n var e = new Error(message);\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\n};\n\nexport function __disposeResources(env) {\n function fail(e) {\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\n env.hasError = true;\n }\n var r, s = 0;\n function next() {\n while (r = env.stack.pop()) {\n try {\n if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);\n if (r.dispose) {\n var result = r.dispose.call(r.value);\n if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\n }\n else s |= 1;\n }\n catch (e) {\n fail(e);\n }\n }\n if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();\n if (env.hasError) throw env.error;\n }\n return next();\n}\n\nexport function __rewriteRelativeImportExtension(path, preserveJsx) {\n if (typeof path === \"string\" && /^\\.\\.?\\//.test(path)) {\n return path.replace(/\\.(tsx)$|((?:\\.d)?)((?:\\.[^./]+?)?)\\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {\n return tsx ? preserveJsx ? \".jsx\" : \".js\" : d && (!ext || !cm) ? m : (d + ext + \".\" + cm.toLowerCase() + \"js\");\n });\n }\n return path;\n}\n\nexport default {\n __extends,\n __assign,\n __rest,\n __decorate,\n __param,\n __esDecorate,\n __runInitializers,\n __propKey,\n __setFunctionName,\n __metadata,\n __awaiter,\n __generator,\n __createBinding,\n __exportStar,\n __values,\n __read,\n __spread,\n __spreadArrays,\n __spreadArray,\n __await,\n __asyncGenerator,\n __asyncDelegator,\n __asyncValues,\n __makeTemplateObject,\n __importStar,\n __importDefault,\n __classPrivateFieldGet,\n __classPrivateFieldSet,\n __classPrivateFieldIn,\n __addDisposableResource,\n __disposeResources,\n __rewriteRelativeImportExtension,\n};\n", "/**\n * Returns true if the object is a function.\n * @param value The value to check\n */\nexport function isFunction(value: any): value is (...args: any[]) => any {\n return typeof value === 'function';\n}\n", "/**\n * Used to create Error subclasses until the community moves away from ES5.\n *\n * This is because compiling from TypeScript down to ES5 has issues with subclassing Errors\n * as well as other built-in types: https://github.com/Microsoft/TypeScript/issues/12123\n *\n * @param createImpl A factory function to create the actual constructor implementation. The returned\n * function should be a named function that calls `_super` internally.\n */\nexport function createErrorClass<T>(createImpl: (_super: any) => any): T {\n const _super = (instance: any) => {\n Error.call(instance);\n instance.stack = new Error().stack;\n };\n\n const ctorFunc = createImpl(_super);\n ctorFunc.prototype = Object.create(Error.prototype);\n ctorFunc.prototype.constructor = ctorFunc;\n return ctorFunc;\n}\n", "import { createErrorClass } from './createErrorClass';\n\nexport interface UnsubscriptionError extends Error {\n readonly errors: any[];\n}\n\nexport interface UnsubscriptionErrorCtor {\n /**\n * @deprecated Internal implementation detail. Do not construct error instances.\n * Cannot be tagged as internal: https://github.com/ReactiveX/rxjs/issues/6269\n */\n new (errors: any[]): UnsubscriptionError;\n}\n\n/**\n * An error thrown when one or more errors have occurred during the\n * `unsubscribe` of a {@link Subscription}.\n */\nexport const UnsubscriptionError: UnsubscriptionErrorCtor = createErrorClass(\n (_super) =>\n function UnsubscriptionErrorImpl(this: any, errors: (Error | string)[]) {\n _super(this);\n this.message = errors\n ? `${errors.length} errors occurred during unsubscription:\n${errors.map((err, i) => `${i + 1}) ${err.toString()}`).join('\\n ')}`\n : '';\n this.name = 'UnsubscriptionError';\n this.errors = errors;\n }\n);\n", "/**\n * Removes an item from an array, mutating it.\n * @param arr The array to remove the item from\n * @param item The item to remove\n */\nexport function arrRemove<T>(arr: T[] | undefined | null, item: T) {\n if (arr) {\n const index = arr.indexOf(item);\n 0 <= index && arr.splice(index, 1);\n }\n}\n", "import { isFunction } from './util/isFunction';\nimport { UnsubscriptionError } from './util/UnsubscriptionError';\nimport { SubscriptionLike, TeardownLogic, Unsubscribable } from './types';\nimport { arrRemove } from './util/arrRemove';\n\n/**\n * Represents a disposable resource, such as the execution of an Observable. A\n * Subscription has one important method, `unsubscribe`, that takes no argument\n * and just disposes the resource held by the subscription.\n *\n * Additionally, subscriptions may be grouped together through the `add()`\n * method, which will attach a child Subscription to the current Subscription.\n * When a Subscription is unsubscribed, all its children (and its grandchildren)\n * will be unsubscribed as well.\n */\nexport class Subscription implements SubscriptionLike {\n public static EMPTY = (() => {\n const empty = new Subscription();\n empty.closed = true;\n return empty;\n })();\n\n /**\n * A flag to indicate whether this Subscription has already been unsubscribed.\n */\n public closed = false;\n\n private _parentage: Subscription[] | Subscription | null = null;\n\n /**\n * The list of registered finalizers to execute upon unsubscription. Adding and removing from this\n * list occurs in the {@link #add} and {@link #remove} methods.\n */\n private _finalizers: Exclude<TeardownLogic, void>[] | null = null;\n\n /**\n * @param initialTeardown A function executed first as part of the finalization\n * process that is kicked off when {@link #unsubscribe} is called.\n */\n constructor(private initialTeardown?: () => void) {}\n\n /**\n * Disposes the resources held by the subscription. May, for instance, cancel\n * an ongoing Observable execution or cancel any other type of work that\n * started when the Subscription was created.\n */\n unsubscribe(): void {\n let errors: any[] | undefined;\n\n if (!this.closed) {\n this.closed = true;\n\n // Remove this from it's parents.\n const { _parentage } = this;\n if (_parentage) {\n this._parentage = null;\n if (Array.isArray(_parentage)) {\n for (const parent of _parentage) {\n parent.remove(this);\n }\n } else {\n _parentage.remove(this);\n }\n }\n\n const { initialTeardown: initialFinalizer } = this;\n if (isFunction(initialFinalizer)) {\n try {\n initialFinalizer();\n } catch (e) {\n errors = e instanceof UnsubscriptionError ? e.errors : [e];\n }\n }\n\n const { _finalizers } = this;\n if (_finalizers) {\n this._finalizers = null;\n for (const finalizer of _finalizers) {\n try {\n execFinalizer(finalizer);\n } catch (err) {\n errors = errors ?? [];\n if (err instanceof UnsubscriptionError) {\n errors = [...errors, ...err.errors];\n } else {\n errors.push(err);\n }\n }\n }\n }\n\n if (errors) {\n throw new UnsubscriptionError(errors);\n }\n }\n }\n\n /**\n * Adds a finalizer to this subscription, so that finalization will be unsubscribed/called\n * when this subscription is unsubscribed. If this subscription is already {@link #closed},\n * because it has already been unsubscribed, then whatever finalizer is passed to it\n * will automatically be executed (unless the finalizer itself is also a closed subscription).\n *\n * Closed Subscriptions cannot be added as finalizers to any subscription. Adding a closed\n * subscription to a any subscription will result in no operation. (A noop).\n *\n * Adding a subscription to itself, or adding `null` or `undefined` will not perform any\n * operation at all. (A noop).\n *\n * `Subscription` instances that are added to this instance will automatically remove themselves\n * if they are unsubscribed. Functions and {@link Unsubscribable} objects that you wish to remove\n * will need to be removed manually with {@link #remove}\n *\n * @param teardown The finalization logic to add to this subscription.\n */\n add(teardown: TeardownLogic): void {\n // Only add the finalizer if it's not undefined\n // and don't add a subscription to itself.\n if (teardown && teardown !== this) {\n if (this.closed) {\n // If this subscription is already closed,\n // execute whatever finalizer is handed to it automatically.\n execFinalizer(teardown);\n } else {\n if (teardown instanceof Subscription) {\n // We don't add closed subscriptions, and we don't add the same subscription\n // twice. Subscription unsubscribe is idempotent.\n if (teardown.closed || teardown._hasParent(this)) {\n return;\n }\n teardown._addParent(this);\n }\n (this._finalizers = this._finalizers ?? []).push(teardown);\n }\n }\n }\n\n /**\n * Checks to see if a this subscription already has a particular parent.\n * This will signal that this subscription has already been added to the parent in question.\n * @param parent the parent to check for\n */\n private _hasParent(parent: Subscription) {\n const { _parentage } = this;\n return _parentage === parent || (Array.isArray(_parentage) && _parentage.includes(parent));\n }\n\n /**\n * Adds a parent to this subscription so it can be removed from the parent if it\n * unsubscribes on it's own.\n *\n * NOTE: THIS ASSUMES THAT {@link _hasParent} HAS ALREADY BEEN CHECKED.\n * @param parent The parent subscription to add\n */\n private _addParent(parent: Subscription) {\n const { _parentage } = this;\n this._parentage = Array.isArray(_parentage) ? (_parentage.push(parent), _parentage) : _parentage ? [_parentage, parent] : parent;\n }\n\n /**\n * Called on a child when it is removed via {@link #remove}.\n * @param parent The parent to remove\n */\n private _removeParent(parent: Subscription) {\n const { _parentage } = this;\n if (_parentage === parent) {\n this._parentage = null;\n } else if (Array.isArray(_parentage)) {\n arrRemove(_parentage, parent);\n }\n }\n\n /**\n * Removes a finalizer from this subscription that was previously added with the {@link #add} method.\n *\n * Note that `Subscription` instances, when unsubscribed, will automatically remove themselves\n * from every other `Subscription` they have been added to. This means that using the `remove` method\n * is not a common thing and should be used thoughtfully.\n *\n * If you add the same finalizer instance of a function or an unsubscribable object to a `Subscription` instance\n * more than once, you will need to call `remove` the same number of times to remove all instances.\n *\n * All finalizer instances are removed to free up memory upon unsubscription.\n *\n * @param teardown The finalizer to remove from this subscription\n */\n remove(teardown: Exclude<TeardownLogic, void>): void {\n const { _finalizers } = this;\n _finalizers && arrRemove(_finalizers, teardown);\n\n if (teardown instanceof Subscription) {\n teardown._removeParent(this);\n }\n }\n}\n\nexport const EMPTY_SUBSCRIPTION = Subscription.EMPTY;\n\nexport function isSubscription(value: any): value is Subscription {\n return (\n value instanceof Subscription ||\n (value && 'closed' in value && isFunction(value.remove) && isFunction(value.add) && isFunction(value.unsubscribe))\n );\n}\n\nfunction execFinalizer(finalizer: Unsubscribable | (() => void)) {\n if (isFunction(finalizer)) {\n finalizer();\n } else {\n finalizer.unsubscribe();\n }\n}\n", "import { Subscriber } from './Subscriber';\nimport { ObservableNotification } from './types';\n\n/**\n * The {@link GlobalConfig} object for RxJS. It is used to configure things\n * like how to react on unhandled errors.\n */\nexport const config: GlobalConfig = {\n onUnhandledError: null,\n onStoppedNotification: null,\n Promise: undefined,\n useDeprecatedSynchronousErrorHandling: false,\n useDeprecatedNextContext: false,\n};\n\n/**\n * The global configuration object for RxJS, used to configure things\n * like how to react on unhandled errors. Accessible via {@link config}\n * object.\n */\nexport interface GlobalConfig {\n /**\n * A registration point for unhandled errors from RxJS. These are errors that\n * cannot were not handled by consuming code in the usual subscription path. For\n * example, if you have this configured, and you subscribe to an observable without\n * providing an error handler, errors from that subscription will end up here. This\n * will _always_ be called asynchronously on another job in the runtime. This is because\n * we do not want errors thrown in this user-configured handler to interfere with the\n * behavior of the library.\n */\n onUnhandledError: ((err: any) => void) | null;\n\n /**\n * A registration point for notifications that cannot be sent to subscribers because they\n * have completed, errored or have been explicitly unsubscribed. By default, next, complete\n * and error notifications sent to stopped subscribers are noops. However, sometimes callers\n * might want a different behavior. For example, with sources that attempt to report errors\n * to stopped subscribers, a caller can configure RxJS to throw an unhandled error instead.\n * This will _always_ be called asynchronously on another job in the runtime. This is because\n * we do not want errors thrown in this user-configured handler to interfere with the\n * behavior of the library.\n */\n onStoppedNotification: ((notification: ObservableNotification<any>, subscriber: Subscriber<any>) => void) | null;\n\n /**\n * The promise constructor used by default for {@link Observable#toPromise toPromise} and {@link Observable#forEach forEach}\n * methods.\n *\n * @deprecated As of version 8, RxJS will no longer support this sort of injection of a\n * Promise constructor. If you need a Promise implementation other than native promises,\n * please polyfill/patch Promise as you see appropriate. Will be removed in v8.\n */\n Promise?: PromiseConstructorLike;\n\n /**\n * If true, turns on synchronous error rethrowing, which is a deprecated behavior\n * in v6 and higher. This behavior enables bad patterns like wrapping a subscribe\n * call in a try/catch block. It also enables producer interference, a nasty bug\n * where a multicast can be broken for all observers by a downstream consumer with\n * an unhandled error. DO NOT USE THIS FLAG UNLESS IT'S NEEDED TO BUY TIME\n * FOR MIGRATION REASONS.\n *\n * @deprecated As of version 8, RxJS will no longer support synchronous throwing\n * of unhandled errors. All errors will be thrown on a separate call stack to prevent bad\n * behaviors described above. Will be removed in v8.\n */\n useDeprecatedSynchronousErrorHandling: boolean;\n\n /**\n * If true, enables an as-of-yet undocumented feature from v5: The ability to access\n * `unsubscribe()` via `this` context in `next` functions created in observers passed\n * to `subscribe`.\n *\n * This is being removed because the performance was severely problematic, and it could also cause\n * issues when types other than POJOs are passed to subscribe as subscribers, as they will likely have\n * their `this` context overwritten.\n *\n * @deprecated As of version 8, RxJS will no longer support altering the\n * context of next functions provided as part of an observer to Subscribe. Instead,\n * you will have access to a subscription or a signal or token that will allow you to do things like\n * unsubscribe and test closed status. Will be removed in v8.\n */\n useDeprecatedNextContext: boolean;\n}\n", "import type { TimerHandle } from './timerHandle';\ntype SetTimeoutFunction = (handler: () => void, timeout?: number, ...args: any[]) => TimerHandle;\ntype ClearTimeoutFunction = (handle: TimerHandle) => void;\n\ninterface TimeoutProvider {\n setTimeout: SetTimeoutFunction;\n clearTimeout: ClearTimeoutFunction;\n delegate:\n | {\n setTimeout: SetTimeoutFunction;\n clearTimeout: ClearTimeoutFunction;\n }\n | undefined;\n}\n\nexport const timeoutProvider: TimeoutProvider = {\n // When accessing the delegate, use the variable rather than `this` so that\n // the functions can be called without being bound to the provider.\n setTimeout(handler: () => void, timeout?: number, ...args) {\n const { delegate } = timeoutProvider;\n if (delegate?.setTimeout) {\n return delegate.setTimeout(handler, timeout, ...args);\n }\n return setTimeout(handler, timeout, ...args);\n },\n clearTimeout(handle) {\n const { delegate } = timeoutProvider;\n return (delegate?.clearTimeout || clearTimeout)(handle as any);\n },\n delegate: undefined,\n};\n", "import { config } from '../config';\nimport { timeoutProvider } from '../scheduler/timeoutProvider';\n\n/**\n * Handles an error on another job either with the user-configured {@link onUnhandledError},\n * or by throwing it on that new job so it can be picked up by `window.onerror`, `process.on('error')`, etc.\n *\n * This should be called whenever there is an error that is out-of-band with the subscription\n * or when an error hits a terminal boundary of the subscription and no error handler was provided.\n *\n * @param err the error to report\n */\nexport function reportUnhandledError(err: any) {\n timeoutProvider.setTimeout(() => {\n const { onUnhandledError } = config;\n if (onUnhandledError) {\n // Execute the user-configured error handler.\n onUnhandledError(err);\n } else {\n // Throw so it is picked up by the runtime's uncaught error mechanism.\n throw err;\n }\n });\n}\n", "/* tslint:disable:no-empty */\nexport function noop() { }\n", "import { CompleteNotification, NextNotification, ErrorNotification } from './types';\n\n/**\n * A completion object optimized for memory use and created to be the\n * same \"shape\" as other notifications in v8.\n * @internal\n */\nexport const COMPLETE_NOTIFICATION = (() => createNotification('C', undefined, undefined) as CompleteNotification)();\n\n/**\n * Internal use only. Creates an optimized error notification that is the same \"shape\"\n * as other notifications.\n * @internal\n */\nexport function errorNotification(error: any): ErrorNotification {\n return createNotification('E', undefined, error) as any;\n}\n\n/**\n * Internal use only. Creates an optimized next notification that is the same \"shape\"\n * as other notifications.\n * @internal\n */\nexport function nextNotification<T>(value: T) {\n return createNotification('N', value, undefined) as NextNotification<T>;\n}\n\n/**\n * Ensures that all notifications created internally have the same \"shape\" in v8.\n *\n * TODO: This is only exported to support a crazy legacy test in `groupBy`.\n * @internal\n */\nexport function createNotification(kind: 'N' | 'E' | 'C', value: any, error: any) {\n return {\n kind,\n value,\n error,\n };\n}\n", "import { config } from '../config';\n\nlet context: { errorThrown: boolean; error: any } | null = null;\n\n/**\n * Handles dealing with errors for super-gross mode. Creates a context, in which\n * any synchronously thrown errors will be passed to {@link captureError}. Which\n * will record the error such that it will be rethrown after the call back is complete.\n * TODO: Remove in v8\n * @param cb An immediately executed function.\n */\nexport function errorContext(cb: () => void) {\n if (config.useDeprecatedSynchronousErrorHandling) {\n const isRoot = !context;\n if (isRoot) {\n context = { errorThrown: false, error: null };\n }\n cb();\n if (isRoot) {\n const { errorThrown, error } = context!;\n context = null;\n if (errorThrown) {\n throw error;\n }\n }\n } else {\n // This is the general non-deprecated path for everyone that\n // isn't crazy enough to use super-gross mode (useDeprecatedSynchronousErrorHandling)\n cb();\n }\n}\n\n/**\n * Captures errors only in super-gross mode.\n * @param err the error to capture\n */\nexport function captureError(err: any) {\n if (config.useDeprecatedSynchronousErrorHandling && context) {\n context.errorThrown = true;\n context.error = err;\n }\n}\n", "import { isFunction } from './util/isFunction';\nimport { Observer, ObservableNotification } from './types';\nimport { isSubscription, Subscription } from './Subscription';\nimport { config } from './config';\nimport { reportUnhandledError } from './util/reportUnhandledError';\nimport { noop } from './util/noop';\nimport { nextNotification, errorNotification, COMPLETE_NOTIFICATION } from './NotificationFactories';\nimport { timeoutProvider } from './scheduler/timeoutProvider';\nimport { captureError } from './util/errorContext';\n\n/**\n * Implements the {@link Observer} interface and extends the\n * {@link Subscription} class. While the {@link Observer} is the public API for\n * consuming the values of an {@link Observable}, all Observers get converted to\n * a Subscriber, in order to provide Subscription-like capabilities such as\n * `unsubscribe`. Subscriber is a common type in RxJS, and crucial for\n * implementing operators, but it is rarely used as a public API.\n */\nexport class Subscriber<T> extends Subscription implements Observer<T> {\n /**\n * A static factory for a Subscriber, given a (potentially partial) definition\n * of an Observer.\n * @param next The `next` callback of an Observer.\n * @param error The `error` callback of an\n * Observer.\n * @param complete The `complete` callback of an\n * Observer.\n * @return A Subscriber wrapping the (partially defined)\n * Observer represented by the given arguments.\n * @deprecated Do not use. Will be removed in v8. There is no replacement for this\n * method, and there is no reason to be creating instances of `Subscriber` directly.\n * If you have a specific use case, please file an issue.\n */\n static create<T>(next?: (x?: T) => void, error?: (e?: any) => void, complete?: () => void): Subscriber<T> {\n return new SafeSubscriber(next, error, complete);\n }\n\n /** @deprecated Internal implementation detail, do not use directly. Will be made internal in v8. */\n protected isStopped: boolean = false;\n /** @deprecated Internal implementation detail, do not use directly. Will be made internal in v8. */\n protected destination: Subscriber<any> | Observer<any>; // this `any` is the escape hatch to erase extra type param (e.g. R)\n\n /**\n * @deprecated Internal implementation detail, do not use directly. Will be made internal in v8.\n * There is no reason to directly create an instance of Subscriber. This type is exported for typings reasons.\n */\n constructor(destination?: Subscriber<any> | Observer<any>) {\n super();\n if (destination) {\n this.destination = destination;\n // Automatically chain subscriptions together here.\n // if destination is a Subscription, then it is a Subscriber.\n if (isSubscription(destination)) {\n destination.add(this);\n }\n } else {\n this.destination = EMPTY_OBSERVER;\n }\n }\n\n /**\n * The {@link Observer} callback to receive notifications of type `next` from\n * the Observable, with a value. The Observable may call this method 0 or more\n * times.\n * @param value The `next` value.\n */\n next(value: T): void {\n if (this.isStopped) {\n handleStoppedNotification(nextNotification(value), this);\n } else {\n this._next(value!);\n }\n }\n\n /**\n * The {@link Observer} callback to receive notifications of type `error` from\n * the Observable, with an attached `Error`. Notifies the Observer that\n * the Observable has experienced an error condition.\n * @param err The `error` exception.\n */\n error(err?: any): void {\n if (this.isStopped) {\n handleStoppedNotification(errorNotification(err), this);\n } else {\n this.isStopped = true;\n this._error(err);\n }\n }\n\n /**\n * The {@link Observer} callback to receive a valueless notification of type\n * `complete` from the Observable. Notifies the Observer that the Observable\n * has finished sending push-based notifications.\n */\n complete(): void {\n if (this.isStopped) {\n handleStoppedNotification(COMPLETE_NOTIFICATION, this);\n } else {\n this.isStopped = true;\n this._complete();\n }\n }\n\n unsubscribe(): void {\n if (!this.closed) {\n this.isStopped = true;\n super.unsubscribe();\n this.destination = null!;\n }\n }\n\n protected _next(value: T): void {\n this.destination.next(value);\n }\n\n protected _error(err: any): void {\n try {\n this.destination.error(err);\n } finally {\n this.unsubscribe();\n }\n }\n\n protected _complete(): void {\n try {\n this.destination.complete();\n } finally {\n this.unsubscribe();\n }\n }\n}\n\n/**\n * This bind is captured here because we want to be able to have\n * compatibility with monoid libraries that tend to use a method named\n * `bind`. In particular, a library called Monio requires this.\n */\nconst _bind = Function.prototype.bind;\n\nfunction bind<Fn extends (...args: any[]) => any>(fn: Fn, thisArg: any): Fn {\n return _bind.call(fn, thisArg);\n}\n\n/**\n * Internal optimization only, DO NOT EXPOSE.\n * @internal\n */\nclass ConsumerObserver<T> implements Observer<T> {\n constructor(private partialObserver: Partial<Observer<T>>) {}\n\n next(value: T): void {\n const { partialObserver } = this;\n if (partialObserver.next) {\n try {\n partialObserver.next(value);\n } catch (error) {\n handleUnhandledError(error);\n }\n }\n }\n\n error(err: any): void {\n const { partialObserver } = this;\n if (partialObserver.error) {\n try {\n partialObserver.error(err);\n } catch (error) {\n handleUnhandledError(error);\n }\n } else {\n handleUnhandledError(err);\n }\n }\n\n complete(): void {\n const { partialObserver } = this;\n if (partialObserver.complete) {\n try {\n partialObserver.complete();\n } catch (error) {\n handleUnhandledError(error);\n }\n }\n }\n}\n\nexport class SafeSubscriber<T> extends Subscriber<T> {\n constructor(\n observerOrNext?: Partial<Observer<T>> | ((value: T) => void) | null,\n error?: ((e?: any) => void) | null,\n complete?: (() => void) | null\n ) {\n super();\n\n let partialObserver: Partial<Observer<T>>;\n if (isFunction(observerOrNext) || !observerOrNext) {\n // The first argument is a function, not an observer. The next\n // two arguments *could* be observers, or they could be empty.\n partialObserver = {\n next: (observerOrNext ?? undefined) as ((value: T) => void) | undefined,\n error: error ?? undefined,\n complete: complete ?? undefined,\n };\n } else {\n // The first argument is a partial observer.\n let context: any;\n if (this && config.useDeprecatedNextContext) {\n // This is a deprecated path that made `this.unsubscribe()` available in\n // next handler functions passed to subscribe. This only exists behind a flag\n // now, as it is *very* slow.\n context = Object.create(observerOrNext);\n context.unsubscribe = () => this.unsubscribe();\n partialObserver = {\n next: observerOrNext.next && bind(observerOrNext.next, context),\n error: observerOrNext.error && bind(observerOrNext.error, context),\n complete: observerOrNext.complete && bind(observerOrNext.complete, context),\n };\n } else {\n // The \"normal\" path. Just use the partial observer directly.\n partialObserver = observerOrNext;\n }\n }\n\n // Wrap the partial observer to ensure it's a full observer, and\n // make sure proper error handling is accounted for.\n this.destination = new ConsumerObserver(partialObserver);\n }\n}\n\nfunction handleUnhandledError(error: any) {\n if (config.useDeprecatedSynchronousErrorHandling) {\n captureError(error);\n } else {\n // Ideal path, we report this as an unhandled error,\n // which is thrown on a new call stack.\n reportUnhandledError(error);\n }\n}\n\n/**\n * An error handler used when no error handler was supplied\n * to the SafeSubscriber -- meaning no error handler was supplied\n * do the `subscribe` call on our observable.\n * @param err The error to handle\n */\nfunction defaultErrorHandler(err: any) {\n throw err;\n}\n\n/**\n * A handler for notifications that cannot be sent to a stopped subscriber.\n * @param notification The notification being sent.\n * @param subscriber The stopped subscriber.\n */\nfunction handleStoppedNotification(notification: ObservableNotification<any>, subscriber: Subscriber<any>) {\n const { onStoppedNotification } = config;\n onStoppedNotification && timeoutProvider.setTimeout(() => onStoppedNotification(notification, subscriber));\n}\n\n/**\n * The observer used as a stub for subscriptions where the user did not\n * pass any arguments to `subscribe`. Comes with the default error handling\n * behavior.\n */\nexport const EMPTY_OBSERVER: Readonly<Observer<any>> & { closed: true } = {\n closed: true,\n next: noop,\n error: defaultErrorHandler,\n complete: noop,\n};\n", "/**\n * Symbol.observable or a string \"@@observable\". Used for interop\n *\n * @deprecated We will no longer be exporting this symbol in upcoming versions of RxJS.\n * Instead polyfill and use Symbol.observable directly *or* use https://www.npmjs.com/package/symbol-observable\n */\nexport const observable: string | symbol = (() => (typeof Symbol === 'function' && Symbol.observable) || '@@observable')();\n", "/**\n * This function takes one parameter and just returns it. Simply put,\n * this is like `<T>(x: T): T => x`.\n *\n * ## Examples\n *\n * This is useful in some cases when using things like `mergeMap`\n *\n * ```ts\n * import { interval, take, map, range, mergeMap, identity } from 'rxjs';\n *\n * const source$ = interval(1000).pipe(take(5));\n *\n * const result$ = source$.pipe(\n * map(i => range(i)),\n * mergeMap(identity) // same as mergeMap(x => x)\n * );\n *\n * result$.subscribe({\n * next: console.log\n * });\n * ```\n *\n * Or when you want to selectively apply an operator\n *\n * ```ts\n * import { interval, take, identity } from 'rxjs';\n *\n * const shouldLimit = () => Math.random() < 0.5;\n *\n * const source$ = interval(1000);\n *\n * const result$ = source$.pipe(shouldLimit() ? take(5) : identity);\n *\n * result$.subscribe({\n * next: console.log\n * });\n * ```\n *\n * @param x Any value that is returned by this function\n * @returns The value passed as the first parameter to this function\n */\nexport function identity<T>(x: T): T {\n return x;\n}\n", "import { identity } from './identity';\nimport { UnaryFunction } from '../types';\n\nexport function pipe(): typeof identity;\nexport function pipe<T, A>(fn1: UnaryFunction<T, A>): UnaryFunction<T, A>;\nexport function pipe<T, A, B>(fn1: UnaryFunction<T, A>, fn2: UnaryFunction<A, B>): UnaryFunction<T, B>;\nexport function pipe<T, A, B, C>(fn1: UnaryFunction<T, A>, fn2: UnaryFunction<A, B>, fn3: UnaryFunction<B, C>): UnaryFunction<T, C>;\nexport function pipe<T, A, B, C, D>(\n fn1: UnaryFunction<T, A>,\n fn2: UnaryFunction<A, B>,\n fn3: UnaryFunction<B, C>,\n fn4: UnaryFunction<C, D>\n): UnaryFunction<T, D>;\nexport function pipe<T, A, B, C, D, E>(\n fn1: UnaryFunction<T, A>,\n fn2: UnaryFunction<A, B>,\n fn3: UnaryFunction<B, C>,\n fn4: UnaryFunction<C, D>,\n fn5: UnaryFunction<D, E>\n): UnaryFunction<T, E>;\nexport function pipe<T, A, B, C, D, E, F>(\n fn1: UnaryFunction<T, A>,\n fn2: UnaryFunction<A, B>,\n fn3: UnaryFunction<B, C>,\n fn4: UnaryFunction<C, D>,\n fn5: UnaryFunction<D, E>,\n fn6: UnaryFunction<E, F>\n): UnaryFunction<T, F>;\nexport function pipe<T, A, B, C, D, E, F, G>(\n fn1: UnaryFunction<T, A>,\n fn2: UnaryFunction<A, B>,\n fn3: UnaryFunction<B, C>,\n fn4: UnaryFunction<C, D>,\n fn5: UnaryFunction<D, E>,\n fn6: UnaryFunction<E, F>,\n fn7: UnaryFunction<F, G>\n): UnaryFunction<T, G>;\nexport function pipe<T, A, B, C, D, E, F, G, H>(\n fn1: UnaryFunction<T, A>,\n fn2: UnaryFunction<A, B>,\n fn3: UnaryFunction<B, C>,\n fn4: UnaryFunction<C, D>,\n fn5: UnaryFunction<D, E>,\n fn6: UnaryFunction<E, F>,\n fn7: UnaryFunction<F, G>,\n fn8: UnaryFunction<G, H>\n): UnaryFunction<T, H>;\nexport function pipe<T, A, B, C, D, E, F, G, H, I>(\n fn1: UnaryFunction<T, A>,\n fn2: UnaryFunction<A, B>,\n fn3: UnaryFunction<B, C>,\n fn4: UnaryFunction<C, D>,\n fn5: UnaryFunction<D, E>,\n fn6: UnaryFunction<E, F>,\n fn7: UnaryFunction<F, G>,\n fn8: UnaryFunction<G, H>,\n fn9: UnaryFunction<H, I>\n): UnaryFunction<T, I>;\nexport function pipe<T, A, B, C, D, E, F, G, H, I>(\n fn1: UnaryFunction<T, A>,\n fn2: UnaryFunction<A, B>,\n fn3: UnaryFunction<B, C>,\n fn4: UnaryFunction<C, D>,\n fn5: UnaryFunction<D, E>,\n fn6: UnaryFunction<E, F>,\n fn7: UnaryFunction<F, G>,\n fn8: UnaryFunction<G, H>,\n fn9: UnaryFunction<H, I>,\n ...fns: UnaryFunction<any, any>[]\n): UnaryFunction<T, unknown>;\n\n/**\n * pipe() can be called on one or more functions, each of which can take one argument (\"UnaryFunction\")\n * and uses it to return a value.\n * It returns a function that takes one argument, passes it to the first UnaryFunction, and then\n * passes the result to the next one, passes that result to the next one, and so on. \n */\nexport function pipe(...fns: Array<UnaryFunction<any, any>>): UnaryFunction<any, any> {\n return pipeFromArray(fns);\n}\n\n/** @internal */\nexport function pipeFromArray<T, R>(fns: Array<UnaryFunction<T, R>>): UnaryFunction<T, R> {\n if (fns.length === 0) {\n return identity as UnaryFunction<any, any>;\n }\n\n if (fns.length === 1) {\n return fns[0];\n }\n\n return function piped(input: T): R {\n return fns.reduce((prev: any, fn: UnaryFunction<T, R>) => fn(prev), input as any);\n };\n}\n", "import { Operator } from './Operator';\nimport { SafeSubscriber, Subscriber } from './Subscriber';\nimport { isSubscription, Subscription } from './Subscription';\nimport { TeardownLogic, OperatorFunction, Subscribable, Observer } from './types';\nimport { observable as Symbol_observable } from './symbol/observable';\nimport { pipeFromArray } from './util/pipe';\nimport { config } from './config';\nimport { isFunction } from './util/isFunction';\nimport { errorContext } from './util/errorContext';\n\n/**\n * A representation of any set of values over any amount of time. This is the most basic building block\n * of RxJS.\n */\nexport class Observable<T> implements Subscribable<T> {\n /**\n * @deprecated Internal implementation detail, do not use directly. Will be made internal in v8.\n */\n source: Observable<any> | undefined;\n\n /**\n * @deprecated Internal implementation detail, do not use directly. Will be made internal in v8.\n */\n operator: Operator<any, T> | undefined;\n\n /**\n * @param subscribe The function that is called when the Observable is\n * initially subscribed to. This function is given a Subscriber, to which new values\n * can be `next`ed, or an `error` method can be called to raise an error, or\n * `complete` can be called to notify of a successful completion.\n */\n constructor(subscribe?: (this: Observable<T>, subscriber: Subscriber<T>) => TeardownLogic) {\n if (subscribe) {\n this._subscribe = subscribe;\n }\n }\n\n // HACK: Since TypeScript inherits static properties too, we have to\n // fight against TypeScript here so Subject can have a different static create signature\n /**\n * Creates a new Observable by calling the Observable constructor\n * @param subscribe the subscriber function to be passed to the Observable constructor\n * @return A new observable.\n * @deprecated Use `new Observable()` instead. Will be removed in v8.\n */\n static create: (...args: any[]) => any = <T>(subscribe?: (subscriber: Subscriber<T>) => TeardownLogic) => {\n return new Observable<T>(subscribe);\n };\n\n /**\n * Creates a new Observable, with this Observable instance as the source, and the passed\n * operator defined as the new observable's operator.\n * @param operator the operator defining the operation to take on the observable\n * @return A new observable with the Operator applied.\n * @deprecated Internal implementation detail, do not use directly. Will be made internal in v8.\n * If you have implemented an operator using `lift`, it is recommended that you create an\n * operator by simply returning `new Observable()` directly. See \"Creating new operators from\n * scratch\" section here: https://rxjs.dev/guide/operators\n */\n lift<R>(operator?: Operator<T, R>): Observable<R> {\n const observable = new Observable<R>();\n observable.source = this;\n observable.operator = operator;\n return observable;\n }\n\n subscribe(observerOrNext?: Partial<Observer<T>> | ((value: T) => void)): Subscription;\n /** @deprecated Instead of passing separate callback arguments, use an observer argument. Signatures taking separate callback arguments will be removed in v8. Details: https://rxjs.dev/deprecations/subscribe-arguments */\n subscribe(next?: ((value: T) => void) | null, error?: ((error: any) => void) | null, complete?: (() => void) | null): Subscription;\n /**\n * Invokes an execution of an Observable and registers Observer handlers for notifications it will emit.\n *\n * <span class=\"informal\">Use it when you have all these Observables, but still nothing is happening.</span>\n *\n * `subscribe` is not a regular operator, but a method that calls Observable's internal `subscribe` function. It\n * might be for example a function that you passed to Observable's constructor, but most of the time it is\n * a library implementation, which defines what will be emitted by an Observable, and when it be will emitted. This means\n * that calling `subscribe` is actually the moment when Observable starts its work, not when it is created, as it is often\n * the thought.\n *\n * Apart from starting the execution of an Observable, this method allows you to listen for values\n * that an Observable emits, as well as for when it completes or errors. You can achieve this in two\n * of the following ways.\n *\n * The first way is creating an object that implements {@link Observer} interface. It should have methods\n * defined by that interface, but note that it should be just a regular JavaScript object, which you can create\n * yourself in any way you want (ES6 class, classic function constructor, object literal etc.). In particular, do\n * not attempt to use any RxJS implementation details to create Observers - you don't need them. Remember also\n * that your object does not have to implement all methods. If you find yourself creating a method that doesn't\n * do anything, you can simply omit it. Note however, if the `error` method is not provided and an error happens,\n * it will be thrown asynchronously. Errors thrown asynchronously cannot be caught using `try`/`catch`. Instead,\n * use the {@link onUnhandledError} configuration option or use a runtime handler (like `window.onerror` or\n * `process.on('error)`) to be notified of unhandled errors. Because of this, it's recommended that you provide\n * an `error` method to avoid missing thrown errors.\n *\n * The second way is to give up on Observer object altogether and simply provide callback functions in place of its methods.\n * This means you can provide three functions as arguments to `subscribe`, where the first function is equivalent\n * of a `next` method, the second of an `error` method and the third of a `complete` method. Just as in case of an Observer,\n * if you do not need to listen for something, you can omit a function by passing `undefined` or `null`,\n * since `subscribe` recognizes these functions by where they were placed in function call. When it comes\n * to the `error` function, as with an Observer, if not provided, errors emitted by an Observable will be thrown asynchronously.\n *\n * You can, however, subscribe with no parameters at all. This may be the case where you're not interested in terminal events\n * and you also handled emissions internally by using operators (e.g. using `tap`).\n *\n * Whichever style of calling `subscribe` you use, in both cases it returns a Subscription object.\n * This object allows you to call `unsubscribe` on it, which in turn will stop the work that an Observable does and will clean\n * up all resources that an Observable used. Note that cancelling a subscription will not call `complete` callback\n * provided to `subscribe` function, which is reserved for a regular completion signal that comes from an Observable.\n *\n * Remember that callbacks provided to `subscribe` are not guaranteed to be called asynchronously.\n * It is an Observable itself that decides when these functions will be called. For example {@link of}\n * by default emits all its values synchronously. Always check documentation for how given Observable\n * will behave when subscribed and if its default behavior can be modified with a `scheduler`.\n *\n * #### Examples\n *\n * Subscribe with an {@link guide/observer Observer}\n *\n * ```ts\n * import { of } from 'rxjs';\n *\n * const sumObserver = {\n * sum: 0,\n * next(value) {\n * console.log('Adding: ' + value);\n * this.sum = this.sum + value;\n * },\n * error() {\n * // We actually could just remove this method,\n * // since we do not really care about errors right now.\n * },\n * complete() {\n * console.log('Sum equals: ' + this.sum);\n * }\n * };\n *\n * of(1, 2, 3) // Synchronously emits 1, 2, 3 and then completes.\n * .subscribe(sumObserver);\n *\n * // Logs:\n * // 'Adding: 1'\n * // 'Adding: 2'\n * // 'Adding: 3'\n * // 'Sum equals: 6'\n * ```\n *\n * Subscribe with functions ({@link deprecations/subscribe-arguments deprecated})\n *\n * ```ts\n * import { of } from 'rxjs'\n *\n * let sum = 0;\n *\n * of(1, 2, 3).subscribe(\n * value => {\n * console.log('Adding: ' + value);\n * sum = sum + value;\n * },\n * undefined,\n * () => console.log('Sum equals: ' + sum)\n * );\n *\n * // Logs:\n * // 'Adding: 1'\n * // 'Adding: 2'\n * // 'Adding: 3'\n * // 'Sum equals: 6'\n * ```\n *\n * Cancel a subscription\n *\n * ```ts\n * import { interval } from 'rxjs';\n *\n * const subscription = interval(1000).subscribe({\n * next(num) {\n * console.log(num)\n * },\n * complete() {\n * // Will not be called, even when cancelling subscription.\n * console.log('completed!');\n * }\n * });\n *\n * setTimeout(() => {\n * subscription.unsubscribe();\n * console.log('unsubscribed!');\n * }, 2500);\n *\n * // Logs:\n * // 0 after 1s\n * // 1 after 2s\n * // 'unsubscribed!' after 2.5s\n * ```\n *\n * @param observerOrNext Either an {@link Observer} with some or all callback methods,\n * or the `next` handler that is called for each value emitted from the subscribed Observable.\n * @param error A handler for a terminal event resulting from an error. If no error handler is provided,\n * the error will be thrown asynchronously as unhandled.\n * @param complete A handler for a terminal event resulting from successful completion.\n * @return A subscription reference to the registered handlers.\n */\n subscribe(\n observerOrNext?: Partial<Observer<T>> | ((value: T) => void) | null,\n error?: ((error: any) => void) | null,\n complete?: (() => void) | null\n ): Subscription {\n const subscriber = isSubscriber(observerOrNext) ? observerOrNext : new SafeSubscriber(observerOrNext, error, complete);\n\n errorContext(() => {\n const { operator, source } = this;\n subscriber.add(\n operator\n ? // We're dealing with a subscription in the\n // operator chain to one of our lifted operators.\n operator.call(subscriber, source)\n : source\n ? // If `source` has a value, but `operator` does not, something that\n // had intimate knowledge of our API, like our `Subject`, must have\n // set it. We're going to just call `_subscribe` directly.\n this._subscribe(subscriber)\n : // In all other cases, we're likely wrapping a user-provided initializer\n // function, so we need to catch errors and handle them appropriately.\n this._trySubscribe(subscriber)\n );\n });\n\n return subscriber;\n }\n\n /** @internal */\n protected _trySubscribe(sink: Subscriber<T>): TeardownLogic {\n try {\n return this._subscribe(sink);\n } catch (err) {\n // We don't need to return anything in this case,\n // because it's just going to try to `add()` to a subscription\n // above.\n sink.error(err);\n }\n }\n\n /**\n * Used as a NON-CANCELLABLE means of subscribing to an observable, for use with\n * APIs that expect promises, like `async/await`. You cannot unsubscribe from this.\n *\n * **WARNING**: Only use this with observables you *know* will complete. If the source\n * observable does not complete, you will end up with a promise that is hung up, and\n * potentially all of the state of an async function hanging out in memory. To avoid\n * this situation, look into adding something like {@link timeout}, {@link take},\n * {@link takeWhile}, or {@link takeUntil} amongst others.\n *\n * #### Example\n *\n * ```ts\n * import { interval, take } from 'rxjs';\n *\n * const source$ = interval(1000).pipe(take(4));\n *\n * async function getTotal() {\n * let total = 0;\n *\n * await source$.forEach(value => {\n * total += value;\n * console.log('observable -> ' + value);\n * });\n *\n * return total;\n * }\n *\n * getTotal().then(\n * total => console.log('Total: ' + total)\n * );\n *\n * // Expected:\n * // 'observable -> 0'\n * // 'observable -> 1'\n * // 'observable -> 2'\n * // 'observable -> 3'\n * // 'Total: 6'\n * ```\n *\n * @param next A handler for each value emitted by the observable.\n * @return A promise that either resolves on observable completion or\n * rejects with the handled error.\n */\n forEach(next: (value: T) => void): Promise<void>;\n\n /**\n * @param next a handler for each value emitted by the observable\n * @param promiseCtor a constructor function used to instantiate the Promise\n * @return a promise that either resolves on observable completion or\n * rejects with the handled error\n * @deprecated Passing a Promise constructor will no longer be available\n * in upcoming versions of RxJS. This is because it adds weight to the library, for very\n * little benefit. If you need this functionality, it is recommended that you either\n * polyfill Promise, or you create an adapter to convert the returned native promise\n * to whatever promise implementation you wanted. Will be removed in v8.\n */\n forEach(next: (value: T) => void, promiseCtor: PromiseConstructorLike): Promise<void>;\n\n forEach(next: (value: T) => void, promiseCtor?: PromiseConstructorLike): Promise<void> {\n promiseCtor = getPromiseCtor(promiseCtor);\n\n return new promiseCtor<void>((resolve, reject) => {\n const subscriber = new SafeSubscriber<T>({\n next: (value) => {\n try {\n next(value);\n } catch (err) {\n reject(err);\n subscriber.unsubscribe();\n }\n },\n error: reject,\n complete: resolve,\n });\n this.subscribe(subscriber);\n }) as Promise<void>;\n }\n\n /** @internal */\n protected _subscribe(subscriber: Subscriber<any>): TeardownLogic {\n return this.source?.subscribe(subscriber);\n }\n\n /**\n * An interop point defined by the es7-observable spec https://github.com/zenparsing/es-observable\n * @return This instance of the observable.\n */\n [Symbol_observable]() {\n return this;\n }\n\n /* tslint:disable:max-line-length */\n pipe(): Observable<T>;\n pipe<A>(op1: OperatorFunction<T, A>): Observable<A>;\n pipe<A, B>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>): Observable<B>;\n pipe<A, B, C>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>): Observable<C>;\n pipe<A, B, C, D>(\n op1: OperatorFunction<T, A>,\n op2: OperatorFunction<A, B>,\n op3: OperatorFunction<B, C>,\n op4: OperatorFunction<C, D>\n ): Observable<D>;\n pipe<A, B, C, D, E>(\n op1: OperatorFunction<T, A>,\n op2: OperatorFunction<A, B>,\n op3: OperatorFunction<B, C>,\n op4: OperatorFunction<C, D>,\n op5: OperatorFunction<D, E>\n ): Observable<E>;\n pipe<A, B, C, D, E, F>(\n op1: OperatorFunction<T, A>,\n op2: OperatorFunction<A, B>,\n op3: OperatorFunction<B, C>,\n op4: OperatorFunction<C, D>,\n op5: OperatorFunction<D, E>,\n op6: OperatorFunction<E, F>\n ): Observable<F>;\n pipe<A, B, C, D, E, F, G>(\n op1: OperatorFunction<T, A>,\n op2: OperatorFunction<A, B>,\n op3: OperatorFunction<B, C>,\n op4: OperatorFunction<C, D>,\n op5: OperatorFunction<D, E>,\n op6: OperatorFunction<E, F>,\n op7: OperatorFunction<F, G>\n ): Observable<G>;\n pipe<A, B, C, D, E, F, G, H>(\n op1: OperatorFunction<T, A>,\n op2: OperatorFunction<A, B>,\n op3: OperatorFunction<B, C>,\n op4: OperatorFunction<C, D>,\n op5: OperatorFunction<D, E>,\n op6: OperatorFunction<E, F>,\n op7: OperatorFunction<F, G>,\n op8: OperatorFunction<G, H>\n ): Observable<H>;\n pipe<A, B, C, D, E, F, G, H, I>(\n op1: OperatorFunction<T, A>,\n op2: OperatorFunction<A, B>,\n op3: OperatorFunction<B, C>,\n op4: OperatorFunction<C, D>,\n op5: OperatorFunction<D, E>,\n op6: OperatorFunction<E, F>,\n op7: OperatorFunction<F, G>,\n op8: OperatorFunction<G, H>,\n op9: OperatorFunction<H, I>\n ): Observable<I>;\n pipe<A, B, C, D, E, F, G, H, I>(\n op1: OperatorFunction<T, A>,\n op2: OperatorFunction<A, B>,\n op3: OperatorFunction<B, C>,\n op4: OperatorFunction<C, D>,\n op5: OperatorFunction<D, E>,\n op6: OperatorFunction<E, F>,\n op7: OperatorFunction<F, G>,\n op8: OperatorFunction<G, H>,\n op9: OperatorFunction<H, I>,\n ...operations: OperatorFunction<any, any>[]\n ): Observable<unknown>;\n /* tslint:enable:max-line-length */\n\n /**\n * Used to stitch together functional operators into a chain.\n *\n * ## Example\n *\n * ```ts\n * import { interval, filter, map, scan } from 'rxjs';\n *\n * interval(1000)\n * .pipe(\n * filter(x => x % 2 === 0),\n * map(x => x + x),\n * scan((acc, x) => acc + x)\n * )\n * .subscribe(x => console.log(x));\n * ```\n *\n * @return The Observable result of all the operators having been called\n * in the order they were passed in.\n */\n pipe(...operations: OperatorFunction<any, any>[]): Observable<any> {\n return pipeFromArray(operations)(this);\n }\n\n /* tslint:disable:max-line-length */\n /** @deprecated Replaced with {@link firstValueFrom} and {@link lastValueFrom}. Will be removed in v8. Details: https://rxjs.dev/deprecations/to-promise */\n toPromise(): Promise<T | undefined>;\n /** @deprecated Replaced with {@link firstValueFrom} and {@link lastValueFrom}. Will be removed in v8. Details: https://rxjs.dev/deprecations/to-promise */\n toPromise(PromiseCtor: typeof Promise): Promise<T | undefined>;\n /** @deprecated Replaced with {@link firstValueFrom} and {@link lastValueFrom}. Will be removed in v8. Details: https://rxjs.dev/deprecations/to-promise */\n toPromise(PromiseCtor: PromiseConstructorLike): Promise<T | undefined>;\n /* tslint:enable:max-line-length */\n\n /**\n * Subscribe to this Observable and get a Promise resolving on\n * `complete` with the last emission (if any).\n *\n * **WARNING**: Only use this with observables you *know* will complete. If the source\n * observable does not complete, you will end up with a promise that is hung up, and\n * potentially all of the state of an async function hanging out in memory. To avoid\n * this situation, look into adding something like {@link timeout}, {@link take},\n * {@link takeWhile}, or {@link takeUntil} amongst others.\n *\n * @param [promiseCtor] a constructor function used to instantiate\n * the Promise\n * @return A Promise that resolves with the last value emit, or\n * rejects on an error. If there were no emissions, Promise\n * resolves with undefined.\n * @deprecated Replaced with {@link firstValueFrom} and {@link lastValueFrom}. Will be removed in v8. Details: https://rxjs.dev/deprecations/to-promise\n */\n toPromise(promiseCtor?: PromiseConstructorLike): Promise<T | undefined> {\n promiseCtor = getPromiseCtor(promiseCtor);\n\n return new promiseCtor((resolve, reject) => {\n let value: T | undefined;\n this.subscribe(\n (x: T) => (value = x),\n (err: any) => reject(err),\n () => resolve(value)\n );\n }) as Promise<T | undefined>;\n }\n}\n\n/**\n * Decides between a passed promise constructor from consuming code,\n * A default configured promise constructor, and the native promise\n * constructor and returns it. If nothing can be found, it will throw\n * an error.\n * @param promiseCtor The optional promise constructor to passed by consuming code\n */\nfunction getPromiseCtor(promiseCtor: PromiseConstructorLike | undefined) {\n return promiseCtor ?? config.Promise ?? Promise;\n}\n\nfunction isObserver<T>(value: any): value is Observer<T> {\n return value && isFunction(value.next) && isFunction(value.error) && isFunction(value.complete);\n}\n\nfunction isSubscriber<T>(value: any): value is Subscriber<T> {\n return (value && value instanceof Subscriber) || (isObserver(value) && isSubscription(value));\n}\n", "import { Observable } from '../Observable';\nimport { Subscriber } from '../Subscriber';\nimport { OperatorFunction } from '../types';\nimport { isFunction } from './isFunction';\n\n/**\n * Used to determine if an object is an Observable with a lift function.\n */\nexport function hasLift(source: any): source is { lift: InstanceType<typeof Observable>['lift'] } {\n return isFunction(source?.lift);\n}\n\n/**\n * Creates an `OperatorFunction`. Used to define operators throughout the library in a concise way.\n * @param init The logic to connect the liftedSource to the subscriber at the moment of subscription.\n */\nexport function operate<T, R>(\n init: (liftedSource: Observable<T>, subscriber: Subscriber<R>) => (() => void) | void\n): OperatorFunction<T, R> {\n return (source: Observable<T>) => {\n if (hasLift(source)) {\n return source.lift(function (this: Subscriber<R>, liftedSource: Observable<T>) {\n try {\n return init(liftedSource, this);\n } catch (err) {\n this.error(err);\n }\n });\n }\n throw new TypeError('Unable to lift unknown Observable type');\n };\n}\n", "import { Subscriber } from '../Subscriber';\n\n/**\n * Creates an instance of an `OperatorSubscriber`.\n * @param destination The downstream subscriber.\n * @param onNext Handles next values, only called if this subscriber is not stopped or closed. Any\n * error that occurs in this function is caught and sent to the `error` method of this subscriber.\n * @param onError Handles errors from the subscription, any errors that occur in this handler are caught\n * and send to the `destination` error handler.\n * @param onComplete Handles completion notification from the subscription. Any errors that occur in\n * this handler are sent to the `destination` error handler.\n * @param onFinalize Additional teardown logic here. This will only be called on teardown if the\n * subscriber itself is not already closed. This is called after all other teardown logic is executed.\n */\nexport function createOperatorSubscriber<T>(\n destination: Subscriber<any>,\n onNext?: (value: T) => void,\n onComplete?: () => void,\n onError?: (err: any) => void,\n onFinalize?: () => void\n): Subscriber<T> {\n return new OperatorSubscriber(destination, onNext, onComplete, onError, onFinalize);\n}\n\n/**\n * A generic helper for allowing operators to be created with a Subscriber and\n * use closures to capture necessary state from the operator function itself.\n */\nexport class OperatorSubscriber<T> extends Subscriber<T> {\n /**\n * Creates an instance of an `OperatorSubscriber`.\n * @param destination The downstream subscriber.\n * @param onNext Handles next values, only called if this subscriber is not stopped or closed. Any\n * error that occurs in this function is caught and sent to the `error` method of this subscriber.\n * @param onError Handles errors from the subscription, any errors that occur in this handler are caught\n * and send to the `destination` error handler.\n * @param onComplete Handles completion notification from the subscription. Any errors that occur in\n * this handler are sent to the `destination` error handler.\n * @param onFinalize Additional finalization logic here. This will only be called on finalization if the\n * subscriber itself is not already closed. This is called after all other finalization logic is executed.\n * @param shouldUnsubscribe An optional check to see if an unsubscribe call should truly unsubscribe.\n * NOTE: This currently **ONLY** exists to support the strange behavior of {@link groupBy}, where unsubscription\n * to the resulting observable does not actually disconnect from the source if there are active subscriptions\n * to any grouped observable. (DO NOT EXPOSE OR USE EXTERNALLY!!!)\n */\n constructor(\n destination: Subscriber<any>,\n onNext?: (value: T) => void,\n onComplete?: () => void,\n onError?: (err: any) => void,\n private onFinalize?: () => void,\n private shouldUnsubscribe?: () => boolean\n ) {\n // It's important - for performance reasons - that all of this class's\n // members are initialized and that they are always initialized in the same\n // order. This will ensure that all OperatorSubscriber instances have the\n // same hidden class in V8. This, in turn, will help keep the number of\n // hidden classes involved in property accesses within the base class as\n // low as possible. If the number of hidden classes involved exceeds four,\n // the property accesses will become megamorphic and performance penalties\n // will be incurred - i.e. inline caches won't be used.\n //\n // The reasons for ensuring all instances have the same hidden class are\n // further discussed in this blog post from Benedikt Meurer:\n // https://benediktmeurer.de/2018/03/23/impact-of-polymorphism-on-component-based-frameworks-like-react/\n super(destination);\n this._next = onNext\n ? function (this: OperatorSubscriber<T>, value: T) {\n try {\n onNext(value);\n } catch (err) {\n destination.error(err);\n }\n }\n : super._next;\n this._error = onError\n ? function (this: OperatorSubscriber<T>, err: any) {\n try {\n onError(err);\n } catch (err) {\n // Send any errors that occur down stream.\n destination.error(err);\n } finally {\n // Ensure finalization.\n this.unsubscribe();\n }\n }\n : super._error;\n this._complete = onComplete\n ? function (this: OperatorSubscriber<T>) {\n try {\n onComplete();\n } catch (err) {\n // Send any errors that occur down stream.\n destination.error(err);\n } finally {\n // Ensure finalization.\n this.unsubscribe();\n }\n }\n : super._complete;\n }\n\n unsubscribe() {\n if (!this.shouldUnsubscribe || this.shouldUnsubscribe()) {\n const { closed } = this;\n super.unsubscribe();\n // Execute additional teardown if we have any and we didn't already do so.\n !closed && this.onFinalize?.();\n }\n }\n}\n", "export const isArrayLike = (<T>(x: any): x is ArrayLike<T> => x && typeof x.length === 'number' && typeof x !== 'function');", "import { isFunction } from \"./isFunction\";\n\n/**\n * Tests to see if the object is \"thennable\".\n * @param value the object to test\n */\nexport function isPromise(value: any): value is PromiseLike<any> {\n return isFunction(value?.then);\n}\n", "import { InteropObservable } from '../types';\nimport { observable as Symbol_observable } from '../symbol/observable';\nimport { isFunction } from './isFunction';\n\n/** Identifies an input as being Observable (but not necessary an Rx Observable) */\nexport function isInteropObservable(input: any): input is InteropObservable<any> {\n return isFunction(input[Symbol_observable]);\n}\n", "import { isFunction } from './isFunction';\n\nexport function isAsyncIterable<T>(obj: any): obj is AsyncIterable<T> {\n return Symbol.asyncIterator && isFunction(obj?.[Symbol.asyncIterator]);\n}\n", "/**\n * Creates the TypeError to throw if an invalid object is passed to `from` or `scheduled`.\n * @param input The object that was passed.\n */\nexport function createInvalidObservableTypeError(input: any) {\n // TODO: We should create error codes that can be looked up, so this can be less verbose.\n return new TypeError(\n `You provided ${\n input !== null && typeof input === 'object' ? 'an invalid object' : `'${input}'`\n } where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.`\n );\n}\n", "export function getSymbolIterator(): symbol {\n if (typeof Symbol !== 'function' || !Symbol.iterator) {\n return '@@iterator' as any;\n }\n\n return Symbol.iterator;\n}\n\nexport const iterator = getSymbolIterator();\n", "import { iterator as Symbol_iterator } from '../symbol/iterator';\nimport { isFunction } from './isFunction';\n\n/** Identifies an input as being an Iterable */\nexport function isIterable(input: any): input is Iterable<any> {\n return isFunction(input?.[Symbol_iterator]);\n}\n", "import { ReadableStreamLike } from '../types';\nimport { isFunction } from './isFunction';\n\nexport async function* readableStreamLikeToAsyncGenerator<T>(readableStream: ReadableStreamLike<T>): AsyncGenerator<T> {\n const reader = readableStream.getReader();\n try {\n while (true) {\n const { value, done } = await reader.read();\n if (done) {\n return;\n }\n yield value!;\n }\n } finally {\n reader.releaseLock();\n }\n}\n\nexport function isReadableStreamLike<T>(obj: any): obj is ReadableStreamLike<T> {\n // We don't want to use instanceof checks because they would return\n // false for instances from another Realm, like an <iframe>.\n return isFunction(obj?.getReader);\n}\n", "import { isArrayLike } from '../util/isArrayLike';\nimport { isPromise } from '../util/isPromise';\nimport { Observable } from '../Observable';\nimport { ObservableInput, ObservedValueOf, ReadableStreamLike } from '../types';\nimport { isInteropObservable } from '../util/isInteropObservable';\nimport { isAsyncIterable } from '../util/isAsyncIterable';\nimport { createInvalidObservableTypeError } from '../util/throwUnobservableError';\nimport { isIterable } from '../util/isIterable';\nimport { isReadableStreamLike, readableStreamLikeToAsyncGenerator } from '../util/isReadableStreamLike';\nimport { Subscriber } from '../Subscriber';\nimport { isFunction } from '../util/isFunction';\nimport { reportUnhandledError } from '../util/reportUnhandledError';\nimport { observable as Symbol_observable } from '../symbol/observable';\n\nexport function innerFrom<O extends ObservableInput<any>>(input: O): Observable<ObservedValueOf<O>>;\nexport function innerFrom<T>(input: ObservableInput<T>): Observable<T> {\n if (input instanceof Observable) {\n return input;\n }\n if (input != null) {\n if (isInteropObservable(input)) {\n return fromInteropObservable(input);\n }\n if (isArrayLike(input)) {\n return fromArrayLike(input);\n }\n if (isPromise(input)) {\n return fromPromise(input);\n }\n if (isAsyncIterable(input)) {\n return fromAsyncIterable(input);\n }\n if (isIterable(input)) {\n return fromIterable(input);\n }\n if (isReadableStreamLike(input)) {\n return fromReadableStreamLike(input);\n }\n }\n\n throw createInvalidObservableTypeError(input);\n}\n\n/**\n * Creates an RxJS Observable from an object that implements `Symbol.observable`.\n * @param obj An object that properly implements `Symbol.observable`.\n */\nexport function fromInteropObservable<T>(obj: any) {\n return new Observable((subscriber: Subscriber<T>) => {\n const obs = obj[Symbol_observable]();\n if (isFunction(obs.subscribe)) {\n return obs.subscribe(subscriber);\n }\n // Should be caught by observable subscribe function error handling.\n throw new TypeError('Provided object does not correctly implement Symbol.observable');\n });\n}\n\n/**\n * Synchronously emits the values of an array like and completes.\n * This is exported because there are creation functions and operators that need to\n * make direct use of the same logic, and there's no reason to make them run through\n * `from` conditionals because we *know* they're dealing with an array.\n * @param array The array to emit values from\n */\nexport function fromArrayLike<T>(array: ArrayLike<T>) {\n return new Observable((subscriber: Subscriber<T>) => {\n // Loop over the array and emit each value. Note two things here:\n // 1. We're making sure that the subscriber is not closed on each loop.\n // This is so we don't continue looping over a very large array after\n // something like a `take`, `takeWhile`, or other synchronous unsubscription\n // has already unsubscribed.\n // 2. In this form, reentrant code can alter that array we're looping over.\n // This is a known issue, but considered an edge case. The alternative would\n // be to copy the array before executing the loop, but this has\n // performance implications.\n for (let i = 0; i < array.length && !subscriber.closed; i++) {\n subscriber.next(array[i]);\n }\n subscriber.complete();\n });\n}\n\nexport function fromPromise<T>(promise: PromiseLike<T>) {\n return new Observable((subscriber: Subscriber<T>) => {\n promise\n .then(\n (value) => {\n if (!subscriber.closed) {\n subscriber.next(value);\n subscriber.complete();\n }\n },\n (err: any) => subscriber.error(err)\n )\n .then(null, reportUnhandledError);\n });\n}\n\nexport function fromIterable<T>(iterable: Iterable<T>) {\n return new Observable((subscriber: Subscriber<T>) => {\n for (const value of iterable) {\n subscriber.next(value);\n if (subscriber.closed) {\n return;\n }\n }\n subscriber.complete();\n });\n}\n\nexport function fromAsyncIterable<T>(asyncIterable: AsyncIterable<T>) {\n return new Observable((subscriber: Subscriber<T>) => {\n process(asyncIterable, subscriber).catch((err) => subscriber.error(err));\n });\n}\n\nexport function fromReadableStreamLike<T>(readableStream: ReadableStreamLike<T>) {\n return fromAsyncIterable(readableStreamLikeToAsyncGenerator(readableStream));\n}\n\nasync function process<T>(asyncIterable: AsyncIterable<T>, subscriber: Subscriber<T>) {\n for await (const value of asyncIterable) {\n subscriber.next(value);\n // A side-effect may have closed our subscriber,\n // check before the next iteration.\n if (subscriber.closed) {\n return;\n }\n }\n subscriber.complete();\n}\n", "import { Subscription } from '../Subscription';\nimport { SchedulerAction, SchedulerLike } from '../types';\n\nexport function executeSchedule(\n parentSubscription: Subscription,\n scheduler: SchedulerLike,\n work: () => void,\n delay: number,\n repeat: true\n): void;\nexport function executeSchedule(\n parentSubscription: Subscription,\n scheduler: SchedulerLike,\n work: () => void,\n delay?: number,\n repeat?: false\n): Subscription;\n\nexport function executeSchedule(\n parentSubscription: Subscription,\n scheduler: SchedulerLike,\n work: () => void,\n delay = 0,\n repeat = false\n): Subscription | void {\n const scheduleSubscription = scheduler.schedule(function (this: SchedulerAction<any>) {\n work();\n if (repeat) {\n parentSubscription.add(this.schedule(null, delay));\n } else {\n this.unsubscribe();\n }\n }, delay);\n\n parentSubscription.add(scheduleSubscription);\n\n if (!repeat) {\n // Because user-land scheduler implementations are unlikely to properly reuse\n // Actions for repeat scheduling, we can't trust that the returned subscription\n // will control repeat subscription scenarios. So we're trying to avoid using them\n // incorrectly within this library.\n return scheduleSubscription;\n }\n}\n", "/** @prettier */\nimport { MonoTypeOperatorFunction, SchedulerLike } from '../types';\nimport { executeSchedule } from '../util/executeSchedule';\nimport { operate } from '../util/lift';\nimport { createOperatorSubscriber } from './OperatorSubscriber';\n\n/**\n * Re-emits all notifications from source Observable with specified scheduler.\n *\n * <span class=\"informal\">Ensure a specific scheduler is used, from outside of an Observable.</span>\n *\n * `observeOn` is an operator that accepts a scheduler as a first parameter, which will be used to reschedule\n * notifications emitted by the source Observable. It might be useful, if you do not have control over\n * internal scheduler of a given Observable, but want to control when its values are emitted nevertheless.\n *\n * Returned Observable emits the same notifications (nexted values, complete and error events) as the source Observable,\n * but rescheduled with provided scheduler. Note that this doesn't mean that source Observables internal\n * scheduler will be replaced in any way. Original scheduler still will be used, but when the source Observable emits\n * notification, it will be immediately scheduled again - this time with scheduler passed to `observeOn`.\n * An anti-pattern would be calling `observeOn` on Observable that emits lots of values synchronously, to split\n * that emissions into asynchronous chunks. For this to happen, scheduler would have to be passed into the source\n * Observable directly (usually into the operator that creates it). `observeOn` simply delays notifications a\n * little bit more, to ensure that they are emitted at expected moments.\n *\n * As a matter of fact, `observeOn` accepts second parameter, which specifies in milliseconds with what delay notifications\n * will be emitted. The main difference between {@link delay} operator and `observeOn` is that `observeOn`\n * will delay all notifications - including error notifications - while `delay` will pass through error\n * from source Observable immediately when it is emitted. In general it is highly recommended to use `delay` operator\n * for any kind of delaying of values in the stream, while using `observeOn` to specify which scheduler should be used\n * for notification emissions in general.\n *\n * ## Example\n *\n * Ensure values in subscribe are called just before browser repaint\n *\n * ```ts\n * import { interval, observeOn, animationFrameScheduler } from 'rxjs';\n *\n * const someDiv = document.createElement('div');\n * someDiv.style.cssText = 'width: 200px;background: #09c';\n * document.body.appendChild(someDiv);\n * const intervals = interval(10); // Intervals are scheduled\n * // with async scheduler by default...\n * intervals.pipe(\n * observeOn(animationFrameScheduler) // ...but we will observe on animationFrame\n * ) // scheduler to ensure smooth animation.\n * .subscribe(val => {\n * someDiv.style.height = val + 'px';\n * });\n * ```\n *\n * @see {@link delay}\n *\n * @param scheduler Scheduler that will be used to reschedule notifications from source Observable.\n * @param delay Number of milliseconds that states with what delay every notification should be rescheduled.\n * @return A function that returns an Observable that emits the same\n * notifications as the source Observable, but with provided scheduler.\n */\nexport function observeOn<T>(scheduler: SchedulerLike, delay = 0): MonoTypeOperatorFunction<T> {\n return operate((source, subscriber) => {\n source.subscribe(\n createOperatorSubscriber(\n subscriber,\n (value) => executeSchedule(subscriber, scheduler, () => subscriber.next(value), delay),\n () => executeSchedule(subscriber, scheduler, () => subscriber.complete(), delay),\n (err) => executeSchedule(subscriber, scheduler, () => subscriber.error(err), delay)\n )\n );\n });\n}\n", "import { MonoTypeOperatorFunction, SchedulerLike } from '../types';\nimport { operate } from '../util/lift';\n\n/**\n * Asynchronously subscribes Observers to this Observable on the specified {@link SchedulerLike}.\n *\n * With `subscribeOn` you can decide what type of scheduler a specific Observable will be using when it is subscribed to.\n *\n * Schedulers control the speed and order of emissions to observers from an Observable stream.\n *\n * \n *\n * ## Example\n *\n * Given the following code:\n *\n * ```ts\n * import { of, merge } from 'rxjs';\n *\n * const a = of(1, 2, 3);\n * const b = of(4, 5, 6);\n *\n * merge(a, b).subscribe(console.log);\n *\n * // Outputs\n * // 1\n * // 2\n * // 3\n * // 4\n * // 5\n * // 6\n * ```\n *\n * Both Observable `a` and `b` will emit their values directly and synchronously once they are subscribed to.\n *\n * If we instead use the `subscribeOn` operator declaring that we want to use the {@link asyncScheduler} for values emitted by Observable `a`:\n *\n * ```ts\n * import { of, subscribeOn, asyncScheduler, merge } from 'rxjs';\n *\n * const a = of(1, 2, 3).pipe(subscribeOn(asyncScheduler));\n * const b = of(4, 5, 6);\n *\n * merge(a, b).subscribe(console.log);\n *\n * // Outputs\n * // 4\n * // 5\n * // 6\n * // 1\n * // 2\n * // 3\n * ```\n *\n * The reason for this is that Observable `b` emits its values directly and synchronously like before\n * but the emissions from `a` are scheduled on the event loop because we are now using the {@link asyncScheduler} for that specific Observable.\n *\n * @param scheduler The {@link SchedulerLike} to perform subscription actions on.\n * @param delay A delay to pass to the scheduler to delay subscriptions\n * @return A function that returns an Observable modified so that its\n * subscriptions happen on the specified {@link SchedulerLike}.\n */\nexport function subscribeOn<T>(scheduler: SchedulerLike, delay: number = 0): MonoTypeOperatorFunction<T> {\n return operate((source, subscriber) => {\n subscriber.add(scheduler.schedule(() => source.subscribe(subscriber), delay));\n });\n}\n", "import { innerFrom } from '../observable/innerFrom';\nimport { observeOn } from '../operators/observeOn';\nimport { subscribeOn } from '../operators/subscribeOn';\nimport { InteropObservable, SchedulerLike } from '../types';\n\nexport function scheduleObservable<T>(input: InteropObservable<T>, scheduler: SchedulerLike) {\n return innerFrom(input).pipe(subscribeOn(scheduler), observeOn(scheduler));\n}\n", "import { innerFrom } from '../observable/innerFrom';\nimport { observeOn } from '../operators/observeOn';\nimport { subscribeOn } from '../operators/subscribeOn';\nimport { SchedulerLike } from '../types';\n\nexport function schedulePromise<T>(input: PromiseLike<T>, scheduler: SchedulerLike) {\n return innerFrom(input).pipe(subscribeOn(scheduler), observeOn(scheduler));\n}\n", "import { Observable } from '../Observable';\nimport { SchedulerLike } from '../types';\n\nexport function scheduleArray<T>(input: ArrayLike<T>, scheduler: SchedulerLike) {\n return new Observable<T>((subscriber) => {\n // The current array index.\n let i = 0;\n // Start iterating over the array like on a schedule.\n return scheduler.schedule(function () {\n if (i === input.length) {\n // If we have hit the end of the array like in the\n // previous job, we can complete.\n subscriber.complete();\n } else {\n // Otherwise let's next the value at the current index,\n // then increment our index.\n subscriber.next(input[i++]);\n // If the last emission didn't cause us to close the subscriber\n // (via take or some side effect), reschedule the job and we'll\n // make another pass.\n if (!subscriber.closed) {\n this.schedule();\n }\n }\n });\n });\n}\n", "import { Observable } from '../Observable';\nimport { SchedulerLike } from '../types';\nimport { iterator as Symbol_iterator } from '../symbol/iterator';\nimport { isFunction } from '../util/isFunction';\nimport { executeSchedule } from '../util/executeSchedule';\n\n/**\n * Used in {@link scheduled} to create an observable from an Iterable.\n * @param input The iterable to create an observable from\n * @param scheduler The scheduler to use\n */\nexport function scheduleIterable<T>(input: Iterable<T>, scheduler: SchedulerLike) {\n return new Observable<T>((subscriber) => {\n let iterator: Iterator<T, T>;\n\n // Schedule the initial creation of the iterator from\n // the iterable. This is so the code in the iterable is\n // not called until the scheduled job fires.\n executeSchedule(subscriber, scheduler, () => {\n // Create the iterator.\n iterator = (input as any)[Symbol_iterator]();\n\n executeSchedule(\n subscriber,\n scheduler,\n () => {\n let value: T;\n let done: boolean | undefined;\n try {\n // Pull the value out of the iterator\n ({ value, done } = iterator.next());\n } catch (err) {\n // We got an error while pulling from the iterator\n subscriber.error(err);\n return;\n }\n\n if (done) {\n // If it is \"done\" we just complete. This mimics the\n // behavior of JavaScript's `for..of` consumption of\n // iterables, which will not emit the value from an iterator\n // result of `{ done: true: value: 'here' }`.\n subscriber.complete();\n } else {\n // The iterable is not done, emit the value.\n subscriber.next(value);\n }\n },\n 0,\n true\n );\n });\n\n // During finalization, if we see this iterator has a `return` method,\n // then we know it is a Generator, and not just an Iterator. So we call\n // the `return()` function. This will ensure that any `finally { }` blocks\n // inside of the generator we can hit will be hit properly.\n return () => isFunction(iterator?.return) && iterator.return();\n });\n}\n", "import { SchedulerLike } from '../types';\nimport { Observable } from '../Observable';\nimport { executeSchedule } from '../util/executeSchedule';\n\nexport function scheduleAsyncIterable<T>(input: AsyncIterable<T>, scheduler: SchedulerLike) {\n if (!input) {\n throw new Error('Iterable cannot be null');\n }\n return new Observable<T>((subscriber) => {\n executeSchedule(subscriber, scheduler, () => {\n const iterator = input[Symbol.asyncIterator]();\n executeSchedule(\n subscriber,\n scheduler,\n () => {\n iterator.next().then((result) => {\n if (result.done) {\n // This will remove the subscriptions from\n // the parent subscription.\n subscriber.complete();\n } else {\n subscriber.next(result.value);\n }\n });\n },\n 0,\n true\n );\n });\n });\n}\n", "import { SchedulerLike, ReadableStreamLike } from '../types';\nimport { Observable } from '../Observable';\nimport { scheduleAsyncIterable } from './scheduleAsyncIterable';\nimport { readableStreamLikeToAsyncGenerator } from '../util/isReadableStreamLike';\n\nexport function scheduleReadableStreamLike<T>(input: ReadableStreamLike<T>, scheduler: SchedulerLike): Observable<T> {\n return scheduleAsyncIterable(readableStreamLikeToAsyncGenerator(input), scheduler);\n}\n", "import { scheduleObservable } from './scheduleObservable';\nimport { schedulePromise } from './schedulePromise';\nimport { scheduleArray } from './scheduleArray';\nimport { scheduleIterable } from './scheduleIterable';\nimport { scheduleAsyncIterable } from './scheduleAsyncIterable';\nimport { isInteropObservable } from '../util/isInteropObservable';\nimport { isPromise } from '../util/isPromise';\nimport { isArrayLike } from '../util/isArrayLike';\nimport { isIterable } from '../util/isIterable';\nimport { ObservableInput, SchedulerLike } from '../types';\nimport { Observable } from '../Observable';\nimport { isAsyncIterable } from '../util/isAsyncIterable';\nimport { createInvalidObservableTypeError } from '../util/throwUnobservableError';\nimport { isReadableStreamLike } from '../util/isReadableStreamLike';\nimport { scheduleReadableStreamLike } from './scheduleReadableStreamLike';\n\n/**\n * Converts from a common {@link ObservableInput} type to an observable where subscription and emissions\n * are scheduled on the provided scheduler.\n *\n * @see {@link from}\n * @see {@link of}\n *\n * @param input The observable, array, promise, iterable, etc you would like to schedule\n * @param scheduler The scheduler to use to schedule the subscription and emissions from\n * the returned observable.\n */\nexport function scheduled<T>(input: ObservableInput<T>, scheduler: SchedulerLike): Observable<T> {\n if (input != null) {\n if (isInteropObservable(input)) {\n return scheduleObservable(input, scheduler);\n }\n if (isArrayLike(input)) {\n return scheduleArray(input, scheduler);\n }\n if (isPromise(input)) {\n return schedulePromise(input, scheduler);\n }\n if (isAsyncIterable(input)) {\n return scheduleAsyncIterable(input, scheduler);\n }\n if (isIterable(input)) {\n return scheduleIterable(input, scheduler);\n }\n if (isReadableStreamLike(input)) {\n return scheduleReadableStreamLike(input, scheduler);\n }\n }\n throw createInvalidObservableTypeError(input);\n}\n", "import { Observable } from '../Observable';\nimport { ObservableInput, SchedulerLike, ObservedValueOf } from '../types';\nimport { scheduled } from '../scheduled/scheduled';\nimport { innerFrom } from './innerFrom';\n\nexport function from<O extends ObservableInput<any>>(input: O): Observable<ObservedValueOf<O>>;\n/** @deprecated The `scheduler` parameter will be removed in v8. Use `scheduled`. Details: https://rxjs.dev/deprecations/scheduler-argument */\nexport function from<O extends ObservableInput<any>>(input: O, scheduler: SchedulerLike | undefined): Observable<ObservedValueOf<O>>;\n\n/**\n * Creates an Observable from an Array, an array-like object, a Promise, an iterable object, or an Observable-like object.\n *\n * <span class=\"informal\">Converts almost anything to an Observable.</span>\n *\n * \n *\n * `from` converts various other objects and data types into Observables. It also converts a Promise, an array-like, or an\n * <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#iterable\" target=\"_blank\">iterable</a>\n * object into an Observable that emits the items in that promise, array, or iterable. A String, in this context, is treated\n * as an array of characters. Observable-like objects (contains a function named with the ES2015 Symbol for Observable) can also be\n * converted through this operator.\n *\n * ## Examples\n *\n * Converts an array to an Observable\n *\n * ```ts\n * import { from } from 'rxjs';\n *\n * const array = [10, 20, 30];\n * const result = from(array);\n *\n * result.subscribe(x => console.log(x));\n *\n * // Logs:\n * // 10\n * // 20\n * // 30\n * ```\n *\n * Convert an infinite iterable (from a generator) to an Observable\n *\n * ```ts\n * import { from, take } from 'rxjs';\n *\n * function* generateDoubles(seed) {\n * let i = seed;\n * while (true) {\n * yield i;\n * i = 2 * i; // double it\n * }\n * }\n *\n * const iterator = generateDoubles(3);\n * const result = from(iterator).pipe(take(10));\n *\n * result.subscribe(x => console.log(x));\n *\n * // Logs:\n * // 3\n * // 6\n * // 12\n * // 24\n * // 48\n * // 96\n * // 192\n * // 384\n * // 768\n * // 1536\n * ```\n *\n * With `asyncScheduler`\n *\n * ```ts\n * import { from, asyncScheduler } from 'rxjs';\n *\n * console.log('start');\n *\n * const array = [10, 20, 30];\n * const result = from(array, asyncScheduler);\n *\n * result.subscribe(x => console.log(x));\n *\n * console.log('end');\n *\n * // Logs:\n * // 'start'\n * // 'end'\n * // 10\n * // 20\n * // 30\n * ```\n *\n * @see {@link fromEvent}\n * @see {@link fromEventPattern}\n *\n * @param input A subscription object, a Promise, an Observable-like,\n * an Array, an iterable, or an array-like object to be converted.\n * @param scheduler An optional {@link SchedulerLike} on which to schedule the emission of values.\n * @return An Observable converted from {@link ObservableInput}.\n */\nexport function from<T>(input: ObservableInput<T>, scheduler?: SchedulerLike): Observable<T> {\n return scheduler ? scheduled(input, scheduler) : innerFrom(input);\n}\n", "import { OperatorFunction } from '../types';\nimport { operate } from '../util/lift';\nimport { createOperatorSubscriber } from './OperatorSubscriber';\n\nexport function map<T, R>(project: (value: T, index: number) => R): OperatorFunction<T, R>;\n/** @deprecated Use a closure instead of a `thisArg`. Signatures accepting a `thisArg` will be removed in v8. */\nexport function map<T, R, A>(project: (this: A, value: T, index: number) => R, thisArg: A): OperatorFunction<T, R>;\n\n/**\n * Applies a given `project` function to each value emitted by the source\n * Observable, and emits the resulting values as an Observable.\n *\n * <span class=\"informal\">Like [Array.prototype.map()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map),\n * it passes each source value through a transformation function to get\n * corresponding output values.</span>\n *\n * \n *\n * Similar to the well known `Array.prototype.map` function, this operator\n * applies a projection to each value and emits that projection in the output\n * Observable.\n *\n * ## Example\n *\n * Map every click to the `clientX` position of that click\n *\n * ```ts\n * import { fromEvent, map } from 'rxjs';\n *\n * const clicks = fromEvent<PointerEvent>(document, 'click');\n * const positions = clicks.pipe(map(ev => ev.clientX));\n *\n * positions.subscribe(x => console.log(x));\n * ```\n *\n * @see {@link mapTo}\n * @see {@link pluck}\n *\n * @param project The function to apply to each `value` emitted by the source\n * Observable. The `index` parameter is the number `i` for the i-th emission\n * that has happened since the subscription, starting from the number `0`.\n * @param thisArg An optional argument to define what `this` is in the\n * `project` function.\n * @return A function that returns an Observable that emits the values from the\n * source Observable transformed by the given `project` function.\n */\nexport function map<T, R>(project: (value: T, index: number) => R, thisArg?: any): OperatorFunction<T, R> {\n return operate((source, subscriber) => {\n // The index of the value from the source. Used with projection.\n let index = 0;\n // Subscribe to the source, all errors and completions are sent along\n // to the consumer.\n source.subscribe(\n createOperatorSubscriber(subscriber, (value: T) => {\n // Call the projection function with the appropriate this context,\n // and send the resulting value to the consumer.\n subscriber.next(project.call(thisArg, value, index++));\n })\n );\n });\n}\n", "import { Observable } from '../Observable';\nimport { innerFrom } from '../observable/innerFrom';\nimport { Subscriber } from '../Subscriber';\nimport { ObservableInput, SchedulerLike } from '../types';\nimport { executeSchedule } from '../util/executeSchedule';\nimport { createOperatorSubscriber } from './OperatorSubscriber';\n\n/**\n * A process embodying the general \"merge\" strategy. This is used in\n * `mergeMap` and `mergeScan` because the logic is otherwise nearly identical.\n * @param source The original source observable\n * @param subscriber The consumer subscriber\n * @param project The projection function to get our inner sources\n * @param concurrent The number of concurrent inner subscriptions\n * @param onBeforeNext Additional logic to apply before nexting to our consumer\n * @param expand If `true` this will perform an \"expand\" strategy, which differs only\n * in that it recurses, and the inner subscription must be schedule-able.\n * @param innerSubScheduler A scheduler to use to schedule inner subscriptions,\n * this is to support the expand strategy, mostly, and should be deprecated\n */\nexport function mergeInternals<T, R>(\n source: Observable<T>,\n subscriber: Subscriber<R>,\n project: (value: T, index: number) => ObservableInput<R>,\n concurrent: number,\n onBeforeNext?: (innerValue: R) => void,\n expand?: boolean,\n innerSubScheduler?: SchedulerLike,\n additionalFinalizer?: () => void\n) {\n // Buffered values, in the event of going over our concurrency limit\n const buffer: T[] = [];\n // The number of active inner subscriptions.\n let active = 0;\n // An index to pass to our accumulator function\n let index = 0;\n // Whether or not the outer source has completed.\n let isComplete = false;\n\n /**\n * Checks to see if we can complete our result or not.\n */\n const checkComplete = () => {\n // If the outer has completed, and nothing is left in the buffer,\n // and we don't have any active inner subscriptions, then we can\n // Emit the state and complete.\n if (isComplete && !buffer.length && !active) {\n subscriber.complete();\n }\n };\n\n // If we're under our concurrency limit, just start the inner subscription, otherwise buffer and wait.\n const outerNext = (value: T) => (active < concurrent ? doInnerSub(value) : buffer.push(value));\n\n const doInnerSub = (value: T) => {\n // If we're expanding, we need to emit the outer values and the inner values\n // as the inners will \"become outers\" in a way as they are recursively fed\n // back to the projection mechanism.\n expand && subscriber.next(value as any);\n\n // Increment the number of active subscriptions so we can track it\n // against our concurrency limit later.\n active++;\n\n // A flag used to show that the inner observable completed.\n // This is checked during finalization to see if we should\n // move to the next item in the buffer, if there is on.\n let innerComplete = false;\n\n // Start our inner subscription.\n innerFrom(project(value, index++)).subscribe(\n createOperatorSubscriber(\n subscriber,\n (innerValue) => {\n // `mergeScan` has additional handling here. For example\n // taking the inner value and updating state.\n onBeforeNext?.(innerValue);\n\n if (expand) {\n // If we're expanding, then just recurse back to our outer\n // handler. It will emit the value first thing.\n outerNext(innerValue as any);\n } else {\n // Otherwise, emit the inner value.\n subscriber.next(innerValue);\n }\n },\n () => {\n // Flag that we have completed, so we know to check the buffer\n // during finalization.\n innerComplete = true;\n },\n // Errors are passed to the destination.\n undefined,\n () => {\n // During finalization, if the inner completed (it wasn't errored or\n // cancelled), then we want to try the next item in the buffer if\n // there is one.\n if (innerComplete) {\n // We have to wrap this in a try/catch because it happens during\n // finalization, possibly asynchronously, and we want to pass\n // any errors that happen (like in a projection function) to\n // the outer Subscriber.\n try {\n // INNER SOURCE COMPLETE\n // Decrement the active count to ensure that the next time\n // we try to call `doInnerSub`, the number is accurate.\n active--;\n // If we have more values in the buffer, try to process those\n // Note that this call will increment `active` ahead of the\n // next conditional, if there were any more inner subscriptions\n // to start.\n while (buffer.length && active < concurrent) {\n const bufferedValue = buffer.shift()!;\n // Particularly for `expand`, we need to check to see if a scheduler was provided\n // for when we want to start our inner subscription. Otherwise, we just start\n // are next inner subscription.\n if (innerSubScheduler) {\n executeSchedule(subscriber, innerSubScheduler, () => doInnerSub(bufferedValue));\n } else {\n doInnerSub(bufferedValue);\n }\n }\n // Check to see if we can complete, and complete if so.\n checkComplete();\n } catch (err) {\n subscriber.error(err);\n }\n }\n }\n )\n );\n };\n\n // Subscribe to our source observable.\n source.subscribe(\n createOperatorSubscriber(subscriber, outerNext, () => {\n // Outer completed, make a note of it, and check to see if we can complete everything.\n isComplete = true;\n checkComplete();\n })\n );\n\n // Additional finalization (for when the destination is torn down).\n // Other finalization is added implicitly via subscription above.\n return () => {\n additionalFinalizer?.();\n };\n}\n", "import { ObservableInput, OperatorFunction, ObservedValueOf } from '../types';\nimport { map } from './map';\nimport { innerFrom } from '../observable/innerFrom';\nimport { operate } from '../util/lift';\nimport { mergeInternals } from './mergeInternals';\nimport { isFunction } from '../util/isFunction';\n\n/* tslint:disable:max-line-length */\nexport function mergeMap<T, O extends ObservableInput<any>>(\n project: (value: T, index: number) => O,\n concurrent?: number\n): OperatorFunction<T, ObservedValueOf<O>>;\n/** @deprecated The `resultSelector` parameter will be removed in v8. Use an inner `map` instead. Details: https://rxjs.dev/deprecations/resultSelector */\nexport function mergeMap<T, O extends ObservableInput<any>>(\n project: (value: T, index: number) => O,\n resultSelector: undefined,\n concurrent?: number\n): OperatorFunction<T, ObservedValueOf<O>>;\n/** @deprecated The `resultSelector` parameter will be removed in v8. Use an inner `map` instead. Details: https://rxjs.dev/deprecations/resultSelector */\nexport function mergeMap<T, R, O extends ObservableInput<any>>(\n project: (value: T, index: number) => O,\n resultSelector: (outerValue: T, innerValue: ObservedValueOf<O>, outerIndex: number, innerIndex: number) => R,\n concurrent?: number\n): OperatorFunction<T, R>;\n/* tslint:enable:max-line-length */\n\n/**\n * Projects each source value to an Observable which is merged in the output\n * Observable.\n *\n * <span class=\"informal\">Maps each value to an Observable, then flattens all of\n * these inner Observables using {@link mergeAll}.</span>\n *\n * \n *\n * Returns an Observable that emits items based on applying a function that you\n * supply to each item emitted by the source Observable, where that function\n * returns an Observable, and then merging those resulting Observables and\n * emitting the results of this merger.\n *\n * ## Example\n *\n * Map and flatten each letter to an Observable ticking every 1 second\n *\n * ```ts\n * import { of, mergeMap, interval, map } from 'rxjs';\n *\n * const letters = of('a', 'b', 'c');\n * const result = letters.pipe(\n * mergeMap(x => interval(1000).pipe(map(i => x + i)))\n * );\n *\n * result.subscribe(x => console.log(x));\n *\n * // Results in the following:\n * // a0\n * // b0\n * // c0\n * // a1\n * // b1\n * // c1\n * // continues to list a, b, c every second with respective ascending integers\n * ```\n *\n * @see {@link concatMap}\n * @see {@link exhaustMap}\n * @see {@link merge}\n * @see {@link mergeAll}\n * @see {@link mergeMapTo}\n * @see {@link mergeScan}\n * @see {@link switchMap}\n *\n * @param project A function that, when applied to an item emitted by the source\n * Observable, returns an Observable.\n * @param concurrent Maximum number of `ObservableInput`s being subscribed to concurrently.\n * @return A function that returns an Observable that emits the result of\n * applying the projection function (and the optional deprecated\n * `resultSelector`) to each item emitted by the source Observable and merging\n * the results of the Observables obtained from this transformation.\n */\nexport function mergeMap<T, R, O extends ObservableInput<any>>(\n project: (value: T, index: number) => O,\n resultSelector?: ((outerValue: T, innerValue: ObservedValueOf<O>, outerIndex: number, innerIndex: number) => R) | number,\n concurrent: number = Infinity\n): OperatorFunction<T, ObservedValueOf<O> | R> {\n if (isFunction(resultSelector)) {\n // DEPRECATED PATH\n return mergeMap((a, i) => map((b: any, ii: number) => resultSelector(a, b, i, ii))(innerFrom(project(a, i))), concurrent);\n } else if (typeof resultSelector === 'number') {\n concurrent = resultSelector;\n }\n\n return operate((source, subscriber) => mergeInternals(source, subscriber, project, concurrent));\n}\n", "import { Observable } from '../Observable';\nimport { Subscriber } from '../Subscriber';\nimport { createOperatorSubscriber } from './OperatorSubscriber';\n\n/**\n * A basic scan operation. This is used for `scan` and `reduce`.\n * @param accumulator The accumulator to use\n * @param seed The seed value for the state to accumulate\n * @param hasSeed Whether or not a seed was provided\n * @param emitOnNext Whether or not to emit the state on next\n * @param emitBeforeComplete Whether or not to emit the before completion\n */\n\nexport function scanInternals<V, A, S>(\n accumulator: (acc: V | A | S, value: V, index: number) => A,\n seed: S,\n hasSeed: boolean,\n emitOnNext: boolean,\n emitBeforeComplete?: undefined | true\n) {\n return (source: Observable<V>, subscriber: Subscriber<any>) => {\n // Whether or not we have state yet. This will only be\n // false before the first value arrives if we didn't get\n // a seed value.\n let hasState = hasSeed;\n // The state that we're tracking, starting with the seed,\n // if there is one, and then updated by the return value\n // from the accumulator on each emission.\n let state: any = seed;\n // An index to pass to the accumulator function.\n let index = 0;\n\n // Subscribe to our source. All errors and completions are passed through.\n source.subscribe(\n createOperatorSubscriber(\n subscriber,\n (value) => {\n // Always increment the index.\n const i = index++;\n // Set the state\n state = hasState\n ? // We already have state, so we can get the new state from the accumulator\n accumulator(state, value, i)\n : // We didn't have state yet, a seed value was not provided, so\n\n // we set the state to the first value, and mark that we have state now\n ((hasState = true), value);\n\n // Maybe send it to the consumer.\n emitOnNext && subscriber.next(state);\n },\n // If an onComplete was given, call it, otherwise\n // just pass through the complete notification to the consumer.\n emitBeforeComplete &&\n (() => {\n hasState && subscriber.next(state);\n subscriber.complete();\n })\n )\n );\n };\n}\n", "import { scanInternals } from './scanInternals';\nimport { OperatorFunction } from '../types';\nimport { operate } from '../util/lift';\n\nexport function reduce<V, A = V>(accumulator: (acc: A | V, value: V, index: number) => A): OperatorFunction<V, V | A>;\nexport function reduce<V, A>(accumulator: (acc: A, value: V, index: number) => A, seed: A): OperatorFunction<V, A>;\nexport function reduce<V, A, S = A>(accumulator: (acc: A | S, value: V, index: number) => A, seed: S): OperatorFunction<V, A>;\n\n/**\n * Applies an accumulator function over the source Observable, and returns the\n * accumulated result when the source completes, given an optional seed value.\n *\n * <span class=\"informal\">Combines together all values emitted on the source,\n * using an accumulator function that knows how to join a new source value into\n * the accumulation from the past.</span>\n *\n * \n *\n * Like\n * [Array.prototype.reduce()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce),\n * `reduce` applies an `accumulator` function against an accumulation and each\n * value of the source Observable (from the past) to reduce it to a single\n * value, emitted on the output Observable. Note that `reduce` will only emit\n * one value, only when the source Observable completes. It is equivalent to\n * applying operator {@link scan} followed by operator {@link last}.\n *\n * Returns an Observable that applies a specified `accumulator` function to each\n * item emitted by the source Observable. If a `seed` value is specified, then\n * that value will be used as the initial value for the accumulator. If no seed\n * value is specified, the first item of the source is used as the seed.\n *\n * ## Example\n *\n * Count the number of click events that happened in 5 seconds\n *\n * ```ts\n * import { fromEvent, takeUntil, interval, map, reduce } from 'rxjs';\n *\n * const clicksInFiveSeconds = fromEvent(document, 'click')\n * .pipe(takeUntil(interval(5000)));\n *\n * const ones = clicksInFiveSeconds.pipe(map(() => 1));\n * const seed = 0;\n * const count = ones.pipe(reduce((acc, one) => acc + one, seed));\n *\n * count.subscribe(x => console.log(x));\n * ```\n *\n * @see {@link count}\n * @see {@link expand}\n * @see {@link mergeScan}\n * @see {@link scan}\n *\n * @param accumulator The accumulator function called on each source value.\n * @param seed The initial accumulation value.\n * @return A function that returns an Observable that emits a single value that\n * is the result of accumulating the values emitted by the source Observable.\n */\nexport function reduce<V, A>(accumulator: (acc: V | A, value: V, index: number) => A, seed?: any): OperatorFunction<V, V | A> {\n return operate(scanInternals(accumulator, seed, arguments.length >= 2, false, true));\n}\n", "import { reduce } from './reduce';\nimport { OperatorFunction } from '../types';\nimport { operate } from '../util/lift';\n\nconst arrReducer = (arr: any[], value: any) => (arr.push(value), arr);\n\n/**\n * Collects all source emissions and emits them as an array when the source completes.\n *\n * <span class=\"informal\">Get all values inside an array when the source completes</span>\n *\n * \n *\n * `toArray` will wait until the source Observable completes before emitting\n * the array containing all emissions. When the source Observable errors no\n * array will be emitted.\n *\n * ## Example\n *\n * ```ts\n * import { interval, take, toArray } from 'rxjs';\n *\n * const source = interval(1000);\n * const example = source.pipe(\n * take(10),\n * toArray()\n * );\n *\n * example.subscribe(value => console.log(value));\n *\n * // output: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n * ```\n *\n * @return A function that returns an Observable that emits an array of items\n * emitted by the source Observable when source completes.\n */\nexport function toArray<T>(): OperatorFunction<T, T[]> {\n // Because arrays are mutable, and we're mutating the array in this\n // reducer process, we have to encapsulate the creation of the initial\n // array within this `operate` function.\n return operate((source, subscriber) => {\n reduce(arrReducer, [] as T[])(source).subscribe(subscriber);\n });\n}\n", "import { CIGAR_D, CIGAR_EQ, CIGAR_I, CIGAR_M, CIGAR_N, CIGAR_RUN, CIGAR_X, parseCigar2Typed, parseCoarseCigar, } from '@jbrowse/cigar-utils';\n// Per-perspective PIF/PAF CIGAR consumption, matching buildSyntenyGeometry's\n// walk: bp1 (query / v1 side) advances on M/=/X and D/N; bp2 (target / v2 side)\n// advances on M/=/X and I. The D<->I asymmetry is the pre-swap the PIF t-line\n// carries, so a clip produced here stays consistent when it feeds back through\n// the same convention.\n//\n// Spelled as ENUMERATED op sets, so H/S/P advance NEITHER axis. That is the\n// convention every other walk in the tree uses \u2014 `visitCigarRenderedSegments`\n// (the walk this clip's own output is re-walked by, which has no branch for them\n// at all) and `findPosInCigar`, whose header says so explicitly. Written as\n// `op !== CIGAR_I` / `op !== CIGAR_D && op !== CIGAR_N` these advanced BOTH axes\n// on a clip, which stays invisible only because a PAF/PIF CIGAR carries none. A\n// BAM-sourced one does: \"Linear read vs ref\" hands the read's raw CIGAR through\n// verbatim while putting the mate in read coordinates that already EXCLUDE the\n// clip (`buildReadVsRefFeatures`, `clipLengthAtStartOfRead`). So a leading\n// `100S` walked the re-anchored block 100bp along both axes past where the block\n// says it starts, and since `clipLargeBlockToWindow` fires once a block exceeds\n// 4x the window \u2014 ~1bp/px on a 20kb read segment, an ordinary inspection zoom \u2014\n// every CIGAR tile and marker on it landed 100bp short of the ribbon it sits in,\n// which in transparent-indels mode is a hole at the trailing end.\n//\n// Bitmasks in `((1 << op) & MASK)` form, the idiom `CIGAR_INDEL_MASK` already\n// carries in this directory (buildSyntenyGeometry's `cigarSegmentKind`), so\n// membership is one test rather than a chain of five. Built from the op\n// constants rather than written as literals: the point of the fix is that the\n// SET is the thing to read, and `0b110001101` hides it. Deliberately local \u2014\n// `visitCigarRenderedSegments` is the authority here and it branches per op to\n// decide WHICH axis, so a mask does not fit it, and a shared one it could not\n// use would just be a second statement of the same convention.\nconst V1_OPS = (1 << CIGAR_M) |\n (1 << CIGAR_EQ) |\n (1 << CIGAR_X) |\n (1 << CIGAR_D) |\n (1 << CIGAR_N);\nconst V2_OPS = (1 << CIGAR_M) | (1 << CIGAR_EQ) | (1 << CIGAR_X) | (1 << CIGAR_I);\nconst MATCH_OPS = (1 << CIGAR_M) | (1 << CIGAR_EQ) | (1 << CIGAR_X);\nfunction consumesQuery(op) {\n return ((1 << op) & V1_OPS) !== 0;\n}\nfunction consumesTarget(op) {\n return ((1 << op) & V2_OPS) !== 0;\n}\nfunction isMatchOp(op) {\n return ((1 << op) & MATCH_OPS) !== 0;\n}\n// Trim a synteny feature + its CIGAR to a query-space window\n// [winStart, winEnd], returning the re-anchored coords + trimmed CIGAR, or\n// undefined if the block doesn't overlap the window.\n//\n// **`winStart`/`winEnd` MUST be integer bp**, and both callers snap them \u2014\n// outward in `clipLargeBlockToWindow` (a viewport bound), inward in\n// `executeSyntenyFeaturesAndPositions`' trim path (a region-containment bound).\n// A fractional window breaks the output two ways at once: the boundary ops are\n// trimmed to it and then packed through `(cHi - cLo) << 4`, whose ToInt32\n// TRUNCATES the length (a 0.6bp remnant becomes a zero-length op), while\n// `start`/`end` come back carrying the fraction in full. The block's declared\n// span then exceeds what its own CIGAR walks, and since the base trapezoid is\n// drawn from the corners while the tiles are walked from the ops, the\n// difference shows in transparent-indels mode as unpainted ribbon at the\n// trailing end. Not asserted here \u2014 this runs per feature over a whole-genome\n// PAF \u2014 so it is the callers' invariant to keep.\n//\n// A single alignment block can span far beyond the viewport \u2014 a whole UCSC\n// liftOver chain is one ~20 Mb feature. Its base ribbon is drawn as one *linear*\n// trapezoid across that span, which cannot follow megabases of indels, so at\n// high zoom the ribbon lands off-screen and nothing renders. Re-anchoring the\n// block to just its visible slice (accurate coords + a short CIGAR) restores it.\n//\n// Walk direction MUST match buildSyntenyGeometry, which walks the query (v1)\n// axis forward in GENOMIC order for BOTH strands and flips only the target (v2)\n// axis. So the query walk here is always start->end; only the target counts\n// down for a - strand block, entering at mateEnd. Within a match op the target\n// maps to the query as target(q) = bp2 + (q - bp1) * revTarget, using the op's\n// walk-entry positions. (buildSyntenyGeometry re-derives its rev1 from the cumBp\n// order of the endpoints, so a reversed display region walks the same file-order\n// CIGAR the other way in cumBp space \u2014 still forward in genomic query bp, so\n// this reassembly stays valid.)\n//\n// Walking the query backward for - strand (as an earlier version did) mirrors\n// every indel's query position within the window: the trimmed CIGAR is\n// reassembled in file order and re-walked forward by buildSyntenyGeometry, so a\n// deletion lands at its mirror-image position (wrong side of the ribbon).\nexport function clipSyntenyFeature(cigar, start, mateStart, mateEnd, strand, winStart, winEnd) {\n const revTarget = strand === -1 ? -1 : 1;\n let bp1 = start;\n let bp2 = strand === -1 ? mateEnd : mateStart;\n const out = [];\n let qLo = Infinity;\n let qHi = -Infinity;\n let tLo = Infinity;\n let tHi = -Infinity;\n const extendTarget = (a, b) => {\n tLo = Math.min(tLo, a, b);\n tHi = Math.max(tHi, a, b);\n };\n for (let k = 0; k < cigar.length; k++) {\n const packed = cigar[k];\n const len = packed >>> 4;\n const op = packed & 0xf;\n // a CIGAR_RUN pair advances the query by its first word and the target by\n // its second, mapping the two in proportion along the run\n const isRun = op === CIGAR_RUN;\n const qAdv = isRun || consumesQuery(op) ? len : 0;\n const tAdv = isRun ? cigar[++k] >>> 4 : consumesTarget(op) ? len : 0;\n const bp1Next = bp1 + qAdv;\n const bp2Next = bp2 + tAdv * revTarget;\n const opQLo = bp1;\n const opQHi = bp1Next;\n if (opQHi >= winStart && opQLo <= winEnd) {\n if (qAdv > 0) {\n // Query-consuming op (match, run or D/N): trim to the window in query\n // space.\n const cLo = Math.max(opQLo, winStart);\n const cHi = Math.min(opQHi, winEnd);\n if (cHi > cLo) {\n qLo = Math.min(qLo, cLo);\n qHi = Math.max(qHi, cHi);\n if (isRun) {\n const ratio = tAdv / len;\n const keptOwn = cHi - cLo;\n const keptMate = Math.round(keptOwn * ratio);\n const tEntry = Math.round(bp2 + (cLo - bp1) * ratio * revTarget);\n out.push((keptOwn << 4) | CIGAR_RUN, (keptMate << 4) | CIGAR_RUN);\n extendTarget(tEntry, tEntry + keptMate * revTarget);\n }\n else {\n out.push(((cHi - cLo) << 4) | op);\n if (isMatchOp(op)) {\n // matches map target 1:1: target(q) = bp2 + (q - bp1) * revTarget\n extendTarget(bp2 + (cLo - bp1) * revTarget, bp2 + (cHi - bp1) * revTarget);\n }\n else {\n // D/N consume no target, so it stays a point at bp2\n extendTarget(bp2, bp2);\n }\n }\n }\n }\n else if (tAdv > 0) {\n // I (or a run with no query span): target-consuming gap at a single\n // query position; keep it whole\n if (isRun) {\n out.push(packed, cigar[k]);\n }\n else {\n out.push(packed);\n }\n qLo = Math.min(qLo, bp1);\n qHi = Math.max(qHi, bp1);\n extendTarget(bp2, bp2Next);\n }\n // An op consuming NEITHER axis (H/S/P) is dropped rather than falling into\n // the arm above. It carries no coordinate on either axis, so keeping it\n // would extend qLo/qHi to a position the alignment does not occupy \u2014 and\n // on a hard clip sitting exactly at winEnd, with the preceding match\n // trimmed to nothing, that arm is the ONLY thing that collects, so the\n // clip alone would come back as a zero-width block. The walk this output\n // feeds (visitCigarRenderedSegments) has no branch for these ops either.\n }\n bp1 = bp1Next;\n bp2 = bp2Next;\n // Query ascends monotonically, so every later op has opQLo >= bp1 > winEnd\n // and cannot overlap the window \u2014 whether or not anything has been collected\n // yet. This used to also require `out.length`, which disabled the break for\n // the one input that walks longest: a block lying entirely to the RIGHT of\n // the window never collects an op, so it read every op of a multi-megabyte\n // chain to conclude what the first op already said.\n if (bp1 > winEnd) {\n break;\n }\n }\n if (out.length === 0) {\n return undefined;\n }\n return {\n start: qLo,\n end: qHi,\n mateStart: tLo,\n mateEnd: tHi,\n cigar: Uint32Array.from(out),\n };\n}\nfunction isGapOp(op) {\n return op === CIGAR_I || op === CIGAR_D || op === CIGAR_N;\n}\n/**\n * The gap-free runs of a block: the block cut at every insertion or deletion\n * of `gapBp` or more, each run re-anchored on both axes with its own ops, in\n * the shape {@link clipSyntenyFeature} answers with so a run can then be\n * clipped to a window like any block. Cut BEFORE the clip rather than after\n * it, because a clip trims a gap straddling the window edge to the part\n * inside, and a 25 kb deletion 9 kb of which is in view is still a gap. The\n * walk is the clip's own \u2014 query forward, target down for a - strand block\n * from `mateEnd` \u2014 and a run's `mateStart`/`mateEnd` are its target extent\n * in ascending order. A run is only what aligned: one holding no match or\n * coarse-run op (a stretch that is deletions alone) is dropped, and a gap at\n * either edge of the block leaves no empty run behind it.\n *\n * Wanted by a display that draws a clipped record as one straight placement\n * and has no CIGAR left to consult: a chain carrying a 25 kb indel inside the\n * window drew as one ribbon, and what it draws now is one placement per run.\n * The coarse tier keeps every indel longer than half its bound as its own op,\n * so a `gapBp` at that bound splits the same way on either tier.\n */\nexport function splitSyntenyFeatureAtGaps(cigar, start, mateStart, mateEnd, strand, gapBp) {\n const revTarget = strand === -1 ? -1 : 1;\n const runs = [];\n let bp1 = start;\n let bp2 = strand === -1 ? mateEnd : mateStart;\n let run;\n let aligned = false;\n const close = () => {\n if (run !== undefined && aligned && run.qHi > run.qLo) {\n runs.push({\n start: run.qLo,\n end: run.qHi,\n mateStart: run.tLo,\n mateEnd: run.tHi,\n cigar: Uint32Array.from(run.ops),\n });\n }\n run = undefined;\n aligned = false;\n };\n for (let k = 0; k < cigar.length; k++) {\n const packed = cigar[k];\n const len = packed >>> 4;\n const op = packed & 0xf;\n const isRun = op === CIGAR_RUN;\n const second = isRun ? cigar[++k] : undefined;\n const qAdv = isRun || consumesQuery(op) ? len : 0;\n const tAdv = second !== undefined ? second >>> 4 : consumesTarget(op) ? len : 0;\n const bp2Next = bp2 + tAdv * revTarget;\n if (isGapOp(op) && len >= gapBp) {\n close();\n }\n else if (qAdv > 0 || tAdv > 0) {\n if (run === undefined) {\n run = { qLo: bp1, qHi: bp1, tLo: bp2, tHi: bp2, ops: [] };\n }\n run.qHi = bp1 + qAdv;\n run.tLo = Math.min(run.tLo, bp2, bp2Next);\n run.tHi = Math.max(run.tHi, bp2, bp2Next);\n run.ops.push(packed);\n if (second !== undefined) {\n run.ops.push(second);\n }\n aligned = aligned || isRun || isMatchOp(op);\n }\n bp1 += qAdv;\n bp2 = bp2Next;\n }\n close();\n return runs;\n}\n// Worker glue over clipSyntenyFeature: gate on size + resolve the v1 region the\n// fetch window is over, convert the window to that region's local bp, parse\n// the CIGAR (or the coarse tier's fold of it) and clip. Returns undefined\n// (leave the block untouched) unless it is a block with an alignment string\n// more than `spanRatio`x the window on a clippable region. The clip\n// itself is region-orientation-agnostic (it walks genomic query bp forward), and\n// buildSyntenyGeometry re-derives its rev1 from the cumBp order of the clipped\n// endpoints \u2014 so a reversed v1 region only changes the cumBp->local-bp window\n// mapping below, not the clip or the downstream projection.\nexport function clipLargeBlockToWindow({ v1Index, refName, start, end, mateStart, mateEnd, strand, cigar, coarseCigar, winCumLo, winCumHi, windowSpan, spanRatio, }) {\n if ((!cigar && !coarseCigar) || end - start <= spanRatio * windowSpan) {\n return undefined;\n }\n // Re-anchor to the region this refName's fetch window falls in. A refName\n // can be displayed at several loci at once \u2014 e.g. a dispersed gene duplication\n // shows the same contig in multiple regions \u2014 so pick the region whose cumBp\n // span overlaps the window most (for the common single-region case, just that\n // region; no overlap = the block is off-screen, leave it untouched). Assumes\n // the same-refName regions are genomically DISJOINT (which the duplication\n // case is): the downstream projection re-resolves the clipped coords with\n // findRegionEntry, which picks the region their span overlaps MOST \u2014 the same\n // region we clipped to only when the genomic ranges don't overlap. Overlapping\n // copies of one locus would need a region index threaded through.\n const entries = v1Index.entries.get(refName) ?? [];\n let r0;\n let bestOverlap = 0;\n for (const e of entries) {\n const regLo = e.bpBefore;\n const regHi = e.bpBefore + (e.region.end - e.region.start);\n const overlap = Math.min(winCumHi, regHi) - Math.max(winCumLo, regLo);\n if (overlap > bestOverlap) {\n bestOverlap = overlap;\n r0 = e;\n }\n }\n if (!r0) {\n return undefined;\n }\n // Snap the window to integer bp (widen outward). winCumLo/Hi come off a\n // fetch window snapped to a pixel-derived grid, so they can carry a sub-bp\n // fraction. The\n // window is only a coarse \"which ops to include\" bound, but the clip trims\n // the boundary match op to start exactly at winStart \u2014 a fractional winStart\n // makes the whole re-anchored block's coords fractional (the op lengths stay\n // integer), rigidly shifting every tile/indel off the true integer-bp grid by\n // that fraction. At several px/bp that reads as indels landing mid-basepair,\n // misaligned vs the exact-bp LGVSyntenyDisplay. Flooring/ceiling keeps the\n // clipped block on the alignment's integer grid; the <1bp widening is well\n // inside the pan buffer.\n //\n // Invert bpToCumBp for this region's orientation. Forward: local =\n // cumBp - bpBefore + start (monotonic up). Reversed: local =\n // end - (cumBp - bpBefore) (monotonic down), so the low/high cumBp bounds map\n // to the high/low local bp \u2014 winStart takes winCumHi and winEnd winCumLo.\n //\n // Clamped to the region, because the cumBp window spans every displayed\n // region and this maps it through one of them: on a multi-region view the\n // window is wider than the region it is being expressed in, so an unclamped\n // winStart lands outside and the re-anchored block keeps an endpoint the\n // projection cannot place.\n const { region, bpBefore } = r0;\n const clampToRegion = (bp) => Math.min(Math.max(bp, region.start), region.end);\n const winStart = clampToRegion(region.reversed\n ? Math.floor(region.end - (winCumHi - bpBefore))\n : Math.floor(winCumLo - bpBefore + region.start));\n const winEnd = clampToRegion(region.reversed\n ? Math.ceil(region.end - (winCumLo - bpBefore))\n : Math.ceil(winCumHi - bpBefore + region.start));\n // A block that doesn't reach the window keeps no op \u2014 every op the walk below\n // retains has to overlap [winStart, winEnd], and the walk only ever moves\n // forward from `start` \u2014 so answer that here, before parsing a multi-megabyte\n // CIGAR string, which is exactly the size of block that reaches this function\n // at all. The window is the fetch window, so a fetched block reaches it\n // unless the same refName is displayed at several loci and the block belongs\n // to another of them.\n if (end < winStart || start > winEnd) {\n return undefined;\n }\n const ops = cigar\n ? parseCigar2Typed(cigar)\n : coarseCigar\n ? parseCoarseCigar(coarseCigar)\n : undefined;\n return ops\n ? clipSyntenyFeature(ops, start, mateStart, mateEnd, strand, winStart, winEnd)\n : undefined;\n}\n", "import { parseCigar2Typed, parseCoarseCigar } from '@jbrowse/cigar-utils';\nexport function getCigar(feature) {\n const cigar = feature.get('CIGAR');\n return typeof cigar === 'string' ? cigar : undefined;\n}\nexport function getCoarseCigar(feature) {\n const coarse = feature.get('coarseCigar');\n return typeof coarse === 'string' ? coarse : undefined;\n}\nexport function hasAlignmentString(feature) {\n return (getCigar(feature) !== undefined || getCoarseCigar(feature) !== undefined);\n}\n// the per-base CIGAR when the record carries one, else the coarse tier's fold\nexport function getAlignmentOps(feature) {\n const cigar = getCigar(feature);\n const coarse = cigar === undefined ? getCoarseCigar(feature) : undefined;\n return cigar !== undefined\n ? parseCigar2Typed(cigar)\n : coarse !== undefined\n ? parseCoarseCigar(coarse)\n : undefined;\n}\n", "import {\n clipSyntenyFeature,\n getAlignmentOps,\n splitSyntenyFeatureAtGaps,\n} from '@jbrowse/synteny-core'\n\nimport SyntenyFeature from './SyntenyFeature.ts'\n\nimport type { Feature, SimpleFeatureSerialized } from '@jbrowse/core/util'\n\ninterface Interval {\n start: number\n end: number\n}\n\ninterface ClippedIntervals extends Interval {\n mateStart: number\n mateEnd: number\n cigar?: Uint32Array\n}\n\nconst ALIGNMENT_STRING_FIELDS = ['CIGAR', 'cs', 'coarseCigar', 'cg', 'cr']\n\ntype SerializedMate = NonNullable<SimpleFeatureSerialized['mate']>\n\nfunction isMate(mate: unknown): mate is SerializedMate {\n return (\n typeof mate === 'object' &&\n mate !== null &&\n 'refName' in mate &&\n 'start' in mate &&\n 'end' in mate &&\n typeof mate.refName === 'string' &&\n typeof mate.start === 'number' &&\n typeof mate.end === 'number'\n )\n}\n\nfunction mateOf(feature: Feature) {\n const mate: unknown = feature.get('mate')\n return isMate(mate) ? mate : undefined\n}\n\n// A record with no alignment string maps its two intervals onto each other in\n// proportion, the way the synteny launch interpolates across such a block; a\n// reverse-strand record runs its mate from the far end.\nfunction interpolateClip(\n own: Interval,\n mate: Interval,\n strand: number,\n window: Interval,\n): ClippedIntervals | undefined {\n const lo = Math.max(own.start, window.start)\n const hi = Math.min(own.end, window.end)\n const ratio = (mate.end - mate.start) / Math.max(own.end - own.start, 1)\n const mateAt = (q: number) =>\n strand === -1\n ? mate.end - (q - own.start) * ratio\n : mate.start + (q - own.start) * ratio\n const a = Math.round(mateAt(lo))\n const b = Math.round(mateAt(hi))\n return hi > lo\n ? { start: lo, end: hi, mateStart: Math.min(a, b), mateEnd: Math.max(a, b) }\n : undefined\n}\n\n// A record inside the window is its own clip, and skips parsing its alignment\n// string, unless the runs or the ops are wanted, which only the string knows.\nfunction clipIntervals(\n feature: Feature,\n mate: Interval,\n window: Interval,\n splitAtGapBp: number | undefined,\n keepAlignment: boolean,\n): ClippedIntervals[] {\n const own = { start: feature.get('start'), end: feature.get('end') }\n const strand = feature.get('strand') === -1 ? -1 : 1\n const inside = own.start >= window.start && own.end <= window.end\n const ops =\n inside && splitAtGapBp === undefined && !keepAlignment\n ? undefined\n : getAlignmentOps(feature)\n if (ops === undefined) {\n const clipped = inside\n ? { ...own, mateStart: mate.start, mateEnd: mate.end }\n : interpolateClip(own, mate, strand, window)\n return clipped === undefined ? [] : [clipped]\n } else {\n const runs =\n splitAtGapBp === undefined\n ? [{ ...own, mateStart: mate.start, mateEnd: mate.end, cigar: ops }]\n : splitSyntenyFeatureAtGaps(\n ops,\n own.start,\n mate.start,\n mate.end,\n strand,\n splitAtGapBp,\n )\n return runs.flatMap(run => {\n const clipped = clipSyntenyFeature(\n run.cigar,\n run.start,\n run.mateStart,\n run.mateEnd,\n strand,\n window.start,\n window.end,\n )\n return clipped === undefined ? [] : [clipped]\n })\n }\n}\n\nfunction clippedFeature(\n feature: Feature,\n mate: SerializedMate,\n clipped: ClippedIntervals,\n window: Interval,\n run: string,\n keepAlignment: boolean,\n) {\n const suffix = `:${window.start}-${window.end}${run}`\n const source = feature.toJSON()\n const data: SimpleFeatureSerialized = {\n ...source,\n uniqueId: `${feature.id()}${suffix}`,\n recordId: source.recordId ?? feature.id(),\n start: clipped.start,\n end: clipped.end,\n mate: { ...mate, start: clipped.mateStart, end: clipped.mateEnd },\n }\n if (source.syntenyId !== undefined) {\n data.syntenyId = `${String(source.syntenyId)}${suffix}`\n }\n for (const field of ALIGNMENT_STRING_FIELDS) {\n delete data[field]\n }\n if (keepAlignment && clipped.cigar) {\n data.alignmentOps = clipped.cigar\n }\n return new SyntenyFeature(data)\n}\n\n/**\n * The pieces of one pairwise record inside `window`, on both axes: none when\n * the record misses the window, one otherwise, and with `splitAtGapBp` one per\n * gap-free run of its alignment, numbered after the window suffix so each run\n * is its own feature and its own `syntenyId` group. A piece keeps every field\n * of the record except the alignment strings, and a `recordId` that names the\n * record the piece was cut from, so a display can tell two runs of one record\n * from two records; `keepAlignment` hands back its\n * own stretch of them as packed ops in `alignmentOps`. A feature with no\n * `mate` is not a pairwise record and passes through whole.\n *\n * A copy of `@jbrowse/plugin-comparative-adapters`' own, which a runtime plugin\n * cannot import: the worker serves that package as a stub too.\n */\nexport function clipFeatureToRegion(\n feature: Feature,\n window: Interval,\n splitAtGapBp?: number,\n keepAlignment = false,\n): Feature[] {\n const mate = mateOf(feature)\n if (mate === undefined) {\n return [feature]\n } else {\n const pieces = clipIntervals(\n feature,\n mate,\n window,\n splitAtGapBp,\n keepAlignment,\n )\n return pieces.map((piece, i) =>\n clippedFeature(\n feature,\n mate,\n piece,\n window,\n pieces.length > 1 ? `/${i}` : '',\n keepAlignment,\n ),\n )\n }\n}\n", "import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter'\nimport { createStatusFanOut } from '@jbrowse/core/util'\nimport { from } from 'rxjs'\nimport { map, mergeMap, toArray } from 'rxjs/operators'\n\nimport { clipFeatureToRegion } from './clipFeatureToRegion.ts'\n\nimport type { AnyConfigurationModel } from '@jbrowse/core/configuration'\nimport type { Feature } from '@jbrowse/core/util'\nimport type { AugmentedRegion as Region } from '@jbrowse/core/util/types'\nimport type { ComparativeOptions } from '@jbrowse/synteny-core'\n\n/**\n * What every adapter in this plugin answers the same way.\n *\n * `hasDataForRefName` is true unconditionally because deciding it properly is a\n * `getFeatures`, and it has to be true, or BaseFeatureDataAdapter filters the\n * track out and `getFeatures` is never called at all. The two feature\n * adapters, RgfaTabixAdapter and MinigraphBubbleAdapter, answer it the same\n * way on their own.\n *\n * Only the answers that do not depend on config live here. Anything reading a\n * slot stays in the concrete adapter, for the reason `getAssemblyNamesFromConf`\n * documents: a base generic over the config cannot prove a slot name to\n * `getConf`, so hoisting a read costs the typing that makes it worth having.\n */\nexport abstract class ComparativeAdapterBase<\n CONF extends AnyConfigurationModel = AnyConfigurationModel,\n> extends BaseFeatureDataAdapter<CONF> {\n public static capabilities = ['getFeatures', 'getRefNames']\n\n /**\n * Whether a record's two intervals are the aligned extents of one alignment,\n * which `clipToRegion` may cut at a region edge on both axes, or two genes,\n * whose extents are the genes and stay whole however the region falls.\n */\n protected readonly recordsAreAlignments: boolean = true\n\n async hasDataForRefName() {\n return true\n }\n\n /**\n * `clipToRegion`, `splitAtGapBp` and `keepAlignment` are honoured here and\n * nowhere below: `getFeatures` never sees them. A record on another assembly\n * than the region's, such as a lane pair read inside an anchor window, is in\n * no coordinates the region states, so it is split at its gaps and clipped\n * to its own extent.\n *\n * Emission is in region order, not arrival order, as core's base does: the\n * multi-way display's lane sort tie-breaks on first appearance in this list,\n * and its weights tie exactly, so arrival order would decide the stack.\n */\n getFeaturesInMultipleRegions(\n regions: Region[],\n opts: ComparativeOptions = {},\n ) {\n const { clipToRegion, splitAtGapBp, keepAlignment, ...rest } = opts\n const clip = clipToRegion && this.recordsAreAlignments\n const slot = createStatusFanOut(rest.statusCallback)\n return from(regions).pipe(\n mergeMap((region, index) =>\n this.getFeatures(region, { ...rest, statusCallback: slot() }).pipe(\n mergeMap((feature): Feature[] =>\n clip\n ? clipFeatureToRegion(\n feature,\n feature.get('assemblyName') === region.assemblyName\n ? region\n : { start: feature.get('start'), end: feature.get('end') },\n splitAtGapBp,\n keepAlignment,\n )\n : [feature],\n ),\n toArray(),\n map(features => ({ index, features })),\n ),\n ),\n toArray(),\n mergeMap(chunks =>\n chunks\n .sort((a, b) => a.index - b.index)\n .flatMap(chunk => chunk.features),\n ),\n )\n }\n}\n", "import { panSNSample } from '@jbrowse/bandage-core/pansn'\n\nimport type { ComparativeOptions } from '@jbrowse/synteny-core'\n\n/**\n * Two lanes aligned to each other inside an anchor window: records on the\n * query lane's contigs, with the target lane's walk as the mate\n */\nexport interface LanePair {\n queryAssemblyName: string\n targetAssemblyName: string\n}\n\n/**\n * `haplotypes` narrows a fetch to the lanes listed: PanSN prefixes at sample\n * (`HG002`) or haplotype (`HG002#1`) depth, or assembly names the config maps\n * to one; undefined is every haplotype.\n *\n * `queryAssemblyName` with `targetAssemblyName`, on a window of the anchor,\n * asks for that pair of lanes aligned to each other inside the window.\n */\nexport interface LaneFeatureOptions extends ComparativeOptions {\n haplotypes?: string[]\n queryAssemblyName?: string\n lanePairs?: LanePair[]\n}\n\nexport class PairTargetError extends Error {\n override name = 'PairTargetError'\n\n constructor(queryAssemblyName: string) {\n super(\n `a pair query names both lanes: queryAssemblyName ${queryAssemblyName} came without a targetAssemblyName`,\n )\n }\n}\n\n// The pairs a fetch asks for: its batch, else its one pair, else none\nexport function requestedPairs(opts: LaneFeatureOptions): LanePair[] {\n const { lanePairs, queryAssemblyName, targetAssemblyName } = opts\n if (lanePairs?.length) {\n return lanePairs\n } else if (queryAssemblyName === undefined) {\n return []\n } else if (targetAssemblyName === undefined) {\n throw new PairTargetError(queryAssemblyName)\n } else {\n return [{ queryAssemblyName, targetAssemblyName }]\n }\n}\n\n// The status a fetch of lane pairs shows while it reads\nexport function lanePairsStatus(pairs: LanePair[]) {\n const [first] = pairs\n return pairs.length === 1 && first\n ? `Reading ${first.queryAssemblyName} against ${first.targetAssemblyName}`\n : `Reading ${pairs.length} lane pairs`\n}\n\n/**\n * The lane a haplotype draws on: the JBrowse assembly the config maps to its\n * `sample#haplotype` prefix, else to its sample, else the prefix itself. The\n * fallback stays at haplotype depth, unlike the multi-genome PAF adapters',\n * because a diploid sample's two walks are two lanes.\n */\nexport function laneAssemblyName(\n asmByPrefix: Record<string, string>,\n prefix: string,\n) {\n return asmByPrefix[prefix] ?? asmByPrefix[panSNSample(prefix)] ?? prefix\n}\n", "import { isNodeLimitError } from '../nodeLimitError.ts'\n\n/**\n * How many times over the view must zoom in for a lane fetch of `windowBp`\n * to fit, where `fitsBp` is the widest fetch that would: rounded up to a\n * tenth, to a whole number past 10, and never under 1.1.\n */\nexport function laneZoomFold(windowBp: number, fitsBp: number) {\n const fits = Math.max(1, fitsBp)\n return windowBp >= 10 * fits\n ? Math.ceil(windowBp / fits)\n : Math.max(11, Math.ceil((10 * windowBp) / fits)) / 10\n}\n\n/**\n * A budget refusal for lanes, naming how far to zoom rather than a span. The\n * display fetches lanes over the 800 px static blocks its view touches, up to\n * a block past each edge, and never tells the adapter the view, so a span that\n * fits the fetch can be wider than the view. The fetch narrows with the view,\n * so a fold holds for both.\n */\nexport function laneZoomNotice(error: unknown, windowBp: number) {\n if (isNodeLimitError(error) && error instanceof Error) {\n const { fitsBp } = error as { fitsBp?: unknown }\n error.message = error.message.replace('to see the graph', 'to see lanes')\n if (typeof fitsBp === 'number') {\n error.message = error.message.replace(\n /^Zoom in to about [\\d.,]*\\d[KM]?bp/,\n `Zoom in about ${laneZoomFold(windowBp, fitsBp)}\u00D7`,\n )\n }\n }\n return error\n}\n", "import SyntenyFeature from './SyntenyFeature.ts'\n\nexport interface MatchSide {\n name: string\n assemblyName: string\n refName: string\n start: number\n end: number\n}\n\n/**\n * One record of a walk aligned to another, on the target walk's contig with\n * the query walk as its mate and the CIGAR read along the target, a `D` being\n * target bases the query lacks. Each side's walk name and extent make the id.\n */\nexport function matchFeature({\n target,\n query,\n strand,\n cigar,\n matches,\n columns,\n}: {\n target: MatchSide\n query: MatchSide\n strand: string\n cigar: string\n matches: number\n columns: number\n}) {\n const id = `${target.name}:${target.start}-${target.end}|${query.name}:${query.start}-${query.end}`\n return new SyntenyFeature({\n uniqueId: id,\n assemblyName: target.assemblyName,\n refName: target.refName,\n start: target.start,\n end: target.end,\n type: 'match',\n strand: strand === '-' ? -1 : 1,\n CIGAR: cigar,\n syntenyId: id,\n identity: matches / Math.max(columns, 1),\n numMatches: matches,\n blockLen: columns,\n mate: {\n refName: query.refName,\n start: query.start,\n end: query.end,\n assemblyName: query.assemblyName,\n },\n })\n}\n"],
|
|
5
|
+
"mappings": "4KA+FA,SAASA,GAAeC,EAAG,CACvB,IAAMC,EAAM,CAAC,EACTC,EAAM,EACNC,EACJ,QAASC,EAAI,EAAGC,EAAIL,EAAE,OAAQI,EAAIC,EAAGD,IAAK,CACtC,IAAME,EAAON,EAAE,WAAWI,CAAC,EAC3B,GAAIE,GAAQ,IAAMA,GAAQ,GACtBJ,EAAMA,EAAM,GAAKI,EAAO,WAEnBA,IAAS,GACdH,EAAiBD,EACjBA,EAAM,MAEL,CAGD,IAAMK,EAAKP,EAAEI,CAAC,EACVG,IAAO,KAAOA,IAAO,KAAOA,IAAO,IACnCN,EAAI,KAAK,CACL,IAAKE,IAAmB,OAAYD,EAAMC,EAC1C,KAAMD,EACN,GAAI,GACR,CAAC,EAEIK,IAAO,IACZN,EAAI,KAAK,CAAE,IAAK,EAAG,KAAMC,EAAK,GAAAK,CAAG,CAAC,GAE7BA,IAAO,KAAOA,IAAO,MAC1BN,EAAI,KAAK,CAAE,IAAKC,EAAK,KAAM,EAAG,GAAAK,CAAG,CAAC,EAEtCJ,EAAiB,OACjBD,EAAM,CACV,CACJ,CACA,OAAOD,CACX,CAiDO,SAASO,GAAmBC,EAAG,CAClC,IAAIC,EAAM,GACV,OAAW,CAAE,IAAAC,EAAK,KAAAC,EAAM,GAA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,CAAO,EAAIG,EACnBA,EAAM,QAAUA,EAAM,QAAQ,QAAQ,mBAAoB,cAAc,EACpE,OAAOH,GAAW,WACpBG,EAAM,QAAUA,EAAM,QAAQ,QAC5B,qCACA,iBAAiBL,GAAaC,EAAUC,CAAM,CAAC,MACjD,EAEJ,CACA,OAAOG,CACT,CClBO,SAASE,GAAa,CAC3B,OAAAC,EACA,MAAAC,EACA,OAAAC,EACA,MAAAC,EACA,QAAAC,EACA,QAAAC,CACF,EAOG,CACD,IAAMC,EAAK,GAAGN,EAAO,IAAI,IAAIA,EAAO,KAAK,IAAIA,EAAO,GAAG,IAAIC,EAAM,IAAI,IAAIA,EAAM,KAAK,IAAIA,EAAM,GAAG,GACjG,OAAO,IAAIM,EAAe,CACxB,SAAUD,EACV,aAAcN,EAAO,aACrB,QAASA,EAAO,QAChB,MAAOA,EAAO,MACd,IAAKA,EAAO,IACZ,KAAM,QACN,OAAQE,IAAW,IAAM,GAAK,EAC9B,MAAOC,EACP,UAAWG,EACX,SAAUF,EAAU,KAAK,IAAIC,EAAS,CAAC,EACvC,WAAYD,EACZ,SAAUC,EACV,KAAM,CACJ,QAASJ,EAAM,QACf,MAAOA,EAAM,MACb,IAAKA,EAAM,IACX,aAAcA,EAAM,YACtB,CACF,CAAC,CACH",
|
|
6
|
+
"names": ["parseCoarseOps", "s", "out", "len", "ownBeforeColon", "i", "l", "code", "op", "coarseCigarOwnAxis", "s", "out", "own", "mate", "op", "parseCoarseOps", "MAX_PACKED_LEN", "pushPacked", "len", "code", "rest", "pushRun", "chunks", "i", "o", "m", "parseCoarseCigar", "isDigit", "code", "isBaseChar", "ch", "scanBases", "cs", "start", "i", "scanDigits", "value", "forEachCsOp", "callback", "c", "next", "len", "end", "forEachCsMismatch", "cs", "callback", "windowStart", "windowEnd", "lo", "hi", "ref", "forEachCsOp", "op", "refLen", "queryLen", "seqStart", "seqEnd", "seq", "cigarToMismatches2", "ops", "seq", "ref", "qual", "roffset", "soffset", "mismatches", "hasRefAndSeq", "i", "l", "packed", "len", "op", "j", "mdToMismatches2", "mdstring", "ops", "cigarMismatches", "seq", "qual", "mismatchRecords", "opsLength", "seqLength", "hasQual", "cigarLength", "hasSkips", "k", "currStart", "lastCigar", "lastTemplateOffset", "lastRefOffset", "lastSkipPos", "i", "len", "char", "num", "c", "letter", "mismatch", "templateOffset", "refOffset", "j", "packed", "op", "s", "base", "CIGAR_CODE_TO_INDEX", "parseCigar2", "s", "currLen", "ret", "i", "l", "code", "opIndex", "CIGAR_CODE_TO_INDEX", "parseCigar2Typed", "opCount", "out", "j", "getMismatches", "cigar", "md", "seq", "ref", "qual", "ops", "mismatches", "cigarToMismatches2", "mdToMismatches2", "SyntenyFeature", "SimpleFeature", "name", "getMismatches", "cigar", "coarse", "coarseCigarOwnAxis", "callback", "opts", "start", "ws", "we", "cs", "forEachCsMismatch", "lo", "hi", "m", "extendStatics", "d", "b", "p", "__extends", "__", "__awaiter", "thisArg", "_arguments", "P", "generator", "adopt", "value", "resolve", "reject", "fulfilled", "step", "e", "rejected", "result", "__generator", "body", "_", "t", "f", "y", "g", "verb", "n", "v", "op", "__values", "o", "s", "m", "i", "__read", "n", "r", "ar", "e", "error", "__spreadArray", "to", "from", "pack", "i", "l", "ar", "__await", "v", "__asyncGenerator", "thisArg", "_arguments", "generator", "g", "q", "verb", "awaitReturn", "f", "reject", "n", "a", "b", "resume", "step", "e", "settle", "r", "fulfill", "value", "__asyncValues", "o", "m", "i", "__values", "verb", "n", "v", "resolve", "reject", "settle", "d", "isFunction", "value", "createErrorClass", "createImpl", "_super", "instance", "ctorFunc", "UnsubscriptionError", "createErrorClass", "_super", "errors", "err", "i", "arrRemove", "arr", "item", "index", "Subscription", "initialTeardown", "errors", "_parentage", "_parentage_1", "__values", "_parentage_1_1", "parent_1", "initialFinalizer", "isFunction", "e", "UnsubscriptionError", "_finalizers", "_finalizers_1", "_finalizers_1_1", "finalizer", "execFinalizer", "err", "__spreadArray", "__read", "teardown", "_a", "parent", "arrRemove", "empty", "EMPTY_SUBSCRIPTION", "Subscription", "isSubscription", "value", "isFunction", "execFinalizer", "finalizer", "config", "timeoutProvider", "handler", "timeout", "args", "_i", "delegate", "__spreadArray", "__read", "handle", "reportUnhandledError", "err", "timeoutProvider", "onUnhandledError", "config", "noop", "COMPLETE_NOTIFICATION", "createNotification", "errorNotification", "error", "nextNotification", "value", "kind", "context", "errorContext", "cb", "config", "isRoot", "_a", "errorThrown", "error", "captureError", "err", "Subscriber", "_super", "__extends", "destination", "_this", "isSubscription", "EMPTY_OBSERVER", "next", "error", "complete", "SafeSubscriber", "value", "handleStoppedNotification", "nextNotification", "err", "errorNotification", "COMPLETE_NOTIFICATION", "Subscription", "_bind", "bind", "fn", "thisArg", "ConsumerObserver", "partialObserver", "value", "error", "handleUnhandledError", "err", "SafeSubscriber", "_super", "__extends", "observerOrNext", "complete", "_this", "isFunction", "context_1", "config", "Subscriber", "handleUnhandledError", "error", "config", "captureError", "reportUnhandledError", "defaultErrorHandler", "err", "handleStoppedNotification", "notification", "subscriber", "onStoppedNotification", "timeoutProvider", "EMPTY_OBSERVER", "noop", "observable", "identity", "x", "pipeFromArray", "fns", "identity", "input", "prev", "fn", "Observable", "subscribe", "operator", "observable", "observerOrNext", "error", "complete", "_this", "subscriber", "isSubscriber", "SafeSubscriber", "errorContext", "_a", "source", "sink", "err", "next", "promiseCtor", "getPromiseCtor", "resolve", "reject", "value", "operations", "_i", "pipeFromArray", "x", "getPromiseCtor", "promiseCtor", "_a", "config", "isObserver", "value", "isFunction", "isSubscriber", "Subscriber", "isSubscription", "hasLift", "source", "isFunction", "operate", "init", "liftedSource", "err", "createOperatorSubscriber", "destination", "onNext", "onComplete", "onError", "onFinalize", "OperatorSubscriber", "_super", "__extends", "shouldUnsubscribe", "_this", "value", "err", "closed_1", "_a", "Subscriber", "isArrayLike", "x", "isPromise", "value", "isFunction", "isInteropObservable", "input", "isFunction", "observable", "isAsyncIterable", "obj", "isFunction", "createInvalidObservableTypeError", "input", "getSymbolIterator", "iterator", "isIterable", "input", "isFunction", "iterator", "readableStreamLikeToAsyncGenerator", "readableStream", "reader", "__await", "_a", "_b", "value", "done", "isReadableStreamLike", "obj", "isFunction", "innerFrom", "input", "Observable", "isInteropObservable", "fromInteropObservable", "isArrayLike", "fromArrayLike", "isPromise", "fromPromise", "isAsyncIterable", "fromAsyncIterable", "isIterable", "fromIterable", "isReadableStreamLike", "fromReadableStreamLike", "createInvalidObservableTypeError", "obj", "subscriber", "obs", "observable", "isFunction", "array", "i", "promise", "value", "err", "reportUnhandledError", "iterable", "iterable_1", "__values", "iterable_1_1", "asyncIterable", "process", "readableStream", "readableStreamLikeToAsyncGenerator", "asyncIterable_1", "__asyncValues", "asyncIterable_1_1", "executeSchedule", "parentSubscription", "scheduler", "work", "delay", "repeat", "scheduleSubscription", "observeOn", "scheduler", "delay", "operate", "source", "subscriber", "createOperatorSubscriber", "value", "executeSchedule", "err", "subscribeOn", "scheduler", "delay", "operate", "source", "subscriber", "scheduleObservable", "input", "scheduler", "innerFrom", "subscribeOn", "observeOn", "schedulePromise", "input", "scheduler", "innerFrom", "subscribeOn", "observeOn", "scheduleArray", "input", "scheduler", "Observable", "subscriber", "i", "scheduleIterable", "input", "scheduler", "Observable", "subscriber", "iterator", "executeSchedule", "value", "done", "_a", "err", "isFunction", "scheduleAsyncIterable", "input", "scheduler", "Observable", "subscriber", "executeSchedule", "iterator", "result", "scheduleReadableStreamLike", "input", "scheduler", "scheduleAsyncIterable", "readableStreamLikeToAsyncGenerator", "scheduled", "input", "scheduler", "isInteropObservable", "scheduleObservable", "isArrayLike", "scheduleArray", "isPromise", "schedulePromise", "isAsyncIterable", "scheduleAsyncIterable", "isIterable", "scheduleIterable", "isReadableStreamLike", "scheduleReadableStreamLike", "createInvalidObservableTypeError", "from", "input", "scheduler", "scheduled", "innerFrom", "map", "project", "thisArg", "operate", "source", "subscriber", "index", "createOperatorSubscriber", "value", "mergeInternals", "source", "subscriber", "project", "concurrent", "onBeforeNext", "expand", "innerSubScheduler", "additionalFinalizer", "buffer", "active", "index", "isComplete", "checkComplete", "outerNext", "value", "doInnerSub", "innerComplete", "innerFrom", "createOperatorSubscriber", "innerValue", "bufferedValue", "executeSchedule", "err", "mergeMap", "project", "resultSelector", "concurrent", "isFunction", "a", "i", "map", "b", "ii", "innerFrom", "operate", "source", "subscriber", "mergeInternals", "scanInternals", "accumulator", "seed", "hasSeed", "emitOnNext", "emitBeforeComplete", "source", "subscriber", "hasState", "state", "index", "createOperatorSubscriber", "value", "i", "reduce", "accumulator", "seed", "operate", "scanInternals", "arrReducer", "arr", "value", "toArray", "operate", "source", "subscriber", "reduce", "V1_OPS", "V2_OPS", "MATCH_OPS", "consumesQuery", "op", "consumesTarget", "isMatchOp", "clipSyntenyFeature", "cigar", "start", "mateStart", "mateEnd", "strand", "winStart", "winEnd", "revTarget", "bp1", "bp2", "out", "qLo", "qHi", "tLo", "tHi", "extendTarget", "a", "b", "k", "packed", "len", "isRun", "qAdv", "tAdv", "bp1Next", "bp2Next", "opQLo", "opQHi", "cLo", "cHi", "ratio", "keptOwn", "keptMate", "tEntry", "isGapOp", "splitSyntenyFeatureAtGaps", "gapBp", "runs", "run", "aligned", "close", "second", "getCigar", "feature", "cigar", "getCoarseCigar", "coarse", "getAlignmentOps", "feature", "cigar", "getCigar", "coarse", "getCoarseCigar", "parseCigar2Typed", "parseCoarseCigar", "ALIGNMENT_STRING_FIELDS", "isMate", "mate", "mateOf", "feature", "interpolateClip", "own", "strand", "window", "lo", "hi", "ratio", "mateAt", "q", "a", "b", "clipIntervals", "splitAtGapBp", "keepAlignment", "inside", "ops", "getAlignmentOps", "clipped", "splitSyntenyFeatureAtGaps", "run", "clipSyntenyFeature", "clippedFeature", "suffix", "source", "data", "field", "SyntenyFeature", "clipFeatureToRegion", "pieces", "piece", "i", "ComparativeAdapterBase", "BaseFeatureDataAdapter", "regions", "opts", "clipToRegion", "splitAtGapBp", "keepAlignment", "rest", "clip", "slot", "createStatusFanOut", "from", "mergeMap", "region", "index", "feature", "clipFeatureToRegion", "toArray", "map", "features", "chunks", "a", "b", "chunk", "PairTargetError", "queryAssemblyName", "requestedPairs", "opts", "lanePairs", "targetAssemblyName", "lanePairsStatus", "pairs", "first", "laneAssemblyName", "asmByPrefix", "prefix", "panSNSample", "laneZoomFold", "windowBp", "fitsBp", "fits", "laneZoomNotice", "error", "isNodeLimitError", "matchFeature", "target", "query", "strand", "cigar", "matches", "columns", "id", "SyntenyFeature"]
|
|
7
7
|
}
|