jbrowse-plugin-graphgenomeviewer 10.24.0 → 10.25.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 (47) hide show
  1. package/dist/chunks/{GraphGenomeView-MQPUCL6L.js → GraphGenomeView-HJ6QSGV7.js} +2 -2
  2. package/dist/chunks/{LinearGraphDisplay-FSY43YBB.js → LinearGraphDisplay-456PTWEO.js} +2 -2
  3. package/dist/chunks/chunk-2VKA7YEW.js +3 -0
  4. package/dist/chunks/chunk-2VKA7YEW.js.map +7 -0
  5. package/dist/chunks/chunk-AGJAVVWD.js +2 -0
  6. package/dist/chunks/chunk-AGJAVVWD.js.map +7 -0
  7. package/dist/chunks/{chunk-QSF7YU5B.js → chunk-GNVL442Z.js} +2 -2
  8. package/dist/chunks/chunk-GNVL442Z.js.map +7 -0
  9. package/dist/chunks/{chunk-6P2BZZ2N.js → chunk-UXUARTLL.js} +4 -4
  10. package/dist/chunks/chunk-UXUARTLL.js.map +7 -0
  11. package/dist/chunks/chunk-YIL4545N.js +9 -0
  12. package/dist/chunks/{chunk-MSQ7YVZS.js.map → chunk-YIL4545N.js.map} +3 -3
  13. package/dist/chunks/renderSvg-LCEIAI6F.js +2 -0
  14. package/dist/chunks/renderSvg-LCEIAI6F.js.map +7 -0
  15. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js +1 -1
  16. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js.map +3 -3
  17. package/package.json +1 -1
  18. package/src/GraphGenomeView/components/GraphCanvas.tsx +28 -3
  19. package/src/GraphGenomeView/components/HoverLayer.tsx +5 -1
  20. package/src/GraphGenomeView/components/PaneLayer.tsx +1 -0
  21. package/src/GraphGenomeView/components/PaneSvg.tsx +18 -3
  22. package/src/GraphGenomeView/frame.ts +37 -0
  23. package/src/GraphGenomeView/model.ts +11 -6
  24. package/src/GraphGenomeView/pane/fitViews.ts +193 -17
  25. package/src/GraphGenomeView/pane/paneBase.ts +1 -0
  26. package/src/GraphGenomeView/pane/viewFrame.test.ts +261 -0
  27. package/src/GraphGenomeView/pane/viewFrame.ts +329 -0
  28. package/src/LinearGraphDisplay/LinearGraphDisplay.kept.test.ts +183 -44
  29. package/src/LinearGraphDisplay/LinearGraphDisplay.key.test.ts +101 -33
  30. package/src/LinearGraphDisplay/LinearGraphDisplay.menu.test.ts +17 -11
  31. package/src/LinearGraphDisplay/LinearGraphDisplay.restore.test.ts +6 -2
  32. package/src/LinearGraphDisplay/LinearGraphDisplay.zoom.test.ts +5 -2
  33. package/src/LinearGraphDisplay/configSchema.ts +19 -1
  34. package/src/LinearGraphDisplay/displayTestSupport.ts +13 -0
  35. package/src/LinearGraphDisplay/model.ts +18 -8
  36. package/src/version.ts +1 -1
  37. package/dist/chunks/chunk-6P2BZZ2N.js.map +0 -7
  38. package/dist/chunks/chunk-MSQ7YVZS.js +0 -9
  39. package/dist/chunks/chunk-QSF7YU5B.js.map +0 -7
  40. package/dist/chunks/chunk-SDV3OGYW.js +0 -3
  41. package/dist/chunks/chunk-SDV3OGYW.js.map +0 -7
  42. package/dist/chunks/chunk-URRY6WTX.js +0 -2
  43. package/dist/chunks/chunk-URRY6WTX.js.map +0 -7
  44. package/dist/chunks/renderSvg-XT3BMW54.js +0 -2
  45. package/dist/chunks/renderSvg-XT3BMW54.js.map +0 -7
  46. /package/dist/chunks/{GraphGenomeView-MQPUCL6L.js.map → GraphGenomeView-HJ6QSGV7.js.map} +0 -0
  47. /package/dist/chunks/{LinearGraphDisplay-FSY43YBB.js.map → LinearGraphDisplay-456PTWEO.js.map} +0 -0
@@ -1,4 +1,4 @@
1
- import{b as $}from"./chunk-URRY6WTX.js";import"./chunk-FN5OANFE.js";import"./chunk-QSF7YU5B.js";import{g as R,h as U}from"./chunk-MSQ7YVZS.js";import{a as V}from"./chunk-SDV3OGYW.js";import{q as v}from"./chunk-WZOAYGF5.js";import"./chunk-6P2BZZ2N.js";import"./chunk-3LEQAY3J.js";import"./chunk-YEY23TBB.js";import"./chunk-5URP77TX.js";import"./chunk-ECNJGM74.js";import"./chunk-IK5G3JHR.js";import"./chunk-7N53GARW.js";import"./chunk-YBLNN5FU.js";import"./chunk-JYU2J2B7.js";import"./chunk-RCXMPQKP.js";import"./chunk-JM4W4PKP.js";import"./chunk-P4XSCP6W.js";import"./chunk-ZQOMV674.js";import"./chunk-YBLNN5FU.js";import"./chunk-3W7WSULH.js";import"./chunk-YGIWBVPD.js";import"./chunk-ZCNHZLT2.js";import"./chunk-HNTK5LBJ.js";import{e as O,j as c}from"./chunk-PCP5Y77D.js";import{B as y,G as x,I as p,e as N,j as B,m as E,n as D,o as l,s as P,y as z}from"./chunk-H42TSPVA.js";import{a as L,b as e,c as n,d}from"./chunk-DUU6T2I5.js";import"./chunk-TMM73K4C.js";import"./chunk-D6TY2QEG.js";import"./chunk-2MOWWQHO.js";import"./chunk-EGZZ3ADM.js";import"./chunk-IMCJTUCX.js";import{j as A,o as F}from"./chunk-5L276I7O.js";var K=v()({paper:{padding:16,margin:8,maxWidth:560,marginInline:"auto",display:"flex",flexDirection:"column",gap:12},row:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},actions:{display:"flex",justifyContent:"flex-end",gap:8}}),_=d(function({model:t}){return e(l,{size:"small","data-testid":"graph-genome-choose-another",onClick:()=>{t.clearGraph()},children:"Choose another graph"})}),X=d(function({model:t}){let{classes:r}=K();return!t.error&&!t.loadCanceled?n(y,{className:r.paper,"data-testid":"graph-genome-loading",children:[n("div",{className:r.row,children:[e(B,{variant:"h6",message:t.statusMessage||void 0}),t.canCancelLoad?e(l,{size:"small","data-testid":"graph-genome-cancel",onClick:()=>{t.cancelLoad()},children:"Cancel"}):null]}),e(z,{variant:"indeterminate"})]}):t.error?n(y,{className:r.paper,children:[e(N,{error:t.error,onReset:()=>{t.retryLoad()}}),e("div",{className:r.actions,children:e(_,{model:t})})]}):e(y,{className:r.paper,"data-testid":"graph-genome-load-canceled",children:n("div",{className:r.row,children:[e(p,{variant:"h6",children:"Loading canceled"}),n("div",{className:r.actions,children:[e(_,{model:t}),e(l,{variant:"contained",size:"small","data-testid":"graph-genome-retry",onClick:()=>{t.retryLoad()},children:"Retry"})]})]})})}),I=X;var q=V(e("path",{d:"M9 21c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-1H9zm3-19C8.14 2 5 5.14 5 9c0 2.38 1.19 4.47 3 5.74V17c0 .55.45 1 1 1h6c.55 0 1-.45 1-1v-2.26c1.81-1.27 3-3.36 3-5.74 0-3.86-3.14-7-7-7m2.85 11.1-.85.6V16h-4v-2.3l-.85-.6C7.8 12.16 7 10.63 7 9c0-2.76 2.24-5 5-5s5 2.24 5 5c0 1.63-.8 3.16-2.15 4.1"}),"LightbulbOutlined");var Z=v()({column:{display:"flex",flexDirection:"column",gap:12},actions:{display:"flex",justifyContent:"flex-end"}}),J=d(function({model:t,choices:r}){let{classes:T}=Z(),f=A(t),{assemblyManager:g}=f,[S,G]=c(r[0]?.trackId),[w,k]=c(),[C,h]=c(),a=r.find(o=>o.trackId===S)??r[0],i=a?.assembly,M=(i?g.get(i):void 0)?.regions?.[0],b=w??(a?R(f.views,a.assembly)??(M?U(a,M):""):"");O(()=>{i&&g.waitForAssembly(i).catch(()=>{})},[g,i]);async function W(){if(a)try{let o=await g.waitForAssembly(a.assembly),s=o?F(b,u=>o.isValidRefName(u)):void 0;!o||!s||!o.isValidRefName(s.refName)?h(`No sequence ${s?.refName??b} in ${a.assembly}`):t.showTrackInLinearView(a.trackId,a.assembly,b)}catch(o){h(String(o instanceof Error?o.message:o))}}return n("form",{className:T.column,"data-testid":"graph-track-picker",onSubmit:o=>{o.preventDefault(),W()},children:[e(D,{options:r,value:a??null,getOptionLabel:o=>o.name,isOptionEqualToValue:(o,s)=>o.trackId===s.trackId,onChange:(o,s)=>{s&&(G(s.trackId),k(void 0),h(void 0))},renderOption:({key:o,...s},u)=>e("li",{...s,children:n("div",{children:[e(p,{variant:"body2",children:u.name}),n(p,{variant:"caption",color:"text.secondary",children:[u.assembly," \xB7 ",u.reach]})]})},u.trackId),renderInput:o=>e(x,{...o,size:"small",label:"Graph track",helperText:a?`${a.assembly} \xB7 ${a.reach}`:""})}),e(x,{size:"small",label:"Region",name:"region",value:b,placeholder:"chr1:1,000,001-1,020,000",error:C!==void 0,helperText:C??"A sequence name, or name:start-end",onChange:o=>{k(o.target.value),h(void 0)}}),e("div",{className:T.actions,children:e(l,{type:"submit",variant:"contained","data-testid":"graph-track-show",disabled:!a||!b.trim(),children:"Show in linear genome view"})})]})}),H=J;var Q=`H VN:Z:1.0
1
+ import{b as $}from"./chunk-AGJAVVWD.js";import"./chunk-FN5OANFE.js";import"./chunk-GNVL442Z.js";import{g as R,h as U}from"./chunk-YIL4545N.js";import{a as V}from"./chunk-2VKA7YEW.js";import{q as v}from"./chunk-WZOAYGF5.js";import"./chunk-UXUARTLL.js";import"./chunk-3LEQAY3J.js";import"./chunk-YEY23TBB.js";import"./chunk-5URP77TX.js";import"./chunk-ECNJGM74.js";import"./chunk-IK5G3JHR.js";import"./chunk-7N53GARW.js";import"./chunk-YBLNN5FU.js";import"./chunk-JYU2J2B7.js";import"./chunk-RCXMPQKP.js";import"./chunk-JM4W4PKP.js";import"./chunk-P4XSCP6W.js";import"./chunk-ZQOMV674.js";import"./chunk-YBLNN5FU.js";import"./chunk-3W7WSULH.js";import"./chunk-YGIWBVPD.js";import"./chunk-ZCNHZLT2.js";import"./chunk-HNTK5LBJ.js";import{e as O,j as c}from"./chunk-PCP5Y77D.js";import{B as y,G as x,I as p,e as N,j as B,m as E,n as D,o as l,s as P,y as z}from"./chunk-H42TSPVA.js";import{a as L,b as e,c as n,d}from"./chunk-DUU6T2I5.js";import"./chunk-TMM73K4C.js";import"./chunk-D6TY2QEG.js";import"./chunk-2MOWWQHO.js";import"./chunk-EGZZ3ADM.js";import"./chunk-IMCJTUCX.js";import{j as A,o as F}from"./chunk-5L276I7O.js";var K=v()({paper:{padding:16,margin:8,maxWidth:560,marginInline:"auto",display:"flex",flexDirection:"column",gap:12},row:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},actions:{display:"flex",justifyContent:"flex-end",gap:8}}),_=d(function({model:t}){return e(l,{size:"small","data-testid":"graph-genome-choose-another",onClick:()=>{t.clearGraph()},children:"Choose another graph"})}),X=d(function({model:t}){let{classes:r}=K();return!t.error&&!t.loadCanceled?n(y,{className:r.paper,"data-testid":"graph-genome-loading",children:[n("div",{className:r.row,children:[e(B,{variant:"h6",message:t.statusMessage||void 0}),t.canCancelLoad?e(l,{size:"small","data-testid":"graph-genome-cancel",onClick:()=>{t.cancelLoad()},children:"Cancel"}):null]}),e(z,{variant:"indeterminate"})]}):t.error?n(y,{className:r.paper,children:[e(N,{error:t.error,onReset:()=>{t.retryLoad()}}),e("div",{className:r.actions,children:e(_,{model:t})})]}):e(y,{className:r.paper,"data-testid":"graph-genome-load-canceled",children:n("div",{className:r.row,children:[e(p,{variant:"h6",children:"Loading canceled"}),n("div",{className:r.actions,children:[e(_,{model:t}),e(l,{variant:"contained",size:"small","data-testid":"graph-genome-retry",onClick:()=>{t.retryLoad()},children:"Retry"})]})]})})}),I=X;var q=V(e("path",{d:"M9 21c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-1H9zm3-19C8.14 2 5 5.14 5 9c0 2.38 1.19 4.47 3 5.74V17c0 .55.45 1 1 1h6c.55 0 1-.45 1-1v-2.26c1.81-1.27 3-3.36 3-5.74 0-3.86-3.14-7-7-7m2.85 11.1-.85.6V16h-4v-2.3l-.85-.6C7.8 12.16 7 10.63 7 9c0-2.76 2.24-5 5-5s5 2.24 5 5c0 1.63-.8 3.16-2.15 4.1"}),"LightbulbOutlined");var Z=v()({column:{display:"flex",flexDirection:"column",gap:12},actions:{display:"flex",justifyContent:"flex-end"}}),J=d(function({model:t,choices:r}){let{classes:T}=Z(),f=A(t),{assemblyManager:g}=f,[S,G]=c(r[0]?.trackId),[w,k]=c(),[C,h]=c(),a=r.find(o=>o.trackId===S)??r[0],i=a?.assembly,M=(i?g.get(i):void 0)?.regions?.[0],b=w??(a?R(f.views,a.assembly)??(M?U(a,M):""):"");O(()=>{i&&g.waitForAssembly(i).catch(()=>{})},[g,i]);async function W(){if(a)try{let o=await g.waitForAssembly(a.assembly),s=o?F(b,u=>o.isValidRefName(u)):void 0;!o||!s||!o.isValidRefName(s.refName)?h(`No sequence ${s?.refName??b} in ${a.assembly}`):t.showTrackInLinearView(a.trackId,a.assembly,b)}catch(o){h(String(o instanceof Error?o.message:o))}}return n("form",{className:T.column,"data-testid":"graph-track-picker",onSubmit:o=>{o.preventDefault(),W()},children:[e(D,{options:r,value:a??null,getOptionLabel:o=>o.name,isOptionEqualToValue:(o,s)=>o.trackId===s.trackId,onChange:(o,s)=>{s&&(G(s.trackId),k(void 0),h(void 0))},renderOption:({key:o,...s},u)=>e("li",{...s,children:n("div",{children:[e(p,{variant:"body2",children:u.name}),n(p,{variant:"caption",color:"text.secondary",children:[u.assembly," \xB7 ",u.reach]})]})},u.trackId),renderInput:o=>e(x,{...o,size:"small",label:"Graph track",helperText:a?`${a.assembly} \xB7 ${a.reach}`:""})}),e(x,{size:"small",label:"Region",name:"region",value:b,placeholder:"chr1:1,000,001-1,020,000",error:C!==void 0,helperText:C??"A sequence name, or name:start-end",onChange:o=>{k(o.target.value),h(void 0)}}),e("div",{className:T.actions,children:e(l,{type:"submit",variant:"contained","data-testid":"graph-track-show",disabled:!a||!b.trim(),children:"Show in linear genome view"})})]})}),H=J;var Q=`H VN:Z:1.0
2
2
  S 1 ACGT
3
3
  S 2 GGCC
4
4
  S 3 TTAA
@@ -7,4 +7,4 @@ L 1 + 2 + 0M
7
7
  L 1 + 3 + 0M
8
8
  L 2 + 4 + 0M
9
9
  L 3 + 4 + 0M`,Y=v()(m=>({column:{display:"flex",flexDirection:"column",gap:8},rowEnd:{display:"flex",gap:8,alignItems:"flex-end"},rowCenter:{display:"flex",gap:8,alignItems:"center"},flex1:{flex:1},paper:{padding:16,margin:8,maxWidth:560,marginInline:"auto"},header:{marginBottom:12},tip:{marginBottom:16},divider:{marginBlock:16},footer:{marginTop:12,display:"flex",justifyContent:"flex-end"},dragging:{outline:`2px dashed ${m.palette.primary.main}`,outlineOffset:-4}})),ee=d(function({model:t}){let{classes:r,cx:T}=Y(),[f,g]=c(""),[S,G]=c(!1),{graphTracks:w}=t;function k(){let a=f.trim();a&&t.openGfaLocation({uri:a,locationType:"UriLocation"})}function C(a){let i=a.target.files?.[0];a.target.value="",i&&t.loadGFAFile(i,i.name)}function h(a){a.preventDefault(),G(!1);let i=a.dataTransfer.files[0];i&&t.loadGFAFile(i,i.name)}return n(y,{className:T(r.paper,S&&r.dragging),"data-testid":"graph-import-form",onDragOver:a=>{a.preventDefault(),G(a.dataTransfer.types.includes("Files"))},onDragLeave:a=>{(!(a.relatedTarget instanceof Node)||!a.currentTarget.contains(a.relatedTarget))&&G(!1)},onDrop:a=>{h(a)},children:[n(E,{severity:"info",icon:e(q,{fontSize:"inherit"}),className:r.tip,"data-testid":"graph-import-tip",children:["A pangenome graph usually reads best as a track in a linear genome view, which redraws it as you pan and zoom."," ",w.length>0?"Pick a graph track and a region below.":"Index it with gfa-to-tabix and open it with File \u2192 Open track."]}),w.length>0?n(L,{children:[e("div",{className:r.header,children:e(p,{variant:"h6",children:"Show a graph track"})}),e(H,{model:t,choices:w}),e(P,{className:r.divider}),e("div",{className:r.header,children:e(p,{variant:"subtitle1",children:"Or open a small GFA file"})})]}):e("div",{className:r.header,children:e(p,{variant:"h6",children:"Open a small GFA file"})}),n("div",{className:r.column,children:[n("div",{className:r.rowCenter,children:[n(l,{variant:"outlined",component:"label",size:"small",children:["Choose file",e("input",{type:"file",accept:".gfa,.gfa1,.gfa2,.gz",hidden:!0,onChange:a=>{C(a)}})]}),e(p,{variant:"caption",color:"text.secondary",children:"Or drop one here. The whole file is drawn at once."})]}),n("div",{className:r.rowEnd,children:[e(x,{size:"small",label:"URL",placeholder:"https://example.com/graph.gfa",value:f,onChange:a=>{g(a.target.value)},onKeyDown:a=>{a.key==="Enter"&&k()},className:r.flex1}),e(l,{variant:"contained",onClick:()=>{k()},disabled:!f.trim(),children:"Open"})]})]}),e("div",{className:r.footer,children:e(l,{size:"small",onClick:()=>{t.loadGFA(Q,"Example graph")},children:"Load 4-node example"})}),t.error?e(N,{error:t.error}):null]})}),j=ee;var ae=d(function({model:t}){return t.hasGraph?e($,{model:t}):t.canRetryLoad?e(I,{model:t}):n(L,{children:[t.isLoading?e(I,{model:t}):null,e("div",{hidden:t.isLoading,children:e(j,{model:t})})]})}),Ve=ae;export{Ve as default};
10
- //# sourceMappingURL=GraphGenomeView-MQPUCL6L.js.map
10
+ //# sourceMappingURL=GraphGenomeView-HJ6QSGV7.js.map
@@ -1,2 +1,2 @@
1
- import{a,b as i}from"./chunk-URRY6WTX.js";import"./chunk-FN5OANFE.js";import"./chunk-QSF7YU5B.js";import"./chunk-SDV3OGYW.js";import"./chunk-WZOAYGF5.js";import"./chunk-6P2BZZ2N.js";import"./chunk-3LEQAY3J.js";import"./chunk-YEY23TBB.js";import"./chunk-5URP77TX.js";import"./chunk-ECNJGM74.js";import"./chunk-7N53GARW.js";import"./chunk-YBLNN5FU.js";import"./chunk-JYU2J2B7.js";import"./chunk-RCXMPQKP.js";import"./chunk-P4XSCP6W.js";import"./chunk-ZQOMV674.js";import"./chunk-YBLNN5FU.js";import"./chunk-3W7WSULH.js";import"./chunk-YGIWBVPD.js";import"./chunk-ZCNHZLT2.js";import"./chunk-HNTK5LBJ.js";import"./chunk-PCP5Y77D.js";import"./chunk-H42TSPVA.js";import{b as o,d as t}from"./chunk-DUU6T2I5.js";import"./chunk-TMM73K4C.js";import"./chunk-2MOWWQHO.js";import"./chunk-EGZZ3ADM.js";import"./chunk-IMCJTUCX.js";import"./chunk-5L276I7O.js";var e=JBrowseExports["@jbrowse/display-kit/DisplayChrome"];var s=e&&e.__esModule?e.default:e;var p=t(function({model:r}){return o(s,{model:r,factory:a,testid:"linear-graph-display","data-layout":r.chosenLayoutMode,"data-cut-tier":r.cutTier,"data-recuts":r.recuts,"data-node-count":r.hasGraph?r.nodeCount:void 0,"data-loading":r.isLoading?"":void 0,style:{width:r.paneWidth,height:r.height,overflow:"hidden"},children:n=>o(i,{model:r,handle:n})})}),c=p;export{c as default};
2
- //# sourceMappingURL=LinearGraphDisplay-FSY43YBB.js.map
1
+ import{a,b as i}from"./chunk-AGJAVVWD.js";import"./chunk-FN5OANFE.js";import"./chunk-GNVL442Z.js";import"./chunk-2VKA7YEW.js";import"./chunk-WZOAYGF5.js";import"./chunk-UXUARTLL.js";import"./chunk-3LEQAY3J.js";import"./chunk-YEY23TBB.js";import"./chunk-5URP77TX.js";import"./chunk-ECNJGM74.js";import"./chunk-7N53GARW.js";import"./chunk-YBLNN5FU.js";import"./chunk-JYU2J2B7.js";import"./chunk-RCXMPQKP.js";import"./chunk-P4XSCP6W.js";import"./chunk-ZQOMV674.js";import"./chunk-YBLNN5FU.js";import"./chunk-3W7WSULH.js";import"./chunk-YGIWBVPD.js";import"./chunk-ZCNHZLT2.js";import"./chunk-HNTK5LBJ.js";import"./chunk-PCP5Y77D.js";import"./chunk-H42TSPVA.js";import{b as o,d as t}from"./chunk-DUU6T2I5.js";import"./chunk-TMM73K4C.js";import"./chunk-2MOWWQHO.js";import"./chunk-EGZZ3ADM.js";import"./chunk-IMCJTUCX.js";import"./chunk-5L276I7O.js";var e=JBrowseExports["@jbrowse/display-kit/DisplayChrome"];var s=e&&e.__esModule?e.default:e;var p=t(function({model:r}){return o(s,{model:r,factory:a,testid:"linear-graph-display","data-layout":r.chosenLayoutMode,"data-cut-tier":r.cutTier,"data-recuts":r.recuts,"data-node-count":r.hasGraph?r.nodeCount:void 0,"data-loading":r.isLoading?"":void 0,style:{width:r.paneWidth,height:r.height,overflow:"hidden"},children:n=>o(i,{model:r,handle:n})})}),c=p;export{c as default};
2
+ //# sourceMappingURL=LinearGraphDisplay-456PTWEO.js.map
@@ -0,0 +1,3 @@
1
+ import{d as po,i as Ti,j as Ii,l as Vt,m as Xt,n as jt,o as Gi,p as _i}from"./chunk-WZOAYGF5.js";import{$ as $r,$b as si,A as Sr,Aa as Do,Ac as yi,B as Mo,Ba as Vo,Bb as Zr,Bd as Fi,C as No,Ca as Xo,Cb as Jr,D as Po,Da as jo,Db as qo,Dc as ki,E as Ze,Ea as Yo,F as Ne,Fa as ot,Fb as Qr,G as Br,Ga as _t,H as we,Ha as Dr,Hb as oi,Hc as xi,I as Qe,Ic as Si,J as Go,Ja as Vr,Jb as be,Jc as Ri,K as et,Ka as zo,Kb as ni,Lb as Ct,Lc as Te,M as _o,Mb as ri,N as Z,Na as Pe,Nb as ye,Nc as vi,O as J,Ob as Ee,Oc as Li,P as le,Pb as Jo,Pc as Mi,Qb as Qo,Qc as Ni,Rc as tn,Sc as Pi,U as Cr,V as Or,Vc as Ei,W as Wr,X as se,Xb as nt,Yb as ii,_ as Et,_b as ai,_c as Ai,aa as At,b as Le,ba as Bo,bb as Xr,bc as en,cb as Bt,cc as Ot,db as jr,dc as rt,fc as di,gb as Yr,gc as pi,gd as Bi,hb as zr,hc as ci,ic as mi,ja as Co,jc as Ae,ka as Tt,kc as Wt,kd as Ci,lc as de,ma as Oo,mc as $t,nd as on,oc as Ft,pb as Kr,pc as Ht,pd as Oi,qa as Wo,qd as Wi,ra as I,rb as Ur,rc as li,rd as $i,sb as Ko,t as Ro,ta as $o,tb as qr,tc as ui,u as wr,uc as hi,v as vo,va as Gt,vc as fi,w as br,wb as Uo,wc as Dt,x as yr,xa as tt,xc as gi,y as kr,ya as Fo,yc as wi,z as xr,za as Ho,zc as bi}from"./chunk-UXUARTLL.js";import{b as ei,c as Zo,e as ti}from"./chunk-3LEQAY3J.js";import{c as go,d as Ve,e as wo,g as bo}from"./chunk-5URP77TX.js";import{a as X,b as dr}from"./chunk-ECNJGM74.js";import{a as Hr}from"./chunk-7N53GARW.js";import{$ as Je,A as Eo,B as Ao,C as To,G as Io,L as Tr,M as Ir,Q as Nt,aa as Gr,b as Rr,ba as _r,c as ce,ca as Pt,d as vr,f as Lr,g as Mr,l as Nr,m as Pr,n as Er,o as Ar}from"./chunk-JYU2J2B7.js";import{Ea as Lt,F as lr,H as kt,Ha as Ue,Ia as Mt,J as Ye,Ja as q,K as xt,Ka as qe,La as Lo,S as xo,W as ze,X as Ke,a as Me,aa as So,b as me,c as je,ga as St,ha as Rt,ia as ur,ja as hr,l as ko,la as vt,ma as fr,qa as gr,r as mr}from"./chunk-RCXMPQKP.js";import{a as pr}from"./chunk-ZQOMV674.js";import{p as ar,q as yo}from"./chunk-3W7WSULH.js";import{A as Fe,D as pe,E as uo,F as fe,H as ho,I as He,M as ie,O as or,P as nr,V as rr,a as We,b as Jn,c as Qn,d as er,e as ee,f as co,g as mo,n as lo,o as te,sa as ae,ta as ir,ua as Xe,x as $e,y as _}from"./chunk-YGIWBVPD.js";import{a as cr,d as Fr,i as It}from"./chunk-ZCNHZLT2.js";import{b as U}from"./chunk-DUU6T2I5.js";import{a as yt,b as sr}from"./chunk-TMM73K4C.js";import{e as Zn}from"./chunk-EGZZ3ADM.js";import{a as ge,c as De,d as fo,i as tr}from"./chunk-IMCJTUCX.js";import{f as Un,g as bt,h as qn,j as re}from"./chunk-5L276I7O.js";var ke=JBrowseExports["@mui/material/SvgIcon"],Ms=e=>ke!=null&&e in Object(ke)?ke[e]:Object.assign(function(){throw new Error("This JBrowse does not provide '"+e+"' from '@mui/material/SvgIcon' to plugins: GraphGenomeView was built for a different JBrowse version, so update the plugin or JBrowse")},{jbrowseHostMissing:e}),j=Ms("createSvgIcon"),yp=ke&&ke.__esModule?ke.default:ke;var Ns=.015;function Yt({graph:e,span:t,rowY:o,positions:n}){let r=t*Ns,i={...e,edges:ir(e.edges)},a=yr(i),s=new Map(i.nodes.map(c=>[c.id,c])),d=[];for(let c of a){let l=c.refSpan-c.pathLength;l>=xo&&d.push({nodeIds:c.nodeIds,bp:l});let h=Math.max(c.refSpan,r),u=c.pathLength>0?h/c.pathLength:0;c.nodeIds.forEach((f,g)=>{let w=s.get(f);if(w){let k=c.nodeOffsets[g],R=h/c.nodeIds.length,b=x=>c.start+x*u,y=o(w);n[f]=u?[{x:b(k),y},{x:b(k+w.length),y}]:[{x:c.start+g*R,y},{x:c.start+(g+1)*R,y}]}})}let p=q(i),m=Object.keys(n);for(let c of m){let l=n[c].at(-1).x;for(let h of p.get(c)??[]){let u=s.get(h);if(u&&!(h in n)){let f=o(u);n[h]=[{x:l,y:f},{x:l+r,y:f}],m.push(h)}}}return d}function Ps(e,t){let o=new Map;for(let r of e.nodes)if(Fe(r)){let i=ge(r.stable.refName);o.set(i,(o.get(i)??0)+r.length)}let n=new Map(t.map((r,i)=>[r,i]));return[...o.keys()].sort((r,i)=>(n.get(r)??1/0)-(n.get(i)??1/0)||o.get(i)-o.get(r)||Xe(r,i))}function Hi(e,t,o=[]){let n=pe(e),r=Ps(e,o);if(n.length===0||r.length===0)return;let i=He(n,t),a=new Map(r.map((l,h)=>[l,h+1])),s=fe(n),d=r.length+1,p=Yt({graph:e,span:i,rowY:l=>{let h=l.stable;return((h?a.get(ge(h.refName)):void 0)??d)*ee},positions:s}),c=[{label:ge(n[0].stable.refName),y:0},...r.map(l=>({label:l,y:a.get(l)*ee}))];return{nodePositions:s,rowLabels:c,sampleRows:r,referenceAxis:!0,pixelRows:!0,alleleDeletions:p}}function Es(e){let t=new Set;for(let o of e.nodes)o.stable&&t.add(o.stable.rank);return new Map([...t].sort((o,n)=>o-n).map((o,n)=>[o,n]))}function Di(e,t){let o=pe(e);if(o.length===0)return;let n=He(o,t),r=Es(e),i=fe(o),a=Yt({graph:e,span:n,rowY:d=>(d.stable?r.get(d.stable.rank)??r.size:r.size)*ee,positions:i}),s=[...r].map(([d,p])=>({label:d===0?"Reference (rank 0)":`Rank ${d}`,y:p*ee}));return{nodePositions:i,rowLabels:s,referenceAxis:!0,pixelRows:!0,alleleDeletions:a}}var As=12,nn=ee;function Vi(e){return 10+8*Math.log2(1+e.length)}function ji(e,t){return ae(e.at,t.at)||ae(e.side,t.side)||ae(e.hops,t.hops)}var Xi={at:1/0,side:0,hops:0};function rn(e){let t=new Map(e.nodes.map(n=>[n.id,n])),o=Gs(e);return e.nodes.map(n=>n.id).sort((n,r)=>ji(o.get(n)??Xi,o.get(r)??Xi)||ae(t.get(n).name,t.get(r).name)||ae(n,r))}function Ts(e,t){let o=new Set(e.nodes.map(m=>m.id)),n=new Map(t.map(m=>[m.id,m.stable.start])),r=new Map,i=new Map;t.forEach((m,c)=>{i.set(m.id,t[c-1]?.id),r.set(m.id,t[c+1]?.id)});let a=t[0]?.id,s=(m,c)=>{let l=r.get(m);r.set(m,c),i.set(c,m),r.set(c,l),l!==void 0&&i.set(l,c)},d=(m,c)=>{let l=i.get(m);l===void 0?(a=c,i.set(c,void 0),r.set(c,m),i.set(m,c)):s(l,c)};for(let m of e.paths??[]){let c=0,l=0,h;for(let w of m.nodeIds){let k=n.get(w);k!==void 0&&(h!==void 0&&k!==h&&(k>h?c++:l++),h=k)}let u=l>c?[...m.nodeIds].reverse():m.nodeIds,f,g=new Set;for(let w of u)if(r.has(w)){if(f===void 0)for(let k of g)d(w,k);f=w}else o.has(w)&&(f===void 0?g.add(w):(s(f,w),f=w))}let p=[];for(let m=a;m!==void 0;m=r.get(m))p.push(m);return p}function Is(e,t,o){let n=[...t.entries()].sort(([s,d],[p,m])=>ji(d,m)||ae(s,p)).map(([s])=>s),r=n.length;for(let s of n){let d=t.get(s);for(let p of e.get(s)??[])o.has(p)&&!t.has(p)&&(t.set(p,{at:d.at,side:1,hops:d.hops+1}),n.push(p))}let i=new Set(n.slice(r)),a=new Set;for(let s of i){if(a.has(s))continue;let{at:d}=t.get(s),p=[s];a.add(s);let m=!0;for(let c of p){let{hops:l}=t.get(c),h=!0,u=!1;for(let f of e.get(c)??[]){let g=t.get(f);g&&(g.at===d&&i.has(f)?(h&&=g.hops<=l,a.has(f)||(a.add(f),p.push(f))):g.at!==d&&(u||=g.at<d,m&&=g.at<d))}m&&=!h||u}if(m)for(let c of p){let l=t.get(c);t.set(c,{...l,side:-1,hops:-l.hops})}}}function Gs(e){let t=e.nodes.filter(_).sort((n,r)=>ae(n.stable.refName,r.stable.refName)||ae(n.stable.start,r.stable.start)||ae(n.name,r.name)),o=new Map;return Ts(e,t).forEach((n,r)=>{o.set(n,{at:r,side:0,hops:0})}),Is(q(e),o,new Set(e.nodes.map(n=>n.id))),o}function _s(e){let t=new Map(e.nodes.map(c=>[c.id,c])),o=rn(e),n=new Map(o.map((c,l)=>[c,l])),r=c=>_(t.get(c)),i=new Map(o.map(c=>[c,[]])),a=new Map(o.map(c=>[c,[]])),s=(c,l)=>{i.get(l).push(c),a.get(c).push(l)};for(let c of e.edges)c.from===c.to||!n.has(c.from)||!n.has(c.to)||(n.get(c.from)<n.get(c.to)?s(c.from,c.to):s(c.to,c.from));let d=o.filter(r);for(let c=1;c<d.length;c++)s(d[c-1],d[c]);let p=new Map;for(let c of o){let l=0;for(let h of i.get(c))l=Math.max(l,p.get(h)+1);p.set(c,l)}for(let c=o.length-1;c>=0;c--){let l=o[c],h=a.get(l);if(r(l)||h.length===0)continue;let u=1/0;for(let w of h)u=Math.min(u,p.get(w));let f=p.get(l),g=Math.max(f,u-1);p.set(l,Math.floor((f+g)/2))}let m=[];for(let c of o)(m[p.get(c)]??=[]).push(c);return{layers:m,layerOf:p,preds:i}}function Yi(e){if(!e.nodes.some(_))return;let t=new Map(e.nodes.map(c=>[c.id,c])),o=c=>_(t.get(c)),{layers:n,layerOf:r,preds:i}=_s(e),a=n.map(c=>{let l=0;for(let h of c)l=Math.max(l,Vi(t.get(h)));return l}),s=[],d=0;for(let c=0;c<n.length;c++)s[c]=d,d+=a[c]+As;let p=new Map;for(let c of n){let l=[];for(let u of c){if(o(u)){p.set(u,0);continue}let f=i.get(u).filter(w=>p.has(w)),g=0;for(let w of f)g+=p.get(w)/f.length;l.push({id:u,ideal:g===0?nn:g})}l.sort((u,f)=>u.ideal-f.ideal);let h=new Set([0]);for(let{id:u,ideal:f}of l){let g=Math.round(f/nn);g===0&&(g=f>=0?1:-1);for(let w=1;h.has(g);w++)h.has(g+w)?h.has(g-w)||(g-=w):g+=w;h.add(g),p.set(u,g*nn)}}let m={};for(let c of e.nodes){let l=r.get(c.id),h=Vi(c),u=s[l]+a[l]/2,f=p.get(c.id);m[c.id]=[{x:u-h/2,y:f},{x:u+h/2,y:f}]}return{nodePositions:m,referenceAxis:!1,pixelRows:!0}}var zt=1.3;function Kt(e){return e.rows.reduce((t,o)=>Math.max(t,se(o)),se(e.reference))}function Bs(e,t){let{widthPx:o}=t;return[e.reference,...e.rows].reduce((n,r,i)=>{let{row:a,base:s,suffix:d}=Or(e,i,t.comparing),p=Cr(`${s}${d}`,t.measure);return Math.max(n,se(a)*o/Math.max(o-p,o/4))},0)}function Ie(e,t={rowPx:ee,readouts:!0},o){let n=t.readouts&&o?Bs(e,o):0;return{maxX:e.origin+Math.max(n,Kt(e)*(t.readouts?zt:1)),maxY:e.rows.length*t.rowPx}}function Ge(e,t,o){return e?o&&!o.labelled?[]:[e.reference,...e.rows].map((n,r)=>({label:n.label,y:r*(o?.rowPx??ee)})):t?.rowLabels??[]}function an(e,t){let o=Ne(e,t);return o&&zi(e,o,t)}function zi(e,t,o){let n=pe(e);if(n.length===0)return;let r=o?n.filter(a=>uo(a,o)):n;return{nodePositions:fe(r.length>0?r:n),rowLabels:Ge(t),referenceAxis:!0,pixelRows:!0,extent:Ie(t)}}var qi="Force-directed layout",_e=e=>e.nodes.some(_),Ki=e=>_e(e)&&(e.paths?.length??0)>1,Ui=e=>_e(e)&&e.nodes.some(Fe),Ut=[{value:"auto",label:"Anchored",description:"x is reference bp, one row per stable rank. Needs rGFA tags or a reference path.",run:(e,t)=>Di(e,t),cutMargins:!0,wholeWalks:!1,available:_e,drawsLocally:_e,drawsNodes:!0},{value:"samplerows",label:"Sample rows",description:"x is reference bp, one row per contributing assembly. Needs rGFA tags or a reference path.",run:(e,t,o)=>Hi(e,t,o),cutMargins:!0,wholeWalks:!1,available:Ui,drawsLocally:Ui,drawsNodes:!0},{value:"walkrows",label:"Walk rows",description:"x is each walk's own bp: one bar per haplotype, blue on the reference's path and purple off it, so a repeat expansion reads as bar length, and each bar boxes its haplotype's own genes where the session has them. Needs a reference and two or more walks.",run:an,cutMargins:!1,wholeWalks:!0,available:Ki,drawsLocally:Ki,drawsNodes:!1},{value:"ordered",label:"Ordered",description:"x is reference order, not bp: every node gets room, bubbles read as lenses. Needs rGFA tags or a reference path.",run:e=>Yi(e),cutMargins:!1,wholeWalks:!1,available:_e,drawsLocally:_e,drawsNodes:!0},{value:"tubemap",label:"Tube map",description:"sequenceTubeMap: every path a coloured tube through boxed nodes, columns in node order and node widths log-scaled. Needs P or W lines.",run:wr,cutMargins:!1,wholeWalks:!1,available:Ro,drawsLocally:Ro,drawsNodes:!1},{value:"tubemapref",label:"Tube map on reference",description:"The tube map with each column at the reference bp it covers, so the tubes line up with the tracks around them. Needs P or W lines and a reference path.",run:br,cutMargins:!0,wholeWalks:!1,available:vo,drawsLocally:vo,drawsNodes:!1},{value:"force",label:qi,description:"OGDF FMMM (wasm) or stress, whichever engine is chosen.",run:()=>{},cutMargins:!1,wholeWalks:!1,available:()=>!0,drawsLocally:()=>!1,drawsNodes:!0}],Cs=Ut.map(e=>e.value);function sn(e,t){return!Y(e).drawsLocally(t)}function Y(e){return Ut.find(t=>t.value===e)??Ut[0]}function qt(e){if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.horizontalScroll=="function"&&typeof t.zoomTo=="function"&&"coarseDynamicBlocks"in t&&"dynamicBlocks"in t}function dn(e){return e.reduce((t,o)=>t&&t.end-t.start>=o.end-o.start?t:o,void 0)}function xe(e){return e.initialized?e.dynamicBlocks.contentBlocks:[]}function Zi(e,t){let o=dn(xe(e).filter(i=>i.refName===t.refName&&i.assemblyName===t.assemblyName)),{bpPerPx:n}=e;if(!o||!(n>0))return;let r=o.offsetPx-e.offsetPx;return o.reversed?{scale:-1/n,translateX:r+o.end/n}:{scale:1/n,translateX:r-o.start/n}}function pn(e){let t=dn(xe(e)),o=t?.displayedRegionIndex===void 0?void 0:e.displayedRegions[t.displayedRegionIndex];return t&&e.bpPerPx>0?{refName:t.refName,assemblyName:t.assemblyName,start:t.start,end:t.end,bpPerPx:e.bpPerPx,span:e.bpPerPx*e.width,regionStart:o?.start??t.start,regionEnd:o?.end??t.end}:void 0}function Ji(e){let t=dn(xe(e)),o=t&&t.start-(t.offsetPx-e.offsetPx)*e.bpPerPx;return o===void 0?void 0:{start:o,end:o+e.bpPerPx*e.width}}function Os(e,t,o=!0){let n=e.end-e.start,r=o?Math.max(0,Math.min(e.span,(t-n)/2)):0,i=Math.max(e.regionStart,Math.floor(e.start-r)),a=Math.min(e.regionEnd,Math.ceil(e.end+r)),s=a-i-t;return s>0&&(i+=Math.floor(s/2),a-=Math.ceil(s/2)),{refName:e.refName,assemblyName:e.assemblyName,start:i,end:a}}function Qi(e){return e==="force"?"snapped":Y(e).cutMargins?"margins":"window"}function Ws(e){return 2**(Math.ceil(Math.log2(e)*2-1e-9)/2)}var mm=2;function lm(e,t=1){let o=Ws(e.span)*t,n=Math.round((e.start+e.end)/o)*(o/2);return{refName:e.refName,assemblyName:e.assemblyName,start:Math.max(e.regionStart,Math.round(n-.75*o)),end:Math.min(e.regionEnd,Math.round(n+.75*o))}}function um(e,t){return e?.refName===t.refName&&e.assemblyName===t.assemblyName&&e.start===t.start&&e.end===t.end}function hm(e,t,o=!0){if(e?.refName!==t.refName||e.assemblyName!==t.assemblyName)return!1;if(o)return e.start<=t.start+1&&t.end<=e.end+1;let n=Os(t,1/0,!1);return Math.abs(e.start-n.start)<1&&Math.abs(e.end-n.end)<1}var $s=/^[^#]+#\d+$/,Fs=/^([^#]+)\.(\d+)$/;function Hs({aliases:e}){return e.find(t=>$s.test(t))}function Ds({name:e}){let t=Fs.exec(e);return t?`${t[1]}#${t[2]}`:void 0}function Vs(e,t,o){let n=e.assemblyNameToPanSN??{},r=new Set(Object.values(n)),i={},a=t.filter(s=>s.name!==o);for(let[s,d]of[[Hs,t],[Ds,a]])for(let p of d){let m=s(p);m!==void 0&&!r.has(m)&&!(p.name in n)&&!(p.name in i)&&(i[p.name]=m,r.add(m))}return Object.keys(i).length===0?e:{...e,assemblyNameToPanSN:{...i,...n}}}function ea(e,t){return e.find(o=>o.name===t||o.aliases.includes(t))?.name??t}function Xs(e,t){let o=a=>ea(t,a),n=e.assemblyNames??[],r=e.assemblyNameToPanSN??{};if([...n,...Object.keys(r)].every(a=>o(a)===a))return e;let i=new Map;for(let[a,s]of Object.entries(r)){let d=o(a);(d===a||!i.has(d))&&i.set(d,s)}for(let a of n){let s=o(a);s!==a&&!i.has(s)&&i.set(s,a)}return{...e,assemblyNames:n.map(o),assemblyNameToPanSN:Object.fromEntries(i)}}var js=new Set(["GbzBaseSyntenyAdapter","GfaWalksSyntenyAdapter"]);function ta(e,t){let o=It(t);if(!js.has(cr(o.type))&&!Fr(o))return o;let n=re(e).assemblyManager.assemblyList.map(i=>({name:po(i,"name"),aliases:po(i,"aliases")})),[r]=yt(t);return Vs(Xs(o,n),n,r===void 0?void 0:ea(n,r))}var Ys="fit",Zt={fit:"Fit graph to track height",grow:"Fit graph, track grows to hold it",fixed:"Reference fills track, rest clipped"};function at(e){return e==="fixed"}function cn(e,t,o,n,r,i,a,s={}){return at(e)?Vo(t,o,n,i,a,s):Xo(t,o,n,r,i,a,s)}function mn(e,t){let o=[],n=i=>{for(let a=0;a<i.length;a++){let s=i[Math.max(0,a-1)],d=i[a];(a>0||i.length===1)&&o.push(s.x,s.y,d.x,d.y)}};for(let i of Object.values(t.nodePositions))n(i);let r=t.deletionRoutes??{};return e.edges.forEach((i,a)=>{let s=r[a],d=t.nodePositions[i.from],p=t.nodePositions[i.to];if(s?.length)n(s);else if(d?.length&&p?.length){let m=te(i),c=m.from==="end"?d.at(-1):d[0],l=m.to==="start"?p[0]:p.at(-1);o.push(c.x,c.y,l.x,l.y)}}),Float64Array.from(o)}function it(e,t,o,n=0){let r=1/0,i=-1/0,a=(s,d)=>{let p=Math.max(0,t-s,s-o);(p===0||n>0)&&(r=Math.min(r,d+n*p),i=Math.max(i,d-n*p))};for(let s=0;s+3<e.length;s+=4){let d=e[s],p=e[s+1],m=e[s+2],c=e[s+3];a(d,p),a(m,c);for(let l of[t,o])Math.min(d,m)<l&&l<Math.max(d,m)&&a(l,p+(c-p)*(l-d)/(m-d))}return i>=r?{minY:r,maxY:i}:void 0}function ln({pieces:e}){return Float64Array.from(e.flatMap(t=>[t.x0,t.y0,t.x1,t.y1]))}function zs(e,t,o){return Math.min(Math.max(e,Math.min(t,o)),Math.max(t,o))}var oa=1;function un({segments:e,reference:t,held:o,scale:n,translateX:r,bounds:i,paneWidth:a,paneHeight:s,pads:{padTop:d=I,padBottom:p=I}={}}){let m=s-d-p,c=(g,w)=>w?zs(g,d-w.minY*n,d+m-w.maxY*n):g,l=it(t,-1/0,1/0),h=c(d+m/2-n*(l?(l.minY+l.maxY)/2:i.minY+i.h/2),{minY:i.minY,maxY:i.minY+i.h}),u=-r/n,f=(a-r)/n;return c(c(h,it(e,u,f,oa)),o)}function Ks(e,t,{padTop:o=I,padBottom:n=I}={}){return Math.ceil(o+n+e.h*t)}var gl=j(U("path",{d:"M19 15.18V7c0-2.21-1.79-4-4-4s-4 1.79-4 4v10c0 1.1-.9 2-2 2s-2-.9-2-2V8.82C8.16 8.4 9 7.3 9 6c0-1.66-1.34-3-3-3S3 4.34 3 6c0 1.3.84 2.4 2 2.82V17c0 2.21 1.79 4 4 4s4-1.79 4-4V7c0-1.1.9-2 2-2s2 .9 2 2v8.18c-1.16.41-2 1.51-2 2.82 0 1.66 1.34 3 3 3s3-1.34 3-3c0-1.3-.84-2.4-2-2.82"}),"Route");var kl=j(U("path",{d:"M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6"}),"Settings");var Rl=["view","cut"],na="view",vl=[{fit:"fit",frame:"view",label:"Fit graph around the view to track",helpText:"The reference in view and every variant that touches it fit the track, with some of the graph on either side; the scale changes smoothly as you pan, and the rest runs on past the track edges"},{fit:"fit",frame:"cut",label:"Fit whole loaded graph to track height",helpText:"All of the graph loaded around the view fits the track height, at one scale while you pan inside it"},{fit:"grow",label:Zt.grow},{fit:"fixed",label:Zt.fixed}];function hn(e){return $e(e)?fn(e):void 0}function fn(e){return{sample:ge(e.stable.refName),haplotype:De(e.stable.refName),refName:fo(e.stable.refName),start:e.stable.start,end:e.stable.start+e.length}}function ra(e,t,o,n){let r=new Map,i=m=>{let c=Se(o,m),l=`${c} ${m.refName} ${m.start}`;c!==void 0&&c!==n&&r.set(l,{assemblyName:c,refName:m.refName,start:m.start,end:m.end})},a=hn(t);a&&i(a);let s=new Map(e.nodes.map(m=>[m.id,m.length])),d=new Set((e.paths??[]).flatMap(m=>or(m,m.nodeIds.reduce((c,l)=>c+(s.get(l)??0),0))?[]:[ie(m.name).name])),p=e.threadFold?[]:(e.pathVisits?.get(t.name)??[]).filter(m=>!d.has(ie(m.path).name));for(let m of p)i({sample:ge(m.path),haplotype:De(m.path),refName:fo(m.path),start:m.start,end:m.start+t.length});return[...r.values()]}function ia(e,t,o){let n=new Map,r=new Set((e.paths??[]).flatMap(a=>De(a.name)??[])),i=new Set;for(let a of e.nodes){if(!$e(a)||a.stable.rank===0)continue;let s=a.stable.refName;if(i.has(s))continue;if(r.size>0&&!r.has(De(s)??"")){i.add(s);continue}let d=fn(a),p=n.get(s);if(p){p.start=Math.min(p.start,d.start),p.end=Math.max(p.end,d.end);continue}let m=Se(t,d);m===void 0||m===o?i.add(s):n.set(s,{stableRefName:s,assemblyName:m,refName:d.refName,start:d.start,end:d.end})}return[...n.values()]}function Us(e,t){let o=[...e].sort((i,a)=>i.start-a.start),n,r;for(let i of o)r=r&&i.start-r.end<=t?{start:r.start,end:Math.max(r.end,i.end)}:{start:i.start,end:i.end},(!n||r.end-r.start>n.end-n.start)&&(n=r);return n}function qs(e){return`${e.haplotype??e.sample}\0${e.refName}`}function aa(e,{maxGap:t=1/0}={}){let o=new Map;for(let r of e.nodes)if($e(r)){let i=fn(r),a=qs(i),s=o.get(a);s?(s.spans.push({start:i.start,end:i.end}),s.rank=Math.min(s.rank,r.stable.rank)):o.set(a,{sample:i.sample,haplotype:i.haplotype,refName:i.refName,rank:r.stable.rank,spans:[{start:i.start,end:i.end}]})}let n=new Map;for(let r of o.values()){let i=Us(r.spans,t);if(i){let a={sample:r.sample,haplotype:r.haplotype,refName:r.refName,start:i.start,end:i.end,rank:r.rank,nodeCount:r.spans.length},s=r.haplotype??r.sample,d=n.get(s);(!d||a.nodeCount>d.nodeCount)&&n.set(s,a)}}return[...n.values()].sort((r,i)=>+(r.rank!==0)-+(i.rank!==0)||r.sample.localeCompare(i.sample)||(r.haplotype??"").localeCompare(i.haplotype??""))}function Se(e,t){return(t.haplotype===void 0?void 0:e(t.haplotype))??e(t.sample)}function sa(e,t){let o=new Map,n=r=>`${r.sample} ${r.refName}`;for(let r of e)r.haplotype!==void 0&&o.set(n(r),(o.get(n(r))??0)+1);return e.flatMap(r=>{let i=(o.get(n(r))??0)>1?t(r.haplotype):Se(t,r);return i===void 0?[]:[{...r,sample:i}]})}function Jt(e){return`${e.refName}:${e.start+1}-${e.end}`}function Zs(e){return X(e)&&e.type==="LinearGenomeView"&&typeof e.id=="string"&&typeof e.navToLocString=="function"&&Array.isArray(e.assemblyNames)}function da(e){return e.flatMap(t=>X(t)&&dr(t.views)?[t,...t.views]:[t])}function Hl(e){return new Set(da(e).flatMap(t=>X(t)&&typeof t.id=="string"?[t.id]:[]))}function Be({views:e,connectedViewId:t,assemblyName:o}){let n=da(e).filter(i=>Zs(i)).filter(i=>i.assemblyNames.includes(o));return n.find(i=>i.id===t)??(n.length===1?n[0]:void 0)}function gn(e,t){let o=e.assemblyManager;return o?.has(t)?o.get(t)?.name??t:t}function zl(e,t){let o=e.assemblyManager,n=o?.has(t.assemblyName)?o.get(t.assemblyName):void 0;return n?{...t,assemblyName:n.name,refName:n.getCanonicalRefName2?.(t.refName)??t.refName}:t}function wn(e,t){return yt(t).map(o=>gn(e,o))}function bn(e,t,o){o.catch(n=>{console.error(`[GraphGenomeView] ${t}`,n),e.notifyError?.(`${t}: ${n}`,n)})}var Js=1e3;function yn(e,t=Js){let o=Math.max(0,Math.ceil((t-(e.end-e.start))/2));return{...e,start:Math.max(0,e.start-o),end:e.end+o}}function ca(e,t){return t?e.map(o=>o.rank===0?{...o,sample:t.assemblyName,haplotype:void 0,refName:t.refName,start:t.start,end:t.end}:o):e}function Kl({session:e,location:t,assembly:o,connectedViewId:n,tracks:r=[]}){let i=Be({views:e.views,connectedViewId:n,assemblyName:o}),a;return i?(bn(e,`Could not show ${o} ${Pe(t)}`,Promise.resolve(i.navToLocString(Jt(t),o))),a=i.id):a=e.addView("LinearGenomeView",{displayName:`${o} \u2014 ${Pe(t)}`,init:{assembly:o,loc:Jt(t),tracks:r}}).id,a}function Ul({session:e,trackId:t,assembly:o,loc:n}){let r=Be({views:e.views,connectedViewId:void 0,assemblyName:o});r?.showTrack?(bn(e,`Could not show ${o} ${n}`,Promise.resolve(r.navToLocString(n,o))),r.showTrack(t)):e.addView("LinearGenomeView",{init:{assembly:o,loc:n,tracks:[t]}})}function ql({session:e,location:t,assembly:o,connectedViewId:n}){Be({views:e.views,connectedViewId:n,assemblyName:o})&&e.addHighlight?.({refName:t.refName,start:t.start,end:t.end,assemblyName:o})}function pa(e,t){let o=t===void 0?void 0:e.tracks.find(n=>n.trackId===t);return o?wn(e,o):[]}function Zl({session:e,contributors:t,trackId:o,graphTrackId:n}){let r=pa(e,n),i=pa(e,o),a=t.filter(p=>i.includes(p.sample)),s=a.length>=2?a:t,d={init:{views:s.map(p=>({assembly:p.sample,loc:Jt(p),...n!==void 0&&r.includes(p.sample)?{tracks:[n]}:{}})),tracks:o?s.slice(1).map(()=>[o]):[],collapseEmptyRows:!0}};bn(e,"Could not open the synteny view",e.launchView("LinearSyntenyView",d))}function kn(e){return e.walkStrip&&e.mode.drawsNodes&&!e.drawsPicture&&!e.popped&&!e.host&&e.walks>1}function xn(e,t){return e.wholeWalks||t.walkStrip&&!t.host}var st=6,ua=260,Qs=11,ed=3,td="#111",ma=3;function Sn(e,t,o){let n=e.pathVisits?.get(o.name)??[],r=[];for(let i of t){let a=i.along;if(!a)continue;let s=ie(i.name).name;for(let d of n){if(d.path!==s)continue;let{start:p,end:m}=No(a,d.start,d.start+o.length);m>0&&p<se(i)&&r.push({row:i.name,start:p,bp:m-p})}}return r}var la=new WeakMap;function od(e,t){let o=la.get(e);if(o||(o=new Map,la.set(e,o)),o.has(t))return o.get(t);let n=new Map(e.nodes.map(s=>[s.id,s.length])),r=ie(t).name,i=(e.paths??[]).filter(s=>ie(s.name).name===r),a;if(i.every(s=>s.start!==void 0)){a={ids:[],starts:[],ends:[]};for(let s of[...i].sort((d,p)=>d.start-p.start)){let d=s.start;for(let p of s.nodeIds){let m=n.get(p)??0;a.ids.push(p),a.starts.push(d),a.ends.push(d+m),d+=m}}}return o.set(t,a),a}function nd(e,t,o,n){let r=t.along,i=r&&od(e,t.name),a=r?Mo(r,o):-1;if(!r||!i||a<0||a>t.bp)return;let s=r.start+a,d=.5/n,p=Et(r,t.bp),m=Math.max(s-d,p.start),c=Math.min(s+d,p.end),l=er(i.starts.length,g=>i.ends[g]<=m),h,u=-1,f=!1;for(let g=l;g<i.starts.length&&i.starts[g]<c;g++){let w=i.ends[g]-i.starts[g],k=i.starts[g]<=s&&s<i.ends[g];(w>u||w===u&&k&&!f)&&(u=w,h=i.ids[g],f=k)}return h}function dt(e,t){let o=t.maxHeight??ua,n=t.labelPx??e.rows.reduce((h,u)=>Math.max(h,u.label.length),e.reference.label.length)*me+16,r=e.rows.length+1,{rowPx:i,barPx:a,labelled:s,readouts:d}=Tt(r,o-2*st,ed),p=Math.max(Kt(e),1),m=s?n:st,l=Math.max(1,t.width-m-st)/(p*(d?zt:1));return{scaleX:l,scaleY:1,translateX:m-e.origin*l,translateY:st+i/2,width:t.width,height:r*i+2*st,rowPx:i,barPx:a,readouts:d,labelled:s,boxesGenes:At(i,a)}}function rd(e,t,o,n){let r=Math.round((n-t.translateY)/t.rowPx),i=[e.reference,...e.rows][r],a=(o-t.translateX)/t.scaleX-e.origin;return i&&r>=0&&a>=0&&a<=se(i)?{index:r,row:i,offset:a}:void 0}function id(e,t,o){let n=new Map([e.reference,...e.rows].map((i,a)=>[i.name,a])),r=i=>(e.origin+i)*t.scaleX+t.translateX;return _o("g",{"data-testid":"graph-walk-marks"},o.flatMap(i=>{let a=n.get(i.row);if(a===void 0)return[];let s=a*t.rowPx+t.translateY,d=r(i.start),p=Math.max(2,i.bp*t.scaleX),m=c=>Z("rect",{x:d,y:c,width:p,height:ma,fill:td});return[m(s-t.barPx/2-ma-1),m(s+t.barPx/2+1)]}))}function Rn(e,t,o=new Set){return _o("g",{"font-family":"sans-serif","font-size":Qs,fill:"#333"},(t.labelled?[e.reference,...e.rows]:[]).map((n,r)=>Z("text",{x:6,y:r*t.rowPx+t.translateY+4,"font-weight":o.has(n.name)?600:void 0},n.label)))}function vn(e,t,o){if(t?.size)return e.boxesGenes?o:{untracked:0,unread:0,...o,crowded:!0}}function ct(e,t){let o=t?[t.reference,...t.rows]:[];return(e?.walks??[]).flatMap(n=>{let r=n.walkPasses,i=we([n])[0];return r?.passes.length&&!o.some(a=>Qe(n.name,a)&&!!i&&Go(i,a))?[{walk:n.name,bp:n.extent?n.extent.end-n.extent.start:n.bp,ownLengths:n.ownLengths,ownInk:r.ownInk,runs:r.runs.map(a=>({...a,ink:Br(r,a.pass)})),passes:r.passes.map((a,s)=>({pass:s,start:a.start,end:a.end,repeatBp:a.repeatBp,againBp:a.againBp,reversedBp:a.reversedBp,text:r.bundled?`${s+1}`:a.title,ink:a.ink,reversed:a.reversed})),bundled:r.bundled}]:[]})}var Ln={"font-family":"Helvetica, Arial, sans-serif","font-size":11},ad=6.2,Qt=12,sd=13,pt=34,Ce=40,Oe=16,ha=4,eo=Ce+Oe+26,dd=(e,t)=>{let o=e/t,n=10**Math.floor(Math.log10(o));return[1,2,5,10].map(r=>r*n).find(r=>r>=o)??o};function Mn(e,t,o){let n=o-2*Qt,r=f=>Qt+(e.bp>0?f/e.bp*n:0),i=n>0?e.bp/n:1,a=[];for(let f of e.runs){let g=a.at(-1);g?.pass===f.pass&&f.start-g.end<i?g.end=f.end:a.push({...f})}let s=e.bp>0?dd(e.bp,8):1,d=Array.from({length:e.bp>0&&e.ownLengths?Math.floor(e.bp/s)+1:0},(f,g)=>g*s),p=Z("text",{x:Qt,y:sd,...Ln,"font-weight":"bold"},e.ownLengths?`${t} along its length`:`${t} along its drawn route`),m=[],c=e.passes.flatMap(f=>{let g=[];for(let S of e.runs){let B=g.at(-1);S.pass===f.pass&&B&&S.start-B.end<i?B.end=S.end:S.pass===f.pass&&g.push({start:S.start,end:S.end})}let w=ce(f.ink),k=g.map(S=>Z("path",{d:`M${r(S.start)},${pt+3}V${pt}H${r(S.end)}V${pt+3}`,fill:"none",stroke:w,"stroke-width":1.5})),R=g.slice(1).map((S,B)=>`M${r(g[B]?.end??S.start)},${pt}H${r(S.start)}`).join(""),b=g.reduce((S,B)=>!S||B.end-B.start>S.end-S.start?B:S,void 0),y=f.text.length*ad/2+2,x=b&&Math.min(Math.max((r(b.start)+r(b.end))/2,y),o-y),P=x!==void 0&&m.every(S=>x+y<=S.from||x-y>=S.to);P&&m.push({from:x-y,to:x+y});let M=P&&Z("text",{x,y:pt-3,...Ln,"font-weight":"bold",fill:w,"text-anchor":"middle"},f.text),V=Z("path",{d:R,fill:"none",stroke:w,"stroke-width":.75,"stroke-dasharray":"1 2"});return(R?[V]:[]).concat(k,M?[M]:[])}),l=Z("rect",{x:Qt,y:Ce,width:n,height:Oe,fill:ce(e.ownInk)}),h=a.map(f=>Z("rect",{x:r(f.start),y:Ce,width:Math.max(.5,r(f.end)-r(f.start)),height:Oe,fill:ce(f.ink)})),u=d.flatMap(f=>[Z("line",{x1:r(f),x2:r(f),y1:Ce+Oe,y2:Ce+Oe+ha,stroke:"#666"}),Z("text",{x:r(f),y:Ce+Oe+ha+11,...Ln,fill:"#444","text-anchor":"middle"},f===0?"0":vt(f))]);return{tag:"g",attrs:{},children:[p].concat(c,[l],h,u)}}var Mf="Line ends",pd=[{value:"tip",label:"tip where the sequence goes on outside the loaded region"},{value:"stop",label:"stop"}],Nf=pd.map(e=>e.value);var fa="collapsed",_f="Sites",cd=[{value:"collapsed",label:"collapsed: one band per site"},{value:"open",label:"open: a node for each run of similar lengths"}],Bf=cd.map(e=>e.value),Cf="Collapsed site band",Of=[{value:"plain",label:"plain: pale where not every haplotype reaches",site:Ao},{value:"stepped",label:"stepped: as thick as the haplotypes at least so long",site:Eo}],ga=e=>e.thickness.field==="haplotypes"?"plain":"stepped",Wf="Length ticks";var Ff=["column","overlay","hidden"],wa="column";var ba="19.1.0";function mt(e,t,o={}){return{nodePositions:o.drawsRows?{}:e.nodePositions,deletions:t.bypassed,deletionRoutes:e.deletionRoutes,stranded:e.stranded,hiddenEdges:t.hidden}}var D={...$o,width:Wo,height:800,colorScheme:"auto",nodeWidth:"walks",edgeWidth:"walks",contigThickness:6,connectorThickness:2,countLaneScale:1,countLaneWidth:"log",liftFade:Lr,nodeLengths:St.nodeLengths,nodeShares:!1,compactKey:!1,keyCounts:!0,loopLengths:!0,smallSites:"hidden",lineEnds:"tip"};var ya=[{value:"auto",label:"Auto"},{value:"uniform",label:"Uniform"},{value:"random",label:"Random"},{value:"rainbow",label:"Rainbow"},{value:"depth",label:"Depth"},{value:"node-length",label:"Node length"},{value:"stable-rank",label:"Stable rank"},{value:"reference-position",label:"Reference position"},{value:"grey",label:"Grey"}],md=ya.map(e=>e.value);function lt(e,t){return e!=="auto"?e:t?.anchoredBy?"reference-position":"uniform"}function ka(e,t,o,n){let r=o.region,i=o.colorDomain??r,a=o.walkRows,s=ot(t,{region:o.fitToDrawing?void 0:r,extent:a&&t.extent?Ie(a,o.walkRowPitch,n):void 0}),d=new Map(e.nodes.map(M=>[M.id,M])),p=lt(o.colorScheme??D.colorScheme,e),m=p==="reference-position"&&!t.tubeMap?Je(e,i):void 0,c=Ke(e,t.tubeMap?[]:ze(e),o.showDeletionEdges),l=o.walks??[],h=l.some(M=>M.color?.field==="reference")?m??Je(e,i):void 0,u=l.length>0&&!t.tubeMap?ye(e,l,h,{countLaneScale:o.countLaneScale,countLaneWidth:o.countLaneWidth,liftFade:o.liftFade}):void 0,f=t.tubeMap?[]:[...new Set(l.map(M=>M.walk))].filter(M=>!u?.names.has(M)),g=Ft(o.facet),w=g.field&&u&&u.walks.length>1?Ee(e,u,l,h):void 0,k=g.field&&w?{panels:w,place:Ht(w.map(M=>M.walks[0].name),g.field,g.sort)}:void 0,R=Mt(e.paths?.length?Ue(e.paths):[]),b=o.referenceName??Ve(e,r),y=o.contigThickness??D.contigThickness,x=o.nodeWidth??D.nodeWidth,P=u?.referenceDomain&&{...u.referenceDomain,name:b};return{bounds:s,nodeById:d,colorScheme:p,referenceRamp:m,drawnDeletions:c,layers:l,lift:u,unmatchedWalks:f,facet:g,facets:k,labelOf:M=>R.get(M)??M,referenceName:b,walkReference:P,keyText:M=>{let V=Jo(M,P);return{note:V.gaps,scale:V.scale}},contigThickness:y,nodeWidth:x,geometry:(M,V)=>Pt({...mt(t,c,{drawsRows:!!a}),graph:e,nodeById:d,colorScheme:p,contigThickness:y,connectorThickness:o.connectorThickness??D.connectorThickness,drawPaths:!1,nodeWidth:x,edgeWidth:o.edgeWidth??D.edgeWidth,linearLayout:o.linearLayout,highlight:M,axis:V,referenceRamp:m,smallSites:o.smallSites??D.smallSites,lineEnds:o.lineEnds})}}var ht='font-family="Helvetica, Arial, sans-serif" font-size="11"',Pn=48,Q=18,xa=8,va=16,An=16,ld=32,ud=22,Nn=6,La="#1c1c22",ut=10,En="#18181c",hd=120,Sa=8;function fd(e){let t=10**Math.floor(Math.log10(Math.max(e,1)));return([5,2,1].find(o=>o*t<=e)??1)*t}var z=(e,t)=>{let o=Rr(t);return`${e}="${ce(t)}"${o<255?` ${e}-opacity="${+(o/255).toFixed(3)}"`:""}`},gd=e=>e?e.kind==="scale"||e.kind==="width"?Pn:Q:0;function wd(e,t){let o=t?Nr:xa,n=o*Pr,r=(t?[n,Q]:[Q-1]).map(i=>{let[a,s,d,p]=hi({x:i,y:9,angle:0,length:n,halfWidth:o/2,color:e},{scaleX:1,scaleY:1,translateX:0,translateY:0,dpr:1});return`M${[a,s,d,p].map(m=>`${+m.x.toFixed(1)},${+m.y.toFixed(1)}`).join("L")}Z`}).join("");return[`<line y1="9" y2="9" x2="${Q}" ${z("stroke",e)} stroke-width="${t?Io:xa}"/>`,t?`<path d="${r}" fill="none" stroke="#ffffff" stroke-width="${2*Er}" stroke-linejoin="round"/>`:"",`<path d="${r}" fill="${ce(Ar(e,!t))}"/>`].join("")}function bd(e,t){switch(e.kind){case"scale":return`<linearGradient id="${t}">${e.stops.map(o=>`<stop offset="${+o.offset.toFixed(4)}" stop-color="${ce(o.ink)}"/>`).join("")}</linearGradient><rect y="5" width="${Pn}" height="8" rx="2" fill="url(#${t})"/>`;case"swatch":return`<rect y="5" width="${Q}" height="8" rx="2" ${z("fill",e.ink)}/>`;case"chip":return`<rect x="4" y="4" width="10" height="10" rx="2" ${z("fill",e.ink)}/>`;case"width":return`<rect y="${9-e.px/2}" width="${Pn}" height="${e.px}" ${z("fill",e.ink)}/>`;case"hollow":return`<rect x="1" y="5" width="${Q-2}" height="8" rx="4" ${z("fill",e.ink)} ${z("stroke",e.rim)} stroke-width="${e.rimPx}"/>`;case"line":return e.arch?`<path d="M2,13 Q${Q/2},1 ${Q-2},13" fill="none" ${z("stroke",e.ink)} stroke-width="1.5"/>`:e.dashed?`<line y1="9" y2="9" x2="${Q}" ${z("stroke",e.ink)} stroke-width="2" stroke-dasharray="4 3"/>`:`<line y1="9" y2="9" x1="5" x2="${Q-5}" ${z("stroke",e.ink)} stroke-width="1.5"/>`;case"outline":return`<rect x="1" y="4" width="${Q-2}" height="10" rx="4" fill="none" ${z("stroke",e.ink)} stroke-width="2"/>`;case"halo":return`<line y1="9" y2="9" x1="5" x2="13" ${z("stroke",e.ink)} stroke-opacity="0.35" stroke-width="8" stroke-linecap="round"/>`;case"threads":return[6,9,12].map(o=>`<line y1="${o}" y2="${o}" x2="${Q}" ${z("stroke",e.ink)} stroke-width="${Io}"/>`).join("");case"lineEnd":{let o=Ir(Tr);return`<g transform="translate(0 9)" fill="none" stroke-linecap="round" ${z("stroke",e.ink)}><path d="${o.line}" stroke-width="${o.lineWidth}"/><path d="${o.tip}" stroke-width="${o.tipWidth}" stroke-linejoin="round"/></g>`}case"heads":return wd(e.ink,e.haloed)}}function Ma(e,t){let o=gd(e.swatch),n=o>0?o+5:0,r=e.strong??"",i=Math.max(n+(r.length+e.text.length)*me,(e.under?.length??0)*me);return(a,s)=>({width:i,height:e.under?ld:An,markup:`<g transform="translate(${a} ${s})" ${ht}>${e.swatch?bd(e.swatch,t):""}<text${n>0?` x="${n}"`:""} y="13">${r?`<tspan font-weight="bold">${J(r)}</tspan>`:""}${J(e.text)}</text>${e.under?`<text y="28">${J(e.under)}</text>`:""}</g>`})}function yd(e){return(t,o)=>({width:e.length*me,height:An,markup:`<g transform="translate(${t} ${o})" ${ht}><text y="13" font-weight="bold">${J(e)}</text></g>`})}var kd=new Set(["Thickness","Node thickness","Link thickness"]);function xd(e,t){return e.flatMap(({id:o,group:n,entries:r,newLine:i})=>[...n&&kd.has(n)?[yd(n)]:[],...r.map((a,s)=>Ma(a,`${t}-${o}-${s}`))].map((a,s)=>i&&s===0?Sd(a):a))}function Sd(e){return(t,o)=>({...e(t,o),newLine:!0})}function Rd(e,t){let o=[],n=6,r=2,i=0;for(let a of e){let s=a(0,0);n>6&&(s.newLine||n+s.width>t-6)&&(n=6,r+=i+4,i=0),o.push(a(n,r).markup),n+=s.width+va,i=Math.max(i,s.height)}return{markup:o,height:r+i}}function vd(e,t){return e.replaceAll(/([ML])(-?[\d.e-]+),(-?[\d.e-]+)/g,(o,n,r,i)=>`${n}${+(Number(r)*t.scaleX+t.translateX).toFixed(1)},${+(Number(i)*t.scaleY+t.translateY).toFixed(1)}`)}function Ld(e,t,o,n,r){return`<rect x="${e-o/2}" y="${t-Me-je+2}" width="${o}" height="${Me+je*2-2}" rx="3" fill="#fff" fill-opacity="0.85" stroke="${ni}"/><text x="${e}" y="${t}" font-family="Helvetica, Arial, sans-serif" font-size="${Me}" fill="${La}" text-anchor="middle"><tspan font-style="italic" font-weight="600">${J(n)}</tspan>${r?J(r):""}</text>`}function Md(e,t,o){let n=o.length*ut*.56+6;return`<rect x="${e-n/2}" y="${t-ut*.65}" width="${n}" height="${ut*1.3}" rx="3" fill="#fff" fill-opacity="0.8"/><text x="${e}" y="${t+ut*.35}" font-family="Helvetica, Arial, sans-serif" font-size="${ut}" fill="${En}" text-anchor="middle">${J(o)}</text>`}function Ra(e,t,o){let n=e(0),r=o(n);for(let i=0;i<3&&!t(n,e(r.header));i++)n=e(r.header),r=o(n);return r}function Tn(e,t,o={}){let n=o.width??D.width,r=o.height??D.height,i=o.walkRows,a=Ge(i,t,o.walkRowPitch),s=a.reduce((v,{label:N})=>Math.max(v,2*Nn+N.length*me),I),{bounds:d,nodeById:p,referenceRamp:m,layers:c,lift:l,facet:h,facets:u,labelOf:f,referenceName:g,walkReference:w,contigThickness:k,nodeWidth:R,geometry:b}=ka(e,t,o,{widthPx:n-s-I}),y=t.pixelRows??!1,x=m&&{start:m.start,end:m.start+m.span},P=o.genes?.length&&!t.tubeMap&&!i?et(e,o.genes,t.nodePositions,t.stranded):[],M=Rt(e,o.nodeLengths??D.nodeLengths),V=fr(e,o.nodeShares??D.nodeShares),S=Math.max(0,(lr(l?.walks??[])?.band??0)-I),B=0;function oe(v,N,W,G,E,A){let $=[],C=kt(e,p,k,R,v?.walks??0,A.collapsed?.through),O=ri(Ct(P,C.halfWidthPx,v,L=>vd(L,N),Ye(A)),{id:`exons${B++}`,width:G,height:E});O&&$.push(le(O));let F=L=>({x:L.x*N.scaleX+N.translateX,y:L.y*N.scaleY+N.translateY});for(let{item:L,x:T,y:H,w:Re,text:so}of W.genes){let{pin:ve,name:he}=L,{x1:Ss,y1:Rs,x2:vs,y2:Ls}=di({x:T,y:H},F(ve.at),k);$.push(`<line x1="${Ss}" x2="${vs}" y1="${Rs}" y2="${Ls}" stroke="${La}" stroke-width="0.8" stroke-opacity="0.6"/>`,Ld(T,H,Re,he,so.slice(he.length)))}for(let{item:L,x:T,y:H,w:Re,text:so}of W.passes){let ve=mi({x:T,y:H},L.at),he=ce(L.ink);$.push(`<line x1="${ve.x1}" x2="${ve.x2}" y1="${ve.y1}" y2="${ve.y2}" stroke="${he}" stroke-width="1"/>`,`<circle cx="${L.at.x}" cy="${L.at.y}" r="2" fill="${he}"/>`,`<rect x="${T-Re/2}" y="${H-Me-je+2}" width="${Re}" height="${Me+je*2-2}" rx="3" fill="#fff" fill-opacity="0.9" stroke="${he}"/>`,`<text x="${T}" y="${H}" ${ht} font-weight="bold" fill="${he}" text-anchor="middle">${J(so)}</text>`)}for(let L of W.sizes){let T=gr(L);T&&$.push(`<line x1="${T.x1}" x2="${T.x2}" y1="${T.y1}" y2="${T.y2}" stroke="${En}" stroke-width="0.8" stroke-opacity="0.6"/>`),$.push(Md(L.x,L.y,L.text))}if(i&&$.push(le(Oo(i,{...N,width:G,height:E,...o.walkRowPitch},{ramp:x,rowGenes:o.rowGenes}))),o.scaleBar&&t.referenceAxis){let L=fd(hd/N.scaleX),T=E-Sa,H=G-Sa,Re=H-L*N.scaleX;$.push(`<path d="M${Re} ${T-4}V${T}H${H}V${T-4}" fill="none" stroke="${En}"/>`,`<text x="${H}" y="${T-7}" ${ht} text-anchor="end">${J(`${vt(L)} of ${g??"the reference"}`)}</text>`)}for(let{label:L,y:T}of a){let H=T*N.scaleY+N.translateY;H>=0&&H<=E&&$.push(`<rect x="${Nn-2}" y="${H-7}" width="${L.length*me+4}" height="14" fill="#fff" fill-opacity="0.85"/>`,`<text x="${Nn}" y="${H+4}" ${ht} stroke="#fff" stroke-width="3" paint-order="stroke">${J(L)}</text>`)}return $.join("")}function ao(v,N,W,G){let E=G?{scale:G.scaleX,translateX:G.translateX,translateY:G.translateY}:tt(d,N,W,y,u?{padLeft:de,padTop:de,padRight:de,padBottom:de}:{padLeft:s,padTop:I+S,padBottom:I+S});if(E){let A=G?{scaleX:G.scaleX,scaleY:G.scaleY,pixelRows:y}:_t(E.scale,y),$=b(v,A),C={scaleX:A.scaleX,scaleY:A.scaleY,translateX:E.translateX,translateY:E.translateY};return{highlight:v,batch:$,t:C,labels:pi({paneWidth:N,canvasHeight:W,axisScale:A,translateX:E.translateX,translateY:E.translateY,contigThickness:k,legendSize:{width:0,height:0},drawnRowLabels:a,bubbleHalos:[],genePins:P,liftedWalks:v?.walks.map(O=>O.name),nodePositions:t.nodePositions,labelsNodeSizes:!t.tubeMap&&(!v||!!e.threadFold),nodeLengths:M,loopLengths:o.loopLengths??D.loopLengths,nodeShares:V.texts,linkShares:V.links,nodeById:p,graph:e,drawnInk:$,alleleDeletions:t.alleleDeletions??[],positionsVersion:0,folded:$.collapsed?.nodes,passLabels:u?[]:ci($,v,C,{width:N,height:W})})}}}function zn(v,N,W){if(!v)return"";let{canvas:G,markup:E}=li(N,W),A=new ui(G);return A.uploadGeometry(v.batch),A.updateTransform({...v.t,dpr:1}),A.render([1,1,1,1]),E()+oe(v.highlight,v.t,v.labels,N,W,v.batch)}let Kn=(v,N,W)=>{let G=xd(si(e,t,{region:o.region,referenceName:g,referenceRamp:m,lift:l,panels:u?.panels,walkLabel:f,nodeWidth:R,nodeSharesOf:hr(v.flatMap(E=>E?E.labels.sizes:[]))?V.of:0,compact:o.compactKey??D.compactKey,counts:o.keyCounts??D.keyCounts,contigThickness:k,edgeWidth:o.edgeWidth??D.edgeWidth,connectorThickness:o.connectorThickness??D.connectorThickness,drawsNodes:!i&&!t.tubeMap,marks:ii(v.flatMap(E=>E?[E.batch]:[]),W),genePins:P,unlabelled:N}),"key");return i&&Bo(i,{ramp:x,genes:o.rowGenes?.size?o.rowGeneGaps:void 0,annotation:o.rowAnnotation}).forEach((E,A)=>{G.push(($,C)=>{let O=Co([E],$,C,`rows-key-${A}`);return{width:O.width-va,height:An,markup:le(O.tree)}})}),Rd(G,n)},ue=[],K;if(u){let{panels:v,place:N}=u,W=C=>$t({count:N.count,bounds:d,pixelRows:y,width:n,room:r-C,columns:N.columns??h.columns}),{drawn:G,header:E}=Ra(W,(C,O)=>C.columns===O.columns&&C.width===O.width&&C.height===O.height,C=>{let O=v.map(L=>ao(L,C.width,C.height)),F=Kn(O);return{drawn:{views:O,key:F,grid:C},header:F.markup.length>0?F.height+Ae:0}}),{grid:A,key:$}=G;for(let C of $.markup)ue.push(C);v.forEach((C,O)=>{let F=N.cells[O],L=F%A.columns*(A.width+Ae),T=E+Math.floor(F/A.columns)*(A.height+Wt+Ae),H=C.walks[0];ue.push(Ma(ai(H,f(H.name),w),`key${O}`)(L+6,T+2).markup,`<svg x="${L}" y="${T+Wt}" width="${A.width}" height="${A.height}">${zn(G.views[O],A.width,A.height)}</svg>`)}),K=E+A.total}else{let v=n-2*I,N=y||!(d.w>0)?d.h:d.h*v/d.w,W=o.frame,G=F=>W?r:Math.max(160,Math.min(r-F,Math.ceil(N+2*(I+S)))),{drawn:E,header:A}=Ra(G,(F,L)=>F===L,F=>{let L=ao(l,n,F,W),T=Kn([L],L?.labels.unlabelled,W&&L?Dr(L.t,L.t,n,F):void 0);return{drawn:{v:L,key:T,h:F},header:T.markup.length>0?Math.max(Wt,T.height):0}}),{v:$,key:C,h:O}=E;for(let F of C.markup)ue.push(F);ue.push(`<svg y="${A}" width="${n}" height="${O}">${zn($,n,O)}</svg>`),K=A+O}let ne=o.walkStrip,ks=u?[]:ct(l,ne&&!i&&!t.tubeMap?ne.rows:void 0);for(let v of ks)ue.push(`<svg y="${K}" width="${n}" height="${eo}">${le(Mn(v,f(v.walk),n))}</svg>`),K+=eo;if(ne&&!i&&!t.tubeMap){let v=dt(ne.rows,{width:n}),N=we(u?u.panels.map(G=>G.walks[0]):l?.walks??[]),W=Co(Bo(ne.rows,{inks:N,ramp:x,genes:vn(v,ne.rowGenes,ne.rowGeneGaps),annotation:o.rowAnnotation,markUnloaded:!0,pitch:v}),6,K+v.height,"strip-key");ue.push(`<line x1="0" x2="${n}" y1="${K+.5}" y2="${K+.5}" stroke="#ddd"/>`,`<svg y="${K}" width="${n}" height="${v.height}">${le(Oo(ne.rows,v,{inks:N,ramp:x,rowGenes:ne.rowGenes,idPrefix:"strip",markUnloaded:!0}))}${le(Rn(ne.rows,v,new Set(c.map(G=>G.walk))))}</svg>`,le(W.tree)),K+=v.height+ud}let xs=JSON.stringify({generator:`@jbrowse/bandage-core@${ba}`,...o.spec===void 0?{}:{spec:o.spec}});return`<svg xmlns="http://www.w3.org/2000/svg" width="${n}" height="${K}" viewBox="0 0 ${n} ${K}"><metadata>${J(xs)}</metadata><rect width="${n}" height="${K}" fill="#fff"/>${ue.join("")}</svg>
2
+ `}var Nd=.9;function ft(e,t){return e+2>=t||e>=Nd*t}var Pd=50;function In(e,t,o,n=[]){let r=new Map(e.nodes.map(a=>[a.name,a])),i=[];for(let a of t){let s=[],d=1/0,p=-1/0,m=1/0,c=[],l=be(a);for(let[f,g]of l.entries()){let w=r.get(g),k=w&&o[w.id];if(!(!w||!k?.length)&&!(a.key?f===0||f===l.length-1:_(w)&&(w.stable.start<a.start||w.stable.start>=a.end))){c.push(w.id),s.push(co(k.length===1?[k[0],k[0]]:k));for(let R of k)d=Math.min(d,R.x),p=Math.max(p,R.x),m=Math.min(m,R.y)}}if(c.length===0)continue;let h={x:(d+p)/2,y:m},u=a.covering===!0||ft(c.length,e.nodes.length);i.push({bubble:a,label:oi(a,n),path:s.join(""),labelAt:h,members:c.length,nodeIds:c,whole:u,tick:!u&&!a.partial&&a.longestAlleleLength<Pd})}return i}function gt(e,t){let o=new Set(t),n=e.nodes.filter(d=>o.has(d.name)),r=new Set(n.map(d=>d.id)),i=new Map(e.nodes.map(d=>[d.id,d.length])),a=new Map,s=e.paths?.flatMap(d=>{let p=d.nodeIds.findIndex(l=>r.has(l));if(p<0)return[];let m=d.nodeIds.filter(l=>r.has(l));a.set(d.name,{first:p,nodeIds:m});let c=d.nodeIds.findLastIndex(l=>r.has(l));return[{...d,nodeIds:m,...d.refStarts?{refStarts:d.refStarts.filter((l,h)=>r.has(d.nodeIds[h]))}:{},...nr(e,d,l=>i.get(l)??0,p,c)}]});return{name:e.name,nodes:n,edges:e.edges.filter(d=>r.has(d.from)&&r.has(d.to)),...s?.length?{paths:s}:{},anchorPaths:rr(e,a),pathVisits:e.pathVisits,anchoredBy:e.anchoredBy,referencePath:e.referencePath,revisited:e.revisited,...e.depthStated?{depthStated:!0}:{}}}function Gn(e,t,o,n){let r=e.get(t);e.set(t,{min:Math.min(r?.min??1/0,o.min+n),max:Math.max(r?.max??-1/0,o.max+n),n:Math.min(ti,o.n+(r?.n??0))})}var Na=(e,t)=>e<t?`${e} ${t}`:`${t} ${e}`,Pa=e=>e.stable.strand==="-"?"start":"end",Ea=e=>e.stable.strand==="-"?"end":"start";function Ed(e,t,o){return e.length===0||e.some(n=>{let r=te(n);return n.fromStrand===void 0||n.toStrand===void 0||(n.from===t.id?r.from===Pa(t)&&r.to===Ea(o):r.from===Ea(o)&&r.to===Pa(t))})}function Aa(e){if(!e.nodes.some(_))return[];let t=new Map(e.nodes.map(h=>[h.id,h])),o=rn(e),n=new Map(o.map((h,u)=>[h,u])),r=new Int32Array(o.length+1),i=new Map,a=new Set,s=new Map;for(let h of e.edges){let u=n.get(h.from),f=n.get(h.to);if(u===void 0||f===void 0||u===f)continue;a.add(`${h.from}>${h.to}`).add(`${h.to}>${h.from}`),We(s,Na(h.from,h.to),h);let[g,w]=u<f?[u,f]:[f,u];r[g+1]++,r[w]--;let[k,R]=u<f?[h.from,h.to]:[h.to,h.from];Jn(i,k,R)}for(let h=1;h<r.length;h++)r[h]+=r[h-1];let d=e.nodes.filter(_).sort((h,u)=>h.stable.start-u.stable.start),p=new Set([...Qn(d,h=>h.stable.refName).values()].flatMap(h=>[h[0].id,h.at(-1).id])),m=d.map(h=>[h,n.get(h.id)]).filter(([h,u])=>p.has(h.id)||r[u]===0).sort(([h,u],[f,g])=>u-g||h.stable.start-f.stable.start),c=_n(e,m.map(([h])=>h.id)),l=[];for(let h=0;h+1<m.length;h++){let[u,f]=m[h],[g,w]=m[h+1],k=o.slice(f+1,w);if(k.length===0||u.stable.refName!==g.stable.refName)continue;let R=new Map([[u.id,{min:0,max:0,n:1}]]);for(let S of[u.id,...k]){let B=R.get(S);if(B)for(let oe of i.get(S)??[])n.get(oe)>w||Gn(R,oe,B,oe===g.id?0:t.get(oe).length)}let b=Bn(e,t,c,u.id,g.id,{inside:new Set(k),beyond:(S,B)=>{let oe=n.get(S);return oe!==void 0&&(B===u.id?oe<f:oe>w)},direct:Ed(s.get(Na(u.id,g.id))??[],u,g)},()=>R.get(g.id)??{min:0,max:0,n:0}),y=u.stable.start+u.length,x=g.stable.start,P=[u.id,...k.filter(S=>_(t.get(S))),g.id],M=P.some((S,B)=>B>0&&!a.has(`${P[B-1]}>${S}`)),V=x-y;l.push(Wn({refName:u.stable.refName,start:y,end:x},[u,...k.map(S=>t.get(S)),g],M&&!b.routes?{...b,min:V,max:V}:b,M||b.walksLeave))}return l}function _n(e,t){let o=e.paths;if(!o)return;let n=new Map;for(let r of t)n.set(r,new Int32Array(o.length).fill(-1));return o.forEach((r,i)=>{let a=r.nodeIds;for(let s=0;s<a.length;s++){let d=n.get(a[s]);d?.[i]===-1&&(d[i]=s)}}),n}function Bn(e,t,o,n,r,i,a){if(!o)return{...a(),walksLeave:!1};let s=o.get(n),d=o.get(r),p=[n,r];return On(e,t,(m,c)=>{let l=s[c],h=d[c],u=Math.min(l,h)+1,f=Math.max(l,h);return l<0||h<0?l>=0||h>=0?"leaves":void 0:Ad(m,u,f,p,i)?{lo:u,hi:f,endFirst:h<l}:Cn(m,p,i)??"leaves"},a)}function Ad(e,t,o,n,r){let{beyond:i}=r;return o>t&&i?!(i(e[t],e[t-1])&&i(e[o-1],e[o])):Ta(e,t,o,n,r)}function Ta(e,t,o,n,{inside:r,direct:i}){let a=o>t||i;for(let s=t;s<o&&a;s++){let d=e[s];a=r.has(d)||d===n[0]||d===n[1]}return a}function Cn(e,t,o){let n,r=-1;for(let i=0;i<e.length&&!n;i++){let a=e[i];a===t[0]||a===t[1]?(r<0||e[r]!==a)&&(r>=0&&Ta(e,r+1,i,t,o)?n={lo:r+1,hi:i,endFirst:e[r]===t[1]}:r=i):o.inside.has(a)||(r=-1)}return n}function On(e,t,o,n){let r=[],i=1/0,a=-1/0,s=0;e.paths?.forEach((p,m)=>{let c=p.nodeIds,l=o(c,m);if(l==="leaves")s++;else if(l){let{lo:h,hi:u,endFirst:f}=l,g=f?k=>c[u-1-k]:k=>c[h+k],w=r.find(k=>k.steps.length===u-h&&k.steps.every((R,b)=>R===g(b)));if(!w){let k=Array.from({length:u-h},(b,y)=>g(y)),R=0;for(let b of k)R+=t.get(b)?.length??0;w={steps:k,bp:R,walks:[]},r.push(w)}w.walks.push(p.name),i=Math.min(i,w.bp),a=Math.max(a,w.bp)}});let d=s>0;return r.length?{min:i,max:a,n:r.length,routes:r,walksLeave:d}:{...n(),walksLeave:d}}function Wn(e,t,{min:o,max:n,n:r,routes:i},a){return{...e,segmentCount:t.length,pathCount:r,inversion:!1,shortestAlleleLength:o,longestAlleleLength:n,segments:t.map(s=>s.name).join(","),shortestAllele:void 0,longestAllele:void 0,partial:a,routes:i,...t.some(s=>s.placeholder)?{unloaded:!0}:{}}}function Td(e,t){let o=e.nodes.length*2,n=new Set,r=[],i=new Int32Array(o);for(let p of e.edges){let m=t.get(p.from),c=t.get(p.to);if(m===void 0||c===void 0)continue;let l=te(p),h=m*2+(l.from==="end"?1:0),u=c*2+(l.to==="end"?1:0),f=Math.min(h,u)*o+Math.max(h,u);n.has(f)||(n.add(f),r.push(h,u),i[h]++,h!==u&&i[u]++)}let a=new Int32Array(o+1);for(let p=0;p<o;p++)a[p+1]=a[p]+i[p];let s=new Int32Array(a[o]),d=a.slice(0,o);for(let p=0;p<r.length;p+=2){let m=r[p],c=r[p+1];s[d[m]++]=c,m!==c&&(s[d[c]++]=m)}return{offset:a,next:s}}function Id(e,t,o){let n=new Int32Array(e),r=new Uint8Array(e*2),i=new Int32Array(e*2),a=new Int32Array(e),s=[],d=0;return p=>{let m=p>>1;d++,s.length=0;let c=0,l=0,h=0,u,f=g=>{r[g]||(r[g]=1,c++,s.push(g))};f(p),i[l++]=p;e:for(;l>0;){let g=i[--l],w=g>>1;if(n[w]=d,w!==m&&(a[h++]=g),r[g]&&(r[g]=0,c--),t[g]===t[g+1])break;for(let k=t[g];k<t[g+1];k++){let R=o[k],b=R>>1;if(b===m)break e;if(f(R^1),n[b]===d)continue;let y=!0;for(let x=t[R];x<t[R+1];x++)if(n[o[x]>>1]!==d){y=!1;break}y&&(i[l++]=R^1)}if(l===1&&c===1){h>0&&(u={source:p,sink:i[0],inside:a.slice(0,h)});break}}for(let g of s)r[g]=0;return u}}function Ia(e){return{source:e.sink^1,sink:e.source^1,inside:e.inside.map(t=>t^1).reverse()}}function Ca(e,t){return _(e)&&_(t)&&e.stable.refName===t.stable.refName}function Ga(e,t){return(e&1)===(t[e>>1].stable.strand==="-"?0:1)}function Gd(e,t){let o=t[e.source>>1],n=t[e.sink>>1];return Ca(o,n)&&o.stable.start!==n.stable.start&&Ga(e.source,t)===o.stable.start>n.stable.start&&Ga(e.sink^1,t)===n.stable.start>o.stable.start}function $n(e,t){return Ca(t[e.source>>1],t[e.sink>>1])&&!Gd(e,t)}function _a(e,t){let o=t[e.source>>1],n=t[e.sink>>1],r=$n(e,t)?o.stable.start-n.stable.start:0,i=((e.sink^1)&1)-(e.source&1);return(r||i||Xe(o.name,n.name))<0}function Ba(e){return[e.source>>1,...Array.from(e.inside,t=>t>>1),e.sink>>1]}function _d(e,t){let o=e.source>>1,n=e.sink>>1;return Math.min(o,n)*t+Math.max(o,n)}function Bd(e){let{nodes:t}=e,o=t.length*2,n=new Map(t.map((c,l)=>[c.id,l])),{offset:r,next:i}=Td(e,n),a=Id(t.length,r,i),s=new Map;for(let c=0;c<o;c++){let l=a(c);if(l){let h=l.source,u=l.sink^1,f=Math.min(h,u)*o+Math.max(h,u);(_a(l,t)||!s.has(f))&&s.set(f,l)}}let d=new Map;for(let c of s.values()){let l=_a(c,t)?c:Ia(c);We(d,_d(l,t.length),l)}let p=[],m=new Map;for(let c of d.values()){let l=c.length===2&&c[0].source>>1===c[1].source>>1,h=c.map(u=>l&&(u.source&1)===0?Ia(u):u);p.push(...h),h.length===2&&m.set(h[0],h[1]).set(h[1],h[0])}return{found:p,twins:m,offset:r,next:i}}function Cd(e,t,o,n){return n.subarray(o[e*2],o[e*2+2]).some(r=>r>>1===t)}function Fn(e,t,o){return o.subarray(t[e.source],t[e.source+1]).includes(e.sink^1)}function Od(e,t,o,n,r,i,a){let{nodes:s}=e,d=[s[o.source>>1].id,s[o.sink>>1].id],p=new Set(Array.from(o.inside,u=>s[u>>1].id)),m=Fn(o,r,i),c=m&&Fn(n,r,i),l={inside:p,direct:m&&!c},h=(u,f)=>c&&f>0&&u[f]!==u[f-1]&&d.includes(u[f])&&d.includes(u[f-1]);return On(e,t,u=>Cn(u,d,l)??(u.some((f,g)=>p.has(f)||h(u,g))?"leaves":void 0),a)}function Wd(e,t,o,n){let r=n.sink>>1,i=new Map([[n.source>>1,{min:0,max:0,n:1}]]);for(let a of[n.source,...n.inside]){let s=i.get(a>>1);if(s)for(let d=t[a];d<t[a+1];d++){let p=o[d]>>1;Gn(i,p,s,p===r?0:e[p].length)}}return i.get(r)??{min:0,max:0,n:0}}function Hn(e,t){let{nodes:o}=e,{found:n,twins:r,offset:i,next:a}=Bd(e),s=n.map(u=>ft(u.inside.length,o.length)),d=n.map(Ba),p=new Map;d.forEach((u,f)=>{for(let g of u)We(p,g,f)});let m=(u,f)=>p.get(u.inside[0]>>1).some(g=>g!==f&&!s[g]&&d[g].length>d[f].length&&d[f].every(w=>p.get(w).includes(g))),c=n.filter((u,f)=>!s[f]&&(t!==void 0||$n(u,o))&&!m(u,f)),l=new Map(o.map(u=>[u.id,u])),h=_n(e,c.flatMap(u=>[o[u.source>>1].id,o[u.sink>>1].id]));return c.map(u=>{let f=o[u.source>>1],g=o[u.sink>>1],w=r.get(u),k=()=>Wd(o,i,a,u),R=w?Od(e,l,u,w,i,a,k):Bn(e,l,h,f.id,g.id,{inside:new Set(Array.from(u.inside,P=>o[P>>1].id)),direct:Fn(u,i,a)||!Cd(u.source>>1,u.sink>>1,i,a)},k),b=$n(u,o),[y,x]=!b||f.stable.start<=g.stable.start?[f,g]:[g,f];return{...Wn({refName:b?f.stable.refName:t.refName,start:b?y.stable.start+y.length:t.start,end:b?x.stable.start:t.end},Ba(u).map(P=>o[P]),R,R.walksLeave),key:`${f.name}>${g.name}`,...b?{}:{offReference:!0}}}).sort((u,f)=>u.start-f.start||u.end-f.end||Xe(u.key,f.key))}function to(e,t){let o=e.nodes.length,n=Aa(e);if(n.length===0){let r=Hn(e,t);return t?[...r,{...t,covering:!0}]:r}return n.flatMap(r=>ft(r.segmentCount-2,o)?[...Hn(r.segmentCount===o?e:gt(e,be(r)),r),{...r,covering:!0}]:[r])}function Dn(e,t,o){return t==="uniform"||t==="grey"?void 0:$d(e,t,o)}function $d(e,t,o){let n=Gr(e,o);return new Map(e.nodes.flatMap((r,i)=>r.placeholder?[]:[[r.id,vr(_r(r,i,t,n))]]))}var oo=JBrowseExports["@jbrowse/core/pluggableElementTypes/renderers/util/serializableFilterChain"];var Oa=oo&&oo.__esModule?oo.default:oo;var Vn={paths:!1,bubbles:!1,deletions:!0,genes:!0,lengths:St.nodeLengths,referenceStrip:!0,walkStrip:!1,walkRibbons:!1,walkBlocks:!1,smallSites:!1};function Wa(e){let t=X(e)?e:{};return new Set(Object.keys(Vn).filter(o=>t[o]??Vn[o]))}function FN(e,t,o){let{[t]:n,...r}=X(e)?e:{};return o===Vn[t]?r:{...r,[t]:o}}var Xn={depth:"depth",length:"node-length",rank:"stable-rank",position:"reference-position"},$a=Object.fromEntries(Object.entries(Xn).map(([e,t])=>[t,e]));function Fa(e){if(X(e)){let{field:t,value:o,scale:n}=e;if(o==="grey"||o==="uniform")return o;if(t==="id")return X(n)&&n.scheme==="rainbow"?"rainbow":"random";if(typeof t=="string"&&t in Xn)return Xn[t]}return"auto"}function Ha(e){let t=X(e)?e.scale:void 0;return X(t)&&typeof t.domainMin=="number"&&typeof t.domainMax=="number"?{start:t.domainMin,end:t.domainMax}:void 0}function VN(e,t){return e==="grey"||e==="uniform"?{value:e}:e==="random"?{field:"id",scale:{type:"ordinal"}}:e==="rainbow"?{field:"id",scale:{scheme:"rainbow"}}:e==="reference-position"&&t?{field:"position",scale:{domainMin:t.start,domainMax:t.end}}:$a[e]?{field:$a[e]}:{}}var Da=6;function no(e){return typeof e=="number"?{width:"uniform",px:e,links:"uniform"}:X(e)?{width:e.field==="walks"||e.field==="depth"||e.field==="frequency"?e.field:"uniform",px:typeof e.value=="number"?e.value:Da,links:e.links==="walks"?"walks":"uniform"}:{width:"walks",px:Da,links:"walks"}}function YN({width:e,px:t,links:o}){return e==="uniform"&&o==="uniform"?t:{...e==="uniform"?{}:{field:e},value:t,...o==="walks"?{links:o}:{}}}var Va=new Set;function Xa(e,t){return e.end>=t.start&&e.start<=t.end}function ja(e,t){let o=new Map(e.nodes.map(r=>[r.id,r])),n=q(e);return new Set(e.nodes.flatMap(r=>{let i=_(r)?void 0:qe({nodeId:r.id,nodeById:o,neighbors:n});return i&&!Xa(i,t)?[r.id]:[]}))}function Fd(e,t,o){return _(e)?e.stable.start>=o.start&&e.stable.start+e.length<=o.end:!t.has(e.id)}function Ya(e,t,o,n){return n?new Map(t.nodes.flatMap(r=>{let i=e.get(r.id);return i!==void 0&&Fd(r,o,n)?[[r.id,i]]:[]})):e}function za(e,t){return t?e.filter(o=>Xa(o,t)):e}function Ka(e,t,o){return o.size===0?e:e.filter(n=>!t.has(n.gene)||[...n.nodeIds].some(r=>!o.has(r)))}var Ua=new WeakMap;function qa(e,t,o){let n=Ua.get(e);return t.size===0?e:n?.outside===t&&n.version===o?n.positions:Hd(e,t,o)}function Hd(e,t,o){let n=Object.fromEntries(Object.entries(e).filter(([r])=>!t.has(r)));return Ua.set(e,{outside:t,version:o,positions:n}),n}function Za(e,t,o,n){let r=ar(e,t,{visits:n});return r?yo(r,o):void 0}var Vd=[];function Xd(e,t){return e.gene.name===t.gene.name&&e.gene.refName===t.gene.refName&&e.gene.start===t.gene.start&&e.gene.end===t.gene.end&&e.exons===t.exons&&e.at.x===t.at.x&&e.at.y===t.at.y&&e.covered===t.covered&&e.onReference===t.onReference&&e.walks===t.walks&&e.nodeIds.size===t.nodeIds.size&&[...e.nodeIds].every(o=>t.nodeIds.has(o))}function jd(e,t){return e.length===t.length&&e.every((o,n)=>{let r=t[n];return r!==void 0&&Xd(o,r)})}function ro(e,t){return e.size===t.size&&[...e.keys()].every(o=>t.has(o))}function Ja(e){try{return e()}catch{return}}function Qa(e){let t=new Map;for(let o of e.nodes)t.set(o.id,o);return t}function es(e,t,o,n){let r=t?.get(e);return n!==void 0&&r&&!_(r)?r.replaces:t&&o?Lo({nodeId:e,nodeById:t,neighbors:o}):void 0}var ts=Qr.views(e=>({sessionTrack(t){return re(e).tracks.find(o=>o.trackId===t)},get grammar(){return{}},get keyPlacement(){return wa},get viewWindow(){},get hasPendingSource(){return!1},get canRetryLoad(){return!1},get sourceTrack(){return Ja(()=>Un(e).configuration)},get sourceAdapter(){let t=this.sourceTrack;return t?ta(e,t):void 0},get containingView(){return Ja(()=>bt(e))}})).views(e=>{let t=a=>Le(a,{equals:(s,d)=>JSON.stringify(s)===JSON.stringify(d)}),o=t(()=>Ha(e.grammar.encoding?.color)),n=t(()=>Ft(e.grammar.facet)),r=t(()=>{let a=Li(e.grammar.facet);return a&&a.field!=="walk"&&a.field!=="sample"?a:void 0}),i=t(()=>e.grammar.walks??[]);return{get walkLayers(){return i.get()},get chosenLayoutMode(){return e.grammar.layoutMode??"force"},get chosenLayoutEngine(){return e.grammar.layoutEngine??"fmmm"},get chosenColorScheme(){return Fa(e.grammar.encoding?.color)},get statedColorDomain(){return o.get()},get chosenHover(){return e.grammar.hover??"nodes"},get chosenLineEnds(){return e.grammar.lineEnds??"tip"},get chosenLinks(){return e.grammar.links??pr},get chosenSites(){return e.grammar.sites??fa},get chosenSite(){return To(e.grammar.encoding?.site)},get chosenBand(){return(e.graph?mr(e.graph,this.nodeWidth):this.nodeWidth)==="walks"?ga(this.chosenSite):"plain"},get nodeWidth(){return no(e.grammar.size).width},get contigThickness(){return no(e.grammar.size).px},get linkWidth(){return no(e.grammar.size).links},get layerSet(){return Wa(e.grammar.layers)},get drawPaths(){return this.layerSet.has("paths")},get showBubbles(){return this.layerSet.has("bubbles")},get showDeletionEdges(){return this.layerSet.has("deletions")},get smallSites(){return this.layerSet.has("smallSites")?"nodes":"hidden"},get showGenes(){return this.layerSet.has("genes")},get showReferenceStrip(){return this.layerSet.has("referenceStrip")},get walkStrip(){return this.layerSet.has("walkStrip")},get walkRibbons(){return this.layerSet.has("walkRibbons")},get facetSetting(){return n.get()},get walkRowGroupBy(){return r.get()},get walkRowSamples(){let a=e.grammar.rows?.kept;return Array.isArray(a)?a:void 0},get walkRowsFollowLift(){return e.grammar.rows?.kept==="lifted"},get walkRowOrder(){return e.grammar.rows?.order==="shared"?"shared":void 0},get hoverLightsEverything(){return this.chosenHover==="everything"},get litNode(){return this.chosenHover==="off"?null:e.hoveredNode}}}).views(e=>({get paneMeasured(){let t=bt(e);return!qt(t)||t.initialized},get paneWidth(){return this.paneMeasured?bt(e).width:0},get drawnGraph(){return e.layoutResult?.tubeMap?.graph??e.graph}})).views(e=>{let t=Le(()=>{let o=e.drawnGraph,n=e.viewWindow;return o&&n?ja(o,n):Va},{equals:ro});return{get outsideView(){return t.get()}}}).views(e=>({get nodeById(){return e.drawnGraph&&Qa(e.drawnGraph)},get nodeLengths(){let t=e.drawnGraph,o=Rt(t,e.layerSet.has("lengths"));return t?Ya(o,t,e.outsideView,e.viewWindow):o},get nodeCount(){return e.graph?.nodes.length??0},get edgeCount(){return e.graph?.edges.length??0},get pathCount(){return(e.unfoldedGraph?e.unfoldedGraph.paths:e.cutWalks??e.graph?.paths)?.length??0},get legendAtRest(){return e.hoveredNode===null&&e.hoveredRowWalks.length===0},get hasGraph(){return e.graph!==void 0},get canCancelLoad(){return e.isLoading&&!e.layoutResult},get usesLayoutEngine(){return e.graph?sn(e.chosenLayoutMode,e.graph):!1},get anchorPaths(){return(e.unfoldedGraph?e.unfoldedGraph.anchorPaths:e.cutWalks??e.graph?.anchorPaths)??[]},get walkChoices(){let t=e.unfoldedGraph?e.unfoldedGraph.paths?.filter(o=>o.nodeIds.length>0):e.cutWalks??e.graph?.paths;return t?.length?Ue(t):[]},get effectiveDrawPaths(){return e.drawPaths&&Lt(e.graph?.paths?.length??0)},get activeReferencePath(){return e.graph?.referencePath},get rampDomain(){let t=e.openBubbles.at(-1);return t&&!t.offReference&&t.end>t.start?{start:t.start,end:t.end}:e.statedColorDomain??e.viewWindow??e.graphRegion},get drawnReferenceRamp(){let t=e.drawnGraph;return t?Je(t,this.rampDomain):void 0},get walkRamp(){return e.walkLayers.some(t=>t.color?.field==="reference")?this.drawnReferenceRamp:void 0},get modeDrawsNodes(){return Y(e.chosenLayoutMode).drawsNodes},get liftedWalkLayers(){return e.walkLayers.length>0||!this.modeDrawsNodes?e.walkLayers:e.hoveredRowWalks.map(t=>({walk:t}))},get sheetColorOf(){let t=e.walkRowSampleTable,o=e.sourceAdapter;return t&&o?Hr(t,tr({getConf:n=>o[n]})):void 0},get coloredWalkLayers(){let t=this.sheetColorOf;return this.liftedWalkLayers.map(o=>{let{field:n,scheme:r,value:i}=o.color??{},a=(n??r??i)===void 0?t?.(o.walk):void 0;return a===void 0?o:{...o,color:{...o.color,value:a}}})},get walkLift(){let{graph:t}=e,o=this.coloredWalkLayers;return t&&!e.walkCut&&o.length>0&&!e.layoutResult?.tubeMap?ye(t,nt(t,o),this.walkRamp):void 0},get facetsWalks(){let{graph:t}=e;return(t&&e.facetSetting.field!==""&&this.modeDrawsNodes&&e.walkLayers.length>1&&!e.walkCut&&!e.layoutResult?.tubeMap?ye(t,nt(t,e.walkLayers))?.walks.length??0:0)>(t?.threadFold?0:1)},get facetPanels(){let{graph:t}=e,o=this.facetsWalks?this.walkLift:void 0;return t&&o?t.threadFold?this.coloredWalkLayers.flatMap(n=>{let r=nt(t,[n]),i=ye(t,r,this.walkRamp);return i?Ee(t,i,r,this.walkRamp):[]}):Ee(t,o,this.coloredWalkLayers,this.walkRamp):void 0},get drawnWalks(){return this.facetPanels?.map(t=>t.walks[0])??this.walkLift?.walks??[]},get walksShadedAlong(){let t=this.drawnWalks;return t.length>0&&t.every(o=>o.encoding.field==="progress")},get liftsWalks(){return!zr.has(e.chosenLayoutMode)},get walkReference(){let t=this.walkLift?.referenceDomain;return t&&{...t,name:e.graph&&Ve(e.graph,e.graphRegion)}},get liftedWalks(){return this.walkLift?.walks.map(t=>t.name)},get walkLabels(){return Mt(this.walkChoices)},walkLabel(t){return this.walkLabels.get(t)??t},get effectiveColorScheme(){return e.layoutResult?.tubeMap&&(this.tubeMapReads||e.chosenColorScheme==="auto")?"uniform":lt(e.chosenColorScheme,e.graph)},get tubeMapReads(){let t=e.layoutResult;return!t?.tubeMapPanels&&(t?.tubeMap?.layout.reads.length??0)>0},get colorSchemeLock(){return this.walkLift?{value:"By walk",why:"Each highlighted haplotype colours its own lane: set it under Haplotypes, Color highlighted..."}:this.tubeMapReads?{value:"By strand",why:"Reads take the reds and blues, so the tube map leaves its nodes clear"}:void 0},get nodePositions(){return e.layoutResult?.nodePositions},get alleleDeletions(){return e.layoutResult?.alleleDeletions??[]},get deletionRoutes(){return e.layoutResult?.deletionRoutes},get stranded(){return e.layoutResult?.stranded},get pixelRows(){return e.layoutResult?.pixelRows??!1},get zoomPercent(){return`${(e.scale*100).toFixed(1)}%`},get isDefaultViewport(){return e.scale===1&&e.translateX===0&&e.translateY===0}})).views(e=>({get derivedBubbles(){return e.graph?to(e.graph):[]},get openBubbleInsides(){let{graph:t}=e;return t?e.openBubbles.map(o=>to(gt(t,be(o)),o).filter(n=>!n.covering)):[]},get openBubble(){return e.openBubbles.at(-1)},get openBubbleFocus(){let t=this.openBubble,{graph:o}=e;if(!t||!o)return;let n=new Set(be(t)),r=new Set(o.nodes.filter(a=>n.has(a.name)).map(a=>a.id)),i=new Set;return o.edges.forEach((a,s)=>{r.has(a.from)&&r.has(a.to)&&i.add(s)}),{walks:[],nodeIds:r,edgeIndexes:i,names:new Set}},get drawnHighlight(){return e.walkLift??this.openBubbleFocus},bubbleIsOpen(t){return e.openBubbles.some(o=>ei(o,t))},bubbleFaded({bubble:t,nodeIds:o}){let n=e.walkLift,r=this.openBubbleFocus;return n?!o.some(i=>n.nodeIds.has(i)):!!r&&!this.bubbleIsOpen(t)&&!o.every(i=>r.nodeIds.has(i))},nodeFaded(t){let o=this.drawnHighlight;return!!o&&!o.nodeIds.has(t)}})).views(e=>({get bubbles(){let t=e.indexBubbles?.length?e.indexBubbles:e.derivedBubbles,o=[...t],n=new Set(t.map(Zo));for(let r of e.openBubbleInsides.flat()){let i=Zo(r);n.has(i)||(n.add(i),o.push(r))}return o},get foldNote(){let t=e.graph?.threadFold?.stepless??0;return t>0?`${t.toLocaleString()} ${t===1?"walk":"walks"} with no steps here not drawn`:void 0},get notLoadedNames(){return new Set((e.unfoldedGraph?.nodes??[]).flatMap(t=>t.placeholder?[t.name]:[]))}})).views(e=>({get cutHaplotypes(){},get sourceTrackId(){return e.sourceTrack?.trackId},get sessionTracks(){let t=re(e);return t.tracks.map(o=>({trackId:o.trackId,name:sr(o,t),adapterType:It(o).type,assemblies:wn(t,o)}))}})).views(e=>({get assemblyTrackChoices(){let t=e.graphRegion,o=t&&gn(re(e),t.assemblyName);return o?e.sessionTracks.filter(n=>n.assemblies.includes(o)):[]}})).views(e=>({get geneTrackChoices(){return e.assemblyTrackChoices.filter(t=>Vt.has(t.adapterType))},get repeatTrackChoices(){return e.assemblyTrackChoices.filter(t=>Ti.has(t.adapterType))},get repeatChoices(){return e.repeatArrays??[]}})).views(e=>({get repeatTrack(){return Ii(e.repeatTrackChoices,e.repeatTrackId)},get geneTrack(){return Xt(e.geneTrackChoices,e.geneTrackId)},get walkRowAnnotation(){return jt(this.geneTrack)},get repeatOptions(){return[{value:"",label:"Whole window"},...e.repeatChoices.map(({key:t,name:o,unit:n})=>({value:t,label:`${o} \xB7 ${n.toLocaleString()} bp unit`}))]},get selectedRepeat(){return e.repeatChoices.find(t=>t.key===e.repeatKey)},get backbone(){return e.graph?go(e.graph):void 0},get cutWalkRows(){let t=e.walkCut,o=t?.walkRowRuns,n=this.rowVisitsNeeded;return t&&o&&n&&e.graphRegion?Za(t,e.graphRegion,void 0,!0):o?yo(o):e.graph?Ne(e.graph,e.graphRegion,void 0,{visits:n}):void 0},get rowVisitsNeeded(){return e.chosenLayoutMode==="walkrows"&&(e.walkRibbons||e.layerSet.has("walkBlocks")||e.walkRowOrder==="shared")},assemblySpellings(t){let{assemblyManager:o}=re(e),n=o.has(t)?o.get(t):void 0,r=e.sourceAdapter?.assemblyNameToPanSN??{},i=[t,...n?[n.name,...n.aliases]:[]];return{name:t,aliases:[...i,...i.flatMap(a=>r[a]??[])]}},get drawsLoadedReference(){let t=e.graph;return t?.anchoredBy==="tags"||t?.referencePath!==void 0&&t.referencePath===e.loadedReferencePath}})).views(e=>({get geneAssembly(){let t=e.graphRegion;return t?e.assemblySpellings(t.assemblyName):void 0},get geneLaneFilter(){let t=e.containingView;if(!t)return;let o=Gi(t,e.geneTrack?.trackId);return o.length?new Oa({filters:o,jexl:qn(e).pluginManager.jexl}):void 0},get geneFeatures(){let t=e.geneTrackFeatures,o=this.geneLaneFilter;return t?_i(o?t.filter(n=>o.passes(n)):t):void 0},get genesBindBackbone(){let{geneAssembly:t}=this;return e.drawsLoadedReference||t!==void 0&&wo(e.backbone,[t])!==void 0},get backboneGenes(){let{backbone:t}=e,{geneFeatures:o}=this;return t&&o&&this.genesBindBackbone?bo(o,t):void 0}})).views(e=>{let t=Le(()=>{let n=e.drawnBatch.collapsed;return{nodes:n?.nodes??xt.nodes,within:n?.within??xt.within}},{equals:(n,r)=>ro(n.nodes,r.nodes)&&ro(n.within,r.within)}),o=Le(()=>Ye(e.drawnBatch),{equals:ro});return{get folded(){return t.get().nodes},get notDrawn(){return o.get()},get foldedWithin(){return t.get().within}}}).views(e=>({get nodeNeighbors(){return e.drawnGraph?q(e.drawnGraph):void 0},get drawnFold(){return e.drawnBatch.collapsed},get nodeInk(){return kt(e.drawnGraph,e.nodeById,e.contigThickness,e.nodeWidth,e.drawnGraph?.threadFold?e.drawnWalks:0,this.drawnFold?.through)},get allDeletions(){return e.graph&&this.drawsNodes?ze(e.graph):[]},get cohortWalkRows(){if(e.chosenLayoutMode!=="walkrows"||!e.graph)return;let t=e.selectedRepeat,o=e.walkCut,n=e.rowVisitsNeeded,r=t?o?Za(o,t,t.unit,n):Ne(e.graph,t,t.unit,{visits:n}):e.cutWalkRows;if(!r)return;let[i,...a]=Bi([r.reference,...r.rows],t?.calls);return{...r,reference:i,rows:a}},get walkRowSampleChoices(){let t=this.cohortWalkRows?.rows??[];return{samples:[...new Set(t.map(o=>o.sample))].sort(),disagreeing:[...new Set(t.filter(o=>o.call?.agrees===!1).map(o=>o.sample))]}},get walkRowSamplesTsv(){let t=e.sourceAdapter?.samplesTsvLocation;return t&&Zn(t)?t:void 0},get walkRowGroupFields(){return vi(e.walkRowSampleTable)},get tubeMapColoring(){let t=e.tubeMapColorBy,o=e.walkRowSampleTable;if(!t||!o||!this.walkRowGroupFields.includes(t))return;let n=$i(t,o),r=(e.graph?.paths??[]).map(i=>ie(i.name).name).filter(i=>i!==e.graph?.referencePath);return{field:t,valueOf:n,palette:Oi(r.map(n)),unvalued:r.some(i=>n(i)==="")}},get tableGroupBy(){let t=e.walkRowGroupBy,o=e.walkRowSampleTable;return t&&o&&this.walkRowGroupFields.includes(t.field)?{groupBy:t,table:o}:void 0},get tubeMapPanelSplit(){let{field:t,sort:o}=e.facetSetting,n=this.tableGroupBy;return t!==""?{by:t,sort:o}:n?{by:"column",...n.groupBy,table:n.table}:void 0},get liftedRowHaplotypes(){let t=e.drawnWalks;return[...new Set((e.cutWalkRows?.rows??[]).filter(o=>t.some(n=>Qe(n.name,o))).map(Po))]},get keptRowSamples(){return e.walkRowsFollowLift?this.liftedRowHaplotypes:e.walkRowSamples},get keptCohortRows(){let t=this.cohortWalkRows,o=t&&Ze(t.rows,this.keptRowSamples);if(!t||!o||e.walkRowOrder!=="shared")return o;let n=[t.reference,...o];return kr(n).filter(r=>r>0).map(r=>n[r])},get walkRowGroups(){let t=this.keptCohortRows,o=this.tableGroupBy;return t&&o?Mi(t,o.table,o.groupBy):void 0},get walkRowBars(){let t=this.cohortWalkRows,o=this.keptCohortRows;return t&&o?{...t,rows:this.walkRowGroups?.rows??o}:void 0},get walkRowList(){let t=this.walkRowBars;return t?[t.reference,...t.rows]:[]},get walkRowRibbons(){let t=this.walkRowGroups?.sections??[];return e.walkRibbons&&e.rowVisitsNeeded&&this.walkRowBars?xr(this.walkRowList).filter(({row:o})=>tn(t,o)===tn(t,o+1)):void 0},get sharedBlocks(){return e.layerSet.has("walkBlocks")&&e.rowVisitsNeeded&&this.walkRowBars?Sr(this.walkRowList):void 0},get drawsNodes(){return Y(e.drawnLayoutMode??e.chosenLayoutMode).drawsNodes},get labelsNodeSizes(){return this.drawsNodes&&!e.layoutResult?.tubeMap&&!e.walkLift},get bubbleHalos(){Uo(e.positionsVersion);let t=e.layoutResult?.nodePositions,o=e.showBubbles?e.bubbles:e.hoveredBubble?[e.hoveredBubble]:[];if(o.length===0||!this.drawsNodes||!e.graph||!t)return[];let{folded:n,foldedWithin:r}=e,i=n.size?Object.fromEntries(Object.entries(t).filter(([a])=>!n.has(a))):t;return In(e.graph,o,i,e.repeatArrays).filter(a=>!a.nodeIds.every(s=>r.has(s)))},get referenceRamp(){return e.effectiveColorScheme==="reference-position"?e.drawnReferenceRamp:void 0},get assemblyNames(){let t=e.graphRegion;return t?[t.assemblyName]:[]},get axisScale(){return _t(e.scale,e.pixelRows)},get scaleX(){return this.axisScale.scaleX},get scaleY(){return this.axisScale.scaleY}})).views(e=>{let t=Le(()=>{Uo(e.positionsVersion);let o=e.layoutResult?.nodePositions,n=e.ownGeneFeatures??[],r=[...za(e.backboneGenes??[],e.viewWindow),...n];return e.showGenes&&e.drawsNodes&&e.graph&&r.length>0&&o?Ka(et(e.graph,r,o,e.layoutResult?.stranded),new Set(n),e.outsideView):Vd},{equals:jd});return{get genePins(){return t.get()}}}).views(e=>({get exonOutlines(){let{genePins:t,walkLift:o}=e,n=o?void 0:e.openBubbleFocus,r=n?t.map(i=>({...i,exonsByNode:i.exonsByNode.filter(a=>n.nodeIds.has(a.nodeId))})):t;return Ct(r,e.nodeInk.halfWidthPx,o,void 0,e.notDrawn)}})).views(e=>({get screenTransform(){return{scaleX:e.scaleX,scaleY:e.scaleY,translateX:e.translateX,translateY:e.translateY}},toScreen(t){return{x:t.x*e.scaleX+e.translateX,y:t.y*e.scaleY+e.translateY}},get deletionDrawing(){return e.graph?Ke(e.graph,e.allDeletions,e.showDeletionEdges):void 0},get deletions(){return this.deletionDrawing?.shown??[]},get deletionEdgeIndexes(){return this.deletionDrawing?.bypassed},get hiddenEdgeIndexes(){return this.deletionDrawing?.hidden},get referenceRampDomain(){let t=e.referenceRamp;return t?{start:t.start,end:t.start+t.span}:void 0},get paintsNodeColors(){return e.drawsNodes||!!e.layoutResult?.tubeMap},get tubeMapNodeColors(){let t=e.drawnGraph;return e.layoutResult?.tubeMap&&t?Dn(t,e.effectiveColorScheme,e.referenceRamp):void 0},get tubeColorKind(){let t=e.layoutResult,o=e.drawnGraph?.paths??[],n=e.tubeMapReads;return t?.tubeMap?e.tubeMapColoring&&!n?"value":t.tubeMapPanels?"role":this.tubeMapNodeColors?"tinted":!n&&(!Lt(o.length)||o.some(r=>r.members))?"role":"path":void 0},tubeColorsOf(t,o){let n=t.paths??[],r=this.tubeColorKind,i=e.tubeMapColoring;return r==="value"&&i?Wi(n,t.referencePath,i.valueOf,i.palette):r==="tinted"?on(n,t.referencePath,Ci):r==="role"?on(n,t.referencePath):o},fadeUnhovered(t,o,n){let r=new Set(e.hoveredRowWalks);return r.size>0?t.map((i,a)=>{let s=o[a]?.name??"";return r.has(s)||n!==void 0&&ie(s).name===n?i:Nt}):t},get tubeMapTubeColors(){let t=e.layoutResult?.tubeMap,o=e.drawnGraph;return t&&o?this.fadeUnhovered(this.tubeColorsOf(o,t.pathColors),o.paths??[]):void 0},nodeSpan(t){return es(t,e.nodeById,e.nodeNeighbors,e.threadEvents)},get hoverDrawing(){let t=e.hoveredPanel;return(t===null?void 0:e.layoutResult?.tubeMapPanels?.[t]?.result.tubeMap)??e.layoutResult?.tubeMap},get hoverGraph(){return this.hoverDrawing?.graph??e.drawnGraph},get hoverNodeById(){let t=this.hoverGraph;return t===e.drawnGraph?e.nodeById:t&&Qa(t)},get hoverNeighbors(){let t=this.hoverGraph;return t===e.drawnGraph?e.nodeNeighbors:t&&q(t)}})).views(e=>({get pathLegend(){let t=e.drawnGraph?.paths;return(e.layoutResult?.tubeMap?e.tubeColorKind==="path":e.drawPaths)&&t&&Lt(t.length)&&!t.some(n=>n.members)?Ue(t,e.tubeMapTubeColors):[]},get hoveredSpan(){let t=e.hoveredNode,o=e.hoveredBubble;return t!==null?es(t,e.hoverNodeById,e.hoverNeighbors,e.threadEvents):o&&!o.offReference?{start:o.start,end:o.end}:void 0},get hoverHighlight(){let t=e.graphRegion,o=this.hoveredSpan;return t&&o&&e.chosenHover!=="off"?{refName:t.refName,assemblyName:t.assemblyName,...o}:void 0}}));var os=ts.views(e=>({get host(){let t=e.containingView;return qt(t)?t:void 0}})).views(e=>({get pairedViewId(){return e.host?.id??e.connectedViewId}})).views(e=>({get contributingAssemblies(){let t=e.graph,o=t?pe(t):[];return t?aa(t,{maxGap:o.length>0?ho(o):1/0}):[]}})).views(e=>({get assemblyResolver(){let{assemblyManager:t}=re(e),o=e.sourceAdapter?.assemblyNameToPanSN,n=new Map(Object.entries(o??{}).map(([i,a])=>[a,i])),r=i=>i!==void 0&&t.has(i)?t.get(i)?.name??i:void 0;return i=>r(n.get(i))??r(i)},get geneTracksByAssembly(){let t=new Map;for(let o of e.sessionTracks)if(Vt.has(o.adapterType)&&jt(o)===e.walkRowAnnotation)for(let n of o.assemblies)t.set(n,[...t.get(n)??[],o]);return new Map([...t].flatMap(([o,n])=>{let r=Xt(n,"");return r?[[o,r]]:[]}))}})).views(e=>({get launchableAssemblies(){return sa(ca(e.contributingAssemblies,e.graphRegion),e.assemblyResolver)},get canHighlightInLinearView(){let t=e.graphRegion;return t!==void 0&&Be({views:[...re(e).views],connectedViewId:e.pairedViewId,assemblyName:t.assemblyName})!==void 0},nodeLaunchTargets(t){let o=e.nodeById?.get(t),n=o?hn(o):void 0,r=n?Se(e.assemblyResolver,n):void 0,i=e.graphRegion,a=i?e.nodeSpan(t):void 0,s=i&&a?{sample:i.assemblyName,haplotype:void 0,refName:i.refName,...a}:void 0;return{own:n&&r?{location:yn(n),assembly:r}:void 0,reference:i&&s?{location:yn(s),assembly:i.assemblyName}:void 0,highlight:i&&s?{location:s,assembly:i.assemblyName}:void 0}},get ownGeneReads(){let{graph:t}=e;return!t||!e.showGenes||!e.modeDrawsNodes?[]:ia(t,e.assemblyResolver,e.graphRegion?.assemblyName).flatMap(({stableRefName:o,assemblyName:n,refName:r,start:i,end:a})=>{let s=e.geneTracksByAssembly.get(n);return s?[{stableRefName:o,trackId:s.trackId,region:{assemblyName:n,refName:r,start:i,end:a}}]:[]}).slice(0,qr)},get assemblyHoverHighlights(){let t=e.hoveredNode,o=t===null?void 0:e.nodeById?.get(t);return o&&e.graph&&e.chosenHover!=="off"?ra(e.graph,o,e.assemblyResolver,e.graphRegion?.assemblyName):[]}}));var ns=os.views(e=>({get walkStripShown(){return kn({walkStrip:e.walkStrip,mode:{drawsNodes:e.modeDrawsNodes},drawsPicture:!!e.layoutResult?.tubeMap||!!e.walkRowBars,walks:e.graph?.paths?.length??0,host:!!e.host})},get walkStripRows(){let t=this.walkStripShown?e.cutWalkRows:void 0;return t?{...t,rows:Ze(t.rows,e.keptRowSamples)}:void 0},get walkStripInks(){return we(e.drawnWalks)},get walkStripFrame(){let t=this.walkStripRows;return t?{...dt(t,{width:e.paneWidth}),measure:Te}:void 0},get cutsWholeWalks(){let t=Y(e.chosenLayoutMode);return e.sourceAdapter?.type==="GbzBaseSyntenyAdapter"&&xn(t,{walkStrip:e.walkStrip&&t.drawsNodes,host:!!e.host})},get walkStripMarks(){let t=this.walkStripRows,o=e.hoveredNode??e.selectedNode,n=o===null?void 0:e.nodeById?.get(o);return t&&n&&e.graph?Sn(e.graph,[t.reference,...t.rows],n):[]},rowLocation(t,o){let n={sample:t.sample,haplotype:t.haplotype===void 0?void 0:`${t.sample}#${t.haplotype}`};return{...n,assembly:Se(e.assemblyResolver,n),span:{refName:o.contig,...Et(o,t.bp)}}},get comparedRows(){return e.rowVisitsNeeded?e.walkRowBars?.rows??[]:[]},get passBars(){return!e.host&&e.drawsNodes&&!e.facetPanels?ct(e.walkLift,this.walkStripRows):[]},get walkStripLocator(){let t=e.stripHover?e.hoveredNode:null;return t===null||e.folded.has(t)?void 0:yi(e.nodePositions?.[t],e.toScreen)}})).views(e=>({get walkGeneReads(){let t=e.walkRowBars??e.walkStripRows;if(!t||!e.showGenes)return;let o=t.rows.filter(i=>!i.stepless),n=o.flatMap(i=>{let a=i.axis?e.rowLocation(i,i.axis):void 0,s=a?.assembly,d=s?e.geneTracksByAssembly.get(s):void 0;return a&&s&&d?[{row:i.name,trackId:d.trackId,region:{assemblyName:s,...a.span}}]:[]}),r=o.filter(i=>!i.axis).length;return{reads:n.slice(0,Ko),gaps:{untracked:o.length-r-n.length,unplaced:r,unread:Math.max(0,n.length-Ko)}}},get walkRowGeneGaps(){return this.walkGeneReads?.gaps},walkRowLaunchTarget(t,o=e.walkRowBars){let n=o?[o.reference,...o.rows][t]:void 0;if(!n?.axis)return;let{sample:r,haplotype:i,assembly:a,span:s}=e.rowLocation(n,n.axis);return{label:n.label,assembly:t===0?e.graphRegion?.assemblyName:a,location:{sample:r,haplotype:i,...s}}},get walkRowGenes(){let t=e.walkRowBars??e.walkStripRows;if(!t||!e.showGenes)return;let o=new Map(e.walkGeneFeatures??[]);return e.geneFeatures&&e.genesBindBackbone&&o.set(t.reference.name,e.geneFeatures),o.size?$r([t.reference,...t.rows],o):void 0}}));var rs=ns.views(e=>({get xIsReferenceBp(){return e.layoutResult?.referenceAxis===!0&&Y(e.drawnLayoutMode??e.chosenLayoutMode).cutMargins}})).views(e=>({get hostPlacesX(){let{host:t,graphRegion:o}=e;return t!==void 0&&t.initialized&&o!==void 0&&e.xIsReferenceBp&&!xe(t).some(n=>n.refName===o.refName&&n.reversed)}})).views(e=>({get hostBpFrame(){let{host:t,graphRegion:o}=e;return t?.initialized&&o?Zi(t,o):void 0}})).views(e=>({get hostFrame(){return e.hostPlacesX?e.hostBpFrame:void 0},get tubeMapPicture(){let t=e.layoutResult?.tubeMap;return t?Ai(t):void 0},get tubeMapReference(){let t=e.layoutResult?.tubeMap;return t?ki(t):void 0},get tubeMapDeviations(){let t=e.layoutResult?.tubeMap;return t?.coarse?Ei(t,t.coarse.deviations):[]},get tubeMapConnectedBoxes(){let t=this.tubeMapReference,{layoutResult:o}=e;return t&&!o?.referenceAxis&&!o?.tubeMapPanels?[...t.values()].flat():void 0}})).views(e=>({get tubeMapGenes(){let t=e.tubeMapReference;return e.showGenes&&!e.host&&t&&e.backboneGenes&&!e.layoutResult?.tubeMapPanels?xi(t,e.backboneGenes):[]},get referenceStripApplies(){return!!e.host?.initialized&&!!e.layoutResult&&e.drawsNodes&&!e.hostPlacesX&&!e.facetPanels}})).views(e=>({get referenceStripBlocks(){let{graph:t}=e;if(!e.showReferenceStrip||!e.referenceStripApplies||!t)return[];let o=gi(t,{colorScheme:e.effectiveColorScheme,referenceRamp:e.referenceRamp,walks:e.walkLift?.walks}),n=e.walkLift?void 0:e.openBubbleFocus;return n?o.map(({pieces:r,...i})=>n.nodeIds.has(i.node)?{...i,...r?{pieces:r}:{}}:{...i,colors:[Nt],faded:!0}):o}})).views(e=>({get referenceStripShown(){return e.referenceStripBlocks.length>0&&e.hostBpFrame!==void 0},get referenceStripFaded(){let t=e.hostBpFrame;return t!==void 0&&wi(e.referenceStripBlocks,t,e.paneWidth)}})).views(e=>({get referenceStripLit(){let t=e.hoveredNode===null?e.hoveredBubble:null,o=e.litNode??e.selectedNode,n=t&&!t.offReference?{start:t.start,end:t.end}:o===null?void 0:e.nodeSpan(o);return e.referenceStripShown?n:void 0},get referenceStripNode(){let t=e.hoveredNode===null?e.hoveredBubble:null,o=e.litNode??e.selectedNode;return this.referenceStripLit&&!(t&&!t.offReference)&&o!==null&&!e.folded.has(o)?o:null},referenceStripNodeAt(t,o){let n=e.hostBpFrame;return e.referenceStripShown&&n?bi(e.referenceStripBlocks,n,t,o):void 0},get referenceStripZonePx(){return e.referenceStripShown?Dt:0}}));var Yd=3e3,zd=350,Kd=34;function Ud(e){let t=[0];for(let o=1;o<e.length;o++)t.push(t[o-1]+Math.hypot(e[o].x-e[o-1].x,e[o].y-e[o-1].y));return t}function qd(e,t){if(e.length===1||t===1)return Array.from({length:t},()=>({...e[0]}));let o=Ud(e),n=o.at(-1),r=[],i=1;for(let a=0;a<t;a++){let s=n*a/(t-1);for(;i<e.length-1&&o[i]<s;)i++;let d=o[i]-o[i-1],p=d>0?(s-o[i-1])/d:0,m=e[i-1],c=e[i];r.push({x:m.x+(c.x-m.x)*p,y:m.y+(c.y-m.y)*p})}return r}var Zd=400,is=1.8,Jd=.1;function eE(e,t,o,n,r){let i=b=>({x:(b.x*t.scaleX+t.translateX-n.translateX)/n.scaleX,y:(b.y*t.scaleY+t.translateY-n.translateY)/n.scaleY}),a={};for(let[b,y]of Object.entries(o)){let x=e[b];x?.length&&y.length&&(a[b]=qd(x.map(i),y.length))}let s=new Map,d=(b,y)=>{let x=s.get(b);x?x.push(y):s.set(b,[y])};for(let b of r){let{from:y,to:x}=b;if(y!==x&&o[y]?.length&&o[x]?.length){let P=te(b);d(y,{id:x,side:P.to}),d(x,{id:y,side:P.from})}}let p=new Map,m=b=>p.get(b.id)??(b.side==="start"?a[b.id][0]:a[b.id].at(-1)),c=Object.keys(a),l=[];for(let b of c)for(let y of s.get(b)??[]){if(a[y.id]||p.has(y.id))continue;let x=s.get(y.id).find(P=>P.id===b);p.set(y.id,{...m(x)}),c.push(y.id),l.push(y.id)}let h=new Map(l.map((b,y)=>[b,y])),u=new Float64Array(l.map(b=>p.get(b).x)),f=new Float64Array(l.map(b=>p.get(b).y)),g=new Float64Array(l.length),w=new Float64Array(l.length),k=l.map((b,y)=>s.get(b).flatMap(x=>{let P=h.get(x.id);if(P===void 0){let M=m(x);return g[y]+=M.x,w[y]+=M.y,[]}return[P]})),R=l.map(b=>s.get(b).length);for(let b=0;b<Zd;b++){let y=0;for(let x=0;x<l.length;x++){let P=g[x],M=w[x];for(let B of k[x])P+=u[B],M+=f[B];let V=is*(P/R[x]-u[x]),S=is*(M/R[x]-f[x]);y=Math.max(y,Math.abs(V*n.scaleX)+Math.abs(S*n.scaleY)),u[x]+=V,f[x]+=S}if(y<Jd)break}l.forEach((b,y)=>{a[b]=o[b].map(()=>({x:u[y],y:f[y]}))});for(let[b,y]of Object.entries(o))a[b]??=y.map(x=>({...x}));return a}function Qd(e,t){let o=0,n=1/0;return e.forEach((r,i)=>{let a=(r.x-t.x)**2+(r.y-t.y)**2;a<n&&(n=a,o=i)}),o}function tE(e,t,o,n){let r=(i,a)=>{let s=o[i],d=n[i];if(!s||!d||d.length===0)return{x:0,y:0};let p=Qd(d,a);return{x:s[p].x-d[p].x,y:s[p].y-d[p].y}};return Object.fromEntries(Object.entries(e).map(([i,a])=>{let s=t[Number(i)],d=r(s?.from??"",a[0]),p=r(s?.to??"",a.at(-1));return[i,a.map((m,c)=>{let l=a.length>1?c/(a.length-1):0;return{x:m.x+d.x+(p.x-d.x)*l,y:m.y+d.y+(p.y-d.y)*l}})]}))}function as(e,t,{ids:o,alpha:n}){let r=(i,a)=>{for(let s=0;a&&s<a.count;s++){let d=i[a.start+s];d.color=Mr(d.color,n)}};for(let i of o)r(e.nodeStrokes,e.nodeStrokeRuns.get(i));t.forEach(({from:i,to:a},s)=>{(o.has(i)||o.has(a))&&(r(e.edgeCurves,e.edgeCurveRuns.get(s)),r(e.arrows,e.arrowRuns.get(s)))})}function ep(e){return e<.5?4*e*e*e:1-(-2*e+2)**3/2}function oE(e,t,o,n){return!(e.referenceAxis||t.referenceAxis||e.pixelRows||t.pixelRows||t.tubeMap||n||o>Yd)}function nE(){return typeof requestAnimationFrame<"u"&&!("matchMedia"in window&&window.matchMedia("(prefers-reduced-motion: reduce)").matches)}function rE(e,t,o){let n={frame:0,finish:()=>{e(1)}},r=0,i=performance.now(),a=()=>{if(!t()){e(1),o();return}let s=performance.now();r+=Math.min(s-i,Kd),i=s;let d=Math.min(1,r/zd);e(ep(d)),d<1?n.frame=requestAnimationFrame(a):o()};return n.frame=requestAnimationFrame(a),n}function iE(e,t,o,n){for(let[r,i]of Object.entries(e)){let a=t[r],s=o[r];!a||!s||i.forEach((d,p)=>{d.x=n===1?s[p].x:a[p].x+(s[p].x-a[p].x)*n,d.y=n===1?s[p].y:a[p].y+(s[p].y-a[p].y)*n})}}var tp={x:1,y:.5};function op(e){let t=new Map(e.nodes.map(i=>[i.id,i])),o=q(e),n=new Map;for(let{id:i}of e.nodes){let a=qe({nodeId:i,nodeById:t,neighbors:o});a&&n.set(i,a)}let r=[...n.keys()];for(;r.length>0;){let i=[];for(let a of r){let s=n.get(a);for(let d of o.get(a)??[])s&&!n.has(d)&&(n.set(d,s),i.push(d))}r=i}return n}function ss(e,t,o){let n=_(e)?t==="start"==(lo(e.id)===(e.stable.strand??"+"))?e.stable.start:e.stable.start+e.length:void 0;return n===void 0?o:{start:n,end:n}}function cs(e){let t={x:1/0,y:1/0},o={x:-1/0,y:-1/0};for(let{x:n,y:r}of e)t.x=Math.min(t.x,n),t.y=Math.min(t.y,r),o.x=Math.max(o.x,n),o.y=Math.max(o.y,r);return{low:t,high:o}}var wt=(e,t)=>{let o=(t-e.bp0)/(e.bp1-e.bp0);return{x:e.x0+(e.x1-e.x0)*o,y:e.y0+(e.y1-e.y0)*o}};function ms(e,t,o,n){let r=op(e),i=new Map(e.nodes.map(p=>[p.id,p])),a=o.pieces.flatMap(p=>[{start:p.bp0,end:p.bp0,low:wt(p,p.bp0),high:wt(p,p.bp0)},{start:p.bp1,end:p.bp1,low:wt(p,p.bp1),high:wt(p,p.bp1)}]),s=e.nodes.flatMap(p=>{let m=t.nodePositions[p.id],c=r.get(p.id);return n.has(p.id)&&!_(p)&&c&&m?.length?[{start:c.start,end:c.end,...cs(m)}]:[]}),d=e.edges.flatMap((p,m)=>{let c=i.get(p.from),l=i.get(p.to),h=te(p),u=c&&n.has(c.id)?ss(c,h.from,r.get(c.id)):void 0,f=l&&n.has(l.id)?ss(l,h.to,r.get(l.id)):void 0;return u&&f?[{edge:m,start:Math.min(u.start,f.start),end:Math.max(u.end,f.end)}]:[]});return{pieces:o.pieces,boxes:[...a,...s],links:d}}var ds=16,np=e=>Array.from({length:ds+1},(t,o)=>mo(e,o/ds));function ls(e,t){let o=e.links.flatMap(({edge:n,start:r,end:i})=>{let a=t.get(n)??[];return a.length>0?[{start:r,end:i,...cs(a.flatMap(np))}]:[]});return{...e,boxes:[...e.boxes,...o],links:[]}}var rp=(e,t,o)=>Math.max(0,e.start-o,t-e.end);function ip({pieces:e},t){let o=[];for(let n of e)for(let r of[t.start,t.end])if(n.bp0<r&&r<n.bp1){let i=wt(n,r);o.push({start:r,end:r,low:i,high:i})}return o}function io(e,t,o,n,r){let i=tp[n],a=1/0,s=-1/0,d=0,p=0,m=0,c=0;for(let l of e)for(let h of l){let u=o*rp(t,h.start,h.end),f=h.low[n]*r+i*u,g=h.high[n]*r-i*u;f<a&&(a=f,d=h.low[n],m=u),g>s&&(s=g,p=h.high[n],c=u)}return{low:a,high:s,drawn:p-d,away:i*(m+c)}}var ap=64;function ps(e,t,o,n,r){let i=ko(1/0),a=io(e,t,o,n,i);for(let s=0;s<ap&&a.high-a.low>r+1e-6;s++)i=(r+a.away)/a.drawn,a=io(e,t,o,n,i);return i}function sp(e,t){let o=t.end-t.start,n=Math.max(e.start,Math.min(t.start,e.end-Math.min(o,e.end-e.start)));return{start:n,end:Math.min(e.end,n+o)}}function us(e,t,o,n,r){let i=n.width-r.padLeft-r.padRight,a=n.height-r.padTop-r.padBottom,s=sp(t,o),d=i/o.span,p=[e.boxes,ip(e,s)];if(e.boxes.length>0&&i>0&&a>0){let m=Math.min(ps(p,s,d,"x",i),ps(p,s,d,"y",a)),c=io(p,s,d,"x",m),l=io(p,s,d,"y",m);return{scale:m,translateX:r.padLeft+(i-c.low-c.high)/2,translateY:r.padTop+(a-l.low-l.high)/2}}}function gs(e,t,o){let n=Fo(e,t.nodePositions),r=o?Ho(e,o):new Set;return{profile:n,bounds:o&&Do(e,t,o),segments:mn(e,t),counted:r,reference:ln(n),parts:ms(e,t,n,r),region:o,landed:structuredClone({nodes:t.nodePositions,routes:t.deletionRoutes})}}var hs=1/64,dp=e=>2**(Math.round(Math.log2(e)/hs)*hs),fs=new WeakMap,pp=4,cp=(e,t)=>ls(e.parts,So(e.landed.nodes,e.graph,{scaleX:t,scaleY:t},e.deletions,0,e.landed.routes,e.stranded));function mp(e,t,o){let n=fs.get(e)??{recent:new Map};fs.set(e,n);let r=o?n.pinned?.scale===t?n.pinned.parts:void 0:n.recent.get(t),i=r??cp(e,t);if(!r&&o&&(n.pinned={scale:t,parts:i}),!r&&!o){n.recent.set(t,i);for(let a of n.recent.keys())n.recent.size>pp&&n.recent.delete(a)}return i}var jn=new WeakMap;function FE(e,t,o){jn.has(t)||jn.set(t,gs(e,t,o))}var lp=8,up=19,hp=48;function fp(e,t,o){if(!(!e||!t))return At(e.rowPx,e.barPx)?o:{untracked:0,unread:0,...o,crowded:!0}}var HE=rs.views(e=>({get paneCeiling(){return Math.max(Bt,e.paneHeight??Xr)},get fitRoom(){return e.host?this.canvasHeight:this.paneCeiling},get walkRowPitch(){let t=e.walkRowBars;if(t)return Tt(t.rows.length+1,this.fitRoom-this.fitPadTop-I-Ni(e.walkRowGroups?.sections??[]))},get walkRowPlacement(){let t=this.walkRowPitch;return t?Pi(e.walkRowGroups?.sections??[],t.rowPx):void 0},get walkRowGeneKey(){return fp(this.walkRowPitch,!!e.walkRowGenes?.size,e.walkRowGeneGaps)},get drawnRowLabels(){let t=this.walkRowPlacement,o=Ge(e.walkRowBars,e.layoutResult,this.walkRowPitch);return e.walkRowBars&&t?o.map((n,r)=>({...n,y:t.rowY(r)})):o},get visibleRowLabels(){return this.drawnRowLabels.flatMap(({label:t,y:o})=>{let n=e.toScreen({x:0,y:o}).y;return n>=0&&n<=this.canvasHeight?[{label:t,y:o,top:n}]:[]})},get fitPadLeft(){return this.drawnRowLabels.reduce((t,o)=>Math.max(t,ur(o.label,0).x1+6),I)},get layoutBounds(){let t=e.layoutResult,o=e.walkRowBars,n=o&&t?.extent?Ie(o,this.walkRowPitch,{widthPx:this.drawingWidth-this.fitPadLeft-I,measure:Te,comparing:e.rowVisitsNeeded}):void 0;return t?ot(t,{region:e.graphRegion,extent:n&&{...n,maxY:n.maxY+(this.walkRowPlacement?.headersPx??0)}}):void 0},get keyColumnPx(){let t=e.facetPanels||e.tubeMapReads||e.keyPlacement!=="column"?0:Ot({legendSize:this.framedLegendSize});return t<e.paneWidth?t:0},get framedLegendSize(){return e.keyFrame??e.legendSize},get drawingWidth(){return e.paneWidth-this.keyColumnPx},get canvasFloor(){return Math.max(Bt,e.facetPanels?0:rt({legendSize:this.framedLegendSize,referenceStripZonePx:e.referenceStripZonePx}))},walkRowReadoutOf(t){let o=e.walkRowBars;return o?Wr(o,t,{scaleX:e.scaleX,translateX:e.translateX,width:this.drawingWidth,measure:Te},{comparing:e.rowVisitsNeeded}):void 0},get hoveredWalkRowText(){let t=e.walkRowList.findIndex(r=>r.name===e.hoveredWalkRow),o=e.walkRowList[t],n=o?this.walkRowReadoutOf(t):void 0;return o&&n&&(this.walkRowPitch?.readouts===!1||n.full!==n.shown)?{label:o.label,readout:n.full}:void 0},walkRowAt(t,o){let n=e.walkRowBars,r=this.walkRowPitch,i=this.walkRowPlacement;if(!n||!r||!i)return;let a=i.rowAt((o-e.translateY)/e.scaleY,n.rows.length+1),s=e.walkRowList[a],d=i.rowY(a)*e.scaleY+e.translateY,p=(t-e.translateX)/e.scaleX-n.origin,m=s&&r.readouts?this.walkRowReadoutOf(a):void 0,c=s?(n.origin+se(s))*e.scaleX+e.translateX:0,l=!!m&&m.full!==m.shown&&t>=c&&t<=m.x+Te(m.shown);return s&&Math.abs(o-d)<=r.barPx/2+2&&(p>=0&&p<=se(s)||l)?a:void 0},get fitPadTop(){let t=Ri(e.tubeMapGenes);return I+Math.max(0,t-1)*Si+e.referenceStripZonePx},get layoutFit(){return{width:this.drawingWidth,height:(e.host?this.scaleRoom:this.paneCeiling)-(e.host?.initialized&&e.showReferenceStrip?Dt:0)}},get minFitScale(){let t=this.layoutBounds,o=e.layoutResult,n=o?.tubeMap?.layout.tracks[0]?.width;return t&&t.h>0&&n&&!o.referenceAxis?Math.min(Yr/n,(this.paneCeiling-this.fitPadTop-I)/t.h):0},get facetSpec(){let{field:t,sort:o,columns:n}=e.facetSetting;return t===""?void 0:o.length===0&&n===void 0?t:{field:t,sort:[...o],...n===void 0?{}:{columns:n}}},get facetPlacement(){let t=e.facetPanels,{field:o,sort:n}=e.facetSetting;return t?Ht(t.map(r=>r.walks[0].name),e.hostPlacesX||o===""?"walk":o,n):void 0},facetGridIn(t){let o=this.facetPlacement,n=this.layoutBounds;return o&&n&&n.w>0?$t({count:o.count,bounds:n,pixelRows:e.pixelRows,width:e.paneWidth,room:t,columns:e.hostPlacesX?1:o.columns??e.facetSetting.columns}):void 0},get facetKeyPx(){return Ae+Math.max(up,e.facetKeyHeight)},get facetGrid(){return this.facetGridIn(this.fitRoom-this.facetKeyPx)},get canvasHeight(){let t=this.layoutBounds,o=Math.max(this.paneCeiling,this.canvasFloor);if(!t)return o;let n=this.facetGrid;if(n)return Math.max(Bt,n.total+this.facetKeyPx);let r=this.canvasFloor,i=this.fitPads,a=i.top+i.bottom;if(e.pixelRows)return Math.min(o,Math.max(r,t.h+a));let s=e.paneWidth-this.keyColumnPx-i.left-i.right;return t.w>0&&s>0?Math.min(o,Math.max(r,t.h*Math.max(s/t.w,this.minFitScale)+a)):o},get viewBox(){let t=this.facetGrid;return t?{width:t.width,height:t.height}:{width:e.paneWidth,height:this.canvasHeight}},get fitPads(){return this.facetGrid?{left:de,top:de,right:de,bottom:de}:{left:this.fitPadLeft,top:this.fitPadTop,right:I,bottom:I}},get usableHeight(){let{top:t,bottom:o}=this.fitPads;return this.viewBox.height-t-o},get snapsHostCut(){let{host:t,graphRegion:o}=e,n=t&&pn(t);return!!t&&Qi(e.chosenLayoutMode)==="snapped"&&!xe(t).some(r=>r.reversed&&(r.refName===o?.refName||r.refName===n?.refName))},get placedByWindow(){let t=e.layoutResult;return this.snapsHostCut&&e.drawnLayoutMode==="force"&&!!t&&!t.referenceAxis&&!t.pixelRows&&!t.tubeMap},get followsWindow(){return this.placedByWindow&&!e.facetsWalks},get frame(){return na},get framesView(){return this.frame==="view"&&this.trackFit==="fit"&&this.followsWindow&&e.host?.displayedRegions.length===1},get trackFit(){return"fit"},get scaleRoom(){return this.canvasHeight},get heldLayout(){let{graph:t,layoutResult:o,graphRegion:n}=e;return t&&o&&this.followsWindow?jn.get(o)??gs(t,o,n):void 0},get heldReference(){return this.heldLayout?.profile},get heldBounds(){return this.heldLayout?.bounds??this.layoutBounds},get followPads(){let t=e.keyPlacement!=="column";return{padLeft:t?0:this.fitPadLeft,padTop:this.fitPadTop,padRight:t?0:I,padBottom:I}},get heldWindow(){let{host:t}=e;return t&&this.followsWindow?pn(t):void 0},get viewFrame(){let t=this.framesView?this.heldLayout:void 0,o=t?.region,n=this.heldWindow,r=this.frameInputs,i=this.heldScale,a=(d,p)=>r&&o&&n?us(mp(r,dp(d),p),o,n,{width:this.drawingWidth,height:this.canvasHeight},this.followPads):void 0,s=t&&o&&i!==void 0&&n?.refName===o.refName&&n.start<o.end&&n.end>o.start?a(i,!0):void 0;return s?a(s.scale,!1):void 0},get frameInputs(){let{graph:t,layoutResult:o}=e,n=this.heldLayout?.landed,r=this.heldLayout?.parts;return t&&o&&n&&r?{parts:r,graph:t,landed:n,deletions:e.deletionEdgeIndexes,stranded:o.stranded}:void 0},get viewSpan(){return this.heldWindow?.span},get heldScale(){let t=this.heldReference,o=e.graphRegion,n=this.heldBounds,r=this.viewSpan;return t&&o&&n&&r?cn(this.trackFit,t,o,r,n,this.drawingWidth,this.scaleRoom,this.followPads):void 0},get followedTransform(){let{host:t}=e,o=this.heldWindow,n=o&&t?Ji(t):void 0,r=this.heldReference,i=this.heldScale,a=this.heldBounds;return o&&n&&r&&i!==void 0&&a?Yo(r,n,i,a,this.drawingWidth,this.canvasHeight,this.followPads):void 0},get keyBandTop(){let t=this.followedTransform,o=this.heldLayout,n=e.keyPlacement==="overlay"&&!e.facetPanels?rt({legendSize:this.framedLegendSize,referenceStripZonePx:e.referenceStripZonePx}):0,r=t&&o&&n>0&&at(this.trackFit)?it(o.segments,-t.translateX/t.scale,(this.drawingWidth-t.translateX)/t.scale):void 0;return t&&r&&n+2*I+(r.maxY-r.minY)*t.scale<=this.canvasHeight?n+I:void 0},get windowTransform(){let{graphRegion:t,layoutResult:o}=e,n=this.heldWindow,r=this.heldBounds,i=this.heldLayout,a=this.viewFrame??this.followedTransform,s=n&&a&&i&&r&&at(this.trackFit)?{...a,translateY:un({segments:i.segments,reference:i.reference,held:jo(i.profile,n),scale:a.scale,translateX:a.translateX,bounds:r,paneWidth:this.drawingWidth,paneHeight:this.canvasHeight,pads:{...this.followPads,padTop:this.keyBandTop??this.followPads.padTop}})}:a;return s&&o&&(t?.refName!==n?.refName||t?.assemblyName!==n?.assemblyName)?{...s,translateX:e.paneWidth+this.drawingWidth-s.scale*Gt(o.nodePositions).minX}:s},get showsKeyRule(){return this.followsWindow&&this.keyColumnPx>0},get drawingCut(){let t=e.referenceStripShown?fi:0,o=this.showsKeyRule?e.paneWidth-this.drawingWidth:0;return this.followsWindow&&(t>0||o>0)?{top:t,right:o}:void 0},get drawingClip(){let t=this.drawingCut?.right??0;return t>0?`inset(0px ${t}px 0px 0px)`:void 0},get drawingMask(){let t=this.drawingCut?.top??0;return t>0?`linear-gradient(to bottom, transparent ${t}px, black ${t}px)`:void 0},get fittedTransform(){let t=this.layoutBounds,o=this.facetGrid,{width:n,height:r}=o??{width:this.drawingWidth,height:this.canvasHeight},i=this.fitPads;return this.windowTransform??(t?tt(t,n,r,e.pixelRows,{minScale:this.facetGrid?0:this.minFitScale,padLeft:i.left,padTop:i.top,padRight:i.right,padBottom:i.bottom}):void 0)}})).views(e=>({get tooltipRightPx(){return!e.facetPanels&&e.legendSize.width>0&&rt(e)-en>e.canvasHeight-hp?Ot(e):lp},get hoveredNodeScreenBox(){let t=e.hoveredNode;return(t===null?void 0:e.nodePositions?.[t])?.reduce((n,r)=>{let{x:i,y:a}=e.toScreen(r);return n?{x0:Math.min(n.x0,i),x1:Math.max(n.x1,i),y0:Math.min(n.y0,a),y1:Math.max(n.y1,a)}:{x0:i,x1:i,y0:a,y1:a}},void 0)}})).views(e=>({get nodeExtent(){let t=e.layoutResult?Gt(e.layoutResult.nodePositions):void 0;return t&&Number.isFinite(t.minX)?t:void 0}})).views(e=>({get liveBuildView(){return{axis:e.axisScale,bounds:Vr(qo(e),Ur)}},get buildViewSettled(){let t=e.settledBuildView,o=e.nodeExtent;return t!==void 0&&t.layout===e.layoutResult&&Zr(t.view.axis,e.axisScale)&&(zo(t.view.bounds,qo(e))||o!==void 0&&zo(t.view.bounds,o))}})).views(e=>({get buildView(){return e.settledBuildView?.view??e.liveBuildView}})).views(e=>({get geometryPainted(){return Jr(e)},get paintSuperseded(){return!this.geometryPainted},get showLoading(){return e.error===void 0&&(e.isLoading||e.hasPendingSource||e.graph!==void 0&&!this.geometryPainted)}})).views(e=>({applySelection(t){let o=e.selectedNode;t.setNodeHighlights(o===null||e.folded.has(o)?new Map:new Map([[o,Kr]]))},get hoverLayerNode(){let{litNode:t,selectedNode:o}=e;return t===o?null:t},get paintTransform(){let t=Fi();return{scaleX:e.scaleX*t,scaleY:e.scaleY*t,translateX:e.translateX*t,translateY:e.translateY*t,dpr:t}}})).views(e=>({paint(t){t.updateTransform(e.paintTransform),t.render(e.referenceStripShown?[0,0,0,0]:jr)}})).views(e=>({drawingOptions(t,o,n){let{graph:r,nodeById:i,layoutResult:a,deletionDrawing:s}=e,d=a&&s&&mt(a,s,{drawsRows:!!e.walkRowBars});return r&&i&&d?{...d,nodePositions:qa(d.nodePositions,e.outsideView,e.positionsVersion),graph:r,nodeById:i,colorScheme:e.effectiveColorScheme,contigThickness:e.contigThickness,connectorThickness:e.connectorThickness,drawPaths:o,nodeWidth:e.nodeWidth,encoding:{site:e.chosenSite},edgeWidth:e.linkWidth,highlight:t,axis:n.axis,linearLayout:e.linearLayout,viewportBounds:n.bounds,referenceRamp:e.referenceRamp,version:e.positionsVersion,smallSites:e.smallSites,lineEnds:e.chosenLineEnds}:void 0}})).views(e=>({buildDrawing(t,o,n=e.buildView){let r=e.drawingOptions(t,o,n),i=r&&Pt(r),a=e.morphEntering;return r&&i&&a&&a.layout===e.layoutResult&&as(i,r.graph.edges,a),i&&{batch:i,view:n}},get facetDrawings(){return e.facetPanels?.map(t=>this.buildDrawing(t,!1))},hoveredOn(t){let o=e.hoveredNode,n=o?e.nodeById?.get(o):void 0,r=n&&Qo(t,n.id,n.length);return r&&(r.onWalk?r.at:"not on this walk")},get figureUnavailable(){return e.layoutResult?e.walkRowGroups?"The SVG export cannot group walk rows yet: set Group by... to None first":e.drawsNodes||e.walkRowBars?void 0:`${Y(e.chosenLayoutMode).label} draws a picture of its own, which the SVG export does not`:"Nothing is drawn yet"},figure(){let{graph:t,layoutResult:o}=e,n=!!e.host&&!e.facetGrid,r=e.drawingCut?.top??0,i=e.screenTransform;return t&&o&&!this.figureUnavailable?Tn(t,o,{width:e.showsKeyRule?e.drawingWidth:e.paneWidth,height:n?e.canvasHeight-r:e.paneCeiling,frame:n?{...i,translateY:i.translateY-r}:void 0,walks:e.walkLayers,facet:e.facetSpec,colorScheme:e.effectiveColorScheme,nodeWidth:e.nodeWidth,edgeWidth:e.linkWidth,showDeletionEdges:e.showDeletionEdges,smallSites:e.smallSites,lineEnds:e.chosenLineEnds,linearLayout:e.linearLayout,contigThickness:e.contigThickness,connectorThickness:e.connectorThickness,region:e.graphRegion,colorDomain:e.statedColorDomain,genes:e.showGenes?[...e.backboneGenes??[],...e.ownGeneFeatures??[]]:void 0,walkRows:e.walkRowBars,walkRowPitch:e.walkRowPitch,rowGenes:e.walkRowGenes,rowGeneGaps:e.walkRowGeneGaps,rowAnnotation:e.walkRowAnnotation,walkStrip:e.walkStripRows&&{rows:e.walkStripRows,rowGenes:e.walkRowGenes,rowGeneGaps:e.walkRowGeneGaps}}):void 0}})).views(e=>({get followsHostView(){let t=e.layoutResult;return!!e.host&&!e.hostPlacesX&&!!t&&!t.referenceAxis&&!t.pixelRows&&!t.tubeMap&&!e.facetGrid}}));var Yn=j(U("path",{d:"M3 16h5v-2H3zm6.5 0h5v-2h-5zm6.5 0h5v-2h-5zM3 20h2v-2H3zm4 0h2v-2H7zm4 0h2v-2h-2zm4 0h2v-2h-2zm4 0h2v-2h-2zM3 12h8v-2H3zm10 0h8v-2h-8zM3 4v4h18V4z"}),"LineStyle");var ws=j(U("path",{d:"M9.01 14H2v2h7.01v3L13 15l-3.99-4zm5.98-1v-3H22V8h-7.01V5L11 9z"}),"CompareArrows");var bs=j(U("path",{d:"M17 5h-2V3h2zm-2 16h2v-2.59L19.59 21 21 19.59 18.41 17H21v-2h-6zm4-12h2V7h-2zm0 4h2v-2h-2zm-8 8h2v-2h-2zM7 5h2V3H7zM3 17h2v-2H3zm2 4v-2H3c0 1.1.9 2 2 2M19 3v2h2c0-1.1-.9-2-2-2m-8 2h2V3h-2zM3 9h2V7H3zm4 12h2v-2H7zm-4-8h2v-2H3zm0-8h2V3c-1.1 0-2 .9-2 2"}),"HighlightAlt");var gp="Linear genome view",wp="Linear synteny view",bp="No synteny track in this session aligns these assemblies";function ys({label:e,icon:t,entries:o,entryLabel:n,onSelect:r,disabledHelpText:i,nameTheOnlyEntry:a=!0}){let[s]=o,d=i?[{label:e,icon:t,disabled:!0,disabledHelpText:i,onClick:()=>{}}]:[];return o.length===0?d:o.length===1&&s?[{label:a?`${e} \u2014 ${n(s)}`:e,icon:t,onClick:r(s)}]:[{label:e,icon:t,type:"subMenu",subMenu:o.map(p=>({label:n(p),onClick:r(p)}))}]}function oA({contributors:e,linearContributors:t=e,syntenyTracks:o,onShowLinear:n,onShowSynteny:r}){let i=o[0]?.coverage??e.length;return[...ys({label:gp,icon:Yn,entries:t,entryLabel:a=>`${a.sample} ${Pe(a)}`,onSelect:a=>()=>{n({location:a,assembly:a.sample})}}),...e.length>=2?ys({label:`${wp} (${i} assemblies)`,icon:ws,entries:o,entryLabel:a=>a.coverage<i?`${a.name} (${a.coverage} of ${i})`:a.name,nameTheOnlyEntry:!1,disabledHelpText:bp,onSelect:a=>()=>{r(a.trackId)}}):[]]}function nA({own:e,reference:t,highlight:o,onShowLinear:n,onHighlight:r}){let i=[e?{label:`Open in ${e.assembly} \u2014 ${Pe(e.location)}`,target:e}:void 0,t&&t.assembly!==e?.assembly?{label:`Open in ${t.assembly} \u2014 around this node`,target:t}:void 0].filter(a=>a!==void 0);return[...r&&o?[{label:`Highlight in ${o.assembly}`,icon:bs,onClick:()=>{r(o)}}]:[],...i.map(({label:a,target:s})=>({label:a,icon:Yn,onClick:()=>{n(s)}}))]}var sA=j(U("path",{d:"M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5M12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5m0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3"}),"Visibility");export{j as a,zi as b,Ut as c,Cs as d,Y as e,qt as f,pn as g,Os as h,Qi as i,Ws as j,mm as k,lm as l,um as m,hm as n,Ys as o,Ks as p,gl as q,kl as r,Rl as s,na as t,vl as u,hn as v,da as w,Hl as x,gn as y,zl as z,wn as A,Kl as B,Ul as C,ql as D,Zl as E,ya as F,sA as G,nd as H,rd as I,id as J,Rn as K,vn as L,eo as M,Mn as N,Dn as O,Mf as P,pd as Q,Nf as R,js as S,ta as T,fa as U,_f as V,cd as W,Bf as X,Cf as Y,Of as Z,Wf as _,FN as $,Ff as aa,wa as ba,VN as ca,YN as da,eE as ea,tE as fa,oE as ga,nE as ha,rE as ia,iE as ja,FE as ka,lp as la,up as ma,HE as na,Yn as oa,oA as pa,nA as qa};
3
+ //# sourceMappingURL=chunk-2VKA7YEW.js.map