import{i as p,c as u,u as f}from"./rpcWorker-CVTx5FIM.js";import{B as d}from"./index-P3rx-5SH.js";import{r as l}from"./rxjs-Dgg09m9e.js";function h(i){return new Map(i.split(">").filter(t=>/\S/.test(t)).map(t=>{const[e,...a]=t.split(`
`),[s,...n]=e.split(" "),r=a.join("").replace(/\s/g,"");return[s,{description:n.join(" "),sequence:r}]}))}class w extends d.BaseSequenceAdapter{async getRefNames(t){const{fasta:e}=await this.setup(t);return[...e.keys()]}async getRegions(t){const{fasta:e}=await this.setup(t);return[...e.entries()].map(([a,s])=>({refName:a,start:0,end:s.sequence.length}))}async setupPre(t){const e=this.getConf("fastaLocation"),a=h(await p.openLocation(e,this.pluginManager).readFile("utf8"));return{fasta:new Map([...a.entries()].map(([s,n])=>[u.readConfObject(this.config,"rewriteRefNames",{refName:s})||s,n]))}}async getHeader(){const t=this.getConf("metadataLocation");return t.uri===""||t.uri==="/path/to/fa.metadata.yaml"?null:p.openLocation(t,this.pluginManager).readFile("utf8")}async setup(t){return this.setupP||(this.setupP=this.setupPre(t).catch(e=>{throw this.setupP=void 0,e})),this.setupP}getFeatures(t,e){const{refName:a,start:s,end:n}=t;return l.ObservableCreate(async r=>{const{fasta:c}=await this.setup(e),o=c.get(a);o&&r.next(new f.SimpleFeature({id:`${a}-${s}-${n}`,data:{refName:a,start:s,end:n,seq:o.sequence.slice(s,n)}})),r.complete()})}freeResources(){}}export{w as default};
