import {
  useDataTableDateFilters
} from "./chunk-NWU7EGGF.js";
import {
  useQueryParams
} from "./chunk-THHRRYRS.js";

// src/hooks/table/filters/use-attribute-table-filters.tsx
import { createDataTableFilterHelper } from "@medusajs/ui";
import { useMemo } from "react";
import { useTranslation } from "react-i18next";
var filterHelper = createDataTableFilterHelper();
var useAttributeTableFilters = () => {
  const { t } = useTranslation();
  const dateFilters = useDataTableDateFilters();
  return useMemo(
    () => [
      filterHelper.accessor("is_filterable", {
        label: t("attributes.fields.filterable"),
        type: "select",
        options: [
          { label: t("filters.radio.yes"), value: "true" },
          { label: t("filters.radio.no"), value: "false" }
        ]
      }),
      ...dateFilters
    ],
    [t, dateFilters]
  );
};

// src/hooks/table/query/use-attribute-table-query.tsx
var useAttributeTableQuery = ({
  prefix,
  pageSize = 20
}) => {
  const queryObject = useQueryParams(
    ["offset", "q", "order", "created_at", "updated_at", "is_filterable"],
    prefix
  );
  const { offset, q, order, created_at, updated_at, is_filterable } = queryObject;
  const searchParams = {
    limit: pageSize,
    offset: offset ? Number(offset) : 0,
    order,
    created_at: created_at ? JSON.parse(created_at) : void 0,
    updated_at: updated_at ? JSON.parse(updated_at) : void 0,
    is_filterable: is_filterable !== void 0 ? is_filterable === "true" : void 0,
    q
  };
  return {
    searchParams,
    raw: queryObject
  };
};

export {
  useAttributeTableFilters,
  useAttributeTableQuery
};
