const l=`(function(){"use strict";class z{constructor(e=null){e?this.elements=new Float64Array(e):this.elements=new Float64Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}clone(){return new z(this.elements)}translate(e){const[n,s,r]=e;return this.elements[12]+=n,this.elements[13]+=s,this.elements[14]+=r,this}scale(e){const[n,s,r]=e;return this.elements[0]*=n,this.elements[5]*=s,this.elements[10]*=r,this}toArray(){return Array.from(this.elements)}}function q(t,e){if(t.length===0)return null;if(t.length===1)return t[0];const n=t.map(e),s=n.reduce((l,h)=>l+h,0);if(s===0)return t[0];let r=Math.random()*s;for(let l=0;l<t.length;l++)if(r-=n[l],r<=0)return t[l];return t[t.length-1]}const k={largestSpan:t=>t.length===0?null:t.reduce((e,n)=>n.span>e.span?n:e,t[0]),centerWeighted:(t,e)=>t.length===0?null:t.reduce((n,s)=>{const r=Math.abs(n.midpoint-e);return Math.abs(s.midpoint-e)<r?s:n},t[0]),spanWeightedRandom:t=>q(t,e=>e.span),first:t=>t.length===0?null:t.reduce((e,n)=>n.s<e.s?n:e,t[0])};function O(t){return k[t]||k.largestSpan}function j(t,e){if(t===1&&e<=1)return 3;const n=Math.log10(Math.max(1,t)),s=Math.log10(Math.max(1,e));return Math.max(1,Math.min(3,3-Math.floor(n+s/2)))}function H(t,e,n,s={}){const{selectionStrategy:r="largestSpan",viewportStart:l=null,viewportEnd:h=null,prevLocalBins:x=null,minStart:I=null,maxEnd:w=null}=s,A=new Set,L=1.05,p=[],f=t.size;if(f===0)return{return_local_bins:t,displayArray:p,showingAllTrees:!1};const v=n/e,a=v<1,g=O(r),m=new z;let y=I,M=w;if(y===null||M===null){y=1/0,M=-1/0;for(const i of t.values())i.s<y&&(y=i.s),i.e>M&&(M=i.e)}const $=a?f:Math.max(1,Math.max(10,Math.ceil(f/v))),K=Math.min(f,$),D=a;if(a){const o=l??y,V=h??M,c=(V-o)/e/f*.9,u=(V-o)/f;let b=0;for(const[S,_]of t.entries()){if(f===1&&x&&x.has(S)){const T=x.get(S);t.set(S,{...T})}else{const U=(o+(b+.5)*u)/e-c/2,P=m.clone().translate([U,0,0]).scale([c,1,1]);t.set(S,{..._,modelMatrix:P,visible:!0,position:_.s,span:_.span,precision:2,slotIndex:b,isRepresentative:!0,groupSize:1})}p.push(S),b++}return{return_local_bins:t,displayArray:p,showingAllTrees:D}}const R=l??y,W=((h??M)-R)/K,E=new Map;for(const i of t.values()){const o=Math.min(K-1,Math.max(0,Math.floor((i.midpoint-R)/W)));E.has(o)||E.set(o,[]),E.get(o).push(i)}const X=new Set,Z=W/e/L;for(const[i,o]of E.entries()){const G=R+i*W+W/2;let c;if(r==="centerWeighted"?c=g(o,G):c=g(o),c){const u=c.global_index;X.add(u);const b=j(o.length,v),_=G/e-Z/2,T=m.clone().translate([_,0,0]).scale([Z,1,1]);t.set(u,{...c,modelMatrix:T,visible:!0,position:c.s,span:c.span,precision:b,slotIndex:i,isRepresentative:!0,groupSize:o.length}),p.push(u)}for(const u of o)X.has(u.global_index)||(A.add(u.global_index),t.set(u.global_index,{...u,modelMatrix:null,visible:!1,position:null,span:null,path:null,precision:null,slotIndex:i,isRepresentative:!1,groupSize:o.length}))}return{return_local_bins:t,displayArray:p,invisibleKeys:A,showingAllTrees:D}}function J(t){const e=t?.intervals;return!Array.isArray(e)||e.length===0?[]:Array.isArray(e[0])?e.map(n=>n[0]):e}let d=null,C=null;function N(t){d=J(t),C=null}function Q(t){return Array.from(t.entries()).map(([e,n])=>({key:e,...n,modelMatrix:n.modelMatrix?n.modelMatrix.toArray():null}))}function Y(t){const{lo:e=0,hi:n=0,start:s,end:r,globalBpPerUnit:l,new_globalBp:h,displayOptions:x={}}=t,{selectionStrategy:I="largestSpan"}=x;if(!d||n<=e)return{local_bins:[],displayArray:[],showing_all_trees:!1};const w=new Map;for(let a=e;a<n-1;a++){const g=d[a],m=d[a+1];w.set(a,{s:g,e:m,span:m-g,midpoint:(g+m)/2,path:null,global_index:a,precision:null})}const A=d[e],L=d[Math.min(n,d.length-1)],{return_local_bins:p,displayArray:f,showingAllTrees:v}=H(w,l,h,{selectionStrategy:I,viewportStart:s,viewportEnd:r,prevLocalBins:C,minStart:A,maxEnd:L});return C=p,{local_bins:Q(p),displayArray:f,showing_all_trees:v}}const F=typeof self<"u"?self:globalThis;F.onmessage=async t=>{const{type:e,id:n,data:s}=t.data;if(e==="config"&&(N(s),F.postMessage({type:"config",id:n,data:null})),e==="local-data"){const r=Y(s);F.postMessage({type:"local-data",id:n,data:r})}}})();
`,s=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",l],{type:"text/javascript;charset=utf-8"});function r(n){let e;try{if(e=s&&(self.URL||self.webkitURL).createObjectURL(s),!e)throw"";const t=new Worker(e,{name:n?.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(e)}),t}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(l),{name:n?.name})}}export{r as default};
