import{DEFAULT_LOCALE_PLACEHOLDER as s}from"../../../../constants/common.js";import{FlexSearch as n}from"./flexsearch/index.js";import{Typesense as a}from"./typesense/index.js";class l{type;l10n;#s={flexsearch:n,typesense:a};#e;constructor(e,t){this.type=e,this.l10n=t,this.#e=new this.#s[e]}async initIndexSchema(e){await this.#e.initIndexSchema?.(e)}async addDocuments(e,t){return this.#e.addDocuments(e,t)}async search(e,t){return this.#e.search({...e,locale:this.#t(e)},t)}async countFacets(e,t){return this.#e.countFacets({...e,locale:this.#t(e)},t)}async export(e){await this.#e.exportDocuments(e),await this.#e.exportIndexes(e)}async import(e){return this.#e.import(e)}#t(e){const t=e.locale||this.l10n?.defaultLocale||s;return t===this.l10n?.defaultLocale?s:t.toLowerCase()}cleanupFacetValues(e){return this.#e.cleanupFacetValues(e)}}export{l as SearchEngine};
