import {
  useDeleteShippingOptionTypeAction
} from "./chunk-Q5MX3WN7.mjs";
import {
  TextCell
} from "./chunk-DRHDNSJA.mjs";
import {
  DateCell
} from "./chunk-EJWRAUTW.mjs";
import "./chunk-P3UUX2T6.mjs";
import "./chunk-LQTHYS2Z.mjs";
import {
  _DataTable,
  useDataTable
} from "./chunk-7TWTWTDT.mjs";
import "./chunk-HQKGZADC.mjs";
import "./chunk-EMIHDNB7.mjs";
import {
  useDateTableFilters
} from "./chunk-W7625H47.mjs";
import "./chunk-XRM7PIRS.mjs";
import {
  SingleColumnPage
} from "./chunk-GIZFNLKK.mjs";
import {
  useQueryParams
} from "./chunk-C76H5USB.mjs";
import "./chunk-3BQAAPDR.mjs";
import {
  useExtension
} from "./chunk-C5P5PL3E.mjs";
import "./chunk-LPEUYMRK.mjs";
import {
  ActionMenu
} from "./chunk-OZPB6JBL.mjs";
import "./chunk-OC7BQLYI.mjs";
import "./chunk-S4DMV3ZT.mjs";
import "./chunk-QJ63TWAK.mjs";
import {
  useShippingOptionTypes
} from "./chunk-OW2UL5FI.mjs";
import "./chunk-5DUV4AET.mjs";
import "./chunk-FAB3VINY.mjs";
import "./chunk-Q7YBE4IP.mjs";
import "./chunk-HI6URQ7H.mjs";
import "./chunk-6CLQKVAU.mjs";
import "./chunk-KI7TOXBR.mjs";
import "./chunk-QBIQEVTU.mjs";
import "./chunk-WAXMT4IY.mjs";
import "./chunk-DYDGGABK.mjs";
import "./chunk-LGNTHZ5Y.mjs";
import "./chunk-CN7JXSGW.mjs";
import "./chunk-AO2USOOE.mjs";
import "./chunk-KWWLGCSY.mjs";
import "./chunk-5AFMB7XQ.mjs";
import "./chunk-5U6AZEO7.mjs";
import "./chunk-A63RZVX6.mjs";
import "./chunk-HBXV7ENS.mjs";
import "./chunk-ZBMENGLV.mjs";
import "./chunk-LGLPAUIO.mjs";
import "./chunk-CDORR33H.mjs";
import "./chunk-DE44HCDH.mjs";
import "./chunk-MUOBXNL6.mjs";
import "./chunk-BEQ5XTWH.mjs";
import "./chunk-HP2JH45P.mjs";
import "./chunk-VCSSQVPD.mjs";
import "./chunk-SQDIZZDW.mjs";
import "./chunk-LA2ILUXH.mjs";
import "./chunk-7AXHHXCX.mjs";
import "./chunk-FXYH54JP.mjs";
import "./chunk-774WSTCC.mjs";
import "./chunk-NFEK63OE.mjs";
import "./chunk-QZ7TP4HQ.mjs";

// src/routes/shipping-option-types/shipping-option-type-list/components/shipping-option-type-list-table/shipping-option-type-list-table.tsx
import { Button, Container, Heading, Text } from "@medusajs/ui";
import { keepPreviousData } from "@tanstack/react-query";
import { createColumnHelper as createColumnHelper2 } from "@tanstack/react-table";
import { useMemo as useMemo2 } from "react";
import { useTranslation as useTranslation3 } from "react-i18next";
import { Link } from "react-router-dom";

// src/hooks/table/columns/use-shipping-option-type-table-columns.tsx
import { createColumnHelper } from "@tanstack/react-table";
import { useMemo } from "react";
import { useTranslation } from "react-i18next";
import { jsx } from "react/jsx-runtime";
var columnHelper = createColumnHelper();
var useShippingOptionTypeTableColumns = () => {
  const { t } = useTranslation();
  return useMemo(
    () => [
      columnHelper.accessor("label", {
        header: () => t("fields.label"),
        cell: ({ getValue }) => /* @__PURE__ */ jsx(TextCell, { text: getValue() })
      }),
      columnHelper.accessor("code", {
        header: () => t("fields.code"),
        cell: ({ getValue }) => /* @__PURE__ */ jsx(TextCell, { text: getValue() })
      }),
      columnHelper.accessor("description", {
        header: () => t("fields.description"),
        cell: ({ getValue }) => /* @__PURE__ */ jsx(TextCell, { text: getValue() })
      }),
      columnHelper.accessor("created_at", {
        header: () => t("fields.createdAt"),
        cell: ({ getValue }) => {
          return /* @__PURE__ */ jsx(DateCell, { date: getValue() });
        }
      }),
      columnHelper.accessor("updated_at", {
        header: () => t("fields.updatedAt"),
        cell: ({ getValue }) => {
          return /* @__PURE__ */ jsx(DateCell, { date: getValue() });
        }
      })
    ],
    [t]
  );
};

// src/hooks/table/filters/use-shipping-option-type-table-filters.tsx
var useShippingOptionTypeTableFilters = () => {
  return useDateTableFilters();
};

// src/hooks/table/query/use-shipping-option-type-table-query.tsx
var useShippingOptionTypeTableQuery = ({
  prefix,
  pageSize = 20
}) => {
  const queryObject = useQueryParams(
    ["offset", "q", "order", "created_at", "updated_at"],
    prefix
  );
  const { offset, q, order, created_at, updated_at } = 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,
    q
  };
  return {
    searchParams,
    raw: queryObject
  };
};

// src/routes/shipping-option-types/shipping-option-type-list/components/shipping-option-type-list-table/shipping-option-type-table-row-actions.tsx
import { PencilSquare, Trash } from "@medusajs/icons";
import { useTranslation as useTranslation2 } from "react-i18next";
import { jsx as jsx2 } from "react/jsx-runtime";
var ShippingOptionTypeRowActions = ({
  shippingOptionType
}) => {
  const { t } = useTranslation2();
  const handleDelete = useDeleteShippingOptionTypeAction(
    shippingOptionType.id,
    shippingOptionType.label
  );
  return /* @__PURE__ */ jsx2(
    ActionMenu,
    {
      groups: [
        {
          actions: [
            {
              label: t("actions.edit"),
              icon: /* @__PURE__ */ jsx2(PencilSquare, {}),
              to: `/settings/locations/shipping-option-types/${shippingOptionType.id}/edit`
            }
          ]
        },
        {
          actions: [
            {
              label: t("actions.delete"),
              icon: /* @__PURE__ */ jsx2(Trash, {}),
              onClick: handleDelete
            }
          ]
        }
      ]
    }
  );
};

// src/routes/shipping-option-types/shipping-option-type-list/components/shipping-option-type-list-table/shipping-option-type-list-table.tsx
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
var PAGE_SIZE = 20;
var ShippingOptionTypeListTable = () => {
  const { t } = useTranslation3();
  const { searchParams, raw } = useShippingOptionTypeTableQuery({
    pageSize: PAGE_SIZE
  });
  const { shipping_option_types, count, isLoading, isError, error } = useShippingOptionTypes(searchParams, {
    placeholderData: keepPreviousData
  });
  const filters = useShippingOptionTypeTableFilters();
  const columns = useColumns();
  const { table } = useDataTable({
    columns,
    data: shipping_option_types,
    count,
    getRowId: (row) => row.id,
    pageSize: PAGE_SIZE
  });
  if (isError) {
    throw error;
  }
  return /* @__PURE__ */ jsxs(Container, { className: "divide-y p-0", children: [
    /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-6 py-4", children: [
      /* @__PURE__ */ jsxs("div", { children: [
        /* @__PURE__ */ jsx3(Heading, { children: t("shippingOptionTypes.domain") }),
        /* @__PURE__ */ jsx3(Text, { className: "text-ui-fg-subtle", size: "small", children: t("shippingOptionTypes.subtitle") })
      ] }),
      /* @__PURE__ */ jsx3(Button, { size: "small", variant: "secondary", asChild: true, children: /* @__PURE__ */ jsx3(Link, { to: "create", children: t("actions.create") }) })
    ] }),
    /* @__PURE__ */ jsx3(
      _DataTable,
      {
        table,
        filters,
        isLoading,
        columns,
        pageSize: PAGE_SIZE,
        count,
        orderBy: [
          { key: "label", label: t("fields.label") },
          { key: "code", label: t("fields.code") },
          { key: "description", label: t("fields.description") },
          { key: "created_at", label: t("fields.createdAt") },
          { key: "updated_at", label: t("fields.updatedAt") }
        ],
        navigateTo: ({ original }) => original.id,
        queryObject: raw,
        pagination: true,
        search: true
      }
    )
  ] });
};
var columnHelper2 = createColumnHelper2();
var useColumns = () => {
  const base = useShippingOptionTypeTableColumns();
  return useMemo2(
    () => [
      ...base,
      columnHelper2.display({
        id: "actions",
        cell: ({ row }) => {
          return /* @__PURE__ */ jsx3(ShippingOptionTypeRowActions, { shippingOptionType: row.original });
        }
      })
    ],
    [base]
  );
};

// src/routes/shipping-option-types/shipping-option-type-list/shipping-option-type-list.tsx
import { jsx as jsx4 } from "react/jsx-runtime";
var ShippingOptionTypeList = () => {
  const { getWidgets } = useExtension();
  return /* @__PURE__ */ jsx4(
    SingleColumnPage,
    {
      widgets: {
        after: getWidgets("shipping_option_type.list.after"),
        before: getWidgets("shipping_option_type.list.before")
      },
      children: /* @__PURE__ */ jsx4(ShippingOptionTypeListTable, {})
    }
  );
};
export {
  ShippingOptionTypeList as Component
};
