@clerk/react 6.9.0 → 6.9.1-canary.v20260610190754

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 (75) hide show
  1. package/dist/ClerkProvider-9lxHp9j5.cjs +1623 -0
  2. package/dist/ClerkProvider-9lxHp9j5.cjs.map +1 -0
  3. package/dist/ClerkProvider-LQpPtmNL.mjs +1533 -0
  4. package/dist/ClerkProvider-LQpPtmNL.mjs.map +1 -0
  5. package/dist/errors.cjs +69 -0
  6. package/dist/errors.d.cts +2 -0
  7. package/dist/errors.d.mts +2 -1
  8. package/dist/errors.mjs +2 -29
  9. package/dist/experimental.cjs +270 -0
  10. package/dist/experimental.cjs.map +1 -0
  11. package/dist/{experimental.d.ts → experimental.d.cts} +18 -18
  12. package/dist/experimental.d.mts +18 -18
  13. package/dist/experimental.mjs +201 -165
  14. package/dist/experimental.mjs.map +1 -1
  15. package/dist/hooks-BiY5Zgpp.mjs +1369 -0
  16. package/dist/hooks-BiY5Zgpp.mjs.map +1 -0
  17. package/dist/hooks-CBghYU21.cjs +1606 -0
  18. package/dist/hooks-CBghYU21.cjs.map +1 -0
  19. package/dist/index.cjs +447 -0
  20. package/dist/index.cjs.map +1 -0
  21. package/dist/index.d.cts +345 -0
  22. package/dist/index.d.mts +183 -157
  23. package/dist/index.mjs +285 -380
  24. package/dist/index.mjs.map +1 -1
  25. package/dist/internal.cjs +107 -0
  26. package/dist/internal.cjs.map +1 -0
  27. package/dist/internal.d.cts +51 -0
  28. package/dist/internal.d.mts +24 -26
  29. package/dist/internal.mjs +39 -73
  30. package/dist/internal.mjs.map +1 -1
  31. package/dist/legacy.cjs +134 -0
  32. package/dist/legacy.cjs.map +1 -0
  33. package/dist/{legacy.d.ts → legacy.d.cts} +6 -3
  34. package/dist/legacy.d.mts +6 -3
  35. package/dist/legacy.mjs +126 -42
  36. package/dist/legacy.mjs.map +1 -1
  37. package/dist/types-Bwenmt7y.d.cts +10951 -0
  38. package/dist/types-CiIhevkA.d.mts +10951 -0
  39. package/dist/types.cjs +0 -0
  40. package/dist/types.d.cts +3 -0
  41. package/dist/types.d.mts +3 -109
  42. package/dist/types.mjs +1 -2
  43. package/dist/useAssertWrappedByClerkProvider-Cm0djUcB.cjs +52 -0
  44. package/dist/useAssertWrappedByClerkProvider-Cm0djUcB.cjs.map +1 -0
  45. package/dist/useAssertWrappedByClerkProvider-GaNwZpWo.mjs +29 -0
  46. package/dist/useAssertWrappedByClerkProvider-GaNwZpWo.mjs.map +1 -0
  47. package/dist/{useAuth-Dlg_G1_7.d.mts → useAuth-BK5Y4htK.d.mts} +58 -39
  48. package/dist/{useAuth-Cv6iRjL9.d.ts → useAuth-BMxaWktj.d.cts} +58 -39
  49. package/package.json +18 -18
  50. package/dist/chunk-E5QRIS4Z.mjs +0 -20
  51. package/dist/chunk-E5QRIS4Z.mjs.map +0 -1
  52. package/dist/chunk-FQVXBXXF.mjs +0 -1487
  53. package/dist/chunk-FQVXBXXF.mjs.map +0 -1
  54. package/dist/chunk-GVGS7DUS.mjs +0 -2097
  55. package/dist/chunk-GVGS7DUS.mjs.map +0 -1
  56. package/dist/chunk-RQWALB2R.mjs +0 -26
  57. package/dist/chunk-RQWALB2R.mjs.map +0 -1
  58. package/dist/errors.d.ts +0 -1
  59. package/dist/errors.js +0 -51
  60. package/dist/errors.js.map +0 -1
  61. package/dist/errors.mjs.map +0 -1
  62. package/dist/experimental.js +0 -1505
  63. package/dist/experimental.js.map +0 -1
  64. package/dist/index.d.ts +0 -319
  65. package/dist/index.js +0 -3919
  66. package/dist/index.js.map +0 -1
  67. package/dist/internal.d.ts +0 -53
  68. package/dist/internal.js +0 -3339
  69. package/dist/internal.js.map +0 -1
  70. package/dist/legacy.js +0 -90
  71. package/dist/legacy.js.map +0 -1
  72. package/dist/types.d.ts +0 -109
  73. package/dist/types.js +0 -19
  74. package/dist/types.js.map +0 -1
  75. package/dist/types.mjs.map +0 -1
@@ -1,2097 +0,0 @@
1
- import {
2
- isConstructor,
3
- mergeWithEnv,
4
- multipleClerkProvidersError,
5
- unsupportedNonBrowserDomainOrProxyUrlFunction,
6
- useAuth,
7
- withClerk,
8
- withMaxAllowedInstancesGuard
9
- } from "./chunk-FQVXBXXF.mjs";
10
- import {
11
- errorThrower,
12
- useAssertWrappedByClerkProvider,
13
- useIsomorphicClerkContext
14
- } from "./chunk-RQWALB2R.mjs";
15
- import {
16
- __privateAdd,
17
- __privateGet,
18
- __privateMethod,
19
- __privateSet,
20
- define_CLERK_UI_SUPPORTED_REACT_BOUNDS_default
21
- } from "./chunk-E5QRIS4Z.mjs";
22
-
23
- // src/components/controlComponents.tsx
24
- import { deprecated } from "@clerk/shared/deprecated";
25
- import { __internal_useSessionBase } from "@clerk/shared/react";
26
- import React from "react";
27
- var ClerkLoaded = ({ children }) => {
28
- useAssertWrappedByClerkProvider("ClerkLoaded");
29
- const isomorphicClerk = useIsomorphicClerkContext();
30
- if (!isomorphicClerk.loaded) {
31
- return null;
32
- }
33
- return children;
34
- };
35
- var ClerkLoading = ({ children }) => {
36
- useAssertWrappedByClerkProvider("ClerkLoading");
37
- const isomorphicClerk = useIsomorphicClerkContext();
38
- if (isomorphicClerk.status !== "loading") {
39
- return null;
40
- }
41
- return children;
42
- };
43
- var ClerkFailed = ({ children }) => {
44
- useAssertWrappedByClerkProvider("ClerkFailed");
45
- const isomorphicClerk = useIsomorphicClerkContext();
46
- if (isomorphicClerk.status !== "error") {
47
- return null;
48
- }
49
- return children;
50
- };
51
- var ClerkDegraded = ({ children }) => {
52
- useAssertWrappedByClerkProvider("ClerkDegraded");
53
- const isomorphicClerk = useIsomorphicClerkContext();
54
- if (isomorphicClerk.status !== "degraded") {
55
- return null;
56
- }
57
- return children;
58
- };
59
- var Show = ({ children, fallback, treatPendingAsSignedOut, when }) => {
60
- useAssertWrappedByClerkProvider("Show");
61
- const { has, isLoaded, userId } = useAuth({ treatPendingAsSignedOut });
62
- if (!isLoaded) {
63
- return null;
64
- }
65
- const resolvedWhen = when;
66
- const authorized = children;
67
- const unauthorized = fallback != null ? fallback : null;
68
- if (resolvedWhen === "signed-out") {
69
- return userId ? unauthorized : authorized;
70
- }
71
- if (!userId) {
72
- return unauthorized;
73
- }
74
- if (resolvedWhen === "signed-in") {
75
- return authorized;
76
- }
77
- if (checkAuthorization(resolvedWhen, has)) {
78
- return authorized;
79
- }
80
- return unauthorized;
81
- };
82
- function checkAuthorization(when, has) {
83
- if (typeof when === "function") {
84
- return when(has);
85
- }
86
- return has(when);
87
- }
88
- var RedirectToSignIn = withClerk(({ clerk, ...props }) => {
89
- var _a, _b;
90
- const { client, session } = clerk;
91
- const hasSignedInSessions = ((_b = (_a = client.signedInSessions) == null ? void 0 : _a.length) != null ? _b : 0) > 0;
92
- React.useEffect(() => {
93
- if (session === null && hasSignedInSessions) {
94
- void clerk.redirectToAfterSignOut();
95
- } else {
96
- void clerk.redirectToSignIn(props);
97
- }
98
- }, []);
99
- return null;
100
- }, "RedirectToSignIn");
101
- var RedirectToSignUp = withClerk(({ clerk, ...props }) => {
102
- React.useEffect(() => {
103
- void clerk.redirectToSignUp(props);
104
- }, []);
105
- return null;
106
- }, "RedirectToSignUp");
107
- var RedirectToTasks = withClerk(({ clerk, ...props }) => {
108
- React.useEffect(() => {
109
- void clerk.redirectToTasks(props);
110
- }, []);
111
- return null;
112
- }, "RedirectToTasks");
113
- var RedirectToUserProfile = withClerk(({ clerk }) => {
114
- React.useEffect(() => {
115
- deprecated("RedirectToUserProfile", "Use the `redirectToUserProfile()` method instead.");
116
- void clerk.redirectToUserProfile();
117
- }, []);
118
- return null;
119
- }, "RedirectToUserProfile");
120
- var RedirectToOrganizationProfile = withClerk(({ clerk }) => {
121
- React.useEffect(() => {
122
- deprecated("RedirectToOrganizationProfile", "Use the `redirectToOrganizationProfile()` method instead.");
123
- void clerk.redirectToOrganizationProfile();
124
- }, []);
125
- return null;
126
- }, "RedirectToOrganizationProfile");
127
- var RedirectToCreateOrganization = withClerk(({ clerk }) => {
128
- React.useEffect(() => {
129
- deprecated("RedirectToCreateOrganization", "Use the `redirectToCreateOrganization()` method instead.");
130
- void clerk.redirectToCreateOrganization();
131
- }, []);
132
- return null;
133
- }, "RedirectToCreateOrganization");
134
- var AuthenticateWithRedirectCallback = withClerk(
135
- ({ clerk, ...handleRedirectCallbackParams }) => {
136
- React.useEffect(() => {
137
- void clerk.handleRedirectCallback(handleRedirectCallbackParams);
138
- }, []);
139
- return null;
140
- },
141
- "AuthenticateWithRedirectCallback"
142
- );
143
- var MultisessionAppSupport = ({ children }) => {
144
- useAssertWrappedByClerkProvider("MultisessionAppSupport");
145
- const session = __internal_useSessionBase();
146
- return /* @__PURE__ */ React.createElement(React.Fragment, { key: session ? session.id : "no-users" }, children);
147
- };
148
-
149
- // src/utils/versionCheck.ts
150
- import { isVersionCompatible } from "@clerk/shared/versionCheck";
151
- import React2 from "react";
152
- import {
153
- checkVersionAgainstBounds,
154
- isVersionCompatible as isVersionCompatible2,
155
- parseVersion
156
- } from "@clerk/shared/versionCheck";
157
- function computeReactVersionCompatibility() {
158
- try {
159
- return isVersionCompatible(React2.version, define_CLERK_UI_SUPPORTED_REACT_BOUNDS_default);
160
- } catch {
161
- return false;
162
- }
163
- }
164
- var IS_REACT_SHARED_VARIANT_COMPATIBLE = computeReactVersionCompatibility();
165
-
166
- // src/contexts/ClerkProvider.tsx
167
- import { ClerkContextProvider } from "@clerk/shared/react";
168
- import React3 from "react";
169
-
170
- // src/isomorphicClerk.ts
171
- import { inBrowser as inBrowser2 } from "@clerk/shared/browser";
172
- import { clerkEvents, createClerkEventBus } from "@clerk/shared/clerkEventBus";
173
- import { loadClerkJSScript, loadClerkUIScript } from "@clerk/shared/loadClerkJsScript";
174
- import { handleValueOrFn } from "@clerk/shared/utils";
175
-
176
- // src/stateProxy.ts
177
- import { inBrowser } from "@clerk/shared/browser";
178
- var defaultSignInErrors = () => ({
179
- fields: {
180
- identifier: null,
181
- password: null,
182
- code: null
183
- },
184
- raw: null,
185
- global: null
186
- });
187
- var defaultSignUpErrors = () => ({
188
- fields: {
189
- firstName: null,
190
- lastName: null,
191
- emailAddress: null,
192
- phoneNumber: null,
193
- password: null,
194
- username: null,
195
- code: null,
196
- captcha: null,
197
- legalAccepted: null
198
- },
199
- raw: null,
200
- global: null
201
- });
202
- var defaultWaitlistErrors = () => ({
203
- fields: {
204
- emailAddress: null
205
- },
206
- raw: null,
207
- global: null
208
- });
209
- var defaultVerificationResource = () => ({
210
- pathRoot: "",
211
- attempts: null,
212
- error: null,
213
- expireAt: null,
214
- externalVerificationRedirectURL: null,
215
- nonce: null,
216
- message: null,
217
- status: null,
218
- strategy: null,
219
- verifiedAtClient: null,
220
- verifiedFromTheSameClient() {
221
- return false;
222
- },
223
- reload() {
224
- throw new Error("reload() called before Clerk is loaded");
225
- },
226
- __internal_toSnapshot() {
227
- return {
228
- object: "verification",
229
- id: "",
230
- attempts: null,
231
- error: { code: "", message: "" },
232
- expire_at: null,
233
- externalVerificationRedirectURL: null,
234
- nonce: null,
235
- message: null,
236
- status: null,
237
- strategy: null,
238
- verified_at_client: null
239
- };
240
- }
241
- });
242
- var defaultSignUpVerificationResource = () => ({
243
- ...defaultVerificationResource(),
244
- supportedStrategies: [],
245
- nextAction: "",
246
- reload() {
247
- throw new Error("reload() called before Clerk is loaded");
248
- },
249
- __internal_toSnapshot() {
250
- return {
251
- ...defaultVerificationResource().__internal_toSnapshot(),
252
- next_action: this.nextAction,
253
- supported_strategies: this.supportedStrategies
254
- };
255
- }
256
- });
257
- var StateProxy = class {
258
- constructor(isomorphicClerk) {
259
- this.isomorphicClerk = isomorphicClerk;
260
- this.signInSignalProxy = this.buildSignInProxy();
261
- this.signUpSignalProxy = this.buildSignUpProxy();
262
- this.waitlistSignalProxy = this.buildWaitlistProxy();
263
- }
264
- signInSignal() {
265
- return this.signInSignalProxy;
266
- }
267
- signUpSignal() {
268
- return this.signUpSignalProxy;
269
- }
270
- waitlistSignal() {
271
- return this.waitlistSignalProxy;
272
- }
273
- get __internal_waitlist() {
274
- return this.state.__internal_waitlist;
275
- }
276
- checkoutSignal(params) {
277
- return this.buildCheckoutProxy(params);
278
- }
279
- buildSignInProxy() {
280
- const gateProperty = this.gateProperty.bind(this);
281
- const target = () => this.client.signIn.__internal_future;
282
- return {
283
- errors: defaultSignInErrors(),
284
- fetchStatus: "idle",
285
- signIn: {
286
- status: "needs_identifier",
287
- availableStrategies: [],
288
- get isTransferable() {
289
- return gateProperty(target, "isTransferable", false);
290
- },
291
- get id() {
292
- return gateProperty(target, "id", void 0);
293
- },
294
- get supportedFirstFactors() {
295
- return gateProperty(target, "supportedFirstFactors", []);
296
- },
297
- get supportedSecondFactors() {
298
- return gateProperty(target, "supportedSecondFactors", []);
299
- },
300
- get secondFactorVerification() {
301
- return gateProperty(target, "secondFactorVerification", {
302
- status: null,
303
- error: null,
304
- expireAt: null,
305
- externalVerificationRedirectURL: null,
306
- nonce: null,
307
- attempts: null,
308
- message: null,
309
- strategy: null,
310
- verifiedAtClient: null,
311
- verifiedFromTheSameClient: () => false,
312
- __internal_toSnapshot: () => {
313
- throw new Error("__internal_toSnapshot called before Clerk is loaded");
314
- },
315
- pathRoot: "",
316
- reload: () => {
317
- throw new Error("__internal_toSnapshot called before Clerk is loaded");
318
- }
319
- });
320
- },
321
- get identifier() {
322
- return gateProperty(target, "identifier", null);
323
- },
324
- get createdSessionId() {
325
- return gateProperty(target, "createdSessionId", null);
326
- },
327
- get userData() {
328
- return gateProperty(target, "userData", {});
329
- },
330
- get firstFactorVerification() {
331
- return gateProperty(target, "firstFactorVerification", {
332
- status: null,
333
- error: null,
334
- expireAt: null,
335
- externalVerificationRedirectURL: null,
336
- nonce: null,
337
- attempts: null,
338
- message: null,
339
- strategy: null,
340
- verifiedAtClient: null,
341
- verifiedFromTheSameClient: () => false,
342
- __internal_toSnapshot: () => {
343
- throw new Error("__internal_toSnapshot called before Clerk is loaded");
344
- },
345
- pathRoot: "",
346
- reload: () => {
347
- throw new Error("__internal_toSnapshot called before Clerk is loaded");
348
- }
349
- });
350
- },
351
- get canBeDiscarded() {
352
- return gateProperty(target, "canBeDiscarded", false);
353
- },
354
- create: this.gateMethod(target, "create"),
355
- password: this.gateMethod(target, "password"),
356
- sso: this.gateMethod(target, "sso"),
357
- finalize: this.gateMethod(target, "finalize"),
358
- reset: this.gateMethod(target, "reset"),
359
- emailCode: this.wrapMethods(() => target().emailCode, ["sendCode", "verifyCode"]),
360
- emailLink: this.wrapStruct(
361
- () => target().emailLink,
362
- ["sendLink", "waitForVerification"],
363
- ["verification"],
364
- { verification: null }
365
- ),
366
- resetPasswordEmailCode: this.wrapMethods(() => target().resetPasswordEmailCode, [
367
- "sendCode",
368
- "verifyCode",
369
- "submitPassword"
370
- ]),
371
- resetPasswordPhoneCode: this.wrapMethods(() => target().resetPasswordPhoneCode, [
372
- "sendCode",
373
- "verifyCode",
374
- "submitPassword"
375
- ]),
376
- phoneCode: this.wrapMethods(() => target().phoneCode, ["sendCode", "verifyCode"]),
377
- mfa: this.wrapMethods(() => target().mfa, [
378
- "sendPhoneCode",
379
- "verifyPhoneCode",
380
- "sendEmailCode",
381
- "verifyEmailCode",
382
- "verifyTOTP",
383
- "verifyBackupCode"
384
- ]),
385
- ticket: this.gateMethod(target, "ticket"),
386
- passkey: this.gateMethod(target, "passkey"),
387
- web3: this.gateMethod(target, "web3")
388
- }
389
- };
390
- }
391
- buildSignUpProxy() {
392
- const gateProperty = this.gateProperty.bind(this);
393
- const gateMethod = this.gateMethod.bind(this);
394
- const target = () => this.client.signUp.__internal_future;
395
- return {
396
- errors: defaultSignUpErrors(),
397
- fetchStatus: "idle",
398
- signUp: {
399
- get id() {
400
- return gateProperty(target, "id", void 0);
401
- },
402
- get requiredFields() {
403
- return gateProperty(target, "requiredFields", []);
404
- },
405
- get optionalFields() {
406
- return gateProperty(target, "optionalFields", []);
407
- },
408
- get missingFields() {
409
- return gateProperty(target, "missingFields", []);
410
- },
411
- get username() {
412
- return gateProperty(target, "username", null);
413
- },
414
- get firstName() {
415
- return gateProperty(target, "firstName", null);
416
- },
417
- get lastName() {
418
- return gateProperty(target, "lastName", null);
419
- },
420
- get emailAddress() {
421
- return gateProperty(target, "emailAddress", null);
422
- },
423
- get phoneNumber() {
424
- return gateProperty(target, "phoneNumber", null);
425
- },
426
- get web3Wallet() {
427
- return gateProperty(target, "web3Wallet", null);
428
- },
429
- get hasPassword() {
430
- return gateProperty(target, "hasPassword", false);
431
- },
432
- get unsafeMetadata() {
433
- return gateProperty(target, "unsafeMetadata", {});
434
- },
435
- get createdSessionId() {
436
- return gateProperty(target, "createdSessionId", null);
437
- },
438
- get createdUserId() {
439
- return gateProperty(target, "createdUserId", null);
440
- },
441
- get abandonAt() {
442
- return gateProperty(target, "abandonAt", null);
443
- },
444
- get legalAcceptedAt() {
445
- return gateProperty(target, "legalAcceptedAt", null);
446
- },
447
- get locale() {
448
- return gateProperty(target, "locale", null);
449
- },
450
- get status() {
451
- return gateProperty(target, "status", "missing_requirements");
452
- },
453
- get unverifiedFields() {
454
- return gateProperty(target, "unverifiedFields", []);
455
- },
456
- get isTransferable() {
457
- return gateProperty(target, "isTransferable", false);
458
- },
459
- get canBeDiscarded() {
460
- return gateProperty(target, "canBeDiscarded", false);
461
- },
462
- create: gateMethod(target, "create"),
463
- update: gateMethod(target, "update"),
464
- sso: gateMethod(target, "sso"),
465
- password: gateMethod(target, "password"),
466
- ticket: gateMethod(target, "ticket"),
467
- web3: gateMethod(target, "web3"),
468
- finalize: gateMethod(target, "finalize"),
469
- reset: gateMethod(target, "reset"),
470
- verifications: this.wrapStruct(
471
- () => target().verifications,
472
- [
473
- "sendEmailCode",
474
- "verifyEmailCode",
475
- "sendEmailLink",
476
- "waitForEmailLinkVerification",
477
- "sendPhoneCode",
478
- "verifyPhoneCode"
479
- ],
480
- ["emailAddress", "phoneNumber", "web3Wallet", "externalAccount", "emailLinkVerification"],
481
- {
482
- emailAddress: defaultSignUpVerificationResource(),
483
- phoneNumber: defaultSignUpVerificationResource(),
484
- web3Wallet: defaultSignUpVerificationResource(),
485
- externalAccount: defaultSignUpVerificationResource(),
486
- emailLinkVerification: null
487
- }
488
- )
489
- }
490
- };
491
- }
492
- buildWaitlistProxy() {
493
- const gateProperty = this.gateProperty.bind(this);
494
- const gateMethod = this.gateMethod.bind(this);
495
- const target = () => {
496
- return this.state.__internal_waitlist;
497
- };
498
- return {
499
- errors: defaultWaitlistErrors(),
500
- fetchStatus: "idle",
501
- waitlist: {
502
- pathRoot: "/waitlist",
503
- get id() {
504
- return gateProperty(target, "id", "");
505
- },
506
- get createdAt() {
507
- return gateProperty(target, "createdAt", null);
508
- },
509
- get updatedAt() {
510
- return gateProperty(target, "updatedAt", null);
511
- },
512
- join: gateMethod(target, "join"),
513
- reload: gateMethod(target, "reload")
514
- }
515
- };
516
- }
517
- buildCheckoutProxy(params) {
518
- const gateProperty = this.gateProperty.bind(this);
519
- const targetCheckout = () => this.checkout(params);
520
- const target = () => targetCheckout().checkout;
521
- return {
522
- errors: {
523
- raw: null,
524
- global: null
525
- },
526
- fetchStatus: "idle",
527
- checkout: {
528
- get status() {
529
- return gateProperty(target, "status", "needs_initialization");
530
- },
531
- get externalClientSecret() {
532
- return gateProperty(target, "externalClientSecret", null);
533
- },
534
- get externalGatewayId() {
535
- return gateProperty(target, "externalGatewayId", null);
536
- },
537
- get paymentMethod() {
538
- return gateProperty(target, "paymentMethod", null);
539
- },
540
- get plan() {
541
- return gateProperty(target, "plan", null);
542
- },
543
- get planPeriod() {
544
- return gateProperty(target, "planPeriod", null);
545
- },
546
- get totals() {
547
- return gateProperty(target, "totals", null);
548
- },
549
- get isImmediatePlanChange() {
550
- return gateProperty(target, "isImmediatePlanChange", false);
551
- },
552
- get freeTrialEndsAt() {
553
- return gateProperty(target, "freeTrialEndsAt", null);
554
- },
555
- get payer() {
556
- return gateProperty(target, "payer", null);
557
- },
558
- get planPeriodStart() {
559
- return gateProperty(target, "planPeriodStart", null);
560
- },
561
- get needsPaymentMethod() {
562
- return gateProperty(target, "needsPaymentMethod", null);
563
- },
564
- start: this.gateMethod(target, "start"),
565
- confirm: this.gateMethod(target, "confirm"),
566
- finalize: this.gateMethod(target, "finalize")
567
- }
568
- };
569
- }
570
- __internal_effect(_) {
571
- throw new Error("__internal_effect called before Clerk is loaded");
572
- }
573
- __internal_computed(_) {
574
- throw new Error("__internal_computed called before Clerk is loaded");
575
- }
576
- get state() {
577
- const s = this.isomorphicClerk.__internal_state;
578
- if (!s) {
579
- throw new Error("Clerk state not ready");
580
- }
581
- return s;
582
- }
583
- get client() {
584
- const c = this.isomorphicClerk.client;
585
- if (!c) {
586
- throw new Error("Clerk client not ready");
587
- }
588
- return c;
589
- }
590
- get checkout() {
591
- const c = this.isomorphicClerk.__experimental_checkout;
592
- if (!c) {
593
- throw new Error("Clerk checkout not ready");
594
- }
595
- return c;
596
- }
597
- gateProperty(getTarget, key, defaultValue) {
598
- return (() => {
599
- if (!inBrowser() || !this.isomorphicClerk.loaded) {
600
- return defaultValue;
601
- }
602
- const t = getTarget();
603
- return t[key];
604
- })();
605
- }
606
- gateMethod(getTarget, key) {
607
- return (async (...args) => {
608
- if (!inBrowser()) {
609
- return errorThrower.throw(`Attempted to call a method (${key}) that is not supported on the server.`);
610
- }
611
- if (!this.isomorphicClerk.loaded) {
612
- await new Promise((resolve) => this.isomorphicClerk.addOnLoaded(resolve));
613
- }
614
- const t = getTarget();
615
- return t[key].apply(t, args);
616
- });
617
- }
618
- wrapMethods(getTarget, keys) {
619
- return Object.fromEntries(keys.map((k) => [k, this.gateMethod(getTarget, k)]));
620
- }
621
- wrapStruct(getTarget, methods, getters, fallbacks) {
622
- const out = {};
623
- for (const m of methods) {
624
- out[m] = this.gateMethod(getTarget, m);
625
- }
626
- for (const g of getters) {
627
- Object.defineProperty(out, g, {
628
- get: () => this.gateProperty(getTarget, g, fallbacks[g]),
629
- enumerable: true
630
- });
631
- }
632
- return out;
633
- }
634
- };
635
-
636
- // src/isomorphicClerk.ts
637
- if (typeof globalThis.__BUILD_DISABLE_RHC__ === "undefined") {
638
- globalThis.__BUILD_DISABLE_RHC__ = false;
639
- }
640
- var SDK_METADATA = {
641
- name: "@clerk/react",
642
- version: "6.9.0",
643
- environment: process.env.NODE_ENV
644
- };
645
- var _status, _domain, _proxyUrl, _publishableKey, _eventBus, _stateProxy, _instance, _IsomorphicClerk_instances, waitForClerkJS_fn;
646
- var _IsomorphicClerk = class _IsomorphicClerk {
647
- constructor(options) {
648
- __privateAdd(this, _IsomorphicClerk_instances);
649
- this.clerkjs = null;
650
- this.preopenOneTap = null;
651
- this.preopenUserVerification = null;
652
- this.preopenEnableOrganizationsPrompt = null;
653
- this.preopenSignIn = null;
654
- this.preopenCheckout = null;
655
- this.preopenPlanDetails = null;
656
- this.preopenSubscriptionDetails = null;
657
- this.preopenSignUp = null;
658
- this.preopenUserProfile = null;
659
- this.preopenOrganizationProfile = null;
660
- this.preopenCreateOrganization = null;
661
- this.preOpenWaitlist = null;
662
- this.premountSignInNodes = /* @__PURE__ */ new Map();
663
- this.premountSignUpNodes = /* @__PURE__ */ new Map();
664
- this.premountUserAvatarNodes = /* @__PURE__ */ new Map();
665
- this.premountUserProfileNodes = /* @__PURE__ */ new Map();
666
- this.premountUserButtonNodes = /* @__PURE__ */ new Map();
667
- this.premountOrganizationProfileNodes = /* @__PURE__ */ new Map();
668
- this.premountCreateOrganizationNodes = /* @__PURE__ */ new Map();
669
- this.premountOrganizationSwitcherNodes = /* @__PURE__ */ new Map();
670
- this.premountOrganizationListNodes = /* @__PURE__ */ new Map();
671
- this.premountMethodCalls = /* @__PURE__ */ new Map();
672
- this.premountWaitlistNodes = /* @__PURE__ */ new Map();
673
- this.premountPricingTableNodes = /* @__PURE__ */ new Map();
674
- this.premountAPIKeysNodes = /* @__PURE__ */ new Map();
675
- this.premountConfigureSSONodes = /* @__PURE__ */ new Map();
676
- this.premountOAuthConsentNodes = /* @__PURE__ */ new Map();
677
- this.premountTaskChooseOrganizationNodes = /* @__PURE__ */ new Map();
678
- this.premountTaskResetPasswordNodes = /* @__PURE__ */ new Map();
679
- this.premountTaskSetupMFANodes = /* @__PURE__ */ new Map();
680
- // A separate Map of `addListener` method calls to handle multiple listeners.
681
- this.premountAddListenerCalls = /* @__PURE__ */ new Map();
682
- this.loadedListeners = [];
683
- __privateAdd(this, _status, "loading");
684
- __privateAdd(this, _domain);
685
- __privateAdd(this, _proxyUrl);
686
- __privateAdd(this, _publishableKey);
687
- __privateAdd(this, _eventBus, createClerkEventBus());
688
- __privateAdd(this, _stateProxy);
689
- this.buildSignInUrl = (opts) => {
690
- const callback = () => {
691
- var _a;
692
- return ((_a = this.clerkjs) == null ? void 0 : _a.buildSignInUrl(opts)) || "";
693
- };
694
- if (this.clerkjs && this.loaded) {
695
- return callback();
696
- } else {
697
- this.premountMethodCalls.set("buildSignInUrl", callback);
698
- }
699
- };
700
- this.buildSignUpUrl = (opts) => {
701
- const callback = () => {
702
- var _a;
703
- return ((_a = this.clerkjs) == null ? void 0 : _a.buildSignUpUrl(opts)) || "";
704
- };
705
- if (this.clerkjs && this.loaded) {
706
- return callback();
707
- } else {
708
- this.premountMethodCalls.set("buildSignUpUrl", callback);
709
- }
710
- };
711
- this.buildAfterSignInUrl = (...args) => {
712
- const callback = () => {
713
- var _a;
714
- return ((_a = this.clerkjs) == null ? void 0 : _a.buildAfterSignInUrl(...args)) || "";
715
- };
716
- if (this.clerkjs && this.loaded) {
717
- return callback();
718
- } else {
719
- this.premountMethodCalls.set("buildAfterSignInUrl", callback);
720
- }
721
- };
722
- this.buildAfterSignUpUrl = (...args) => {
723
- const callback = () => {
724
- var _a;
725
- return ((_a = this.clerkjs) == null ? void 0 : _a.buildAfterSignUpUrl(...args)) || "";
726
- };
727
- if (this.clerkjs && this.loaded) {
728
- return callback();
729
- } else {
730
- this.premountMethodCalls.set("buildAfterSignUpUrl", callback);
731
- }
732
- };
733
- this.buildAfterSignOutUrl = () => {
734
- const callback = () => {
735
- var _a;
736
- return ((_a = this.clerkjs) == null ? void 0 : _a.buildAfterSignOutUrl()) || "";
737
- };
738
- if (this.clerkjs && this.loaded) {
739
- return callback();
740
- } else {
741
- this.premountMethodCalls.set("buildAfterSignOutUrl", callback);
742
- }
743
- };
744
- this.buildNewSubscriptionRedirectUrl = () => {
745
- const callback = () => {
746
- var _a;
747
- return ((_a = this.clerkjs) == null ? void 0 : _a.buildNewSubscriptionRedirectUrl()) || "";
748
- };
749
- if (this.clerkjs && this.loaded) {
750
- return callback();
751
- } else {
752
- this.premountMethodCalls.set("buildNewSubscriptionRedirectUrl", callback);
753
- }
754
- };
755
- this.buildAfterMultiSessionSingleSignOutUrl = () => {
756
- const callback = () => {
757
- var _a;
758
- return ((_a = this.clerkjs) == null ? void 0 : _a.buildAfterMultiSessionSingleSignOutUrl()) || "";
759
- };
760
- if (this.clerkjs && this.loaded) {
761
- return callback();
762
- } else {
763
- this.premountMethodCalls.set("buildAfterMultiSessionSingleSignOutUrl", callback);
764
- }
765
- };
766
- this.buildUserProfileUrl = () => {
767
- const callback = () => {
768
- var _a;
769
- return ((_a = this.clerkjs) == null ? void 0 : _a.buildUserProfileUrl()) || "";
770
- };
771
- if (this.clerkjs && this.loaded) {
772
- return callback();
773
- } else {
774
- this.premountMethodCalls.set("buildUserProfileUrl", callback);
775
- }
776
- };
777
- this.buildCreateOrganizationUrl = () => {
778
- const callback = () => {
779
- var _a;
780
- return ((_a = this.clerkjs) == null ? void 0 : _a.buildCreateOrganizationUrl()) || "";
781
- };
782
- if (this.clerkjs && this.loaded) {
783
- return callback();
784
- } else {
785
- this.premountMethodCalls.set("buildCreateOrganizationUrl", callback);
786
- }
787
- };
788
- this.buildOrganizationProfileUrl = () => {
789
- const callback = () => {
790
- var _a;
791
- return ((_a = this.clerkjs) == null ? void 0 : _a.buildOrganizationProfileUrl()) || "";
792
- };
793
- if (this.clerkjs && this.loaded) {
794
- return callback();
795
- } else {
796
- this.premountMethodCalls.set("buildOrganizationProfileUrl", callback);
797
- }
798
- };
799
- this.buildWaitlistUrl = () => {
800
- const callback = () => {
801
- var _a;
802
- return ((_a = this.clerkjs) == null ? void 0 : _a.buildWaitlistUrl()) || "";
803
- };
804
- if (this.clerkjs && this.loaded) {
805
- return callback();
806
- } else {
807
- this.premountMethodCalls.set("buildWaitlistUrl", callback);
808
- }
809
- };
810
- this.buildTasksUrl = () => {
811
- const callback = () => {
812
- var _a;
813
- return ((_a = this.clerkjs) == null ? void 0 : _a.buildTasksUrl()) || "";
814
- };
815
- if (this.clerkjs && this.loaded) {
816
- return callback();
817
- } else {
818
- this.premountMethodCalls.set("buildTasksUrl", callback);
819
- }
820
- };
821
- this.buildUrlWithAuth = (to) => {
822
- const callback = () => {
823
- var _a;
824
- return ((_a = this.clerkjs) == null ? void 0 : _a.buildUrlWithAuth(to)) || "";
825
- };
826
- if (this.clerkjs && this.loaded) {
827
- return callback();
828
- } else {
829
- this.premountMethodCalls.set("buildUrlWithAuth", callback);
830
- }
831
- };
832
- this.handleUnauthenticated = async () => {
833
- const callback = () => {
834
- var _a;
835
- return (_a = this.clerkjs) == null ? void 0 : _a.handleUnauthenticated();
836
- };
837
- if (this.clerkjs && this.loaded) {
838
- void callback();
839
- } else {
840
- this.premountMethodCalls.set("handleUnauthenticated", callback);
841
- }
842
- };
843
- this.on = (...args) => {
844
- var _a;
845
- if ((_a = this.clerkjs) == null ? void 0 : _a.on) {
846
- return this.clerkjs.on(...args);
847
- } else {
848
- __privateGet(this, _eventBus).on(...args);
849
- }
850
- };
851
- this.off = (...args) => {
852
- var _a;
853
- if ((_a = this.clerkjs) == null ? void 0 : _a.off) {
854
- return this.clerkjs.off(...args);
855
- } else {
856
- __privateGet(this, _eventBus).off(...args);
857
- }
858
- };
859
- /**
860
- * @deprecated Please use `addStatusListener`. This api will be removed in the next major.
861
- */
862
- this.addOnLoaded = (cb) => {
863
- this.loadedListeners.push(cb);
864
- if (this.loaded) {
865
- this.emitLoaded();
866
- }
867
- };
868
- /**
869
- * @deprecated Please use `__internal_setStatus`. This api will be removed in the next major.
870
- */
871
- this.emitLoaded = () => {
872
- this.loadedListeners.forEach((cb) => cb());
873
- this.loadedListeners = [];
874
- };
875
- this.beforeLoad = (clerkjs) => {
876
- if (!clerkjs) {
877
- throw new Error("Failed to hydrate latest Clerk JS");
878
- }
879
- };
880
- this.replayInterceptedInvocations = (clerkjs) => {
881
- var _a;
882
- if (!clerkjs) {
883
- throw new Error("Failed to hydrate latest Clerk JS");
884
- }
885
- this.clerkjs = clerkjs;
886
- this.premountMethodCalls.forEach((cb) => cb());
887
- this.premountAddListenerCalls.forEach((listenerExtras, listener) => {
888
- listenerExtras.handlers.nativeUnsubscribe = clerkjs.addListener(listener, listenerExtras.options);
889
- });
890
- (_a = __privateGet(this, _eventBus).internal.retrieveListeners("status")) == null ? void 0 : _a.forEach((listener) => {
891
- this.on("status", listener, { notify: true });
892
- });
893
- if (this.preopenSignIn !== null) {
894
- clerkjs.openSignIn(this.preopenSignIn);
895
- }
896
- if (this.preopenCheckout !== null) {
897
- clerkjs.__internal_openCheckout(this.preopenCheckout);
898
- }
899
- if (this.preopenPlanDetails !== null) {
900
- clerkjs.__internal_openPlanDetails(this.preopenPlanDetails);
901
- }
902
- if (this.preopenSubscriptionDetails !== null) {
903
- clerkjs.__internal_openSubscriptionDetails(this.preopenSubscriptionDetails);
904
- }
905
- if (this.preopenSignUp !== null) {
906
- clerkjs.openSignUp(this.preopenSignUp);
907
- }
908
- if (this.preopenUserProfile !== null) {
909
- clerkjs.openUserProfile(this.preopenUserProfile);
910
- }
911
- if (this.preopenUserVerification !== null) {
912
- clerkjs.__internal_openReverification(this.preopenUserVerification);
913
- }
914
- if (this.preopenOneTap !== null) {
915
- clerkjs.openGoogleOneTap(this.preopenOneTap);
916
- }
917
- if (this.preopenOrganizationProfile !== null) {
918
- clerkjs.openOrganizationProfile(this.preopenOrganizationProfile);
919
- }
920
- if (this.preopenCreateOrganization !== null) {
921
- clerkjs.openCreateOrganization(this.preopenCreateOrganization);
922
- }
923
- if (this.preOpenWaitlist !== null) {
924
- clerkjs.openWaitlist(this.preOpenWaitlist);
925
- }
926
- if (this.preopenEnableOrganizationsPrompt) {
927
- clerkjs.__internal_openEnableOrganizationsPrompt(this.preopenEnableOrganizationsPrompt);
928
- }
929
- this.premountSignInNodes.forEach((props, node) => {
930
- clerkjs.mountSignIn(node, props);
931
- });
932
- this.premountSignUpNodes.forEach((props, node) => {
933
- clerkjs.mountSignUp(node, props);
934
- });
935
- this.premountUserProfileNodes.forEach((props, node) => {
936
- clerkjs.mountUserProfile(node, props);
937
- });
938
- this.premountUserAvatarNodes.forEach((props, node) => {
939
- clerkjs.mountUserAvatar(node, props);
940
- });
941
- this.premountUserButtonNodes.forEach((props, node) => {
942
- clerkjs.mountUserButton(node, props);
943
- });
944
- this.premountOrganizationListNodes.forEach((props, node) => {
945
- clerkjs.mountOrganizationList(node, props);
946
- });
947
- this.premountWaitlistNodes.forEach((props, node) => {
948
- clerkjs.mountWaitlist(node, props);
949
- });
950
- this.premountPricingTableNodes.forEach((props, node) => {
951
- clerkjs.mountPricingTable(node, props);
952
- });
953
- this.premountAPIKeysNodes.forEach((props, node) => {
954
- clerkjs.mountAPIKeys(node, props);
955
- });
956
- this.premountConfigureSSONodes.forEach((props, node) => {
957
- clerkjs.__internal_mountConfigureSSO(node, props);
958
- });
959
- this.premountOAuthConsentNodes.forEach((props, node) => {
960
- clerkjs.__internal_mountOAuthConsent(node, props);
961
- });
962
- this.premountTaskChooseOrganizationNodes.forEach((props, node) => {
963
- clerkjs.mountTaskChooseOrganization(node, props);
964
- });
965
- this.premountTaskResetPasswordNodes.forEach((props, node) => {
966
- clerkjs.mountTaskResetPassword(node, props);
967
- });
968
- this.premountTaskSetupMFANodes.forEach((props, node) => {
969
- clerkjs.mountTaskSetupMFA(node, props);
970
- });
971
- if (typeof this.clerkjs.status === "undefined") {
972
- __privateGet(this, _eventBus).emit(clerkEvents.Status, "ready");
973
- }
974
- this.emitLoaded();
975
- return this.clerkjs;
976
- };
977
- this.__experimental_checkout = (...args) => {
978
- return this.loaded && this.clerkjs ? this.clerkjs.__experimental_checkout(...args) : __privateGet(this, _stateProxy).checkoutSignal(...args);
979
- };
980
- // TODO @userland-errors:
981
- this.__internal_updateProps = async (props) => {
982
- const clerkjs = await __privateMethod(this, _IsomorphicClerk_instances, waitForClerkJS_fn).call(this);
983
- if (clerkjs && "__internal_updateProps" in clerkjs) {
984
- return clerkjs.__internal_updateProps(props);
985
- }
986
- };
987
- /**
988
- * `setActive` can be used to set the active session and/or organization.
989
- */
990
- this.setActive = (params) => {
991
- if (this.clerkjs) {
992
- return this.clerkjs.setActive(params);
993
- } else {
994
- return Promise.reject();
995
- }
996
- };
997
- this.openSignIn = (props) => {
998
- if (this.clerkjs && this.loaded) {
999
- this.clerkjs.openSignIn(props);
1000
- } else {
1001
- this.preopenSignIn = props;
1002
- }
1003
- };
1004
- this.closeSignIn = () => {
1005
- if (this.clerkjs && this.loaded) {
1006
- this.clerkjs.closeSignIn();
1007
- } else {
1008
- this.preopenSignIn = null;
1009
- }
1010
- };
1011
- this.__internal_openCheckout = (props) => {
1012
- if (this.clerkjs && this.loaded) {
1013
- this.clerkjs.__internal_openCheckout(props);
1014
- } else {
1015
- this.preopenCheckout = props;
1016
- }
1017
- };
1018
- this.__internal_closeCheckout = () => {
1019
- if (this.clerkjs && this.loaded) {
1020
- this.clerkjs.__internal_closeCheckout();
1021
- } else {
1022
- this.preopenCheckout = null;
1023
- }
1024
- };
1025
- this.__internal_openPlanDetails = (props) => {
1026
- if (this.clerkjs && this.loaded) {
1027
- this.clerkjs.__internal_openPlanDetails(props);
1028
- } else {
1029
- this.preopenPlanDetails = props;
1030
- }
1031
- };
1032
- this.__internal_closePlanDetails = () => {
1033
- if (this.clerkjs && this.loaded) {
1034
- this.clerkjs.__internal_closePlanDetails();
1035
- } else {
1036
- this.preopenPlanDetails = null;
1037
- }
1038
- };
1039
- this.__internal_openSubscriptionDetails = (props) => {
1040
- if (this.clerkjs && this.loaded) {
1041
- this.clerkjs.__internal_openSubscriptionDetails(props);
1042
- } else {
1043
- this.preopenSubscriptionDetails = props != null ? props : null;
1044
- }
1045
- };
1046
- this.__internal_closeSubscriptionDetails = () => {
1047
- if (this.clerkjs && this.loaded) {
1048
- this.clerkjs.__internal_closeSubscriptionDetails();
1049
- } else {
1050
- this.preopenSubscriptionDetails = null;
1051
- }
1052
- };
1053
- this.__internal_openReverification = (props) => {
1054
- if (this.clerkjs && this.loaded) {
1055
- this.clerkjs.__internal_openReverification(props);
1056
- } else {
1057
- this.preopenUserVerification = props;
1058
- }
1059
- };
1060
- this.__internal_closeReverification = () => {
1061
- if (this.clerkjs && this.loaded) {
1062
- this.clerkjs.__internal_closeReverification();
1063
- } else {
1064
- this.preopenUserVerification = null;
1065
- }
1066
- };
1067
- this.__internal_openEnableOrganizationsPrompt = (props) => {
1068
- if (this.clerkjs && this.loaded) {
1069
- this.clerkjs.__internal_openEnableOrganizationsPrompt(props);
1070
- } else {
1071
- this.preopenEnableOrganizationsPrompt = props;
1072
- }
1073
- };
1074
- this.__internal_closeEnableOrganizationsPrompt = () => {
1075
- if (this.clerkjs && this.loaded) {
1076
- this.clerkjs.__internal_closeEnableOrganizationsPrompt();
1077
- } else {
1078
- this.preopenEnableOrganizationsPrompt = null;
1079
- }
1080
- };
1081
- this.openGoogleOneTap = (props) => {
1082
- if (this.clerkjs && this.loaded) {
1083
- this.clerkjs.openGoogleOneTap(props);
1084
- } else {
1085
- this.preopenOneTap = props;
1086
- }
1087
- };
1088
- this.closeGoogleOneTap = () => {
1089
- if (this.clerkjs && this.loaded) {
1090
- this.clerkjs.closeGoogleOneTap();
1091
- } else {
1092
- this.preopenOneTap = null;
1093
- }
1094
- };
1095
- this.openUserProfile = (props) => {
1096
- if (this.clerkjs && this.loaded) {
1097
- this.clerkjs.openUserProfile(props);
1098
- } else {
1099
- this.preopenUserProfile = props;
1100
- }
1101
- };
1102
- this.closeUserProfile = () => {
1103
- if (this.clerkjs && this.loaded) {
1104
- this.clerkjs.closeUserProfile();
1105
- } else {
1106
- this.preopenUserProfile = null;
1107
- }
1108
- };
1109
- this.openOrganizationProfile = (props) => {
1110
- if (this.clerkjs && this.loaded) {
1111
- this.clerkjs.openOrganizationProfile(props);
1112
- } else {
1113
- this.preopenOrganizationProfile = props;
1114
- }
1115
- };
1116
- this.closeOrganizationProfile = () => {
1117
- if (this.clerkjs && this.loaded) {
1118
- this.clerkjs.closeOrganizationProfile();
1119
- } else {
1120
- this.preopenOrganizationProfile = null;
1121
- }
1122
- };
1123
- this.openCreateOrganization = (props) => {
1124
- if (this.clerkjs && this.loaded) {
1125
- this.clerkjs.openCreateOrganization(props);
1126
- } else {
1127
- this.preopenCreateOrganization = props;
1128
- }
1129
- };
1130
- this.closeCreateOrganization = () => {
1131
- if (this.clerkjs && this.loaded) {
1132
- this.clerkjs.closeCreateOrganization();
1133
- } else {
1134
- this.preopenCreateOrganization = null;
1135
- }
1136
- };
1137
- this.openWaitlist = (props) => {
1138
- if (this.clerkjs && this.loaded) {
1139
- this.clerkjs.openWaitlist(props);
1140
- } else {
1141
- this.preOpenWaitlist = props;
1142
- }
1143
- };
1144
- this.closeWaitlist = () => {
1145
- if (this.clerkjs && this.loaded) {
1146
- this.clerkjs.closeWaitlist();
1147
- } else {
1148
- this.preOpenWaitlist = null;
1149
- }
1150
- };
1151
- this.openSignUp = (props) => {
1152
- if (this.clerkjs && this.loaded) {
1153
- this.clerkjs.openSignUp(props);
1154
- } else {
1155
- this.preopenSignUp = props;
1156
- }
1157
- };
1158
- this.closeSignUp = () => {
1159
- if (this.clerkjs && this.loaded) {
1160
- this.clerkjs.closeSignUp();
1161
- } else {
1162
- this.preopenSignUp = null;
1163
- }
1164
- };
1165
- this.mountSignIn = (node, props) => {
1166
- if (this.clerkjs && this.loaded) {
1167
- this.clerkjs.mountSignIn(node, props);
1168
- } else {
1169
- this.premountSignInNodes.set(node, props);
1170
- }
1171
- };
1172
- this.unmountSignIn = (node) => {
1173
- if (this.clerkjs && this.loaded) {
1174
- this.clerkjs.unmountSignIn(node);
1175
- } else {
1176
- this.premountSignInNodes.delete(node);
1177
- }
1178
- };
1179
- this.mountSignUp = (node, props) => {
1180
- if (this.clerkjs && this.loaded) {
1181
- this.clerkjs.mountSignUp(node, props);
1182
- } else {
1183
- this.premountSignUpNodes.set(node, props);
1184
- }
1185
- };
1186
- this.unmountSignUp = (node) => {
1187
- if (this.clerkjs && this.loaded) {
1188
- this.clerkjs.unmountSignUp(node);
1189
- } else {
1190
- this.premountSignUpNodes.delete(node);
1191
- }
1192
- };
1193
- this.mountUserAvatar = (node, props) => {
1194
- if (this.clerkjs && this.loaded) {
1195
- this.clerkjs.mountUserAvatar(node, props);
1196
- } else {
1197
- this.premountUserAvatarNodes.set(node, props);
1198
- }
1199
- };
1200
- this.unmountUserAvatar = (node) => {
1201
- if (this.clerkjs && this.loaded) {
1202
- this.clerkjs.unmountUserAvatar(node);
1203
- } else {
1204
- this.premountUserAvatarNodes.delete(node);
1205
- }
1206
- };
1207
- this.mountUserProfile = (node, props) => {
1208
- if (this.clerkjs && this.loaded) {
1209
- this.clerkjs.mountUserProfile(node, props);
1210
- } else {
1211
- this.premountUserProfileNodes.set(node, props);
1212
- }
1213
- };
1214
- this.unmountUserProfile = (node) => {
1215
- if (this.clerkjs && this.loaded) {
1216
- this.clerkjs.unmountUserProfile(node);
1217
- } else {
1218
- this.premountUserProfileNodes.delete(node);
1219
- }
1220
- };
1221
- this.mountOrganizationProfile = (node, props) => {
1222
- if (this.clerkjs && this.loaded) {
1223
- this.clerkjs.mountOrganizationProfile(node, props);
1224
- } else {
1225
- this.premountOrganizationProfileNodes.set(node, props);
1226
- }
1227
- };
1228
- this.unmountOrganizationProfile = (node) => {
1229
- if (this.clerkjs && this.loaded) {
1230
- this.clerkjs.unmountOrganizationProfile(node);
1231
- } else {
1232
- this.premountOrganizationProfileNodes.delete(node);
1233
- }
1234
- };
1235
- this.mountCreateOrganization = (node, props) => {
1236
- if (this.clerkjs && this.loaded) {
1237
- this.clerkjs.mountCreateOrganization(node, props);
1238
- } else {
1239
- this.premountCreateOrganizationNodes.set(node, props);
1240
- }
1241
- };
1242
- this.unmountCreateOrganization = (node) => {
1243
- if (this.clerkjs && this.loaded) {
1244
- this.clerkjs.unmountCreateOrganization(node);
1245
- } else {
1246
- this.premountCreateOrganizationNodes.delete(node);
1247
- }
1248
- };
1249
- this.mountOrganizationSwitcher = (node, props) => {
1250
- if (this.clerkjs && this.loaded) {
1251
- this.clerkjs.mountOrganizationSwitcher(node, props);
1252
- } else {
1253
- this.premountOrganizationSwitcherNodes.set(node, props);
1254
- }
1255
- };
1256
- this.unmountOrganizationSwitcher = (node) => {
1257
- if (this.clerkjs && this.loaded) {
1258
- this.clerkjs.unmountOrganizationSwitcher(node);
1259
- } else {
1260
- this.premountOrganizationSwitcherNodes.delete(node);
1261
- }
1262
- };
1263
- this.__experimental_prefetchOrganizationSwitcher = () => {
1264
- const callback = () => {
1265
- var _a;
1266
- return (_a = this.clerkjs) == null ? void 0 : _a.__experimental_prefetchOrganizationSwitcher();
1267
- };
1268
- if (this.clerkjs && this.loaded) {
1269
- void callback();
1270
- } else {
1271
- this.premountMethodCalls.set("__experimental_prefetchOrganizationSwitcher", callback);
1272
- }
1273
- };
1274
- this.mountOrganizationList = (node, props) => {
1275
- if (this.clerkjs && this.loaded) {
1276
- this.clerkjs.mountOrganizationList(node, props);
1277
- } else {
1278
- this.premountOrganizationListNodes.set(node, props);
1279
- }
1280
- };
1281
- this.unmountOrganizationList = (node) => {
1282
- if (this.clerkjs && this.loaded) {
1283
- this.clerkjs.unmountOrganizationList(node);
1284
- } else {
1285
- this.premountOrganizationListNodes.delete(node);
1286
- }
1287
- };
1288
- this.mountUserButton = (node, userButtonProps) => {
1289
- if (this.clerkjs && this.loaded) {
1290
- this.clerkjs.mountUserButton(node, userButtonProps);
1291
- } else {
1292
- this.premountUserButtonNodes.set(node, userButtonProps);
1293
- }
1294
- };
1295
- this.unmountUserButton = (node) => {
1296
- if (this.clerkjs && this.loaded) {
1297
- this.clerkjs.unmountUserButton(node);
1298
- } else {
1299
- this.premountUserButtonNodes.delete(node);
1300
- }
1301
- };
1302
- this.mountWaitlist = (node, props) => {
1303
- if (this.clerkjs && this.loaded) {
1304
- this.clerkjs.mountWaitlist(node, props);
1305
- } else {
1306
- this.premountWaitlistNodes.set(node, props);
1307
- }
1308
- };
1309
- this.unmountWaitlist = (node) => {
1310
- if (this.clerkjs && this.loaded) {
1311
- this.clerkjs.unmountWaitlist(node);
1312
- } else {
1313
- this.premountWaitlistNodes.delete(node);
1314
- }
1315
- };
1316
- this.mountPricingTable = (node, props) => {
1317
- if (this.clerkjs && this.loaded) {
1318
- this.clerkjs.mountPricingTable(node, props);
1319
- } else {
1320
- this.premountPricingTableNodes.set(node, props);
1321
- }
1322
- };
1323
- this.unmountPricingTable = (node) => {
1324
- if (this.clerkjs && this.loaded) {
1325
- this.clerkjs.unmountPricingTable(node);
1326
- } else {
1327
- this.premountPricingTableNodes.delete(node);
1328
- }
1329
- };
1330
- this.mountAPIKeys = (node, props) => {
1331
- if (this.clerkjs && this.loaded) {
1332
- this.clerkjs.mountAPIKeys(node, props);
1333
- } else {
1334
- this.premountAPIKeysNodes.set(node, props);
1335
- }
1336
- };
1337
- this.unmountAPIKeys = (node) => {
1338
- if (this.clerkjs && this.loaded) {
1339
- this.clerkjs.unmountAPIKeys(node);
1340
- } else {
1341
- this.premountAPIKeysNodes.delete(node);
1342
- }
1343
- };
1344
- this.__internal_mountConfigureSSO = (node, props) => {
1345
- if (this.clerkjs && this.loaded) {
1346
- this.clerkjs.__internal_mountConfigureSSO(node, props);
1347
- } else {
1348
- this.premountConfigureSSONodes.set(node, props);
1349
- }
1350
- };
1351
- this.__internal_unmountConfigureSSO = (node) => {
1352
- if (this.clerkjs && this.loaded) {
1353
- this.clerkjs.__internal_unmountConfigureSSO(node);
1354
- } else {
1355
- this.premountConfigureSSONodes.delete(node);
1356
- }
1357
- };
1358
- this.__internal_mountOAuthConsent = (node, props) => {
1359
- if (this.clerkjs && this.loaded) {
1360
- this.clerkjs.__internal_mountOAuthConsent(node, props);
1361
- } else {
1362
- this.premountOAuthConsentNodes.set(node, props);
1363
- }
1364
- };
1365
- this.__internal_unmountOAuthConsent = (node) => {
1366
- if (this.clerkjs && this.loaded) {
1367
- this.clerkjs.__internal_unmountOAuthConsent(node);
1368
- } else {
1369
- this.premountOAuthConsentNodes.delete(node);
1370
- }
1371
- };
1372
- this.mountOAuthConsent = (node, props) => {
1373
- this.__internal_mountOAuthConsent(node, props);
1374
- };
1375
- this.unmountOAuthConsent = (node) => {
1376
- this.__internal_unmountOAuthConsent(node);
1377
- };
1378
- this.mountTaskChooseOrganization = (node, props) => {
1379
- if (this.clerkjs && this.loaded) {
1380
- this.clerkjs.mountTaskChooseOrganization(node, props);
1381
- } else {
1382
- this.premountTaskChooseOrganizationNodes.set(node, props);
1383
- }
1384
- };
1385
- this.unmountTaskChooseOrganization = (node) => {
1386
- if (this.clerkjs && this.loaded) {
1387
- this.clerkjs.unmountTaskChooseOrganization(node);
1388
- } else {
1389
- this.premountTaskChooseOrganizationNodes.delete(node);
1390
- }
1391
- };
1392
- this.mountTaskResetPassword = (node, props) => {
1393
- if (this.clerkjs && this.loaded) {
1394
- this.clerkjs.mountTaskResetPassword(node, props);
1395
- } else {
1396
- this.premountTaskResetPasswordNodes.set(node, props);
1397
- }
1398
- };
1399
- this.unmountTaskResetPassword = (node) => {
1400
- if (this.clerkjs && this.loaded) {
1401
- this.clerkjs.unmountTaskResetPassword(node);
1402
- } else {
1403
- this.premountTaskResetPasswordNodes.delete(node);
1404
- }
1405
- };
1406
- this.mountTaskSetupMFA = (node, props) => {
1407
- if (this.clerkjs && this.loaded) {
1408
- this.clerkjs.mountTaskSetupMFA(node, props);
1409
- } else {
1410
- this.premountTaskSetupMFANodes.set(node, props);
1411
- }
1412
- };
1413
- this.unmountTaskSetupMFA = (node) => {
1414
- if (this.clerkjs && this.loaded) {
1415
- this.clerkjs.unmountTaskSetupMFA(node);
1416
- } else {
1417
- this.premountTaskSetupMFANodes.delete(node);
1418
- }
1419
- };
1420
- this.addListener = (listener, options) => {
1421
- if (this.clerkjs) {
1422
- return this.clerkjs.addListener(listener, options);
1423
- } else {
1424
- const unsubscribe = () => {
1425
- var _a, _b;
1426
- const listenerExtras = this.premountAddListenerCalls.get(listener);
1427
- if (listenerExtras == null ? void 0 : listenerExtras.handlers) {
1428
- (_b = listenerExtras == null ? void 0 : (_a = listenerExtras.handlers).nativeUnsubscribe) == null ? void 0 : _b.call(_a);
1429
- this.premountAddListenerCalls.delete(listener);
1430
- }
1431
- };
1432
- this.premountAddListenerCalls.set(listener, { options, handlers: { unsubscribe, nativeUnsubscribe: void 0 } });
1433
- return unsubscribe;
1434
- }
1435
- };
1436
- this.navigate = (to) => {
1437
- const callback = () => {
1438
- var _a;
1439
- return (_a = this.clerkjs) == null ? void 0 : _a.navigate(to);
1440
- };
1441
- if (this.clerkjs && this.loaded) {
1442
- void callback();
1443
- } else {
1444
- this.premountMethodCalls.set("navigate", callback);
1445
- }
1446
- };
1447
- this.redirectWithAuth = async (...args) => {
1448
- const callback = () => {
1449
- var _a;
1450
- return (_a = this.clerkjs) == null ? void 0 : _a.redirectWithAuth(...args);
1451
- };
1452
- if (this.clerkjs && this.loaded) {
1453
- return callback();
1454
- } else {
1455
- this.premountMethodCalls.set("redirectWithAuth", callback);
1456
- return;
1457
- }
1458
- };
1459
- this.redirectToSignIn = async (opts) => {
1460
- const callback = () => {
1461
- var _a;
1462
- return (_a = this.clerkjs) == null ? void 0 : _a.redirectToSignIn(opts);
1463
- };
1464
- if (this.clerkjs && this.loaded) {
1465
- return callback();
1466
- } else {
1467
- this.premountMethodCalls.set("redirectToSignIn", callback);
1468
- return;
1469
- }
1470
- };
1471
- this.redirectToSignUp = async (opts) => {
1472
- const callback = () => {
1473
- var _a;
1474
- return (_a = this.clerkjs) == null ? void 0 : _a.redirectToSignUp(opts);
1475
- };
1476
- if (this.clerkjs && this.loaded) {
1477
- return callback();
1478
- } else {
1479
- this.premountMethodCalls.set("redirectToSignUp", callback);
1480
- return;
1481
- }
1482
- };
1483
- this.redirectToUserProfile = async () => {
1484
- const callback = () => {
1485
- var _a;
1486
- return (_a = this.clerkjs) == null ? void 0 : _a.redirectToUserProfile();
1487
- };
1488
- if (this.clerkjs && this.loaded) {
1489
- return callback();
1490
- } else {
1491
- this.premountMethodCalls.set("redirectToUserProfile", callback);
1492
- return;
1493
- }
1494
- };
1495
- this.redirectToAfterSignUp = () => {
1496
- const callback = () => {
1497
- var _a;
1498
- return (_a = this.clerkjs) == null ? void 0 : _a.redirectToAfterSignUp();
1499
- };
1500
- if (this.clerkjs && this.loaded) {
1501
- return callback();
1502
- } else {
1503
- this.premountMethodCalls.set("redirectToAfterSignUp", callback);
1504
- }
1505
- };
1506
- this.redirectToAfterSignIn = () => {
1507
- const callback = () => {
1508
- var _a;
1509
- return (_a = this.clerkjs) == null ? void 0 : _a.redirectToAfterSignIn();
1510
- };
1511
- if (this.clerkjs && this.loaded) {
1512
- callback();
1513
- } else {
1514
- this.premountMethodCalls.set("redirectToAfterSignIn", callback);
1515
- }
1516
- };
1517
- this.redirectToAfterSignOut = () => {
1518
- const callback = () => {
1519
- var _a;
1520
- return (_a = this.clerkjs) == null ? void 0 : _a.redirectToAfterSignOut();
1521
- };
1522
- if (this.clerkjs && this.loaded) {
1523
- callback();
1524
- } else {
1525
- this.premountMethodCalls.set("redirectToAfterSignOut", callback);
1526
- }
1527
- };
1528
- this.redirectToOrganizationProfile = async () => {
1529
- const callback = () => {
1530
- var _a;
1531
- return (_a = this.clerkjs) == null ? void 0 : _a.redirectToOrganizationProfile();
1532
- };
1533
- if (this.clerkjs && this.loaded) {
1534
- return callback();
1535
- } else {
1536
- this.premountMethodCalls.set("redirectToOrganizationProfile", callback);
1537
- return;
1538
- }
1539
- };
1540
- this.redirectToCreateOrganization = async () => {
1541
- const callback = () => {
1542
- var _a;
1543
- return (_a = this.clerkjs) == null ? void 0 : _a.redirectToCreateOrganization();
1544
- };
1545
- if (this.clerkjs && this.loaded) {
1546
- return callback();
1547
- } else {
1548
- this.premountMethodCalls.set("redirectToCreateOrganization", callback);
1549
- return;
1550
- }
1551
- };
1552
- this.redirectToWaitlist = async () => {
1553
- const callback = () => {
1554
- var _a;
1555
- return (_a = this.clerkjs) == null ? void 0 : _a.redirectToWaitlist();
1556
- };
1557
- if (this.clerkjs && this.loaded) {
1558
- return callback();
1559
- } else {
1560
- this.premountMethodCalls.set("redirectToWaitlist", callback);
1561
- return;
1562
- }
1563
- };
1564
- this.redirectToTasks = async (opts) => {
1565
- const callback = () => {
1566
- var _a;
1567
- return (_a = this.clerkjs) == null ? void 0 : _a.redirectToTasks(opts);
1568
- };
1569
- if (this.clerkjs && this.loaded) {
1570
- return callback();
1571
- } else {
1572
- this.premountMethodCalls.set("redirectToTasks", callback);
1573
- return;
1574
- }
1575
- };
1576
- this.handleRedirectCallback = async (params) => {
1577
- var _a;
1578
- const callback = () => {
1579
- var _a2;
1580
- return (_a2 = this.clerkjs) == null ? void 0 : _a2.handleRedirectCallback(params);
1581
- };
1582
- if (this.clerkjs && this.loaded) {
1583
- void ((_a = callback()) == null ? void 0 : _a.catch(() => {
1584
- }));
1585
- } else {
1586
- this.premountMethodCalls.set("handleRedirectCallback", callback);
1587
- }
1588
- };
1589
- this.handleGoogleOneTapCallback = async (signInOrUp, params) => {
1590
- var _a;
1591
- const callback = () => {
1592
- var _a2;
1593
- return (_a2 = this.clerkjs) == null ? void 0 : _a2.handleGoogleOneTapCallback(signInOrUp, params);
1594
- };
1595
- if (this.clerkjs && this.loaded) {
1596
- void ((_a = callback()) == null ? void 0 : _a.catch(() => {
1597
- }));
1598
- } else {
1599
- this.premountMethodCalls.set("handleGoogleOneTapCallback", callback);
1600
- }
1601
- };
1602
- this.handleEmailLinkVerification = async (params) => {
1603
- const callback = () => {
1604
- var _a;
1605
- return (_a = this.clerkjs) == null ? void 0 : _a.handleEmailLinkVerification(params);
1606
- };
1607
- if (this.clerkjs && this.loaded) {
1608
- return callback();
1609
- } else {
1610
- this.premountMethodCalls.set("handleEmailLinkVerification", callback);
1611
- }
1612
- };
1613
- this.authenticateWithMetamask = async (params) => {
1614
- const callback = () => {
1615
- var _a;
1616
- return (_a = this.clerkjs) == null ? void 0 : _a.authenticateWithMetamask(params);
1617
- };
1618
- if (this.clerkjs && this.loaded) {
1619
- return callback();
1620
- } else {
1621
- this.premountMethodCalls.set("authenticateWithMetamask", callback);
1622
- }
1623
- };
1624
- this.authenticateWithCoinbaseWallet = async (params) => {
1625
- const callback = () => {
1626
- var _a;
1627
- return (_a = this.clerkjs) == null ? void 0 : _a.authenticateWithCoinbaseWallet(params);
1628
- };
1629
- if (this.clerkjs && this.loaded) {
1630
- return callback();
1631
- } else {
1632
- this.premountMethodCalls.set("authenticateWithCoinbaseWallet", callback);
1633
- }
1634
- };
1635
- this.authenticateWithBase = async (params) => {
1636
- const callback = () => {
1637
- var _a;
1638
- return (_a = this.clerkjs) == null ? void 0 : _a.authenticateWithBase(params);
1639
- };
1640
- if (this.clerkjs && this.loaded) {
1641
- return callback();
1642
- } else {
1643
- this.premountMethodCalls.set("authenticateWithBase", callback);
1644
- }
1645
- };
1646
- this.authenticateWithOKXWallet = async (params) => {
1647
- const callback = () => {
1648
- var _a;
1649
- return (_a = this.clerkjs) == null ? void 0 : _a.authenticateWithOKXWallet(params);
1650
- };
1651
- if (this.clerkjs && this.loaded) {
1652
- return callback();
1653
- } else {
1654
- this.premountMethodCalls.set("authenticateWithOKXWallet", callback);
1655
- }
1656
- };
1657
- this.authenticateWithSolana = async (params) => {
1658
- const callback = () => {
1659
- var _a;
1660
- return (_a = this.clerkjs) == null ? void 0 : _a.authenticateWithSolana(params);
1661
- };
1662
- if (this.clerkjs && this.loaded) {
1663
- return callback();
1664
- } else {
1665
- this.premountMethodCalls.set("authenticateWithSolana", callback);
1666
- }
1667
- };
1668
- this.authenticateWithWeb3 = async (params) => {
1669
- const callback = () => {
1670
- var _a;
1671
- return (_a = this.clerkjs) == null ? void 0 : _a.authenticateWithWeb3(params);
1672
- };
1673
- if (this.clerkjs && this.loaded) {
1674
- return callback();
1675
- } else {
1676
- this.premountMethodCalls.set("authenticateWithWeb3", callback);
1677
- }
1678
- };
1679
- this.authenticateWithGoogleOneTap = async (params) => {
1680
- const clerkjs = await __privateMethod(this, _IsomorphicClerk_instances, waitForClerkJS_fn).call(this);
1681
- return clerkjs.authenticateWithGoogleOneTap(params);
1682
- };
1683
- this.__internal_loadStripeJs = async () => {
1684
- const clerkjs = await __privateMethod(this, _IsomorphicClerk_instances, waitForClerkJS_fn).call(this);
1685
- return clerkjs.__internal_loadStripeJs();
1686
- };
1687
- this.createOrganization = async (params) => {
1688
- const callback = () => {
1689
- var _a;
1690
- return (_a = this.clerkjs) == null ? void 0 : _a.createOrganization(params);
1691
- };
1692
- if (this.clerkjs && this.loaded) {
1693
- return callback();
1694
- } else {
1695
- this.premountMethodCalls.set("createOrganization", callback);
1696
- }
1697
- };
1698
- this.getOrganization = async (organizationId) => {
1699
- const callback = () => {
1700
- var _a;
1701
- return (_a = this.clerkjs) == null ? void 0 : _a.getOrganization(organizationId);
1702
- };
1703
- if (this.clerkjs && this.loaded) {
1704
- return callback();
1705
- } else {
1706
- this.premountMethodCalls.set("getOrganization", callback);
1707
- }
1708
- };
1709
- this.joinWaitlist = async (params) => {
1710
- const callback = () => {
1711
- var _a;
1712
- return (_a = this.clerkjs) == null ? void 0 : _a.joinWaitlist(params);
1713
- };
1714
- if (this.clerkjs && this.loaded) {
1715
- return callback();
1716
- } else {
1717
- this.premountMethodCalls.set("joinWaitlist", callback);
1718
- }
1719
- };
1720
- this.signOut = async (...args) => {
1721
- const callback = () => {
1722
- var _a;
1723
- return (_a = this.clerkjs) == null ? void 0 : _a.signOut(...args);
1724
- };
1725
- if (this.clerkjs && this.loaded) {
1726
- return callback();
1727
- } else {
1728
- this.premountMethodCalls.set("signOut", callback);
1729
- }
1730
- };
1731
- this.__internal_attemptToEnableEnvironmentSetting = (options) => {
1732
- const callback = () => {
1733
- var _a;
1734
- return (_a = this.clerkjs) == null ? void 0 : _a.__internal_attemptToEnableEnvironmentSetting(options);
1735
- };
1736
- if (this.clerkjs && this.loaded) {
1737
- return callback();
1738
- } else {
1739
- this.premountMethodCalls.set("__internal_attemptToEnableEnvironmentSetting", callback);
1740
- }
1741
- };
1742
- var _a;
1743
- __privateSet(this, _publishableKey, options == null ? void 0 : options.publishableKey);
1744
- __privateSet(this, _proxyUrl, options == null ? void 0 : options.proxyUrl);
1745
- __privateSet(this, _domain, options == null ? void 0 : options.domain);
1746
- this.options = options;
1747
- this.Clerk = (options == null ? void 0 : options.Clerk) || null;
1748
- this.mode = inBrowser2() ? "browser" : "server";
1749
- __privateSet(this, _stateProxy, new StateProxy(this));
1750
- if (!this.options.sdkMetadata) {
1751
- this.options.sdkMetadata = SDK_METADATA;
1752
- }
1753
- __privateGet(this, _eventBus).emit(clerkEvents.Status, "loading");
1754
- __privateGet(this, _eventBus).prioritizedOn(clerkEvents.Status, (status) => __privateSet(this, _status, status));
1755
- if (__privateGet(this, _publishableKey) && ((_a = this.options.experimental) == null ? void 0 : _a.runtimeEnvironment) === "headless" && this.options.Clerk) {
1756
- void this.loadHeadlessClerk();
1757
- } else if (__privateGet(this, _publishableKey)) {
1758
- void this.getEntryChunks();
1759
- }
1760
- }
1761
- get publishableKey() {
1762
- return __privateGet(this, _publishableKey);
1763
- }
1764
- get loaded() {
1765
- var _a;
1766
- return ((_a = this.clerkjs) == null ? void 0 : _a.loaded) || false;
1767
- }
1768
- get status() {
1769
- var _a;
1770
- if (!this.clerkjs) {
1771
- return __privateGet(this, _status);
1772
- }
1773
- return ((_a = this.clerkjs) == null ? void 0 : _a.status) || /**
1774
- * Support older clerk-js versions.
1775
- * If clerk-js is available but `.status` is missing it we need to fallback to `.loaded`.
1776
- * Since "degraded" an "error" did not exist before,
1777
- * map "loaded" to "ready" and "not loaded" to "loading".
1778
- */
1779
- (this.clerkjs.loaded ? "ready" : "loading");
1780
- }
1781
- static getOrCreateInstance(options) {
1782
- if (!inBrowser2() || !__privateGet(this, _instance) || options.Clerk && __privateGet(this, _instance).Clerk !== options.Clerk || // Allow hot swapping PKs on the client
1783
- __privateGet(this, _instance).publishableKey !== options.publishableKey) {
1784
- __privateSet(this, _instance, new _IsomorphicClerk(options));
1785
- }
1786
- return __privateGet(this, _instance);
1787
- }
1788
- static clearInstance() {
1789
- __privateSet(this, _instance, null);
1790
- }
1791
- get domain() {
1792
- if (typeof window !== "undefined" && window.location) {
1793
- return handleValueOrFn(__privateGet(this, _domain), new URL(window.location.href), "");
1794
- }
1795
- if (typeof __privateGet(this, _domain) === "function") {
1796
- return errorThrower.throw(unsupportedNonBrowserDomainOrProxyUrlFunction);
1797
- }
1798
- return __privateGet(this, _domain) || "";
1799
- }
1800
- get proxyUrl() {
1801
- if (typeof window !== "undefined" && window.location) {
1802
- return handleValueOrFn(__privateGet(this, _proxyUrl), new URL(window.location.href), "");
1803
- }
1804
- if (typeof __privateGet(this, _proxyUrl) === "function") {
1805
- return errorThrower.throw(unsupportedNonBrowserDomainOrProxyUrlFunction);
1806
- }
1807
- return __privateGet(this, _proxyUrl) || "";
1808
- }
1809
- /**
1810
- * Accesses private options from the `Clerk` instance and defaults to
1811
- * `IsomorphicClerk` options when in SSR context.
1812
- * @internal
1813
- */
1814
- __internal_getOption(key) {
1815
- var _a, _b;
1816
- return ((_a = this.clerkjs) == null ? void 0 : _a.__internal_getOption) ? (_b = this.clerkjs) == null ? void 0 : _b.__internal_getOption(key) : this.options[key];
1817
- }
1818
- /**
1819
- * Initialize Clerk for headless/React Native environments where a Clerk instance is provided directly.
1820
- * Only handles Clerk construction and loading — post-load wiring is shared via replayInterceptedInvocations.
1821
- */
1822
- loadHeadlessClerk() {
1823
- const clerk = isConstructor(this.options.Clerk) ? new this.options.Clerk(__privateGet(this, _publishableKey), { proxyUrl: this.proxyUrl, domain: this.domain }) : this.options.Clerk;
1824
- if (!clerk) {
1825
- __privateGet(this, _eventBus).emit(clerkEvents.Status, "error");
1826
- return;
1827
- }
1828
- const onLoaded = () => {
1829
- this.replayInterceptedInvocations(clerk);
1830
- };
1831
- if (!clerk.loaded) {
1832
- clerk.load(this.options).then(() => onLoaded()).catch((err) => {
1833
- if (false) {
1834
- console.error("Clerk: Failed to load:", err);
1835
- }
1836
- __privateGet(this, _eventBus).emit(clerkEvents.Status, "error");
1837
- this.emitLoaded();
1838
- });
1839
- } else {
1840
- onLoaded();
1841
- }
1842
- }
1843
- get sdkMetadata() {
1844
- var _a;
1845
- return ((_a = this.clerkjs) == null ? void 0 : _a.sdkMetadata) || this.options.sdkMetadata || void 0;
1846
- }
1847
- get instanceType() {
1848
- var _a;
1849
- return (_a = this.clerkjs) == null ? void 0 : _a.instanceType;
1850
- }
1851
- get frontendApi() {
1852
- var _a;
1853
- return ((_a = this.clerkjs) == null ? void 0 : _a.frontendApi) || "";
1854
- }
1855
- get isStandardBrowser() {
1856
- var _a;
1857
- return ((_a = this.clerkjs) == null ? void 0 : _a.isStandardBrowser) || this.options.standardBrowser || false;
1858
- }
1859
- get isSatellite() {
1860
- if (typeof window !== "undefined" && window.location) {
1861
- return handleValueOrFn(this.options.isSatellite, new URL(window.location.href), false);
1862
- }
1863
- if (typeof this.options.isSatellite === "function") {
1864
- return errorThrower.throw(unsupportedNonBrowserDomainOrProxyUrlFunction);
1865
- }
1866
- return false;
1867
- }
1868
- async getEntryChunks() {
1869
- var _a;
1870
- if (this.mode !== "browser" || this.loaded) {
1871
- return;
1872
- }
1873
- if (typeof window !== "undefined") {
1874
- window.__clerk_publishable_key = __privateGet(this, _publishableKey);
1875
- window.__clerk_proxy_url = this.proxyUrl;
1876
- window.__clerk_domain = this.domain;
1877
- }
1878
- try {
1879
- const clerk = await this.getClerkJsEntryChunk();
1880
- if (!clerk.loaded) {
1881
- this.beforeLoad(clerk);
1882
- const shouldLoadUi = this.options.standardBrowser !== false && !this.options.Clerk || !!((_a = this.options.ui) == null ? void 0 : _a.ClerkUI);
1883
- const ClerkUI = shouldLoadUi ? await this.getClerkUIEntryChunk() : void 0;
1884
- await clerk.load({ ...this.options, ui: { ...this.options.ui, ClerkUI } });
1885
- }
1886
- if (clerk.loaded) {
1887
- this.replayInterceptedInvocations(clerk);
1888
- }
1889
- } catch (err) {
1890
- const error = err;
1891
- __privateGet(this, _eventBus).emit(clerkEvents.Status, "error");
1892
- console.error(error.stack || error.message || error);
1893
- return;
1894
- }
1895
- }
1896
- async getClerkJsEntryChunk() {
1897
- if ((!this.options.Clerk || this.options.__internal_clerkJSUrl) && !__BUILD_DISABLE_RHC__) {
1898
- await loadClerkJSScript({
1899
- ...this.options,
1900
- publishableKey: __privateGet(this, _publishableKey),
1901
- proxyUrl: this.proxyUrl,
1902
- domain: this.domain,
1903
- nonce: this.options.nonce
1904
- });
1905
- }
1906
- if (this.options.Clerk && !this.options.__internal_clerkJSUrl) {
1907
- global.Clerk = isConstructor(this.options.Clerk) ? new this.options.Clerk(__privateGet(this, _publishableKey), { proxyUrl: this.proxyUrl, domain: this.domain }) : this.options.Clerk;
1908
- }
1909
- if (!global.Clerk) {
1910
- throw new Error("Failed to download latest ClerkJS. Contact support@clerk.com.");
1911
- }
1912
- return global.Clerk;
1913
- }
1914
- async getClerkUIEntryChunk() {
1915
- const uiProp = this.options.ui;
1916
- const hasInternalUrl = !!this.options.__internal_clerkUIUrl;
1917
- if ((uiProp == null ? void 0 : uiProp.ClerkUI) && !hasInternalUrl) {
1918
- return uiProp.ClerkUI;
1919
- }
1920
- if ((uiProp || this.options.prefetchUI === false) && !hasInternalUrl) {
1921
- return void 0;
1922
- }
1923
- if (!__BUILD_DISABLE_RHC__) {
1924
- await loadClerkUIScript({
1925
- ...this.options,
1926
- publishableKey: __privateGet(this, _publishableKey),
1927
- proxyUrl: this.proxyUrl,
1928
- domain: this.domain,
1929
- nonce: this.options.nonce
1930
- });
1931
- if (!global.__internal_ClerkUICtor) {
1932
- throw new Error("Failed to download latest Clerk UI. Contact support@clerk.com.");
1933
- }
1934
- return global.__internal_ClerkUICtor;
1935
- }
1936
- return void 0;
1937
- }
1938
- get version() {
1939
- var _a;
1940
- return (_a = this.clerkjs) == null ? void 0 : _a.version;
1941
- }
1942
- get client() {
1943
- if (this.clerkjs) {
1944
- return this.clerkjs.client;
1945
- } else {
1946
- return void 0;
1947
- }
1948
- }
1949
- get session() {
1950
- if (this.clerkjs) {
1951
- return this.clerkjs.session;
1952
- } else {
1953
- return void 0;
1954
- }
1955
- }
1956
- get user() {
1957
- if (this.clerkjs) {
1958
- return this.clerkjs.user;
1959
- } else {
1960
- return void 0;
1961
- }
1962
- }
1963
- get organization() {
1964
- if (this.clerkjs) {
1965
- return this.clerkjs.organization;
1966
- } else {
1967
- return void 0;
1968
- }
1969
- }
1970
- get telemetry() {
1971
- if (this.clerkjs) {
1972
- return this.clerkjs.telemetry;
1973
- } else {
1974
- return void 0;
1975
- }
1976
- }
1977
- get __internal_environment() {
1978
- if (this.clerkjs) {
1979
- return this.clerkjs.__internal_environment;
1980
- } else {
1981
- return void 0;
1982
- }
1983
- }
1984
- get isSignedIn() {
1985
- if (this.clerkjs) {
1986
- return this.clerkjs.isSignedIn;
1987
- } else {
1988
- return false;
1989
- }
1990
- }
1991
- get billing() {
1992
- var _a;
1993
- return (_a = this.clerkjs) == null ? void 0 : _a.billing;
1994
- }
1995
- get __internal_state() {
1996
- return this.loaded && this.clerkjs ? this.clerkjs.__internal_state : __privateGet(this, _stateProxy);
1997
- }
1998
- get apiKeys() {
1999
- var _a;
2000
- return (_a = this.clerkjs) == null ? void 0 : _a.apiKeys;
2001
- }
2002
- get oauthApplication() {
2003
- var _a;
2004
- return (_a = this.clerkjs) == null ? void 0 : _a.oauthApplication;
2005
- }
2006
- __internal_setEnvironment(...args) {
2007
- if (this.clerkjs && "__internal_setEnvironment" in this.clerkjs) {
2008
- this.clerkjs.__internal_setEnvironment(args);
2009
- } else {
2010
- return void 0;
2011
- }
2012
- }
2013
- get __internal_lastEmittedResources() {
2014
- var _a;
2015
- return (_a = this.clerkjs) == null ? void 0 : _a.__internal_lastEmittedResources;
2016
- }
2017
- };
2018
- _status = new WeakMap();
2019
- _domain = new WeakMap();
2020
- _proxyUrl = new WeakMap();
2021
- _publishableKey = new WeakMap();
2022
- _eventBus = new WeakMap();
2023
- _stateProxy = new WeakMap();
2024
- _instance = new WeakMap();
2025
- _IsomorphicClerk_instances = new WeakSet();
2026
- waitForClerkJS_fn = function() {
2027
- return new Promise((resolve) => {
2028
- this.addOnLoaded(() => resolve(this.clerkjs));
2029
- });
2030
- };
2031
- __privateAdd(_IsomorphicClerk, _instance);
2032
- var IsomorphicClerk = _IsomorphicClerk;
2033
-
2034
- // src/contexts/ClerkProvider.tsx
2035
- function ClerkProviderBase(props) {
2036
- const { initialState, children, ...restIsomorphicClerkOptions } = props;
2037
- const mergedOptions = mergeWithEnv(restIsomorphicClerkOptions);
2038
- const { isomorphicClerk, clerkStatus } = useLoadedIsomorphicClerk(mergedOptions);
2039
- return /* @__PURE__ */ React3.createElement(
2040
- ClerkContextProvider,
2041
- {
2042
- initialState,
2043
- clerk: isomorphicClerk,
2044
- clerkStatus
2045
- },
2046
- children
2047
- );
2048
- }
2049
- var ClerkProvider = withMaxAllowedInstancesGuard(ClerkProviderBase, "ClerkProvider", multipleClerkProvidersError);
2050
- ClerkProvider.displayName = "ClerkProvider";
2051
- var DEFAULT_CLERK_UI_VARIANT = IS_REACT_SHARED_VARIANT_COMPATIBLE ? "shared" : "";
2052
- var useLoadedIsomorphicClerk = (mergedOptions) => {
2053
- const optionsWithDefaults = React3.useMemo(
2054
- () => ({
2055
- clerkUIVariant: DEFAULT_CLERK_UI_VARIANT,
2056
- ...mergedOptions
2057
- }),
2058
- [mergedOptions]
2059
- );
2060
- const isomorphicClerkRef = React3.useRef(IsomorphicClerk.getOrCreateInstance(optionsWithDefaults));
2061
- const [clerkStatus, setClerkStatus] = React3.useState(isomorphicClerkRef.current.status);
2062
- React3.useEffect(() => {
2063
- void isomorphicClerkRef.current.__internal_updateProps({ appearance: mergedOptions.appearance });
2064
- }, [mergedOptions.appearance]);
2065
- React3.useEffect(() => {
2066
- void isomorphicClerkRef.current.__internal_updateProps({ options: mergedOptions });
2067
- }, [mergedOptions.localization]);
2068
- React3.useEffect(() => {
2069
- isomorphicClerkRef.current.on("status", setClerkStatus);
2070
- return () => {
2071
- if (isomorphicClerkRef.current) {
2072
- isomorphicClerkRef.current.off("status", setClerkStatus);
2073
- }
2074
- IsomorphicClerk.clearInstance();
2075
- };
2076
- }, []);
2077
- return { isomorphicClerk: isomorphicClerkRef.current, clerkStatus };
2078
- };
2079
-
2080
- export {
2081
- ClerkLoaded,
2082
- ClerkLoading,
2083
- ClerkFailed,
2084
- ClerkDegraded,
2085
- Show,
2086
- RedirectToSignIn,
2087
- RedirectToSignUp,
2088
- RedirectToTasks,
2089
- RedirectToUserProfile,
2090
- RedirectToOrganizationProfile,
2091
- RedirectToCreateOrganization,
2092
- AuthenticateWithRedirectCallback,
2093
- MultisessionAppSupport,
2094
- IS_REACT_SHARED_VARIANT_COMPATIBLE,
2095
- ClerkProvider
2096
- };
2097
- //# sourceMappingURL=chunk-GVGS7DUS.mjs.map