"use strict";(globalThis.webpackChunk_jbrowse_web=globalThis.webpackChunk_jbrowse_web||[]).push([[8343],{98343:(e,t,a)=>{a.r(t),a.d(t,{default:()=>u});var s=a(46377),r=a(99546),n=a(99834),c=a(66885),i=a(32598),o=a(9502),l=a(54702);class u extends s.BaseFeatureDataAdapter{calculatedIntervalTreeMap={};static capabilities=["getFeatures","getRefNames"];async getHeader(){const{header:e}=await this.setup();return e}async getMetadata(){const{header:e}=await this.setup();return new o.A({header:e}).getMetadata()}async setupP(e){const{statusCallback:t=()=>{}}=e||{},a=(0,n.openLocation)(this.getConf("vcfLocation"),this.pluginManager),s=await(0,r.fetchAndMaybeUnzip)(a,e),c=[],u={};let h=0;const d=new TextDecoder("utf8");let p=0;for(;h<s.length;){const e=s.indexOf("\n",h),a=-1===e?s.subarray(h):s.subarray(h,e),r=d.decode(a).trim();if(r)if(r.startsWith("#"))c.push(r);else{const e=r.indexOf("\t"),t=r.slice(0,e);u[t]||(u[t]=[]),u[t].push(r)}p++%1e4==0&&t(`Loading ${Math.floor(h/1e6).toLocaleString("en-US")}/${Math.floor(s.length/1e6).toLocaleString("en-US")} MB`),h=e+1}const f=c.join("\n"),g=new o.A({header:f});return{header:f,intervalTreeMap:Object.fromEntries(Object.entries(u).map((([e,t])=>[e,a=>{if(!this.calculatedIntervalTreeMap[e]){a?.("Parsing VCF data");let s=0;const r=new i.Ay;for(const a of t){const t=new l.A({variant:g.parseLine(a),parser:g,id:`${this.id}-${e}-${s++}`});r.insert([t.get("start"),t.get("end")],t)}this.calculatedIntervalTreeMap[e]=r}return this.calculatedIntervalTreeMap[e]}])))}}async setup(){return this.vcfFeatures||(this.vcfFeatures=this.setupP().catch((e=>{throw this.vcfFeatures=void 0,e}))),this.vcfFeatures}async getRefNames(e={}){const{intervalTreeMap:t}=await this.setup();return Object.keys(t)}getFeatures(e,t={}){return(0,c.ObservableCreate)((async a=>{try{const{start:s,end:r,refName:n}=e,{intervalTreeMap:c}=await this.setup();c[n]?.(t.statusCallback).search([s,r]).forEach((e=>{a.next(e)})),a.complete()}catch(e){a.error(e)}}),t.signal)}freeResources(){}}}}]);
//# sourceMappingURL=8343.1a64a334.chunk.js.map