import {
  require_dist
} from "./chunk-ZZO3INVE.js";
import {
  DateRangeDisplay
} from "./chunk-RK5N3XIX.js";
import {
  DateCell
} from "./chunk-25LYVP3C.js";
import {
  getStylizedAmount
} from "./chunk-PXYDR7WQ.js";
import {
  IconAvatar
} from "./chunk-U2EI2ZLM.js";
import {
  TwoColumnPage
} from "./chunk-V5J73NPW.js";
import {
  _DataTable,
  useDataTable
} from "./chunk-ULJ3OMWU.js";
import {
  currencies
} from "./chunk-IQPN4PZJ.js";
import {
  TwoColumnPageSkeleton
} from "./chunk-INNFZYX2.js";
import {
  ActionMenu
} from "./chunk-BDGZ4EQO.js";
import {
  useMemberTableQuery
} from "./chunk-NNI6QKKZ.js";
import {
  useSubscriptionPlans
} from "./chunk-3MDRW5MA.js";
import {
  useApproveSeller,
  useRemoveSellerMember,
  useSeller,
  useSellerMembers,
  useSuspendSeller,
  useTerminateSeller,
  useUnsuspendSeller,
  useUnterminateSeller
} from "./chunk-M3YP3NX4.js";
import {
  __toESM
} from "./chunk-NBMM2TZK.js";

// src/pages/stores/store-details/components/store-details.tsx
import { Children as Children3, useState as useState2 } from "react";
import { useParams } from "react-router-dom";
var import_types3 = __toESM(require_dist(), 1);

// src/pages/stores/store-details/components/store-general-section.tsx
import { Children as Children2 } from "react";
import { Photo } from "@medusajs/icons";
import { Badge, Container, Text } from "@medusajs/ui";
import { useTranslation as useTranslation2 } from "react-i18next";

// src/pages/stores/store-details/components/store-detail-header.tsx
import { Children } from "react";
import {
  CheckCircleSolid,
  PencilSquare,
  XCircleSolid,
  XMarkMini,
  ArrowUturnLeft
} from "@medusajs/icons";
import { Avatar, Heading, StatusBadge, toast, usePrompt } from "@medusajs/ui";
import { useTranslation } from "react-i18next";
var import_types = __toESM(require_dist(), 1);
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
var getStatusColor = (status) => {
  switch (status) {
    case import_types.SellerStatus.OPEN:
      return "green";
    case import_types.SellerStatus.PENDING_APPROVAL:
      return "orange";
    case import_types.SellerStatus.SUSPENDED:
    case import_types.SellerStatus.TERMINATED:
      return "red";
    default:
      return "grey";
  }
};
var getStatusLabel = (status, t) => {
  switch (status) {
    case import_types.SellerStatus.OPEN:
      return t("stores.status.open");
    case import_types.SellerStatus.PENDING_APPROVAL:
      return t("stores.status.pending_approval");
    case import_types.SellerStatus.SUSPENDED:
      return t("stores.status.suspended");
    case import_types.SellerStatus.TERMINATED:
      return t("stores.status.terminated");
    default:
      return status;
  }
};
var StoreDetailTitle = ({ seller }) => {
  return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-4", children: [
    /* @__PURE__ */ jsx(
      Avatar,
      {
        variant: "squared",
        size: "large",
        src: seller.logo || void 0,
        fallback: seller.name.charAt(0).toUpperCase()
      }
    ),
    /* @__PURE__ */ jsx(Heading, { children: seller.name })
  ] });
};
var StoreDetailEditButton = ({ seller }) => {
  const { t } = useTranslation();
  return /* @__PURE__ */ jsx(
    ActionMenu,
    {
      groups: [
        {
          actions: [
            {
              icon: /* @__PURE__ */ jsx(PencilSquare, {}),
              label: t("actions.edit"),
              to: `/stores/${seller.id}/edit`
            }
          ]
        }
      ]
    }
  );
};
var StoreDetailActions = ({
  seller,
  children
}) => {
  const { t } = useTranslation();
  const prompt = usePrompt();
  const { mutateAsync: approveSeller } = useApproveSeller(seller.id);
  const { mutateAsync: suspendSeller } = useSuspendSeller(seller.id);
  const { mutateAsync: unsuspendSeller } = useUnsuspendSeller(seller.id);
  const { mutateAsync: terminateSeller } = useTerminateSeller(seller.id);
  const { mutateAsync: unterminateSeller } = useUnterminateSeller(seller.id);
  const handleAction = async (action, label) => {
    const res = await prompt({
      title: label.title,
      description: label.description,
      verificationText: seller.email || seller.name || "",
      confirmText: t("actions.confirm"),
      cancelText: t("actions.cancel")
    });
    if (!res) return;
    await action().then(
      () => toast.success(label.success),
      (error) => toast.error(error.message)
    );
  };
  const statusActions = (() => {
    switch (seller.status) {
      case import_types.SellerStatus.PENDING_APPROVAL:
        return [
          {
            label: t("stores.actions.approve.label"),
            onClick: () => handleAction(() => approveSeller(), {
              title: t("stores.actions.approve.title"),
              description: t("stores.actions.approve.description"),
              success: t("stores.actions.approve.success")
            }),
            icon: /* @__PURE__ */ jsx(CheckCircleSolid, {})
          },
          {
            label: t("stores.actions.terminate.label"),
            onClick: () => handleAction(() => terminateSeller(), {
              title: t("stores.actions.terminate.title"),
              description: t("stores.actions.terminate.description"),
              success: t("stores.actions.terminate.success")
            }),
            icon: /* @__PURE__ */ jsx(XCircleSolid, {})
          }
        ];
      case import_types.SellerStatus.OPEN:
        return [
          {
            label: t("stores.actions.suspend.label"),
            onClick: () => handleAction(() => suspendSeller(), {
              title: t("stores.actions.suspend.title"),
              description: t("stores.actions.suspend.description"),
              success: t("stores.actions.suspend.success")
            }),
            icon: /* @__PURE__ */ jsx(XMarkMini, {})
          }
        ];
      case import_types.SellerStatus.SUSPENDED:
        return [
          {
            label: t("stores.actions.unsuspend.label"),
            onClick: () => handleAction(() => unsuspendSeller(), {
              title: t("stores.actions.unsuspend.title"),
              description: t("stores.actions.unsuspend.description"),
              success: t("stores.actions.unsuspend.success")
            }),
            icon: /* @__PURE__ */ jsx(ArrowUturnLeft, {})
          },
          {
            label: t("stores.actions.terminate.label"),
            onClick: () => handleAction(() => terminateSeller(), {
              title: t("stores.actions.terminate.title"),
              description: t("stores.actions.terminate.description"),
              success: t("stores.actions.terminate.success")
            }),
            icon: /* @__PURE__ */ jsx(XCircleSolid, {})
          }
        ];
      case import_types.SellerStatus.TERMINATED:
        return [
          {
            label: t("stores.actions.unterminate.label"),
            onClick: () => handleAction(() => unterminateSeller(), {
              title: t("stores.actions.unterminate.title"),
              description: t("stores.actions.unterminate.description"),
              success: t("stores.actions.unterminate.success")
            }),
            icon: /* @__PURE__ */ jsx(ArrowUturnLeft, {})
          }
        ];
      default:
        return [];
    }
  })();
  return /* @__PURE__ */ jsx("div", { className: "flex items-center gap-x-2", children: Children.count(children) > 0 ? children : /* @__PURE__ */ jsxs(Fragment, { children: [
    /* @__PURE__ */ jsx(StatusBadge, { color: getStatusColor(seller.status), children: getStatusLabel(seller.status, t) }),
    /* @__PURE__ */ jsx(
      ActionMenu,
      {
        groups: [
          {
            actions: [
              {
                icon: /* @__PURE__ */ jsx(PencilSquare, {}),
                label: t("actions.edit"),
                to: `/stores/${seller.id}/edit`
              }
            ]
          },
          {
            actions: statusActions
          }
        ]
      }
    )
  ] }) });
};
var StoreDetailHeader = ({
  seller,
  children
}) => {
  return /* @__PURE__ */ jsx("div", { className: "flex items-center justify-between px-6 py-4", children: Children.count(children) > 0 ? children : /* @__PURE__ */ jsxs(Fragment, { children: [
    /* @__PURE__ */ jsx(StoreDetailTitle, { seller }),
    /* @__PURE__ */ jsx(StoreDetailActions, { seller })
  ] }) });
};

// src/pages/stores/store-details/components/store-general-section.tsx
import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
var StoreGeneralSection = ({
  seller,
  children
}) => {
  const { t } = useTranslation2();
  return /* @__PURE__ */ jsx2(Container, { className: "divide-y p-0", children: Children2.count(children) > 0 ? children : /* @__PURE__ */ jsxs2(Fragment2, { children: [
    /* @__PURE__ */ jsx2("div", { className: "bg-ui-bg-subtle relative h-32 w-full overflow-hidden rounded-t-lg", children: seller.banner ? /* @__PURE__ */ jsx2(
      "img",
      {
        src: seller.banner,
        alt: seller.name,
        className: "h-full w-full object-cover"
      }
    ) : /* @__PURE__ */ jsx2("div", { className: "flex h-full w-full items-center justify-center", children: /* @__PURE__ */ jsx2(Photo, { className: "text-ui-fg-muted" }) }) }),
    /* @__PURE__ */ jsx2(StoreDetailHeader, { seller }),
    /* @__PURE__ */ jsxs2("div", { className: "text-ui-fg-subtle grid grid-cols-2 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: seller.description || "-" })
    ] }),
    /* @__PURE__ */ jsxs2("div", { className: "text-ui-fg-subtle grid grid-cols-2 px-6 py-4", children: [
      /* @__PURE__ */ jsx2(Text, { size: "small", leading: "compact", weight: "plus", children: t("fields.handle") }),
      /* @__PURE__ */ jsx2(Text, { size: "small", leading: "compact", children: seller.handle ? `/${seller.handle}` : "-" })
    ] }),
    /* @__PURE__ */ jsxs2("div", { className: "text-ui-fg-subtle grid grid-cols-2 px-6 py-4", children: [
      /* @__PURE__ */ jsx2(Text, { size: "small", leading: "compact", weight: "plus", children: t("fields.email") }),
      /* @__PURE__ */ jsx2(Text, { size: "small", leading: "compact", children: seller.email || "-" })
    ] }),
    /* @__PURE__ */ jsxs2("div", { className: "text-ui-fg-subtle grid grid-cols-2 px-6 py-4", children: [
      /* @__PURE__ */ jsx2(Text, { size: "small", leading: "compact", weight: "plus", children: t("fields.website") }),
      /* @__PURE__ */ jsx2(Text, { size: "small", leading: "compact", children: seller.website_url || "-" })
    ] }),
    /* @__PURE__ */ jsxs2("div", { className: "text-ui-fg-subtle grid grid-cols-2 px-6 py-4", children: [
      /* @__PURE__ */ jsx2(Text, { size: "small", leading: "compact", weight: "plus", children: t("fields.currency") }),
      /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-x-2", children: [
        /* @__PURE__ */ jsx2(Badge, { size: "2xsmall", children: seller.currency_code?.toUpperCase() }),
        /* @__PURE__ */ jsx2(Text, { size: "small", leading: "compact", children: currencies[seller.currency_code.toUpperCase()].name })
      ] })
    ] }),
    /* @__PURE__ */ jsxs2("div", { className: "text-ui-fg-subtle grid grid-cols-2 items-center px-6 py-4", children: [
      /* @__PURE__ */ jsx2(Text, { size: "small", leading: "compact", weight: "plus", children: t("fields.premium") }),
      /* @__PURE__ */ jsx2(Text, { size: "small", leading: "compact", children: seller.is_premium ? t("general.yes") : t("general.no") })
    ] }),
    /* @__PURE__ */ jsxs2("div", { className: "text-ui-fg-subtle grid grid-cols-2 items-center px-6 py-4", children: [
      /* @__PURE__ */ jsx2(Text, { size: "small", leading: "compact", weight: "plus", children: t("fields.createdAt") }),
      /* @__PURE__ */ jsx2(Text, { size: "small", leading: "compact", children: new Date(seller.created_at).toLocaleDateString(void 0, {
        year: "numeric",
        month: "long",
        day: "numeric"
      }) })
    ] })
  ] }) });
};

// src/pages/stores/store-details/components/store-payment-details-section.tsx
import { CreditCard, PencilSquare as PencilSquare2 } from "@medusajs/icons";
import { Container as Container2, Heading as Heading2, Text as Text2 } from "@medusajs/ui";
import { useTranslation as useTranslation3 } from "react-i18next";
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
var StorePaymentDetailsSection = ({
  seller
}) => {
  const { t } = useTranslation3();
  const details = seller.payment_details;
  const isABA = details?.country_code === "us";
  const accountIdentifier = isABA ? details?.account_number : details?.iban;
  const subtitle = [details?.bank_name, accountIdentifier].filter(Boolean).join(" \u2022 ");
  return /* @__PURE__ */ jsxs3(Container2, { className: "p-0", children: [
    /* @__PURE__ */ jsxs3("div", { className: "flex items-center justify-between px-6 py-4", children: [
      /* @__PURE__ */ jsx3(Heading2, { level: "h2", children: t("store.paymentDetails.header") }),
      /* @__PURE__ */ jsx3(
        ActionMenu,
        {
          groups: [
            {
              actions: [
                {
                  label: t("actions.edit"),
                  icon: /* @__PURE__ */ jsx3(PencilSquare2, {}),
                  to: `/stores/${seller.id}/payment-details`
                }
              ]
            }
          ]
        }
      )
    ] }),
    /* @__PURE__ */ jsx3("div", { className: "flex flex-col gap-2 px-2 pb-2", children: /* @__PURE__ */ jsx3("div", { className: "px-4 pb-2", children: /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-4", children: [
      /* @__PURE__ */ jsx3(IconAvatar, { size: "large", variant: "squared", children: /* @__PURE__ */ jsx3(CreditCard, {}) }),
      /* @__PURE__ */ jsxs3("div", { className: "flex flex-1 flex-col", children: [
        /* @__PURE__ */ jsx3(Text2, { size: "small", leading: "compact", weight: "plus", children: details?.holder_name || "-" }),
        /* @__PURE__ */ jsx3(
          Text2,
          {
            size: "small",
            leading: "compact",
            className: "text-ui-fg-subtle",
            children: subtitle || "-"
          }
        )
      ] })
    ] }) }) })
  ] });
};

// src/pages/stores/store-details/components/store-company-details-section.tsx
import { Buildings, PencilSquare as PencilSquare3 } from "@medusajs/icons";
import { Container as Container3, Heading as Heading3, Text as Text3 } from "@medusajs/ui";
import { useTranslation as useTranslation4 } from "react-i18next";
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
var StoreCompanyDetailsSection = ({
  seller
}) => {
  const { t } = useTranslation4();
  const details = seller.professional_details;
  return /* @__PURE__ */ jsxs4(Container3, { className: "p-0", children: [
    /* @__PURE__ */ jsxs4("div", { className: "flex items-center justify-between px-6 py-4", children: [
      /* @__PURE__ */ jsx4(Heading3, { level: "h2", children: t("store.professionalDetails.header") }),
      /* @__PURE__ */ jsx4(
        ActionMenu,
        {
          groups: [
            {
              actions: [
                {
                  label: t("actions.edit"),
                  icon: /* @__PURE__ */ jsx4(PencilSquare3, {}),
                  to: `/stores/${seller.id}/professional-details`
                }
              ]
            }
          ]
        }
      )
    ] }),
    /* @__PURE__ */ jsx4("div", { className: "flex flex-col gap-2 px-2 pb-2", children: /* @__PURE__ */ jsx4("div", { className: "px-4 pb-2", children: /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-4", children: [
      /* @__PURE__ */ jsx4(IconAvatar, { size: "large", variant: "squared", children: /* @__PURE__ */ jsx4(Buildings, {}) }),
      /* @__PURE__ */ jsxs4("div", { className: "flex flex-1 flex-col", children: [
        /* @__PURE__ */ jsx4(Text3, { size: "small", leading: "compact", weight: "plus", children: details?.corporate_name || "-" }),
        /* @__PURE__ */ jsx4(
          Text3,
          {
            size: "small",
            leading: "compact",
            className: "text-ui-fg-subtle",
            children: [details?.registration_number, details?.tax_id].filter(Boolean).join(" \xB7 ") || "-"
          }
        )
      ] })
    ] }) }) })
  ] });
};

// src/pages/stores/store-details/components/store-configuration-section.tsx
import { PencilSquare as PencilSquare4 } from "@medusajs/icons";
import { Container as Container4, Heading as Heading4 } from "@medusajs/ui";
import { useTranslation as useTranslation5 } from "react-i18next";
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
var StoreConfigurationSection = ({
  seller
}) => {
  const { t } = useTranslation5();
  return /* @__PURE__ */ jsxs5(Container4, { className: "flex flex-col gap-y-4", children: [
    /* @__PURE__ */ jsxs5("div", { className: "flex items-center justify-between", children: [
      /* @__PURE__ */ jsx5(Heading4, { level: "h2", children: t("store.scheduledClosure.header") }),
      /* @__PURE__ */ jsx5(
        ActionMenu,
        {
          groups: [
            {
              actions: [
                {
                  label: t("actions.edit"),
                  icon: /* @__PURE__ */ jsx5(PencilSquare4, {}),
                  to: `/stores/${seller.id}/store-closure`
                }
              ]
            }
          ]
        }
      )
    ] }),
    /* @__PURE__ */ jsx5(
      DateRangeDisplay,
      {
        startsAt: seller.closed_from,
        endsAt: seller.closed_to,
        showTime: true
      }
    )
  ] });
};

// src/pages/stores/store-details/components/store-address-section.tsx
import { BuildingStorefront, PencilSquare as PencilSquare5 } from "@medusajs/icons";
import { Container as Container5, Heading as Heading5, Text as Text4 } from "@medusajs/ui";
import { useTranslation as useTranslation6 } from "react-i18next";
import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
var StoreAddressSection = ({ seller }) => {
  const { t } = useTranslation6();
  const address = seller.address;
  const formatAddress = () => {
    const parts = [
      address?.address_1,
      address?.city,
      address?.postal_code,
      address?.country_code?.toUpperCase()
    ].filter(Boolean);
    return parts.length > 0 ? parts.join(", ") : null;
  };
  const formattedAddress = formatAddress();
  return /* @__PURE__ */ jsxs6(Container5, { className: "p-0", children: [
    /* @__PURE__ */ jsxs6("div", { className: "flex items-center justify-between px-6 py-4", children: [
      /* @__PURE__ */ jsx6(Heading5, { level: "h2", children: t("store.address.header") }),
      /* @__PURE__ */ jsx6(
        ActionMenu,
        {
          groups: [
            {
              actions: [
                {
                  label: t("actions.edit"),
                  icon: /* @__PURE__ */ jsx6(PencilSquare5, {}),
                  to: `/stores/${seller.id}/edit-address`
                }
              ]
            }
          ]
        }
      )
    ] }),
    /* @__PURE__ */ jsx6("div", { className: "flex flex-col gap-2 px-2 pb-2", children: /* @__PURE__ */ jsx6("div", { className: "px-4 pb-2", children: /* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-4", children: [
      /* @__PURE__ */ jsx6(IconAvatar, { size: "large", variant: "squared", children: /* @__PURE__ */ jsx6(BuildingStorefront, {}) }),
      /* @__PURE__ */ jsxs6("div", { className: "flex flex-1 flex-col", children: [
        /* @__PURE__ */ jsx6(Text4, { size: "small", leading: "compact", weight: "plus", children: [address?.first_name, address?.last_name].filter(Boolean).join(" ") || "-" }),
        /* @__PURE__ */ jsx6(
          Text4,
          {
            size: "small",
            leading: "compact",
            className: "text-ui-fg-subtle",
            children: formattedAddress || "-"
          }
        )
      ] })
    ] }) }) })
  ] });
};

// src/pages/stores/store-details/components/store-subscription-section.tsx
import { CurrencyDollar, TriangleRightMini } from "@medusajs/icons";
import { Container as Container6, Heading as Heading6, Text as Text5 } from "@medusajs/ui";
import { useTranslation as useTranslation7 } from "react-i18next";
import { Link } from "react-router-dom";
import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
var StoreSubscriptionSection = ({
  seller
}) => {
  const { t } = useTranslation7();
  const { subscription_plans } = useSubscriptionPlans({
    currency_code: seller.currency_code,
    limit: 100,
    offset: 0
  });
  const plan = subscription_plans?.find(
    (p) => p.currency_code === seller.currency_code
  );
  if (!plan) {
    return null;
  }
  const override = plan.overrides?.find(
    (o) => o.reference === "seller" && o.reference_id === seller.id
  );
  const effectiveAmount = override?.monthly_amount ?? plan.monthly_amount;
  return /* @__PURE__ */ jsxs7(Container6, { className: "p-0", children: [
    /* @__PURE__ */ jsx7("div", { className: "flex items-center justify-between px-6 py-4", children: /* @__PURE__ */ jsx7(Heading6, { level: "h2", children: t("store.subscription.header") }) }),
    /* @__PURE__ */ jsx7("div", { className: "flex flex-col gap-2 px-2 pb-2", children: /* @__PURE__ */ jsx7(
      Link,
      {
        to: `/subscription-plans/${plan.id}`,
        className: "group outline-none rounded-md focus-within:shadow-borders-interactive-with-focus [&:hover>div]:bg-ui-bg-component-hover",
        children: /* @__PURE__ */ jsx7("div", { className: "shadow-elevation-card-rest bg-ui-bg-component rounded-md px-4 py-2 transition-colors", children: /* @__PURE__ */ jsxs7("div", { className: "flex items-center gap-4", children: [
          /* @__PURE__ */ jsx7(IconAvatar, { size: "large", variant: "squared", children: /* @__PURE__ */ jsx7(CurrencyDollar, {}) }),
          /* @__PURE__ */ jsxs7("div", { className: "flex flex-1 flex-col", children: [
            /* @__PURE__ */ jsx7(Text5, { size: "small", leading: "compact", weight: "plus", children: plan.currency_code.toUpperCase() }),
            /* @__PURE__ */ jsxs7(
              Text5,
              {
                size: "small",
                leading: "compact",
                className: "text-ui-fg-subtle",
                children: [
                  getStylizedAmount(effectiveAmount, plan.currency_code),
                  "/",
                  t("store.subscription.month")
                ]
              }
            )
          ] }),
          /* @__PURE__ */ jsx7("div", { className: "flex size-7 items-center justify-center", children: /* @__PURE__ */ jsx7(TriangleRightMini, { className: "text-ui-fg-muted" }) })
        ] }) })
      }
    ) })
  ] });
};

// src/pages/stores/store-details/components/store-members-section/store-members-section.tsx
import { Button, Container as Container7, Heading as Heading7 } from "@medusajs/ui";
import { useTranslation as useTranslation9 } from "react-i18next";
import { Link as Link2 } from "react-router-dom";

// src/pages/stores/store-details/components/store-members-section/store-members-data-table.tsx
import { useMemo } from "react";
import { Trash } from "@medusajs/icons";
import { toast as toast2 } from "@medusajs/ui";
import { keepPreviousData } from "@tanstack/react-query";
import { createColumnHelper } from "@tanstack/react-table";
import { useTranslation as useTranslation8 } from "react-i18next";
var import_types2 = __toESM(require_dist(), 1);
import { jsx as jsx8 } from "react/jsx-runtime";
var PAGE_SIZE = 20;
var ROLE_TRANSLATION_MAP = {
  [import_types2.SellerRole.SELLER_ADMINISTRATION]: "users.roles.administration",
  [import_types2.SellerRole.INVENTORY_MANAGEMENT]: "users.roles.inventoryManagement",
  [import_types2.SellerRole.ORDER_MANAGEMENT]: "users.roles.orderManagement",
  [import_types2.SellerRole.ACCOUNTING]: "users.roles.accounting",
  [import_types2.SellerRole.SUPPORT]: "users.roles.support"
};
var StoreMembersDataTable = ({
  sellerId
}) => {
  const { t } = useTranslation8();
  const { searchParams, raw } = useMemberTableQuery({ pageSize: PAGE_SIZE });
  const { seller_members, count, isPending, isError, error } = useSellerMembers(sellerId, searchParams, {
    placeholderData: keepPreviousData
  });
  const columns = useColumns(sellerId);
  const { table } = useDataTable({
    data: seller_members ?? [],
    columns,
    enablePagination: true,
    count,
    pageSize: PAGE_SIZE,
    getRowId: (row) => row.id
  });
  if (isError) {
    throw error;
  }
  return /* @__PURE__ */ jsx8(
    _DataTable,
    {
      table,
      columns,
      count,
      pageSize: PAGE_SIZE,
      pagination: true,
      isLoading: isPending,
      queryObject: raw,
      orderBy: [
        { key: "created_at", label: t("fields.createdAt") },
        { key: "updated_at", label: t("fields.updatedAt") }
      ],
      noRecords: {
        message: t("users.list.empty.description")
      }
    }
  );
};
var columnHelper = createColumnHelper();
var useColumns = (sellerId) => {
  const { t } = useTranslation8();
  return useMemo(
    () => [
      columnHelper.accessor("member.email", {
        header: () => /* @__PURE__ */ jsx8("div", { className: "flex h-full w-full items-center", children: /* @__PURE__ */ jsx8("span", { children: t("fields.email") }) }),
        cell: ({ row }) => {
          return /* @__PURE__ */ jsx8("div", { className: "flex size-full items-center overflow-hidden", children: /* @__PURE__ */ jsx8("span", { className: "truncate", children: row.original.member?.email }) });
        }
      }),
      columnHelper.accessor("role_id", {
        header: () => /* @__PURE__ */ jsx8("div", { className: "flex h-full w-full items-center", children: /* @__PURE__ */ jsx8("span", { children: t("fields.role") }) }),
        cell: ({ row }) => {
          const roleId = row.original.role_id;
          const translationKey = ROLE_TRANSLATION_MAP[roleId];
          const label = translationKey ? t(translationKey) : "-";
          return /* @__PURE__ */ jsx8("div", { className: "flex size-full items-center overflow-hidden", children: /* @__PURE__ */ jsx8("span", { className: "truncate", children: label }) });
        }
      }),
      columnHelper.accessor("created_at", {
        header: () => /* @__PURE__ */ jsx8("div", { className: "flex h-full w-full items-center", children: /* @__PURE__ */ jsx8("span", { children: t("fields.createdAt") }) }),
        cell: ({ getValue }) => {
          const date = getValue();
          return /* @__PURE__ */ jsx8(DateCell, { date: date ? new Date(date) : null });
        }
      }),
      columnHelper.display({
        id: "actions",
        cell: ({ row }) => {
          return /* @__PURE__ */ jsx8(MemberActions, { member: row.original, sellerId });
        }
      })
    ],
    [t, sellerId]
  );
};
var MemberActions = ({
  member,
  sellerId
}) => {
  const { t } = useTranslation8();
  const { mutateAsync: removeMember } = useRemoveSellerMember(
    sellerId,
    member.id
  );
  const handleRemove = async () => {
    try {
      await removeMember();
      toast2.success(
        t("users.deleteUserSuccess", {
          name: member.member?.email
        })
      );
    } catch (e) {
      toast2.error(e.message);
    }
  };
  return /* @__PURE__ */ jsx8(
    ActionMenu,
    {
      groups: [
        {
          actions: [
            {
              icon: /* @__PURE__ */ jsx8(Trash, {}),
              label: t("actions.remove"),
              onClick: handleRemove
            }
          ]
        }
      ]
    }
  );
};

// src/pages/stores/store-details/components/store-members-section/store-members-section.tsx
import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
var StoreMembersSection = ({ sellerId }) => {
  const { t } = useTranslation9();
  return /* @__PURE__ */ jsxs8(Container7, { className: "divide-y p-0", children: [
    /* @__PURE__ */ jsxs8("div", { className: "flex items-center justify-between px-6 py-4", children: [
      /* @__PURE__ */ jsx9(Heading7, { level: "h2", children: t("users.domain", "Users") }),
      /* @__PURE__ */ jsx9(Link2, { to: "invite", children: /* @__PURE__ */ jsx9(Button, { size: "small", variant: "secondary", children: t("users.invite", "Invite") }) })
    ] }),
    /* @__PURE__ */ jsx9(StoreMembersDataTable, { sellerId })
  ] });
};

// src/pages/stores/store-details/components/store-request-section.tsx
import { useState } from "react";
import { ExclamationCircleSolid } from "@medusajs/icons";
import {
  Button as Button2,
  Container as Container8,
  Heading as Heading8,
  Text as Text6,
  Textarea,
  toast as toast3
} from "@medusajs/ui";
import { useTranslation as useTranslation10 } from "react-i18next";
import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
var StoreRequestSection = ({ seller }) => {
  const { t } = useTranslation10();
  const [reason, setReason] = useState("");
  const { mutateAsync: approveSeller, isPending: isApproving } = useApproveSeller(seller.id);
  const { mutateAsync: suspendSeller, isPending: isSuspending } = useSuspendSeller(seller.id);
  const handleConfirm = async () => {
    try {
      await approveSeller();
      toast3.success(
        t("stores.approve.successToast", "Store approved successfully")
      );
    } catch (error) {
      toast3.error(error.message);
    }
  };
  const handleReject = async () => {
    try {
      await suspendSeller({ reason: reason || void 0 });
      toast3.success(
        t("stores.suspend.successToast", "Store suspended successfully")
      );
    } catch (error) {
      toast3.error(error.message);
    }
  };
  return /* @__PURE__ */ jsx10(
    "div",
    {
      style: {
        background: "repeating-linear-gradient(-45deg, rgb(212, 212, 216, 0.15), rgb(212, 212, 216,.15) 10px, transparent 10px, transparent 20px)"
      },
      className: "-m-4 mb-1 border-b border-l p-4",
      children: /* @__PURE__ */ jsx10(Container8, { className: "flex items-center justify-between p-0", children: /* @__PURE__ */ jsxs9("div", { className: "flex w-full flex-col divide-y divide-dashed", children: [
        /* @__PURE__ */ jsxs9("div", { className: "flex items-center gap-2 px-6 py-4", children: [
          /* @__PURE__ */ jsx10(ExclamationCircleSolid, { className: "text-orange-500" }),
          /* @__PURE__ */ jsx10(Heading8, { level: "h2", children: t("stores.request.title", "Store request") })
        ] }),
        /* @__PURE__ */ jsx10("div", { className: "px-6 py-4", children: /* @__PURE__ */ jsx10(Text6, { className: "text-ui-fg-subtle", children: t(
          "stores.request.description",
          "A new store request has been submitted. Review the details, make any necessary updates, and choose whether to confirm and publish the store or suspend the request."
        ) }) }),
        /* @__PURE__ */ jsxs9("div", { className: "flex flex-col gap-y-2 px-6 py-4", children: [
          /* @__PURE__ */ jsx10(Text6, { size: "small", weight: "plus", className: "text-ui-fg-subtle", children: t("stores.request.reasonLabel", "Suspend reason") }),
          /* @__PURE__ */ jsx10(
            Textarea,
            {
              placeholder: t(
                "stores.request.reasonPlaceholder",
                "Optional reason for suspending this store..."
              ),
              value: reason,
              onChange: (e) => setReason(e.target.value)
            }
          )
        ] }),
        /* @__PURE__ */ jsxs9("div", { className: "bg-ui-bg-subtle flex items-center justify-end gap-x-2 rounded-b-xl px-4 py-4", children: [
          /* @__PURE__ */ jsx10(
            Button2,
            {
              size: "small",
              variant: "secondary",
              onClick: handleConfirm,
              isLoading: isApproving,
              children: t("stores.request.confirm", "Confirm")
            }
          ),
          /* @__PURE__ */ jsx10(
            Button2,
            {
              size: "small",
              variant: "secondary",
              onClick: handleReject,
              isLoading: isSuspending,
              children: t("stores.request.suspend", "Suspend")
            }
          )
        ] })
      ] }) })
    }
  );
};

// src/pages/stores/store-details/components/store-details.tsx
import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
var TABS = [{ value: "users", label: "Users" }];
var TabBar = ({
  activeTab,
  onTabChange
}) => {
  return /* @__PURE__ */ jsx11("div", { className: "flex items-center gap-x-3 py-2", children: TABS.map((tab) => {
    const isActive = activeTab === tab.value;
    return /* @__PURE__ */ jsx11(
      "button",
      {
        onClick: () => onTabChange(tab.value),
        className: `txt-compact-medium-plus rounded-full px-4 py-1.5 transition-colors ${isActive ? "border-ui-border-base bg-ui-bg-base shadow-borders-base text-ui-fg-base" : "text-ui-fg-subtle hover:text-ui-fg-base"}`,
        children: tab.label
      },
      tab.value
    );
  }) });
};
var Root = ({ children }) => {
  const { id } = useParams();
  const [activeTab, setActiveTab] = useState2("users");
  const { seller, isLoading, isError, error } = useSeller(id);
  if (isLoading || !seller) {
    return /* @__PURE__ */ jsx11(TwoColumnPageSkeleton, { mainSections: 3, sidebarSections: 3 });
  }
  if (isError) {
    throw error;
  }
  if (Children3.count(children) > 0) {
    return /* @__PURE__ */ jsx11(TwoColumnPage, { data: seller, hasOutlet: true, "data-testid": "store-detail-page", children });
  }
  return /* @__PURE__ */ jsxs10(TwoColumnPage, { data: seller, hasOutlet: true, "data-testid": "store-detail-page", children: [
    /* @__PURE__ */ jsxs10(TwoColumnPage.Main, { children: [
      seller.status === import_types3.SellerStatus.PENDING_APPROVAL && /* @__PURE__ */ jsx11(StoreRequestSection, { seller }),
      /* @__PURE__ */ jsx11(StoreGeneralSection, { seller }),
      /* @__PURE__ */ jsx11(TabBar, { activeTab, onTabChange: setActiveTab }),
      activeTab === "users" && /* @__PURE__ */ jsx11(StoreMembersSection, { sellerId: seller.id })
    ] }),
    /* @__PURE__ */ jsxs10(TwoColumnPage.Sidebar, { children: [
      /* @__PURE__ */ jsx11(StoreConfigurationSection, { seller }),
      /* @__PURE__ */ jsx11(StoreAddressSection, { seller }),
      /* @__PURE__ */ jsx11(StoreCompanyDetailsSection, { seller }),
      /* @__PURE__ */ jsx11(StorePaymentDetailsSection, { seller }),
      /* @__PURE__ */ jsx11(StoreSubscriptionSection, { seller })
    ] })
  ] });
};
var StoreDetailPage = Object.assign(Root, {
  Main: TwoColumnPage.Main,
  Sidebar: TwoColumnPage.Sidebar,
  MainGeneralSection: StoreGeneralSection,
  MainPaymentDetailsSection: StorePaymentDetailsSection,
  MainCompanyDetailsSection: StoreCompanyDetailsSection,
  SidebarConfigurationSection: StoreConfigurationSection,
  SidebarAddressSection: StoreAddressSection,
  SidebarSubscriptionSection: StoreSubscriptionSection,
  SidebarMembersSection: StoreMembersSection,
  Header: StoreDetailHeader,
  HeaderTitle: StoreDetailTitle,
  HeaderActions: StoreDetailActions,
  HeaderEditButton: StoreDetailEditButton
});

export {
  StoreDetailPage
};
