import {
  SingleColumnPage
} from "./chunk-H6MYB7GB.js";
import {
  SingleColumnPageSkeleton
} from "./chunk-INNFZYX2.js";
import {
  ActionMenu
} from "./chunk-BDGZ4EQO.js";
import {
  languages
} from "./chunk-XQNVC4Q7.js";
import {
  useMe
} from "./chunk-GKGLVDDV.js";

// src/pages/profile/profile-detail/profile-detail.tsx
import { Children } from "react";

// src/pages/profile/profile-detail/components/profile-general-section/profile-general-section.tsx
import { PencilSquare } from "@medusajs/icons";
import { Container, Heading, Text } from "@medusajs/ui";
import { useTranslation } from "react-i18next";
import { jsx, jsxs } from "react/jsx-runtime";
var ProfileGeneralSection = ({ user }) => {
  const { i18n, t } = useTranslation();
  const name = [user.first_name, user.last_name].filter(Boolean).join(" ");
  return /* @__PURE__ */ jsxs(Container, { className: "divide-y p-0", "data-testid": "profile-general-section", children: [
    /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-6 py-4", "data-testid": "profile-general-section-header", children: [
      /* @__PURE__ */ jsxs("div", { children: [
        /* @__PURE__ */ jsx(Heading, { "data-testid": "profile-general-section-heading", children: t("profile.domain") }),
        /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", size: "small", "data-testid": "profile-general-section-description", children: t("profile.manageYourProfileDetails") })
      ] }),
      /* @__PURE__ */ jsx(
        ActionMenu,
        {
          groups: [
            {
              actions: [
                {
                  label: t("actions.edit"),
                  to: "edit",
                  icon: /* @__PURE__ */ jsx(PencilSquare, {})
                }
              ]
            }
          ],
          "data-testid": "profile-general-section-action-menu"
        }
      )
    ] }),
    /* @__PURE__ */ jsxs("div", { className: "text-ui-fg-subtle grid grid-cols-2 items-center px-6 py-4", "data-testid": "profile-general-section-name-row", children: [
      /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", weight: "plus", "data-testid": "profile-general-section-name-label", children: t("fields.name") }),
      /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", "data-testid": "profile-general-section-name-value", children: name || "-" })
    ] }),
    /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 items-center px-6 py-4", "data-testid": "profile-general-section-email-row", children: [
      /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", weight: "plus", "data-testid": "profile-general-section-email-label", children: t("fields.email") }),
      /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", "data-testid": "profile-general-section-email-value", children: user.email })
    ] }),
    /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 items-center px-6 py-4", "data-testid": "profile-general-section-language-row", children: [
      /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", weight: "plus", "data-testid": "profile-general-section-language-label", children: t("profile.fields.languageLabel") }),
      /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", "data-testid": "profile-general-section-language-value", children: languages.find((lang) => lang.code === i18n.language)?.display_name || "-" })
    ] })
  ] });
};

// src/pages/profile/profile-detail/profile-detail.tsx
import { jsx as jsx2 } from "react/jsx-runtime";
var Root = ({ children }) => {
  const { user, isPending: isLoading, isError, error } = useMe();
  if (isLoading || !user) {
    return /* @__PURE__ */ jsx2(SingleColumnPageSkeleton, { sections: 1 });
  }
  if (isError) {
    throw error;
  }
  return Children.count(children) > 0 ? /* @__PURE__ */ jsx2(SingleColumnPage, { "data-testid": "profile-detail-page", children }) : /* @__PURE__ */ jsx2(SingleColumnPage, { "data-testid": "profile-detail-page", children: /* @__PURE__ */ jsx2(ProfileGeneralSection, { user }) });
};
var ProfileDetailPage = Object.assign(Root, {
  GeneralSection: ProfileGeneralSection
});

export {
  ProfileDetailPage
};
