import{DEFAULT_LOCALE_PLACEHOLDER as n}from"../../../../constants/common.js";import{FlexSearch as a}from"./flexsearch/index.js";import{Typesense as c}from"./typesense/index.js";class h{type;l10n;#s={flexsearch:a,typesense:c};#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,s){return this.#e.search({...e,locale:this.#t(e)},t,s)}async countFacets(e,t,s){return this.#e.countFacets({...e,locale:this.#t(e)},t,s)}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||n;return t===this.l10n?.defaultLocale?n:t.toLowerCase()}cleanupFacetValues(e){return this.#e.cleanupFacetValues(e)}}export{h as SearchEngine};
