jbrowse-plugin-graphgenomeviewer 4.0.12 → 4.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/README.md +21 -5
  2. package/dist/chunks/GbzBaseSyntenyAdapter-Y5NBXK7P.js +8 -0
  3. package/dist/chunks/{GbzBaseSyntenyAdapter-5ZQ2IPHJ.js.map → GbzBaseSyntenyAdapter-Y5NBXK7P.js.map} +3 -3
  4. package/dist/chunks/{GraphGenomeView-SRR7EJFX.js → GraphGenomeView-TTQEJJQD.js} +2 -2
  5. package/dist/chunks/{GraphGenomeView-SRR7EJFX.js.map → GraphGenomeView-TTQEJJQD.js.map} +1 -1
  6. package/dist/chunks/GraphTrackSettingsDialog-3A2PKZRI.js +4 -0
  7. package/dist/chunks/{GraphTrackSettingsDialog-LZITZ3VD.js.map → GraphTrackSettingsDialog-3A2PKZRI.js.map} +1 -1
  8. package/dist/chunks/LinearGraphDisplay-MJ5XZFE5.js +2 -0
  9. package/dist/chunks/{LinearGraphDisplay-J3KVTK4C.js.map → LinearGraphDisplay-MJ5XZFE5.js.map} +1 -1
  10. package/dist/chunks/{MinigraphBubbleAdapter-QTXGK7DW.js → MinigraphBubbleAdapter-APC7JYOM.js} +2 -2
  11. package/dist/chunks/{RgfaTabixAdapter-O3ERR2GY.js → RgfaTabixAdapter-4E365PXO.js} +2 -2
  12. package/dist/chunks/{chunk-LGGAXAS6.js → chunk-5DP7IXD3.js} +2 -2
  13. package/dist/chunks/chunk-CJ56O2VG.js +2 -0
  14. package/dist/chunks/chunk-CJ56O2VG.js.map +7 -0
  15. package/dist/chunks/chunk-EFVAQ2KM.js +2 -0
  16. package/dist/chunks/chunk-EFVAQ2KM.js.map +7 -0
  17. package/dist/chunks/chunk-IFRDWMQ2.js +2 -0
  18. package/dist/chunks/chunk-IFRDWMQ2.js.map +7 -0
  19. package/dist/chunks/chunk-JAQ2RQAE.js +2 -0
  20. package/dist/chunks/{chunk-QRVREF7H.js.map → chunk-JAQ2RQAE.js.map} +4 -4
  21. package/dist/chunks/{chunk-WETM2CD7.js → chunk-LA7MQS33.js} +2 -2
  22. package/dist/chunks/chunk-M4YEAXSR.js +2 -0
  23. package/dist/chunks/chunk-M4YEAXSR.js.map +7 -0
  24. package/dist/chunks/chunk-XDOIZTY6.js +4 -0
  25. package/dist/chunks/chunk-XDOIZTY6.js.map +7 -0
  26. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js +2 -2
  27. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js.map +4 -4
  28. package/package.json +3 -3
  29. package/src/GraphGenomeView/components/GraphCanvas.tsx +4 -11
  30. package/src/GraphGenomeView/components/TubeMapOverlay.tsx +117 -4
  31. package/src/GraphGenomeView/components/WalkRowsOverlay.tsx +261 -44
  32. package/src/GraphGenomeView/components/referenceRampCss.test.ts +27 -0
  33. package/src/GraphGenomeView/components/referenceRampCss.ts +39 -0
  34. package/src/GraphGenomeView/genes/genes.test.ts +9 -2
  35. package/src/GraphGenomeView/host.test.ts +25 -2
  36. package/src/GraphGenomeView/host.ts +9 -7
  37. package/src/GraphGenomeView/model.test.ts +383 -4
  38. package/src/GraphGenomeView/model.ts +413 -88
  39. package/src/GraphGenomeView/repeats/repeatFeatures.test.ts +75 -0
  40. package/src/GraphGenomeView/repeats/repeatFeatures.ts +156 -8
  41. package/src/GraphGenomeView/repeats/walkCalls.test.ts +18 -0
  42. package/src/GraphGenomeView/repeats/walkCalls.ts +35 -18
  43. package/src/GraphGenomeView/subgraphLoad.test.ts +1 -0
  44. package/src/LinearGraphDisplay/LinearGraphDisplay.test.ts +165 -6
  45. package/src/LinearGraphDisplay/model.ts +61 -1
  46. package/src/gaf/gafFile.test.ts +18 -0
  47. package/src/version.ts +1 -1
  48. package/dist/chunks/GbzBaseSyntenyAdapter-5ZQ2IPHJ.js +0 -8
  49. package/dist/chunks/GraphTrackSettingsDialog-LZITZ3VD.js +0 -4
  50. package/dist/chunks/LinearGraphDisplay-J3KVTK4C.js +0 -2
  51. package/dist/chunks/chunk-ADEBM7AA.js +0 -2
  52. package/dist/chunks/chunk-ADEBM7AA.js.map +0 -7
  53. package/dist/chunks/chunk-J7CABMMI.js +0 -2
  54. package/dist/chunks/chunk-J7CABMMI.js.map +0 -7
  55. package/dist/chunks/chunk-LBHU3DHN.js +0 -4
  56. package/dist/chunks/chunk-LBHU3DHN.js.map +0 -7
  57. package/dist/chunks/chunk-QRVREF7H.js +0 -2
  58. /package/dist/chunks/{MinigraphBubbleAdapter-QTXGK7DW.js.map → MinigraphBubbleAdapter-APC7JYOM.js.map} +0 -0
  59. /package/dist/chunks/{RgfaTabixAdapter-O3ERR2GY.js.map → RgfaTabixAdapter-4E365PXO.js.map} +0 -0
  60. /package/dist/chunks/{chunk-LGGAXAS6.js.map → chunk-5DP7IXD3.js.map} +0 -0
  61. /package/dist/chunks/{chunk-WETM2CD7.js.map → chunk-LA7MQS33.js.map} +0 -0
@@ -1,4 +1,4 @@
1
- import{a as x}from"./chunk-LBHU3DHN.js";import"./chunk-J7CABMMI.js";import"./chunk-VAGPKHHS.js";import"./chunk-SCMIJAAX.js";import"./chunk-FCWXYIFC.js";import"./chunk-WETM2CD7.js";import{H as L}from"./chunk-ADEBM7AA.js";import"./chunk-MUK3KYB4.js";import{a as s,b as g,c as v,d as G,e as B}from"./chunk-XEJ47DLD.js";import{b as a}from"./chunk-FY3BTKY4.js";var S=a(g(),1);var m=a(G(),1),n=a(v(),1),C=a(g(),1),P=a(L(),1),o=a(s(),1),I=(0,P.makeStyles)()({paper:{padding:16,margin:8,maxWidth:560,marginInline:"auto",display:"flex",flexDirection:"column",gap:12},row:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8}}),b=(0,C.observer)(function({model:e}){let{classes:r}=I();return e.isLoading?(0,o.jsxs)(n.Paper,{className:r.paper,"data-testid":"graph-genome-loading",children:[(0,o.jsxs)("div",{className:r.row,children:[(0,o.jsx)(m.LoadingEllipses,{variant:"h6",message:e.statusMessage}),(0,o.jsx)(n.Button,{size:"small","data-testid":"graph-genome-cancel",onClick:()=>{e.cancelLoad()},children:"Cancel"})]}),(0,o.jsx)(n.LinearProgress,{variant:"indeterminate"})]}):e.error?(0,o.jsx)(n.Paper,{className:r.paper,children:(0,o.jsx)(m.ErrorBanner,{error:e.error,onReset:()=>{e.retryLoad()}})}):(0,o.jsx)(n.Paper,{className:r.paper,"data-testid":"graph-genome-load-canceled",children:(0,o.jsxs)("div",{className:r.row,children:[(0,o.jsx)(n.Typography,{variant:"h6",children:"Loading canceled"}),(0,o.jsx)(n.Button,{variant:"contained",size:"small","data-testid":"graph-genome-retry",onClick:()=>{e.retryLoad()},children:"Retry"})]})})}),h=b;var M=a(B(),1),N=a(G(),1),i=a(v(),1),w=a(g(),1),E=a(L(),1),t=a(s(),1),k=`H VN:Z:1.0
1
+ import{a as x}from"./chunk-XDOIZTY6.js";import"./chunk-CJ56O2VG.js";import"./chunk-VAGPKHHS.js";import"./chunk-SCMIJAAX.js";import"./chunk-FCWXYIFC.js";import"./chunk-LA7MQS33.js";import{A as L}from"./chunk-M4YEAXSR.js";import"./chunk-EFVAQ2KM.js";import"./chunk-MUK3KYB4.js";import{a as s,b as g,c as v,d as G,e as B}from"./chunk-XEJ47DLD.js";import{b as a}from"./chunk-FY3BTKY4.js";var S=a(g(),1);var m=a(G(),1),n=a(v(),1),C=a(g(),1),P=a(L(),1),o=a(s(),1),I=(0,P.makeStyles)()({paper:{padding:16,margin:8,maxWidth:560,marginInline:"auto",display:"flex",flexDirection:"column",gap:12},row:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8}}),b=(0,C.observer)(function({model:e}){let{classes:r}=I();return e.isLoading?(0,o.jsxs)(n.Paper,{className:r.paper,"data-testid":"graph-genome-loading",children:[(0,o.jsxs)("div",{className:r.row,children:[(0,o.jsx)(m.LoadingEllipses,{variant:"h6",message:e.statusMessage}),(0,o.jsx)(n.Button,{size:"small","data-testid":"graph-genome-cancel",onClick:()=>{e.cancelLoad()},children:"Cancel"})]}),(0,o.jsx)(n.LinearProgress,{variant:"indeterminate"})]}):e.error?(0,o.jsx)(n.Paper,{className:r.paper,children:(0,o.jsx)(m.ErrorBanner,{error:e.error,onReset:()=>{e.retryLoad()}})}):(0,o.jsx)(n.Paper,{className:r.paper,"data-testid":"graph-genome-load-canceled",children:(0,o.jsxs)("div",{className:r.row,children:[(0,o.jsx)(n.Typography,{variant:"h6",children:"Loading canceled"}),(0,o.jsx)(n.Button,{variant:"contained",size:"small","data-testid":"graph-genome-retry",onClick:()=>{e.retryLoad()},children:"Retry"})]})})}),h=b;var M=a(B(),1),N=a(G(),1),i=a(v(),1),w=a(g(),1),E=a(L(),1),t=a(s(),1),k=`H VN:Z:1.0
2
2
  S 1 ACGT
3
3
  S 2 GGCC
4
4
  S 3 TTAA
@@ -7,4 +7,4 @@ L 1 + 2 + 0M
7
7
  L 1 + 3 + 0M
8
8
  L 2 + 4 + 0M
9
9
  L 3 + 4 + 0M`,z=(0,E.makeStyles)()({column:{display:"flex",flexDirection:"column",gap:8},rowEnd:{display:"flex",gap:8,alignItems:"flex-end"},rowCenter:{display:"flex",gap:8,alignItems:"center"},flex1:{flex:1},paper:{padding:16,margin:8,maxWidth:560,marginInline:"auto"},header:{marginBottom:12},footer:{marginTop:12,display:"flex",justifyContent:"flex-end"}}),R=(0,w.observer)(function({model:e}){let{classes:r}=z(),[d,T]=(0,M.useState)("");function y(){d.trim()&&e.loadGFAFromLocation({uri:d,locationType:"UriLocation"})}function A(p){let c=p.target.files?.[0];c&&c.text().then(f=>e.loadGFA(f,c.name)).catch(f=>{e.setError(f)})}return(0,t.jsxs)(i.Paper,{className:r.paper,children:[(0,t.jsx)("div",{className:r.header,children:(0,t.jsx)(i.Typography,{variant:"h6",children:"Load a GFA graph"})}),(0,t.jsxs)("div",{className:r.column,children:[(0,t.jsxs)("div",{className:r.rowCenter,children:[(0,t.jsxs)(i.Button,{variant:"outlined",component:"label",size:"small",children:["Choose file",(0,t.jsx)("input",{type:"file",accept:".gfa,.gfa1,.gfa2",hidden:!0,onChange:p=>{A(p)}})]}),(0,t.jsx)(i.Typography,{variant:"caption",color:"text.secondary",children:"Whole-file GFA; best for small/medium graphs."})]}),(0,t.jsxs)("div",{className:r.rowEnd,children:[(0,t.jsx)(i.TextField,{size:"small",label:"URL",placeholder:"https://example.com/graph.gfa",value:d,onChange:p=>{T(p.target.value)},onKeyDown:p=>{p.key==="Enter"&&y()},className:r.flex1}),(0,t.jsx)(i.Button,{variant:"contained",onClick:()=>{y()},disabled:!d.trim(),children:"Open"})]})]}),(0,t.jsx)("div",{className:r.footer,children:(0,t.jsx)(i.Button,{size:"small",onClick:()=>{e.loadGFA(k,"Example graph")},children:"Load 4-node example"})}),e.error?(0,t.jsx)(N.ErrorBanner,{error:e.error}):null]})}),F=R;var l=a(s(),1),U=(0,S.observer)(function({model:e}){return e.hasGraph?(0,l.jsx)(x,{model:e}):e.canRetryLoad&&(e.error||e.loadCanceled)?(0,l.jsx)(h,{model:e}):(0,l.jsxs)(l.Fragment,{children:[e.isLoading?(0,l.jsx)(h,{model:e}):null,(0,l.jsx)("div",{hidden:e.isLoading,children:(0,l.jsx)(F,{model:e})})]})}),O=U;export{O as default};
10
- //# sourceMappingURL=GraphGenomeView-SRR7EJFX.js.map
10
+ //# sourceMappingURL=GraphGenomeView-TTQEJJQD.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/GraphGenomeView/components/GraphGenomeView.tsx", "../../src/GraphGenomeView/components/GraphLoadStatus.tsx", "../../src/GraphGenomeView/components/ImportForm.tsx"],
4
4
  "sourcesContent": ["import { observer } from 'mobx-react'\n\nimport GraphCanvas from './GraphCanvas'\nimport GraphLoadStatus from './GraphLoadStatus'\nimport ImportForm from './ImportForm'\n\nimport type { GraphPaneModel } from '../model'\n\nconst GraphGenomeView = observer(function GraphGenomeView({\n model,\n}: {\n model: GraphPaneModel\n}) {\n if (model.hasGraph) {\n return <GraphCanvas model={model} />\n }\n // A launched or restored view has a source of its own, so the import form\n // has nothing to offer it when that source fails\n if (model.canRetryLoad && (model.error || model.loadCanceled)) {\n return <GraphLoadStatus model={model} />\n }\n // Hidden rather than unmounted, so a typed URL survives a failed load\n return (\n <>\n {model.isLoading ? <GraphLoadStatus model={model} /> : null}\n <div hidden={model.isLoading}>\n <ImportForm model={model} />\n </div>\n </>\n )\n})\n\nexport default GraphGenomeView\n", "import { ErrorBanner, LoadingEllipses } from '@jbrowse/core/ui'\nimport { Button, LinearProgress, Paper, Typography } from '@mui/material'\nimport { observer } from 'mobx-react'\nimport { makeStyles } from 'tss-react/mui'\n\nimport type { GraphPaneModel } from '../model'\n\nconst useStyles = makeStyles()({\n paper: {\n padding: 16,\n margin: 8,\n maxWidth: 560,\n marginInline: 'auto',\n display: 'flex',\n flexDirection: 'column',\n gap: 12,\n },\n row: {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n gap: 8,\n },\n})\n\n// What a view with no graph on screen shows while its load runs, and after a\n// load of a source it can retry was canceled or failed.\nconst GraphLoadStatus = observer(function GraphLoadStatus({\n model,\n}: {\n model: GraphPaneModel\n}) {\n const { classes } = useStyles()\n if (model.isLoading) {\n return (\n <Paper className={classes.paper} data-testid=\"graph-genome-loading\">\n <div className={classes.row}>\n <LoadingEllipses variant=\"h6\" message={model.statusMessage} />\n <Button\n size=\"small\"\n data-testid=\"graph-genome-cancel\"\n onClick={() => {\n model.cancelLoad()\n }}\n >\n Cancel\n </Button>\n </div>\n <LinearProgress variant=\"indeterminate\" />\n </Paper>\n )\n }\n if (model.error) {\n return (\n <Paper className={classes.paper}>\n <ErrorBanner\n error={model.error}\n onReset={() => {\n model.retryLoad()\n }}\n />\n </Paper>\n )\n }\n return (\n <Paper className={classes.paper} data-testid=\"graph-genome-load-canceled\">\n <div className={classes.row}>\n <Typography variant=\"h6\">Loading canceled</Typography>\n <Button\n variant=\"contained\"\n size=\"small\"\n data-testid=\"graph-genome-retry\"\n onClick={() => {\n model.retryLoad()\n }}\n >\n Retry\n </Button>\n </div>\n </Paper>\n )\n})\n\nexport default GraphLoadStatus\n", "import { useState } from 'react'\n\nimport { ErrorBanner } from '@jbrowse/core/ui'\nimport { Button, Paper, TextField, Typography } from '@mui/material'\nimport { observer } from 'mobx-react'\nimport { makeStyles } from 'tss-react/mui'\n\nimport type { GraphPaneModel } from '../model'\n\nconst EXAMPLE_GFA = `H\\tVN:Z:1.0\nS\\t1\\tACGT\nS\\t2\\tGGCC\nS\\t3\\tTTAA\nS\\t4\\tCCGG\nL\\t1\\t+\\t2\\t+\\t0M\nL\\t1\\t+\\t3\\t+\\t0M\nL\\t2\\t+\\t4\\t+\\t0M\nL\\t3\\t+\\t4\\t+\\t0M`\n\nconst useStyles = makeStyles()({\n column: { display: 'flex', flexDirection: 'column', gap: 8 },\n rowEnd: { display: 'flex', gap: 8, alignItems: 'flex-end' },\n rowCenter: { display: 'flex', gap: 8, alignItems: 'center' },\n flex1: { flex: 1 },\n paper: { padding: 16, margin: 8, maxWidth: 560, marginInline: 'auto' },\n header: { marginBottom: 12 },\n footer: { marginTop: 12, display: 'flex', justifyContent: 'flex-end' },\n})\n\nconst ImportForm = observer(function ImportForm({\n model,\n}: {\n model: GraphPaneModel\n}) {\n const { classes } = useStyles()\n const [url, setUrl] = useState('')\n\n function handleUrlLoad() {\n if (url.trim()) {\n void model.loadGFAFromLocation({ uri: url, locationType: 'UriLocation' })\n }\n }\n\n function handleFileUpload(event: React.ChangeEvent<HTMLInputElement>) {\n const file = event.target.files?.[0]\n if (file) {\n file\n .text()\n .then(text => model.loadGFA(text, file.name))\n .catch((err: unknown) => {\n model.setError(err)\n })\n }\n }\n\n return (\n <Paper className={classes.paper}>\n <div className={classes.header}>\n <Typography variant=\"h6\">Load a GFA graph</Typography>\n </div>\n\n <div className={classes.column}>\n <div className={classes.rowCenter}>\n <Button variant=\"outlined\" component=\"label\" size=\"small\">\n Choose file\n <input\n type=\"file\"\n accept=\".gfa,.gfa1,.gfa2\"\n hidden\n onChange={event => {\n handleFileUpload(event)\n }}\n />\n </Button>\n <Typography variant=\"caption\" color=\"text.secondary\">\n Whole-file GFA; best for small/medium graphs.\n </Typography>\n </div>\n\n <div className={classes.rowEnd}>\n <TextField\n size=\"small\"\n label=\"URL\"\n placeholder=\"https://example.com/graph.gfa\"\n value={url}\n onChange={e => {\n setUrl(e.target.value)\n }}\n onKeyDown={e => {\n if (e.key === 'Enter') {\n handleUrlLoad()\n }\n }}\n className={classes.flex1}\n />\n <Button\n variant=\"contained\"\n onClick={() => {\n handleUrlLoad()\n }}\n disabled={!url.trim()}\n >\n Open\n </Button>\n </div>\n </div>\n\n <div className={classes.footer}>\n <Button\n size=\"small\"\n onClick={() => {\n void model.loadGFA(EXAMPLE_GFA, 'Example graph')\n }}\n >\n Load 4-node example\n </Button>\n </div>\n\n {model.error ? <ErrorBanner error={model.error} /> : null}\n </Paper>\n )\n})\n\nexport default ImportForm\n"],
5
- "mappings": "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",
5
+ "mappings": "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",
6
6
  "names": ["import_mobx_react", "import_ui", "import_material", "import_mobx_react", "import_mui", "import_jsx_runtime", "useStyles", "GraphLoadStatus", "model", "classes", "GraphLoadStatus_default", "import_react", "import_ui", "import_material", "import_mobx_react", "import_mui", "import_jsx_runtime", "EXAMPLE_GFA", "useStyles", "ImportForm", "model", "classes", "url", "setUrl", "handleUrlLoad", "handleFileUpload", "event", "file", "text", "err", "e", "ImportForm_default", "import_jsx_runtime", "GraphGenomeView", "model", "GraphCanvas_default", "GraphLoadStatus_default", "ImportForm_default", "GraphGenomeView_default"]
7
7
  }
@@ -0,0 +1,4 @@
1
+ import{a as g}from"./chunk-LA7MQS33.js";import{A as f}from"./chunk-M4YEAXSR.js";import"./chunk-EFVAQ2KM.js";import"./chunk-MUK3KYB4.js";import{a as l,b as m,c as y,e as x}from"./chunk-XEJ47DLD.js";import{b as o}from"./chunk-FY3BTKY4.js";var a=o(y(),1),b=o(m(),1),S=o(f(),1),n=o(l(),1),L=(0,S.makeStyles)()({section:{marginBottom:24},formControl:{minWidth:200}}),w=[{value:0,label:"None"},{value:1,label:"1 hop"},{value:2,label:"2 hops"}],k=(0,b.observer)(function({model:e}){let{classes:t}=L();return(0,n.jsxs)("div",{className:t.section,children:[(0,n.jsxs)(a.FormControl,{className:t.formControl,children:[(0,n.jsx)(a.InputLabel,{children:"Graph context"}),(0,n.jsx)(a.Select,{value:e.subgraphContext,label:"Graph context","data-testid":"graph-context-select",onChange:p=>{e.setSubgraphContext(p.target.value),e.cut()},children:w.map(({value:p,label:u})=>(0,n.jsx)(a.MenuItem,{value:p,children:u},p))})]}),(0,n.jsx)(a.Typography,{variant:"caption",color:"text.secondary",children:"How far the cut follows links out of the region, one hop by default. A detour that leaves the reference before the window and rejoins after it is indexed under its own sequence, so at none its middle is missing and the one bubble draws as two unrelated stubs. Each hop costs a query per off-reference segment already reached."})]})}),v=k;var C=o(x(),1),d=o(y(),1),c=o(m(),1),G=o(f(),1),i=o(l(),1),T=(0,G.makeStyles)()({section:{marginBottom:24}});function M(r){let e=r.split(/[\s,]+/).map(t=>t.trim()).filter(t=>t!=="");return e.length===0?void 0:e}var F=(0,c.observer)(function({model:e}){let[t,p]=(0,C.useState)(e.chosenHaplotypes?.join(", ")??""),u=()=>{let s=M(t)??[];s.join(`
2
+ `)===(e.chosenHaplotypes??[]).join(`
3
+ `)||(e.setSubgraphHaplotypes(s),e.cut())};return(0,i.jsx)(d.TextField,{fullWidth:!0,label:"Haplotypes",placeholder:"every haplotype",value:t,slotProps:{htmlInput:{"data-testid":"graph-haplotypes-field"}},onChange:s=>{p(s.target.value)},onBlur:()=>{u()},onKeyDown:s=>{s.key==="Enter"&&u()}})}),N=(0,c.observer)(function({model:e}){let{classes:t}=T();return e.adapterConfig.type==="GbzBaseSyntenyAdapter"?(0,i.jsxs)("div",{className:t.section,children:[(0,i.jsx)(F,{model:e},e.chosenHaplotypes?.join(",")??""),(0,i.jsx)(d.Typography,{variant:"caption",color:"text.secondary",children:"The haplotypes the cut is for, as lane assembly names or PanSN prefixes (HG002#1, or HG002 for both), separated by commas. The cut keeps their walks and the nodes those walks visit, with the reference. Empty is every haplotype."})]}):null}),H=N;var h=o(l(),1);function B({model:r,open:e,onClose:t}){return(0,h.jsxs)(g,{model:r,open:e,onClose:t,children:[(0,h.jsx)(v,{model:r}),(0,h.jsx)(H,{model:r})]})}export{B as default};
4
+ //# sourceMappingURL=GraphTrackSettingsDialog-3A2PKZRI.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/LinearGraphDisplay/components/SubgraphContextSelect.tsx", "../../src/LinearGraphDisplay/components/SubgraphHaplotypesField.tsx", "../../src/LinearGraphDisplay/components/GraphTrackSettingsDialog.tsx"],
4
4
  "sourcesContent": ["import {\n FormControl,\n InputLabel,\n MenuItem,\n Select,\n Typography,\n} from '@mui/material'\nimport { observer } from 'mobx-react'\nimport { makeStyles } from 'tss-react/mui'\n\nimport type { LinearGraphCutModel } from '../model'\n\nconst useStyles = makeStyles()({\n section: {\n marginBottom: 24,\n },\n formControl: {\n minWidth: 200,\n },\n})\n\n// Hops past the region's own segments, each costing a tabix query per\n// off-reference segment already reached. One is the default: at none a single\n// detour draws as two unrelated stubs, which is a wrong picture of the graph\n// rather than a cheaper one. Two exists for a graph whose alleles have alleles\n// (HPRC's amylase window keeps growing at 2, the E. coli paa locus does not), and\n// it stops there because a frontier is still not a bubble decomposition. Cut an\n// exact slice with gfatools when that is what is wanted.\nconst SUBGRAPH_CONTEXTS = [\n { value: 0, label: 'None' },\n { value: 1, label: '1 hop' },\n { value: 2, label: '2 hops' },\n]\n\nconst SubgraphContextSelect = observer(function SubgraphContextSelect({\n model,\n}: {\n model: LinearGraphCutModel\n}) {\n const { classes } = useStyles()\n return (\n <div className={classes.section}>\n <FormControl className={classes.formControl}>\n <InputLabel>Graph context</InputLabel>\n <Select\n value={model.subgraphContext}\n label=\"Graph context\"\n data-testid=\"graph-context-select\"\n onChange={e => {\n model.setSubgraphContext(e.target.value)\n void model.cut()\n }}\n >\n {SUBGRAPH_CONTEXTS.map(({ value, label }) => (\n <MenuItem key={value} value={value}>\n {label}\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n <Typography variant=\"caption\" color=\"text.secondary\">\n How far the cut follows links out of the region, one hop by default. A\n detour that leaves the reference before the window and rejoins after it\n is indexed under its own sequence, so at none its middle is missing and\n the one bubble draws as two unrelated stubs. Each hop costs a query per\n off-reference segment already reached.\n </Typography>\n </div>\n )\n})\n\nexport default SubgraphContextSelect\n", "import { useState } from 'react'\n\nimport { TextField, Typography } from '@mui/material'\nimport { observer } from 'mobx-react'\nimport { makeStyles } from 'tss-react/mui'\n\nimport type { LinearGraphCutModel } from '../model'\n\nconst useStyles = makeStyles()({\n section: {\n marginBottom: 24,\n },\n})\n\nexport function parseHaplotypeList(text: string) {\n const names = text\n .split(/[\\s,]+/)\n .map(name => name.trim())\n .filter(name => name !== '')\n return names.length === 0 ? undefined : names\n}\n\nconst HaplotypeListField = observer(function HaplotypeListField({\n model,\n}: {\n model: LinearGraphCutModel\n}) {\n const [draft, setDraft] = useState(model.chosenHaplotypes?.join(', ') ?? '')\n const apply = () => {\n const parsed = parseHaplotypeList(draft) ?? []\n const unchanged =\n parsed.join('\\n') === (model.chosenHaplotypes ?? []).join('\\n')\n if (!unchanged) {\n model.setSubgraphHaplotypes(parsed)\n void model.cut()\n }\n }\n return (\n <TextField\n fullWidth\n label=\"Haplotypes\"\n placeholder=\"every haplotype\"\n value={draft}\n slotProps={{ htmlInput: { 'data-testid': 'graph-haplotypes-field' } }}\n onChange={e => {\n setDraft(e.target.value)\n }}\n onBlur={() => {\n apply()\n }}\n onKeyDown={e => {\n if (e.key === 'Enter') {\n apply()\n }\n }}\n />\n )\n})\n\n// Only a GBZ cut reads the set. The inner field is keyed on it so an outside\n// change (a restored session, a launch) resets the draft rather than fighting\n// it.\nconst SubgraphHaplotypesField = observer(function SubgraphHaplotypesField({\n model,\n}: {\n model: LinearGraphCutModel\n}) {\n const { classes } = useStyles()\n return model.adapterConfig.type === 'GbzBaseSyntenyAdapter' ? (\n <div className={classes.section}>\n <HaplotypeListField\n key={model.chosenHaplotypes?.join(',') ?? ''}\n model={model}\n />\n <Typography variant=\"caption\" color=\"text.secondary\">\n The haplotypes the cut is for, as lane assembly names or PanSN prefixes\n (HG002#1, or HG002 for both), separated by commas. The cut keeps their\n walks and the nodes those walks visit, with the reference. Empty is\n every haplotype.\n </Typography>\n </div>\n ) : null\n})\n\nexport default SubgraphHaplotypesField\n", "import SubgraphContextSelect from './SubgraphContextSelect'\nimport SubgraphHaplotypesField from './SubgraphHaplotypesField'\nimport GraphSettingsDialog from '../../GraphGenomeView/components/GraphSettingsDialog'\n\nimport type { LinearGraphCutModel } from '../model'\n\nexport default function GraphTrackSettingsDialog({\n model,\n open,\n onClose,\n}: {\n model: LinearGraphCutModel\n open: boolean\n onClose: () => void\n}) {\n return (\n <GraphSettingsDialog model={model} open={open} onClose={onClose}>\n <SubgraphContextSelect model={model} />\n <SubgraphHaplotypesField model={model} />\n </GraphSettingsDialog>\n )\n}\n"],
5
- "mappings": "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",
5
+ "mappings": "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",
6
6
  "names": ["import_material", "import_mobx_react", "import_mui", "import_jsx_runtime", "useStyles", "SUBGRAPH_CONTEXTS", "SubgraphContextSelect", "model", "classes", "e", "value", "label", "SubgraphContextSelect_default", "import_react", "import_material", "import_mobx_react", "import_mui", "import_jsx_runtime", "useStyles", "parseHaplotypeList", "text", "names", "name", "HaplotypeListField", "model", "draft", "setDraft", "apply", "parsed", "e", "SubgraphHaplotypesField", "classes", "SubgraphHaplotypesField_default", "import_jsx_runtime", "GraphTrackSettingsDialog", "model", "open", "onClose", "GraphSettingsDialog_default", "SubgraphContextSelect_default", "SubgraphHaplotypesField_default"]
7
7
  }
@@ -0,0 +1,2 @@
1
+ import{a as i}from"./chunk-XDOIZTY6.js";import"./chunk-CJ56O2VG.js";import"./chunk-VAGPKHHS.js";import"./chunk-SCMIJAAX.js";import"./chunk-FCWXYIFC.js";import"./chunk-LA7MQS33.js";import"./chunk-M4YEAXSR.js";import"./chunk-EFVAQ2KM.js";import"./chunk-MUK3KYB4.js";import{a as e,b as d}from"./chunk-XEJ47DLD.js";import{a as h,b as t}from"./chunk-FY3BTKY4.js";var p=h((l,o)=>{o.exports=JBrowseExports["@jbrowse/display-kit/DisplayChrome"]});var s=t(p(),1),n=t(d(),1);var r=t(e(),1),y=(0,n.observer)(function({model:a}){return(0,r.jsx)(s.DisplayStatusChrome,{model:a,phase:a.displayPhase,drawn:a.painted&&a.geometryPainted,testid:"linear-graph-display","data-layout":a.chosenLayoutMode,"data-cut-tier":a.cutTier,"data-recuts":a.recuts,"data-node-count":a.hasGraph?a.nodeCount:void 0,"data-loading":a.isLoading?"":void 0,style:{width:a.paneWidth,height:a.height,overflow:"hidden"},children:(0,r.jsx)(i,{model:a,ownChrome:!1})})}),c=y;export{c as default};
2
+ //# sourceMappingURL=LinearGraphDisplay-MJ5XZFE5.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["global-externals:@jbrowse/display-kit/DisplayChrome", "../../src/LinearGraphDisplay/components/LinearGraphDisplay.tsx"],
4
4
  "sourcesContent": ["module.exports = JBrowseExports[\"@jbrowse/display-kit/DisplayChrome\"];", "import { DisplayStatusChrome } from '@jbrowse/display-kit/DisplayChrome'\nimport { observer } from 'mobx-react'\n\nimport GraphCanvas from '../../GraphGenomeView/components/GraphCanvas'\n\nimport type { LinearGraphDisplayModel } from '../model'\n\nconst LinearGraphDisplay = observer(function LinearGraphDisplay({\n model,\n}: {\n model: LinearGraphDisplayModel\n}) {\n return (\n <DisplayStatusChrome\n model={model}\n phase={model.displayPhase}\n drawn={model.painted && model.geometryPainted}\n testid=\"linear-graph-display\"\n data-layout={model.chosenLayoutMode}\n data-cut-tier={model.cutTier}\n data-recuts={model.recuts}\n data-node-count={model.hasGraph ? model.nodeCount : undefined}\n data-loading={model.isLoading ? '' : undefined}\n style={{\n width: model.paneWidth,\n height: model.height,\n overflow: 'hidden',\n }}\n >\n <GraphCanvas model={model} ownChrome={false} />\n </DisplayStatusChrome>\n )\n})\n\nexport default LinearGraphDisplay\n"],
5
- "mappings": "0UAAA,IAAAA,EAAAC,EAAA,CAAAC,EAAAC,IAAA,CAAAA,EAAO,QAAU,eAAe,oCAAoC,ICApE,IAAAC,EAAoC,SACpCC,EAAyB,SA4BnB,IAAAC,EAAA,SAtBAC,KAAqB,YAAS,SAA4B,CAC9D,MAAAC,CACF,EAEG,CACD,SACE,OAAC,uBACC,MAAOA,EACP,MAAOA,EAAM,aACb,MAAOA,EAAM,SAAWA,EAAM,gBAC9B,OAAO,uBACP,cAAaA,EAAM,iBACnB,gBAAeA,EAAM,QACrB,cAAaA,EAAM,OACnB,kBAAiBA,EAAM,SAAWA,EAAM,UAAY,OACpD,eAAcA,EAAM,UAAY,GAAK,OACrC,MAAO,CACL,MAAOA,EAAM,UACb,OAAQA,EAAM,OACd,SAAU,QACZ,EAEA,mBAACC,EAAA,CAAY,MAAOD,EAAO,UAAW,GAAO,EAC/C,CAEJ,CAAC,EAEME,EAAQH",
5
+ "mappings": "sWAAA,IAAAA,EAAAC,EAAA,CAAAC,EAAAC,IAAA,CAAAA,EAAO,QAAU,eAAe,oCAAoC,ICApE,IAAAC,EAAoC,SACpCC,EAAyB,SA4BnB,IAAAC,EAAA,SAtBAC,KAAqB,YAAS,SAA4B,CAC9D,MAAAC,CACF,EAEG,CACD,SACE,OAAC,uBACC,MAAOA,EACP,MAAOA,EAAM,aACb,MAAOA,EAAM,SAAWA,EAAM,gBAC9B,OAAO,uBACP,cAAaA,EAAM,iBACnB,gBAAeA,EAAM,QACrB,cAAaA,EAAM,OACnB,kBAAiBA,EAAM,SAAWA,EAAM,UAAY,OACpD,eAAcA,EAAM,UAAY,GAAK,OACrC,MAAO,CACL,MAAOA,EAAM,UACb,OAAQA,EAAM,OACd,SAAU,QACZ,EAEA,mBAACC,EAAA,CAAY,MAAOD,EAAO,UAAW,GAAO,EAC/C,CAEJ,CAAC,EAEME,EAAQH",
6
6
  "names": ["require_DisplayChrome", "__commonJSMin", "exports", "module", "import_DisplayChrome", "import_mobx_react", "import_jsx_runtime", "LinearGraphDisplay", "model", "GraphCanvas_default", "LinearGraphDisplay_default"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{a as m,b as g}from"./chunk-LGGAXAS6.js";import{c as N,d as C}from"./chunk-QRVREF7H.js";import"./chunk-KWAXLUPQ.js";import{a as y}from"./chunk-J4OLMLS5.js";import{a as b,b as p,d as u}from"./chunk-VAGPKHHS.js";import"./chunk-MUK3KYB4.js";import{b as n}from"./chunk-FY3BTKY4.js";var f=n(N(),1),r=n(y(),1),c=n(C(),1);var o=class extends f.BaseFeatureDataAdapter{static{this.capabilities=["getFeatures","getRefNames"]}constructor(t,a,s){super(t,a,s),this.bubbles=m(this,["bubblesLocation"],["index"]),this.refNames=new g(this.bubbles,this)}async getRefNames(t={}){return this.refNames.assemblyRefNames(t)}async hasDataForRefName(){return!0}getFeatures(t,a={}){let{signal:s,statusCallback:d}=a;return(0,c.ObservableCreate)(async i=>{let l=await this.refNames.resolve(t,a);l!==void 0&&await(0,r.updateStatus)("Downloading bubbles",d,()=>this.bubbles.getLines(l,t.start,t.end,{signal:s,lineCallback:(h,A)=>{let e=b(h);i.next(new r.SimpleFeature({uniqueId:`bubble-${A}`,refName:t.refName,start:e.start,end:e.end,name:p(e),description:u(e),type:"bubble",score:e.segmentCount,segmentCount:e.segmentCount,pathCount:e.pathCount,inversion:e.inversion,shortestAlleleLength:e.shortestAlleleLength,longestAlleleLength:e.longestAlleleLength,segments:e.segments,shortestAllele:e.shortestAllele,longestAllele:e.longestAllele}))}})),i.complete()},s)}};export{o as default};
2
- //# sourceMappingURL=MinigraphBubbleAdapter-QTXGK7DW.js.map
1
+ import{a as m,b as g}from"./chunk-5DP7IXD3.js";import{c as N,d as C}from"./chunk-JAQ2RQAE.js";import"./chunk-KWAXLUPQ.js";import{a as y}from"./chunk-J4OLMLS5.js";import{a as b,b as p,d as u}from"./chunk-VAGPKHHS.js";import"./chunk-MUK3KYB4.js";import{b as n}from"./chunk-FY3BTKY4.js";var f=n(N(),1),r=n(y(),1),c=n(C(),1);var o=class extends f.BaseFeatureDataAdapter{static{this.capabilities=["getFeatures","getRefNames"]}constructor(t,a,s){super(t,a,s),this.bubbles=m(this,["bubblesLocation"],["index"]),this.refNames=new g(this.bubbles,this)}async getRefNames(t={}){return this.refNames.assemblyRefNames(t)}async hasDataForRefName(){return!0}getFeatures(t,a={}){let{signal:s,statusCallback:d}=a;return(0,c.ObservableCreate)(async i=>{let l=await this.refNames.resolve(t,a);l!==void 0&&await(0,r.updateStatus)("Downloading bubbles",d,()=>this.bubbles.getLines(l,t.start,t.end,{signal:s,lineCallback:(h,A)=>{let e=b(h);i.next(new r.SimpleFeature({uniqueId:`bubble-${A}`,refName:t.refName,start:e.start,end:e.end,name:p(e),description:u(e),type:"bubble",score:e.segmentCount,segmentCount:e.segmentCount,pathCount:e.pathCount,inversion:e.inversion,shortestAlleleLength:e.shortestAlleleLength,longestAlleleLength:e.longestAlleleLength,segments:e.segments,shortestAllele:e.shortestAllele,longestAllele:e.longestAllele}))}})),i.complete()},s)}};export{o as default};
2
+ //# sourceMappingURL=MinigraphBubbleAdapter-APC7JYOM.js.map
@@ -1,3 +1,3 @@
1
- import{a as h,b as y}from"./chunk-LGGAXAS6.js";import{c as O,d as P}from"./chunk-QRVREF7H.js";import"./chunk-KWAXLUPQ.js";import{a as B}from"./chunk-J4OLMLS5.js";import"./chunk-MUK3KYB4.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(`
1
+ import{a as h,b as y}from"./chunk-5DP7IXD3.js";import{c as O,d as P}from"./chunk-JAQ2RQAE.js";import"./chunk-KWAXLUPQ.js";import{a as B}from"./chunk-J4OLMLS5.js";import"./chunk-MUK3KYB4.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
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-O3ERR2GY.js.map
3
+ //# sourceMappingURL=RgfaTabixAdapter-4E365PXO.js.map
@@ -1,2 +1,2 @@
1
- import{b as l,c as h}from"./chunk-QRVREF7H.js";import{a as y}from"./chunk-KWAXLUPQ.js";import{a as u,b as m,c as s,d as g,e as p}from"./chunk-MUK3KYB4.js";import{b as f}from"./chunk-FY3BTKY4.js";var x=f(h(),1),r=f(y(),1),N=50*2**20;function B(n,t,e){let a=n.pluginManager;return new l({filehandle:(0,r.openLocation)(n.getConf(t),a),...(0,r.openTabixIndexFilehandle)(n.getConf([...e,"location"]),n.getConf([...e,"indexType"]),a),chunkCacheSize:N})}function c(n,t){return`${n} ${t}`}function S(n){let t=new Map;for(let e of n){t.set(e,e);let a=u(e);if(a!==e){let i=s(e);t.set(c(a,i),e);let o=m(e);o!==void 0&&t.set(c(o,i),e)}}return t}function b(n,t,e){let a=n.get(c(t,e));return a===void 0?n.get(e):a}var d=class{constructor(t,e){this.file=t;this.adapter=e;this.lookup=(0,x.cachedSetup)({setup:async t=>S(await this.file.getReferenceSequenceNames(t))})}async assemblyRefNames(t={}){let e=await this.file.getReferenceSequenceNames(t),a=p(this.adapter,t.assemblyName),i=e.filter(o=>g(o,a)).map(o=>s(o));return i.length>0?i:e}async resolve(t,e){let a=await this.lookup(e);return b(a,p(this.adapter,t.assemblyName),t.refName)}};export{B as a,d as b};
2
- //# sourceMappingURL=chunk-LGGAXAS6.js.map
1
+ import{b as l,c as h}from"./chunk-JAQ2RQAE.js";import{a as y}from"./chunk-KWAXLUPQ.js";import{a as u,b as m,c as s,d as g,e as p}from"./chunk-MUK3KYB4.js";import{b as f}from"./chunk-FY3BTKY4.js";var x=f(h(),1),r=f(y(),1),N=50*2**20;function B(n,t,e){let a=n.pluginManager;return new l({filehandle:(0,r.openLocation)(n.getConf(t),a),...(0,r.openTabixIndexFilehandle)(n.getConf([...e,"location"]),n.getConf([...e,"indexType"]),a),chunkCacheSize:N})}function c(n,t){return`${n} ${t}`}function S(n){let t=new Map;for(let e of n){t.set(e,e);let a=u(e);if(a!==e){let i=s(e);t.set(c(a,i),e);let o=m(e);o!==void 0&&t.set(c(o,i),e)}}return t}function b(n,t,e){let a=n.get(c(t,e));return a===void 0?n.get(e):a}var d=class{constructor(t,e){this.file=t;this.adapter=e;this.lookup=(0,x.cachedSetup)({setup:async t=>S(await this.file.getReferenceSequenceNames(t))})}async assemblyRefNames(t={}){let e=await this.file.getReferenceSequenceNames(t),a=p(this.adapter,t.assemblyName),i=e.filter(o=>g(o,a)).map(o=>s(o));return i.length>0?i:e}async resolve(t,e){let a=await this.lookup(e);return b(a,p(this.adapter,t.assemblyName),t.refName)}};export{B as a,d as b};
2
+ //# sourceMappingURL=chunk-5DP7IXD3.js.map
@@ -0,0 +1,2 @@
1
+ import{c as at}from"./chunk-VAGPKHHS.js";import{c as st}from"./chunk-SCMIJAAX.js";import{i as Le,n as it,o as lt,p as bn,q as gn,t as ct,x as ut,y as yn}from"./chunk-M4YEAXSR.js";import{a as Be,b as B,c as Ke,d as le,e as ce,f as rt,h as Qe}from"./chunk-EFVAQ2KM.js";import{a as Ue,b as tt,c as ot}from"./chunk-MUK3KYB4.js";import{a as Ve}from"./chunk-XEJ47DLD.js";import{a as je,b as be}from"./chunk-FY3BTKY4.js";var ft=je((Vi,dt)=>{dt.exports=JBrowseExports["@mui/material/SvgIcon"]});var cs=je((ql,jt)=>{jt.exports=JBrowseExports.mobx});var Vn=je((jc,Wo)=>{Wo.exports=JBrowseExports["@jbrowse/core/util/colorBits"]});var Yi=je((Du,lr)=>{lr.exports=JBrowseExports["@jbrowse/render-core/canvas2dUtils"]});var te=be(ft(),1);function Zi(e){let n=t=>Math.round(t*100)/100;return e.map((t,r)=>`${r?"L":"M"}${n(t.x)},${n(t.y)}`).join("")}function pt(e,n,t,r,o){let s=Math.hypot(r-n,t-e);if(s===0)return[t,r];let a=(t-e)/s,i=(r-n)/s;return[t+o*a,r+o*i]}function Ln(e,n){let t=1-n,r=t*t*t,o=3*t*t*n,s=3*t*n*n,a=n*n*n;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 xt(e){let n=e[Math.floor(e.length/2)];return n?Ln(n,.5):void 0}function Mt(e){let n=1/0,t=1/0,r=-1/0,o=-1/0;for(let s of e)n=Math.min(n,s.x0,s.cx0,s.cx1,s.x1),r=Math.max(r,s.x0,s.cx0,s.cx1,s.x1),t=Math.min(t,s.y0,s.cy0,s.cy1,s.y1),o=Math.max(o,s.y0,s.cy0,s.cy1,s.y1);return{minX:n,minY:t,maxX:r,maxY:o}}function hr(e,n,t){let r=Ln(e,n),o=Ln(e,t),s=(t-n)/3,a=ht(e,n),i=ht(e,t);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 ht(e,n){let t=1-n,r=3*t*t,o=6*t*n,s=3*n*n;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 wt(e,n){let t=[];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/n)|1);for(let a=0;a<s;a+=2)t.push([hr(r,a/s,(a+1)/s)])}return t}function Lt(e,n,t){let r=new Array(e.length);for(let o=0;o<e.length;o++){let s=e[o];r[o]={x0:s.x0+n,y0:s.y0+t,cx0:s.cx0+n,cy0:s.cy0+t,cx1:s.cx1+n,cy1:s.cy1+t,x1:s.x1+n,y1:s.y1+t}}return r}function xn(e,n){let t=e.length-1;return n==="end"?{at:e[t],inward:e[t-1]}:{at:e[0],inward:e[1]}}var mr=.5,br=80;function mt(e){let n=1/0,t=-1/0;for(let r of e)n=Math.min(n,r.x),t=Math.max(t,r.x);return{min:n,max:t}}function bt(e,n){return Math.max(0,n.min-e,e-n.max)}function gt(e,n,t){let r=bt(e[0].x,n),o=bt(e[e.length-1].x,n);return r===o?t:r<o?"start":"end"}function gr(e,n){return{from:gt(e,mt(n),"end"),to:gt(n,mt(e),"start")}}var yr=.75,xr=1.15,Mr=.35,wr=60;function Lr(e,n,t,r,o,s){let a=Math.hypot(t-e,r-n),i=a===0?1:(t-e)/a,l=a===0?0:(r-n)/a,c=0,f=1/0,u=-1/0;for(let m of o){let b=m.x-e,g=m.y-n,y=b*-l+g*i;Math.abs(y)>Math.abs(c)&&(c=y);let w=b*i+g*l;f=Math.min(f,w),u=Math.max(u,w)}let d=o.length?u-f:0,h=Math.max(Math.abs(c)*xr/yr,d*Mr),p=s===void 0?h:Math.min(h,s);return c<0?-p:p}function Ze({scaleX:e,scaleY:n}){return n/e}var Nr=3;function Mn(e,n,t){let r=n.x-e.x,o=(n.y-e.y)*t,s=Math.hypot(r,o);return s===0?void 0:{x:r/s,y:o/s}}function Nt(e,n,t,r,o=Nr){let s=Ze(r),a=Mn(e[e.length-1],n[0],s)??Mn(e[0],e.at(-1),s)??Mn(n[0],n.at(-1),s)??{x:1,y:0},i=[];for(let l=0;l<t;l++){let c=(l-(t-1)/2)*o;i.push({x:-a.y*c,y:a.x*c/s})}return i}function wn(e,n){return e.map(t=>({x:t.x,y:t.y*n}))}function Sr(e,n){for(let t of e)t.y0/=n,t.cy0/=n,t.cy1/=n,t.y1/=n;return e}var Rr=12,Er=40;function yt(e,n){let t=0;for(let s=1;s<e.length;s++)t+=Math.hypot(e[s].x-e[s-1].x,e[s].y-e[s-1].y);let r=t*n;return Math.min(Er,Math.max(Rr,r/2))/Math.max(n,Number.EPSILON)}function St(e){return e.from!==e.to?!1:e.fromStrand&&e.toStrand&&e.fromStrand!==e.toStrand?e.fromStrand==="+"?"end":"start":!0}function Ar(e,n,t,r){let{at:o,inward:s}=e,a=s?o.x-s.x:1,i=s?o.y-s.y:0,l=Math.hypot(a,i)||1,c=a/l,f=i/l,u=o.x+t,d=o.y+r,h=u+c*n/3,p=d+f*n/3,m=u+c*n,b=d+f*n,g=-f*n/2,y=c*n/2;return[{x0:u,y0:d,cx0:h,cy0:p,cx1:m+g,cy1:b+y,x1:m,y1:b},{x0:m,y0:b,cx0:m-g,cy0:b-y,cx1:h,cy1:p,x1:u,y1:d}]}function Oe(e,n,t,r,o,s,a=[],i){let l=s.scaleX,c=Ze(s),f=i??(s.pixelRows?wr:void 0);if(c!==1)return Sr(Oe(wn(e,c),wn(n,c),t,r,o*c,{scaleX:l,scaleY:l},wn(a,c),f===void 0?void 0:f*c),c);if(typeof t=="string")return Ar(xn(e,t),yt(e,l),r,o);let u=t?{from:"end",to:"start"}:gr(e,n),d=xn(e,u.from),h=xn(n,u.to),p=d.at,m=h.at,b=p.x+r,g=p.y+o,y=m.x+r,w=m.y+o;if(t){let N=1,S=0;if(d.inward){let U=p.x-d.inward.x,j=p.y-d.inward.y,V=Math.hypot(U,j);V>0&&(N=U/V,S=j/V)}let R=yt(e,l),x=-S,E=N,C=(p.x+m.x)/2+r+x*R,P=(p.y+m.y)/2+o+E*R,z=b+N*R,W=g+S*R,q=y-N*R,F=w-S*R;return[{x0:b,y0:g,cx0:z,cy0:W,cx1:z+x*R,cy1:W+E*R,x1:C,y1:P},{x0:C,y0:P,cx0:q+x*R,cy0:F+E*R,cx1:q,cy1:F,x1:y,y1:w}]}else{let N=d.inward??{x:p.x-(m.x-p.x),y:p.y-(m.y-p.y)},S=h.inward??{x:m.x-(p.x-m.x),y:m.y-(p.y-m.y)},R=Math.hypot(y-b,w-g),x=(Z,J,se,Te)=>{let ae=J.x-Z.x,ie=J.y-Z.y,ee=Math.hypot(ae,ie),he=ee===0?0:(se*ae+Te*ie)/ee;return Math.max(0,Math.min(R*mr,br,he*.5))},E=m.x-p.x,C=m.y-p.y,[P,z]=pt(N.x,N.y,p.x,p.y,x(N,p,E,C)),[W,q]=pt(S.x,S.y,m.x,m.y,x(S,m,-E,-C)),F=a.length?Lr(b,g,y,w,a,f):0,U=R===0?1:R,j=(y-b)/U,V=(w-g)/U,We=-V*F,v=j*F,D=j*Math.abs(F),K=V*Math.abs(F);return[{x0:b,y0:g,cx0:P+r+We-D,cy0:z+o+v-K,cx1:W+r+We+D,cy1:q+o+v+K,x1:y,y1:w}]}}var Tr=1;function Nn(e,n){return n.flatMap(t=>e[t]??[])}function Rt(e,n,t){let r=e[n.from],o=e[n.to];return r?.length&&o?.length?Oe(r,o,n.from===n.to,0,0,t,Nn(e,n.bypassed)):void 0}function Cr(e){let n=new Map;for(let t of e.nodes)if(B(t)){let r=n.get(t.stable.refName);r?r.push(t):n.set(t.stable.refName,[t])}for(let t of n.values())t.sort((r,o)=>r.stable.start-o.stable.start);return n}function Ir(e,n,t){let r=[];if(e)for(let o=rt(e,n);o<e.length;o++){let s=e[o];if(s.stable.start>=t)break;s.stable.start+s.length<=t&&r.push(s.id)}return r}function _r(e,n,t,r){let{fromStrand:o,toStrand:s}=e;if(o===void 0||s===void 0)return!0;let a=o===(n.stable.strand??"+"),i=s===(t.stable.strand??"+");return r?a&&i:!a&&!i}function tl(e){let n=new Map(e.nodes.map(o=>[o.id,o])),t=Cr(e),r=[];for(let o=0;o<e.edges.length;o++){let s=e.edges[o],a=n.get(s.from),i=n.get(s.to);if(a!==void 0&&i!==void 0&&B(a)&&B(i)&&a.stable.refName===i.stable.refName){let l=a.stable.start<=i.stable.start,[c,f]=l?[a,i]:[i,a],u=c.stable.start+c.length,d=f.stable.start,h=d-u;if(h>=Tr&&_r(s,a,i,l)){let p=c.stable.refName;r.push({edgeIndex:o,from:s.from,to:s.to,refName:p,start:u,end:d,bp:h,bypassed:Ir(t.get(p),u,d)})}}}return r}function Ne(e){return e.endsWith("-")?"-":"+"}function Et(e){return e==="+"?"-":"+"}function vr(e){let n=(e.fromStrand??Ne(e.from))===Ne(e.from)?"end":"start",t=(e.toStrand??Ne(e.to))===Ne(e.to)?"start":"end";return{from:n,to:t}}function sl(e){let n=e.edges.map(vr),t=new Map,r=(d,h,p)=>{let m=`${d}|${h}`,b=t.get(m);b?b.push(p):t.set(m,[p])};e.edges.forEach((d,h)=>{r(d.from,n[h].from,h),r(d.to,n[h].to,h)});let o=d=>{let h=t.get(`${d}|end`);if(h?.length!==1)return;let p=h[0],m=e.edges[p];return m.from===d&&m.to!==d&&n[p].from==="end"&&n[p].to==="start"&&t.get(`${m.to}|start`)?.length===1?p:void 0},s=new Set,a=new Map,i=new Map;for(let d of e.nodes){let h=t.get(`${d.id}|start`),p=h?.length===1?e.edges[h[0]].from:void 0;if(a.has(d.id)||p!==void 0&&o(p)===h[0])continue;let m=[d.id];for(;;){let b=o(m.at(-1)),g=b===void 0?void 0:e.edges[b].to;if(g===void 0||a.has(g))break;s.add(b),m.push(g)}for(let b of m)a.set(b,d.id);m.length>1&&i.set(d.id,m)}for(let d of e.nodes)a.has(d.id)||a.set(d.id,d.id);let l=new Map(e.nodes.map(d=>[d.id,d])),c=[];for(let d of e.nodes){if(a.get(d.id)!==d.id)continue;let h=i.get(d.id);if(!h){c.push(d);continue}let p=h.map(g=>l.get(g)),m=p.filter(B),b=m.length?m.reduce((g,y)=>g.stable.start<=y.stable.start?g:y):p[0];c.push({id:d.id,name:d.name,length:p.reduce((g,y)=>g+y.length,0),depth:d.depth,stable:b.stable})}let f=new Set,u=[];return e.edges.forEach((d,h)=>{let p=a.get(d.from),m=a.get(d.to),b=n[h],g=`${p}|${b.from}>${m}|${b.to}`;s.has(h)||f.has(g)||(f.add(g),u.push({from:p,to:m,...b.from==="start"?{fromStrand:Et(Ne(p))}:{},...b.to==="end"?{toStrand:Et(Ne(m))}:{}}))}),{graph:{...e,nodes:c,edges:u,paths:void 0,pathVisits:void 0},runs:i}}function al(e,n,t){let r={...e};for(let[o,s]of n){let a=e[o];if(!a?.length)continue;delete r[o];let i=Rn(a),l=i.at(-1),c=s.map(d=>Math.max(t(d),0)),f=c.reduce((d,h)=>d+h,0)||s.length,u=0;s.forEach((d,h)=>{let p=f?c[h]/f*l:l/s.length,m=h===s.length-1?l:u+p;r[d]=Tt(a,i,u,m),u=m})}return r}function il(e,n,t){if(e.length===0)return[];let r=Rn(e),o=r.at(-1);return Tt(e,r,n*o,t*o)}function At(e){let n=Rn(e);return Sn(e,n,n.at(-1)/2)}function Rn(e){let n=[0];for(let t=1;t<e.length;t++)n.push(n[t-1]+Math.hypot(e[t].x-e[t-1].x,e[t].y-e[t-1].y));return n}function Sn(e,n,t){if(t<=0)return{...e[0]};let r=1;for(;r<n.length&&n[r]<t;)r++;if(r>=n.length)return{...e.at(-1)};let o=n[r]-n[r-1],s=o>0?(t-n[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 Tt(e,n,t,r){let o=[Sn(e,n,t)];for(let s=0;s<e.length;s++)n[s]>t&&n[s]<r&&o.push({...e[s]});return o.push(Sn(e,n,r)),o}function En(e){return e.length*6.2+8}function Br(e,n){return e.x0<n.x1&&e.x1>n.x0&&e.y0<n.y1&&e.y1>n.y0}function Ct(e,n){return e.x1<=0||e.x0>=n.width||e.y1<=0||e.y0>=n.height}function Or(e,n){return e.x0>=0&&e.x1<=n.width&&e.y0>=0&&e.y1<=n.height}function An(e,n=[]){let t=[...n];return r=>Ct(r,e)||t.some(o=>Br(o,r))?!1:(t.push(r),!0)}function Pe(e,n,t){let r=[];for(let s of e){let a=En(s.text),i=s.y>n.height/2?-1:1;for(let l=0;l<=(s.stack??0);l++){let c=s.y+i*l*19,f={x0:s.x-a/2,x1:s.x+a/2,y0:c-11-4,y1:c+4};if(Ct(f,n))break;if(Or(f,n)&&t(f)){r.push({...s,y:c,w:a});break}}}return r}var Pr=26,Gr=4e4,Dr=8,$r=8,qr=5.7,Fr=6,Hr=13,Ge=3,Je=2;function tn(e){return(e.length*qr+Fr+Ge)/2}var ue=(Hr+Ge)/2,Wr=tn("1 bp");function en(e,n,t){return{x0:n-e,x1:n+e,y0:t-ue,y1:t+ue}}function Bt(e,n){return{x0:6,x1:6+e.length*6.2+8+Ge,y0:n-8-Ge/2,y1:n+8+Ge/2}}function nn(e,n,t){return t<n?e:Math.min(Math.max(e,n),t)}function on(e){return e>=1e6?`${+(e/1e6).toFixed(1)} Mb`:e>=1e3?`${+(e/1e3).toFixed(1)} kb`:`${e} bp`}function It(e){return`${on(e)} del`}function Xr(e,n,t,r){let o=e[0],s=e[e.length-1],a=(n.x-(o.x0+s.x1)/2)*t,i=(n.y-(o.y0+s.y1)/2)*r,l=Math.hypot(a,i);return l===0?{x:0,y:-1}:{x:a/l,y:i/l}}function Yr(e,n){return Math.abs(n.x)*(e.x1-e.x0)/2+Math.abs(n.y)*(e.y1-e.y0)/2}function kr(e,n){let t=(e.x1-e.x0)/2,r=(e.y1-e.y0)/2;return Math.min(n.x===0?1/0:t/Math.abs(n.x),n.y===0?1/0:r/Math.abs(n.y))}function zr(e,n,t){let r=0;for(let o=1;o<e.length;o++){let s=e[o-1],a=e[o];r+=Math.hypot((a.x-s.x)*n,(a.y-s.y)*t)}return r}function jr(e,n){let t=1/0,r=1/0,o=-1/0,s=-1/0;for(let a of e)for(let i of n[a]??[])t=Math.min(t,i.x),o=Math.max(o,i.x),r=Math.min(r,i.y),s=Math.max(s,i.y);return t===1/0?void 0:{minX:t,minY:r,maxX:o,maxY:s}}var _t=new WeakMap;function Vr(e,n){let t=_t.get(e);if(t?.nodeLengths===n)return t.order;let r=Object.entries(e).filter(([o,s])=>s.length>0&&n.has(o)).sort(([o],[s])=>n.get(s)-n.get(o));return _t.set(e,{nodeLengths:n,order:r}),r}var vt=new WeakMap;function Ur(e,n,t,r){let{scaleX:o,scaleY:s}=t,a=vt.get(e);if(a?.deletions===n&&a.scaleX===o&&a.scaleY===s&&a.version===r)return a.arcs;let i=[];for(let l of[...n].sort((c,f)=>f.bp-c.bp)){let c=Rt(e,l,t),f=c?xt(c):void 0;if(c&&f){let{minX:u,minY:d,maxX:h,maxY:p}=Mt(c);i.push({deletion:l,curves:c,apex:f,extent:Math.max((h-u)*o,(p-d)*s)})}}return vt.set(e,{deletions:n,scaleX:o,scaleY:s,version:r,arcs:i}),i}function Ot({nodePositions:e,nodeLengths:n,deletions:t,alleleDeletions:r,axis:o,translateX:s,translateY:a,width:i,height:l,version:c=0}){let{scaleX:f,scaleY:u}=o,d=[],h=[];for(let{deletion:b,curves:g,apex:y,extent:w}of Ur(e,t,o,c))if(w>=Pr){let N=It(b.bp),S=tn(N),R=en(S,0,0),x=y.x*f+s,E=y.y*u+a,C=w>=S*2/Je,P=Xr(g,y,f,u),z=Yr(R,P)+$r,W=C?x:nn(x+P.x*z,S,i-S),q=C?E:nn(E+P.y*z,ue,l-ue),F=Math.hypot(W-x,q-E),U;if(F>0){let j={x:(W-x)/F,y:(q-E)/F},V=kr(R,j);U={arcX:x,arcY:E,labelX:W-j.x*V,labelY:q-j.y*V}}d.push({label:{key:`del:${b.edgeIndex}`,text:N,x:W,y:q,kind:"deletion",leader:U},box:en(S,W,q)})}let p=new Set,m=[...r??[]].sort((b,g)=>g.bp-b.bp);for(let b of m){let g=jr(b.nodeIds,e);if(!g)continue;let y=Math.max(g.minX*f+s,0),w=Math.min(g.maxX*f+s,i),N=Math.max(g.minY*u+a,0),S=Math.min(g.maxY*u+a,l);if(w<y||S<N)continue;let R=Math.max(w-y,S-N),x=It(b.bp),E=tn(x);if(R>=E*2/Je){for(let z of b.nodeIds)p.add(z);let C=nn((y+w)/2,E,i-E),P=nn((N+S)/2,ue,l-ue);d.push({label:{key:`alleledel:${b.nodeIds.join(",")}`,text:x,x:C,y:P,kind:"deletion"},box:en(E,C,P)})}}for(let[b,g]of Vr(e,n)){if(p.has(b))continue;let{x:y,y:w}=At(g),N=w*u+a;if(N+ue<=0||N-ue>=l)continue;let S=zr(g,f,u);if(S<Wr*2/Je)continue;let R=on(n.get(b)),x=tn(R);if(S>=x*2/Je){let E=y*f+s;h.push({label:{key:`node:${b}`,text:R,x:E,y:N,kind:"node"},box:en(x,E,N)})}}return{deletions:d,nodes:h}}function Pt(e,n){return Math.max(Dr,Math.floor(e*n/Gr))}function Tn(e,n,t=1/0){let r=[];for(let{label:o,box:s}of e){if(r.length>=t)break;n(s)&&r.push(o)}return r}var Qr=3.4,Gt=6,Zr=8,Jr=18,es=2,ns=60,ts=8,Dt=15;function Cn(e,n){return[...e].sort((t,r)=>n(r)-n(t))}function gl(e){let{paneWidth:n,canvasHeight:t,translateX:r,translateY:o}=e,{scaleX:s,scaleY:a}=e.axisScale,i={width:n,height:t},l=x=>({x:x.x*s+r,y:x.y*a+o}),c=e.drawnRowLabels.map(({label:x,y:E})=>Bt(x,E*a+o));e.legendSize.width>0&&c.push({x0:n-Gt-e.legendSize.width,x1:n,y0:0,y1:Gt+e.legendSize.height}),e.poppedFrom&&c.push({x0:0,x1:60+e.poppedFrom.label.length*6.2*1.2,y0:0,y1:44});let f=An(i,c),u=e.drawnRowLabels.length>0,d=u?Math.min(...e.drawnRowLabels.map(x=>x.y)):1/0,h=e.contigThickness*Qr,p=Cn(e.bubbleHalos,x=>x.members),m=Pe(p.map(x=>{let{x:E,y:C}=l({x:x.labelAt.x,y:Math.min(x.labelAt.y,d)}),P=C-h/2-6;return{item:x,x:E,y:u?Math.max(P,Dt):P,text:x.label}}),i,f),b=Math.max(2,Math.min(ts,Math.floor((o-ns)/19))),g=Pe(Cn(e.bubbleGlyphs,x=>x.bubble.end-x.bubble.start).flatMap(x=>{let E=(x.bubble.start+x.bubble.end)/2*s+r,C=En(x.label)/2;return E<0||E>n?[]:[{item:{glyph:x,glyphX:E},x:Math.min(Math.max(E,C),n-C),y:Dt,text:x.label,stack:b-1}]}),i,f),y=Pe(Cn(e.genePins,x=>x.gene.end-x.gene.start).map(x=>{let{x:E,y:C}=l(x.at);return{item:x,x:E,y:C+e.contigThickness+Jr,text:x.covered<.98?`${x.gene.name} \u2026`:x.gene.name,stack:es}}),i,f),w=e.nodePositions&&e.labelsNodeSizes?Ot({nodePositions:e.nodePositions,nodeLengths:e.nodeLengths,deletions:e.showDeletionEdges?e.deletions:[],alleleDeletions:e.alleleDeletions,axis:e.axisScale,translateX:r,translateY:o,width:n,height:t,version:e.positionsVersion}):{deletions:[],nodes:[]},N=Tn(w.deletions,f),S=Pe(p.flatMap(x=>x.routes.map(E=>{let{x:C,y:P}=l(E.at);return{item:{halo:x,route:E},x:C,y:P+4,text:E.text,stack:Zr}})),i,f),R=Tn(w.nodes,f,Pt(n,t));return{bubbles:m,glyphs:g,genes:y,routes:S,sizes:[...N,...R]}}function wl(e){return Be(e)?Ft(e):void 0}function Ft(e){return{sample:Ue(e.stable.refName),haplotype:tt(e.stable.refName),refName:ot(e.stable.refName),start:e.stable.start,end:e.stable.start+e.length}}function os(e,n){let t=[...e].sort((s,a)=>s.start-a.start),r,o;for(let s of t)o=o&&s.start-o.end<=n?{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 rs(e){return`${e.haplotype??e.sample}\0${e.refName}`}function Ll(e,{maxGap:n=1/0}={}){let t=new Map;for(let o of e.nodes)if(Be(o)){let s=Ft(o),a=rs(s),i=t.get(a);i?(i.spans.push({start:s.start,end:s.end}),i.rank=Math.min(i.rank,o.stable.rank)):t.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 t.values()){let s=os(o.spans,n);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,l=r.get(i);(!l||a.nodeCount>l.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 ss(e,n){return(n.haplotype===void 0?void 0:e(n.haplotype))??e(n.sample)}function Nl(e,n){return e.flatMap(t=>{let r=ss(n,t);return r===void 0?[]:[{...t,sample:r}]})}function Sl(e){return`${e.refName}:${e.start+1}-${e.end}`}function In(e){return`${e.refName}:${(e.start+1).toLocaleString()}-${e.end.toLocaleString()}`}var Ht=be(Ve(),1),Wt=(0,te.createSvgIcon)((0,Ht.jsx)("path",{d:"M9.01 14H2v2h7.01v3L13 15l-3.99-4zm5.98-1v-3H22V8h-7.01V5L11 9z"}),"CompareArrows");var Xt=be(Ve(),1),Yt=(0,te.createSvgIcon)((0,Xt.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 kt=be(Ve(),1),_n=(0,te.createSvgIcon)((0,kt.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 as="Linear genome view",is="Linear synteny view",ls="No synteny track in this session aligns these assemblies";function zt({label:e,icon:n,entries:t,entryLabel:r,onSelect:o,disabledHelpText:s,nameTheOnlyEntry:a=!0}){let[i]=t,l=s?[{label:e,icon:n,disabled:!0,disabledHelpText:s,onClick:()=>{}}]:[];return t.length===0?l:t.length===1&&i?[{label:a?`${e} \u2014 ${r(i)}`:e,icon:n,onClick:o(i)}]:[{label:e,icon:n,type:"subMenu",subMenu:t.map(c=>({label:r(c),onClick:o(c)}))}]}function Gl({contributors:e,syntenyTracks:n,onShowLinear:t,onShowSynteny:r}){let o=n[0]?.coverage??e.length;return[...zt({label:as,icon:_n,entries:e,entryLabel:s=>`${s.sample} ${In(s)}`,onSelect:s=>()=>{t({location:s,assembly:s.sample})}}),...e.length>=2?zt({label:`${is} (${o} assemblies)`,icon:Wt,entries:n,entryLabel:s=>s.coverage<o?`${s.name} (${s.coverage} of ${o})`:s.name,nameTheOnlyEntry:!1,disabledHelpText:ls,onSelect:s=>()=>{r(s.trackId)}}):[]]}function Dl({own:e,reference:n,highlight:t,onShowLinear:r,onHighlight:o}){let s=[e?{label:`Open in ${e.assembly} \u2014 ${In(e.location)}`,target:e}:void 0,n&&n.assembly!==e?.assembly?{label:`Open in ${n.assembly} \u2014 around this node`,target:n}:void 0].filter(a=>a!==void 0);return[...o&&t?[{label:`Highlight in ${t.assembly}`,icon:Yt,onClick:()=>{o(t)}}]:[],...s.map(({label:a,target:i})=>({label:a,icon:_n,onClick:()=>{r(i)}}))]}var us=10;function ds(e,n){let t=e.end-e.start,r=e.longestAlleleLength-e.shortestAlleleLength;return n.find(o=>r<=us*(o.end-o.start)&&(t===0?o.start<=e.start&&e.start<=o.end:Math.min(e.end,o.end)-Math.max(e.start,o.start)>=t/2))}var fs=40;function ge(e){return e>=1e4?`${(e/1e3).toFixed(0)} kb`:e>=1e3?`${(e/1e3).toFixed(1)} kb`:`${e} bp`}function ps(e,n){let t=ge(e),r=ge(n),o=r.slice(r.indexOf(" "));return t.endsWith(o)?`${t.slice(0,-o.length)}\u2013${r}`:`${t}\u2013${r}`}function Vt(e){return e>=at?"\u22652.1B routes":e>=1e5?`${(e/1e3).toFixed(0)}k routes`:`${e} routes`}function Hl(e,n=[]){let t=hs(e,n);return e.partial?{...t,label:`${t.label}, partial`}:t}function hs(e,n){let t=e.end-e.start,{shortestAlleleLength:r,longestAlleleLength:o,pathCount:s,segmentCount:a,inversion:i}=e,l=ps(r,o);if(a>=fs)return{kind:"superbubble",label:`${l} superbubble, ${a} segments, ${Vt(s)}${i?", inv":""}`};if(i)return{kind:"inversion",label:`${ge(o)} inv`};let c=o!==r?ds(e,n):void 0;if(c){let u=c.name?` (${c.name})`:"";return{kind:"repeat",label:`${l} repeat array${u}, ${Vt(s)}`}}let f=s>2?`, ${s} alleles`:"";return r===o&&r===t?t<=1?{kind:"snp",label:"SNP"}:{kind:"substitution",label:`${ge(t)} sub`}:t===0||r===t?{kind:"insertion",label:`\u2264${ge(o-t)} ins${f}`}:o===t?{kind:"deletion",label:`${ge(t-r)} del${f}`}:{kind:"complex",label:`${ge(t)} ref \u2192 ${l}, ${s} alleles`}}var Wl={snp:"#5b6b7a",substitution:"#5b6b7a",insertion:"#2f8fd6",deletion:"#c94040",inversion:"#e07b00",repeat:"#8e3fbf",superbubble:"#8e3fbf",complex:"#8e3fbf"},Xl={snp:"SNP",substitution:"substitution",insertion:"insertion",deletion:"deletion",inversion:"inversion",repeat:"repeat array",superbubble:"superbubble",complex:"site"};function Yl(e){return e.segments.split(",").filter(Boolean)}var ms=4;function De(e){let n=new Map;function t(r,o){let s=n.get(r);s?s.push(o):n.set(r,[o])}for(let r of e.edges)t(r.from,r.to),t(r.to,r.from);return n}function bs({nodeId:e,nodeById:n,neighbors:t}){let r=new Set([e]),o=[e],s=1/0,a=-1/0;for(let i=0;i<ms&&o.length>0;i++){let l=[];for(let c of o){let f=t.get(c);if(f){for(let u of f)if(!r.has(u)){r.add(u);let d=n.get(u);d&&B(d)?(s=Math.min(s,d.stable.start+d.length),a=Math.max(a,d.stable.start)):l.push(u)}}}o=l}return s===1/0?void 0:{start:Math.min(s,a),end:Math.max(s,a)}}function gs({nodeId:e,nodeById:n,neighbors:t}){let r=n.get(e);return r===void 0?void 0:B(r)?{start:r.stable.start,end:r.stable.start+r.length}:bs({nodeId:e,nodeById:n,neighbors:t})}function Ut(e){let n=new Map(e.nodes.map(o=>[o.id,o])),t=De(e),r=new Map;for(let o of e.nodes){let s=gs({nodeId:o.id,nodeById:n,neighbors:t});s&&r.set(o.id,(s.start+s.end)/2)}return r}function rn(e){let n=e.split("#"),t=n.length>=2?Number(n[1]):Number.NaN;return{sample:n[0]??e,haplotype:Number.isFinite(t)?t:void 0}}function ys(e,n,t,r){let o=[],s=[],a=[e];for(r.add(e);a.length>0;){let i=a.pop(),l=n.get(i);if(l){o.push(l);for(let c of t.get(i)??[]){let f=n.get(c);f&&(f.stable.rank===0?s.push(f):r.has(c)||(r.add(c),a.push(c)))}}}return{members:o,anchors:s}}function xs(e){if(new Set(e.map(i=>i.stable.refName)).size!==1||e.length<2)return;let t=[...e].sort((i,l)=>i.stable.start-l.stable.start),r=t[0],o=t.at(-1),s=r.stable.start+r.length,a=o.stable.start;return a>=s?{start:s,end:a,entry:r}:void 0}function Ms(e,n,t){let r=new Map(e.map(a=>[a.id,a])),o=new Map,s=[];for(let a of t.get(n.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 l of t.get(a)??[])if(r.has(l)){let c=o.get(l);(c===void 0||i<c)&&(o.set(l,i),s.push(l))}}return o}function ws(e,n,t){let r=Ms(e,n,t),o=[...e].sort((l,c)=>r.get(l.id)-r.get(c.id)),s=new Map(o.map((l,c)=>[l.id,c])),a=new Map(e.map(l=>[l.id,l])),i=new Map;for(let[l,c]of o.entries()){let f=0;for(let u of t.get(c.id)??[]){let d=a.get(u);d&&s.get(u)<l&&(f=Math.max(f,i.get(u)+d.length))}i.set(c.id,f)}return{offsets:i,ordered:o}}function Qt(e){let n=new Map(e.nodes.filter(Be).map(s=>[s.id,s])),t=De(e),r=new Set,o=[];for(let s of n.values())if(s.stable.rank!==0&&!r.has(s.id)){let{members:a,anchors:i}=ys(s.id,n,t,r),l=xs(i);if(l){let{offsets:c,ordered:f}=ws(a,l.entry,t);o.push({start:l.start,refSpan:l.end-l.start,nodeIds:f.map(u=>u.id),nodeOffsets:f.map(u=>c.get(u.id)),pathLength:f.reduce((u,d)=>Math.max(u,c.get(d.id)+d.length),0)})}}return o.sort((s,a)=>s.start-a.start)}var Ls=1,Ns=.015;function sn({graph:e,span:n,rowY:t,positions:r}){let o=n*Ns,s=Qt(e),a=new Map(e.nodes.map(f=>[f.id,f])),i=[];for(let f of s){let u=f.refSpan-f.pathLength;u>=Ls&&i.push({nodeIds:f.nodeIds,bp:u});let d=Math.max(f.refSpan,o),h=f.pathLength>0?d/f.pathLength:0;f.nodeIds.forEach((p,m)=>{let b=a.get(p);if(b){let g=f.nodeOffsets[m],y=d/f.nodeIds.length,w=S=>f.start+S*h,N=t(b);r[p]=h?[{x:w(g),y:N},{x:w(g+b.length),y:N}]:[{x:f.start+m*y,y:N},{x:f.start+(m+1)*y,y:N}]}})}let l=De(e),c=Object.keys(r);for(let f of c){let u=r[f].at(-1).x;for(let d of l.get(f)??[]){let h=a.get(d);if(h&&!(d in r)){let p=t(h);r[d]=[{x:u,y:p},{x:u+o,y:p}],c.push(d)}}}return i}function Ss(e){let n=new Set;for(let t of e.nodes)t.stable&&n.add(t.stable.rank);return new Map([...n].sort((t,r)=>t-r).map((t,r)=>[t,r]))}function Zt(e,n){let t=le(e);if(t.length===0)return;let r=Qe(t,n),o=Ss(e),s=ce(t),a=sn({graph:e,span:r,rowY:l=>(l.stable?o.get(l.stable.rank)??o.size:o.size)*20,positions:s}),i=[...o].map(([l,c])=>({label:l===0?"Reference (rank 0)":`Rank ${l}`,y:c*20}));return{nodePositions:s,rowLabels:i,referenceAxis:!0,pixelRows:!0,alleleDeletions:a}}var Rs=12,vn=20;function Jt(e){return 10+8*Math.log2(1+e.length)}function de(e,n){return e<n?-1:e>n?1:0}function no(e,n){return de(e.at,n.at)||de(e.side,n.side)||de(e.hops,n.hops)}var eo={at:1/0,side:0,hops:0};function Es(e){let n=new Map(e.nodes.map(r=>[r.id,r])),t=Cs(e);return e.nodes.map(r=>r.id).sort((r,o)=>no(t.get(r)??eo,t.get(o)??eo)||de(n.get(r).name,n.get(o).name)||de(r,o))}function As(e,n){let t=new Set(e.nodes.map(f=>f.id)),r=new Map(n.map(f=>[f.id,f.stable.start])),o=new Map,s=new Map;n.forEach((f,u)=>{s.set(f.id,n[u-1]?.id),o.set(f.id,n[u+1]?.id)});let a=n[0]?.id,i=(f,u)=>{let d=o.get(f);o.set(f,u),s.set(u,f),o.set(u,d),d!==void 0&&s.set(d,u)},l=(f,u)=>{let d=s.get(f);d===void 0?(a=u,s.set(u,void 0),o.set(u,f),s.set(f,u)):i(d,u)};for(let f of e.paths??[]){let u=0,d=0,h;for(let g of f.nodeIds){let y=r.get(g);y!==void 0&&(h!==void 0&&y!==h&&(y>h?u++:d++),h=y)}let p=d>u?[...f.nodeIds].reverse():f.nodeIds,m,b=new Set;for(let g of p)if(o.has(g)){if(m===void 0)for(let y of b)l(g,y);m=g}else t.has(g)&&(m===void 0?b.add(g):(i(m,g),m=g))}let c=[];for(let f=a;f!==void 0;f=o.get(f))c.push(f);return c}function Ts(e,n){let t=[...n.entries()].sort(([a,i],[l,c])=>no(i,c)||de(a,l)).map(([a])=>a),r=t.length;for(let a of t){let i=n.get(a);for(let l of e.get(a)??[])n.has(l)||(n.set(l,{at:i.at,side:1,hops:i.hops+1}),t.push(l))}let o=new Set(t.slice(r)),s=new Set;for(let a of o){if(s.has(a))continue;let{at:i}=n.get(a),l=[a];s.add(a);let c=!0;for(let f of l){let{hops:u}=n.get(f),d=!0,h=!1;for(let p of e.get(f)??[]){let m=n.get(p);m.at===i&&o.has(p)?(d&&=m.hops<=u,s.has(p)||(s.add(p),l.push(p))):m.at!==i&&(h||=m.at<i,c&&=m.at<i)}c&&=!d||h}if(c)for(let f of l){let u=n.get(f);n.set(f,{...u,side:-1,hops:-u.hops})}}}function Cs(e){let n=new Set(e.nodes.map(s=>s.id)),t=new Map;for(let s of e.edges)!n.has(s.from)||!n.has(s.to)||((t.get(s.from)??t.set(s.from,[]).get(s.from)).push(s.to),(t.get(s.to)??t.set(s.to,[]).get(s.to)).push(s.from));let r=e.nodes.filter(B).sort((s,a)=>de(s.stable.start,a.stable.start)||de(s.name,a.name)),o=new Map;return As(e,r).forEach((s,a)=>{o.set(s,{at:a,side:0,hops:0})}),Ts(t,o),o}function Is(e){let n=new Map(e.nodes.map(u=>[u.id,u])),t=Es(e),r=new Map(t.map((u,d)=>[u,d])),o=u=>B(n.get(u)),s=new Map(t.map(u=>[u,[]])),a=new Map(t.map(u=>[u,[]])),i=(u,d)=>{s.get(d).push(u),a.get(u).push(d)};for(let u of e.edges)u.from===u.to||!r.has(u.from)||!r.has(u.to)||(r.get(u.from)<r.get(u.to)?i(u.from,u.to):i(u.to,u.from));let l=t.filter(o);for(let u=1;u<l.length;u++)i(l[u-1],l[u]);let c=new Map;for(let u of t){let d=0;for(let h of s.get(u))d=Math.max(d,c.get(h)+1);c.set(u,d)}for(let u=t.length-1;u>=0;u--){let d=t[u],h=a.get(d);if(o(d)||h.length===0)continue;let p=1/0;for(let g of h)p=Math.min(p,c.get(g));let m=c.get(d),b=Math.max(m,p-1);c.set(d,Math.floor((m+b)/2))}let f=[];for(let u of t)(f[c.get(u)]??=[]).push(u);return{layers:f,layerOf:c,preds:s}}function to(e){if(!e.nodes.some(B))return;let n=new Map(e.nodes.map(u=>[u.id,u])),t=u=>B(n.get(u)),{layers:r,layerOf:o,preds:s}=Is(e),a=r.map(u=>{let d=0;for(let h of u)d=Math.max(d,Jt(n.get(h)));return d}),i=[],l=0;for(let u=0;u<r.length;u++)i[u]=l,l+=a[u]+Rs;let c=new Map;for(let u of r){let d=[];for(let p of u){if(t(p)){c.set(p,0);continue}let m=s.get(p).filter(g=>c.has(g)),b=0;for(let g of m)b+=c.get(g)/m.length;d.push({id:p,ideal:b===0?vn:b})}d.sort((p,m)=>p.ideal-m.ideal);let h=new Set([0]);for(let{id:p,ideal:m}of d){let b=Math.round(m/vn);b===0&&(b=m>=0?1:-1);for(let g=1;h.has(b);g++)h.has(b+g)?h.has(b-g)||(b-=g):b+=g;h.add(b),c.set(p,b*vn)}}let f={};for(let u of e.nodes){let d=o.get(u.id),h=Jt(u),p=i[d]+a[d]/2,m=c.get(u.id);f[u.id]=[{x:p-h/2,y:m},{x:p+h/2,y:m}]}return{nodePositions:f,referenceAxis:!1,pixelRows:!0}}function _s(e,n){let t=new Map;for(let o of e.nodes)if(Ke(o)){let{sample:s}=rn(o.stable.refName);t.set(s,(t.get(s)??0)+o.length)}let r=new Map(n.map((o,s)=>[o,s]));return[...t.keys()].sort((o,s)=>(r.get(o)??1/0)-(r.get(s)??1/0)||t.get(s)-t.get(o)||o.localeCompare(s))}function oo(e,n,t=[]){let r=le(e),o=_s(e,t);if(r.length===0||o.length===0)return;let s=Qe(r,n),a=new Map(o.map((d,h)=>[d,h+1])),i=ce(r),l=o.length+1,c=sn({graph:e,span:s,rowY:d=>{let h=d.stable;return((h?a.get(rn(h.refName).sample):void 0)??l)*20},positions:i}),u=[{label:rn(r[0].stable.refName).sample,y:0},...o.map(d=>({label:d,y:a.get(d)*20}))];return{nodePositions:i,rowLabels:u,sampleRows:o,referenceAxis:!0,pixelRows:!0,alleleDeletions:c}}function Bn(){return{rectangles:[],curves:[],corners:[],verticalRectangles:[],featureRectangles:[]}}var Fe=!1,ro=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f"];function wo(e){return{mergeNodesFlag:e.mergeNodes??!0,showReads:e.showReads??!0,coarsenedReadView:e.coarsenedReadView??!1,ignoreStrand:e.ignoreStrand??!1,nodeWidthOption:e.nodeWidthOption??"normal",charWidth:e.charWidth??8.401,trackWidth:e.trackWidth??15,mappingQualityCutoff:e.mappingQualityCutoff??0,focusReadNames:e.focusReadNames??null,showExonsFlag:e.showExons??!1,trackColor:e.trackColor??(n=>ro[n.id%ro.length]),trackAlpha:e.trackAlpha??(()=>1)}}var _=wo({}),$n=null,M=[],L=[],A=[],I=new Map,Ee=[],T=[],ye=[],Fn=[],Hn=[],Q=-1,G=Bn(),qn={minX:0,maxX:0,minY:0,maxY:0},$e,an=new Map;function Lo(e,n,t=[],r={}){if(_=wo(r),$n=r.bed??null,G=Bn(),ye=[],Fn=[],Hn=[],Ee=[],qn={minX:0,maxX:0,minY:0,maxY:0},$e=void 0,an=new Map,e.length===0||n.length===0)return;let o=On(e);M=[],o.forEach((l,c)=>{M[c+1]=l}),L=On(n);let s=t.length>0;A=On(ya(t));for(let l=L.length-1;l>=0;l-=1){let c=L[l];if(c.type===void 0&&(c.type="haplotype"),c.hidden===!0){L.splice(l,1);continue}c.indexOfFirstBase!==void 0&&($e=c.name)}if(L.length===0)return;Bs(0),I=io(),Se(L),_.showReads&&A.length>0&&Se(A),Mo(),_.mergeNodesFlag&&(lo(),Gn(),_.showReads&&A.length>0&&Pn(),ga(),I=io(),Mo(),Se(L),_.showReads&&A.length>0&&Se(A)),lo(),ea(),Fe&&console.log(`${M.length} nodes.`),Gn(),Q=uo(),na(),Gn(),Q=uo();let a=_.showReads&&_.coarsenedReadView&&!s;if(a){let l=$e===void 0?-1:L.findIndex(u=>u.name===$e),c=l===-1?0:l,f=L.filter((u,d)=>d!==c);if(f.length>0){let u=bo(f,"haplotype");u.length>0&&(L=[L[c]],A=u)}}da(),sa(),_.showExonsFlag&&$n!==null&&ua();let i=_.showReads&&_.coarsenedReadView&&A.length>0&&!a;return _.showReads&&A.length>0?(Os(),Pn(),Se(A),i&&(A=bo(A,"read"),Pn(),Se(A)),Gs(),L=L.concat(A)):M.forEach(l=>{l&&(l.incomingReads=[],l.outgoingReads=[],l.internalReads=[])}),oa(),ha(),Fe&&(console.log("Tracks:"),console.log(L),console.log("Nodes:"),console.log(M),console.log("Lane assignment:"),console.log(ye)),Vs(),{nodes:M,tracks:L,reads:A,nodeMap:I,shapes:G,bounds:qn,maxOrder:Q,trackForRuler:$e,coarsenedEdgeMeta:an}}function Re(e,n="plain"){return _.trackColor(e,n)}function vs(e){return _.trackAlpha(e)}function On(e){return structuredClone(e)}function X(e){let n=String(e);return n.length>=1&&n.startsWith("-")}function O(e){return X(e)?String(e).substring(1):e}function fe(e){return X(e)?e:`-${e}`}function No(e){return X(e)?O(e):fe(e)}function ln(e){return(e||1/e)>=0}function Bs(e){let n=new Set,t=L[e].sequence;for(let r=0;r<t.length;r+=1){let o=t[r];if(X(o)){let s=O(o),a=t.indexOf(s);(a===-1||a>r)&&n.add(s)}}for(let r of L){t=r.sequence;for(let o=0;o<t.length;o+=1){let s=t[o];X(s)?n.has(O(s))&&(t[o]=O(s)):n.has(s)&&(t[o]=fe(s))}}M.forEach(r=>{r&&n.has(r.name)&&(r.seq=r.seq.split("").reverse().join(""))})}function Os(){Ee=[];for(let n=0;n<=Q;n+=1)Ee[n]=[];let e=new Map;M.forEach(n=>{n.y!==void 0&&so(e,n.order,n.y+n.contentHeight)}),L.forEach(n=>{n.type==="haplotype"&&n.path.forEach(t=>{so(e,t.order,(t.y??0)+n.width)})}),M.forEach((n,t)=>{n.order>=0&&n.y===void 0&&(n.y=(e.get(n.order)??0)+25,n.contentHeight=0,Ee[n.order].push(t))})}function so(e,n,t){let r=e.get(n);r===void 0?e.set(n,t):e.set(n,Math.max(r,t))}var cn=7;function Ps(){M.forEach(e=>{e&&(e.incomingReads=[],e.outgoingReads=[],e.internalReads=[])}),A.forEach((e,n)=>{if((e.width===void 0||e.width===0)&&(e.width=cn),e.path.length===1){let t=e.path[0].node;t!==null&&M[t].internalReads.push(n)}else e.path.forEach((t,r)=>{if(r===0){let o=e.path[0].node;o!==null&&M[o].outgoingReads.push([n,r])}else{let o=t.node;o!==null&&M[o].incomingReads.push([n,r])}})})}function Gs(){Ys(),Ps();let e=M.slice();e.sort(un);let n=new Map;for(let a=0;a<A.length;a++){let i=A[a].sourceTrackID,l=n.get(i);l===void 0?n.set(i,[a]):l.push(a)}let t=Array.from(n.keys()).sort((a,i)=>a-i),r=t.length>1?cn:0;e.forEach(a=>{if(a)for(let i of t)Ds(n.get(i),a,r)});let o=Xs(),s=[];A.forEach((a,i)=>{let l=a.path.length,c=new Array(l),f;for(let h=0;h<l;h++){h===0?c[h]=void 0:c[h]=f??a.path[0];let p=a.path[h];p.node!==null&&p.node&&(f=p)}let u=new Array(l),d;for(let h=l-1;h>=0;h--){h===l-1?u[h]=void 0:u[h]=d??a.path[l-1];let p=a.path[h];p.node!==null&&p.node&&(d=p)}a.path.forEach((h,p)=>{if(h.y===void 0){let m=c[p],b=u[p],g=!!(b&&m&&b.isForward!==void 0&&m.isForward!==void 0&&(m.order>b.order||b.order===m.order&&b.isForward===m.isForward));h.betweenCycleReverseTraversal=g,s.push({readIndex:i,pathIndex:p,previousY:m?.y,previousNode:m?.node})}})}),s.sort(qs),s.forEach(a=>{let i=A[a.readIndex],l=i.path[a.pathIndex];l.y=o[l.order],o[l.order]+=i.width}),Fe&&(console.log("Reads:"),console.log(A))}function Ds(e,n,t){let r=new Set(e),o=n.incomingReads.filter(([p])=>r.has(p)),s=n.outgoingReads.filter(([p])=>r.has(p)),a=n.internalReads.filter(p=>r.has(p));o.length===0&&s.length===0&&a.length===0&&(t=0);let i=n.y+n.contentHeight+t*2,l=o.map(p=>{let[m,b]=p,g=A[m].path,y=b+1,w;for(let N=1;N<=b;N++){let S=g[b-N]?.y;if(S!==void 0){y=N,w=S;break}}return{entry:p,decisionStep:y,y:w}});l.sort($s),o=l.map(p=>p.entry);let c=i,f=new Map;o.forEach(p=>{let m=A[p[0]];m.path[p[1]].y=c,ao(f,m,p[1],c,n),c+=m.width});let u=c;s.sort(Fs);let d=new Map;c=i,s.forEach(p=>{let m=A[p[0]],b=m.firstNodeOffset??0;m.path[p[1]].y=c,d.set(c,b);let g=f.get(c);g===void 0||g+1<=b?(c+=m.width,u=Math.max(u,c)):(f.set(c,0),o.forEach(y=>{let w=A[y[0]],N=w.path[y[1]];N.y!==void 0&&N.y>=c&&(N.y+=m.width,ao(f,w,y[1],N.y,n))}),c+=m.width,u+=m.width)}),a.sort(Ws),a.forEach(p=>{let m=A[p],b=m.firstNodeOffset??0,g=m.finalNodeCoverLength??0;for(c=i;b<(f.get(c)??-1/0)+2||g>(d.get(c)??1/0)-3;)c+=m.width||cn;m.path[0].y=c,f.set(c,g),u=Math.max(u,c)});let h=u-n.y-n.contentHeight;n.contentHeight+=h,ca(n,h)}function $s(e,n){return e.decisionStep!==n.decisionStep?e.decisionStep-n.decisionStep:e.y===void 0||n.y===void 0?(e.y===void 0?0:1)-(n.y===void 0?0:1):e.y-n.y}function ao(e,n,t,r,o){t===n.path.length-1?e.set(r,n.finalNodeCoverLength??0):e.set(r,o.sequenceLength)}function qs(e,n){let t=A[e.readIndex],r=A[n.readIndex],o=t.path[e.pathIndex],s=r.path[n.pathIndex];if(o.order!==s.order)return o.order-s.order;if(t.sourceTrackID!==r.sourceTrackID)return t.sourceTrackID-r.sourceTrackID;if(e.previousNode&&n.previousNode){let l=M[e.previousNode],c=M[n.previousNode];if(l&&c&&l.order!==c.order)return l.order-c.order}let a=e.previousY??0,i=n.previousY??0;return o.betweenCycleReverseTraversal&&s.betweenCycleReverseTraversal?i-a:a-i}function Fs([e,n],[t,r]){let o=A[e],s=A[t],a,i,l=o.path.length-1,c=s.path.length-1;for(;!a&&l>=0;)a=o.path[l]?.y,l-=1;for(;!i&&c>=0;)i=s.path[c]?.y,c-=1;if(a&&i)return a-i;let f=o.path[n]?.node,u=s.path[r]?.node,d=f!=null?M[f]:null,h=u!=null?M[u]:null;for(;d!=null&&h!=null&&d===h;){if(n<o.path.length-1){for(n+=1;o.path[n]?.node===null;)n+=1;let m=o.path[n]?.node;d=m!=null?M[m]:null}else d=null;if(r<s.path.length-1){for(r+=1;s.path[r]?.node===null;)r+=1;let m=s.path[r]?.node;h=m!=null?M[m]:null}else h=null}if(d!=null)return h!=null?un(d,h):1;if(h!=null)return-1;let p=(o.firstNodeOffset??0)-(s.firstNodeOffset??0);return p!==0?p:(o.finalNodeCoverLength??0)-(s.finalNodeCoverLength??0)}function Hs(e,n){if(e.path===void 0||n.path===void 0)return(e.path===void 0?0:1)-(n.path===void 0?0:1);let t=e.path,r=n.path,o=0,s=0;for(;o<t.length&&s<r.length;){let a=t[o],i=r[s],l=a.order,c=i.order;if(l===c&&a.node&&i.node)return(i.y??0)-(a.y??0);l<c?o+=1:(l>c||(o+=1),s+=1)}return 0}function Ws(e,n){let t=A[e],r=A[n],o=t.firstNodeOffset??0,s=r.firstNodeOffset??0;if(o<s)return-1;if(o>s)return 1;let a=t.finalNodeCoverLength??0,i=r.finalNodeCoverLength??0;return a<i?-1:a>i?1:0}function Xs(){let e=[];for(let n=0;n<=Q;n+=1)e.push(0);return M.forEach(n=>{n.y!==void 0&&(e[n.order]=Math.max(e[n.order],n.y+n.contentHeight+20))}),L.forEach(n=>{n.path.forEach(t=>{e[t.order]=Math.max(e[t.order],(t.y??0)+n.width)})}),e}function Ys(){A.forEach(e=>{let n=Math.abs(e.indexSequence[0]),t=ln(e.indexSequence[0]),r=M[n],o,s;e.path=[],e.path.push({order:r.order,isForward:t,node:n});for(let a=1;a<e.sequence.length;a+=1)if(o=r,s=t,n=Math.abs(e.indexSequence[a]),t=ln(e.indexSequence[a]),r=M[n],r.order>o.order){s||e.path.push({order:o.order,isForward:!0,node:null});for(let i=o.order+1;i<r.order;i+=1)e.path.push({order:i,isForward:!0,node:null});t?e.path.push({order:r.order,isForward:!0,node:n}):(e.path.push({order:r.order,isForward:!0,node:null}),e.path.push({order:r.order,isForward:!1,node:n}))}else if(r.order<o.order){s&&e.path.push({order:o.order,isForward:!1,node:null});for(let i=o.order-1;i>r.order;i-=1)e.path.push({order:i,isForward:!1,node:null});t?(e.path.push({order:r.order,isForward:!1,node:null}),e.path.push({order:r.order,isForward:!0,node:n})):e.path.push({order:r.order,isForward:!1,node:n})}else t!==s?e.path.push({order:r.order,isForward:t,node:n}):(e.path.push({order:r.order,isForward:!t,node:null}),e.path.push({order:r.order,isForward:t,node:n}))})}function Pn(){A.forEach(e=>{let n=0;for(;n<e.sequence.length&&e.sequence[n].startsWith("-");)n+=1;if(n===e.sequence.length){e.is_reverse=!0,e.sequence=e.sequence.reverse();for(let a=0;a<e.sequence.length;a+=1)e.sequence[a]=O(e.sequence[a]);let t=e.sequenceNew??[];t.reverse(),e.sequenceNew=t;for(let a of t)a.nodeName=O(a.nodeName),ks(a.mismatches,oe(a.nodeName).sequenceLength);let r=e.firstNodeOffset??0,o=oe(e.sequence[0]).sequenceLength;e.firstNodeOffset=o-(e.finalNodeCoverLength??0);let s=oe(e.sequence[e.sequence.length-1]).sequenceLength;e.finalNodeCoverLength=s-r}})}function ks(e,n){e.forEach(t=>{t.type==="insertion"?t.pos=n-t.pos:t.type==="deletion"?t.pos=n-t.pos-(t.length??0):t.type==="substitution"&&(t.pos=n-t.pos-(t.seq?.length??0)),t.seq!==void 0&&(t.seq=So(t.seq).split("").reverse().join(""))})}var zs={A:"T",T:"A",C:"G",G:"C"};function So(e){let n="";for(let t=e.length-1;t>=0;t-=1)n+=zs[e.charAt(t)]??"N";return n}function Se(e){e.forEach(n=>{n.indexSequence=[],n.sequence.forEach(t=>{let r=t,o=I.get(O(r)),s=M[o]?.switched??!1;s&&(r=No(r));let a=I.get(O(r));if(a===0)throw new Error("Node "+O(r)+" has prohibited index 0");X(r)!==s?n.indexSequence.push(-a):n.indexSequence.push(a)})})}var js=20;function Vs(){let e={minX:99,maxX:-99,minY:99,maxY:-99};M.forEach(n=>{n&&(n.x!==void 0&&(e.minX=Math.min(e.minX,n.x),e.maxX=Math.max(e.maxX,n.x+js+n.pixelWidth)),n.y!==void 0&&(e.minY=Math.min(e.minY,n.y-10),e.maxY=Math.max(e.maxY,n.y+n.contentHeight+10)))}),L.forEach(n=>{n.path.forEach(t=>{let r=t.y??0;e.maxY=Math.max(e.maxY,r+n.width),e.minY=Math.min(e.minY,r)})}),qn=e}function oe(e){let n=I.get(O(e)),t=n===void 0?void 0:M[n];if(t===void 0)throw new Error(`Unknown node ${e}`);return t}function io(){return I=new Map,M.forEach((e,n)=>{e&&I.set(e.name,n)}),I}function lo(){let e=M.map(()=>new Set),n=M.map(()=>new Set),t=r=>{for(let o=0;o<r.indexSequence.length-1;o+=1){let s=Math.abs(r.indexSequence[o]),a=Math.abs(r.indexSequence[o+1]);e[s].add(a),n[a].add(s)}};L.forEach(t),_.showReads&&A.length>0&&A.forEach(t),M.forEach((r,o)=>{r&&(r.successors=Array.from(e[o]),r.predecessors=Array.from(n[o]))})}function co(e){let n=0,t=0,r=0;e.forEach(o=>{let s=Math.abs(o);if(o<0){T[s]===void 0&&(T[s]=t);let a=T[s];a<r&&(r=a),n=a,t=a-1}else{T[s]===void 0&&(T[s]=n);let a=T[s];n=a+1,t=a}}),r<0&&Wn(-r)}function Us(e){let n=0,t=0;for(;n<e.length&&T[Math.abs(e[n])]===void 0;)n+=1;if(n>=e.length)return null;let r=e[n],o,s;r>=0?(o=T[r]-1,s=-1):(o=T[-r]+1,s=1);for(let a=n-1;a>=0;a-=1){let i=Math.abs(e[a]);T[i]===void 0&&(T[i]=o,t=Math.min(t,o),o+=s)}return t<0&&Wn(-t),n}var Ks=-1;function Qs(e){let n=[];for(let t of e)n.push(t??Ks);return n}function Gn(){let e,n,t,r,o=0,s=_.showReads&&A.length>0?L.concat(A):L,a={stamp:new Int32Array(M.length),generation:0};T=new Array(M.length).fill(void 0),M.forEach(l=>{l&&(l.order=void 0)}),co(L[0].indexSequence);for(let l=1;l<s.length;l+=1){if(Fe&&console.log(`generating order for track ${l+1}`),t=Us(s[l].indexSequence),t===null){s[l].type==="haplotype"?co(s[l].indexSequence):(s.splice(l,1),A.splice(l-L.length,1),l-=1);continue}for(e=Js(s[l].indexSequence);t<e.length;){for(r=t,t+=1;t<e.length&&T[e[t]]===void 0;)t+=1;if(t<e.length){n=T[e[r]]+1;for(let c=r+1;c<t;c+=1)T[e[c]]=n,n+=1;if(T[e[t]]>T[e[r]])T[e[t]]<n&&fo(e[t],e[t-1],n);else if(s[l].indexSequence[t]>=0&&!Zs(e[t],e[r],a))fo(e[t],e[t-1],n);else if(s[l].indexSequence[r]<0||M[e[r+1]].degree<2&&T[e[t]]<T[e[r]]){n=T[e[r]]-1;for(let c=r+1;c<t;c+=1)T[e[c]]=n,o=Math.min(o,n),n-=1}}else if(s[l].indexSequence[r]>=0){n=T[e[r]]+1;for(let c=r+1;c<e.length;c+=1){let f=e[c];T[f]===void 0&&(T[f]=n,n+=1)}}else{n=T[e[r]]-1;for(let c=r+1;c<e.length;c+=1){let f=e[c];T[f]===void 0&&(T[f]=n,o=Math.min(o,n),n-=1)}}}}o<0&&Wn(-o);let i=Qs(T);T=i,i.forEach((l,c)=>{let f=M[c];f!==void 0&&(f.order=l)})}function Zs(e,n,t){t.generation+=1;let{stamp:r,generation:o}=t,s=[e];for(r[e]=o;s.length>0;){let a=s.pop();if(a===n)return!0;for(let i of M[a].successors)r[i]!==o&&(r[i]=o,s.push(i))}return!1}function uo(){let e=-1;return T.forEach(n=>{n!==void 0&&n>e&&(e=n)}),e}function Js(e){return e.map(n=>Math.abs(n))}function Wn(e){T.forEach((n,t)=>{n!==void 0&&(T[t]=n+e)})}function fo(e,n,t){let r=new Map,o=[[e,t]],s=0;for(;s<o.length;){let[a,i]=o[s];s+=1;let l=T[a];l!==void 0&&l<i&&(!r.has(a)||r.get(a)<i)&&(r.set(a,i),M[a].successors.forEach(c=>{T[c]>l&&c!==n&&o.push([c,i+1])}),a!==e&&M[a].predecessors.forEach(c=>{T[c]>l&&c!==n&&o.push([c,i+1])}))}r.forEach((a,i)=>{T[i]=a})}function ea(){M.forEach(e=>{e.tracks=[]}),L.forEach(e=>{e.indexSequence.forEach(n=>{M[Math.abs(n)].tracks.push(e.id)})}),M.forEach(e=>{e.tracks!==void 0&&(e.degree=e.tracks.length)})}function na(){let e=L[0],n=L.slice(1,L.length);if(_.showReads&&A.length>0&&(n=n.concat(A)),ta(n,e),_.showReads&&A.length>0){for(let t=0;t<A.length;t++)if(A[t]!==n[t+L.length-1])throw new Error("Read inequality")}}function ta(e,n){let t=new Map,r=n?new Set(n.sequence):null;for(let o of e){let s=o.sequence;for(let a=0;a<s.length;a+=1){let i=O(s[a]),l=oe(i);if(r&&!r.has(i)){let c=a>0?oe(s[a-1]).order:void 0,f=a<s.length-1?oe(s[a+1]).order:void 0;(c===void 0||c<l.order)&&(f===void 0||l.order<f)&&po(t,i,X(s[a])?1:-1),(c===void 0||c>l.order)&&(f===void 0||l.order>f)&&po(t,i,X(s[a])?-1:1)}}}for(let o of e)o.sequence.forEach((s,a)=>{let i=t.get(O(s));i!==void 0&&i>0&&(o.sequence[a]=No(s),o.indexSequence[a]=-o.indexSequence[a])});t.forEach((o,s)=>{if(o>0){let a=oe(s);a.seq=So(a.seq),a.switched=!0}})}function po(e,n,t){e.set(n,(e.get(n)??0)+t)}function oa(){let e=0,n=20,t=-1,r=M.slice();r.sort(un);let o=ra();r.forEach(s=>{s.order>=0&&(s.order>t&&(t=s.order,e=n+10*o[s.order]),s.x=e,n=Math.max(n,e+40+s.pixelWidth))})}function ra(){let e=[],n=[],t=[],r=[];for(let o=0;o<=Q;o+=1)e.push(0),n.push(0),t.push(0);L.forEach(o=>{for(let s=1;s<o.path.length;s+=1){let a=o.path[s],i=o.path[s-1];if(a.order===i.order)a.isForward?e[a.order]=e[a.order]+1:n[a.order]=n[a.order]+1;else{let l=Math.abs((a.y??0)-(i.y??0));t[a.order]=Math.max(l/17.5,t[a.order])}}}),r.push(Math.max(0,e[0]-1));for(let o=1;o<=Q;o+=1)r.push(Math.max(Math.max(0,e[o]-1)+Math.max(0,n[o-1]-1),t[o]));return r}function sa(){let e,n,t,r,o,s,a=[],i=[];for(let l=0;l<=Q;l+=1){ye[l]=[],i[l]=new Map,a[l]=[];for(let c=0;c<L.length;c+=1)a[l][c]=null}L.forEach((l,c)=>{n=Math.abs(l.indexSequence[0]),t=ln(l.indexSequence[0]),r=M[n],l.path=[],l.path.push({order:r.order,lane:null,isForward:t,node:n}),H(r.order,n,c,0,a,i),e=1;for(let f=1;f<l.sequence.length;f+=1)if(o=r,s=t,n=Math.abs(l.indexSequence[f]),t=ln(l.indexSequence[f]),r=M[n],r.order>o.order){s||(l.path.push({order:o.order,lane:null,isForward:!0,node:null}),H(o.order,null,c,e,a,i),e+=1);for(let u=o.order+1;u<r.order;u+=1)l.path.push({order:u,lane:null,isForward:!0,node:null}),H(u,null,c,e,a,i),e+=1;t?(l.path.push({order:r.order,lane:null,isForward:!0,node:n}),H(r.order,n,c,e,a,i),e+=1):(l.path.push({order:r.order,lane:null,isForward:!0,node:null}),H(r.order,null,c,e,a,i),e+=1,l.path.push({order:r.order,lane:null,isForward:!1,node:n}),H(r.order,n,c,e,a,i),e+=1)}else if(r.order<o.order){s&&(l.path.push({order:o.order,lane:null,isForward:!1,node:null}),H(o.order,null,c,e,a,i),e+=1);for(let u=o.order-1;u>r.order;u-=1)l.path.push({order:u,lane:null,isForward:!1,node:null}),H(u,null,c,e,a,i),e+=1;t?(l.path.push({order:r.order,lane:null,isForward:!1,node:null}),H(r.order,null,c,e,a,i),e+=1,l.path.push({order:r.order,lane:null,isForward:!0,node:n}),H(r.order,n,c,e,a,i),e+=1):(l.path.push({order:r.order,lane:null,isForward:!1,node:n}),H(r.order,n,c,e,a,i),e+=1)}else t!==s?(l.path.push({order:r.order,lane:null,isForward:t,node:n}),H(r.order,n,c,e,a,i),e+=1):(l.path.push({order:r.order,lane:null,isForward:!t,node:null}),H(r.order,null,c,e,a,i),e+=1,l.path.push({order:r.order,lane:null,isForward:t,node:n}),H(r.order,n,c,e,a,i),e+=1)});for(let l=0;l<=Q;l+=1)ia(ye[l],l)}function H(e,n,t,r,o,s){let a={trackID:t,segmentID:r,compareToFromSame:o[e][t]??null},i=n===null?void 0:s[e].get(n);if(i===void 0){let l={type:"single",node:n,tracks:[a]};ye[e].push(l),n!==null&&s[e].set(n,l)}else i.type="multiple",i.tracks.push(a);o[e][t]=a}function aa(e,n){let t;e.forEach(r=>{r.idealLane=0,r.tracks.forEach(o=>{if(o.segmentID===0)o.idealLane=o.trackID,o.idealY=null;else if(L[o.trackID].path[o.segmentID-1].order===n-1)o.idealLane=L[o.trackID].path[o.segmentID-1].lane??void 0,o.idealY=L[o.trackID].path[o.segmentID-1].y;else if(o.segmentID<L[o.trackID].path.length-1&&L[o.trackID].path[o.segmentID+1].order===n-1)o.idealLane=L[o.trackID].path[o.segmentID+1].lane??void 0,o.idealY=L[o.trackID].path[o.segmentID+1].y;else{for(t=o.segmentID-1;t>=0&&L[o.trackID].path[t].order!==n-1;)t-=1;t<0?(o.idealLane=o.trackID,o.idealY=null):(o.idealLane=L[o.trackID].path[t].lane??void 0,o.idealY=L[o.trackID].path[t].y)}r.idealLane+=o.idealLane}),r.idealLane/=r.tracks.length})}function ia(e,n){let t=0,r=new Set,o=20,s=!1,a=-1;aa(e,n),e.sort(mo),e.forEach(i=>{i.node!==null?(M[i.node].topLane=t,s&&(o-=10),M[i.node].y=o,M[i.node].contentHeight=0,s=!1):(s?o-=25:o>20&&(o-=10),s=!0),i.tracks.sort(mo),i.tracks.forEach(l=>{l.lane=t,l.trackID===a&&i.node===null&&s&&(o+=10),L[l.trackID].path[l.segmentID].lane=t,L[l.trackID].path[l.segmentID].y=o,l.idealY!=null&&r.add(l.idealY-o),t+=1,o+=L[l.trackID].width,i.node!==null&&(M[i.node].contentHeight+=L[l.trackID].width),a=l.trackID}),o+=25}),la(e,r)}function la(e,n){let t=0,r=Number.MAX_SAFE_INTEGER;n.forEach(o=>{ho(e,o)<r&&(r=ho(e,o),t=o)}),e.forEach(o=>{o.node!==null&&(M[o.node].y+=t),o.tracks.forEach(s=>{let a=L[s.trackID].path[s.segmentID];a.y=a.y+t})})}function ca(e,n){e.order<0||ye[e.order]===void 0||(ye[e.order].forEach(t=>{if(t.node!==null){let r=M[t.node];r!==e&&r.y>e.y&&(r.y+=n,t.tracks.forEach(o=>{let s=L[o.trackID].path[o.segmentID];s.y=s.y+n}))}else t.tracks.forEach(r=>{let o=L[r.trackID].path[r.segmentID];o.y>=e.y&&(o.y=o.y+n)})}),Ee[e.order].length>0&&Ee[e.order].forEach(t=>{M[t]!==e&&M[t].y>e.y&&(M[t].y+=n)}))}function ho(e,n){let t=0;return e.forEach(r=>{r.tracks.forEach(o=>{o.idealY!=null&&L[o.trackID].type!=="read"&&(t+=Math.abs(o.idealY-n-L[o.trackID].path[o.segmentID].y)*L[o.trackID].width)})}),t}function mo(e,n){return e.idealLane!==void 0?n.idealLane!==void 0?e.idealLane<n.idealLane?-1:e.idealLane>n.idealLane?1:0:-1:n.idealLane!==void 0?1:0}function un(e,n){if(!e)return n?-1:0;if(!n)return 1;if(e.order!==void 0){if(n.order!==void 0){if(e.order<n.order)return-1;if(e.order>n.order)return 1;if(e.y!==void 0&&n.y!==void 0){if(e.y<n.y)return-1;if(e.y>n.y)return 1}return 0}return-1}return n.order!==void 0?1:0}function ua(){let e,n,t={};$n.forEach(r=>{let o=0;for(;o<L.length&&L[o].name!==r.track;)o+=1;o<L.length&&(e=0,L[o].path.forEach(s=>{s.node!==null&&(t={},n=e+M[s.node].sequenceLength-1,e>=r.start&&e<=r.end&&(t.start=0),e<r.start&&n>=r.start&&(t.start=r.start-e),n<=r.end&&n>=r.start&&(t.end=n-e,n<r.end&&(t.continue=!0)),n>r.end&&e<=r.end&&(t.end=r.end-e),t.start!==void 0&&(t.type=r.type,t.name=r.name,s.features===void 0&&(s.features=[]),s.features.push(t)),e=n+1)}))})}function da(){let e=!0,n=4,t=_.trackWidth;L.forEach(r=>{r.freq!==void 0?r.width=Math.round((Math.log(r.freq)+1)*n):(r.width=t,r.type!==void 0&&r.type==="read"&&(r.width=n)),r.width!==n&&(e=!1)}),e&&L.forEach(r=>{r.freq!==void 0&&(r.width=t)})}function fa(e){let n=e.path[0],t=M[n.node],r=e.firstNodeOffset??0;return Xn(t,n.isForward?r:t.sequenceLength-r)}function pa(e){let n=e.path[e.path.length-1],t=M[n.node],r=e.finalNodeCoverLength??0;return Xn(t,n.isForward?r:t.sequenceLength-r)}function Ro(e,n){return n>e.sequenceLength?null:Xn(e,n)}function Xn(e,n){let[t,r]=ba(e);if(e.sequenceLength===0)return t;let o=Math.min(Math.max(n,0),e.sequenceLength);return t+o/e.sequenceLength*(r-t)}function ha(){let e,n,t,r,o,s,a,i,l;for(let u=0;u<=Q;u+=1)Fn.push(0),Hn.push(0);let c=[],f=[];M.forEach(u=>{u.x!==void 0&&(c[u.order]=u.x,f[u.order]===void 0?f[u.order]=u.x+u.pixelWidth:f[u.order]=Math.max(f[u.order],u.x+u.pixelWidth))}),L.sort(Hs),L.forEach(u=>{a="plain",o=Re(u,a),s=vs(u);let d=a,h=()=>(d!==a&&(d=a,o=Re(u,a)),o);t=u.path[0].y,u.type!=="read"?u.sequence[0].startsWith("-")?e=f[u.path[0].order]+20:e=c[u.path[0].order]-20:e=fa(u);for(let p=0;p<u.path.length;p+=1)u.path[p].y===t?u.path[p].features!==void 0&&(l=p>0&&u.path[p-1].order===u.path[p].order,i=go(u.path[p],c[u.path[p].order],f[u.path[p].order],a,u,e,t,o,l),a=i.highlight,e=i.xStart):(u.path[p-1].isForward?n=f[u.path[p-1].order]:n=c[u.path[p-1].order],n!==e&&(o=h(),G.rectangles.push({xStart:Math.min(e,n),yStart:t,xEnd:Math.max(e,n),yEnd:t+u.width-1,color:o,alpha:s,id:u.id,name:u.name,type:u.type})),u.path[p].order-1===u.path[p-1].order?(e=n,n=c[u.path[p].order],r=u.path[p].y,o=h(),G.curves.push({xStart:e,yStart:t,xEnd:n+1,yEnd:r,width:u.width,color:o,alpha:s,laneChange:Math.abs(u.path[p].lane-u.path[p-1].lane),id:u.id,name:u.name,type:u.type,nodeStart:u.path[p-1]?.node,nodeEnd:u.path[p]?.node}),e=n,t=r):u.path[p].order+1===u.path[p-1].order?(e=n,n=f[u.path[p].order],r=u.path[p].y,o=h(),G.curves.push({xStart:e+1,yStart:t,xEnd:n,yEnd:r,width:u.width,color:o,alpha:s,laneChange:Math.abs(u.path[p].lane-u.path[p-1].lane),id:u.id,name:u.name,type:u.type,nodeStart:u.path[p-1]?.node,nodeEnd:u.path[p]?.node}),e=n,t=r):u.path[p-1].isForward?(r=u.path[p].y,xo(1,n,t,r,u.width,o,u.id,u.path[p].order,u.type,u.name),e=f[u.path[p].order],t=u.path[p].y):(r=u.path[p].y,xo(-1,n,t,r,u.width,o,u.id,u.path[p].order,u.type,u.name),e=c[u.path[p].order],t=u.path[p].y),u.path[p].features!==void 0&&(l=u.path[p-1].order===u.path[p].order,i=go(u.path[p],c[u.path[p].order],f[u.path[p].order],a,u,e,t,o,l),a=i.highlight,e=i.xStart));u.type!=="read"?u.path[u.path.length-1].isForward?n=f[u.path[u.path.length-1].order]+20:n=c[u.path[u.path.length-1].order]-20:n=pa(u),G.rectangles.push({xStart:Math.min(e,n),yStart:t,xEnd:Math.max(e,n),yEnd:t+u.width-1,color:o,alpha:s,id:u.id,name:u.name,type:u.type})})}var ma=1e9;function bo(e,n){an=new Map;let t=new Map,r=_.ignoreStrand;for(let d of e){let h=d.indexSequence;if(!(!h||h.length<2))for(let p=0;p<h.length-1;p+=1){let m=h[p],b=h[p+1],g=Math.abs(m),y=Math.abs(b),w=M[g],N=M[y];if(!w||!N)continue;let S;if(r){let x=`${m}>${b}`,E=`${-b}>${-m}`;S=x<E?x:E}else S=`${m}>${b}`;let R=t.get(S);R===void 0?t.set(S,{sSigned:m,dSigned:b,sName:m<0?`-${w.name}`:w.name,dName:b<0?`-${N.name}`:N.name,count:1,sourceTrackID:d.sourceTrackID}):R.count+=1}}let o=0;for(let d of t.values())d.count>o&&(o=d.count);let s=cn,a=60,i=d=>o<=1?s:s+(a-s)*Math.sqrt(d/o),l=[],c=0;for(let d of t.values()){let h=ma+c,p=`${d.count.toLocaleString()} ${n}${d.count===1?"":"s"}: Node ${d.sName} \u2192 Node ${d.dName}`;an.set(h,{count:d.count,label:p});let m=M[Math.abs(d.sSigned)]?.sequenceLength??0;l.push({id:h,sourceTrackID:d.sourceTrackID,type:"read",name:p,sequence:[d.sName,d.dName],indexSequence:[],path:[],width:i(d.count),firstNodeOffset:m,finalNodeCoverLength:0,sequenceNew:[{nodeName:d.sName,mismatches:[]},{nodeName:d.dName,mismatches:[]}],mapping_quality:0,is_secondary:!1,sample_name:null,read_group:null,score:d.count}),c+=1}let f="?",u=0;for(let d of M){if(!d)continue;let h=d.contentHeight;h>u&&(u=h,f=d.name)}return Fe&&console.log(`[coarsened] ${n}s_in=${e.length} edges_out=${l.length} tallestNodeBeforePlace=${f}(${u.toFixed(1)})`),l}function go(e,n,t,r,o,s,a,i,l){let c=r,f,u,d,h;n-=8,t+=8;let p=M[e.node].sequenceLength;return e.features.sort((m,b)=>m.start-b.start),e.features.forEach(m=>{c!==m.type&&(f=Re(o,c),e.isForward?(d=n+Math.round(m.start*(t-n+1)/p),l&&d<n+8&&(h=n+Math.round((m.end+1)*(t-n+1)/p)-1,u=Re(o,m.type),G.featureRectangles.push({xStart:d,yStart:a,xEnd:h,yEnd:a+o.width-1,color:u,id:o.id,name:o.name,type:o.type})),d>s+1&&G.featureRectangles.push({xStart:s,yStart:a,xEnd:d-1,yEnd:a+o.width-1,color:f,id:o.id,name:o.name,type:o.type})):(d=t-Math.round(m.start*(t-n+1)/p),l&&d>t-8&&(h=t-Math.round((m.end+1)*(t-n+1)/p)-1,u=Re(o,m.type),G.featureRectangles.push({xStart:h,yStart:a,xEnd:d,yEnd:a+o.width-1,color:u,id:o.id,name:o.name,type:o.type})),s>d+1&&G.featureRectangles.push({xStart:d+1,yStart:a,xEnd:s,yEnd:a+o.width-1,color:f,id:o.id,name:o.name,type:o.type})),s=d,c=m.type),(m.end<p-1||m.continue===void 0)&&(f=Re(o,c),e.isForward?(h=n+Math.round((m.end+1)*(t-n+1)/p)-1,G.featureRectangles.push({xStart:s,yStart:a,xEnd:h,yEnd:a+o.width-1,color:f,id:o.id,name:o.name,type:o.type})):(h=t-Math.round((m.end+1)*(t-n+1)/p)-1,G.featureRectangles.push({xStart:h,yStart:a,xEnd:s,yEnd:a+o.width-1,color:f,id:o.id,name:o.name,type:o.type})),s=h+1,c="plain")}),{xStart:s,highlight:c}}var yo=7;function xo(e,n,t,r,o,s,a,i,l,c){let f=e===1?Hn:Fn,u=10*f[i],d=n+e*(u+5),h=yo,p=Math.min(yo,o),m=Math.min(t,r),b=Math.max(t,r),g=e===1?n:d-1,y=e===1?d:n,w=x=>{G.verticalRectangles.push({xStart:g,yStart:x,xEnd:y,yEnd:x+o-1,color:s,id:a,name:c,type:l})};w(t),G.verticalRectangles.push({xStart:e===1?d+h:d-h-p,yStart:m+o+h-1,xEnd:e===1?d+h+p-1:d-h-1,yEnd:b-h+1,color:s,id:a,name:c,type:l}),w(r);let N=d+e*h,S=d+e*(h+p),R=`M ${d} ${b}`;R+=` Q ${N} ${b} ${N} ${b-h}`,R+=` H ${S}`,R+=` Q ${S} ${b+o} ${d} ${b+o}`,R+=" Z ",G.corners.push({path:R,color:s,id:a,type:l}),R=`M ${d} ${m}`,R+=` Q ${S} ${m} ${S} ${m+o+h}`,R+=` H ${N}`,R+=` Q ${N} ${m+o} ${d} ${m+o}`,R+=" Z ",G.corners.push({path:R,color:s,id:a,type:l}),f[i]+=1}function ba(e){let n=e.x-4,t=e.x+e.pixelWidth+4;return[n,t]}function Mo(){switch(M.forEach(e=>{e.sequenceLength===void 0&&(e.sequenceLength=e.seq.length)}),_.nodeWidthOption){case"compressed":M.forEach(e=>{e.width=1+Math.log(e.sequenceLength)/Math.log(2),e.pixelWidth=Math.round((e.width-1)*8.401)});break;case"small":M.forEach(e=>{e.width=e.sequenceLength/100,e.pixelWidth=Math.round((e.width-1)*8.401)});break;case"fixed":M.forEach(e=>{e.width=10,e.pixelWidth=Math.round(e.width*8.401)});break;case"normal":{let e=_.charWidth;M.forEach(n=>{n.width=n.sequenceLength;let t=n.seq?.length??1;n.pixelWidth=Math.round(e*t)});break}default:throw new Error(`${_.nodeWidthOption} not implemented`)}}function ga(){let e,n,t=Array.from(M,()=>new Set),r=Array.from(M,()=>new Set),o;_.showReads&&A.length>0?o=L.concat(A):o=L,o.forEach(i=>{for(let l=0;l<i.sequence.length;l+=1)X(i.sequence[l])?(e=O(i.sequence[l]),l>0?(n=i.sequence[l-1],X(n)?r[I.get(e)].add(O(n)):(r[I.get(e)].add(n),r[I.get(e)].add(fe(n)))):i.type==="haplotype"&&r[I.get(e)].add("None"),l<i.sequence.length-1?(n=i.sequence[l+1],X(n)?t[I.get(e)].add(O(n)):(t[I.get(e)].add(n),t[I.get(e)].add(fe(n)))):i.type==="haplotype"&&t[I.get(e)].add("None")):(l>0?(e=i.sequence[l-1],t[I.get(i.sequence[l])].add(e),X(e)&&t[I.get(i.sequence[l])].add(O(e))):i.type==="haplotype"&&t[I.get(i.sequence[l])].add("None"),l<i.sequence.length-1?(e=i.sequence[l+1],r[I.get(i.sequence[l])].add(e),X(e)&&r[I.get(i.sequence[l])].add(O(e))):i.type==="haplotype"&&r[I.get(i.sequence[l])].add("None"))});let s=t.map(i=>Array.from(i)),a=r.map(i=>Array.from(i));if(_.showReads&&A.length>0){let i=M.slice();i.sort(un);let l=new Map,c=new Map,f=d=>{let h=l.get(d);if(h===void 0)throw new Error(`No merge offset recorded for node ${d}`);return h},u=d=>{let h=c.get(d);if(h===void 0)throw new Error(`No merge origin recorded for node ${d}`);return h};i.forEach(d=>{let h=qe(I.get(d.name),s,a);if(h){let p=f(h)+oe(h).sequenceLength;l.set(d.name,p),l.set(fe(d.name),p),c.set(d.name,u(h)),c.set(fe(d.name),u(h))}else l.set(d.name,0),l.set(fe(d.name),0),c.set(d.name,d.name),c.set(fe(d.name),d.name)}),A.forEach(d=>{let h=d.sequenceNew??[];d.firstNodeOffset=(d.firstNodeOffset??0)+f(d.sequence[0]),d.finalNodeCoverLength=(d.finalNodeCoverLength??0)+f(d.sequence[d.sequence.length-1]);for(let p=d.sequence.length-1;p>=0;p-=1){let m=O(d.sequence[p]),b=qe(I.get(m),s,a);if(b&&Dn(I.get(b),s,a))if(p>0){d.sequence.splice(p,1);let g=oe(b).sequenceLength;h[p].mismatches.forEach(y=>{y.pos+=g}),h[p-1].mismatches=h[p-1].mismatches.concat(h[p].mismatches),h.splice(p,1)}else{d.sequence[0]=u(d.sequence[0]);let g=h[0],y=f(g.nodeName);g.mismatches.forEach(w=>{w.pos+=y}),g.nodeName=u(g.nodeName)}}})}for(let i=0;i<M.length;i+=1)if(Dn(i,s,a)&&!qe(i,s,a)){let l=i;for(;Dn(l,s,a);)l=I.get(O(a[l][0])),M[i].sequenceLength+=M[l].sequenceLength,M[i].seq+=M[l].seq}L.forEach(i=>{for(let l=i.sequence.length-1;l>=0;l-=1){e=O(i.sequence[l]);let c=I.get(e);qe(c,s,a)&&i.sequence.splice(l,1)}});for(let i=M.length-1;i>=0;i-=1)qe(i,s,a)&&M.splice(i,1)}function qe(e,n,t){if(n[e].length!==1||n[e][0]==="None")return!1;let r=O(n[e][0]),o=I.get(r);return t[o].length!==1||t[o][0]==="None"?!1:r}function Dn(e,n,t){if(t[e].length!==1||t[e][0]==="None")return!1;let r=O(t[e][0]),o=I.get(r);return!(n[o].length!==1||n[o][0]==="None")}function ya(e){let n=_.focusReadNames?new Set(_.focusReadNames):null;return e.filter(t=>t.is_secondary!==!0&&(t.mapping_quality??0)>=_.mappingQualityCutoff&&(n===null||t.name!==void 0&&n.has(t.name)))}function xa(e,n){let t=new Map;for(let r of e){let o=n(r),s=t.get(o);s===void 0?t.set(o,[r]):s.push(r)}return t}function Ma(e,n){return e.xStart<n.xStart?1:e.xStart>n.xStart?-1:e.yStart>n.yStart?1:e.yStart<n.yStart?-1:0}function Eo(e,n){let t=xa(e.filter(s=>s.type===n),s=>`${s.nodeStart},${s.nodeEnd}`);t.forEach(s=>{let a=.3,i=.4/s.length;s.length<=5&&(a=.5,i=0),s.sort(Ma),s.forEach(l=>{let c,f;l.yStart<l.yEnd?(c=l.xStart+(l.xEnd-l.xStart)*(1-a),a+=i,f=l.xStart+(l.xEnd-l.xStart)*(1-a)):(c=l.xStart+(l.xEnd-l.xStart)*a,a+=i,f=l.xStart+(l.xEnd-l.xStart)*a);let u=`M ${l.xStart} ${l.yStart}`;u+=` C ${c} ${l.yStart} ${c} ${l.yEnd} ${l.xEnd} ${l.yEnd}`,u+=` V ${l.yEnd+l.width}`,u+=` C ${f} ${l.yEnd+l.width} ${f} ${l.yStart+l.width} ${l.xStart} ${l.yStart+l.width}`,u+=" Z",l.path=u})});let r=Array.from(t.keys());r.sort(function(s,a){let i=s.split(",").map(Number),l=a.split(",").map(Number),c=i[0]??0,f=i[1]??0,u=l[0]??0,d=l[1]??0;return c<u?-1:c>u?1:f<d?-1:f>d?1:0});let o=[];for(let s of r){let a=t.get(s);a!==void 0&&o.push(...a)}return o}function Ao(e){let n=`M ${e.x-9} ${e.y} Q ${e.x-9} ${e.y-9} ${e.x} ${e.y-9}`,t=e.x,r=e.y-9;return e.width>1&&(t+=e.pixelWidth,n+=` L ${t} ${r}`),n+=` Q ${t+9} ${r} ${t+9} ${r+9}`,t+=9,r+=9,e.contentHeight>0&&(r+=e.contentHeight-0,n+=` L ${t} ${r}`),n+=` Q ${t} ${r+9} ${t-9} ${r+9}`,t-=9,r+=9,e.width>1&&(t-=e.pixelWidth,n+=` L ${t} ${r}`),n+=` Q ${t-9} ${r} ${t-9} ${r-9}`,t-=9,r-=9,e.contentHeight>0&&(r-=e.contentHeight-0,n+=` L ${t} ${r}`),n}function Yn(e){return e.id.endsWith("-")?"-":"+"}function kn(e,n){return n===Yn(e)?e.id:`-${e.id}`}function wa(e,n){let t=e.map(()=>{}),r=0,o=0;for(;o<e.length&&e[o]!==void 0;o++)t[o]=r,r+=e[o];let s=n;for(let a=e.length-1;a>o&&e[a]!==void 0;a--)s-=e[a],t[a]=s;return t}function La(e,n){let t=e.path.map(()=>[]);if(e.cs===void 0)return t;let r=wa(n,e.pathLength),o=(i,l=!1)=>{for(let c=0;c<r.length;c++){let f=r[c],u=n[c];if(f!==void 0&&u!==void 0&&f<=i&&(i<f+u||l&&i===f+u))return{s:c,local:i-f,room:f+u-i}}},s=(i,l)=>{let c=t[i],f=c.at(-1);l.type==="substitution"&&f?.type==="substitution"&&f.pos+f.seq.length===l.pos?f.seq+=l.seq:c.push(l)},a=e.pathStart;for(let i of st(e.cs))if(i.op==="match")a+=i.length;else if(i.op==="substitution"){let l=o(a);l&&s(l.s,{type:"substitution",pos:l.local,seq:i.seq}),a+=1}else if(i.op==="insertion"){let l=o(a,a===e.pathEnd);l&&s(l.s,{type:"insertion",pos:l.local,seq:i.seq})}else{let l=i.length;for(;l>0;){let c=o(a),f=c?Math.min(l,c.room):l;c&&s(c.s,{type:"deletion",pos:c.local,length:f}),a+=f,l-=f}}return t}function To(e,n,t){let r=new Map(e.nodes.map(s=>[s.name,s])),o=[];for(let s of n){let a=s.path.map(f=>r.get(f.name)),i=a.flatMap((f,u)=>f?[u]:[]),l=i[0],c=i.at(-1);if(l!==void 0&&c!==void 0){let f=La(s,a.map(h=>h?.length)),u=i.map(h=>kn(a[h],s.path[h].strand)),d=a[c].length;o.push({id:t+o.length,name:s.name,type:"read",sourceTrackID:1,sequence:u,sequenceNew:i.map((h,p)=>({nodeName:u[p],mismatches:f[h]})),firstNodeOffset:l===0?s.pathStart:0,finalNodeCoverLength:c===s.path.length-1?d-(s.pathLength-s.pathEnd):d,mapping_quality:s.mappingQuality===255?0:s.mappingQuality,is_secondary:s.secondary,is_reverse:s.strand==="-"})}}return o}var Na=["#6baed6","#4292c6","#2171b5","#08519c"],Sa=["#fb6a4a","#ef3b2c","#cb181d","#a50f15"];function Co(e){let n=e.is_reverse?Sa:Na;return n[e.id%n.length]}function Ra(e){let n=new Map;for(let[t,r]of e.pathVisits??[])for(let o of r){let s=`${o.path} ${t}`,a=n.get(s);a?a.push(o.strand):n.set(s,[o.strand])}return n}function Ea(e){let n=new Map(e.nodes.map(s=>[s.id,s])),t=Ra(e),r=(e.paths??[]).map((s,a)=>({path:s,index:a})),o=r.findIndex(s=>Le(s.path.name).name===e.referencePath);return o>0&&r.unshift(...r.splice(o,1)),r.flatMap(({path:s,index:a})=>{let i=Le(s.name).name,l=new Map,c=s.nodeIds.flatMap(f=>{let u=n.get(f);if(!u)return[];let d=l.get(u.name)??0;l.set(u.name,d+1);let h=t.get(`${i} ${u.name}`)?.[d]??Yn(u);return[kn(u,h)]});return c.length>0?[{id:a,name:s.name,sequence:c,sourceTrackID:0,type:"haplotype"}]:[]})}function Aa(e){return e.nodes.map(n=>({name:n.id,seq:"",sequenceLength:Math.max(1,n.length)}))}function Ae(e){return(e.paths?.length??0)>0}var Ta=600,Ca=3,Ia=15;function _a(e){return Math.max(Ca,Math.min(Ia,Math.floor(Ta/Math.max(1,e))))}function Io(e){let n=e.paths??[],t=Ea(e),r=e.reads?To(e,e.reads,n.length):[];return Lo(Aa(e),t,r,{nodeWidthOption:"compressed",trackWidth:_a(t.length),trackColor:o=>o.type==="read"?Co(o):ct(o.id,n.length)})}function zn(e){let n=[];return e.nodes.forEach(t=>{t.order>=0&&n.push(t)}),n}function _o(e,n,t,r){let o=e.y+e.contentHeight/2-n;return[{x:t,y:o},{x:r,y:o}]}function vo(e,n){return{minY:e.bounds.minY-n,maxY:e.bounds.maxY-n}}function Bo(e){let n=Ae(e)?Io(e):void 0;if(!n)return;let t=n.bounds.minY,r={};for(let a of zn(n))r[a.name]=_o(a,t,a.x,a.x+a.pixelWidth);let{minY:o,maxY:s}=vo(n,t);return{nodePositions:r,tubeMap:{layout:n,yOffset:t},extent:{minX:n.bounds.minX,maxX:n.bounds.maxX,minY:o,maxY:s}}}function va(e,n){let t=new Map(e.nodes.map(i=>[i.id,i])),r=new Map;for(let i of zn(n)){let l=r.get(i.order);l?l.push(i):r.set(i.order,[i])}let o=[],s=-1/0;for(let i of[...r.keys()].sort((l,c)=>l-c)){let l=r.get(i),c=1/0,f=-1/0;for(let u of l){let d=t.get(u.name);d&&B(d)&&(c=Math.min(c,d.stable.start),f=Math.max(f,d.stable.start+u.sequenceLength))}c===1/0&&(c=f=s),c<s&&(c=s,f=Math.max(s,f)),s=Math.max(s,f),o.push({order:i,x0:Math.min(...l.map(u=>u.x)),x1:Math.max(...l.map(u=>u.x+u.pixelWidth)),bp0:c,bp1:f})}let a=o.find(i=>i.bp0!==-1/0);for(let i of o)i.bp0===-1/0&&(i.bp0=i.bp1=a?.bp0??0);return o}function Ba(e){return e.nodes.some(B)&&Ae(e)}function Oo(e){let n=Ba(e)?Io(e):void 0;if(!n)return;let t=va(e,n),r=new Map(t.map(a=>[a.order,a])),o=n.bounds.minY,s={};for(let a of zn(n)){let i=r.get(a.order);s[a.name]=_o(a,o,i.bp0,i.bp1)}return{nodePositions:s,tubeMap:{layout:n,yOffset:o,columns:t},referenceAxis:!0,pixelRows:!0,extent:vo(n,o)}}function Po(e){let n=le(e);if(n.length!==0)return{nodePositions:ce(n),referenceAxis:!0,pixelRows:!0}}function Go(e){return e.sample??Ue(e.name)}function Oa(e){return e.haplotype!==void 0&&e.sample!==void 0?`${e.sample}#${e.haplotype}`:Go(e)}function Pa(e,n,t,r=!0){if(!t||!r)return{ids:e,complete:!0};let o=-1,s=-1,a=-1/0,i=1/0;if(e.forEach((c,f)=>{let u=n.get(c);u&&(u.end<=t.start&&u.end>a&&(a=u.end,o=f),u.start>=t.end&&u.start<i&&(i=u.start,s=f))}),o<0||s<0)return{ids:e,complete:!1};let l=e.slice(Math.min(o,s)+1,Math.max(o,s));return{ids:o<s?l:l.reverse(),complete:!0}}function Do(e,n,t){let r=e.paths??[],o=r.find(h=>Le(h.name).name===e.referencePath)??r[0];if(!o||r.length<2)return;let s=new Map(e.nodes.map(h=>[h.id,h.length])),a=e.anchorPaths?.find(h=>h.name===Le(o.name).name)?.start??0,i=n&&n.end>n.start?n:void 0,l=new Map,c=a;for(let h of o.nodeIds){let p=s.get(h)??0;l.has(h)||l.set(h,{start:c,end:c+p}),c+=p}let f=i===void 0||[...l.values()].some(h=>h.end<=i.start)&&[...l.values()].some(h=>h.start>=i.end),u=h=>{let{ids:p,complete:m}=Pa(h.nodeIds,l,i,f),b=[],g=0,y=0,w=0;for(let N of p){let S=s.get(N)??0,R=l.get(N),x=b.at(-1),E=x?.referenceStart,C=R&&E!==void 0&&w>=0&&E+x.bp===R.start,P=R&&E!==void 0&&w<=0&&R.end===E;!R&&x&&!x.onReference?x.bp+=S:C||P?(x.bp+=S,C||(x.referenceStart=R.start,x.reversed=!0),w=C?1:-1):(b.push({start:g,bp:S,onReference:R!==void 0,referenceStart:R?.start}),w=0),g+=S,R||(y+=S)}return{name:h.name,label:Oa(h),sample:Go(h),haplotype:h.haplotype,bp:g,offReferenceBp:y,complete:m,runs:b}};return{origin:i?i.start:a,unit:t,reference:u(o),rows:r.filter(h=>h!==o).map(u).sort((h,p)=>Number(p.complete)-Number(h.complete)||p.bp-h.bp||h.label.localeCompare(p.label))}}var Ga=1.3;function Da(e){let n=e.reference.bp;for(let t of e.rows)n=Math.max(n,t.bp);return{maxX:e.origin+n*Ga,maxY:e.rows.length*20}}function $o(e,n){let t=le(e),r=Do(e,n);if(t.length===0||!r)return;let o=ce(t),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:Da(r)}}var $a="Force-directed layout",re=e=>e.nodes.some(B),qo=e=>re(e)&&(e.paths?.length??0)>1,Fo=e=>re(e)&&Ae(e),Ho=e=>re(e)&&e.nodes.some(Ke),jn=[{value:"auto",label:"Anchored",description:"x is reference bp, one row per stable rank. Needs rGFA tags or a reference path.",run:Zt,cutMargins:!0,available:re,drawsLocally:re},{value:"samplerows",label:"Sample rows",description:"x is reference bp, one row per contributing assembly. Needs rGFA tags or a reference path.",run:oo,cutMargins:!0,available:Ho,drawsLocally:Ho},{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:$o,cutMargins:!1,available:qo,drawsLocally:qo},{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:to,cutMargins:!1,available:re,drawsLocally:re},{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:Po,cutMargins:!0,available:re,drawsLocally:re},{value:"tubemap",label:"Tube map",description:"sequenceTubeMap: every path a coloured tube through boxed nodes, columns in node order and node widths log-scaled. Needs P or W lines.",run:Bo,cutMargins:!1,available:Ae,drawsLocally:Ae},{value:"tubemapref",label:"Tube map on reference",description:"The tube map with each column at the reference bp it covers, so the tubes line up with the tracks around them. Needs P or W lines and a reference path.",run:Oo,cutMargins:!0,available:Fo,drawsLocally:Fo},{value:"force",label:$a,description:"OGDF FMMM, via the external Bandage engine.",run:()=>{},cutMargins:!1,available:()=>!0,drawsLocally:()=>!1}],Yc=jn.map(e=>e.value);function kc(e,n){return!qa(e).drawsLocally(n)}function qa(e){return jn.find(n=>n.value===e)??jn[0]}var Y=be(Vn(),1);var $=be(Vn(),1);function He(e,n){return(0,$.packAbgr)((0,$.abgrRed)(e),(0,$.abgrGreen)(e),(0,$.abgrBlue)(e),Math.round((0,$.abgrAlpha)(e)*n))}function Vc(e,n){return(0,$.packAbgr)(Math.min(255,Math.round((0,$.abgrRed)(e)*n)),Math.min(255,Math.round((0,$.abgrGreen)(e)*n)),Math.min(255,Math.round((0,$.abgrBlue)(e)*n)),(0,$.abgrAlpha)(e))}var Xo=new WeakMap;function Yo(e,n,t,r,o){let{scaleX:s,scaleY:a}=t,i=Xo.get(e);if(i?.graph===n&&i.scaleX===s&&i.scaleY===a&&i.deletions===r&&i.version===o)return i.curves;let l=new Map;for(let c=0;c<n.edges.length;c++){let f=n.edges[c],u=e[f.from],d=e[f.to];if(u?.length&&d?.length){let h=r?.get(c);l.set(c,Oe(u,d,St(f),0,0,t,h?Nn(e,h):[]))}}return Xo.set(e,{graph:n,scaleX:s,scaleY:a,deletions:r,version:o,curves:l}),l}var Fa=(0,Y.packAbgr)(119,119,119,217),ko=(0,Y.packAbgr)(136,136,136,217),Ha=(0,Y.packAbgr)(24,24,28,240),Wa=2.2,Xa=(0,Y.packAbgr)(30,30,36,245),Ya=1.8,dn=.18,ka=11,za=1.2,ja=1e-6,Va=7,Ua=3,Ka=3,Qa=1.5,Za=.5,Ja=.45,Un=12,ei=1e-6,pe=new Float64Array(64),xe=new Float64Array(64),Me=new Float64Array(64);function ni(e,n,t,r){let o=e.length*Un+1;pe.length<o&&(pe=new Float64Array(o),xe=new Float64Array(o),Me=new Float64Array(o));let s=e[e.length-1];pe[0]=s.x1,xe[0]=s.y1,Me[0]=0;let a=1,i=0;for(let l=e.length-1;l>=0&&i<r;l--){let c=e[l];for(let f=1;f<=Un&&i<r;f++){let u=1-(f/Un)**2,d=1-u,h=d*d*d,p=3*d*d*u,m=3*d*u*u,b=u*u*u,g=h*c.x0+p*c.cx0+m*c.cx1+b*c.x1,y=h*c.y0+p*c.cy0+m*c.cy1+b*c.y1;i+=Math.hypot(g-pe[a-1],(y-xe[a-1])*t)*n,pe[a]=g,xe[a]=y,Me[a]=i,a++}}return a}function zo(e,n){let t=1;for(;t<e-1&&Me[t]<n;)t++;let r=Me[t-1],o=Me[t],s=o>r?Math.min(1,Math.max(0,(n-r)/(o-r))):0;return{x:pe[t-1]+(pe[t]-pe[t-1])*s,y:xe[t-1]+(xe[t]-xe[t-1])*s}}function ti({curves:e,edgeHalfWidth:n,nodeHalfWidth:t,scale:r,yToX:o,color:s,fromSegments:a,toSegments:i}){let l=Va+Ua*n,c=ni(e,r,o,t+l),f=Me[c-1],u=Math.min(t,f),d=f<ei?oi(a,r,o):f-u,h=Math.min(1,d/l);if(h<Za)return;let p=zo(c,u),m=zo(c,u+l*h),b=p.x-m.x,g=(p.y-m.y)*o,y=e[e.length-1];return{x:p.x,y:p.y,angle:Math.hypot(b,g)>0?Math.atan2(g,b):gi(y,o,ri(y,i)),length:l*h,halfWidth:(Ka+Qa*n)*h,color:s}}function oi(e,n,t){let r=0;for(let o=1;o<e.length;o++)r+=Math.hypot(e[o].x-e[o-1].x,(e[o].y-e[o-1].y)*t);return r*n}function ri(e,n){if(n.length<2)return;let t=n[0],r=n[n.length-1];return Math.hypot(e.x1-t.x,e.y1-t.y)<=Math.hypot(e.x1-r.x,e.y1-r.y)?{from:t,to:n[1]}:{from:r,to:n[n.length-2]}}function si(e,n=1){let t=n===1?e:e.map(o=>({x:o.x,y:o.y*n})),r=[];for(let o=0;o<t.length;o++){let s=0,a=0;if(o===0){let i=t[1].x-t[0].x,l=t[1].y-t[0].y,c=Math.hypot(i,l);c>0&&(s=-l/c,a=i/c)}else if(o===t.length-1){let i=t[o].x-t[o-1].x,l=t[o].y-t[o-1].y,c=Math.hypot(i,l);c>0&&(s=-l/c,a=i/c)}else{let i=t[o].x-t[o-1].x,l=t[o].y-t[o-1].y,c=Math.hypot(i,l),f=t[o+1].x-t[o].x,u=t[o+1].y-t[o].y,d=Math.hypot(f,u);if(c>0&&d>0){let h=-l/c,p=i/c,m=-u/d,b=f/d;s=(h+m)/2,a=(p+b)/2;let g=h*s+p*a;g>.1&&(s/=g,a/=g)}else c>0?(s=-l/c,a=i/c):d>0&&(s=-u/d,a=f/d)}r.push({nx:s,ny:a})}return r}function ai(e,n,t,r=1){return e.map((o,s)=>({x:o.x+n[s].nx*t,y:o.y+n[s].ny*t/r}))}function fn(e,n,t,r){return(0,Y.packAbgr)(Math.round(e*255),Math.round(n*255),Math.round(t*255),Math.round(r*255))}function pn(e,n,t){let r=(1-Math.abs(2*t-1))*n,o=r*(1-Math.abs(e/60%2-1)),s=t-r/2,a=0,i=0,l=0;return e<60?(a=r,i=o):e<120?(a=o,i=r):e<180?(i=r,l=o):e<240?(i=o,l=r):e<300?(a=o,l=r):(a=r,l=o),[a+s,i+s,l+s]}var ii=[[68,1,84],[59,82,139],[33,145,140],[94,201,98],[253,231,37]],li=[[237,137,44],[158,42,122]],ci=[[220,50,50],[50,120,220]];function Kn(e,n){let t=Math.max(0,Math.min(1,n))*(e.length-1),r=Math.min(e.length-2,Math.floor(t)),o=t-r,s=e[r],a=e[r+1];return(0,Y.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 ui(e,n){let[t,r,o]=pn(it(e),bn,gn);return fn(t,r,o,n)}var di=300,fi=.7,pi=.5,Uo=[60,65,72],hi=(0,Y.packAbgr)(...Uo,255),su=`rgb(${Uo.join(", ")})`;function au(e,n){let t=Ut(e);if(n&&n.end>n.start)return{start:n.start,span:n.end-n.start,midpoints:t};let r=1/0,o=-1/0;for(let s of t.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:t}}function mi(e){let n=1/0,t=-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<n&&(n=a.depth),a.depth>t&&(t=a.depth),a.length<r&&(r=a.length),a.length>o&&(o=a.length);return{minDepth:n,maxDepth:t,minLength:r,maxLength:o,maxRank:s,nodeCount:e.nodes.length}}function bi(e,n,t,r){switch(t){case"random":return ui(e.id,1);case"depth":return Kn(ii,r.maxDepth>r.minDepth?(e.depth-r.minDepth)/(r.maxDepth-r.minDepth):.5);case"node-length":return Kn(ci,r.maxLength>r.minLength?(e.length-r.minLength)/(r.maxLength-r.minLength):.5);case"stable-rank":return e.stable===void 0?(0,Y.packAbgr)(160,160,160,255):e.stable.rank===0?(0,Y.packAbgr)(52,152,219,255):Kn(li,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,Y.packAbgr)(160,160,160,255);if(e.stable!==void 0&&e.stable.rank>0)return hi;let a=Math.max(0,Math.min(1,(s-o.start)/o.span)),[i,l,c]=pn(a*di,fi,pi);return fn(i,l,c,1)}case"grey":return(0,Y.packAbgr)(160,160,160,255);case"rainbow":{let o=r.nodeCount>1?n/r.nodeCount*360:0,[s,a,i]=pn(o,.75,.5);return fn(s,a,i,1)}default:return(0,Y.packAbgr)(52,152,219,255)}}function gi(e,n=1,t){let r=[[e.cx1,e.cy1],[e.cx0,e.cy0],[e.x0,e.y0]];for(let[o,s]of r){let a=e.x1-o,i=(e.y1-s)*n;if(Math.hypot(a,i)>0)return Math.atan2(i,a)}return t?Math.atan2((t.to.y-t.from.y)*n,t.to.x-t.from.x):0}function yi(e,n){let t=!1;for(let r=0;r<e.length-1&&!t;r++){let o=e[r],s=e[r+1];t=Math.max(o.x,s.x)>=n.minX&&Math.min(o.x,s.x)<=n.maxX&&Math.max(o.y,s.y)>=n.minY&&Math.min(o.y,s.y)<=n.maxY}return t}function xi(e,n){for(let t of e){let r=Math.min(t.x0,t.cx0,t.cx1,t.x1),o=Math.max(t.x0,t.cx0,t.cx1,t.x1),s=Math.min(t.y0,t.cy0,t.cy1,t.y1),a=Math.max(t.y0,t.cy0,t.cy1,t.y1);if(o>=n.minX&&r<=n.maxX&&a>=n.minY&&s<=n.maxY)return!0}return!1}var jo=new WeakMap;function Mi(e){let n=jo.get(e);if(!n){let t=[],r=new Map,o=e.paths??[];for(let s=0;s<o.length;s++){let[a,i,l]=pn(lt(s,o.length),bn,gn);t.push(fn(a,i,l,.85)),r.has(o[s].name)||r.set(o[s].name,s)}n={pathColorByIndex:t,pathIndexByName:r},jo.set(e,n)}return n}var Vo=new WeakMap,wi=new Map;function Li(e){let n=Vo.get(e);if(!n){n=new Map;for(let[t,r]of(e.paths??[]).entries())for(let o of new Set(r.nodeIds)){let s=n.get(o);s?s.push(t):n.set(o,[t])}Vo.set(e,n)}return n}function iu(e){let{nodePositions:n,graph:t,nodeById:r,colorScheme:o,contigThickness:s,connectorThickness:a,drawPaths:i,nodeWidth:l="uniform",highlight:c,axis:f,linearLayout:u,viewportBounds:d,referenceRamp:h,deletions:p,hiddenEdges:m,version:b=0}=e,g=l==="depth"?ut(t):0,y=f.scaleX,w=Ze(f),N=Yo(n,t,f,p,b),S=[],R=new Map,x=[],E=new Map,C=[],P=new Map,z={...mi(t),referenceRamp:h},W=new Map;if(o==="rainbow")for(let v=0;v<t.nodes.length;v++)W.set(t.nodes[v].id,v);let q=t.paths?.length??0,{pathColorByIndex:F,pathIndexByName:U}=Mi(t),j=v=>F[U.get(v)??-1]??ko,V=i&&q>1?Li(t):wi,We=y>(u?1:Ja);for(let v=0;v<t.edges.length;v++){let D=t.edges[v],K=n[D.from],Z=n[D.to],J=N.get(v);if(!K?.length||!Z?.length||!J||m?.has(v))continue;let se=D.pathIds?.length??0,ae=p?.get(v)!==void 0,ie=c?.edgeIndexes.has(v)??!1,ee=a/2*(ae?Wa:1)*(ie?Ya:1),he=i&&se>0,Ce=ae?Ha:Fa,we=c?ie?Xa:He(Ce,dn):Ce,Xe=r.get(D.to),mn=(Xe?yn(Xe,s,l,g):s)/2,Ie=(ke,ze,ne,ve)=>{let me=ke===0&&ze===0?J:Lt(J,ke,ze);if(d&&!xi(me,d))return;if(ae)for(let pr of wt(me,ka/y))C.push({curves:pr,thickness:ee,color:ne});else C.push({curves:me,thickness:ee,color:ne});let nt=We&&ve!==void 0?ti({curves:me,edgeHalfWidth:ee,nodeHalfWidth:mn,scale:y,yToX:w,color:ve,fromSegments:K,toSegments:Z}):void 0;nt&&x.push(nt)},Ye=C.length,_e=x.length;if(!he)Ie(0,0,we,we);else{let ke=Nt(K,Z,se,f),ze=Math.floor((se-1)/2);for(let ne=0;ne<se;ne++){let ve=ke[ne],me=j(D.pathIds[ne]);Ie(ve.x,ve.y,c&&D.pathIds[ne]!==c.name?He(me,dn):me,ne===ze?we:void 0)}}let Jn=C.length-Ye;Jn>0&&P.set(v,{start:Ye,count:Jn});let et=x.length-_e;et>0&&E.set(v,{start:_e,count:et})}for(let[v,D]of Object.entries(n)){let K=r.get(v);if(!K||d&&!yi(D,d))continue;let Z=bi(K,W.get(v)??0,o,z),J=c!==void 0&&!c.nodeIds.has(v),se=J?He(Z,dn):Z,Te=yn(K,s,l,g),ae=Te/2,ie=S.length,ee=V.get(v),he=Te/q,Ce=D.length>=2;if(Ce&&ee?.length&&he>=za){let Xe=si(D,w),mn=1/Math.max(y,ja);for(let Ie of ee){let Ye=(Ie-(q-1)/2)*he*mn,_e=F[Ie]??ko;S.push({points:ai(D,Xe,Ye,w),thickness:he/2,color:J?He(_e,dn):_e})}}else Ce&&S.push({points:D,thickness:ae,color:se});let we=S.length-ie;we>0&&R.set(v,{start:ie,count:we})}return{nodeStrokes:S,nodeStrokeRuns:R,arrows:x,arrowRuns:E,edgeCurves:C,edgeCurveRuns:P}}function du(e,n){let t=new Map(e.nodes.map(o=>[o.id,o])),r=new Map;n.nodes.forEach(o=>{let s=t.get(o.name);if(o.order>=0&&s&&B(s)){let{refName:a,start:i}=s.stable;(r.get(a)??r.set(a,[]).get(a)).push({bp0:i,bp1:i+o.sequenceLength,x0:o.x,x1:o.x+o.pixelWidth})}});for(let o of r.values())o.sort((s,a)=>s.bp0-a.bp0);return r}function Qn(e,n,t=!1){let r=0,o=e.length-1;for(;r<o;){let i=r+o>>1,l=e[i].bp1;(t?l<n:l<=n)?r=i+1:o=i}let s=e[r];if(n<=s.bp0)return s.x0;let a=s.bp1-s.bp0;return a>0?s.x0+(Math.min(n,s.bp1)-s.bp0)/a*(s.x1-s.x0):s.x0}function Zn(e,n,t){let r=Qn(e,n),o=Qn(e,t,!0);return{x0:Math.min(r,o),x1:Math.max(r,o)}}function fu(e){let n;for(let t of e.values())(!n||t.length>n.length)&&(n=t);return n}var Ko=5,Ni=10,Qo=110,Si=4,Ri=2.5;function Ei(e){return e?"#b0b0b8":"#55555c"}function Ai(e){let n=10**Math.floor(Math.log10(e)),t=e/n;return(t<=1?1:t<=2?2:t<=5?5:10)*n}function Ti(e,n,t,r){let o=e[0],s=e.at(-1);if(!o||!s)return;let a=n(o.x0),i=n(s.x1),l=s.bp1-o.bp0;if(i<=a||l<=0)return;let c=Ai(l/(i-a)*Qo),f=e.filter(y=>{let w=y.bp1-y.bp0;return w>=c&&(n(y.x1)-n(y.x0))*c/w<Qo/2}),u=[],d=[];for(let y of f){let w=n(y.x0),N=n(y.x1);if(N>=0&&w<=t){u.push({x0:w,x1:N});let S=on(y.bp1-y.bp0);d.push({text:S,at:(w+N)/2,width:r(S)})}}let h=[],p=[],m=0;for(let y=Math.ceil(o.bp0/c)*c;y<=s.bp1;y+=c){for(;m<f.length&&f[m].bp1<=y;)m++;if(m<f.length&&f[m].bp0<y)continue;let w=Math.round(n(Qn(e,y)))+.5;if(w>=0&&w<=t){h.push(w);let N=y.toLocaleString("en-US");p.push({text:N,at:w,width:r(N)})}}let b=[],g=y=>b.every(w=>Math.abs(y.at-w.at)>=(y.width+w.width)/2+Ni);for(let y of[...p,...d])g(y)&&b.push(y);return{from:a,to:i,ticks:h,squeezed:u,labels:b.map(({text:y,at:w})=>({text:y,at:w}))}}function Ci(e,n,t,r){let o=Math.max(1,Math.round((t-n)/Si)),s=(t-n)/o;for(let a=0;a<o;a++)e.lineTo(n+(a+.5)*s,r+(a%2?1:-1)*Ri);e.lineTo(t,r)}function pu(e,n,t,r){let{x:o,width:s,darkMode:a}=t;e.font="10px sans-serif";let i=Ti(n,o,s,f=>e.measureText(f).width);if(!i)return;let l=Ei(a),c=r+.5;e.strokeStyle=l,e.fillStyle=l,e.lineWidth=1,e.textAlign="center",e.textBaseline="top",e.beginPath(),e.moveTo(Math.max(0,i.from),c);for(let{x0:f,x1:u}of i.squeezed)e.lineTo(f,c),Ci(e,f,u,c);e.lineTo(Math.min(s,i.to),c);for(let f of i.ticks)e.moveTo(f,r),e.lineTo(f,r+Ko);e.stroke();for(let{text:f,at:u}of i.labels)e.fillText(f,u,r+Ko+2)}function bu(e,n){let t=new Map(e.nodes.map(o=>[o.id,o])),r=[];return n.nodes.forEach(o=>{let s=t.get(o.name);o.order>=0&&s&&B(s)&&r.push({node:o.name,bp0:s.stable.start,bp1:s.stable.start+o.sequenceLength,x0:o.x,x1:o.x+o.pixelWidth})}),r}function gu(e,n,t,r){let o=[];for(let s of e){let a=t(s.x0),i=t(s.x1);i>=0&&a<=r&&o.push({node:s.node,top0:n(s.bp0),top1:n(s.bp1),bottom0:a,bottom1:i})}return o}var Ii=3;function yu(e,n,t,r){if(n<=0||r<0||r>n)return;let o=r/n,s,a=Ii;for(let i of e){let l=i.top0+(i.bottom0-i.top0)*o,c=i.top1+(i.bottom1-i.top1)*o,f=Math.max(0,Math.min(l,c)-t,t-Math.max(l,c));f<a&&(a=f,s=i.node)}return s}function Zo(e,n,t){e.moveTo(n.top0,0),e.lineTo(n.top1,0),e.lineTo(n.bottom1,t),e.lineTo(n.bottom0,t),e.closePath()}function Jo(e,n,t){e.moveTo(n.top0,0),e.lineTo(n.bottom0,t),e.moveTo(n.top1,0),e.lineTo(n.bottom1,t)}function xu(e,n,t,{highlightNode:r,darkMode:o}){if(t<=0||n.length===0)return;let s=o?"255,255,255":"0,0,0";e.beginPath();for(let i of n)Zo(e,i,t);e.fillStyle=`rgba(${s},0.07)`,e.fill(),e.beginPath();for(let i of n)Jo(e,i,t);e.strokeStyle=`rgba(${s},0.35)`,e.lineWidth=.5,e.stroke();let a=n.find(i=>i.node===r);a&&(e.beginPath(),Zo(e,a,t),e.fillStyle="rgba(255,192,203,0.5)",e.fill(),e.beginPath(),Jo(e,a,t),e.strokeStyle="#ff0000",e.lineWidth=1,e.stroke())}function _i(e,n){let t=new Map(e.nodes.map(o=>[o.id,o])),r=[];return n.nodes.forEach((o,s)=>{let a=t.get(o.name);if(o.order>=0&&a&&B(a)){let i=a.stable.start;r.push({bp0:i,bp1:i+o.sequenceLength,index:s,node:o})}}),r.sort((o,s)=>o.bp0-s.bp0)}function vi(e,n,t){let r=0,o=e.length-1;for(;r<o;){let s=r+o+1>>1;e[s].bp0<=n?r=s:o=s-1}return[e[r],e[r-1]].find(s=>s&&t.has(s.index)&&s.bp0<=n&&n<=s.bp1)}function Lu(e,n,t){let r=_i(e,n),o=[];for(let s of n.tracks){let a=s.name?t.get(s.name):void 0;if(a?.length){let i=new Map;for(let l of s.path)l.node!==null&&l.y!==void 0&&!i.has(l.node)&&i.set(l.node,l.y);for(let l of a){let c=vi(r,l.start,i);if(c){let{node:f,bp0:u,bp1:d}=c,h=p=>f.x+(Math.min(p,d)-u)/(d-u)*f.pixelWidth;o.push({x0:h(l.start),x1:h(l.end),y:i.get(c.index),height:s.width})}}}}return o}function Bi(e){return e?"rgba(255,255,255,0.9)":"rgba(0,0,0,0.8)"}function Nu(e,n,{x:t,y:r,width:o,darkMode:s}){if(n.length!==0){e.fillStyle=Bi(s),e.beginPath();for(let a of n){let i=t(a.x0),l=Math.max(t(a.x1),i+1);if(l>=0&&i<=o){let c=r(a.y);e.rect(i,c,l-i,r(a.y+a.height)-c)}}e.fill()}}function Oi(e,n){let t=[],r=e.sequenceNew??[];return r.forEach((o,s)=>{let a=n.nodeMap.get(O(o.nodeName)),i=a===void 0?void 0:n.nodes[a],l=s;for(;l<e.path.length&&e.path[l].node!==a;)l+=1;let c=e.path[l]?.y;if(i&&c!==void 0){let f={readId:e.id,y:c,height:e.width,nodeY:i.y},u=d=>Ro(i,d);for(let d of o.mismatches){let h=u(d.pos);if(h!==null){if(d.type==="insertion"){let p=s===0&&d.pos===e.firstNodeOffset||s===r.length-1&&d.pos===e.finalNodeCoverLength;t.push({...f,kind:"insertion",x:h,seq:d.seq,softClip:p})}else if(d.type==="deletion"&&d.length!==void 0){let p=u(d.pos+d.length);p!==null&&t.push({...f,kind:"deletion",x0:h,x1:p})}else if(d.type==="substitution"&&d.seq!==void 0){let p=u(d.pos+d.seq.length);p!==null&&t.push({...f,kind:"substitution",x0:h,x1:p,seq:d.seq})}}}}}),t}function er(e){return e.reads.flatMap(n=>Oi(n,e))}function sr(e){let n=e.trim().split(/[\s,]+/),t=[],r=0,o=()=>Number(n[r++]);for(;r<n.length;){let s=n[r++];s==="M"||s==="L"?t.push({op:s,x:o(),y:o()}):s==="H"?t.push({op:s,x:o()}):s==="V"?t.push({op:s,y:o()}):s==="Q"?t.push({op:s,x1:o(),y1:o(),x:o(),y:o()}):s==="C"?t.push({op:s,x1:o(),y1:o(),x2:o(),y2:o(),x:o(),y:o()}):s==="Z"&&t.push({op:s})}return t}function ar(e){let n=1/0,t=-1/0;for(let r of e)"x"in r&&(n=Math.min(n,r.x),t=Math.max(t,r.x)),"x1"in r&&(n=Math.min(n,r.x1),t=Math.max(t,r.x1));return{x0:n,x1:t}}function nr(e,n,t){let r=sr(e);return{commands:r,color:n,alpha:t,...ar(r)}}function tr(e,n){let{shapes:t}=e,r=[...t.rectangles,...t.verticalRectangles].filter(a=>a.type===n).map(a=>({color:a.color,alpha:a.alpha??1,x0:a.xStart,x1:a.xEnd+1,y0:a.yStart,y1:a.yEnd+1})),o=Eo(t.curves,n).map(a=>nr(a.path,a.color,a.alpha??1)),s=t.corners.filter(a=>a.type===n).map(a=>nr(a.path,a.color,1));return{rects:r,shapes:[...o,...s]}}function Cu(e){let n=[];return e.nodes.forEach(t=>{if(t.order>=0){let r=sr(Ao(t));n.push({name:t.name,commands:r,...ar(r)})}}),{bounds:e.bounds,layers:[tr(e,"haplotype"),tr(e,"read")],nodes:n,mismatches:er(e).filter(t=>t.kind!=="insertion"||!t.softClip)}}function or(e,n,t,r){let o=0,s=0;for(let a of n)switch(a.op){case"M":o=a.x,s=a.y,e.moveTo(t(o),r(s));break;case"L":o=a.x,s=a.y,e.lineTo(t(o),r(s));break;case"H":o=a.x,e.lineTo(t(o),r(s));break;case"V":s=a.y,e.lineTo(t(o),r(s));break;case"Q":o=a.x,s=a.y,e.quadraticCurveTo(t(a.x1),r(a.y1),t(o),r(s));break;case"C":o=a.x,s=a.y,e.bezierCurveTo(t(a.x1),r(a.y1),t(a.x2),r(a.y2),t(o),r(s));break;case"Z":e.closePath();break}}function rr(e,n,t,r){let o=new Map;for(let s of n)if(t(s)){let a=`${s.color}|${s.alpha}`,i=o.get(a);i?i.push(s):o.set(a,[s])}for(let s of o.values()){e.fillStyle=s[0].color,e.globalAlpha=s[0].alpha,e.beginPath();for(let a of s)r(a);e.fill()}e.globalAlpha=1}var Pi=12,Gi=.15;function Di(e){return Math.max(Gi,Math.min(1,e/Pi))}function Iu(e,n,t){let{x:r,y:o,width:s}=t,a=c=>r(c.x1)>=0&&r(c.x0)<=s;for(let c of n.layers)rr(e,c.rects,a,f=>{let u=r(f.x0),d=o(f.y0);e.rect(u,d,r(f.x1)-u,o(f.y1)-d)}),rr(e,c.shapes,a,f=>{or(e,f.commands,r,o)});let i=t.darkMode?"#d0d0d0":"#000000",l=t.darkMode?"rgba(40,40,40,0.4)":"rgba(255,255,255,0.4)";e.lineWidth=2*Math.max(.25,Math.min(1,t.yScale));for(let c of n.nodes)if(a(c)){let f=c.name===t.highlightNode;e.beginPath(),or(e,c.commands,r,o),e.fillStyle=f?"rgba(255,192,203,0.5)":l,e.strokeStyle=f?"#ff0000":i,e.fill(),e.globalAlpha=f?1:Di(r(c.x1)-r(c.x0)),e.stroke(),e.globalAlpha=1}Fi(e,n.mismatches,t)}var $i=12,qi=6;function Fi(e,n,{x:t,y:r,yScale:o,width:s,darkMode:a}){let i=$i*o;if(i<qi||n.length===0)return;let l=(c,f)=>t(f)>=0&&t(c)<=s;e.fillStyle="grey",e.beginPath();for(let c of n)if(c.kind==="deletion"&&l(c.x0,c.x1)){let f=t(c.x0),u=r(c.y);e.rect(f,u,t(c.x1)-f,r(c.y+c.height)-u)}e.fill(),e.font=`${i}px monospace`,e.textBaseline="alphabetic",e.fillStyle=a?"#ffffff":"#000000";for(let c of n)c.kind==="substitution"&&l(c.x0,c.x1)?e.fillText(c.seq,t(c.x0)+1,r(c.y+c.height)):c.kind==="insertion"&&l(c.x,c.x)&&e.fillText("*",t(c.x)-3,r(c.y+c.height))}function Bu(e,n){let t=[];for(let r of n){let o=e.get(r.refName),s=o?.[0],a=o?.at(-1);if(!o||!s||!a)continue;let i=Math.max(r.start,s.bp0),l=Math.min(r.end,a.bp1);l<=i||t.push({gene:r,...Zn(o,i,l),exons:r.exons.filter(c=>c.end>i&&c.start<l).map(c=>Zn(o,Math.max(c.start,i),Math.min(c.end,l)))})}return t}var ir=22,Hi=4,hn=8,Wi="11px sans-serif",Xi=8;function Ou(e){let n=e.flatMap(o=>[{x:o.x0,step:1},{x:o.x1,step:-1}]).sort((o,s)=>o.x-s.x||o.step-s.step),t=0,r=0;for(let{step:o}of n)t+=o,r=Math.max(r,t);return Math.min(Hi,r)}function Pu(e,n,t,r,o=0){let{x:s,width:a,darkMode:i}=t,l=Math.max(1,Math.floor((r-o)/ir)),c=[],f=i?"#e0e0e6":"#1c1c22";e.font=Wi,e.textAlign="center",e.textBaseline="alphabetic",e.fillStyle=f,e.strokeStyle=f,e.lineWidth=1;let u=n.map(d=>({g:d,s0:s(d.x0),s1:s(d.x1)})).filter(({s0:d,s1:h})=>h>=0&&d<=a).sort((d,h)=>d.s0-h.s0);for(let{g:d,s0:h,s1:p}of u){let m=d.gene.strand>0?" \u2192":d.gene.strand<0?"\u2190 ":"",b=d.gene.strand<0?`${m}${d.gene.name}`:`${d.gene.name}${m}`,g=(Math.max(h,0)+Math.min(p,a))/2,y=e.measureText(b).width/2,w=Math.min(h,g-y),N=Math.max(p,g+y),S=c.findIndex(x=>x+Xi<=w);S===-1&&(S=Math.min(c.length,l-1)),c[S]=Math.max(c[S]??-1/0,N);let R=r-S*ir-hn/2;e.beginPath(),e.moveTo(h,R+.5),e.lineTo(p,R+.5),e.stroke();for(let x of d.exons){let E=s(x.x0);e.fillRect(E,R-hn/2,Math.max(1,s(x.x1)-E),hn)}e.fillText(b,g,R-hn/2-2)}}function ki(e,n){return Math.abs(n-e)<=.1*Math.max(e,n)}function zi(e,n){let t=e.length,r=n.length,o=Array.from({length:t+1},()=>new Array(r+1).fill(0)),s=Array.from({length:t+1},()=>new Array(r+1).fill(!1));for(let i=t-1;i>=0;i--)for(let l=r-1;l>=0;l--){let c=Math.abs(e[i]-n[l])+o[i+1][l+1],f=t-i>r-l?o[i+1][l]:1/0,u=r-l>t-i?o[i][l+1]:1/0;o[i][l]=Math.min(c,f,u),s[i][l]=o[i][l]===c}let a=new Array(t).fill(void 0);for(let i=0,l=0;i<t&&l<r;)s[i][l]?a[i++]=l++:t-i>r-l?i++:l++;return a}function cr(e,n){return e.map((t,r)=>({item:t,i:r})).sort((t,r)=>n(t.item)-n(r.item))}var dr=e=>e.spanningReads!==0;function ur(e,n){return{...n,agrees:e.complete&&dr(n)?ki(e.bp,n.bp):void 0}}function ji(e,n){let t=new Map,r=new Set;e.forEach((i,l)=>{let c=n.find(f=>f.haplotype!==void 0&&f.haplotype===i.haplotype);c&&(r.add(c),t.set(l,ur(i,c)))});let o=n.filter(i=>i.haplotype===void 0),s=cr(e,i=>i.bp),a=[[s.filter(i=>i.item.complete),o.filter(dr)],[s,o]];for(let[i,l]of a){let c=i.filter(u=>!t.has(u.i)),f=cr(l.filter(u=>!r.has(u)),u=>u.bp);zi(c.map(u=>u.item.bp),f.map(u=>u.item.bp)).forEach((u,d)=>{if(u!==void 0){let h=c[d],p=f[u].item;r.add(p),t.set(h.i,ur(h.item,p))}})}return t}function $u(e,n){if(!n)return e;let t=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=n[o];if(a)for(let[i,l]of ji(s,a))t.set(s[i],l)}return e.map(o=>({...o,call:t.get(o)}))}var fr=be(Ve(),1),Hu=(0,te.createSvgIcon)((0,fr.jsx)("path",{d:"M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6"}),"Settings");export{te as a,cs as b,Vn as c,ge as d,Hl as e,Wl as f,Xl as g,Yl as h,Zi as i,Mt as j,Lt as k,Ze as l,Nt as m,Es as n,tl as o,sl as p,al as q,il as r,Bt as s,on as t,Qr as u,Gt as v,gl as w,Do as x,Da as y,De as z,gs as A,Yn as B,Ra as C,jn as D,Yc as E,kc as F,qa as G,Vc as H,Yo as I,di as J,su as K,au as L,iu as M,du as N,fu as O,Si as P,Ri as Q,Ei as R,Ti as S,pu as T,bu as U,gu as V,yu as W,xu as X,Lu as Y,Bi as Z,Nu as _,Cu as $,Iu as aa,Bu as ba,ir as ca,Ou as da,Pu as ea,Yi as fa,$u as ga,wl as ha,Ll as ia,ss as ja,Nl as ka,Sl as la,In as ma,Gl as na,Dl as oa,Hu as pa};
2
+ //# sourceMappingURL=chunk-CJ56O2VG.js.map