jbrowse-plugin-graphgenomeviewer 7.4.3 → 7.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. package/README.md +10 -7
  2. package/dist/chunks/{AddTrackWorkflow-LK25EC3H.js → AddTrackWorkflow-NLSZYK56.js} +2 -2
  3. package/dist/chunks/{GbzBaseSyntenyAdapter-EKLUEECW.js → GbzBaseSyntenyAdapter-4KVWVUN6.js} +2 -2
  4. package/dist/chunks/{GbzBaseSyntenyAdapter-EKLUEECW.js.map → GbzBaseSyntenyAdapter-4KVWVUN6.js.map} +1 -1
  5. package/dist/chunks/{GraphGenomeView-P3XMSKUQ.js → GraphGenomeView-KI4FQ5A7.js} +2 -2
  6. package/dist/chunks/GraphTrackSettingsDialog-UQNMDXTE.js +4 -0
  7. package/dist/chunks/GraphTrackSettingsDialog-UQNMDXTE.js.map +7 -0
  8. package/dist/chunks/{HighlightColorDialog-G6AFRYUD.js → HighlightColorDialog-D4RCUCUF.js} +2 -2
  9. package/dist/chunks/LinearGraphDisplay-RPZUZSM2.js +2 -0
  10. package/dist/chunks/{LinearGraphDisplay-O4SQSXJJ.js.map → LinearGraphDisplay-RPZUZSM2.js.map} +2 -2
  11. package/dist/chunks/MinigraphBubbleAdapter-TJYI7KEN.js +2 -0
  12. package/dist/chunks/{MinigraphBubbleAdapter-3NJ2VLN2.js.map → MinigraphBubbleAdapter-TJYI7KEN.js.map} +1 -1
  13. package/dist/chunks/RgfaTabixAdapter-5ZMJLFZP.js +2 -0
  14. package/dist/chunks/RgfaTabixAdapter-5ZMJLFZP.js.map +7 -0
  15. package/dist/chunks/WalkFormsAdapter-CAJOWOEX.js +2 -0
  16. package/dist/chunks/WalkFormsAdapter-CAJOWOEX.js.map +7 -0
  17. package/dist/chunks/WalkTabixSyntenyAdapter-VI3KA2GX.js +2 -0
  18. package/dist/chunks/{WalkTabixSyntenyAdapter-NHNSZZBX.js.map → WalkTabixSyntenyAdapter-VI3KA2GX.js.map} +2 -2
  19. package/dist/chunks/{chunk-MCE6STZR.js → chunk-22ANI2KL.js} +2 -2
  20. package/dist/chunks/{chunk-MCE6STZR.js.map → chunk-22ANI2KL.js.map} +1 -1
  21. package/dist/chunks/chunk-42KD4AVY.js +2 -0
  22. package/dist/chunks/{chunk-OKRGO7XA.js.map → chunk-42KD4AVY.js.map} +4 -4
  23. package/dist/chunks/chunk-4NIWMRKH.js +2 -0
  24. package/dist/chunks/chunk-4NIWMRKH.js.map +7 -0
  25. package/dist/chunks/chunk-BCOXRUNQ.js +3 -0
  26. package/dist/chunks/chunk-BCOXRUNQ.js.map +7 -0
  27. package/dist/chunks/chunk-DAPI7M4M.js +4 -0
  28. package/dist/chunks/chunk-DAPI7M4M.js.map +7 -0
  29. package/dist/chunks/chunk-DEWZOJSC.js +2 -0
  30. package/dist/chunks/{chunk-6OXXT2YP.js.map → chunk-DEWZOJSC.js.map} +4 -4
  31. package/dist/chunks/{chunk-K4TFAHGC.js → chunk-FCMXEFJA.js} +1 -1
  32. package/dist/chunks/{chunk-K4TFAHGC.js.map → chunk-FCMXEFJA.js.map} +1 -1
  33. package/dist/chunks/{chunk-UOFWYS6T.js → chunk-GYY6LF5L.js} +1 -1
  34. package/dist/chunks/{chunk-UOFWYS6T.js.map → chunk-GYY6LF5L.js.map} +1 -1
  35. package/dist/chunks/{chunk-F2DMEJEK.js → chunk-HHMJNAA3.js} +2 -2
  36. package/dist/chunks/{chunk-NPV7SRJD.js → chunk-HTTONSO4.js} +2 -2
  37. package/dist/chunks/{chunk-NPV7SRJD.js.map → chunk-HTTONSO4.js.map} +1 -1
  38. package/dist/chunks/{chunk-MVVXRZXV.js → chunk-JRJHXLGP.js} +2 -2
  39. package/dist/chunks/{chunk-MVVXRZXV.js.map → chunk-JRJHXLGP.js.map} +2 -2
  40. package/dist/chunks/chunk-K4JL57NR.js +2 -0
  41. package/dist/chunks/chunk-K4JL57NR.js.map +7 -0
  42. package/dist/chunks/chunk-KOC23YNN.js +4 -0
  43. package/dist/chunks/chunk-KOC23YNN.js.map +7 -0
  44. package/dist/chunks/{chunk-MNCPMOHJ.js → chunk-LTNFVL2F.js} +2 -2
  45. package/dist/chunks/chunk-OZEKEYT3.js +2 -0
  46. package/dist/chunks/{chunk-ZAYC5OMQ.js.map → chunk-OZEKEYT3.js.map} +4 -4
  47. package/dist/chunks/{chunk-DUPBXBYE.js → chunk-POUV7OPY.js} +2 -2
  48. package/dist/chunks/{chunk-DUPBXBYE.js.map → chunk-POUV7OPY.js.map} +1 -1
  49. package/dist/chunks/{chunk-CNNZDE6I.js → chunk-SPL3UO2D.js} +2 -2
  50. package/dist/chunks/{chunk-CNNZDE6I.js.map → chunk-SPL3UO2D.js.map} +1 -1
  51. package/dist/chunks/{chunk-QJ43NDYS.js → chunk-TYV6UXJA.js} +2 -2
  52. package/dist/chunks/chunk-UR2MJJUP.js +2 -0
  53. package/dist/chunks/chunk-VTMJQFN5.js +2 -0
  54. package/dist/chunks/chunk-VTMJQFN5.js.map +7 -0
  55. package/dist/chunks/{chunk-CXOMX2I6.js → chunk-XZGYJ3JC.js} +1 -1
  56. package/dist/chunks/{chunk-CXOMX2I6.js.map → chunk-XZGYJ3JC.js.map} +1 -1
  57. package/dist/chunks/{chunk-TGSDXZXI.js → chunk-Z3IKZAYC.js} +2 -2
  58. package/dist/chunks/{chunk-TGSDXZXI.js.map → chunk-Z3IKZAYC.js.map} +1 -1
  59. package/dist/chunks/chunk-ZV5FNOHS.js +3 -0
  60. package/dist/chunks/chunk-ZV5FNOHS.js.map +7 -0
  61. package/dist/chunks/{renderSvg-7G6NWBXF.js → renderSvg-3PPAEMBT.js} +2 -2
  62. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js +4 -4
  63. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js.map +4 -4
  64. package/package.json +3 -3
  65. package/src/GraphComputeLayout.test.ts +24 -0
  66. package/src/GraphComputeLayout.ts +4 -2
  67. package/src/GraphGenomeView/components/GraphSettingsDialog.tsx +16 -0
  68. package/src/GraphGenomeView/components/WalkRowsOverlay.tsx +83 -0
  69. package/src/GraphGenomeView/components/usePaneGestures.test.tsx +82 -5
  70. package/src/GraphGenomeView/components/usePaneGestures.ts +10 -4
  71. package/src/GraphGenomeView/graphLayers.ts +14 -1
  72. package/src/GraphGenomeView/legendSections.ts +32 -0
  73. package/src/GraphGenomeView/model.test.ts +294 -113
  74. package/src/GraphGenomeView/model.ts +3 -10
  75. package/src/GraphGenomeView/nodeSize.test.ts +21 -5
  76. package/src/GraphGenomeView/nodeSize.ts +24 -8
  77. package/src/GraphGenomeView/pane/fitViews.ts +5 -110
  78. package/src/GraphGenomeView/pane/graphViews.ts +96 -20
  79. package/src/GraphGenomeView/pane/launchActions.ts +55 -33
  80. package/src/GraphGenomeView/pane/launchViews.ts +46 -0
  81. package/src/GraphGenomeView/pane/loadActions.ts +85 -25
  82. package/src/GraphGenomeView/pane/morph.test.ts +25 -1
  83. package/src/GraphGenomeView/pane/morph.ts +3 -1
  84. package/src/GraphGenomeView/pane/paneBase.ts +5 -7
  85. package/src/GraphGenomeView/pane/renderingActions.ts +61 -2
  86. package/src/GraphGenomeView/pane/settingActions.ts +62 -4
  87. package/src/GraphGenomeView/pane/walkRowViews.ts +17 -6
  88. package/src/GraphGenomeView/tubeMapPanels.ts +2 -1
  89. package/src/GraphGenomeView/viewModel.ts +4 -9
  90. package/src/GraphGenomeView/walkRowBlocks.ts +50 -0
  91. package/src/LinearGraphDisplay/LinearGraphDisplay.test.ts +35 -5
  92. package/src/LinearGraphDisplay/components/GraphStatusChrome.test.tsx +18 -0
  93. package/src/LinearGraphDisplay/components/GraphStatusChrome.tsx +4 -2
  94. package/src/LinearGraphDisplay/components/SubgraphHaplotypesField.test.tsx +41 -1
  95. package/src/LinearGraphDisplay/components/SubgraphHaplotypesField.tsx +33 -19
  96. package/src/LinearGraphDisplay/configSchema.ts +4 -3
  97. package/src/RgfaTabixAdapter/RgfaTabixAdapter.ts +2 -9
  98. package/src/RgfaTabixAdapter/configSchema.ts +3 -3
  99. package/src/RgfaTabixAdapter/walkFiles.test.ts +6 -6
  100. package/src/WalkFormsAdapter/WalkFormsAdapter.test.ts +204 -0
  101. package/src/WalkFormsAdapter/WalkFormsAdapter.ts +232 -0
  102. package/src/WalkFormsAdapter/configSchema.ts +127 -0
  103. package/src/WalkFormsAdapter/formRows.test.ts +258 -0
  104. package/src/WalkFormsAdapter/formRows.ts +231 -0
  105. package/src/WalkFormsAdapter/formsMenu.test.ts +237 -0
  106. package/src/WalkFormsAdapter/formsMenu.ts +202 -0
  107. package/src/WalkFormsAdapter/index.ts +21 -0
  108. package/src/WalkFormsAdapter/pinned.ts +33 -0
  109. package/src/WalkTabixSyntenyAdapter/WalkTabixSyntenyAdapter.test.ts +5 -5
  110. package/src/WalkTabixSyntenyAdapter/WalkTabixSyntenyAdapter.ts +3 -6
  111. package/src/WalkTabixSyntenyAdapter/configSchema.ts +2 -2
  112. package/src/hoverSync/graphViewHighlights.test.ts +53 -0
  113. package/src/hoverSync/graphViewHighlights.ts +25 -0
  114. package/src/hoverSync/lgvHover.test.ts +100 -1
  115. package/src/hoverSync/lgvHover.ts +77 -6
  116. package/src/index.ts +4 -0
  117. package/src/launchFromGraph/contributors.test.ts +52 -0
  118. package/src/launchFromGraph/contributors.ts +105 -1
  119. package/src/launchFromGraph/launchFromGraph.ts +2 -2
  120. package/src/panSNAliases/panSNAliases.test.ts +2 -2
  121. package/src/panSNTabix.test.ts +28 -0
  122. package/src/panSNTabix.ts +26 -8
  123. package/src/version.ts +1 -1
  124. package/dist/chunks/GraphTrackSettingsDialog-UTYH6HEC.js +0 -6
  125. package/dist/chunks/GraphTrackSettingsDialog-UTYH6HEC.js.map +0 -7
  126. package/dist/chunks/LinearGraphDisplay-O4SQSXJJ.js +0 -2
  127. package/dist/chunks/MinigraphBubbleAdapter-3NJ2VLN2.js +0 -2
  128. package/dist/chunks/RgfaTabixAdapter-55DGDID2.js +0 -2
  129. package/dist/chunks/RgfaTabixAdapter-55DGDID2.js.map +0 -7
  130. package/dist/chunks/WalkTabixSyntenyAdapter-NHNSZZBX.js +0 -2
  131. package/dist/chunks/chunk-4I3K4RHE.js +0 -2
  132. package/dist/chunks/chunk-4I3K4RHE.js.map +0 -7
  133. package/dist/chunks/chunk-6OXXT2YP.js +0 -2
  134. package/dist/chunks/chunk-NFH2U74B.js +0 -2
  135. package/dist/chunks/chunk-OKRGO7XA.js +0 -2
  136. package/dist/chunks/chunk-P7VMOTUM.js +0 -3
  137. package/dist/chunks/chunk-P7VMOTUM.js.map +0 -7
  138. package/dist/chunks/chunk-RU4WSKBO.js +0 -3
  139. package/dist/chunks/chunk-RU4WSKBO.js.map +0 -7
  140. package/dist/chunks/chunk-WGTLNVST.js +0 -2
  141. package/dist/chunks/chunk-WGTLNVST.js.map +0 -7
  142. package/dist/chunks/chunk-XQFBLJU5.js +0 -4
  143. package/dist/chunks/chunk-XQFBLJU5.js.map +0 -7
  144. package/dist/chunks/chunk-Y5DNBFDY.js +0 -3
  145. package/dist/chunks/chunk-Y5DNBFDY.js.map +0 -7
  146. package/dist/chunks/chunk-ZAYC5OMQ.js +0 -2
  147. package/src/launchFromGraph/launchTracks.test.ts +0 -95
  148. package/src/launchFromGraph/launchTracks.ts +0 -49
  149. /package/dist/chunks/{AddTrackWorkflow-LK25EC3H.js.map → AddTrackWorkflow-NLSZYK56.js.map} +0 -0
  150. /package/dist/chunks/{GraphGenomeView-P3XMSKUQ.js.map → GraphGenomeView-KI4FQ5A7.js.map} +0 -0
  151. /package/dist/chunks/{HighlightColorDialog-G6AFRYUD.js.map → HighlightColorDialog-D4RCUCUF.js.map} +0 -0
  152. /package/dist/chunks/{chunk-F2DMEJEK.js.map → chunk-HHMJNAA3.js.map} +0 -0
  153. /package/dist/chunks/{chunk-MNCPMOHJ.js.map → chunk-LTNFVL2F.js.map} +0 -0
  154. /package/dist/chunks/{chunk-QJ43NDYS.js.map → chunk-TYV6UXJA.js.map} +0 -0
  155. /package/dist/chunks/{chunk-NFH2U74B.js.map → chunk-UR2MJJUP.js.map} +0 -0
  156. /package/dist/chunks/{renderSvg-7G6NWBXF.js.map → renderSvg-3PPAEMBT.js.map} +0 -0
  157. /package/src/RgfaTabixAdapter/test_data/{walks4_follow.GRCh38.walks.bed.gz → walks5_follow.GRCh38.walks.bed.gz} +0 -0
  158. /package/src/RgfaTabixAdapter/test_data/{walks4_follow.GRCh38.walks.bed.gz.tbi → walks5_follow.GRCh38.walks.bed.gz.tbi} +0 -0
  159. /package/src/RgfaTabixAdapter/test_data/{walks4_header.GRCh38.walks.bed.gz → walks5_header.GRCh38.walks.bed.gz} +0 -0
  160. /package/src/RgfaTabixAdapter/test_data/{walks4_header.GRCh38.walks.bed.gz.tbi → walks5_header.GRCh38.walks.bed.gz.tbi} +0 -0
  161. /package/src/RgfaTabixAdapter/test_data/{walks4_inversion.GRCh38.walks.bed.gz → walks5_inversion.GRCh38.walks.bed.gz} +0 -0
  162. /package/src/RgfaTabixAdapter/test_data/{walks4_inversion.GRCh38.walks.bed.gz.tbi → walks5_inversion.GRCh38.walks.bed.gz.tbi} +0 -0
  163. /package/src/RgfaTabixAdapter/test_data/{walks4_lanepairs.GRCh38.walks.bed.gz → walks5_lanepairs.GRCh38.walks.bed.gz} +0 -0
  164. /package/src/RgfaTabixAdapter/test_data/{walks4_lanepairs.GRCh38.walks.bed.gz.tbi → walks5_lanepairs.GRCh38.walks.bed.gz.tbi} +0 -0
  165. /package/src/RgfaTabixAdapter/test_data/{walks4_maxnode.GRCh38.walks.bed.gz → walks5_maxnode.GRCh38.walks.bed.gz} +0 -0
  166. /package/src/RgfaTabixAdapter/test_data/{walks4_maxnode.GRCh38.walks.bed.gz.tbi → walks5_maxnode.GRCh38.walks.bed.gz.tbi} +0 -0
  167. /package/src/RgfaTabixAdapter/test_data/{walks4_rejoin.GRCh38.walks.bed.gz → walks5_rejoin.GRCh38.walks.bed.gz} +0 -0
  168. /package/src/RgfaTabixAdapter/test_data/{walks4_rejoin.GRCh38.walks.bed.gz.tbi → walks5_rejoin.GRCh38.walks.bed.gz.tbi} +0 -0
  169. /package/src/RgfaTabixAdapter/test_data/{walks4_twopart.GRCh38.walks.bed.gz → walks5_twopart.GRCh38.walks.bed.gz} +0 -0
  170. /package/src/RgfaTabixAdapter/test_data/{walks4_twopart.GRCh38.walks.bed.gz.tbi → walks5_twopart.GRCh38.walks.bed.gz.tbi} +0 -0
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/GraphGenomeView/components/PaneLayer.tsx", "../../src/GraphGenomeView/components/BubbleHalos.tsx", "../../src/GraphGenomeView/legendSections.ts", "../../src/GraphGenomeView/components/ElTree.tsx", "../../src/GraphGenomeView/components/LegendSwatch.tsx", "../../src/GraphGenomeView/components/GenePins.tsx", "../../src/GraphGenomeView/components/LabelChip.tsx", "../../src/GraphGenomeView/components/LabelLayer.tsx", "../../src/GraphGenomeView/components/ReferenceStripOverlay.tsx", "../../src/GraphGenomeView/components/TubeMapOverlay.tsx", "host:@jbrowse/render-core/marks", "../../src/GraphGenomeView/walkRowSpans.ts", "../../src/GraphGenomeView/components/WalkRowsOverlay.tsx"],
4
- "sourcesContent": ["import { useEffect, useRef } from 'react'\nimport type { ReactNode } from 'react'\n\nimport { syncCanvasSize } from '@jbrowse/bandage-core/renderer/canvas'\nimport { autorun } from 'mobx'\nimport { observer } from 'mobx-react'\n\nimport { dependOn } from '../pane/paneBase'\nimport { trackedDpr } from '../trackedDpr'\n\nimport type { GraphPaneModel } from '../model'\n\n// marks an overlay whose labels move with the drawing, so a press on one pans\nexport const PANS_WITH_DRAWING = 'data-pans-with-drawing'\n\n// A layer over the pane's canvas that leaves the pointer to it\nexport function paneLayerStyle(\n zIndex: number,\n overflow?: 'hidden' | 'visible',\n) {\n return {\n position: 'absolute' as const,\n left: 0,\n top: 0,\n pointerEvents: 'none' as const,\n overflow,\n zIndex,\n }\n}\n\n// An SVG the pane's size, over the canvas or inside PaneSvg's export\nexport const PaneSvgLayer = observer(function PaneSvgLayer({\n model,\n zIndex,\n overflow = 'hidden',\n testId,\n pansWithDrawing,\n children,\n}: {\n model: GraphPaneModel\n zIndex: number\n overflow?: 'hidden' | 'visible'\n testId?: string\n pansWithDrawing?: boolean\n children: ReactNode\n}) {\n return (\n <svg\n style={{\n ...paneLayerStyle(zIndex, overflow),\n userSelect: pansWithDrawing ? 'none' : undefined,\n }}\n width={model.paneWidth}\n height={model.canvasHeight}\n data-testid={testId}\n {...(pansWithDrawing ? { [PANS_WITH_DRAWING]: '' } : {})}\n >\n {children}\n </svg>\n )\n})\n\n// Layout units onto the screen. Its own observer, so a pan frame re-renders\n// this group's transform and not the children a parent built.\nexport const PaneTransformGroup = observer(function PaneTransformGroup({\n model,\n children,\n}: {\n model: GraphPaneModel\n children: ReactNode\n}) {\n const { scaleX, scaleY, translateX, translateY } = model\n return (\n <g\n transform={`translate(${translateX} ${translateY}) scale(${scaleX} ${scaleY})`}\n >\n {children}\n </g>\n )\n})\n\n// A canvas the pane's size that an autorun repaints, so a pan moves its ink in\n// the same frame as the drawing. `paint` draws in css px.\nexport function PaneOverlayCanvas({\n model,\n zIndex,\n shown = true,\n testId,\n paint,\n}: {\n model: GraphPaneModel\n zIndex: number\n shown?: boolean\n testId: string\n paint: (ctx: CanvasRenderingContext2D, dpr: number) => void\n}) {\n const ref = useRef<HTMLCanvasElement>(null)\n useEffect(() => {\n if (!shown) {\n return undefined\n }\n return autorun(() => {\n const canvas = ref.current\n const ctx = canvas?.getContext('2d')\n if (canvas && ctx) {\n const width = model.paneWidth\n const height = model.canvasHeight\n dependOn(trackedDpr())\n const dpr = syncCanvasSize(canvas, width, height)\n ctx.setTransform(dpr, 0, 0, dpr, 0, 0)\n ctx.clearRect(0, 0, width, height)\n paint(ctx, dpr)\n }\n })\n }, [model, shown, paint])\n return (\n <canvas\n ref={ref}\n data-testid={shown ? testId : undefined}\n style={{ ...paneLayerStyle(zIndex), display: shown ? 'block' : 'none' }}\n />\n )\n}\n", "import { bubbleKey, sameBubble } from '@jbrowse/bandage-core/bubbles/bubbleLine'\nimport { BUBBLE_KIND_COLORS } from '@jbrowse/bandage-core/bubbles/classifyBubble'\nimport { HALO_FACTOR } from '@jbrowse/bandage-core/labelLayout'\nimport { observer } from 'mobx-react'\n\nimport { PaneSvgLayer, PaneTransformGroup } from './PaneLayer'\n\nimport type { GraphPaneModel } from '../model'\n\n// The bubbles over a node drawing: each a translucent halo along its nodes,\n// drawn once in layout units and moved with the canvas by one transform. The\n// halo takes no pointer events, so the nodes under it still hover and drag;\n// its name and its routes' chips are LabelLayer's. A small variant is\n// LabelLayer's tick, and shows its halo only while hovered.\n\nconst BubbleHalos = observer(function BubbleHalos({\n model,\n}: {\n model: GraphPaneModel\n}) {\n const { bubbleHalos, hoveredBubble } = model\n if (bubbleHalos.length === 0) {\n return null\n }\n const halo = model.contigThickness * HALO_FACTOR\n return (\n <PaneSvgLayer model={model} zIndex={2} testId=\"graph-bubble-halos\">\n <PaneTransformGroup model={model}>\n {bubbleHalos\n .filter(\n h =>\n !h.whole &&\n (!h.tick ||\n (hoveredBubble && sameBubble(h.bubble, hoveredBubble))),\n )\n .map(h => (\n <path\n key={bubbleKey(h.bubble)}\n d={h.path}\n fill=\"none\"\n stroke={BUBBLE_KIND_COLORS[h.kind]}\n strokeOpacity={\n hoveredBubble && sameBubble(h.bubble, hoveredBubble)\n ? 0.45\n : model.bubbleFaded(h)\n ? 0.06\n : 0.22\n }\n strokeWidth={halo}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n vectorEffect=\"non-scaling-stroke\"\n />\n ))}\n </PaneTransformGroup>\n </PaneSvgLayer>\n )\n})\n\nexport default BubbleHalos\n", "import { sameBubble } from '@jbrowse/bandage-core/bubbles/bubbleLine'\nimport {\n BUBBLE_KIND_COLORS,\n BUBBLE_KIND_NAMES,\n} from '@jbrowse/bandage-core/bubbles/classifyBubble'\nimport { EXON_COLOR } from '@jbrowse/bandage-core/genes/exonOutline'\nimport { formatBp } from '@jbrowse/bandage-core/graphLabels'\nimport {\n BAR_PX as WALK_ROW_BAR_PX,\n CALL_TICK,\n DISAGREES,\n GENE_INK,\n UNBACKED_TICK,\n walkRowsKey,\n} from '@jbrowse/bandage-core/layout/walkRowDraw'\nimport { RAMP_GRADIENT_STOPS } from '@jbrowse/bandage-core/referenceRampCss'\nimport {\n LIFT_BACKDROP_CSS,\n REFERENCE_RAMP_ALT_CSS,\n} from '@jbrowse/bandage-core/renderer/GeometryBuilder'\nimport { deviationInk } from '@jbrowse/bandage-core/tubeMap/deviations'\nimport {\n FORWARD_READ_COLORS,\n REVERSE_READ_COLORS,\n} from '@jbrowse/bandage-core/tubeMap/reads'\nimport { encodingStops } from '@jbrowse/bandage-core/walkEncoding'\nimport { walkKey } from '@jbrowse/bandage-core/walkKey'\n\nimport { CALL_TOLERANCE } from './repeats/walkCalls'\nimport { PANEL_REFERENCE_TUBE } from './tubeMapPanels'\n\nimport type { GraphPaneModel } from './model'\nimport type { KeySwatch } from '@jbrowse/bandage-core/layout/walkRowDraw'\nimport type { LiftedWalk } from '@jbrowse/bandage-core/walkHighlight'\n\n// The legend as data, so the screen's panel and the exported figure's key\n// draw the same rows from one place\n\nexport const SWATCH_PX = 18\nconst BAR_PX = 48\n\n// LIFT_BACKDROP_CSS reads paler alone than faded strokes do where they\n// overlap, so the key samples it darker\nconst FADED_SWATCH = 'rgba(160, 160, 160, 0.45)'\n\nconst STRIP_SAMPLES = 6\nconst TUBE_SWATCH_PX = 7\nconst FOLD_TICK_BACKING = '#b8b8c0'\nconst WALK_ROW_SWATCH_PX = WALK_ROW_BAR_PX - 4\n\nexport interface Stop {\n offset: number\n color: string\n}\n\nexport type LegendSwatch =\n | {\n kind: 'fill'\n stops: Stop[]\n width?: number\n height?: number\n square?: boolean\n }\n // the reference strip, a band per lifted walk\n | { kind: 'bands'; bands: Stop[][] }\n | { kind: 'line'; color: string }\n | { kind: 'halo'; color: string }\n | {\n kind: 'outline'\n color: string\n stroke: number\n radius: number\n height: number\n }\n | { kind: 'overhang' }\n | { kind: 'glyph'; char: string }\n | { kind: 'tick'; color: string; height: number; backing?: string }\n | { kind: 'bracket' }\n | { kind: 'blank' }\n\n// A row with no swatch is a note on the drawing\nexport interface LegendRow {\n key: string\n label: string\n swatch?: LegendSwatch\n strong?: string\n under?: string\n title?: string\n walk?: LiftedWalk\n closesBubble?: true\n}\n\ninterface LegendSection {\n testid: string\n rows: LegendRow[]\n}\n\nexport function swatchWidth(swatch: LegendSwatch) {\n return swatch.kind === 'fill' ? (swatch.width ?? SWATCH_PX) : SWATCH_PX\n}\n\nconst flat = (color: string): Stop[] => [{ offset: 0, color }]\n\nfunction fillRow(\n key: string,\n color: string,\n label: string,\n width = SWATCH_PX,\n): LegendRow {\n return { key, label, swatch: { kind: 'fill', stops: flat(color), width } }\n}\n\n// hard-edged bands, a read taking one shade of its strand's palette\nfunction bandStops(colors: readonly string[]) {\n return colors.flatMap((color, i) => [\n { offset: i / colors.length, color },\n { offset: (i + 1) / colors.length, color },\n ])\n}\n\nfunction openBubbleRows(model: GraphPaneModel): LegendRow[] {\n const open = model.openBubble\n if (!open) {\n return []\n }\n const halo = model.bubbleHalos.find(h => sameBubble(h.bubble, open))\n return [\n {\n key: 'open',\n label: `open: ${halo?.label ?? 'bubble'}`,\n swatch: halo\n ? { kind: 'halo', color: BUBBLE_KIND_COLORS[halo.kind] }\n : { kind: 'blank' },\n closesBubble: true,\n },\n ]\n}\n\n// Under lifted walks each lane states its own scale, and the rest is grey\nfunction rampRows(model: GraphPaneModel): LegendRow[] {\n const domain = model.walkLift ? undefined : model.referenceRampDomain\n if (!domain) {\n return []\n }\n // a measured domain runs between node midpoints, which can fall on a half bp\n const start = Math.round(domain.start)\n const end = Math.round(domain.end)\n return [\n {\n key: 'ramp',\n label: `${start.toLocaleString('en-US')}-${end.toLocaleString('en-US')} (${formatBp(end - start)})`,\n swatch: { kind: 'fill', stops: RAMP_GRADIENT_STOPS, width: BAR_PX },\n },\n ...(model.referenceRampDrawsOffReference\n ? [fillRow('off', REFERENCE_RAMP_ALT_CSS, 'off the reference', BAR_PX)]\n : []),\n ]\n}\n\n// The strip's own colours: a band per lifted walk in its lane's, else the\n// node scheme's, a few of its blocks in bp order rather than a rainbow it\n// does not draw\nfunction stripBands(model: GraphPaneModel): Stop[][] {\n const lift = model.walkLift\n if (lift) {\n return lift.walks.map(w => encodingStops(w.encoding))\n }\n if (model.effectiveColorScheme === 'reference-position') {\n return [RAMP_GRADIENT_STOPS]\n }\n const colors = model.referenceStripBlocks\n .map(b => b.colors[0]!)\n .filter((c, i, all) => c !== all[i - 1])\n const n = Math.min(STRIP_SAMPLES, colors.length)\n return [\n n === 0\n ? flat(LIFT_BACKDROP_CSS)\n : Array.from({ length: n }, (_, i) => ({\n offset: n > 1 ? i / (n - 1) : 0,\n color:\n colors[\n n > 1 ? Math.round((i * (colors.length - 1)) / (n - 1)) : 0\n ]!,\n })),\n ]\n}\n\nfunction stripRows(model: GraphPaneModel): LegendRow[] {\n if (!model.referenceStripShown) {\n return []\n }\n const rowPerWalk = (model.walkLift?.walks.length ?? 0) > 1\n return [\n {\n key: 'strip',\n label: `top strip: reference${rowPerWalk ? ', a row per walk' : ''}`,\n swatch: { kind: 'bands', bands: stripBands(model) },\n },\n ...(model.referenceStripFaded\n ? [\n fillRow(\n 'strip-faded',\n LIFT_BACKDROP_CSS,\n model.walkLift\n ? `reference not on ${rowPerWalk ? \"that row's walk\" : model.liftedWalksLabel}`\n : 'reference outside the open bubble',\n ),\n ]\n : []),\n ...(model.referenceStripOverhangs\n ? [\n {\n key: 'overhang',\n label: 'graph runs past this edge',\n swatch: { kind: 'overhang' } as const,\n },\n ]\n : []),\n ]\n}\n\n// One row per halo colour drawn, naming the kinds it stands for\nfunction haloRows(model: GraphPaneModel): LegendRow[] {\n const kindsByColor = new Map<string, Set<string>>()\n for (const h of model.bubbleHalos) {\n if (!h.whole) {\n const color = BUBBLE_KIND_COLORS[h.kind]\n const kinds = kindsByColor.get(color) ?? new Set<string>()\n kinds.add(BUBBLE_KIND_NAMES[h.kind])\n kindsByColor.set(color, kinds)\n }\n }\n return [...kindsByColor].map(([color, kinds]) => {\n const names = [...kinds].join(' or ')\n return {\n key: `halo-${color}`,\n label:\n names === BUBBLE_KIND_NAMES.superbubble ? names : `${names} bubble`,\n swatch: { kind: 'halo', color },\n }\n })\n}\n\nfunction geneRows(model: GraphPaneModel): LegendRow[] {\n return model.genePins.some(pin => pin.exonsByNode.length > 0)\n ? [\n {\n key: 'exon',\n label: 'exon',\n swatch: {\n kind: 'outline',\n color: EXON_COLOR,\n stroke: 2,\n radius: 5,\n height: 8,\n },\n },\n ]\n : []\n}\n\nfunction foldRows(model: GraphPaneModel): LegendRow[] {\n const note = model.foldNote\n return note ? [{ key: 'fold', label: note }] : []\n}\n\nfunction pathRows(model: GraphPaneModel): LegendRow[] {\n return model.pathLegend.map(({ name, label, color }) => ({\n key: `path-${name}`,\n label,\n swatch: { kind: 'line', color },\n }))\n}\n\nfunction tubeRow(key: string, stops: Stop[], label: string): LegendRow {\n return {\n key,\n label,\n swatch: { kind: 'fill', stops, height: TUBE_SWATCH_PX, square: true },\n }\n}\n\n// What a tube map draws that nothing else on screen explains, each listed\n// only while it applies\nexport function tubeMapRows(model: GraphPaneModel): LegendRow[] {\n const {\n roles,\n haplotypeTube,\n bundled,\n values,\n logWidths,\n foldBp,\n forwardReads,\n reverseReads,\n substitution,\n insertion,\n deletion,\n } = model.tubeMapKeys\n const reads = model.readsShown\n const rows: LegendRow[] = []\n if (values) {\n rows.push(\n tubeRow('value-reference', flat(PANEL_REFERENCE_TUBE), 'reference'),\n )\n for (const { value, color } of values) {\n rows.push(tubeRow(`value-${value}`, flat(color), value))\n }\n }\n if (roles) {\n rows.push(\n tubeRow('ref', flat(PANEL_REFERENCE_TUBE), 'reference'),\n tubeRow(\n 'hap',\n flat(haplotypeTube),\n bundled ? 'shared route, \u00D7n haplotypes' : 'haplotype',\n ),\n )\n }\n if (forwardReads) {\n rows.push(\n tubeRow(\n 'fwd',\n bandStops(FORWARD_READ_COLORS),\n 'read on the forward strand',\n ),\n )\n }\n if (reverseReads) {\n rows.push(\n tubeRow(\n 'rev',\n bandStops(REVERSE_READ_COLORS),\n 'read on the reverse strand',\n ),\n )\n }\n if (reads && reads.shown < reads.total) {\n rows.push({\n key: 'sampled',\n label: `${reads.shown.toLocaleString('en-US')} of ${reads.total.toLocaleString('en-US')} reads shown`,\n swatch: { kind: 'blank' },\n })\n }\n if (substitution) {\n rows.push({\n key: 'sub',\n label: 'read mismatch',\n swatch: { kind: 'glyph', char: 'A' },\n })\n }\n if (insertion) {\n rows.push({\n key: 'ins',\n label: 'read insertion',\n swatch: { kind: 'glyph', char: '*' },\n })\n }\n if (deletion) {\n rows.push(tubeRow('del', flat('grey'), 'read deletion'))\n }\n if (foldBp !== undefined) {\n rows.push({\n key: 'tube-fold',\n label: `haplotype variant < ${formatBp(foldBp)}`,\n swatch: {\n kind: 'tick',\n color: deviationInk(),\n height: TUBE_SWATCH_PX,\n backing: FOLD_TICK_BACKING,\n },\n })\n }\n if (logWidths) {\n rows.push({\n key: 'log',\n label: 'width grows with log of length',\n swatch: { kind: 'bracket' },\n })\n }\n return rows\n}\n\nexport function walkRowSwatch(swatch: KeySwatch): LegendSwatch {\n return swatch.kind === 'gene'\n ? {\n kind: 'outline',\n color: GENE_INK,\n stroke: 1.5,\n radius: 0,\n height: WALK_ROW_SWATCH_PX,\n }\n : {\n kind: 'fill',\n stops:\n swatch.kind === 'bar' && swatch.ramp\n ? RAMP_GRADIENT_STOPS\n : flat(swatch.fill),\n height: swatch.kind === 'gap' ? swatch.px : WALK_ROW_SWATCH_PX,\n }\n}\n\n// The walk rows' bar colours, genes and ticks; each tick row appears once\n// the rows hold one, so a catalogue with no genotypes keeps the plain key\nfunction walkRowsRows(model: GraphPaneModel): LegendRow[] {\n const bars = model.walkRowBars\n if (!bars) {\n return []\n }\n const calls = [bars.reference, ...bars.rows].flatMap(row => row.call ?? [])\n const tick = (key: string, color: string, label: string): LegendRow => ({\n key,\n label,\n swatch: { kind: 'tick', color, height: WALK_ROW_SWATCH_PX },\n })\n return [\n ...walkRowsKey(bars, {\n ramp: model.referenceRampDomain,\n genes: model.walkRowGeneKey,\n }).map(entry => ({\n key: `rows-${entry.label}`,\n label: entry.label,\n swatch: entry.note ? undefined : walkRowSwatch(entry.swatch),\n })),\n ...(calls.some(call => call.spanningReads !== 0)\n ? [tick('call', CALL_TICK, 'allele length called for this walk')]\n : []),\n ...(calls.some(call => call.spanningReads === 0)\n ? [tick('unbacked', UNBACKED_TICK, 'called with no read spanning it')]\n : []),\n ...(calls.some(call => call.agrees === false)\n ? [\n tick(\n 'disagrees',\n DISAGREES,\n `walk and call over ${Math.round(CALL_TOLERANCE * 100)}% apart`,\n ),\n ]\n : []),\n ]\n}\n\n// One lifted walk's key: a swatch, or a short bar of the scale its lane\n// shades by, then its name, with the scale's stretch under it\nexport function walkKeyRow(model: GraphPaneModel, walk: LiftedWalk): LegendRow {\n const key = walkKey(walk, model.walkReference)\n return {\n key: `walk-${walk.name}`,\n strong: model.walkLabel(walk.name),\n label: key.delta + key.gaps + key.reversed,\n swatch: {\n kind: 'fill',\n stops: encodingStops(walk.encoding),\n width: key.shades ? BAR_PX : SWATCH_PX,\n },\n under: key.scale,\n title: key.hover,\n walk,\n }\n}\n\n// The off-reference colour, where the lift paints it, and the faded rest.\n// rampRows draws no key while walks are lifted, so these rows name both.\nfunction fadedRows(\n model: GraphPaneModel,\n faded: string,\n width = SWATCH_PX,\n): LegendRow[] {\n return [\n ...(model.liftPaintsOffReference\n ? [\n fillRow(\n 'lift-off',\n REFERENCE_RAMP_ALT_CSS,\n 'off the reference',\n width,\n ),\n ]\n : []),\n fillRow('faded', FADED_SWATCH, faded, width),\n ]\n}\n\n// Each lifted walk's key, then what the faded rest is; the colours under a\n// shaded walk's bar are bars of its width\nfunction walkReadoutRows(model: GraphPaneModel): LegendRow[] {\n const lift = model.walkLift\n if (!lift || model.facetPanels) {\n return []\n }\n const rows = lift.walks.map(w => walkKeyRow(model, w))\n const width = rows.some(r => swatchWidth(r.swatch!) === BAR_PX)\n ? BAR_PX\n : SWATCH_PX\n return [\n ...rows,\n ...fadedRows(model, `not on ${model.liftedWalksLabel}`, width),\n ]\n}\n\n// The faceted pane's one key line under its panels: each panel's title keys\n// its walk, so this keys only what every panel greys\nexport function facetKeyRows(model: GraphPaneModel): LegendRow[] {\n return model.facetPanels ? fadedRows(model, \"not on the panel's walk\") : []\n}\n\n// The keys in the order the panel stacks them, top first\nexport function legendSections(model: GraphPaneModel): LegendSection[] {\n return [\n { testid: 'graph-open-bubble-legend', rows: openBubbleRows(model) },\n { testid: 'graph-ramp-legend', rows: rampRows(model) },\n { testid: 'graph-reference-strip-legend', rows: stripRows(model) },\n { testid: 'graph-halo-legend', rows: haloRows(model) },\n { testid: 'graph-gene-legend', rows: geneRows(model) },\n { testid: 'graph-fold-legend', rows: foldRows(model) },\n { testid: 'graph-path-legend', rows: pathRows(model) },\n { testid: 'graph-tube-map-legend', rows: tubeMapRows(model) },\n { testid: 'graph-walk-rows-legend', rows: walkRowsRows(model) },\n { testid: 'graph-walk-readout', rows: walkReadoutRows(model) },\n ].filter(section => section.rows.length > 0)\n}\n", "import { createElement, useId } from 'react'\nimport type { ReactNode } from 'react'\n\nimport type { El } from '@jbrowse/bandage-core/el'\n\n// SVG's attribute names as React's props: `class` is className, `data-` and\n// `aria-` keep their dashes, the rest are camel-cased (`stroke-width` is\n// strokeWidth)\nfunction propName(name: string) {\n return name === 'class'\n ? 'className'\n : /^(data|aria)-/.test(name)\n ? name\n : name.replace(/-([a-z])/g, (_, c: string) => c.toUpperCase())\n}\n\nfunction toReact(node: El | string, key: number): ReactNode {\n if (typeof node === 'string') {\n return node\n }\n const props: Record<string, unknown> = { key }\n for (const [name, value] of Object.entries(node.attrs)) {\n if (value !== undefined) {\n props[propName(name)] = value\n }\n }\n return createElement(node.tag, props, node.children.map(toReact))\n}\n\n// A useId fit for an SVG id and for url(#\u2026)\nexport function useSvgId() {\n return useId().replaceAll(/[^\\w-]/g, '')\n}\n\n// A core element tree as React elements\nexport default function ElTree({ el }: { el: El }) {\n return toReact(el, 0)\n}\n", "import { rulerInk } from '@jbrowse/bandage-core/tubeMap/axis'\n\nimport { useSvgId } from './ElTree'\nimport { SWATCH_PX, swatchWidth } from '../legendSections'\n\nimport type { LegendSwatch, Stop } from '../legendSections'\n\nfunction Gradient({\n id,\n x,\n y,\n stops,\n width,\n height,\n square,\n}: {\n id: string\n x: number\n y: number\n stops: readonly Stop[]\n width: number\n height: number\n square?: boolean\n}) {\n const rect = (fill: string) => (\n <rect\n x={x}\n y={y}\n width={width}\n height={height}\n rx={square ? 0 : 2}\n fill={fill}\n />\n )\n return stops.length > 1 ? (\n <>\n <defs>\n <linearGradient id={id}>\n {stops.map((s, i) => (\n <stop key={i} offset={s.offset} stopColor={s.color} />\n ))}\n </linearGradient>\n </defs>\n {rect(`url(#${id})`)}\n </>\n ) : (\n rect(stops[0]!.color)\n )\n}\n\nconst bandPx = (bands: readonly unknown[]) => (bands.length > 1 ? 3 : 4)\n\nfunction swatchHeight(swatch: LegendSwatch) {\n switch (swatch.kind) {\n case 'fill':\n return swatch.height ?? 8\n case 'bands':\n return bandPx(swatch.bands) * swatch.bands.length\n case 'line':\n return 3\n case 'halo':\n case 'overhang':\n return 10\n case 'outline':\n case 'tick':\n return swatch.height\n case 'glyph':\n return 15\n case 'bracket':\n return 7\n case 'blank':\n return 0\n }\n}\n\n// A row's swatch with its left edge at x, centred on the row's text 5 px\n// above the baseline\nexport function SvgSwatch({\n swatch,\n x,\n id,\n}: {\n swatch: LegendSwatch\n x: number\n id: string\n}) {\n const mid = -5\n switch (swatch.kind) {\n case 'fill': {\n const height = swatchHeight(swatch)\n return (\n <Gradient\n id={id}\n x={x}\n y={mid - height / 2}\n stops={swatch.stops}\n width={swatchWidth(swatch)}\n height={height}\n square={swatch.square}\n />\n )\n }\n case 'bands': {\n const band = bandPx(swatch.bands)\n const top = mid - swatchHeight(swatch) / 2\n return (\n <>\n {swatch.bands.map((stops, i) => (\n <Gradient\n key={i}\n id={`${id}-${i}`}\n x={x}\n y={top + i * band}\n stops={stops}\n width={SWATCH_PX}\n height={band}\n square\n />\n ))}\n </>\n )\n }\n case 'line':\n return (\n <rect\n x={x}\n y={mid - 1.5}\n width={SWATCH_PX}\n height={3}\n rx={2}\n fill={swatch.color}\n />\n )\n case 'halo':\n return (\n <line\n x1={x + 5}\n x2={x + 13}\n y1={mid}\n y2={mid}\n stroke={swatch.color}\n strokeOpacity={0.35}\n strokeWidth={8}\n strokeLinecap=\"round\"\n />\n )\n case 'outline': {\n const inset = swatch.stroke / 2\n return (\n <rect\n x={x + inset}\n y={mid - swatch.height / 2 + inset}\n width={SWATCH_PX - swatch.stroke}\n height={swatch.height - swatch.stroke}\n rx={Math.max(0, swatch.radius - inset)}\n fill=\"none\"\n stroke={swatch.color}\n strokeWidth={swatch.stroke}\n />\n )\n }\n case 'overhang':\n return (\n <path\n transform={`translate(${x} ${mid - 5})`}\n d=\"M0,5 L8,0 L8,10 Z M18,5 L10,0 L10,10 Z\"\n fill=\"#18181c\"\n />\n )\n case 'glyph':\n return (\n <text\n x={x + SWATCH_PX / 2}\n y={mid + 4}\n textAnchor=\"middle\"\n fontFamily=\"monospace\"\n fontSize={12}\n fill=\"currentColor\"\n >\n {swatch.char}\n </text>\n )\n case 'tick': {\n const y = mid - swatch.height / 2\n return (\n <>\n {swatch.backing ? (\n <rect\n x={x}\n y={y}\n width={SWATCH_PX}\n height={swatch.height}\n fill={swatch.backing}\n />\n ) : null}\n <rect\n x={x + SWATCH_PX / 2 - 1}\n y={y}\n width={2}\n height={swatch.height}\n fill={swatch.color}\n />\n </>\n )\n }\n case 'bracket':\n return (\n <path\n transform={`translate(${x} ${mid - 3.5})`}\n d={`M0.5,6 V1.5 H5.5 V6 M8.5,6 V1.5 H${SWATCH_PX - 0.5} V6`}\n fill=\"none\"\n stroke={rulerInk()}\n />\n )\n case 'blank':\n return null\n }\n}\n\n// The same swatch on screen, in a box as tall as the swatch so the row\n// centres it on its words\nexport function LegendSwatchView({ swatch }: { swatch: LegendSwatch }) {\n const id = useSvgId()\n const height = swatchHeight(swatch)\n return (\n <svg\n width={swatchWidth(swatch)}\n height={height}\n overflow=\"visible\"\n style={{ flex: 'none' }}\n >\n <g transform={`translate(0 ${height / 2 + 5})`}>\n <SvgSwatch swatch={swatch} x={0} id={id} />\n </g>\n </svg>\n )\n}\n", "import { useMemo } from 'react'\n\nimport {\n exonOutlineTree,\n exonStretches,\n} from '@jbrowse/bandage-core/genes/exonOutline'\nimport { computed } from 'mobx'\nimport { observer } from 'mobx-react'\n\nimport ElTree, { useSvgId } from './ElTree'\nimport { PaneSvgLayer } from './PaneLayer'\n\nimport type { GraphPaneModel } from '../model'\n\n// The session's genes drawn onto the graph: each exon outlined round its\n// stretch of node, as core's exonOutlineTree draws it for every host, moved by\n// the same transform the halos use. Their names are LabelLayer's.\n\nconst GenePins = observer(function GenePins({\n model,\n}: {\n model: GraphPaneModel\n}) {\n const id = `exon-outline-${useSvgId()}`\n // in layout units, so a pan frame reuses them and only moves the transform\n const stretches = useMemo(\n () =>\n computed(() => {\n const { genePins, walkLift } = model\n // an open bubble rings only its own exons\n const focus = walkLift ? undefined : model.openBubbleFocus\n const pins = focus\n ? genePins.map(pin => ({\n ...pin,\n exonsByNode: pin.exonsByNode.filter(e =>\n focus.nodeIds.has(e.nodeId),\n ),\n }))\n : genePins\n return exonStretches(pins, model.nodeInk.halfWidthPx, walkLift)\n }),\n [model],\n )\n const { scaleX, scaleY, translateX, translateY, paneWidth, canvasHeight } =\n model\n const tree = exonOutlineTree(stretches.get(), {\n id,\n width: paneWidth,\n height: canvasHeight,\n transform: `translate(${translateX} ${translateY}) scale(${scaleX} ${scaleY})`,\n })\n return tree ? (\n <PaneSvgLayer model={model} zIndex={2} testId=\"graph-gene-pins\">\n <ElTree el={tree} />\n </PaneSvgLayer>\n ) : null\n})\n\nexport default GenePins\n", "import { LABEL_PAD, LABEL_PX } from '@jbrowse/bandage-core/overlayLabels'\n\n// A chip's box, its text's baseline at y and centred on x\nfunction chipBox(x: number, y: number, w: number) {\n return {\n x: x - w / 2,\n y: y - LABEL_PX - LABEL_PAD + 2,\n width: w,\n height: LABEL_PX + LABEL_PAD * 2 - 2,\n }\n}\n\nexport function inChip(\n chip: { x: number; y: number; w: number },\n px: number,\n py: number,\n) {\n const box = chipBox(chip.x, chip.y, chip.w)\n return (\n px >= box.x &&\n px <= box.x + box.width &&\n py >= box.y &&\n py <= box.y + box.height\n )\n}\n\n// One label on an overlay: a white chip with a coloured edge and text. A note\n// follows the text in plain type. A chip takes the pointer only with a\n// handler, so its title shows only then.\nexport default function LabelChip({\n x,\n y,\n w,\n text,\n note,\n color,\n edge = color,\n italic,\n dimmed,\n title,\n testId,\n onClick,\n onHover,\n}: {\n x: number\n y: number\n w: number\n text: string\n note?: string\n color: string\n edge?: string\n italic?: boolean\n dimmed?: boolean\n title?: string\n testId?: string\n onClick?: () => void\n onHover?: (hovered: boolean) => void\n}) {\n return (\n <g\n style={{\n pointerEvents: onClick || onHover ? 'auto' : 'none',\n cursor: onClick ? 'pointer' : undefined,\n opacity: dimmed ? 0.35 : 1,\n }}\n data-testid={testId}\n onClick={onClick}\n onMouseEnter={() => {\n onHover?.(true)\n }}\n onMouseLeave={() => {\n onHover?.(false)\n }}\n // a clickable chip is a button to the keyboard too\n {...(onClick && {\n role: 'button',\n tabIndex: 0,\n 'aria-label': (title ?? text).replaceAll('\\n', ', '),\n onKeyDown: (e: React.KeyboardEvent) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n onClick()\n }\n },\n onFocus: () => {\n onHover?.(true)\n },\n onBlur: () => {\n onHover?.(false)\n },\n })}\n >\n {title ? <title>{title}</title> : null}\n <rect\n {...chipBox(x, y, w)}\n rx={3}\n fill=\"rgba(255,255,255,0.85)\"\n stroke={edge}\n strokeWidth={1}\n />\n <text\n x={x}\n y={y}\n fontSize={LABEL_PX}\n fontFamily=\"sans-serif\"\n fontStyle={italic ? 'italic' : undefined}\n fontWeight={italic ? 600 : undefined}\n fill={color}\n textAnchor=\"middle\"\n >\n {text}\n {note ? (\n <tspan fontStyle=\"normal\" fontWeight=\"normal\">\n {note}\n </tspan>\n ) : null}\n </text>\n </g>\n )\n}\n", "import { bubbleKey, sameBubble } from '@jbrowse/bandage-core/bubbles/bubbleLine'\nimport { BUBBLE_KIND_COLORS } from '@jbrowse/bandage-core/bubbles/classifyBubble'\nimport { EXON_COLOR } from '@jbrowse/bandage-core/genes/exonOutline'\nimport { geneCoverageNote } from '@jbrowse/bandage-core/labelLayout'\nimport { LABEL_PX, labelWidth } from '@jbrowse/bandage-core/overlayLabels'\nimport { isAlive } from '@jbrowse/mobx-state-tree'\nimport { observer } from 'mobx-react'\n\nimport LabelChip, { inChip } from './LabelChip'\nimport { PaneSvgLayer } from './PaneLayer'\n\nimport type { GraphPaneModel } from '../model'\nimport type { BubbleHalo } from '@jbrowse/bandage-core/bubbles/bubbleHalos'\nimport type { LabelLayout } from '@jbrowse/bandage-core/labelLayout'\n\n// Every chip drawn over the graph, above all of its ink: bubble names and gene\n// names on their pins. `overlayLabels` has placed\n// them against each other and against the row labels already.\n\nconst GENE_INK = '#1c1c22'\nconst TICK_PX = 9\nconst TICK_WIDTH = 3\n\n// What the gene chip under a point reads out, for the hover tooltip: those\n// chips leave the pointer to the canvas, so a drag can start on one\nexport function chipReadoutAt(\n { genes }: Pick<LabelLayout, 'genes'>,\n px: number,\n py: number,\n) {\n const pin = genes.find(chip => inChip(chip, px, py))?.item\n if (!pin) {\n return undefined\n }\n const { gene } = pin\n const note = geneCoverageNote(pin)\n return {\n label: gene.name,\n readout: `${gene.refName}:${gene.start.toLocaleString()}-${gene.end.toLocaleString()}${note ? `, ${note} in the cut` : ''}`,\n }\n}\n\nconst LabelLayer = observer(function LabelLayer({\n model,\n}: {\n model: GraphPaneModel\n}) {\n const { bubbles, genes, ticks } = model.overlayLabels\n if (bubbles.length + genes.length + ticks.length === 0) {\n return null\n }\n const { scaleY, translateY, contigThickness, hoveredBubble } = model\n const hoveredTick = hoveredBubble\n ? ticks.find(t => sameBubble(t.item.bubble, hoveredBubble))\n : undefined\n const tickAt = (target: EventTarget) =>\n ticks[Number((target as Element).getAttribute('data-tick'))]\n const dimmedBubble = (h: BubbleHalo) => model.bubbleFaded(h)\n const isOpen = (h: BubbleHalo) => model.bubbleIsOpen(h.bubble)\n\n return (\n <PaneSvgLayer\n model={model}\n zIndex={3}\n testId=\"graph-label-layer\"\n pansWithDrawing\n >\n <g\n data-testid=\"graph-bubble-ticks\"\n onClick={e => {\n const tick = tickAt(e.target)\n if (tick) {\n model.toggleBubble(tick.item.bubble)\n }\n }}\n onMouseOver={e => {\n const tick = tickAt(e.target)\n if (tick) {\n model.setHoveredBubble(tick.item.bubble)\n }\n }}\n // a leave also fires as the view closing it unmounts the tick\n onMouseOut={() => {\n if (isAlive(model)) {\n model.setHoveredBubble(null)\n }\n }}\n onFocus={e => {\n const tick = tickAt(e.target)\n if (tick) {\n model.setHoveredBubble(tick.item.bubble)\n }\n }}\n onBlur={() => {\n if (isAlive(model)) {\n model.setHoveredBubble(null)\n }\n }}\n onKeyDown={e => {\n const tick = tickAt(e.target)\n if (tick && (e.key === 'Enter' || e.key === ' ')) {\n e.preventDefault()\n model.toggleBubble(tick.item.bubble)\n }\n }}\n >\n {ticks.map(({ item: h, x, y }, i) => (\n <rect\n key={bubbleKey(h.bubble)}\n data-tick={i}\n role=\"button\"\n tabIndex={0}\n aria-label={`${h.label}, ${isOpen(h) ? 'close' : 'open'} bubble`}\n x={x - TICK_WIDTH / 2}\n y={y - TICK_PX}\n width={TICK_WIDTH}\n height={TICK_PX}\n rx={TICK_WIDTH / 2}\n fill={BUBBLE_KIND_COLORS[h.kind]}\n opacity={dimmedBubble(h) ? 0.35 : 1}\n style={{ pointerEvents: 'all', cursor: 'pointer' }}\n />\n ))}\n </g>\n {genes.map(({ item: pin, x, y, w, text }) => {\n const { gene } = pin\n return (\n <g key={`${gene.name}-${gene.start}`}>\n <line\n x1={x}\n x2={x}\n y1={y - LABEL_PX - 2}\n y2={pin.at.y * scaleY + translateY + contigThickness / 2}\n stroke={GENE_INK}\n strokeWidth={0.8}\n strokeOpacity={0.6}\n />\n <LabelChip\n x={x}\n y={y}\n w={w}\n text={gene.name}\n note={text.slice(gene.name.length) || undefined}\n color={GENE_INK}\n edge={EXON_COLOR}\n italic\n testId=\"graph-gene-pin-label\"\n />\n </g>\n )\n })}\n {bubbles.map(({ item: h, x, y, w, text }) => (\n <LabelChip\n key={bubbleKey(h.bubble)}\n x={x}\n y={y}\n w={w}\n text={text}\n color={BUBBLE_KIND_COLORS[h.kind]}\n dimmed={dimmedBubble(h)}\n title={`${h.label}\\n${h.bubble.segmentCount} segments${h.bubble.covering ? '' : isOpen(h) ? ' \u00B7 click to close' : ' \u00B7 click to open'}`}\n testId=\"graph-bubble-halo-label\"\n // the bubble the drawing is would open into this same drawing\n onClick={\n h.bubble.covering\n ? undefined\n : () => {\n model.toggleBubble(h.bubble)\n }\n }\n // a leave also fires as the view closing it unmounts the chip\n onHover={hovered => {\n if (isAlive(model)) {\n model.setHoveredBubble(hovered ? h.bubble : null)\n }\n }}\n />\n ))}\n {hoveredTick ? (\n <LabelChip\n x={hoveredTick.x}\n y={hoveredTick.y - TICK_PX - 4}\n w={labelWidth(hoveredTick.item.label)}\n text={hoveredTick.item.label}\n color={BUBBLE_KIND_COLORS[hoveredTick.item.kind]}\n testId=\"graph-bubble-tick-label\"\n />\n ) : null}\n </PaneSvgLayer>\n )\n})\n\nexport default LabelLayer\n", "import { useCallback } from 'react'\n\nimport { drawReferenceStrip } from '@jbrowse/bandage-core/referenceStrip'\nimport { observer } from 'mobx-react'\n\nimport { PaneOverlayCanvas } from './PaneLayer'\n\nimport type { GraphPaneModel } from '../model'\n\n// Each reference segment at its bp in the linear view, onto the pane's\n// canvas or the linear view's SVG export\nexport function paintReferenceStrip(\n ctx: CanvasRenderingContext2D,\n model: GraphPaneModel,\n {\n lit,\n dpr,\n }: { lit: GraphPaneModel['referenceStripLit'] | undefined; dpr: number },\n) {\n const frame = model.hostBpFrame\n if (frame) {\n drawReferenceStrip(ctx, model.referenceStripBlocks, frame, {\n width: model.paneWidth,\n lit,\n dpr,\n })\n }\n}\n\n// Each reference segment at its bp in the linear view, over a drawing that\n// has no bp axis of its own. Repainted by an autorun, so a pan in the linear\n// view moves the strip in the same frame as its other tracks.\nconst ReferenceStripOverlay = observer(function ReferenceStripOverlay({\n model,\n}: {\n model: GraphPaneModel\n}) {\n const paint = useCallback(\n (ctx: CanvasRenderingContext2D, dpr: number) => {\n paintReferenceStrip(ctx, model, { lit: model.referenceStripLit, dpr })\n },\n [model],\n )\n return (\n <PaneOverlayCanvas\n model={model}\n zIndex={5}\n shown={model.referenceStripShown}\n testId=\"graph-reference-strip\"\n paint={paint}\n />\n )\n})\n\nexport default ReferenceStripOverlay\n", "import { useCallback } from 'react'\n\nimport { drawTubeMapRuler } from '@jbrowse/bandage-core/tubeMap/axis'\nimport { drawTubeMapConnectors } from '@jbrowse/bandage-core/tubeMap/connectors'\nimport { drawDeviationMarks } from '@jbrowse/bandage-core/tubeMap/deviations'\nimport { drawTubeMap } from '@jbrowse/bandage-core/tubeMap/draw'\nimport { drawTubeMapGenes } from '@jbrowse/bandage-core/tubeMap/genes'\nimport { observer } from 'mobx-react'\n\nimport { PaneOverlayCanvas } from './PaneLayer'\nimport {\n PANEL_TITLE_FONT,\n drawBundleCounts,\n drawSqueezedLengths,\n} from '../tubeMapPanels'\n\n// variants folded into a box mark texture under a panel's routes\nconst PANEL_TICK_ALPHA = 0.45\n\nimport type { GraphPaneModel } from '../model'\n\n// The tubes, their connectors, genes and ruler, onto a canvas sized to the\n// pane or onto the linear view's SVG export\nexport function paintTubeMap(\n ctx: CanvasRenderingContext2D,\n model: GraphPaneModel,\n { highlightNode }: { highlightNode: string | null },\n) {\n const picture = model.tubeMapPicture\n const frame = model.tubeMapFrame\n if (!picture || !frame) {\n return\n }\n const width = model.paneWidth\n const panels = model.tubeMapPanelViews\n if (panels) {\n paintPanels(ctx, model, panels, highlightNode)\n return\n }\n const tubeFrame = {\n ...frame,\n width,\n highlightNode,\n tubeColors: model.tubeMapTubeColors,\n nodeColors: model.tubeMapNodeColors,\n }\n drawTubeMap(ctx, picture, tubeFrame)\n const drawn = model.layoutResult?.tubeMap\n if (drawn) {\n drawBundleCounts(ctx, picture, drawn.graph, tubeFrame)\n drawSqueezedLengths(ctx, drawn, tubeFrame)\n }\n drawDeviationMarks(ctx, model.tubeMapDeviations, tubeFrame)\n drawTubeMapConnectors(\n ctx,\n model.tubeMapConnectors,\n model.connectorZoneBottom,\n tubeFrame,\n )\n const { bounds } = picture\n drawTubeMapGenes(ctx, model.tubeMapGenes, tubeFrame, frame.y(bounds.minY) - 2)\n const boxes = model.tubeMapRulerBoxes\n if (boxes) {\n drawTubeMapRuler(\n ctx,\n boxes,\n tubeFrame,\n frame.y(bounds.maxY) + 4,\n model.layoutResult?.referenceAxis,\n )\n }\n}\n\n// Each panel of a split tube map under a rule and its title, which the canvas\n// draws so a figure's SVG carries them\nfunction paintPanels(\n ctx: CanvasRenderingContext2D,\n model: GraphPaneModel,\n panels: NonNullable<GraphPaneModel['tubeMapPanelViews']>,\n highlightNode: string | null,\n) {\n const width = model.paneWidth\n for (const p of panels) {\n if (p.bottom < 0 || p.titleTop > model.canvasHeight) {\n continue\n }\n const tubeFrame = {\n ...p.frame,\n width,\n highlightNode,\n tubeColors: p.tubeColors,\n nodeColors: p.nodeColors,\n }\n drawTubeMap(ctx, p.picture, tubeFrame)\n drawBundleCounts(ctx, p.picture, p.panel.result.tubeMap.graph, tubeFrame)\n drawSqueezedLengths(ctx, p.panel.result.tubeMap, tubeFrame)\n ctx.globalAlpha = PANEL_TICK_ALPHA\n drawDeviationMarks(ctx, p.deviations, tubeFrame)\n ctx.globalAlpha = 1\n ctx.strokeStyle = 'rgba(0,0,0,0.15)'\n ctx.lineWidth = 1\n ctx.beginPath()\n ctx.moveTo(0, Math.round(p.titleTop) + 0.5)\n ctx.lineTo(width, Math.round(p.titleTop) + 0.5)\n ctx.stroke()\n ctx.font = PANEL_TITLE_FONT\n ctx.textAlign = 'left'\n ctx.textBaseline = 'top'\n ctx.fillStyle = 'rgba(0,0,0,0.85)'\n ctx.fillText(p.label, 6, p.titleTop + 4)\n }\n const last = panels.at(-1)\n const boxes = model.tubeMapPanelRulerBoxes\n if (last && boxes) {\n drawTubeMapRuler(\n ctx,\n boxes,\n { ...last.frame, width },\n last.bottom + 4,\n true,\n )\n }\n}\n\n// The tube map's ink, over the canvas, which draws nothing under a tube map\n// layout. Above the tubes go the session's genes in a view of its own, or in\n// a linear view the bands tying each reference box to its bp there; under\n// them a reference ruler, unless the linear view's is already the axis.\n// Repainted by an autorun on every change of transform, so a pan in the linear\n// view above moves the tubes in the same frame as its other tracks.\nconst TubeMapOverlay = observer(function TubeMapOverlay({\n model,\n}: {\n model: GraphPaneModel\n}) {\n const paint = useCallback(\n (ctx: CanvasRenderingContext2D) => {\n paintTubeMap(ctx, model, { highlightNode: model.selectedNode })\n },\n [model],\n )\n return (\n <PaneOverlayCanvas\n model={model}\n zIndex={1}\n shown={!!model.tubeMapPicture}\n testId=\"graph-tube-map\"\n paint={paint}\n />\n )\n})\n\nexport default TubeMapOverlay\n", "const host = JBrowseExports[\"@jbrowse/render-core/marks\"]\nconst read = name =>\n host != null && name in Object(host)\n ? host[name]\n : Object.assign(\n function () {\n throw new Error(\n \"This JBrowse does not provide '\" + name + \"' from '\" + \"@jbrowse/render-core/marks\" + \"' to plugins: GraphGenomeView was built for a different JBrowse version, so update the plugin or JBrowse\",\n )\n },\n { jbrowseHostMissing: name },\n )\nexport const HIDDEN_ROW = /* @__PURE__ */ read(\"HIDDEN_ROW\")\nexport const LINK_ELSEWHERE = /* @__PURE__ */ read(\"LINK_ELSEWHERE\")\nexport const LINK_NO_REGION = /* @__PURE__ */ read(\"LINK_NO_REGION\")\nexport const NO_ROW_COLOR = /* @__PURE__ */ read(\"NO_ROW_COLOR\")\nexport const RAMP_NOT_A_NUMBER_COLOR = /* @__PURE__ */ read(\"RAMP_NOT_A_NUMBER_COLOR\")\nexport const RAMP_NO_VALUE_BITS = /* @__PURE__ */ read(\"RAMP_NO_VALUE_BITS\")\nexport const RAMP_NO_VALUE_COLOR = /* @__PURE__ */ read(\"RAMP_NO_VALUE_COLOR\")\nexport const RowKeys = /* @__PURE__ */ read(\"RowKeys\")\nexport const abgrToCssRgba = /* @__PURE__ */ read(\"abgrToCssRgba\")\nexport const appendGlyph = /* @__PURE__ */ read(\"appendGlyph\")\nexport const backToFront = /* @__PURE__ */ read(\"backToFront\")\nexport const barMark = /* @__PURE__ */ read(\"barMark\")\nexport const buildRowTable = /* @__PURE__ */ read(\"buildRowTable\")\nexport const defineMark = /* @__PURE__ */ read(\"defineMark\")\nexport const ellipseDistance = /* @__PURE__ */ read(\"ellipseDistance\")\nexport const ellipseNearest = /* @__PURE__ */ read(\"ellipseNearest\")\nexport const inkOfInstances = /* @__PURE__ */ read(\"inkOfInstances\")\nexport const instanceColor = /* @__PURE__ */ read(\"instanceColor\")\nexport const isThreshold = /* @__PURE__ */ read(\"isThreshold\")\nexport const keepRampValues = /* @__PURE__ */ read(\"keepRampValues\")\nexport const keySlot = /* @__PURE__ */ read(\"keySlot\")\nexport const lineCenterMark = /* @__PURE__ */ read(\"lineCenterMark\")\nexport const lineMarkOf = /* @__PURE__ */ read(\"lineMarkOf\")\nexport const lineStepMark = /* @__PURE__ */ read(\"lineStepMark\")\nexport const linkFeet = /* @__PURE__ */ read(\"linkFeet\")\nexport const linkMark = /* @__PURE__ */ read(\"linkMark\")\nexport const makeAbgrFill = /* @__PURE__ */ read(\"makeAbgrFill\")\nexport const nearestMarkHit = /* @__PURE__ */ read(\"nearestMarkHit\")\nexport const paintColors = /* @__PURE__ */ read(\"paintColors\")\nexport const paintMarkBlocks = /* @__PURE__ */ read(\"paintMarkBlocks\")\nexport const planMarks = /* @__PURE__ */ read(\"planMarks\")\nexport const pointInsetPx = /* @__PURE__ */ read(\"pointInsetPx\")\nexport const pointMark = /* @__PURE__ */ read(\"pointMark\")\nexport const rampUniforms = /* @__PURE__ */ read(\"rampUniforms\")\nexport const rampValueBits = /* @__PURE__ */ read(\"rampValueBits\")\nexport const recordPath = /* @__PURE__ */ read(\"recordPath\")\nexport const rowColor = /* @__PURE__ */ read(\"rowColor\")\nexport const rowSlot = /* @__PURE__ */ read(\"rowSlot\")\nexport const rowSpanIndex = /* @__PURE__ */ read(\"rowSpanIndex\")\nexport const ruleMark = /* @__PURE__ */ read(\"ruleMark\")\nexport const shiftInk = /* @__PURE__ */ read(\"shiftInk\")\nexport const spanMark = /* @__PURE__ */ read(\"spanMark\")\nexport const spansInRow = /* @__PURE__ */ read(\"spansInRow\")\nexport const thresholdBandOf = /* @__PURE__ */ read(\"thresholdBandOf\")\nexport const valueWindow = /* @__PURE__ */ read(\"valueWindow\")\nexport const withPassId = /* @__PURE__ */ read(\"withPassId\")\nexport default host && host.__esModule ? host.default : host", "import {\n GAP_PX,\n MISSING_PX,\n coalesceRuns,\n gapStyle,\n runPaint,\n} from '@jbrowse/bandage-core/layout/walkRowDraw'\nimport { hslToRgb } from '@jbrowse/bandage-core/renderer/GeometryBuilder'\nimport { packAbgr } from '@jbrowse/bandage-core/renderer/colorBits'\nimport { spanMark } from '@jbrowse/render-core/marks'\n\nimport type { WalkRow, WalkRun } from '@jbrowse/bandage-core/layout/walkRows'\nimport type { MarkContext2D, SpanChannels } from '@jbrowse/render-core/marks'\n\ntype Rgb = [number, number, number]\n\n// The colours runPaint writes: `#rrggbb`, `rgb(r, g, b)` and\n// `hsl(h, s%, l%)`\nexport function cssRgb(css: string): Rgb {\n if (css.startsWith('#')) {\n const v = Number.parseInt(css.slice(1), 16)\n return [(v >> 16) & 0xff, (v >> 8) & 0xff, v & 0xff]\n }\n const [a = 0, b = 0, c = 0] = css.match(/[\\d.]+/g)!.map(Number)\n return css.startsWith('hsl')\n ? (hslToRgb(a, b / 100, c / 100).map(v => v * 255) as Rgb)\n : [a, b, c]\n}\n\nconst abgr = ([r, g, b]: Rgb) =>\n packAbgr(Math.round(r), Math.round(g), Math.round(b), 255)\n\nconst cssAbgr = new Map<string, number>()\nfunction packCss(css: string) {\n let v = cssAbgr.get(css)\n if (v === undefined) {\n v = abgr(cssRgb(css))\n cssAbgr.set(css, v)\n }\n return v\n}\n\n/**\n * A run as the pieces it paints in, each `[start, end, abgr]` in bp along\n * the row: one for a solid fill, and for a gradient one per pixel or per\n * degree of hue, whichever is fewer, coloured as the SVG gradient through\n * the same stops colours its middle\n */\nexport function runPieces(\n run: WalkRun,\n ramp: { start: number; end: number } | undefined,\n pxPerBp: number,\n): [number, number, number][] {\n const end = run.start + run.bp\n const paint = runPaint(run, ramp)\n if ('fill' in paint) {\n return [[run.start, end, packCss(paint.fill)]]\n }\n const stops = paint.stops.map(cssRgb)\n const hues = paint.stops.map(css => Number(/[\\d.]+/.exec(css)![0]))\n const hueSpan = Math.abs(hues.at(-1)! - hues[0]!)\n const n = Math.max(\n 1,\n Math.min(Math.ceil(run.bp * pxPerBp), Math.ceil(hueSpan), run.bp),\n )\n const pieces: [number, number, number][] = []\n for (let k = 0; k < n; k++) {\n const t = ((k + 0.5) / n) * (stops.length - 1)\n const i = Math.min(Math.floor(t), stops.length - 2)\n const a = stops[i]!\n const b = stops[i + 1]!\n const f = t - i\n pieces.push([\n Math.round(run.start + (run.bp * k) / n),\n Math.round(run.start + (run.bp * (k + 1)) / n),\n abgr([0, 1, 2].map(j => a[j]! + (b[j]! - a[j]!) * f) as Rgb),\n ])\n }\n return pieces\n}\n\nexport interface WalkRowSpans {\n bars: SpanChannels & { color: Uint32Array }\n gaps: SpanChannels & { color: Uint32Array }\n // gaps of bases the graph lacks, which draw as a hairline\n hairlines: SpanChannels & { color: Uint32Array }\n // where each drawn row's spans start in `bars`, `gaps` and `hairlines`\n barRows: Uint32Array\n gapRows: Uint32Array\n hairlineRows: Uint32Array\n // the furthest any span reaches along its row, in bp, and at least 1\n longest: number\n}\n\nfunction channels(capacity: number) {\n return {\n x: new Uint32Array(capacity),\n x2: new Uint32Array(capacity),\n row: new Uint32Array(capacity),\n color: new Uint32Array(capacity),\n count: 0,\n }\n}\n\nfunction slice<T extends SpanChannels & { color: Uint32Array }>(\n c: T,\n a: number,\n b: number,\n) {\n return {\n x: c.x.subarray(a, b),\n x2: c.x2.subarray(a, b),\n row: c.row.subarray(a, b),\n color: c.color.subarray(a, b),\n count: b - a,\n }\n}\n\n/**\n * Each row's runs as `walkRowsTree` coalesces and colours them at\n * `pxPerBp`, as span channels: `x`/`x2` in bp along the row, `row` its index\n * among `rows`. Gaps go apart, since they draw thinner, and gaps of bases the\n * graph lacks apart again, as a hairline.\n */\nexport function walkRowSpans(\n rows: WalkRow[],\n pxPerBp: number,\n ramp?: { start: number; end: number },\n): WalkRowSpans {\n const pieces = rows.map(r =>\n coalesceRuns(r.runs, pxPerBp).map(run => ({\n gap: run.gap,\n hairline: run.gap && gapStyle(run.cause).px === MISSING_PX,\n pieces: runPieces(run, ramp, pxPerBp),\n })),\n )\n let total = 0\n for (const runs of pieces) {\n for (const run of runs) {\n total += run.pieces.length\n }\n }\n const bars = channels(total)\n const gaps = channels(total)\n const hairlines = channels(total)\n const barRows = new Uint32Array(rows.length + 1)\n const gapRows = new Uint32Array(rows.length + 1)\n const hairlineRows = new Uint32Array(rows.length + 1)\n let longest = 1\n pieces.forEach((runs, row) => {\n for (const run of runs) {\n const c = run.hairline ? hairlines : run.gap ? gaps : bars\n for (const [x, x2, color] of run.pieces) {\n const i = c.count++\n c.x[i] = x\n c.x2[i] = x2\n c.row[i] = row\n c.color[i] = color\n longest = Math.max(longest, c.x2[i])\n }\n }\n barRows[row + 1] = bars.count\n gapRows[row + 1] = gaps.count\n hairlineRows[row + 1] = hairlines.count\n })\n return {\n bars: slice(bars, 0, bars.count),\n gaps: slice(gaps, 0, gaps.count),\n hairlines: slice(hairlines, 0, hairlines.count),\n barRows,\n gapRows,\n hairlineRows,\n longest,\n }\n}\n\nexport interface WalkRowSpanFrame {\n scaleX: number\n scaleY: number\n translateX: number\n translateY: number\n width: number\n height: number\n rowPx: number\n barPx: number\n origin: number\n // runs of rows whose y is `rowY(first)` plus a row pitch each, as the\n // reference row and each grouped section are\n blocks: { first: number; count: number; rowY: number }[]\n}\n\n/**\n * Paints the spans through render-core's span mark, a block of rows at a\n * time: row i's bar centred where `walkRowsTree` centres it, `barPx` tall,\n * its x at `origin + bp` through the pane's transform.\n */\nexport function paintWalkRowSpans(\n ctx: MarkContext2D,\n spans: WalkRowSpans,\n f: WalkRowSpanFrame,\n) {\n const { longest } = spans\n const block = {\n start: 0,\n end: longest,\n screenStartPx: f.origin * f.scaleX + f.translateX,\n screenEndPx: (f.origin + longest) * f.scaleX + f.translateX,\n reversed: false,\n displayedRegionIndex: 0,\n }\n const frame = { canvasWidth: f.width, canvasHeight: f.height }\n const rowHeight = f.rowPx * f.scaleY\n for (const { first, count, rowY } of f.blocks) {\n // slot `row` centres at (rowY + (row - first) * rowPx) * scaleY + translateY\n const scrollTop =\n rowHeight / 2 - f.translateY - (rowY - first * f.rowPx) * f.scaleY\n const top = (rowY - f.rowPx / 2) * f.scaleY + f.translateY\n if (top > f.height || top + count * rowHeight < 0) {\n continue\n }\n for (const [c, starts, barPx] of [\n [spans.bars, spans.barRows, f.barPx],\n [spans.gaps, spans.gapRows, Math.min(GAP_PX, f.barPx)],\n [spans.hairlines, spans.hairlineRows, Math.min(MISSING_PX, f.barPx)],\n ] as const) {\n spanMark.paintBlock(\n ctx,\n slice(c, starts[first]!, starts[first + count]!),\n block,\n frame,\n {\n rowHeight,\n rowProportion: barPx / rowHeight,\n minWidthPx: 1,\n seamPx: 0,\n scrollTop,\n },\n )\n }\n }\n}\n", "import { useCallback, useMemo } from 'react'\n\nimport { computed } from 'mobx'\nimport { observer } from 'mobx-react'\n\nimport ElTree, { useSvgId } from './ElTree'\nimport { PaneOverlayCanvas, PaneSvgLayer } from './PaneLayer'\nimport { SECTION_HEADER_PX, walkRowTrees } from '../walkRowGroups'\nimport { paintWalkRowSpans, walkRowSpans } from '../walkRowSpans'\n\nimport type { GraphPaneModel } from '../model'\n\n// The walk-rows layout's bars: one per haplotype walk under the reference\n// row, each on its own bp axis from the window's left edge. The runs paint as\n// spans on a canvas, coloured by whether they are on the reference walk's\n// path, and core's walkRowsTree draws the rest: unit separators, each row's\n// genes from its own assembly's annotation, the allele a repeat genotype\n// called and a readout. Under the\n// reference-position ramp an aligned run takes the hue of the reference it is\n// threaded through. In a tandem array that is the aligner's pick among\n// near-identical copies, so the hue says which reference copy the graph used,\n// not which one a copy resembles.\n//\n// The walk rows pair a repeat record's allele with each walk \u2014 see\n// repeats/walkCalls.ts, which also holds the threshold a red readout is read\n// off. Colouring each copy by its unit is jbrowse-plugin-tandem-repeat's.\n\n// The spans are recut only when the rows, the zoom or the ramp change\nfunction WalkRowSpansCanvas({ model }: { model: GraphPaneModel }) {\n const spans = useMemo(\n () =>\n computed(() => {\n const bars = model.walkRowBars\n return bars\n ? walkRowSpans(\n [bars.reference, ...bars.rows],\n model.scaleX,\n model.referenceRampDomain,\n )\n : undefined\n }),\n [model],\n )\n const paint = useCallback(\n (ctx: CanvasRenderingContext2D) => {\n const bars = model.walkRowBars\n const place = model.walkRowPlacement\n const pitch = model.walkRowPitch\n const painted = spans.get()\n if (!bars || !place || !pitch || !painted) {\n return\n }\n const sections = model.walkRowGroups?.sections\n const blocks = sections?.length\n ? [\n { first: 0, count: 1, rowY: place.rowY(0) },\n ...sections.map(s => ({\n first: s.first,\n count: s.count,\n rowY: place.rowY(s.first),\n })),\n ]\n : [{ first: 0, count: bars.rows.length + 1, rowY: place.rowY(0) }]\n paintWalkRowSpans(ctx, painted, {\n ...model.screenTransform,\n width: model.paneWidth,\n height: model.canvasHeight,\n rowPx: pitch.rowPx,\n barPx: pitch.barPx,\n origin: bars.origin,\n blocks,\n })\n },\n [model, spans],\n )\n return (\n <PaneOverlayCanvas\n model={model}\n zIndex={3}\n testId=\"graph-walk-rows-spans\"\n paint={paint}\n />\n )\n}\n\n// Its own observer, so moving between rows redraws this rect and not every row\nconst HoveredWalkRow = observer(function HoveredWalkRow({\n model,\n}: {\n model: GraphPaneModel\n}) {\n const bars = model.walkRowBars\n const place = model.walkRowPlacement\n const pitch = model.walkRowPitch\n if (!bars || !place || !pitch || !model.hoveredWalkRowText) {\n return null\n }\n const rows = [bars.reference, ...bars.rows]\n const index = rows.findIndex(r => r.name === model.hoveredWalkRow)\n const row = rows[index]\n if (!row) {\n return null\n }\n const start = model.toScreen({ x: bars.origin, y: place.rowY(index) })\n return (\n <rect\n data-testid=\"graph-walk-row-hovered\"\n x={start.x - 2}\n y={start.y - pitch.rowPx / 2 - 1}\n width={row.bp * model.scaleX + 4}\n height={pitch.rowPx + 2}\n fill=\"none\"\n stroke=\"#111\"\n strokeWidth={1}\n />\n )\n})\n\n// `vector` for an SVG export, which draws the bars as walkRowsTree's rects\nconst WalkRowsOverlay = observer(function WalkRowsOverlay({\n model,\n vector = false,\n}: {\n model: GraphPaneModel\n vector?: boolean\n}) {\n const idPrefix = useSvgId()\n const bars = model.walkRowBars\n const place = model.walkRowPlacement\n const pitch = model.walkRowPitch\n if (!bars || !place || !pitch) {\n return null\n }\n const { paneWidth: width, canvasHeight } = model\n // the canvas paints the bars, except in a vector export\n const frame = {\n ...model.screenTransform,\n width,\n height: canvasHeight,\n ...pitch,\n bars: vector,\n }\n return (\n <>\n {vector ? null : <WalkRowSpansCanvas model={model} />}\n <PaneSvgLayer\n model={model}\n zIndex={3}\n overflow=\"visible\"\n testId=\"graph-walk-rows\"\n >\n {walkRowTrees(\n bars,\n model.walkRowGroups?.sections ?? [],\n place.rowY,\n frame,\n {\n ramp: model.referenceRampDomain,\n rowGenes: model.walkRowGenes,\n idPrefix,\n },\n ).map((tree, i) => (\n <ElTree key={i} el={tree} />\n ))}\n {place.headers.map(header => (\n <text\n key={header.key}\n x={10}\n y={\n model.toScreen({ x: 0, y: header.top }).y + SECTION_HEADER_PX - 4\n }\n fontFamily=\"sans-serif\"\n fontSize={11}\n fontWeight=\"bold\"\n fill=\"#333\"\n data-testid=\"graph-walk-section\"\n >\n {header.title}\n </text>\n ))}\n <HoveredWalkRow model={model} />\n </PaneSvgLayer>\n </>\n )\n})\n\nexport default WalkRowsOverlay\n"],
5
- "mappings": "muBAaO,IAAMA,GAAoB,yBAG1B,SAASC,GACdC,EACAC,EACA,CACA,MAAO,CACL,SAAU,WACV,KAAM,EACN,IAAK,EACL,cAAe,OACf,SAAAA,EACA,OAAAD,CACF,CACF,CAGO,IAAME,EAAeC,EAAS,SAAsB,CACzD,MAAAC,EACA,OAAAJ,EACA,SAAAC,EAAW,SACX,OAAAI,EACA,gBAAAC,EACA,SAAAC,CACF,EAOG,CACD,OACEC,EAAC,OACC,MAAO,CACL,GAAGT,GAAeC,EAAQC,CAAQ,EAClC,WAAYK,EAAkB,OAAS,MACzC,EACA,MAAOF,EAAM,UACb,OAAQA,EAAM,aACd,cAAaC,EACZ,GAAIC,EAAkB,CAAE,CAACR,EAAiB,EAAG,EAAG,EAAI,CAAC,EAErD,SAAAS,EACH,CAEJ,CAAC,EAIYE,GAAqBN,EAAS,SAA4B,CACrE,MAAAC,EACA,SAAAG,CACF,EAGG,CACD,GAAM,CAAE,OAAAG,EAAQ,OAAAC,EAAQ,WAAAC,EAAY,WAAAC,CAAW,EAAIT,EACnD,OACEI,EAAC,KACC,UAAW,aAAaI,CAAU,IAAIC,CAAU,WAAWH,CAAM,IAAIC,CAAM,IAE1E,SAAAJ,EACH,CAEJ,CAAC,EAIM,SAASO,EAAkB,CAChC,MAAAV,EACA,OAAAJ,EACA,MAAAe,EAAQ,GACR,OAAAV,EACA,MAAAW,CACF,EAMG,CACD,IAAMC,EAAMC,GAA0B,IAAI,EAC1C,OAAAC,GAAU,IAAM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CACC,MAAOlC,EACP,OAAQ,EACR,SAAS,UACT,OAAO,kBAEN,UAAAmC,GACC/B,EACAJ,EAAM,eAAe,UAAY,CAAC,EAClCS,EAAM,KACNsB,EACA,CACE,KAAM/B,EAAM,oBACZ,SAAUA,EAAM,aAChB,SAAA2B,CACF,CACF,EAAE,IAAI,CAACS,EAAMC,IACXrB,EAACsB,EAAA,CAAe,GAAIF,GAAPC,CAAa,CAC3B,EACA5B,EAAM,QAAQ,IAAI8B,GACjBvB,EAAC,QAEC,EAAG,GACH,EACEhB,EAAM,SAAS,CAAE,EAAG,EAAG,EAAGuC,EAAO,GAAI,CAAC,EAAE,EAAIC,GAAoB,EAElE,WAAW,aACX,SAAU,GACV,WAAW,OACX,KAAK,OACL,cAAY,qBAEX,SAAAD,EAAO,OAXHA,EAAO,GAYd,CACD,EACDvB,EAACE,GAAA,CAAe,MAAOlB,EAAO,GAChC,GACF,CAEJ,CAAC,EAEMyC,GAAQhB",
6
- "names": ["PANS_WITH_DRAWING", "paneLayerStyle", "zIndex", "overflow", "PaneSvgLayer", "observer", "model", "testId", "pansWithDrawing", "children", "jsx", "PaneTransformGroup", "scaleX", "scaleY", "translateX", "translateY", "PaneOverlayCanvas", "shown", "paint", "ref", "useRef", "useEffect", "autorun", "canvas", "ctx", "width", "height", "dependOn", "trackedDpr", "dpr", "syncCanvasSize", "BubbleHalos", "observer", "model", "bubbleHalos", "hoveredBubble", "halo", "HALO_FACTOR", "jsx", "PaneSvgLayer", "PaneTransformGroup", "h", "sameBubble", "BUBBLE_KIND_COLORS", "bubbleKey", "BubbleHalos_default", "SWATCH_PX", "BAR_PX", "FADED_SWATCH", "STRIP_SAMPLES", "TUBE_SWATCH_PX", "FOLD_TICK_BACKING", "WALK_ROW_SWATCH_PX", "swatchWidth", "swatch", "flat", "color", "fillRow", "key", "label", "width", "bandStops", "colors", "i", "openBubbleRows", "model", "open", "halo", "h", "sameBubble", "BUBBLE_KIND_COLORS", "rampRows", "domain", "start", "end", "formatBp", "RAMP_GRADIENT_STOPS", "REFERENCE_RAMP_ALT_CSS", "stripBands", "lift", "w", "encodingStops", "b", "c", "all", "n", "LIFT_BACKDROP_CSS", "_", "stripRows", "rowPerWalk", "haloRows", "kindsByColor", "kinds", "BUBBLE_KIND_NAMES", "names", "geneRows", "pin", "EXON_COLOR", "foldRows", "note", "pathRows", "name", "tubeRow", "stops", "tubeMapRows", "roles", "haplotypeTube", "bundled", "values", "logWidths", "foldBp", "forwardReads", "reverseReads", "substitution", "insertion", "deletion", "reads", "rows", "PANEL_REFERENCE_TUBE", "value", "FORWARD_READ_COLORS", "REVERSE_READ_COLORS", "deviationInk", "walkRowSwatch", "GENE_INK", "walkRowsRows", "bars", "calls", "row", "tick", "walkRowsKey", "entry", "call", "CALL_TICK", "UNBACKED_TICK", "DISAGREES", "walkKeyRow", "walk", "walkKey", "fadedRows", "faded", "walkReadoutRows", "facetKeyRows", "legendSections", "section", "propName", "name", "_", "c", "toReact", "node", "key", "props", "value", "createElement", "useSvgId", "useId", "ElTree", "el", "Gradient", "id", "x", "y", "stops", "width", "height", "square", "rect", "fill", "jsx", "jsxs", "Fragment", "s", "i", "bandPx", "bands", "swatchHeight", "swatch", "SvgSwatch", "swatchWidth", "band", "top", "SWATCH_PX", "inset", "rulerInk", "LegendSwatchView", "useSvgId", "GenePins", "observer", "model", "id", "useSvgId", "stretches", "useMemo", "computed", "genePins", "walkLift", "focus", "pins", "pin", "e", "exonStretches", "scaleX", "scaleY", "translateX", "translateY", "paneWidth", "canvasHeight", "tree", "exonOutlineTree", "jsx", "PaneSvgLayer", "ElTree", "GenePins_default", "chipBox", "x", "y", "w", "LABEL_PX", "LABEL_PAD", "inChip", "chip", "px", "py", "box", "LabelChip", "text", "note", "color", "edge", "italic", "dimmed", "title", "testId", "onClick", "onHover", "jsxs", "e", "jsx", "GENE_INK", "TICK_PX", "TICK_WIDTH", "chipReadoutAt", "genes", "px", "py", "pin", "chip", "inChip", "gene", "note", "geneCoverageNote", "LabelLayer", "observer", "model", "bubbles", "ticks", "scaleY", "translateY", "contigThickness", "hoveredBubble", "hoveredTick", "t", "sameBubble", "tickAt", "target", "dimmedBubble", "h", "isOpen", "jsxs", "PaneSvgLayer", "jsx", "e", "tick", "isAlive", "x", "y", "i", "BUBBLE_KIND_COLORS", "bubbleKey", "w", "text", "LABEL_PX", "LabelChip", "EXON_COLOR", "hovered", "labelWidth", "LabelLayer_default", "paintReferenceStrip", "ctx", "model", "lit", "dpr", "frame", "drawReferenceStrip", "ReferenceStripOverlay", "observer", "paint", "useCallback", "jsx", "PaneOverlayCanvas", "ReferenceStripOverlay_default", "PANEL_TICK_ALPHA", "paintTubeMap", "ctx", "model", "highlightNode", "picture", "frame", "width", "panels", "paintPanels", "tubeFrame", "drawTubeMap", "drawn", "drawBundleCounts", "drawSqueezedLengths", "drawDeviationMarks", "drawTubeMapConnectors", "bounds", "drawTubeMapGenes", "boxes", "drawTubeMapRuler", "p", "PANEL_TITLE_FONT", "last", "TubeMapOverlay", "observer", "paint", "useCallback", "jsx", "PaneOverlayCanvas", "TubeMapOverlay_default", "host", "read", "name", "spanMark", "read", "marks_default", "host", "cssRgb", "css", "v", "a", "b", "c", "hslToRgb", "abgr", "r", "g", "packAbgr", "cssAbgr", "packCss", "runPieces", "run", "ramp", "pxPerBp", "end", "paint", "runPaint", "stops", "hues", "hueSpan", "n", "pieces", "k", "t", "i", "f", "j", "channels", "capacity", "slice", "walkRowSpans", "rows", "coalesceRuns", "gapStyle", "MISSING_PX", "total", "runs", "bars", "gaps", "hairlines", "barRows", "gapRows", "hairlineRows", "longest", "row", "x", "x2", "color", "paintWalkRowSpans", "ctx", "spans", "block", "frame", "rowHeight", "first", "count", "rowY", "scrollTop", "top", "starts", "barPx", "GAP_PX", "spanMark", "WalkRowSpansCanvas", "model", "spans", "useMemo", "computed", "bars", "walkRowSpans", "paint", "useCallback", "ctx", "place", "pitch", "painted", "sections", "blocks", "s", "paintWalkRowSpans", "jsx", "PaneOverlayCanvas", "HoveredWalkRow", "observer", "rows", "index", "r", "row", "start", "WalkRowsOverlay", "vector", "idPrefix", "useSvgId", "width", "canvasHeight", "frame", "jsxs", "Fragment", "PaneSvgLayer", "walkRowTrees", "tree", "i", "ElTree", "header", "SECTION_HEADER_PX", "WalkRowsOverlay_default"]
7
- }
@@ -1,3 +0,0 @@
1
- import{a as Te,d as U,e as et,g as j,h as tt,i as Mn,j as vn,k as En,l as Sn,m as _e,o as Oe,r as nt,s as ot}from"./chunk-4I3K4RHE.js";import{a as an,c as cn,e as Ae,f as rt,g as kn,i as Rn,j as Tn}from"./chunk-CXOMX2I6.js";import{A as oe,B as A,C as Qe,J as yn,K as wn,a as ke,c as ln,e as dn,f as H,g as fn,h as Ke,i as Re,k as ze,l as un,m as de,n as pn,p as hn,q as Ze,r as mn,s as gn,x as bn,y as xn,z as Je}from"./chunk-WGTLNVST.js";import{e as _n}from"./chunk-UOFWYS6T.js";import{a as nn,d as sn}from"./chunk-DUPBXBYE.js";import{c as D,d as ne,g as en,j as Ue,k as Ee,l as on,m as rn}from"./chunk-6OXXT2YP.js";import{a as te,c as zt,d as K,e as We,f as Zt,g as O,q as tn,r as I,s as je,v as Ve}from"./chunk-CNNZDE6I.js";import{d as Jt,e as Qt,f as le}from"./chunk-K4TFAHGC.js";import{a as He}from"./chunk-IKJZPPOA.js";import{g as E}from"./chunk-NDRLCGPC.js";import{b as Se}from"./chunk-YU7T5WOQ.js";var Ne=8,st=34,Pe=12,Ur=60;function jr({count:e,bounds:t,pixelRows:n,width:o,room:r,columns:s}){function i(l){let c=Math.ceil(e/l),f=Math.floor((o-(l-1)*Ne)/l),u=(r-c*st-(c-1)*Ne)/c,d=(f-2*Pe)/t.w,p=t.h>0?(u-2*Pe)/t.h:1/0,h=n?d:Math.min(d,p),m=n?t.h:t.h*h,b=Math.floor(Math.max(Ur,Math.min(m+2*Pe,u)));return{columns:l,width:f,height:b,scale:h,total:c*(b+st)+(c-1)*Ne}}if(s!==void 0)return i(Math.max(1,Math.min(e,Math.round(s))));let a=i(1);if(n)return a;for(let l=2;l<=e;l++){let c=i(l);c.scale>a.scale&&(a=c)}return a}var Vr=[{value:"",label:"None",description:"Every lifted walk in one drawing"},{value:"walk",label:"A panel per walk",description:"One panel per lifted walk, side by side"},{value:"sample",label:"A row per sample",description:"A row per sample, a column per haplotype"}];function Kr(e){let t=typeof e=="string"?{field:e}:e??{};return{field:t.field==="walk"||t.field==="sample"?t.field:"",domain:[...t.domain??[]],...t.columns===void 0?{}:{columns:t.columns}}}function On(e,t){let n=new Map(t.map((r,s)=>[r,s])),o=r=>n.get(r)??t.length;return e.map((r,s)=>({name:r,i:s})).sort((r,s)=>o(r.name)-o(s.name)||r.i-s.i).map(({name:r})=>r)}function zr(e,t,n=[]){let o=On(e,n),r={columns:void 0,count:e.length,cells:e.map(c=>o.indexOf(c))};if(t==="walk")return r;let s=e.map(c=>{let f=Qt(c);return f&&Number.isInteger(f.haplotype)&&f.haplotype>=0?{sample:f.sample,column:Math.max(0,f.haplotype-1)}:void 0}),i=On([...new Set(s.flatMap(c=>c?[c.sample]:[]))],n),a=Math.max(1,...s.map(c=>c?c.column+1:1)),l=s.map(c=>c?i.indexOf(c.sample)*a+c.column:-1);return l.includes(-1)||new Set(l).size<l.length?r:{columns:a,count:i.length*a,cells:l}}var Zr=Math.PI/24;function An(e,t){let n=e[t-1],o=e[t],r=e[t+1];if(!n||!r)return 0;let s=Math.abs(Math.atan2(r.y-o.y,r.x-o.x)-Math.atan2(o.y-n.y,o.x-n.x));return s>Math.PI?2*Math.PI-s:s}function Jr(e,t,n,o,r){let s=(h,m)=>Math.max(Math.hypot(m.x-h.x,m.y-h.y)**.5,1e-9),i=s(e,t),a=i+s(t,n),l=a+s(n,o),c=i+r*(a-i),f=(h,m,b,g)=>{let x=(c-b)/(g-b);return{x:h.x+(m.x-h.x)*x,y:h.y+(m.y-h.y)*x}},u=f(e,t,0,i),d=f(t,n,i,a),p=f(n,o,a,l);return f(f(u,d,0,a),f(d,p,i,l),i,a)}var Nn=(e,t)=>({x:2*t.x-e.x,y:2*t.y-e.y});function Pn(e){if(e.length<3)return e;let t=[e[0]];for(let n=0;n+1<e.length;n++){let o=e[n],r=e[n+1],s=Math.ceil(Math.max(An(e,n),An(e,n+1))/Zr),i=e[n-1]??Nn(r,o),a=e[n+2]??Nn(o,r);for(let l=1;l<s;l++)t.push(Jr(i,o,r,a,l/s));t.push(r)}return t}function $n(e,t){let o=e.nodes.filter(O).filter(b=>(t[b.id]?.length??0)>0).flatMap(b=>{let g=t[b.id],x=g.length-1,M=H(b.id)===(b.stable.strand??"+");return g.map((y,w)=>{let v=x===0?.5:w/x;return{x:y.x,y:y.y,r:b.stable.start+b.length*(M?v:1-v),w:b.length/g.length}})}),r=o.reduce((b,g)=>b+g.w,0);if(r===0)return t;let s=o.reduce((b,g)=>b+g.x*g.w,0)/r,i=o.reduce((b,g)=>b+g.y*g.w,0)/r,a=o.reduce((b,g)=>b+g.r*g.w,0)/r,l=0,c=0;for(let b of o)l+=b.w*(b.x-s)*(b.r-a),c+=b.w*(b.y-i)*(b.r-a);if(l===0&&c===0)return t;let f=-Math.atan2(c,l),u=Math.cos(f),d=Math.sin(f),p={};for(let[b,g]of Object.entries(t))p[b]=g.map(x=>{let M=x.x-s,y=x.y-i;return{x:s+u*M-d*y,y:i+d*M+u*y}});let h=0,m=0;for(let b of e.nodes)if(!O(b))for(let g of p[b.id]??[])g.y>i?h++:m++;if(m>h)for(let b of Object.values(p))for(let g of b)g.y=2*i-g.y;return p}var Cn=30;function Qr(e,t){let{opts:n}=t,o=new Map(t.nodes.map(d=>[d.id,Ae(n,d.length)])),r=d=>o.get(d)??n.minimumNodeLength,s=e.nodes.filter(O).sort((d,p)=>d.stable.start-p.stable.start),i=new Map,a=0;for(let d of s)i.set(d.id,{x:a,y:0}),a+=r(d.id)+n.edgeLength;let l=Te(e),c=new Map(s.map(d=>[d.id,0])),f=s.map(d=>d.id);for(let d of f){let p=i.get(d),h=c.get(d)+1;for(let m of l.get(d)??[])c.has(m)||(c.set(m,h),i.set(m,{x:p.x+r(d)/2,y:Cn*h}),f.push(m))}let u=0;for(let d of e.nodes)i.has(d.id)||i.set(d.id,{x:u++*a/e.nodes.length,y:Cn*3});return i}function In(e,t){let n=Qr(e,t);return t.nodes.map(o=>({...o,...n.get(o.id)}))}var es=.5;function Ln(e,t,n=new Set){let o=new Map(t.map(s=>[s.edgeIndex,`${an}${s.edgeIndex}`])),r=[];return e.edges.forEach((s,i)=>{let a=o.get(i);if(!n.has(i))if(a===void 0)r.push(s);else{let{fromStrand:l,toStrand:c}=s;r.push({from:s.from,to:a,...l?{fromStrand:l}:{}},{from:a,to:s.to,...c?{toStrand:c}:{}})}}),{graph:{...e,nodes:[...e.nodes,...[...o.values()].map(s=>({id:s,name:s,length:0,depth:0}))],edges:r},routes:o,ids:new Set(o.values())}}function Bn(e,t,n,o,r){let s=new Map(e.nodes.map(i=>[i.id,i.length]));return t.map(i=>{let a=i.bypassed.reduce((f,u)=>f+(s.get(u)??0),0),l=Math.max(r.minimumNodeLength,o(a)*es),c=n.get(i.edgeIndex);return{id:c,name:c,length:Math.round(l*1e6/r.nodeLengthPerMegabase),depth:0}})}function Xn(e,t){let n={...e},o={};for(let[r,s]of t){let i=n[s];delete n[s],i?.length&&(o[r]=i)}return{nodePositions:n,deletionRoutes:o}}function ts(e,t){let n=e.indexOf(":"),o=e.indexOf(":",n+1);if(n!==-1&&o!==-1){let r=e.slice(0,n),s=e.slice(n+1,o),i=e.slice(o+1);s==="i"||s==="f"?t[r]=+i:s==="Z"&&(t[r]=i)}}function fe(e){let t={};for(let n of e)ts(n,t);return t}function Fn(e){let{SN:t,SO:n,SR:o}=e.tags;return typeof t=="string"&&typeof n=="number"&&typeof o=="number"?{refName:t,start:n,rank:o}:void 0}var Dn=62,ns=60;function os(e){let t=[],n="+",o=0;function r(s){s>o&&t.push({id:e.slice(o,s),strand:n})}for(let s=0;s<e.length;s++){let i=e.charCodeAt(s);(i===Dn||i===ns)&&(r(s),n=i===Dn?"+":"-",o=s+1)}return r(e.length),t}function qn(e){let t={nodes:[],links:[],paths:[],walks:[],header:[],id:""};for(let n of e.split(`
2
- `)){let o=n.endsWith("\r")?n.slice(0,-1):n,r=o.indexOf(" "),s=r===-1?o:o.slice(0,r);if(s==="H"){let[,...i]=o.split(" ");t.header.push(fe(i))}else if(s==="S"){let[,i,...a]=o.split(" "),l,c,f,u=!1,d=a[0]??"*";/^\d+$/.test(d)?(l=+d,c=a[1]??"*",f=a.slice(2)):(u=!0,c=d,l=c==="*"?0:c.length,f=a.slice(1));let p=fe(f);u&&"LN"in p&&(l=+p.LN),t.nodes.push({id:i,length:l,sequence:c,tags:p})}else if(s==="E"){let[,,i,a,,,,,l,...c]=o.split(" ");i&&a&&t.links.push({source:i.slice(0,-1),target:a.slice(0,-1),strand1:i.at(-1),strand2:a.at(-1),cigar:l??"*",tags:fe(c)})}else if(s==="L"){let[,i,a,l,c,f,...u]=o.split(" ");i&&l&&c&&t.links.push({source:i,target:l,strand1:a,strand2:c,cigar:f??"*",tags:fe(u)})}else if(s==="W"){let[,i,a,l,c,f,u,...d]=o.split(" ");i&&a&&l&&c&&f&&u&&t.walks.push({sample:i,haplotype:+a,contig:l,start:c==="*"?-1:+c,end:f==="*"?-1:+f,segments:os(u),tags:fe(d)})}else if(s==="P"){let[,i,a,...l]=o.split(" ");i&&a&&t.paths.push({name:i,path:a,rest:l})}}return t}function rs(e,t){let n=new Map,o=new Map;function r(i,a){n.has(i)||n.set(i,a)}function s(i,a){let l=o.get(i);l===void 0&&r(i,a),o.set(i,(l??0)+1)}for(let i of e.links)r(i.source,i.strand1==="-"?"-":"+"),r(i.target,i.strand2==="-"?"-":"+");for(let{steps:i}of t)for(let a of i)s(a.id,a.strand);for(let i of e.walks)for(let a of i.segments)s(a.id,a.strand);return{canonical:n,traversals:o}}var Gn=e=>e.start===-1?0:e.start;function ss(e){return{...I(e.name),steps:e.path.split(",").map(t=>({id:t.slice(0,-1),strand:t.endsWith("-")?"-":"+"}))}}function is(e,t){return[...t,...e.walks.map(n=>({name:`${n.sample}#${n.haplotype}#${n.contig}`,start:Gn(n),steps:n.segments}))]}function as(e){let t=e.tags.SM;if(typeof t!="string")return;let n=t.split(",").map(o=>o.trim()).filter(Boolean);return n.length>0?n:void 0}var ue=e=>typeof e=="number"&&e>0?e:void 0;function cs({tags:e,length:t}){let n=ue(e.RC)??ue(e.FC)??ue(e.KC);return ue(e.dp)??ue(e.DP)??(n!==void 0&&t>0?n/t:void 0)}function ls(e,t,n){return{id:`${e.id}${t}`,name:e.id,length:e.length,depth:n,stable:Fn(e),samples:as(e)}}function Yn(e,t="Imported GFA"){let n=[],o=[],r=e.paths.map(ss),{canonical:s,traversals:i}=rs(e,r),a=new Map,l=g=>{let x=a.get(g);return x===void 0&&(x=`${g}${s.get(g)??"+"}`,a.set(g,x)),x},c=new Map;for(let g of e.nodes){if(c.has(g.id))continue;c.set(g.id,g.length);let x=cs(g)??Math.max(i.get(g.id)??1,1);n.push(ls(g,s.get(g.id)??"+",x))}for(let g of e.links)o.push({from:l(g.source),to:l(g.target),fromStrand:g.strand1==="-"?"-":"+",toStrand:g.strand2==="-"?"-":"+"});let f=[],u=new Map,d=(g,x)=>u.get(g)?.get(x);function p(g,x,M){let y=u.get(g);y||(y=new Map,u.set(g,y)),y.set(x,M)}let h=o.map(g=>{let x=d(g.from,g.to);return x||(x=new Set,p(g.from,g.to,x),p(g.to,g.from,x)),x});function m(g,x){for(let M=0;M<g.length-1;M++)d(g[M],g[M+1])?.add(x)}e.paths.forEach(({name:g},x)=>{let{start:M,steps:y}=r[x],w=y.map(v=>l(v.id));f.push({name:g,nodeIds:w,start:M}),m(w,g)});for(let g of e.walks){let x=g.segments.map(y=>l(y.id)),M=`${g.sample}#${g.haplotype}#${g.contig}`;f.push({name:M,nodeIds:x,start:Gn(g),sample:g.sample,haplotype:g.haplotype,contig:g.contig,...en(g.tags)}),m(x,M)}o.forEach((g,x)=>{let M=h[x];M.size>0&&(g.pathIds=[...M])});let b=e.paths.length>0||e.walks.length>0?je(is(e,r),g=>c.get(g)??0):void 0;return{name:t,nodes:n,edges:o,paths:f.length>0?f:void 0,anchorPaths:b?.anchorPaths,pathVisits:b?.pathVisits,anchoredBy:n.some(g=>g.stable)?"tags":void 0}}function ds(e,t){if(typeof e!="string")return Ue(e,t);let n=nn(e);return n?Ue(n,t):Yn(qn(e),t)}function Gl(e,t,n={}){let o=ds(e,t);if(o.nodes.length===0)throw new Error(`No graph segments in ${t}`);if(n.maxNodes!==void 0&&o.nodes.length>n.maxNodes)throw new Error(`Graph too large to draw: ${o.nodes.length.toLocaleString()} nodes (limit ${n.maxNodes.toLocaleString()}). Zoom in to a smaller region, or raise maxGraphNodes on this view.`);return Ve(o,n.referencePath)}var z={engine:"fmmm",quality:2,linearLayout:!1,bubbleSpread:"auto",spacing:1,componentSeparation:1,showDeletionEdges:!0};function Wn(e={}){return{engine:e.engine??z.engine,quality:e.quality??z.quality,linearLayout:e.linearLayout??z.linearLayout,bubbleSpread:e.bubbleSpread??z.bubbleSpread,spacing:e.spacing??z.spacing,componentSeparation:e.componentSeparation??z.componentSeparation,showDeletionEdges:e.showDeletionEdges??z.showDeletionEdges}}var fs=15;function us(e,t,n){let o=e.nodes.some(O),r=Wn(n),s={...t,opts:{...t.opts,edgeLength:t.opts.edgeLength*r.spacing}};return{graph:{nodes:o?In(e,s):s.nodes,edges:e.edges},options:{quality:r.quality,linearLayout:r.linearLayout,...s.opts,componentSeparation:fs*r.componentSeparation,...o?{rotateComponents:!1}:{},engine:r.engine}}}function it(e,t){let n=e.nodes.some(O);return[...Object.values(Wn(t)),n,e.referencePath??""].join("|")}async function Hn(e,t,n){let o=Tn(t.bubbleSpread),{shown:r,hidden:s}=xn(e,bn(e),t.showDeletionEdges!==!1),i=Ln(e,r,s),a=mn(i.graph,i.ids),l={...a.graph,nodes:a.graph.nodes.filter(x=>!i.ids.has(x.id))},c=rt(l,o),{result:f,duration:u}=await n(us(a.graph,{...c,nodes:[...c.nodes,...Bn(e,r,i.routes,kn(l,o),c.opts)]},t)),d=rt(e,o),p=new Map(d.nodes.map(x=>[x.id,Ae(d.opts,x.length)])),h=Object.fromEntries(Object.entries(f.nodePositions).map(([x,M])=>[x,Pn(M)])),m=gn(h,a.runs,x=>p.get(x)??0),{nodePositions:b,deletionRoutes:g}=Xn(e.nodes.some(O)?$n(e,m):m,i.routes);return{result:{...f,nodePositions:b,stranded:!0,...r.length?{deletionRoutes:g,extent:Un(g)}:{}},duration:u}}function Un(e){let t=1/0,n=1/0,o=-1/0,r=-1/0;for(let s of Object.values(e))for(let i of s)t=Math.min(t,i.x),n=Math.min(n,i.y),o=Math.max(o,i.x),r=Math.max(r,i.y);return{minX:t,minY:n,maxX:o,maxY:r}}var pe=40,ps=1e-6,hs=100;function at(e){return Math.max(ps,Math.min(hs,e))}function ms(e,t,n,o=pe){let r=t-e.h*n;return o-e.minY*n+Math.max(0,r)/2}function Yl(e,t,n,o,{minScale:r=0,padLeft:s=pe,padTop:i=pe,padRight:a=pe,padBottom:l=pe}={}){let c=t-s-a,f=n-i-l;if(c<=0||f<=0||!(e.w>0||!o&&e.h>0))return;let u=e.w>0?c/e.w:1/0,d=e.h>0?f/e.h:1/0,p=at(Math.max(r,o?u:Math.min(u,d))),h=c-e.w*p;return{scale:p,translateX:s-e.minX*p+Math.max(0,h)/2,translateY:ms(e,f,o?1:p,i)}}function Wl(e,t={}){let{minX:n,minY:o,maxX:r,maxY:s}=Un(e.nodePositions),{region:i}=t;e.referenceAxis&&i&&i.end>i.start&&(n=i.start,r=i.end);let a=t.extent??e.extent;return a&&(n=Math.min(n,a.minX??n),o=Math.min(o,a.minY??o),r=Math.max(r,a.maxX??r),s=Math.max(s,a.maxY??s)),{minX:n,minY:o,w:r-n,h:s-o}}var gs=4;function ct(e=gs){let t=new WeakMap,n=o=>{let r=t.get(o);return r||(r=new Map,t.set(o,r)),r};return{layout(o,r,s){let i=n(o),a=it(o,r),l=i.get(a);if(l)return l.run;i.size>=e&&i.delete(i.keys().next().value);let c=performance.now(),f={run:Hn(o,r,s).then(u=>(f.done=u.result,{...u,duration:u.duration||performance.now()-c}))};return f.run.catch(()=>{i.get(a)===f&&i.delete(a)}),i.set(a,f),f.run},ready(o,r){return t.get(o)?.get(it(o,r))?.done},inherit(o,r){let s=t.get(o);s&&o!==r&&t.set(r,s)}}}function bs(e,t){return{scaleX:e,scaleY:t?1:e,pixelRows:t}}function lt(e,t,n,o){return{minX:-e.translateX/t.scaleX,minY:-e.translateY/t.scaleY,maxX:(n-e.translateX)/t.scaleX,maxY:(o-e.translateY)/t.scaleY}}function xs(e,t){let n=(e.maxX-e.minX)*t,o=(e.maxY-e.minY)*t;return{minX:e.minX-n,minY:e.minY-o,maxX:e.maxX+n,maxY:e.maxY+o}}function ys(e,t){return t.minX>=e.minX&&t.maxX<=e.maxX&&t.minY>=e.minY&&t.maxY<=e.maxY}function ws(e,t,n,o,r){let s=at(e.scale*t),i=s/e.scale;return{scale:s,translateX:n-(n-e.translateX)*i,translateY:r?e.translateY:o-(o-e.translateY)*i}}function Ms(e,t,n,o){return{x:(e-n.translateX)/o.scaleX,y:(t-n.translateY)/o.scaleY}}var Z=JBrowseExports["@jbrowse/render-core/RenderLifecycleMixin"],vs=e=>Z!=null&&e in Object(Z)?Z[e]:Object.assign(function(){throw new Error("This JBrowse does not provide '"+e+"' from '@jbrowse/render-core/RenderLifecycleMixin' to plugins: GraphGenomeView was built for a different JBrowse version, so update the plugin or JBrowse")},{jbrowseHostMissing:e}),jn=vs("RenderLifecycleMixin"),Vd=Z&&Z.__esModule?Z.default:Z;function Vn(e){return t=>e.includes(t)?t:void 0}function Zd(e){return E.snapshotProcessor(E.maybe(E.enumeration(e)),{preProcessor:Vn(e)})}function $e(e,t){return E.snapshotProcessor(E.optional(E.enumeration(e),t),{preProcessor:Vn(e)})}var lf=600,df=160,ff=[1,1,1,1],uf="rgb(255, 255, 255)",pf=5,hf=new Set(["tubemap","tubemapref"]),mf=Se(()=>import("./ChooseSamplesDialog-JRN4YLBY.js")),gf=Se(()=>import("./ChooseWalksDialog-SM326TOX.js")),bf=Se(()=>import("./HighlightColorDialog-G6AFRYUD.js")),xf=12,yf=[{bp:0,label:"None"},{bp:3,label:"Under 3 bp"},{bp:10,label:"Under 10 bp"},{bp:50,label:"Under 50 bp, leaving structural variants"},{bp:1e3,label:"Under 1 kb"}];function wf(e){if(typeof e.uri=="string")return e.uri;let n=e.segmentsLocation?.uri;return typeof n=="string"&&n.endsWith(He)?n.slice(0,-He.length):void 0}var Mf=1.15,vf=1.6,Ef=150,Sf=1,kf=40,Rf=[{value:"each",label:"A tube per haplotype"},{value:"grouped",label:"A tube per haplotype, grouped by route"},{value:"bundled",label:"A tube per route"}],Es={nodeStrokes:[],nodeStrokeRuns:new Map,arrows:[],arrowRuns:new Map,edgeCurves:[],edgeCurveRuns:new Map};function Tf(...e){}var Ss=5e6;function _f(e){return e>=1e6?`${+(e/1e6).toFixed(1)} Mb`:`${Math.round(e/1e3)} kb`}var ks=2e4;function Of(e){return("uri"in e?e.uri.split(/[?#]/)[0]:"localPath"in e?e.localPath:"name"in e?e.name:"").split(/[\\/]/).at(-1)??""}function Af(e){return e&&"uri"in e&&e.uri?new URL(e.uri,e.baseUri??window.location.href).href:void 0}function Nf(e){return e.builtViewport!==void 0&&e.paintedViewport===e.builtViewport&&e.builtViewport.viewportDirty===e.viewportDirty&&!e.viewportRebuildPending}function Pf(e){let{width:t,height:n}=e.viewBox;return lt(e,e.axisScale,t,n)}var $f=ct(),Cf=E.compose("GraphPane",jn(),E.model({layoutQuality:E.optional(E.number,2),layoutEngine:$e(cn,"fmmm"),linearLayout:E.optional(E.boolean,!1),bubbleSpread:$e(Rn,"auto"),tubeMapFold:E.optional(E.number,0),tubeMapRoutes:$e(["each","grouped","bundled"],"each"),tubeMapColorBy:E.optional(E.string,""),geneTrackId:E.optional(E.string,""),repeatTrackId:E.optional(E.string,""),repeatKey:E.optional(E.string,""),walkLayers:E.optional(E.frozen(),[]),referencePath:E.optional(E.string,""),showPerf:E.optional(E.boolean,!1),connectorThickness:E.optional(E.number,2),scale:E.optional(E.number,1),translateX:E.optional(E.number,0),translateY:E.optional(E.number,0),paneHeight:E.maybe(E.number),maxGraphNodes:E.optional(E.number,ks),connectedViewId:E.maybe(E.string),maxRegionBp:E.optional(E.number,Ss),subgraphContext:E.optional(E.number,1),subgraphHaplotypes:E.maybe(E.frozen()),expandedWalks:E.optional(E.frozen(),[])})).volatile(()=>({graph:void 0,walkCut:void 0,graphRegion:void 0,loadedReferencePath:void 0,layoutResult:void 0,drawnLayoutMode:void 0,legendSize:{width:0,height:0},indexBubbles:void 0,foldedBelowBp:void 0,geneTrackFeatures:void 0,walkGeneFeatures:void 0,walkRowSampleTable:void 0,repeatArrays:void 0,handledLayoutMode:void 0,openBubbles:[],error:void 0,isLoading:!1,loadCanceled:!1,statusMessage:"",hoveredNode:null,hoveredAt:null,hoveredTube:null,hoveredPanel:null,hoveredRowWalks:[],hoveredBubble:null,pointerInPane:!1,stripHover:null,hoveredWalkRow:null,hoveredEdge:null,selectedNode:null,viewportDirty:0,positionsVersion:0,morphEntering:void 0,drawnBatch:Es,builtViewport:void 0,paintedViewport:void 0,draggingNode:null,isPanning:!1,viewportOwner:"fit",viewportDirtyTimer:void 0,positionsDirtyFrame:0,lastFetchMs:void 0,readsShown:void 0,lastLayoutMs:void 0,lastGeometryMs:void 0,lastGeometryStrokeCount:void 0,viewportRebuildPending:!1}));var Kn=2,zn=8192;function re(e=0,t=0){let n=typeof devicePixelRatio>"u"?1:Math.min(devicePixelRatio,Kn);return Math.min(n,zn/Math.max(e,t,1))}function dt(e,t,n){let o=re(t,n),r=Math.round(t*o),s=Math.round(n*o);(e.width!==r||e.height!==s)&&(e.width=r,e.height=s);let i=`${t}px`,a=`${n}px`;return e.style.width!==i&&(e.style.width=i),e.style.height!==a&&(e.style.height=a),o}var Df=class{constructor(e){this.transform=null,this.batch=null,this.nodeHighlights=new Map,this.highlightedEdge=null,this.highlightFactor=1,this.fit=1,this.painted=null;let t=e.getContext("2d");if(!t)throw new Error("Canvas 2D context not available");this.canvas=e,this.ctx=t}setErrorHandler(e){}releaseOffscreenTargets(){}resize(e,t){this.fit=dt(this.canvas,e,t)/re()}uploadGeometry(e){this.batch=e,this.highlightedEdge=null,this.painted=null}setNodeHighlights(e){this.nodeHighlights=e,this.painted=null}setEdgeHighlight(e,t){this.highlightedEdge=e,this.highlightFactor=t,this.painted=null}updateTransform(e){this.transform=e}fitted(){let e=this.transform,t=this.fit;return!e||t===1?e:{...e,scaleX:e.scaleX*t,scaleY:e.scaleY*t,translateX:e.translateX*t,translateY:e.translateY*t,dpr:e.dpr*t}}render(e){let t=this.fitted();if(!t)return;let n=this.ctx,{width:o,height:r}=n.canvas;e[3]<1&&n.clearRect(0,0,o,r),e[3]>0&&(n.fillStyle=et([e[0],e[1],e[2]],e[3]),n.fillRect(0,0,o,r));let s=this.batch;if(!s)return;n.lineCap="round",n.lineJoin="round";let{edges:i,nodes:a,arrows:l}=this.paintedGroups(s);for(let{color:c,items:f}of i)this.strokeCurves(f,c,t);for(let{color:c,items:f}of a)this.strokeNodes(f,c,t);for(let{color:c,items:f}of l)this.fillArrows(f,c,t)}paintedGroups(e){if(this.painted)return this.painted;let t=this.highlightFactor,n=this.edgeRun(e.edgeCurveRuns),o=this.edgeRun(e.arrowRuns),r=this.liftedStrokes(e);return this.painted={edges:se(e.edgeCurves,(s,i)=>({color:Ce(n,i)?j(s.color,t):s.color,weight:s.thickness,last:Ce(n,i)})),nodes:se(e.nodeStrokes,(s,i)=>{let a=r.get(i);return{color:a===void 0?s.color:j(s.color,a),weight:s.thickness,last:a!==void 0}}),arrows:se(e.arrows,(s,i)=>({color:Ce(o,i)?j(s.color,t):s.color,weight:0,last:Ce(o,i)}))}}renderHighlights(){let e=this.ctx;e.clearRect(0,0,e.canvas.width,e.canvas.height);let t=this.batch,n=this.fitted();if(!n||!t)return;e.lineCap="round",e.lineJoin="round";let o=this.highlightFactor,r=Zn(t.edgeCurves,this.edgeRun(t.edgeCurveRuns));for(let{color:a,items:l}of se(r,c=>({color:j(c.color,o),weight:c.thickness,last:!1})))this.strokeCurves(l,a,n);let s=[...this.liftedStrokes(t)];for(let{color:a,items:l}of se(s,([c,f])=>({color:j(t.nodeStrokes[c].color,f),weight:t.nodeStrokes[c].thickness,last:!1})))this.strokeNodes(l.map(([c])=>t.nodeStrokes[c]),a,n);let i=Zn(t.arrows,this.edgeRun(t.arrowRuns));for(let{color:a,items:l}of se(i,c=>({color:j(c.color,o),weight:0,last:!1})))this.fillArrows(l,a,n)}edgeRun(e){return this.highlightedEdge===null?void 0:e.get(this.highlightedEdge)}liftedStrokes(e){let t=new Map;for(let[n,o]of this.nodeHighlights){let r=e.nodeStrokeRuns.get(n);if(r)for(let s=r.start;s<r.start+r.count;s++)t.set(s,o)}return t}strokeCurves(e,t,n){let o=this.ctx;o.strokeStyle=U(t),o.lineWidth=e[0].thickness*2*n.dpr,o.beginPath();for(let r of e){let s=r.curves[0];o.moveTo(s.x0*n.scaleX+n.translateX,s.y0*n.scaleY+n.translateY);for(let i of r.curves)o.bezierCurveTo(i.cx0*n.scaleX+n.translateX,i.cy0*n.scaleY+n.translateY,i.cx1*n.scaleX+n.translateX,i.cy1*n.scaleY+n.translateY,i.x1*n.scaleX+n.translateX,i.y1*n.scaleY+n.translateY)}o.stroke()}strokeNodes(e,t,n){let o=this.ctx;o.strokeStyle=U(t),o.lineWidth=e[0].thickness*2*n.dpr,o.beginPath();for(let r of e){let s=r.points[0];o.moveTo(s.x*n.scaleX+n.translateX,s.y*n.scaleY+n.translateY);for(let i=1,a=r.points.length;i<a;i++){let l=r.points[i];o.lineTo(l.x*n.scaleX+n.translateX,l.y*n.scaleY+n.translateY)}}o.stroke()}fillArrows(e,t,n){let o=this.ctx;o.fillStyle=U(t),o.beginPath();for(let r of e){let[s,i,a,l]=Ts(r,n);o.moveTo(s.x,s.y),o.lineTo(i.x,i.y),o.lineTo(a.x,a.y),o.lineTo(l.x,l.y),o.closePath()}o.fill()}dispose(){this.batch=null,this.nodeHighlights=new Map,this.highlightedEdge=null,this.painted=null}},Rs=.25;function Ts(e,t){let n=Math.cos(e.angle),o=Math.sin(e.angle),r=e.x*t.scaleX+t.translateX,s=e.y*t.scaleY+t.translateY,i=e.length*t.dpr,a=e.halfWidth*t.dpr,l=r-n*i,c=s-o*i,f=i*(1-Rs);return[{x:r,y:s},{x:l-o*a,y:c+n*a},{x:r-n*f,y:s-o*f},{x:l+o*a,y:c-n*a}]}function Zn(e,t){return t?e.slice(t.start,t.start+t.count):[]}function Ce(e,t){return e!==void 0&&t>=e.start&&t<e.start+e.count}function se(e,t){let n=new Map,o=new Map;for(let r=0,s=e.length;r<s;r++){let i=e[r],{color:a,weight:l,last:c}=t(i,r),f=c?o:n,u=`${a}:${l}`,d=f.get(u);d?d.items.push(i):f.set(u,{color:a,items:[i]})}return[...n.values(),...o.values()]}var N=e=>+e.toFixed(1),_s=e=>+e.toFixed(3);function Os(e){let t=/^rgba?\(([^,]+),([^,]+),([^,)]+)(?:,([^)]+))?\)$/.exec(e.replaceAll(" ",""));if(!t)return{color:e,opacity:1};let n=t[4]===void 0?1:Number(t[4]);return{color:`rgb(${t[1]},${t[2]},${t[3]})`,opacity:n}}function ft(e,t){let{color:n,opacity:o}=Os(t);return`${e}="${n}"${o<1?` ${e}-opacity="${_s(o)}"`:""}`}var Jn=.5,Qn=.25;function Gf(e,t){let n=[],o=[],r=(c,f)=>{let u={d:`M${N(c)} ${N(f)}`,segments:0,x0:c,x1:c,y0:f,y1:f};return o.push(u),u},s=c=>{let f=o.at(-1)??r(c[0],c[1]);for(let u=0;u<c.length;u+=2)f.x0=Math.min(f.x0,c[u]),f.x1=Math.max(f.x1,c[u]),f.y0=Math.min(f.y0,c[u+1]),f.y1=Math.max(f.y1,c[u+1]);return f.segments++,f},i=c=>{let f=new Set;return o.map(u=>{if(!c||u.x1-u.x0>=Jn||u.y1-u.y0>=Jn)return u.d;let d=(u.x0+u.x1)/2,p=(u.y0+u.y1)/2,h=`${Math.round(d/Qn)} ${Math.round(p/Qn)}`;return u.segments===0||f.has(h)?"":(f.add(h),`M${N(d)} ${N(p)}h0`)}).join("")},a={canvas:void 0,fillStyle:"#000",strokeStyle:"#000",lineWidth:1,lineCap:"butt",lineJoin:"miter",beginPath(){o=[]},moveTo(c,f){r(c,f)},lineTo(c,f){s([c,f]).d+=`L${N(c)} ${N(f)}`},bezierCurveTo(c,f,u,d,p,h){s([c,f,u,d,p,h]).d+=`C${N(c)} ${N(f)} ${N(u)} ${N(d)} ${N(p)} ${N(h)}`},closePath(){let c=o.at(-1);c&&(c.d+="Z")},stroke(){let c=i(a.lineCap!=="butt");c&&n.push(`<path d="${c}" fill="none" ${ft("stroke",a.strokeStyle)} stroke-width="${N(a.lineWidth)}" stroke-linecap="${a.lineCap}" stroke-linejoin="${a.lineJoin}"/>`)},fill(){let c=i(!1);c&&n.push(`<path d="${c}" ${ft("fill",a.fillStyle)}/>`)},clearRect(){n.length=0},fillRect(c,f,u,d){n.push(`<rect x="${N(c)}" y="${N(f)}" width="${N(u)}" height="${N(d)}" ${ft("fill",a.fillStyle)}/>`)}},l={width:e,height:t,style:{},getContext:()=>a};return a.canvas=l,{canvas:l,markup:()=>n.join("")}}var As=50;function eo(e,t){return t>0?Math.max(1,e/t):As}function Ns(e){let t=new Set,n=1/0,o=-1/0;for(let r of e)t.add(r.minY),n=Math.min(n,r.minY),o=Math.max(o,r.minY);return t.size>1?(o-n)/(t.size-1):void 0}function to(e,t,n){let o=eo(t,e.length);return{x:o,y:n>0?eo(n,e.length):Ns(e)??o}}function Ps(e,t,n,o){return e===void 0?to(t,n,o):typeof e=="number"?{x:e,y:e}:e}function $s(e,t,n){let o=e.get(t);o||(o=new Map,e.set(t,o));let r=o.get(n);return r||(r=[],o.set(n,r)),r}function no(e,t,n,o,r,s,i){let a=Math.floor(n/t.x),l=Math.floor(r/t.x),c=Math.floor(o/t.y),f=Math.floor(s/t.y);for(let u=a;u<=l;u++)for(let d=c;d<=f;d++)$s(e,u,d).push(i)}function oo(e,t,n,o,r,s){let i=Math.floor((n-r)/t.x),a=Math.floor((n+r)/t.x),l=Math.floor((o-s)/t.y),c=Math.floor((o+s)/t.y),f=[],u=new Set;for(let d=i;d<=a;d++){let p=e.get(d);if(p)for(let h=l;h<=c;h++){let m=p.get(h);if(m)for(let b of m)u.has(b)||(u.add(b),f.push(b))}}return f}var ro=class{constructor(e,t){this.cells=new Map;let n=[],o=0,r=0;for(let[s,i]of Object.entries(e))for(let a=0;a<i.length-1;a++){let l=i[a],c=i[a+1],f=Math.min(l.x,c.x),u=Math.min(l.y,c.y),d=Math.max(l.x,c.x),p=Math.max(l.y,c.y);o+=d-f,r+=p-u,n.push({entry:{nodeId:s,segmentIdx:a},minX:f,minY:u,maxX:d,maxY:p})}this.cellSize=Ps(t,n,o,r);for(let s of n)no(this.cells,this.cellSize,s.minX,s.minY,s.maxX,s.maxY,s.entry)}query(e,t,n,o=n){return oo(this.cells,this.cellSize,e,t,n,o)}},so=class{constructor(e,t,n,o,r,s=0,i,a=!1){this.cells=new Map,this.edgeCurves=Sn(e,t,o,r,s,i,a);let l=[],c=0,f=0;for(let u=0;u<t.edges.length;u++){let d=t.edges[u],p=e[d.from],h=e[d.to],m=this.edgeCurves.get(u);if(p?.length&&h?.length&&m){let{minX:b,minY:g,maxX:x,maxY:M}=ln(m),y=d.pathIds?.length??0;if(n&&y>0){let w=0,v=0;for(let S of Re(p,h,y,o))w=Math.max(w,Math.abs(S.x)),v=Math.max(v,Math.abs(S.y));b-=w,g-=v,x+=w,M+=v}c+=x-b,f+=M-g,l.push({ei:u,minX:b,minY:g,maxX:x,maxY:M})}}this.cellSize=to(l,c,f);for(let u of l)no(this.cells,this.cellSize,u.minX,u.minY,u.maxX,u.maxY,u.ei)}getCurves(e){return this.edgeCurves.get(e)}query(e,t,n,o=n){return oo(this.cells,this.cellSize,e,t,n,o)}};function ao(e,t,n,o,r,s){let i=r-n,a=s-o,l=i*i+a*a;if(l===0)return Math.hypot(e-n,t-o);let c=Math.max(0,Math.min(1,((e-n)*i+(t-o)*a)/l));return Math.hypot(e-(n+c*i),t-(o+c*a))}function Cs(e,t,n){let o=1/0,r=20,s=n.x0,i=n.y0;for(let a=1;a<=r;a++){let l=a/r,c=1-l,f=c*c*c*n.x0+3*c*c*l*n.cx0+3*c*l*l*n.cx1+l*l*l*n.x1,u=c*c*c*n.y0+3*c*c*l*n.cy0+3*c*l*l*n.cy1+l*l*l*n.y1;o=Math.min(o,ao(e,t,s,i,f,u)),s=f,i=u}return o}function io(e,t,n,o=1){let r=1/0;for(let s of n){let i=Cs(e,t,o===1?s:{x0:s.x0,y0:s.y0*o,cx0:s.cx0,cy0:s.cy0*o,cx1:s.cx1,cy1:s.cy1*o,x1:s.x1,y1:s.y1*o});i<r&&(r=i)}return r}var Is=ze();function co(e,t){return Is(e,[t],()=>new ro(e))}var Ls=ze();function Bs(e,t,n,o,r,s,i,a=!1){return Ls(e,[t,n,o.scaleX,o.scaleY,r,s,i,a],()=>new so(e,t,n,o,s,r,i,a))}var Xs=5;function Jf(e,t,n,o,r=0,s){let i=Ke(o),a=co(e,r),l=p=>Math.max(Xs,p)/o.scaleX,c=l(s?.maxHalfWidthPx??0),f=a.query(t,n,c,c/i),u=null,d=1/0;for(let{nodeId:p,segmentIdx:h}of f){let m=e[p],b=ao(t,n*i,m[h].x,m[h].y*i,m[h+1].x,m[h+1].y*i);b<d&&b<l(s?.halfWidthPx(p)??0)&&(d=b,u=p)}return u}function Ds(e,t,n){let o=t.x-e.x,r=t.y-e.y,s=0,i=1;for(let[a,l]of[[-o,e.x-n.x0],[o,n.x1-e.x],[-r,e.y-n.y0],[r,n.y1-e.y]])if(a===0){if(l<0)return!1}else a<0?s=Math.max(s,l/a):i=Math.min(i,l/a);return s<=i}function lo(e,t,n=0){let o=co(e,n),r=s=>({x:s.x*t.scaleX+t.translateX,y:s.y*t.scaleY+t.translateY});return s=>{let i=new Set,a=o.query(((s.x0+s.x1)/2-t.translateX)/t.scaleX,((s.y0+s.y1)/2-t.translateY)/t.scaleY,Math.abs((s.x1-s.x0)/2/t.scaleX),Math.abs((s.y1-s.y0)/2/t.scaleY));for(let{nodeId:l,segmentIdx:c}of a){let f=e[l];!i.has(l)&&Ds(r(f[c]),r(f[c+1]),s)&&i.add(l)}return i}}function Qf(e,t,n,o,r,s,i=0,a,l,c,f=!1){let u=Ke(r),d=10/r.scaleX,p=Bs(e,t,s,r,i,a,c,f),h=p.query(n,o,d,d/u),m=null,b=d;for(let g of h){let x=t.edges[g],M=e[x.from],y=e[x.to];if(!M?.length||!y?.length||l?.has(g))continue;let w=x.pathIds?.length??0,v=p.getCurves(g);if(!v)continue;let S;if(!s||w===0)S=io(n,o*u,v,u);else{let k=1/0;for(let T of Re(M,y,w,r)){let G=T.x===0&&T.y===0?v:dn(v,T.x,T.y),Y=io(n,o*u,G,u);Y<k&&(k=Y)}S=k}S<b&&(b=S,m=g)}return m}var fo=3.4,ut=6,Fs=18,qs=2,Gs=3,Ys=un+pn;function uo(e){let t=e.gene.end-e.gene.start;if(e.covered>=.98)return;let[n,o]=t>=999500?[1e6,"Mb"]:t>=1e3?[1e3,"kb"]:[1,"bp"],r=s=>+(s/n).toFixed(n===1?0:1);return`${r(e.covered*t)} of ${r(t)} ${o}`}function po(e,t,n,o){let r=n/2;return ho(e,s=>s.gene.end-s.gene.start).map(s=>{let{x:i,y:a}=t(s.at),l=uo(s);return{item:s,x:i,y:a+n+Fs,text:l?`${s.gene.name} \xB7 ${l}`:s.gene.name,fallback:l?`${s.gene.name} \u2026`:void 0,stack:qs,fits:c=>[...o({x0:c.x0-r,x1:c.x1+r,y0:c.y0-r,y1:c.y1+r})].every(f=>s.nodeIds.has(f))}})}function ho(e,t){return[...e].sort((n,o)=>t(o)-t(n))}function Ws(e){let{paneWidth:t,canvasHeight:n,translateX:o,translateY:r}=e,{scaleX:s,scaleY:i}=e.axisScale,a={width:t,height:n},l=w=>({x:w.x*s+o,y:w.y*i+r}),c=e.drawnRowLabels.map(({label:w,y:v})=>Je(w,v*i+r)),f=e.referenceStripZonePx??0;f>0&&c.push({x0:0,x1:t,y0:0,y1:f}),e.legendSize.width>0&&c.push({x0:t-ut-e.legendSize.width,x1:t,y0:0,y1:f+ut+e.legendSize.height}),e.poppedFrom&&c.push({x0:0,x1:60+e.poppedFrom.label.length*de*1.2,y0:0,y1:44});let u=hn(a,c),d=e.drawnRowLabels.length>0,p=d?Math.min(...e.drawnRowLabels.map(w=>w.y)):1/0,h=e.contigThickness*fo,m=(w,v)=>{let{x:S,y:k}=l({x:w.labelAt.x,y:Math.min(w.labelAt.y,p)}),T=k-h/2-v;return{x:S,y:d?Math.max(T,Ys):T}},b=ho(e.bubbleHalos.filter(w=>!w.tick),w=>w.whole?-1:w.members),g=Ze(b.map(w=>({item:w,...m(w,6),text:w.label,fallback:w.label.includes(",")?w.label.split(",")[0]:void 0,stack:Gs})),a,u),x=e.bubbleHalos.filter(w=>w.tick).map(w=>({item:w,...m(w,2)})).filter(w=>w.x>=0&&w.x<=t&&w.y>=0&&w.y<=n),M=Ze(po(e.genePins,l,e.contigThickness,lo(e.nodePositions??{},{scaleX:s,scaleY:i,translateX:o,translateY:r},e.positionsVersion)),a,u),y=e.nodePositions&&e.labelsNodeSizes?Qe({nodePositions:e.nodePositions,nodeLengths:e.nodeLengths,deletions:e.deletions,deletionRoutes:e.deletionRoutes,stranded:e.stranded,alleleDeletions:e.alleleDeletions,axis:e.axisScale,translateX:o,translateY:r,width:t,height:n,version:e.positionsVersion,take:u}):[];return{bubbles:g,ticks:x,genes:M,sizes:y}}var J=JBrowseExports.mobx,ie=e=>J!=null&&e in Object(J)?J[e]:Object.assign(function(){throw new Error("This JBrowse does not provide '"+e+"' from 'mobx' to plugins: GraphGenomeView was built for a different JBrowse version, so update the plugin or JBrowse")},{jbrowseHostMissing:e});var Su=ie("autorun");var ku=ie("computed");var mo=ie("observable");var Ru=ie("reaction");var go=ie("runInAction");var Tu=ie("untracked");var _u=J&&J.__esModule?J.default:J;function pt(e,t){return t===H(e.id)?e.id:`-${e.id}`}function Hs(e,t){let n=e.map(()=>{}),o=0,r=0;for(;r<e.length&&e[r]!==void 0;r++)n[r]=o,o+=e[r];let s=t;for(let i=e.length-1;i>r&&e[i]!==void 0;i--)s-=e[i],n[i]=s;return n}function Us(e,t){let n=e.path.map(()=>[]);if(e.cs===void 0)return n;let o=Hs(t,e.pathLength),r=o.flatMap((d,p)=>d===void 0?[]:[p]),s=d=>o[r[d]],i=d=>s(d)+t[r[d]],a=0,l=d=>{for(;a<r.length&&i(a)<d;)a++;for(let p=a;p<r.length&&s(p)<=d;p++){let h=i(p);if(d<h)return{s:r[p],local:d-s(p),room:h-d}}},c=d=>{for(let p=a;p<r.length;p++)if(s(p)>d)return s(p)-d;return 1/0},f=(d,p)=>{let h=n[d],m=h.at(-1);p.type==="substitution"&&m?.type==="substitution"&&m.pos+m.seq.length===p.pos?m.seq+=p.seq:h.push(p)},u=e.pathStart;for(let d of sn(e.cs))if(d.op==="match")u+=d.length;else if(d.op==="substitution"){let p=l(u);p&&f(p.s,{type:"substitution",pos:p.local,seq:d.seq}),u+=1}else if(d.op==="insertion"){let p=u>e.pathStart&&u<e.pathEnd?l(u):void 0;p&&f(p.s,{type:"insertion",pos:p.local,seq:d.seq})}else{let p=d.length;for(;p>0;){let h=l(u),m=Math.min(p,h?h.room:c(u));h&&f(h.s,{type:"deletion",pos:h.local,length:m}),u+=m,p-=m}}return n}function bo(e,t,n){let o=new Map(e.nodes.map(s=>[s.name,s])),r=[];for(let s of t){let i=s.path.map(f=>o.get(f.name)),a=i.flatMap((f,u)=>f?[u]:[]),l=a[0],c=a.at(-1);if(l!==void 0&&c!==void 0){let f=Us(s,i.map(p=>p?.length)),u=a.map(p=>pt(i[p],s.path[p].strand)),d=i[c].length;r.push({id:n+r.length,name:s.name,type:"read",sourceTrackID:1,sequence:u,sequenceNew:a.map((p,h)=>({nodeName:u[h],mismatches:f[p]})),firstNodeOffset:l===0?s.pathStart:0,finalNodeCoverLength:c===s.path.length-1?d-(s.pathLength-s.pathEnd):d,mapping_quality:s.mappingQuality===255?void 0:s.mappingQuality,is_secondary:s.secondary,is_reverse:s.strand==="-"})}}return r}var js=["#6baed6","#4292c6","#2171b5","#08519c"],Vs=["#fb6a4a","#ef3b2c","#cb181d","#a50f15"];function xo(e){let t=e.is_reverse?Vs:js;return t[e.id%t.length]}function _(e,t={},...n){return{tag:e,attrs:t,children:n.filter(o=>!!o||o==="")}}function yo(e){return e.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;")}function Ks(e){return yo(e).replaceAll('"',"&quot;")}function zs(e){if(typeof e=="string")return yo(e);let t=Object.entries(e.attrs).filter(([,n])=>n!==void 0).map(([n,o])=>` ${n}="${Ks(String(o))}"`).join("");return`<${e.tag}${t}>${e.children.map(zs).join("")}</${e.tag}>`}var xt="#2f8fd6",yt="#8e3fbf",wo="#bdbdbd",Mo="#8a8a8a",vo="#e2e2e2",Eo="#d9a441",he="#1c1c22",wt=12,Ie=4,So=1,gt=12,Zs=6,Js=3;function F(e){return`${(e/1e3).toFixed(e<1e4?1:0)} kb`}function Qs(e){let t=Math.abs(e);return`${e>0?"+":"\u2212"}${t<1e3?`${t} bp`:F(t)}`}function ht(e,t){return t?` \u2248 ${Math.round(e/t)} units`:""}var ei=({refName:e,start:t})=>`${Jt(e)}:${t<1e6?`${Math.round(t/1e3)} kb`:`${(t/1e6).toFixed(1)} Mb`}`;function ti(e){return e<1e3?`${e}`:`${Math.round(e/1e3)} k`}function ni(e,t,n=0){if(e<=0)return"";let o=(t??[]).filter(l=>l.gap);if(!o.some(l=>l.cause))return` \xB7 ${F(e)} ${ne}`;let r=l=>o.filter(c=>c.cause===l).reduce((c,f)=>c+f.bp,0),s=[...new Set(o.flatMap(l=>l.chunk?[ei(l.chunk)]:[]))],i=[[r("missing"),D.missing],[r("elsewhere"),`on nodes filed near ${s[0]}${s.length>1?` and ${s.length-1} more place${s.length>2?"s":""}`:""}`],[r("unknown"),D.unknown],[r(void 0),ne]],a=r("abridged");return(a>0?` \xB7 ${ti(n)} steps, ${F(a)} not loaded`:"")+i.filter(([l])=>l>0).map(([l,c])=>` \xB7 ${F(l)} ${c}`).join("")}function ko(e,t,n,o){let{bp:r,gapBp:s,complete:i,stop:a}=e;if(!t)return`${F(r)}${ht(r,n)}`;let l=ni(s,e.runs,e.abridgedSteps),c=o?` \xB7 called ${F(o.bp)}${o.spanningReads===0?" \xB7 no spanning read":""}`:"";if(i){let d=r-t.bp,p=d===0?"":` (${Qs(d)})`;return`${F(r)}${ht(r,n)}${p}${l}${c}`}let f=n?"repeat":"window";if(a?.contigEnds&&r===0)return`contig ends ${a.shortBp>0?`${F(a.shortBp)} before`:"at"} the ${f}${c}`;let u=a?a.contigEnds?`contig ends inside the ${f}`:"does not rejoin the reference within the extracted subgraph":"partial walk";return`\u2265 ${F(r)}${ht(r,n)} \xB7 ${u}${l}${c}`}function Ro(e,t,n){let o=t+6;return o+e.length*de<n?{x:o,anchor:"start",halo:!1}:{x:t-6,anchor:"end",halo:!0}}function To(e,t,n){if(t*n<Js)return[];let o=[];for(let r=t;r<e;r+=t)o.push(r);return o}function me(e){return e==="missing"?{fill:Mo,px:So,label:D.missing}:e==="unknown"?{fill:vo,px:Ie,label:D.unknown}:e==="abridged"?{fill:Eo,px:Ie,label:D.abridged}:{fill:wo,px:Ie,label:ne}}function _o(e,t){if(e.gap)return{fill:me(e.cause).fill};if(!t)return{fill:e.onReference?xt:yt};if(e.referenceStart===void 0)return{fill:Oe};let n=Mn({...e,start:e.referenceStart},t);return n.length===1?{fill:tt(n[0])}:{stops:n.map(tt)}}function bt(e,t,n){return e.reversed?{start:e.start-n,end:e.start-t}:{start:t-e.start,end:n-e.start}}function oi(e,t){return e.reversed?{start:e.start-t,end:e.start}:{start:e.start,end:e.start+t}}function ri(e,t){let n=new Map;for(let o of e){let r=t.get(o.name);if(!o.axis||!r)continue;let s=o.axis,i=({start:a,end:l})=>({start:Math.max(0,a),end:Math.min(o.bp,l)});n.set(o.name,r.map(a=>({name:a.name,...i(bt(s,a.start,a.end)),exons:a.exons.map(l=>i(bt(s,l.start,l.end))).filter(l=>l.end>l.start)})).filter(a=>a.end>a.start).sort((a,l)=>a.start-l.start))}return n}var si=9,ii=5.2,ai=8,Oo=(e,t)=>Math.min(2,(e-t)/2-1);function Ao(e,t){return Oo(e,t)>=1}function No(e,t,n,{rowPx:o=ke,barPx:r=wt}={}){if(!Ao(o,r))return[];let s=Oo(o,r),i=e.map(c=>{let f=t(c.start);return{g:c,x:f,w:Math.max(2,t(c.end)-f)}}),a=[],l=new Set((r>=ai?[...i]:[]).sort((c,f)=>c.w-f.w).filter(({g:c,x:f,w:u})=>{let d=c.name.length*ii/2,p=[f+u/2-d,f+u/2+d];return 2*d>u+6||a.some(([h,m])=>p[0]<m+2&&p[1]>h-2)?!1:(a.push(p),!0)}));return i.map(c=>({name:c.g.name,x:c.x,y:n-r/2-s,w:c.w,h:r+2*s,exons:c.g.exons.map(f=>({x:t(f.start),w:Math.max(1,t(f.end)-t(f.start))})),label:l.has(c)?{x:c.x+c.w/2,y:n+3,size:si}:void 0}))}var mt=e=>`${e} row${e===1?"":"s"}`;function ci(e,t={}){let n=[{swatch:t.ramp?{kind:"bar",fill:t.rampCss??En,ramp:!0}:{kind:"bar",fill:xt},label:`on ${e.reference.label}'s path`},{swatch:{kind:"bar",fill:t.ramp?Oe:yt},label:`off ${e.reference.label}'s path`}],o=[e.reference,...e.rows].flatMap(s=>s.runs.filter(i=>i.gap)),r=new Set(o.map(s=>me(s.cause).label));for(let s of[void 0,"missing","unknown","abridged"]){let{fill:i,px:a,label:l}=me(s);r.has(l)&&n.push({swatch:{kind:"gap",fill:i,px:a},label:l})}return t.genes?.crowded?n.push({swatch:{kind:"gene"},label:"genes left out: too many rows to box them in",note:!0}):t.genes&&(n.push({swatch:{kind:"gene"},label:"gene"}),t.genes.untracked&&n.push({swatch:{kind:"gene"},label:`no gene track for ${mt(t.genes.untracked)}`,note:!0}),t.genes.unplaced&&n.push({swatch:{kind:"gene"},label:`no contig coordinates for ${mt(t.genes.unplaced)}`,note:!0}),t.genes.unread&&n.push({swatch:{kind:"gene"},label:`genes not read for the last ${mt(t.genes.unread)}`,note:!0})),n}var Po="#111",$o="#9e9e9e",Mt="#c62828";function Co(e){return e.agrees===!1?Mt:e.spanningReads===0?$o:Po}function li(e,t,n,o="walk-key"){let r=0,s=e.flatMap((i,a)=>{let l=`${o}-ramp-${a}`,c=!i.note&&i.swatch.kind==="bar"&&i.swatch.ramp?_("linearGradient",{id:l},...vn.map(d=>_("stop",{offset:d.offset,"stop-color":d.color}))):void 0,f=i.note?void 0:i.swatch.kind==="gene"?_("rect",{x:r,y:5,width:18,height:8,fill:"none",stroke:he,"stroke-width":1.5}):_("rect",{x:r,y:i.swatch.kind==="gap"?9-i.swatch.px/2:5,width:18,height:i.swatch.kind==="gap"?i.swatch.px:8,rx:2,fill:c?`url(#${l})`:i.swatch.fill}),u=_("text",{x:i.note?r:r+23,y:13,"font-style":i.note?"italic":void 0,fill:i.note?"#666":void 0},i.label);return r+=(i.note?0:23)+i.label.length*de+16,[c,f,u].filter(d=>d!==void 0)});return{width:r,tree:_("g",{transform:`translate(${t} ${n})`,"font-family":"Helvetica, Arial, sans-serif","font-size":11},...s)}}function di(e,t,n=0){let o=t/Math.max(1,e),r=Math.max(n,Math.min(ke,o>=1?Math.floor(o):o));return{rowPx:r,barPx:r<=3?r:Math.max(3,Math.round(r*.6)),labelled:r>=gt,readouts:r>=gt}}function Io(e,t){let n=1/t,o=[],r=[],s=()=>{if(r.length!==0){if(r.length===1)o.push(r[0]);else{let a=0,l=0;for(let u of r)u.onReference?a+=u.bp:l+=u.bp;let c=a>=l,f=r.find(u=>u.onReference===c);o.push({start:r[0].start,bp:a+l,onReference:c,referenceStart:c?f.referenceStart:void 0,...f.reversed?{reversed:!0}:{}})}r=[]}},i=0;for(let a of e){if(a.gap||a.bp>=n){s(),i=0,o.push(a);continue}r.push(a),i+=a.bp,i>=n&&(s(),i=0)}return s(),o}function fi(e,t,n){return _("g",{class:"row-gene","data-testid":"graph-walk-gene"},_("title",{},e.name),...e.exons.map(o=>_("rect",{x:o.x,y:t-n/2,width:o.w,height:n,fill:he,opacity:.35})),_("rect",{x:e.x,y:e.y,width:e.w,height:e.h,fill:"none",stroke:he,"stroke-width":1.5}),e.label&&_("text",{x:e.label.x,y:e.label.y,"font-family":"sans-serif","font-size":e.label.size,"font-weight":600,"text-anchor":"middle",fill:he,stroke:"white","stroke-width":2.5,"paint-order":"stroke"},e.name))}function ge(e,t,n={}){let o=m=>m*t.scaleX+t.translateX,r=t.rowPx??ke,s=t.barPx??wt,i=Math.min(3,Math.max(0,(r-s)/2)),a=m=>m*r*t.scaleY+t.translateY,{origin:l,unit:c,reference:f,rows:u}=e,d=m=>o(l+m),p=n.idPrefix??"walkrow",h=(m,b)=>{let g=a(b);if(g<-s||g>t.height+s)return;let x=t.bars===!1?[]:m.runs,M=Io(x,t.scaleX).flatMap(k=>{let T=_o(k,n.ramp),G=k.gap?Math.min(me(k.cause).px,s):s,Y=`${p}-${b}-${k.start}`,ye=_("rect",{x:d(k.start),y:g-G/2,width:Math.max(1,k.bp*t.scaleX),height:G,fill:"stops"in T?`url(#${Y})`:T.fill});return"stops"in T?[_("linearGradient",{id:Y},...T.stops.map((we,Me)=>_("stop",{offset:Me/(T.stops.length-1),"stop-color":we}))),ye]:[ye]}),y=c&&s>=Zs?To(m.bp,c,t.scaleX).map(k=>_("line",{x1:d(k),x2:d(k),y1:g-s/2,y2:g+s/2,stroke:"white","stroke-width":1})):[],{call:w}=m,v=t.readouts??!0?{text:ko(m,b===0?void 0:f,c,w)}:void 0,S=v&&Ro(v.text,d(m.bp),t.width);return _("g",{"data-testid":b===0?"graph-walk-reference":"graph-walk-row"},...M,...y,...No(n.rowGenes?.get(m.name)??[],d,g,{rowPx:r,barPx:s}).map(k=>fi(k,g,s)),w&&_("rect",{"data-testid":"graph-walk-call",x:d(w.bp)-1,y:g-s/2-i,width:2,height:s+2*i,fill:Co(w)}),v&&S&&_("text",{x:S.x,y:g+4,"font-family":"sans-serif","font-size":11,fill:w?.agrees===!1?Mt:"#333",stroke:S.halo?"white":void 0,"stroke-width":S.halo?3:void 0,"paint-order":"stroke","text-anchor":S.anchor},v.text))};return _("g",{},...[f,...u].map(h))}var ui=10;function pi(e,t){let n=e.end-e.start,o=e.longestAlleleLength-e.shortestAlleleLength;return t.find(r=>o<=ui*(r.end-r.start)&&(n===0?r.start<=e.start&&e.start<=r.end:Math.min(e.end,r.end)-Math.max(e.start,r.start)>=n/2))}var hi=40;function mi(e,t){let n=A(e),o=A(t),r=o.slice(o.indexOf(" "));return n.endsWith(r)?`${n.slice(0,-r.length)}\u2013${o}`:`${n}\u2013${o}`}function vt(e){return e>=_n?"\u22652.1B routes":e>=1e5?`${(e/1e3).toFixed(0)}k routes`:`${e} routes`}function gi(e,t=[]){let n=bi(e,t);return e.partial?{...n,label:`${n.label}, partial`}:n}function bi(e,t){let n=e.end-e.start,{shortestAlleleLength:o,longestAlleleLength:r,pathCount:s,segmentCount:i,inversion:a}=e,l=mi(o,r);if(i>=hi)return{kind:"superbubble",label:`${l} superbubble, ${i} segments, ${vt(s)}${a?", inv":""}`};if(a)return{kind:"inversion",label:`${A(r)} inv`};if(e.offReference)return o===r?Lo(o):{kind:"complex",label:`${l}, ${vt(s)}`};let c=r!==o?pi(e,t):void 0;if(c){let u=c.name?` (${c.name})`:"";return{kind:"repeat",label:`${l} repeat array${u}, ${vt(s)}`}}let f=s>2?`, ${s} alleles`:"";return o===r&&o===n?Lo(n):n===0||o===n?{kind:"insertion",label:`\u2264${A(r-n)} ins${f}`}:r===n?{kind:"deletion",label:`${A(n-o)} del${f}`}:{kind:"complex",label:`${A(n)} ref \u2192 ${l}, ${s} alleles`}}function Lo(e){return e<=1?{kind:"snp",label:"SNP"}:{kind:"substitution",label:`${A(e)} sub`}}var xi={snp:"#5b6b7a",substitution:"#5b6b7a",insertion:"#2f8fd6",deletion:"#c94040",inversion:"#e07b00",repeat:"#8e3fbf",superbubble:"#8e3fbf",complex:"#8e3fbf"},yi={snp:"SNP",substitution:"substitution",insertion:"insertion",deletion:"deletion",inversion:"inversion",repeat:"repeat array",superbubble:"superbubble",complex:"site"};function wi(e){return e.segments.split(",").filter(Boolean)}function Et({graph:e,layout:t}){let n=new Map(e.nodes.map(r=>[r.id,r])),o=new Map;t.nodes.forEach((r,s)=>{let i=n.get(r.name);if(r.order>=0&&i&&O(i)){let{refName:a,start:l}=i.stable;te(o,a,{name:r.name,index:s,bp0:l,bp1:l+i.length,x0:r.x,x1:r.x+r.pixelWidth})}});for(let r of o.values())r.sort((s,i)=>s.bp0-i.bp0);return o}function Le(e,t,n=!1){let o=K(e.length-1,r=>n?e[r].bp1<t:e[r].bp1<=t);return be(e[o],t)}function be(e,t){let n=e.bp1-e.bp0;return t<=e.bp0||n<=0?e.x0:e.x0+(Math.min(t,e.bp1)-e.bp0)/n*(e.x1-e.x0)}function Be(e,t,n){let o=Le(e,t),r=Le(e,n,!0);return{x0:Math.min(o,r),x1:Math.max(o,r)}}function Mi(e){let t;for(let n of e.values())(!t||n.length>t.length)&&(t=n);return t}var Bo=5,vi=10,Ei=110,Si=3;function Xo(e){return e?"#b0b0b8":"#55555c"}function ki(e){let t=10**Math.floor(Math.log10(e)),n=e/t;return(n<=1?1:n<=2?2:n<=5?5:10)*t}function Do(e){let t=[];for(let n of e)t.every(o=>Math.abs(n.at-o.at)>=(n.width+o.width)/2+vi)&&t.push(n);return t.map(({text:n,at:o})=>({text:n,at:o}))}function Ri(e,t,n,o){let r=e[0],s=e.at(-1);if(!r||!s)return;let i=t(r.x0),a=t(s.x1),l=s.bp1-r.bp0;if(a<=i||l<=0)return;let c=ki(l/(a-i)*Ei),f=[],u=[];for(let d=Math.ceil(r.bp0/c)*c;d<=s.bp1;d+=c){let p=Math.round(t(Le(e,d)))+.5;if(p>=0&&p<=n){f.push(p);let h=d.toLocaleString("en-US");u.push({text:h,at:p,width:o(h)})}}return{spans:[{x0:i,x1:a}],ticks:f,labels:Do(u)}}function Ti(e,t,n,o){let r=e.map(h=>({box:h,s0:t(h.x0),s1:t(h.x1)})).filter(({s0:h,s1:m})=>m>=0&&h<=n),s=r[0],i=r.at(-1);if(!s||!i)return;let a=(h,m)=>({text:h,at:m,width:o(h)}),l=(h,m)=>a(h.toLocaleString("en-US"),m),c=[],f=[],u=[],d=[];for(let{box:h,s0:m,s1:b}of r){c.push({x0:m,x1:b}),f.push(Math.round(m)+.5),b-m>=Si&&f.push(Math.round(b)+.5);let g=a(A(h.bp1-h.bp0),(m+b)/2);g.width<=b-m&&u.push(g),h!==s.box&&d.push(l(h.bp0,m))}let p=[l(s.box.bp0,s.s0),l(i.box.bp1,i.s1)];return{spans:c,ticks:f,labels:Do([...p,...u,...d])}}function Fo(e,t,n,o,r=!1){return(r?Ri:Ti)(e,t,n,o)}function _i(e,t,n,o,r=!1){let{x:s,width:i,darkMode:a}=n;e.font="10px sans-serif";let l=Fo(t,s,i,u=>e.measureText(u).width,r);if(!l)return;let c=Xo(a),f=o+.5;e.strokeStyle=c,e.fillStyle=c,e.lineWidth=1,e.textAlign="center",e.textBaseline="top",e.beginPath();for(let{x0:u,x1:d}of l.spans)e.moveTo(Math.max(0,u),f),e.lineTo(Math.min(i,d),f);for(let u of l.ticks)e.moveTo(u,o),e.lineTo(u,o+Bo);e.stroke();for(let{text:u,at:d}of l.labels)e.fillText(u,d,o+Bo+2)}function Oi(e,t,n,o){let r=[];for(let s of e){let i=n(s.x0),a=n(s.x1);a>=0&&i<=o&&r.push({node:s.name,top0:t(s.bp0),top1:t(s.bp1),bottom0:i,bottom1:a})}return r}var Ai=3;function Ni(e,t,n,o){if(t<=0||o<0||o>t)return;let r=o/t,s,i=Ai;for(let a of e){let l=a.top0+(a.bottom0-a.top0)*r,c=a.top1+(a.bottom1-a.top1)*r,f=Math.max(0,Math.min(l,c)-n,n-Math.max(l,c));f<i&&(i=f,s=a.node)}return s}function qo(e,t,n){e.moveTo(t.top0,0),e.lineTo(t.top1,0),e.lineTo(t.bottom1,n),e.lineTo(t.bottom0,n),e.closePath()}function Go(e,t,n){e.moveTo(t.top0,0),e.lineTo(t.bottom0,n),e.moveTo(t.top1,0),e.lineTo(t.bottom1,n)}function Pi(e,t,n,{highlightNode:o,darkMode:r}){if(n<=0||t.length===0)return;let s=r?"255,255,255":"0,0,0";e.beginPath();for(let i of t)qo(e,i,n);e.fillStyle=`rgba(${s},0.07)`,e.fill(),e.beginPath();for(let i of t)Go(e,i,n);e.strokeStyle=`rgba(${s},0.35)`,e.lineWidth=.5,e.stroke(),Yo(e,t,n,o)}function Yo(e,t,n,o){let r=n>0&&o?t.find(s=>s.node===o):void 0;r&&(e.beginPath(),qo(e,r,n),e.fillStyle="rgba(255,192,203,0.5)",e.fill(),e.beginPath(),Go(e,r,n),e.strokeStyle="#ff0000",e.lineWidth=1,e.stroke())}function Wo(e,t){let n=new Map;for(let o of e){let r=t(o),s=n.get(r);s===void 0?n.set(r,[o]):s.push(o)}return n}var $i=new Set(["_gbwt_ref","unknown"]);function Ho(e){let[t,n,o]=e?.split("#")??[];if(!(t===void 0||t===""||$i.has(t)||n===void 0||!/^\d+$/.test(n)||o===void 0||o===""))return{sample:t,haplotype:Number(n),contig:o}}var Ci=["read_group","sample_name"],Qp=[...Ci,"haplotype_sample"],Xe=8.401;function Ii({layers:e,coarsenedReadView:t=!1,showReads:n=!0},o){if(e!==void 0)return e;let r=t&&n,s=i=>i?{stat:"coarsen"}:{};return[{data:"haplotypes",...s(r&&!o)},{data:"reads",...s(r&&o)}]}function Uo(e,t){return e.find(n=>n.data===t)?.stat}function Li(e,t){return{mergeNodes:e.mergeNodes??!0,showReads:e.showReads??!0,coarsenedReadView:e.coarsenedReadView??!1,layers:Ii(e,t),ignoreStrand:e.ignoreStrand??!1,nodeWidthOption:e.nodeWidthOption??"normal",charWidth:e.charWidth??Xe,trackWidth:e.trackWidth??15,freqWidth:e.freqWidth??"log"}}function Bi(){return{rectangles:[],curves:[],corners:[],verticalRectangles:[]}}function sr(e){return{config:e,nodes:[],tracks:[],reads:[],nodeMap:new Map,nodesPerOrder:[],nodeOrders:[],assignments:[],extraLeft:[],extraRight:[],maxOrder:-1,shapes:Bi(),trackForRuler:void 0,coarsenedEdgeMeta:new Map}}function ir(e,t,n=[],o={}){let r=Xi(e,t,n,o);return r&&Di(r,o)}var ar=new WeakMap;function Xi(e,t,n=[],o={}){let r=qi(e,t,n,o);if(r===void 0)return;let s=cr(r,r.tracks,r.reads,"measure");return s.nodes.forEach((i,a)=>{i.order>=0&&(r.nodes[a].x=i.x)}),ar.set(r,s),r}function Di(e,t={}){return Fi(e,Hi(e,t.facet),Gi(e,t))}function Fi(e,t,n,o){let r=ar.get(e);return r!==void 0&&t.length===e.tracks.length&&n.length===e.reads.length?r:cr(e,t,n,"topology",o)}function qi(e,t,n,o){let r=sr(Li(o,n.length>0));if(!(e.length===0||t.length===0)){structuredClone(e).forEach((s,i)=>{s.seq??="",s.sequenceLength??=s.seq.length,r.nodes[i+1]=s}),r.tracks=structuredClone(t),r.reads=r.config.showReads?structuredClone(n.filter(s=>s.is_secondary!==!0)):[];for(let s=r.tracks.length-1;s>=0;s-=1){let i=r.tracks[s];if(i.type??="haplotype",i.hidden===!0){r.tracks.splice(s,1);continue}i.indexOfFirstBase!==void 0&&(r.trackForRuler=i.name)}if(r.tracks.length!==0)return ji(r,0),r.nodeMap=zo(r),ae(r,r.tracks),ae(r,r.reads),or(r),r.config.mergeNodes&&(Zo(r),kt(r),Tt(r),La(r),r.nodeMap=zo(r),or(r),ae(r,r.tracks),ae(r,r.reads)),Zo(r),ha(r),kt(r),ma(r),kt(r),Tt(r),ae(r,r.reads),{options:r.config,nodes:r.nodes,tracks:r.tracks,reads:r.reads,nodeMap:r.nodeMap,maxOrder:ua(r),trackForRuler:r.trackForRuler}}}function Gi(e,{mappingQualityCutoff:t=0,focusReadNames:n=null,facet:o}){let r=n?new Set(n):null;return e.reads.filter(s=>(s.mapping_quality??0)>=t&&(r===null||s.name!==void 0&&r.has(s.name))&&(o===void 0||Yi(o,s)))}function Yi(e,t){return e.by==="haplotype_sample"?"reads"in e:(t[e.by]??null)===e.key}function Wi(e){return new Set(e.tracks.filter((t,n)=>n===0||t.name===e.trackForRuler))}function Hi(e,t){if(t?.by!=="haplotype_sample")return e.tracks;let n=Wi(e);return e.tracks.filter(o=>n.has(o)||!("reads"in t)&&Ui(o)===t.key)}function Ui(e){return Ho(e.name)?.sample??null}function cr(e,t,n,o,r={}){let s=sr(e.options);e.nodes.forEach((d,p)=>{s.nodes[p]={...d}}),s.tracks=t.map(d=>({...d})),s.reads=n.map(d=>({...d})),s.nodeMap=e.nodeMap,s.maxOrder=e.maxOrder,s.trackForRuler=e.trackForRuler;let{layers:i,ignoreStrand:a}=s.config,l=r.haplotypes??Oa,c=Uo(i,"haplotypes")==="coarsen"?Aa(s,l):void 0;c!==void 0&&(s.tracks=[c.ref]),Ta(s),wa(s),Vi(s);let f=Uo(i,"reads")==="coarsen"&&s.reads.length>0?pr(s,s.reads,"read",r.reads??l+(c?.bands.length??0)):void 0;f!==void 0&&(s.reads=f.bands);let u={};for(let[d,p,h]of[["haplotypes","haplotype",c],["reads","read",f]])h!==void 0&&(Tt(s,h.bands),ae(s,h.bands),u[d]={unit:p,total:h.total,reverse:!a&&h.bands.some(m=>m.is_reverse)});return c!==void 0&&(s.reads=c.bands.concat(s.reads)),zi(s),s.tracks=s.tracks.concat(s.reads),o==="measure"&&ba(s),_a(s),{nodes:s.nodes,tracks:s.tracks,reads:s.reads,nodeMap:s.nodeMap,shapes:s.shapes,bounds:ia(s),maxOrder:s.maxOrder,trackForRuler:s.trackForRuler,coarsenedEdgeMeta:s.coarsenedEdgeMeta,coarsened:u}}function P(e){return e.startsWith("-")}function $(e){return P(e)?e.substring(1):e}function lr(e){return P(e)?e:`-${e}`}function _t(e){return P(e)?$(e):lr(e)}function jo(e){return e>0}function ji(e,t){let n=new Set,o=new Set;for(let r of e.tracks[t].sequence)P(r)?o.has($(r))||n.add($(r)):o.add(r);if(n.size!==0){for(let{sequence:r}of[...e.tracks,...e.reads])for(let s=0;s<r.length;s+=1)n.has($(r[s]))&&(r[s]=_t(r[s]));e.nodes.forEach(r=>{n.has(r.name)&&(r.seq=Nt(r.seq))})}}function Vi(e){e.nodesPerOrder=Array.from({length:e.maxOrder+1},()=>[]);let t=new Map;e.nodes.forEach(n=>{n.y!==void 0&&Vo(t,n.order,n.y+n.contentHeight)}),e.tracks.forEach(n=>{n.type==="haplotype"&&n.path.forEach(o=>{Vo(t,o.order,(o.y??0)+n.width)})}),e.nodes.forEach((n,o)=>{n.order>=0&&n.y===void 0&&(n.y=(t.get(n.order)??0)+25,n.contentHeight=0,e.nodesPerOrder[n.order].push(o))})}function Vo(e,t,n){let o=e.get(t);o===void 0?e.set(t,n):e.set(t,Math.max(o,n))}var Ot=7;function Ki(e){e.nodes.forEach(t=>{t.incomingReads=[],t.outgoingReads=[],t.internalReads=[]}),e.reads.forEach((t,n)=>{(t.width===void 0||t.width===0)&&(t.width=Ot),t.path.forEach((o,r)=>{if(o.node===null)return;let s=e.nodes[o.node];t.path.length===1?s.internalReads.push(n):r===0?s.outgoingReads.push([n,r]):s.incomingReads.push([n,r])})})}function zi(e){e.reads.forEach(a=>{a.path=dr(e,a)}),Ki(e);let t=e.nodes.filter(a=>a.order>=0);t.sort($t);let n=new Map;for(let a=0;a<e.reads.length;a++){let l=e.reads[a],c=l.haplotypeShare===void 0?1:0,f=l.sourceTrackID,u=`${c}:${f}`,d=n.get(u);d===void 0?n.set(u,{layer:c,source:f,reads:new Set([a])}):d.reads.add(a)}let o=[...n.values()].sort((a,l)=>a.layer-l.layer||a.source-l.source),r=o.length>1?Ot:0;t.forEach(a=>{for(let{reads:l}of o)Zi(e,l,a,r)});let s=oa(e),i=[];e.reads.forEach((a,l)=>{let c=[],f=[],u;a.path.forEach((d,p)=>{c[p]=u,d.node!==null&&(u=d)}),u=void 0;for(let d=a.path.length-1;d>=0;d-=1)f[d]=u,a.path[d].node!==null&&(u=a.path[d]);a.path.forEach((d,p)=>{if(d.y===void 0){let h=c[p],m=f[p],b=!!(m&&h&&(h.order>m.order||m.order===h.order&&m.isForward===h.isForward));d.betweenCycleReverseTraversal=b,i.push({readIndex:l,pathIndex:p,previousY:h?.y,previousNode:h?.node})}})}),i.sort((a,l)=>Qi(e,a,l)),i.forEach(a=>{let l=e.reads[a.readIndex],c=l.path[a.pathIndex];c.y=s[c.order],s[c.order]+=l.width})}function Zi(e,t,n,o){let r=n.incomingReads.filter(([h])=>t.has(h)),s=n.outgoingReads.filter(([h])=>t.has(h)),i=n.internalReads.filter(h=>t.has(h));r.length===0&&s.length===0&&i.length===0&&(o=0);let a=n.y+n.contentHeight+o*2,l=r.map(h=>{let[m,b]=h,g=e.reads[m].path,x=b+1,M;for(let y=1;y<=b;y++){let w=g[b-y]?.y;if(w!==void 0){x=y,M=w;break}}return{entry:h,decisionStep:x,y:M}});l.sort(Ji),r=l.map(h=>h.entry);let c=a,f=new Map;r.forEach(h=>{let m=e.reads[h[0]];m.path[h[1]].y=c,Ko(f,m,h[1],c,n),c+=m.width});let u=c;s.sort((h,m)=>ea(e,h,m));let d=new Map;c=a,s.forEach(h=>{let m=e.reads[h[0]],b=m.firstNodeOffset??0;m.path[h[1]].y=c,d.set(c,b);let g=f.get(c);g===void 0||g+1<=b?(c+=m.width,u=Math.max(u,c)):(f.set(c,0),r.forEach(x=>{let M=e.reads[x[0]],y=M.path[x[1]];y.y!==void 0&&y.y>=c&&(y.y+=m.width,Ko(f,M,x[1],y.y,n))}),c+=m.width,u+=m.width)}),i.sort((h,m)=>na(e,h,m)),i.forEach(h=>{let m=e.reads[h],b=m.firstNodeOffset??0,g=m.finalNodeCoverLength??0;for(c=a;b<(f.get(c)??-1/0)+2||g>(d.get(c)??1/0)-3;)c+=m.width;m.path[0].y=c,f.set(c,g),u=Math.max(u,c)});let p=u-n.y-n.contentHeight;n.contentHeight+=p,ka(e,n,p)}function Ji(e,t){return e.decisionStep!==t.decisionStep?e.decisionStep-t.decisionStep:e.y===void 0||t.y===void 0?(e.y===void 0?0:1)-(t.y===void 0?0:1):e.y-t.y}function Ko(e,t,n,o,r){e.set(o,n===t.path.length-1?t.finalNodeCoverLength??0:r.sequenceLength)}function Qi(e,t,n){let o=e.reads[t.readIndex],r=e.reads[n.readIndex],s=o.path[t.pathIndex],i=r.path[n.pathIndex];if(s.order!==i.order)return s.order-i.order;if(o.sourceTrackID!==r.sourceTrackID)return o.sourceTrackID-r.sourceTrackID;if(t.previousNode&&n.previousNode){let u=e.nodes[t.previousNode],d=e.nodes[n.previousNode];if(u&&d&&u.order!==d.order)return u.order-d.order}let a=t.previousY??0,l=n.previousY??0,c=s.betweenCycleReverseTraversal===!0,f=i.betweenCycleReverseTraversal===!0;return c!==f?c?1:-1:c?l-a:a-l}function ea(e,[t,n],[o,r]){let s=e.reads[t],i=e.reads[o],a=s.path.findLast(p=>p.y!==void 0)?.y,l=i.path.findLast(p=>p.y!==void 0)?.y;if(a!==void 0&&l!==void 0)return a-l;let c=(p,h)=>{let m=p.path[h]?.node;return m==null?null:e.nodes[m]??null},f=(p,h)=>{let m=h+1;for(;p.path[m]?.node===null;)m+=1;return m},u=c(s,n),d=c(i,r);for(;u!==null&&u===d;)n=f(s,n),r=f(i,r),u=c(s,n),d=c(i,r);return u!==null&&d!==null?$t(u,d):u!==null||d!==null?u===null?-1:1:(s.firstNodeOffset??0)-(i.firstNodeOffset??0)||(s.finalNodeCoverLength??0)-(i.finalNodeCoverLength??0)}function ta(e,t){let n=e.path,o=t.path,r=0,s=0;for(;r<n.length&&s<o.length;){let i=n[r],a=o[s],l=i.order,c=a.order;if(l===c&&i.node&&a.node)return(a.y??0)-(i.y??0);l<c?r+=1:(l>c||(r+=1),s+=1)}return 0}function na(e,t,n){let o=e.reads[t],r=e.reads[n];return(o.firstNodeOffset??0)-(r.firstNodeOffset??0)||(o.finalNodeCoverLength??0)-(r.finalNodeCoverLength??0)}function oa(e){let t=new Array(e.maxOrder+1).fill(0);return e.nodes.forEach(n=>{n.y!==void 0&&(t[n.order]=Math.max(t[n.order],n.y+n.contentHeight+20))}),e.tracks.forEach(n=>{n.path.forEach(o=>{t[o.order]=Math.max(t[o.order],(o.y??0)+n.width)})}),t}function dr(e,t){let n=[],o=(l,c)=>{n.push({order:l,isForward:c,node:null})},r=(l,c,f)=>{n.push({order:l,isForward:c,node:f})},s=Math.abs(t.indexSequence[0]),i=jo(t.indexSequence[0]),a=e.nodes[s];r(a.order,i,s);for(let l=1;l<t.sequence.length;l+=1){let c=a,f=i;s=Math.abs(t.indexSequence[l]),i=jo(t.indexSequence[l]),a=e.nodes[s];let{order:u}=a;if(u>c.order){f||o(c.order,!0);for(let d=c.order+1;d<u;d+=1)o(d,!0);i||o(u,!0)}else if(u<c.order){f&&o(c.order,!1);for(let d=c.order-1;d>u;d-=1)o(d,!1);i&&o(u,!1)}else i===f&&o(u,!i);r(u,i,s)}return n}function Tt(e,t=e.reads){t.forEach(n=>{if(!n.sequence.every(P))return;n.is_reverse=n.is_reverse!==!0,n.sequence=n.sequence.toReversed().map($),n.sequenceNew!==void 0&&(n.sequenceNew=n.sequenceNew.toReversed());for(let i of n.sequenceNew??[]){i.nodeName=$(i.nodeName);let{sequenceLength:a}=St(e,i.nodeName);i.mismatches=i.mismatches.map(l=>At(l,a))}let o=n.firstNodeOffset??0,r=St(e,n.sequence[0]).sequenceLength,s=St(e,n.sequence.at(-1)).sequenceLength;n.firstNodeOffset=r-(n.finalNodeCoverLength??0),n.finalNodeCoverLength=s-o})}function At(e,t){let n=e.type==="insertion"?0:e.type==="deletion"?e.length??0:e.seq?.length??0;return{...e,pos:t-e.pos-n,...e.seq!==void 0&&{seq:Nt(e.seq)}}}var ra={A:"T",T:"A",C:"G",G:"C"};function Nt(e){let t="";for(let n=e.length-1;n>=0;n-=1)t+=ra[e.charAt(n)]??"N";return t}function ae(e,t){let n=new Map;t.forEach(o=>{o.indexSequence=o.sequence.map(r=>{let s=n.get(r);if(s===void 0){let i=e.nodeMap.get($(r));if(i===void 0)throw new Error(`Track ${o.name??o.id} visits unknown node ${r}`);s=P(r)?-i:i,n.set(r,s)}return s})})}var sa=20;function ia(e){let t={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0},{rectangles:n,verticalRectangles:o,curves:r}=e.shapes;for(let s of[n,o,r])for(let{xStart:i,xEnd:a}of s)t.minX=Math.min(t.minX,i,a),t.maxX=Math.max(t.maxX,i,a);return e.nodes.forEach(s=>{s.x!==void 0&&(t.minX=Math.min(t.minX,s.x-9),t.maxX=Math.max(t.maxX,s.x+sa+s.pixelWidth)),s.y!==void 0&&(t.minY=Math.min(t.minY,s.y-10),t.maxY=Math.max(t.maxY,s.y+s.contentHeight+10))}),e.tracks.forEach(s=>{s.path.forEach(i=>{let a=i.y??0;t.maxY=Math.max(t.maxY,a+s.width),t.minY=Math.min(t.minY,a)})}),t}function St(e,t){let n=e.nodeMap.get($(t)),o=n===void 0?void 0:e.nodes[n];if(o===void 0)throw new Error(`Unknown node ${t}`);return o}function zo(e){let t=new Map;return e.nodes.forEach((n,o)=>{t.set(n.name,o)}),t}function Zo(e){let t=e.nodes.map(()=>new Set),n=e.nodes.map(()=>new Set),o=r=>{for(let s=0;s<r.indexSequence.length-1;s+=1){let i=Math.abs(r.indexSequence[s]),a=Math.abs(r.indexSequence[s+1]);t[i].add(a),n[a].add(i)}};e.tracks.forEach(o),e.reads.forEach(o),e.nodes.forEach((r,s)=>{r.successors=Array.from(t[s]),r.predecessors=Array.from(n[s])})}function Jo(e,t){let n=0,o=0,r=0;t.forEach(s=>{let i=Math.abs(s);if(s<0){let a=e.nodeOrders[i]??=o;a<r&&(r=a),n=a,o=a-1}else{let a=e.nodeOrders[i]??=n;n=a+1,o=a}}),r<0&&Pt(e,-r)}function aa(e,t){let n=0,o=0;for(;n<t.length&&e.nodeOrders[Math.abs(t[n])]===void 0;)n+=1;if(n>=t.length)return null;let r=t[n],s,i;r>=0?(s=e.nodeOrders[r]-1,i=-1):(s=e.nodeOrders[-r]+1,i=1);for(let a=n-1;a>=0;a-=1){let l=Math.abs(t[a]);e.nodeOrders[l]===void 0&&(e.nodeOrders[l]=s,o=Math.min(o,s),s+=i)}return o<0&&Pt(e,-o),n}var ca=-1;function la(e){return Array.from(e,t=>t??ca)}function da(e){let t=[...new Set(e.filter(o=>o>=0))].sort((o,r)=>o-r),n=new Map(t.map((o,r)=>[o,r]));return e.map(o=>n.get(o)??o)}function kt(e){let t,n,o,r,s=0,i=e.tracks.concat(e.reads),a={stamp:new Int32Array(e.nodes.length),generation:0};e.nodeOrders=new Array(e.nodes.length).fill(void 0),e.nodes.forEach(l=>{l.order=void 0}),Jo(e,e.tracks[0].indexSequence);for(let l=1;l<i.length;l+=1){if(o=aa(e,i[l].indexSequence),o===null){l<e.tracks.length?Jo(e,i[l].indexSequence):(i.splice(l,1),e.reads.splice(l-e.tracks.length,1),l-=1);continue}for(t=pa(i[l].indexSequence);o<t.length;){for(r=o,o+=1;o<t.length&&e.nodeOrders[t[o]]===void 0;)o+=1;if(o<t.length){n=e.nodeOrders[t[r]]+1;for(let c=r+1;c<o;c+=1)e.nodeOrders[t[c]]=n,n+=1;if(e.nodeOrders[t[o]]>e.nodeOrders[t[r]])e.nodeOrders[t[o]]<n&&Qo(e,t[o],t[o-1],n);else if(i[l].indexSequence[o]>=0&&!fa(e,t[o],t[r],a))Qo(e,t[o],t[o-1],n);else if(i[l].indexSequence[r]<0||e.nodes[t[r+1]].degree<2&&e.nodeOrders[t[o]]<e.nodeOrders[t[r]]){n=e.nodeOrders[t[r]]-1;for(let c=r+1;c<o;c+=1)e.nodeOrders[t[c]]=n,s=Math.min(s,n),n-=1}}else if(i[l].indexSequence[r]>=0){n=e.nodeOrders[t[r]]+1;for(let c=r+1;c<t.length;c+=1){let f=t[c];e.nodeOrders[f]===void 0&&(e.nodeOrders[f]=n,n+=1)}}else{n=e.nodeOrders[t[r]]-1;for(let c=r+1;c<t.length;c+=1){let f=t[c];e.nodeOrders[f]===void 0&&(e.nodeOrders[f]=n,s=Math.min(s,n),n-=1)}}}}s<0&&Pt(e,-s),e.nodeOrders=da(la(e.nodeOrders)),e.nodes.forEach((l,c)=>{l.order=e.nodeOrders[c]})}function fa(e,t,n,o){o.generation+=1;let{stamp:r,generation:s}=o,i=[t];for(r[t]=s;i.length>0;){let a=i.pop();if(a===n)return!0;for(let l of e.nodes[a].successors)r[l]!==s&&(r[l]=s,i.push(l))}return!1}function ua(e){let t=-1;return e.nodeOrders.forEach(n=>{n!==void 0&&n>t&&(t=n)}),t}function pa(e){return e.map(t=>Math.abs(t))}function Pt(e,t){e.nodeOrders.forEach((n,o)=>{n!==void 0&&(e.nodeOrders[o]=n+t)})}function Qo(e,t,n,o){let r=new Map,s=[[t,o]],i=0;for(;i<s.length;){let[a,l]=s[i];i+=1;let c=e.nodeOrders[a];c!==void 0&&c<l&&(r.get(a)??-1/0)<l&&(r.set(a,l),e.nodes[a].successors.forEach(f=>{e.nodeOrders[f]>c&&f!==n&&s.push([f,l+1])}),a!==t&&e.nodes[a].predecessors.forEach(f=>{e.nodeOrders[f]>c&&f!==n&&s.push([f,l+1])}))}r.forEach((a,l)=>{e.nodeOrders[l]=a})}function ha(e){e.nodes.forEach(t=>{t.tracks=[]}),e.tracks.forEach(t=>{t.indexSequence.forEach(n=>{e.nodes[Math.abs(n)].tracks.push(t.id)})}),e.nodes.forEach(t=>{t.degree=t.tracks.length})}function ma(e){ga(e,[...e.tracks.slice(1),...e.reads],e.tracks[0])}function ga(e,t,n){let o=new Int32Array(e.nodes.length),r=new Uint8Array(e.nodes.length);for(let s of n.sequence){let i=P(s)?void 0:e.nodeMap.get(s);i!==void 0&&(r[i]=1)}for(let s of t){let{sequence:i,indexSequence:a}=s,l=a.length-1;for(let c=0;c<=l;c+=1){let f=Math.abs(a[c]);if(r[f]===1)continue;let u=e.nodes[f].order,d=c>0?e.nodes[Math.abs(a[c-1])].order:void 0,p=c<l?e.nodes[Math.abs(a[c+1])].order:void 0,h=P(i[c])?1:-1;(d===void 0||d<u)&&(p===void 0||u<p)&&(o[f]+=h),(d===void 0||d>u)&&(p===void 0||u>p)&&(o[f]-=h)}}for(let s of t){let{sequence:i,indexSequence:a}=s;for(let l=0;l<a.length;l+=1)o[Math.abs(a[l])]>0&&(i[l]=_t(i[l]),a[l]=-a[l])}e.nodes.forEach((s,i)=>{o[i]>0&&(s.seq=Nt(s.seq),s.switched=!0)})}function ba(e){let t=0,n=20,o=-1,r=e.nodes.slice();r.sort($t);let s=ya(e);r.forEach(i=>{i.order>=0&&(i.order>o&&(o=i.order,t=n+10*s[i.order]),i.x=t,n=Math.max(n,t+40+i.pixelWidth))})}var Rt=35;function xa(e){return e<=Rt?e/17.5:Rt/17.5*Math.sqrt(e/Rt)}function ya(e){let t=e.maxOrder+1,n=new Array(t).fill(0),o=new Array(t).fill(0),r=new Array(t).fill(0),s=[];e.tracks.forEach(i=>{for(let a=1;a<i.path.length;a+=1){let l=i.path[a],c=i.path[a-1];l.order===c.order?l.isForward?n[l.order]+=1:o[l.order]+=1:r[l.order]=Math.max(xa(Math.abs((l.y??0)-(c.y??0))),r[l.order])}}),s.push(Math.max(0,n[0]-1));for(let i=1;i<=e.maxOrder;i+=1)s.push(Math.max(Math.max(0,n[i]-1)+Math.max(0,o[i-1]-1),r[i]));return s}function wa(e){e.assignments=Array.from({length:e.maxOrder+1},()=>[]);let t=new Map;e.tracks.forEach((n,o)=>{n.path=dr(e,n),n.path.forEach(({order:r,node:s},i)=>{let a={trackID:o,segmentID:i},l=s===null?void 0:t.get(s);if(l===void 0){let c={node:s,tracks:[a]};e.assignments[r].push(c),s!==null&&t.set(s,c)}else l.tracks.push(a)})});for(let n=0;n<=e.maxOrder;n+=1)Ea(e,e.assignments[n],n)}function Ma(e,t,n){t.forEach(o=>{let r=0;o.tracks.forEach(s=>{let i=va(e.tracks[s.trackID].path,s.segmentID,n-1);s.idealLane=i===void 0?s.trackID:i.lane,s.idealY=i===void 0?null:i.y,r+=s.idealLane}),o.idealLane=r/o.tracks.length})}function va(e,t,n){if(t!==0)return e[t-1].order===n?e[t-1]:e[t+1]?.order===n?e[t+1]:e.slice(0,t).findLast(o=>o.order===n)}function Ea(e,t,n){let o=0,r=new Set,s=20,i=!1,a=-1;Ma(e,t,n),t.sort(er),t.forEach(l=>{let c=l.node===null?void 0:e.nodes[l.node];c!==void 0?(i&&(s-=10),c.y=s,c.contentHeight=0,i=!1):(i?s-=25:s>20&&(s-=10),i=!0),l.tracks.sort(er),l.tracks.forEach(f=>{let{path:u,width:d}=e.tracks[f.trackID];f.trackID===a&&c===void 0&&i&&(s+=10),u[f.segmentID].lane=o,u[f.segmentID].y=s,typeof f.idealY=="number"&&r.add(f.idealY-s),o+=1,s+=d,c!==void 0&&(c.contentHeight+=d),a=f.trackID}),s+=25}),Sa(e,t,r)}function Sa(e,t,n){let o=0,r=Number.MAX_SAFE_INTEGER;n.forEach(s=>{let i=Ra(e,t,s);i<r&&(r=i,o=s)}),t.forEach(s=>{s.node!==null&&(e.nodes[s.node].y+=o),s.tracks.forEach(i=>{let a=e.tracks[i.trackID].path[i.segmentID];a.y=a.y+o})})}function ka(e,t,n){t.order<0||e.assignments[t.order]===void 0||(e.assignments[t.order].forEach(o=>{if(o.node!==null){let r=e.nodes[o.node];r!==t&&r.y>t.y&&(r.y+=n,o.tracks.forEach(s=>{let i=e.tracks[s.trackID].path[s.segmentID];i.y=i.y+n}))}else o.tracks.forEach(r=>{let s=e.tracks[r.trackID].path[r.segmentID];s.y>=t.y&&(s.y=s.y+n)})}),e.nodesPerOrder[t.order].forEach(o=>{let r=e.nodes[o];r!==t&&r.y>t.y&&(r.y+=n)}))}function Ra(e,t,n){let o=0;return t.forEach(r=>{r.tracks.forEach(s=>{let{type:i,path:a,width:l}=e.tracks[s.trackID];typeof s.idealY=="number"&&i!=="read"&&(o+=Math.abs(s.idealY-n-a[s.segmentID].y)*l)})}),o}function er(e,t){return e.idealLane===void 0||t.idealLane===void 0?+(e.idealLane===void 0)-+(t.idealLane===void 0):e.idealLane-t.idealLane}function $t(e,t){return e.order!==t.order?e.order-t.order:e.y!==void 0&&t.y!==void 0?e.y-t.y:0}function Ta(e){let n=e.config.trackWidth;if(e.config.freqWidth==="linear"){for(let o of e.tracks)o.width=o.type==="read"?4:Math.max(1,Math.round(o.freq??1))*n;return}for(let o of e.tracks)o.width=o.freq!==void 0?Math.round((Math.log(Math.max(o.freq,1))+1)*4):o.type==="read"?4:n;e.tracks.every(o=>o.width===4)&&e.tracks.forEach(o=>{o.freq!==void 0&&(o.width=n)})}function tr(e,t,n){let o=e.nodes[t.node];return ur(o,t.isForward?n:o.sequenceLength-n)}function fr(e,t){return t>e.sequenceLength?null:ur(e,t)}function ur(e,t){let[n,o]=Ia(e);if(e.sequenceLength===0)return n;let r=Math.min(Math.max(t,0),e.sequenceLength);return n+r/e.sequenceLength*(o-n)}function _a(e){e.extraLeft=new Array(e.maxOrder+1).fill(0),e.extraRight=new Array(e.maxOrder+1).fill(0);let t=[],n=[];e.nodes.forEach(r=>{r.x!==void 0&&(t[r.order]=r.x,n[r.order]=Math.max(n[r.order]??-1/0,r.x+r.pixelWidth))});let o=e.tracks[0];e.tracks.sort(ta),e.tracks.forEach(r=>{let{id:s,name:i,type:a,width:l,path:c}=r,f=(g,x,M)=>{e.shapes.rectangles.push({xStart:Math.min(g,x),yStart:M,xEnd:Math.max(g,x),yEnd:M+l-1,id:s,name:i,type:a})},u=g=>g.isForward?n[g.order]:t[g.order],d=c[0],p=d.y,h=a==="read"?tr(e,d,r.firstNodeOffset??0):d.isForward?t[d.order]-20:n[d.order]+20;for(let g=1;g<c.length;g+=1){let x=c[g-1],M=c[g];if(M.y===p)continue;let y=u(x);y!==h&&f(h,y,p);let w=M.y,v=M.order-x.order;if(v===1||v===-1){let S=v===1?t[M.order]:n[M.order];e.shapes.curves.push({xStart:v===1?y:y+1,yStart:p,xEnd:v===1?S+1:S,yEnd:w,width:l,id:s,name:i,type:a,nodeStart:x.node,nodeEnd:M.node,orderStart:x.order,orderEnd:M.order,...r===o?{reference:!0}:{}}),h=S}else Ca(e,r,x.isForward?1:-1,y,p,w,M.order),h=y;p=w}let m=c[c.length-1],b=a==="read"?tr(e,m,r.finalNodeCoverLength??0):u(m)+(m.isForward?20:-20);f(h,b,p)})}var Oa=1e9;function pr(e,t,n,o){let r=new Map,s=0,i=e.nodes.length,a=(m,b)=>(m+i)*(2*i+1)+b+i,l=e.config.ignoreStrand;for(let[m,b]of t.entries()){let g=Math.max(b.freq??1,1);s+=g;let x=b.indexSequence;if(!(x.length<2))for(let M=0;M<x.length-1;M+=1){let y=x[M],w=x[M+1],v=e.nodes[Math.abs(y)],S=e.nodes[Math.abs(w)],k=l?Math.min(a(y,w),a(-w,-y)):a(y,w),T=r.get(k);T===void 0?r.set(k,{sSigned:y,dSigned:w,sName:y<0?`-${v.name}`:v.name,dName:w<0?`-${S.name}`:S.name,count:g,crossings:g,sourceTrackID:b.sourceTrackID,lastSource:m}):(T.crossings+=g,T.lastSource!==m&&(T.count+=g,T.lastSource=m))}}let c=0;for(let m of r.values())m.crossings>c&&(c=m.crossings);let f=Ot,u=60,d=m=>c<=1?f:f+(u-f)*Math.sqrt(m/c),p=[],h=0;for(let m of r.values()){let b=o+h,g=n==="haplotype"?{count:m.count,total:s}:void 0,x=g===void 0?"":` (${$a(g)})`,M=m.crossings===m.count?"":`, ${m.crossings.toLocaleString()} crossings`,y=`${m.count.toLocaleString()} ${n}${m.count===1?"":"s"}${x}${M}: Node ${m.sName} \u2192 Node ${m.dName}`;e.coarsenedEdgeMeta.set(b,{count:m.count,label:y});let w=e.nodes[Math.abs(m.sSigned)].sequenceLength;p.push({id:b,sourceTrackID:m.sourceTrackID,type:"read",name:y,sequence:[m.sName,m.dName],indexSequence:[],path:[],width:d(m.crossings),firstNodeOffset:w,finalNodeCoverLength:0,sequenceNew:[{nodeName:m.sName,mismatches:[]},{nodeName:m.dName,mismatches:[]}],mapping_quality:0,is_secondary:!1,sample_name:null,read_group:null,score:m.count,haplotypeShare:g}),h+=1}return{bands:p,total:s}}function Aa(e,t){let n=e.trackForRuler===void 0?-1:e.tracks.findIndex(f=>f.name===e.trackForRuler),o=n===-1?0:n,r=e.tracks[o],s=(r.freq??1)-1,i=Pa(e,r),a=e.tracks.filter((f,u)=>u!==o).map(f=>Na(i,f));if(s>0&&a.push({...r,freq:s}),a.length===0)return;let{bands:l,total:c}=pr(e,a,"haplotype",t);return l.length>0?{ref:r,bands:l,total:c}:void 0}function Na(e,t){let n=0;for(let o of t.indexSequence){let r=e[Math.abs(o)];r!==void 0&&r!==0&&(n+=r===Math.sign(o)?1:-1)}return n>=0?t:{...t,sequence:t.sequence.map(_t).reverse(),indexSequence:t.indexSequence.map(o=>-o).reverse()}}function Pa(e,t){let n=new Int8Array(e.nodes.length);for(let o of t.indexSequence){let r=Math.abs(o);n[r]===0&&(n[r]=Math.sign(o))}return n}function $a({count:e,total:t}){let n=e/t;return n<.01?"<1%":n>.99&&e<t?">99%":`${Math.round(n*100)}%`}var nr=7;function Ca(e,{width:t,id:n,name:o,type:r},s,i,a,l,c){let f=s===1?e.extraRight:e.extraLeft,u=10*f[c],d=i+s*(u+5),p=nr,h=Math.min(nr,t),m=Math.min(a,l),b=Math.max(a,l),g=s===1?i:d-1,x=s===1?d:i,M=S=>{e.shapes.verticalRectangles.push({xStart:g,yStart:S,xEnd:x,yEnd:S+t-1,id:n,name:o,type:r})};M(a),e.shapes.verticalRectangles.push({xStart:s===1?d+p:d-p-h,yStart:m+t+p-1,xEnd:s===1?d+p+h-1:d-p-1,yEnd:b-p+1,id:n,name:o,type:r}),M(l);let y=d+s*p,w=d+s*(p+h),v=`M ${d} ${b}`;v+=` Q ${y} ${b} ${y} ${b-p}`,v+=` H ${w}`,v+=` Q ${w} ${b+t} ${d} ${b+t}`,v+=" Z ",e.shapes.corners.push({path:v,id:n,name:o,type:r}),v=`M ${d} ${m}`,v+=` Q ${w} ${m} ${w} ${m+t+p}`,v+=` H ${y}`,v+=` Q ${y} ${m+t} ${d} ${m+t}`,v+=" Z ",e.shapes.corners.push({path:v,id:n,name:o,type:r}),f[c]+=1}function Ia(e){let t=e.x-4,n=e.x+e.pixelWidth+4;return[t,n]}function or(e){switch(e.config.nodeWidthOption){case"compressed":e.nodes.forEach(t=>{t.width=1+Math.log2(Math.max(t.sequenceLength,1)),t.pixelWidth=Math.round((t.width-1)*Xe)});break;case"small":e.nodes.forEach(t=>{t.width=t.sequenceLength/100,t.pixelWidth=Math.max(Math.round((t.width-1)*Xe),0)});break;case"fixed":e.nodes.forEach(t=>{t.width=10,t.pixelWidth=Math.round(t.width*Xe)});break;case"normal":{let t=e.config.charWidth;e.nodes.forEach(n=>{n.width=n.sequenceLength,n.pixelWidth=Math.round(t*Math.max(n.sequenceLength-1,0))});break}default:throw new Error(`${e.config.nodeWidthOption} not implemented`)}}var Q=0;function rr(e){return{first:new Int32Array(e),count:new Uint8Array(e)}}function L(e,t,n){let o=e.count[t];o===0?(e.first[t]=n,e.count[t]=1):o===1&&e.first[t]!==n&&(e.count[t]=2)}function xe(e,t){return e.count[t]===1?Math.abs(e.first[t]):0}function La(e){let t=rr(e.nodes.length),n=rr(e.nodes.length),o=new Map,r=u=>{let d=o.get(u);if(d===void 0){let p=e.nodeMap.get($(u));d=P(u)?-p:p,o.set(u,d)}return d};e.tracks.concat(e.reads).forEach(u=>{let{sequence:d}=u,p=u.type==="haplotype",h=d.length-1,m=Q,b=h>=0?r(d[0]):Q;for(let g=0;g<=h;g+=1){let x=g<h?r(d[g+1]):Q;if(b>0)g>0?(L(t,b,m),m<0&&L(t,b,-m)):p&&L(t,b,Q),g<h?(L(n,b,x),x<0&&L(n,b,-x)):p&&L(n,b,Q);else{let M=-b;g>0?(L(n,M,-m),m>0&&L(n,M,m)):p&&L(n,M,Q),g<h?(L(t,M,-x),x>0&&L(t,M,x)):p&&L(t,M,Q)}m=b,b=x}});let i=new Uint8Array(e.nodes.length);e.nodes.forEach((u,d)=>{Ba(d,t,n)&&(i[d]=1)});let a=new Int32Array(e.nodes.length),l=new Float64Array(e.nodes.length),c=new Float64Array(e.nodes.length);e.nodes.forEach((u,d)=>{if(i[d]!==1){a[d]=d,c[d]=u.sequenceLength;for(let p=d;Xa(p,t,n);)p=xe(n,p),a[p]=d,l[p]=u.sequenceLength,u.sequenceLength+=e.nodes[p].sequenceLength,u.seq+=e.nodes[p].seq,c[p]=u.sequenceLength}}),e.reads.forEach(u=>{let{sequence:d}=u,p=u.sequenceNew??d.map(M=>({nodeName:M,mismatches:[]})),h=M=>{let y=Math.abs(r(M));return P(M)?e.nodes[a[y]].sequenceLength-c[y]:l[y]},m=d.length-1;u.firstNodeOffset=(u.firstNodeOffset??0)+h(d[0]),u.finalNodeCoverLength=(u.finalNodeCoverLength??0)+h(d[m]);let b=[],g=[],x=[];d.forEach((M,y)=>{let w=Math.abs(r(M)),{mismatches:v}=p[y],S=h(M);if(v.forEach(k=>{k.pos+=S}),i[w]===1&&!P(M)&&y>0)g.at(-1).mismatches.push(...v);else if(i[w]===1&&P(M)&&y<m)x.push(...v);else{let k=e.nodes[a[w]].name,T=P(M)?lr(k):k;b.push(T),g.push({nodeName:T,mismatches:x.concat(v)}),x=[]}}),u.sequence=b,u.sequenceNew!==void 0&&(u.sequenceNew=g)}),e.tracks.forEach(u=>{let{sequence:d}=u,p=0;for(let h of d)i[Math.abs(r(h))]===0&&(d[p]=h,p+=1);d.length=p});let f=1;for(let u=1;u<e.nodes.length;u+=1)i[u]===0&&(e.nodes[f]=e.nodes[u],f+=1);e.nodes.length=f}function Ba(e,t,n){let o=xe(t,e);return o!==0&&xe(n,o)!==0}function Xa(e,t,n){let o=xe(n,e);return o!==0&&xe(t,o)!==0}function Da(e,t){return t.xStart-e.xStart||e.yStart-t.yStart}function Ct(e){return[e.nodeStart??-1,e.nodeEnd??-1,e.nodeStart===null?e.orderStart:-1,e.nodeEnd===null?e.orderEnd:-1]}function Fa(e,t){for(let n=0;n<e.length;n+=1){let o=e[n]-t[n];if(o!==0)return o}return 0}var hr=.75,De=.8;function qa(e,t){let n=e[0],o=Math.min(Math.abs(n.xEnd-n.xStart),t);if(o===0)return e.map(()=>0);let r=e.length>5?.4/e.length:0,s=e.map(d=>{let p=Math.abs(d.yEnd-d.yStart),h=p/Math.hypot(p,o)*Math.min(d.width,De*hr*o);return Math.max(r,h/(hr*o))}),i=d=>s.reduce((p,h,m)=>p+(d(e[m])?h:0),0),a=i(d=>d.reference===!0),l=i(d=>d.reference!==!0),c=a>De?De/a:1,f=De-a*c,u=l>f?f/l:1;return s.map((d,p)=>d*(e[p].reference?c:u))}function mr(e,t,{gapWidth:n=1/0}={}){let o=Wo(e.filter(r=>r.type===t),r=>Ct(r).join(","));return o.forEach(r=>{r.sort(Da);let s=qa(r,n),i=.5-s.reduce((a,l)=>a+l,0)/2;r.forEach((a,l)=>{let c=p=>a.xStart+(a.xEnd-a.xStart)*(a.yStart<a.yEnd?1-p:p),f=c(i);i+=s[l];let u=c(i),d=`M ${a.xStart} ${a.yStart}`;d+=` C ${f} ${a.yStart} ${f} ${a.yEnd} ${a.xEnd} ${a.yEnd}`,d+=` V ${a.yEnd+a.width}`,d+=` C ${u} ${a.yEnd+a.width} ${u} ${a.yStart+a.width} ${a.xStart} ${a.yStart+a.width}`,d+=" Z",a.path=d})}),[...o.values()].sort((r,s)=>Fa(Ct(r[0]),Ct(s[0]))).flat()}function gr(e,t=16){let n=e.match(/[A-Za-z]|-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?/g)??[],o=[],r=0,s=0,i=0,a=()=>Number(n[i++]);for(;i<n.length;){let l=n[i++];if(l==="M"||l==="L")r=a(),s=a(),o.push([r,s]);else if(l==="H")r=a(),o.push([r,s]);else if(l==="V")s=a(),o.push([r,s]);else if(l==="C"){let[c,f,u,d,p,h]=[a(),a(),a(),a(),a(),a()];for(let m=1;m<=t;m+=1){let b=m/t,g=1-b,x=g*g*g,M=3*g*g*b,y=3*g*b*b,w=b*b*b;o.push([x*r+M*c+y*u+w*p,x*s+M*f+y*d+w*h])}r=p,s=h}else if(l==="Q"){let[c,f,u,d]=[a(),a(),a(),a()];for(let p=1;p<=t;p+=1){let h=p/t,m=1-h;o.push([m*m*r+2*m*h*c+h*h*u,m*m*s+2*m*h*f+h*h*d])}r=u,s=d}else if(l!=="Z")throw new Error(`flattenPath: unsupported path command ${l}`)}return o}function br(e){let t=`M ${e.x-9} ${e.y} Q ${e.x-9} ${e.y-9} ${e.x} ${e.y-9}`,n=e.x,o=e.y-9;return e.width>1&&(n+=e.pixelWidth,t+=` L ${n} ${o}`),t+=` Q ${n+9} ${o} ${n+9} ${o+9}`,n+=9,o+=9,e.contentHeight>0&&(o+=e.contentHeight,t+=` L ${n} ${o}`),t+=` Q ${n} ${o+9} ${n-9} ${o+9}`,n-=9,o+=9,e.width>1&&(n-=e.pixelWidth,t+=` L ${n} ${o}`),t+=` Q ${n-9} ${o} ${n-9} ${o-9}`,n-=9,o-=9,e.contentHeight>0&&(o-=e.contentHeight,t+=` L ${n} ${o}`),t}function It(e){let t=new Map(e.nodes.map(r=>[r.id,r])),n=e.pathVisits,o=n?.replay();return(e.paths??[]).map(r=>{let s=n?.pathIndex(I(r.name).name)??-1;return r.nodeIds.flatMap(i=>{let a=t.get(i);if(!a)return[];let l=n&&o?o(n.slot(a.name),s):-1;return[{node:a,strand:l>=0?n.strand(l):H(a.id)}]})})}function Ga(e){let t=It(e),n=(e.paths??[]).flatMap((s,i)=>{let a=t[i].map(l=>pt(l.node,l.strand));return a.length>0?[{id:i,name:s.name,sequence:a,sourceTrackID:0,type:"haplotype",...s.members?{freq:s.members.length}:{}}]:[]}),o=Ee(e),r=n.findIndex(s=>I(s.name).name===o);return r>0&&n.unshift(...n.splice(r,1)),n}function Ya(e){return e.nodes.map(t=>({name:t.id,seq:"",sequenceLength:Math.max(1,t.length)}))}function yr(e){return(e.paths?.length??0)>0}var Wa=600,Ha=3,Ua=15;function ja(e){return Math.max(Ha,Math.min(Ua,Math.floor(Wa/Math.max(1,e))))}function Va(e){let t=new Set,n=new Set;for(let o of e?.sequence??[])P(o)?n.has($(o))||t.add($(o)):n.add(o);return t}function Ka(e,t,n){let o=Va(n[0]),r=new Map;for(let{sequence:l,is_secondary:c}of n)c||l.forEach((f,u)=>{let d=$(f),h=P(f)!==o.has(d)?l[u+1]:l[u-1];!t.nodeMap.has(d)&&h!==void 0&&r.set(d,$(h))});let s=new Map(e.nodes.map(l=>[l.id,Math.max(1,l.length)])),i=new Map([...r].map(([l,c])=>[c,l])),a=new Map;for(let l of i.keys()){let c=t.nodeMap.get(l);if(c!==void 0){let f=[l];for(let d=i.get(l);d!==void 0;d=i.get(d))f.push(d);f.reduce((d,p)=>d+(s.get(p)??0),0)===t.nodes[c].sequenceLength&&a.set(l,f)}}return{members:a,flipped:o}}var za={start:"end",end:"start"},xr={"+":"-","-":"+"};function Za(e,{members:t,flipped:n}){if(t.size===0)return e;let o=new Map(e.nodes.map(d=>[d.id,d])),r=new Map,s=new Set,i=(d,p)=>n.has(d)?za[p]:p;for(let[d,p]of t)p.forEach((h,m)=>{r.set(h,d);let b=p[m+1];b!==void 0&&s.add(`${h}:${i(h,"end")} ${b}:${i(b,"start")}`)});let a=new Set([...r].filter(([d,p])=>d!==p).map(([d])=>d)),l=e.nodes.flatMap(d=>{let p=t.get(d.id);if(!p)return a.has(d.id)?[]:[d];let h=p.map(b=>o.get(b)),m=h.flatMap(b=>b.stable?[b.stable.start]:[]);return[{...d,length:h.reduce((b,g)=>b+g.length,0),stable:d.stable&&{...d.stable,start:Math.min(...m)}}]}),c=(d,p,h)=>i(p,i(d,h))==="end"?H(p):xr[H(p)],f=e.edges.flatMap(d=>{let p=fn(d),h=`${d.from}:${p.from}`,m=`${d.to}:${p.to}`;if(s.has(`${h} ${m}`)||s.has(`${m} ${h}`))return[];let b=r.get(d.from),g=r.get(d.to);return[{...d,...b===void 0?{}:{from:b,fromStrand:c(d.from,b,p.from)},...g===void 0?{}:{to:g,toStrand:xr[c(d.to,g,p.to)]}}]}),u=new Set([...a].map(d=>o.get(d)?.name??d));return{...e,nodes:l,edges:f,paths:e.paths?.map(d=>({...d,nodeIds:d.nodeIds.filter(p=>!a.has(p))})),pathVisits:e.pathVisits?.filter(()=>!0,d=>!u.has(d))}}function wr(e){let t=e.paths??[],n=Ga(e),o=e.reads?bo(e,e.reads,t.length):[],r=o.length>0?wn:yn,s=t.map((f,u)=>r(u,t.length)),i=t.some(f=>f.members),a=t.reduce((f,u)=>f+(u.members?.length??1),0),l=ir(Ya(e),n,o,{nodeWidthOption:"compressed",trackWidth:ja(i?a:n.length),...i?{freqWidth:"linear"}:{}});if(!l)return;let c=Ka(e,l,[...n,...o]);return{layout:l,pathColors:s,members:c.members,graph:Za(e,c)}}function Lt(e){let t=[];return e.nodes.forEach(n=>{n.order>=0&&t.push(n)}),t}function Mr(e,t,n,o){let r=e.y+e.contentHeight/2-t;return[{x:n,y:r},{x:o,y:r}]}function vr(e,t){return{minY:e.bounds.minY-t,maxY:e.bounds.maxY-t}}function fh(e){let t=yr(e)?wr(e):void 0;if(!t)return;let{layout:n,...o}=t,r=n.bounds.minY,s={};for(let l of Lt(n))s[l.name]=Mr(l,r,l.x,l.x+l.pixelWidth);let{minY:i,maxY:a}=vr(n,r);return{nodePositions:s,tubeMap:{layout:n,yOffset:r,...o},extent:{minX:n.bounds.minX,maxX:n.bounds.maxX,minY:i,maxY:a}}}function Ja(e,t){let n=new Map(e.nodes.map(a=>[a.id,a])),o=zt(Lt(t),a=>a.order),r=[],s=-1/0;for(let a of[...o.keys()].sort((l,c)=>l-c)){let l=o.get(a),c=1/0,f=-1/0;for(let u of l){let d=n.get(u.name);d&&O(d)&&(c=Math.min(c,d.stable.start),f=Math.max(f,d.stable.start+d.length))}c===1/0&&(c=f=s),c<s&&(c=s,f=Math.max(s,f)),s=Math.max(s,f),r.push({order:a,x0:Math.min(...l.map(u=>u.x)),x1:Math.max(...l.map(u=>u.x+u.pixelWidth)),bp0:c,bp1:f})}let i=r.find(a=>a.bp0!==-1/0);for(let a of r)a.bp0===-1/0&&(a.bp0=a.bp1=i?.bp0??0);return r}function Qa(e){return yr(e)&&e.nodes.some(O)}function uh(e){let t=Qa(e)?wr(e):void 0;if(!t)return;let{layout:n,...o}=t,r=Ja(o.graph,n),s=new Map(r.map(l=>[l.order,l])),i=n.bounds.minY,a={};for(let l of Lt(n)){let c=s.get(l.order);a[l.name]=Mr(l,i,c.bp0,c.bp1)}return{nodePositions:a,tubeMap:{layout:n,yOffset:i,columns:r,...o},referenceAxis:!0,pixelRows:!0,extent:vr(n,i)}}function ec(e,t){let n=[],o=()=>({a:-1/0,b:1/0,detour:[],bp:0}),r=[o()];for(let{node:s,strand:i}of t){let a=r.at(-1),l=n.at(-1);if(O(s)){let c=s.stable.start,f=c+s.length,u=i!==(s.stable.strand??"+"),d=l!==void 0&&a.detour.length===0;d&&!l.inverted&&!u&&l.end===c?l.end=f:d&&l.inverted&&u&&l.start===f?l.start=c:(n.push({start:c,end:f,inverted:u}),r.push(o()))}else a.detour.push({node:s,strand:i}),a.bp+=s.length}return n.forEach((s,i)=>{r[i].b=s.start,r[i+1].a=s.end}),{path:e,runs:n,gaps:r}}function Bt(e,t){return Number.isFinite(e.a)&&Number.isFinite(e.b)&&e.b>=e.a&&Math.max(e.b-e.a,e.bp)<t}function Er(e,t,n){let o=K(e.length,r=>e[r]<=t);return o<e.length&&e[o]<n}function tc(e){let t=new Map;for(let n=1;n<e.length;n++){let o=e[n-1],r=e[n],s=o.stable.start+o.length;s!==r.stable.start&&(t.set(s,"reference-gap"),t.set(r.stable.start,"reference-gap"))}return t}function nc(e,t,n){let o=(s,i)=>{Number.isFinite(s)&&!n.has(s)&&n.set(s,i)};for(let{runs:s,gaps:i}of e){let a=s[0],l=s.at(-1);a&&l&&(o(a.start,"walk-end"),o(l.end,"walk-end"));for(let c of s)c.inverted&&c.end-c.start>=t&&(o(c.start,"inversion"),o(c.end,"inversion"));for(let c of i)c.b<c.a?(o(c.a,"backward"),o(c.b,"backward")):Bt(c,t)||(o(c.a,"variant"),o(c.b,"variant"))}let r=e.flatMap(({runs:s,gaps:i})=>[...i.filter(a=>Bt(a,t)).map(a=>[a.a,a.b]),...s.filter(a=>a.inverted&&a.end-a.start<t).map(a=>[a.start,a.end])]);for(let s=!0;s;){s=!1;let i=[...n.keys()].sort((a,l)=>a-l);for(let[a,l]of r)Er(i,a,l)&&(s||=!n.has(a)||!n.has(l),o(a,"overlap"),o(l,"overlap"))}return n}function oc(e,t){let n=[],o=[],r=()=>{let s=o[0],i=o.at(-1);if(s&&i){let a=s.stable.start,l=i.stable.start+i.length,c=`${a}-${l}`;n.push({node:{id:`${c}+`,name:c,length:l-a,depth:0,stable:{refName:s.stable.refName,start:a,rank:0,strand:"+"}},members:o})}o=[]};for(let s of e)t.has(s.stable.start)&&r(),o.push(s);return r(),n}function Xt(e,t,n){return Math.max(0,K(e.length,o=>t(e[o])<=n)-1)}function yh(e,t){let n=e.nodes.filter(O).sort((y,w)=>y.stable.start-w.stable.start),o=e.paths??[];if(n.length===0||o.length===0)return;let r=It(e),s=o.map((y,w)=>ec(y,r[w])),i=nc(s,t,tc(n)),a=[...i.keys()].sort((y,w)=>y-w),l=oc(n,i),c=y=>Xt(l,w=>w.node.stable.start,y),f=new Map,u=new Map;for(let y of l){f.set(y.node.id,y.members.map(w=>w.id));for(let w of y.members)u.set(w.id,y.node.id)}let d=new Map,p=y=>{let w=`${y.a} ${y.b} ${y.detour.map(S=>S.node.id+S.strand).join(",")}`,v=d.get(w);if(!v){let S=`r${d.size}`;v={id:`${S}+`,name:S,length:y.bp,depth:0,stable:{refName:n[0].stable.refName,start:Number.isFinite(y.a)?y.a:y.b,rank:1,strand:"+"}},d.set(w,v),f.set(v.id,y.detour.map(k=>k.node.id));for(let k of y.detour)u.has(k.node.id)||u.set(k.node.id,v.id)}return v},h=new Map,m=[],b=new tn,g=new Map,x=new Map;for(let{path:y,runs:w,gaps:v}of s){let S=[],k=[],T=!1,G=(R,B)=>{let C=S.at(-1);T&&C?.node===R&&C.strand===B||S.push({node:R,strand:B}),T=!0},Y=R=>{T=!1,R.detour.length>0&&(G(p(R),"+"),T=!1)},ye=R=>{(R.bp>0||R.b>R.a)&&k.push({start:R.a,end:R.b,bp:R.bp});let B=l[c(R.b>R.a?R.a:R.a-1)];for(let C of R.detour)u.has(C.node.id)||(u.set(C.node.id,B.node.id),f.get(B.node.id).push(C.node.id))};w.forEach((R,B)=>{let C=v[B];Bt(C,t)&&!Er(a,C.a,C.b)?ye(C):Y(C);let W=c(R.start),ce=c(R.end-1),ve=R.end-R.start<t;if(R.inverted&&!ve){T=!1;for(let V=ce;V>=W;V--)G(l[V].node,"-");T=!1}else{R.inverted&&k.push({start:R.start,end:R.end,bp:R.end-R.start,inverted:!0});for(let V=W;V<=ce;V++)G(l[V].node,"+")}}),Y(v.at(-1));let we=I(y.name).name,Me=0;S.forEach(({node:R,strand:B},C)=>{x.set(R.id,(x.get(R.id)??0)+1),b.add(R.name,we,y.sample??we,Me,B==="-"),Me+=R.length;let W=S[C+1];if(W){let ce=`${R.id}${B} ${W.node.id}${W.strand}`,ve=g.get(ce);ve?ve.pathIds.push(y.name):g.set(ce,{from:R.id,to:W.node.id,fromStrand:B,toStrand:W.strand,pathIds:[y.name]})}}),m.push({...y,nodeIds:S.map(R=>R.node.id)}),h.set(y.name,k)}let M=[...l.map(y=>y.node),...d.values()].filter(y=>x.has(y.id)).map(y=>({...y,depth:x.get(y.id)}));return{graph:{...e,nodes:M,edges:[...g.values()],paths:m,pathVisits:b.build(),reads:void 0},members:f,coarseOf:u,deviations:h,cuts:i}}function vh(e,t){return t?e.filter(n=>t.includes(n.sample)).sort((n,o)=>t.indexOf(n.sample)-t.indexOf(o.sample)||n.label.localeCompare(o.label)):e}function Eh(e,t,n,o={}){let r=on(e,t,o);return r&&rn(r,n)}function rc(e,t,n){let o=Xt(e,r=>r.bp0,t);return[e[o],e[o-1]].find(r=>r&&n.has(r.index)&&r.bp0<=t&&t<=r.bp1)}function sc(e,t){let n=new Map;for(let[r,s]of t)for(let i of s)te(n,I(r).name,i);let o=new Map;for(let r of e.paths??[])if(r.members){let s=new Map;for(let i of r.members.flatMap(a=>n.get(a)??[]))s.set(`${i.start}-${i.end}`,i);o.set(r.name,[...s.values()])}else o.set(r.name,t.get(r.name)??[]);return o}function Kh(e,t){let{graph:n,layout:o}=e,r=[...Et(e).values()].flat().sort((a,l)=>a.bp0-l.bp0),s=sc(n,t),i=[];for(let a of o.tracks){let l=a.name?s.get(a.name):void 0;if(l?.length){let c=new Map;for(let f of a.path)f.node!==null&&f.y!==void 0&&!c.has(f.node)&&c.set(f.node,f.y);for(let f of l){let u=rc(r,f.start,c);u&&i.push({x0:be(u,f.start),x1:be(u,f.end),y:c.get(u.index),height:a.width})}}}return i}function ic(e){return e?"rgba(255,255,255,0.9)":"rgba(0,0,0,0.8)"}function zh(e,t,{x:n,y:o,width:r,darkMode:s}){if(t.length!==0){e.fillStyle=ic(s),e.beginPath();for(let i of t){let a=n(i.x0),l=Math.max(n(i.x1),a+1);if(l>=0&&a<=r){let c=o(i.y);e.rect(a,c,l-a,o(i.y+i.height)-c)}}e.fill()}}function ac(e,t){let n=[],o=e.sequenceNew??[],r=e.path.filter(s=>s.node!==null);return o.forEach((s,i)=>{let a=t.nodeMap.get($(s.nodeName)),l=a===void 0?void 0:t.nodes[a],c=r[i];if(l&&c?.y!==void 0){let f={readId:e.id,y:c.y,height:e.width},u=d=>fr(l,d);for(let d of s.mismatches){let p=c.isForward?d:At(d,l.sequenceLength),h=u(p.pos);if(h!==null){if(p.type==="insertion")n.push({...f,kind:"insertion",x:h,seq:p.seq});else if(p.type==="deletion"&&p.length!==void 0){let m=u(p.pos+p.length);m!==null&&n.push({...f,kind:"deletion",x0:h,x1:m,length:p.length})}else if(p.type==="substitution"&&p.seq!==void 0){let m=u(p.pos+p.seq.length);m!==null&&n.push({...f,kind:"substitution",x0:h,x1:m,seq:p.seq})}}}}}),n}function Sr(e){return e.reads.flatMap(t=>ac(t,e))}var Dt=24,cc=.5,lc=e=>e.bp1>e.bp0;function tm(e,t){let n=e.filter(lc);if(n.length===0){let c=e[0];return c?[{tx:c.x0,sx:t(c.bp0)}]:[]}let o=[],r=[],s=[];n.forEach((c,f)=>{o.push(c.x0,c.x1),r.push(t(c.bp0),t(c.bp1)),s.push(f===0?0:Math.min(c.x0-n[f-1].x1,Dt),0)});let i=r.at(-1)-r[0],a=s.reduce((c,f)=>c+f,0),l=a>0?Math.min(1,cc*i/a):1;return dc(r,s,l).map((c,f)=>({tx:o[f],sx:c}))}function dc(e,t,n){let o=[],r=0;for(let i of t)r+=i*n,o.push(r);let s=[];return e.forEach((i,a)=>{let l={mean:i-o[a],n:1},c=s.at(-1);for(;c&&c.mean>=l.mean;){s.pop();let f=c.n+l.n;l={mean:(c.mean*c.n+l.mean*l.n)/f,n:f},c=s.at(-1)}s.push(l)}),s.flatMap(i=>Array(i.n).fill(i.mean)).map((i,a)=>i+o[a])}function nm(e,t){let n=e.length;if(n===0)return t;let o=e[0],r=e[n-1];if(t<=o.tx)return o.sx+(t-o.tx);if(t>=r.tx)return r.sx+(t-r.tx);let s=1+K(n-2,c=>e[c+1].tx<=t),i=e[s-1],a=e[s],l=a.tx-i.tx;return l>0?i.sx+(t-i.tx)/l*(a.sx-i.sx):i.sx}function Gt(e){let t=e.trim().split(/[\s,]+/),n=[],o=0,r=()=>Number(t[o++]);for(;o<t.length;){let s=t[o++];s==="M"||s==="L"?n.push({op:s,x:r(),y:r()}):s==="H"?n.push({op:s,x:r()}):s==="V"?n.push({op:s,y:r()}):s==="Q"?n.push({op:s,x1:r(),y1:r(),x:r(),y:r()}):s==="C"?n.push({op:s,x1:r(),y1:r(),x2:r(),y2:r(),x:r(),y:r()}):s==="Z"&&n.push({op:s})}return n}function _r(e){let t=1/0,n=-1/0;for(let o of e)"x"in o&&(t=Math.min(t,o.x),n=Math.max(n,o.x)),"x1"in o&&(t=Math.min(t,o.x1),n=Math.max(n,o.x1));return{x0:t,x1:n}}function kr(e,t,n,o,r){let s=Gt(e);return{commands:s,outline:gr(e,12),color:t,id:n,haplotype:o,reference:r,..._r(s)}}function Or(e,t){return new Map(e.tracks.map(n=>[n.id,n.type==="read"?xo(n):t[n.id]]))}function Rr(e,t,n,o,r){let{shapes:s}=e,i=t==="haplotype",a=d=>n.get(d.id),l=d=>i&&o.has(d.id),c=[...s.rectangles,...s.verticalRectangles].filter(d=>d.type===t).map(d=>({color:a(d),id:d.id,haplotype:i,reference:l(d),x0:d.xStart,x1:d.xEnd+1,y0:d.yStart,y1:d.yEnd+1})),f=mr(s.curves,t,{gapWidth:r}).map(d=>kr(d.path,a(d),d.id,i,l(d))),u=s.corners.filter(d=>d.type===t).map(d=>kr(d.path,a(d),d.id,i,l(d)));return{rects:c,shapes:[...f,...u]}}function fc(e){let t=new Set,n=e&&Ee(e);return e?.paths?.forEach((o,r)=>{I(o.name).name===n&&t.add(r)}),t}function uc({layout:e,pathColors:t,graph:n,columns:o}){let r=Or(e,t),s=fc(n),i=o?Dt:void 0,a=[];return e.nodes.forEach(l=>{if(l.order>=0){let c=Gt(br(l));a.push({name:l.name,commands:c,..._r(c)})}}),{bounds:e.bounds,layers:[Rr(e,"haplotype",r,s,i),Rr(e,"read",r,s,i)],nodes:a,mismatches:Sr(e)}}function Ft(e,t,n,o){let r=0,s=0;for(let i of t)switch(i.op){case"M":r=i.x,s=i.y,e.moveTo(n(r),o(s));break;case"L":r=i.x,s=i.y,e.lineTo(n(r),o(s));break;case"H":r=i.x,e.lineTo(n(r),o(s));break;case"V":s=i.y,e.lineTo(n(r),o(s));break;case"Q":r=i.x,s=i.y,e.quadraticCurveTo(n(i.x1),o(i.y1),n(r),o(s));break;case"C":r=i.x,s=i.y,e.bezierCurveTo(n(i.x1),o(i.y1),n(i.x2),o(i.y2),n(r),o(s));break;case"Z":e.closePath();break}}function Tr(e,t,n,o,r){let s=new Map;for(let i of t)n(i)&&te(s,o(i),i);for(let i of s.values()){e.fillStyle=o(i[0]),e.beginPath();for(let a of i)r(a);e.fill()}}var pc=12,hc=.15;function mc(e){return Math.max(hc,Math.min(1,e/pc))}var gc=.55;function bc(e,t,n){let{x:o,y:r,width:s}=n,i=f=>o(f.x1)>=0&&o(f.x0)<=s,a=f=>f.haplotype&&n.tubeColors?.[f.id]||f.color;e.globalAlpha=1;for(let f of t.layers)for(let u of[!1,!0]){let d=p=>p.reference===u;Tr(e,f.rects,p=>d(p)&&i(p),a,p=>{let h=o(p.x0),m=r(p.y0);e.rect(h,m,o(p.x1)-h,r(p.y1)-m)}),Tr(e,f.shapes,p=>d(p)&&i(p),a,p=>{Ft(e,p.commands,o,r)})}let l=n.darkMode?"#d0d0d0":"#000000",c=n.darkMode?"rgba(40,40,40,0.4)":"rgba(255,255,255,0.4)";e.lineWidth=Ar(n);for(let f of t.nodes)if(i(f)&&f.name!==n.highlightNode){e.beginPath(),Ft(e,f.commands,o,r);let u=n.nodeColors?.get(f.name);e.fillStyle=u??c,e.strokeStyle=l,e.globalAlpha=u?gc:1,e.fill(),e.globalAlpha=mc(o(f.x1)-o(f.x0)),e.stroke(),e.globalAlpha=1}Fe(e,t,n),yc(e,t.mismatches,n)}function Ar(e){return 2*Math.max(.25,Math.min(1,e.yScale))}function Fe(e,t,n){let o=n.highlightNode?t.nodes.find(r=>r.name===n.highlightNode):void 0;o&&(e.beginPath(),Ft(e,o.commands,n.x,n.y),e.globalAlpha=1,e.lineWidth=Ar(n),e.fillStyle="rgba(255,192,203,0.5)",e.strokeStyle="#ff0000",e.fill(),e.stroke())}var Nr=12,xc=6;function Yt(e){return Nr*e>=xc}function qt(e,{x:t,width:n}){let[o,r]=e.kind==="insertion"?[e.x,e.x]:[e.x0,e.x1];return t(r)>=0&&t(o)<=n}function yc(e,t,n){let{x:o,y:r,yScale:s,darkMode:i}=n;if(!Yt(s)||t.length===0)return;let a=Nr*s;e.fillStyle="grey",e.beginPath();for(let l of t)if(l.kind==="deletion"&&qt(l,n)){let c=o(l.x0),f=r(l.y);e.rect(c,f,o(l.x1)-c,r(l.y+l.height)-f)}e.fill(),e.font=`${a}px monospace`,e.textAlign="left",e.textBaseline="alphabetic",e.fillStyle=i?"#ffffff":"#000000";for(let l of t)qt(l,n)&&(l.kind==="substitution"?e.fillText(l.seq,o(l.x0)+1,r(l.y+l.height)):l.kind==="insertion"&&e.fillText("*",o(l.x)-3,r(l.y+l.height)))}function wc(e,t,n){let o=!1;for(let r=0,s=e.length-1;r<e.length;s=r++){let[i,a]=e[r],[l,c]=e[s];a>n!=c>n&&t<(l-i)*(n-a)/(c-a)+i&&(o=!o)}return o}function Mc(e,{x:t,y:n},o,r){for(let s=e.layers.length-1;s>=0;s--){let{rects:i,shapes:a}=e.layers[s];for(let l of[!0,!1]){for(let c of i)if(c.reference===l&&t(c.x0)<=o&&o<=t(c.x1)&&n(c.y0)<=r&&r<=n(c.y1))return c.id;for(let c of a)if(c.reference===l&&t(c.x0)<=o&&o<=t(c.x1)&&wc(c.outline.map(([f,u])=>[t(f),n(u)]),o,r))return c.id}}}var vc=4;function Ec(e,t,n,o){let{x:r,y:s,yScale:i}=t;return Yt(i)?e.mismatches.find(a=>s(a.y)<=o&&o<=s(a.y+a.height)&&(a.kind==="insertion"?Math.abs(r(a.x)-n)<=vc:r(a.x0)<=n&&n<=r(a.x1))):void 0}var ee=JBrowseExports["@jbrowse/core/util/groupKeys"],Sc=e=>ee!=null&&e in Object(ee)?ee[e]:Object.assign(function(){throw new Error("This JBrowse does not provide '"+e+"' from '@jbrowse/core/util/groupKeys' to plugins: GraphGenomeView was built for a different JBrowse version, so update the plugin or JBrowse")},{jbrowseHostMissing:e});var qe=Sc("groupKeyComparator");var ng=ee&&ee.__esModule?ee.default:ee;var Ge=16;function ig(e){let[t="",...n]=e.split(/\r\n|\r|\n/),o=t.split(" ").slice(1),r=new Map;for(let s of n){if(!s)continue;let[i="",...a]=s.split(" ");i&&!r.has(i)&&r.set(i,{...Object.fromEntries(o.map((l,c)=>[l,a[c]??""])),name:i})}return[...r.values()]}function ag(e){let t=new Set;for(let n of e??[])for(let o of Object.keys(n))o!=="name"&&t.add(o);return[...t]}function cg(e){if(typeof e=="string")return e?{field:e}:void 0;let{field:t,domain:n}=e??{};if(!(typeof t!="string"||!t))return Array.isArray(n)?{field:t,domain:n.filter(o=>typeof o=="string")}:{field:t}}function Wt(e,t){return`${e} ${t}${e===1?"":"s"}`}function Ht(e,t){let n=new Map(t.map(o=>[o.name,o[e]??""]));return(o,r)=>n.get(o)||n.get(r)||""}function Ut(e,t,{field:n,domain:o},r,s){let i=new Map;for(let a of e){let l=t(a),c=i.get(l);c?c.push(a):i.set(l,[a])}return[...i.keys()].sort(qe(o)).map(a=>{let l=i.get(a),c=new Set(l.map(s)).size;return{key:a,members:l,title:`${a||`${n}: none`} \xB7 ${Wt(c,r)}`}})}function lg(e,t,n){let o=Ht(n.field,t),r=Ut(e,a=>o(a.label,a.sample),n,"haplotype",a=>a.label),s=1,i=r.map(({key:a,members:l,title:c})=>{let f={key:a,title:c,first:s,count:l.length};return s+=l.length,f});return{rows:r.flatMap(a=>a.members),sections:i}}function dg(e,t){let n=r=>{let s=-1;for(;s+1<e.length&&e[s+1].first<=r;)s++;return s},o=r=>r*t+(n(r)+1)*Ge;return{rowY:o,headers:e.map((r,s)=>({...r,top:(r.first-.5)*t+s*Ge})),headersPx:e.length*Ge,rowAt(r,s){let i=0;for(let a=-1;a<e.length;a++){let l=a<0?0:e[a].first,c=a<0?Math.min(s,e[0]?.first??s):l+e[a].count,f=(a+1)*Ge,u=Math.min(c-1,Math.max(l,Math.round((r-f)/t)));Math.abs(o(u)-r)<Math.abs(o(i)-r)&&(i=u)}return i}}}function fg(e,t,n,o,r){return t.length===0?[ge(e,o,r)]:[ge({...e,rows:[]},o,r),...t.flatMap((s,i)=>ge({...e,rows:e.rows.slice(s.first-1,s.first-1+s.count)},{...o,translateY:o.translateY+(n(s.first)-o.rowPx)*o.scaleY},{...r,idPrefix:`${r.idPrefix}-s${i}`}).children.filter(l=>typeof l!="string"&&l.attrs["data-testid"]!=="graph-walk-reference"))]}function kc(e,t,n,o){let r=[],s=[],i=[e];for(o.add(e);i.length>0;){let a=i.pop(),l=t.get(a);if(l){r.push(l);for(let c of n.get(a)??[]){let f=t.get(c);f&&(f.stable.rank===We?s.push(f):o.has(c)||(o.add(c),i.push(c)))}}}return{members:r,anchors:s}}function Rc(e){if(new Set(e.map(a=>a.stable.refName)).size!==1||e.length<2)return;let n=[...e].sort((a,l)=>a.stable.start-l.stable.start),o=n[0],r=n.at(-1),s=o.stable.start+o.length,i=r.stable.start;return i>=s?{start:s,end:i,entry:o}:void 0}function Tc(e,t,n){let o=new Map(e.map(i=>[i.id,i])),r=new Map,s=[];for(let i of n.get(t.id)??[])o.has(i)&&(r.set(i,0),s.push(i));if(s.length===0)for(let i of e)r.set(i.id,0),s.push(i.id);for(let i of s){let a=r.get(i)+o.get(i).length;for(let l of n.get(i)??[])if(o.has(l)){let c=r.get(l);(c===void 0||a<c)&&(r.set(l,a),s.push(l))}}return r}function _c(e,t,n){let o=Tc(e,t,n),r=[...e].sort((l,c)=>o.get(l.id)-o.get(c.id)),s=new Map(r.map((l,c)=>[l.id,c])),i=new Map(e.map(l=>[l.id,l])),a=new Map;for(let[l,c]of r.entries()){let f=0;for(let u of n.get(c.id)??[]){let d=i.get(u);d&&s.get(u)<l&&(f=Math.max(f,a.get(u)+d.length))}a.set(c.id,f)}return{offsets:a,ordered:r}}function Oc(e){let t=new Map(e.nodes.filter(Zt).map(s=>[s.id,s])),n=Te(e),o=new Set,r=[];for(let s of t.values())if(s.stable.rank!==We&&!o.has(s.id)){let{members:i,anchors:a}=kc(s.id,t,n,o),l=Rc(a);if(l){let{offsets:c,ordered:f}=_c(i,l.entry,n);r.push({start:l.start,refSpan:l.end-l.start,nodeIds:f.map(u=>u.id),nodeOffsets:f.map(u=>c.get(u.id)),pathLength:f.reduce((u,d)=>Math.max(u,c.get(d.id)+d.length),0)})}}return r.sort((s,i)=>s.start-i.start)}var Ac=28,Pr="#4d4d4d",Nc="#5b8cc4",Pc=[Nc,"#82abd9"],Fg=["#8c8c8c","#adadad"],$c="12px sans-serif",qg=[{field:"",label:"None"},{field:"sample",label:"A panel per sample"},{field:"walk",label:"A panel per haplotype"}],X=e=>I(e).name;function Gg(e,t,n=Pc){let o=0;return e.map(r=>X(r.name)===t?Pr:n[o++%n.length])}var Cc=["#4e79a7","#f28e2b","#59a14f","#e15759","#b07aa1","#76b7b2","#edc948","#9c755f","#ff9da7","#bab0ac"],$r="#c8c8c8";function Yg(e){let t=[...new Set(e)].filter(n=>n!=="").sort(qe());return new Map(t.map((n,o)=>[n,Cc[o]??$r]))}function Wg(e,t,n,o){return e.map(r=>{let s=X(r.name);return s===t?Pr:o.get(n(r.members?.[0]??s))??$r})}function Ic(e,t){let n=Ht(e,t);return o=>{let{sample:r,haplotype:s}=le(o);return n(`${r}#${s}`,r)}}function Hg(e,t){let n=(e.paths??[]).map(l=>l.name).filter(l=>X(l)!==e.referencePath);if(t.by==="column"){let l=Ic(t.field,t.table);return Ut(n,c=>l(X(c)),t,"sample",c=>le(X(c)).sample).map(({key:c,members:f,title:u})=>({key:c,paths:f,label:u}))}let o=t.by==="sample"?l=>le(l).sample:l=>l,r=new Map;for(let l of n){let c=o(X(l)),f=r.get(c);f?f.push(l):r.set(c,[l])}let s=t.domain??[],i=new Map(s.map((l,c)=>[l,c])),a=l=>i.get(l)??s.length;return[...r].map(([l,c],f)=>({key:l,paths:c,i:f})).sort((l,c)=>a(l.key)-a(c.key)||l.i-c.i).map(({key:l,paths:c})=>({key:l,paths:c}))}function Ug(e,t){if(e.graph.nodes.some(n=>n.id===t))return t;for(let[n,o]of e.members)if(o.includes(t))return n}function jg(e,t,n,o,r){let s=e.flatMap(u=>{let d=t(u);return d?[{id:u,...d}]:[]});if(s.length===0)return;let i=s.reduce((u,d)=>Math.min(u,d.start),1/0),a=s.reduce((u,d)=>Math.max(u,d.end),-1/0),l=o>n?(r-n)/(o-n):0,c=i+Math.min(1,Math.max(0,l))*(a-i),f=u=>c<u.start?u.start-c:c>=u.end?c-u.end+1:0;return s.reduce((u,d)=>f(d)<f(u)?d:u).id}function Vg(e,t){let n=new Set,o=new Set;for(let r of e.paths??[]){let s=X(r.name);if(s!==e.referencePath)for(let i of r.members??[s])n.add(i),r.nodeIds.includes(t)&&o.add(i)}return{here:o.size,of:n.size}}var Lc="bold 11px sans-serif",Bc=80,Xc=9;function Kg(e,t,n,{x:o,y:r,width:s}){let i=n.paths??[];if(!i.some(l=>l.members))return;let a=new Map;i.forEach((l,c)=>{X(l.name)!==n.referencePath&&a.set(c,l.members?.length??1)}),e.font=Lc,e.textAlign="left",e.textBaseline="middle",e.fillStyle="#0b1f3a";for(let l of t.layers[0]?.rects??[]){let c=a.get(l.id),f=Math.max(0,o(l.x0)),u=Math.min(s,o(l.x1)),d=r(l.y0),p=r(l.y1);c!==void 0&&u-f>=Bc&&p-d>=Xc&&e.fillText(`\xD7${c}`,f+4,(d+p)/2)}}var Dc="10px sans-serif",Fc=1e3;function zg(e,t,{x:n,y:o,width:r}){if(!t.columns)return;let s=new Map(t.graph.nodes.map(l=>[l.id,l.length]));e.font=Dc;let i=new Map;t.layout.nodes.forEach(l=>{let c=s.get(l.name)??0,f=n(l.x),u=n(l.x+l.pixelWidth),d=A(c);if(l.order>=0&&c>=Fc&&u-f<e.measureText(d).width){let p=(o(l.y)+o(l.y+l.contentHeight))/2,h=`${Math.round(u)}:${d}`,m=i.get(h);m?(m.count++,m.mid=Math.max(m.mid,p)):i.set(h,{text:d,right:u,mid:p,count:1})}}),e.textAlign="left",e.textBaseline="middle",e.lineJoin="round",e.lineWidth=3,e.strokeStyle="rgba(255,255,255,0.9)",e.fillStyle="rgba(0,0,0,0.75)";let a=[];for(let{text:l,right:c,mid:f,count:u}of i.values()){let d=u>1?`${l} each`:l,p={x0:c+3,x1:c+3+e.measureText(d).width,y0:f-6,y1:f+6};p.x1<=r&&!a.some(h=>h.x0<p.x1&&p.x0<h.x1&&h.y0<p.y1&&p.y0<h.y1)&&(a.push(p),e.strokeText(d,p.x0,f),e.fillText(d,p.x0,f))}}function Zg(e,t,n,{width:o,lit:r}){t.forEach((s,i)=>{let a=n?.[i];a&&(r&&Fe(e,s.picture,{...s.frame,width:o,highlightNode:a.box}),e.font=$c,e.textAlign="left",e.textBaseline="top",e.fillStyle="#c00000",e.fillText(` \xB7 ${a.here} of ${Wt(a.of,"haplotype")} here`,6+e.measureText(s.label).width,s.titleTop+4))})}function Jg(e,t){let n=new Set(t),o=(e.paths??[]).filter(c=>n.has(c.name)||X(c.name)===e.referencePath),r=new Set(o.map(c=>X(c.name))),s=new Set(o.flatMap(c=>c.nodeIds)),i=e.nodes.filter(c=>s.has(c.id)),a=new Set(i.map(c=>c.name)),l=e.pathVisits?.filter(c=>r.has(c),c=>a.has(c));return{...e,nodes:i,edges:e.edges.filter(c=>s.has(c.from)&&s.has(c.to)),paths:o,anchorPaths:e.anchorPaths?.filter(c=>r.has(c.name)),pathVisits:l,reads:void 0}}function Qg(e,t){let n=[],o={},r=0,s=1/0,i=-1/0;for(let{key:a,paths:l,label:c,result:f}of t){let u=f?.tubeMap,d=f?.extent;if(u&&d){let p=r+Ac,h=(d.maxY??0)-(d.minY??0);n.push({key:a,paths:l,label:c,result:{...f,tubeMap:u},top:p,height:h});let m=p-(d.minY??0);for(let[b,g]of Object.entries(f.nodePositions))o[b]=g.map(x=>({x:x.x,y:x.y+m}));r=p+h,s=Math.min(s,d.minX??s),i=Math.max(i,d.maxX??i)}}return n.length>1?{...e,nodePositions:o,extent:{...s<=i?{minX:s,maxX:i}:{},minY:0,maxY:r},tubeMapPanels:n}:e}var qc="#daa520",Gc=1,Yc=2,Wc=4;function nb(e,t,n,o=r=>r){let r=s=>{let i=t(s)*2;return n?.nodeIds.has(s)?Math.max(i,n.walks.length*Wc):i};return e.flatMap(s=>s.exonsByNode.map(({nodeId:i,d:a})=>({key:`${s.gene.name}-${s.gene.start}-${i}`,d:o(a),inner:r(i)+2*Gc})))}function ob(e,t){if(e.length===0)return;let n=(o,r,s)=>_("path",{d:o.d,fill:"none",stroke:r,"stroke-width":s,"stroke-linecap":"round","stroke-linejoin":"round","vector-effect":t.transform?"non-scaling-stroke":void 0});return _("g",{},_("mask",{id:t.id,maskUnits:"userSpaceOnUse",x:0,y:0,width:t.width,height:t.height},_("g",{transform:t.transform},...e.map(o=>n(o,"#fff",o.inner+2*Yc)),...e.map(o=>n(o,"#000",o.inner)))),_("rect",{width:t.width,height:t.height,fill:qc,mask:`url(#${t.id})`}))}function jt(e,t,n){let o=Math.round(t),r=Math.round(n);return`${e?`${e}:`:""}${oe(o+1)}-${oe(r)} (${A(r-o)})`}function Hc(e,t){let{field:n}=e.encoding,o=e.range?jt(e.range.contig,e.range.start,e.range.end):void 0,r=n==="progress"?o:n==="reference"&&t?jt(t.name,t.start,t.end):void 0,s=e.range?e.range.end-e.range.start:e.bp,i=s-e.bp-e.missingBp-e.unknownBp,a=[[e.missingBp,D.missing],[e.unknownBp,D.unknown],[i,ne]];return{delta:e.referenceBp===void 0||s===e.referenceBp?"":` ${s>e.referenceBp?"+":"\u2212"}${A(Math.abs(s-e.referenceBp))}`,gaps:a.filter(([l])=>l>0).map(([l,c])=>`, ${A(l)} ${c}`).join(""),reversed:e.reversedBp>0?`, ${A(e.reversedBp)} reversed`:"",shades:n!=="walk",scale:r,hover:r===o?void 0:o}}function Uc(e,t,n){let o=e.progress.get(t),r=e.range;if(o===void 0||!r)return;let s=Math.round(r.start+o*(r.end-r.start)-n/2);return`${r.contig}:${oe(s+1)}-${oe(s+n)}`}function jc(e,t){let n=[];for(let o of t){let r=e.get(o.refName),s=r?.[0],i=r?.at(-1);if(!r||!s||!i)continue;let a=Math.max(o.start,s.bp0),l=Math.min(o.end,i.bp1);l<=a||n.push({gene:o,...Be(r,a,l),exons:o.exons.filter(c=>c.end>a&&c.start<l).map(c=>Be(r,Math.max(c.start,a),Math.min(c.end,l)))})}return n}var Vt=22,Vc=4,Ye=8,Kc="11px sans-serif",zc=8;function Zc(e){let t=e.flatMap(r=>[{x:r.x0,step:1},{x:r.x1,step:-1}]).sort((r,s)=>r.x-s.x||r.step-s.step),n=0,o=0;for(let{step:r}of t)n+=r,o=Math.max(o,n);return Math.min(Vc,o)}function Jc(e,t,n,o,r=0){let{x:s,width:i,darkMode:a}=n,l=Math.max(1,Math.floor((o-r)/Vt)),c=[],f=a?"#e0e0e6":"#1c1c22";e.font=Kc,e.textAlign="center",e.textBaseline="alphabetic",e.fillStyle=f,e.strokeStyle=f,e.lineWidth=1;let u=t.map(d=>({g:d,s0:s(d.x0),s1:s(d.x1)})).filter(({s0:d,s1:p})=>p>=0&&d<=i).sort((d,p)=>d.s0-p.s0);for(let{g:d,s0:p,s1:h}of u){let m=d.gene.strand>0?" \u2192":d.gene.strand<0?"\u2190 ":"",b=d.gene.strand<0?`${m}${d.gene.name}`:`${d.gene.name}${m}`,g=(Math.max(p,0)+Math.min(h,i))/2,x=e.measureText(b).width/2,M=Math.min(p,g-x),y=Math.max(h,g+x),w=c.findIndex(S=>S+zc<=M);w===-1&&(w=Math.min(c.length,l-1)),c[w]=Math.max(c[w]??-1/0,y);let v=o-w*Vt-Ye/2;e.beginPath(),e.moveTo(p,v+.5),e.lineTo(h,v+.5),e.stroke();for(let S of d.exons){let k=s(S.x0);e.fillRect(k,v-Ye/2,Math.max(1,s(S.x1)-k),Ye)}e.fillText(b,g,v-Ye/2-2)}}var q=12,Xr=q+8,Dr=8,Cr=Dr+3,Qc=12;function el(e,{colorScheme:t,referenceRamp:n,walks:o}){let r=nt(e,n),s=[];return e.nodes.forEach((i,a)=>{if(O(i)){let l=o?o.map(c=>{let f=c.colors.get(i.id);return f===void 0?_e:U(f)}):[U(ot(i,a,t,r))];s.push({node:i.id,bp0:i.stable.start,bp1:i.stable.start+i.length,colors:l,faded:l.includes(_e)})}}),s.sort((i,a)=>i.bp0-a.bp0)}function Kt(e,t,n){let o=t*e.scale+e.translateX,r=n*e.scale+e.translateX;return o<r?[o,r]:[r,o]}var Ir=2;function Fr(e,t,n){let o=-t.translateX/t.scale,r=(n-t.translateX)/t.scale,s=Math.min(o,r),i=Math.max(o,r),a=0,l=0;for(let c of e)a+=Math.max(0,Math.min(c.bp1,s)-c.bp0),l+=Math.max(0,c.bp1-Math.max(c.bp0,i));return t.scale>=0?{left:Math.round(a),right:Math.round(l)}:{left:Math.round(l),right:Math.round(a)}}function tl(e,t,n,o){if(o<0||o>q+Ir)return;let r,s=Ir;for(let i of e){let[a,l]=Kt(t,i.bp0,i.bp1),c=Math.max(0,a-n,n-l);c<=s&&(s=c,r=i.node)}return r}function nl(e,t){let n=e?.[Math.floor(e.length/2)];return n?t(n):void 0}function qr(e,t,n,o){let r=e.map(c=>{let[f,u]=Kt(t,c.bp0,c.bp1),d=Math.round(f*o);return{colors:c.colors,x0:f,px0:d,px1:Math.max(Math.round(u*o),d+1)}}).filter(c=>c.px1>0&&c.px0<n*o).sort((c,f)=>c.x0-f.x0),s=[],i=-1/0,a=[-1/0,-1/0];for(let{colors:c,px0:f,px1:u}of r){let d=Math.max(f,i);if(u>d){let p=a[0]<d?0:1;a[p]=u,s.push({colors:c,x0:d/o,x1:u/o,tier:p}),i=u}}return(s.length>0?s.at(-1).x1-s[0].x0:0)>=s.length*Qc?s:s.map(({tier:c,...f})=>f)}function Lr(e,t,n,o){let r=n>0?t:t-Cr;e.clearRect(r,0,Cr,q);let s=t+n,i=s+n*Dr;e.beginPath(),e.moveTo(s,q/2),e.lineTo(i,0),e.lineTo(i,q),e.closePath(),e.fillStyle=o,e.fill()}function Br(e,t,n){return Math.round(e*q*n/t)/n}function ol(e,t,n,{width:o,lit:r,darkMode:s,dpr:i=1}){let a=s?"#ffffff":"#18181c";e.clearRect(0,0,o,Xr);for(let c of qr(t,n,o,i)){let{tier:f}=c,u=f!==void 0&&c.colors.length===1,d=u?2:c.colors.length;c.colors.forEach((p,h)=>{let m=u?f:h,b=Br(m,d,i);e.fillStyle=p,e.fillRect(c.x0,b,c.x1-c.x0,Br(m+1,d,i)-b)})}let l=Fr(t,n,o);if(l.left>0&&Lr(e,0,1,a),l.right>0&&Lr(e,o,-1,a),r){let[c,f]=Kt(n,r.start,r.end),u=Math.max(f-c,3),d=(c+f)/2-u/2;e.strokeStyle=a,e.lineWidth=1.5,e.strokeRect(d,.75,u,q-1.5),r.anchor&&(e.beginPath(),e.moveTo(d+u/2,q),e.lineTo(r.anchor.x,r.anchor.y),e.lineWidth=1,e.stroke())}}function rl(e,t){return Math.abs(t-e)<=.1*Math.max(e,t)}function sl(e,t){let n=e.length,o=t.length,r=Array.from({length:n+1},()=>new Array(o+1).fill(0)),s=Array.from({length:n+1},()=>new Array(o+1).fill(!1));for(let a=n-1;a>=0;a--)for(let l=o-1;l>=0;l--){let c=Math.abs(e[a]-t[l])+r[a+1][l+1],f=n-a>o-l?r[a+1][l]:1/0,u=o-l>n-a?r[a][l+1]:1/0;r[a][l]=Math.min(c,f,u),s[a][l]=r[a][l]===c}let i=new Array(n).fill(void 0);for(let a=0,l=0;a<n&&l<o;)s[a][l]?i[a++]=l++:n-a>o-l?a++:l++;return i}function Gr(e,t){return e.map((n,o)=>({item:n,i:o})).sort((n,o)=>t(n.item)-t(o.item))}var Yr=e=>e.spanningReads!==0;function il(e,t){return{...t,agrees:e.complete&&Yr(t)?rl(e.bp,t.bp):void 0}}function al(e,t){let n=new Map,o=new Set,r=Gr(e,i=>i.bp),s=(i,a)=>{let l=[[i.filter(c=>c.item.complete),a.filter(Yr)],[i,a]];for(let[c,f]of l){let u=c.filter(p=>!n.has(p.i)),d=Gr(f.filter(p=>!o.has(p)),p=>p.bp);sl(u.map(p=>p.item.bp),d.map(p=>p.item.bp)).forEach((p,h)=>{if(p!==void 0){let m=u[h],b=d[p].item;o.add(b),n.set(m.i,il(m.item,b))}})}};for(let i of new Set(t.flatMap(a=>a.haplotype??[])))s(r.filter(a=>a.item.haplotype===i),t.filter(a=>a.haplotype===i));return s(r,t.filter(i=>i.haplotype===void 0)),n}function V0(e,t){if(!t)return e;let n=new Map,o=new Map;for(let r of e){let s=o.get(r.sample);s?s.push(r):o.set(r.sample,[r])}for(let[r,s]of o){let i=t[r];if(i)for(let[a,l]of al(s,i))n.set(s[a],l)}return e.map(r=>({...r,call:n.get(r)}))}var Wr=mo.box(typeof devicePixelRatio>"u"?1:devicePixelRatio);function Hr(){matchMedia(`(resolution: ${devicePixelRatio}dppx)`).addEventListener("change",()=>{go(()=>{Wr.set(devicePixelRatio)}),Hr()},{once:!0})}typeof matchMedia=="function"&&Hr();function ex(e=0,t=0){return Wr.get(),re(e,t)}export{Su as a,ku as b,Ru as c,Tu as d,js as e,Vs as f,It as g,yr as h,fh as i,Qa as j,uh as k,Oc as l,vh as m,Eh as n,Zd as o,$e as p,_ as q,Ks as r,zs as s,he as t,wt as u,Ie as v,So as w,ko as x,me as y,_o as z,bt as A,oi as B,ri as C,Ao as D,ci as E,Po as F,$o as G,Mt as H,li as I,di as J,Io as K,ge as L,Ne as M,st as N,Pe as O,jr as P,Vr as Q,Kr as R,zr as S,Gl as T,z as U,Wn as V,pe as W,at as X,ms as Y,Yl as Z,Wl as _,bs as $,xs as aa,ys as ba,ws as ca,Ms as da,lf as ea,df as fa,ff as ga,uf as ha,pf as ia,hf as ja,mf as ka,gf as la,bf as ma,xf as na,yf as oa,wf as pa,Mf as qa,vf as ra,Ef as sa,Sf as ta,kf as ua,Rf as va,Es as wa,Tf as xa,_f as ya,Of as za,Af as Aa,Nf as Ba,Pf as Ca,$f as Da,Cf as Ea,gi as Fa,xi as Ga,yi as Ha,wi as Ia,yh as Ja,Et as Ka,Mi as La,Xo as Ma,_i as Na,Oi as Oa,Ni as Pa,Pi as Qa,Yo as Ra,Kh as Sa,ic as Ta,zh as Ua,tm as Va,nm as Wa,uc as Xa,bc as Ya,Fe as Za,Yt as _a,qt as $a,Mc as ab,Ec as bb,Ge as cb,ig as db,ag as eb,cg as fb,lg as gb,dg as hb,fg as ib,Ac as jb,Pr as kb,Nc as lb,Fg as mb,$c as nb,qg as ob,Gg as pb,$r as qb,Yg as rb,Wg as sb,Ic as tb,Hg as ub,Ug as vb,jg as wb,Vg as xb,Kg as yb,zg as zb,Zg as Ab,Jg as Bb,Qg as Cb,dt as Db,Df as Eb,Gf as Fb,qc as Gb,nb as Hb,ob as Ib,Jf as Jb,lo as Kb,Qf as Lb,fo as Mb,ut as Nb,uo as Ob,po as Pb,Ws as Qb,jt as Rb,Hc as Sb,Uc as Tb,jc as Ub,Vt as Vb,Zc as Wb,Jc as Xb,Xr as Yb,el as Zb,Fr as _b,tl as $b,nl as ac,ol as bc,V0 as cc,ex as dc};
3
- //# sourceMappingURL=chunk-Y5DNBFDY.js.map