jbrowse-plugin-graphgenomeviewer 6.2.0 → 6.3.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 (43) hide show
  1. package/dist/chunks/{GbzBaseSyntenyAdapter-TLI5IUU7.js → GbzBaseSyntenyAdapter-PT4IARIU.js} +2 -2
  2. package/dist/chunks/{GbzBaseSyntenyAdapter-TLI5IUU7.js.map → GbzBaseSyntenyAdapter-PT4IARIU.js.map} +1 -1
  3. package/dist/chunks/{GraphGenomeView-5OPCROMQ.js → GraphGenomeView-6CRBLHNG.js} +2 -2
  4. package/dist/chunks/{GraphTrackSettingsDialog-FGLLUIEE.js → GraphTrackSettingsDialog-2QQYWNWW.js} +2 -2
  5. package/dist/chunks/{LinearGraphDisplay-NBJHGOYX.js → LinearGraphDisplay-KNEXJAAV.js} +2 -2
  6. package/dist/chunks/{MinigraphBubbleAdapter-LQUIL3MD.js → MinigraphBubbleAdapter-MQRO5J7Z.js} +2 -2
  7. package/dist/chunks/{RgfaTabixAdapter-3BFNY4SB.js → RgfaTabixAdapter-ALEXRTPS.js} +2 -2
  8. package/dist/chunks/{bandage-layout-3AR6BCUD-I6CCWYSR.js → bandage-layout-3AR6BCUD-BW536UT3.js} +1 -1
  9. package/dist/chunks/{bandage-layout-3AR6BCUD-I6CCWYSR.js.map → bandage-layout-3AR6BCUD-BW536UT3.js.map} +1 -1
  10. package/dist/chunks/{chunk-EKMGHBWM.js → chunk-3MJ4ZXML.js} +1 -1
  11. package/dist/chunks/{chunk-EKMGHBWM.js.map → chunk-3MJ4ZXML.js.map} +1 -1
  12. package/dist/chunks/{chunk-O5EHYU3Y.js → chunk-4F2MWXJF.js} +2 -2
  13. package/dist/chunks/{chunk-NGQRKSHY.js → chunk-4LEFC42C.js} +2 -2
  14. package/dist/chunks/{chunk-NGQRKSHY.js.map → chunk-4LEFC42C.js.map} +2 -2
  15. package/dist/chunks/{chunk-F7V6ZPKD.js → chunk-5GRQIE5Q.js} +1 -1
  16. package/dist/chunks/{chunk-F7V6ZPKD.js.map → chunk-5GRQIE5Q.js.map} +1 -1
  17. package/dist/chunks/{chunk-JYZAMHIP.js → chunk-6IK6ZDSI.js} +2 -2
  18. package/dist/chunks/{chunk-JYZAMHIP.js.map → chunk-6IK6ZDSI.js.map} +1 -1
  19. package/dist/chunks/{chunk-X24J6VF4.js → chunk-C4PHHPUP.js} +1 -1
  20. package/dist/chunks/{chunk-X24J6VF4.js.map → chunk-C4PHHPUP.js.map} +1 -1
  21. package/dist/chunks/{chunk-XWGKHQYO.js → chunk-CJ47OHWP.js} +2 -2
  22. package/dist/chunks/{chunk-XWGKHQYO.js.map → chunk-CJ47OHWP.js.map} +1 -1
  23. package/dist/chunks/{chunk-7MWOPEIC.js → chunk-ETTZTJNK.js} +1 -1
  24. package/dist/chunks/{chunk-7MWOPEIC.js.map → chunk-ETTZTJNK.js.map} +1 -1
  25. package/dist/chunks/chunk-PZE3GABA.js +2 -0
  26. package/dist/chunks/chunk-PZE3GABA.js.map +7 -0
  27. package/dist/chunks/{chunk-ZKLOV6MW.js → chunk-SYHZ5T54.js} +2 -2
  28. package/dist/chunks/{chunk-ZKLOV6MW.js.map → chunk-SYHZ5T54.js.map} +1 -1
  29. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js +4 -4
  30. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js.map +3 -3
  31. package/package.json +2 -3
  32. package/src/GraphGenomeView/pane/hostViews.ts +1 -1
  33. package/src/GraphGenomeView/pane/paneBase.ts +1 -1
  34. package/src/GraphGenomeView/renderer/GraphRenderer.ts +2 -2
  35. package/src/version.ts +1 -1
  36. package/dist/chunks/chunk-LZUNK4MQ.js +0 -2
  37. package/dist/chunks/chunk-LZUNK4MQ.js.map +0 -7
  38. /package/dist/chunks/{GraphGenomeView-5OPCROMQ.js.map → GraphGenomeView-6CRBLHNG.js.map} +0 -0
  39. /package/dist/chunks/{GraphTrackSettingsDialog-FGLLUIEE.js.map → GraphTrackSettingsDialog-2QQYWNWW.js.map} +0 -0
  40. /package/dist/chunks/{LinearGraphDisplay-NBJHGOYX.js.map → LinearGraphDisplay-KNEXJAAV.js.map} +0 -0
  41. /package/dist/chunks/{MinigraphBubbleAdapter-LQUIL3MD.js.map → MinigraphBubbleAdapter-MQRO5J7Z.js.map} +0 -0
  42. /package/dist/chunks/{RgfaTabixAdapter-3BFNY4SB.js.map → RgfaTabixAdapter-ALEXRTPS.js.map} +0 -0
  43. /package/dist/chunks/{chunk-O5EHYU3Y.js.map → chunk-4F2MWXJF.js.map} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jbrowse-plugin-graphgenomeviewer",
3
- "version": "6.2.0",
3
+ "version": "6.3.0",
4
4
  "description": "JBrowse 2 graph genome (pangenome) view: rGFA reference-anchored layouts, the Bandage force-directed engine, and haplotype lanes read from a gbz-base database",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "repository": {
@@ -28,7 +28,6 @@
28
28
  "@gmod/bgzf-filehandle": "^6.7.0",
29
29
  "@gmod/gbz-base": "^7.1.0",
30
30
  "@gmod/tabix": "^3.9.1",
31
- "@gmod/tubemap-core": "^0.1.0",
32
31
  "@jbrowse/cigar-utils": "5.0.0-beta.11",
33
32
  "@jbrowse/core": "5.0.0-beta.11",
34
33
  "@jbrowse/display-kit": "5.0.0-beta.11",
@@ -40,7 +39,7 @@
40
39
  "@emotion/styled": "^11.14.1",
41
40
  "@eslint/js": "^10.0.1",
42
41
  "@fal-works/esbuild-plugin-global-externals": "^2.1.2",
43
- "@jbrowse/bandage-core": "^7.5.1",
42
+ "@jbrowse/bandage-core": "^8.0.0",
44
43
  "@jbrowse/cli": "^4.3.0",
45
44
  "@jbrowse/mobx-state-tree": "^6.7.0",
46
45
  "@jbrowse/plugin-canvas": "5.0.0-beta.11",
@@ -57,7 +57,7 @@ export const withHostViews = withWalkRowViews
57
57
  },
58
58
  get tubeMapPicture() {
59
59
  const drawing = self.layoutResult?.tubeMap
60
- return drawing ? tubeMapPicture(drawing.layout) : undefined
60
+ return drawing ? tubeMapPicture(drawing) : undefined
61
61
  },
62
62
  get tubeMapReference() {
63
63
  const drawing = self.layoutResult?.tubeMap
@@ -132,7 +132,7 @@ export function dependOn(..._values: unknown[]) {}
132
132
  // region is fetched through `getSubgraph`, and the rGFA cut is what this number
133
133
  // was chosen against (the GBZ cut is base-level and has its own `nodeLimit`,
134
134
  // which trips long before 5 Mb). Both measured rGFAs are sparse, and at 5 Mb
135
- // both land at or under the ~2k nodes that redraw in under 10 ms (see agent-docs/GRAPH_SCALE_AND_LOD.md):
135
+ // both land at or under the ~2k nodes that redraw in under 10 ms (see agent-docs/reference/GRAPH_SCALE_AND_LOD.md):
136
136
  //
137
137
  // HPRC MC GRCh38 ~7,000 bp/segment whole 4.9 Mb MHC 1,173 nodes
138
138
  // ecoli minigraph 3,078 bp/segment whole 4.6 Mb genome 2,415 nodes
@@ -3,11 +3,11 @@ import { Canvas2DRenderer } from '@jbrowse/bandage-core/renderer/Canvas2DRendere
3
3
  // Canvas2D only, and deliberately not through render-core's GPU ladder. The
4
4
  // batch is strokes and arrowheads in layout units, and stroking them batched by
5
5
  // colour is inside a frame budget at the node counts this view caps itself at
6
- // (agent-docs/GRAPH_SCALE_AND_LOD.md), so a GPU backend would buy a few
6
+ // (agent-docs/reference/GRAPH_SCALE_AND_LOD.md), so a GPU backend would buy a few
7
7
  // milliseconds for ~30 KB of bundled HAL and a shader toolchain. If one is ever
8
8
  // wanted, it should take the same `Renderer` interface and draw the batch as
9
9
  // instances — a capsule per node segment, a bezier ribbon per edge stroke —
10
- // rather than reviving a triangle mesh; agent-docs/IDEAS.md scopes it.
10
+ // rather than reviving a triangle mesh; agent-docs/ideas/waiting-on-a-number scopes it.
11
11
  export function createGraphRenderer(canvas: HTMLCanvasElement) {
12
12
  return Promise.resolve(new Canvas2DRenderer(canvas))
13
13
  }
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '6.2.0'
1
+ export const version = '6.3.0'
@@ -1,2 +0,0 @@
1
- import{A as Zt,B as Jt,C as yt,D as fe,J as fo,K as ho,L as en,M as tn,P as uo,Q as po,Y as mo,Z as bt,a as F,b as to,c as we,d as no,e as oo,f as gt,h as so,i as ro,j as et,k as xt,l as tt,m as De,n as ao,o as io,p as lo,t as co,x as Qt,y as Fe,z as ce}from"./chunk-XWGKHQYO.js";import{d as go}from"./chunk-EKMGHBWM.js";import{c as eo}from"./chunk-7MWOPEIC.js";import{a as mt,b as Be,c as $,d as Ze,e as ye,f as Vt,g as be,j as Je}from"./chunk-F7V6ZPKD.js";import{a as ut,c as Jn,d as pt}from"./chunk-X24J6VF4.js";import{a as ht}from"./chunk-TYJTJGPO.js";import{a as jt,b as ke}from"./chunk-FY3BTKY4.js";var yo=jt((uf,xo)=>{xo.exports=JBrowseExports["@mui/material/SvgIcon"]});var oi=jt((nh,ss)=>{ss.exports=JBrowseExports.mobx});var sr=jt((Yu,or)=>{or.exports=JBrowseExports["@jbrowse/core/util/groupKeys"]});var ne=ke(yo(),1);function D(e,t,n,s){return(s<<24|n<<16|t<<8|e)>>>0}function nn(e){return e&255}function on(e){return e>>>8&255}function sn(e){return e>>>16&255}function rn(e){return e>>>24&255}function oe(e){return`rgba(${nn(e)},${on(e)},${sn(e)},${rn(e)/255})`}function bo(e,t){return`rgba(${Math.round(e[0]*255)},${Math.round(e[1]*255)},${Math.round(e[2]*255)},${t})`}function qe(e,t){return D(nn(e),on(e),sn(e),Math.round(rn(e)*t))}function wt(e,t){return D(Math.min(255,Math.round(nn(e)*t)),Math.min(255,Math.round(on(e)*t)),Math.min(255,Math.round(sn(e)*t)),rn(e))}var wo=new WeakMap;function Mt(e,t,n,s,o,r,a=!1){let{scaleX:l,scaleY:i}=n,c=wo.get(e);if(c?.graph===t&&c.scaleX===l&&c.scaleY===i&&c.deletions===s&&c.routes===r&&c.stranded===a&&c.version===o)return c.curves;let d=new Map;for(let f=0;f<t.edges.length;f++){let h=t.edges[f],p=e[h.from],u=e[h.to];if(p?.length&&u?.length){let m=s?.get(f),g=m&&r?.[f];d.set(f,g?lo(p,u,g,a?xt(h):void 0):io(p,u,ao(h,a),0,0,n,m?co(e,m):[]))}}return wo.set(e,{graph:t,scaleX:l,scaleY:i,deletions:s,routes:r,stranded:a,version:o,curves:d}),d}var Zr=4;function nt(e){let t=new Map;function n(s,o){let r=t.get(s);r?r.push(o):t.set(s,[o])}for(let s of e.edges)n(s.from,s.to),n(s.to,s.from);return t}function Jr({nodeId:e,nodeById:t,neighbors:n}){let s=new Set([e]),o=[e],r=1/0,a=-1/0;for(let l=0;l<Zr&&o.length>0;l++){let i=[];for(let c of o){let d=n.get(c);if(d){for(let f of d)if(!s.has(f)){s.add(f);let h=t.get(f);h&&$(h)?(r=Math.min(r,h.stable.start+h.length),a=Math.max(a,h.stable.start)):i.push(f)}}}o=i}return r===1/0?void 0:{start:Math.min(r,a),end:Math.max(r,a)}}function ea({nodeId:e,nodeById:t,neighbors:n}){let s=t.get(e);return s===void 0?void 0:$(s)?{start:s.stable.start,end:s.stable.start+s.length}:Jr({nodeId:e,nodeById:t,neighbors:n})}function Mo(e){let t=new Map(e.nodes.map(o=>[o.id,o])),n=nt(e),s=new Map;for(let o of e.nodes){let r=ea({nodeId:o.id,nodeById:t,neighbors:n});r&&s.set(o.id,(r.start+r.end)/2)}return s}var ta=D(119,119,119,217),vo=D(136,136,136,217),na=D(24,24,28,240),oa=2.2,dn=D(160,160,160,255),Xe=.18,Et=oe(qe(dn,Xe)),sa=11,ra=1.2,Eo=4,an=1e-6,aa=7,ia=3,la=3,ca=1.5,Ro=3,fa=.5,da=.45,ln=12,ha=1e-6,de=new Float64Array(64),Me=new Float64Array(64),ve=new Float64Array(64);function ua(e,t,n,s){let o=e.length*ln+1;de.length<o&&(de=new Float64Array(o),Me=new Float64Array(o),ve=new Float64Array(o));let r=e[e.length-1];de[0]=r.x1,Me[0]=r.y1,ve[0]=0;let a=1,l=0;for(let i=e.length-1;i>=0&&l<s;i--){let c=e[i];for(let d=1;d<=ln&&l<s;d++){let f=1-(d/ln)**2,h=1-f,p=h*h*h,u=3*h*h*f,m=3*h*f*f,g=f*f*f,x=p*c.x0+u*c.cx0+m*c.cx1+g*c.x1,w=p*c.y0+u*c.cy0+m*c.cy1+g*c.y1;l+=Math.hypot(x-de[a-1],(w-Me[a-1])*n)*t,de[a]=x,Me[a]=w,ve[a]=l,a++}}return a}function So(e,t){let n=1;for(;n<e-1&&ve[n]<t;)n++;let s=ve[n-1],o=ve[n],r=o>s?Math.min(1,Math.max(0,(t-s)/(o-s))):0;return{x:de[n-1]+(de[n]-de[n-1])*r,y:Me[n-1]+(Me[n]-Me[n-1])*r}}function pa({curves:e,edgeHalfWidth:t,nodeHalfWidth:n,scale:s,yToX:o,color:r,fromSegments:a,toSegments:l}){let i=aa+ia*t,c=ua(e,s,o,n+Ro*i),d=ve[c-1],f=d<ha,h=Math.min(n,d),p=f?Math.min(1,ma(a,s,o)/i):1;if(f?p<fa:d<Ro*i)return;let u=So(c,h),m=So(c,h+i*p),g=u.x-m.x,x=(u.y-m.y)*o,w=e[e.length-1];return{x:u.x,y:u.y,angle:Math.hypot(g,x)>0?Math.atan2(x,g):Co(w,o,xa(w,l)),length:i*p,halfWidth:(la+ca*t)*p,color:r}}function ma(e,t,n){let s=0;for(let o=1;o<e.length;o++)s+=Math.hypot(e[o].x-e[o-1].x,(e[o].y-e[o-1].y)*n);return s*t}function ga(e,t,n,s,o){if(s)return xt(e).from==="start";let r=a=>Math.hypot(a.x-n.x0,(a.y-n.y0)*o);return r(t[0])<r(t.at(-1))}function xa(e,t){if(t.length<2)return;let n=t[0],s=t[t.length-1];return Math.hypot(e.x1-n.x,e.y1-n.y)<=Math.hypot(e.x1-s.x,e.y1-s.y)?{from:n,to:t[1]}:{from:s,to:t[t.length-2]}}function cn(e,t=1){let n=t===1?e:e.map(o=>({x:o.x,y:o.y*t})),s=[];for(let o=0;o<n.length;o++){let r=0,a=0;if(o===0){let l=n[1].x-n[0].x,i=n[1].y-n[0].y,c=Math.hypot(l,i);c>0&&(r=-i/c,a=l/c)}else if(o===n.length-1){let l=n[o].x-n[o-1].x,i=n[o].y-n[o-1].y,c=Math.hypot(l,i);c>0&&(r=-i/c,a=l/c)}else{let l=n[o].x-n[o-1].x,i=n[o].y-n[o-1].y,c=Math.hypot(l,i),d=n[o+1].x-n[o].x,f=n[o+1].y-n[o].y,h=Math.hypot(d,f);if(c>0&&h>0){let p=-i/c,u=l/c,m=-f/h,g=d/h;r=(p+m)/2,a=(u+g)/2;let x=p*r+u*a;x>.1&&(r/=x,a/=x)}else c>0?(r=-i/c,a=l/c):h>0&&(r=-f/h,a=d/h)}s.push({nx:r,ny:a})}return s}function No(e,t,n,s=1){return e.map((o,r)=>({x:o.x+t[r].nx*n,y:o.y+t[r].ny*n/s}))}function vt(e,t,n,s){return D(Math.round(e*255),Math.round(t*255),Math.round(n*255),Math.round(s*255))}function Ee(e,t,n){let s=(1-Math.abs(2*n-1))*t,o=s*(1-Math.abs(e/60%2-1)),r=n-s/2,a=0,l=0,i=0;return e<60?(a=s,l=o):e<120?(a=o,l=s):e<180?(l=s,i=o):e<240?(l=o,i=s):e<300?(a=o,i=s):(a=s,i=o),[a+r,l+r,i+r]}var ya=[[68,1,84],[59,82,139],[33,145,140],[94,201,98],[253,231,37]],ba=[[237,137,44],[158,42,122]],wa=[[220,50,50],[50,120,220]];function fn(e,t){let n=Math.max(0,Math.min(1,t))*(e.length-1),s=Math.min(e.length-2,Math.floor(n)),o=n-s,r=e[s],a=e[s+1];return D(Math.round(r[0]+(a[0]-r[0])*o),Math.round(r[1]+(a[1]-r[1])*o),Math.round(r[2]+(a[2]-r[2])*o),255)}function Ma(e,t){let[n,s,o]=Ee(fo(e),en,tn);return vt(n,s,o,t)}var Re=300,va=.7,Ea=.5,Io=[60,65,72],Rt=D(...Io,255),St=`rgb(${Io.join(", ")})`;function Ra(e,t){let n=Mo(e);if(t&&t.end>t.start)return{start:t.start,span:t.end-t.start,midpoints:n};let s=1/0,o=-1/0;for(let r of n.values())s=Math.min(s,r),o=Math.max(o,r);return{start:s===1/0?0:s,span:o>s?o-s:1,midpoints:n}}function Nt(e){let t=1/0,n=-1/0,s=1/0,o=-1/0,r=0;for(let a of e.nodes)a.stable!==void 0&&a.stable.rank>r&&(r=a.stable.rank),a.depth<t&&(t=a.depth),a.depth>n&&(n=a.depth),a.length<s&&(s=a.length),a.length>o&&(o=a.length);return{minDepth:t,maxDepth:n,minLength:s,maxLength:o,maxRank:r,nodeCount:e.nodes.length}}function _t(e,t,n,s){switch(n){case"random":return Ma(e.id,1);case"depth":return fn(ya,s.maxDepth>s.minDepth?(e.depth-s.minDepth)/(s.maxDepth-s.minDepth):.5);case"node-length":return fn(wa,s.maxLength>s.minLength?(e.length-s.minLength)/(s.maxLength-s.minLength):.5);case"stable-rank":return e.stable===void 0?D(160,160,160,255):e.stable.rank===0?D(52,152,219,255):fn(ba,s.maxRank>1?(e.stable.rank-1)/(s.maxRank-1):0);case"reference-position":{let o=s.referenceRamp,r=o?.midpoints.get(e.id);if(o===void 0||r===void 0)return D(160,160,160,255);if(e.stable!==void 0&&e.stable.rank>0)return Rt;let a=Math.max(0,Math.min(1,(r-o.start)/o.span)),[l,i,c]=Ee(a*Re,va,Ea);return vt(l,i,c,1)}case"grey":return D(160,160,160,255);case"rainbow":{let o=s.nodeCount>1?t/s.nodeCount*360:0,[r,a,l]=Ee(o,.75,.5);return vt(r,a,l,1)}default:return D(52,152,219,255)}}function Co(e,t=1,n){let s=[[e.cx1,e.cy1],[e.cx0,e.cy0],[e.x0,e.y0]];for(let[o,r]of s){let a=e.x1-o,l=(e.y1-r)*t;if(Math.hypot(a,l)>0)return Math.atan2(l,a)}return n?Math.atan2((n.to.y-n.from.y)*t,n.to.x-n.from.x):0}function Sa(e,t){let n=!1;for(let s=0;s<e.length-1&&!n;s++){let o=e[s],r=e[s+1];n=Math.max(o.x,r.x)>=t.minX&&Math.min(o.x,r.x)<=t.maxX&&Math.max(o.y,r.y)>=t.minY&&Math.min(o.y,r.y)<=t.maxY}return n}function _o(e,t){for(let n of e){let s=Math.min(n.x0,n.cx0,n.cx1,n.x1),o=Math.max(n.x0,n.cx0,n.cx1,n.x1),r=Math.min(n.y0,n.cy0,n.cy1,n.y1),a=Math.max(n.y0,n.cy0,n.cy1,n.y1);if(o>=t.minX&&s<=t.maxX&&a>=t.minY&&r<=t.maxY)return!0}return!1}var Ao=new WeakMap;function Na(e){let t=Ao.get(e);if(!t){let n=[],s=new Map,o=e.paths??[];for(let r=0;r<o.length;r++){let[a,l,i]=Ee(ho(r,o.length),en,tn);n.push(vt(a,l,i,.85)),s.has(o[r].name)||s.set(o[r].name,r)}t={pathColorByIndex:n,pathIndexByName:s},Ao.set(e,t)}return t}var Lo=new WeakMap,_a=new Map;function Aa(e){let t=Lo.get(e);if(!t){t=new Map;for(let[n,s]of(e.paths??[]).entries())for(let o of new Set(s.nodeIds)){let r=t.get(o);r?r.push(n):t.set(o,[n])}Lo.set(e,t)}return t}function La(e){let{nodePositions:t,graph:n,nodeById:s,colorScheme:o,contigThickness:r,connectorThickness:a,drawPaths:l,nodeWidth:i="uniform",highlight:c,axis:d,linearLayout:f,viewportBounds:h,referenceRamp:p,deletions:u,deletionRoutes:m,stranded:g,hiddenEdges:x,version:w=0}=e,N=i==="depth"?mo(n):0,v=d.scaleX,R=tt(d),M=Mt(t,n,d,u,w,m,g),S=[],A=new Map,P=[],H=new Map,B=[],ae=new Map,_e={...Nt(n),referenceRamp:p},K=new Map;if(o==="rainbow")for(let T=0;T<n.nodes.length;T++)K.set(n.nodes[T].id,T);let G=n.paths?.length??0,{pathColorByIndex:j,pathIndexByName:z}=Na(n),U=T=>j[z.get(T)??-1]??vo,Ae=l&&G>1?Aa(n):_a,Ue=v>(f?1:da);for(let T=0;T<n.edges.length;T++){let k=n.edges[T],Q=t[k.from],ie=t[k.to],Z=M.get(T);if(!Q?.length||!ie?.length||!Z||x?.has(T))continue;let Le=k.pathIds?.length??0,Ke=u?.get(T)!==void 0,je=c?.edgeIndexes.has(T)??!1,Ie=a/2*(Ke?oa:1),Ce=l&&Le>0,me=Ke?na:ta,J=!c||je?me:qe(me,Xe),Ve=s.get(k.to),Te=(Ve?bt(Ve,r,i,N):r)/2,Oe=(xe,$e,Y,le)=>{let te=xe===0&&$e===0?Z:et(Z,xe,$e);if(h&&!_o(te,h))return;if(Ke)for(let zt of ro(te,sa/v))B.push({curves:zt,thickness:Ie,color:Y});else B.push({curves:te,thickness:Ie,color:Y});let dt=Ue&&le!==void 0?pa({curves:te,edgeHalfWidth:a/2,nodeHalfWidth:Te,scale:v,yToX:R,color:le,fromSegments:Q,toSegments:ie}):void 0;dt&&P.push(dt)},ge=B.length,Pe=P.length,ee=c&&je&&!Ce?c.walks:void 0;if(ee){let xe=s.get(k.from),$e=xe?bt(xe,r,i,N):r,Y=Math.max($e/ee.length,Eo),le=cn(Q,R),{nx:te,ny:dt}=(ga(k,Q,Z[0],g,R)?le[0]:le.at(-1))??{nx:0,ny:0},zt=1/Math.max(v,an);ee.forEach((Ut,Qr)=>{if(!Ut.edgeIndexes.has(T))return;let Kt=(Qr-(ee.length-1)/2)*Y*zt,Zn=Kt===0?Z:et(Z,te*Kt,dt*Kt/R);h&&!_o(Zn,h)||B.push({curves:Zn,thickness:Y/2,color:Ut.colors.get(k.from)??Ut.colors.get(k.to)??me})})}else if(!Ce)Oe(0,0,J,J);else{let xe=De(Q,ie,Le,d),$e=Math.floor((Le-1)/2);for(let Y=0;Y<Le;Y++){let le=xe[Y],te=U(k.pathIds[Y]);Oe(le.x,le.y,c&&!c.names.has(k.pathIds[Y])?qe(te,Xe):te,Y===$e?J:void 0)}}let Qe=B.length-ge;Qe>0&&ae.set(T,{start:ge,count:Qe});let ft=P.length-Pe;ft>0&&H.set(T,{start:Pe,count:ft})}for(let[T,k]of Object.entries(t)){let Q=s.get(T);if(!Q||h&&!Sa(k,h))continue;let ie=c!==void 0&&!c.nodeIds.has(T),Z=ie?dn:_t(Q,K.get(T)??0,o,_e),Le=ie?qe(Z,Xe):Z,ct=bt(Q,r,i,N),Ke=ct/2,je=S.length,Ie=Ae.get(T),Ce=ct/G,me=k.length>=2,J=c&&!ie&&!Ie?.length?c.walks:void 0;if(me&&J){let Te=Math.max(ct/J.length,Eo),Oe=cn(k,R),ge=1/Math.max(v,an);J.forEach((Pe,ee)=>{let Qe=Pe.colors.get(T);if(Qe===void 0)return;let ft=(ee-(J.length-1)/2)*Te*ge;S.push({points:J.length===1?k:No(k,Oe,ft,R),thickness:Te/2,color:Qe})})}else if(me&&Ie?.length&&Ce>=ra){let Te=cn(k,R),Oe=1/Math.max(v,an);for(let ge of Ie){let Pe=(ge-(G-1)/2)*Ce*Oe,ee=j[ge]??vo;S.push({points:No(k,Te,Pe,R),thickness:Ce/2,color:ie?qe(ee,Xe):ee})}}else me&&S.push({points:k,thickness:Ke,color:Le});let Ve=S.length-je;Ve>0&&A.set(T,{start:je,count:Ve})}return{nodeStrokes:S,nodeStrokeRuns:A,arrows:P,arrowRuns:H,edgeCurves:B,edgeCurveRuns:ae}}function At(e){return`hsl(${e}, 70%, 50%)`}function hn(e,t){let n=(e-t.start)/(t.end-t.start);return Math.max(0,Math.min(1,n))*Re}var Ia=30;function To({start:e,bp:t,reversed:n},s){let o=hn(e,s),r=hn(e+t,s);if(r-o<1)return[(o+r)/2];let a=Math.ceil((r-o)/Ia);return Array.from({length:a+1},(l,i)=>hn(e+t*(n?a-i:i)/a,s))}var un=Array.from({length:7},(e,t)=>({offset:t/6,color:At(t/6*Re)})),Oo=`linear-gradient(to right, ${un.map(e=>`${e.color} ${e.offset*100}%`).join(", ")})`;function L(e,t={},...n){return{tag:e,attrs:t,children:n.filter(s=>!!s||s==="")}}function Po(e){return e.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;")}function Ca(e){return Po(e).replaceAll('"',"&quot;")}function Ta(e){if(typeof e=="string")return Po(e);let t=Object.entries(e.attrs).filter(([,n])=>n!==void 0).map(([n,s])=>` ${n}="${Ca(String(s))}"`).join("");return`<${e.tag}${t}>${e.children.map(Ta).join("")}</${e.tag}>`}var Oa="#daa520",Pa=1,$a=2,ka=4;function Tf(e,t,n,s=o=>o){let o=r=>{let a=t(r)*2;return n?.nodeIds.has(r)?Math.max(a,n.walks.length*ka):a};return e.flatMap(r=>r.exonsByNode.map(({nodeId:a,d:l})=>({key:`${r.gene.name}-${r.gene.start}-${a}`,d:s(l),inner:o(a)+2*Pa})))}function Of(e,t){if(e.length===0)return;let n=(s,o,r)=>L("path",{d:s.d,fill:"none",stroke:o,"stroke-width":r,"stroke-linecap":"round","stroke-linejoin":"round","vector-effect":t.transform?"non-scaling-stroke":void 0});return L("g",{},L("mask",{id:t.id,maskUnits:"userSpaceOnUse",x:0,y:0,width:t.width,height:t.height},L("g",{transform:t.transform},...e.map(s=>n(s,"#fff",s.inner+2*$a)),...e.map(s=>n(s,"#000",s.inner)))),L("rect",{width:t.width,height:t.height,fill:Oa,mask:`url(#${t.id})`}))}var Ba=50;function $o(e,t){return t>0?Math.max(1,e/t):Ba}function Da(e){let t=new Set,n=1/0,s=-1/0;for(let o of e)t.add(o.minY),n=Math.min(n,o.minY),s=Math.max(s,o.minY);return t.size>1?(s-n)/(t.size-1):void 0}function Fa(e,t,n){let s=$o(t,e.length);return{x:s,y:n>0?$o(n,e.length):Da(e)??s}}function ko(e,t,n,s){return e===void 0?Fa(t,n,s):typeof e=="number"?{x:e,y:e}:e}function qa(e,t,n){let s=e.get(t);s||(s=new Map,e.set(t,s));let o=s.get(n);return o||(o=[],s.set(n,o)),o}function Bo(e,t,n,s,o,r,a){let l=Math.floor(n/t.x),i=Math.floor(o/t.x),c=Math.floor(s/t.y),d=Math.floor(r/t.y);for(let f=l;f<=i;f++)for(let h=c;h<=d;h++)qa(e,f,h).push(a)}function Do(e,t,n,s,o,r){let a=Math.floor((n-o)/t.x),l=Math.floor((n+o)/t.x),i=Math.floor((s-r)/t.y),c=Math.floor((s+r)/t.y),d=[],f=new Set;for(let h=a;h<=l;h++){let p=e.get(h);if(p)for(let u=i;u<=c;u++){let m=p.get(u);if(m)for(let g of m)f.has(g)||(f.add(g),d.push(g))}}return d}var Fo=class{constructor(e,t){this.cells=new Map;let n=[],s=0,o=0;for(let[r,a]of Object.entries(e))for(let l=0;l<a.length-1;l++){let i=a[l],c=a[l+1],d=Math.min(i.x,c.x),f=Math.min(i.y,c.y),h=Math.max(i.x,c.x),p=Math.max(i.y,c.y);s+=h-d,o+=p-f,n.push({entry:{nodeId:r,segmentIdx:l},minX:d,minY:f,maxX:h,maxY:p})}this.cellSize=ko(t,n,s,o);for(let r of n)Bo(this.cells,this.cellSize,r.minX,r.minY,r.maxX,r.maxY,r.entry)}query(e,t,n,s=n){return Do(this.cells,this.cellSize,e,t,n,s)}},qo=class{constructor(e,t,n,s,o,r,a=0,l,i=!1){this.cells=new Map,this.edgeCurves=Mt(e,t,s,r,a,l,i);let c=[],d=0,f=0;for(let h=0;h<t.edges.length;h++){let p=t.edges[h],u=e[p.from],m=e[p.to],g=this.edgeCurves.get(h);if(u?.length&&m?.length&&g){let{minX:x,minY:w,maxX:N,maxY:v}=so(g),R=p.pathIds?.length??0;if(n&&R>0){let M=0,S=0;for(let A of De(u,m,R,s))M=Math.max(M,Math.abs(A.x)),S=Math.max(S,Math.abs(A.y));x-=M,w-=S,N+=M,v+=S}d+=N-x,f+=v-w,c.push({ei:h,minX:x,minY:w,maxX:N,maxY:v})}}this.cellSize=ko(o,c,d,f);for(let h of c)Bo(this.cells,this.cellSize,h.minX,h.minY,h.maxX,h.maxY,h.ei)}getCurves(e){return this.edgeCurves.get(e)}query(e,t,n,s=n){return Do(this.cells,this.cellSize,e,t,n,s)}};function Go(e,t,n,s,o,r){let a=o-n,l=r-s,i=a*a+l*l;if(i===0)return Math.hypot(e-n,t-s);let c=Math.max(0,Math.min(1,((e-n)*a+(t-s)*l)/i));return Math.hypot(e-(n+c*a),t-(s+c*l))}function Xa(e,t,n,s,o,r,a,l,i,c){let d=1/0,f=20,h=n,p=s;for(let u=1;u<=f;u++){let m=u/f,g=1-m,x=g*g*g*n+3*g*g*m*o+3*g*m*m*a+m*m*m*i,w=g*g*g*s+3*g*g*m*r+3*g*m*m*l+m*m*m*c;d=Math.min(d,Go(e,t,h,p,x,w)),h=x,p=w}return d}function Wa(e,t,n){return Xa(e,t,n.x0,n.y0,n.cx0,n.cy0,n.cx1,n.cy1,n.x1,n.y1)}function Xo(e,t,n,s=1){let o=1/0;for(let r of n){let a=Wa(e,t,s===1?r:{x0:r.x0,y0:r.y0*s,cx0:r.cx0,cy0:r.cy0*s,cx1:r.cx1,cy1:r.cy1*s,x1:r.x1,y1:r.y1*s});a<o&&(o=a)}return o}var Wo=new WeakMap;function Yo(e,t){let n=Wo.get(e);if(n?.version===t)return n.index;let s=new Fo(e);return Wo.set(e,{version:t,index:s}),s}var Ho=new WeakMap;function Ha(e,t,n,s,o,r,a,l=!1){let i=Ho.get(e);if(i?.graph===t&&i.drawPaths===n&&i.scaleX===s.scaleX&&i.scaleY===s.scaleY&&i.version===o&&i.deletions===r&&i.routes===a&&i.stranded===l)return i.index;let c=new qo(e,t,n,s,void 0,r,o,a,l);return Ho.set(e,{graph:t,drawPaths:n,scaleX:s.scaleX,scaleY:s.scaleY,version:o,index:c,deletions:r,routes:a,stranded:l}),c}var Ga=5;function Wf(e,t,n,s,o=0,r){let a=tt(s),l=Yo(e,o),i=p=>Math.max(Ga,p)/s.scaleX,c=i(r?.maxHalfWidthPx??0),d=l.query(t,n,c,c/a),f=null,h=1/0;for(let{nodeId:p,segmentIdx:u}of d){let m=e[p],g=Go(t,n*a,m[u].x,m[u].y*a,m[u+1].x,m[u+1].y*a);g<h&&g<i(r?.halfWidthPx(p)??0)&&(h=g,f=p)}return f}function Ya(e,t,n){let s=t.x-e.x,o=t.y-e.y,r=0,a=1;for(let[l,i]of[[-s,e.x-n.x0],[s,n.x1-e.x],[-o,e.y-n.y0],[o,n.y1-e.y]])if(l===0){if(i<0)return!1}else l<0?r=Math.max(r,i/l):a=Math.min(a,i/l);return r<=a}function zo(e,t,n=0){let s=Yo(e,n),o=r=>({x:r.x*t.scaleX+t.translateX,y:r.y*t.scaleY+t.translateY});return r=>{let a=new Set,l=s.query(((r.x0+r.x1)/2-t.translateX)/t.scaleX,((r.y0+r.y1)/2-t.translateY)/t.scaleY,Math.abs((r.x1-r.x0)/2/t.scaleX),Math.abs((r.y1-r.y0)/2/t.scaleY));for(let{nodeId:i,segmentIdx:c}of l){let d=e[i];!a.has(i)&&Ya(o(d[c]),o(d[c+1]),r)&&a.add(i)}return a}}function Hf(e,t,n,s,o,r,a=0,l,i,c,d=!1){let f=tt(o),h=10/o.scaleX,p=Ha(e,t,r,o,a,l,c,d),u=p.query(n,s,h,h/f),m=null,g=h;for(let x of u){let w=t.edges[x],N=e[w.from],v=e[w.to];if(!N?.length||!v?.length||i?.has(x))continue;let R=w.pathIds?.length??0,M=p.getCurves(x);if(!M)continue;let S;if(!r||R===0)S=Xo(n,s*f,M,f);else{let A=1/0;for(let P of De(N,v,R,o)){let H=P.x===0&&P.y===0?M:et(M,P.x,P.y),B=Xo(n,s*f,H,f);B<A&&(A=B)}S=A}S<g&&(g=S,m=x)}return m}var Uo=3.4,pn=6,za=8,Ua=18,Ka=2,ja=to+no;function Ko(e){let t=e.gene.end-e.gene.start;if(e.covered>=.98)return;let[n,s]=t>=1e6?[1e6,"Mb"]:t>=1e3?[1e3,"kb"]:[1,"bp"],o=r=>+(r/n).toFixed(n===1?0:1);return`${o(e.covered*t)} of ${o(t)} ${s}`}function jo(e,t,n,s){let o=n/2;return Vo(e,r=>r.gene.end-r.gene.start).map(r=>{let{x:a,y:l}=t(r.at),i=Ko(r);return{item:r,x:a,y:l+n+Ua,text:i?`${r.gene.name} \xB7 ${i}`:r.gene.name,fallback:i?`${r.gene.name} \u2026`:void 0,stack:Ka,fits:c=>[...s({x0:c.x0-o,x1:c.x1+o,y0:c.y0-o,y1:c.y1+o})].every(d=>r.nodeIds.has(d))}})}function Vo(e,t){return[...e].sort((n,s)=>t(s)-t(n))}function Va(e){let{paneWidth:t,canvasHeight:n,translateX:s,translateY:o}=e,{scaleX:r,scaleY:a}=e.axisScale,l={width:t,height:n},i=M=>({x:M.x*r+s,y:M.y*a+o}),c=e.drawnRowLabels.map(({label:M,y:S})=>Qt(M,S*a+o)),d=e.referenceStripZonePx??0;d>0&&c.push({x0:0,x1:t,y0:0,y1:d}),e.legendSize.width>0&&c.push({x0:t-pn-e.legendSize.width,x1:t,y0:0,y1:d+pn+e.legendSize.height}),e.poppedFrom&&c.push({x0:0,x1:60+e.poppedFrom.label.length*we*1.2,y0:0,y1:44});let f=oo(l,c),h=e.drawnRowLabels.length>0,p=h?Math.min(...e.drawnRowLabels.map(M=>M.y)):1/0,u=e.contigThickness*Uo,m=Vo(e.bubbleHalos,M=>M.members),g=gt(m.map(M=>{let{x:S,y:A}=i({x:M.labelAt.x,y:Math.min(M.labelAt.y,p)}),P=A-u/2-6;return{item:M,x:S,y:h?Math.max(P,ja):P,text:M.label}}),l,f),x=gt(jo(e.genePins,i,e.contigThickness,zo(e.nodePositions??{},{scaleX:r,scaleY:a,translateX:s,translateY:o},e.positionsVersion)),l,f),w=e.nodePositions&&e.labelsNodeSizes?Zt({nodePositions:e.nodePositions,nodeLengths:e.nodeLengths,deletions:e.deletions,deletionRoutes:e.deletionRoutes,stranded:e.stranded,alleleDeletions:e.alleleDeletions,axis:e.axisScale,translateX:s,translateY:o,width:t,height:n,version:e.positionsVersion}):{deletions:[],nodes:[]},N=yt(w.deletions,f),v=gt(m.flatMap(M=>M.routes.map(S=>{let{x:A,y:P}=i(S.at);return{item:{halo:M,route:S},x:A,y:P+4,text:S.text,stack:za}})),l,f),R=yt(w.nodes,f,Jt(t,n));return{bubbles:g,genes:x,routes:v,sizes:[...N,...R]}}function Dd(e){return Be(e)?Qo(e):void 0}function Qo(e){return{sample:ut(e.stable.refName),haplotype:Jn(e.stable.refName),refName:pt(e.stable.refName),start:e.stable.start,end:e.stable.start+e.length}}function Qa(e,t){let n=[...e].sort((r,a)=>r.start-a.start),s,o;for(let r of n)o=o&&r.start-o.end<=t?{start:o.start,end:Math.max(o.end,r.end)}:{start:r.start,end:r.end},(!s||o.end-o.start>s.end-s.start)&&(s=o);return s}function Za(e){return`${e.haplotype??e.sample}\0${e.refName}`}function Fd(e,{maxGap:t=1/0}={}){let n=new Map;for(let o of e.nodes)if(Be(o)){let r=Qo(o),a=Za(r),l=n.get(a);l?(l.spans.push({start:r.start,end:r.end}),l.rank=Math.min(l.rank,o.stable.rank)):n.set(a,{sample:r.sample,haplotype:r.haplotype,refName:r.refName,rank:o.stable.rank,spans:[{start:r.start,end:r.end}]})}let s=new Map;for(let o of n.values()){let r=Qa(o.spans,t);if(r){let a={sample:o.sample,haplotype:o.haplotype,refName:o.refName,start:r.start,end:r.end,rank:o.rank,nodeCount:o.spans.length},l=o.haplotype??o.sample,i=s.get(l);(!i||a.nodeCount>i.nodeCount)&&s.set(l,a)}}return[...s.values()].sort((o,r)=>+(o.rank!==0)-+(r.rank!==0)||o.sample.localeCompare(r.sample)||(o.haplotype??"").localeCompare(r.haplotype??""))}function Ja(e,t){return(t.haplotype===void 0?void 0:e(t.haplotype))??e(t.sample)}function qd(e,t){return e.flatMap(n=>{let s=Ja(t,n);return s===void 0?[]:[{...n,sample:s}]})}function Xd(e){return`${e.refName}:${e.start+1}-${e.end}`}function mn(e){return`${e.refName}:${(e.start+1).toLocaleString()}-${e.end.toLocaleString()}`}var Zo=ke(ht(),1),Jo=(0,ne.createSvgIcon)((0,Zo.jsx)("path",{d:"M9.01 14H2v2h7.01v3L13 15l-3.99-4zm5.98-1v-3H22V8h-7.01V5L11 9z"}),"CompareArrows");var es=ke(ht(),1),ts=(0,ne.createSvgIcon)((0,es.jsx)("path",{d:"M17 5h-2V3h2zm-2 16h2v-2.59L19.59 21 21 19.59 18.41 17H21v-2h-6zm4-12h2V7h-2zm0 4h2v-2h-2zm-8 8h2v-2h-2zM7 5h2V3H7zM3 17h2v-2H3zm2 4v-2H3c0 1.1.9 2 2 2M19 3v2h2c0-1.1-.9-2-2-2m-8 2h2V3h-2zM3 9h2V7H3zm4 12h2v-2H7zm-4-8h2v-2H3zm0-8h2V3c-1.1 0-2 .9-2 2"}),"HighlightAlt");var ns=ke(ht(),1),gn=(0,ne.createSvgIcon)((0,ns.jsx)("path",{d:"M3 16h5v-2H3zm6.5 0h5v-2h-5zm6.5 0h5v-2h-5zM3 20h2v-2H3zm4 0h2v-2H7zm4 0h2v-2h-2zm4 0h2v-2h-2zm4 0h2v-2h-2zM3 12h8v-2H3zm10 0h8v-2h-8zM3 4v4h18V4z"}),"LineStyle");var ei="Linear genome view",ti="Linear synteny view",ni="No synteny track in this session aligns these assemblies";function os({label:e,icon:t,entries:n,entryLabel:s,onSelect:o,disabledHelpText:r,nameTheOnlyEntry:a=!0}){let[l]=n,i=r?[{label:e,icon:t,disabled:!0,disabledHelpText:r,onClick:()=>{}}]:[];return n.length===0?i:n.length===1&&l?[{label:a?`${e} \u2014 ${s(l)}`:e,icon:t,onClick:o(l)}]:[{label:e,icon:t,type:"subMenu",subMenu:n.map(c=>({label:s(c),onClick:o(c)}))}]}function Jd({contributors:e,syntenyTracks:t,onShowLinear:n,onShowSynteny:s}){let o=t[0]?.coverage??e.length;return[...os({label:ei,icon:gn,entries:e,entryLabel:r=>`${r.sample} ${mn(r)}`,onSelect:r=>()=>{n({location:r,assembly:r.sample})}}),...e.length>=2?os({label:`${ti} (${o} assemblies)`,icon:Jo,entries:t,entryLabel:r=>r.coverage<o?`${r.name} (${r.coverage} of ${o})`:r.name,nameTheOnlyEntry:!1,disabledHelpText:ni,onSelect:r=>()=>{s(r.trackId)}}):[]]}function eh({own:e,reference:t,highlight:n,onShowLinear:s,onHighlight:o}){let r=[e?{label:`Open in ${e.assembly} \u2014 ${mn(e.location)}`,target:e}:void 0,t&&t.assembly!==e?.assembly?{label:`Open in ${t.assembly} \u2014 around this node`,target:t}:void 0].filter(a=>a!==void 0);return[...o&&n?[{label:`Highlight in ${n.assembly}`,icon:ts,onClick:()=>{o(n)}}]:[],...r.map(({label:a,target:l})=>({label:a,icon:gn,onClick:()=>{s(l)}}))]}function xn(e){return e.id.endsWith("-")?"-":"+"}function yn(e,t){return t===xn(e)?e.id:`-${e.id}`}function si(e,t){let n=e.map(()=>{}),s=0,o=0;for(;o<e.length&&e[o]!==void 0;o++)n[o]=s,s+=e[o];let r=t;for(let a=e.length-1;a>o&&e[a]!==void 0;a--)r-=e[a],n[a]=r;return n}function ri(e,t){let n=e.path.map(()=>[]);if(e.cs===void 0)return n;let s=si(t,e.pathLength),o=(l,i=!1)=>{for(let c=0;c<s.length;c++){let d=s[c],f=t[c];if(d!==void 0&&f!==void 0&&d<=l&&(l<d+f||i&&l===d+f))return{s:c,local:l-d,room:d+f-l}}},r=(l,i)=>{let c=n[l],d=c.at(-1);i.type==="substitution"&&d?.type==="substitution"&&d.pos+d.seq.length===i.pos?d.seq+=i.seq:c.push(i)},a=e.pathStart;for(let l of eo(e.cs))if(l.op==="match")a+=l.length;else if(l.op==="substitution"){let i=o(a);i&&r(i.s,{type:"substitution",pos:i.local,seq:l.seq}),a+=1}else if(l.op==="insertion"){let i=o(a,a===e.pathEnd);i&&r(i.s,{type:"insertion",pos:i.local,seq:l.seq})}else{let i=l.length;for(;i>0;){let c=o(a),d=c?Math.min(i,c.room):i;c&&r(c.s,{type:"deletion",pos:c.local,length:d}),a+=d,i-=d}}return n}function rs(e,t,n){let s=new Map(e.nodes.map(r=>[r.name,r])),o=[];for(let r of t){let a=r.path.map(d=>s.get(d.name)),l=a.flatMap((d,f)=>d?[f]:[]),i=l[0],c=l.at(-1);if(i!==void 0&&c!==void 0){let d=ri(r,a.map(p=>p?.length)),f=l.map(p=>yn(a[p],r.path[p].strand)),h=a[c].length;o.push({id:n+o.length,name:r.name,type:"read",sourceTrackID:1,sequence:f,sequenceNew:l.map((p,u)=>({nodeName:f[u],mismatches:d[p]})),firstNodeOffset:i===0?r.pathStart:0,finalNodeCoverLength:c===r.path.length-1?h-(r.pathLength-r.pathEnd):h,mapping_quality:r.mappingQuality===255?0:r.mappingQuality,is_secondary:r.secondary,is_reverse:r.strand==="-"})}}return o}var ai=["#6baed6","#4292c6","#2171b5","#08519c"],ii=["#fb6a4a","#ef3b2c","#cb181d","#a50f15"];function as(e){let t=e.is_reverse?ii:ai;return t[e.id%t.length]}function Lt(e){let t=e.split("#"),n=t.length>=2?Number(t[1]):Number.NaN;return{sample:t[0]??e,haplotype:Number.isFinite(n)?n:void 0}}function li(e,t,n,s){let o=[],r=[],a=[e];for(s.add(e);a.length>0;){let l=a.pop(),i=t.get(l);if(i){o.push(i);for(let c of n.get(l)??[]){let d=t.get(c);d&&(d.stable.rank===mt?r.push(d):s.has(c)||(s.add(c),a.push(c)))}}}return{members:o,anchors:r}}function ci(e){if(new Set(e.map(l=>l.stable.refName)).size!==1||e.length<2)return;let n=[...e].sort((l,i)=>l.stable.start-i.stable.start),s=n[0],o=n.at(-1),r=s.stable.start+s.length,a=o.stable.start;return a>=r?{start:r,end:a,entry:s}:void 0}function fi(e,t,n){let s=new Map(e.map(a=>[a.id,a])),o=new Map,r=[];for(let a of n.get(t.id)??[])s.has(a)&&(o.set(a,0),r.push(a));if(r.length===0)for(let a of e)o.set(a.id,0),r.push(a.id);for(let a of r){let l=o.get(a)+s.get(a).length;for(let i of n.get(a)??[])if(s.has(i)){let c=o.get(i);(c===void 0||l<c)&&(o.set(i,l),r.push(i))}}return o}function di(e,t,n){let s=fi(e,t,n),o=[...e].sort((i,c)=>s.get(i.id)-s.get(c.id)),r=new Map(o.map((i,c)=>[i.id,c])),a=new Map(e.map(i=>[i.id,i])),l=new Map;for(let[i,c]of o.entries()){let d=0;for(let f of n.get(c.id)??[]){let h=a.get(f);h&&r.get(f)<i&&(d=Math.max(d,l.get(f)+h.length))}l.set(c.id,d)}return{offsets:l,ordered:o}}function is(e){let t=new Map(e.nodes.filter(Be).map(r=>[r.id,r])),n=nt(e),s=new Set,o=[];for(let r of t.values())if(r.stable.rank!==mt&&!s.has(r.id)){let{members:a,anchors:l}=li(r.id,t,n,s),i=ci(l);if(i){let{offsets:c,ordered:d}=di(a,i.entry,n);o.push({start:i.start,refSpan:i.end-i.start,nodeIds:d.map(f=>f.id),nodeOffsets:d.map(f=>c.get(f.id)),pathLength:d.reduce((f,h)=>Math.max(f,c.get(h.id)+h.length),0)})}}return o.sort((r,a)=>r.start-a.start)}var hi=1,ui=.015;function It({graph:e,span:t,rowY:n,positions:s}){let o=t*ui,r=is(e),a=new Map(e.nodes.map(d=>[d.id,d])),l=[];for(let d of r){let f=d.refSpan-d.pathLength;f>=hi&&l.push({nodeIds:d.nodeIds,bp:f});let h=Math.max(d.refSpan,o),p=d.pathLength>0?h/d.pathLength:0;d.nodeIds.forEach((u,m)=>{let g=a.get(u);if(g){let x=d.nodeOffsets[m],w=h/d.nodeIds.length,N=R=>d.start+R*p,v=n(g);s[u]=p?[{x:N(x),y:v},{x:N(x+g.length),y:v}]:[{x:d.start+m*w,y:v},{x:d.start+(m+1)*w,y:v}]}})}let i=nt(e),c=Object.keys(s);for(let d of c){let f=s[d].at(-1).x;for(let h of i.get(d)??[]){let p=a.get(h);if(p&&!(h in s)){let u=n(p);s[h]=[{x:f,y:u},{x:f+o,y:u}],c.push(h)}}}return l}function pi(e,t){let n=new Map;for(let o of e.nodes)if(Ze(o)){let{sample:r}=Lt(o.stable.refName);n.set(r,(n.get(r)??0)+o.length)}let s=new Map(t.map((o,r)=>[o,r]));return[...n.keys()].sort((o,r)=>(s.get(o)??1/0)-(s.get(r)??1/0)||n.get(r)-n.get(o)||o.localeCompare(r))}function ls(e,t,n=[]){let s=ye(e),o=pi(e,n);if(s.length===0||o.length===0)return;let r=Je(s,t),a=new Map(o.map((h,p)=>[h,p+1])),l=be(s),i=o.length+1,c=It({graph:e,span:r,rowY:h=>{let p=h.stable;return((p?a.get(Lt(p.refName).sample):void 0)??i)*F},positions:l}),f=[{label:Lt(s[0].stable.refName).sample,y:0},...o.map(h=>({label:h,y:a.get(h)*F}))];return{nodePositions:l,rowLabels:f,sampleRows:o,referenceAxis:!0,pixelRows:!0,alleleDeletions:c}}function bn(){return{rectangles:[],curves:[],corners:[],verticalRectangles:[],featureRectangles:[]}}var rt=!1,cs=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f"];function Ss(e){return{mergeNodesFlag:e.mergeNodes??!0,showReads:e.showReads??!0,coarsenedReadView:e.coarsenedReadView??!1,ignoreStrand:e.ignoreStrand??!1,nodeWidthOption:e.nodeWidthOption??"normal",charWidth:e.charWidth??8.401,trackWidth:e.trackWidth??15,mappingQualityCutoff:e.mappingQualityCutoff??0,focusReadNames:e.focusReadNames??null,showExonsFlag:e.showExons??!1,trackColor:e.trackColor??(t=>cs[t.id%cs.length]),trackAlpha:e.trackAlpha??(()=>1)}}var C=Ss({}),Rn=null,y=[],b=[],E=[],I=new Map,Ge=[],_=[],Se=[],Nn=[],_n=[],V=-1,q=bn(),Sn={minX:0,maxX:0,minY:0,maxY:0},ot,Ct=new Map;function Ns(e,t,n=[],s={}){if(C=Ss(s),Rn=s.bed??null,q=bn(),Se=[],Nn=[],_n=[],Ge=[],Sn={minX:0,maxX:0,minY:0,maxY:0},ot=void 0,Ct=new Map,e.length===0||t.length===0)return;let o=wn(e);y=[],o.forEach((i,c)=>{y[c+1]=i}),b=wn(t);let r=n.length>0;E=wn(tl(n));for(let i=b.length-1;i>=0;i-=1){let c=b[i];if(c.type===void 0&&(c.type="haplotype"),c.hidden===!0){b.splice(i,1);continue}c.indexOfFirstBase!==void 0&&(ot=c.name)}if(b.length===0)return;gi(0),I=hs(),We(b),C.showReads&&E.length>0&&We(E),Rs(),C.mergeNodesFlag&&(us(),vn(),C.showReads&&E.length>0&&Mn(),el(),I=hs(),Rs(),We(b),C.showReads&&E.length>0&&We(E)),us(),Bi(),rt&&console.log(`${y.length} nodes.`),vn(),V=ms(),Di(),vn(),V=ms();let a=C.showReads&&C.coarsenedReadView&&!r;if(a){let i=ot===void 0?-1:b.findIndex(f=>f.name===ot),c=i===-1?0:i,d=b.filter((f,h)=>h!==c);if(d.length>0){let f=ws(d,"haplotype");f.length>0&&(b=[b[c]],E=f)}}Ki(),Wi(),C.showExonsFlag&&Rn!==null&&Ui();let l=C.showReads&&C.coarsenedReadView&&E.length>0&&!a;return C.showReads&&E.length>0?(xi(),Mn(),We(E),l&&(E=ws(E,"read"),Mn(),We(E)),bi(),b=b.concat(E)):y.forEach(i=>{i&&(i.incomingReads=[],i.outgoingReads=[],i.internalReads=[])}),qi(),Qi(),rt&&(console.log("Tracks:"),console.log(b),console.log("Nodes:"),console.log(y),console.log("Lane assignment:"),console.log(Se)),Ci(),{nodes:y,tracks:b,reads:E,nodeMap:I,shapes:q,bounds:Sn,maxOrder:V,trackForRuler:ot,coarsenedEdgeMeta:Ct}}function He(e,t="plain"){return C.trackColor(e,t)}function mi(e){return C.trackAlpha(e)}function wn(e){return structuredClone(e)}function W(e){let t=String(e);return t.length>=1&&t.startsWith("-")}function O(e){return W(e)?String(e).substring(1):e}function he(e){return W(e)?e:`-${e}`}function _s(e){return W(e)?O(e):he(e)}function Tt(e){return(e||1/e)>=0}function gi(e){let t=new Set,n=b[e].sequence;for(let s=0;s<n.length;s+=1){let o=n[s];if(W(o)){let r=O(o),a=n.indexOf(r);(a===-1||a>s)&&t.add(r)}}for(let s of b){n=s.sequence;for(let o=0;o<n.length;o+=1){let r=n[o];W(r)?t.has(O(r))&&(n[o]=O(r)):t.has(r)&&(n[o]=he(r))}}y.forEach(s=>{s&&t.has(s.name)&&(s.seq=s.seq.split("").reverse().join(""))})}function xi(){Ge=[];for(let t=0;t<=V;t+=1)Ge[t]=[];let e=new Map;y.forEach(t=>{t.y!==void 0&&fs(e,t.order,t.y+t.contentHeight)}),b.forEach(t=>{t.type==="haplotype"&&t.path.forEach(n=>{fs(e,n.order,(n.y??0)+t.width)})}),y.forEach((t,n)=>{t.order>=0&&t.y===void 0&&(t.y=(e.get(t.order)??0)+25,t.contentHeight=0,Ge[t.order].push(n))})}function fs(e,t,n){let s=e.get(t);s===void 0?e.set(t,n):e.set(t,Math.max(s,n))}var Ot=7;function yi(){y.forEach(e=>{e&&(e.incomingReads=[],e.outgoingReads=[],e.internalReads=[])}),E.forEach((e,t)=>{if((e.width===void 0||e.width===0)&&(e.width=Ot),e.path.length===1){let n=e.path[0].node;n!==null&&y[n].internalReads.push(t)}else e.path.forEach((n,s)=>{if(s===0){let o=e.path[0].node;o!==null&&y[o].outgoingReads.push([t,s])}else{let o=n.node;o!==null&&y[o].incomingReads.push([t,s])}})})}function bi(){_i(),yi();let e=y.slice();e.sort(Pt);let t=new Map;for(let a=0;a<E.length;a++){let l=E[a].sourceTrackID,i=t.get(l);i===void 0?t.set(l,[a]):i.push(a)}let n=Array.from(t.keys()).sort((a,l)=>a-l),s=n.length>1?Ot:0;e.forEach(a=>{if(a)for(let l of n)wi(t.get(l),a,s)});let o=Ni(),r=[];E.forEach((a,l)=>{let i=a.path.length,c=new Array(i),d;for(let p=0;p<i;p++){p===0?c[p]=void 0:c[p]=d??a.path[0];let u=a.path[p];u.node!==null&&u.node&&(d=u)}let f=new Array(i),h;for(let p=i-1;p>=0;p--){p===i-1?f[p]=void 0:f[p]=h??a.path[i-1];let u=a.path[p];u.node!==null&&u.node&&(h=u)}a.path.forEach((p,u)=>{if(p.y===void 0){let m=c[u],g=f[u],x=!!(g&&m&&g.isForward!==void 0&&m.isForward!==void 0&&(m.order>g.order||g.order===m.order&&g.isForward===m.isForward));p.betweenCycleReverseTraversal=x,r.push({readIndex:l,pathIndex:u,previousY:m?.y,previousNode:m?.node})}})}),r.sort(vi),r.forEach(a=>{let l=E[a.readIndex],i=l.path[a.pathIndex];i.y=o[i.order],o[i.order]+=l.width}),rt&&(console.log("Reads:"),console.log(E))}function wi(e,t,n){let s=new Set(e),o=t.incomingReads.filter(([u])=>s.has(u)),r=t.outgoingReads.filter(([u])=>s.has(u)),a=t.internalReads.filter(u=>s.has(u));o.length===0&&r.length===0&&a.length===0&&(n=0);let l=t.y+t.contentHeight+n*2,i=o.map(u=>{let[m,g]=u,x=E[m].path,w=g+1,N;for(let v=1;v<=g;v++){let R=x[g-v]?.y;if(R!==void 0){w=v,N=R;break}}return{entry:u,decisionStep:w,y:N}});i.sort(Mi),o=i.map(u=>u.entry);let c=l,d=new Map;o.forEach(u=>{let m=E[u[0]];m.path[u[1]].y=c,ds(d,m,u[1],c,t),c+=m.width});let f=c;r.sort(Ei);let h=new Map;c=l,r.forEach(u=>{let m=E[u[0]],g=m.firstNodeOffset??0;m.path[u[1]].y=c,h.set(c,g);let x=d.get(c);x===void 0||x+1<=g?(c+=m.width,f=Math.max(f,c)):(d.set(c,0),o.forEach(w=>{let N=E[w[0]],v=N.path[w[1]];v.y!==void 0&&v.y>=c&&(v.y+=m.width,ds(d,N,w[1],v.y,t))}),c+=m.width,f+=m.width)}),a.sort(Si),a.forEach(u=>{let m=E[u],g=m.firstNodeOffset??0,x=m.finalNodeCoverLength??0;for(c=l;g<(d.get(c)??-1/0)+2||x>(h.get(c)??1/0)-3;)c+=m.width||Ot;m.path[0].y=c,d.set(c,x),f=Math.max(f,c)});let p=f-t.y-t.contentHeight;t.contentHeight+=p,zi(t,p)}function Mi(e,t){return e.decisionStep!==t.decisionStep?e.decisionStep-t.decisionStep:e.y===void 0||t.y===void 0?(e.y===void 0?0:1)-(t.y===void 0?0:1):e.y-t.y}function ds(e,t,n,s,o){n===t.path.length-1?e.set(s,t.finalNodeCoverLength??0):e.set(s,o.sequenceLength)}function vi(e,t){let n=E[e.readIndex],s=E[t.readIndex],o=n.path[e.pathIndex],r=s.path[t.pathIndex];if(o.order!==r.order)return o.order-r.order;if(n.sourceTrackID!==s.sourceTrackID)return n.sourceTrackID-s.sourceTrackID;if(e.previousNode&&t.previousNode){let i=y[e.previousNode],c=y[t.previousNode];if(i&&c&&i.order!==c.order)return i.order-c.order}let a=e.previousY??0,l=t.previousY??0;return o.betweenCycleReverseTraversal&&r.betweenCycleReverseTraversal?l-a:a-l}function Ei([e,t],[n,s]){let o=E[e],r=E[n],a,l,i=o.path.length-1,c=r.path.length-1;for(;!a&&i>=0;)a=o.path[i]?.y,i-=1;for(;!l&&c>=0;)l=r.path[c]?.y,c-=1;if(a&&l)return a-l;let d=o.path[t]?.node,f=r.path[s]?.node,h=d!=null?y[d]:null,p=f!=null?y[f]:null;for(;h!=null&&p!=null&&h===p;){if(t<o.path.length-1){for(t+=1;o.path[t]?.node===null;)t+=1;let m=o.path[t]?.node;h=m!=null?y[m]:null}else h=null;if(s<r.path.length-1){for(s+=1;r.path[s]?.node===null;)s+=1;let m=r.path[s]?.node;p=m!=null?y[m]:null}else p=null}if(h!=null)return p!=null?Pt(h,p):1;if(p!=null)return-1;let u=(o.firstNodeOffset??0)-(r.firstNodeOffset??0);return u!==0?u:(o.finalNodeCoverLength??0)-(r.finalNodeCoverLength??0)}function Ri(e,t){if(e.path===void 0||t.path===void 0)return(e.path===void 0?0:1)-(t.path===void 0?0:1);let n=e.path,s=t.path,o=0,r=0;for(;o<n.length&&r<s.length;){let a=n[o],l=s[r],i=a.order,c=l.order;if(i===c&&a.node&&l.node)return(l.y??0)-(a.y??0);i<c?o+=1:(i>c||(o+=1),r+=1)}return 0}function Si(e,t){let n=E[e],s=E[t],o=n.firstNodeOffset??0,r=s.firstNodeOffset??0;if(o<r)return-1;if(o>r)return 1;let a=n.finalNodeCoverLength??0,l=s.finalNodeCoverLength??0;return a<l?-1:a>l?1:0}function Ni(){let e=[];for(let t=0;t<=V;t+=1)e.push(0);return y.forEach(t=>{t.y!==void 0&&(e[t.order]=Math.max(e[t.order],t.y+t.contentHeight+20))}),b.forEach(t=>{t.path.forEach(n=>{e[n.order]=Math.max(e[n.order],(n.y??0)+t.width)})}),e}function _i(){E.forEach(e=>{let t=Math.abs(e.indexSequence[0]),n=Tt(e.indexSequence[0]),s=y[t],o,r;e.path=[],e.path.push({order:s.order,isForward:n,node:t});for(let a=1;a<e.sequence.length;a+=1)if(o=s,r=n,t=Math.abs(e.indexSequence[a]),n=Tt(e.indexSequence[a]),s=y[t],s.order>o.order){r||e.path.push({order:o.order,isForward:!0,node:null});for(let l=o.order+1;l<s.order;l+=1)e.path.push({order:l,isForward:!0,node:null});n?e.path.push({order:s.order,isForward:!0,node:t}):(e.path.push({order:s.order,isForward:!0,node:null}),e.path.push({order:s.order,isForward:!1,node:t}))}else if(s.order<o.order){r&&e.path.push({order:o.order,isForward:!1,node:null});for(let l=o.order-1;l>s.order;l-=1)e.path.push({order:l,isForward:!1,node:null});n?(e.path.push({order:s.order,isForward:!1,node:null}),e.path.push({order:s.order,isForward:!0,node:t})):e.path.push({order:s.order,isForward:!1,node:t})}else n!==r?e.path.push({order:s.order,isForward:n,node:t}):(e.path.push({order:s.order,isForward:!n,node:null}),e.path.push({order:s.order,isForward:n,node:t}))})}function Mn(){E.forEach(e=>{let t=0;for(;t<e.sequence.length&&e.sequence[t].startsWith("-");)t+=1;if(t===e.sequence.length){e.is_reverse=!0,e.sequence=e.sequence.reverse();for(let a=0;a<e.sequence.length;a+=1)e.sequence[a]=O(e.sequence[a]);let n=e.sequenceNew??[];n.reverse(),e.sequenceNew=n;for(let a of n)a.nodeName=O(a.nodeName),Ai(a.mismatches,se(a.nodeName).sequenceLength);let s=e.firstNodeOffset??0,o=se(e.sequence[0]).sequenceLength;e.firstNodeOffset=o-(e.finalNodeCoverLength??0);let r=se(e.sequence[e.sequence.length-1]).sequenceLength;e.finalNodeCoverLength=r-s}})}function Ai(e,t){e.forEach(n=>{n.type==="insertion"?n.pos=t-n.pos:n.type==="deletion"?n.pos=t-n.pos-(n.length??0):n.type==="substitution"&&(n.pos=t-n.pos-(n.seq?.length??0)),n.seq!==void 0&&(n.seq=As(n.seq).split("").reverse().join(""))})}var Li={A:"T",T:"A",C:"G",G:"C"};function As(e){let t="";for(let n=e.length-1;n>=0;n-=1)t+=Li[e.charAt(n)]??"N";return t}function We(e){e.forEach(t=>{t.indexSequence=[],t.sequence.forEach(n=>{let s=n,o=I.get(O(s)),r=y[o]?.switched??!1;r&&(s=_s(s));let a=I.get(O(s));if(a===0)throw new Error("Node "+O(s)+" has prohibited index 0");W(s)!==r?t.indexSequence.push(-a):t.indexSequence.push(a)})})}var Ii=20;function Ci(){let e={minX:99,maxX:-99,minY:99,maxY:-99};y.forEach(t=>{t&&(t.x!==void 0&&(e.minX=Math.min(e.minX,t.x),e.maxX=Math.max(e.maxX,t.x+Ii+t.pixelWidth)),t.y!==void 0&&(e.minY=Math.min(e.minY,t.y-10),e.maxY=Math.max(e.maxY,t.y+t.contentHeight+10)))}),b.forEach(t=>{t.path.forEach(n=>{let s=n.y??0;e.maxY=Math.max(e.maxY,s+t.width),e.minY=Math.min(e.minY,s)})}),Sn=e}function se(e){let t=I.get(O(e)),n=t===void 0?void 0:y[t];if(n===void 0)throw new Error(`Unknown node ${e}`);return n}function hs(){return I=new Map,y.forEach((e,t)=>{e&&I.set(e.name,t)}),I}function us(){let e=y.map(()=>new Set),t=y.map(()=>new Set),n=s=>{for(let o=0;o<s.indexSequence.length-1;o+=1){let r=Math.abs(s.indexSequence[o]),a=Math.abs(s.indexSequence[o+1]);e[r].add(a),t[a].add(r)}};b.forEach(n),C.showReads&&E.length>0&&E.forEach(n),y.forEach((s,o)=>{s&&(s.successors=Array.from(e[o]),s.predecessors=Array.from(t[o]))})}function ps(e){let t=0,n=0,s=0;e.forEach(o=>{let r=Math.abs(o);if(o<0){_[r]===void 0&&(_[r]=n);let a=_[r];a<s&&(s=a),t=a,n=a-1}else{_[r]===void 0&&(_[r]=t);let a=_[r];t=a+1,n=a}}),s<0&&An(-s)}function Ti(e){let t=0,n=0;for(;t<e.length&&_[Math.abs(e[t])]===void 0;)t+=1;if(t>=e.length)return null;let s=e[t],o,r;s>=0?(o=_[s]-1,r=-1):(o=_[-s]+1,r=1);for(let a=t-1;a>=0;a-=1){let l=Math.abs(e[a]);_[l]===void 0&&(_[l]=o,n=Math.min(n,o),o+=r)}return n<0&&An(-n),t}var Oi=-1;function Pi(e){let t=[];for(let n of e)t.push(n??Oi);return t}function vn(){let e,t,n,s,o=0,r=C.showReads&&E.length>0?b.concat(E):b,a={stamp:new Int32Array(y.length),generation:0};_=new Array(y.length).fill(void 0),y.forEach(i=>{i&&(i.order=void 0)}),ps(b[0].indexSequence);for(let i=1;i<r.length;i+=1){if(rt&&console.log(`generating order for track ${i+1}`),n=Ti(r[i].indexSequence),n===null){r[i].type==="haplotype"?ps(r[i].indexSequence):(r.splice(i,1),E.splice(i-b.length,1),i-=1);continue}for(e=ki(r[i].indexSequence);n<e.length;){for(s=n,n+=1;n<e.length&&_[e[n]]===void 0;)n+=1;if(n<e.length){t=_[e[s]]+1;for(let c=s+1;c<n;c+=1)_[e[c]]=t,t+=1;if(_[e[n]]>_[e[s]])_[e[n]]<t&&gs(e[n],e[n-1],t);else if(r[i].indexSequence[n]>=0&&!$i(e[n],e[s],a))gs(e[n],e[n-1],t);else if(r[i].indexSequence[s]<0||y[e[s+1]].degree<2&&_[e[n]]<_[e[s]]){t=_[e[s]]-1;for(let c=s+1;c<n;c+=1)_[e[c]]=t,o=Math.min(o,t),t-=1}}else if(r[i].indexSequence[s]>=0){t=_[e[s]]+1;for(let c=s+1;c<e.length;c+=1){let d=e[c];_[d]===void 0&&(_[d]=t,t+=1)}}else{t=_[e[s]]-1;for(let c=s+1;c<e.length;c+=1){let d=e[c];_[d]===void 0&&(_[d]=t,o=Math.min(o,t),t-=1)}}}}o<0&&An(-o);let l=Pi(_);_=l,l.forEach((i,c)=>{let d=y[c];d!==void 0&&(d.order=i)})}function $i(e,t,n){n.generation+=1;let{stamp:s,generation:o}=n,r=[e];for(s[e]=o;r.length>0;){let a=r.pop();if(a===t)return!0;for(let l of y[a].successors)s[l]!==o&&(s[l]=o,r.push(l))}return!1}function ms(){let e=-1;return _.forEach(t=>{t!==void 0&&t>e&&(e=t)}),e}function ki(e){return e.map(t=>Math.abs(t))}function An(e){_.forEach((t,n)=>{t!==void 0&&(_[n]=t+e)})}function gs(e,t,n){let s=new Map,o=[[e,n]],r=0;for(;r<o.length;){let[a,l]=o[r];r+=1;let i=_[a];i!==void 0&&i<l&&(!s.has(a)||s.get(a)<l)&&(s.set(a,l),y[a].successors.forEach(c=>{_[c]>i&&c!==t&&o.push([c,l+1])}),a!==e&&y[a].predecessors.forEach(c=>{_[c]>i&&c!==t&&o.push([c,l+1])}))}s.forEach((a,l)=>{_[l]=a})}function Bi(){y.forEach(e=>{e.tracks=[]}),b.forEach(e=>{e.indexSequence.forEach(t=>{y[Math.abs(t)].tracks.push(e.id)})}),y.forEach(e=>{e.tracks!==void 0&&(e.degree=e.tracks.length)})}function Di(){let e=b[0],t=b.slice(1,b.length);if(C.showReads&&E.length>0&&(t=t.concat(E)),Fi(t,e),C.showReads&&E.length>0){for(let n=0;n<E.length;n++)if(E[n]!==t[n+b.length-1])throw new Error("Read inequality")}}function Fi(e,t){let n=new Map,s=t?new Set(t.sequence):null;for(let o of e){let r=o.sequence;for(let a=0;a<r.length;a+=1){let l=O(r[a]),i=se(l);if(s&&!s.has(l)){let c=a>0?se(r[a-1]).order:void 0,d=a<r.length-1?se(r[a+1]).order:void 0;(c===void 0||c<i.order)&&(d===void 0||i.order<d)&&xs(n,l,W(r[a])?1:-1),(c===void 0||c>i.order)&&(d===void 0||i.order>d)&&xs(n,l,W(r[a])?-1:1)}}}for(let o of e)o.sequence.forEach((r,a)=>{let l=n.get(O(r));l!==void 0&&l>0&&(o.sequence[a]=_s(r),o.indexSequence[a]=-o.indexSequence[a])});n.forEach((o,r)=>{if(o>0){let a=se(r);a.seq=As(a.seq),a.switched=!0}})}function xs(e,t,n){e.set(t,(e.get(t)??0)+n)}function qi(){let e=0,t=20,n=-1,s=y.slice();s.sort(Pt);let o=Xi();s.forEach(r=>{r.order>=0&&(r.order>n&&(n=r.order,e=t+10*o[r.order]),r.x=e,t=Math.max(t,e+40+r.pixelWidth))})}function Xi(){let e=[],t=[],n=[],s=[];for(let o=0;o<=V;o+=1)e.push(0),t.push(0),n.push(0);b.forEach(o=>{for(let r=1;r<o.path.length;r+=1){let a=o.path[r],l=o.path[r-1];if(a.order===l.order)a.isForward?e[a.order]=e[a.order]+1:t[a.order]=t[a.order]+1;else{let i=Math.abs((a.y??0)-(l.y??0));n[a.order]=Math.max(i/17.5,n[a.order])}}}),s.push(Math.max(0,e[0]-1));for(let o=1;o<=V;o+=1)s.push(Math.max(Math.max(0,e[o]-1)+Math.max(0,t[o-1]-1),n[o]));return s}function Wi(){let e,t,n,s,o,r,a=[],l=[];for(let i=0;i<=V;i+=1){Se[i]=[],l[i]=new Map,a[i]=[];for(let c=0;c<b.length;c+=1)a[i][c]=null}b.forEach((i,c)=>{t=Math.abs(i.indexSequence[0]),n=Tt(i.indexSequence[0]),s=y[t],i.path=[],i.path.push({order:s.order,lane:null,isForward:n,node:t}),X(s.order,t,c,0,a,l),e=1;for(let d=1;d<i.sequence.length;d+=1)if(o=s,r=n,t=Math.abs(i.indexSequence[d]),n=Tt(i.indexSequence[d]),s=y[t],s.order>o.order){r||(i.path.push({order:o.order,lane:null,isForward:!0,node:null}),X(o.order,null,c,e,a,l),e+=1);for(let f=o.order+1;f<s.order;f+=1)i.path.push({order:f,lane:null,isForward:!0,node:null}),X(f,null,c,e,a,l),e+=1;n?(i.path.push({order:s.order,lane:null,isForward:!0,node:t}),X(s.order,t,c,e,a,l),e+=1):(i.path.push({order:s.order,lane:null,isForward:!0,node:null}),X(s.order,null,c,e,a,l),e+=1,i.path.push({order:s.order,lane:null,isForward:!1,node:t}),X(s.order,t,c,e,a,l),e+=1)}else if(s.order<o.order){r&&(i.path.push({order:o.order,lane:null,isForward:!1,node:null}),X(o.order,null,c,e,a,l),e+=1);for(let f=o.order-1;f>s.order;f-=1)i.path.push({order:f,lane:null,isForward:!1,node:null}),X(f,null,c,e,a,l),e+=1;n?(i.path.push({order:s.order,lane:null,isForward:!1,node:null}),X(s.order,null,c,e,a,l),e+=1,i.path.push({order:s.order,lane:null,isForward:!0,node:t}),X(s.order,t,c,e,a,l),e+=1):(i.path.push({order:s.order,lane:null,isForward:!1,node:t}),X(s.order,t,c,e,a,l),e+=1)}else n!==r?(i.path.push({order:s.order,lane:null,isForward:n,node:t}),X(s.order,t,c,e,a,l),e+=1):(i.path.push({order:s.order,lane:null,isForward:!n,node:null}),X(s.order,null,c,e,a,l),e+=1,i.path.push({order:s.order,lane:null,isForward:n,node:t}),X(s.order,t,c,e,a,l),e+=1)});for(let i=0;i<=V;i+=1)Gi(Se[i],i)}function X(e,t,n,s,o,r){let a={trackID:n,segmentID:s,compareToFromSame:o[e][n]??null},l=t===null?void 0:r[e].get(t);if(l===void 0){let i={type:"single",node:t,tracks:[a]};Se[e].push(i),t!==null&&r[e].set(t,i)}else l.type="multiple",l.tracks.push(a);o[e][n]=a}function Hi(e,t){let n;e.forEach(s=>{s.idealLane=0,s.tracks.forEach(o=>{if(o.segmentID===0)o.idealLane=o.trackID,o.idealY=null;else if(b[o.trackID].path[o.segmentID-1].order===t-1)o.idealLane=b[o.trackID].path[o.segmentID-1].lane??void 0,o.idealY=b[o.trackID].path[o.segmentID-1].y;else if(o.segmentID<b[o.trackID].path.length-1&&b[o.trackID].path[o.segmentID+1].order===t-1)o.idealLane=b[o.trackID].path[o.segmentID+1].lane??void 0,o.idealY=b[o.trackID].path[o.segmentID+1].y;else{for(n=o.segmentID-1;n>=0&&b[o.trackID].path[n].order!==t-1;)n-=1;n<0?(o.idealLane=o.trackID,o.idealY=null):(o.idealLane=b[o.trackID].path[n].lane??void 0,o.idealY=b[o.trackID].path[n].y)}s.idealLane+=o.idealLane}),s.idealLane/=s.tracks.length})}function Gi(e,t){let n=0,s=new Set,o=20,r=!1,a=-1;Hi(e,t),e.sort(bs),e.forEach(l=>{l.node!==null?(y[l.node].topLane=n,r&&(o-=10),y[l.node].y=o,y[l.node].contentHeight=0,r=!1):(r?o-=25:o>20&&(o-=10),r=!0),l.tracks.sort(bs),l.tracks.forEach(i=>{i.lane=n,i.trackID===a&&l.node===null&&r&&(o+=10),b[i.trackID].path[i.segmentID].lane=n,b[i.trackID].path[i.segmentID].y=o,i.idealY!=null&&s.add(i.idealY-o),n+=1,o+=b[i.trackID].width,l.node!==null&&(y[l.node].contentHeight+=b[i.trackID].width),a=i.trackID}),o+=25}),Yi(e,s)}function Yi(e,t){let n=0,s=Number.MAX_SAFE_INTEGER;t.forEach(o=>{ys(e,o)<s&&(s=ys(e,o),n=o)}),e.forEach(o=>{o.node!==null&&(y[o.node].y+=n),o.tracks.forEach(r=>{let a=b[r.trackID].path[r.segmentID];a.y=a.y+n})})}function zi(e,t){e.order<0||Se[e.order]===void 0||(Se[e.order].forEach(n=>{if(n.node!==null){let s=y[n.node];s!==e&&s.y>e.y&&(s.y+=t,n.tracks.forEach(o=>{let r=b[o.trackID].path[o.segmentID];r.y=r.y+t}))}else n.tracks.forEach(s=>{let o=b[s.trackID].path[s.segmentID];o.y>=e.y&&(o.y=o.y+t)})}),Ge[e.order].length>0&&Ge[e.order].forEach(n=>{y[n]!==e&&y[n].y>e.y&&(y[n].y+=t)}))}function ys(e,t){let n=0;return e.forEach(s=>{s.tracks.forEach(o=>{o.idealY!=null&&b[o.trackID].type!=="read"&&(n+=Math.abs(o.idealY-t-b[o.trackID].path[o.segmentID].y)*b[o.trackID].width)})}),n}function bs(e,t){return e.idealLane!==void 0?t.idealLane!==void 0?e.idealLane<t.idealLane?-1:e.idealLane>t.idealLane?1:0:-1:t.idealLane!==void 0?1:0}function Pt(e,t){if(!e)return t?-1:0;if(!t)return 1;if(e.order!==void 0){if(t.order!==void 0){if(e.order<t.order)return-1;if(e.order>t.order)return 1;if(e.y!==void 0&&t.y!==void 0){if(e.y<t.y)return-1;if(e.y>t.y)return 1}return 0}return-1}return t.order!==void 0?1:0}function Ui(){let e,t,n={};Rn.forEach(s=>{let o=0;for(;o<b.length&&b[o].name!==s.track;)o+=1;o<b.length&&(e=0,b[o].path.forEach(r=>{r.node!==null&&(n={},t=e+y[r.node].sequenceLength-1,e>=s.start&&e<=s.end&&(n.start=0),e<s.start&&t>=s.start&&(n.start=s.start-e),t<=s.end&&t>=s.start&&(n.end=t-e,t<s.end&&(n.continue=!0)),t>s.end&&e<=s.end&&(n.end=s.end-e),n.start!==void 0&&(n.type=s.type,n.name=s.name,r.features===void 0&&(r.features=[]),r.features.push(n)),e=t+1)}))})}function Ki(){let e=!0,t=4,n=C.trackWidth;b.forEach(s=>{s.freq!==void 0?s.width=Math.round((Math.log(s.freq)+1)*t):(s.width=n,s.type!==void 0&&s.type==="read"&&(s.width=t)),s.width!==t&&(e=!1)}),e&&b.forEach(s=>{s.freq!==void 0&&(s.width=n)})}function ji(e){let t=e.path[0],n=y[t.node],s=e.firstNodeOffset??0;return Ln(n,t.isForward?s:n.sequenceLength-s)}function Vi(e){let t=e.path[e.path.length-1],n=y[t.node],s=e.finalNodeCoverLength??0;return Ln(n,t.isForward?s:n.sequenceLength-s)}function Ls(e,t){return t>e.sequenceLength?null:Ln(e,t)}function Ln(e,t){let[n,s]=Ji(e);if(e.sequenceLength===0)return n;let o=Math.min(Math.max(t,0),e.sequenceLength);return n+o/e.sequenceLength*(s-n)}function Qi(){let e,t,n,s,o,r,a,l,i;for(let f=0;f<=V;f+=1)Nn.push(0),_n.push(0);let c=[],d=[];y.forEach(f=>{f.x!==void 0&&(c[f.order]=f.x,d[f.order]===void 0?d[f.order]=f.x+f.pixelWidth:d[f.order]=Math.max(d[f.order],f.x+f.pixelWidth))}),b.sort(Ri),b.forEach(f=>{a="plain",o=He(f,a),r=mi(f);let h=a,p=()=>(h!==a&&(h=a,o=He(f,a)),o);n=f.path[0].y,f.type!=="read"?f.sequence[0].startsWith("-")?e=d[f.path[0].order]+20:e=c[f.path[0].order]-20:e=ji(f);for(let u=0;u<f.path.length;u+=1)f.path[u].y===n?f.path[u].features!==void 0&&(i=u>0&&f.path[u-1].order===f.path[u].order,l=Ms(f.path[u],c[f.path[u].order],d[f.path[u].order],a,f,e,n,o,i),a=l.highlight,e=l.xStart):(f.path[u-1].isForward?t=d[f.path[u-1].order]:t=c[f.path[u-1].order],t!==e&&(o=p(),q.rectangles.push({xStart:Math.min(e,t),yStart:n,xEnd:Math.max(e,t),yEnd:n+f.width-1,color:o,alpha:r,id:f.id,name:f.name,type:f.type})),f.path[u].order-1===f.path[u-1].order?(e=t,t=c[f.path[u].order],s=f.path[u].y,o=p(),q.curves.push({xStart:e,yStart:n,xEnd:t+1,yEnd:s,width:f.width,color:o,alpha:r,laneChange:Math.abs(f.path[u].lane-f.path[u-1].lane),id:f.id,name:f.name,type:f.type,nodeStart:f.path[u-1]?.node,nodeEnd:f.path[u]?.node}),e=t,n=s):f.path[u].order+1===f.path[u-1].order?(e=t,t=d[f.path[u].order],s=f.path[u].y,o=p(),q.curves.push({xStart:e+1,yStart:n,xEnd:t,yEnd:s,width:f.width,color:o,alpha:r,laneChange:Math.abs(f.path[u].lane-f.path[u-1].lane),id:f.id,name:f.name,type:f.type,nodeStart:f.path[u-1]?.node,nodeEnd:f.path[u]?.node}),e=t,n=s):f.path[u-1].isForward?(s=f.path[u].y,Es(1,t,n,s,f.width,o,f.id,f.path[u].order,f.type,f.name),e=d[f.path[u].order],n=f.path[u].y):(s=f.path[u].y,Es(-1,t,n,s,f.width,o,f.id,f.path[u].order,f.type,f.name),e=c[f.path[u].order],n=f.path[u].y),f.path[u].features!==void 0&&(i=f.path[u-1].order===f.path[u].order,l=Ms(f.path[u],c[f.path[u].order],d[f.path[u].order],a,f,e,n,o,i),a=l.highlight,e=l.xStart));f.type!=="read"?f.path[f.path.length-1].isForward?t=d[f.path[f.path.length-1].order]+20:t=c[f.path[f.path.length-1].order]-20:t=Vi(f),q.rectangles.push({xStart:Math.min(e,t),yStart:n,xEnd:Math.max(e,t),yEnd:n+f.width-1,color:o,alpha:r,id:f.id,name:f.name,type:f.type})})}var Zi=1e9;function ws(e,t){Ct=new Map;let n=new Map,s=C.ignoreStrand;for(let h of e){let p=h.indexSequence;if(!(!p||p.length<2))for(let u=0;u<p.length-1;u+=1){let m=p[u],g=p[u+1],x=Math.abs(m),w=Math.abs(g),N=y[x],v=y[w];if(!N||!v)continue;let R;if(s){let S=`${m}>${g}`,A=`${-g}>${-m}`;R=S<A?S:A}else R=`${m}>${g}`;let M=n.get(R);M===void 0?n.set(R,{sSigned:m,dSigned:g,sName:m<0?`-${N.name}`:N.name,dName:g<0?`-${v.name}`:v.name,count:1,sourceTrackID:h.sourceTrackID}):M.count+=1}}let o=0;for(let h of n.values())h.count>o&&(o=h.count);let r=Ot,a=60,l=h=>o<=1?r:r+(a-r)*Math.sqrt(h/o),i=[],c=0;for(let h of n.values()){let p=Zi+c,u=`${h.count.toLocaleString()} ${t}${h.count===1?"":"s"}: Node ${h.sName} \u2192 Node ${h.dName}`;Ct.set(p,{count:h.count,label:u});let m=y[Math.abs(h.sSigned)]?.sequenceLength??0;i.push({id:p,sourceTrackID:h.sourceTrackID,type:"read",name:u,sequence:[h.sName,h.dName],indexSequence:[],path:[],width:l(h.count),firstNodeOffset:m,finalNodeCoverLength:0,sequenceNew:[{nodeName:h.sName,mismatches:[]},{nodeName:h.dName,mismatches:[]}],mapping_quality:0,is_secondary:!1,sample_name:null,read_group:null,score:h.count}),c+=1}let d="?",f=0;for(let h of y){if(!h)continue;let p=h.contentHeight;p>f&&(f=p,d=h.name)}return rt&&console.log(`[coarsened] ${t}s_in=${e.length} edges_out=${i.length} tallestNodeBeforePlace=${d}(${f.toFixed(1)})`),i}function Ms(e,t,n,s,o,r,a,l,i){let c=s,d,f,h,p;t-=8,n+=8;let u=y[e.node].sequenceLength;return e.features.sort((m,g)=>m.start-g.start),e.features.forEach(m=>{c!==m.type&&(d=He(o,c),e.isForward?(h=t+Math.round(m.start*(n-t+1)/u),i&&h<t+8&&(p=t+Math.round((m.end+1)*(n-t+1)/u)-1,f=He(o,m.type),q.featureRectangles.push({xStart:h,yStart:a,xEnd:p,yEnd:a+o.width-1,color:f,id:o.id,name:o.name,type:o.type})),h>r+1&&q.featureRectangles.push({xStart:r,yStart:a,xEnd:h-1,yEnd:a+o.width-1,color:d,id:o.id,name:o.name,type:o.type})):(h=n-Math.round(m.start*(n-t+1)/u),i&&h>n-8&&(p=n-Math.round((m.end+1)*(n-t+1)/u)-1,f=He(o,m.type),q.featureRectangles.push({xStart:p,yStart:a,xEnd:h,yEnd:a+o.width-1,color:f,id:o.id,name:o.name,type:o.type})),r>h+1&&q.featureRectangles.push({xStart:h+1,yStart:a,xEnd:r,yEnd:a+o.width-1,color:d,id:o.id,name:o.name,type:o.type})),r=h,c=m.type),(m.end<u-1||m.continue===void 0)&&(d=He(o,c),e.isForward?(p=t+Math.round((m.end+1)*(n-t+1)/u)-1,q.featureRectangles.push({xStart:r,yStart:a,xEnd:p,yEnd:a+o.width-1,color:d,id:o.id,name:o.name,type:o.type})):(p=n-Math.round((m.end+1)*(n-t+1)/u)-1,q.featureRectangles.push({xStart:p,yStart:a,xEnd:r,yEnd:a+o.width-1,color:d,id:o.id,name:o.name,type:o.type})),r=p+1,c="plain")}),{xStart:r,highlight:c}}var vs=7;function Es(e,t,n,s,o,r,a,l,i,c){let d=e===1?_n:Nn,f=10*d[l],h=t+e*(f+5),p=vs,u=Math.min(vs,o),m=Math.min(n,s),g=Math.max(n,s),x=e===1?t:h-1,w=e===1?h:t,N=S=>{q.verticalRectangles.push({xStart:x,yStart:S,xEnd:w,yEnd:S+o-1,color:r,id:a,name:c,type:i})};N(n),q.verticalRectangles.push({xStart:e===1?h+p:h-p-u,yStart:m+o+p-1,xEnd:e===1?h+p+u-1:h-p-1,yEnd:g-p+1,color:r,id:a,name:c,type:i}),N(s);let v=h+e*p,R=h+e*(p+u),M=`M ${h} ${g}`;M+=` Q ${v} ${g} ${v} ${g-p}`,M+=` H ${R}`,M+=` Q ${R} ${g+o} ${h} ${g+o}`,M+=" Z ",q.corners.push({path:M,color:r,id:a,type:i}),M=`M ${h} ${m}`,M+=` Q ${R} ${m} ${R} ${m+o+p}`,M+=` H ${v}`,M+=` Q ${v} ${m+o} ${h} ${m+o}`,M+=" Z ",q.corners.push({path:M,color:r,id:a,type:i}),d[l]+=1}function Ji(e){let t=e.x-4,n=e.x+e.pixelWidth+4;return[t,n]}function Rs(){switch(y.forEach(e=>{e.sequenceLength===void 0&&(e.sequenceLength=e.seq.length)}),C.nodeWidthOption){case"compressed":y.forEach(e=>{e.width=1+Math.log(e.sequenceLength)/Math.log(2),e.pixelWidth=Math.round((e.width-1)*8.401)});break;case"small":y.forEach(e=>{e.width=e.sequenceLength/100,e.pixelWidth=Math.round((e.width-1)*8.401)});break;case"fixed":y.forEach(e=>{e.width=10,e.pixelWidth=Math.round(e.width*8.401)});break;case"normal":{let e=C.charWidth;y.forEach(t=>{t.width=t.sequenceLength;let n=t.seq?.length??1;t.pixelWidth=Math.round(e*n)});break}default:throw new Error(`${C.nodeWidthOption} not implemented`)}}function el(){let e,t,n=Array.from(y,()=>new Set),s=Array.from(y,()=>new Set),o;C.showReads&&E.length>0?o=b.concat(E):o=b,o.forEach(l=>{for(let i=0;i<l.sequence.length;i+=1)W(l.sequence[i])?(e=O(l.sequence[i]),i>0?(t=l.sequence[i-1],W(t)?s[I.get(e)].add(O(t)):(s[I.get(e)].add(t),s[I.get(e)].add(he(t)))):l.type==="haplotype"&&s[I.get(e)].add("None"),i<l.sequence.length-1?(t=l.sequence[i+1],W(t)?n[I.get(e)].add(O(t)):(n[I.get(e)].add(t),n[I.get(e)].add(he(t)))):l.type==="haplotype"&&n[I.get(e)].add("None")):(i>0?(e=l.sequence[i-1],n[I.get(l.sequence[i])].add(e),W(e)&&n[I.get(l.sequence[i])].add(O(e))):l.type==="haplotype"&&n[I.get(l.sequence[i])].add("None"),i<l.sequence.length-1?(e=l.sequence[i+1],s[I.get(l.sequence[i])].add(e),W(e)&&s[I.get(l.sequence[i])].add(O(e))):l.type==="haplotype"&&s[I.get(l.sequence[i])].add("None"))});let r=n.map(l=>Array.from(l)),a=s.map(l=>Array.from(l));if(C.showReads&&E.length>0){let l=y.slice();l.sort(Pt);let i=new Map,c=new Map,d=h=>{let p=i.get(h);if(p===void 0)throw new Error(`No merge offset recorded for node ${h}`);return p},f=h=>{let p=c.get(h);if(p===void 0)throw new Error(`No merge origin recorded for node ${h}`);return p};l.forEach(h=>{let p=st(I.get(h.name),r,a);if(p){let u=d(p)+se(p).sequenceLength;i.set(h.name,u),i.set(he(h.name),u),c.set(h.name,f(p)),c.set(he(h.name),f(p))}else i.set(h.name,0),i.set(he(h.name),0),c.set(h.name,h.name),c.set(he(h.name),h.name)}),E.forEach(h=>{let p=h.sequenceNew??[];h.firstNodeOffset=(h.firstNodeOffset??0)+d(h.sequence[0]),h.finalNodeCoverLength=(h.finalNodeCoverLength??0)+d(h.sequence[h.sequence.length-1]);for(let u=h.sequence.length-1;u>=0;u-=1){let m=O(h.sequence[u]),g=st(I.get(m),r,a);if(g&&En(I.get(g),r,a))if(u>0){h.sequence.splice(u,1);let x=se(g).sequenceLength;p[u].mismatches.forEach(w=>{w.pos+=x}),p[u-1].mismatches=p[u-1].mismatches.concat(p[u].mismatches),p.splice(u,1)}else{h.sequence[0]=f(h.sequence[0]);let x=p[0],w=d(x.nodeName);x.mismatches.forEach(N=>{N.pos+=w}),x.nodeName=f(x.nodeName)}}})}for(let l=0;l<y.length;l+=1)if(En(l,r,a)&&!st(l,r,a)){let i=l;for(;En(i,r,a);)i=I.get(O(a[i][0])),y[l].sequenceLength+=y[i].sequenceLength,y[l].seq+=y[i].seq}b.forEach(l=>{for(let i=l.sequence.length-1;i>=0;i-=1){e=O(l.sequence[i]);let c=I.get(e);st(c,r,a)&&l.sequence.splice(i,1)}});for(let l=y.length-1;l>=0;l-=1)st(l,r,a)&&y.splice(l,1)}function st(e,t,n){if(t[e].length!==1||t[e][0]==="None")return!1;let s=O(t[e][0]),o=I.get(s);return n[o].length!==1||n[o][0]==="None"?!1:s}function En(e,t,n){if(n[e].length!==1||n[e][0]==="None")return!1;let s=O(n[e][0]),o=I.get(s);return!(t[o].length!==1||t[o][0]==="None")}function tl(e){let t=C.focusReadNames?new Set(C.focusReadNames):null;return e.filter(n=>n.is_secondary!==!0&&(n.mapping_quality??0)>=C.mappingQualityCutoff&&(t===null||n.name!==void 0&&t.has(n.name)))}function nl(e,t){let n=new Map;for(let s of e){let o=t(s),r=n.get(o);r===void 0?n.set(o,[s]):r.push(s)}return n}function ol(e,t){return e.xStart<t.xStart?1:e.xStart>t.xStart?-1:e.yStart>t.yStart?1:e.yStart<t.yStart?-1:0}function Is(e,t){let n=nl(e.filter(r=>r.type===t),r=>`${r.nodeStart},${r.nodeEnd}`);n.forEach(r=>{let a=.3,l=.4/r.length;r.length<=5&&(a=.5,l=0),r.sort(ol),r.forEach(i=>{let c,d;i.yStart<i.yEnd?(c=i.xStart+(i.xEnd-i.xStart)*(1-a),a+=l,d=i.xStart+(i.xEnd-i.xStart)*(1-a)):(c=i.xStart+(i.xEnd-i.xStart)*a,a+=l,d=i.xStart+(i.xEnd-i.xStart)*a);let f=`M ${i.xStart} ${i.yStart}`;f+=` C ${c} ${i.yStart} ${c} ${i.yEnd} ${i.xEnd} ${i.yEnd}`,f+=` V ${i.yEnd+i.width}`,f+=` C ${d} ${i.yEnd+i.width} ${d} ${i.yStart+i.width} ${i.xStart} ${i.yStart+i.width}`,f+=" Z",i.path=f})});let s=Array.from(n.keys());s.sort(function(r,a){let l=r.split(",").map(Number),i=a.split(",").map(Number),c=l[0]??0,d=l[1]??0,f=i[0]??0,h=i[1]??0;return c<f?-1:c>f?1:d<h?-1:d>h?1:0});let o=[];for(let r of s){let a=n.get(r);a!==void 0&&o.push(...a)}return o}function Cs(e){let t=`M ${e.x-9} ${e.y} Q ${e.x-9} ${e.y-9} ${e.x} ${e.y-9}`,n=e.x,s=e.y-9;return e.width>1&&(n+=e.pixelWidth,t+=` L ${n} ${s}`),t+=` Q ${n+9} ${s} ${n+9} ${s+9}`,n+=9,s+=9,e.contentHeight>0&&(s+=e.contentHeight-0,t+=` L ${n} ${s}`),t+=` Q ${n} ${s+9} ${n-9} ${s+9}`,n-=9,s+=9,e.width>1&&(n-=e.pixelWidth,t+=` L ${n} ${s}`),t+=` Q ${n-9} ${s} ${n-9} ${s-9}`,n-=9,s-=9,e.contentHeight>0&&(s-=e.contentHeight-0,t+=` L ${n} ${s}`),t}function sl(e){let t=new Map;for(let[n,s]of e.pathVisits??[])for(let o of s){let r=`${o.path} ${n}`,a=t.get(r);a?a.push(o.strand):t.set(r,[o.strand])}return t}function rl(e){let t=new Map(e.nodes.map(r=>[r.id,r])),n=sl(e),s=(e.paths??[]).map((r,a)=>({path:r,index:a})),o=s.findIndex(r=>fe(r.path.name).name===e.referencePath);return o>0&&s.unshift(...s.splice(o,1)),s.flatMap(({path:r,index:a})=>{let l=fe(r.name).name,i=new Map,c=r.nodeIds.flatMap(d=>{let f=t.get(d);if(!f)return[];let h=i.get(f.name)??0;i.set(f.name,h+1);let p=n.get(`${l} ${f.name}`)?.[h]??xn(f);return[yn(f,p)]});return c.length>0?[{id:a,name:r.name,sequence:c,sourceTrackID:0,type:"haplotype"}]:[]})}function al(e){return e.nodes.map(t=>({name:t.id,seq:"",sequenceLength:Math.max(1,t.length)}))}function Ye(e){return(e.paths?.length??0)>0}var il=600,ll=3,cl=15;function fl(e){return Math.max(ll,Math.min(cl,Math.floor(il/Math.max(1,e))))}function Ts(e){let t=e.paths??[],n=rl(e),s=e.reads?rs(e,e.reads,t.length):[],o=s.length>0?po:uo,r=t.map((l,i)=>o(i,t.length)),a=Ns(al(e),n,s,{nodeWidthOption:"compressed",trackWidth:fl(n.length),trackColor:l=>l.type==="read"?as(l):r[l.id]});return a?{layout:a,pathColors:r}:void 0}function In(e){let t=[];return e.nodes.forEach(n=>{n.order>=0&&t.push(n)}),t}function Os(e,t,n,s){let o=e.y+e.contentHeight/2-t;return[{x:n,y:o},{x:s,y:o}]}function Ps(e,t){return{minY:e.bounds.minY-t,maxY:e.bounds.maxY-t}}function $s(e){let t=Ye(e)?Ts(e):void 0;if(!t)return;let{layout:n,pathColors:s}=t,o=n.bounds.minY,r={};for(let i of In(n))r[i.name]=Os(i,o,i.x,i.x+i.pixelWidth);let{minY:a,maxY:l}=Ps(n,o);return{nodePositions:r,tubeMap:{layout:n,yOffset:o,pathColors:s},extent:{minX:n.bounds.minX,maxX:n.bounds.maxX,minY:a,maxY:l}}}function dl(e,t){let n=new Map(e.nodes.map(l=>[l.id,l])),s=new Map;for(let l of In(t)){let i=s.get(l.order);i?i.push(l):s.set(l.order,[l])}let o=[],r=-1/0;for(let l of[...s.keys()].sort((i,c)=>i-c)){let i=s.get(l),c=1/0,d=-1/0;for(let f of i){let h=n.get(f.name);h&&$(h)&&(c=Math.min(c,h.stable.start),d=Math.max(d,h.stable.start+f.sequenceLength))}c===1/0&&(c=d=r),c<r&&(c=r,d=Math.max(r,d)),r=Math.max(r,d),o.push({order:l,x0:Math.min(...i.map(f=>f.x)),x1:Math.max(...i.map(f=>f.x+f.pixelWidth)),bp0:c,bp1:d})}let a=o.find(l=>l.bp0!==-1/0);for(let l of o)l.bp0===-1/0&&(l.bp0=l.bp1=a?.bp0??0);return o}function hl(e){return e.nodes.some($)&&Ye(e)}function ks(e){let t=hl(e)?Ts(e):void 0;if(!t)return;let{layout:n,pathColors:s}=t,o=dl(e,n),r=new Map(o.map(i=>[i.order,i])),a=n.bounds.minY,l={};for(let i of In(n)){let c=r.get(i.order);l[i.name]=Os(i,a,c.bp0,c.bp1)}return{nodePositions:l,tubeMap:{layout:n,yOffset:a,columns:o,pathColors:s},referenceAxis:!0,pixelRows:!0,extent:Ps(n,a)}}function ul(e){let t=new Set;for(let n of e.nodes)n.stable&&t.add(n.stable.rank);return new Map([...t].sort((n,s)=>n-s).map((n,s)=>[n,s]))}function Bs(e,t){let n=ye(e);if(n.length===0)return;let s=Je(n,t),o=ul(e),r=be(n),a=It({graph:e,span:s,rowY:i=>(i.stable?o.get(i.stable.rank)??o.size:o.size)*F,positions:r}),l=[...o].map(([i,c])=>({label:i===0?"Reference (rank 0)":`Rank ${i}`,y:c*F}));return{nodePositions:r,rowLabels:l,referenceAxis:!0,pixelRows:!0,alleleDeletions:a}}var pl=12,Cn=F;function Ds(e){return 10+8*Math.log2(1+e.length)}function ue(e,t){return e<t?-1:e>t?1:0}function qs(e,t){return ue(e.at,t.at)||ue(e.side,t.side)||ue(e.hops,t.hops)}var Fs={at:1/0,side:0,hops:0};function ml(e){let t=new Map(e.nodes.map(s=>[s.id,s])),n=yl(e);return e.nodes.map(s=>s.id).sort((s,o)=>qs(n.get(s)??Fs,n.get(o)??Fs)||ue(t.get(s).name,t.get(o).name)||ue(s,o))}function gl(e,t){let n=new Set(e.nodes.map(d=>d.id)),s=new Map(t.map(d=>[d.id,d.stable.start])),o=new Map,r=new Map;t.forEach((d,f)=>{r.set(d.id,t[f-1]?.id),o.set(d.id,t[f+1]?.id)});let a=t[0]?.id,l=(d,f)=>{let h=o.get(d);o.set(d,f),r.set(f,d),o.set(f,h),h!==void 0&&r.set(h,f)},i=(d,f)=>{let h=r.get(d);h===void 0?(a=f,r.set(f,void 0),o.set(f,d),r.set(d,f)):l(h,f)};for(let d of e.paths??[]){let f=0,h=0,p;for(let x of d.nodeIds){let w=s.get(x);w!==void 0&&(p!==void 0&&w!==p&&(w>p?f++:h++),p=w)}let u=h>f?[...d.nodeIds].reverse():d.nodeIds,m,g=new Set;for(let x of u)if(o.has(x)){if(m===void 0)for(let w of g)i(x,w);m=x}else n.has(x)&&(m===void 0?g.add(x):(l(m,x),m=x))}let c=[];for(let d=a;d!==void 0;d=o.get(d))c.push(d);return c}function xl(e,t){let n=[...t.entries()].sort(([a,l],[i,c])=>qs(l,c)||ue(a,i)).map(([a])=>a),s=n.length;for(let a of n){let l=t.get(a);for(let i of e.get(a)??[])t.has(i)||(t.set(i,{at:l.at,side:1,hops:l.hops+1}),n.push(i))}let o=new Set(n.slice(s)),r=new Set;for(let a of o){if(r.has(a))continue;let{at:l}=t.get(a),i=[a];r.add(a);let c=!0;for(let d of i){let{hops:f}=t.get(d),h=!0,p=!1;for(let u of e.get(d)??[]){let m=t.get(u);m.at===l&&o.has(u)?(h&&=m.hops<=f,r.has(u)||(r.add(u),i.push(u))):m.at!==l&&(p||=m.at<l,c&&=m.at<l)}c&&=!h||p}if(c)for(let d of i){let f=t.get(d);t.set(d,{...f,side:-1,hops:-f.hops})}}}function yl(e){let t=new Set(e.nodes.map(r=>r.id)),n=new Map;for(let r of e.edges)!t.has(r.from)||!t.has(r.to)||((n.get(r.from)??n.set(r.from,[]).get(r.from)).push(r.to),(n.get(r.to)??n.set(r.to,[]).get(r.to)).push(r.from));let s=e.nodes.filter($).sort((r,a)=>ue(r.stable.start,a.stable.start)||ue(r.name,a.name)),o=new Map;return gl(e,s).forEach((r,a)=>{o.set(r,{at:a,side:0,hops:0})}),xl(n,o),o}function bl(e){let t=new Map(e.nodes.map(f=>[f.id,f])),n=ml(e),s=new Map(n.map((f,h)=>[f,h])),o=f=>$(t.get(f)),r=new Map(n.map(f=>[f,[]])),a=new Map(n.map(f=>[f,[]])),l=(f,h)=>{r.get(h).push(f),a.get(f).push(h)};for(let f of e.edges)f.from===f.to||!s.has(f.from)||!s.has(f.to)||(s.get(f.from)<s.get(f.to)?l(f.from,f.to):l(f.to,f.from));let i=n.filter(o);for(let f=1;f<i.length;f++)l(i[f-1],i[f]);let c=new Map;for(let f of n){let h=0;for(let p of r.get(f))h=Math.max(h,c.get(p)+1);c.set(f,h)}for(let f=n.length-1;f>=0;f--){let h=n[f],p=a.get(h);if(o(h)||p.length===0)continue;let u=1/0;for(let x of p)u=Math.min(u,c.get(x));let m=c.get(h),g=Math.max(m,u-1);c.set(h,Math.floor((m+g)/2))}let d=[];for(let f of n)(d[c.get(f)]??=[]).push(f);return{layers:d,layerOf:c,preds:r}}function Xs(e){if(!e.nodes.some($))return;let t=new Map(e.nodes.map(f=>[f.id,f])),n=f=>$(t.get(f)),{layers:s,layerOf:o,preds:r}=bl(e),a=s.map(f=>{let h=0;for(let p of f)h=Math.max(h,Ds(t.get(p)));return h}),l=[],i=0;for(let f=0;f<s.length;f++)l[f]=i,i+=a[f]+pl;let c=new Map;for(let f of s){let h=[];for(let u of f){if(n(u)){c.set(u,0);continue}let m=r.get(u).filter(x=>c.has(x)),g=0;for(let x of m)g+=c.get(x)/m.length;h.push({id:u,ideal:g===0?Cn:g})}h.sort((u,m)=>u.ideal-m.ideal);let p=new Set([0]);for(let{id:u,ideal:m}of h){let g=Math.round(m/Cn);g===0&&(g=m>=0?1:-1);for(let x=1;p.has(g);x++)p.has(g+x)?p.has(g-x)||(g-=x):g+=x;p.add(g),c.set(u,g*Cn)}}let d={};for(let f of e.nodes){let h=o.get(f.id),p=Ds(f),u=l[h]+a[h]/2,m=c.get(f.id);d[f.id]=[{x:u-p/2,y:m},{x:u+p/2,y:m}]}return{nodePositions:d,referenceAxis:!1,pixelRows:!0}}function Ws(e){return e.sample??ut(e.name)}function wl(e){return e.haplotype!==void 0&&e.sample!==void 0?`${e.sample}#${e.haplotype}`:Ws(e)}function Ml(e,t){let n=[],s;for(let o of e){s!==void 0&&o.start!==void 0&&o.start>s&&n.push(o.start-s),n.push(...o.nodeIds);let r=o.nodeIds.reduce((a,l)=>a+(t.get(l)??0),0);s=o.start===void 0?void 0:o.start+r}return n}function vl(e,t){let n=[],s;for(let o of e){if(o.start===void 0||s!==void 0&&o.start<s)return;s!==void 0&&o.start>s&&n.push({start:s,end:o.start});let r=o.start;for(let a of o.nodeIds){let l=t.get(a)??0;n.push({start:r,end:r+l}),r+=l}s=r}return n}function El(e,t,n,s=!0){if(!n||!s)return{ids:e,complete:!0,from:-1,to:-1};let o=-1,r=-1,a=-1/0,l=1/0;if(e.forEach((c,d)=>{let f=typeof c=="string"?t.get(c):void 0;f&&(f.end<=n.start&&f.end>a&&(a=f.end,o=d),f.start>=n.end&&f.start<l&&(l=f.start,r=d))}),o<0||r<0)return{ids:e,complete:!1,from:-1,to:-1};let i=e.slice(Math.min(o,r)+1,Math.max(o,r));return{ids:o<r?i:i.reverse(),complete:!0,from:o,to:r}}function Fh(e,t){return t?e.filter(n=>t.includes(n.sample)).sort((n,s)=>t.indexOf(n.sample)-t.indexOf(s.sample)||n.label.localeCompare(s.label)):e}function Hs(e,t,n){let s=e.paths??[],o=g=>fe(g.name).name===e.referencePath,r=s.some(o)?s.filter(o).sort((g,x)=>(g.start??0)-(x.start??0)):s.slice(0,1),a=r[0],l=s.filter(g=>!r.includes(g));if(!a||l.length===0)return;let i=new Map;for(let g of l)i.set(g.name,[...i.get(g.name)??[],g]);let c=new Map(e.nodes.map(g=>[g.id,g.length])),d=a.start??0,f=t&&t.end>t.start?t:void 0,h=new Map;for(let g of r){let x=g.start??0;for(let w of g.nodeIds){let N=c.get(w)??0;h.has(w)||h.set(w,{start:x,end:x+N}),x+=N}}let p=f===void 0||[...h.values()].some(g=>g.end<=f.start)&&[...h.values()].some(g=>g.start>=f.end),u=g=>{let x=g[0],w=[...g].sort((G,j)=>(G.start??0)-(j.start??0)),{ids:N,complete:v,from:R,to:M}=El(Ml(w,c),h,f,p),S=vl(w,c),A=x.contig??pt(fe(x.name).name),P=S?.length?R<0?{contig:A,start:S[0].start,reversed:!1}:R<M?{contig:A,start:S[R].end,reversed:!1}:{contig:A,start:S[R].start,reversed:!0}:void 0,H=[],B=0,ae=0,_e=0,K=0;for(let G of N){if(typeof G=="number"){H.push({start:B,bp:G,onReference:!1,gap:!0}),B+=G,_e+=G,K=0;continue}let j=c.get(G)??0,z=h.get(G),U=H.at(-1),Ae=U?.referenceStart,Ue=z&&Ae!==void 0&&K>=0&&Ae+U.bp===z.start,T=z&&Ae!==void 0&&K<=0&&z.end===Ae;!z&&U&&!U.onReference&&!U.gap?U.bp+=j:Ue||T?(U.bp+=j,Ue||(U.referenceStart=z.start,U.reversed=!0),K=Ue?1:-1):(H.push({start:B,bp:j,onReference:z!==void 0,referenceStart:z?.start}),K=0),B+=j,z||(ae+=j)}return{name:x.name,label:wl(x),sample:Ws(x),haplotype:x.haplotype,bp:B,offReferenceBp:ae,gapBp:_e,complete:v,runs:H,axis:P}};return{origin:f?f.start:d,unit:n,reference:u(r),rows:[...i.values()].map(u).sort((g,x)=>Number(x.complete)-Number(g.complete)||x.bp-g.bp||g.label.localeCompare(x.label))}}var Rl=1.3;function Sl(e,t={rowPx:F,readouts:!0}){let n=e.reference.bp;for(let s of e.rows)n=Math.max(n,s.bp);return{maxX:e.origin+n*(t.readouts?Rl:1),maxY:e.rows.length*t.rowPx}}function Gh(e,t,n){return e?n&&!n.labelled?[]:[e.reference,...e.rows].map((s,o)=>({label:s.label,y:o*(n?.rowPx??F)})):t?.rowLabels??[]}function Gs(e,t){let n=ye(e),s=Hs(e,t);if(n.length===0||!s)return;let o=t?n.filter(l=>Vt(l,t)):n,r=be(o.length>0?o:n),a=[{label:s.reference.label,y:0},...s.rows.map((l,i)=>({label:l.label,y:(i+1)*F}))];return{nodePositions:r,rowLabels:a,referenceAxis:!0,pixelRows:!0,extent:Sl(s)}}var Ks="Force-directed layout",Ne=e=>e.nodes.some($),Ys=e=>Ne(e)&&(e.paths?.length??0)>1,zs=e=>Ne(e)&&Ye(e),Us=e=>Ne(e)&&e.nodes.some(Ze),$t=[{value:"auto",label:"Anchored",description:"x is reference bp, one row per stable rank. Needs rGFA tags or a reference path.",run:Bs,cutMargins:!0,wholeWalks:!1,available:Ne,drawsLocally:Ne,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:ls,cutMargins:!0,wholeWalks:!1,available:Us,drawsLocally:Us,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 W or P lines.",run:Gs,cutMargins:!1,wholeWalks:!0,available:Ys,drawsLocally:Ys,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:Xs,cutMargins:!1,wholeWalks:!1,available:Ne,drawsLocally:Ne,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:$s,cutMargins:!1,wholeWalks:!1,available:Ye,drawsLocally:Ye,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:ks,cutMargins:!0,wholeWalks:!1,available:zs,drawsLocally:zs,drawsNodes:!1},{value:"force",label:Ks,description:"OGDF FMMM, via the external Bandage engine.",run:()=>{},cutMargins:!1,wholeWalks:!1,available:()=>!0,drawsLocally:()=>!1,drawsNodes:!0}],Nl=$t.map(e=>e.value);function _l(e,t){return!js(e).drawsLocally(t)}function js(e){return $t.find(t=>t.value===e)??$t[0]}var kt=8,Tn=34,Bt=12,Al=60;function Ll({count:e,bounds:t,pixelRows:n,width:s,room:o,columns:r}){function a(i){let c=Math.ceil(e/i),d=Math.floor((s-(i-1)*kt)/i),f=(o-c*Tn-(c-1)*kt)/c,h=(d-2*Bt)/t.w,p=t.h>0?(f-2*Bt)/t.h:1/0,u=n?h:Math.min(h,p),m=n?t.h:t.h*u,g=Math.floor(Math.max(Al,Math.min(m+2*Bt,f)));return{columns:i,width:d,height:g,scale:u,total:c*(g+Tn)+(c-1)*kt}}if(r!==void 0)return a(Math.max(1,Math.min(e,Math.round(r))));let l=a(1);for(let i=2;i<=e;i++){let c=a(i);c.scale>l.scale&&(l=c)}return l}var Il=[{value:"",label:"None",description:"Every lifted walk in one drawing"},{value:"walk",label:"A panel per walk",description:"One panel per lifted walk, side by side"},{value:"sample",label:"A row per sample",description:"A row per sample, a column per haplotype"}];function Cl(e){let t=typeof e=="string"?{field:e}:e??{};return{field:t.field==="walk"||t.field==="sample"?t.field:"",domain:[...t.domain??[]],...t.columns===void 0?{}:{columns:t.columns}}}function Vs(e,t){let n=new Map(t.map((o,r)=>[o,r])),s=o=>n.get(o)??t.length;return e.map((o,r)=>({name:o,i:r})).sort((o,r)=>s(o.name)-s(r.name)||o.i-r.i).map(({name:o})=>o)}function Tl(e,t,n=[]){let s=Vs(e,n),o={columns:void 0,count:e.length,cells:e.map(c=>s.indexOf(c))};if(t==="walk")return o;let r=e.map(c=>{let[d,f,h]=c.split("#"),p=Number(f);return h!==void 0&&Number.isInteger(p)&&p>=0?{sample:d,column:Math.max(0,p-1)}:void 0}),a=Vs([...new Set(r.flatMap(c=>c?[c.sample]:[]))],n),l=Math.max(1,...r.map(c=>c?c.column+1:1)),i=r.map(c=>c?a.indexOf(c.sample)*l+c.column:-1);return i.includes(-1)||new Set(i).size<i.length?o:{columns:l,count:a.length*l,cells:i}}var Js=[{value:"progress",label:"Progress along the walk"},{value:"walk",label:"One colour for the walk"},{value:"reference",label:"Reference position"}],$n=[{value:"grey",label:"Grey to black",ends:["#a3a3a3","#151515"]},{value:"blue",label:"Cyan to navy",ends:["#6ee0f0","#0b2c7a"]},{value:"red",label:"Yellow to red",ends:["#ffd24a","#b3121b"]},{value:"purple",label:"Pink to plum",ends:["#f5a3d8","#5e1a6e"]},{value:"green",label:"Lime to forest",ends:["#b6e36c","#0b5d3b"]},{value:"rainbow",label:"Rainbow"}],Qs=["blue","red","purple","green"],Ol=e=>Js.some(t=>t.value===e),Pl=e=>$n.some(t=>t.value===e);function $l(e,t,n,s=!0){let{field:o,scheme:r}=e.color??{},a=Ol(o)?o:s?"progress":"walk",l=t?"grey":Qs[n%Qs.length],i=Pl(r)?r==="rainbow"&&a!=="reference"?l:r:l;return{field:a,scheme:i}}var er=.5,kl=e=>e<=.04045?e/12.92:((e+.055)/1.055)**2.4,Bl=e=>e<=.0031308?e*12.92:1.055*e**(1/2.4)-.055;function Zs(e){let[t,n,s]=[1,3,5].map(l=>kl(Number.parseInt(e.slice(l,l+2),16)/255)),o=Math.cbrt(.4122214708*t+.5363325363*n+.0514459929*s),r=Math.cbrt(.2119034982*t+.6806995451*n+.1073969566*s),a=Math.cbrt(.0883024619*t+.2817188376*n+.6299787005*s);return[.2104542553*o+.793617785*r-.0040720468*a,1.9779984951*o-2.428592205*r+.4505937099*a,.0259040371*o+.7827717662*r-.808675766*a]}function Dl([e,t,n]){let s=(e+.3963377774*t+.2158037573*n)**3,o=(e-.1055613458*t-.0638541728*n)**3,r=(e-.0894841775*t-1.291485548*n)**3;return[4.0767416621*s-3.3077115913*o+.2309699292*r,-1.2684380046*s+2.6097574011*o-.3413193965*r,-.0041960863*s-.7034186147*o+1.707614701*r].map(a=>Bl(Math.max(0,Math.min(1,a)))*255)}function kn(e,t){let n=Math.max(0,Math.min(1,t)),s=$n.find(a=>a.value===e);if(!s||!("ends"in s))return Ee(n*Re,.7,.5).map(a=>a*255);let o=Zs(s.ends[0]),r=Zs(s.ends[1]);return Dl(o.map((a,l)=>a+(r[l]-a)*n))}function On(e,t){let[n,s,o]=kn(e,t).map(Math.round);return`rgb(${n}, ${s}, ${o})`}function Pn(e,t){let[n,s,o]=kn(e,t).map(Math.round);return D(n,s,o,255)}function Fl({field:e,scheme:t},n){return e==="walk"?Pn(t,er):n===void 0?tr:Pn(t,n)}var tr=Rt;function nr({field:e,scheme:t}){return e==="walk"?[{offset:0,color:On(t,er)}]:Array.from({length:7},(n,s)=>({offset:s/6,color:On(t,s/6)}))}function ql(e){let t=nr(e);return t.length===1?t[0].color:`linear-gradient(to right, ${t.map(n=>`${n.color} ${n.offset*100}%`).join(", ")})`}var rr=ke(sr(),1),Dt=16;function zu(e){let[t="",...n]=e.split(/\r\n|\r|\n/),s=t.split(" ").slice(1),o=new Map;for(let r of n){if(!r)continue;let[a="",...l]=r.split(" ");a&&!o.has(a)&&o.set(a,{...Object.fromEntries(s.map((i,c)=>[i,l[c]??""])),name:a})}return[...o.values()]}function Uu(e){let t=new Set;for(let n of e??[])for(let s of Object.keys(n))s!=="name"&&t.add(s);return[...t]}function Ku(e){if(typeof e=="string")return e?{field:e}:void 0;let{field:t,domain:n}=e??{};if(!(typeof t!="string"||!t))return Array.isArray(n)?{field:t,domain:n.filter(s=>typeof s=="string")}:{field:t}}function Xl(e){let t=new Set(e.map(n=>n.label)).size;return`${t} haplotype${t===1?"":"s"}`}function ju(e,t,{field:n,domain:s}){let o=new Map(t.map(i=>[i.name,i[n]??""])),r=new Map;for(let i of e){let c=o.get(i.label)||o.get(i.sample)||"",d=r.get(c);d?d.push(i):r.set(c,[i])}let a=1,l=[...r.keys()].sort((0,rr.groupKeyComparator)(s)).map(i=>{let c=r.get(i),d={key:i,title:`${i||`${n}: none`} \xB7 ${Xl(c)}`,first:a,count:c.length};return a+=c.length,d});return{rows:l.flatMap(i=>r.get(i.key)),sections:l}}function Vu(e,t){let n=o=>{let r=-1;for(;r+1<e.length&&e[r+1].first<=o;)r++;return r},s=o=>o*t+(n(o)+1)*Dt;return{rowY:s,headers:e.map((o,r)=>({...o,top:(o.first-.5)*t+r*Dt})),headersPx:e.length*Dt,rowAt(o,r){let a=0;for(let l=-1;l<e.length;l++){let i=l<0?0:e[l].first,c=l<0?Math.min(r,e[0]?.first??r):i+e[l].count,d=(l+1)*Dt,f=Math.min(c-1,Math.max(i,Math.round((o-d)/t)));Math.abs(s(f)-o)<Math.abs(s(a)-o)&&(a=f)}return a}}}var Wl=10;function Hl(e,t){let n=e.end-e.start,s=e.longestAlleleLength-e.shortestAlleleLength;return t.find(o=>s<=Wl*(o.end-o.start)&&(n===0?o.start<=e.start&&e.start<=o.end:Math.min(e.end,o.end)-Math.max(e.start,o.start)>=n/2))}var Gl=40;function pe(e){return e>=1e4?`${(e/1e3).toFixed(0)} kb`:e>=1e3?`${(e/1e3).toFixed(1)} kb`:`${e} bp`}function Yl(e,t){let n=pe(e),s=pe(t),o=s.slice(s.indexOf(" "));return n.endsWith(o)?`${n.slice(0,-o.length)}\u2013${s}`:`${n}\u2013${s}`}function ar(e){return e>=go?"\u22652.1B routes":e>=1e5?`${(e/1e3).toFixed(0)}k routes`:`${e} routes`}function zl(e,t=[]){let n=Ul(e,t);return e.partial?{...n,label:`${n.label}, partial`}:n}function Ul(e,t){let n=e.end-e.start,{shortestAlleleLength:s,longestAlleleLength:o,pathCount:r,segmentCount:a,inversion:l}=e,i=Yl(s,o);if(a>=Gl)return{kind:"superbubble",label:`${i} superbubble, ${a} segments, ${ar(r)}${l?", inv":""}`};if(l)return{kind:"inversion",label:`${pe(o)} inv`};let c=o!==s?Hl(e,t):void 0;if(c){let f=c.name?` (${c.name})`:"";return{kind:"repeat",label:`${i} repeat array${f}, ${ar(r)}`}}let d=r>2?`, ${r} alleles`:"";return s===o&&s===n?n<=1?{kind:"snp",label:"SNP"}:{kind:"substitution",label:`${pe(n)} sub`}:n===0||s===n?{kind:"insertion",label:`\u2264${pe(o-n)} ins${d}`}:o===n?{kind:"deletion",label:`${pe(n-s)} del${d}`}:{kind:"complex",label:`${pe(n)} ref \u2192 ${i}, ${r} alleles`}}var Kl={snp:"#5b6b7a",substitution:"#5b6b7a",insertion:"#2f8fd6",deletion:"#c94040",inversion:"#e07b00",repeat:"#8e3fbf",superbubble:"#8e3fbf",complex:"#8e3fbf"},jl={snp:"SNP",substitution:"substitution",insertion:"insertion",deletion:"deletion",inversion:"inversion",repeat:"repeat array",superbubble:"superbubble",complex:"site"};function Vl(e){return e.segments.split(",").filter(Boolean)}var Dn="#2f8fd6",Fn="#8e3fbf",qn="#bdbdbd",at="#1c1c22",Xn=12,Wn=4,Ft=12,Ql=6,Zl=3;function ze(e){return`${(e/1e3).toFixed(e<1e4?1:0)} kb`}function ir(e,t){return t?` \u2248 ${Math.round(e/t)} units`:""}function lr(e,t,n,s){let{bp:o,gapBp:r,complete:a}=e;if(!t)return`${ze(o)}${ir(o,n)}`;let l=o-t.bp,i=l===0?"":` (${l>0?"+":"\u2212"}${ze(Math.abs(l))})`,c=r>0?` \xB7 ${ze(r)} outside the cut`:"",d=s?` \xB7 called ${ze(s.bp)}${s.spanningReads===0?" \xB7 no spanning read":""}`:"";return`${ze(o)}${ir(o,n)}${i}${c}${a?"":" \xB7 partial walk"}${d}`}function cr(e,t,n){let s=t+6;return s+e.length*we<n?{x:s,anchor:"start",halo:!1}:{x:t-6,anchor:"end",halo:!0}}function fr(e,t,n){if(t*n<Zl)return[];let s=[];for(let o=t;o<e;o+=t)s.push(o);return s}function dr(e,t){if(e.gap)return{fill:qn};if(!t)return{fill:e.onReference?Dn:Fn};if(e.referenceStart===void 0)return{fill:St};let n=To({...e,start:e.referenceStart},t);return n.length===1?{fill:At(n[0])}:{stops:n.map(At)}}function it(e,t,n){return e.reversed?{start:e.start-n,end:e.start-t}:{start:t-e.start,end:n-e.start}}function Jl(e,t){return e.reversed?{start:e.start-t,end:e.start}:{start:e.start,end:e.start+t}}function ec(e,t){let n=new Map;for(let s of e){let o=t.get(s.name);if(!s.axis||!o)continue;let r=s.axis,a=({start:l,end:i})=>({start:Math.max(0,l),end:Math.min(s.bp,i)});n.set(s.name,o.map(l=>({name:l.name,...a(it(r,l.start,l.end)),exons:l.exons.map(i=>a(it(r,i.start,i.end))).filter(i=>i.end>i.start)})).filter(l=>l.end>l.start).sort((l,i)=>l.start-i.start))}return n}var tc=9,nc=5.2,oc=8,hr=(e,t)=>Math.min(2,(e-t)/2-1);function qt(e,t){return hr(e,t)>=1}function ur(e,t,n,{rowPx:s=F,barPx:o=Xn}={}){if(!qt(s,o))return[];let r=hr(s,o),a=e.map(c=>{let d=t(c.start);return{g:c,x:d,w:Math.max(2,t(c.end)-d)}}),l=[],i=new Set((o>=oc?[...a]:[]).sort((c,d)=>c.w-d.w).filter(({g:c,x:d,w:f})=>{let h=c.name.length*nc/2,p=[d+f/2-h,d+f/2+h];return 2*h>f+6||l.some(([u,m])=>p[0]<m+2&&p[1]>u-2)?!1:(l.push(p),!0)}));return a.map(c=>({name:c.g.name,x:c.x,y:n-o/2-r,w:c.w,h:o+2*r,exons:c.g.exons.map(d=>({x:t(d.start),w:Math.max(1,t(d.end)-t(d.start))})),label:i.has(c)?{x:c.x+c.w/2,y:n+3,size:tc}:void 0}))}var Bn=e=>`${e} row${e===1?"":"s"}`;function sc(e,t={}){let n=[{swatch:t.ramp?{kind:"bar",fill:t.rampCss??Oo,ramp:!0}:{kind:"bar",fill:Dn},label:`on ${e.reference.label}'s path`},{swatch:{kind:"bar",fill:t.ramp?St:Fn},label:`off ${e.reference.label}'s path`}];return[e.reference,...e.rows].some(s=>s.gapBp>0)&&n.push({swatch:{kind:"gap",fill:qn},label:"walked outside the cut"}),t.genes?.crowded?n.push({swatch:{kind:"gene"},label:"genes left out: too many rows to box them in",note:!0}):t.genes&&(n.push({swatch:{kind:"gene"},label:"genes, each row's own annotation"}),t.genes.untracked&&n.push({swatch:{kind:"gene"},label:`no gene track for ${Bn(t.genes.untracked)}`,note:!0}),t.genes.unplaced&&n.push({swatch:{kind:"gene"},label:`no contig coordinates for ${Bn(t.genes.unplaced)}`,note:!0}),t.genes.unread&&n.push({swatch:{kind:"gene"},label:`genes not read for the last ${Bn(t.genes.unread)}`,note:!0})),n}var pr="#111",mr="#9e9e9e",Hn="#c62828";function gr(e){return e.agrees===!1?Hn:e.spanningReads===0?mr:pr}function rc(e,t,n,s="walk-key"){let o=0,r=e.flatMap((a,l)=>{let i=`${s}-ramp-${l}`,c=!a.note&&a.swatch.kind==="bar"&&a.swatch.ramp?L("linearGradient",{id:i},...un.map(h=>L("stop",{offset:h.offset,"stop-color":h.color}))):void 0,d=a.note?void 0:a.swatch.kind==="gene"?L("rect",{x:o,y:5,width:18,height:8,fill:"none",stroke:at,"stroke-width":1.5}):L("rect",{x:o,y:a.swatch.kind==="gap"?7:5,width:18,height:a.swatch.kind==="gap"?Wn:8,rx:2,fill:c?`url(#${i})`:a.swatch.fill}),f=L("text",{x:a.note?o:o+23,y:13,"font-style":a.note?"italic":void 0,fill:a.note?"#666":void 0},a.label);return o+=(a.note?0:23)+a.label.length*we+16,[c,d,f].filter(h=>h!==void 0)});return{width:o,tree:L("g",{transform:`translate(${t} ${n})`,"font-family":"Helvetica, Arial, sans-serif","font-size":11},...r)}}function Gn(e,t,n=0){let s=t/Math.max(1,e),o=Math.max(n,Math.min(F,s>=1?Math.floor(s):s));return{rowPx:o,barPx:o<=3?o:Math.max(3,Math.round(o*.6)),labelled:o>=Ft,readouts:o>=Ft}}function xr(e,t){let n=1/t,s=[],o=[],r=()=>{if(o.length!==0){if(o.length===1)s.push(o[0]);else{let l=0,i=0;for(let f of o)f.onReference?l+=f.bp:i+=f.bp;let c=l>=i,d=o.find(f=>f.onReference===c);s.push({start:o[0].start,bp:l+i,onReference:c,referenceStart:c?d.referenceStart:void 0,...d.reversed?{reversed:!0}:{}})}o=[]}},a=0;for(let l of e){if(l.gap||l.bp>=n){r(),a=0,s.push(l);continue}o.push(l),a+=l.bp,a>=n&&(r(),a=0)}return r(),s}function ac(e,t,n){return L("g",{class:"row-gene","data-testid":"graph-walk-gene"},L("title",{},e.name),...e.exons.map(s=>L("rect",{x:s.x,y:t-n/2,width:s.w,height:n,fill:at,opacity:.35})),L("rect",{x:e.x,y:e.y,width:e.w,height:e.h,fill:"none",stroke:at,"stroke-width":1.5}),e.label&&L("text",{x:e.label.x,y:e.label.y,"font-family":"sans-serif","font-size":e.label.size,"font-weight":600,"text-anchor":"middle",fill:at,stroke:"white","stroke-width":2.5,"paint-order":"stroke"},e.name))}function ic(e,t,n={}){let s=m=>m*t.scaleX+t.translateX,o=t.rowPx??F,r=t.barPx??Xn,a=Math.min(3,Math.max(0,(o-r)/2)),l=m=>m*o*t.scaleY+t.translateY,{origin:i,unit:c,reference:d,rows:f}=e,h=m=>s(i+m),p=n.idPrefix??"walkrow",u=(m,g)=>{let x=l(g);if(x<-r||x>t.height+r)return;let w=xr(m.runs,t.scaleX).flatMap(A=>{let P=dr(A,n.ramp),H=A.gap?Math.min(Wn,r):r,B=`${p}-${g}-${A.start}`,ae=L("rect",{x:h(A.start),y:x-H/2,width:Math.max(1,A.bp*t.scaleX),height:H,fill:"stops"in P?`url(#${B})`:P.fill});return"stops"in P?[L("linearGradient",{id:B},...P.stops.map((_e,K)=>L("stop",{offset:K/(P.stops.length-1),"stop-color":_e}))),ae]:[ae]}),N=c&&r>=Ql?fr(m.bp,c,t.scaleX).map(A=>L("line",{x1:h(A),x2:h(A),y1:x-r/2,y2:x+r/2,stroke:"white","stroke-width":1})):[],{call:v}=m,R=lr(m,g===0?void 0:d,c,v),M=cr(R,h(m.bp),t.width),S=t.readouts??!0;return L("g",{"data-testid":g===0?"graph-walk-reference":"graph-walk-row"},...w,...N,...ur(n.rowGenes?.get(m.name)??[],h,x,{rowPx:o,barPx:r}).map(A=>ac(A,x,r)),v&&L("rect",{"data-testid":"graph-walk-call",x:h(v.bp)-1,y:x-r/2-a,width:2,height:r+2*a,fill:gr(v)}),S&&L("text",{x:M.x,y:x+4,"font-family":"sans-serif","font-size":11,fill:v?.agrees===!1?Hn:"#333",stroke:M.halo?"white":void 0,"stroke-width":M.halo?3:void 0,"paint-order":"stroke","text-anchor":M.anchor},R))};return L("g",{},...[d,...f].map(u))}function lc(e){return e.walkStrip&&e.mode.drawsNodes&&!e.drawsPicture&&!e.popped&&!e.host&&e.walks>1}function cc(e,t){return e.wholeWalks||t.walkStrip&&!t.host}var lt=6,wr=260,fc=11,dc=3,hc=1.3,uc="#111",yr=3;function pc(e,t,n){let s=e.pathVisits?.get(n.name)??[],o=[];for(let r of t){let a=r.axis;if(!a)continue;let l=fe(r.name).name;for(let i of s){if(i.path!==l)continue;let{start:c,end:d}=it(a,i.start,i.start+n.length);d>0&&c<r.bp&&o.push({row:r.name,start:c,bp:d-c})}}return o}var br=new WeakMap;function mc(e,t){let n=br.get(e);if(n||(n=new Map,br.set(e,n)),n.has(t))return n.get(t);let s=new Map(e.nodes.map(a=>[a.id,a.length])),o=(e.paths??[]).filter(a=>a.name===t),r;if(o.every(a=>a.start!==void 0)){r={ids:[],starts:[],ends:[]};for(let a of[...o].sort((l,i)=>l.start-i.start)){let l=a.start;for(let i of a.nodeIds){let c=s.get(i)??0;r.ids.push(i),r.starts.push(l),r.ends.push(l+c),l+=c}}}return n.set(t,r),r}function gc(e,t,n,s){let o=t.axis,r=o&&mc(e,t.name);if(!o||!r||n<0||n>t.bp)return;let a=o.reversed?o.start-n:o.start+n,l=.5/s,i=o.reversed?{start:o.start-t.bp,end:o.start}:{start:o.start,end:o.start+t.bp},c=Math.max(a-l,i.start),d=Math.min(a+l,i.end),f=0,h=r.starts.length;for(;f<h;){let g=f+h>>1;r.ends[g]<=c?f=g+1:h=g}let p,u=-1,m=!1;for(let g=f;g<r.starts.length&&r.starts[g]<d;g++){let x=r.ends[g]-r.starts[g],w=r.starts[g]<=a&&a<r.ends[g];(x>u||x===u&&w&&!m)&&(u=x,p=r.ids[g],m=w)}return p}function xc(e,t){let n=t.maxHeight??wr,s=t.labelPx??Math.max(...[e.reference,...e.rows].map(p=>p.label.length))*we+16,o=e.rows.length+1,{rowPx:r,barPx:a,labelled:l,readouts:i}=Gn(o,n-2*lt,dc),c=Math.max(e.reference.bp,...e.rows.map(p=>p.bp),1),d=l?s:lt,h=Math.max(1,t.width-d-lt)/(c*(i?hc:1));return{scaleX:h,scaleY:1,translateX:d-e.origin*h,translateY:lt+r/2,width:t.width,height:o*r+2*lt,rowPx:r,barPx:a,readouts:i,labelled:l,boxesGenes:qt(r,a)}}function yc(e,t,n,s){let o=Math.round((s-t.translateY)/t.rowPx),r=[e.reference,...e.rows][o],a=(n-t.translateX)/t.scaleX-e.origin;return r&&o>=0&&a>=0&&a<=r.bp?{index:o,row:r,offset:a}:void 0}function bc(e,t,n){let s=new Map([e.reference,...e.rows].map((r,a)=>[r.name,a])),o=r=>(e.origin+r)*t.scaleX+t.translateX;return L("g",{"data-testid":"graph-walk-marks"},...n.flatMap(r=>{let a=s.get(r.row);if(a===void 0)return[];let l=a*t.rowPx+t.translateY,i=o(r.start),c=Math.max(2,r.bp*t.scaleX),d=f=>L("rect",{x:i,y:f,width:c,height:yr,fill:uc});return[d(l-t.barPx/2-yr-1),d(l+t.barPx/2+1)]}))}function wc(e,t,n=new Set){return L("g",{"font-family":"sans-serif","font-size":fc,fill:"#333"},...(t.labelled?[e.reference,...e.rows]:[]).map((s,o)=>L("text",{x:6,y:o*t.rowPx+t.translateY+4,"font-weight":n.has(s.name)?600:void 0},s.label)))}function Mc(e,t,n){if(t?.size)return e.boxesGenes?n:{untracked:0,unread:0,...n,crowded:!0}}var Er=2,Xt=8192;function Rr(){return typeof devicePixelRatio>"u"?1:Math.min(devicePixelRatio,Er)}var Mr=!1;function vr(e,t,n){let s=Math.round(e*t);return s>Xt?(Mr||(Mr=!0,console.warn(`Canvas ${n} ${s}px exceeds the safe limit ${Xt}px and was clamped`)),Xt):s}function Yn(e,t,n){let s=Rr(),o=vr(t,s,"width"),r=vr(n,s,"height");(e.width!==o||e.height!==r)&&(e.width=o,e.height=r);let a=`${t}px`,l=`${n}px`;e.style.width!==a&&(e.style.width=a),e.style.height!==l&&(e.style.height=l)}var Bp=class{constructor(e){this.transform=null,this.batch=null,this.nodeHighlights=new Map,this.highlightedEdge=null,this.highlightFactor=1;let t=e.getContext("2d");if(!t)throw new Error("Canvas 2D context not available");this.canvas=e,this.ctx=t}setErrorHandler(e){}releaseOffscreenTargets(){}resize(e,t){Yn(this.canvas,e,t)}uploadGeometry(e){this.batch=e,this.highlightedEdge=null}setNodeHighlights(e){this.nodeHighlights=e}setEdgeHighlight(e,t){this.highlightedEdge=e,this.highlightFactor=t}updateTransform(e){this.transform=e}render(e){if(!this.transform)return;let n=this.ctx,{width:s,height:o}=n.canvas;e[3]<1&&n.clearRect(0,0,s,o),n.fillStyle=bo([e[0],e[1],e[2]],e[3]),n.fillRect(0,0,s,o);let r=this.batch;r&&(n.lineCap="round",n.lineJoin="round",this.renderEdges(r),this.renderNodes(r),this.renderArrows(r))}renderEdges(e){let t=this.transform,n=this.ctx,s=this.highlightedEdge===null?void 0:e.edgeCurveRuns.get(this.highlightedEdge);for(let{color:o,items:r}of zn(e.edgeCurves,(a,l)=>({color:Wt(s,l)?wt(a.color,this.highlightFactor):a.color,weight:a.thickness,last:Wt(s,l)}))){n.strokeStyle=oe(o),n.lineWidth=r[0].thickness*2*t.dpr,n.beginPath();for(let a of r){let l=a.curves[0];n.moveTo(l.x0*t.scaleX+t.translateX,l.y0*t.scaleY+t.translateY);for(let i of a.curves)n.bezierCurveTo(i.cx0*t.scaleX+t.translateX,i.cy0*t.scaleY+t.translateY,i.cx1*t.scaleX+t.translateX,i.cy1*t.scaleY+t.translateY,i.x1*t.scaleX+t.translateX,i.y1*t.scaleY+t.translateY)}n.stroke()}}renderNodes(e){let t=this.transform,n=this.ctx,s=new Map;for(let[o,r]of this.nodeHighlights){let a=e.nodeStrokeRuns.get(o);if(a)for(let l=a.start;l<a.start+a.count;l++)s.set(l,r)}for(let{color:o,items:r}of zn(e.nodeStrokes,(a,l)=>{let i=s.get(l);return{color:i===void 0?a.color:wt(a.color,i),weight:a.thickness,last:i!==void 0}})){n.strokeStyle=oe(o),n.lineWidth=r[0].thickness*2*t.dpr,n.beginPath();for(let a of r){let l=a.points[0];n.moveTo(l.x*t.scaleX+t.translateX,l.y*t.scaleY+t.translateY);for(let i=1,c=a.points.length;i<c;i++){let d=a.points[i];n.lineTo(d.x*t.scaleX+t.translateX,d.y*t.scaleY+t.translateY)}}n.stroke()}}renderArrows(e){let t=this.transform,n=this.ctx,s=this.highlightedEdge===null?void 0:e.arrowRuns.get(this.highlightedEdge);for(let{color:o,items:r}of zn(e.arrows,(a,l)=>({color:Wt(s,l)?wt(a.color,this.highlightFactor):a.color,weight:0,last:Wt(s,l)}))){n.fillStyle=oe(o),n.beginPath();for(let a of r){let[l,i,c,d]=Ec(a,t);n.moveTo(l.x,l.y),n.lineTo(i.x,i.y),n.lineTo(c.x,c.y),n.lineTo(d.x,d.y),n.closePath()}n.fill()}}dispose(){this.batch=null,this.nodeHighlights=new Map,this.highlightedEdge=null}},vc=.25;function Ec(e,t){let n=Math.cos(e.angle),s=Math.sin(e.angle),o=e.x*t.scaleX+t.translateX,r=e.y*t.scaleY+t.translateY,a=e.length*t.dpr,l=e.halfWidth*t.dpr,i=o-n*a,c=r-s*a,d=a*(1-vc);return[{x:o,y:r},{x:i-s*l,y:c+n*l},{x:o-n*d,y:r-s*d},{x:i+s*l,y:c-n*l}]}function Wt(e,t){return e!==void 0&&t>=e.start&&t<e.start+e.count}function zn(e,t){let n=new Map,s=new Map;for(let o=0,r=e.length;o<r;o++){let a=e[o],{color:l,weight:i,last:c}=t(a,o),d=c?s:n,f=`${l}:${i}`,h=d.get(f);h?h.items.push(a):d.set(f,{color:l,items:[a]})}return[...n.values(),...s.values()]}function Un(e,t,n){let s=Math.round(t),o=Math.round(n);return`${e?`${e}:`:""}${Fe(s)}-${Fe(o)} (${ce(o-s)})`}function Rc(e,t){let{field:n}=e.encoding,s=e.range?Un(e.range.contig,e.range.start,e.range.end):void 0,o=n==="progress"?s:n==="reference"&&t?Un(t.name,t.start,t.end):void 0,r=e.range?e.range.end-e.range.start:e.bp,a=r-e.bp;return{delta:e.referenceBp===void 0||r===e.referenceBp?"":` ${r>e.referenceBp?"+":"\u2212"}${ce(Math.abs(r-e.referenceBp))}`,outside:a>0?`, ${ce(a)} outside the cut`:"",reversed:e.reversedBp>0?`, ${ce(e.reversedBp)} reversed`:"",shades:n!=="walk",scale:o,hover:o===s?void 0:s}}function Sc(e,t,n){let s=e.progress.get(t),o=e.range;if(s===void 0||!o)return;let r=Math.round(o.start+s*(o.end-o.start)-n/2);return`${o.contig}:${Fe(r)}-${Fe(r+n)}`}function Nc(e,t){let n=new Map(e.nodes.map(o=>[o.id,o])),s=new Map;t.nodes.forEach(o=>{let r=n.get(o.name);if(o.order>=0&&r&&$(r)){let{refName:a,start:l}=r.stable;(s.get(a)??s.set(a,[]).get(a)).push({bp0:l,bp1:l+o.sequenceLength,x0:o.x,x1:o.x+o.pixelWidth})}});for(let o of s.values())o.sort((r,a)=>r.bp0-a.bp0);return s}function Ht(e,t,n=!1){let s=0,o=e.length-1;for(;s<o;){let l=s+o>>1,i=e[l].bp1;(n?i<t:i<=t)?s=l+1:o=l}let r=e[s];if(t<=r.bp0)return r.x0;let a=r.bp1-r.bp0;return a>0?r.x0+(Math.min(t,r.bp1)-r.bp0)/a*(r.x1-r.x0):r.x0}function Gt(e,t,n){let s=Ht(e,t),o=Ht(e,n,!0);return{x0:Math.min(s,o),x1:Math.max(s,o)}}function _c(e){let t;for(let n of e.values())(!t||n.length>t.length)&&(t=n);return t}var Sr=5,Ac=10,Lc=110,Ic=3;function Nr(e){return e?"#b0b0b8":"#55555c"}function Cc(e){let t=10**Math.floor(Math.log10(e)),n=e/t;return(n<=1?1:n<=2?2:n<=5?5:10)*t}function _r(e){let t=[];for(let n of e)t.every(s=>Math.abs(n.at-s.at)>=(n.width+s.width)/2+Ac)&&t.push(n);return t.map(({text:n,at:s})=>({text:n,at:s}))}function Tc(e,t,n,s){let o=e[0],r=e.at(-1);if(!o||!r)return;let a=t(o.x0),l=t(r.x1),i=r.bp1-o.bp0;if(l<=a||i<=0)return;let c=Cc(i/(l-a)*Lc),d=[],f=[];for(let h=Math.ceil(o.bp0/c)*c;h<=r.bp1;h+=c){let p=Math.round(t(Ht(e,h)))+.5;if(p>=0&&p<=n){d.push(p);let u=h.toLocaleString("en-US");f.push({text:u,at:p,width:s(u)})}}return{spans:[{x0:a,x1:l}],ticks:d,labels:_r(f)}}function Oc(e,t,n,s){let o=e.map(u=>({box:u,s0:t(u.x0),s1:t(u.x1)})).filter(({s0:u,s1:m})=>m>=0&&u<=n),r=o[0],a=o.at(-1);if(!r||!a)return;let l=(u,m)=>({text:u,at:m,width:s(u)}),i=(u,m)=>l(u.toLocaleString("en-US"),m),c=[],d=[],f=[],h=[];for(let{box:u,s0:m,s1:g}of o){c.push({x0:m,x1:g}),d.push(Math.round(m)+.5),g-m>=Ic&&d.push(Math.round(g)+.5);let x=l(ce(u.bp1-u.bp0),(m+g)/2);x.width<=g-m&&f.push(x),u!==r.box&&h.push(i(u.bp0,m))}let p=[i(r.box.bp0,r.s0),i(a.box.bp1,a.s1)];return{spans:c,ticks:d,labels:_r([...p,...f,...h])}}function Ar(e,t,n,s,o=!1){return(o?Tc:Oc)(e,t,n,s)}function Pc(e,t,n,s,o=!1){let{x:r,width:a,darkMode:l}=n;e.font="10px sans-serif";let i=Ar(t,r,a,f=>e.measureText(f).width,o);if(!i)return;let c=Nr(l),d=s+.5;e.strokeStyle=c,e.fillStyle=c,e.lineWidth=1,e.textAlign="center",e.textBaseline="top",e.beginPath();for(let{x0:f,x1:h}of i.spans)e.moveTo(Math.max(0,f),d),e.lineTo(Math.min(a,h),d);for(let f of i.ticks)e.moveTo(f,s),e.lineTo(f,s+Sr);e.stroke();for(let{text:f,at:h}of i.labels)e.fillText(f,h,s+Sr+2)}function $c(e,t){let n=new Map(e.nodes.map(o=>[o.id,o])),s=[];return t.nodes.forEach(o=>{let r=n.get(o.name);o.order>=0&&r&&$(r)&&s.push({node:o.name,bp0:r.stable.start,bp1:r.stable.start+o.sequenceLength,x0:o.x,x1:o.x+o.pixelWidth})}),s}function kc(e,t,n,s){let o=[];for(let r of e){let a=n(r.x0),l=n(r.x1);l>=0&&a<=s&&o.push({node:r.node,top0:t(r.bp0),top1:t(r.bp1),bottom0:a,bottom1:l})}return o}var Bc=3;function Dc(e,t,n,s){if(t<=0||s<0||s>t)return;let o=s/t,r,a=Bc;for(let l of e){let i=l.top0+(l.bottom0-l.top0)*o,c=l.top1+(l.bottom1-l.top1)*o,d=Math.max(0,Math.min(i,c)-n,n-Math.max(i,c));d<a&&(a=d,r=l.node)}return r}function Lr(e,t,n){e.moveTo(t.top0,0),e.lineTo(t.top1,0),e.lineTo(t.bottom1,n),e.lineTo(t.bottom0,n),e.closePath()}function Ir(e,t,n){e.moveTo(t.top0,0),e.lineTo(t.bottom0,n),e.moveTo(t.top1,0),e.lineTo(t.bottom1,n)}function Fc(e,t,n,{highlightNode:s,darkMode:o}){if(n<=0||t.length===0)return;let r=o?"255,255,255":"0,0,0";e.beginPath();for(let l of t)Lr(e,l,n);e.fillStyle=`rgba(${r},0.07)`,e.fill(),e.beginPath();for(let l of t)Ir(e,l,n);e.strokeStyle=`rgba(${r},0.35)`,e.lineWidth=.5,e.stroke();let a=t.find(l=>l.node===s);a&&(e.beginPath(),Lr(e,a,n),e.fillStyle="rgba(255,192,203,0.5)",e.fill(),e.beginPath(),Ir(e,a,n),e.strokeStyle="#ff0000",e.lineWidth=1,e.stroke())}function qc(e,t){let n=[],s=e.sequenceNew??[];return s.forEach((o,r)=>{let a=t.nodeMap.get(O(o.nodeName)),l=a===void 0?void 0:t.nodes[a],i=r;for(;i<e.path.length&&e.path[i].node!==a;)i+=1;let c=e.path[i]?.y;if(l&&c!==void 0){let d={readId:e.id,y:c,height:e.width,nodeY:l.y},f=h=>Ls(l,h);for(let h of o.mismatches){let p=f(h.pos);if(p!==null){if(h.type==="insertion"){let u=r===0&&h.pos===e.firstNodeOffset||r===s.length-1&&h.pos===e.finalNodeCoverLength;n.push({...d,kind:"insertion",x:p,seq:h.seq,softClip:u})}else if(h.type==="deletion"&&h.length!==void 0){let u=f(h.pos+h.length);u!==null&&n.push({...d,kind:"deletion",x0:p,x1:u})}else if(h.type==="substitution"&&h.seq!==void 0){let u=f(h.pos+h.seq.length);u!==null&&n.push({...d,kind:"substitution",x0:p,x1:u,seq:h.seq})}}}}}),n}function Cr(e){return e.reads.flatMap(t=>qc(t,e))}function jn(e){let t=e.trim().split(/[\s,]+/),n=[],s=0,o=()=>Number(t[s++]);for(;s<t.length;){let r=t[s++];r==="M"||r==="L"?n.push({op:r,x:o(),y:o()}):r==="H"?n.push({op:r,x:o()}):r==="V"?n.push({op:r,y:o()}):r==="Q"?n.push({op:r,x1:o(),y1:o(),x:o(),y:o()}):r==="C"?n.push({op:r,x1:o(),y1:o(),x2:o(),y2:o(),x:o(),y:o()}):r==="Z"&&n.push({op:r})}return n}function kr(e){let t=1/0,n=-1/0;for(let s of e)"x"in s&&(t=Math.min(t,s.x),n=Math.max(n,s.x)),"x1"in s&&(t=Math.min(t,s.x1),n=Math.max(n,s.x1));return{x0:t,x1:n}}function Tr(e,t,n,s){let o=jn(e);return{commands:o,color:t,track:s,alpha:n,...kr(o)}}function Or(e,t){let{shapes:n}=e,s=l=>t==="haplotype"?l.id:void 0,o=[...n.rectangles,...n.verticalRectangles].filter(l=>l.type===t).map(l=>({color:l.color,track:s(l),alpha:l.alpha??1,x0:l.xStart,x1:l.xEnd+1,y0:l.yStart,y1:l.yEnd+1})),r=Is(n.curves,t).map(l=>Tr(l.path,l.color,l.alpha??1,s(l))),a=n.corners.filter(l=>l.type===t).map(l=>Tr(l.path,l.color,1,s(l)));return{rects:o,shapes:[...r,...a]}}function Xc(e){let t=[];return e.nodes.forEach(n=>{if(n.order>=0){let s=jn(Cs(n));t.push({name:n.name,commands:s,...kr(s)})}}),{bounds:e.bounds,layers:[Or(e,"haplotype"),Or(e,"read")],nodes:t,mismatches:Cr(e).filter(n=>n.kind!=="insertion"||!n.softClip)}}function Pr(e,t,n,s){let o=0,r=0;for(let a of t)switch(a.op){case"M":o=a.x,r=a.y,e.moveTo(n(o),s(r));break;case"L":o=a.x,r=a.y,e.lineTo(n(o),s(r));break;case"H":o=a.x,e.lineTo(n(o),s(r));break;case"V":r=a.y,e.lineTo(n(o),s(r));break;case"Q":o=a.x,r=a.y,e.quadraticCurveTo(n(a.x1),s(a.y1),n(o),s(r));break;case"C":o=a.x,r=a.y,e.bezierCurveTo(n(a.x1),s(a.y1),n(a.x2),s(a.y2),n(o),s(r));break;case"Z":e.closePath();break}}function $r(e,t,n,s,o){let r=new Map;for(let a of t)if(n(a)){let l=`${s(a)}|${a.alpha}`,i=r.get(l);i?i.push(a):r.set(l,[a])}for(let a of r.values()){e.fillStyle=s(a[0]),e.globalAlpha=a[0].alpha,e.beginPath();for(let l of a)o(l);e.fill()}e.globalAlpha=1}var Wc=12,Hc=.15;function Gc(e){return Math.max(Hc,Math.min(1,e/Wc))}var Yc=.55;function zc(e,t,n){let{x:s,y:o,width:r}=n,a=d=>s(d.x1)>=0&&s(d.x0)<=r,l=d=>d.track!==void 0&&n.tubeColors?.[d.track]||d.color;for(let d of t.layers)$r(e,d.rects,a,l,f=>{let h=s(f.x0),p=o(f.y0);e.rect(h,p,s(f.x1)-h,o(f.y1)-p)}),$r(e,d.shapes,a,l,f=>{Pr(e,f.commands,s,o)});let i=n.darkMode?"#d0d0d0":"#000000",c=n.darkMode?"rgba(40,40,40,0.4)":"rgba(255,255,255,0.4)";e.lineWidth=2*Math.max(.25,Math.min(1,n.yScale));for(let d of t.nodes)if(a(d)){let f=d.name===n.highlightNode;e.beginPath(),Pr(e,d.commands,s,o);let h=f?void 0:n.nodeColors?.get(d.name);e.fillStyle=f?"rgba(255,192,203,0.5)":h??c,e.strokeStyle=f?"#ff0000":i,e.globalAlpha=h?Yc:1,e.fill(),e.globalAlpha=f?1:Gc(s(d.x1)-s(d.x0)),e.stroke(),e.globalAlpha=1}Kc(e,t.mismatches,n)}var Br=12,Uc=6;function Dr(e){return Br*e>=Uc}function Kn(e,{x:t,width:n}){let[s,o]=e.kind==="insertion"?[e.x,e.x]:[e.x0,e.x1];return t(o)>=0&&t(s)<=n}function Kc(e,t,n){let{x:s,y:o,yScale:r,darkMode:a}=n;if(!Dr(r)||t.length===0)return;let l=Br*r;e.fillStyle="grey",e.beginPath();for(let i of t)if(i.kind==="deletion"&&Kn(i,n)){let c=s(i.x0),d=o(i.y);e.rect(c,d,s(i.x1)-c,o(i.y+i.height)-d)}e.fill(),e.font=`${l}px monospace`,e.textBaseline="alphabetic",e.fillStyle=a?"#ffffff":"#000000";for(let i of t)Kn(i,n)&&(i.kind==="substitution"?e.fillText(i.seq,s(i.x0)+1,o(i.y+i.height)):i.kind==="insertion"&&e.fillText("*",s(i.x)-3,o(i.y+i.height)))}function jc(e,t){let n=[];for(let s of t){let o=e.get(s.refName),r=o?.[0],a=o?.at(-1);if(!o||!r||!a)continue;let l=Math.max(s.start,r.bp0),i=Math.min(s.end,a.bp1);i<=l||n.push({gene:s,...Gt(o,l,i),exons:s.exons.filter(c=>c.end>l&&c.start<i).map(c=>Gt(o,Math.max(c.start,l),Math.min(c.end,i)))})}return n}var Vn=22,Vc=4,Yt=8,Qc="11px sans-serif",Zc=8;function Jc(e){let t=e.flatMap(o=>[{x:o.x0,step:1},{x:o.x1,step:-1}]).sort((o,r)=>o.x-r.x||o.step-r.step),n=0,s=0;for(let{step:o}of t)n+=o,s=Math.max(s,n);return Math.min(Vc,s)}function ef(e,t,n,s,o=0){let{x:r,width:a,darkMode:l}=n,i=Math.max(1,Math.floor((s-o)/Vn)),c=[],d=l?"#e0e0e6":"#1c1c22";e.font=Qc,e.textAlign="center",e.textBaseline="alphabetic",e.fillStyle=d,e.strokeStyle=d,e.lineWidth=1;let f=t.map(h=>({g:h,s0:r(h.x0),s1:r(h.x1)})).filter(({s0:h,s1:p})=>p>=0&&h<=a).sort((h,p)=>h.s0-p.s0);for(let{g:h,s0:p,s1:u}of f){let m=h.gene.strand>0?" \u2192":h.gene.strand<0?"\u2190 ":"",g=h.gene.strand<0?`${m}${h.gene.name}`:`${h.gene.name}${m}`,x=(Math.max(p,0)+Math.min(u,a))/2,w=e.measureText(g).width/2,N=Math.min(p,x-w),v=Math.max(u,x+w),R=c.findIndex(S=>S+Zc<=N);R===-1&&(R=Math.min(c.length,i-1)),c[R]=Math.max(c[R]??-1/0,v);let M=s-R*Vn-Yt/2;e.beginPath(),e.moveTo(p,M+.5),e.lineTo(u,M+.5),e.stroke();for(let S of h.exons){let A=r(S.x0);e.fillRect(A,M-Yt/2,Math.max(1,r(S.x1)-A),Yt)}e.fillText(g,x,M-Yt/2-2)}}var re=12,Hr=re+8,Gr=8,Fr=Gr+3,tf=12;function nf(e,{colorScheme:t,referenceRamp:n,walks:s}){let o={...Nt(e),referenceRamp:n},r=[];return e.nodes.forEach((a,l)=>{if($(a)){let i=s?s.map(c=>{let d=c.colors.get(a.id);return d===void 0?Et:oe(d)}):[oe(_t(a,l,t,o))];r.push({node:a.id,bp0:a.stable.start,bp1:a.stable.start+a.length,colors:i,faded:i.includes(Et)})}}),r.sort((a,l)=>a.bp0-l.bp0)}function Qn(e,t,n){let s=t*e.scale+e.translateX,o=n*e.scale+e.translateX;return s<o?[s,o]:[o,s]}var qr=2;function Yr(e,t,n){let s=-t.translateX/t.scale,o=(n-t.translateX)/t.scale,r=Math.min(s,o),a=Math.max(s,o),l=0,i=0;for(let c of e)l+=Math.max(0,Math.min(c.bp1,r)-c.bp0),i+=Math.max(0,c.bp1-Math.max(c.bp0,a));return t.scale>=0?{left:Math.round(l),right:Math.round(i)}:{left:Math.round(i),right:Math.round(l)}}function of(e,t,n,s){if(s<0||s>re+qr)return;let o,r=qr;for(let a of e){let[l,i]=Qn(t,a.bp0,a.bp1),c=Math.max(0,l-n,n-i);c<=r&&(r=c,o=a.node)}return o}function sf(e,t){let n=e?.[Math.floor(e.length/2)];return n?t(n):void 0}function zr(e,t,n,s){let o=e.map(c=>{let[d,f]=Qn(t,c.bp0,c.bp1),h=Math.round(d*s);return{colors:c.colors,x0:d,px0:h,px1:Math.max(Math.round(f*s),h+1)}}).filter(c=>c.px1>0&&c.px0<n*s).sort((c,d)=>c.x0-d.x0),r=[],a=-1/0,l=[-1/0,-1/0];for(let{colors:c,px0:d,px1:f}of o){let h=Math.max(d,a);if(f>h){let p=l[0]<h?0:1;l[p]=f,r.push({colors:c,x0:h/s,x1:f/s,tier:p}),a=f}}return(r.length>0?r.at(-1).x1-r[0].x0:0)>=r.length*tf?r:r.map(({tier:c,...d})=>d)}function Xr(e,t,n,s){let o=n>0?t:t-Fr;e.clearRect(o,0,Fr,re);let r=t+n,a=r+n*Gr;e.beginPath(),e.moveTo(r,re/2),e.lineTo(a,0),e.lineTo(a,re),e.closePath(),e.fillStyle=s,e.fill()}function Wr(e,t,n){return Math.round(e*re*n/t)/n}function rf(e,t,n,{width:s,lit:o,darkMode:r,dpr:a=1}){let l=r?"#ffffff":"#18181c";e.clearRect(0,0,s,Hr);for(let c of zr(t,n,s,a)){let{tier:d}=c,f=d!==void 0&&c.colors.length===1,h=f?2:c.colors.length;c.colors.forEach((p,u)=>{let m=f?d:u,g=Wr(m,h,a);e.fillStyle=p,e.fillRect(c.x0,g,c.x1-c.x0,Wr(m+1,h,a)-g)})}let i=Yr(t,n,s);if(i.left>0&&Xr(e,0,1,l),i.right>0&&Xr(e,s,-1,l),o){let[c,d]=Qn(n,o.start,o.end),f=Math.max(d-c,3),h=(c+d)/2-f/2;e.strokeStyle=l,e.lineWidth=1.5,e.strokeRect(h,.75,f,re-1.5),o.anchor&&(e.beginPath(),e.moveTo(h+f/2,re),e.lineTo(o.anchor.x,o.anchor.y),e.lineWidth=1,e.stroke())}}function af(e,t){let n=new Map(e.nodes.map(o=>[o.id,o])),s=[];return t.nodes.forEach((o,r)=>{let a=n.get(o.name);if(o.order>=0&&a&&$(a)){let l=a.stable.start;s.push({bp0:l,bp1:l+o.sequenceLength,index:r,node:o})}}),s.sort((o,r)=>o.bp0-r.bp0)}function lf(e,t,n){let s=0,o=e.length-1;for(;s<o;){let r=s+o+1>>1;e[r].bp0<=t?s=r:o=r-1}return[e[s],e[s-1]].find(r=>r&&n.has(r.index)&&r.bp0<=t&&t<=r.bp1)}function Rg(e,t,n){let s=af(e,t),o=[];for(let r of t.tracks){let a=r.name?n.get(r.name):void 0;if(a?.length){let l=new Map;for(let i of r.path)i.node!==null&&i.y!==void 0&&!l.has(i.node)&&l.set(i.node,i.y);for(let i of a){let c=lf(s,i.start,l);if(c){let{node:d,bp0:f,bp1:h}=c,p=u=>d.x+(Math.min(u,h)-f)/(h-f)*d.pixelWidth;o.push({x0:p(i.start),x1:p(i.end),y:l.get(c.index),height:r.width})}}}}return o}function cf(e){return e?"rgba(255,255,255,0.9)":"rgba(0,0,0,0.8)"}function Sg(e,t,{x:n,y:s,width:o,darkMode:r}){if(t.length!==0){e.fillStyle=cf(r),e.beginPath();for(let a of t){let l=n(a.x0),i=Math.max(n(a.x1),l+1);if(i>=0&&l<=o){let c=s(a.y);e.rect(l,c,i-l,s(a.y+a.height)-c)}}e.fill()}}function ff(e,t){return Math.abs(t-e)<=.1*Math.max(e,t)}function df(e,t){let n=e.length,s=t.length,o=Array.from({length:n+1},()=>new Array(s+1).fill(0)),r=Array.from({length:n+1},()=>new Array(s+1).fill(!1));for(let l=n-1;l>=0;l--)for(let i=s-1;i>=0;i--){let c=Math.abs(e[l]-t[i])+o[l+1][i+1],d=n-l>s-i?o[l+1][i]:1/0,f=s-i>n-l?o[l][i+1]:1/0;o[l][i]=Math.min(c,d,f),r[l][i]=o[l][i]===c}let a=new Array(n).fill(void 0);for(let l=0,i=0;l<n&&i<s;)r[l][i]?a[l++]=i++:n-l>s-i?l++:i++;return a}function Ur(e,t){return e.map((n,s)=>({item:n,i:s})).sort((n,s)=>t(n.item)-t(s.item))}var jr=e=>e.spanningReads!==0;function Kr(e,t){return{...t,agrees:e.complete&&jr(t)?ff(e.bp,t.bp):void 0}}function hf(e,t){let n=new Map,s=new Set;e.forEach((l,i)=>{let c=t.find(d=>d.haplotype!==void 0&&d.haplotype===l.haplotype);c&&(s.add(c),n.set(i,Kr(l,c)))});let o=t.filter(l=>l.haplotype===void 0),r=Ur(e,l=>l.bp),a=[[r.filter(l=>l.item.complete),o.filter(jr)],[r,o]];for(let[l,i]of a){let c=l.filter(f=>!n.has(f.i)),d=Ur(i.filter(f=>!s.has(f)),f=>f.bp);df(c.map(f=>f.item.bp),d.map(f=>f.item.bp)).forEach((f,h)=>{if(f!==void 0){let p=c[h],u=d[f].item;s.add(u),n.set(p.i,Kr(p.item,u))}})}return n}function _g(e,t){if(!t)return e;let n=new Map,s=new Map;for(let o of e)s.set(o.sample,[...s.get(o.sample)??[],o]);for(let[o,r]of s){let a=t[o];if(a)for(let[l,i]of hf(r,a))n.set(r[l],i)}return e.map(o=>({...o,call:n.get(o)}))}var Vr=ke(ht(),1),Ig=(0,ne.createSvgIcon)((0,Vr.jsx)("path",{d:"M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6"}),"Settings");export{ne as a,oi as b,nt as c,ea as d,xn as e,ai as f,ii as g,sl as h,ml as i,Fh as j,Hs as k,Sl as l,Gh as m,$t as n,Nl as o,_l as p,js as q,kt as r,Tn as s,Bt as t,Ll as u,Il as v,Cl as w,Tl as x,oe as y,Et as z,St as A,Ra as B,Nt as C,_t as D,La as E,Js as F,$n as G,$l as H,Fl as I,tr as J,nr as K,ql as L,Dt as M,zu as N,Uu as O,Ku as P,ju as Q,Vu as R,pe as S,zl as T,Kl as U,jl as V,Vl as W,Oo as X,Ta as Y,at as Z,Xn as _,Wn as $,lr as aa,Jl as ba,ec as ca,qt as da,sc as ea,pr as fa,mr as ga,Hn as ha,rc as ia,Gn as ja,ic as ka,lc as la,cc as ma,pc as na,gc as oa,xc as pa,yc as qa,bc as ra,wc as sa,Mc as ta,Rr as ua,Bp as va,Oa as wa,Tf as xa,Of as ya,Un as za,Rc as Aa,Sc as Ba,Wf as Ca,zo as Da,Hf as Ea,Uo as Fa,pn as Ga,Ko as Ha,jo as Ia,Va as Ja,Nc as Ka,_c as La,Nr as Ma,Pc as Na,$c as Oa,kc as Pa,Dc as Qa,Fc as Ra,Xc as Sa,zc as Ta,Dr as Ua,Kn as Va,jc as Wa,Vn as Xa,Jc as Ya,ef as Za,Hr as _a,nf as $a,Yr as ab,of as bb,sf as cb,rf as db,Rg as eb,cf as fb,Sg as gb,_g as hb,Dd as ib,Fd as jb,Ja as kb,qd as lb,Xd as mb,mn as nb,gn as ob,Jd as pb,eh as qb,Ig as rb};
2
- //# sourceMappingURL=chunk-LZUNK4MQ.js.map