"use strict";(globalThis.webpackChunk_jbrowse_web=globalThis.webpackChunk_jbrowse_web||[]).push([[8797],{58797:(t,e,a)=>{a.r(e),a.d(e,{default:()=>i});var s=a(8656),r=a(68584),c=a(46377),n=a(57097);class h{constructor(t){this.url=t.url.endsWith("/")?t.url:`${t.url}/`}async readMeta(){const t=await this.loadFile("meta.json"),{compress:e,track_names:a}=t;return{hashHexCharacters:Math.ceil(t.hash_bits/4),compress:e,tracks:a}}async getHashHexCharacters(){return(await this.readMeta()).hashHexCharacters}async getCompress(){return(await this.readMeta()).compress}async getTrackNames(){return(await this.readMeta()).tracks}async get(t){return(await this.getBucket(t))[t]}async getBucket(t){const e=this.hash(t),a=await this.hexToDirPath(e);return this.loadFile(a)}async loadFile(t){const e=await fetch(`${this.url}${t}`);if(!e.ok)throw new Error(`HTTP ${e.status} ${e.statusText}`);return e.json()}async hexToDirPath(t){const e=await this.getHashHexCharacters();if(e){const a=await this.getCompress();for(;t.length<8;)t=`0${t}`;t=t.slice(8-e);const s=[];for(let e=0;e<t.length;e+=3)s.push(t.slice(e,e+3));return`${s.join("/")}.json${a?"z":""}`}return""}hash(t){return(0,n.A)(t).toString(16).toLowerCase().replace("-","n")}}class i extends c.BaseAdapter{constructor(t,e,a){super(t,e,a);const s=(0,r.readConfObject)(t,"namesIndexLocation"),{baseUri:c,uri:n}=s;this.httpMap=new h({url:c?new URL(n,c).href:n})}async loadIndexFile(t){return this.httpMap.getBucket(t)}async searchIndex(t){const{searchType:e,queryString:a}=t,s=this.tracksNames||await this.httpMap.getTrackNames(),r=a.toLowerCase(),c=await this.loadIndexFile(r);return c[r]?this.formatResults(c[r],s,e):[]}formatResults(t,e,a){return[..."exact"===a?[]:t.prefix.map((t=>new s.A({label:"object"==typeof t?t.name:t,matchedAttribute:"name",matchedObject:{result:t}}))),...t.exact.map((t=>{const a=t[0],r=t[1],c=`${t[3]||a}:${t[4]}-${t[5]}`;return new s.A({locString:c,label:a,matchedAttribute:"name",matchedObject:t,trackId:e[r]})}))].filter((t=>"too many matches"!==t.getLabel()))}freeResources(){}}}}]);
//# sourceMappingURL=8797.176105c3.chunk.js.map