@genome-spy/core 0.78.0 → 0.79.1

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 (292) hide show
  1. package/dist/bundle/{browser-KWU9rWZT.js → browser-CETrb2cm.js} +53 -33
  2. package/dist/bundle/esm-BdLYkz-m.js +248 -0
  3. package/dist/bundle/esm-BwiDsqSb.js +1367 -0
  4. package/dist/bundle/esm-CDFd1cjk.js +441 -0
  5. package/dist/bundle/{esm-DVOHLB1e.js → esm-CTUHLDbv.js} +30 -30
  6. package/dist/bundle/{esm-NIYEaYkc.js → esm-Cx-EbkOj.js} +13 -13
  7. package/dist/bundle/esm-DlYGqi79.js +128 -0
  8. package/dist/bundle/{esm-BygJiwh0.js → esm-k9p3oHkt.js} +133 -158
  9. package/dist/bundle/{esm-CT3ygiMq.js → esm-zAZJQO6D.js} +226 -212
  10. package/dist/bundle/index.es.js +14879 -11656
  11. package/dist/bundle/index.js +119 -108
  12. package/dist/bundle/{parquetRead-DG_-F5j5.js → parquetRead-Cad1SOVV.js} +473 -399
  13. package/dist/schema.json +18940 -6914
  14. package/dist/src/config/axisConfig.d.ts +2 -2
  15. package/dist/src/config/axisConfig.d.ts.map +1 -1
  16. package/dist/src/config/axisConfig.js +28 -44
  17. package/dist/src/config/configLayers.d.ts +45 -0
  18. package/dist/src/config/configLayers.d.ts.map +1 -0
  19. package/dist/src/config/configLayers.js +110 -0
  20. package/dist/src/config/defaultConfig.d.ts.map +1 -1
  21. package/dist/src/config/defaultConfig.js +8 -1
  22. package/dist/src/config/defaults/legendDefaults.d.ts +14 -0
  23. package/dist/src/config/defaults/legendDefaults.d.ts.map +1 -0
  24. package/dist/src/config/defaults/legendDefaults.js +46 -0
  25. package/dist/src/config/defaults/titleDefaults.d.ts.map +1 -1
  26. package/dist/src/config/defaults/titleDefaults.js +26 -18
  27. package/dist/src/config/legendConfig.d.ts +11 -0
  28. package/dist/src/config/legendConfig.d.ts.map +1 -0
  29. package/dist/src/config/legendConfig.js +63 -0
  30. package/dist/src/config/styleUtils.d.ts +8 -2
  31. package/dist/src/config/styleUtils.d.ts.map +1 -1
  32. package/dist/src/config/styleUtils.js +25 -1
  33. package/dist/src/config/themes.d.ts.map +1 -1
  34. package/dist/src/config/themes.js +21 -2
  35. package/dist/src/config/titleConfig.d.ts.map +1 -1
  36. package/dist/src/config/titleConfig.js +2 -18
  37. package/dist/src/data/collector.d.ts.map +1 -1
  38. package/dist/src/data/collector.js +40 -18
  39. package/dist/src/data/flowInit.d.ts +6 -0
  40. package/dist/src/data/flowInit.d.ts.map +1 -1
  41. package/dist/src/data/flowInit.js +1 -1
  42. package/dist/src/data/flowNode.d.ts +32 -0
  43. package/dist/src/data/flowNode.d.ts.map +1 -1
  44. package/dist/src/data/flowNode.js +59 -0
  45. package/dist/src/data/sources/lazy/bamSource.d.ts +0 -1
  46. package/dist/src/data/sources/lazy/bamSource.d.ts.map +1 -1
  47. package/dist/src/data/sources/lazy/bamSource.js +39 -30
  48. package/dist/src/data/sources/lazy/bigBedSource.d.ts +0 -10
  49. package/dist/src/data/sources/lazy/bigBedSource.d.ts.map +1 -1
  50. package/dist/src/data/sources/lazy/bigBedSource.js +127 -62
  51. package/dist/src/data/sources/lazy/bigWigSource.d.ts +2 -2
  52. package/dist/src/data/sources/lazy/bigWigSource.d.ts.map +1 -1
  53. package/dist/src/data/sources/lazy/bigWigSource.js +234 -81
  54. package/dist/src/data/sources/lazy/gff3Source.d.ts +7 -3
  55. package/dist/src/data/sources/lazy/gff3Source.d.ts.map +1 -1
  56. package/dist/src/data/sources/lazy/gff3Source.js +7 -8
  57. package/dist/src/data/sources/lazy/indexedFastaSource.d.ts +1 -1
  58. package/dist/src/data/sources/lazy/indexedFastaSource.d.ts.map +1 -1
  59. package/dist/src/data/sources/lazy/indexedFastaSource.js +28 -19
  60. package/dist/src/data/sources/lazy/legendEntriesSource.d.ts +24 -0
  61. package/dist/src/data/sources/lazy/legendEntriesSource.d.ts.map +1 -0
  62. package/dist/src/data/sources/lazy/legendEntriesSource.js +218 -0
  63. package/dist/src/data/sources/lazy/legendGradientSource.d.ts +30 -0
  64. package/dist/src/data/sources/lazy/legendGradientSource.d.ts.map +1 -0
  65. package/dist/src/data/sources/lazy/legendGradientSource.js +388 -0
  66. package/dist/src/data/sources/lazy/mockLazySource.d.ts +4 -1
  67. package/dist/src/data/sources/lazy/mockLazySource.d.ts.map +1 -1
  68. package/dist/src/data/sources/lazy/mockLazySource.js +49 -4
  69. package/dist/src/data/sources/lazy/registerCoreLazySources.js +2 -0
  70. package/dist/src/data/sources/lazy/singleAxisWindowedSource.d.ts.map +1 -1
  71. package/dist/src/data/sources/lazy/singleAxisWindowedSource.js +3 -4
  72. package/dist/src/data/sources/lazy/tabixSource.d.ts +9 -4
  73. package/dist/src/data/sources/lazy/tabixSource.d.ts.map +1 -1
  74. package/dist/src/data/sources/lazy/tabixSource.js +201 -70
  75. package/dist/src/data/sources/lazy/tabixTsvSource.d.ts +2 -3
  76. package/dist/src/data/sources/lazy/tabixTsvSource.d.ts.map +1 -1
  77. package/dist/src/data/sources/lazy/tabixTsvSource.js +14 -12
  78. package/dist/src/data/sources/lazy/vcfSource.d.ts +7 -3
  79. package/dist/src/data/sources/lazy/vcfSource.d.ts.map +1 -1
  80. package/dist/src/data/sources/lazy/vcfSource.js +7 -8
  81. package/dist/src/data/sources/urlDescriptor.d.ts +165 -0
  82. package/dist/src/data/sources/urlDescriptor.d.ts.map +1 -0
  83. package/dist/src/data/sources/urlDescriptor.js +473 -0
  84. package/dist/src/data/sources/urlDescriptorController.d.ts +25 -0
  85. package/dist/src/data/sources/urlDescriptorController.d.ts.map +1 -0
  86. package/dist/src/data/sources/urlDescriptorController.js +72 -0
  87. package/dist/src/data/sources/urlDescriptorState.d.ts +47 -0
  88. package/dist/src/data/sources/urlDescriptorState.d.ts.map +1 -0
  89. package/dist/src/data/sources/urlDescriptorState.js +129 -0
  90. package/dist/src/data/sources/urlSource.d.ts.map +1 -1
  91. package/dist/src/data/sources/urlSource.js +101 -61
  92. package/dist/src/data/transforms/packLegendLabels.d.ts +21 -0
  93. package/dist/src/data/transforms/packLegendLabels.d.ts.map +1 -0
  94. package/dist/src/data/transforms/packLegendLabels.js +189 -0
  95. package/dist/src/data/transforms/transformFactory.d.ts.map +1 -1
  96. package/dist/src/data/transforms/transformFactory.js +4 -0
  97. package/dist/src/data/transforms/truncateText.d.ts +27 -0
  98. package/dist/src/data/transforms/truncateText.d.ts.map +1 -0
  99. package/dist/src/data/transforms/truncateText.js +94 -0
  100. package/dist/src/debug/dataflowDebugSnapshot.d.ts +58 -0
  101. package/dist/src/debug/dataflowDebugSnapshot.d.ts.map +1 -0
  102. package/dist/src/debug/dataflowDebugSnapshot.js +159 -0
  103. package/dist/src/debug/markDebugSnapshot.d.ts +54 -0
  104. package/dist/src/debug/markDebugSnapshot.d.ts.map +1 -0
  105. package/dist/src/debug/markDebugSnapshot.js +100 -0
  106. package/dist/src/debug/paramDebugSnapshot.d.ts +53 -0
  107. package/dist/src/debug/paramDebugSnapshot.d.ts.map +1 -0
  108. package/dist/src/debug/paramDebugSnapshot.js +86 -0
  109. package/dist/src/debug/resolutionDebugSnapshot.d.ts +155 -0
  110. package/dist/src/debug/resolutionDebugSnapshot.d.ts.map +1 -0
  111. package/dist/src/debug/resolutionDebugSnapshot.js +291 -0
  112. package/dist/src/debug/valuePreview.d.ts +9 -0
  113. package/dist/src/debug/valuePreview.d.ts.map +1 -0
  114. package/dist/src/debug/valuePreview.js +57 -0
  115. package/dist/src/debug/viewDebugSnapshot.d.ts +131 -0
  116. package/dist/src/debug/viewDebugSnapshot.d.ts.map +1 -0
  117. package/dist/src/debug/viewDebugSnapshot.js +390 -0
  118. package/dist/src/embedFactory.d.ts.map +1 -1
  119. package/dist/src/embedFactory.js +6 -1
  120. package/dist/src/encoder/encoder.d.ts +2 -2
  121. package/dist/src/encoder/encoder.d.ts.map +1 -1
  122. package/dist/src/encoder/encoder.js +5 -4
  123. package/dist/src/fonts/bmFontManager.d.ts +1 -1
  124. package/dist/src/fonts/bmFontManager.d.ts.map +1 -1
  125. package/dist/src/fonts/bmFontManager.js +45 -10
  126. package/dist/src/fonts/textMetrics.d.ts +69 -0
  127. package/dist/src/fonts/textMetrics.d.ts.map +1 -0
  128. package/dist/src/fonts/textMetrics.js +73 -0
  129. package/dist/src/genomeSpy/headlessBootstrap.d.ts.map +1 -1
  130. package/dist/src/genomeSpy/headlessBootstrap.js +6 -0
  131. package/dist/src/genomeSpy/renderCoordinator.d.ts.map +1 -1
  132. package/dist/src/genomeSpy/renderCoordinator.js +25 -3
  133. package/dist/src/genomeSpy/viewDataInit.d.ts +14 -0
  134. package/dist/src/genomeSpy/viewDataInit.d.ts.map +1 -1
  135. package/dist/src/genomeSpy/viewDataInit.js +45 -8
  136. package/dist/src/genomeSpyBase.d.ts +6 -0
  137. package/dist/src/genomeSpyBase.d.ts.map +1 -1
  138. package/dist/src/genomeSpyBase.js +20 -3
  139. package/dist/src/gl/glslScaleGenerator.d.ts +17 -0
  140. package/dist/src/gl/glslScaleGenerator.d.ts.map +1 -1
  141. package/dist/src/gl/glslScaleGenerator.js +39 -2
  142. package/dist/src/gl/includes/common.glsl.js +1 -1
  143. package/dist/src/gl/vertexRangeIndex.d.ts.map +1 -1
  144. package/dist/src/gl/vertexRangeIndex.js +4 -2
  145. package/dist/src/gl/webGLHelper.d.ts +1 -1
  146. package/dist/src/gl/webGLHelper.d.ts.map +1 -1
  147. package/dist/src/gl/webGLHelper.js +13 -8
  148. package/dist/src/marks/__snapshots__/shaderSnapshot.test.js.snap +140 -3
  149. package/dist/src/marks/mark.d.ts +47 -4
  150. package/dist/src/marks/mark.d.ts.map +1 -1
  151. package/dist/src/marks/mark.js +158 -54
  152. package/dist/src/marks/point.d.ts.map +1 -1
  153. package/dist/src/marks/point.js +4 -0
  154. package/dist/src/marks/point.vertex.glsl.js +1 -1
  155. package/dist/src/marks/text.d.ts +1 -1
  156. package/dist/src/marks/text.d.ts.map +1 -1
  157. package/dist/src/marks/text.js +2 -7
  158. package/dist/src/marks/text.vertex.glsl.js +1 -1
  159. package/dist/src/paramRuntime/paramUtils.d.ts +43 -9
  160. package/dist/src/paramRuntime/paramUtils.d.ts.map +1 -1
  161. package/dist/src/paramRuntime/paramUtils.js +61 -1
  162. package/dist/src/paramRuntime/viewParamRuntime.d.ts +32 -0
  163. package/dist/src/paramRuntime/viewParamRuntime.d.ts.map +1 -1
  164. package/dist/src/paramRuntime/viewParamRuntime.js +63 -0
  165. package/dist/src/scales/axisResolution.d.ts +35 -0
  166. package/dist/src/scales/axisResolution.d.ts.map +1 -1
  167. package/dist/src/scales/axisResolution.js +115 -7
  168. package/dist/src/scales/legendResolution.d.ts +83 -0
  169. package/dist/src/scales/legendResolution.d.ts.map +1 -0
  170. package/dist/src/scales/legendResolution.js +461 -0
  171. package/dist/src/scales/scaleResolution.d.ts +36 -0
  172. package/dist/src/scales/scaleResolution.d.ts.map +1 -1
  173. package/dist/src/scales/scaleResolution.js +59 -0
  174. package/dist/src/scales/viewLevelGuideConfig.d.ts +53 -0
  175. package/dist/src/scales/viewLevelGuideConfig.d.ts.map +1 -0
  176. package/dist/src/scales/viewLevelGuideConfig.js +224 -0
  177. package/dist/src/scales/viewLevelScaleConfig.d.ts.map +1 -1
  178. package/dist/src/scales/viewLevelScaleConfig.js +13 -2
  179. package/dist/src/spec/axis.d.ts +109 -3
  180. package/dist/src/spec/channel.d.ts +23 -4
  181. package/dist/src/spec/config.d.ts +59 -4
  182. package/dist/src/spec/data.d.ts +177 -17
  183. package/dist/src/spec/legend.d.ts +246 -0
  184. package/dist/src/spec/mark.d.ts +16 -4
  185. package/dist/src/spec/title.d.ts +58 -1
  186. package/dist/src/spec/transform.d.ts +149 -0
  187. package/dist/src/spec/view.d.ts +39 -6
  188. package/dist/src/types/embedApi.d.ts +262 -6
  189. package/dist/src/types/rendering.d.ts +19 -3
  190. package/dist/src/types/viewContext.d.ts +18 -2
  191. package/dist/src/utils/arrayUtils.d.ts +11 -0
  192. package/dist/src/utils/arrayUtils.d.ts.map +1 -1
  193. package/dist/src/utils/arrayUtils.js +23 -0
  194. package/dist/src/utils/suspension.d.ts +17 -0
  195. package/dist/src/utils/suspension.d.ts.map +1 -0
  196. package/dist/src/utils/suspension.js +41 -0
  197. package/dist/src/view/axisGridView.d.ts.map +1 -1
  198. package/dist/src/view/axisGridView.js +1 -4
  199. package/dist/src/view/axisView.d.ts +18 -2
  200. package/dist/src/view/axisView.d.ts.map +1 -1
  201. package/dist/src/view/axisView.js +180 -75
  202. package/dist/src/view/concatView.d.ts +10 -2
  203. package/dist/src/view/concatView.d.ts.map +1 -1
  204. package/dist/src/view/concatView.js +46 -9
  205. package/dist/src/view/containerMutationHelper.d.ts +20 -1
  206. package/dist/src/view/containerMutationHelper.d.ts.map +1 -1
  207. package/dist/src/view/containerMutationHelper.js +196 -33
  208. package/dist/src/view/facetView.d.ts +1 -1
  209. package/dist/src/view/gridView/gridChild.d.ts +54 -4
  210. package/dist/src/view/gridView/gridChild.d.ts.map +1 -1
  211. package/dist/src/view/gridView/gridChild.js +301 -120
  212. package/dist/src/view/gridView/gridChildLegends.d.ts +57 -0
  213. package/dist/src/view/gridView/gridChildLegends.d.ts.map +1 -0
  214. package/dist/src/view/gridView/gridChildLegends.js +503 -0
  215. package/dist/src/view/gridView/gridView.d.ts +25 -0
  216. package/dist/src/view/gridView/gridView.d.ts.map +1 -1
  217. package/dist/src/view/gridView/gridView.js +490 -78
  218. package/dist/src/view/gridView/legendLayout.d.ts +30 -0
  219. package/dist/src/view/gridView/legendLayout.d.ts.map +1 -0
  220. package/dist/src/view/gridView/legendLayout.js +115 -0
  221. package/dist/src/view/gridView/scrollbar.d.ts.map +1 -1
  222. package/dist/src/view/gridView/scrollbar.js +1 -4
  223. package/dist/src/view/gridView/selectionRect.d.ts.map +1 -1
  224. package/dist/src/view/gridView/selectionRect.js +1 -4
  225. package/dist/src/view/gridView/separatorView.d.ts.map +1 -1
  226. package/dist/src/view/gridView/separatorView.js +1 -4
  227. package/dist/src/view/layerView.d.ts +9 -2
  228. package/dist/src/view/layerView.d.ts.map +1 -1
  229. package/dist/src/view/layerView.js +18 -1
  230. package/dist/src/view/layout/flexLayout.d.ts +20 -4
  231. package/dist/src/view/layout/flexLayout.d.ts.map +1 -1
  232. package/dist/src/view/layout/flexLayout.js +331 -31
  233. package/dist/src/view/layout/rectangle.d.ts +14 -0
  234. package/dist/src/view/layout/rectangle.d.ts.map +1 -1
  235. package/dist/src/view/layout/rectangle.js +40 -0
  236. package/dist/src/view/legend/legendEntries.d.ts +20 -0
  237. package/dist/src/view/legend/legendEntries.d.ts.map +1 -0
  238. package/dist/src/view/legend/legendEntries.js +21 -0
  239. package/dist/src/view/legendView.d.ts +137 -0
  240. package/dist/src/view/legendView.d.ts.map +1 -0
  241. package/dist/src/view/legendView.js +1654 -0
  242. package/dist/src/view/renderingContext/bufferedViewRenderingContext.d.ts.map +1 -1
  243. package/dist/src/view/renderingContext/bufferedViewRenderingContext.js +26 -4
  244. package/dist/src/view/renderingContext/clipOptions.d.ts +44 -0
  245. package/dist/src/view/renderingContext/clipOptions.d.ts.map +1 -0
  246. package/dist/src/view/renderingContext/clipOptions.js +140 -0
  247. package/dist/src/view/renderingContext/simpleViewRenderingContext.d.ts.map +1 -1
  248. package/dist/src/view/renderingContext/simpleViewRenderingContext.js +12 -1
  249. package/dist/src/view/resolutionPlanner.d.ts +2 -1
  250. package/dist/src/view/resolutionPlanner.d.ts.map +1 -1
  251. package/dist/src/view/resolutionPlanner.js +89 -25
  252. package/dist/src/view/testUtils.d.ts +4 -2
  253. package/dist/src/view/testUtils.d.ts.map +1 -1
  254. package/dist/src/view/testUtils.js +60 -7
  255. package/dist/src/view/titleView.d.ts +37 -0
  256. package/dist/src/view/titleView.d.ts.map +1 -0
  257. package/dist/src/view/titleView.js +584 -0
  258. package/dist/src/view/unitView.d.ts +3 -3
  259. package/dist/src/view/unitView.d.ts.map +1 -1
  260. package/dist/src/view/unitView.js +3 -2
  261. package/dist/src/view/view.d.ts +25 -24
  262. package/dist/src/view/view.d.ts.map +1 -1
  263. package/dist/src/view/view.js +126 -16
  264. package/dist/src/view/viewChrome.d.ts +33 -0
  265. package/dist/src/view/viewChrome.d.ts.map +1 -0
  266. package/dist/src/view/viewChrome.js +64 -0
  267. package/dist/src/view/viewFactory.d.ts +2 -5
  268. package/dist/src/view/viewFactory.d.ts.map +1 -1
  269. package/dist/src/view/viewFactory.js +1 -2
  270. package/dist/src/view/viewIdentityRegistry.d.ts +37 -0
  271. package/dist/src/view/viewIdentityRegistry.d.ts.map +1 -0
  272. package/dist/src/view/viewIdentityRegistry.js +71 -0
  273. package/dist/src/view/viewMutationAcidTestUtils.d.ts +112 -0
  274. package/dist/src/view/viewMutationAcidTestUtils.d.ts.map +1 -0
  275. package/dist/src/view/viewMutationAcidTestUtils.js +234 -0
  276. package/dist/src/view/viewMutationApi.d.ts +42 -0
  277. package/dist/src/view/viewMutationApi.d.ts.map +1 -0
  278. package/dist/src/view/viewMutationApi.js +811 -0
  279. package/dist/src/view/viewSelectors.d.ts +11 -9
  280. package/dist/src/view/viewSelectors.d.ts.map +1 -1
  281. package/dist/src/view/viewSelectors.js +28 -17
  282. package/package.json +4 -4
  283. package/dist/bundle/esm-CuMSzCHy.js +0 -298
  284. package/dist/bundle/esm-DAnOffpD.js +0 -1426
  285. package/dist/bundle/esm-DMXpJXM4.js +0 -369
  286. package/dist/bundle/esm-DNtC3H80.js +0 -121
  287. package/dist/src/view/title.d.ts +0 -13
  288. package/dist/src/view/title.d.ts.map +0 -1
  289. package/dist/src/view/title.js +0 -154
  290. /package/dist/bundle/{AbortablePromiseCache-3gHJdF3E.js → AbortablePromiseCache-BTmAcN-t.js} +0 -0
  291. /package/dist/bundle/{esm-CuVa5T98.js → esm-VvpZ9hsq.js} +0 -0
  292. /package/dist/bundle/{chunk-DmhlhrBa.js → rolldown-runtime-Dy4uBu1J.js} +0 -0
@@ -0,0 +1,1367 @@
1
+ import { n as e, r as t } from "./esm-Cx-EbkOj.js";
2
+ import { t as n } from "./esm-VvpZ9hsq.js";
3
+ import { r, t as i } from "./browser-CETrb2cm.js";
4
+ //#region ../../node_modules/@gmod/bam/esm/chunk.js
5
+ var a = class {
6
+ minv;
7
+ maxv;
8
+ bin;
9
+ endPosition;
10
+ constructor(e, t, n, r = t.blockPosition + 65536) {
11
+ this.minv = e, this.maxv = t, this.bin = n, this.endPosition = r;
12
+ }
13
+ toString() {
14
+ return `${this.minv.toString()}..${this.maxv.toString()} (bin ${this.bin}, fetchedSize ${this.fetchedSize()})`;
15
+ }
16
+ compareTo(e) {
17
+ return this.minv.compareTo(e.minv) || this.maxv.compareTo(e.maxv) || this.bin - e.bin;
18
+ }
19
+ fetchedSize() {
20
+ return this.endPosition - this.minv.blockPosition;
21
+ }
22
+ }, o = 65536, s = o * o;
23
+ function c(e, t = 0) {
24
+ let n = e[t] | e[t + 1] << 8 | e[t + 2] << 16 | e[t + 3] << 24;
25
+ return ((e[t + 4] | e[t + 5] << 8 | e[t + 6] << 16 | e[t + 7] << 24) >>> 0) * s + (n >>> 0);
26
+ }
27
+ //#endregion
28
+ //#region ../../node_modules/@gmod/bam/esm/util.js
29
+ function l(e, t) {
30
+ let n = e.length;
31
+ if (n === 0) return e;
32
+ let r;
33
+ if (t) {
34
+ let i = t.blockPosition, a = t.dataPosition;
35
+ r = [];
36
+ for (let t = 0; t < n; t++) {
37
+ let n = e[t], o = n.maxv;
38
+ (o.blockPosition - i || o.dataPosition - a) > 0 && r.push(n);
39
+ }
40
+ if (r.length === 0) return r;
41
+ } else r = e;
42
+ r.sort((e, t) => {
43
+ let n = e.minv.blockPosition - t.minv.blockPosition;
44
+ return n === 0 ? e.minv.dataPosition - t.minv.dataPosition : n;
45
+ });
46
+ let i = [r[0]], o = r[0].minv.blockPosition, s = r[0].maxv.blockPosition;
47
+ for (let e = 1; e < r.length; e++) {
48
+ let t = r[e], n = t.minv.blockPosition, c = t.maxv.blockPosition;
49
+ if (n - s < 65e3 && c - o < 5e6) {
50
+ let e = i[i.length - 1];
51
+ (c - s || t.maxv.dataPosition - e.maxv.dataPosition) > 0 && (i[i.length - 1] = new a(e.minv, t.maxv, e.bin, t.endPosition), s = c);
52
+ } else i.push(t), o = n, s = c;
53
+ }
54
+ return i;
55
+ }
56
+ function u(e, t) {
57
+ return { lineCount: c(e, t) };
58
+ }
59
+ function d(e, t = []) {
60
+ let n = [...t];
61
+ for (let t of e) n.push(t.minv.blockPosition, t.maxv.blockPosition);
62
+ n.sort((e, t) => e - t);
63
+ for (let t of e) {
64
+ let e = t.maxv.blockPosition, r = 0, i = n.length;
65
+ for (; r < i;) {
66
+ let t = r + i >>> 1;
67
+ n[t] > e ? i = t : r = t + 1;
68
+ }
69
+ r < n.length && (t.endPosition = Math.min(t.endPosition, n[r]));
70
+ }
71
+ }
72
+ function f(e, t, n) {
73
+ if (t + 4 > e.length) return;
74
+ let r = new DataView(e.buffer), i = r.getInt32(t, !0), a = {}, o = [], s = new TextDecoder("utf8"), c = t + 4;
75
+ for (let t = 0; t < i; t++) {
76
+ if (c + 8 > e.length) return;
77
+ let i = r.getInt32(c, !0);
78
+ if (c + 8 + i > e.length) return;
79
+ let l = n(s.decode(e.subarray(c + 4, c + 4 + i - 1))), u = r.getInt32(c + i + 4, !0);
80
+ a[l] = t, o.push({
81
+ refName: l,
82
+ length: u
83
+ }), c += 8 + i;
84
+ }
85
+ return {
86
+ chrToIndex: a,
87
+ indexToChr: o
88
+ };
89
+ }
90
+ function p(e, t) {
91
+ return e ? e.compareTo(t) > 0 ? t : e : t;
92
+ }
93
+ function m(e, t = (e) => e) {
94
+ let n = new TextDecoder(), r = 0, i = 0, a = [], o = {};
95
+ for (let s = 0; s < e.length; s++) if (!e[s]) {
96
+ if (i < s) {
97
+ let c = t(n.decode(e.subarray(i, s)));
98
+ a[r] = c, o[c] = r;
99
+ }
100
+ i = s + 1, r++;
101
+ }
102
+ return {
103
+ refNameToId: o,
104
+ refIdToName: a
105
+ };
106
+ }
107
+ function h(e) {
108
+ let t = 0;
109
+ for (let n of e) t += n.length;
110
+ let n = new Uint8Array(t), r = 0;
111
+ for (let t of e) n.set(t, r), r += t.length;
112
+ return n;
113
+ }
114
+ function g(e, t, n) {
115
+ return (e & t) !== t || (e & n) !== 0;
116
+ }
117
+ function _(e, t) {
118
+ return t === "*" ? e === void 0 : `${e}` != `${t}`;
119
+ }
120
+ function v(e) {
121
+ if (!e) return "";
122
+ let { flagInclude: t = 0, flagExclude: n = 0, tagFilter: r } = e;
123
+ return `:f${t}x${n}${r ? `:${r.tag}=${r.value ?? "*"}` : ""}`;
124
+ }
125
+ function y(e, t) {
126
+ let { flagInclude: n = 0, flagExclude: r = 0, tagFilter: i } = t, a = [];
127
+ for (let t = 0, o = e.length; t < o; t++) {
128
+ let o = e[t];
129
+ !g(o.flags, n, r) && !(i && _(o.tags[i.tag], i.value)) && a.push(o);
130
+ }
131
+ return a;
132
+ }
133
+ function b(e, t, n, r, i = []) {
134
+ for (let a = 0, o = e.length; a < o; a++) {
135
+ let o = e[a];
136
+ if (o.ref_id === t) {
137
+ if (o.start >= r) break;
138
+ o.end >= n && i.push(o);
139
+ } else if (o.ref_id > t) break;
140
+ }
141
+ return i;
142
+ }
143
+ //#endregion
144
+ //#region ../../node_modules/@gmod/bam/esm/indexFile.js
145
+ function x(e, t = 5) {
146
+ let r = new n({ maxSize: t });
147
+ return (t) => {
148
+ if (r.has(t)) return r.get(t);
149
+ let n = e(t);
150
+ return n && r.set(t, n), n;
151
+ };
152
+ }
153
+ var S = class {
154
+ filehandle;
155
+ renameRefSeq;
156
+ setupP;
157
+ constructor({ filehandle: e, renameRefSeq: t = (e) => e }) {
158
+ this.filehandle = e, this.renameRefSeq = t;
159
+ }
160
+ async blocksForRange(e, t, n, r = {}) {
161
+ t < 0 && (t = 0);
162
+ let i = (await this.parse(r)).indices(e);
163
+ if (!i) return [];
164
+ let a = this.reg2bins(t, n);
165
+ if (a.length === 0) return [];
166
+ let o = [], { binIndex: s } = i;
167
+ for (let [e, t] of a) for (let n = e; n <= t; n++) {
168
+ let e = s[n];
169
+ if (e) for (let t = 0, n = e.length; t < n; t++) o.push(e[t]);
170
+ }
171
+ return l(o, this.getLowestChunk(i, t));
172
+ }
173
+ parse(e = {}) {
174
+ return this.setupP ||= this._parse(e).catch((e) => {
175
+ throw this.setupP = void 0, e;
176
+ }), this.setupP;
177
+ }
178
+ async lineCount(e, t) {
179
+ return (await this.parse(t)).indices(e)?.stats?.lineCount ?? 0;
180
+ }
181
+ async hasRefSeq(e, t) {
182
+ return !!(await this.parse(t)).indices(e);
183
+ }
184
+ async estimatedBytesForRegions(e, t) {
185
+ let n = l((await Promise.all(e.map((e) => this.blocksForRange(e.refId, e.start, e.end, t)))).flat()), r = 0;
186
+ for (let e of n) r += e.fetchedSize();
187
+ return r;
188
+ }
189
+ }, C = class {
190
+ blockPosition;
191
+ dataPosition;
192
+ constructor(e, t) {
193
+ this.blockPosition = e, this.dataPosition = t;
194
+ }
195
+ toString() {
196
+ return `${this.blockPosition}:${this.dataPosition}`;
197
+ }
198
+ compareTo(e) {
199
+ return this.blockPosition - e.blockPosition || this.dataPosition - e.dataPosition;
200
+ }
201
+ };
202
+ function w(e, t = 0, n = !1) {
203
+ if (n) throw Error("big-endian virtual file offsets not implemented");
204
+ return new C(e[t + 7] * 1099511627776 + e[t + 6] * 4294967296 + e[t + 5] * 16777216 + e[t + 4] * 65536 + e[t + 3] * 256 + e[t + 2], e[t + 1] << 8 | e[t]);
205
+ }
206
+ //#endregion
207
+ //#region ../../node_modules/@gmod/bam/esm/bai.js
208
+ var ee = 21578050, T = 14, E = 1 << T;
209
+ function te(e, t) {
210
+ return e - e % t;
211
+ }
212
+ function D(e, t) {
213
+ return e - e % t + t;
214
+ }
215
+ function O(e, t) {
216
+ return --t, [
217
+ [0, 0],
218
+ [1 + (e >> 26), 1 + (t >> 26)],
219
+ [9 + (e >> 23), 9 + (t >> 23)],
220
+ [73 + (e >> 20), 73 + (t >> 20)],
221
+ [585 + (e >> 17), 585 + (t >> 17)],
222
+ [4681 + (e >> T), 4681 + (t >> T)]
223
+ ];
224
+ }
225
+ var k = class extends S {
226
+ async _parse(e) {
227
+ let t = await this.filehandle.readFile(e), n = new DataView(t.buffer);
228
+ if (n.getUint32(0, !0) !== ee) throw Error("Not a BAI file");
229
+ let r = n.getInt32(4, !0), i = 8, o, s = [];
230
+ for (let e = 0; e < r; e++) {
231
+ s.push(i);
232
+ let e = n.getInt32(i, !0);
233
+ i += 4;
234
+ for (let t = 0; t < e; t += 1) {
235
+ let e = n.getUint32(i, !0);
236
+ if (i += 4, e === 37450) i += 4, i += 32;
237
+ else if (e > 37450) throw Error("bai index contains too many bins, please use CSI");
238
+ else {
239
+ let e = n.getInt32(i, !0);
240
+ i += 4;
241
+ for (let t = 0; t < e; t++) i += 8, i += 8;
242
+ }
243
+ }
244
+ let r = n.getInt32(i, !0);
245
+ i += 4;
246
+ for (let e = 0; e < r; e++) o = p(o, w(t, i)), i += 8;
247
+ }
248
+ function c(e) {
249
+ let r = s[e];
250
+ if (r === void 0) return;
251
+ let i = n.getInt32(r, !0), o;
252
+ r += 4;
253
+ let c = {};
254
+ for (let e = 0; e < i; e += 1) {
255
+ let e = n.getUint32(r, !0);
256
+ if (r += 4, e === 37450) r += 4, o = u(t, r + 16), r += 32;
257
+ else if (e > 37450) throw Error("bai index contains too many bins, please use CSI");
258
+ else {
259
+ let i = n.getInt32(r, !0);
260
+ r += 4;
261
+ let o = Array(i);
262
+ for (let n = 0; n < i; n++) {
263
+ let i = w(t, r);
264
+ r += 8;
265
+ let s = w(t, r);
266
+ r += 8, o[n] = new a(i, s, e);
267
+ }
268
+ c[e] = o;
269
+ }
270
+ }
271
+ let l = n.getInt32(r, !0);
272
+ r += 4;
273
+ let f = Array(l);
274
+ for (let e = 0; e < l; e++) f[e] = w(t, r), r += 8;
275
+ return d(Object.values(c).flat(), f.map((e) => e.blockPosition)), {
276
+ binIndex: c,
277
+ linearIndex: f,
278
+ stats: o
279
+ };
280
+ }
281
+ return {
282
+ bai: !0,
283
+ firstDataLine: o,
284
+ maxBlockSize: 65536,
285
+ indices: x(c),
286
+ refCount: r
287
+ };
288
+ }
289
+ async indexCov(e, t, n, r) {
290
+ let i = E, a = t !== void 0, o = (await this.parse(r)).indices(e);
291
+ if (!o) return [];
292
+ let { linearIndex: s, stats: c } = o;
293
+ if (s.length === 0) return [];
294
+ let l = n === void 0 ? (s.length - 1) * i : D(n, i), u = t === void 0 ? 0 : te(t, i), d = Array(a ? (l - u) / i : s.length - 1), f = s[s.length - 1].blockPosition;
295
+ if (l > (s.length - 1) * i) throw Error("query outside of range of linear index");
296
+ let p = s[u / i].blockPosition;
297
+ for (let e = u / i, t = 0; e < l / i; e++, t++) d[t] = {
298
+ score: s[e + 1].blockPosition - p,
299
+ start: e * i,
300
+ end: e * i + i
301
+ }, p = s[e + 1].blockPosition;
302
+ return d.map((e) => ({
303
+ ...e,
304
+ score: e.score * (c?.lineCount ?? 0) / f
305
+ }));
306
+ }
307
+ reg2bins(e, t) {
308
+ return O(e, t);
309
+ }
310
+ getLowestChunk(e, t) {
311
+ let { linearIndex: n } = e, r = n.length;
312
+ return n[Math.min(t >> T, r - 1)];
313
+ }
314
+ }, A = [
315
+ 0,
316
+ 1996959894,
317
+ 3993919788,
318
+ 2567524794,
319
+ 124634137,
320
+ 1886057615,
321
+ 3915621685,
322
+ 2657392035,
323
+ 249268274,
324
+ 2044508324,
325
+ 3772115230,
326
+ 2547177864,
327
+ 162941995,
328
+ 2125561021,
329
+ 3887607047,
330
+ 2428444049,
331
+ 498536548,
332
+ 1789927666,
333
+ 4089016648,
334
+ 2227061214,
335
+ 450548861,
336
+ 1843258603,
337
+ 4107580753,
338
+ 2211677639,
339
+ 325883990,
340
+ 1684777152,
341
+ 4251122042,
342
+ 2321926636,
343
+ 335633487,
344
+ 1661365465,
345
+ 4195302755,
346
+ 2366115317,
347
+ 997073096,
348
+ 1281953886,
349
+ 3579855332,
350
+ 2724688242,
351
+ 1006888145,
352
+ 1258607687,
353
+ 3524101629,
354
+ 2768942443,
355
+ 901097722,
356
+ 1119000684,
357
+ 3686517206,
358
+ 2898065728,
359
+ 853044451,
360
+ 1172266101,
361
+ 3705015759,
362
+ 2882616665,
363
+ 651767980,
364
+ 1373503546,
365
+ 3369554304,
366
+ 3218104598,
367
+ 565507253,
368
+ 1454621731,
369
+ 3485111705,
370
+ 3099436303,
371
+ 671266974,
372
+ 1594198024,
373
+ 3322730930,
374
+ 2970347812,
375
+ 795835527,
376
+ 1483230225,
377
+ 3244367275,
378
+ 3060149565,
379
+ 1994146192,
380
+ 31158534,
381
+ 2563907772,
382
+ 4023717930,
383
+ 1907459465,
384
+ 112637215,
385
+ 2680153253,
386
+ 3904427059,
387
+ 2013776290,
388
+ 251722036,
389
+ 2517215374,
390
+ 3775830040,
391
+ 2137656763,
392
+ 141376813,
393
+ 2439277719,
394
+ 3865271297,
395
+ 1802195444,
396
+ 476864866,
397
+ 2238001368,
398
+ 4066508878,
399
+ 1812370925,
400
+ 453092731,
401
+ 2181625025,
402
+ 4111451223,
403
+ 1706088902,
404
+ 314042704,
405
+ 2344532202,
406
+ 4240017532,
407
+ 1658658271,
408
+ 366619977,
409
+ 2362670323,
410
+ 4224994405,
411
+ 1303535960,
412
+ 984961486,
413
+ 2747007092,
414
+ 3569037538,
415
+ 1256170817,
416
+ 1037604311,
417
+ 2765210733,
418
+ 3554079995,
419
+ 1131014506,
420
+ 879679996,
421
+ 2909243462,
422
+ 3663771856,
423
+ 1141124467,
424
+ 855842277,
425
+ 2852801631,
426
+ 3708648649,
427
+ 1342533948,
428
+ 654459306,
429
+ 3188396048,
430
+ 3373015174,
431
+ 1466479909,
432
+ 544179635,
433
+ 3110523913,
434
+ 3462522015,
435
+ 1591671054,
436
+ 702138776,
437
+ 2966460450,
438
+ 3352799412,
439
+ 1504918807,
440
+ 783551873,
441
+ 3082640443,
442
+ 3233442989,
443
+ 3988292384,
444
+ 2596254646,
445
+ 62317068,
446
+ 1957810842,
447
+ 3939845945,
448
+ 2647816111,
449
+ 81470997,
450
+ 1943803523,
451
+ 3814918930,
452
+ 2489596804,
453
+ 225274430,
454
+ 2053790376,
455
+ 3826175755,
456
+ 2466906013,
457
+ 167816743,
458
+ 2097651377,
459
+ 4027552580,
460
+ 2265490386,
461
+ 503444072,
462
+ 1762050814,
463
+ 4150417245,
464
+ 2154129355,
465
+ 426522225,
466
+ 1852507879,
467
+ 4275313526,
468
+ 2312317920,
469
+ 282753626,
470
+ 1742555852,
471
+ 4189708143,
472
+ 2394877945,
473
+ 397917763,
474
+ 1622183637,
475
+ 3604390888,
476
+ 2714866558,
477
+ 953729732,
478
+ 1340076626,
479
+ 3518719985,
480
+ 2797360999,
481
+ 1068828381,
482
+ 1219638859,
483
+ 3624741850,
484
+ 2936675148,
485
+ 906185462,
486
+ 1090812512,
487
+ 3747672003,
488
+ 2825379669,
489
+ 829329135,
490
+ 1181335161,
491
+ 3412177804,
492
+ 3160834842,
493
+ 628085408,
494
+ 1382605366,
495
+ 3423369109,
496
+ 3138078467,
497
+ 570562233,
498
+ 1426400815,
499
+ 3317316542,
500
+ 2998733608,
501
+ 733239954,
502
+ 1555261956,
503
+ 3268935591,
504
+ 3050360625,
505
+ 752459403,
506
+ 1541320221,
507
+ 2607071920,
508
+ 3965973030,
509
+ 1969922972,
510
+ 40735498,
511
+ 2617837225,
512
+ 3943577151,
513
+ 1913087877,
514
+ 83908371,
515
+ 2512341634,
516
+ 3803740692,
517
+ 2075208622,
518
+ 213261112,
519
+ 2463272603,
520
+ 3855990285,
521
+ 2094854071,
522
+ 198958881,
523
+ 2262029012,
524
+ 4057260610,
525
+ 1759359992,
526
+ 534414190,
527
+ 2176718541,
528
+ 4139329115,
529
+ 1873836001,
530
+ 414664567,
531
+ 2282248934,
532
+ 4279200368,
533
+ 1711684554,
534
+ 285281116,
535
+ 2405801727,
536
+ 4167216745,
537
+ 1634467795,
538
+ 376229701,
539
+ 2685067896,
540
+ 3608007406,
541
+ 1308918612,
542
+ 956543938,
543
+ 2808555105,
544
+ 3495958263,
545
+ 1231636301,
546
+ 1047427035,
547
+ 2932959818,
548
+ 3654703836,
549
+ 1088359270,
550
+ 936918e3,
551
+ 2847714899,
552
+ 3736837829,
553
+ 1202900863,
554
+ 817233897,
555
+ 3183342108,
556
+ 3401237130,
557
+ 1404277552,
558
+ 615818150,
559
+ 3134207493,
560
+ 3453421203,
561
+ 1423857449,
562
+ 601450431,
563
+ 3009837614,
564
+ 3294710456,
565
+ 1567103746,
566
+ 711928724,
567
+ 3020668471,
568
+ 3272380065,
569
+ 1510334235,
570
+ 755167117
571
+ ];
572
+ typeof Int32Array < "u" && (A = new Int32Array(A));
573
+ var j = (e, t) => {
574
+ let n = t === 0 ? 0 : ~~t ^ -1;
575
+ for (let t = 0; t < e.length; t++) n = A[(n ^ e[t]) & 255] ^ n >>> 8;
576
+ return n ^ -1;
577
+ }, M = 21582659, N = 38359875, P = new C(0, 0);
578
+ function F(e, t) {
579
+ return e * 2 ** t;
580
+ }
581
+ function I(e, t) {
582
+ return Math.floor(e / 2 ** t);
583
+ }
584
+ var L = class extends S {
585
+ maxBinNumber = 0;
586
+ depth = 0;
587
+ minShift = 0;
588
+ async indexCov() {
589
+ return [];
590
+ }
591
+ parseAuxData(e, t) {
592
+ let n = new DataView(e.buffer), r = n.getUint32(t, !0), i = r & 65536 ? "zero-based-half-open" : "1-based-closed", a = [
593
+ "generic",
594
+ "SAM",
595
+ "VCF"
596
+ ][r & 15];
597
+ if (!a) throw Error(`invalid Tabix preset format flags ${r}`);
598
+ let o = {
599
+ ref: n.getInt32(t + 4, !0),
600
+ start: n.getInt32(t + 8, !0),
601
+ end: n.getInt32(t + 12, !0)
602
+ }, s = n.getInt32(t + 16, !0), c = s ? String.fromCharCode(s) : "", l = n.getInt32(t + 20, !0), u = n.getInt32(t + 24, !0);
603
+ return {
604
+ columnNumbers: o,
605
+ coordinateType: i,
606
+ metaValue: s,
607
+ metaChar: c,
608
+ skipLines: l,
609
+ format: a,
610
+ formatFlags: r,
611
+ ...m(e.subarray(t + 28, t + 28 + u), this.renameRefSeq)
612
+ };
613
+ }
614
+ async _parse(t) {
615
+ let n = await e(await this.filehandle.readFile(t)), r = new DataView(n.buffer), i, o = r.getUint32(0, !0);
616
+ if (o === M) i = 1;
617
+ else if (o === N) i = 2;
618
+ else throw Error(`Not a CSI file ${o}`);
619
+ this.minShift = r.getInt32(4, !0), this.depth = r.getInt32(8, !0), this.maxBinNumber = ((1 << (this.depth + 1) * 3) - 1) / 7;
620
+ let s = this.maxBinNumber, c = r.getInt32(12, !0), l = c >= 30 ? this.parseAuxData(n, 16) : void 0, f = r.getInt32(16 + c, !0), m = 16 + c + 4, h, g = [];
621
+ for (let e = 0; e < f; e++) {
622
+ g.push(m);
623
+ let e = r.getInt32(m, !0);
624
+ m += 4;
625
+ for (let t = 0; t < e; t++) {
626
+ let e = r.getUint32(m, !0);
627
+ if (m += 4, e > this.maxBinNumber) m += 44;
628
+ else {
629
+ m += 8;
630
+ let e = r.getInt32(m, !0);
631
+ m += 4;
632
+ for (let t = 0; t < e; t += 1) {
633
+ let e = w(n, m);
634
+ m += 8, m += 8, h = p(h, e);
635
+ }
636
+ }
637
+ }
638
+ }
639
+ function _(e) {
640
+ let t = g[e];
641
+ if (t === void 0) return;
642
+ let i = r.getInt32(t, !0);
643
+ t += 4;
644
+ let o = {}, c;
645
+ for (let e = 0; e < i; e++) {
646
+ let e = r.getUint32(t, !0);
647
+ if (t += 4, e > s) c = u(n, t + 28), t += 44;
648
+ else {
649
+ t += 8;
650
+ let i = r.getInt32(t, !0);
651
+ t += 4;
652
+ let s = Array(i);
653
+ for (let r = 0; r < i; r += 1) {
654
+ let i = w(n, t);
655
+ t += 8;
656
+ let o = w(n, t);
657
+ t += 8, s[r] = new a(i, o, e);
658
+ }
659
+ o[e] = s;
660
+ }
661
+ }
662
+ return d(Object.values(o).flat()), {
663
+ binIndex: o,
664
+ stats: c
665
+ };
666
+ }
667
+ return {
668
+ csiVersion: i,
669
+ firstDataLine: h,
670
+ indices: x(_),
671
+ refCount: f,
672
+ csi: !0,
673
+ maxBlockSize: 65536,
674
+ ...l
675
+ };
676
+ }
677
+ getLowestChunk() {
678
+ return P;
679
+ }
680
+ reg2bins(e, t) {
681
+ let n = 2 ** (this.minShift + this.depth * 3);
682
+ t > n && (t = n), --t;
683
+ let r = 0, i = 0, a = this.minShift + this.depth * 3, o = [];
684
+ for (; r <= this.depth; a -= 3, i += F(1, r * 3), r += 1) {
685
+ let n = i + I(e, a), r = i + I(t, a);
686
+ if (r - n + o.length > this.maxBinNumber) throw Error(`query ${e}-${t} is too large for current binning scheme (shift ${this.minShift}, depth ${this.depth}), try a smaller query or a coarser index binning scheme`);
687
+ o.push([n, r]);
688
+ }
689
+ return o;
690
+ }
691
+ }, ne = class {
692
+ read() {
693
+ throw Error("never called");
694
+ }
695
+ stat() {
696
+ throw Error("never called");
697
+ }
698
+ readFile() {
699
+ throw Error("never called");
700
+ }
701
+ close() {
702
+ throw Error("never called");
703
+ }
704
+ }, R = {
705
+ BAM_FPAIRED: 1,
706
+ BAM_FPROPER_PAIR: 2,
707
+ BAM_FUNMAP: 4,
708
+ BAM_FMUNMAP: 8,
709
+ BAM_FREVERSE: 16,
710
+ BAM_FMREVERSE: 32,
711
+ BAM_FREAD1: 64,
712
+ BAM_FREAD2: 128,
713
+ BAM_FSECONDARY: 256,
714
+ BAM_FQCFAIL: 512,
715
+ BAM_FDUP: 1024,
716
+ BAM_FSUPPLEMENTARY: 2048
717
+ }, z = "=ACMGRSVTWYHKDBN".split(""), B = /* @__PURE__ */ "F F .F R .R F .R R .F2F1.F2R1.R2F1.R2R1.F1F2.F1R2.R1F2.R1R2.F2F1.F2R1.R2F1.R2R1.F F .R F .F R .R R .F1F2.R1F2.F1R2.R1R2.F2F1.R2F1.F2R1.R2R1.F1F2.R1F2.F1R2.R1R2".split("."), V = [
718
+ 77,
719
+ 73,
720
+ 68,
721
+ 78,
722
+ 83,
723
+ 72,
724
+ 80,
725
+ 61,
726
+ 88,
727
+ 63,
728
+ 63,
729
+ 63,
730
+ 63,
731
+ 63,
732
+ 63,
733
+ 63
734
+ ], H = new TextDecoder(), U = 461;
735
+ function W(e, t, n, r, i) {
736
+ let a = e.byteOffset + n;
737
+ switch (r) {
738
+ case 105: {
739
+ if (a % 4 == 0) return new Int32Array(e.buffer, a, i);
740
+ let r = Array(i);
741
+ for (let e = 0; e < i; e++) r[e] = t.getInt32(n + e * 4, !0);
742
+ return r;
743
+ }
744
+ case 73: {
745
+ if (a % 4 == 0) return new Uint32Array(e.buffer, a, i);
746
+ let r = Array(i);
747
+ for (let e = 0; e < i; e++) r[e] = t.getUint32(n + e * 4, !0);
748
+ return r;
749
+ }
750
+ case 115: {
751
+ if (a % 2 == 0) return new Int16Array(e.buffer, a, i);
752
+ let r = Array(i);
753
+ for (let e = 0; e < i; e++) r[e] = t.getInt16(n + e * 2, !0);
754
+ return r;
755
+ }
756
+ case 83: {
757
+ if (a % 2 == 0) return new Uint16Array(e.buffer, a, i);
758
+ let r = Array(i);
759
+ for (let e = 0; e < i; e++) r[e] = t.getUint16(n + e * 2, !0);
760
+ return r;
761
+ }
762
+ case 99: return new Int8Array(e.buffer, a, i);
763
+ case 67: return new Uint8Array(e.buffer, a, i);
764
+ case 102: {
765
+ if (a % 4 == 0) return new Float32Array(e.buffer, a, i);
766
+ let r = Array(i);
767
+ for (let e = 0; e < i; e++) r[e] = t.getFloat32(n + e * 4, !0);
768
+ return r;
769
+ }
770
+ default: return;
771
+ }
772
+ }
773
+ function G(e, t) {
774
+ return e === 105 || e === 73 || e === 102 ? t << 2 : e === 115 || e === 83 ? t << 1 : t;
775
+ }
776
+ var K = class {
777
+ fileOffset;
778
+ _byteArray;
779
+ _start;
780
+ _end;
781
+ _dataView;
782
+ _cachedEnd;
783
+ _cachedTags;
784
+ _cachedLengthOnRef;
785
+ _cachedNumericCigar;
786
+ _cachedNUMERIC_MD;
787
+ _cachedSeqStart;
788
+ constructor(e) {
789
+ this._byteArray = e.bytes.byteArray, this._start = e.bytes.start, this._end = e.bytes.end, this.fileOffset = e.fileOffset, this._dataView = e.dataView;
790
+ }
791
+ get byteArray() {
792
+ return this._byteArray;
793
+ }
794
+ get flags() {
795
+ return this._dataView.getUint16(this._start + 18, !0);
796
+ }
797
+ get ref_id() {
798
+ return this._dataView.getInt32(this._start + 4, !0);
799
+ }
800
+ get start() {
801
+ return this._dataView.getInt32(this._start + 8, !0);
802
+ }
803
+ get end() {
804
+ return this._cachedEnd === void 0 && (this._cachedEnd = this.start + this.length_on_ref), this._cachedEnd;
805
+ }
806
+ get mq() {
807
+ let e = (this.bin_mq_nl & 65280) >> 8;
808
+ return e === 255 ? void 0 : e;
809
+ }
810
+ get score() {
811
+ return this.mq;
812
+ }
813
+ get qual() {
814
+ let e = this.seq_length;
815
+ if (e === 0) return null;
816
+ {
817
+ let t = this.seqStart + (e + 1 >> 1);
818
+ return this._byteArray.subarray(t, t + e);
819
+ }
820
+ }
821
+ get strand() {
822
+ return this.isReverseComplemented() ? -1 : 1;
823
+ }
824
+ get b0() {
825
+ return this._start + 36;
826
+ }
827
+ get seqStart() {
828
+ return this._cachedSeqStart === void 0 && (this._cachedSeqStart = this.b0 + this.read_name_length + this.num_cigar_bytes), this._cachedSeqStart;
829
+ }
830
+ get tagsStart() {
831
+ let e = this.seq_length;
832
+ return this.seqStart + (e + 1 >> 1) + e;
833
+ }
834
+ get name() {
835
+ let e = this.read_name_length - 1, t = this.b0, n = this._byteArray, r = Array(e);
836
+ for (let i = 0; i < e; i++) r[i] = n[t + i];
837
+ return String.fromCharCode(...r);
838
+ }
839
+ get NUMERIC_MD() {
840
+ if (this._cachedNUMERIC_MD === void 0) {
841
+ let e = this.getTagRaw("MD");
842
+ this._cachedNUMERIC_MD = e instanceof Uint8Array ? e : null;
843
+ }
844
+ return this._cachedNUMERIC_MD === null ? void 0 : this._cachedNUMERIC_MD;
845
+ }
846
+ get tags() {
847
+ return this._cachedTags === void 0 && (this._cachedTags = this._computeTags()), this._cachedTags;
848
+ }
849
+ getTag(e) {
850
+ return this._cachedTags === void 0 ? this._findTag(e, !1) : this._cachedTags[e];
851
+ }
852
+ getTagRaw(e) {
853
+ return this._findTag(e, !0);
854
+ }
855
+ _findTag(e, t) {
856
+ let n = e.charCodeAt(0), r = e.charCodeAt(1), i = this.tagsStart, a = this._end, o = this._byteArray;
857
+ for (; i < a;) {
858
+ let e = o[i], s = o[i + 1], c = o[i + 2];
859
+ i += 3;
860
+ let l = e === n && s === r;
861
+ switch (c) {
862
+ case 65:
863
+ if (l) return String.fromCharCode(o[i]);
864
+ i += 1;
865
+ break;
866
+ case 105:
867
+ if (l) return this._dataView.getInt32(i, !0);
868
+ i += 4;
869
+ break;
870
+ case 73:
871
+ if (l) return this._dataView.getUint32(i, !0);
872
+ i += 4;
873
+ break;
874
+ case 99:
875
+ if (l) return this._dataView.getInt8(i);
876
+ i += 1;
877
+ break;
878
+ case 67:
879
+ if (l) return this._dataView.getUint8(i);
880
+ i += 1;
881
+ break;
882
+ case 115:
883
+ if (l) return this._dataView.getInt16(i, !0);
884
+ i += 2;
885
+ break;
886
+ case 83:
887
+ if (l) return this._dataView.getUint16(i, !0);
888
+ i += 2;
889
+ break;
890
+ case 102:
891
+ if (l) return this._dataView.getFloat32(i, !0);
892
+ i += 4;
893
+ break;
894
+ case 90:
895
+ case 72: {
896
+ let e = i;
897
+ for (; i < a && o[i] !== 0;) i++;
898
+ if (l) return t ? o.subarray(e, i) : H.decode(o.subarray(e, i));
899
+ i++;
900
+ break;
901
+ }
902
+ case 66: {
903
+ let e = o[i++], t = this._dataView.getInt32(i, !0);
904
+ if (i += 4, l) return W(o, this._dataView, i, e, t);
905
+ i += G(e, t);
906
+ break;
907
+ }
908
+ default:
909
+ c !== void 0 && console.error("Unknown BAM tag type", c);
910
+ break;
911
+ }
912
+ }
913
+ }
914
+ _computeTags() {
915
+ let e = this.tagsStart, t = this._end, n = this._byteArray, r = {};
916
+ for (; e < t;) {
917
+ let i = String.fromCharCode(n[e], n[e + 1]), a = n[e + 2];
918
+ switch (e += 3, a) {
919
+ case 65:
920
+ r[i] = String.fromCharCode(n[e]), e += 1;
921
+ break;
922
+ case 105:
923
+ r[i] = this._dataView.getInt32(e, !0), e += 4;
924
+ break;
925
+ case 73:
926
+ r[i] = this._dataView.getUint32(e, !0), e += 4;
927
+ break;
928
+ case 99:
929
+ r[i] = this._dataView.getInt8(e), e += 1;
930
+ break;
931
+ case 67:
932
+ r[i] = this._dataView.getUint8(e), e += 1;
933
+ break;
934
+ case 115:
935
+ r[i] = this._dataView.getInt16(e, !0), e += 2;
936
+ break;
937
+ case 83:
938
+ r[i] = this._dataView.getUint16(e, !0), e += 2;
939
+ break;
940
+ case 102:
941
+ r[i] = this._dataView.getFloat32(e, !0), e += 4;
942
+ break;
943
+ case 90:
944
+ case 72: {
945
+ let a = e;
946
+ for (; e < t && n[e] !== 0;) e++;
947
+ r[i] = H.decode(n.subarray(a, e)), e++;
948
+ break;
949
+ }
950
+ case 66: {
951
+ let t = n[e++], a = this._dataView.getInt32(e, !0);
952
+ e += 4, r[i] = W(n, this._dataView, e, t, a), e += G(t, a);
953
+ break;
954
+ }
955
+ default:
956
+ console.error("Unknown BAM tag type", a);
957
+ break;
958
+ }
959
+ }
960
+ return r;
961
+ }
962
+ isPaired() {
963
+ return !!(this.flags & R.BAM_FPAIRED);
964
+ }
965
+ isProperlyPaired() {
966
+ return !!(this.flags & R.BAM_FPROPER_PAIR);
967
+ }
968
+ isSegmentUnmapped() {
969
+ return !!(this.flags & R.BAM_FUNMAP);
970
+ }
971
+ isMateUnmapped() {
972
+ return !!(this.flags & R.BAM_FMUNMAP);
973
+ }
974
+ isReverseComplemented() {
975
+ return !!(this.flags & R.BAM_FREVERSE);
976
+ }
977
+ isMateReverseComplemented() {
978
+ return !!(this.flags & R.BAM_FMREVERSE);
979
+ }
980
+ isRead1() {
981
+ return !!(this.flags & R.BAM_FREAD1);
982
+ }
983
+ isRead2() {
984
+ return !!(this.flags & R.BAM_FREAD2);
985
+ }
986
+ isSecondary() {
987
+ return !!(this.flags & R.BAM_FSECONDARY);
988
+ }
989
+ isFailedQc() {
990
+ return !!(this.flags & R.BAM_FQCFAIL);
991
+ }
992
+ isDuplicate() {
993
+ return !!(this.flags & R.BAM_FDUP);
994
+ }
995
+ isSupplementary() {
996
+ return !!(this.flags & R.BAM_FSUPPLEMENTARY);
997
+ }
998
+ _isCGTagPattern(e, t) {
999
+ if (t === 2) {
1000
+ let t = this._dataView.getInt32(e, !0);
1001
+ return (t & 15) == 4 && t >> 4 === this.seq_length;
1002
+ } else return !1;
1003
+ }
1004
+ _computeLengthOnRef() {
1005
+ let e = this._dataView.getInt32(this._start + 16, !0);
1006
+ if (e & R.BAM_FUNMAP << 16) return 0;
1007
+ let t = e & 65535, n = this.b0 + this.read_name_length;
1008
+ if (this._isCGTagPattern(n, t)) {
1009
+ let e = this._dataView.getInt32(n + 4, !0);
1010
+ return (e & 15) != 3 && console.warn("CG tag with no N tag"), e >> 4;
1011
+ }
1012
+ let r = this._byteArray.byteOffset + n;
1013
+ if (r % 4 == 0 && t > 50) {
1014
+ let e = new Uint32Array(this._byteArray.buffer, r, t);
1015
+ this._cachedNumericCigar = e;
1016
+ let n = 0;
1017
+ for (let r = 0; r < t; ++r) {
1018
+ let t = e[r];
1019
+ n += (t >> 4) * (U >> (t & 15) & 1);
1020
+ }
1021
+ return n;
1022
+ }
1023
+ let i = 0;
1024
+ for (let e = 0; e < t; ++e) {
1025
+ let t = this._dataView.getInt32(n + e * 4, !0);
1026
+ i += (t >> 4) * (U >> (t & 15) & 1);
1027
+ }
1028
+ return i;
1029
+ }
1030
+ _computeNumericCigar() {
1031
+ let e = this._dataView.getInt32(this._start + 16, !0);
1032
+ if (e & R.BAM_FUNMAP << 16) return /* @__PURE__ */ new Uint32Array();
1033
+ let t = e & 65535, n = this.b0 + this.read_name_length;
1034
+ if (this._isCGTagPattern(n, t)) return this.tags.CG ?? /* @__PURE__ */ new Uint32Array();
1035
+ let r = this._byteArray.byteOffset + n;
1036
+ if (r % 4 == 0 && t > 50) return new Uint32Array(this._byteArray.buffer, r, t);
1037
+ let i = Array(t);
1038
+ for (let e = 0; e < t; ++e) i[e] = this._dataView.getInt32(n + e * 4, !0) | 0;
1039
+ return i;
1040
+ }
1041
+ get length_on_ref() {
1042
+ return this._cachedLengthOnRef === void 0 && (this._cachedLengthOnRef = this._computeLengthOnRef()), this._cachedLengthOnRef;
1043
+ }
1044
+ get NUMERIC_CIGAR() {
1045
+ return this._cachedNumericCigar === void 0 && (this._cachedNumericCigar = this._computeNumericCigar()), this._cachedNumericCigar;
1046
+ }
1047
+ get CIGAR() {
1048
+ let e = this.NUMERIC_CIGAR, t = "";
1049
+ for (let n = 0, r = e.length; n < r; n++) {
1050
+ let r = e[n], i = r >> 4, a = V[r & 15];
1051
+ t += i + String.fromCharCode(a);
1052
+ }
1053
+ return t;
1054
+ }
1055
+ get num_cigar_ops() {
1056
+ return this.flag_nc & 65535;
1057
+ }
1058
+ get num_cigar_bytes() {
1059
+ return this.num_cigar_ops << 2;
1060
+ }
1061
+ get read_name_length() {
1062
+ return this.bin_mq_nl & 255;
1063
+ }
1064
+ get num_seq_bytes() {
1065
+ return this.seq_length + 1 >> 1;
1066
+ }
1067
+ get NUMERIC_SEQ() {
1068
+ let e = this.seqStart;
1069
+ return this._byteArray.subarray(e, e + this.num_seq_bytes);
1070
+ }
1071
+ get seq() {
1072
+ let e = this.seq_length, t = this.seqStart, n = this._byteArray, r = Array(e), i = 0, a = e >> 1;
1073
+ for (let e = 0; e < a; ++e) {
1074
+ let a = n[t + e];
1075
+ r[i++] = z[(a & 240) >> 4], r[i++] = z[a & 15];
1076
+ }
1077
+ return i < e && (r[i] = z[(n[t + a] & 240) >> 4]), r.join("");
1078
+ }
1079
+ get pair_orientation() {
1080
+ let e = this.flags;
1081
+ if (!(e & 12 || this.ref_id !== this.next_refid)) return B[e >> 4 & 15 | (this.template_length > 0 ? 16 : 0)];
1082
+ }
1083
+ get bin_mq_nl() {
1084
+ return this._dataView.getInt32(this._start + 12, !0);
1085
+ }
1086
+ get flag_nc() {
1087
+ return this._dataView.getInt32(this._start + 16, !0);
1088
+ }
1089
+ get seq_length() {
1090
+ return this._dataView.getInt32(this._start + 20, !0);
1091
+ }
1092
+ get next_refid() {
1093
+ return this._dataView.getInt32(this._start + 24, !0);
1094
+ }
1095
+ get next_pos() {
1096
+ return this._dataView.getInt32(this._start + 28, !0);
1097
+ }
1098
+ get template_length() {
1099
+ return this._dataView.getInt32(this._start + 32, !0);
1100
+ }
1101
+ seqAt(e) {
1102
+ if (e < this.seq_length) {
1103
+ let t = this._byteArray[this.seqStart + (e >> 1)];
1104
+ return e % 2 == 0 ? z[(t & 240) >> 4] : z[t & 15];
1105
+ } else return;
1106
+ }
1107
+ toJSON() {
1108
+ return {
1109
+ fileOffset: this.fileOffset,
1110
+ ref_id: this.ref_id,
1111
+ start: this.start,
1112
+ end: this.end,
1113
+ name: this.name,
1114
+ flags: this.flags,
1115
+ mq: this.mq,
1116
+ CIGAR: this.CIGAR,
1117
+ seq: this.seq,
1118
+ next_refid: this.next_refid,
1119
+ next_pos: this.next_pos,
1120
+ template_length: this.template_length,
1121
+ tags: this.tags
1122
+ };
1123
+ }
1124
+ };
1125
+ //#endregion
1126
+ //#region ../../node_modules/@gmod/bam/esm/sam.js
1127
+ function q(e) {
1128
+ let t = e.split(/\r?\n/), n = [];
1129
+ for (let e of t) {
1130
+ let [t, ...r] = e.split(/\t/);
1131
+ t && n.push({
1132
+ tag: t.slice(1),
1133
+ data: r.map((e) => {
1134
+ let t = e.indexOf(":");
1135
+ return {
1136
+ tag: e.slice(0, t),
1137
+ value: e.slice(t + 1)
1138
+ };
1139
+ })
1140
+ });
1141
+ }
1142
+ return n;
1143
+ }
1144
+ var J = 65536;
1145
+ function Y(e, t, n) {
1146
+ return e ?? (t ? new i(t) : n ? new r(n) : void 0);
1147
+ }
1148
+ function X(e, t) {
1149
+ let { minv: n, maxv: r } = e;
1150
+ return `${n.blockPosition}:${n.dataPosition}-${r.blockPosition}:${r.dataPosition}${v(t)}`;
1151
+ }
1152
+ var Z = class {
1153
+ renameRefSeq;
1154
+ bam;
1155
+ header;
1156
+ chrToIndex;
1157
+ indexToChr;
1158
+ index;
1159
+ htsget = !1;
1160
+ headerP;
1161
+ chunkFeatureCache = new n({ maxSize: 100 });
1162
+ RecordClass;
1163
+ constructor({ bamFilehandle: e, bamPath: t, bamUrl: n, baiPath: r, baiFilehandle: i, baiUrl: a, csiPath: o, csiFilehandle: s, csiUrl: c, htsget: l, renameRefSeqs: u = (e) => e, recordClass: d }) {
1164
+ this.renameRefSeq = u, this.RecordClass = d ?? K;
1165
+ let f = Y(e, t, n);
1166
+ if (f) this.bam = f;
1167
+ else if (l) this.htsget = !0, this.bam = new ne();
1168
+ else throw Error("no bam source: pass bamFilehandle, bamPath, bamUrl, or htsget: true");
1169
+ let p = Y(s, o, c), m = Y(i, r, a) ?? Y(void 0, t ? `${t}.bai` : void 0, n ? `${n}.bai` : void 0);
1170
+ if (p) this.index = new L({ filehandle: p });
1171
+ else if (m) this.index = new k({ filehandle: m });
1172
+ else if (!l) throw Error("no index source: pass csi*/bai* options or a bamPath/bamUrl so the .bai sibling can be inferred");
1173
+ }
1174
+ async getHeaderPre(t = {}) {
1175
+ if (!this.index) return;
1176
+ let n = await this.index.parse(t), r = n.firstDataLine === void 0 ? void 0 : n.firstDataLine.blockPosition + J, i = await e(r === void 0 ? await this.bam.readFile() : await this.bam.read(r, 0)), a = new DataView(i.buffer);
1177
+ if (a.getInt32(0, !0) !== 21840194) throw Error("Not a BAM file");
1178
+ let o = a.getInt32(4, !0);
1179
+ this.header = new TextDecoder("utf8").decode(i.subarray(8, 8 + o));
1180
+ let s = o + 8, c = f(i, s, this.renameRefSeq);
1181
+ if (c ||= (i = await e(await this.bam.readFile()), f(i, s, this.renameRefSeq)), !c) throw Error("Insufficient data for reference sequences");
1182
+ return this.chrToIndex = c.chrToIndex, this.indexToChr = c.indexToChr, q(this.header);
1183
+ }
1184
+ getHeader(e) {
1185
+ return this.headerP ||= this.getHeaderPre(e).catch((e) => {
1186
+ throw this.headerP = void 0, e;
1187
+ }), this.headerP;
1188
+ }
1189
+ async getHeaderText(e = {}) {
1190
+ return await this.getHeader(e), this.header;
1191
+ }
1192
+ async getSeqId(e, t) {
1193
+ return await this.getHeader(t), this.chrToIndex?.[e];
1194
+ }
1195
+ async getRecordsForRange(e, t, n, r) {
1196
+ let i = await this.getSeqId(e, r);
1197
+ if (i === void 0 || !this.index) return [];
1198
+ let a = await this.index.blocksForRange(i, t - 1, n, r);
1199
+ return this._fetchChunkFeaturesDirect(a, i, t, n, r);
1200
+ }
1201
+ evictOverlappingChunks(e, t) {
1202
+ for (let [n, r] of this.chunkFeatureCache) e <= r.maxBlock && t >= r.minBlock && this.chunkFeatureCache.delete(n);
1203
+ }
1204
+ async _fetchChunkFeaturesDirect(e, t, n, r, i = {}) {
1205
+ let { viewAsPairs: a, filterBy: o, onProgress: s } = i, c = [], l = 0;
1206
+ for (let t = 0, n = e.length; t < n; t++) l += e[t].fetchedSize();
1207
+ let u = 0;
1208
+ s?.(0, l);
1209
+ for (let a = 0, d = e.length; a < d; a++) {
1210
+ let d = e[a], f = X(d, o), p = d.minv.blockPosition, m = d.maxv.blockPosition, h, g = this.chunkFeatureCache.get(f);
1211
+ if (g) h = g.features;
1212
+ else {
1213
+ this.evictOverlappingChunks(p, m);
1214
+ let e = await this._readChunkFeatures(d, i);
1215
+ h = o ? y(e, o) : e, this.chunkFeatureCache.set(f, {
1216
+ minBlock: p,
1217
+ maxBlock: m,
1218
+ features: h
1219
+ });
1220
+ }
1221
+ u += d.fetchedSize(), s?.(u, l), b(h, t, n, r, c);
1222
+ }
1223
+ if (a) {
1224
+ let e = await this.fetchPairs(t, c, i);
1225
+ for (let t = 0, n = e.length; t < n; t++) c.push(e[t]);
1226
+ }
1227
+ return c;
1228
+ }
1229
+ async fetchPairs(e, t, n) {
1230
+ let { pairAcrossChr: r, maxInsertSize: i = 2e5 } = n, a = {}, o = /* @__PURE__ */ new Set();
1231
+ for (let e = 0, n = t.length; e < n; e++) {
1232
+ let n = t[e], r = n.name;
1233
+ a[r] = (a[r] ?? 0) + 1, o.add(n.fileOffset);
1234
+ }
1235
+ let s = [];
1236
+ for (let o = 0, c = t.length; o < c; o++) {
1237
+ let c = t[o], l = c.name;
1238
+ this.index && a[l] === 1 && (r || c.next_refid === e && Math.abs(c.start - c.next_pos) < i) && s.push(this.index.blocksForRange(c.next_refid, c.next_pos, c.next_pos + 1, n));
1239
+ }
1240
+ let c = /* @__PURE__ */ new Map(), l = await Promise.all(s);
1241
+ for (let e = 0, t = l.length; e < t; e++) {
1242
+ let t = l[e];
1243
+ for (let e = 0, n = t.length; e < n; e++) {
1244
+ let n = t[e];
1245
+ c.set(n.toString(), n);
1246
+ }
1247
+ }
1248
+ return (await Promise.all([...c.values()].map(async (e) => {
1249
+ let t = await this._readChunkFeatures(e, n), r = [];
1250
+ for (let e = 0, n = t.length; e < n; e++) {
1251
+ let n = t[e];
1252
+ a[n.name] === 1 && !o.has(n.fileOffset) && r.push(n);
1253
+ }
1254
+ return r;
1255
+ }))).flat();
1256
+ }
1257
+ async _readChunkFeatures(e, n) {
1258
+ let { buffer: r, cpositions: i, dpositions: a } = await t(await this.bam.read(e.fetchedSize(), e.minv.blockPosition, { signal: n.signal }), e);
1259
+ return this.readBamFeatures(r, i, a, e);
1260
+ }
1261
+ async readBamFeatures(e, t, n, r) {
1262
+ let i = 0, a = [], o = 0, s = new DataView(e.buffer), c = n.length > 0, l = t.length > 0;
1263
+ for (; i + 4 < e.length;) {
1264
+ let u = s.getInt32(i, !0), d = i + 4 + u - 1;
1265
+ if (c) {
1266
+ let e = i + r.minv.dataPosition;
1267
+ for (; o < n.length && e >= n[o];) o++;
1268
+ }
1269
+ if (d < e.length) {
1270
+ let c = new this.RecordClass({
1271
+ bytes: {
1272
+ byteArray: e,
1273
+ start: i,
1274
+ end: d
1275
+ },
1276
+ fileOffset: l ? t[o] * 256 + (i - n[o]) + r.minv.dataPosition + 1 : j(e.subarray(i, d)) >>> 0,
1277
+ dataView: s
1278
+ });
1279
+ a.push(c);
1280
+ }
1281
+ i = d + 1;
1282
+ }
1283
+ return a;
1284
+ }
1285
+ async hasRefSeq(e, t) {
1286
+ let n = await this.getSeqId(e, t);
1287
+ return !this.index || n === void 0 ? !1 : this.index.hasRefSeq(n);
1288
+ }
1289
+ async lineCount(e, t) {
1290
+ let n = await this.getSeqId(e, t);
1291
+ return !this.index || n === void 0 ? 0 : this.index.lineCount(n);
1292
+ }
1293
+ async indexCov(e, t, n) {
1294
+ let r = await this.getSeqId(e);
1295
+ return !this.index || r === void 0 ? [] : this.index.indexCov(r, t, n);
1296
+ }
1297
+ async blocksForRange(e, t, n, r) {
1298
+ let i = await this.getSeqId(e, r);
1299
+ return !this.index || i === void 0 ? [] : this.index.blocksForRange(i, t, n, r);
1300
+ }
1301
+ clearFeatureCache() {
1302
+ this.chunkFeatureCache.clear();
1303
+ }
1304
+ async estimatedBytesForRegions(e, t) {
1305
+ if (!this.index) return 0;
1306
+ await this.getHeader(t);
1307
+ let n = e.flatMap((e) => {
1308
+ let t = this.chrToIndex?.[e.refName];
1309
+ return t === void 0 ? [] : [{
1310
+ refId: t,
1311
+ start: e.start,
1312
+ end: e.end
1313
+ }];
1314
+ });
1315
+ return this.index.estimatedBytesForRegions(n, t);
1316
+ }
1317
+ };
1318
+ //#endregion
1319
+ //#region ../../node_modules/@gmod/bam/esm/htsget.js
1320
+ async function Q(e, t) {
1321
+ let n = await fetch(e, t);
1322
+ if (!n.ok) throw Error(`HTTP ${n.status} fetching ${e}: ${await n.text()}`);
1323
+ return n;
1324
+ }
1325
+ async function re({ url: e, headers: t }, n) {
1326
+ let { referer: r, ...i } = t ?? {}, a = e.startsWith("data:") ? await Q(e) : await Q(e, {
1327
+ ...n,
1328
+ headers: i
1329
+ });
1330
+ return new Uint8Array(await a.arrayBuffer());
1331
+ }
1332
+ async function $(t, n) {
1333
+ return h(await Promise.all(t.map(async (t) => e(await re(t, n)))));
1334
+ }
1335
+ var ie = class extends Z {
1336
+ baseUrl;
1337
+ trackId;
1338
+ constructor(e) {
1339
+ super({
1340
+ htsget: !0,
1341
+ recordClass: e.recordClass
1342
+ }), this.baseUrl = e.baseUrl, this.trackId = e.trackId;
1343
+ }
1344
+ async getRecordsForRange(e, t, n, r) {
1345
+ await this.getHeader(r);
1346
+ let i = `${`${this.baseUrl}/${this.trackId}`}?referenceName=${e}&start=${t}&end=${n}&format=BAM`, o = this.chrToIndex?.[e];
1347
+ if (o === void 0) return [];
1348
+ let s = await $((await (await Q(i, r)).json()).htsget.urls.slice(1), { signal: r?.signal }), c = new C(0, 0);
1349
+ return b(await this.readBamFeatures(s, [], [], new a(c, c, 0)), o, t, n);
1350
+ }
1351
+ async getHeaderPre(e = {}) {
1352
+ let t = await $((await (await Q(`${this.baseUrl}/${this.trackId}?referenceName=na&class=header`, e)).json()).htsget.urls, { signal: e.signal }), n = new DataView(t.buffer);
1353
+ if (n.getInt32(0, !0) !== 21840194) throw Error("Not a BAM file");
1354
+ let r = n.getInt32(4, !0), i = q(new TextDecoder().decode(t.subarray(8, 8 + r))), a = [], o = {}, s = i.filter((e) => e.tag === "SQ");
1355
+ for (let [e, t] of s.entries()) {
1356
+ let n = "", r = 0;
1357
+ for (let e of t.data) e.tag === "SN" ? n = e.value : e.tag === "LN" && (r = +e.value);
1358
+ o[n] = e, a[e] = {
1359
+ refName: n,
1360
+ length: r
1361
+ };
1362
+ }
1363
+ return this.chrToIndex = o, this.indexToChr = a, i;
1364
+ }
1365
+ };
1366
+ //#endregion
1367
+ export { k as BAI, Z as BamFile, K as BamRecord, L as CSI, ie as HtsgetFile };