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