import {
  useProductTagTableColumns
} from "./chunk-N335VHD3.js";
import {
  useProductTagTableQuery
} from "./chunk-BI2AYXZQ.js";
import {
  useProductTagTableFilters
} from "./chunk-HHD2VUED.js";
import {
  SingleColumnPage
} from "./chunk-YV6MK4PZ.js";
import {
  _DataTable,
  useDataTable
} from "./chunk-7TQNE3E2.js";
import {
  useProductTags
} from "./chunk-RLRWDHME.js";

// src/pages/settings/product-tags/product-tag-list-page.tsx
import { Children as Children3 } from "react";
import { WidgetZone } from "@mercurjs/dashboard-shared";

// src/pages/settings/product-tags/_components/product-tag-list-table.tsx
import { Children as Children2 } from "react";
import { Container } from "@medusajs/ui";

// src/pages/settings/product-tags/_components/product-tag-list-header.tsx
import { Children } from "react";
import { useTranslation } from "react-i18next";
import { Heading } from "@medusajs/ui";
import { jsx } from "react/jsx-runtime";
var ProductTagListTitle = () => {
  const { t } = useTranslation();
  return /* @__PURE__ */ jsx(Heading, { children: t("productTags.domain") });
};
var ProductTagListActions = ({
  children
}) => {
  return /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center gap-x-2", children: Children.count(children) > 0 ? children : null });
};
var ProductTagListHeader = ({
  children
}) => {
  return /* @__PURE__ */ jsx("div", { className: "flex items-center justify-between px-6 py-4", children: Children.count(children) > 0 ? children : /* @__PURE__ */ jsx(ProductTagListTitle, {}) });
};

// src/pages/settings/product-tags/_components/product-tag-list-data-table.tsx
import { keepPreviousData } from "@tanstack/react-query";
import { useMemo } from "react";
import { useTranslation as useTranslation2 } from "react-i18next";
import { useLoaderData } from "react-router-dom";
import { jsx as jsx2 } from "react/jsx-runtime";
var PAGE_SIZE = 20;
var ProductTagListDataTable = () => {
  const { t } = useTranslation2();
  const { searchParams, raw } = useProductTagTableQuery({
    pageSize: PAGE_SIZE
  });
  const initialData = useLoaderData();
  const { product_tags, count, isPending, isError, error } = useProductTags(
    searchParams,
    {
      initialData,
      placeholderData: keepPreviousData
    }
  );
  const columns = useColumns();
  const filters = useProductTagTableFilters();
  const { table } = useDataTable({
    data: product_tags,
    count,
    columns,
    getRowId: (row) => row.id,
    pageSize: PAGE_SIZE
  });
  if (isError) {
    throw error;
  }
  return /* @__PURE__ */ jsx2(
    _DataTable,
    {
      table,
      filters,
      queryObject: raw,
      isLoading: isPending,
      columns,
      pageSize: PAGE_SIZE,
      count,
      navigateTo: (row) => row.original.id,
      search: true,
      pagination: true,
      orderBy: [
        { key: "value", label: t("fields.value") },
        {
          key: "created_at",
          label: t("fields.createdAt")
        },
        {
          key: "updated_at",
          label: t("fields.updatedAt")
        }
      ]
    }
  );
};
var useColumns = () => {
  const base = useProductTagTableColumns();
  return useMemo(() => [...base], [base]);
};

// src/pages/settings/product-tags/_components/product-tag-list-table.tsx
import { Fragment, jsx as jsx3, jsxs } from "react/jsx-runtime";
var ProductTagListTable = ({
  children
}) => {
  return /* @__PURE__ */ jsx3(Container, { className: "divide-y px-0 py-0", children: Children2.count(children) > 0 ? children : /* @__PURE__ */ jsxs(Fragment, { children: [
    /* @__PURE__ */ jsx3(ProductTagListHeader, {}),
    /* @__PURE__ */ jsx3(ProductTagListDataTable, {})
  ] }) });
};

// src/pages/settings/product-tags/product-tag-list-page.tsx
import { jsx as jsx4 } from "react/jsx-runtime";
var Root = ({ children }) => {
  return /* @__PURE__ */ jsx4(SingleColumnPage, { showMetadata: false, showJSON: false, hasOutlet: true, children: /* @__PURE__ */ jsx4(WidgetZone, { id: "product-tags.list", children: Children3.count(children) > 0 ? children : /* @__PURE__ */ jsx4(ProductTagListTable, {}) }) });
};
var ProductTagListPage = Object.assign(Root, {
  Table: ProductTagListTable,
  Header: ProductTagListHeader,
  HeaderTitle: ProductTagListTitle,
  HeaderActions: ProductTagListActions,
  DataTable: ProductTagListDataTable
});

export {
  ProductTagListPage
};
