jbrowse-plugin-graphgenomeviewer 3.0.4 → 3.1.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.
- package/README.md +29 -2
- package/dist/chunks/GbzBaseSyntenyAdapter-MIOUYHOF.js +8 -0
- package/dist/chunks/GbzBaseSyntenyAdapter-MIOUYHOF.js.map +7 -0
- package/dist/chunks/GraphGenomeView-TM7WYDLH.js +14 -0
- package/dist/chunks/GraphGenomeView-TM7WYDLH.js.map +7 -0
- package/dist/chunks/MinigraphBubbleAdapter-A7SBF2XY.js +2 -0
- package/dist/chunks/MinigraphBubbleAdapter-A7SBF2XY.js.map +7 -0
- package/dist/chunks/RgfaTabixAdapter-7ZGKJJYW.js +3 -0
- package/dist/chunks/RgfaTabixAdapter-7ZGKJJYW.js.map +7 -0
- package/dist/chunks/{chunk-X3X74OGB.js → chunk-7T2HTRP3.js} +2 -2
- package/dist/chunks/{chunk-X3X74OGB.js.map → chunk-7T2HTRP3.js.map} +3 -3
- package/dist/chunks/{chunk-JCG7RLMB.js → chunk-HOM2Y6XS.js} +2 -2
- package/dist/chunks/chunk-HOM2Y6XS.js.map +7 -0
- package/dist/jbrowse-plugin-graphgenomeviewer.esm.js +2 -2
- package/dist/jbrowse-plugin-graphgenomeviewer.esm.js.map +4 -4
- package/package.json +21 -22
- package/src/GbzBaseSyntenyAdapter/GbzBaseSyntenyAdapter.test.ts +69 -0
- package/src/GbzBaseSyntenyAdapter/GbzBaseSyntenyAdapter.ts +13 -10
- package/src/GetSubgraph.ts +5 -1
- package/src/GraphGenomeView/components/FollowControl.test.tsx +69 -0
- package/src/GraphGenomeView/components/FollowControl.tsx +42 -0
- package/src/GraphGenomeView/components/GraphStats.tsx +1 -0
- package/src/GraphGenomeView/components/GraphToolbar.tsx +2 -0
- package/src/GraphGenomeView/follow.test.ts +624 -0
- package/src/GraphGenomeView/follow.ts +129 -0
- package/src/GraphGenomeView/layout/sampleRowLayout.test.ts +16 -0
- package/src/GraphGenomeView/layout/sampleRowLayout.ts +13 -4
- package/src/GraphGenomeView/layoutModes.ts +3 -1
- package/src/GraphGenomeView/model.ts +361 -55
- package/src/GraphGenomeView/types.ts +4 -0
- package/src/MinigraphBubbleAdapter/MinigraphBubbleAdapter.ts +1 -1
- package/src/RgfaTabixAdapter/RgfaTabixAdapter.test.ts +73 -0
- package/src/RgfaTabixAdapter/RgfaTabixAdapter.ts +48 -16
- package/src/RgfaTabixAdapter/configSchema.ts +70 -3
- package/src/RgfaTabixAdapter/test_data/rgfa_ecoli.tier1000.links.bed.gz +0 -0
- package/src/RgfaTabixAdapter/test_data/rgfa_ecoli.tier1000.links.bed.gz.tbi +0 -0
- package/src/RgfaTabixAdapter/test_data/rgfa_ecoli.tier1000.segs.bed.gz +0 -0
- package/src/RgfaTabixAdapter/test_data/rgfa_ecoli.tier1000.segs.bed.gz.tbi +0 -0
- package/src/launchSubgraph/index.ts +12 -6
- package/src/launchSubgraph/launchSubgraph.test.ts +89 -3
- package/src/launchSubgraph/launchSubgraphView.ts +14 -6
- package/src/launchSubgraph/linearViewMenuItems.ts +3 -0
- package/src/launchSubgraph/subgraphMenuItems.ts +7 -0
- package/src/launchSubgraph/testEnv.ts +2 -0
- package/src/panSNTabix.ts +6 -5
- package/src/synteny/ComparativeAdapterBase.ts +13 -10
- package/src/synteny/clipFeatureToRegion.test.ts +41 -1
- package/src/synteny/clipFeatureToRegion.ts +22 -5
- package/src/version.ts +1 -1
- package/dist/chunks/GbzBaseSyntenyAdapter-6UTRY4CV.js +0 -8
- package/dist/chunks/GbzBaseSyntenyAdapter-6UTRY4CV.js.map +0 -7
- package/dist/chunks/GraphGenomeView-UD5WCV3Q.js +0 -14
- package/dist/chunks/GraphGenomeView-UD5WCV3Q.js.map +0 -7
- package/dist/chunks/MinigraphBubbleAdapter-B75VQK7T.js +0 -2
- package/dist/chunks/MinigraphBubbleAdapter-B75VQK7T.js.map +0 -7
- package/dist/chunks/RgfaTabixAdapter-IT7I5RR3.js +0 -3
- package/dist/chunks/RgfaTabixAdapter-IT7I5RR3.js.map +0 -7
- package/dist/chunks/chunk-JCG7RLMB.js.map +0 -7
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/MinigraphBubbleAdapter/MinigraphBubbleAdapter.ts"],
|
|
4
|
+
"sourcesContent": ["import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter'\nimport { SimpleFeature, updateStatus } from '@jbrowse/core/util'\nimport { ObservableCreate } from '@jbrowse/core/util/rxjs'\n\nimport { PanSNRefNames, openTabixSlot } from '../panSNTabix.ts'\nimport {\n bubbleDescription,\n bubbleLabel,\n parseBubbleLine,\n} from './bubbleLine.ts'\n\nimport type { MinigraphBubbleAdapterConfig } from './configSchema.ts'\nimport type PluginManager from '@jbrowse/core/PluginManager'\nimport type { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter'\nimport type { getSubAdapterType } from '@jbrowse/core/data_adapters/dataAdapterCache'\nimport type { Feature } from '@jbrowse/core/util'\nimport type { Region } from '@jbrowse/core/util/types'\n\nexport default class MinigraphBubbleAdapter extends BaseFeatureDataAdapter<MinigraphBubbleAdapterConfig> {\n public static capabilities = ['getFeatures', 'getRefNames']\n\n private readonly bubbles\n // `gfatools bubble` names each row after the graph's stable sequence, so a\n // Minigraph-Cactus graph produces PanSN rows (`GRCh38#0#chr6`) where a plain\n // minigraph graph produces bare ones (`chr6`). Same resolution the segment\n // adapter does, through the same `assemblyNameToPanSN` slot.\n private readonly refNames\n\n public constructor(\n config: MinigraphBubbleAdapterConfig,\n getSubAdapter?: getSubAdapterType,\n pluginManager?: PluginManager,\n ) {\n super(config, getSubAdapter, pluginManager)\n this.bubbles = openTabixSlot(this, ['bubblesLocation'], ['index'])\n this.refNames = new PanSNRefNames(this.bubbles, this)\n }\n\n async getRefNames(opts: BaseOptions = {}) {\n return this.refNames.assemblyRefNames(opts)\n }\n\n public async hasDataForRefName() {\n return true\n }\n\n getFeatures(query: Region, opts: BaseOptions = {}) {\n const { signal, statusCallback } = opts\n return ObservableCreate<Feature>(async observer => {\n const tabixRefName = await this.refNames.resolve(query, opts)\n if (tabixRefName !== undefined) {\n await updateStatus('Downloading bubbles', statusCallback, () =>\n this.bubbles.getLines(tabixRefName, query.start, query.end, {\n signal,\n lineCallback: (line, fileOffset) => {\n const bubble = parseBubbleLine(line)\n observer.next(\n new SimpleFeature({\n uniqueId: `bubble-${fileOffset}`,\n refName: query.refName,\n start: bubble.start,\n end: bubble.end,\n // How variable this spot is, in two words, since that is the\n // whole point of the track.\n name: bubbleLabel(bubble),\n description: bubbleDescription(bubble),\n type: 'bubble',\n score: bubble.segmentCount,\n segmentCount: bubble.segmentCount,\n pathCount: bubble.pathCount,\n inversion: bubble.inversion,\n shortestAlleleLength: bubble.shortestAlleleLength,\n longestAlleleLength: bubble.longestAlleleLength,\n segments: bubble.segments,\n shortestAllele: bubble.shortestAllele,\n longestAllele: bubble.longestAllele,\n }),\n )\n },\n }),\n )\n }\n observer.complete()\n }, signal)\n }\n}\n"],
|
|
5
|
+
"mappings": "4RAAA,IAAAA,EAAuC,SACvCC,EAA4C,SAC5CC,EAAiC,SAgBjC,IAAqBC,EAArB,cAAoD,wBAAqD,CACvG,YAAc,aAAe,CAAC,cAAe,aAAa,EASnD,YACLC,EACAC,EACAC,EACA,CACA,MAAMF,EAAQC,EAAeC,CAAa,EAC1C,KAAK,QAAUC,EAAc,KAAM,CAAC,iBAAiB,EAAG,CAAC,OAAO,CAAC,EACjE,KAAK,SAAW,IAAIC,EAAc,KAAK,QAAS,IAAI,CACtD,CAEA,MAAM,YAAYC,EAAoB,CAAC,EAAG,CACxC,OAAO,KAAK,SAAS,iBAAiBA,CAAI,CAC5C,CAEA,MAAa,mBAAoB,CAC/B,MAAO,EACT,CAEA,YAAYC,EAAeD,EAAoB,CAAC,EAAG,CACjD,GAAM,CAAE,OAAAE,EAAQ,eAAAC,CAAe,EAAIH,EACnC,SAAO,oBAA0B,MAAMI,GAAY,CACjD,IAAMC,EAAe,MAAM,KAAK,SAAS,QAAQJ,EAAOD,CAAI,EACxDK,IAAiB,QACnB,QAAM,gBAAa,sBAAuBF,EAAgB,IACxD,KAAK,QAAQ,SAASE,EAAcJ,EAAM,MAAOA,EAAM,IAAK,CAC1D,OAAAC,EACA,aAAc,CAACI,EAAMC,IAAe,CAClC,IAAMC,EAASC,EAAgBH,CAAI,EACnCF,EAAS,KACP,IAAI,gBAAc,CAChB,SAAU,UAAUG,CAAU,GAC9B,QAASN,EAAM,QACf,MAAOO,EAAO,MACd,IAAKA,EAAO,IAGZ,KAAME,EAAYF,CAAM,EACxB,YAAaG,EAAkBH,CAAM,EACrC,KAAM,SACN,MAAOA,EAAO,aACd,aAAcA,EAAO,aACrB,UAAWA,EAAO,UAClB,UAAWA,EAAO,UAClB,qBAAsBA,EAAO,qBAC7B,oBAAqBA,EAAO,oBAC5B,SAAUA,EAAO,SACjB,eAAgBA,EAAO,eACvB,cAAeA,EAAO,aACxB,CAAC,CACH,CACF,CACF,CAAC,CACH,EAEFJ,EAAS,SAAS,CACpB,EAAGF,CAAM,CACX,CACF",
|
|
6
|
+
"names": ["import_BaseAdapter", "import_util", "import_rxjs", "MinigraphBubbleAdapter", "config", "getSubAdapter", "pluginManager", "openTabixSlot", "PanSNRefNames", "opts", "query", "signal", "statusCallback", "observer", "tabixRefName", "line", "fileOffset", "bubble", "parseBubbleLine", "bubbleLabel", "bubbleDescription"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{a as h,b as y}from"./chunk-HOM2Y6XS.js";import{a as O,b as P}from"./chunk-TN6FK5UD.js";import"./chunk-KWAXLUPQ.js";import{a as B}from"./chunk-J4OLMLS5.js";import"./chunk-F4C3BEPV.js";import{b as S}from"./chunk-FY3BTKY4.js";var C=S(O(),1),l=S(B(),1),M=S(P(),1);function b(t){let e=t.split(" ");return{refName:e[0],start:+e[1],end:+e[2],id:e[3],rank:+e[4],tags:e[5]??""}}function $(t){let e=t.tags.split(" ").find(a=>a.startsWith("SM:Z:"));if(e===void 0)return;let n=e.slice(5).split(",").map(a=>a.trim()).filter(Boolean);return n.length>0?n:void 0}function L(t){return{id:t.slice(0,-1),strand:t.slice(-1)}}function A(t){let e=t.split(" "),n=L(e[3]),a=L(e[4]);return{source:n.id,sourceStrand:n.strand,target:a.id,targetStrand:a.strand,sourceSegment:{id:n.id,refName:e[5],start:+e[6],end:+e[7],rank:+e[8],tags:e[13]??""},targetSegment:{id:a.id,refName:e[9],start:+e[10],end:+e[11],rank:+e[12],tags:e[14]??""}}}function I(t){return`${t.source}${t.sourceStrand}${t.target}${t.targetStrand}`}var j=/^[A-Za-z][A-Za-z0-9]:[AifZJHB]:/;function G(t){let{id:e,refName:n,start:a,end:r,rank:s,tags:m}=t,o=m.split(" ").filter(g=>j.test(g)),i=o.length===0?"":` ${o.join(" ")}`;return`S ${e} * LN:i:${r-a} SN:Z:${n} SO:i:${a} SR:i:${s}${i}`}function Z(t){let{source:e,sourceStrand:n,target:a,targetStrand:r}=t;return`L ${e} ${n} ${a} ${r} 0M`}function w(t,e){return t<e?-1:t>e?1:0}function T(t,e){let n=[...t.values()].sort((r,s)=>r.refName===s.refName?r.start-s.start:w(r.refName,s.refName)),a=[...e.keys()].sort((r,s)=>w(r,s));return["H VN:Z:1.0",...n.map(r=>G(r)),...a.map(r=>Z(e.get(r)))].join(`
|
|
2
|
+
`)}function F(t){return t.filter(e=>e.rank>0)}var N=class extends C.BaseFeatureDataAdapter{static{this.capabilities=["getFeatures","getRefNames"]}constructor(e,n,a){super(e,n,a),this.fine=this.openIndex([])}openIndex(e){let n=h(this,[...e,"segmentsLocation"],[...e,"segmentsIndex"]);return{segments:n,links:h(this,[...e,"linksLocation"],[...e,"linksIndex"]),refNames:new y(n,this)}}index(e="fine"){return e==="fine"?this.fine:(this.coarse??=this.openIndex(["coarse"]),this.coarse)}async getRefNames(e={}){return this.fine.refNames.assemblyRefNames(e)}async hasDataForRefName(){return!0}getFeatures(e,n={}){let{signal:a,statusCallback:r}=n;return(0,M.ObservableCreate)(async s=>{let m=await this.fine.refNames.resolve(e,n);m!==void 0&&await(0,l.updateStatus)("Downloading segments",r,()=>this.fine.segments.getLines(m,e.start,e.end,{signal:a,lineCallback:o=>{let i=b(o),g=$(i);s.next(new l.SimpleFeature({uniqueId:i.id,refName:e.refName,start:i.start,end:i.end,name:i.id,type:"segment",rank:i.rank,stableName:i.refName,...g&&{samples:g,carriers:g.length}}))}})),s.complete()},a)}async getSubgraph(e,n={}){let{hops:a=0,signal:r,tier:s}=n,m=this.index(s),o=new Map,i=new Map,g=await m.refNames.resolve(e,{signal:r}),x=async(f,p,c)=>{let k=[];return await m.links.getLines(f,p,c,{signal:r,lineCallback:v=>{let d=A(v);i.set(I(d),d);for(let u of[d.sourceSegment,d.targetSegment])o.has(u.id)||(o.set(u.id,u),k.push(u))}}),k};if(g===void 0)throw new Error(`${e.assemblyName} ${e.refName} is not in this graph's index; a graph with PanSN names (GRCh38#0#chr1) needs ${e.assemblyName} mapped to its prefix in assemblyNameToPanSN`);await m.segments.getLines(g,e.start,e.end,{signal:r,lineCallback:f=>{let p=b(f);o.set(p.id,p)}});let R=F(await x(g,e.start,e.end));for(let f=0;f<a;f++){let p=await Promise.all(R.map(c=>x(c.refName,c.start,c.end)));R=F(p.flat())}return T(o,i)}};export{N as default};
|
|
3
|
+
//# sourceMappingURL=RgfaTabixAdapter-7ZGKJJYW.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/RgfaTabixAdapter/RgfaTabixAdapter.ts", "../../src/RgfaTabixAdapter/rgfaBed.ts"],
|
|
4
|
+
"sourcesContent": ["import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter'\nimport { SimpleFeature, updateStatus } from '@jbrowse/core/util'\nimport { ObservableCreate } from '@jbrowse/core/util/rxjs'\n\nimport { PanSNRefNames, openTabixSlot } from '../panSNTabix.ts'\nimport {\n formatSubgraph,\n linkKey,\n parseLinkLine,\n parseSegmentLine,\n segmentSamples,\n} from './rgfaBed.ts'\n\nimport type { RgfaTabixAdapterConfig } from './configSchema.ts'\nimport type { SubgraphAdapterOptions, SubgraphTier } from '../GetSubgraph.ts'\nimport type { RgfaLink, RgfaSegment } from './rgfaBed.ts'\nimport type { TabixIndexedFile } from '@gmod/tabix'\nimport type PluginManager from '@jbrowse/core/PluginManager'\nimport type { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter'\nimport type { getSubAdapterType } from '@jbrowse/core/data_adapters/dataAdapterCache'\nimport type { Feature } from '@jbrowse/core/util'\nimport type { Region } from '@jbrowse/core/util/types'\n\n// What a hop follows: alleles, never the backbone. A rank-0 segment reached\n// through a link is flanking backbone, usually outside the window, so querying\n// its links walks the reference away from the region, brings back more backbone,\n// and closes nothing. Every segment that closes a bubble is an allele interior,\n// and an allele interior is rank > 0 in both index formats (rGFA's SR tag, and\n// pggb's rank 0-or-1 against the anchor path). Reached backbone still becomes a\n// node and its edge still draws; it is only not walked through.\n//\n// This is gfabase's rule, arrived at from the other end. `gfabase sub` expands\n// from a seed either to the whole connected component (`--connected`, which its\n// own README calls overkill) or with `--cutpoints 1`, which takes the biconnected\n// component by *stopping at cutpoints*, the segments every end-to-end walk of\n// the chromosome must traverse. In a reference-anchored pangenome the cutpoints\n// are the backbone, and rank is what the index already states about it, so\n// `rank > 0` is that stopping rule without a connectivity index to build. The\n// third tool is the same shape again: `gfatools view -R` maps the region onto its\n// precomputed bubble decomposition and returns whole overlapping bubbles\n// (gfa_query_by_reg), which is complete for the same reason. Bandage's own\n// `--distance` is a node-step radius, but Bandage holds the entire graph in\n// memory, so its scope is a drawing filter rather than a fetch strategy.\n//\n// Measured with this rule: the E. coli paa window converges at one hop (17\n// segments at 1 and at 2), so the cut closes and stays closed. HPRC's amylase\n// window keeps growing (63 at 0, 78 at 1, 92 at 2) because its alleles have\n// alleles, and wall-clock is flat across all three, since a hop's queries go out\n// together and the remote index dominates.\n//\n// The exact version, when a graph ships a bubble index beside its segments:\n// gfatools' bubble rows carry the member segment ids of every bubble, so the\n// bubbles overlapping the region state which segments a complete cut must\n// contain. That turns the hop count into a termination condition rather than a\n// setting, and MinigraphBubbleAdapter already parses those rows.\nfunction offReference(segments: RgfaSegment[]) {\n return segments.filter(segment => segment.rank > 0)\n}\n\ninterface GraphIndex {\n segments: TabixIndexedFile\n links: TabixIndexedFile\n refNames: PanSNRefNames\n}\n\nexport default class RgfaTabixAdapter extends BaseFeatureDataAdapter<RgfaTabixAdapterConfig> {\n public static capabilities = ['getFeatures', 'getRefNames']\n\n private readonly fine\n private coarse: GraphIndex | undefined\n\n public constructor(\n config: RgfaTabixAdapterConfig,\n getSubAdapter?: getSubAdapterType,\n pluginManager?: PluginManager,\n ) {\n super(config, getSubAdapter, pluginManager)\n this.fine = this.openIndex([])\n }\n\n // refNames off the SEGMENT index: it is the one that names every stable\n // sequence the graph is anchored to, where the link index only names those a\n // link touches.\n private openIndex(under: string[]): GraphIndex {\n const segments = openTabixSlot(\n this,\n [...under, 'segmentsLocation'],\n [...under, 'segmentsIndex'],\n )\n return {\n segments,\n links: openTabixSlot(\n this,\n [...under, 'linksLocation'],\n [...under, 'linksIndex'],\n ),\n refNames: new PanSNRefNames(segments, this),\n }\n }\n\n private index(tier: SubgraphTier = 'fine') {\n if (tier === 'fine') {\n return this.fine\n }\n this.coarse ??= this.openIndex(['coarse'])\n return this.coarse\n }\n\n async getRefNames(opts: BaseOptions = {}) {\n return this.fine.refNames.assemblyRefNames(opts)\n }\n\n public async hasDataForRefName() {\n return true\n }\n\n getFeatures(query: Region, opts: BaseOptions = {}) {\n const { signal, statusCallback } = opts\n return ObservableCreate<Feature>(async observer => {\n const tabixRefName = await this.fine.refNames.resolve(query, opts)\n if (tabixRefName !== undefined) {\n await updateStatus('Downloading segments', statusCallback, () =>\n this.fine.segments.getLines(tabixRefName, query.start, query.end, {\n signal,\n lineCallback: line => {\n const segment = parseSegmentLine(line)\n // `samples` is who, `carriers` is how many, and the second is not\n // just a convenience: a lane colored by carriage is a jexl\n // expression in a config, where counting a list means relying on\n // jexl resolving `.length` through a member access on an array.\n // The count is the axis the color reads, so the index states it.\n const samples = segmentSamples(segment)\n observer.next(\n new SimpleFeature({\n uniqueId: segment.id,\n refName: query.refName,\n start: segment.start,\n end: segment.end,\n name: segment.id,\n type: 'segment',\n rank: segment.rank,\n stableName: segment.refName,\n ...(samples && { samples, carriers: samples.length }),\n }),\n )\n },\n }),\n )\n }\n observer.complete()\n }, signal)\n }\n\n // Extract the graph around a region as GFA text, for GraphGenomeView. The\n // region's own segments come from segs.bed.gz; links.bed.gz supplies the edges\n // incident to them *and* the coordinates of the segments on the other end,\n // which typically sit on a different stable sequence (a rank>0 bubble) and so\n // are not reachable by any coordinate query on this region.\n //\n // `hops` is extra rounds of link-following past the region's own segments\n // and their immediate neighbours, each costing one tabix query per\n // off-reference segment newly reached. One round is what closes a bubble, so\n // it is the default the view asks for; see the frontier below. `signal` goes\n // to every one of those queries, so a cut the view has replaced stops.\n // `tier: 'coarse'` reads the `coarse` pair instead, the same way.\n async getSubgraph(region: Region, opts: SubgraphAdapterOptions = {}) {\n const { hops = 0, signal, tier } = opts\n const index = this.index(tier)\n const segments = new Map<string, RgfaSegment>()\n const links = new Map<string, RgfaLink>()\n const tabixRefName = await index.refNames.resolve(region, { signal })\n\n const addLinksOver = async (\n refName: string,\n start: number,\n end: number,\n ) => {\n const reached: RgfaSegment[] = []\n await index.links.getLines(refName, start, end, {\n signal,\n lineCallback: line => {\n const link = parseLinkLine(line)\n links.set(linkKey(link), link)\n for (const segment of [link.sourceSegment, link.targetSegment]) {\n if (!segments.has(segment.id)) {\n segments.set(segment.id, segment)\n reached.push(segment)\n }\n }\n },\n })\n return reached\n }\n\n if (tabixRefName === undefined) {\n throw new Error(\n `${region.assemblyName} ${region.refName} is not in this graph's index; a graph with PanSN names (GRCh38#0#chr1) needs ${region.assemblyName} mapped to its prefix in assemblyNameToPanSN`,\n )\n }\n await index.segments.getLines(tabixRefName, region.start, region.end, {\n signal,\n lineCallback: line => {\n const segment = parseSegmentLine(line)\n segments.set(segment.id, segment)\n },\n })\n let frontier = offReference(\n await addLinksOver(tabixRefName, region.start, region.end),\n )\n for (let hop = 0; hop < hops; hop++) {\n // One hop's queries are independent of each other, so they go out\n // together rather than one round-trip at a time. Their callbacks share\n // the segment and link maps, which is safe because only one of them runs\n // at a time, and the output is sorted at the end regardless of the order\n // they arrive in.\n const reached = await Promise.all(\n frontier.map(segment =>\n addLinksOver(segment.refName, segment.start, segment.end),\n ),\n )\n frontier = offReference(reached.flat())\n }\n\n return formatSubgraph(segments, links)\n }\n}\n", "// A segment as it appears in segs.bed.gz, and as it is repeated inside every\n// links.bed.gz row: `stableName start end segmentId rank [tags]`. The first\n// five are the SN/SO/SR tags rGFA already carries, projected to BED by\n// `gfatools gfa2bed -m`.\n//\n// `tags` is a space-separated list of GFA tags, written verbatim onto the\n// S-line formatSegment synthesizes, where the GFA parser reads them into\n// `GraphNode.tags` with no work here. It is the extension point for everything\n// the five columns cannot say: carriage on a path-derived graph (`SM:Z:`), the\n// collapse summary on a level-of-detail tier (`ct:Z:`, `cn:i:`, ...), a\n// precomputed layout position later. rGFA files have no sixth column at all,\n// so this is empty for them and nothing changes.\nexport interface RgfaSegment {\n refName: string\n start: number\n end: number\n id: string\n rank: number\n tags: string\n}\n\nexport interface RgfaLink {\n source: string\n sourceStrand: string\n target: string\n targetStrand: string\n sourceSegment: RgfaSegment\n targetSegment: RgfaSegment\n}\n\nexport function parseSegmentLine(line: string): RgfaSegment {\n const cols = line.split('\\t')\n return {\n refName: cols[0]!,\n start: +cols[1]!,\n end: +cols[2]!,\n id: cols[3]!,\n rank: +cols[4]!,\n tags: cols[5] ?? '',\n }\n}\n\n// Carriage as an ordinary feature attribute, for the linear track rather than\n// the graph. The tag column reaches the graph view through the synthesized\n// S-line (formatSegment below, then gfaConverter reads SM into\n// `GraphNode.samples`), and that route ends at the graph: `getFeatures` builds\n// its own features and had no way to say who carries a segment, so a lane\n// colored by carriage was not expressible.\n//\n// `SM:Z:` is its own grammar check here. build_pggb_tabix.sh wrote a bare\n// comma-separated list in this column before the tag column existed, and those\n// files are still hosted; a bare list has no prefix to match, so it is dropped\n// rather than read as one sample named `K12,Sakai,CFT073`.\n//\n// Undefined rather than [] when the tag is absent, matching gfaConverter: an\n// rGFA has no sixth column at all, so a segment that says nothing about\n// carriage stays distinguishable from one carried by nobody.\nexport function segmentSamples(segment: RgfaSegment) {\n const tag = segment.tags.split(' ').find(t => t.startsWith('SM:Z:'))\n if (tag === undefined) {\n return undefined\n }\n const samples = tag\n .slice('SM:Z:'.length)\n .split(',')\n .map(s => s.trim())\n .filter(Boolean)\n return samples.length > 0 ? samples : undefined\n}\n\n// `s322+` \u2014 the L-line's segment id with its orientation appended, mirroring\n// the GFA record it came from.\nfunction parseEndpoint(field: string) {\n return { id: field.slice(0, -1), strand: field.slice(-1) }\n}\n\nexport function parseLinkLine(line: string): RgfaLink {\n const cols = line.split('\\t')\n const source = parseEndpoint(cols[3]!)\n const target = parseEndpoint(cols[4]!)\n return {\n source: source.id,\n sourceStrand: source.strand,\n target: target.id,\n targetStrand: target.strand,\n sourceSegment: {\n id: source.id,\n refName: cols[5]!,\n start: +cols[6]!,\n end: +cols[7]!,\n rank: +cols[8]!,\n tags: cols[13] ?? '',\n },\n targetSegment: {\n id: target.id,\n refName: cols[9]!,\n start: +cols[10]!,\n end: +cols[11]!,\n rank: +cols[12]!,\n tags: cols[14] ?? '',\n },\n }\n}\n\nexport function linkKey(link: RgfaLink) {\n return `${link.source}${link.sourceStrand}${link.target}${link.targetStrand}`\n}\n\n// Both endpoints of a link are written into every row, so the same link is\n// indexed under each endpoint's stable sequence and arrives twice for a region\n// covering both. Callers dedupe on linkKey.\n\n// Segments carry no sequence here \u2014 the BED records only their span \u2014 so every\n// S-line is written with `*` and an LN tag, which is what the GFA spec asks for\n// and what packages/graph-core's parser reads back as the node length.\n// `NM:i:0`, `SM:Z:HG002.1,HG002.2` \u2014 the GFA tag grammar, checked rather than\n// trusted. Files built before the tag column existed put a bare comma-separated\n// sample list here, and passing that through would put a field that is not a\n// tag on an S-line, which is a malformed GFA rather than a missing annotation.\n// Dropping it degrades to the pre-tag behaviour instead.\nconst GFA_TAG = /^[A-Za-z][A-Za-z0-9]:[AifZJHB]:/\n\nfunction formatSegment(segment: RgfaSegment) {\n const { id, refName, start, end, rank, tags } = segment\n const valid = tags.split(' ').filter(t => GFA_TAG.test(t))\n const extra = valid.length === 0 ? '' : `\\t${valid.join('\\t')}`\n return `S\\t${id}\\t*\\tLN:i:${end - start}\\tSN:Z:${refName}\\tSO:i:${start}\\tSR:i:${rank}${extra}`\n}\n\nfunction formatLink(link: RgfaLink) {\n const { source, sourceStrand, target, targetStrand } = link\n return `L\\t${source}\\t${sourceStrand}\\t${target}\\t${targetStrand}\\t0M`\n}\n\n// Codepoint order, not localeCompare: the byte-identical-output guarantee below\n// has to hold across locales.\nfunction compare(a: string, b: string) {\n return a < b ? -1 : a > b ? 1 : 0\n}\n\n// Deterministic ordering: the same region always produces byte-identical GFA,\n// so a layout computed from it is reproducible.\nexport function formatSubgraph(\n segments: Map<string, RgfaSegment>,\n links: Map<string, RgfaLink>,\n) {\n const sortedSegments = [...segments.values()].sort((a, b) =>\n a.refName === b.refName ? a.start - b.start : compare(a.refName, b.refName),\n )\n const sortedLinks = [...links.keys()].sort((a, b) => compare(a, b))\n return [\n 'H\\tVN:Z:1.0',\n ...sortedSegments.map(s => formatSegment(s)),\n ...sortedLinks.map(k => formatLink(links.get(k)!)),\n ].join('\\n')\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["import_BaseAdapter", "import_util", "import_rxjs", "parseSegmentLine", "line", "cols", "segmentSamples", "segment", "tag", "t", "samples", "s", "parseEndpoint", "field", "parseLinkLine", "source", "target", "linkKey", "link", "GFA_TAG", "formatSegment", "id", "refName", "start", "end", "rank", "tags", "valid", "extra", "formatLink", "sourceStrand", "targetStrand", "compare", "a", "b", "formatSubgraph", "segments", "links", "sortedSegments", "sortedLinks", "k", "offReference", "segments", "segment", "RgfaTabixAdapter", "config", "getSubAdapter", "pluginManager", "under", "openTabixSlot", "PanSNRefNames", "tier", "opts", "query", "signal", "statusCallback", "observer", "tabixRefName", "line", "parseSegmentLine", "samples", "segmentSamples", "region", "hops", "index", "links", "addLinksOver", "refName", "start", "end", "reached", "link", "parseLinkLine", "linkKey", "frontier", "hop", "formatSubgraph"]
|
|
7
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as Te}from"./chunk-XEJ47DLD.js";import{c as Je}from"./chunk-ZNGDWZ6Z.js";import{a as oe,b as je,c as qe}from"./chunk-F4C3BEPV.js";import{a as we,b as re}from"./chunk-FY3BTKY4.js";var Qe=we((zr,Ze)=>{Ze.exports=JBrowseExports["@mui/material/SvgIcon"]});var Be=we((Xr,et)=>{et.exports=JBrowseExports["@jbrowse/core/util/colorBits"]});var cr=we((Zo,Gt)=>{Gt.exports=JBrowseExports["tss-react/mui"]});var dr=we((Qo,_t)=>{_t.exports=JBrowseExports["@jbrowse/render-core/canvas2dUtils"]});var Q=re(Qe(),1);var G=re(Be(),1);var L=re(Be(),1);function fe(e,t){return(0,L.packAbgr)((0,L.abgrRed)(e),(0,L.abgrGreen)(e),(0,L.abgrBlue)(e),Math.round((0,L.abgrAlpha)(e)*t))}function Ur(e,t){return(0,L.packAbgr)(Math.min(255,Math.round((0,L.abgrRed)(e)*t)),Math.min(255,Math.round((0,L.abgrGreen)(e)*t)),Math.min(255,Math.round((0,L.abgrBlue)(e)*t)),(0,L.abgrAlpha)(e))}var jt=[{value:"depth",label:"By depth",description:"Thicker the more paths carry a node, on the square root of its depth against the mean. A graph with one depth everywhere draws uniform."},{value:"uniform",label:"Uniform",description:"Every node the same thickness."}],Kr=jt.map(e=>e.value),qt=.3,tt=3;function nt(e){let t=0,n=0;for(let r of e.nodes)t+=r.depth*r.length,n+=r.length;return n>0?t/n:0}function Jt(e,t){return!(t>0)||!(e.depth>0)?1:Math.min(tt,Math.max(qt,Math.sqrt(e.depth/t)))}function rt(e,t,n,r){return t*(n==="depth"?Jt(e,r):1)}function Vr(e,t){return e*(t==="depth"?tt:1)}function me(e){return e.stable!==void 0}function S(e){return e.stable?.rank===0}function Se(e){return e.stable!==void 0&&e.stable.rank>0}function X(e){return e.nodes.filter(S)}function U(e){let t={};for(let n of e)t[n.id]=[{x:n.stable.start,y:0},{x:n.stable.start+n.length,y:0}];return t}function ot(e,t){let n=0,r=e.length;for(;n<r;){let o=n+r>>1;e[o].stable.start<t?n=o+1:r=o}return n}function Zt(e){let t=1/0,n=-1/0;for(let r of e)t=Math.min(t,r.stable.start),n=Math.max(n,r.stable.start+r.length);return n-t}function Le(e,t){return t&&t.end>t.start?t.end-t.start:Zt(e)}var Qt=/:(\d+)-\d+$/;function se(e){let t=Qt.exec(e);return t?{name:e.slice(0,t.index),start:+t[1]}:{name:e,start:0}}function Qr(e,t){let n=[],r=new Map;for(let o of e){let s=oe(o.name),a=o.start;for(let i of o.steps){let c={path:o.name,sample:s,start:a,strand:i.strand},l=r.get(i.id);l?l.push(c):r.set(i.id,[c]),a+=t(i.id)}n.push({name:o.name,sample:s,start:o.start,length:a-o.start})}return{anchorPaths:n,pathVisits:r}}function en(e,t){return e.find(r=>r.sample===t||r.name===t)??e[0]}var tn=1;function nn(e,t,n){let r=e;if(t&&t.length>0){let o=t.find(s=>s.path===n)??t[0];r={...e,stable:{refName:o.path,start:o.start,rank:o.path===n?0:tn,strand:o.strand},samples:[...new Set(t.map(s=>s.sample))].sort()}}return r}function rn(e,t){let{anchorPaths:n,pathVisits:r}=e,o=n&&r?en(n,t):void 0;return o&&r?{...e,nodes:e.nodes.map(s=>nn(s,r.get(s.name),o.name)),anchoredBy:"paths",referencePath:o.name}:e}function eo(e,t){return e.anchoredBy==="tags"?e:rn(e,t)}function st(e){let t=0;for(let n=0;n<e.length;n++)t=e.charCodeAt(n)+((t<<5)-t);return Math.abs(t%360)}function Pe(e,t){return e*360/t}var Ee=.7,Ge=.5,on=16;function ro(e){return e>0&&e<=on}function sn(e,t){return`hsl(${Pe(e,t)}, ${Ee*100}%, ${Ge*100}%)`}function an(e){let t=se(e).name.split("#");return[t[0],t.slice(0,2).join("#"),t.join("#")]}function cn(e){return String(e).replace(/\B(?=(\d{3})+$)/g,",")}function dn(e,t){let{start:n}=se(e);return t.map(r=>`${r} @${cn(n)}`)}function oo(e){let t=e.map(s=>an(s.name)),n=[0,1,2].flatMap(s=>[e.map((a,i)=>t[i][s]),e.map((a,i)=>dn(a.name,t[i])[s])]),o=n.find(s=>new Set(s).size===e.length)??n.at(-1);return e.map((s,a)=>({name:s.name,label:o[a],color:sn(a,e.length)}))}var un=4;function he(e){let t=new Map;function n(r,o){let s=t.get(r);s?s.push(o):t.set(r,[o])}for(let r of e.edges)n(r.from,r.to),n(r.to,r.from);return t}function ln({nodeId:e,nodeById:t,neighbors:n}){let r=new Set([e]),o=[e],s=1/0,a=-1/0;for(let i=0;i<un&&o.length>0;i++){let c=[];for(let l of o){let p=n.get(l);if(p){for(let d of p)if(!r.has(d)){r.add(d);let u=t.get(d);u&&S(u)?(s=Math.min(s,u.stable.start+u.length),a=Math.max(a,u.stable.start)):c.push(d)}}}o=c}return s===1/0?void 0:{start:Math.min(s,a),end:Math.max(s,a)}}function pn({nodeId:e,nodeById:t,neighbors:n}){let r=t.get(e);return r===void 0?void 0:S(r)?{start:r.stable.start,end:r.stable.start+r.length}:ln({nodeId:e,nodeById:t,neighbors:n})}function at(e){let t=new Map(e.nodes.map(o=>[o.id,o])),n=he(e),r=new Map;for(let o of e.nodes){let s=pn({nodeId:o.id,nodeById:t,neighbors:n});s&&r.set(o.id,(s.start+s.end)/2)}return r}function lo(e){let t=n=>Math.round(n*100)/100;return e.map((n,r)=>`${r?"L":"M"}${t(n.x)},${t(n.y)}`).join("")}function it(e,t,n,r,o){let s=Math.hypot(r-t,n-e);if(s===0)return[n,r];let a=(n-e)/s,i=(r-t)/s;return[n+o*a,r+o*i]}function $e(e,t){let n=1-t,r=n*n*n,o=3*n*n*t,s=3*n*t*t,a=t*t*t;return{x:r*e.x0+o*e.cx0+s*e.cx1+a*e.x1,y:r*e.y0+o*e.cy0+s*e.cy1+a*e.y1}}function po(e){let t=e[Math.floor(e.length/2)];return t?$e(t,.5):void 0}function fo(e){let t=1/0,n=1/0,r=-1/0,o=-1/0;for(let s of e)t=Math.min(t,s.x0,s.cx0,s.cx1,s.x1),r=Math.max(r,s.x0,s.cx0,s.cx1,s.x1),n=Math.min(n,s.y0,s.cy0,s.cy1,s.y1),o=Math.max(o,s.y0,s.cy0,s.cy1,s.y1);return{minX:t,minY:n,maxX:r,maxY:o}}function fn(e,t,n){let r=$e(e,t),o=$e(e,n),s=(n-t)/3,a=ct(e,t),i=ct(e,n);return{x0:r.x,y0:r.y,cx0:r.x+a.x*s,cy0:r.y+a.y*s,cx1:o.x-i.x*s,cy1:o.y-i.y*s,x1:o.x,y1:o.y}}function ct(e,t){let n=1-t,r=3*n*n,o=6*n*t,s=3*t*t;return{x:r*(e.cx0-e.x0)+o*(e.cx1-e.cx0)+s*(e.x1-e.cx1),y:r*(e.cy0-e.y0)+o*(e.cy1-e.cy0)+s*(e.y1-e.cy1)}}function ft(e,t){let n=[];for(let r of e){let o=Math.hypot(r.cx0-r.x0,r.cy0-r.y0)+Math.hypot(r.cx1-r.cx0,r.cy1-r.cy0)+Math.hypot(r.x1-r.cx1,r.y1-r.cy1),s=Math.max(3,Math.round(o/t)|1);for(let a=0;a<s;a+=2)n.push([fn(r,a/s,(a+1)/s)])}return n}function mt(e,t,n){let r=new Array(e.length);for(let o=0;o<e.length;o++){let s=e[o];r[o]={x0:s.x0+t,y0:s.y0+n,cx0:s.cx0+t,cy0:s.cy0+n,cx1:s.cx1+t,cy1:s.cy1+n,x1:s.x1+t,y1:s.y1+n}}return r}function dt(e,t){let n=e.length-1;return t==="end"?{at:e[n],inward:e[n-1]}:{at:e[0],inward:e[1]}}var mn=.5,hn=80;function ut(e){let t=1/0,n=-1/0;for(let r of e)t=Math.min(t,r.x),n=Math.max(n,r.x);return{min:t,max:n}}function lt(e,t){return Math.max(0,t.min-e,e-t.max)}function pt(e,t,n){let r=lt(e[0].x,t),o=lt(e[e.length-1].x,t);return r===o?n:r<o?"start":"end"}function bn(e,t){return{from:pt(e,ut(t),"end"),to:pt(t,ut(e),"start")}}var gn=.75,yn=1.15,xn=.35,Nn=60;function Mn(e,t,n,r,o,s){let a=Math.hypot(n-e,r-t),i=a===0?1:(n-e)/a,c=a===0?0:(r-t)/a,l=0,p=1/0,d=-1/0;for(let h of o){let g=h.x-e,b=h.y-t,y=g*-c+b*i;Math.abs(y)>Math.abs(l)&&(l=y);let R=g*i+b*c;p=Math.min(p,R),d=Math.max(d,R)}let u=o.length?d-p:0,m=Math.max(Math.abs(l)*yn/gn,u*xn),f=s===void 0?m:Math.min(m,s);return l<0?-f:f}function _e({scaleX:e,scaleY:t}){return t/e}var Rn=3;function De(e,t,n){let r=t.x-e.x,o=(t.y-e.y)*n,s=Math.hypot(r,o);return s===0?void 0:{x:r/s,y:o/s}}function ht(e,t,n,r,o=Rn){let s=_e(r),a=De(e[e.length-1],t[0],s)??De(e[0],e.at(-1),s)??De(t[0],t.at(-1),s)??{x:1,y:0},i=[];for(let c=0;c<n;c++){let l=(c-(n-1)/2)*o;i.push({x:-a.y*l,y:a.x*l/s})}return i}function He(e,t){return e.map(n=>({x:n.x,y:n.y*t}))}function wn(e,t){for(let n of e)n.y0/=t,n.cy0/=t,n.cy1/=t,n.y1/=t;return e}function be(e,t,n,r,o,s,a=[],i){let c=s.scaleX,l=_e(s),p=i??(s.pixelRows?Nn:void 0);if(l!==1)return wn(be(He(e,l),He(t,l),n,r,o*l,{scaleX:c,scaleY:c},He(a,l),p===void 0?void 0:p*l),l);let d=n?{from:"end",to:"start"}:bn(e,t),u=dt(e,d.from),m=dt(t,d.to),f=u.at,h=m.at,g=f.x+r,b=f.y+o,y=h.x+r,R=h.y+o;if(n){let w=1,N=0;if(u.inward){let q=f.x-u.inward.x,J=f.y-u.inward.y,P=Math.hypot(q,J);P>0&&(w=q/P,N=J/P)}let M=Math.min(50,50*c),A=-N,O=w,v=(f.x+h.x)/2+r+A*M,V=(f.y+h.y)/2+o+O*M,te=g+w*M,j=b+N*M,B=y-w*M,C=R-N*M;return[{x0:g,y0:b,cx0:te,cy0:j,cx1:te+A*M,cy1:j+O*M,x1:v,y1:V},{x0:v,y0:V,cx0:B+A*M,cy0:C+O*M,cx1:B,cy1:C,x1:y,y1:R}]}else{let w=u.inward??{x:f.x-(h.x-f.x),y:f.y-(h.y-f.y)},N=m.inward??{x:h.x-(f.x-h.x),y:h.y-(f.y-h.y)},M=Math.hypot(y-g,R-b),A=(D,k,H,ie)=>{let $=k.x-D.x,W=k.y-D.y,z=Math.hypot($,W),Z=z===0?0:(H*$+ie*W)/z;return Math.max(0,Math.min(M*mn,hn,Z*.5))},O=h.x-f.x,v=h.y-f.y,[V,te]=it(w.x,w.y,f.x,f.y,A(w,f,O,v)),[j,B]=it(N.x,N.y,h.x,h.y,A(N,h,-O,-v)),C=a.length?Mn(g,b,y,R,a,p):0,q=M===0?1:M,J=(y-g)/q,P=(R-b)/q,ge=-P*C,x=J*C,E=J*Math.abs(C),I=P*Math.abs(C);return[{x0:g,y0:b,cx0:V+r+ge-E,cy0:te+o+x-I,cx1:j+r+ge+E,cy1:B+o+x+I,x1:y,y1:R}]}}var Sn=1;function We(e,t){return t.flatMap(n=>e[n]??[])}function go(e,t,n){let r=e[t.from],o=e[t.to];return r?.length&&o?.length?be(r,o,t.from===t.to,0,0,n,We(e,t.bypassed)):void 0}function Ln(e){let t=new Map;for(let n of e.nodes)if(S(n)){let r=t.get(n.stable.refName);r?r.push(n):t.set(n.stable.refName,[n])}for(let n of t.values())n.sort((r,o)=>r.stable.start-o.stable.start);return t}function An(e,t,n){let r=[];if(e)for(let o=ot(e,t);o<e.length;o++){let s=e[o];if(s.stable.start>=n)break;s.stable.start+s.length<=n&&r.push(s.id)}return r}function En(e,t,n,r){let{fromStrand:o,toStrand:s}=e;if(o===void 0||s===void 0)return!0;let a=o===(t.stable.strand??"+"),i=s===(n.stable.strand??"+");return r?a&&i:!a&&!i}function yo(e){let t=new Map(e.nodes.map(o=>[o.id,o])),n=Ln(e),r=[];for(let o=0;o<e.edges.length;o++){let s=e.edges[o],a=t.get(s.from),i=t.get(s.to);if(a!==void 0&&i!==void 0&&S(a)&&S(i)&&a.stable.refName===i.stable.refName){let c=a.stable.start<=i.stable.start,[l,p]=c?[a,i]:[i,a],d=l.stable.start+l.length,u=p.stable.start,m=u-d;if(m>=Sn&&En(s,a,i,c)){let f=l.stable.refName;r.push({edgeIndex:o,from:s.from,to:s.to,refName:f,start:d,end:u,bp:m,bypassed:An(n.get(f),d,u)})}}}return r}var bt=new WeakMap;function gt(e,t,n,r,o){let{scaleX:s,scaleY:a}=n,i=bt.get(e);if(i?.graph===t&&i.scaleX===s&&i.scaleY===a&&i.deletions===r&&i.version===o)return i.curves;let c=new Map;for(let l=0;l<t.edges.length;l++){let p=t.edges[l],d=e[p.from],u=e[p.to];if(d?.length&&u?.length){let m=r?.get(l);c.set(l,be(d,u,p.from===p.to,0,0,n,m?We(e,m):[]))}}return bt.set(e,{graph:t,scaleX:s,scaleY:a,deletions:r,version:o,curves:c}),c}var Gn=(0,G.packAbgr)(119,119,119,217),yt=(0,G.packAbgr)(136,136,136,217),_n=(0,G.packAbgr)(24,24,28,240),vn=2.2,Cn=(0,G.packAbgr)(30,30,36,245),On=1.8,ve=.18,In=11,kn=1.2,Tn=1e-6,Bn=12,Pn=.45;function Dn(e,t=1){let n=t===1?e:e.map(o=>({x:o.x,y:o.y*t})),r=[];for(let o=0;o<n.length;o++){let s=0,a=0;if(o===0){let i=n[1].x-n[0].x,c=n[1].y-n[0].y,l=Math.hypot(i,c);l>0&&(s=-c/l,a=i/l)}else if(o===n.length-1){let i=n[o].x-n[o-1].x,c=n[o].y-n[o-1].y,l=Math.hypot(i,c);l>0&&(s=-c/l,a=i/l)}else{let i=n[o].x-n[o-1].x,c=n[o].y-n[o-1].y,l=Math.hypot(i,c),p=n[o+1].x-n[o].x,d=n[o+1].y-n[o].y,u=Math.hypot(p,d);if(l>0&&u>0){let m=-c/l,f=i/l,h=-d/u,g=p/u;s=(m+h)/2,a=(f+g)/2;let b=m*s+f*a;b>.1&&(s/=b,a/=b)}else l>0?(s=-c/l,a=i/l):u>0&&(s=-d/u,a=p/u)}r.push({nx:s,ny:a})}return r}function Hn(e,t,n,r=1){return e.map((o,s)=>({x:o.x+t[s].nx*n,y:o.y+t[s].ny*n/r}))}function Ce(e,t,n,r){return(0,G.packAbgr)(Math.round(e*255),Math.round(t*255),Math.round(n*255),Math.round(r*255))}function Oe(e,t,n){let r=(1-Math.abs(2*n-1))*t,o=r*(1-Math.abs(e/60%2-1)),s=n-r/2,a=0,i=0,c=0;return e<60?(a=r,i=o):e<120?(a=o,i=r):e<180?(i=r,c=o):e<240?(i=o,c=r):e<300?(a=o,c=r):(a=r,c=o),[a+s,i+s,c+s]}var $n=[[68,1,84],[59,82,139],[33,145,140],[94,201,98],[253,231,37]],Wn=[[237,137,44],[158,42,122]],zn=[[220,50,50],[50,120,220]];function ze(e,t){let n=Math.max(0,Math.min(1,t))*(e.length-1),r=Math.min(e.length-2,Math.floor(n)),o=n-r,s=e[r],a=e[r+1];return(0,G.packAbgr)(Math.round(s[0]+(a[0]-s[0])*o),Math.round(s[1]+(a[1]-s[1])*o),Math.round(s[2]+(a[2]-s[2])*o),255)}function Fn(e,t){let[n,r,o]=Oe(st(e),Ee,Ge);return Ce(n,r,o,t)}var Xn=300,Un=.7,Yn=.5,Kn=(0,G.packAbgr)(60,65,72,255);function _o(e,t){let n=at(e);if(t&&t.end>t.start)return{start:t.start,span:t.end-t.start,midpoints:n};let r=1/0,o=-1/0;for(let s of n.values())r=Math.min(r,s),o=Math.max(o,s);return{start:r===1/0?0:r,span:o>r?o-r:1,midpoints:n}}function Vn(e){let t=1/0,n=-1/0,r=1/0,o=-1/0,s=0;for(let a of e.nodes)a.stable!==void 0&&a.stable.rank>s&&(s=a.stable.rank),a.depth<t&&(t=a.depth),a.depth>n&&(n=a.depth),a.length<r&&(r=a.length),a.length>o&&(o=a.length);return{minDepth:t,maxDepth:n,minLength:r,maxLength:o,maxRank:s,nodeCount:e.nodes.length}}function jn(e,t,n,r){switch(n){case"random":return Fn(e.id,1);case"depth":return ze($n,r.maxDepth>r.minDepth?(e.depth-r.minDepth)/(r.maxDepth-r.minDepth):.5);case"node-length":return ze(zn,r.maxLength>r.minLength?(e.length-r.minLength)/(r.maxLength-r.minLength):.5);case"stable-rank":return e.stable===void 0?(0,G.packAbgr)(160,160,160,255):e.stable.rank===0?(0,G.packAbgr)(52,152,219,255):ze(Wn,r.maxRank>1?(e.stable.rank-1)/(r.maxRank-1):0);case"reference-position":{let o=r.referenceRamp,s=o?.midpoints.get(e.id);if(o===void 0||s===void 0)return(0,G.packAbgr)(160,160,160,255);if(e.stable!==void 0&&e.stable.rank>0)return Kn;let a=Math.max(0,Math.min(1,(s-o.start)/o.span)),[i,c,l]=Oe(a*Xn,Un,Yn);return Ce(i,c,l,1)}case"grey":return(0,G.packAbgr)(160,160,160,255);case"rainbow":{let o=r.nodeCount>1?t/r.nodeCount*360:0,[s,a,i]=Oe(o,.75,.5);return Ce(s,a,i,1)}default:return(0,G.packAbgr)(52,152,219,255)}}function qn(e,t=1){let n=e.x1-e.cx1,r=(e.y1-e.cy1)*t;return Math.hypot(n,r)>0?Math.atan2(r,n):Math.atan2((e.y1-e.y0)*t,e.x1-e.x0)}function Jn(e,t){let n=!1;for(let r=0;r<e.length-1&&!n;r++){let o=e[r],s=e[r+1];n=Math.max(o.x,s.x)>=t.minX&&Math.min(o.x,s.x)<=t.maxX&&Math.max(o.y,s.y)>=t.minY&&Math.min(o.y,s.y)<=t.maxY}return n}function Zn(e,t){for(let n of e){let r=Math.min(n.x0,n.cx0,n.cx1,n.x1),o=Math.max(n.x0,n.cx0,n.cx1,n.x1),s=Math.min(n.y0,n.cy0,n.cy1,n.y1),a=Math.max(n.y0,n.cy0,n.cy1,n.y1);if(o>=t.minX&&r<=t.maxX&&a>=t.minY&&s<=t.maxY)return!0}return!1}var xt=new WeakMap;function Qn(e){let t=xt.get(e);if(!t){let n=[],r=new Map,o=e.paths??[];for(let s=0;s<o.length;s++){let[a,i,c]=Oe(Pe(s,o.length),Ee,Ge);n.push(Ce(a,i,c,.85)),r.has(o[s].name)||r.set(o[s].name,s)}t={pathColorByIndex:n,pathIndexByName:r},xt.set(e,t)}return t}var Nt=new WeakMap,er=new Map;function tr(e){let t=Nt.get(e);if(!t){t=new Map;for(let[n,r]of(e.paths??[]).entries())for(let o of new Set(r.nodeIds)){let s=t.get(o);s?s.push(n):t.set(o,[n])}Nt.set(e,t)}return t}function vo(e){let{nodePositions:t,graph:n,nodeById:r,colorScheme:o,contigThickness:s,connectorThickness:a,drawPaths:i,nodeWidth:c="uniform",highlight:l,axis:p,linearLayout:d,viewportBounds:u,referenceRamp:m,deletions:f,hiddenEdges:h,version:g=0}=e,b=c==="depth"?nt(n):0,y=p.scaleX,R=_e(p),w=gt(t,n,p,f,g),N=[],M=new Map,A=[],O=new Map,v=[],V=new Map,te={...Vn(n),referenceRamp:m},j=new Map;if(o==="rainbow")for(let x=0;x<n.nodes.length;x++)j.set(n.nodes[x].id,x);let B=n.paths?.length??0,{pathColorByIndex:C,pathIndexByName:q}=Qn(n),J=x=>C[q.get(x)??-1]??yt,P=i&&B>1?tr(n):er,ge=y>(d?1:Pn);for(let x=0;x<n.edges.length;x++){let E=n.edges[x],I=t[E.from],D=t[E.to],k=w.get(x);if(!I?.length||!D?.length||!k||h?.has(x))continue;let H=E.pathIds?.length??0,$=f?.get(x)!==void 0,W=l?.edgeIndexes.has(x)??!1,z=a/2*($?vn:1)*(W?On:1),Z=i&&H>0,ce=$?_n:Gn,ne=l?W?Cn:fe(ce,ve):ce,ye=(Me,Re,T,le)=>{let F=Me===0&&Re===0?k:mt(k,Me,Re);if(!(u&&!Zn(F,u))){if($)for(let pe of ft(F,In/y))v.push({curves:pe,thickness:z,color:T});else v.push({curves:F,thickness:z,color:T});if(ge&&le!==void 0){let pe=F[F.length-1];A.push({x:pe.x1,y:pe.y1,angle:qn(pe,R),size:Bn,color:le})}}},xe=v.length,de=A.length;if(!Z)ye(0,0,ne,ne);else{let Me=ht(I,D,H,p),Re=Math.floor((H-1)/2);for(let T=0;T<H;T++){let le=Me[T],F=J(E.pathIds[T]);ye(le.x,le.y,l&&E.pathIds[T]!==l.name?fe(F,ve):F,T===Re?ne:void 0)}}let Ne=v.length-xe;Ne>0&&V.set(x,{start:xe,count:Ne});let ue=A.length-de;ue>0&&O.set(x,{start:de,count:ue})}for(let[x,E]of Object.entries(t)){let I=r.get(x);if(!I||u&&!Jn(E,u))continue;let D=jn(I,j.get(x)??0,o,te),k=l!==void 0&&!l.nodeIds.has(x),H=k?fe(D,ve):D,ie=rt(I,s,c,b),$=ie/2,W=N.length,z=P.get(x),Z=ie/B,ce=E.length>=2;if(ce&&z?.length&&Z>=kn){let ye=Dn(E,R),xe=1/Math.max(y,Tn);for(let de of z){let Ne=(de-(B-1)/2)*Z*xe,ue=C[de]??yt;N.push({points:Hn(E,ye,Ne,R),thickness:Z/2,color:k?fe(ue,ve):ue})}}else ce&&N.push({points:E,thickness:$,color:H});let ne=N.length-W;ne>0&&M.set(x,{start:W,count:ne})}return{nodeStrokes:N,nodeStrokeRuns:M,arrows:A,arrowRuns:O,edgeCurves:v,edgeCurveRuns:V}}function ko(e){return me(e)?Mt(e):void 0}function Mt(e){return{sample:oe(e.stable.refName),haplotype:je(e.stable.refName),refName:qe(e.stable.refName),start:e.stable.start,end:e.stable.start+e.length}}function nr(e,t){let n=[...e].sort((s,a)=>s.start-a.start),r,o;for(let s of n)o=o&&s.start-o.end<=t?{start:o.start,end:Math.max(o.end,s.end)}:{start:s.start,end:s.end},(!r||o.end-o.start>r.end-r.start)&&(r=o);return r}function rr(e){return`${e.haplotype??e.sample}\0${e.refName}`}function To(e,{maxGap:t=1/0}={}){let n=new Map;for(let o of e.nodes)if(me(o)){let s=Mt(o),a=rr(s),i=n.get(a);i?(i.spans.push({start:s.start,end:s.end}),i.rank=Math.min(i.rank,o.stable.rank)):n.set(a,{sample:s.sample,haplotype:s.haplotype,refName:s.refName,rank:o.stable.rank,spans:[{start:s.start,end:s.end}]})}let r=new Map;for(let o of n.values()){let s=nr(o.spans,t);if(s){let a={sample:o.sample,haplotype:o.haplotype,refName:o.refName,start:s.start,end:s.end,rank:o.rank,nodeCount:o.spans.length},i=o.haplotype??o.sample,c=r.get(i);(!c||a.nodeCount>c.nodeCount)&&r.set(i,a)}}return[...r.values()].sort((o,s)=>+(o.rank!==0)-+(s.rank!==0)||o.sample.localeCompare(s.sample)||(o.haplotype??"").localeCompare(s.haplotype??""))}function or(e,t){return(t.haplotype===void 0?void 0:e(t.haplotype))??e(t.sample)}function Bo(e,t){return e.flatMap(n=>{let r=or(t,n);return r===void 0?[]:[{...n,sample:r}]})}function Po(e){return`${e.refName}:${e.start+1}-${e.end}`}function Fe(e){return`${e.refName}:${(e.start+1).toLocaleString()}-${e.end.toLocaleString()}`}var Rt=re(Te(),1),wt=(0,Q.createSvgIcon)((0,Rt.jsx)("path",{d:"M9.01 14H2v2h7.01v3L13 15l-3.99-4zm5.98-1v-3H22V8h-7.01V5L11 9z"}),"CompareArrows");var St=re(Te(),1),Lt=(0,Q.createSvgIcon)((0,St.jsx)("path",{d:"M17 5h-2V3h2zm-2 16h2v-2.59L19.59 21 21 19.59 18.41 17H21v-2h-6zm4-12h2V7h-2zm0 4h2v-2h-2zm-8 8h2v-2h-2zM7 5h2V3H7zM3 17h2v-2H3zm2 4v-2H3c0 1.1.9 2 2 2M19 3v2h2c0-1.1-.9-2-2-2m-8 2h2V3h-2zM3 9h2V7H3zm4 12h2v-2H7zm-4-8h2v-2H3zm0-8h2V3c-1.1 0-2 .9-2 2"}),"HighlightAlt");var At=re(Te(),1),Xe=(0,Q.createSvgIcon)((0,At.jsx)("path",{d:"M3 16h5v-2H3zm6.5 0h5v-2h-5zm6.5 0h5v-2h-5zM3 20h2v-2H3zm4 0h2v-2H7zm4 0h2v-2h-2zm4 0h2v-2h-2zm4 0h2v-2h-2zM3 12h8v-2H3zm10 0h8v-2h-8zM3 4v4h18V4z"}),"LineStyle");var sr="Linear genome view",ar="Linear synteny view",ir="No synteny track in this session aligns these assemblies";function Et({label:e,icon:t,entries:n,entryLabel:r,onSelect:o,disabledHelpText:s,nameTheOnlyEntry:a=!0}){let[i]=n,c=s?[{label:e,icon:t,disabled:!0,disabledHelpText:s,onClick:()=>{}}]:[];return n.length===0?c:n.length===1&&i?[{label:a?`${e} \u2014 ${r(i)}`:e,icon:t,onClick:o(i)}]:[{label:e,icon:t,type:"subMenu",subMenu:n.map(l=>({label:r(l),onClick:o(l)}))}]}function jo({contributors:e,syntenyTracks:t,onShowLinear:n,onShowSynteny:r}){let o=t[0]?.coverage??e.length;return[...Et({label:sr,icon:Xe,entries:e,entryLabel:s=>`${s.sample} ${Fe(s)}`,onSelect:s=>()=>{n({location:s,assembly:s.sample})}}),...e.length>=2?Et({label:`${ar} (${o} assemblies)`,icon:wt,entries:t,entryLabel:s=>s.coverage<o?`${s.name} (${s.coverage} of ${o})`:s.name,nameTheOnlyEntry:!1,disabledHelpText:ir,onSelect:s=>()=>{r(s.trackId)}}):[]]}function qo({own:e,reference:t,highlight:n,onShowLinear:r,onHighlight:o}){let s=[e?{label:`Open in ${e.assembly} \u2014 ${Fe(e.location)}`,target:e}:void 0,t&&t.assembly!==e?.assembly?{label:`Open in ${t.assembly} \u2014 around this node`,target:t}:void 0].filter(a=>a!==void 0);return[...o&&n?[{label:`Highlight in ${n.assembly}`,icon:Lt,onClick:()=>{o(n)}}]:[],...s.map(({label:a,target:i})=>({label:a,icon:Xe,onClick:()=>{r(i)}}))]}function es(e,t){return Math.max(e.nodeLengthPerMegabase*t/1e6,e.minimumNodeLength)}function ur(e,t=5){let r=e.nodes.reduce((s,a)=>s+a.length,0)/1e6,o=Math.max(e.nodes.length*40,500);return{nodeLengthPerMegabase:r>0?o/r:1e4,minimumNodeLength:Math.max(5,t),edgeLength:5,nodeSegmentLength:20}}var ae={power:1,effect:1};function lr(e){return e.power===1&&e.effect===1}function pr(e,t){let n=e.nodes.length,r=e.nodes.reduce((a,i)=>a+i.length,0),o=n>0?r/n:0,s=n>0?Math.max(n*40,500)/n:40;return a=>{if(o<=0)return s;let i=(a/o)**t.power;return Math.max(s*((i-1)*t.effect+1),5)}}var vt=1e3,fr={law:ae,minNodeLength:0};function ts(e,t=fr){let{law:n,minNodeLength:r}=t,o=ur(e,r);if(lr(n))return{nodes:e.nodes,opts:o};let s=pr(e,n);return{nodes:e.nodes.map(a=>({...a,length:Math.round(s(a.length)*vt)})),opts:{...o,nodeLengthPerMegabase:1e6/vt,minimumNodeLength:5}}}var Ct=[{value:"auto",label:"Proportional",description:"Bandage's own scale: a node draws proportional to its length, so a 1 bp allele is a speck.",law:ae,minNodeFactor:0},{value:"open",label:"Open bubbles",description:"Give every allele a drawn length, so a bubble reads as two arms rather than a knot.",law:ae,minNodeFactor:2.5},{value:"wide",label:"Wide bubbles",description:"As open, spread further. Best on a window of a dozen bubbles.",law:ae,minNodeFactor:10},{value:"compress",label:"Compress lengths",description:"Pull the longest and shortest nodes towards the graph\u2019s mean, so a cut spanning kb and bp fits one pane.",law:{power:.5,effect:.5},minNodeFactor:0}],os=Ct.map(e=>e.value);function ss(e){let t=Ct.find(n=>n.value===e);return{law:t?.law??ae,minNodeLength:(t?.minNodeFactor??0)*40}}var hr=40;function ee(e){return e>=1e4?`${(e/1e3).toFixed(0)} kb`:e>=1e3?`${(e/1e3).toFixed(1)} kb`:`${e} bp`}function br(e,t){let n=ee(e),r=ee(t),o=r.slice(r.indexOf(" "));return n.endsWith(o)?`${n.slice(0,-o.length)}\u2013${r}`:`${n}\u2013${r}`}function Ot(e){return e>=Je?"\u22652.1B routes":e>=1e5?`${(e/1e3).toFixed(0)}k routes`:`${e} routes`}function cs(e){let t=gr(e);return e.partial?{...t,label:`${t.label}, partial`}:t}function gr(e){let t=e.end-e.start,{shortestAlleleLength:n,longestAlleleLength:r,pathCount:o,segmentCount:s,inversion:a}=e,i=br(n,r);if(s>=hr)return{kind:"superbubble",label:`${i} superbubble, ${s} segments, ${Ot(o)}${a?", inv":""}`};if(a)return{kind:"inversion",label:`${ee(r)} inv`};if(o>=8&&r>5*Math.max(n,1))return{kind:"repeat",label:`${i} repeat array, ${Ot(o)}`};let c=o>2?`, ${o} alleles`:"";return n===r&&n===t?t<=1?{kind:"snp",label:"SNP"}:{kind:"substitution",label:`${ee(t)} sub`}:t===0||n===t?{kind:"insertion",label:`\u2264${ee(r-t)} ins${c}`}:r===t?{kind:"deletion",label:`${ee(t-n)} del${c}`}:{kind:"complex",label:`${ee(t)} ref \u2192 ${i}, ${o} alleles`}}var ds={snp:"#5b6b7a",substitution:"#5b6b7a",insertion:"#2f8fd6",deletion:"#c94040",inversion:"#e07b00",repeat:"#8e3fbf",superbubble:"#8e3fbf",complex:"#8e3fbf"},us={snp:"SNP",substitution:"substitution",insertion:"insertion",deletion:"deletion",inversion:"inversion",repeat:"repeat array",superbubble:"superbubble",complex:"site"};function ls(e){return e.segments.split(",").filter(Boolean)}var yr=[{value:"auto",label:"Auto"},{value:"uniform",label:"Uniform"},{value:"random",label:"Random"},{value:"rainbow",label:"Rainbow"},{value:"depth",label:"Depth"},{value:"node-length",label:"Node Length"},{value:"stable-rank",label:"Stable rank"},{value:"reference-position",label:"Reference position"},{value:"grey",label:"Grey"}],fs=yr.map(e=>e.value);function bs(e){let t=new Map,n=new Map,r=(u,m,f)=>{let h=u.get(m);h?h.push(f):u.set(m,[f])};for(let u of e.edges)r(t,u.from,u.to),r(n,u.to,u.from);let o=(u,m)=>u!==m&&t.get(u)?.length===1&&n.get(m)?.length===1,s=new Map,a=new Map;for(let u of e.nodes){let m=n.get(u.id);if(s.has(u.id)||m?.length===1&&o(m[0],u.id))continue;let f=[u.id];for(;;){let h=t.get(f.at(-1))?.[0];if(h===void 0||s.has(h)||!o(f.at(-1),h))break;f.push(h)}for(let h of f)s.set(h,u.id);f.length>1&&a.set(u.id,f)}for(let u of e.nodes)s.has(u.id)||s.set(u.id,u.id);let i=new Map(e.nodes.map(u=>[u.id,u])),c=[];for(let u of e.nodes){if(s.get(u.id)!==u.id)continue;let m=a.get(u.id);if(!m){c.push(u);continue}let f=m.map(b=>i.get(b)),h=f.filter(S),g=h.length?h.reduce((b,y)=>b.stable.start<=y.stable.start?b:y):f[0];c.push({id:u.id,name:u.name,length:f.reduce((b,y)=>b+y.length,0),depth:u.depth,stable:g.stable})}let l=new Set;for(let u of a.values())for(let m=1;m<u.length;m++)l.add(`${u[m-1]}>${u[m]}`);let p=new Set,d=[];for(let u of e.edges){let m=`${s.get(u.from)}>${s.get(u.to)}`;l.has(`${u.from}>${u.to}`)||p.has(m)||(p.add(m),d.push({from:s.get(u.from),to:s.get(u.to)}))}return{graph:{...e,nodes:c,edges:d,paths:void 0,pathVisits:void 0},runs:a}}function gs(e,t,n){let r={...e};for(let[o,s]of t){let a=e[o];if(!a?.length)continue;delete r[o];let i=Ye(a),c=i.at(-1),l=s.map(u=>Math.max(n(u),0)),p=l.reduce((u,m)=>u+m,0)||s.length,d=0;s.forEach((u,m)=>{let f=p?l[m]/p*c:c/s.length,h=m===s.length-1?c:d+f;r[u]=It(a,i,d,h),d=h})}return r}function ys(e,t,n){if(e.length===0)return[];let r=Ye(e),o=r.at(-1);return It(e,r,t*o,n*o)}function xs(e){let t=Ye(e);return Ue(e,t,t.at(-1)/2)}function Ye(e){let t=[0];for(let n=1;n<e.length;n++)t.push(t[n-1]+Math.hypot(e[n].x-e[n-1].x,e[n].y-e[n-1].y));return t}function Ue(e,t,n){if(n<=0)return{...e[0]};let r=1;for(;r<t.length&&t[r]<n;)r++;if(r>=t.length)return{...e.at(-1)};let o=t[r]-t[r-1],s=o>0?(n-t[r-1])/o:0,a=e[r-1],i=e[r];return{x:a.x+(i.x-a.x)*s,y:a.y+(i.y-a.y)*s}}function It(e,t,n,r){let o=[Ue(e,t,n)];for(let s=0;s<e.length;s++)t[s]>n&&t[s]<r&&o.push({...e[s]});return o.push(Ue(e,t,r)),o}function kt(e){return e.sample??oe(e.name)}function xr(e){return e.haplotype!==void 0&&e.sample!==void 0?`${e.sample}#${e.haplotype}`:kt(e)}function Nr(e,t,n,r=!0){if(!n||!r)return{ids:e,complete:!0};let o=-1,s=-1,a=-1/0,i=1/0;if(e.forEach((l,p)=>{let d=t.get(l);d&&(d.end<=n.start&&d.end>a&&(a=d.end,o=p),d.start>=n.end&&d.start<i&&(i=d.start,s=p))}),o<0||s<0)return{ids:e,complete:!1};let c=e.slice(Math.min(o,s)+1,Math.max(o,s));return{ids:o<s?c:c.reverse(),complete:!0}}function Tt(e,t,n){let r=e.paths??[],o=r.find(f=>se(f.name).name===e.referencePath)??r[0];if(!o||r.length<2)return;let s=new Map(e.nodes.map(f=>[f.id,f.length])),a=new Set(o.nodeIds),i=e.anchorPaths?.find(f=>f.name===se(o.name).name)?.start??0,c=t&&t.end>t.start?t:void 0,l=new Map,p=i;for(let f of o.nodeIds){let h=s.get(f)??0;l.has(f)||l.set(f,{start:p,end:p+h}),p+=h}let d=c===void 0||[...l.values()].some(f=>f.end<=c.start)&&[...l.values()].some(f=>f.start>=c.end),u=f=>{let{ids:h,complete:g}=Nr(f.nodeIds,l,c,d),b=[],y=0,R=0;for(let w of h){let N=s.get(w)??0,M=a.has(w),A=b.at(-1);A?.onReference===M?A.bp+=N:b.push({start:y,bp:N,onReference:M}),y+=N,M||(R+=N)}return{name:f.name,label:xr(f),sample:kt(f),bp:y,offReferenceBp:R,complete:g,runs:b}};return{origin:c?c.start:i,unit:n,reference:u(o),rows:r.filter(f=>f!==o).map(u).sort((f,h)=>Number(h.complete)-Number(f.complete)||h.bp-f.bp||f.label.localeCompare(h.label))}}var Mr=1.3;function Rr(e){let t=e.reference.bp;for(let n of e.rows)t=Math.max(t,n.bp);return{maxX:e.origin+t*Mr,maxY:e.rows.length*20}}function Bt(e,t){let n=X(e),r=Tt(e,t);if(n.length===0||!r)return;let o=U(n),s=[{label:r.reference.label,y:0},...r.rows.map((a,i)=>({label:a.label,y:(i+1)*20}))];return{nodePositions:o,rowLabels:s,referenceAxis:!0,pixelRows:!0,extent:Rr(r)}}function Ie(e){let t=e.split("#"),n=t.length>=2?Number(t[1]):Number.NaN;return{sample:t[0]??e,haplotype:Number.isFinite(n)?n:void 0}}function wr(e,t,n,r){let o=[],s=[],a=[e];for(r.add(e);a.length>0;){let i=a.pop(),c=t.get(i);if(c){o.push(c);for(let l of n.get(i)??[]){let p=t.get(l);p&&(p.stable.rank===0?s.push(p):r.has(l)||(r.add(l),a.push(l)))}}}return{members:o,anchors:s}}function Sr(e){if(new Set(e.map(i=>i.stable.refName)).size!==1||e.length<2)return;let n=[...e].sort((i,c)=>i.stable.start-c.stable.start),r=n[0],o=n.at(-1),s=r.stable.start+r.length,a=o.stable.start;return a>=s?{start:s,end:a,entry:r}:void 0}function Lr(e,t,n){let r=new Map(e.map(a=>[a.id,a])),o=new Map,s=[];for(let a of n.get(t.id)??[])r.has(a)&&(o.set(a,0),s.push(a));if(s.length===0)for(let a of e)o.set(a.id,0),s.push(a.id);for(let a of s){let i=o.get(a)+r.get(a).length;for(let c of n.get(a)??[])if(r.has(c)){let l=o.get(c);(l===void 0||i<l)&&(o.set(c,i),s.push(c))}}return o}function Ar(e,t,n){let r=Lr(e,t,n),o=[...e].sort((c,l)=>r.get(c.id)-r.get(l.id)),s=new Map(o.map((c,l)=>[c.id,l])),a=new Map(e.map(c=>[c.id,c])),i=new Map;for(let[c,l]of o.entries()){let p=0;for(let d of n.get(l.id)??[]){let u=a.get(d);u&&s.get(d)<c&&(p=Math.max(p,i.get(d)+u.length))}i.set(l.id,p)}return{offsets:i,ordered:o}}function Pt(e){let t=new Map(e.nodes.filter(me).map(s=>[s.id,s])),n=he(e),r=new Set,o=[];for(let s of t.values())if(s.stable.rank!==0&&!r.has(s.id)){let{members:a,anchors:i}=wr(s.id,t,n,r),c=Sr(i);if(c){let{offsets:l,ordered:p}=Ar(a,c.entry,n);o.push({start:c.start,refSpan:c.end-c.start,nodeIds:p.map(d=>d.id),nodeOffsets:p.map(d=>l.get(d.id)),pathLength:p.reduce((d,u)=>Math.max(d,l.get(u.id)+u.length),0)})}}return o.sort((s,a)=>s.start-a.start)}var Er=1,Gr=.015;function ke({graph:e,span:t,rowY:n,positions:r}){let o=t*Gr,s=Pt(e),a=new Map(e.nodes.map(p=>[p.id,p])),i=[];for(let p of s){let d=p.refSpan-p.pathLength;d>=Er&&i.push({nodeIds:p.nodeIds,bp:d});let u=Math.max(p.refSpan,o),m=p.pathLength>0?u/p.pathLength:0;p.nodeIds.forEach((f,h)=>{let g=a.get(f);if(g){let b=p.nodeOffsets[h],y=u/p.nodeIds.length,R=N=>p.start+N*m,w=n(g);r[f]=m?[{x:R(b),y:w},{x:R(b+g.length),y:w}]:[{x:p.start+h*y,y:w},{x:p.start+(h+1)*y,y:w}]}})}let c=he(e),l=Object.keys(r);for(let p of l){let d=r[p].at(-1).x;for(let u of c.get(p)??[]){let m=a.get(u);if(m&&!(u in r)){let f=n(m);r[u]=[{x:d,y:f},{x:d+o,y:f}],l.push(u)}}}return i}function _r(e){let t=new Set;for(let n of e.nodes)n.stable&&t.add(n.stable.rank);return new Map([...t].sort((n,r)=>n-r).map((n,r)=>[n,r]))}function Dt(e,t){let n=X(e);if(n.length===0)return;let r=Le(n,t),o=_r(e),s=U(n),a=ke({graph:e,span:r,rowY:c=>(c.stable?o.get(c.stable.rank)??o.size:o.size)*20,positions:s}),i=[...o].map(([c,l])=>({label:c===0?"Reference (rank 0)":`Rank ${c}`,y:l*20}));return{nodePositions:s,rowLabels:i,referenceAxis:!0,pixelRows:!0,alleleDeletions:a}}var vr=12,Ke=20;function Ht(e){return 10+8*Math.log2(1+e.length)}function Y(e,t){return e<t?-1:e>t?1:0}function Wt(e,t){return Y(e.at,t.at)||Y(e.side,t.side)||Y(e.hops,t.hops)}var $t={at:1/0,side:0,hops:0};function Cr(e){let t=new Map(e.nodes.map(r=>[r.id,r])),n=kr(e);return e.nodes.map(r=>r.id).sort((r,o)=>Wt(n.get(r)??$t,n.get(o)??$t)||Y(t.get(r).name,t.get(o).name)||Y(r,o))}function Or(e,t){let n=new Set(e.nodes.map(p=>p.id)),r=new Map(t.map(p=>[p.id,p.stable.start])),o=new Map,s=new Map;t.forEach((p,d)=>{s.set(p.id,t[d-1]?.id),o.set(p.id,t[d+1]?.id)});let a=t[0]?.id,i=(p,d)=>{let u=o.get(p);o.set(p,d),s.set(d,p),o.set(d,u),u!==void 0&&s.set(u,d)},c=(p,d)=>{let u=s.get(p);u===void 0?(a=d,s.set(d,void 0),o.set(d,p),s.set(p,d)):i(u,d)};for(let p of e.paths??[]){let d=0,u=0,m;for(let b of p.nodeIds){let y=r.get(b);y!==void 0&&(m!==void 0&&y!==m&&(y>m?d++:u++),m=y)}let f=u>d?[...p.nodeIds].reverse():p.nodeIds,h,g=new Set;for(let b of f)if(o.has(b)){if(h===void 0)for(let y of g)c(b,y);h=b}else n.has(b)&&(h===void 0?g.add(b):(i(h,b),h=b))}let l=[];for(let p=a;p!==void 0;p=o.get(p))l.push(p);return l}function Ir(e,t){let n=[...t.entries()].sort(([a,i],[c,l])=>Wt(i,l)||Y(a,c)).map(([a])=>a),r=n.length;for(let a of n){let i=t.get(a);for(let c of e.get(a)??[])t.has(c)||(t.set(c,{at:i.at,side:1,hops:i.hops+1}),n.push(c))}let o=new Set(n.slice(r)),s=new Set;for(let a of o){if(s.has(a))continue;let{at:i}=t.get(a),c=[a];s.add(a);let l=!0;for(let p of c){let{hops:d}=t.get(p),u=!0,m=!1;for(let f of e.get(p)??[]){let h=t.get(f);h.at===i&&o.has(f)?(u&&=h.hops<=d,s.has(f)||(s.add(f),c.push(f))):h.at!==i&&(m||=h.at<i,l&&=h.at<i)}l&&=!u||m}if(l)for(let p of c){let d=t.get(p);t.set(p,{...d,side:-1,hops:-d.hops})}}}function kr(e){let t=new Set(e.nodes.map(s=>s.id)),n=new Map;for(let s of e.edges)!t.has(s.from)||!t.has(s.to)||((n.get(s.from)??n.set(s.from,[]).get(s.from)).push(s.to),(n.get(s.to)??n.set(s.to,[]).get(s.to)).push(s.from));let r=e.nodes.filter(S).sort((s,a)=>Y(s.stable.start,a.stable.start)||Y(s.name,a.name)),o=new Map;return Or(e,r).forEach((s,a)=>{o.set(s,{at:a,side:0,hops:0})}),Ir(n,o),o}function Tr(e){let t=new Map(e.nodes.map(d=>[d.id,d])),n=Cr(e),r=new Map(n.map((d,u)=>[d,u])),o=d=>S(t.get(d)),s=new Map(n.map(d=>[d,[]])),a=new Map(n.map(d=>[d,[]])),i=(d,u)=>{s.get(u).push(d),a.get(d).push(u)};for(let d of e.edges)d.from===d.to||!r.has(d.from)||!r.has(d.to)||(r.get(d.from)<r.get(d.to)?i(d.from,d.to):i(d.to,d.from));let c=n.filter(o);for(let d=1;d<c.length;d++)i(c[d-1],c[d]);let l=new Map;for(let d of n){let u=0;for(let m of s.get(d))u=Math.max(u,l.get(m)+1);l.set(d,u)}for(let d=n.length-1;d>=0;d--){let u=n[d],m=a.get(u);if(o(u)||m.length===0)continue;let f=1/0;for(let b of m)f=Math.min(f,l.get(b));let h=l.get(u),g=Math.max(h,f-1);l.set(u,Math.floor((h+g)/2))}let p=[];for(let d of n)(p[l.get(d)]??=[]).push(d);return{layers:p,layerOf:l,preds:s}}function zt(e){if(!e.nodes.some(S))return;let t=new Map(e.nodes.map(d=>[d.id,d])),n=d=>S(t.get(d)),{layers:r,layerOf:o,preds:s}=Tr(e),a=r.map(d=>{let u=0;for(let m of d)u=Math.max(u,Ht(t.get(m)));return u}),i=[],c=0;for(let d=0;d<r.length;d++)i[d]=c,c+=a[d]+vr;let l=new Map;for(let d of r){let u=[];for(let f of d){if(n(f)){l.set(f,0);continue}let h=s.get(f).filter(b=>l.has(b)),g=0;for(let b of h)g+=l.get(b)/h.length;u.push({id:f,ideal:g===0?Ke:g})}u.sort((f,h)=>f.ideal-h.ideal);let m=new Set([0]);for(let{id:f,ideal:h}of u){let g=Math.round(h/Ke);g===0&&(g=h>=0?1:-1);for(let b=1;m.has(g);b++)m.has(g+b)?m.has(g-b)||(g-=b):g+=b;m.add(g),l.set(f,g*Ke)}}let p={};for(let d of e.nodes){let u=o.get(d.id),m=Ht(d),f=i[u]+a[u]/2,h=l.get(d.id);p[d.id]=[{x:f-m/2,y:h},{x:f+m/2,y:h}]}return{nodePositions:p,referenceAxis:!1,pixelRows:!0}}function Br(e){let t=new Map;for(let n of e.nodes)if(Se(n)){let{sample:r}=Ie(n.stable.refName);t.set(r,(t.get(r)??0)+n.length)}return[...t.keys()].sort((n,r)=>t.get(r)-t.get(n)||n.localeCompare(r))}function Ft(e,t){let n=X(e),r=Br(e);if(n.length===0||r.length===0)return;let o=Le(n,t),s=new Map(r.map((d,u)=>[d,u+1])),a=U(n),i=r.length+1,c=ke({graph:e,span:o,rowY:d=>{let u=d.stable;return((u?s.get(Ie(u.refName).sample):void 0)??i)*20},positions:a}),p=[{label:Ie(n[0].stable.refName).sample,y:0},...r.map(d=>({label:d,y:s.get(d)*20}))];return{nodePositions:a,rowLabels:p,referenceAxis:!0,pixelRows:!0,alleleDeletions:c}}function Xt(e){let t=X(e);if(t.length!==0)return{nodePositions:U(t),referenceAxis:!0,pixelRows:!0}}var Pr="Force-directed layout",K=e=>e.nodes.some(S),Ut=e=>K(e)&&(e.paths?.length??0)>1,Yt=e=>K(e)&&e.nodes.some(Se),Ve=[{value:"auto",label:"Anchored",description:"x is reference bp, one row per stable rank. Needs rGFA tags or a reference path.",run:Dt,available:K,drawsLocally:K},{value:"samplerows",label:"Sample rows",description:"x is reference bp, one row per contributing assembly. Needs rGFA tags or a reference path.",run:Ft,available:Yt,drawsLocally:Yt},{value:"walkrows",label:"Walk rows",description:"x is each walk's own bp: one bar per haplotype, sequence the reference also carries in blue and sequence it does not in purple, so a repeat expansion reads as bar length. Needs W or P lines.",run:Bt,available:Ut,drawsLocally:Ut},{value:"ordered",label:"Ordered",description:"x is reference order, not bp: every node gets room, bubbles read as lenses. Needs rGFA tags or a reference path.",run:zt,available:K,drawsLocally:K},{value:"variants",label:"Variant map",description:"The reference as a line with one typed glyph per bubble, from the bubble index or from the graph itself: SNP, indel, deletion, inversion, repeat array. Click a glyph to open the graph inside it.",run:Xt,available:K,drawsLocally:K},{value:"force",label:Pr,description:"OGDF FMMM, via the external Bandage engine.",run:()=>{},available:()=>!0,drawsLocally:()=>!1}],ea=Ve.map(e=>e.value);function ta(e,t){return!Dr(e).drawsLocally(t)}function Dr(e){return Ve.find(t=>t.value===e)??Ve[0]}function Hr(e,t){return Math.abs(t-e)<=.1*Math.max(e,t)}function $r(e,t){let n=e.length,r=t.length,o=Array.from({length:n+1},()=>new Array(r+1).fill(0)),s=Array.from({length:n+1},()=>new Array(r+1).fill(!1));for(let i=n-1;i>=0;i--)for(let c=r-1;c>=0;c--){let l=Math.abs(e[i]-t[c])+o[i+1][c+1],p=n-i>r-c?o[i+1][c]:1/0,d=r-c>n-i?o[i][c+1]:1/0;o[i][c]=Math.min(l,p,d),s[i][c]=o[i][c]===l}let a=new Array(n).fill(void 0);for(let i=0,c=0;i<n&&c<r;)s[i][c]?a[i++]=c++:n-i>r-c?i++:c++;return a}function Kt(e,t){return e.map((n,r)=>({item:n,i:r})).sort((n,r)=>t(n.item)-t(r.item))}var Vt=e=>e.spanningReads!==0;function Wr(e,t){let n=new Map,r=new Set,o=Kt(e,a=>a.bp),s=[[o.filter(a=>a.item.complete),t.filter(Vt)],[o,t]];for(let[a,i]of s){let c=a.filter(p=>!n.has(p.i)),l=Kt(i.filter(p=>!r.has(p)),p=>p.bp);$r(c.map(p=>p.item.bp),l.map(p=>p.item.bp)).forEach((p,d)=>{if(p!==void 0){let u=c[d],m=l[p].item;r.add(m),n.set(u.i,{...m,agrees:u.item.complete&&Vt(m)?Hr(u.item.bp,m.bp):void 0})}})}return n}function ra(e,t){if(!t)return e;let n=new Map,r=new Map;for(let o of e)r.set(o.sample,[...r.get(o.sample)??[],o]);for(let[o,s]of r){let a=t[o];if(a)for(let[i,c]of Wr(s,a))n.set(s[i],c)}return e.map(o=>({...o,call:n.get(o)}))}export{Q as a,Be as b,dr as c,S as d,X as e,ot as f,Zt as g,es as h,ts as i,Ct as j,os as k,ss as l,ee as m,cs as n,ds as o,us as p,ls as q,lo as r,po as s,fo as t,mt as u,_e as v,ht as w,Cr as x,yr as y,fs as z,go as A,yo as B,bs as C,gs as D,ys as E,xs as F,se as G,Qr as H,rn as I,eo as J,he as K,pn as L,Tt as M,Rr as N,Ve as O,ea as P,ta as Q,Dr as R,jt as S,Kr as T,nt as U,rt as V,Vr as W,on as X,ro as Y,oo as Z,Ur as _,gt as $,Xn as aa,_o as ba,vo as ca,ra as da,ko as ea,To as fa,or as ga,Bo as ha,Po as ia,Fe as ja,jo as ka,qo as la,cr as ma};
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as Te}from"./chunk-XEJ47DLD.js";import{c as Je}from"./chunk-ZNGDWZ6Z.js";import{a as oe,b as je,c as qe}from"./chunk-F4C3BEPV.js";import{a as we,b as re}from"./chunk-FY3BTKY4.js";var Qe=we((zr,Ze)=>{Ze.exports=JBrowseExports["@mui/material/SvgIcon"]});var Be=we((Xr,et)=>{et.exports=JBrowseExports["@jbrowse/core/util/colorBits"]});var cr=we((Zo,Gt)=>{Gt.exports=JBrowseExports["tss-react/mui"]});var dr=we((Qo,_t)=>{_t.exports=JBrowseExports["@jbrowse/render-core/canvas2dUtils"]});var Q=re(Qe(),1);var G=re(Be(),1);var L=re(Be(),1);function fe(e,t){return(0,L.packAbgr)((0,L.abgrRed)(e),(0,L.abgrGreen)(e),(0,L.abgrBlue)(e),Math.round((0,L.abgrAlpha)(e)*t))}function Ur(e,t){return(0,L.packAbgr)(Math.min(255,Math.round((0,L.abgrRed)(e)*t)),Math.min(255,Math.round((0,L.abgrGreen)(e)*t)),Math.min(255,Math.round((0,L.abgrBlue)(e)*t)),(0,L.abgrAlpha)(e))}var jt=[{value:"depth",label:"By depth",description:"Thicker the more paths carry a node, on the square root of its depth against the mean. A graph with one depth everywhere draws uniform."},{value:"uniform",label:"Uniform",description:"Every node the same thickness."}],Kr=jt.map(e=>e.value),qt=.3,tt=3;function nt(e){let t=0,n=0;for(let r of e.nodes)t+=r.depth*r.length,n+=r.length;return n>0?t/n:0}function Jt(e,t){return!(t>0)||!(e.depth>0)?1:Math.min(tt,Math.max(qt,Math.sqrt(e.depth/t)))}function rt(e,t,n,r){return t*(n==="depth"?Jt(e,r):1)}function Vr(e,t){return e*(t==="depth"?tt:1)}function me(e){return e.stable!==void 0}function S(e){return e.stable?.rank===0}function Se(e){return e.stable!==void 0&&e.stable.rank>0}function X(e){return e.nodes.filter(S)}function U(e){let t={};for(let n of e)t[n.id]=[{x:n.stable.start,y:0},{x:n.stable.start+n.length,y:0}];return t}function ot(e,t){let n=0,r=e.length;for(;n<r;){let o=n+r>>1;e[o].stable.start<t?n=o+1:r=o}return n}function Zt(e){let t=1/0,n=-1/0;for(let r of e)t=Math.min(t,r.stable.start),n=Math.max(n,r.stable.start+r.length);return n-t}function Le(e,t){return t&&t.end>t.start?t.end-t.start:Zt(e)}var Qt=/:(\d+)-\d+$/;function se(e){let t=Qt.exec(e);return t?{name:e.slice(0,t.index),start:+t[1]}:{name:e,start:0}}function Qr(e,t){let n=[],r=new Map;for(let o of e){let s=oe(o.name),a=o.start;for(let i of o.steps){let c={path:o.name,sample:s,start:a,strand:i.strand},u=r.get(i.id);u?u.push(c):r.set(i.id,[c]),a+=t(i.id)}n.push({name:o.name,sample:s,start:o.start,length:a-o.start})}return{anchorPaths:n,pathVisits:r}}function en(e,t){return e.find(r=>r.sample===t||r.name===t)??e[0]}var tn=1;function nn(e,t,n){let r=e;if(t&&t.length>0){let o=t.find(s=>s.path===n)??t[0];r={...e,stable:{refName:o.path,start:o.start,rank:o.path===n?0:tn,strand:o.strand},samples:[...new Set(t.map(s=>s.sample))].sort()}}return r}function rn(e,t){let{anchorPaths:n,pathVisits:r}=e,o=n&&r?en(n,t):void 0;return o&&r?{...e,nodes:e.nodes.map(s=>nn(s,r.get(s.name),o.name)),anchoredBy:"paths",referencePath:o.name}:e}function eo(e,t){return e.anchoredBy==="tags"?e:rn(e,t)}function st(e){let t=0;for(let n=0;n<e.length;n++)t=e.charCodeAt(n)+((t<<5)-t);return Math.abs(t%360)}function Pe(e,t){return e*360/t}var Ee=.7,Ge=.5,on=16;function ro(e){return e>0&&e<=on}function sn(e,t){return`hsl(${Pe(e,t)}, ${Ee*100}%, ${Ge*100}%)`}function an(e){let t=se(e).name.split("#");return[t[0],t.slice(0,2).join("#"),t.join("#")]}function cn(e){return String(e).replace(/\B(?=(\d{3})+$)/g,",")}function dn(e,t){let{start:n}=se(e);return t.map(r=>`${r} @${cn(n)}`)}function oo(e){let t=e.map(s=>an(s.name)),n=[0,1,2].flatMap(s=>[e.map((a,i)=>t[i][s]),e.map((a,i)=>dn(a.name,t[i])[s])]),o=n.find(s=>new Set(s).size===e.length)??n.at(-1);return e.map((s,a)=>({name:s.name,label:o[a],color:sn(a,e.length)}))}var ln=4;function he(e){let t=new Map;function n(r,o){let s=t.get(r);s?s.push(o):t.set(r,[o])}for(let r of e.edges)n(r.from,r.to),n(r.to,r.from);return t}function un({nodeId:e,nodeById:t,neighbors:n}){let r=new Set([e]),o=[e],s=1/0,a=-1/0;for(let i=0;i<ln&&o.length>0;i++){let c=[];for(let u of o){let p=n.get(u);if(p){for(let l of p)if(!r.has(l)){r.add(l);let d=t.get(l);d&&S(d)?(s=Math.min(s,d.stable.start+d.length),a=Math.max(a,d.stable.start)):c.push(l)}}}o=c}return s===1/0?void 0:{start:Math.min(s,a),end:Math.max(s,a)}}function pn({nodeId:e,nodeById:t,neighbors:n}){let r=t.get(e);return r===void 0?void 0:S(r)?{start:r.stable.start,end:r.stable.start+r.length}:un({nodeId:e,nodeById:t,neighbors:n})}function at(e){let t=new Map(e.nodes.map(o=>[o.id,o])),n=he(e),r=new Map;for(let o of e.nodes){let s=pn({nodeId:o.id,nodeById:t,neighbors:n});s&&r.set(o.id,(s.start+s.end)/2)}return r}function uo(e){let t=n=>Math.round(n*100)/100;return e.map((n,r)=>`${r?"L":"M"}${t(n.x)},${t(n.y)}`).join("")}function it(e,t,n,r,o){let s=Math.hypot(r-t,n-e);if(s===0)return[n,r];let a=(n-e)/s,i=(r-t)/s;return[n+o*a,r+o*i]}function $e(e,t){let n=1-t,r=n*n*n,o=3*n*n*t,s=3*n*t*t,a=t*t*t;return{x:r*e.x0+o*e.cx0+s*e.cx1+a*e.x1,y:r*e.y0+o*e.cy0+s*e.cy1+a*e.y1}}function po(e){let t=e[Math.floor(e.length/2)];return t?$e(t,.5):void 0}function fo(e){let t=1/0,n=1/0,r=-1/0,o=-1/0;for(let s of e)t=Math.min(t,s.x0,s.cx0,s.cx1,s.x1),r=Math.max(r,s.x0,s.cx0,s.cx1,s.x1),n=Math.min(n,s.y0,s.cy0,s.cy1,s.y1),o=Math.max(o,s.y0,s.cy0,s.cy1,s.y1);return{minX:t,minY:n,maxX:r,maxY:o}}function fn(e,t,n){let r=$e(e,t),o=$e(e,n),s=(n-t)/3,a=ct(e,t),i=ct(e,n);return{x0:r.x,y0:r.y,cx0:r.x+a.x*s,cy0:r.y+a.y*s,cx1:o.x-i.x*s,cy1:o.y-i.y*s,x1:o.x,y1:o.y}}function ct(e,t){let n=1-t,r=3*n*n,o=6*n*t,s=3*t*t;return{x:r*(e.cx0-e.x0)+o*(e.cx1-e.cx0)+s*(e.x1-e.cx1),y:r*(e.cy0-e.y0)+o*(e.cy1-e.cy0)+s*(e.y1-e.cy1)}}function ft(e,t){let n=[];for(let r of e){let o=Math.hypot(r.cx0-r.x0,r.cy0-r.y0)+Math.hypot(r.cx1-r.cx0,r.cy1-r.cy0)+Math.hypot(r.x1-r.cx1,r.y1-r.cy1),s=Math.max(3,Math.round(o/t)|1);for(let a=0;a<s;a+=2)n.push([fn(r,a/s,(a+1)/s)])}return n}function mt(e,t,n){let r=new Array(e.length);for(let o=0;o<e.length;o++){let s=e[o];r[o]={x0:s.x0+t,y0:s.y0+n,cx0:s.cx0+t,cy0:s.cy0+n,cx1:s.cx1+t,cy1:s.cy1+n,x1:s.x1+t,y1:s.y1+n}}return r}function dt(e,t){let n=e.length-1;return t==="end"?{at:e[n],inward:e[n-1]}:{at:e[0],inward:e[1]}}var mn=.5,hn=80;function lt(e){let t=1/0,n=-1/0;for(let r of e)t=Math.min(t,r.x),n=Math.max(n,r.x);return{min:t,max:n}}function ut(e,t){return Math.max(0,t.min-e,e-t.max)}function pt(e,t,n){let r=ut(e[0].x,t),o=ut(e[e.length-1].x,t);return r===o?n:r<o?"start":"end"}function bn(e,t){return{from:pt(e,lt(t),"end"),to:pt(t,lt(e),"start")}}var gn=.75,yn=1.15,xn=.35,Nn=60;function Mn(e,t,n,r,o,s){let a=Math.hypot(n-e,r-t),i=a===0?1:(n-e)/a,c=a===0?0:(r-t)/a,u=0,p=1/0,l=-1/0;for(let h of o){let g=h.x-e,b=h.y-t,y=g*-c+b*i;Math.abs(y)>Math.abs(u)&&(u=y);let R=g*i+b*c;p=Math.min(p,R),l=Math.max(l,R)}let d=o.length?l-p:0,m=Math.max(Math.abs(u)*yn/gn,d*xn),f=s===void 0?m:Math.min(m,s);return u<0?-f:f}function _e({scaleX:e,scaleY:t}){return t/e}var Rn=3;function De(e,t,n){let r=t.x-e.x,o=(t.y-e.y)*n,s=Math.hypot(r,o);return s===0?void 0:{x:r/s,y:o/s}}function ht(e,t,n,r,o=Rn){let s=_e(r),a=De(e[e.length-1],t[0],s)??De(e[0],e.at(-1),s)??De(t[0],t.at(-1),s)??{x:1,y:0},i=[];for(let c=0;c<n;c++){let u=(c-(n-1)/2)*o;i.push({x:-a.y*u,y:a.x*u/s})}return i}function He(e,t){return e.map(n=>({x:n.x,y:n.y*t}))}function wn(e,t){for(let n of e)n.y0/=t,n.cy0/=t,n.cy1/=t,n.y1/=t;return e}function be(e,t,n,r,o,s,a=[],i){let c=s.scaleX,u=_e(s),p=i??(s.pixelRows?Nn:void 0);if(u!==1)return wn(be(He(e,u),He(t,u),n,r,o*u,{scaleX:c,scaleY:c},He(a,u),p===void 0?void 0:p*u),u);let l=n?{from:"end",to:"start"}:bn(e,t),d=dt(e,l.from),m=dt(t,l.to),f=d.at,h=m.at,g=f.x+r,b=f.y+o,y=h.x+r,R=h.y+o;if(n){let w=1,N=0;if(d.inward){let q=f.x-d.inward.x,J=f.y-d.inward.y,P=Math.hypot(q,J);P>0&&(w=q/P,N=J/P)}let M=Math.min(50,50*c),A=-N,O=w,v=(f.x+h.x)/2+r+A*M,V=(f.y+h.y)/2+o+O*M,te=g+w*M,j=b+N*M,B=y-w*M,C=R-N*M;return[{x0:g,y0:b,cx0:te,cy0:j,cx1:te+A*M,cy1:j+O*M,x1:v,y1:V},{x0:v,y0:V,cx0:B+A*M,cy0:C+O*M,cx1:B,cy1:C,x1:y,y1:R}]}else{let w=d.inward??{x:f.x-(h.x-f.x),y:f.y-(h.y-f.y)},N=m.inward??{x:h.x-(f.x-h.x),y:h.y-(f.y-h.y)},M=Math.hypot(y-g,R-b),A=(D,k,H,ie)=>{let $=k.x-D.x,W=k.y-D.y,z=Math.hypot($,W),Z=z===0?0:(H*$+ie*W)/z;return Math.max(0,Math.min(M*mn,hn,Z*.5))},O=h.x-f.x,v=h.y-f.y,[V,te]=it(w.x,w.y,f.x,f.y,A(w,f,O,v)),[j,B]=it(N.x,N.y,h.x,h.y,A(N,h,-O,-v)),C=a.length?Mn(g,b,y,R,a,p):0,q=M===0?1:M,J=(y-g)/q,P=(R-b)/q,ge=-P*C,x=J*C,E=J*Math.abs(C),I=P*Math.abs(C);return[{x0:g,y0:b,cx0:V+r+ge-E,cy0:te+o+x-I,cx1:j+r+ge+E,cy1:B+o+x+I,x1:y,y1:R}]}}var Sn=1;function We(e,t){return t.flatMap(n=>e[n]??[])}function go(e,t,n){let r=e[t.from],o=e[t.to];return r?.length&&o?.length?be(r,o,t.from===t.to,0,0,n,We(e,t.bypassed)):void 0}function Ln(e){let t=new Map;for(let n of e.nodes)if(S(n)){let r=t.get(n.stable.refName);r?r.push(n):t.set(n.stable.refName,[n])}for(let n of t.values())n.sort((r,o)=>r.stable.start-o.stable.start);return t}function An(e,t,n){let r=[];if(e)for(let o=ot(e,t);o<e.length;o++){let s=e[o];if(s.stable.start>=n)break;s.stable.start+s.length<=n&&r.push(s.id)}return r}function En(e,t,n,r){let{fromStrand:o,toStrand:s}=e;if(o===void 0||s===void 0)return!0;let a=o===(t.stable.strand??"+"),i=s===(n.stable.strand??"+");return r?a&&i:!a&&!i}function yo(e){let t=new Map(e.nodes.map(o=>[o.id,o])),n=Ln(e),r=[];for(let o=0;o<e.edges.length;o++){let s=e.edges[o],a=t.get(s.from),i=t.get(s.to);if(a!==void 0&&i!==void 0&&S(a)&&S(i)&&a.stable.refName===i.stable.refName){let c=a.stable.start<=i.stable.start,[u,p]=c?[a,i]:[i,a],l=u.stable.start+u.length,d=p.stable.start,m=d-l;if(m>=Sn&&En(s,a,i,c)){let f=u.stable.refName;r.push({edgeIndex:o,from:s.from,to:s.to,refName:f,start:l,end:d,bp:m,bypassed:An(n.get(f),l,d)})}}}return r}var bt=new WeakMap;function gt(e,t,n,r,o){let{scaleX:s,scaleY:a}=n,i=bt.get(e);if(i?.graph===t&&i.scaleX===s&&i.scaleY===a&&i.deletions===r&&i.version===o)return i.curves;let c=new Map;for(let u=0;u<t.edges.length;u++){let p=t.edges[u],l=e[p.from],d=e[p.to];if(l?.length&&d?.length){let m=r?.get(u);c.set(u,be(l,d,p.from===p.to,0,0,n,m?We(e,m):[]))}}return bt.set(e,{graph:t,scaleX:s,scaleY:a,deletions:r,version:o,curves:c}),c}var Gn=(0,G.packAbgr)(119,119,119,217),yt=(0,G.packAbgr)(136,136,136,217),_n=(0,G.packAbgr)(24,24,28,240),vn=2.2,Cn=(0,G.packAbgr)(30,30,36,245),On=1.8,ve=.18,In=11,kn=1.2,Tn=1e-6,Bn=12,Pn=.45;function Dn(e,t=1){let n=t===1?e:e.map(o=>({x:o.x,y:o.y*t})),r=[];for(let o=0;o<n.length;o++){let s=0,a=0;if(o===0){let i=n[1].x-n[0].x,c=n[1].y-n[0].y,u=Math.hypot(i,c);u>0&&(s=-c/u,a=i/u)}else if(o===n.length-1){let i=n[o].x-n[o-1].x,c=n[o].y-n[o-1].y,u=Math.hypot(i,c);u>0&&(s=-c/u,a=i/u)}else{let i=n[o].x-n[o-1].x,c=n[o].y-n[o-1].y,u=Math.hypot(i,c),p=n[o+1].x-n[o].x,l=n[o+1].y-n[o].y,d=Math.hypot(p,l);if(u>0&&d>0){let m=-c/u,f=i/u,h=-l/d,g=p/d;s=(m+h)/2,a=(f+g)/2;let b=m*s+f*a;b>.1&&(s/=b,a/=b)}else u>0?(s=-c/u,a=i/u):d>0&&(s=-l/d,a=p/d)}r.push({nx:s,ny:a})}return r}function Hn(e,t,n,r=1){return e.map((o,s)=>({x:o.x+t[s].nx*n,y:o.y+t[s].ny*n/r}))}function Ce(e,t,n,r){return(0,G.packAbgr)(Math.round(e*255),Math.round(t*255),Math.round(n*255),Math.round(r*255))}function Oe(e,t,n){let r=(1-Math.abs(2*n-1))*t,o=r*(1-Math.abs(e/60%2-1)),s=n-r/2,a=0,i=0,c=0;return e<60?(a=r,i=o):e<120?(a=o,i=r):e<180?(i=r,c=o):e<240?(i=o,c=r):e<300?(a=o,c=r):(a=r,c=o),[a+s,i+s,c+s]}var $n=[[68,1,84],[59,82,139],[33,145,140],[94,201,98],[253,231,37]],Wn=[[237,137,44],[158,42,122]],zn=[[220,50,50],[50,120,220]];function ze(e,t){let n=Math.max(0,Math.min(1,t))*(e.length-1),r=Math.min(e.length-2,Math.floor(n)),o=n-r,s=e[r],a=e[r+1];return(0,G.packAbgr)(Math.round(s[0]+(a[0]-s[0])*o),Math.round(s[1]+(a[1]-s[1])*o),Math.round(s[2]+(a[2]-s[2])*o),255)}function Fn(e,t){let[n,r,o]=Oe(st(e),Ee,Ge);return Ce(n,r,o,t)}var Xn=300,Un=.7,Yn=.5,Kn=(0,G.packAbgr)(60,65,72,255);function _o(e,t){let n=at(e);if(t&&t.end>t.start)return{start:t.start,span:t.end-t.start,midpoints:n};let r=1/0,o=-1/0;for(let s of n.values())r=Math.min(r,s),o=Math.max(o,s);return{start:r===1/0?0:r,span:o>r?o-r:1,midpoints:n}}function Vn(e){let t=1/0,n=-1/0,r=1/0,o=-1/0,s=0;for(let a of e.nodes)a.stable!==void 0&&a.stable.rank>s&&(s=a.stable.rank),a.depth<t&&(t=a.depth),a.depth>n&&(n=a.depth),a.length<r&&(r=a.length),a.length>o&&(o=a.length);return{minDepth:t,maxDepth:n,minLength:r,maxLength:o,maxRank:s,nodeCount:e.nodes.length}}function jn(e,t,n,r){switch(n){case"random":return Fn(e.id,1);case"depth":return ze($n,r.maxDepth>r.minDepth?(e.depth-r.minDepth)/(r.maxDepth-r.minDepth):.5);case"node-length":return ze(zn,r.maxLength>r.minLength?(e.length-r.minLength)/(r.maxLength-r.minLength):.5);case"stable-rank":return e.stable===void 0?(0,G.packAbgr)(160,160,160,255):e.stable.rank===0?(0,G.packAbgr)(52,152,219,255):ze(Wn,r.maxRank>1?(e.stable.rank-1)/(r.maxRank-1):0);case"reference-position":{let o=r.referenceRamp,s=o?.midpoints.get(e.id);if(o===void 0||s===void 0)return(0,G.packAbgr)(160,160,160,255);if(e.stable!==void 0&&e.stable.rank>0)return Kn;let a=Math.max(0,Math.min(1,(s-o.start)/o.span)),[i,c,u]=Oe(a*Xn,Un,Yn);return Ce(i,c,u,1)}case"grey":return(0,G.packAbgr)(160,160,160,255);case"rainbow":{let o=r.nodeCount>1?t/r.nodeCount*360:0,[s,a,i]=Oe(o,.75,.5);return Ce(s,a,i,1)}default:return(0,G.packAbgr)(52,152,219,255)}}function qn(e,t=1){let n=e.x1-e.cx1,r=(e.y1-e.cy1)*t;return Math.hypot(n,r)>0?Math.atan2(r,n):Math.atan2((e.y1-e.y0)*t,e.x1-e.x0)}function Jn(e,t){let n=!1;for(let r=0;r<e.length-1&&!n;r++){let o=e[r],s=e[r+1];n=Math.max(o.x,s.x)>=t.minX&&Math.min(o.x,s.x)<=t.maxX&&Math.max(o.y,s.y)>=t.minY&&Math.min(o.y,s.y)<=t.maxY}return n}function Zn(e,t){for(let n of e){let r=Math.min(n.x0,n.cx0,n.cx1,n.x1),o=Math.max(n.x0,n.cx0,n.cx1,n.x1),s=Math.min(n.y0,n.cy0,n.cy1,n.y1),a=Math.max(n.y0,n.cy0,n.cy1,n.y1);if(o>=t.minX&&r<=t.maxX&&a>=t.minY&&s<=t.maxY)return!0}return!1}var xt=new WeakMap;function Qn(e){let t=xt.get(e);if(!t){let n=[],r=new Map,o=e.paths??[];for(let s=0;s<o.length;s++){let[a,i,c]=Oe(Pe(s,o.length),Ee,Ge);n.push(Ce(a,i,c,.85)),r.has(o[s].name)||r.set(o[s].name,s)}t={pathColorByIndex:n,pathIndexByName:r},xt.set(e,t)}return t}var Nt=new WeakMap,er=new Map;function tr(e){let t=Nt.get(e);if(!t){t=new Map;for(let[n,r]of(e.paths??[]).entries())for(let o of new Set(r.nodeIds)){let s=t.get(o);s?s.push(n):t.set(o,[n])}Nt.set(e,t)}return t}function vo(e){let{nodePositions:t,graph:n,nodeById:r,colorScheme:o,contigThickness:s,connectorThickness:a,drawPaths:i,nodeWidth:c="uniform",highlight:u,axis:p,linearLayout:l,viewportBounds:d,referenceRamp:m,deletions:f,hiddenEdges:h,version:g=0}=e,b=c==="depth"?nt(n):0,y=p.scaleX,R=_e(p),w=gt(t,n,p,f,g),N=[],M=new Map,A=[],O=new Map,v=[],V=new Map,te={...Vn(n),referenceRamp:m},j=new Map;if(o==="rainbow")for(let x=0;x<n.nodes.length;x++)j.set(n.nodes[x].id,x);let B=n.paths?.length??0,{pathColorByIndex:C,pathIndexByName:q}=Qn(n),J=x=>C[q.get(x)??-1]??yt,P=i&&B>1?tr(n):er,ge=y>(l?1:Pn);for(let x=0;x<n.edges.length;x++){let E=n.edges[x],I=t[E.from],D=t[E.to],k=w.get(x);if(!I?.length||!D?.length||!k||h?.has(x))continue;let H=E.pathIds?.length??0,$=f?.get(x)!==void 0,W=u?.edgeIndexes.has(x)??!1,z=a/2*($?vn:1)*(W?On:1),Z=i&&H>0,ce=$?_n:Gn,ne=u?W?Cn:fe(ce,ve):ce,ye=(Me,Re,T,ue)=>{let F=Me===0&&Re===0?k:mt(k,Me,Re);if(!(d&&!Zn(F,d))){if($)for(let pe of ft(F,In/y))v.push({curves:pe,thickness:z,color:T});else v.push({curves:F,thickness:z,color:T});if(ge&&ue!==void 0){let pe=F[F.length-1];A.push({x:pe.x1,y:pe.y1,angle:qn(pe,R),size:Bn,color:ue})}}},xe=v.length,de=A.length;if(!Z)ye(0,0,ne,ne);else{let Me=ht(I,D,H,p),Re=Math.floor((H-1)/2);for(let T=0;T<H;T++){let ue=Me[T],F=J(E.pathIds[T]);ye(ue.x,ue.y,u&&E.pathIds[T]!==u.name?fe(F,ve):F,T===Re?ne:void 0)}}let Ne=v.length-xe;Ne>0&&V.set(x,{start:xe,count:Ne});let le=A.length-de;le>0&&O.set(x,{start:de,count:le})}for(let[x,E]of Object.entries(t)){let I=r.get(x);if(!I||d&&!Jn(E,d))continue;let D=jn(I,j.get(x)??0,o,te),k=u!==void 0&&!u.nodeIds.has(x),H=k?fe(D,ve):D,ie=rt(I,s,c,b),$=ie/2,W=N.length,z=P.get(x),Z=ie/B,ce=E.length>=2;if(ce&&z?.length&&Z>=kn){let ye=Dn(E,R),xe=1/Math.max(y,Tn);for(let de of z){let Ne=(de-(B-1)/2)*Z*xe,le=C[de]??yt;N.push({points:Hn(E,ye,Ne,R),thickness:Z/2,color:k?fe(le,ve):le})}}else ce&&N.push({points:E,thickness:$,color:H});let ne=N.length-W;ne>0&&M.set(x,{start:W,count:ne})}return{nodeStrokes:N,nodeStrokeRuns:M,arrows:A,arrowRuns:O,edgeCurves:v,edgeCurveRuns:V}}function ko(e){return me(e)?Mt(e):void 0}function Mt(e){return{sample:oe(e.stable.refName),haplotype:je(e.stable.refName),refName:qe(e.stable.refName),start:e.stable.start,end:e.stable.start+e.length}}function nr(e,t){let n=[...e].sort((s,a)=>s.start-a.start),r,o;for(let s of n)o=o&&s.start-o.end<=t?{start:o.start,end:Math.max(o.end,s.end)}:{start:s.start,end:s.end},(!r||o.end-o.start>r.end-r.start)&&(r=o);return r}function rr(e){return`${e.haplotype??e.sample}\0${e.refName}`}function To(e,{maxGap:t=1/0}={}){let n=new Map;for(let o of e.nodes)if(me(o)){let s=Mt(o),a=rr(s),i=n.get(a);i?(i.spans.push({start:s.start,end:s.end}),i.rank=Math.min(i.rank,o.stable.rank)):n.set(a,{sample:s.sample,haplotype:s.haplotype,refName:s.refName,rank:o.stable.rank,spans:[{start:s.start,end:s.end}]})}let r=new Map;for(let o of n.values()){let s=nr(o.spans,t);if(s){let a={sample:o.sample,haplotype:o.haplotype,refName:o.refName,start:s.start,end:s.end,rank:o.rank,nodeCount:o.spans.length},i=o.haplotype??o.sample,c=r.get(i);(!c||a.nodeCount>c.nodeCount)&&r.set(i,a)}}return[...r.values()].sort((o,s)=>+(o.rank!==0)-+(s.rank!==0)||o.sample.localeCompare(s.sample)||(o.haplotype??"").localeCompare(s.haplotype??""))}function or(e,t){return(t.haplotype===void 0?void 0:e(t.haplotype))??e(t.sample)}function Bo(e,t){return e.flatMap(n=>{let r=or(t,n);return r===void 0?[]:[{...n,sample:r}]})}function Po(e){return`${e.refName}:${e.start+1}-${e.end}`}function Fe(e){return`${e.refName}:${(e.start+1).toLocaleString()}-${e.end.toLocaleString()}`}var Rt=re(Te(),1),wt=(0,Q.createSvgIcon)((0,Rt.jsx)("path",{d:"M9.01 14H2v2h7.01v3L13 15l-3.99-4zm5.98-1v-3H22V8h-7.01V5L11 9z"}),"CompareArrows");var St=re(Te(),1),Lt=(0,Q.createSvgIcon)((0,St.jsx)("path",{d:"M17 5h-2V3h2zm-2 16h2v-2.59L19.59 21 21 19.59 18.41 17H21v-2h-6zm4-12h2V7h-2zm0 4h2v-2h-2zm-8 8h2v-2h-2zM7 5h2V3H7zM3 17h2v-2H3zm2 4v-2H3c0 1.1.9 2 2 2M19 3v2h2c0-1.1-.9-2-2-2m-8 2h2V3h-2zM3 9h2V7H3zm4 12h2v-2H7zm-4-8h2v-2H3zm0-8h2V3c-1.1 0-2 .9-2 2"}),"HighlightAlt");var At=re(Te(),1),Xe=(0,Q.createSvgIcon)((0,At.jsx)("path",{d:"M3 16h5v-2H3zm6.5 0h5v-2h-5zm6.5 0h5v-2h-5zM3 20h2v-2H3zm4 0h2v-2H7zm4 0h2v-2h-2zm4 0h2v-2h-2zm4 0h2v-2h-2zM3 12h8v-2H3zm10 0h8v-2h-8zM3 4v4h18V4z"}),"LineStyle");var sr="Linear genome view",ar="Linear synteny view",ir="No synteny track in this session aligns these assemblies";function Et({label:e,icon:t,entries:n,entryLabel:r,onSelect:o,disabledHelpText:s,nameTheOnlyEntry:a=!0}){let[i]=n,c=s?[{label:e,icon:t,disabled:!0,disabledHelpText:s,onClick:()=>{}}]:[];return n.length===0?c:n.length===1&&i?[{label:a?`${e} \u2014 ${r(i)}`:e,icon:t,onClick:o(i)}]:[{label:e,icon:t,type:"subMenu",subMenu:n.map(u=>({label:r(u),onClick:o(u)}))}]}function jo({contributors:e,syntenyTracks:t,onShowLinear:n,onShowSynteny:r}){let o=t[0]?.coverage??e.length;return[...Et({label:sr,icon:Xe,entries:e,entryLabel:s=>`${s.sample} ${Fe(s)}`,onSelect:s=>()=>{n({location:s,assembly:s.sample})}}),...e.length>=2?Et({label:`${ar} (${o} assemblies)`,icon:wt,entries:t,entryLabel:s=>s.coverage<o?`${s.name} (${s.coverage} of ${o})`:s.name,nameTheOnlyEntry:!1,disabledHelpText:ir,onSelect:s=>()=>{r(s.trackId)}}):[]]}function qo({own:e,reference:t,highlight:n,onShowLinear:r,onHighlight:o}){let s=[e?{label:`Open in ${e.assembly} \u2014 ${Fe(e.location)}`,target:e}:void 0,t&&t.assembly!==e?.assembly?{label:`Open in ${t.assembly} \u2014 around this node`,target:t}:void 0].filter(a=>a!==void 0);return[...o&&n?[{label:`Highlight in ${n.assembly}`,icon:Lt,onClick:()=>{o(n)}}]:[],...s.map(({label:a,target:i})=>({label:a,icon:Xe,onClick:()=>{r(i)}}))]}function es(e,t){return Math.max(e.nodeLengthPerMegabase*t/1e6,e.minimumNodeLength)}function lr(e,t=5){let r=e.nodes.reduce((s,a)=>s+a.length,0)/1e6,o=Math.max(e.nodes.length*40,500);return{nodeLengthPerMegabase:r>0?o/r:1e4,minimumNodeLength:Math.max(5,t),edgeLength:5,nodeSegmentLength:20}}var ae={power:1,effect:1};function ur(e){return e.power===1&&e.effect===1}function pr(e,t){let n=e.nodes.length,r=e.nodes.reduce((a,i)=>a+i.length,0),o=n>0?r/n:0,s=n>0?Math.max(n*40,500)/n:40;return a=>{if(o<=0)return s;let i=(a/o)**t.power;return Math.max(s*((i-1)*t.effect+1),5)}}var vt=1e3,fr={law:ae,minNodeLength:0};function ts(e,t=fr){let{law:n,minNodeLength:r}=t,o=lr(e,r);if(ur(n))return{nodes:e.nodes,opts:o};let s=pr(e,n);return{nodes:e.nodes.map(a=>({...a,length:Math.round(s(a.length)*vt)})),opts:{...o,nodeLengthPerMegabase:1e6/vt,minimumNodeLength:5}}}var Ct=[{value:"auto",label:"Proportional",description:"Bandage's own scale: a node draws proportional to its length, so a 1 bp allele is a speck.",law:ae,minNodeFactor:0},{value:"open",label:"Open bubbles",description:"Give every allele a drawn length, so a bubble reads as two arms rather than a knot.",law:ae,minNodeFactor:2.5},{value:"wide",label:"Wide bubbles",description:"As open, spread further. Best on a window of a dozen bubbles.",law:ae,minNodeFactor:10},{value:"compress",label:"Compress lengths",description:"Pull the longest and shortest nodes towards the graph\u2019s mean, so a cut spanning kb and bp fits one pane.",law:{power:.5,effect:.5},minNodeFactor:0}],os=Ct.map(e=>e.value);function ss(e){let t=Ct.find(n=>n.value===e);return{law:t?.law??ae,minNodeLength:(t?.minNodeFactor??0)*40}}var hr=40;function ee(e){return e>=1e4?`${(e/1e3).toFixed(0)} kb`:e>=1e3?`${(e/1e3).toFixed(1)} kb`:`${e} bp`}function br(e,t){let n=ee(e),r=ee(t),o=r.slice(r.indexOf(" "));return n.endsWith(o)?`${n.slice(0,-o.length)}\u2013${r}`:`${n}\u2013${r}`}function Ot(e){return e>=Je?"\u22652.1B routes":e>=1e5?`${(e/1e3).toFixed(0)}k routes`:`${e} routes`}function cs(e){let t=gr(e);return e.partial?{...t,label:`${t.label}, partial`}:t}function gr(e){let t=e.end-e.start,{shortestAlleleLength:n,longestAlleleLength:r,pathCount:o,segmentCount:s,inversion:a}=e,i=br(n,r);if(s>=hr)return{kind:"superbubble",label:`${i} superbubble, ${s} segments, ${Ot(o)}${a?", inv":""}`};if(a)return{kind:"inversion",label:`${ee(r)} inv`};if(o>=8&&r>5*Math.max(n,1))return{kind:"repeat",label:`${i} repeat array, ${Ot(o)}`};let c=o>2?`, ${o} alleles`:"";return n===r&&n===t?t<=1?{kind:"snp",label:"SNP"}:{kind:"substitution",label:`${ee(t)} sub`}:t===0||n===t?{kind:"insertion",label:`\u2264${ee(r-t)} ins${c}`}:r===t?{kind:"deletion",label:`${ee(t-n)} del${c}`}:{kind:"complex",label:`${ee(t)} ref \u2192 ${i}, ${o} alleles`}}var ds={snp:"#5b6b7a",substitution:"#5b6b7a",insertion:"#2f8fd6",deletion:"#c94040",inversion:"#e07b00",repeat:"#8e3fbf",superbubble:"#8e3fbf",complex:"#8e3fbf"},ls={snp:"SNP",substitution:"substitution",insertion:"insertion",deletion:"deletion",inversion:"inversion",repeat:"repeat array",superbubble:"superbubble",complex:"site"};function us(e){return e.segments.split(",").filter(Boolean)}var yr=[{value:"auto",label:"Auto"},{value:"uniform",label:"Uniform"},{value:"random",label:"Random"},{value:"rainbow",label:"Rainbow"},{value:"depth",label:"Depth"},{value:"node-length",label:"Node Length"},{value:"stable-rank",label:"Stable rank"},{value:"reference-position",label:"Reference position"},{value:"grey",label:"Grey"}],fs=yr.map(e=>e.value);function bs(e){let t=new Map,n=new Map,r=(d,m,f)=>{let h=d.get(m);h?h.push(f):d.set(m,[f])};for(let d of e.edges)r(t,d.from,d.to),r(n,d.to,d.from);let o=(d,m)=>d!==m&&t.get(d)?.length===1&&n.get(m)?.length===1,s=new Map,a=new Map;for(let d of e.nodes){let m=n.get(d.id);if(s.has(d.id)||m?.length===1&&o(m[0],d.id))continue;let f=[d.id];for(;;){let h=t.get(f.at(-1))?.[0];if(h===void 0||s.has(h)||!o(f.at(-1),h))break;f.push(h)}for(let h of f)s.set(h,d.id);f.length>1&&a.set(d.id,f)}for(let d of e.nodes)s.has(d.id)||s.set(d.id,d.id);let i=new Map(e.nodes.map(d=>[d.id,d])),c=[];for(let d of e.nodes){if(s.get(d.id)!==d.id)continue;let m=a.get(d.id);if(!m){c.push(d);continue}let f=m.map(b=>i.get(b)),h=f.filter(S),g=h.length?h.reduce((b,y)=>b.stable.start<=y.stable.start?b:y):f[0];c.push({id:d.id,name:d.name,length:f.reduce((b,y)=>b+y.length,0),depth:d.depth,stable:g.stable})}let u=new Set;for(let d of a.values())for(let m=1;m<d.length;m++)u.add(`${d[m-1]}>${d[m]}`);let p=new Set,l=[];for(let d of e.edges){let m=`${s.get(d.from)}>${s.get(d.to)}`;u.has(`${d.from}>${d.to}`)||p.has(m)||(p.add(m),l.push({from:s.get(d.from),to:s.get(d.to)}))}return{graph:{...e,nodes:c,edges:l,paths:void 0,pathVisits:void 0},runs:a}}function gs(e,t,n){let r={...e};for(let[o,s]of t){let a=e[o];if(!a?.length)continue;delete r[o];let i=Ye(a),c=i.at(-1),u=s.map(d=>Math.max(n(d),0)),p=u.reduce((d,m)=>d+m,0)||s.length,l=0;s.forEach((d,m)=>{let f=p?u[m]/p*c:c/s.length,h=m===s.length-1?c:l+f;r[d]=It(a,i,l,h),l=h})}return r}function ys(e,t,n){if(e.length===0)return[];let r=Ye(e),o=r.at(-1);return It(e,r,t*o,n*o)}function xs(e){let t=Ye(e);return Ue(e,t,t.at(-1)/2)}function Ye(e){let t=[0];for(let n=1;n<e.length;n++)t.push(t[n-1]+Math.hypot(e[n].x-e[n-1].x,e[n].y-e[n-1].y));return t}function Ue(e,t,n){if(n<=0)return{...e[0]};let r=1;for(;r<t.length&&t[r]<n;)r++;if(r>=t.length)return{...e.at(-1)};let o=t[r]-t[r-1],s=o>0?(n-t[r-1])/o:0,a=e[r-1],i=e[r];return{x:a.x+(i.x-a.x)*s,y:a.y+(i.y-a.y)*s}}function It(e,t,n,r){let o=[Ue(e,t,n)];for(let s=0;s<e.length;s++)t[s]>n&&t[s]<r&&o.push({...e[s]});return o.push(Ue(e,t,r)),o}function kt(e){return e.sample??oe(e.name)}function xr(e){return e.haplotype!==void 0&&e.sample!==void 0?`${e.sample}#${e.haplotype}`:kt(e)}function Nr(e,t,n,r=!0){if(!n||!r)return{ids:e,complete:!0};let o=-1,s=-1,a=-1/0,i=1/0;if(e.forEach((u,p)=>{let l=t.get(u);l&&(l.end<=n.start&&l.end>a&&(a=l.end,o=p),l.start>=n.end&&l.start<i&&(i=l.start,s=p))}),o<0||s<0)return{ids:e,complete:!1};let c=e.slice(Math.min(o,s)+1,Math.max(o,s));return{ids:o<s?c:c.reverse(),complete:!0}}function Tt(e,t,n){let r=e.paths??[],o=r.find(f=>se(f.name).name===e.referencePath)??r[0];if(!o||r.length<2)return;let s=new Map(e.nodes.map(f=>[f.id,f.length])),a=new Set(o.nodeIds),i=e.anchorPaths?.find(f=>f.name===se(o.name).name)?.start??0,c=t&&t.end>t.start?t:void 0,u=new Map,p=i;for(let f of o.nodeIds){let h=s.get(f)??0;u.has(f)||u.set(f,{start:p,end:p+h}),p+=h}let l=c===void 0||[...u.values()].some(f=>f.end<=c.start)&&[...u.values()].some(f=>f.start>=c.end),d=f=>{let{ids:h,complete:g}=Nr(f.nodeIds,u,c,l),b=[],y=0,R=0;for(let w of h){let N=s.get(w)??0,M=a.has(w),A=b.at(-1);A?.onReference===M?A.bp+=N:b.push({start:y,bp:N,onReference:M}),y+=N,M||(R+=N)}return{name:f.name,label:xr(f),sample:kt(f),bp:y,offReferenceBp:R,complete:g,runs:b}};return{origin:c?c.start:i,unit:n,reference:d(o),rows:r.filter(f=>f!==o).map(d).sort((f,h)=>Number(h.complete)-Number(f.complete)||h.bp-f.bp||f.label.localeCompare(h.label))}}var Mr=1.3;function Rr(e){let t=e.reference.bp;for(let n of e.rows)t=Math.max(t,n.bp);return{maxX:e.origin+t*Mr,maxY:e.rows.length*20}}function Bt(e,t){let n=X(e),r=Tt(e,t);if(n.length===0||!r)return;let o=U(n),s=[{label:r.reference.label,y:0},...r.rows.map((a,i)=>({label:a.label,y:(i+1)*20}))];return{nodePositions:o,rowLabels:s,referenceAxis:!0,pixelRows:!0,extent:Rr(r)}}function Ie(e){let t=e.split("#"),n=t.length>=2?Number(t[1]):Number.NaN;return{sample:t[0]??e,haplotype:Number.isFinite(n)?n:void 0}}function wr(e,t,n,r){let o=[],s=[],a=[e];for(r.add(e);a.length>0;){let i=a.pop(),c=t.get(i);if(c){o.push(c);for(let u of n.get(i)??[]){let p=t.get(u);p&&(p.stable.rank===0?s.push(p):r.has(u)||(r.add(u),a.push(u)))}}}return{members:o,anchors:s}}function Sr(e){if(new Set(e.map(i=>i.stable.refName)).size!==1||e.length<2)return;let n=[...e].sort((i,c)=>i.stable.start-c.stable.start),r=n[0],o=n.at(-1),s=r.stable.start+r.length,a=o.stable.start;return a>=s?{start:s,end:a,entry:r}:void 0}function Lr(e,t,n){let r=new Map(e.map(a=>[a.id,a])),o=new Map,s=[];for(let a of n.get(t.id)??[])r.has(a)&&(o.set(a,0),s.push(a));if(s.length===0)for(let a of e)o.set(a.id,0),s.push(a.id);for(let a of s){let i=o.get(a)+r.get(a).length;for(let c of n.get(a)??[])if(r.has(c)){let u=o.get(c);(u===void 0||i<u)&&(o.set(c,i),s.push(c))}}return o}function Ar(e,t,n){let r=Lr(e,t,n),o=[...e].sort((c,u)=>r.get(c.id)-r.get(u.id)),s=new Map(o.map((c,u)=>[c.id,u])),a=new Map(e.map(c=>[c.id,c])),i=new Map;for(let[c,u]of o.entries()){let p=0;for(let l of n.get(u.id)??[]){let d=a.get(l);d&&s.get(l)<c&&(p=Math.max(p,i.get(l)+d.length))}i.set(u.id,p)}return{offsets:i,ordered:o}}function Pt(e){let t=new Map(e.nodes.filter(me).map(s=>[s.id,s])),n=he(e),r=new Set,o=[];for(let s of t.values())if(s.stable.rank!==0&&!r.has(s.id)){let{members:a,anchors:i}=wr(s.id,t,n,r),c=Sr(i);if(c){let{offsets:u,ordered:p}=Ar(a,c.entry,n);o.push({start:c.start,refSpan:c.end-c.start,nodeIds:p.map(l=>l.id),nodeOffsets:p.map(l=>u.get(l.id)),pathLength:p.reduce((l,d)=>Math.max(l,u.get(d.id)+d.length),0)})}}return o.sort((s,a)=>s.start-a.start)}var Er=1,Gr=.015;function ke({graph:e,span:t,rowY:n,positions:r}){let o=t*Gr,s=Pt(e),a=new Map(e.nodes.map(p=>[p.id,p])),i=[];for(let p of s){let l=p.refSpan-p.pathLength;l>=Er&&i.push({nodeIds:p.nodeIds,bp:l});let d=Math.max(p.refSpan,o),m=p.pathLength>0?d/p.pathLength:0;p.nodeIds.forEach((f,h)=>{let g=a.get(f);if(g){let b=p.nodeOffsets[h],y=d/p.nodeIds.length,R=N=>p.start+N*m,w=n(g);r[f]=m?[{x:R(b),y:w},{x:R(b+g.length),y:w}]:[{x:p.start+h*y,y:w},{x:p.start+(h+1)*y,y:w}]}})}let c=he(e),u=Object.keys(r);for(let p of u){let l=r[p].at(-1).x;for(let d of c.get(p)??[]){let m=a.get(d);if(m&&!(d in r)){let f=n(m);r[d]=[{x:l,y:f},{x:l+o,y:f}],u.push(d)}}}return i}function _r(e){let t=new Set;for(let n of e.nodes)n.stable&&t.add(n.stable.rank);return new Map([...t].sort((n,r)=>n-r).map((n,r)=>[n,r]))}function Dt(e,t){let n=X(e);if(n.length===0)return;let r=Le(n,t),o=_r(e),s=U(n),a=ke({graph:e,span:r,rowY:c=>(c.stable?o.get(c.stable.rank)??o.size:o.size)*20,positions:s}),i=[...o].map(([c,u])=>({label:c===0?"Reference (rank 0)":`Rank ${c}`,y:u*20}));return{nodePositions:s,rowLabels:i,referenceAxis:!0,pixelRows:!0,alleleDeletions:a}}var vr=12,Ke=20;function Ht(e){return 10+8*Math.log2(1+e.length)}function Y(e,t){return e<t?-1:e>t?1:0}function Wt(e,t){return Y(e.at,t.at)||Y(e.side,t.side)||Y(e.hops,t.hops)}var $t={at:1/0,side:0,hops:0};function Cr(e){let t=new Map(e.nodes.map(r=>[r.id,r])),n=kr(e);return e.nodes.map(r=>r.id).sort((r,o)=>Wt(n.get(r)??$t,n.get(o)??$t)||Y(t.get(r).name,t.get(o).name)||Y(r,o))}function Or(e,t){let n=new Set(e.nodes.map(p=>p.id)),r=new Map(t.map(p=>[p.id,p.stable.start])),o=new Map,s=new Map;t.forEach((p,l)=>{s.set(p.id,t[l-1]?.id),o.set(p.id,t[l+1]?.id)});let a=t[0]?.id,i=(p,l)=>{let d=o.get(p);o.set(p,l),s.set(l,p),o.set(l,d),d!==void 0&&s.set(d,l)},c=(p,l)=>{let d=s.get(p);d===void 0?(a=l,s.set(l,void 0),o.set(l,p),s.set(p,l)):i(d,l)};for(let p of e.paths??[]){let l=0,d=0,m;for(let b of p.nodeIds){let y=r.get(b);y!==void 0&&(m!==void 0&&y!==m&&(y>m?l++:d++),m=y)}let f=d>l?[...p.nodeIds].reverse():p.nodeIds,h,g=new Set;for(let b of f)if(o.has(b)){if(h===void 0)for(let y of g)c(b,y);h=b}else n.has(b)&&(h===void 0?g.add(b):(i(h,b),h=b))}let u=[];for(let p=a;p!==void 0;p=o.get(p))u.push(p);return u}function Ir(e,t){let n=[...t.entries()].sort(([a,i],[c,u])=>Wt(i,u)||Y(a,c)).map(([a])=>a),r=n.length;for(let a of n){let i=t.get(a);for(let c of e.get(a)??[])t.has(c)||(t.set(c,{at:i.at,side:1,hops:i.hops+1}),n.push(c))}let o=new Set(n.slice(r)),s=new Set;for(let a of o){if(s.has(a))continue;let{at:i}=t.get(a),c=[a];s.add(a);let u=!0;for(let p of c){let{hops:l}=t.get(p),d=!0,m=!1;for(let f of e.get(p)??[]){let h=t.get(f);h.at===i&&o.has(f)?(d&&=h.hops<=l,s.has(f)||(s.add(f),c.push(f))):h.at!==i&&(m||=h.at<i,u&&=h.at<i)}u&&=!d||m}if(u)for(let p of c){let l=t.get(p);t.set(p,{...l,side:-1,hops:-l.hops})}}}function kr(e){let t=new Set(e.nodes.map(s=>s.id)),n=new Map;for(let s of e.edges)!t.has(s.from)||!t.has(s.to)||((n.get(s.from)??n.set(s.from,[]).get(s.from)).push(s.to),(n.get(s.to)??n.set(s.to,[]).get(s.to)).push(s.from));let r=e.nodes.filter(S).sort((s,a)=>Y(s.stable.start,a.stable.start)||Y(s.name,a.name)),o=new Map;return Or(e,r).forEach((s,a)=>{o.set(s,{at:a,side:0,hops:0})}),Ir(n,o),o}function Tr(e){let t=new Map(e.nodes.map(l=>[l.id,l])),n=Cr(e),r=new Map(n.map((l,d)=>[l,d])),o=l=>S(t.get(l)),s=new Map(n.map(l=>[l,[]])),a=new Map(n.map(l=>[l,[]])),i=(l,d)=>{s.get(d).push(l),a.get(l).push(d)};for(let l of e.edges)l.from===l.to||!r.has(l.from)||!r.has(l.to)||(r.get(l.from)<r.get(l.to)?i(l.from,l.to):i(l.to,l.from));let c=n.filter(o);for(let l=1;l<c.length;l++)i(c[l-1],c[l]);let u=new Map;for(let l of n){let d=0;for(let m of s.get(l))d=Math.max(d,u.get(m)+1);u.set(l,d)}for(let l=n.length-1;l>=0;l--){let d=n[l],m=a.get(d);if(o(d)||m.length===0)continue;let f=1/0;for(let b of m)f=Math.min(f,u.get(b));let h=u.get(d),g=Math.max(h,f-1);u.set(d,Math.floor((h+g)/2))}let p=[];for(let l of n)(p[u.get(l)]??=[]).push(l);return{layers:p,layerOf:u,preds:s}}function zt(e){if(!e.nodes.some(S))return;let t=new Map(e.nodes.map(l=>[l.id,l])),n=l=>S(t.get(l)),{layers:r,layerOf:o,preds:s}=Tr(e),a=r.map(l=>{let d=0;for(let m of l)d=Math.max(d,Ht(t.get(m)));return d}),i=[],c=0;for(let l=0;l<r.length;l++)i[l]=c,c+=a[l]+vr;let u=new Map;for(let l of r){let d=[];for(let f of l){if(n(f)){u.set(f,0);continue}let h=s.get(f).filter(b=>u.has(b)),g=0;for(let b of h)g+=u.get(b)/h.length;d.push({id:f,ideal:g===0?Ke:g})}d.sort((f,h)=>f.ideal-h.ideal);let m=new Set([0]);for(let{id:f,ideal:h}of d){let g=Math.round(h/Ke);g===0&&(g=h>=0?1:-1);for(let b=1;m.has(g);b++)m.has(g+b)?m.has(g-b)||(g-=b):g+=b;m.add(g),u.set(f,g*Ke)}}let p={};for(let l of e.nodes){let d=o.get(l.id),m=Ht(l),f=i[d]+a[d]/2,h=u.get(l.id);p[l.id]=[{x:f-m/2,y:h},{x:f+m/2,y:h}]}return{nodePositions:p,referenceAxis:!1,pixelRows:!0}}function Br(e,t){let n=new Map;for(let o of e.nodes)if(Se(o)){let{sample:s}=Ie(o.stable.refName);n.set(s,(n.get(s)??0)+o.length)}let r=new Map(t.map((o,s)=>[o,s]));return[...n.keys()].sort((o,s)=>(r.get(o)??1/0)-(r.get(s)??1/0)||n.get(s)-n.get(o)||o.localeCompare(s))}function Ft(e,t,n=[]){let r=X(e),o=Br(e,n);if(r.length===0||o.length===0)return;let s=Le(r,t),a=new Map(o.map((d,m)=>[d,m+1])),i=U(r),c=o.length+1,u=ke({graph:e,span:s,rowY:d=>{let m=d.stable;return((m?a.get(Ie(m.refName).sample):void 0)??c)*20},positions:i}),l=[{label:Ie(r[0].stable.refName).sample,y:0},...o.map(d=>({label:d,y:a.get(d)*20}))];return{nodePositions:i,rowLabels:l,sampleRows:o,referenceAxis:!0,pixelRows:!0,alleleDeletions:u}}function Xt(e){let t=X(e);if(t.length!==0)return{nodePositions:U(t),referenceAxis:!0,pixelRows:!0}}var Pr="Force-directed layout",K=e=>e.nodes.some(S),Ut=e=>K(e)&&(e.paths?.length??0)>1,Yt=e=>K(e)&&e.nodes.some(Se),Ve=[{value:"auto",label:"Anchored",description:"x is reference bp, one row per stable rank. Needs rGFA tags or a reference path.",run:Dt,available:K,drawsLocally:K},{value:"samplerows",label:"Sample rows",description:"x is reference bp, one row per contributing assembly. Needs rGFA tags or a reference path.",run:Ft,available:Yt,drawsLocally:Yt},{value:"walkrows",label:"Walk rows",description:"x is each walk's own bp: one bar per haplotype, sequence the reference also carries in blue and sequence it does not in purple, so a repeat expansion reads as bar length. Needs W or P lines.",run:Bt,available:Ut,drawsLocally:Ut},{value:"ordered",label:"Ordered",description:"x is reference order, not bp: every node gets room, bubbles read as lenses. Needs rGFA tags or a reference path.",run:zt,available:K,drawsLocally:K},{value:"variants",label:"Variant map",description:"The reference as a line with one typed glyph per bubble, from the bubble index or from the graph itself: SNP, indel, deletion, inversion, repeat array. Click a glyph to open the graph inside it.",run:Xt,available:K,drawsLocally:K},{value:"force",label:Pr,description:"OGDF FMMM, via the external Bandage engine.",run:()=>{},available:()=>!0,drawsLocally:()=>!1}],ea=Ve.map(e=>e.value);function ta(e,t){return!Dr(e).drawsLocally(t)}function Dr(e){return Ve.find(t=>t.value===e)??Ve[0]}function Hr(e,t){return Math.abs(t-e)<=.1*Math.max(e,t)}function $r(e,t){let n=e.length,r=t.length,o=Array.from({length:n+1},()=>new Array(r+1).fill(0)),s=Array.from({length:n+1},()=>new Array(r+1).fill(!1));for(let i=n-1;i>=0;i--)for(let c=r-1;c>=0;c--){let u=Math.abs(e[i]-t[c])+o[i+1][c+1],p=n-i>r-c?o[i+1][c]:1/0,l=r-c>n-i?o[i][c+1]:1/0;o[i][c]=Math.min(u,p,l),s[i][c]=o[i][c]===u}let a=new Array(n).fill(void 0);for(let i=0,c=0;i<n&&c<r;)s[i][c]?a[i++]=c++:n-i>r-c?i++:c++;return a}function Kt(e,t){return e.map((n,r)=>({item:n,i:r})).sort((n,r)=>t(n.item)-t(r.item))}var Vt=e=>e.spanningReads!==0;function Wr(e,t){let n=new Map,r=new Set,o=Kt(e,a=>a.bp),s=[[o.filter(a=>a.item.complete),t.filter(Vt)],[o,t]];for(let[a,i]of s){let c=a.filter(p=>!n.has(p.i)),u=Kt(i.filter(p=>!r.has(p)),p=>p.bp);$r(c.map(p=>p.item.bp),u.map(p=>p.item.bp)).forEach((p,l)=>{if(p!==void 0){let d=c[l],m=u[p].item;r.add(m),n.set(d.i,{...m,agrees:d.item.complete&&Vt(m)?Hr(d.item.bp,m.bp):void 0})}})}return n}function ra(e,t){if(!t)return e;let n=new Map,r=new Map;for(let o of e)r.set(o.sample,[...r.get(o.sample)??[],o]);for(let[o,s]of r){let a=t[o];if(a)for(let[i,c]of Wr(s,a))n.set(s[i],c)}return e.map(o=>({...o,call:n.get(o)}))}export{Q as a,Be as b,dr as c,S as d,X as e,ot as f,Zt as g,es as h,ts as i,Ct as j,os as k,ss as l,ee as m,cs as n,ds as o,ls as p,us as q,uo as r,po as s,fo as t,mt as u,_e as v,ht as w,Cr as x,yr as y,fs as z,go as A,yo as B,bs as C,gs as D,ys as E,xs as F,se as G,Qr as H,rn as I,eo as J,he as K,pn as L,Tt as M,Rr as N,Pr as O,Ve as P,ea as Q,ta as R,Dr as S,jt as T,Kr as U,nt as V,rt as W,Vr as X,on as Y,ro as Z,oo as _,Ur as $,gt as aa,Xn as ba,_o as ca,vo as da,ra as ea,ko as fa,To as ga,or as ha,Bo as ia,Po as ja,Fe as ka,jo as la,qo as ma,cr as na};
|
|
2
|
+
//# sourceMappingURL=chunk-7T2HTRP3.js.map
|