'use strict';

const fuse_esm = require('./fuse.esm-847a739f.js');
const store = require('./store-140a5df9.js');

async function searchServices(query, filter, limit) {
  let services = ((store.state === null || store.state === void 0 ? void 0 : store.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_esm.Fuse(services, {
      keys: ["name", "description"],
    });
    services = fuse.search(query, { limit }).map((result) => result === null || result === void 0 ? void 0 : result.item);
  }
  return services;
}

function cleanAndLowerString(str) {
  return str
    .replace(/\s{2,}/g, " ")
    .trim()
    .toLowerCase();
}

function getServiceTypes() {
  return [
    ...new Set(((store.state === null || store.state === void 0 ? void 0 : store.state.services) || []).map((service) => cleanAndLowerString(service === null || service === void 0 ? void 0 : service.tab))),
  ]
    .sort((a, b) => (a > b ? 1 : -1))
    .filter((value) => value === null || value === void 0 ? void 0 : value.length)
    .map((value) => ({
    label: value,
    value,
  }));
}

exports.cleanAndLowerString = cleanAndLowerString;
exports.getServiceTypes = getServiceTypes;
exports.searchServices = searchServices;
