import {
  useDeleteShippingOptionTypeAction
} from "./chunk-Q5MX3WN7.mjs";
import {
  SingleColumnPage
} from "./chunk-GIZFNLKK.mjs";
import {
  useExtension
} from "./chunk-C5P5PL3E.mjs";
import {
  SingleColumnPageSkeleton
} from "./chunk-LPEUYMRK.mjs";
import {
  ActionMenu
} from "./chunk-OZPB6JBL.mjs";
import "./chunk-OC7BQLYI.mjs";
import "./chunk-S4DMV3ZT.mjs";
import {
  shippingOptionTypesQueryKeys,
  useShippingOptionType
} 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 {
  queryClient
} from "./chunk-FXYH54JP.mjs";
import "./chunk-774WSTCC.mjs";
import {
  sdk
} from "./chunk-NFEK63OE.mjs";
import "./chunk-QZ7TP4HQ.mjs";

// src/routes/shipping-option-types/shipping-option-type-detail/breadcrumb.tsx
import { jsx } from "react/jsx-runtime";
var ShippingOptionTypeDetailBreadcrumb = (props) => {
  const { id } = props.params || {};
  const { shipping_option_type } = useShippingOptionType(id, void 0, {
    initialData: props.data,
    enabled: Boolean(id)
  });
  if (!shipping_option_type) {
    return null;
  }
  return /* @__PURE__ */ jsx("span", { children: shipping_option_type.label });
};

// src/routes/shipping-option-types/shipping-option-type-detail/loader.ts
var shippingOptionTypeDetailQuery = (id) => ({
  queryKey: shippingOptionTypesQueryKeys.detail(id),
  queryFn: async () => sdk.admin.shippingOptionType.retrieve(id)
});
var shippingOptionTypeLoader = async ({
  params
}) => {
  const id = params.id;
  const query = shippingOptionTypeDetailQuery(id);
  return queryClient.ensureQueryData(query);
};

// src/routes/shipping-option-types/shipping-option-type-detail/shipping-option-type-detail.tsx
import { useLoaderData, useParams } from "react-router-dom";

// src/routes/shipping-option-types/shipping-option-type-detail/components/shipping-option-type-general-section/shipping-option-type-general-section.tsx
import { PencilSquare, Trash } from "@medusajs/icons";
import { Container, Heading, Text } from "@medusajs/ui";
import { useTranslation } from "react-i18next";
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
var ShippingOptionTypeGeneralSection = ({
  shippingOptionType
}) => {
  const { t } = useTranslation();
  const handleDelete = useDeleteShippingOptionTypeAction(
    shippingOptionType.id,
    shippingOptionType.label
  );
  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__ */ jsx2(Heading, { children: shippingOptionType.label }),
      /* @__PURE__ */ jsx2(
        ActionMenu,
        {
          groups: [
            {
              actions: [
                {
                  label: t("actions.edit"),
                  icon: /* @__PURE__ */ jsx2(PencilSquare, {}),
                  to: "edit"
                }
              ]
            },
            {
              actions: [
                {
                  label: t("actions.delete"),
                  icon: /* @__PURE__ */ jsx2(Trash, {}),
                  onClick: handleDelete
                }
              ]
            }
          ]
        }
      )
    ] }),
    /* @__PURE__ */ jsxs("div", { className: "text-ui-fg-subtle grid grid-cols-2 items-start px-6 py-4", children: [
      /* @__PURE__ */ jsx2(Text, { size: "small", leading: "compact", weight: "plus", children: t("fields.code") }),
      /* @__PURE__ */ jsx2(Text, { size: "small", leading: "compact", children: shippingOptionType.code })
    ] }),
    /* @__PURE__ */ jsxs("div", { className: "text-ui-fg-subtle grid grid-cols-2 items-start px-6 py-4", children: [
      /* @__PURE__ */ jsx2(Text, { size: "small", leading: "compact", weight: "plus", children: t("fields.description") }),
      /* @__PURE__ */ jsx2(Text, { size: "small", leading: "compact", children: shippingOptionType.description || "-" })
    ] })
  ] });
};

// src/routes/shipping-option-types/shipping-option-type-detail/shipping-option-type-detail.tsx
import { jsx as jsx3 } from "react/jsx-runtime";
var ShippingOptionTypeDetail = () => {
  const { id } = useParams();
  const initialData = useLoaderData();
  const { shipping_option_type, isPending, isError, error } = useShippingOptionType(id, void 0, {
    initialData
  });
  const { getWidgets } = useExtension();
  if (isPending || !shipping_option_type) {
    return /* @__PURE__ */ jsx3(SingleColumnPageSkeleton, { sections: 2, showJSON: true, showMetadata: true });
  }
  if (isError) {
    throw error;
  }
  return /* @__PURE__ */ jsx3(
    SingleColumnPage,
    {
      widgets: {
        after: getWidgets("shipping_option_type.details.after"),
        before: getWidgets("shipping_option_type.details.before")
      },
      showJSON: true,
      showMetadata: true,
      data: shipping_option_type,
      children: /* @__PURE__ */ jsx3(
        ShippingOptionTypeGeneralSection,
        {
          shippingOptionType: shipping_option_type
        }
      )
    }
  );
};
export {
  ShippingOptionTypeDetailBreadcrumb as Breadcrumb,
  ShippingOptionTypeDetail as Component,
  shippingOptionTypeLoader as loader
};
