import{InvalidOperationError as r}from"../../InvalidOperationError.js";import{checkArg as s}from"../../utilities/checkArg.js";import*as i from"../../utilities/promise.js";import{SearchOptions as e}from"./SearchOptions.js";export class SearchProviderBase{search(e,t,o){s("source",e).isNotMissing();const a=Array.isArray(e)?e:[e];if(!a.every((r=>this.isSupported(r))))throw new r("Unsupported feature source.");const n=this;return async function*(){t&&(await i.parallelEach(a,(r=>r.initialize())),yield*n._search(a,t,o))}()}async suggest(i,t,o){s("source",i).isNotMissing();const a=Array.isArray(i)?i:[i];if(!a.every((r=>this.isSupported(r))))throw new r("Unsupported feature source.");return t?this._suggest(a,t,{...e.DEFAULTS,...o}):[]}async count(e,t,o){s("source",e).isNotMissing();const a=Array.isArray(e)?e:[e];if(!a.every((r=>this.isSupported(r))))throw new r("Unsupported feature source.");if(t)return await i.parallelEach(a,(r=>r.initialize())),this._count(a,t,o)}}