"use strict";(globalThis.webpackChunk_jbrowse_web=globalThis.webpackChunk_jbrowse_web||[]).push([[4058],{54058:(e,t,a)=>{a.r(t),a.d(t,{default:()=>l});var r=a(32598),s=a(46377),n=a(99546),i=a(99834),o=a(66885);class l extends s.BaseFeatureDataAdapter{intervalTrees={};async getNames(){const{header:e,columnNames:t}=await this.loadData();if(t.length)return t;const a=e.split(/\n|\r\n|\r/).filter((e=>!!e)).at(-1);return a?.includes("\t")?a.slice(1).split("\t").map((e=>e.trim())):void 0}async loadFeatureIntervalTreeHelper(e){const{features:t}=await this.loadData(),a=t[e];if(!a)return;const s=(await this.getNames())?.slice(3)||[],i=new r.Ay;for(let e=0;e<a.length;e++){const t=a[e],[r,o,l,...c]=t.split("\t");for(let t=0;t<c.length;t++){const a=`${this.id}-${r}-${e}-${t}`,h=+o,u=+l,d=+c[t],f=s[t]||`col${t}`;d&&i.insert([h,u],new n.SimpleFeature({id:a,data:{refName:r,start:h,end:u,score:d,source:f}}))}}return i}async getRefNames(e={}){const{features:t}=await this.loadData(e);return Object.keys(t)}async loadDataP(e={}){const t=this.pluginManager,a=this.getConf("bedGraphLocation"),r=await(0,n.fetchAndMaybeUnzip)((0,i.openLocation)(a,t),e);if(r.length>536870888)throw new Error("Data exceeds maximum string length (512MB)");const s=new TextDecoder("utf8",{fatal:!0}).decode(r).split(/\n|\r\n|\r/).filter((e=>!!e)),o=[];let l=0;for(;l<s.length&&s[l].startsWith("#");l++)o.push(s[l]);const c=o.join("\n"),h={};for(;l<s.length;l++){const e=s[l],t=e.indexOf("\t"),a=e.slice(0,t);h[a]||(h[a]=[]),h[a].push(e)}return{header:c,features:h,columnNames:this.getConf("columnNames")}}async loadFeatureIntervalTree(e){return this.intervalTrees[e]||(this.intervalTrees[e]=this.loadFeatureIntervalTreeHelper(e).catch((t=>{throw this.intervalTrees[e]=void 0,t}))),this.intervalTrees[e]}async loadData(e={}){return this.bedFeatures||(this.bedFeatures=this.loadDataP(e).catch((e=>{throw this.bedFeatures=void 0,e}))),this.bedFeatures}getFeatures(e,t={}){return(0,o.ObservableCreate)((async t=>{const{start:a,end:r,refName:s}=e,n=await this.loadFeatureIntervalTree(s);for(const e of n?.search([a,r])||[])t.next(e);t.complete()}))}}}}]);
//# sourceMappingURL=4058.c13614af.chunk.js.map