"use strict";(globalThis.webpackChunk_jbrowse_web=globalThis.webpackChunk_jbrowse_web||[]).push([[4058],{18340:(e,t,a)=>{a.d(t,{P:()=>r});var s=a(99546);function r(e,t,a=()=>{}){const r=new TextDecoder("utf8");let n=0,i=0;for(;n<e.length;){const o=e.indexOf(10,n),l=-1===o?e.length:o,c=e.subarray(n,l),h=r.decode(c).trim();if(h&&!1===t(h,i))break;i++%1e4==0&&a(`Loading ${(0,s.getProgressDisplayStr)(n,e.length)}`),n=l+1}}},54058:(e,t,a)=>{a.r(t),a.d(t,{default:()=>c});var s=a(32598),r=a(46377),n=a(99546),i=a(99834),o=a(18340),l=a(66885);class c extends r.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 r=(await this.getNames())?.slice(3)||[],i=new s.Ay;for(let e=0;e<a.length;e++){const t=a[e],[s,o,l,...c]=t.split("\t");for(let t=0;t<c.length;t++){const a=`${this.id}-${s}-${e}-${t}`,h=+o,u=+l,d=+c[t],f=r[t]||`col${t}`;d&&i.insert([h,u],new n.SimpleFeature({id:a,data:{refName:s,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"),s=await(0,n.fetchAndMaybeUnzip)((0,i.openLocation)(a,t),e),r={},l=[];(0,o.P)(s,e=>{if(e.startsWith("#"))l.push(e);else{const t=e.indexOf("\t"),a=e.slice(0,t);r[a]||(r[a]=[]),r[a].push(e)}return!0},e.statusCallback);const c=this.getConf("columnNames");return{header:l.join("\n"),features:r,columnNames:c}}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,l.ObservableCreate)(async t=>{const{start:a,end:s,refName:r}=e,n=await this.loadFeatureIntervalTree(r);for(const e of n?.search([a,s])||[])t.next(e);t.complete()})}}}}]);
//# sourceMappingURL=4058.9575d062.chunk.js.map