"use strict";(globalThis.webpackChunk_jbrowse_web=globalThis.webpackChunk_jbrowse_web||[]).push([[8343],{98343:(e,t,a)=>{a.r(t),a.d(t,{default:()=>p});var s=a(32598),r=a(350),n=a(46377),i=a(99546),c=a(99834),o=a(66885),l=a(95600);class p extends n.BaseFeatureDataAdapter{calculatedIntervalTreeMap={};static capabilities=["getFeatures","getRefNames"];async getHeader(){const{header:e}=await this.setup();return e}async getMetadata(){const{parser:e}=await this.setup();return e.getMetadata()}async setupP(e){const{statusCallback:t=()=>{}}=e||{},a=(0,c.openLocation)(this.getConf("vcfLocation"),this.pluginManager),n=await(0,i.fetchAndMaybeUnzip)(a,e),o=[],p={};let u=0;const h=new TextDecoder("utf8");let d=0;for(;u<n.length;){const e=n.indexOf(10,u),a=-1===e?n.subarray(u):n.subarray(u,e),s=h.decode(a).trim();if(s)if(s.startsWith("#"))o.push(s);else{const e=s.indexOf("\t"),t=s.slice(0,e);p[t]||(p[t]=[]),p[t].push(s)}d++%1e4==0&&t(`Loading ${(0,i.getProgressDisplayStr)(u,n.length)}`),u=e+1}const f=o.join("\n"),g=new r.A({header:f}),b=Object.fromEntries(Object.entries(p).map((([e,t])=>[e,a=>{if(!this.calculatedIntervalTreeMap[e]){a?.("Parsing VCF data");let r=0;const n=new s.Ay;for(const a of t){const t=new l.A({variant:g.parseLine(a),parser:g,id:`${this.id}-${e}-${r++}`});n.insert([t.get("start"),t.get("end")],t)}this.calculatedIntervalTreeMap[e]=n}return this.calculatedIntervalTreeMap[e]}])));return{header:f,parser:g,intervalTreeMap:b}}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,o.ObservableCreate)((async a=>{try{const{start:s,end:r,refName:n}=e,{intervalTreeMap:i}=await this.setup();for(const e of i[n]?.(t.statusCallback).search([s,r])||[])a.next(e);a.complete()}catch(e){a.error(e)}}),t.stopToken)}async getSources(){const e=this.getConf("samplesTsvLocation");if(""===e.uri||"/path/to/samples.tsv"===e.uri){const{parser:e}=await this.setup();return e.samples.map((e=>({name:e})))}{const t=(await(0,c.openLocation)(e).readFile("utf8")).split(/\n|\r\n|\r/),a=t[0].split("\t"),{parser:s}=await this.setup(),r=new Set(s.samples);return t.slice(1).map((e=>{const t=e.split("\t");return{name:t[0],...Object.fromEntries(t.slice(1).map(((e,t)=>[a[t+1],e])))}})).filter((e=>r.has(e.name)))}}}}}]);
//# sourceMappingURL=8343.adb5b3ff.chunk.js.map