@mercurjs/vendor 2.3.7 → 2.3.8-canary.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/dist/{[id]-ETBVSKK3.js → [id]-A7X2XZ2K.js} +3 -3
  2. package/dist/{[id]-666YLRJF.js → [id]-BMHZLJCH.js} +3 -2
  3. package/dist/{[id]-MDSZJASE.js → [id]-FFJKPSR6.js} +6 -5
  4. package/dist/{[id]-4FS7TSTE.js → [id]-JTZEHZSR.js} +4 -3
  5. package/dist/{[id]-MJGZQFKV.js → [id]-M46TPJE5.js} +7 -6
  6. package/dist/{[id]-ZHOKCJ4T.js → [id]-NG32RHXO.js} +7 -6
  7. package/dist/{[id]-GQQXDJGU.js → [id]-P226VJ63.js} +2 -2
  8. package/dist/{[id]-D224RIUO.js → [id]-PZB5XXVO.js} +3 -2
  9. package/dist/{[id]-KYC52AAR.js → [id]-UIXWQETQ.js} +8 -7
  10. package/dist/{[id]-DJ6I7ZWW.js → [id]-UXUKBJV7.js} +2 -2
  11. package/dist/{[id]-ASQEGEPZ.js → [id]-VVGOMTEU.js} +3 -2
  12. package/dist/{[id]-XQWHZ4UU.js → [id]-ZSJXD3P3.js} +3 -2
  13. package/dist/{add-VMWDXYOJ.js → add-7LOGKVAM.js} +9 -8
  14. package/dist/{add-QJVY7JHR.js → add-INWI3TYC.js} +5 -4
  15. package/dist/{add-customer-groups-JMKG22IT.js → add-customer-groups-GM7OGAAX.js} +3 -2
  16. package/dist/{add-products-OELSCMHI.js → add-products-UWIFYV5Y.js} +7 -6
  17. package/dist/{add-promotions-453ZFOHU.js → add-promotions-QP5MHMZ3.js} +3 -3
  18. package/dist/{add-to-campaign-NOTFKGZY.js → add-to-campaign-VRF4TYPG.js} +3 -3
  19. package/dist/{address-JYUFTBRK.js → address-PAV5NXDR.js} +3 -2
  20. package/dist/{breadcrumb-G6PJ7I6I.js → breadcrumb-5CRSOET4.js} +3 -2
  21. package/dist/{breadcrumb-LCLZRWFG.js → breadcrumb-CJCOBDES.js} +3 -2
  22. package/dist/{breadcrumb-FNE5V4QU.js → breadcrumb-HWQCVD4O.js} +4 -3
  23. package/dist/{breadcrumb-55K5ZUXM.js → breadcrumb-N5DYMI7C.js} +1 -1
  24. package/dist/{breadcrumb-L5D2RZ67.js → breadcrumb-ON6CLH2A.js} +1 -1
  25. package/dist/{chunk-EXNGI5EU.js → chunk-2WB7YUWZ.js} +1 -1
  26. package/dist/{chunk-EMD7D7E6.js → chunk-4HAMH7VM.js} +2 -2
  27. package/dist/{chunk-PYLKKTXF.js → chunk-5KJZCQF5.js} +1 -1
  28. package/dist/{chunk-XAASERO6.js → chunk-5W77GKZP.js} +1 -1
  29. package/dist/{chunk-AQI5E3SK.js → chunk-6UCUPNTP.js} +1 -1
  30. package/dist/{chunk-U5U446UX.js → chunk-7MFXEOB7.js} +38 -31
  31. package/dist/{chunk-HNLII2AN.js → chunk-7TUOQ4EJ.js} +1 -1
  32. package/dist/{chunk-YMUXQFOC.js → chunk-AE3XRG4P.js} +2 -2
  33. package/dist/{chunk-LSOVGW4R.js → chunk-AFL2QWVT.js} +3 -2
  34. package/dist/{chunk-4GWGFBV5.js → chunk-AKYXDJWB.js} +1 -1
  35. package/dist/{chunk-XFR5AOON.js → chunk-BJ5NEVN4.js} +1 -1
  36. package/dist/{chunk-IDQIECSP.js → chunk-HQYV2PDP.js} +1 -1
  37. package/dist/{chunk-XLGMSDJO.js → chunk-HWEMQW76.js} +3 -3
  38. package/dist/{chunk-GT2DDPIB.js → chunk-KYZ32CY4.js} +1 -1
  39. package/dist/{chunk-Y3KLCTG3.js → chunk-LKQQJWYX.js} +10 -0
  40. package/dist/{chunk-SWZYH77J.js → chunk-MKKE5DJT.js} +1 -1
  41. package/dist/{chunk-TEGB74UF.js → chunk-MW2TTR75.js} +1 -1
  42. package/dist/{chunk-CDJVJZGQ.js → chunk-MXPO73MQ.js} +1 -1
  43. package/dist/{chunk-5ZHZVKNQ.js → chunk-PEBSUNXQ.js} +4 -0
  44. package/dist/{chunk-2ERDNBOU.js → chunk-PKFBOMPL.js} +1 -1
  45. package/dist/{chunk-BIIYZTKH.js → chunk-S3ZSIXJC.js} +2 -2
  46. package/dist/{chunk-RDN6US4B.js → chunk-SQMXR7QG.js} +2 -2
  47. package/dist/{chunk-JAOJFGII.js → chunk-VN2ZQTUW.js} +1 -1
  48. package/dist/{chunk-S6IGY77X.js → chunk-WFABIIXN.js} +1 -1
  49. package/dist/{chunk-RLPH22S3.js → chunk-WNTMS4KZ.js} +4 -4
  50. package/dist/{chunk-KKTTDJMT.js → chunk-Y2MESGBX.js} +1 -1
  51. package/dist/{chunk-ESRIX7ZH.js → chunk-YJI74L4M.js} +18 -0
  52. package/dist/{chunk-CERNIJIO.js → chunk-YNQUVE2G.js} +1 -1
  53. package/dist/chunk-ZDMCE62O.js +25 -0
  54. package/dist/{chunk-N3OUMXNV.js → chunk-ZQUYRDTM.js} +1 -1
  55. package/dist/{collections-YI345PXH.js → collections-IYJS2DHY.js} +5 -4
  56. package/dist/{create-MQFDW6CK.js → create-635IISRG.js} +3 -2
  57. package/dist/{create-MYLL6LX4.js → create-ASGFPV3G.js} +8 -7
  58. package/dist/{create-JXTADLBY.js → create-GKM3QEDM.js} +7 -6
  59. package/dist/{create-KVTRPU5I.js → create-HYB4GAWY.js} +3 -2
  60. package/dist/{create-264ONF7U.js → create-KK4UG2CK.js} +5 -4
  61. package/dist/{create-KCF62PCA.js → create-KR3HX77W.js} +3 -3
  62. package/dist/{create-FUM6N3U2.js → create-SECM5KHG.js} +4 -3
  63. package/dist/{create-5OVMJIGW.js → create-WBNN6ESF.js} +9 -8
  64. package/dist/{edit-VLKDSPFM.js → edit-7UMVMO3H.js} +6 -5
  65. package/dist/{edit-O5K6IVV2.js → edit-E2KCTXHW.js} +3 -3
  66. package/dist/{edit-NILXRC63.js → edit-JGBJGVHD.js} +3 -2
  67. package/dist/{edit-UZP7TBH2.js → edit-KO6PAAL2.js} +4 -3
  68. package/dist/{edit-VWLAKVLW.js → edit-NPHZHWTC.js} +4 -3
  69. package/dist/{edit-NVYJX3GX.js → edit-OO3U575W.js} +4 -3
  70. package/dist/{edit-SZXNN4QR.js → edit-RGJ7IID3.js} +36 -2
  71. package/dist/{edit-EKAUVJT5.js → edit-VRQLOD5E.js} +3 -3
  72. package/dist/{edit-price-DABJMEL3.js → edit-price-U4VESGJX.js} +2 -2
  73. package/dist/{edit-stock-PTXEUMBY.js → edit-stock-55GII22S.js} +1 -1
  74. package/dist/{fulfillment-EBULAIBY.js → fulfillment-CJNQSDIH.js} +3 -2
  75. package/dist/{fulfillment-providers-Q7X6EB3X.js → fulfillment-providers-ISDZHIL7.js} +5 -4
  76. package/dist/{home-G3HG42YM.js → home-IS7KHLMH.js} +4 -3
  77. package/dist/index.css +4 -0
  78. package/dist/index.js +111 -110
  79. package/dist/{inventory-WRRJWQFB.js → inventory-WPHSH2TX.js} +1 -1
  80. package/dist/{invite-IPHZFADY.js → invite-QOIJAXMP.js} +4 -3
  81. package/dist/{invite-ELEPCOPG.js → invite-VHJ4SBNB.js} +3 -2
  82. package/dist/{loader-USWXCRPF.js → loader-CDXJP5XD.js} +1 -1
  83. package/dist/{loader-KKHXERTR.js → loader-UABAR5TP.js} +1 -1
  84. package/dist/{login-W3PYWTDO.js → login-UC5HPXF5.js} +5 -4
  85. package/dist/{manage-items-VVFNTJX7.js → manage-items-63TE6TBN.js} +1 -1
  86. package/dist/{media-K6I5ZZBK.js → media-6LTNORR5.js} +7 -6
  87. package/dist/{media-5IJEFAYC.js → media-A3KYE6UF.js} +4 -3
  88. package/dist/{metadata-SIK4VNPL.js → metadata-6557WF6T.js} +3 -2
  89. package/dist/{metadata-46LW5L7T.js → metadata-73EGQ4TO.js} +3 -2
  90. package/dist/{metadata-JGLHL3FU.js → metadata-GLN7CKHN.js} +3 -2
  91. package/dist/{metadata-LEMNES27.js → metadata-ODGRHE7T.js} +3 -2
  92. package/dist/{metadata-U7K5JCLI.js → metadata-UMVNBIT7.js} +3 -2
  93. package/dist/{offer-create-page-36PYLWW4.js → offer-create-page-GXILFDX2.js} +48 -6
  94. package/dist/{offer-detail-page-KRH4TNJN.js → offer-detail-page-A5ZB76DU.js} +1 -1
  95. package/dist/{offer-variant-detail-page-SRB5J3TJ.js → offer-variant-detail-page-L3WHS5MI.js} +8 -1
  96. package/dist/{offers-OYVOW23Y.js → offers-P7NGBPPT.js} +9 -8
  97. package/dist/onboarding-GEX2RXKN.js +1085 -0
  98. package/dist/{orders-2ILL72R4.js → orders-BU5NNXMG.js} +5 -4
  99. package/dist/{organization-GKL3Z5AS.js → organization-5DJJF6ZP.js} +4 -3
  100. package/dist/pages/index.js +23 -22
  101. package/dist/{payment-details-5A7IUG5U.js → payment-details-WEYB343E.js} +3 -2
  102. package/dist/{pricing-ROKACFQV.js → pricing-C7G2MT2K.js} +2 -2
  103. package/dist/{pricing-XNTOYT2H.js → pricing-HFJ5XETU.js} +3 -2
  104. package/dist/{product-tags-G3CS5MMC.js → product-tags-R6EB7BXD.js} +8 -7
  105. package/dist/{product-variant-detail-7IMC2SAO.js → product-variant-detail-U5SIMQ23.js} +3 -2
  106. package/dist/{product-variant-edit-RWYSXW3M.js → product-variant-edit-YEJQFLO4.js} +5 -4
  107. package/dist/{products-P74QKZEO.js → products-CY7WB2JP.js} +7 -6
  108. package/dist/{products-2FUI5H5W.js → products-R3JOTGF3.js} +12 -11
  109. package/dist/{professional-details-DNDPFYGU.js → professional-details-BYOFTJOF.js} +3 -2
  110. package/dist/{profile-TFG3JE7U.js → profile-2RDAL6RW.js} +3 -2
  111. package/dist/{promotions-RXTEX2JX.js → promotions-BKO4AC7V.js} +4 -4
  112. package/dist/{register-FCTWVDWF.js → register-7EE35NGI.js} +5 -4
  113. package/dist/{reset-password-R3HXKS3J.js → reset-password-NHRLPUUH.js} +1 -1
  114. package/dist/{return-reasons-5MPNWIQK.js → return-reasons-BIMPEFVD.js} +3 -3
  115. package/dist/{settings-56LZ2QOK.js → settings-TYX5R5OR.js} +6 -5
  116. package/dist/{shipment-DNSHILRM.js → shipment-ZRFNHKPM.js} +3 -2
  117. package/dist/{shipping-FIWGNBNC.js → shipping-64I6RABH.js} +1 -1
  118. package/dist/{shipping-profiles-JJ4HH5Y7.js → shipping-profiles-EYPSBIXE.js} +3 -2
  119. package/dist/{stock-LTZBLHJW.js → stock-DH34YUOP.js} +3 -2
  120. package/dist/{store-MZRR67LA.js → store-G3S3C55J.js} +4 -3
  121. package/dist/{store-closure-TYZV2MRG.js → store-closure-X3IFCHGR.js} +3 -2
  122. package/dist/{store-select-QASXNKMO.js → store-select-CVGMGXN7.js} +9 -5
  123. package/dist/{team-CF4F6KTM.js → team-6XRNWO4M.js} +4 -3
  124. package/package.json +6 -6
  125. package/dist/onboarding-4RRUUXWQ.js +0 -957
  126. /package/dist/{chunk-PC4EJU3M.js → chunk-ZAB27HSU.js} +0 -0
@@ -0,0 +1,1085 @@
1
+ import {
2
+ CountrySelect
3
+ } from "./chunk-7CAFYKKA.js";
4
+ import "./chunk-JRTZWK77.js";
5
+ import {
6
+ HandleInput
7
+ } from "./chunk-HJ56YXBU.js";
8
+ import {
9
+ Form
10
+ } from "./chunk-3QSRE5LS.js";
11
+ import {
12
+ retrieveActiveStore,
13
+ storeQueryKeys,
14
+ useStore
15
+ } from "./chunk-ZAB27HSU.js";
16
+ import {
17
+ useLogout
18
+ } from "./chunk-3JFOBIRE.js";
19
+ import "./chunk-P6UW4MKP.js";
20
+ import "./chunk-37GBG5JR.js";
21
+ import "./chunk-TIZRIQFH.js";
22
+ import "./chunk-TBKX7EQP.js";
23
+ import "./chunk-JXLOX7ZP.js";
24
+ import "./chunk-ZDMCE62O.js";
25
+ import "./chunk-ITV6SKOV.js";
26
+ import "./chunk-CFUFUOLL.js";
27
+ import {
28
+ useCreateSellerAccount,
29
+ useSellerHandleAvailability,
30
+ useSellers
31
+ } from "./chunk-LKQQJWYX.js";
32
+ import "./chunk-6NPALPJ6.js";
33
+ import "./chunk-BDMA67RG.js";
34
+ import "./chunk-DHC22IMF.js";
35
+ import "./chunk-2VXV42WD.js";
36
+ import "./chunk-JVQQKRAB.js";
37
+ import "./chunk-ARB246D5.js";
38
+ import "./chunk-CL47ZKQ3.js";
39
+ import "./chunk-V7ZAQBSV.js";
40
+ import "./chunk-XVVNJBC5.js";
41
+ import "./chunk-WJR7CLUN.js";
42
+ import "./chunk-RFOLOEUY.js";
43
+ import "./chunk-SKYXU4GP.js";
44
+ import "./chunk-A5DJIOHN.js";
45
+ import {
46
+ queryClient
47
+ } from "./chunk-RHKRREUU.js";
48
+ import "./chunk-ZA2KFUFR.js";
49
+ import {
50
+ assetUrl,
51
+ sdk
52
+ } from "./chunk-UKLW4VDE.js";
53
+ import "./chunk-NBMM2TZK.js";
54
+
55
+ // src/pages/onboarding/loader.ts
56
+ var storeDetailQuery = () => ({
57
+ queryKey: storeQueryKeys.details(),
58
+ queryFn: async () => retrieveActiveStore()
59
+ });
60
+ var onboardingLoader = async () => {
61
+ const query = storeDetailQuery();
62
+ return queryClient.ensureQueryData(query);
63
+ };
64
+
65
+ // src/pages/onboarding/onboarding.tsx
66
+ import { useEffect as useEffect2 } from "react";
67
+ import { Navigate, useLocation } from "react-router-dom";
68
+
69
+ // src/components/onboarding-wizard/onboarding-wizard.tsx
70
+ import { useMemo } from "react";
71
+ import { useNavigate as useNavigate2 } from "react-router-dom";
72
+ import { useExtension, useLinkQuery } from "@mercurjs/dashboard-shared";
73
+
74
+ // src/components/onboarding-wizard/constants.ts
75
+ var WIZARD_STEPS = [
76
+ { id: "store", rank: 10, optional: false, required: true },
77
+ { id: "address", rank: 20, optional: true },
78
+ { id: "company", rank: 30, optional: true },
79
+ { id: "payment", rank: 40, optional: true }
80
+ ];
81
+
82
+ // src/components/onboarding-wizard/wizard-sidebar.tsx
83
+ import { ChevronLeft } from "@medusajs/icons";
84
+ import { Text } from "@medusajs/ui";
85
+ import { useTranslation } from "react-i18next";
86
+ import { jsx, jsxs } from "react/jsx-runtime";
87
+ var WizardSidebar = ({
88
+ currentStep,
89
+ totalSteps,
90
+ onBack,
91
+ showBack,
92
+ children
93
+ }) => {
94
+ const { t } = useTranslation();
95
+ 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: [
96
+ showBack && onBack && /* @__PURE__ */ jsxs(
97
+ "button",
98
+ {
99
+ type: "button",
100
+ onClick: onBack,
101
+ 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",
102
+ children: [
103
+ /* @__PURE__ */ jsx(ChevronLeft, { className: "size-4" }),
104
+ /* @__PURE__ */ jsx("span", { children: t("actions.back") })
105
+ ]
106
+ }
107
+ ),
108
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle mb-1", children: t("onboarding.wizard.stepOf", {
109
+ current: currentStep + 1,
110
+ total: totalSteps
111
+ }) }),
112
+ children
113
+ ] }) });
114
+ };
115
+
116
+ // src/components/onboarding-wizard/wizard-preview.tsx
117
+ import { jsx as jsx2 } from "react/jsx-runtime";
118
+ var WizardPreview = () => {
119
+ return /* @__PURE__ */ jsx2("div", { className: "hidden lg:flex flex-1 relative overflow-hidden", children: /* @__PURE__ */ jsx2(
120
+ "img",
121
+ {
122
+ src: assetUrl("/onboarding/illustration.svg"),
123
+ alt: "",
124
+ className: "h-full w-full object-cover"
125
+ }
126
+ ) });
127
+ };
128
+
129
+ // src/components/onboarding-wizard/wizard-step.tsx
130
+ import { clx } from "@medusajs/ui";
131
+ import { motion } from "motion/react";
132
+ import { jsx as jsx3 } from "react/jsx-runtime";
133
+ var stepVariants = {
134
+ initial: { opacity: 0, y: 12, filter: "blur(4px)" },
135
+ animate: { opacity: 1, y: 0, filter: "blur(0px)" }
136
+ };
137
+ var WizardStep = ({ active, children }) => {
138
+ return /* @__PURE__ */ jsx3(
139
+ motion.div,
140
+ {
141
+ variants: stepVariants,
142
+ initial: "initial",
143
+ animate: active ? "animate" : "initial",
144
+ transition: { duration: 0.35, ease: [0.23, 1, 0.32, 1] },
145
+ className: clx("flex-col", active ? "flex" : "hidden"),
146
+ children
147
+ }
148
+ );
149
+ };
150
+
151
+ // src/components/onboarding-wizard/hooks/use-onboarding.ts
152
+ import { useCallback, useRef, useState } from "react";
153
+ import { useNavigate } from "react-router-dom";
154
+ import { toast } from "@medusajs/ui";
155
+ var readRegisterDraft = () => {
156
+ try {
157
+ const raw = sessionStorage.getItem("mercur_register_draft");
158
+ if (!raw) return {};
159
+ const parsed = JSON.parse(raw);
160
+ return {
161
+ first_name: parsed.first_name || void 0,
162
+ last_name: parsed.last_name || void 0,
163
+ additional_data: parsed.additional_data || void 0
164
+ };
165
+ } catch {
166
+ return {};
167
+ }
168
+ };
169
+ var useOnboarding = (memberEmail, steps) => {
170
+ const navigate = useNavigate();
171
+ const [currentStep, setCurrentStep] = useState(0);
172
+ const [furthestStep, setFurthestStep] = useState(0);
173
+ const [isSubmitting, setIsSubmitting] = useState(false);
174
+ const sellerIdRef = useRef(null);
175
+ const stepDataRef = useRef({});
176
+ const { mutateAsync: createSeller, isPending: isCreating } = useCreateSellerAccount();
177
+ const { mutateAsync: logout } = useLogout();
178
+ const isPending = isCreating || isSubmitting;
179
+ const createSellerWithAllData = useCallback(async () => {
180
+ if (sellerIdRef.current) {
181
+ navigate("/store-select", { replace: true });
182
+ return;
183
+ }
184
+ const stepData = stepDataRef.current;
185
+ const valuesOf = (id) => {
186
+ const entry = stepData[id];
187
+ if (!entry) return void 0;
188
+ const { additional_data: _additionalData, ...values } = entry;
189
+ return values;
190
+ };
191
+ const storeData = valuesOf("store");
192
+ if (!storeData) return;
193
+ const addressData = valuesOf("address");
194
+ const companyData = valuesOf("company");
195
+ const paymentData = valuesOf("payment");
196
+ const hasCompanyData = companyData?.corporate_name || companyData?.registration_number || companyData?.tax_id;
197
+ const isUS = paymentData?.country_code === "us";
198
+ const registerDraft = readRegisterDraft();
199
+ const additionalData = steps.reduce(
200
+ (acc, step) => ({ ...acc, ...stepData[step.id]?.additional_data }),
201
+ { ...registerDraft.additional_data }
202
+ );
203
+ try {
204
+ setIsSubmitting(true);
205
+ const result = await createSeller({
206
+ name: storeData.name,
207
+ handle: storeData.handle,
208
+ email: storeData.email,
209
+ phone: storeData.phone || void 0,
210
+ member_email: memberEmail,
211
+ first_name: registerDraft.first_name,
212
+ last_name: registerDraft.last_name,
213
+ currency_code: storeData.currency_code.toLowerCase(),
214
+ description: storeData.description || void 0,
215
+ ...Object.keys(additionalData).length ? { additional_data: additionalData } : {},
216
+ address: addressData ? {
217
+ name: addressData.name || void 0,
218
+ address_1: addressData.address_1 || void 0,
219
+ address_2: addressData.address_2 || void 0,
220
+ postal_code: addressData.postal_code || void 0,
221
+ city: addressData.city || void 0,
222
+ country_code: addressData.country_code,
223
+ province: addressData.province || void 0
224
+ } : void 0,
225
+ professional_details: companyData && hasCompanyData ? {
226
+ corporate_name: companyData.corporate_name || void 0,
227
+ registration_number: companyData.registration_number || void 0,
228
+ tax_id: companyData.tax_id || void 0
229
+ } : void 0,
230
+ payment_details: paymentData ? {
231
+ country_code: paymentData.country_code,
232
+ holder_name: paymentData.holder_name,
233
+ iban: isUS ? null : paymentData.iban || null,
234
+ bic: isUS ? null : paymentData.bic || null,
235
+ routing_number: isUS ? paymentData.routing_number || null : null,
236
+ account_number: paymentData.account_number || null
237
+ } : void 0
238
+ });
239
+ sellerIdRef.current = result.seller.id;
240
+ try {
241
+ await logout();
242
+ } catch {
243
+ }
244
+ queryClient.clear();
245
+ sessionStorage.removeItem("mercur_onboarding_email");
246
+ sessionStorage.removeItem("mercur_register_draft");
247
+ navigate("/login", { replace: true });
248
+ } catch (error) {
249
+ toast.error(error instanceof Error ? error.message : String(error));
250
+ } finally {
251
+ setIsSubmitting(false);
252
+ }
253
+ }, [createSeller, logout, memberEmail, navigate, steps]);
254
+ const advance = useCallback(
255
+ async (index) => {
256
+ if (index >= steps.length - 1) {
257
+ await createSellerWithAllData();
258
+ return;
259
+ }
260
+ setCurrentStep(index + 1);
261
+ setFurthestStep((prev) => Math.max(prev, index + 1));
262
+ },
263
+ [steps.length, createSellerWithAllData]
264
+ );
265
+ const submitStep = useCallback(
266
+ async (index, data) => {
267
+ stepDataRef.current[steps[index].id] = data;
268
+ await advance(index);
269
+ },
270
+ [steps, advance]
271
+ );
272
+ const skipStep = useCallback(
273
+ async (index) => {
274
+ stepDataRef.current[steps[index].id] = null;
275
+ await advance(index);
276
+ },
277
+ [steps, advance]
278
+ );
279
+ const goBack = useCallback(() => {
280
+ setCurrentStep((prev) => Math.max(0, prev - 1));
281
+ }, []);
282
+ return {
283
+ currentStep,
284
+ furthestStep,
285
+ totalSteps: steps.length,
286
+ isPending,
287
+ goBack,
288
+ submitStep,
289
+ skipStep
290
+ };
291
+ };
292
+
293
+ // src/components/onboarding-wizard/steps/store-step.tsx
294
+ import { CheckCircleSolid, Spinner } from "@medusajs/icons";
295
+ import { Heading, Input, Select, Text as Text2, Textarea } from "@medusajs/ui";
296
+ import i18n from "i18next";
297
+ import { useEffect, useState as useState2 } from "react";
298
+ import { useTranslation as useTranslation3 } from "react-i18next";
299
+ import { useLoaderData } from "react-router-dom";
300
+ import * as z from "zod";
301
+ import {
302
+ FormExtensionZone,
303
+ useExtendableForm
304
+ } from "@mercurjs/dashboard-shared";
305
+
306
+ // src/components/onboarding-wizard/steps/step-actions.tsx
307
+ import { Button } from "@medusajs/ui";
308
+ import { useTranslation as useTranslation2 } from "react-i18next";
309
+ import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
310
+ var StepActions = ({ onSkip, isLast, isPending }) => {
311
+ const { t } = useTranslation2();
312
+ return /* @__PURE__ */ jsxs2("div", { className: "flex flex-col gap-y-2", children: [
313
+ /* @__PURE__ */ jsx4(
314
+ Button,
315
+ {
316
+ type: "submit",
317
+ className: "w-full",
318
+ isLoading: isPending,
319
+ "data-testid": "onboarding-continue-button",
320
+ children: isLast ? t("onboarding.wizard.finish") : t("actions.continue")
321
+ }
322
+ ),
323
+ onSkip && /* @__PURE__ */ jsx4(
324
+ Button,
325
+ {
326
+ type: "button",
327
+ variant: "transparent",
328
+ className: "w-full",
329
+ onClick: onSkip,
330
+ disabled: isPending,
331
+ "data-testid": "onboarding-skip-button",
332
+ children: t("onboarding.wizard.skip")
333
+ }
334
+ )
335
+ ] });
336
+ };
337
+
338
+ // src/components/onboarding-wizard/steps/store-step.tsx
339
+ import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
340
+ var HANDLE_REGEX = /^[\p{Ll}\p{Lo}\p{Lm}\p{N}]+(?:-[\p{Ll}\p{Lo}\p{Lm}\p{N}]+)*$/u;
341
+ var HANDLE_CHECK_DEBOUNCE_MS = 400;
342
+ var StoreStepSchema = z.object({
343
+ name: z.string().min(1, i18n.t("onboarding.wizard.validation.nameRequired")),
344
+ email: z.string().email(i18n.t("onboarding.wizard.validation.emailInvalid")),
345
+ phone: z.string().optional(),
346
+ currency_code: z.string().min(1, i18n.t("onboarding.wizard.validation.currencyRequired")),
347
+ description: z.string().optional(),
348
+ handle: z.string().min(1, i18n.t("onboarding.wizard.store.handleRequired")).regex(HANDLE_REGEX, i18n.t("onboarding.wizard.store.handleInvalid"))
349
+ });
350
+ var useDebouncedValue = (value, delay) => {
351
+ const [debounced, setDebounced] = useState2(value);
352
+ useEffect(() => {
353
+ const timeout = setTimeout(() => setDebounced(value), delay);
354
+ return () => clearTimeout(timeout);
355
+ }, [value, delay]);
356
+ return debounced;
357
+ };
358
+ var StoreStep = ({
359
+ onSubmit,
360
+ onSkip,
361
+ isLast,
362
+ isPending
363
+ }) => {
364
+ const { t } = useTranslation3();
365
+ const initialData = useLoaderData();
366
+ const { store } = useStore(void 0, { initialData });
367
+ const form = useExtendableForm({
368
+ schema: StoreStepSchema,
369
+ model: "seller",
370
+ zone: "onboarding",
371
+ tab: "store",
372
+ data: store,
373
+ defaultValues: {
374
+ name: "",
375
+ email: "",
376
+ phone: "",
377
+ currency_code: "",
378
+ description: "",
379
+ handle: ""
380
+ }
381
+ });
382
+ const handle = form.watch("handle");
383
+ const debouncedHandle = useDebouncedValue(handle, HANDLE_CHECK_DEBOUNCE_MS);
384
+ const canCheckHandle = HANDLE_REGEX.test(debouncedHandle);
385
+ const { available, reason, isFetching } = useSellerHandleAvailability(
386
+ debouncedHandle,
387
+ { enabled: canCheckHandle }
388
+ );
389
+ const isCheckingHandle = HANDLE_REGEX.test(handle) && (handle !== debouncedHandle || isFetching);
390
+ const isHandleAvailable = !isCheckingHandle && canCheckHandle && handle === debouncedHandle && available;
391
+ useEffect(() => {
392
+ if (isCheckingHandle || !canCheckHandle || available !== false) {
393
+ if (form.getFieldState("handle").error?.type === "manual") {
394
+ form.clearErrors("handle");
395
+ }
396
+ return;
397
+ }
398
+ form.setError("handle", {
399
+ type: "manual",
400
+ message: reason === "invalid" ? t("onboarding.wizard.store.handleInvalid") : t("onboarding.wizard.store.handleTaken")
401
+ });
402
+ }, [available, reason, isCheckingHandle, canCheckHandle, form, t]);
403
+ const handleSubmit = form.handleSubmit(async (data) => {
404
+ const result = await sdk.vendor.sellers.handleAvailability.query({
405
+ handle: data.handle
406
+ });
407
+ if (!result.available) {
408
+ form.setError("handle", {
409
+ type: "manual",
410
+ message: result.reason === "invalid" ? t("onboarding.wizard.store.handleInvalid") : t("onboarding.wizard.store.handleTaken")
411
+ });
412
+ return;
413
+ }
414
+ await onSubmit(data);
415
+ });
416
+ return /* @__PURE__ */ jsxs3("div", { className: "flex flex-col gap-y-8", children: [
417
+ /* @__PURE__ */ jsx5(Heading, { level: "h2", className: "text-ui-fg-base text-lg", children: t("onboarding.wizard.store.title") }),
418
+ /* @__PURE__ */ jsx5(Form, { ...form, children: /* @__PURE__ */ jsxs3("form", { onSubmit: handleSubmit, className: "flex flex-col gap-y-6", children: [
419
+ /* @__PURE__ */ jsxs3("div", { className: "flex flex-col gap-y-4", children: [
420
+ /* @__PURE__ */ jsx5(
421
+ Form.Field,
422
+ {
423
+ control: form.control,
424
+ name: "name",
425
+ render: ({ field }) => /* @__PURE__ */ jsxs3(Form.Item, { children: [
426
+ /* @__PURE__ */ jsx5(Form.Label, { children: t("onboarding.wizard.store.name") }),
427
+ /* @__PURE__ */ jsx5(Form.Control, { children: /* @__PURE__ */ jsx5(Input, { autoComplete: "organization", ...field }) }),
428
+ /* @__PURE__ */ jsx5(Form.ErrorMessage, {})
429
+ ] })
430
+ }
431
+ ),
432
+ /* @__PURE__ */ jsx5(
433
+ Form.Field,
434
+ {
435
+ control: form.control,
436
+ name: "email",
437
+ render: ({ field }) => /* @__PURE__ */ jsxs3(Form.Item, { children: [
438
+ /* @__PURE__ */ jsx5(Form.Label, { children: t("onboarding.wizard.store.email") }),
439
+ /* @__PURE__ */ jsx5(Form.Control, { children: /* @__PURE__ */ jsx5(Input, { type: "email", autoComplete: "email", ...field }) }),
440
+ /* @__PURE__ */ jsx5(Form.ErrorMessage, {})
441
+ ] })
442
+ }
443
+ ),
444
+ /* @__PURE__ */ jsx5(
445
+ Form.Field,
446
+ {
447
+ control: form.control,
448
+ name: "phone",
449
+ render: ({ field }) => /* @__PURE__ */ jsxs3(Form.Item, { children: [
450
+ /* @__PURE__ */ jsx5(Form.Label, { optional: true, children: t("fields.phone") }),
451
+ /* @__PURE__ */ jsx5(Form.Control, { children: /* @__PURE__ */ jsx5(Input, { type: "tel", autoComplete: "tel", ...field }) }),
452
+ /* @__PURE__ */ jsx5(Form.ErrorMessage, {})
453
+ ] })
454
+ }
455
+ ),
456
+ /* @__PURE__ */ jsx5(
457
+ Form.Field,
458
+ {
459
+ control: form.control,
460
+ name: "description",
461
+ render: ({ field }) => /* @__PURE__ */ jsxs3(Form.Item, { children: [
462
+ /* @__PURE__ */ jsx5(Form.Label, { optional: true, children: t("fields.description") }),
463
+ /* @__PURE__ */ jsx5(Form.Control, { children: /* @__PURE__ */ jsx5(Textarea, { ...field }) }),
464
+ /* @__PURE__ */ jsx5(Form.ErrorMessage, {})
465
+ ] })
466
+ }
467
+ ),
468
+ /* @__PURE__ */ jsx5(
469
+ Form.Field,
470
+ {
471
+ control: form.control,
472
+ name: "handle",
473
+ render: ({ field }) => /* @__PURE__ */ jsxs3(Form.Item, { children: [
474
+ /* @__PURE__ */ jsx5(
475
+ Form.Label,
476
+ {
477
+ tooltip: t("onboarding.wizard.store.handleTooltip"),
478
+ children: t("onboarding.wizard.store.handle")
479
+ }
480
+ ),
481
+ /* @__PURE__ */ jsx5(Form.Control, { children: /* @__PURE__ */ jsx5(
482
+ HandleInput,
483
+ {
484
+ placeholder: t("onboarding.wizard.store.handlePlaceholder"),
485
+ "data-testid": "onboarding-handle-input",
486
+ ...field
487
+ }
488
+ ) }),
489
+ isCheckingHandle && /* @__PURE__ */ jsxs3(
490
+ "div",
491
+ {
492
+ className: "text-ui-fg-muted flex items-center gap-x-1.5",
493
+ "data-testid": "onboarding-handle-checking",
494
+ children: [
495
+ /* @__PURE__ */ jsx5(Spinner, { className: "size-3.5 animate-spin" }),
496
+ /* @__PURE__ */ jsx5(Text2, { size: "small", leading: "compact", children: t("onboarding.wizard.store.handleChecking") })
497
+ ]
498
+ }
499
+ ),
500
+ isHandleAvailable && /* @__PURE__ */ jsxs3(
501
+ "div",
502
+ {
503
+ className: "flex items-center gap-x-1.5",
504
+ "data-testid": "onboarding-handle-available",
505
+ children: [
506
+ /* @__PURE__ */ jsx5(CheckCircleSolid, { className: "text-ui-tag-green-icon" }),
507
+ /* @__PURE__ */ jsx5(
508
+ Text2,
509
+ {
510
+ size: "small",
511
+ leading: "compact",
512
+ className: "text-ui-tag-green-text",
513
+ children: t("onboarding.wizard.store.handleAvailable")
514
+ }
515
+ )
516
+ ]
517
+ }
518
+ ),
519
+ /* @__PURE__ */ jsx5(Form.ErrorMessage, {})
520
+ ] })
521
+ }
522
+ ),
523
+ /* @__PURE__ */ jsx5(
524
+ Form.Field,
525
+ {
526
+ control: form.control,
527
+ name: "currency_code",
528
+ render: ({ field: { onChange, ref, ...field } }) => /* @__PURE__ */ jsxs3(Form.Item, { children: [
529
+ /* @__PURE__ */ jsx5(Form.Label, { children: t("onboarding.wizard.store.currency") }),
530
+ /* @__PURE__ */ jsx5(Form.Control, { children: /* @__PURE__ */ jsxs3(Select, { ...field, onValueChange: onChange, children: [
531
+ /* @__PURE__ */ jsx5(Select.Trigger, { ref, children: /* @__PURE__ */ jsx5(
532
+ Select.Value,
533
+ {
534
+ placeholder: t("onboarding.wizard.store.selectCurrency")
535
+ }
536
+ ) }),
537
+ /* @__PURE__ */ jsx5(Select.Content, { children: store?.supported_currencies?.map((sc) => /* @__PURE__ */ jsx5(
538
+ Select.Item,
539
+ {
540
+ value: sc.currency_code,
541
+ children: sc.currency_code.toUpperCase()
542
+ },
543
+ sc.currency_code
544
+ )) })
545
+ ] }) }),
546
+ /* @__PURE__ */ jsx5(Form.ErrorMessage, {})
547
+ ] })
548
+ }
549
+ ),
550
+ /* @__PURE__ */ jsx5(
551
+ FormExtensionZone,
552
+ {
553
+ model: "seller",
554
+ zone: "onboarding",
555
+ tab: "store",
556
+ control: form.control,
557
+ data: store
558
+ }
559
+ )
560
+ ] }),
561
+ /* @__PURE__ */ jsx5(
562
+ StepActions,
563
+ {
564
+ onSkip,
565
+ isLast,
566
+ isPending: isPending || form.formState.isSubmitting
567
+ }
568
+ )
569
+ ] }) })
570
+ ] });
571
+ };
572
+
573
+ // src/components/onboarding-wizard/steps/address-step.tsx
574
+ import { Heading as Heading2, Input as Input2 } from "@medusajs/ui";
575
+ import i18n2 from "i18next";
576
+ import { useTranslation as useTranslation4 } from "react-i18next";
577
+ import * as z2 from "zod";
578
+ import {
579
+ FormExtensionZone as FormExtensionZone2,
580
+ useExtendableForm as useExtendableForm2
581
+ } from "@mercurjs/dashboard-shared";
582
+ import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
583
+ var AddressStepSchema = z2.object({
584
+ name: z2.string().min(1, i18n2.t("onboarding.wizard.validation.nameRequired")),
585
+ address_1: z2.string().optional(),
586
+ address_2: z2.string().optional(),
587
+ postal_code: z2.string().optional(),
588
+ city: z2.string().optional(),
589
+ country_code: z2.string().min(1, i18n2.t("onboarding.wizard.validation.countryRequired")),
590
+ province: z2.string().optional()
591
+ });
592
+ var AddressStep = ({
593
+ onSubmit,
594
+ onSkip,
595
+ isLast,
596
+ isPending
597
+ }) => {
598
+ const { t } = useTranslation4();
599
+ const form = useExtendableForm2({
600
+ schema: AddressStepSchema,
601
+ model: "seller",
602
+ zone: "onboarding",
603
+ tab: "address",
604
+ defaultValues: {
605
+ name: "",
606
+ address_1: "",
607
+ address_2: "",
608
+ postal_code: "",
609
+ city: "",
610
+ country_code: "",
611
+ province: ""
612
+ }
613
+ });
614
+ const handleSubmit = form.handleSubmit(async (data) => {
615
+ await onSubmit(data);
616
+ });
617
+ return /* @__PURE__ */ jsxs4("div", { className: "flex flex-col gap-y-8", children: [
618
+ /* @__PURE__ */ jsx6(Heading2, { level: "h2", className: "text-ui-fg-base text-lg", children: t("onboarding.wizard.address.title") }),
619
+ /* @__PURE__ */ jsx6(Form, { ...form, children: /* @__PURE__ */ jsxs4("form", { onSubmit: handleSubmit, className: "flex flex-col gap-y-6", children: [
620
+ /* @__PURE__ */ jsxs4("div", { className: "flex flex-col gap-y-4", children: [
621
+ /* @__PURE__ */ jsx6(
622
+ Form.Field,
623
+ {
624
+ control: form.control,
625
+ name: "name",
626
+ render: ({ field }) => /* @__PURE__ */ jsxs4(Form.Item, { children: [
627
+ /* @__PURE__ */ jsx6(Form.Label, { children: t("onboarding.wizard.address.name") }),
628
+ /* @__PURE__ */ jsx6(Form.Control, { children: /* @__PURE__ */ jsx6(Input2, { ...field }) }),
629
+ /* @__PURE__ */ jsx6(Form.ErrorMessage, {})
630
+ ] })
631
+ }
632
+ ),
633
+ /* @__PURE__ */ jsx6(
634
+ Form.Field,
635
+ {
636
+ control: form.control,
637
+ name: "address_1",
638
+ render: ({ field }) => /* @__PURE__ */ jsxs4(Form.Item, { children: [
639
+ /* @__PURE__ */ jsx6(Form.Label, { optional: true, children: t("onboarding.wizard.address.address") }),
640
+ /* @__PURE__ */ jsx6(Form.Control, { children: /* @__PURE__ */ jsx6(Input2, { autoComplete: "address-line1", ...field }) }),
641
+ /* @__PURE__ */ jsx6(Form.ErrorMessage, {})
642
+ ] })
643
+ }
644
+ ),
645
+ /* @__PURE__ */ jsx6(
646
+ Form.Field,
647
+ {
648
+ control: form.control,
649
+ name: "address_2",
650
+ render: ({ field }) => /* @__PURE__ */ jsxs4(Form.Item, { children: [
651
+ /* @__PURE__ */ jsx6(Form.Label, { optional: true, children: t("onboarding.wizard.address.address2") }),
652
+ /* @__PURE__ */ jsx6(Form.Control, { children: /* @__PURE__ */ jsx6(Input2, { autoComplete: "address-line2", ...field }) }),
653
+ /* @__PURE__ */ jsx6(Form.ErrorMessage, {})
654
+ ] })
655
+ }
656
+ ),
657
+ /* @__PURE__ */ jsx6(
658
+ Form.Field,
659
+ {
660
+ control: form.control,
661
+ name: "postal_code",
662
+ render: ({ field }) => /* @__PURE__ */ jsxs4(Form.Item, { children: [
663
+ /* @__PURE__ */ jsx6(Form.Label, { optional: true, children: t("onboarding.wizard.address.postalCode") }),
664
+ /* @__PURE__ */ jsx6(Form.Control, { children: /* @__PURE__ */ jsx6(Input2, { autoComplete: "postal-code", ...field }) }),
665
+ /* @__PURE__ */ jsx6(Form.ErrorMessage, {})
666
+ ] })
667
+ }
668
+ ),
669
+ /* @__PURE__ */ jsx6(
670
+ Form.Field,
671
+ {
672
+ control: form.control,
673
+ name: "city",
674
+ render: ({ field }) => /* @__PURE__ */ jsxs4(Form.Item, { children: [
675
+ /* @__PURE__ */ jsx6(Form.Label, { optional: true, children: t("onboarding.wizard.address.city") }),
676
+ /* @__PURE__ */ jsx6(Form.Control, { children: /* @__PURE__ */ jsx6(Input2, { autoComplete: "address-level2", ...field }) }),
677
+ /* @__PURE__ */ jsx6(Form.ErrorMessage, {})
678
+ ] })
679
+ }
680
+ ),
681
+ /* @__PURE__ */ jsx6(
682
+ Form.Field,
683
+ {
684
+ control: form.control,
685
+ name: "country_code",
686
+ render: ({ field: { onChange, ref: _ref, ...field } }) => /* @__PURE__ */ jsxs4(Form.Item, { children: [
687
+ /* @__PURE__ */ jsx6(Form.Label, { children: t("onboarding.wizard.address.country") }),
688
+ /* @__PURE__ */ jsx6(Form.Control, { children: /* @__PURE__ */ jsx6(CountrySelect, { ...field, onChange }) }),
689
+ /* @__PURE__ */ jsx6(Form.ErrorMessage, {})
690
+ ] })
691
+ }
692
+ ),
693
+ /* @__PURE__ */ jsx6(
694
+ Form.Field,
695
+ {
696
+ control: form.control,
697
+ name: "province",
698
+ render: ({ field }) => /* @__PURE__ */ jsxs4(Form.Item, { children: [
699
+ /* @__PURE__ */ jsx6(Form.Label, { optional: true, children: t("onboarding.wizard.address.state") }),
700
+ /* @__PURE__ */ jsx6(Form.Control, { children: /* @__PURE__ */ jsx6(Input2, { autoComplete: "address-level1", ...field }) }),
701
+ /* @__PURE__ */ jsx6(Form.ErrorMessage, {})
702
+ ] })
703
+ }
704
+ ),
705
+ /* @__PURE__ */ jsx6(
706
+ FormExtensionZone2,
707
+ {
708
+ model: "seller",
709
+ zone: "onboarding",
710
+ tab: "address",
711
+ control: form.control
712
+ }
713
+ )
714
+ ] }),
715
+ /* @__PURE__ */ jsx6(StepActions, { onSkip, isLast, isPending })
716
+ ] }) })
717
+ ] });
718
+ };
719
+
720
+ // src/components/onboarding-wizard/steps/company-step.tsx
721
+ import { Heading as Heading3, Input as Input3 } from "@medusajs/ui";
722
+ import { useTranslation as useTranslation5 } from "react-i18next";
723
+ import * as z3 from "zod";
724
+ import {
725
+ FormExtensionZone as FormExtensionZone3,
726
+ useExtendableForm as useExtendableForm3
727
+ } from "@mercurjs/dashboard-shared";
728
+ import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
729
+ var CompanyStepSchema = z3.object({
730
+ corporate_name: z3.string().optional(),
731
+ registration_number: z3.string().optional(),
732
+ tax_id: z3.string().optional()
733
+ });
734
+ var CompanyStep = ({
735
+ onSubmit,
736
+ onSkip,
737
+ isLast,
738
+ isPending
739
+ }) => {
740
+ const { t } = useTranslation5();
741
+ const form = useExtendableForm3({
742
+ schema: CompanyStepSchema,
743
+ model: "seller",
744
+ zone: "onboarding",
745
+ tab: "company",
746
+ defaultValues: {
747
+ corporate_name: "",
748
+ registration_number: "",
749
+ tax_id: ""
750
+ }
751
+ });
752
+ const handleSubmit = form.handleSubmit(async (data) => {
753
+ await onSubmit(data);
754
+ });
755
+ return /* @__PURE__ */ jsxs5("div", { className: "flex flex-col gap-y-8", children: [
756
+ /* @__PURE__ */ jsx7(Heading3, { level: "h2", className: "text-ui-fg-base text-lg", children: t("onboarding.wizard.company.title") }),
757
+ /* @__PURE__ */ jsx7(Form, { ...form, children: /* @__PURE__ */ jsxs5("form", { onSubmit: handleSubmit, className: "flex flex-col gap-y-6", children: [
758
+ /* @__PURE__ */ jsxs5("div", { className: "flex flex-col gap-y-4", children: [
759
+ /* @__PURE__ */ jsx7(
760
+ Form.Field,
761
+ {
762
+ control: form.control,
763
+ name: "corporate_name",
764
+ render: ({ field }) => /* @__PURE__ */ jsxs5(Form.Item, { children: [
765
+ /* @__PURE__ */ jsx7(Form.Label, { optional: true, children: t("onboarding.wizard.company.corporateName") }),
766
+ /* @__PURE__ */ jsx7(Form.Control, { children: /* @__PURE__ */ jsx7(Input3, { ...field }) }),
767
+ /* @__PURE__ */ jsx7(Form.ErrorMessage, {})
768
+ ] })
769
+ }
770
+ ),
771
+ /* @__PURE__ */ jsx7(
772
+ Form.Field,
773
+ {
774
+ control: form.control,
775
+ name: "registration_number",
776
+ render: ({ field }) => /* @__PURE__ */ jsxs5(Form.Item, { children: [
777
+ /* @__PURE__ */ jsx7(Form.Label, { optional: true, children: t("onboarding.wizard.company.registrationNumber") }),
778
+ /* @__PURE__ */ jsx7(Form.Control, { children: /* @__PURE__ */ jsx7(Input3, { ...field }) }),
779
+ /* @__PURE__ */ jsx7(Form.ErrorMessage, {})
780
+ ] })
781
+ }
782
+ ),
783
+ /* @__PURE__ */ jsx7(
784
+ Form.Field,
785
+ {
786
+ control: form.control,
787
+ name: "tax_id",
788
+ render: ({ field }) => /* @__PURE__ */ jsxs5(Form.Item, { children: [
789
+ /* @__PURE__ */ jsx7(Form.Label, { optional: true, children: t("onboarding.wizard.company.taxId") }),
790
+ /* @__PURE__ */ jsx7(Form.Control, { children: /* @__PURE__ */ jsx7(Input3, { ...field }) }),
791
+ /* @__PURE__ */ jsx7(Form.ErrorMessage, {})
792
+ ] })
793
+ }
794
+ ),
795
+ /* @__PURE__ */ jsx7(
796
+ FormExtensionZone3,
797
+ {
798
+ model: "seller",
799
+ zone: "onboarding",
800
+ tab: "company",
801
+ control: form.control
802
+ }
803
+ )
804
+ ] }),
805
+ /* @__PURE__ */ jsx7(StepActions, { onSkip, isLast, isPending })
806
+ ] }) })
807
+ ] });
808
+ };
809
+
810
+ // src/components/onboarding-wizard/steps/payment-step.tsx
811
+ import { Heading as Heading4, Input as Input4 } from "@medusajs/ui";
812
+ import i18n3 from "i18next";
813
+ import { useTranslation as useTranslation6 } from "react-i18next";
814
+ import * as z4 from "zod";
815
+ import {
816
+ FormExtensionZone as FormExtensionZone4,
817
+ useExtendableForm as useExtendableForm4
818
+ } from "@mercurjs/dashboard-shared";
819
+ import { Fragment, jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
820
+ var PaymentStepSchema = z4.object({
821
+ country_code: z4.string().min(1, i18n3.t("onboarding.wizard.validation.countryRequired")),
822
+ holder_name: z4.string().min(1, i18n3.t("onboarding.wizard.validation.accountNameRequired")),
823
+ iban: z4.string().optional(),
824
+ bic: z4.string().optional(),
825
+ routing_number: z4.string().optional(),
826
+ account_number: z4.string().optional()
827
+ });
828
+ var PaymentStep = ({
829
+ onSubmit,
830
+ onSkip,
831
+ isLast,
832
+ isPending
833
+ }) => {
834
+ const { t } = useTranslation6();
835
+ const form = useExtendableForm4({
836
+ schema: PaymentStepSchema,
837
+ model: "seller",
838
+ zone: "onboarding",
839
+ tab: "payment",
840
+ defaultValues: {
841
+ country_code: "",
842
+ holder_name: "",
843
+ iban: "",
844
+ bic: "",
845
+ routing_number: "",
846
+ account_number: ""
847
+ }
848
+ });
849
+ const selectedCountry = form.watch("country_code");
850
+ const isUS = selectedCountry === "us";
851
+ const handleSubmit = form.handleSubmit(async (data) => {
852
+ await onSubmit(data);
853
+ });
854
+ return /* @__PURE__ */ jsxs6("div", { className: "flex flex-col gap-y-8", children: [
855
+ /* @__PURE__ */ jsx8(Heading4, { level: "h2", className: "text-ui-fg-base text-lg", children: t("onboarding.wizard.payment.title") }),
856
+ /* @__PURE__ */ jsx8(Form, { ...form, children: /* @__PURE__ */ jsxs6("form", { onSubmit: handleSubmit, className: "flex flex-col gap-y-6", children: [
857
+ /* @__PURE__ */ jsxs6("div", { className: "flex flex-col gap-y-4", children: [
858
+ /* @__PURE__ */ jsx8(
859
+ Form.Field,
860
+ {
861
+ control: form.control,
862
+ name: "country_code",
863
+ render: ({ field: { onChange, ref: _ref, ...field } }) => /* @__PURE__ */ jsxs6(Form.Item, { children: [
864
+ /* @__PURE__ */ jsx8(Form.Label, { children: t("onboarding.wizard.address.country") }),
865
+ /* @__PURE__ */ jsx8(Form.Control, { children: /* @__PURE__ */ jsx8(CountrySelect, { ...field, onChange }) }),
866
+ /* @__PURE__ */ jsx8(Form.ErrorMessage, {})
867
+ ] })
868
+ }
869
+ ),
870
+ selectedCountry && /* @__PURE__ */ jsxs6(Fragment, { children: [
871
+ /* @__PURE__ */ jsx8(
872
+ Form.Field,
873
+ {
874
+ control: form.control,
875
+ name: "holder_name",
876
+ render: ({ field }) => /* @__PURE__ */ jsxs6(Form.Item, { children: [
877
+ /* @__PURE__ */ jsx8(Form.Label, { children: t("onboarding.wizard.payment.accountName") }),
878
+ /* @__PURE__ */ jsx8(Form.Control, { children: /* @__PURE__ */ jsx8(Input4, { ...field }) }),
879
+ /* @__PURE__ */ jsx8(Form.ErrorMessage, {})
880
+ ] })
881
+ }
882
+ ),
883
+ isUS ? /* @__PURE__ */ jsxs6(Fragment, { children: [
884
+ /* @__PURE__ */ jsx8(
885
+ Form.Field,
886
+ {
887
+ control: form.control,
888
+ name: "account_number",
889
+ render: ({ field }) => /* @__PURE__ */ jsxs6(Form.Item, { children: [
890
+ /* @__PURE__ */ jsx8(Form.Label, { optional: true, children: t("onboarding.wizard.payment.accountNumber") }),
891
+ /* @__PURE__ */ jsx8(Form.Control, { children: /* @__PURE__ */ jsx8(Input4, { ...field }) }),
892
+ /* @__PURE__ */ jsx8(Form.ErrorMessage, {})
893
+ ] })
894
+ }
895
+ ),
896
+ /* @__PURE__ */ jsx8(
897
+ Form.Field,
898
+ {
899
+ control: form.control,
900
+ name: "routing_number",
901
+ render: ({ field }) => /* @__PURE__ */ jsxs6(Form.Item, { children: [
902
+ /* @__PURE__ */ jsx8(Form.Label, { optional: true, children: t("onboarding.wizard.payment.achRoutingNumber") }),
903
+ /* @__PURE__ */ jsx8(Form.Control, { children: /* @__PURE__ */ jsx8(Input4, { ...field }) }),
904
+ /* @__PURE__ */ jsx8(Form.ErrorMessage, {})
905
+ ] })
906
+ }
907
+ )
908
+ ] }) : /* @__PURE__ */ jsxs6(Fragment, { children: [
909
+ /* @__PURE__ */ jsx8(
910
+ Form.Field,
911
+ {
912
+ control: form.control,
913
+ name: "iban",
914
+ render: ({ field }) => /* @__PURE__ */ jsxs6(Form.Item, { children: [
915
+ /* @__PURE__ */ jsx8(Form.Label, { optional: true, children: t("onboarding.wizard.payment.iban") }),
916
+ /* @__PURE__ */ jsx8(Form.Control, { children: /* @__PURE__ */ jsx8(Input4, { ...field }) }),
917
+ /* @__PURE__ */ jsx8(Form.ErrorMessage, {})
918
+ ] })
919
+ }
920
+ ),
921
+ /* @__PURE__ */ jsx8(
922
+ Form.Field,
923
+ {
924
+ control: form.control,
925
+ name: "account_number",
926
+ render: ({ field }) => /* @__PURE__ */ jsxs6(Form.Item, { children: [
927
+ /* @__PURE__ */ jsx8(Form.Label, { optional: true, children: t("onboarding.wizard.payment.accountNumber") }),
928
+ /* @__PURE__ */ jsx8(Form.Control, { children: /* @__PURE__ */ jsx8(Input4, { ...field }) }),
929
+ /* @__PURE__ */ jsx8(Form.ErrorMessage, {})
930
+ ] })
931
+ }
932
+ ),
933
+ /* @__PURE__ */ jsx8(
934
+ Form.Field,
935
+ {
936
+ control: form.control,
937
+ name: "bic",
938
+ render: ({ field }) => /* @__PURE__ */ jsxs6(Form.Item, { children: [
939
+ /* @__PURE__ */ jsx8(Form.Label, { optional: true, children: t("onboarding.wizard.payment.swiftBic") }),
940
+ /* @__PURE__ */ jsx8(Form.Control, { children: /* @__PURE__ */ jsx8(Input4, { ...field }) }),
941
+ /* @__PURE__ */ jsx8(Form.ErrorMessage, {})
942
+ ] })
943
+ }
944
+ )
945
+ ] })
946
+ ] }),
947
+ /* @__PURE__ */ jsx8(
948
+ FormExtensionZone4,
949
+ {
950
+ model: "seller",
951
+ zone: "onboarding",
952
+ tab: "payment",
953
+ control: form.control
954
+ }
955
+ )
956
+ ] }),
957
+ /* @__PURE__ */ jsx8(StepActions, { onSkip, isLast, isPending })
958
+ ] }) })
959
+ ] });
960
+ };
961
+
962
+ // src/components/onboarding-wizard/steps/custom-step.tsx
963
+ import { Heading as Heading5 } from "@medusajs/ui";
964
+ import * as z5 from "zod";
965
+ import {
966
+ FormExtensionZone as FormExtensionZone5,
967
+ useExtendableForm as useExtendableForm5
968
+ } from "@mercurjs/dashboard-shared";
969
+ import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
970
+ var CustomStepSchema = z5.object({});
971
+ var CustomStep = ({
972
+ id,
973
+ label,
974
+ onSubmit,
975
+ onSkip,
976
+ isLast,
977
+ isPending
978
+ }) => {
979
+ const form = useExtendableForm5({
980
+ schema: CustomStepSchema,
981
+ model: "seller",
982
+ zone: "onboarding",
983
+ tab: id,
984
+ defaultValues: {}
985
+ });
986
+ const handleSubmit = form.handleSubmit(async (data) => {
987
+ await onSubmit(data);
988
+ });
989
+ return /* @__PURE__ */ jsxs7("div", { className: "flex flex-col gap-y-8", children: [
990
+ label && /* @__PURE__ */ jsx9(Heading5, { level: "h2", className: "text-ui-fg-base text-lg", children: label }),
991
+ /* @__PURE__ */ jsx9(Form, { ...form, children: /* @__PURE__ */ jsxs7("form", { onSubmit: handleSubmit, className: "flex flex-col gap-y-6", children: [
992
+ /* @__PURE__ */ jsx9(
993
+ FormExtensionZone5,
994
+ {
995
+ model: "seller",
996
+ zone: "onboarding",
997
+ tab: id,
998
+ control: form.control
999
+ }
1000
+ ),
1001
+ /* @__PURE__ */ jsx9(StepActions, { onSkip, isLast, isPending })
1002
+ ] }) })
1003
+ ] });
1004
+ };
1005
+
1006
+ // src/components/onboarding-wizard/onboarding-wizard.tsx
1007
+ import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
1008
+ var BUILT_IN_STEPS = {
1009
+ store: StoreStep,
1010
+ address: AddressStep,
1011
+ company: CompanyStep,
1012
+ payment: PaymentStep
1013
+ };
1014
+ var OnboardingWizard = ({ memberEmail }) => {
1015
+ const navigate = useNavigate2();
1016
+ const extension = useExtension();
1017
+ const { mutateAsync: logoutMutation } = useLogout();
1018
+ const { seller_members } = useSellers(useLinkQuery("seller"));
1019
+ const hasStores = (seller_members?.length ?? 0) > 0;
1020
+ const steps = useMemo(
1021
+ () => extension.getOnboardingSteps("seller", [...WIZARD_STEPS]),
1022
+ [extension]
1023
+ );
1024
+ const { currentStep, furthestStep, isPending, goBack, submitStep, skipStep } = useOnboarding(memberEmail, steps);
1025
+ const handleBack = async () => {
1026
+ if (currentStep === 0) {
1027
+ if (hasStores) {
1028
+ navigate("/store-select", { replace: true });
1029
+ } else {
1030
+ await logoutMutation(void 0, {
1031
+ onSuccess: () => queryClient.clear(),
1032
+ onSettled: () => navigate("/login")
1033
+ });
1034
+ }
1035
+ } else {
1036
+ goBack();
1037
+ }
1038
+ };
1039
+ const renderStep = (index) => {
1040
+ const step = steps[index];
1041
+ const props = {
1042
+ onSubmit: (data) => submitStep(index, data),
1043
+ onSkip: step.optional ? () => skipStep(index) : void 0,
1044
+ isLast: index === steps.length - 1,
1045
+ isPending
1046
+ };
1047
+ const BuiltIn = step.custom ? void 0 : BUILT_IN_STEPS[step.id];
1048
+ return /* @__PURE__ */ jsx10(WizardStep, { active: index === currentStep, children: /* @__PURE__ */ jsx10("div", { "data-testid": `onboarding-step-${step.id}`, children: BuiltIn ? /* @__PURE__ */ jsx10(BuiltIn, { ...props }) : /* @__PURE__ */ jsx10(CustomStep, { id: step.id, label: step.label, ...props }) }) }, step.id);
1049
+ };
1050
+ return /* @__PURE__ */ jsxs8("div", { className: "flex h-dvh w-dvw overflow-hidden", children: [
1051
+ /* @__PURE__ */ jsx10(
1052
+ WizardSidebar,
1053
+ {
1054
+ currentStep,
1055
+ totalSteps: steps.length,
1056
+ onBack: handleBack,
1057
+ showBack: true,
1058
+ children: steps.slice(0, furthestStep + 1).map((_, index) => renderStep(index))
1059
+ }
1060
+ ),
1061
+ /* @__PURE__ */ jsx10(WizardPreview, {})
1062
+ ] });
1063
+ };
1064
+
1065
+ // src/pages/onboarding/onboarding.tsx
1066
+ import { jsx as jsx11 } from "react/jsx-runtime";
1067
+ var ONBOARDING_EMAIL_KEY = "mercur_onboarding_email";
1068
+ var Onboarding = () => {
1069
+ const location = useLocation();
1070
+ const stateEmail = location.state?.email;
1071
+ useEffect2(() => {
1072
+ if (stateEmail) {
1073
+ sessionStorage.setItem(ONBOARDING_EMAIL_KEY, stateEmail);
1074
+ }
1075
+ }, [stateEmail]);
1076
+ const email = stateEmail || sessionStorage.getItem(ONBOARDING_EMAIL_KEY) || "";
1077
+ if (!email) {
1078
+ return /* @__PURE__ */ jsx11(Navigate, { to: "/login", replace: true });
1079
+ }
1080
+ return /* @__PURE__ */ jsx11(OnboardingWizard, { memberEmail: email });
1081
+ };
1082
+ export {
1083
+ Onboarding as Component,
1084
+ onboardingLoader as loader
1085
+ };