import {
  CountrySelect
} from "./chunk-7CAFYKKA.js";
import "./chunk-JRTZWK77.js";
import {
  HandleInput
} from "./chunk-HJ56YXBU.js";
import {
  Form
} from "./chunk-3QSRE5LS.js";
import {
  retrieveActiveStore,
  storeQueryKeys,
  useStore
} from "./chunk-RLRWDHME.js";
import {
  useLogout
} from "./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 {
  useCreateSellerAccount,
  useSellers
} 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 {
  assetUrl
} from "./chunk-DTGEFKK4.js";
import "./chunk-NBMM2TZK.js";

// src/pages/onboarding/loader.ts
var storeDetailQuery = () => ({
  queryKey: storeQueryKeys.details(),
  queryFn: async () => retrieveActiveStore()
});
var onboardingLoader = async () => {
  const query = storeDetailQuery();
  return queryClient.ensureQueryData(query);
};

// src/pages/onboarding/onboarding.tsx
import { useEffect } from "react";
import { Navigate, useLocation } from "react-router-dom";

// src/components/onboarding-wizard/onboarding-wizard.tsx
import { AnimatePresence } from "motion/react";
import { useNavigate as useNavigate2 } from "react-router-dom";
import { useLinkQuery } from "@mercurjs/dashboard-shared";

// src/components/onboarding-wizard/wizard-sidebar.tsx
import { ChevronLeft } from "@medusajs/icons";
import { Text } from "@medusajs/ui";
import { useTranslation } from "react-i18next";

// src/components/onboarding-wizard/constants.ts
var WIZARD_STEPS = [
  {
    id: "store",
    number: 1,
    labelKey: "onboarding.wizard.steps.store"
  },
  {
    id: "address",
    number: 2,
    labelKey: "onboarding.wizard.steps.address"
  },
  {
    id: "company",
    number: 3,
    labelKey: "onboarding.wizard.steps.company"
  },
  {
    id: "payment",
    number: 4,
    labelKey: "onboarding.wizard.steps.payment"
  }
];
var TOTAL_STEPS = WIZARD_STEPS.length;

// src/components/onboarding-wizard/wizard-sidebar.tsx
import { jsx, jsxs } from "react/jsx-runtime";
var WizardSidebar = ({
  currentStep,
  onBack,
  showBack,
  children
}) => {
  const { t } = useTranslation();
  return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col lg:w-[584px] lg:shrink-0 h-full bg-ui-bg-base border-r border-ui-border-base overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-col p-8 lg:px-14 lg:py-12", children: [
    showBack && onBack && /* @__PURE__ */ jsxs(
      "button",
      {
        type: "button",
        onClick: onBack,
        className: "txt-compact-small text-ui-fg-base flex items-center gap-x-0.5 font-medium transition-colors hover:text-ui-fg-subtle self-start mb-6",
        children: [
          /* @__PURE__ */ jsx(ChevronLeft, { className: "size-4" }),
          /* @__PURE__ */ jsx("span", { children: t("actions.back") })
        ]
      }
    ),
    /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle mb-1", children: t("onboarding.wizard.stepOf", {
      current: currentStep + 1,
      total: TOTAL_STEPS
    }) }),
    children
  ] }) });
};

// src/components/onboarding-wizard/wizard-preview.tsx
import { jsx as jsx2 } from "react/jsx-runtime";
var WizardPreview = () => {
  return /* @__PURE__ */ jsx2("div", { className: "hidden lg:flex flex-1 relative overflow-hidden", children: /* @__PURE__ */ jsx2(
    "img",
    {
      src: assetUrl("/onboarding/illustration.svg"),
      alt: "",
      className: "h-full w-full object-cover"
    }
  ) });
};

// src/components/onboarding-wizard/wizard-step.tsx
import { motion } from "motion/react";
import { jsx as jsx3 } from "react/jsx-runtime";
var stepVariants = {
  initial: { opacity: 0, y: 12, filter: "blur(4px)" },
  animate: { opacity: 1, y: 0, filter: "blur(0px)" },
  exit: {
    opacity: 0,
    y: -8,
    filter: "blur(4px)",
    transition: { duration: 0.2, ease: [0.23, 1, 0.32, 1] }
  }
};
var WizardStep = ({ children }) => {
  return /* @__PURE__ */ jsx3(
    motion.div,
    {
      variants: stepVariants,
      initial: "initial",
      animate: "animate",
      exit: "exit",
      transition: { duration: 0.35, ease: [0.23, 1, 0.32, 1] },
      className: "flex flex-col",
      children
    }
  );
};

// src/components/onboarding-wizard/hooks/use-onboarding.ts
import { useState, useCallback, useRef } from "react";
import { useNavigate } from "react-router-dom";
import { toast } from "@medusajs/ui";
var useOnboarding = (memberEmail) => {
  const navigate = useNavigate();
  const [currentStep, setCurrentStep] = useState(0);
  const [isSubmitting, setIsSubmitting] = useState(false);
  const sellerIdRef = useRef(null);
  const [sellerIdState, setSellerIdState] = useState(null);
  const setSellerId = (id) => {
    sellerIdRef.current = id;
    setSellerIdState(id);
  };
  const storeDataRef = useRef(null);
  const addressDataRef = useRef(null);
  const companyDataRef = useRef(null);
  const { mutateAsync: createSeller, isPending: isCreating } = useCreateSellerAccount();
  const { mutateAsync: logout } = useLogout();
  const isPending = isCreating || isSubmitting;
  const submitStoreStep = useCallback(async (data) => {
    storeDataRef.current = data;
    setCurrentStep(1);
  }, []);
  const submitAddressStep = useCallback(async (data) => {
    addressDataRef.current = data;
    setCurrentStep(2);
  }, []);
  const skipAddressStep = useCallback(() => {
    addressDataRef.current = null;
    setCurrentStep(2);
  }, []);
  const submitCompanyStep = useCallback(async (data) => {
    companyDataRef.current = data;
    setCurrentStep(3);
  }, []);
  const skipCompanyStep = useCallback(() => {
    companyDataRef.current = null;
    setCurrentStep(3);
  }, []);
  const createSellerWithAllData = useCallback(
    async (paymentData) => {
      const storeData = storeDataRef.current;
      if (!storeData) return;
      if (sellerIdRef.current) {
        navigate("/store-select", { replace: true });
        return;
      }
      const addressData = addressDataRef.current;
      const companyData = companyDataRef.current;
      const hasCompanyData = companyData?.corporate_name || companyData?.registration_number || companyData?.tax_id;
      const isUS = paymentData?.country_code === "us";
      let registerDraft = {};
      try {
        const raw = sessionStorage.getItem("mercur_register_draft");
        if (raw) {
          const parsed = JSON.parse(raw);
          registerDraft = {
            first_name: parsed.first_name || void 0,
            last_name: parsed.last_name || void 0
          };
        }
      } catch {
      }
      try {
        setIsSubmitting(true);
        const result = await createSeller({
          name: storeData.name,
          handle: storeData.handle || void 0,
          email: storeData.email,
          phone: storeData.phone || void 0,
          member_email: memberEmail,
          first_name: registerDraft.first_name,
          last_name: registerDraft.last_name,
          currency_code: storeData.currency_code.toLowerCase(),
          description: storeData.description || void 0,
          ...storeData.additional_data && Object.keys(storeData.additional_data).length ? { additional_data: storeData.additional_data } : {},
          address: addressData ? {
            name: addressData.name || void 0,
            address_1: addressData.address_1 || void 0,
            address_2: addressData.address_2 || void 0,
            postal_code: addressData.postal_code || void 0,
            city: addressData.city || void 0,
            country_code: addressData.country_code,
            province: addressData.province || void 0
          } : void 0,
          professional_details: hasCompanyData ? {
            corporate_name: companyData.corporate_name || void 0,
            registration_number: companyData.registration_number || void 0,
            tax_id: companyData.tax_id || void 0
          } : void 0,
          payment_details: paymentData ? {
            country_code: paymentData.country_code,
            holder_name: paymentData.holder_name,
            iban: isUS ? null : paymentData.iban || null,
            bic: isUS ? null : paymentData.bic || null,
            routing_number: isUS ? paymentData.routing_number || null : null,
            account_number: paymentData.account_number || null
          } : void 0
        });
        const newSellerId = result.seller.id;
        setSellerId(newSellerId);
        try {
          await logout();
        } catch {
        }
        queryClient.clear();
        sessionStorage.removeItem("mercur_onboarding_email");
        sessionStorage.removeItem("mercur_register_draft");
        navigate("/login", { replace: true });
      } catch (error) {
        toast.error(error.message);
      } finally {
        setIsSubmitting(false);
      }
    },
    [createSeller, logout, memberEmail, navigate]
  );
  const submitPaymentStep = useCallback(
    async (data) => {
      await createSellerWithAllData(data);
    },
    [createSellerWithAllData]
  );
  const skipPaymentStep = useCallback(async () => {
    await createSellerWithAllData();
  }, [createSellerWithAllData]);
  const goBack = useCallback(() => {
    if (currentStep > 0) {
      setCurrentStep((prev) => prev - 1);
    }
  }, [currentStep]);
  return {
    currentStep,
    totalSteps: TOTAL_STEPS,
    sellerId: sellerIdState,
    isPending,
    canGoBack: currentStep > 0,
    goBack,
    submitStoreStep,
    submitAddressStep,
    skipAddressStep,
    submitCompanyStep,
    skipCompanyStep,
    submitPaymentStep,
    skipPaymentStep
  };
};

// src/components/onboarding-wizard/steps/store-step.tsx
import { Button, Heading, Input, Select, Textarea } from "@medusajs/ui";
import i18n from "i18next";
import { useTranslation as useTranslation2 } from "react-i18next";
import { useLoaderData } from "react-router-dom";
import * as z from "zod";
import {
  FormExtensionZone,
  useExtendableForm
} from "@mercurjs/dashboard-shared";
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
var StoreStepSchema = z.object({
  name: z.string().min(1, i18n.t("onboarding.wizard.validation.nameRequired")),
  email: z.string().email(i18n.t("onboarding.wizard.validation.emailInvalid")),
  phone: z.string().optional(),
  currency_code: z.string().min(1, i18n.t("onboarding.wizard.validation.currencyRequired")),
  description: z.string().optional(),
  handle: z.string().optional()
});
var StoreStep = ({ onSubmit, isPending }) => {
  const { t } = useTranslation2();
  const initialData = useLoaderData();
  const { store } = useStore(void 0, { initialData });
  const form = useExtendableForm({
    schema: StoreStepSchema,
    model: "seller",
    zone: "onboarding",
    tab: "store",
    data: store,
    defaultValues: {
      name: "",
      email: "",
      phone: "",
      currency_code: "",
      description: "",
      handle: ""
    }
  });
  const handleSubmit = form.handleSubmit(async (data) => {
    await onSubmit(data);
  });
  return /* @__PURE__ */ jsxs2("div", { className: "flex flex-col gap-y-8", children: [
    /* @__PURE__ */ jsx4(Heading, { level: "h2", className: "text-ui-fg-base text-lg", children: t("onboarding.wizard.store.title") }),
    /* @__PURE__ */ jsx4(Form, { ...form, children: /* @__PURE__ */ jsxs2("form", { onSubmit: handleSubmit, className: "flex flex-col gap-y-6", children: [
      /* @__PURE__ */ jsxs2("div", { className: "flex flex-col gap-y-4", children: [
        /* @__PURE__ */ jsx4(
          Form.Field,
          {
            control: form.control,
            name: "name",
            render: ({ field }) => /* @__PURE__ */ jsxs2(Form.Item, { children: [
              /* @__PURE__ */ jsx4(Form.Label, { children: t("onboarding.wizard.store.name") }),
              /* @__PURE__ */ jsx4(Form.Control, { children: /* @__PURE__ */ jsx4(Input, { autoComplete: "organization", ...field }) }),
              /* @__PURE__ */ jsx4(Form.ErrorMessage, {})
            ] })
          }
        ),
        /* @__PURE__ */ jsx4(
          Form.Field,
          {
            control: form.control,
            name: "email",
            render: ({ field }) => /* @__PURE__ */ jsxs2(Form.Item, { children: [
              /* @__PURE__ */ jsx4(Form.Label, { children: t("onboarding.wizard.store.email") }),
              /* @__PURE__ */ jsx4(Form.Control, { children: /* @__PURE__ */ jsx4(Input, { type: "email", autoComplete: "email", ...field }) }),
              /* @__PURE__ */ jsx4(Form.ErrorMessage, {})
            ] })
          }
        ),
        /* @__PURE__ */ jsx4(
          Form.Field,
          {
            control: form.control,
            name: "phone",
            render: ({ field }) => /* @__PURE__ */ jsxs2(Form.Item, { children: [
              /* @__PURE__ */ jsx4(Form.Label, { optional: true, children: t("fields.phone") }),
              /* @__PURE__ */ jsx4(Form.Control, { children: /* @__PURE__ */ jsx4(Input, { type: "tel", autoComplete: "tel", ...field }) }),
              /* @__PURE__ */ jsx4(Form.ErrorMessage, {})
            ] })
          }
        ),
        /* @__PURE__ */ jsx4(
          Form.Field,
          {
            control: form.control,
            name: "description",
            render: ({ field }) => /* @__PURE__ */ jsxs2(Form.Item, { children: [
              /* @__PURE__ */ jsx4(Form.Label, { optional: true, children: t("fields.description") }),
              /* @__PURE__ */ jsx4(Form.Control, { children: /* @__PURE__ */ jsx4(Textarea, { ...field }) }),
              /* @__PURE__ */ jsx4(Form.ErrorMessage, {})
            ] })
          }
        ),
        /* @__PURE__ */ jsx4(
          Form.Field,
          {
            control: form.control,
            name: "handle",
            render: ({ field }) => /* @__PURE__ */ jsxs2(Form.Item, { children: [
              /* @__PURE__ */ jsx4(
                Form.Label,
                {
                  optional: true,
                  tooltip: t("onboarding.wizard.store.handleTooltip"),
                  children: t("onboarding.wizard.store.handle")
                }
              ),
              /* @__PURE__ */ jsx4(Form.Control, { children: /* @__PURE__ */ jsx4(HandleInput, { ...field }) }),
              /* @__PURE__ */ jsx4(Form.ErrorMessage, {})
            ] })
          }
        ),
        /* @__PURE__ */ jsx4(
          Form.Field,
          {
            control: form.control,
            name: "currency_code",
            render: ({ field: { onChange, ref, ...field } }) => /* @__PURE__ */ jsxs2(Form.Item, { children: [
              /* @__PURE__ */ jsx4(Form.Label, { children: t("onboarding.wizard.store.currency") }),
              /* @__PURE__ */ jsx4(Form.Control, { children: /* @__PURE__ */ jsxs2(Select, { ...field, onValueChange: onChange, children: [
                /* @__PURE__ */ jsx4(Select.Trigger, { ref, children: /* @__PURE__ */ jsx4(
                  Select.Value,
                  {
                    placeholder: t("onboarding.wizard.store.selectCurrency")
                  }
                ) }),
                /* @__PURE__ */ jsx4(Select.Content, { children: store?.supported_currencies?.map((sc) => /* @__PURE__ */ jsx4(
                  Select.Item,
                  {
                    value: sc.currency_code,
                    children: sc.currency_code.toUpperCase()
                  },
                  sc.currency_code
                )) })
              ] }) }),
              /* @__PURE__ */ jsx4(Form.ErrorMessage, {})
            ] })
          }
        ),
        /* @__PURE__ */ jsx4(
          FormExtensionZone,
          {
            model: "seller",
            zone: "onboarding",
            tab: "store",
            control: form.control,
            data: store
          }
        )
      ] }),
      /* @__PURE__ */ jsx4(Button, { type: "submit", className: "w-full", isLoading: isPending, children: t("actions.continue") })
    ] }) })
  ] });
};

// src/components/onboarding-wizard/steps/address-step.tsx
import { zodResolver } from "@hookform/resolvers/zod";
import { Button as Button2, Heading as Heading2, Input as Input2 } from "@medusajs/ui";
import i18n2 from "i18next";
import { useForm } from "react-hook-form";
import { useTranslation as useTranslation3 } from "react-i18next";
import * as z2 from "zod";
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
var AddressStepSchema = z2.object({
  name: z2.string().min(1, i18n2.t("onboarding.wizard.validation.nameRequired")),
  address_1: z2.string().optional(),
  address_2: z2.string().optional(),
  postal_code: z2.string().optional(),
  city: z2.string().optional(),
  country_code: z2.string().min(1, i18n2.t("onboarding.wizard.validation.countryRequired")),
  province: z2.string().optional()
});
var AddressStep = ({ onSubmit, onSkip, isPending }) => {
  const { t } = useTranslation3();
  const form = useForm({
    resolver: zodResolver(AddressStepSchema),
    defaultValues: {
      name: "",
      address_1: "",
      address_2: "",
      postal_code: "",
      city: "",
      country_code: "",
      province: ""
    }
  });
  const handleSubmit = form.handleSubmit(async (data) => {
    await onSubmit(data);
  });
  return /* @__PURE__ */ jsxs3("div", { className: "flex flex-col gap-y-8", children: [
    /* @__PURE__ */ jsx5(Heading2, { level: "h2", className: "text-ui-fg-base text-lg", children: t("onboarding.wizard.address.title") }),
    /* @__PURE__ */ jsx5(Form, { ...form, children: /* @__PURE__ */ jsxs3("form", { onSubmit: handleSubmit, className: "flex flex-col gap-y-6", children: [
      /* @__PURE__ */ jsxs3("div", { className: "flex flex-col gap-y-4", children: [
        /* @__PURE__ */ jsx5(
          Form.Field,
          {
            control: form.control,
            name: "name",
            render: ({ field }) => /* @__PURE__ */ jsxs3(Form.Item, { children: [
              /* @__PURE__ */ jsx5(Form.Label, { children: t("onboarding.wizard.address.name") }),
              /* @__PURE__ */ jsx5(Form.Control, { children: /* @__PURE__ */ jsx5(Input2, { ...field }) }),
              /* @__PURE__ */ jsx5(Form.ErrorMessage, {})
            ] })
          }
        ),
        /* @__PURE__ */ jsx5(
          Form.Field,
          {
            control: form.control,
            name: "address_1",
            render: ({ field }) => /* @__PURE__ */ jsxs3(Form.Item, { children: [
              /* @__PURE__ */ jsx5(Form.Label, { optional: true, children: t("onboarding.wizard.address.address") }),
              /* @__PURE__ */ jsx5(Form.Control, { children: /* @__PURE__ */ jsx5(Input2, { autoComplete: "address-line1", ...field }) }),
              /* @__PURE__ */ jsx5(Form.ErrorMessage, {})
            ] })
          }
        ),
        /* @__PURE__ */ jsx5(
          Form.Field,
          {
            control: form.control,
            name: "address_2",
            render: ({ field }) => /* @__PURE__ */ jsxs3(Form.Item, { children: [
              /* @__PURE__ */ jsx5(Form.Label, { optional: true, children: t("onboarding.wizard.address.address2") }),
              /* @__PURE__ */ jsx5(Form.Control, { children: /* @__PURE__ */ jsx5(Input2, { autoComplete: "address-line2", ...field }) }),
              /* @__PURE__ */ jsx5(Form.ErrorMessage, {})
            ] })
          }
        ),
        /* @__PURE__ */ jsx5(
          Form.Field,
          {
            control: form.control,
            name: "postal_code",
            render: ({ field }) => /* @__PURE__ */ jsxs3(Form.Item, { children: [
              /* @__PURE__ */ jsx5(Form.Label, { optional: true, children: t("onboarding.wizard.address.postalCode") }),
              /* @__PURE__ */ jsx5(Form.Control, { children: /* @__PURE__ */ jsx5(Input2, { autoComplete: "postal-code", ...field }) }),
              /* @__PURE__ */ jsx5(Form.ErrorMessage, {})
            ] })
          }
        ),
        /* @__PURE__ */ jsx5(
          Form.Field,
          {
            control: form.control,
            name: "city",
            render: ({ field }) => /* @__PURE__ */ jsxs3(Form.Item, { children: [
              /* @__PURE__ */ jsx5(Form.Label, { optional: true, children: t("onboarding.wizard.address.city") }),
              /* @__PURE__ */ jsx5(Form.Control, { children: /* @__PURE__ */ jsx5(Input2, { autoComplete: "address-level2", ...field }) }),
              /* @__PURE__ */ jsx5(Form.ErrorMessage, {})
            ] })
          }
        ),
        /* @__PURE__ */ jsx5(
          Form.Field,
          {
            control: form.control,
            name: "country_code",
            render: ({ field: { onChange, ref: _ref, ...field } }) => /* @__PURE__ */ jsxs3(Form.Item, { children: [
              /* @__PURE__ */ jsx5(Form.Label, { children: t("onboarding.wizard.address.country") }),
              /* @__PURE__ */ jsx5(Form.Control, { children: /* @__PURE__ */ jsx5(CountrySelect, { ...field, onChange }) }),
              /* @__PURE__ */ jsx5(Form.ErrorMessage, {})
            ] })
          }
        ),
        /* @__PURE__ */ jsx5(
          Form.Field,
          {
            control: form.control,
            name: "province",
            render: ({ field }) => /* @__PURE__ */ jsxs3(Form.Item, { children: [
              /* @__PURE__ */ jsx5(Form.Label, { optional: true, children: t("onboarding.wizard.address.state") }),
              /* @__PURE__ */ jsx5(Form.Control, { children: /* @__PURE__ */ jsx5(Input2, { autoComplete: "address-level1", ...field }) }),
              /* @__PURE__ */ jsx5(Form.ErrorMessage, {})
            ] })
          }
        )
      ] }),
      /* @__PURE__ */ jsxs3("div", { className: "flex flex-col gap-y-2", children: [
        /* @__PURE__ */ jsx5(Button2, { type: "submit", className: "w-full", isLoading: isPending, children: t("actions.continue") }),
        /* @__PURE__ */ jsx5(
          Button2,
          {
            type: "button",
            variant: "transparent",
            className: "w-full",
            onClick: onSkip,
            children: t("onboarding.wizard.skip")
          }
        )
      ] })
    ] }) })
  ] });
};

// src/components/onboarding-wizard/steps/company-step.tsx
import { zodResolver as zodResolver2 } from "@hookform/resolvers/zod";
import { Button as Button3, Heading as Heading3, Input as Input3 } from "@medusajs/ui";
import { useForm as useForm2 } from "react-hook-form";
import { useTranslation as useTranslation4 } from "react-i18next";
import * as z3 from "zod";
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
var CompanyStepSchema = z3.object({
  corporate_name: z3.string().optional(),
  registration_number: z3.string().optional(),
  tax_id: z3.string().optional()
});
var CompanyStep = ({ onSubmit, onSkip, isPending }) => {
  const { t } = useTranslation4();
  const form = useForm2({
    resolver: zodResolver2(CompanyStepSchema),
    defaultValues: {
      corporate_name: "",
      registration_number: "",
      tax_id: ""
    }
  });
  const handleSubmit = form.handleSubmit(async (data) => {
    await onSubmit(data);
  });
  return /* @__PURE__ */ jsxs4("div", { className: "flex flex-col gap-y-8", children: [
    /* @__PURE__ */ jsx6(Heading3, { level: "h2", className: "text-ui-fg-base text-lg", children: t("onboarding.wizard.company.title") }),
    /* @__PURE__ */ jsx6(Form, { ...form, children: /* @__PURE__ */ jsxs4("form", { onSubmit: handleSubmit, className: "flex flex-col gap-y-6", children: [
      /* @__PURE__ */ jsxs4("div", { className: "flex flex-col gap-y-4", children: [
        /* @__PURE__ */ jsx6(
          Form.Field,
          {
            control: form.control,
            name: "corporate_name",
            render: ({ field }) => /* @__PURE__ */ jsxs4(Form.Item, { children: [
              /* @__PURE__ */ jsx6(Form.Label, { optional: true, children: t("onboarding.wizard.company.corporateName") }),
              /* @__PURE__ */ jsx6(Form.Control, { children: /* @__PURE__ */ jsx6(Input3, { ...field }) }),
              /* @__PURE__ */ jsx6(Form.ErrorMessage, {})
            ] })
          }
        ),
        /* @__PURE__ */ jsx6(
          Form.Field,
          {
            control: form.control,
            name: "registration_number",
            render: ({ field }) => /* @__PURE__ */ jsxs4(Form.Item, { children: [
              /* @__PURE__ */ jsx6(Form.Label, { optional: true, children: t("onboarding.wizard.company.registrationNumber") }),
              /* @__PURE__ */ jsx6(Form.Control, { children: /* @__PURE__ */ jsx6(Input3, { ...field }) }),
              /* @__PURE__ */ jsx6(Form.ErrorMessage, {})
            ] })
          }
        ),
        /* @__PURE__ */ jsx6(
          Form.Field,
          {
            control: form.control,
            name: "tax_id",
            render: ({ field }) => /* @__PURE__ */ jsxs4(Form.Item, { children: [
              /* @__PURE__ */ jsx6(Form.Label, { optional: true, children: t("onboarding.wizard.company.taxId") }),
              /* @__PURE__ */ jsx6(Form.Control, { children: /* @__PURE__ */ jsx6(Input3, { ...field }) }),
              /* @__PURE__ */ jsx6(Form.ErrorMessage, {})
            ] })
          }
        )
      ] }),
      /* @__PURE__ */ jsxs4("div", { className: "flex flex-col gap-y-2", children: [
        /* @__PURE__ */ jsx6(Button3, { type: "submit", className: "w-full", isLoading: isPending, children: t("actions.continue") }),
        /* @__PURE__ */ jsx6(
          Button3,
          {
            type: "button",
            variant: "transparent",
            className: "w-full",
            onClick: onSkip,
            children: t("onboarding.wizard.skip")
          }
        )
      ] })
    ] }) })
  ] });
};

// src/components/onboarding-wizard/steps/payment-step.tsx
import { zodResolver as zodResolver3 } from "@hookform/resolvers/zod";
import { Button as Button4, Heading as Heading4, Input as Input4 } from "@medusajs/ui";
import i18n3 from "i18next";
import { useForm as useForm3 } from "react-hook-form";
import { useTranslation as useTranslation5 } from "react-i18next";
import * as z4 from "zod";
import { Fragment, jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
var PaymentStepSchema = z4.object({
  country_code: z4.string().min(1, i18n3.t("onboarding.wizard.validation.countryRequired")),
  holder_name: z4.string().min(1, i18n3.t("onboarding.wizard.validation.accountNameRequired")),
  iban: z4.string().optional(),
  bic: z4.string().optional(),
  routing_number: z4.string().optional(),
  account_number: z4.string().optional()
});
var PaymentStep = ({
  onSubmit,
  onSkip,
  isPending
}) => {
  const { t } = useTranslation5();
  const form = useForm3({
    resolver: zodResolver3(PaymentStepSchema),
    defaultValues: {
      country_code: "",
      holder_name: "",
      iban: "",
      bic: "",
      routing_number: "",
      account_number: ""
    }
  });
  const selectedCountry = form.watch("country_code");
  const isUS = selectedCountry === "us";
  const handleSubmit = form.handleSubmit(async (data) => {
    await onSubmit(data);
  });
  return /* @__PURE__ */ jsxs5("div", { className: "flex flex-col gap-y-8", children: [
    /* @__PURE__ */ jsx7(Heading4, { level: "h2", className: "text-ui-fg-base text-lg", children: t("onboarding.wizard.payment.title") }),
    /* @__PURE__ */ jsx7(Form, { ...form, children: /* @__PURE__ */ jsxs5("form", { onSubmit: handleSubmit, className: "flex flex-col gap-y-6", children: [
      /* @__PURE__ */ jsxs5("div", { className: "flex flex-col gap-y-4", children: [
        /* @__PURE__ */ jsx7(
          Form.Field,
          {
            control: form.control,
            name: "country_code",
            render: ({ field: { onChange, ref: _ref, ...field } }) => /* @__PURE__ */ jsxs5(Form.Item, { children: [
              /* @__PURE__ */ jsx7(Form.Label, { children: t("onboarding.wizard.address.country") }),
              /* @__PURE__ */ jsx7(Form.Control, { children: /* @__PURE__ */ jsx7(CountrySelect, { ...field, onChange }) }),
              /* @__PURE__ */ jsx7(Form.ErrorMessage, {})
            ] })
          }
        ),
        selectedCountry && /* @__PURE__ */ jsxs5(Fragment, { children: [
          /* @__PURE__ */ jsx7(
            Form.Field,
            {
              control: form.control,
              name: "holder_name",
              render: ({ field }) => /* @__PURE__ */ jsxs5(Form.Item, { children: [
                /* @__PURE__ */ jsx7(Form.Label, { children: t("onboarding.wizard.payment.accountName") }),
                /* @__PURE__ */ jsx7(Form.Control, { children: /* @__PURE__ */ jsx7(Input4, { ...field }) }),
                /* @__PURE__ */ jsx7(Form.ErrorMessage, {})
              ] })
            }
          ),
          isUS ? /* @__PURE__ */ jsxs5(Fragment, { children: [
            /* @__PURE__ */ jsx7(
              Form.Field,
              {
                control: form.control,
                name: "account_number",
                render: ({ field }) => /* @__PURE__ */ jsxs5(Form.Item, { children: [
                  /* @__PURE__ */ jsx7(Form.Label, { optional: true, children: t("onboarding.wizard.payment.accountNumber") }),
                  /* @__PURE__ */ jsx7(Form.Control, { children: /* @__PURE__ */ jsx7(Input4, { ...field }) }),
                  /* @__PURE__ */ jsx7(Form.ErrorMessage, {})
                ] })
              }
            ),
            /* @__PURE__ */ jsx7(
              Form.Field,
              {
                control: form.control,
                name: "routing_number",
                render: ({ field }) => /* @__PURE__ */ jsxs5(Form.Item, { children: [
                  /* @__PURE__ */ jsx7(Form.Label, { optional: true, children: t("onboarding.wizard.payment.achRoutingNumber") }),
                  /* @__PURE__ */ jsx7(Form.Control, { children: /* @__PURE__ */ jsx7(Input4, { ...field }) }),
                  /* @__PURE__ */ jsx7(Form.ErrorMessage, {})
                ] })
              }
            )
          ] }) : /* @__PURE__ */ jsxs5(Fragment, { children: [
            /* @__PURE__ */ jsx7(
              Form.Field,
              {
                control: form.control,
                name: "iban",
                render: ({ field }) => /* @__PURE__ */ jsxs5(Form.Item, { children: [
                  /* @__PURE__ */ jsx7(Form.Label, { optional: true, children: t("onboarding.wizard.payment.iban") }),
                  /* @__PURE__ */ jsx7(Form.Control, { children: /* @__PURE__ */ jsx7(Input4, { ...field }) }),
                  /* @__PURE__ */ jsx7(Form.ErrorMessage, {})
                ] })
              }
            ),
            /* @__PURE__ */ jsx7(
              Form.Field,
              {
                control: form.control,
                name: "account_number",
                render: ({ field }) => /* @__PURE__ */ jsxs5(Form.Item, { children: [
                  /* @__PURE__ */ jsx7(Form.Label, { optional: true, children: t("onboarding.wizard.payment.accountNumber") }),
                  /* @__PURE__ */ jsx7(Form.Control, { children: /* @__PURE__ */ jsx7(Input4, { ...field }) }),
                  /* @__PURE__ */ jsx7(Form.ErrorMessage, {})
                ] })
              }
            ),
            /* @__PURE__ */ jsx7(
              Form.Field,
              {
                control: form.control,
                name: "bic",
                render: ({ field }) => /* @__PURE__ */ jsxs5(Form.Item, { children: [
                  /* @__PURE__ */ jsx7(Form.Label, { optional: true, children: t("onboarding.wizard.payment.swiftBic") }),
                  /* @__PURE__ */ jsx7(Form.Control, { children: /* @__PURE__ */ jsx7(Input4, { ...field }) }),
                  /* @__PURE__ */ jsx7(Form.ErrorMessage, {})
                ] })
              }
            )
          ] })
        ] })
      ] }),
      /* @__PURE__ */ jsxs5("div", { className: "flex flex-col gap-y-2", children: [
        /* @__PURE__ */ jsx7(Button4, { type: "submit", className: "w-full", isLoading: isPending, children: t("actions.continue") }),
        /* @__PURE__ */ jsx7(
          Button4,
          {
            type: "button",
            variant: "transparent",
            className: "w-full",
            onClick: onSkip,
            children: t("onboarding.wizard.skip")
          }
        )
      ] })
    ] }) })
  ] });
};

// src/components/onboarding-wizard/onboarding-wizard.tsx
import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
var OnboardingWizard = ({ memberEmail }) => {
  const navigate = useNavigate2();
  const { mutateAsync: logoutMutation } = useLogout();
  const { seller_members } = useSellers(useLinkQuery("seller"));
  const hasStores = (seller_members?.length ?? 0) > 0;
  const {
    currentStep,
    sellerId,
    isPending,
    goBack,
    submitStoreStep,
    submitAddressStep,
    skipAddressStep,
    submitCompanyStep,
    skipCompanyStep,
    submitPaymentStep,
    skipPaymentStep
  } = useOnboarding(memberEmail);
  const handleBack = async () => {
    if (currentStep === 0) {
      if (hasStores) {
        navigate("/store-select", { replace: true });
      } else {
        await logoutMutation(void 0, {
          onSuccess: () => queryClient.clear(),
          onSettled: () => navigate("/login")
        });
      }
    } else {
      goBack();
    }
  };
  const renderStep = () => {
    switch (currentStep) {
      case 0:
        return /* @__PURE__ */ jsx8(WizardStep, { children: /* @__PURE__ */ jsx8(StoreStep, { onSubmit: submitStoreStep, isPending }) }, "store");
      case 1:
        return /* @__PURE__ */ jsx8(WizardStep, { children: /* @__PURE__ */ jsx8(
          AddressStep,
          {
            onSubmit: submitAddressStep,
            onSkip: skipAddressStep,
            isPending
          }
        ) }, "address");
      case 2:
        return /* @__PURE__ */ jsx8(WizardStep, { children: /* @__PURE__ */ jsx8(
          CompanyStep,
          {
            onSubmit: submitCompanyStep,
            onSkip: skipCompanyStep,
            isPending
          }
        ) }, "company");
      case 3:
        return /* @__PURE__ */ jsx8(WizardStep, { children: /* @__PURE__ */ jsx8(
          PaymentStep,
          {
            sellerId,
            onSubmit: submitPaymentStep,
            onSkip: skipPaymentStep,
            isPending
          }
        ) }, "payment");
      default:
        return null;
    }
  };
  return /* @__PURE__ */ jsxs6("div", { className: "flex h-dvh w-dvw overflow-hidden", children: [
    /* @__PURE__ */ jsx8(
      WizardSidebar,
      {
        currentStep,
        onBack: handleBack,
        showBack: true,
        children: /* @__PURE__ */ jsx8(AnimatePresence, { mode: "wait", children: renderStep() })
      }
    ),
    /* @__PURE__ */ jsx8(WizardPreview, {})
  ] });
};

// src/pages/onboarding/onboarding.tsx
import { jsx as jsx9 } from "react/jsx-runtime";
var ONBOARDING_EMAIL_KEY = "mercur_onboarding_email";
var Onboarding = () => {
  const location = useLocation();
  const stateEmail = location.state?.email;
  useEffect(() => {
    if (stateEmail) {
      sessionStorage.setItem(ONBOARDING_EMAIL_KEY, stateEmail);
    }
  }, [stateEmail]);
  const email = stateEmail || sessionStorage.getItem(ONBOARDING_EMAIL_KEY) || "";
  if (!email) {
    return /* @__PURE__ */ jsx9(Navigate, { to: "/login", replace: true });
  }
  return /* @__PURE__ */ jsx9(OnboardingWizard, { memberEmail: email });
};
export {
  Onboarding as Component,
  onboardingLoader as loader
};
