import Fuse from "fuse.js";
import state from "../store";
export default async function searchServices(query, filter, limit) {
  let services = ((state === null || state === void 0 ? void 0 : state.services) || []).filter((service) => filter && typeof filter === "function" ? filter(service) : true);
  if (query === null || query === void 0 ? void 0 : query.length) {
    const fuse = new Fuse(services, {
      keys: ["name", "description"],
    });
    services = fuse.search(query, { limit }).map((result) => result === null || result === void 0 ? void 0 : result.item);
  }
  return services;
}
