jbrowse-plugin-graphgenomeviewer 10.2.0 → 10.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/dist/chunks/{AddTrackWorkflow-BY23IVYG.js → AddTrackWorkflow-4S5QEZTJ.js} +2 -2
  2. package/dist/chunks/{GbzBaseSyntenyAdapter-XAMRWAYZ.js → GbzBaseSyntenyAdapter-64HUHYVC.js} +2 -2
  3. package/dist/chunks/{GbzBaseSyntenyAdapter-XAMRWAYZ.js.map → GbzBaseSyntenyAdapter-64HUHYVC.js.map} +1 -1
  4. package/dist/chunks/{GraphGenomeView-7FALCHVY.js → GraphGenomeView-EGR7L5WT.js} +2 -2
  5. package/dist/chunks/GraphSettingsDialog-6VOMA2TZ.js +2 -0
  6. package/dist/chunks/{HighlightColorDialog-AD7B53ZA.js → HighlightColorDialog-FHRKHBDZ.js} +2 -2
  7. package/dist/chunks/LinearGraphDisplay-R3A64XKK.js +2 -0
  8. package/dist/chunks/{MinigraphBubbleAdapter-W7RUVFVI.js → MinigraphBubbleAdapter-LQ2NYC6O.js} +2 -2
  9. package/dist/chunks/{RgfaTabixAdapter-QOEMTN56.js → RgfaTabixAdapter-UM7L6HPH.js} +2 -2
  10. package/dist/chunks/WalkFormsAdapter-4D6MTHLE.js +2 -0
  11. package/dist/chunks/WalkFormsAdapter-4D6MTHLE.js.map +7 -0
  12. package/dist/chunks/{WalkTabixSyntenyAdapter-HEXLZ5YL.js → WalkTabixSyntenyAdapter-V5IQCHP4.js} +2 -2
  13. package/dist/chunks/{chunk-V5ZGDS4W.js → chunk-2OH3T4CR.js} +2 -2
  14. package/dist/chunks/{chunk-V5ZGDS4W.js.map → chunk-2OH3T4CR.js.map} +1 -1
  15. package/dist/chunks/{chunk-BDBERNEC.js → chunk-2XAPUOET.js} +2 -2
  16. package/dist/chunks/{chunk-BDBERNEC.js.map → chunk-2XAPUOET.js.map} +1 -1
  17. package/dist/chunks/chunk-3S24TQNP.js +5 -0
  18. package/dist/chunks/chunk-3S24TQNP.js.map +7 -0
  19. package/dist/chunks/{chunk-HT3RFCRI.js → chunk-4GC42TBO.js} +2 -2
  20. package/dist/chunks/{chunk-HT3RFCRI.js.map → chunk-4GC42TBO.js.map} +1 -1
  21. package/dist/chunks/{chunk-KFSVGH3X.js → chunk-4IPVOCXX.js} +2 -2
  22. package/dist/chunks/{chunk-KFSVGH3X.js.map → chunk-4IPVOCXX.js.map} +1 -1
  23. package/dist/chunks/{chunk-AW7U7KMG.js → chunk-4WMWSJXJ.js} +2 -2
  24. package/dist/chunks/{chunk-AW7U7KMG.js.map → chunk-4WMWSJXJ.js.map} +1 -1
  25. package/dist/chunks/{chunk-IQURFLWC.js → chunk-55PR5XJY.js} +2 -2
  26. package/dist/chunks/{chunk-7V5D6ZDX.js → chunk-5CTDN4UC.js} +1 -1
  27. package/dist/chunks/{chunk-7V5D6ZDX.js.map → chunk-5CTDN4UC.js.map} +1 -1
  28. package/dist/chunks/{chunk-FSVORNAP.js → chunk-5KWWMR7X.js} +2 -2
  29. package/dist/chunks/{chunk-4FDZC66W.js → chunk-5PMRULDS.js} +1 -1
  30. package/dist/chunks/{chunk-4FDZC66W.js.map → chunk-5PMRULDS.js.map} +1 -1
  31. package/dist/chunks/{chunk-IAN7FKQ5.js → chunk-EYNSJ5AX.js} +2 -2
  32. package/dist/chunks/{chunk-CWT6WZ3D.js → chunk-GPNGXGMH.js} +2 -2
  33. package/dist/chunks/{chunk-CWT6WZ3D.js.map → chunk-GPNGXGMH.js.map} +2 -2
  34. package/dist/chunks/{chunk-BCRRODIU.js → chunk-HE7BFKXW.js} +2 -2
  35. package/dist/chunks/{chunk-TD6XNJRC.js → chunk-HYQOBARI.js} +2 -2
  36. package/dist/chunks/{chunk-TD6XNJRC.js.map → chunk-HYQOBARI.js.map} +1 -1
  37. package/dist/chunks/{chunk-L2YRM5BR.js → chunk-L5HPUPUZ.js} +2 -2
  38. package/dist/chunks/{chunk-L2YRM5BR.js.map → chunk-L5HPUPUZ.js.map} +1 -1
  39. package/dist/chunks/{chunk-Z6IFVSZS.js → chunk-LDY26KXZ.js} +3 -3
  40. package/dist/chunks/{chunk-Z6IFVSZS.js.map → chunk-LDY26KXZ.js.map} +2 -2
  41. package/dist/chunks/{chunk-B65Y26K2.js → chunk-LOR4V6JJ.js} +2 -2
  42. package/dist/chunks/{chunk-B65Y26K2.js.map → chunk-LOR4V6JJ.js.map} +1 -1
  43. package/dist/chunks/{chunk-4JYYNBSO.js → chunk-QVQIHX2Y.js} +2 -2
  44. package/dist/chunks/{chunk-4JYYNBSO.js.map → chunk-QVQIHX2Y.js.map} +1 -1
  45. package/dist/chunks/chunk-RRQGLRKY.js +8 -0
  46. package/dist/chunks/chunk-RRQGLRKY.js.map +7 -0
  47. package/dist/chunks/{chunk-H6TKCTCB.js → chunk-SBHNFZRS.js} +2 -2
  48. package/dist/chunks/chunk-VOD5M5MV.js +2 -0
  49. package/dist/chunks/{chunk-NGTPDYX7.js → chunk-XXMAC5EP.js} +1 -1
  50. package/dist/chunks/{chunk-NGTPDYX7.js.map → chunk-XXMAC5EP.js.map} +1 -1
  51. package/dist/chunks/{chunk-CVHICHF5.js → chunk-ZMUXLTEP.js} +2 -2
  52. package/dist/chunks/{renderSvg-KEQ6NZ4A.js → renderSvg-WQ5CH3G3.js} +2 -2
  53. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js +1 -1
  54. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js.map +1 -1
  55. package/package.json +3 -3
  56. package/src/WalkFormsAdapter/WalkFormsAdapter.test.ts +3 -3
  57. package/src/WalkFormsAdapter/configSchema.ts +1 -1
  58. package/src/WalkFormsAdapter/formRows.test.ts +12 -13
  59. package/src/WalkFormsAdapter/formRows.ts +2 -13
  60. package/src/version.ts +1 -1
  61. package/dist/chunks/GraphSettingsDialog-XXCBW2UA.js +0 -2
  62. package/dist/chunks/LinearGraphDisplay-26MRFDXW.js +0 -2
  63. package/dist/chunks/WalkFormsAdapter-AV746ZGI.js +0 -2
  64. package/dist/chunks/WalkFormsAdapter-AV746ZGI.js.map +0 -7
  65. package/dist/chunks/chunk-3QEIRGMZ.js +0 -2
  66. package/dist/chunks/chunk-5BMTS4FH.js +0 -5
  67. package/dist/chunks/chunk-5BMTS4FH.js.map +0 -7
  68. package/dist/chunks/chunk-SMC6O3CR.js +0 -6
  69. package/dist/chunks/chunk-SMC6O3CR.js.map +0 -7
  70. /package/dist/chunks/{AddTrackWorkflow-BY23IVYG.js.map → AddTrackWorkflow-4S5QEZTJ.js.map} +0 -0
  71. /package/dist/chunks/{GraphGenomeView-7FALCHVY.js.map → GraphGenomeView-EGR7L5WT.js.map} +0 -0
  72. /package/dist/chunks/{GraphSettingsDialog-XXCBW2UA.js.map → GraphSettingsDialog-6VOMA2TZ.js.map} +0 -0
  73. /package/dist/chunks/{HighlightColorDialog-AD7B53ZA.js.map → HighlightColorDialog-FHRKHBDZ.js.map} +0 -0
  74. /package/dist/chunks/{LinearGraphDisplay-26MRFDXW.js.map → LinearGraphDisplay-R3A64XKK.js.map} +0 -0
  75. /package/dist/chunks/{MinigraphBubbleAdapter-W7RUVFVI.js.map → MinigraphBubbleAdapter-LQ2NYC6O.js.map} +0 -0
  76. /package/dist/chunks/{RgfaTabixAdapter-QOEMTN56.js.map → RgfaTabixAdapter-UM7L6HPH.js.map} +0 -0
  77. /package/dist/chunks/{WalkTabixSyntenyAdapter-HEXLZ5YL.js.map → WalkTabixSyntenyAdapter-V5IQCHP4.js.map} +0 -0
  78. /package/dist/chunks/{chunk-IQURFLWC.js.map → chunk-55PR5XJY.js.map} +0 -0
  79. /package/dist/chunks/{chunk-FSVORNAP.js.map → chunk-5KWWMR7X.js.map} +0 -0
  80. /package/dist/chunks/{chunk-IAN7FKQ5.js.map → chunk-EYNSJ5AX.js.map} +0 -0
  81. /package/dist/chunks/{chunk-BCRRODIU.js.map → chunk-HE7BFKXW.js.map} +0 -0
  82. /package/dist/chunks/{chunk-H6TKCTCB.js.map → chunk-SBHNFZRS.js.map} +0 -0
  83. /package/dist/chunks/{chunk-3QEIRGMZ.js.map → chunk-VOD5M5MV.js.map} +0 -0
  84. /package/dist/chunks/{chunk-CVHICHF5.js.map → chunk-ZMUXLTEP.js.map} +0 -0
  85. /package/dist/chunks/{renderSvg-KEQ6NZ4A.js.map → renderSvg-WQ5CH3G3.js.map} +0 -0
@@ -1,4 +1,4 @@
1
- import{f as Y,j as X,m as q,q as S}from"./chunk-V5ZGDS4W.js";import{g as K}from"./chunk-AW7U7KMG.js";import{la as w,o as $,ra as L}from"./chunk-4JYYNBSO.js";import{c as U,d as Q,e as z}from"./chunk-D3QZGLZ3.js";import{f as M,h as I,i as C}from"./chunk-J2PN6CG3.js";import{A as _,E as B,F as W,G as T,I as y,d as H,n as P,o as G,q as D,r as E,t as A,u as F,x as O,z as R}from"./chunk-H42TSPVA.js";import{b as o,c as i,d as p}from"./chunk-DUU6T2I5.js";var x=[{value:0,label:"Fastest"},{value:1,label:"Fast"},{value:2,label:"Default"},{value:3,label:"Fine"},{value:4,label:"Best"}];var v=p(function({label:a,value:e,options:n,testId:r,size:t,sx:d,disabled:f,title:h,shown:b,onChange:g}){let u=M();return i(A,{size:t,sx:d,disabled:f,title:h,children:[o(O,{id:u,shrink:!0,children:a}),o(B,{labelId:u,value:e,label:a,notched:!0,displayEmpty:!0,"data-testid":r,renderValue:s=>b??n.find(oe=>oe.value===s)?.label??s,onChange:s=>{g(s.target.value)},children:n.map(s=>o(_,{value:s.value,disabled:s.disabled,title:s.disabled?void 0:s.description,children:o(R,{primary:s.label,secondary:s.disabled?s.description:void 0})},s.value))})]})});var ae=S()({section:{marginBottom:24}}),ne=[{value:"0",label:"None"},{value:"1",label:"1 hop"},{value:"2",label:"2 hops"}],re=p(function({model:a}){let{classes:e}=ae(),n=a.sourceAdapter;return n?.type==="RgfaTabixAdapter"&&!U(n)?i("div",{className:e.section,children:[o(v,{label:"Graph context",sx:{minWidth:200},value:String(a.subgraphContext),options:ne,testId:"graph-context-select",onChange:r=>{a.setSubgraphContext(Number(r))}}),o(y,{variant:"caption",component:"div",color:"text.secondary",children:"How far the cut follows links out of the region. At none, a detour that leaves the window draws as two stubs. No effect on gfa-to-tabix's default anchored index."})]}):null}),V=re;var le=S()({section:{marginBottom:24}}),j=(l,a)=>l.join(`
1
+ import{f as Y,j as X,m as q,q as S}from"./chunk-2OH3T4CR.js";import{g as K}from"./chunk-4WMWSJXJ.js";import{la as w,o as $,ra as L}from"./chunk-QVQIHX2Y.js";import{c as U,d as Q,e as z}from"./chunk-D3QZGLZ3.js";import{f as M,h as I,i as C}from"./chunk-J2PN6CG3.js";import{A as _,E as B,F as W,G as T,I as y,d as H,n as P,o as G,q as D,r as E,t as A,u as F,x as O,z as R}from"./chunk-H42TSPVA.js";import{b as o,c as i,d as p}from"./chunk-DUU6T2I5.js";var x=[{value:0,label:"Fastest"},{value:1,label:"Fast"},{value:2,label:"Default"},{value:3,label:"Fine"},{value:4,label:"Best"}];var v=p(function({label:a,value:e,options:n,testId:r,size:t,sx:d,disabled:f,title:h,shown:b,onChange:g}){let u=M();return i(A,{size:t,sx:d,disabled:f,title:h,children:[o(O,{id:u,shrink:!0,children:a}),o(B,{labelId:u,value:e,label:a,notched:!0,displayEmpty:!0,"data-testid":r,renderValue:s=>b??n.find(oe=>oe.value===s)?.label??s,onChange:s=>{g(s.target.value)},children:n.map(s=>o(_,{value:s.value,disabled:s.disabled,title:s.disabled?void 0:s.description,children:o(R,{primary:s.label,secondary:s.disabled?s.description:void 0})},s.value))})]})});var ae=S()({section:{marginBottom:24}}),ne=[{value:"0",label:"None"},{value:"1",label:"1 hop"},{value:"2",label:"2 hops"}],re=p(function({model:a}){let{classes:e}=ae(),n=a.sourceAdapter;return n?.type==="RgfaTabixAdapter"&&!U(n)?i("div",{className:e.section,children:[o(v,{label:"Graph context",sx:{minWidth:200},value:String(a.subgraphContext),options:ne,testId:"graph-context-select",onChange:r=>{a.setSubgraphContext(Number(r))}}),o(y,{variant:"caption",component:"div",color:"text.secondary",children:"How far the cut follows links out of the region. At none, a detour that leaves the window draws as two stubs. No effect on gfa-to-tabix's default anchored index."})]}):null}),V=re;var le=S()({section:{marginBottom:24}}),j=(l,a)=>l.join(`
2
2
  `)===a.join(`
3
3
  `);function J(l,a){let e=l.cutHaplotypes??[],[n,r]=C(e);return j(e,n)||(r(e),a()),t=>{j(t,e)||(r(t),l.setSubgraphHaplotypes(t))}}var se=p(function({model:a}){let[e,n]=C(a.cutHaplotypes?.join(", ")??""),r=J(a,()=>{n(a.cutHaplotypes?.join(", ")??"")}),t=()=>{r(Q(e))};return o(T,{fullWidth:!0,label:"Haplotypes",placeholder:"every haplotype",value:e,slotProps:{htmlInput:{"data-testid":"graph-haplotypes-field"}},onChange:d=>{n(d.target.value)},onBlur:()=>{t()},onKeyDown:d=>{d.key==="Enter"&&t()}})}),ie=p(function({model:a,names:e}){let[n,r]=C(a.cutHaplotypes??[]),t=I(n),d=I(""),[f,h]=C(!1),b=J(a,()=>{t.current=a.cutHaplotypes??[],r(t.current)});return o(P,{multiple:!0,freeSolo:!0,disableCloseOnSelect:!0,options:e,value:n,open:f,onOpen:()=>{h(!0)},onInputChange:(g,u)=>{d.current=u},onClose:(g,u)=>{h(!1);let s=d.current.trim();u==="blur"&&s&&!t.current.includes(s)&&(t.current=[...t.current,s],r(t.current)),b(t.current)},onChange:(g,u)=>{t.current=u,r(u),f||b(u)},renderInput:g=>o(T,{...g,label:"Haplotypes",placeholder:n.length===0?"every haplotype":void 0,slotProps:{...g.slotProps,htmlInput:{...g.slotProps.htmlInput,"data-testid":"graph-haplotypes-field"}}})})}),pe=p(function({model:a}){let{classes:e}=le(),n=a.haplotypeNames,r=a.sourceAdapter;return r&&z(r)?i("div",{className:e.section,children:[n?o(ie,{model:a,names:n}):o(se,{model:a}),i(y,{variant:"caption",component:"div",color:"text.secondary",children:[n?`Which of the graph's ${n.length.toLocaleString()} haplotypes to cut, or a PanSN prefix (HG002 for both).`:"Which haplotypes to cut, as lane assembly names or PanSN prefixes (HG002#1, or HG002 for both) separated by commas."," ","Empty is every haplotype."]})]}):null}),Z=pe;var k=S()({section:{marginBottom:24},group:{marginBottom:16},heading:{marginBottom:8}}),c=p(function({warn:a=!1,children:e}){return o(y,{variant:"caption",component:"div",color:a?"warning.main":"text.secondary",children:e})}),N=p(function({title:a,children:e}){let{classes:n}=k();return i("section",{className:n.group,children:[o(y,{variant:"subtitle1",className:n.heading,children:a}),e]})}),ee=p(function({label:a,checked:e,onChange:n,children:r}){let{classes:t}=k();return i("div",{className:t.section,children:[o(F,{control:o(W,{checked:e,onChange:d=>{n(d.target.checked)}}),label:a}),r]})}),m=p(function({children:a,...e}){let{classes:n}=k();return i("div",{className:n.section,children:[o(v,{sx:{minWidth:200},...e}),a]})}),ce=[5e3,2e4,5e4,1e5];function de(l){return[...new Set([...ce,l])].sort((a,e)=>a-e).map(a=>({value:String(a),label:a.toLocaleString()}))}var te=p(function({label:a,choices:e,stored:n,auto:r,testId:t,onChange:d,children:f}){return e.length>0?o(m,{label:a,value:e.some(h=>h.trackId===n)?n:"",options:[{value:"",label:`Automatic (${r?.name??"none"})`},...e.map(({trackId:h,name:b})=>({value:h,label:b}))],testId:t,onChange:d,children:f}):null}),ue=p(function(a){let{model:e,onClose:n}=a,{classes:r}=k();return i(H,{open:!0,onClose:n,title:"Graph settings",children:[i(E,{children:[i(N,{title:"Subgraph",children:[o(V,{model:e}),o(Z,{model:e}),o(m,{label:"Node limit",value:String(e.maxGraphNodes),options:de(e.maxGraphNodes),testId:"graph-node-limit-select",onChange:t=>{e.setMaxGraphNodes(Number(t))},children:o(c,{children:"The most nodes a layout draws; past it the graph is declined. Walk rows take no limit."})})]}),i(N,{title:"Drawing",children:[e.anchorPaths.length>1?o(m,{label:"Reference path",value:e.activeReferencePath??"",options:e.anchorPaths.map(({name:t})=>({value:t,label:t})),testId:"graph-reference-path-select",onChange:t=>{e.setReferencePath(t)},children:o(c,{children:"The path the anchored layouts place x along"})}):null,o(m,{label:"Node width",value:e.nodeWidth,options:$,testId:"graph-node-width-select",onChange:t=>{e.setNodeWidth(t)},children:o(c,{children:"Depth as width. In a cut with walks, depth is how many haplotypes carry the node."})}),o(m,{label:"Link width",value:e.linkWidth,options:L,testId:"graph-link-width-select",onChange:t=>{e.setLinkWidth(t)},children:o(c,{children:"Walks as width, so a common route reads heavy and a private one thin."})}),i(ee,{label:"Draw paths",checked:e.drawPaths,onChange:t=>{e.setLayer("paths",t)},children:[o(c,{children:"Color each node by the paths through it, one lane per path"}),e.drawPaths&&!e.effectiveDrawPaths?o(c,{warn:!0,children:e.pathCount>w?`Off: ${e.pathCount.toLocaleString()} paths is past the ${w} this can tell apart`:"Off: this graph states no paths"}):null]}),o(te,{label:"Gene track",choices:e.geneTrackChoices,stored:e.geneTrackId,auto:q(e.geneTrackChoices,""),testId:"graph-gene-track-select",onChange:t=>{e.setGeneTrackId(t)},children:o(c,{children:"Where genes on the backbone come from"})}),o(te,{label:"Repeat track",choices:e.repeatTrackChoices,stored:e.repeatTrackId,auto:X(e.repeatTrackChoices,""),testId:"graph-repeat-track-select",onChange:t=>{e.setRepeatTrackId(t)},children:o(c,{children:"The tandem repeat annotation walk rows measure and tile by"})})]}),i(N,{title:"Force-directed layout",children:[e.hasGraph&&!e.usesLayoutEngine?o("div",{className:r.section,children:o(c,{warn:!0,children:"No effect on the current layout until Layout is Force-directed"})}):null,o(m,{label:"Engine",value:e.chosenLayoutEngine,options:Y,testId:"graph-layout-engine-select",onChange:t=>{e.setLayoutEngine(t)},children:o(c,{children:"Stress keeps the reference straight, so a zoom keeps the picture; FMMM lets the whole graph settle."})}),o(m,{label:"Layout quality",value:String(e.layoutQuality),options:x.map(t=>({value:String(t.value),label:t.label})),testId:"graph-layout-quality-select",onChange:t=>{e.setLayoutQuality(Number(t))},children:o(c,{children:"The engine's iteration budget; higher is slower"})}),o(m,{label:"Bubble spread",value:e.bubbleSpread,options:K,testId:"graph-bubble-spread-select",onChange:t=>{e.setBubbleSpread(t)},children:o(c,{children:"How far the layout opens a bubble"})}),e.chosenLayoutEngine==="stress"?null:o(ee,{label:"Linear layout",checked:e.linearLayout,onChange:t=>{e.setLinearLayout(t)},children:o(c,{children:"Keeps a chain of nodes on one line where it can"})})]})]}),o(D,{children:o(G,{variant:"contained",color:"primary",onClick:n,children:"Close"})})]})}),et=ue;export{v as a,et as b};
4
- //# sourceMappingURL=chunk-B65Y26K2.js.map
4
+ //# sourceMappingURL=chunk-LOR4V6JJ.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../node_modules/.pnpm/@jbrowse+bandage-core@14.2.0/node_modules/@jbrowse/bandage-core/dist/chunks/chunk-K5SIJGAE.js", "../../src/GraphGenomeView/components/LabelledSelect.tsx", "../../src/GraphGenomeView/components/SubgraphContextSelect.tsx", "../../src/GraphGenomeView/components/SubgraphHaplotypesField.tsx", "../../src/GraphGenomeView/components/GraphSettingsDialog.tsx"],
3
+ "sources": ["../../node_modules/.pnpm/@jbrowse+bandage-core@14.3.0/node_modules/@jbrowse/bandage-core/dist/chunks/chunk-K5SIJGAE.js", "../../src/GraphGenomeView/components/LabelledSelect.tsx", "../../src/GraphGenomeView/components/SubgraphContextSelect.tsx", "../../src/GraphGenomeView/components/SubgraphHaplotypesField.tsx", "../../src/GraphGenomeView/components/GraphSettingsDialog.tsx"],
4
4
  "sourcesContent": ["// src/layoutQualities.ts\nvar LAYOUT_QUALITIES = [\n { value: 0, label: \"Fastest\" },\n { value: 1, label: \"Fast\" },\n { value: 2, label: \"Default\" },\n { value: 3, label: \"Fine\" },\n { value: 4, label: \"Best\" }\n];\n\nexport {\n LAYOUT_QUALITIES\n};\n", "import { useId } from 'react'\n\nimport {\n FormControl,\n InputLabel,\n ListItemText,\n MenuItem,\n Select,\n} from '@mui/material'\nimport { observer } from 'mobx-react'\n\nimport type { SxProps } from '@mui/material'\n\ninterface SelectOption<T extends string> {\n value: T\n label: string\n // an option's tooltip, and the reason under a disabled one, whose tooltip\n // cannot open\n description?: string\n disabled?: boolean\n}\n\n// One dropdown with its label tied to it, so a screen reader names the combobox\nexport default observer(function LabelledSelect<T extends string>({\n label,\n value,\n options,\n testId,\n size,\n sx,\n disabled,\n title,\n shown,\n onChange,\n}: {\n label: string\n value: T\n options: readonly SelectOption<T>[]\n testId?: string\n size?: 'small' | 'medium'\n sx?: SxProps\n disabled?: boolean\n title?: string\n // what the closed select reads, when not the picked option's label\n shown?: string\n onChange: (value: T) => void\n}) {\n const labelId = useId()\n return (\n <FormControl size={size} sx={sx} disabled={disabled} title={title}>\n <InputLabel id={labelId} shrink>\n {label}\n </InputLabel>\n <Select\n labelId={labelId}\n value={value}\n label={label}\n notched\n displayEmpty\n data-testid={testId}\n renderValue={picked =>\n shown ?? options.find(o => o.value === picked)?.label ?? picked\n }\n onChange={e => {\n onChange(e.target.value as T)\n }}\n >\n {options.map(o => (\n <MenuItem\n key={o.value}\n value={o.value}\n disabled={o.disabled}\n title={o.disabled ? undefined : o.description}\n >\n <ListItemText\n primary={o.label}\n secondary={o.disabled ? o.description : undefined}\n />\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n )\n})\n", "import { Typography } from '@mui/material'\nimport { observer } from 'mobx-react'\nimport { makeStyles } from 'tss-react/mui'\n\nimport LabelledSelect from './LabelledSelect'\nimport { walkIndexed } from '../../graphTrackConfig'\n\nimport type { GraphPaneModel } from '../model'\n\nconst useStyles = makeStyles()({\n section: {\n marginBottom: 24,\n },\n})\n\n// Only an rGFA cut from segment rows reads hops: a GBZ cut widens by its\n// adapter's bp `context`, and a walk-indexed cut follows its walks.\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: Pick<\n GraphPaneModel,\n 'sourceAdapter' | 'subgraphContext' | 'setSubgraphContext'\n >\n}) {\n const { classes } = useStyles()\n const adapter = model.sourceAdapter\n return adapter?.type === 'RgfaTabixAdapter' && !walkIndexed(adapter) ? (\n <div className={classes.section}>\n <LabelledSelect\n label=\"Graph context\"\n sx={{ minWidth: 200 }}\n value={String(model.subgraphContext)}\n options={SUBGRAPH_CONTEXTS}\n testId=\"graph-context-select\"\n onChange={hops => {\n model.setSubgraphContext(Number(hops))\n }}\n />\n <Typography variant=\"caption\" component=\"div\" color=\"text.secondary\">\n How far the cut follows links out of the region. At none, a detour that\n leaves the window draws as two stubs. No effect on gfa-to-tabix&apos;s\n default anchored index.\n </Typography>\n </div>\n ) : null\n})\n\nexport default SubgraphContextSelect\n", "import { useRef, useState } from 'react'\n\nimport { Autocomplete, TextField, Typography } from '@mui/material'\nimport { observer } from 'mobx-react'\nimport { makeStyles } from 'tss-react/mui'\n\nimport { cutsByHaplotype, parseHaplotypes } from '../../graphTrackConfig'\n\nimport type { GraphPaneModel } from '../model'\n\ntype CutHaplotypes = Pick<\n GraphPaneModel,\n 'sourceAdapter' | 'cutHaplotypes' | 'haplotypeNames' | 'setSubgraphHaplotypes'\n>\n\nconst useStyles = makeStyles()({\n section: {\n marginBottom: 24,\n },\n})\n\nconst sameList = (a: readonly string[], b: readonly string[]) =>\n a.join('\\n') === b.join('\\n')\n\n// The cut's set, and the last one this field saw: an outside change (a\n// restored session, a launch) resets the draft, while the field's own apply\n// records what it set first, so it keeps its focus and draft\nfunction useCutHaplotypes(model: CutHaplotypes, reset: () => void) {\n const current = model.cutHaplotypes ?? []\n const [seen, setSeen] = useState(current)\n if (!sameList(current, seen)) {\n setSeen(current)\n reset()\n }\n return (haplotypes: string[]) => {\n if (!sameList(haplotypes, current)) {\n setSeen(haplotypes)\n model.setSubgraphHaplotypes(haplotypes)\n }\n }\n}\n\nconst HaplotypeListField = observer(function HaplotypeListField({\n model,\n}: {\n model: CutHaplotypes\n}) {\n const [draft, setDraft] = useState(model.cutHaplotypes?.join(', ') ?? '')\n const setCut = useCutHaplotypes(model, () => {\n setDraft(model.cutHaplotypes?.join(', ') ?? '')\n })\n const apply = () => {\n setCut(parseHaplotypes(draft))\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// The haplotypes a walk-indexed graph's header names, searched as typed. A\n// typed prefix the list lacks (HG002 for both haplotypes) is kept too, on\n// Enter or when the field loses focus. The set applies when the list closes\n// or, with the list closed, as it changes. Not MUI's `autoSelect`: in a\n// multiple select its blur toggles the highlighted option, so a pick made by\n// keyboard was dropped again on Tab.\nconst HaplotypePickField = observer(function HaplotypePickField({\n model,\n names,\n}: {\n model: CutHaplotypes\n names: string[]\n}) {\n const [draft, setDraft] = useState(model.cutHaplotypes ?? [])\n const draftRef = useRef(draft)\n const typed = useRef('')\n const [open, setOpen] = useState(false)\n const apply = useCutHaplotypes(model, () => {\n draftRef.current = model.cutHaplotypes ?? []\n setDraft(draftRef.current)\n })\n return (\n <Autocomplete\n multiple\n freeSolo\n disableCloseOnSelect\n options={names}\n value={draft}\n open={open}\n onOpen={() => {\n setOpen(true)\n }}\n onInputChange={(_, text) => {\n typed.current = text\n }}\n onClose={(_, reason) => {\n setOpen(false)\n const text = typed.current.trim()\n if (reason === 'blur' && text && !draftRef.current.includes(text)) {\n draftRef.current = [...draftRef.current, text]\n setDraft(draftRef.current)\n }\n apply(draftRef.current)\n }}\n onChange={(_, value) => {\n draftRef.current = value\n setDraft(value)\n if (!open) {\n apply(value)\n }\n }}\n renderInput={params => (\n <TextField\n {...params}\n label=\"Haplotypes\"\n placeholder={draft.length === 0 ? 'every haplotype' : undefined}\n slotProps={{\n ...params.slotProps,\n htmlInput: {\n ...params.slotProps.htmlInput,\n 'data-testid': 'graph-haplotypes-field',\n },\n }}\n />\n )}\n />\n )\n})\n\n// Only a GBZ cut and a walk-indexed rGFA cut read the set\nconst SubgraphHaplotypesField = observer(function SubgraphHaplotypesField({\n model,\n}: {\n model: CutHaplotypes\n}) {\n const { classes } = useStyles()\n const names = model.haplotypeNames\n const adapter = model.sourceAdapter\n return adapter && cutsByHaplotype(adapter) ? (\n <div className={classes.section}>\n {names ? (\n <HaplotypePickField model={model} names={names} />\n ) : (\n <HaplotypeListField model={model} />\n )}\n <Typography variant=\"caption\" component=\"div\" color=\"text.secondary\">\n {names\n ? `Which of the graph's ${names.length.toLocaleString()} haplotypes to cut, or a PanSN prefix (HG002 for both).`\n : 'Which haplotypes to cut, as lane assembly names or PanSN prefixes (HG002#1, or HG002 for both) separated by commas.'}{' '}\n Empty is every haplotype.\n </Typography>\n </div>\n ) : null\n})\n\nexport default SubgraphHaplotypesField\n", "import type { ReactNode } from 'react'\n\nimport { BUBBLE_SPREADS } from '@jbrowse/bandage-core/bubbleSpreads'\nimport { EDGE_WIDTHS } from '@jbrowse/bandage-core/edgeWidths'\nimport { LAYOUT_ENGINES } from '@jbrowse/bandage-core/layoutEngines'\nimport { LAYOUT_QUALITIES } from '@jbrowse/bandage-core/layoutQualities'\nimport { NODE_WIDTHS } from '@jbrowse/bandage-core/nodeWidths'\nimport { MAX_PATH_COLORS } from '@jbrowse/bandage-core/pathColors'\nimport { Dialog } from '@jbrowse/core/ui'\nimport {\n Button,\n DialogActions,\n DialogContent,\n FormControlLabel,\n Switch,\n Typography,\n} from '@mui/material'\nimport { observer } from 'mobx-react'\nimport { makeStyles } from 'tss-react/mui'\n\nimport LabelledSelect from './LabelledSelect'\nimport SubgraphContextSelect from './SubgraphContextSelect'\nimport SubgraphHaplotypesField from './SubgraphHaplotypesField'\nimport { pickGeneTrack } from '../genes/geneFeatures'\nimport { pickRepeatTrack } from '../repeats/repeatFeatures'\n\nimport type { GraphPaneModel } from '../model'\n\nconst useStyles = makeStyles()({\n section: {\n marginBottom: 24,\n },\n group: {\n marginBottom: 16,\n },\n heading: {\n marginBottom: 8,\n },\n})\n\nconst Caption = observer(function Caption({\n warn = false,\n children,\n}: {\n warn?: boolean\n children: ReactNode\n}) {\n return (\n <Typography\n variant=\"caption\"\n component=\"div\"\n color={warn ? 'warning.main' : 'text.secondary'}\n >\n {children}\n </Typography>\n )\n})\n\nconst Group = observer(function Group({\n title,\n children,\n}: {\n title: string\n children: ReactNode\n}) {\n const { classes } = useStyles()\n return (\n <section className={classes.group}>\n <Typography variant=\"subtitle1\" className={classes.heading}>\n {title}\n </Typography>\n {children}\n </section>\n )\n})\n\nconst SettingSwitch = observer(function SettingSwitch({\n label,\n checked,\n onChange,\n children,\n}: {\n label: string\n checked: boolean\n onChange: (checked: boolean) => void\n children?: ReactNode\n}) {\n const { classes } = useStyles()\n return (\n <div className={classes.section}>\n <FormControlLabel\n control={\n <Switch\n checked={checked}\n onChange={e => {\n onChange(e.target.checked)\n }}\n />\n }\n label={label}\n />\n {children}\n </div>\n )\n})\n\n// one dropdown setting, at the dialog's width, and its caption\nconst SettingSelect = observer(function SettingSelect<T extends string>({\n children,\n ...props\n}: Omit<Parameters<typeof LabelledSelect<T>>[0], 'size' | 'sx'> & {\n children?: ReactNode\n}) {\n const { classes } = useStyles()\n return (\n <div className={classes.section}>\n <LabelledSelect sx={{ minWidth: 200 }} {...props} />\n {children}\n </div>\n )\n})\n\nconst NODE_LIMITS = [5000, 20_000, 50_000, 100_000]\n\n// the presets, with a limit a session states among them\nfunction nodeLimitOptions(current: number) {\n return [...new Set([...NODE_LIMITS, current])]\n .sort((a, b) => a - b)\n .map(limit => ({ value: String(limit), label: limit.toLocaleString() }))\n}\n\ninterface NamedTrack {\n trackId: string\n name: string\n}\n\n// '' leaves the pick to the heuristic, so a session can go back to it\nconst TrackPickSetting = observer(function TrackPickSetting({\n label,\n choices,\n stored,\n auto,\n testId,\n onChange,\n children,\n}: {\n label: string\n choices: NamedTrack[]\n stored: string\n auto: NamedTrack | undefined\n testId: string\n onChange: (trackId: string) => void\n children: ReactNode\n}) {\n return choices.length > 0 ? (\n <SettingSelect\n label={label}\n value={choices.some(t => t.trackId === stored) ? stored : ''}\n options={[\n { value: '', label: `Automatic (${auto?.name ?? 'none'})` },\n ...choices.map(({ trackId, name }) => ({\n value: trackId,\n label: name,\n })),\n ]}\n testId={testId}\n onChange={onChange}\n >\n {children}\n </SettingSelect>\n ) : null\n})\n\n// Toggles the menus already offer (halos, genes, color) stay out of here.\nconst GraphSettingsDialog = observer(function GraphSettingsDialog(props: {\n model: GraphPaneModel\n onClose: () => void\n}) {\n const { model, onClose } = props\n const { classes } = useStyles()\n\n return (\n <Dialog open onClose={onClose} title=\"Graph settings\">\n <DialogContent>\n <Group title=\"Subgraph\">\n <SubgraphContextSelect model={model} />\n <SubgraphHaplotypesField model={model} />\n <SettingSelect\n label=\"Node limit\"\n value={String(model.maxGraphNodes)}\n options={nodeLimitOptions(model.maxGraphNodes)}\n testId=\"graph-node-limit-select\"\n onChange={limit => {\n model.setMaxGraphNodes(Number(limit))\n }}\n >\n <Caption>\n The most nodes a layout draws; past it the graph is declined. Walk\n rows take no limit.\n </Caption>\n </SettingSelect>\n </Group>\n\n <Group title=\"Drawing\">\n {model.anchorPaths.length > 1 ? (\n <SettingSelect\n label=\"Reference path\"\n value={model.activeReferencePath ?? ''}\n options={model.anchorPaths.map(({ name }) => ({\n value: name,\n label: name,\n }))}\n testId=\"graph-reference-path-select\"\n onChange={name => {\n model.setReferencePath(name)\n }}\n >\n <Caption>The path the anchored layouts place x along</Caption>\n </SettingSelect>\n ) : null}\n\n <SettingSelect\n label=\"Node width\"\n value={model.nodeWidth}\n options={NODE_WIDTHS}\n testId=\"graph-node-width-select\"\n onChange={width => {\n model.setNodeWidth(width)\n }}\n >\n <Caption>\n Depth as width. In a cut with walks, depth is how many haplotypes\n carry the node.\n </Caption>\n </SettingSelect>\n\n <SettingSelect\n label=\"Link width\"\n value={model.linkWidth}\n options={EDGE_WIDTHS}\n testId=\"graph-link-width-select\"\n onChange={links => {\n model.setLinkWidth(links)\n }}\n >\n <Caption>\n Walks as width, so a common route reads heavy and a private one\n thin.\n </Caption>\n </SettingSelect>\n\n <SettingSwitch\n label=\"Draw paths\"\n checked={model.drawPaths}\n onChange={draw => {\n model.setLayer('paths', draw)\n }}\n >\n <Caption>\n Color each node by the paths through it, one lane per path\n </Caption>\n {model.drawPaths && !model.effectiveDrawPaths ? (\n <Caption warn>\n {model.pathCount > MAX_PATH_COLORS\n ? `Off: ${model.pathCount.toLocaleString()} paths is past the ${MAX_PATH_COLORS} this can tell apart`\n : 'Off: this graph states no paths'}\n </Caption>\n ) : null}\n </SettingSwitch>\n\n <TrackPickSetting\n label=\"Gene track\"\n choices={model.geneTrackChoices}\n stored={model.geneTrackId}\n auto={pickGeneTrack(model.geneTrackChoices, '')}\n testId=\"graph-gene-track-select\"\n onChange={trackId => {\n model.setGeneTrackId(trackId)\n }}\n >\n <Caption>Where genes on the backbone come from</Caption>\n </TrackPickSetting>\n\n <TrackPickSetting\n label=\"Repeat track\"\n choices={model.repeatTrackChoices}\n stored={model.repeatTrackId}\n auto={pickRepeatTrack(model.repeatTrackChoices, '')}\n testId=\"graph-repeat-track-select\"\n onChange={trackId => {\n model.setRepeatTrackId(trackId)\n }}\n >\n <Caption>\n The tandem repeat annotation walk rows measure and tile by\n </Caption>\n </TrackPickSetting>\n </Group>\n\n <Group title=\"Force-directed layout\">\n {model.hasGraph && !model.usesLayoutEngine ? (\n <div className={classes.section}>\n <Caption warn>\n No effect on the current layout until Layout is Force-directed\n </Caption>\n </div>\n ) : null}\n\n <SettingSelect\n label=\"Engine\"\n value={model.chosenLayoutEngine}\n options={LAYOUT_ENGINES}\n testId=\"graph-layout-engine-select\"\n onChange={engine => {\n model.setLayoutEngine(engine)\n }}\n >\n <Caption>\n Stress keeps the reference straight, so a zoom keeps the picture;\n FMMM lets the whole graph settle.\n </Caption>\n </SettingSelect>\n\n <SettingSelect\n label=\"Layout quality\"\n value={String(model.layoutQuality)}\n options={LAYOUT_QUALITIES.map(q => ({\n value: String(q.value),\n label: q.label,\n }))}\n testId=\"graph-layout-quality-select\"\n onChange={quality => {\n model.setLayoutQuality(Number(quality))\n }}\n >\n <Caption>\n The engine&apos;s iteration budget; higher is slower\n </Caption>\n </SettingSelect>\n\n <SettingSelect\n label=\"Bubble spread\"\n value={model.bubbleSpread}\n options={BUBBLE_SPREADS}\n testId=\"graph-bubble-spread-select\"\n onChange={spread => {\n model.setBubbleSpread(spread)\n }}\n >\n <Caption>How far the layout opens a bubble</Caption>\n </SettingSelect>\n\n {model.chosenLayoutEngine === 'stress' ? null : (\n <SettingSwitch\n label=\"Linear layout\"\n checked={model.linearLayout}\n onChange={linear => {\n model.setLinearLayout(linear)\n }}\n >\n <Caption>Keeps a chain of nodes on one line where it can</Caption>\n </SettingSwitch>\n )}\n </Group>\n </DialogContent>\n\n <DialogActions>\n <Button variant=\"contained\" color=\"primary\" onClick={onClose}>\n Close\n </Button>\n </DialogActions>\n </Dialog>\n )\n})\n\nexport default GraphSettingsDialog\n"],
5
5
  "mappings": "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",
6
6
  "names": ["LAYOUT_QUALITIES", "LabelledSelect_default", "observer", "label", "value", "options", "testId", "size", "sx", "disabled", "title", "shown", "onChange", "labelId", "useId", "jsxs", "FormControl", "jsx", "InputLabel", "Select", "picked", "o", "e", "MenuItem", "ListItemText", "useStyles", "makeStyles", "SUBGRAPH_CONTEXTS", "SubgraphContextSelect", "observer", "model", "classes", "adapter", "walkIndexed", "jsxs", "jsx", "LabelledSelect_default", "hops", "Typography", "SubgraphContextSelect_default", "useStyles", "makeStyles", "sameList", "a", "b", "useCutHaplotypes", "model", "reset", "current", "seen", "setSeen", "useState", "haplotypes", "HaplotypeListField", "observer", "draft", "setDraft", "setCut", "apply", "parseHaplotypes", "jsx", "TextField", "e", "HaplotypePickField", "names", "draftRef", "useRef", "typed", "open", "setOpen", "Autocomplete", "_", "text", "reason", "value", "params", "SubgraphHaplotypesField", "classes", "adapter", "cutsByHaplotype", "jsxs", "Typography", "SubgraphHaplotypesField_default", "useStyles", "makeStyles", "Caption", "observer", "warn", "children", "jsx", "Typography", "Group", "title", "classes", "jsxs", "SettingSwitch", "label", "checked", "onChange", "FormControlLabel", "Switch", "e", "SettingSelect", "props", "LabelledSelect_default", "NODE_LIMITS", "nodeLimitOptions", "current", "b", "limit", "TrackPickSetting", "choices", "stored", "auto", "testId", "t", "trackId", "name", "GraphSettingsDialog", "model", "onClose", "Dialog", "DialogContent", "SubgraphContextSelect_default", "SubgraphHaplotypesField_default", "NODE_WIDTHS", "width", "EDGE_WIDTHS", "links", "draw", "MAX_PATH_COLORS", "pickGeneTrack", "pickRepeatTrack", "LAYOUT_ENGINES", "engine", "LAYOUT_QUALITIES", "q", "quality", "BUBBLE_SPREADS", "spread", "linear", "DialogActions", "Button", "GraphSettingsDialog_default"]
@@ -1,2 +1,2 @@
1
- import{A as at,C as St,E as Jt,J as te,K as J,Q as ee,R as ne,a as $,b as wt,c as K,d as Y,g as W,h as Vt,i as U,ka as oe,m as Z,ma as se,n as st,na as Q,o as jt,p as bt,q as rt,r as G,s as Kt,t as Ut,u as Zt,x as R}from"./chunk-TD6XNJRC.js";import{b as Qt,c as ct}from"./chunk-4FDZC66W.js";var ss=[{value:"depth",label:"By depth",description:"Thicker the more paths carry a node, on the square root of its depth against the mean. A graph with one depth everywhere draws uniform."},{value:"frequency",label:"By frequency",description:"As wide as the share of haplotypes that pass a node, or its AF tag: full width at 100%, half at 50%, and wider where a haplotype passes it more than once."},{value:"uniform",label:"Uniform",description:"Every node the same thickness."}],sn=.3,kt=3,rn=.05;function re(t){let e=0,n=0;for(let o of t.nodes)e+=o.depth*o.length,n+=o.length;return n>0?e/n:0}function It(t){return t.sample===void 0?ct(t.name)??t.name:`${t.sample}#${t.haplotype??0}`}function At(t){let e=new Map;for(let n of t.paths??[]){let o=It(n);e.has(o)||e.set(o,e.size)}return e}function an(t){return At(t).size}function cn(t,e){return t.frequency??(e>0?t.depth/e:void 0)}function _t(t,e){return e==="depth"?re(t):e==="frequency"?an(t):0}function ae(t){return Math.min(kt,Math.max(rn,t))}function fn(t,e){let n=cn(t,e);return n===void 0?1:ae(n)}function rs(t){return[1,.5,.1].map(e=>({label:`${e*100}%`,widthPx:t*ae(e)}))}function ce(t,e){return!(e>0)||!(t>0)?1:Math.min(kt,Math.max(sn,Math.sqrt(t/e)))}function as(t,e,n){let o=1/0,s=-1/0;for(let{id:a,depth:c}of t.nodes)(!n||n.has(a))&&(o=Math.min(o,c),s=Math.max(s,c));let r=re(t);return(o<s?[s,o]:o===s?[s]:[]).map(a=>({depth:a,widthPx:e*ce(a,r)}))}function Et(t,e,n,o){return e*(n==="depth"?ce(t.depth,o):n==="frequency"?fn(t,o):1)}function ln(t,e){return t*(e==="uniform"?1:kt)}var dn=4;function un(t,e){return Math.max(t/e,dn)}function hn(t,e,n){let o=[...t.from,...t.to].flatMap(s=>{let r=n(s);return r===void 0?[]:[r]});return o.length>0?o.reduce((s,r)=>Math.min(s,r),1/0):e}function cs(t,e,n,o,s=0,r){let a=t?_t(t,o):0,c=f=>s>0?un(f,s)*s/2:f/2,i=f=>{let l=e?.get(f);return l?Et(l,n,o,a):void 0};return{maxHalfWidthPx:c(ln(n,o)),halfWidthPx:f=>{let l=i(f)??n,d=r?.get(f);return c(d?hn(d,l,i):l)}}}function Nt(t){return t==="+"?"-":"+"}function hs(t,e=new Set){let n=t.edges.map(st),o=new Map,s=(u,m,h)=>{$(o,`${u}|${m}`,h)};t.edges.forEach((u,m)=>{s(u.from,n[m].from,m),s(u.to,n[m].to,m)});let r=u=>{let m=o.get(`${u}|end`);if(m?.length!==1)return;let h=m[0],v=t.edges[h];return v.from===u&&v.to!==u&&!e.has(u)&&!e.has(v.to)&&n[h].from==="end"&&n[h].to==="start"&&o.get(`${v.to}|start`)?.length===1?h:void 0},a=new Set,c=new Map,i=new Map;for(let u of t.nodes){let m=o.get(`${u.id}|start`),h=m?.length===1?t.edges[m[0]].from:void 0;if(c.has(u.id)||h!==void 0&&r(h)===m[0])continue;let v=[u.id];for(;;){let y=r(v.at(-1)),M=y===void 0?void 0:t.edges[y].to;if(M===void 0||c.has(M))break;a.add(y),v.push(M)}for(let y of v)c.set(y,u.id);v.length>1&&i.set(u.id,v)}for(let u of t.nodes)c.has(u.id)||c.set(u.id,u.id);let f=new Map(t.nodes.map(u=>[u.id,u])),l=[];for(let u of t.nodes){if(c.get(u.id)!==u.id)continue;let m=i.get(u.id);if(!m){l.push(u);continue}let h=m.map(M=>f.get(M)),v=h.filter(R),y=v.length?v.reduce((M,S)=>M.stable.start<=S.stable.start?M:S):h[0];l.push({id:u.id,name:u.name,length:h.reduce((M,S)=>M+S.length,0),depth:u.depth,stable:y.stable&&Z(y.id)!==Z(u.id)?{...y.stable,strand:Nt(y.stable.strand??"+")}:y.stable})}let d=new Set,p=[];return t.edges.forEach((u,m)=>{let h=c.get(u.from),v=c.get(u.to),y=n[m],M=`${h}|${y.from}>${v}|${y.to}`;a.has(m)||d.has(M)||(d.add(M),p.push({from:h,to:v,...y.from==="start"?{fromStrand:Nt(Z(h))}:{},...y.to==="end"?{toStrand:Nt(Z(v))}:{}}))}),{graph:{...t,nodes:l,edges:p,paths:void 0,pathVisits:void 0},runs:i}}function ps(t,e,n){let o={...t};for(let[s,r]of e){let a=t[s];if(!a?.length)continue;delete o[s];let c=Lt(a),i=c.at(-1),f=r.map(p=>Math.max(n(p),0)),l=f.reduce((p,u)=>p+u,0),d=0;r.forEach((p,u)=>{let m=l?f[u]/l*i:i/r.length,h=u===r.length-1?i:d+m;o[p]=fe(a,c,d,h),d=h})}return o}function ms(t,e,n){if(t.length===0)return[];let o=Lt(t),s=o.at(-1);return fe(t,o,e*s,n*s)}function it(t,e){let n=Lt(t);return t.length===0?{x:Number.NaN,y:Number.NaN}:Ot(t,n,n.at(-1)*e)}function Lt(t){let e=[0];for(let n=1;n<t.length;n++)e.push(e[n-1]+Math.hypot(t[n].x-t[n-1].x,t[n].y-t[n-1].y));return e}var ie=(t,e)=>Y(t.length,n=>t[n]<e);function Ot(t,e,n){if(n<=0)return{...t[0]};let o=ie(e,n);if(o>=e.length)return{...t.at(-1)};let s=e[o]-e[o-1],r=s>0?(n-e[o-1])/s:0,a=t[o-1],c=t[o];return{x:a.x+(c.x-a.x)*r,y:a.y+(c.y-a.y)*r}}function fe(t,e,n,o){let s=[Ot(t,e,n)];for(let r=ie(e,n);r<t.length&&e[r]<o;r++)e[r]>n&&s.push({...t[r]});return s.push(Ot(t,e,o)),s}var le=[.1834346424956498,.525532409916329,.7966664774136267,.9602898564975363],pn=[.362683783378362,.3137066458778873,.2223810344533745,.1012285362903763],mn=1e-10,yn=40;function gn(t,e,n){let o=3*(t.cx0-t.x0)*e,s=3*(t.cx1-t.cx0)*e,r=3*(t.x1-t.cx1)*e,a=3*(t.cy0-t.y0)*n,c=3*(t.cy1-t.cy0)*n,i=3*(t.y1-t.cy1)*n;return f=>{let l=1-f,d=l*l,p=2*l*f,u=f*f;return Math.hypot(d*o+p*s+u*r,d*a+p*c+u*i)}}function Pt(t,e,n){let o=(n-e)/2,s=(e+n)/2,r=0;for(let a=0;a<le.length;a++){let c=o*le[a];r+=pn[a]*(t(s-c)+t(s+c))}return r*o}function Ct(t,e,n,o,s,r){let a=(e+n)/2,c=Pt(t,e,a),i=Pt(t,a,n);return r>=yn||!(Math.abs(c+i-o)>s)?c+i:Ct(t,e,a,c,s/2,r+1)+Ct(t,a,n,i,s/2,r+1)}function de(t,e,n){let o=(a,c,i,f)=>Math.hypot((i-a)*e,(f-c)*n),s=o(t.x0,t.y0,t.cx0,t.cy0)+o(t.cx0,t.cy0,t.cx1,t.cy1)+o(t.cx1,t.cy1,t.x1,t.y1),r=gn(t,e,n);return Ct(r,0,1,Pt(r,0,1),mn*s,0)}var xn=1e-6,ft=100;function xs(t){return Math.max(xn,Math.min(ft,t))}var V=(t,e)=>{let n=Math.max(0,t),o=Math.min(1,e);return n<=o?[n,o]:void 0};function ue(t,e,n,o){return e===0?t>=n&&t<=o?V(0,1):void 0:V(Math.min((n-t)/e,(o-t)/e),Math.max((n-t)/e,(o-t)/e))}var Mn=(t,e)=>t&&e?V(Math.max(t[0],e[0]),Math.min(t[1],e[1])):void 0;function lt(t,e,n,o){let s=e.x-t.x,r=e.y-t.y,a=t.x-n.x,c=t.y-n.y,i=s*s+r*r,f=2*(a*s+c*r),l=a*a+c*c-o*o,d=f*f-4*i*l;return i===0?l<=0?V(0,1):void 0:d<0?void 0:V((-f-Math.sqrt(d))/(2*i),(-f+Math.sqrt(d))/(2*i))}function vn(t,e,n,o,s){let r=Math.hypot(o.x-n.x,o.y-n.y),a=r>0?(o.x-n.x)/r:0,c=r>0?(o.y-n.y)/r:0,i=t.x-n.x,f=t.y-n.y,l=e.x-t.x,d=e.y-t.y,p=r>0?Mn(ue(i*a+f*c,l*a+d*c,0,r),ue(i*c-f*a,l*c-d*a,-s,s)):void 0,u=[lt(t,e,n,s),lt(t,e,o,s),p].filter(m=>m!==void 0);return u.length>0?V(u.reduce((m,h)=>Math.min(m,h[0]),1),u.reduce((m,h)=>Math.max(m,h[1]),0)):void 0}var he=1e-9;function Xt(t,e,n,o=0){let s=n.halfWidth-o,r=[];for(let c of n.lines){for(let f=1;f<c.length;f++){let l=vn(t,e,c[f-1],c[f],s);l&&r.push(l)}let i=c.length===1?lt(t,e,c[0],s):void 0;i&&r.push(i)}for(let c of n.points){let i=lt(t,e,c,s);i&&r.push(i)}r.sort((c,i)=>c[0]-i[0]);let a=0;for(let[c,i]of r)a=c<=a+he?Math.max(a,i):a;return s>=0&&a>=1-he}var Tt=(t,e)=>Xt(t,t,e);function pe(t,e,n,o){let s={x0:t.x0*e,y0:t.y0*n,cx0:t.cx0*e,cy0:t.cy0*n,cx1:t.cx1*e,cy1:t.cy1*n,x1:t.x1*e,y1:t.y1*n},r=Math.max(Math.hypot(s.x0-2*s.cx0+s.cx1,s.y0-2*s.cy0+s.cy1),Math.hypot(s.cx0-2*s.cx1+s.x1,s.cy0-2*s.cy1+s.y1)),a=Math.max(1,Math.ceil(Math.sqrt(.75*r/o)));return Array.from({length:Number.isFinite(a)?a+1:0},(c,i)=>W(s,i/a))}function H(){let t=new WeakMap;return(e,n,o)=>{let s=t.get(e);if(s?.deps.length===n.length&&s.deps.every((a,c)=>Object.is(a,n[c])))return s.value;let r=o();return t.set(e,{deps:n,value:r}),r}}var q=3,me=.01;function Xs(t){let e=new Set(t.collapsed?.nodes);for(let n of t.laneOnly?.nodes??[])e.add(n);return e}var Ts={sites:[],nodes:new Set,edges:new Set,siteOf:new Map,pxPerBp:0,within:new Map,through:new Map,bridges:new Map,runOf:new Map},z=t=>!!t&&R(t)&&!t.placeholder,dt=(t,e)=>t.stable.start+(at(t,e)?t.length:0),Bt=(t,e)=>t.stable.start+(at(t,e)?0:t.length),ye=(t,e,n)=>n===at(t,e)?"end":"start";function wn(t){let e=At(t),n=new Map,o=new Map;for(let r of t.paths??[]){let a=e.get(It(r))??0;n.set(r.name,a);for(let c of r.nodeIds)wt(o,c,a)}let s=r=>n.get(r)??e.get(ct(r)??r);for(let r of t.nodes)for(let{path:a}of r.departureVisits??[]){let c=s(a);c!==void 0&&wt(o,r.id,c)}return{total:e.size,byNode:o,walkNamed:s}}function bn(t,e,n){let o=new Map(t.nodes.map(g=>[g.id,g])),{total:s,byNode:r,walkNamed:a}=wn(t),c=new Map;for(let g of t.nodes)R(g)||c.set(g.id,g.id);let i=g=>{let x=g,b=c.get(x);for(;b!==void 0&&b!==x;)x=b,b=c.get(x);let k=g;for(;k!==x;){let I=c.get(k)??x;c.set(k,x),k=I}return x},f=g=>c.has(g);for(let{from:g,to:x}of t.edges)f(g)&&f(x)&&c.set(i(g),i(x));let l=new Map,d=g=>{let x=i(g),b=l.get(x),k=b??{nodes:[],edges:[],feet:[],attachments:[],ends:new Set,refNames:new Set,walks:[],bp:0,skip:void 0,tail:!1,tied:!1};return b||l.set(x,k),k};for(let g of t.nodes)if(f(g.id)){let x=d(g.id);x.nodes.push(g.id),x.bp+=g.length}let p=[],u=new Map;t.edges.forEach(({from:g,to:x,fromStrand:b,toStrand:k,pathIds:I},_)=>{let T=f(g)?g:f(x)?x:void 0,X=f(g)?x:g,O=o.get(X),w=o.get(g),L=o.get(x);if(T!==void 0){let A=d(T);A.edges.push(_),f(X)||(z(O)?(A.feet.push({edge:_,atEnd:X===x}),A.refNames.add(O.stable.refName),A.attachments.push(X===g?dt(O,b):Bt(O,k)),A.ends.add(X===g?ye(O,b,!0):ye(O,k,!1))):A.tied=!0)}else if(z(w)&&z(L)&&w.stable.refName===L.stable.refName&&dt(w,b)===Bt(L,k)){let A=u.get(w.stable.refName)??[];A.push({edge:_,at:dt(w,b)}),u.set(w.stable.refName,A)}else if(e?.has(_)&&!n?.has(_)&&z(w)&&z(L)){let A=new Set;for(let B of I??[]){let P=a(B);P!==void 0&&A.add(P)}if(A.size>0){let B=[dt(w,b),Bt(L,k)];p.push({nodes:[],edges:[_],feet:[{edge:_,atEnd:!1},{edge:_,atEnd:!0}],attachments:B,refNames:new Set([w.stable.refName,L.stable.refName]),walks:[...A],bp:ge(B),skip:_,tail:!1})}}});let m=[...p],h=oe(t);for(let{tied:g,ends:x,...b}of l.values()){let k=new Set;for(let _ of b.nodes)for(let T of r.get(_)??[])k.add(T);let I=b.nodes.some(_=>h.has(_));!g&&(x.size===2||b.feet.length===1)&&(!I||b.nodes.every(_=>o.get(_)?.placeholder))&&k.size>0&&m.push({...b,bp:b.bp+ge(b.attachments),walks:[...k],tail:I})}let v=t.nodes.filter(z),y=new Map,M=g=>{let x=y.get(g),b=x??{spans:[],links:[],endingAt:new Map,startingAt:new Map};return x||y.set(g,b),b};for(let g of v){let{refName:x,start:b}=g.stable,k=M(x),I=b+g.length;k.spans.push({id:g.id,start:b,end:I}),$(k.endingAt,I,g.id),$(k.startingAt,b,g.id)}for(let[g,x]of u)M(g).links=x;for(let g of y.values())g.spans.sort((x,b)=>x.start-b.start),g.links.sort((x,b)=>x.at-b.at);let S=g=>g.nodes[0]??`#${g.skip}`;return{units:m.map(g=>({unit:g,start:tt(g.attachments),key:S(g)})).sort((g,x)=>g.start!==x.start?g.start-x.start:g.key<x.key?-1:g.key>x.key?1:0).map(({unit:g})=>g),total:s,backbone:v.map(g=>g.id),backboneBp:v.reduce((g,x)=>g+x.length,0),references:y}}function pt(t,e,n){let o=[];for(let s=Y(t.length,r=>t[r].start<e);s<t.length&&t[s].start<n;s++){let r=t[s];r.end<=n&&r.end>r.start&&o.push(r)}return o}function Sn(t,e){let n=new Map;for(let o of t){let s=e.get(o.refName)?.spans??[];for(let r of pt(s,o.start,o.end))n.set(r.id,o)}return n}function kn(t,e){let n=new Map,o=new Map,s=new Map,r=t.toSorted((c,i)=>c.refName!==i.refName?c.refName<i.refName?-1:1:c.start-i.start),a=0;for(;a<r.length;){let{refName:c}=r[a],{start:i}=r[a],{end:f}=r[a],l=a;for(a++;a<r.length&&r[a].refName===c&&r[a].start<=f;)f=Math.max(f,r[a].end),a++;let d=e.get(c);if(d){let p=pt(d.spans,i,f),u={start:i,end:f,from:d.endingAt.get(i)??[],to:d.startingAt.get(f)??[]};for(let h of p)n.set(h.id,u);for(let h of r.slice(l,a))s.set(h,u);let{links:m}=d;for(let h=Y(m.length,v=>m[v].at<i);h<m.length&&m[h].at<=f;h++)o.set(m[h].edge,{run:u,at:m[h].at})}}return{nodes:n,bridges:o,runOf:s}}var tt=t=>t.reduce((e,n)=>Math.min(e,n),1/0),ht=t=>t.reduce((e,n)=>Math.max(e,n),-1/0),ge=t=>t.length>0?ht(t)-tt(t):0,In=H();function An(t,{edge:e,atEnd:n}){let o=t.get(e),s=o?.[0],r=o?.at(-1);return!s||!r?void 0:n?{x:r.x1,y:r.y1}:{x:s.x0,y:s.y0}}var _n=t=>({x:t.reduce((e,n)=>e+n.x,0)/t.length,y:t.reduce((e,n)=>e+n.y,0)/t.length}),En=(t,e)=>t.reduce((n,o)=>n+de(o,e.scaleX,e.scaleY),0);function Nn(t,e){let n=t[0],o=t.at(-1);return n&&o?Math.hypot((o.x1-n.x0)*e.scaleX,(o.y1-n.y0)*e.scaleY):0}function xe(t,e,n,o){let s=tt(t.attachments),r=ht(t.attachments),a=e?.links??[],c=0;for(let i of t.nodes)c+=n(i);for(let i of t.edges)c+=o(i);for(let i of e?pt(e.spans,s,r):[])c+=n(i.id);for(let i=Y(a.length,f=>a[f].at<s);i<a.length&&a[i].at<=r;i++)c+=o(a[i].edge);return c}function Me(t){let e=new Map;return n=>{let o=e.get(n),s=o??t(n);return o===void 0&&e.set(n,s),s}}function Rt(t,e,n,o){let s=t.reduce((r,a)=>r+G(n[a]??[],o.scaleX,o.scaleY),0);return e>0?s/e:0}var On=H();function Bs(t,e,n,o=0){return On(e,[t,n.scaleX,n.scaleY,o],()=>{let s=t.filter(z);return Rt(s.map(r=>r.id),s.reduce((r,a)=>r+a.length,0),e,n)})}var ut=(t,e)=>({x:t.x*e.scaleX,y:t.y*e.scaleY});function Ln(t,e,n,o,s){let r=t.nodes.map(c=>(n[c]??[]).map(i=>ut(i,s))),a=(c,i)=>c.every((f,l)=>l===0||Xt(c[l-1],f,e,i));return r.every(c=>c.every(i=>Tt(i,e)))&&r.every(c=>a(c,0))&&t.edges.every(c=>(o.get(c)??[]).every(i=>a(pe(i,s.scaleX,s.scaleY,me),me)))}function Pn(t,e,n,o,s,r,a){let{units:c,total:i,backbone:f,backboneBp:l,references:d}=In(t,[s,r],()=>bn(t,s,r)),p=Rt(f,l,e,n),u={...n,scaleX:ft,scaleY:n.pixelRows?n.scaleY:ft},m=Rt(f,l,e,u),h=new Set(t.nodes.flatMap(w=>w.placeholder?[w.id]:[])),v=(w,L)=>({node:Me(A=>G(e[A]??[],w.scaleX,w.scaleY)),edge:Me(A=>L(o.get(A)??[],w))}),y=v(n,En),M=v(u,Nn),S=(w,L)=>{let A=d.get(L),B=xe(w,A,y.node,y.edge),P=xe(w,A,M.node,M.edge),E=w.nodes.some(C=>h.has(C))&&p>0;return w.tail?{shown:w.bp*p,back:w.bp*m}:{shown:E?Math.min(B,w.bp*p):B,back:E?Math.min(P,w.bp*m):P}},N=new Map(t.nodes.map(w=>[w.id,w])),g=_t(t,a.nodeWidth),x=w=>{let L=N.get(w);return L?Et(L,a.contigThickness,a.nodeWidth,g)/2:0},b=(w,L,A,B)=>{let P=L?pt(L.spans,tt(w.attachments),ht(w.attachments)).map(C=>C.id):[],E=w.feet.flatMap(({edge:C,atEnd:j})=>{let vt=t.edges[C];return vt?[j?vt.to:vt.from]:[]});return{lines:P.map(C=>(e[C]??[]).map(j=>ut(j,B))),points:A.map(C=>ut(C,B)),halfWidth:[...P,...E].reduce((C,j)=>Math.min(C,x(j)),1/0)}},k=(w,L,A)=>{let B=()=>{let P=b(w,L,A,u);return w.nodes.some(E=>(e[E]??[]).some(C=>!Tt(ut(C,u),P)))};return w.nodes.length>0&&w.bp*p<q&&w.bp*m>=q&&Ln(w,b(w,L,A,n),e,o,n)&&B()},I=new Set,_=new Set,T=new Map,X=[];for(let w of c){let L=w.feet.flatMap(P=>{let E=An(o,P);return E?[E]:[]}),[A]=w.refNames,B=A!==void 0&&w.refNames.size===1&&w.bp>0&&L.length===w.feet.length&&w.nodes.every(P=>e[P]?.length)?S(w,A):void 0;if(A!==void 0&&B&&B.back>=q&&(B.shown<q||k(w,d.get(A),L))){let P={nodes:w.nodes,edges:w.edges,refName:A,start:tt(w.attachments),end:ht(w.attachments),bp:w.bp,..._n(L),count:w.walks.length,total:i};X.push(P);for(let E of w.nodes)I.add(E),T.set(E,P);for(let E of w.edges)_.add(E)}}let O=kn(X,d);return{sites:X,nodes:I,edges:_,siteOf:T,pxPerBp:p,within:Sn(X,d),through:O.nodes,bridges:O.bridges,runOf:O.runOf}}var Cn=H(),Rs=t=>t.sites.reduce((e,n)=>Math.max(e,n.bp+1),0);function Hs(t,e,n,o,s,r,a){return Cn(o,[t,e,s,r,a.contigThickness,a.nodeWidth],()=>Pn(t,e,n,o,s,r,a))}var ve=11,Xn=6.2,mt=4;function yt(t){return t.length*Xn+mt*2}function Se(t,e){return t.x0<e.x1&&t.x1>e.x0&&t.y0<e.y1&&t.y1>e.y0}function ke(t,e){return t.x1<=0||t.x0>=e.width||t.y1<=0||t.y0>=e.height}function D(t,e){return t.x0>=0&&t.x1<=e.width&&t.y0>=0&&t.y1<=e.height}function Ie(t,e){return{x0:t.x0-e,x1:t.x1+e,y0:t.y0-e,y1:t.y1+e}}function Tn(t,e=[]){let n=[...e];return(o,s)=>{let r=s?[o,s]:[o];if(ke(o,t)||n.some(a=>r.some(c=>Se(a,c))))return!1;for(let a of r)n.push(a);return!0}}var we=8;function be(t){let e=[0];for(let n=we;n<t;n+=we)e.push(-n,n);return t>0&&e.push(-t,t),e}function Ys(t,e,n,o=[],s=0){let r=[],a=0,c=ve+mt*2,i=(h,v,y)=>({x0:h-y/2,x1:h+y/2,y0:v-ve-mt,y1:v+mt}),f=(h,v,y,M)=>{let S=yt(v),N=[];for(let x=0;x<=(h.stack??0);x++){let b=y+M*x*c;if(ke(i(h.x,b,S),e))break;for(let k of be(h.slide??0))N.push({dx:k,y:b,distance:Math.hypot(k,x*c)})}N.sort((x,b)=>x.distance-b.distance);let g=!1;for(let{dx:x,y:b}of N){let k=i(h.x+x,b,S);if(D(k,e)&&(h.fits?.(k)??!0)){if(n(k))return{placed:{...h,x:h.x+x,text:v,y:b,w:S},crowded:g};g||=!o.some(I=>Se(I,k))}}return{placed:void 0,crowded:g}},l=(h,v)=>{let y=f(h,v,h.y,h.y>e.height/2?-1:1);return y.placed||h.flipY===void 0||y.crowded?y:f(h,v,h.flipY,h.flipY<h.y?-1:1)},d=Math.ceil(e.height/c),p=h=>{let v=[];for(let y=-d;y<=d;y++)for(let M of be(h))v.push({dx:M,dy:y*c,distance:Math.hypot(M,y*c)});return v.sort((y,M)=>y.distance-M.distance)},u,m=(h,v,y)=>{let M=yt(v),S=D({x0:y.x,x1:y.x,y0:y.y,y1:y.y},e)?u??=p(e.width):p(h.slide??0),N=x=>{let b;for(let k=0;k<S.length&&!b;k++){let I=y.x+S[k].dx,_=y.y+S[k].dy,T=i(I,_,M);b=D(T,e)&&x(T)?{x:I,y:_}:void 0}return b},g=N(x=>(h.fits?.(x)??!0)&&n(x))??N(n);return g&&{...h,x:g.x,y:g.y,text:v,w:M}};for(let h of t){let v=l(h,h.text),y=v.placed||h.fallback===void 0?void 0:l(h,h.fallback),M=v.placed??y?.placed,S=v.crowded||y?.crowded===!0,N=M||h.nearest===void 0||S&&a>=s?void 0:m(h,h.text,h.nearest);N&&a++;let g=M??N;g&&r.push(g)}return r}function qs(t,e){let n=new Set(t.nodes.filter(i=>R(i)&&St(i,e)).map(i=>i.id)),o=t.paths??[];if(n.size===0||o.length===0)return t;let s=o.map(i=>{let f=-1,l=-1;return i.nodeIds.forEach((d,p)=>{n.has(d)&&(f<0&&(f=p),l=p)}),f<0?void 0:{first:f,last:l}});if(s.every((i,f)=>i?.first===0&&i.last===o[f].nodeIds.length-1))return t;let r=new Set,a=[],c=new Map;return o.forEach((i,f)=>{let l=s[f];if(l){let d=i.nodeIds.slice(l.first,l.last+1);for(let p of d)r.add(p);a.push({...i,nodeIds:d,...i.refStarts?{refStarts:i.refStarts.subarray(l.first,l.last+1)}:{}}),c.set(i.name,{first:l.first,nodeIds:d})}}),{...t,nodes:t.nodes.filter(i=>r.has(i.id)),edges:t.edges.filter(i=>r.has(i.from)&&r.has(i.to)),paths:a,pathVisits:t.pathVisits&&Bn(t.pathVisits,o,s,new Map(t.nodes.map(i=>[i.id,i.name]))),anchorPaths:ee(t,c)}}function Bn(t,e,n,o){let s=t.replay(),r=new te;return e.forEach((a,c)=>{let i=t.pathIndex(J(a.name).name),f=n[c];a.nodeIds.forEach((l,d)=>{let p=o.get(l)??l,u=s(t.slot(p),i);u>=0&&f&&d>=f.first&&d<=f.last&&r.add(p,t.paths[i],t.samples[i],t.start[u],t.reversed[u]===1)})}),r.build()}function Gs(t,e,n){let o=t.nodes.map(s=>{if(!R(s))return s;let r=s.stable.start,a=r+s.length,[c,i]=St(s,e)?[Math.max(r,e.start),Math.min(a,e.end)]:a<=e.start?[Math.max(r,a-n),a]:[r,Math.min(a,r+n)];return c===r&&i===a?s:{...s,length:i-c,stable:{...s.stable,start:c},unclipped:{start:r,length:s.length}}});return o.some((s,r)=>s!==t.nodes[r])?{...t,nodes:o}:t}function Ae(t){return t.nodes.some(e=>e.unclipped)?{...t,nodes:t.nodes.map(({unclipped:e,...n})=>e&&n.stable?{...n,length:e.length,stable:{...n.stable,start:e.start}}:n)}:t}var Rn=1,er=t=>`skips ${t??"the reference"} sequence`,nr="short skip";function Hn(t,e){return e.flatMap(n=>t[n]??[])}function Ht(t,e,n,o,s,r){let a=t[e.from],c=t[e.to];if(!(!a?.length||!c?.length))return s?Zt(a,c,s,r?st(e):void 0):Ut(a,c,Kt(e,r),n,o?Hn(t,o):[])}function $n(t){let e=K(t.nodes.filter(R),n=>n.stable.refName);for(let n of e.values())n.sort((o,s)=>o.stable.start-s.stable.start);return e}function Yn(t,e,n){let o=[];if(t)for(let s=Jt(t,e);s<t.length;s++){let r=t[s];if(r.stable.start>=n)break;r.stable.start+r.length<=n&&o.push(r.id)}return o}function Wn(t,e,n,o){let{fromStrand:s,toStrand:r}=t;if(s===void 0||r===void 0)return!0;let a=s===e.strand,c=r===n.strand;return o?a&&c:!a&&!c}function Dn(t,e,n,o){let s;for(let[r,a]of o){let c=r.start<=a.start,i=c?{start:r.start+e.length,end:a.start}:{start:a.start+n.length,end:r.start};Wn(t,r,a,c)&&(!s||Math.abs(i.end-i.start)<Math.abs(s.end-s.start))&&(s=i)}return s}function Fn(t,e,n){return n(t).flatMap(o=>n(e).map(s=>[o,s]))}function zn(t){let{pathVisits:e}=t;return(n,o)=>{let s;if(e){let r=e.pathIndex(n.stable.refName),a=e.slot(n.name);if(a>=0&&r>=0)for(let c=e.offsets[a];c<e.offsets[a+1]&&!s;c++)e.path[c]===r&&e.start[c]===o&&(s={start:o,strand:e.strand(c)})}return s}}function qn(t,e){let n=new Map;for(let r of e){let{from:a,to:c}=t.edges[r],i=n.get(a);i||(i=new Map,n.set(a,i)),$(i,c,r)}let o=new Map,s=(r,a,c)=>{let i=o.get(r);if(i||(i=[],o.set(r,i)),!Number.isNaN(a)&&!Number.isNaN(c)){let f=!1;for(let l=0;l<i.length&&!f;l+=2)f=i[l]===a&&i[l+1]===c;f||i.push(a,c)}};for(let{nodeIds:r,refStarts:a}of t.paths??[])if(a)for(let c=1;c<r.length;c++){let i=r[c-1],f=r[c];for(let l of n.get(i)?.get(f)??[])s(l,a[c-1],a[c]);for(let l of n.get(f)?.get(i)??[])s(l,a[c],a[c-1])}return o}function Gn(t,e,n,o){let s=[];for(let r=0;r<n.length;r+=2){let a=o(t,n[r]),c=o(e,n[r+1]);a&&c&&s.push([a,c])}return s}var Vn=.01;function jn(t,e){let n=new Map;for(let[o,s]of t){let r=s.flatMap(a=>{let c=e(a).map(i=>i.start);return c.slice(1).map((i,f)=>({at:c[f],copy:i-c[f]}))});r.length&&n.set(o,r.sort((a,c)=>a.at-c.at))}return n}function Kn(t,e,n){if(!t)return!1;let o=Y(t.length,r=>t[r].at<e),s=[t[o-1],t[o]].filter(r=>r!==void 0).sort((r,a)=>Math.abs(r.at-e)-Math.abs(a.at-e))[0];return s!==void 0&&Math.abs(s.at-e)<=s.copy&&Math.abs(n-s.copy)<=s.copy*Vn}function Un(t){let e=Ae(t),n=new Map(e.nodes.map(l=>[l.id,l])),o=$n(e),s=ne(e),r=e.edges.flatMap((l,d)=>{let p=n.get(l.from),u=n.get(l.to);return!l.foldBridge&&p!==void 0&&u!==void 0&&R(p)&&R(u)&&p.stable.refName===u.stable.refName?[{edgeIndex:d,edge:l,from:p,to:u}]:[]}),c=e.paths!==void 0&&e.paths.length>0&&e.paths.every(l=>l.refStarts)?qn(e,r.map(l=>l.edgeIndex)):new Map,i=zn(e);return{links:r.map(({edgeIndex:l,edge:d,from:p,to:u})=>{let m=c.get(l);return{edgeIndex:l,edge:d,refName:p.stable.refName,span:Dn(d,p,u,m?Gn(p,u,m,i):Fn(p,u,s))}}),backbone:o,copies:jn(o,s)}}function Ee(t){let{links:e,backbone:n,copies:o}=Un(t);return e.flatMap(({edgeIndex:s,edge:r,refName:a,span:c})=>{let i=c?c.end-c.start:0;return c&&i>=Rn&&!Kn(o.get(a),c.start,i)?[{edgeIndex:s,from:r.from,to:r.to,...r.fromStrand?{fromStrand:r.fromStrand}:{},...r.toStrand?{toStrand:r.toStrand}:{},refName:a,start:c.start,end:c.end,bp:i,bypassed:Yn(n.get(a),c.start,c.end)}]:[]})}function Zn(t,e){let n=new Map,o=a=>{let c=a;for(;n.has(c);)c=n.get(c);return c!==a&&n.set(a,c),c},s=(a,c)=>{let[i,f]=[o(a),o(c)];return i!==f&&n.set(i,f),i!==f},r=new Set(e);return t.edges.forEach((a,c)=>{r.has(c)||s(a.from,a.to)}),new Set(se(e.map(a=>({...t.edges[a],ei:a}))).filter(a=>!s(a.from,a.to)).map(({ei:a})=>a))}var _e=new WeakMap;function or(t,e,n=!0){let o=_e.get(e);o||(o=new Map,_e.set(e,o));let s=o.get(n);if(!s){let r=n?new Set:Zn(t,e.map(a=>a.edgeIndex));s={shown:e.filter(a=>!r.has(a.edgeIndex)),bypassed:new Map(e.map(a=>[a.edgeIndex,a.bypassed])),hidden:r},o.set(n,s)}return s}var Jn=class extends Map{constructor(){super(...arguments),this.arcs=new Set}},Qn=1,to=11,eo=3*to,no=t=>t>=eo,$t=5,Pe=8,oo=64,Yt=-1,Ce=12,Ne=16,so=Ce+$t;function ro(t,e,n,o){let s=l=>({x:l.x*o.scaleX,y:l.y*o.scaleY}),r=t[0],a=t.at(-1),c=[s({x:r.x0,y:r.y0}),...e.flatMap(l=>(n[l]??[]).map(s)),s({x:a.x1,y:a.y1})],i=0,f=0;for(let l of t)for(let d=0;d<=Ne;d++){let p=s(W(l,d/Ne)),u=!1;for(let m=1;m<c.length&&!u;m++){let h=c[m-1],v=c[m];u=U(p.x,p.y,h.x,h.y,v.x,v.y)<=Ce}f++,i+=u?1:0}return i*2>f}function ao(t,e,n,o){let{ax:s,ay:r,ux:a,uy:c}=gt(t,o),i=0;for(let f of e)for(let l of n[f]??[]){let d=(l.y*o.scaleY-r)*a-(l.x*o.scaleX-s)*c;i=Math.abs(d)>Math.abs(i)?d:i}return Math.abs(i)>=1?-Math.sign(i):Math.sign(Wt(t,o,Pe))||Yt}function Oe(t,e){return gt(t,e).length}var co=H();function Xe(t,e,n,o,s,r,a=!1){return co(t,[e,n.scaleX,n.scaleY,!!n.pixelRows,o,r,a,s],()=>{let c=new Jn;for(let i=0;i<e.edges.length;i++){let f=e.edges[i],l=o?.get(i),d=r?.[i],p=l?Ht(t,f,n,l,d,a):void 0,u=l&&d&&p&&no(Oe(p,n))&&ro(p,l,t,n)?Le(p,n,so*ao(p,l,t,n)):p,m=u!==void 0&&Oe(u,n)>=Qn,h=m?u:Ht(t,f,n,void 0,void 0,a);h&&(c.set(i,h),m&&c.arcs.add(i))}if(o){let i=new Map(e.nodes.map(y=>[y.id,y])),{spans:f,levels:l,alone:d}=io(o,[e],()=>fo(Ee(e).filter(y=>o.has(y.edgeIndex)))),p=y=>l.get(y)??1,u=new Map(Array.from(c.arcs,y=>[y,lo(c.get(y),n)])),m=new Map;for(let y of u.values())m.set(y,(m.get(y)??0)+1);let h=new Map,v=new Map;for(let y of Array.from(c.arcs).sort((M,S)=>p(M)-p(S)||M-S)){let M=u.get(y),S=Math.max(p(y),(h.get(M)??0)+1);h.set(M,S),v.set(y,S*$t)}Te(f.filter(y=>c.arcs.has(y.edgeIndex)),(y,M)=>{let S=y.edgeIndex,N=e.edges[S],g=c.get(S),x=Math.max(v.get(S),M>0?M+$t:0),b=Wt(g,n,Pe),I=(!d.has(S)||m.get(u.get(S))>1)&&Math.abs(b)<x;if(I){let _=i.get(N.from)?.stable?.start??0,T=i.get(N.to)?.stable?.start??0,X=r?.[S]?_<=T?Yt:-Yt:Math.sign(b)||1;c.set(S,Le(g,n,x*X))}return I?x:Math.abs(Wt(g,n,oo))})}return c})}var io=H();function Te(t,e){for(let n of K(t,o=>o.refName).values()){let o=Array.from(new Set(n.map(r=>r.start))).sort((r,a)=>a-r),s=new Array(o.length+1).fill(0);for(let r of n.toSorted((a,c)=>a.end-c.end||c.start-a.start||a.edgeIndex-c.edgeIndex)){let a=Y(o.length,f=>o[f]>r.start)+1,c=0;for(let f=a;f>0;f-=f&-f)c=Math.max(c,s[f]);let i=e(r,c);for(let f=a;f<=o.length;f+=f&-f)s[f]=Math.max(s[f],i)}}}function fo(t){let e=new Map;Te(t,(o,s)=>(e.set(o.edgeIndex,s+1),s+1));let n=new Set;for(let o of K(t,s=>s.refName).values()){let s;for(let r of o.toSorted((a,c)=>a.start-c.start))s&&r.start<s.end&&(n.add(r.edgeIndex),n.add(s.edgeIndex)),s=s&&s.end>=r.end?s:r}return{spans:t,levels:e,alone:new Set(t.flatMap(o=>n.has(o.edgeIndex)?[]:[o.edgeIndex]))}}function lo(t,e){let n=t[0],o=t.at(-1);return[`${Math.round(n.x0*e.scaleX)},${Math.round(n.y0*e.scaleY)}`,`${Math.round(o.x1*e.scaleX)},${Math.round(o.y1*e.scaleY)}`].sort().join(" ")}function gt(t,e){let n=t[0],o=t.at(-1),s=n.x0*e.scaleX,r=n.y0*e.scaleY,a=Math.hypot(o.x1*e.scaleX-s,o.y1*e.scaleY-r);return{ax:s,ay:r,length:a,ux:(o.x1*e.scaleX-s)/a,uy:(o.y1*e.scaleY-r)/a}}function Wt(t,e,n){let{ax:o,ay:s,ux:r,uy:a}=gt(t,e),c=0;for(let i of t)for(let f=1;f<n;f++){let l=W(i,f/n),d=(l.y*e.scaleY-s)*r-(l.x*e.scaleX-o)*a;c=Math.abs(d)>Math.abs(c)?d:c}return c}function Le(t,e,n){let o=t[0],s=t.at(-1),{ux:r,uy:a}=gt(t,e),c=n/jt,i=-a*c/e.scaleX,f=r*c/e.scaleY,l=r*Math.abs(c)/e.scaleX,d=a*Math.abs(c)/e.scaleY;return[{x0:o.x0,y0:o.y0,cx0:o.x0+i-l,cy0:o.y0+f-d,cx1:s.x1+i+l,cy1:s.y1+f+d,x1:s.x1,y1:s.y1}]}var uo=50;function Be(t,e){return e>0?Math.max(1,t/e):uo}function ho(t){let e=new Set,n=1/0,o=-1/0;for(let s of t)e.add(s.minY),n=Math.min(n,s.minY),o=Math.max(o,s.minY);return e.size>1?(o-n)/(e.size-1):void 0}function He(t,e,n){let o=Be(e,t.length);return{x:o,y:n>0?Be(n,t.length):ho(t)??o}}function po(t,e,n,o){return t===void 0?He(e,n,o):typeof t=="number"?{x:t,y:t}:t}function mo(t,e,n){let o=t.get(e);o||(o=new Map,t.set(e,o));let s=o.get(n);return s||(s=[],o.set(n,s)),s}function $e(t,e,n,o,s,r,a){let c=Math.floor(n/e.x),i=Math.floor(s/e.x),f=Math.floor(o/e.y),l=Math.floor(r/e.y);for(let d=c;d<=i;d++)for(let p=f;p<=l;p++)mo(t,d,p).push(a)}function*Re(t,e,n){if(n-e<t.size)for(let o=e;o<=n;o++){let s=t.get(o);s!==void 0&&(yield s)}else{let o=[];for(let s of t)s[0]>=e&&s[0]<=n&&o.push(s);o.sort((s,r)=>s[0]-r[0]);for(let[,s]of o)yield s}}function*Ye(t,e,n,o,s,r){let a=Math.floor((o-r)/e.y),c=Math.floor((o+r)/e.y);for(let i of Re(t,Math.floor((n-s)/e.x),Math.floor((n+s)/e.x)))yield*Re(i,a,c)}function We(t,e,n,o,s,r){let a=[],c=new Set;for(let i of Ye(t,e,n,o,s,r))for(let f of i)c.has(f)||(c.add(f),a.push(f));return a}function yo(t,e,n,o,s,r,a){let c=!1;for(let i of Ye(t,e,n,o,s,r))if(c=i.some(a),c)break;return c}var Dt=class{constructor(t,e,n={x:0,y:0}){this.cells=new Map;let o=[],s=0,r=0;for(let[c,i]of Object.entries(t))for(let f=0;f<i.length-1;f++){let l=i[f],d=i[f+1],p=Math.min(l.x,d.x),u=Math.min(l.y,d.y),m=Math.max(l.x,d.x),h=Math.max(l.y,d.y);s+=m-p,r+=h-u,o.push({entry:{nodeId:c,segmentIdx:f},minX:p,minY:u,maxX:m,maxY:h})}let a=po(e,o,s,r);this.cellSize={x:Math.max(a.x,n.x),y:Math.max(a.y,n.y)};for(let c of o)$e(this.cells,this.cellSize,c.minX,c.minY,c.maxX,c.maxY,c.entry)}query(t,e,n,o=n){return We(this.cells,this.cellSize,t,e,n,o)}some(t,e,n,o,s){return yo(this.cells,this.cellSize,t,e,n,o,s)}},De=class{constructor(t,e,n,o,s,r=0,a,c=!1){this.cells=new Map,this.edgeCurves=Xe(t,e,o,s,r,a,c);let i=[],f=0,l=0;for(let d=0;d<e.edges.length;d++){let p=e.edges[d],u=t[p.from],m=t[p.to],h=this.edgeCurves.get(d);if(u?.length&&m?.length&&h){let{minX:v,minY:y,maxX:M,maxY:S}=Vt(h),N=p.pathIds?.length??0;if(n&&N>0){let g=0,x=0;for(let b of rt(u,m,N,o,h))g=Math.max(g,Math.abs(b.x)),x=Math.max(x,Math.abs(b.y));v-=g,y-=x,M+=g,S+=x}f+=M-v,l+=S-y,i.push({ei:d,minX:v,minY:y,maxX:M,maxY:S})}}this.cellSize=He(i,f,l);for(let d of i)$e(this.cells,this.cellSize,d.minX,d.minY,d.maxX,d.maxY,d.ei)}getCurves(t){return this.edgeCurves.get(t)}query(t,e,n,o=n){return We(this.cells,this.cellSize,t,e,n,o)}};var Fe=20;function go(t,e,n,o=1){let s=1/0,r=W(n,0);for(let a=1;a<=Fe;a++){let c=W(n,a/Fe);s=Math.min(s,U(t,e,r.x,r.y*o,c.x,c.y*o)),r=c}return s}function xo(t,e,n,o){let s=1/0;for(let r of n){let a=go(t,e,r,o);a<s&&(s=a)}return s}var Mo=H();function vo(t,e){return Mo(t,[e],()=>new Dt(t))}var ze=16,wo=H();function bo(t,e,n,o){return wo(t,[e,n,o],()=>new Dt(t,void 0,{x:ze/Math.abs(n),y:ze/Math.abs(o)}))}var So=H();function ko(t,e,n,o,s,r,a,c){return So(t,[e,n,o.scaleX,o.scaleY,!!o.pixelRows,s,r,a,c],()=>new De(t,e,n,o,r,s,a,c))}var Io=5;function vr(t,e,n,o,s,r,a){let c=bt(o),i=vo(t,s),f=m=>Math.max(Io,m)/o.scaleX,l=f(r?.maxHalfWidthPx??0),d=i.query(e,n,l,l/c),p=null,u=1/0;for(let{nodeId:m,segmentIdx:h}of d){let v=t[m],y=a?.nodes.has(m)?1/0:U(e,n*c,v[h].x,v[h].y*c,v[h+1].x,v[h+1].y*c);y<u&&y<f(r?.halfWidthPx(m)??0)&&(u=y,p=m)}return p}function xt(t,e,n){let o=e.x-t.x,s=e.y-t.y,r=0,a=1;for(let[c,i]of[[-o,t.x-n.x0],[o,n.x1-t.x],[-s,t.y-n.y0],[s,n.y1-t.y]])c===0?r=i<0?1/0:r:c<0?r=Math.max(r,i/c):a=Math.min(a,i/c);return r<=a?[r,a]:void 0}function Ao(t,e,n){return xt(t,e,n)!==void 0}function wr(t,e,n=0){let o=r=>({x:r.x*e.scaleX+e.translateX,y:r.y*e.scaleY+e.translateY}),s;return(r,a)=>(s??=bo(t,n,e.scaleX,e.scaleY),s.some(((r.x0+r.x1)/2-e.translateX)/e.scaleX,((r.y0+r.y1)/2-e.translateY)/e.scaleY,Math.abs((r.x1-r.x0)/2/e.scaleX),Math.abs((r.y1-r.y0)/2/e.scaleY),({nodeId:c,segmentIdx:i})=>{let f=t[c],l=f?.[i],d=f?.[i+1];return l!==void 0&&d!==void 0&&!a(c)&&Ao(o(l),o(d),r)}))}var _o={x:0,y:0};function br(t,e,n,o,s,r,a,c,i,f,l,d){let p=bt(s),u=10/s.scaleX,m=ko(t,e,r,s,a,c,f,l),h=m.query(n,o,u,u/p),v=null,y=u;for(let M of h){let S=e.edges[M],N=t[S.from],g=t[S.to],x=m.getCurves(M);if(N?.length&&g?.length&&x&&!i?.has(M)&&!d?.edges.has(M)){let b=S.pathIds?.length??0,k=r&&b>0?rt(N,g,b,s,x):[_o];for(let I of k){let _=xo(n-I.x,(o-I.y)*p,x,p);_<y&&(y=_,v=M)}}}return v}var Eo={nodeLengths:!0};function Cr(t,e=Eo.nodeLengths){let n=new Map;for(let o of t)(e||o.placeholder)&&n.set(o.id,o.length);return n}var No=4e4,Oo=8,Lo=5.7,Po=6,ot=13,et=3,Ft=ot,Co=3,Xo=2;function Gt(t){return(t.length*Lo+Po+et)/2}var F=(ot+et)/2,qe=2*F+2*Ft,Ke=({x:t,y:e},{width:n,height:o})=>t>=0&&t<=n&&e+F>0&&e-F<o;function Mt(t,e,n){return{x0:e-t,x1:e+t,y0:n-F,y1:n+F}}function Xr(t,e){return{x0:6,x1:6+yt(t)+et,y0:e-8-et/2,y1:e+8+et/2}}function Ue(t){return String(t).replace(/\B(?=(\d{3})+$)/g,",")}function zt(t){let[e,n]=t>=999500?[t/1e6,"Mb"]:t>=1e3?[t/1e3,"kb"]:[];return e===void 0?`${t} bp`:`${+e.toFixed(e>=100?0:1)} ${n}`}var To=H();function Bo(t,e,n){return To(t,[e,n],()=>Object.entries(t).filter(([o,s])=>s.length>0&&e.has(o)).map(([o,s])=>({id:o,segments:s,kept:n?.get(o)?.placeholder===!0})).sort((o,s)=>o.kept===s.kept?e.get(s.id)-e.get(o.id)||Q(o.id,s.id):o.kept?-1:1))}var Ze=Array.from({length:15},(t,e)=>(e+1)/16).sort((t,e)=>Math.abs(t-.5)-Math.abs(e-.5)||t-e);function Je(t,e,n,o){let s=[0];for(let r=Ge;r<=e;r+=Ge)s.push(-r,r);return Array.from({length:o},(r,a)=>a+1).flatMap(r=>[1,-1].flatMap(a=>s.map(c=>({x:n.x+c,y:n.y+a*r*qt,distance:Math.hypot(c,r*qt)})))).sort((r,a)=>r.distance-a.distance).map(({x:r,y:a})=>({label:{...t,x:r,y:a,leader:n},box:Mt(e,r,a)}))}var Ge=8,Ro=2*F,Qe=(t,e)=>Math.hypot(t.x-e.x,t.y-e.y)<Ro,qt=2*F,tn=t=>Math.ceil(t/qt);function Tr({x:t,y:e,leader:n}){return n?en({x:t,y:e},n):void 0}function en({x:t,y:e},n){return{x1:t,y1:n.y>e?e+ot/2:e-ot/2,x2:n.x,y2:n.y}}function Ho(t,e){let{x1:n,y1:o}=en(t,e),s=Math.hypot(n-e.x,o-e.y),r=s>0?Math.min(1,F/s):1,a=e.x+(n-e.x)*r,c=e.y+(o-e.y)*r;return{x0:Math.min(n,a)-1,x1:Math.max(n,a)+1,y0:Math.min(o,c),y1:Math.max(o,c)}}function nn(t,e){let n=0,o=1/0,s=-1/0,r=0,a=!1;return t.forEach((c,i)=>{let f=t[i-1],l=f?xt(f,c,e):void 0,d=f?Math.hypot(c.x-f.x,c.y-f.y):0;l&&(o=Math.min(o,n+l[0]*d),s=n+l[1]*d),r+=l&&!a?1:0,a=!!l,n+=d}),r===1&&o>=Ft&&n-s>=Ft}function Br({nodePositions:t,nodeLengths:e,nodeById:n,alleleDeletions:o,pxPerBp:s=0,axis:r,translateX:a,translateY:c,width:i,height:f}){let{scaleX:l,scaleY:d}=r,p=new Set(o?.flatMap(y=>y.nodeIds)),u=[],m=({x:y,y:M})=>({x:y*l+a,y:M*d+c}),h={width:i,height:f},v=y=>m(it(t[y]??[],.5));for(let{id:y,segments:M,kept:S}of Bo(t,e,n)){let N=p.has(y)?[]:Ze.map(I=>m(it(M,I))).filter(I=>Ke(I,h)),g=e.get(y),x=N.length>0?G(M,l,d):0,b=S||g*s>=q,[k]=N;if(k&&(x>=qe||b)){let I={key:`node:${y}`,node:y,text:zt(g)},_=Gt(I.text),T=x>=qe?M.map(m):[],X=N.map(({x:O,y:w})=>({label:{...I,x:O,y:w},box:Mt(_,O,w)})).filter(({box:O})=>D(O,h)&&nn(T,O));(X.length>0||b)&&u.push({id:y,kept:S,middle:k,along:X,own:({node:O})=>O===y||O!==void 0&&(t[O]?.length??0)>0&&Qe(v(O),v(y)),stacked:b?()=>Je(I,_,k,S?tn(f):Co).filter(({box:O})=>D(O,h)):void 0})}}return u}var $o=H();function Rr(t){return $o(t.nodes,[t.paths],()=>{let e=new Map(t.nodes.map(a=>[a.id,a])),n=new Set,o=[];for(let a of t.paths??[]){let c=[],i=0,f=!0,l=!1;for(let d of a.nodeIds){let p=e.get(d);if(p&&R(p)){let u=c.join(" ");l&&f&&c.length>0&&!n.has(u)&&(n.add(u),o.push({nodes:c,bp:i})),l=!0,c=[],i=0,f=!0}else c.push(d),i+=p?.length??0,f&&=!!p&&!p.placeholder}}o.sort((a,c)=>c.bp-a.bp||Q(a.nodes[0]??"",c.nodes[0]??"")||c.nodes.length-a.nodes.length);let s=[],r=new Map;for(let a of o){let c=new Map;for(let l of new Set(a.nodes))for(let d of r.get(l)??[])c.set(d,(c.get(d)??0)+(e.get(l)?.length??0));let i;for(let[l,d]of c)i??=2*d>=s[l].bp?l:void 0;let f=i===void 0?void 0:s[i];if(f){f.least=Math.min(f.least,a.bp);for(let l of a.nodes)f.drawn.add(l)}else{for(let l of new Set(a.nodes))$(r,l,s.length);s.push({...a,least:a.bp,drawn:new Set(a.nodes)})}}return s})}function Yo(t,e){let n=zt(t),o=zt(e),[s,r]=n.split(" ");return n===o?o:r===o.split(" ")[1]?`${s}\u2013${o}`:`${n}\u2013${o}`}var nt=(t,e)=>Math.hypot(t.x-e.x,t.y-e.y),Ve=(t,e)=>Math.min(nt(t,e[0]??t),nt(t,e.at(-1)??t));function Wo(t,e){let n=t.map(a=>e[a]??[]),o=[],s=[],r=0;return n.forEach((a,c)=>{let i=a[0],f=a.at(-1),l=n[c+1]??[],d=o.at(-1),p=i&&f?d?nt(d,f)<nt(d,i):l.length>0&&Ve(i,l)<Ve(f,l):!1;for(let u=0;u<a.length;u++){let m=a[p?a.length-1-u:u],h=o.at(-1);r+=h?nt(h,m):0,o.push(m)}s.push(r)}),n.every(a=>a.length>0)?{line:o,ends:s}:void 0}var Do=H(),je=()=>!1;function Fo(t,e){let n=0,o=!1,s=0;return t.forEach((r,a)=>{let c=t[a-1],i=c?xt(c,r,e):void 0;n+=i&&!o?1:0,o=!!i,s+=i&&c?(i[1]-i[0])*Math.hypot(r.x-c.x,r.y-c.y):0}),n===1&&s<=Math.hypot(e.x1-e.x0,e.y1-e.y0)}function Hr({loops:t,edges:e,nodePositions:n,folded:o,pxPerBp:s,ink:r,axis:a,translateX:c,translateY:i,width:f,height:l}){let{scaleX:d,scaleY:p}=a,u=Do(n,[t],()=>t.flatMap(M=>{let S=Wo(M.nodes,n);return S?[{loop:M,...S}]:[]})),m=({x:M,y:S})=>({x:M*d+c,y:S*p+i}),h={width:f,height:l},v=new Map,y=[];for(let{loop:M,line:S,ends:N}of u){let g=Yo(M.least,M.bp),x=Gt(g);if(M.bp*s>=q&&G(S,d,p)>=x*2/Xo&&!M.nodes.every(b=>o?.has(b))){let b=N.at(-1)??0,k=M.nodes[N.findIndex(E=>E>=b/2)]??M.nodes[0],I=`${M.nodes[0]}>${M.nodes.at(-1)}`,_=v.get(I)??0;v.set(I,_+1);let T={key:`loop:${I}${_?`#${_}`:""}`,node:k,text:g},{drawn:X}=M,O=({node:E,edge:C})=>E!==void 0?X.has(E):C!==void 0&&(X.has(e[C]?.from??"")||X.has(e[C]?.to??"")),w=S.map(m),L=r.widest(M.nodes),A=Ze.map(E=>m(it(S,E))).filter(E=>Ke(E,h)),B=A.map(({x:E,y:C})=>({label:{...T,x:E,y:C},box:Mt(x,E,C)})).filter(({box:E})=>D(E,h)&&nn(w,E)&&Fo(w,Ie(E,L))),[P]=A;P&&y.push({id:T.key,kept:!1,middle:P,along:B,own:O,stacked:()=>Je(T,x,P,tn(l)).filter(({box:E})=>D(E,h))})}}return y}function $r(t,e){return Math.max(Oo,Math.floor(t*e/No))}var zo=(t,e)=>Math.hypot(Math.max(0,t.x0-e.x1,e.x0-t.x1),Math.max(0,t.y0-e.y1,e.y0-t.y1));function Yr(t,e,{budget:n=1/0,placed:o=[],leaders:s=1/0,under:r=je}={}){let a=[],c=o.slice(),i=d=>c.some(({middle:p})=>Qe(p,d)),f=({label:d,box:p})=>c.every(u=>u.label.text!==d.text||zo(p,Mt(Gt(d.text),u.label.x,u.label.y))>=ot),l=0;for(let d of t)if((d.kept||c.length<n)&&!i(d.middle)){let p=m=>d.own(m)||m.exon!==void 0&&d.own({node:m.exon}),u=d.along.find(m=>f(m)&&!r(m.box,d.own)&&e(m.box))??(l<s?d.stacked?.().find(m=>{let h=Ho(m.label,d.middle);return f(m)&&!r(m.box,je)&&!r(h,p)&&e(m.box,h)}):void 0);if(u){let m={label:u.label,middle:d.middle};a.push(m),c.push(m),l+=u.label.leader?1:0}}return a}function Wr(t,e,n){let o=new Set(e.map(c=>c.node)),s=0,r=1/0,a=0;for(let{id:c,kept:i}of t)if(i&&!o.has(c)){let f=n.get(c);s++,r=Math.min(r,f),a=Math.max(a,f)}return s>0?{count:s,smallest:r,largest:a}:void 0}function Vr(t){let e=0;for(let n=0;n<t.length;n++)e=t.charCodeAt(n)+((e<<5)-e);return Math.abs(e%360)}function qo(t,e){return t*360/e}var Go=.7,Vo=.5,jo=16;function jr(t){return t>0&&t<=jo}function Ko(t,e){return`hsl(${qo(t,e)}, ${Go*100}%, ${Vo*100}%)`}function Kr(t,e){return`hsl(0, 0%, ${e>1?25+45*t/(e-1):45}%)`}function Uo(t){let e=J(t).name.split("#"),n=e.join("#");if(e.length>=3&&Qt(e[0])){let o=e.slice(2).join("#");return[o,o,n]}return[e[0],e.slice(0,2).join("#"),n]}function Zo(t,e){let{start:n}=J(t);return e.map(o=>`${o} @${Ue(n)}`)}function Ur(t,e){let n=new Map;t.forEach((l,d)=>{n.has(l.name)||n.set(l.name,d)});let o=[...n].map(([l,d])=>({name:l,i:d})),s=o.map(l=>Uo(l.name)),r=l=>o.map((d,p)=>s[p][l]),a=l=>o.map((d,p)=>Zo(d.name,s[p])[l]),c=[r(0),r(1),a(0),r(2),a(1),a(2)],f=c.find(l=>new Set(l).size===o.length)??c.at(-1);return o.map(({name:l,i:d},p)=>({name:l,label:f[p],color:e?.[d]??Ko(d,t.length)}))}function Zr(t){let e=new Map;return new Map([...t].sort((n,o)=>Q(n.label,o.label)).map(n=>{let o=(e.get(n.label)??0)+1;return e.set(n.label,o),[n.name,o>1?`${n.label} (${o})`:n.label]}))}var Qr=[{value:"uniform",label:"Uniform",description:"Every link the same thickness."},{value:"walks",label:"By walks",description:"Thicker the more walks take a link, on the square root of its count against the busiest link in the cut. A graph without walks draws uniform."}],on=.5,Jo=4;function ta(t){let e=0;for(let n of t.edges)e=Math.max(e,n.pathIds?.length??0);return e}function ea(t,e,n){return n==="uniform"||e===0?1:on+(Jo-on)*Math.sqrt(t/e)}var Qo=4;function ts(t){let e=new Map;for(let n of t.edges)$(e,n.from,n.to),$(e,n.to,n.from);return e}function es({nodeId:t,nodeById:e,neighbors:n}){let o=new Set([t]),s=[t],r=1/0,a=-1/0;for(let c=0;c<Qo&&s.length>0;c++){let i=[];for(let f of s){let l=n.get(f);if(l){for(let d of l)if(!o.has(d)){o.add(d);let p=e.get(d);p&&R(p)?(r=Math.min(r,p.stable.start+p.length),a=Math.max(a,p.stable.start)):i.push(d)}}}s=i}return r===1/0?void 0:{start:Math.min(r,a),end:Math.max(r,a)}}function ns({nodeId:t,nodeById:e,neighbors:n}){let o=e.get(t);return o===void 0?void 0:R(o)?{start:o.stable.start,end:o.stable.start+o.length}:es({nodeId:t,nodeById:e,neighbors:n})}function ra(t,e=ts(t)){let n=new Map(t.nodes.map(s=>[s.id,s])),o=new Map;for(let s of t.nodes){let r=ns({nodeId:s.id,nodeById:n,neighbors:e});r&&o.set(s.id,(r.start+r.end)/2)}return o}export{ts as a,ns as b,ra as c,qs as d,Gs as e,Rn as f,er as g,nr as h,Ee as i,or as j,hs as k,ps as l,ms as m,xs as n,ss as o,re as p,_t as q,rs as r,as as s,Et as t,dn as u,un as v,hn as w,cs as x,pe as y,H as z,q as A,Xs as B,Ts as C,Bs as D,Rs as E,Hs as F,ve as G,Xn as H,mt as I,yt as J,Ie as K,Tn as L,Ys as M,to as N,no as O,Oe as P,Xe as Q,vr as R,xt as S,Ao as T,wr as U,br as V,Eo as W,Cr as X,Xr as Y,Ue as Z,zt as _,Tr as $,Br as aa,Rr as ba,Yo as ca,Hr as da,$r as ea,Yr as fa,Wr as ga,Vr as ha,qo as ia,Go as ja,Vo as ka,jo as la,jr as ma,Ko as na,Kr as oa,Ur as pa,Zr as qa,Qr as ra,ta as sa,ea as ta};
2
- //# sourceMappingURL=chunk-4JYYNBSO.js.map
1
+ import{A as at,C as St,E as Jt,J as te,K as J,Q as ee,R as ne,a as $,b as wt,c as K,d as Y,g as W,h as Vt,i as U,ka as oe,m as Z,ma as se,n as st,na as Q,o as jt,p as bt,q as rt,r as G,s as Kt,t as Ut,u as Zt,x as R}from"./chunk-HYQOBARI.js";import{b as Qt,c as ct}from"./chunk-5PMRULDS.js";var ss=[{value:"depth",label:"By depth",description:"Thicker the more paths carry a node, on the square root of its depth against the mean. A graph with one depth everywhere draws uniform."},{value:"frequency",label:"By frequency",description:"As wide as the share of haplotypes that pass a node, or its AF tag: full width at 100%, half at 50%, and wider where a haplotype passes it more than once."},{value:"uniform",label:"Uniform",description:"Every node the same thickness."}],sn=.3,kt=3,rn=.05;function re(t){let e=0,n=0;for(let o of t.nodes)e+=o.depth*o.length,n+=o.length;return n>0?e/n:0}function It(t){return t.sample===void 0?ct(t.name)??t.name:`${t.sample}#${t.haplotype??0}`}function At(t){let e=new Map;for(let n of t.paths??[]){let o=It(n);e.has(o)||e.set(o,e.size)}return e}function an(t){return At(t).size}function cn(t,e){return t.frequency??(e>0?t.depth/e:void 0)}function _t(t,e){return e==="depth"?re(t):e==="frequency"?an(t):0}function ae(t){return Math.min(kt,Math.max(rn,t))}function fn(t,e){let n=cn(t,e);return n===void 0?1:ae(n)}function rs(t){return[1,.5,.1].map(e=>({label:`${e*100}%`,widthPx:t*ae(e)}))}function ce(t,e){return!(e>0)||!(t>0)?1:Math.min(kt,Math.max(sn,Math.sqrt(t/e)))}function as(t,e,n){let o=1/0,s=-1/0;for(let{id:a,depth:c}of t.nodes)(!n||n.has(a))&&(o=Math.min(o,c),s=Math.max(s,c));let r=re(t);return(o<s?[s,o]:o===s?[s]:[]).map(a=>({depth:a,widthPx:e*ce(a,r)}))}function Et(t,e,n,o){return e*(n==="depth"?ce(t.depth,o):n==="frequency"?fn(t,o):1)}function ln(t,e){return t*(e==="uniform"?1:kt)}var dn=4;function un(t,e){return Math.max(t/e,dn)}function hn(t,e,n){let o=[...t.from,...t.to].flatMap(s=>{let r=n(s);return r===void 0?[]:[r]});return o.length>0?o.reduce((s,r)=>Math.min(s,r),1/0):e}function cs(t,e,n,o,s=0,r){let a=t?_t(t,o):0,c=f=>s>0?un(f,s)*s/2:f/2,i=f=>{let l=e?.get(f);return l?Et(l,n,o,a):void 0};return{maxHalfWidthPx:c(ln(n,o)),halfWidthPx:f=>{let l=i(f)??n,d=r?.get(f);return c(d?hn(d,l,i):l)}}}function Nt(t){return t==="+"?"-":"+"}function hs(t,e=new Set){let n=t.edges.map(st),o=new Map,s=(u,m,h)=>{$(o,`${u}|${m}`,h)};t.edges.forEach((u,m)=>{s(u.from,n[m].from,m),s(u.to,n[m].to,m)});let r=u=>{let m=o.get(`${u}|end`);if(m?.length!==1)return;let h=m[0],v=t.edges[h];return v.from===u&&v.to!==u&&!e.has(u)&&!e.has(v.to)&&n[h].from==="end"&&n[h].to==="start"&&o.get(`${v.to}|start`)?.length===1?h:void 0},a=new Set,c=new Map,i=new Map;for(let u of t.nodes){let m=o.get(`${u.id}|start`),h=m?.length===1?t.edges[m[0]].from:void 0;if(c.has(u.id)||h!==void 0&&r(h)===m[0])continue;let v=[u.id];for(;;){let y=r(v.at(-1)),M=y===void 0?void 0:t.edges[y].to;if(M===void 0||c.has(M))break;a.add(y),v.push(M)}for(let y of v)c.set(y,u.id);v.length>1&&i.set(u.id,v)}for(let u of t.nodes)c.has(u.id)||c.set(u.id,u.id);let f=new Map(t.nodes.map(u=>[u.id,u])),l=[];for(let u of t.nodes){if(c.get(u.id)!==u.id)continue;let m=i.get(u.id);if(!m){l.push(u);continue}let h=m.map(M=>f.get(M)),v=h.filter(R),y=v.length?v.reduce((M,S)=>M.stable.start<=S.stable.start?M:S):h[0];l.push({id:u.id,name:u.name,length:h.reduce((M,S)=>M+S.length,0),depth:u.depth,stable:y.stable&&Z(y.id)!==Z(u.id)?{...y.stable,strand:Nt(y.stable.strand??"+")}:y.stable})}let d=new Set,p=[];return t.edges.forEach((u,m)=>{let h=c.get(u.from),v=c.get(u.to),y=n[m],M=`${h}|${y.from}>${v}|${y.to}`;a.has(m)||d.has(M)||(d.add(M),p.push({from:h,to:v,...y.from==="start"?{fromStrand:Nt(Z(h))}:{},...y.to==="end"?{toStrand:Nt(Z(v))}:{}}))}),{graph:{...t,nodes:l,edges:p,paths:void 0,pathVisits:void 0},runs:i}}function ps(t,e,n){let o={...t};for(let[s,r]of e){let a=t[s];if(!a?.length)continue;delete o[s];let c=Lt(a),i=c.at(-1),f=r.map(p=>Math.max(n(p),0)),l=f.reduce((p,u)=>p+u,0),d=0;r.forEach((p,u)=>{let m=l?f[u]/l*i:i/r.length,h=u===r.length-1?i:d+m;o[p]=fe(a,c,d,h),d=h})}return o}function ms(t,e,n){if(t.length===0)return[];let o=Lt(t),s=o.at(-1);return fe(t,o,e*s,n*s)}function it(t,e){let n=Lt(t);return t.length===0?{x:Number.NaN,y:Number.NaN}:Ot(t,n,n.at(-1)*e)}function Lt(t){let e=[0];for(let n=1;n<t.length;n++)e.push(e[n-1]+Math.hypot(t[n].x-t[n-1].x,t[n].y-t[n-1].y));return e}var ie=(t,e)=>Y(t.length,n=>t[n]<e);function Ot(t,e,n){if(n<=0)return{...t[0]};let o=ie(e,n);if(o>=e.length)return{...t.at(-1)};let s=e[o]-e[o-1],r=s>0?(n-e[o-1])/s:0,a=t[o-1],c=t[o];return{x:a.x+(c.x-a.x)*r,y:a.y+(c.y-a.y)*r}}function fe(t,e,n,o){let s=[Ot(t,e,n)];for(let r=ie(e,n);r<t.length&&e[r]<o;r++)e[r]>n&&s.push({...t[r]});return s.push(Ot(t,e,o)),s}var le=[.1834346424956498,.525532409916329,.7966664774136267,.9602898564975363],pn=[.362683783378362,.3137066458778873,.2223810344533745,.1012285362903763],mn=1e-10,yn=40;function gn(t,e,n){let o=3*(t.cx0-t.x0)*e,s=3*(t.cx1-t.cx0)*e,r=3*(t.x1-t.cx1)*e,a=3*(t.cy0-t.y0)*n,c=3*(t.cy1-t.cy0)*n,i=3*(t.y1-t.cy1)*n;return f=>{let l=1-f,d=l*l,p=2*l*f,u=f*f;return Math.hypot(d*o+p*s+u*r,d*a+p*c+u*i)}}function Pt(t,e,n){let o=(n-e)/2,s=(e+n)/2,r=0;for(let a=0;a<le.length;a++){let c=o*le[a];r+=pn[a]*(t(s-c)+t(s+c))}return r*o}function Ct(t,e,n,o,s,r){let a=(e+n)/2,c=Pt(t,e,a),i=Pt(t,a,n);return r>=yn||!(Math.abs(c+i-o)>s)?c+i:Ct(t,e,a,c,s/2,r+1)+Ct(t,a,n,i,s/2,r+1)}function de(t,e,n){let o=(a,c,i,f)=>Math.hypot((i-a)*e,(f-c)*n),s=o(t.x0,t.y0,t.cx0,t.cy0)+o(t.cx0,t.cy0,t.cx1,t.cy1)+o(t.cx1,t.cy1,t.x1,t.y1),r=gn(t,e,n);return Ct(r,0,1,Pt(r,0,1),mn*s,0)}var xn=1e-6,ft=100;function xs(t){return Math.max(xn,Math.min(ft,t))}var V=(t,e)=>{let n=Math.max(0,t),o=Math.min(1,e);return n<=o?[n,o]:void 0};function ue(t,e,n,o){return e===0?t>=n&&t<=o?V(0,1):void 0:V(Math.min((n-t)/e,(o-t)/e),Math.max((n-t)/e,(o-t)/e))}var Mn=(t,e)=>t&&e?V(Math.max(t[0],e[0]),Math.min(t[1],e[1])):void 0;function lt(t,e,n,o){let s=e.x-t.x,r=e.y-t.y,a=t.x-n.x,c=t.y-n.y,i=s*s+r*r,f=2*(a*s+c*r),l=a*a+c*c-o*o,d=f*f-4*i*l;return i===0?l<=0?V(0,1):void 0:d<0?void 0:V((-f-Math.sqrt(d))/(2*i),(-f+Math.sqrt(d))/(2*i))}function vn(t,e,n,o,s){let r=Math.hypot(o.x-n.x,o.y-n.y),a=r>0?(o.x-n.x)/r:0,c=r>0?(o.y-n.y)/r:0,i=t.x-n.x,f=t.y-n.y,l=e.x-t.x,d=e.y-t.y,p=r>0?Mn(ue(i*a+f*c,l*a+d*c,0,r),ue(i*c-f*a,l*c-d*a,-s,s)):void 0,u=[lt(t,e,n,s),lt(t,e,o,s),p].filter(m=>m!==void 0);return u.length>0?V(u.reduce((m,h)=>Math.min(m,h[0]),1),u.reduce((m,h)=>Math.max(m,h[1]),0)):void 0}var he=1e-9;function Xt(t,e,n,o=0){let s=n.halfWidth-o,r=[];for(let c of n.lines){for(let f=1;f<c.length;f++){let l=vn(t,e,c[f-1],c[f],s);l&&r.push(l)}let i=c.length===1?lt(t,e,c[0],s):void 0;i&&r.push(i)}for(let c of n.points){let i=lt(t,e,c,s);i&&r.push(i)}r.sort((c,i)=>c[0]-i[0]);let a=0;for(let[c,i]of r)a=c<=a+he?Math.max(a,i):a;return s>=0&&a>=1-he}var Tt=(t,e)=>Xt(t,t,e);function pe(t,e,n,o){let s={x0:t.x0*e,y0:t.y0*n,cx0:t.cx0*e,cy0:t.cy0*n,cx1:t.cx1*e,cy1:t.cy1*n,x1:t.x1*e,y1:t.y1*n},r=Math.max(Math.hypot(s.x0-2*s.cx0+s.cx1,s.y0-2*s.cy0+s.cy1),Math.hypot(s.cx0-2*s.cx1+s.x1,s.cy0-2*s.cy1+s.y1)),a=Math.max(1,Math.ceil(Math.sqrt(.75*r/o)));return Array.from({length:Number.isFinite(a)?a+1:0},(c,i)=>W(s,i/a))}function H(){let t=new WeakMap;return(e,n,o)=>{let s=t.get(e);if(s?.deps.length===n.length&&s.deps.every((a,c)=>Object.is(a,n[c])))return s.value;let r=o();return t.set(e,{deps:n,value:r}),r}}var q=3,me=.01;function Xs(t){let e=new Set(t.collapsed?.nodes);for(let n of t.laneOnly?.nodes??[])e.add(n);return e}var Ts={sites:[],nodes:new Set,edges:new Set,siteOf:new Map,pxPerBp:0,within:new Map,through:new Map,bridges:new Map,runOf:new Map},z=t=>!!t&&R(t)&&!t.placeholder,dt=(t,e)=>t.stable.start+(at(t,e)?t.length:0),Bt=(t,e)=>t.stable.start+(at(t,e)?0:t.length),ye=(t,e,n)=>n===at(t,e)?"end":"start";function wn(t){let e=At(t),n=new Map,o=new Map;for(let r of t.paths??[]){let a=e.get(It(r))??0;n.set(r.name,a);for(let c of r.nodeIds)wt(o,c,a)}let s=r=>n.get(r)??e.get(ct(r)??r);for(let r of t.nodes)for(let{path:a}of r.departureVisits??[]){let c=s(a);c!==void 0&&wt(o,r.id,c)}return{total:e.size,byNode:o,walkNamed:s}}function bn(t,e,n){let o=new Map(t.nodes.map(g=>[g.id,g])),{total:s,byNode:r,walkNamed:a}=wn(t),c=new Map;for(let g of t.nodes)R(g)||c.set(g.id,g.id);let i=g=>{let x=g,b=c.get(x);for(;b!==void 0&&b!==x;)x=b,b=c.get(x);let k=g;for(;k!==x;){let I=c.get(k)??x;c.set(k,x),k=I}return x},f=g=>c.has(g);for(let{from:g,to:x}of t.edges)f(g)&&f(x)&&c.set(i(g),i(x));let l=new Map,d=g=>{let x=i(g),b=l.get(x),k=b??{nodes:[],edges:[],feet:[],attachments:[],ends:new Set,refNames:new Set,walks:[],bp:0,skip:void 0,tail:!1,tied:!1};return b||l.set(x,k),k};for(let g of t.nodes)if(f(g.id)){let x=d(g.id);x.nodes.push(g.id),x.bp+=g.length}let p=[],u=new Map;t.edges.forEach(({from:g,to:x,fromStrand:b,toStrand:k,pathIds:I},_)=>{let T=f(g)?g:f(x)?x:void 0,X=f(g)?x:g,O=o.get(X),w=o.get(g),L=o.get(x);if(T!==void 0){let A=d(T);A.edges.push(_),f(X)||(z(O)?(A.feet.push({edge:_,atEnd:X===x}),A.refNames.add(O.stable.refName),A.attachments.push(X===g?dt(O,b):Bt(O,k)),A.ends.add(X===g?ye(O,b,!0):ye(O,k,!1))):A.tied=!0)}else if(z(w)&&z(L)&&w.stable.refName===L.stable.refName&&dt(w,b)===Bt(L,k)){let A=u.get(w.stable.refName)??[];A.push({edge:_,at:dt(w,b)}),u.set(w.stable.refName,A)}else if(e?.has(_)&&!n?.has(_)&&z(w)&&z(L)){let A=new Set;for(let B of I??[]){let P=a(B);P!==void 0&&A.add(P)}if(A.size>0){let B=[dt(w,b),Bt(L,k)];p.push({nodes:[],edges:[_],feet:[{edge:_,atEnd:!1},{edge:_,atEnd:!0}],attachments:B,refNames:new Set([w.stable.refName,L.stable.refName]),walks:[...A],bp:ge(B),skip:_,tail:!1})}}});let m=[...p],h=oe(t);for(let{tied:g,ends:x,...b}of l.values()){let k=new Set;for(let _ of b.nodes)for(let T of r.get(_)??[])k.add(T);let I=b.nodes.some(_=>h.has(_));!g&&(x.size===2||b.feet.length===1)&&(!I||b.nodes.every(_=>o.get(_)?.placeholder))&&k.size>0&&m.push({...b,bp:b.bp+ge(b.attachments),walks:[...k],tail:I})}let v=t.nodes.filter(z),y=new Map,M=g=>{let x=y.get(g),b=x??{spans:[],links:[],endingAt:new Map,startingAt:new Map};return x||y.set(g,b),b};for(let g of v){let{refName:x,start:b}=g.stable,k=M(x),I=b+g.length;k.spans.push({id:g.id,start:b,end:I}),$(k.endingAt,I,g.id),$(k.startingAt,b,g.id)}for(let[g,x]of u)M(g).links=x;for(let g of y.values())g.spans.sort((x,b)=>x.start-b.start),g.links.sort((x,b)=>x.at-b.at);let S=g=>g.nodes[0]??`#${g.skip}`;return{units:m.map(g=>({unit:g,start:tt(g.attachments),key:S(g)})).sort((g,x)=>g.start!==x.start?g.start-x.start:g.key<x.key?-1:g.key>x.key?1:0).map(({unit:g})=>g),total:s,backbone:v.map(g=>g.id),backboneBp:v.reduce((g,x)=>g+x.length,0),references:y}}function pt(t,e,n){let o=[];for(let s=Y(t.length,r=>t[r].start<e);s<t.length&&t[s].start<n;s++){let r=t[s];r.end<=n&&r.end>r.start&&o.push(r)}return o}function Sn(t,e){let n=new Map;for(let o of t){let s=e.get(o.refName)?.spans??[];for(let r of pt(s,o.start,o.end))n.set(r.id,o)}return n}function kn(t,e){let n=new Map,o=new Map,s=new Map,r=t.toSorted((c,i)=>c.refName!==i.refName?c.refName<i.refName?-1:1:c.start-i.start),a=0;for(;a<r.length;){let{refName:c}=r[a],{start:i}=r[a],{end:f}=r[a],l=a;for(a++;a<r.length&&r[a].refName===c&&r[a].start<=f;)f=Math.max(f,r[a].end),a++;let d=e.get(c);if(d){let p=pt(d.spans,i,f),u={start:i,end:f,from:d.endingAt.get(i)??[],to:d.startingAt.get(f)??[]};for(let h of p)n.set(h.id,u);for(let h of r.slice(l,a))s.set(h,u);let{links:m}=d;for(let h=Y(m.length,v=>m[v].at<i);h<m.length&&m[h].at<=f;h++)o.set(m[h].edge,{run:u,at:m[h].at})}}return{nodes:n,bridges:o,runOf:s}}var tt=t=>t.reduce((e,n)=>Math.min(e,n),1/0),ht=t=>t.reduce((e,n)=>Math.max(e,n),-1/0),ge=t=>t.length>0?ht(t)-tt(t):0,In=H();function An(t,{edge:e,atEnd:n}){let o=t.get(e),s=o?.[0],r=o?.at(-1);return!s||!r?void 0:n?{x:r.x1,y:r.y1}:{x:s.x0,y:s.y0}}var _n=t=>({x:t.reduce((e,n)=>e+n.x,0)/t.length,y:t.reduce((e,n)=>e+n.y,0)/t.length}),En=(t,e)=>t.reduce((n,o)=>n+de(o,e.scaleX,e.scaleY),0);function Nn(t,e){let n=t[0],o=t.at(-1);return n&&o?Math.hypot((o.x1-n.x0)*e.scaleX,(o.y1-n.y0)*e.scaleY):0}function xe(t,e,n,o){let s=tt(t.attachments),r=ht(t.attachments),a=e?.links??[],c=0;for(let i of t.nodes)c+=n(i);for(let i of t.edges)c+=o(i);for(let i of e?pt(e.spans,s,r):[])c+=n(i.id);for(let i=Y(a.length,f=>a[f].at<s);i<a.length&&a[i].at<=r;i++)c+=o(a[i].edge);return c}function Me(t){let e=new Map;return n=>{let o=e.get(n),s=o??t(n);return o===void 0&&e.set(n,s),s}}function Rt(t,e,n,o){let s=t.reduce((r,a)=>r+G(n[a]??[],o.scaleX,o.scaleY),0);return e>0?s/e:0}var On=H();function Bs(t,e,n,o=0){return On(e,[t,n.scaleX,n.scaleY,o],()=>{let s=t.filter(z);return Rt(s.map(r=>r.id),s.reduce((r,a)=>r+a.length,0),e,n)})}var ut=(t,e)=>({x:t.x*e.scaleX,y:t.y*e.scaleY});function Ln(t,e,n,o,s){let r=t.nodes.map(c=>(n[c]??[]).map(i=>ut(i,s))),a=(c,i)=>c.every((f,l)=>l===0||Xt(c[l-1],f,e,i));return r.every(c=>c.every(i=>Tt(i,e)))&&r.every(c=>a(c,0))&&t.edges.every(c=>(o.get(c)??[]).every(i=>a(pe(i,s.scaleX,s.scaleY,me),me)))}function Pn(t,e,n,o,s,r,a){let{units:c,total:i,backbone:f,backboneBp:l,references:d}=In(t,[s,r],()=>bn(t,s,r)),p=Rt(f,l,e,n),u={...n,scaleX:ft,scaleY:n.pixelRows?n.scaleY:ft},m=Rt(f,l,e,u),h=new Set(t.nodes.flatMap(w=>w.placeholder?[w.id]:[])),v=(w,L)=>({node:Me(A=>G(e[A]??[],w.scaleX,w.scaleY)),edge:Me(A=>L(o.get(A)??[],w))}),y=v(n,En),M=v(u,Nn),S=(w,L)=>{let A=d.get(L),B=xe(w,A,y.node,y.edge),P=xe(w,A,M.node,M.edge),E=w.nodes.some(C=>h.has(C))&&p>0;return w.tail?{shown:w.bp*p,back:w.bp*m}:{shown:E?Math.min(B,w.bp*p):B,back:E?Math.min(P,w.bp*m):P}},N=new Map(t.nodes.map(w=>[w.id,w])),g=_t(t,a.nodeWidth),x=w=>{let L=N.get(w);return L?Et(L,a.contigThickness,a.nodeWidth,g)/2:0},b=(w,L,A,B)=>{let P=L?pt(L.spans,tt(w.attachments),ht(w.attachments)).map(C=>C.id):[],E=w.feet.flatMap(({edge:C,atEnd:j})=>{let vt=t.edges[C];return vt?[j?vt.to:vt.from]:[]});return{lines:P.map(C=>(e[C]??[]).map(j=>ut(j,B))),points:A.map(C=>ut(C,B)),halfWidth:[...P,...E].reduce((C,j)=>Math.min(C,x(j)),1/0)}},k=(w,L,A)=>{let B=()=>{let P=b(w,L,A,u);return w.nodes.some(E=>(e[E]??[]).some(C=>!Tt(ut(C,u),P)))};return w.nodes.length>0&&w.bp*p<q&&w.bp*m>=q&&Ln(w,b(w,L,A,n),e,o,n)&&B()},I=new Set,_=new Set,T=new Map,X=[];for(let w of c){let L=w.feet.flatMap(P=>{let E=An(o,P);return E?[E]:[]}),[A]=w.refNames,B=A!==void 0&&w.refNames.size===1&&w.bp>0&&L.length===w.feet.length&&w.nodes.every(P=>e[P]?.length)?S(w,A):void 0;if(A!==void 0&&B&&B.back>=q&&(B.shown<q||k(w,d.get(A),L))){let P={nodes:w.nodes,edges:w.edges,refName:A,start:tt(w.attachments),end:ht(w.attachments),bp:w.bp,..._n(L),count:w.walks.length,total:i};X.push(P);for(let E of w.nodes)I.add(E),T.set(E,P);for(let E of w.edges)_.add(E)}}let O=kn(X,d);return{sites:X,nodes:I,edges:_,siteOf:T,pxPerBp:p,within:Sn(X,d),through:O.nodes,bridges:O.bridges,runOf:O.runOf}}var Cn=H(),Rs=t=>t.sites.reduce((e,n)=>Math.max(e,n.bp+1),0);function Hs(t,e,n,o,s,r,a){return Cn(o,[t,e,s,r,a.contigThickness,a.nodeWidth],()=>Pn(t,e,n,o,s,r,a))}var ve=11,Xn=6.2,mt=4;function yt(t){return t.length*Xn+mt*2}function Se(t,e){return t.x0<e.x1&&t.x1>e.x0&&t.y0<e.y1&&t.y1>e.y0}function ke(t,e){return t.x1<=0||t.x0>=e.width||t.y1<=0||t.y0>=e.height}function D(t,e){return t.x0>=0&&t.x1<=e.width&&t.y0>=0&&t.y1<=e.height}function Ie(t,e){return{x0:t.x0-e,x1:t.x1+e,y0:t.y0-e,y1:t.y1+e}}function Tn(t,e=[]){let n=[...e];return(o,s)=>{let r=s?[o,s]:[o];if(ke(o,t)||n.some(a=>r.some(c=>Se(a,c))))return!1;for(let a of r)n.push(a);return!0}}var we=8;function be(t){let e=[0];for(let n=we;n<t;n+=we)e.push(-n,n);return t>0&&e.push(-t,t),e}function Ys(t,e,n,o=[],s=0){let r=[],a=0,c=ve+mt*2,i=(h,v,y)=>({x0:h-y/2,x1:h+y/2,y0:v-ve-mt,y1:v+mt}),f=(h,v,y,M)=>{let S=yt(v),N=[];for(let x=0;x<=(h.stack??0);x++){let b=y+M*x*c;if(ke(i(h.x,b,S),e))break;for(let k of be(h.slide??0))N.push({dx:k,y:b,distance:Math.hypot(k,x*c)})}N.sort((x,b)=>x.distance-b.distance);let g=!1;for(let{dx:x,y:b}of N){let k=i(h.x+x,b,S);if(D(k,e)&&(h.fits?.(k)??!0)){if(n(k))return{placed:{...h,x:h.x+x,text:v,y:b,w:S},crowded:g};g||=!o.some(I=>Se(I,k))}}return{placed:void 0,crowded:g}},l=(h,v)=>{let y=f(h,v,h.y,h.y>e.height/2?-1:1);return y.placed||h.flipY===void 0||y.crowded?y:f(h,v,h.flipY,h.flipY<h.y?-1:1)},d=Math.ceil(e.height/c),p=h=>{let v=[];for(let y=-d;y<=d;y++)for(let M of be(h))v.push({dx:M,dy:y*c,distance:Math.hypot(M,y*c)});return v.sort((y,M)=>y.distance-M.distance)},u,m=(h,v,y)=>{let M=yt(v),S=D({x0:y.x,x1:y.x,y0:y.y,y1:y.y},e)?u??=p(e.width):p(h.slide??0),N=x=>{let b;for(let k=0;k<S.length&&!b;k++){let I=y.x+S[k].dx,_=y.y+S[k].dy,T=i(I,_,M);b=D(T,e)&&x(T)?{x:I,y:_}:void 0}return b},g=N(x=>(h.fits?.(x)??!0)&&n(x))??N(n);return g&&{...h,x:g.x,y:g.y,text:v,w:M}};for(let h of t){let v=l(h,h.text),y=v.placed||h.fallback===void 0?void 0:l(h,h.fallback),M=v.placed??y?.placed,S=v.crowded||y?.crowded===!0,N=M||h.nearest===void 0||S&&a>=s?void 0:m(h,h.text,h.nearest);N&&a++;let g=M??N;g&&r.push(g)}return r}function qs(t,e){let n=new Set(t.nodes.filter(i=>R(i)&&St(i,e)).map(i=>i.id)),o=t.paths??[];if(n.size===0||o.length===0)return t;let s=o.map(i=>{let f=-1,l=-1;return i.nodeIds.forEach((d,p)=>{n.has(d)&&(f<0&&(f=p),l=p)}),f<0?void 0:{first:f,last:l}});if(s.every((i,f)=>i?.first===0&&i.last===o[f].nodeIds.length-1))return t;let r=new Set,a=[],c=new Map;return o.forEach((i,f)=>{let l=s[f];if(l){let d=i.nodeIds.slice(l.first,l.last+1);for(let p of d)r.add(p);a.push({...i,nodeIds:d,...i.refStarts?{refStarts:i.refStarts.subarray(l.first,l.last+1)}:{}}),c.set(i.name,{first:l.first,nodeIds:d})}}),{...t,nodes:t.nodes.filter(i=>r.has(i.id)),edges:t.edges.filter(i=>r.has(i.from)&&r.has(i.to)),paths:a,pathVisits:t.pathVisits&&Bn(t.pathVisits,o,s,new Map(t.nodes.map(i=>[i.id,i.name]))),anchorPaths:ee(t,c)}}function Bn(t,e,n,o){let s=t.replay(),r=new te;return e.forEach((a,c)=>{let i=t.pathIndex(J(a.name).name),f=n[c];a.nodeIds.forEach((l,d)=>{let p=o.get(l)??l,u=s(t.slot(p),i);u>=0&&f&&d>=f.first&&d<=f.last&&r.add(p,t.paths[i],t.samples[i],t.start[u],t.reversed[u]===1)})}),r.build()}function Gs(t,e,n){let o=t.nodes.map(s=>{if(!R(s))return s;let r=s.stable.start,a=r+s.length,[c,i]=St(s,e)?[Math.max(r,e.start),Math.min(a,e.end)]:a<=e.start?[Math.max(r,a-n),a]:[r,Math.min(a,r+n)];return c===r&&i===a?s:{...s,length:i-c,stable:{...s.stable,start:c},unclipped:{start:r,length:s.length}}});return o.some((s,r)=>s!==t.nodes[r])?{...t,nodes:o}:t}function Ae(t){return t.nodes.some(e=>e.unclipped)?{...t,nodes:t.nodes.map(({unclipped:e,...n})=>e&&n.stable?{...n,length:e.length,stable:{...n.stable,start:e.start}}:n)}:t}var Rn=1,er=t=>`skips ${t??"the reference"} sequence`,nr="short skip";function Hn(t,e){return e.flatMap(n=>t[n]??[])}function Ht(t,e,n,o,s,r){let a=t[e.from],c=t[e.to];if(!(!a?.length||!c?.length))return s?Zt(a,c,s,r?st(e):void 0):Ut(a,c,Kt(e,r),n,o?Hn(t,o):[])}function $n(t){let e=K(t.nodes.filter(R),n=>n.stable.refName);for(let n of e.values())n.sort((o,s)=>o.stable.start-s.stable.start);return e}function Yn(t,e,n){let o=[];if(t)for(let s=Jt(t,e);s<t.length;s++){let r=t[s];if(r.stable.start>=n)break;r.stable.start+r.length<=n&&o.push(r.id)}return o}function Wn(t,e,n,o){let{fromStrand:s,toStrand:r}=t;if(s===void 0||r===void 0)return!0;let a=s===e.strand,c=r===n.strand;return o?a&&c:!a&&!c}function Dn(t,e,n,o){let s;for(let[r,a]of o){let c=r.start<=a.start,i=c?{start:r.start+e.length,end:a.start}:{start:a.start+n.length,end:r.start};Wn(t,r,a,c)&&(!s||Math.abs(i.end-i.start)<Math.abs(s.end-s.start))&&(s=i)}return s}function Fn(t,e,n){return n(t).flatMap(o=>n(e).map(s=>[o,s]))}function zn(t){let{pathVisits:e}=t;return(n,o)=>{let s;if(e){let r=e.pathIndex(n.stable.refName),a=e.slot(n.name);if(a>=0&&r>=0)for(let c=e.offsets[a];c<e.offsets[a+1]&&!s;c++)e.path[c]===r&&e.start[c]===o&&(s={start:o,strand:e.strand(c)})}return s}}function qn(t,e){let n=new Map;for(let r of e){let{from:a,to:c}=t.edges[r],i=n.get(a);i||(i=new Map,n.set(a,i)),$(i,c,r)}let o=new Map,s=(r,a,c)=>{let i=o.get(r);if(i||(i=[],o.set(r,i)),!Number.isNaN(a)&&!Number.isNaN(c)){let f=!1;for(let l=0;l<i.length&&!f;l+=2)f=i[l]===a&&i[l+1]===c;f||i.push(a,c)}};for(let{nodeIds:r,refStarts:a}of t.paths??[])if(a)for(let c=1;c<r.length;c++){let i=r[c-1],f=r[c];for(let l of n.get(i)?.get(f)??[])s(l,a[c-1],a[c]);for(let l of n.get(f)?.get(i)??[])s(l,a[c],a[c-1])}return o}function Gn(t,e,n,o){let s=[];for(let r=0;r<n.length;r+=2){let a=o(t,n[r]),c=o(e,n[r+1]);a&&c&&s.push([a,c])}return s}var Vn=.01;function jn(t,e){let n=new Map;for(let[o,s]of t){let r=s.flatMap(a=>{let c=e(a).map(i=>i.start);return c.slice(1).map((i,f)=>({at:c[f],copy:i-c[f]}))});r.length&&n.set(o,r.sort((a,c)=>a.at-c.at))}return n}function Kn(t,e,n){if(!t)return!1;let o=Y(t.length,r=>t[r].at<e),s=[t[o-1],t[o]].filter(r=>r!==void 0).sort((r,a)=>Math.abs(r.at-e)-Math.abs(a.at-e))[0];return s!==void 0&&Math.abs(s.at-e)<=s.copy&&Math.abs(n-s.copy)<=s.copy*Vn}function Un(t){let e=Ae(t),n=new Map(e.nodes.map(l=>[l.id,l])),o=$n(e),s=ne(e),r=e.edges.flatMap((l,d)=>{let p=n.get(l.from),u=n.get(l.to);return!l.foldBridge&&p!==void 0&&u!==void 0&&R(p)&&R(u)&&p.stable.refName===u.stable.refName?[{edgeIndex:d,edge:l,from:p,to:u}]:[]}),c=e.paths!==void 0&&e.paths.length>0&&e.paths.every(l=>l.refStarts)?qn(e,r.map(l=>l.edgeIndex)):new Map,i=zn(e);return{links:r.map(({edgeIndex:l,edge:d,from:p,to:u})=>{let m=c.get(l);return{edgeIndex:l,edge:d,refName:p.stable.refName,span:Dn(d,p,u,m?Gn(p,u,m,i):Fn(p,u,s))}}),backbone:o,copies:jn(o,s)}}function Ee(t){let{links:e,backbone:n,copies:o}=Un(t);return e.flatMap(({edgeIndex:s,edge:r,refName:a,span:c})=>{let i=c?c.end-c.start:0;return c&&i>=Rn&&!Kn(o.get(a),c.start,i)?[{edgeIndex:s,from:r.from,to:r.to,...r.fromStrand?{fromStrand:r.fromStrand}:{},...r.toStrand?{toStrand:r.toStrand}:{},refName:a,start:c.start,end:c.end,bp:i,bypassed:Yn(n.get(a),c.start,c.end)}]:[]})}function Zn(t,e){let n=new Map,o=a=>{let c=a;for(;n.has(c);)c=n.get(c);return c!==a&&n.set(a,c),c},s=(a,c)=>{let[i,f]=[o(a),o(c)];return i!==f&&n.set(i,f),i!==f},r=new Set(e);return t.edges.forEach((a,c)=>{r.has(c)||s(a.from,a.to)}),new Set(se(e.map(a=>({...t.edges[a],ei:a}))).filter(a=>!s(a.from,a.to)).map(({ei:a})=>a))}var _e=new WeakMap;function or(t,e,n=!0){let o=_e.get(e);o||(o=new Map,_e.set(e,o));let s=o.get(n);if(!s){let r=n?new Set:Zn(t,e.map(a=>a.edgeIndex));s={shown:e.filter(a=>!r.has(a.edgeIndex)),bypassed:new Map(e.map(a=>[a.edgeIndex,a.bypassed])),hidden:r},o.set(n,s)}return s}var Jn=class extends Map{constructor(){super(...arguments),this.arcs=new Set}},Qn=1,to=11,eo=3*to,no=t=>t>=eo,$t=5,Pe=8,oo=64,Yt=-1,Ce=12,Ne=16,so=Ce+$t;function ro(t,e,n,o){let s=l=>({x:l.x*o.scaleX,y:l.y*o.scaleY}),r=t[0],a=t.at(-1),c=[s({x:r.x0,y:r.y0}),...e.flatMap(l=>(n[l]??[]).map(s)),s({x:a.x1,y:a.y1})],i=0,f=0;for(let l of t)for(let d=0;d<=Ne;d++){let p=s(W(l,d/Ne)),u=!1;for(let m=1;m<c.length&&!u;m++){let h=c[m-1],v=c[m];u=U(p.x,p.y,h.x,h.y,v.x,v.y)<=Ce}f++,i+=u?1:0}return i*2>f}function ao(t,e,n,o){let{ax:s,ay:r,ux:a,uy:c}=gt(t,o),i=0;for(let f of e)for(let l of n[f]??[]){let d=(l.y*o.scaleY-r)*a-(l.x*o.scaleX-s)*c;i=Math.abs(d)>Math.abs(i)?d:i}return Math.abs(i)>=1?-Math.sign(i):Math.sign(Wt(t,o,Pe))||Yt}function Oe(t,e){return gt(t,e).length}var co=H();function Xe(t,e,n,o,s,r,a=!1){return co(t,[e,n.scaleX,n.scaleY,!!n.pixelRows,o,r,a,s],()=>{let c=new Jn;for(let i=0;i<e.edges.length;i++){let f=e.edges[i],l=o?.get(i),d=r?.[i],p=l?Ht(t,f,n,l,d,a):void 0,u=l&&d&&p&&no(Oe(p,n))&&ro(p,l,t,n)?Le(p,n,so*ao(p,l,t,n)):p,m=u!==void 0&&Oe(u,n)>=Qn,h=m?u:Ht(t,f,n,void 0,void 0,a);h&&(c.set(i,h),m&&c.arcs.add(i))}if(o){let i=new Map(e.nodes.map(y=>[y.id,y])),{spans:f,levels:l,alone:d}=io(o,[e],()=>fo(Ee(e).filter(y=>o.has(y.edgeIndex)))),p=y=>l.get(y)??1,u=new Map(Array.from(c.arcs,y=>[y,lo(c.get(y),n)])),m=new Map;for(let y of u.values())m.set(y,(m.get(y)??0)+1);let h=new Map,v=new Map;for(let y of Array.from(c.arcs).sort((M,S)=>p(M)-p(S)||M-S)){let M=u.get(y),S=Math.max(p(y),(h.get(M)??0)+1);h.set(M,S),v.set(y,S*$t)}Te(f.filter(y=>c.arcs.has(y.edgeIndex)),(y,M)=>{let S=y.edgeIndex,N=e.edges[S],g=c.get(S),x=Math.max(v.get(S),M>0?M+$t:0),b=Wt(g,n,Pe),I=(!d.has(S)||m.get(u.get(S))>1)&&Math.abs(b)<x;if(I){let _=i.get(N.from)?.stable?.start??0,T=i.get(N.to)?.stable?.start??0,X=r?.[S]?_<=T?Yt:-Yt:Math.sign(b)||1;c.set(S,Le(g,n,x*X))}return I?x:Math.abs(Wt(g,n,oo))})}return c})}var io=H();function Te(t,e){for(let n of K(t,o=>o.refName).values()){let o=Array.from(new Set(n.map(r=>r.start))).sort((r,a)=>a-r),s=new Array(o.length+1).fill(0);for(let r of n.toSorted((a,c)=>a.end-c.end||c.start-a.start||a.edgeIndex-c.edgeIndex)){let a=Y(o.length,f=>o[f]>r.start)+1,c=0;for(let f=a;f>0;f-=f&-f)c=Math.max(c,s[f]);let i=e(r,c);for(let f=a;f<=o.length;f+=f&-f)s[f]=Math.max(s[f],i)}}}function fo(t){let e=new Map;Te(t,(o,s)=>(e.set(o.edgeIndex,s+1),s+1));let n=new Set;for(let o of K(t,s=>s.refName).values()){let s;for(let r of o.toSorted((a,c)=>a.start-c.start))s&&r.start<s.end&&(n.add(r.edgeIndex),n.add(s.edgeIndex)),s=s&&s.end>=r.end?s:r}return{spans:t,levels:e,alone:new Set(t.flatMap(o=>n.has(o.edgeIndex)?[]:[o.edgeIndex]))}}function lo(t,e){let n=t[0],o=t.at(-1);return[`${Math.round(n.x0*e.scaleX)},${Math.round(n.y0*e.scaleY)}`,`${Math.round(o.x1*e.scaleX)},${Math.round(o.y1*e.scaleY)}`].sort().join(" ")}function gt(t,e){let n=t[0],o=t.at(-1),s=n.x0*e.scaleX,r=n.y0*e.scaleY,a=Math.hypot(o.x1*e.scaleX-s,o.y1*e.scaleY-r);return{ax:s,ay:r,length:a,ux:(o.x1*e.scaleX-s)/a,uy:(o.y1*e.scaleY-r)/a}}function Wt(t,e,n){let{ax:o,ay:s,ux:r,uy:a}=gt(t,e),c=0;for(let i of t)for(let f=1;f<n;f++){let l=W(i,f/n),d=(l.y*e.scaleY-s)*r-(l.x*e.scaleX-o)*a;c=Math.abs(d)>Math.abs(c)?d:c}return c}function Le(t,e,n){let o=t[0],s=t.at(-1),{ux:r,uy:a}=gt(t,e),c=n/jt,i=-a*c/e.scaleX,f=r*c/e.scaleY,l=r*Math.abs(c)/e.scaleX,d=a*Math.abs(c)/e.scaleY;return[{x0:o.x0,y0:o.y0,cx0:o.x0+i-l,cy0:o.y0+f-d,cx1:s.x1+i+l,cy1:s.y1+f+d,x1:s.x1,y1:s.y1}]}var uo=50;function Be(t,e){return e>0?Math.max(1,t/e):uo}function ho(t){let e=new Set,n=1/0,o=-1/0;for(let s of t)e.add(s.minY),n=Math.min(n,s.minY),o=Math.max(o,s.minY);return e.size>1?(o-n)/(e.size-1):void 0}function He(t,e,n){let o=Be(e,t.length);return{x:o,y:n>0?Be(n,t.length):ho(t)??o}}function po(t,e,n,o){return t===void 0?He(e,n,o):typeof t=="number"?{x:t,y:t}:t}function mo(t,e,n){let o=t.get(e);o||(o=new Map,t.set(e,o));let s=o.get(n);return s||(s=[],o.set(n,s)),s}function $e(t,e,n,o,s,r,a){let c=Math.floor(n/e.x),i=Math.floor(s/e.x),f=Math.floor(o/e.y),l=Math.floor(r/e.y);for(let d=c;d<=i;d++)for(let p=f;p<=l;p++)mo(t,d,p).push(a)}function*Re(t,e,n){if(n-e<t.size)for(let o=e;o<=n;o++){let s=t.get(o);s!==void 0&&(yield s)}else{let o=[];for(let s of t)s[0]>=e&&s[0]<=n&&o.push(s);o.sort((s,r)=>s[0]-r[0]);for(let[,s]of o)yield s}}function*Ye(t,e,n,o,s,r){let a=Math.floor((o-r)/e.y),c=Math.floor((o+r)/e.y);for(let i of Re(t,Math.floor((n-s)/e.x),Math.floor((n+s)/e.x)))yield*Re(i,a,c)}function We(t,e,n,o,s,r){let a=[],c=new Set;for(let i of Ye(t,e,n,o,s,r))for(let f of i)c.has(f)||(c.add(f),a.push(f));return a}function yo(t,e,n,o,s,r,a){let c=!1;for(let i of Ye(t,e,n,o,s,r))if(c=i.some(a),c)break;return c}var Dt=class{constructor(t,e,n={x:0,y:0}){this.cells=new Map;let o=[],s=0,r=0;for(let[c,i]of Object.entries(t))for(let f=0;f<i.length-1;f++){let l=i[f],d=i[f+1],p=Math.min(l.x,d.x),u=Math.min(l.y,d.y),m=Math.max(l.x,d.x),h=Math.max(l.y,d.y);s+=m-p,r+=h-u,o.push({entry:{nodeId:c,segmentIdx:f},minX:p,minY:u,maxX:m,maxY:h})}let a=po(e,o,s,r);this.cellSize={x:Math.max(a.x,n.x),y:Math.max(a.y,n.y)};for(let c of o)$e(this.cells,this.cellSize,c.minX,c.minY,c.maxX,c.maxY,c.entry)}query(t,e,n,o=n){return We(this.cells,this.cellSize,t,e,n,o)}some(t,e,n,o,s){return yo(this.cells,this.cellSize,t,e,n,o,s)}},De=class{constructor(t,e,n,o,s,r=0,a,c=!1){this.cells=new Map,this.edgeCurves=Xe(t,e,o,s,r,a,c);let i=[],f=0,l=0;for(let d=0;d<e.edges.length;d++){let p=e.edges[d],u=t[p.from],m=t[p.to],h=this.edgeCurves.get(d);if(u?.length&&m?.length&&h){let{minX:v,minY:y,maxX:M,maxY:S}=Vt(h),N=p.pathIds?.length??0;if(n&&N>0){let g=0,x=0;for(let b of rt(u,m,N,o,h))g=Math.max(g,Math.abs(b.x)),x=Math.max(x,Math.abs(b.y));v-=g,y-=x,M+=g,S+=x}f+=M-v,l+=S-y,i.push({ei:d,minX:v,minY:y,maxX:M,maxY:S})}}this.cellSize=He(i,f,l);for(let d of i)$e(this.cells,this.cellSize,d.minX,d.minY,d.maxX,d.maxY,d.ei)}getCurves(t){return this.edgeCurves.get(t)}query(t,e,n,o=n){return We(this.cells,this.cellSize,t,e,n,o)}};var Fe=20;function go(t,e,n,o=1){let s=1/0,r=W(n,0);for(let a=1;a<=Fe;a++){let c=W(n,a/Fe);s=Math.min(s,U(t,e,r.x,r.y*o,c.x,c.y*o)),r=c}return s}function xo(t,e,n,o){let s=1/0;for(let r of n){let a=go(t,e,r,o);a<s&&(s=a)}return s}var Mo=H();function vo(t,e){return Mo(t,[e],()=>new Dt(t))}var ze=16,wo=H();function bo(t,e,n,o){return wo(t,[e,n,o],()=>new Dt(t,void 0,{x:ze/Math.abs(n),y:ze/Math.abs(o)}))}var So=H();function ko(t,e,n,o,s,r,a,c){return So(t,[e,n,o.scaleX,o.scaleY,!!o.pixelRows,s,r,a,c],()=>new De(t,e,n,o,r,s,a,c))}var Io=5;function vr(t,e,n,o,s,r,a){let c=bt(o),i=vo(t,s),f=m=>Math.max(Io,m)/o.scaleX,l=f(r?.maxHalfWidthPx??0),d=i.query(e,n,l,l/c),p=null,u=1/0;for(let{nodeId:m,segmentIdx:h}of d){let v=t[m],y=a?.nodes.has(m)?1/0:U(e,n*c,v[h].x,v[h].y*c,v[h+1].x,v[h+1].y*c);y<u&&y<f(r?.halfWidthPx(m)??0)&&(u=y,p=m)}return p}function xt(t,e,n){let o=e.x-t.x,s=e.y-t.y,r=0,a=1;for(let[c,i]of[[-o,t.x-n.x0],[o,n.x1-t.x],[-s,t.y-n.y0],[s,n.y1-t.y]])c===0?r=i<0?1/0:r:c<0?r=Math.max(r,i/c):a=Math.min(a,i/c);return r<=a?[r,a]:void 0}function Ao(t,e,n){return xt(t,e,n)!==void 0}function wr(t,e,n=0){let o=r=>({x:r.x*e.scaleX+e.translateX,y:r.y*e.scaleY+e.translateY}),s;return(r,a)=>(s??=bo(t,n,e.scaleX,e.scaleY),s.some(((r.x0+r.x1)/2-e.translateX)/e.scaleX,((r.y0+r.y1)/2-e.translateY)/e.scaleY,Math.abs((r.x1-r.x0)/2/e.scaleX),Math.abs((r.y1-r.y0)/2/e.scaleY),({nodeId:c,segmentIdx:i})=>{let f=t[c],l=f?.[i],d=f?.[i+1];return l!==void 0&&d!==void 0&&!a(c)&&Ao(o(l),o(d),r)}))}var _o={x:0,y:0};function br(t,e,n,o,s,r,a,c,i,f,l,d){let p=bt(s),u=10/s.scaleX,m=ko(t,e,r,s,a,c,f,l),h=m.query(n,o,u,u/p),v=null,y=u;for(let M of h){let S=e.edges[M],N=t[S.from],g=t[S.to],x=m.getCurves(M);if(N?.length&&g?.length&&x&&!i?.has(M)&&!d?.edges.has(M)){let b=S.pathIds?.length??0,k=r&&b>0?rt(N,g,b,s,x):[_o];for(let I of k){let _=xo(n-I.x,(o-I.y)*p,x,p);_<y&&(y=_,v=M)}}}return v}var Eo={nodeLengths:!0};function Cr(t,e=Eo.nodeLengths){let n=new Map;for(let o of t)(e||o.placeholder)&&n.set(o.id,o.length);return n}var No=4e4,Oo=8,Lo=5.7,Po=6,ot=13,et=3,Ft=ot,Co=3,Xo=2;function Gt(t){return(t.length*Lo+Po+et)/2}var F=(ot+et)/2,qe=2*F+2*Ft,Ke=({x:t,y:e},{width:n,height:o})=>t>=0&&t<=n&&e+F>0&&e-F<o;function Mt(t,e,n){return{x0:e-t,x1:e+t,y0:n-F,y1:n+F}}function Xr(t,e){return{x0:6,x1:6+yt(t)+et,y0:e-8-et/2,y1:e+8+et/2}}function Ue(t){return String(t).replace(/\B(?=(\d{3})+$)/g,",")}function zt(t){let[e,n]=t>=999500?[t/1e6,"Mb"]:t>=1e3?[t/1e3,"kb"]:[];return e===void 0?`${t} bp`:`${+e.toFixed(e>=100?0:1)} ${n}`}var To=H();function Bo(t,e,n){return To(t,[e,n],()=>Object.entries(t).filter(([o,s])=>s.length>0&&e.has(o)).map(([o,s])=>({id:o,segments:s,kept:n?.get(o)?.placeholder===!0})).sort((o,s)=>o.kept===s.kept?e.get(s.id)-e.get(o.id)||Q(o.id,s.id):o.kept?-1:1))}var Ze=Array.from({length:15},(t,e)=>(e+1)/16).sort((t,e)=>Math.abs(t-.5)-Math.abs(e-.5)||t-e);function Je(t,e,n,o){let s=[0];for(let r=Ge;r<=e;r+=Ge)s.push(-r,r);return Array.from({length:o},(r,a)=>a+1).flatMap(r=>[1,-1].flatMap(a=>s.map(c=>({x:n.x+c,y:n.y+a*r*qt,distance:Math.hypot(c,r*qt)})))).sort((r,a)=>r.distance-a.distance).map(({x:r,y:a})=>({label:{...t,x:r,y:a,leader:n},box:Mt(e,r,a)}))}var Ge=8,Ro=2*F,Qe=(t,e)=>Math.hypot(t.x-e.x,t.y-e.y)<Ro,qt=2*F,tn=t=>Math.ceil(t/qt);function Tr({x:t,y:e,leader:n}){return n?en({x:t,y:e},n):void 0}function en({x:t,y:e},n){return{x1:t,y1:n.y>e?e+ot/2:e-ot/2,x2:n.x,y2:n.y}}function Ho(t,e){let{x1:n,y1:o}=en(t,e),s=Math.hypot(n-e.x,o-e.y),r=s>0?Math.min(1,F/s):1,a=e.x+(n-e.x)*r,c=e.y+(o-e.y)*r;return{x0:Math.min(n,a)-1,x1:Math.max(n,a)+1,y0:Math.min(o,c),y1:Math.max(o,c)}}function nn(t,e){let n=0,o=1/0,s=-1/0,r=0,a=!1;return t.forEach((c,i)=>{let f=t[i-1],l=f?xt(f,c,e):void 0,d=f?Math.hypot(c.x-f.x,c.y-f.y):0;l&&(o=Math.min(o,n+l[0]*d),s=n+l[1]*d),r+=l&&!a?1:0,a=!!l,n+=d}),r===1&&o>=Ft&&n-s>=Ft}function Br({nodePositions:t,nodeLengths:e,nodeById:n,alleleDeletions:o,pxPerBp:s=0,axis:r,translateX:a,translateY:c,width:i,height:f}){let{scaleX:l,scaleY:d}=r,p=new Set(o?.flatMap(y=>y.nodeIds)),u=[],m=({x:y,y:M})=>({x:y*l+a,y:M*d+c}),h={width:i,height:f},v=y=>m(it(t[y]??[],.5));for(let{id:y,segments:M,kept:S}of Bo(t,e,n)){let N=p.has(y)?[]:Ze.map(I=>m(it(M,I))).filter(I=>Ke(I,h)),g=e.get(y),x=N.length>0?G(M,l,d):0,b=S||g*s>=q,[k]=N;if(k&&(x>=qe||b)){let I={key:`node:${y}`,node:y,text:zt(g)},_=Gt(I.text),T=x>=qe?M.map(m):[],X=N.map(({x:O,y:w})=>({label:{...I,x:O,y:w},box:Mt(_,O,w)})).filter(({box:O})=>D(O,h)&&nn(T,O));(X.length>0||b)&&u.push({id:y,kept:S,middle:k,along:X,own:({node:O})=>O===y||O!==void 0&&(t[O]?.length??0)>0&&Qe(v(O),v(y)),stacked:b?()=>Je(I,_,k,S?tn(f):Co).filter(({box:O})=>D(O,h)):void 0})}}return u}var $o=H();function Rr(t){return $o(t.nodes,[t.paths],()=>{let e=new Map(t.nodes.map(a=>[a.id,a])),n=new Set,o=[];for(let a of t.paths??[]){let c=[],i=0,f=!0,l=!1;for(let d of a.nodeIds){let p=e.get(d);if(p&&R(p)){let u=c.join(" ");l&&f&&c.length>0&&!n.has(u)&&(n.add(u),o.push({nodes:c,bp:i})),l=!0,c=[],i=0,f=!0}else c.push(d),i+=p?.length??0,f&&=!!p&&!p.placeholder}}o.sort((a,c)=>c.bp-a.bp||Q(a.nodes[0]??"",c.nodes[0]??"")||c.nodes.length-a.nodes.length);let s=[],r=new Map;for(let a of o){let c=new Map;for(let l of new Set(a.nodes))for(let d of r.get(l)??[])c.set(d,(c.get(d)??0)+(e.get(l)?.length??0));let i;for(let[l,d]of c)i??=2*d>=s[l].bp?l:void 0;let f=i===void 0?void 0:s[i];if(f){f.least=Math.min(f.least,a.bp);for(let l of a.nodes)f.drawn.add(l)}else{for(let l of new Set(a.nodes))$(r,l,s.length);s.push({...a,least:a.bp,drawn:new Set(a.nodes)})}}return s})}function Yo(t,e){let n=zt(t),o=zt(e),[s,r]=n.split(" ");return n===o?o:r===o.split(" ")[1]?`${s}\u2013${o}`:`${n}\u2013${o}`}var nt=(t,e)=>Math.hypot(t.x-e.x,t.y-e.y),Ve=(t,e)=>Math.min(nt(t,e[0]??t),nt(t,e.at(-1)??t));function Wo(t,e){let n=t.map(a=>e[a]??[]),o=[],s=[],r=0;return n.forEach((a,c)=>{let i=a[0],f=a.at(-1),l=n[c+1]??[],d=o.at(-1),p=i&&f?d?nt(d,f)<nt(d,i):l.length>0&&Ve(i,l)<Ve(f,l):!1;for(let u=0;u<a.length;u++){let m=a[p?a.length-1-u:u],h=o.at(-1);r+=h?nt(h,m):0,o.push(m)}s.push(r)}),n.every(a=>a.length>0)?{line:o,ends:s}:void 0}var Do=H(),je=()=>!1;function Fo(t,e){let n=0,o=!1,s=0;return t.forEach((r,a)=>{let c=t[a-1],i=c?xt(c,r,e):void 0;n+=i&&!o?1:0,o=!!i,s+=i&&c?(i[1]-i[0])*Math.hypot(r.x-c.x,r.y-c.y):0}),n===1&&s<=Math.hypot(e.x1-e.x0,e.y1-e.y0)}function Hr({loops:t,edges:e,nodePositions:n,folded:o,pxPerBp:s,ink:r,axis:a,translateX:c,translateY:i,width:f,height:l}){let{scaleX:d,scaleY:p}=a,u=Do(n,[t],()=>t.flatMap(M=>{let S=Wo(M.nodes,n);return S?[{loop:M,...S}]:[]})),m=({x:M,y:S})=>({x:M*d+c,y:S*p+i}),h={width:f,height:l},v=new Map,y=[];for(let{loop:M,line:S,ends:N}of u){let g=Yo(M.least,M.bp),x=Gt(g);if(M.bp*s>=q&&G(S,d,p)>=x*2/Xo&&!M.nodes.every(b=>o?.has(b))){let b=N.at(-1)??0,k=M.nodes[N.findIndex(E=>E>=b/2)]??M.nodes[0],I=`${M.nodes[0]}>${M.nodes.at(-1)}`,_=v.get(I)??0;v.set(I,_+1);let T={key:`loop:${I}${_?`#${_}`:""}`,node:k,text:g},{drawn:X}=M,O=({node:E,edge:C})=>E!==void 0?X.has(E):C!==void 0&&(X.has(e[C]?.from??"")||X.has(e[C]?.to??"")),w=S.map(m),L=r.widest(M.nodes),A=Ze.map(E=>m(it(S,E))).filter(E=>Ke(E,h)),B=A.map(({x:E,y:C})=>({label:{...T,x:E,y:C},box:Mt(x,E,C)})).filter(({box:E})=>D(E,h)&&nn(w,E)&&Fo(w,Ie(E,L))),[P]=A;P&&y.push({id:T.key,kept:!1,middle:P,along:B,own:O,stacked:()=>Je(T,x,P,tn(l)).filter(({box:E})=>D(E,h))})}}return y}function $r(t,e){return Math.max(Oo,Math.floor(t*e/No))}var zo=(t,e)=>Math.hypot(Math.max(0,t.x0-e.x1,e.x0-t.x1),Math.max(0,t.y0-e.y1,e.y0-t.y1));function Yr(t,e,{budget:n=1/0,placed:o=[],leaders:s=1/0,under:r=je}={}){let a=[],c=o.slice(),i=d=>c.some(({middle:p})=>Qe(p,d)),f=({label:d,box:p})=>c.every(u=>u.label.text!==d.text||zo(p,Mt(Gt(d.text),u.label.x,u.label.y))>=ot),l=0;for(let d of t)if((d.kept||c.length<n)&&!i(d.middle)){let p=m=>d.own(m)||m.exon!==void 0&&d.own({node:m.exon}),u=d.along.find(m=>f(m)&&!r(m.box,d.own)&&e(m.box))??(l<s?d.stacked?.().find(m=>{let h=Ho(m.label,d.middle);return f(m)&&!r(m.box,je)&&!r(h,p)&&e(m.box,h)}):void 0);if(u){let m={label:u.label,middle:d.middle};a.push(m),c.push(m),l+=u.label.leader?1:0}}return a}function Wr(t,e,n){let o=new Set(e.map(c=>c.node)),s=0,r=1/0,a=0;for(let{id:c,kept:i}of t)if(i&&!o.has(c)){let f=n.get(c);s++,r=Math.min(r,f),a=Math.max(a,f)}return s>0?{count:s,smallest:r,largest:a}:void 0}function Vr(t){let e=0;for(let n=0;n<t.length;n++)e=t.charCodeAt(n)+((e<<5)-e);return Math.abs(e%360)}function qo(t,e){return t*360/e}var Go=.7,Vo=.5,jo=16;function jr(t){return t>0&&t<=jo}function Ko(t,e){return`hsl(${qo(t,e)}, ${Go*100}%, ${Vo*100}%)`}function Kr(t,e){return`hsl(0, 0%, ${e>1?25+45*t/(e-1):45}%)`}function Uo(t){let e=J(t).name.split("#"),n=e.join("#");if(e.length>=3&&Qt(e[0])){let o=e.slice(2).join("#");return[o,o,n]}return[e[0],e.slice(0,2).join("#"),n]}function Zo(t,e){let{start:n}=J(t);return e.map(o=>`${o} @${Ue(n)}`)}function Ur(t,e){let n=new Map;t.forEach((l,d)=>{n.has(l.name)||n.set(l.name,d)});let o=[...n].map(([l,d])=>({name:l,i:d})),s=o.map(l=>Uo(l.name)),r=l=>o.map((d,p)=>s[p][l]),a=l=>o.map((d,p)=>Zo(d.name,s[p])[l]),c=[r(0),r(1),a(0),r(2),a(1),a(2)],f=c.find(l=>new Set(l).size===o.length)??c.at(-1);return o.map(({name:l,i:d},p)=>({name:l,label:f[p],color:e?.[d]??Ko(d,t.length)}))}function Zr(t){let e=new Map;return new Map([...t].sort((n,o)=>Q(n.label,o.label)).map(n=>{let o=(e.get(n.label)??0)+1;return e.set(n.label,o),[n.name,o>1?`${n.label} (${o})`:n.label]}))}var Qr=[{value:"uniform",label:"Uniform",description:"Every link the same thickness."},{value:"walks",label:"By walks",description:"Thicker the more walks take a link, on the square root of its count against the busiest link in the cut. A graph without walks draws uniform."}],on=.5,Jo=4;function ta(t){let e=0;for(let n of t.edges)e=Math.max(e,n.pathIds?.length??0);return e}function ea(t,e,n){return n==="uniform"||e===0?1:on+(Jo-on)*Math.sqrt(t/e)}var Qo=4;function ts(t){let e=new Map;for(let n of t.edges)$(e,n.from,n.to),$(e,n.to,n.from);return e}function es({nodeId:t,nodeById:e,neighbors:n}){let o=new Set([t]),s=[t],r=1/0,a=-1/0;for(let c=0;c<Qo&&s.length>0;c++){let i=[];for(let f of s){let l=n.get(f);if(l){for(let d of l)if(!o.has(d)){o.add(d);let p=e.get(d);p&&R(p)?(r=Math.min(r,p.stable.start+p.length),a=Math.max(a,p.stable.start)):i.push(d)}}}s=i}return r===1/0?void 0:{start:Math.min(r,a),end:Math.max(r,a)}}function ns({nodeId:t,nodeById:e,neighbors:n}){let o=e.get(t);return o===void 0?void 0:R(o)?{start:o.stable.start,end:o.stable.start+o.length}:es({nodeId:t,nodeById:e,neighbors:n})}function ra(t,e=ts(t)){let n=new Map(t.nodes.map(s=>[s.id,s])),o=new Map;for(let s of t.nodes){let r=ns({nodeId:s.id,nodeById:n,neighbors:e});r&&o.set(s.id,(r.start+r.end)/2)}return o}export{ts as a,ns as b,ra as c,qs as d,Gs as e,Rn as f,er as g,nr as h,Ee as i,or as j,hs as k,ps as l,ms as m,xs as n,ss as o,re as p,_t as q,rs as r,as as s,Et as t,dn as u,un as v,hn as w,cs as x,pe as y,H as z,q as A,Xs as B,Ts as C,Bs as D,Rs as E,Hs as F,ve as G,Xn as H,mt as I,yt as J,Ie as K,Tn as L,Ys as M,to as N,no as O,Oe as P,Xe as Q,vr as R,xt as S,Ao as T,wr as U,br as V,Eo as W,Cr as X,Xr as Y,Ue as Z,zt as _,Tr as $,Br as aa,Rr as ba,Yo as ca,Hr as da,$r as ea,Yr as fa,Wr as ga,Vr as ha,qo as ia,Go as ja,Vo as ka,jo as la,jr as ma,Ko as na,Kr as oa,Ur as pa,Zr as qa,Qr as ra,ta as sa,ea as ta};
2
+ //# sourceMappingURL=chunk-QVQIHX2Y.js.map