jbrowse-plugin-graphgenomeviewer 6.2.0 → 6.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/dist/chunks/ChooseWalksDialog-L6QKOT7M.js +2 -0
- package/dist/chunks/ChooseWalksDialog-L6QKOT7M.js.map +7 -0
- package/dist/chunks/{GbzBaseSyntenyAdapter-TLI5IUU7.js → GbzBaseSyntenyAdapter-KVJKGGQ4.js} +2 -2
- package/dist/chunks/{GbzBaseSyntenyAdapter-TLI5IUU7.js.map → GbzBaseSyntenyAdapter-KVJKGGQ4.js.map} +1 -1
- package/dist/chunks/{GraphGenomeView-5OPCROMQ.js → GraphGenomeView-VIKLXNQD.js} +2 -2
- package/dist/chunks/{GraphGenomeView-5OPCROMQ.js.map → GraphGenomeView-VIKLXNQD.js.map} +1 -1
- package/dist/chunks/GraphTrackSettingsDialog-MRMSH2FO.js +4 -0
- package/dist/chunks/{GraphTrackSettingsDialog-FGLLUIEE.js.map → GraphTrackSettingsDialog-MRMSH2FO.js.map} +1 -1
- package/dist/chunks/HighlightColorDialog-SABW5OMB.js +2 -0
- package/dist/chunks/HighlightColorDialog-SABW5OMB.js.map +7 -0
- package/dist/chunks/LinearGraphDisplay-AHCKWNFJ.js +2 -0
- package/dist/chunks/{LinearGraphDisplay-NBJHGOYX.js.map → LinearGraphDisplay-AHCKWNFJ.js.map} +1 -1
- package/dist/chunks/{MinigraphBubbleAdapter-LQUIL3MD.js → MinigraphBubbleAdapter-CAXB5FGR.js} +2 -2
- package/dist/chunks/{RgfaTabixAdapter-3BFNY4SB.js → RgfaTabixAdapter-GYRNCGT2.js} +2 -2
- package/dist/chunks/{bandage-layout-3AR6BCUD-I6CCWYSR.js → bandage-layout-3AR6BCUD-PYYNJEGI.js} +1 -1
- package/dist/chunks/{bandage-layout-3AR6BCUD-I6CCWYSR.js.map → bandage-layout-3AR6BCUD-PYYNJEGI.js.map} +1 -1
- package/dist/chunks/{chunk-O5EHYU3Y.js → chunk-2SIR336R.js} +2 -2
- package/dist/chunks/chunk-2SL675KP.js +3 -0
- package/dist/chunks/{chunk-NGQRKSHY.js.map → chunk-2SL675KP.js.map} +3 -3
- package/dist/chunks/chunk-A6GKF63C.js +2 -0
- package/dist/chunks/{chunk-ZKLOV6MW.js.map → chunk-A6GKF63C.js.map} +2 -2
- package/dist/chunks/chunk-B7GF3TC3.js +2 -0
- package/dist/chunks/chunk-B7GF3TC3.js.map +7 -0
- package/dist/chunks/chunk-B7KMMGFB.js +2 -0
- package/dist/chunks/chunk-B7KMMGFB.js.map +7 -0
- package/dist/chunks/{chunk-X24J6VF4.js → chunk-DILFGQIL.js} +1 -1
- package/dist/chunks/{chunk-X24J6VF4.js.map → chunk-DILFGQIL.js.map} +1 -1
- package/dist/chunks/{chunk-7MWOPEIC.js → chunk-EHV7EUMI.js} +1 -1
- package/dist/chunks/{chunk-7MWOPEIC.js.map → chunk-EHV7EUMI.js.map} +1 -1
- package/dist/chunks/chunk-GMSOU6VO.js +2 -0
- package/dist/chunks/chunk-GMSOU6VO.js.map +7 -0
- package/dist/chunks/{chunk-EKMGHBWM.js → chunk-KRXALLQG.js} +1 -1
- package/dist/chunks/{chunk-EKMGHBWM.js.map → chunk-KRXALLQG.js.map} +1 -1
- package/dist/chunks/{chunk-F7V6ZPKD.js → chunk-MYJYGSOH.js} +1 -1
- package/dist/chunks/{chunk-F7V6ZPKD.js.map → chunk-MYJYGSOH.js.map} +1 -1
- package/dist/chunks/chunk-WTOQRUK2.js +2 -0
- package/dist/chunks/chunk-WTOQRUK2.js.map +7 -0
- package/dist/chunks/{chunk-JYZAMHIP.js → chunk-WUGRVNUJ.js} +2 -2
- package/dist/chunks/{chunk-JYZAMHIP.js.map → chunk-WUGRVNUJ.js.map} +1 -1
- package/dist/jbrowse-plugin-graphgenomeviewer.esm.js +6 -6
- package/dist/jbrowse-plugin-graphgenomeviewer.esm.js.map +4 -4
- package/package.json +2 -3
- package/src/GbzBaseSyntenyAdapter/configSchema.ts +1 -1
- package/src/GraphGenomeView/components/ChooseWalksDialog.tsx +6 -7
- package/src/GraphGenomeView/components/HighlightColorDialog.tsx +117 -0
- package/src/GraphGenomeView/components/TubeMapOverlay.tsx +1 -1
- package/src/GraphGenomeView/model.test.ts +107 -31
- package/src/GraphGenomeView/pane/fitViews.ts +8 -5
- package/src/GraphGenomeView/pane/graphViews.ts +11 -1
- package/src/GraphGenomeView/pane/hostViews.ts +1 -1
- package/src/GraphGenomeView/pane/keepInView.ts +62 -0
- package/src/GraphGenomeView/pane/launchActions.ts +159 -184
- package/src/GraphGenomeView/pane/loadActions.ts +3 -0
- package/src/GraphGenomeView/pane/paneBase.ts +9 -3
- package/src/GraphGenomeView/pane/renderingActions.ts +11 -1
- package/src/GraphGenomeView/pane/settingActions.ts +38 -0
- package/src/GraphGenomeView/renderPipeline.test.ts +4 -1
- package/src/GraphGenomeView/renderer/GraphRenderer.ts +2 -2
- package/src/GraphGenomeView/viewModel.ts +1 -1
- package/src/LinearGraphDisplay/LinearGraphDisplay.test.ts +12 -5
- package/src/LinearGraphDisplay/configSchema.ts +8 -0
- package/src/LinearGraphDisplay/model.ts +39 -33
- package/src/hoverSync/GraphNodeHighlight.tsx +3 -3
- package/src/version.ts +1 -1
- package/dist/chunks/ChooseWalksDialog-GVQLSGHX.js +0 -2
- package/dist/chunks/ChooseWalksDialog-GVQLSGHX.js.map +0 -7
- package/dist/chunks/GraphTrackSettingsDialog-FGLLUIEE.js +0 -4
- package/dist/chunks/LinearGraphDisplay-NBJHGOYX.js +0 -2
- package/dist/chunks/chunk-LZUNK4MQ.js +0 -2
- package/dist/chunks/chunk-LZUNK4MQ.js.map +0 -7
- package/dist/chunks/chunk-NGQRKSHY.js +0 -3
- package/dist/chunks/chunk-XWGKHQYO.js +0 -2
- package/dist/chunks/chunk-XWGKHQYO.js.map +0 -7
- package/dist/chunks/chunk-ZKLOV6MW.js +0 -2
- /package/dist/chunks/{MinigraphBubbleAdapter-LQUIL3MD.js.map → MinigraphBubbleAdapter-CAXB5FGR.js.map} +0 -0
- /package/dist/chunks/{RgfaTabixAdapter-3BFNY4SB.js.map → RgfaTabixAdapter-GYRNCGT2.js.map} +0 -0
- /package/dist/chunks/{chunk-O5EHYU3Y.js.map → chunk-2SIR336R.js.map} +0 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as xe,c as K,d as Bt,e as Me,f as Dt,g as ve,h as Ee,i as Se,k as Ue,l as Ke}from"./chunk-WTOQRUK2.js";import{A as Ge,B as ze,C as we,D as q,P as Pt,Q as Xt,a as _,b as At,c as U,d as It,e as Tt,f as be,h as Ct,j as $t,l as Ye,m as ye,x as He,y as J,z as D}from"./chunk-B7GF3TC3.js";import{d as qt}from"./chunk-KRXALLQG.js";import{c as Ot}from"./chunk-EHV7EUMI.js";import{a as ge,b as Z,c as L,d as se,e as G,f as We,g as z,j as ae}from"./chunk-MYJYGSOH.js";import{a as he,c as kt,d as me}from"./chunk-DILFGQIL.js";import{a as pe}from"./chunk-TYJTJGPO.js";import{a as Fe,b as Q}from"./chunk-FY3BTKY4.js";var Wt=Fe((oc,Ft)=>{Ft.exports=JBrowseExports["@mui/material/SvgIcon"]});var Xr=Fe((ql,gn)=>{gn.exports=JBrowseExports.mobx});var mo=Fe((ld,ho)=>{ho.exports=JBrowseExports["@jbrowse/core/util/groupKeys"]});var P=Q(Wt(),1);function Re(e){return`hsl(${e}, 70%, 50%)`}function je(e,t){let n=(e-t.start)/(t.end-t.start);return Math.max(0,Math.min(1,n))*Ee}var fr=30;function Yt({start:e,bp:t,reversed:n},s){let o=je(e,s),r=je(e+t,s);if(r-o<1)return[(o+r)/2];let i=Math.ceil((r-o)/fr);return Array.from({length:i+1},(a,c)=>je(e+t*(n?i-c:c)/i,s))}var Ve=Array.from({length:7},(e,t)=>({offset:t/6,color:Re(t/6*Ee)})),Ht=`linear-gradient(to right, ${Ve.map(e=>`${e.color} ${e.offset*100}%`).join(", ")})`;function R(e,t={},...n){return{tag:e,attrs:t,children:n.filter(s=>!!s||s==="")}}function Gt(e){return e.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">")}function dr(e){return Gt(e).replaceAll('"',""")}function ur(e){if(typeof e=="string")return Gt(e);let t=Object.entries(e.attrs).filter(([,n])=>n!==void 0).map(([n,s])=>` ${n}="${dr(String(s))}"`).join("");return`<${e.tag}${t}>${e.children.map(ur).join("")}</${e.tag}>`}var pr="#daa520",hr=1,mr=2,gr=4;function lc(e,t,n,s=o=>o){let o=r=>{let i=t(r)*2;return n?.nodeIds.has(r)?Math.max(i,n.walks.length*gr):i};return e.flatMap(r=>r.exonsByNode.map(({nodeId:i,d:a})=>({key:`${r.gene.name}-${r.gene.start}-${i}`,d:s(a),inner:o(i)+2*hr})))}function fc(e,t){if(e.length===0)return;let n=(s,o,r)=>R("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 R("g",{},R("mask",{id:t.id,maskUnits:"userSpaceOnUse",x:0,y:0,width:t.width,height:t.height},R("g",{transform:t.transform},...e.map(s=>n(s,"#fff",s.inner+2*mr)),...e.map(s=>n(s,"#000",s.inner)))),R("rect",{width:t.width,height:t.height,fill:pr,mask:`url(#${t.id})`}))}var xr=50;function zt(e,t){return t>0?Math.max(1,e/t):xr}function br(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 yr(e,t,n){let s=zt(t,e.length);return{x:s,y:n>0?zt(n,e.length):br(e)??s}}function Ut(e,t,n,s){return e===void 0?yr(t,n,s):typeof e=="number"?{x:e,y:e}:e}function wr(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 Kt(e,t,n,s,o,r,i){let a=Math.floor(n/t.x),c=Math.floor(o/t.x),l=Math.floor(s/t.y),d=Math.floor(r/t.y);for(let f=a;f<=c;f++)for(let u=l;u<=d;u++)wr(e,f,u).push(i)}function jt(e,t,n,s,o,r){let i=Math.floor((n-o)/t.x),a=Math.floor((n+o)/t.x),c=Math.floor((s-r)/t.y),l=Math.floor((s+r)/t.y),d=[],f=new Set;for(let u=i;u<=a;u++){let m=e.get(u);if(m)for(let h=c;h<=l;h++){let p=m.get(h);if(p)for(let g of p)f.has(g)||(f.add(g),d.push(g))}}return d}var Vt=class{constructor(e,t){this.cells=new Map;let n=[],s=0,o=0;for(let[r,i]of Object.entries(e))for(let a=0;a<i.length-1;a++){let c=i[a],l=i[a+1],d=Math.min(c.x,l.x),f=Math.min(c.y,l.y),u=Math.max(c.x,l.x),m=Math.max(c.y,l.y);s+=u-d,o+=m-f,n.push({entry:{nodeId:r,segmentIdx:a},minX:d,minY:f,maxX:u,maxY:m})}this.cellSize=Ut(t,n,s,o);for(let r of n)Kt(this.cells,this.cellSize,r.minX,r.minY,r.maxX,r.maxY,r.entry)}query(e,t,n,s=n){return jt(this.cells,this.cellSize,e,t,n,s)}},Qt=class{constructor(e,t,n,s,o,r,i=0,a,c=!1){this.cells=new Map,this.edgeCurves=Dt(e,t,s,r,i,a,c);let l=[],d=0,f=0;for(let u=0;u<t.edges.length;u++){let m=t.edges[u],h=e[m.from],p=e[m.to],g=this.edgeCurves.get(u);if(h?.length&&p?.length&&g){let{minX:x,minY:b,maxX:M,maxY:w}=Ct(g),v=m.pathIds?.length??0;if(n&&v>0){let y=0,E=0;for(let S of ye(h,p,v,s))y=Math.max(y,Math.abs(S.x)),E=Math.max(E,Math.abs(S.y));x-=y,b-=E,M+=y,w+=E}d+=M-x,f+=w-b,l.push({ei:u,minX:x,minY:b,maxX:M,maxY:w})}}this.cellSize=Ut(o,l,d,f);for(let u of l)Kt(this.cells,this.cellSize,u.minX,u.minY,u.maxX,u.maxY,u.ei)}getCurves(e){return this.edgeCurves.get(e)}query(e,t,n,s=n){return jt(this.cells,this.cellSize,e,t,n,s)}};function tn(e,t,n,s,o,r){let i=o-n,a=r-s,c=i*i+a*a;if(c===0)return Math.hypot(e-n,t-s);let l=Math.max(0,Math.min(1,((e-n)*i+(t-s)*a)/c));return Math.hypot(e-(n+l*i),t-(s+l*a))}function Mr(e,t,n,s,o,r,i,a,c,l){let d=1/0,f=20,u=n,m=s;for(let h=1;h<=f;h++){let p=h/f,g=1-p,x=g*g*g*n+3*g*g*p*o+3*g*p*p*i+p*p*p*c,b=g*g*g*s+3*g*g*p*r+3*g*p*p*a+p*p*p*l;d=Math.min(d,tn(e,t,u,m,x,b)),u=x,m=b}return d}function vr(e,t,n){return Mr(e,t,n.x0,n.y0,n.cx0,n.cy0,n.cx1,n.cy1,n.x1,n.y1)}function Zt(e,t,n,s=1){let o=1/0;for(let r of n){let i=vr(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});i<o&&(o=i)}return o}var Jt=new WeakMap;function nn(e,t){let n=Jt.get(e);if(n?.version===t)return n.index;let s=new Vt(e);return Jt.set(e,{version:t,index:s}),s}var en=new WeakMap;function Er(e,t,n,s,o,r,i,a=!1){let c=en.get(e);if(c?.graph===t&&c.drawPaths===n&&c.scaleX===s.scaleX&&c.scaleY===s.scaleY&&c.version===o&&c.deletions===r&&c.routes===i&&c.stranded===a)return c.index;let l=new Qt(e,t,n,s,void 0,r,o,i,a);return en.set(e,{graph:t,drawPaths:n,scaleX:s.scaleX,scaleY:s.scaleY,version:o,index:l,deletions:r,routes:i,stranded:a}),l}var Sr=5;function yc(e,t,n,s,o=0,r){let i=Ye(s),a=nn(e,o),c=m=>Math.max(Sr,m)/s.scaleX,l=c(r?.maxHalfWidthPx??0),d=a.query(t,n,l,l/i),f=null,u=1/0;for(let{nodeId:m,segmentIdx:h}of d){let p=e[m],g=tn(t,n*i,p[h].x,p[h].y*i,p[h+1].x,p[h+1].y*i);g<u&&g<c(r?.halfWidthPx(m)??0)&&(u=g,f=m)}return f}function Rr(e,t,n){let s=t.x-e.x,o=t.y-e.y,r=0,i=1;for(let[a,c]of[[-s,e.x-n.x0],[s,n.x1-e.x],[-o,e.y-n.y0],[o,n.y1-e.y]])if(a===0){if(c<0)return!1}else a<0?r=Math.max(r,c/a):i=Math.min(i,c/a);return r<=i}function on(e,t,n=0){let s=nn(e,n),o=r=>({x:r.x*t.scaleX+t.translateX,y:r.y*t.scaleY+t.translateY});return r=>{let i=new Set,a=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:c,segmentIdx:l}of a){let d=e[c];!i.has(c)&&Rr(o(d[l]),o(d[l+1]),r)&&i.add(c)}return i}}function wc(e,t,n,s,o,r,i=0,a,c,l,d=!1){let f=Ye(o),u=10/o.scaleX,m=Er(e,t,r,o,i,a,l,d),h=m.query(n,s,u,u/f),p=null,g=u;for(let x of h){let b=t.edges[x],M=e[b.from],w=e[b.to];if(!M?.length||!w?.length||c?.has(x))continue;let v=b.pathIds?.length??0,y=m.getCurves(x);if(!y)continue;let E;if(!r||v===0)E=Zt(n,s*f,y,f);else{let S=1/0;for(let N of ye(M,w,v,o)){let T=N.x===0&&N.y===0?y:$t(y,N.x,N.y),A=Zt(n,s*f,T,f);A<S&&(S=A)}E=S}E<g&&(g=E,p=x)}return p}var rn=3.4,Qe=6,Nr=8,Lr=18,_r=2,kr=At+It;function sn(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 an(e,t,n,s){let o=n/2;return cn(e,r=>r.gene.end-r.gene.start).map(r=>{let{x:i,y:a}=t(r.at),c=sn(r);return{item:r,x:i,y:a+n+Lr,text:c?`${r.gene.name} \xB7 ${c}`:r.gene.name,fallback:c?`${r.gene.name} \u2026`:void 0,stack:_r,fits:l=>[...s({x0:l.x0-o,x1:l.x1+o,y0:l.y0-o,y1:l.y1+o})].every(d=>r.nodeIds.has(d))}})}function cn(e,t){return[...e].sort((n,s)=>t(s)-t(n))}function Or(e){let{paneWidth:t,canvasHeight:n,translateX:s,translateY:o}=e,{scaleX:r,scaleY:i}=e.axisScale,a={width:t,height:n},c=y=>({x:y.x*r+s,y:y.y*i+o}),l=e.drawnRowLabels.map(({label:y,y:E})=>He(y,E*i+o)),d=e.referenceStripZonePx??0;d>0&&l.push({x0:0,x1:t,y0:0,y1:d}),e.legendSize.width>0&&l.push({x0:t-Qe-e.legendSize.width,x1:t,y0:0,y1:d+Qe+e.legendSize.height}),e.poppedFrom&&l.push({x0:0,x1:60+e.poppedFrom.label.length*U*1.2,y0:0,y1:44});let f=Tt(a,l),u=e.drawnRowLabels.length>0,m=u?Math.min(...e.drawnRowLabels.map(y=>y.y)):1/0,h=e.contigThickness*rn,p=cn(e.bubbleHalos,y=>y.members),g=be(p.map(y=>{let{x:E,y:S}=c({x:y.labelAt.x,y:Math.min(y.labelAt.y,m)}),N=S-h/2-6;return{item:y,x:E,y:u?Math.max(N,kr):N,text:y.label}}),a,f),x=be(an(e.genePins,c,e.contigThickness,on(e.nodePositions??{},{scaleX:r,scaleY:i,translateX:s,translateY:o},e.positionsVersion)),a,f),b=e.nodePositions&&e.labelsNodeSizes?Ge({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:[]},M=we(b.deletions,f),w=be(p.flatMap(y=>y.routes.map(E=>{let{x:S,y:N}=c(E.at);return{item:{halo:y,route:E},x:S,y:N+4,text:E.text,stack:Nr}})),a,f),v=we(b.nodes,f,ze(t,n));return{bubbles:g,genes:x,routes:w,sizes:[...M,...v]}}function vl(e){return Z(e)?ln(e):void 0}function ln(e){return{sample:he(e.stable.refName),haplotype:kt(e.stable.refName),refName:me(e.stable.refName),start:e.stable.start,end:e.stable.start+e.length}}function Ar(e,t){let n=[...e].sort((r,i)=>r.start-i.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 Ir(e){return`${e.haplotype??e.sample}\0${e.refName}`}function El(e,{maxGap:t=1/0}={}){let n=new Map;for(let o of e.nodes)if(Z(o)){let r=ln(o),i=Ir(r),a=n.get(i);a?(a.spans.push({start:r.start,end:r.end}),a.rank=Math.min(a.rank,o.stable.rank)):n.set(i,{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=Ar(o.spans,t);if(r){let i={sample:o.sample,haplotype:o.haplotype,refName:o.refName,start:r.start,end:r.end,rank:o.rank,nodeCount:o.spans.length},a=o.haplotype??o.sample,c=s.get(a);(!c||i.nodeCount>c.nodeCount)&&s.set(a,i)}}return[...s.values()].sort((o,r)=>+(o.rank!==0)-+(r.rank!==0)||o.sample.localeCompare(r.sample)||(o.haplotype??"").localeCompare(r.haplotype??""))}function Tr(e,t){return(t.haplotype===void 0?void 0:e(t.haplotype))??e(t.sample)}function Sl(e,t){return e.flatMap(n=>{let s=Tr(t,n);return s===void 0?[]:[{...n,sample:s}]})}function Rl(e){return`${e.refName}:${e.start+1}-${e.end}`}function Ze(e){return`${e.refName}:${(e.start+1).toLocaleString()}-${e.end.toLocaleString()}`}var fn=Q(pe(),1),dn=(0,P.createSvgIcon)((0,fn.jsx)("path",{d:"M9.01 14H2v2h7.01v3L13 15l-3.99-4zm5.98-1v-3H22V8h-7.01V5L11 9z"}),"CompareArrows");var un=Q(pe(),1),pn=(0,P.createSvgIcon)((0,un.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 hn=Q(pe(),1),Je=(0,P.createSvgIcon)((0,hn.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 Cr="Linear genome view",$r="Linear synteny view",Pr="No synteny track in this session aligns these assemblies";function mn({label:e,icon:t,entries:n,entryLabel:s,onSelect:o,disabledHelpText:r,nameTheOnlyEntry:i=!0}){let[a]=n,c=r?[{label:e,icon:t,disabled:!0,disabledHelpText:r,onClick:()=>{}}]:[];return n.length===0?c:n.length===1&&a?[{label:i?`${e} \u2014 ${s(a)}`:e,icon:t,onClick:o(a)}]:[{label:e,icon:t,type:"subMenu",subMenu:n.map(l=>({label:s(l),onClick:o(l)}))}]}function Xl({contributors:e,syntenyTracks:t,onShowLinear:n,onShowSynteny:s}){let o=t[0]?.coverage??e.length;return[...mn({label:Cr,icon:Je,entries:e,entryLabel:r=>`${r.sample} ${Ze(r)}`,onSelect:r=>()=>{n({location:r,assembly:r.sample})}}),...e.length>=2?mn({label:`${$r} (${o} assemblies)`,icon:dn,entries:t,entryLabel:r=>r.coverage<o?`${r.name} (${r.coverage} of ${o})`:r.name,nameTheOnlyEntry:!1,disabledHelpText:Pr,onSelect:r=>()=>{s(r.trackId)}}):[]]}function Bl({own:e,reference:t,highlight:n,onShowLinear:s,onHighlight:o}){let r=[e?{label:`Open in ${e.assembly} \u2014 ${Ze(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(i=>i!==void 0);return[...o&&n?[{label:`Highlight in ${n.assembly}`,icon:pn,onClick:()=>{o(n)}}]:[],...r.map(({label:i,target:a})=>({label:i,icon:Je,onClick:()=>{s(a)}}))]}function et(e){return e.id.endsWith("-")?"-":"+"}function tt(e,t){return t===et(e)?e.id:`-${e.id}`}function Br(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 i=e.length-1;i>o&&e[i]!==void 0;i--)r-=e[i],n[i]=r;return n}function Dr(e,t){let n=e.path.map(()=>[]);if(e.cs===void 0)return n;let s=Br(t,e.pathLength),o=(a,c=!1)=>{for(let l=0;l<s.length;l++){let d=s[l],f=t[l];if(d!==void 0&&f!==void 0&&d<=a&&(a<d+f||c&&a===d+f))return{s:l,local:a-d,room:d+f-a}}},r=(a,c)=>{let l=n[a],d=l.at(-1);c.type==="substitution"&&d?.type==="substitution"&&d.pos+d.seq.length===c.pos?d.seq+=c.seq:l.push(c)},i=e.pathStart;for(let a of Ot(e.cs))if(a.op==="match")i+=a.length;else if(a.op==="substitution"){let c=o(i);c&&r(c.s,{type:"substitution",pos:c.local,seq:a.seq}),i+=1}else if(a.op==="insertion"){let c=o(i,i===e.pathEnd);c&&r(c.s,{type:"insertion",pos:c.local,seq:a.seq})}else{let c=a.length;for(;c>0;){let l=o(i),d=l?Math.min(c,l.room):c;l&&r(l.s,{type:"deletion",pos:l.local,length:d}),i+=d,c-=d}}return n}function xn(e,t,n){let s=new Map(e.nodes.map(r=>[r.name,r])),o=[];for(let r of t){let i=r.path.map(d=>s.get(d.name)),a=i.flatMap((d,f)=>d?[f]:[]),c=a[0],l=a.at(-1);if(c!==void 0&&l!==void 0){let d=Dr(r,i.map(m=>m?.length)),f=a.map(m=>tt(i[m],r.path[m].strand)),u=i[l].length;o.push({id:n+o.length,name:r.name,type:"read",sourceTrackID:1,sequence:f,sequenceNew:a.map((m,h)=>({nodeName:f[h],mismatches:d[m]})),firstNodeOffset:c===0?r.pathStart:0,finalNodeCoverLength:l===r.path.length-1?u-(r.pathLength-r.pathEnd):u,mapping_quality:r.mappingQuality===255?0:r.mappingQuality,is_secondary:r.secondary,is_reverse:r.strand==="-"})}}return o}var qr=["#6baed6","#4292c6","#2171b5","#08519c"],Fr=["#fb6a4a","#ef3b2c","#cb181d","#a50f15"];function bn(e){let t=e.is_reverse?Fr:qr;return t[e.id%t.length]}function Ne(e){let t=e.split("#"),n=t.length>=2?Number(t[1]):Number.NaN;return{sample:t[0]??e,haplotype:Number.isFinite(n)?n:void 0}}function Wr(e,t,n,s){let o=[],r=[],i=[e];for(s.add(e);i.length>0;){let a=i.pop(),c=t.get(a);if(c){o.push(c);for(let l of n.get(a)??[]){let d=t.get(l);d&&(d.stable.rank===ge?r.push(d):s.has(l)||(s.add(l),i.push(l)))}}}return{members:o,anchors:r}}function Yr(e){if(new Set(e.map(a=>a.stable.refName)).size!==1||e.length<2)return;let n=[...e].sort((a,c)=>a.stable.start-c.stable.start),s=n[0],o=n.at(-1),r=s.stable.start+s.length,i=o.stable.start;return i>=r?{start:r,end:i,entry:s}:void 0}function Hr(e,t,n){let s=new Map(e.map(i=>[i.id,i])),o=new Map,r=[];for(let i of n.get(t.id)??[])s.has(i)&&(o.set(i,0),r.push(i));if(r.length===0)for(let i of e)o.set(i.id,0),r.push(i.id);for(let i of r){let a=o.get(i)+s.get(i).length;for(let c of n.get(i)??[])if(s.has(c)){let l=o.get(c);(l===void 0||a<l)&&(o.set(c,a),r.push(c))}}return o}function Gr(e,t,n){let s=Hr(e,t,n),o=[...e].sort((c,l)=>s.get(c.id)-s.get(l.id)),r=new Map(o.map((c,l)=>[c.id,l])),i=new Map(e.map(c=>[c.id,c])),a=new Map;for(let[c,l]of o.entries()){let d=0;for(let f of n.get(l.id)??[]){let u=i.get(f);u&&r.get(f)<c&&(d=Math.max(d,a.get(f)+u.length))}a.set(l.id,d)}return{offsets:a,ordered:o}}function yn(e){let t=new Map(e.nodes.filter(Z).map(r=>[r.id,r])),n=xe(e),s=new Set,o=[];for(let r of t.values())if(r.stable.rank!==ge&&!s.has(r.id)){let{members:i,anchors:a}=Wr(r.id,t,n,s),c=Yr(a);if(c){let{offsets:l,ordered:d}=Gr(i,c.entry,n);o.push({start:c.start,refSpan:c.end-c.start,nodeIds:d.map(f=>f.id),nodeOffsets:d.map(f=>l.get(f.id)),pathLength:d.reduce((f,u)=>Math.max(f,l.get(u.id)+u.length),0)})}}return o.sort((r,i)=>r.start-i.start)}var zr=1,Ur=.015;function Le({graph:e,span:t,rowY:n,positions:s}){let o=t*Ur,r=yn(e),i=new Map(e.nodes.map(d=>[d.id,d])),a=[];for(let d of r){let f=d.refSpan-d.pathLength;f>=zr&&a.push({nodeIds:d.nodeIds,bp:f});let u=Math.max(d.refSpan,o),m=d.pathLength>0?u/d.pathLength:0;d.nodeIds.forEach((h,p)=>{let g=i.get(h);if(g){let x=d.nodeOffsets[p],b=u/d.nodeIds.length,M=v=>d.start+v*m,w=n(g);s[h]=m?[{x:M(x),y:w},{x:M(x+g.length),y:w}]:[{x:d.start+p*b,y:w},{x:d.start+(p+1)*b,y:w}]}})}let c=xe(e),l=Object.keys(s);for(let d of l){let f=s[d].at(-1).x;for(let u of c.get(d)??[]){let m=i.get(u);if(m&&!(u in s)){let h=n(m);s[u]=[{x:f,y:h},{x:f+o,y:h}],l.push(u)}}}return a}function Kr(e,t){let n=new Map;for(let o of e.nodes)if(se(o)){let{sample:r}=Ne(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 wn(e,t,n=[]){let s=G(e),o=Kr(e,n);if(s.length===0||o.length===0)return;let r=ae(s,t),i=new Map(o.map((u,m)=>[u,m+1])),a=z(s),c=o.length+1,l=Le({graph:e,span:r,rowY:u=>{let m=u.stable;return((m?i.get(Ne(m.refName).sample):void 0)??c)*_},positions:a}),f=[{label:Ne(s[0].stable.refName).sample,y:0},...o.map(u=>({label:u,y:i.get(u)*_}))];return{nodePositions:a,rowLabels:f,sampleRows:o,referenceAxis:!0,pixelRows:!0,alleleDeletions:l}}function Mn(){return{rectangles:[],curves:[],corners:[],verticalRectangles:[]}}var jr=new Set(["_gbwt_ref","unknown"]);function vn(e){let[t,n,s]=e?.split("#")??[];if(!(t===void 0||t===""||jr.has(t)||n===void 0||!/^\d+$/.test(n)||s===void 0||s===""))return{sample:t,haplotype:Number(n),contig:s}}var Pn=!1;function te(...e){Pn&&console.log(...e)}var Vr=["read_group","sample_name"],rf=[...Vr,"haplotype_sample"];function Qr({layers:e,coarsenedReadView:t=!1,showReads:n=!0},s){if(e!==void 0)return e;let o=t&&n,r=i=>i?{stat:"coarsen"}:{};return[{data:"haplotypes",...r(o&&!s)},{data:"reads",...r(o&&s)}]}function En(e,t){return e.find(n=>n.data===t)?.stat}function Zr(e,t){return{mergeNodes:e.mergeNodes??!0,showReads:e.showReads??!0,coarsenedReadView:e.coarsenedReadView??!1,layers:Qr(e,t),ignoreStrand:e.ignoreStrand??!1,nodeWidthOption:e.nodeWidthOption??"normal",charWidth:e.charWidth??8.401,trackWidth:e.trackWidth??15}}function Xn(e){return{config:e,nodes:[],tracks:[],reads:[],nodeMap:new Map,nodesPerOrder:[],nodeOrders:[],assignments:[],extraLeft:[],extraRight:[],maxOrder:-1,shapes:Mn(),imageBounds:{minX:0,maxX:0,minY:0,maxY:0},trackForRuler:void 0,coarsenedEdgeMeta:new Map}}function Bn(e,t,n=[],s={}){let o=Jr(e,t,n,s);return o&&es(o,s)}var Dn=new WeakMap;function Jr(e,t,n=[],s={}){let o=ns(e,t,n,s);if(o===void 0)return;let r=qn(o,o.tracks,o.reads,"measure");return r.nodes.forEach((i,a)=>{i.order>=0&&(o.nodes[a].x=i.x)}),Dn.set(o,r),o}function es(e,t={}){return ts(e,as(e,t.facet),os(e,t))}function ts(e,t,n,s){let o=Dn.get(e);return o!==void 0&&t.length===e.tracks.length&&n.length===e.reads.length?o:qn(e,t,n,"topology",s)}function ns(e,t,n,s){let o=Xn(Zr(s,n.length>0));if(!(e.length===0||t.length===0)){structuredClone(e).forEach((r,i)=>{r.seq??="",r.sequenceLength??=r.seq.length,o.nodes[i+1]=r}),o.tracks=structuredClone(t),o.reads=o.config.showReads?structuredClone(n.filter(r=>r.is_secondary!==!0)):[];for(let r=o.tracks.length-1;r>=0;r-=1){let i=o.tracks[r];if(i.type??="haplotype",i.hidden===!0){o.tracks.splice(r,1);continue}i.indexOfFirstBase!==void 0&&(o.trackForRuler=i.name)}if(o.tracks.length!==0)return cs(o,0),o.nodeMap=Ln(o),ee(o,o.tracks),ee(o,o.reads),Cn(o),o.config.mergeNodes&&(_n(o),ot(o),rt(o),Qs(o),o.nodeMap=Ln(o),Cn(o),ee(o,o.tracks),ee(o,o.reads)),_n(o),Os(o),ot(o),As(o),ot(o),rt(o),ee(o,o.reads),{options:o.config,nodes:o.nodes,tracks:o.tracks,reads:o.reads,nodeMap:o.nodeMap,maxOrder:_s(o),trackForRuler:o.trackForRuler}}}function os(e,{mappingQualityCutoff:t=0,focusReadNames:n=null,facet:s}){let o=n?new Set(n):null;return e.reads.filter(r=>(r.mapping_quality??0)>=t&&(o===null||r.name!==void 0&&o.has(r.name))&&(s===void 0||rs(s,r)))}function rs(e,t){return e.by==="haplotype_sample"?"reads"in e:(t[e.by]??null)===e.key}function ss(e){return new Set(e.tracks.filter((t,n)=>n===0||t.name===e.trackForRuler))}function as(e,t){if(t?.by!=="haplotype_sample")return e.tracks;let n=ss(e);return e.tracks.filter(s=>n.has(s)||!("reads"in t)&&is(s)===t.key)}function is(e){return vn(e.name)?.sample??null}function qn(e,t,n,s,o={}){let r=Xn(e.options);e.nodes.forEach((u,m)=>{r.nodes[m]={...u}}),r.tracks=t.map(u=>({...u})),r.reads=n.map(u=>({...u})),r.nodeMap=e.nodeMap,r.maxOrder=e.maxOrder,r.trackForRuler=e.trackForRuler;let{layers:i,ignoreStrand:a}=r.config,c=o.haplotypes??Hn,l=En(i,"haplotypes")==="coarsen"?zs(r,c):void 0;l!==void 0&&(r.tracks=[l.ref]),Ws(r),$s(r),ls(r);let d=En(i,"reads")==="coarsen"&&r.reads.length>0?Gn(r,r.reads,"read",o.reads??c+(l?.bands.length??0)):void 0;d!==void 0&&(r.reads=d.bands);let f={};for(let[u,m,h]of[["haplotypes","haplotype",l],["reads","read",d]])h!==void 0&&(rt(r,h.bands),ee(r,h.bands),f[u]={unit:m,total:h.total,reverse:!a&&h.bands.some(p=>p.is_reverse)});return l!==void 0&&(r.reads=l.bands.concat(r.reads)),r.reads.length>0?(ds(r),r.tracks=r.tracks.concat(r.reads)):r.nodes.forEach(u=>{u.incomingReads=[],u.outgoingReads=[],u.internalReads=[]}),s==="measure"&&Ts(r),Gs(r),te("Tracks:",r.tracks),te("Nodes:",r.nodes),te("Lane assignment:",r.assignments),Es(r),{nodes:r.nodes,tracks:r.tracks,reads:r.reads,nodeMap:r.nodeMap,shapes:r.shapes,bounds:r.imageBounds,maxOrder:r.maxOrder,trackForRuler:r.trackForRuler,coarsenedEdgeMeta:r.coarsenedEdgeMeta,coarsened:f}}function O(e){return e.startsWith("-")}function I(e){return O(e)?e.substring(1):e}function Fn(e){return O(e)?e:`-${e}`}function st(e){return O(e)?I(e):Fn(e)}function Sn(e){return e>0}function cs(e,t){let n=new Set,s=new Set;for(let o of e.tracks[t].sequence)O(o)?s.has(I(o))||n.add(I(o)):s.add(o);if(n.size!==0){for(let{sequence:o}of[...e.tracks,...e.reads])for(let r=0;r<o.length;r+=1)n.has(I(o[r]))&&(o[r]=st(o[r]));e.nodes.forEach(o=>{n.has(o.name)&&(o.seq=at(o.seq))})}}function ls(e){e.nodesPerOrder=[];for(let n=0;n<=e.maxOrder;n+=1)e.nodesPerOrder[n]=[];let t=new Map;e.nodes.forEach(n=>{n.y!==void 0&&Rn(t,n.order,n.y+n.contentHeight)}),e.tracks.forEach(n=>{n.type==="haplotype"&&n.path.forEach(s=>{Rn(t,s.order,(s.y??0)+n.width)})}),e.nodes.forEach((n,s)=>{n.order>=0&&n.y===void 0&&(n.y=(t.get(n.order)??0)+25,n.contentHeight=0,e.nodesPerOrder[n.order].push(s))})}function Rn(e,t,n){let s=e.get(t);s===void 0?e.set(t,n):e.set(t,Math.max(s,n))}var _e=7;function fs(e){e.nodes.forEach(t=>{t.incomingReads=[],t.outgoingReads=[],t.internalReads=[]}),e.reads.forEach((t,n)=>{if((t.width===void 0||t.width===0)&&(t.width=_e),t.path.length===1){let s=t.path[0].node;s!==null&&e.nodes[s].internalReads.push(n)}else t.path.forEach((s,o)=>{if(o===0){let r=t.path[0].node;r!==null&&e.nodes[r].outgoingReads.push([n,o])}else{let r=s.node;r!==null&&e.nodes[r].incomingReads.push([n,o])}})})}function ds(e){e.reads.forEach(a=>{a.path=Wn(e,a)}),fs(e);let t=e.nodes.filter(a=>a.order>=0);t.sort(ct);let n=new Map;for(let a=0;a<e.reads.length;a++){let c=e.reads[a],l=c.haplotypeShare===void 0?1:0,d=c.sourceTrackID,f=`${l}:${d}`,u=n.get(f);u===void 0?n.set(f,{layer:l,source:d,reads:new Set([a])}):u.reads.add(a)}let s=[...n.values()].sort((a,c)=>a.layer-c.layer||a.source-c.source),o=s.length>1?_e:0;t.forEach(a=>{for(let{reads:c}of s)us(e,c,a,o)});let r=bs(e),i=[];e.reads.forEach((a,c)=>{let l=a.path.length,d=new Array(l),f;for(let h=0;h<l;h++){h===0?d[h]=void 0:d[h]=f??a.path[0];let p=a.path[h];p.node!==null&&p.node&&(f=p)}let u=new Array(l),m;for(let h=l-1;h>=0;h--){h===l-1?u[h]=void 0:u[h]=m??a.path[l-1];let p=a.path[h];p.node!==null&&p.node&&(m=p)}a.path.forEach((h,p)=>{if(h.y===void 0){let g=d[p],x=u[p],b=!!(x&&g&&(g.order>x.order||x.order===g.order&&x.isForward===g.isForward));h.betweenCycleReverseTraversal=b,i.push({readIndex:c,pathIndex:p,previousY:g?.y,previousNode:g?.node})}})}),i.sort((a,c)=>hs(e,a,c)),i.forEach(a=>{let c=e.reads[a.readIndex],l=c.path[a.pathIndex];l.y=r[l.order],r[l.order]+=c.width}),te("Reads:",e.reads)}function us(e,t,n,s){let o=n.incomingReads.filter(([h])=>t.has(h)),r=n.outgoingReads.filter(([h])=>t.has(h)),i=n.internalReads.filter(h=>t.has(h));o.length===0&&r.length===0&&i.length===0&&(s=0);let a=n.y+n.contentHeight+s*2,c=o.map(h=>{let[p,g]=h,x=e.reads[p].path,b=g+1,M;for(let w=1;w<=g;w++){let v=x[g-w]?.y;if(v!==void 0){b=w,M=v;break}}return{entry:h,decisionStep:b,y:M}});c.sort(ps),o=c.map(h=>h.entry);let l=a,d=new Map;o.forEach(h=>{let p=e.reads[h[0]];p.path[h[1]].y=l,Nn(d,p,h[1],l,n),l+=p.width});let f=l;r.sort((h,p)=>ms(e,h,p));let u=new Map;l=a,r.forEach(h=>{let p=e.reads[h[0]],g=p.firstNodeOffset??0;p.path[h[1]].y=l,u.set(l,g);let x=d.get(l);x===void 0||x+1<=g?(l+=p.width,f=Math.max(f,l)):(d.set(l,0),o.forEach(b=>{let M=e.reads[b[0]],w=M.path[b[1]];w.y!==void 0&&w.y>=l&&(w.y+=p.width,Nn(d,M,b[1],w.y,n))}),l+=p.width,f+=p.width)}),i.sort((h,p)=>xs(e,h,p)),i.forEach(h=>{let p=e.reads[h],g=p.firstNodeOffset??0,x=p.finalNodeCoverLength??0;for(l=a;g<(d.get(l)??-1/0)+2||x>(u.get(l)??1/0)-3;)l+=p.width||_e;p.path[0].y=l,d.set(l,x),f=Math.max(f,l)});let m=f-n.y-n.contentHeight;n.contentHeight+=m,qs(e,n,m)}function ps(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 Nn(e,t,n,s,o){n===t.path.length-1?e.set(s,t.finalNodeCoverLength??0):e.set(s,o.sequenceLength)}function hs(e,t,n){let s=e.reads[t.readIndex],o=e.reads[n.readIndex],r=s.path[t.pathIndex],i=o.path[n.pathIndex];if(r.order!==i.order)return r.order-i.order;if(s.sourceTrackID!==o.sourceTrackID)return s.sourceTrackID-o.sourceTrackID;if(t.previousNode&&n.previousNode){let f=e.nodes[t.previousNode],u=e.nodes[n.previousNode];if(f&&u&&f.order!==u.order)return f.order-u.order}let a=t.previousY??0,c=n.previousY??0,l=r.betweenCycleReverseTraversal===!0,d=i.betweenCycleReverseTraversal===!0;return l!==d?l?1:-1:l?c-a:a-c}function ms(e,[t,n],[s,o]){let r=e.reads[t],i=e.reads[s],a,c,l=r.path.length-1,d=i.path.length-1;for(;!a&&l>=0;)a=r.path[l]?.y,l-=1;for(;!c&&d>=0;)c=i.path[d]?.y,d-=1;if(a&&c)return a-c;let f=r.path[n]?.node,u=i.path[o]?.node,m=typeof f=="number"?e.nodes[f]:null,h=typeof u=="number"?e.nodes[u]:null;for(;m&&h&&m===h;){if(n<r.path.length-1){for(n+=1;r.path[n]?.node===null;)n+=1;let g=r.path[n]?.node;m=typeof g=="number"?e.nodes[g]:null}else m=null;if(o<i.path.length-1){for(o+=1;i.path[o]?.node===null;)o+=1;let g=i.path[o]?.node;h=typeof g=="number"?e.nodes[g]:null}else h=null}if(m)return h?ct(m,h):1;if(h)return-1;let p=(r.firstNodeOffset??0)-(i.firstNodeOffset??0);return p!==0?p:(r.finalNodeCoverLength??0)-(i.finalNodeCoverLength??0)}function gs(e,t){let n=e.path,s=t.path,o=0,r=0;for(;o<n.length&&r<s.length;){let i=n[o],a=s[r],c=i.order,l=a.order;if(c===l&&i.node&&a.node)return(a.y??0)-(i.y??0);c<l?o+=1:(c>l||(o+=1),r+=1)}return 0}function xs(e,t,n){let s=e.reads[t],o=e.reads[n],r=s.firstNodeOffset??0,i=o.firstNodeOffset??0;if(r<i)return-1;if(r>i)return 1;let a=s.finalNodeCoverLength??0,c=o.finalNodeCoverLength??0;return a<c?-1:a>c?1:0}function bs(e){let t=[];for(let n=0;n<=e.maxOrder;n+=1)t.push(0);return e.nodes.forEach(n=>{n.y!==void 0&&(t[n.order]=Math.max(t[n.order],n.y+n.contentHeight+20))}),e.tracks.forEach(n=>{n.path.forEach(s=>{t[s.order]=Math.max(t[s.order],(s.y??0)+n.width)})}),t}function Wn(e,t){let n=[],s=(c,l)=>{n.push({order:c,isForward:l,node:null})},o=(c,l,d)=>{n.push({order:c,isForward:l,node:d})},r=Math.abs(t.indexSequence[0]),i=Sn(t.indexSequence[0]),a=e.nodes[r];o(a.order,i,r);for(let c=1;c<t.sequence.length;c+=1){let l=a,d=i;r=Math.abs(t.indexSequence[c]),i=Sn(t.indexSequence[c]),a=e.nodes[r];let{order:f}=a;if(f>l.order){d||s(l.order,!0);for(let u=l.order+1;u<f;u+=1)s(u,!0);i||s(f,!0)}else if(f<l.order){d&&s(l.order,!1);for(let u=l.order-1;u>f;u-=1)s(u,!1);i&&s(f,!1)}else i===d&&s(f,!i);o(f,i,r)}return n}function rt(e,t=e.reads){t.forEach(n=>{let s=0;for(;s<n.sequence.length&&n.sequence[s].startsWith("-");)s+=1;if(s===n.sequence.length){n.is_reverse=!0,n.sequence=n.sequence.reverse();for(let c=0;c<n.sequence.length;c+=1)n.sequence[c]=I(n.sequence[c]);let o=n.sequenceNew??[];o.reverse(),n.sequenceNew=o;for(let c of o)c.nodeName=I(c.nodeName),ys(c.mismatches,nt(e,c.nodeName).sequenceLength);let r=n.firstNodeOffset??0,i=nt(e,n.sequence[0]).sequenceLength;n.firstNodeOffset=i-(n.finalNodeCoverLength??0);let a=nt(e,n.sequence[n.sequence.length-1]).sequenceLength;n.finalNodeCoverLength=a-r}})}function ys(e,t){e.forEach(n=>{Object.assign(n,ws(n,t))})}function ws(e,t){let n=e.type==="insertion"?0:e.type==="deletion"?e.length??0:e.seq?.length??0;return{...e,pos:t-e.pos-n,...e.seq!==void 0&&{seq:at(e.seq)}}}var Ms={A:"T",T:"A",C:"G",G:"C"};function at(e){let t="";for(let n=e.length-1;n>=0;n-=1)t+=Ms[e.charAt(n)]??"N";return t}function ee(e,t){let n=new Map;t.forEach(s=>{s.indexSequence=s.sequence.map(o=>{let r=n.get(o);if(r===void 0){let i=e.nodeMap.get(I(o));if(i===void 0)throw new Error(`Track ${s.name??s.id} visits unknown node ${o}`);r=O(o)?-i:i,n.set(o,r)}return r})})}var vs=20;function Es(e){let t={minX:99,maxX:-99,minY:99,maxY:-99};e.nodes.forEach(n=>{n.x!==void 0&&(t.minX=Math.min(t.minX,n.x),t.maxX=Math.max(t.maxX,n.x+vs+n.pixelWidth)),n.y!==void 0&&(t.minY=Math.min(t.minY,n.y-10),t.maxY=Math.max(t.maxY,n.y+n.contentHeight+10))}),e.tracks.forEach(n=>{n.path.forEach(s=>{let o=s.y??0;t.maxY=Math.max(t.maxY,o+n.width),t.minY=Math.min(t.minY,o)})}),e.imageBounds=t}function nt(e,t){let n=e.nodeMap.get(I(t)),s=n===void 0?void 0:e.nodes[n];if(s===void 0)throw new Error(`Unknown node ${t}`);return s}function Ln(e){let t=new Map;return e.nodes.forEach((n,s)=>{t.set(n.name,s)}),t}function _n(e){let t=e.nodes.map(()=>new Set),n=e.nodes.map(()=>new Set),s=o=>{for(let r=0;r<o.indexSequence.length-1;r+=1){let i=Math.abs(o.indexSequence[r]),a=Math.abs(o.indexSequence[r+1]);t[i].add(a),n[a].add(i)}};e.tracks.forEach(s),e.reads.forEach(s),e.nodes.forEach((o,r)=>{o.successors=Array.from(t[r]),o.predecessors=Array.from(n[r])})}function kn(e,t){let n=0,s=0,o=0;t.forEach(r=>{let i=Math.abs(r);if(r<0){let a=e.nodeOrders[i]??=s;a<o&&(o=a),n=a,s=a-1}else{let a=e.nodeOrders[i]??=n;n=a+1,s=a}}),o<0&&it(e,-o)}function Ss(e,t){let n=0,s=0;for(;n<t.length&&e.nodeOrders[Math.abs(t[n])]===void 0;)n+=1;if(n>=t.length)return null;let o=t[n],r,i;o>=0?(r=e.nodeOrders[o]-1,i=-1):(r=e.nodeOrders[-o]+1,i=1);for(let a=n-1;a>=0;a-=1){let c=Math.abs(t[a]);e.nodeOrders[c]===void 0&&(e.nodeOrders[c]=r,s=Math.min(s,r),r+=i)}return s<0&&it(e,-s),n}var Rs=-1;function Ns(e){let t=[];for(let n of e)t.push(n??Rs);return t}function ot(e){let t,n,s,o,r=0,i=e.tracks.concat(e.reads),a={stamp:new Int32Array(e.nodes.length),generation:0};e.nodeOrders=new Array(e.nodes.length).fill(void 0),e.nodes.forEach(l=>{l.order=void 0}),kn(e,e.tracks[0].indexSequence);for(let l=1;l<i.length;l+=1){if(te(`generating order for track ${l+1}`),s=Ss(e,i[l].indexSequence),s===null){l<e.tracks.length?kn(e,i[l].indexSequence):(i.splice(l,1),e.reads.splice(l-e.tracks.length,1),l-=1);continue}for(t=ks(i[l].indexSequence);s<t.length;){for(o=s,s+=1;s<t.length&&e.nodeOrders[t[s]]===void 0;)s+=1;if(s<t.length){n=e.nodeOrders[t[o]]+1;for(let d=o+1;d<s;d+=1)e.nodeOrders[t[d]]=n,n+=1;if(e.nodeOrders[t[s]]>e.nodeOrders[t[o]])e.nodeOrders[t[s]]<n&&On(e,t[s],t[s-1],n);else if(i[l].indexSequence[s]>=0&&!Ls(e,t[s],t[o],a))On(e,t[s],t[s-1],n);else if(i[l].indexSequence[o]<0||e.nodes[t[o+1]].degree<2&&e.nodeOrders[t[s]]<e.nodeOrders[t[o]]){n=e.nodeOrders[t[o]]-1;for(let d=o+1;d<s;d+=1)e.nodeOrders[t[d]]=n,r=Math.min(r,n),n-=1}}else if(i[l].indexSequence[o]>=0){n=e.nodeOrders[t[o]]+1;for(let d=o+1;d<t.length;d+=1){let f=t[d];e.nodeOrders[f]===void 0&&(e.nodeOrders[f]=n,n+=1)}}else{n=e.nodeOrders[t[o]]-1;for(let d=o+1;d<t.length;d+=1){let f=t[d];e.nodeOrders[f]===void 0&&(e.nodeOrders[f]=n,r=Math.min(r,n),n-=1)}}}}r<0&&it(e,-r);let c=Ns(e.nodeOrders);e.nodeOrders=c,c.forEach((l,d)=>{let f=e.nodes[d];f!==void 0&&(f.order=l)})}function Ls(e,t,n,s){s.generation+=1;let{stamp:o,generation:r}=s,i=[t];for(o[t]=r;i.length>0;){let a=i.pop();if(a===n)return!0;for(let c of e.nodes[a].successors)o[c]!==r&&(o[c]=r,i.push(c))}return!1}function _s(e){let t=-1;return e.nodeOrders.forEach(n=>{n!==void 0&&n>t&&(t=n)}),t}function ks(e){return e.map(t=>Math.abs(t))}function it(e,t){e.nodeOrders.forEach((n,s)=>{n!==void 0&&(e.nodeOrders[s]=n+t)})}function On(e,t,n,s){let o=new Map,r=[[t,s]],i=0;for(;i<r.length;){let[a,c]=r[i];i+=1;let l=e.nodeOrders[a];l!==void 0&&l<c&&(!o.has(a)||o.get(a)<c)&&(o.set(a,c),e.nodes[a].successors.forEach(d=>{e.nodeOrders[d]>l&&d!==n&&r.push([d,c+1])}),a!==t&&e.nodes[a].predecessors.forEach(d=>{e.nodeOrders[d]>l&&d!==n&&r.push([d,c+1])}))}o.forEach((a,c)=>{e.nodeOrders[c]=a})}function Os(e){e.nodes.forEach(t=>{t.tracks=[]}),e.tracks.forEach(t=>{t.indexSequence.forEach(n=>{e.nodes[Math.abs(n)].tracks.push(t.id)})}),e.nodes.forEach(t=>{t.degree=t.tracks.length})}function As(e){Is(e,[...e.tracks.slice(1),...e.reads],e.tracks[0])}function Is(e,t,n){let s=new Int32Array(e.nodes.length),o=new Uint8Array(e.nodes.length);for(let r of n.sequence){let i=O(r)?void 0:e.nodeMap.get(r);i!==void 0&&(o[i]=1)}for(let r of t){let{sequence:i,indexSequence:a}=r,c=a.length-1;for(let l=0;l<=c;l+=1){let d=Math.abs(a[l]);if(o[d]===1)continue;let f=e.nodes[d].order,u=l>0?e.nodes[Math.abs(a[l-1])].order:void 0,m=l<c?e.nodes[Math.abs(a[l+1])].order:void 0,h=O(i[l])?1:-1;(u===void 0||u<f)&&(m===void 0||f<m)&&(s[d]+=h),(u===void 0||u>f)&&(m===void 0||f>m)&&(s[d]-=h)}}for(let r of t){let{sequence:i,indexSequence:a}=r;for(let c=0;c<a.length;c+=1)s[Math.abs(a[c])]>0&&(i[c]=st(i[c]),a[c]=-a[c])}e.nodes.forEach((r,i)=>{s[i]>0&&(r.seq=at(r.seq),r.switched=!0)})}function Ts(e){let t=0,n=20,s=-1,o=e.nodes.slice();o.sort(ct);let r=Cs(e);o.forEach(i=>{i.order>=0&&(i.order>s&&(s=i.order,t=n+10*r[i.order]),i.x=t,n=Math.max(n,t+40+i.pixelWidth))})}function Cs(e){let t=[],n=[],s=[],o=[];for(let r=0;r<=e.maxOrder;r+=1)t.push(0),n.push(0),s.push(0);e.tracks.forEach(r=>{for(let i=1;i<r.path.length;i+=1){let a=r.path[i],c=r.path[i-1];if(a.order===c.order)a.isForward?t[a.order]=t[a.order]+1:n[a.order]=n[a.order]+1;else{let l=Math.abs((a.y??0)-(c.y??0));s[a.order]=Math.max(l/17.5,s[a.order])}}}),o.push(Math.max(0,t[0]-1));for(let r=1;r<=e.maxOrder;r+=1)o.push(Math.max(Math.max(0,t[r]-1)+Math.max(0,n[r-1]-1),s[r]));return o}function $s(e){let t=[],n=[];for(let s=0;s<=e.maxOrder;s+=1)e.assignments[s]=[],n[s]=new Map,t[s]=[];e.tracks.forEach((s,o)=>{s.path=Wn(e,s),s.path.forEach((r,i)=>{Ps(e,r.order,r.node,o,i,t,n)})});for(let s=0;s<=e.maxOrder;s+=1)Bs(e,e.assignments[s],s)}function Ps(e,t,n,s,o,r,i){let a={trackID:s,segmentID:o,compareToFromSame:r[t][s]??null},c=n===null?void 0:i[t].get(n);if(c===void 0){let l={type:"single",node:n,tracks:[a]};e.assignments[t].push(l),n!==null&&i[t].set(n,l)}else c.type="multiple",c.tracks.push(a);r[t][s]=a}function Xs(e,t,n){let s;t.forEach(o=>{o.idealLane=0,o.tracks.forEach(r=>{if(r.segmentID===0)r.idealLane=r.trackID,r.idealY=null;else if(e.tracks[r.trackID].path[r.segmentID-1].order===n-1)r.idealLane=e.tracks[r.trackID].path[r.segmentID-1].lane??void 0,r.idealY=e.tracks[r.trackID].path[r.segmentID-1].y;else if(r.segmentID<e.tracks[r.trackID].path.length-1&&e.tracks[r.trackID].path[r.segmentID+1].order===n-1)r.idealLane=e.tracks[r.trackID].path[r.segmentID+1].lane??void 0,r.idealY=e.tracks[r.trackID].path[r.segmentID+1].y;else{for(s=r.segmentID-1;s>=0&&e.tracks[r.trackID].path[s].order!==n-1;)s-=1;s<0?(r.idealLane=r.trackID,r.idealY=null):(r.idealLane=e.tracks[r.trackID].path[s].lane,r.idealY=e.tracks[r.trackID].path[s].y)}o.idealLane+=r.idealLane}),o.idealLane/=o.tracks.length})}function Bs(e,t,n){let s=0,o=new Set,r=20,i=!1,a=-1;Xs(e,t,n),t.sort(An),t.forEach(c=>{c.node!==null?(e.nodes[c.node].topLane=s,i&&(r-=10),e.nodes[c.node].y=r,e.nodes[c.node].contentHeight=0,i=!1):(i?r-=25:r>20&&(r-=10),i=!0),c.tracks.sort(An),c.tracks.forEach(l=>{l.lane=s,l.trackID===a&&c.node===null&&i&&(r+=10),e.tracks[l.trackID].path[l.segmentID].lane=s,e.tracks[l.trackID].path[l.segmentID].y=r,typeof l.idealY=="number"&&o.add(l.idealY-r),s+=1,r+=e.tracks[l.trackID].width,c.node!==null&&(e.nodes[c.node].contentHeight+=e.tracks[l.trackID].width),a=l.trackID}),r+=25}),Ds(e,t,o)}function Ds(e,t,n){let s=0,o=Number.MAX_SAFE_INTEGER;n.forEach(r=>{let i=Fs(e,t,r);i<o&&(o=i,s=r)}),t.forEach(r=>{r.node!==null&&(e.nodes[r.node].y+=s),r.tracks.forEach(i=>{let a=e.tracks[i.trackID].path[i.segmentID];a.y=a.y+s})})}function qs(e,t,n){t.order<0||e.assignments[t.order]===void 0||(e.assignments[t.order].forEach(s=>{if(s.node!==null){let o=e.nodes[s.node];o!==t&&o.y>t.y&&(o.y+=n,s.tracks.forEach(r=>{let i=e.tracks[r.trackID].path[r.segmentID];i.y=i.y+n}))}else s.tracks.forEach(o=>{let r=e.tracks[o.trackID].path[o.segmentID];r.y>=t.y&&(r.y=r.y+n)})}),e.nodesPerOrder[t.order].length>0&&e.nodesPerOrder[t.order].forEach(s=>{e.nodes[s]!==t&&e.nodes[s].y>t.y&&(e.nodes[s].y+=n)}))}function Fs(e,t,n){let s=0;return t.forEach(o=>{o.tracks.forEach(r=>{typeof r.idealY=="number"&&e.tracks[r.trackID].type!=="read"&&(s+=Math.abs(r.idealY-n-e.tracks[r.trackID].path[r.segmentID].y)*e.tracks[r.trackID].width)})}),s}function An(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 ct(e,t){return e.order!==t.order?e.order-t.order:e.y!==void 0&&t.y!==void 0?e.y-t.y:0}function Ws(e){let t=!0,n=4,s=e.config.trackWidth;for(let o of e.tracks)o.freq!==void 0?o.width=Math.round((Math.log(Math.max(o.freq,1))+1)*n):(o.width=s,o.type!==void 0&&o.type==="read"&&(o.width=n)),o.width!==n&&(t=!1);t&&e.tracks.forEach(o=>{o.freq!==void 0&&(o.width=s)})}function Ys(e,t){let n=t.path[0],s=e.nodes[n.node],o=t.firstNodeOffset??0;return lt(s,n.isForward?o:s.sequenceLength-o)}function Hs(e,t){let n=t.path[t.path.length-1],s=e.nodes[n.node],o=t.finalNodeCoverLength??0;return lt(s,n.isForward?o:s.sequenceLength-o)}function Yn(e,t){return t>e.sequenceLength?null:lt(e,t)}function lt(e,t){let[n,s]=Vs(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 Gs(e){let t,n,s,o;for(let a=0;a<=e.maxOrder;a+=1)e.extraLeft.push(0),e.extraRight.push(0);let r=[],i=[];e.nodes.forEach(a=>{a.x!==void 0&&(r[a.order]=a.x,i[a.order]===void 0?i[a.order]=a.x+a.pixelWidth:i[a.order]=Math.max(i[a.order],a.x+a.pixelWidth))}),e.tracks.sort(gs),e.tracks.forEach(a=>{s=a.path[0].y,a.type!=="read"?a.sequence[0].startsWith("-")?t=i[a.path[0].order]+20:t=r[a.path[0].order]-20:t=Ys(e,a);for(let c=0;c<a.path.length;c+=1)a.path[c].y!==s&&(a.path[c-1].isForward?n=i[a.path[c-1].order]:n=r[a.path[c-1].order],n!==t&&e.shapes.rectangles.push({xStart:Math.min(t,n),yStart:s,xEnd:Math.max(t,n),yEnd:s+a.width-1,id:a.id,name:a.name,type:a.type}),a.path[c].order-1===a.path[c-1].order?(t=n,n=r[a.path[c].order],o=a.path[c].y,e.shapes.curves.push({xStart:t,yStart:s,xEnd:n+1,yEnd:o,width:a.width,id:a.id,name:a.name,type:a.type,nodeStart:a.path[c-1].node,nodeEnd:a.path[c].node,orderStart:a.path[c-1].order,orderEnd:a.path[c].order}),t=n,s=o):a.path[c].order+1===a.path[c-1].order?(t=n,n=i[a.path[c].order],o=a.path[c].y,e.shapes.curves.push({xStart:t+1,yStart:s,xEnd:n,yEnd:o,width:a.width,id:a.id,name:a.name,type:a.type,nodeStart:a.path[c-1].node,nodeEnd:a.path[c].node,orderStart:a.path[c-1].order,orderEnd:a.path[c].order}),t=n,s=o):a.path[c-1].isForward?(o=a.path[c].y,Tn(e,1,n,s,o,a.width,a.id,a.path[c].order,a.type,a.name),t=i[a.path[c].order],s=a.path[c].y):(o=a.path[c].y,Tn(e,-1,n,s,o,a.width,a.id,a.path[c].order,a.type,a.name),t=r[a.path[c].order],s=a.path[c].y));a.type!=="read"?a.path[a.path.length-1].isForward?n=i[a.path[a.path.length-1].order]+20:n=r[a.path[a.path.length-1].order]-20:n=Hs(e,a),e.shapes.rectangles.push({xStart:Math.min(t,n),yStart:s,xEnd:Math.max(t,n),yEnd:s+a.width-1,id:a.id,name:a.name,type:a.type})})}var Hn=1e9;function Gn(e,t,n,s=Hn){let o=new Map,r=0,i=e.nodes.length,a=(p,g)=>(p+i)*(2*i+1)+g+i,c=e.config.ignoreStrand;for(let[p,g]of t.entries()){let x=Math.max(g.freq??1,1);r+=x;let b=g.indexSequence;if(!(b.length<2))for(let M=0;M<b.length-1;M+=1){let w=b[M],v=b[M+1],y=e.nodes[Math.abs(w)],E=e.nodes[Math.abs(v)],S=c?Math.min(a(w,v),a(-v,-w)):a(w,v),N=o.get(S);N===void 0?o.set(S,{sSigned:w,dSigned:v,sName:w<0?`-${y.name}`:y.name,dName:v<0?`-${E.name}`:E.name,count:x,crossings:x,sourceTrackID:g.sourceTrackID,lastSource:p}):(N.crossings+=x,N.lastSource!==p&&(N.count+=x,N.lastSource=p))}}let l=0;for(let p of o.values())p.crossings>l&&(l=p.crossings);let d=_e,f=60,u=p=>l<=1?d:d+(f-d)*Math.sqrt(p/l),m=[],h=0;for(let p of o.values()){let g=s+h,x=n==="haplotype"?{count:p.count,total:r}:void 0,b=x===void 0?"":` (${js(x)})`,M=p.crossings===p.count?"":`, ${p.crossings.toLocaleString()} crossings`,w=`${p.count.toLocaleString()} ${n}${p.count===1?"":"s"}${b}${M}: Node ${p.sName} \u2192 Node ${p.dName}`;e.coarsenedEdgeMeta.set(g,{count:p.count,label:w});let v=e.nodes[Math.abs(p.sSigned)].sequenceLength;m.push({id:g,sourceTrackID:p.sourceTrackID,type:"read",name:w,sequence:[p.sName,p.dName],indexSequence:[],path:[],width:u(p.crossings),firstNodeOffset:v,finalNodeCoverLength:0,sequenceNew:[{nodeName:p.sName,mismatches:[]},{nodeName:p.dName,mismatches:[]}],mapping_quality:0,is_secondary:!1,sample_name:null,read_group:null,score:p.count,haplotypeShare:x}),h+=1}if(Pn){let p="?",g=0;e.nodes.forEach(x=>{x.contentHeight>g&&(g=x.contentHeight,p=x.name)}),te(`[coarsened] ${n}s_in=${t.length} edges_out=${m.length} tallestNodeBeforePlace=${p}(${g.toFixed(1)})`)}return{bands:m,total:r}}function zs(e,t){let n=e.trackForRuler===void 0?-1:e.tracks.findIndex(d=>d.name===e.trackForRuler),s=n===-1?0:n,o=e.tracks[s],r=(o.freq??1)-1,i=Ks(e,o),a=e.tracks.filter((d,f)=>f!==s).map(d=>Us(i,d));if(r>0&&a.push({...o,freq:r}),a.length===0)return;let{bands:c,total:l}=Gn(e,a,"haplotype",t);return c.length>0?{ref:o,bands:c,total:l}:void 0}function Us(e,t){let n=0;for(let s of t.indexSequence){let o=e[Math.abs(s)];o!==void 0&&o!==0&&(n+=o===Math.sign(s)?1:-1)}return n>=0?t:{...t,sequence:t.sequence.map(st).reverse(),indexSequence:t.indexSequence.map(s=>-s).reverse()}}function Ks(e,t){let n=new Int8Array(e.nodes.length);for(let s of t.indexSequence){let o=Math.abs(s);n[o]===0&&(n[o]=Math.sign(s))}return n}function js({count:e,total:t}){let n=e/t;return n<.01?"<1%":n>.99&&e<t?">99%":`${Math.round(n*100)}%`}var In=7;function Tn(e,t,n,s,o,r,i,a,c,l){let d=t===1?e.extraRight:e.extraLeft,f=10*d[a],u=n+t*(f+5),m=In,h=Math.min(In,r),p=Math.min(s,o),g=Math.max(s,o),x=t===1?n:u-1,b=t===1?u:n,M=E=>{e.shapes.verticalRectangles.push({xStart:x,yStart:E,xEnd:b,yEnd:E+r-1,id:i,name:l,type:c})};M(s),e.shapes.verticalRectangles.push({xStart:t===1?u+m:u-m-h,yStart:p+r+m-1,xEnd:t===1?u+m+h-1:u-m-1,yEnd:g-m+1,id:i,name:l,type:c}),M(o);let w=u+t*m,v=u+t*(m+h),y=`M ${u} ${g}`;y+=` Q ${w} ${g} ${w} ${g-m}`,y+=` H ${v}`,y+=` Q ${v} ${g+r} ${u} ${g+r}`,y+=" Z ",e.shapes.corners.push({path:y,id:i,type:c}),y=`M ${u} ${p}`,y+=` Q ${v} ${p} ${v} ${p+r+m}`,y+=` H ${w}`,y+=` Q ${w} ${p+r} ${u} ${p+r}`,y+=" Z ",e.shapes.corners.push({path:y,id:i,type:c}),d[a]+=1}function Vs(e){let t=e.x-4,n=e.x+e.pixelWidth+4;return[t,n]}function Cn(e){switch(e.config.nodeWidthOption){case"compressed":e.nodes.forEach(t=>{t.width=1+Math.log2(Math.max(t.sequenceLength,1)),t.pixelWidth=Math.round((t.width-1)*8.401)});break;case"small":e.nodes.forEach(t=>{t.width=t.sequenceLength/100,t.pixelWidth=Math.max(Math.round((t.width-1)*8.401),0)});break;case"fixed":e.nodes.forEach(t=>{t.width=10,t.pixelWidth=Math.round(t.width*8.401)});break;case"normal":{let t=e.config.charWidth;e.nodes.forEach(n=>{n.width=n.sequenceLength,n.pixelWidth=Math.round(t*Math.max(n.sequenceLength-1,0))});break}default:throw new Error(`${e.config.nodeWidthOption} not implemented`)}}var j=0;function $n(e){return{first:new Int32Array(e),count:new Uint8Array(e)}}function k(e,t,n){let s=e.count[t];s===0?(e.first[t]=n,e.count[t]=1):s===1&&e.first[t]!==n&&(e.count[t]=2)}function ie(e,t){return e.count[t]===1?Math.abs(e.first[t]):0}function Qs(e){let t=$n(e.nodes.length),n=$n(e.nodes.length),s=new Map,o=f=>{let u=s.get(f);if(u===void 0){let m=e.nodeMap.get(I(f));u=O(f)?-m:m,s.set(f,u)}return u};e.tracks.concat(e.reads).forEach(f=>{let{sequence:u}=f,m=f.type==="haplotype",h=u.length-1,p=j,g=h>=0?o(u[0]):j;for(let x=0;x<=h;x+=1){let b=x<h?o(u[x+1]):j;if(g>0)x>0?(k(t,g,p),p<0&&k(t,g,-p)):m&&k(t,g,j),x<h?(k(n,g,b),b<0&&k(n,g,-b)):m&&k(n,g,j);else{let M=-g;x>0?(k(n,M,-p),p>0&&k(n,M,p)):m&&k(n,M,j),x<h?(k(t,M,-b),b>0&&k(t,M,b)):m&&k(t,M,j)}p=g,g=b}});let i=new Uint8Array(e.nodes.length);e.nodes.forEach((f,u)=>{Zs(u,t,n)!==0&&(i[u]=1)});let a=new Int32Array(e.nodes.length),c=new Float64Array(e.nodes.length),l=new Float64Array(e.nodes.length);e.nodes.forEach((f,u)=>{if(i[u]!==1){a[u]=u,l[u]=f.sequenceLength;for(let m=u;Js(m,t,n);)m=ie(n,m),a[m]=u,c[m]=f.sequenceLength,f.sequenceLength+=e.nodes[m].sequenceLength,f.seq+=e.nodes[m].seq,l[m]=f.sequenceLength}}),e.reads.forEach(f=>{let{sequence:u}=f,m=f.sequenceNew??u.map(M=>({nodeName:M,mismatches:[]})),h=M=>{let w=Math.abs(o(M));return O(M)?e.nodes[a[w]].sequenceLength-l[w]:c[w]},p=u.length-1;f.firstNodeOffset=(f.firstNodeOffset??0)+h(u[0]),f.finalNodeCoverLength=(f.finalNodeCoverLength??0)+h(u[p]);let g=[],x=[],b=[];u.forEach((M,w)=>{let v=Math.abs(o(M)),{mismatches:y}=m[w],E=h(M);if(y.forEach(S=>{S.pos+=E}),i[v]===1&&!O(M)&&w>0)x.at(-1).mismatches.push(...y);else if(i[v]===1&&O(M)&&w<p)b.push(...y);else{let S=e.nodes[a[v]].name,N=O(M)?Fn(S):S;g.push(N),x.push({nodeName:N,mismatches:b.concat(y)}),b=[]}}),f.sequence=g,f.sequenceNew!==void 0&&(f.sequenceNew=x)}),e.tracks.forEach(f=>{let{sequence:u}=f,m=0;for(let h of u)i[Math.abs(o(h))]===0&&(u[m]=h,m+=1);u.length=m});let d=1;for(let f=1;f<e.nodes.length;f+=1)i[f]===0&&(e.nodes[d]=e.nodes[f],d+=1);e.nodes.length=d}function Zs(e,t,n){let s=ie(t,e);return s!==0&&ie(n,s)!==0?s:0}function Js(e,t,n){let s=ie(n,e);return s!==0&&ie(t,s)!==0}function ea(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 ta(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 ft(e){return[e.nodeStart??-1,e.nodeEnd??-1,e.nodeStart===null?e.orderStart:-1,e.nodeEnd===null?e.orderEnd:-1]}function na(e,t){for(let n=0;n<e.length;n+=1){let s=e[n]-t[n];if(s!==0)return s}return 0}function zn(e,t){let n=ea(e.filter(s=>s.type===t),s=>ft(s).join(","));return n.forEach(s=>{let o=.3,r=.4/s.length;s.length<=5&&(o=.5,r=0),s.sort(ta),s.forEach(i=>{let a,c;i.yStart<i.yEnd?(a=i.xStart+(i.xEnd-i.xStart)*(1-o),o+=r,c=i.xStart+(i.xEnd-i.xStart)*(1-o)):(a=i.xStart+(i.xEnd-i.xStart)*o,o+=r,c=i.xStart+(i.xEnd-i.xStart)*o);let l=`M ${i.xStart} ${i.yStart}`;l+=` C ${a} ${i.yStart} ${a} ${i.yEnd} ${i.xEnd} ${i.yEnd}`,l+=` V ${i.yEnd+i.width}`,l+=` C ${c} ${i.yEnd+i.width} ${c} ${i.yStart+i.width} ${i.xStart} ${i.yStart+i.width}`,l+=" Z",i.path=l})}),[...n.values()].sort((s,o)=>na(ft(s[0]),ft(o[0]))).flat()}function Un(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,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,t+=` L ${n} ${s}`),t}function oa(e){let t=new Map;for(let[n,s]of e.pathVisits??[])for(let o of s){let r=`${o.path} ${n}`,i=t.get(r);i?i.push(o.strand):t.set(r,[o.strand])}return t}function ra(e){let t=new Map(e.nodes.map(r=>[r.id,r])),n=oa(e),s=(e.paths??[]).map((r,i)=>({path:r,index:i})),o=s.findIndex(r=>q(r.path.name).name===e.referencePath);return o>0&&s.unshift(...s.splice(o,1)),s.flatMap(({path:r,index:i})=>{let a=q(r.name).name,c=new Map,l=r.nodeIds.flatMap(d=>{let f=t.get(d);if(!f)return[];let u=c.get(f.name)??0;c.set(f.name,u+1);let m=n.get(`${a} ${f.name}`)?.[u]??et(f);return[tt(f,m)]});return l.length>0?[{id:i,name:r.name,sequence:l,sourceTrackID:0,type:"haplotype"}]:[]})}function sa(e){return e.nodes.map(t=>({name:t.id,seq:"",sequenceLength:Math.max(1,t.length)}))}function ne(e){return(e.paths?.length??0)>0}var aa=600,ia=3,ca=15;function la(e){return Math.max(ia,Math.min(ca,Math.floor(aa/Math.max(1,e))))}function Kn(e){let t=e.paths??[],n=ra(e),s=e.reads?xn(e,e.reads,t.length):[],o=s.length>0?Xt:Pt,r=t.map((a,c)=>o(c,t.length)),i=Bn(sa(e),n,s,{nodeWidthOption:"compressed",trackWidth:la(n.length)});return i?{layout:i,pathColors:r}:void 0}function dt(e){let t=[];return e.nodes.forEach(n=>{n.order>=0&&t.push(n)}),t}function jn(e,t,n,s){let o=e.y+e.contentHeight/2-t;return[{x:n,y:o},{x:s,y:o}]}function Vn(e,t){return{minY:e.bounds.minY-t,maxY:e.bounds.maxY-t}}function Qn(e){let t=ne(e)?Kn(e):void 0;if(!t)return;let{layout:n,pathColors:s}=t,o=n.bounds.minY,r={};for(let c of dt(n))r[c.name]=jn(c,o,c.x,c.x+c.pixelWidth);let{minY:i,maxY:a}=Vn(n,o);return{nodePositions:r,tubeMap:{layout:n,yOffset:o,pathColors:s},extent:{minX:n.bounds.minX,maxX:n.bounds.maxX,minY:i,maxY:a}}}function fa(e,t){let n=new Map(e.nodes.map(a=>[a.id,a])),s=new Map;for(let a of dt(t)){let c=s.get(a.order);c?c.push(a):s.set(a.order,[a])}let o=[],r=-1/0;for(let a of[...s.keys()].sort((c,l)=>c-l)){let c=s.get(a),l=1/0,d=-1/0;for(let f of c){let u=n.get(f.name);u&&L(u)&&(l=Math.min(l,u.stable.start),d=Math.max(d,u.stable.start+f.sequenceLength))}l===1/0&&(l=d=r),l<r&&(l=r,d=Math.max(r,d)),r=Math.max(r,d),o.push({order:a,x0:Math.min(...c.map(f=>f.x)),x1:Math.max(...c.map(f=>f.x+f.pixelWidth)),bp0:l,bp1:d})}let i=o.find(a=>a.bp0!==-1/0);for(let a of o)a.bp0===-1/0&&(a.bp0=a.bp1=i?.bp0??0);return o}function da(e){return e.nodes.some(L)&&ne(e)}function Zn(e){let t=da(e)?Kn(e):void 0;if(!t)return;let{layout:n,pathColors:s}=t,o=fa(e,n),r=new Map(o.map(c=>[c.order,c])),i=n.bounds.minY,a={};for(let c of dt(n)){let l=r.get(c.order);a[c.name]=jn(c,i,l.bp0,l.bp1)}return{nodePositions:a,tubeMap:{layout:n,yOffset:i,columns:o,pathColors:s},referenceAxis:!0,pixelRows:!0,extent:Vn(n,i)}}function ua(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 Jn(e,t){let n=G(e);if(n.length===0)return;let s=ae(n,t),o=ua(e),r=z(n),i=Le({graph:e,span:s,rowY:c=>(c.stable?o.get(c.stable.rank)??o.size:o.size)*_,positions:r}),a=[...o].map(([c,l])=>({label:c===0?"Reference (rank 0)":`Rank ${c}`,y:l*_}));return{nodePositions:r,rowLabels:a,referenceAxis:!0,pixelRows:!0,alleleDeletions:i}}var pa=12,ut=_;function eo(e){return 10+8*Math.log2(1+e.length)}function F(e,t){return e<t?-1:e>t?1:0}function no(e,t){return F(e.at,t.at)||F(e.side,t.side)||F(e.hops,t.hops)}var to={at:1/0,side:0,hops:0};function ha(e){let t=new Map(e.nodes.map(s=>[s.id,s])),n=xa(e);return e.nodes.map(s=>s.id).sort((s,o)=>no(n.get(s)??to,n.get(o)??to)||F(t.get(s).name,t.get(o).name)||F(s,o))}function ma(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 i=t[0]?.id,a=(d,f)=>{let u=o.get(d);o.set(d,f),r.set(f,d),o.set(f,u),u!==void 0&&r.set(u,f)},c=(d,f)=>{let u=r.get(d);u===void 0?(i=f,r.set(f,void 0),o.set(f,d),r.set(d,f)):a(u,f)};for(let d of e.paths??[]){let f=0,u=0,m;for(let x of d.nodeIds){let b=s.get(x);b!==void 0&&(m!==void 0&&b!==m&&(b>m?f++:u++),m=b)}let h=u>f?[...d.nodeIds].reverse():d.nodeIds,p,g=new Set;for(let x of h)if(o.has(x)){if(p===void 0)for(let b of g)c(x,b);p=x}else n.has(x)&&(p===void 0?g.add(x):(a(p,x),p=x))}let l=[];for(let d=i;d!==void 0;d=o.get(d))l.push(d);return l}function ga(e,t){let n=[...t.entries()].sort(([i,a],[c,l])=>no(a,l)||F(i,c)).map(([i])=>i),s=n.length;for(let i of n){let a=t.get(i);for(let c of e.get(i)??[])t.has(c)||(t.set(c,{at:a.at,side:1,hops:a.hops+1}),n.push(c))}let o=new Set(n.slice(s)),r=new Set;for(let i of o){if(r.has(i))continue;let{at:a}=t.get(i),c=[i];r.add(i);let l=!0;for(let d of c){let{hops:f}=t.get(d),u=!0,m=!1;for(let h of e.get(d)??[]){let p=t.get(h);p.at===a&&o.has(h)?(u&&=p.hops<=f,r.has(h)||(r.add(h),c.push(h))):p.at!==a&&(m||=p.at<a,l&&=p.at<a)}l&&=!u||m}if(l)for(let d of c){let f=t.get(d);t.set(d,{...f,side:-1,hops:-f.hops})}}}function xa(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(L).sort((r,i)=>F(r.stable.start,i.stable.start)||F(r.name,i.name)),o=new Map;return ma(e,s).forEach((r,i)=>{o.set(r,{at:i,side:0,hops:0})}),ga(n,o),o}function ba(e){let t=new Map(e.nodes.map(f=>[f.id,f])),n=ha(e),s=new Map(n.map((f,u)=>[f,u])),o=f=>L(t.get(f)),r=new Map(n.map(f=>[f,[]])),i=new Map(n.map(f=>[f,[]])),a=(f,u)=>{r.get(u).push(f),i.get(f).push(u)};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)?a(f.from,f.to):a(f.to,f.from));let c=n.filter(o);for(let f=1;f<c.length;f++)a(c[f-1],c[f]);let l=new Map;for(let f of n){let u=0;for(let m of r.get(f))u=Math.max(u,l.get(m)+1);l.set(f,u)}for(let f=n.length-1;f>=0;f--){let u=n[f],m=i.get(u);if(o(u)||m.length===0)continue;let h=1/0;for(let x of m)h=Math.min(h,l.get(x));let p=l.get(u),g=Math.max(p,h-1);l.set(u,Math.floor((p+g)/2))}let d=[];for(let f of n)(d[l.get(f)]??=[]).push(f);return{layers:d,layerOf:l,preds:r}}function oo(e){if(!e.nodes.some(L))return;let t=new Map(e.nodes.map(f=>[f.id,f])),n=f=>L(t.get(f)),{layers:s,layerOf:o,preds:r}=ba(e),i=s.map(f=>{let u=0;for(let m of f)u=Math.max(u,eo(t.get(m)));return u}),a=[],c=0;for(let f=0;f<s.length;f++)a[f]=c,c+=i[f]+pa;let l=new Map;for(let f of s){let u=[];for(let h of f){if(n(h)){l.set(h,0);continue}let p=r.get(h).filter(x=>l.has(x)),g=0;for(let x of p)g+=l.get(x)/p.length;u.push({id:h,ideal:g===0?ut:g})}u.sort((h,p)=>h.ideal-p.ideal);let m=new Set([0]);for(let{id:h,ideal:p}of u){let g=Math.round(p/ut);g===0&&(g=p>=0?1:-1);for(let x=1;m.has(g);x++)m.has(g+x)?m.has(g-x)||(g-=x):g+=x;m.add(g),l.set(h,g*ut)}}let d={};for(let f of e.nodes){let u=o.get(f.id),m=eo(f),h=a[u]+i[u]/2,p=l.get(f.id);d[f.id]=[{x:h-m/2,y:p},{x:h+m/2,y:p}]}return{nodePositions:d,referenceAxis:!1,pixelRows:!0}}function ro(e){return e.sample??he(e.name)}function ya(e){return e.haplotype!==void 0&&e.sample!==void 0?`${e.sample}#${e.haplotype}`:ro(e)}function wa(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((i,a)=>i+(t.get(a)??0),0);s=o.start===void 0?void 0:o.start+r}return n}function Ma(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 i of o.nodeIds){let a=t.get(i)??0;n.push({start:r,end:r+a}),r+=a}s=r}return n}function va(e,t,n,s=!0){if(!n||!s)return{ids:e,complete:!0,from:-1,to:-1};let o=-1,r=-1,i=-1/0,a=1/0;if(e.forEach((l,d)=>{let f=typeof l=="string"?t.get(l):void 0;f&&(f.end<=n.start&&f.end>i&&(i=f.end,o=d),f.start>=n.end&&f.start<a&&(a=f.start,r=d))}),o<0||r<0)return{ids:e,complete:!1,from:-1,to:-1};let c=e.slice(Math.min(o,r)+1,Math.max(o,r));return{ids:o<r?c:c.reverse(),complete:!0,from:o,to:r}}function Ef(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 so(e,t,n){let s=e.paths??[],o=g=>q(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),i=r[0],a=s.filter(g=>!r.includes(g));if(!i||a.length===0)return;let c=new Map;for(let g of a)c.set(g.name,[...c.get(g.name)??[],g]);let l=new Map(e.nodes.map(g=>[g.id,g.length])),d=i.start??0,f=t&&t.end>t.start?t:void 0,u=new Map;for(let g of r){let x=g.start??0;for(let b of g.nodeIds){let M=l.get(b)??0;u.has(b)||u.set(b,{start:x,end:x+M}),x+=M}}let m=f===void 0||[...u.values()].some(g=>g.end<=f.start)&&[...u.values()].some(g=>g.start>=f.end),h=g=>{let x=g[0],b=[...g].sort((B,H)=>(B.start??0)-(H.start??0)),{ids:M,complete:w,from:v,to:y}=va(wa(b,l),u,f,m),E=Ma(b,l),S=x.contig??me(q(x.name).name),N=E?.length?v<0?{contig:S,start:E[0].start,reversed:!1}:v<y?{contig:S,start:E[v].end,reversed:!1}:{contig:S,start:E[v].start,reversed:!0}:void 0,T=[],A=0,re=0,de=0,Y=0;for(let B of M){if(typeof B=="number"){T.push({start:A,bp:B,onReference:!1,gap:!0}),A+=B,de+=B,Y=0;continue}let H=l.get(B)??0,C=u.get(B),$=T.at(-1),ue=$?.referenceStart,qe=C&&ue!==void 0&&Y>=0&&ue+$.bp===C.start,lr=C&&ue!==void 0&&Y<=0&&C.end===ue;!C&&$&&!$.onReference&&!$.gap?$.bp+=H:qe||lr?($.bp+=H,qe||($.referenceStart=C.start,$.reversed=!0),Y=qe?1:-1):(T.push({start:A,bp:H,onReference:C!==void 0,referenceStart:C?.start}),Y=0),A+=H,C||(re+=H)}return{name:x.name,label:ya(x),sample:ro(x),haplotype:x.haplotype,bp:A,offReferenceBp:re,gapBp:de,complete:w,runs:T,axis:N}};return{origin:f?f.start:d,unit:n,reference:h(r),rows:[...c.values()].map(h).sort((g,x)=>Number(x.complete)-Number(g.complete)||x.bp-g.bp||g.label.localeCompare(x.label))}}var Ea=1.3;function Sa(e,t={rowPx:_,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?Ea:1),maxY:e.rows.length*t.rowPx}}function _f(e,t,n){return e?n&&!n.labelled?[]:[e.reference,...e.rows].map((s,o)=>({label:s.label,y:o*(n?.rowPx??_)})):t?.rowLabels??[]}function ao(e,t){let n=G(e),s=so(e,t);if(n.length===0||!s)return;let o=t?n.filter(a=>We(a,t)):n,r=z(o.length>0?o:n),i=[{label:s.reference.label,y:0},...s.rows.map((a,c)=>({label:a.label,y:(c+1)*_}))];return{nodePositions:r,rowLabels:i,referenceAxis:!0,pixelRows:!0,extent:Sa(s)}}var fo="Force-directed layout",V=e=>e.nodes.some(L),io=e=>V(e)&&(e.paths?.length??0)>1,co=e=>V(e)&&ne(e),lo=e=>V(e)&&e.nodes.some(se),ke=[{value:"auto",label:"Anchored",description:"x is reference bp, one row per stable rank. Needs rGFA tags or a reference path.",run:Jn,cutMargins:!0,wholeWalks:!1,available:V,drawsLocally:V,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:wn,cutMargins:!0,wholeWalks:!1,available:lo,drawsLocally:lo,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:ao,cutMargins:!1,wholeWalks:!0,available:io,drawsLocally:io,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:oo,cutMargins:!1,wholeWalks:!1,available:V,drawsLocally:V,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:Qn,cutMargins:!1,wholeWalks:!1,available:ne,drawsLocally:ne,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:Zn,cutMargins:!0,wholeWalks:!1,available:co,drawsLocally:co,drawsNodes:!1},{value:"force",label:fo,description:"OGDF FMMM, via the external Bandage engine.",run:()=>{},cutMargins:!1,wholeWalks:!1,available:()=>!0,drawsLocally:()=>!1,drawsNodes:!0}],Ra=ke.map(e=>e.value);function Na(e,t){return!uo(e).drawsLocally(t)}function uo(e){return ke.find(t=>t.value===e)??ke[0]}var Oe=8,pt=34,Ae=12,La=60;function _a({count:e,bounds:t,pixelRows:n,width:s,room:o,columns:r}){function i(c){let l=Math.ceil(e/c),d=Math.floor((s-(c-1)*Oe)/c),f=(o-l*pt-(l-1)*Oe)/l,u=(d-2*Ae)/t.w,m=t.h>0?(f-2*Ae)/t.h:1/0,h=n?u:Math.min(u,m),p=n?t.h:t.h*h,g=Math.floor(Math.max(La,Math.min(p+2*Ae,f)));return{columns:c,width:d,height:g,scale:h,total:l*(g+pt)+(l-1)*Oe}}if(r!==void 0)return i(Math.max(1,Math.min(e,Math.round(r))));let a=i(1);for(let c=2;c<=e;c++){let l=i(c);l.scale>a.scale&&(a=l)}return a}var ka=[{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 Oa(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 po(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 Aa(e,t,n=[]){let s=po(e,n),o={columns:void 0,count:e.length,cells:e.map(l=>s.indexOf(l))};if(t==="walk")return o;let r=e.map(l=>{let[d,f,u]=l.split("#"),m=Number(f);return u!==void 0&&Number.isInteger(m)&&m>=0?{sample:d,column:Math.max(0,m-1)}:void 0}),i=po([...new Set(r.flatMap(l=>l?[l.sample]:[]))],n),a=Math.max(1,...r.map(l=>l?l.column+1:1)),c=r.map(l=>l?i.indexOf(l.sample)*a+l.column:-1);return c.includes(-1)||new Set(c).size<c.length?o:{columns:a,count:i.length*a,cells:c}}var go=Q(mo(),1),Ie=16;function fd(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[i="",...a]=r.split(" ");i&&!o.has(i)&&o.set(i,{...Object.fromEntries(s.map((c,l)=>[c,a[l]??""])),name:i})}return[...o.values()]}function dd(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 ud(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 Ia(e){let t=new Set(e.map(n=>n.label)).size;return`${t} haplotype${t===1?"":"s"}`}function pd(e,t,{field:n,domain:s}){let o=new Map(t.map(c=>[c.name,c[n]??""])),r=new Map;for(let c of e){let l=o.get(c.label)||o.get(c.sample)||"",d=r.get(l);d?d.push(c):r.set(l,[c])}let i=1,a=[...r.keys()].sort((0,go.groupKeyComparator)(s)).map(c=>{let l=r.get(c),d={key:c,title:`${c||`${n}: none`} \xB7 ${Ia(l)}`,first:i,count:l.length};return i+=l.length,d});return{rows:a.flatMap(c=>r.get(c.key)),sections:a}}function hd(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)*Ie;return{rowY:s,headers:e.map((o,r)=>({...o,top:(o.first-.5)*t+r*Ie})),headersPx:e.length*Ie,rowAt(o,r){let i=0;for(let a=-1;a<e.length;a++){let c=a<0?0:e[a].first,l=a<0?Math.min(r,e[0]?.first??r):c+e[a].count,d=(a+1)*Ie,f=Math.min(l-1,Math.max(c,Math.round((o-d)/t)));Math.abs(s(f)-o)<Math.abs(s(i)-o)&&(i=f)}return i}}}var Ta=10;function Ca(e,t){let n=e.end-e.start,s=e.longestAlleleLength-e.shortestAlleleLength;return t.find(o=>s<=Ta*(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 $a=40;function W(e){return e>=1e4?`${(e/1e3).toFixed(0)} kb`:e>=1e3?`${(e/1e3).toFixed(1)} kb`:`${e} bp`}function Pa(e,t){let n=W(e),s=W(t),o=s.slice(s.indexOf(" "));return n.endsWith(o)?`${n.slice(0,-o.length)}\u2013${s}`:`${n}\u2013${s}`}function xo(e){return e>=qt?"\u22652.1B routes":e>=1e5?`${(e/1e3).toFixed(0)}k routes`:`${e} routes`}function Xa(e,t=[]){let n=Ba(e,t);return e.partial?{...n,label:`${n.label}, partial`}:n}function Ba(e,t){let n=e.end-e.start,{shortestAlleleLength:s,longestAlleleLength:o,pathCount:r,segmentCount:i,inversion:a}=e,c=Pa(s,o);if(i>=$a)return{kind:"superbubble",label:`${c} superbubble, ${i} segments, ${xo(r)}${a?", inv":""}`};if(a)return{kind:"inversion",label:`${W(o)} inv`};let l=o!==s?Ca(e,t):void 0;if(l){let f=l.name?` (${l.name})`:"";return{kind:"repeat",label:`${c} repeat array${f}, ${xo(r)}`}}let d=r>2?`, ${r} alleles`:"";return s===o&&s===n?n<=1?{kind:"snp",label:"SNP"}:{kind:"substitution",label:`${W(n)} sub`}:n===0||s===n?{kind:"insertion",label:`\u2264${W(o-n)} ins${d}`}:o===n?{kind:"deletion",label:`${W(n-s)} del${d}`}:{kind:"complex",label:`${W(n)} ref \u2192 ${c}, ${r} alleles`}}var Da={snp:"#5b6b7a",substitution:"#5b6b7a",insertion:"#2f8fd6",deletion:"#c94040",inversion:"#e07b00",repeat:"#8e3fbf",superbubble:"#8e3fbf",complex:"#8e3fbf"},qa={snp:"SNP",substitution:"substitution",insertion:"insertion",deletion:"deletion",inversion:"inversion",repeat:"repeat array",superbubble:"superbubble",complex:"site"};function Fa(e){return e.segments.split(",").filter(Boolean)}var mt="#2f8fd6",gt="#8e3fbf",xt="#bdbdbd",ce="#1c1c22",bt=12,yt=4,Te=12,Wa=6,Ya=3;function oe(e){return`${(e/1e3).toFixed(e<1e4?1:0)} kb`}function bo(e,t){return t?` \u2248 ${Math.round(e/t)} units`:""}function yo(e,t,n,s){let{bp:o,gapBp:r,complete:i}=e;if(!t)return`${oe(o)}${bo(o,n)}`;let a=o-t.bp,c=a===0?"":` (${a>0?"+":"\u2212"}${oe(Math.abs(a))})`,l=r>0?` \xB7 ${oe(r)} outside the cut`:"",d=s?` \xB7 called ${oe(s.bp)}${s.spanningReads===0?" \xB7 no spanning read":""}`:"";return`${oe(o)}${bo(o,n)}${c}${l}${i?"":" \xB7 partial walk"}${d}`}function wo(e,t,n){let s=t+6;return s+e.length*U<n?{x:s,anchor:"start",halo:!1}:{x:t-6,anchor:"end",halo:!0}}function Mo(e,t,n){if(t*n<Ya)return[];let s=[];for(let o=t;o<e;o+=t)s.push(o);return s}function vo(e,t){if(e.gap)return{fill:xt};if(!t)return{fill:e.onReference?mt:gt};if(e.referenceStart===void 0)return{fill:Se};let n=Yt({...e,start:e.referenceStart},t);return n.length===1?{fill:Re(n[0])}:{stops:n.map(Re)}}function le(e,t,n){return e.reversed?{start:e.start-n,end:e.start-t}:{start:t-e.start,end:n-e.start}}function Ha(e,t){return e.reversed?{start:e.start-t,end:e.start}:{start:e.start,end:e.start+t}}function Ga(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,i=({start:a,end:c})=>({start:Math.max(0,a),end:Math.min(s.bp,c)});n.set(s.name,o.map(a=>({name:a.name,...i(le(r,a.start,a.end)),exons:a.exons.map(c=>i(le(r,c.start,c.end))).filter(c=>c.end>c.start)})).filter(a=>a.end>a.start).sort((a,c)=>a.start-c.start))}return n}var za=9,Ua=5.2,Ka=8,Eo=(e,t)=>Math.min(2,(e-t)/2-1);function Ce(e,t){return Eo(e,t)>=1}function So(e,t,n,{rowPx:s=_,barPx:o=bt}={}){if(!Ce(s,o))return[];let r=Eo(s,o),i=e.map(l=>{let d=t(l.start);return{g:l,x:d,w:Math.max(2,t(l.end)-d)}}),a=[],c=new Set((o>=Ka?[...i]:[]).sort((l,d)=>l.w-d.w).filter(({g:l,x:d,w:f})=>{let u=l.name.length*Ua/2,m=[d+f/2-u,d+f/2+u];return 2*u>f+6||a.some(([h,p])=>m[0]<p+2&&m[1]>h-2)?!1:(a.push(m),!0)}));return i.map(l=>({name:l.g.name,x:l.x,y:n-o/2-r,w:l.w,h:o+2*r,exons:l.g.exons.map(d=>({x:t(d.start),w:Math.max(1,t(d.end)-t(d.start))})),label:c.has(l)?{x:l.x+l.w/2,y:n+3,size:za}:void 0}))}var ht=e=>`${e} row${e===1?"":"s"}`;function ja(e,t={}){let n=[{swatch:t.ramp?{kind:"bar",fill:t.rampCss??Ht,ramp:!0}:{kind:"bar",fill:mt},label:`on ${e.reference.label}'s path`},{swatch:{kind:"bar",fill:t.ramp?Se:gt},label:`off ${e.reference.label}'s path`}];return[e.reference,...e.rows].some(s=>s.gapBp>0)&&n.push({swatch:{kind:"gap",fill:xt},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 ${ht(t.genes.untracked)}`,note:!0}),t.genes.unplaced&&n.push({swatch:{kind:"gene"},label:`no contig coordinates for ${ht(t.genes.unplaced)}`,note:!0}),t.genes.unread&&n.push({swatch:{kind:"gene"},label:`genes not read for the last ${ht(t.genes.unread)}`,note:!0})),n}var Ro="#111",No="#9e9e9e",wt="#c62828";function Lo(e){return e.agrees===!1?wt:e.spanningReads===0?No:Ro}function Va(e,t,n,s="walk-key"){let o=0,r=e.flatMap((i,a)=>{let c=`${s}-ramp-${a}`,l=!i.note&&i.swatch.kind==="bar"&&i.swatch.ramp?R("linearGradient",{id:c},...Ve.map(u=>R("stop",{offset:u.offset,"stop-color":u.color}))):void 0,d=i.note?void 0:i.swatch.kind==="gene"?R("rect",{x:o,y:5,width:18,height:8,fill:"none",stroke:ce,"stroke-width":1.5}):R("rect",{x:o,y:i.swatch.kind==="gap"?7:5,width:18,height:i.swatch.kind==="gap"?yt:8,rx:2,fill:l?`url(#${c})`:i.swatch.fill}),f=R("text",{x:i.note?o:o+23,y:13,"font-style":i.note?"italic":void 0,fill:i.note?"#666":void 0},i.label);return o+=(i.note?0:23)+i.label.length*U+16,[l,d,f].filter(u=>u!==void 0)});return{width:o,tree:R("g",{transform:`translate(${t} ${n})`,"font-family":"Helvetica, Arial, sans-serif","font-size":11},...r)}}function Mt(e,t,n=0){let s=t/Math.max(1,e),o=Math.max(n,Math.min(_,s>=1?Math.floor(s):s));return{rowPx:o,barPx:o<=3?o:Math.max(3,Math.round(o*.6)),labelled:o>=Te,readouts:o>=Te}}function _o(e,t){let n=1/t,s=[],o=[],r=()=>{if(o.length!==0){if(o.length===1)s.push(o[0]);else{let a=0,c=0;for(let f of o)f.onReference?a+=f.bp:c+=f.bp;let l=a>=c,d=o.find(f=>f.onReference===l);s.push({start:o[0].start,bp:a+c,onReference:l,referenceStart:l?d.referenceStart:void 0,...d.reversed?{reversed:!0}:{}})}o=[]}},i=0;for(let a of e){if(a.gap||a.bp>=n){r(),i=0,s.push(a);continue}o.push(a),i+=a.bp,i>=n&&(r(),i=0)}return r(),s}function Qa(e,t,n){return R("g",{class:"row-gene","data-testid":"graph-walk-gene"},R("title",{},e.name),...e.exons.map(s=>R("rect",{x:s.x,y:t-n/2,width:s.w,height:n,fill:ce,opacity:.35})),R("rect",{x:e.x,y:e.y,width:e.w,height:e.h,fill:"none",stroke:ce,"stroke-width":1.5}),e.label&&R("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:ce,stroke:"white","stroke-width":2.5,"paint-order":"stroke"},e.name))}function Za(e,t,n={}){let s=p=>p*t.scaleX+t.translateX,o=t.rowPx??_,r=t.barPx??bt,i=Math.min(3,Math.max(0,(o-r)/2)),a=p=>p*o*t.scaleY+t.translateY,{origin:c,unit:l,reference:d,rows:f}=e,u=p=>s(c+p),m=n.idPrefix??"walkrow",h=(p,g)=>{let x=a(g);if(x<-r||x>t.height+r)return;let b=_o(p.runs,t.scaleX).flatMap(S=>{let N=vo(S,n.ramp),T=S.gap?Math.min(yt,r):r,A=`${m}-${g}-${S.start}`,re=R("rect",{x:u(S.start),y:x-T/2,width:Math.max(1,S.bp*t.scaleX),height:T,fill:"stops"in N?`url(#${A})`:N.fill});return"stops"in N?[R("linearGradient",{id:A},...N.stops.map((de,Y)=>R("stop",{offset:Y/(N.stops.length-1),"stop-color":de}))),re]:[re]}),M=l&&r>=Wa?Mo(p.bp,l,t.scaleX).map(S=>R("line",{x1:u(S),x2:u(S),y1:x-r/2,y2:x+r/2,stroke:"white","stroke-width":1})):[],{call:w}=p,v=yo(p,g===0?void 0:d,l,w),y=wo(v,u(p.bp),t.width),E=t.readouts??!0;return R("g",{"data-testid":g===0?"graph-walk-reference":"graph-walk-row"},...b,...M,...So(n.rowGenes?.get(p.name)??[],u,x,{rowPx:o,barPx:r}).map(S=>Qa(S,x,r)),w&&R("rect",{"data-testid":"graph-walk-call",x:u(w.bp)-1,y:x-r/2-i,width:2,height:r+2*i,fill:Lo(w)}),E&&R("text",{x:y.x,y:x+4,"font-family":"sans-serif","font-size":11,fill:w?.agrees===!1?wt:"#333",stroke:y.halo?"white":void 0,"stroke-width":y.halo?3:void 0,"paint-order":"stroke","text-anchor":y.anchor},v))};return R("g",{},...[d,...f].map(h))}function Ja(e){return e.walkStrip&&e.mode.drawsNodes&&!e.drawsPicture&&!e.popped&&!e.host&&e.walks>1}function ei(e,t){return e.wholeWalks||t.walkStrip&&!t.host}var fe=6,Ao=260,ti=11,ni=3,oi=1.3,ri="#111",ko=3;function si(e,t,n){let s=e.pathVisits?.get(n.name)??[],o=[];for(let r of t){let i=r.axis;if(!i)continue;let a=q(r.name).name;for(let c of s){if(c.path!==a)continue;let{start:l,end:d}=le(i,c.start,c.start+n.length);d>0&&l<r.bp&&o.push({row:r.name,start:l,bp:d-l})}}return o}var Oo=new WeakMap;function ai(e,t){let n=Oo.get(e);if(n||(n=new Map,Oo.set(e,n)),n.has(t))return n.get(t);let s=new Map(e.nodes.map(i=>[i.id,i.length])),o=(e.paths??[]).filter(i=>i.name===t),r;if(o.every(i=>i.start!==void 0)){r={ids:[],starts:[],ends:[]};for(let i of[...o].sort((a,c)=>a.start-c.start)){let a=i.start;for(let c of i.nodeIds){let l=s.get(c)??0;r.ids.push(c),r.starts.push(a),r.ends.push(a+l),a+=l}}}return n.set(t,r),r}function ii(e,t,n,s){let o=t.axis,r=o&&ai(e,t.name);if(!o||!r||n<0||n>t.bp)return;let i=o.reversed?o.start-n:o.start+n,a=.5/s,c=o.reversed?{start:o.start-t.bp,end:o.start}:{start:o.start,end:o.start+t.bp},l=Math.max(i-a,c.start),d=Math.min(i+a,c.end),f=0,u=r.starts.length;for(;f<u;){let g=f+u>>1;r.ends[g]<=l?f=g+1:u=g}let m,h=-1,p=!1;for(let g=f;g<r.starts.length&&r.starts[g]<d;g++){let x=r.ends[g]-r.starts[g],b=r.starts[g]<=i&&i<r.ends[g];(x>h||x===h&&b&&!p)&&(h=x,m=r.ids[g],p=b)}return m}function ci(e,t){let n=t.maxHeight??Ao,s=t.labelPx??Math.max(...[e.reference,...e.rows].map(m=>m.label.length))*U+16,o=e.rows.length+1,{rowPx:r,barPx:i,labelled:a,readouts:c}=Mt(o,n-2*fe,ni),l=Math.max(e.reference.bp,...e.rows.map(m=>m.bp),1),d=a?s:fe,u=Math.max(1,t.width-d-fe)/(l*(c?oi:1));return{scaleX:u,scaleY:1,translateX:d-e.origin*u,translateY:fe+r/2,width:t.width,height:o*r+2*fe,rowPx:r,barPx:i,readouts:c,labelled:a,boxesGenes:Ce(r,i)}}function li(e,t,n,s){let o=Math.round((s-t.translateY)/t.rowPx),r=[e.reference,...e.rows][o],i=(n-t.translateX)/t.scaleX-e.origin;return r&&o>=0&&i>=0&&i<=r.bp?{index:o,row:r,offset:i}:void 0}function fi(e,t,n){let s=new Map([e.reference,...e.rows].map((r,i)=>[r.name,i])),o=r=>(e.origin+r)*t.scaleX+t.translateX;return R("g",{"data-testid":"graph-walk-marks"},...n.flatMap(r=>{let i=s.get(r.row);if(i===void 0)return[];let a=i*t.rowPx+t.translateY,c=o(r.start),l=Math.max(2,r.bp*t.scaleX),d=f=>R("rect",{x:c,y:f,width:l,height:ko,fill:ri});return[d(a-t.barPx/2-ko-1),d(a+t.barPx/2+1)]}))}function di(e,t,n=new Set){return R("g",{"font-family":"sans-serif","font-size":ti,fill:"#333"},...(t.labelled?[e.reference,...e.rows]:[]).map((s,o)=>R("text",{x:6,y:o*t.rowPx+t.translateY+4,"font-weight":n.has(s.name)?600:void 0},s.label)))}function ui(e,t,n){if(t?.size)return e.boxesGenes?n:{untracked:0,unread:0,...n,crowded:!0}}var Co=2,$e=8192;function $o(){return typeof devicePixelRatio>"u"?1:Math.min(devicePixelRatio,Co)}var Io=!1;function To(e,t,n){let s=Math.round(e*t);return s>$e?(Io||(Io=!0,console.warn(`Canvas ${n} ${s}px exceeds the safe limit ${$e}px and was clamped`)),$e):s}function vt(e,t,n){let s=$o(),o=To(t,s,"width"),r=To(n,s,"height");(e.width!==o||e.height!==r)&&(e.width=o,e.height=r);let i=`${t}px`,a=`${n}px`;e.style.width!==i&&(e.style.width=i),e.style.height!==a&&(e.style.height=a)}var tu=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){vt(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=Bt([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 Et(e.edgeCurves,(i,a)=>({color:Pe(s,a)?Me(i.color,this.highlightFactor):i.color,weight:i.thickness,last:Pe(s,a)}))){n.strokeStyle=K(o),n.lineWidth=r[0].thickness*2*t.dpr,n.beginPath();for(let i of r){let a=i.curves[0];n.moveTo(a.x0*t.scaleX+t.translateX,a.y0*t.scaleY+t.translateY);for(let c of i.curves)n.bezierCurveTo(c.cx0*t.scaleX+t.translateX,c.cy0*t.scaleY+t.translateY,c.cx1*t.scaleX+t.translateX,c.cy1*t.scaleY+t.translateY,c.x1*t.scaleX+t.translateX,c.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 i=e.nodeStrokeRuns.get(o);if(i)for(let a=i.start;a<i.start+i.count;a++)s.set(a,r)}for(let{color:o,items:r}of Et(e.nodeStrokes,(i,a)=>{let c=s.get(a);return{color:c===void 0?i.color:Me(i.color,c),weight:i.thickness,last:c!==void 0}})){n.strokeStyle=K(o),n.lineWidth=r[0].thickness*2*t.dpr,n.beginPath();for(let i of r){let a=i.points[0];n.moveTo(a.x*t.scaleX+t.translateX,a.y*t.scaleY+t.translateY);for(let c=1,l=i.points.length;c<l;c++){let d=i.points[c];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 Et(e.arrows,(i,a)=>({color:Pe(s,a)?Me(i.color,this.highlightFactor):i.color,weight:0,last:Pe(s,a)}))){n.fillStyle=K(o),n.beginPath();for(let i of r){let[a,c,l,d]=hi(i,t);n.moveTo(a.x,a.y),n.lineTo(c.x,c.y),n.lineTo(l.x,l.y),n.lineTo(d.x,d.y),n.closePath()}n.fill()}}dispose(){this.batch=null,this.nodeHighlights=new Map,this.highlightedEdge=null}},pi=.25;function hi(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,i=e.length*t.dpr,a=e.halfWidth*t.dpr,c=o-n*i,l=r-s*i,d=i*(1-pi);return[{x:o,y:r},{x:c-s*a,y:l+n*a},{x:o-n*d,y:r-s*d},{x:c+s*a,y:l-n*a}]}function Pe(e,t){return e!==void 0&&t>=e.start&&t<e.start+e.count}function Et(e,t){let n=new Map,s=new Map;for(let o=0,r=e.length;o<r;o++){let i=e[o],{color:a,weight:c,last:l}=t(i,o),d=l?s:n,f=`${a}:${c}`,u=d.get(f);u?u.items.push(i):d.set(f,{color:a,items:[i]})}return[...n.values(),...s.values()]}function St(e,t,n){let s=Math.round(t),o=Math.round(n);return`${e?`${e}:`:""}${J(s)}-${J(o)} (${D(o-s)})`}function mi(e,t){let{field:n}=e.encoding,s=e.range?St(e.range.contig,e.range.start,e.range.end):void 0,o=n==="progress"?s:n==="reference"&&t?St(t.name,t.start,t.end):void 0,r=e.range?e.range.end-e.range.start:e.bp,i=r-e.bp;return{delta:e.referenceBp===void 0||r===e.referenceBp?"":` ${r>e.referenceBp?"+":"\u2212"}${D(Math.abs(r-e.referenceBp))}`,outside:i>0?`, ${D(i)} outside the cut`:"",reversed:e.reversedBp>0?`, ${D(e.reversedBp)} reversed`:"",shades:n!=="walk",scale:o,hover:o===s?void 0:s}}function gi(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}:${J(r)}-${J(r+n)}`}function xi(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&&L(r)){let{refName:i,start:a}=r.stable;(s.get(i)??s.set(i,[]).get(i)).push({bp0:a,bp1:a+o.sequenceLength,x0:o.x,x1:o.x+o.pixelWidth})}});for(let o of s.values())o.sort((r,i)=>r.bp0-i.bp0);return s}function Xe(e,t,n=!1){let s=0,o=e.length-1;for(;s<o;){let a=s+o>>1,c=e[a].bp1;(n?c<t:c<=t)?s=a+1:o=a}let r=e[s];if(t<=r.bp0)return r.x0;let i=r.bp1-r.bp0;return i>0?r.x0+(Math.min(t,r.bp1)-r.bp0)/i*(r.x1-r.x0):r.x0}function Be(e,t,n){let s=Xe(e,t),o=Xe(e,n,!0);return{x0:Math.min(s,o),x1:Math.max(s,o)}}function bi(e){let t;for(let n of e.values())(!t||n.length>t.length)&&(t=n);return t}var Po=5,yi=10,wi=110,Mi=3;function Xo(e){return e?"#b0b0b8":"#55555c"}function vi(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 Bo(e){let t=[];for(let n of e)t.every(s=>Math.abs(n.at-s.at)>=(n.width+s.width)/2+yi)&&t.push(n);return t.map(({text:n,at:s})=>({text:n,at:s}))}function Ei(e,t,n,s){let o=e[0],r=e.at(-1);if(!o||!r)return;let i=t(o.x0),a=t(r.x1),c=r.bp1-o.bp0;if(a<=i||c<=0)return;let l=vi(c/(a-i)*wi),d=[],f=[];for(let u=Math.ceil(o.bp0/l)*l;u<=r.bp1;u+=l){let m=Math.round(t(Xe(e,u)))+.5;if(m>=0&&m<=n){d.push(m);let h=u.toLocaleString("en-US");f.push({text:h,at:m,width:s(h)})}}return{spans:[{x0:i,x1:a}],ticks:d,labels:Bo(f)}}function Si(e,t,n,s){let o=e.map(h=>({box:h,s0:t(h.x0),s1:t(h.x1)})).filter(({s0:h,s1:p})=>p>=0&&h<=n),r=o[0],i=o.at(-1);if(!r||!i)return;let a=(h,p)=>({text:h,at:p,width:s(h)}),c=(h,p)=>a(h.toLocaleString("en-US"),p),l=[],d=[],f=[],u=[];for(let{box:h,s0:p,s1:g}of o){l.push({x0:p,x1:g}),d.push(Math.round(p)+.5),g-p>=Mi&&d.push(Math.round(g)+.5);let x=a(D(h.bp1-h.bp0),(p+g)/2);x.width<=g-p&&f.push(x),h!==r.box&&u.push(c(h.bp0,p))}let m=[c(r.box.bp0,r.s0),c(i.box.bp1,i.s1)];return{spans:l,ticks:d,labels:Bo([...m,...f,...u])}}function Do(e,t,n,s,o=!1){return(o?Ei:Si)(e,t,n,s)}function Ri(e,t,n,s,o=!1){let{x:r,width:i,darkMode:a}=n;e.font="10px sans-serif";let c=Do(t,r,i,f=>e.measureText(f).width,o);if(!c)return;let l=Xo(a),d=s+.5;e.strokeStyle=l,e.fillStyle=l,e.lineWidth=1,e.textAlign="center",e.textBaseline="top",e.beginPath();for(let{x0:f,x1:u}of c.spans)e.moveTo(Math.max(0,f),d),e.lineTo(Math.min(i,u),d);for(let f of c.ticks)e.moveTo(f,s),e.lineTo(f,s+Po);e.stroke();for(let{text:f,at:u}of c.labels)e.fillText(f,u,s+Po+2)}function Ni(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&&L(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 Li(e,t,n,s){let o=[];for(let r of e){let i=n(r.x0),a=n(r.x1);a>=0&&i<=s&&o.push({node:r.node,top0:t(r.bp0),top1:t(r.bp1),bottom0:i,bottom1:a})}return o}var _i=3;function ki(e,t,n,s){if(t<=0||s<0||s>t)return;let o=s/t,r,i=_i;for(let a of e){let c=a.top0+(a.bottom0-a.top0)*o,l=a.top1+(a.bottom1-a.top1)*o,d=Math.max(0,Math.min(c,l)-n,n-Math.max(c,l));d<i&&(i=d,r=a.node)}return r}function qo(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 Fo(e,t,n){e.moveTo(t.top0,0),e.lineTo(t.bottom0,n),e.moveTo(t.top1,0),e.lineTo(t.bottom1,n)}function Oi(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 a of t)qo(e,a,n);e.fillStyle=`rgba(${r},0.07)`,e.fill(),e.beginPath();for(let a of t)Fo(e,a,n);e.strokeStyle=`rgba(${r},0.35)`,e.lineWidth=.5,e.stroke();let i=t.find(a=>a.node===s);i&&(e.beginPath(),qo(e,i,n),e.fillStyle="rgba(255,192,203,0.5)",e.fill(),e.beginPath(),Fo(e,i,n),e.strokeStyle="#ff0000",e.lineWidth=1,e.stroke())}function Ai(e,t){let n=[],s=e.sequenceNew??[];return s.forEach((o,r)=>{let i=t.nodeMap.get(I(o.nodeName)),a=i===void 0?void 0:t.nodes[i],c=r;for(;c<e.path.length&&e.path[c].node!==i;)c+=1;let l=e.path[c]?.y;if(a&&l!==void 0){let d={readId:e.id,y:l,height:e.width,nodeY:a.y},f=u=>Yn(a,u);for(let u of o.mismatches){let m=f(u.pos);if(m!==null){if(u.type==="insertion"){let h=r===0&&u.pos===e.firstNodeOffset||r===s.length-1&&u.pos===e.finalNodeCoverLength;n.push({...d,kind:"insertion",x:m,seq:u.seq,softClip:h})}else if(u.type==="deletion"&&u.length!==void 0){let h=f(u.pos+u.length);h!==null&&n.push({...d,kind:"deletion",x0:m,x1:h})}else if(u.type==="substitution"&&u.seq!==void 0){let h=f(u.pos+u.seq.length);h!==null&&n.push({...d,kind:"substitution",x0:m,x1:h,seq:u.seq})}}}}}),n}function Wo(e){return e.reads.flatMap(t=>Ai(t,e))}function Nt(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 Uo(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 Yo(e,t,n){let s=Nt(e);return{commands:s,color:t,track:n,...Uo(s)}}function Ko(e,t){return new Map(e.tracks.map(n=>[n.id,n.type==="read"?bn(n):t[n.id]]))}function Ho(e,t,n){let{shapes:s}=e,o=l=>n.get(l.id),r=l=>t==="haplotype"?l.id:void 0,i=[...s.rectangles,...s.verticalRectangles].filter(l=>l.type===t).map(l=>({color:o(l),track:r(l),x0:l.xStart,x1:l.xEnd+1,y0:l.yStart,y1:l.yEnd+1})),a=zn(s.curves,t).map(l=>Yo(l.path,o(l),r(l))),c=s.corners.filter(l=>l.type===t).map(l=>Yo(l.path,o(l),r(l)));return{rects:i,shapes:[...a,...c]}}function Ii({layout:e,pathColors:t}){let n=Ko(e,t),s=[];return e.nodes.forEach(o=>{if(o.order>=0){let r=Nt(Un(o));s.push({name:o.name,commands:r,...Uo(r)})}}),{bounds:e.bounds,layers:[Ho(e,"haplotype",n),Ho(e,"read",n)],nodes:s,mismatches:Wo(e).filter(o=>o.kind!=="insertion"||!o.softClip)}}function Go(e,t,n,s){let o=0,r=0;for(let i of t)switch(i.op){case"M":o=i.x,r=i.y,e.moveTo(n(o),s(r));break;case"L":o=i.x,r=i.y,e.lineTo(n(o),s(r));break;case"H":o=i.x,e.lineTo(n(o),s(r));break;case"V":r=i.y,e.lineTo(n(o),s(r));break;case"Q":o=i.x,r=i.y,e.quadraticCurveTo(n(i.x1),s(i.y1),n(o),s(r));break;case"C":o=i.x,r=i.y,e.bezierCurveTo(n(i.x1),s(i.y1),n(i.x2),s(i.y2),n(o),s(r));break;case"Z":e.closePath();break}}function zo(e,t,n,s,o){let r=new Map;for(let i of t)if(n(i)){let a=s(i),c=r.get(a);c?c.push(i):r.set(a,[i])}for(let i of r.values()){e.fillStyle=s(i[0]),e.beginPath();for(let a of i)o(a);e.fill()}}var Ti=12,Ci=.15;function $i(e){return Math.max(Ci,Math.min(1,e/Ti))}var Pi=.55;function Xi(e,t,n){let{x:s,y:o,width:r}=n,i=d=>s(d.x1)>=0&&s(d.x0)<=r,a=d=>d.track!==void 0&&n.tubeColors?.[d.track]||d.color;e.globalAlpha=1;for(let d of t.layers)zo(e,d.rects,i,a,f=>{let u=s(f.x0),m=o(f.y0);e.rect(u,m,s(f.x1)-u,o(f.y1)-m)}),zo(e,d.shapes,i,a,f=>{Go(e,f.commands,s,o)});let c=n.darkMode?"#d0d0d0":"#000000",l=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(i(d)){let f=d.name===n.highlightNode;e.beginPath(),Go(e,d.commands,s,o);let u=f?void 0:n.nodeColors?.get(d.name);e.fillStyle=f?"rgba(255,192,203,0.5)":u??l,e.strokeStyle=f?"#ff0000":c,e.globalAlpha=u?Pi:1,e.fill(),e.globalAlpha=f?1:$i(s(d.x1)-s(d.x0)),e.stroke(),e.globalAlpha=1}Di(e,t.mismatches,n)}var jo=12,Bi=6;function Vo(e){return jo*e>=Bi}function Rt(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 Di(e,t,n){let{x:s,y:o,yScale:r,darkMode:i}=n;if(!Vo(r)||t.length===0)return;let a=jo*r;e.fillStyle="grey",e.beginPath();for(let c of t)if(c.kind==="deletion"&&Rt(c,n)){let l=s(c.x0),d=o(c.y);e.rect(l,d,s(c.x1)-l,o(c.y+c.height)-d)}e.fill(),e.font=`${a}px monospace`,e.textBaseline="alphabetic",e.fillStyle=i?"#ffffff":"#000000";for(let c of t)Rt(c,n)&&(c.kind==="substitution"?e.fillText(c.seq,s(c.x0)+1,o(c.y+c.height)):c.kind==="insertion"&&e.fillText("*",s(c.x)-3,o(c.y+c.height)))}function qi(e,t){let n=[];for(let s of t){let o=e.get(s.refName),r=o?.[0],i=o?.at(-1);if(!o||!r||!i)continue;let a=Math.max(s.start,r.bp0),c=Math.min(s.end,i.bp1);c<=a||n.push({gene:s,...Be(o,a,c),exons:s.exons.filter(l=>l.end>a&&l.start<c).map(l=>Be(o,Math.max(l.start,a),Math.min(l.end,c)))})}return n}var Lt=22,Fi=4,De=8,Wi="11px sans-serif",Yi=8;function Hi(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(Fi,s)}function Gi(e,t,n,s,o=0){let{x:r,width:i,darkMode:a}=n,c=Math.max(1,Math.floor((s-o)/Lt)),l=[],d=a?"#e0e0e6":"#1c1c22";e.font=Wi,e.textAlign="center",e.textBaseline="alphabetic",e.fillStyle=d,e.strokeStyle=d,e.lineWidth=1;let f=t.map(u=>({g:u,s0:r(u.x0),s1:r(u.x1)})).filter(({s0:u,s1:m})=>m>=0&&u<=i).sort((u,m)=>u.s0-m.s0);for(let{g:u,s0:m,s1:h}of f){let p=u.gene.strand>0?" \u2192":u.gene.strand<0?"\u2190 ":"",g=u.gene.strand<0?`${p}${u.gene.name}`:`${u.gene.name}${p}`,x=(Math.max(m,0)+Math.min(h,i))/2,b=e.measureText(g).width/2,M=Math.min(m,x-b),w=Math.max(h,x+b),v=l.findIndex(E=>E+Yi<=M);v===-1&&(v=Math.min(l.length,c-1)),l[v]=Math.max(l[v]??-1/0,w);let y=s-v*Lt-De/2;e.beginPath(),e.moveTo(m,y+.5),e.lineTo(h,y+.5),e.stroke();for(let E of u.exons){let S=r(E.x0);e.fillRect(S,y-De/2,Math.max(1,r(E.x1)-S),De)}e.fillText(g,x,y-De/2-2)}}var X=12,tr=X+8,nr=8,Qo=nr+3,zi=12;function Ui(e,{colorScheme:t,referenceRamp:n,walks:s}){let o={...Ue(e),referenceRamp:n},r=[];return e.nodes.forEach((i,a)=>{if(L(i)){let c=s?s.map(l=>{let d=l.colors.get(i.id);return d===void 0?ve:K(d)}):[K(Ke(i,a,t,o))];r.push({node:i.id,bp0:i.stable.start,bp1:i.stable.start+i.length,colors:c,faded:c.includes(ve)})}}),r.sort((i,a)=>i.bp0-a.bp0)}function _t(e,t,n){let s=t*e.scale+e.translateX,o=n*e.scale+e.translateX;return s<o?[s,o]:[o,s]}var Zo=2;function or(e,t,n){let s=-t.translateX/t.scale,o=(n-t.translateX)/t.scale,r=Math.min(s,o),i=Math.max(s,o),a=0,c=0;for(let l of e)a+=Math.max(0,Math.min(l.bp1,r)-l.bp0),c+=Math.max(0,l.bp1-Math.max(l.bp0,i));return t.scale>=0?{left:Math.round(a),right:Math.round(c)}:{left:Math.round(c),right:Math.round(a)}}function Ki(e,t,n,s){if(s<0||s>X+Zo)return;let o,r=Zo;for(let i of e){let[a,c]=_t(t,i.bp0,i.bp1),l=Math.max(0,a-n,n-c);l<=r&&(r=l,o=i.node)}return o}function ji(e,t){let n=e?.[Math.floor(e.length/2)];return n?t(n):void 0}function rr(e,t,n,s){let o=e.map(l=>{let[d,f]=_t(t,l.bp0,l.bp1),u=Math.round(d*s);return{colors:l.colors,x0:d,px0:u,px1:Math.max(Math.round(f*s),u+1)}}).filter(l=>l.px1>0&&l.px0<n*s).sort((l,d)=>l.x0-d.x0),r=[],i=-1/0,a=[-1/0,-1/0];for(let{colors:l,px0:d,px1:f}of o){let u=Math.max(d,i);if(f>u){let m=a[0]<u?0:1;a[m]=f,r.push({colors:l,x0:u/s,x1:f/s,tier:m}),i=f}}return(r.length>0?r.at(-1).x1-r[0].x0:0)>=r.length*zi?r:r.map(({tier:l,...d})=>d)}function Jo(e,t,n,s){let o=n>0?t:t-Qo;e.clearRect(o,0,Qo,X);let r=t+n,i=r+n*nr;e.beginPath(),e.moveTo(r,X/2),e.lineTo(i,0),e.lineTo(i,X),e.closePath(),e.fillStyle=s,e.fill()}function er(e,t,n){return Math.round(e*X*n/t)/n}function Vi(e,t,n,{width:s,lit:o,darkMode:r,dpr:i=1}){let a=r?"#ffffff":"#18181c";e.clearRect(0,0,s,tr);for(let l of rr(t,n,s,i)){let{tier:d}=l,f=d!==void 0&&l.colors.length===1,u=f?2:l.colors.length;l.colors.forEach((m,h)=>{let p=f?d:h,g=er(p,u,i);e.fillStyle=m,e.fillRect(l.x0,g,l.x1-l.x0,er(p+1,u,i)-g)})}let c=or(t,n,s);if(c.left>0&&Jo(e,0,1,a),c.right>0&&Jo(e,s,-1,a),o){let[l,d]=_t(n,o.start,o.end),f=Math.max(d-l,3),u=(l+d)/2-f/2;e.strokeStyle=a,e.lineWidth=1.5,e.strokeRect(u,.75,f,X-1.5),o.anchor&&(e.beginPath(),e.moveTo(u+f/2,X),e.lineTo(o.anchor.x,o.anchor.y),e.lineWidth=1,e.stroke())}}function Qi(e,t){let n=new Map(e.nodes.map(o=>[o.id,o])),s=[];return t.nodes.forEach((o,r)=>{let i=n.get(o.name);if(o.order>=0&&i&&L(i)){let a=i.stable.start;s.push({bp0:a,bp1:a+o.sequenceLength,index:r,node:o})}}),s.sort((o,r)=>o.bp0-r.bp0)}function Zi(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 Gp(e,t,n){let s=Qi(e,t),o=[];for(let r of t.tracks){let i=r.name?n.get(r.name):void 0;if(i?.length){let a=new Map;for(let c of r.path)c.node!==null&&c.y!==void 0&&!a.has(c.node)&&a.set(c.node,c.y);for(let c of i){let l=Zi(s,c.start,a);if(l){let{node:d,bp0:f,bp1:u}=l,m=h=>d.x+(Math.min(h,u)-f)/(u-f)*d.pixelWidth;o.push({x0:m(c.start),x1:m(c.end),y:a.get(l.index),height:r.width})}}}}return o}function Ji(e){return e?"rgba(255,255,255,0.9)":"rgba(0,0,0,0.8)"}function zp(e,t,{x:n,y:s,width:o,darkMode:r}){if(t.length!==0){e.fillStyle=Ji(r),e.beginPath();for(let i of t){let a=n(i.x0),c=Math.max(n(i.x1),a+1);if(c>=0&&a<=o){let l=s(i.y);e.rect(a,l,c-a,s(i.y+i.height)-l)}}e.fill()}}function ec(e,t){return Math.abs(t-e)<=.1*Math.max(e,t)}function tc(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 a=n-1;a>=0;a--)for(let c=s-1;c>=0;c--){let l=Math.abs(e[a]-t[c])+o[a+1][c+1],d=n-a>s-c?o[a+1][c]:1/0,f=s-c>n-a?o[a][c+1]:1/0;o[a][c]=Math.min(l,d,f),r[a][c]=o[a][c]===l}let i=new Array(n).fill(void 0);for(let a=0,c=0;a<n&&c<s;)r[a][c]?i[a++]=c++:n-a>s-c?a++:c++;return i}function sr(e,t){return e.map((n,s)=>({item:n,i:s})).sort((n,s)=>t(n.item)-t(s.item))}var ir=e=>e.spanningReads!==0;function ar(e,t){return{...t,agrees:e.complete&&ir(t)?ec(e.bp,t.bp):void 0}}function nc(e,t){let n=new Map,s=new Set;e.forEach((a,c)=>{let l=t.find(d=>d.haplotype!==void 0&&d.haplotype===a.haplotype);l&&(s.add(l),n.set(c,ar(a,l)))});let o=t.filter(a=>a.haplotype===void 0),r=sr(e,a=>a.bp),i=[[r.filter(a=>a.item.complete),o.filter(ir)],[r,o]];for(let[a,c]of i){let l=a.filter(f=>!n.has(f.i)),d=sr(c.filter(f=>!s.has(f)),f=>f.bp);tc(l.map(f=>f.item.bp),d.map(f=>f.item.bp)).forEach((f,u)=>{if(f!==void 0){let m=l[u],h=d[f].item;s.add(h),n.set(m.i,ar(m.item,h))}})}return n}function Kp(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 i=t[o];if(i)for(let[a,c]of nc(r,i))n.set(r[a],c)}return e.map(o=>({...o,call:n.get(o)}))}var cr=Q(pe(),1),Qp=(0,P.createSvgIcon)((0,cr.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{P as a,Xr as b,et as c,qr as d,Fr as e,oa as f,ha as g,Ef as h,so as i,Sa as j,_f as k,ke as l,Ra as m,Na as n,uo as o,Oe as p,pt as q,Ae as r,_a as s,ka as t,Oa as u,Aa as v,Ie as w,fd as x,dd as y,ud as z,pd as A,hd as B,W as C,Xa as D,Da as E,qa as F,Fa as G,Ht as H,ur as I,ce as J,bt as K,yt as L,yo as M,Ha as N,Ga as O,Ce as P,ja as Q,Ro as R,No as S,wt as T,Va as U,Mt as V,Za as W,Ja as X,ei as Y,si as Z,ii as _,ci as $,li as aa,fi as ba,di as ca,ui as da,$o as ea,tu as fa,pr as ga,lc as ha,fc as ia,St as ja,mi as ka,gi as la,yc as ma,on as na,wc as oa,rn as pa,Qe as qa,sn as ra,an as sa,Or as ta,xi as ua,bi as va,Xo as wa,Ri as xa,Ni as ya,Li as za,ki as Aa,Oi as Ba,Ii as Ca,Xi as Da,Vo as Ea,Rt as Fa,qi as Ga,Lt as Ha,Hi as Ia,Gi as Ja,tr as Ka,Ui as La,or as Ma,Ki as Na,ji as Oa,Vi as Pa,Gp as Qa,Ji as Ra,zp as Sa,Kp as Ta,vl as Ua,El as Va,Tr as Wa,Sl as Xa,Rl as Ya,Ze as Za,Je as _a,Xl as $a,Bl as ab,Qp as bb};
|
|
2
|
+
//# sourceMappingURL=chunk-B7KMMGFB.js.map
|