"use strict";(globalThis.webpackChunk_jbrowse_web=globalThis.webpackChunk_jbrowse_web||[]).push([[5247],{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 c=e.indexOf(10,n),o=-1===c?e.length:c,u=e.subarray(n,o),p=r.decode(u).trim();if(p&&!1===t(p,i))break;i++%1e4==0&&a(`Loading ${(0,s.getProgressDisplayStr)(n,e.length)}`),n=o+1}}},75247:(e,t,a)=>{a.r(t),a.d(t,{default:()=>l});var s=a(32598),r=a(350),n=a(46377),i=a(99546),c=a(99834),o=a(66885),u=a(95600),p=a(18340);class l 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),{header:o,featureMap:l}=function(e,t=()=>{}){const a=[],s={};return(0,p.P)(e,e=>{if(e.startsWith("#"))a.push(e);else{const t=e.indexOf("\t"),a=e.slice(0,t);s[a]||(s[a]=[]),s[a].push(e)}return!0},t),{header:a.join("\n"),featureMap:s}}(n,t),h=new r.A({header:o}),f=Object.fromEntries(Object.entries(l).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 u.A({variant:h.parseLine(a),parser:h,id:`${this.id}-${e}-${r++}`});n.insert([t.get("start"),t.get("end")],t)}this.calculatedIntervalTreeMap[e]=n}return this.calculatedIntervalTreeMap[e]}]));return{header:o,parser:h,intervalTreeMap:f}}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=5247.1e0acc1c.chunk.js.map