@clerk/react 5.54.0

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 (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +71 -0
  3. package/dist/chunk-KLK6ZMZX.mjs +1011 -0
  4. package/dist/chunk-KLK6ZMZX.mjs.map +1 -0
  5. package/dist/chunk-MB46WFKC.mjs +28 -0
  6. package/dist/chunk-MB46WFKC.mjs.map +1 -0
  7. package/dist/chunk-OANWQR3B.mjs +16 -0
  8. package/dist/chunk-OANWQR3B.mjs.map +1 -0
  9. package/dist/chunk-PS5BRRRD.mjs +282 -0
  10. package/dist/chunk-PS5BRRRD.mjs.map +1 -0
  11. package/dist/chunk-Z2DSM5QN.mjs +171 -0
  12. package/dist/chunk-Z2DSM5QN.mjs.map +1 -0
  13. package/dist/errors.d.mts +1 -0
  14. package/dist/errors.d.ts +1 -0
  15. package/dist/errors.js +45 -0
  16. package/dist/errors.js.map +1 -0
  17. package/dist/errors.mjs +24 -0
  18. package/dist/errors.mjs.map +1 -0
  19. package/dist/experimental.d.mts +125 -0
  20. package/dist/experimental.d.ts +125 -0
  21. package/dist/experimental.js +1301 -0
  22. package/dist/experimental.js.map +1 -0
  23. package/dist/experimental.mjs +164 -0
  24. package/dist/experimental.mjs.map +1 -0
  25. package/dist/index.d.mts +217 -0
  26. package/dist/index.d.ts +217 -0
  27. package/dist/index.js +3304 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/index.mjs +1940 -0
  30. package/dist/index.mjs.map +1 -0
  31. package/dist/internal.d.mts +18 -0
  32. package/dist/internal.d.ts +18 -0
  33. package/dist/internal.js +260 -0
  34. package/dist/internal.js.map +1 -0
  35. package/dist/internal.mjs +58 -0
  36. package/dist/internal.mjs.map +1 -0
  37. package/dist/legacy.d.mts +95 -0
  38. package/dist/legacy.d.ts +95 -0
  39. package/dist/legacy.js +90 -0
  40. package/dist/legacy.js.map +1 -0
  41. package/dist/legacy.mjs +48 -0
  42. package/dist/legacy.mjs.map +1 -0
  43. package/dist/types-BS-xjOf_.d.mts +77 -0
  44. package/dist/types-BS-xjOf_.d.ts +77 -0
  45. package/dist/useAuth-CibrZ7p3.d.mts +182 -0
  46. package/dist/useAuth-yh0dHssU.d.ts +182 -0
  47. package/package.json +116 -0
package/dist/index.js ADDED
@@ -0,0 +1,3304 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __typeError = (msg) => {
9
+ throw TypeError(msg);
10
+ };
11
+ var __export = (target, all) => {
12
+ for (var name in all)
13
+ __defProp(target, name, { get: all[name], enumerable: true });
14
+ };
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from))
18
+ if (!__hasOwnProp.call(to, key) && key !== except)
19
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
+ }
21
+ return to;
22
+ };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
+ // If the importer is in node compatibility mode or this is not an ESM
25
+ // file that has been converted to a CommonJS file using a Babel-
26
+ // compatible transform (i.e. "__esModule" has not been set), then set
27
+ // "default" to the CommonJS "module.exports" for node compatibility.
28
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
+ mod
30
+ ));
31
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
33
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
34
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
35
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
36
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
37
+
38
+ // src/index.ts
39
+ var src_exports = {};
40
+ __export(src_exports, {
41
+ APIKeys: () => APIKeys,
42
+ AuthenticateWithRedirectCallback: () => AuthenticateWithRedirectCallback,
43
+ ClerkDegraded: () => ClerkDegraded,
44
+ ClerkFailed: () => ClerkFailed,
45
+ ClerkLoaded: () => ClerkLoaded,
46
+ ClerkLoading: () => ClerkLoading,
47
+ ClerkProvider: () => ClerkProvider,
48
+ CreateOrganization: () => CreateOrganization,
49
+ GoogleOneTap: () => GoogleOneTap,
50
+ OrganizationList: () => OrganizationList,
51
+ OrganizationProfile: () => OrganizationProfile,
52
+ OrganizationSwitcher: () => OrganizationSwitcher,
53
+ PricingTable: () => PricingTable,
54
+ Protect: () => Protect,
55
+ RedirectToCreateOrganization: () => RedirectToCreateOrganization,
56
+ RedirectToOrganizationProfile: () => RedirectToOrganizationProfile,
57
+ RedirectToSignIn: () => RedirectToSignIn,
58
+ RedirectToSignUp: () => RedirectToSignUp,
59
+ RedirectToTasks: () => RedirectToTasks,
60
+ RedirectToUserProfile: () => RedirectToUserProfile,
61
+ SignIn: () => SignIn,
62
+ SignInButton: () => SignInButton,
63
+ SignInWithMetamaskButton: () => SignInWithMetamaskButton,
64
+ SignOutButton: () => SignOutButton,
65
+ SignUp: () => SignUp,
66
+ SignUpButton: () => SignUpButton,
67
+ SignedIn: () => SignedIn,
68
+ SignedOut: () => SignedOut,
69
+ TaskChooseOrganization: () => TaskChooseOrganization,
70
+ UserAvatar: () => UserAvatar,
71
+ UserButton: () => UserButton,
72
+ UserProfile: () => UserProfile,
73
+ Waitlist: () => Waitlist,
74
+ __experimental_CheckoutProvider: () => import_react19.__experimental_CheckoutProvider,
75
+ __experimental_PaymentElement: () => import_react19.__experimental_PaymentElement,
76
+ __experimental_PaymentElementProvider: () => import_react19.__experimental_PaymentElementProvider,
77
+ __experimental_useCheckout: () => import_react19.__experimental_useCheckout,
78
+ __experimental_usePaymentElement: () => import_react19.__experimental_usePaymentElement,
79
+ useAuth: () => useAuth,
80
+ useClerk: () => import_react19.useClerk,
81
+ useEmailLink: () => useEmailLink,
82
+ useOrganization: () => import_react19.useOrganization,
83
+ useOrganizationList: () => import_react19.useOrganizationList,
84
+ useReverification: () => import_react19.useReverification,
85
+ useSession: () => import_react19.useSession,
86
+ useSessionList: () => import_react19.useSessionList,
87
+ useSignIn: () => useSignIn,
88
+ useSignUp: () => useSignUp,
89
+ useUser: () => import_react19.useUser
90
+ });
91
+ module.exports = __toCommonJS(src_exports);
92
+
93
+ // src/polyfills.ts
94
+ if (typeof window !== "undefined" && !window.global) {
95
+ window.global = typeof global === "undefined" ? window : global;
96
+ }
97
+
98
+ // src/index.ts
99
+ var import_loadClerkJsScript2 = require("@clerk/shared/loadClerkJsScript");
100
+
101
+ // src/errors/errorThrower.ts
102
+ var import_error = require("@clerk/shared/error");
103
+ var errorThrower = (0, import_error.buildErrorThrower)({ packageName: "@clerk/react" });
104
+ function setErrorThrowerOptions(options) {
105
+ errorThrower.setMessages(options).setPackageName(options);
106
+ }
107
+
108
+ // src/components/uiComponents.tsx
109
+ var import_utils3 = require("@clerk/shared/utils");
110
+ var import_react13 = __toESM(require("react"));
111
+
112
+ // src/errors/messages.ts
113
+ var multipleClerkProvidersError = "You've added multiple <ClerkProvider> components in your React component tree. Wrap your components in a single <ClerkProvider>.";
114
+ var multipleChildrenInButtonComponent = (name) => `You've passed multiple children components to <${name}/>. You can only pass a single child component or text.`;
115
+ var invalidStateError = "Invalid state. Feel free to submit a bug or reach out to support here: https://clerk.com/support";
116
+ var unsupportedNonBrowserDomainOrProxyUrlFunction = "Unsupported usage of isSatellite, domain or proxyUrl. The usage of isSatellite, domain or proxyUrl as function is not supported in non-browser environments.";
117
+ var userProfilePageRenderedError = "<UserProfile.Page /> component needs to be a direct child of `<UserProfile />` or `<UserButton />`.";
118
+ var userProfileLinkRenderedError = "<UserProfile.Link /> component needs to be a direct child of `<UserProfile />` or `<UserButton />`.";
119
+ var organizationProfilePageRenderedError = "<OrganizationProfile.Page /> component needs to be a direct child of `<OrganizationProfile />` or `<OrganizationSwitcher />`.";
120
+ var organizationProfileLinkRenderedError = "<OrganizationProfile.Link /> component needs to be a direct child of `<OrganizationProfile />` or `<OrganizationSwitcher />`.";
121
+ var customPagesIgnoredComponent = (componentName) => `<${componentName} /> can only accept <${componentName}.Page /> and <${componentName}.Link /> as its children. Any other provided component will be ignored. Additionally, please ensure that the component is rendered in a client component.`;
122
+ var customPageWrongProps = (componentName) => `Missing props. <${componentName}.Page /> component requires the following props: url, label, labelIcon, alongside with children to be rendered inside the page.`;
123
+ var customLinkWrongProps = (componentName) => `Missing props. <${componentName}.Link /> component requires the following props: url, label and labelIcon.`;
124
+ var userButtonIgnoredComponent = `<UserButton /> can only accept <UserButton.UserProfilePage />, <UserButton.UserProfileLink /> and <UserButton.MenuItems /> as its children. Any other provided component will be ignored. Additionally, please ensure that the component is rendered in a client component.`;
125
+ var customMenuItemsIgnoredComponent = "<UserButton.MenuItems /> component can only accept <UserButton.Action /> and <UserButton.Link /> as its children. Any other provided component will be ignored. Additionally, please ensure that the component is rendered in a client component.";
126
+ var userButtonMenuItemsRenderedError = "<UserButton.MenuItems /> component needs to be a direct child of `<UserButton />`.";
127
+ var userButtonMenuActionRenderedError = "<UserButton.Action /> component needs to be a direct child of `<UserButton.MenuItems />`.";
128
+ var userButtonMenuLinkRenderedError = "<UserButton.Link /> component needs to be a direct child of `<UserButton.MenuItems />`.";
129
+ var userButtonMenuItemLinkWrongProps = "Missing props. <UserButton.Link /> component requires the following props: href, label and labelIcon.";
130
+ var userButtonMenuItemsActionWrongsProps = "Missing props. <UserButton.Action /> component requires the following props: label.";
131
+
132
+ // src/utils/childrenUtils.tsx
133
+ var import_react = __toESM(require("react"));
134
+ var assertSingleChild = (children) => (name) => {
135
+ try {
136
+ return import_react.default.Children.only(children);
137
+ } catch {
138
+ return errorThrower.throw(multipleChildrenInButtonComponent(name));
139
+ }
140
+ };
141
+ var normalizeWithDefaultValue = (children, defaultText) => {
142
+ if (!children) {
143
+ children = defaultText;
144
+ }
145
+ if (typeof children === "string") {
146
+ children = /* @__PURE__ */ import_react.default.createElement("button", null, children);
147
+ }
148
+ return children;
149
+ };
150
+ var safeExecute = (cb) => (...args) => {
151
+ if (cb && typeof cb === "function") {
152
+ return cb(...args);
153
+ }
154
+ };
155
+
156
+ // src/utils/isConstructor.ts
157
+ function isConstructor(f) {
158
+ return typeof f === "function";
159
+ }
160
+
161
+ // src/utils/useMaxAllowedInstancesGuard.tsx
162
+ var import_react2 = __toESM(require("react"));
163
+ var counts = /* @__PURE__ */ new Map();
164
+ function useMaxAllowedInstancesGuard(name, error, maxCount = 1) {
165
+ import_react2.default.useEffect(() => {
166
+ const count = counts.get(name) || 0;
167
+ if (count == maxCount) {
168
+ return errorThrower.throw(error);
169
+ }
170
+ counts.set(name, count + 1);
171
+ return () => {
172
+ counts.set(name, (counts.get(name) || 1) - 1);
173
+ };
174
+ }, []);
175
+ }
176
+ function withMaxAllowedInstancesGuard(WrappedComponent, name, error) {
177
+ const displayName = WrappedComponent.displayName || WrappedComponent.name || name || "Component";
178
+ const Hoc = (props) => {
179
+ useMaxAllowedInstancesGuard(name, error);
180
+ return /* @__PURE__ */ import_react2.default.createElement(WrappedComponent, { ...props });
181
+ };
182
+ Hoc.displayName = `withMaxAllowedInstancesGuard(${displayName})`;
183
+ return Hoc;
184
+ }
185
+
186
+ // src/utils/useCustomElementPortal.tsx
187
+ var import_react3 = require("react");
188
+ var import_react_dom = require("react-dom");
189
+ var useCustomElementPortal = (elements) => {
190
+ const [nodeMap, setNodeMap] = (0, import_react3.useState)(/* @__PURE__ */ new Map());
191
+ return elements.map((el) => ({
192
+ id: el.id,
193
+ mount: (node) => setNodeMap((prev) => new Map(prev).set(String(el.id), node)),
194
+ unmount: () => setNodeMap((prev) => {
195
+ const newMap = new Map(prev);
196
+ newMap.set(String(el.id), null);
197
+ return newMap;
198
+ }),
199
+ portal: () => {
200
+ const node = nodeMap.get(String(el.id));
201
+ return node ? (0, import_react_dom.createPortal)(el.component, node) : null;
202
+ }
203
+ }));
204
+ };
205
+
206
+ // src/utils/useCustomPages.tsx
207
+ var import_utils = require("@clerk/shared/utils");
208
+ var import_react5 = __toESM(require("react"));
209
+
210
+ // src/utils/componentValidation.ts
211
+ var import_react4 = __toESM(require("react"));
212
+ var isThatComponent = (v, component) => {
213
+ return !!v && import_react4.default.isValidElement(v) && (v == null ? void 0 : v.type) === component;
214
+ };
215
+
216
+ // src/utils/useCustomPages.tsx
217
+ var useUserProfileCustomPages = (children, options) => {
218
+ const reorderItemsLabels = ["account", "security"];
219
+ return useCustomPages(
220
+ {
221
+ children,
222
+ reorderItemsLabels,
223
+ LinkComponent: UserProfileLink,
224
+ PageComponent: UserProfilePage,
225
+ MenuItemsComponent: MenuItems,
226
+ componentName: "UserProfile"
227
+ },
228
+ options
229
+ );
230
+ };
231
+ var useOrganizationProfileCustomPages = (children, options) => {
232
+ const reorderItemsLabels = ["general", "members"];
233
+ return useCustomPages(
234
+ {
235
+ children,
236
+ reorderItemsLabels,
237
+ LinkComponent: OrganizationProfileLink,
238
+ PageComponent: OrganizationProfilePage,
239
+ componentName: "OrganizationProfile"
240
+ },
241
+ options
242
+ );
243
+ };
244
+ var useSanitizedChildren = (children) => {
245
+ const sanitizedChildren = [];
246
+ const excludedComponents = [
247
+ OrganizationProfileLink,
248
+ OrganizationProfilePage,
249
+ MenuItems,
250
+ UserProfilePage,
251
+ UserProfileLink
252
+ ];
253
+ import_react5.default.Children.forEach(children, (child) => {
254
+ if (!excludedComponents.some((component) => isThatComponent(child, component))) {
255
+ sanitizedChildren.push(child);
256
+ }
257
+ });
258
+ return sanitizedChildren;
259
+ };
260
+ var useCustomPages = (params, options) => {
261
+ const { children, LinkComponent, PageComponent, MenuItemsComponent, reorderItemsLabels, componentName } = params;
262
+ const { allowForAnyChildren = false } = options || {};
263
+ const validChildren = [];
264
+ import_react5.default.Children.forEach(children, (child) => {
265
+ if (!isThatComponent(child, PageComponent) && !isThatComponent(child, LinkComponent) && !isThatComponent(child, MenuItemsComponent)) {
266
+ if (child && !allowForAnyChildren) {
267
+ (0, import_utils.logErrorInDevMode)(customPagesIgnoredComponent(componentName));
268
+ }
269
+ return;
270
+ }
271
+ const { props } = child;
272
+ const { children: children2, label, url, labelIcon } = props;
273
+ if (isThatComponent(child, PageComponent)) {
274
+ if (isReorderItem(props, reorderItemsLabels)) {
275
+ validChildren.push({ label });
276
+ } else if (isCustomPage(props)) {
277
+ validChildren.push({ label, labelIcon, children: children2, url });
278
+ } else {
279
+ (0, import_utils.logErrorInDevMode)(customPageWrongProps(componentName));
280
+ return;
281
+ }
282
+ }
283
+ if (isThatComponent(child, LinkComponent)) {
284
+ if (isExternalLink(props)) {
285
+ validChildren.push({ label, labelIcon, url });
286
+ } else {
287
+ (0, import_utils.logErrorInDevMode)(customLinkWrongProps(componentName));
288
+ return;
289
+ }
290
+ }
291
+ });
292
+ const customPageContents = [];
293
+ const customPageLabelIcons = [];
294
+ const customLinkLabelIcons = [];
295
+ validChildren.forEach((cp, index) => {
296
+ if (isCustomPage(cp)) {
297
+ customPageContents.push({ component: cp.children, id: index });
298
+ customPageLabelIcons.push({ component: cp.labelIcon, id: index });
299
+ return;
300
+ }
301
+ if (isExternalLink(cp)) {
302
+ customLinkLabelIcons.push({ component: cp.labelIcon, id: index });
303
+ }
304
+ });
305
+ const customPageContentsPortals = useCustomElementPortal(customPageContents);
306
+ const customPageLabelIconsPortals = useCustomElementPortal(customPageLabelIcons);
307
+ const customLinkLabelIconsPortals = useCustomElementPortal(customLinkLabelIcons);
308
+ const customPages = [];
309
+ const customPagesPortals = [];
310
+ validChildren.forEach((cp, index) => {
311
+ if (isReorderItem(cp, reorderItemsLabels)) {
312
+ customPages.push({ label: cp.label });
313
+ return;
314
+ }
315
+ if (isCustomPage(cp)) {
316
+ const {
317
+ portal: contentPortal,
318
+ mount,
319
+ unmount
320
+ } = customPageContentsPortals.find((p) => p.id === index);
321
+ const {
322
+ portal: labelPortal,
323
+ mount: mountIcon,
324
+ unmount: unmountIcon
325
+ } = customPageLabelIconsPortals.find((p) => p.id === index);
326
+ customPages.push({ label: cp.label, url: cp.url, mount, unmount, mountIcon, unmountIcon });
327
+ customPagesPortals.push(contentPortal);
328
+ customPagesPortals.push(labelPortal);
329
+ return;
330
+ }
331
+ if (isExternalLink(cp)) {
332
+ const {
333
+ portal: labelPortal,
334
+ mount: mountIcon,
335
+ unmount: unmountIcon
336
+ } = customLinkLabelIconsPortals.find((p) => p.id === index);
337
+ customPages.push({ label: cp.label, url: cp.url, mountIcon, unmountIcon });
338
+ customPagesPortals.push(labelPortal);
339
+ return;
340
+ }
341
+ });
342
+ return { customPages, customPagesPortals };
343
+ };
344
+ var isReorderItem = (childProps, validItems) => {
345
+ const { children, label, url, labelIcon } = childProps;
346
+ return !children && !url && !labelIcon && validItems.some((v) => v === label);
347
+ };
348
+ var isCustomPage = (childProps) => {
349
+ const { children, label, url, labelIcon } = childProps;
350
+ return !!children && !!url && !!labelIcon && !!label;
351
+ };
352
+ var isExternalLink = (childProps) => {
353
+ const { children, label, url, labelIcon } = childProps;
354
+ return !children && !!url && !!labelIcon && !!label;
355
+ };
356
+
357
+ // src/utils/useCustomMenuItems.tsx
358
+ var import_utils2 = require("@clerk/shared/utils");
359
+ var import_react6 = __toESM(require("react"));
360
+ var useUserButtonCustomMenuItems = (children, options) => {
361
+ var _a;
362
+ const reorderItemsLabels = ["manageAccount", "signOut"];
363
+ return useCustomMenuItems({
364
+ children,
365
+ reorderItemsLabels,
366
+ MenuItemsComponent: MenuItems,
367
+ MenuActionComponent: MenuAction,
368
+ MenuLinkComponent: MenuLink,
369
+ UserProfileLinkComponent: UserProfileLink,
370
+ UserProfilePageComponent: UserProfilePage,
371
+ allowForAnyChildren: (_a = options == null ? void 0 : options.allowForAnyChildren) != null ? _a : false
372
+ });
373
+ };
374
+ var useCustomMenuItems = ({
375
+ children,
376
+ MenuItemsComponent,
377
+ MenuActionComponent,
378
+ MenuLinkComponent,
379
+ UserProfileLinkComponent,
380
+ UserProfilePageComponent,
381
+ reorderItemsLabels,
382
+ allowForAnyChildren = false
383
+ }) => {
384
+ const validChildren = [];
385
+ const customMenuItems = [];
386
+ const customMenuItemsPortals = [];
387
+ import_react6.default.Children.forEach(children, (child) => {
388
+ if (!isThatComponent(child, MenuItemsComponent) && !isThatComponent(child, UserProfileLinkComponent) && !isThatComponent(child, UserProfilePageComponent)) {
389
+ if (child && !allowForAnyChildren) {
390
+ (0, import_utils2.logErrorInDevMode)(userButtonIgnoredComponent);
391
+ }
392
+ return;
393
+ }
394
+ if (isThatComponent(child, UserProfileLinkComponent) || isThatComponent(child, UserProfilePageComponent)) {
395
+ return;
396
+ }
397
+ const { props } = child;
398
+ import_react6.default.Children.forEach(props.children, (child2) => {
399
+ if (!isThatComponent(child2, MenuActionComponent) && !isThatComponent(child2, MenuLinkComponent)) {
400
+ if (child2) {
401
+ (0, import_utils2.logErrorInDevMode)(customMenuItemsIgnoredComponent);
402
+ }
403
+ return;
404
+ }
405
+ const { props: props2 } = child2;
406
+ const { label, labelIcon, href, onClick, open } = props2;
407
+ if (isThatComponent(child2, MenuActionComponent)) {
408
+ if (isReorderItem2(props2, reorderItemsLabels)) {
409
+ validChildren.push({ label });
410
+ } else if (isCustomMenuItem(props2)) {
411
+ const baseItem = {
412
+ label,
413
+ labelIcon
414
+ };
415
+ if (onClick !== void 0) {
416
+ validChildren.push({
417
+ ...baseItem,
418
+ onClick
419
+ });
420
+ } else if (open !== void 0) {
421
+ validChildren.push({
422
+ ...baseItem,
423
+ open: open.startsWith("/") ? open : `/${open}`
424
+ });
425
+ } else {
426
+ (0, import_utils2.logErrorInDevMode)("Custom menu item must have either onClick or open property");
427
+ return;
428
+ }
429
+ } else {
430
+ (0, import_utils2.logErrorInDevMode)(userButtonMenuItemsActionWrongsProps);
431
+ return;
432
+ }
433
+ }
434
+ if (isThatComponent(child2, MenuLinkComponent)) {
435
+ if (isExternalLink2(props2)) {
436
+ validChildren.push({ label, labelIcon, href });
437
+ } else {
438
+ (0, import_utils2.logErrorInDevMode)(userButtonMenuItemLinkWrongProps);
439
+ return;
440
+ }
441
+ }
442
+ });
443
+ });
444
+ const customMenuItemLabelIcons = [];
445
+ const customLinkLabelIcons = [];
446
+ validChildren.forEach((mi, index) => {
447
+ if (isCustomMenuItem(mi)) {
448
+ customMenuItemLabelIcons.push({ component: mi.labelIcon, id: index });
449
+ }
450
+ if (isExternalLink2(mi)) {
451
+ customLinkLabelIcons.push({ component: mi.labelIcon, id: index });
452
+ }
453
+ });
454
+ const customMenuItemLabelIconsPortals = useCustomElementPortal(customMenuItemLabelIcons);
455
+ const customLinkLabelIconsPortals = useCustomElementPortal(customLinkLabelIcons);
456
+ validChildren.forEach((mi, index) => {
457
+ if (isReorderItem2(mi, reorderItemsLabels)) {
458
+ customMenuItems.push({
459
+ label: mi.label
460
+ });
461
+ }
462
+ if (isCustomMenuItem(mi)) {
463
+ const {
464
+ portal: iconPortal,
465
+ mount: mountIcon,
466
+ unmount: unmountIcon
467
+ } = customMenuItemLabelIconsPortals.find((p) => p.id === index);
468
+ const menuItem = {
469
+ label: mi.label,
470
+ mountIcon,
471
+ unmountIcon
472
+ };
473
+ if ("onClick" in mi) {
474
+ menuItem.onClick = mi.onClick;
475
+ } else if ("open" in mi) {
476
+ menuItem.open = mi.open;
477
+ }
478
+ customMenuItems.push(menuItem);
479
+ customMenuItemsPortals.push(iconPortal);
480
+ }
481
+ if (isExternalLink2(mi)) {
482
+ const {
483
+ portal: iconPortal,
484
+ mount: mountIcon,
485
+ unmount: unmountIcon
486
+ } = customLinkLabelIconsPortals.find((p) => p.id === index);
487
+ customMenuItems.push({
488
+ label: mi.label,
489
+ href: mi.href,
490
+ mountIcon,
491
+ unmountIcon
492
+ });
493
+ customMenuItemsPortals.push(iconPortal);
494
+ }
495
+ });
496
+ return { customMenuItems, customMenuItemsPortals };
497
+ };
498
+ var isReorderItem2 = (childProps, validItems) => {
499
+ const { children, label, onClick, labelIcon } = childProps;
500
+ return !children && !onClick && !labelIcon && validItems.some((v) => v === label);
501
+ };
502
+ var isCustomMenuItem = (childProps) => {
503
+ const { label, labelIcon, onClick, open } = childProps;
504
+ return !!labelIcon && !!label && (typeof onClick === "function" || typeof open === "string");
505
+ };
506
+ var isExternalLink2 = (childProps) => {
507
+ const { label, href, labelIcon } = childProps;
508
+ return !!href && !!labelIcon && !!label;
509
+ };
510
+
511
+ // src/utils/useWaitForComponentMount.ts
512
+ var import_react7 = require("react");
513
+ var createAwaitableMutationObserver = (globalOptions) => {
514
+ const isReady = globalOptions == null ? void 0 : globalOptions.isReady;
515
+ return (options) => new Promise((resolve, reject) => {
516
+ const { root = document == null ? void 0 : document.body, selector, timeout = 0 } = options;
517
+ if (!root) {
518
+ reject(new Error("No root element provided"));
519
+ return;
520
+ }
521
+ let elementToWatch = root;
522
+ if (selector) {
523
+ elementToWatch = root == null ? void 0 : root.querySelector(selector);
524
+ }
525
+ if (isReady(elementToWatch, selector)) {
526
+ resolve();
527
+ return;
528
+ }
529
+ const observer = new MutationObserver((mutationsList) => {
530
+ for (const mutation of mutationsList) {
531
+ if (!elementToWatch && selector) {
532
+ elementToWatch = root == null ? void 0 : root.querySelector(selector);
533
+ }
534
+ if (globalOptions.childList && mutation.type === "childList" || globalOptions.attributes && mutation.type === "attributes") {
535
+ if (isReady(elementToWatch, selector)) {
536
+ observer.disconnect();
537
+ resolve();
538
+ return;
539
+ }
540
+ }
541
+ }
542
+ });
543
+ observer.observe(root, globalOptions);
544
+ if (timeout > 0) {
545
+ setTimeout(() => {
546
+ observer.disconnect();
547
+ reject(new Error(`Timeout waiting for ${selector}`));
548
+ }, timeout);
549
+ }
550
+ });
551
+ };
552
+ var waitForElementChildren = createAwaitableMutationObserver({
553
+ childList: true,
554
+ subtree: true,
555
+ isReady: (el, selector) => {
556
+ var _a;
557
+ return !!(el == null ? void 0 : el.childElementCount) && ((_a = el == null ? void 0 : el.matches) == null ? void 0 : _a.call(el, selector)) && el.childElementCount > 0;
558
+ }
559
+ });
560
+ function useWaitForComponentMount(component, options) {
561
+ const watcherRef = (0, import_react7.useRef)();
562
+ const [status, setStatus] = (0, import_react7.useState)("rendering");
563
+ (0, import_react7.useEffect)(() => {
564
+ if (!component) {
565
+ throw new Error("Clerk: no component name provided, unable to detect mount.");
566
+ }
567
+ if (typeof window !== "undefined" && !watcherRef.current) {
568
+ const defaultSelector = `[data-clerk-component="${component}"]`;
569
+ const selector = options == null ? void 0 : options.selector;
570
+ watcherRef.current = waitForElementChildren({
571
+ selector: selector ? (
572
+ // Allows for `[data-clerk-component="xxxx"][data-some-attribute="123"] .my-class`
573
+ defaultSelector + selector
574
+ ) : defaultSelector
575
+ }).then(() => {
576
+ setStatus("rendered");
577
+ }).catch(() => {
578
+ setStatus("error");
579
+ });
580
+ }
581
+ }, [component, options == null ? void 0 : options.selector]);
582
+ return status;
583
+ }
584
+
585
+ // src/components/ClerkHostRenderer.tsx
586
+ var import_object = require("@clerk/shared/object");
587
+ var import_react8 = require("@clerk/shared/react");
588
+ var import_react9 = __toESM(require("react"));
589
+ var isMountProps = (props) => {
590
+ return "mount" in props;
591
+ };
592
+ var isOpenProps = (props) => {
593
+ return "open" in props;
594
+ };
595
+ var stripMenuItemIconHandlers = (menuItems) => {
596
+ return menuItems == null ? void 0 : menuItems.map(({ mountIcon, unmountIcon, ...rest }) => rest);
597
+ };
598
+ var ClerkHostRenderer = class extends import_react9.default.PureComponent {
599
+ constructor() {
600
+ super(...arguments);
601
+ this.rootRef = import_react9.default.createRef();
602
+ }
603
+ componentDidUpdate(_prevProps) {
604
+ var _a, _b, _c, _d;
605
+ if (!isMountProps(_prevProps) || !isMountProps(this.props)) {
606
+ return;
607
+ }
608
+ const prevProps = (0, import_object.without)(_prevProps.props, "customPages", "customMenuItems", "children");
609
+ const newProps = (0, import_object.without)(this.props.props, "customPages", "customMenuItems", "children");
610
+ const customPagesChanged = ((_a = prevProps.customPages) == null ? void 0 : _a.length) !== ((_b = newProps.customPages) == null ? void 0 : _b.length);
611
+ const customMenuItemsChanged = ((_c = prevProps.customMenuItems) == null ? void 0 : _c.length) !== ((_d = newProps.customMenuItems) == null ? void 0 : _d.length);
612
+ const prevMenuItemsWithoutHandlers = stripMenuItemIconHandlers(_prevProps.props.customMenuItems);
613
+ const newMenuItemsWithoutHandlers = stripMenuItemIconHandlers(this.props.props.customMenuItems);
614
+ if (!(0, import_react8.isDeeplyEqual)(prevProps, newProps) || !(0, import_react8.isDeeplyEqual)(prevMenuItemsWithoutHandlers, newMenuItemsWithoutHandlers) || customPagesChanged || customMenuItemsChanged) {
615
+ if (this.rootRef.current) {
616
+ this.props.updateProps({ node: this.rootRef.current, props: this.props.props });
617
+ }
618
+ }
619
+ }
620
+ componentDidMount() {
621
+ if (this.rootRef.current) {
622
+ if (isMountProps(this.props)) {
623
+ this.props.mount(this.rootRef.current, this.props.props);
624
+ }
625
+ if (isOpenProps(this.props)) {
626
+ this.props.open(this.props.props);
627
+ }
628
+ }
629
+ }
630
+ componentWillUnmount() {
631
+ if (this.rootRef.current) {
632
+ if (isMountProps(this.props)) {
633
+ this.props.unmount(this.rootRef.current);
634
+ }
635
+ if (isOpenProps(this.props)) {
636
+ this.props.close();
637
+ }
638
+ }
639
+ }
640
+ render() {
641
+ const { hideRootHtmlElement = false } = this.props;
642
+ const rootAttributes = {
643
+ ref: this.rootRef,
644
+ ...this.props.rootProps,
645
+ ...this.props.component && { "data-clerk-component": this.props.component }
646
+ };
647
+ return /* @__PURE__ */ import_react9.default.createElement(import_react9.default.Fragment, null, !hideRootHtmlElement && /* @__PURE__ */ import_react9.default.createElement("div", { ...rootAttributes }), this.props.children);
648
+ }
649
+ };
650
+
651
+ // src/components/withClerk.tsx
652
+ var import_react12 = __toESM(require("react"));
653
+
654
+ // src/contexts/IsomorphicClerkContext.tsx
655
+ var import_react10 = require("@clerk/shared/react");
656
+ var IsomorphicClerkContext = import_react10.ClerkInstanceContext;
657
+ var useIsomorphicClerkContext = import_react10.useClerkInstanceContext;
658
+
659
+ // src/hooks/useAssertWrappedByClerkProvider.ts
660
+ var import_react11 = require("@clerk/shared/react");
661
+ var useAssertWrappedByClerkProvider = (source) => {
662
+ (0, import_react11.useAssertWrappedByClerkProvider)(() => {
663
+ errorThrower.throwMissingClerkProviderError({ source });
664
+ });
665
+ };
666
+
667
+ // src/components/withClerk.tsx
668
+ var withClerk = (Component, displayNameOrOptions) => {
669
+ const passedDisplayedName = typeof displayNameOrOptions === "string" ? displayNameOrOptions : displayNameOrOptions == null ? void 0 : displayNameOrOptions.component;
670
+ const displayName = passedDisplayedName || Component.displayName || Component.name || "Component";
671
+ Component.displayName = displayName;
672
+ const options = typeof displayNameOrOptions === "string" ? void 0 : displayNameOrOptions;
673
+ const HOC = (props) => {
674
+ useAssertWrappedByClerkProvider(displayName || "withClerk");
675
+ const clerk = useIsomorphicClerkContext();
676
+ if (!clerk.loaded && !(options == null ? void 0 : options.renderWhileLoading)) {
677
+ return null;
678
+ }
679
+ return /* @__PURE__ */ import_react12.default.createElement(
680
+ Component,
681
+ {
682
+ ...props,
683
+ component: displayName,
684
+ clerk
685
+ }
686
+ );
687
+ };
688
+ HOC.displayName = `withClerk(${displayName})`;
689
+ return HOC;
690
+ };
691
+
692
+ // src/components/uiComponents.tsx
693
+ var CustomPortalsRenderer = (props) => {
694
+ var _a, _b;
695
+ return /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, (_a = props == null ? void 0 : props.customPagesPortals) == null ? void 0 : _a.map((portal, index) => (0, import_react13.createElement)(portal, { key: index })), (_b = props == null ? void 0 : props.customMenuItemsPortals) == null ? void 0 : _b.map((portal, index) => (0, import_react13.createElement)(portal, { key: index })));
696
+ };
697
+ var SignIn = withClerk(
698
+ ({ clerk, component, fallback, ...props }) => {
699
+ const mountingStatus = useWaitForComponentMount(component);
700
+ const shouldShowFallback = mountingStatus === "rendering" || !clerk.loaded;
701
+ const rendererRootProps = {
702
+ ...shouldShowFallback && fallback && { style: { display: "none" } }
703
+ };
704
+ return /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, shouldShowFallback && fallback, clerk.loaded && /* @__PURE__ */ import_react13.default.createElement(
705
+ ClerkHostRenderer,
706
+ {
707
+ component,
708
+ mount: clerk.mountSignIn,
709
+ unmount: clerk.unmountSignIn,
710
+ updateProps: clerk.__unstable__updateProps,
711
+ props,
712
+ rootProps: rendererRootProps
713
+ }
714
+ ));
715
+ },
716
+ { component: "SignIn", renderWhileLoading: true }
717
+ );
718
+ var SignUp = withClerk(
719
+ ({ clerk, component, fallback, ...props }) => {
720
+ const mountingStatus = useWaitForComponentMount(component);
721
+ const shouldShowFallback = mountingStatus === "rendering" || !clerk.loaded;
722
+ const rendererRootProps = {
723
+ ...shouldShowFallback && fallback && { style: { display: "none" } }
724
+ };
725
+ return /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, shouldShowFallback && fallback, clerk.loaded && /* @__PURE__ */ import_react13.default.createElement(
726
+ ClerkHostRenderer,
727
+ {
728
+ component,
729
+ mount: clerk.mountSignUp,
730
+ unmount: clerk.unmountSignUp,
731
+ updateProps: clerk.__unstable__updateProps,
732
+ props,
733
+ rootProps: rendererRootProps
734
+ }
735
+ ));
736
+ },
737
+ { component: "SignUp", renderWhileLoading: true }
738
+ );
739
+ function UserProfilePage({ children }) {
740
+ (0, import_utils3.logErrorInDevMode)(userProfilePageRenderedError);
741
+ return /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, children);
742
+ }
743
+ function UserProfileLink({ children }) {
744
+ (0, import_utils3.logErrorInDevMode)(userProfileLinkRenderedError);
745
+ return /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, children);
746
+ }
747
+ var _UserProfile = withClerk(
748
+ ({
749
+ clerk,
750
+ component,
751
+ fallback,
752
+ ...props
753
+ }) => {
754
+ const mountingStatus = useWaitForComponentMount(component);
755
+ const shouldShowFallback = mountingStatus === "rendering" || !clerk.loaded;
756
+ const rendererRootProps = {
757
+ ...shouldShowFallback && fallback && { style: { display: "none" } }
758
+ };
759
+ const { customPages, customPagesPortals } = useUserProfileCustomPages(props.children);
760
+ return /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, shouldShowFallback && fallback, /* @__PURE__ */ import_react13.default.createElement(
761
+ ClerkHostRenderer,
762
+ {
763
+ component,
764
+ mount: clerk.mountUserProfile,
765
+ unmount: clerk.unmountUserProfile,
766
+ updateProps: clerk.__unstable__updateProps,
767
+ props: { ...props, customPages },
768
+ rootProps: rendererRootProps
769
+ },
770
+ /* @__PURE__ */ import_react13.default.createElement(CustomPortalsRenderer, { customPagesPortals })
771
+ ));
772
+ },
773
+ { component: "UserProfile", renderWhileLoading: true }
774
+ );
775
+ var UserProfile = Object.assign(_UserProfile, {
776
+ Page: UserProfilePage,
777
+ Link: UserProfileLink
778
+ });
779
+ var UserButtonContext = (0, import_react13.createContext)({
780
+ mount: () => {
781
+ },
782
+ unmount: () => {
783
+ },
784
+ updateProps: () => {
785
+ }
786
+ });
787
+ var _UserButton = withClerk(
788
+ ({
789
+ clerk,
790
+ component,
791
+ fallback,
792
+ ...props
793
+ }) => {
794
+ const mountingStatus = useWaitForComponentMount(component);
795
+ const shouldShowFallback = mountingStatus === "rendering" || !clerk.loaded;
796
+ const rendererRootProps = {
797
+ ...shouldShowFallback && fallback && { style: { display: "none" } }
798
+ };
799
+ const { customPages, customPagesPortals } = useUserProfileCustomPages(props.children, {
800
+ allowForAnyChildren: !!props.__experimental_asProvider
801
+ });
802
+ const userProfileProps = Object.assign(props.userProfileProps || {}, { customPages });
803
+ const { customMenuItems, customMenuItemsPortals } = useUserButtonCustomMenuItems(props.children, {
804
+ allowForAnyChildren: !!props.__experimental_asProvider
805
+ });
806
+ const sanitizedChildren = useSanitizedChildren(props.children);
807
+ const passableProps = {
808
+ mount: clerk.mountUserButton,
809
+ unmount: clerk.unmountUserButton,
810
+ updateProps: clerk.__unstable__updateProps,
811
+ props: { ...props, userProfileProps, customMenuItems }
812
+ };
813
+ const portalProps = {
814
+ customPagesPortals,
815
+ customMenuItemsPortals
816
+ };
817
+ return /* @__PURE__ */ import_react13.default.createElement(UserButtonContext.Provider, { value: passableProps }, shouldShowFallback && fallback, clerk.loaded && /* @__PURE__ */ import_react13.default.createElement(
818
+ ClerkHostRenderer,
819
+ {
820
+ component,
821
+ ...passableProps,
822
+ hideRootHtmlElement: !!props.__experimental_asProvider,
823
+ rootProps: rendererRootProps
824
+ },
825
+ props.__experimental_asProvider ? sanitizedChildren : null,
826
+ /* @__PURE__ */ import_react13.default.createElement(CustomPortalsRenderer, { ...portalProps })
827
+ ));
828
+ },
829
+ { component: "UserButton", renderWhileLoading: true }
830
+ );
831
+ function MenuItems({ children }) {
832
+ (0, import_utils3.logErrorInDevMode)(userButtonMenuItemsRenderedError);
833
+ return /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, children);
834
+ }
835
+ function MenuAction({ children }) {
836
+ (0, import_utils3.logErrorInDevMode)(userButtonMenuActionRenderedError);
837
+ return /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, children);
838
+ }
839
+ function MenuLink({ children }) {
840
+ (0, import_utils3.logErrorInDevMode)(userButtonMenuLinkRenderedError);
841
+ return /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, children);
842
+ }
843
+ function UserButtonOutlet(outletProps) {
844
+ const providerProps = (0, import_react13.useContext)(UserButtonContext);
845
+ const portalProps = {
846
+ ...providerProps,
847
+ props: {
848
+ ...providerProps.props,
849
+ ...outletProps
850
+ }
851
+ };
852
+ return /* @__PURE__ */ import_react13.default.createElement(ClerkHostRenderer, { ...portalProps });
853
+ }
854
+ var UserButton = Object.assign(_UserButton, {
855
+ UserProfilePage,
856
+ UserProfileLink,
857
+ MenuItems,
858
+ Action: MenuAction,
859
+ Link: MenuLink,
860
+ __experimental_Outlet: UserButtonOutlet
861
+ });
862
+ function OrganizationProfilePage({ children }) {
863
+ (0, import_utils3.logErrorInDevMode)(organizationProfilePageRenderedError);
864
+ return /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, children);
865
+ }
866
+ function OrganizationProfileLink({ children }) {
867
+ (0, import_utils3.logErrorInDevMode)(organizationProfileLinkRenderedError);
868
+ return /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, children);
869
+ }
870
+ var _OrganizationProfile = withClerk(
871
+ ({
872
+ clerk,
873
+ component,
874
+ fallback,
875
+ ...props
876
+ }) => {
877
+ const mountingStatus = useWaitForComponentMount(component);
878
+ const shouldShowFallback = mountingStatus === "rendering" || !clerk.loaded;
879
+ const rendererRootProps = {
880
+ ...shouldShowFallback && fallback && { style: { display: "none" } }
881
+ };
882
+ const { customPages, customPagesPortals } = useOrganizationProfileCustomPages(props.children);
883
+ return /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, shouldShowFallback && fallback, clerk.loaded && /* @__PURE__ */ import_react13.default.createElement(
884
+ ClerkHostRenderer,
885
+ {
886
+ component,
887
+ mount: clerk.mountOrganizationProfile,
888
+ unmount: clerk.unmountOrganizationProfile,
889
+ updateProps: clerk.__unstable__updateProps,
890
+ props: { ...props, customPages },
891
+ rootProps: rendererRootProps
892
+ },
893
+ /* @__PURE__ */ import_react13.default.createElement(CustomPortalsRenderer, { customPagesPortals })
894
+ ));
895
+ },
896
+ { component: "OrganizationProfile", renderWhileLoading: true }
897
+ );
898
+ var OrganizationProfile = Object.assign(_OrganizationProfile, {
899
+ Page: OrganizationProfilePage,
900
+ Link: OrganizationProfileLink
901
+ });
902
+ var CreateOrganization = withClerk(
903
+ ({ clerk, component, fallback, ...props }) => {
904
+ const mountingStatus = useWaitForComponentMount(component);
905
+ const shouldShowFallback = mountingStatus === "rendering" || !clerk.loaded;
906
+ const rendererRootProps = {
907
+ ...shouldShowFallback && fallback && { style: { display: "none" } }
908
+ };
909
+ return /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, shouldShowFallback && fallback, clerk.loaded && /* @__PURE__ */ import_react13.default.createElement(
910
+ ClerkHostRenderer,
911
+ {
912
+ component,
913
+ mount: clerk.mountCreateOrganization,
914
+ unmount: clerk.unmountCreateOrganization,
915
+ updateProps: clerk.__unstable__updateProps,
916
+ props,
917
+ rootProps: rendererRootProps
918
+ }
919
+ ));
920
+ },
921
+ { component: "CreateOrganization", renderWhileLoading: true }
922
+ );
923
+ var OrganizationSwitcherContext = (0, import_react13.createContext)({
924
+ mount: () => {
925
+ },
926
+ unmount: () => {
927
+ },
928
+ updateProps: () => {
929
+ }
930
+ });
931
+ var _OrganizationSwitcher = withClerk(
932
+ ({
933
+ clerk,
934
+ component,
935
+ fallback,
936
+ ...props
937
+ }) => {
938
+ const mountingStatus = useWaitForComponentMount(component);
939
+ const shouldShowFallback = mountingStatus === "rendering" || !clerk.loaded;
940
+ const rendererRootProps = {
941
+ ...shouldShowFallback && fallback && { style: { display: "none" } }
942
+ };
943
+ const { customPages, customPagesPortals } = useOrganizationProfileCustomPages(props.children, {
944
+ allowForAnyChildren: !!props.__experimental_asProvider
945
+ });
946
+ const organizationProfileProps = Object.assign(props.organizationProfileProps || {}, { customPages });
947
+ const sanitizedChildren = useSanitizedChildren(props.children);
948
+ const passableProps = {
949
+ mount: clerk.mountOrganizationSwitcher,
950
+ unmount: clerk.unmountOrganizationSwitcher,
951
+ updateProps: clerk.__unstable__updateProps,
952
+ props: { ...props, organizationProfileProps },
953
+ rootProps: rendererRootProps,
954
+ component
955
+ };
956
+ clerk.__experimental_prefetchOrganizationSwitcher();
957
+ return /* @__PURE__ */ import_react13.default.createElement(OrganizationSwitcherContext.Provider, { value: passableProps }, /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, shouldShowFallback && fallback, clerk.loaded && /* @__PURE__ */ import_react13.default.createElement(
958
+ ClerkHostRenderer,
959
+ {
960
+ ...passableProps,
961
+ hideRootHtmlElement: !!props.__experimental_asProvider
962
+ },
963
+ props.__experimental_asProvider ? sanitizedChildren : null,
964
+ /* @__PURE__ */ import_react13.default.createElement(CustomPortalsRenderer, { customPagesPortals })
965
+ )));
966
+ },
967
+ { component: "OrganizationSwitcher", renderWhileLoading: true }
968
+ );
969
+ function OrganizationSwitcherOutlet(outletProps) {
970
+ const providerProps = (0, import_react13.useContext)(OrganizationSwitcherContext);
971
+ const portalProps = {
972
+ ...providerProps,
973
+ props: {
974
+ ...providerProps.props,
975
+ ...outletProps
976
+ }
977
+ };
978
+ return /* @__PURE__ */ import_react13.default.createElement(ClerkHostRenderer, { ...portalProps });
979
+ }
980
+ var OrganizationSwitcher = Object.assign(_OrganizationSwitcher, {
981
+ OrganizationProfilePage,
982
+ OrganizationProfileLink,
983
+ __experimental_Outlet: OrganizationSwitcherOutlet
984
+ });
985
+ var OrganizationList = withClerk(
986
+ ({ clerk, component, fallback, ...props }) => {
987
+ const mountingStatus = useWaitForComponentMount(component);
988
+ const shouldShowFallback = mountingStatus === "rendering" || !clerk.loaded;
989
+ const rendererRootProps = {
990
+ ...shouldShowFallback && fallback && { style: { display: "none" } }
991
+ };
992
+ return /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, shouldShowFallback && fallback, clerk.loaded && /* @__PURE__ */ import_react13.default.createElement(
993
+ ClerkHostRenderer,
994
+ {
995
+ component,
996
+ mount: clerk.mountOrganizationList,
997
+ unmount: clerk.unmountOrganizationList,
998
+ updateProps: clerk.__unstable__updateProps,
999
+ props,
1000
+ rootProps: rendererRootProps
1001
+ }
1002
+ ));
1003
+ },
1004
+ { component: "OrganizationList", renderWhileLoading: true }
1005
+ );
1006
+ var GoogleOneTap = withClerk(
1007
+ ({ clerk, component, fallback, ...props }) => {
1008
+ const mountingStatus = useWaitForComponentMount(component);
1009
+ const shouldShowFallback = mountingStatus === "rendering" || !clerk.loaded;
1010
+ const rendererRootProps = {
1011
+ ...shouldShowFallback && fallback && { style: { display: "none" } }
1012
+ };
1013
+ return /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, shouldShowFallback && fallback, clerk.loaded && /* @__PURE__ */ import_react13.default.createElement(
1014
+ ClerkHostRenderer,
1015
+ {
1016
+ component,
1017
+ open: clerk.openGoogleOneTap,
1018
+ close: clerk.closeGoogleOneTap,
1019
+ updateProps: clerk.__unstable__updateProps,
1020
+ props,
1021
+ rootProps: rendererRootProps
1022
+ }
1023
+ ));
1024
+ },
1025
+ { component: "GoogleOneTap", renderWhileLoading: true }
1026
+ );
1027
+ var Waitlist = withClerk(
1028
+ ({ clerk, component, fallback, ...props }) => {
1029
+ const mountingStatus = useWaitForComponentMount(component);
1030
+ const shouldShowFallback = mountingStatus === "rendering" || !clerk.loaded;
1031
+ const rendererRootProps = {
1032
+ ...shouldShowFallback && fallback && { style: { display: "none" } }
1033
+ };
1034
+ return /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, shouldShowFallback && fallback, clerk.loaded && /* @__PURE__ */ import_react13.default.createElement(
1035
+ ClerkHostRenderer,
1036
+ {
1037
+ component,
1038
+ mount: clerk.mountWaitlist,
1039
+ unmount: clerk.unmountWaitlist,
1040
+ updateProps: clerk.__unstable__updateProps,
1041
+ props,
1042
+ rootProps: rendererRootProps
1043
+ }
1044
+ ));
1045
+ },
1046
+ { component: "Waitlist", renderWhileLoading: true }
1047
+ );
1048
+ var PricingTable = withClerk(
1049
+ ({ clerk, component, fallback, ...props }) => {
1050
+ const mountingStatus = useWaitForComponentMount(component, {
1051
+ // This attribute is added to the PricingTable root element after we've successfully fetched the plans asynchronously.
1052
+ selector: '[data-component-status="ready"]'
1053
+ });
1054
+ const shouldShowFallback = mountingStatus === "rendering" || !clerk.loaded;
1055
+ const rendererRootProps = {
1056
+ ...shouldShowFallback && fallback && { style: { display: "none" } }
1057
+ };
1058
+ return /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, shouldShowFallback && fallback, clerk.loaded && /* @__PURE__ */ import_react13.default.createElement(
1059
+ ClerkHostRenderer,
1060
+ {
1061
+ component,
1062
+ mount: clerk.mountPricingTable,
1063
+ unmount: clerk.unmountPricingTable,
1064
+ updateProps: clerk.__unstable__updateProps,
1065
+ props,
1066
+ rootProps: rendererRootProps
1067
+ }
1068
+ ));
1069
+ },
1070
+ { component: "PricingTable", renderWhileLoading: true }
1071
+ );
1072
+ var APIKeys = withClerk(
1073
+ ({ clerk, component, fallback, ...props }) => {
1074
+ const mountingStatus = useWaitForComponentMount(component);
1075
+ const shouldShowFallback = mountingStatus === "rendering" || !clerk.loaded;
1076
+ const rendererRootProps = {
1077
+ ...shouldShowFallback && fallback && { style: { display: "none" } }
1078
+ };
1079
+ return /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, shouldShowFallback && fallback, clerk.loaded && /* @__PURE__ */ import_react13.default.createElement(
1080
+ ClerkHostRenderer,
1081
+ {
1082
+ component,
1083
+ mount: clerk.mountApiKeys,
1084
+ unmount: clerk.unmountApiKeys,
1085
+ updateProps: clerk.__unstable__updateProps,
1086
+ props,
1087
+ rootProps: rendererRootProps
1088
+ }
1089
+ ));
1090
+ },
1091
+ { component: "ApiKeys", renderWhileLoading: true }
1092
+ );
1093
+ var UserAvatar = withClerk(
1094
+ ({ clerk, component, fallback, ...props }) => {
1095
+ const mountingStatus = useWaitForComponentMount(component);
1096
+ const shouldShowFallback = mountingStatus === "rendering" || !clerk.loaded;
1097
+ const rendererRootProps = {
1098
+ ...shouldShowFallback && fallback && { style: { display: "none" } }
1099
+ };
1100
+ return /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, shouldShowFallback && fallback, clerk.loaded && /* @__PURE__ */ import_react13.default.createElement(
1101
+ ClerkHostRenderer,
1102
+ {
1103
+ component,
1104
+ mount: clerk.mountUserAvatar,
1105
+ unmount: clerk.unmountUserAvatar,
1106
+ updateProps: clerk.__unstable__updateProps,
1107
+ props,
1108
+ rootProps: rendererRootProps
1109
+ }
1110
+ ));
1111
+ },
1112
+ { component: "UserAvatar", renderWhileLoading: true }
1113
+ );
1114
+ var TaskChooseOrganization = withClerk(
1115
+ ({ clerk, component, fallback, ...props }) => {
1116
+ const mountingStatus = useWaitForComponentMount(component);
1117
+ const shouldShowFallback = mountingStatus === "rendering" || !clerk.loaded;
1118
+ const rendererRootProps = {
1119
+ ...shouldShowFallback && fallback && { style: { display: "none" } }
1120
+ };
1121
+ return /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, shouldShowFallback && fallback, clerk.loaded && /* @__PURE__ */ import_react13.default.createElement(
1122
+ ClerkHostRenderer,
1123
+ {
1124
+ component,
1125
+ mount: clerk.mountTaskChooseOrganization,
1126
+ unmount: clerk.unmountTaskChooseOrganization,
1127
+ updateProps: clerk.__unstable__updateProps,
1128
+ props,
1129
+ rootProps: rendererRootProps
1130
+ }
1131
+ ));
1132
+ },
1133
+ { component: "TaskChooseOrganization", renderWhileLoading: true }
1134
+ );
1135
+
1136
+ // src/components/controlComponents.tsx
1137
+ var import_deprecated = require("@clerk/shared/deprecated");
1138
+ var import_react20 = __toESM(require("react"));
1139
+
1140
+ // src/contexts/SessionContext.tsx
1141
+ var import_react14 = require("@clerk/shared/react");
1142
+
1143
+ // src/hooks/useAuth.ts
1144
+ var import_authorization = require("@clerk/shared/authorization");
1145
+ var import_telemetry = require("@clerk/shared/telemetry");
1146
+ var import_react16 = require("react");
1147
+
1148
+ // src/contexts/AuthContext.ts
1149
+ var import_react15 = require("@clerk/shared/react");
1150
+ var [AuthContext, useAuthContext] = (0, import_react15.createContextAndHook)("AuthContext");
1151
+
1152
+ // src/hooks/utils.ts
1153
+ var clerkLoaded = (isomorphicClerk) => {
1154
+ return new Promise((resolve) => {
1155
+ const handler = (status) => {
1156
+ if (["ready", "degraded"].includes(status)) {
1157
+ resolve();
1158
+ isomorphicClerk.off("status", handler);
1159
+ }
1160
+ };
1161
+ isomorphicClerk.on("status", handler, { notify: true });
1162
+ });
1163
+ };
1164
+ var createGetToken = (isomorphicClerk) => {
1165
+ return async (options) => {
1166
+ await clerkLoaded(isomorphicClerk);
1167
+ if (!isomorphicClerk.session) {
1168
+ return null;
1169
+ }
1170
+ return isomorphicClerk.session.getToken(options);
1171
+ };
1172
+ };
1173
+ var createSignOut = (isomorphicClerk) => {
1174
+ return async (...args) => {
1175
+ await clerkLoaded(isomorphicClerk);
1176
+ return isomorphicClerk.signOut(...args);
1177
+ };
1178
+ };
1179
+
1180
+ // src/hooks/useAuth.ts
1181
+ var useAuth = (initialAuthStateOrOptions = {}) => {
1182
+ var _a;
1183
+ useAssertWrappedByClerkProvider("useAuth");
1184
+ const { treatPendingAsSignedOut, ...rest } = initialAuthStateOrOptions != null ? initialAuthStateOrOptions : {};
1185
+ const initialAuthState = rest;
1186
+ const authContextFromHook = useAuthContext();
1187
+ let authContext = authContextFromHook;
1188
+ if (authContext.sessionId === void 0 && authContext.userId === void 0) {
1189
+ authContext = initialAuthState != null ? initialAuthState : {};
1190
+ }
1191
+ const isomorphicClerk = useIsomorphicClerkContext();
1192
+ const getToken = (0, import_react16.useCallback)(createGetToken(isomorphicClerk), [isomorphicClerk]);
1193
+ const signOut = (0, import_react16.useCallback)(createSignOut(isomorphicClerk), [isomorphicClerk]);
1194
+ (_a = isomorphicClerk.telemetry) == null ? void 0 : _a.record((0, import_telemetry.eventMethodCalled)("useAuth", { treatPendingAsSignedOut }));
1195
+ return useDerivedAuth(
1196
+ {
1197
+ ...authContext,
1198
+ getToken,
1199
+ signOut
1200
+ },
1201
+ {
1202
+ treatPendingAsSignedOut
1203
+ }
1204
+ );
1205
+ };
1206
+ function useDerivedAuth(authObject, { treatPendingAsSignedOut = true } = {}) {
1207
+ const { userId, orgId, orgRole, has, signOut, getToken, orgPermissions, factorVerificationAge, sessionClaims } = authObject != null ? authObject : {};
1208
+ const derivedHas = (0, import_react16.useCallback)(
1209
+ (params) => {
1210
+ if (has) {
1211
+ return has(params);
1212
+ }
1213
+ return (0, import_authorization.createCheckAuthorization)({
1214
+ userId,
1215
+ orgId,
1216
+ orgRole,
1217
+ orgPermissions,
1218
+ factorVerificationAge,
1219
+ features: (sessionClaims == null ? void 0 : sessionClaims.fea) || "",
1220
+ plans: (sessionClaims == null ? void 0 : sessionClaims.pla) || ""
1221
+ })(params);
1222
+ },
1223
+ [has, userId, orgId, orgRole, orgPermissions, factorVerificationAge, sessionClaims]
1224
+ );
1225
+ const payload = (0, import_authorization.resolveAuthState)({
1226
+ authObject: {
1227
+ ...authObject,
1228
+ getToken,
1229
+ signOut,
1230
+ has: derivedHas
1231
+ },
1232
+ options: {
1233
+ treatPendingAsSignedOut
1234
+ }
1235
+ });
1236
+ if (!payload) {
1237
+ return errorThrower.throw(invalidStateError);
1238
+ }
1239
+ return payload;
1240
+ }
1241
+
1242
+ // src/hooks/useEmailLink.ts
1243
+ var import_react17 = __toESM(require("react"));
1244
+ function useEmailLink(resource) {
1245
+ const { startEmailLinkFlow, cancelEmailLinkFlow } = import_react17.default.useMemo(() => resource.createEmailLinkFlow(), [resource]);
1246
+ import_react17.default.useEffect(() => {
1247
+ return cancelEmailLinkFlow;
1248
+ }, []);
1249
+ return {
1250
+ startEmailLinkFlow,
1251
+ cancelEmailLinkFlow
1252
+ };
1253
+ }
1254
+
1255
+ // src/hooks/useClerkSignal.ts
1256
+ var import_telemetry2 = require("@clerk/shared/telemetry");
1257
+ var import_react18 = require("react");
1258
+ function useClerkSignal(signal) {
1259
+ var _a, _b;
1260
+ useAssertWrappedByClerkProvider("useClerkSignal");
1261
+ const clerk = useIsomorphicClerkContext();
1262
+ switch (signal) {
1263
+ case "signIn":
1264
+ (_a = clerk.telemetry) == null ? void 0 : _a.record((0, import_telemetry2.eventMethodCalled)("useSignIn", { apiVersion: "2025-11" }));
1265
+ break;
1266
+ case "signUp":
1267
+ (_b = clerk.telemetry) == null ? void 0 : _b.record((0, import_telemetry2.eventMethodCalled)("useSignUp", { apiVersion: "2025-11" }));
1268
+ break;
1269
+ default:
1270
+ break;
1271
+ }
1272
+ const subscribe = (0, import_react18.useCallback)(
1273
+ (callback) => {
1274
+ if (!clerk.loaded) {
1275
+ return () => {
1276
+ };
1277
+ }
1278
+ return clerk.__internal_state.__internal_effect(() => {
1279
+ switch (signal) {
1280
+ case "signIn":
1281
+ clerk.__internal_state.signInSignal();
1282
+ break;
1283
+ case "signUp":
1284
+ clerk.__internal_state.signUpSignal();
1285
+ break;
1286
+ default:
1287
+ throw new Error(`Unknown signal: ${signal}`);
1288
+ }
1289
+ callback();
1290
+ });
1291
+ },
1292
+ [clerk, clerk.loaded, clerk.__internal_state]
1293
+ );
1294
+ const getSnapshot = (0, import_react18.useCallback)(() => {
1295
+ switch (signal) {
1296
+ case "signIn":
1297
+ return clerk.__internal_state.signInSignal();
1298
+ case "signUp":
1299
+ return clerk.__internal_state.signUpSignal();
1300
+ default:
1301
+ throw new Error(`Unknown signal: ${signal}`);
1302
+ }
1303
+ }, [clerk.__internal_state]);
1304
+ const value = (0, import_react18.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
1305
+ return value;
1306
+ }
1307
+ function useSignIn() {
1308
+ return useClerkSignal("signIn");
1309
+ }
1310
+ function useSignUp() {
1311
+ return useClerkSignal("signUp");
1312
+ }
1313
+
1314
+ // src/hooks/index.ts
1315
+ var import_react19 = require("@clerk/shared/react");
1316
+
1317
+ // src/components/controlComponents.tsx
1318
+ var SignedIn = ({ children, treatPendingAsSignedOut }) => {
1319
+ useAssertWrappedByClerkProvider("SignedIn");
1320
+ const { userId } = useAuth({ treatPendingAsSignedOut });
1321
+ if (userId) {
1322
+ return children;
1323
+ }
1324
+ return null;
1325
+ };
1326
+ var SignedOut = ({ children, treatPendingAsSignedOut }) => {
1327
+ useAssertWrappedByClerkProvider("SignedOut");
1328
+ const { userId } = useAuth({ treatPendingAsSignedOut });
1329
+ if (userId === null) {
1330
+ return children;
1331
+ }
1332
+ return null;
1333
+ };
1334
+ var ClerkLoaded = ({ children }) => {
1335
+ useAssertWrappedByClerkProvider("ClerkLoaded");
1336
+ const isomorphicClerk = useIsomorphicClerkContext();
1337
+ if (!isomorphicClerk.loaded) {
1338
+ return null;
1339
+ }
1340
+ return children;
1341
+ };
1342
+ var ClerkLoading = ({ children }) => {
1343
+ useAssertWrappedByClerkProvider("ClerkLoading");
1344
+ const isomorphicClerk = useIsomorphicClerkContext();
1345
+ if (isomorphicClerk.status !== "loading") {
1346
+ return null;
1347
+ }
1348
+ return children;
1349
+ };
1350
+ var ClerkFailed = ({ children }) => {
1351
+ useAssertWrappedByClerkProvider("ClerkFailed");
1352
+ const isomorphicClerk = useIsomorphicClerkContext();
1353
+ if (isomorphicClerk.status !== "error") {
1354
+ return null;
1355
+ }
1356
+ return children;
1357
+ };
1358
+ var ClerkDegraded = ({ children }) => {
1359
+ useAssertWrappedByClerkProvider("ClerkDegraded");
1360
+ const isomorphicClerk = useIsomorphicClerkContext();
1361
+ if (isomorphicClerk.status !== "degraded") {
1362
+ return null;
1363
+ }
1364
+ return children;
1365
+ };
1366
+ var Protect = ({ children, fallback, treatPendingAsSignedOut, ...restAuthorizedParams }) => {
1367
+ useAssertWrappedByClerkProvider("Protect");
1368
+ const { isLoaded, has, userId } = useAuth({ treatPendingAsSignedOut });
1369
+ if (!isLoaded) {
1370
+ return null;
1371
+ }
1372
+ const unauthorized = fallback != null ? fallback : null;
1373
+ const authorized = children;
1374
+ if (!userId) {
1375
+ return unauthorized;
1376
+ }
1377
+ if (typeof restAuthorizedParams.condition === "function") {
1378
+ if (restAuthorizedParams.condition(has)) {
1379
+ return authorized;
1380
+ }
1381
+ return unauthorized;
1382
+ }
1383
+ if (restAuthorizedParams.role || restAuthorizedParams.permission || restAuthorizedParams.feature || restAuthorizedParams.plan) {
1384
+ if (has(restAuthorizedParams)) {
1385
+ return authorized;
1386
+ }
1387
+ return unauthorized;
1388
+ }
1389
+ return authorized;
1390
+ };
1391
+ var RedirectToSignIn = withClerk(({ clerk, ...props }) => {
1392
+ const { client, session } = clerk;
1393
+ const hasSignedInSessions = client.signedInSessions ? client.signedInSessions.length > 0 : (
1394
+ // Compat for clerk-js<5.54.0 (which was released with the `signedInSessions` property)
1395
+ client.activeSessions && client.activeSessions.length > 0
1396
+ );
1397
+ import_react20.default.useEffect(() => {
1398
+ if (session === null && hasSignedInSessions) {
1399
+ void clerk.redirectToAfterSignOut();
1400
+ } else {
1401
+ void clerk.redirectToSignIn(props);
1402
+ }
1403
+ }, []);
1404
+ return null;
1405
+ }, "RedirectToSignIn");
1406
+ var RedirectToSignUp = withClerk(({ clerk, ...props }) => {
1407
+ import_react20.default.useEffect(() => {
1408
+ void clerk.redirectToSignUp(props);
1409
+ }, []);
1410
+ return null;
1411
+ }, "RedirectToSignUp");
1412
+ var RedirectToTasks = withClerk(({ clerk, ...props }) => {
1413
+ import_react20.default.useEffect(() => {
1414
+ void clerk.redirectToTasks(props);
1415
+ }, []);
1416
+ return null;
1417
+ }, "RedirectToTasks");
1418
+ var RedirectToUserProfile = withClerk(({ clerk }) => {
1419
+ import_react20.default.useEffect(() => {
1420
+ (0, import_deprecated.deprecated)("RedirectToUserProfile", "Use the `redirectToUserProfile()` method instead.");
1421
+ void clerk.redirectToUserProfile();
1422
+ }, []);
1423
+ return null;
1424
+ }, "RedirectToUserProfile");
1425
+ var RedirectToOrganizationProfile = withClerk(({ clerk }) => {
1426
+ import_react20.default.useEffect(() => {
1427
+ (0, import_deprecated.deprecated)("RedirectToOrganizationProfile", "Use the `redirectToOrganizationProfile()` method instead.");
1428
+ void clerk.redirectToOrganizationProfile();
1429
+ }, []);
1430
+ return null;
1431
+ }, "RedirectToOrganizationProfile");
1432
+ var RedirectToCreateOrganization = withClerk(({ clerk }) => {
1433
+ import_react20.default.useEffect(() => {
1434
+ (0, import_deprecated.deprecated)("RedirectToCreateOrganization", "Use the `redirectToCreateOrganization()` method instead.");
1435
+ void clerk.redirectToCreateOrganization();
1436
+ }, []);
1437
+ return null;
1438
+ }, "RedirectToCreateOrganization");
1439
+ var AuthenticateWithRedirectCallback = withClerk(
1440
+ ({ clerk, ...handleRedirectCallbackParams }) => {
1441
+ import_react20.default.useEffect(() => {
1442
+ void clerk.handleRedirectCallback(handleRedirectCallbackParams);
1443
+ }, []);
1444
+ return null;
1445
+ },
1446
+ "AuthenticateWithRedirectCallback"
1447
+ );
1448
+
1449
+ // src/components/SignInButton.tsx
1450
+ var import_react21 = __toESM(require("react"));
1451
+ var SignInButton = withClerk(
1452
+ ({ clerk, children, ...props }) => {
1453
+ const {
1454
+ signUpFallbackRedirectUrl,
1455
+ forceRedirectUrl,
1456
+ fallbackRedirectUrl,
1457
+ signUpForceRedirectUrl,
1458
+ mode,
1459
+ initialValues,
1460
+ withSignUp,
1461
+ oauthFlow,
1462
+ ...rest
1463
+ } = props;
1464
+ children = normalizeWithDefaultValue(children, "Sign in");
1465
+ const child = assertSingleChild(children)("SignInButton");
1466
+ const clickHandler = () => {
1467
+ const opts = {
1468
+ forceRedirectUrl,
1469
+ fallbackRedirectUrl,
1470
+ signUpFallbackRedirectUrl,
1471
+ signUpForceRedirectUrl,
1472
+ initialValues,
1473
+ withSignUp,
1474
+ oauthFlow
1475
+ };
1476
+ if (mode === "modal") {
1477
+ return clerk.openSignIn({ ...opts, appearance: props.appearance });
1478
+ }
1479
+ return clerk.redirectToSignIn({
1480
+ ...opts,
1481
+ signInFallbackRedirectUrl: fallbackRedirectUrl,
1482
+ signInForceRedirectUrl: forceRedirectUrl
1483
+ });
1484
+ };
1485
+ const wrappedChildClickHandler = async (e) => {
1486
+ if (child && typeof child === "object" && "props" in child) {
1487
+ await safeExecute(child.props.onClick)(e);
1488
+ }
1489
+ return clickHandler();
1490
+ };
1491
+ const childProps = { ...rest, onClick: wrappedChildClickHandler };
1492
+ return import_react21.default.cloneElement(child, childProps);
1493
+ },
1494
+ { component: "SignInButton", renderWhileLoading: true }
1495
+ );
1496
+
1497
+ // src/components/SignInWithMetamaskButton.tsx
1498
+ var import_react22 = __toESM(require("react"));
1499
+ var SignInWithMetamaskButton = withClerk(
1500
+ ({ clerk, children, ...props }) => {
1501
+ const { redirectUrl, ...rest } = props;
1502
+ children = normalizeWithDefaultValue(children, "Sign in with Metamask");
1503
+ const child = assertSingleChild(children)("SignInWithMetamaskButton");
1504
+ const clickHandler = async () => {
1505
+ async function authenticate() {
1506
+ await clerk.authenticateWithMetamask({ redirectUrl: redirectUrl || void 0 });
1507
+ }
1508
+ void authenticate();
1509
+ };
1510
+ const wrappedChildClickHandler = async (e) => {
1511
+ await safeExecute(child.props.onClick)(e);
1512
+ return clickHandler();
1513
+ };
1514
+ const childProps = { ...rest, onClick: wrappedChildClickHandler };
1515
+ return import_react22.default.cloneElement(child, childProps);
1516
+ },
1517
+ { component: "SignInWithMetamask", renderWhileLoading: true }
1518
+ );
1519
+
1520
+ // src/components/SignOutButton.tsx
1521
+ var import_react23 = __toESM(require("react"));
1522
+ var SignOutButton = withClerk(
1523
+ ({ clerk, children, ...props }) => {
1524
+ const { redirectUrl = "/", signOutOptions, ...rest } = props;
1525
+ children = normalizeWithDefaultValue(children, "Sign out");
1526
+ const child = assertSingleChild(children)("SignOutButton");
1527
+ const clickHandler = () => clerk.signOut({ redirectUrl, ...signOutOptions });
1528
+ const wrappedChildClickHandler = async (e) => {
1529
+ await safeExecute(child.props.onClick)(e);
1530
+ return clickHandler();
1531
+ };
1532
+ const childProps = { ...rest, onClick: wrappedChildClickHandler };
1533
+ return import_react23.default.cloneElement(child, childProps);
1534
+ },
1535
+ { component: "SignOutButton", renderWhileLoading: true }
1536
+ );
1537
+
1538
+ // src/components/SignUpButton.tsx
1539
+ var import_react24 = __toESM(require("react"));
1540
+ var SignUpButton = withClerk(
1541
+ ({ clerk, children, ...props }) => {
1542
+ const {
1543
+ fallbackRedirectUrl,
1544
+ forceRedirectUrl,
1545
+ signInFallbackRedirectUrl,
1546
+ signInForceRedirectUrl,
1547
+ mode,
1548
+ initialValues,
1549
+ oauthFlow,
1550
+ ...rest
1551
+ } = props;
1552
+ children = normalizeWithDefaultValue(children, "Sign up");
1553
+ const child = assertSingleChild(children)("SignUpButton");
1554
+ const clickHandler = () => {
1555
+ const opts = {
1556
+ fallbackRedirectUrl,
1557
+ forceRedirectUrl,
1558
+ signInFallbackRedirectUrl,
1559
+ signInForceRedirectUrl,
1560
+ initialValues,
1561
+ oauthFlow
1562
+ };
1563
+ if (mode === "modal") {
1564
+ return clerk.openSignUp({
1565
+ ...opts,
1566
+ appearance: props.appearance,
1567
+ unsafeMetadata: props.unsafeMetadata
1568
+ });
1569
+ }
1570
+ return clerk.redirectToSignUp({
1571
+ ...opts,
1572
+ signUpFallbackRedirectUrl: fallbackRedirectUrl,
1573
+ signUpForceRedirectUrl: forceRedirectUrl
1574
+ });
1575
+ };
1576
+ const wrappedChildClickHandler = async (e) => {
1577
+ if (child && typeof child === "object" && "props" in child) {
1578
+ await safeExecute(child.props.onClick)(e);
1579
+ }
1580
+ return clickHandler();
1581
+ };
1582
+ const childProps = { ...rest, onClick: wrappedChildClickHandler };
1583
+ return import_react24.default.cloneElement(child, childProps);
1584
+ },
1585
+ { component: "SignUpButton", renderWhileLoading: true }
1586
+ );
1587
+
1588
+ // src/contexts/ClerkProvider.tsx
1589
+ var import_keys = require("@clerk/shared/keys");
1590
+ var import_react27 = __toESM(require("react"));
1591
+
1592
+ // src/contexts/ClerkContextProvider.tsx
1593
+ var import_deriveState = require("@clerk/shared/deriveState");
1594
+ var import_react25 = require("@clerk/shared/react");
1595
+ var import_react26 = __toESM(require("react"));
1596
+
1597
+ // src/isomorphicClerk.ts
1598
+ var import_browser2 = require("@clerk/shared/browser");
1599
+ var import_clerkEventBus = require("@clerk/shared/clerkEventBus");
1600
+ var import_loadClerkJsScript = require("@clerk/shared/loadClerkJsScript");
1601
+ var import_utils10 = require("@clerk/shared/utils");
1602
+
1603
+ // src/stateProxy.ts
1604
+ var import_browser = require("@clerk/shared/browser");
1605
+ var defaultErrors = () => ({
1606
+ fields: {
1607
+ firstName: null,
1608
+ lastName: null,
1609
+ emailAddress: null,
1610
+ identifier: null,
1611
+ phoneNumber: null,
1612
+ password: null,
1613
+ username: null,
1614
+ code: null,
1615
+ captcha: null,
1616
+ legalAccepted: null
1617
+ },
1618
+ raw: null,
1619
+ global: null
1620
+ });
1621
+ var StateProxy = class {
1622
+ constructor(isomorphicClerk) {
1623
+ this.isomorphicClerk = isomorphicClerk;
1624
+ this.signInSignalProxy = this.buildSignInProxy();
1625
+ this.signUpSignalProxy = this.buildSignUpProxy();
1626
+ }
1627
+ signInSignal() {
1628
+ return this.signInSignalProxy;
1629
+ }
1630
+ signUpSignal() {
1631
+ return this.signUpSignalProxy;
1632
+ }
1633
+ buildSignInProxy() {
1634
+ const gateProperty = this.gateProperty.bind(this);
1635
+ const target = () => this.client.signIn.__internal_future;
1636
+ return {
1637
+ errors: defaultErrors(),
1638
+ fetchStatus: "idle",
1639
+ signIn: {
1640
+ status: "needs_identifier",
1641
+ availableStrategies: [],
1642
+ isTransferable: false,
1643
+ get id() {
1644
+ return gateProperty(target, "id", void 0);
1645
+ },
1646
+ get supportedFirstFactors() {
1647
+ return gateProperty(target, "supportedFirstFactors", []);
1648
+ },
1649
+ get supportedSecondFactors() {
1650
+ return gateProperty(target, "supportedSecondFactors", []);
1651
+ },
1652
+ get secondFactorVerification() {
1653
+ return gateProperty(target, "secondFactorVerification", {
1654
+ status: null,
1655
+ error: null,
1656
+ expireAt: null,
1657
+ externalVerificationRedirectURL: null,
1658
+ nonce: null,
1659
+ attempts: null,
1660
+ message: null,
1661
+ strategy: null,
1662
+ verifiedAtClient: null,
1663
+ verifiedFromTheSameClient: () => false,
1664
+ __internal_toSnapshot: () => {
1665
+ throw new Error("__internal_toSnapshot called before Clerk is loaded");
1666
+ },
1667
+ pathRoot: "",
1668
+ reload: () => {
1669
+ throw new Error("__internal_toSnapshot called before Clerk is loaded");
1670
+ }
1671
+ });
1672
+ },
1673
+ get identifier() {
1674
+ return gateProperty(target, "identifier", null);
1675
+ },
1676
+ get createdSessionId() {
1677
+ return gateProperty(target, "createdSessionId", null);
1678
+ },
1679
+ get userData() {
1680
+ return gateProperty(target, "userData", {});
1681
+ },
1682
+ get firstFactorVerification() {
1683
+ return gateProperty(target, "firstFactorVerification", {
1684
+ status: null,
1685
+ error: null,
1686
+ expireAt: null,
1687
+ externalVerificationRedirectURL: null,
1688
+ nonce: null,
1689
+ attempts: null,
1690
+ message: null,
1691
+ strategy: null,
1692
+ verifiedAtClient: null,
1693
+ verifiedFromTheSameClient: () => false,
1694
+ __internal_toSnapshot: () => {
1695
+ throw new Error("__internal_toSnapshot called before Clerk is loaded");
1696
+ },
1697
+ pathRoot: "",
1698
+ reload: () => {
1699
+ throw new Error("__internal_toSnapshot called before Clerk is loaded");
1700
+ }
1701
+ });
1702
+ },
1703
+ get hasBeenFinalized() {
1704
+ return gateProperty(target, "hasBeenFinalized", false);
1705
+ },
1706
+ create: this.gateMethod(target, "create"),
1707
+ password: this.gateMethod(target, "password"),
1708
+ sso: this.gateMethod(target, "sso"),
1709
+ finalize: this.gateMethod(target, "finalize"),
1710
+ emailCode: this.wrapMethods(() => target().emailCode, ["sendCode", "verifyCode"]),
1711
+ emailLink: this.wrapStruct(
1712
+ () => target().emailLink,
1713
+ ["sendLink", "waitForVerification"],
1714
+ ["verification"],
1715
+ { verification: null }
1716
+ ),
1717
+ resetPasswordEmailCode: this.wrapMethods(() => target().resetPasswordEmailCode, [
1718
+ "sendCode",
1719
+ "verifyCode",
1720
+ "submitPassword"
1721
+ ]),
1722
+ phoneCode: this.wrapMethods(() => target().phoneCode, ["sendCode", "verifyCode"]),
1723
+ mfa: this.wrapMethods(() => target().mfa, [
1724
+ "sendPhoneCode",
1725
+ "verifyPhoneCode",
1726
+ "verifyTOTP",
1727
+ "verifyBackupCode"
1728
+ ]),
1729
+ ticket: this.gateMethod(target, "ticket"),
1730
+ passkey: this.gateMethod(target, "passkey"),
1731
+ web3: this.gateMethod(target, "web3")
1732
+ }
1733
+ };
1734
+ }
1735
+ buildSignUpProxy() {
1736
+ const gateProperty = this.gateProperty.bind(this);
1737
+ const gateMethod = this.gateMethod.bind(this);
1738
+ const wrapMethods = this.wrapMethods.bind(this);
1739
+ const target = () => this.client.signUp.__internal_future;
1740
+ return {
1741
+ errors: defaultErrors(),
1742
+ fetchStatus: "idle",
1743
+ signUp: {
1744
+ get id() {
1745
+ return gateProperty(target, "id", void 0);
1746
+ },
1747
+ get requiredFields() {
1748
+ return gateProperty(target, "requiredFields", []);
1749
+ },
1750
+ get optionalFields() {
1751
+ return gateProperty(target, "optionalFields", []);
1752
+ },
1753
+ get missingFields() {
1754
+ return gateProperty(target, "missingFields", []);
1755
+ },
1756
+ get username() {
1757
+ return gateProperty(target, "username", null);
1758
+ },
1759
+ get firstName() {
1760
+ return gateProperty(target, "firstName", null);
1761
+ },
1762
+ get lastName() {
1763
+ return gateProperty(target, "lastName", null);
1764
+ },
1765
+ get emailAddress() {
1766
+ return gateProperty(target, "emailAddress", null);
1767
+ },
1768
+ get phoneNumber() {
1769
+ return gateProperty(target, "phoneNumber", null);
1770
+ },
1771
+ get web3Wallet() {
1772
+ return gateProperty(target, "web3Wallet", null);
1773
+ },
1774
+ get hasPassword() {
1775
+ return gateProperty(target, "hasPassword", false);
1776
+ },
1777
+ get unsafeMetadata() {
1778
+ return gateProperty(target, "unsafeMetadata", {});
1779
+ },
1780
+ get createdSessionId() {
1781
+ return gateProperty(target, "createdSessionId", null);
1782
+ },
1783
+ get createdUserId() {
1784
+ return gateProperty(target, "createdUserId", null);
1785
+ },
1786
+ get abandonAt() {
1787
+ return gateProperty(target, "abandonAt", null);
1788
+ },
1789
+ get legalAcceptedAt() {
1790
+ return gateProperty(target, "legalAcceptedAt", null);
1791
+ },
1792
+ get locale() {
1793
+ return gateProperty(target, "locale", null);
1794
+ },
1795
+ get status() {
1796
+ return gateProperty(target, "status", "missing_requirements");
1797
+ },
1798
+ get unverifiedFields() {
1799
+ return gateProperty(target, "unverifiedFields", []);
1800
+ },
1801
+ get isTransferable() {
1802
+ return gateProperty(target, "isTransferable", false);
1803
+ },
1804
+ get hasBeenFinalized() {
1805
+ return gateProperty(target, "hasBeenFinalized", false);
1806
+ },
1807
+ create: gateMethod(target, "create"),
1808
+ update: gateMethod(target, "update"),
1809
+ sso: gateMethod(target, "sso"),
1810
+ password: gateMethod(target, "password"),
1811
+ ticket: gateMethod(target, "ticket"),
1812
+ web3: gateMethod(target, "web3"),
1813
+ finalize: gateMethod(target, "finalize"),
1814
+ verifications: wrapMethods(() => target().verifications, [
1815
+ "sendEmailCode",
1816
+ "verifyEmailCode",
1817
+ "sendPhoneCode",
1818
+ "verifyPhoneCode"
1819
+ ])
1820
+ }
1821
+ };
1822
+ }
1823
+ __internal_effect(_) {
1824
+ throw new Error("__internal_effect called before Clerk is loaded");
1825
+ }
1826
+ __internal_computed(_) {
1827
+ throw new Error("__internal_computed called before Clerk is loaded");
1828
+ }
1829
+ get client() {
1830
+ const c = this.isomorphicClerk.client;
1831
+ if (!c) {
1832
+ throw new Error("Clerk client not ready");
1833
+ }
1834
+ return c;
1835
+ }
1836
+ gateProperty(getTarget, key, defaultValue) {
1837
+ return (() => {
1838
+ if (!(0, import_browser.inBrowser)() || !this.isomorphicClerk.loaded) {
1839
+ return defaultValue;
1840
+ }
1841
+ const t = getTarget();
1842
+ return t[key];
1843
+ })();
1844
+ }
1845
+ gateMethod(getTarget, key) {
1846
+ return (async (...args) => {
1847
+ if (!(0, import_browser.inBrowser)()) {
1848
+ return errorThrower.throw(`Attempted to call a method (${key}) that is not supported on the server.`);
1849
+ }
1850
+ if (!this.isomorphicClerk.loaded) {
1851
+ await new Promise((resolve) => this.isomorphicClerk.addOnLoaded(resolve));
1852
+ }
1853
+ const t = getTarget();
1854
+ return t[key].apply(t, args);
1855
+ });
1856
+ }
1857
+ wrapMethods(getTarget, keys) {
1858
+ return Object.fromEntries(keys.map((k) => [k, this.gateMethod(getTarget, k)]));
1859
+ }
1860
+ wrapStruct(getTarget, methods, getters, fallbacks) {
1861
+ const out = {};
1862
+ for (const m of methods) {
1863
+ out[m] = this.gateMethod(getTarget, m);
1864
+ }
1865
+ for (const g of getters) {
1866
+ Object.defineProperty(out, g, {
1867
+ get: () => this.gateProperty(getTarget, g, fallbacks[g]),
1868
+ enumerable: true
1869
+ });
1870
+ }
1871
+ return out;
1872
+ }
1873
+ };
1874
+
1875
+ // src/isomorphicClerk.ts
1876
+ if (typeof globalThis.__BUILD_DISABLE_RHC__ === "undefined") {
1877
+ globalThis.__BUILD_DISABLE_RHC__ = false;
1878
+ }
1879
+ var SDK_METADATA = {
1880
+ name: "@clerk/react",
1881
+ version: "5.54.0",
1882
+ environment: process.env.NODE_ENV
1883
+ };
1884
+ var _status, _domain, _proxyUrl, _publishableKey, _eventBus, _stateProxy, _instance, _IsomorphicClerk_instances, waitForClerkJS_fn;
1885
+ var _IsomorphicClerk = class _IsomorphicClerk {
1886
+ constructor(options) {
1887
+ __privateAdd(this, _IsomorphicClerk_instances);
1888
+ this.clerkjs = null;
1889
+ this.preopenOneTap = null;
1890
+ this.preopenUserVerification = null;
1891
+ this.preopenSignIn = null;
1892
+ this.preopenCheckout = null;
1893
+ this.preopenPlanDetails = null;
1894
+ this.preopenSubscriptionDetails = null;
1895
+ this.preopenSignUp = null;
1896
+ this.preopenUserProfile = null;
1897
+ this.preopenOrganizationProfile = null;
1898
+ this.preopenCreateOrganization = null;
1899
+ this.preOpenWaitlist = null;
1900
+ this.premountSignInNodes = /* @__PURE__ */ new Map();
1901
+ this.premountSignUpNodes = /* @__PURE__ */ new Map();
1902
+ this.premountUserAvatarNodes = /* @__PURE__ */ new Map();
1903
+ this.premountUserProfileNodes = /* @__PURE__ */ new Map();
1904
+ this.premountUserButtonNodes = /* @__PURE__ */ new Map();
1905
+ this.premountOrganizationProfileNodes = /* @__PURE__ */ new Map();
1906
+ this.premountCreateOrganizationNodes = /* @__PURE__ */ new Map();
1907
+ this.premountOrganizationSwitcherNodes = /* @__PURE__ */ new Map();
1908
+ this.premountOrganizationListNodes = /* @__PURE__ */ new Map();
1909
+ this.premountMethodCalls = /* @__PURE__ */ new Map();
1910
+ this.premountWaitlistNodes = /* @__PURE__ */ new Map();
1911
+ this.premountPricingTableNodes = /* @__PURE__ */ new Map();
1912
+ this.premountApiKeysNodes = /* @__PURE__ */ new Map();
1913
+ this.premountOAuthConsentNodes = /* @__PURE__ */ new Map();
1914
+ this.premountTaskChooseOrganizationNodes = /* @__PURE__ */ new Map();
1915
+ // A separate Map of `addListener` method calls to handle multiple listeners.
1916
+ this.premountAddListenerCalls = /* @__PURE__ */ new Map();
1917
+ this.loadedListeners = [];
1918
+ __privateAdd(this, _status, "loading");
1919
+ __privateAdd(this, _domain);
1920
+ __privateAdd(this, _proxyUrl);
1921
+ __privateAdd(this, _publishableKey);
1922
+ __privateAdd(this, _eventBus, (0, import_clerkEventBus.createClerkEventBus)());
1923
+ __privateAdd(this, _stateProxy);
1924
+ this.buildSignInUrl = (opts) => {
1925
+ const callback = () => {
1926
+ var _a;
1927
+ return ((_a = this.clerkjs) == null ? void 0 : _a.buildSignInUrl(opts)) || "";
1928
+ };
1929
+ if (this.clerkjs && this.loaded) {
1930
+ return callback();
1931
+ } else {
1932
+ this.premountMethodCalls.set("buildSignInUrl", callback);
1933
+ }
1934
+ };
1935
+ this.buildSignUpUrl = (opts) => {
1936
+ const callback = () => {
1937
+ var _a;
1938
+ return ((_a = this.clerkjs) == null ? void 0 : _a.buildSignUpUrl(opts)) || "";
1939
+ };
1940
+ if (this.clerkjs && this.loaded) {
1941
+ return callback();
1942
+ } else {
1943
+ this.premountMethodCalls.set("buildSignUpUrl", callback);
1944
+ }
1945
+ };
1946
+ this.buildAfterSignInUrl = (...args) => {
1947
+ const callback = () => {
1948
+ var _a;
1949
+ return ((_a = this.clerkjs) == null ? void 0 : _a.buildAfterSignInUrl(...args)) || "";
1950
+ };
1951
+ if (this.clerkjs && this.loaded) {
1952
+ return callback();
1953
+ } else {
1954
+ this.premountMethodCalls.set("buildAfterSignInUrl", callback);
1955
+ }
1956
+ };
1957
+ this.buildAfterSignUpUrl = (...args) => {
1958
+ const callback = () => {
1959
+ var _a;
1960
+ return ((_a = this.clerkjs) == null ? void 0 : _a.buildAfterSignUpUrl(...args)) || "";
1961
+ };
1962
+ if (this.clerkjs && this.loaded) {
1963
+ return callback();
1964
+ } else {
1965
+ this.premountMethodCalls.set("buildAfterSignUpUrl", callback);
1966
+ }
1967
+ };
1968
+ this.buildAfterSignOutUrl = () => {
1969
+ const callback = () => {
1970
+ var _a;
1971
+ return ((_a = this.clerkjs) == null ? void 0 : _a.buildAfterSignOutUrl()) || "";
1972
+ };
1973
+ if (this.clerkjs && this.loaded) {
1974
+ return callback();
1975
+ } else {
1976
+ this.premountMethodCalls.set("buildAfterSignOutUrl", callback);
1977
+ }
1978
+ };
1979
+ this.buildNewSubscriptionRedirectUrl = () => {
1980
+ const callback = () => {
1981
+ var _a;
1982
+ return ((_a = this.clerkjs) == null ? void 0 : _a.buildNewSubscriptionRedirectUrl()) || "";
1983
+ };
1984
+ if (this.clerkjs && this.loaded) {
1985
+ return callback();
1986
+ } else {
1987
+ this.premountMethodCalls.set("buildNewSubscriptionRedirectUrl", callback);
1988
+ }
1989
+ };
1990
+ this.buildAfterMultiSessionSingleSignOutUrl = () => {
1991
+ const callback = () => {
1992
+ var _a;
1993
+ return ((_a = this.clerkjs) == null ? void 0 : _a.buildAfterMultiSessionSingleSignOutUrl()) || "";
1994
+ };
1995
+ if (this.clerkjs && this.loaded) {
1996
+ return callback();
1997
+ } else {
1998
+ this.premountMethodCalls.set("buildAfterMultiSessionSingleSignOutUrl", callback);
1999
+ }
2000
+ };
2001
+ this.buildUserProfileUrl = () => {
2002
+ const callback = () => {
2003
+ var _a;
2004
+ return ((_a = this.clerkjs) == null ? void 0 : _a.buildUserProfileUrl()) || "";
2005
+ };
2006
+ if (this.clerkjs && this.loaded) {
2007
+ return callback();
2008
+ } else {
2009
+ this.premountMethodCalls.set("buildUserProfileUrl", callback);
2010
+ }
2011
+ };
2012
+ this.buildCreateOrganizationUrl = () => {
2013
+ const callback = () => {
2014
+ var _a;
2015
+ return ((_a = this.clerkjs) == null ? void 0 : _a.buildCreateOrganizationUrl()) || "";
2016
+ };
2017
+ if (this.clerkjs && this.loaded) {
2018
+ return callback();
2019
+ } else {
2020
+ this.premountMethodCalls.set("buildCreateOrganizationUrl", callback);
2021
+ }
2022
+ };
2023
+ this.buildOrganizationProfileUrl = () => {
2024
+ const callback = () => {
2025
+ var _a;
2026
+ return ((_a = this.clerkjs) == null ? void 0 : _a.buildOrganizationProfileUrl()) || "";
2027
+ };
2028
+ if (this.clerkjs && this.loaded) {
2029
+ return callback();
2030
+ } else {
2031
+ this.premountMethodCalls.set("buildOrganizationProfileUrl", callback);
2032
+ }
2033
+ };
2034
+ this.buildWaitlistUrl = () => {
2035
+ const callback = () => {
2036
+ var _a;
2037
+ return ((_a = this.clerkjs) == null ? void 0 : _a.buildWaitlistUrl()) || "";
2038
+ };
2039
+ if (this.clerkjs && this.loaded) {
2040
+ return callback();
2041
+ } else {
2042
+ this.premountMethodCalls.set("buildWaitlistUrl", callback);
2043
+ }
2044
+ };
2045
+ this.buildTasksUrl = () => {
2046
+ const callback = () => {
2047
+ var _a;
2048
+ return ((_a = this.clerkjs) == null ? void 0 : _a.buildTasksUrl()) || "";
2049
+ };
2050
+ if (this.clerkjs && this.loaded) {
2051
+ return callback();
2052
+ } else {
2053
+ this.premountMethodCalls.set("buildTasksUrl", callback);
2054
+ }
2055
+ };
2056
+ this.buildUrlWithAuth = (to) => {
2057
+ const callback = () => {
2058
+ var _a;
2059
+ return ((_a = this.clerkjs) == null ? void 0 : _a.buildUrlWithAuth(to)) || "";
2060
+ };
2061
+ if (this.clerkjs && this.loaded) {
2062
+ return callback();
2063
+ } else {
2064
+ this.premountMethodCalls.set("buildUrlWithAuth", callback);
2065
+ }
2066
+ };
2067
+ this.handleUnauthenticated = async () => {
2068
+ const callback = () => {
2069
+ var _a;
2070
+ return (_a = this.clerkjs) == null ? void 0 : _a.handleUnauthenticated();
2071
+ };
2072
+ if (this.clerkjs && this.loaded) {
2073
+ void callback();
2074
+ } else {
2075
+ this.premountMethodCalls.set("handleUnauthenticated", callback);
2076
+ }
2077
+ };
2078
+ this.on = (...args) => {
2079
+ var _a;
2080
+ if ((_a = this.clerkjs) == null ? void 0 : _a.on) {
2081
+ return this.clerkjs.on(...args);
2082
+ } else {
2083
+ __privateGet(this, _eventBus).on(...args);
2084
+ }
2085
+ };
2086
+ this.off = (...args) => {
2087
+ var _a;
2088
+ if ((_a = this.clerkjs) == null ? void 0 : _a.off) {
2089
+ return this.clerkjs.off(...args);
2090
+ } else {
2091
+ __privateGet(this, _eventBus).off(...args);
2092
+ }
2093
+ };
2094
+ /**
2095
+ * @deprecated Please use `addStatusListener`. This api will be removed in the next major.
2096
+ */
2097
+ this.addOnLoaded = (cb) => {
2098
+ this.loadedListeners.push(cb);
2099
+ if (this.loaded) {
2100
+ this.emitLoaded();
2101
+ }
2102
+ };
2103
+ /**
2104
+ * @deprecated Please use `__internal_setStatus`. This api will be removed in the next major.
2105
+ */
2106
+ this.emitLoaded = () => {
2107
+ this.loadedListeners.forEach((cb) => cb());
2108
+ this.loadedListeners = [];
2109
+ };
2110
+ this.beforeLoad = (clerkjs) => {
2111
+ if (!clerkjs) {
2112
+ throw new Error("Failed to hydrate latest Clerk JS");
2113
+ }
2114
+ };
2115
+ this.replayInterceptedInvocations = (clerkjs) => {
2116
+ var _a, _b;
2117
+ if (!clerkjs) {
2118
+ throw new Error("Failed to hydrate latest Clerk JS");
2119
+ }
2120
+ this.clerkjs = clerkjs;
2121
+ this.premountMethodCalls.forEach((cb) => cb());
2122
+ this.premountAddListenerCalls.forEach((listenerHandlers, listener) => {
2123
+ listenerHandlers.nativeUnsubscribe = clerkjs.addListener(listener);
2124
+ });
2125
+ (_a = __privateGet(this, _eventBus).internal.retrieveListeners("status")) == null ? void 0 : _a.forEach((listener) => {
2126
+ this.on("status", listener, { notify: true });
2127
+ });
2128
+ (_b = __privateGet(this, _eventBus).internal.retrieveListeners("queryClientStatus")) == null ? void 0 : _b.forEach((listener) => {
2129
+ this.on("queryClientStatus", listener, { notify: true });
2130
+ });
2131
+ if (this.preopenSignIn !== null) {
2132
+ clerkjs.openSignIn(this.preopenSignIn);
2133
+ }
2134
+ if (this.preopenCheckout !== null) {
2135
+ clerkjs.__internal_openCheckout(this.preopenCheckout);
2136
+ }
2137
+ if (this.preopenPlanDetails !== null) {
2138
+ clerkjs.__internal_openPlanDetails(this.preopenPlanDetails);
2139
+ }
2140
+ if (this.preopenSubscriptionDetails !== null) {
2141
+ clerkjs.__internal_openSubscriptionDetails(this.preopenSubscriptionDetails);
2142
+ }
2143
+ if (this.preopenSignUp !== null) {
2144
+ clerkjs.openSignUp(this.preopenSignUp);
2145
+ }
2146
+ if (this.preopenUserProfile !== null) {
2147
+ clerkjs.openUserProfile(this.preopenUserProfile);
2148
+ }
2149
+ if (this.preopenUserVerification !== null) {
2150
+ clerkjs.__internal_openReverification(this.preopenUserVerification);
2151
+ }
2152
+ if (this.preopenOneTap !== null) {
2153
+ clerkjs.openGoogleOneTap(this.preopenOneTap);
2154
+ }
2155
+ if (this.preopenOrganizationProfile !== null) {
2156
+ clerkjs.openOrganizationProfile(this.preopenOrganizationProfile);
2157
+ }
2158
+ if (this.preopenCreateOrganization !== null) {
2159
+ clerkjs.openCreateOrganization(this.preopenCreateOrganization);
2160
+ }
2161
+ if (this.preOpenWaitlist !== null) {
2162
+ clerkjs.openWaitlist(this.preOpenWaitlist);
2163
+ }
2164
+ this.premountSignInNodes.forEach((props, node) => {
2165
+ clerkjs.mountSignIn(node, props);
2166
+ });
2167
+ this.premountSignUpNodes.forEach((props, node) => {
2168
+ clerkjs.mountSignUp(node, props);
2169
+ });
2170
+ this.premountUserProfileNodes.forEach((props, node) => {
2171
+ clerkjs.mountUserProfile(node, props);
2172
+ });
2173
+ this.premountUserAvatarNodes.forEach((props, node) => {
2174
+ clerkjs.mountUserAvatar(node, props);
2175
+ });
2176
+ this.premountUserButtonNodes.forEach((props, node) => {
2177
+ clerkjs.mountUserButton(node, props);
2178
+ });
2179
+ this.premountOrganizationListNodes.forEach((props, node) => {
2180
+ clerkjs.mountOrganizationList(node, props);
2181
+ });
2182
+ this.premountWaitlistNodes.forEach((props, node) => {
2183
+ clerkjs.mountWaitlist(node, props);
2184
+ });
2185
+ this.premountPricingTableNodes.forEach((props, node) => {
2186
+ clerkjs.mountPricingTable(node, props);
2187
+ });
2188
+ this.premountApiKeysNodes.forEach((props, node) => {
2189
+ clerkjs.mountApiKeys(node, props);
2190
+ });
2191
+ this.premountOAuthConsentNodes.forEach((props, node) => {
2192
+ clerkjs.__internal_mountOAuthConsent(node, props);
2193
+ });
2194
+ this.premountTaskChooseOrganizationNodes.forEach((props, node) => {
2195
+ clerkjs.mountTaskChooseOrganization(node, props);
2196
+ });
2197
+ if (typeof this.clerkjs.status === "undefined") {
2198
+ __privateGet(this, _eventBus).emit(import_clerkEventBus.clerkEvents.Status, "ready");
2199
+ }
2200
+ this.emitLoaded();
2201
+ return this.clerkjs;
2202
+ };
2203
+ this.__experimental_checkout = (...args) => {
2204
+ var _a;
2205
+ return (_a = this.clerkjs) == null ? void 0 : _a.__experimental_checkout(...args);
2206
+ };
2207
+ // TODO @userland-errors:
2208
+ this.__unstable__updateProps = async (props) => {
2209
+ const clerkjs = await __privateMethod(this, _IsomorphicClerk_instances, waitForClerkJS_fn).call(this);
2210
+ if (clerkjs && "__unstable__updateProps" in clerkjs) {
2211
+ return clerkjs.__unstable__updateProps(props);
2212
+ }
2213
+ };
2214
+ /**
2215
+ * `setActive` can be used to set the active session and/or organization.
2216
+ */
2217
+ this.setActive = (params) => {
2218
+ if (this.clerkjs) {
2219
+ return this.clerkjs.setActive(params);
2220
+ } else {
2221
+ return Promise.reject();
2222
+ }
2223
+ };
2224
+ this.openSignIn = (props) => {
2225
+ if (this.clerkjs && this.loaded) {
2226
+ this.clerkjs.openSignIn(props);
2227
+ } else {
2228
+ this.preopenSignIn = props;
2229
+ }
2230
+ };
2231
+ this.closeSignIn = () => {
2232
+ if (this.clerkjs && this.loaded) {
2233
+ this.clerkjs.closeSignIn();
2234
+ } else {
2235
+ this.preopenSignIn = null;
2236
+ }
2237
+ };
2238
+ this.__internal_openCheckout = (props) => {
2239
+ if (this.clerkjs && this.loaded) {
2240
+ this.clerkjs.__internal_openCheckout(props);
2241
+ } else {
2242
+ this.preopenCheckout = props;
2243
+ }
2244
+ };
2245
+ this.__internal_closeCheckout = () => {
2246
+ if (this.clerkjs && this.loaded) {
2247
+ this.clerkjs.__internal_closeCheckout();
2248
+ } else {
2249
+ this.preopenCheckout = null;
2250
+ }
2251
+ };
2252
+ this.__internal_openPlanDetails = (props) => {
2253
+ if (this.clerkjs && this.loaded) {
2254
+ this.clerkjs.__internal_openPlanDetails(props);
2255
+ } else {
2256
+ this.preopenPlanDetails = props;
2257
+ }
2258
+ };
2259
+ this.__internal_closePlanDetails = () => {
2260
+ if (this.clerkjs && this.loaded) {
2261
+ this.clerkjs.__internal_closePlanDetails();
2262
+ } else {
2263
+ this.preopenPlanDetails = null;
2264
+ }
2265
+ };
2266
+ this.__internal_openSubscriptionDetails = (props) => {
2267
+ if (this.clerkjs && this.loaded) {
2268
+ this.clerkjs.__internal_openSubscriptionDetails(props);
2269
+ } else {
2270
+ this.preopenSubscriptionDetails = props != null ? props : null;
2271
+ }
2272
+ };
2273
+ this.__internal_closeSubscriptionDetails = () => {
2274
+ if (this.clerkjs && this.loaded) {
2275
+ this.clerkjs.__internal_closeSubscriptionDetails();
2276
+ } else {
2277
+ this.preopenSubscriptionDetails = null;
2278
+ }
2279
+ };
2280
+ this.__internal_openReverification = (props) => {
2281
+ if (this.clerkjs && this.loaded) {
2282
+ this.clerkjs.__internal_openReverification(props);
2283
+ } else {
2284
+ this.preopenUserVerification = props;
2285
+ }
2286
+ };
2287
+ this.__internal_closeReverification = () => {
2288
+ if (this.clerkjs && this.loaded) {
2289
+ this.clerkjs.__internal_closeReverification();
2290
+ } else {
2291
+ this.preopenUserVerification = null;
2292
+ }
2293
+ };
2294
+ this.openGoogleOneTap = (props) => {
2295
+ if (this.clerkjs && this.loaded) {
2296
+ this.clerkjs.openGoogleOneTap(props);
2297
+ } else {
2298
+ this.preopenOneTap = props;
2299
+ }
2300
+ };
2301
+ this.closeGoogleOneTap = () => {
2302
+ if (this.clerkjs && this.loaded) {
2303
+ this.clerkjs.closeGoogleOneTap();
2304
+ } else {
2305
+ this.preopenOneTap = null;
2306
+ }
2307
+ };
2308
+ this.openUserProfile = (props) => {
2309
+ if (this.clerkjs && this.loaded) {
2310
+ this.clerkjs.openUserProfile(props);
2311
+ } else {
2312
+ this.preopenUserProfile = props;
2313
+ }
2314
+ };
2315
+ this.closeUserProfile = () => {
2316
+ if (this.clerkjs && this.loaded) {
2317
+ this.clerkjs.closeUserProfile();
2318
+ } else {
2319
+ this.preopenUserProfile = null;
2320
+ }
2321
+ };
2322
+ this.openOrganizationProfile = (props) => {
2323
+ if (this.clerkjs && this.loaded) {
2324
+ this.clerkjs.openOrganizationProfile(props);
2325
+ } else {
2326
+ this.preopenOrganizationProfile = props;
2327
+ }
2328
+ };
2329
+ this.closeOrganizationProfile = () => {
2330
+ if (this.clerkjs && this.loaded) {
2331
+ this.clerkjs.closeOrganizationProfile();
2332
+ } else {
2333
+ this.preopenOrganizationProfile = null;
2334
+ }
2335
+ };
2336
+ this.openCreateOrganization = (props) => {
2337
+ if (this.clerkjs && this.loaded) {
2338
+ this.clerkjs.openCreateOrganization(props);
2339
+ } else {
2340
+ this.preopenCreateOrganization = props;
2341
+ }
2342
+ };
2343
+ this.closeCreateOrganization = () => {
2344
+ if (this.clerkjs && this.loaded) {
2345
+ this.clerkjs.closeCreateOrganization();
2346
+ } else {
2347
+ this.preopenCreateOrganization = null;
2348
+ }
2349
+ };
2350
+ this.openWaitlist = (props) => {
2351
+ if (this.clerkjs && this.loaded) {
2352
+ this.clerkjs.openWaitlist(props);
2353
+ } else {
2354
+ this.preOpenWaitlist = props;
2355
+ }
2356
+ };
2357
+ this.closeWaitlist = () => {
2358
+ if (this.clerkjs && this.loaded) {
2359
+ this.clerkjs.closeWaitlist();
2360
+ } else {
2361
+ this.preOpenWaitlist = null;
2362
+ }
2363
+ };
2364
+ this.openSignUp = (props) => {
2365
+ if (this.clerkjs && this.loaded) {
2366
+ this.clerkjs.openSignUp(props);
2367
+ } else {
2368
+ this.preopenSignUp = props;
2369
+ }
2370
+ };
2371
+ this.closeSignUp = () => {
2372
+ if (this.clerkjs && this.loaded) {
2373
+ this.clerkjs.closeSignUp();
2374
+ } else {
2375
+ this.preopenSignUp = null;
2376
+ }
2377
+ };
2378
+ this.mountSignIn = (node, props) => {
2379
+ if (this.clerkjs && this.loaded) {
2380
+ this.clerkjs.mountSignIn(node, props);
2381
+ } else {
2382
+ this.premountSignInNodes.set(node, props);
2383
+ }
2384
+ };
2385
+ this.unmountSignIn = (node) => {
2386
+ if (this.clerkjs && this.loaded) {
2387
+ this.clerkjs.unmountSignIn(node);
2388
+ } else {
2389
+ this.premountSignInNodes.delete(node);
2390
+ }
2391
+ };
2392
+ this.mountSignUp = (node, props) => {
2393
+ if (this.clerkjs && this.loaded) {
2394
+ this.clerkjs.mountSignUp(node, props);
2395
+ } else {
2396
+ this.premountSignUpNodes.set(node, props);
2397
+ }
2398
+ };
2399
+ this.unmountSignUp = (node) => {
2400
+ if (this.clerkjs && this.loaded) {
2401
+ this.clerkjs.unmountSignUp(node);
2402
+ } else {
2403
+ this.premountSignUpNodes.delete(node);
2404
+ }
2405
+ };
2406
+ this.mountUserAvatar = (node, props) => {
2407
+ if (this.clerkjs && this.loaded) {
2408
+ this.clerkjs.mountUserAvatar(node, props);
2409
+ } else {
2410
+ this.premountUserAvatarNodes.set(node, props);
2411
+ }
2412
+ };
2413
+ this.unmountUserAvatar = (node) => {
2414
+ if (this.clerkjs && this.loaded) {
2415
+ this.clerkjs.unmountUserAvatar(node);
2416
+ } else {
2417
+ this.premountUserAvatarNodes.delete(node);
2418
+ }
2419
+ };
2420
+ this.mountUserProfile = (node, props) => {
2421
+ if (this.clerkjs && this.loaded) {
2422
+ this.clerkjs.mountUserProfile(node, props);
2423
+ } else {
2424
+ this.premountUserProfileNodes.set(node, props);
2425
+ }
2426
+ };
2427
+ this.unmountUserProfile = (node) => {
2428
+ if (this.clerkjs && this.loaded) {
2429
+ this.clerkjs.unmountUserProfile(node);
2430
+ } else {
2431
+ this.premountUserProfileNodes.delete(node);
2432
+ }
2433
+ };
2434
+ this.mountOrganizationProfile = (node, props) => {
2435
+ if (this.clerkjs && this.loaded) {
2436
+ this.clerkjs.mountOrganizationProfile(node, props);
2437
+ } else {
2438
+ this.premountOrganizationProfileNodes.set(node, props);
2439
+ }
2440
+ };
2441
+ this.unmountOrganizationProfile = (node) => {
2442
+ if (this.clerkjs && this.loaded) {
2443
+ this.clerkjs.unmountOrganizationProfile(node);
2444
+ } else {
2445
+ this.premountOrganizationProfileNodes.delete(node);
2446
+ }
2447
+ };
2448
+ this.mountCreateOrganization = (node, props) => {
2449
+ if (this.clerkjs && this.loaded) {
2450
+ this.clerkjs.mountCreateOrganization(node, props);
2451
+ } else {
2452
+ this.premountCreateOrganizationNodes.set(node, props);
2453
+ }
2454
+ };
2455
+ this.unmountCreateOrganization = (node) => {
2456
+ if (this.clerkjs && this.loaded) {
2457
+ this.clerkjs.unmountCreateOrganization(node);
2458
+ } else {
2459
+ this.premountCreateOrganizationNodes.delete(node);
2460
+ }
2461
+ };
2462
+ this.mountOrganizationSwitcher = (node, props) => {
2463
+ if (this.clerkjs && this.loaded) {
2464
+ this.clerkjs.mountOrganizationSwitcher(node, props);
2465
+ } else {
2466
+ this.premountOrganizationSwitcherNodes.set(node, props);
2467
+ }
2468
+ };
2469
+ this.unmountOrganizationSwitcher = (node) => {
2470
+ if (this.clerkjs && this.loaded) {
2471
+ this.clerkjs.unmountOrganizationSwitcher(node);
2472
+ } else {
2473
+ this.premountOrganizationSwitcherNodes.delete(node);
2474
+ }
2475
+ };
2476
+ this.__experimental_prefetchOrganizationSwitcher = () => {
2477
+ const callback = () => {
2478
+ var _a;
2479
+ return (_a = this.clerkjs) == null ? void 0 : _a.__experimental_prefetchOrganizationSwitcher();
2480
+ };
2481
+ if (this.clerkjs && this.loaded) {
2482
+ void callback();
2483
+ } else {
2484
+ this.premountMethodCalls.set("__experimental_prefetchOrganizationSwitcher", callback);
2485
+ }
2486
+ };
2487
+ this.mountOrganizationList = (node, props) => {
2488
+ if (this.clerkjs && this.loaded) {
2489
+ this.clerkjs.mountOrganizationList(node, props);
2490
+ } else {
2491
+ this.premountOrganizationListNodes.set(node, props);
2492
+ }
2493
+ };
2494
+ this.unmountOrganizationList = (node) => {
2495
+ if (this.clerkjs && this.loaded) {
2496
+ this.clerkjs.unmountOrganizationList(node);
2497
+ } else {
2498
+ this.premountOrganizationListNodes.delete(node);
2499
+ }
2500
+ };
2501
+ this.mountUserButton = (node, userButtonProps) => {
2502
+ if (this.clerkjs && this.loaded) {
2503
+ this.clerkjs.mountUserButton(node, userButtonProps);
2504
+ } else {
2505
+ this.premountUserButtonNodes.set(node, userButtonProps);
2506
+ }
2507
+ };
2508
+ this.unmountUserButton = (node) => {
2509
+ if (this.clerkjs && this.loaded) {
2510
+ this.clerkjs.unmountUserButton(node);
2511
+ } else {
2512
+ this.premountUserButtonNodes.delete(node);
2513
+ }
2514
+ };
2515
+ this.mountWaitlist = (node, props) => {
2516
+ if (this.clerkjs && this.loaded) {
2517
+ this.clerkjs.mountWaitlist(node, props);
2518
+ } else {
2519
+ this.premountWaitlistNodes.set(node, props);
2520
+ }
2521
+ };
2522
+ this.unmountWaitlist = (node) => {
2523
+ if (this.clerkjs && this.loaded) {
2524
+ this.clerkjs.unmountWaitlist(node);
2525
+ } else {
2526
+ this.premountWaitlistNodes.delete(node);
2527
+ }
2528
+ };
2529
+ this.mountPricingTable = (node, props) => {
2530
+ if (this.clerkjs && this.loaded) {
2531
+ this.clerkjs.mountPricingTable(node, props);
2532
+ } else {
2533
+ this.premountPricingTableNodes.set(node, props);
2534
+ }
2535
+ };
2536
+ this.unmountPricingTable = (node) => {
2537
+ if (this.clerkjs && this.loaded) {
2538
+ this.clerkjs.unmountPricingTable(node);
2539
+ } else {
2540
+ this.premountPricingTableNodes.delete(node);
2541
+ }
2542
+ };
2543
+ this.mountApiKeys = (node, props) => {
2544
+ if (this.clerkjs && this.loaded) {
2545
+ this.clerkjs.mountApiKeys(node, props);
2546
+ } else {
2547
+ this.premountApiKeysNodes.set(node, props);
2548
+ }
2549
+ };
2550
+ this.unmountApiKeys = (node) => {
2551
+ if (this.clerkjs && this.loaded) {
2552
+ this.clerkjs.unmountApiKeys(node);
2553
+ } else {
2554
+ this.premountApiKeysNodes.delete(node);
2555
+ }
2556
+ };
2557
+ this.__internal_mountOAuthConsent = (node, props) => {
2558
+ if (this.clerkjs && this.loaded) {
2559
+ this.clerkjs.__internal_mountOAuthConsent(node, props);
2560
+ } else {
2561
+ this.premountOAuthConsentNodes.set(node, props);
2562
+ }
2563
+ };
2564
+ this.__internal_unmountOAuthConsent = (node) => {
2565
+ if (this.clerkjs && this.loaded) {
2566
+ this.clerkjs.__internal_unmountOAuthConsent(node);
2567
+ } else {
2568
+ this.premountOAuthConsentNodes.delete(node);
2569
+ }
2570
+ };
2571
+ this.mountTaskChooseOrganization = (node, props) => {
2572
+ if (this.clerkjs && this.loaded) {
2573
+ this.clerkjs.mountTaskChooseOrganization(node, props);
2574
+ } else {
2575
+ this.premountTaskChooseOrganizationNodes.set(node, props);
2576
+ }
2577
+ };
2578
+ this.unmountTaskChooseOrganization = (node) => {
2579
+ if (this.clerkjs && this.loaded) {
2580
+ this.clerkjs.unmountTaskChooseOrganization(node);
2581
+ } else {
2582
+ this.premountTaskChooseOrganizationNodes.delete(node);
2583
+ }
2584
+ };
2585
+ this.addListener = (listener) => {
2586
+ if (this.clerkjs) {
2587
+ return this.clerkjs.addListener(listener);
2588
+ } else {
2589
+ const unsubscribe = () => {
2590
+ var _a;
2591
+ const listenerHandlers = this.premountAddListenerCalls.get(listener);
2592
+ if (listenerHandlers) {
2593
+ (_a = listenerHandlers.nativeUnsubscribe) == null ? void 0 : _a.call(listenerHandlers);
2594
+ this.premountAddListenerCalls.delete(listener);
2595
+ }
2596
+ };
2597
+ this.premountAddListenerCalls.set(listener, { unsubscribe, nativeUnsubscribe: void 0 });
2598
+ return unsubscribe;
2599
+ }
2600
+ };
2601
+ this.navigate = (to) => {
2602
+ const callback = () => {
2603
+ var _a;
2604
+ return (_a = this.clerkjs) == null ? void 0 : _a.navigate(to);
2605
+ };
2606
+ if (this.clerkjs && this.loaded) {
2607
+ void callback();
2608
+ } else {
2609
+ this.premountMethodCalls.set("navigate", callback);
2610
+ }
2611
+ };
2612
+ this.redirectWithAuth = async (...args) => {
2613
+ const callback = () => {
2614
+ var _a;
2615
+ return (_a = this.clerkjs) == null ? void 0 : _a.redirectWithAuth(...args);
2616
+ };
2617
+ if (this.clerkjs && this.loaded) {
2618
+ return callback();
2619
+ } else {
2620
+ this.premountMethodCalls.set("redirectWithAuth", callback);
2621
+ return;
2622
+ }
2623
+ };
2624
+ this.redirectToSignIn = async (opts) => {
2625
+ const callback = () => {
2626
+ var _a;
2627
+ return (_a = this.clerkjs) == null ? void 0 : _a.redirectToSignIn(opts);
2628
+ };
2629
+ if (this.clerkjs && this.loaded) {
2630
+ return callback();
2631
+ } else {
2632
+ this.premountMethodCalls.set("redirectToSignIn", callback);
2633
+ return;
2634
+ }
2635
+ };
2636
+ this.redirectToSignUp = async (opts) => {
2637
+ const callback = () => {
2638
+ var _a;
2639
+ return (_a = this.clerkjs) == null ? void 0 : _a.redirectToSignUp(opts);
2640
+ };
2641
+ if (this.clerkjs && this.loaded) {
2642
+ return callback();
2643
+ } else {
2644
+ this.premountMethodCalls.set("redirectToSignUp", callback);
2645
+ return;
2646
+ }
2647
+ };
2648
+ this.redirectToUserProfile = async () => {
2649
+ const callback = () => {
2650
+ var _a;
2651
+ return (_a = this.clerkjs) == null ? void 0 : _a.redirectToUserProfile();
2652
+ };
2653
+ if (this.clerkjs && this.loaded) {
2654
+ return callback();
2655
+ } else {
2656
+ this.premountMethodCalls.set("redirectToUserProfile", callback);
2657
+ return;
2658
+ }
2659
+ };
2660
+ this.redirectToAfterSignUp = () => {
2661
+ const callback = () => {
2662
+ var _a;
2663
+ return (_a = this.clerkjs) == null ? void 0 : _a.redirectToAfterSignUp();
2664
+ };
2665
+ if (this.clerkjs && this.loaded) {
2666
+ return callback();
2667
+ } else {
2668
+ this.premountMethodCalls.set("redirectToAfterSignUp", callback);
2669
+ }
2670
+ };
2671
+ this.redirectToAfterSignIn = () => {
2672
+ const callback = () => {
2673
+ var _a;
2674
+ return (_a = this.clerkjs) == null ? void 0 : _a.redirectToAfterSignIn();
2675
+ };
2676
+ if (this.clerkjs && this.loaded) {
2677
+ callback();
2678
+ } else {
2679
+ this.premountMethodCalls.set("redirectToAfterSignIn", callback);
2680
+ }
2681
+ };
2682
+ this.redirectToAfterSignOut = () => {
2683
+ const callback = () => {
2684
+ var _a;
2685
+ return (_a = this.clerkjs) == null ? void 0 : _a.redirectToAfterSignOut();
2686
+ };
2687
+ if (this.clerkjs && this.loaded) {
2688
+ callback();
2689
+ } else {
2690
+ this.premountMethodCalls.set("redirectToAfterSignOut", callback);
2691
+ }
2692
+ };
2693
+ this.redirectToOrganizationProfile = async () => {
2694
+ const callback = () => {
2695
+ var _a;
2696
+ return (_a = this.clerkjs) == null ? void 0 : _a.redirectToOrganizationProfile();
2697
+ };
2698
+ if (this.clerkjs && this.loaded) {
2699
+ return callback();
2700
+ } else {
2701
+ this.premountMethodCalls.set("redirectToOrganizationProfile", callback);
2702
+ return;
2703
+ }
2704
+ };
2705
+ this.redirectToCreateOrganization = async () => {
2706
+ const callback = () => {
2707
+ var _a;
2708
+ return (_a = this.clerkjs) == null ? void 0 : _a.redirectToCreateOrganization();
2709
+ };
2710
+ if (this.clerkjs && this.loaded) {
2711
+ return callback();
2712
+ } else {
2713
+ this.premountMethodCalls.set("redirectToCreateOrganization", callback);
2714
+ return;
2715
+ }
2716
+ };
2717
+ this.redirectToWaitlist = async () => {
2718
+ const callback = () => {
2719
+ var _a;
2720
+ return (_a = this.clerkjs) == null ? void 0 : _a.redirectToWaitlist();
2721
+ };
2722
+ if (this.clerkjs && this.loaded) {
2723
+ return callback();
2724
+ } else {
2725
+ this.premountMethodCalls.set("redirectToWaitlist", callback);
2726
+ return;
2727
+ }
2728
+ };
2729
+ this.redirectToTasks = async (opts) => {
2730
+ const callback = () => {
2731
+ var _a;
2732
+ return (_a = this.clerkjs) == null ? void 0 : _a.redirectToTasks(opts);
2733
+ };
2734
+ if (this.clerkjs && this.loaded) {
2735
+ return callback();
2736
+ } else {
2737
+ this.premountMethodCalls.set("redirectToTasks", callback);
2738
+ return;
2739
+ }
2740
+ };
2741
+ this.handleRedirectCallback = async (params) => {
2742
+ var _a;
2743
+ const callback = () => {
2744
+ var _a2;
2745
+ return (_a2 = this.clerkjs) == null ? void 0 : _a2.handleRedirectCallback(params);
2746
+ };
2747
+ if (this.clerkjs && this.loaded) {
2748
+ void ((_a = callback()) == null ? void 0 : _a.catch(() => {
2749
+ }));
2750
+ } else {
2751
+ this.premountMethodCalls.set("handleRedirectCallback", callback);
2752
+ }
2753
+ };
2754
+ this.handleGoogleOneTapCallback = async (signInOrUp, params) => {
2755
+ var _a;
2756
+ const callback = () => {
2757
+ var _a2;
2758
+ return (_a2 = this.clerkjs) == null ? void 0 : _a2.handleGoogleOneTapCallback(signInOrUp, params);
2759
+ };
2760
+ if (this.clerkjs && this.loaded) {
2761
+ void ((_a = callback()) == null ? void 0 : _a.catch(() => {
2762
+ }));
2763
+ } else {
2764
+ this.premountMethodCalls.set("handleGoogleOneTapCallback", callback);
2765
+ }
2766
+ };
2767
+ this.handleEmailLinkVerification = async (params) => {
2768
+ const callback = () => {
2769
+ var _a;
2770
+ return (_a = this.clerkjs) == null ? void 0 : _a.handleEmailLinkVerification(params);
2771
+ };
2772
+ if (this.clerkjs && this.loaded) {
2773
+ return callback();
2774
+ } else {
2775
+ this.premountMethodCalls.set("handleEmailLinkVerification", callback);
2776
+ }
2777
+ };
2778
+ this.authenticateWithMetamask = async (params) => {
2779
+ const callback = () => {
2780
+ var _a;
2781
+ return (_a = this.clerkjs) == null ? void 0 : _a.authenticateWithMetamask(params);
2782
+ };
2783
+ if (this.clerkjs && this.loaded) {
2784
+ return callback();
2785
+ } else {
2786
+ this.premountMethodCalls.set("authenticateWithMetamask", callback);
2787
+ }
2788
+ };
2789
+ this.authenticateWithCoinbaseWallet = async (params) => {
2790
+ const callback = () => {
2791
+ var _a;
2792
+ return (_a = this.clerkjs) == null ? void 0 : _a.authenticateWithCoinbaseWallet(params);
2793
+ };
2794
+ if (this.clerkjs && this.loaded) {
2795
+ return callback();
2796
+ } else {
2797
+ this.premountMethodCalls.set("authenticateWithCoinbaseWallet", callback);
2798
+ }
2799
+ };
2800
+ this.authenticateWithBase = async (params) => {
2801
+ const callback = () => {
2802
+ var _a;
2803
+ return (_a = this.clerkjs) == null ? void 0 : _a.authenticateWithBase(params);
2804
+ };
2805
+ if (this.clerkjs && this.loaded) {
2806
+ return callback();
2807
+ } else {
2808
+ this.premountMethodCalls.set("authenticateWithBase", callback);
2809
+ }
2810
+ };
2811
+ this.authenticateWithOKXWallet = async (params) => {
2812
+ const callback = () => {
2813
+ var _a;
2814
+ return (_a = this.clerkjs) == null ? void 0 : _a.authenticateWithOKXWallet(params);
2815
+ };
2816
+ if (this.clerkjs && this.loaded) {
2817
+ return callback();
2818
+ } else {
2819
+ this.premountMethodCalls.set("authenticateWithOKXWallet", callback);
2820
+ }
2821
+ };
2822
+ this.authenticateWithWeb3 = async (params) => {
2823
+ const callback = () => {
2824
+ var _a;
2825
+ return (_a = this.clerkjs) == null ? void 0 : _a.authenticateWithWeb3(params);
2826
+ };
2827
+ if (this.clerkjs && this.loaded) {
2828
+ return callback();
2829
+ } else {
2830
+ this.premountMethodCalls.set("authenticateWithWeb3", callback);
2831
+ }
2832
+ };
2833
+ this.authenticateWithGoogleOneTap = async (params) => {
2834
+ const clerkjs = await __privateMethod(this, _IsomorphicClerk_instances, waitForClerkJS_fn).call(this);
2835
+ return clerkjs.authenticateWithGoogleOneTap(params);
2836
+ };
2837
+ this.__internal_loadStripeJs = async () => {
2838
+ const clerkjs = await __privateMethod(this, _IsomorphicClerk_instances, waitForClerkJS_fn).call(this);
2839
+ return clerkjs.__internal_loadStripeJs();
2840
+ };
2841
+ this.createOrganization = async (params) => {
2842
+ const callback = () => {
2843
+ var _a;
2844
+ return (_a = this.clerkjs) == null ? void 0 : _a.createOrganization(params);
2845
+ };
2846
+ if (this.clerkjs && this.loaded) {
2847
+ return callback();
2848
+ } else {
2849
+ this.premountMethodCalls.set("createOrganization", callback);
2850
+ }
2851
+ };
2852
+ this.getOrganization = async (organizationId) => {
2853
+ const callback = () => {
2854
+ var _a;
2855
+ return (_a = this.clerkjs) == null ? void 0 : _a.getOrganization(organizationId);
2856
+ };
2857
+ if (this.clerkjs && this.loaded) {
2858
+ return callback();
2859
+ } else {
2860
+ this.premountMethodCalls.set("getOrganization", callback);
2861
+ }
2862
+ };
2863
+ this.joinWaitlist = async (params) => {
2864
+ const callback = () => {
2865
+ var _a;
2866
+ return (_a = this.clerkjs) == null ? void 0 : _a.joinWaitlist(params);
2867
+ };
2868
+ if (this.clerkjs && this.loaded) {
2869
+ return callback();
2870
+ } else {
2871
+ this.premountMethodCalls.set("joinWaitlist", callback);
2872
+ }
2873
+ };
2874
+ this.signOut = async (...args) => {
2875
+ const callback = () => {
2876
+ var _a;
2877
+ return (_a = this.clerkjs) == null ? void 0 : _a.signOut(...args);
2878
+ };
2879
+ if (this.clerkjs && this.loaded) {
2880
+ return callback();
2881
+ } else {
2882
+ this.premountMethodCalls.set("signOut", callback);
2883
+ }
2884
+ };
2885
+ const { Clerk = null, publishableKey } = options || {};
2886
+ __privateSet(this, _publishableKey, publishableKey);
2887
+ __privateSet(this, _proxyUrl, options == null ? void 0 : options.proxyUrl);
2888
+ __privateSet(this, _domain, options == null ? void 0 : options.domain);
2889
+ this.options = options;
2890
+ this.Clerk = Clerk;
2891
+ this.mode = (0, import_browser2.inBrowser)() ? "browser" : "server";
2892
+ __privateSet(this, _stateProxy, new StateProxy(this));
2893
+ if (!this.options.sdkMetadata) {
2894
+ this.options.sdkMetadata = SDK_METADATA;
2895
+ }
2896
+ __privateGet(this, _eventBus).emit(import_clerkEventBus.clerkEvents.Status, "loading");
2897
+ __privateGet(this, _eventBus).prioritizedOn(import_clerkEventBus.clerkEvents.Status, (status) => __privateSet(this, _status, status));
2898
+ if (__privateGet(this, _publishableKey)) {
2899
+ void this.loadClerkEntryChunks();
2900
+ }
2901
+ }
2902
+ get publishableKey() {
2903
+ return __privateGet(this, _publishableKey);
2904
+ }
2905
+ get loaded() {
2906
+ var _a;
2907
+ return ((_a = this.clerkjs) == null ? void 0 : _a.loaded) || false;
2908
+ }
2909
+ get status() {
2910
+ var _a;
2911
+ if (!this.clerkjs) {
2912
+ return __privateGet(this, _status);
2913
+ }
2914
+ return ((_a = this.clerkjs) == null ? void 0 : _a.status) || /**
2915
+ * Support older clerk-js versions.
2916
+ * If clerk-js is available but `.status` is missing it we need to fallback to `.loaded`.
2917
+ * Since "degraded" an "error" did not exist before,
2918
+ * map "loaded" to "ready" and "not loaded" to "loading".
2919
+ */
2920
+ (this.clerkjs.loaded ? "ready" : "loading");
2921
+ }
2922
+ static getOrCreateInstance(options) {
2923
+ if (!(0, import_browser2.inBrowser)() || !__privateGet(this, _instance) || options.Clerk && __privateGet(this, _instance).Clerk !== options.Clerk || // Allow hot swapping PKs on the client
2924
+ __privateGet(this, _instance).publishableKey !== options.publishableKey) {
2925
+ __privateSet(this, _instance, new _IsomorphicClerk(options));
2926
+ }
2927
+ return __privateGet(this, _instance);
2928
+ }
2929
+ static clearInstance() {
2930
+ __privateSet(this, _instance, null);
2931
+ }
2932
+ get domain() {
2933
+ if (typeof window !== "undefined" && window.location) {
2934
+ return (0, import_utils10.handleValueOrFn)(__privateGet(this, _domain), new URL(window.location.href), "");
2935
+ }
2936
+ if (typeof __privateGet(this, _domain) === "function") {
2937
+ return errorThrower.throw(unsupportedNonBrowserDomainOrProxyUrlFunction);
2938
+ }
2939
+ return __privateGet(this, _domain) || "";
2940
+ }
2941
+ get proxyUrl() {
2942
+ if (typeof window !== "undefined" && window.location) {
2943
+ return (0, import_utils10.handleValueOrFn)(__privateGet(this, _proxyUrl), new URL(window.location.href), "");
2944
+ }
2945
+ if (typeof __privateGet(this, _proxyUrl) === "function") {
2946
+ return errorThrower.throw(unsupportedNonBrowserDomainOrProxyUrlFunction);
2947
+ }
2948
+ return __privateGet(this, _proxyUrl) || "";
2949
+ }
2950
+ /**
2951
+ * Accesses private options from the `Clerk` instance and defaults to
2952
+ * `IsomorphicClerk` options when in SSR context.
2953
+ * @internal
2954
+ */
2955
+ __internal_getOption(key) {
2956
+ var _a, _b;
2957
+ return ((_a = this.clerkjs) == null ? void 0 : _a.__internal_getOption) ? (_b = this.clerkjs) == null ? void 0 : _b.__internal_getOption(key) : this.options[key];
2958
+ }
2959
+ get sdkMetadata() {
2960
+ var _a;
2961
+ return ((_a = this.clerkjs) == null ? void 0 : _a.sdkMetadata) || this.options.sdkMetadata || void 0;
2962
+ }
2963
+ get instanceType() {
2964
+ var _a;
2965
+ return (_a = this.clerkjs) == null ? void 0 : _a.instanceType;
2966
+ }
2967
+ get frontendApi() {
2968
+ var _a;
2969
+ return ((_a = this.clerkjs) == null ? void 0 : _a.frontendApi) || "";
2970
+ }
2971
+ get isStandardBrowser() {
2972
+ var _a;
2973
+ return ((_a = this.clerkjs) == null ? void 0 : _a.isStandardBrowser) || this.options.standardBrowser || false;
2974
+ }
2975
+ get __internal_queryClient() {
2976
+ var _a;
2977
+ return (_a = this.clerkjs) == null ? void 0 : _a.__internal_queryClient;
2978
+ }
2979
+ get isSatellite() {
2980
+ if (typeof window !== "undefined" && window.location) {
2981
+ return (0, import_utils10.handleValueOrFn)(this.options.isSatellite, new URL(window.location.href), false);
2982
+ }
2983
+ if (typeof this.options.isSatellite === "function") {
2984
+ return errorThrower.throw(unsupportedNonBrowserDomainOrProxyUrlFunction);
2985
+ }
2986
+ return false;
2987
+ }
2988
+ async loadClerkEntryChunks() {
2989
+ if (this.mode !== "browser" || this.loaded) {
2990
+ return;
2991
+ }
2992
+ if (typeof window !== "undefined") {
2993
+ window.__clerk_publishable_key = __privateGet(this, _publishableKey);
2994
+ window.__clerk_proxy_url = this.proxyUrl;
2995
+ window.__clerk_domain = this.domain;
2996
+ }
2997
+ try {
2998
+ const clerkPromise = this.loadClerkJsEntryChunk();
2999
+ const clerkUiCtor = this.loadClerkUiEntryChunk();
3000
+ await clerkPromise;
3001
+ if (!global.Clerk) {
3002
+ throw new Error("Failed to download latest ClerkJS. Contact support@clerk.com.");
3003
+ }
3004
+ if (!global.Clerk.loaded) {
3005
+ this.beforeLoad(global.Clerk);
3006
+ await global.Clerk.load({ ...this.options, clerkUiCtor });
3007
+ }
3008
+ if (global.Clerk.loaded) {
3009
+ this.replayInterceptedInvocations(global.Clerk);
3010
+ }
3011
+ } catch (err) {
3012
+ const error = err;
3013
+ __privateGet(this, _eventBus).emit(import_clerkEventBus.clerkEvents.Status, "error");
3014
+ console.error(error.stack || error.message || error);
3015
+ return;
3016
+ }
3017
+ }
3018
+ async loadClerkJsEntryChunk() {
3019
+ if (!this.Clerk && !__BUILD_DISABLE_RHC__) {
3020
+ await (0, import_loadClerkJsScript.loadClerkJsScript)({
3021
+ ...this.options,
3022
+ publishableKey: __privateGet(this, _publishableKey),
3023
+ proxyUrl: this.proxyUrl,
3024
+ domain: this.domain,
3025
+ nonce: this.options.nonce
3026
+ });
3027
+ }
3028
+ if (this.Clerk) {
3029
+ global.Clerk = isConstructor(this.Clerk) ? new this.Clerk(__privateGet(this, _publishableKey), { proxyUrl: this.proxyUrl, domain: this.domain }) : this.Clerk;
3030
+ }
3031
+ return global.Clerk;
3032
+ }
3033
+ async loadClerkUiEntryChunk() {
3034
+ await (0, import_loadClerkJsScript.loadClerkUiScript)({
3035
+ ...this.options,
3036
+ publishableKey: __privateGet(this, _publishableKey),
3037
+ proxyUrl: this.proxyUrl,
3038
+ domain: this.domain,
3039
+ nonce: this.options.nonce
3040
+ });
3041
+ if (!global.__unstable_ClerkUiCtor) {
3042
+ throw new Error("Failed to download latest Clerk UI. Contact support@clerk.com.");
3043
+ }
3044
+ return global.__unstable_ClerkUiCtor;
3045
+ }
3046
+ get version() {
3047
+ var _a;
3048
+ return (_a = this.clerkjs) == null ? void 0 : _a.version;
3049
+ }
3050
+ get client() {
3051
+ if (this.clerkjs) {
3052
+ return this.clerkjs.client;
3053
+ } else {
3054
+ return void 0;
3055
+ }
3056
+ }
3057
+ get session() {
3058
+ if (this.clerkjs) {
3059
+ return this.clerkjs.session;
3060
+ } else {
3061
+ return void 0;
3062
+ }
3063
+ }
3064
+ get user() {
3065
+ if (this.clerkjs) {
3066
+ return this.clerkjs.user;
3067
+ } else {
3068
+ return void 0;
3069
+ }
3070
+ }
3071
+ get organization() {
3072
+ if (this.clerkjs) {
3073
+ return this.clerkjs.organization;
3074
+ } else {
3075
+ return void 0;
3076
+ }
3077
+ }
3078
+ get telemetry() {
3079
+ if (this.clerkjs) {
3080
+ return this.clerkjs.telemetry;
3081
+ } else {
3082
+ return void 0;
3083
+ }
3084
+ }
3085
+ get __unstable__environment() {
3086
+ if (this.clerkjs) {
3087
+ return this.clerkjs.__unstable__environment;
3088
+ } else {
3089
+ return void 0;
3090
+ }
3091
+ }
3092
+ get isSignedIn() {
3093
+ if (this.clerkjs) {
3094
+ return this.clerkjs.isSignedIn;
3095
+ } else {
3096
+ return false;
3097
+ }
3098
+ }
3099
+ get billing() {
3100
+ var _a;
3101
+ return (_a = this.clerkjs) == null ? void 0 : _a.billing;
3102
+ }
3103
+ get __internal_state() {
3104
+ return this.loaded && this.clerkjs ? this.clerkjs.__internal_state : __privateGet(this, _stateProxy);
3105
+ }
3106
+ get apiKeys() {
3107
+ var _a;
3108
+ return (_a = this.clerkjs) == null ? void 0 : _a.apiKeys;
3109
+ }
3110
+ __unstable__setEnvironment(...args) {
3111
+ if (this.clerkjs && "__unstable__setEnvironment" in this.clerkjs) {
3112
+ this.clerkjs.__unstable__setEnvironment(args);
3113
+ } else {
3114
+ return void 0;
3115
+ }
3116
+ }
3117
+ };
3118
+ _status = new WeakMap();
3119
+ _domain = new WeakMap();
3120
+ _proxyUrl = new WeakMap();
3121
+ _publishableKey = new WeakMap();
3122
+ _eventBus = new WeakMap();
3123
+ _stateProxy = new WeakMap();
3124
+ _instance = new WeakMap();
3125
+ _IsomorphicClerk_instances = new WeakSet();
3126
+ waitForClerkJS_fn = function() {
3127
+ return new Promise((resolve) => {
3128
+ this.addOnLoaded(() => resolve(this.clerkjs));
3129
+ });
3130
+ };
3131
+ __privateAdd(_IsomorphicClerk, _instance);
3132
+ var IsomorphicClerk = _IsomorphicClerk;
3133
+
3134
+ // src/contexts/ClerkContextProvider.tsx
3135
+ function ClerkContextProvider(props) {
3136
+ const { isomorphicClerkOptions, initialState, children } = props;
3137
+ const { isomorphicClerk: clerk, clerkStatus } = useLoadedIsomorphicClerk(isomorphicClerkOptions);
3138
+ const [state, setState] = import_react26.default.useState({
3139
+ client: clerk.client,
3140
+ session: clerk.session,
3141
+ user: clerk.user,
3142
+ organization: clerk.organization
3143
+ });
3144
+ import_react26.default.useEffect(() => {
3145
+ return clerk.addListener((e) => setState({ ...e }));
3146
+ }, []);
3147
+ const derivedState = (0, import_deriveState.deriveState)(clerk.loaded, state, initialState);
3148
+ const clerkCtx = import_react26.default.useMemo(
3149
+ () => ({ value: clerk }),
3150
+ [
3151
+ // Only update the clerk reference on status change
3152
+ clerkStatus
3153
+ ]
3154
+ );
3155
+ const clientCtx = import_react26.default.useMemo(() => ({ value: state.client }), [state.client]);
3156
+ const {
3157
+ sessionId,
3158
+ sessionStatus,
3159
+ sessionClaims,
3160
+ session,
3161
+ userId,
3162
+ user,
3163
+ orgId,
3164
+ actor,
3165
+ organization,
3166
+ orgRole,
3167
+ orgSlug,
3168
+ orgPermissions,
3169
+ factorVerificationAge
3170
+ } = derivedState;
3171
+ const authCtx = import_react26.default.useMemo(() => {
3172
+ const value = {
3173
+ sessionId,
3174
+ sessionStatus,
3175
+ sessionClaims,
3176
+ userId,
3177
+ actor,
3178
+ orgId,
3179
+ orgRole,
3180
+ orgSlug,
3181
+ orgPermissions,
3182
+ factorVerificationAge
3183
+ };
3184
+ return { value };
3185
+ }, [sessionId, sessionStatus, userId, actor, orgId, orgRole, orgSlug, factorVerificationAge, sessionClaims == null ? void 0 : sessionClaims.__raw]);
3186
+ const sessionCtx = import_react26.default.useMemo(() => ({ value: session }), [sessionId, session]);
3187
+ const userCtx = import_react26.default.useMemo(() => ({ value: user }), [userId, user]);
3188
+ const organizationCtx = import_react26.default.useMemo(() => {
3189
+ const value = {
3190
+ organization
3191
+ };
3192
+ return { value };
3193
+ }, [orgId, organization]);
3194
+ return (
3195
+ // @ts-expect-error value passed is of type IsomorphicClerk where the context expects LoadedClerk
3196
+ /* @__PURE__ */ import_react26.default.createElement(IsomorphicClerkContext.Provider, { value: clerkCtx }, /* @__PURE__ */ import_react26.default.createElement(import_react25.ClientContext.Provider, { value: clientCtx }, /* @__PURE__ */ import_react26.default.createElement(import_react25.SessionContext.Provider, { value: sessionCtx }, /* @__PURE__ */ import_react26.default.createElement(import_react25.OrganizationProvider, { ...organizationCtx.value }, /* @__PURE__ */ import_react26.default.createElement(AuthContext.Provider, { value: authCtx }, /* @__PURE__ */ import_react26.default.createElement(import_react25.UserContext.Provider, { value: userCtx }, /* @__PURE__ */ import_react26.default.createElement(
3197
+ import_react25.__experimental_CheckoutProvider,
3198
+ {
3199
+ value: void 0
3200
+ },
3201
+ children
3202
+ )))))))
3203
+ );
3204
+ }
3205
+ var useLoadedIsomorphicClerk = (options) => {
3206
+ const isomorphicClerkRef = import_react26.default.useRef(IsomorphicClerk.getOrCreateInstance(options));
3207
+ const [clerkStatus, setClerkStatus] = import_react26.default.useState(isomorphicClerkRef.current.status);
3208
+ import_react26.default.useEffect(() => {
3209
+ void isomorphicClerkRef.current.__unstable__updateProps({ appearance: options.appearance });
3210
+ }, [options.appearance]);
3211
+ import_react26.default.useEffect(() => {
3212
+ void isomorphicClerkRef.current.__unstable__updateProps({ options });
3213
+ }, [options.localization]);
3214
+ import_react26.default.useEffect(() => {
3215
+ isomorphicClerkRef.current.on("status", setClerkStatus);
3216
+ return () => {
3217
+ if (isomorphicClerkRef.current) {
3218
+ isomorphicClerkRef.current.off("status", setClerkStatus);
3219
+ }
3220
+ IsomorphicClerk.clearInstance();
3221
+ };
3222
+ }, []);
3223
+ return { isomorphicClerk: isomorphicClerkRef.current, clerkStatus };
3224
+ };
3225
+
3226
+ // src/contexts/ClerkProvider.tsx
3227
+ function ClerkProviderBase(props) {
3228
+ const { initialState, children, __internal_bypassMissingPublishableKey, ...restIsomorphicClerkOptions } = props;
3229
+ const { publishableKey = "", Clerk: userInitialisedClerk } = restIsomorphicClerkOptions;
3230
+ if (!userInitialisedClerk && !__internal_bypassMissingPublishableKey) {
3231
+ if (!publishableKey) {
3232
+ errorThrower.throwMissingPublishableKeyError();
3233
+ } else if (publishableKey && !(0, import_keys.isPublishableKey)(publishableKey)) {
3234
+ errorThrower.throwInvalidPublishableKeyError({ key: publishableKey });
3235
+ }
3236
+ }
3237
+ return /* @__PURE__ */ import_react27.default.createElement(
3238
+ ClerkContextProvider,
3239
+ {
3240
+ initialState,
3241
+ isomorphicClerkOptions: restIsomorphicClerkOptions
3242
+ },
3243
+ children
3244
+ );
3245
+ }
3246
+ var ClerkProvider = withMaxAllowedInstancesGuard(ClerkProviderBase, "ClerkProvider", multipleClerkProvidersError);
3247
+ ClerkProvider.displayName = "ClerkProvider";
3248
+
3249
+ // src/index.ts
3250
+ setErrorThrowerOptions({ packageName: "@clerk/react" });
3251
+ (0, import_loadClerkJsScript2.setClerkJsLoadingErrorPackageName)("@clerk/react");
3252
+ // Annotate the CommonJS export names for ESM import in node:
3253
+ 0 && (module.exports = {
3254
+ APIKeys,
3255
+ AuthenticateWithRedirectCallback,
3256
+ ClerkDegraded,
3257
+ ClerkFailed,
3258
+ ClerkLoaded,
3259
+ ClerkLoading,
3260
+ ClerkProvider,
3261
+ CreateOrganization,
3262
+ GoogleOneTap,
3263
+ OrganizationList,
3264
+ OrganizationProfile,
3265
+ OrganizationSwitcher,
3266
+ PricingTable,
3267
+ Protect,
3268
+ RedirectToCreateOrganization,
3269
+ RedirectToOrganizationProfile,
3270
+ RedirectToSignIn,
3271
+ RedirectToSignUp,
3272
+ RedirectToTasks,
3273
+ RedirectToUserProfile,
3274
+ SignIn,
3275
+ SignInButton,
3276
+ SignInWithMetamaskButton,
3277
+ SignOutButton,
3278
+ SignUp,
3279
+ SignUpButton,
3280
+ SignedIn,
3281
+ SignedOut,
3282
+ TaskChooseOrganization,
3283
+ UserAvatar,
3284
+ UserButton,
3285
+ UserProfile,
3286
+ Waitlist,
3287
+ __experimental_CheckoutProvider,
3288
+ __experimental_PaymentElement,
3289
+ __experimental_PaymentElementProvider,
3290
+ __experimental_useCheckout,
3291
+ __experimental_usePaymentElement,
3292
+ useAuth,
3293
+ useClerk,
3294
+ useEmailLink,
3295
+ useOrganization,
3296
+ useOrganizationList,
3297
+ useReverification,
3298
+ useSession,
3299
+ useSessionList,
3300
+ useSignIn,
3301
+ useSignUp,
3302
+ useUser
3303
+ });
3304
+ //# sourceMappingURL=index.js.map