import {
  require_dist
} from "./chunk-52KJSIHS.js";
import {
  useProductTags
} from "./chunk-RLRWDHME.js";
import {
  useProductTypes
} from "./chunk-L2NJPDUD.js";
import {
  useCollections
} from "./chunk-XKEYHWBS.js";
import {
  useProductCategories
} from "./chunk-656G74I2.js";
import {
  __toESM
} from "./chunk-NBMM2TZK.js";

// src/hooks/table/filters/use-product-table-filters.tsx
var import_types = __toESM(require_dist(), 1);
import { useTranslation } from "react-i18next";
var useProductTableFilters = (exclude) => {
  const { t } = useTranslation();
  const isProductTypeExcluded = exclude?.includes("product_types");
  const { product_types } = useProductTypes(
    {
      limit: 1e3,
      offset: 0
    },
    {
      enabled: !isProductTypeExcluded
    }
  );
  const isProductTagExcluded = exclude?.includes("product_tags");
  const { product_tags } = useProductTags({
    limit: 1e3,
    offset: 0
  });
  const isCategoryExcluded = exclude?.includes("categories");
  const { product_categories } = useProductCategories(
    {
      limit: 1e3,
      offset: 0,
      fields: "id,name"
    },
    {
      enabled: !isCategoryExcluded
    }
  );
  const isCollectionExcluded = exclude?.includes("collections");
  const { collections } = useCollections(
    {
      limit: 1e3,
      offset: 0,
      fields: "id,title"
    },
    {
      enabled: !isCollectionExcluded
    }
  );
  let filters = [];
  if (product_types && !isProductTypeExcluded) {
    const typeFilter = {
      key: "type_id",
      label: t("fields.type"),
      type: "select",
      multiple: true,
      searchable: true,
      options: product_types.map((t2) => ({
        label: t2.value,
        value: t2.id
      }))
    };
    filters = [...filters, typeFilter];
  }
  if (product_tags && !isProductTagExcluded) {
    const tagFilter = {
      key: "tag_id",
      label: t("fields.tag"),
      type: "select",
      multiple: true,
      searchable: true,
      options: product_tags.map((t2) => ({
        label: t2.value,
        value: t2.id
      }))
    };
    filters = [...filters, tagFilter];
  }
  if (product_categories && !isCategoryExcluded) {
    const categoryFilter = {
      key: "category_id",
      label: t("fields.category"),
      type: "select",
      multiple: true,
      searchable: true,
      options: product_categories.map((c) => ({
        label: c.name,
        value: c.id
      }))
    };
    filters = [...filters, categoryFilter];
  }
  if (collections && !isCollectionExcluded) {
    const collectionFilter = {
      key: "collection_id",
      label: t("fields.collection"),
      type: "select",
      multiple: true,
      searchable: true,
      options: collections.map((c) => ({
        label: c.title,
        value: c.id
      }))
    };
    filters = [...filters, collectionFilter];
  }
  const statusFilter = {
    key: "status",
    label: t("fields.status"),
    type: "select",
    multiple: true,
    options: [
      {
        label: t("products.productStatus.draft"),
        value: import_types.ProductStatus.DRAFT
      },
      {
        label: t("products.productStatus.proposed"),
        value: import_types.ProductStatus.PROPOSED
      },
      {
        label: t("products.productStatus.published"),
        value: import_types.ProductStatus.PUBLISHED
      },
      {
        label: t("products.productStatus.rejected"),
        value: import_types.ProductStatus.REJECTED
      }
    ]
  };
  const dateFilters = [
    { label: t("fields.createdAt"), key: "created_at" },
    { label: t("fields.updatedAt"), key: "updated_at" }
  ].map((f) => ({
    key: f.key,
    label: f.label,
    type: "date"
  }));
  filters = [...filters, statusFilter, ...dateFilters];
  return filters;
};

export {
  useProductTableFilters
};
