jbrowse-plugin-graphgenomeviewer 10.0.2 → 10.0.4

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.
Files changed (66) hide show
  1. package/dist/chunks/{AddTrackWorkflow-W7XIQ5F3.js → AddTrackWorkflow-47H3VBK4.js} +2 -2
  2. package/dist/chunks/{GbzBaseSyntenyAdapter-JMYDJODG.js → GbzBaseSyntenyAdapter-X6AW5IYW.js} +2 -2
  3. package/dist/chunks/{GraphGenomeView-2WSTZQNY.js → GraphGenomeView-ZTZEYNUY.js} +2 -2
  4. package/dist/chunks/{LinearGraphDisplay-VYCJVUW4.js → LinearGraphDisplay-QWJZ5PSO.js} +2 -2
  5. package/dist/chunks/{MinigraphBubbleAdapter-N5BOXD7U.js → MinigraphBubbleAdapter-WUTIBCFA.js} +2 -2
  6. package/dist/chunks/{RgfaTabixAdapter-FZZ7W2HN.js → RgfaTabixAdapter-VT7TYMNE.js} +2 -2
  7. package/dist/chunks/{WalkFormsAdapter-TZW5UBRI.js → WalkFormsAdapter-VRJ4FYQB.js} +2 -2
  8. package/dist/chunks/{WalkTabixSyntenyAdapter-XM7HBNJA.js → WalkTabixSyntenyAdapter-ZYWYXAC7.js} +2 -2
  9. package/dist/chunks/{WalkTabixSyntenyAdapter-XM7HBNJA.js.map → WalkTabixSyntenyAdapter-ZYWYXAC7.js.map} +2 -2
  10. package/dist/chunks/chunk-4MTS65XF.js +3 -0
  11. package/dist/chunks/{chunk-ZKQLPKNN.js.map → chunk-4MTS65XF.js.map} +3 -3
  12. package/dist/chunks/{chunk-NLHJYXCS.js → chunk-5FMNLEED.js} +2 -2
  13. package/dist/chunks/{chunk-NDWP2KNR.js → chunk-JJ2TPWSH.js} +2 -2
  14. package/dist/chunks/{chunk-EVYIBH4N.js → chunk-MQ43JVZM.js} +2 -2
  15. package/dist/chunks/{chunk-D7BAG2VJ.js → chunk-P7V5S3V3.js} +2 -2
  16. package/dist/chunks/{chunk-D7BAG2VJ.js.map → chunk-P7V5S3V3.js.map} +2 -2
  17. package/dist/chunks/chunk-TDHUAADJ.js +6 -0
  18. package/dist/chunks/chunk-TDHUAADJ.js.map +7 -0
  19. package/dist/chunks/{chunk-AVUNIRM5.js → chunk-TP6OXTXD.js} +5 -5
  20. package/dist/chunks/chunk-TP6OXTXD.js.map +7 -0
  21. package/dist/chunks/{chunk-JLIDLLZG.js → chunk-UPSA4KVF.js} +2 -2
  22. package/dist/chunks/{chunk-HTVBMX7V.js → chunk-UXBGMTAO.js} +2 -2
  23. package/dist/chunks/chunk-VV5LVNCP.js +9 -0
  24. package/dist/chunks/chunk-VV5LVNCP.js.map +7 -0
  25. package/dist/chunks/renderSvg-SEYWHXD7.js +2 -0
  26. package/dist/chunks/renderSvg-SEYWHXD7.js.map +7 -0
  27. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js +1 -1
  28. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js.map +1 -1
  29. package/package.json +2 -2
  30. package/src/GraphGenomeView/components/PaneSvg.tsx +2 -1
  31. package/src/GraphGenomeView/model.facetRebuild.test.ts +10 -7
  32. package/src/GraphGenomeView/model.fold.test.ts +2 -5
  33. package/src/GraphGenomeView/model.geneNames.test.ts +4 -4
  34. package/src/GraphGenomeView/model.layout.test.ts +6 -13
  35. package/src/GraphGenomeView/model.passes.test.tsx +2 -5
  36. package/src/GraphGenomeView/model.ts +2 -8
  37. package/src/GraphGenomeView/pane/fitViews.ts +63 -20
  38. package/src/GraphGenomeView/pane/graphViews.ts +1 -18
  39. package/src/GraphGenomeView/pane/paneBase.ts +28 -13
  40. package/src/GraphGenomeView/pane/renderingActions.ts +34 -66
  41. package/src/GraphGenomeView/pane/settingActions.ts +47 -28
  42. package/src/GraphGenomeView/renderPipeline.test.ts +28 -9
  43. package/src/LinearGraphDisplay/LinearGraphDisplay.test.ts +6 -6
  44. package/src/RgfaTabixAdapter/walkReader.ts +4 -2
  45. package/src/WalkTabixSyntenyAdapter/WalkTabixSyntenyAdapter.ts +1 -1
  46. package/src/version.ts +1 -1
  47. package/dist/chunks/chunk-AVUNIRM5.js.map +0 -7
  48. package/dist/chunks/chunk-CTQBRAQH.js +0 -6
  49. package/dist/chunks/chunk-CTQBRAQH.js.map +0 -7
  50. package/dist/chunks/chunk-EUXYBAW2.js +0 -9
  51. package/dist/chunks/chunk-EUXYBAW2.js.map +0 -7
  52. package/dist/chunks/chunk-ZKQLPKNN.js +0 -3
  53. package/dist/chunks/renderSvg-X3BRMJX3.js +0 -2
  54. package/dist/chunks/renderSvg-X3BRMJX3.js.map +0 -7
  55. /package/dist/chunks/{AddTrackWorkflow-W7XIQ5F3.js.map → AddTrackWorkflow-47H3VBK4.js.map} +0 -0
  56. /package/dist/chunks/{GbzBaseSyntenyAdapter-JMYDJODG.js.map → GbzBaseSyntenyAdapter-X6AW5IYW.js.map} +0 -0
  57. /package/dist/chunks/{GraphGenomeView-2WSTZQNY.js.map → GraphGenomeView-ZTZEYNUY.js.map} +0 -0
  58. /package/dist/chunks/{LinearGraphDisplay-VYCJVUW4.js.map → LinearGraphDisplay-QWJZ5PSO.js.map} +0 -0
  59. /package/dist/chunks/{MinigraphBubbleAdapter-N5BOXD7U.js.map → MinigraphBubbleAdapter-WUTIBCFA.js.map} +0 -0
  60. /package/dist/chunks/{RgfaTabixAdapter-FZZ7W2HN.js.map → RgfaTabixAdapter-VT7TYMNE.js.map} +0 -0
  61. /package/dist/chunks/{WalkFormsAdapter-TZW5UBRI.js.map → WalkFormsAdapter-VRJ4FYQB.js.map} +0 -0
  62. /package/dist/chunks/{chunk-NLHJYXCS.js.map → chunk-5FMNLEED.js.map} +0 -0
  63. /package/dist/chunks/{chunk-NDWP2KNR.js.map → chunk-JJ2TPWSH.js.map} +0 -0
  64. /package/dist/chunks/{chunk-EVYIBH4N.js.map → chunk-MQ43JVZM.js.map} +0 -0
  65. /package/dist/chunks/{chunk-JLIDLLZG.js.map → chunk-UPSA4KVF.js.map} +0 -0
  66. /package/dist/chunks/{chunk-HTVBMX7V.js.map → chunk-UXBGMTAO.js.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/WalkTabixSyntenyAdapter/walkLanes.ts", "../../src/WalkTabixSyntenyAdapter/WalkTabixSyntenyAdapter.ts"],
4
- "sourcesContent": ["import { weightedLcs } from '@gmod/gbz-base/lcs'\nimport { pairAlignments, pairCigar } from '@gmod/gbz-base/pairAlignment'\nimport { panSNContig } from '@jbrowse/bandage-core/pansn'\n\nimport SyntenyFeature from '../synteny/SyntenyFeature.ts'\nimport { matchFeature } from '../synteny/matchFeature.ts'\n\nimport type { PairChain, PairEdit } from '@gmod/gbz-base/pairAlignment'\nimport type {\n WalkDeparture,\n WalkFragment,\n WalkNode,\n} from '@jbrowse/graph-walks'\n\n// The longest bubble with equal bases on both sides that is written as\n// mismatches; a longer one stays an insertion and a deletion\nconst BALANCED_BUBBLE_MAX_BP = 50\n\n/**\n * A chain's edits with each short balanced bubble as `X`. The walks carry no\n * bases, so two walks differ wherever they leave a shared node, and a SNP is\n * one base inserted and one deleted until it is read as the mismatch it is.\n */\nexport function bubblesAsMismatches(edits: PairEdit[]) {\n const out: PairEdit[] = []\n for (let i = 0; i < edits.length; i++) {\n const [op, len] = edits[i]!\n const [nextOp, nextLen] = edits[i + 1] ?? []\n if (\n len === nextLen &&\n len <= BALANCED_BUBBLE_MAX_BP &&\n ((op === 'I' && nextOp === 'D') || (op === 'D' && nextOp === 'I'))\n ) {\n out.push(['X', len])\n i++\n } else {\n out.push([op, len])\n }\n }\n return out\n}\n\n// A walk's steps as the handles gbz-base reads, 2 * id + reversed\nfunction handlesOf(fragment: WalkFragment) {\n return Array.from(fragment.ids, (id, i) => 2 * id + fragment.rev[i]!)\n}\n\nfunction nodeLength(nodes: Map<number, WalkNode>, id: number) {\n const node = nodes.get(id)\n return node === undefined ? 0 : node.end - node.start\n}\n\n/**\n * Aligns one walk fragment to another on the nodes both visit, from node\n * lengths alone: the fragments' steps as the handles gbz-base's chainer reads,\n * and a stand-in sequence of each node's length.\n */\nexport function walkAligner(nodes: Map<number, WalkNode>) {\n const standIn = new Map<number, string>()\n const sequenceOf = (id: number) => {\n const length = nodeLength(nodes, id)\n let sequence = standIn.get(length)\n if (sequence === undefined) {\n sequence = 'N'.repeat(length)\n standIn.set(length, sequence)\n }\n return sequence\n }\n const handles = new Map<WalkFragment, number[]>()\n const cachedHandles = (fragment: WalkFragment) => {\n let steps = handles.get(fragment)\n if (steps === undefined) {\n steps = handlesOf(fragment)\n handles.set(fragment, steps)\n }\n return steps\n }\n return (query: WalkFragment, target: WalkFragment) =>\n pairAlignments({\n query: cachedHandles(query),\n target: cachedHandles(target),\n sequenceOf,\n bases: false,\n })\n}\n\n// The fewest bases on shared nodes a record against the reference keeps,\n// gbz-base's floor for a pair record\nconst MIN_MATCH_BP = 100\n\nfunction appendEdit(edits: PairEdit[], op: PairEdit[0], len: number) {\n const last = edits.at(-1)\n if (len > 0) {\n if (last?.[0] === op) {\n last[1] += len\n } else {\n edits.push([op, len])\n }\n }\n}\n\n/**\n * Aligns a haplotype's walk fragment to the reference's as gbz-base aligns a\n * walk to its reference path: the heaviest common subsequence of their steps,\n * each node weighing its length, read in whichever direction shares more. A\n * pair chain leaves out every node either walk passes twice, which is the\n * whole of a collapsed copy-number array (amylase, KIV-2); the subsequence\n * matches one pass over it, and the other copies are insertions.\n */\nexport function referenceAligner(nodes: Map<number, WalkNode>) {\n const lengthOf = (handle: number) => nodeLength(nodes, handle >> 1)\n const offsets = (handles: number[]) => {\n const out = new Float64Array(handles.length + 1)\n handles.forEach((handle, i) => {\n out[i + 1] = out[i]! + lengthOf(handle)\n })\n return out\n }\n\n return (query: WalkFragment, target: WalkFragment): PairChain[] => {\n const ref = handlesOf(target)\n const hap = handlesOf(query)\n const [same, sameWeight] = weightedLcs(hap, ref, lengthOf)\n const [turned, turnedWeight] = weightedLcs(\n hap.map(handle => handle ^ 1).reverse(),\n ref,\n lengthOf,\n )\n const reverse = turnedWeight > sameWeight\n const pairs = reverse ? turned : same\n const sharedBases = Math.max(sameWeight, turnedWeight)\n if (sharedBases < MIN_MATCH_BP) {\n return []\n }\n const refAt = offsets(ref)\n const hapAt = offsets(hap)\n // a pair's haplotype step, counted along the haplotype\n const stepOf = (k: number) =>\n reverse ? hap.length - 1 - pairs[k]![0] : pairs[k]![0]\n const edits: PairEdit[] = []\n pairs.forEach(([, r], k) => {\n if (k > 0) {\n const [lo, hi] = [stepOf(k - 1), stepOf(k)].sort((x, y) => x - y)\n appendEdit(edits, 'I', hapAt[hi!]! - hapAt[lo! + 1]!)\n appendEdit(edits, 'D', refAt[r]! - refAt[pairs[k - 1]![1] + 1]!)\n }\n appendEdit(edits, '=', lengthOf(ref[r]!))\n })\n const [lo, hi] = [stepOf(0), stepOf(pairs.length - 1)].sort((x, y) => x - y)\n return [\n {\n queryStart: hapAt[lo!]!,\n queryEnd: hapAt[hi! + 1]!,\n targetStart: refAt[pairs[0]![1]]!,\n targetEnd: refAt[pairs.at(-1)![1] + 1]!,\n strand: reverse ? '-' : '+',\n edits,\n sharedBases,\n },\n ]\n }\n}\n\n// Each node a walk visits once, with the direction it passes it\nfunction singleVisits(fragment: WalkFragment) {\n const rev = new Map<number, number>()\n const twice = new Set<number>()\n fragment.ids.forEach((id, i) => {\n if (rev.has(id)) {\n twice.add(id)\n } else {\n rev.set(id, fragment.rev[i]!)\n }\n })\n for (const id of twice) {\n rev.delete(id)\n }\n return rev\n}\n\n// The bases on singly visited nodes two walks pass the same way and the\n// opposite way\nfunction directionShares(nodes: Map<number, WalkNode>) {\n const visits = new Map<WalkFragment, Map<number, number>>()\n const visitsOf = (fragment: WalkFragment) => {\n let found = visits.get(fragment)\n if (found === undefined) {\n found = singleVisits(fragment)\n visits.set(fragment, found)\n }\n return found\n }\n return (query: WalkFragment, target: WalkFragment) => {\n const theirs = visitsOf(target)\n let same = 0\n let opposite = 0\n for (const [id, rev] of visitsOf(query)) {\n const other = theirs.get(id)\n if (other === rev) {\n same += nodeLength(nodes, id)\n } else if (other !== undefined) {\n opposite += nodeLength(nodes, id)\n }\n }\n return { same, opposite }\n }\n}\n\n/**\n * Aligns one lane's walk fragment to another's. The weighted subsequence\n * (`referenceAligner`) is the fast route and matches through copy-number\n * arrays, but it reads one direction per pair, so an inversion between the\n * lanes comes out as an insertion beside a deletion. A pair sharing 100 bp\n * (MIN_MATCH_BP) or more of singly visited nodes in each direction goes to\n * pair chaining (`walkAligner`) instead, which answers the inverted stretch as\n * a reverse-strand record of its own. Chaining leaves out every node a walk\n * passes twice, so counting singly visited nodes misses no inversion it could\n * draw.\n */\nexport function lanePairAligner(nodes: Map<number, WalkNode>) {\n const subsequence = referenceAligner(nodes)\n const chained = walkAligner(nodes)\n const shares = directionShares(nodes)\n return (query: WalkFragment, target: WalkFragment) => {\n const { same, opposite } = shares(query, target)\n return same >= MIN_MATCH_BP && opposite >= MIN_MATCH_BP\n ? chained(query, target)\n : subsequence(query, target)\n }\n}\n\n// The multi-way display's SPLIT_AT_GAP_BP, under which a turned stretch names\n// no inversion there\nconst TURNED_MIN_BP = 10_000\n\n/**\n * Aligns a haplotype's walk fragment to the reference's as `referenceAligner`\n * does, then adds the stretches it reads the other way. A walk sharing\n * TURNED_MIN_BP or more of singly visited nodes in each direction is chained\n * too, and the chained records on the strand the subsequence did not take are\n * its turned stretches. The subsequence record stays, so a copy-number array,\n * which chaining leaves out, still matches one pass alike in every lane.\n */\nexport function anchorAligner(nodes: Map<number, WalkNode>) {\n const subsequence = referenceAligner(nodes)\n const chained = walkAligner(nodes)\n const shares = directionShares(nodes)\n return (query: WalkFragment, target: WalkFragment) => {\n const records = subsequence(query, target)\n const taken = records[0]?.strand\n const { same, opposite } = shares(query, target)\n return taken === undefined || Math.min(same, opposite) < TURNED_MIN_BP\n ? records\n : [\n ...records,\n ...chained(query, target).filter(chain => chain.strand !== taken),\n ]\n }\n}\n\n/**\n * One record of a walk aligned to another, with its short balanced bubbles as\n * mismatches\n */\nexport function chainFeature({\n chain,\n target,\n query,\n assemblyName,\n refName,\n mateAssemblyName,\n}: {\n chain: PairChain\n target: WalkFragment\n query: WalkFragment\n assemblyName: string\n refName: string\n mateAssemblyName: string\n}) {\n const edits = bubblesAsMismatches(chain.edits)\n return matchFeature({\n target: {\n name: target.name,\n assemblyName,\n refName,\n start: target.hapStart + chain.targetStart,\n end: target.hapStart + chain.targetEnd,\n },\n query: {\n name: query.name,\n assemblyName: mateAssemblyName,\n refName: panSNContig(query.name),\n start: query.hapStart + chain.queryStart,\n end: query.hapStart + chain.queryEnd,\n },\n strand: chain.strand,\n cigar: pairCigar(edits),\n matches: edits.reduce((sum, [op, n]) => sum + (op === '=' ? n : 0), 0),\n columns: edits.reduce((sum, [, n]) => sum + n, 0),\n })\n}\n\n/**\n * Whether a walk's fragment steps on the reference inside the window: on a\n * node of `refName` overlapping it\n */\nexport function stepsInWindow(\n fragment: WalkFragment,\n nodes: Map<number, WalkNode>,\n refName: string,\n window: { start: number; end: number },\n) {\n return Array.from(fragment.ids).some(id => {\n const node = nodes.get(id)\n return (\n node?.rank === 0 &&\n node.refName === refName &&\n node.start < window.end &&\n node.end > window.start\n )\n })\n}\n\n/** Whether the reference between a departure's ends covers the whole window */\nexport function departureSpans(\n { leavePos, rejoinPos }: WalkDeparture,\n window: { start: number; end: number },\n) {\n return (\n Math.min(leavePos, rejoinPos) <= window.start &&\n Math.max(leavePos, rejoinPos) >= window.end\n )\n}\n\n/**\n * A haplotype whose departure from the reference spans the whole window, as\n * the record a multi-way display lifts out as a deletion: `spansWindow`, the\n * reference between the departure's ends whole so its length heads the lane,\n * and the haplotype's own sequence between them as its mate, a point where\n * it has none. The record runs the way the walk rejoins the reference, and\n * carries no CIGAR and no identity, so no ramp or identity filter reads it\n * as an alignment.\n */\nexport function departureFeature({\n departure,\n refName,\n assemblyName,\n mateAssemblyName,\n}: {\n departure: WalkDeparture\n refName: string\n assemblyName: string\n mateAssemblyName: string\n}) {\n const { name, hapStart, ownBp, leavePos, rejoinPos, rejoinReversed } =\n departure\n const id = `${name}:${hapStart}:${leavePos}:departure`\n return new SyntenyFeature({\n uniqueId: id,\n assemblyName,\n refName,\n start: Math.min(leavePos, rejoinPos),\n end: Math.max(leavePos, rejoinPos),\n type: 'departure',\n strand: rejoinReversed ? -1 : 1,\n syntenyId: id,\n spansWindow: true,\n mate: {\n refName: panSNContig(name),\n start: hapStart,\n end: hapStart + ownBp,\n assemblyName: mateAssemblyName,\n },\n })\n}\n", "import {\n assemblyByPanSNPrefix,\n panSNContig,\n panSNHaplotype,\n panSNMatchesPrefix,\n panSNSample,\n resolvePanSNPrefix,\n} from '@jbrowse/bandage-core/pansn'\nimport { updateStatus } from '@jbrowse/core/util'\nimport { ObservableCreate } from '@jbrowse/core/util/rxjs'\nimport { getSamplesTsvSources } from '@jbrowse/core/util/samplesTsv'\nimport { walksKept } from '@jbrowse/graph-walks'\n\nimport {\n anchorAligner,\n chainFeature,\n departureFeature,\n departureSpans,\n lanePairAligner,\n stepsInWindow,\n} from './walkLanes.ts'\nimport { WalkIndex } from '../RgfaTabixAdapter/walkReader.ts'\nimport { locationIsSet } from '../locationName.ts'\nimport { PanSNRefNames, openWalkReader } from '../panSNTabix.ts'\nimport { ComparativeAdapterBase } from '../synteny/ComparativeAdapterBase.ts'\nimport {\n laneAssemblyName,\n lanePairsStatus,\n requestedPairs,\n} from '../synteny/lanePairs.ts'\nimport { laneZoomNotice } from '../synteny/laneZoomNotice.ts'\nimport { sheetColorOf } from '../synteny/sheetColors.ts'\n\nimport type { WalkTabixSyntenyAdapterConfig } from './configSchema.ts'\nimport type { SubgraphAdapterOptions } from '../GetSubgraph.ts'\nimport type { LaneFeatureOptions, LanePair } from '../synteny/lanePairs.ts'\nimport type { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter'\nimport type { Feature } from '@jbrowse/core/util'\nimport type { Region } from '@jbrowse/core/util/types'\n\nconst haplotypeOf = ({ name }: { name: string }) => panSNHaplotype(name) ?? name\n\nexport default class WalkTabixSyntenyAdapter extends ComparativeAdapterBase<WalkTabixSyntenyAdapterConfig> {\n private readonly walks: WalkIndex = new WalkIndex(openWalkReader(this), this)\n private readonly refNames: PanSNRefNames = new PanSNRefNames(\n this.walks.source,\n this,\n )\n\n private get anchor() {\n const anchor = this.getConf('assemblyNames')[0]\n if (anchor === undefined) {\n throw new Error(\n 'WalkTabixSyntenyAdapter needs assemblyNames: its first entry is the assembly the reference sample is loaded as',\n )\n }\n return anchor\n }\n\n /**\n * The haplotypes the walk file's header names, `sample#haplotype` in byte\n * order, or undefined when it names none\n */\n async getHaplotypeNames(opts: BaseOptions = {}) {\n return this.walks.haplotypeNames(opts)\n }\n\n /**\n * `lanes` is every haplotype the header names but the anchor's own,\n * declared up front so the display can offer the whole graph's haplotypes\n * before a fetch has placed any of them. A lane's `color`, and the anchor's\n * `anchorColor`, is its haplotype's in `samplesTsvLocation`, where it has one;\n * a sheet that fails to read leaves the lanes uncoloured rather than failing\n * them\n */\n async getHeader(opts: BaseOptions = {}) {\n const [{ haplotypes }, colorOf] = await Promise.all([\n this.walks.reader.header(opts),\n this.sheetColors(opts),\n ])\n const { anchor } = this\n const anchorPrefix = resolvePanSNPrefix(this, anchor)\n const asmByPrefix = assemblyByPanSNPrefix(this)\n const isAnchor = (prefix: string) =>\n prefix === anchorPrefix || panSNSample(prefix) === anchorPrefix\n const anchorColor = colorOf?.(haplotypes.find(isAnchor) ?? anchorPrefix)\n return {\n hasCoarseTier: false,\n anchorAssemblyName: anchor,\n ...(anchorColor === undefined ? {} : { anchorColor }),\n lanes: haplotypes\n .filter(prefix => !isAnchor(prefix))\n .map(prefix => {\n const color = colorOf?.(prefix)\n return {\n name: laneAssemblyName(asmByPrefix, prefix),\n label: prefix,\n group: panSNSample(prefix),\n ...(color === undefined ? {} : { color }),\n }\n }),\n }\n }\n\n private async sheetColors(opts: BaseOptions) {\n const location = this.getConf('samplesTsvLocation')\n return locationIsSet(location)\n ? getSamplesTsvSources({\n location,\n names: undefined,\n namesLabel: 'the walk file',\n pluginManager: this.pluginManager,\n opts,\n }).then(\n ({ sources }) => sheetColorOf(sources, assemblyByPanSNPrefix(this)),\n () => undefined,\n )\n : undefined\n }\n\n // A lane's contigs are named only in its walk rows, so only the anchor's\n // are listed\n async getRefNames(opts: BaseOptions = {}) {\n const { assemblyName } = opts\n return assemblyName === undefined || assemblyName === this.anchor\n ? this.refNames.assemblyRefNames({ ...opts, assemblyName: this.anchor })\n : []\n }\n\n /**\n * The graph display's cut of the window, as RgfaTabixAdapter cuts a\n * walk-indexed graph: the reference walk first, then the walks `haplotypes`\n * asks for, and the nodes and links they visit\n */\n async getSubgraph(region: Region, opts: SubgraphAdapterOptions = {}) {\n const refName = await this.refNames.resolveForCut(region, {\n signal: opts.signal,\n })\n return this.walks.subgraph(refName, region, opts)\n }\n\n // The window's walks for the haplotypes named and the reference, with\n // every departure from the reference over it and no link read; a window\n // past a budget fails as a zoom-in notice for lanes. Named lanes come back\n // in full where the walk file abridged them, so a lane draws the nodes its\n // haplotype walks rather than runs of steps not fetched.\n private async laneWalks(\n refName: string,\n region: Region,\n prefixes: string[] | undefined,\n opts: LaneFeatureOptions,\n status: string,\n ) {\n const keep = walksKept(prefixes, refName)\n return updateStatus(status, opts.statusCallback, () =>\n this.walks.reader\n .cut(refName, region, {\n ...this.walks.cutOptions(),\n signal: opts.signal,\n keep,\n expand: keep,\n links: false,\n })\n .catch((error: unknown) => {\n throw laneZoomNotice(error, region.end - region.start)\n }),\n )\n }\n\n /**\n * One record per stretch a haplotype's walk shares with the reference's,\n * on the reference with the haplotype as its mate. A haplotype with no step\n * on the reference inside the window whose departure spans it is one\n * `spansWindow` record of the departure's stretch, its mate the haplotype's\n * own sequence between the departure's ends, a point where it has none.\n */\n private async anchorFeatures(\n refName: string,\n region: Region,\n opts: LaneFeatureOptions,\n ) {\n const wanted = opts.haplotypes?.length\n ? opts.haplotypes.map(lane => resolvePanSNPrefix(this, lane))\n : undefined\n const target = resolvePanSNPrefix(this, opts.targetAssemblyName)\n const prefixes =\n target === undefined\n ? wanted\n : wanted === undefined ||\n wanted.some(\n prefix =>\n panSNMatchesPrefix(target, prefix) ||\n panSNMatchesPrefix(prefix, target),\n )\n ? [target]\n : []\n if (prefixes?.length === 0) {\n return []\n }\n const { start, end } = region\n const status = `Reading walks ${region.refName}:${start.toLocaleString()}-${end.toLocaleString()}`\n const { graph, fragments, departures } = await this.laneWalks(\n refName,\n region,\n prefixes,\n opts,\n status,\n )\n // lanes come back in the order the fetch names them, which is the order\n // the display stacks lanes of equal weight in\n const rank = ({ name }: { name: string }) =>\n prefixes === undefined\n ? 0\n : prefixes.findIndex(prefix => panSNMatchesPrefix(name, prefix))\n const align = anchorAligner(graph.nodes)\n const asmByPrefix = assemblyByPanSNPrefix(this)\n const laneOf = (walk: { name: string }) =>\n laneAssemblyName(asmByPrefix, haplotypeOf(walk))\n const references = fragments.filter(f => f.name === refName)\n const walked = fragments\n .filter(fragment => fragment.name !== refName && rank(fragment) >= 0)\n .map(query => ({\n rank: rank(query),\n features: references.flatMap(reference =>\n align(query, reference).map(chain =>\n chainFeature({\n chain,\n target: reference,\n query,\n assemblyName: region.assemblyName,\n refName: region.refName,\n mateAssemblyName: laneOf(query),\n }),\n ),\n ),\n }))\n // NA19036#1 skips the IGL locus on one contig and walks it on another\n const walking = new Set(\n fragments\n .filter(fragment =>\n stepsInWindow(fragment, graph.nodes, refName, region),\n )\n .map(haplotypeOf),\n )\n const spanning = departures\n .filter(\n departure =>\n rank(departure) >= 0 &&\n !walking.has(haplotypeOf(departure)) &&\n departureSpans(departure, region),\n )\n .sort((a, b) => a.name.localeCompare(b.name))\n .map(departure => ({\n rank: rank(departure),\n features: [\n departureFeature({\n departure,\n refName: region.refName,\n assemblyName: region.assemblyName,\n mateAssemblyName: laneOf(departure),\n }),\n ],\n }))\n return [...walked, ...spanning]\n .sort((a, b) => a.rank - b.rank)\n .flatMap(lane => lane.features)\n }\n\n /**\n * Each pair's two lanes read out of the anchor window, all pairs in one\n * read, and each walk of a pair's query lane aligned to each walk of its\n * target lane. A pair's records sit on its query lane's contigs, the lane\n * the display draws on top.\n */\n private async pairFeatures(\n refName: string,\n region: Region,\n pairs: LanePair[],\n opts: LaneFeatureOptions,\n ) {\n const sides = pairs.map(pair => ({\n pair,\n featurePrefix: resolvePanSNPrefix(this, pair.queryAssemblyName),\n matePrefix: resolvePanSNPrefix(this, pair.targetAssemblyName),\n }))\n const { graph, fragments } = await this.laneWalks(\n refName,\n region,\n sides.flatMap(side => [side.featurePrefix, side.matePrefix]),\n opts,\n lanePairsStatus(pairs),\n )\n const align = lanePairAligner(graph.nodes)\n const walksOf = (prefix: string) =>\n fragments.filter(f => panSNMatchesPrefix(f.name, prefix))\n return sides.flatMap(({ pair, featurePrefix, matePrefix }) =>\n walksOf(featurePrefix).flatMap(target =>\n walksOf(matePrefix).flatMap(query =>\n align(query, target).map(chain =>\n chainFeature({\n chain,\n target,\n query,\n assemblyName: pair.queryAssemblyName,\n refName: panSNContig(target.name),\n mateAssemblyName: pair.targetAssemblyName,\n }),\n ),\n ),\n ),\n )\n }\n\n // The files are filed under the reference alone, so a window on a\n // haplotype lane has no answer: a lane pair is read inside the anchor's\n getFeatures(region: Region, opts: LaneFeatureOptions = {}) {\n return ObservableCreate<Feature>(async observer => {\n const refName =\n region.assemblyName === this.anchor\n ? await this.refNames.resolveMapped(region, opts)\n : undefined\n if (refName !== undefined) {\n const pairs = requestedPairs(opts)\n const features =\n pairs.length > 0\n ? await this.pairFeatures(refName, region, pairs, opts)\n : await this.anchorFeatures(refName, region, opts)\n for (const feature of features) {\n observer.next(feature)\n }\n }\n observer.complete()\n }, opts.signal)\n }\n}\n"],
5
- "mappings": "62BAgBA,IAAMA,GAAyB,GAOxB,SAASC,GAAoBC,EAAmB,CACrD,IAAMC,EAAkB,CAAC,EACzB,QAASC,EAAI,EAAGA,EAAIF,EAAM,OAAQE,IAAK,CACrC,GAAM,CAACC,EAAIC,CAAG,EAAIJ,EAAME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AK,UAAU,CAAC,EAC3D7D,EACA8D,EAAgBJ,CAAK,CACvB,EACMpB,EAAQyB,GAAgB7B,EAAM,KAAK,EACnC8B,EAAWxD,GACf2B,EAAU,OAAO,GAAKJ,EAAmB,EAAE,KAAMvB,CAAM,CAAC,EAC1D,OAAOmD,EAAM,QAAQ,CAAC,CAAE,KAAAC,EAAM,cAAAK,EAAe,WAAAC,CAAW,IACtDF,EAAQC,CAAa,EAAE,QAAQnC,GAC7BkC,EAAQE,CAAU,EAAE,QAAQpB,GAC1BR,EAAMQ,EAAOhB,CAAM,EAAE,IAAIkB,GACvBC,EAAa,CACX,MAAAD,EACA,OAAAlB,EACA,MAAAgB,EACA,aAAcc,EAAK,kBACnB,QAASO,EAAYrC,EAAO,IAAI,EAChC,iBAAkB8B,EAAK,kBACzB,CAAC,CACH,CACF,CACF,CACF,CACF,CAIA,YAAYzC,EAAgBnB,EAA2B,CAAC,EAAG,CACzD,OAAOoE,EAA0B,MAAMC,GAAY,CACjD,IAAMjD,EACJD,EAAO,eAAiB,KAAK,OACzB,MAAM,KAAK,SAAS,cAAcA,EAAQnB,CAAI,EAC9C,OACN,GAAIoB,IAAY,OAAW,CACzB,IAAMsC,EAAQY,EAAetE,CAAI,EAC3BuE,EACJb,EAAM,OAAS,EACX,MAAM,KAAK,aAAatC,EAASD,EAAQuC,EAAO1D,CAAI,EACpD,MAAM,KAAK,eAAeoB,EAASD,EAAQnB,CAAI,EACrD,QAAWwE,KAAWD,EACpBF,EAAS,KAAKG,CAAO,CAEzB,CACAH,EAAS,SAAS,CACpB,EAAGrE,EAAK,MAAM,CAChB,CACF",
4
+ "sourcesContent": ["import { weightedLcs } from '@gmod/gbz-base/lcs'\nimport { pairAlignments, pairCigar } from '@gmod/gbz-base/pairAlignment'\nimport { panSNContig } from '@jbrowse/bandage-core/pansn'\n\nimport SyntenyFeature from '../synteny/SyntenyFeature.ts'\nimport { matchFeature } from '../synteny/matchFeature.ts'\n\nimport type { PairChain, PairEdit } from '@gmod/gbz-base/pairAlignment'\nimport type {\n WalkDeparture,\n WalkFragment,\n WalkNode,\n} from '@jbrowse/graph-walks'\n\n// The longest bubble with equal bases on both sides that is written as\n// mismatches; a longer one stays an insertion and a deletion\nconst BALANCED_BUBBLE_MAX_BP = 50\n\n/**\n * A chain's edits with each short balanced bubble as `X`. The walks carry no\n * bases, so two walks differ wherever they leave a shared node, and a SNP is\n * one base inserted and one deleted until it is read as the mismatch it is.\n */\nexport function bubblesAsMismatches(edits: PairEdit[]) {\n const out: PairEdit[] = []\n for (let i = 0; i < edits.length; i++) {\n const [op, len] = edits[i]!\n const [nextOp, nextLen] = edits[i + 1] ?? []\n if (\n len === nextLen &&\n len <= BALANCED_BUBBLE_MAX_BP &&\n ((op === 'I' && nextOp === 'D') || (op === 'D' && nextOp === 'I'))\n ) {\n out.push(['X', len])\n i++\n } else {\n out.push([op, len])\n }\n }\n return out\n}\n\n// A walk's steps as the handles gbz-base reads, 2 * id + reversed\nfunction handlesOf(fragment: WalkFragment) {\n return Array.from(fragment.ids, (id, i) => 2 * id + fragment.rev[i]!)\n}\n\nfunction nodeLength(nodes: Map<number, WalkNode>, id: number) {\n const node = nodes.get(id)\n return node === undefined ? 0 : node.end - node.start\n}\n\n/**\n * Aligns one walk fragment to another on the nodes both visit, from node\n * lengths alone: the fragments' steps as the handles gbz-base's chainer reads,\n * and a stand-in sequence of each node's length.\n */\nexport function walkAligner(nodes: Map<number, WalkNode>) {\n const standIn = new Map<number, string>()\n const sequenceOf = (id: number) => {\n const length = nodeLength(nodes, id)\n let sequence = standIn.get(length)\n if (sequence === undefined) {\n sequence = 'N'.repeat(length)\n standIn.set(length, sequence)\n }\n return sequence\n }\n const handles = new Map<WalkFragment, number[]>()\n const cachedHandles = (fragment: WalkFragment) => {\n let steps = handles.get(fragment)\n if (steps === undefined) {\n steps = handlesOf(fragment)\n handles.set(fragment, steps)\n }\n return steps\n }\n return (query: WalkFragment, target: WalkFragment) =>\n pairAlignments({\n query: cachedHandles(query),\n target: cachedHandles(target),\n sequenceOf,\n bases: false,\n })\n}\n\n// The fewest bases on shared nodes a record against the reference keeps,\n// gbz-base's floor for a pair record\nconst MIN_MATCH_BP = 100\n\nfunction appendEdit(edits: PairEdit[], op: PairEdit[0], len: number) {\n const last = edits.at(-1)\n if (len > 0) {\n if (last?.[0] === op) {\n last[1] += len\n } else {\n edits.push([op, len])\n }\n }\n}\n\n/**\n * Aligns a haplotype's walk fragment to the reference's as gbz-base aligns a\n * walk to its reference path: the heaviest common subsequence of their steps,\n * each node weighing its length, read in whichever direction shares more. A\n * pair chain leaves out every node either walk passes twice, which is the\n * whole of a collapsed copy-number array (amylase, KIV-2); the subsequence\n * matches one pass over it, and the other copies are insertions.\n */\nexport function referenceAligner(nodes: Map<number, WalkNode>) {\n const lengthOf = (handle: number) => nodeLength(nodes, handle >> 1)\n const offsets = (handles: number[]) => {\n const out = new Float64Array(handles.length + 1)\n handles.forEach((handle, i) => {\n out[i + 1] = out[i]! + lengthOf(handle)\n })\n return out\n }\n\n return (query: WalkFragment, target: WalkFragment): PairChain[] => {\n const ref = handlesOf(target)\n const hap = handlesOf(query)\n const [same, sameWeight] = weightedLcs(hap, ref, lengthOf)\n const [turned, turnedWeight] = weightedLcs(\n hap.map(handle => handle ^ 1).reverse(),\n ref,\n lengthOf,\n )\n const reverse = turnedWeight > sameWeight\n const pairs = reverse ? turned : same\n const sharedBases = Math.max(sameWeight, turnedWeight)\n if (sharedBases < MIN_MATCH_BP) {\n return []\n }\n const refAt = offsets(ref)\n const hapAt = offsets(hap)\n // a pair's haplotype step, counted along the haplotype\n const stepOf = (k: number) =>\n reverse ? hap.length - 1 - pairs[k]![0] : pairs[k]![0]\n const edits: PairEdit[] = []\n pairs.forEach(([, r], k) => {\n if (k > 0) {\n const [lo, hi] = [stepOf(k - 1), stepOf(k)].sort((x, y) => x - y)\n appendEdit(edits, 'I', hapAt[hi!]! - hapAt[lo! + 1]!)\n appendEdit(edits, 'D', refAt[r]! - refAt[pairs[k - 1]![1] + 1]!)\n }\n appendEdit(edits, '=', lengthOf(ref[r]!))\n })\n const [lo, hi] = [stepOf(0), stepOf(pairs.length - 1)].sort((x, y) => x - y)\n return [\n {\n queryStart: hapAt[lo!]!,\n queryEnd: hapAt[hi! + 1]!,\n targetStart: refAt[pairs[0]![1]]!,\n targetEnd: refAt[pairs.at(-1)![1] + 1]!,\n strand: reverse ? '-' : '+',\n edits,\n sharedBases,\n },\n ]\n }\n}\n\n// Each node a walk visits once, with the direction it passes it\nfunction singleVisits(fragment: WalkFragment) {\n const rev = new Map<number, number>()\n const twice = new Set<number>()\n fragment.ids.forEach((id, i) => {\n if (rev.has(id)) {\n twice.add(id)\n } else {\n rev.set(id, fragment.rev[i]!)\n }\n })\n for (const id of twice) {\n rev.delete(id)\n }\n return rev\n}\n\n// The bases on singly visited nodes two walks pass the same way and the\n// opposite way\nfunction directionShares(nodes: Map<number, WalkNode>) {\n const visits = new Map<WalkFragment, Map<number, number>>()\n const visitsOf = (fragment: WalkFragment) => {\n let found = visits.get(fragment)\n if (found === undefined) {\n found = singleVisits(fragment)\n visits.set(fragment, found)\n }\n return found\n }\n return (query: WalkFragment, target: WalkFragment) => {\n const theirs = visitsOf(target)\n let same = 0\n let opposite = 0\n for (const [id, rev] of visitsOf(query)) {\n const other = theirs.get(id)\n if (other === rev) {\n same += nodeLength(nodes, id)\n } else if (other !== undefined) {\n opposite += nodeLength(nodes, id)\n }\n }\n return { same, opposite }\n }\n}\n\n/**\n * Aligns one lane's walk fragment to another's. The weighted subsequence\n * (`referenceAligner`) is the fast route and matches through copy-number\n * arrays, but it reads one direction per pair, so an inversion between the\n * lanes comes out as an insertion beside a deletion. A pair sharing 100 bp\n * (MIN_MATCH_BP) or more of singly visited nodes in each direction goes to\n * pair chaining (`walkAligner`) instead, which answers the inverted stretch as\n * a reverse-strand record of its own. Chaining leaves out every node a walk\n * passes twice, so counting singly visited nodes misses no inversion it could\n * draw.\n */\nexport function lanePairAligner(nodes: Map<number, WalkNode>) {\n const subsequence = referenceAligner(nodes)\n const chained = walkAligner(nodes)\n const shares = directionShares(nodes)\n return (query: WalkFragment, target: WalkFragment) => {\n const { same, opposite } = shares(query, target)\n return same >= MIN_MATCH_BP && opposite >= MIN_MATCH_BP\n ? chained(query, target)\n : subsequence(query, target)\n }\n}\n\n// The multi-way display's SPLIT_AT_GAP_BP, under which a turned stretch names\n// no inversion there\nconst TURNED_MIN_BP = 10_000\n\n/**\n * Aligns a haplotype's walk fragment to the reference's as `referenceAligner`\n * does, then adds the stretches it reads the other way. A walk sharing\n * TURNED_MIN_BP or more of singly visited nodes in each direction is chained\n * too, and the chained records on the strand the subsequence did not take are\n * its turned stretches. The subsequence record stays, so a copy-number array,\n * which chaining leaves out, still matches one pass alike in every lane.\n */\nexport function anchorAligner(nodes: Map<number, WalkNode>) {\n const subsequence = referenceAligner(nodes)\n const chained = walkAligner(nodes)\n const shares = directionShares(nodes)\n return (query: WalkFragment, target: WalkFragment) => {\n const records = subsequence(query, target)\n const taken = records[0]?.strand\n const { same, opposite } = shares(query, target)\n return taken === undefined || Math.min(same, opposite) < TURNED_MIN_BP\n ? records\n : [\n ...records,\n ...chained(query, target).filter(chain => chain.strand !== taken),\n ]\n }\n}\n\n/**\n * One record of a walk aligned to another, with its short balanced bubbles as\n * mismatches\n */\nexport function chainFeature({\n chain,\n target,\n query,\n assemblyName,\n refName,\n mateAssemblyName,\n}: {\n chain: PairChain\n target: WalkFragment\n query: WalkFragment\n assemblyName: string\n refName: string\n mateAssemblyName: string\n}) {\n const edits = bubblesAsMismatches(chain.edits)\n return matchFeature({\n target: {\n name: target.name,\n assemblyName,\n refName,\n start: target.hapStart + chain.targetStart,\n end: target.hapStart + chain.targetEnd,\n },\n query: {\n name: query.name,\n assemblyName: mateAssemblyName,\n refName: panSNContig(query.name),\n start: query.hapStart + chain.queryStart,\n end: query.hapStart + chain.queryEnd,\n },\n strand: chain.strand,\n cigar: pairCigar(edits),\n matches: edits.reduce((sum, [op, n]) => sum + (op === '=' ? n : 0), 0),\n columns: edits.reduce((sum, [, n]) => sum + n, 0),\n })\n}\n\n/**\n * Whether a walk's fragment steps on the reference inside the window: on a\n * node of `refName` overlapping it\n */\nexport function stepsInWindow(\n fragment: WalkFragment,\n nodes: Map<number, WalkNode>,\n refName: string,\n window: { start: number; end: number },\n) {\n return Array.from(fragment.ids).some(id => {\n const node = nodes.get(id)\n return (\n node?.rank === 0 &&\n node.refName === refName &&\n node.start < window.end &&\n node.end > window.start\n )\n })\n}\n\n/** Whether the reference between a departure's ends covers the whole window */\nexport function departureSpans(\n { leavePos, rejoinPos }: WalkDeparture,\n window: { start: number; end: number },\n) {\n return (\n Math.min(leavePos, rejoinPos) <= window.start &&\n Math.max(leavePos, rejoinPos) >= window.end\n )\n}\n\n/**\n * A haplotype whose departure from the reference spans the whole window, as\n * the record a multi-way display lifts out as a deletion: `spansWindow`, the\n * reference between the departure's ends whole so its length heads the lane,\n * and the haplotype's own sequence between them as its mate, a point where\n * it has none. The record runs the way the walk rejoins the reference, and\n * carries no CIGAR and no identity, so no ramp or identity filter reads it\n * as an alignment.\n */\nexport function departureFeature({\n departure,\n refName,\n assemblyName,\n mateAssemblyName,\n}: {\n departure: WalkDeparture\n refName: string\n assemblyName: string\n mateAssemblyName: string\n}) {\n const { name, hapStart, ownBp, leavePos, rejoinPos, rejoinReversed } =\n departure\n const id = `${name}:${hapStart}:${leavePos}:departure`\n return new SyntenyFeature({\n uniqueId: id,\n assemblyName,\n refName,\n start: Math.min(leavePos, rejoinPos),\n end: Math.max(leavePos, rejoinPos),\n type: 'departure',\n strand: rejoinReversed ? -1 : 1,\n syntenyId: id,\n spansWindow: true,\n mate: {\n refName: panSNContig(name),\n start: hapStart,\n end: hapStart + ownBp,\n assemblyName: mateAssemblyName,\n },\n })\n}\n", "import {\n assemblyByPanSNPrefix,\n panSNContig,\n panSNHaplotype,\n panSNMatchesPrefix,\n panSNSample,\n resolvePanSNPrefix,\n} from '@jbrowse/bandage-core/pansn'\nimport { updateStatus } from '@jbrowse/core/util'\nimport { ObservableCreate } from '@jbrowse/core/util/rxjs'\nimport { getSamplesTsvSources } from '@jbrowse/core/util/samplesTsv'\nimport { walksKept } from '@jbrowse/graph-walks'\n\nimport {\n anchorAligner,\n chainFeature,\n departureFeature,\n departureSpans,\n lanePairAligner,\n stepsInWindow,\n} from './walkLanes.ts'\nimport { WalkIndex } from '../RgfaTabixAdapter/walkReader.ts'\nimport { locationIsSet } from '../locationName.ts'\nimport { PanSNRefNames, openWalkReader } from '../panSNTabix.ts'\nimport { ComparativeAdapterBase } from '../synteny/ComparativeAdapterBase.ts'\nimport {\n laneAssemblyName,\n lanePairsStatus,\n requestedPairs,\n} from '../synteny/lanePairs.ts'\nimport { laneZoomNotice } from '../synteny/laneZoomNotice.ts'\nimport { sheetColorOf } from '../synteny/sheetColors.ts'\n\nimport type { WalkTabixSyntenyAdapterConfig } from './configSchema.ts'\nimport type { SubgraphAdapterOptions } from '../GetSubgraph.ts'\nimport type { LaneFeatureOptions, LanePair } from '../synteny/lanePairs.ts'\nimport type { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter'\nimport type { Feature } from '@jbrowse/core/util'\nimport type { Region } from '@jbrowse/core/util/types'\n\nconst haplotypeOf = ({ name }: { name: string }) => panSNHaplotype(name) ?? name\n\nexport default class WalkTabixSyntenyAdapter extends ComparativeAdapterBase<WalkTabixSyntenyAdapterConfig> {\n private readonly walks: WalkIndex = new WalkIndex(openWalkReader(this), this)\n private readonly refNames: PanSNRefNames = new PanSNRefNames(\n this.walks.source,\n this,\n )\n\n private get anchor() {\n const anchor = this.getConf('assemblyNames')[0]\n if (anchor === undefined) {\n throw new Error(\n 'WalkTabixSyntenyAdapter needs assemblyNames: its first entry is the assembly the reference sample is loaded as',\n )\n }\n return anchor\n }\n\n /**\n * The haplotypes the walk file's header names, `sample#haplotype` in byte\n * order, or undefined when it names none\n */\n async getHaplotypeNames(opts: BaseOptions = {}) {\n return this.walks.haplotypeNames(opts)\n }\n\n /**\n * `lanes` is every haplotype the header names but the anchor's own,\n * declared up front so the display can offer the whole graph's haplotypes\n * before a fetch has placed any of them. A lane's `color`, and the anchor's\n * `anchorColor`, is its haplotype's in `samplesTsvLocation`, where it has one;\n * a sheet that fails to read leaves the lanes uncoloured rather than failing\n * them\n */\n async getHeader(opts: BaseOptions = {}) {\n const [{ haplotypes }, colorOf] = await Promise.all([\n this.walks.reader.header(opts),\n this.sheetColors(opts),\n ])\n const { anchor } = this\n const anchorPrefix = resolvePanSNPrefix(this, anchor)\n const asmByPrefix = assemblyByPanSNPrefix(this)\n const isAnchor = (prefix: string) =>\n prefix === anchorPrefix || panSNSample(prefix) === anchorPrefix\n const anchorColor = colorOf?.(haplotypes.find(isAnchor) ?? anchorPrefix)\n return {\n hasCoarseTier: false,\n anchorAssemblyName: anchor,\n ...(anchorColor === undefined ? {} : { anchorColor }),\n lanes: haplotypes\n .filter(prefix => !isAnchor(prefix))\n .map(prefix => {\n const color = colorOf?.(prefix)\n return {\n name: laneAssemblyName(asmByPrefix, prefix),\n label: prefix,\n group: panSNSample(prefix),\n ...(color === undefined ? {} : { color }),\n }\n }),\n }\n }\n\n private async sheetColors(opts: BaseOptions) {\n const location = this.getConf('samplesTsvLocation')\n return locationIsSet(location)\n ? getSamplesTsvSources({\n location,\n names: undefined,\n namesLabel: 'the walk file',\n pluginManager: this.pluginManager,\n opts,\n }).then(\n ({ sources }) => sheetColorOf(sources, assemblyByPanSNPrefix(this)),\n () => undefined,\n )\n : undefined\n }\n\n // A lane's contigs are named only in its walk rows, so only the anchor's\n // are listed\n async getRefNames(opts: BaseOptions = {}) {\n const { assemblyName } = opts\n return assemblyName === undefined || assemblyName === this.anchor\n ? this.refNames.assemblyRefNames({ ...opts, assemblyName: this.anchor })\n : []\n }\n\n /**\n * The graph display's cut of the window, as RgfaTabixAdapter cuts a\n * walk-indexed graph: the reference walk first, then the walks `haplotypes`\n * asks for, and the nodes and links they visit\n */\n async getSubgraph(region: Region, opts: SubgraphAdapterOptions = {}) {\n const refName = await this.refNames.resolveForCut(region, {\n signal: opts.signal,\n })\n return this.walks.subgraph(refName, region, opts)\n }\n\n // The window's walks for the haplotypes named and the reference, with\n // every departure from the reference over it and no link read; a window\n // past a budget fails as a zoom-in notice for lanes. Named lanes come back\n // in full where the walk file abridged them, so a lane draws the nodes its\n // haplotype walks rather than runs of steps not fetched.\n private async laneWalks(\n refName: string,\n region: Region,\n prefixes: string[] | undefined,\n opts: LaneFeatureOptions,\n status: string,\n ) {\n const keep = walksKept(prefixes, refName)\n return updateStatus(status, opts.statusCallback, () =>\n this.walks.reader\n .cut(refName, region, {\n ...this.walks.cutOptions(),\n signal: opts.signal,\n keep,\n expand: keep,\n links: 'none',\n })\n .catch((error: unknown) => {\n throw laneZoomNotice(error, region.end - region.start)\n }),\n )\n }\n\n /**\n * One record per stretch a haplotype's walk shares with the reference's,\n * on the reference with the haplotype as its mate. A haplotype with no step\n * on the reference inside the window whose departure spans it is one\n * `spansWindow` record of the departure's stretch, its mate the haplotype's\n * own sequence between the departure's ends, a point where it has none.\n */\n private async anchorFeatures(\n refName: string,\n region: Region,\n opts: LaneFeatureOptions,\n ) {\n const wanted = opts.haplotypes?.length\n ? opts.haplotypes.map(lane => resolvePanSNPrefix(this, lane))\n : undefined\n const target = resolvePanSNPrefix(this, opts.targetAssemblyName)\n const prefixes =\n target === undefined\n ? wanted\n : wanted === undefined ||\n wanted.some(\n prefix =>\n panSNMatchesPrefix(target, prefix) ||\n panSNMatchesPrefix(prefix, target),\n )\n ? [target]\n : []\n if (prefixes?.length === 0) {\n return []\n }\n const { start, end } = region\n const status = `Reading walks ${region.refName}:${start.toLocaleString()}-${end.toLocaleString()}`\n const { graph, fragments, departures } = await this.laneWalks(\n refName,\n region,\n prefixes,\n opts,\n status,\n )\n // lanes come back in the order the fetch names them, which is the order\n // the display stacks lanes of equal weight in\n const rank = ({ name }: { name: string }) =>\n prefixes === undefined\n ? 0\n : prefixes.findIndex(prefix => panSNMatchesPrefix(name, prefix))\n const align = anchorAligner(graph.nodes)\n const asmByPrefix = assemblyByPanSNPrefix(this)\n const laneOf = (walk: { name: string }) =>\n laneAssemblyName(asmByPrefix, haplotypeOf(walk))\n const references = fragments.filter(f => f.name === refName)\n const walked = fragments\n .filter(fragment => fragment.name !== refName && rank(fragment) >= 0)\n .map(query => ({\n rank: rank(query),\n features: references.flatMap(reference =>\n align(query, reference).map(chain =>\n chainFeature({\n chain,\n target: reference,\n query,\n assemblyName: region.assemblyName,\n refName: region.refName,\n mateAssemblyName: laneOf(query),\n }),\n ),\n ),\n }))\n // NA19036#1 skips the IGL locus on one contig and walks it on another\n const walking = new Set(\n fragments\n .filter(fragment =>\n stepsInWindow(fragment, graph.nodes, refName, region),\n )\n .map(haplotypeOf),\n )\n const spanning = departures\n .filter(\n departure =>\n rank(departure) >= 0 &&\n !walking.has(haplotypeOf(departure)) &&\n departureSpans(departure, region),\n )\n .sort((a, b) => a.name.localeCompare(b.name))\n .map(departure => ({\n rank: rank(departure),\n features: [\n departureFeature({\n departure,\n refName: region.refName,\n assemblyName: region.assemblyName,\n mateAssemblyName: laneOf(departure),\n }),\n ],\n }))\n return [...walked, ...spanning]\n .sort((a, b) => a.rank - b.rank)\n .flatMap(lane => lane.features)\n }\n\n /**\n * Each pair's two lanes read out of the anchor window, all pairs in one\n * read, and each walk of a pair's query lane aligned to each walk of its\n * target lane. A pair's records sit on its query lane's contigs, the lane\n * the display draws on top.\n */\n private async pairFeatures(\n refName: string,\n region: Region,\n pairs: LanePair[],\n opts: LaneFeatureOptions,\n ) {\n const sides = pairs.map(pair => ({\n pair,\n featurePrefix: resolvePanSNPrefix(this, pair.queryAssemblyName),\n matePrefix: resolvePanSNPrefix(this, pair.targetAssemblyName),\n }))\n const { graph, fragments } = await this.laneWalks(\n refName,\n region,\n sides.flatMap(side => [side.featurePrefix, side.matePrefix]),\n opts,\n lanePairsStatus(pairs),\n )\n const align = lanePairAligner(graph.nodes)\n const walksOf = (prefix: string) =>\n fragments.filter(f => panSNMatchesPrefix(f.name, prefix))\n return sides.flatMap(({ pair, featurePrefix, matePrefix }) =>\n walksOf(featurePrefix).flatMap(target =>\n walksOf(matePrefix).flatMap(query =>\n align(query, target).map(chain =>\n chainFeature({\n chain,\n target,\n query,\n assemblyName: pair.queryAssemblyName,\n refName: panSNContig(target.name),\n mateAssemblyName: pair.targetAssemblyName,\n }),\n ),\n ),\n ),\n )\n }\n\n // The files are filed under the reference alone, so a window on a\n // haplotype lane has no answer: a lane pair is read inside the anchor's\n getFeatures(region: Region, opts: LaneFeatureOptions = {}) {\n return ObservableCreate<Feature>(async observer => {\n const refName =\n region.assemblyName === this.anchor\n ? await this.refNames.resolveMapped(region, opts)\n : undefined\n if (refName !== undefined) {\n const pairs = requestedPairs(opts)\n const features =\n pairs.length > 0\n ? await this.pairFeatures(refName, region, pairs, opts)\n : await this.anchorFeatures(refName, region, opts)\n for (const feature of features) {\n observer.next(feature)\n }\n }\n observer.complete()\n }, opts.signal)\n }\n}\n"],
5
+ "mappings": "62BAgBA,IAAMA,GAAyB,GAOxB,SAASC,GAAoBC,EAAmB,CACrD,IAAMC,EAAkB,CAAC,EACzB,QAASC,EAAI,EAAGA,EAAIF,EAAM,OAAQE,IAAK,CACrC,GAAM,CAACC,EAAIC,CAAG,EAAIJ,EAAME,CAAC,EACnB,CAACG,EAAQC,CAAO,EAAIN,EAAME,EAAI,CAAC,GAAK,CAAC,EAEzCE,IAAQE,GACRF,GAAON,KACLK,IAAO,KAAOE,IAAW,KAASF,IAAO,KAAOE,IAAW,MAE7DJ,EAAI,KAAK,CAAC,IAAKG,CAAG,CAAC,EACnBF,KAEAD,EAAI,KAAK,CAACE,EAAIC,CAAG,CAAC,CAEtB,CACA,OAAOH,CACT,CAGA,SAASM,EAAUC,EAAwB,CACzC,OAAO,MAAM,KAAKA,EAAS,IAAK,CAACC,EAAIP,IAAM,EAAIO,EAAKD,EAAS,IAAIN,CAAC,CAAE,CACtE,CAEA,SAASQ,EAAWC,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EACA,aAAcc,EAAK,kBACnB,QAASO,EAAYrC,EAAO,IAAI,EAChC,iBAAkB8B,EAAK,kBACzB,CAAC,CACH,CACF,CACF,CACF,CACF,CAIA,YAAYzC,EAAgBnB,EAA2B,CAAC,EAAG,CACzD,OAAOoE,EAA0B,MAAMC,GAAY,CACjD,IAAMjD,EACJD,EAAO,eAAiB,KAAK,OACzB,MAAM,KAAK,SAAS,cAAcA,EAAQnB,CAAI,EAC9C,OACN,GAAIoB,IAAY,OAAW,CACzB,IAAMsC,EAAQY,EAAetE,CAAI,EAC3BuE,EACJb,EAAM,OAAS,EACX,MAAM,KAAK,aAAatC,EAASD,EAAQuC,EAAO1D,CAAI,EACpD,MAAM,KAAK,eAAeoB,EAASD,EAAQnB,CAAI,EACrD,QAAWwE,KAAWD,EACpBF,EAAS,KAAKG,CAAO,CAEzB,CACAH,EAAS,SAAS,CACpB,EAAGrE,EAAK,MAAM,CAChB,CACF",
6
6
  "names": ["BALANCED_BUBBLE_MAX_BP", "bubblesAsMismatches", "edits", "out", "i", "op", "len", "nextOp", "nextLen", "handlesOf", "fragment", "id", "nodeLength", "nodes", "node", "walkAligner", "standIn", "sequenceOf", "length", "sequence", "handles", "cachedHandles", "steps", "query", "target", "pairAlignments", "MIN_MATCH_BP", "appendEdit", "last", "referenceAligner", "lengthOf", "handle", "offsets", "ref", "hap", "same", "sameWeight", "weightedLcs", "turned", "turnedWeight", "reverse", "pairs", "sharedBases", "refAt", "hapAt", "stepOf", "k", "r", "lo", "hi", "x", "y", "singleVisits", "rev", "twice", "directionShares", "visits", "visitsOf", "found", "theirs", "opposite", "other", "lanePairAligner", "subsequence", "chained", "shares", "TURNED_MIN_BP", "anchorAligner", "records", "taken", "chain", "chainFeature", "assemblyName", "refName", "mateAssemblyName", "matchFeature", "panSNContig", "pairCigar", "sum", "n", "stepsInWindow", "window", "departureSpans", "leavePos", "rejoinPos", "departureFeature", "departure", "name", "hapStart", "ownBp", "rejoinReversed", "SyntenyFeature", "haplotypeOf", "name", "panSNHaplotype", "WalkTabixSyntenyAdapter", "ComparativeAdapterBase", "WalkIndex", "openWalkReader", "PanSNRefNames", "anchor", "opts", "haplotypes", "colorOf", "anchorPrefix", "resolvePanSNPrefix", "asmByPrefix", "assemblyByPanSNPrefix", "isAnchor", "prefix", "panSNSample", "anchorColor", "color", "laneAssemblyName", "location", "locationIsSet", "getSamplesTsvSources", "sources", "sheetColorOf", "assemblyName", "region", "refName", "prefixes", "status", "keep", "walksKept", "updateStatus", "error", "laneZoomNotice", "wanted", "lane", "target", "panSNMatchesPrefix", "start", "end", "graph", "fragments", "departures", "rank", "align", "anchorAligner", "laneOf", "walk", "references", "f", "walked", "fragment", "query", "reference", "chain", "chainFeature", "walking", "stepsInWindow", "spanning", "departure", "departureSpans", "a", "b", "departureFeature", "pairs", "sides", "pair", "side", "lanePairsStatus", "lanePairAligner", "walksOf", "featurePrefix", "matePrefix", "panSNContig", "ObservableCreate", "observer", "requestedPairs", "features", "feature"]
7
7
  }
@@ -0,0 +1,3 @@
1
+ import{a as Qn}from"./chunk-G6DZANDH.js";import{d as oo,i as ea,j as ta,l as Ht,m as Ft,n as Xt,o as oa,p as ra}from"./chunk-OP2PTYDR.js";import{$b as Wn,A as Yr,Ab as et,B as bo,Bb as An,Bc as Jn,C as yo,D as Ye,Db as Tn,E as Me,Ea as mn,Eb as En,F as nn,Fa as At,G as ye,Ga as ln,Gb as Fo,H as Ue,Hb as Gt,I as xo,Ia as un,Ib as It,Ic as na,Ja as hn,K as Ro,Kb as Gn,L as q,Lb as In,M as Q,Mb as Bn,Mc as aa,N as de,Nb as Cn,Ob as Ne,Pb as Bt,Pc as Do,Qb as ne,Ra as fn,Rb as Ct,Rc as ia,S as an,Sc as sa,T as me,Ta as gn,Tb as Ot,Tc as pa,Ua as Co,Ub as _t,Va as wn,W as Lt,Wb as On,X as sn,Y as Mt,Ya as Je,Yb as _n,Z as So,Zb as $n,_b as $t,ac as Hn,b as Fe,ba as vo,bb as bn,bc as Fn,bd as ca,ca as Nt,cb as yn,cc as Wt,db as Oo,ea as Lo,ec as Xn,fa as Mo,fb as kn,ga as D,ia as No,ic as Dn,jb as _o,jc as Vn,ka as Po,kb as xn,kc as jn,lb as Rn,mb as Sn,mc as tt,na as qe,oa as Ao,ob as vn,oc as zn,pa as To,pc as Yn,q as Hr,qa as Eo,qc as Kn,ra as Go,rb as Mn,rc as Un,sa as Io,sc as Xo,ta as Bo,tb as ke,tc as qn,u as go,ua as Ze,ub as Nn,v as Dr,va as Pt,vb as Et,w as wo,wa as pn,wb as Pn,wc as Zn,x as Vr,xb as Wo,y as jr,ya as cn,yb as Ho,z as zr,za as dn,zb as Qe}from"./chunk-TP6OXTXD.js";import{D as tn,F as St,Q as Ke,R as on,S as rn,T as vt,a as pe,b as ho,d as Kr,e as re,f as Ur,i as qr,n as Zr,o as Jr,p as Qr,q as en,z as ko}from"./chunk-JWIFJIPZ.js";import{G as Ve,H as je,R as yt,S as kt,T as Fr,V as Le,W as Xr,c as fo,ga as xt,ja as ze,ka as Rt,n as wt,r as Xe,s as bt,w as ve,x as ce,y as De}from"./chunk-4RZCYOCW.js";import{b as Tt,c as $o,e as Ln}from"./chunk-NTXLYTF6.js";import{b as co,c as We,d as mo,f as lo}from"./chunk-LRBNBP2K.js";import{i as _r,j as uo}from"./chunk-ZLQEXXMV.js";import{A as ie,B as ao,C as ge,D as io,E as so,F as $e,J as oe,P as Br,a as Tr,b as Er,d as Gr,da as Cr,e as J,f as Ce,ka as Or,la as He,m as Oe,u as ro,v as fe,w as H,x as _e,y as no}from"./chunk-RQSCKHNS.js";import{c as Wr,h as gt}from"./chunk-D3QZGLZ3.js";import{a as ft,b as $r}from"./chunk-TMM73K4C.js";import{e as Ar}from"./chunk-EGZZ3ADM.js";import{a as we,c as be,d as po,i as Ir}from"./chunk-H5PFNYKH.js";import{f as Nr,g as to,h as Pr,j as te}from"./chunk-5L276I7O.js";import{b as U}from"./chunk-DUU6T2I5.js";var xe=JBrowseExports["@mui/material/SvgIcon"],Si=e=>xe!=null&&e in Object(xe)?xe[e]:Object.assign(function(){throw new Error("This JBrowse does not provide '"+e+"' from '@mui/material/SvgIcon' to plugins: GraphGenomeView was built for a different JBrowse version, so update the plugin or JBrowse")},{jbrowseHostMissing:e}),z=Si("createSvgIcon"),qs=xe&&xe.__esModule?xe.default:xe;var vi=1,Li=.015;function Dt({graph:e,span:t,rowY:o,positions:r}){let n=t*Li,a={...e,edges:Or(e.edges)},i=Hr(a),s=new Map(a.nodes.map(d=>[d.id,d])),p=[];for(let d of i){let m=d.refSpan-d.pathLength;m>=vi&&p.push({nodeIds:d.nodeIds,bp:m});let h=Math.max(d.refSpan,n),f=d.pathLength>0?h/d.pathLength:0;d.nodeIds.forEach((u,g)=>{let b=s.get(u);if(b){let x=d.nodeOffsets[g],R=h/d.nodeIds.length,k=w=>d.start+w*f,y=o(b);r[u]=f?[{x:k(x),y},{x:k(x+b.length),y}]:[{x:d.start+g*R,y},{x:d.start+(g+1)*R,y}]}})}let c=pe(a),l=Object.keys(r);for(let d of l){let m=r[d].at(-1).x;for(let h of c.get(d)??[]){let f=s.get(h);if(f&&!(h in r)){let u=o(f);r[h]=[{x:m,y:u},{x:m+n,y:u}],l.push(h)}}}return p}function Mi(e,t){let o=new Map;for(let n of e.nodes)if(_e(n)){let a=we(n.stable.refName);o.set(a,(o.get(a)??0)+n.length)}let r=new Map(t.map((n,a)=>[n,a]));return[...o.keys()].sort((n,a)=>(r.get(n)??1/0)-(r.get(a)??1/0)||o.get(a)-o.get(n)||He(n,a))}function da(e,t,o=[]){let r=ie(e),n=Mi(e,o);if(r.length===0||n.length===0)return;let a=$e(r,t),i=new Map(n.map((m,h)=>[m,h+1])),s=ge(r),p=n.length+1,c=Dt({graph:e,span:a,rowY:m=>{let h=m.stable;return((h?i.get(we(h.refName)):void 0)??p)*J},positions:s}),d=[{label:we(r[0].stable.refName),y:0},...n.map(m=>({label:m,y:i.get(m)*J}))];return{nodePositions:s,rowLabels:d,sampleRows:n,referenceAxis:!0,pixelRows:!0,alleleDeletions:c}}function Ni(e){let t=new Set;for(let o of e.nodes)o.stable&&t.add(o.stable.rank);return new Map([...t].sort((o,r)=>o-r).map((o,r)=>[o,r]))}function ma(e,t){let o=ie(e);if(o.length===0)return;let r=$e(o,t),n=Ni(e),a=ge(o),i=Dt({graph:e,span:r,rowY:p=>(p.stable?n.get(p.stable.rank)??n.size:n.size)*J,positions:a}),s=[...n].map(([p,c])=>({label:p===0?"Reference (rank 0)":`Rank ${p}`,y:c*J}));return{nodePositions:a,rowLabels:s,referenceAxis:!0,pixelRows:!0,alleleDeletions:i}}var Pi=12,Vo=J;function la(e){return 10+8*Math.log2(1+e.length)}function le(e,t){return e<t?-1:e>t?1:0}function ha(e,t){return le(e.at,t.at)||le(e.side,t.side)||le(e.hops,t.hops)}var ua={at:1/0,side:0,hops:0};function jo(e){let t=new Map(e.nodes.map(r=>[r.id,r])),o=Ei(e);return e.nodes.map(r=>r.id).sort((r,n)=>ha(o.get(r)??ua,o.get(n)??ua)||le(t.get(r).name,t.get(n).name)||le(r,n))}function Ai(e,t){let o=new Set(e.nodes.map(l=>l.id)),r=new Map(t.map(l=>[l.id,l.stable.start])),n=new Map,a=new Map;t.forEach((l,d)=>{a.set(l.id,t[d-1]?.id),n.set(l.id,t[d+1]?.id)});let i=t[0]?.id,s=(l,d)=>{let m=n.get(l);n.set(l,d),a.set(d,l),n.set(d,m),m!==void 0&&a.set(m,d)},p=(l,d)=>{let m=a.get(l);m===void 0?(i=d,a.set(d,void 0),n.set(d,l),a.set(l,d)):s(m,d)};for(let l of e.paths??[]){let d=0,m=0,h;for(let b of l.nodeIds){let x=r.get(b);x!==void 0&&(h!==void 0&&x!==h&&(x>h?d++:m++),h=x)}let f=m>d?[...l.nodeIds].reverse():l.nodeIds,u,g=new Set;for(let b of f)if(n.has(b)){if(u===void 0)for(let x of g)p(b,x);u=b}else o.has(b)&&(u===void 0?g.add(b):(s(u,b),u=b))}let c=[];for(let l=i;l!==void 0;l=n.get(l))c.push(l);return c}function Ti(e,t,o){let r=[...t.entries()].sort(([s,p],[c,l])=>ha(p,l)||le(s,c)).map(([s])=>s),n=r.length;for(let s of r){let p=t.get(s);for(let c of e.get(s)??[])o.has(c)&&!t.has(c)&&(t.set(c,{at:p.at,side:1,hops:p.hops+1}),r.push(c))}let a=new Set(r.slice(n)),i=new Set;for(let s of a){if(i.has(s))continue;let{at:p}=t.get(s),c=[s];i.add(s);let l=!0;for(let d of c){let{hops:m}=t.get(d),h=!0,f=!1;for(let u of e.get(d)??[]){let g=t.get(u);g&&(g.at===p&&a.has(u)?(h&&=g.hops<=m,i.has(u)||(i.add(u),c.push(u))):g.at!==p&&(f||=g.at<p,l&&=g.at<p))}l&&=!h||f}if(l)for(let d of c){let m=t.get(d);t.set(d,{...m,side:-1,hops:-m.hops})}}}function Ei(e){let t=e.nodes.filter(H).sort((r,n)=>le(r.stable.start,n.stable.start)||le(r.name,n.name)),o=new Map;return Ai(e,t).forEach((r,n)=>{o.set(r,{at:n,side:0,hops:0})}),Ti(pe(e),o,new Set(e.nodes.map(r=>r.id))),o}function Gi(e){let t=new Map(e.nodes.map(d=>[d.id,d])),o=jo(e),r=new Map(o.map((d,m)=>[d,m])),n=d=>H(t.get(d)),a=new Map(o.map(d=>[d,[]])),i=new Map(o.map(d=>[d,[]])),s=(d,m)=>{a.get(m).push(d),i.get(d).push(m)};for(let d of e.edges)d.from===d.to||!r.has(d.from)||!r.has(d.to)||(r.get(d.from)<r.get(d.to)?s(d.from,d.to):s(d.to,d.from));let p=o.filter(n);for(let d=1;d<p.length;d++)s(p[d-1],p[d]);let c=new Map;for(let d of o){let m=0;for(let h of a.get(d))m=Math.max(m,c.get(h)+1);c.set(d,m)}for(let d=o.length-1;d>=0;d--){let m=o[d],h=i.get(m);if(n(m)||h.length===0)continue;let f=1/0;for(let b of h)f=Math.min(f,c.get(b));let u=c.get(m),g=Math.max(u,f-1);c.set(m,Math.floor((u+g)/2))}let l=[];for(let d of o)(l[c.get(d)]??=[]).push(d);return{layers:l,layerOf:c,preds:a}}function fa(e){if(!e.nodes.some(H))return;let t=new Map(e.nodes.map(d=>[d.id,d])),o=d=>H(t.get(d)),{layers:r,layerOf:n,preds:a}=Gi(e),i=r.map(d=>{let m=0;for(let h of d)m=Math.max(m,la(t.get(h)));return m}),s=[],p=0;for(let d=0;d<r.length;d++)s[d]=p,p+=i[d]+Pi;let c=new Map;for(let d of r){let m=[];for(let f of d){if(o(f)){c.set(f,0);continue}let u=a.get(f).filter(b=>c.has(b)),g=0;for(let b of u)g+=c.get(b)/u.length;m.push({id:f,ideal:g===0?Vo:g})}m.sort((f,u)=>f.ideal-u.ideal);let h=new Set([0]);for(let{id:f,ideal:u}of m){let g=Math.round(u/Vo);g===0&&(g=u>=0?1:-1);for(let b=1;h.has(g);b++)h.has(g+b)?h.has(g-b)||(g-=b):g+=b;h.add(g),c.set(f,g*Vo)}}let l={};for(let d of e.nodes){let m=n.get(d.id),h=la(d),f=s[m]+i[m]/2,u=c.get(d.id);l[d.id]=[{x:f-h/2,y:u},{x:f+h/2,y:u}]}return{nodePositions:l,referenceAxis:!1,pixelRows:!0}}var Vt=1.3;function jt(e){return e.rows.reduce((t,o)=>Math.max(t,me(o)),me(e.reference))}function Pe(e,t={rowPx:J,readouts:!0}){return{maxX:e.origin+jt(e)*(t.readouts?Vt:1),maxY:e.rows.length*t.rowPx}}function Ae(e,t,o){return e?o&&!o.labelled?[]:[e.reference,...e.rows].map((r,n)=>({label:r.label,y:n*(o?.rowPx??J)})):t?.rowLabels??[]}function zo(e,t){let o=Me(e,t);return o&&ga(e,o,t)}function ga(e,t,o){let r=ie(e);if(r.length===0)return;let n=o?r.filter(i=>ao(i,o)):r;return{nodePositions:ge(n.length>0?n:r),rowLabels:Ae(t),referenceAxis:!0,pixelRows:!0,extent:Pe(t)}}var ya="Force-directed layout",Te=e=>e.nodes.some(H),wa=e=>Te(e)&&(e.paths?.length??0)>1,ba=e=>Te(e)&&e.nodes.some(_e),zt=[{value:"auto",label:"Anchored",description:"x is reference bp, one row per stable rank. Needs rGFA tags or a reference path.",run:(e,t)=>ma(e,t),cutMargins:!0,wholeWalks:!1,available:Te,drawsLocally:Te,drawsNodes:!0},{value:"samplerows",label:"Sample rows",description:"x is reference bp, one row per contributing assembly. Needs rGFA tags or a reference path.",run:(e,t,o)=>da(e,t,o),cutMargins:!0,wholeWalks:!1,available:ba,drawsLocally:ba,drawsNodes:!0},{value:"walkrows",label:"Walk rows",description:"x is each walk's own bp: one bar per haplotype, blue on the reference's path and purple off it, so a repeat expansion reads as bar length, and each bar boxes its haplotype's own genes where the session has them. Needs a reference and two or more walks.",run:zo,cutMargins:!1,wholeWalks:!0,available:wa,drawsLocally:wa,drawsNodes:!1},{value:"ordered",label:"Ordered",description:"x is reference order, not bp: every node gets room, bubbles read as lenses. Needs rGFA tags or a reference path.",run:e=>fa(e),cutMargins:!1,wholeWalks:!1,available:Te,drawsLocally:Te,drawsNodes:!0},{value:"tubemap",label:"Tube map",description:"sequenceTubeMap: every path a coloured tube through boxed nodes, columns in node order and node widths log-scaled. Needs P or W lines.",run:Dr,cutMargins:!1,wholeWalks:!1,available:go,drawsLocally:go,drawsNodes:!1},{value:"tubemapref",label:"Tube map on reference",description:"The tube map with each column at the reference bp it covers, so the tubes line up with the tracks around them. Needs P or W lines and a reference path.",run:Vr,cutMargins:!0,wholeWalks:!1,available:wo,drawsLocally:wo,drawsNodes:!1},{value:"force",label:ya,description:"OGDF FMMM (wasm) or stress, whichever engine is chosen.",run:()=>{},cutMargins:!1,wholeWalks:!1,available:()=>!0,drawsLocally:()=>!1,drawsNodes:!0}],Ii=zt.map(e=>e.value);function Yo(e,t){return!Y(e).drawsLocally(t)}function Y(e){return zt.find(t=>t.value===e)??zt[0]}function ka(e){if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.horizontalScroll=="function"&&typeof t.zoomTo=="function"&&"coarseDynamicBlocks"in t&&"dynamicBlocks"in t}function Ko(e){return e.reduce((t,o)=>t&&t.end-t.start>=o.end-o.start?t:o,void 0)}function xa(e,t){let o=Ko(e.dynamicBlocks.contentBlocks.filter(a=>a.refName===t.refName&&a.assemblyName===t.assemblyName)),{bpPerPx:r}=e;if(!o||!(r>0))return;let n=o.offsetPx-e.offsetPx;return o.reversed?{scale:-1/r,translateX:n+o.end/r}:{scale:1/r,translateX:n-o.start/r}}function Uo(e){let t=Ko(e.dynamicBlocks.contentBlocks),o=t?.displayedRegionIndex===void 0?void 0:e.displayedRegions[t.displayedRegionIndex];return t&&e.bpPerPx>0?{refName:t.refName,assemblyName:t.assemblyName,start:t.start,end:t.end,bpPerPx:e.bpPerPx,span:e.bpPerPx*e.width,regionStart:o?.start??t.start,regionEnd:o?.end??t.end}:void 0}function Ra(e){let t=Ko(e.dynamicBlocks.contentBlocks),o=t&&t.start-(t.offsetPx-e.offsetPx)*e.bpPerPx;return o===void 0?void 0:{start:o,end:o+e.bpPerPx*e.width}}function Bi(e,t,o=!0){let r=e.end-e.start,n=o?Math.max(0,Math.min(e.span,(t-r)/2)):0,a=Math.max(e.regionStart,Math.floor(e.start-n)),i=Math.min(e.regionEnd,Math.ceil(e.end+n)),s=i-a-t;return s>0&&(a+=Math.floor(s/2),i-=Math.ceil(s/2)),{refName:e.refName,assemblyName:e.assemblyName,start:a,end:i}}function Sa(e){return e==="force"?"snapped":Y(e).cutMargins?"margins":"window"}function Ci(e){return 2**(Math.ceil(Math.log2(e)*2-1e-9)/2)}function Oc(e){let t=Ci(e.span),o=Math.round((e.start+e.end)/t)*(t/2);return{refName:e.refName,assemblyName:e.assemblyName,start:Math.max(e.regionStart,Math.round(o-.75*t)),end:Math.min(e.regionEnd,Math.round(o+.75*t))}}function _c(e,t){return e?.refName===t.refName&&e.assemblyName===t.assemblyName&&e.start===t.start&&e.end===t.end}function $c(e,t,o=!0){if(e?.refName!==t.refName||e.assemblyName!==t.assemblyName)return!1;if(o)return e.start<=t.start+1&&t.end<=e.end+1;let r=Bi(t,1/0,!1);return Math.abs(e.start-r.start)<1&&Math.abs(e.end-r.end)<1}function V(e){return typeof e=="object"&&e!==null}function va(e){return Array.isArray(e)}var Oi=/^[^#]+#\d+$/,_i=/^([^#]+)\.(\d+)$/;function $i({aliases:e}){return e.find(t=>Oi.test(t))}function Wi({name:e}){let t=_i.exec(e);return t?`${t[1]}#${t[2]}`:void 0}function Hi(e,t,o){let r=e.assemblyNameToPanSN??{},n=new Set(Object.values(r)),a={},i=t.filter(s=>s.name!==o);for(let[s,p]of[[$i,t],[Wi,i]])for(let c of p){let l=s(c);l!==void 0&&!n.has(l)&&!(c.name in r)&&!(c.name in a)&&(a[c.name]=l,n.add(l))}return Object.keys(a).length===0?e:{...e,assemblyNameToPanSN:{...a,...r}}}function La(e,t){return e.find(o=>o.name===t||o.aliases.includes(t))?.name??t}function Fi(e,t){let o=i=>La(t,i),r=e.assemblyNames??[],n=e.assemblyNameToPanSN??{};if([...r,...Object.keys(n)].every(i=>o(i)===i))return e;let a=new Map;for(let[i,s]of Object.entries(n)){let p=o(i);(p===i||!a.has(p))&&a.set(p,s)}for(let i of r){let s=o(i);s!==i&&!a.has(s)&&a.set(s,i)}return{...e,assemblyNames:r.map(o),assemblyNameToPanSN:Object.fromEntries(a)}}var Xi=new Set(["GbzBaseSyntenyAdapter","WalkTabixSyntenyAdapter"]);function Ma(e,t){let o=gt(t);if(!Xi.has(o.type)&&!Wr(o))return o;let r=te(e).assemblyManager.assemblyList.map(a=>({name:oo(a,"name"),aliases:oo(a,"aliases")})),[n]=ft(t);return Hi(Fi(o,r),r,n===void 0?void 0:La(r,n))}var Kc=z(U("path",{d:"M19 15.18V7c0-2.21-1.79-4-4-4s-4 1.79-4 4v10c0 1.1-.9 2-2 2s-2-.9-2-2V8.82C8.16 8.4 9 7.3 9 6c0-1.66-1.34-3-3-3S3 4.34 3 6c0 1.3.84 2.4 2 2.82V17c0 2.21 1.79 4 4 4s4-1.79 4-4V7c0-1.1.9-2 2-2s2 .9 2 2v8.18c-1.16.41-2 1.51-2 2.82 0 1.66 1.34 3 3 3s3-1.34 3-3c0-1.3-.84-2.4-2-2.82"}),"Route");var Jc=z(U("path",{d:"M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6"}),"Settings");function ue(e){return`${e.refName}:${(e.start+1).toLocaleString()}-${e.end.toLocaleString()}`}function Di(e,t,o=r=>r){return t?{deletion:{bp:`${t.bp.toLocaleString()} bp`,where:ue(t)}}:{ends:`${o(e.from)}${e.fromStrand??""} \u2192 ${o(e.to)}${e.toStrand??""}`}}function Vi(e){let t=e.stable?.refName??e.name;return e.placeholder?`${Le(e.length)} of ${be(t)??t}'s route, ${Cr}`:void 0}function qo(e){return fe(e)?Zo(e):void 0}function Zo(e){return{sample:we(e.stable.refName),haplotype:be(e.stable.refName),refName:po(e.stable.refName),start:e.stable.start,end:e.stable.start+e.length}}function Na(e,t,o,r){let n=new Map,a=s=>{let p=Re(o,s),c=`${p} ${s.refName} ${s.start}`;p!==void 0&&p!==r&&n.set(c,{assemblyName:p,refName:s.refName,start:s.start,end:s.end})},i=qo(t);i&&a(i);for(let s of e.pathVisits?.get(t.name)??[])a({sample:we(s.path),haplotype:be(s.path),refName:po(s.path),start:s.start,end:s.start+t.length});return[...n.values()]}function Pa(e,t,o){let r=new Map,n=new Set((e.paths??[]).flatMap(i=>be(i.name)??[])),a=new Set;for(let i of e.nodes){if(!fe(i)||i.stable.rank===0)continue;let s=i.stable.refName;if(a.has(s))continue;if(n.size>0&&!n.has(be(s)??"")){a.add(s);continue}let p=Zo(i),c=r.get(s);if(c){c.start=Math.min(c.start,p.start),c.end=Math.max(c.end,p.end);continue}let l=Re(t,p);l===void 0||l===o?a.add(s):r.set(s,{stableRefName:s,assemblyName:l,refName:p.refName,start:p.start,end:p.end})}return[...r.values()]}function ji(e,t){let o=[...e].sort((a,i)=>a.start-i.start),r,n;for(let a of o)n=n&&a.start-n.end<=t?{start:n.start,end:Math.max(n.end,a.end)}:{start:a.start,end:a.end},(!r||n.end-n.start>r.end-r.start)&&(r=n);return r}function zi(e){return`${e.haplotype??e.sample}\0${e.refName}`}function Aa(e,{maxGap:t=1/0}={}){let o=new Map;for(let n of e.nodes)if(fe(n)){let a=Zo(n),i=zi(a),s=o.get(i);s?(s.spans.push({start:a.start,end:a.end}),s.rank=Math.min(s.rank,n.stable.rank)):o.set(i,{sample:a.sample,haplotype:a.haplotype,refName:a.refName,rank:n.stable.rank,spans:[{start:a.start,end:a.end}]})}let r=new Map;for(let n of o.values()){let a=ji(n.spans,t);if(a){let i={sample:n.sample,haplotype:n.haplotype,refName:n.refName,start:a.start,end:a.end,rank:n.rank,nodeCount:n.spans.length},s=n.haplotype??n.sample,p=r.get(s);(!p||i.nodeCount>p.nodeCount)&&r.set(s,i)}}return[...r.values()].sort((n,a)=>+(n.rank!==0)-+(a.rank!==0)||n.sample.localeCompare(a.sample)||(n.haplotype??"").localeCompare(a.haplotype??""))}function Re(e,t){return(t.haplotype===void 0?void 0:e(t.haplotype))??e(t.sample)}function Ta(e,t){let o=new Map,r=n=>`${n.sample} ${n.refName}`;for(let n of e)n.haplotype!==void 0&&o.set(r(n),(o.get(r(n))??0)+1);return e.flatMap(n=>{let a=(o.get(r(n))??0)>1?t(n.haplotype):Re(t,n);return a===void 0?[]:[{...n,sample:a}]})}function Yt(e){return`${e.refName}:${e.start+1}-${e.end}`}function Yi(e){return V(e)&&e.type==="LinearGenomeView"&&typeof e.id=="string"&&typeof e.navToLocString=="function"&&Array.isArray(e.assemblyNames)}function Ea(e){return e.flatMap(t=>V(t)&&va(t.views)?[t,...t.views]:[t])}function Hd(e){return new Set(Ea(e).flatMap(t=>V(t)&&typeof t.id=="string"?[t.id]:[]))}function Ee({views:e,connectedViewId:t,assemblyName:o}){let r=Ea(e).filter(a=>Yi(a)).filter(a=>a.assemblyNames.includes(o));return r.find(a=>a.id===t)??(r.length===1?r[0]:void 0)}function Jo(e,t){let o=e.assemblyManager;return o?.has(t)?o.get(t)?.name??t:t}function zd(e,t){let o=e.assemblyManager,r=o?.has(t.assemblyName)?o.get(t.assemblyName):void 0;return r?{...t,assemblyName:r.name,refName:r.getCanonicalRefName2?.(t.refName)??t.refName}:t}function Qo(e,t){return ft(t).map(o=>Jo(e,o))}function er(e,t,o){o.catch(r=>{console.error(`[GraphGenomeView] ${t}`,r),e.notifyError?.(`${t}: ${r}`,r)})}var Ki=1e3;function tr(e,t=Ki){let o=Math.max(0,Math.ceil((t-(e.end-e.start))/2));return{...e,start:Math.max(0,e.start-o),end:e.end+o}}function Ia(e,t){return t?e.map(o=>o.rank===0?{...o,sample:t.assemblyName,haplotype:void 0,refName:t.refName,start:t.start,end:t.end}:o):e}function Yd({session:e,location:t,assembly:o,connectedViewId:r,tracks:n=[]}){let a=Ee({views:e.views,connectedViewId:r,assemblyName:o}),i;return a?(er(e,`Could not show ${o} ${ue(t)}`,Promise.resolve(a.navToLocString(Yt(t),o))),i=a.id):i=e.addView("LinearGenomeView",{displayName:`${o} \u2014 ${ue(t)}`,init:{assembly:o,loc:Yt(t),tracks:n}}).id,i}function Kd({session:e,trackId:t,assembly:o,loc:r}){let n=Ee({views:e.views,connectedViewId:void 0,assemblyName:o});n?.showTrack?(er(e,`Could not show ${o} ${r}`,Promise.resolve(n.navToLocString(r,o))),n.showTrack(t)):e.addView("LinearGenomeView",{init:{assembly:o,loc:r,tracks:[t]}})}function Ud({session:e,location:t,assembly:o,connectedViewId:r}){Ee({views:e.views,connectedViewId:r,assemblyName:o})&&e.addHighlight?.({refName:t.refName,start:t.start,end:t.end,assemblyName:o})}function Ga(e,t){let o=t===void 0?void 0:e.tracks.find(r=>r.trackId===t);return o?Qo(e,o):[]}function qd({session:e,contributors:t,trackId:o,graphTrackId:r}){let n=Ga(e,r),a=Ga(e,o),i=t.filter(c=>a.includes(c.sample)),s=i.length>=2?i:t,p={init:{views:s.map(c=>({assembly:c.sample,loc:Yt(c),...r!==void 0&&n.includes(c.sample)?{tracks:[r]}:{}})),tracks:o?s.slice(1).map(()=>[o]):[],collapseEmptyRows:!0}};er(e,"Could not open the synteny view",e.launchView("LinearSyntenyView",p))}function or(e){return e.walkStrip&&e.mode.drawsNodes&&!e.drawsPicture&&!e.popped&&!e.host&&e.walks>1}function rr(e,t){return e.wholeWalks||t.walkStrip&&!t.host}var ot=6,Oa=260,Ui=11,qi=3,Zi="#111",Ba=3;function nr(e,t,o){let r=e.pathVisits?.get(o.name)??[],n=[];for(let a of t){let i=a.axis;if(!i)continue;let s=oe(a.name).name;for(let p of r){if(p.path!==s)continue;let{start:c,end:l}=bo(i,p.start,p.start+o.length);l>0&&c<a.bp&&n.push({row:a.name,start:c,bp:l-c})}}return n}var Ca=new WeakMap;function Ji(e,t){let o=Ca.get(e);if(o||(o=new Map,Ca.set(e,o)),o.has(t))return o.get(t);let r=new Map(e.nodes.map(s=>[s.id,s.length])),n=oe(t).name,a=(e.paths??[]).filter(s=>oe(s.name).name===n),i;if(a.every(s=>s.start!==void 0)){i={ids:[],starts:[],ends:[]};for(let s of[...a].sort((p,c)=>p.start-c.start)){let p=s.start;for(let c of s.nodeIds){let l=r.get(c)??0;i.ids.push(c),i.starts.push(p),i.ends.push(p+l),p+=l}}}return o.set(t,i),i}function Qi(e,t,o,r){let n=t.axis,a=n&&Ji(e,t.name);if(!n||!a||o<0||o>t.bp)return;let i=n.reversed?n.start-o:n.start+o,s=.5/r,p=Lt(n,t.bp),c=Math.max(i-s,p.start),l=Math.min(i+s,p.end),d=Gr(a.starts.length,u=>a.ends[u]<=c),m,h=-1,f=!1;for(let u=d;u<a.starts.length&&a.starts[u]<l;u++){let g=a.ends[u]-a.starts[u],b=a.starts[u]<=i&&i<a.ends[u];(g>h||g===h&&b&&!f)&&(h=g,m=a.ids[u],f=b)}return m}function rt(e,t){let o=t.maxHeight??Oa,r=t.labelPx??e.rows.reduce((h,f)=>Math.max(h,f.label.length),e.reference.label.length)*ce+16,n=e.rows.length+1,{rowPx:a,barPx:i,labelled:s,readouts:p}=Nt(n,o-2*ot,qi),c=Math.max(jt(e),1),l=s?r:ot,m=Math.max(1,t.width-l-ot)/(c*(p?Vt:1));return{scaleX:m,scaleY:1,translateX:l-e.origin*m,translateY:ot+a/2,width:t.width,height:n*a+2*ot,rowPx:a,barPx:i,readouts:p,labelled:s,boxesGenes:Mt(a,i)}}function es(e,t,o,r){let n=Math.round((r-t.translateY)/t.rowPx),a=[e.reference,...e.rows][n],i=(o-t.translateX)/t.scaleX-e.origin;return a&&n>=0&&i>=0&&i<=me(a)?{index:n,row:a,offset:i}:void 0}function ts(e,t,o){let r=new Map([e.reference,...e.rows].map((a,i)=>[a.name,i])),n=a=>(e.origin+a)*t.scaleX+t.translateX;return Ro("g",{"data-testid":"graph-walk-marks"},o.flatMap(a=>{let i=r.get(a.row);if(i===void 0)return[];let s=i*t.rowPx+t.translateY,p=n(a.start),c=Math.max(2,a.bp*t.scaleX),l=d=>q("rect",{x:p,y:d,width:c,height:Ba,fill:Zi});return[l(s-t.barPx/2-Ba-1),l(s+t.barPx/2+1)]}))}function ar(e,t,o=new Set){return Ro("g",{"font-family":"sans-serif","font-size":Ui,fill:"#333"},(t.labelled?[e.reference,...e.rows]:[]).map((r,n)=>q("text",{x:6,y:n*t.rowPx+t.translateY+4,"font-weight":o.has(r.name)?600:void 0},r.label)))}function ir(e,t,o){if(t?.size)return e.boxesGenes?o:{untracked:0,unread:0,...o,crowded:!0}}function at(e,t){let o=t?[t.reference,...t.rows]:[];return(e?.walks??[]).flatMap(r=>{let n=r.walkPasses,a=ye([r])[0];return n?.passes.length&&!o.some(i=>Ue(r.name,i)&&!!a&&xo(a,i))?[{walk:r.name,bp:r.range?r.range.end-r.range.start:r.bp,ownInk:n.ownInk,runs:n.runs.map(i=>({...i,ink:nn(n,i.pass)})),passes:n.passes.map((i,s)=>({pass:s,start:i.start,end:i.end,repeatBp:i.repeatBp,againBp:i.againBp,reversedBp:i.reversedBp,text:n.bundled?`${s+1}`:i.title,ink:i.ink,reversed:i.reversed})),bundled:n.bundled}]:[]})}var sr={"font-family":"Helvetica, Arial, sans-serif","font-size":11},os=6.2,Kt=12,rs=13,nt=34,Ge=40,Ie=16,_a=4,Ut=Ge+Ie+26,ns=(e,t)=>{let o=e/t,r=10**Math.floor(Math.log10(o));return[1,2,5,10].map(n=>n*r).find(n=>n>=o)??o};function pr(e,t,o){let r=o-2*Kt,n=u=>Kt+(e.bp>0?u/e.bp*r:0),a=r>0?e.bp/r:1,i=[];for(let u of e.runs){let g=i.at(-1);g?.pass===u.pass&&u.start-g.end<a?g.end=u.end:i.push({...u})}let s=e.bp>0?ns(e.bp,8):1,p=Array.from({length:e.bp>0?Math.floor(e.bp/s)+1:0},(u,g)=>g*s),c=q("text",{x:Kt,y:rs,...sr,"font-weight":"bold"},`${t} along its length`),l=[],d=e.passes.flatMap(u=>{let g=[];for(let L of e.runs){let B=g.at(-1);L.pass===u.pass&&B&&L.start-B.end<a?B.end=L.end:L.pass===u.pass&&g.push({start:L.start,end:L.end})}let b=re(u.ink),x=g.map(L=>q("path",{d:`M${n(L.start)},${nt+3}V${nt}H${n(L.end)}V${nt+3}`,fill:"none",stroke:b,"stroke-width":1.5})),R=g.slice(1).map((L,B)=>`M${n(g[B]?.end??L.start)},${nt}H${n(L.start)}`).join(""),k=g.reduce((L,B)=>!L||B.end-B.start>L.end-L.start?B:L,void 0),y=u.text.length*os/2+2,w=k&&Math.min(Math.max((n(k.start)+n(k.end))/2,y),o-y),S=w!==void 0&&l.every(L=>w+y<=L.from||w-y>=L.to);S&&l.push({from:w-y,to:w+y});let M=S&&q("text",{x:w,y:nt-3,...sr,"font-weight":"bold",fill:b,"text-anchor":"middle"},u.text),I=q("path",{d:R,fill:"none",stroke:b,"stroke-width":.75,"stroke-dasharray":"1 2"});return(R?[I]:[]).concat(x,M?[M]:[])}),m=q("rect",{x:Kt,y:Ge,width:r,height:Ie,fill:re(e.ownInk)}),h=i.map(u=>q("rect",{x:n(u.start),y:Ge,width:Math.max(.5,n(u.end)-n(u.start)),height:Ie,fill:re(u.ink)})),f=p.flatMap(u=>[q("line",{x1:n(u),x2:n(u),y1:Ge+Ie,y2:Ge+Ie+_a,stroke:"#666"}),q("text",{x:n(u),y:Ge+Ie+_a+11,...sr,fill:"#444","text-anchor":"middle"},u===0?"0":Le(u))]);return{tag:"g",attrs:{},children:[c].concat(d,[m],h,f)}}var $a=new WeakMap;function as(e){let t=$a.get(e);return t||(t={byRefName:is(e),stretches:ss(e),walks:new Map},$a.set(e,t)),t}var Wa=e=>`${e.refName} ${e.start} ${e.end}`;function is(e){let t=new Map;for(let o of e.nodes)if(fe(o)){let{refName:r}=o.stable,n=t.get(r)??t.set(r,{nodes:[],reach:0,reference:!1}).get(r);n.reference||=o.stable.rank===ro,n.nodes.push(o),n.reach=Math.max(n.reach,o.length)}for(let{nodes:o}of t.values())o.sort((r,n)=>r.stable.start-n.stable.start);return t}function ss(e){let t=new Map(e.nodes.map(n=>[n.id,n.length])),o=new Map;for(let n of e.paths??[]){let a=oe(n.name),i=n.start??a.start,s=n.nodeIds.reduce((c,l)=>c+(t.get(l)??0),i),p=o.get(a.name);p?p.push({start:i,end:s}):o.set(a.name,[{start:i,end:s}])}let r=new Map;for(let[n,a]of o){let i=[];for(let{start:s,end:p}of a.sort((c,l)=>c.start-l.start)){let c=i.at(-1);c&&s<=c.end?c.end=Math.max(c.end,p):i.push({start:s,end:p})}r.set(n,i)}return r}function ps(e,{start:t,end:o}){return e.reduce((r,n)=>r+Math.max(0,Math.min(o,n.end)-Math.max(t,n.start)),0)}function cs(e,t){let o=new Map(t.map(n=>[n,new Set])),r=new Map;for(let[n,a]of o)for(let i of n){let s=r.get(i);s?s.push(a):r.set(i,[a])}for(let n of e.paths??[]){let a=oe(n.name).name;for(let i of n.nodeIds)for(let s of r.get(i)??[])s.add(a)}return new Map([...o].map(([n,a])=>[n,a.size]))}function cr(e,t,o,r){let n=e.length?t/e.length:0,a=e.length?o/e.length:0;return r&&!no(e)?[1-a,1-n]:[n,a]}function it(e,t,o,r=!1){let n=as(e),a=new Map,i=[];for(let s of t){let p=n.byRefName.get(s.refName);if(!p)continue;let c=[],l=[],d=new Set,m=[],h,f=1/0,u=0,g=Wa(s),b=n.walks.has(g)?void 0:new Set,x=(s.start+s.end)/2,{nodes:R,reach:k,reference:y}=p;for(let w=io(R,s.start-k);w<R.length&&R[w].stable.start<s.end;w++){let S=R[w],M=S.stable.start,I=M+S.length;if(I<=s.start)continue;b?.add(S.id);let L=o[S.id];if(!L?.length)continue;d.add(S.id);let B=cr(S,Math.max(M,s.start)-M,Math.min(I,s.end)-M,r);m.push({nodeId:S.id,from:B[0],to:B[1]}),u+=Math.min(I,s.end)-Math.max(M,s.start);let se=[],Be=[];for(let $ of s.exons){let lt=Math.max($.start,M),ut=Math.min($.end,I);if(ut<=lt)continue;let[v,N]=cr(S,lt-M,ut-M,r),A=fo(L,v,N);A.length===1&&A.push({...A[0]}),se.push(Ce(A)),Be.push(A)}if(se.length>0){for(let $ of se)c.push($);l.push({nodeId:S.id,d:se.join(""),stretches:Be})}let Z=Math.min(Math.max(x,M),I),X=Math.abs(Z-x);if(X<f){f=X;let[$]=cr(S,Z-M,Z-M,r);h=fo(L,$,$)[0]}}h&&(b&&a.set(g,b),i.push({gene:s,exons:c.join(""),exonsByNode:l,nodeIds:d,body:m,at:h,covered:u/(s.end-s.start),onReference:y}))}if(a.size>0){let s=cs(e,[...a.values()]);for(let[p,c]of a)n.walks.set(p,s.get(c)??0)}return i.map(s=>{let p=n.stretches.get(s.gene.refName),c=p?ps(p,s.gene):0,l=s.gene.end-s.gene.start;return{...s,covered:p&&!s.onReference?c/l:s.covered,anchored:s.onReference&&c>0?Math.min(1,s.covered*l/c):1,walks:n.walks.get(Wa(s.gene))??0}})}var Ha="14.0.0";function st(e,t,o={}){return{nodePositions:o.drawsRows?{}:e.nodePositions,deletions:t.bypassed,deletionRoutes:e.deletionRoutes,stranded:e.stranded,hiddenEdges:t.hidden}}var K={...No,width:Mo,height:800,colorScheme:"auto",nodeWidth:"depth",edgeWidth:"uniform",contigThickness:6,connectorThickness:2,nodeLengths:yt.nodeLengths,smallSites:"hidden"};var Fa=[{value:"auto",label:"Auto"},{value:"uniform",label:"Uniform"},{value:"random",label:"Random"},{value:"rainbow",label:"Rainbow"},{value:"depth",label:"Depth"},{value:"node-length",label:"Node length"},{value:"stable-rank",label:"Stable rank"},{value:"reference-position",label:"Reference position"},{value:"grey",label:"Grey"}],ds=Fa.map(e=>e.value);function pt(e,t){return e!=="auto"?e:t?.anchoredBy?"reference-position":"uniform"}function Xa(e,t,o){let r=o.region,n=o.colorDomain??r,a=o.walkRows,i=Ze(t,{region:o.fitToDrawing?void 0:r,extent:a&&t.extent?Pe(a,o.walkRowPitch):void 0}),s=new Map(e.nodes.map(w=>[w.id,w])),p=pt(o.colorScheme??K.colorScheme,e),c=p==="reference-position"&&!t.tubeMap?Ke(e,n):void 0,l=je(e,t.tubeMap?[]:Ve(e),o.showDeletionEdges),d=o.walks??[],m=d.some(w=>w.color?.field==="reference")?c??Ke(e,n):void 0,h=d.length>0&&!t.tubeMap?Qe(e,d,m):void 0,f=Ot(o.facet),u=f.field&&h&&h.walks.length>1?et(e,h,d,m):void 0,g=f.field&&u?{panels:u,place:_t(u.map(w=>w.walks[0].name),f.field,f.sort)}:void 0,b=Rt(e.paths?.length?ze(e.paths):[]),x=o.referenceName??We(e,r),R=o.contigThickness??K.contigThickness,k=o.nodeWidth??K.nodeWidth,y=h?.referenceDomain&&{...h.referenceDomain,name:x};return{bounds:i,nodeById:s,colorScheme:p,referenceRamp:c,drawnDeletions:l,layers:d,lift:h,facet:f,facets:g,labelOf:w=>b.get(w)??w,referenceName:x,walkReference:y,keyText:w=>{let S=Wo(w,y);return{note:S.gaps,scale:S.scale}},contigThickness:R,nodeWidth:k,geometry:(w,S)=>vt({...st(t,l,{drawsRows:!!a}),graph:e,nodeById:s,colorScheme:p,contigThickness:R,connectorThickness:o.connectorThickness??K.connectorThickness,drawPaths:!1,nodeWidth:k,edgeWidth:o.edgeWidth??K.edgeWidth,linearLayout:o.linearLayout,highlight:w,axis:S,referenceRamp:c,smallSites:o.smallSites??K.smallSites})}}var qt='font-family="Helvetica, Arial, sans-serif" font-size="11"',mr=48,ae=18,Da=8,ja=16,lr=16,ms=32,ls=22,dr=6,za="#1c1c22",ct=10,Ya="#18181c",ee=(e,t)=>{let o=Kr(t);return`${e}="${re(t)}"${o<255?` ${e}-opacity="${+(o/255).toFixed(3)}"`:""}`},us=e=>e?e.kind==="scale"||e.kind==="width"?mr:ae:0;function hs(e,t){let o=t?Zr:Da,r=o*Jr,n=(t?[r,ae]:[ae-1]).map(a=>{let[i,s,p,c]=$n({x:a,y:9,angle:0,length:r,halfWidth:o/2,color:e},{scaleX:1,scaleY:1,translateX:0,translateY:0,dpr:1});return`M${[i,s,p,c].map(l=>`${+l.x.toFixed(1)},${+l.y.toFixed(1)}`).join("L")}Z`}).join("");return[`<line y1="9" y2="9" x2="${ae}" ${ee("stroke",e)} stroke-width="${t?ko:Da}"/>`,t?`<path d="${n}" fill="none" stroke="#ffffff" stroke-width="${2*Qr}" stroke-linejoin="round"/>`:"",`<path d="${n}" fill="${re(en(e,!t))}"/>`].join("")}function fs(e,t){switch(e.kind){case"scale":return`<linearGradient id="${t}">${e.stops.map(o=>`<stop offset="${+o.offset.toFixed(4)}" stop-color="${re(o.ink)}"/>`).join("")}</linearGradient><rect y="5" width="${mr}" height="8" rx="2" fill="url(#${t})"/>`;case"swatch":return`<rect y="5" width="${ae}" height="8" rx="2" ${ee("fill",e.ink)}/>`;case"chip":return`<rect x="4" y="4" width="10" height="10" rx="2" ${ee("fill",e.ink)}/>`;case"width":return`<rect y="${9-e.px/2}" width="${mr}" height="${e.px}" ${ee("fill",e.ink)}/>`;case"hollow":return`<rect x="1" y="5" width="${ae-2}" height="8" rx="4" ${ee("fill",e.ink)} ${ee("stroke",e.rim)} stroke-width="${e.rimPx}"/>`;case"line":return e.dashed?`<line y1="9" y2="9" x2="${ae}" ${ee("stroke",e.ink)} stroke-width="2" stroke-dasharray="4 3"/>`:`<line y1="9" y2="9" x1="5" x2="${ae-5}" ${ee("stroke",e.ink)} stroke-width="1.5"/>`;case"outline":return`<rect x="1" y="4" width="${ae-2}" height="10" rx="4" fill="none" ${ee("stroke",e.ink)} stroke-width="2"/>`;case"halo":return`<line y1="9" y2="9" x1="5" x2="13" ${ee("stroke",e.ink)} stroke-opacity="0.35" stroke-width="8" stroke-linecap="round"/>`;case"threads":return[6,9,12].map(o=>`<line y1="${o}" y2="${o}" x2="${ae}" ${ee("stroke",e.ink)} stroke-width="${ko}"/>`).join("");case"overhang":return`<path d="M0,9 L8,4 L8,14 Z M18,9 L10,4 L10,14 Z" fill="${re(tn)}"/>`;case"heads":return hs(e.ink,e.haloed)}}function Ka(e,t){let o=us(e.swatch),r=o>0?o+5:0,n=e.strong??"",a=Math.max(r+(n.length+e.text.length)*ce,(e.under?.length??0)*ce);return(i,s)=>({width:a,height:e.under?ms:lr,markup:`<g transform="translate(${i} ${s})" ${qt}>${e.swatch?fs(e.swatch,t):""}<text${r>0?` x="${r}"`:""} y="13">${n?`<tspan font-weight="bold">${Q(n)}</tspan>`:""}${Q(e.text)}</text>${e.under?`<text y="28">${Q(e.under)}</text>`:""}</g>`})}function gs(e){return(t,o)=>({width:e.length*ce,height:lr,markup:`<g transform="translate(${t} ${o})" ${qt}><text y="13" font-weight="bold">${Q(e)}</text></g>`})}var ws=new Set(["Node thickness","Link thickness"]);function bs(e,t){return e.flatMap(({group:o,entries:r})=>[...o&&ws.has(o)?[gs(o)]:[],...r.map((n,a)=>Ka(n,`${t}-${n.key}-${a}`))])}function ys(e,t){let o=[],r=6,n=2,a=0;for(let i of e){let s=i(0,0);r>6&&r+s.width>t-6&&(r=6,n+=a+4,a=0),o.push(i(r,n).markup),r+=s.width+ja,a=Math.max(a,s.height)}return{markup:o,height:n+a}}function ks(e,t){return e.replaceAll(/([ML])(-?[\d.e-]+),(-?[\d.e-]+)/g,(o,r,n,a)=>`${r}${+(Number(n)*t.scaleX+t.translateX).toFixed(1)},${+(Number(a)*t.scaleY+t.translateY).toFixed(1)}`)}function xs(e,t,o,r,n){return`<rect x="${e-o/2}" y="${t-ve-De+2}" width="${o}" height="${ve+De*2-2}" rx="3" fill="#fff" fill-opacity="0.85" stroke="${Nn}"/><text x="${e}" y="${t}" font-family="Helvetica, Arial, sans-serif" font-size="${ve}" fill="${za}" text-anchor="middle"><tspan font-style="italic" font-weight="600">${Q(r)}</tspan>${n?Q(n):""}</text>`}function Rs(e,t,o){let r=o.length*ct*.56+6;return`<rect x="${e-r/2}" y="${t-ct*.65}" width="${r}" height="${ct*1.3}" rx="3" fill="#fff" fill-opacity="0.8"/><text x="${e}" y="${t+ct*.35}" font-family="Helvetica, Arial, sans-serif" font-size="${ct}" fill="${Ya}" text-anchor="middle">${Q(o)}</text>`}function Va(e){let t=0,o=e(t);for(let r=0;r<3&&o.header!==t;r++)t=o.header,o=e(t);return o}function ur(e,t,o={}){let r=o.width??K.width,n=o.height??K.height,a=o.walkRows,{bounds:i,nodeById:s,referenceRamp:p,layers:c,lift:l,facet:d,facets:m,labelOf:h,referenceName:f,walkReference:u,contigThickness:g,nodeWidth:b,geometry:x}=Xa(e,t,o),R=t.pixelRows??!1,k=p&&{start:p.start,end:p.start+p.span},y=o.genes?.length&&!t.tubeMap&&!a?it(e,o.genes,t.nodePositions,t.stranded):[],w=Ae(a,t,o.walkRowPitch),S=kt(e.nodes,o.nodeLengths??K.nodeLengths),M=w.reduce((v,{label:N})=>Math.max(v,2*dr+N.length*ce),D),I=0;function L(v,N,A,G,C,T){let O=[],F=wt(e,s,g,b,0,T.collapsed?.through),_=Pn(Et(y,F.halfWidthPx,v,P=>ks(P,N),Xe(T)),{id:`exons${I++}`,width:G,height:C});_&&O.push(de(_));let j=P=>({x:P.x*N.scaleX+N.translateX,y:P.y*N.scaleY+N.translateY});for(let{item:P,x:E,y:W,w:ht,text:eo}of A.genes){let{pin:Se,name:he}=P,{x1:yi,y1:ki,x2:xi,y2:Ri}=Gn({x:E,y:W},j(Se.at),g);O.push(`<line x1="${yi}" x2="${xi}" y1="${ki}" y2="${Ri}" stroke="${za}" stroke-width="0.8" stroke-opacity="0.6"/>`,xs(E,W,ht,he,eo.slice(he.length)))}for(let{item:P,x:E,y:W,w:ht,text:eo}of A.passes){let Se=Cn({x:E,y:W},P.at),he=re(P.ink);O.push(`<line x1="${Se.x1}" x2="${Se.x2}" y1="${Se.y1}" y2="${Se.y2}" stroke="${he}" stroke-width="1"/>`,`<circle cx="${P.at.x}" cy="${P.at.y}" r="2" fill="${he}"/>`,`<rect x="${E-ht/2}" y="${W-ve-De+2}" width="${ht}" height="${ve+De*2-2}" rx="3" fill="#fff" fill-opacity="0.9" stroke="${he}"/>`,`<text x="${E}" y="${W}" ${qt} font-weight="bold" fill="${he}" text-anchor="middle">${Q(eo)}</text>`)}for(let P of A.sizes){let E=Xr(P);E&&O.push(`<line x1="${E.x1}" x2="${E.x2}" y1="${E.y1}" y2="${E.y2}" stroke="${Ya}" stroke-width="0.8" stroke-opacity="0.6"/>`),O.push(Rs(P.x,P.y,P.text))}a&&O.push(de(Lo(a,{...N,width:G,height:C,...o.walkRowPitch},{ramp:k,rowGenes:o.rowGenes})));for(let{label:P,y:E}of w){let W=E*N.scaleY+N.translateY;W>=0&&W<=C&&O.push(`<rect x="${dr-2}" y="${W-7}" width="${P.length*ce+4}" height="14" fill="#fff" fill-opacity="0.85"/>`,`<text x="${dr}" y="${W+4}" ${qt} stroke="#fff" stroke-width="3" paint-order="stroke">${Q(P)}</text>`)}return O.join("")}function B(v,N,A,G){let C=G?{scale:G.scaleX,translateX:G.translateX,translateY:G.translateY}:qe(i,N,A,R,m?{padLeft:ne,padTop:ne,padRight:ne,padBottom:ne}:{padLeft:M});if(C){let T=G?{scaleX:G.scaleX,scaleY:G.scaleY,pixelRows:R}:Pt(C.scale,R),O=x(v,T),F={scaleX:T.scaleX,scaleY:T.scaleY,translateX:C.translateX,translateY:C.translateY};return{highlight:v,batch:O,t:F,labels:In({paneWidth:N,canvasHeight:A,axisScale:T,translateX:C.translateX,translateY:C.translateY,contigThickness:g,legendSize:{width:0,height:0},drawnRowLabels:w,bubbleHalos:[],genePins:y,liftedWalks:v?.walks.map(_=>_.name),nodePositions:t.nodePositions,labelsNodeSizes:!t.tubeMap&&!v,nodeLengths:S,nodeById:s,graph:e,drawnInk:O,alleleDeletions:t.alleleDeletions??[],positionsVersion:0,folded:O.collapsed?.nodes,passLabels:m?[]:Bn(O,v,F,{width:N,height:A})})}}}function se(v,N,A){if(!v)return"";let{canvas:G,markup:C}=On(N,A),T=new _n(G);return T.uploadGeometry(v.batch),T.updateTransform({...v.t,dpr:1}),T.render([1,1,1,1]),C()+L(v.highlight,v.t,v.labels,N,A,v.batch)}let Be=(v,N,A)=>{let G=bs(En(e,t,{region:o.region,referenceName:f,referenceRamp:p,lift:l,panels:m?.panels,walkLabel:h,nodeWidth:b,contigThickness:g,edgeWidth:o.edgeWidth??K.edgeWidth,connectorThickness:o.connectorThickness??K.connectorThickness,drawsNodes:!a&&!t.tubeMap,marks:An(v.flatMap(C=>C?[C.batch]:[]),A),genePins:y,unlabelled:N}),"key");return a&&So(a,{ramp:k,genes:o.rowGenes?.size?o.rowGeneGaps:void 0,annotation:o.rowAnnotation}).forEach((C,T)=>{G.push((O,F)=>{let _=vo([C],O,F,`rows-key-${T}`);return{width:_.width-ja,height:lr,markup:de(_.tree)}})}),ys(G,r)},Z=[],X;if(m){let{panels:v,place:N}=m,A=F=>Ct({count:N.count,bounds:i,pixelRows:R,width:r,room:n-F,columns:N.columns??d.columns}),{drawn:G,header:C}=Va(F=>{let _=A(F),j=v.map(E=>B(E,_.width,_.height)),P=Be(j);return{drawn:{views:j,key:P,grid:_},header:P.markup.length>0?P.height+Ne:0}}),{grid:T,key:O}=G;for(let F of O.markup)Z.push(F);v.forEach((F,_)=>{let j=N.cells[_],P=j%T.columns*(T.width+Ne),E=C+Math.floor(j/T.columns)*(T.height+Bt+Ne),W=F.walks[0];Z.push(Ka(Tn(W,h(W.name),u),`key${_}`)(P+6,E+2).markup,`<svg x="${P}" y="${E+Bt}" width="${T.width}" height="${T.height}">${se(G.views[_],T.width,T.height)}</svg>`)}),X=C+T.total}else{let v=r-2*D,N=R||!(i.w>0)?i.h:i.h*v/i.w,A=o.frame,G=j=>A?n:Math.max(160,Math.min(n-j,Math.ceil(N+2*D))),{drawn:C,header:T}=Va(j=>{let P=G(j),E=B(l,r,P,A),W=Be([E],E?.labels.unlabelled,A&&E?pn(E.t,E.t,r,P):void 0);return{drawn:{v:E,key:W,h:P},header:W.markup.length>0?Math.max(Bt,W.height):0}}),{v:O,key:F,h:_}=C;for(let j of F.markup)Z.push(j);Z.push(`<svg y="${T}" width="${r}" height="${_}">${se(O,r,_)}</svg>`),X=T+_}let $=o.walkStrip,lt=m?[]:at(l,$&&!a&&!t.tubeMap?$.rows:void 0);for(let v of lt)Z.push(`<svg y="${X}" width="${r}" height="${Ut}">${de(pr(v,h(v.walk),r))}</svg>`),X+=Ut;if($&&!a&&!t.tubeMap){let v=rt($.rows,{width:r}),N=ye(m?m.panels.map(G=>G.walks[0]):l?.walks??[]),A=vo(So($.rows,{inks:N,ramp:k,genes:ir(v,$.rowGenes,$.rowGeneGaps),annotation:o.rowAnnotation,markUnloaded:!0}),6,X+v.height,"strip-key");Z.push(`<line x1="0" x2="${r}" y1="${X+.5}" y2="${X+.5}" stroke="#ddd"/>`,`<svg y="${X}" width="${r}" height="${v.height}">${de(Lo($.rows,v,{inks:N,ramp:k,rowGenes:$.rowGenes,idPrefix:"strip",markUnloaded:!0}))}${de(ar($.rows,v,new Set(c.map(G=>G.walk))))}</svg>`,de(A.tree)),X+=v.height+ls}let ut=JSON.stringify({generator:`@jbrowse/bandage-core@${Ha}`,...o.spec===void 0?{}:{spec:o.spec}});return`<svg xmlns="http://www.w3.org/2000/svg" width="${r}" height="${X}" viewBox="0 0 ${r} ${X}"><metadata>${Q(ut)}</metadata><rect width="${r}" height="${X}" fill="#fff"/>${Z.join("")}</svg>
2
+ `}var Ss=.9;function dt(e,t){return e+2>=t||e>=Ss*t}var vs=50;function hr(e,t,o,r=[]){let n=new Map(e.nodes.map(i=>[i.name,i])),a=[];for(let i of t){let s=[],p=1/0,c=-1/0,l=1/0,d=[],m=ke(i);for(let[u,g]of m.entries()){let b=n.get(g),x=b&&o[b.id];if(!(!b||!x?.length)&&!(i.key?u===0||u===m.length-1:H(b)&&(b.stable.start<i.start||b.stable.start>=i.end))){d.push(b.id),s.push(Ce(x.length===1?[x[0],x[0]]:x));for(let R of x)p=Math.min(p,R.x),c=Math.max(c,R.x),l=Math.min(l,R.y)}}if(d.length===0)continue;let h={x:(p+c)/2,y:l},f=i.covering===!0||dt(d.length,e.nodes.length);a.push({bubble:i,label:Mn(i,r),path:s.join(""),labelAt:h,members:d.length,nodeIds:d,whole:f,tick:!f&&!i.partial&&i.longestAlleleLength<vs})}return a}function mt(e,t){let o=new Set(t),r=e.nodes.filter(p=>o.has(p.name)),n=new Set(r.map(p=>p.id)),a=new Map(e.nodes.map(p=>[p.id,p.length])),i=new Map,s=e.paths?.flatMap(p=>{let c=p.nodeIds.findIndex(m=>n.has(m));if(c<0)return[];let l=p.nodeIds.filter(m=>n.has(m));i.set(p.name,{first:c,nodeIds:l});let d=p.nodeIds.slice(0,c).reduce((m,h)=>m+(a.get(h)??0),0);return[{...p,nodeIds:l,...p.refStarts?{refStarts:p.refStarts.filter((m,h)=>n.has(p.nodeIds[h]))}:{},...p.start===void 0?{}:{start:p.start+d}}]});return{name:e.name,nodes:r,edges:e.edges.filter(p=>n.has(p.from)&&n.has(p.to)),...s?.length?{paths:s}:{},anchorPaths:Br(e,i),pathVisits:e.pathVisits,anchoredBy:e.anchoredBy,referencePath:e.referencePath,revisited:e.revisited}}function fr(e,t,o,r){let n=e.get(t);e.set(t,{min:Math.min(n?.min??1/0,o.min+r),max:Math.max(n?.max??-1/0,o.max+r),n:Math.min(Ln,o.n+(n?.n??0))})}function Ua(e){if(!e.nodes.some(H))return[];let t=new Map(e.nodes.map(m=>[m.id,m])),o=jo(e),r=new Map(o.map((m,h)=>[m,h])),n=new Int32Array(o.length+1),a=new Map,i=new Set;for(let m of e.edges){let h=r.get(m.from),f=r.get(m.to);if(h===void 0||f===void 0||h===f)continue;i.add(`${m.from}>${m.to}`).add(`${m.to}>${m.from}`);let[u,g]=h<f?[h,f]:[f,h];n[u+1]++,n[g]--;let[b,x]=h<f?[m.from,m.to]:[m.to,m.from];Er(a,b,x)}for(let m=1;m<n.length;m++)n[m]+=n[m-1];let s=e.nodes.filter(H).sort((m,h)=>m.stable.start-h.stable.start),p=new Set([s[0].id,s.at(-1).id]),c=s.map(m=>[m,r.get(m.id)]).filter(([m,h])=>p.has(m.id)||n[h]===0).sort(([m,h],[f,u])=>h-u||m.stable.start-f.stable.start),l=gr(e,c.map(([m])=>m.id)),d=[];for(let m=0;m+1<c.length;m++){let[h,f]=c[m],[u,g]=c[m+1],b=o.slice(f+1,g);if(b.length===0)continue;let x=new Map([[h.id,{min:0,max:0,n:1}]]);for(let I of[h.id,...b]){let L=x.get(I);if(L)for(let B of a.get(I)??[])r.get(B)>g||fr(x,B,L,B===u.id?0:t.get(B).length)}let R=wr(e,t,l,h.id,u.id,()=>x.get(u.id)??{min:0,max:0,n:0}),k=h.stable.start+h.length,y=u.stable.start,w=[h.id,...b.filter(I=>H(t.get(I))),u.id],S=w.some((I,L)=>L>0&&!i.has(`${w[L-1]}>${I}`)),M=y-k;d.push(br({refName:h.stable.refName,start:k,end:y},[h,...b.map(I=>t.get(I)),u],S&&!R.routes?{...R,min:M,max:M}:R,S||R.walksLeave))}return d}function gr(e,t){let o=e.paths;if(!o)return;let r=new Map;for(let n of t)r.set(n,new Int32Array(o.length).fill(-1));return o.forEach((n,a)=>{let i=n.nodeIds;for(let s=0;s<i.length;s++){let p=r.get(i[s]);p?.[a]===-1&&(p[a]=s)}}),r}function wr(e,t,o,r,n,a){if(!o)return{...a(),walksLeave:!1};let i=[],s=1/0,p=-1/0,c=0,l=o.get(r),d=o.get(n);e.paths.forEach((h,f)=>{let u=l[f],g=d[f];if(u<0||g<0){(u>=0||g>=0)&&c++;return}let b=h.nodeIds,x=Math.min(u,g)+1,R=Math.max(u,g),k=g<u?w=>b[R-1-w]:w=>b[x+w],y=i.find(w=>w.steps.length===R-x&&w.steps.every((S,M)=>S===k(M)));if(!y){let w=Array.from({length:R-x},(M,I)=>k(I)),S=0;for(let M of w)S+=t.get(M)?.length??0;y={steps:w,bp:S,walks:[]},i.push(y)}y.walks.push(h.name),s=Math.min(s,y.bp),p=Math.max(p,y.bp)});let m=c>0;return i.length?{min:s,max:p,n:i.length,routes:i,walksLeave:m}:{...a(),walksLeave:m}}function br(e,t,{min:o,max:r,n,routes:a},i){return{...e,segmentCount:t.length,pathCount:n,inversion:!1,shortestAlleleLength:o,longestAlleleLength:r,segments:t.map(s=>s.name).join(","),shortestAllele:void 0,longestAllele:void 0,partial:i,routes:a,...t.some(s=>s.placeholder)?{unloaded:!0}:{}}}function Ls(e,t){let o=e.nodes.length*2,r=new Set,n=[],a=new Int32Array(o);for(let c of e.edges){let l=t.get(c.from),d=t.get(c.to);if(l===void 0||d===void 0)continue;let m=Oe(c),h=l*2+(m.from==="end"?1:0),f=d*2+(m.to==="end"?1:0),u=Math.min(h,f)*o+Math.max(h,f);r.has(u)||(r.add(u),n.push(h,f),a[h]++,h!==f&&a[f]++)}let i=new Int32Array(o+1);for(let c=0;c<o;c++)i[c+1]=i[c]+a[c];let s=new Int32Array(i[o]),p=i.slice(0,o);for(let c=0;c<n.length;c+=2){let l=n[c],d=n[c+1];s[p[l]++]=d,l!==d&&(s[p[d]++]=l)}return{offset:i,next:s}}function Ms(e,t,o){let r=new Int32Array(e),n=new Uint8Array(e*2),a=new Int32Array(e*2),i=new Int32Array(e),s=[],p=0;return c=>{let l=c>>1;p++,s.length=0;let d=0,m=0,h=0,f,u=g=>{n[g]||(n[g]=1,d++,s.push(g))};u(c),a[m++]=c;e:for(;m>0;){let g=a[--m],b=g>>1;if(r[b]=p,b!==l&&(i[h++]=g),n[g]&&(n[g]=0,d--),t[g]===t[g+1])break;for(let x=t[g];x<t[g+1];x++){let R=o[x],k=R>>1;if(k===l)break e;if(u(R^1),r[k]===p)continue;let y=!0;for(let w=t[R];w<t[R+1];w++)if(r[o[w]>>1]!==p){y=!1;break}y&&(a[m++]=R^1)}if(m===1&&d===1){h>0&&(f={source:c,sink:a[0],inside:i.slice(0,h)});break}}for(let g of s)n[g]=0;return f}}function Ns(e){return{source:e.sink^1,sink:e.source^1,inside:e.inside.map(t=>t^1).reverse()}}function yr(e,t){return H(e)&&H(t)&&e.stable.refName===t.stable.refName}function qa(e,t){let o=t[e.source>>1],r=t[e.sink>>1],n=yr(o,r)?o.stable.start-r.stable.start:0,a=((e.sink^1)&1)-(e.source&1);return(n||a||He(o.name,r.name))<0}function Za(e){return[e.source>>1,...Array.from(e.inside,t=>t>>1),e.sink>>1]}function Ps(e){let{nodes:t}=e,o=new Map(t.map((p,c)=>[p.id,c])),{offset:r,next:n}=Ls(e,o),a=Ms(t.length,r,n),i=new Map;for(let p=0;p<t.length*2;p++){let c=a(p);if(!c)continue;let l=c.source>>1,d=c.sink>>1,m=Math.min(l,d)*t.length+Math.max(l,d);(qa(c,t)||!i.has(m))&&i.set(m,c)}return{found:[...i.values()].map(p=>qa(p,t)?p:Ns(p)),offset:r,next:n}}function As(e,t,o,r){let n=r.sink>>1,a=new Map([[r.source>>1,{min:0,max:0,n:1}]]);for(let i of[r.source,...r.inside]){let s=a.get(i>>1);if(s)for(let p=t[i];p<t[i+1];p++){let c=o[p]>>1;fr(a,c,s,c===n?0:e[c].length)}}return a.get(n)??{min:0,max:0,n:0}}function kr(e,t){let{nodes:o}=e,{found:r,offset:n,next:a}=Ps(e),i=r.map(f=>dt(f.inside.length,o.length)),s=r.map(Za),p=new Map;s.forEach((f,u)=>{for(let g of f)Tr(p,g,u)});let c=(f,u)=>p.get(f.inside[0]>>1).some(g=>g!==u&&!i[g]&&s[g].length>s[u].length&&s[u].every(b=>p.get(b).includes(g))),l=f=>t!==void 0||yr(o[f.source>>1],o[f.sink>>1]),d=r.filter((f,u)=>!i[u]&&l(f)&&!c(f,u)),m=new Map(o.map(f=>[f.id,f])),h=gr(e,d.flatMap(f=>[o[f.source>>1].id,o[f.sink>>1].id]));return d.map(f=>{let u=o[f.source>>1],g=o[f.sink>>1],b=wr(e,m,h,u.id,g.id,()=>As(o,n,a,f)),x=yr(u,g);return{...br({refName:x?u.stable.refName:t.refName,start:x?u.stable.start+u.length:t.start,end:x?g.stable.start:t.end},Za(f).map(R=>o[R]),b,b.walksLeave),key:`${u.name}>${g.name}`,...x?{}:{offReference:!0}}}).sort((f,u)=>f.start-u.start||f.end-u.end||He(f.key,u.key))}function Zt(e,t){let o=e.nodes.length,r=Ua(e);if(r.length===0){let n=kr(e,t);return t?[...n,{...t,covering:!0}]:n}return r.flatMap(n=>dt(n.segmentCount-2,o)?[...kr(n.segmentCount===o?e:mt(e,ke(n)),n),{...n,covering:!0}]:[n])}function xr(e,t,o){return t==="uniform"||t==="grey"?void 0:Ts(e,t,o)}function Ts(e,t,o){let r=on(e,o);return new Map(e.nodes.flatMap((n,a)=>n.placeholder?[]:[[n.id,Ur(rn(n,a,t,r))]]))}var Jt=JBrowseExports["@jbrowse/core/pluggableElementTypes/renderers/util/serializableFilterChain"];var Ja=Jt&&Jt.__esModule?Jt.default:Jt;var Rr={paths:!1,bubbles:!1,deletions:!0,genes:!0,lengths:yt.nodeLengths,referenceStrip:!0,walkStrip:!1,walkRibbons:!1,walkBlocks:!1,smallSites:!1};function Qa(e){let t=V(e)?e:{};return new Set(Object.keys(Rr).filter(o=>t[o]??Rr[o]))}function rv(e,t,o){let{[t]:r,...n}=V(e)?e:{};return o===Rr[t]?n:{...n,[t]:o}}var Sr={depth:"depth",length:"node-length",rank:"stable-rank",position:"reference-position"},ei=Object.fromEntries(Object.entries(Sr).map(([e,t])=>[t,e]));function ti(e){if(V(e)){let{field:t,value:o,scale:r}=e;if(o==="grey"||o==="uniform")return o;if(t==="id")return V(r)&&r.scheme==="rainbow"?"rainbow":"random";if(typeof t=="string"&&t in Sr)return Sr[t]}return"auto"}function oi(e){let t=V(e)?e.scale:void 0;return V(t)&&typeof t.domainMin=="number"&&typeof t.domainMax=="number"?{start:t.domainMin,end:t.domainMax}:void 0}function iv(e,t){return e==="grey"||e==="uniform"?{value:e}:e==="random"?{field:"id",scale:{type:"ordinal"}}:e==="rainbow"?{field:"id",scale:{scheme:"rainbow"}}:e==="reference-position"&&t?{field:"position",scale:{domainMin:t.start,domainMax:t.end}}:ei[e]?{field:ei[e]}:{}}var ri=6;function Qt(e){return typeof e=="number"?{width:"uniform",px:e,links:"uniform"}:V(e)?{width:e.field==="depth"||e.field==="frequency"?e.field:"uniform",px:typeof e.value=="number"?e.value:ri,links:e.links==="walks"?"walks":"uniform"}:{width:"depth",px:ri,links:"uniform"}}function cv({width:e,px:t,links:o}){return e==="uniform"&&o==="uniform"?t:{...e==="uniform"?{}:{field:e},value:t,...o==="walks"?{links:o}:{}}}function ni(e,t,o,r){let n=_r(e,t,{visits:r});return n?uo(n,o):void 0}var Es=[];function Gs(e,t){return e.gene.name===t.gene.name&&e.gene.refName===t.gene.refName&&e.gene.start===t.gene.start&&e.gene.end===t.gene.end&&e.exons===t.exons&&e.at.x===t.at.x&&e.at.y===t.at.y&&e.covered===t.covered&&e.onReference===t.onReference&&e.walks===t.walks&&e.nodeIds.size===t.nodeIds.size&&[...e.nodeIds].every(o=>t.nodeIds.has(o))}function Is(e,t){return e.length===t.length&&e.every((o,r)=>{let n=t[r];return n!==void 0&&Gs(o,n)})}function vr(e,t){return e.size===t.size&&[...e.keys()].every(o=>t.has(o))}function ai(e){try{return e()}catch{return}}function ii(e){let t=new Map;for(let o of e.nodes)t.set(o.id,o);return t}function si(e,t,o){return t&&o?ho({nodeId:e,nodeById:t,neighbors:o}):void 0}var pi=kn.views(e=>({sessionTrack(t){return te(e).tracks.find(o=>o.trackId===t)},get grammar(){return{}},get hasPendingSource(){return!1},get canRetryLoad(){return!1},get sourceTrack(){return ai(()=>Nr(e).configuration)},get sourceAdapter(){let t=this.sourceTrack;return t?Ma(e,t):void 0},get containingView(){return ai(()=>to(e))}})).views(e=>{let t=a=>Fe(a,{equals:(i,s)=>JSON.stringify(i)===JSON.stringify(s)}),o=t(()=>oi(e.grammar.encoding?.color)),r=t(()=>Ot(e.grammar.facet)),n=t(()=>{let a=Yn(e.grammar.facet);return a&&a.field!=="walk"&&a.field!=="sample"?a:void 0});return{get chosenLayoutMode(){return e.grammar.layoutMode??"force"},get chosenLayoutEngine(){return e.grammar.layoutEngine??"fmmm"},get chosenColorScheme(){return ti(e.grammar.encoding?.color)},get statedColorDomain(){return o.get()},get chosenHover(){return e.grammar.hover??"nodes"},get nodeWidth(){return Qt(e.grammar.size).width},get contigThickness(){return Qt(e.grammar.size).px},get linkWidth(){return Qt(e.grammar.size).links},get layerSet(){return Qa(e.grammar.layers)},get drawPaths(){return this.layerSet.has("paths")},get showBubbles(){return this.layerSet.has("bubbles")},get showDeletionEdges(){return this.layerSet.has("deletions")},get smallSites(){return this.layerSet.has("smallSites")?"nodes":"hidden"},get showGenes(){return this.layerSet.has("genes")},get showReferenceStrip(){return this.layerSet.has("referenceStrip")},get walkStrip(){return this.layerSet.has("walkStrip")},get walkRibbons(){return this.layerSet.has("walkRibbons")},get facetSetting(){return r.get()},get walkRowGroupBy(){return n.get()},get walkRowSamples(){let a=e.grammar.rows?.kept;return Array.isArray(a)?a:void 0},get walkRowsFollowLift(){return e.grammar.rows?.kept==="lifted"},get walkRowOrder(){return e.grammar.rows?.order==="shared"?"shared":void 0},get hoverLightsEverything(){return this.chosenHover==="everything"},get litNode(){return this.chosenHover==="off"?null:e.hoveredNode}}}).views(e=>({get paneWidth(){return to(e).width},get paneMeasured(){return!0},get drawnGraph(){return e.layoutResult?.tubeMap?.graph??e.graph}})).views(e=>({get nodeById(){return e.drawnGraph&&ii(e.drawnGraph)},get nodeLengths(){return kt(e.drawnGraph?.nodes??[],e.layerSet.has("lengths"))},get nodeCount(){return e.graph?.nodes.length??0},get edgeCount(){return e.graph?.edges.length??0},get pathCount(){return e.graph?.paths?.length??0},get legendAtRest(){return e.hoveredNode===null&&e.hoveredRowWalks.length===0},get hasGraph(){return e.graph!==void 0},get canCancelLoad(){return e.isLoading&&!e.layoutResult},get usesLayoutEngine(){return e.graph?Yo(e.chosenLayoutMode,e.graph):!1},get anchorPaths(){return e.graph?.anchorPaths??[]},get walkChoices(){let t=e.graph?.paths;return t?.length?ze(t):[]},get effectiveDrawPaths(){return e.drawPaths&&xt(e.graph?.paths?.length??0)},get activeReferencePath(){return e.graph?.referencePath},get rampDomain(){let t=e.openBubbles.at(-1);return t&&!t.offReference&&t.end>t.start?{start:t.start,end:t.end}:e.statedColorDomain??e.graphRegion},get drawnReferenceRamp(){let t=e.drawnGraph;return t?Ke(t,this.rampDomain):void 0},get walkRamp(){return e.walkLayers.some(t=>t.color?.field==="reference")?this.drawnReferenceRamp:void 0},get modeDrawsNodes(){return Y(e.chosenLayoutMode).drawsNodes},get liftedWalkLayers(){return e.walkLayers.length>0||!this.modeDrawsNodes?e.walkLayers:e.hoveredRowWalks.map(t=>({walk:t}))},get sheetColorOf(){let t=e.walkRowSampleTable,o=e.sourceAdapter;return t&&o?Qn(t,Ir({getConf:r=>o[r]})):void 0},get coloredWalkLayers(){let t=this.sheetColorOf;return this.liftedWalkLayers.map(o=>{let{field:r,scheme:n,value:a}=o.color??{},i=(r??n??a)===void 0?t?.(o.walk):void 0;return i===void 0?o:{...o,color:{...o.color,value:i}}})},get walkLift(){let{graph:t}=e,o=this.coloredWalkLayers;return t&&!e.walkCut&&o.length>0&&!e.layoutResult?.tubeMap?Qe(t,o,this.walkRamp):void 0},get facetPanels(){let{graph:t}=e,o=this.walkLift;return e.facetSetting.field!==""&&this.modeDrawsNodes&&t&&o&&e.walkLayers.length>1&&o.walks.length>1?et(t,o,this.coloredWalkLayers,this.walkRamp):void 0},get drawnWalks(){return this.facetPanels?.map(t=>t.walks[0])??this.walkLift?.walks??[]},get walksShadedAlong(){let t=this.drawnWalks;return t.length>0&&t.every(o=>o.encoding.field==="progress")},get liftsWalks(){return!hn.has(e.chosenLayoutMode)},get walkReference(){let t=this.walkLift?.referenceDomain;return t&&{...t,name:e.graph&&We(e.graph,e.graphRegion)}},get liftedWalks(){return this.walkLift?.walks.map(t=>t.name)},get walkLabels(){return Rt(this.walkChoices)},walkLabel(t){return this.walkLabels.get(t)??t},get liftedWalksLabel(){let t=this.walkLift?.walks??[];return t.length===1?this.walkLabel(t[0].name):"these walks"},get effectiveColorScheme(){return e.layoutResult?.tubeMap&&(this.tubeMapReads||e.chosenColorScheme==="auto")?"uniform":pt(e.chosenColorScheme,e.graph)},get tubeMapReads(){let t=e.layoutResult;return!t?.tubeMapPanels&&(t?.tubeMap?.layout.reads.length??0)>0},get colorSchemeLock(){return this.walkLift?{value:"By walk",why:"Each highlighted haplotype colours its own lane: set it under Haplotypes, Color highlighted..."}:this.tubeMapReads?{value:"By strand",why:"Reads take the reds and blues, so the tube map leaves its nodes clear"}:void 0},get nodePositions(){return e.layoutResult?.nodePositions},get labelsNodeSizes(){return!e.layoutResult?.tubeMap&&!this.walkLift},get alleleDeletions(){return e.layoutResult?.alleleDeletions??[]},get deletionRoutes(){return e.layoutResult?.deletionRoutes},get stranded(){return e.layoutResult?.stranded},get pixelRows(){return e.layoutResult?.pixelRows??!1},get zoomPercent(){return`${(e.scale*100).toFixed(1)}%`},get isDefaultViewport(){return e.scale===1&&e.translateX===0&&e.translateY===0}})).views(e=>({get derivedBubbles(){return e.graph?Zt(e.graph):[]},get openBubbleInsides(){let{graph:t}=e;return t?e.openBubbles.map(o=>Zt(mt(t,ke(o)),o).filter(r=>!r.covering)):[]},get openBubble(){return e.openBubbles.at(-1)},get openBubbleFocus(){let t=this.openBubble,{graph:o}=e;if(!t||!o)return;let r=new Set(ke(t)),n=new Set(o.nodes.filter(i=>r.has(i.name)).map(i=>i.id)),a=new Set;return o.edges.forEach((i,s)=>{n.has(i.from)&&n.has(i.to)&&a.add(s)}),{walks:[],nodeIds:n,edgeIndexes:a,names:new Set}},get drawnHighlight(){return e.walkLift??this.openBubbleFocus},bubbleIsOpen(t){return e.openBubbles.some(o=>Tt(o,t))},bubbleFaded({bubble:t,nodeIds:o}){let r=e.walkLift,n=this.openBubbleFocus;return r?!o.some(a=>r.nodeIds.has(a)):!!n&&!this.bubbleIsOpen(t)&&!o.every(a=>n.nodeIds.has(a))}})).views(e=>({get bubbles(){let t=e.indexBubbles?.length?e.indexBubbles:e.derivedBubbles,o=[...t],r=new Set(t.map($o));for(let n of e.openBubbleInsides.flat()){let a=$o(n);r.has(a)||(r.add(a),o.push(n))}return o},get foldNote(){let t=e.foldedBelowBp;return t===void 0?void 0:`variants under ${Le(t)} folded into the reference`}})).views(e=>({get cutHaplotypes(){},get sourceTrackId(){return e.sourceTrack?.trackId},get sessionTracks(){let t=te(e);return t.tracks.map(o=>({trackId:o.trackId,name:$r(o,t),adapterType:gt(o).type,assemblies:Qo(t,o)}))}})).views(e=>({get assemblyTrackChoices(){let t=e.graphRegion,o=t&&Jo(te(e),t.assemblyName);return o?e.sessionTracks.filter(r=>r.assemblies.includes(o)):[]}})).views(e=>({get geneTrackChoices(){return e.assemblyTrackChoices.filter(t=>Ht.has(t.adapterType))},get repeatTrackChoices(){return e.assemblyTrackChoices.filter(t=>ea.has(t.adapterType))},get repeatChoices(){return e.repeatArrays??[]}})).views(e=>({get repeatTrack(){return ta(e.repeatTrackChoices,e.repeatTrackId)},get geneTrack(){return Ft(e.geneTrackChoices,e.geneTrackId)},get walkRowAnnotation(){return Xt(this.geneTrack)},get repeatOptions(){return[{value:"",label:"Whole window"},...e.repeatChoices.map(({key:t,name:o,unit:r})=>({value:t,label:`${o} \xB7 ${r.toLocaleString()} bp unit`}))]},get selectedRepeat(){return e.repeatChoices.find(t=>t.key===e.repeatKey)},get backbone(){return e.graph?co(e.graph):void 0},get cutWalkRows(){let t=e.walkCut,o=t?.walkRowRuns,r=this.rowVisitsNeeded;return t&&o&&r&&e.graphRegion?ni(t,e.graphRegion,void 0,!0):o?uo(o):e.graph?Me(e.graph,e.graphRegion,void 0,{visits:r}):void 0},get rowVisitsNeeded(){return e.chosenLayoutMode==="walkrows"&&(e.walkRibbons||e.layerSet.has("walkBlocks")||e.walkRowOrder==="shared")},assemblySpellings(t){let{assemblyManager:o}=te(e),r=o.has(t)?o.get(t):void 0,n=e.sourceAdapter?.assemblyNameToPanSN??{},a=[t,...r?[r.name,...r.aliases]:[]];return{name:t,aliases:[...a,...a.flatMap(i=>n[i]??[])]}},get drawsLoadedReference(){let t=e.graph;return t?.anchoredBy==="tags"||t?.referencePath!==void 0&&t.referencePath===e.loadedReferencePath}})).views(e=>({get geneAssembly(){let t=e.graphRegion;return t?e.assemblySpellings(t.assemblyName):void 0},get geneLaneFilter(){let t=e.containingView;if(!t)return;let o=oa(t,e.geneTrack?.trackId);return o.length?new Ja({filters:o,jexl:Pr(e).pluginManager.jexl}):void 0},get geneFeatures(){let t=e.geneTrackFeatures,o=this.geneLaneFilter;return t?ra(o?t.filter(r=>o.passes(r)):t):void 0},get backboneGenes(){let{backbone:t}=e,{geneAssembly:o,geneFeatures:r}=this,n=e.drawsLoadedReference||o!==void 0&&mo(t,[o])!==void 0;return t&&r&&n?lo(r,t):void 0}})).views(e=>{let t=Fe(()=>{let r=e.drawnBatch.collapsed;return{nodes:r?.nodes??bt.nodes,within:r?.within??bt.within}},{equals:(r,n)=>vr(r.nodes,n.nodes)&&vr(r.within,n.within)}),o=Fe(()=>Xe(e.drawnBatch),{equals:vr});return{get folded(){return t.get().nodes},get notDrawn(){return o.get()},get foldedWithin(){return t.get().within}}}).views(e=>({get nodeNeighbors(){return e.drawnGraph?pe(e.drawnGraph):void 0},get drawnFold(){return e.drawnBatch.collapsed},get nodeInk(){return wt(e.drawnGraph,e.nodeById,e.contigThickness,e.nodeWidth,0,this.drawnFold?.through)},get allDeletions(){return e.graph&&this.drawsNodes?Ve(e.graph):[]},get cohortWalkRows(){if(e.chosenLayoutMode!=="walkrows"||!e.graph)return;let t=e.selectedRepeat,o=e.walkCut,r=e.rowVisitsNeeded,n=t?o?ni(o,t,t.unit,r):Me(e.graph,t,t.unit,{visits:r}):e.cutWalkRows;if(!n)return;let[a,...i]=na([n.reference,...n.rows],t?.calls);return{...n,reference:a,rows:i}},get walkRowSampleChoices(){let t=this.cohortWalkRows?.rows??[];return{samples:[...new Set(t.map(o=>o.sample))].sort(),disagreeing:[...new Set(t.filter(o=>o.call?.agrees===!1).map(o=>o.sample))]}},get walkRowSamplesTsv(){let t=e.sourceAdapter?.samplesTsvLocation;return t&&Ar(t)?t:void 0},get walkRowGroupFields(){return zn(e.walkRowSampleTable)},get tubeMapColoring(){let t=e.tubeMapColorBy,o=e.walkRowSampleTable;if(!t||!o||!this.walkRowGroupFields.includes(t))return;let r=pa(t,o),n=(e.graph?.paths??[]).map(a=>oe(a.name).name).filter(a=>a!==e.graph?.referencePath);return{field:t,valueOf:r,palette:ia(n.map(r)),unvalued:n.some(a=>r(a)==="")}},get tableGroupBy(){let t=e.walkRowGroupBy,o=e.walkRowSampleTable;return t&&o&&this.walkRowGroupFields.includes(t.field)?{groupBy:t,table:o}:void 0},get tubeMapPanelSplit(){let{field:t,sort:o}=e.facetSetting,r=this.tableGroupBy;return t!==""?{by:t,sort:o}:r?{by:"column",...r.groupBy,table:r.table}:void 0},get liftedRowHaplotypes(){let t=e.drawnWalks;return[...new Set((e.cutWalkRows?.rows??[]).filter(o=>t.some(r=>Ue(r.name,o))).map(yo))]},get keptRowSamples(){return e.walkRowsFollowLift?this.liftedRowHaplotypes:e.walkRowSamples},get keptCohortRows(){let t=this.cohortWalkRows,o=t&&Ye(t.rows,this.keptRowSamples);if(!t||!o||e.walkRowOrder!=="shared")return o;let r=[t.reference,...o];return jr(r).filter(n=>n>0).map(n=>r[n])},get walkRowGroups(){let t=this.keptCohortRows,o=this.tableGroupBy;return t&&o?Kn(t,o.table,o.groupBy):void 0},get walkRowBars(){let t=this.cohortWalkRows,o=this.keptCohortRows;return t&&o?{...t,rows:this.walkRowGroups?.rows??o}:void 0},get walkRowList(){let t=this.walkRowBars;return t?[t.reference,...t.rows]:[]},get walkRowRibbons(){let t=this.walkRowGroups?.sections??[];return e.walkRibbons&&e.rowVisitsNeeded&&this.walkRowBars?zr(this.walkRowList).filter(({row:o})=>Xo(t,o)===Xo(t,o+1)):void 0},get sharedBlocks(){return e.layerSet.has("walkBlocks")&&e.rowVisitsNeeded&&this.walkRowBars?Yr(this.walkRowList):void 0},get drawsNodes(){return Y(e.drawnLayoutMode??e.chosenLayoutMode).drawsNodes},get bubbleHalos(){Je(e.positionsVersion);let t=e.layoutResult?.nodePositions,o=e.showBubbles?e.bubbles:e.hoveredBubble?[e.hoveredBubble]:[];if(o.length===0||!this.drawsNodes||!e.graph||!t)return[];let{folded:r,foldedWithin:n}=e,a=r.size?Object.fromEntries(Object.entries(t).filter(([i])=>!r.has(i))):t;return hr(e.graph,o,a,e.repeatArrays).filter(i=>!i.nodeIds.every(s=>n.has(s)))},get referenceRamp(){return e.effectiveColorScheme==="reference-position"?e.drawnReferenceRamp:void 0},get assemblyNames(){let t=e.graphRegion;return t?[t.assemblyName]:[]},get axisScale(){return Pt(e.scale,e.pixelRows)},get scaleX(){return this.axisScale.scaleX},get scaleY(){return this.axisScale.scaleY}})).views(e=>{let t=Fe(()=>{Je(e.positionsVersion);let o=e.layoutResult?.nodePositions,r=[...e.backboneGenes??[],...e.ownGeneFeatures??[]];return e.showGenes&&e.drawsNodes&&e.graph&&r.length>0&&o?it(e.graph,r,o,e.layoutResult?.stranded):Es},{equals:Is});return{get genePins(){return t.get()}}}).views(e=>({get exonOutlines(){let{genePins:t,walkLift:o}=e,r=o?void 0:e.openBubbleFocus,n=r?t.map(a=>({...a,exonsByNode:a.exonsByNode.filter(i=>r.nodeIds.has(i.nodeId))})):t;return Et(n,e.nodeInk.halfWidthPx,o,void 0,e.notDrawn)}})).views(e=>({get screenTransform(){return{scaleX:e.scaleX,scaleY:e.scaleY,translateX:e.translateX,translateY:e.translateY}},toScreen(t){return{x:t.x*e.scaleX+e.translateX,y:t.y*e.scaleY+e.translateY}},get deletionDrawing(){return e.graph?je(e.graph,e.allDeletions,e.showDeletionEdges):void 0},get deletions(){return this.deletionDrawing?.shown??[]},get deletionEdgeIndexes(){return this.deletionDrawing?.bypassed},get hiddenEdgeIndexes(){return this.deletionDrawing?.hidden},get referenceRampDomain(){let t=e.referenceRamp;return t?{start:t.start,end:t.start+t.span}:void 0},get paintsNodeColors(){return e.drawsNodes||!!e.layoutResult?.tubeMap},get tubeMapNodeColors(){let t=e.drawnGraph;return e.layoutResult?.tubeMap&&t?xr(t,e.effectiveColorScheme,e.referenceRamp):void 0},get tubeColorKind(){let t=e.layoutResult,o=e.drawnGraph?.paths??[],r=e.tubeMapReads;return t?.tubeMap?e.tubeMapColoring&&!r?"value":t.tubeMapPanels?"role":this.tubeMapNodeColors?"tinted":!r&&(!xt(o.length)||o.some(n=>n.members))?"role":"path":void 0},tubeColorsOf(t,o){let r=t.paths??[],n=this.tubeColorKind,a=e.tubeMapColoring;return n==="value"&&a?sa(r,t.referencePath,a.valueOf,a.palette):n==="tinted"?Do(r,t.referencePath,aa):n==="role"?Do(r,t.referencePath):o},fadeUnhovered(t,o,r){let n=new Set(e.hoveredRowWalks);return n.size>0?t.map((a,i)=>{let s=o[i]?.name??"";return n.has(s)||r!==void 0&&oe(s).name===r?a:St}):t},get tubeMapTubeColors(){let t=e.layoutResult?.tubeMap,o=e.drawnGraph;return t&&o?this.fadeUnhovered(this.tubeColorsOf(o,t.pathColors),o.paths??[]):void 0},nodeSpan(t){return si(t,e.nodeById,e.nodeNeighbors)},get hoverDrawing(){let t=e.hoveredPanel;return(t===null?void 0:e.layoutResult?.tubeMapPanels?.[t]?.result.tubeMap)??e.layoutResult?.tubeMap},get hoverGraph(){return this.hoverDrawing?.graph??e.drawnGraph},get hoverNodeById(){let t=this.hoverGraph;return t===e.drawnGraph?e.nodeById:t&&ii(t)},get hoverNeighbors(){let t=this.hoverGraph;return t===e.drawnGraph?e.nodeNeighbors:t&&pe(t)}})).views(e=>({get pathLegend(){let t=e.drawnGraph?.paths;return(e.layoutResult?.tubeMap?e.tubeColorKind==="path":e.drawPaths)&&t&&xt(t.length)&&!t.some(r=>r.members)?ze(t,e.tubeMapTubeColors):[]},get hoveredSpan(){let t=e.hoveredNode,o=e.hoveredBubble;return t!==null?si(t,e.hoverNodeById,e.hoverNeighbors):o&&!o.offReference?{start:o.start,end:o.end}:void 0},get hoverHighlight(){let t=e.graphRegion,o=this.hoveredSpan;return t&&o&&e.chosenHover!=="off"?{refName:t.refName,assemblyName:t.assemblyName,...o}:void 0}}));var ci=pi.views(e=>({get host(){let t=e.containingView;return ka(t)?t:void 0}})).views(e=>({get pairedViewId(){return e.host?.id??e.connectedViewId}})).views(e=>({get contributingAssemblies(){let t=e.graph,o=t?ie(t):[];return t?Aa(t,{maxGap:o.length>0?so(o):1/0}):[]}})).views(e=>({get assemblyResolver(){let{assemblyManager:t}=te(e),o=e.sourceAdapter?.assemblyNameToPanSN,r=new Map(Object.entries(o??{}).map(([a,i])=>[i,a])),n=a=>a!==void 0&&t.has(a)?t.get(a)?.name??a:void 0;return a=>n(r.get(a))??n(a)},get geneTracksByAssembly(){let t=new Map;for(let o of e.sessionTracks)if(Ht.has(o.adapterType)&&Xt(o)===e.walkRowAnnotation)for(let r of o.assemblies)t.set(r,[...t.get(r)??[],o]);return new Map([...t].flatMap(([o,r])=>{let n=Ft(r,"");return n?[[o,n]]:[]}))}})).views(e=>({get launchableAssemblies(){return Ta(Ia(e.contributingAssemblies,e.graphRegion),e.assemblyResolver)},get canHighlightInLinearView(){let t=e.graphRegion;return t!==void 0&&Ee({views:[...te(e).views],connectedViewId:e.pairedViewId,assemblyName:t.assemblyName})!==void 0},nodeLaunchTargets(t){let o=e.nodeById?.get(t),r=o?qo(o):void 0,n=r?Re(e.assemblyResolver,r):void 0,a=e.graphRegion,i=a?e.nodeSpan(t):void 0,s=a&&i?{sample:a.assemblyName,haplotype:void 0,refName:a.refName,...i}:void 0;return{own:r&&n?{location:tr(r),assembly:n}:void 0,reference:a&&s?{location:tr(s),assembly:a.assemblyName}:void 0,highlight:a&&s?{location:s,assembly:a.assemblyName}:void 0}},get ownGeneReads(){let{graph:t}=e;return!t||!e.showGenes||!e.modeDrawsNodes?[]:Pa(t,e.assemblyResolver,e.graphRegion?.assemblyName).flatMap(({stableRefName:o,assemblyName:r,refName:n,start:a,end:i})=>{let s=e.geneTracksByAssembly.get(r);return s?[{stableRefName:o,trackId:s.trackId,region:{assemblyName:r,refName:n,start:a,end:i}}]:[]}).slice(0,wn)},get assemblyHoverHighlights(){let t=e.hoveredNode,o=t===null?void 0:e.nodeById?.get(t);return o&&e.graph&&e.chosenHover!=="off"?Na(e.graph,o,e.assemblyResolver,e.graphRegion?.assemblyName):[]}}));var di=ci.views(e=>({get walkStripShown(){return or({walkStrip:e.walkStrip,mode:{drawsNodes:e.modeDrawsNodes},drawsPicture:!!e.layoutResult?.tubeMap||!!e.walkRowBars,walks:e.graph?.paths?.length??0,host:!!e.host})},get walkStripRows(){let t=this.walkStripShown?e.cutWalkRows:void 0;return t?{...t,rows:Ye(t.rows,e.keptRowSamples)}:void 0},get walkStripInks(){return ye(e.drawnWalks)},get walkStripFrame(){let t=this.walkStripRows;return t?{...rt(t,{width:e.paneWidth}),measure:tt}:void 0},get cutsWholeWalks(){let t=Y(e.chosenLayoutMode);return e.sourceAdapter?.type==="GbzBaseSyntenyAdapter"&&rr(t,{walkStrip:e.walkStrip&&t.drawsNodes,host:!!e.host})},get walkStripMarks(){let t=this.walkStripRows,o=e.hoveredNode??e.selectedNode,r=o===null?void 0:e.nodeById?.get(o);return t&&r&&e.graph?nr(e.graph,[t.reference,...t.rows],r):[]},rowLocation(t,o){let r={sample:t.sample,haplotype:t.haplotype===void 0?void 0:`${t.sample}#${t.haplotype}`};return{...r,assembly:Re(e.assemblyResolver,r),span:{refName:o.contig,...Lt(o,t.bp)}}},get comparedRows(){return e.rowVisitsNeeded?e.walkRowBars?.rows??[]:[]},get passBars(){return!e.host&&e.drawsNodes&&!e.facetPanels?at(e.walkLift,this.walkStripRows):[]},get walkStripLocator(){let t=e.stripHover?e.hoveredNode:null;return t===null||e.folded.has(t)?void 0:Wt(e.nodePositions?.[t],e.toScreen)}})).views(e=>({get walkGeneReads(){let t=e.walkRowBars??e.walkStripRows;if(!t||!e.showGenes)return;let o=t.rows.filter(a=>!a.stepless),r=o.flatMap(a=>{let i=a.axis?e.rowLocation(a,a.axis):void 0,s=i?.assembly,p=s?e.geneTracksByAssembly.get(s):void 0;return i&&s&&p?[{row:a.name,trackId:p.trackId,region:{assemblyName:s,...i.span}}]:[]}),n=o.filter(a=>!a.axis).length;return{reads:r.slice(0,Co),gaps:{untracked:o.length-n-r.length,unplaced:n,unread:Math.max(0,r.length-Co)}}},get walkRowGeneGaps(){return this.walkGeneReads?.gaps},walkRowLaunchTarget(t,o=e.walkRowBars){let r=o?[o.reference,...o.rows][t]:void 0;if(!r?.axis)return;let{sample:n,haplotype:a,assembly:i,span:s}=e.rowLocation(r,r.axis);return{label:r.label,assembly:t===0?e.graphRegion?.assemblyName:i,location:{sample:n,haplotype:a,...s}}},get walkRowGenes(){let t=e.walkRowBars??e.walkStripRows;if(!t||!e.showGenes)return;let o=new Map(e.walkGeneFeatures??[]);return e.geneFeatures&&o.set(t.reference.name,e.geneFeatures),o.size?sn([t.reference,...t.rows],o):void 0}}));var mi=di.views(e=>({get xIsReferenceBp(){return e.layoutResult?.referenceAxis===!0&&Y(e.drawnLayoutMode??e.chosenLayoutMode).cutMargins}})).views(e=>({get hostPlacesX(){let{host:t,graphRegion:o}=e;return t!==void 0&&t.initialized&&o!==void 0&&e.xIsReferenceBp&&!t.dynamicBlocks.contentBlocks.some(r=>r.refName===o.refName&&r.reversed)}})).views(e=>({get hostBpFrame(){let{host:t,graphRegion:o}=e;return t?.initialized&&o?xa(t,o):void 0}})).views(e=>({get hostFrame(){return e.hostPlacesX?e.hostBpFrame:void 0},get tubeMapPicture(){let t=e.layoutResult?.tubeMap;return t?Jn(t):void 0},get tubeMapReference(){let t=e.layoutResult?.tubeMap;return t?Xn(t):void 0},get tubeMapDeviations(){let t=e.layoutResult?.tubeMap;return t?.coarse?Zn(t,t.coarse.deviations):[]},get tubeMapConnectedBoxes(){let t=this.tubeMapReference,{layoutResult:o}=e;return t&&!o?.referenceAxis&&!o?.tubeMapPanels?[...t.values()].flat():void 0}})).views(e=>({get tubeMapGenes(){let t=e.tubeMapReference;return e.showGenes&&!e.host&&t&&e.backboneGenes&&!e.layoutResult?.tubeMapPanels?Dn(t,e.backboneGenes):[]},get referenceStripApplies(){return!!e.host?.initialized&&!!e.layoutResult&&e.drawsNodes&&!e.hostPlacesX&&!e.facetPanels}})).views(e=>({get referenceStripBlocks(){let{graph:t}=e;if(!e.showReferenceStrip||!e.referenceStripApplies||!t)return[];let o=Wn(t,{colorScheme:e.effectiveColorScheme,referenceRamp:e.referenceRamp,walks:e.walkLift?.walks}),r=e.walkLift?void 0:e.openBubbleFocus;return r?o.map(n=>r.nodeIds.has(n.node)?n:{...n,colors:[St],faded:!0}):o}})).views(e=>({get referenceStripShown(){return e.referenceStripBlocks.length>0&&e.hostBpFrame!==void 0},get referenceStripOverhangs(){let t=e.hostBpFrame;if(!t||e.referenceStripBlocks.length===0)return!1;let{left:o,right:r}=Hn(e.referenceStripBlocks,t,e.paneWidth);return o>0||r>0},get referenceStripFaded(){let t=e.hostBpFrame;return t!==void 0&&e.referenceStripBlocks.some(o=>{let r=o.bp0*t.scale+t.translateX,n=o.bp1*t.scale+t.translateX;return o.faded&&Math.max(r,n)>0&&Math.min(r,n)<e.paneWidth})}})).views(e=>({get referenceStripLit(){if(!e.referenceStripShown)return;let t=e.hoveredNode===null?e.hoveredBubble:null;if(t&&!t.offReference){let n=e.bubbleHalos.find(a=>Tt(a.bubble,t));return{start:t.start,end:t.end,anchor:n?e.toScreen(n.labelAt):void 0}}let o=e.hoveredNode??e.selectedNode,r=o===null?void 0:e.nodeSpan(o);return r&&o!==null?{...r,anchor:e.folded.has(o)?void 0:Wt(e.nodePositions?.[o],e.toScreen)}:void 0},referenceStripNodeAt(t,o){let r=e.hostBpFrame;return e.referenceStripShown&&r?Fn(e.referenceStripBlocks,r,t,o):void 0},get referenceStripZonePx(){return e.referenceStripShown?$t:0}}));var Bs=3e3,Cs=350,Os=34;function _s(e){let t=[0];for(let o=1;o<e.length;o++)t.push(t[o-1]+Math.hypot(e[o].x-e[o-1].x,e[o].y-e[o-1].y));return t}function $s(e,t){if(e.length===1||t===1)return Array.from({length:t},()=>({...e[0]}));let o=_s(e),r=o.at(-1),n=[],a=1;for(let i=0;i<t;i++){let s=r*i/(t-1);for(;a<e.length-1&&o[a]<s;)a++;let p=o[a]-o[a-1],c=p>0?(s-o[a-1])/p:0,l=e[a-1],d=e[a];n.push({x:l.x+(d.x-l.x)*c,y:l.y+(d.y-l.y)*c})}return n}var Ws=400,li=1.8,Hs=.1;function i0(e,t,o,r,n){let a=k=>({x:(k.x*t.scaleX+t.translateX-r.translateX)/r.scaleX,y:(k.y*t.scaleY+t.translateY-r.translateY)/r.scaleY}),i={};for(let[k,y]of Object.entries(o)){let w=e[k];w?.length&&y.length&&(i[k]=$s(w.map(a),y.length))}let s=new Map,p=(k,y)=>{let w=s.get(k);w?w.push(y):s.set(k,[y])};for(let k of n){let{from:y,to:w}=k;if(y!==w&&o[y]?.length&&o[w]?.length){let S=Oe(k);p(y,{id:w,side:S.to}),p(w,{id:y,side:S.from})}}let c=new Map,l=k=>c.get(k.id)??(k.side==="start"?i[k.id][0]:i[k.id].at(-1)),d=Object.keys(i),m=[];for(let k of d)for(let y of s.get(k)??[]){if(i[y.id]||c.has(y.id))continue;let w=s.get(y.id).find(S=>S.id===k);c.set(y.id,{...l(w)}),d.push(y.id),m.push(y.id)}let h=new Map(m.map((k,y)=>[k,y])),f=new Float64Array(m.map(k=>c.get(k).x)),u=new Float64Array(m.map(k=>c.get(k).y)),g=new Float64Array(m.length),b=new Float64Array(m.length),x=m.map((k,y)=>s.get(k).flatMap(w=>{let S=h.get(w.id);if(S===void 0){let M=l(w);return g[y]+=M.x,b[y]+=M.y,[]}return[S]})),R=m.map(k=>s.get(k).length);for(let k=0;k<Ws;k++){let y=0;for(let w=0;w<m.length;w++){let S=g[w],M=b[w];for(let B of x[w])S+=f[B],M+=u[B];let I=li*(S/R[w]-f[w]),L=li*(M/R[w]-u[w]);y=Math.max(y,Math.abs(I*r.scaleX)+Math.abs(L*r.scaleY)),f[w]+=I,u[w]+=L}if(y<Hs)break}m.forEach((k,y)=>{i[k]=o[k].map(()=>({x:f[y],y:u[y]}))});for(let[k,y]of Object.entries(o))i[k]??=y.map(w=>({...w}));return i}function Fs(e,t){let o=0,r=1/0;return e.forEach((n,a)=>{let i=(n.x-t.x)**2+(n.y-t.y)**2;i<r&&(r=i,o=a)}),o}function s0(e,t,o,r){let n=(a,i)=>{let s=o[a],p=r[a];if(!s||!p||p.length===0)return{x:0,y:0};let c=Fs(p,i);return{x:s[c].x-p[c].x,y:s[c].y-p[c].y}};return Object.fromEntries(Object.entries(e).map(([a,i])=>{let s=t[Number(a)],p=n(s?.from??"",i[0]),c=n(s?.to??"",i.at(-1));return[a,i.map((l,d)=>{let m=i.length>1?d/(i.length-1):0;return{x:l.x+p.x+(c.x-p.x)*m,y:l.y+p.y+(c.y-p.y)*m}})]}))}function ui(e,t,{ids:o,alpha:r}){let n=(a,i)=>{for(let s=0;i&&s<i.count;s++){let p=a[i.start+s];p.color=qr(p.color,r)}};for(let a of o)n(e.nodeStrokes,e.nodeStrokeRuns.get(a));t.forEach(({from:a,to:i},s)=>{(o.has(a)||o.has(i))&&(n(e.edgeCurves,e.edgeCurveRuns.get(s)),n(e.arrows,e.arrowRuns.get(s)))})}function Xs(e){return e<.5?4*e*e*e:1-(-2*e+2)**3/2}function p0(e,t,o,r){return!(e.referenceAxis||t.referenceAxis||e.pixelRows||t.pixelRows||t.tubeMap||r||o>Bs)}function c0(){return typeof requestAnimationFrame<"u"&&!("matchMedia"in window&&window.matchMedia("(prefers-reduced-motion: reduce)").matches)}function d0(e,t,o){let r={frame:0,finish:()=>{e(1)}},n=0,a=performance.now(),i=()=>{if(!t()){e(1),o();return}let s=performance.now();n+=Math.min(s-a,Os),a=s;let p=Math.min(1,n/Cs);e(Xs(p)),p<1?r.frame=requestAnimationFrame(i):o()};return r.frame=requestAnimationFrame(i),r}function m0(e,t,o,r){for(let[n,a]of Object.entries(e)){let i=t[n],s=o[n];!i||!s||a.forEach((p,c)=>{p.x=r===1?s[c].x:i[c].x+(s[c].x-i[c].x)*r,p.y=r===1?s[c].y:i[c].y+(s[c].y-i[c].y)*r})}}function fi(e,t,o){let r=Ao(e,t.nodePositions);return{profile:r,bounds:o&&To(e,t,o),segments:xn(e,t),reference:Rn(r)}}var Lr=new WeakMap;function _0(e,t,o){Lr.has(t)||Lr.set(t,fi(e,t,o))}var Ds=8,Vs=19,hi=Ne+Vs,js=48;function zs(e,t,o){if(!(!e||!t))return Mt(e.rowPx,e.barPx)?o:{untracked:0,unread:0,...o,crowded:!0}}var $0=mi.views(e=>({get paneCeiling(){return Math.max(At,e.paneHeight??mn)},get fitRoom(){return e.host?this.canvasHeight:this.paneCeiling},get walkRowPitch(){let t=e.walkRowBars;if(t)return Nt(t.rows.length+1,this.fitRoom-this.fitPadTop-D-Un(e.walkRowGroups?.sections??[]))},get walkRowPlacement(){let t=this.walkRowPitch;return t?qn(e.walkRowGroups?.sections??[],t.rowPx):void 0},get walkRowGeneKey(){return zs(this.walkRowPitch,!!e.walkRowGenes?.size,e.walkRowGeneGaps)},get drawnRowLabels(){let t=this.walkRowPlacement,o=Ae(e.walkRowBars,e.layoutResult,this.walkRowPitch);return e.walkRowBars&&t?o.map((r,n)=>({...r,y:t.rowY(n)})):o},get visibleRowLabels(){return this.drawnRowLabels.flatMap(({label:t,y:o})=>{let r=e.toScreen({x:0,y:o}).y;return r>=0&&r<=this.canvasHeight?[{label:t,y:o,top:r}]:[]})},get fitPadLeft(){return this.drawnRowLabels.reduce((t,o)=>Math.max(t,Fr(o.label,0).x1+6),D)},get layoutBounds(){let t=e.layoutResult,o=e.walkRowBars,r=o&&t?.extent?Pe(o,this.walkRowPitch):void 0;return t?Ze(t,{region:e.graphRegion,extent:r&&{...r,maxY:r.maxY+(this.walkRowPlacement?.headersPx??0)}}):void 0},get keyColumnPx(){return e.facetPanels||e.tubeMapReads?0:Gt({legendSize:this.framedLegendSize})},get framedLegendSize(){return e.keyFrame??e.legendSize},get drawingWidth(){return e.paneWidth-this.keyColumnPx},get canvasFloor(){return Math.max(At,e.facetPanels?0:It({legendSize:this.framedLegendSize,referenceStripZonePx:e.referenceStripZonePx}))},walkRowReadoutOf(t){let o=e.walkRowBars;return o?an(o,t,{scaleX:e.scaleX,translateX:e.translateX,width:this.drawingWidth,measure:tt},{comparing:e.rowVisitsNeeded}):void 0},get hoveredWalkRowText(){let t=e.walkRowList.findIndex(n=>n.name===e.hoveredWalkRow),o=e.walkRowList[t],r=o?this.walkRowReadoutOf(t):void 0;return o&&r&&(this.walkRowPitch?.readouts===!1||r.cut)?{label:o.label,readout:r.text}:void 0},walkRowAt(t,o){let r=e.walkRowBars,n=this.walkRowPitch,a=this.walkRowPlacement;if(!r||!n||!a)return;let i=a.rowAt((o-e.translateY)/e.scaleY,r.rows.length+1),s=e.walkRowList[i],p=a.rowY(i)*e.scaleY+e.translateY,c=(t-e.translateX)/e.scaleX-r.origin,l=s&&n.readouts?this.walkRowReadoutOf(i):void 0,d=s?(r.origin+me(s))*e.scaleX+e.translateX:0,m=!!l?.cut&&t>=d&&t<=l.x+tt(l.shown);return s&&Math.abs(o-p)<=n.barPx/2+2&&(c>=0&&c<=me(s)||m)?i:void 0},get fitPadTop(){let t=jn(e.tubeMapGenes);return D+Math.max(0,t-1)*Vn+e.referenceStripZonePx},get layoutFit(){return{width:this.drawingWidth,height:this.fitRoom-(e.host?.initialized&&e.showReferenceStrip?$t:0)}},get minFitScale(){let t=this.layoutBounds,o=e.layoutResult,r=o?.tubeMap?.layout.tracks[0]?.width;return t&&t.h>0&&r&&!o.referenceAxis?Math.min(un/r,(this.paneCeiling-this.fitPadTop-D)/t.h):0},get facetSpec(){let{field:t,sort:o,columns:r}=e.facetSetting;return t===""?void 0:o.length===0&&r===void 0?t:{field:t,sort:[...o],...r===void 0?{}:{columns:r}}},get facetPlacement(){let t=e.facetPanels,{field:o,sort:r}=e.facetSetting;return t?_t(t.map(n=>n.walks[0].name),e.hostPlacesX||o===""?"walk":o,r):void 0},facetGridIn(t){let o=this.facetPlacement,r=this.layoutBounds;return o&&r&&r.w>0?Ct({count:o.count,bounds:r,pixelRows:e.pixelRows,width:e.paneWidth,room:t,columns:e.hostPlacesX?1:o.columns??e.facetSetting.columns}):void 0},get facetGrid(){return this.facetGridIn(this.fitRoom-hi)},get canvasHeight(){let t=this.layoutBounds,o=this.paneCeiling;if(!t)return o;let r=this.facetGrid;if(r)return Math.max(At,r.total+hi);let n=this.canvasFloor,a=this.fitPads,i=a.top+a.bottom;if(e.pixelRows)return Math.min(o,Math.max(n,t.h+i));let s=e.paneWidth-this.keyColumnPx-a.left-a.right;return t.w>0&&s>0?Math.min(o,Math.max(n,t.h*Math.max(s/t.w,this.minFitScale)+i)):o},get viewBox(){let t=this.facetGrid;return t?{width:t.width,height:t.height}:{width:e.paneWidth,height:this.canvasHeight}},get fitPads(){return this.facetGrid?{left:ne,top:ne,right:ne,bottom:ne}:{left:this.fitPadLeft,top:this.fitPadTop,right:D,bottom:D}},get usableHeight(){let{top:t,bottom:o}=this.fitPads;return this.viewBox.height-t-o},get snapsHostCut(){let{host:t,graphRegion:o}=e,r=t&&Uo(t);return!!t&&Sa(e.chosenLayoutMode)==="snapped"&&!t.dynamicBlocks.contentBlocks.some(n=>n.reversed&&(n.refName===o?.refName||n.refName===r?.refName))},get followsWindow(){let t=e.layoutResult;return this.snapsHostCut&&e.drawnLayoutMode==="force"&&!!t&&!t.referenceAxis&&!t.pixelRows&&!t.tubeMap&&!e.facetPanels},get trackFit(){return"fit"},get referenceRoom(){return this.canvasHeight},get heldLayout(){let{graph:t,layoutResult:o,graphRegion:r}=e;return t&&o&&this.followsWindow?Lr.get(o)??fi(t,o,r):void 0},get heldReference(){return this.heldLayout?.profile},get heldBounds(){return this.heldLayout?.bounds??this.layoutBounds},get followPads(){return{padLeft:this.fitPadLeft,padTop:this.fitPadTop,padRight:D,padBottom:D}},get heldWindow(){let{host:t}=e;return t&&this.followsWindow?Uo(t):void 0},get viewSpan(){return this.heldWindow?.span},get heldScale(){let t=this.heldReference,o=e.graphRegion,r=this.heldBounds,n=this.viewSpan;return t&&o&&r&&n?_o(this.trackFit)?Eo(t,o,n,this.drawingWidth,this.referenceRoom,this.followPads):Go(t,o,n,r,this.drawingWidth,this.canvasHeight,this.followPads):void 0},get windowTransform(){let{graphRegion:t,layoutResult:o,host:r}=e,n=this.heldWindow,a=n&&r?Ra(r):void 0,i=this.heldReference,s=this.heldScale,p=this.heldBounds,c=this.heldLayout,l=n&&a&&i&&s!==void 0&&p?Bo(i,a,s,p,this.drawingWidth,this.canvasHeight,this.followPads):void 0,d=n&&l&&c&&p&&_o(this.trackFit)?{...l,translateY:Sn({segments:c.segments,reference:c.reference,held:Io(c.profile,n),scale:l.scale,translateX:l.translateX,bounds:p,paneWidth:this.drawingWidth,paneHeight:this.canvasHeight,pads:this.followPads})}:l;return d&&o&&(t?.refName!==n?.refName||t?.assemblyName!==n?.assemblyName)?{...d,translateX:e.paneWidth+this.drawingWidth-d.scale*Po(o.nodePositions).minX}:d},get edgeMarks(){let t=this.followsWindow?this.heldLayout:void 0;return t?vn(t.segments,{scale:e.scale,translateX:e.translateX,translateY:e.translateY},this.drawingWidth,{top:e.referenceStripZonePx,bottom:this.canvasHeight}):void 0},get runsPastEdge(){let t=this.edgeMarks;return!!t&&t.top.length+t.bottom.length>0},get drawingClip(){return this.followsWindow?`inset(0px ${e.paneWidth-this.drawingWidth}px 0px 0px)`:void 0},get fittedTransform(){let t=this.layoutBounds,o=this.facetGrid,{width:r,height:n}=o??{width:this.drawingWidth,height:this.canvasHeight},a=this.fitPads;return this.windowTransform??(t?qe(t,r,n,e.pixelRows,{minScale:this.facetGrid?0:this.minFitScale,padLeft:a.left,padTop:a.top,padRight:a.right,padBottom:a.bottom}):void 0)}})).views(e=>({get tooltipRightPx(){return!e.facetPanels&&e.legendSize.width>0&&It(e)-Fo>e.canvasHeight-js?Gt(e):Ds}})).views(e=>({get liveBuildView(){return{axis:e.axisScale,bounds:cn(Oo(e),gn)}},get buildViewSettled(){let t=e.settledBuildView;return t!==void 0&&t.layout===e.layoutResult&&bn(t.view.axis,e.axisScale)&&dn(t.view.bounds,Oo(e))}})).views(e=>({get buildView(){return e.settledBuildView?.view??e.liveBuildView}})).views(e=>({get geometryPainted(){return yn(e)},get paintSuperseded(){return!this.geometryPainted},get showLoading(){return e.error===void 0&&(e.isLoading||e.hasPendingSource||e.graph!==void 0&&!this.geometryPainted)}})).views(e=>({applySelection(t){let o=e.selectedNode;t.setNodeHighlights(o===null||e.folded.has(o)?new Map:new Map([[o,fn]]))},get hoverLayerNode(){let{litNode:t,selectedNode:o}=e;return t===o?null:t},get paintTransform(){let t=ca();return{scaleX:e.scaleX*t,scaleY:e.scaleY*t,translateX:e.translateX*t,translateY:e.translateY*t,dpr:t}}})).views(e=>({paint(t){t.updateTransform(e.paintTransform),t.render(e.referenceStripShown?[0,0,0,0]:ln)}})).views(e=>({buildDrawing(t,o,r=e.buildView){let{graph:n,nodeById:a,layoutResult:i,deletionDrawing:s}=e;if(!n||!a||!i||!s)return;Je(e.positionsVersion);let p=vt({...st(i,s,{drawsRows:!!e.walkRowBars}),graph:n,nodeById:a,colorScheme:e.effectiveColorScheme,contigThickness:e.contigThickness,connectorThickness:e.connectorThickness,drawPaths:o,nodeWidth:e.nodeWidth,edgeWidth:e.linkWidth,highlight:t,axis:r.axis,linearLayout:e.linearLayout,viewportBounds:r.bounds,referenceRamp:e.referenceRamp,version:e.positionsVersion,smallSites:e.smallSites}),c=e.morphEntering;return c?.layout===i&&ui(p,n.edges,c),{batch:p,view:r}},get facetDrawings(){return e.facetPanels?.map(t=>this.buildDrawing(t,!1))},hoveredOn(t){let o=e.hoveredNode,r=o?e.nodeById?.get(o):void 0;return r?Ho(t,r.id,r.length)??"not on this walk":void 0},get figureUnavailable(){return e.layoutResult?e.walkRowGroups?"The SVG export cannot group walk rows yet: set Group by... to None first":e.drawsNodes||e.walkRowBars?void 0:`${Y(e.chosenLayoutMode).label} draws a picture of its own, which the SVG export does not`:"Nothing is drawn yet"},figure(){let{graph:t,layoutResult:o}=e,r=!!e.host&&!e.facetGrid;return t&&o&&!this.figureUnavailable?ur(t,o,{width:r?e.drawingWidth:e.paneWidth,height:r?e.canvasHeight:e.paneCeiling,frame:r?e.screenTransform:void 0,walks:e.walkLayers,facet:e.facetSpec,colorScheme:e.effectiveColorScheme,nodeWidth:e.nodeWidth,edgeWidth:e.linkWidth,showDeletionEdges:e.showDeletionEdges,smallSites:e.smallSites,linearLayout:e.linearLayout,contigThickness:e.contigThickness,connectorThickness:e.connectorThickness,region:e.graphRegion,colorDomain:e.statedColorDomain,genes:e.showGenes?[...e.backboneGenes??[],...e.ownGeneFeatures??[]]:void 0,walkRows:e.walkRowBars,walkRowPitch:e.walkRowPitch,rowGenes:e.walkRowGenes,rowGeneGaps:e.walkRowGeneGaps,rowAnnotation:e.walkRowAnnotation,walkStrip:e.walkStripRows&&{rows:e.walkStripRows,rowGenes:e.walkRowGenes,rowGeneGaps:e.walkRowGeneGaps}}):void 0}})).views(e=>({get followsHostView(){let t=e.layoutResult;return!!e.host&&!e.hostPlacesX&&!!t&&!t.referenceAxis&&!t.pixelRows&&!t.tubeMap&&!e.facetGrid}}));var Mr=z(U("path",{d:"M3 16h5v-2H3zm6.5 0h5v-2h-5zm6.5 0h5v-2h-5zM3 20h2v-2H3zm4 0h2v-2H7zm4 0h2v-2h-2zm4 0h2v-2h-2zm4 0h2v-2h-2zM3 12h8v-2H3zm10 0h8v-2h-8zM3 4v4h18V4z"}),"LineStyle");var gi=z(U("path",{d:"M9.01 14H2v2h7.01v3L13 15l-3.99-4zm5.98-1v-3H22V8h-7.01V5L11 9z"}),"CompareArrows");var wi=z(U("path",{d:"M17 5h-2V3h2zm-2 16h2v-2.59L19.59 21 21 19.59 18.41 17H21v-2h-6zm4-12h2V7h-2zm0 4h2v-2h-2zm-8 8h2v-2h-2zM7 5h2V3H7zM3 17h2v-2H3zm2 4v-2H3c0 1.1.9 2 2 2M19 3v2h2c0-1.1-.9-2-2-2m-8 2h2V3h-2zM3 9h2V7H3zm4 12h2v-2H7zm-4-8h2v-2H3zm0-8h2V3c-1.1 0-2 .9-2 2"}),"HighlightAlt");var Ys="Linear genome view",Ks="Linear synteny view",Us="No synteny track in this session aligns these assemblies";function bi({label:e,icon:t,entries:o,entryLabel:r,onSelect:n,disabledHelpText:a,nameTheOnlyEntry:i=!0}){let[s]=o,p=a?[{label:e,icon:t,disabled:!0,disabledHelpText:a,onClick:()=>{}}]:[];return o.length===0?p:o.length===1&&s?[{label:i?`${e} \u2014 ${r(s)}`:e,icon:t,onClick:n(s)}]:[{label:e,icon:t,type:"subMenu",subMenu:o.map(c=>({label:r(c),onClick:n(c)}))}]}function Q0({contributors:e,linearContributors:t=e,syntenyTracks:o,onShowLinear:r,onShowSynteny:n}){let a=o[0]?.coverage??e.length;return[...bi({label:Ys,icon:Mr,entries:t,entryLabel:i=>`${i.sample} ${ue(i)}`,onSelect:i=>()=>{r({location:i,assembly:i.sample})}}),...e.length>=2?bi({label:`${Ks} (${a} assemblies)`,icon:gi,entries:o,entryLabel:i=>i.coverage<a?`${i.name} (${i.coverage} of ${a})`:i.name,nameTheOnlyEntry:!1,disabledHelpText:Us,onSelect:i=>()=>{n(i.trackId)}}):[]]}function eM({own:e,reference:t,highlight:o,onShowLinear:r,onHighlight:n}){let a=[e?{label:`Open in ${e.assembly} \u2014 ${ue(e.location)}`,target:e}:void 0,t&&t.assembly!==e?.assembly?{label:`Open in ${t.assembly} \u2014 around this node`,target:t}:void 0].filter(i=>i!==void 0);return[...n&&o?[{label:`Highlight in ${o.assembly}`,icon:wi,onClick:()=>{n(o)}}]:[],...a.map(({label:i,target:s})=>({label:i,icon:Mr,onClick:()=>{r(s)}}))]}var nM=z(U("path",{d:"M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5M12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5m0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3"}),"Visibility");export{z as a,ga as b,zt as c,Ii as d,Y as e,Kc as f,Jc as g,ka as h,Uo as i,Bi as j,Sa as k,Ci as l,Oc as m,_c as n,$c as o,ue as p,Di as q,Vi as r,qo as s,V as t,va as u,Ea as v,Hd as w,Jo as x,zd as y,Qo as z,Yd as A,Kd as B,Ud as C,qd as D,Fa as E,nM as F,Qi as G,es as H,ts as I,ar as J,ir as K,Ut as L,pr as M,xr as N,Xi as O,Ma as P,rv as Q,iv as R,cv as S,i0 as T,s0 as U,p0 as V,c0 as W,d0 as X,m0 as Y,_0 as Z,Ds as _,Vs as $,hi as aa,$0 as ba,Mr as ca,Q0 as da,eM as ea};
3
+ //# sourceMappingURL=chunk-4MTS65XF.js.map