import {
  DataTable
} from "./chunk-IV57G2CB.js";
import {
  currencies
} from "./chunk-IQPN4PZJ.js";
import {
  IconAvatar
} from "./chunk-U2EI2ZLM.js";
import {
  TwoColumnPage
} from "./chunk-YV6MK4PZ.js";
import {
  NoRecords
} from "./chunk-CVXKASWV.js";
import "./chunk-THHRRYRS.js";
import {
  useDate
} from "./chunk-LRD242C7.js";
import {
  require_dist
} from "./chunk-52KJSIHS.js";
import {
  TwoColumnPageSkeleton
} from "./chunk-INNFZYX2.js";
import {
  ActionMenu
} from "./chunk-BDGZ4EQO.js";
import "./chunk-LAVHRER2.js";
import "./chunk-QHQWEERJ.js";
import "./chunk-Y7QKP6QU.js";
import "./chunk-RLRWDHME.js";
import "./chunk-K5324KIX.js";
import "./chunk-FV76G2D7.js";
import "./chunk-GHDLST2P.js";
import "./chunk-YVYYOBAE.js";
import "./chunk-L2NJPDUD.js";
import "./chunk-P7UBW2EI.js";
import "./chunk-MR6REQKT.js";
import "./chunk-EPSDO2MJ.js";
import "./chunk-BHEU34FL.js";
import {
  membersQueryKeys,
  useMe,
  useSeller,
  useUpdateSeller
} from "./chunk-W34KDYZA.js";
import "./chunk-II3CLUXA.js";
import "./chunk-XKEYHWBS.js";
import "./chunk-J2XUEO2E.js";
import "./chunk-656G74I2.js";
import "./chunk-VWPNMEOE.js";
import "./chunk-O72AIZUN.js";
import "./chunk-VUWAOX7H.js";
import "./chunk-5DKUSZQ7.js";
import "./chunk-DIAWPVYS.js";
import "./chunk-4U2BLH45.js";
import "./chunk-YAUGB4LD.js";
import "./chunk-A5DJIOHN.js";
import {
  queryClient
} from "./chunk-RHKRREUU.js";
import "./chunk-ZA2KFUFR.js";
import {
  sdk
} from "./chunk-DTGEFKK4.js";
import {
  __toESM
} from "./chunk-NBMM2TZK.js";

// src/pages/settings/store/store-detail-page.tsx
import { Children as Children3 } from "react";
import { Alert, Text as Text5 } from "@medusajs/ui";
import { useTranslation as useTranslation7 } from "react-i18next";
import { WidgetZone, useLinkQuery } from "@mercurjs/dashboard-shared";
var import_types2 = __toESM(require_dist(), 1);

// src/pages/settings/store/_components/store-address-section.tsx
import { BuildingStorefront, PencilSquare } from "@medusajs/icons";
import { Container, Heading, Text } from "@medusajs/ui";
import { useTranslation } from "react-i18next";
import { jsx, jsxs } from "react/jsx-runtime";
var StoreAddressSection = ({ seller }) => {
  const { t } = useTranslation();
  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__ */ jsxs(Container, { className: "p-0", children: [
    /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-6 py-4", children: [
      /* @__PURE__ */ jsx(Heading, { level: "h2", children: t("store.address.header") }),
      /* @__PURE__ */ jsx(
        ActionMenu,
        {
          groups: [
            {
              actions: [
                {
                  label: t("actions.edit"),
                  icon: /* @__PURE__ */ jsx(PencilSquare, {}),
                  to: "address"
                }
              ]
            }
          ]
        }
      )
    ] }),
    formattedAddress ? /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2 px-2 pb-2", children: /* @__PURE__ */ jsx("div", { className: "px-4 pb-2", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4", children: [
      /* @__PURE__ */ jsx(IconAvatar, { size: "large", variant: "squared", children: /* @__PURE__ */ jsx(BuildingStorefront, {}) }),
      /* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-col", children: [
        /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", weight: "plus", children: address?.name || t("store.address.defaultName") }),
        /* @__PURE__ */ jsx(
          Text,
          {
            size: "small",
            leading: "compact",
            className: "text-ui-fg-subtle",
            children: formattedAddress
          }
        )
      ] })
    ] }) }) }) : /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-y-1 pb-6 pt-2", children: [
      /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", weight: "plus", children: t("store.address.empty.title") }),
      /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: t("store.address.empty.message") })
    ] })
  ] });
};

// src/pages/settings/store/_components/store-time-off-section.tsx
import { CalendarMini, EllipsisHorizontal, PencilSquare as PencilSquare2, Trash } from "@medusajs/icons";
import {
  Container as Container2,
  DropdownMenu,
  Heading as Heading2,
  IconButton,
  toast,
  usePrompt
} from "@medusajs/ui";
import { useMemo } from "react";
import { useTranslation as useTranslation2 } from "react-i18next";
import { Link } from "react-router-dom";
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
var StoreTimeOffSection = ({ seller }) => {
  const { t } = useTranslation2();
  const { getFullDate } = useDate();
  const prompt = usePrompt();
  const { mutateAsync: updateSeller } = useUpdateSeller(seller.id);
  const data = useMemo(() => {
    if (!seller.closed_from) return [];
    return [
      {
        id: "closure",
        closed_from: new Date(seller.closed_from),
        closed_to: seller.closed_to ? new Date(seller.closed_to) : null,
        note: seller.closure_note ?? null
      }
    ];
  }, [seller.closed_from, seller.closed_to, seller.closure_note]);
  const handleDelete = async () => {
    const confirmed = await prompt({
      title: t("store.timeOff.deleteConfirm.title"),
      description: t("store.timeOff.deleteConfirm.description"),
      confirmText: t("actions.delete"),
      cancelText: t("actions.cancel")
    });
    if (!confirmed) return;
    await updateSeller(
      { closed_from: null, closed_to: null, closure_note: null },
      {
        onSuccess: () => {
          toast.success(t("store.timeOff.deleteSuccess"));
        },
        onError: (error) => {
          toast.error(error.message);
        }
      }
    );
  };
  const columns = useMemo(
    () => [
      {
        id: "closed_from",
        header: t("store.timeOff.columns.firstDay"),
        accessorFn: (row) => getFullDate({ date: row.closed_from })
      },
      {
        id: "closed_to",
        header: t("store.timeOff.columns.lastDay"),
        accessorFn: (row) => row.closed_to ? getFullDate({ date: row.closed_to }) : "-"
      },
      {
        id: "note",
        header: t("store.timeOff.columns.note"),
        accessorFn: (row) => row.note || "-",
        cell: ({ row }) => /* @__PURE__ */ jsx2(
          "span",
          {
            className: "block max-w-[240px] truncate",
            title: row.original.note ?? void 0,
            children: row.original.note || "-"
          }
        )
      },
      {
        id: "actions",
        header: "",
        cell: () => /* @__PURE__ */ jsx2("div", { className: "flex justify-end", children: /* @__PURE__ */ jsxs2(DropdownMenu, { children: [
          /* @__PURE__ */ jsx2(DropdownMenu.Trigger, { asChild: true, children: /* @__PURE__ */ jsx2(IconButton, { variant: "transparent", size: "small", children: /* @__PURE__ */ jsx2(EllipsisHorizontal, {}) }) }),
          /* @__PURE__ */ jsxs2(DropdownMenu.Content, { children: [
            /* @__PURE__ */ jsx2(DropdownMenu.Item, { asChild: true, children: /* @__PURE__ */ jsxs2(Link, { to: "store-closure", children: [
              /* @__PURE__ */ jsx2(PencilSquare2, { className: "mr-2" }),
              t("actions.edit")
            ] }) }),
            /* @__PURE__ */ jsx2(DropdownMenu.Separator, {}),
            /* @__PURE__ */ jsxs2(DropdownMenu.Item, { onClick: handleDelete, children: [
              /* @__PURE__ */ jsx2(Trash, { className: "mr-2" }),
              t("actions.delete")
            ] })
          ] })
        ] }) }),
        meta: {
          className: "w-[1%]"
        }
      }
    ],
    /* oxlint-disable react-hooks/exhaustive-deps */
    [
      t,
      getFullDate,
      handleDelete
    ]
    /* oxlint-enable react-hooks/exhaustive-deps */
  );
  if (data.length === 0) {
    return /* @__PURE__ */ jsxs2(Container2, { className: "flex flex-col overflow-hidden p-0", children: [
      /* @__PURE__ */ jsx2("div", { className: "flex items-center justify-between px-6 py-4", children: /* @__PURE__ */ jsx2(Heading2, { level: "h2", children: t("store.timeOff.header") }) }),
      /* @__PURE__ */ jsx2(
        NoRecords,
        {
          icon: /* @__PURE__ */ jsx2(CalendarMini, { className: "text-ui-fg-subtle" }),
          title: t("store.timeOff.empty.title"),
          message: t("store.timeOff.empty.message"),
          action: {
            to: "store-closure",
            label: t("store.timeOff.empty.action")
          },
          className: "h-[300px]"
        }
      )
    ] });
  }
  return /* @__PURE__ */ jsx2(Container2, { className: "flex flex-col overflow-hidden p-0", children: /* @__PURE__ */ jsx2(
    DataTable,
    {
      data,
      columns,
      getRowId: (row) => row.id,
      rowCount: data.length,
      heading: t("store.timeOff.header"),
      enableSearch: false,
      enablePagination: false
    }
  ) });
};

// src/pages/settings/store/_components/store-general-section.tsx
import { Children as Children2 } from "react";
import { Badge, Container as Container3, Text as Text2 } from "@medusajs/ui";
import { useTranslation as useTranslation4 } from "react-i18next";
import {
  DisplayExtensionZone,
  DisplayField as DisplayField2
} from "@mercurjs/dashboard-shared";

// src/pages/settings/store/_components/store-detail-header.tsx
import { Children } from "react";
import { CheckCircleSolid, PencilSquare as PencilSquare3 } from "@medusajs/icons";
import { Avatar, Heading as Heading3, StatusBadge, Tooltip } from "@medusajs/ui";
import { useTranslation as useTranslation3 } from "react-i18next";
import { DisplayField } from "@mercurjs/dashboard-shared";
var import_types = __toESM(require_dist(), 1);
import { Fragment, jsx as jsx3, jsxs as jsxs3 } 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("store.status.active");
    case import_types.SellerStatus.PENDING_APPROVAL:
      return t("store.status.pendingApproval");
    case import_types.SellerStatus.SUSPENDED:
      return t("store.status.suspended");
    case import_types.SellerStatus.TERMINATED:
      return t("store.status.terminated");
    default:
      return status;
  }
};
var StoreDetailTitle = ({ seller }) => {
  const { t } = useTranslation3();
  return /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-x-4", children: [
    /* @__PURE__ */ jsx3(
      Avatar,
      {
        variant: "squared",
        size: "large",
        src: seller.logo || void 0,
        fallback: seller.name.charAt(0).toUpperCase()
      }
    ),
    /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-x-2", children: [
      /* @__PURE__ */ jsx3(Heading3, { children: seller.name }),
      seller.is_premium && /* @__PURE__ */ jsx3(Tooltip, { content: t("fields.premium"), children: /* @__PURE__ */ jsx3(CheckCircleSolid, { className: "text-ui-tag-blue-icon" }) })
    ] })
  ] });
};
var StoreDetailEditButton = () => {
  const { t } = useTranslation3();
  return /* @__PURE__ */ jsx3(
    ActionMenu,
    {
      groups: [
        {
          actions: [
            {
              icon: /* @__PURE__ */ jsx3(PencilSquare3, {}),
              label: t("actions.edit"),
              to: "edit"
            }
          ]
        }
      ]
    }
  );
};
var StoreDetailActions = ({
  seller,
  children
}) => {
  const { t } = useTranslation3();
  return /* @__PURE__ */ jsx3("div", { className: "flex items-center gap-x-2", children: Children.count(children) > 0 ? children : /* @__PURE__ */ jsxs3(Fragment, { children: [
    /* @__PURE__ */ jsx3(
      DisplayField,
      {
        model: "seller",
        zone: "general",
        id: "status",
        data: seller,
        children: /* @__PURE__ */ jsx3(StatusBadge, { color: getStatusColor(seller.status), children: getStatusLabel(seller.status, t) })
      }
    ),
    /* @__PURE__ */ jsx3(StoreDetailEditButton, {})
  ] }) });
};
var StoreDetailHeader = ({
  seller,
  children
}) => {
  return /* @__PURE__ */ jsx3("div", { className: "flex items-center justify-between px-6 py-4", children: Children.count(children) > 0 ? children : /* @__PURE__ */ jsxs3(Fragment, { children: [
    /* @__PURE__ */ jsx3(StoreDetailTitle, { seller }),
    /* @__PURE__ */ jsx3(StoreDetailActions, { seller })
  ] }) });
};

// src/pages/settings/store/_components/store-general-section.tsx
import { Fragment as Fragment2, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
var StoreGeneralSection = ({
  seller,
  children
}) => {
  const { t } = useTranslation4();
  return /* @__PURE__ */ jsx4(Container3, { className: "divide-y p-0", children: Children2.count(children) > 0 ? children : /* @__PURE__ */ jsxs4(Fragment2, { children: [
    /* @__PURE__ */ jsx4("div", { className: "bg-ui-bg-subtle relative h-32 w-full overflow-hidden rounded-t-lg", children: seller.banner ? /* @__PURE__ */ jsx4(
      "img",
      {
        src: seller.banner,
        alt: seller.name,
        className: "h-full w-full object-cover"
      }
    ) : /* @__PURE__ */ jsx4(
      "div",
      {
        className: "h-full w-full",
        style: {
          background: `repeating-linear-gradient(
                    -45deg,
                    transparent,
                    transparent 10px,
                    rgba(255,255,255,0.5) 10px,
                    rgba(255,255,255,0.5) 20px
                  )`
        }
      }
    ) }),
    /* @__PURE__ */ jsx4(StoreDetailHeader, { seller }),
    /* @__PURE__ */ jsx4(
      DisplayField2,
      {
        model: "seller",
        zone: "general",
        id: "description",
        data: seller,
        children: /* @__PURE__ */ jsxs4("div", { className: "text-ui-fg-subtle grid grid-cols-2 px-6 py-4", children: [
          /* @__PURE__ */ jsx4(Text2, { size: "small", leading: "compact", weight: "plus", children: t("fields.description") }),
          /* @__PURE__ */ jsx4(Text2, { size: "small", leading: "compact", children: seller.description || "-" })
        ] })
      }
    ),
    /* @__PURE__ */ jsx4(DisplayField2, { model: "seller", zone: "general", id: "handle", data: seller, children: /* @__PURE__ */ jsxs4("div", { className: "text-ui-fg-subtle grid grid-cols-2 px-6 py-4", children: [
      /* @__PURE__ */ jsx4(Text2, { size: "small", leading: "compact", weight: "plus", children: t("fields.handle") }),
      /* @__PURE__ */ jsx4(Text2, { size: "small", leading: "compact", children: seller.handle ? `/${seller.handle}` : "-" })
    ] }) }),
    /* @__PURE__ */ jsx4(DisplayField2, { model: "seller", zone: "general", id: "email", data: seller, children: /* @__PURE__ */ jsxs4("div", { className: "text-ui-fg-subtle grid grid-cols-2 px-6 py-4", children: [
      /* @__PURE__ */ jsx4(Text2, { size: "small", leading: "compact", weight: "plus", children: t("fields.email") }),
      /* @__PURE__ */ jsx4(Text2, { size: "small", leading: "compact", children: seller.email || "-" })
    ] }) }),
    /* @__PURE__ */ jsx4(DisplayField2, { model: "seller", zone: "general", id: "phone", data: seller, children: /* @__PURE__ */ jsxs4("div", { className: "text-ui-fg-subtle grid grid-cols-2 px-6 py-4", children: [
      /* @__PURE__ */ jsx4(Text2, { size: "small", leading: "compact", weight: "plus", children: t("fields.phone") }),
      /* @__PURE__ */ jsx4(Text2, { size: "small", leading: "compact", children: seller.phone || "-" })
    ] }) }),
    /* @__PURE__ */ jsx4(
      DisplayField2,
      {
        model: "seller",
        zone: "general",
        id: "website_url",
        data: seller,
        children: /* @__PURE__ */ jsxs4("div", { className: "text-ui-fg-subtle grid grid-cols-2 px-6 py-4", children: [
          /* @__PURE__ */ jsx4(Text2, { size: "small", leading: "compact", weight: "plus", children: t("fields.website") }),
          /* @__PURE__ */ jsx4(Text2, { size: "small", leading: "compact", children: seller.website_url || "-" })
        ] })
      }
    ),
    /* @__PURE__ */ jsx4(
      DisplayField2,
      {
        model: "seller",
        zone: "general",
        id: "currency_code",
        data: seller,
        children: /* @__PURE__ */ jsxs4("div", { className: "text-ui-fg-subtle grid grid-cols-2 px-6 py-4", children: [
          /* @__PURE__ */ jsx4(Text2, { size: "small", leading: "compact", weight: "plus", children: t("fields.currency") }),
          /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-x-2", children: [
            /* @__PURE__ */ jsx4(Badge, { size: "2xsmall", children: seller.currency_code?.toUpperCase() }),
            /* @__PURE__ */ jsx4(Text2, { size: "small", leading: "compact", children: currencies[seller.currency_code?.toUpperCase()]?.name || "-" })
          ] })
        ] })
      }
    ),
    /* @__PURE__ */ jsx4(
      DisplayExtensionZone,
      {
        model: "seller",
        zone: "general",
        data: seller,
        builtInFieldIds: [
          "status",
          "description",
          "handle",
          "email",
          "phone",
          "website_url",
          "currency_code"
        ]
      }
    )
  ] }) });
};

// src/pages/settings/store/_components/store-payment-details-section.tsx
import { CreditCard, PencilSquare as PencilSquare4 } from "@medusajs/icons";
import { Container as Container4, Heading as Heading4, Text as Text3 } from "@medusajs/ui";
import { useTranslation as useTranslation5 } from "react-i18next";
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
var StorePaymentDetailsSection = ({
  seller
}) => {
  const { t } = useTranslation5();
  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__ */ jsxs5(Container4, { className: "p-0", children: [
    /* @__PURE__ */ jsxs5("div", { className: "flex items-center justify-between px-6 py-4", children: [
      /* @__PURE__ */ jsx5(Heading4, { level: "h2", children: t("store.paymentDetails.header") }),
      /* @__PURE__ */ jsx5(
        ActionMenu,
        {
          groups: [
            {
              actions: [
                {
                  label: t("actions.edit"),
                  icon: /* @__PURE__ */ jsx5(PencilSquare4, {}),
                  to: "payment-details"
                }
              ]
            }
          ]
        }
      )
    ] }),
    details ? /* @__PURE__ */ jsx5("div", { className: "flex flex-col gap-2 px-2 pb-2", children: /* @__PURE__ */ jsx5("div", { className: "px-4 pb-2", children: /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-4", children: [
      /* @__PURE__ */ jsx5(IconAvatar, { size: "large", variant: "squared", children: /* @__PURE__ */ jsx5(CreditCard, {}) }),
      /* @__PURE__ */ jsxs5("div", { className: "flex flex-1 flex-col", children: [
        /* @__PURE__ */ jsx5(Text3, { size: "small", leading: "compact", weight: "plus", children: details.holder_name || "-" }),
        /* @__PURE__ */ jsx5(
          Text3,
          {
            size: "small",
            leading: "compact",
            className: "text-ui-fg-subtle",
            children: subtitle || "-"
          }
        )
      ] })
    ] }) }) }) : /* @__PURE__ */ jsxs5("div", { className: "flex flex-col items-center gap-y-1 pb-6 pt-2", children: [
      /* @__PURE__ */ jsx5(Text3, { size: "small", leading: "compact", weight: "plus", children: t("store.paymentDetails.empty.title") }),
      /* @__PURE__ */ jsx5(Text3, { size: "small", className: "text-ui-fg-muted", children: t("store.paymentDetails.empty.message") })
    ] })
  ] });
};

// src/pages/settings/store/_components/store-professional-details-section.tsx
import { Buildings, 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 StoreProfessionalDetailsSection = ({
  seller
}) => {
  const { t } = useTranslation6();
  const details = seller.professional_details;
  const hasDetails = details?.corporate_name || details?.registration_number || details?.tax_id;
  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.professionalDetails.header") }),
      /* @__PURE__ */ jsx6(
        ActionMenu,
        {
          groups: [
            {
              actions: [
                {
                  label: t("actions.edit"),
                  icon: /* @__PURE__ */ jsx6(PencilSquare5, {}),
                  to: "professional-details"
                }
              ]
            }
          ]
        }
      )
    ] }),
    hasDetails ? /* @__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(Buildings, {}) }),
      /* @__PURE__ */ jsxs6("div", { className: "flex flex-1 flex-col", children: [
        /* @__PURE__ */ jsx6(Text4, { size: "small", leading: "compact", weight: "plus", children: details?.corporate_name || "-" }),
        /* @__PURE__ */ jsx6(
          Text4,
          {
            size: "small",
            leading: "compact",
            className: "text-ui-fg-subtle",
            children: [details?.registration_number, details?.tax_id].filter(Boolean).join(" \xB7 ") || "-"
          }
        )
      ] })
    ] }) }) }) : /* @__PURE__ */ jsxs6("div", { className: "flex flex-col items-center gap-y-1 pb-6 pt-2", children: [
      /* @__PURE__ */ jsx6(Text4, { size: "small", leading: "compact", weight: "plus", children: t("store.professionalDetails.empty.title") }),
      /* @__PURE__ */ jsx6(Text4, { size: "small", className: "text-ui-fg-muted", children: t("store.professionalDetails.empty.message") })
    ] })
  ] });
};

// src/pages/settings/store/store-detail-page.tsx
import { Fragment as Fragment3, jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
var ME_SELLER_FIELDS = "+seller.*,+seller.address.*,+seller.payment_details.*,+seller.professional_details.*";
var SELLER_DETAIL_FIELDS = "+address.*,+payment_details.*,+professional_details.*";
var Root = ({ children }) => {
  const { t } = useTranslation7();
  const { seller_member, isPending, isError, error } = useMe({
    fields: ME_SELLER_FIELDS
  });
  const meSeller = seller_member?.seller;
  const query = useLinkQuery("seller", SELLER_DETAIL_FIELDS);
  const needsLinks = !!useLinkQuery("seller").fields;
  const { seller: linkedSeller, isPending: linkedPending } = useSeller(
    meSeller?.id ?? "",
    query,
    { enabled: needsLinks && !!meSeller?.id }
  );
  const seller = needsLinks ? linkedSeller : meSeller;
  if (isError) {
    throw error;
  }
  if (isPending || !seller || needsLinks && linkedPending) {
    return /* @__PURE__ */ jsx7(TwoColumnPageSkeleton, { mainSections: 3, sidebarSections: 3 });
  }
  const statusAlert = (() => {
    switch (seller.status) {
      case import_types2.SellerStatus.TERMINATED:
        return {
          variant: "error",
          title: t("store.alert.terminated.title"),
          description: seller.status_reason || t("store.alert.terminated.description")
        };
      default:
        return null;
    }
  })();
  const StatusBanner = () => /* @__PURE__ */ jsxs7(Fragment3, { children: [
    /* @__PURE__ */ jsx7(WidgetZone, { id: "seller.setup", data: seller }),
    statusAlert && /* @__PURE__ */ jsxs7(Alert, { variant: statusAlert.variant, dismissible: true, className: "p-5", children: [
      /* @__PURE__ */ jsx7("div", { className: "text-ui-fg-subtle txt-small pb-2 font-medium leading-[20px]", children: statusAlert.title }),
      /* @__PURE__ */ jsx7(Text5, { className: "text-ui-fg-subtle txt-small leading-normal", children: statusAlert.description })
    ] })
  ] });
  if (Children3.count(children) > 0) {
    return /* @__PURE__ */ jsx7(TwoColumnPage, { data: seller, hasOutlet: true, children });
  }
  return /* @__PURE__ */ jsxs7(TwoColumnPage, { data: seller, hasOutlet: true, children: [
    /* @__PURE__ */ jsxs7(TwoColumnPage.Main, { children: [
      /* @__PURE__ */ jsx7(StatusBanner, {}),
      /* @__PURE__ */ jsx7(StoreGeneralSection, { seller }),
      /* @__PURE__ */ jsx7(StoreTimeOffSection, { seller })
    ] }),
    /* @__PURE__ */ jsxs7(TwoColumnPage.Sidebar, { children: [
      /* @__PURE__ */ jsx7(StoreAddressSection, { seller }),
      /* @__PURE__ */ jsx7(StoreProfessionalDetailsSection, { seller }),
      /* @__PURE__ */ jsx7(StorePaymentDetailsSection, { seller })
    ] })
  ] });
};
var StoreDetailPage = Object.assign(Root, {
  Main: TwoColumnPage.Main,
  Sidebar: TwoColumnPage.Sidebar,
  MainGeneralSection: StoreGeneralSection,
  MainPaymentDetailsSection: StorePaymentDetailsSection,
  MainProfessionalDetailsSection: StoreProfessionalDetailsSection,
  MainTimeOffSection: StoreTimeOffSection,
  SidebarAddressSection: StoreAddressSection,
  Header: StoreDetailHeader,
  HeaderTitle: StoreDetailTitle,
  HeaderActions: StoreDetailActions,
  HeaderEditButton: StoreDetailEditButton
});

// src/pages/settings/store/loader.ts
var meQuery = () => ({
  queryKey: membersQueryKeys.me(),
  queryFn: async () => sdk.vendor.members.me.query()
});
var storeDetailLoader = async (_) => {
  return queryClient.ensureQueryData({
    ...meQuery(),
    staleTime: 9e4
  });
};
export {
  StoreDetailPage,
  storeDetailLoader as loader
};
