"use strict";(self.webpackChunk_jbrowse_web=self.webpackChunk_jbrowse_web||[]).push([[8258],{78258:(e,t,a)=>{a.r(t),a.d(t,{default:()=>u,featureData:()=>c});var s=a(56798),r=a(59062),n=a(16979),i=a(90872),o=a(65904),l=a(31238);function c(e,t,a,s){const r=e.split("\t"),n=r[a?3:0],o=+r[a?4:1],l=+r[a?5:2],c=r[a?0:3],u=+r[a?1:4],h=+r[a?2:5],f=r[6],p=+r[7],m=d(r[8]),v=d(r[9]),g=r.slice(10),w=s?Object.fromEntries(s.slice(10).map(((e,t)=>[e,g[t]]))):g;let b;return["DUP","TRA","INV","CNV","DEL"].includes(g[0])&&(b="<".concat(g[0],">")),new i.SimpleFeature({start:o,end:l,refName:n,...b?{ALT:[b]}:{},strand:m,name:f,...w,score:p,uniqueId:t,mate:{refName:c,start:u,end:h,strand:v}})}function d(e){return"+"===e?1:"-"===e?-1:"."===e?0:void 0}class u extends s.BaseFeatureDataAdapter{constructor(){super(...arguments),this.bedpeFeatures=void 0,this.intervalTrees={}}async loadDataP(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=this.pluginManager,a=this.getConf("bedpeLocation"),s=await(0,r.openLocation)(a,t).readFile(e),n=function(e){return 31===e[0]&&139===e[1]&&8===e[2]}(s)?await(0,l.unzip)(s):s;if(n.length>536870888)throw new Error("Data exceeds maximum string length (512MB)");const i=new TextDecoder("utf8",{fatal:!0}).decode(n).split(/\n|\r\n|\r/).filter((e=>!!e)),o=[];let c=0;for(;c<i.length&&i[c].startsWith("#");c++)o.push(i[c]);const d=o.join("\n"),u={},h={};for(;c<i.length;c++){const e=i[c],t=e.split("\t"),a=t[0],s=t[3];u[a]||(u[a]=[]),h[s]||(h[s]=[]),u[a].push(e),h[s].push(e)}return{header:d,feats1:u,feats2:h,columnNames:this.getConf("columnNames")}}async loadData(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.bedpeFeatures||(this.bedpeFeatures=this.loadDataP(e).catch((e=>{throw this.bedpeFeatures=void 0,e}))),this.bedpeFeatures}async getRefNames(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{feats1:t,feats2:a}=await this.loadData(e);return[...new Set([...Object.keys(t),...Object.keys(a)])]}async getHeader(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{header:t}=await this.loadData(e);return t}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 null!==a&&void 0!==a&&a.includes("\t")?a.slice(1).split("\t").map((e=>e.trim())):void 0}async loadFeatureTreeP(e){var t,a,s,r;const{feats1:n,feats2:i}=await this.loadData(),l=await this.getNames(),d=new o.ZP,u=null!==(t=null===(a=n[e])||void 0===a?void 0:a.map(((t,a)=>c(t,"".concat(this.id,"-").concat(e,"-").concat(a,"-r1"),!1,l))))&&void 0!==t?t:[],h=null!==(s=null===(r=i[e])||void 0===r?void 0:r.map(((t,a)=>c(t,"".concat(this.id,"-").concat(e,"-").concat(a,"-r2"),!0,l))))&&void 0!==s?s:[];for(const o of[...u,...h])d.insert([o.get("start"),o.get("end")],o);return d}async loadFeatureTree(e){return this.intervalTrees[e]||(this.intervalTrees[e]=this.loadFeatureTreeP(e).catch((t=>{throw this.intervalTrees[e]=void 0,t}))),this.intervalTrees[e]}getFeatures(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(0,n.ObservableCreate)((async t=>{const{start:a,end:s,refName:r}=e,n=await this.loadFeatureTree(r);null===n||void 0===n||n.search([a,s]).forEach((e=>t.next(e))),t.complete()}),t.signal)}freeResources(){}}u.capabilities=["getFeatures","getRefNames"]}}]);
//# sourceMappingURL=8258.f0aee51f.chunk.js.map