import{B as w,a as y}from"./bbi-T1lZJhlh.js";import{b6 as x,a9 as B,u as P}from"./index-Bm2SqMk3.js";import{B as S}from"./index-6rN3ss-L.js";import{r as N}from"./rxjs-DT7GVwt0.js";import"./Observable-CNFN7Ka5.js";class v extends w{async getView(t,e){const{zoomLevels:s,refsByName:r,isBigEndian:n,uncompressBufSize:u}=await this.getHeader(e),c=1/t,l=s.length-1;for(let o=l;o>=0;o-=1){const i=s[o];if(i&&i.reductionLevel<=2*c)return new y(this.bbi,r,i.indexOffset,n,u>0,"summary")}return this.getUnzoomedView(e)}}var C=x();class E extends S.BaseFeatureDataAdapter{async setupPre(t){const{statusCallback:e=()=>{}}=t||{},s=this.pluginManager,r=new v({filehandle:B.openLocation(this.getConf("bigWigLocation"),s)}),n=await P.updateStatus("Downloading bigwig header",e,()=>r.getHeader(t));return{bigwig:r,header:n}}async setup(t){return this.setupP||(this.setupP=this.setupPre(t).catch(e=>{throw this.setupP=void 0,e})),this.setupP}async getRefNames(t){const{header:e}=await this.setup(t);return Object.keys(e.refsByName)}async refIdToName(t){var e;const{header:s}=await this.setup();return(e=s.refsByNumber[t])===null||e===void 0?void 0:e.name}async getGlobalStats(t){const{header:e}=await this.setup(t);return C.rectifyStats(e.totalSummary)}getFeatures(t,e={}){const{refName:s,start:r,end:n}=t,{bpPerPx:u=0,stopToken:c,resolution:l=1,statusCallback:o=()=>{}}=e;return N.ObservableCreate(async i=>{o("Downloading bigwig data");const g=this.getConf("source"),f=this.getConf("resolutionMultiplier"),{bigwig:h}=await this.setup(e),m=await h.getFeatures(s,r,n,{...e,basesPerSpan:u/l*f});for(const a of m){g&&(a.source=g);const d=`${g}:${t.refName}:${a.start}-${a.end}`;a.refName=s,a.uniqueId=d,i.next({get:b=>a[b],id:()=>d,toJSON:()=>a})}i.complete()},c)}async getMultiRegionFeatureDensityStats(t){return{featureDensity:0}}freeResources(){}}E.capabilities=["hasResolution","hasLocalStats","hasGlobalStats"];export{E as default};
