import { objectKeys } from "@scalar/helpers/object/object-keys";
import { AVAILABLE_CLIENTS, GROUPED_CLIENTS } from "@scalar/types/snippetz";
const mapHiddenClientsConfig = (hiddenClients) => {
  if (hiddenClients === true) {
    return [];
  }
  if (!hiddenClients || Array.isArray(hiddenClients) && hiddenClients.length === 0) {
    return AVAILABLE_CLIENTS;
  }
  const visibleClientsSet = new Set(AVAILABLE_CLIENTS);
  if (Array.isArray(hiddenClients)) {
    for (const item of hiddenClients) {
      const group = GROUPED_CLIENTS[item];
      if (group) {
        for (const client of group) {
          visibleClientsSet.delete(`${item}/${client}`);
        }
      } else if (item.includes("/")) {
        visibleClientsSet.delete(item);
      } else {
        for (const language of objectKeys(GROUPED_CLIENTS)) {
          visibleClientsSet.delete(`${language}/${item}`);
        }
      }
    }
  } else if (typeof hiddenClients === "object") {
    for (const [targetId, clients] of Object.entries(hiddenClients)) {
      if (clients === true) {
        const group = GROUPED_CLIENTS[targetId];
        if (group) {
          for (const client of group) {
            visibleClientsSet.delete(`${targetId}/${client}`);
          }
        }
      } else if (Array.isArray(clients)) {
        for (const client of clients) {
          visibleClientsSet.delete(client);
          visibleClientsSet.delete(`${targetId}/${client}`);
        }
      }
    }
  }
  return Array.from(visibleClientsSet);
};
export {
  mapHiddenClientsConfig
};
